From acfee0da561d8e210cf57196e047b5f5f246a680 Mon Sep 17 00:00:00 2001 From: Fangfei Yang Date: Mon, 2 Nov 2020 23:48:02 -0600 Subject: [PATCH 1/2] [ADD] Ghidra decompile result --- blobs/bl602_demo_at.ghidra.c | 157775 +++++++++++++++++++++++++++++ blobs/bl602_demo_at.ghidra.h | 69201 +++++++++++++ blobs/bl602_demo_wifi.ghidra.c | 104853 +++++++++++++++++++ blobs/bl602_demo_wifi.ghidra.h | 41930 ++++++++ blobs/sdk_app_ble_sync.ghidra.c | 100977 ++++++++++++++++++ blobs/sdk_app_ble_sync.ghidra.h | 39238 +++++++ 6 files changed, 513974 insertions(+) create mode 100755 blobs/bl602_demo_at.ghidra.c create mode 100755 blobs/bl602_demo_at.ghidra.h create mode 100755 blobs/bl602_demo_wifi.ghidra.c create mode 100755 blobs/bl602_demo_wifi.ghidra.h create mode 100755 blobs/sdk_app_ble_sync.ghidra.c create mode 100755 blobs/sdk_app_ble_sync.ghidra.h diff --git a/blobs/bl602_demo_at.ghidra.c b/blobs/bl602_demo_at.ghidra.c new file mode 100755 index 0000000..143bd7a --- /dev/null +++ b/blobs/bl602_demo_at.ghidra.c @@ -0,0 +1,157775 @@ +#include "bl602_demo_at.ghidra.h" + + + +// WARNING: Removing unreachable block (ram,0x230000d8) + +void bl602_start(void) + +{ + uint32_t *puVar1; + undefined4 *puVar2; + uint8_t *puVar3; + ipc_shared_env_tag *piVar4; + anon_struct_conflict529 *paVar5; + anon_struct_conflict530 *paVar6; + code *pcVar7; + + puVar2 = (undefined4 *)&__boot2_pt_addr_src; + paVar5 = &boot2_partition_table; + do { + *(undefined4 *)paVar5 = *puVar2; + puVar2 = puVar2 + 1; + paVar5 = (anon_struct_conflict529 *)&paVar5->table; + } while (paVar5 < &boot2_flashCfg); + puVar1 = (uint32_t *)hal_boot2_get_flash_addr(); + paVar6 = &boot2_flashCfg; + do { + paVar6->magic = *puVar1; + puVar1 = puVar1 + 1; + paVar6 = (anon_struct_conflict530 *)&paVar6->flashCfg; + } while (paVar6 < &ble_sync_auto); + puVar2 = (undefined4 *)&_bl_static_blogfile_code_end; + pcVar7 = AON_Power_On_BG; + do { + *(undefined4 *)pcVar7 = *puVar2; + puVar2 = puVar2 + 1; + pcVar7 = (code *)&((anon_struct_conflict529 *)pcVar7)->table; + } while (pcVar7 < &boot2_partition_table); + puVar3 = &ble_sync_auto; + do { + *(undefined4 *)puVar3 = 0; + puVar3 = (uint8_t *)((undefined4 *)puVar3 + 1); + } while (puVar3 < &__bss_end); + piVar4 = &ipc_shared_env; + do { + (piVar4->msg_a2e_buf).dummy_word = 0; + piVar4 = (ipc_shared_env_tag *)(piVar4->msg_a2e_buf).msg; + } while (piVar4 < (ipc_shared_env_tag *)&_heap_wifi_start); + DAT_4203fff8 = 0x230000e8; + bfl_main(0,0); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void cmd_free_mem(char *buf,int len,int argc,char **argv) + +{ + size_t sVar1; + + sVar1 = xPortGetFreeHeapSize(); + printf("free memory is %d\r\n",sVar1); + return; +} + + + +void cmd_stack_ble(void) + +{ + ble_controller_init('\x1f'); + hci_driver_init(); + bt_enable(bt_enable_cb); + return; +} + + + +void cmd_stack_wifi(char *buf,int len,int argc,char **argv) + +{ + uint8_t stack_wifi_init; + + if (stack_wifi_init == '\x01') { + puts("Wi-Fi Stack Started already!!!\r\n"); + return; + } + stack_wifi_init = '\x01'; + hal_wifi_start_firmware_task(); + aos_post_event(2,1,0); + return; +} + + + +void scan_complete_cb(void *p_arg,void *param) + +{ + wifi_mgmr_scan_ap_all((wifi_mgmr_ap_item_t *)0x0,(uint32_t *)p_arg,scan_item_cb); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void scan_item_cb(wifi_mgmr_ap_item_t *env,uint32_t *param1,wifi_mgmr_ap_item_t *item) + +{ + undefined auStack64 [4]; + _wifi_item_t wifi_item; + + wifi_item.bssid[4] = item->rssi; + wifi_item.bssid._2_2_ = *(undefined2 *)&item->channel; + wifi_item.ssid._28_4_ = item->ssid_len; + memcpy(auStack64,item,0x20); + memcpy(&wifi_item.ssid_len,item->bssid,6); + if (param1 != (uint32_t *)0x0) { + (*(code *)param1)(auStack64); + } + return; +} + + + +void wifiprov_wifi_state_get(void *p_arg) + +{ + char *__src; + int iStack296; + int tmp_state; + ip4_addr_t ip; + ip4_addr_t gw; + ip4_addr_t mask; + _wifi_state state; + wifi_mgmr_sta_connect_ind_stat_info_t info; + + memset(&mask,0,0x58); + memset(state.bssid + 3,0,0xae); + wifi_mgmr_state_get(&iStack296); + wifi_mgmr_sta_ip_get((uint32_t *)&tmp_state,(uint32_t *)&ip,(uint32_t *)&gw); + wifi_mgmr_sta_connect_ind_stat_get((wifi_mgmr_sta_connect_ind_stat_info_t *)(state.bssid + 3)); + __src = ip4addr_ntoa((ip4_addr_t *)&tmp_state); + strcpy((char *)&mask,__src); + __src = ip4addr_ntoa(&gw); + strcpy(state.gw + 0xc,__src); + __src = ip4addr_ntoa(&ip); + strcpy(state.ip + 0xc,__src); + memcpy(state.mask + 0xc,&state.state,0x20); + memcpy(state.ssid + 0x1d,info.pmk + 0x3c,6); + state.ssid[28] = '\0'; + printf("IP :%s \r\n",&mask); + printf("GW :%s \r\n",state.ip + 0xc); + printf("MASK:%s \r\n",state.gw + 0xc); + if (p_arg != (void *)0x0) { + (*(code *)p_arg)(&mask); + } + return; +} + + + +uchar char_to_hex(char asccode) + +{ + char cVar1; + byte bVar2; + + bVar2 = asccode - 0x30; + if (9 < bVar2) { + if ((byte)(asccode + 0x9fU) < 6) { + cVar1 = -0x57; + } + else { + if (5 < (byte)(asccode + 0xbfU)) { + return '\0'; + } + cVar1 = -0x37; + } + bVar2 = asccode + cVar1; + } + return (uchar)bVar2; +} + + + +void event_cb_wifi_event(input_event_t *event,void *private_data) + +{ + ushort uVar1; + int iVar2; + uint8_t *puVar3; + uint16_t freq; + uint uVar4; + uchar band; + uchar uVar5; + at_evt_t event_00; + void *pvVar6; + size_t sVar7; + size_t sVar8; + undefined3 extraout_var; + size_t sVar9; + wifi_interface_t *wifi_interface; + input_event_t *piVar10; + undefined4 uVar11; + char *ssid_00; + int iVar12; + int iVar13; + longlong lVar14; + int iStack280; + int wifi_mode; + int wifi_auto; + uint8_t mac [6]; + char chan [10]; + char bssid [32]; + char ssid [33]; + char password [66]; + int state; + + uVar1 = event->code; + switch((uint)uVar1 - 1 & 0xffff) { + case 0: + lVar14 = aos_now_ms(); + printf("[APP] [EVT] INIT DONE %lld\r\n",event,private_data,(int)lVar14); + wifi_mgmr_start_background(&conf); + break; + case 1: + lVar14 = aos_now_ms(); + printf("[APP] [EVT] MGMR DONE %lld\r\n",event,private_data,(int)lVar14); + iStack280 = 0; + wifi_mode = 0; + at_key_value_get("wifi_mode",&iStack280); + iVar12 = iStack280; + if (iStack280 != 1) { + return; + } + at_key_value_get("wifi_auto",&wifi_mode); + if (wifi_mode == 0) { + return; + } + wifi_interface = wifi_mgmr_sta_enable(); + memset(bssid + 0x1c,0,0x21); + memset(ssid + 0x20,0,0x42); + memset(chan + 8,0,0x20); + memset(&wifi_auto,0,6); + memset(mac + 4,0,10); + memset(password + 0x40,0,0x42); + ef_get_env_blob("wifi_ssid",password + 0x40,0x41,(size_t *)0x0); + if (password[64] == '\0') { + puts("[APP] Empty Config\r\n"); + puts("[APP] Try to set the following ENV with psm_set command, then reboot\r\n"); + puts("[APP] NOTE: conf_ap_pmk MUST be psm_unset when conf is changed\r\n"); + puts("[APP] env: wifi_ssid\r\n"); + puts("[APP] env: wifi_pask\r\n"); + puts("[APP] env(optinal): conf_ap_pmk\r\n"); + return; + } + strncpy(bssid + 0x1c,password + 0x40,0x20); + memset(password + 0x40,0,0x42); + ef_get_env_blob("wifi_pask",password + 0x40,0x41,(size_t *)0x0); + if (password[64] != '\0') { + strncpy(ssid + 0x20,password + 0x40,0x41); + } + memset(password + 0x40,0,0x42); + memset(password + 0x40,0,0x42); + ef_get_env_blob("conf_ap_channel",password + 0x40,0x41,(size_t *)0x0); + if (password[64] == '\0') { +LAB_2300066c: + freq = 0; + band = '\0'; + } + else { + strncpy((char *)(mac + 4),password + 0x40,9); + printf("connect wifi channel = %s\r\n",mac + 4); + ssid_00 = strchr((char *)(mac + 4),0x7c); + if (ssid_00 + 1 == (char *)0x0) goto LAB_2300066c; + iVar13 = 0; + band = char_to_hex(ssid_00[1]); + sVar7 = strlen((char *)(mac + 4)); + sVar8 = strlen(ssid_00 + 1); + iVar2 = sVar7 - sVar8; + mac[iVar2 + 3] = '\0'; + uVar4 = 0; + puVar3 = mac + iVar2 + 4; + while( true ) { + freq = (uint16_t)uVar4; + if (iVar2 + -1 <= iVar13) break; + iVar13 = iVar13 + 1; + uVar5 = char_to_hex(puVar3[-2]); + uVar4 = uVar4 + CONCAT31(extraout_var,uVar5) * iVar12 & 0xffff; + iVar12 = iVar12 * 10; + puVar3 = puVar3 + -1; + } + } + uVar11 = 0; + pvVar6 = memset(password + 0x40,0,0x42); + aos_now_ms(); + sVar7 = strlen(bssid + 0x1c); + sVar8 = strlen(ssid + 0x20); + printf( + "[APP] [WIFI] [T] %lld\r\n[APP] SSID %s\r\n[APP] SSID len %d\r\n[APP] password %s\r\n[APP] password len %d\r\n[APP] bssid %s\r\n[APP] channel band %d\r\n[APP] channel freq %d\r\n" + ,pvVar6,uVar11,bssid + 0x1c,sVar7,ssid + 0x20,sVar8); + wifi_mgmr_sta_connect + ((wifi_interface_t *)wifi_interface,bssid + 0x1c,ssid + 0x20,(char *)0x0, + (uint8_t *)0x0,band,freq); + break; + case 2: + lVar14 = aos_now_ms(); + uVar11 = (undefined4)lVar14; + ssid_00 = "[APP] [EVT] Reconnect %lld\r\n"; + goto LAB_23000814; + case 3: + lVar14 = aos_now_ms(); + printf("[APP] [EVT] connected %lld\r\n",event,private_data,(int)lVar14); + event_00 = AT_ASYNC_WIFI_CONNECTED; + goto LAB_230007fe; + case 4: + piVar10 = event; + aos_now_ms(); + ssid_00 = wifi_mgmr_status_code_str(*(uint16_t *)&event->value); + printf("[APP] [EVT] disconnect %lld, Reason: %s\r\n",piVar10,private_data,ssid_00); + wifi_mgmr_state_get((int *)(password + 0x40)); + if (stack0xffffff8c == 8) { + at_server_notify(AT_ASYNC_PSK_ERROR); + } + if (stack0xffffff8c == 9) { + at_server_notify(AT_ASYNC_NO_AP_FOUND); + } + event_00 = AT_WIFI_DISCONNECT; + goto LAB_230007fe; + case 5: + lVar14 = aos_now_ms(); + uVar11 = (undefined4)lVar14; + ssid_00 = "[APP] [EVT] connected %lld\r\n"; + goto LAB_23000814; + case 6: + lVar14 = aos_now_ms(); + printf("[APP] [EVT] GOT IP %lld\r\n",event,private_data,(int)lVar14); + sVar9 = xPortGetFreeHeapSize(); + printf("[SYS] Memory left is %d Bytes\r\n",sVar9); + event_00 = AT_WIFI_IP_GET; +LAB_230007fe: + at_server_notify(event_00); + break; + case 7: + lVar14 = aos_now_ms(); + uVar11 = (undefined4)lVar14; + ssid_00 = "[APP] [EVT] Connecting %lld\r\n"; +LAB_23000814: + printf(ssid_00,event,private_data,uVar11); + break; + case 8: + piVar10 = event; + lVar14 = aos_now_ms(); + if (event->value == 0) { + ssid_00 = "OK"; + } + else { + ssid_00 = "Busy now"; + } + printf("[APP] [EVT] SCAN Done %lld, SCAN Result: %s\r\n",piVar10,private_data,ssid_00, + (int)lVar14); + wifi_mgmr_cli_scanlist(); + break; + default: + lVar14 = aos_now_ms(); + printf("[APP] [EVT] Unknown code %u, %lld\r\n",(uint)uVar1,event,private_data,(int)lVar14); + break; + case 0xd: + piVar10 = event; + lVar14 = aos_now_ms(); + ssid_00 = (char *)event->value; + if (ssid_00 == (char *)0x0) { + ssid_00 = "UNKNOWN"; + } + printf("[APP] [EVT] [PROV] [BSSID] %lld: %s\r\n",piVar10,private_data,ssid_00,(int)lVar14); + if ((void *)event->value != (void *)0x0) { + vPortFree((void *)event->value); + } + break; + case 0xf: + piVar10 = event; + lVar14 = aos_now_ms(); + printf("[APP] [EVT] [PROV] [CONNECT] %lld\r\n",piVar10,private_data,(int)lVar14); + ssid_00 = (char *)event->value; + at_key_value_set("wifi_ssid",ssid_00); + at_key_value_set("wifi_pask",ssid_00 + 0x21); + at_server_notify_with_ctx(AT_WIFI_PRVO_DUMP,(void *)0x0,0); + if (ble_sync_auto != '\0') { + stack0xffffff8c = 0; + wifi_interface = (wifi_interface_t *)wifi_mgmr_sta_enable(); + wifi_mgmr_sta_connect(wifi_interface,ssid_00,ssid_00 + 0x21,(char *)0x0,(uint8_t *)0x0,'\0',0) + ; + at_key_value_get("wifi_auto",password + 0x40); + if (stack0xffffff8c == 0) { + wifi_mgmr_sta_autoconnect_disable(); + } + else { + wifi_mgmr_sta_autoconnect_enable(); + } + } + break; + case 0x10: + lVar14 = aos_now_ms(); + printf("[APP] [EVT] [PROV] [DISCONNECT] %lld\r\n",event,private_data,(int)lVar14); + wifi_mgmr_sta_disconnect(); + vTaskDelay(1000); + wifi_mgmr_sta_disable((wifi_interface_t *)0x0); + break; + case 0x11: + piVar10 = event; + lVar14 = aos_now_ms(); + printf("[APP] [EVT] [PROV] [SCAN] %lld\r\n",piVar10,private_data,(int)lVar14); + wifi_mgmr_scan((void *)event->value,scan_complete_cb); + break; + case 0x12: + piVar10 = event; + lVar14 = aos_now_ms(); + printf("[APP] [EVT] [PROV] [STATE] %lld\r\n",piVar10,private_data,(int)lVar14); + wifiprov_wifi_state_get((void *)event->value); + } + return; +} + + + +void event_cb_cli(input_event_t *event,void *p_arg) + +{ + if (event->code == 1) { + ble_sync_auto = event->value != 0; + blsync_ble_start(); + return; + } + if (event->code != 2) { + return; + } + blsync_ble_stop(); + printf("blsync ble stop\r\n"); + return; +} + + + +int get_dts_addr(char *name) + +{ + TickType_t TVar1; + + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %s NULL.\r\n",TVar1,&DAT_230a9dd8,&UNK_230a9dd0,0x262,name); + return -1; +} + + + +void aos_loop_proc(void *pvParameters) + +{ + StackType_t proc_stack_looprt [512]; + StaticTask_t proc_task_looprt; + void *fdt; + void *fdt_00; + int sock; + aos_poll_call_t *cb; + void *pvVar1; + void *pvVar2; + + looprt_start((StackType_t *)&ram0x42010798,0x200,(StaticTask_t *)&ram0x42010f98); + loopset_led_hook_on_looprt(); + easyflash_init(); + vfs_init(); + vfs_device_init(); + fdt = (void *)hal_board_get_factory_addr(); + fdt_00 = (void *)fdt_subnode_offset(fdt,0,"uart"); + if (fdt_00 == (void *)0x0) { + sock = get_dts_addr("uart"); + fdt = fdt_00; + pvVar2 = (void *)0x0; + if (sock != 0) goto LAB_23000a94; + fdt = (void *)0x0; + } + vfs_uart_init(fdt,fdt_00); + pvVar2 = fdt_00; +LAB_23000a94: + fdt_00 = (void *)hal_board_get_factory_addr(); + pvVar1 = (void *)fdt_subnode_offset(fdt_00,0,"gpio"); + if ((pvVar1 != (void *)0x0) || + (sock = get_dts_addr("gpio"), fdt_00 = fdt, pvVar1 = pvVar2, sock == 0)) { + hal_gpio_init_from_dts(fdt_00,pvVar1); + } + romfs_register(); + aos_loop_init(); + sock = aos_open("/dev/ttyS0",0); + if (-1 < sock) { + printf("Init CLI with event Driven\r\n"); + aos_cli_init(0); + cb = (aos_poll_call_t *)aos_cli_event_cb_read_get(); + aos_poll_read_fd(sock,cb,(void *)0x12345678); + codex_debug_cli_init(); + easyflash_cli_init(); + network_netutils_iperf_cli_register(); + sntp_cli_init(); + bl_sys_time_cli_init(); + bl_sys_ota_cli_init(); + blfdt_cli_init(); + wifi_mgmr_cli_init(); + bl_wdt_cli_init(); + bl_gpio_cli_init(); + looprt_test_cli_init(); + } + aos_register_event_filter(2,event_cb_wifi_event,(void *)0x0); + aos_register_event_filter(5,event_cb_cli,(void *)0x0); + at_server_init(); + usr_at_cmd_register(); + cmd_stack_wifi((char *)0x0,0,0,(char **)0x0); + ble_stack_start(); + aos_loop_run(); + puts("------------------------------------------\r\n"); + puts("+++++++++Critical Exit From Loop++++++++++\r\n"); + puts("******************************************\r\n"); + vTaskDelete((TaskHandle_t)0x0); + return; +} + + + +void vApplicationStackOverflowHook(TaskHandle_t xTask,char *pcTaskName) + +{ + puts("Stack Overflow checked\r\n"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void vApplicationMallocFailedHook(void) + +{ + size_t sVar1; + + sVar1 = xPortGetFreeHeapSize(); + printf("Memory Allocate Failed. Current left size is %d bytes\r\n",sVar1); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void vApplicationIdleHook(void) + +{ + wfi(); + return; +} + + + +void vApplicationGetIdleTaskMemory + (StaticTask_t **ppxIdleTaskTCBBuffer,StackType_t **ppxIdleTaskStackBuffer, + uint32_t *pulIdleTaskStackSize) + +{ + StackType_t uxIdleTaskStack [96]; + StaticTask_t xIdleTaskTCB; + + *ppxIdleTaskTCBBuffer = (StaticTask_t *)&ram0x420117b8; + *ppxIdleTaskStackBuffer = (StackType_t *)&ram0x42010ff8; + *pulIdleTaskStackSize = 0x60; + return; +} + + + +void vApplicationGetTimerTaskMemory + (StaticTask_t **ppxTimerTaskTCBBuffer,StackType_t **ppxTimerTaskStackBuffer, + uint32_t *pulTimerTaskStackSize) + +{ + StackType_t uxTimerTaskStack [400]; + StaticTask_t xTimerTaskTCB; + + *ppxTimerTaskTCBBuffer = (StaticTask_t *)&ram0x42011818; + *ppxTimerTaskStackBuffer = (StackType_t *)&ram0x42011178; + *pulTimerTaskStackSize = 400; + return; +} + + + +// WARNING: Removing unreachable block (ram,0x23000c12) + +void vAssertCalled(void) + +{ + uint32_t ulSetTo1ToExitFunction; + + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void bfl_main(void) + +{ + StackType_t aos_loop_proc_stack [1024]; + StaticTask_t aos_loop_proc_task; + int iVar1; + char *pcStack76; + char *banner; + char chip_feature [40]; + + bl_sys_early_init(); + bl_uart_init('\0','\x10','\a',-1,-1,(uint32_t)&DAT_001e8480); + puts("Starting bl602 now....\r\n"); + bl_sys_init(); + puts("Booting BL602 Chip...\r\n"); + iVar1 = bl_chip_banner(&pcStack76); + if (iVar1 == 0) { + puts(pcStack76); + } + puts("\r\n"); + puts("\r\n"); + puts("------------------------------------------------------------\r\n"); + puts("RISC-V Core Feature:"); + bl_chip_info((char *)&banner); + puts((char *)&banner); + puts("\r\n"); + puts("Build Version: "); + puts("release_bl_iot_sdk_1.6.11-1-g66bb28da-dirty"); + puts("\r\n"); + puts("Build Version: "); + puts("release_bl_iot_sdk_1.6.11-1-g66bb28da-dirty"); + puts("\r\n"); + puts("PHY Version: "); + puts("a0_final-44-geb7fadd"); + puts("\r\n"); + puts("RF Version: "); + puts("f76e39a"); + puts("\r\n"); + puts("Build Date: "); + puts("Oct 30 2020"); + puts("\r\n"); + puts("Build Time: "); + puts("01:01:30"); + puts("\r\n"); + puts("------------------------------------------------------------\r\n"); + vPortDefineHeapRegions(xHeapRegions); + printf("Heap %u@%p, %u@%p\r\n",&_heap_size,&__bss_end,0x860,&_heap_wifi_start); + blog_init(); + bl_irq_init(); + bl_sec_init(); + bl_sec_test(); + bl_dma_init(); + hal_boot2_init(); + hal_board_cfg(0); + puts("[OS] Starting proc_hellow_entry task...\r\n"); + puts("[OS] Starting aos_loop_proc task...\r\n"); + xTaskCreateStatic(aos_loop_proc,"event_loop",0x400,(void *)0x0,0xf,(StackType_t *)&ram0x4200f738, + (StaticTask_t *)&ram0x42010738); + puts("[OS] Starting TCP/IP Stack...\r\n"); + tcpip_init((tcpip_init_done_fn)0x0,(void *)0x0); + puts("[OS] Starting OS Scheduler...\r\n"); + vTaskStartScheduler(); + return; +} + + + +// WARNING: Variable defined which should be unmapped: para +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE __usr_at_cmd_demo(at_para_t *at_para) + +{ + char cVar1; + AT_ERROR_CODE AVar2; + undefined3 extraout_var; + s32 sStack112; + s32 paracnt; + at_para_descriptor_t cmd_para_list [2]; + at_test_para_t para; + + cmd_para_list[0]._0_4_ = memset(&cmd_para_list[1].option,0,0x44); + paracnt._0_1_ = APT_DI; + cmd_para_list[1].pvar = (void *)0xc40; + cmd_para_list[0].pvar = (void *)0xc04; + cmd_para_list[0].option._0_1_ = 0; + cVar1 = *at_para->ptr; + cmd_para_list[1]._0_4_ = ¶ + if (cVar1 == '?') { + at_dump_noend("\r\n"); + at_dump_noend("TEST AT ? SUCCESSFUL"); + at_dump_noend("\r\n"); + AVar2 = AEC_OK; + } + else { + AVar2 = AEC_OK; + if (cVar1 == '=') { + at_para->ptr = at_para->ptr + 1; + AVar2 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)¶cnt,2,&sStack112); + if (CONCAT31(extraout_var,AVar2) == 0) { + at_dump_noend("\r\n"); + at_dump_noend("TEST AT %d %s SUCCESSFUL",cmd_para_list[1].option,¶); + at_dump_noend("\r\n"); + } + else { + AVar2 = AEC_PARA_ERROR; + } + } + } + return AVar2; +} + + + +void usr_at_cmd_register(void) + +{ + at_command_register(g_at_cmd_usr,1); + return; +} + + + +void bt_enable_cb(int err) + +{ + if (err == 0) { + ble_cli_register(); + blemesh_cli_register(); + ble_tp_init(); + return; + } + return; +} + + + +void ble_stack_start(void) + +{ + ble_controller_init('\x1f'); + hci_driver_init(); + bt_enable(bt_enable_cb); + return; +} + + + +void blesync_complete_cb(void *p_arg) + +{ + return; +} + + + +void app_delayed_action_bleadv(void *arg) + +{ + size_t count; + + count = strlen("ble_init\r\n"); + aos_cli_input_direct("ble_init\r\n",count); + count = strlen("ble_start_adv 0 0 0x100 0x100\r\n"); + aos_cli_input_direct("ble_start_adv 0 0 0x100 0x100\r\n",count); + return; +} + + + +void wifiprov_api_state_get(anon_subr_void_void_ptr *state_get) + +{ + printf("Recevied indication to wifi state get\r\n"); + wifi_prov_api_event_state_get(state_get); + return; +} + + + +void wifiprov_wifi_scan(anon_subr_void_void_ptr *complete) + +{ + printf("Recevied indication to wifi scan\r\n"); + wifi_prov_api_event_trigger_scan(complete); + return; +} + + + +void wifiprov_disc_from_ap_ind(void) + +{ + printf("Recevied indication to disconnect to AP\r\n"); + wifi_prov_api_event_trigger_disconnect(); + return; +} + + + +void wifiprov_connect_ap_ind(wifi_conn *info) + +{ + wifi_mgmr_status_code_clean_internal(); + printf("Recevied indication to connect to AP\r\n"); + wifi_prov_api_event_trigger_connect(info); + return; +} + + + +void blsync_disconnected(bt_conn *conn,u8_t reason) + +{ + undefined3 in_register_0000202d; + + printf("disconnected (reason %u)\r\n",CONCAT31(in_register_0000202d,reason)); + at_server_notify_with_ctx(AT_BLE_DISCONNECTED,(void *)0x0,0); + return; +} + + + +void blsync_connected(bt_conn *conn,u8_t err) + +{ + char "blsync_connected" [17]; + bt_addr_le_t *pbVar1; + + pbVar1 = bt_conn_get_dst(conn); + at_server_notify_with_ctx(AT_BLE_CONNECTED,&pbVar1->a,6); + printf("%s\n","blsync_connected"); + return; +} + + + +void app_delayed_action_bleadvstop(void *arg) + +{ + size_t count; + + count = strlen("ble_stop_adv\r\n"); + aos_cli_input_direct("ble_stop_adv\r\n",count); + bl_ble_sync_stop(gp_index); + vPortFree(gp_index); + gp_index = (bl_ble_sync_t *)0x0; + return; +} + + + +void blsync_ble_start(void) + +{ + uint8_t inited; + + if (inited == '\0') { + inited = '\x01'; + bt_conn_cb_register(&blsync_cb); + } + if (gp_index != (bl_ble_sync_t *)0x0) { + printf("blsync already started\r\n"); + return; + } + gp_index = (bl_ble_sync_t *)pvPortMalloc(0x1908); + if (gp_index != (bl_ble_sync_t *)0x0) { + bl_ble_sync_start(gp_index,&WifiProv_conn_callback,blesync_complete_cb,gp_index); + aos_post_delayed_action(500,app_delayed_action_bleadv,(void *)0x0); + return; + } + return; +} + + + +void blsync_ble_stop(void) + +{ + aos_post_delayed_action(100,app_delayed_action_bleadvstop,(void *)0x0); + return; +} + + + +void cmd_coex_dump(char *buf,int len,int argc,char **argv) + +{ + coex_dump_pta(); + coex_dump_wifi(); + coex_dump_ble(); + return; +} + + + +int codex_debug_cli_init(void) + +{ + return 0; +} + + + +int wifi_prov_api_event_trigger_connect(wifi_conn *info) + +{ + int iVar1; + + iVar1 = aos_post_event(2,0x10,(ulong)info); + if (iVar1 < 0) { + puts("[APP] [PROV] trigger CONNECT event failed\r\n"); + iVar1 = -1; + } + else { + puts("[APP] [PROV] trigger CONNECT event OK\r\n"); + iVar1 = 0; + } + return iVar1; +} + + + +int wifi_prov_api_event_trigger_disconnect(void) + +{ + int iVar1; + + iVar1 = aos_post_event(2,0x11,0); + if (iVar1 < 0) { + puts("[APP] [PROV] trigger DISCONNECT event failed\r\n"); + iVar1 = -1; + } + else { + puts("[APP] [PROV] trigger DISCONNECT event OK\r\n"); + iVar1 = 0; + } + return iVar1; +} + + + +int wifi_prov_api_event_trigger_scan(anon_subr_void_void_ptr *complete) + +{ + int iVar1; + + iVar1 = aos_post_event(2,0x12,(ulong)complete); + if (iVar1 < 0) { + puts("[APP] [PROV] trigger scan event failed\r\n"); + iVar1 = -1; + } + else { + puts("[APP] [PROV] trigger scan event OK\r\n"); + iVar1 = 0; + } + return iVar1; +} + + + +int wifi_prov_api_event_state_get(anon_subr_void_void_ptr *state_get) + +{ + int iVar1; + + iVar1 = aos_post_event(2,0x13,(ulong)state_get); + if (iVar1 < 0) { + puts("[APP] [PROV] trigger scan event failed\r\n"); + iVar1 = -1; + } + else { + puts("[APP] [PROV] trigger scan event OK\r\n"); + iVar1 = 0; + } + return iVar1; +} + + +/* +Unable to decompile 'assert_rec' +Cause: Exception while decompiling 230011f4: Decompiler process died + +*/ + + +void assert_err(char *condition,char *file,int line) + +{ + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void assert_warn(char *condition,char *file,int line) + +{ + return; +} + + + +void coex_dump_pta(void) + +{ + return; +} + + + +void coex_dump_wifi(void) + +{ + return; +} + + + +void coex_wifi_rf_forece_enable(int enable) + +{ + if (enable != 0) { + enable = 1; + } + rfc_coex_force_to(enable,0); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void coex_wifi_pti_forece_enable(int enable) + +{ + if (enable == 0) { + _DAT_44b00400 = _DAT_44b00400 & 0xffffffef; + } + else { + _DAT_44b00400 = _DAT_44b00400 | 0xf0000010; + } + if ((int)(_DAT_44b00400 << 4) < 0) { + _DAT_44b00400 = _DAT_44b00400 & 0xfbffffff; + } + else { + _DAT_44b00400 = _DAT_44b00400 & 0xfbffffff | 0x4000000; + } + return; +} + + +/* +Unable to decompile 'coex_wifi_pta_forece_enable' +Cause: Exception while decompiling 230012ae: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void wifi_main(void) + +{ + int iVar1; + uint uVar2; + + rfc_init(40000000); + _DAT_44b00400 = _DAT_44b00400 | 1; + mpif_clk_init(); + sysctrl_init(); + intc_init(); + ipc_emb_init(); + bl_init(); + _DAT_44b00404 = 0x24f037; + _DAT_44b00400 = 0x49; + _DAT_44920004 = 0x5010001f; + do { + if (_DAT_44b00120 << 0xc < 0) { + _DAT_44900084 = _DAT_44900084 | 1; + } + else { + _DAT_44900084 = _DAT_44900084 & 0xfffffffe; + } + if (ke_env.evt_field == 0) { + ipc_emb_wait(); + } + if ((packets_num_12624 & 0xf) == 0) { + uVar2 = _DAT_40007018 >> 0x18 & 7; + if (uVar2 != 0) { + if (uVar2 != 3) { + _DAT_40000014 = _DAT_40000014 | 0x40000; + } + if ((uVar2 != 0) && (uVar2 != 3)) { + _DAT_40002040 = _DAT_40002040 & 0xfffffffc; + _DAT_40002044 = _DAT_40002044 & 0xfffffffe; + } + } + if ((_DAT_40007018 >> 0x18 & 4) != 0) { + _DAT_40000014 = _DAT_40000014 | 0x5c2000; + _DAT_4000f90c = _DAT_4000f90c & 0xfffffffe | 4; + } + } + packets_num_12624 = packets_num_12624 + 1; + ke_evt_schedule(); + iVar1 = bl_sleep(); + coex_wifi_pta_forece_enable((uint)(iVar1 == 0)); + } while( true ); +} + + + +void ipc_emb_notify(void) + +{ + BaseType_t BStack20; + BaseType_t xHigherPriorityTaskWoken; + + if (xTaskToNotify == (TaskHandle_t)0x0) { + assert_err("NULL != xTaskToNotify","module",0x93); + } + if (TrapNetCounter == 0) { + xTaskGenericNotify(xTaskToNotify,0,eIncrement,(uint32_t *)0x0); + } + else { + vTaskNotifyGiveFromISR(xTaskToNotify,&BStack20); + if (BStack20 != 0) { + vTaskSwitchContext(); + } + } + return; +} + + + +void ipc_emb_wait(void) + +{ + ulTaskNotifyTake(1,0xffffffff); + ipc_emb_counter = ipc_emb_counter + 1; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_init(void) + +{ + xTaskToNotify = xTaskGetCurrentTaskHandle(); + memset(&ipc_emb_env,0,0x20); + ipc_emb_env.txdesc = ipc_shared_env.txdesc0; + if (_DAT_44800140 != 0x49504332) { + assert_err("ipc_emb_signature_get() == IPC_EMB_SIGNATURE_RESET","module",0xbb); + } + _DAT_4480010c = 0x1f03; + _DAT_44800114 = 0x3ff2a04; + _DAT_44800118 = 0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_tx_irq(void) + +{ + uint uVar1; + + uVar1 = _DAT_4480011c & 0x1f00; + if (uVar1 != 0) { + ke_evt_set(uVar1 >> 1); + _DAT_44800108 = uVar1; + _DAT_44800110 = uVar1; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_tx_evt(int queue_idx) + +{ + txdesc_host *ptVar1; + txdesc_host *ptVar2; + hostdesc *phVar3; + hostdesc *phVar4; + uint event; + hostdesc *__s; + + event = ipc_emb_evt_bit[queue_idx]; + ke_evt_clear(event); + ptVar1 = ipc_emb_env.txdesc; + while( true ) { + ptVar2 = ptVar1 + (ipc_emb_env.txdesc_idx & 3); + if (ptVar2->ready != 0xffffffff) { + _DAT_4480010c = 0x100; + return; + } + if (((event & 0x800) == 0) && ((ke_env.evt_field & 0x440800) != 0)) break; + __s = (hostdesc *)ptVar2->pad_txdesc; + _DAT_44800108 = 0x100; + memset(__s,0,0x2cc); + *(uint32_t **)(ptVar2->pad_txdesc + 0x1c) = ptVar2->pad_txdesc + 0x2e; + *(uint32_t **)(ptVar2->pad_txdesc + 0x1b) = ptVar2->pad_txdesc + 0x1c; + phVar3 = &ptVar2->host; + do { + phVar4 = (hostdesc *)&phVar3->packet_addr; + phVar3[1].packet_addr = phVar3->pbuf_addr; + phVar3 = phVar4; + } while (__s != phVar4); + ptVar2->pad_txdesc[0x19] = 0; + *(undefined4 *)(*(int *)ptVar2->pad_txdesc[0x1b] + 0x10) = 0; + ptVar2->pad_txdesc[0x27] = 0; + ptVar2->pad_txdesc[0x28] = 0; + ptVar2->pad_txdesc[0x29] = 0; + ptVar2->pad_txdesc[0x15] = 0; + txu_cntrl_push(__s,0); + ptVar2->ready = 1; + ipc_emb_env.txdesc_idx = ipc_emb_env.txdesc_idx + 1; + } + ke_evt_set(event); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_cfmback_irq(void) + +{ + uint uVar1; + + uVar1 = _DAT_4480011c; + if ((_DAT_4480011c & 0x20) != 0) { + _DAT_44800110 = 0x20; + _DAT_44800108 = 0x20; + ke_evt_set(0x40000); + } + if ((uVar1 & 0x10) != 0) { + _DAT_44800110 = 0x10; + _DAT_44800108 = 0x10; + ke_evt_set(0x80000); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_txcfm_ind(uint32_t queue_bits) + +{ + _DAT_44800100 = queue_bits << 7; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_msg_irq(void) + +{ + if ((_DAT_4480011c & 2) != 0) { + ke_evt_set(0x2000000); + _DAT_44800110 = 2; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_msg_evt(void) + +{ + undefined4 *puVar1; + uint8_t uVar2; + undefined4 *puVar3; + undefined4 *puVar4; + int iVar5; + + do { + if ((_DAT_44800104 & 2) == 0) { + ke_evt_clear(0x2000000); + _DAT_4480010c = 2; + return; + } + _DAT_44800108 = 2; + puVar1 = (undefined4 *)ke_malloc((uint)ipc_shared_env.msg_a2e_buf.msg[1]._2_2_ + 0xc); + if (puVar1 == (undefined4 *)0x0) { + assert_err("kmsg_dst != NULL","module",0x1d9); + } + *puVar1 = 0; + *(undefined2 *)(puVar1 + 1) = (undefined2)ipc_shared_env.msg_a2e_buf.msg[0]; + *(undefined2 *)((int)puVar1 + 6) = ipc_shared_env.msg_a2e_buf.msg[0]._2_2_; + *(undefined2 *)(puVar1 + 2) = 0xd; + *(ushort *)((int)puVar1 + 10) = ipc_shared_env.msg_a2e_buf.msg[1]._2_2_; + iVar5 = 0xc; + while (iVar5 + -0xc < (int)(uint)*(ushort *)((int)puVar1 + 10)) { + puVar3 = (undefined4 *)((int)&ipc_shared_env.msg_a2e_buf.dummy_word + iVar5); + puVar4 = (undefined4 *)((int)puVar1 + iVar5); + iVar5 = iVar5 + 4; + *puVar4 = *puVar3; + } + uVar2 = ipc_emb_env.ipc_msgacke2a_cnt + '\x01'; + ipc_shared_env.msg_a2e_buf.msg[1]._0_2_ = (ushort)ipc_emb_env.ipc_msgacke2a_cnt; + ipc_emb_env.ipc_msgacke2a_cnt = uVar2; + if (*(ushort *)((int)puVar1 + 6) < 0xf) { + if (0xc < *(ushort *)((int)puVar1 + 6)) goto LAB_2300190c; + } + else { + assert_err("id <= TASK_MAX","module",0xb6); +LAB_2300190c: + assert_err("ke_task_local(kmsg_dst->dest_id)","module",0x1ed); + } + _DAT_44800100 = 4; + ke_msg_send(puVar1 + 3); + } while( true ); +} + + + +void ipc_emb_msg_dma_int_handler(void) + +{ + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_dbg_dma_int_handler(void) + +{ + _DAT_44800100 = 1; + _DAT_44a00020 = 0x80; + return; +} + + + +void ipc_emb_dump(void) + +{ + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mdm_txcbwmax_setf(uint8_t txcbwmax) + +{ + if ((txcbwmax & 0xfc) != 0) { + assert_err("(((uint32_t)txcbwmax << 24) & ~((uint32_t)0x03000000)) == 0","module",0xb58); + } + _DAT_44c00824 = _DAT_44c00824 & 0xfcffffff | (uint)txcbwmax << 0x18; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void phy_config_rxgain(int offset) + +{ + if ((int)rxgain_offset_vs_temperature != offset) { + rxgain_offset_vs_temperature = (int8_t)offset; + _DAT_44c0c080 = + ((int)rxgain_offset_vs_temperature + 0x19) * 0x1000000 | + ((int)rxgain_offset_vs_temperature + 0x12) * 0x10000 & 0xff0000U | + ((int)rxgain_offset_vs_temperature + 0xb) * 0x100 & 0xffffU | + (int)rxgain_offset_vs_temperature + 3U & 0xff; + _DAT_44c0c084 = + ((int)rxgain_offset_vs_temperature + 0x35) * 0x1000000 | + ((int)rxgain_offset_vs_temperature + 0x2d) * 0x10000 & 0xff0000U | + ((int)rxgain_offset_vs_temperature + 0x27) * 0x100 & 0xffffU | + (int)rxgain_offset_vs_temperature + 0x20U & 0xff; + _DAT_44c0c088 = (int)rxgain_offset_vs_temperature + 0x3bU & 0xff | _DAT_44c0c088 & 0xffffff00; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void agc_config(void) + +{ + _DAT_44c0b390 = _DAT_44c0b390 & 0xfffefbff; + _DAT_44c0b3a4 = _DAT_44c0b3a4 & 0xffff0000; + _DAT_44c0b394 = _DAT_44c0b394 & 0xff00ffff | 0xf80000; + _DAT_44c0b398 = _DAT_44c0b398 & 0xffff00ff | 0x9e00; + _DAT_44c0b3c4 = _DAT_44c0b3c4 & 0xffffff00 | 0xce; + _DAT_44c0b364 = _DAT_44c0b364 & 0xe0c0c0c0 | 0x83c3839; + _DAT_44c0b368 = _DAT_44c0b368 & 0xffc00c00 | 0x70070; + _DAT_44c0b36c = _DAT_44c0b36c & 0xf800f800 | 0x7280512; + _DAT_44c0b370 = _DAT_44c0b370 & 0xff80ffff | 0x580000; + _DAT_44c0b3c0 = _DAT_44c0b3c0 & 0xffffff | 0x18000000; + _DAT_44c0b380 = _DAT_44c0b380 & 0x3ff | 0x77f8400; + _DAT_44c0b384 = _DAT_44c0b384 & 0x3ff | 0xe7750800; + _DAT_44c0b388 = _DAT_44c0b388 & 0x3ff | 0x3d7a9400; + _DAT_44c0b38c = _DAT_44c0b38c & 0x23ff | 0x64038800; + _DAT_44c0c830 = _DAT_44c0c830 & 0x23ff | 0xfc1d9400; + _DAT_44c0c814 = _DAT_44c0c814 & 0xffffffc0 | 8; + _DAT_44c0c040 = _DAT_44c0c040 & 0xfe007fff | 0xc18000; + _DAT_44c0c044 = _DAT_44c0c044 & 0xffff0000 | 0x800; + phy_config_rxgain(0); + _DAT_44c0b3a0 = _DAT_44c0b3a0 & 0xffffff00 | 0x9e; + _DAT_44c0b3c0 = _DAT_44c0b3c0 & 0xffff0000 | 0xa3a4; + _DAT_44c0c82c = _DAT_44c0c82c & 0xff007700 | 0x2009b5; + _DAT_44c0c838 = _DAT_44c0c838 & 0x7ff80000 | 0x80000100; + _DAT_44c0c83c = _DAT_44c0c83c & 0x7ff00000 | 0x8000017c; + _DAT_44c0c840 = _DAT_44c0c840 & 0x7fc00000 | 0x80000100; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mdm_reset(void) + +{ + _DAT_44c00888 = 0; + return; +} + + + +void phy_powroffset_set(int8_t *power_offset) + +{ + int8_t *piVar1; + int8_t *piVar2; + int iVar3; + + iVar3 = 0; + do { + piVar1 = power_offset + iVar3; + piVar2 = poweroffset + iVar3; + iVar3 = iVar3 + 1; + *piVar2 = *piVar1; + } while (iVar3 != 0xe); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void phy_hw_set_channel(uint8_t band,uint16_t freq,uint16_t freq1,uint8_t chantype) + +{ + uint8_t channel; + undefined3 in_register_00002029; + int iVar1; + undefined2 in_register_0000202e; + int iVar2; + undefined3 in_register_00002035; + + iVar2 = CONCAT22(in_register_0000202e,freq); + iVar1 = CONCAT31(in_register_00002029,band); + if (CONCAT31(in_register_00002035,chantype) != 0) { + assert_err("chantype == PHY_CHNL_BW_20","module",0x144); + } + if (iVar1 != 0) { + assert_err("band == PHY_BAND_2G4","module",0x145); + } + _DAT_44c0b390 = _DAT_44c0b390 & 0xfffffeff; + _DAT_44c00820 = _DAT_44c00820 | 1; + _DAT_44c00800 = 0; + mdm_reset(); + _DAT_44c00838 = 0xb4; + _DAT_44c0088c = 0x1c13; + _DAT_44c00898 = 0x2d00438; + _DAT_44c00858 = _DAT_44c00858 & 0xffffff00; + _DAT_44c0081c = 0xf07; + _DAT_44c00834 = _DAT_44c00834 & 0xffffff | 0x6000000; + _DAT_44c00818 = 0x1880c06; + _DAT_44c00860 = 0x7f03; + _DAT_44c0b340 = 0; + _DAT_44c0b344 = 0; + _DAT_44c0b348 = 0; + mdm_txcbwmax_setf(chantype); + if (_DAT_44c0b000 << 10 < 0) { + _DAT_44c0b118 = 1; + } + rf_set_channel(chantype,freq1); + if (iVar1 == 0) { + channel = '\0'; + if ((0x48 < (iVar2 - 0x96cU & 0xffff)) || (channel = '\x0e', iVar2 == 0x9b4)) goto LAB_23002088; + iVar1 = -0x967; + } + else { + channel = '\0'; + if ((iVar1 != 1) || (channel = '\0', 0x334 < (iVar2 - 0x138dU & 0xffff))) goto LAB_23002088; + iVar1 = -5000; + } + channel = (uint8_t)((iVar2 + iVar1) / 5); +LAB_23002088: + rfc_apply_tx_power_offset(channel,poweroffset); + trpc_update_vs_channel((int8_t)freq1); + return; +} + + + +void phy_get_channel(phy_channel_info *info,uint8_t index) + +{ + info->info1 = (uint)phy_env[0].chnl_type << 8 | (uint)phy_env[0].chnl_prim20_freq << 0x10 | + (uint)phy_env[0].band; + info->info2 = phy_env[0]._6_4_; + return; +} + + + +void phy_set_channel(uint8_t band,uint8_t type,uint16_t prim20_freq,uint16_t center1_freq, + uint16_t center2_freq,uint8_t index) + +{ + undefined3 in_register_00002029; + + if ((((ushort)(center1_freq - 0x96c) < 0x49) || (CONCAT31(in_register_00002029,band) != 0)) && + (CONCAT31(in_register_00002029,band) < 2)) { + phy_hw_set_channel(band,prim20_freq,center1_freq,type); + phy_env[0].chnl_prim20_freq = prim20_freq; + phy_env[0].chnl_center1_freq = center1_freq; + phy_env[0].band = band; + phy_env[0].chnl_type = type; + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void phy_get_version(uint32_t *version_1,uint32_t *version_2) + +{ + *version_1 = _DAT_44c00000; + *version_2 = 0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +_Bool phy_vht_supported(void) + +{ + byte bVar1; + + bVar1 = 1; + if (-1 < _DAT_44c00000 << 9) { + bVar1 = (byte)((uint)_DAT_44c00000 >> 0x19) & 1; + } + return (_Bool)bVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void phy_init(phy_cfg_tag *config) + +{ + uint uVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint32_t uVar3; + uint32_t *puVar4; + uint32_t *puVar5; + uint32_t *puVar6; + + _DAT_44c00800 = 0; + mdm_reset(); + _DAT_44c00820 = 0x20d; + uVar1 = ((_DAT_44c00000 >> 8 & 0xf) - 1 & 0xff) << 4; + if ((uVar1 & 0xffffff8f) != 0) { + assert_err("(((uint32_t)rxnssmax << 4) & ~((uint32_t)0x00000070)) == 0","module",0xa09); + } + _DAT_44c00820 = uVar1 | _DAT_44c00820 & 0xffffff8f; + uVar1 = ((_DAT_44c00000 >> 0xc & 0xf) - 1 & 0xff) << 0xc; + if ((uVar1 & 0xf8000) != 0) { + assert_err("(((uint32_t)rxndpnstsmax << 12) & ~((uint32_t)0x00007000)) == 0","module",0x987); + } + _DAT_44c00820 = _DAT_44c00000 >> 0x13 & 0x100 | uVar1 | _DAT_44c00820 & 0xffff8eff; + _Var2 = phy_vht_supported(); + _DAT_44c00820 = + (_DAT_44c00000 >> 0x1e & 1) << 0x14 | + (_DAT_44c00000 >> 0x1e & 1) << 0x10 | + (CONCAT31(extraout_var,_Var2) << 1 | _DAT_44c00820 & 0xfffffffd) & 0xffeeffff; + _DAT_44c03024 = _DAT_44c03024 & 0xffc0ffff | 0x2d0000; + _DAT_44c0089c = 0xffffffff; + _DAT_44c00824 = 0x20d; + uVar1 = ((_DAT_44c00000 >> 8 & 0xf) - 1 & 0xff) << 4; + if ((uVar1 & 0xffffff8f) != 0) { + assert_err("(((uint32_t)txnssmax << 4) & ~((uint32_t)0x00000070)) == 0","module",0xc0e); + } + _DAT_44c00824 = uVar1 | _DAT_44c00824 & 0xffffff8f; + uVar1 = ((_DAT_44c00000 >> 4 & 0xf) - 1 & 0xff) << 0x14; + if ((uVar1 & 0xf800000) != 0) { + assert_err("(((uint32_t)ntxmax << 20) & ~((uint32_t)0x00700000)) == 0","module",0xb72); + } + _DAT_44c00824 = uVar1 | _DAT_44c00824 & 0xff8fffff; + mdm_txcbwmax_setf((byte)(_DAT_44c00000 >> 0x18) & 3); + _DAT_44c00824 = _DAT_44c00000 >> 0x12 & 0x100 | _DAT_44c00824 & 0xfffffeff; + _Var2 = phy_vht_supported(); + _DAT_44c00824 = + (_DAT_44c00000 >> 0x1f) << 0x10 | + (CONCAT31(extraout_var_00,_Var2) << 1 | _DAT_44c00824 & 0xfffffffd) & 0xfffeffff; + _DAT_44c00834 = _DAT_44c00834 | 1; + _DAT_44c00818 = _DAT_44c00818 & 0xfffbffff; + _DAT_44c00830 = _DAT_44c00830 & 0xffff0000 | 0x1b0f; + _DAT_44c0083c = 0x4920492; + _DAT_44c00874 = _DAT_44c00874 & 0xf7ffffff | 0x8000000; + _DAT_44c0b500 = _DAT_44c0b500 & 0xffffcfff | 0x2000; + if (_DAT_44c0b000 << 10 < 0) { + _DAT_44c0b110 = _DAT_44c0b110 & 0xfffffff0; + _DAT_44c0b118 = 0; + } + _DAT_44c0b004 = 1; + _DAT_44c0b390 = _DAT_44c0b390 & 0xfffffffc | 1; + _DAT_44c0b3bc = 4000000; + _DAT_44c0b414 = _DAT_44c0b414 | 0x100; + agc_config(); + _DAT_44c0b390 = _DAT_44c0b390 & 0xffffefff | 0x1000; + _DAT_44c00874 = _DAT_44c00874 & 0xdfffffff | 0x20000000; + puVar6 = agcmem; + puVar4 = (uint32_t *)&DAT_54c0a000; + do { + uVar3 = *puVar6; + puVar5 = puVar4 + 1; + puVar6 = puVar6 + 1; + *puVar4 = uVar3; + puVar4 = puVar5; + } while (puVar5 != (uint32_t *)0x54c0a800); + _DAT_44c00874 = _DAT_44c00874 & 0xdfffffff; + _DAT_44c0b390 = _DAT_44c0b390 & 0xffffefff; + _DAT_44c0c020 = _DAT_44c0c020 & 0xfc00ffff | 0x140000; + phy_env[0].cfg = config->parameters[0]; + phy_env[0]._4_4_ = 0xff00ff; + phy_env[0]._8_4_ = 0x50000ff; + trpc_init(); + pa_init(); + phy_tcal_reset(); + phy_tcal_start(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t phy_get_nss(void) + +{ + return (uint8_t)(((byte)((uint)_DAT_44c00000 >> 8) & 0xf) - 1); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t phy_get_ntx(void) + +{ + return (uint8_t)(((byte)(_DAT_44c00000 >> 4) & 0xf) - 1); +} + + + +void phy_stop(void) + +{ + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +_Bool phy_ldpc_tx_supported(void) + +{ + return (_Bool)((byte)((uint)_DAT_44c00000 >> 0x1a) & 1); +} + + + +uint8_t phy_get_mac_freq(void) + +{ + return '('; +} + + + +void phy_get_rf_gain_idx(int8_t *power,uint8_t *idx) + +{ + uint32_t uVar1; + + uVar1 = rfc_get_power_level(2,(int)*power * 10); + *idx = (uint8_t)uVar1; + return; +} + + + +void phy_get_rf_gain_capab(int8_t *max,int8_t *min) + +{ + int8_t iVar1; + + iVar1 = trpc_get_rf_max_power(); + *max = iVar1; + iVar1 = trpc_get_rf_min_power(); + *min = iVar1; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void bz_phy_reset(void) + +{ + _DAT_40002808 = _DAT_40002808 & 0x7fffff | 0x8800000; + _DAT_4000280c = _DAT_4000280c & 0x7fff00 | 0x4800000; + _DAT_40002810 = _DAT_40002810 & 0xfffffffe | 2; + _DAT_40002854 = 0x1e0a201e; + _DAT_40002cac = _DAT_40002cac & 0xffffffe0 | 4; + return; +} + + + +void mpif_clk_init(void) + +{ + return; +} + + + +void phy_mdm_isr(void) + +{ + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void phy_rc_isr(void) + +{ + _DAT_44c0b420 = _DAT_44c0b41c; + if ((_DAT_44c0b41c & 0x100) != 0) { + mdm_reset(); + return; + } + _DAT_44c0b420 = _DAT_44c0b41c; + return; +} + + + +void pa_init(void) + +{ + int iVar1; + pa_state_t *ppVar2; + pa_state_t *ppVar3; + + ppVar3 = pa_env; + do { + ppVar3->rss_state = '\0'; + ppVar3->rss_count = 0; + ppVar3->last_update = 0; + ppVar3->input_buffer_ptr = '\0'; + ppVar3->ce_state = '\0'; + ppVar3->ce = 0.00000000; + ppVar3->ce_num_up_cmds = '\0'; + ppVar3->ce_num_dn_cmds = '\0'; + iVar1 = 8; + ppVar2 = ppVar3; + do { + ppVar2->input_buffer[0].new = '\0'; + ppVar2->input_buffer[0].rssi = '\0'; + ppVar2->input_buffer[0].lna = '\0'; + ppVar2->input_buffer[0].ppm = 0.00000000; + iVar1 = iVar1 + -1; + ppVar2 = (pa_state_t *)&ppVar2->input_buffer[0].ppm; + } while (iVar1 != 0); + ppVar3 = ppVar3 + 1; + } while (ppVar3 != (pa_state_t *)&tcal_env); + return; +} + + + +// WARNING: Control flow encountered bad instruction data + +void pa_input(uint8_t id,rx_hd *rhd) + +{ + undefined3 in_register_00002029; + uint uVar1; + int iVar2; + + uVar1 = CONCAT31(in_register_00002029,id); + if (uVar1 < 4) { + iVar2 = (int)pa_env[uVar1].input_buffer_ptr; + pa_env[uVar1].last_update = rhd->tsflo; + pa_env[uVar1].input_buffer[iVar2].new = '\x01'; + pa_env[uVar1].input_buffer[iVar2].rssi = *(int8_t *)((int)&rhd->recvec1c + 3); + pa_env[uVar1].input_buffer[iVar2].lna = (char)((int)(rhd->recvec1d << 0x14) >> 0x1c); + if (((rhd->recvec1b & 0x70000) == 0) && ((rhd->recvec1a >> 0xc & 0xf) < 4)) { + __floatsidf((int)*(char *)((int)&rhd->recvec2a + 3)); + __muldf3(); + } + else { + __floatsidf(-(int)*(short *)((int)&rhd->recvec2a + 3)); + __muldf3(); + __divdf3(); + } + __truncdfsf2(); + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); + } + return; +} + + +/* +Unable to decompile 'pa_adapt' +Cause: Exception while decompiling 230027e0: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t hal_get_capcode(void) + +{ + return (uint8_t)((byte)(_DAT_4000f884 >> 0x16) & 0x3f); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_set_capcode(uint32_t capcode) + +{ + _DAT_4000f884 = capcode << 0x10 | capcode << 0x16 | _DAT_4000f884 & 0xf000ffff; + return; +} + + + +_Bool hal_get_temperature(int16_t *temperature) + +{ + *temperature = hal_env.temperature; + return true; +} + + + +void hal_set_temperature(int16_t temperature) + +{ + hal_env.temperature = temperature; + return; +} + + + +void trpc_update_power(int8_t (*power_rate_table) [8]) + +{ + int iVar1; + int iVar2; + int iVar3; + int8_t *piVar4; + int8_t *piVar5; + + piVar4 = txpwr_vs_rate_table; + iVar2 = 0; + do { + iVar3 = 0; + do { + iVar1 = iVar3 + iVar2; + piVar5 = piVar4 + iVar3; + iVar3 = iVar3 + 1; + *piVar5 = (*power_rate_table)[iVar1]; + } while (iVar3 != 8); + iVar2 = iVar2 + 8; + piVar4 = piVar4 + 8; + } while (iVar2 != 0x18); + return; +} + + + +void trpc_power_get(int8_t *power_rate_table) + +{ + memcpy(power_rate_table,txpwr_vs_rate_table,0x18); + return; +} + + + +void trpc_update_power_11b(int8_t *power_rate_table) + +{ + int8_t *piVar1; + int8_t *piVar2; + int iVar3; + + iVar3 = 0; + do { + piVar1 = power_rate_table + iVar3; + piVar2 = txpwr_vs_rate_table + iVar3; + iVar3 = iVar3 + 1; + *piVar2 = *piVar1; + } while (iVar3 != 4); + return; +} + + + +void trpc_update_power_11g(int8_t *power_rate_table) + +{ + int8_t *piVar1; + int iVar2; + int8_t *piVar3; + + iVar2 = 0; + piVar3 = txpwr_vs_rate_table; + do { + piVar1 = power_rate_table + iVar2; + iVar2 = iVar2 + 1; + piVar3[8] = *piVar1; + piVar3 = piVar3 + 1; + } while (iVar2 != 8); + return; +} + + + +void trpc_update_power_11n(int8_t *power_rate_table) + +{ + int8_t *piVar1; + int iVar2; + int8_t *piVar3; + + iVar2 = 0; + piVar3 = txpwr_vs_rate_table; + do { + piVar1 = power_rate_table + iVar2; + iVar2 = iVar2 + 1; + piVar3[0x10] = *piVar1; + piVar3 = piVar3 + 1; + } while (iVar2 != 8); + return; +} + + + +void trpc_init(void) + +{ + int32_t iVar1; + + DAT_4201e980 = 0x98a; + iVar1 = rf_pri_get_txgain_max(); + trpc_env = (undefined)iVar1; + iVar1 = rf_pri_get_txgain_min(); + pwr_dbm_bottom = (int8_t)iVar1; + DAT_4201e97e = 0x1e; + DAT_4201e982 = 0x19; + return; +} + + + +int8_t trpc_get_rf_max_power(void) + +{ + return trpc_env; +} + + + +int8_t trpc_get_rf_min_power(void) + +{ + return pwr_dbm_bottom; +} + + + +uint8_t trpc_get_power_idx(uint8_t formatmod,uint8_t mcs,int8_t pwr_dbm) + +{ + int8_t pwr_dbm_bottom; + undefined3 in_register_00002029; + uint uVar1; + undefined3 in_register_0000202d; + int iVar2; + undefined3 in_register_00002031; + char cVar3; + uint uVar4; + char cVar5; + int iVar6; + + uVar1 = CONCAT31(in_register_00002029,formatmod); + uVar4 = 2; + if (uVar1 < 3) { + uVar4 = (uint)formatmod; + } + iVar6 = 3; + if (uVar1 != 0) { + iVar6 = 7; + } + cVar5 = DAT_4201e97e; + if ((int)trpc_env < (int)DAT_4201e97e) { + cVar5 = trpc_env; + } + if (CONCAT31(in_register_00002031,pwr_dbm) < (int)cVar5) { + cVar5 = pwr_dbm; + } + iVar2 = CONCAT31(in_register_0000202d,mcs); + if (iVar6 < CONCAT31(in_register_0000202d,mcs)) { + iVar2 = iVar6; + } + cVar3 = txpwr_vs_rate_table[iVar2 + uVar4 * 8]; + if (cVar5 < txpwr_vs_rate_table[iVar2 + uVar4 * 8]) { + cVar3 = cVar5; + } + if (pwr_dbm_bottom < cVar3) { + pwr_dbm_bottom = cVar3; + } + __floatsidf(((int)pwr_dbm_bottom * -0x1fe + (int)trpc_env) / 0x200); + __adddf3(); + uVar4 = __fixdfsi(); + iVar6 = 3; + if (uVar1 != 0) { + iVar6 = 0; + } + uVar4 = iVar6 + (uVar4 & 0xff) & 0xff; + if (0xf < uVar4) { + uVar4 = 0xf; + } + return (uint8_t)(uVar4 << 2); +} + + + +uint8_t trpc_get_default_power_idx(uint8_t formatmod,uint8_t mcs) + +{ + uint8_t uVar1; + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + int iVar2; + uint uVar3; + int iVar4; + + uVar3 = (uint)formatmod; + if (2 < CONCAT31(in_register_00002029,formatmod)) { + uVar3 = 2; + } + iVar4 = 3; + if (CONCAT31(in_register_00002029,formatmod) != 0) { + iVar4 = 7; + } + iVar2 = CONCAT31(in_register_0000202d,mcs); + if (iVar4 < CONCAT31(in_register_0000202d,mcs)) { + iVar2 = iVar4; + } + uVar1 = trpc_get_power_idx((uint8_t)uVar3,(uint8_t)iVar2,txpwr_vs_rate_table[iVar2 + uVar3 * 8]); + return uVar1; +} + + + +void trpc_update_vs_channel(int8_t channel_MHz) + +{ + undefined3 in_register_00002029; + int32_t iVar1; + + DAT_4201e980 = (undefined2)CONCAT31(in_register_00002029,channel_MHz); + iVar1 = rf_pri_get_txgain_max(); + trpc_env = (undefined)iVar1; + iVar1 = rf_pri_get_txgain_min(); + pwr_dbm_bottom = (int8_t)iVar1; + return; +} + + + +void trpc_update_vs_temperature(int8_t temperature) + +{ + int32_t iVar1; + + DAT_4201e982._0_1_ = temperature; + iVar1 = rf_pri_get_txgain_max(); + trpc_env = (undefined)iVar1; + iVar1 = rf_pri_get_txgain_min(); + pwr_dbm_bottom = (int8_t)iVar1; + return; +} + + + +void phy_tcal_reset(void) + +{ + memset(&tcal_env,0,0x38); + tcal_env.prev_temperature = 0x19; + tcal_env.last_action_temperature[0] = 0x19; + tcal_env.last_action_temperature[1] = 0x19; + tcal_env.last_action_temperature[2] = 0x19; + tcal_env.last_action_temperature[3] = 0x19; + tcal_env.enabled = true; + return; +} + + + +void phy_tcal_start(void) + +{ + tcal_env.enabled = true; + return; +} + + + +void phy_tcal_txpwr(int16_t curr_temperature) + +{ + undefined2 in_register_0000202a; + + rf_pri_tx_gain_comp(CONCAT22(in_register_0000202a,curr_temperature)); + trpc_update_vs_temperature((int8_t)curr_temperature); + return; +} + + +/* +Unable to decompile 'phy_tcal_handle' +Cause: Exception while decompiling 23002d8a: Decompiler process died + +*/ + + +void phy_tcal_callback(int16_t temperature) + +{ + hal_set_temperature(temperature); + if (tcal_env.enabled != false) { + phy_tcal_handle(); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_fsm_ctrl_en_setf(uint32_t x) + +{ + _DAT_40001004 = x << 1 | _DAT_40001004 & 0xfffffffd; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_gc_tbb_setf(uint32_t x) + +{ + _DAT_40001048 = (x & 0x1f) << 0x14 | _DAT_40001048 & 0xfe0fffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_gc_tmx_setf(uint32_t x) + +{ + _DAT_40001048 = (x & 7) << 0x10 | _DAT_40001048 & 0xfff8ffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pa_ib_fix_setf(uint32_t x) + +{ + _DAT_40001064 = x << 0x10 | _DAT_40001064 & 0xfffeffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pa_vbcas_setf(uint32_t x) + +{ + _DAT_40001064 = x << 0xc | _DAT_40001064 & 0xffff8fff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pa_vbcore_setf(uint32_t x) + +{ + _DAT_40001064 = x << 8 | _DAT_40001064 & 0xfffff0ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tmx_cs_setf(uint32_t x) + +{ + _DAT_4000106c = x | _DAT_4000106c & 0xfffffff8; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_fsm_st_dbg_en_setf(uint32_t x) + +{ + _DAT_4000126c = x << 3 | _DAT_4000126c & 0xfffffff7; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc3_setf(uint32_t x) + +{ + _DAT_40001630 = (x & 0x7f) << 0x18 | _DAT_40001630 & 0x80ffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc2_setf(uint32_t x) + +{ + _DAT_40001630 = (x & 0x7f) << 0x10 | _DAT_40001630 & 0xff80ffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc1_setf(uint32_t x) + +{ + _DAT_40001630 = (x & 0x7f) << 8 | _DAT_40001630 & 0xffff80ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc0_setf(uint32_t x) + +{ + _DAT_40001630 = x & 0x7f | _DAT_40001630 & 0xffffff80; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc7_setf(uint32_t x) + +{ + _DAT_40001634 = (x & 0x7f) << 0x18 | _DAT_40001634 & 0x80ffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc6_setf(uint32_t x) + +{ + _DAT_40001634 = (x & 0x7f) << 0x10 | _DAT_40001634 & 0xff80ffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc5_setf(uint32_t x) + +{ + _DAT_40001634 = (x & 0x7f) << 8 | _DAT_40001634 & 0xffff80ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc4_setf(uint32_t x) + +{ + _DAT_40001634 = x & 0x7f | _DAT_40001634 & 0xffffff80; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc11_setf(uint32_t x) + +{ + _DAT_40001638 = (x & 0x7f) << 0x18 | _DAT_40001638 & 0x80ffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc10_setf(uint32_t x) + +{ + _DAT_40001638 = (x & 0x7f) << 0x10 | _DAT_40001638 & 0xff80ffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc9_setf(uint32_t x) + +{ + _DAT_40001638 = (x & 0x7f) << 8 | _DAT_40001638 & 0xffff80ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc8_setf(uint32_t x) + +{ + _DAT_40001638 = x & 0x7f | _DAT_40001638 & 0xffffff80; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc15_setf(uint32_t x) + +{ + _DAT_4000163c = (x & 0x7f) << 0x18 | _DAT_4000163c & 0x80ffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc14_setf(uint32_t x) + +{ + _DAT_4000163c = (x & 0x7f) << 0x10 | _DAT_4000163c & 0xff80ffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc13_setf(uint32_t x) + +{ + _DAT_4000163c = (x & 0x7f) << 8 | _DAT_4000163c & 0xffff80ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc12_setf(uint32_t x) + +{ + _DAT_4000163c = x & 0x7f | _DAT_4000163c & 0xffffff80; + return; +} + + + +void wait_us(uint32_t us) + +{ + bool bVar1; + uint32_t n; + int iStack4; + + iStack4 = us << 4; + do { + bVar1 = iStack4 != 0; + iStack4 = iStack4 + -1; + } while (bVar1); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pa_etb_en_setf(void) + +{ + _DAT_40001064 = _DAT_40001064 & 0xfffffff7; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pa_half_on_setf(void) + +{ + _DAT_40001064 = _DAT_40001064 & 0xffff7fff | 0x8000; + return; +} + + + +void _print_channel_info(void) + +{ + int iVar1; + + iVar1 = 8; + do { + iVar1 = iVar1 + -1; + wait_us(1000); + } while (iVar1 != 0); + iVar1 = 8; + do { + iVar1 = iVar1 + -1; + wait_us(1000); + } while (iVar1 != 0); + return; +} + + + +// WARNING: Control flow encountered bad instruction data + +void rfc_init(uint32_t xtalfreq_hz) + +{ + uint32_t rfg_index; + uint32_t dg; + + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rfc_rxdfe_set_notch0(uint8_t en,uint8_t alpha,int8_t nrmfc) + +{ + _DAT_40001700 = + ((uint)en & 1) << 6 | (uint)(byte)nrmfc << 8 | (uint)alpha & 7 | _DAT_40001700 & 0xffff00b8; + return; +} + + + +// WARNING: Variable defined which should be unmapped: ncf_freq_hz +// WARNING: Could not reconcile some variable overlaps +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rfc_config_channel(uint32_t channel_freq) + +{ + SItype SVar1; + uint8_t uStack21; + uint8_t ncf_on; + SItype SStack20; + int32_t ncf_freq_hz; + + _DAT_40001228 = _DAT_40001228 | 8; + _DAT_4000100c = _DAT_4000100c | 0x241; + _DAT_40001264 = channel_freq & 0xfff | _DAT_40001264 & 0xfffff000; + _DAT_40001268 = _DAT_40001268 & 0xfffdffff | 0x20000; + wait_us(10); + _DAT_40001268 = _DAT_40001268 & 0xfffdffff; + wait_us(10); + rf_fsm_ctrl_en_setf(0); + wait_us(10); + rf_fsm_ctrl_en_setf(1); + wait_us(10); + _DAT_4000126c = _DAT_4000126c & 0xfffffff8 | 1; + wait_us(10); + rf_fsm_st_dbg_en_setf(1); + wait_us(10); + _DAT_4000126c = _DAT_4000126c & 0xfffffff8 | 2; + wait_us(100); + rf_fsm_st_dbg_en_setf(0); + wait_us(10); + _print_channel_info(); + rf_pri_update_param(channel_freq); + rf_pri_get_notch_param(channel_freq,&uStack21,(int32_t *)&stack0xffffffec); + __floatsidf(SStack20); + __divdf3(); + __muldf3(); + __adddf3(); + SVar1 = __fixdfsi(); + rfc_rxdfe_set_notch0(uStack21,'\x01',(int8_t)SVar1); + _DAT_40001228 = _DAT_40001228 & 0xfffffff7; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rfc_coex_force_to(uint32_t force_enable,uint32_t bbmode) + +{ + rf_fsm_ctrl_en_setf(0); + wait_us(10); + _DAT_40001220 = + (uint)(force_enable != 0) << 0x1b | (bbmode & 1) << 0x1a | _DAT_40001220 & 0xf3ffffff; + wait_us(10); + rf_fsm_ctrl_en_setf(1); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +_Bool rfc_config_power_ble(int32_t pwr_dbm) + +{ + int iVar1; + uint uVar2; + + if ((uint)pwr_dbm < 0x10) { + if (pwr_dbm < 4) { + rf_pa_ib_fix_setf(1); + rf_pa_half_on_setf(); + rf_pa_vbcas_setf(4); + rf_pa_vbcore_setf(9); + rf_pa_etb_en_setf(); + rf_tmx_cs_setf(5); + rf_gc_tbb_setf(2); + rf_gc_tmx_setf(5); + iVar1 = pwr_dbm * 4 + -0x12; + } + else { + if (pwr_dbm < 7) { + rf_pa_ib_fix_setf(1); + rf_pa_half_on_setf(); + rf_pa_vbcas_setf(4); + rf_pa_vbcore_setf(9); + rf_pa_etb_en_setf(); + rf_tmx_cs_setf(5); + rf_gc_tbb_setf(2); + rf_gc_tmx_setf(7); + iVar1 = pwr_dbm * 4 + -0x1e; + } + else { + if (pwr_dbm < 10) { + rf_pa_ib_fix_setf(1); + rf_pa_half_on_setf(); + rf_pa_vbcas_setf(4); + rf_pa_vbcore_setf(9); + rf_pa_etb_en_setf(); + rf_tmx_cs_setf(5); + rf_gc_tbb_setf(3); + rf_gc_tmx_setf(7); + iVar1 = pwr_dbm + -10; + } + else { + if (pwr_dbm < 0xc) { + rf_pa_ib_fix_setf(1); + rf_pa_half_on_setf(); + rf_pa_vbcas_setf(4); + rf_pa_vbcore_setf(9); + rf_pa_etb_en_setf(); + rf_tmx_cs_setf(5); + rf_gc_tbb_setf(4); + rf_gc_tmx_setf(7); + iVar1 = pwr_dbm + -0xc; + } + else { + rf_pa_ib_fix_setf(1); + rf_pa_half_on_setf(); + rf_pa_vbcas_setf(4); + rf_pa_vbcore_setf(9); + rf_pa_etb_en_setf(); + rf_tmx_cs_setf(5); + rf_gc_tbb_setf(6); + rf_gc_tmx_setf(7); + iVar1 = pwr_dbm + -0xf; + } + } + iVar1 = iVar1 << 2; + } + } + uVar2 = iVar1 - 1; + _DAT_40001648 = + uVar2 * 0x10000 & 0x7f0000 | + uVar2 * 0x100 & 0x7f00 | uVar2 & 0x7f | _DAT_40001648 & 0xff808080; + return true; + } + return false; +} + + + +uint32_t rfc_get_power_level(uint32_t formatmod,int32_t power) + +{ + uint32_t mode; + + mode = 0; + if ((formatmod != 0) && (mode = 1, formatmod != 1)) { + mode = 2; + } + mode = rf_pri_get_txgain_index(power,mode); + return mode << 2; +} + + + +void rfc_apply_tx_dvga(int8_t *dvga_qdb) + +{ + rf_tx_dvga_gain_qdb_gc0_setf((int)*dvga_qdb); + rf_tx_dvga_gain_qdb_gc1_setf((int)dvga_qdb[1]); + rf_tx_dvga_gain_qdb_gc2_setf((int)dvga_qdb[2]); + rf_tx_dvga_gain_qdb_gc3_setf((int)dvga_qdb[3]); + rf_tx_dvga_gain_qdb_gc4_setf((int)dvga_qdb[4]); + rf_tx_dvga_gain_qdb_gc5_setf((int)dvga_qdb[5]); + rf_tx_dvga_gain_qdb_gc6_setf((int)dvga_qdb[6]); + rf_tx_dvga_gain_qdb_gc7_setf((int)dvga_qdb[7]); + rf_tx_dvga_gain_qdb_gc8_setf((int)dvga_qdb[8]); + rf_tx_dvga_gain_qdb_gc9_setf((int)dvga_qdb[9]); + rf_tx_dvga_gain_qdb_gc10_setf((int)dvga_qdb[10]); + rf_tx_dvga_gain_qdb_gc11_setf((int)dvga_qdb[0xb]); + rf_tx_dvga_gain_qdb_gc12_setf((int)dvga_qdb[0xc]); + rf_tx_dvga_gain_qdb_gc13_setf((int)dvga_qdb[0xd]); + rf_tx_dvga_gain_qdb_gc14_setf((int)dvga_qdb[0xe]); + rf_tx_dvga_gain_qdb_gc15_setf((int)dvga_qdb[0xf]); + return; +} + + + +// WARNING: Variable defined which should be unmapped: dg +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rfc_apply_tx_power_offset(uint8_t channel,int8_t *power_offset) + +{ + uint32_t uStack56; + uint32_t rfg_index; + uint32_t dg; + + rf_pri_update_tx_power_offset(channel,power_offset); + rf_pri_query_txgain_table(0,&uStack56,&rfg_index); + _DAT_40001640 = uStack56 & 7 | _DAT_40001640 & 0xfffffff8; + rf_tx_dvga_gain_qdb_gc0_setf(rfg_index); + rf_pri_query_txgain_table(1,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 4 | _DAT_40001640 & 0xffffff8f; + rf_tx_dvga_gain_qdb_gc1_setf(rfg_index); + rf_pri_query_txgain_table(2,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 8 | _DAT_40001640 & 0xfffff8ff; + rf_tx_dvga_gain_qdb_gc2_setf(rfg_index); + rf_pri_query_txgain_table(3,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 0xc | _DAT_40001640 & 0xffff8fff; + rf_tx_dvga_gain_qdb_gc3_setf(rfg_index); + rf_pri_query_txgain_table(4,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 0x10 | _DAT_40001640 & 0xfff8ffff; + rf_tx_dvga_gain_qdb_gc4_setf(rfg_index); + rf_pri_query_txgain_table(5,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 0x14 | _DAT_40001640 & 0xff8fffff; + rf_tx_dvga_gain_qdb_gc5_setf(rfg_index); + rf_pri_query_txgain_table(6,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 0x18 | _DAT_40001640 & 0xf8ffffff; + rf_tx_dvga_gain_qdb_gc6_setf(rfg_index); + rf_pri_query_txgain_table(7,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 0x1c | _DAT_40001640 & 0x8fffffff; + rf_tx_dvga_gain_qdb_gc7_setf(rfg_index); + rf_pri_query_txgain_table(8,&uStack56,&rfg_index); + _DAT_40001644 = uStack56 & 7 | _DAT_40001644 & 0xfffffff8; + rf_tx_dvga_gain_qdb_gc8_setf(rfg_index); + rf_pri_query_txgain_table(9,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 4 | _DAT_40001644 & 0xffffff8f; + rf_tx_dvga_gain_qdb_gc9_setf(rfg_index); + rf_pri_query_txgain_table(10,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 8 | _DAT_40001644 & 0xfffff8ff; + rf_tx_dvga_gain_qdb_gc10_setf(rfg_index); + rf_pri_query_txgain_table(0xb,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 0xc | _DAT_40001644 & 0xffff8fff; + rf_tx_dvga_gain_qdb_gc11_setf(rfg_index); + rf_pri_query_txgain_table(0xc,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 0x10 | _DAT_40001644 & 0xfff8ffff; + rf_tx_dvga_gain_qdb_gc12_setf(rfg_index); + rf_pri_query_txgain_table(0xd,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 0x14 | _DAT_40001644 & 0xff8fffff; + rf_tx_dvga_gain_qdb_gc13_setf(rfg_index); + rf_pri_query_txgain_table(0xe,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 0x18 | _DAT_40001644 & 0xf8ffffff; + rf_tx_dvga_gain_qdb_gc14_setf(rfg_index); + rf_pri_query_txgain_table(0xf,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 0x1c | _DAT_40001644 & 0x8fffffff; + rf_tx_dvga_gain_qdb_gc15_setf(rfg_index); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_set_gain_table_regs(void) + +{ + _DAT_40001118 = + ((tx_pwr_table[12][2] << 0x18 | + (tx_pwr_table[12][3] << 0x10 | + (tx_pwr_table[14][0] << 0xe | + (tx_pwr_table[14][1] << 0xc | + (tx_pwr_table[14][2] << 8 | (_DAT_40001118 & 0xffffffe0 | tx_pwr_table[14][3]) & 0xfffff8ff) + & 0xffffcfff) & 0xffff3fff) & 0xffe0ffff) & 0xf8ffffff) & 0xcfffffff | + tx_pwr_table[12][1] << 0x1c) & 0x3fffffff | tx_pwr_table[12][0] << 0x1e; + _DAT_4000111c = + (tx_pwr_table[8][1] << 0x1c | + (tx_pwr_table[8][2] << 0x18 | + (tx_pwr_table[8][3] << 0x10 | + (tx_pwr_table[10][0] << 0xe | + (tx_pwr_table[10][1] << 0xc | + (tx_pwr_table[10][2] << 8 | (_DAT_4000111c & 0xffffffe0 | tx_pwr_table[10][3]) & 0xfffff8ff) + & 0xffffcfff) & 0xffff3fff) & 0xffe0ffff) & 0xf8ffffff) & 0xcfffffff) & 0x3fffffff | + tx_pwr_table[8][0] << 0x1e; + _DAT_40001120 = + tx_pwr_table[4][0] << 0x1e | + (tx_pwr_table[4][1] << 0x1c | + (tx_pwr_table[4][2] << 0x18 | + (tx_pwr_table[4][3] << 0x10 | + (tx_pwr_table[6][0] << 0xe | + (tx_pwr_table[6][1] << 0xc | + (tx_pwr_table[6][2] << 8 | (_DAT_40001120 & 0xffffffe0 | tx_pwr_table[6][3]) & 0xfffff8ff) & + 0xffffcfff) & 0xffff3fff) & 0xffe0ffff) & 0xf8ffffff) & 0xcfffffff) & 0x3fffffff; + _DAT_40001124 = + (tx_pwr_table[0][1] << 0x1c | + ((tx_pwr_table[0][3] << 0x10 | + (tx_pwr_table[2][0] << 0xe | + ((tx_pwr_table[2][2] << 8 | (_DAT_40001124 & 0xffffffe0 | tx_pwr_table[2][3]) & 0xfffff8ff) + & 0xffffcfff | tx_pwr_table[2][1] << 0xc) & 0xffff3fff) & 0xffe0ffff) & 0xf8ffffff | + tx_pwr_table[0][2] << 0x18) & 0xcfffffff) & 0x3fffffff | tx_pwr_table[0][0] << 0x1e; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_manu_pu(uint32_t mode) + +{ + int iVar1; + uint uVar2; + + if (mode == 5) { + _DAT_40001030 = _DAT_40001030 & 0xcefff8ff; + iVar1 = -0x39009000; + } + else { + if (5 < mode) { + if (7 < mode) goto LAB_23003fee; + _DAT_40001030 = _DAT_40001030 & 0x8f090ff; + uVar2 = 0xf00000; + goto LAB_23004022; + } + if (mode != 4) { +LAB_23003fee: + _DAT_40001004 = _DAT_40001004 & 0xfffffffd; + _DAT_4000100c = 0; + _DAT_40001030 = _DAT_40001030 & 0x2df0feff | 0x25f06e00; + return; + } + _DAT_40001030 = _DAT_40001030 & 0x2cf8f8ff; + iVar1 = 0x24f87000; + } + uVar2 = iVar1 - 0x800; +LAB_23004022: + _DAT_40001004 = _DAT_40001004 & 0xfffffffd; + _DAT_4000100c = 0; + _DAT_40001030 = _DAT_40001030 | uVar2; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_save_state_for_cal(void) + +{ + state_adda1 = _DAT_4000108c; + state_dfe_ctrl_0 = _DAT_40001600; + state_dfe_ctrl_3 = _DAT_4000160c; + state_dfe_ctrl_6 = _DAT_40001618; + state_dfe_ctrl_7 = _DAT_4000161c; + state_fbdv = _DAT_400010b8; + state_pa1 = _DAT_40001064; + state_pucr1 = _DAT_40001030; + state_rbb3 = _DAT_40001084; + state_rf_fsm_ctrl_hw = _DAT_40001004; + state_rf_resv_reg_1 = _DAT_400010f0; + state_rfcal_ctrlen = _DAT_4000101c; + state_rfctrl_hw_en = _DAT_4000100c; + state_rfif_dfe_ctrl0 = _DAT_40001220; + state_sdm1 = _DAT_400010c0; + state_sdm2 = _DAT_400010c4; + state_singen_ctrl0 = _DAT_4000120c; + state_singen_ctrl2 = _DAT_40001214; + state_singen_ctrl3 = _DAT_40001218; + state_sram_ctrl0 = _DAT_4000123c; + state_sram_ctrl1 = _DAT_40001240; + state_sram_ctrl2 = _DAT_40001244; + state_tbb = _DAT_40001070; + state_ten_ac = _DAT_40001058; + state_trx_gain1 = _DAT_40001048; + state_vco2 = _DAT_400010a4; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_restore_state_for_cal(void) + +{ + _DAT_40001004 = state_rf_fsm_ctrl_hw; + _DAT_4000100c = state_rfctrl_hw_en; + _DAT_4000101c = state_rfcal_ctrlen; + _DAT_40001030 = state_pucr1; + _DAT_40001048 = state_trx_gain1; + _DAT_40001058 = state_ten_ac; + _DAT_40001064 = state_pa1; + _DAT_40001070 = state_tbb; + _DAT_40001084 = state_rbb3; + _DAT_4000108c = state_adda1; + _DAT_400010a4 = state_vco2; + _DAT_400010b8 = state_fbdv; + _DAT_400010c0 = state_sdm1; + _DAT_400010c4 = state_sdm2; + _DAT_400010f0 = state_rf_resv_reg_1; + _DAT_4000120c = state_singen_ctrl0; + _DAT_40001214 = state_singen_ctrl2; + _DAT_40001218 = state_singen_ctrl3; + _DAT_40001220 = state_rfif_dfe_ctrl0; + _DAT_4000123c = state_sram_ctrl0; + _DAT_40001240 = state_sram_ctrl1; + _DAT_40001244 = state_sram_ctrl2; + _DAT_40001600 = state_dfe_ctrl_0; + _DAT_4000160c = state_dfe_ctrl_3; + _DAT_40001618 = state_dfe_ctrl_6; + _DAT_4000161c = state_dfe_ctrl_7; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_singen_start(void) + +{ + _DAT_4000120c = _DAT_4000120c & 0x7fffffff | 0x80000000; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t rf_pri_pm_pwr(void) + +{ + int iVar1; + int iVar2; + + do { + } while (-1 < (int)((_DAT_40001618 & 0xdfefffff | 0x20100000) << 3)); + iVar1 = (_DAT_40001620 << 7) >> 0x10; + iVar2 = (_DAT_40001624 << 7) >> 0x10; + _DAT_40001618 = _DAT_40001618 & 0xdfefffff; + return iVar1 * iVar1 + iVar2 * iVar2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_start_txdfe(void) + +{ + _DAT_40001220 = _DAT_40001220 & 0xffffe67f | 0x1182; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int32_t rf_pri_pm_pwr_avg(uint32_t iq,uint32_t acc_len) + +{ + int iVar1; + + do { + } while (-1 < (int)((_DAT_40001618 & 0xdfefffff) << 3)); + iVar1 = _DAT_40001624; + if (iq != 0) { + iVar1 = _DAT_40001620; + } + _DAT_40001618 = _DAT_40001618 & 0xdfefffff; + _DAT_4000161c = acc_len << 0x10 | _DAT_4000161c & 0xffff; + return (iVar1 << 7) >> 7; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_txcal_config_hw(void) + +{ + _DAT_40001180 = + (*(uint *)(rf_calib_data->txcal + 1) >> 6 & 0x3f) << 0x18 | + (*(uint *)rf_calib_data->txcal >> 6 & 0x3f) << 8 | + *(uint *)rf_calib_data->txcal & 0x3f | _DAT_40001180 & 0xc0c0c0c0 | + (*(uint *)(rf_calib_data->txcal + 1) & 0x3f) << 0x10; + _DAT_40001184 = + (*(uint *)(rf_calib_data->txcal + 3) >> 6 & 0x3f) << 0x18 | + (*(uint *)(rf_calib_data->txcal + 2) >> 6 & 0x3f) << 8 | + *(uint *)(rf_calib_data->txcal + 2) & 0x3f | _DAT_40001184 & 0xc0c0c0c0 | + (*(uint *)(rf_calib_data->txcal + 3) & 0x3f) << 0x10; + _DAT_40001188 = + (*(uint *)(rf_calib_data->txcal + 5) >> 6 & 0x3f) << 0x18 | + (*(uint *)(rf_calib_data->txcal + 4) >> 6 & 0x3f) << 8 | + *(uint *)(rf_calib_data->txcal + 4) & 0x3f | _DAT_40001188 & 0xc0c0c0c0 | + (*(uint *)(rf_calib_data->txcal + 5) & 0x3f) << 0x10; + _DAT_4000118c = + (*(uint *)(rf_calib_data->txcal + 7) >> 6 & 0x3f) << 0x18 | + (*(uint *)(rf_calib_data->txcal + 6) >> 6 & 0x3f) << 8 | + *(uint *)(rf_calib_data->txcal + 6) & 0x3f | _DAT_4000118c & 0xc0c0c0c0 | + (*(uint *)(rf_calib_data->txcal + 7) & 0x3f) << 0x10; + _DAT_40001190 = + (*(uint *)rf_calib_data->txcal >> 0xc & 0x7ff) << 0x10 | _DAT_40001190 & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[0].field_0x4 & 0x3ff; + _DAT_40001194 = + (*(uint *)(rf_calib_data->txcal + 1) >> 0xc & 0x7ff) << 0x10 | _DAT_40001194 & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[1].field_0x4 & 0x3ff; + _DAT_40001198 = + (*(uint *)(rf_calib_data->txcal + 2) >> 0xc & 0x7ff) << 0x10 | _DAT_40001198 & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[2].field_0x4 & 0x3ff; + _DAT_4000119c = + (*(uint *)(rf_calib_data->txcal + 3) >> 0xc & 0x7ff) << 0x10 | _DAT_4000119c & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[3].field_0x4 & 0x3ff; + _DAT_400011a0 = + (*(uint *)(rf_calib_data->txcal + 4) >> 0xc & 0x7ff) << 0x10 | _DAT_400011a0 & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[4].field_0x4 & 0x3ff; + _DAT_400011a4 = + (*(uint *)(rf_calib_data->txcal + 5) >> 0xc & 0x7ff) << 0x10 | _DAT_400011a4 & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[5].field_0x4 & 0x3ff; + _DAT_400011a8 = + (*(uint *)(rf_calib_data->txcal + 6) >> 0xc & 0x7ff) << 0x10 | _DAT_400011a8 & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[6].field_0x4 & 0x3ff; + _DAT_400011ac = + (*(uint *)(rf_calib_data->txcal + 7) >> 0xc & 0x7ff) << 0x10 | _DAT_400011ac & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[7].field_0x4 & 0x3ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint16_t rf_pri_fcal_meas(uint32_t cw) + +{ + _DAT_400010a0 = cw | _DAT_400010a0 & 0xffffff00; + BL602_Delay_US(100); + do { + } while (-1 < (int)((_DAT_400010ac | 0x10) << 0xb)); + _DAT_400010ac = _DAT_400010ac & 0xffffffef; + return (uint16_t)((uint)_DAT_400010a8 >> 0x10); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_rccal_config(uint32_t rbb_fc) + +{ + _DAT_40001080 = rbb_fc << 8 | rbb_fc << 0x18 | _DAT_40001080 & 0xc0ffc0ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_rccal_config(uint32_t iq,uint32_t rbb_fc) + +{ + if (iq != 0) { + rf_pri_rccal_config(rbb_fc); + return; + } + _DAT_40001080 = rbb_fc << 0x10 | _DAT_40001080 & 0xffc0ffc0 | rbb_fc; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_txcal_config(uint32_t param_ind,int32_t val) + +{ + uint uVar1; + + if (param_ind == 2) { + _DAT_40001600 = val << 0xc | _DAT_40001600 & 0xff800fff | 0x800000; + return; + } + if (param_ind != 3) { + if (param_ind == 0) { + _DAT_40001070 = _DAT_40001070 & 0xc0ffffff; + uVar1 = val << 0x18; + } + else { + if (param_ind != 1) { + return; + } + _DAT_40001070 = _DAT_40001070 & 0xffc0ffff; + uVar1 = val << 0x10; + } + _DAT_40001070 = uVar1 | _DAT_40001070; + return; + } + if (val < 0) { + val = val + 0x400; + } + _DAT_40001600 = val | _DAT_40001600 & 0xfffffc00 | 0x400; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int32_t rf_pri_txcal_search_core + (uint32_t param_ind,uint32_t center,uint32_t delta,uint32_t meas_freq) + +{ + uint32_t val; + uint32_t val_00; + uint32_t uVar1; + uint uVar2; + uint32_t uVar3; + + rf_pri_txcal_config(param_ind,center); + BL602_Delay_US(10); + _DAT_40001618 = meas_freq << 10 | _DAT_40001618 & 0xfff00000; + uVar1 = rf_pri_pm_pwr(); + do { + val = center - delta; + val_00 = center + delta; + if (param_ind < 2) { + if ((int)val < 0) { + val = 0; + } + if (0x3f < (int)val_00) { + val_00 = 0x3f; + } + } + else { + if (param_ind == 2) { + if ((int)val < 0) { + val = 0; + } + if (0x7ff < (int)val_00) { + val_00 = 0x7ff; + } + } + else { + if ((int)val < -0x200) { + val = 0xfffffe00; + } + if (0x1ff < (int)val_00) { + val_00 = 0x1ff; + } + } + } + rf_pri_txcal_config(param_ind,val); + delta = (int)delta >> 1; + BL602_Delay_US(10); + uVar2 = rf_pri_pm_pwr(); + if (uVar1 <= uVar2) { + rf_pri_txcal_config(param_ind,val_00); + BL602_Delay_US(10); + uVar3 = rf_pri_pm_pwr(); + val = center; + uVar2 = uVar1; + if (uVar3 < uVar1) { + val = val_00; + uVar2 = uVar3; + } + } + center = val; + uVar1 = uVar2; + } while (delta != 0); + return val; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_singen_config(uint32_t fcw) + +{ + _DAT_4000120c = fcw << 0x10 | _DAT_4000120c & 0xfc00ffff; + _DAT_40001214 = _DAT_40001214 & 0x3fffff; + _DAT_40001218 = _DAT_40001218 & 0x3fffff | 0xc0000000; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t rf_pri_rccal_iq(uint32_t iq) + +{ + uint uVar1; + uint32_t i; + USItype UVar2; + uint32_t uVar3; + uint uVar4; + int iVar5; + undefined4 uVar6; + + if (iq == 0) { + _DAT_4000160c = _DAT_4000160c & 0xfbffffff | 0x400; + } + else { + _DAT_4000160c = _DAT_4000160c & 0xfffffbff | 0x4000000; + } + _DAT_40001048 = _DAT_40001048 & 0xffff8cff | 0x3100; + rf_pri_singen_config(3); + _DAT_40001214 = _DAT_40001214 & 0xfffff800 | 0x3ff; + _DAT_40001218 = _DAT_40001218 & 0xfffff800 | 0x3ff; + uVar6 = rf_pri_singen_start(); + rf_pri_start_txdfe(uVar6); + _DAT_40001618 = _DAT_40001618 & 0xfff00000 | 0xc00; + rf_pri_pm_pwr_avg(iq,0x400); + i = rf_pri_pm_pwr(); + __floatunsidf(i); + __muldf3(); + UVar2 = __fixunsdfsi(); + _DAT_40001048 = _DAT_40001048 & 0xffff8cff | 0x6200; + rf_pri_singen_config(0xb5); + uVar6 = rf_pri_singen_start(); + rf_pri_start_txdfe(uVar6); + _DAT_40001618 = _DAT_40001618 & 0xfff00000 | 0x2d400; + i = 0; + uVar1 = 6; + uVar4 = 0x20; + do { + rf_pri_rccal_config(iq,uVar4 + i); + uVar3 = rf_pri_pm_pwr(); + if (UVar2 < uVar3) { + i = uVar4 + i; + } + uVar1 = uVar1 - 1; + uVar4 = uVar4 >> 1; + } while (uVar1 != 0); + iVar5 = 0x3f; + do { + rf_pri_rccal_config(iq,i); + uVar3 = rf_pri_pm_pwr(); + if (UVar2 < uVar3) { + uVar1 = uVar1 * 2 + 1 & 0xf; + i = i + 1; + if (uVar1 == 5) { + return 3; + } + } + else { + uVar1 = uVar1 * 2 & 0xf; + i = i - 1; + if (uVar1 == 10) { + return 3; + } + } + iVar5 = iVar5 + -1; + } while (iVar5 != 0); + return 2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_config_channel(void) + +{ + _DAT_400010a0 = + ((uint)((ushort)rf_calib_data->lo[9] >> 8) & 0x1f) << 0x10 | + (uint)(ushort)rf_calib_data->lo[9] & 0xff | _DAT_400010a0 & 0xffe0ff00; + _DAT_400010bc = + (((uint)(ushort)rf_calib_data->lo[9] & 0xff) >> 4) << 0x14 | _DAT_400010bc & 0xff0fffff; + _DAT_400010c4 = _DAT_400010c4 & 0xc0000000 | channel_div_table[9]; + _DAT_400010c0 = _DAT_400010c0 & 0xffffefff; + while( true ) { + _DAT_400010b8 = _DAT_400010b8 | 0x10000; + BL602_Delay_US(10); + _DAT_400010b8 = _DAT_400010b8 & 0xfffeffff; + BL602_Delay_US(0x32); + _DAT_400010b0 = _DAT_400010b0 | 0x10000000; + BL602_Delay_US(10); + _DAT_400010b0 = _DAT_400010b0 & 0xefffffff; + BL602_Delay_US(0x32); + if ((_DAT_400010b4 & 0x1100000) == 0) break; + printf("."); + } + printf("LO locked %ld %ld\r\n",(uint)(ushort)rf_calib_data->lo[9] & 0xff); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t rf_pri_roscal_iq(uint32_t iq) + +{ + uint uVar1; + int32_t iVar2; + uint uVar3; + uint uVar4; + int iVar5; + uint uVar6; + + uVar1 = 6; + uVar3 = 0; + uVar4 = 0x20; + do { + uVar6 = uVar4 + uVar3; + if (iq == 0) { + _DAT_4000107c = uVar6 | _DAT_4000107c & 0xffffffc0; + } + else { + _DAT_4000107c = uVar6 * 0x100 | _DAT_4000107c & 0xffffc0ff; + } + iVar2 = rf_pri_pm_pwr_avg(iq,0x400); + if (iVar2 < 1) { + uVar3 = uVar6; + } + uVar1 = uVar1 - 1; + uVar4 = uVar4 >> 1; + } while (uVar1 != 0); + iVar5 = 0x3f; + do { + if (iq == 0) { + _DAT_4000107c = _DAT_4000107c & 0xffffffc0 | uVar3; + } + else { + _DAT_4000107c = uVar3 << 8 | _DAT_4000107c & 0xffffc0ff; + } + iVar2 = rf_pri_pm_pwr_avg(iq,0x400); + if (iVar2 < 1) { + uVar1 = uVar1 * 2 & 0xf; + uVar3 = uVar3 + 1; + if (uVar1 == 10) { + return uVar3; + } + } + else { + uVar1 = uVar1 * 2 + 1 & 0xf; + uVar3 = uVar3 - 1; + if (uVar1 == 5) { + return uVar3; + } + } + iVar5 = iVar5 + -1; + } while (iVar5 != 0); + return uVar3; +} + + + +void rf_pri_chipv(uint8_t chipv) + +{ + regs_to_opti *prVar1; + undefined3 in_register_00002029; + undefined4 *puVar2; + undefined4 *puVar3; + int iVar4; + uint32_t *puVar5; + void_fn **ppvVar6; + int iVar7; + uint32_t *puVar8; + uint32_t *puVar9; + int iVar10; + void_fn **ppvVar11; + void_fn **ppvVar12; + + if (CONCAT31(in_register_00002029,chipv) == 0) { + tmxcss._0_4_ = 0x60003; + tmxcss[2] = 6; + iVar4 = 0x1c; + do { + iVar7 = iVar4 + -0x1c; + do { + *(undefined4 *)((int)tx_pwr_table + iVar7) = *(undefined4 *)((int)tx_pwr_table_a0 + iVar7); + *(undefined4 *)((int)tx_pwr_table_origin + iVar7) = + *(undefined4 *)((int)tx_pwr_table_a0 + iVar7); + iVar7 = iVar7 + 4; + } while (iVar4 != iVar7); + iVar4 = iVar4 + 0x1c; + } while (iVar4 != 0x1dc); + iVar4 = 0; + do { + puVar2 = (undefined4 *)((int)tx_pwr_ch_os_a0 + iVar4); + puVar3 = (undefined4 *)((int)tx_pwr_ch_os + iVar4); + iVar4 = iVar4 + 4; + *puVar3 = *puVar2; + } while (iVar4 != 0x38); + puVar5 = txcal_para; + puVar8 = txcal_para_a0; + do { + puVar9 = puVar8 + 4; + *puVar5 = *puVar8; + puVar5[1] = puVar8[1]; + puVar5[2] = puVar8[2]; + puVar5[3] = puVar8[3]; + puVar5 = puVar5 + 4; + puVar8 = puVar9; + } while (puVar9 != txcal_para_a1); + opti_regs->vbcore = 10; + prVar1 = opti_regs; + opti_regs->iet = 3; + prVar1->vbcore_11n = 10; + prVar1->iet_11n = 3; + prVar1->vbcore_11g = 10; + prVar1->iet_11g = 3; + prVar1->vbcore_11b = 10; + prVar1->iet_11b = 3; + prVar1->lo_fbdv_halfstep_en = 0; + prVar1->lo_fbdv_halfstep_en_tx = 0; + prVar1->lo_fbdv_halfstep_en_tx = 0; + prVar1->clkpll_reset_postdiv = 0; + prVar1->clkpll_dither_sel = 0; + return; + } + if (CONCAT31(in_register_00002029,chipv) == 1) { + tmxcss._0_4_ = 0x50005; + tmxcss[2] = 5; + iVar4 = 0x1c; + do { + iVar7 = iVar4 + -0x1c; + do { + iVar10 = iVar7; + *(undefined4 *)((int)tx_pwr_table + iVar10) = *(undefined4 *)((int)tx_pwr_table_a1 + iVar10) + ; + *(undefined4 *)((int)tx_pwr_table_origin + iVar10) = + *(undefined4 *)((int)tx_pwr_table_a1 + iVar10); + iVar7 = iVar10 + 4; + } while (iVar10 + 4 != iVar4); + iVar4 = iVar10 + 0x20; + } while (iVar4 != 0x1dc); + iVar4 = 0; + do { + puVar2 = (undefined4 *)((int)tx_pwr_ch_os_a1 + iVar4); + puVar3 = (undefined4 *)((int)tx_pwr_ch_os + iVar4); + iVar4 = iVar4 + 4; + *puVar3 = *puVar2; + } while (iVar4 != 0x38); + ppvVar6 = (void_fn **)txcal_para; + ppvVar11 = (void_fn **)txcal_para_a1; + do { + ppvVar12 = ppvVar11 + 4; + *ppvVar6 = *ppvVar11; + ppvVar6[1] = ppvVar11[1]; + ppvVar6[2] = ppvVar11[2]; + ppvVar6[3] = ppvVar11[3]; + ppvVar6 = ppvVar6 + 4; + ppvVar11 = ppvVar12; + } while (ppvVar12 != intc_irq_handlers); + opti_regs->vbcore = 0xc; + prVar1 = opti_regs; + opti_regs->iet = 5; + prVar1->vbcore_11n = 0xc; + prVar1->iet_11n = 5; + prVar1->vbcore_11g = 0xc; + prVar1->iet_11g = 5; + prVar1->vbcore_11b = 0xc; + prVar1->iet_11b = 5; + prVar1->lo_fbdv_halfstep_en = 1; + prVar1->lo_fbdv_halfstep_en_tx = 1; + prVar1->lo_fbdv_halfstep_en_tx = 1; + prVar1->clkpll_reset_postdiv = 1; + prVar1->clkpll_dither_sel = 2; + } + return; +} + + + +void rf_pri_update_tx_power_offset(uint8_t channel,int8_t *power_offset) + +{ + char cVar1; + undefined3 in_register_00002029; + int32_t *piVar2; + int32_t *piVar3; + + cVar1 = power_offset[CONCAT31(in_register_00002029,channel)]; + memcpy(tx_pwr_table,tx_pwr_table_origin,0x1c0); + piVar2 = tx_pwr_table; + do { + piVar3 = piVar2 + 7; + piVar2[5] = piVar2[5] + (int)cVar1 % 4; + piVar2[6] = piVar2[6] + ((int)cVar1 / 4) * -10; + piVar2 = piVar3; + } while (piVar3 != tx_pwr_table_origin); + rf_pri_set_gain_table_regs(); + return; +} + + + +void rf_pri_get_notch_param(uint32_t chanfreq_MHz,uint8_t *ncf_on,int32_t *ncf_freq_Hz) + +{ + uint uVar1; + int32_t iVar2; + + uVar1 = 0xd; + if (chanfreq_MHz < 0x9a9) { + uVar1 = (chanfreq_MHz - 0x96c) / 5; + } + iVar2 = rx_notch_para_40M[uVar1 * 2 + 1]; + *ncf_on = (uint8_t)rx_notch_para_40M[uVar1 * 2]; + *ncf_freq_Hz = iVar2; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_update_param(uint32_t chanfreq_MHz) + +{ + ushort uVar1; + int iVar2; + int32_t *piVar3; + int iVar4; + int iVar5; + int iVar6; + int32_t iVar7; + int iVar8; + uint32_t uVar9; + int32_t *piVar10; + + index_os_pre = 0; + index_os_pre_mdb = 0; + dvga_os_pre = 0; + up_dn = 0; + if ((chanfreq_MHz < 0x96c) || (chanfreq_MHz < 0x971)) { + iVar5 = 0; + } + else { + if (chanfreq_MHz < 0x97b) { + iVar5 = 1; + } + else { + if (chanfreq_MHz < 0x98a) { + iVar5 = 2; + } + else { + if (chanfreq_MHz < 0x999) { + iVar5 = 3; + } + else { + iVar4 = 8; + iVar5 = 7; + if (0x9a7 < chanfreq_MHz) goto LAB_23004fb0; + iVar5 = 4; + } + } + } + } + uVar9 = Tchannels[iVar5]; + iVar8 = 0; + if (uVar9 != chanfreq_MHz) { + iVar8 = chanfreq_MHz - uVar9; + } + iVar6 = iVar5 + 1; + iVar4 = (uint)((Tchannel_os[iVar6] - Tchannel_os[iVar5]) * iVar8) / (Tchannels[iVar6] - uVar9) + + Tchannel_os[iVar5]; + iVar5 = (uint)((Tchannel_os_low[iVar6] - Tchannel_os_low[iVar5]) * iVar8) / + (Tchannels[iVar6] - uVar9) + Tchannel_os_low[iVar5]; +LAB_23004fb0: + piVar3 = temps; + piVar10 = temps; + iVar8 = 0; + iVar6 = 10; + do { + iVar2 = (piVar10[4] + iVar8) - (0x14 - iVar5); + iVar8 = 0; + if (iVar6 < iVar2) { + iVar8 = iVar2 - iVar6; + iVar2 = iVar6; + } + piVar10[3] = iVar2; + iVar6 = iVar6 + -5; + piVar10 = piVar10 + -1; + } while (iVar6 != -10); + iVar8 = 0x38; + iVar5 = 0; + do { + iVar7 = (piVar3[5] - iVar5) + (0x14 - iVar4); + if (0x5f < iVar7) { + iVar7 = iVar7 + (5 - iVar4 / 4); + } + piVar3[6] = iVar7; + iVar6 = piVar3[6]; + iVar5 = 0; + if (iVar6 < iVar8) { + iVar5 = iVar8 - iVar6; + iVar6 = iVar8; + } + piVar3[6] = iVar6; + iVar8 = iVar8 + 5; + piVar3 = piVar3 + 1; + } while (iVar8 != 0x5b); + uVar1 = tmxcss[2]; + if (chanfreq_MHz < 0x986) { + uVar1 = tmxcss[1]; + } + _DAT_4000106c = (uint)uVar1 | _DAT_4000106c & 0xfffffff8; + tx_pwr_os = tx_pwr_ch_os[6]; + if (chanfreq_MHz != 0x98a) { + if (chanfreq_MHz < 0x98b) { + tx_pwr_os = tx_pwr_ch_os[2]; + if (chanfreq_MHz != 0x976) { + if (chanfreq_MHz < 0x977) { + tx_pwr_os = tx_pwr_ch_os[0]; + if ((chanfreq_MHz != 0x96c) && (tx_pwr_os = tx_pwr_ch_os[1], chanfreq_MHz != 0x971)) { + temps[4] = 0xf; + temps[5] = 0x33; + tx_pwr_os = 0; + return; + } + } + else { + tx_pwr_os = tx_pwr_ch_os[4]; + if (((chanfreq_MHz != 0x980) && (tx_pwr_os = tx_pwr_ch_os[5], chanfreq_MHz != 0x985)) && + (tx_pwr_os = tx_pwr_ch_os[3], chanfreq_MHz != 0x97b)) { + temps[4] = 0xf; + temps[5] = 0x33; + tx_pwr_os = 0; + return; + } + } + } + } + else { + tx_pwr_os = tx_pwr_ch_os[10]; + if (chanfreq_MHz != 0x99e) { + if (chanfreq_MHz < 0x99f) { + tx_pwr_os = tx_pwr_ch_os[8]; + if (((chanfreq_MHz != 0x994) && (tx_pwr_os = tx_pwr_ch_os[9], chanfreq_MHz != 0x999)) && + (tx_pwr_os = tx_pwr_ch_os[7], chanfreq_MHz != 0x98f)) { + temps[4] = 0xf; + temps[5] = 0x33; + tx_pwr_os = 0; + return; + } + } + else { + tx_pwr_os = tx_pwr_ch_os[12]; + if (((chanfreq_MHz != 0x9a8) && (tx_pwr_os = tx_pwr_ch_os[13], chanfreq_MHz != 0x9b4)) && + (tx_pwr_os = tx_pwr_ch_os[11], chanfreq_MHz != 0x9a3)) { + temps[4] = 0xf; + temps[5] = 0x33; + tx_pwr_os = 0; + return; + } + } + } + } + } + temps[4] = 0xf; + temps[5] = 0x33; + return; +} + + + +void rf_pri_xtalfreq(uint32_t xtalfreq) + +{ + if (xtalfreq == 0) { + channel_div_table[0] = 0x21638e39; + channel_div_table[1] = 0x2171c71c; + channel_div_table[2] = 0x21800000; + channel_div_table[3] = 0x218e38e4; + channel_div_table[4] = 0x219c71c7; + channel_div_table[5] = 0x21aaaaab; + channel_div_table[6] = 0x21b8e38e; + channel_div_table[7] = 0x21c71c72; + channel_div_table[8] = 0x21d55555; + channel_div_table[9] = 0x21e38e39; + channel_div_table[10] = 0x21f1c71c; + channel_div_table[11] = 0x22000000; + channel_div_table[12] = 0x220e38e4; + channel_div_table[13] = 0x221c71c7; + channel_div_table[14] = 0x222aaaab; + channel_div_table[15] = 0x2238e38e; + channel_div_table[16] = 0x22471c72; + channel_div_table[17] = 0x22555555; + channel_div_table[18] = 0x22638e39; + channel_div_table[19] = 0x2271c71c; + channel_div_table[20] = 0x22800000; + fcal_div = 0x500; + rx_notch_para_40M[4][0] = 1; + rx_notch_para_40M[6][0] = 1; + rx_notch_para_40M[7][0] = 1; + rx_notch_para_40M[12][0] = 1; + rx_notch_para_40M[1][1] = 7000000; + rx_notch_para_40M[2][1] = (int32_t)&DAT_001e8480; + rx_notch_para_40M[3][1] = -3000000; + rx_notch_para_40M[4][1] = -8000000; + rx_notch_para_40M[6][1] = 6000000; + rx_notch_para_40M[7][1] = 1000000; + rx_notch_para_40M[8][1] = -4000000; + rx_notch_para_40M[9][1] = -9000000; + rx_notch_para_40M[0][0] = 0; + rx_notch_para_40M[10][0] = 0; + rx_notch_para_40M[0][1] = 0; + rx_notch_para_40M[10][1] = 0; + rx_notch_para_40M[11][1] = 5000000; +LAB_230053b2: + channel_cnt_range[2] = 0xace7; + channel_cnt_range._0_4_ = 0xa6e7a6a7; + rx_notch_para_40M[11][0] = 1; + rx_notch_para_40M[9][0] = 1; + rx_notch_para_40M[5][1] = 0; + rx_notch_para_40M[5][0] = 0; + rx_notch_para_40M[3][0] = 1; + rx_notch_para_40M[2][0] = 1; + rx_notch_para_40M[1][0] = 1; + channel_cnt_table[20] = 0xac80; + channel_cnt_table._36_4_ = 0xac39abf2; + channel_cnt_table._32_4_ = 0xababab64; + channel_cnt_table._28_4_ = 0xab1caad5; + channel_cnt_table._24_4_ = 0xaa8eaa47; + channel_cnt_table._20_4_ = 0xaa00a9b9; + channel_cnt_table._16_4_ = 0xa972a92b; + channel_cnt_table._12_4_ = 0xa8e4a89c; + channel_cnt_table._8_4_ = 0xa855a80e; + channel_cnt_table._4_4_ = 0xa7c7a780; + channel_cnt_table._0_4_ = 0xa739a6f2; +LAB_230053b4: + rx_notch_para_40M[8][0] = 1; + rx_notch_para_40M[12][1] = 0; + } + else { + if (xtalfreq == 1) { + channel_div_table[0] = 0x1ed20d21; + channel_div_table[1] = 0x1edf2df3; + channel_div_table[2] = 0x1eec4ec5; + channel_div_table[3] = 0x1ef96f97; + channel_div_table[4] = 0x1f069069; + channel_div_table[5] = 0x1f13b13b; + channel_div_table[6] = 0x1f20d20d; + channel_div_table[7] = 0x1f2df2df; + channel_div_table[8] = 0x1f3b13b1; + channel_div_table[9] = 0x1f483483; + channel_div_table[10] = 0x1f555555; + channel_div_table[11] = 0x1f627627; + channel_div_table[12] = 0x1f6f96f9; + channel_div_table[13] = 0x1f7cb7cb; + channel_div_table[14] = 0x1f89d89e; + channel_div_table[15] = 0x1f96f970; + channel_div_table[16] = 0x1fa41a42; + channel_div_table[17] = 0x1fb13b14; + channel_div_table[18] = 0x1fbe5be6; + channel_div_table[19] = 0x1fcb7cb8; + channel_div_table[20] = 0x1fd89d8a; + channel_cnt_table._0_4_ = 0xa743a6fc; + channel_cnt_table._4_4_ = 0xa7d1a78a; + channel_cnt_table._8_4_ = 0xa860a819; + channel_cnt_table._12_4_ = 0xa8eea8a7; + channel_cnt_table._16_4_ = 0xa97ca935; + channel_cnt_table._20_4_ = 0xaa0aa9c3; + channel_cnt_table._24_4_ = 0xaa99aa52; + channel_cnt_table._28_4_ = 0xab27aae0; + channel_cnt_table._32_4_ = 0xabb5ab6e; + channel_cnt_table._36_4_ = 0xac43abfc; + channel_cnt_table[20] = 0xac8b; + channel_cnt_range._0_4_ = 0xa6f1a6b1; + channel_cnt_range[2] = 0xacf2; + fcal_div = 0x56b; + rx_notch_para_40M[0][1] = 6000000; + rx_notch_para_40M[1][1] = 1000000; + rx_notch_para_40M[2][1] = -4000000; + rx_notch_para_40M[3][1] = -9000000; + rx_notch_para_40M[5][1] = 7000000; + rx_notch_para_40M[6][1] = (int32_t)&DAT_001e8480; + rx_notch_para_40M[7][1] = -3000000; + rx_notch_para_40M[8][1] = -8000000; + rx_notch_para_40M[10][1] = 8000000; + rx_notch_para_40M[11][1] = 3000000; + rx_notch_para_40M[4][0] = 0; + rx_notch_para_40M[9][0] = 0; + rx_notch_para_40M[9][1] = 0; + rx_notch_para_40M[12][1] = -2000000; + rx_notch_para_40M[8][0] = xtalfreq; + rx_notch_para_40M[12][0] = xtalfreq; + } + else { + if (xtalfreq != 2) { + if (xtalfreq == 3) { + channel_div_table[0] = 0x14de38e4; + channel_div_table[1] = 0x14e71c72; + channel_div_table[2] = 0x14f00000; + channel_div_table[3] = 0x14f8e38e; + channel_div_table[4] = 0x1501c71c; + channel_div_table[5] = 0x150aaaab; + channel_div_table[6] = 0x15138e39; + channel_div_table[7] = 0x151c71c7; + channel_div_table[8] = 0x15255555; + channel_div_table[9] = 0x152e38e4; + channel_div_table[10] = 0x15371c72; + channel_div_table[11] = 0x15400000; + channel_div_table[12] = 0x1548e38e; + channel_div_table[13] = 0x1551c71c; + channel_div_table[14] = 0x155aaaab; + channel_div_table[15] = 0x15638e39; + channel_div_table[16] = 0x156c71c7; + channel_div_table[17] = 0x15755555; + channel_div_table[18] = 0x157e38e4; + channel_div_table[19] = 0x15871c72; + channel_div_table[20] = 0x15900000; + fcal_div = 0x800; + rx_notch_para_40M[0][0] = 1; + rx_notch_para_40M[10][0] = 1; + rx_notch_para_40M[0][1] = 7200000; + rx_notch_para_40M[1][1] = 2200000; + rx_notch_para_40M[2][1] = -2800000; + rx_notch_para_40M[3][1] = -7800000; + rx_notch_para_40M[8][1] = 5600000; + rx_notch_para_40M[9][1] = 600000; + rx_notch_para_40M[10][1] = -4400000; + rx_notch_para_40M[4][0] = 0; + rx_notch_para_40M[6][0] = 0; + rx_notch_para_40M[7][0] = 0; + rx_notch_para_40M[12][0] = 0; + rx_notch_para_40M[4][1] = 0; + rx_notch_para_40M[6][1] = 0; + rx_notch_para_40M[7][1] = 0; + rx_notch_para_40M[11][1] = -9400000; + goto LAB_230053b2; + } + if (xtalfreq == 4) { + channel_cnt_table._0_4_ = 0xa732a6eb; + channel_cnt_table._4_4_ = 0xa7c0a779; + channel_cnt_table._8_4_ = 0xa84fa808; + channel_cnt_table._12_4_ = 0xa8dda896; + channel_cnt_table._16_4_ = 0xa96ba924; + channel_cnt_table._20_4_ = 0xa9f9a9b2; + channel_cnt_table._24_4_ = 0xaa87aa40; + channel_cnt_table._28_4_ = 0xab16aacf; + channel_cnt_table._32_4_ = 0xaba4ab5d; + channel_cnt_table._36_4_ = 0xac32abeb; + channel_cnt_table[20] = 0xac79; + channel_div_table[0] = 0x14088889; + channel_div_table[1] = 0x14111111; + channel_div_table[2] = 0x1419999a; + channel_div_table[3] = 0x14222222; + channel_div_table[4] = 0x142aaaab; + channel_div_table[5] = 0x14333333; + channel_div_table[6] = 0x143bbbbc; + channel_div_table[7] = 0x14444444; + channel_div_table[8] = 0x144ccccd; + channel_div_table[9] = 0x14555555; + channel_div_table[10] = 0x145dddde; + channel_div_table[11] = 0x14666666; + channel_div_table[12] = 0x146eeeef; + channel_div_table[13] = 0x14777777; + channel_div_table[14] = 0x14800000; + channel_div_table[15] = 0x14888889; + channel_div_table[16] = 0x14911111; + channel_div_table[17] = 0x1499999a; + channel_div_table[18] = 0x14a22222; + channel_div_table[19] = 0x14aaaaab; + channel_div_table[20] = 0x14b33333; + rx_notch_para_40M[0][0] = 0; + rx_notch_para_40M[0][1] = 0; + rx_notch_para_40M[1][0] = 0; + rx_notch_para_40M[1][1] = 0; + rx_notch_para_40M[2][0] = 0; + rx_notch_para_40M[2][1] = 0; + rx_notch_para_40M[3][0] = 0; + rx_notch_para_40M[3][1] = 0; + rx_notch_para_40M[4][0] = 1; + rx_notch_para_40M[4][1] = 8000000; + rx_notch_para_40M[5][0] = 1; + rx_notch_para_40M[5][1] = 3000000; + rx_notch_para_40M[6][0] = 1; + rx_notch_para_40M[6][1] = -2000000; + rx_notch_para_40M[7][0] = 1; + rx_notch_para_40M[7][1] = -7000000; + rx_notch_para_40M[8][0] = 0; + rx_notch_para_40M[8][1] = 0; + rx_notch_para_40M[9][0] = 0; + rx_notch_para_40M[9][1] = 0; + rx_notch_para_40M[10][0] = 0; + rx_notch_para_40M[10][1] = 0; + rx_notch_para_40M[11][0] = 0; + rx_notch_para_40M[11][1] = 0; + rx_notch_para_40M[12][0] = 1; + rx_notch_para_40M[12][1] = 8000000; + rx_notch_para_40M[13][0] = 1; + rx_notch_para_40M[13][1] = -4000000; + channel_cnt_range._0_4_ = 0xa6e0a6a0; + channel_cnt_range[2] = 0xace0; + fcal_div = 0x855; + return; + } + if (xtalfreq != 5) { + return; + } + channel_div_table[0] = 0xf690690; + channel_div_table[1] = 0xf6f96f9; + channel_div_table[2] = 0xf762762; + channel_div_table[3] = 0xf7cb7cb; + channel_div_table[4] = 0xf834835; + channel_div_table[5] = 0xf89d89e; + channel_div_table[6] = 0xf906907; + channel_div_table[7] = 0xf96f970; + channel_div_table[8] = 0xf9d89d9; + channel_div_table[9] = 0xfa41a42; + channel_div_table[10] = 0xfaaaaab; + channel_div_table[11] = 0xfb13b14; + channel_div_table[12] = 0xfb7cb7d; + channel_div_table[13] = 0xfbe5be6; + channel_div_table[14] = 0xfc4ec4f; + channel_div_table[15] = 0xfcb7cb8; + channel_div_table[16] = 0xfd20d21; + channel_div_table[17] = 0xfd89d8a; + channel_div_table[18] = 0xfdf2df3; + channel_div_table[19] = 0xfe5be5c; + channel_div_table[20] = 0xfec4ec5; + channel_cnt_table._0_4_ = 0xa734a6ed; + channel_cnt_table._4_4_ = 0xa7c2a77b; + channel_cnt_table._8_4_ = 0xa850a809; + channel_cnt_table._12_4_ = 0xa8dea897; + channel_cnt_table._16_4_ = 0xa96da925; + channel_cnt_table._20_4_ = 0xa9fba9b4; + channel_cnt_table._24_4_ = 0xaa89aa42; + channel_cnt_table._28_4_ = 0xab17aad0; + channel_cnt_table._32_4_ = 0xaba5ab5e; + channel_cnt_table._36_4_ = 0xac34abec; + channel_cnt_table[20] = 0xac7b; + channel_cnt_range._0_4_ = 0xa6e2a6a2; + channel_cnt_range[2] = 0xace2; + fcal_div = 0xad5; + rx_notch_para_40M[5][0] = 1; + rx_notch_para_40M[6][0] = 1; + rx_notch_para_40M[7][0] = 1; + rx_notch_para_40M[5][1] = 7000000; + rx_notch_para_40M[6][1] = (int32_t)&DAT_001e8480; + rx_notch_para_40M[7][1] = -3000000; + rx_notch_para_40M[0][0] = 0; + rx_notch_para_40M[1][0] = 0; + rx_notch_para_40M[2][0] = 0; + rx_notch_para_40M[3][0] = 0; + rx_notch_para_40M[4][0] = 0; + rx_notch_para_40M[9][0] = 0; + rx_notch_para_40M[10][0] = 0; + rx_notch_para_40M[11][0] = 0; + rx_notch_para_40M[12][0] = 0; + rx_notch_para_40M[0][1] = 0; + rx_notch_para_40M[1][1] = 0; + rx_notch_para_40M[2][1] = 0; + rx_notch_para_40M[3][1] = 0; + rx_notch_para_40M[4][1] = 0; + rx_notch_para_40M[8][1] = -8000000; + rx_notch_para_40M[9][1] = 0; + rx_notch_para_40M[10][1] = 0; + rx_notch_para_40M[11][1] = 0; + goto LAB_230053b4; + } + channel_div_table[0] = 0x190aaaab; + channel_div_table[1] = 0x19155555; + channel_div_table[2] = 0x19200000; + channel_div_table[3] = 0x192aaaab; + channel_div_table[4] = 0x19355555; + channel_div_table[5] = 0x19400000; + channel_div_table[6] = 0x194aaaab; + channel_div_table[7] = 0x19555555; + channel_div_table[8] = 0x19600000; + channel_div_table[9] = 0x196aaaab; + channel_div_table[10] = 0x19755555; + channel_div_table[11] = 0x19800000; + channel_div_table[12] = 0x198aaaab; + channel_div_table[13] = 0x19955555; + channel_div_table[14] = 0x19a00000; + channel_div_table[15] = 0x19aaaaab; + channel_div_table[16] = 0x19b55555; + channel_div_table[17] = 0x19c00000; + channel_div_table[18] = 0x19caaaab; + channel_div_table[19] = 0x19d55555; + channel_div_table[20] = 0x19e00000; + channel_cnt_table._0_4_ = 0xa741a6fa; + channel_cnt_table._4_4_ = 0xa7d0a788; + channel_cnt_table._8_4_ = 0xa85ea817; + channel_cnt_table._12_4_ = 0xa8eca8a5; + channel_cnt_table._16_4_ = 0xa97aa933; + channel_cnt_table._20_4_ = 0xaa09a9c1; + channel_cnt_table._24_4_ = 0xaa97aa50; + channel_cnt_table._28_4_ = 0xab25aade; + channel_cnt_table._32_4_ = 0xabb3ab6c; + channel_cnt_table._36_4_ = 0xac42abfa; + channel_cnt_table[20] = 0xac89; + channel_cnt_range._0_4_ = 0xa6efa6af; + channel_cnt_range[2] = 0xacf0; + fcal_div = 0x6ab; + rx_notch_para_40M[4][0] = 1; + rx_notch_para_40M[9][0] = 1; + rx_notch_para_40M[12][0] = 1; + rx_notch_para_40M[2][1] = 10000000; + rx_notch_para_40M[3][1] = 5000000; + rx_notch_para_40M[5][1] = -5000000; + rx_notch_para_40M[6][1] = -10000000; + rx_notch_para_40M[9][1] = 7000000; + rx_notch_para_40M[10][1] = (int32_t)&DAT_001e8480; + rx_notch_para_40M[11][1] = -3000000; + rx_notch_para_40M[8][0] = 0; + rx_notch_para_40M[0][1] = 0; + rx_notch_para_40M[1][1] = 0; + rx_notch_para_40M[7][1] = 0; + rx_notch_para_40M[8][1] = 0; + rx_notch_para_40M[12][1] = -8000000; + } + rx_notch_para_40M[4][1] = 0; + rx_notch_para_40M[0][0] = rx_notch_para_40M[8][0]; + rx_notch_para_40M[1][0] = rx_notch_para_40M[8][0]; + rx_notch_para_40M[2][0] = rx_notch_para_40M[12][0]; + rx_notch_para_40M[3][0] = rx_notch_para_40M[12][0]; + rx_notch_para_40M[5][0] = rx_notch_para_40M[12][0]; + rx_notch_para_40M[6][0] = rx_notch_para_40M[12][0]; + rx_notch_para_40M[7][0] = rx_notch_para_40M[8][0]; + rx_notch_para_40M[10][0] = rx_notch_para_40M[12][0]; + rx_notch_para_40M[11][0] = rx_notch_para_40M[12][0]; + } + rx_notch_para_40M[13][0] = 0; + rx_notch_para_40M[13][1] = 0; + return; +} + + + +uint32_t rf_pri_get_vco_freq_cw(uint32_t chanfreq_MHz) + +{ + int iVar1; + + __floatunsidf(chanfreq_MHz - 0x964 >> 2); + __adddf3(); + iVar1 = __fixdfsi(); + if (0x14 < iVar1) { + iVar1 = 0x14; + } + return (uint)*(ushort *)(&(rf_calib_data->cal).field_0x8 + (iVar1 + 8) * 2) & 0xff; +} + + + +uint32_t rf_pri_get_vco_idac_cw(uint32_t chanfreq_MHz) + +{ + int iVar1; + + __floatunsidf(chanfreq_MHz - 0x964 >> 2); + __adddf3(); + iVar1 = __fixdfsi(); + if (0x14 < iVar1) { + iVar1 = 0x14; + } + return (uint)(*(ushort *)(&(rf_calib_data->cal).field_0x8 + (iVar1 + 8) * 2) >> 8) & 0x1f; +} + + + +int32_t rf_pri_get_txgain_max(void) + +{ + return tx_pwr_os_temperature + tx_pwr_table[0][6] + tx_pwr_os; +} + + + +int32_t rf_pri_get_txgain_min(void) + +{ + return tx_pwr_os_temperature + tx_pwr_table[15][6] + tx_pwr_os; +} + + + +uint32_t rf_pri_get_txgain_index(int32_t pwr,uint32_t mode) + +{ + int32_t *piVar1; + uint32_t uVar2; + + if (mode == 0) { + pwr = pwr + -0x1e; + } + piVar1 = tx_pwr_table; + uVar2 = 0; + do { + if (piVar1[6] + tx_pwr_os + tx_pwr_os_temperature <= pwr) { + return uVar2; + } + uVar2 = uVar2 + 1; + piVar1 = piVar1 + 7; + } while (uVar2 != 0x10); + return 0xf; +} + + + +void rf_pri_query_txgain_table(uint32_t index,uint32_t *rfg_index,uint32_t *dg) + +{ + if (0xf < index) { + index = 0xf; + } + *rfg_index = 7 - (index >> 1); + *dg = tx_pwr_table[index * 7 + 5]; + return; +} + + + +void rf_pri_update_dvga_os(int8_t dvga_os) + +{ + int iVar1; + int32_t *piVar2; + int8_t *piVar3; + + piVar2 = tx_pwr_table; + iVar1 = 0; + do { + piVar3 = temps_dvga + iVar1; + iVar1 = iVar1 + 1; + *piVar3 = (char)piVar2[5] + dvga_os; + piVar2 = piVar2 + 7; + } while (iVar1 != 0x10); + return; +} + + + +void rf_pri_tx_gain_comp(int32_t Tsens) + +{ + int iVar1; + int iVar2; + int32_t *piVar3; + uint uVar4; + + if (up_dn == 1) { + if ((Tthr <= Tsens) || (Tsens <= Tthr + -5)) { +LAB_23005fa2: + piVar3 = temps; + iVar2 = 0xc; + do { + if (piVar3[0xc] <= Tsens) break; + iVar2 = iVar2 + -1; + piVar3 = piVar3 + -1; + } while (iVar2 != -1); + if (iVar2 < 0) { + iVar2 = 0; + } + uVar4 = iVar2 - 4; + iVar1 = temps[iVar2]; + Tthr = iVar1; + if (Tsens < 0x23) { + if (iVar1 < Tsens) { + Tthr = temps[iVar2 + 1]; + if (0x22 < temps[iVar2 + 1]) { + Tthr = iVar1; + } + } + else { + uVar4 = iVar2 - 5; + } + } + else { + if (iVar1 < 0x24) { + Tthr = temps[iVar2 + 1]; + } + } + if (index_os_pre_mdb < (int)uVar4) { + up_dn = 1; + } + else { + if ((int)uVar4 < index_os_pre_mdb) { + up_dn = -1; + } + } + if ((int)uVar4 < 1) { + dvga_os_pre = 0; + index_os_pre = uVar4; + if (uVar4 != 0) { + dvga_os_pre = 0xffffffff; + if ((uVar4 & 1) != 0) { + dvga_os_pre = 1; + } + index_os_pre = (int)(uVar4 - 1) / 2; + } + } + else { + dvga_os_pre = uVar4 + 1 & 1; + if (dvga_os_pre == 0) { + dvga_os_pre = 0xffffffff; + } + index_os_pre = (int)(uVar4 + 1) >> 1; + } + tx_pwr_os_temperature = index_os_pre * -10; + index_os_pre_mdb = uVar4; + goto LAB_23005f76; + } + } + else { + if (((up_dn != -1) || (Tsens <= Tthr)) || (Tthr + 5 <= Tsens)) goto LAB_23005fa2; + } + tx_pwr_os_temperature = index_os_pre * -10; +LAB_23005f76: + rf_pri_update_dvga_os((int8_t)dvga_os_pre); + rfc_apply_tx_dvga(temps_dvga); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_txcal(void) + +{ + int32_t val; + uint32_t center; + uint val_00; + uint val_01; + uint32_t *puVar1; + int iVar2; + uint32_t *puVar3; + int32_t *piVar4; + uint val_02; + uint uVar5; + int iVar6; + + _DAT_40001014 = _DAT_40001014 & 0xff0fffff | 0x500000; + rf_pri_save_state_for_cal(); + rf_pri_manu_pu(5); + rf_pri_config_channel(); + _DAT_4000101c = _DAT_4000101c | 0x3000; + _DAT_40001084 = _DAT_40001084 | 0x80000000; + _DAT_40001064 = _DAT_40001064 | 0x400000; + iVar2 = 7; + _DAT_4000106c = (uint)tmxcss[0] | _DAT_4000106c & 0xfffffff8; + rf_pri_singen_config(0x3d); + puVar3 = txcal_para; + piVar4 = tx_pwr_table; + do { + _DAT_40001064 = *puVar3 << 0x1c | _DAT_40001064 & 0xfc3ffff | puVar3[2] << 0x12; + _DAT_40001058 = puVar3[1] << 0x10 | _DAT_40001058 & 0xfff8ffff; + _DAT_40001048 = *piVar4 << 0x1c | _DAT_40001048 & 0xce08ffff | piVar4[3] << 0x14 | 0x70000; + BL602_Delay_US(10); + val_02 = puVar3[3]; + uVar5 = val_02; + do { + uVar5 = uVar5 >> 1; + _DAT_40001214 = val_02 | _DAT_40001214 & 0xfffff800; + _DAT_40001218 = val_02 | _DAT_40001218 & 0xfffff800; + rf_pri_singen_start(); + rf_pri_start_txdfe(); + BL602_Delay_US(10); + val = rf_pri_pm_pwr_avg(1,0x400); + iVar6 = val >> 10; + printf("amp=%ld,step=%ld,adc_mean_i=%ld\r\n",val_02,uVar5,iVar6); + if (iVar6 < 0x141) { + val_00 = uVar5; + if (0xbf < iVar6) break; + } + else { + val_00 = -uVar5; + } + val_02 = val_02 + val_00; + } while (uVar5 != 0); + rf_pri_pm_pwr_avg(1,0x1000); + center = rf_pri_txcal_search_core(0,0x20,0x10,0x3d); + rf_pri_txcal_config(0,center); + uVar5 = rf_pri_txcal_search_core(1,0x20,0x10,0x3d); + _DAT_40001070 = uVar5 << 0x10 | _DAT_40001070 & 0xffc0ffff; + val_02 = rf_pri_txcal_search_core(0,center,2,0x3d); + rf_pri_txcal_config(0,val_02); + center = rf_pri_txcal_search_core(2,0x400,0x80,0x7a); + rf_pri_txcal_config(2,center); + val = rf_pri_txcal_search_core(3,0,0x40,0x7a); + rf_pri_txcal_config(3,val); + val_00 = rf_pri_txcal_search_core(2,center,0x40,0x7a); + rf_pri_txcal_config(2,val_00); + val_01 = rf_pri_txcal_search_core(3,0,0x20,0x7a); + rf_pri_txcal_config(3,val_01); + puVar1 = &rf_calib_data->inited + (iVar2 + 0xc) * 2; + puVar1[2] = puVar1[2] & 0xffffffc0 | val_02 & 0x3f; + puVar1[2] = puVar1[2] & 0xfffff03f | (uVar5 & 0x3f) << 6; + puVar1[2] = puVar1[2] & 0xff800fff | (val_00 & 0x7ff) << 0xc; + puVar1[3] = puVar1[3] & 0xfffffc00 | val_01 & 0x3ff; + printf("tosdac_i=%ld,tosdac_q=%ld,tx_iq_gain_comp=%ld,tx_iq_phase_comp=%ld\r\n",val_02,uVar5, + val_00); + iVar2 = iVar2 + -1; + puVar3 = puVar3 + 4; + piVar4 = piVar4 + 0xe; + if (iVar2 == -1) { + rf_pri_txcal_config_hw(); + _DAT_4000101c = _DAT_4000101c & 0xffffcfff; + rf_pri_restore_state_for_cal(); + _DAT_40001014 = _DAT_40001014 | 0xf00000; + _DAT_40001070 = + (*(uint *)(rf_calib_data->txcal + 3) >> 6 & 0x3f) << 0x10 | + (*(uint *)(rf_calib_data->txcal + 3) & 0x3f) << 0x18 | _DAT_40001070 & 0xc0c0ffff; + _DAT_40001600 = + *(uint *)&rf_calib_data->txcal[3].field_0x4 & 0x3ff | + *(uint *)(rf_calib_data->txcal + 3) & 0x7ff000 | _DAT_40001600 & 0xff800c00; + return; + } + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_roscal(void) + +{ + uint32_t uVar1; + uint uVar2; + + _DAT_40001014 = _DAT_40001014 & 0xffff3fff; + if ((_DAT_40001020 & 0x100) != 0) { + _DAT_40001014 = _DAT_40001014 | 0x4000; + rf_pri_save_state_for_cal(); + rf_pri_manu_pu(3); + _DAT_4000101c = _DAT_4000101c | 0x200; + rf_pri_config_channel(); + _DAT_40001048 = _DAT_40001048 & 0xffff8fff | 0x6300; + uVar1 = rf_pri_roscal_iq(1); + uVar2 = uVar1 & 0x3f; + *(uint *)(rf_calib_data->rxcal + 3) = *(uint *)(rf_calib_data->rxcal + 3) & 0xffffffc0 | uVar2; + _DAT_4000116c = _DAT_4000116c & 0xffc0ffff | uVar1 << 0x10; + printf("rosdac_i_gc3=%ld\r\n",uVar1); + *(uint *)(rf_calib_data->rxcal + 2) = *(uint *)(rf_calib_data->rxcal + 2) & 0xffffffc0 | uVar2; + _DAT_4000116c = uVar1 | _DAT_4000116c & 0xffffffc0; + printf("rosdac_i_gc2=%ld\r\n",uVar1); + *(uint *)(rf_calib_data->rxcal + 1) = *(uint *)(rf_calib_data->rxcal + 1) & 0xffffffc0 | uVar2; + _DAT_40001168 = uVar1 << 0x10 | _DAT_40001168 & 0xffc0ffff; + printf("rosdac_i_gc1=%ld\r\n",uVar1); + *(uint *)rf_calib_data->rxcal = *(uint *)rf_calib_data->rxcal & 0xffffffc0 | uVar2; + _DAT_40001168 = uVar1 | _DAT_40001168 & 0xffffffc0; + printf("rosdac_i_gc0=%ld\r\n",uVar1); + uVar1 = rf_pri_roscal_iq(0); + uVar2 = (uVar1 & 0x3f) << 6; + *(uint *)(rf_calib_data->rxcal + 3) = *(uint *)(rf_calib_data->rxcal + 3) & 0xfffff03f | uVar2; + _DAT_4000116c = _DAT_4000116c & 0xc0ffffff | uVar1 << 0x18; + printf("rosdac_q_gc3=%ld\r\n",uVar1); + *(uint *)(rf_calib_data->rxcal + 2) = *(uint *)(rf_calib_data->rxcal + 2) & 0xfffff03f | uVar2; + _DAT_4000116c = _DAT_4000116c & 0xffffc0ff | uVar1 << 8; + printf("rosdac_q_gc2=%ld\r\n",uVar1); + *(uint *)(rf_calib_data->rxcal + 1) = *(uint *)(rf_calib_data->rxcal + 1) & 0xfffff03f | uVar2; + _DAT_40001168 = uVar1 << 0x18 | _DAT_40001168 & 0xc0ffffff; + printf("rosdac_q_gc1=%ld\r\n",uVar1); + *(uint *)rf_calib_data->rxcal = *(uint *)rf_calib_data->rxcal & 0xfffff03f | uVar2; + _DAT_40001168 = uVar1 << 8 | _DAT_40001168 & 0xffffc0ff; + printf("rosdac_q_gc0=%ld\r\n",uVar1); + rf_pri_restore_state_for_cal(); + _DAT_40001014 = _DAT_40001014 | 0xc000; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_rccal(void) + +{ + rf_calib_data_tag *prVar1; + uint32_t uVar2; + uint32_t uVar3; + uint uVar4; + uint uVar5; + + _DAT_40001014 = _DAT_40001014 & 0xfff3ffff; + if ((_DAT_40001020 & 0x400) != 0) { + _DAT_40001014 = _DAT_40001014 | 0x40000; + rf_pri_save_state_for_cal(); + rf_pri_manu_pu(4); + _DAT_40001084 = _DAT_40001084 & 0xfcffffff | 0x2000000; + _DAT_4000108c = _DAT_4000108c | 0x1000; + _DAT_4000101c = _DAT_4000101c | 0x800; + uVar2 = rf_pri_rccal_iq(1); + uVar3 = rf_pri_rccal_iq(0); + prVar1 = rf_calib_data; + uVar5 = _DAT_40001080; + *(uint *)&(rf_calib_data->cal).field_0x4 = + *(uint *)&(rf_calib_data->cal).field_0x4 & 0xffffffc0 | _DAT_40001080 >> 0x18 & 0x3f; + *(uint *)&(prVar1->cal).field_0x4 = + *(uint *)&(prVar1->cal).field_0x4 & 0xfffff03f | (uVar5 >> 0x10 & 0x3f) << 6; + *(uint *)&(prVar1->cal).field_0x4 = + *(uint *)&(prVar1->cal).field_0x4 & 0xfffc0fff | (uVar5 >> 8 & 0x3f) << 0xc; + *(uint *)&(prVar1->cal).field_0x4 = + (uVar5 & 0x3f) << 0x12 | *(uint *)&(prVar1->cal).field_0x4 & 0xff03ffff; + printf("rbb_cap1_fc_i=%ld,rbb_cap2_fc_i=%ld,rbb_cap1_fc_q=%ld,rbb_cap2_fc_q=%ld\r\n", + *(uint *)&(prVar1->cal).field_0x4 & 0x3f,*(uint *)&(prVar1->cal).field_0x4 >> 0xc & 0x3f, + *(uint *)&(prVar1->cal).field_0x4 >> 6 & 0x3f, + *(uint *)&(prVar1->cal).field_0x4 >> 0x12 & 0x3f); + prVar1 = rf_calib_data; + uVar5 = *(uint *)&(rf_calib_data->cal).field_0x4 & 0x3f; + if (uVar5 < (*(uint *)&(rf_calib_data->cal).field_0x4 >> 6 & 0x3f)) { + uVar5 = *(uint *)&(rf_calib_data->cal).field_0x4 >> 6 & 0x3f; + } + if (uVar5 < (*(uint *)&(rf_calib_data->cal).field_0x4 >> 0xc & 0x3f)) { + uVar5 = *(uint *)&(rf_calib_data->cal).field_0x4 >> 0xc & 0x3f; + } + if (uVar5 < (*(uint *)&(rf_calib_data->cal).field_0x4 >> 0x12 & 0x3f)) { + uVar5 = *(uint *)&(rf_calib_data->cal).field_0x4 >> 0x12 & 0x3f; + } + uVar4 = 0x18; + if (0x27 < uVar5) { + uVar4 = 0x3f - uVar5; + } + uVar4 = uVar4 & 0xff; + *(uint *)&(rf_calib_data->cal).field_0x4 = + *(uint *)&(rf_calib_data->cal).field_0x4 & 0xffffffc0 | + *(int *)&(rf_calib_data->cal).field_0x4 + uVar4 & 0x3f; + *(uint *)&(prVar1->cal).field_0x4 = + ((*(uint *)&(prVar1->cal).field_0x4 >> 6) + uVar4 & 0x3f) << 6 | + *(uint *)&(prVar1->cal).field_0x4 & 0xfffff03f; + *(uint *)&(prVar1->cal).field_0x4 = + ((*(uint *)&(prVar1->cal).field_0x4 >> 0xc) + uVar4 & 0x3f) << 0xc | + *(uint *)&(prVar1->cal).field_0x4 & 0xfffc0fff; + *(uint *)&(prVar1->cal).field_0x4 = + ((*(uint *)&(prVar1->cal).field_0x4 >> 0x12) + uVar4 & 0x3f) << 0x12 | + *(uint *)&(prVar1->cal).field_0x4 & 0xff03ffff; + rf_pri_rccal_config(*(uint *)&(prVar1->cal).field_0x4 & 0x3f); + rf_pri_rccal_config(0,*(uint *)&(rf_calib_data->cal).field_0x4 >> 6 & 0x3f); + printf("new rbb_cap1_fc_i=%ld,rbb_cap2_fc_i=%ld,rbb_cap1_fc_q=%ld,rbb_cap2_fc_q=%ld\r\n", + *(uint *)&(rf_calib_data->cal).field_0x4 & 0x3f, + *(uint *)&(rf_calib_data->cal).field_0x4 >> 0xc & 0x3f, + *(uint *)&(rf_calib_data->cal).field_0x4 >> 6 & 0x3f, + *(uint *)&(rf_calib_data->cal).field_0x4 >> 0x12 & 0x3f); + rf_pri_restore_state_for_cal(); + if ((uVar2 == 2) || (uVar3 == 2)) { + _DAT_40001014 = _DAT_40001014 & 0xfff3ffff | 0x80000; + } + else { + _DAT_40001014 = _DAT_40001014 | 0xc0000; + } + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_lo_acal(void) + +{ + uint uVar1; + int iVar2; + int iVar3; + uint32_t *puVar4; + uint32_t *puVar5; + uint uVar6; + + _DAT_40001014 = _DAT_40001014 & 0xffffff3f | 0x40; + rf_pri_save_state_for_cal(); + rf_pri_manu_pu(6); + puVar4 = channel_div_table; + iVar3 = 0; + do { + _DAT_4000101c = _DAT_4000101c | 0x10; + _DAT_400010a4 = _DAT_400010a4 & 0xfffff8ff | 0x400; + uVar6 = 3; + uVar1 = 0x10; + _DAT_400010a0 = + (uint)*(ushort *)(&(rf_calib_data->cal).field_0x8 + (iVar3 + 8) * 2) & 0xff | + _DAT_400010a0 & 0xffe0ff00 | 0x100000; + _DAT_400010c4 = *puVar4; + BL602_Delay_US(1); + while (_DAT_400010a0 = _DAT_400010a0 & 0xffe0ffff | uVar1 << 0x10, uVar6 != 0xffffffff) { + BL602_Delay_US(1); + iVar2 = 1 << (uVar6 & 0x1f); + if ((int)(_DAT_400010a4 << 0x13) < 0) { + iVar2 = -iVar2; + } + uVar1 = uVar1 + iVar2; + uVar6 = uVar6 - 1; + } + BL602_Delay_US(1); + if ((-1 < (int)(_DAT_400010a4 << 0x13)) && (uVar1 < 0x1f)) { + uVar1 = uVar1 + 1; + } + puVar5 = (uint32_t *)((int)&rf_calib_data->inited + (iVar3 + 8) * 2); + *(ushort *)(puVar5 + 3) = *(ushort *)(puVar5 + 3) & 0xe0ff | (ushort)((uVar1 & 0x1f) << 8); + printf("%ldth channel,vco_idac_cw=%ld\r\n",iVar3,uVar1); + iVar3 = iVar3 + 1; + puVar4 = puVar4 + 1; + } while (iVar3 != 0x15); + rf_pri_restore_state_for_cal(); + _DAT_40001014 = _DAT_40001014 | 0xc0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_fcal(void) + +{ + uint cw; + uint16_t uVar1; + undefined2 extraout_var; + undefined2 extraout_var_00; + int iVar2; + uint32_t *puVar3; + uint uVar4; + uint uVar5; + uint cw_00; + uint16_t *puVar6; + uint uVar7; + + cw_00 = (uint)channel_cnt_range[0]; + uVar7 = (uint)channel_cnt_range[1]; + uVar5 = (uint)channel_cnt_range[2]; + _DAT_40001014 = _DAT_40001014 & 0xffffffcf | 0x10; + rf_pri_save_state_for_cal(); + rf_pri_manu_pu(7); + _DAT_4000101c = _DAT_4000101c | 8; + _DAT_400010a0 = _DAT_400010a0 & 0xffffff00 | 0x80; + _DAT_400010a8 = (uint)fcal_div | _DAT_400010a8 & 0xffff0000; + _DAT_400010c4 = 0x1000000; + _DAT_400010c0 = _DAT_400010c0 & 0xfffeffff | 0x1000; + _DAT_400010b8 = _DAT_400010b8 & 0xffffcfff | 0x10000; + BL602_Delay_US(10); + _DAT_400010c0 = _DAT_400010c0 | 0x10000; + _DAT_400010b8 = _DAT_400010b8 & 0xfffeffff; + BL602_Delay_US(0x32); + _DAT_400010a4 = _DAT_400010a4 & 0xfffffffc | 2; + BL602_Delay_US(0x32); + do { + uVar4 = 6; + cw = 0x80; + while (uVar4 != 0xffffffff) { + uVar1 = rf_pri_fcal_meas(cw); + if (CONCAT22(extraout_var,uVar1) < cw_00) { + iVar2 = -(1 << (uVar4 & 0x1f)); + } + else { + if (CONCAT22(extraout_var,uVar1) <= uVar7) break; + iVar2 = 1 << (uVar4 & 0x1f); + } + cw = cw + iVar2 & 0xffff; + uVar4 = uVar4 - 1; + } + if (0xe < cw) break; + printf("Unexpected cw %ld\r\n",cw); + _DAT_400010c0 = _DAT_400010c0 & 0xfffeffff; + _DAT_400010b8 = _DAT_400010b8 | 0x10000; + BL602_Delay_US(0x32); + _DAT_400010c0 = _DAT_400010c0 | 0x10000; + _DAT_400010b8 = _DAT_400010b8 & 0xfffeffff; + BL602_Delay_US(0x32); + } while( true ); + cw_00 = cw + 1 & 0xffff; + channel_cnt_opt_table[0] = rf_pri_fcal_meas(cw_00); + puVar6 = channel_cnt_opt_table; + do { + cw_00 = cw_00 - 1 & 0xffff; + uVar1 = rf_pri_fcal_meas(cw_00); + puVar6[1] = uVar1; + if (uVar5 < CONCAT22(extraout_var_00,uVar1)) break; + puVar6 = puVar6 + 1; + } while (cw_00 != (cw - 0x26 & 0xffff)); + iVar2 = 0; + uVar5 = 0; + puVar6 = channel_cw_table; + do { + while (cw_00 = uVar5 & 0xffff, + channel_cnt_opt_table[uVar5] < *(ushort *)((int)channel_cnt_table + iVar2)) { + uVar5 = (int)((cw_00 + 1) * 0x10000) >> 0x10; + } + *(short *)((int)channel_cw_table + iVar2) = ((short)cw + 2) - (short)cw_00; + if ((int)uVar5 < 1) { + uVar5 = 0; + } + else { + uVar5 = (int)((cw_00 - 1) * 0x10000) >> 0x10; + } + iVar2 = iVar2 + 2; + } while (iVar2 != 0x2a); + rf_pri_restore_state_for_cal(); + iVar2 = 0; + do { + puVar3 = (uint32_t *)((int)&rf_calib_data->inited + (iVar2 + 8) * 2); + iVar2 = iVar2 + 1; + *(ushort *)(puVar3 + 3) = *(ushort *)(puVar3 + 3) & 0xff00 | *puVar6 & 0xff; + printf("%ldth channel,lo_vco_freq_cw=%ld\r\n"); + puVar6 = puVar6 + 1; + } while (iVar2 != 0x15); + _DAT_40001014 = _DAT_40001014 | 0x30; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_full_cal(void) + +{ + _DAT_40001220 = _DAT_40001220 & 0xffffff9f | 0x61; + rf_pri_start_txdfe(); + rf_pri_fcal(); + rf_pri_lo_acal(); + rf_pri_roscal(); + rf_pri_rccal(); + rf_pri_txcal(); + _DAT_4000100c = _DAT_4000100c | 6; + _DAT_40001220 = _DAT_40001220 & 0xffffe61c; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_restore_cal_reg(void) + +{ + _DAT_40001168 = + (*(uint *)(rf_calib_data->rxcal + 1) >> 6 & 0x3f) << 0x18 | + (*(uint *)rf_calib_data->rxcal >> 6 & 0x3f) << 8 | + *(uint *)rf_calib_data->rxcal & 0x3f | _DAT_40001168 & 0xc0c0c0c0 | + (*(uint *)(rf_calib_data->rxcal + 1) & 0x3f) << 0x10; + _DAT_4000116c = + (*(uint *)(rf_calib_data->rxcal + 3) >> 6 & 0x3f) << 0x18 | + (*(uint *)(rf_calib_data->rxcal + 2) >> 6 & 0x3f) << 8 | + *(uint *)(rf_calib_data->rxcal + 2) & 0x3f | _DAT_4000116c & 0xc0c0c0c0 | + (*(uint *)(rf_calib_data->rxcal + 3) & 0x3f) << 0x10; + _DAT_40001080 = + (*(uint *)&(rf_calib_data->cal).field_0x4 >> 6 & 0x3f) << 0x10 | + (*(uint *)&(rf_calib_data->cal).field_0x4 >> 0xc & 0x3f) << 8 | + (*(uint *)&(rf_calib_data->cal).field_0x4 & 0x3f) << 0x18 | _DAT_40001080 & 0xc0c0c0c0 | + *(uint *)&(rf_calib_data->cal).field_0x4 >> 0x12 & 0x3f; + rf_pri_txcal_config_hw(); + _DAT_40001070 = + (*(uint *)(rf_calib_data->txcal + 3) >> 6 & 0x3f) << 0x10 | + (*(uint *)(rf_calib_data->txcal + 3) & 0x3f) << 0x18 | _DAT_40001070 & 0xc0c0ffff; + _DAT_40001600 = + *(uint *)(rf_calib_data->txcal + 3) & 0x7ff000 | _DAT_40001600 & 0xff800c00 | + *(uint *)&rf_calib_data->txcal[3].field_0x4 & 0x3ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_init(uint8_t reset,uint8_t chipv) + +{ + undefined3 in_register_00002029; + int iVar1; + + iVar1 = CONCAT31(in_register_00002029,reset); + rf_pri_chipv(chipv); + init_fast = (uint32_t)(iVar1 == 0); + _DAT_4000f814 = _DAT_4000f814 & 0xfffff0ff | 0x300; + _DAT_4000f030 = _DAT_4000f030 & 0xf0ffffff | 0x8000000; + _DAT_40001030 = _DAT_40001030 | 0x1001; + _DAT_4000f884 = _DAT_4000f884 | 4; + if (iVar1 != 0) { + BL602_Delay_MS(10); + } + _DAT_40001064 = _DAT_40001064 & 0xffff8008 | opti_regs->vbcore << 8 | opti_regs->iet << 4 | 0x4002 + ; + _DAT_40001128 = + _DAT_40001128 & 0xff800fff | opti_regs->vbcore_11n << 0x10 | opti_regs->iet_11n << 0xc | + 0x400000; + _DAT_4000112c = + (_DAT_4000112c & 0xfffff800 | opti_regs->vbcore_11g << 4 | opti_regs->iet_11g) & 0xff800fff | + 0x400 | opti_regs->vbcore_11b << 0x10 | opti_regs->iet_11b << 0xc | 0x400000; + _DAT_40001090 = _DAT_40001090 | 0x10000; + _DAT_400010b8 = opti_regs->lo_fbdv_halfstep_en << 4 | _DAT_400010b8 & 0xffffffef; + _DAT_40001138 = + (_DAT_40001138 & 0xfffffffc | opti_regs->lo_fbdv_halfstep_en_tx << 1 | + opti_regs->lo_fbdv_halfstep_en_tx) & 0xfffcfff7 | 0x300; + _DAT_40001130 = _DAT_40001130 & 0xfffefffe; + _DAT_4000e400 = opti_regs->clkpll_reset_postdiv << 1 | _DAT_4000e400 & 0xfffffffd; + _DAT_4000e418 = opti_regs->clkpll_dither_sel << 0x18 | _DAT_4000e418 & 0xfcffffff; + _DAT_4000108c = _DAT_4000108c & 0xfffffffc | 2; + _DAT_4000f030 = _DAT_4000f030 & 0xfff0ffff | 0xc0000; + rf_pri_set_gain_table_regs(); + _DAT_4000e404 = _DAT_4000e404 | 0x10000; + _DAT_4000e41c = _DAT_4000e41c | 0xff; + if (iVar1 == 0) { + rf_pri_restore_cal_reg(); + return; + } + rf_pri_full_cal(); + return; +} + + + +void rf_pri_update_power_offset(int32_t *power_offset) + +{ + undefined4 uVar1; + int iVar2; + + iVar2 = 0; + do { + uVar1 = *(undefined4 *)((int)power_offset + iVar2); + *(undefined4 *)((int)tx_pwr_ch_os_a1 + iVar2) = uVar1; + *(undefined4 *)((int)tx_pwr_ch_os + iVar2) = uVar1; + iVar2 = iVar2 + 4; + } while (iVar2 != 0x38); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sysctrl_init(void) + +{ + _DAT_44900068 = 0x8000000c; + _DAT_449000e0 = _DAT_449000e0 | 0x1ff00; + return; +} + + + +void intc_spurious(void) + +{ + assert_err("0","module",0x36); + return; +} + + + +void intc_enable_irq(int index) + +{ + *(int *)(((index >> 5) + 0x11244004) * 4) = 1 << (index & 0x1fU); + return; +} + + + +void intc_init(void) + +{ + intc_enable_irq(0x3f); + intc_enable_irq(0x3e); + intc_enable_irq(0x3d); + intc_enable_irq(0x18); + intc_enable_irq(0x19); + intc_enable_irq(0x1a); + intc_enable_irq(0x1b); + intc_enable_irq(0x1c); + intc_enable_irq(0x1d); + intc_enable_irq(0x1e); + intc_enable_irq(0x1f); + intc_enable_irq(0x20); + intc_enable_irq(0x21); + intc_enable_irq(0x23); + intc_enable_irq(0x37); + intc_enable_irq(0x35); + intc_enable_irq(0x32); + intc_enable_irq(0x34); + intc_enable_irq(0x36); + intc_enable_irq(10); + intc_enable_irq(0xb); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mac_irq(void) + +{ + void_fn *pvVar1; + + if ((_DAT_44910000 == 0) && (_DAT_44910004 == 0)) { + return; + } + pvVar1 = intc_irq_handlers[_DAT_44910040]; + if (pvVar1 == (void_fn *)0x0) { + assert_err("intc_irq_handlers[irq_idx] != NULL","module",0x9d); + } + (*pvVar1)(); + ipc_emb_notify(); + return; +} + + + +void bl_irq_handler(void) + +{ + ipc_host_disable_irq_e2a(); + ke_evt_set(0x40000000); + ipc_emb_notify(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t blmac_soft_reset_getf(void) + +{ + uint uVar1; + + uVar1 = _DAT_44b08050; + if ((_DAT_44b08050 & 0xfffffffe) != 0) { + assert_err("(localVal & ~((uint32_t)0x00000001)) == 0","module",0x11d); + } + return (uint8_t)uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_wt_2_crypt_clk_ratio_setf(uint8_t wt2cryptclkratio) + +{ + undefined3 in_register_00002029; + + _DAT_44b000f0 = CONCAT31(in_register_00002029,wt2cryptclkratio) | _DAT_44b000f0 & 0xfffffffc; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_rx_flow_cntrl_en_setf(void) + +{ + _DAT_44b00054 = _DAT_44b00054 & 0xfffeffff | 0x10000; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_key_sto_ram_reset_setf(void) + +{ + _DAT_44b0004c = _DAT_44b0004c & 0xffffdfff | 0x2000; + return; +} + + +/* +Unable to decompile 'hal_machw_idle_req' +Cause: Exception while decompiling 23007232: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_machw_stop(void) + +{ + uint8_t uVar1; + undefined3 extraout_var; + + _DAT_44b08050 = 1; + do { + uVar1 = blmac_soft_reset_getf(); + } while (CONCAT31(extraout_var,uVar1) != 0); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_machw_init(void) + +{ + uint uVar1; + uint8_t wt2cryptclkratio; + undefined3 extraout_var; + uint uVar2; + undefined3 extraout_var_00; + uint uVar3; + uint uVar4; + + _DAT_44b08050 = 1; + do { + wt2cryptclkratio = blmac_soft_reset_getf(); + } while (CONCAT31(extraout_var,wt2cryptclkratio) != 0); + _DAT_44b00404 = 0x24f637; + _DAT_44b00400 = 0x49; + _DAT_44920004 = 0x5010001f; + wt2cryptclkratio = phy_get_mac_freq(); + uVar2 = CONCAT31(uVar2._1_3_,wt2cryptclkratio); + uVar1 = _DAT_44b000e4 & 0xff; + uVar3 = _DAT_44b000e4 & 0xffffff00 | 0x28; + uVar4 = (((_DAT_44b000e4 & 0x3ff00) >> 8) * uVar2) / uVar1 << 8; + _DAT_44b000e4 = uVar3; + if ((uVar4 & 0xfc0000) != 0) { + assert_err("(((uint32_t)txrfdelayinmacclk << 8) & ~((uint32_t)0x0003FF00)) == 0","module",0x1d59 + ); + } + _DAT_44b000e4 = (_DAT_44b000e4 & 0xfffc00ff | uVar4 & 0xffff00) & 0xf003ffff | 0x2200000; + _DAT_44b000e8 = + (((_DAT_44b000e8 >> 8 & 0xffff) * uVar2) / uVar1 & 0xffff) << 8 | _DAT_44b000e8 & 0xff0000ff; + uVar3 = _DAT_44b000ec & 0xc00fffff | 0x2700000; + uVar4 = (((_DAT_44b000ec & 0xffc00) >> 10) * uVar2) / uVar1 << 10; + _DAT_44b000ec = uVar3; + if ((uVar4 & 0x3f00000) != 0) { + assert_err("(((uint32_t)txdelayrfoninmacclk << 10) & ~((uint32_t)0x000FFC00)) == 0","module", + 0x1ea2); + } + wt2cryptclkratio = '\x03'; + _DAT_44b000ec = _DAT_44b000ec & 0xfff00000 | uVar4 & 0x3fffc00 | 0xb4; + if ((0x1d < uVar2) && (wt2cryptclkratio = '\x02', 0x3b < uVar2)) { + wt2cryptclkratio = '\x01'; + } + blmac_wt_2_crypt_clk_ratio_setf(wt2cryptclkratio); + _DAT_44b000f4 = + (((_DAT_44b000f4 >> 8 & 0xffff) * uVar2) / uVar1 & 0xffff) << 8 | _DAT_44b000f4 & 0xff0000ff; + _DAT_44b000f8 = + (((_DAT_44b000f8 >> 8 & 0xffff) * uVar2) / uVar1 & 0xffff) << 8 | _DAT_44b000f8 & 0xff0000ff; + uVar3 = ((_DAT_44b00104 >> 0x14 & 0x3ff) * uVar2) / uVar1 << 0x14; + if ((uVar3 & 0xc0000000) != 0) { + assert_err("(((uint32_t)rifstoinmacclk << 20) & ~((uint32_t)0x3FF00000)) == 0","module",0x228a); + } + uVar3 = _DAT_44b00104 & 0xc00fffff | uVar3; + uVar4 = (((_DAT_44b00104 & 0xffc00) >> 10) * uVar2) / uVar1 << 10; + _DAT_44b00104 = uVar3; + if ((uVar4 & 0x3f00000) != 0) { + assert_err("(((uint32_t)rifsinmacclk << 10) & ~((uint32_t)0x000FFC00)) == 0","module",0x22a4); + } + uVar3 = _DAT_44b00104 & 0xfff003ff | uVar4 & 0x3fffc00; + uVar1 = ((_DAT_44b00104 & 0x3ff) * uVar2) / uVar1; + _DAT_44b00104 = uVar3; + if ((uVar1 & 0xfc00) != 0) { + assert_err("(((uint32_t)txdmaprocdlyinmacclk << 0) & ~((uint32_t)0x000003FF)) == 0","module", + 0x22be); + } + _DAT_44b00104 = _DAT_44b00104 & 0xfffffc00 | uVar1 & 0xffff; + _DAT_44b08074 = 0x8373f14c; + _DAT_44b0004c = _DAT_44b0004c & 0xfffff7ff; + if (_DAT_44b000d8 >> 0x18 < 0x11) { + assert_err("MM_STA_TO_KEY(NX_REMOTE_STA_MAX - 1) <= blmac_sta_key_max_index_getf()","module", + 0x124); + } + printf("[WF] [KEY] [CFG] nVAP is %d, endidx %d, startidx %d\r\n",2,0x11,8); + _DAT_44b000d8 = 0x21108; + _DAT_44b08080 = 0x800a07c0; + _DAT_44b0004c = _DAT_44b0004c | 0x4000780; + blmac_rx_flow_cntrl_en_setf(); + _DAT_44b00060 = 0x7fffffde; + _DAT_44b00114 = 0x3010a; + _DAT_44b00064 = 0xff900064; + _DAT_44b00150 = 0x1000; + _DAT_44b00224 = 0; + _DAT_44b000a0 = 0x2020; + _DAT_44b0004c = _DAT_44b0004c & 0xffffefff | 0x1000; + blmac_key_sto_ram_reset_setf(); + _DAT_44b00510 = 0x1c25; + _DAT_44b00310 = _DAT_44b00310 | 0x80; + wt2cryptclkratio = phy_get_ntx(); + uVar1 = (CONCAT31(extraout_var_00,wt2cryptclkratio) + 1) * 0x4000000; + if ((uVar1 & 0xe0000000) != 0) { + assert_err("(((uint32_t)maxphyntx << 26) & ~((uint32_t)0x1C000000)) == 0","module",0x1539); + } + _DAT_44b0004c = _DAT_44b0004c & 0xfdffffff | 0x2000000; + _DAT_44b0009c = _DAT_44b0009c & 0xe3ffffff | uVar1; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_machw_disable_int(void) + +{ + _DAT_44b08074 = _DAT_44b08074 & 0x7fffffff; + _DAT_44b08080 = _DAT_44b08080 & 0x7fffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_machw_reset(void) + +{ + char "hal_machw_reset" [16]; + + if ((_DAT_44b00038 & 0xf) != 0) { + helper_record_all_states("hal_machw_reset"); + } + _DAT_44b0004c = _DAT_44b0004c & 0xffffff7f; + _DAT_44b00038 = 0; + _DAT_44b00054 = 0x7c; + ps_env.prevent_sleep = ps_env.prevent_sleep & 0xfffffffb; + blmac_rx_flow_cntrl_en_setf(); + _DAT_44b0004c = _DAT_44b0004c | 0x80; + _DAT_44b08070 = 0x37ff187; + _DAT_44b08074 = _DAT_44b08074 & 0x7fffffff | 0x80000000; + _DAT_44b0807c = 0xffffffff; + _DAT_44b08080 = _DAT_44b08080 & 0x7fffffff | 0x80000000; + _DAT_44b0808c = _DAT_44b0808c & 0xffffffc0; + return; +} + + + +// WARNING: Removing unreachable block (ram,0x230077f2) +// WARNING: Removing unreachable block (ram,0x230077fe) +// WARNING: Removing unreachable block (ram,0x23007808) + +uint8_t hal_machw_search_addr(mac_addr *addr) + +{ + // WARNING: Do nothing block with infinite loop + do { + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_machw_monitor_mode(void) + +{ + _DAT_44b08074 = _DAT_44b08074 & 0xfffffffc; + mm_env.rx_filter_umac = 0x7fffffde; + _DAT_44b00060 = mm_env.rx_filter_lmac_enable | 0x7fffffde; + _DAT_44b0004c = _DAT_44b0004c & 0xfffe3fff | 0xc700; + blmac_key_sto_ram_reset_setf(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +_Bool hal_machw_sleep_check(void) + +{ + uint uVar1; + + uVar1 = 0; + while (((1 << (uVar1 & 0x1f) & _DAT_44b0808c) == 0 || + (-1 < (-2000 - _DAT_44b00120) + *(int *)(&DAT_44b00128 + uVar1 * 4)))) { + uVar1 = uVar1 + 1; + if (uVar1 == 9) { + return true; + } + } + if (-1 < (5000 - _DAT_44b00120) + *(int *)(&DAT_44b00128 + uVar1 * 4)) { + return false; + } + assert_err("!hal_machw_time_past(blmac_abs_timer_get(i) + 5000)","module",0x208); + return false; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_machw_gen_handler(void) + +{ + uint uVar1; + uint uVar2; + char *condition; + int line; + + uVar2 = _DAT_44b08074 & _DAT_44b0806c; + _DAT_44b08070 = uVar2; + if ((uVar2 & 0x40001) != 0) { + ke_evt_set(0x400000); + } + if ((uVar2 & 0x80002) != 0) { + ke_evt_set(0x200000); + } + if ((uVar2 & 4) != 0) { + if ((_DAT_44b00038 & 0xf) == 0) { + _DAT_44b0808c = _DAT_44b0808c & 0xffffffdf; + ps_env.prevent_sleep = ps_env.prevent_sleep & 0xfffffffb; + ke_evt_set(0x800000); + } + else { + assert_rec("blmac_current_state_getf() == HW_IDLE","module",0x8c); + } + } + uVar1 = _DAT_44b08084; + if ((uVar2 & 8) != 0) { + _DAT_44b08088 = _DAT_44b08084; + if ((_DAT_44b08084 & 0x100) != 0) { + ke_evt_set(0x4000000); + } + if ((uVar1 & 0x40) != 0) { + rxl_timeout_int_handler(); + } + if ((uVar1 & 0x80) != 0) { + ke_evt_set(0x8000000); + } + if ((uVar1 & 1) != 0) { + assert_rec("HAL_AC0_TIMER_BIT timeout ","module",0x22f); + } + if ((uVar1 & 2) == 0) { + if ((uVar1 & 4) == 0) { + if ((uVar1 & 8) == 0) { + if ((uVar1 & 0x10) == 0) { + if ((uVar1 & 0x20) == 0) goto LAB_230079a6; + line = 0x236; + condition = "!(timer_pending & HAL_IDLE_TIMER_BIT)"; + } + else { + line = 0x235; + condition = "!(timer_pending & HAL_BCN_TIMER_BIT)"; + } + } + else { + line = 0x234; + condition = "!(timer_pending & HAL_AC3_TIMER_BIT)"; + } + } + else { + line = 0x233; + condition = "!(timer_pending & HAL_AC2_TIMER_BIT)"; + } + } + else { + line = 0x232; + condition = "!(timer_pending & HAL_AC1_TIMER_BIT)"; + } + assert_rec(condition,"module",line); + } +LAB_230079a6: + if ((uVar2 & 0x80) == 0) { + if ((uVar2 & 0x100) == 0) { + if ((int)(uVar2 << 0x13) < 0) { + line = 0x27a; + condition = "!(genirq_pending & NXMAC_PT_ERROR_BIT)"; + } + else { + if ((int)(uVar2 << 0x12) < 0) { + line = 0x27b; + condition = "!(genirq_pending & NXMAC_AC_0_TX_DMA_DEAD_BIT)"; + } + else { + if ((int)(uVar2 << 0x11) < 0) { + line = 0x27c; + condition = "!(genirq_pending & NXMAC_AC_1_TX_DMA_DEAD_BIT)"; + } + else { + if ((int)(uVar2 << 0x10) < 0) { + line = 0x27d; + condition = "!(genirq_pending & NXMAC_AC_2_TX_DMA_DEAD_BIT)"; + } + else { + if ((int)(uVar2 << 0xf) < 0) { + line = 0x27e; + condition = "!(genirq_pending & NXMAC_AC_3_TX_DMA_DEAD_BIT)"; + } + else { + if ((int)(uVar2 << 0xe) < 0) { + line = 0x27f; + condition = "!(genirq_pending & NXMAC_BCN_TX_DMA_DEAD_BIT)"; + } + else { + if ((int)(uVar2 << 10) < 0) { + line = 0x280; + condition = "!(genirq_pending & NXMAC_MAC_PHYIF_UNDER_RUN_BIT)"; + } + else { + if ((int)(uVar2 << 9) < 0) { + line = 0x281; + condition = "!(genirq_pending & NXMAC_PHY_ERR_BIT)"; + } + else { + if ((int)(uVar2 << 7) < 0) { + line = 0x282; + condition = "!(genirq_pending & NXMAC_RX_HEADER_DMA_DEAD_BIT)"; + } + else { + if ((int)(uVar2 << 6) < 0) { + line = 0x283; + condition = "!(genirq_pending & NXMAC_RX_PAYLOAD_DMA_DEAD_BIT)"; + } + else { + if (-1 < (int)(uVar2 << 0xb)) { + return; + } + line = 0x284; + condition = "!(genirq_pending & NXMAC_HW_ERR_BIT)"; + } + } + } + } + } + } + } + } + } + } + } + else { + line = 0x279; + condition = "!(genirq_pending & NXMAC_RX_FIFO_OVER_FLOW_BIT)"; + } + } + else { + line = 0x278; + condition = "!(genirq_pending & NXMAC_RX_DMA_EMPTY_BIT)"; + } + assert_rec(condition,"module",line); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_rx_filter_set(void) + +{ + _DAT_44b00060 = mm_env.rx_filter_lmac_enable | mm_env.rx_filter_umac; + return; +} + + + +int element_notify_status_enabled + (cfg_element_entry *entry,void *arg1,void *arg2,CFG_ELEMENT_TYPE_OPS ops) + +{ + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_ap_setf(uint8_t ap) + +{ + undefined3 in_register_00002029; + + _DAT_44b0004c = CONCAT31(in_register_00002029,ap) << 1 | _DAT_44b0004c & 0xfffffffd; + return; +} + + + +uchar ascii_to_hex(char asccode) + +{ + char cVar1; + byte bVar2; + + bVar2 = asccode - 0x30; + if (9 < bVar2) { + if ((byte)(asccode + 0x9fU) < 6) { + cVar1 = -0x57; + } + else { + if (5 < (byte)(asccode + 0xbfU)) { + return '\0'; + } + cVar1 = -0x37; + } + bVar2 = asccode + cVar1; + } + return (uchar)bVar2; +} + + + +undefined4 element_notify_time_last_received_set(void) + +{ + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_encr_cntrl_pack + (uint8_t newread,uint8_t newwrite,uint16_t keyindexram,uint8_t ctyperam, + uint8_t vlanidram,uint8_t sppram,uint8_t usedefkeyram,uint8_t clenram) + +{ + uint uVar1; + undefined3 in_register_00002035; + undefined3 in_register_00002039; + undefined3 in_register_0000203d; + undefined3 in_register_00002041; + undefined3 in_register_00002045; + uint uVar2; + + uVar2 = CONCAT31(in_register_00002039,vlanidram) << 4; + if ((uVar2 & 0xffffff0f) != 0) { + assert_err("(((uint32_t)vlanidram << 4) & ~((uint32_t)0x000000F0)) == 0","module",0x1873); + } + uVar1 = CONCAT31(in_register_0000203d,sppram) << 2; + if ((uVar1 & 0xfffffff3) != 0) { + assert_err("(((uint32_t)sppram << 2) & ~((uint32_t)0x0000000C)) == 0","module",0x1874); + } + _DAT_44b000c4 = + (uint)newread << 0x1f | CONCAT31(in_register_00002045,clenram) | + CONCAT31(in_register_00002041,usedefkeyram) << 1 | uVar1 | uVar2 | + CONCAT31(in_register_00002035,ctyperam) << 8 | (uint)keyindexram << 0x10 | + (uint)newwrite << 0x1e; + return; +} + + + +undefined4 element_notify_keepalive_received(void) + +{ + return 0; +} + + + +// WARNING: Removing unreachable block (ram,0x23007d64) +// WARNING: Removing unreachable block (ram,0x23007d6e) +// WARNING: Removing unreachable block (ram,0x23007d96) +// WARNING: Removing unreachable block (ram,0x23007d8a) +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t hal_machw_rx_duration(rx_hd *rhd,uint16_t len) + +{ + if ((""[rhd->recvec1a >> 0xc & 0xf] & 0x80) != 0) { + assert_err("(((uint32_t)ppdumcsindex << 0) & ~((uint32_t)0x0000007F)) == 0","module",0x1a99); + } + do { + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_env_max_ampdu_duration_set(void) + +{ + mm_env.ampdu_max_dur[0] = 0x96; + if (((_DAT_44b00200 >> 0xc & 0xffff) != 0) && ((_DAT_44b00200 >> 0xc & 0xffff) < 0x97)) { + mm_env.ampdu_max_dur[0] = (uint16_t)(_DAT_44b00200 >> 0xc); + } + mm_env.ampdu_max_dur[1] = 0x96; + if (((_DAT_44b00204 >> 0xc & 0xffff) != 0) && ((_DAT_44b00204 >> 0xc & 0xffff) < 0x97)) { + mm_env.ampdu_max_dur[1] = (uint16_t)(_DAT_44b00204 >> 0xc); + } + mm_env.ampdu_max_dur[2] = 0x96; + if (((_DAT_44b00208 >> 0xc & 0xffff) != 0) && ((_DAT_44b00208 >> 0xc & 0xffff) < 0x97)) { + mm_env.ampdu_max_dur[2] = (uint16_t)(_DAT_44b00208 >> 0xc); + } + mm_env.ampdu_max_dur[3] = 0x96; + if (((_DAT_44b0020c >> 0xc & 0xffff) != 0) && ((_DAT_44b0020c >> 0xc & 0xffff) < 0x97)) { + mm_env.ampdu_max_dur[3] = (uint16_t)(_DAT_44b0020c >> 0xc); + } + mm_env.ampdu_max_dur[4] = mm_env.ampdu_max_dur[3]; + return; +} + + + +void mm_env_init(void) + +{ + memset(&mm_env,0,0x2c); + mm_env._34_2_ = 0x101; + mm_env._18_2_ = 0; + mm_env.rx_filter_lmac_enable = 0; + mm_env.rx_filter_umac = 0x7fffffde; + mm_rx_filter_set(); + mm_env_max_ampdu_duration_set(); + return; +} + + + +void mm_init(void) + +{ + hal_machw_init(); + mm_env_init(); + vif_mgmt_init(); + sta_mgmt_init(); + td_init(); + ps_init(); + txl_cntrl_init(); + rxl_init(); + mm_timer_init(); + scan_init(); + chan_init(); + hal_dma_init(); + mm_bcn_init(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_active(void) + +{ + _DAT_44b00038 = 0x30; + ke_state_set(0,1); + return; +} + + + +void mm_reset(void) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(0); + if (CONCAT22(extraout_var,kVar1) == 1) { + mm_active(); + return; + } + ke_state_set(0,0); + return; +} + + +/* +Unable to decompile 'mm_tbtt_evt' +Cause: Exception while decompiling 23007f26: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t mm_sec_machwaddr_wr(uint8_t sta_idx,uint8_t inst_nbr) + +{ + uint uVar1; + undefined3 in_register_00002029; + int iVar2; + + iVar2 = CONCAT31(in_register_00002029,sta_idx); + uVar1 = iVar2 + 8U & 0xff; + _DAT_44b000bc = *(undefined4 *)sta_info_tab[iVar2].mac_addr.array; + _DAT_44b000c0 = (uint)sta_info_tab[iVar2].mac_addr.array[2]; + _DAT_44b000ac = 0; + _DAT_44b000b0 = 0; + _DAT_44b000b4 = 0; + _DAT_44b000b8 = 0; + blmac_encr_cntrl_pack('\0','\x01',(uint16_t)uVar1,'\0',inst_nbr,'\0','\x01','\0'); + do { + } while (_DAT_44b000c4 << 1 < 0); + return (uint8_t)uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t mm_sec_machwkey_wr(mm_key_add_req *param) + +{ + byte bVar1; + byte vlanidram; + uint16_t keyindexram; + uint uVar2; + uint8_t ctyperam; + uint8_t clenram; + uint uVar3; + + bVar1 = param->sta_idx; + uVar3 = (uint)bVar1; + vlanidram = param->inst_nbr; + if (bVar1 == 0xff) { + uVar3 = (uint)vlanidram * 4 + (uint)param->key_idx & 0xff; + keyindexram = (uint16_t)uVar3; + _DAT_44b000bc = 0xffffffff; + _DAT_44b000c0 = 0xffffffff; + vif_mgmt_add_key(param,(uint8_t)uVar3); + } + else { + if (0xb < bVar1) { + assert_err("sta_idx < STA_MAX","module",0x3e4); + } + uVar2 = uVar3 + 8 & 0xff; + keyindexram = (uint16_t)uVar2; + sta_mgmt_add_key(param,(uint8_t)uVar2); + _DAT_44b000bc = *(undefined4 *)sta_info_tab[uVar3].mac_addr.array; + _DAT_44b000c0 = (uint)sta_info_tab[uVar3].mac_addr.array[2]; + } + bVar1 = param->cipher_suite; + if (bVar1 < 4) { + clenram = *(uint8_t *)((int)&CSWTCH_22 + (uint)bVar1); + ctyperam = *(uint8_t *)((int)&CSWTCH_23 + (uint)bVar1); + } + else { + assert_err("0","module",0x429); + ctyperam = '\0'; + clenram = '\x01'; + } + _DAT_44b000ac = (param->key).array[0]; + _DAT_44b000b0 = (param->key).array[1]; + _DAT_44b000b4 = (param->key).array[2]; + _DAT_44b000b8 = (param->key).array[3]; + blmac_encr_cntrl_pack('\0','\x01',keyindexram,ctyperam,vlanidram,param->spp,'\0',clenram); + do { + } while (_DAT_44b000c4 << 1 < 0); + return (uint8_t)keyindexram; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_sec_machwkey_del(uint8_t hw_key_idx) + +{ + undefined3 in_register_00002029; + uint uVar1; + uint uVar2; + + uVar1 = CONCAT31(in_register_00002029,hw_key_idx); + if (uVar1 < 8) { + _DAT_44b000bc = 0xffffffff; + _DAT_44b000c0 = 0xffffffff; + vif_mgmt_del_key(vif_info_tab + ((int)uVar1 >> 2),hw_key_idx & 3); + } + else { + uVar2 = uVar1 - 8 & 0xff; + _DAT_44b000bc = *(undefined4 *)sta_info_tab[uVar2].mac_addr.array; + _DAT_44b000c0 = (uint)sta_info_tab[uVar2].mac_addr.array[2]; + sta_mgmt_del_key(sta_info_tab + uVar2); + } + _DAT_44b000ac = 0; + _DAT_44b000b0 = 0; + _DAT_44b000b4 = 0; + _DAT_44b000b8 = 0; + blmac_encr_cntrl_pack('\0','\x01',(uint16_t)uVar1,'\0','\0','\0','\0','\0'); + do { + } while (_DAT_44b000c4 << 1 < 0); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_sec_machwaddr_del(uint8_t sta_idx) + +{ + _DAT_44b000bc = 0xffffffff; + _DAT_44b000c0 = 0xffffffff; + _DAT_44b000ac = 0; + _DAT_44b000b0 = 0; + _DAT_44b000b4 = 0; + _DAT_44b000b8 = 0; + blmac_encr_cntrl_pack('\0','\x01',(ushort)sta_idx + 8 & 0xff,'\0','\0','\0','\0','\0'); + do { + } while (_DAT_44b000c4 << 1 < 0); + return; +} + + + +void mm_hw_idle_evt(int dummy) + +{ + ke_evt_clear(0x800000); + ke_state_set(0,0); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_hw_info_set(mac_addr *mac_addr) + +{ + blmac_ap_setf('\0'); + _DAT_44b0001c = 0x100; + _DAT_44b080a4 = 0; + _DAT_44b080a8 = 0; + _DAT_44b00010 = *(undefined4 *)mac_addr->array; + _DAT_44b00014 = (uint)mac_addr->array[2]; + _DAT_44b0004c = _DAT_44b0004c & 0xfffff8ff | 1; + mm_env.rx_filter_umac = 0x3503858c; + mm_rx_filter_set(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_hw_ap_info_set(void) + +{ + blmac_ap_setf('\x01'); + mm_env.rx_filter_umac = 0x3507a58c; + mm_rx_filter_set(); + _DAT_44b08070 = 0x40001; + _DAT_44b08074 = _DAT_44b08074 | 0x40001; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_hw_ap_info_reset(void) + +{ + blmac_ap_setf('\0'); + mm_env.rx_filter_umac = 0x3503858c; + mm_rx_filter_set(); + _DAT_44b08070 = 0x40001; + _DAT_44b08074 = _DAT_44b08074 & 0xfffbfffe; + return; +} + + + +void mm_back_to_host_idle(void) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(0); + if (CONCAT22(extraout_var,kVar1) != 3) { + assert_err("ke_state_get(TASK_MM) == MM_HOST_BYPASSED","module",0x52a); + } + if (mm_env.host_idle == '\0') { + mm_active(); + return; + } + ke_state_set(0,0); + return; +} + + +/* +Unable to decompile 'mm_force_idle_req' +Cause: Exception while decompiling 230083e2: Decompiler process died + +*/ + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +uint8_t mm_sta_add(mm_sta_add_req *param,uint8_t *sta_idx,uint8_t *hw_sta_idx) + +{ + uint uVar1; + uint8_t uVar2; + uint8_t uVar3; + uchar uVar4; + uchar uVar5; + undefined3 extraout_var; + size_t sVar6; + int security_mode; + uint8_t *phrase; + int iVar7; + int iVar8; + _Bool is_pmf_required; + uint uVar9; + undefined2 uStack92; + mm_key_add_req key_add_req; + + uVar2 = sta_mgmt_register(param,sta_idx); + if (CONCAT31(extraout_var,uVar2) != 0) { + return uVar2; + } + uVar1 = (uint)param->inst_nbr; + uVar3 = mm_sec_machwaddr_wr(*sta_idx,param->inst_nbr); + *hw_sta_idx = uVar3; + if (vif_info_tab[uVar1].type != '\0') { + return uVar2; + } + if (vif_info_tab[uVar1].bss_info.is_supplicant_enabled == false) goto LAB_23008468; + sta_conn_info.staId = *sta_idx; + if ((*(uint *)&vif_info_tab[uVar1].bss_info.is_supplicant_enabled & 0x12800) == 0) { + if ((*(byte *)&vif_info_tab[uVar1].bss_info.wpa_wpa2_wep & 2) != 0) { + sVar6 = strlen((char *)(sm_env.connect_param)->phrase); + printf("wep:len:%d,password:%s\n",sVar6,(sm_env.connect_param)->phrase); + memset(&uStack92,0,0x2c); + key_add_req.key.array[7]._1_1_ = param->inst_nbr; + uStack92 = 0xff00; + sVar6 = strlen((char *)(sm_env.connect_param)->phrase); + uVar9 = sVar6 & 0xff; + key_add_req.key_idx = (uint8_t)uVar9; + if (uVar9 == 5) { + key_add_req.key.array[7]._0_1_ = '\0'; +LAB_2300859c: + memcpy(&key_add_req.key,(sm_env.connect_param)->phrase,sVar6 & 0xff); + } + else { + if (uVar9 == 0xd) { + key_add_req.key.array[7]._0_1_ = '\x03'; + goto LAB_2300859c; + } + if (uVar9 == 10) { + key_add_req.key.array[7]._0_1_ = '\0'; + } + else { + if (uVar9 != 0x1a) { + printf("password length is not correct for wep\n"); + sta_mgmt_unregister(*sta_idx); + return '\x01'; + } + key_add_req.key.array[7]._0_1_ = '\x03'; + } + uVar9 = sVar6 & 0xff; + if ((sVar6 & 1) != 0) { + uVar9 = sVar6 & 0xfe; + } + if (uVar9 != 0) { + iVar7 = 0; + phrase = (sm_env.connect_param)->phrase; + do { + uVar4 = ascii_to_hex(*phrase); + uVar5 = ascii_to_hex(phrase[1]); + (&key_add_req.key.length)[iVar7 >> 1] = uVar4 * '\x10' + uVar5; + iVar7 = iVar7 + 2; + phrase = phrase + 2; + } while (iVar7 < (int)uVar9); + } + key_add_req.key_idx = key_add_req.key_idx >> 1; + } + wep_hw_keyid = mm_sec_machwkey_wr((mm_key_add_req *)&uStack92); + } + } + else { + if ((sm_env.connect_param)->phrase_pmk[0] == '\0') { + phrase = (sm_env.connect_param)->phrase; + } + else { + phrase = (sm_env.connect_param)->phrase_pmk; + } + set_psk((char *)vif_info_tab[uVar1].bss_info.ssid.array,vif_info_tab[uVar1].bss_info.ssid.length + ,(char *)phrase); + } + iVar7 = uVar1 * 0x5d8; + if ((*(uint *)&vif_info_tab[uVar1].bss_info.is_supplicant_enabled & 0x12000) == 0) { + if ((*(byte *)&vif_info_tab[uVar1].bss_info.wpa_wpa2_wep & 8) != 0) { + iVar8 = iVar7 + 0x3ec; + iVar7 = iVar7 + 0x3eb; + is_pmf_required = vif_info_tab[uVar1].bss_info.is_pmf_required; + security_mode = 3; + goto LAB_230084fe; + } + } + else { + is_pmf_required = vif_info_tab[uVar1].bss_info.is_pmf_required; + iVar8 = iVar7 + 0x3ee; + iVar7 = iVar7 + 0x3ed; + security_mode = 4; +LAB_230084fe: + supplicantEnable(&sta_conn_info,security_mode, + (void *)((int)&vif_info_tab[0].list_hdr.next + iVar7), + (void *)((int)&vif_info_tab[0].list_hdr.next + iVar8),is_pmf_required); + } + if (vif_info_tab[uVar1].type != '\0') { + return uVar2; + } +LAB_23008468: + vif_info_tab[uVar1].u[4] = *sta_idx; + return '\0'; +} + + + +void mm_sta_del(uint8_t sta_idx) + +{ + uint uVar1; + undefined3 in_register_00002029; + undefined *puVar2; + byte bVar3; + uint uVar4; + + uVar4 = (uint)sta_info_tab[CONCAT31(in_register_00002029,sta_idx)].inst_nbr; + if (vif_info_tab[uVar4].type == '\0') { + vif_info_tab[uVar4].u[4] = 0xff; + if (vif_info_tab[uVar4].bss_info.is_supplicant_enabled != false) { + if ((*(uint *)&vif_info_tab[uVar4].bss_info.is_supplicant_enabled & 0x12800) == 0) { + if (((*(byte *)&vif_info_tab[uVar4].bss_info.wpa_wpa2_wep & 2) != 0) && (wep_hw_keyid != -1) + ) { + mm_sec_machwkey_del(wep_hw_keyid); + } + } + else { + mm_sec_machwkey_del(sta_conn_info.ptkHwKeyId); + mm_sec_machwkey_del(sta_conn_info.gtkHwKeyId); + mm_sec_machwkey_del(sta_conn_info.mfpHwKeyId); + supplicantDisable(&sta_conn_info); + memset(&(sta_conn_info.suppData)->hashSsId,0,0x22); + remove_psk((char *)vif_info_tab[uVar4].bss_info.ssid.array, + vif_info_tab[uVar4].bss_info.ssid.length); + } + vif_info_tab[uVar4].bss_info.is_supplicant_enabled = false; + } + } + else { + if ((sta_info_tab[CONCAT31(in_register_00002029,sta_idx)].ps_state == '\x01') && + (bVar3 = vif_info_tab[uVar4].u[0x2ee] - 1, vif_info_tab[uVar4].u[0x2ee] = bVar3, bVar3 == 0)) + { + uVar1 = (uint)vif_info_tab[uVar4].index + 10 & 0xff; + puVar2 = (undefined *)ke_msg_alloc(0x49,0xd,0,2); + sta_info_tab[uVar1].ps_state = '\0'; + *puVar2 = (char)uVar1; + puVar2[1] = 0; + ke_msg_send(); + apm_tx_int_ps_clear(vif_info_tab + uVar4,vif_info_tab[uVar4].index + '\n'); + } + } + mm_sec_machwaddr_del(sta_idx); + sta_mgmt_unregister(sta_idx); + return; +} + + + +void mm_cfg_element_keepalive_timestamp_update(void) + +{ + mm_env.keep_alive_time_last_received = xTaskGetTickCount(); + mm_env.keep_alive_packet_counter = mm_env.keep_alive_packet_counter + 1; + return; +} + + + +void mm_send_connection_loss_ind(vif_info_tag *p_vif_entry) + +{ + uint8_t *puVar1; + + puVar1 = (uint8_t *)ke_msg_alloc(0x43,6,0,1); + *puVar1 = p_vif_entry->index; + ke_msg_send(); + return; +} + + + +void mm_ap_probe_cfm(void *env,uint32_t status) + +{ + if ((int)(status << 8) < 0) { + *(undefined *)((int)env + 0x74) = 0; + return; + } + mm_send_connection_loss_ind((vif_info_tag *)env); + return; +} + + + +// WARNING: Variable defined which should be unmapped: cur_us +// WARNING: Could not reconcile some variable overlaps + +void mm_check_rssi(vif_info_tag *vif_entry,int8_t rssi) + +{ + byte bVar1; + uint8_t uVar2; + int iVar3; + uint8_t *puVar4; + undefined3 in_register_0000202d; + int iVar5; + uint uVar6; + bool bVar7; + int iVar8; + uint uStack40; + longlong cur_us; + + iVar5 = CONCAT31(in_register_0000202d,rssi); + iVar8 = (int)(char)vif_entry->u[0x19]; + iVar3 = (int)(char)vif_entry->u[0x1a]; + bVar1 = vif_entry->u[0x1b]; + bVar7 = (bool)vif_entry->u[0x1c]; + vif_entry->u[0x19] = rssi; + uStack40 = 0; + cur_us._0_4_ = 0; + bl60x_current_time_us((longlong *)&uStack40); + if (iVar8 != 0) { + uVar6 = (uint)(uStack40 < uStack40 - (uint)last_us); + if (((int)(((int)cur_us - last_us._4_4_) - uVar6) < 1) && + (((int)cur_us - last_us._4_4_ != uVar6 || (uStack40 - (uint)last_us < 0x1e8481)))) + goto LAB_2300889c; + } + puVar4 = (uint8_t *)ke_msg_alloc(0x57,0xd,0,3); + uVar2 = vif_entry->index; + *(bool *)(puVar4 + 1) = bVar7; + puVar4[2] = rssi; + *puVar4 = uVar2; + last_us._0_4_ = uStack40; + last_us._4_4_ = (int)cur_us; + ke_msg_send(); +LAB_2300889c: + if (iVar3 != 0) { + if (bVar7 == false) { + if (iVar5 < iVar8) { + bVar7 = iVar5 < iVar3 - (char)bVar1; + } + } + else { + if (iVar8 < iVar5) { + bVar7 = iVar5 <= iVar3 + (char)bVar1; + } + } + if ((bool)vif_entry->u[0x1c] != bVar7) { + puVar4 = (uint8_t *)ke_msg_alloc(0x57,0xd,0,3); + uVar2 = vif_entry->index; + *(bool *)(puVar4 + 1) = bVar7; + puVar4[2] = rssi; + *puVar4 = uVar2; + ke_msg_send(); + } + *(bool *)(vif_entry->u + 0x1c) = bVar7; + } + return; +} + + + +void mm_send_csa_traffic_ind(uint8_t vif_index,_Bool enable) + +{ + uint8_t *puVar1; + + puVar1 = (uint8_t *)ke_msg_alloc(0x59,0xd,0,2); + *puVar1 = vif_index; + *(_Bool *)(puVar1 + 1) = enable; + ke_msg_send(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint mm_check_beacon(rx_hd *param_1,vif_info_tag *param_2,int param_3,char **param_4) + +{ + ushort len; + ushort uVar1; + ushort uVar2; + uint uVar3; + int iVar4; + uint8_t uVar5; + undefined3 extraout_var; + uint32_t crc; + uint32_t uVar6; + uint32_t uVar7; + uint uVar8; + uint uVar9; + char *pcVar10; + uint uVar11; + int iVar12; + int iVar13; + uint len_00; + int iVar14; + uint uVar15; + + len = param_1->frmlen; + iVar13 = *(int *)(param_1->first_pbd_ptr + 8); + param_2->u[0x18] = 0; + beacon_rx_count = beacon_rx_count + 1; + iVar14 = *(int *)(param_2->u + 0x14); + if (param_2->u[0x1e] != 0) { + mm_send_csa_traffic_ind(param_2->index,true); + param_2->u[0x1e] = 0; + } + if ((((30000000 - _DAT_44b00120) + *(int *)(param_2->u + 0x10) < 0) && + (mm_env.keep_alive_status_enabled != false)) && + (uVar5 = txl_frame_send_null_frame(param_2->u[4],(cfm_func_ptr *)0x0,(void *)0x0), + CONCAT31(extraout_var,uVar5) == 0)) { + *(int *)(param_2->u + 0x10) = _DAT_44b00120; + } + uVar3 = (uint)len - 0x24; + mm_check_rssi(param_2,*(int8_t *)((int)¶m_1->recvec1c + 3)); + crc = co_crc32(iVar13 + 0x20,4,0); + pcVar10 = (char *)(iVar13 + 0x24); + *param_4 = (char *)0x0; + while (uVar3 = uVar3 & 0xffff, 1 < uVar3) { + len_00 = (uint)(byte)pcVar10[1]; + if (uVar3 <= len_00 + 1) break; + if (*pcVar10 == '\x05') { + *param_4 = pcVar10; + } + else { + crc = co_crc32((uint32_t)(pcVar10 + 2),len_00,crc); + } + uVar3 = uVar3 + (-2 - len_00); + pcVar10 = pcVar10 + 2 + len_00; + } + *(uint32_t *)(param_2->u + 0x14) = crc; + uVar1 = *(ushort *)(param_3 + 0x16); + uVar2 = *(ushort *)(iVar13 + 0x20); + uVar3 = *(uint *)(iVar13 + 0x18); + crc = param_1->tsflo; + iVar4 = (uint)uVar2 * 0x400; + iVar13 = *(int *)(iVar13 + 0x1c); + len_00 = (uint)*(ushort *)param_2->u; + if (*(ushort *)param_2->u == 0) { + pcVar10 = *param_4; + len_00 = 1; + if ((pcVar10 != (char *)0x0) && (len_00 = (uint)(byte)pcVar10[2], pcVar10[2] == 0)) { + len_00 = (uint)(byte)pcVar10[3]; + } + } + uVar6 = hal_machw_rx_duration(param_1,len); + uVar7 = hal_machw_rx_duration(param_1,0x18); + uVar8 = uVar3; + iVar12 = iVar13; + __udivdi3(); + uVar11 = uVar3 - uVar7; + uVar15 = iVar13 - (uint)(uVar3 < uVar11); + uVar9 = iVar12 * iVar4 + (int)((ulonglong)uVar8 * (ulonglong)uVar2 * 0x400 >> 0x20); + if ((uVar9 < uVar15) || ((uVar15 == uVar9 && (uVar8 * iVar4 < uVar11)))) { + uVar11 = uVar8 * iVar4; + } + iVar12 = ((uVar11 + len_00 * iVar4) - ((uVar3 - crc) + (uVar6 - uVar7))) - uVar1 * len_00; + iVar13 = iVar12 + -400; + if (iVar12 + (-0xc80 - _DAT_44b00120) < 0) { + iVar13 = iVar13 + iVar4; + } + crc = (_DAT_44b00120 - _DAT_44b080a4) + iVar13; + if (crc != (param_2->tbtt_timer).time) { + mm_timer_set(¶m_2->tbtt_timer,crc); + } + return (uint)(*(int *)(param_2->u + 0x14) != iVar14); +} + + + +void mm_sta_tbtt(void *env) + +{ + uint32_t value; + _Bool _Var1; + undefined3 extraout_var; + byte bVar2; + + if (*(char *)((int)env + 0x58) == '\0') { + return; + } + if (*(char *)((int)env + 0x79) != '\0') { + bVar2 = *(char *)((int)env + 0x79) - 1; + *(byte *)((int)env + 0x79) = bVar2; + if (bVar2 < 2) { + vif_mgmt_switch_channel((vif_info_tag *)env); + return; + } + if (bVar2 == 2) { + mm_send_csa_traffic_ind(*(uint8_t *)((int)env + 0x57),false); + } + } + value = sta_info_tab[*(byte *)((int)env + 0x60)].bcn_int + *(int *)((int)env + 0x24); + mm_timer_set((mm_timer_tag *)((int)env + 0x18),value); + vif_mgmt_bcn_to_prog((vif_info_tag *)env); + chan_tbtt_switch_update((vif_info_tag *)env,value); + _Var1 = chan_is_on_channel((vif_info_tag *)env); + if (CONCAT31(extraout_var,_Var1) != 0) { + *(uint *)((int)env + 4) = *(uint *)((int)env + 4) | 1; + bVar2 = *(char *)((int)env + 0x74) + 1; + *(byte *)((int)env + 0x74) = bVar2; + if (100 < bVar2) { + txl_frame_send_null_frame(*(uint8_t *)((int)env + 0x60),mm_ap_probe_cfm,env); + return; + } + if (bVar2 == 100) { + chan_bcn_detect_start((vif_info_tag *)env); + return; + } + } + return; +} + + + +uint16_t mm_get_rsn_wpa_ie(uint8_t sta_id,uint8_t *wpa_ie) + +{ + undefined3 in_register_00002029; + uint uVar1; + + uVar1 = (uint)sta_info_tab[CONCAT31(in_register_00002029,sta_id)].inst_nbr; + memcpy(wpa_ie,vif_info_tab[uVar1].bss_info.rsn_wpa_ie, + (uint)vif_info_tab[uVar1].bss_info.rsn_wpa_ie_len); + return (uint16_t)(ushort)vif_info_tab[uVar1].bss_info.rsn_wpa_ie_len; +} + + + +void mm_tim_update_proceed(ushort *param_1) + +{ + byte bVar1; + ushort uVar2; + uint uVar3; + uint8_t *puVar4; + uint uVar5; + int iVar6; + uint uVar7; + int iVar8; + uint uVar9; + uint uVar10; + uint uVar11; + byte *pbVar12; + + uVar2 = *param_1; + uVar9 = (uint)*(byte *)((int)param_1 + 3); + if (uVar2 == 0) { + if (*(char *)(param_1 + 1) == '\0') { + vif_info_tab[uVar9].u[0x2ea] = 0; + } + else { + vif_info_tab[uVar9].u[0x2ea] = 1; + } + } + else { + iVar8 = uVar9 * 8; + uVar10 = (uint)(uVar2 >> 3); + uVar11 = uVar10 & 0xff; + puVar4 = txl_tim_bitmap_pool + uVar9 * 0xfc; + pbVar12 = puVar4 + uVar11; + bVar1 = *pbVar12; + uVar7 = 1 << ((uint)uVar2 & 7); + uVar5 = uVar7 & 0xff; + uVar3 = uVar5 & bVar1; + if (*(char *)(param_1 + 1) == '\0') { + if (uVar3 != 0) { + *pbVar12 = ~(byte)uVar7 & bVar1; + uVar3 = (uint)*(ushort *)(vif_info_tab[uVar9].u + 0x2e0) - 1; + *(short *)(vif_info_tab[uVar9].u + 0x2e0) = (short)(uVar3 * 0x10000 >> 0x10); + if ((uVar3 & 0xffff) == 0) { + *(undefined2 *)(vif_info_tab[uVar9].u + 0x2de) = 6; + *(undefined2 *)(vif_info_tab[uVar9].u + 0x2e8) = 0xff; + bVar1 = vif_info_tab[uVar9].u[0x2de]; + txl_tim_ie_pool[iVar8 + 4] = '\0'; + txl_tim_ie_pool[iVar8 + 1] = bVar1 - 2; + txl_tim_desc[uVar9 * 2].dataendptr = iVar8 + 0x42045365; + *(tx_pbd **)&txl_tim_desc[uVar9 * 2].next = txl_bcn_end_desc + *(byte *)((int)param_1 + 3) + ; + *(uint8_t **)&txl_tim_desc[uVar9 * 2 + 1].dataendptr = + puVar4 + vif_info_tab[uVar9].u[0x2e9]; + } + else { + if ((uint)vif_info_tab[uVar9].u[0x2e8] == (uVar10 & 0xfe)) { + while( true ) { + bVar1 = vif_info_tab[uVar9].u[0x2e8]; + if ((bVar1 == 0xfb) || (puVar4[(uint)bVar1] != '\0')) break; + vif_info_tab[uVar9].u[0x2e8] = bVar1 + 1; + } + uVar3 = (uint)bVar1 & 0xfe; + vif_info_tab[uVar9].u[0x2e8] = (byte)uVar3; + *(uint8_t **)&txl_tim_desc[uVar9 * 2 + 1].datastartptr = puVar4 + uVar3; + } + if ((uint)vif_info_tab[uVar9].u[0x2e9] == uVar11) { + while( true ) { + bVar1 = vif_info_tab[uVar9].u[0x2e9]; + if ((bVar1 == 0) || (puVar4[bVar1] != '\0')) break; + vif_info_tab[uVar9].u[0x2e9] = bVar1 - 1; + } + *(uint8_t **)&txl_tim_desc[uVar9 * 2 + 1].dataendptr = puVar4 + bVar1; + } + iVar6 = (((uint)vif_info_tab[uVar9].u[0x2e9] + 6) - (uint)vif_info_tab[uVar9].u[0x2e8]) * + 0x10000; + *(short *)(vif_info_tab[uVar9].u + 0x2de) = (short)((uint)iVar6 >> 0x10); + txl_tim_ie_pool[iVar8 + 1] = (char)((uint)iVar6 >> 0x10) + -2; + txl_tim_ie_pool[iVar8 + 4] = vif_info_tab[uVar9].u[0x2e8]; + } + } + } + else { + if (uVar3 == 0) { + *pbVar12 = (byte)uVar5 | bVar1; + bVar1 = vif_info_tab[uVar9].u[0x2e8]; + *(short *)(vif_info_tab[uVar9].u + 0x2e0) = *(short *)(vif_info_tab[uVar9].u + 0x2e0) + 1; + if (uVar11 < bVar1) { + vif_info_tab[uVar9].u[0x2e8] = (byte)(uVar10 & 0xfe); + *(uint8_t **)&txl_tim_desc[uVar9 * 2 + 1].datastartptr = puVar4 + (uVar10 & 0xfe); + } + if (vif_info_tab[uVar9].u[0x2e9] < uVar11) { + vif_info_tab[uVar9].u[0x2e9] = (byte)uVar11; + *(byte **)&txl_tim_desc[uVar9 * 2 + 1].dataendptr = pbVar12; + } + iVar6 = (((uint)vif_info_tab[uVar9].u[0x2e9] + 6) - (uint)vif_info_tab[uVar9].u[0x2e8]) * + 0x10000; + *(short *)(vif_info_tab[uVar9].u + 0x2de) = (short)((uint)iVar6 >> 0x10); + txl_tim_ie_pool[iVar8 + 1] = (char)((uint)iVar6 >> 0x10) + -2; + txl_tim_ie_pool[iVar8 + 4] = vif_info_tab[uVar9].u[0x2e8]; + txl_tim_desc[uVar9 * 2].dataendptr = iVar8 + 0x42045364; + txl_tim_desc[uVar9 * 2].next = uVar9 * 0x28 + 0x42045aa4; + } + } + } + ke_msg_send_basic(0x42,param_1[-2],0); + ke_msg_free(param_1 + -6); + return; +} + + + +void mm_bcn_init(void) + +{ + memset(&mm_bcn_env,0,0x24); + mm_bcn_env.dma.dma_desc = &bcn_dwnld_desc; + mm_bcn_env.dma.cb = mm_bcn_updated; + co_list_init(&mm_bcn_env.tim_list); + return; +} + + + +void mm_bcn_init_vif(vif_info_tag *vif_entry) + +{ + byte bVar1; + tx_pbd *ptVar2; + uint uVar3; + int iVar4; + + uVar3 = (uint)vif_entry->index; + txl_frame_init_desc((txl_frame_desc_tag *)(vif_entry->u + 4), + (txl_buffer_tag *)(txl_bcn_pool + uVar3 * 0xd3),txl_bcn_hwdesc_pool + uVar3, + txl_bcn_buf_ctrl + uVar3); + txl_bcn_hwdesc_pool[uVar3].cfm_ptr = txl_bcn_hwdesc_cfms + vif_entry->index; + uVar3 = (uint)vif_entry->index; + iVar4 = uVar3 * 8; + vif_entry->u[0x2e7] = 0; + *(undefined2 *)(vif_entry->u + 0x2e0) = 0; + vif_entry->u[0x2ea] = 0; + *(undefined2 *)(vif_entry->u + 0x2de) = 6; + *(undefined2 *)(vif_entry->u + 0x2e8) = 0xff; + txl_tim_desc[uVar3 * 2].dataendptr = iVar4 + 0x42045365; + txl_tim_desc[uVar3 * 2].upatterntx = 0xcafefade; + *(uint8_t **)&txl_tim_desc[uVar3 * 2].datastartptr = txl_tim_ie_pool + iVar4; + txl_tim_desc[uVar3 * 2].bufctrlinfo = 0; + ptVar2 = txl_bcn_end_desc + uVar3; + *(tx_pbd **)&txl_tim_desc[uVar3 * 2].next = ptVar2; + txl_tim_ie_pool[iVar4] = '\x05'; + txl_tim_ie_pool[iVar4 + 1] = '\x04'; + bVar1 = vif_entry->u[0x2e7]; + txl_tim_ie_pool[iVar4 + 4] = '\0'; + txl_tim_ie_pool[iVar4 + 2] = bVar1; + txl_tim_ie_pool[iVar4 + 3] = '\x01'; + txl_tim_ie_pool[iVar4 + 5] = -1; + txl_tim_desc[uVar3 * 2 + 1].upatterntx = 0xcafefade; + bVar1 = vif_entry->u[0x2e9]; + *(tx_pbd **)&txl_tim_desc[uVar3 * 2 + 1].next = ptVar2; + *(uint8_t **)&txl_tim_desc[uVar3 * 2 + 1].dataendptr = txl_tim_bitmap_pool + uVar3 * 0xfc + bVar1; + memset(txl_tim_bitmap_pool + uVar3 * 0xfc,0,0xfc); + ptVar2->upatterntx = 0xcafefade; + txl_bcn_end_desc[uVar3].next = 0; + txl_bcn_end_desc[uVar3].bufctrlinfo = 0; + iVar4 = *(int *)(vif_entry->u + 0x70); + *(undefined4 *)(iVar4 + 0x24) = 0; + *(undefined4 *)(iVar4 + 0x3c) = 0; + *(undefined4 *)(iVar4 + 0x10) = 0; + *(undefined4 *)(vif_entry->u + 0x2d0) = 0x230094f6; + *(vif_info_tag **)(vif_entry->u + 0x2d4) = vif_entry; + return; +} + + + +void mm_tim_update(mm_tim_update_req *param) + +{ + if (mm_bcn_env.tx_cfm != 0) { + co_list_push_back(&mm_bcn_env.tim_list,(co_list_hdr *)(param + -3)); + return; + } + mm_tim_update_proceed(); + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void mm_bcn_transmit(void) + +{ + byte bVar1; + uint8_t uVar2; + uint8_t uVar3; + vif_info_tag *vif; + txl_frame_desc_tag *frame; + _Bool _Var4; + undefined3 extraout_var; + char *pcVar5; + undefined3 extraout_var_00; + uint8_t *puVar6; + int iVar7; + byte bVar8; + uint uVar9; + char cVar10; + int iVar11; + + vif = (vif_info_tag *)vif_mgmt_env.used_list.first; + if (mm_bcn_env.tx_cfm != 0) { + assert_err("!mm_bcn_env.tx_cfm","module",0x339); + } + if (mm_bcn_env.update_ongoing == false) { + mm_bcn_env.tx_pending = false; + while (vif != (vif_info_tag *)0x0) { + if (((vif->type == '\x02') && (*(char *)((int)vif->u + 0x2e6) != '\0')) && + (*(char *)((int)vif->u + 0x2e5) == *(char *)((int)vif->u + 0x2e4))) { + iVar7 = *(int *)((int)vif->u + 0x70); + iVar11 = (uint)vif->index * 8; + bVar1 = txl_tim_ie_pool[iVar11 + 4]; + *(int *)(iVar7 + 0x1c) = + (uint)*(ushort *)((int)vif->u + 0x2dc) + (uint)*(ushort *)((int)vif->u + 0x2de) + 4; + uVar9 = (uint)txl_cntrl_env.seqnbr; + frame = (txl_frame_desc_tag *)((int)vif->u + 4); + txl_cntrl_env.seqnbr = (uint16_t)((uVar9 + 1) * 0x10000 >> 0x10); + *(undefined2 *)(*(int *)(iVar7 + 0x14) + 0x16) = (short)((uVar9 + 1 & 0xffff) << 4); + uVar2 = *(uint8_t *)((int)vif->u + 0x2e7); + txl_tim_ie_pool[iVar11 + 2] = uVar2; + if (uVar2 == '\0') { + if ((*(char *)((int)vif->u + 0x2ea) != '\0') || + (bVar8 = bVar1 & 0xfe, ipc_emb_env.txdesc[ipc_emb_env.txdesc_idx & 3].ready != 0)) { + bVar8 = bVar1 | 1; + } + *(uint8_t *)((int)vif->u + 0x2e7) = txl_tim_ie_pool[iVar11 + 3]; + } + else { + bVar8 = bVar1 & 0xfe; + if ((*(byte *)((int)vif->u + 0x2ea) & 2) != 0) { + bVar8 = bVar1 | 1; + } + } + txl_tim_ie_pool[iVar11 + 4] = bVar8 | 1; + *(char *)((int)vif->u + 0x2e7) = *(char *)((int)vif->u + 0x2e7) + -1; + cVar10 = *(char *)((int)vif->u + 0x2eb); + if (cVar10 != '\0') { + bVar1 = *(byte *)((int)vif->u + 0x2ec); + cVar10 = cVar10 + -1; + *(char *)((int)vif->u + 0x2eb) = cVar10; + if (bVar1 != 0) { + *(char *)(*(int *)(iVar7 + 0x14) + (uint)bVar1) = cVar10; + bVar1 = *(byte *)((int)vif->u + 0x2ed); + if (bVar1 != 0) { + *(undefined *)(*(int *)(iVar7 + 0x14) + (uint)bVar1) = + *(undefined *)((int)vif->u + 0x2eb); + } + } + uVar2 = *(uint8_t *)((int)vif->u + 0x2eb); + if (uVar2 != '\0') { + uVar3 = vif->index; + puVar6 = (uint8_t *)ke_msg_alloc(0x4e,0xd,0,2); + *puVar6 = uVar3; + puVar6[1] = uVar2; + ke_msg_send(); + if (*(char *)((int)vif->u + 0x2eb) != '\0') goto LAB_2300926e; + } + *(undefined *)((int)vif->u + 0x2eb) = 1; + } +LAB_2300926e: + tpc_update_frame_tx_power(vif,frame); + _Var4 = chan_is_on_operational_channel(vif); + if (CONCAT31(extraout_var,_Var4) != 0) { + uVar2 = vif->index; + pcVar5 = (char *)ke_msg_alloc(0x4a,0xd,0,3); + *pcVar5 = uVar2 + '\n'; + pcVar5[1] = '\0'; + pcVar5[2] = '\0'; + ke_msg_send(); + *(uint8_t *)((int)vif->u + 0x33) = vif->index; + *(undefined *)((int)vif->u + 0x34) = 0xff; + _Var4 = txl_frame_push(frame,'\x04'); + if (CONCAT31(extraout_var_00,_Var4) != 0) { + mm_bcn_env.tx_cfm = mm_bcn_env.tx_cfm + 1; + } + iVar7 = (uint)vif->index + 10; + if ((sta_info_tab[iVar7].traffic_avail & PS_TRAFFIC_INT) != 0) { + sta_info_tab[iVar7].ps_service_period = 9; + sta_mgmt_send_postponed_frame(vif,sta_info_tab + iVar7,0); + sta_info_tab[iVar7].ps_service_period = 0; + } + } + } + vif = *(vif_info_tag **)&vif->list_hdr; + } + } + else { + mm_bcn_env.tx_pending = true; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_bcn_updated(void *env,int dma_queue) + +{ + ushort uVar1; + ushort uVar2; + mm_bcn_change_req *pmVar3; + int iVar4; + uint32_t uVar5; + int iVar6; + txl_buffer_control *ptVar7; + mm_bcn_change_req *mem_ptr; + int iVar8; + uint uVar9; + int iVar10; + + mem_ptr = mm_bcn_env.param + -1; + ke_msg_send_basic(0x40,*(ke_task_id_t *)&mm_bcn_env.param[-1].tim_len,0); + pmVar3 = mm_bcn_env.param; + uVar9 = (uint)*(byte *)((int)env + 0x57); + iVar4 = *(int *)((int)env + 0xcc); + uVar1 = (mm_bcn_env.param)->tim_oft; + iVar10 = (uint)(mm_bcn_env.param)->bcn_len - (uint)(mm_bcn_env.param)->tim_len; + iVar8 = *(int *)(iVar4 + 0x14); + *(undefined2 *)((int)env + 0x338) = (short)iVar10; + me_beacon_check(*(byte *)((int)env + 0x57),pmVar3->bcn_len,*(uint32_t *)(iVar4 + 0x14)); + iVar6 = *(int *)(iVar4 + 0x14) + ((uint)pmVar3->tim_oft - 1); + *(int *)(iVar4 + 0x18) = iVar6; + uVar5 = (uint)pmVar3->tim_len + 1 + iVar6; + txl_bcn_end_desc[uVar9].datastartptr = uVar5; + uVar2 = pmVar3->tim_oft; + txl_bcn_end_desc[uVar9].bufctrlinfo = 0; + txl_bcn_end_desc[uVar9].dataendptr = ~(uint)uVar2 + iVar10 + uVar5; + if (*(char *)(*(int *)((int)env + 0x40) + 4) == '\0') { + ptVar7 = &txl_buffer_control_24G; + } + else { + ptVar7 = &txl_buffer_control_5G; + } + *(uint *)(ptVar7->field_0 + 0x24) = _DAT_44b000a0 & 0xff; + *(txl_buffer_control **)(iVar4 + 0x28) = ptVar7; + *(undefined4 *)(iVar4 + 0x24) = 0; + *(undefined4 *)(iVar4 + 0x3c) = 0; + *(tx_pbd **)(iVar4 + 0x10) = txl_tim_desc + (uint)*(byte *)((int)env + 0x57) * 2; + *(undefined *)((int)env + 0x342) = 1; + txl_tim_ie_pool[uVar9 * 8 + 3] = *(uint8_t *)(iVar8 + (uint)uVar1 + 3); + pmVar3 = mm_bcn_env.param; + *(undefined *)((int)env + 0x347) = 0; + *(uint8_t *)((int)env + 0x348) = pmVar3->csa_oft[0]; + *(uint8_t *)((int)env + 0x349) = pmVar3->csa_oft[1]; + if (pmVar3->csa_oft[0] != 0) { + *(char *)((int)env + 0x347) = + *(char *)(*(int *)(*(int *)((int)env + 0xcc) + 0x14) + (uint)pmVar3->csa_oft[0]) + '\x01'; + } + mm_bcn_env.update_ongoing = false; + if (mm_bcn_env.tx_pending != false) { + mm_bcn_transmit(); + } + mm_bcn_env.param = (mm_bcn_change_req *)0x0; + ke_msg_free(mem_ptr); + return; +} + + + +void mm_bcn_update(mm_bcn_change_req *param) + +{ + byte bVar1; + + bVar1 = param->inst_nbr; + memcpy(txl_bcn_pool + (uint)bVar1 * 0xd3 + 0x53,param + 1,(uint)param->bcn_len); + mm_bcn_env.update_pending = false; + mm_bcn_env.update_ongoing = true; + mm_bcn_updated(vif_info_tab + (uint)bVar1,0); + return; +} + + + +void mm_bcn_transmitted(vif_info_tag *param_1) + +{ + co_list_hdr *pcVar1; + + if (mm_bcn_env.tx_cfm == 0) { + assert_err("mm_bcn_env.tx_cfm","module",0x244); + } + mm_bcn_env.tx_cfm = mm_bcn_env.tx_cfm + -1; + if (mm_bcn_env.tx_cfm == 0) { + if (mm_bcn_env.update_pending != false) { + mm_bcn_update(mm_bcn_env.param); + } + while (mm_bcn_env.tim_list.first != (co_list_hdr *)0x0) { + pcVar1 = co_list_pop_front(&mm_bcn_env.tim_list); + mm_tim_update_proceed(pcVar1 + 3); + } + if (param_1->u[0x2eb] == 1) { + vif_mgmt_switch_channel(param_1); + return; + } + } + return; +} + + + +void mm_bcn_change(mm_bcn_change_req *param) + +{ + if (mm_bcn_env.tx_cfm != 0) { + mm_bcn_env.param = param; + mm_bcn_env.update_pending = true; + return; + } + mm_bcn_env.param = param; + mm_bcn_update(param); + return; +} + + +/* +Unable to decompile 'mm_timer_hw_set' +Cause: Exception while decompiling 23009596: Decompiler process died + +*/ + + +_Bool cmp_abs_time(co_list_hdr *timerA,co_list_hdr *timerB) + +{ + return SUB41((uint)((int)timerA[3].next - (int)timerB[3].next) >> 0x1f,0); +} + + + +void mm_timer_init(void) + +{ + co_list_init((co_list *)&mm_timer_env); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_timer_set(mm_timer_tag *timer,uint32_t value) + +{ + bool bVar1; + + if ((int)(value - _DAT_44b00120) < 0) { + puts("\r\n-------------------[FW] Timer is past due to flash operation. Try to fix\r\n"); + value = _DAT_44b00120 + 3000; + } + bVar1 = timer != (mm_timer_tag *)mm_timer_env.prog.first; + if (bVar1) { + co_list_extract((co_list *)&mm_timer_env,(co_list_hdr *)timer); + } + else { + co_list_pop_front((co_list *)&mm_timer_env); + } + timer->time = value; + co_list_insert((co_list *)&mm_timer_env,(co_list_hdr *)timer,cmp_abs_time); + if ((!bVar1) || (timer == (mm_timer_tag *)mm_timer_env.prog.first)) { + mm_timer_hw_set(mm_timer_env.prog.first); + } + if ((int)(value - _DAT_44b00120) < 0) { + ke_evt_set(0x8000000); + return; + } + return; +} + + + +void mm_timer_clear(mm_timer_tag *timer) + +{ + if (timer == (mm_timer_tag *)mm_timer_env.prog.first) { + co_list_pop_front((co_list *)&mm_timer_env); + mm_timer_hw_set(mm_timer_env.prog.first); + return; + } + co_list_extract((co_list *)&mm_timer_env,(co_list_hdr *)timer); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_timer_schedule(int dummy) + +{ + co_list_hdr *pcVar1; + + while( true ) { + ke_evt_clear(0x8000000); + pcVar1 = mm_timer_env.prog.first; + if (mm_timer_env.prog.first == (co_list_hdr *)0x0) { + mm_timer_hw_set(0); + return; + } + if ((-1 < (int)mm_timer_env.prog.first[3].next + (-0x32 - _DAT_44b00120)) && + (mm_timer_hw_set(mm_timer_env.prog.first), -1 < (int)((int)pcVar1[3].next - _DAT_44b00120))) + break; + co_list_pop_front((co_list *)&mm_timer_env); + if (pcVar1[1].next == (co_list_hdr *)0x0) { + assert_err("timer->cb","module",0xde); + } + (*(code *)pcVar1[1].next)(pcVar1[2].next,pcVar1[1].next); + } + return; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ps_uapsd_timer_handle(void *env) + +{ + vif_info_tag *p_vif_entry; + _Bool _Var1; + undefined3 extraout_var; + int iVar2; + + iVar2 = 0; + p_vif_entry = (vif_info_tag *)vif_mgmt_env.used_list.first; + while (p_vif_entry != (vif_info_tag *)0x0) { + if (((p_vif_entry->type == '\0') && (p_vif_entry->active != false)) && + (*(char *)((int)p_vif_entry->u + 0xc) != '\0')) { + _Var1 = chan_is_on_channel(p_vif_entry); + __Var1 = CONCAT31(extraout_var,_Var1); + if ((__Var1 != 0) && + (iVar2 = __Var1, + (int)(((ps_env.uapsd_timeout >> 1) - _DAT_44b00120) + *(int *)((int)p_vif_entry->u + 8)) < + 0)) { + p_vif_entry->prevent_sleep = p_vif_entry->prevent_sleep | 8; + txl_frame_send_qosnull_frame + (*(uint8_t *)((int)p_vif_entry->u + 4),7,(cfm_func_ptr *)0x0,(void *)0x0); + *(int *)((int)p_vif_entry->u + 8) = _DAT_44b00120; + } + } + p_vif_entry = *(vif_info_tag **)&p_vif_entry->list_hdr; + } + if (iVar2 != 0) { + mm_timer_set(&ps_env.uapsd_timer,_DAT_44b00120 + ps_env.uapsd_timeout); + return; + } + ps_env.uapsd_tmr_on = false; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_pwr_mgt_setf(uint8_t pwrmgt) + +{ + undefined3 in_register_00002029; + + _DAT_44b0004c = CONCAT31(in_register_00002029,pwrmgt) << 2 | _DAT_44b0004c & 0xfffffffb; + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void ps_dpsm_update(_Bool pause) + +{ + vif_info_tag *p_vif_entry; + _Bool _Var1; + undefined3 in_register_00002029; + undefined3 extraout_var; + code *UNRECOVERED_JUMPTABLE; + + if (CONCAT31(in_register_00002029,pause) == 0) { + ps_env.dpsm_state = ps_env.dpsm_state | 4; + ps_env.prevent_sleep = ps_env.prevent_sleep & 0xfffffff7; + UNRECOVERED_JUMPTABLE = ps_enable_cfm; + } + else { + ps_env.dpsm_state = ps_env.dpsm_state | 2; + ps_env.prevent_sleep = ps_env.prevent_sleep | 8; + UNRECOVERED_JUMPTABLE = ps_disable_cfm; + } + blmac_pwr_mgt_setf(pause ^ 1); + ps_env.cfm_cnt = '\0'; + p_vif_entry = (vif_info_tag *)vif_mgmt_env.used_list.first; + while (p_vif_entry != (vif_info_tag *)0x0) { + if (((p_vif_entry->type == '\0') && (p_vif_entry->active != false)) && + (_Var1 = chan_is_on_channel(p_vif_entry), CONCAT31(extraout_var,_Var1) != 0)) { + *(undefined *)((int)p_vif_entry->u + 3) = 0; + ps_env.cfm_cnt = ps_env.cfm_cnt + '\x01'; + txl_frame_send_null_frame + (*(uint8_t *)((int)p_vif_entry->u + 4),UNRECOVERED_JUMPTABLE,p_vif_entry); + } + p_vif_entry = *(vif_info_tag **)&p_vif_entry->list_hdr; + } + if (ps_env.cfm_cnt == '\0') { + // WARNING: Could not recover jumptable at 0x230098a0. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)((void *)0x0,0x800000); + return; + } + return; +} + + + +uint8_t ps_send_pspoll(vif_info_tag *vif_entry) + +{ + ushort uVar1; + txl_frame_desc_tag *frame; + tx_hw_desc *ptVar2; + txl_buffer_tag *ptVar3; + uint uVar4; + char acStack40 [4]; + phy_channel_info phy_info; + + uVar4 = (uint)vif_entry->u[4]; + phy_get_channel((phy_channel_info *)acStack40,'\0'); + frame = txl_frame_get((uint)(acStack40[0] != '\0'),0x10); + if (frame != (txl_frame_desc_tag *)0x0) { + tpc_update_frame_tx_power(vif_entry,frame); + ptVar3 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar3[1].length = 0xa4; + *(undefined *)((int)&ptVar3[1].length + 1) = 0; + uVar1 = sta_info_tab[uVar4].aid; + *(undefined *)((int)&ptVar3[1].length + 2) = (char)uVar1; + *(byte *)((int)&ptVar3[1].length + 3) = (byte)((uint)uVar1 >> 8) | 0xc0; + memcpy(&ptVar3[1].lenheader,&sta_info_tab[uVar4].mac_addr,6); + memcpy((void *)((int)&ptVar3[1].lenpad + 2),&vif_entry->mac_addr,6); + ptVar2 = (frame->txdesc).lmac.hw_desc; + (ptVar2->thd).macctrlinfo2 = (ptVar2->thd).macctrlinfo2 | 0x10000053; + (frame->txdesc).host.vif_idx = sta_info_tab[uVar4].inst_nbr; + (frame->txdesc).host.staid = sta_info_tab[uVar4].staid; + txl_frame_push(frame,'\x03'); + } + return (uint8_t)(frame == (txl_frame_desc_tag *)0x0); +} + + + +void ps_init(void) + +{ + memset(&ps_env,0,0x28); + ps_env.uapsd_timer.cb = ps_uapsd_timer_handle; + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void ps_set_mode(uint8_t mode,ke_task_id_t taskid) + +{ + vif_info_tag *p_vif_entry; + _Bool _Var1; + undefined3 in_register_00002029; + undefined3 extraout_var; + code *UNRECOVERED_JUMPTABLE; + + ps_env.taskid = taskid; + if (((ps_env.dpsm_state & 1) == 0) || ((ps_env.dpsm_state & 6) == 0)) { + if (CONCAT31(in_register_00002029,mode) == 0) { + ps_env.dpsm_state = '\0'; + UNRECOVERED_JUMPTABLE = ps_disable_cfm; + blmac_pwr_mgt_setf(mode); + } + else { + if (CONCAT31(in_register_00002029,mode) == 2) { + ps_env.dpsm_state = ps_env.dpsm_state | 1; + } + blmac_pwr_mgt_setf('\x01'); + UNRECOVERED_JUMPTABLE = ps_enable_cfm; + } + ps_env.cfm_cnt = '\0'; + ps_env.uapsd_on = false; + p_vif_entry = (vif_info_tag *)vif_mgmt_env.used_list.first; + while (p_vif_entry != (vif_info_tag *)0x0) { + if (((p_vif_entry->type == '\0') && (p_vif_entry->active != false)) && + (_Var1 = chan_is_on_channel(p_vif_entry), CONCAT31(extraout_var,_Var1) != 0)) { + *(undefined *)((int)p_vif_entry->u + 3) = 0; + ps_env.cfm_cnt = ps_env.cfm_cnt + '\x01'; + if (*(char *)((int)p_vif_entry->u + 0xc) != '\0') { + ps_env.uapsd_on = true; + } + txl_frame_send_null_frame + (*(uint8_t *)((int)p_vif_entry->u + 4),UNRECOVERED_JUMPTABLE,p_vif_entry); + } + p_vif_entry = *(vif_info_tag **)&p_vif_entry->list_hdr; + } + if (ps_env.cfm_cnt == '\0') { + // WARNING: Could not recover jumptable at 0x23009a6e. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)((void *)0x0,0x800000); + return; + } + } + else { + ps_env.dpsm_state = ps_env.dpsm_state | 0x10; + ps_env.next_mode = mode; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ps_enable_cfm(void *env,uint32_t status) + +{ + co_list_hdr cVar1; + char cVar2; + + if (-1 < (int)(status << 8)) { + cVar2 = *(char *)((int)env + 0x5f) + '\x01'; + *(char *)((int)env + 0x5f) = cVar2; + if (cVar2 != '\x03') { + txl_frame_send_null_frame(*(uint8_t *)((int)env + 0x60),ps_enable_cfm,env); + return; + } + mm_send_connection_loss_ind((vif_info_tag *)env); + } + cVar1 = (co_list_hdr)vif_mgmt_env.used_list.first; + if ((ps_env.cfm_cnt == '\0') || (ps_env.cfm_cnt = ps_env.cfm_cnt + -1, ps_env.cfm_cnt == '\0')) { + if (ps_env.uapsd_on != false) { + mm_timer_set(&ps_env.uapsd_timer,_DAT_44b00120 + ps_env.uapsd_timeout); + ps_env.uapsd_tmr_on = true; + while (cVar1 != (co_list_hdr)0x0) { + if (((*(char *)((int)cVar1 + 0x56) == '\0') && + (*(char *)&((co_list_hdr *)((int)cVar1 + 0x58))->next != '\0')) && + (*(char *)&((co_list_hdr *)((int)cVar1 + 0x68))->next != '\0')) { + ((co_list_hdr *)((int)cVar1 + 4))->next = + (co_list_hdr *)((uint)((co_list_hdr *)((int)cVar1 + 4))->next & 0xfffffff7); + } + cVar1 = *(co_list_hdr *)cVar1; + } + } + if ((ps_env.dpsm_state & 5) == 5) { + ps_env.dpsm_state = ps_env.dpsm_state & 0xf3; + } + else { + ps_env.ps_on = true; + ke_msg_send_basic(0x32,ps_env.taskid,0); + } + if ((ps_env.dpsm_state & 0x10) != 0) { + ps_env.dpsm_state = ps_env.dpsm_state & 0xef; + ps_set_mode(ps_env.next_mode,ps_env.taskid); + return; + } + } + return; +} + + + +void ps_disable_cfm(void *env,uint32_t status) + +{ + char cVar1; + + if (-1 < (int)(status << 8)) { + cVar1 = *(char *)((int)env + 0x5f) + '\x01'; + *(char *)((int)env + 0x5f) = cVar1; + if (cVar1 != '\x03') { + txl_frame_send_null_frame(*(uint8_t *)((int)env + 0x60),ps_disable_cfm,env); + return; + } + mm_send_connection_loss_ind((vif_info_tag *)env); + } + if ((ps_env.cfm_cnt == '\0') || (ps_env.cfm_cnt = ps_env.cfm_cnt + -1, ps_env.cfm_cnt == '\0')) { + mm_timer_clear(&ps_env.uapsd_timer); + ps_env.uapsd_tmr_on = false; + if ((ps_env.dpsm_state & 3) == 3) { + ps_env.dpsm_state = ps_env.dpsm_state & 0xfd | 8; + } + else { + ps_env.ps_on = false; + ke_msg_send_basic(0x32,ps_env.taskid,0); + } + if ((ps_env.dpsm_state & 0x10) != 0) { + ps_env.dpsm_state = ps_env.dpsm_state & 0xef; + ps_set_mode(ps_env.next_mode,ps_env.taskid); + return; + } + } + return; +} + + + +uint8_t ps_polling_frame(vif_info_tag *vif_entry) + +{ + ushort uVar1; + txl_frame_desc_tag *frame; + tx_hw_desc *ptVar2; + txl_buffer_tag *ptVar3; + uint uVar4; + char acStack40 [16]; + + uVar4 = (uint)vif_entry->u[4]; + phy_get_channel((phy_channel_info *)acStack40,'\0'); + frame = txl_frame_get((uint)(acStack40[0] != '\0'),0x10); + if (frame != (txl_frame_desc_tag *)0x0) { + tpc_update_frame_tx_power(vif_entry,frame); + ptVar3 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar3[1].length = 0xa4; + *(undefined *)((int)&ptVar3[1].length + 1) = 0; + uVar1 = sta_info_tab[uVar4].aid; + *(undefined *)((int)&ptVar3[1].length + 2) = (char)uVar1; + *(byte *)((int)&ptVar3[1].length + 3) = (byte)((uint)uVar1 >> 8) | 0xc0; + memcpy(&ptVar3[1].lenheader,&sta_info_tab[uVar4].mac_addr,6); + memcpy((void *)((int)&ptVar3[1].lenpad + 2),&vif_entry->mac_addr,6); + ptVar2 = (frame->txdesc).lmac.hw_desc; + (ptVar2->thd).macctrlinfo2 = (ptVar2->thd).macctrlinfo2 | 0x10000053; + (frame->txdesc).host.vif_idx = sta_info_tab[uVar4].inst_nbr; + (frame->txdesc).host.staid = sta_info_tab[uVar4].staid; + txl_frame_push(frame,'\x03'); + } + return (uint8_t)(frame == (txl_frame_desc_tag *)0x0); +} + + + +void ps_check_beacon(int param_1,vif_info_tag *param_2) + +{ + ushort uVar1; + _Bool _Var2; + uint8_t uVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint uVar4; + uint uVar5; + uint32_t uVar6; + byte bVar7; + + _Var2 = ps_env.ps_on; + uVar1 = sta_info_tab[param_2->u[4]].aid; + uVar5 = param_2->prevent_sleep; + uVar4 = uVar5 & 0xfffffffe; + param_2->prevent_sleep = uVar4; + if (((_Var2 == false) || ((ps_env.dpsm_state & 8) != 0)) || (param_1 == 0)) { + return; + } + if (param_2->u[2] == 0) { + if ((*(byte *)(param_1 + 4) & 1) == 0) { + param_2->prevent_sleep = uVar5 & 0xfffffffc; + } + else { + param_2->prevent_sleep = uVar4 | 2; + } + } + uVar5 = (uint)(uVar1 >> 3); + uVar4 = (uint)*(byte *)(param_1 + 4) & 0xfe; + bVar7 = param_2->u[0xc] & 0xf; + if (((uVar4 <= uVar5) && (uVar5 <= ((uint)*(byte *)(param_1 + 1) - 4) + uVar4)) && + (((uint)*(byte *)(((uVar5 + param_1) - uVar4) + 5) & 1 << ((uint)uVar1 & 7)) != 0)) { + if (bVar7 == 0xf) { + uVar3 = txl_frame_send_qosnull_frame(param_2->u[4],7,(cfm_func_ptr *)0x0,(void *)0x0); + if (CONCAT31(extraout_var,uVar3) != 0) { + return; + } + uVar6 = param_2->prevent_sleep | 8; + } + else { + uVar3 = ps_send_pspoll(param_2); + if (CONCAT31(extraout_var_00,uVar3) != 0) { + return; + } + uVar6 = param_2->prevent_sleep | 4; + } + param_2->prevent_sleep = uVar6; + return; + } + if (bVar7 == 0xf) { + uVar6 = param_2->prevent_sleep & 0xfffffff7; + } + else { + uVar6 = param_2->prevent_sleep & 0xfffffffb; + } + param_2->prevent_sleep = uVar6; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ps_check_frame(uint8_t *frame,uint32_t statinfo,vif_info_tag *vif_entry) + +{ + byte bVar1; + uint uVar2; + uint8_t uVar3; + undefined3 extraout_var; + uint32_t uVar4; + _Bool _Var5; + + _Var5 = ps_env.uapsd_on; + if (ps_env.ps_on == false) { + return; + } + uVar2 = (uint)*(ushort *)frame; + if ((frame[4] & 1) != 0) { + if (((int)(uVar2 << 0x12) < 0) && (vif_entry->u[2] == 0)) { + return; + } + uVar4 = vif_entry->prevent_sleep & 0xfffffffd; +LAB_23009dae: + vif_entry->prevent_sleep = uVar4; + return; + } + if ((statinfo & 0x200) != 0) { + return; + } + if (ps_env.uapsd_on != false) { + if ((uVar2 & 0x88) == 0x88) { + if ((uVar2 & 0x300) == 0x300) { + bVar1 = frame[0x1e]; + } + else { + bVar1 = frame[0x18]; + } + if ((vif_entry->u[0xc] >> ((uint)"\x01"[(uint)bVar1 & 7] & 0x1f) & 1) != 0) { + *(undefined4 *)(vif_entry->u + 8) = _DAT_44b00120; + if ((bVar1 & 0x10) == 0) { + return; + } + uVar4 = vif_entry->prevent_sleep & 0xfffffff7; + goto LAB_23009dae; + } + } + else { + if (((*(ushort *)frame & 0xc) == 0) && ((vif_entry->u[0xc] & 8) != 0)) { + *(undefined4 *)(vif_entry->u + 8) = _DAT_44b00120; + goto LAB_23009e48; + } + } + _Var5 = false; + } +LAB_23009e48: + td_pck_ps_ind(vif_entry->index,true); + if ((_Var5 == false) && + ((-1 < (int)(uVar2 << 0x12) || + (((ps_env.dpsm_state & 8) == 0 && + (uVar3 = ps_send_pspoll(vif_entry), CONCAT31(extraout_var,uVar3) != 0)))))) { + vif_entry->prevent_sleep = vif_entry->prevent_sleep & 0xfffffffb; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ps_check_tx_frame(uint8_t staid,uint8_t tid) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + uint uVar1; + + if ((((ps_env.ps_on != false) && (CONCAT31(in_register_00002029,staid) != 0xff)) && + (CONCAT31(in_register_0000202d,tid) != 0xff)) && + ((uVar1 = (uint)sta_info_tab[CONCAT31(in_register_00002029,staid)].inst_nbr, + vif_info_tab[uVar1].type == '\0' && (vif_info_tab[uVar1].active != false)))) { + if ((vif_info_tab[uVar1].u[0xc] >> ((uint)"\x01"[CONCAT31(in_register_0000202d,tid)] & 0x1f) & 1 + ) != 0) { + vif_info_tab[uVar1].prevent_sleep = vif_info_tab[uVar1].prevent_sleep | 8; + *(undefined4 *)(vif_info_tab[uVar1].u + 8) = _DAT_44b00120; + return; + } + td_pck_ps_ind(vif_info_tab[uVar1].index,false); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ps_uapsd_set(vif_info_tag *vif_entry,uint8_t hw_queue,_Bool uapsd) + +{ + byte bVar1; + undefined3 in_register_00002031; + + bVar1 = (byte)(1 << ((uint)hw_queue & 0x1f)); + if (CONCAT31(in_register_00002031,uapsd) == 0) { + vif_entry->u[0xc] = vif_entry->u[0xc] & ~bVar1; + } + else { + vif_entry->u[0xc] = vif_entry->u[0xc] | bVar1; + if ((ps_env.ps_on != false) && (ps_env.uapsd_tmr_on == false)) { + ps_env.uapsd_on = true; + mm_timer_set(&ps_env.uapsd_timer,_DAT_44b00120 + ps_env.uapsd_timeout); + ps_env.uapsd_tmr_on = true; + } + } + return; +} + + + +void ps_traffic_status_update(uint8_t vif_index,uint8_t new_status) + +{ + _Bool pause; + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + char cVar1; + co_list_hdr cVar2; + + if (((ps_env.ps_on != false) && ((ps_env.dpsm_state & 1) != 0)) && ((ps_env.dpsm_state & 6) == 0)) + { + cVar2 = (co_list_hdr)vif_mgmt_env.used_list.first; + if (CONCAT31(in_register_0000202d,new_status) == 0) { + while (cVar2 != (co_list_hdr)0x0) { + if ((((uint)*(byte *)((int)cVar2 + 0x57) != CONCAT31(in_register_00002029,vif_index)) && + (cVar1 = *(char *)&((co_list_hdr *)((int)cVar2 + 0x58))->next, cVar1 != '\0')) && + ((*(char *)((int)cVar2 + 0x56) == '\0' && + ((td_env[(uint)*(byte *)((int)cVar2 + 0x57)].status & 0xc) != 0)))) goto LAB_23009fa8; + cVar2 = *(co_list_hdr *)cVar2; + } + cVar1 = '\0'; +LAB_23009fa8: + if (cVar1 == '\0') { + if ((ps_env.dpsm_state & 8) == 0) { + return; + } + pause = false; + goto LAB_23009fb0; + } + } + pause = true; + if ((ps_env.dpsm_state & 8) == 0) { +LAB_23009fb0: + ps_dpsm_update(pause); + return; + } + } + return; +} + + + +void bl_init(void) + +{ + fw_nap_chain_ptr = &fw_nap_chain; + bl_env.hw_in_doze = 0; + dbg_init(); + me_init(); + mm_init(); + ke_init(); + memset(&sta_conn_info,0,0xec); + sta_conn_info._4_2_ = 0xffff; + sta_conn_info.conType = '\0'; + sta_conn_info.gtkHwKeyId = -1; + supplicantFuncInit(); + allocSupplicantData(&sta_conn_info); + return; +} + + +/* +Unable to decompile 'bl_reset_evt' +Cause: Exception while decompiling 2300a040: Decompiler process died + +*/ + + +// WARNING: Type propagation algorithm not settling + +int bl_sleep(void) + +{ + vif_info_tag *p_vif_entry; + _Bool _Var1; + ke_state_t kVar2; + undefined2 extraout_var_01; + undefined3 extraout_var; + undefined3 extraout_var_00; + + if (ke_env.evt_field != 0) { + return 0; + } + kVar2 = ke_state_get(4); + if (((CONCAT22(extraout_var_01,kVar2) == 0) && (ps_env.ps_on != false)) && + (p_vif_entry = (vif_info_tag *)vif_mgmt_env.used_list.first, ps_env.prevent_sleep == 0)) { + while (p_vif_entry != (vif_info_tag *)0x0) { + _Var1 = chan_is_on_channel(p_vif_entry); + if ((CONCAT31(extraout_var_00,_Var1) != 0) && (p_vif_entry->prevent_sleep != 0)) { + return 0; + } + p_vif_entry = *(vif_info_tag **)&p_vif_entry->list_hdr; + } + if (txl_cntrl_env.pck_cnt == 0) { + _Var1 = hal_machw_sleep_check(); + return CONCAT31(extraout_var,_Var1); + } + } + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t bl_nap_calculate(void) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + + uVar2 = 0; + uVar1 = 0xffffffff; + do { + if ((1 << (uVar2 & 0x1f) & _DAT_44b0808c) != 0) { + uVar3 = *(uint *)(&DAT_44b00128 + uVar2 * 4); + if (_DAT_44b00120 < uVar3) { + uVar3 = uVar3 - _DAT_44b00120; + } + else { + uVar3 = (_DAT_44b00120 - 1) - uVar3; + } + if (uVar3 < uVar1) { + uVar1 = uVar3; + } + } + uVar2 = uVar2 + 1; + } while (uVar2 != 9); + return uVar1; +} + + + +void mm_ps_change_ind(uint8_t sta_idx,uint8_t ps_state) + +{ + undefined3 in_register_00002029; + uint8_t *puVar1; + + puVar1 = (uint8_t *)ke_msg_alloc(0x49,0xd,0,2); + sta_info_tab[CONCAT31(in_register_00002029,sta_idx)].ps_state = ps_state; + *puVar1 = sta_idx; + puVar1[1] = ps_state; + ke_msg_send(); + return; +} + + + +void rxl_mpdu_transfer(rx_swdesc *swdesc) + +{ + rx_pbd *prVar1; + rx_pbd *prVar2; + rx_pbd *prVar3; + rx_dmadesc *prVar4; + + prVar4 = swdesc->dma_hdrdesc; + prVar1 = (rx_pbd *)(prVar4->hd).first_pbd_ptr; + phy_get_channel(&prVar4->phy_info,'\0'); + prVar4->payl_offset = mac_payload_offset; + swdesc->pbd_count = '\0'; + prVar3 = (rx_pbd *)0x0; + do { + prVar2 = prVar1; + if ((prVar2->bufstatinfo & 1) != 0) { + swdesc->spare_pbd = prVar2; + swdesc->last_pbd = prVar3; + return; + } + prVar1 = (rx_pbd *)prVar2->next; + swdesc->pbd_count = swdesc->pbd_count + '\x01'; + prVar3 = prVar2; + } while (prVar1 != (rx_pbd *)0x0); + assert_rec("pd != NULL","module",0xb4); + return; +} + + + +void rxl_init(void) + +{ + rxl_hwdesc_init(1); + rx_swdesc_init(); + co_list_init((co_list *)&rxl_cntrl_env); + rxu_cntrl_init(); + return; +} + + + +void rxl_cntrl_dump(void) + +{ + uint32_t uVar1; + co_list_hdr cVar2; + + uVar1 = co_list_cnt((co_list *)&rxl_cntrl_env); + cVar2 = (co_list_hdr)rxl_cntrl_env.ready.first; + if (uVar1 != 0) { + while (cVar2 != (co_list_hdr)0x0) { + cVar2 = *(co_list_hdr *)cVar2; + } + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxl_timer_int_handler(void) + +{ + rx_hd *prVar1; + rx_dmadesc *desc; + char *condition; + rx_swdesc *list_hdr; + int line; + uint32_t uVar2; + + _DAT_44b0807c = 0xa0000; + do { + while( true ) { + if ((rxl_cntrl_env.first == (rx_dmadesc *)0x0) || + (-1 < (int)(((rxl_cntrl_env.first)->hd).statinfo << 0x11))) { + if (rxl_cntrl_env.ready.first != (co_list_hdr *)0x0) { + ke_evt_set(0x40000); + return; + } + return; + } + list_hdr = ((rxl_cntrl_env.first)->hd).swdesc; + prVar1 = &(rxl_cntrl_env.first)->hd; + desc = list_hdr->dma_hdrdesc; + rxl_cntrl_env.first = (rx_dmadesc *)((rxl_cntrl_env.first)->hd).next; + list_hdr->pd = (rx_payloaddesc *)prVar1->first_pbd_ptr; + uVar2 = (desc->hd).first_pbd_ptr; + if ((desc->hd).frmlen == 0) break; + if (uVar2 == 0) { + line = 0xd8; + condition = "pd != NULL"; +LAB_2300a286: + assert_rec(condition,"module",line); + } + else { + co_list_push_back((co_list *)&rxl_cntrl_env,(co_list_hdr *)list_hdr); + } + } + if (uVar2 != 0) { + line = 0xfa; + condition = "dma_hdrdesc->hd.first_pbd_ptr == 0"; + goto LAB_2300a286; + } + list_hdr->spare_pbd = (rx_pbd *)0x0; + list_hdr->last_pbd = (rx_pbd *)0x0; + rxl_hd_append(desc); + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxl_timeout_int_handler(void) + +{ + _DAT_44b0808c = _DAT_44b0808c & 0xffffffbf; + return; +} + + + +void rxl_dma_int_handler(void) + +{ + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxl_dma_evt(int dummy) + +{ + ke_evt_clear(0x100000); + _DAT_44a00020 = 0x20; + return; +} + + + +void rxl_frame_release(rx_swdesc *swdesc) + +{ + rxl_pd_append((rx_pbd *)(swdesc->dma_hdrdesc->hd).first_pbd_ptr,swdesc->last_pbd,swdesc->spare_pbd + ); + rxl_hd_append(swdesc->dma_hdrdesc); + return; +} + + + +void rxl_mpdu_free(rx_swdesc *swdesc) + +{ + ushort uVar1; + rx_pbd *prVar2; + rx_pbd *prVar3; + rx_pbd *prVar4; + + prVar2 = (rx_pbd *)(swdesc->dma_hdrdesc->hd).first_pbd_ptr; + vTaskEnterCritical(); + swdesc->use_in_tcpip = '\0'; + swdesc->dma_hdrdesc->use_in_tcpip = 0; + prVar4 = (rx_pbd *)0x0; + do { + prVar3 = prVar2; + uVar1 = prVar3->bufstatinfo; + prVar3[1].upattern = 0; + if ((uVar1 & 1) != 0) { + swdesc->spare_pbd = prVar3; + swdesc->last_pbd = prVar4; + rxl_frame_release(swdesc); + vTaskExitCritical(); + return; + } + prVar2 = (rx_pbd *)prVar3->next; + prVar4 = prVar3; + } while ((rx_pbd *)prVar3->next != (rx_pbd *)0x0); + assert_rec("pd != NULL","module",0x397); + return; +} + + +/* +Unable to decompile 'rxl_cntrl_evt' +Cause: Exception while decompiling 2300a38a: Decompiler process died + +*/ + + +void bl60x_firmwre_mpdu_free(void *swdesc_ptr) + +{ + rx_swdesc *swdesc; + + vTaskEnterCritical(); + rxl_cntrl_env.packet_stack_cnt = + rxl_cntrl_env.packet_stack_cnt - *(byte *)((int)swdesc_ptr + 0x1d); + vTaskExitCritical(); + rxl_mpdu_free((rx_swdesc *)swdesc_ptr); + return; +} + + + +void rxl_reset(void) + +{ + rxl_hwdesc_init(0); + co_list_init((co_list *)&rxl_cntrl_env); + co_list_init((co_list *)&swdesc); + return; +} + + + +void rxl_hwdesc_dump(void) + +{ + rx_dmadesc *prVar1; + rx_payloaddesc *prVar2; + int iVar3; + int iVar4; + uint32_t uVar5; + + puts("---------- rxl_hwdesc_dump -------\r\n"); + printf("rx_dma_hdrdesc: %d\r\n",0xd); + iVar3 = 0; + prVar1 = rx_dma_hdrdesc; + do { + printf(" [%2d]@%08lx: upatternrx %08lx next %08lx first_pbd_ptr %08lx, swdesc %p\r\n",iVar3, + prVar1,(prVar1->hd).upatternrx,(prVar1->hd).next,(prVar1->hd).first_pbd_ptr, + (prVar1->hd).swdesc); + iVar3 = iVar3 + 1; + printf( + " datastartptr %08lx dataendptr %08lx, headerctrlinfo %08lx frmlen %4u ampdu_stat_info %04x\r\n" + ,(prVar1->hd).datastartptr,(prVar1->hd).dataendptr,(prVar1->hd).headerctrlinfo, + (uint)(prVar1->hd).frmlen,(uint)(prVar1->hd).ampdu_stat_info); + printf( + " tsflo %08lx tsfhi %08lx recvec1b %08lx recvec1c %08lx recvec1d %08lx recvec2a %08lx recvec2b %08lx statinfo %08lx\r\n" + ,(prVar1->hd).tsflo,(prVar1->hd).tsfhi,(prVar1->hd).recvec1b,(prVar1->hd).recvec1c, + (prVar1->hd).recvec1d,(prVar1->hd).recvec2a,(prVar1->hd).recvec2b); + prVar1 = prVar1 + 1; + } while (iVar3 != 0xd); + printf("rx_payload_desc: %d\r\n",0xd); + iVar3 = 0; + prVar2 = rx_payload_desc; + do { + uVar5 = (prVar2->pbd).dataendptr; + iVar4 = 0; + if (uVar5 != 0) { + iVar4 = (uVar5 + 1) - (prVar2->pbd).datastartptr; + } + iVar3 = iVar3 + 1; + printf( + " [%2d]@%08lx %3lu Bytes: upatternrx %08lx next %08lx datastartptr %08lx dataendptr %08lx bufstatinfo %04x reserved %04X\r\n" + ,prVar2,iVar4,(prVar2->pbd).upattern,(prVar2->pbd).next); + prVar2 = prVar2 + 1; + } while (iVar3 != 0xd); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxl_hwdesc_init(int init) + +{ + rx_dmadesc *prVar1; + rx_dmadesc *prVar2; + txl_buffer_control *ptVar3; + txl_buffer_control *ptVar4; + txl_buffer_control *ptVar5; + int iVar6; + uint32_t *puVar7; + int iVar8; + txl_buffer_control *ptVar9; + rx_dmadesc *prVar10; + rx_dmadesc *prVar11; + rx_dmadesc *prVar12; + rx_dmadesc *prVar13; + txl_buffer_control *ptVar14; + txl_buffer_control *ptVar15; + + vTaskEnterCritical(); + prVar13 = (rx_dmadesc *)0x0; + iVar6 = 0; + iVar8 = 0; + prVar1 = (rx_dmadesc *)0x0; + prVar10 = rx_dma_hdrdesc; + prVar11 = (rx_dmadesc *)0x0; + do { + prVar2 = prVar10; + prVar10 = prVar2 + 1; + prVar12 = prVar11; + if ((init == 0) && (prVar2->use_in_tcpip == 1)) { + prVar2 = prVar1; + if (prVar1 != (rx_dmadesc *)0x0) { + (prVar1->hd).next = 0; + } + } + else { + if (prVar1 != (rx_dmadesc *)0x0) { + *(rx_dmadesc **)&(prVar1->hd).next = prVar2; + } + (prVar2->hd).datastartptr = 0; + (prVar2->hd).dataendptr = 0; + (prVar2->hd).upatternrx = 0xbaadf00d; + (prVar2->hd).statinfo = 0; + (prVar2->hd).headerctrlinfo = 0; + *(rx_dmadesc **)&(prVar2->hd).next = prVar10; + (prVar2->hd).first_pbd_ptr = 0; + (prVar2->hd).swdesc = rx_swdesc_tab + iVar8; + (prVar2->hd).frmlen = 0; + prVar12 = prVar2; + if ((iVar6 != 0) && (prVar12 = prVar11, iVar6 == 1)) { + prVar13 = prVar2; + } + iVar6 = iVar6 + 1; + } + iVar8 = iVar8 + 1; + prVar1 = prVar2; + prVar11 = prVar12; + } while (iVar8 != 0xd); + if (iVar6 < 4) { + printf("No enough DESC %d(%d)\r\n",0xd); + } + if (prVar2 != (rx_dmadesc *)0x0) { + (prVar2->hd).next = 0; + } + _DAT_44b08180 = 0x4000000; + puVar7 = rx_payload_desc_buffer; + ptVar9 = (txl_buffer_control *)0x0; + iVar6 = 0; + ptVar3 = (txl_buffer_control *)0x0; + ptVar5 = (txl_buffer_control *)rx_payload_desc; + ptVar14 = (txl_buffer_control *)0x0; + _DAT_44b081b8 = prVar13; + do { + ptVar4 = ptVar5; + ptVar5 = (txl_buffer_control *)&ptVar4->mac_control_info; + ptVar15 = ptVar14; + if ((init == 0) && (*(int *)(ptVar4->field_0 + 0x14) == 1)) { + ptVar4 = ptVar3; + if (ptVar3 != (txl_buffer_control *)0x0) { + *(undefined4 *)ptVar3->field_0 = 0; + } + } + else { + if (ptVar3 != (txl_buffer_control *)0x0) { + *(txl_buffer_control **)ptVar3->field_0 = ptVar4; + } + *(txl_buffer_control **)ptVar4->field_0 = ptVar5; + *(undefined4 *)ptVar4->field_0 = 0xc0dedbad; + *(undefined2 *)ptVar4->field_0 = 0; + *(uint32_t **)ptVar4->field_0 = puVar7; + *(int *)ptVar4->field_0 = (int)puVar7 + 0x34f; + *(uint32_t **)(ptVar4->field_0 + 0x18) = puVar7; + ptVar15 = ptVar4; + if ((iVar6 != 0) && (ptVar15 = ptVar14, iVar6 == 1)) { + ptVar9 = ptVar4; + } + iVar6 = iVar6 + 1; + } + puVar7 = puVar7 + 0xd4; + ptVar3 = ptVar4; + ptVar14 = ptVar15; + } while (ptVar5 != txl_buffer_control_desc_bcmc); + if (iVar6 < 4) { + printf("No enough PBD DESC, %d(%d)\r\n",0xd); + } + *(undefined4 *)ptVar4->field_0 = 0; + _DAT_44b08180 = 0x8000000; + _DAT_44b081bc = ptVar9; + if ((((prVar12 == (rx_dmadesc *)0x0) || (prVar13 == (rx_dmadesc *)0x0)) || + (prVar2 == (rx_dmadesc *)0x0)) || + ((ptVar15 == (txl_buffer_control *)0x0 || (ptVar9 == (txl_buffer_control *)0x0)))) { + printf("%p:%p%p vs %p:%p:%p\r\n",prVar12,prVar13,prVar2,ptVar15,ptVar4); + } + rxl_cntrl_env.first = prVar13; + rxl_cntrl_env.last = prVar2; + rxl_cntrl_env.free = prVar12; + rx_hwdesc_env.last = (rx_pbd *)ptVar4; + rx_hwdesc_env.free = (rx_pbd *)ptVar15; + vTaskExitCritical(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxl_hd_append(rx_dmadesc *desc) + +{ + rx_dmadesc *prVar1; + + if (desc == (rx_dmadesc *)0x0) { + assert_err("desc != NULL","module",0xf9); + } + prVar1 = desc; + if (rxl_cntrl_env.free != _DAT_44b08548) { + prVar1 = rxl_cntrl_env.free; + rxl_cntrl_env.free = desc; + } + (prVar1->hd).next = 0; + (prVar1->hd).first_pbd_ptr = 0; + (prVar1->hd).statinfo = 0; + (prVar1->hd).frmlen = 0; + *(rx_dmadesc **)&((rxl_cntrl_env.last)->hd).next = prVar1; + if (rxl_cntrl_env.first == (rx_dmadesc *)0x0) { + rxl_cntrl_env.first = prVar1; + } + rxl_cntrl_env.last = prVar1; + _DAT_44b08180 = 0x1000000; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxl_pd_append(rx_pbd *first,rx_pbd *last,rx_pbd *spare) + +{ + rx_pbd **pprVar1; + rx_pbd *prVar2; + rx_pbd *prVar3; + rx_pbd *prVar4; + + if (spare == (rx_pbd *)0x0) { + assert_err("spare != NULL","module",0x128); + } + prVar4 = rx_hwdesc_env.free; + if (rx_hwdesc_env.free == _DAT_44b0854c) { + prVar4 = first; + if (last == (rx_pbd *)0x0) { + prVar4 = spare; + } + spare->bufstatinfo = 0; + } + else { + prVar2 = rx_hwdesc_env.free; + prVar3 = spare; + if (last != (rx_pbd *)0x0) { + pprVar1 = (rx_pbd **)&(rx_hwdesc_env.free)->next; + rx_hwdesc_env.free = spare; + *pprVar1 = first; + prVar2 = last; + prVar3 = rx_hwdesc_env.free; + } + rx_hwdesc_env.free = prVar3; + spare = prVar2; + prVar4->bufstatinfo = 0; + } + spare->next = 0; + *(rx_pbd **)&(rx_hwdesc_env.last)->next = prVar4; + rx_hwdesc_env.last = spare; + _DAT_44b08180 = 0x2000000; + return; +} + + + +void scan_search_ds(void) + +{ + scan_start_req *param; + + DAT_4201ea4c = mac_ie_find(0x42045d04,(uint)param->add_ie_len,3); + return; +} + + + +void scan_init(void) + +{ + memset(&scan_env,0,0x1c); + ke_state_set(2,0); + DAT_4201ea3c = &scan_probe_req_ie; + DAT_4201ea40 = dma_cb; + DAT_4201ea44 = 0; + scan_probe_req_ie.dma_desc.dest = 0x42045d04; + scan_probe_req_ie.pbd.upatterntx = 0xcafefade; + scan_probe_req_ie.pbd.next = 0; + scan_probe_req_ie.pbd.datastartptr = 0x42045d04; + scan_probe_req_ie.pbd.bufctrlinfo = 0; + return; +} + + + +void scan_set_channel_request(void) + +{ + scan_chan_tag *psVar1; + uint uVar2; + undefined uVar3; + int iVar4; + + psVar1 = param->chan + DAT_4201ea52; + chan_scan_req(*(uint8_t *)(&psVar1->freq + 1),psVar1->freq,*(int8_t *)(&psVar1->freq + 2),110000, + param->vif_idx); + if (DAT_4201ea4c == 0) goto LAB_2300ac5c; + uVar2 = (uint)psVar1->freq; + if (*(char *)(&psVar1->freq + 1) == '\0') { + uVar3 = 0; + if (((uVar2 - 0x96c & 0xffff) < 0x49) && (uVar3 = 0xe, psVar1->freq != 0x9b4)) { + iVar4 = -0x967; +LAB_2300ac50: + uVar3 = (undefined)((int)(uVar2 + iVar4) / 5); + } + } + else { + uVar3 = 0; + if ((*(char *)(&psVar1->freq + 1) == '\x01') && ((uVar2 - 0x138d & 0xffff) < 0x335)) { + iVar4 = -5000; + goto LAB_2300ac50; + } + } + *(undefined *)(DAT_4201ea4c + 2) = uVar3; +LAB_2300ac5c: + ke_state_set(2,2); + return; +} + + + +void dma_cb(void *env,int dma_queue) + +{ + scan_search_ds(); + scan_set_channel_request(); + return; +} + + + +void scan_ie_download(scan_start_req *param) + +{ + scan_search_ds(); + scan_set_channel_request(); + scan_probe_req_ie.pbd.dataendptr = + (scan_probe_req_ie.pbd.datastartptr - 1) + (uint)param->add_ie_len; + scan_probe_req_ie.pbd.bufctrlinfo = 0; + return; +} + + + +void scan_probe_req_tx(void) + +{ + byte bVar1; + byte bVar2; + scan_start_req *psVar3; + txl_buffer_tag *ptVar4; + uint type; + txl_frame_desc_tag *frame; + int iVar5; + int iVar6; + uint uVar7; + uint8_t *puVar8; + tx_hw_desc *ptVar9; + + psVar3 = param; + uVar7 = (uint)DAT_4201ea52; + bVar1 = param->vif_idx; + puVar8 = param->ssid[0].array; + iVar6 = 0; + while( true ) { + if ((int)(uint)psVar3->ssid_cnt <= iVar6) { + return; + } + type = 1; + if (psVar3->chan[uVar7].band == '\0') { + type = (uint)psVar3->no_cck; + } + frame = txl_frame_get(type,(uint)psVar3->add_ie_len + (uint)puVar8[-1] + 0x1a); + if (frame == (txl_frame_desc_tag *)0x0) break; + ptVar4 = (frame->txdesc).lmac.buffer; + ptVar9 = (frame->txdesc).lmac.hw_desc; + *(undefined *)&ptVar4[1].length = 0x40; + *(undefined *)((int)&ptVar4[1].length + 1) = 0; + *(undefined *)((int)&ptVar4[1].length + 2) = 0; + *(undefined *)((int)&ptVar4[1].length + 3) = 0; + memcpy(&ptVar4[1].lenheader,&mac_addr_bcst,6); + memcpy((void *)((int)&ptVar4[1].lenpad + 2),&vif_info_tab[bVar1].mac_addr,6); + memcpy(&ptVar4[1].next,&psVar3->bssid,6); + type = (uint)txl_cntrl_env.seqnbr; + *(undefined *)&ptVar4[1].dma_desc[0].src = 0; + txl_cntrl_env.seqnbr = (uint16_t)((type + 1) * 0x10000 >> 0x10); + iVar5 = (type + 1) * 0x100000; + *(undefined *)((int)&ptVar4[1].txdesc + 2) = (char)((uint)iVar5 >> 0x10); + *(undefined *)((int)&ptVar4[1].txdesc + 3) = (char)((uint)iVar5 >> 0x18); + bVar2 = puVar8[-1]; + *(byte *)((int)&ptVar4[1].dma_desc[0].src + 1) = bVar2; + type = 0; + while ((uint)bVar2 != type) { + *(uint8_t *)((int)&ptVar4[1].dma_desc[0].src + type + 2) = puVar8[type]; + type = type + 1; + } + (ptVar9->thd).field_3 = 0x42045cf0; + (ptVar9->thd).field_5 = (ptVar9->thd).field_5 - (uint)psVar3->add_ie_len; + (frame->cfm).cfm_func = (cfm_func_ptr *)0x0; + (frame->cfm).env = (void *)0x0; + iVar6 = iVar6 + 1; + puVar8 = puVar8 + 0x22; + (frame->txdesc).host.vif_idx = psVar3->vif_idx; + (frame->txdesc).host.staid = -1; + txl_frame_push(frame,'\x03'); + } + return; +} + + + +void scan_send_cancel_cfm(uint8_t status,ke_task_id_t dest_id) + +{ + uint8_t *puVar1; + + puVar1 = (uint8_t *)ke_msg_alloc(0x804,dest_id,2,1); + *puVar1 = status; + ke_msg_send(); + return; +} + + + +void sta_mgmt_entry_init(sta_info_tag *sta_entry) + +{ + txdesc *txdesc; + uint16_t *puVar1; + + while ((sta_entry->tx_desc_post).first != (co_list_hdr *)0x0) { + txdesc = (txdesc *)co_list_pop_front(&sta_entry->tx_desc_post); + txl_frame_release(txdesc,true); + } + memset(sta_entry,0,0x1b0); + puVar1 = (uint16_t *)&sta_entry->ba_info[0].bam_idx_rx; + do { + *(uint8_t *)puVar1 = '\x02'; + *(uint8_t *)((int)puVar1 + 1) = '\x02'; + puVar1 = puVar1 + 6; + } while (puVar1 != sta_entry->rx_qos_last_seqcntl + 3); + sta_entry->inst_nbr = -1; + return; +} + + + +void sta_mgmt_init(void) + +{ + sta_info_tag *sta_entry; + sta_info_tag *psVar1; + + co_list_init((co_list *)&sta_info_env); + sta_entry = sta_info_tab; + do { + sta_mgmt_entry_init(sta_entry); + psVar1 = sta_entry + 1; + co_list_push_back((co_list *)&sta_info_env,(co_list_hdr *)sta_entry); + sta_entry = psVar1; + } while (psVar1 != sta_info_tab + 10); + sta_mgmt_entry_init(sta_info_tab + 10); + sta_info_tab[10].pol_tbl.buf_ctrl = txl_buffer_control_desc_bcmc; + sta_info_tab[10].sta_sec_info.cur_key = &vif_info_tab[0].default_key; + sta_info_tab[10].inst_nbr = '\0'; + sta_info_tab[10].ctrl_port_state = '\0'; + printf("------ set default key %p, key ptr %p\r\n",0x42020538,vif_info_tab[0].default_key); + sta_mgmt_entry_init(sta_info_tab + 0xb); + sta_info_tab[11].inst_nbr = '\x01'; + sta_info_tab[11].pol_tbl.buf_ctrl = txl_buffer_control_desc_bcmc + 1; + sta_info_tab[11].ctrl_port_state = '\0'; + sta_info_tab[11].sta_sec_info.cur_key = &vif_info_tab[1].default_key; + printf("------ set default key %p, key ptr %p\r\n",vif_info_tab[1].default_key); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t sta_mgmt_register(mm_sta_add_req *param,uint8_t *sta_idx) + +{ + uint8_t uVar1; + co_list_hdr *list_hdr; + char *fmt; + undefined4 uVar2; + key_info_tag *pkVar3; + co_list_hdr *pcVar4; + byte bVar5; + co_list_hdr *pcVar6; + co_list_hdr *pcVar7; + uint uVar8; + + uVar8 = (uint)param->inst_nbr; + list_hdr = co_list_pop_front((co_list *)&sta_info_env); + if (list_hdr == (co_list_hdr *)0x0) { + uVar1 = '\x01'; + } + else { + memcpy((void *)((int)&list_hdr[7].next + 2),¶m->mac_addr,6); + bVar5 = param->ampdu_spacing_min; + if (bVar5 < 0x10) { + bVar5 = 0x10; + } + *(byte *)&list_hdr[5].next = bVar5; + *(uint16_t *)&list_hdr[3].next = param->ampdu_size_max_ht; + list_hdr[2].next = (co_list_hdr *)param->ampdu_size_max_vht; + list_hdr[4].next = (co_list_hdr *)param->paid_gid; + *(uint8_t *)((int)&list_hdr[6].next + 2) = param->inst_nbr; + *(int8_t *)&list_hdr[9].next = param->rssi; + list_hdr[10].next = (co_list_hdr *)param->tsflo; + list_hdr[0xb].next = (co_list_hdr *)param->tsfhi; + *(uint8_t *)&list_hdr[0xc].next = param->data_rate; + uVar1 = (char)((int)(list_hdr + -0x10807a98) >> 4) * '\x13'; + *sta_idx = uVar1; + *(uint8_t *)((int)&list_hdr[6].next + 3) = uVar1; + list_hdr[1].next = (co_list_hdr *)0x19000; + *(undefined2 *)&list_hdr[0x62].next = 0xffff; + pcVar6 = (co_list_hdr *)((int)&list_hdr[0x62].next + 2); + do { + *(undefined2 *)&pcVar6->next = 0xffff; + pcVar6 = (co_list_hdr *)((int)&pcVar6->next + 2); + } while (pcVar6 != list_hdr + 0x67); + bVar5 = *sta_idx; + *(undefined *)((int)&list_hdr[0xc].next + 1) = 0; + *(txl_buffer_control **)&list_hdr[0x43].next = txl_buffer_control_desc + bVar5; + if ((vif_info_tab[uVar8].flags & 8) == 0) { + list_hdr[0x2b].next = (co_list_hdr *)(uVar8 * 0x5d8 + 0x42020538); + pkVar3 = vif_info_tab[uVar8].default_key; + uVar2 = 0x10d; + fmt = "------ %d set default key %p, ptr %p\r\n"; + } + else { + pkVar3 = (key_info_tag *)list_hdr[0x2a].next; + list_hdr[0x2b].next = list_hdr + 0x2a; + uVar2 = 0x102; + fmt = "------ %d set default key %p, key ptr %p\r\n"; + } + printf(fmt,uVar2,pkVar3); + pcVar6 = _DAT_44b00120; + pcVar7 = list_hdr + 0x47; + pcVar4 = _DAT_44b00120 + -250000; + do { + pcVar7->next = pcVar6; + pcVar7[1].next = pcVar4; + pcVar7 = pcVar7 + 3; + } while (pcVar7 != list_hdr + 0x62); + co_list_push_back(&vif_info_tab[uVar8].sta_list,list_hdr); + *(undefined *)((int)&list_hdr[7].next + 1) = 1; + uVar1 = '\0'; + } + return uVar1; +} + + + +void sta_mgmt_unregister(uint8_t sta_idx) + +{ + sta_info_tag *sta_entry; + undefined3 in_register_00002029; + + sta_entry = sta_info_tab + CONCAT31(in_register_00002029,sta_idx); + co_list_extract(&vif_info_tab[sta_info_tab[CONCAT31(in_register_00002029,sta_idx)].inst_nbr]. + sta_list,(co_list_hdr *)sta_entry); + sta_mgmt_entry_init(sta_entry); + co_list_push_back((co_list *)&sta_info_env,(co_list_hdr *)sta_entry); + return; +} + + + +void sta_mgmt_add_key(mm_key_add_req *param,uint8_t hw_key_idx) + +{ + uint8_t uVar1; + uint uVar2; + + uVar2 = (uint)param->sta_idx; + sta_info_tab[uVar2].sta_sec_info.key_info.hw_key_idx = hw_key_idx; + sta_info_tab[uVar2].sta_sec_info.key_info.cipher = param->cipher_suite; + sta_info_tab[uVar2].sta_sec_info.key_info.key_idx = param->key_idx; + memset(&sta_info_tab[uVar2].sta_sec_info,0,0x48); + uVar1 = sta_info_tab[uVar2].sta_sec_info.key_info.cipher; + if (uVar1 == '\x01') { + *(undefined4 *)&sta_info_tab[uVar2].sta_sec_info.key_info.tx_pn = 0; + *(undefined4 *)((int)&sta_info_tab[uVar2].sta_sec_info.key_info.tx_pn + 4) = 0; + *(uint32_t *)sta_info_tab[uVar2].sta_sec_info.key_info.u = (param->key).array[4]; + *(uint32_t *)(sta_info_tab[uVar2].sta_sec_info.key_info.u + 4) = (param->key).array[5]; + *(uint32_t *)(sta_info_tab[uVar2].sta_sec_info.key_info.u + 8) = (param->key).array[6]; + *(uint32_t *)(sta_info_tab[uVar2].sta_sec_info.key_info.u + 0xc) = (param->key).array[7]; + } + else { + if ((uVar1 == '\0') || (uVar1 == '\x03')) { + next = next * 0x41c64e6d + 0x3039; + *(ulong *)&sta_info_tab[uVar2].sta_sec_info.key_info.tx_pn = next >> 0x10; + *(undefined4 *)((int)&sta_info_tab[uVar2].sta_sec_info.key_info.tx_pn + 4) = 0; + } + else { + *(undefined4 *)&sta_info_tab[uVar2].sta_sec_info.key_info.tx_pn = 0; + *(undefined4 *)((int)&sta_info_tab[uVar2].sta_sec_info.key_info.tx_pn + 4) = 0; + } + } + sta_info_tab[uVar2].sta_sec_info.key_info.valid = true; + *(sta_mgmt_sec_info **)&sta_info_tab[uVar2].sta_sec_info.pairwise_key = + &sta_info_tab[uVar2].sta_sec_info; + return; +} + + + +void sta_mgmt_del_key(sta_info_tag *sta) + +{ + (sta->sta_sec_info).key_info.valid = false; + (sta->sta_sec_info).pairwise_key = (key_info_tag *)0x0; + sta->ctrl_port_state = '\x01'; + return; +} + + + +int sta_mgmt_send_postponed_frame(vif_info_tag *p_vif_entry,sta_info_tag *p_sta_entry,int limit) + +{ + uint8_t access_category; + int iVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 extraout_var_00; + txdesc *txdesc; + int iStack36; + int stop; + + iVar1 = 0; + while( true ) { + txdesc = (txdesc *)(p_sta_entry->tx_desc_post).first; + if (txdesc == (txdesc *)0x0) { + return iVar1; + } + iStack36 = 0; + _Var2 = txl_cntrl_tx_check(p_vif_entry); + if (CONCAT31(extraout_var,_Var2) == 0) { + return iVar1; + } + _Var2 = apm_tx_int_ps_check(txdesc); + if (CONCAT31(extraout_var_00,_Var2) == 0) { + return iVar1; + } + txdesc = apm_tx_int_ps_get_postpone(p_vif_entry,p_sta_entry,&iStack36); + if (iStack36 != 0) break; + if (txdesc == (txdesc *)0x0) { + txdesc = (txdesc *)co_list_pop_front(&p_sta_entry->tx_desc_post); + } + access_category = (txdesc->host).tid; + *(undefined *)((int)&txdesc[1].host.packet_addr + 1) = 0; + iVar1 = iVar1 + 1; + txl_cntrl_push_int(txdesc,access_category); + if ((limit != 0) && (iVar1 == limit)) { + return iVar1; + } + } + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void td_timer_end(void *env) + +{ + int iVar1; + bool bVar2; + undefined *puVar3; + undefined *puVar4; + + iVar1 = _DAT_44b00120; + if (*(char *)((int)env + 0x23) != '\0') { + bVar2 = *(int *)((int)env + 0x10) != 0; + if (*(int *)((int)env + 0x14) != 0) { + bVar2 = (bool)(bVar2 | 2); + } + if (*(int *)((int)env + 0x18) != 0) { + bVar2 = (bool)(bVar2 | 4); + } + if (*(int *)((int)env + 0x1c) != 0) { + bVar2 = (bool)(bVar2 | 8); + } + if (((*(byte *)((int)env + 0x21) ^ bVar2) & 0xc) != 0) { + if ((bVar2 & 4U) == 0) { + puVar3 = &UNK_230abff8; + } + else { + puVar3 = &UNK_230abff4; + } + if ((bVar2 & 8U) == 0) { + puVar4 = &UNK_230abff8; + } + else { + puVar4 = &UNK_230abffc; + } + printf(&DAT_230ac000,puVar3,puVar4); + ps_traffic_status_update(*(uint8_t *)((int)env + 0x20),bVar2 & 0xc); + } + *(bool *)((int)env + 0x21) = bVar2; + } + *(undefined4 *)((int)env + 0x10) = 0; + *(undefined4 *)((int)env + 0x14) = 0; + *(undefined4 *)((int)env + 0x18) = 0; + *(undefined4 *)((int)env + 0x1c) = 0; + *(bool *)((int)env + 0x23) = vif_info_tab[*(byte *)((int)env + 0x20)].chan_ctxt == DAT_42022d30; + mm_timer_set((mm_timer_tag *)env,iVar1 + 1000000); + return; +} + + + +void td_reset(uint8_t vif_index) + +{ + td_env_tag *__s; + undefined3 in_register_00002029; + int iVar1; + + iVar1 = CONCAT31(in_register_00002029,vif_index); + __s = td_env + iVar1; + printf(&DAT_230abfcc,iVar1); + if (td_env[iVar1].is_on != false) { + mm_timer_clear((mm_timer_tag *)__s); + } + memset(__s,0,0x24); + td_env[iVar1].td_timer.cb = td_timer_end; + *(td_env_tag **)&td_env[iVar1].td_timer.env = __s; + td_env[iVar1].vif_index = vif_index; + return; +} + + + +void td_init(void) + +{ + printf(&DAT_230abfc0); + td_reset('\0'); + td_reset('\x01'); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void td_start(uint8_t vif_index) + +{ + int iVar1; + undefined3 in_register_00002029; + int iVar2; + + iVar1 = _DAT_44b00120; + iVar2 = CONCAT31(in_register_00002029,vif_index); + if (td_env[iVar2].is_on == false) { + printf(&DAT_230abfe0,iVar2); + td_env[iVar2].is_on = true; + mm_timer_set((mm_timer_tag *)(td_env + iVar2),iVar1 + 1000000); + return; + } + return; +} + + + +void td_pck_ind(uint8_t vif_index,uint8_t sta_index,_Bool rx) + +{ + undefined3 in_register_00002029; + int iVar1; + undefined3 in_register_00002031; + + iVar1 = CONCAT31(in_register_00002029,vif_index); + if (CONCAT31(in_register_00002031,rx) != 0) { + td_env[iVar1].pck_cnt_rx = td_env[iVar1].pck_cnt_rx + 1; + return; + } + td_env[iVar1].pck_cnt_tx = td_env[iVar1].pck_cnt_tx + 1; + return; +} + + + +void td_pck_ps_ind(uint8_t vif_index,_Bool rx) + +{ + undefined3 in_register_00002029; + int iVar1; + undefined3 in_register_0000202d; + + iVar1 = CONCAT31(in_register_00002029,vif_index); + if (CONCAT31(in_register_0000202d,rx) != 0) { + td_env[iVar1].pck_cnt_rx_ps = td_env[iVar1].pck_cnt_rx_ps + 1; + return; + } + td_env[iVar1].pck_cnt_tx_ps = td_env[iVar1].pck_cnt_tx_ps + 1; + return; +} + + + +void bl_tpc_update_power_table(int8_t *power_table) + +{ + char cVar1; + int32_t *piVar2; + char *pcVar3; + int iStack72; + int32_t power_os [14]; + + trpc_update_power((int8_t (*) [8])power_table); + pcVar3 = power_table + 0x18; + piVar2 = &iStack72; + while (pcVar3 != power_table + 0x26) { + cVar1 = *pcVar3; + pcVar3 = pcVar3 + 1; + *piVar2 = (int)cVar1; + piVar2 = piVar2 + 1; + } + rf_pri_update_power_offset(&iStack72); + return; +} + + + +void bl_tpc_power_table_get(int8_t *power_table_config) + +{ + int iVar1; + + trpc_power_get(power_table_config); + iVar1 = 0x18; + do { + power_table_config[iVar1] = '\0'; + iVar1 = iVar1 + 1; + } while (iVar1 != 0x26); + return; +} + + + +void bl_tpc_update_power_rate_11b(int8_t *power_rate_table) + +{ + int8_t *piVar1; + int8_t *piVar2; + int iVar3; + + iVar3 = 0; + do { + piVar1 = power_rate_table + iVar3; + piVar2 = txpwr_vs_rate_table + iVar3; + iVar3 = iVar3 + 1; + *piVar2 = *piVar1; + } while (iVar3 != 4); + return; +} + + + +void bl_tpc_update_power_rate_11g(int8_t *power_rate_table) + +{ + int8_t *piVar1; + int iVar2; + int8_t *piVar3; + + iVar2 = 0; + piVar3 = txpwr_vs_rate_table; + do { + piVar1 = power_rate_table + iVar2; + iVar2 = iVar2 + 1; + piVar3[8] = *piVar1; + piVar3 = piVar3 + 1; + } while (iVar2 != 8); + return; +} + + + +void bl_tpc_update_power_rate_11n(int8_t *power_rate_table) + +{ + int8_t *piVar1; + int iVar2; + int8_t *piVar3; + + iVar2 = 0; + piVar3 = txpwr_vs_rate_table; + do { + piVar1 = power_rate_table + iVar2; + iVar2 = iVar2 + 1; + piVar3[0x10] = *piVar1; + piVar3 = piVar3 + 1; + } while (iVar2 != 8); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void tpc_update_tx_power(int8_t pwr) + +{ + uint8_t uVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + + uVar1 = trpc_get_default_power_idx('\x02','\0'); + _DAT_44b000a0 = CONCAT31(extraout_var,uVar1) | _DAT_44b000a0 & 0xffffff00; + uVar1 = trpc_get_default_power_idx('\0','\0'); + _DAT_44b000a0 = CONCAT31(extraout_var_00,uVar1) << 8 | _DAT_44b000a0 & 0xffff00ff; + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void tpc_update_vif_tx_power(vif_info_tag *vif,int8_t *pwr,uint8_t *idx) + +{ + char cVar1; + char cVar2; + _Bool _Var3; + undefined3 extraout_var; + int *piVar4; + + if (*pwr == '\x7f') { + return; + } + cVar1 = vif->tx_power; + phy_get_rf_gain_idx(pwr,idx); + cVar2 = *pwr; + vif->tx_power = cVar2; + if (vif->user_tx_power < cVar2) { + *pwr = vif->user_tx_power; + phy_get_rf_gain_idx(pwr,idx); + } + if (*pwr != cVar1) { + piVar4 = (int *)(vif->sta_list).first; + while (piVar4 != (int *)0x0) { + *(byte *)((int)piVar4 + 0x11a) = *(byte *)((int)piVar4 + 0x11a) | 0x10; + piVar4 = (int *)*piVar4; + } + if (vif->chan_ctxt != (chan_ctxt_tag *)0x0) { + chan_update_tx_power(vif->chan_ctxt); + _Var3 = chan_is_on_channel(vif); + if (CONCAT31(extraout_var,_Var3) != 0) { + tpc_update_tx_power((vif->chan_ctxt->channel).tx_power); + return; + } + } + } + return; +} + + + +uint8_t tpc_get_vif_tx_power_vs_rate(uint32_t rate_config) + +{ + uint8_t formatmod; + byte mcs; + + mcs = (byte)rate_config & 0x7f; + if ((rate_config >> 0xb & 7) == 0) { + formatmod = (uint8_t)(rate_config & 0x7c); + if ((rate_config & 0x7c) != 0) { + mcs = mcs - 4; + formatmod = '\x01'; + } + } + else { + formatmod = '\x02'; + } + formatmod = trpc_get_default_power_idx(formatmod,mcs); + return formatmod; +} + + + +void tpc_update_frame_tx_power(vif_info_tag *vif,txl_frame_desc_tag *frame) + +{ + uint32_t uVar1; + uint8_t uVar2; + undefined3 extraout_var; + + uVar1 = (((frame->txdesc).lmac.hw_desc)->thd).policyentryaddr; + uVar2 = tpc_get_vif_tx_power_vs_rate(*(uint32_t *)(uVar1 + 0x14)); + *(undefined4 *)(uVar1 + 0x24) = CONCAT31(extraout_var,uVar2); + return; +} + + + +void txl_cfm_init(void) + +{ + memset(&txl_cfm_env,0,0x28); + co_list_init((co_list *)&txl_cfm_env); + co_list_init(txl_cfm_env.cfmlist + 1); + co_list_init(txl_cfm_env.cfmlist + 2); + co_list_init(txl_cfm_env.cfmlist + 3); + co_list_init(txl_cfm_env.cfmlist + 4); + return; +} + + + +void txl_cfm_push(txdesc *txdesc,uint32_t status,uint8_t access_category) + +{ + undefined3 in_register_00002031; + + ((txdesc->lmac).hw_desc)->cfm_ptr->status = status; + co_list_push_back(txl_cfm_env.cfmlist + CONCAT31(in_register_00002031,access_category), + (co_list_hdr *)txdesc); + ke_evt_set(txl_cfm_evt_bit[CONCAT31(in_register_00002031,access_category)]); + return; +} + + +/* +Unable to decompile 'txl_cfm_evt' +Cause: Exception while decompiling 2300b6f0: Decompiler process died + +*/ + + +void txl_cfm_flush(uint8_t access_category,co_list *list,uint32_t status) + +{ + txdesc *txdesc; + tx_cfm_tag *ptVar1; + + while (txdesc = (txdesc *)co_list_pop_front(list), txdesc != (txdesc *)0x0) { + ptVar1 = ((txdesc->lmac).hw_desc)->cfm_ptr; + if ((txdesc->lmac).agg_desc == (tx_agg_desc *)0x0) { + if (-1 < (int)ptVar1->status) { + ptVar1->status = status; + } + } + else { + ptVar1->status = status | 0x3c000000; + } + if ((txdesc->host).packet_addr == 0) { + txl_frame_cfm(txdesc); + } + else { + txu_cntrl_cfm(txdesc); + txl_cntrl_env.pck_cnt = txl_cntrl_env.pck_cnt - 1; + if ((txdesc->lmac).buffer != (txl_buffer_tag *)0x0) { + (txdesc->lmac).buffer = (txl_buffer_tag *)0x0; + } + } + } + txl_frame_evt(0); + ipc_emb_txcfm_ind(1 << ((uint)access_category & 0x1f)); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_cfm_dma_int_handler(void) + +{ + ps_env.prevent_sleep = ps_env.prevent_sleep & 0xfffffffe; + _DAT_44a00020 = _DAT_44a00024 & 0x100; + return; +} + + + +void txl_cfm_dump(void) + +{ + txl_cfm_env_tag *list; + uint32_t uVar1; + tx_hd *ptVar2; + + list = &txl_cfm_env; + do { + uVar1 = co_list_cnt((co_list *)list); + if (uVar1 != 0) { + ptVar2 = ((txl_cntrl_env_tag *)list)->txlist[0].last_frame_exch; + while (ptVar2 != (tx_hd *)0x0) { + ptVar2 = (tx_hd *)ptVar2->upatterntx; + } + } + list = (txl_cfm_env_tag *)&((txl_cntrl_env_tag *)list)->txlist[0].transmitting.last; + } while ((txl_cntrl_env_tag *)list != &txl_cntrl_env); + return; +} + + + +void txl_int_fake_transfer(txdesc *txdesc,uint8_t access_category) + +{ + undefined3 in_register_0000202d; + int iVar1; + txl_buffer_tag *ptVar2; + + ptVar2 = (txdesc->lmac).buffer; + (ptVar2->tbd).upatterntx = 0xcafefade; + iVar1 = CONCAT31(in_register_0000202d,access_category) + 0x16; + ptVar2->txdesc = txdesc; + if ((&txl_buffer_env.buf_idx[0].free)[iVar1 * 2] == 0) { + *(txl_buffer_tag **)(&txl_buffer_env.buf_idx[0].free + iVar1 * 2) = ptVar2; + } + else { + *(txl_buffer_tag **)((&txl_buffer_env.buf_idx[0].free_size)[iVar1 * 2] + 0x10) = ptVar2; + } + *(txl_buffer_tag **)(&txl_buffer_env.buf_idx[0].free_size + iVar1 * 2) = ptVar2; + ptVar2->next = (txl_buffer_tag *)0x0; + return; +} + + + +void blmac_abs_timer_set(int reg_idx,uint32_t value) + +{ + if (9 < reg_idx) { + assert_err("reg_idx <= 9","module",0x26a0); + } + *(uint32_t *)((reg_idx + 0x112c004a) * 4) = value; + return; +} + + + +void txl_machdr_format(uint32_t machdrptr) + +{ + uint uVar1; + + if ((*(byte *)(machdrptr + 0x16) & 0xf) == 0) { + txl_cntrl_env.seqnbr = txl_cntrl_env.seqnbr + 1; + } + uVar1 = (uint)txl_cntrl_env.seqnbr; + *(byte *)(machdrptr + 0x16) = (byte)(uVar1 << 4) | *(byte *)(machdrptr + 0x16) & 0xf; + *(undefined *)(machdrptr + 0x17) = (char)((uVar1 << 4) >> 8); + return; +} + + + +void txl_cntrl_init(void) + +{ + txl_cntrl_env_tag *ptVar1; + undefined4 uVar2; + undefined4 *puVar3; + + txl_hwdesc_init(); + txl_buffer_init(); + txl_cfm_init(); + txl_frame_init(false); + memset(&txl_cntrl_env,0,0x58); + ptVar1 = &txl_cntrl_env; + puVar3 = (undefined4 *)&DAT_44a00080; + do { + co_list_init(&ptVar1->txlist[0].transmitting); + ptVar1->txlist[0].last_frame_exch = (tx_hd *)0x0; + uVar2 = *puVar3; + ptVar1->txlist[0].chk_state = '\0'; + puVar3 = puVar3 + 1; + ptVar1->txlist[0].bridgedmacnt = (uint16_t)uVar2; + ptVar1 = (txl_cntrl_env_tag *)(ptVar1->txlist + 1); + } while (puVar3 != (undefined4 *)0x44a00094); + txl_cntrl_env.seqnbr = 0; + return; +} + + + +_Bool txl_cntrl_tx_check(vif_info_tag *p_vif_entry) + +{ + _Bool _Var1; + + if (txl_cntrl_env.reset == false) { + _Var1 = chan_is_tx_allowed(p_vif_entry); + return _Var1; + } + return false; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_cntrl_halt_ac(uint8_t access_category) + +{ + undefined3 in_register_00002029; + + switch(CONCAT31(in_register_00002029,access_category)) { + case 0: + _DAT_44b08180 = 0x10000; + do { + } while ((_DAT_44b08188 >> 4 & 3) != 0); + _DAT_44b08184 = 0x10000; + break; + case 1: + _DAT_44b08180 = 0x20000; + do { + } while ((_DAT_44b08188 >> 8 & 3) != 0); + _DAT_44b08184 = 0x20000; + break; + case 2: + _DAT_44b08180 = 0x40000; + do { + } while ((_DAT_44b08188 >> 0xc & 3) != 0); + _DAT_44b08184 = 0x40000; + break; + case 3: + _DAT_44b08180 = 0x80000; + do { + } while ((_DAT_44b08188 >> 0x10 & 3) != 0); + _DAT_44b08184 = 0x80000; + break; + case 4: + _DAT_44b08180 = 0x8000; + do { + } while ((_DAT_44b08188 & 3) != 0); + _DAT_44b08184 = 0x8000; + break; + default: + assert_err("0","module",0x779); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_cntrl_flush_ac(uint8_t access_category,uint32_t status) + +{ + uint uVar1; + undefined3 in_register_00002029; + int iVar2; + uint uVar3; + + uVar1 = _DAT_44b0808c; + iVar2 = CONCAT31(in_register_00002029,access_category); + uVar3 = 1 << ((uint)access_category & 0x1f); + txl_cfm_flush(access_category,txl_cfm_env.cfmlist + iVar2,status); + txl_cfm_flush(access_category,&txl_cntrl_env.txlist[iVar2].transmitting,status); + txl_cntrl_env.txlist[iVar2].last_frame_exch = (tx_hd *)0x0; + txl_buffer_reset(iVar2); + _DAT_44b08088 = uVar3; + _DAT_44b0808c = ~uVar3 & uVar1; + return; +} + + +/* +Unable to decompile 'txl_cntrl_clear_bcn_ac' +Cause: Exception while decompiling 2300baee: Decompiler process died + +*/ + +/* +Unable to decompile 'txl_cntrl_clear_all_ac' +Cause: Exception while decompiling 2300bb10: Decompiler process died + +*/ + + +void txl_cntrl_inc_pck_cnt(void) + +{ + txl_cntrl_env.pck_cnt = txl_cntrl_env.pck_cnt + 1; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_payload_handle(void) + +{ + int iVar1; + + while ((_DAT_44a00024 & 0x1f) != 0) { + iVar1 = __clzsi2(_DAT_44a00024 & 0x1f); + _DAT_44a00020 = 1 << (0x1fU - iVar1 & 0x1f); + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_payload_handle_backup(void) + +{ + ushort uVar1; + uint uVar2; + uint uVar3; + txl_buffer_tag *ptVar4; + char *condition; + int line; + byte bVar5; + uint reg_idx; + tx_hd *ptVar6; + undefined *puVar7; + txdesc *txdesc; + tx_hd *ptVar8; + txl_buffer_env_tag *ptVar9; + txl_cntrl_env_tag *ptVar10; + uint uVar11; + tx_hw_desc *ptVar12; + + ptVar9 = &txl_buffer_env; + ptVar10 = &txl_cntrl_env; + uVar3 = 0; + while (ptVar4 = ptVar9->list[0].first, ptVar4 == (txl_buffer_tag *)0x0) { +LAB_2300bc06: + uVar3 = uVar3 + 1; + ptVar9 = (txl_buffer_env_tag *)&ptVar9->buf_idx[0].free_size; + ptVar10 = (txl_cntrl_env_tag *)(ptVar10->txlist + 1); + if (uVar3 == 5) { + return; + } + } + uVar2 = uVar3 & 0xff; + ptVar9->list[0].first = ptVar4->next; + uVar11 = 1 << (uVar3 & 0x1f); + do { + txdesc = ptVar4->txdesc; + if ((txdesc->host).packet_addr != 0) { + if (uVar3 == 4) { + reg_idx = (uint)(txdesc->host).vif_idx; + if ((*(byte *)((int)&ptVar4[1].length + 1) >> 5 & 1) == 0) { + bVar5 = vif_info_tab[reg_idx].u[0x2ea] & 0xfd; + } + else { + bVar5 = vif_info_tab[reg_idx].u[0x2ea] | 2; + } + vif_info_tab[reg_idx].u[0x2ea] = bVar5; + } + if ((txdesc->host).tid == -1) { + uVar1 = (txdesc->host).flags; + if ((((uVar1 & 8) != 0) && ((*(byte *)&ptVar4[1].length & 0xdc) == 0x10)) && + (*(short *)((int)&ptVar4[1].dma_desc[0].src + 2) == 0)) { + (txdesc->host).flags = uVar1 | 0x20; + rxu_cntrl_monitor_pm((mac_addr *)&ptVar4[1].lenheader); + } + txl_machdr_format((uint32_t)(ptVar4 + 1)); + } + ptVar4 = (txdesc->lmac).buffer; + ptVar12 = (txdesc->lmac).hw_desc; + if (((txdesc->host).flags & 8) == 0) { + txu_cntrl_tkip_mic_append(txdesc,(uint8_t)uVar2); + (ptVar12->thd).macctrlinfo1 = (ptVar4->buffer_control).mac_control_info; + } + else { + (ptVar12->thd).macctrlinfo2 = (ptVar12->thd).macctrlinfo2 & 0xff87ffff; + bVar5 = *(byte *)&ptVar4[1].lenheader; + (ptVar12->thd).statinfo = 0; + (ptVar12->thd).macctrlinfo1 = (uint)((bVar5 & 1) == 0) << 9; + } + *(txl_buffer_control **)&(ptVar12->thd).policyentryaddr = &ptVar4->buffer_control; + (ptVar12->thd).phyctrlinfo = (ptVar4->buffer_control).phy_control_info; + } + ptVar10->txlist[0].bridgedmacnt = ptVar10->txlist[0].bridgedmacnt + 1; + ptVar6 = ptVar10->txlist[0].last_frame_exch; + ptVar8 = &((txdesc->lmac).hw_desc)->thd; + if (ptVar6 == (tx_hd *)0x0) { + reg_idx = uVar3; + if (uVar2 == 2) { + if ((_DAT_44b08188 >> 0xc & 3) == 2) { + line = 0x23c; + condition = "blmac_tx_ac_2_state_getf() != 2"; + goto LAB_2300bdfc; + } + _DAT_44b08180 = 0x800; + puVar7 = (undefined *)0x61a80; + _DAT_44b081a4 = ptVar8; + } + else { + if (2 < uVar2) { + if (uVar2 == 3) { + if ((_DAT_44b08188 >> 0x10 & 3) != 2) { + _DAT_44b08180 = 0x1000; + _DAT_44b081a8 = ptVar8; + goto LAB_2300be5c; + } + line = 0x236; + condition = "blmac_tx_ac_3_state_getf() != 2"; + } + else { + if (uVar2 != 4) goto LAB_2300bdaa; + if ((_DAT_44b08188 & 3) != 2) { + _DAT_44b08180 = 0x100; + reg_idx = 4; + puVar7 = (undefined *)0xc350; + _DAT_44b08198 = ptVar8; + goto LAB_2300be18; + } + line = 0x22f; + condition = "blmac_tx_bcn_state_getf() != 2"; + } +LAB_2300bdfc: + assert_rec(condition,"module",line); + goto LAB_2300bd6e; + } + if (uVar2 == 1) { + if ((_DAT_44b08188 >> 8 & 3) == 2) { + line = 0x242; + condition = "blmac_tx_ac_1_state_getf() != 2"; + goto LAB_2300bdfc; + } + _DAT_44b08180 = 0x400; + puVar7 = &DAT_001e8480; + _DAT_44b081a0 = ptVar8; + } + else { +LAB_2300bdaa: + if ((_DAT_44b08188 >> 4 & 3) == 2) { + line = 0x248; + condition = "blmac_tx_ac_0_state_getf() != 2"; + goto LAB_2300bdfc; + } + _DAT_44b08180 = 0x200; + _DAT_44b0819c = ptVar8; +LAB_2300be5c: + puVar7 = (undefined *)0x30d40; + } + } +LAB_2300be18: + blmac_abs_timer_set(reg_idx,(uint32_t)(puVar7 + _DAT_44b00120)); + _DAT_44b0808c = uVar11 | _DAT_44b0808c; + _DAT_44b08088 = uVar11; + } + else { + *(tx_hd **)&ptVar6->nextfrmexseq_ptr = ptVar8; + if (uVar2 == 2) { + _DAT_44b08180 = 8; + } + else { + if (uVar2 < 3) { + if (uVar2 == 1) { + _DAT_44b08180 = 4; + } + else { +LAB_2300bd36: + _DAT_44b08180 = 2; + } + } + else { + if (uVar2 == 3) { + _DAT_44b08180 = 0x10; + } + else { + if (uVar2 != 4) goto LAB_2300bd36; + _DAT_44b08180 = 1; + } + } + } + } +LAB_2300bd6e: + ptVar4 = ptVar9->list[0].first; + ptVar10->txlist[0].last_frame_exch = ptVar8; + if (ptVar4 == (txl_buffer_tag *)0x0) goto LAB_2300bc06; + ptVar9->list[0].first = ptVar4->next; + } while( true ); +} + + +/* +Unable to decompile 'txl_cntrl_push_int' +Cause: Exception while decompiling 2300bee2: Decompiler process died + +*/ + +/* +Unable to decompile 'txl_cntrl_push_int_force' +Cause: Exception while decompiling 2300bfb4: Decompiler process died + +*/ + +/* +Unable to decompile 'txl_cntrl_push' +Cause: Exception while decompiling 2300c002: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_transmit_trigger(void) + +{ + uint reg_idx; + uint uVar1; + int iVar2; + uint32_t status; + tx_hw_desc *ptVar3; + uint32_t uVar4; + txdesc *txdesc; + co_list *list; + + if ((_DAT_44b08078 & 0x7c0) == 0) { + return; + } + iVar2 = __clzsi2(_DAT_44b08078 & 0x7c0); + reg_idx = 0x19U - iVar2 & 0xff; + if (4 < reg_idx) { + assert_err("access_category < NX_TXQ_CNT","module",0x90b); + } + _DAT_44b0807c = 1 << (reg_idx + 6 & 0x1f); + list = &txl_cntrl_env.txlist[reg_idx].transmitting; + uVar1 = ~(1 << (0x19U - iVar2 & 0x1f)); + while( true ) { + txdesc = (txdesc *)list->first; + if (txdesc == (txdesc *)0x0) { + txl_cntrl_env.txlist[reg_idx].last_frame_exch = (tx_hd *)0x0; + _DAT_44b0808c = uVar1 & _DAT_44b0808c; + return; + } + ptVar3 = (txdesc->lmac).hw_desc; + status = (ptVar3->thd).statinfo; + if (-1 < (int)status) break; + if (((txdesc->host).packet_addr != 0) && ((txdesc->lmac).buffer != (txl_buffer_tag *)0x0)) { + (txdesc->lmac).buffer = (txl_buffer_tag *)0x0; + } + ptVar3->cfm_ptr->status = status; + uVar4 = (ptVar3->thd).nextfrmexseq_ptr; + if (uVar4 == 0) { + txl_cntrl_env.txlist[reg_idx].last_frame_exch = (tx_hd *)0x0; + _DAT_44b0808c = _DAT_44b0808c & uVar1; + } + else { + if (-1 < *(int *)(uVar4 + 0x3c)) { + blmac_abs_timer_set(reg_idx,_DAT_44b00120 + TX_TIMEOUT[reg_idx]); + return; + } + } + co_list_pop_front(list); + if ((txdesc->host).packet_addr == 0) { + txl_frame_cfm(txdesc); + } + else { + txl_cfm_push(txdesc,status,(uint8_t)reg_idx); + } + blmac_abs_timer_set(reg_idx,_DAT_44b00120 + TX_TIMEOUT[reg_idx]); + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_reset(void) + +{ + uint8_t access_category; + uint16_t uVar1; + txl_cntrl_env_tag *ptVar2; + undefined4 *puVar3; + undefined4 uVar4; + uint uVar5; + co_list *list; + txl_cfm_env_tag *list_00; + + uVar1 = txl_cntrl_env.seqnbr; + ke_evt_clear(0x1f000); + do { + } while ((_DAT_44a00010 & 0xffff) != 0xffff); + txl_cntrl_env.reset = true; + list_00 = &txl_cfm_env; + list = &txl_cntrl_env.txlist[0].transmitting; + uVar5 = 0; + do { + _DAT_44a00020 = 1 << (uVar5 & 0x1f); + access_category = (uint8_t)uVar5; + txl_cfm_flush(access_category,(co_list *)list_00,0x40000000); + uVar5 = uVar5 + 1; + txl_cfm_flush(access_category,list,0x40000000); + list_00 = (txl_cfm_env_tag *)(list_00->cfmlist + 1); + list = list + 2; + } while (uVar5 != 5); + txl_hwdesc_reset(); + txl_buffer_reinit(); + txl_cfm_init(); + memset(&txl_cntrl_env,0,0x58); + ptVar2 = &txl_cntrl_env; + puVar3 = (undefined4 *)&DAT_44a00080; + txl_cntrl_env.seqnbr = uVar1; + do { + co_list_init(&ptVar2->txlist[0].transmitting); + ptVar2->txlist[0].last_frame_exch = (tx_hd *)0x0; + uVar4 = *puVar3; + ptVar2->txlist[0].chk_state = '\0'; + puVar3 = puVar3 + 1; + ptVar2->txlist[0].bridgedmacnt = (uint16_t)uVar4; + ptVar2 = (txl_cntrl_env_tag *)(ptVar2->txlist + 1); + } while (puVar3 != (undefined4 *)0x44a00094); + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void txl_cntrl_env_dump(void) + +{ + int iVar1; + uint32_t uVar2; + int *piVar3; + int iVar4; + int *piVar5; + co_list *list; + + iVar1 = 4; + do { + list = (co_list *)((int)&txl_cntrl_env.txlist[0].last_frame_exch + iVar1); + uVar2 = co_list_cnt(list); + if (uVar2 != 0) { + piVar5 = (int *)list->first; + piVar3 = piVar5; + while (piVar3 != (int *)0x0) { + piVar3 = (int *)*piVar3; + } + while (piVar5 != (int *)0x0) { + iVar4 = *(int *)(piVar5[0x1b] + 0x10); + while (iVar4 != 0) { + iVar4 = *(int *)(iVar4 + 4); + } + piVar5 = (int *)*piVar5; + } + } + iVar1 = iVar1 + 0x10; + } while (iVar1 != 0x54); + return; +} + + + +void txl_frame_init_desc(txl_frame_desc_tag *frame,txl_buffer_tag *buffer,tx_hw_desc *hwdesc, + txl_buffer_control *bufctrl) + +{ + memset(frame,0,0x2d8); + (hwdesc->thd).upatterntx = 0xcafebabe; + *(txl_buffer_tag **)&(hwdesc->thd).field_4 = buffer + 1; + (hwdesc->thd).frmlifetime = 0; + (hwdesc->thd).optlen[0] = 0; + (hwdesc->thd).optlen[1] = 0; + (hwdesc->thd).optlen[2] = 0; + *(undefined4 *)bufctrl->field_0 = 0xbadcab1e; + (frame->txdesc).lmac.hw_desc = hwdesc; + (frame->txdesc).lmac.buffer = buffer; + (frame->txdesc).umac.buf_control = bufctrl; + frame->type = '\x01'; + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void txl_frame_init(_Bool reset) + +{ + tx_hw_desc *ptVar1; + txl_frame_desc_tag *__s; + uint8_t uVar2; + byte bVar3; + undefined3 in_register_00002029; + undefined3 extraout_var; + undefined3 extraout_var_00; + txl_buffer_control *ptVar4; + uint32_t *puVar5; + int iVar6; + + co_list_init((co_list *)&txl_frame_env); + co_list_init(&txl_frame_env.desc_done); + __s = txl_frame_desc; + ptVar1 = txl_frame_hwdesc_pool; + puVar5 = txl_frame_pool; + ptVar4 = txl_frame_buf_ctrl; + iVar6 = 0; + do { + if ((CONCAT31(in_register_00002029,reset) == 0) || ((&__s->type)[1] == '\0')) { + memset(__s,0,0x2d8); + (ptVar1->thd).upatterntx = 0xcafebabe; + (ptVar1->thd).frmlifetime = 0; + (ptVar1->thd).optlen[0] = 0; + (ptVar1->thd).optlen[1] = 0; + (ptVar1->thd).optlen[2] = 0; + *(undefined4 *)ptVar4->field_0 = 0xbadcab1e; + *(uint32_t **)&(__s->txdesc).lmac.buffer = puVar5; + (__s->txdesc).umac.buf_control = ptVar4; + (__s->txdesc).lmac.hw_desc = ptVar1; + ptVar1->cfm_ptr = txl_frame_hwdesc_cfms + iVar6; + *(txl_buffer_tag **)&(ptVar1->thd).field_4 = (txl_buffer_tag *)puVar5 + 1; + __s->type = '\0'; + co_list_push_back((co_list *)&txl_frame_env,(co_list_hdr *)__s); + } + iVar6 = iVar6 + 1; + __s = __s + 1; + ptVar1 = ptVar1 + 1; + puVar5 = (uint32_t *)(((txl_buffer_tag *)puVar5)[1].buffer_control.field_0 + 0x10); + ptVar4 = ptVar4 + 1; + } while (iVar6 != 4); + txl_buffer_control_24G.field_0._0_4_ = 0xbadcab1e; + txl_buffer_control_24G.mac_control_info = 0; + txl_buffer_control_24G.phy_control_info = 0; + uVar2 = phy_get_ntx(); + txl_buffer_control_24G.field_0._4_4_ = CONCAT31(extraout_var,uVar2) << 0xe; + bVar3 = phy_get_ntx(); + txl_buffer_control_24G.field_0._8_4_ = (1 << ((uint)bVar3 + 1 & 0x1f)) + -1; + txl_buffer_control_24G.field_0._16_4_ = 0xffff0704; + txl_buffer_control_24G.field_0._20_4_ = 0x400; + txl_buffer_control_24G.field_0._12_4_ = 0; + txl_buffer_control_24G.field_0._24_4_ = 0; + txl_buffer_control_24G.field_0._28_4_ = 0; + txl_buffer_control_24G.field_0._32_4_ = 0; + txl_buffer_control_24G.field_0._40_4_ = 0; + txl_buffer_control_24G.field_0._44_4_ = 0; + txl_buffer_control_24G.field_0._48_4_ = 0; + txl_buffer_control_5G.field_0._0_4_ = 0xbadcab1e; + txl_buffer_control_5G.mac_control_info = 0; + txl_buffer_control_5G.phy_control_info = 0; + uVar2 = phy_get_ntx(); + txl_buffer_control_5G.field_0._4_4_ = CONCAT31(extraout_var_00,uVar2) << 0xe; + bVar3 = phy_get_ntx(); + txl_buffer_control_5G.field_0._8_4_ = (1 << ((uint)bVar3 + 1 & 0x1f)) + -1; + txl_buffer_control_5G.field_0._12_4_ = 0; + txl_buffer_control_5G.field_0._16_4_ = 0xffff0704; + txl_buffer_control_5G.field_0._20_4_ = iVar6; + txl_buffer_control_5G.field_0._24_4_ = 0; + txl_buffer_control_5G.field_0._28_4_ = 0; + txl_buffer_control_5G.field_0._32_4_ = 0; + txl_buffer_control_5G.field_0._40_4_ = 0; + txl_buffer_control_5G.field_0._44_4_ = 0; + txl_buffer_control_5G.field_0._48_4_ = 0; + return; +} + + + +// WARNING: Type propagation algorithm not settling + +txl_frame_desc_tag * txl_frame_get(int type,int len) + +{ + txl_frame_desc_tag *ptVar1; + tx_hw_desc *ptVar2; + uint8_t uVar3; + undefined3 extraout_var; + uint32_t uVar4; + uint32_t uVar5; + txl_buffer_control *__src; + txl_buffer_control *__dest; + txl_buffer_tag *ptVar6; + + ptVar1 = (txl_frame_desc_tag *)co_list_pop_front((co_list *)&txl_frame_env); + if (ptVar1 == (txl_frame_desc_tag *)0x0) { + tx_count = tx_count + 1; + if (tx_count == 10) { + tx_count = 0; + rx_count = 2; + uVar4 = co_list_cnt((co_list *)&txl_frame_env); + uVar5 = co_list_cnt(&txl_frame_env.desc_done); + if ((uVar5 | uVar4) == 0) { + txl_cntrl_clear_all_ac(); + } + } + } + else { + if (rx_count == 1) { + rx_count = 0; + mac_hw_reset = '\x01'; + vTaskEnterCritical(); + assert_rec("MAC HW RESET include tx and rx","tx rx",0x10b); + vTaskDelay(200); + ptVar1 = (txl_frame_desc_tag *)0x0; + vTaskExitCritical(); + } + else { + if (rx_count != 0) { + rx_count = rx_count - 1; + } + ptVar2 = (ptVar1->txdesc).lmac.hw_desc; + ptVar6 = (ptVar1->txdesc).lmac.buffer; + (ptVar2->thd).frmlen = len + 4; + (ptVar2->thd).field_5 = (ptVar2->thd).field_4 + len + -1; + __dest = &ptVar6->buffer_control; + if (type == 0) { + __src = &txl_buffer_control_24G; + } + else { + __src = __dest; + if (type == 1) { + __src = &txl_buffer_control_5G; + } + } + memcpy(__dest,__src,0x34); + uVar3 = tpc_get_vif_tx_power_vs_rate(*(uint32_t *)((ptVar6->buffer_control).field_0 + 0x14)); + *(uint *)((ptVar6->buffer_control).field_0 + 0x24) = CONCAT31(extraout_var,uVar3); + *(txl_buffer_control **)&(ptVar2->thd).policyentryaddr = __dest; + (ptVar2->thd).phyctrlinfo = 0; + (ptVar2->thd).macctrlinfo2 = 0; + (ptVar2->thd).field_3 = 0; + (ptVar1->cfm).cfm_func = (cfm_func_ptr *)0x0; + (ptVar1->cfm).env = (void *)0x0; + } + } + return ptVar1; +} + + + +_Bool txl_frame_push(txl_frame_desc_tag *frame,uint8_t ac) + +{ + byte bVar1; + tx_hw_desc *ptVar2; + _Bool _Var3; + + ptVar2 = (frame->txdesc).lmac.hw_desc; + if (((ptVar2->thd).field_4 & 1) != 0) { + assert_err("(thd->datastartptr & 0x01) == 0","module",0x182); + } + (ptVar2->thd).nextfrmexseq_ptr = 0; + (ptVar2->thd).nextmpdudesc_ptr = 0; + (ptVar2->thd).macctrlinfo2 = (ptVar2->thd).macctrlinfo2 & 0xff87ffff; + bVar1 = *(byte *)((ptVar2->thd).field_4 + 4); + (ptVar2->thd).statinfo = 0; + (ptVar2->thd).macctrlinfo1 = (uint)((bVar1 & 1) == 0) << 9; + _Var3 = txl_cntrl_push_int((txdesc *)frame,ac); + return _Var3; +} + + + +_Bool txl_frame_push_force(txl_frame_desc_tag *frame,uint8_t ac) + +{ + byte bVar1; + tx_hw_desc *ptVar2; + _Bool _Var3; + + ptVar2 = (frame->txdesc).lmac.hw_desc; + if (((ptVar2->thd).field_4 & 1) != 0) { + assert_err("(thd->datastartptr & 0x01) == 0","module",0x1ad); + } + (ptVar2->thd).nextfrmexseq_ptr = 0; + (ptVar2->thd).nextmpdudesc_ptr = 0; + (ptVar2->thd).macctrlinfo2 = (ptVar2->thd).macctrlinfo2 & 0xff87ffff; + bVar1 = *(byte *)((ptVar2->thd).field_4 + 4); + (ptVar2->thd).statinfo = 0; + (ptVar2->thd).macctrlinfo1 = (uint)((bVar1 & 1) == 0) << 9; + _Var3 = txl_cntrl_push_int_force((txdesc *)frame,ac); + return _Var3; +} + + + +void txl_frame_cfm(txdesc *txdesc) + +{ + co_list_push_back(&txl_frame_env.desc_done,(co_list_hdr *)txdesc); + ke_evt_set(0x20000); + return; +} + + + +void txl_frame_release(txdesc *txdesc,_Bool postponed) + +{ + co_list_hdr *UNRECOVERED_JUMPTABLE; + undefined3 in_register_0000202d; + + if (*(char *)&txdesc[1].host.packet_addr == '\0') { + co_list_push_back((co_list *)&txl_frame_env,(co_list_hdr *)txdesc); + } + if ((CONCAT31(in_register_0000202d,postponed) != 0) && + (UNRECOVERED_JUMPTABLE = txdesc[1].list_hdr.next, UNRECOVERED_JUMPTABLE != (co_list_hdr *)0x0)) + { + // WARNING: Could not recover jumptable at 0x2300c7d4. Too many branches + // WARNING: Treating indirect jump as call + (*(code *)UNRECOVERED_JUMPTABLE)(txdesc[1].host.pbuf_addr,0); + return; + } + return; +} + + +/* +Unable to decompile 'txl_frame_evt' +Cause: Exception while decompiling 2300c7e0: Decompiler process died + +*/ + + +uint8_t txl_frame_send_null_frame(uint8_t sta_idx,cfm_func_ptr *cfm,void *env) + +{ + byte bVar1; + uint8_t uVar2; + txl_buffer_tag *ptVar3; + undefined3 in_register_00002029; + int iVar4; + txl_frame_desc_tag *frame; + uint uVar5; + int iVar6; + char acStack56 [4]; + phy_channel_info phy_info; + + iVar4 = CONCAT31(in_register_00002029,sta_idx); + bVar1 = sta_info_tab[iVar4].inst_nbr; + phy_get_channel((phy_channel_info *)acStack56,'\0'); + frame = txl_frame_get((uint)(acStack56[0] != '\0'),0x18); + if (frame != (txl_frame_desc_tag *)0x0) { + tpc_update_frame_tx_power(vif_info_tab + bVar1,frame); + ptVar3 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar3[1].length = 0x48; + *(undefined *)((int)&ptVar3[1].length + 1) = 1; + *(undefined *)((int)&ptVar3[1].length + 2) = 0; + *(undefined *)((int)&ptVar3[1].length + 3) = 0; + memcpy(&ptVar3[1].lenheader,&sta_info_tab[iVar4].mac_addr,6); + memcpy((void *)((int)&ptVar3[1].lenpad + 2),&vif_info_tab[bVar1].mac_addr,6); + memcpy(&ptVar3[1].next,&sta_info_tab[iVar4].mac_addr,6); + uVar5 = (uint)txl_cntrl_env.seqnbr; + txl_cntrl_env.seqnbr = (uint16_t)((uVar5 + 1) * 0x10000 >> 0x10); + iVar6 = (uVar5 + 1) * 0x100000; + *(undefined *)((int)&ptVar3[1].txdesc + 2) = (char)((uint)iVar6 >> 0x10); + *(undefined *)((int)&ptVar3[1].txdesc + 3) = (char)((uint)iVar6 >> 0x18); + (frame->cfm).cfm_func = cfm; + (frame->cfm).env = env; + uVar2 = sta_info_tab[iVar4].inst_nbr; + (frame->txdesc).host.staid = sta_idx; + (frame->txdesc).host.vif_idx = uVar2; + txl_frame_push(frame,'\x03'); + } + return (uint8_t)(frame == (txl_frame_desc_tag *)0x0); +} + + + +// WARNING: Variable defined which should be unmapped: phy_info + +uint8_t txl_frame_send_qosnull_frame(uint8_t sta_idx,uint16_t qos,cfm_func_ptr *cfm,void *env) + +{ + txl_buffer_tag *ptVar1; + uint8_t uVar2; + undefined3 in_register_00002029; + int iVar3; + txl_frame_desc_tag *frame; + mac_addr *__src; + uint uVar4; + char acStack56 [4]; + phy_channel_info phy_info; + + iVar3 = CONCAT31(in_register_00002029,sta_idx); + uVar4 = (uint)sta_info_tab[iVar3].inst_nbr; + phy_get_channel((phy_channel_info *)acStack56,'\0'); + frame = txl_frame_get((uint)(acStack56[0] != '\0'),0x1a); + if (frame == (txl_frame_desc_tag *)0x0) { + uVar2 = '\x01'; + } + else { + tpc_update_frame_tx_power(vif_info_tab + uVar4,frame); + ptVar1 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar1[1].length = 200; + *(undefined *)((int)&ptVar1[1].length + 1) = 0; + *(undefined *)((int)&ptVar1[1].length + 2) = 0; + *(undefined *)((int)&ptVar1[1].length + 3) = 0; + memcpy(&ptVar1[1].lenheader,&sta_info_tab[iVar3].mac_addr,6); + __src = &vif_info_tab[uVar4].mac_addr; + memcpy((void *)((int)&ptVar1[1].lenpad + 2),__src,6); + uVar2 = vif_info_tab[uVar4].type; + *(undefined *)&ptVar1[1].length = 200; + if (uVar2 == '\0') { + *(undefined *)((int)&ptVar1[1].length + 1) = 1; + __src = &sta_info_tab[iVar3].mac_addr; + } + else { + *(undefined *)((int)&ptVar1[1].length + 1) = 2; + } + memcpy(&ptVar1[1].next,__src,6); + *(char *)&ptVar1[1].dma_desc[0].src = (char)qos; + *(undefined *)((int)&ptVar1[1].txdesc + 2) = 0; + *(undefined *)((int)&ptVar1[1].txdesc + 3) = 0; + *(undefined *)((int)&ptVar1[1].dma_desc[0].src + 1) = (char)(qos >> 8); + (frame->cfm).cfm_func = cfm; + (frame->cfm).env = env; + uVar2 = sta_info_tab[iVar3].inst_nbr; + (frame->txdesc).host.staid = sta_idx; + (frame->txdesc).host.vif_idx = uVar2; + txl_frame_push(frame,'\x03'); + uVar2 = '\0'; + } + return uVar2; +} + + + +uint8_t txl_frame_send_eapol_frame + (uint8_t sta_idx,cfm_func_ptr *cfm,void *cfm_env,uint8_t *pBuf,uint32_t pBuf_len) + +{ + byte bVar1; + uint8_t uVar2; + ushort uVar3; + undefined2 uVar4; + txl_buffer_tag *ptVar5; + undefined3 in_register_00002029; + txl_frame_desc_tag *frame; + key_info_tag *pkVar6; + uint32_t uVar7; + undefined *puVar8; + int iVar9; + tx_hw_desc *ptVar10; + uint16_t uVar11; + uint uVar12; + dma_desc *pdVar13; + uint uVar14; + dma_desc *unaff_s8; + mac_addr *pmVar15; + mac_addr *pmVar16; + uint uVar17; + int iVar18; + char acStack88 [4]; + phy_channel_info phy_info; + mic_calc mic; + + iVar18 = CONCAT31(in_register_00002029,sta_idx); + bVar1 = sta_info_tab[iVar18].inst_nbr; + uVar17 = (uint)bVar1; + phy_get_channel((phy_channel_info *)acStack88,'\0'); + frame = txl_frame_get((uint)(acStack88[0] != '\0'),0x100); + if (frame == (txl_frame_desc_tag *)0x0) { + return '\0'; + } + (frame->txdesc).host.vif_idx = bVar1; + (frame->txdesc).host.staid = sta_idx; + (frame->txdesc).host.tid = '\0'; + uVar3 = sta_info_tab[iVar18].seq_nbr[0]; + sta_info_tab[iVar18].seq_nbr[0] = (ushort)(((uint)uVar3 + 1) * 0x100000 >> 0x14); + (frame->txdesc).host.ethertype = 0x8e88; + (frame->txdesc).host.sn = uVar3; + pmVar15 = &sta_info_tab[iVar18].mac_addr; + (frame->txdesc).host.eth_dest_addr.array[0] = pmVar15->array[0]; + (frame->txdesc).host.eth_dest_addr.array[1] = sta_info_tab[iVar18].mac_addr.array[1]; + (frame->txdesc).host.eth_dest_addr.array[2] = sta_info_tab[iVar18].mac_addr.array[2]; + pmVar16 = &vif_info_tab[uVar17].mac_addr; + (frame->txdesc).host.eth_src_addr.array[0] = pmVar16->array[0]; + (frame->txdesc).host.eth_src_addr.array[1] = vif_info_tab[uVar17].mac_addr.array[1]; + (frame->txdesc).host.eth_src_addr.array[2] = vif_info_tab[uVar17].mac_addr.array[2]; + tpc_update_frame_tx_power(vif_info_tab + uVar17,frame); + ptVar5 = (frame->txdesc).lmac.buffer; + if ((vif_info_tab[uVar17].bss_info.valid_flags & 1) == 0) { + *(undefined *)&ptVar5[1].length = 8; + uVar14 = (uint)txl_cntrl_env.seqnbr; + *(undefined *)((int)&ptVar5[1].length + 1) = 0; + pdVar13 = ptVar5[1].dma_desc; + txl_cntrl_env.seqnbr = (uint16_t)((uVar14 + 1) * 0x10000 >> 0x10); + iVar9 = (uVar14 + 1) * 0x100000; + *(undefined *)((int)&ptVar5[1].txdesc + 2) = (char)((uint)iVar9 >> 0x10); + *(undefined *)((int)&ptVar5[1].txdesc + 3) = (char)((uint)iVar9 >> 0x18); + uVar14 = pBuf_len + 0x20; + } + else { + *(undefined *)&ptVar5[1].length = 0x88; + *(undefined *)((int)&ptVar5[1].length + 1) = 0; + pdVar13 = (dma_desc *)((int)&ptVar5[1].dma_desc[0].src + 2); + uVar14 = pBuf_len + 0x22; + iVar9 = (uint)(frame->txdesc).host.sn << 0x14; + *(undefined *)((int)&ptVar5[1].txdesc + 2) = (char)((uint)iVar9 >> 0x10); + *(undefined *)((int)&ptVar5[1].txdesc + 3) = (char)((uint)iVar9 >> 0x18); + uVar2 = (frame->txdesc).host.tid; + *(undefined *)((int)&ptVar5[1].dma_desc[0].src + 1) = 0; + *(uint8_t *)&ptVar5[1].dma_desc[0].src = uVar2; + } + if (0x100 < uVar14) { + assert_err("length<=NX_TXFRAME_LEN","module",0x591); + } + uVar4 = *(undefined2 *)&ptVar5[1].length; + bVar1 = 1; + if (vif_info_tab[uVar17].type == '\x02') { + bVar1 = 2; + } + *(char *)&ptVar5[1].length = (char)uVar4; + *(byte *)((int)&ptVar5[1].length + 1) = (byte)((ushort)uVar4 >> 8) | bVar1; + *(undefined *)((int)&ptVar5[1].length + 2) = 0; + *(undefined *)((int)&ptVar5[1].length + 3) = 0; + *(uint16_t *)&ptVar5[1].lenheader = pmVar15->array[0]; + *(uint16_t *)((int)&ptVar5[1].lenheader + 2) = sta_info_tab[iVar18].mac_addr.array[1]; + *(uint16_t *)&ptVar5[1].lenpad = sta_info_tab[iVar18].mac_addr.array[2]; + *(uint16_t *)((int)&ptVar5[1].lenpad + 2) = pmVar16->array[0]; + *(uint16_t *)&ptVar5[1].flags = vif_info_tab[uVar17].mac_addr.array[1]; + *(uint16_t *)((int)&ptVar5[1].flags + 2) = vif_info_tab[uVar17].mac_addr.array[2]; + if (vif_info_tab[uVar17].type == '\x02') { + *(uint16_t *)&ptVar5[1].next = pmVar16->array[0]; + *(uint16_t *)((int)&ptVar5[1].next + 2) = vif_info_tab[uVar17].mac_addr.array[1]; + uVar11 = vif_info_tab[uVar17].mac_addr.array[2]; + } + else { + *(uint16_t *)&ptVar5[1].next = pmVar15->array[0]; + *(uint16_t *)((int)&ptVar5[1].next + 2) = sta_info_tab[iVar18].mac_addr.array[1]; + uVar11 = sta_info_tab[iVar18].mac_addr.array[2]; + } + *(uint16_t *)&ptVar5[1].txdesc = uVar11; + iVar18 = 0; + if ((vif_info_tab[(frame->txdesc).host.vif_idx].type != '\0') || + (uVar17 = (uint)(frame->txdesc).host.staid, sta_info_tab[uVar17].ctrl_port_state != '\x02')) + goto LAB_2300cd74; + pkVar6 = *sta_info_tab[uVar17].sta_sec_info.cur_key; + uVar2 = pkVar6->cipher; + if (uVar2 == '\x01') { + uVar17 = *(uint *)&pkVar6->tx_pn + 1; + *(int *)((int)&pkVar6->tx_pn + 4) = + (uint)(uVar17 < *(uint *)&pkVar6->tx_pn) + *(int *)((int)&pkVar6->tx_pn + 4); + *(uint *)&pkVar6->tx_pn = uVar17; + memcpy((frame->txdesc).host.pn,&pkVar6->tx_pn,6); + iVar9 = 0xc; +LAB_2300cecc: + iVar18 = 8; + } + else { + if (uVar2 == '\0') { +LAB_2300ccae: + uVar17 = *(uint *)&pkVar6->tx_pn + 1; + *(int *)((int)&pkVar6->tx_pn + 4) = + (uint)(uVar17 < *(uint *)&pkVar6->tx_pn) + *(int *)((int)&pkVar6->tx_pn + 4); + *(uint *)&pkVar6->tx_pn = uVar17; + memcpy((frame->txdesc).host.pn,&pkVar6->tx_pn,4); + iVar9 = 4; + iVar18 = 4; + } + else { + if (uVar2 == '\x02') { + uVar17 = *(uint *)&pkVar6->tx_pn + 1; + *(int *)((int)&pkVar6->tx_pn + 4) = + (uint)(uVar17 < *(uint *)&pkVar6->tx_pn) + *(int *)((int)&pkVar6->tx_pn + 4); + *(uint *)&pkVar6->tx_pn = uVar17; + memcpy((frame->txdesc).host.pn,&pkVar6->tx_pn,6); + iVar9 = 8; + goto LAB_2300cecc; + } + if (uVar2 == '\x03') goto LAB_2300ccae; + iVar9 = 0; + iVar18 = 0; + } + } + iVar18 = iVar18 + iVar9; + if (iVar18 == 0) goto LAB_2300cd74; + uVar3 = *(ushort *)&ptVar5[1].length; + uVar14 = uVar14 + iVar18; + *(char *)&ptVar5[1].length = (char)uVar3; + *(byte *)((int)&ptVar5[1].length + 1) = (byte)((uint)uVar3 >> 8) | 0x40; + uVar17 = (uint)vif_info_tab[(frame->txdesc).host.vif_idx].type; + if (vif_info_tab[(frame->txdesc).host.vif_idx].type == 0) { + uVar12 = (uint)(frame->txdesc).host.staid; + if (sta_info_tab[uVar12].ctrl_port_state == '\x02') { + pkVar6 = *sta_info_tab[uVar12].sta_sec_info.cur_key; + uVar7 = (((frame->txdesc).lmac.hw_desc)->thd).policyentryaddr; + uVar2 = pkVar6->cipher; + if (uVar2 == '\x01') { + uVar3 = (frame->txdesc).host.pn[0]; + *(ushort *)&pdVar13->src = uVar3 & 0x7f00 | 0x2000 | uVar3 >> 8; + uVar3 = (ushort)*(byte *)(frame->txdesc).host.pn | (ushort)pkVar6->key_idx << 0xe; +LAB_2300cf24: + *(ushort *)((int)&pdVar13->src + 2) = uVar3 | 0x2000; + uVar17 = 8; + *(uint16_t *)&pdVar13->dest = (frame->txdesc).host.pn[1]; + *(uint16_t *)((int)&pdVar13->dest + 2) = (frame->txdesc).host.pn[2]; + } + else { + if (uVar2 == '\0') { +LAB_2300cd42: + *(uint16_t *)&pdVar13->src = (frame->txdesc).host.pn[0]; + *(ushort *)((int)&pdVar13->src + 2) = + (ushort)pkVar6->key_idx << 0xe | (frame->txdesc).host.pn[1]; + uVar17 = 4; + } + else { + if (uVar2 == '\x02') { + *(uint16_t *)&pdVar13->src = (frame->txdesc).host.pn[0]; + uVar3 = (ushort)pkVar6->key_idx << 0xe; + goto LAB_2300cf24; + } + if (uVar2 == '\x03') goto LAB_2300cd42; + } + } + *(uint *)(uVar7 + 0xc) = *(uint *)(uVar7 + 0xc) & 0xffc00 | (uint)pkVar6->hw_key_idx; + } + } + else { + uVar17 = 0; + } + pdVar13 = (dma_desc *)((int)&pdVar13->src + uVar17); + unaff_s8 = pdVar13; +LAB_2300cd74: + *(undefined2 *)&pdVar13->src = 0xaaaa; + *(undefined2 *)((int)&pdVar13->src + 2) = 3; + *(undefined2 *)&pdVar13->dest = 0; + *(uint16_t *)((int)&pdVar13->dest + 2) = (frame->txdesc).host.ethertype; + memcpy(&pdVar13->length,pBuf,pBuf_len); + if ((iVar18 != 0) && + (pkVar6 = *sta_info_tab[(frame->txdesc).host.staid].sta_sec_info.cur_key, + pkVar6->cipher == '\x01')) { + me_mic_init((mic_calc *)&phy_info.info2,(uint32_t *)pkVar6->u, + &(frame->txdesc).host.eth_dest_addr,&(frame->txdesc).host.eth_src_addr, + (frame->txdesc).host.tid); + me_mic_calc((mic_calc *)&phy_info.info2,(uint32_t)unaff_s8,pBuf_len + 8); + me_mic_end((mic_calc *)&phy_info.info2); + iVar18 = 0; + do { + puVar8 = (undefined *)((int)&phy_info.info2 + iVar18); + iVar9 = iVar18 + pBuf_len + 8; + iVar18 = iVar18 + 1; + *(undefined *)((int)&unaff_s8->length + iVar9 + -8) = *puVar8; + } while (iVar18 != 8); + } + ptVar10 = (frame->txdesc).lmac.hw_desc; + (ptVar10->thd).field_5 = (ptVar10->thd).field_4 + -1 + uVar14; + (ptVar10->thd).frmlen = uVar14 + 4; + if (cfm != (cfm_func_ptr *)0x0) { + (frame->cfm).cfm_func = cfm; + (frame->cfm).env = cfm_env; + } + txl_frame_push(frame,"\x01"[(frame->txdesc).host.tid]); + return '\0'; +} + + + +void txl_frame_dump(void) + +{ + uint32_t uVar1; + co_list_hdr cVar2; + co_list_hdr cVar3; + + uVar1 = co_list_cnt((co_list *)&txl_frame_env); + cVar2 = (co_list_hdr)txl_frame_env.desc_free.first; + if (uVar1 != 0) { + while (cVar3 = (co_list_hdr)txl_frame_env.desc_done.first, cVar2 != (co_list_hdr)0x0) { + cVar2 = *(co_list_hdr *)cVar2; + } + while (cVar3 != (co_list_hdr)0x0) { + cVar3 = *(co_list_hdr *)cVar3; + } + } + return; +} + + + +void txl_hwdesc_init(void) + +{ + return; +} + + + +void txl_hwdesc_reset(void) + +{ + return; +} + + + +void vif_mgmt_bcn_to_evt(void *env) + +{ + if (*(int *)((int)env + 0x40) != 0) { + chan_bcn_to_evt((vif_info_tag *)env); + return; + } + return; +} + + + +void vif_mgmt_init(void) + +{ + memset(&vif_mgmt_env,0,0x14); + co_list_init((co_list *)&vif_mgmt_env); + co_list_init(&vif_mgmt_env.used_list); + memset(vif_info_tab,0,0x5d8); + vif_info_tab[0].type = '\x04'; + vif_info_tab[0].tx_power = '\x7f'; + vif_info_tab[0].user_tx_power = '\x7f'; + vif_info_tab[0].tmr_bcn_to.cb = vif_mgmt_bcn_to_evt; + vif_info_tab[0].tmr_bcn_to.env = vif_info_tab; + co_list_push_back((co_list *)&vif_mgmt_env,(co_list_hdr *)vif_info_tab); + memset(vif_info_tab + 1,0,0x5d8); + vif_info_tab[1].type = '\x04'; + vif_info_tab[1].tx_power = '\x7f'; + vif_info_tab[1].user_tx_power = '\x7f'; + vif_info_tab[1].tmr_bcn_to.cb = vif_mgmt_bcn_to_evt; + vif_info_tab[1].tmr_bcn_to.env = vif_info_tab + 1; + co_list_push_back((co_list *)&vif_mgmt_env,(co_list_hdr *)(vif_info_tab + 1)); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t vif_mgmt_register(mac_addr *mac_addr,uint8_t vif_type,_Bool p2p,uint8_t *vif_idx) + +{ + uint8_t uVar1; + vif_info_tag *vif_entry; + undefined3 in_register_0000202d; + + if (vif_mgmt_env.free_list.first == (co_list_hdr *)0x0) { + uVar1 = '\x01'; + } + else { + if (vif_mgmt_env.used_list.first == (co_list_hdr *)0x0) { + mm_hw_info_set(mac_addr); + } + else { + if (*(int *)mac_addr->array != _DAT_44b00010) { + return '\x01'; + } + if (((mac_addr->array[2] ^ _DAT_44b00014) & ~_DAT_44b0001c) != 0) { + return '\x01'; + } + mm_env.rx_filter_lmac_enable = mm_env.rx_filter_lmac_enable | 0x10; + _DAT_44b00060 = mm_env.rx_filter_lmac_enable | mm_env.rx_filter_umac; + } + vif_entry = (vif_info_tag *)co_list_pop_front((co_list *)&vif_mgmt_env); + vif_entry->type = vif_type; + memcpy(&vif_entry->mac_addr,mac_addr,6); + uVar1 = (char)((int)(vif_entry[-0xb4ba3].u + 0xb4) >> 3) * 's'; + vif_entry->txq_params[1] = 0xa43; + vif_entry->txq_params[2] = 0x5e432; + vif_entry->index = uVar1; + vif_entry->txq_params[0] = 0xa47; + vif_entry->txq_params[3] = 0x2f322; + vif_entry->chan_ctxt = (chan_ctxt_tag *)0x0; + (vif_entry->tbtt_switch).vif_index = uVar1; + if (CONCAT31(in_register_0000202d,vif_type) == 0) { + *(vif_info_tag **)&(vif_entry->tbtt_timer).env = vif_entry; + vif_entry->u[0x1d] = 0; + vif_mgmt_env.vif_sta_cnt = vif_mgmt_env.vif_sta_cnt + '\x01'; + (vif_entry->tbtt_timer).cb = mm_sta_tbtt; + vif_entry->u[4] = 0xff; + vif_entry->u[0x1e] = 0; + } + else { + if (CONCAT31(in_register_0000202d,vif_type) == 2) { + if (vif_mgmt_env.vif_ap_cnt == '\0') { + mm_hw_ap_info_set(); + } + vif_mgmt_env.vif_ap_cnt = vif_mgmt_env.vif_ap_cnt + '\x01'; + mm_bcn_init_vif(vif_entry); + } + } + td_start(vif_entry->index); + *vif_idx = vif_entry->index; + co_list_push_back(&vif_mgmt_env.used_list,(co_list_hdr *)vif_entry); + uVar1 = '\0'; + } + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void vif_mgmt_unregister(uint8_t vif_idx) + +{ + vif_info_tag *__s; + undefined3 in_register_00002029; + int iVar1; + + iVar1 = CONCAT31(in_register_00002029,vif_idx); + __s = vif_info_tab + iVar1; + co_list_extract(&vif_mgmt_env.used_list,(co_list_hdr *)__s); + if (vif_info_tab[iVar1].type == '\0') { + vif_mgmt_env.vif_sta_cnt = vif_mgmt_env.vif_sta_cnt + -1; + } + else { + if (vif_info_tab[iVar1].type == '\x02') { + vif_mgmt_env.vif_ap_cnt = vif_mgmt_env.vif_ap_cnt + -1; + if (vif_mgmt_env.vif_ap_cnt == '\0') { + mm_hw_ap_info_reset(); + } + } + } + if ((uint)vif_mgmt_env.vif_ap_cnt + (uint)vif_mgmt_env.vif_sta_cnt == 1) { + mm_env.rx_filter_lmac_enable = mm_env.rx_filter_lmac_enable & 0xffffffef; + _DAT_44b00060 = mm_env.rx_filter_lmac_enable | mm_env.rx_filter_umac; + _DAT_44b00020 = vif_mgmt_env.used_list.first[0xe].next; + _DAT_44b00024 = (uint)*(ushort *)&vif_mgmt_env.used_list.first[0xf].next; + } + if (vif_info_tab[iVar1].type == '\x02') { + txl_cntrl_clear_bcn_ac(); + } + mm_timer_clear(&vif_info_tab[iVar1].tbtt_timer); + mm_timer_clear(&vif_info_tab[iVar1].tmr_bcn_to); + td_reset(vif_info_tab[iVar1].index); + memset(__s,0,0x5d8); + vif_info_tab[iVar1].type = '\x04'; + vif_info_tab[iVar1].tx_power = '\x7f'; + vif_info_tab[iVar1].user_tx_power = '\x7f'; + vif_info_tab[iVar1].tmr_bcn_to.cb = vif_mgmt_bcn_to_evt; + *(vif_info_tag **)&vif_info_tab[iVar1].tmr_bcn_to.env = __s; + co_list_push_back((co_list *)&vif_mgmt_env,(co_list_hdr *)__s); + return; +} + + + +void vif_mgmt_add_key(mm_key_add_req *param,uint8_t hw_key_idx) + +{ + uint8_t uVar1; + uint uVar2; + uint uVar3; + + uVar3 = (uint)param->inst_nbr; + uVar2 = (uint)param->key_idx; + vif_info_tab[uVar3].key_info[uVar2].hw_key_idx = hw_key_idx; + vif_info_tab[uVar3].key_info[uVar2].cipher = param->cipher_suite; + vif_info_tab[uVar3].key_info[uVar2].key_idx = param->key_idx; + memset(vif_info_tab[uVar3].key_info + uVar2,0,0x48); + uVar1 = vif_info_tab[uVar3].key_info[uVar2].cipher; + if (uVar1 == '\x01') { + *(undefined4 *)&vif_info_tab[uVar3].key_info[uVar2].tx_pn = 0; + *(undefined4 *)((int)&vif_info_tab[uVar3].key_info[uVar2].tx_pn + 4) = 0; + *(uint32_t *)vif_info_tab[uVar3].key_info[uVar2].u = (param->key).array[4]; + *(uint32_t *)(vif_info_tab[uVar3].key_info[uVar2].u + 4) = (param->key).array[5]; + *(uint32_t *)(vif_info_tab[uVar3].key_info[uVar2].u + 8) = (param->key).array[6]; + *(uint32_t *)(vif_info_tab[uVar3].key_info[uVar2].u + 0xc) = (param->key).array[7]; + } + else { + if ((uVar1 == '\0') || (uVar1 == '\x03')) { + next = next * 0x41c64e6d + 0x3039; + *(ulong *)&vif_info_tab[uVar3].key_info[uVar2].tx_pn = next >> 0x10; + *(undefined4 *)((int)&vif_info_tab[uVar3].key_info[uVar2].tx_pn + 4) = 0; + } + else { + *(undefined4 *)&vif_info_tab[uVar3].key_info[uVar2].tx_pn = 0; + *(undefined4 *)((int)&vif_info_tab[uVar3].key_info[uVar2].tx_pn + 4) = 0; + } + } + vif_info_tab[uVar3].key_info[uVar2].valid = true; + vif_info_tab[uVar3].default_key = vif_info_tab[uVar3].key_info + uVar2; + return; +} + + + +void vif_mgmt_del_key(vif_info_tag *vif,uint8_t keyid) + +{ + undefined3 in_register_0000202d; + _Bool *p_Var1; + int iVar2; + + vif->key_info[CONCAT31(in_register_0000202d,keyid)].valid = false; + if (vif->default_key == vif->key_info + CONCAT31(in_register_0000202d,keyid)) { + vif->default_key = (key_info_tag *)0x0; + p_Var1 = &vif->key_info[0].valid; + iVar2 = 0; + do { + if (*p_Var1 != false) { + vif->default_key = vif->key_info + iVar2; + return; + } + iVar2 = iVar2 + 1; + p_Var1 = p_Var1 + 0x68; + } while (iVar2 != 4); + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void vif_mgmt_send_postponed_frame(vif_info_tag *p_vif_entry) + +{ + sta_info_tag *p_sta_entry; + + p_sta_entry = (sta_info_tag *)(p_vif_entry->sta_list).first; + while (p_sta_entry != (sta_info_tag *)0x0) { + sta_mgmt_send_postponed_frame(p_vif_entry,p_sta_entry,0); + p_sta_entry = *(sta_info_tag **)&p_sta_entry->list_hdr; + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void vif_mgmt_reset(void) + +{ + vif_info_tag *p_vif_entry; + + p_vif_entry = (vif_info_tag *)vif_mgmt_env.used_list.first; + while (p_vif_entry != (vif_info_tag *)0x0) { + vif_mgmt_send_postponed_frame(p_vif_entry); + p_vif_entry = *(vif_info_tag **)&p_vif_entry->list_hdr; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void vif_mgmt_bcn_to_prog(vif_info_tag *p_vif_entry) + +{ + mm_timer_set(&p_vif_entry->tmr_bcn_to,_DAT_44b00120 + 10000); + return; +} + + + +void vif_mgmt_bcn_recv(vif_info_tag *p_vif_entry) + +{ + if (((ps_env.ps_on != false) && ((ps_env.prevent_sleep & 8) == 0)) && + (p_vif_entry->prevent_sleep == 0)) { + mm_timer_clear(&p_vif_entry->tmr_bcn_to); + vif_mgmt_bcn_to_evt(p_vif_entry); + return; + } + return; +} + + +/* +Unable to decompile 'vif_mgmt_set_ap_bcn_int' +Cause: Exception while decompiling 2300d4ec: Decompiler process died + +*/ + + +// WARNING: Variable defined which should be unmapped: chan_idx +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void vif_mgmt_switch_channel(vif_info_tag *p_vif_entry) + +{ + byte bVar1; + uint16_t freq; + uint8_t uVar2; + void *pvVar3; + scan_chan_tag *psVar4; + undefined3 extraout_var; + uint8_t chan_idx_00; + uint8_t local_11 [4]; + uint8_t chan_idx; + + pvVar3 = ke_msg_alloc(0x58,0xd,0,3); + local_11[0] = -1; + chan_ctxt_unlink(p_vif_entry->index); + freq = (p_vif_entry->csa_channel).prim20_freq; + chan_idx_00 = (uint8_t)freq; + psVar4 = me_freq_to_chan_ptr((p_vif_entry->csa_channel).band,freq); + freq = (p_vif_entry->csa_channel).center1_freq; + (p_vif_entry->bss_info).chan = psVar4; + (p_vif_entry->bss_info).center_freq1 = freq; + (p_vif_entry->bss_info).center_freq2 = (p_vif_entry->csa_channel).center2_freq; + uVar2 = (p_vif_entry->csa_channel).type; + (p_vif_entry->bss_info).phy_bw = uVar2; + if (uVar2 == '\x04') { + uVar2 = '\x03'; + } + (p_vif_entry->bss_info).bw = uVar2; + if (psVar4 == (scan_chan_tag *)0x0) { + ebreak(); + } + else { + (p_vif_entry->csa_channel).tx_power = psVar4->tx_power; + uVar2 = chan_ctxt_add(&p_vif_entry->csa_channel,local_11); + psVar4 = (scan_chan_tag *)CONCAT31(extraout_var,uVar2); + *(uint8_t *)((int)pvVar3 + 1) = uVar2; + *(uint8_t *)((int)pvVar3 + 2) = local_11[0]; + chan_idx_00 = local_11[0]; + if (p_vif_entry->type != '\0') { + if ((p_vif_entry->type == '\x02') && + (p_vif_entry->u[0x2eb] = 0, psVar4 == (scan_chan_tag *)0x0)) { + chan_ctxt_link(p_vif_entry->index,local_11[0]); + mm_bcn_env.update_ongoing = true; + } + goto LAB_2300d66a; + } + } + p_vif_entry->u[0x1d] = 0; + if (psVar4 == (scan_chan_tag *)0x0) { + bVar1 = p_vif_entry->u[4]; + chan_ctxt_link(p_vif_entry->index,chan_idx_00); + mm_timer_clear(&p_vif_entry->tmr_bcn_to); + mm_timer_set(&p_vif_entry->tbtt_timer,_DAT_44b00120 + sta_info_tab[bVar1].bcn_int); + p_vif_entry->u[0x18] = 0; + p_vif_entry->u[0x1e] = 1; + } + else { + mm_send_connection_loss_ind(p_vif_entry); + } +LAB_2300d66a: + ke_msg_send(pvVar3); + return; +} + + + +vif_info_tag * vif_mgmt_get_first_ap_inf(void) + +{ + co_list_hdr cVar1; + co_list_hdr cVar2; + + cVar1 = (co_list_hdr)vif_mgmt_env.used_list.first; + cVar2 = (co_list_hdr)0x0; + if (vif_mgmt_env.vif_ap_cnt != '\0') { + while ((cVar2 = cVar1, cVar1 != (co_list_hdr)0x0 && (*(char *)((int)cVar1 + 0x56) != '\x02'))) { + cVar1 = *(co_list_hdr *)cVar1; + } + } + return (vif_info_tag *)cVar2; +} + + + +void me_init(void) + +{ + memset(&me_env,0,0x134); + ke_state_set(5,0); + scanu_init(); + apm_init(); + sm_init(); + bam_init(); + return; +} + + + +scan_chan_tag * me_freq_to_chan_ptr(uint8_t band,uint16_t freq) + +{ + int iVar1; + byte bVar2; + ushort *puVar3; + undefined3 in_register_00002029; + scan_chan_tag *psVar4; + undefined2 in_register_0000202e; + scan_chan_tag *psVar5; + scan_chan_tag *psVar6; + + if (CONCAT31(in_register_00002029,band) == 0) { + iVar1 = -0x494; + bVar2 = me_env.chan.chan2G4_cnt; + } + else { + iVar1 = -0x440; + bVar2 = me_env.chan.chan5G_cnt; + } + psVar5 = (scan_chan_tag *)((int)&sta_stats[4].rate_stats[9].attempts + iVar1); + psVar6 = psVar5; + do { + if (psVar6 == psVar5 + bVar2) { + return (scan_chan_tag *)0x0; + } + psVar4 = psVar6; + puVar3 = &psVar6->freq; + psVar6 = psVar6 + 1; + } while ((uint)*puVar3 != CONCAT22(in_register_0000202e,freq)); + return psVar4; +} + + + +void michael_block(mic_calc *mic_calc_ptr,uint32_t block) + +{ + uint uVar1; + uint uVar2; + + uVar1 = block ^ mic_calc_ptr->mic_key_least; + uVar2 = mic_calc_ptr->mic_key_most ^ (uVar1 >> 0xf | uVar1 << 0x11); + uVar1 = uVar1 + uVar2; + uVar2 = (uVar1 >> 8 & 0xff00ff | uVar1 * 0x100 & 0xff00ff00) ^ uVar2; + uVar1 = uVar1 + uVar2; + uVar2 = (uVar1 * 8 | uVar1 >> 0x1d) ^ uVar2; + uVar1 = uVar1 + uVar2; + uVar2 = (uVar1 >> 2 | uVar1 * 0x40000000) ^ uVar2; + mic_calc_ptr->mic_key_most = uVar2; + mic_calc_ptr->mic_key_least = uVar1 + uVar2; + return; +} + + + +void me_mic_init(mic_calc *mic_calc_ptr,uint32_t *mic_key_ptr,mac_addr *da,mac_addr *sa,uint8_t tid) + +{ + uint32_t block; + uint16_t uVar1; + uint16_t uVar2; + uint32_t block_00; + undefined3 in_register_00002039; + uint32_t uVar3; + uint32_t block_01; + + block = *(uint32_t *)da->array; + block_01 = (uint)tid & 7; + uVar1 = sa->array[0]; + uVar2 = da->array[2]; + block_00 = *(uint32_t *)(sa->array + 1); + if (CONCAT31(in_register_00002039,tid) == 0xff) { + block_01 = 0; + } + mic_calc_ptr->mic_key_least = *mic_key_ptr; + uVar3 = mic_key_ptr[1]; + mic_calc_ptr->last_m_i = 0; + mic_calc_ptr->mic_key_most = uVar3; + mic_calc_ptr->last_m_i_len = '\0'; + michael_block(mic_calc_ptr,block); + michael_block(mic_calc_ptr,CONCAT22(uVar1,uVar2)); + michael_block(mic_calc_ptr,block_00); + michael_block(mic_calc_ptr,block_01); + return; +} + + + +void me_mic_calc(mic_calc *mic_calc_ptr,uint32_t start_ptr,uint32_t data_len) + +{ + uint8_t uVar1; + uint block; + uint block_00; + uint uVar2; + uint uVar3; + uint *puVar4; + uint uVar5; + uint uVar6; + uint *puVar7; + uint uVar8; + + puVar7 = (uint *)(start_ptr & 0xfffffffc) + 1; + block = 4 - (start_ptr & 3) & 0xff; + uVar3 = (uint)mic_calc_ptr->last_m_i_len; + uVar2 = *(uint *)(start_ptr & 0xfffffffc) >> ((start_ptr & 3) << 3); + uVar8 = data_len - block; + if (data_len < block) { + uVar2 = uVar2 & 0xffffffffU >> ((4 - data_len) * 8 & 0x1f); + block = data_len & 0xff; + uVar8 = 0; + } + block = block + uVar3; + block_00 = uVar2 << ((uVar3 & 3) << 3) | mic_calc_ptr->last_m_i; + uVar6 = block_00; + if (3 < block) { + uVar3 = (4 - uVar3) * 8; + uVar6 = 0; + if (uVar3 != 0x20) { + uVar6 = uVar2 >> (uVar3 & 0x1f); + } + block = block - 4; + michael_block(mic_calc_ptr,block_00); + } + uVar1 = (uint8_t)block; + uVar2 = (4 - block) * 8; + uVar3 = 0; + puVar4 = puVar7; + while (uVar8 >> 2 != uVar3) { + uVar5 = *puVar4; + puVar4 = puVar4 + 1; + block_00 = uVar5 << (block << 3 & 0x1f) | uVar6; + uVar6 = 0; + if (uVar2 != 0x20) { + uVar6 = uVar5 >> (uVar2 & 0x1f); + } + michael_block(mic_calc_ptr,block_00); + uVar3 = uVar3 + 1; + } + if ((uVar8 & 0xfffffffc) < uVar8) { + block_00 = (4 - (uVar8 & 3)) * 8; + uVar3 = 0; + if (block_00 != 0x20) { + uVar3 = 0xffffffff >> (block_00 & 0x1f); + } + uVar3 = *(uint *)((int)puVar7 + (uVar8 & 0xfffffffc)) & uVar3; + uVar8 = block + (uVar8 & 3); + uVar1 = (uint8_t)uVar8; + block = uVar6 | uVar3 << (block << 3 & 0x1f); + uVar6 = block; + if (3 < uVar8) { + uVar6 = 0; + if (uVar2 != 0x20) { + uVar6 = uVar3 >> (uVar2 & 0x1f); + } + uVar1 = uVar1 + -4; + michael_block(mic_calc_ptr,block); + } + } + mic_calc_ptr->last_m_i_len = uVar1; + mic_calc_ptr->last_m_i = uVar6; + return; +} + + + +void me_mic_end(mic_calc *mic_calc_ptr) + +{ + uint uVar1; + + uVar1 = mic_calc_ptr->last_m_i; + if (3 < mic_calc_ptr->last_m_i_len) { + assert_err("mic_calc_ptr->last_m_i_len < 4","module",0x13e); + } + michael_block(mic_calc_ptr,0x5a << (((uint)mic_calc_ptr->last_m_i_len & 3) << 3) | uVar1); + michael_block(mic_calc_ptr,0); + return; +} + + + +_Bool me_set_sta_ht_vht_param(sta_info_tag *sta,mac_bss_info *bss) + +{ + ushort uVar1; + uint uVar2; + uint uVar3; + uint8_t uVar4; + uint uVar5; + + uVar1 = (sta->info).ht_cap.ht_capa_info; + uVar3 = (uint)(uVar1 >> 1) & 1; + uVar2 = (int)(uint)uVar1 >> 8 & 3; + if ((uint)me_env.phy_bw_max < uVar3) { + uVar3 = (uint)me_env.phy_bw_max; + } + (sta->info).phy_bw_max = (uint8_t)uVar3; + uVar5 = (uint)bss->phy_bw; + if (bss->phy_bw == 4) { + uVar5 = 2; + } + uVar4 = (uint8_t)uVar5; + if (uVar3 < uVar5) { + uVar4 = (uint8_t)uVar3; + } + (sta->info).bw_cur = uVar4; + uVar4 = me_env.stbc_nss; + if (uVar2 < me_env.stbc_nss) { + uVar4 = (uint8_t)uVar2; + } + (sta->info).stbc_nss = uVar4; + return (_Bool)(((uint)uVar1 & 0xc) != 0xc); +} + + + +uint8_t me_11n_nss_max(uint8_t *mcs_set) + +{ + uint8_t uVar1; + + if (mcs_set[3] == '\0') { + uVar1 = '\x02'; + if ((mcs_set[2] == '\0') && (uVar1 = mcs_set[1], uVar1 != '\0')) { + uVar1 = '\x01'; + } + } + else { + uVar1 = '\x03'; + } + return uVar1; +} + + + +uint8_t me_legacy_ridx_min(uint16_t rate_map) + +{ + undefined2 in_register_0000202a; + uint uVar1; + + uVar1 = 0; + do { + if ((CONCAT22(in_register_0000202a,rate_map) >> (uVar1 & 0x1f) & 1U) != 0) { + return (uint8_t)uVar1; + } + uVar1 = uVar1 + 1; + } while (uVar1 != 0xc); + return '\f'; +} + + + +uint8_t me_legacy_ridx_max(uint16_t rate_map) + +{ + undefined2 in_register_0000202a; + char cVar1; + uint uVar2; + + if (CONCAT22(in_register_0000202a,rate_map) == 0) { + return '\f'; + } + uVar2 = 0xb; + do { + cVar1 = '\v' - (char)uVar2; + if ((CONCAT22(in_register_0000202a,rate_map) >> (uVar2 & 0x1f) & 1U) != 0) goto LAB_2300da70; + uVar2 = uVar2 - 1; + } while (uVar2 != 0xffffffff); + cVar1 = '\f'; +LAB_2300da70: + return '\v' - cVar1; +} + + + +uint8_t me_rate_translate(uint8_t rate) + +{ + uint8_t uVar1; + byte bVar2; + byte bVar3; + + bVar3 = rate & 0x7f; + if (bVar3 == 0x16) { + uVar1 = '\x03'; + } + else { + if (bVar3 < 0x17) { + if (bVar3 == 0xb) { + return '\x02'; + } + if (bVar3 < 0xc) { + if (bVar3 == 2) { + return '\0'; + } + bVar2 = 4; + uVar1 = '\x01'; + } + else { + if (bVar3 == 0xc) { + return '\x04'; + } + bVar2 = 0x12; + uVar1 = '\x05'; + } + } + else { + if (bVar3 == 0x30) { + return '\b'; + } + if (bVar3 < 0x31) { + if (bVar3 == 0x18) { + return '\x06'; + } + bVar2 = 0x24; + uVar1 = '\a'; + } + else { + if (bVar3 == 0x60) { + return '\n'; + } + if (bVar3 == 0x6c) { + return '\v'; + } + bVar2 = 0x48; + uVar1 = '\t'; + } + } + if (bVar3 != bVar2) { + return -1; + } + } + return uVar1; +} + + + +void me_get_basic_rates(mac_rateset *rateset,mac_rateset *basic_ratest) + +{ + byte bVar1; + int iVar2; + + basic_ratest->length = '\0'; + iVar2 = 0; + while (iVar2 < (int)(uint)rateset->length) { + if ((char)rateset->array[iVar2] < '\0') { + bVar1 = basic_ratest->length; + basic_ratest->array[bVar1] = rateset->array[iVar2]; + basic_ratest->length = bVar1 + 1; + } + iVar2 = iVar2 + 1; + } + return; +} + + + +uint16_t me_legacy_rate_bitfield_build(mac_rateset *rateset,_Bool basic_only) + +{ + uint uVar1; + int iVar2; + byte bVar3; + undefined3 extraout_var; + undefined3 in_register_0000202d; + + uVar1 = 0; + iVar2 = 0; + while (iVar2 < (int)(uint)rateset->length) { + if ((CONCAT31(in_register_0000202d,basic_only) == 0) || ((char)rateset->array[iVar2] < '\0')) { + bVar3 = me_rate_translate(rateset->array[iVar2]); + if (CONCAT31(extraout_var,bVar3) < 0xc) { + uVar1 = uVar1 | 1 << ((uint)bVar3 & 0x1f) & 0xffffU; + } + else { + assert_warn("bit_pos < MAC_RATESET_LEN","module",0x1c6); + } + } + iVar2 = iVar2 + 1; + } + return (uint16_t)uVar1; +} + + + +uint16_t me_build_capability(uint8_t vif_idx) + +{ + ushort uVar1; + undefined3 in_register_00002029; + int iVar2; + ushort uVar3; + + iVar2 = CONCAT31(in_register_00002029,vif_idx); + uVar3 = 0x11; + if (((vif_info_tab[iVar2].type != '\0') && (uVar3 = 1, vif_info_tab[iVar2].type == '\x02')) && + ((*(uint *)&vif_info_tab[iVar2].bss_info.is_supplicant_enabled & 0x12a00) != 0)) { + uVar3 = 0x11; + } + uVar1 = uVar3 | 0x520; + if ((vif_info_tab[iVar2].bss_info.chan)->band != '\x01') { + uVar1 = uVar3 | 0x420; + } + return (uint16_t)uVar1; +} + + + +void me_init_bcmc_rate(sta_info_tag *sta_entry) + +{ + byte bVar1; + byte rate; + uint8_t basic_rate_idx; + int iVar2; + + if ((sta_entry->info).rate_set.length == '\0') { + assert_err("rates->length != 0","module",0x229); + } + iVar2 = 0; + rate = 0; + while (iVar2 < (int)(uint)(sta_entry->info).rate_set.length) { + bVar1 = (sta_entry->info).rate_set.array[iVar2]; + if (rate < (bVar1 & 0x7f)) { + rate = bVar1 & 0x7f; + } + iVar2 = iVar2 + 1; + } + basic_rate_idx = me_rate_translate(rate); + rc_init_bcmc_rate(sta_entry,basic_rate_idx); + (sta_entry->pol_tbl).upd_field = '\0'; + return; +} + + + +void me_tx_cfm_singleton(txdesc *txdesc) + +{ + uint8_t sta_idx; + uint uVar1; + uint uVar2; + + uVar1 = ((txdesc->lmac).hw_desc)->cfm_ptr->status; + uVar2 = uVar1 & 0x10000; + uVar1 = uVar1 >> 8 & 0xff; + if (uVar2 == 0) { + sta_idx = (txdesc->host).staid; + } + else { + rf_dump_status(); + sta_idx = (txdesc->host).staid; + } + rc_update_counters(sta_idx,uVar1 + 1,uVar1 + (uVar2 != 0),false,false); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void me_check_rc(uint8_t sta_idx,_Bool *tx_ampdu) + +{ + ushort uVar1; + ushort uVar2; + ushort rate_config; + ushort rate_config_00; + uint16_t uVar3; + bool bVar4; + rc_sta_stats *rc_ss; + uint uVar5; + _Bool _Var6; + uint8_t uVar7; + uint8_t uVar8; + undefined3 in_register_00002029; + uint uVar9; + undefined3 extraout_var; + uint uVar10; + uint32_t uVar11; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + uint32_t uVar12; + byte bVar13; + uint32_t *puVar14; + uint uVar15; + int iVar16; + uint uVar17; + uint uVar18; + + uVar9 = CONCAT31(in_register_00002029,sta_idx); + if (9 < uVar9) { + return; + } + rc_ss = sta_info_tab[uVar9].pol_tbl.sta_stats; + if (rc_ss == (rc_sta_stats *)0x0) { + assert_err("rc_ss != NULL","module",0x826); + } + iVar16 = 0; + if ((int)((100000 - _DAT_44b00120) + rc_ss->last_rc_time) < 0) { + _Var6 = rc_update_stats(rc_ss,false); + iVar16 = CONCAT31(extraout_var,_Var6); + rc_ss->trial_status = '\0'; + rc_ss->sw_retry_step = '\0'; + rc_ss->info = rc_ss->info & 0xef; + rc_ss->last_rc_time = _DAT_44b00120; + } + if (rc_ss->trial_status == '\x01') { + if ((rc_ss->info & 0x40) == 0) { + bVar13 = rc_ss->format_mod; + uVar1 = rc_ss->retry[0].idx; + uVar15 = (uint)uVar1; + if (bVar13 < 2) { + if ((ushort)(rc_ss->rate_stats[uVar15].probability + 0xe667) < 0xd99b) { + uVar7 = '\n'; + } + else { + uVar7 = '\x05'; + } + } + else { + uVar7 = ((char)*(undefined2 *)((int)&rc_ss->avg_ampdu_len + 2) + '\b') * '\x02'; + } + rc_ss->sample_wait = uVar7; + next = next * 0x41c64e6d + 0x3039; + uVar5 = (next >> 0x10) % (uint)rc_ss->no_samples; + if (uVar5 != uVar15) { + uVar2 = rc_ss->retry[1].idx; + if (((uVar5 != (uint)uVar2) && (uVar18 = (uint)rc_ss->retry[2].idx, uVar5 != uVar18)) && + (puVar14 = &rc_ss->last_rc_time + uVar5 * 3, *(ushort *)(puVar14 + 2) < 0xf334)) { + rate_config = *(ushort *)((int)puVar14 + 10); + uVar10 = rc_get_duration((uint)rate_config); + rate_config_00 = rc_ss->rate_stats[uVar15].rate_config; + if (bVar13 < 2) { + uVar15 = rc_get_duration((uint)rate_config_00); + if (uVar15 < uVar10) { + uVar11 = 0; + bVar4 = 0x13 < *(byte *)(puVar14 + 3); + } + else { + uVar11 = 0; + bVar4 = true; + } + } + else { + uVar17 = 0x20; + uVar15 = rc_get_duration((uint)rc_ss->rate_stats[(uint)uVar2].rate_config); + if (*(char *)((int)puVar14 + 0xd) == '\0') { + uVar17 = (uint)*(ushort *)((int)&rc_ss->avg_ampdu_len + 2); + } + if (uVar15 <= uVar10) { + uVar7 = rc_get_nss(rate_config_00); + uVar8 = rc_get_nss(rate_config); + if ((CONCAT31(extraout_var_00,uVar7) - 1U < CONCAT31(extraout_var_01,uVar8)) || + (uVar15 = rc_get_duration((uint)rc_ss->rate_stats[uVar18].rate_config), + uVar15 <= uVar10)) { + if (uVar17 <= *(byte *)(puVar14 + 3)) { + bVar13 = rc_ss->sample_slow + 1; + rc_ss->sample_slow = bVar13; + if (bVar13 < 3) goto LAB_2300f85c; + if (0xf < bVar13) { + rc_ss->sample_slow = '\x0f'; + } + } + goto LAB_2300f836; + } + } +LAB_2300f85c: + uVar11 = rc_calc_tp(rc_ss,(uint8_t)uVar5); + bVar4 = true; + if ((*(byte *)((int)puVar14 + 0xe) & 0xf) < 10) { + bVar4 = uVar17 <= *(byte *)(puVar14 + 3); + } + } + uVar12 = rc_ss->retry[1].tp; + (rc_ss->max_tp_2_trial).idx = uVar2; + (rc_ss->max_tp_2_trial).tp = uVar12; + if (bVar4) { + uVar12 = rc_ss->retry[0].tp; + rc_ss->info = rc_ss->info & 0xfd; + rc_ss->retry[1].tp = uVar12; + rc_ss->retry[1].idx = uVar1; + rc_ss->retry[0].tp = uVar11; + rc_ss->retry[0].idx = (uint16_t)uVar5; + } + else { + rc_ss->info = rc_ss->info | 2; + rc_ss->retry[1].tp = uVar11; + rc_ss->retry[1].idx = (uint16_t)uVar5; + } + rc_ss->trial_status = '\x02'; + goto LAB_2300f79c; + } + } + } +LAB_2300f836: + rc_ss->trial_status = '\0'; + } + else { + if (rc_ss->trial_status == '\x03') { + if ((rc_ss->info & 2) == 0) { + rc_ss->retry[0].idx = rc_ss->retry[1].idx; + rc_ss->retry[0].tp = rc_ss->retry[1].tp; + } + uVar3 = (rc_ss->max_tp_2_trial).idx; + rc_ss->trial_status = '\0'; + rc_ss->retry[1].idx = uVar3; + uVar11 = (rc_ss->max_tp_2_trial).tp; + (rc_ss->max_tp_2_trial).tp = 0; + rc_ss->retry[1].tp = uVar11; + (rc_ss->max_tp_2_trial).idx = 0xff; + goto LAB_2300f79c; + } + } + if (iVar16 == 0) { + return; + } +LAB_2300f79c: + sta_info_tab[uVar9].pol_tbl.upd_field = sta_info_tab[uVar9].pol_tbl.upd_field | 1; + return; +} + + +/* +Unable to decompile 'me_update_buffer_control' +Cause: Exception while decompiling 2300dcc2: Decompiler process died + +*/ + + +void me_init_rate(sta_info_tag *sta_entry) + +{ + rc_init(sta_entry); + me_update_buffer_control(sta_entry); + return; +} + + + +void me_bw_check(int param_1,int param_2) + +{ + short sVar1; + short sVar2; + byte bVar3; + + sVar2 = **(short **)(param_2 + 0x4c); + bVar3 = 0; + if ((param_1 != 0) && (bVar3 = me_env.phy_bw_max, me_env.phy_bw_max != '\0')) { + bVar3 = *(byte *)(param_1 + 3) & 3; + if ((*(byte *)(param_1 + 3) & 3) != 0) { + sVar1 = 10; + if (bVar3 != 1) { + sVar1 = -10; + } + sVar2 = sVar2 + sVar1; + bVar3 = 1; + } + } + *(byte *)(param_2 + 0x82) = bVar3; + *(byte *)(param_2 + 0x83) = bVar3; + *(short *)(param_2 + 0x50) = sVar2; + *(undefined2 *)(param_2 + 0x52) = 0; + return; +} + + + +void me_beacon_check(uint8_t vif_idx,uint16_t length,uint32_t bcn_addr) + +{ + byte bVar1; + uint8_t uVar2; + uint8_t uVar3; + undefined3 in_register_00002029; + int iVar4; + int iVar5; + undefined4 uVar6; + uint8_t *puVar7; + undefined2 in_register_0000202e; + uint uVar8; + uint16_t uVar9; + scan_chan_tag *psVar10; + uint uVar11; + byte bVar12; + char cStack51; + int8_t iStack50; + uint8_t auStack49 [2]; + uint8_t csa_mode; + int8_t pwr; + uint8_t idx; + + iVar4 = CONCAT31(in_register_00002029,vif_idx); + psVar10 = vif_info_tab[iVar4].bss_info.chan; + vif_info_tab[iVar4].bss_info.prot_status = 0; + uVar8 = CONCAT22(in_register_0000202e,length) - 0x24; + bVar1 = vif_info_tab[iVar4].bss_info.phy_bw; + uVar2 = vif_info_tab[iVar4].bss_info.power_constraint; + bcn_addr = bcn_addr + 0x24; + uVar11 = uVar8 & 0xffff; + if ((psVar10->band == '\0') && (iVar5 = mac_ie_find(bcn_addr,uVar11,0x2a), iVar5 != 0)) { + bVar12 = *(byte *)(iVar5 + 2); + uVar9 = vif_info_tab[iVar4].bss_info.prot_status & 0xfff8; + if ((bVar12 & 1) != 0) { + uVar9 = uVar9 | 1; + } + vif_info_tab[iVar4].bss_info.prot_status = uVar9; + if ((bVar12 & 2) != 0) { + vif_info_tab[iVar4].bss_info.prot_status = vif_info_tab[iVar4].bss_info.prot_status | 2; + } + if ((bVar12 & 4) != 0) { + vif_info_tab[iVar4].bss_info.prot_status = vif_info_tab[iVar4].bss_info.prot_status | 4; + } + } + uVar6 = 0; + if (me_env.ht_supported != false) { + uVar6 = mac_ie_find(bcn_addr,uVar11,0x3d); + } + me_bw_check(uVar6,0,&vif_info_tab[iVar4].bss_info); + uVar11 = me_extract_csa(bcn_addr,uVar11,&cStack51,iVar4 * 0x5d8 + 0x42020540); + if ((uVar11 & 0xff) != 0) { + bVar12 = (byte)(uVar11 & 0xff); + if (vif_info_tab[iVar4].type == '\0') { + if ((vif_info_tab[iVar4].u[0x1d] == 0) && (cStack51 == '\x01')) { + mm_send_csa_traffic_ind(vif_info_tab[iVar4].index,false); + } + vif_info_tab[iVar4].u[0x1d] = bVar12; + } + else { + if (vif_info_tab[iVar4].type == '\x02') { + vif_info_tab[iVar4].u[0x2eb] = bVar12; + } + } + } + me_extract_power_constraint + (bcn_addr,(uint16_t)(uVar8 * 0x10000 >> 0x10),&vif_info_tab[iVar4].bss_info); + uVar3 = vif_info_tab[iVar4].bss_info.power_constraint; + if (uVar3 != uVar2) { + iStack50 = (vif_info_tab[iVar4].bss_info.chan)->tx_power - uVar3; + tpc_update_vif_tx_power(vif_info_tab + iVar4,&iStack50,auStack49); + } + if (bVar1 < vif_info_tab[iVar4].bss_info.phy_bw) { + puVar7 = (uint8_t *)ke_msg_alloc(0x3b,0,5,0xc); + if (vif_info_tab[iVar4].chan_ctxt == (chan_ctxt_tag *)0x0) { + assert_err("vif->chan_ctxt != NULL","module",0x39); + } + *puVar7 = (vif_info_tab[iVar4].chan_ctxt)->idx; + puVar7[1] = (vif_info_tab[iVar4].bss_info.chan)->band; + puVar7[2] = vif_info_tab[iVar4].bss_info.phy_bw; + *(uint16_t *)(puVar7 + 4) = (vif_info_tab[iVar4].bss_info.chan)->freq; + *(uint16_t *)(puVar7 + 6) = vif_info_tab[iVar4].bss_info.center_freq1; + *(uint16_t *)(puVar7 + 8) = vif_info_tab[iVar4].bss_info.center_freq2; + puVar7[10] = ((vif_info_tab[iVar4].chan_ctxt)->channel).tx_power; + ke_msg_send(puVar7); + } + return; +} + + + +void me_sta_bw_nss_max_upd(uint8_t sta_idx,uint8_t bw,uint8_t nss) + +{ + byte bVar1; + byte bVar2; + uint8_t sta_idx_00; + uint8_t nss_max; + uint8_t bw_max; + undefined3 in_register_00002029; + int iVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 in_register_0000202d; + uint uVar4; + undefined3 in_register_00002031; + uint uVar5; + + iVar3 = CONCAT31(in_register_00002029,sta_idx); + bVar1 = sta_info_tab[iVar3].inst_nbr; + if (me_env.ht_supported == false) { + assert_err("me_env.ht_supported","module",0x429); + } + nss_max = me_11n_nss_max(sta_info_tab[iVar3].info.ht_cap.mcs_rate); + bw_max = me_11n_nss_max(me_env.ht_cap.mcs_rate); + uVar5 = CONCAT31(extraout_var_00,bw_max); + if (CONCAT31(extraout_var,nss_max) < CONCAT31(extraout_var_00,bw_max)) { + uVar5 = CONCAT31(extraout_var,nss_max); + } + nss_max = (uint8_t)uVar5; + if (CONCAT31(in_register_00002031,nss) < uVar5) { + nss_max = nss; + } + bVar2 = sta_info_tab[iVar3].info.phy_bw_max; + uVar5 = (uint)bVar2; + if (bVar2 == 4) { + uVar5 = 3; + } + uVar4 = (uint)vif_info_tab[bVar1].bss_info.bw; + if (CONCAT31(in_register_0000202d,bw) < uVar4) { + uVar4 = CONCAT31(in_register_0000202d,bw); + } + bw_max = (uint8_t)uVar4; + if (uVar5 < uVar4) { + bw_max = (uint8_t)uVar5; + } + sta_idx_00 = sta_info_tab[iVar3].staid; + sta_info_tab[iVar3].info.bw_cur = bw_max; + rc_update_bw_nss_max(sta_idx_00,bw_max,nss_max); + sta_info_tab[iVar3].pol_tbl.upd_field = sta_info_tab[iVar3].pol_tbl.upd_field | 8; + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +uint8_t me_add_chan_ctx(uint8_t *p_chan_idx,scan_chan_tag *p_chan,uint32_t center_freq1, + uint32_t center_freq2,uint8_t ch_width) + +{ + uint8_t uVar1; + uint8_t uStack28; + uint8_t uStack27; + uint16_t uStack26; + mm_chan_ctxt_add_req req; + + uStack28 = p_chan->band; + req._0_2_ = (uint16_t)center_freq1; + uStack26 = p_chan->freq; + req.prim20_freq = (uint16_t)center_freq2; + req.center1_freq._0_1_ = p_chan->tx_power; + uStack27 = ch_width; + uVar1 = chan_ctxt_add((mm_chan_ctxt_add_req *)&uStack28,p_chan_idx); + return uVar1; +} + + + +uint8_t rc_get_nss(uint16_t rate_config) + +{ + undefined2 in_register_0000202a; + + if ((CONCAT22(in_register_0000202a,rate_config) >> 0xb & 7U) - 2 < 2) { + return (uint8_t)((byte)(CONCAT22(in_register_0000202a,rate_config) >> 3) & 3); + } + return '\0'; +} + + + +uint8_t rc_get_mcs_index(uint16_t rate_config) + +{ + undefined2 in_register_0000202a; + byte bVar1; + uint uVar2; + + uVar2 = CONCAT22(in_register_0000202a,rate_config) >> 0xb & 7; + if (uVar2 < 2) { + bVar1 = (byte)rate_config & 0x7f; + } + else { + bVar1 = 0; + if (uVar2 < 4) { + bVar1 = (byte)rate_config & 7; + } + } + return (uint8_t)bVar1; +} + + + +uint16_t rc_set_previous_mcs_index(rc_sta_stats *rc_ss,uint16_t rate_config) + +{ + uint uVar1; + uint8_t uVar2; + undefined3 extraout_var; + undefined2 in_register_0000202e; + + uVar2 = rc_get_mcs_index(rate_config); + _uVar2 = CONCAT31(extraout_var,uVar2); + uVar1 = CONCAT22(in_register_0000202e,rate_config) >> 0xb & 7; + if (uVar1 < 2) { + if (rc_ss->r_idx_min < _uVar2) { + rate_config = rate_config & 0xff80 | (short)_uVar2 - 1U; + } + } + else { + if ((uVar1 < 4) && (_uVar2 != 0)) { + rate_config = rate_config & 0xfff8 | (short)_uVar2 - 1U; + if (rc_ss->short_gi != '\0') { + rate_config = rate_config | 0x200; + } + } + } + return rate_config; +} + + + +uint16_t rc_set_next_mcs_index(rc_sta_stats *rc_ss,uint16_t rate_config) + +{ + uint8_t uVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined2 in_register_0000202e; + uint uVar2; + + uVar1 = rc_get_mcs_index(rate_config); + _uVar1 = CONCAT31(extraout_var,uVar1); + uVar2 = CONCAT22(in_register_0000202e,rate_config) >> 0xb & 7; + if (uVar2 < 2) { + if ((_uVar1 < rc_ss->r_idx_max) && ((rc_ss->rate_map_l >> (_uVar1 + 1 & 0x1f) & 1) != 0)) { + rate_config = rate_config & 0xff80 | (ushort)(_uVar1 + 1); + } + } + else { + if ((uVar2 < 4) && (_uVar1 < rc_ss->mcs_max)) { + uVar1 = rc_get_nss(rate_config); + if ((*(byte *)((int)&rc_ss->rate_map + CONCAT31(extraout_var_00,uVar1)) >> (_uVar1 + 1 & 0x1f) + & 1) != 0) { + rate_config = rate_config & 0xfff8 | (ushort)(_uVar1 + 1); + if (rc_ss->short_gi != '\0') { + rate_config = rate_config | 0x200; + } + } + } + } + return rate_config; +} + + + +_Bool is_cck_group(uint16_t rate_config) + +{ + uint8_t uVar1; + undefined3 extraout_var; + + if ((rate_config & 0x3000) == 0) { + uVar1 = rc_get_mcs_index(rate_config); + return (_Bool)(CONCAT31(extraout_var,uVar1) < 4); + } + return false; +} + + + +void rc_update_retry_chain(rc_sta_stats *rc_ss,uint32_t *cur_tp) + +{ + ushort uVar1; + ushort uVar2; + int iVar3; + uint uVar4; + _Bool _Var5; + ushort uVar6; + undefined3 extraout_var; + undefined3 extraout_var_00; + ushort *puVar7; + int iVar8; + uint32_t uVar9; + uint uVar10; + uint uVar11; + uint uVar12; + uint uVar13; + + uVar6 = rc_ss->no_samples; + uVar13 = (uint)uVar6; + if (((rc_ss->info & 4) == 0) && (cur_tp[uVar13 - 1] < *cur_tp)) { + rc_ss->retry[0].idx = 0; + rc_ss->retry[0].tp = 0; + uVar4 = 1; + } + else { + rc_ss->retry[0].idx = uVar6 - 1; + uVar4 = 2; + rc_ss->retry[0].tp = cur_tp[uVar13 - 1]; + } + uVar1 = rc_ss->retry[0].idx; + _Var5 = is_cck_group(*(uint16_t *)((int)(&rc_ss->last_rc_time + (uint)uVar1 * 3) + 10)); + if (CONCAT31(extraout_var,_Var5) == 0) { + uVar12 = 0; + while ((int)uVar12 < (int)(uVar13 - 1)) { + _Var5 = is_cck_group(*(uint16_t *)((int)(&rc_ss->last_rc_time + uVar12 * 3) + 10)); + if (CONCAT31(extraout_var_00,_Var5) != 0) { + *(undefined *)((int)(&rc_ss->last_rc_time + uVar12 * 3) + 0xf) = 0; + } + uVar12 = uVar12 + 1 & 0xffff; + } + *(undefined *)((int)(&rc_ss->last_rc_time + (uint)uVar1 * 3) + 0xf) = 1; + } + uVar9 = rc_ss->retry[0].tp; + rc_ss->retry[1].idx = uVar1; + rc_ss->retry[1].tp = uVar9; + iVar3 = uVar13 - uVar4; + do { + iVar8 = iVar3; + uVar12 = uVar4; + uVar4 = uVar12 + 1 & 0xffff; + if (uVar13 <= uVar12) goto LAB_2300e3d4; + iVar3 = iVar8 + -1; + } while (rc_ss->rate_stats[iVar8].rate_allowed == false); + rc_ss->retry[1].idx = uVar6 - (short)uVar12; + rc_ss->retry[1].tp = cur_tp[iVar8]; +LAB_2300e3d4: + uVar12 = (uint)rc_ss->retry[1].idx; + uVar4 = uVar13 - uVar4; + do { + uVar10 = uVar4; + uVar11 = uVar12; + if (uVar13 <= (uVar13 - uVar10 & 0xffff)) break; + uVar4 = uVar10 - 1; + uVar11 = uVar10; + } while (rc_ss->rate_stats[uVar10].rate_allowed == false); + uVar13 = cur_tp[uVar11]; + puVar7 = &rc_ss->rate_stats[0].probability; + uVar6 = rc_ss->rate_stats[uVar11].probability; + uVar4 = 0; + do { + if (uVar12 <= (uVar4 & 0xffff)) { + rc_ss->retry[2].idx = (uint16_t)uVar11; + uVar9 = cur_tp[uVar11]; + rc_ss->retry[3].idx = 0; + rc_ss->retry[2].tp = uVar9; + rc_ss->retry[3].tp = *cur_tp; + return; + } + if ((*(char *)((int)puVar7 + 7) != '\0') && ((uVar4 & 0xffff) != (uint)uVar1)) { + uVar2 = *puVar7; + if (uVar2 < 0xf333) { + if (uVar6 <= uVar2) { + uVar9 = cur_tp[uVar4]; + goto LAB_2300e4b8; + } + } + else { + uVar9 = cur_tp[uVar4]; + if (uVar13 <= uVar9) { +LAB_2300e4b8: + uVar13 = uVar9; + uVar11 = uVar4; + uVar6 = uVar2; + } + } + } + uVar4 = uVar4 + 1; + puVar7 = puVar7 + 6; + } while( true ); +} + + + +uint16_t rc_get_lowest_rate_config(rc_sta_stats *rc_ss) + +{ + byte bVar1; + uint16_t uVar2; + + bVar1 = rc_ss->format_mod; + if (bVar1 < 2) { + uVar2 = (uint16_t)rc_ss->r_idx_min; + if (rc_ss->r_idx_min == 0) { + return 0x400; + } + } + else { + if (3 < bVar1) { + return 0; + } + if (rc_ss->r_idx_min == '\0') { + return 0x400; + } + uVar2 = (ushort)bVar1 << 0xb; + } + return uVar2; +} + + + +// WARNING: Variable defined which should be unmapped: rc_ss_tmp + +void rc_sort_samples_tp(rc_sta_stats *rc_ss,uint32_t *cur_tp) + +{ + ushort uVar1; + uint32_t *puVar2; + ushort uVar3; + uint32_t uVar4; + ushort uVar5; + rc_rate_stats *__src; + ushort uVar6; + rc_rate_stats *__src_00; + undefined auStack44 [4]; + rc_rate_stats rc_ss_tmp; + + uVar5 = rc_ss->no_samples; + uVar1 = uVar5 - 1; + while (uVar6 = uVar1, uVar5 != 0) { + puVar2 = cur_tp + 1; + uVar5 = 0; + uVar3 = 1; + __src = rc_ss->rate_stats + 1; + while (uVar1 = uVar5, uVar3 < uVar6) { + __src_00 = __src + 1; + if (puVar2[1] < *puVar2) { + memmove(auStack44,__src,0xc); + memmove(__src,__src_00,0xc); + memmove(__src_00,auStack44,0xc); + uVar4 = puVar2[1]; + puVar2[1] = *puVar2; + *puVar2 = uVar4; + uVar5 = uVar3; + } + uVar3 = uVar3 + 1; + puVar2 = puVar2 + 1; + __src = __src_00; + } + } + return; +} + + + +uint16_t rc_get_initial_rate_config(rc_sta_stats *rc_ss) + +{ + byte bVar1; + byte bVar2; + ushort uVar3; + int iVar4; + ushort uVar5; + + bVar1 = rc_ss->format_mod; + if (bVar1 < 2) { + uVar3 = (ushort)rc_ss->r_idx_max; + uVar5 = (ushort)bVar1 << 0xb | (ushort)rc_ss->p_type << 10; + } + else { + if (3 < bVar1) { + return 0; + } + bVar2 = rc_ss->no_ss; + iVar4 = __clzsi2((uint)*(byte *)((int)&rc_ss->rate_map + (uint)bVar2)); + uVar5 = (ushort)rc_ss->short_gi << 9 | (ushort)bVar1 << 0xb | (ushort)rc_ss->bw_max << 7 | + (ushort)bVar2 << 3; + uVar3 = 0x1fU - (short)iVar4 & 0xff; + } + return (uint16_t)(uVar5 | uVar3); +} + + + +void rc_calc_prob_ewma(rc_rate_stats *rc_rs) + +{ + ushort uVar1; + uint uVar2; + uint uVar3; + + uVar1 = rc_rs->attempts; + if (uVar1 != 0) { + rc_rs->sample_skipped = '\0'; + uVar3 = (uint)rc_rs->success << 0x10; + uVar2 = uVar3 / uVar1; + if (rc_rs->old_prob_available == false) { + if (uVar3 < uVar1) { + rc_rs->probability = 0; + } + else { + rc_rs->probability = (short)uVar2 - 1; + } + } + else { + rc_rs->probability = (uint16_t)((uint)rc_rs->probability * 0x60 + uVar2 * 0x20 >> 7); + } + rc_rs->old_prob_available = true; + return; + } + if (rc_rs->sample_skipped != -1) { + rc_rs->sample_skipped = rc_rs->sample_skipped + '\x01'; + } + return; +} + + + +_Bool rc_check_valid_rate(rc_sta_stats *rc_ss,uint16_t rate_config) + +{ + uint8_t uVar1; + byte bVar2; + undefined3 extraout_var; + undefined2 in_register_0000202e; + uint uVar3; + + uVar3 = CONCAT22(in_register_0000202e,rate_config) >> 0xb & 7; + if (uVar3 < 2) { + bVar2 = rc_get_mcs_index(rate_config); + uVar3 = (uint)rc_ss->rate_map_l; + } + else { + if (3 < uVar3) { + return true; + } + uVar1 = rc_get_nss(rate_config); + bVar2 = rc_get_mcs_index(rate_config); + uVar3 = (uint)*(byte *)((int)&rc_ss->rate_map + CONCAT31(extraout_var,uVar1)); + } + return (_Bool)((byte)(uVar3 >> ((uint)bVar2 & 0x1f)) & 1); +} + + + +uint16_t rc_new_random_rate(rc_sta_stats *rc_ss) + +{ + byte bVar1; + byte bVar2; + uint uVar3; + int iVar4; + uint16_t uVar5; + uint uVar6; + ushort uVar7; + uint uVar8; + + bVar1 = rc_ss->bw_max; + uVar8 = 0; + next = next * 0x41c64e6d + 0x3039; + bVar2 = rc_ss->format_mod; + uVar6 = next >> 0x10; + uVar5 = (uint16_t)(((uint)bVar2 << 0x1b) >> 0x10); + if (bVar1 != 0) { + uVar8 = (uint)bVar1 - 1 & 0xff; + } + uVar7 = (ushort)(next >> 0x10); + if (bVar2 < 2) { + uVar8 = (int)(uVar6 & 0x7f) % (((uint)rc_ss->r_idx_max - (uint)rc_ss->r_idx_min) + 1) + + (uint)rc_ss->r_idx_min; + uVar6 = uVar8 & 0xff; + if ((rc_ss->rate_map_l >> (uVar8 & 0x1f) & 1) == 0) { + uVar6 = (uint)rc_ss->r_idx_max; + } + uVar5 = uVar5 | (ushort)uVar6; + if (uVar6 == 0) { + uVar5 = uVar5 | 0x400; + } + else { + if ((uVar6 - 1 & 0xff) < 3) { + uVar5 = uVar5 | uVar7 & 0x400 | (ushort)rc_ss->p_type << 10; + } + } + } + else { + if (bVar2 < 4) { + bVar2 = rc_ss->r_idx_min; + if ((bVar2 < 4) && ((int)(uVar6 << 0x14) < 0)) { + uVar8 = (int)(uVar6 & 0x7f) % (((uint)rc_ss->r_idx_max - (uint)bVar2) + 1) + (uint)bVar2; + uVar6 = uVar8 & 0xff; + if ((rc_ss->rate_map_l >> (uVar8 & 0x1f) & 1) == 0) { + uVar6 = (uint)rc_ss->r_idx_max; + } + uVar5 = 0x400; + if (uVar6 != 0) { + uVar5 = (ushort)rc_ss->p_type << 10 | uVar7 & 0x400 | (ushort)uVar6; + } + } + else { + uVar7 = (ushort)rc_ss->mcs_max; + iVar4 = (int)((int)uVar6 >> 3 & 3U) % ((uint)rc_ss->no_ss + 1); + uVar3 = (int)(uVar6 & 7) % ((uint)rc_ss->mcs_max + 1); + if ((*(byte *)((int)&rc_ss->rate_map + iVar4) >> (uVar3 & 0x1f) & 1) != 0) { + uVar7 = (ushort)uVar3 & 0xff; + } + uVar5 = uVar5 | (ushort)((int)((int)uVar6 >> 9 & 1U) % ((uint)rc_ss->short_gi + 1) << 9) | + (ushort)(iVar4 << 3) | + ((short)((int)((int)uVar6 >> 7 & 3U) % (((uint)bVar1 - uVar8) + 1)) + (short)uVar8) + * 0x80 | uVar7; + } + } + } + return uVar5; +} + + + +void rc_update_counters(uint8_t sta_idx,uint32_t attempts,uint32_t failures,_Bool tx_ampdu, + _Bool retry_required) + +{ + short sVar1; + rc_sta_stats *prVar2; + undefined3 in_register_00002029; + uint uVar3; + uint8_t uVar4; + uint32_t *puVar5; + ushort *puVar6; + + uVar3 = CONCAT31(in_register_00002029,sta_idx); + if (9 < uVar3) { + return; + } + if (sta_info_tab[uVar3].inst_nbr != -1) { + prVar2 = sta_info_tab[uVar3].pol_tbl.sta_stats; + if (prVar2 == (rc_sta_stats *)0x0) { + assert_err("rc_ss != NULL","module",0x7ce); + } + puVar6 = &prVar2->retry[0].idx; + prVar2->ampdu_packets = prVar2->ampdu_packets + 1; + prVar2->ampdu_len = prVar2->ampdu_len + 1; + do { + if (attempts == 0) break; + puVar5 = &prVar2->last_rc_time + (uint)*puVar6 * 3; + if (failures < 4) { + *(short *)(puVar5 + 1) = *(short *)(puVar5 + 1) + (short)attempts; + sVar1 = (short)failures; + failures = 0; + *(short *)((int)puVar5 + 6) = ((short)attempts - sVar1) + *(short *)((int)puVar5 + 6); + attempts = 0; + } + else { + *(short *)(puVar5 + 1) = *(short *)(puVar5 + 1) + 4; + attempts = attempts - 4; + failures = failures - 4; + } + if (*(ushort *)(puVar5 + 1) < *(ushort *)((int)puVar5 + 6)) { + assert_err("rc_rs->attempts >= rc_rs->success","module",0x7fa); + } + puVar6 = puVar6 + 4; + } while (puVar6 != &(prVar2->max_tp_2_trial).idx); + if (prVar2->trial_status == '\0') { + if (prVar2->sample_wait != '\0') { + prVar2->sample_wait = prVar2->sample_wait + -1; + return; + } + uVar4 = '\x01'; + } + else { + if (prVar2->trial_status != '\x02') { + return; + } + if ((sta_info_tab[uVar3].pol_tbl.upd_field & 1) != 0) { + return; + } + uVar4 = '\x03'; + } + prVar2->trial_status = uVar4; + } + return; +} + + + +uint32_t rc_get_duration(uint param_1) + +{ + uint8_t uVar1; + undefined3 extraout_var; + uint32_t uVar2; + undefined3 extraout_var_00; + uint uVar3; + + uVar1 = rc_get_mcs_index((uint16_t)param_1); + _uVar1 = CONCAT31(extraout_var,uVar1); + uVar3 = (int)param_1 >> 0xb & 7; + if (uVar3 < 2) { + if (_uVar1 < 4) { + uVar2 = rc_duration_cck[(int)param_1 >> 10 & 1U | _uVar1 << 1]; + } + else { + uVar2 = rc_duration_non_ht[_uVar1 - 4]; + } + } + else { + uVar2 = 0; + if (uVar3 < 4) { + uVar1 = rc_get_nss((uint16_t)param_1); + uVar2 = rc_duration_ht_ampdu[_uVar1 << 3 | param_1 >> 9 & 1 | param_1 >> 6 & 6] / + (CONCAT31(extraout_var_00,uVar1) + 1U); + } + } + return uVar2; +} + + + +void rc_update_bw_nss_max(uint8_t sta_idx,uint8_t bw_max,uint8_t nss_max) + +{ + ushort uVar1; + rc_sta_stats *rc_ss; + uint16_t uVar2; + undefined3 in_register_00002029; + int iVar3; + undefined2 extraout_var; + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + uint32_t *puVar4; + uint uVar5; + ushort *puVar6; + uint16_t *puVar7; + uint uVar8; + uint32_t local_48; + uint32_t cur_tp [10]; + + iVar3 = CONCAT31(in_register_00002029,sta_idx); + rc_ss = sta_info_tab[iVar3].pol_tbl.sta_stats; + if (rc_ss == (rc_sta_stats *)0x0) { + assert_err("rc_ss != NULL","module",0x969); + } + if (((uint)rc_ss->bw_max != CONCAT31(in_register_0000202d,bw_max)) || + ((uint)rc_ss->no_ss != CONCAT31(in_register_00002031,nss_max))) { + rc_ss->bw_max = bw_max; + if (3 < CONCAT31(in_register_0000202d,bw_max)) { + assert_err("rc_ss->bw_max <= BW_160MHZ","module",0x96f); + } + rc_ss->no_ss = nss_max; + if (7 < CONCAT31(in_register_00002031,nss_max)) { + assert_err("rc_ss->no_ss < 8","module",0x971); + } + if (rc_ss->fixed_rate_cfg == 0xffff) { + uVar2 = rc_get_lowest_rate_config(rc_ss); + rc_ss->rate_stats[0].rate_config = uVar2; + uVar2 = rc_get_initial_rate_config(rc_ss); + rc_ss->rate_stats[(uint)rc_ss->no_samples - 1].rate_config = uVar2; + uVar5 = 1; +LAB_2300eabc: + uVar1 = rc_ss->no_samples; + if ((int)uVar5 < (int)((uint)uVar1 - 1)) { + do { + uVar2 = rc_new_random_rate(rc_ss); + uVar8 = 0; + puVar6 = &rc_ss->rate_stats[0].rate_config; + while( true ) { + if (rc_ss->no_samples <= uVar8) { + rc_ss->rate_stats[uVar5].rate_config = uVar2; + uVar5 = uVar5 + 1 & 0xffff; + goto LAB_2300eabc; + } + if ((uint)*puVar6 == CONCAT22(extraout_var,uVar2)) break; + uVar8 = uVar8 + 1; + puVar6 = puVar6 + 6; + } + } while( true ); + } + puVar7 = &rc_ss->rate_stats[0].probability; + uVar5 = 0; + puVar4 = &local_48; + while ((uint)uVar1 != uVar5) { + *(undefined *)(puVar7 + 3) = 0; + *(undefined *)((int)puVar7 + 7) = 1; + *puVar7 = 0; + *(undefined *)((int)puVar7 + 5) = 0; + *puVar4 = 0; + uVar5 = uVar5 + 1 & 0xffff; + puVar7 = puVar7 + 6; + puVar4 = puVar4 + 1; + } + rc_sort_samples_tp(rc_ss,&local_48); + rc_update_retry_chain(rc_ss,&local_48); + sta_info_tab[iVar3].pol_tbl.upd_field = sta_info_tab[iVar3].pol_tbl.upd_field | 1; + } + } + return; +} + + + +void rc_init_bcmc_rate(sta_info_tag *sta_entry,uint8_t basic_rate_idx) + +{ + undefined3 in_register_0000202d; + txl_buffer_control *ptVar1; + uint uVar2; + + ptVar1 = (sta_entry->pol_tbl).buf_ctrl; + uVar2 = 0; + if (CONCAT31(in_register_0000202d,basic_rate_idx) < 4) { + uVar2 = SEXT24((short)((sta_entry->pol_tbl).ppdu_tx_cfg & 0x400)); + } + uVar2 = CONCAT31(in_register_0000202d,basic_rate_idx) | uVar2 | 0x20000000; + *(uint *)(ptVar1->field_0 + 0x14) = uVar2; + *(uint *)(ptVar1->field_0 + 0x18) = uVar2; + *(uint *)(ptVar1->field_0 + 0x1c) = uVar2; + *(uint *)(ptVar1->field_0 + 0x20) = uVar2; + return; +} + + + +_Bool rc_check_fixed_rate_config(rc_sta_stats *rc_ss,uint16_t fixed_rate_config) + +{ + uint8_t uVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined2 in_register_0000202e; + uint uVar3; + uint uVar4; + + uVar4 = (uint)rc_ss->format_mod; + uVar3 = ((uint)fixed_rate_config & 0x3800) >> 0xb; + if (uVar4 < uVar3) { + return false; + } + if (rc_ss->format_mod == 4) { + if (uVar3 != uVar4) { + return false; + } +LAB_2300ebae: + if ((fixed_rate_config & 0x3000) == 0) { +LAB_2300ec06: + if (((CONCAT22(in_register_0000202e,fixed_rate_config) >> 10 & 1U) == 0) && + (rc_ss->p_type == '\x01')) { + return false; + } + goto LAB_2300ebe0; + } + } + else { + if (1 < (uVar4 - 2 & 0xff)) goto LAB_2300ebae; + if ((fixed_rate_config & 0x3000) == 0) { + if (3 < rc_ss->r_idx_min) { + return false; + } + goto LAB_2300ec06; + } + } + if (((((fixed_rate_config & 0x200) != 0) && (rc_ss->short_gi == '\0')) || + ((uint)rc_ss->bw_max < (CONCAT22(in_register_0000202e,fixed_rate_config) >> 7 & 3U))) || + (uVar1 = rc_get_nss(fixed_rate_config), (uint)rc_ss->no_ss < CONCAT31(extraout_var,uVar1))) { + return false; + } +LAB_2300ebe0: + _Var2 = rc_check_valid_rate(rc_ss,fixed_rate_config); + return _Var2; +} + + + +uint32_t rc_calc_tp(rc_sta_stats *rc_ss,uint8_t sample_idx) + +{ + ushort uVar1; + ushort rate_config; + uint uVar2; + _Bool _Var3; + undefined3 extraout_var; + int iVar4; + uint32_t uVar5; + undefined3 in_register_0000202d; + + uVar1 = *(ushort *)(&rc_ss->last_rc_time + CONCAT31(in_register_0000202d,sample_idx) * 3 + 2); + if (uVar1 < 0x1999) { + uVar5 = 0; + } + else { + rate_config = *(ushort *) + ((int)(&rc_ss->last_rc_time + CONCAT31(in_register_0000202d,sample_idx) * 3) + 10 + ); + uVar2 = 0; + _Var3 = is_cck_group(rate_config); + if (CONCAT31(extraout_var,_Var3) == 0) { + uVar2 = 0x35390 / (uint)*(ushort *)((int)&rc_ss->avg_ampdu_len + 2); + } + iVar4 = rc_get_duration((uint)rate_config); + uVar5 = (((uint)uVar1 * 1000) / (iVar4 + uVar2)) * 1000000 >> 0x10; + } + return uVar5; +} + + + +_Bool rc_update_stats(rc_sta_stats *rc_ss,_Bool init) + +{ + byte bVar1; + ushort rate_config; + _Bool _Var2; + uint16_t rate_config_00; + uint32_t uVar3; + undefined2 extraout_var_03; + undefined3 extraout_var; + undefined2 extraout_var_04; + undefined3 extraout_var_00; + undefined2 extraout_var_05; + undefined3 extraout_var_01; + undefined2 extraout_var_06; + undefined3 extraout_var_02; + uint uVar4; + undefined3 in_register_0000202d; + rc_rate_stats *prVar5; + uint32_t *cur_tp_00; + uint32_t *puVar6; + uint uVar7; + ushort rate_config_01; + uint16_t uVar8; + uint8_t *puVar9; + uint16_t *puVar10; + uint16_t *puVar11; + uint uVar12; + char cVar13; + uint16_t uStack148; + ushort uStack146; + uint16_t new_rate_cfg_array [6]; + step old_retry [4]; + uint32_t cur_tp [10]; + + memcpy(new_rate_cfg_array + 4,rc_ss->retry,0x20); + if (rc_ss->ampdu_packets != 0) { + rate_config = rc_ss->ampdu_len; + *(undefined4 *)&rc_ss->ampdu_len = 0; + rc_ss->avg_ampdu_len = + ((int)((uint)rate_config << 0x10) / (int)(uint)rc_ss->ampdu_packets) * 0x20 + + rc_ss->avg_ampdu_len * 0x60 >> 7; + } + rate_config = rc_ss->no_samples; + cur_tp_00 = (uint32_t *)&old_retry[3].idx; + rc_ss->sample_slow = '\0'; + puVar9 = &rc_ss->rate_stats[0].n_retry; + uVar7 = 0; + puVar6 = cur_tp_00; + while ((uint)rate_config != uVar7) { + *puVar6 = 0; + *puVar9 = '\0'; + puVar9[1] = '\x01'; + uVar7 = uVar7 + 1 & 0xffff; + puVar6 = puVar6 + 1; + puVar9 = puVar9 + 0xc; + } + rate_config_00 = rc_ss->fixed_rate_cfg; + uVar12 = 0; + if (rate_config_00 == 0xffff) { + while (uVar12 < rc_ss->no_samples) { + rc_calc_prob_ewma(rc_ss->rate_stats + uVar12); + uVar3 = rc_calc_tp(rc_ss,(uint8_t)uVar12); + *(uint32_t *)(&old_retry[3].idx + uVar12 * 2) = uVar3; + uVar12 = uVar12 + 1 & 0xffff; + } + rc_sort_samples_tp(rc_ss,cur_tp_00); + rc_update_retry_chain(rc_ss,cur_tp_00); + if (CONCAT31(in_register_0000202d,init) == 0) { + rate_config = rc_ss->no_samples; + if (9 < rate_config) { + cVar13 = '\0'; + rate_config = rc_ss->rate_stats[rc_ss->retry[0].idx].rate_config; + uVar7 = (uint)rate_config; + rate_config_01 = rc_ss->rate_stats[rc_ss->retry[1].idx].rate_config; + memset(&uStack148,-1,0xc); + do { + switch(cVar13) { + case '\x01': + if ((((int)uVar7 >> 0xb & 6U) != 0) && (rc_ss->short_gi == '\x01')) { + if ((rate_config & 0x200) == 0) { + uStack146 = rate_config | 0x200; + } + else { + uStack146 = rate_config & 0xfdff; + } + } + break; + case '\x02': + rate_config_00 = rc_set_next_mcs_index(rc_ss,rate_config); + if ((uVar7 != CONCAT22(extraout_var_03,rate_config_00)) && + (_Var2 = rc_check_valid_rate(rc_ss,rate_config_00), CONCAT31(extraout_var,_Var2) != 0 + )) { + new_rate_cfg_array[0] = rate_config_00; + } + break; + case '\x03': + rate_config_00 = rc_set_previous_mcs_index(rc_ss,rate_config); + if ((uVar7 != CONCAT22(extraout_var_04,rate_config_00)) && + (_Var2 = rc_check_valid_rate(rc_ss,rate_config_00), + CONCAT31(extraout_var_00,_Var2) != 0)) { + new_rate_cfg_array[1] = rate_config_00; + } + break; + case '\x04': + rate_config_00 = rc_set_next_mcs_index(rc_ss,rate_config_01); + if (((uint)rate_config_01 != CONCAT22(extraout_var_05,rate_config_00)) && + (_Var2 = rc_check_valid_rate(rc_ss,rate_config_00), + CONCAT31(extraout_var_01,_Var2) != 0)) { + new_rate_cfg_array[2] = rate_config_00; + } + break; + case '\x05': + rate_config_00 = rc_set_previous_mcs_index(rc_ss,rate_config_01); + if (((uint)rate_config_01 != CONCAT22(extraout_var_06,rate_config_00)) && + (_Var2 = rc_check_valid_rate(rc_ss,rate_config_00), + CONCAT31(extraout_var_02,_Var2) != 0)) { + new_rate_cfg_array[3] = rate_config_00; + } + break; + default: + uStack148 = rc_new_random_rate(rc_ss); + } + cVar13 = cVar13 + '\x01'; + } while (cVar13 != '\x06'); + rate_config = rc_ss->no_samples; + uVar12 = 1; + uVar7 = 0; + while (uVar12 < rate_config) { + puVar6 = &rc_ss->last_rc_time + uVar12 * 3; + if ((((*(short *)(puVar6 + 2) < 0) && (*(byte *)(puVar6 + 3) < 0xb)) || + ((uint)rc_ss->retry[0].idx == uVar12)) || + ((((uint)rc_ss->retry[1].idx == uVar12 || ((uint)rc_ss->retry[2].idx == uVar12)) || + (5 < uVar7)))) { + uVar12 = uVar12 + 1 & 0xffff; + } + else { + rate_config_00 = (&uStack148)[uVar7]; + if (rate_config_00 != 0xffff) { + uVar4 = 0; + puVar11 = &rc_ss->rate_stats[0].rate_config; + while (uVar4 < rate_config) { + if (*puVar11 == rate_config_00) goto LAB_2300ef9e; + uVar4 = uVar4 + 1; + puVar11 = puVar11 + 6; + } + *(uint16_t *)((int)puVar6 + 10) = rate_config_00; + *(undefined2 *)(puVar6 + 2) = 0; + *(undefined *)((int)puVar6 + 0xd) = 0; + uVar12 = uVar12 + 1 & 0xffff; + } +LAB_2300ef9e: + uVar7 = uVar7 + 1; + } + *(undefined2 *)(puVar6 + 1) = 0; + *(undefined2 *)((int)puVar6 + 6) = 0; + } + *(undefined4 *)rc_ss->rate_stats = 0; + goto LAB_2300ee64; + } + prVar5 = rc_ss->rate_stats; + rate_config_01 = 0; + while (rate_config != rate_config_01) { + rate_config_01 = rate_config_01 + 1; + prVar5->attempts = 0; + prVar5->success = 0; + prVar5 = prVar5 + 1; + } + } + } + else { + bVar1 = rc_ss->info; + uVar12 = 0; + if ((bVar1 & 0x20) != 0) { + while (uVar8 = (uint16_t)uVar12, uVar12 < uVar7) { + if (rc_ss->rate_stats[uVar12].rate_config == rate_config_00) goto LAB_2300eff8; + uVar12 = uVar12 + 1 & 0xff; + } + if (uVar7 == uVar12) { + uVar12 = uVar12 - 1 & 0xff; + uVar8 = (uint16_t)uVar12; + *(uint16_t *)((int)(&rc_ss->last_rc_time + uVar12 * 3) + 10) = rate_config_00; + *(undefined2 *)(&rc_ss->last_rc_time + uVar12 * 3 + 2) = 0; + } +LAB_2300eff8: + rc_ss->retry[0].idx = uVar8; + rc_ss->retry[1].idx = uVar8; + rc_ss->retry[2].idx = uVar8; + rc_ss->retry[0].tp = 0; + rc_ss->retry[1].tp = 0; + rc_ss->retry[2].tp = 0; + prVar5 = rc_ss->rate_stats; + uVar12 = 0; + while (uVar7 != uVar12) { + prVar5->attempts = 0; + prVar5->success = 0; + uVar12 = uVar12 + 1 & 0xffff; + prVar5 = prVar5 + 1; + } + rc_ss->info = bVar1 & 0x9f | 0x40; + init = true; + goto LAB_2300ee64; + } + uVar7 = (uint)*(byte *)&rc_ss->retry[0].idx; + rc_calc_prob_ewma(rc_ss->rate_stats + uVar7); + *(undefined2 *)(&rc_ss->last_rc_time + uVar7 * 3 + 1) = 0; + *(undefined2 *)((int)(&rc_ss->last_rc_time + uVar7 * 3) + 6) = 0; + *(undefined4 *)rc_ss->rate_stats = 0; + } + init = false; +LAB_2300ee64: + puVar10 = &rc_ss->retry[0].idx; + puVar11 = new_rate_cfg_array; + do { + if (puVar11[6] != *puVar10) { + return true; + } + puVar10 = puVar10 + 4; + puVar11 = puVar11 + 4; + } while (puVar10 != &(rc_ss->max_tp_2_trial).idx); + return init; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rc_init(sta_info_tag *sta_entry) + +{ + byte bVar1; + ushort uVar2; + uint uVar3; + step *psVar4; + uint8_t uVar5; + uint8_t uVar6; + _Bool _Var7; + byte bVar8; + uint16_t rate_map; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + undefined3 extraout_var_05; + undefined3 extraout_var_06; + undefined2 extraout_var_07; + int iVar9; + short sVar10; + uint *puVar11; + uint *puVar12; + uint uVar13; + ushort *puVar14; + uint uVar15; + uint uVar16; + rc_sta_stats *__s; + txl_buffer_control *ptVar17; + uint uVar18; + rc_sta_stats *rc_ss; + uint uVar19; + uint8_t *mcs_set; + ushort *puVar20; + + bVar8 = sta_entry->staid; + ptVar17 = (sta_entry->pol_tbl).buf_ctrl; + if (9 < bVar8) { + assert_err("sta_entry->staid < NX_REMOTE_STA_MAX","module",0x85f); + } + uVar16 = (uint)sta_entry->staid; + __s = sta_stats + uVar16; + (sta_entry->pol_tbl).sta_stats = __s; + uVar5 = phy_get_ntx(); + uVar18 = CONCAT31(extraout_var,uVar5) << 0xe; + memset(__s,0,200); + if (((sta_entry->info).capa_flags & 2) == 0) { + rate_map = me_legacy_rate_bitfield_build((mac_rateset *)&sta_entry->info,false); + sta_stats[uVar16].rate_map_l = rate_map; + uVar5 = me_legacy_ridx_min(rate_map); + sta_stats[uVar16].r_idx_min = uVar5; + if (0xb < CONCAT31(extraout_var_05,uVar5)) { + assert_err("rc_ss->r_idx_min < MAC_RATESET_LEN","module",0x8f4); + } + uVar5 = me_legacy_ridx_max(sta_stats[uVar16].rate_map_l); + sta_stats[uVar16].r_idx_max = uVar5; + if (0xb < CONCAT31(extraout_var_06,uVar5)) { + assert_err("rc_ss->r_idx_max < MAC_RATESET_LEN","module",0x8f6); + } + sta_stats[uVar16].mcs_max = -1; + uVar5 = (sta_entry->info).bw_cur; + sta_stats[uVar16].bw_max = uVar5; + if (uVar5 != '\0') { + assert_err("rc_ss->bw_max == BW_20MHZ","module",0x8f9); + } + sta_stats[uVar16].p_type = (byte)((int)(uint)(sta_entry->pol_tbl).ppdu_tx_cfg >> 10) & 1; + } + else { + rate_map = me_legacy_rate_bitfield_build((mac_rateset *)&sta_entry->info,false); + mcs_set = (sta_entry->info).ht_cap.mcs_rate; + sta_stats[uVar16].format_mod = '\x02'; + sta_stats[uVar16].rate_map_l = rate_map; + uVar5 = me_11n_nss_max(mcs_set); + uVar6 = me_11n_nss_max(me_env.ht_cap.mcs_rate); + uVar19 = CONCAT31(extraout_var_00,uVar5); + if (CONCAT31(extraout_var_01,uVar6) < CONCAT31(extraout_var_00,uVar5)) { + uVar19 = CONCAT31(extraout_var_01,uVar6); + } + sta_stats[uVar16].no_ss = (uint8_t)uVar19; + if (3 < uVar19) { + assert_err("rc_ss->no_ss <= 3","module",0x8a6); + } + memcpy(&sta_stats[uVar16].rate_map,mcs_set,4); + rate_map = sta_stats[uVar16].rate_map_l; + *(undefined *)&sta_stats[uVar16].rate_map = 0xff; + sta_stats[uVar16].mcs_max = '\a'; + uVar5 = me_legacy_ridx_min(rate_map); + sta_stats[uVar16].r_idx_min = uVar5; + if (0xc < CONCAT31(extraout_var_02,uVar5)) { + assert_err("(rc_ss->r_idx_min <= HW_RATE_54MBPS) || (rc_ss->r_idx_min == MAC_RATESET_LEN)", + "module",0x8b8); + } + uVar5 = me_legacy_ridx_max(sta_stats[uVar16].rate_map_l); + sta_stats[uVar16].r_idx_max = uVar5; + if (0xc < CONCAT31(extraout_var_03,uVar5)) { + assert_err("(rc_ss->r_idx_max <= HW_RATE_54MBPS) || (rc_ss->r_idx_max == MAC_RATESET_LEN)", + "module",0x8be); + } + sta_stats[uVar16].p_type = (byte)((int)(uint)(sta_entry->pol_tbl).ppdu_tx_cfg >> 10) & 1; + _Var7 = phy_ldpc_tx_supported(); + uVar2 = (sta_entry->info).ht_cap.ht_capa_info; + if ((CONCAT31(extraout_var_04,_Var7) != 0) && ((uVar2 & 1) != 0)) { + uVar18 = uVar18 | 0x40; + } + if ((int)((uint)uVar2 << 0x14) < 0) { + sVar10 = 0x2000; + } + else { + sVar10 = 0x1000; + } + sta_stats[uVar16].max_amsdu_len = sVar10 - 0x101; + bVar1 = (sta_entry->info).bw_cur; + sta_stats[uVar16].bw_max = bVar1; + if (3 < bVar1) { + assert_err("rc_ss->bw_max <= BW_160MHZ","module",0x8d5); + } + uVar5 = (sta_entry->info).bw_cur; + if (uVar5 == '\0') { + if (((sta_entry->info).ht_cap.ht_capa_info & 0x20) != 0) { + uVar5 = '\x01'; + goto LAB_2300f2aa; + } + } + else { + if ((uVar5 == '\x01') && (((sta_entry->info).ht_cap.ht_capa_info & 0x40) != 0)) { +LAB_2300f2aa: + sta_stats[uVar16].short_gi = uVar5; + } + } + } + if (sta_stats[uVar16].format_mod < 2) { + uVar19 = (uint)sta_stats[uVar16].rate_map_l; + uVar15 = 1 - (uint)sta_stats[uVar16].p_type; + uVar13 = (((int)uVar19 >> 1 & 1U) + ((int)uVar19 >> 2 & 1U) << (uVar15 & 0x1f)) + (uVar19 & 1) + + (((int)uVar19 >> 3 & 1U) << (uVar15 & 0x1f)) & 0xffff; + uVar15 = 4; + do { + uVar3 = uVar15 & 0x1f; + uVar15 = uVar15 + 1; + uVar13 = uVar13 + ((int)uVar19 >> uVar3 & 1U) & 0xffff; + } while (uVar15 != 0xc); +LAB_2300f3c4: + if (10 < uVar13) { + sta_stats[uVar16].no_samples = 10; + goto LAB_2300f3d8; + } + sta_stats[uVar16].no_samples = (uint16_t)uVar13; + if (uVar13 != 0) goto LAB_2300f3d8; + } + else { + if (sta_stats[uVar16].format_mod < 4) { + uVar19 = (uint)*(byte *)&sta_stats[uVar16].rate_map; + iVar9 = 8; + uVar15 = 0; + do { + uVar13 = uVar19 & 1; + iVar9 = iVar9 + -1; + uVar19 = uVar19 >> 1; + uVar15 = uVar15 + (1 << ((uint)sta_stats[uVar16].short_gi & 0x1f)) * uVar13 & 0xffff; + } while (iVar9 != 0); + uVar13 = (uint)sta_stats[uVar16].rate_map_l; + uVar19 = 1 - (uint)sta_stats[uVar16].p_type; + uVar13 = uVar15 + (((int)uVar13 >> 1 & 1U) + ((int)uVar13 >> 2 & 1U) << (uVar19 & 0x1f)) + + (uVar13 & 1) + (((int)uVar13 >> 3 & 1U) << (uVar19 & 0x1f)) & 0xffff; + goto LAB_2300f3c4; + } + sta_stats[uVar16].no_samples = 0; + } + assert_err("rc_ss->no_samples >= 1","module",0x8ff); + if (10 < sta_stats[uVar16].no_samples) { + assert_err("rc_ss->no_samples <= RC_MAX_N_SAMPLE","module",0x900); + } +LAB_2300f3d8: + rc_ss = sta_info_tab[sta_entry->staid].pol_tbl.sta_stats; + if (rc_ss == (rc_sta_stats *)0x0) { + assert_err("rc_ss != NULL","module",0x6e4); + } + uVar2 = rc_ss->no_samples; + puVar20 = &rc_ss->rate_stats[0].rate_config; + uVar19 = 0; + puVar14 = puVar20; + while (uVar19 != (uint)uVar2) { + *puVar14 = 0xffff; + uVar19 = uVar19 + 1 & 0xffff; + puVar14 = puVar14 + 6; + } + rate_map = rc_get_lowest_rate_config(rc_ss); + rc_ss->rate_stats[0].rate_config = rate_map; + rate_map = rc_get_initial_rate_config(rc_ss); + rc_ss->rate_stats[uVar19 - 1].rate_config = rate_map; + uVar19 = 1; +LAB_2300f442: + do { + uVar2 = rc_ss->no_samples; + if ((int)((uint)uVar2 - 1) <= (int)uVar19) { + rc_ss->retry[0].idx = (uint16_t)((uint)uVar2 - 1); + rc_ss->retry[2].idx = uVar2 - 3; + rc_ss->avg_ampdu_len = 0x10000; + rc_ss->retry[1].idx = uVar2 - 2; + rc_ss->fixed_rate_cfg = 0xffff; + rc_ss->retry[0].tp = 0; + rc_ss->retry[1].tp = 0; + rc_ss->retry[2].tp = 0; + rc_ss->retry[3].idx = 0; + rc_ss->retry[3].tp = 0; + rc_ss->info = '\0'; + rc_update_stats(rc_ss,true); + rc_ss->sample_wait = '\x05'; + puVar11 = (uint *)(ptVar17->field_0 + 0x14); + do { + psVar4 = __s->retry; + puVar12 = puVar11 + 1; + __s = (rc_sta_stats *)&__s->rate_stats[0].probability; + *puVar11 = (uint)sta_stats[uVar16].rate_stats[*(byte *)&psVar4->idx].rate_config | + 0x80000000; + puVar11 = puVar12; + } while (puVar12 != (uint *)(ptVar17->field_0 + 0x24)); + sta_stats[uVar16].last_rc_time = _DAT_44b00120; + *(undefined4 *)ptVar17->field_0 = 0xbadcab1e; + *(uint *)(ptVar17->field_0 + 0xc) = ((uint)bVar8 + 8 & 0xff) << 10; + *(undefined4 *)(ptVar17->field_0 + 0x10) = 0xffff0704; + *(uint *)(ptVar17->field_0 + 4) = uVar18; + bVar8 = phy_get_ntx(); + *(int *)(ptVar17->field_0 + 8) = (1 << ((uint)bVar8 + 1 & 0x1f)) + -1; + ((sta_entry->pol_tbl).buf_ctrl)->mac_control_info = 0x2200; + ((sta_entry->pol_tbl).buf_ctrl)->phy_control_info = sta_entry->paid_gid; + (sta_entry->pol_tbl).upd_field = (sta_entry->pol_tbl).upd_field | 0x11; + return; + } + rate_map = rc_new_random_rate(rc_ss); + uVar15 = 0; + puVar14 = puVar20; + while (uVar15 < rc_ss->no_samples) { + if ((uint)*puVar14 == CONCAT22(extraout_var_07,rate_map)) goto LAB_2300f442; + uVar15 = uVar15 + 1; + puVar14 = puVar14 + 6; + } + rc_ss->rate_stats[uVar19].rate_config = rate_map; + uVar19 = uVar19 + 1 & 0xffff; + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rc_check(uint8_t sta_idx,_Bool *tx_ampdu) + +{ + ushort uVar1; + ushort uVar2; + ushort rate_config; + ushort rate_config_00; + uint16_t uVar3; + bool bVar4; + rc_sta_stats *rc_ss; + uint uVar5; + _Bool _Var6; + uint8_t uVar7; + uint8_t uVar8; + undefined3 in_register_00002029; + uint uVar9; + undefined3 extraout_var; + uint uVar10; + uint32_t uVar11; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + uint32_t uVar12; + byte bVar13; + uint32_t *puVar14; + uint uVar15; + int iVar16; + uint uVar17; + uint uVar18; + + uVar9 = CONCAT31(in_register_00002029,sta_idx); + if (9 < uVar9) { + return; + } + rc_ss = sta_info_tab[uVar9].pol_tbl.sta_stats; + if (rc_ss == (rc_sta_stats *)0x0) { + assert_err("rc_ss != NULL","module",0x826); + } + iVar16 = 0; + if ((int)((100000 - _DAT_44b00120) + rc_ss->last_rc_time) < 0) { + _Var6 = rc_update_stats(rc_ss,false); + iVar16 = CONCAT31(extraout_var,_Var6); + rc_ss->trial_status = '\0'; + rc_ss->sw_retry_step = '\0'; + rc_ss->info = rc_ss->info & 0xef; + rc_ss->last_rc_time = _DAT_44b00120; + } + if (rc_ss->trial_status == '\x01') { + if ((rc_ss->info & 0x40) == 0) { + bVar13 = rc_ss->format_mod; + uVar1 = rc_ss->retry[0].idx; + uVar15 = (uint)uVar1; + if (bVar13 < 2) { + if ((ushort)(rc_ss->rate_stats[uVar15].probability + 0xe667) < 0xd99b) { + uVar7 = '\n'; + } + else { + uVar7 = '\x05'; + } + } + else { + uVar7 = ((char)*(undefined2 *)((int)&rc_ss->avg_ampdu_len + 2) + '\b') * '\x02'; + } + rc_ss->sample_wait = uVar7; + next = next * 0x41c64e6d + 0x3039; + uVar5 = (next >> 0x10) % (uint)rc_ss->no_samples; + if (uVar5 != uVar15) { + uVar2 = rc_ss->retry[1].idx; + if (((uVar5 != (uint)uVar2) && (uVar18 = (uint)rc_ss->retry[2].idx, uVar5 != uVar18)) && + (puVar14 = &rc_ss->last_rc_time + uVar5 * 3, *(ushort *)(puVar14 + 2) < 0xf334)) { + rate_config = *(ushort *)((int)puVar14 + 10); + uVar10 = rc_get_duration((uint)rate_config); + rate_config_00 = rc_ss->rate_stats[uVar15].rate_config; + if (bVar13 < 2) { + uVar15 = rc_get_duration((uint)rate_config_00); + if (uVar15 < uVar10) { + uVar11 = 0; + bVar4 = 0x13 < *(byte *)(puVar14 + 3); + } + else { + uVar11 = 0; + bVar4 = true; + } + } + else { + uVar17 = 0x20; + uVar15 = rc_get_duration((uint)rc_ss->rate_stats[(uint)uVar2].rate_config); + if (*(char *)((int)puVar14 + 0xd) == '\0') { + uVar17 = (uint)*(ushort *)((int)&rc_ss->avg_ampdu_len + 2); + } + if (uVar15 <= uVar10) { + uVar7 = rc_get_nss(rate_config_00); + uVar8 = rc_get_nss(rate_config); + if ((CONCAT31(extraout_var_00,uVar7) - 1U < CONCAT31(extraout_var_01,uVar8)) || + (uVar15 = rc_get_duration((uint)rc_ss->rate_stats[uVar18].rate_config), + uVar15 <= uVar10)) { + if (uVar17 <= *(byte *)(puVar14 + 3)) { + bVar13 = rc_ss->sample_slow + 1; + rc_ss->sample_slow = bVar13; + if (bVar13 < 3) goto LAB_2300f85c; + if (0xf < bVar13) { + rc_ss->sample_slow = '\x0f'; + } + } + goto LAB_2300f836; + } + } +LAB_2300f85c: + uVar11 = rc_calc_tp(rc_ss,(uint8_t)uVar5); + bVar4 = true; + if ((*(byte *)((int)puVar14 + 0xe) & 0xf) < 10) { + bVar4 = uVar17 <= *(byte *)(puVar14 + 3); + } + } + uVar12 = rc_ss->retry[1].tp; + (rc_ss->max_tp_2_trial).idx = uVar2; + (rc_ss->max_tp_2_trial).tp = uVar12; + if (bVar4) { + uVar12 = rc_ss->retry[0].tp; + rc_ss->info = rc_ss->info & 0xfd; + rc_ss->retry[1].tp = uVar12; + rc_ss->retry[1].idx = uVar1; + rc_ss->retry[0].tp = uVar11; + rc_ss->retry[0].idx = (uint16_t)uVar5; + } + else { + rc_ss->info = rc_ss->info | 2; + rc_ss->retry[1].tp = uVar11; + rc_ss->retry[1].idx = (uint16_t)uVar5; + } + rc_ss->trial_status = '\x02'; + goto LAB_2300f79c; + } + } + } +LAB_2300f836: + rc_ss->trial_status = '\0'; + } + else { + if (rc_ss->trial_status == '\x03') { + if ((rc_ss->info & 2) == 0) { + rc_ss->retry[0].idx = rc_ss->retry[1].idx; + rc_ss->retry[0].tp = rc_ss->retry[1].tp; + } + uVar3 = (rc_ss->max_tp_2_trial).idx; + rc_ss->trial_status = '\0'; + rc_ss->retry[1].idx = uVar3; + uVar11 = (rc_ss->max_tp_2_trial).tp; + (rc_ss->max_tp_2_trial).tp = 0; + rc_ss->retry[1].tp = uVar11; + (rc_ss->max_tp_2_trial).idx = 0xff; + goto LAB_2300f79c; + } + } + if (iVar16 == 0) { + return; + } +LAB_2300f79c: + sta_info_tab[uVar9].pol_tbl.upd_field = sta_info_tab[uVar9].pol_tbl.upd_field | 1; + return; +} + + + +uint8_t rxu_cntrl_machdr_len_get(uint16_t frame_cntl) + +{ + uint8_t uVar1; + + uVar1 = '\x18'; + if ((frame_cntl & 0x300) == 0x300) { + uVar1 = '\x1e'; + } + if ((frame_cntl & 0xfc) == 0x88) { + uVar1 = uVar1 + '\x02'; + } + if ((short)frame_cntl < 0) { + uVar1 = uVar1 + '\x04'; + } + return uVar1; +} + + + +_Bool rxu_cntrl_protected_handle(uint8_t *frame,uint32_t statinfo) + +{ + ushort *puVar1; + uint uVar2; + vif_info_tag *pvVar3; + int iVar4; + + uVar2 = statinfo & 0x1c; + puVar1 = (ushort *)(frame + DAT_42021538); + if (uVar2 == 0x18) { + DAT_42021538 = DAT_42021538 + 8; + DAT_42021544 = (uint)puVar1[3]; + DAT_42021540 = (uint)puVar1[2] << 0x10 | (uint)*(byte *)(puVar1 + 1) | + ((uint)*puVar1 & 0xff) << 8; + DAT_42021560 = DAT_42021560 | 3; + if ((statinfo & 0x400) == 0) { + iVar4 = (uint)DAT_42021539 * 0x1b0 + 0x40; + pvVar3 = (vif_info_tag *)sta_info_tab; + } + else { + iVar4 = (uint)(puVar1[1] >> 0xe) * 0x68 + (uint)DAT_4202153a * 0x5d8 + 0x420; + pvVar3 = vif_info_tab; + } + key = (key_info_tag *)((int)&(pvVar3->list_hdr).next + iVar4); + } + else { + if (uVar2 == 0x1c) { + if ((statinfo & 0x400) == 0) { + iVar4 = (uint)DAT_42021539 * 0x1b0 + 0x40; + pvVar3 = (vif_info_tag *)sta_info_tab; + } + else { + iVar4 = (uint)(puVar1[1] >> 0xe) * 0x68 + (uint)DAT_4202153a * 0x5d8 + 0x420; + pvVar3 = vif_info_tab; + } + key = (key_info_tag *)((int)&(pvVar3->list_hdr).next + iVar4); + DAT_42021538 = DAT_42021538 + 8; + DAT_42021544 = (uint)puVar1[3]; + DAT_42021540 = CONCAT22(puVar1[2],*puVar1); + DAT_42021560 = DAT_42021560 | 2; + } + else { + if (uVar2 != 0x14) { + return false; + } + DAT_42021538 = DAT_42021538 + 4; + } + } + return true; +} + + +/* +Unable to decompile 'rxu_mpdu_upload_and_indicate' +Cause: Exception while decompiling 2300fa38: Decompiler process died + +*/ + + +undefined4 rxu_mgt_frame_check(rx_swdesc *param_1,uint param_2) + +{ + char cVar1; + ushort length; + bool bVar2; + ushort uVar3; + int8_t iVar4; + ushort *bcn_addr; + ushort uVar5; + _Bool _Var6; + ke_state_t kVar7; + undefined3 extraout_var; + undefined2 extraout_var_01; + undefined2 extraout_var_02; + undefined3 extraout_var_00; + undefined2 *puVar8; + byte sta_idx; + byte bw; + uint8_t nss; + co_list_hdr cVar9; + char *pcVar10; + uint uVar11; + uint uVar12; + ke_task_id_t dest_id; + rx_dmadesc *prVar13; + uint uVar14; + vif_info_tag *vif; + int8_t iStack73; + phy_channel_info apStack72 [2]; + + sta_idx = (byte)param_2; + prVar13 = param_1->dma_hdrdesc; + iStack73 = '\0'; + bcn_addr = *(ushort **)((prVar13->hd).first_pbd_ptr + 0x18); + length = *bcn_addr; + if ((length & 0x400) != 0) { + return 1; + } + if ((*(byte *)(bcn_addr + 0xb) & 0xf) != 0) { + return 1; + } + if ((param_2 == 0xff) && (DAT_4202153a = 0xff, ((prVar13->hd).statinfo & 0x600) == 0)) { + cVar9 = (co_list_hdr)vif_mgmt_env.used_list.first; + if (((length == 0xb0) || (bVar2 = true, length == 0)) && + ((((bVar2 = true, *(char *)(bcn_addr + 2) == *(char *)(bcn_addr + 8) && + (*(char *)((int)bcn_addr + 5) == *(char *)((int)bcn_addr + 0x11))) && + (*(char *)(bcn_addr + 3) == *(char *)(bcn_addr + 9))) && + ((*(char *)((int)bcn_addr + 7) == *(char *)((int)bcn_addr + 0x13) && + (*(char *)(bcn_addr + 4) == *(char *)(bcn_addr + 10))))))) { + bVar2 = *(char *)((int)bcn_addr + 9) != *(char *)((int)bcn_addr + 0x15); + } + while (DAT_4202153a = sta_idx, cVar9 != (co_list_hdr)0x0) { + if (((*(char *)&((co_list_hdr *)((int)cVar9 + 0x50))->next == *(char *)(bcn_addr + 2)) && + (*(char *)((int)cVar9 + 0x51) == *(char *)((int)bcn_addr + 5))) && + ((*(char *)((int)cVar9 + 0x52) == *(char *)(bcn_addr + 3) && + (((*(char *)((int)cVar9 + 0x53) == *(char *)((int)bcn_addr + 7) && + (*(char *)&((co_list_hdr *)((int)cVar9 + 0x54))->next == *(char *)(bcn_addr + 4))) && + (*(char *)((int)cVar9 + 0x55) == *(char *)((int)bcn_addr + 9))))))) { + if (*(char *)((int)cVar9 + 0x56) == '\0') { + if (bVar2) { +LAB_2300fc76: + DAT_4202153a = *(byte *)((int)cVar9 + 0x57); + break; + } + } + else { + if ((*(char *)((int)cVar9 + 0x56) == '\x02') && (!bVar2)) goto LAB_2300fc76; + } + } + cVar9 = *(co_list_hdr *)cVar9; + } + } + phyif_utils_decode((phyif_utils_recvtable_t *)&(prVar13->hd).recvec1a,&iStack73); + iVar4 = iStack73; + bw = DAT_42021538; + uVar3 = *bcn_addr; + uVar14 = (uint)DAT_42021538; + uVar11 = (uint)DAT_4202153a; + length = (prVar13->hd).frmlen; + uVar12 = (uint)length; + if (DAT_4202153a == 0xff) { + if (param_2 != uVar11) { + DAT_4202153a = sta_info_tab[param_2].inst_nbr; + uVar11 = (uint)DAT_4202153a; + goto LAB_2300fcc4; + } + nss = '\x04'; + vif = (vif_info_tag *)0x0; + } + else { +LAB_2300fcc4: + vif = vif_info_tab + uVar11; + nss = vif_info_tab[uVar11].type; + } + uVar5 = uVar3 & 0xfc; + if (uVar5 == 0x50) { + if (vif == (vif_info_tag *)0x0) goto LAB_2300fd00; + bVar2 = true; + dest_id = 4; + goto LAB_2300fe20; + } + if (uVar5 < 0x51) { + if (uVar5 == 0x20) { +LAB_2300fd4e: + _Var6 = apm_embedded_enabled(vif); + if (CONCAT31(extraout_var,_Var6) == 0) { +LAB_2300fd00: + rxu_mpdu_upload_and_indicate(param_1); + return 1; + } +LAB_2300fe1c: + bVar2 = true; + dest_id = 7; + goto LAB_2300fe20; + } + if (uVar5 < 0x21) { + if ((uVar3 & 0xfc) == 0) goto LAB_2300fd4e; + if (uVar5 != 0x10) goto LAB_2300fd00; + } + else { + if (uVar5 != 0x30) { + if (uVar5 != 0x40) goto LAB_2300fd00; + goto LAB_2300fd4e; + } + } + if (nss != '\0') goto LAB_2300fd00; + } + else { + if (uVar5 != 0xb0) { + if (0xb0 < uVar5) { + if (uVar5 != 0xc0) { + if ((uVar5 != 0xd0) || (pcVar10 = (char *)((int)bcn_addr + uVar14), param_2 == 0xff)) + goto LAB_2300fd00; + cVar1 = *pcVar10; + if (cVar1 == '\a') { + if (pcVar10[1] == '\0') { + if ((sta_info_tab[param_2].info.capa_flags & 2) == 0) { + return 0; + } + bw = pcVar10[2]; + nss = -1; + if (1 < bw) { + return 0; + } + } + else { + if (pcVar10[1] != '\x01') goto LAB_2300fd00; + if ((sta_info_tab[param_2].info.capa_flags & 2) == 0) { + return 0; + } + nss = -1; + if ((pcVar10[2] & 1U) != 0) { + nss = '\0'; + } + bw = 0xff; + } + me_sta_bw_nss_max_upd(sta_idx,bw,nss); + return 0; + } + if (cVar1 == '\b') { + if ((int)(uVar12 - uVar14) < 4) { + return 0; + } + if ((DAT_4202153a == 0xff) || + ((byte)(vif_info_tab[DAT_4202153a].type | pcVar10[1]) != 0)) goto LAB_2300fd00; + dest_id = 6; + } + else { + if (cVar1 != '\x03') goto LAB_2300fd00; + dest_id = 8; + } + bVar2 = false; + goto LAB_2300fe20; + } +LAB_2300fd74: + if (param_2 == 0xff) { + return 0; + } + goto LAB_2300fd7e; + } + if (uVar5 != 0x80) { + if (uVar5 != 0xa0) goto LAB_2300fd00; + goto LAB_2300fd74; + } + kVar7 = ke_state_get(4); + bVar2 = CONCAT22(extraout_var_01,kVar7) != 1; + if (bVar2) { + dest_id = 0xff; + } + else { + dest_id = 4; + } + bVar2 = !bVar2; + if (param_2 != 0xff) { + if (vif->active != false) { + me_beacon_check(DAT_4202153a,length,(uint32_t)bcn_addr); + } +LAB_2300fdf6: + if (dest_id != 0xff) goto LAB_2300fe20; + goto LAB_2300fd00; + } + kVar7 = ke_state_get(4); + if ((CONCAT22(extraout_var_02,kVar7) == 1) || + (_Var6 = apm_embedded_enabled(vif), CONCAT31(extraout_var_00,_Var6) == 0)) + goto LAB_2300fdf6; + goto LAB_2300fe1c; + } +LAB_2300fd7e: + if (nss != '\0') goto LAB_2300fd4e; + } + bVar2 = false; + dest_id = 6; +LAB_2300fe20: + puVar8 = (undefined2 *) + ke_msg_alloc(0x2c00,dest_id,0xb,(uint16_t)((uVar12 + 0x1c) * 0x10000 >> 0x10)); + if (puVar8 != (undefined2 *)0x0) { + phy_get_channel(apStack72,'\0'); + if (!bVar2) { + if ((bw & 1) != 0) { + assert_warn("(machdr_length & 0x1) == 0","module",0x64d); + } + uVar12 = uVar12 - uVar14 & 0xffff; + bcn_addr = (ushort *)((int)bcn_addr + uVar14); + } + *puVar8 = (short)uVar12; + uVar11 = 0; + while (bw = DAT_4202153a, (uVar12 + 3 & 0xfffffffc) != uVar11) { + *(undefined4 *)((int)puVar8 + uVar11 + 0x1c) = *(undefined4 *)((int)bcn_addr + uVar11); + uVar11 = uVar11 + 4; + } + puVar8[1] = uVar3; + *(byte *)((int)puVar8 + 7) = sta_idx; + *(byte *)(puVar8 + 4) = bw; + *(int8_t *)(puVar8 + 0xd) = iVar4; + *(int8_t *)((int)puVar8 + 0x19) = iVar4; + puVar8[2] = (short)(apStack72[0].info1 >> 0x10); + *(char *)(puVar8 + 3) = (char)apStack72[0].info1; + *(undefined *)(puVar8 + 0xc) = *(undefined *)((int)&(prVar13->hd).recvec1c + 3); + if ((dest_id == 7) && ((uVar3 & 0xfc) == 0)) { + *(uint32_t *)(puVar8 + 8) = (prVar13->hd).tsflo; + *(uint32_t *)(puVar8 + 10) = (prVar13->hd).tsfhi; + *(byte *)((int)puVar8 + 0x1b) = (byte)((prVar13->hd).recvec1a >> 0xc) & 0xf; + } + ke_msg_send(puVar8); + } + return 0; +} + + + +void rxu_cntrl_init(void) + +{ + co_list_init((co_list *)&swdesc); + co_list_init((co_list *)&DAT_42021568); + co_list_init((co_list *)&DAT_4202157c); + co_list_init((co_list *)&DAT_42021584); + DAT_42021592 = 0xffff; + return; +} + + +/* +Unable to decompile 'rxu_cntrl_frame_handle' +Cause: Exception while decompiling 2300fffa: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxu_cntrl_monitor_pm(mac_addr *addr) + +{ + if (DAT_4202159f == '\0') { + _DAT_42021598 = addr->array[0]; + _DAT_4202159a = addr->array[1]; + _DAT_4202159c = addr->array[2]; + _DAT_4202159e = 0x100; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t rxu_cntrl_get_pm(void) + +{ + _DAT_4202159e = 0; + return DAT_4202159e; +} + + + +void rxu_cntrl_evt(int dummy) + +{ + ke_evt_clear(0x80000); + if (swdesc != (rx_swdesc *)0x0) { + ke_evt_set(0x20000000); + return; + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: pkt + +void rxu_swdesc_upload_evt(int arg) + +{ + rx_swdesc *swdesc; + uint uVar1; + int iVar2; + uint32_t uVar3; + uint32_t *puVar4; + uint32_t *puVar5; + uint32_t uVar6; + uint32_t local_48; + wifi_pkt pkt; + + ke_evt_clear(0x20000000); + swdesc = (rx_swdesc *)co_list_pop_front((co_list *)&swdesc); + while (swdesc != (rx_swdesc *)0x0) { + uVar1 = (uint)(swdesc->dma_hdrdesc->hd).frmlen; + memset(&local_48,0,0x28); + puVar4 = (uint32_t *)&local_48; + uVar6 = (swdesc->dma_hdrdesc->hd).first_pbd_ptr; + puVar5 = puVar4; + while ((uVar1 != 0 && (puVar5 != pkt.pkt + 3))) { + swdesc->pbd_count = swdesc->pbd_count + '\x01'; + uVar3 = *(uint32_t *)(uVar6 + 8); + *puVar5 = uVar3; + *(short *)(puVar4 + 8) = ((short)*(undefined4 *)(uVar6 + 0xc) + 1) - (short)uVar3; + puVar5[4] = uVar6 + 0x1c; + *(undefined4 *)(uVar6 + 0x14) = 1; + if (uVar1 < 0x350) { + uVar1 = 0; + } + else { + uVar1 = uVar1 - 0x350; + } + uVar6 = *(uint32_t *)(uVar6 + 4); + puVar5 = puVar5 + 1; + puVar4 = (uint32_t *)((int)puVar4 + 2); + } + swdesc->use_in_tcpip = '\x01'; + swdesc->dma_hdrdesc->use_in_tcpip = 1; + iVar2 = tcpip_stack_input(swdesc,swdesc->status,&(swdesc->dma_hdrdesc->hd).frmlen, + swdesc->dma_hdrdesc->payl_offset,(wifi_pkt *)&local_48); + if (iVar2 == 0) { + vTaskEnterCritical(); + rxl_cntrl_env.packet_stack_cnt = rxl_cntrl_env.packet_stack_cnt + swdesc->pbd_count; + vTaskExitCritical(); + } + else { + rxl_mpdu_free(swdesc); + } + swdesc = (rx_swdesc *)co_list_pop_front((co_list *)&swdesc); + } + return; +} + + + +void scanu_confirm(uint8_t status) + +{ + uint8_t *puVar1; + uint8_t *puVar2; + + if (scanu_env.joining == false) { + puVar2 = (uint8_t *)ke_msg_alloc(0x1001,scanu_env.src_id,4,1); + puVar1 = (uint8_t *)0x0; + } + else { + puVar2 = (uint8_t *)ke_msg_alloc(0x1003,scanu_env.src_id,4,1); + puVar1 = (uint8_t *)ke_msg_alloc(0x1003,0xd,4,1); + } + *puVar2 = status; + ke_msg_free(&scanu_env.param[-1].add_ies); + scanu_env.param = (scanu_start_req *)0x0; + ke_msg_send(puVar2); + if (puVar1 != (uint8_t *)0x0) { + *puVar1 = status; + ke_msg_send(puVar1); + } + ke_state_set(4,0); + return; +} + + + +void scanu_raw_send_cfm(uint8_t status,ke_task_id_t dst_id) + +{ + undefined3 in_register_00002029; + undefined4 *puVar1; + + puVar1 = (undefined4 *)ke_msg_alloc(0x1006,dst_id,4,4); + *puVar1 = CONCAT31(in_register_00002029,status); + ke_msg_send(); + return; +} + + + +void scanu_init(void) + +{ + ke_state_set(4,0); + memset(&scanu_env,0,0x194); + scanu_env.dma_desc.dma_desc = &scanu_add_ie; + scanu_env.dma_desc.cb = scanu_dma_cb; + scanu_env.dma_desc.env = (void *)0x0; + scanu_add_ie.dma_desc.dest = 0x42045ddc; + return; +} + + + +mac_scan_result * scanu_find_result(mac_addr *bssid_ptr,_Bool allocate) + +{ + undefined3 in_register_0000202d; + mac_scan_result *pmVar1; + + pmVar1 = scanu_env.scan_result; + do { + if (pmVar1->valid_flag == false) { + if (CONCAT31(in_register_0000202d,allocate) != 0) { + return pmVar1; + } + } + else { + if ((((*(char *)(pmVar1->bssid).array == *(char *)bssid_ptr->array) && + (*(char *)((int)(pmVar1->bssid).array + 1) == *(char *)((int)bssid_ptr->array + 1))) && + (*(char *)((pmVar1->bssid).array + 1) == *(char *)(bssid_ptr->array + 1))) && + (((*(char *)((int)(pmVar1->bssid).array + 3) == *(char *)((int)bssid_ptr->array + 3) && + (*(char *)((pmVar1->bssid).array + 2) == *(char *)(bssid_ptr->array + 2))) && + (*(char *)((int)(pmVar1->bssid).array + 5) == *(char *)((int)bssid_ptr->array + 5))))) { + return pmVar1; + } + } + pmVar1 = pmVar1 + 1; + if (pmVar1 == (mac_scan_result *)&scanu_env.src_id) { + return (mac_scan_result *)0x0; + } + } while( true ); +} + + + +// WARNING: Restarted to delay deadcode elimination for space: ram + +undefined4 scanu_frame_handler(ushort *param_1) + +{ + undefined uVar1; + uint8_t band; + _Bool _Var2; + ushort uVar3; + scanu_start_req *psVar4; + sm_connect_req *psVar5; + uchar uVar6; + ke_state_t kVar7; + uint16_t uVar8; + int iVar9; + undefined2 extraout_var; + mac_scan_result *pmVar10; + scan_chan_tag *psVar11; + void *__src; + byte bVar12; + uint16_t freq; + uint __n; + undefined *puVar13; + uint8_t *puVar14; + undefined *puVar15; + uint8_t *rsn_ie; + SecurityMode_t *security_mode; + char cVar16; + uint uVar17; + uint uVar18; + mac_bss_info *bss; + int iVar19; + Cipher_t *mcstCipher; + Cipher_t *mcstCipher_00; + Cipher_t *ucstCipher; + uint32_t uVar20; + mac_ssid *pmVar21; + uint uVar22; + ushort *buffer; + mac_rateset *mac_rate_set_ptr; + Cipher_t *ucstCipher_00; + undefined uStack100; + undefined local_63 [47]; + + psVar4 = scanu_env.param; + buffer = param_1 + 0x20; + uVar22 = (uint)(scanu_env.param)->vif_idx; + iVar9 = mac_ie_find(buffer,(uint)*param_1 - 0x24 & 0xffff,0); + if (iVar9 != 0) { + bVar12 = *(byte *)(iVar9 + 1); + uVar17 = (uint)bVar12; + if (bVar12 < 0x21) { + if (bVar12 == 0) goto LAB_23010bda; + } + else { + uVar17 = 0x20; + } + puVar13 = (undefined *)(iVar9 + 2); + if (*(char *)(iVar9 + 2) != '\0') { + uStack100 = (undefined)uVar17; + puVar15 = &uStack100; + uVar18 = uVar17; + while( true ) { + uVar18 = uVar18 - 1; + puVar15 = puVar15 + 1; + if (uVar18 == 0xffffffff) break; + uVar1 = *puVar13; + puVar13 = puVar13 + 1; + *puVar15 = uVar1; + } + local_63[uVar17] = 0; + } + } +LAB_23010bda: + kVar7 = ke_state_get(4); + if (((CONCAT22(extraout_var,kVar7) != 1) || + (pmVar10 = scanu_find_result((mac_addr *)(param_1 + 0x16),true), + pmVar10 == (mac_scan_result *)0x0)) || + ((((byte)scanu_env.bssid.array[0] & 1) == 0 && + (((((*(byte *)(param_1 + 0x16) != (byte)scanu_env.bssid.array[0] || + (*(char *)((int)param_1 + 0x2d) != scanu_env.bssid.array[0]._1_1_)) || + (*(char *)(param_1 + 0x17) != (char)scanu_env.bssid.array[1])) || + ((*(char *)((int)param_1 + 0x2f) != scanu_env.bssid.array[1]._1_1_ || + (*(char *)(param_1 + 0x18) != (char)scanu_env.bssid.array[2])))) || + (*(char *)((int)param_1 + 0x31) != scanu_env.bssid.array[2]._1_1_)))))) goto LAB_23011310; + (pmVar10->bssid).array[0] = param_1[0x16]; + (pmVar10->bssid).array[1] = param_1[0x17]; + (pmVar10->bssid).array[2] = param_1[0x18]; + pmVar10->beacon_period = param_1[0x1e]; + uVar3 = param_1[0x1f]; + pmVar10->cap_info = uVar3; + freq = uVar3 & 1; + if ((uVar3 & 1) == 0) { + freq = 2; + } + pmVar10->bsstype = freq; + uVar3 = *param_1; + uVar17 = (uint)uVar3 - 0x24 & 0xffff; + iVar9 = mac_ie_find(buffer,uVar17,0); + if (iVar9 == 0) { + (pmVar10->ssid).length = '\0'; + } + else { + bVar12 = *(byte *)(iVar9 + 1); + uVar18 = (uint)bVar12; + if (bVar12 < 0x21) { + if (bVar12 == 0) goto LAB_23010cae; + } + else { + uVar18 = 0x20; + } + rsn_ie = (uint8_t *)(iVar9 + 2); + if (*(char *)(iVar9 + 2) != '\0') { + (pmVar10->ssid).length = (uint8_t)uVar18; + puVar14 = (pmVar10->ssid).array; + while (uVar18 = uVar18 - 1, uVar18 != 0xffffffff) { + band = *rsn_ie; + rsn_ie = rsn_ie + 1; + *puVar14 = band; + puVar14 = puVar14 + 1; + } + } + } +LAB_23010cae: + pmVar10->ppm_rel = *(int8_t *)(param_1 + 0xd); + pmVar10->ppm_abs = *(int8_t *)((int)param_1 + 0x19); + if (psVar4->ssid_cnt != '\0') { + uVar18 = 0; + pmVar21 = psVar4->ssid; + while ((int)uVar18 < (int)(uint)psVar4->ssid_cnt) { + if (pmVar21->length == 0) goto LAB_23010d4c; + __n = (uint)(pmVar10->ssid).length; + if ((__n == (uint)pmVar21->length) && + (iVar9 = memcmp(pmVar21->array,(pmVar10->ssid).array,__n), iVar9 == 0)) break; + uVar18 = uVar18 + 1; + pmVar21 = pmVar21 + 1; + } + if ((uint)psVar4->ssid_cnt == uVar18) goto LAB_23011310; + } +LAB_23010d4c: + iVar9 = mac_ie_find(buffer,uVar17,3); + if (iVar9 == 0) { + if (pmVar10->rssi < *(char *)(param_1 + 0xc)) { + psVar11 = me_freq_to_chan_ptr(*(uint8_t *)(param_1 + 3),param_1[2]); + pmVar10->chan = psVar11; + cVar16 = *(char *)(param_1 + 0xc); + goto LAB_23010d9c; + } + } + else { + bVar12 = *(byte *)(iVar9 + 2); + band = *(uint8_t *)(param_1 + 3); + if (band == '\0') { + if ((uint)bVar12 - 1 < 0xe) { + if (bVar12 == 0xe) { + freq = 0x9b4; + } + else { + freq = (ushort)bVar12 * 5 + 0x967; + } + } + else { +LAB_230111fa: + freq = 0xffff; + } + } + else { + if ((band != '\x01') || (0xa4 < (uint)bVar12 - 1)) goto LAB_230111fa; + freq = (ushort)bVar12 * 5 + 5000; + } + psVar11 = me_freq_to_chan_ptr(band,freq); + pmVar10->chan = psVar11; + cVar16 = *(char *)(param_1 + 0xc); + if (pmVar10->rssi < cVar16) { +LAB_23010d9c: + pmVar10->rssi = cVar16; + } + } + if (scanu_env.joining != false) { + bss = &vif_info_tab[uVar22].bss_info; + vif_info_tab[uVar22].bss_info.bsstype = pmVar10->bsstype; + mac_rate_set_ptr = &vif_info_tab[uVar22].bss_info.rate_set; + *(undefined4 *)vif_info_tab[uVar22].bss_info.bssid.array = *(undefined4 *)(pmVar10->bssid).array + ; + vif_info_tab[uVar22].bss_info.bssid.array[2] = (pmVar10->bssid).array[2]; + vif_info_tab[uVar22].bss_info.cap_info = pmVar10->cap_info; + vif_info_tab[uVar22].bss_info.beacon_period = pmVar10->beacon_period; + memcpy(&vif_info_tab[uVar22].bss_info.ssid,&pmVar10->ssid,0x22); + psVar11 = pmVar10->chan; + vif_info_tab[uVar22].bss_info.valid_flags = 0; + vif_info_tab[uVar22].bss_info.chan = psVar11; + vif_info_tab[uVar22].bss_info.ppm_rel = pmVar10->ppm_rel; + vif_info_tab[uVar22].bss_info.ppm_abs = pmVar10->ppm_abs; + freq = (uint16_t)(((uint)uVar3 - 0x24) * 0x10000 >> 0x10); + me_extract_rate_set((uint32_t)buffer,freq,mac_rate_set_ptr); + if (pmVar10->chan->band == '\0') { + uVar8 = me_legacy_rate_bitfield_build(mac_rate_set_ptr,true); + if ((uVar8 & 0xf) == 0) { + vif_info_tab[uVar22].bss_info.high_11b_rate = '\x01'; + } + else { + iVar9 = __clzsi2((uint)uVar8 & 0xf); + vif_info_tab[uVar22].bss_info.high_11b_rate = '\x1f' - (char)iVar9; + } + } + iVar9 = mac_vsie_find(buffer,uVar17,&DAT_230ac5c8,5); + if (iVar9 == 0) { + vif_info_tab[uVar22].bss_info.edca_param.ac_param[0] = 0xa43; + vif_info_tab[uVar22].bss_info.edca_param.ac_param[1] = 0xa43; + vif_info_tab[uVar22].bss_info.edca_param.ac_param[2] = 0xa43; + vif_info_tab[uVar22].bss_info.edca_param.ac_param[3] = 0xa43; + } + else { + vif_info_tab[uVar22].bss_info.edca_param.qos_info = *(uint8_t *)(iVar9 + 8); + vif_info_tab[uVar22].bss_info.cap_info = vif_info_tab[uVar22].bss_info.cap_info | 0x200; + uVar18 = *(uint *)(iVar9 + 10); + bVar12 = (byte)(uVar18 >> 3) & 2; + vif_info_tab[uVar22].bss_info.edca_param.acm = bVar12; + vif_info_tab[uVar22].bss_info.edca_param.ac_param[1] = uVar18 & 0xf | (uVar18 >> 8) << 4; + uVar18 = *(uint *)(iVar9 + 0xe); + bVar12 = (byte)(uVar18 >> 4) & 1 | bVar12; + vif_info_tab[uVar22].bss_info.edca_param.acm = bVar12; + vif_info_tab[uVar22].bss_info.edca_param.ac_param[0] = uVar18 & 0xf | (uVar18 >> 8) << 4; + uVar18 = *(uint *)(iVar9 + 0x12); + bVar12 = bVar12 | (byte)(uVar18 >> 2) & 4; + vif_info_tab[uVar22].bss_info.edca_param.acm = bVar12; + vif_info_tab[uVar22].bss_info.edca_param.ac_param[2] = uVar18 & 0xf | (uVar18 >> 8) << 4; + uVar18 = *(uint *)(iVar9 + 0x16); + vif_info_tab[uVar22].bss_info.edca_param.acm = bVar12 | (byte)(uVar18 >> 1) & 8; + __n = vif_info_tab[uVar22].bss_info.valid_flags; + vif_info_tab[uVar22].bss_info.edca_param.ac_param[3] = uVar18 & 0xf | (uVar18 >> 8) << 4; + vif_info_tab[uVar22].bss_info.valid_flags = __n | 1; + } + uVar18 = 0; + if (me_env.ht_supported != false) { + uVar18 = vif_info_tab[uVar22].bss_info.valid_flags & 1; + if (uVar18 != 0) { + iVar9 = mac_ie_find(buffer,uVar17,0x2d); + if (iVar9 != 0) { + vif_info_tab[uVar22].bss_info.ht_cap.ht_capa_info = *(uint16_t *)(iVar9 + 2); + vif_info_tab[uVar22].bss_info.ht_cap.a_mpdu_param = *(uint8_t *)(iVar9 + 4); + iVar19 = 0; + do { + vif_info_tab[uVar22].bss_info.ht_cap.mcs_rate[iVar19] = *(uint8_t *)(iVar9 + 5 + iVar19) + ; + iVar19 = iVar19 + 1; + } while (iVar19 != 0x10); + vif_info_tab[uVar22].bss_info.ht_cap.ht_extended_capa = *(uint16_t *)(iVar9 + 0x15); + vif_info_tab[uVar22].bss_info.ht_cap.tx_beamforming_capa = (uint)*(ushort *)(iVar9 + 0x17) + ; + vif_info_tab[uVar22].bss_info.ht_cap.asel_capa = *(uint8_t *)(iVar9 + 0x1b); + vif_info_tab[uVar22].bss_info.valid_flags = vif_info_tab[uVar22].bss_info.valid_flags | 2; + } + uVar18 = mac_ie_find(buffer,uVar17,0x3d); + } + } + _Var2 = (sm_env.connect_param)->is_supplicant_enabled; + vif_info_tab[uVar22].bss_info.is_supplicant_enabled = _Var2; + if ((_Var2 != false) && (-1 < (int)vif_info_tab[uVar22].bss_info.valid_flags)) { + security_mode = &vif_info_tab[uVar22].bss_info.wpa_wpa2_wep; + memset(security_mode,0,2); + mcstCipher = &vif_info_tab[uVar22].bss_info.rsn_mcstCipher; + ucstCipher_00 = &vif_info_tab[uVar22].bss_info.rsn_ucstCipher; + memset(mcstCipher,0,1); + memset(ucstCipher_00,0,1); + mcstCipher_00 = &vif_info_tab[uVar22].bss_info.wpa_mcstCipher; + memset(mcstCipher_00,0,1); + ucstCipher = &vif_info_tab[uVar22].bss_info.wpa_ucstCipher; + memset(ucstCipher,0,1); + vif_info_tab[uVar22].bss_info.rsn_wpa_ie_len = '\0'; + vif_info_tab[uVar22].bss_info.is_pmf_required = false; + vif_info_tab[uVar22].bss_info.is_wpa2_prefered = false; + __src = (void *)mac_ie_find(buffer,uVar17,0x30); + rsn_ie = vif_info_tab[uVar22].bss_info.rsn_wpa_ie; + if (__src != (void *)0x0) { + __n = (uint)*(byte *)((int)__src + 1) + 2 & 0xff; + vif_info_tab[uVar22].bss_info.rsn_wpa_ie_len = (uint8_t)__n; + memcpy(rsn_ie,__src,__n); + uVar6 = process_rsn_ie(rsn_ie,mcstCipher,ucstCipher_00, + &vif_info_tab[uVar22].bss_info.is_pmf_required,security_mode, + *(_Bool *)(uVar22 * 0x5d8 + 0x42020368)); + __n = *(uint *)&vif_info_tab[uVar22].bss_info.wpa_ucstCipher; + vif_info_tab[uVar22].bss_info.rsn_wpa_ie_len = uVar6; + printf("wpa2/wpa3 pairwise ccmp:%d,tkip:%d,wep104:%d,wep:40:%d\r\n",__n >> 0x13 & 1, + __n >> 0x12 & 1,__n >> 0x11 & 1,__n >> 0x10 & 1); + __n = *(uint *)&vif_info_tab[uVar22].bss_info.wpa_ucstCipher; + printf("wpa2/wpa3 group ccmp:%d,tkip:%d,wep104:%d,wep:40:%d\r\n",__n >> 0xb & 1, + __n >> 10 & 1,__n >> 9 & 1,__n >> 8 & 1); + printf("wpa2/wpa3 is_pmf_required:%d\r\n", + (uint)vif_info_tab[uVar22].bss_info.is_pmf_required); + } + __src = (void *)mac_vsie_find(buffer,uVar17,&DAT_230ac5d0,4); + if (__src != (void *)0x0) { + *(byte *)&vif_info_tab[uVar22].bss_info.wpa_wpa2_wep = + *(byte *)&vif_info_tab[uVar22].bss_info.wpa_wpa2_wep | 8; + if (vif_info_tab[uVar22].bss_info.rsn_wpa_ie_len == '\0') { + __n = (uint)*(byte *)((int)__src + 1) + 2 & 0xff; + vif_info_tab[uVar22].bss_info.rsn_wpa_ie_len = (uint8_t)__n; + memcpy(rsn_ie,__src,__n); + uVar6 = process_wpa_ie(rsn_ie,mcstCipher_00,ucstCipher); + vif_info_tab[uVar22].bss_info.rsn_wpa_ie_len = uVar6; + } + } + psVar5 = sm_env.connect_param; + (sm_env.connect_param)->flags = 0; + if ((*(uint *)&vif_info_tab[uVar22].bss_info.is_supplicant_enabled & 0x12800) == 0) { + if ((vif_info_tab[uVar22].bss_info.cap_info & 0x10) == 0) { + uVar20 = 2; + goto LAB_230111cc; + } + *(byte *)&vif_info_tab[uVar22].bss_info.wpa_wpa2_wep = + *(byte *)&vif_info_tab[uVar22].bss_info.wpa_wpa2_wep | 2; + psVar5->auth_type = '\x01'; + } + else { + uVar20 = 9; +LAB_230111cc: + psVar5->flags = uVar20; + } + memcpy(psVar5->ie_buf,rsn_ie,(uint)vif_info_tab[uVar22].bss_info.rsn_wpa_ie_len); + (sm_env.connect_param)->ie_len = (ushort)vif_info_tab[uVar22].bss_info.rsn_wpa_ie_len; + __n = *(uint *)&vif_info_tab[uVar22].bss_info.is_supplicant_enabled; + printf("AP Security mode: wep:%d,wpa:%d,wpa2:%d,wpa3:%d\r\n",__n >> 9 & 1,__n >> 0xb & 1, + __n >> 0xd & 1,__n >> 0x10 & 1); + } + me_bw_check(uVar18,0,bss); + me_extract_power_constraint((uint32_t)buffer,freq,bss); + me_extract_country_reg(buffer,uVar17,bss); + me_extract_mobility_domain((uint32_t)buffer,freq,bss); + vif_info_tab[uVar22].bss_info.valid_flags = + vif_info_tab[uVar22].bss_info.valid_flags | 0x80000000; + } + if (pmVar10->valid_flag == false) { + scanu_env.result_cnt = scanu_env.result_cnt + 1; + } + if (psVar4->ssid_cnt != '\0') { + pmVar10->valid_flag = true; + } +LAB_23011310: + ke_msg_forward_and_change_id(param_1,0x1004,0xd,4); + return 1; +} + + + +mac_scan_result * scanu_search_by_bssid(mac_addr *bssid) + +{ + mac_scan_result *pmVar1; + + pmVar1 = scanu_find_result(bssid,false); + return pmVar1; +} + + + +mac_scan_result * scanu_search_by_ssid(mac_ssid *ssid,int *idx) + +{ + scanu_env_tag *psVar1; + int iVar2; + int iVar3; + mac_scan_result *pmVar4; + int8_t iVar5; + + pmVar4 = (mac_scan_result *)0x0; + if (ssid->length != '\0') { + psVar1 = &scanu_env; + iVar3 = 0; + pmVar4 = (mac_scan_result *)0x0; + iVar5 = -0x80; + do { + if (psVar1->scan_result[0].valid_flag == false) { + return pmVar4; + } + if (((iVar5 < psVar1->scan_result[0].rssi) && + ((uint)ssid->length == (uint)psVar1->scan_result[0].ssid.length)) && + (iVar2 = memcmp(psVar1->scan_result[0].ssid.array,ssid->array,(uint)ssid->length), + iVar2 == 0)) { + iVar5 = psVar1->scan_result[0].rssi; + pmVar4 = psVar1->scan_result; + *idx = iVar3; + } + iVar3 = iVar3 + 1; + psVar1 = (scanu_env_tag *)(psVar1->scan_result[0].ssid.array + 0x19); + } while (iVar3 != 6); + } + return pmVar4; +} + + + +void scanu_rm_exist_ssid(mac_ssid *ssid,int index) + +{ + int iVar1; + + if ((index < 0) || (ssid == (mac_ssid *)0x0)) { + return; + } + if (((scanu_env.scan_result[index].valid_flag != false) && + ((uint)ssid->length == (uint)scanu_env.scan_result[index].ssid.length)) && + (iVar1 = memcmp(scanu_env.scan_result[index].ssid.array,ssid->array,(uint)ssid->length), + iVar1 == 0)) { + memset(scanu_env.scan_result + index,0,0x38); + return; + } + return; +} + + + +void scanu_scan_next(void) + +{ + byte bVar1; + int iVar2; + scanu_start_req *psVar3; + uint uVar4; + void *pvVar5; + uint uVar6; + uint8_t *puVar7; + undefined *puVar8; + undefined *puVar9; + uint32_t *puVar10; + me_env_tag *pmVar11; + short sVar12; + int iVar13; + undefined *puVar14; + int iVar15; + scanu_add_ie_tag *psVar16; + uint8_t *puVar17; + uint uVar18; + int iVar19; + int iVar20; + + psVar3 = scanu_env.param; + while( true ) { + if (1 < scanu_env.band) { + scanu_confirm('\0'); + return; + } + uVar18 = 0; + puVar7 = &(scanu_env.param)->chan[0].band; + while ((int)uVar18 < (int)(uint)(scanu_env.param)->chan_cnt) { + if (*puVar7 == scanu_env.band) goto LAB_2301148a; + uVar18 = uVar18 + 1; + puVar7 = puVar7 + 6; + } + if ((uint)(scanu_env.param)->chan_cnt != uVar18) break; + scanu_env.band = scanu_env.band + '\x01'; + } +LAB_2301148a: + pvVar5 = ke_msg_alloc(0x800,2,4,0x154); + *(uint8_t *)((int)pvVar5 + 0x14e) = psVar3->vif_idx; + *(undefined4 *)((int)pvVar5 + 0x140) = *(undefined4 *)(psVar3->bssid).array; + *(uint16_t *)((int)pvVar5 + 0x144) = (psVar3->bssid).array[2]; + *(uint8_t *)((int)pvVar5 + 0x150) = psVar3->ssid_cnt; + *(_Bool *)((int)pvVar5 + 0x151) = psVar3->no_cck; + while ((int)uVar18 < (int)(uint)psVar3->chan_cnt) { + if (*(uint8_t *)(&psVar3->chan[uVar18].freq + 1) == scanu_env.band) { + bVar1 = *(byte *)((int)pvVar5 + 0x14f); + memcpy((void *)((uint)bVar1 * 6 + (int)pvVar5),psVar3->chan + uVar18,6); + *(char *)((int)pvVar5 + 0x14f) = bVar1 + 1; + } + uVar18 = uVar18 + 1; + } + iVar19 = 0xfc; + iVar20 = 0; + while (iVar20 < (int)(uint)psVar3->ssid_cnt) { + memcpy((void *)((int)pvVar5 + iVar19),(void *)((int)&psVar3->chan[0].freq + iVar19),0x22); + iVar20 = iVar20 + 1; + iVar19 = iVar19 + 0x22; + } + uVar18 = (uint)(scanu_env.param)->add_ie_len; + puVar10 = scanu_add_ie.buf; + if (200 < (scanu_env.param)->add_ie_len) { + uVar18 = 0; + } + if ((scanu_env.band == '\x01') || ((scanu_env.param)->no_cck != false)) { + iVar19 = 4; + iVar20 = 8; + } + else { + iVar19 = 0; + iVar20 = 0xc; + } + scan_probe_req_ie.buf[0]._0_1_ = 1; + scan_probe_req_ie.buf[0]._1_1_ = 8; + iVar13 = 0; + do { + iVar15 = iVar19 + iVar13; + iVar2 = iVar13 + 2; + iVar13 = iVar13 + 1; + *(uint8_t *)((int)scan_probe_req_ie.buf + iVar2) = mac_id2rate[iVar15]; + } while (iVar13 != 8); + puVar14 = (undefined *)((int)scan_probe_req_ie.buf + 10); + if ((uVar18 != 0) && ((char)scanu_add_ie.buf[0] == '\n')) { + uVar6 = (uint)scanu_add_ie.buf[0]._1_1_ + 2 & 0xff; + uVar4 = uVar6; + psVar16 = &scanu_add_ie; + while( true ) { + uVar4 = uVar4 - 1; + if (uVar4 == 0xffffffff) break; + *puVar14 = *(undefined *)psVar16->buf; + psVar16 = (scanu_add_ie_tag *)((int)&(psVar16->dma_desc).src + 1); + puVar14 = puVar14 + 1; + } + puVar14 = (undefined *)((int)scan_probe_req_ie.buf + uVar6 + 10); + puVar10 = (uint32_t *)((int)scanu_add_ie.buf + uVar6); + uVar18 = uVar18 - uVar6 & 0xffff; + } + if (iVar20 != 8) { + uVar4 = iVar20 - 8U & 0xff; + *puVar14 = 0x32; + puVar14[1] = (char)uVar4; + iVar19 = uVar4 + 2; + puVar7 = mac_id2rate; + puVar17 = puVar14 + 2; + while( true ) { + uVar4 = uVar4 - 1; + if (uVar4 == 0xffffffff) break; + *puVar17 = puVar7[8]; + puVar7 = puVar7 + 1; + puVar17 = puVar17 + 1; + } + puVar14 = puVar14 + iVar19; + } + if (scanu_env.band == '\0') { + *puVar14 = 3; + puVar14[1] = 1; + puVar14 = puVar14 + 3; + } + if ((uVar18 != 0) && (*(char *)puVar10 == ';')) { + uVar4 = 0; + uVar6 = (uint)*(byte *)((int)puVar10 + 1) + 2 & 0xff; + while (uVar6 != uVar4) { + puVar8 = (undefined *)((int)puVar10 + uVar4); + puVar9 = puVar14 + uVar4; + uVar4 = uVar4 + 1; + *puVar9 = *puVar8; + } + puVar14 = puVar14 + uVar6; + puVar10 = (uint32_t *)((int)puVar10 + uVar6); + uVar18 = uVar18 - uVar6 & 0xffff; + } + if (me_env.ht_supported != false) { + *puVar14 = 0x2d; + puVar14[1] = 0x1a; + puVar8 = puVar14 + 0x1c; + pmVar11 = &me_env; + puVar14 = puVar14 + 2; + while (puVar8 != puVar14) { + *puVar14 = *(undefined *)&(pmVar11->ht_cap).ht_capa_info; + pmVar11 = (me_env_tag *)((int)&pmVar11->active_vifs + 1); + puVar14 = puVar14 + 1; + } + } + sVar12 = (short)puVar14; + if (uVar18 != 0) { + uVar4 = 0; + do { + puVar8 = (undefined *)((int)puVar10 + uVar4); + puVar9 = puVar14 + uVar4; + uVar4 = uVar4 + 1; + *puVar9 = *puVar8; + } while (uVar18 != uVar4); + sVar12 = sVar12 + (short)uVar18; + } + *(short *)((int)pvVar5 + 0x14c) = sVar12 + -0x5d04; + *(undefined4 *)((int)pvVar5 + 0x148) = 0; + ke_msg_send(pvVar5); + return; +} + + + +void scanu_dma_cb(void) + +{ + byte bVar1; + int iVar2; + scanu_start_req *psVar3; + uint uVar4; + void *pvVar5; + uint uVar6; + uint8_t *puVar7; + undefined *puVar8; + undefined *puVar9; + uint32_t *puVar10; + me_env_tag *pmVar11; + short sVar12; + int iVar13; + undefined *puVar14; + int iVar15; + scanu_add_ie_tag *psVar16; + uint8_t *puVar17; + uint uVar18; + int iVar19; + int iVar20; + + psVar3 = scanu_env.param; + while( true ) { + if (1 < scanu_env.band) { + scanu_confirm('\0'); + return; + } + uVar18 = 0; + puVar7 = &(scanu_env.param)->chan[0].band; + while ((int)uVar18 < (int)(uint)(scanu_env.param)->chan_cnt) { + if (*puVar7 == scanu_env.band) goto LAB_2301148a; + uVar18 = uVar18 + 1; + puVar7 = puVar7 + 6; + } + if ((uint)(scanu_env.param)->chan_cnt != uVar18) break; + scanu_env.band = scanu_env.band + '\x01'; + } +LAB_2301148a: + pvVar5 = ke_msg_alloc(0x800,2,4,0x154); + *(uint8_t *)((int)pvVar5 + 0x14e) = psVar3->vif_idx; + *(undefined4 *)((int)pvVar5 + 0x140) = *(undefined4 *)(psVar3->bssid).array; + *(uint16_t *)((int)pvVar5 + 0x144) = (psVar3->bssid).array[2]; + *(uint8_t *)((int)pvVar5 + 0x150) = psVar3->ssid_cnt; + *(_Bool *)((int)pvVar5 + 0x151) = psVar3->no_cck; + while ((int)uVar18 < (int)(uint)psVar3->chan_cnt) { + if (*(uint8_t *)(&psVar3->chan[uVar18].freq + 1) == scanu_env.band) { + bVar1 = *(byte *)((int)pvVar5 + 0x14f); + memcpy((void *)((uint)bVar1 * 6 + (int)pvVar5),psVar3->chan + uVar18,6); + *(char *)((int)pvVar5 + 0x14f) = bVar1 + 1; + } + uVar18 = uVar18 + 1; + } + iVar19 = 0xfc; + iVar20 = 0; + while (iVar20 < (int)(uint)psVar3->ssid_cnt) { + memcpy((void *)((int)pvVar5 + iVar19),(void *)((int)&psVar3->chan[0].freq + iVar19),0x22); + iVar20 = iVar20 + 1; + iVar19 = iVar19 + 0x22; + } + uVar18 = (uint)(scanu_env.param)->add_ie_len; + puVar10 = scanu_add_ie.buf; + if (200 < (scanu_env.param)->add_ie_len) { + uVar18 = 0; + } + if ((scanu_env.band == '\x01') || ((scanu_env.param)->no_cck != false)) { + iVar19 = 4; + iVar20 = 8; + } + else { + iVar19 = 0; + iVar20 = 0xc; + } + scan_probe_req_ie.buf[0]._0_1_ = 1; + scan_probe_req_ie.buf[0]._1_1_ = 8; + iVar13 = 0; + do { + iVar15 = iVar19 + iVar13; + iVar2 = iVar13 + 2; + iVar13 = iVar13 + 1; + *(uint8_t *)((int)scan_probe_req_ie.buf + iVar2) = mac_id2rate[iVar15]; + } while (iVar13 != 8); + puVar14 = (undefined *)((int)scan_probe_req_ie.buf + 10); + if ((uVar18 != 0) && ((char)scanu_add_ie.buf[0] == '\n')) { + uVar6 = (uint)scanu_add_ie.buf[0]._1_1_ + 2 & 0xff; + uVar4 = uVar6; + psVar16 = &scanu_add_ie; + while( true ) { + uVar4 = uVar4 - 1; + if (uVar4 == 0xffffffff) break; + *puVar14 = *(undefined *)psVar16->buf; + psVar16 = (scanu_add_ie_tag *)((int)&(psVar16->dma_desc).src + 1); + puVar14 = puVar14 + 1; + } + puVar14 = (undefined *)((int)scan_probe_req_ie.buf + uVar6 + 10); + puVar10 = (uint32_t *)((int)scanu_add_ie.buf + uVar6); + uVar18 = uVar18 - uVar6 & 0xffff; + } + if (iVar20 != 8) { + uVar4 = iVar20 - 8U & 0xff; + *puVar14 = 0x32; + puVar14[1] = (char)uVar4; + iVar19 = uVar4 + 2; + puVar7 = mac_id2rate; + puVar17 = puVar14 + 2; + while( true ) { + uVar4 = uVar4 - 1; + if (uVar4 == 0xffffffff) break; + *puVar17 = puVar7[8]; + puVar7 = puVar7 + 1; + puVar17 = puVar17 + 1; + } + puVar14 = puVar14 + iVar19; + } + if (scanu_env.band == '\0') { + *puVar14 = 3; + puVar14[1] = 1; + puVar14 = puVar14 + 3; + } + if ((uVar18 != 0) && (*(char *)puVar10 == ';')) { + uVar4 = 0; + uVar6 = (uint)*(byte *)((int)puVar10 + 1) + 2 & 0xff; + while (uVar6 != uVar4) { + puVar8 = (undefined *)((int)puVar10 + uVar4); + puVar9 = puVar14 + uVar4; + uVar4 = uVar4 + 1; + *puVar9 = *puVar8; + } + puVar14 = puVar14 + uVar6; + puVar10 = (uint32_t *)((int)puVar10 + uVar6); + uVar18 = uVar18 - uVar6 & 0xffff; + } + if (me_env.ht_supported != false) { + *puVar14 = 0x2d; + puVar14[1] = 0x1a; + puVar8 = puVar14 + 0x1c; + pmVar11 = &me_env; + puVar14 = puVar14 + 2; + while (puVar8 != puVar14) { + *puVar14 = *(undefined *)&(pmVar11->ht_cap).ht_capa_info; + pmVar11 = (me_env_tag *)((int)&pmVar11->active_vifs + 1); + puVar14 = puVar14 + 1; + } + } + sVar12 = (short)puVar14; + if (uVar18 != 0) { + uVar4 = 0; + do { + puVar8 = (undefined *)((int)puVar10 + uVar4); + puVar9 = puVar14 + uVar4; + uVar4 = uVar4 + 1; + *puVar9 = *puVar8; + } while (uVar18 != uVar4); + sVar12 = sVar12 + (short)uVar18; + } + *(short *)((int)pvVar5 + 0x14c) = sVar12 + -0x5d04; + *(undefined4 *)((int)pvVar5 + 0x148) = 0; + ke_msg_send(pvVar5); + return; +} + + + +void scanu_start(void) + +{ + scanu_env_tag *psVar1; + + if (scanu_env.joining == false) { + psVar1 = &scanu_env; + do { + psVar1->scan_result[0].valid_flag = false; + psVar1->scan_result[0].rssi = -0x80; + psVar1 = (scanu_env_tag *)(psVar1->scan_result[0].ssid.array + 0x19); + } while (psVar1 != (scanu_env_tag *)0x420216fc); + scanu_env.result_cnt = 0; + } + ke_state_set(4,1); + if ((scanu_env.param)->add_ies != 0) { + if ((scanu_env.param)->add_ie_len < 0xc9) { + scanu_add_ie.dma_desc.src = (scanu_env.param)->add_ies; + scanu_add_ie.dma_desc.length = (scanu_env.param)->add_ie_len; + hal_dma_push(&scanu_env.dma_desc,0); + return; + } + } + scanu_scan_next(); + return; +} + + + +uint16_t txl_get_seq_ctrl(void) + +{ + uint uVar1; + + uVar1 = (uint)txl_cntrl_env.seqnbr; + txl_cntrl_env.seqnbr = (uint16_t)((uVar1 + 1) * 0x10000 >> 0x10); + return (uint16_t)((uVar1 + 1) * 0x100000 >> 0x10); +} + + + +void sm_delete_resources(vif_info_tag *vif) + +{ + undefined *puVar1; + undefined *puVar2; + void *pvVar3; + byte *pbVar4; + + puVar1 = (undefined *)ke_msg_alloc(0x1413,5,6,2); + puVar2 = (undefined *)ke_msg_alloc(0x1411,5,6,2); + *puVar1 = 0; + puVar1[1] = vif->index; + ke_msg_send(puVar1); + if (vif->active != false) { + pvVar3 = ke_msg_alloc(0x1e,0,6,4); + *(undefined *)((int)pvVar3 + 2) = 0; + *(uint8_t *)((int)pvVar3 + 3) = vif->index; + ke_msg_send(); + } + if (vif->u[4] != 0xff) { + pbVar4 = (byte *)ke_msg_alloc(0xc,0,6,1); + *pbVar4 = vif->u[4]; + ke_msg_send(); + } + if (vif->chan_ctxt != (chan_ctxt_tag *)0x0) { + chan_ctxt_unlink(vif->index); + } + *puVar2 = 0; + puVar2[1] = vif->index; + ke_msg_send(puVar2); + (vif->bss_info).valid_flags = 0; + return; +} + + + +void sm_frame_tx_cfm_handler(void *env,uint32_t status) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(6); + if (((status & 0x40030000) != 0) && (CONCAT22(extraout_var,kVar1) - 5U < 2)) { + txl_frame_push((txl_frame_desc_tag *)env,'\x03'); + *(undefined *)((int)env + 0x2d6) = 1; + } + return; +} + + + +void sm_init(void) + +{ + sm_env.connect_param = (sm_connect_req *)0x0; + ke_state_set(6,0); + return; +} + + + +void sm_get_bss_params(mac_addr **bssid,scan_chan_tag **chan) + +{ + byte bVar1; + sm_connect_req *ssid; + int iVar2; + int iVar3; + mac_scan_result *pmVar4; + mac_addr *bssid_00; + mac_addr *pmVar5; + int local_34; + int index; + + ssid = sm_env.connect_param; + *bssid = (mac_addr *)0x0; + *chan = (scan_chan_tag *)0x0; + bssid_00 = &ssid->bssid; + local_34 = -1; + printf("===start sm_get_bss_params===\r\n"); + iVar2 = 0; + pmVar5 = bssid_00; + do { + iVar3 = iVar2 + 1; + printf("bssid[%d] = 0x%x\r\n",iVar2,(uint)pmVar5->array[0]); + pmVar5 = (mac_addr *)(pmVar5->array + 1); + iVar2 = iVar3; + } while (iVar3 != 3); + bVar1 = *(byte *)(ssid->bssid).array; + if (((bVar1 & 1) == 0) && + ((((bVar1 != 0 || (*(char *)((int)(ssid->bssid).array + 1) != '\0')) || + (*(char *)((ssid->bssid).array + 1) != '\0')) || + (((*(char *)((int)(ssid->bssid).array + 3) != '\0' || + (*(char *)((ssid->bssid).array + 2) != '\0')) || + (*(char *)((int)(ssid->bssid).array + 5) != '\0')))))) { + printf("search bssid \r\n "); + *bssid = bssid_00; + pmVar4 = scanu_search_by_bssid(bssid_00); + if (pmVar4 == (mac_scan_result *)0x0) goto LAB_230119a4; + } + else { + printf("search ssid = %s\r\n",(ssid->ssid).array); + pmVar4 = scanu_search_by_ssid((mac_ssid *)ssid,&local_34); + printf("result ssid index = %d\r\n",local_34); + if (pmVar4 == (mac_scan_result *)0x0) { +LAB_230119a4: + if ((ssid->chan).freq != 0xffff) { + *chan = &ssid->chan; + } + goto LAB_23011966; + } + if (-1 < local_34) { + *(mac_scan_result **)bssid = pmVar4; + sm_env.exist_ssid_idx = local_34; + } + } + *chan = pmVar4->chan; +LAB_23011966: + printf("===end sm_get_bss_params===\r\n"); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void sm_scan_bss(mac_addr *bssid,scan_chan_tag *chan_1) + +{ + uint8_t uVar1; + byte bVar2; + undefined2 uVar3; + sm_connect_req *__src; + int iVar4; + void *__dest; + void *__src_00; + undefined2 *puVar5; + int *piVar6; + undefined2 local_2c; + undefined2 uStack42; + uint8_t chan_cnt [2]; + scan_chan_tag *chan [2]; + + __src = sm_env.connect_param; + __dest = ke_msg_alloc(0x1000,4,6,0x154); + uVar1 = __src->vif_idx; + *(undefined4 *)((int)__dest + 0x148) = 0; + *(uint8_t *)((int)__dest + 0x14e) = uVar1; + *(undefined2 *)((int)__dest + 0x14c) = 0; + memcpy((void *)((int)__dest + 0xfc),__src,0x22); + *(undefined *)((int)__dest + 0x150) = 1; + if (bssid == (mac_addr *)0x0) { + bssid = &mac_addr_bcst; + } + memcpy((void *)((int)__dest + 0x140),bssid,6); + uVar3 = me_env.chan._252_2_; + if (chan_1 == (scan_chan_tag *)0x0) { + _chan_cnt = 0x42020b6c; + *(undefined *)((int)__dest + 0x14f) = 0; + puVar5 = &local_2c; + local_2c = uVar3; + piVar6 = (int *)chan_cnt; + do { + iVar4 = 0; + while (iVar4 < (int)(uint)*(byte *)puVar5) { + __src_00 = (void *)(iVar4 * 6 + *piVar6); + if ((*(byte *)((int)__src_00 + 3) & 2) == 0) { + bVar2 = *(byte *)((int)__dest + 0x14f); + *(char *)((int)__dest + 0x14f) = bVar2 + 1; + memcpy((void *)((uint)bVar2 * 6 + (int)__dest),__src_00,6); + } + iVar4 = iVar4 + 1; + } + puVar5 = (undefined2 *)((int)puVar5 + 1); + piVar6 = piVar6 + 1; + } while (puVar5 != &uStack42); + } + else { + memcpy(__dest,chan_1,6); + *(undefined *)((int)__dest + 0x14f) = 1; + } + ke_msg_send(__dest); + ke_state_set(6,1); + return; +} + + + +void sm_join_bss(mac_addr *bssid,scan_chan_tag *chan,_Bool passive) + +{ + sm_connect_req *__src; + void *__dest; + undefined3 in_register_00002031; + + __src = sm_env.connect_param; + __dest = ke_msg_alloc(0x1002,4,6,0x154); + memcpy(__dest,chan,6); + *(undefined *)((int)__dest + 0x14f) = 1; + memcpy((void *)((int)__dest + 0xfc),__src,0x22); + *(undefined *)((int)__dest + 0x150) = 1; + *(undefined2 *)((int)__dest + 0x14c) = 0; + *(undefined4 *)((int)__dest + 0x148) = 0; + *(uint8_t *)((int)__dest + 0x14e) = __src->vif_idx; + memcpy((void *)((int)__dest + 0x140),bssid,6); + if (CONCAT31(in_register_00002031,passive) != 0) { + *(byte *)((int)__dest + 3) = *(byte *)((int)__dest + 3) | 1; + } + sm_env.join_passive = passive; + ke_msg_send(__dest); + ke_state_set(6,2); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +uint8_t sm_add_chan_ctx(uint8_t *p_chan_idx) + +{ + uint8_t uVar1; + scan_chan_tag *psVar2; + uint uVar3; + uint8_t uStack28; + uint8_t uStack27; + uint16_t uStack26; + mm_chan_ctxt_add_req req; + + uVar3 = (uint)(sm_env.connect_param)->vif_idx; + psVar2 = vif_info_tab[uVar3].bss_info.chan; + uStack27 = vif_info_tab[uVar3].bss_info.phy_bw; + uStack28 = psVar2->band; + uStack26 = psVar2->freq; + req._0_4_ = *(undefined4 *)&vif_info_tab[uVar3].bss_info.center_freq1; + req.center1_freq._0_1_ = psVar2->tx_power; + uVar1 = chan_ctxt_add((mm_chan_ctxt_add_req *)&uStack28,p_chan_idx); + return uVar1; +} + + + +void sm_send_next_bss_param(void) + +{ + co_list_hdr *pcVar1; + + pcVar1 = co_list_pop_front(&sm_env.bss_config); + if (pcVar1 == (co_list_hdr *)0x0) { + assert_err("msg != NULL","module",0x1a0); + } + ke_msg_send(pcVar1 + 3); + return; +} + + + +void sm_set_bss_param(void) + +{ + sm_connect_req *psVar1; + vif_info_tag *pvVar2; + uint16_t uVar3; + undefined *puVar4; + void *__dest; + undefined4 *puVar5; + uint16_t *puVar6; + undefined *puVar7; + undefined2 extraout_var; + uint32_t *puVar8; + bool bVar9; + uint32_t uVar10; + uint uVar11; + int iVar12; + + psVar1 = sm_env.connect_param; + uVar11 = (uint)(sm_env.connect_param)->vif_idx; + puVar4 = (undefined *)ke_msg_alloc(0x1413,5,6,2); + __dest = ke_msg_alloc(0x18,0,6,7); + puVar5 = (undefined4 *)ke_msg_alloc(0x16,0,6,8); + puVar6 = (uint16_t *)ke_msg_alloc(0x14,0,6,4); + puVar7 = (undefined *)ke_msg_alloc(0x1411,5,6,2); + co_list_init(&sm_env.bss_config); + *puVar4 = 1; + puVar4[1] = psVar1->vif_idx; + co_list_push_back(&sm_env.bss_config,(co_list_hdr *)(puVar4 + -0xc)); + pvVar2 = vif_info_tab + uVar11; + memcpy(__dest,&vif_info_tab[uVar11].bss_info.bssid,6); + *(uint8_t *)((int)__dest + 6) = psVar1->vif_idx; + co_list_push_back(&sm_env.bss_config,(co_list_hdr *)((int)__dest + -0xc)); + *(uint8_t *)((int)puVar5 + 5) = (vif_info_tab[uVar11].bss_info.chan)->band; + uVar3 = me_legacy_rate_bitfield_build(&vif_info_tab[uVar11].bss_info.rate_set,true); + *puVar5 = CONCAT22(extraout_var,uVar3); + *(uint8_t *)(puVar5 + 1) = psVar1->vif_idx; + co_list_push_back(&sm_env.bss_config,(co_list_hdr *)(puVar5 + -3)); + *puVar6 = vif_info_tab[uVar11].bss_info.beacon_period; + iVar12 = 0; + *(uint8_t *)(puVar6 + 1) = psVar1->vif_idx; + co_list_push_back(&sm_env.bss_config,(co_list_hdr *)(puVar6 + -6)); + do { + puVar8 = (uint32_t *)ke_msg_alloc(0x1a,0,6,8); + uVar10 = (pvVar2->bss_info).edca_param.ac_param[0]; + *(undefined *)((int)puVar8 + 5) = (char)iVar12; + *puVar8 = uVar10; + *(uint8_t *)((int)puVar8 + 6) = psVar1->vif_idx; + bVar9 = false; + if ((ps_env.uapsd_timeout != 0) && + ((char)vif_info_tab[uVar11].bss_info.edca_param.qos_info < '\0')) { + bVar9 = (mac_ac2uapsd[iVar12] & psVar1->uapsd_queues) != 0; + } + *(bool *)(puVar8 + 1) = bVar9; + iVar12 = iVar12 + 1; + co_list_push_back(&sm_env.bss_config,(co_list_hdr *)(puVar8 + -3)); + pvVar2 = (vif_info_tag *)&pvVar2->prevent_sleep; + } while (iVar12 != 4); + *puVar7 = 1; + puVar7[1] = psVar1->vif_idx; + co_list_push_back(&sm_env.bss_config,(co_list_hdr *)(puVar7 + -0xc)); + sm_send_next_bss_param(); + ke_state_set(6,4); + return; +} + + + +void sm_disconnect_process(vif_info_tag *vif,uint16_t reason) + +{ + uint16_t *puVar1; + + puVar1 = (uint16_t *)ke_msg_alloc(0x1805,0xd,6,4); + sm_delete_resources(vif); + *puVar1 = reason; + *(uint8_t *)(puVar1 + 1) = vif->index; + if (sm_env.ft_over_ds != false) { + *(undefined *)((int)puVar1 + 3) = 1; + } + ke_msg_send(puVar1); + return; +} + + + +void sm_deauth_cfm(void *env,uint32_t status) + +{ + sm_disconnect_process((vif_info_tag *)env,0); + return; +} + + + +void sm_disconnect(uint8_t vif_index,uint16_t reason_code) + +{ + byte bVar1; + _Bool _Var2; + uint16_t uVar3; + undefined3 in_register_00002029; + int iVar4; + txl_frame_desc_tag *frame; + undefined2 extraout_var_00; + undefined3 extraout_var; + vif_info_tag *vif; + tx_hw_desc *ptVar5; + txl_buffer_tag *ptVar6; + + iVar4 = CONCAT31(in_register_00002029,vif_index); + vif = vif_info_tab + iVar4; + if ((vif_info_tab[iVar4].type == '\0') && (vif_info_tab[iVar4].active != false)) { + bVar1 = vif_info_tab[iVar4].u[4]; + ke_state_set(6,8); + frame = txl_frame_get((uint)((vif_info_tab[iVar4].bss_info.chan)->band != '\0'),0x100); + if (frame != (txl_frame_desc_tag *)0x0) { + tpc_update_frame_tx_power(vif,frame); + ptVar6 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar6[1].length = 0xc0; + *(undefined *)((int)&ptVar6[1].length + 1) = 0; + *(undefined *)((int)&ptVar6[1].length + 2) = 0; + *(undefined *)((int)&ptVar6[1].length + 3) = 0; + memcpy(&ptVar6[1].lenheader,&sta_info_tab[bVar1].mac_addr,6); + memcpy((void *)((int)&ptVar6[1].lenpad + 2),&vif_info_tab[iVar4].mac_addr,6); + memcpy(&ptVar6[1].next,&sta_info_tab[bVar1].mac_addr,6); + uVar3 = txl_get_seq_ctrl(); + *(undefined *)((int)&ptVar6[1].txdesc + 2) = (char)uVar3; + *(undefined *)((int)&ptVar6[1].txdesc + 3) = (char)(uVar3 >> 8); + (frame->cfm).cfm_func = sm_deauth_cfm; + *(vif_info_tag **)&(frame->cfm).env = vif; + (frame->txdesc).host.vif_idx = vif_index; + (frame->txdesc).host.staid = vif_info_tab[iVar4].u[4]; + uVar3 = me_build_deauthenticate((uint32_t)ptVar6[1].dma_desc,reason_code); + ptVar5 = (frame->txdesc).lmac.hw_desc; + (ptVar5->thd).frmlen = CONCAT22(extraout_var_00,uVar3) + 0x1c; + (ptVar5->thd).field_5 = (ptVar5->thd).field_4 + 0x17 + CONCAT22(extraout_var_00,uVar3); + _Var2 = txl_frame_push(frame,'\x03'); + if (CONCAT31(extraout_var,_Var2) != 0) { + return; + } + vif = (vif_info_tag *)(frame->cfm).env; + } + sm_disconnect_process(vif,0); + return; + } + return; +} + + + +void sm_connect_ind(uint16_t status) + +{ + sm_connect_req *ssid; + sm_connect_ind *psVar1; + int index; + undefined2 in_register_0000202a; + uint8_t uVar2; + uint uVar3; + chan_ctxt_tag *pcVar4; + uint uVar5; + + index = sm_env.exist_ssid_idx; + psVar1 = sm_env.connect_ind; + ssid = sm_env.connect_param; + uVar5 = (uint)(sm_env.connect_param)->vif_idx; + (sm_env.connect_ind)->vif_idx = (sm_env.connect_param)->vif_idx; + memcpy(&psVar1->bssid,&vif_info_tab[uVar5].bss_info.bssid,6); + psVar1->ap_idx = vif_info_tab[uVar5].u[4]; + printf("ind ix %p, chan_ctxt is %p\r\n",psVar1,vif_info_tab[uVar5].chan_ctxt); + pcVar4 = vif_info_tab[uVar5].chan_ctxt; + psVar1->ch_idx = '\0'; + if (pcVar4 == (chan_ctxt_tag *)0x0) { + psVar1->band = '\0'; + psVar1->center_freq = 0; + psVar1->center_freq1 = 0; + psVar1->center_freq2 = 0; + psVar1->width = '\0'; + } + else { + psVar1->band = ((vif_info_tab[uVar5].chan_ctxt)->channel).band; + psVar1->center_freq = ((vif_info_tab[uVar5].chan_ctxt)->channel).prim20_freq; + psVar1->center_freq1 = (uint)((vif_info_tab[uVar5].chan_ctxt)->channel).center1_freq; + psVar1->center_freq2 = (uint)((vif_info_tab[uVar5].chan_ctxt)->channel).center2_freq; + psVar1->width = ((vif_info_tab[uVar5].chan_ctxt)->channel).type; + } + uVar2 = '\0'; + uVar3 = vif_info_tab[uVar5].bss_info.valid_flags & 1; + psVar1->qos = SUB41(uVar3,0); + if (uVar3 != 0) { + uVar2 = vif_info_tab[uVar5].bss_info.edca_param.acm; + } + psVar1->acm = uVar2; + psVar1->roamed = false; + if (CONCAT22(in_register_0000202a,status) == 0) { + ke_state_set(6,0); + } + else { + ke_state_set(6,8); + printf("connect failure, ssid = %s, index = %d\r\n",(ssid->ssid).array,index); + if (-1 < index) { + printf("from sm_connect_ind to scanu_rm_exist_ssid\r\n"); + scanu_rm_exist_ssid((mac_ssid *)ssid,index); + sm_env.exist_ssid_idx = -1; + } + sm_delete_resources(vif_info_tab + uVar5); + } + ke_msg_free(sm_env.connect_param[-1].phrase_pmk + 0x37); + sm_env.connect_param = (sm_connect_req *)0x0; + sm_env.ft_over_ds = false; + psVar1->status_code = status; + ke_msg_send(psVar1); + sm_env.connect_ind = (sm_connect_ind *)0x0; + return; +} + + + +void sm_supplicant_deauth_cfm(void *env,uint32_t status) + +{ + if (-1 < (int)(status << 8)) { + printf("sm deauth frame transmit failure\r\n"); + } + sm_connect_ind(8); + return; +} + + + +void sm_auth_send(uint16_t auth_seq,uint32_t *challenge) + +{ + byte bVar1; + sm_connect_req *psVar2; + txl_buffer_tag *ptVar3; + uint16_t uVar4; + undefined2 in_register_0000202a; + txl_frame_desc_tag *frame; + undefined2 extraout_var; + tx_hw_desc *ptVar5; + uint uVar6; + int iVar7; + + psVar2 = sm_env.connect_param; + uVar6 = (uint)(sm_env.connect_param)->vif_idx; + bVar1 = vif_info_tab[uVar6].u[4]; + frame = txl_frame_get((uint)((vif_info_tab[uVar6].bss_info.chan)->band != '\0'),0x100); + if (frame != (txl_frame_desc_tag *)0x0) { + tpc_update_frame_tx_power(vif_info_tab + uVar6,frame); + ptVar3 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar3[1].length = 0xb0; + *(undefined *)((int)&ptVar3[1].length + 1) = 0; + *(undefined *)((int)&ptVar3[1].length + 2) = 0; + *(undefined *)((int)&ptVar3[1].length + 3) = 0; + memcpy(&ptVar3[1].lenheader,&sta_info_tab[bVar1].mac_addr,6); + memcpy((void *)((int)&ptVar3[1].lenpad + 2),&vif_info_tab[uVar6].mac_addr,6); + memcpy(&ptVar3[1].next,&sta_info_tab[bVar1].mac_addr,6); + uVar4 = txl_get_seq_ctrl(); + *(undefined *)((int)&ptVar3[1].txdesc + 2) = (char)uVar4; + *(undefined *)((int)&ptVar3[1].txdesc + 3) = (char)(uVar4 >> 8); + (frame->txdesc).host.vif_idx = vif_info_tab[uVar6].index; + bVar1 = vif_info_tab[uVar6].u[4]; + (frame->txdesc).umac.head_len = '\0'; + (frame->txdesc).umac.tail_len = '\0'; + (frame->txdesc).host.staid = bVar1; + iVar7 = 0x18; + if ((psVar2->auth_type == '\x01') && (CONCAT22(in_register_0000202a,auth_seq) == 3)) { + txu_cntrl_protect_mgmt_frame((txdesc *)frame,(uint32_t)(ptVar3 + 1),0x18); + iVar7 = (uint)(frame->txdesc).umac.head_len + 0x18; + } + uVar4 = me_build_authenticate + ((int)&ptVar3[1].length + iVar7,(ushort)psVar2->auth_type,auth_seq,0,challenge + ); + bVar1 = (frame->txdesc).umac.tail_len; + ptVar5 = (frame->txdesc).lmac.hw_desc; + *(txl_frame_desc_tag **)&(frame->cfm).env = frame; + iVar7 = CONCAT22(extraout_var,uVar4) + (uint)bVar1 + iVar7; + (frame->cfm).cfm_func = sm_frame_tx_cfm_handler; + (ptVar5->thd).frmlen = iVar7 + 4; + (ptVar5->thd).field_5 = (ptVar5->thd).field_4 + -1 + iVar7; + txl_frame_push(frame,'\x03'); + ke_timer_set(0x1806,6,0x32000); + ke_state_set(6,5); + return; + } + sm_connect_ind(1); + return; +} + + + +// WARNING: Variable defined which should be unmapped: ie_addr +// WARNING: Could not reconcile some variable overlaps + +void sm_assoc_req_send(void) + +{ + byte bVar1; + sm_connect_req *con_par; + sm_connect_ind *psVar2; + txl_buffer_tag *ptVar3; + uint16_t uVar4; + txl_frame_desc_tag *frame; + undefined2 extraout_var; + tx_hw_desc *ptVar5; + _Bool _Var6; + sm_connect_ind *psVar7; + uint uVar8; + mac_addr *old_ap_addr_ptr; + uint16_t uStack54; + uint16_t ie_len; + uint32_t uStack52; + uint32_t ie_addr; + + con_par = sm_env.connect_param; + uVar8 = (uint)(sm_env.connect_param)->vif_idx; + bVar1 = vif_info_tab[uVar8].u[4]; + frame = txl_frame_get((uint)((vif_info_tab[uVar8].bss_info.chan)->band != '\0'),0x100); + psVar2 = sm_env.connect_ind; + if (frame == (txl_frame_desc_tag *)0x0) { + sm_connect_ind(4); + } + else { + tpc_update_frame_tx_power(vif_info_tab + uVar8,frame); + ptVar3 = (frame->txdesc).lmac.buffer; + old_ap_addr_ptr = (mac_addr *)0x0; + _Var6 = sm_env.ft_over_ds; + if (sm_env.ft_over_ds != false) { + _Var6 = true; + old_ap_addr_ptr = &sm_env.ft_old_bssid; + } + *(_Bool *)&ptVar3[1].length = _Var6; + *(undefined *)((int)&ptVar3[1].length + 1) = 0; + *(undefined *)((int)&ptVar3[1].length + 2) = 0; + *(undefined *)((int)&ptVar3[1].length + 3) = 0; + memcpy(&ptVar3[1].lenheader,&sta_info_tab[bVar1].mac_addr,6); + memcpy((void *)((int)&ptVar3[1].lenpad + 2),&vif_info_tab[uVar8].mac_addr,6); + memcpy(&ptVar3[1].next,&sta_info_tab[bVar1].mac_addr,6); + uVar4 = txl_get_seq_ctrl(); + *(undefined *)((int)&ptVar3[1].txdesc + 2) = (char)uVar4; + *(undefined *)((int)&ptVar3[1].txdesc + 3) = (char)(uVar4 >> 8); + uVar4 = me_build_associate_req + ((uint32_t)ptVar3[1].dma_desc,&vif_info_tab[uVar8].bss_info,old_ap_addr_ptr, + vif_info_tab[uVar8].index,(uint32_t *)&stack0xffffffcc,&uStack54,con_par); + ptVar5 = (frame->txdesc).lmac.hw_desc; + (frame->txdesc).host.vif_idx = vif_info_tab[uVar8].index; + bVar1 = vif_info_tab[uVar8].u[4]; + *(txl_frame_desc_tag **)&(frame->cfm).env = frame; + (frame->txdesc).host.staid = bVar1; + (frame->cfm).cfm_func = sm_frame_tx_cfm_handler; + (ptVar5->thd).field_5 = (ptVar5->thd).field_4 + 0x17 + CONCAT22(extraout_var,uVar4); + (ptVar5->thd).frmlen = CONCAT22(extraout_var,uVar4) + 0x1c; + psVar7 = psVar2; + while (psVar7 != (sm_connect_ind *)((int)&psVar2->status_code + (uint)uStack54)) { + *(undefined *)psVar7->assoc_ie_buf = *(undefined *)((uStack52 - (int)psVar2) + (int)psVar7); + psVar7 = (sm_connect_ind *)((int)&psVar7->status_code + 1); + } + psVar2->assoc_req_ie_len = uStack54; + txl_frame_push(frame,'\x03'); + ke_timer_set(0x1806,6,0x32000); + ke_state_set(6,6); + } + return; +} + + + +void sm_assoc_done(uint16_t aid) + +{ + sm_connect_req *psVar1; + uint16_t *puVar2; + + psVar1 = sm_env.connect_param; + puVar2 = (uint16_t *)ke_msg_alloc(0x1e,0,6,4); + *puVar2 = aid; + *(undefined *)(puVar2 + 1) = 1; + *(uint8_t *)((int)puVar2 + 3) = psVar1->vif_idx; + ke_msg_send(); + ke_state_set(6,7); + return; +} + + + +void sm_auth_handler(rxu_mgt_ind *param) + +{ + uint16_t auth_seq; + uint32_t *challenge; + + ke_timer_clear(0x1806,6); + if (param[1].center_freq != 0) { + if (((sm_env.connect_param)->auth_type != '\x01') || + ((sm_env.connect_param)->is_supplicant_enabled == false)) { + printf("Authentication failure, Wlan802.11 status code = %d\r\n"); + sm_connect_ind(2); + return; + } + (sm_env.connect_param)->auth_type = '\0'; + challenge = (uint32_t *)0x0; + auth_seq = 1; +LAB_230124ba: + sm_auth_send(auth_seq,challenge); + return; + } + if (param[1].length != 0) { + if (param[1].length != 1) { + return; + } + if (param[1].framectrl != 4) { + if (param[1].framectrl != 2) { + sm_connect_ind(3); + assert_warn("0","module",0x374); + return; + } + if (param->length < 0x88) { + printf("Drop illegal auth packet length %u\r\n"); + return; + } + challenge = (uint32_t *)¶m[1].inst_nbr; + auth_seq = 3; + goto LAB_230124ba; + } + } + sm_assoc_req_send(); + return; +} + + + +void sm_assoc_rsp_handler(rxu_mgt_ind *param) + +{ + uint8_t *puVar1; + byte bVar2; + ushort uVar3; + int iVar4; + sm_connect_ind *psVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint8_t uStack50; + int8_t aiStack49 [3]; + uint8_t idx; + int8_t pwr; + + psVar5 = sm_env.connect_ind; + uVar8 = (uint)(sm_env.connect_param)->vif_idx; + uStack50 = '\0'; + bVar2 = vif_info_tab[uVar8].u[4]; + ke_timer_clear(0x1806,6); + uVar6 = (uint)param[1].framectrl; + if (param[1].framectrl == 0) { + if (5 < param->length) { + uVar6 = (uint)param->length - 6 & 0xffff; + } + sm_assoc_done((ushort)(((uint)param[1].center_freq << 0x12) >> 0x12)); + me_init_rate(sta_info_tab + bVar2); + aiStack49[0] = (vif_info_tab[uVar8].bss_info.chan)->tx_power - + vif_info_tab[uVar8].bss_info.power_constraint; + tpc_update_vif_tx_power(vif_info_tab + uVar8,aiStack49,&uStack50); + uVar3 = psVar5->assoc_req_ie_len; + uVar7 = 0; + while (uVar6 != uVar7) { + puVar1 = ¶m[1].band + uVar7; + iVar4 = uVar7 + uVar3; + uVar7 = uVar7 + 1; + *(uint8_t *)((int)psVar5->assoc_ie_buf + iVar4) = *puVar1; + } + psVar5->assoc_rsp_ie_len = (uint16_t)uVar6; + if ((*(uint *)&vif_info_tab[uVar8].bss_info.is_supplicant_enabled & 0x12a00) != 0) { + supplicantInitSession + (&sta_conn_info,(CHAR *)vif_info_tab[uVar8].bss_info.ssid.array, + (ushort)vif_info_tab[uVar8].bss_info.ssid.length, + (CHAR *)&vif_info_tab[uVar8].bss_info.bssid,(UINT8 *)&vif_info_tab[uVar8].mac_addr) + ; + } + } + else { + printf("Association failure, Wlan802.11 status code = %d\r\n",uVar6); + sm_connect_ind(5); + } + return; +} + + + +int sm_deauth_handler(rxu_mgt_ind *param) + +{ + byte bVar1; + ushort reason; + sm_connect_req *psVar2; + ke_state_t kVar3; + undefined2 extraout_var; + undefined2 extraout_var_00; + + psVar2 = sm_env.connect_param; + bVar1 = param->inst_nbr; + kVar3 = ke_state_get(6); + if (CONCAT22(extraout_var,kVar3) != 8) { + kVar3 = ke_state_get(6); + if (CONCAT22(extraout_var_00,kVar3) == 0) { + if (vif_info_tab[bVar1].active == false) { + return 0; + } + reason = param[1].length; + ke_state_set(6,8); + printf("Deauth by AP, Wlan802.11 reason code = %d\r\n",(uint)reason); + sm_disconnect_process(vif_info_tab + bVar1,reason); + return 0; + } + if (psVar2->vif_idx == param->inst_nbr) { + sm_connect_ind(6); + return 0; + } + } + return 2; +} + + + +void sm_handle_supplicant_result(uint8_t sta_id,uint16_t reason_code) + +{ + byte bVar1; + txl_buffer_tag *ptVar2; + _Bool _Var3; + uint16_t status; + undefined3 in_register_00002029; + int iVar4; + txl_frame_desc_tag *frame; + undefined2 extraout_var_00; + undefined3 extraout_var; + undefined2 in_register_0000202e; + tx_hw_desc *ptVar5; + uint uVar6; + + iVar4 = CONCAT31(in_register_00002029,sta_id); + bVar1 = sta_info_tab[iVar4].inst_nbr; + uVar6 = (uint)bVar1; + if (CONCAT22(in_register_0000202e,reason_code) == 0) { + sta_info_tab[iVar4].ctrl_port_state = '\x02'; + status = 0; + } + else { + if (CONCAT22(in_register_0000202e,reason_code) == 0xf) { + printf( + "4-way handshake timeout failure, wlan 802.11 reason code = %u, try to transmit deauth frame\r\n" + ); + } + frame = txl_frame_get((uint)((vif_info_tab[uVar6].bss_info.chan)->band != '\0'),0x100); + if (frame == (txl_frame_desc_tag *)0x0) { + status = 10; + } + else { + tpc_update_frame_tx_power(vif_info_tab + uVar6,frame); + ptVar2 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar2[1].length = 0xc0; + *(undefined *)((int)&ptVar2[1].length + 1) = 0; + *(undefined *)((int)&ptVar2[1].length + 2) = 0; + *(undefined *)((int)&ptVar2[1].length + 3) = 0; + memcpy(&ptVar2[1].lenheader,&sta_info_tab[iVar4].mac_addr,6); + memcpy((void *)((int)&ptVar2[1].lenpad + 2),&vif_info_tab[uVar6].mac_addr,6); + memcpy(&ptVar2[1].next,&sta_info_tab[iVar4].mac_addr,6); + status = txl_get_seq_ctrl(); + *(undefined *)((int)&ptVar2[1].txdesc + 2) = (char)status; + *(undefined *)((int)&ptVar2[1].txdesc + 3) = (char)(status >> 8); + (frame->cfm).cfm_func = sm_supplicant_deauth_cfm; + *(vif_info_tag **)&(frame->cfm).env = vif_info_tab + uVar6; + (frame->txdesc).host.vif_idx = bVar1; + (frame->txdesc).host.staid = sta_id; + status = me_build_deauthenticate((uint32_t)ptVar2[1].dma_desc,reason_code); + ptVar5 = (frame->txdesc).lmac.hw_desc; + (ptVar5->thd).frmlen = CONCAT22(extraout_var_00,status) + 0x1c; + (ptVar5->thd).field_5 = (ptVar5->thd).field_4 + 0x17 + CONCAT22(extraout_var_00,status); + _Var3 = txl_frame_push(frame,'\x03'); + if (CONCAT31(extraout_var,_Var3) != 0) { + return; + } + status = 9; + } + } + sm_connect_ind(status); + return; +} + + + +undefined2 * txu_cntrl_sec_hdr_append(int param_1,undefined2 *param_2,int param_3) + +{ + uint8_t uVar1; + ushort uVar2; + undefined2 *puVar3; + int iVar4; + key_info_tag *pkVar5; + + pkVar5 = *sta_info_tab[*(byte *)(param_1 + 0x30)].sta_sec_info.cur_key; + if (pkVar5 == (key_info_tag *)0x0) { + return param_2; + } + if (((vif_info_tab[*(byte *)(param_1 + 0x2f)].flags & 2) != 0) && + ((uint)sta_info_tab[*(byte *)(param_1 + 0x30)].ctrl_port_ethertype == + (((uint)*(ushort *)(param_1 + 0x20) & 0xff) << 8 | (uint)(*(ushort *)(param_1 + 0x20) >> 8)))) + { + return param_2; + } + uVar1 = pkVar5->cipher; + if (uVar1 == '\x01') { + param_2[-4] = *(ushort *)(param_1 + 0x22) & 0x7f00 | 0x2000 | *(ushort *)(param_1 + 0x22) >> 8; + uVar2 = (ushort)*(byte *)(param_1 + 0x22) | (ushort)pkVar5->key_idx << 0xe; +LAB_23012954: + puVar3 = param_2 + -4; + param_2[-3] = uVar2 | 0x2000; + param_2[-2] = *(undefined2 *)(param_1 + 0x24); + param_2[-1] = *(undefined2 *)(param_1 + 0x26); + } + else { + if (uVar1 != '\0') { + if (uVar1 == '\x02') { + param_2[-4] = *(undefined2 *)(param_1 + 0x22); + uVar2 = (ushort)pkVar5->key_idx << 0xe; + goto LAB_23012954; + } + puVar3 = param_2; + if (uVar1 != '\x03') goto LAB_23012906; + } + puVar3 = param_2 + -2; + *puVar3 = *(undefined2 *)(param_1 + 0x22); + param_2[-1] = (ushort)pkVar5->key_idx << 0xe | *(ushort *)(param_1 + 0x24); + } +LAB_23012906: + if (param_3 == 0) { + iVar4 = *(int *)(param_1 + 0x68) + 0xf0; + } + else { + iVar4 = *(int *)(param_1 + 0x54); + } + *(uint *)(iVar4 + 0xc) = (uint)pkVar5->hw_key_idx | *(uint *)(iVar4 + 0xc) & 0xffc00; + return puVar3; +} + + + +int txu_cntrl_sechdr_len_compute(txdesc *txdesc,int *tail_len) + +{ + byte bVar1; + uint8_t uVar2; + ushort uVar3; + int iVar4; + int iVar5; + uint uVar6; + uint uVar7; + key_info_tag *pkVar8; + + bVar1 = (txdesc->host).vif_idx; + pkVar8 = *sta_info_tab[(txdesc->host).staid].sta_sec_info.cur_key; + *tail_len = 0; + if (pkVar8 == (key_info_tag *)0x0) { + return 0; + } + if (((vif_info_tab[bVar1].flags & 2) != 0) && + (uVar3 = (txdesc->host).ethertype, + (uint)sta_info_tab[(txdesc->host).staid].ctrl_port_ethertype == + (((uint)uVar3 & 0xff) << 8 | (uint)(uVar3 >> 8)))) { + return 0; + } + uVar2 = pkVar8->cipher; + if (uVar2 == '\x01') { + iVar4 = 0xc; +LAB_23012a4a: + *tail_len = iVar4; + if (((txdesc->host).flags & 1) == 0) { + uVar7 = *(uint *)&pkVar8->tx_pn; + iVar4 = *(int *)((int)&pkVar8->tx_pn + 4); + uVar6 = uVar7 + 1; + *(uint *)&pkVar8->tx_pn = uVar6; + *(int *)((int)&pkVar8->tx_pn + 4) = (uint)(uVar6 < uVar7) + iVar4; + memcpy((txdesc->host).pn,&pkVar8->tx_pn,6); + } + iVar4 = 8; + } + else { + if (uVar2 != '\0') { + if (uVar2 == '\x02') { + iVar4 = 8; + goto LAB_23012a4a; + } + if (uVar2 != '\x03') { + return 0; + } + } + *tail_len = 4; + iVar4 = 4; + if (((txdesc->host).flags & 1) == 0) { + uVar7 = *(uint *)&pkVar8->tx_pn; + iVar5 = *(int *)((int)&pkVar8->tx_pn + 4); + uVar6 = uVar7 + 1; + *(uint *)&pkVar8->tx_pn = uVar6; + *(int *)((int)&pkVar8->tx_pn + 4) = (uint)(uVar6 < uVar7) + iVar5; + memcpy((txdesc->host).pn,&pkVar8->tx_pn,4); + } + } + return iVar4; +} + + + +void txu_cntrl_frame_build(txdesc *txdesc,uint32_t buf) + +{ + uint8_t uVar1; + byte bVar2; + int iVar3; + ushort *puVar4; + ushort *puVar5; + uint uVar6; + ushort uVar7; + ushort uVar8; + ushort *puVar9; + uint uVar10; + key_info_tag *pkVar11; + + uVar8 = (txdesc->host).ethertype; + if (0x5ff < (((uint)uVar8 & 0xff) << 8 | (uint)(uVar8 >> 8))) { + *(undefined2 *)(buf - 8) = 0xaaaa; + *(undefined2 *)(buf - 6) = 3; + *(undefined2 *)(buf - 4) = 0; + *(uint16_t *)(buf - 2) = (txdesc->host).ethertype; + } + iVar3 = txu_cntrl_sec_hdr_append(txdesc,1); + uVar6 = (uint)(txdesc->host).staid; + uVar1 = (txdesc->host).tid; + uVar10 = (uint)(txdesc->host).vif_idx; + pkVar11 = *sta_info_tab[uVar6].sta_sec_info.cur_key; + puVar9 = (ushort *)(iVar3 + -0x1a); + if (uVar1 == -1) { + puVar9 = (ushort *)(iVar3 + -0x18); + } + puVar4 = puVar9 + 0xc; + puVar5 = (ushort *)0x0; + if (((txdesc->host).flags & 0x100) != 0) { + puVar5 = puVar9 + -3; + puVar9 = puVar5; + } + if (uVar1 == -1) { + *(undefined *)puVar9 = 0; + *(undefined *)((int)puVar9 + 1) = 0; + *(undefined *)(puVar9 + 0xb) = 0; + *(undefined *)((int)puVar9 + 0x17) = 0; + } + else { + *(undefined *)puVar9 = 0x80; + *(undefined *)((int)puVar9 + 1) = 0; + *puVar4 = (ushort)(txdesc->host).tid; + iVar3 = (uint)(txdesc->host).sn << 0x14; + *(char *)(puVar9 + 0xb) = (char)((uint)iVar3 >> 0x10); + *(undefined *)((int)puVar9 + 0x17) = (char)((uint)iVar3 >> 0x18); + if (((txdesc->host).flags & 0x200) != 0) { + *puVar4 = *puVar4 | 0x10; + } + } + uVar7 = *puVar9; + *(byte *)puVar9 = (byte)uVar7 | 8; + *(undefined *)((int)puVar9 + 1) = (char)((uint)uVar7 >> 8); + uVar8 = (txdesc->host).flags; + if ((int)((uint)uVar8 << 0x14) < 0) { + uVar7 = uVar7 & 0xfcff | 8; +LAB_23012b8c: + *(char *)puVar9 = (char)uVar7; + *(undefined *)((int)puVar9 + 1) = (char)(uVar7 >> 8); + } + else { + if ((uVar8 & 0x100) != 0) { + uVar7 = uVar7 | 0x308; + goto LAB_23012b8c; + } + if (vif_info_tab[uVar10].type == '\0') { + uVar7 = uVar7 | 0x108; + goto LAB_23012b8c; + } + if (vif_info_tab[uVar10].type == '\x02') { + uVar7 = uVar7 | 0x208; + goto LAB_23012b8c; + } + } + if (((txdesc->host).flags & 4) != 0) { + uVar8 = *puVar9; + *(char *)puVar9 = (char)uVar8; + *(byte *)((int)puVar9 + 1) = (byte)((uint)uVar8 >> 8) | 0x20; + } + puVar9[5] = vif_info_tab[uVar10].mac_addr.array[0]; + puVar9[6] = vif_info_tab[uVar10].mac_addr.array[1]; + puVar9[7] = vif_info_tab[uVar10].mac_addr.array[2]; + bVar2 = *(byte *)((int)puVar9 + 1) & 3; + if (bVar2 == 1) { + puVar9[2] = sta_info_tab[uVar6].mac_addr.array[0]; + puVar9[3] = sta_info_tab[uVar6].mac_addr.array[1]; + puVar9[4] = sta_info_tab[uVar6].mac_addr.array[2]; + puVar9[8] = (txdesc->host).eth_dest_addr.array[0]; + puVar9[9] = (txdesc->host).eth_dest_addr.array[1]; + uVar8 = (txdesc->host).eth_dest_addr.array[2]; + } + else { + if (bVar2 == 2) { + puVar9[2] = (txdesc->host).eth_dest_addr.array[0]; + puVar9[3] = (txdesc->host).eth_dest_addr.array[1]; + puVar9[4] = (txdesc->host).eth_dest_addr.array[2]; + puVar9[8] = (txdesc->host).eth_src_addr.array[0]; + puVar9[9] = (txdesc->host).eth_src_addr.array[1]; + uVar8 = (txdesc->host).eth_src_addr.array[2]; + } + else { + if (bVar2 != 0) { + puVar5[2] = sta_info_tab[uVar6].mac_addr.array[0]; + puVar5[3] = sta_info_tab[uVar6].mac_addr.array[1]; + puVar5[4] = sta_info_tab[uVar6].mac_addr.array[2]; + puVar5[8] = (txdesc->host).eth_dest_addr.array[0]; + puVar5[9] = (txdesc->host).eth_dest_addr.array[1]; + puVar5[10] = (txdesc->host).eth_dest_addr.array[2]; + puVar5[0xc] = (txdesc->host).eth_src_addr.array[0]; + puVar5[0xd] = (txdesc->host).eth_src_addr.array[1]; + puVar5[0xe] = (txdesc->host).eth_src_addr.array[2]; + goto LAB_23012c30; + } + puVar9[2] = (txdesc->host).eth_dest_addr.array[0]; + puVar9[3] = (txdesc->host).eth_dest_addr.array[1]; + puVar9[4] = (txdesc->host).eth_dest_addr.array[2]; + puVar9[8] = vif_info_tab[uVar10].bss_info.bssid.array[0]; + puVar9[9] = vif_info_tab[uVar10].bss_info.bssid.array[1]; + uVar8 = vif_info_tab[uVar10].bss_info.bssid.array[2]; + } + } + puVar9[10] = uVar8; +LAB_23012c30: + if ((pkVar11 != (key_info_tag *)0x0) && + (((vif_info_tab[uVar10].flags & 2) == 0 || + (uVar8 = (txdesc->host).ethertype, + (uint)sta_info_tab[(txdesc->host).staid].ctrl_port_ethertype != + (((uint)uVar8 & 0xff) << 8 | (uint)(uVar8 >> 8)))))) { + uVar8 = *puVar9; + *(char *)puVar9 = (char)uVar8; + *(byte *)((int)puVar9 + 1) = (byte)((uint)uVar8 >> 8) | 0x40; + } + return; +} + + +/* +Unable to decompile 'txu_cntrl_push' +Cause: Exception while decompiling 23012d96: Decompiler process died + +*/ + + +void txu_cntrl_tkip_mic_append(txdesc *txdesc,uint8_t ac) + +{ + uint8_t uVar1; + byte bVar2; + byte bVar3; + txl_buffer_tag *ptVar4; + uint32_t uVar5; + int iVar6; + key_info_tag *pkVar7; + int iVar8; + tx_pbd *ptVar9; + undefined *puVar10; + undefined *puVar11; + tx_pbd *ptVar12; + txl_buffer_tag *ptVar13; + undefined auStack48 [4]; + mic_calc mic; + + pkVar7 = *sta_info_tab[(txdesc->host).staid].sta_sec_info.cur_key; + if (pkVar7 != (key_info_tag *)0x0) { + uVar1 = pkVar7->cipher; + ptVar4 = (txdesc->lmac).buffer; + if (uVar1 != '\x01') { + if ((uVar1 == '\0') || (uVar1 == '\x03')) { + ptVar9 = &ptVar4->tbd; + do { + ptVar12 = ptVar9; + ptVar9 = (tx_pbd *)ptVar12->next; + } while (ptVar9 != (tx_pbd *)0x0); + *(tx_pbd **)&ptVar12->next = &ptVar4->tkip_mic_icv_pbd; + *(uint8_t **)&(ptVar4->tkip_mic_icv_pbd).datastartptr = ptVar4->tkip_mic_icv; + *(uint8_t **)&(ptVar4->tkip_mic_icv_pbd).dataendptr = ptVar4->tkip_mic_icv + 3; + (ptVar4->tkip_mic_icv_pbd).upatterntx = 0xcafefade; + (ptVar4->tkip_mic_icv_pbd).bufctrlinfo = 0; + (ptVar4->tkip_mic_icv_pbd).next = 0; + } + return; + } + ptVar9 = &ptVar4->tbd; + do { + ptVar12 = ptVar9; + ptVar9 = (tx_pbd *)ptVar12->next; + } while (ptVar9 != (tx_pbd *)0x0); + bVar2 = (txdesc->umac).head_len; + bVar3 = (txdesc->umac).hdr_len_802_2; + *(tx_pbd **)&ptVar12->next = &ptVar4->tkip_mic_icv_pbd; + *(uint8_t **)&(ptVar4->tkip_mic_icv_pbd).datastartptr = ptVar4->tkip_mic_icv; + *(uint8_t **)&(ptVar4->tkip_mic_icv_pbd).dataendptr = ptVar4->tkip_mic_icv + 0xb; + (ptVar4->tkip_mic_icv_pbd).upatterntx = 0xcafefade; + (ptVar4->tkip_mic_icv_pbd).bufctrlinfo = 0; + (ptVar4->tkip_mic_icv_pbd).next = 0; + ptVar13 = (txdesc->lmac).buffer; + me_mic_init((mic_calc *)auStack48,(uint32_t *)pkVar7->u,&(txdesc->host).eth_dest_addr, + &(txdesc->host).eth_src_addr,(txdesc->host).tid); + me_mic_calc((mic_calc *)auStack48,(int)ptVar4 + (uint)bVar2 + (0x14c - (uint)bVar3), + (uint)(txdesc->umac).hdr_len_802_2); + uVar5 = (ptVar13->tbd).next; + while (uVar5 != 0) { + iVar6 = *(int *)(uVar5 + 4); + if (iVar6 == 0) { + me_mic_end((mic_calc *)auStack48); + iVar8 = *(int *)(uVar5 + 8); + do { + puVar10 = auStack48 + iVar6; + puVar11 = (undefined *)(iVar8 + iVar6); + iVar6 = iVar6 + 1; + *puVar11 = *puVar10; + } while (iVar6 != 8); + return; + } + me_mic_calc((mic_calc *)auStack48,*(uint32_t *)(uVar5 + 8), + (*(int *)(uVar5 + 0xc) + 1) - *(uint32_t *)(uVar5 + 8)); + uVar5 = *(uint32_t *)(uVar5 + 4); + } + me_mic_end((mic_calc *)auStack48); + ebreak(); + } + return; +} + + + +void txu_cntrl_cfm(txdesc *txdesc) + +{ + ushort uVar1; + tx_cfm_tag *ptVar2; + uint32_t *puVar3; + + puVar3 = (uint32_t *)(txdesc->host).status_addr; + ptVar2 = ((txdesc->lmac).hw_desc)->cfm_ptr; + uVar1 = (txdesc->host).flags; + if ((uVar1 & 8) == 0) { + if ((uVar1 & 0x200) == 0) goto LAB_2301310c; + } + else { + if (((uVar1 & 0x20) != 0) && (-1 < (int)(ptVar2->status << 8))) { + rxu_cntrl_get_pm(); + } + if (((txdesc->host).flags & 0x200) == 0) goto LAB_2301310c; + if ((txdesc->host).staid == -1) { + assert_err("txdesc->host.staid != INVALID_STA_IDX","module",0x3a9); + } + txl_frame_send_qosnull_frame((txdesc->host).staid,0x17,(cfm_func_ptr *)0x0,(void *)0x0); + } + sta_info_tab[(txdesc->host).staid].ps_service_period = 0; +LAB_2301310c: + ptVar2->status = ptVar2->status | 1; + *(undefined2 *)&ptVar2->credits = 0x101; + txdesc[-1].buf[0x6b] = 0; + *puVar3 = ptVar2->status; + return; +} + + + +void txu_cntrl_protect_mgmt_frame(txdesc *txdesc,uint32_t frame,uint16_t hdr_len) + +{ + byte bVar1; + ushort uVar2; + uint uVar3; + undefined2 in_register_00002032; + uint uStack20; + int tail_len; + + bVar1 = (txdesc->umac).head_len; + uVar3 = (uint)bVar1; + if (bVar1 == 0) { + uVar3 = txu_cntrl_sechdr_len_compute(txdesc,(int *)&uStack20); + (txdesc->umac).head_len = (uint8_t)uVar3; + (txdesc->umac).tail_len = (uint8_t)uStack20; + } + else { + uStack20 = (uint)(txdesc->umac).tail_len; + } + uVar2 = *(ushort *)frame; + *(undefined *)frame = *(undefined *)frame; + *(byte *)(frame + 1) = (byte)((uint)uVar2 >> 8) | 0x40; + txu_cntrl_sec_hdr_append(txdesc,CONCAT22(in_register_00002032,hdr_len) + frame + uVar3,0); + return; +} + + + +int _aid_list_delete(uint8_t *mac) + +{ + int iVar1; + int iVar2; + apm *paVar3; + + paVar3 = &apm_env; + iVar1 = 0; + do { + if (paVar3->aid_list[0].used != '\0') { + iVar2 = memcmp(paVar3->aid_list,mac,6); + if (iVar2 == 0) { + memset(paVar3->aid_list,0,6); + apm_env.aid_list[iVar1].used = '\0'; + return 0; + } + } + iVar1 = iVar1 + 1; + paVar3 = (apm *)((int)&(paVar3->bss_config).first + 3); + } while (iVar1 != 10); + return -1; +} + + + +void apm_sta_delete(uint8_t sta_idx,uint8_t *mac) + +{ + uint8_t *puVar1; + uint8_t *puVar2; + + puVar1 = (uint8_t *)ke_msg_alloc(0x1409,5,7,2); + puVar2 = (uint8_t *)ke_msg_alloc(0x1c09,0xd,7,1); + _aid_list_delete(mac); + mm_sec_machwkey_del(sta_idx + '\b'); + apm_env.assoc_sta_count = apm_env.assoc_sta_count + -1; + *puVar2 = sta_idx; + ke_msg_send(puVar2); + *puVar1 = sta_idx; + puVar1[1] = '\0'; + ke_msg_send(puVar1); + return; +} + + + +void apm_tx_cfm_handler(uint8_t *param_1,int param_2) + +{ + if (-1 < param_2 << 8) { + _aid_list_delete(param_1); + ke_msg_free(param_1 + -0xc); + printf("apm mlme assoc rsp send failed:%d,aid:%d\n",(uint)*(ushort *)(param_1 + 0x44)); + apm_env.assoc_sta_count = apm_env.assoc_sta_count + -1; + return; + } + if (*(short *)(param_1 + 0x44) != 0) { + ke_msg_send(); + return; + } + ke_msg_free(param_1 + -0xc); + return; +} + + + +void apm_init(void) + +{ + memset(&apm_env,0,0x60); + apm_env.aging_sta_idx = '\0'; + apm_env._22_2_ = 0xc00; + ke_state_set(7,0); + return; +} + + + +void apm_start_cfm(int param_1) + +{ + byte bVar1; + uint16_t uVar2; + apm_start_req *__src; + undefined *puVar3; + void *pvVar4; + uint uVar5; + int iVar6; + + __src = apm_env.param; + puVar3 = (undefined *)ke_msg_alloc(0x1c01,0xd,7,4); + if (param_1 == 0) { + uVar5 = (uint)__src->vif_idx; + pvVar4 = ke_msg_alloc(0x1e,0,7,4); + iVar6 = uVar5 + 10; + *(undefined *)((int)pvVar4 + 2) = 1; + *(uint8_t *)((int)pvVar4 + 3) = vif_info_tab[uVar5].index; + ke_msg_send(); + vif_info_tab[uVar5].flags = __src->flags; + uVar2 = __src->ctrl_port_ethertype; + vif_info_tab[uVar5].u[0x2ee] = 0; + *(uint16_t *)(vif_info_tab[uVar5].u + 0x2f0) = uVar2; + puVar3[2] = (vif_info_tab[uVar5].chan_ctxt)->idx; + puVar3[3] = __src->vif_idx + '\n'; + memcpy(&sta_info_tab[iVar6].info,__src,0xd); + sta_info_tab[iVar6].ctrl_port_state = '\x02'; + me_init_bcmc_rate(sta_info_tab + iVar6); + bVar1 = sta_info_tab[iVar6].pol_tbl.upd_field; + sta_info_tab[iVar6].mac_addr.array[0] = 1; + sta_info_tab[iVar6].pol_tbl.upd_field = bVar1 | 0x10; + sta_info_tab[iVar6].staid = __src->vif_idx + '\n'; + } + *puVar3 = (char)param_1; + puVar3[1] = __src->vif_idx; + ke_timer_set(0x1c0a,7,5000000); + ke_msg_send(puVar3); + ke_msg_free(__src[-1].phrase + 0x35); + apm_env.param = (apm_start_req *)0x0; + ke_state_set(7,0); + return; +} + + + +void apm_send_next_bss_param(void) + +{ + co_list_hdr *pcVar1; + + pcVar1 = co_list_pop_front(&apm_env.bss_config); + if (pcVar1 == (co_list_hdr *)0x0) { + assert_err("msg != NULL","module",0xbf); + } + ke_msg_send(pcVar1 + 3); + return; +} + + + +void apm_set_bss_param(void) + +{ + byte bVar1; + apm_start_req *rateset; + uint16_t uVar2; + undefined *puVar3; + void *__dest; + undefined4 *puVar4; + uint16_t *puVar5; + undefined *puVar6; + undefined2 extraout_var; + + rateset = apm_env.param; + bVar1 = (apm_env.param)->vif_idx; + puVar3 = (undefined *)ke_msg_alloc(0x1413,5,7,2); + __dest = ke_msg_alloc(0x18,0,7,7); + puVar4 = (undefined4 *)ke_msg_alloc(0x16,0,7,8); + puVar5 = (uint16_t *)ke_msg_alloc(0x14,0,7,4); + puVar6 = (undefined *)ke_msg_alloc(0x1411,5,7,2); + *puVar3 = 1; + puVar3[1] = vif_info_tab[bVar1].index; + co_list_push_back(&apm_env.bss_config,(co_list_hdr *)(puVar3 + -0xc)); + memcpy(__dest,&vif_info_tab[bVar1].mac_addr,6); + *(uint8_t *)((int)__dest + 6) = rateset->vif_idx; + co_list_push_back(&apm_env.bss_config,(co_list_hdr *)((int)__dest + -0xc)); + *(uint8_t *)((int)puVar4 + 5) = (rateset->chan).band; + uVar2 = me_legacy_rate_bitfield_build((mac_rateset *)rateset,true); + *puVar4 = CONCAT22(extraout_var,uVar2); + *(uint8_t *)(puVar4 + 1) = rateset->vif_idx; + co_list_push_back(&apm_env.bss_config,(co_list_hdr *)(puVar4 + -3)); + *puVar5 = rateset->bcn_int; + *(uint8_t *)(puVar5 + 1) = rateset->vif_idx; + co_list_push_back(&apm_env.bss_config,(co_list_hdr *)(puVar5 + -6)); + *puVar6 = 1; + puVar6[1] = rateset->vif_idx; + co_list_push_back(&apm_env.bss_config,(co_list_hdr *)(puVar6 + -0xc)); + apm_send_next_bss_param(); + ke_state_set(7,1); + return; +} + + + +void apm_stop(vif_info_tag *vif) + +{ + undefined *puVar1; + undefined *puVar2; + void *pvVar3; + + puVar1 = (undefined *)ke_msg_alloc(0x1413,5,7,2); + puVar2 = (undefined *)ke_msg_alloc(0x1411,5,7,2); + ke_timer_clear(0x1c0a,7); + *puVar1 = 0; + puVar1[1] = vif->index; + ke_msg_send(puVar1); + if (vif->active != false) { + pvVar3 = ke_msg_alloc(0x1e,0,7,4); + *(undefined *)((int)pvVar3 + 2) = 0; + *(uint8_t *)((int)pvVar3 + 3) = vif->index; + ke_msg_send(); + } + if (vif->chan_ctxt != (chan_ctxt_tag *)0x0) { + chan_ctxt_unlink(vif->index); + } + *puVar2 = 0; + puVar2[1] = vif->index; + ke_msg_send(puVar2); + return; +} + + + +_Bool apm_tx_int_ps_check(txdesc *txdesc) + +{ + byte bVar1; + undefined uVar2; + + if (vif_info_tab[(txdesc->host).vif_idx].type == '\x02') { + bVar1 = (txdesc->host).staid; + uVar2 = 1; + if (((bVar1 < 0xc) && (sta_info_tab[bVar1].ps_state == '\x01')) && + ((sta_info_tab[bVar1].ps_service_period & 3U) == 0)) { + (txdesc->host).flags = (txdesc->host).flags | 0x1000; + uVar2 = 0; + } + } + else { + uVar2 = 1; + } + return (_Bool)uVar2; +} + + + +void apm_tx_int_ps_postpone(txdesc *txdesc,sta_info_tag *sta) + +{ + byte bVar1; + sta_ps_traffic sVar2; + sta_ps_traffic sVar3; + uint16_t *puVar4; + + if ((int)((uint)(txdesc->host).flags << 0x13) < 0) { + bVar1 = (sta->info).uapsd_queues; + sVar2 = sta->traffic_avail; + if ((mac_ac2uapsd[(txdesc->host).tid] & bVar1) == 0) { + if ((sVar2 & PS_TRAFFIC_INT) != 0) { + return; + } + sVar3 = PS_TRAFFIC_INT; + } + else { + sVar3 = UAPSD_TRAFFIC_INT; + if ((sVar2 & UAPSD_TRAFFIC_INT) != 0) { + return; + } + } + sta->traffic_avail = sVar2 | sVar3; + if (((mac_ac2uapsd[(txdesc->host).tid] & bVar1) == 0) || (bVar1 == 0xf)) { + puVar4 = (uint16_t *)ke_msg_alloc(0x41,0,5,4); + *puVar4 = sta->aid; + *(uint8_t *)((int)puVar4 + 3) = sta->inst_nbr; + *(undefined *)(puVar4 + 1) = 1; + ke_msg_send(); + return; + } + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +txdesc * apm_tx_int_ps_get_postpone(vif_info_tag *vif,sta_info_tag *sta,int *stop) + +{ + uint8_t uVar1; + ushort uVar2; + co_list_hdr cVar3; + co_list_hdr element; + uint16_t *puVar4; + co_list_hdr *pcVar5; + uint uVar6; + int *piVar7; + sta_ps_traffic sVar8; + sta_ps_traffic sVar9; + co_list_hdr prev_element; + + sVar8 = vif->type; + if ((sVar8 == PS_TRAFFIC_INT) && (uVar6 = sta->ps_service_period, uVar6 != 0)) { + sVar9 = PS_TRAFFIC_HOST; + if ((uVar6 & 1) == 0) { + sVar9 = UAPSD_TRAFFIC_HOST; + sVar8 = UAPSD_TRAFFIC_INT; + } + if ((sVar8 & sta->traffic_avail) != 0) { + cVar3 = (co_list_hdr)(sta->tx_desc_post).first; + prev_element = (co_list_hdr)(co_list_hdr *)0x0; + while( true ) { + element = cVar3; + if (element == (co_list_hdr)0x0) { + assert_warn("txdesc","module",0x16f); + *stop = 1; + return (txdesc *)0x0; + } + if (((mac_ac2uapsd[*(byte *)((int)element + 0x2e)] & (sta->info).uapsd_queues) == 0) != + (uVar6 == 2)) break; + cVar3 = *(co_list_hdr *)element; + prev_element = element; + } + co_list_remove(&sta->tx_desc_post,(co_list_hdr *)prev_element,(co_list_hdr *)element); + *(char *)((int)element + 0x2e) = ((sta->ps_service_period & 8U) != 0) + '\x03'; + if (prev_element == (co_list_hdr)0x0) { + piVar7 = (int *)(sta->tx_desc_post).first; + } + else { + piVar7 = (int *)((co_list_hdr *)prev_element)->next; + } + while (piVar7 != (int *)0x0) { + if (((mac_ac2uapsd[*(byte *)((int)piVar7 + 0x2e)] & (sta->info).uapsd_queues) == 0) != + (sta->ps_service_period == 2)) goto LAB_23013820; + piVar7 = (int *)*piVar7; + } + sVar8 = ~sVar8 & sta->traffic_avail; + sta->traffic_avail = sVar8; + if ((sVar8 & sVar9) == 0) { + puVar4 = (uint16_t *)ke_msg_alloc(0x41,0,5,4); + *puVar4 = sta->aid; + uVar1 = sta->inst_nbr; + *(undefined *)(puVar4 + 1) = 0; + *(uint8_t *)((int)puVar4 + 3) = uVar1; + ke_msg_send(); + } + else { +LAB_23013820: + pcVar5 = ((co_list_hdr *)((int)element + 0x68))->next; + uVar2 = *(ushort *)&pcVar5[0x53].next; + *(char *)&pcVar5[0x53].next = (char)uVar2; + *(byte *)((int)&pcVar5[0x53].next + 1) = (byte)((uint)uVar2 >> 8) | 0x20; + } + return (txdesc *)element; + } + *stop = 1; + } + else { + *stop = 0; + } + return (txdesc *)0x0; +} + + + +void apm_tx_int_ps_clear(vif_info_tag *vif,uint8_t sta_idx) + +{ + sta_ps_traffic sVar1; + uint8_t uVar2; + uint16_t *puVar3; + undefined3 in_register_0000202d; + int iVar4; + + iVar4 = CONCAT31(in_register_0000202d,sta_idx); + if (vif->type != '\x02') { + return; + } + sta_mgmt_send_postponed_frame(vif,sta_info_tab + iVar4,0); + sVar1 = sta_info_tab[iVar4].traffic_avail; + if (((sVar1 & (PS_TRAFFIC_INT|UAPSD_TRAFFIC_INT)) != 0) && + (sta_info_tab[iVar4].traffic_avail = sVar1 & ~(PS_TRAFFIC_INT|UAPSD_TRAFFIC_INT), + (sVar1 & ~(PS_TRAFFIC_INT|UAPSD_TRAFFIC_INT)) == 0)) { + puVar3 = (uint16_t *)ke_msg_alloc(0x41,0,5,4); + *puVar3 = sta_info_tab[iVar4].aid; + uVar2 = sta_info_tab[iVar4].inst_nbr; + *(undefined *)(puVar3 + 1) = 0; + *(uint8_t *)((int)puVar3 + 3) = uVar2; + ke_msg_send(); + return; + } + return; +} + + + +void apm_sta_fw_delete(uint8_t sta_idx) + +{ + undefined3 in_register_00002029; + + apm_sta_delete(sta_idx,(uint8_t *)&sta_info_tab[CONCAT31(in_register_00002029,sta_idx)].mac_addr); + return; +} + + + +void apm_sta_add(uint8_t sta_idx) + +{ + undefined3 in_register_00002029; + int iVar1; + uint32_t *puVar2; + + iVar1 = CONCAT31(in_register_00002029,sta_idx); + puVar2 = (uint32_t *)ke_msg_alloc(0x1c08,0xd,7,0x1c); + sta_info_tab[iVar1].ctrl_port_state = '\x02'; + *puVar2 = sta_info_tab[iVar1].info.capa_flags; + memcpy(puVar2 + 1,&sta_info_tab[iVar1].mac_addr,6); + *(uint8_t *)((int)puVar2 + 0xb) = sta_info_tab[iVar1].staid; + *(uint8_t *)((int)puVar2 + 10) = sta_info_tab[iVar1].inst_nbr; + *(int8_t *)(puVar2 + 3) = sta_info_tab[iVar1].rssi; + puVar2[4] = sta_info_tab[iVar1].tsflo; + puVar2[5] = sta_info_tab[iVar1].tsfhi; + *(uint8_t *)(puVar2 + 6) = sta_info_tab[iVar1].data_rate; + ke_msg_send(puVar2); + return; +} + + + +void apm_send_mlme(vif_info_tag *vif,uint16_t fctl,mac_addr *ra,cfm_func_ptr *cfm_func,void *env, + uint16_t status_code) + +{ + uint8_t uVar1; + txl_buffer_tag *ptVar2; + uint16_t uVar3; + txl_frame_desc_tag *frame; + undefined2 in_register_0000202e; + uint uVar4; + int iVar5; + tx_hw_desc *ptVar6; + + _uVar3 = CONCAT22(in_register_0000202e,fctl); + frame = txl_frame_get((uint)(((vif->bss_info).chan)->band != '\0'),0x100); + if (frame == (txl_frame_desc_tag *)0x0) { + return; + } + ptVar2 = (frame->txdesc).lmac.buffer; + *(undefined *)((int)&ptVar2[1].length + 1) = (char)(fctl >> 8); + *(char *)&ptVar2[1].length = (char)fctl; + *(undefined *)((int)&ptVar2[1].length + 2) = 0; + *(undefined *)((int)&ptVar2[1].length + 3) = 0; + memcpy(&ptVar2[1].lenheader,ra,6); + memcpy((void *)((int)&ptVar2[1].lenpad + 2),&vif->mac_addr,6); + memcpy(&ptVar2[1].next,&vif->mac_addr,6); + uVar4 = (uint)txl_cntrl_env.seqnbr; + txl_cntrl_env.seqnbr = (uint16_t)((uVar4 + 1) * 0x10000 >> 0x10); + iVar5 = (uVar4 + 1) * 0x100000; + *(undefined *)((int)&ptVar2[1].txdesc + 2) = (char)((uint)iVar5 >> 0x10); + *(undefined *)((int)&ptVar2[1].txdesc + 3) = (char)((uint)iVar5 >> 0x18); + if (_uVar3 == 0xb0) { + uVar3 = me_build_authenticate((uint32_t)ptVar2[1].dma_desc,0,2,0,(uint32_t *)0x0); + _uVar3 = (uint)uVar3; + } + else { + if (_uVar3 == 0xc0) { + uVar3 = me_build_deauthenticate((uint32_t)ptVar2[1].dma_desc,status_code); + _uVar3 = (uint)uVar3; + } + else { + if (_uVar3 == 0x50) { + uVar3 = me_build_probe_rsp((uint32_t)ptVar2[1].dma_desc,vif->index); + _uVar3 = (uint)uVar3; + } + else { + uVar4 = 0x18; + if ((_uVar3 & 0xffffffdf) != 0x10) goto LAB_23013a78; + uVar3 = me_build_associate_rsp + ((uint32_t)ptVar2[1].dma_desc,vif->index,status_code,(me_sta_add_req *)env + ); + _uVar3 = (uint)uVar3; + } + } + } + uVar4 = _uVar3 + 0x18 & 0xffff; +LAB_23013a78: + ptVar6 = (frame->txdesc).lmac.hw_desc; + (ptVar6->thd).frmlen = uVar4 + 4; + (ptVar6->thd).field_5 = (ptVar6->thd).field_4 + -1 + uVar4; + uVar1 = vif->index; + (frame->txdesc).umac.head_len = '\0'; + (frame->txdesc).umac.tail_len = '\0'; + (frame->txdesc).host.vif_idx = uVar1; + (frame->txdesc).host.staid = -1; + (frame->cfm).cfm_func = cfm_func; + (frame->cfm).env = env; + txl_frame_push(frame,'\x03'); + return; +} + + + +_Bool apm_embedded_enabled(vif_info_tag *vif) + +{ + _Bool _Var1; + + if (vif != (vif_info_tag *)0x0) { + _Var1 = false; + if (vif->type == '\x02') { + _Var1 = apm_env.apm_emb_enabled; + } + return (_Bool)(_Var1 & 1); + } + return apm_env.apm_emb_enabled; +} + + + +void apm_bcn_set(void) + +{ + byte bVar1; + apm_start_req *paVar2; + _Bool _Var3; + uint32_t *puVar4; + undefined3 extraout_var; + + paVar2 = apm_env.param; + puVar4 = (uint32_t *) + ke_msg_alloc(0x3f,0,7,(uint16_t) + (((uint)(apm_env.param)->bcn_len + 0xc) * 0x10000 >> 0x10)); + *puVar4 = paVar2->bcn_addr; + *(uint16_t *)(puVar4 + 1) = paVar2->bcn_len; + *(uint16_t *)((int)puVar4 + 6) = paVar2->tim_oft; + *(uint8_t *)(puVar4 + 2) = paVar2->tim_len; + bVar1 = paVar2->vif_idx; + *(byte *)((int)puVar4 + 9) = bVar1; + _Var3 = apm_embedded_enabled(vif_info_tab + bVar1); + if (CONCAT31(extraout_var,_Var3) == 0) { + memcpy(puVar4 + 3,(void *)&paVar2->field_0xa7,(uint)paVar2->bcn_len); + } + else { + memcpy(puVar4 + 3,apm_env.bcn_buf,(uint)paVar2->bcn_len); + ke_free(apm_env.bcn_buf); + apm_env.bcn_buf = (uint8_t *)0x0; + } + ke_msg_send(puVar4); + ke_state_set(7,2); + return; +} + + + +void apm_probe_req_handler(ushort *param_1) + +{ + uint8_t uVar1; + ushort uVar2; + int iVar3; + vif_info_tag *vif; + uint __n; + scan_chan_tag *psVar4; + int iVar5; + uint uVar6; + + if (*(byte *)(param_1 + 4) == 0xff) { + vif = vif_mgmt_get_first_ap_inf(); + if (vif == (vif_info_tag *)0x0) { + return; + } + } + else { + vif = vif_info_tab + *(byte *)(param_1 + 4); + } + iVar3 = mac_ie_find(param_1 + 0x1a,(uint)*param_1 - 0x18 & 0xffff,0); + if ((iVar3 == 0) || (*(byte *)(iVar3 + 1) == 0)) { + if (apm_env.hidden_ssid != '\0') { + return; + } + } + else { + __n = (uint)(vif->bss_info).ssid.length; + if (__n != (uint)*(byte *)(iVar3 + 1)) { + return; + } + iVar3 = memcmp((void *)(iVar3 + 2),(vif->bss_info).ssid.array,__n); + if (iVar3 != 0) { + return; + } + } + iVar3 = mac_ie_find(param_1 + 0x1a,(uint)*param_1 - 0x18 & 0xffff,3); + if (iVar3 == 0) goto LAB_23013c60; + psVar4 = (vif->bss_info).chan; + uVar1 = psVar4->band; + uVar2 = psVar4->freq; + __n = (uint)uVar2; + if (uVar1 == '\0') { + uVar6 = 0; + if (((__n - 0x96c & 0xffff) < 0x49) && (uVar6 = 0xe, uVar2 != 0x9b4)) { + iVar5 = -0x967; +LAB_23013cd6: + uVar6 = (int)(__n + iVar5) / 5; + } + } + else { + uVar6 = 0; + if ((uVar1 == '\x01') && (uVar6 = 0, (__n - 0x138d & 0xffff) < 0x335)) { + iVar5 = -5000; + goto LAB_23013cd6; + } + } + if ((uint)*(byte *)(iVar3 + 2) != uVar6) { + return; + } +LAB_23013c60: + apm_send_mlme(vif,0x50,(mac_addr *)(param_1 + 0x13),(cfm_func_ptr *)0x0,(void *)0x0,0); + return; +} + + + +void apm_auth_handler(rxu_mgt_ind *param) + +{ + byte bVar1; + mac_addr *addr; + uint8_t sta_idx; + undefined3 extraout_var; + + bVar1 = param->inst_nbr; + if (bVar1 != 0xff) { + addr = (mac_addr *)(param[1].sa + 1); + sta_idx = hal_machw_search_addr(addr); + if (CONCAT31(extraout_var,sta_idx) != 0xff) { + apm_sta_delete(sta_idx,(uint8_t *)addr); + } + apm_send_mlme(vif_info_tab + bVar1,0xb0,addr,(cfm_func_ptr *)0x0,(void *)0x0,0); + return; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void apm_assoc_req_handler(ushort *param_1,int param_2) + +{ + uint8_t uVar1; + IEEEtypes_Addr_t IVar2; + uint8_t uVar3; + ushort *puVar4; + byte bVar5; + uint16_t status_code; + IEEEtypes_MacAddr_t *peerMacAddr; + int iVar6; + int iVar7; + undefined2 extraout_var; + uint8_t *puVar8; + int iVar9; + uint16_t fctl; + uint __n; + mac_rateset *pmVar10; + IEEEtypes_Addr_t *pIVar11; + IEEEtypes_Addr_t *pIVar12; + uint uVar13; + apm *paVar14; + mac_addr *ra; + short sVar15; + uint uVar16; + Cipher_t aCStack84 [4]; + undefined2 uStack80; + + uVar16 = (uint)*(byte *)(param_1 + 4); + if (*(byte *)(param_1 + 4) == 0xff) { + return; + } + peerMacAddr = (IEEEtypes_MacAddr_t *)ke_msg_alloc(0x1407,5,7,0x58); + ra = (mac_addr *)(param_1 + 0x13); + memset(peerMacAddr,0,0x58); + memcpy(peerMacAddr,ra,6); + (peerMacAddr + 0xc)[1] = *(IEEEtypes_Addr_t *)(param_1 + 4); + *(undefined4 *)(peerMacAddr + 0xc + 4) = *(undefined4 *)(param_1 + 8); + *(undefined4 *)(peerMacAddr + 0xd + 2) = *(undefined4 *)(param_1 + 10); + (peerMacAddr + 0xe)[0] = *(IEEEtypes_Addr_t *)(param_1 + 0xc); + (peerMacAddr + 0xe)[1] = *(IEEEtypes_Addr_t *)((int)param_1 + 0x1b); + if (param_2 == 0) { + puVar4 = param_1 + 0x1c; + uVar13 = (uint)*param_1 - 0x1c; + } + else { + puVar4 = param_1 + 0x1f; + uVar13 = (uint)*param_1 - 0x22; + } + status_code = 0x33; + if (param_1[0x1b] <= vif_info_tab[uVar16].bss_info.max_listen_interval) { + uVar13 = uVar13 & 0xffff; + iVar6 = mac_ie_find(puVar4,uVar13,0); + if (((iVar6 == 0) || + (__n = (uint)vif_info_tab[uVar16].bss_info.ssid.length, __n != (uint)*(byte *)(iVar6 + 1))) + || (iVar6 = memcmp((void *)(iVar6 + 2),vif_info_tab[uVar16].bss_info.ssid.array,__n), + iVar6 != 0)) { + status_code = 1; + } + else { + iVar7 = mac_ie_find(puVar4,uVar13,1); + status_code = 0x12; + if (iVar7 != 0) { + __n = (uint)*(byte *)(iVar7 + 1); + puVar8 = (uint8_t *)(iVar7 + 2); + uStack80 = uStack80 & 0xff00 | (ushort)*(byte *)(iVar7 + 1); + pmVar10 = (mac_rateset *)&uStack80; + while( true ) { + __n = __n - 1; + pmVar10 = (mac_rateset *)pmVar10->array; + if (__n == 0xffffffff) break; + uVar1 = *puVar8; + puVar8 = puVar8 + 1; + pmVar10->length = uVar1; + } + iVar7 = mac_ie_find(puVar4,uVar13,0x32); + if (iVar7 != 0) { + bVar5 = *(byte *)(iVar7 + 1); + __n = 0; + while ((uint)bVar5 != __n) { + *(undefined *)((int)&uStack80 + (byte)uStack80 + __n + 1) = + *(undefined *)(iVar7 + 2 + __n); + __n = __n + 1; + } + uStack80 = uStack80 & 0xff00 | (ushort)(byte)(bVar5 + (byte)uStack80); + } + status_code = me_legacy_rate_bitfield_build((mac_rateset *)&uStack80,false); + (peerMacAddr + 1)[0] = '\0'; + __n = 0; + while (__n < vif_info_tab[uVar16].bss_info.rate_set.length) { + iVar7 = (int)&vif_info_tab[uVar16].list_hdr.next + __n; + bVar5 = me_rate_translate(*(uint8_t *)(iVar7 + 0x3b1)); + if ((CONCAT22(extraout_var,status_code) >> ((uint)bVar5 & 0x1f) & 1U) == 0) { + if (*(char *)(iVar7 + 0x3b1) < '\0') { + status_code = 0x12; + goto fail; + } + } + else { + bVar5 = (peerMacAddr + 1)[0]; + (peerMacAddr + 1)[(uint)bVar5 + 1] = *(IEEEtypes_Addr_t *)(iVar7 + 0x3b1); + (peerMacAddr + 1)[0] = bVar5 + 1; + } + __n = __n + 1 & 0xff; + } + iVar7 = mac_ie_find(puVar4,uVar13,0x2d); + if (iVar7 != 0) { + *(undefined2 *)(peerMacAddr + 3 + 2) = *(undefined2 *)(iVar7 + 2); + pIVar11 = (IEEEtypes_Addr_t *)(iVar7 + 5); + (peerMacAddr + 3)[4] = *(IEEEtypes_Addr_t *)(iVar7 + 4); + pIVar12 = peerMacAddr + 3 + 5; + while (pIVar12 != peerMacAddr + 6 + 3) { + IVar2 = *pIVar11; + pIVar11 = pIVar11 + 1; + *pIVar12 = IVar2; + pIVar12 = pIVar12 + 1; + } + *(undefined2 *)(peerMacAddr + 6 + 4) = *(undefined2 *)(iVar7 + 0x15); + *(uint *)(peerMacAddr + 7 + 2) = (uint)*(ushort *)(iVar7 + 0x17); + (peerMacAddr + 8)[0] = *(IEEEtypes_Addr_t *)(iVar7 + 0x1b); + *(uint *)(peerMacAddr + 10 + 4) = *(uint *)(peerMacAddr + 10 + 4) | 2; + } + iVar7 = mac_vsie_find(puVar4,uVar13,&DAT_230ac93c,4); + if (iVar7 != 0) { + bVar5 = *(byte *)(iVar7 + 8); + *(uint *)(peerMacAddr + 10 + 4) = *(uint *)(peerMacAddr + 10 + 4) | 1; + (peerMacAddr + 0xb)[4] = bVar5 & 0xf; + (peerMacAddr + 0xb)[5] = bVar5 >> 4 & 6; + } + memset((mac_rateset *)&uStack80,0,2); + memset(aCStack84,0,1); + iVar7 = mac_ie_find(puVar4,uVar13,0x30); + if (iVar7 == 0) { + iVar7 = mac_vsie_find(puVar4,uVar13,&DAT_230ac944,4); + if (iVar7 != 0) { + uStack80 = uStack80 | 8; + aCStack84[0] = (Cipher_t)((byte)aCStack84[0] | 4); + } + } + else { + uStack80 = uStack80 | 0x20; + aCStack84[0] = (Cipher_t)((byte)aCStack84[0] | 8); + } + if (uap_conn_info != (cm_ConnectionInfo_t *)0x0) { + status_code = 0x2e; + if ((uStack80 & 0x28) == 0) goto fail; + InitStaKeyInfo(uap_conn_info,(SecurityMode_t *)(mac_rateset *)&uStack80,aCStack84,0,'\0'); + cm_SetPeerAddr(uap_conn_info,(IEEEtypes_MacAddr_t *)0x0,peerMacAddr); + } + uVar3 = apm_env.max_sta_supported; + uVar1 = apm_env.assoc_sta_count; + *(undefined2 *)(peerMacAddr + 0xb + 2) = 0; + if (uVar1 < uVar3) { + paVar14 = &apm_env; + iVar7 = -1; + do { + sVar15 = (short)iVar6; + if (paVar14->aid_list[0].used == '\0') { + if (iVar7 == -1) { + iVar7 = iVar6; + } + } + else { + iVar9 = memcmp(paVar14->aid_list,ra,6); + if (iVar9 == 0) { + apm_env.aid_list[iVar6].used = '\x01'; + goto LAB_230140f6; + } + } + sVar15 = (short)iVar7; + iVar6 = iVar6 + 1; + paVar14 = (apm *)((int)&(paVar14->bss_config).first + 3); + } while (iVar6 != 10); + if (iVar7 != -1) { + memcpy(apm_env.aid_list + iVar7,ra,6); + apm_env.aid_list[iVar7].used = '\x01'; +LAB_230140f6: + *(short *)(peerMacAddr + 0xb + 2) = sVar15 + 1; + apm_env.assoc_sta_count = apm_env.assoc_sta_count + '\x01'; + status_code = 0; + goto fail; + } + } + status_code = 0x11; + } + } + } +fail: + fctl = 0x30; + if (param_2 == 0) { + fctl = 0x10; + } + apm_send_mlme(vif_info_tab + uVar16,fctl,ra,apm_tx_cfm_handler,peerMacAddr,status_code); + return; +} + + + +void apm_deauth_handler(rxu_mgt_ind *param) + +{ + if ((param->inst_nbr != -1) && (param->sta_idx != -1)) { + apm_sta_delete(param->sta_idx,param[1].sa + 1); + return; + } + return; +} + + + +void apm_disassoc_handler(rxu_mgt_ind *param) + +{ + byte bVar1; + + bVar1 = param->inst_nbr; + if ((bVar1 != 0xff) && (param->sta_idx != -1)) { + apm_sta_delete(param->sta_idx,(uint8_t *)(mac_addr *)(param[1].sa + 1)); + apm_send_mlme(vif_info_tab + bVar1,0xc0,(mac_addr *)(param[1].sa + 1),(cfm_func_ptr *)0x0, + (void *)0x0,2); + return; + } + return; +} + + + +void apm_beacon_handler(rxu_mgt_ind *param) + +{ + return; +} + + + +void apm_sta_remove(uint8_t vif_idx,uint8_t sta_idx) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + + apm_send_mlme(vif_info_tab + CONCAT31(in_register_00002029,vif_idx),0xc0, + &sta_info_tab[CONCAT31(in_register_0000202d,sta_idx)].mac_addr,(cfm_func_ptr *)0x0, + (void *)0x0,2); + apm_sta_delete(sta_idx,(uint8_t *)&sta_info_tab[CONCAT31(in_register_0000202d,sta_idx)].mac_addr); + return; +} + + + +char * cfg_api_element_dump(void *val,CFG_ELEMENT_TYPE type,char *strs) + +{ + int iVar1; + char *pcVar2; + + switch((uint)type - 1 & 0xff) { + case 0: + if (*(char *)val == '\0') { + pcVar2 = "False"; + } + else { + pcVar2 = "True"; + } + iVar1 = snprintf(strs,0xf,"%s",pcVar2); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "Boolean"; + break; + case 1: + iVar1 = snprintf(strs,0xf,"%d",(int)*(char *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "SINT8"; + break; + case 2: + iVar1 = snprintf(strs,0xf,"%u",(uint)*(byte *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "UINT8"; + break; + case 3: + iVar1 = snprintf(strs,0xf,"%d",(int)*(short *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "SINT16"; + break; + case 4: + iVar1 = snprintf(strs,0xf,"%u",(uint)*(ushort *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "UINT16"; + break; + case 5: + iVar1 = snprintf(strs,0xf,"%ld",*(undefined4 *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "SINT32"; + break; + case 6: + iVar1 = snprintf(strs,0xf,"%lu",*(undefined4 *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "UINT32"; + break; + case 7: + iVar1 = snprintf(strs,0xf,"%lu",*(undefined4 *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "STRING"; + break; + default: + return (char *)0x0; + } + return pcVar2; +} + + + +int cfg_api_element_general_set(cfg_element_entry *entry,void *arg1,void *arg2) + +{ + undefined uVar1; + undefined2 uVar2; + uint uVar3; + undefined4 *puVar4; + + printf(" updating element: %s\r\n",entry->name); + uVar3 = (uint)entry->type - 1 & 0xffff; + if (6 < uVar3) { + return 0; + } + puVar4 = (undefined4 *)entry->val; + switch(uVar3) { + default: + uVar1 = *(undefined *)arg1; + break; + case 1: + uVar1 = *(undefined *)arg1; + break; + case 3: + uVar2 = *(undefined2 *)arg1; + goto LAB_230143ec; + case 4: + uVar2 = *(undefined2 *)arg1; +LAB_230143ec: + *(undefined2 *)puVar4 = uVar2; + return 0; + case 5: + case 6: + *puVar4 = *(undefined4 *)arg1; + return 0; + } + *(undefined *)puVar4 = uVar1; + return 0; +} + + + +int cfg_api_element_general_get(cfg_element_entry *entry,void *arg1,void *arg2) + +{ + return 0; +} + + + +int cfg_api_element_set(uint32_t task,uint32_t element,uint32_t type,void *arg1,void *arg2) + +{ + cfg_element_entry *pcVar1; + + pcVar1 = cfg_entrys_mm; + while (pcVar1 < &_fsymc_info_bloop) { + if ((pcVar1->task == task) && ((uint)pcVar1->element == element)) { + if ((uint)pcVar1->type == type) goto LAB_23014454; + printf("type %lu NOT matched on element: %lu %lu %u\r\n",type,task,element); + } + pcVar1 = pcVar1 + 1; + } + if (pcVar1 != (cfg_element_entry *)&_fsymc_info_bloop) { +LAB_23014454: + (*pcVar1->set)(pcVar1,arg1,arg2); + } + return 0; +} + + + +void co_list_init(co_list *list) + +{ + list->first = (co_list_hdr *)0x0; + list->last = (co_list_hdr *)0x0; + return; +} + + + +void co_list_push_back(co_list *list,co_list_hdr *list_hdr) + +{ + if (list_hdr == (co_list_hdr *)0x0) { + assert_err("list_hdr != NULL","module",0x47); + } + if (list->first == (co_list_hdr *)0x0) { + list->first = list_hdr; + } + else { + list->last->next = list_hdr; + } + list->last = list_hdr; + list_hdr->next = (co_list_hdr *)0x0; + return; +} + + + +void co_list_push_front(co_list *list,co_list_hdr *list_hdr) + +{ + if (list_hdr == (co_list_hdr *)0x0) { + assert_err("list_hdr != NULL","module",0x5e); + } + if (list->first == (co_list_hdr *)0x0) { + list->last = list_hdr; + } + list_hdr->next = list->first; + list->first = list_hdr; + return; +} + + + +co_list_hdr * co_list_pop_front(co_list *list) + +{ + co_list_hdr *pcVar1; + + pcVar1 = list->first; + if (pcVar1 != (co_list_hdr *)0x0) { + list->first = pcVar1->next; + } + return pcVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +void co_list_extract(co_list *list,co_list_hdr *list_hdr) + +{ + co_list_hdr cVar1; + co_list_hdr cVar2; + + if (list == (co_list *)0x0) { + assert_err("list != NULL","module",0x81); + } + cVar1 = (co_list_hdr)list->first; + if (cVar1 != (co_list_hdr)0x0) { + if (cVar1 == (co_list_hdr)list_hdr) { + list->first = list_hdr->next; + } + else { + do { + cVar2 = cVar1; + cVar1 = *(co_list_hdr *)cVar2; + if (cVar1 == (co_list_hdr)0x0) { + return; + } + } while (cVar1 != (co_list_hdr)list_hdr); + if (list->last == list_hdr) { + *(co_list_hdr *)&((co_list_hdr *)&list->last)->next = cVar2; + } + *(co_list_hdr **)cVar2 = list_hdr->next; + } + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +uint32_t co_list_cnt(co_list *list) + +{ + uint32_t uVar1; + int *piVar2; + + piVar2 = (int *)list->first; + uVar1 = 0; + while (piVar2 != (int *)0x0) { + uVar1 = uVar1 + 1; + piVar2 = (int *)*piVar2; + } + return uVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +void co_list_insert(co_list *list,co_list_hdr *element, + anon_subr__Bool_co_list_hdr_ptr_co_list_hdr_ptr *cmp) + +{ + co_list_hdr cVar1; + co_list_hdr cVar2; + _Bool _Var3; + undefined3 extraout_var; + co_list_hdr cVar4; + + cVar1 = (co_list_hdr)list->first; + cVar4 = (co_list_hdr)(co_list_hdr *)0x0; + while (cVar2 = cVar1, cVar2 != (co_list_hdr)0x0) { + _Var3 = (*cmp)(element,(co_list_hdr *)cVar2); + if (CONCAT31(extraout_var,_Var3) != 0) goto LAB_230145a8; + cVar1 = *(co_list_hdr *)cVar2; + cVar4 = cVar2; + } + list->last = element; +LAB_230145a8: + *(co_list_hdr *)&element->next = cVar2; + if (cVar4 == (co_list_hdr)0x0) { + list->first = element; + } + else { + ((co_list_hdr *)cVar4)->next = element; + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void co_list_insert_after(co_list *list,co_list_hdr *prev_element,co_list_hdr *element) + +{ + co_list_hdr cVar1; + + cVar1 = (co_list_hdr)list->first; + if (prev_element == (co_list_hdr *)0x0) { + co_list_push_front(list,element); + return; + } + while( true ) { + if (cVar1 == (co_list_hdr)0x0) { + return; + } + if (cVar1 == (co_list_hdr)prev_element) break; + cVar1 = *(co_list_hdr *)cVar1; + } + element->next = *(co_list_hdr **)cVar1; + *(co_list_hdr **)cVar1 = element; + if (element->next != (co_list_hdr *)0x0) { + return; + } + list->last = element; + return; +} + + + +void co_list_remove(co_list *list,co_list_hdr *prev_element,co_list_hdr *element) + +{ + if (list == (co_list *)0x0) { + assert_err("list != NULL","module",0x168); + } + if (prev_element == (co_list_hdr *)0x0) { + if (element == (co_list_hdr *)0x0) goto LAB_2301464c; +LAB_23014666: + list->first = element->next; + } + else { + if (prev_element->next != element) { + assert_err("(prev_element == NULL) || (prev_element->next == element)","module",0x169); + } + if (element == (co_list_hdr *)0x0) { +LAB_2301464c: + assert_err("element != NULL","module",0x16a); + if (prev_element == (co_list_hdr *)0x0) goto LAB_23014666; + } + prev_element->next = element->next; + if (list->last == element) { + list->last = prev_element; + } + } + element->next = (co_list_hdr *)0x0; + return; +} + + + +uint32_t co_crc32(uint32_t addr,uint32_t len,uint32_t crc) + +{ + uint32_t uVar1; + byte *pbVar2; + + uVar1 = 0; + while (uVar1 != len) { + pbVar2 = (byte *)(uVar1 + addr); + uVar1 = uVar1 + 1; + crc = crc << 8 ^ crc_tab[crc >> 0x18 ^ (uint)*pbVar2]; + } + return crc; +} + + + +void dbg_init(void) + +{ + memset(&dbg_env,0,8); + dbg_env.filter_module = 0xffffffff; + dbg_env.filter_severity = 2; + return; +} + + +/* +Unable to decompile 'ke_evt_set' +Cause: Exception while decompiling 230146d6: Decompiler process died + +*/ + +/* +Unable to decompile 'ke_evt_clear' +Cause: Exception while decompiling 230146ee: Decompiler process died + +*/ + + +void bl_event_handle(int param) + +{ + ke_evt_clear(0x40000000); + bl_main_event_handle(); + return; +} + + +/* +Unable to decompile 'bl_fw_statistic_dump' +Cause: Exception while decompiling 2301471e: Decompiler process died + +*/ + + +void bl60x_fw_dump_statistic(int forced) + +{ + if (forced != 0) { + bl_fw_statistic_dump(0); + return; + } + ke_evt_set(0x20); + return; +} + + + +void ke_evt_schedule(void) + +{ + int iVar1; + evt_ptr_t *peVar2; + + while (ke_env.evt_field != 0) { + iVar1 = __clzsi2(ke_env.evt_field); + peVar2 = ke_evt_hdlr[iVar1].func; + if ((0x1a < iVar1) || (peVar2 == (evt_ptr_t *)0x0)) { + assert_err("(event < KE_EVT_MAX) && ke_evt_hdlr[event].func","module",0xdd); + } + (*peVar2)(ke_evt_hdlr[iVar1].param); + } + return; +} + + + +void ke_init(void) + +{ + ke_env.mblock_first = ke_mem_init(); + ke_env.queue_saved.first = (co_list_hdr *)0x0; + ke_env.queue_saved.last = (co_list_hdr *)0x0; + ke_env.queue_sent.first = (co_list_hdr *)0x0; + ke_env.queue_sent.last = (co_list_hdr *)0x0; + ke_env.queue_timer.first = (co_list_hdr *)0x0; + ke_env.queue_timer.last = (co_list_hdr *)0x0; + ke_evt_clear(0xffffffff); + return; +} + + +/* +Unable to decompile 'ke_mem_init' +Cause: Exception while decompiling 23014816: Decompiler process died + +*/ + +/* +Unable to decompile 'ke_malloc' +Cause: Exception while decompiling 2301483c: Decompiler process died + +*/ + +/* +Unable to decompile 'ke_free' +Cause: Exception while decompiling 230148d0: Decompiler process died + +*/ + + +void * ke_msg_alloc(ke_msg_id_t id,ke_task_id_t dest_id,ke_task_id_t src_id,uint16_t param_len) + +{ + undefined4 *puVar1; + undefined2 in_register_00002036; + + puVar1 = (undefined4 *)ke_malloc(CONCAT22(in_register_00002036,param_len) + 0xc); + if (puVar1 == (undefined4 *)0x0) { + assert_err("msg != NULL","module",0x50); + } + *(ke_msg_id_t *)(puVar1 + 1) = id; + *(ke_task_id_t *)((int)puVar1 + 6) = dest_id; + *(ke_task_id_t *)(puVar1 + 2) = src_id; + *(uint16_t *)((int)puVar1 + 10) = param_len; + *puVar1 = 0; + memset(puVar1 + 3,0,CONCAT22(in_register_00002036,param_len)); + return puVar1 + 3; +} + + + +void ke_msg_send(int param_1) + +{ + if (*(byte *)(param_1 + -6) < 0xf) { + if (*(byte *)(param_1 + -6) < 0xd) { + co_list_push_back(&ke_env.queue_sent,(co_list_hdr *)(param_1 + -0xc)); + ke_evt_set(0x1000000); + return; + } + } + else { + assert_err("id <= TASK_MAX","module",0xb6); + } + bl_rx_e2a_handler((void *)(param_1 + -8)); + ke_free((co_list_hdr *)(param_1 + -0xc)); + return; +} + + + +void ke_msg_send_basic(ke_msg_id_t id,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_msg_alloc(id,dest_id,src_id,0); + ke_msg_send(); + return; +} + + + +void ke_msg_forward_and_change_id + (void *param_ptr,ke_msg_id_t msg_id,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + *(ke_msg_id_t *)((int)param_ptr + -8) = msg_id; + *(ke_task_id_t *)((int)param_ptr + -6) = dest_id; + *(ke_task_id_t *)((int)param_ptr + -4) = src_id; + ke_msg_send(); + return; +} + + +/* +Unable to decompile 'ke_msg_free' +Cause: Exception while decompiling 23014a9a: Decompiler process died + +*/ + + +_Bool cmp_dest_id(co_list_hdr *msg,uint32_t dest_id) + +{ + return (_Bool)((uint)*(ushort *)((int)&msg[1].next + 2) == dest_id); +} + + + +_Bool ke_task_local(ke_task_id_t id) + +{ + undefined2 in_register_0000202a; + + if (0xe < CONCAT22(in_register_0000202a,id)) { + assert_err("id <= TASK_MAX","module",0xb6); + } + return (_Bool)(CONCAT22(in_register_0000202a,id) < 0xd); +} + + + +ke_msg_func_t * ke_handler_search(ke_msg_id_t msg_id,ke_state_handler *state_handler) + +{ + undefined2 in_register_0000202a; + int iVar1; + + iVar1 = (uint)state_handler->msg_cnt - 1; + if (iVar1 == -1) { + return (ke_msg_func_t *)0x0; + } + do { + if ((uint)state_handler->msg_table[iVar1].id == CONCAT22(in_register_0000202a,msg_id)) { + if (state_handler->msg_table[iVar1].func == (ke_msg_func_t *)0x0) { + assert_err("state_handler->msg_table[i].func","module",0xf4); + } + return state_handler->msg_table[iVar1].func; + } + iVar1 = iVar1 + -1; + } while (iVar1 != -1); + return (ke_msg_func_t *)0x0; +} + + +/* +Unable to decompile 'ke_state_set' +Cause: Exception while decompiling 23014b3c: Decompiler process died + +*/ + + +ke_state_t ke_state_get(ke_task_id_t id) + +{ + uint uVar1; + _Bool _Var2; + undefined2 in_register_0000202a; + undefined3 extraout_var; + uint uVar3; + + uVar1 = (uint)id & 0xff; + uVar3 = CONCAT22(in_register_0000202a,id) >> 8; + if (0xd < uVar1) { + assert_err("type < TASK_MAX","module",0xd7); + } + _Var2 = ke_task_local((ke_task_id_t)uVar1); + if (CONCAT31(extraout_var,_Var2) == 0) { + assert_err("ke_task_local(type)","module",0xd8); + } + if (TASK_DESC[uVar1].idx_max <= uVar3) { + assert_err("idx < TASK_DESC[type].idx_max","module",0xd9); + } + return TASK_DESC[uVar1].state[uVar3]; +} + + +/* +Unable to decompile 'ke_task_schedule' +Cause: Exception while decompiling 23014cd4: Decompiler process died + +*/ + + +int ke_msg_discard(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + return 0; +} + + + +int ke_msg_save(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + return 2; +} + + +/* +Unable to decompile 'ke_timer_hw_set' +Cause: Exception while decompiling 23014e42: Decompiler process died + +*/ + + +_Bool cmp_abs_time(co_list_hdr *timerA,co_list_hdr *timerB) + +{ + return (_Bool)((co_list_hdr *)0x11e1a300 < + (co_list_hdr *)((int)timerA[2].next - (int)timerB[2].next)); +} + + + +_Bool cmp_timer_id(co_list_hdr *timer,uint32_t timer_task) + +{ + if ((uint)*(ushort *)&timer[1].next == timer_task >> 0x10) { + return (_Bool)((uint)*(ushort *)((int)&timer[1].next + 2) == (timer_task & 0xffff)); + } + return false; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ke_timer_set(ke_msg_id_t timer_id,ke_task_id_t task_id,uint32_t delay) + +{ + bool bVar1; + co_list_hdr *pcVar2; + undefined2 in_register_0000202a; + char *condition; + co_list_hdr *element; + undefined2 in_register_0000202e; + int line; + + if (delay == 0) { + line = 0x8c; + condition = "delay > 0"; + } + else { + if (delay < 300000000) goto LAB_23014ef0; + line = 0x8d; + condition = "delay < KE_TIMER_DELAY_MAX"; + } + assert_err(condition,"module",line); +LAB_23014ef0: + bVar1 = false; + if ((ke_env.queue_timer.first != (co_list_hdr *)0x0) && + ((uint)*(ushort *)&ke_env.queue_timer.first[1].next == CONCAT22(in_register_0000202a,timer_id)) + ) { + bVar1 = (uint)*(ushort *)((int)&ke_env.queue_timer.first[1].next + 2) == + CONCAT22(in_register_0000202e,task_id); + } + element = ke_queue_extract(&ke_env.queue_timer,cmp_timer_id, + CONCAT22(in_register_0000202a,timer_id) << 0x10 | + CONCAT22(in_register_0000202e,task_id)); + if (element == (co_list_hdr *)0x0) { + element = (co_list_hdr *)ke_malloc(0xc); + if (element == (co_list_hdr *)0x0) { + assert_err("timer","module",0x9d); + } + *(ke_msg_id_t *)&element[1].next = timer_id; + *(ke_task_id_t *)((int)&element[1].next + 2) = task_id; + } + pcVar2 = (co_list_hdr *)(delay + _DAT_44b00120); + element[2].next = pcVar2; + co_list_insert(&ke_env.queue_timer,element,cmp_abs_time); + if ((bVar1) || (ke_env.queue_timer.first == element)) { + ke_timer_hw_set(ke_env.queue_timer.first); + } + if ((int)((int)pcVar2 - _DAT_44b00120) < 0) { + ke_evt_set(0x4000000); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ke_timer_clear(ke_msg_id_t timer_id,ke_task_id_t task_id) + +{ + co_list_hdr *pcVar1; + undefined2 in_register_0000202a; + co_list_hdr *mem_ptr; + undefined2 in_register_0000202e; + + mem_ptr = ke_env.queue_timer.first; + if (ke_env.queue_timer.first == (co_list_hdr *)0x0) { + return; + } + if (((uint)*(ushort *)&ke_env.queue_timer.first[1].next == CONCAT22(in_register_0000202a,timer_id) + ) && ((uint)*(ushort *)((int)&ke_env.queue_timer.first[1].next + 2) == + CONCAT22(in_register_0000202e,task_id))) { + co_list_pop_front(&ke_env.queue_timer); + pcVar1 = ke_env.queue_timer.first; + ke_timer_hw_set(ke_env.queue_timer.first); + if ((pcVar1 != (co_list_hdr *)0x0) && ((int)((int)pcVar1[2].next - _DAT_44b00120) < 0)) { + assert_err("!first || !ke_time_past(first->time)","module",0xd7); + } + } + else { + mem_ptr = ke_queue_extract(&ke_env.queue_timer,cmp_timer_id, + CONCAT22(in_register_0000202a,timer_id) << 0x10 | + CONCAT22(in_register_0000202e,task_id)); + if (mem_ptr == (co_list_hdr *)0x0) { + return; + } + } + ke_free(mem_ptr); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ke_timer_schedule(int dummy) + +{ + co_list_hdr *mem_ptr; + + while( true ) { + ke_evt_clear(0x4000000); + mem_ptr = ke_env.queue_timer.first; + if (ke_env.queue_timer.first == (co_list_hdr *)0x0) { + ke_timer_hw_set(0); + return; + } + if ((-1 < (int)ke_env.queue_timer.first[2].next + (-0x32 - _DAT_44b00120)) && + (ke_timer_hw_set(ke_env.queue_timer.first), -1 < (int)((int)mem_ptr[2].next - _DAT_44b00120)) + ) break; + mem_ptr = co_list_pop_front(&ke_env.queue_timer); + ke_msg_send_basic(*(ke_msg_id_t *)&mem_ptr[1].next,*(ke_task_id_t *)((int)&mem_ptr[1].next + 2), + 0xff); + ke_free(mem_ptr); + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void bl60x_current_time_us(longlong *time_now) + +{ + undefined4 uVar1; + + uVar1 = _DAT_44b080a8; + *(undefined4 *)time_now = _DAT_44b080a4; + *(undefined4 *)((int)time_now + 4) = uVar1; + return; +} + + + +byte * mac_ie_find(byte *param_1,int param_2,uint param_3) + +{ + byte *pbVar1; + + pbVar1 = param_1 + param_2; + while( true ) { + if (pbVar1 <= param_1) { + return (byte *)0; + } + if ((uint)*param_1 == param_3) break; + param_1 = param_1 + (uint)param_1[1] + 2; + } + return param_1; +} + + + +char * mac_vsie_find(char *param_1,int param_2,int param_3,int param_4) + +{ + int iVar1; + char *pcVar2; + int iVar3; + + pcVar2 = param_1 + param_2; + while (param_1 < pcVar2) { + if (*param_1 == -0x23) { + iVar3 = 0; + do { + if (param_4 == iVar3) { + return param_1; + } + iVar1 = iVar3 + 2; + iVar3 = iVar3 + 1; + } while (*(char *)(param_3 + iVar3 + -1) == param_1[iVar1]); + } + param_1 = param_1 + (uint)(byte)param_1[1] + 2; + } + if (param_1 != pcVar2) { + puts("--->>> addr != end\r\n"); + return (char *)0; + } + return (char *)0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BufferDesc_t * +GetTxEAPOLBuffer(cm_ConnectionInfo_t *connPtr,EAPOL_KeyMsg_Tx_t **ppTxEapol,BufferDesc_t *pBufDesc) + +{ + char "GetTxEAPOLBuffer" [17]; + void *pvVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"GetTxEAPOLBuffer"); + if (pBufDesc == (BufferDesc_t *)0x0) { + pBufDesc = (BufferDesc_t *)ke_malloc(0xc); + if (pBufDesc != (BufferDesc_t *)0x0) { + memset(pBufDesc,0,0xc); + pvVar1 = ke_malloc(0x200); + pBufDesc->Buffer = pvVar1; + if (pvVar1 != (void *)0x0) goto LAB_23015204; + } + pBufDesc = (BufferDesc_t *)0x0; + } + else { +LAB_23015204: + *(cm_ConnectionInfo_t **)&pBufDesc->intf = connPtr; + *ppTxEapol = (EAPOL_KeyMsg_Tx_t *)pBufDesc->Buffer; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad2a0); + } + return pBufDesc; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void UpdateEAPOLWcbLenAndTransmit(BufferDesc_t *pBufDesc,UINT16 frameLen) + +{ + char "UpdateEAPOLWcbLenAndTransmit" [29]; + undefined2 in_register_0000202e; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"UpdateEAPOLWcbLenAndTransmit"); + txl_frame_send_eapol_frame + (*(uint8_t *)(pBufDesc->intf + 1),(cfm_func_ptr *)0x0,(void *)0x0, + (uint8_t *)((int)pBufDesc->Buffer + 0xe),CONCAT22(in_register_0000202e,frameLen) + 4); + ke_free(pBufDesc->Buffer); + ke_free(pBufDesc); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad2c8); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN keyMgmtProcessMsgExt(keyMgmtInfoSta_t *pKeyMgmtInfoSta,EAPOL_KeyMsg_t *pKeyMsg) + +{ + char "keyMgmtProcessMsgExt" [21]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtProcessMsgExt"); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad2e8); + return 1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmtInitSta(cm_ConnectionInfo_t *connPtr) + +{ + char "KeyMgmtInitSta" [15]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtInitSta"); + KeyMgmtSta_InitSession(&connPtr->suppData->keyMgmtInfoSta); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad300); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void keyMgmtSta_StartSession(cm_ConnectionInfo_t *connPtr,CHAR *pBssid,UINT8 *pStaAddr) + +{ + char "keyMgmtSta_StartSession" [24]; + supplicantData *psVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtSta_StartSession"); + psVar1 = connPtr->suppData; + *(cm_ConnectionInfo_t **)&(psVar1->keyMgmtInfoSta).connPtr = connPtr; + memcpy(connPtr->suppData->localStaAddr,pStaAddr,6); + memcpy(connPtr->suppData->localBssid,pBssid,6); + keyMgmtSta_StartSession_internal(&psVar1->keyMgmtInfoSta,10000000); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad3ac); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void init_customApp_mibs(supplicantData_t *suppData) + +{ + char "init_customApp_mibs" [20]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"init_customApp_mibs"); + memset(&suppData->customMIB_RSNStats,0,3); + memset(&suppData->customMIB_RSNConfig,0,0x1c); + *(ushort *)&(suppData->customMIB_RSNConfig).wpaType = + (ushort)(suppData->customMIB_RSNConfig).wpaType | 1; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad3dc); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT8 supplicantIsEnabled(void *connectionPtr) + +{ + byte bVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantIsEnabled"); + bVar1 = 0; + if (*(int *)((int)connectionPtr + 8) != 0) { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"supplicantIsEnabled"); + bVar1 = (byte)((uint)*(undefined4 *)(*(int *)((int)connectionPtr + 8) + 0x34) >> 8) & 1; + } + return (UINT8)bVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantInitSession + (cm_ConnectionInfo_t *connPtr,CHAR *pSsid,UINT16 len,CHAR *pBssid,UINT8 *pStaAddr) + +{ + char "supplicantInitSession" [22]; + UINT8 UVar1; + undefined3 extraout_var; + undefined2 in_register_00002032; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantInitSession"); + UVar1 = supplicantIsEnabled(connPtr); + if (CONCAT31(extraout_var,UVar1) != 0) { + KeyMgmtInitSta(connPtr); + memcpy((connPtr->suppData->hashSsId).SsId,pSsid,CONCAT22(in_register_00002032,len)); + (connPtr->suppData->hashSsId).Len = (IEEEtypes_Len_t)len; + keyMgmtSta_StartSession(connPtr,pBssid,pStaAddr); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad3c4); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantDisable(cm_ConnectionInfo_t *connPtr) + +{ + char "supplicantDisable" [18]; + UINT8 UVar1; + undefined3 extraout_var; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantDisable"); + UVar1 = supplicantIsEnabled(connPtr); + if (CONCAT31(extraout_var,UVar1) != 0) { + mm_timer_clear(&(connPtr->suppData->keyMgmtInfoSta).rsnTimer); + *(byte *)&connPtr->suppData->customMIB_RSNConfig = + *(byte *)&connPtr->suppData->customMIB_RSNConfig & 0xfe; + init_customApp_mibs((supplicantData_t *)connPtr->suppData); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad404); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantEnable(void *connectionPtr,int security_mode,void *mcstCipher,void *ucstCipher, + _Bool is_pmf_required) + +{ + char "supplicantEnable" [17]; + int iVar1; + UINT8 *__src; + undefined3 in_register_00002039; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantEnable"); + *(byte *)(*(int *)((int)connectionPtr + 8) + 0x35) = + *(byte *)(*(int *)((int)connectionPtr + 8) + 0x35) | 1; + if (security_mode - 4U < 3) { + *(ushort *)(*(int *)((int)connectionPtr + 8) + 0x36) = + *(ushort *)(*(int *)((int)connectionPtr + 8) + 0x36) | 0x20; + *(byte *)(*(int *)((int)connectionPtr + 8) + 0x35) = + *(byte *)(*(int *)((int)connectionPtr + 8) + 0x35) | 4; + *(ushort *)(*(int *)((int)connectionPtr + 8) + 0x4e) = + *(ushort *)(*(int *)((int)connectionPtr + 8) + 0x4e) | 1; + memcpy((void *)(*(int *)((int)connectionPtr + 8) + 0x38),mcstCipher,1); + memcpy((void *)(*(int *)((int)connectionPtr + 8) + 0x39),ucstCipher,1); + if (CONCAT31(in_register_00002039,is_pmf_required) == 0) { + *(undefined *)(*(int *)((int)connectionPtr + 8) + 0x3d) = 2; + } + else { + *(undefined *)(*(int *)((int)connectionPtr + 8) + 0x3d) = 6; + } + iVar1 = *(int *)((int)connectionPtr + 8); + __src = ""; + } + else { + if (security_mode != 3) goto LAB_230156bc; + *(ushort *)(*(int *)((int)connectionPtr + 8) + 0x36) = + *(ushort *)(*(int *)((int)connectionPtr + 8) + 0x36) | 8; + memcpy((void *)(*(int *)((int)connectionPtr + 8) + 0x38),mcstCipher,1); + memcpy((void *)(*(int *)((int)connectionPtr + 8) + 0x39),ucstCipher,1); + *(undefined *)(*(int *)((int)connectionPtr + 8) + 0x3d) = 2; + iVar1 = *(int *)((int)connectionPtr + 8); + __src = ""; + } + memcpy((void *)(iVar1 + 0x3a),__src,3); +LAB_230156bc: + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad418); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT16 keyMgmtFormatWpaRsnIe + (cm_ConnectionInfo_t *connPtr,UINT8 *pos,IEEEtypes_MacAddr_t *pBssid, + IEEEtypes_MacAddr_t *pStaAddr,UINT8 *pPmkid,BOOLEAN addPmkid) + +{ + char "keyMgmtFormatWpaRsnIe" [22]; + uint16_t uVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtFormatWpaRsnIe"); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad42c); + uVar1 = mm_get_rsn_wpa_ie(connPtr->staId,pos); + return (UINT16)uVar1; +} + + + +// WARNING: Variable defined which should be unmapped: pTxEapol +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +Status_e GeneratePWKMsg2(BufferDesc_t *pEAPoLBufDesc,UINT8 *pSNonce,UINT8 *pEAPOLMICKey, + UINT8 forceKeyDescVersion) + +{ + EAPOL_KeyMsg_Tx_t *pEVar1; + char "GeneratePWKMsg2" [16]; + cm_ConnectionInfo_t *connPtr; + Status_e SVar2; + UINT16 frameLen; + BufferDesc_t *pBufDesc; + EAPOL_KeyMsg_t *pRxEapol; + EAPOL_KeyMsg_Tx_t *pEStack36; + EAPOL_KeyMsg_Tx_t *pTxEapol; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"GeneratePWKMsg2"); + connPtr = (cm_ConnectionInfo_t *)pEAPoLBufDesc->intf; + pRxEapol = (EAPOL_KeyMsg_t *)pEAPoLBufDesc->Buffer; + pBufDesc = GetTxEAPOLBuffer(connPtr,&pEStack36,(BufferDesc_t *)0x0); + if (pBufDesc == (BufferDesc_t *)0x0) { + SVar2 = FAIL; + } + else { + KeyMgmtSta_PrepareEAPOLFrame + (pEStack36,pRxEapol,(IEEEtypes_MacAddr_t *)connPtr->suppData->localBssid, + (IEEEtypes_MacAddr_t *)connPtr->suppData->localStaAddr,pSNonce); + pEVar1 = pEStack36; + if ((pEStack36->keyMsg).desc_type != '\x01') { + frameLen = keyMgmtFormatWpaRsnIe + (connPtr,(pEStack36->keyMsg).key_data, + (IEEEtypes_MacAddr_t *)connPtr->suppData->localBssid, + (IEEEtypes_MacAddr_t *)connPtr->suppData->localStaAddr,(UINT8 *)0x0,0); + *(char *)&(pEVar1->keyMsg).key_material_len = (char)frameLen; + *(undefined *)((int)&(pEVar1->keyMsg).key_material_len + 1) = (char)(frameLen >> 8); + } + frameLen = KeyMgmtSta_PopulateEAPOLLengthMic(pEStack36,pEAPOLMICKey,'\x01',forceKeyDescVersion); + UpdateEAPOLWcbLenAndTransmit(pBufDesc,frameLen); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad310); + SVar2 = FW_SUCCESS; + } + return SVar2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN KeyMgmtStaHsk_Recvd_PWKMsg1 + (BufferDesc_t *pEAPoLBufDesc,IEEEtypes_MacAddr_t *sa,IEEEtypes_MacAddr_t *da) + +{ + char "KeyMgmtStaHsk_Recvd_PWKMsg1" [28]; + int iVar1; + int iVar2; + Status_e SVar3; + EAPOL_KeyMsg_t *pEVar4; + BOOLEAN BVar5; + UINT8 *pPMK; + undefined3 extraout_var; + int iVar6; + keyMgmtInfoSta_t *pKeyMgmtInfoSta; + BOOLEAN in_fa0; + + iVar6 = pEAPoLBufDesc->intf; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtStaHsk_Recvd_PWKMsg1"); + iVar1 = *(int *)(iVar6 + 8); + pKeyMgmtInfoSta = (keyMgmtInfoSta_t *)(iVar1 + 0x54); + pEVar4 = GetKeyMsgNonceFromEAPOL(pEAPoLBufDesc,pKeyMgmtInfoSta); + if (pEVar4 == (EAPOL_KeyMsg_t *)0x0) { +LAB_230158d8: + iVar2 = 0; + } + else { + iVar2 = supplicantAkmIsWpaWpa2((AkmSuite_t *)(*(int *)(iVar6 + 8) + 0x3a)); + if (iVar2 != 0) { + BVar5 = supplicantAkmIsWpaWpa2Psk((AkmSuite_t *)(*(int *)(iVar6 + 8) + 0x3a)); + if ((BVar5 == 0) || + (pPMK = pmkCacheFindPSK((UINT8 *)(*(int *)(iVar6 + 8) + 6), + *(UINT8 *)(*(int *)(iVar6 + 8) + 5)), pPMK == (UINT8 *)0x0)) + goto LAB_230158d8; + supplicantAkmUsesKdf((AkmSuite_t *)(*(int *)(iVar6 + 8) + 0x3a)); + KeyMgmtSta_DeriveKeys + (pPMK,da,sa,(UINT8 *)pKeyMgmtInfoSta,(UINT8 *)(iVar1 + 0x74),(UINT8 *)(iVar1 + 0x94) + ,(UINT8 *)(iVar1 + 0xa4),(KeyData_t *)(iVar1 + 0x128),in_fa0); + iVar2 = 1; + } + SVar3 = GeneratePWKMsg2(pEAPoLBufDesc,(UINT8 *)(iVar1 + 0x74),(UINT8 *)(iVar1 + 0x94),'\0'); + if (CONCAT31(extraout_var,SVar3) == 0) { + if (iVar2 == 1) { + updateApReplayCounter(pKeyMgmtInfoSta,(UINT8 *)pEVar4->replay_cnt); + *(undefined4 *)(iVar1 + 0xcc) = 0; + } + } + else { + iVar2 = 0; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad340); + } + return iVar2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantInit(supplicantData_t *suppData) + +{ + char "supplicantInit" [15]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantInit"); + init_customApp_mibs(suppData); + memset(&suppData->currParams,0xff,4); + memset(&suppData->keyMgmtInfoSta,0,0x144); + (suppData->keyMgmtInfoSta).sta_MIC_Error.disableStaAsso = 0; + (suppData->keyMgmtInfoSta).sta_MIC_Error.MICCounterMeasureEnabled = 1; + (suppData->keyMgmtInfoSta).sta_MIC_Error.status = NO_MIC_FAILURE; + KeyMgmtResetCounter(&suppData->keyMgmtInfoSta); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad444); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void allocSupplicantData(void *connectionPtr) + +{ + char "allocSupplicantData" [20]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"allocSupplicantData"); + if (*(int *)((int)connectionPtr + 8) == 0) { + if ((*(char *)connectionPtr == '\0') && (keyMgmt_SuppData[0].inUse == 0)) { + keyMgmt_SuppData[0].inUse = 1; + supplicantInit(keyMgmt_SuppData); + *(undefined4 *)((int)connectionPtr + 8) = 0x42012c18; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad2b4); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT16 keyMgmtGetKeySize(cm_ConnectionInfo_t *connPtr,UINT8 isPairwise) + +{ + char "keyMgmtGetKeySize" [18]; + UINT16 UVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtGetKeySize"); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad454); + UVar1 = keyMgmtGetKeySize_internal(&connPtr->suppData->customMIB_RSNConfig,isPairwise); + return UVar1; +} + + + +// WARNING: Variable defined which should be unmapped: key_add_req +// WARNING: Could not reconcile some variable overlaps + +uint8_t add_key_to_mac(cm_ConnectionInfo_t *connPtr,UINT8 pairwise) + +{ + uint32_t uVar1; + uint32_t uVar2; + size_t __n; + uint8_t uVar3; + UINT16 UVar4; + apInfo_t *paVar5; + undefined3 in_register_0000202d; + int iVar6; + KeyData_t *__src; + byte bStack60; + byte bStack59; + mm_key_add_req key_add_req; + + iVar6 = CONCAT31(in_register_0000202d,pairwise); + __n = 0x10; + if (connPtr->conType == '\0') { + UVar4 = keyMgmtGetKeySize(connPtr,pairwise); + __n = (uint)UVar4 & 0xff; + } + memset(&bStack60,0,0x2c); + key_add_req.key.array[7]._3_1_ = iVar6 != 0; + key_add_req.key.array[7]._1_1_ = connPtr->instNbr; + if (iVar6 == 0) { + bStack59 = 0xff; + if (connPtr->conType == '\0') { + __src = &(connPtr->suppData->keyMgmtInfoSta).GRKey; + bStack60 = (byte)(connPtr->suppData->keyMgmtInfoSta).GRKey.KeyIndex; + } + else { + paVar5 = cm_GetApInfo(connPtr); + __src = &(paVar5->bssData).grpKeyData; + bStack60 = (byte)(paVar5->bssData).grpKeyData.KeyIndex; + } + } + else { + bStack59 = connPtr->staId; + if (connPtr->conType == '\0') { + __src = &(connPtr->suppData->keyMgmtInfoSta).PWKey; + } + else { + __src = (KeyData_t *)((connPtr->TxRxCipherKeyBuf).cipher_key.ckd + 0x20); + } + } + memcpy(&key_add_req.key,__src,__n); + uVar2 = key_add_req.key.array[6]; + uVar1 = key_add_req.key.array[3]; + key_add_req.key_idx = (uint8_t)__n; + if (__n == 0x10) { + key_add_req.key.array[7]._0_1_ = 2; + } + else { + if (__n == 0x20) { + key_add_req.key.array[7]._0_1_ = 1; + if (iVar6 != 0) { + key_add_req.key.array[3] = key_add_req.key.array[5]; + key_add_req.key.array[5] = uVar1; + key_add_req.key.array[6] = key_add_req.key.array[4]; + key_add_req.key.array[4] = uVar2; + } + } + else { + if (__n == 0xd) { + key_add_req.key.array[7]._0_1_ = 3; + } + else { + if (__n == 5) { + key_add_req.key.array[7]._0_1_ = 0; + } + else { + assert_err("0","module",0x783); + } + } + } + } + printf("set key:sta_idx:%d, inst_nbr:%d, key_idx:%d,cipher_suite:%d,key_len:%d\r\n",(uint)bStack59 + ,(uint)key_add_req.key.array[7]._1_1_,(uint)bStack60,(uint)(byte)key_add_req.key.array[7], + (uint)key_add_req.key_idx); + uVar3 = mm_sec_machwkey_wr((mm_key_add_req *)&bStack60); + return uVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BufferReturnNotify_t * keyMgmtKeyGroupTxDone(void) + +{ + cm_ConnectionInfo_t *connPtr; + uint8_t uVar1; + cm_ConnectionInfo_t **in_a0; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtKeyGroupTxDone"); + connPtr = *in_a0; + if (connPtr->gtkHwKeyId != -1) { + mm_sec_machwkey_del(connPtr->gtkHwKeyId); + } + uVar1 = add_key_to_mac(connPtr,'\0'); + connPtr->gtkHwKeyId = uVar1; + (connPtr->suppData->keyMgmtInfoSta).RSNDataTrafficEnabled = 1; + if ((connPtr->suppData->keyMgmtInfoSta).RSNSecured == 0) { + (connPtr->suppData->keyMgmtInfoSta).RSNSecured = 1; + sm_handle_supplicant_result(connPtr->staId,0); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"keyMgmtKeyGroupTxDone"); + return (BufferReturnNotify_t *)0x0; +} + + + +// WARNING: Variable defined which should be unmapped: pTxEapol +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +Status_e GenerateGrpMsg2(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta) + +{ + char "GenerateGrpMsg2" [16]; + UINT16 frameLen_00; + BufferDesc_t *pBufDesc; + supplicantData *psVar1; + cm_ConnectionInfo_t *connPtr; + EAPOL_KeyMsg_t *pRxEapol; + UINT16 frameLen; + EAPOL_KeyMsg_Tx_t *pEStack36; + EAPOL_KeyMsg_Tx_t *pTxEapol; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"GenerateGrpMsg2"); + connPtr = (cm_ConnectionInfo_t *)pEAPoLBufDesc->intf; + pRxEapol = (EAPOL_KeyMsg_t *)pEAPoLBufDesc->Buffer; + pBufDesc = GetTxEAPOLBuffer(connPtr,&pEStack36,(BufferDesc_t *)0x0); + if (pBufDesc != (BufferDesc_t *)0x0) { + psVar1 = connPtr->suppData; + KeyMgmtSta_PrepareEAPOLFrame + (pEStack36,pRxEapol,(IEEEtypes_MacAddr_t *)psVar1->localBssid, + (IEEEtypes_MacAddr_t *)psVar1->localStaAddr,(UINT8 *)0x0); + frameLen_00 = KeyMgmtSta_PopulateEAPOLLengthMic + (pEStack36,pKeyMgmtInfoSta->EAPOL_MIC_Key,'\x01','\0'); + keyMgmtKeyGroupTxDone(); + UpdateEAPOLWcbLenAndTransmit(pBufDesc,frameLen_00); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad330); + } + return (Status_e)(pBufDesc == (BufferDesc_t *)0x0); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +EAPOL_KeyMsg_t * KeyMgmtStaHsk_Recvd_GrpMsg1(BufferDesc_t *pEAPoLBufDesc) + +{ + char "KeyMgmtStaHsk_Recvd_GrpMsg1" [28]; + keyMgmtInfoSta_t *pKeyMgmtInfoSta; + Status_e SVar1; + EAPOL_KeyMsg_t *pEVar2; + undefined3 extraout_var; + + pKeyMgmtInfoSta = (keyMgmtInfoSta_t *)(*(int *)(pEAPoLBufDesc->intf + 8) + 0x54); + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtStaHsk_Recvd_GrpMsg1"); + pEVar2 = ProcessRxEAPOL_GrpMsg1(pEAPoLBufDesc,pKeyMgmtInfoSta); + if ((pEVar2 == (EAPOL_KeyMsg_t *)0x0) || + (SVar1 = GenerateGrpMsg2(pEAPoLBufDesc,pKeyMgmtInfoSta), CONCAT31(extraout_var,SVar1) != 0)) { + pEVar2 = (EAPOL_KeyMsg_t *)0x0; + } + else { + updateApReplayCounter(pKeyMgmtInfoSta,(UINT8 *)pEVar2->replay_cnt); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad378); + } + return pEVar2; +} + + + +// WARNING: Variable defined which should be unmapped: key_add_req +// WARNING: Could not reconcile some variable overlaps + +uint8_t add_mfp_key_to_mac(cm_ConnectionInfo_t *connPtr,UINT8 pairwise) + +{ + uint8_t uVar1; + UINT16 UVar2; + undefined3 extraout_var; + undefined3 in_register_0000202d; + KeyData_t *__src; + undefined2 uStack60; + mm_key_add_req key_add_req; + + UVar2 = keyMgmtGetKeySize(connPtr,pairwise); + memset(&uStack60,0,0x2c); + key_add_req.key.array[7]._1_1_ = connPtr->instNbr; + key_add_req.key_idx = (uint8_t)((uint)UVar2 & 0xff); + key_add_req.key.array[7]._0_1_ = 5; + uStack60 = 0xff04; + if (CONCAT31(in_register_0000202d,pairwise) == 0) { + if (connPtr->conType != '\0') goto LAB_23015e84; + __src = &(connPtr->suppData->keyMgmtInfoSta).GRKey; + } + else { + if (connPtr->conType != '\0') goto LAB_23015e84; + __src = &(connPtr->suppData->keyMgmtInfoSta).PWKey; + } + memcpy(&key_add_req.key,__src,(uint)UVar2 & 0xff); +LAB_23015e84: + printf("set mfp key:sta_idx:%d, inst_nbr:%d, key_idx:%d,cipher_suite:%d,key_len:%d\r\n", + (uint)uStack60._1_1_,(uint)key_add_req.key.array[7]._1_1_,(uint)(byte)uStack60, + (uint)(byte)key_add_req.key.array[7],(uint)key_add_req.key_idx); + uVar1 = mm_sec_machwkey_wr((mm_key_add_req *)&uStack60); + printf("mfp hw id: %d\n",CONCAT31(extraout_var,uVar1)); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void keyMgmtPlumbPairwiseKey(cm_ConnectionInfo_t *connPtr) + +{ + char "keyMgmtPlumbPairwiseKey" [24]; + uint8_t uVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtPlumbPairwiseKey"); + memcpy(&(connPtr->suppData->keyMgmtInfoSta).PWKey,&(connPtr->suppData->keyMgmtInfoSta).newPWKey, + 0x28); + uVar1 = add_key_to_mac(connPtr,'\x01'); + connPtr->ptkHwKeyId = uVar1; + if ((connPtr->suppData->customMIB_RSNConfig).AKM.akmType == AKM_SHA256_PSK) { + uVar1 = add_mfp_key_to_mac(connPtr,'\x01'); + connPtr->mfpHwKeyId = uVar1; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad468); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BufferReturnNotify_t * keyMgmtKeyPairwiseTxDone(void) + +{ + cm_ConnectionInfo_t **in_a0; + cm_ConnectionInfo_t *connPtr; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtKeyPairwiseTxDone"); + connPtr = *in_a0; + keyMgmtPlumbPairwiseKey(connPtr); + (connPtr->suppData->keyMgmtInfoSta).pwkHandshakeComplete = 1; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"keyMgmtKeyPairwiseTxDone"); + return (BufferReturnNotify_t *)0x0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +Status_e GeneratePWKMsg4(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta, + BOOLEAN groupKeyReceived) + +{ + char "GeneratePWKMsg4" [16]; + Status_e SVar1; + UINT16 frameLen; + BufferDesc_t *pBufDesc; + supplicantData *psVar2; + cm_ConnectionInfo_t *connPtr; + EAPOL_KeyMsg_t *pRxEapol; + EAPOL_KeyMsg_Tx_t *pEStack52; + EAPOL_KeyMsg_Tx_t *pTxEapol; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"GeneratePWKMsg4"); + connPtr = (cm_ConnectionInfo_t *)pEAPoLBufDesc->intf; + pRxEapol = (EAPOL_KeyMsg_t *)pEAPoLBufDesc->Buffer; + pBufDesc = GetTxEAPOLBuffer(connPtr,&pEStack52,(BufferDesc_t *)0x0); + if (pBufDesc == (BufferDesc_t *)0x0) { + SVar1 = FAIL; + } + else { + psVar2 = connPtr->suppData; + KeyMgmtSta_PrepareEAPOLFrame + (pEStack52,pRxEapol,(IEEEtypes_MacAddr_t *)psVar2->localBssid, + (IEEEtypes_MacAddr_t *)psVar2->localStaAddr,(UINT8 *)0x0); + frameLen = KeyMgmtSta_PopulateEAPOLLengthMic + (pEStack52,pKeyMgmtInfoSta->EAPOL_MIC_Key,'\x01','\0'); + UpdateEAPOLWcbLenAndTransmit(pBufDesc,frameLen); + if (groupKeyReceived == 0) { + keyMgmtKeyPairwiseTxDone(); + } + else { + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtKeyPairAndGroupTxDone"); + keyMgmtKeyPairwiseTxDone(); + keyMgmtKeyGroupTxDone(); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"keyMgmtKeyPairAndGroupTxDone"); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad320); + SVar1 = FW_SUCCESS; + } + return SVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +EAPOL_KeyMsg_t * KeyMgmtStaHsk_Recvd_PWKMsg3(BufferDesc_t *pEAPoLBufDesc) + +{ + char "KeyMgmtStaHsk_Recvd_PWKMsg3" [28]; + int iVar1; + keyMgmtInfoSta_t *pKeyMgmtInfoSta; + Status_e SVar2; + EAPOL_KeyMsg_t *pEVar3; + undefined3 extraout_var; + + iVar1 = pEAPoLBufDesc->intf; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtStaHsk_Recvd_PWKMsg3"); + pKeyMgmtInfoSta = (keyMgmtInfoSta_t *)(*(int *)(iVar1 + 8) + 0x54); + pEVar3 = ProcessRxEAPOL_PwkMsg3(pEAPoLBufDesc,pKeyMgmtInfoSta); + if ((pEVar3 != (EAPOL_KeyMsg_t *)0x0) && + (SVar2 = GeneratePWKMsg4(pEAPoLBufDesc,pKeyMgmtInfoSta,(uint)(pEVar3->desc_type == '\x02')), + CONCAT31(extraout_var,SVar2) == 0)) { + updateApReplayCounter(pKeyMgmtInfoSta,(UINT8 *)pEVar3->replay_cnt); + pEVar3 = (EAPOL_KeyMsg_t *)0x0; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad35c); + } + return pEVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ProcessKeyMgmtDataSta(BufferDesc_t *pBufDesc,IEEEtypes_MacAddr_t *sa,IEEEtypes_MacAddr_t *da) + +{ + char "ProcessKeyMgmtDataSta" [22]; + void *pvVar1; + + pvVar1 = pBufDesc->Buffer; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"ProcessKeyMgmtDataSta"); + if ((*(byte *)((int)pvVar1 + 6) & 8) == 0) { + KeyMgmtStaHsk_Recvd_GrpMsg1(pBufDesc); + } + else { + if ((*(byte *)((int)pvVar1 + 5) & 1) == 0) { + KeyMgmtStaHsk_Recvd_PWKMsg1(pBufDesc,sa,da); + } + else { + KeyMgmtStaHsk_Recvd_PWKMsg3(pBufDesc); + } + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad394); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT8 ProcessEAPoLPkt(BufferDesc_t *bufDesc,IEEEtypes_MacAddr_t *sa,IEEEtypes_MacAddr_t *da) + +{ + char "ProcessEAPoLPkt" [16]; + UINT8 UVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"ProcessEAPoLPkt"); + if (*(char *)((int)bufDesc->Buffer + 1) == '\x03') { + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"ProcessEAPoLKeyPkt"); + if (*(char *)bufDesc->intf == '\x02') { + ProcessKeyMgmtDataAp(bufDesc); + } + else { + ProcessKeyMgmtDataSta(bufDesc,sa,da); + } + UVar1 = '\x01'; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"ProcessEAPoLKeyPkt"); + } + else { + UVar1 = '\0'; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad290); + return UVar1; +} + + + +uchar process_rsn_ie(uint8_t *rsn_ie,Cipher_t *mcstCipher,Cipher_t *ucstCipher, + _Bool *is_pmf_required,SecurityMode_t *security_mode,_Bool wpa2_prefered) + +{ + int iVar1; + UINT8 *__s2; + Cipher_t CVar2; + undefined3 in_register_0000203d; + uint uVar3; + uint8_t *__s1; + uint8_t *__dest; + ushort auStack66 [2]; + uint16_t akmp_count; + + __s1 = rsn_ie + 0xe; + __dest = rsn_ie + 10; + if (*(short *)(rsn_ie + 8) == 2) { + rsn_ie[9] = '\0'; + rsn_ie[1] = rsn_ie[1] + -4; + rsn_ie[8] = '\x01'; + iVar1 = memcmp(__s1,"",4); + if (iVar1 == 0) { + memcpy(__dest,__s1,4); + } + memcpy(__s1,rsn_ie + 0x12,0xc); + } + memcpy(auStack66,__s1,2); + uVar3 = 0; + while (uVar3 < auStack66[0]) { + iVar1 = memcmp(__dest + (uVar3 + 1) * 4 + 2,"",4); + if (iVar1 == 0) { + *(byte *)security_mode = *(byte *)security_mode | 0x20; + } + else { + iVar1 = memcmp(__dest + (uVar3 + 1) * 4 + 2,"",4); + if (iVar1 == 0) { + *(byte *)&security_mode->field_0x1 = *(byte *)&security_mode->field_0x1 | 1; + } + } + uVar3 = uVar3 + 1 & 0xff; + } + if (auStack66[0] == 2) { + rsn_ie[1] = '\x14'; + auStack66[0] = 1; + memcpy(__s1,auStack66,2); + __s1 = rsn_ie + 0x14; + if (CONCAT31(in_register_0000203d,wpa2_prefered) == 0) { + __s2 = ""; + } + else { + __s2 = ""; + } + iVar1 = memcmp(__s1,__s2,4); + if (iVar1 == 0) { + memcpy(rsn_ie + 0x10,__s1,6); + } + memcpy(__s1,rsn_ie + 0x18,2); + } + if (((*(byte *)&security_mode->field_0x1 & 1) != 0) && + (((*(byte *)security_mode & 0x20) == 0 || (CONCAT31(in_register_0000203d,wpa2_prefered) == 0))) + ) { + *is_pmf_required = true; + rsn_ie[0x14] = -0x40; + rsn_ie[0x16] = '\0'; + rsn_ie[1] = rsn_ie[1] + '\x02'; + rsn_ie[0x17] = '\0'; + memcpy(rsn_ie + 0x18,"",4); + rsn_ie[1] = rsn_ie[1] + '\x04'; + } + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t)((byte)*ucstCipher | 8); +LAB_23016432: + *ucstCipher = CVar2; + } + else { + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t)((byte)*ucstCipher | 4); + goto LAB_23016432; + } + } + __s1 = rsn_ie + 4; + iVar1 = memcmp(__s1,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t)((byte)*mcstCipher | 8); + } + else { + iVar1 = memcmp(__s1,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t)((byte)*mcstCipher | 4); + } + else { + iVar1 = memcmp(__s1,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t)((byte)*mcstCipher | 2); + } + else { + iVar1 = memcmp(__s1,"",4); + if (iVar1 != 0) goto LAB_23016454; + CVar2 = (Cipher_t)((byte)*mcstCipher | 1); + } + } + } + *mcstCipher = CVar2; +LAB_23016454: + return (uchar)(rsn_ie[1] + '\x02'); +} + + + +uchar process_wpa_ie(uint8_t *wpa_ie,Cipher_t *mcstCipher,Cipher_t *ucstCipher) + +{ + int iVar1; + Cipher_t CVar2; + uint8_t *__dest; + uint8_t *__s1; + + __dest = wpa_ie + 0xe; + if (*(short *)(wpa_ie + 0xc) == 2) { + wpa_ie[1] = '\x16'; + __s1 = wpa_ie + 0x12; + wpa_ie[0xc] = '\x01'; + wpa_ie[0xd] = '\0'; + iVar1 = memcmp(__s1,"",4); + if (iVar1 == 0) { + memcpy(__dest,__s1,4); + } + memcpy(__s1,wpa_ie + 0x16,8); + } + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t)((byte)*ucstCipher | 8); +LAB_230165bc: + *ucstCipher = CVar2; + } + else { + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t)((byte)*ucstCipher | 4); + goto LAB_230165bc; + } + } + __dest = wpa_ie + 8; + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t)((byte)*mcstCipher | 8); + } + else { + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t)((byte)*mcstCipher | 4); + } + else { + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t)((byte)*mcstCipher | 2); + } + else { + iVar1 = memcmp(__dest,"",4); + if (iVar1 != 0) goto LAB_230165de; + CVar2 = (Cipher_t)((byte)*mcstCipher | 1); + } + } + } + *mcstCipher = CVar2; +LAB_230165de: + return (uchar)(wpa_ie[1] + '\x02'); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void keyMgmtStaRsnSecuredTimeoutHandler(void *env) + +{ + char "keyMgmtStaRsnSecuredTimeoutHandler" [35]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtStaRsnSecuredTimeoutHandler"); + if ((env != (void *)0x0) && (*(int *)((int)env + 0x78) == 0)) { + sm_handle_supplicant_result(*(uint8_t *)(*(int *)((int)env + 0x118) + 1),0xf); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad7e8); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantGenerateRand(UINT8 *dataOut,UINT32 length) + +{ + char "supplicantGenerateRand" [23]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantGenerateRand"); + bl_rand_stream(dataOut,length); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad598); + return; +} + + + +void ComputeEAPOL_MIC(EAPOL_KeyMsg_t *pKeyMsg,UINT16 data_length,UINT8 *MIC_Key,UINT8 MIC_Key_length + ,UINT8 micKeyDescVersion) + +{ + undefined2 in_register_0000202e; + undefined3 in_register_00002035; + undefined3 in_register_00002039; + uint uVar1; + uchar *output; + int iStack24; + int len; + UINT8 *pMicData; + + uVar1 = CONCAT31(in_register_00002039,micKeyDescVersion); + iStack24 = CONCAT22(in_register_0000202e,data_length); + if (uVar1 == 0) { + uVar1 = (uint)*(byte *)&(pKeyMsg->key_info).field_0x1 & 7; + } + output = pKeyMsg->key_MIC; + len = (int)pKeyMsg; + if (uVar1 == 1) { + Bl_hmac_md5((UINT8 *)pKeyMsg,iStack24,MIC_Key,CONCAT31(in_register_00002035,MIC_Key_length), + output); + } + else { + if (uVar1 == 2) { + Bl_hmac_sha1((uchar **)&len,&iStack24,1,MIC_Key,CONCAT31(in_register_00002035,MIC_Key_length), + output,0x10); + } + else { + bl_aes_cmac(MIC_Key,(UINT8 *)pKeyMsg,iStack24,output); + } + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT16 keyMgmtGetKeySize_internal(RSNConfig_t *pRsnConfig,UINT8 isPairwise) + +{ + Cipher_t CVar1; + char "keyMgmtGetKeySize_internal" [27]; + UINT16 UVar2; + undefined3 in_register_0000202d; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtGetKeySize_internal"); + if (CONCAT31(in_register_0000202d,isPairwise) == 0) { + CVar1 = pRsnConfig->mcstCipher; + UVar2 = 0x10; + if (((((byte)CVar1 & 8) == 0) && (UVar2 = 0xd, ((byte)CVar1 & 2) == 0)) && + (UVar2 = 0x20, ((byte)CVar1 & 1) != 0)) { + UVar2 = 5; + } + } + else { + UVar2 = 0x20; + if (((byte)pRsnConfig->ucstCipher & 8) != 0) { + UVar2 = 0x10; + } + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad5b0); + return UVar2; +} + + + +// WARNING: Variable defined which should be unmapped: tmpLo +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int isApReplayCounterFresh(keyMgmtInfoSta_t *pKeyMgmtInfoSta,UINT8 *pRxReplayCount) + +{ + char "isApReplayCounterFresh" [23]; + uint uVar1; + uint uVar2; + uint uVar3; + uint uVar4; + uint uStack24; + UINT32 tmpHi; + UINT32 tmpLo; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"isApReplayCounterFresh"); + memcpy(&uStack24,pRxReplayCount,4); + memcpy(&tmpHi,pRxReplayCount + 4,4); + uVar3 = uStack24 * 0x1000000 + (uStack24 >> 0x18) + (uStack24 & 0xff00) * 0x100 + + (uStack24 >> 8 & 0xff00); + uVar2 = pKeyMgmtInfoSta->apCounterHi; + uVar1 = 1; + if ((uVar3 <= uVar2) && (uVar1 = 0, uVar2 == uVar3)) { + uVar1 = 1; + uVar4 = tmpHi * 0x1000000 + (tmpHi >> 0x18) + (tmpHi & 0xff00) * 0x100 + (tmpHi >> 8 & 0xff00); + uVar3 = pKeyMgmtInfoSta->apCounterLo; + if ((uVar4 <= uVar3) && ((uVar1 = 0, uVar3 == uVar4 && ((uVar2 | uVar3) == 0)))) { + uVar1 = (uint)(pKeyMgmtInfoSta->apCounterZeroDone == 0); + } + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad5cc); + return uVar1; +} + + + +// WARNING: Variable defined which should be unmapped: tmpLo +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void updateApReplayCounter(keyMgmtInfoSta_t *pKeyMgmtStaInfo,UINT8 *pRxReplayCount) + +{ + char "updateApReplayCounter" [22]; + uint uVar1; + uint uVar2; + uint uStack24; + UINT32 tmpHi; + UINT32 tmpLo; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"updateApReplayCounter"); + memcpy(&uStack24,pRxReplayCount,4); + memcpy(&tmpHi,pRxReplayCount + 4,4); + uVar2 = uStack24 * 0x1000000 + (uStack24 >> 0x18) + (uStack24 & 0xff00) * 0x100 + + (uStack24 >> 8 & 0xff00); + uVar1 = tmpHi * 0x1000000 + (tmpHi >> 0x18) + (tmpHi & 0xff00) * 0x100 + (tmpHi >> 8 & 0xff00); + pKeyMgmtStaInfo->apCounterHi = uVar2; + pKeyMgmtStaInfo->apCounterLo = uVar1; + if ((uVar2 | uVar1) == 0) { + pKeyMgmtStaInfo->apCounterZeroDone = 1; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad5e4); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void formEAPOLEthHdr(EAPOL_KeyMsg_Tx_t *pTxEapol,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa) + +{ + char "formEAPOLEthHdr" [16]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"formEAPOLEthHdr"); + memcpy(pTxEapol,da,6); + memcpy((pTxEapol->ethHdr).sa,sa,6); + *(undefined *)&(pTxEapol->ethHdr).type = 0x88; + *(undefined *)((int)&(pTxEapol->ethHdr).type + 1) = 0x8e; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad5fc); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN IsEAPOL_MICValid(EAPOL_KeyMsg_t *pKeyMsg,UINT8 *pMICKey) + +{ + UINT8 *__src; + int iVar1; + undefined auStack48 [4]; + UINT8 msgMIC [16]; + + __src = pKeyMsg->key_MIC; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"IsEAPOL_MICValid"); + memcpy(auStack48,__src,0x10); + memset(__src,0,0x10); + ComputeEAPOL_MIC(pKeyMsg,(UINT16)(((uint)CONCAT21((pKeyMsg->hdr_8021x).pckt_body_len, + *(undefined *) + ((int)&(pKeyMsg->hdr_8021x).pckt_body_len + 1)) + + 4) * 0x10000 >> 0x10),pMICKey,'\x10','\0'); + iVar1 = memcmp(__src,auStack48,0x10); + if (iVar1 == 0) { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"IsEAPOL_MICValid"); + } + return (uint)(iVar1 == 0); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT16 KeyMgmtSta_PopulateEAPOLLengthMic + (EAPOL_KeyMsg_Tx_t *pTxEapol,UINT8 *pEAPOLMICKey,UINT8 eapolProtocolVersion, + UINT8 forceKeyDescVersion) + +{ + undefined uVar1; + ushort uVar2; + char "KeyMgmtSta_PopulateEAPOLLengthMic" [34]; + UINT16 UVar3; + uint uVar4; + + UVar3 = 0; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_PopulateEAPOLLengthMic"); + if (pTxEapol != (EAPOL_KeyMsg_Tx_t *)0x0) { + uVar1 = *(undefined *)((int)&(pTxEapol->keyMsg).key_material_len + 1); + uVar2 = (pTxEapol->keyMsg).key_material_len; + uVar4 = (uint)uVar2 + 0x5f & 0xffff; + UVar3 = (UINT16)uVar4; + (pTxEapol->keyMsg).hdr_8021x.pckt_type = IEEE_8021X_PACKET_TYPE_EAPOL_KEY; + *(char *)&(pTxEapol->keyMsg).hdr_8021x.pckt_body_len = (char)(uVar4 >> 8); + *(undefined *)((int)&(pTxEapol->keyMsg).hdr_8021x.pckt_body_len + 1) = (char)uVar4; + *(undefined *)&(pTxEapol->keyMsg).key_material_len = uVar1; + (pTxEapol->keyMsg).hdr_8021x.protocol_ver = eapolProtocolVersion; + *(undefined *)((int)&(pTxEapol->keyMsg).key_material_len + 1) = + (char)((uint)CONCAT21(uVar2,uVar1) >> 8); + ComputeEAPOL_MIC(&pTxEapol->keyMsg,(UINT16)(((uint)uVar2 + 99) * 0x10000 >> 0x10),pEAPOLMICKey, + '\x10',forceKeyDescVersion); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad620); + } + return UVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +KDE_t * parseKeyKDE(IEEEtypes_InfoElementHdr_t *pIe) + +{ + char "parseKeyKDE" [12]; + int iVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"parseKeyKDE"); + if (((pIe->ElementId != ELEM_ID_VENDOR_SPECIFIC) || (pIe->Len < 8)) || + (iVar1 = memcmp(pIe + 1,"",3), iVar1 != 0)) { + pIe = (IEEEtypes_InfoElementHdr_t *)0x0; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad644); + } + return (KDE_t *)pIe; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +KDE_t * parseKeyKDE_DataType(UINT8 *pData,SINT32 dataLen,IEEEtypes_KDEDataType_e KDEDataType) + +{ + KDE_t *pKVar1; + undefined3 in_register_00002031; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"parseKeyKDE_DataType"); + if (pData != (UINT8 *)0x0) { + while (2 < dataLen) { + if (((IEEEtypes_InfoElementHdr_t *)pData)->ElementId == ELEM_ID_VENDOR_SPECIFIC) { + pKVar1 = parseKeyKDE((IEEEtypes_InfoElementHdr_t *)pData); + if ((pKVar1 != (KDE_t *)0x0) && + ((uint)pKVar1->dataType == CONCAT31(in_register_00002031,KDEDataType))) { + return pKVar1; + } + if (((IEEEtypes_InfoElementHdr_t *)pData)->Len == '\0') { + dataLen = 2; + } + } + dataLen = dataLen + (-2 - (uint)((IEEEtypes_InfoElementHdr_t *)pData)->Len); + pData = (UINT8 *)(&((IEEEtypes_InfoElementHdr_t *)pData)[1].ElementId + + (uint)((IEEEtypes_InfoElementHdr_t *)pData)->Len); + } + pData = (UINT8 *)0x0; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"parseKeyKDE_DataType"); + } + return (KDE_t *)pData; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +KDE_t * parseKeyDataGTK(UINT8 *pKey,UINT16 len,KeyData_t *pGRKey) + +{ + char "parseKeyDataGTK" [16]; + KDE_t *pKVar1; + undefined2 in_register_0000202e; + undefined auStack40 [4]; + UINT8 buf [8]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"parseKeyDataGTK"); + pKVar1 = parseKeyKDE_DataType(pKey,CONCAT22(in_register_0000202e,len),KDE_DATA_TYPE_GTK); + if (pKVar1 != (KDE_t *)0x0) { + memcpy(pGRKey,&pKVar1[1].length,(uint)pKVar1->length - 6); + pGRKey->KeyIndex = (ushort)pKVar1->data[0] & 3; + memcpy(auStack40,pGRKey->TxMICKey,8); + memcpy(pGRKey->TxMICKey,pGRKey->RxMICKey,8); + memcpy(pGRKey->RxMICKey,auStack40,8); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad668); + return pKVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmtSta_ApplyKEK(EAPOL_KeyMsg_t *pKeyMsg,KeyData_t *pGRKey,UINT8 *EAPOL_Encr_Key) + +{ + byte bVar1; + undefined uVar2; + uint3 uVar3; + char "KeyMgmtSta_ApplyKEK" [20]; + UINT8 *cipher; + uint uVar4; + int iVar5; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_ApplyKEK"); + bVar1 = pKeyMsg->key_RSC[1]; + cipher = pKeyMsg->key_data; + pGRKey->TxIV16 = (ushort)bVar1 << 8; + pGRKey->TxIV16 = CONCAT11(bVar1,pKeyMsg->key_RSC[0]); + pGRKey->TxIV32 = 0xffffffff; + uVar2 = *(undefined *)((int)&pKeyMsg->key_material_len + 1); + uVar3 = CONCAT21(pKeyMsg->key_material_len,uVar2); + uVar4 = (uint)uVar3 & 0xffff; + *(undefined *)((int)&pKeyMsg->key_material_len + 1) = (char)(uVar4 >> 8); + bVar1 = *(byte *)&(pKeyMsg->key_info).field_0x1; + *(undefined *)&pKeyMsg->key_material_len = uVar2; + if ((bVar1 & 7) == 1) { + RC4_Encrypt(EAPOL_Encr_Key,pKeyMsg->EAPOL_key_IV,0x10,cipher,(ushort)uVar3,0x100); + } + else { + BL_AesUnWrap(EAPOL_Encr_Key,'\x02',(uVar4 >> 3) - 1,cipher,(UINT8 *)0x0,cipher); + iVar5 = (uint)pKeyMsg->key_material_len - 8; + *(char *)&pKeyMsg->key_material_len = (char)((uint)(iVar5 * 0x10000) >> 0x10); + *(undefined *)((int)&pKeyMsg->key_material_len + 1) = (char)((uint)iVar5 >> 8); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad678); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN KeyMgmtSta_IsRxEAPOLValid(keyMgmtInfoSta_t *pKeyMgmtInfoSta,EAPOL_KeyMsg_t *pKeyMsg) + +{ + BOOLEAN BVar1; + int iVar2; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_IsRxEAPOLValid"); + if ((((pKeyMgmtInfoSta == (keyMgmtInfoSta_t *)0x0) || (pKeyMsg == (EAPOL_KeyMsg_t *)0x0)) || + (iVar2 = isApReplayCounterFresh(pKeyMgmtInfoSta,(UINT8 *)pKeyMsg->replay_cnt), iVar2 == 0)) || + (((*(byte *)&pKeyMsg->key_info & 1) != 0 && + ((((*(byte *)&(pKeyMsg->key_info).field_0x1 & 8) != 0 && + (iVar2 = memcmp(pKeyMsg->key_nonce,pKeyMgmtInfoSta,0x20), iVar2 != 0)) || + (BVar1 = IsEAPOL_MICValid(pKeyMsg,pKeyMgmtInfoSta->EAPOL_MIC_Key), BVar1 == 0)))))) { + BVar1 = 0; + } + else { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_IsRxEAPOLValid"); + BVar1 = 1; + } + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmtSta_PrepareEAPOLFrame + (EAPOL_KeyMsg_Tx_t *pTxEapol,EAPOL_KeyMsg_t *pRxEapol,IEEEtypes_MacAddr_t *da, + IEEEtypes_MacAddr_t *sa,UINT8 *pSNonce) + +{ + byte bVar1; + byte bVar2; + UINT32 UVar3; + char "KeyMgmtSta_PrepareEAPOLFrame" [29]; + byte bVar4; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_PrepareEAPOLFrame"); + if ((pTxEapol != (EAPOL_KeyMsg_Tx_t *)0x0) && (pRxEapol != (EAPOL_KeyMsg_t *)0x0)) { + memset(pTxEapol,0,0x72); + formEAPOLEthHdr(pTxEapol,da,sa); + (pTxEapol->keyMsg).desc_type = pRxEapol->desc_type; + bVar4 = *(byte *)&(pRxEapol->key_info).field_0x1 & 8; + bVar1 = *(byte *)&(pTxEapol->keyMsg).key_info.field_0x1; + bVar2 = *(byte *)&(pTxEapol->keyMsg).key_info; + *(byte *)&(pTxEapol->keyMsg).key_info.field_0x1 = bVar1 & 0xf7 | bVar4; + *(byte *)&(pTxEapol->keyMsg).key_info = bVar2 | 1; + *(byte *)&(pTxEapol->keyMsg).key_info = bVar2 & 0xfd | 1 | *(byte *)&pRxEapol->key_info & 2; + UVar3 = pRxEapol->replay_cnt[0]; + *(char *)(pTxEapol->keyMsg).replay_cnt = (char)*(undefined3 *)pRxEapol->replay_cnt; + *(undefined *)((int)(pTxEapol->keyMsg).replay_cnt + 1) = (char)(UVar3 >> 8); + *(undefined *)((int)(pTxEapol->keyMsg).replay_cnt + 2) = (char)(UVar3 >> 0x10); + *(undefined *)((int)(pTxEapol->keyMsg).replay_cnt + 3) = (char)(UVar3 >> 0x18); + UVar3 = pRxEapol->replay_cnt[1]; + *(char *)((pTxEapol->keyMsg).replay_cnt + 1) = (char)*(undefined3 *)(pRxEapol->replay_cnt + 1); + *(undefined *)((int)(pTxEapol->keyMsg).replay_cnt + 5) = (char)(UVar3 >> 8); + *(undefined *)((int)(pTxEapol->keyMsg).replay_cnt + 6) = (char)(UVar3 >> 0x10); + *(undefined *)((int)(pTxEapol->keyMsg).replay_cnt + 7) = (char)(UVar3 >> 0x18); + *(byte *)&(pTxEapol->keyMsg).key_info.field_0x1 = + bVar1 & 0xf0 | bVar4 | *(byte *)&(pRxEapol->key_info).field_0x1 & 7; + if (pSNonce != (UINT8 *)0x0) { + memcpy((pTxEapol->keyMsg).key_nonce,pSNonce,0x20); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad6a8); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN supplicantAkmIsWpaWpa2(AkmSuite_t *pAkm) + +{ + int iVar1; + BOOLEAN BVar2; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantAkmIsWpaWpa2"); + iVar1 = memcmp(pAkm,"",3); + if ((iVar1 == 0) || (iVar1 = memcmp(pAkm,"",3), iVar1 == 0)) { + BVar2 = 1; + } + else { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"supplicantAkmIsWpaWpa2"); + BVar2 = 0; + } + return BVar2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN supplicantAkmIsWpa2(AkmSuite_t *pAkm) + +{ + int iVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantAkmIsWpa2"); + iVar1 = memcmp(pAkm,"",3); + if (iVar1 != 0) { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"supplicantAkmIsWpa2"); + } + return (uint)(iVar1 == 0); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN supplicantAkmIsWpaWpa2Psk(AkmSuite_t *pAkm) + +{ + char "supplicantAkmIsWpaWpa2Psk" [26]; + uint uVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantAkmIsWpaWpa2Psk"); + uVar1 = supplicantAkmIsWpaWpa2(pAkm); + if (uVar1 == 0) { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad6f4); + } + else { + uVar1 = 1; + if ((pAkm->akmType & 0xfb) != 2) { + uVar1 = (uint)(pAkm->akmType == AKM_FT_PSK); + } + } + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN supplicantAkmUsesKdf(AkmSuite_t *pAkm) + +{ + char "supplicantAkmUsesKdf" [21]; + BOOLEAN BVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantAkmUsesKdf"); + BVar1 = supplicantAkmIsWpa2(pAkm); + if ((BVar1 == 0) || (BVar1 = 1, 3 < (byte)(pAkm->akmType + ~AKM_WPA_MAX))) { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad710); + BVar1 = 0; + } + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantConstructContext + (IEEEtypes_MacAddr_t *pAddr1,IEEEtypes_MacAddr_t *pAddr2,UINT8 *pNonce1, + UINT8 *pNonce2,UINT8 *pContext) + +{ + char "supplicantConstructContext" [27]; + int iVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantConstructContext"); + iVar1 = memcmp(pAddr1,pAddr2,6); + if (iVar1 < 0) { + memcpy(pContext,pAddr1,6); + pAddr1 = pAddr2; + } + else { + memcpy(pContext,pAddr2,6); + } + memcpy(pContext + 6,pAddr1,6); + iVar1 = memcmp(pNonce1,pNonce2,0x20); + if (iVar1 < 0) { + memcpy(pContext + 0xc,pNonce1,0x20); + pNonce1 = pNonce2; + } + else { + memcpy(pContext + 0xc,pNonce2,0x20); + } + memcpy(pContext + 0x2c,pNonce1,0x20); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad728); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmt_DerivePTK(IEEEtypes_MacAddr_t *pAddr1,IEEEtypes_MacAddr_t *pAddr2,UINT8 *pNonce1, + UINT8 *pNonce2,UINT8 *pPTK,UINT8 *pPMK,BOOLEAN use_kdf) + +{ + char "KeyMgmt_DerivePTK" [18]; + UINT8 *pContext; + + pContext = pPTK + 200; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmt_DerivePTK"); + supplicantConstructContext(pAddr1,pAddr2,pNonce1,pNonce2,pContext); + if (use_kdf == 0) { + Bl_PRF(pPMK,0x20,(uchar *)"Pairwise key expansion",0x16,pContext,0x4c,pPTK,0x40); + } + else { + bl_sha256_crypto_kdf(pPMK,' ',"Pairwise key expansion",'\x16',pContext,0x4c,pPTK,0x180); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad744); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmtSta_DeriveKeys + (UINT8 *pPMK,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa,UINT8 *ANonce, + UINT8 *SNonce,UINT8 *EAPOL_MIC_Key,UINT8 *EAPOL_Encr_Key,KeyData_t *newPWKey, + BOOLEAN use_kdf) + +{ + char "KeyMgmtSta_DeriveKeys" [22]; + BOOLEAN in_stack_00000000; + UINT8 aUStack548 [4]; + UINT8 pBuf [500]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_DeriveKeys"); + if (((pPMK != (UINT8 *)0x0) && (EAPOL_MIC_Key != (UINT8 *)0x0)) && (newPWKey != (KeyData_t *)0x0)) + { + KeyMgmt_DerivePTK(sa,da,ANonce,SNonce,aUStack548,pPMK,in_stack_00000000); + memcpy(EAPOL_MIC_Key,aUStack548,0x10); + memcpy(EAPOL_Encr_Key,pBuf + 0xc,0x10); + memcpy(newPWKey,pBuf + 0x1c,0x10); + memcpy(newPWKey->RxMICKey,pBuf + 0x2c,8); + memcpy(newPWKey->TxMICKey,pBuf + 0x34,8); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad758); + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SetEAPOLKeyDescTypeVersion + (EAPOL_KeyMsg_Tx_t *pTxEapol,BOOLEAN isWPA2,BOOLEAN isKDF,BOOLEAN nonTKIP) + +{ + byte bVar1; + char "SetEAPOLKeyDescTypeVersion" [27]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"SetEAPOLKeyDescTypeVersion"); + bVar1 = *(byte *)&(pTxEapol->keyMsg).key_info.field_0x1; + (pTxEapol->keyMsg).desc_type = '\x02'; + *(byte *)&(pTxEapol->keyMsg).key_info.field_0x1 = bVar1 & 0xf8 | (isKDF != 0) + 2U; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad770); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +EAPOL_KeyMsg_t * +GetKeyMsgNonceFromEAPOL(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta) + +{ + char "GetKeyMsgNonceFromEAPOL" [24]; + EAPOL_KeyMsg_t *pKeyMsg; + BOOLEAN BVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"GetKeyMsgNonceFromEAPOL"); + pKeyMsg = (EAPOL_KeyMsg_t *)pEAPoLBufDesc->Buffer; + BVar1 = KeyMgmtSta_IsRxEAPOLValid(pKeyMgmtInfoSta,pKeyMsg); + if (BVar1 == 0) { + pKeyMsg = (EAPOL_KeyMsg_t *)0x0; + } + else { + if ((*(byte *)&pKeyMsg->key_info & 1) == 0) { + memcpy(pKeyMgmtInfoSta,pKeyMsg->key_nonce,0x20); + supplicantGenerateRand(pKeyMgmtInfoSta->SNonce,0x20); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad78c); + } + return pKeyMsg; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +EAPOL_KeyMsg_t * +ProcessRxEAPOL_PwkMsg3(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta) + +{ + char "ProcessRxEAPOL_PwkMsg3" [23]; + EAPOL_KeyMsg_t *pKeyMsg; + BOOLEAN BVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"ProcessRxEAPOL_PwkMsg3"); + pKeyMsg = GetKeyMsgNonceFromEAPOL(pEAPoLBufDesc,pKeyMgmtInfoSta); + if (pKeyMsg == (EAPOL_KeyMsg_t *)0x0) { +LAB_23017696: + pKeyMsg = (EAPOL_KeyMsg_t *)0x0; + } + else { + (pKeyMgmtInfoSta->newPWKey).TxIV16 = 1; + (pKeyMgmtInfoSta->newPWKey).TxIV32 = 0; + if ((*(byte *)&pKeyMsg->key_info & 0x10) != 0) { + mm_timer_clear(&pKeyMgmtInfoSta->rsnTimer); + KeyMgmtSta_ApplyKEK(pKeyMsg,&pKeyMgmtInfoSta->GRKey,pKeyMgmtInfoSta->EAPOL_Encr_Key); + BVar1 = keyMgmtProcessMsgExt(pKeyMgmtInfoSta,pKeyMsg); + if (BVar1 == 0) goto LAB_23017696; + parseKeyDataGTK(pKeyMsg->key_data,pKeyMsg->key_material_len,&pKeyMgmtInfoSta->GRKey); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad7a4); + } + return pKeyMsg; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +EAPOL_KeyMsg_t * +ProcessRxEAPOL_GrpMsg1(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta) + +{ + char "ProcessRxEAPOL_GrpMsg1" [23]; + EAPOL_KeyMsg_t *pKeyMsg; + BOOLEAN BVar1; + KeyData_t *pGRKey; + UINT8 *__src; + UINT8 *__src_00; + undefined auStack40 [4]; + UINT8 buf [8]; + + pKeyMsg = GetKeyMsgNonceFromEAPOL(pEAPoLBufDesc,pKeyMgmtInfoSta); + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"ProcessRxEAPOL_GrpMsg1"); + if (pKeyMsg == (EAPOL_KeyMsg_t *)0x0) { +LAB_23017752: + pKeyMsg = (EAPOL_KeyMsg_t *)0x0; + } + else { + pGRKey = &pKeyMgmtInfoSta->GRKey; + KeyMgmtSta_ApplyKEK(pKeyMsg,pGRKey,pKeyMgmtInfoSta->EAPOL_Encr_Key); + pKeyMgmtInfoSta->RSNDataTrafficEnabled = 1; + mm_timer_clear(&pKeyMgmtInfoSta->rsnTimer); + if (pKeyMsg->desc_type == '\x02') { + parseKeyDataGTK(pKeyMsg->key_data,pKeyMsg->key_material_len,pGRKey); + BVar1 = keyMgmtProcessMsgExt(pKeyMgmtInfoSta,pKeyMsg); + if (BVar1 == 0) goto LAB_23017752; + } + else { + memcpy(pGRKey,pKeyMsg->key_data,(uint)pKeyMsg->key_material_len); + __src_00 = (pKeyMgmtInfoSta->GRKey).TxMICKey; + memcpy(auStack40,__src_00,8); + __src = (pKeyMgmtInfoSta->GRKey).RxMICKey; + memcpy(__src_00,__src,8); + memcpy(__src,auStack40,8); + (pKeyMgmtInfoSta->GRKey).KeyIndex = (ushort)(*(byte *)&(pKeyMsg->key_info).field_0x1 >> 4) & 3 + ; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad7bc); + } + return pKeyMsg; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmtResetCounter(keyMgmtInfoSta_t *pKeyMgmtInfo) + +{ + char "KeyMgmtResetCounter" [20]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtResetCounter"); + if (pKeyMgmtInfo != (keyMgmtInfoSta_t *)0x0) { + pKeyMgmtInfo->staCounterHi = 0; + pKeyMgmtInfo->staCounterLo = 0; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad7d4); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void keyMgmtSta_StartSession_internal(keyMgmtInfoSta_t *pKeyMgmtInfoSta,UINT32 expiry) + +{ + char "keyMgmtSta_StartSession_internal" [33]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtSta_StartSession_internal"); + if ((pKeyMgmtInfoSta->sta_MIC_Error).disableStaAsso == 0) { + mm_timer_set(&pKeyMgmtInfoSta->rsnTimer,_DAT_44b00120 + expiry); + } + pKeyMgmtInfoSta->apCounterLo = 0; + pKeyMgmtInfoSta->apCounterHi = 0; + pKeyMgmtInfoSta->apCounterZeroDone = 0; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad80c); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmtSta_InitSession(keyMgmtInfoSta_t *pKeyMgmtInfoSta) + +{ + char "KeyMgmtSta_InitSession" [23]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_InitSession"); + pKeyMgmtInfoSta->RSNDataTrafficEnabled = 0; + pKeyMgmtInfoSta->RSNSecured = 0; + pKeyMgmtInfoSta->pRxDecryptKey = (cipher_key_t *)0x0; + pKeyMgmtInfoSta->pwkHandshakeComplete = 0; + (pKeyMgmtInfoSta->rsnTimer).cb = keyMgmtStaRsnSecuredTimeoutHandler; + *(keyMgmtInfoSta_t **)&(pKeyMgmtInfoSta->rsnTimer).env = pKeyMgmtInfoSta; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad830); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void set_psk(char *pSsid,UINT8 ssidLen,char *phrase) + +{ + char "set_psk" [8]; + size_t sVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"set_psk"); + memset(&nohostParams,0xff,0x43); + sVar1 = strlen(phrase); + pmkCacheSetPassphrase((UINT8 *)pSsid,ssidLen,(UINT8 *)phrase,(UINT8)sVar1); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230cb8c8); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void remove_psk(char *pSsid,UINT8 ssidLen) + +{ + char "remove_psk" [11]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"remove_psk"); + pmkCacheDeletePSK((UINT8 *)pSsid,ssidLen); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad848); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void bl_sha256_crypto_kdf + (UINT8 *pKey,UINT8 key_len,char *label,UINT8 label_len,UINT8 *pContext, + UINT16 context_len,UINT8 *pOutput,UINT16 output_len) + +{ + UINT8 *mac; + undefined3 in_register_0000202d; + undefined2 in_register_0000203e; + undefined2 in_register_00002046; + ushort auStack114 [8]; + ushort uStack98; + UINT16 i; + ushort *puStack96; + UINT8 *vectors [4]; + size_t vectLen [4]; + + uStack98 = 1; + mac = pContext + CONCAT22(in_register_0000203e,context_len); + auStack114[0] = output_len; + while ((uint)uStack98 <= (CONCAT22(in_register_00002046,output_len) + 0xff >> 8 & 0xffU)) { + vectors[3] = (UINT8 *)0x2; + puStack96 = &uStack98; + vectors[0] = (UINT8 *)label; + vectors[1] = pContext; + vectors[2] = (UINT8 *)auStack114; + hmac_sha256_vector(pKey,CONCAT31(in_register_0000202d,key_len),4,(UINT8 **)&stack0xffffffa0, + (size_t *)(vectors + 3),mac); + mac = mac + 0x20; + uStack98 = uStack98 + 1; + } + memcpy(pOutput,pContext + CONCAT22(in_register_0000203e,context_len),(uint)(auStack114[0] >> 3)); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT8 * pmkCacheFindPSK(UINT8 *pSsid,UINT8 ssidLen) + +{ + char "pmkCacheFindPSK" [16]; + pmkElement_t *pPSK; + size_t sVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheFindPSK"); + pPSK = pmkCacheFindPSKElement(pSsid,ssidLen); + if (pPSK == (pmkElement_t *)0x0) { + if (PSKPassPhrase != '\0') { + pmkCacheAddPSK(pSsid,ssidLen,(UINT8 *)0x0,'\0'); + pPSK = pmkCacheFindPSKElement(pSsid,ssidLen); + sVar1 = strlen((char *)PSKPassPhrase); + pPSK = (pmkElement_t *)pPSK->PMK; + pmkCacheGeneratePSK(pSsid,ssidLen,PSKPassPhrase,(UINT8)sVar1,(UINT8 *)pPSK); + } + } + else { + pPSK = (pmkElement_t *)pPSK->PMK; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad854); + return (UINT8 *)pPSK; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheSetPassphrase(UINT8 *pSsid,UINT8 ssidLen,UINT8 *pPassphrase,UINT8 PassphraseLen) + +{ + char "pmkCacheSetPassphrase" [22]; + pmkElement_t *pSsid_00; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheSetPassphrase"); + if (pPassphrase != (UINT8 *)0x0) { + memcpy(PSKPassPhrase,pPassphrase,0x40); + pmkCacheAddPSK(pSsid,ssidLen,pPassphrase,PassphraseLen); + pSsid_00 = pmkCacheFindPSKElement(pSsid,ssidLen); + pmkCacheGeneratePSK((UINT8 *)pSsid_00,pSsid_00->length,PSKPassPhrase,PassphraseLen,pSsid_00->PMK + ); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad864); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheInit(void) + +{ + char "pmkCacheInit" [13]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheInit"); + memset(pmkCache,0,0x86); + memset(PSKPassPhrase,0,0x40); + replacementRankMax = '\0'; + dbg_test_print("%dms : Leave: %s\n",0x230ad87c); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheRomInit(void) + +{ + char "pmkCacheRomInit" [16]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheRomInit"); + ramHook_MAX_PMK_CACHE_ENTRIES = 2; + ramHook_pmkCache = pmkCache; + ramHook_PSKPassPhrase = PSKPassPhrase; + dbg_test_print("%dms : Leave: %s\n",0x230ad88c); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +pmkElement_t * pmkCacheNewElement(void) + +{ + char "pmkCacheNewElement" [19]; + uint uVar1; + pmkElement_t *__s; + pmkElement_t *ppVar2; + + ppVar2 = (pmkElement_t *)0x0; + uVar1 = 0; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheNewElement"); + while ((int)uVar1 < ramHook_MAX_PMK_CACHE_ENTRIES) { + if ((int)replacementRankMax == ramHook_MAX_PMK_CACHE_ENTRIES) { + ramHook_pmkCache[uVar1].replacementRank = ramHook_pmkCache[uVar1].replacementRank + -1; + } + if (ppVar2 == (pmkElement_t *)0x0) { + __s = ramHook_pmkCache + uVar1; + if (__s->replacementRank == '\0') { + memset(__s,0,0x43); + if (replacementRankMax < ramHook_MAX_PMK_CACHE_ENTRIES) { + replacementRankMax = replacementRankMax + '\x01'; + } + ramHook_pmkCache[uVar1].replacementRank = replacementRankMax; + ppVar2 = __s; + } + } + uVar1 = uVar1 + 1 & 0xff; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad89c); + return ppVar2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheUpdateReplacementRank(pmkElement_t *pPMKElement) + +{ + char cVar1; + SINT8 SVar2; + pmkElement_t *ppVar3; + SINT32 SVar4; + char "pmkCacheUpdateReplacementRank" [30]; + uint uVar5; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheUpdateReplacementRank"); + SVar4 = ramHook_MAX_PMK_CACHE_ENTRIES; + ppVar3 = ramHook_pmkCache; + SVar2 = replacementRankMax; + if ((pPMKElement != (pmkElement_t *)0x0) && (pPMKElement->replacementRank != replacementRankMax)) + { + uVar5 = 0; + while ((int)uVar5 < SVar4) { + cVar1 = ppVar3[uVar5].replacementRank; + if (pPMKElement->replacementRank < cVar1) { + ppVar3[uVar5].replacementRank = cVar1 + -1; + } + uVar5 = uVar5 + 1 & 0xff; + } + pPMKElement->replacementRank = SVar2; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad8b0); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +pmkElement_t * pmkCacheFindPSKElement(UINT8 *pSsid,UINT8 ssidLen) + +{ + char "pmkCacheFindPSKElement" [23]; + uint uVar1; + pmkElement_t *pPMKElement; + pmkElement_t *__s1; + int iVar2; + undefined3 in_register_0000202d; + + pPMKElement = (pmkElement_t *)0x0; + uVar1 = 0; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheFindPSKElement"); + while ((int)uVar1 < ramHook_MAX_PMK_CACHE_ENTRIES) { + __s1 = ramHook_pmkCache + uVar1; + if (((__s1->replacementRank != '\0') && + ((uint)__s1->length == CONCAT31(in_register_0000202d,ssidLen))) && + (iVar2 = memcmp(__s1,pSsid,CONCAT31(in_register_0000202d,ssidLen)), iVar2 == 0)) { + pPMKElement = ramHook_pmkCache + uVar1; + } + uVar1 = uVar1 + 1 & 0xff; + } + pmkCacheUpdateReplacementRank(pPMKElement); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad8d0); + return pPMKElement; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheAddPSK(UINT8 *pSsid,UINT8 ssidLen,UINT8 *pPSK,UINT8 pPSKLen) + +{ + char "pmkCacheAddPSK" [15]; + pmkElement_t *__dest; + undefined3 in_register_0000202d; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheAddPSK"); + __dest = pmkCacheFindPSKElement(pSsid,ssidLen); + if (__dest == (pmkElement_t *)0x0) { + __dest = pmkCacheNewElement(); + memcpy(__dest,pSsid,CONCAT31(in_register_0000202d,ssidLen)); + __dest->length = ssidLen; + } + if (pPSK != (UINT8 *)0x0) { + memcpy(__dest->PMK,pPSK,0x20); + __dest->psk_length = pPSKLen; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad8e8); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheDeletePSK(UINT8 *pSsid,UINT8 ssidLen) + +{ + char "pmkCacheDeletePSK" [18]; + pmkElement_t *__s; + + __s = pmkCacheFindPSKElement(pSsid,ssidLen); + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheDeletePSK"); + if (__s != (pmkElement_t *)0x0) { + memset(__s,0,0x43); + replacementRankMax = replacementRankMax + -1; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad8f8); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT8 pmkCacheGetHexNibble(UINT8 nibble) + +{ + undefined3 in_register_00002029; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheGetHexNibble"); + if (CONCAT31(in_register_00002029,nibble) < 0x61) { + if (CONCAT31(in_register_00002029,nibble) < 0x41) { + nibble = nibble + -0x30; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"pmkCacheGetHexNibble"); + } + else { + nibble = nibble + -0x37; + } + } + else { + nibble = nibble + -0x57; + } + return nibble; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheGeneratePSK(UINT8 *pSsid,UINT8 ssidLen,UINT8 *pPassphrase,UINT8 PassphraseLen, + UINT8 *pPSK) + +{ + char "pmkCacheGeneratePSK" [20]; + UINT8 UVar1; + byte bVar2; + undefined3 in_register_0000202d; + undefined3 in_register_00002035; + int iVar3; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheGeneratePSK"); + if ((pPSK != (UINT8 *)0x0) && (pPassphrase != (UINT8 *)0x0)) { + if (CONCAT31(in_register_00002035,PassphraseLen) - 8U < 0x38) { + utils_wifi_psk_cal_fast_bin + ((char *)pPassphrase,pSsid,CONCAT31(in_register_0000202d,ssidLen),pPSK); + } + else { + if (CONCAT31(in_register_00002035,PassphraseLen) == 0x40) { + iVar3 = 0; + do { + UVar1 = pmkCacheGetHexNibble(*pPassphrase); + bVar2 = pmkCacheGetHexNibble(pPassphrase[1]); + pPSK[iVar3 >> 1] = bVar2 | UVar1 << 4; + iVar3 = iVar3 + 2; + pPassphrase = pPassphrase + 2; + } while (iVar3 != 0x40); + } + } + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ad924); + return; +} + + + +void prepare_key(uchar *key_data_ptr,int key_data_len,rc4_key *key) + +{ + byte bVar1; + uchar *puVar2; + rc4_key *prVar3; + uint uVar4; + int iVar5; + uint uVar6; + uint uVar7; + + iVar5 = 0; + do { + key->state[iVar5] = (uchar)iVar5; + iVar5 = iVar5 + 1; + } while (iVar5 != 0x100); + key->x = '\0'; + key->y = '\0'; + uVar7 = 0; + uVar4 = 0; + prVar3 = key; + do { + bVar1 = prVar3->state[0]; + puVar2 = prVar3->state; + uVar6 = (uint)key_data_ptr[uVar4] + (uint)bVar1 + uVar7; + uVar7 = uVar6 & 0xff; + prVar3->state[0] = key->state[uVar6 & 0xff]; + key->state[uVar6 & 0xff] = bVar1; + uVar4 = (int)(uVar4 + 1) % key_data_len & 0xff; + prVar3 = (rc4_key *)(puVar2 + 1); + } while ((rc4_key *)&key->x != (rc4_key *)(puVar2 + 1)); + return; +} + + + +void rc4(uchar *buffer_ptr,int buffer_len,int skip,rc4_key *key) + +{ + byte bVar1; + byte bVar2; + byte *pbVar3; + uint uVar4; + int iVar5; + uint uVar6; + byte *pbVar7; + uint uVar8; + + bVar1 = key->x; + uVar4 = (uint)key->y; + iVar5 = 0; + while (uVar8 = (uint)bVar1 + iVar5 & 0xff, iVar5 < skip) { + bVar2 = key->state[uVar8 + 1 & 0xff]; + uVar4 = uVar4 + bVar2 & 0xff; + iVar5 = (iVar5 + 1) * 0x10000 >> 0x10; + key->state[uVar8 + 1 & 0xff] = key->state[uVar4]; + key->state[uVar4] = bVar2; + } + iVar5 = 0; + while (uVar6 = uVar8 + iVar5 & 0xff, iVar5 < buffer_len) { + pbVar7 = key->state + (uVar6 + 1 & 0xff); + bVar1 = *pbVar7; + uVar4 = uVar4 + (uint)bVar1 & 0xff; + *pbVar7 = key->state[uVar4]; + key->state[uVar4] = bVar1; + pbVar3 = buffer_ptr + iVar5; + iVar5 = (iVar5 + 1) * 0x10000 >> 0x10; + *pbVar3 = key->state[(uint)bVar1 + (uint)*pbVar7 & 0xff] ^ *pbVar3; + } + key->x = (uchar)uVar6; + key->y = (uchar)uVar4; + return; +} + + + +void RC4_Encrypt(uchar *Encr_Key,uchar *IV,ushort iv_length,uchar *Data,ushort data_length, + ushort skipBytes) + +{ + undefined2 in_register_00002032; + size_t __n; + undefined2 in_register_0000203a; + undefined2 in_register_0000203e; + uchar auStack64 [4]; + uchar key [32]; + + __n = CONCAT22(in_register_00002032,iv_length); + if ((int)(__n + 0x10) < 0x21) { + memcpy(auStack64,IV,__n); + memcpy(auStack64 + __n,Encr_Key,0x10); + prepare_key(auStack64,__n + 0x10,&rc4key); + rc4(Data,CONCAT22(in_register_0000203a,data_length),CONCAT22(in_register_0000203e,skipBytes), + &rc4key); + } + return; +} + + + +int sha256_compress(sha256_state *md,UINT8 *msgBuf,UINT8 *pScratchMem) + +{ + UINT32 *pUVar1; + UINT32 *pUVar2; + int iVar3; + uint uVar4; + uint *puVar5; + uint uVar6; + int *piVar7; + int *piVar8; + int iVar9; + int iVar10; + uint uVar11; + int *__dest; + ushort *puVar12; + ushort *puVar13; + uint uVar14; + uint uVar15; + uint uVar16; + + __dest = (int *)(pScratchMem + 0x100); + memcpy(__dest,md->state,0x20); + puVar5 = (uint *)pScratchMem; + puVar12 = (ushort *)msgBuf; + do { + puVar13 = puVar12 + 2; + *puVar5 = (((uint)(*puVar12 >> 8) | ((uint)*puVar12 & 0xff) << 8) << 8 | + (uint)*(byte *)(puVar12 + 1)) << 8 | (uint)*(byte *)((int)puVar12 + 3); + puVar5 = puVar5 + 1; + puVar12 = puVar13; + } while (puVar13 != (ushort *)(msgBuf + 0x40)); + piVar7 = (int *)(pScratchMem + 0x40); + do { + uVar6 = piVar7[-2]; + uVar4 = piVar7[-0xf]; + piVar8 = piVar7 + 1; + *piVar7 = ((uVar6 << 0xf | uVar6 >> 0x11) ^ (uVar6 << 0xd | uVar6 >> 0x13) ^ uVar6 >> 10) + + piVar7[-7] + piVar7[-0x10] + + ((uVar4 >> 7 | uVar4 << 0x19) ^ (uVar4 << 0xe | uVar4 >> 0x12) ^ uVar4 >> 3); + piVar7 = piVar8; + } while (__dest != piVar8); + iVar3 = 0; + do { + uVar4 = *(uint *)(pScratchMem + 0x110); + uVar14 = *(uint *)(pScratchMem + 0x118); + uVar15 = *(uint *)(pScratchMem + 0x114); + uVar6 = *(uint *)(pScratchMem + 0x100); + iVar9 = *(int *)((int)K + iVar3); + uVar11 = *(uint *)(pScratchMem + 0x104); + uVar16 = *(uint *)(pScratchMem + 0x108); + iVar10 = *(int *)(pScratchMem + iVar3); + *(uint *)(pScratchMem + 0x114) = uVar4; + iVar10 = ((uVar4 >> 6 | uVar4 << 0x1a) ^ (uVar4 >> 0xb | uVar4 << 0x15) ^ + (uVar4 << 7 | uVar4 >> 0x19)) + ((uVar14 ^ uVar15) & uVar4 ^ uVar14) + + *(int *)(pScratchMem + 0x11c) + iVar9 + iVar10; + *(int *)(pScratchMem + 0x110) = *(int *)(pScratchMem + 0x10c) + iVar10; + *(uint *)(pScratchMem + 0x104) = uVar6; + *(uint *)(pScratchMem + 0x11c) = uVar14; + *(uint *)(pScratchMem + 0x118) = uVar15; + *(uint *)(pScratchMem + 0x10c) = uVar16; + *(uint *)(pScratchMem + 0x108) = uVar11; + *(uint *)(pScratchMem + 0x100) = + iVar10 + ((uVar6 >> 2 | uVar6 << 0x1e) ^ (uVar6 >> 0xd | uVar6 << 0x13) ^ + (uVar6 << 10 | uVar6 >> 0x16)) + (uVar6 & uVar11 | (uVar6 | uVar11) & uVar16); + iVar3 = iVar3 + 4; + } while (iVar3 != 0x100); + pUVar1 = md->state; + do { + iVar3 = *__dest; + pUVar2 = pUVar1 + 1; + __dest = __dest + 1; + *pUVar1 = *pUVar1 + iVar3; + pUVar1 = pUVar2; + } while (&md->curlen != pUVar2); + return 0; +} + + + +void sha256_init(sha256_state *md) + +{ + *(undefined4 *)&md->length = 0; + md->state[0] = 0x6a09e667; + md->state[1] = 0xbb67ae85; + md->state[2] = 0x3c6ef372; + md->state[3] = 0xa54ff53a; + md->state[4] = 0x510e527f; + md->state[5] = 0x9b05688c; + md->state[6] = 0x1f83d9ab; + md->curlen = 0; + *(undefined4 *)((int)&md->length + 4) = 0; + md->state[7] = 0x5be0cd19; + return; +} + + + +void sha256_vector(size_t num_elem,UINT8 **addr,size_t *len,UINT8 *mac,UINT8 *pScratchMem) + +{ + int iVar1; + uint uVar2; + uint __n; + undefined4 uVar3; + undefined4 uVar4; + undefined4 *puVar5; + uint uVar6; + UINT8 *msgBuf; + UINT8 *pScratchMem_00; + int iVar7; + + pScratchMem_00 = pScratchMem + 0x70; + sha256_init((sha256_state *)pScratchMem); + iVar7 = 0; + do { + __n = *(uint *)(pScratchMem + 0x28); + if (iVar7 == num_elem << 2) { + if (__n < 0x40) { + uVar2 = __n * 8 + *(uint *)pScratchMem; + *(uint *)(pScratchMem + 4) = + (uint)(uVar2 < *(uint *)pScratchMem) + *(int *)(pScratchMem + 4); + *(uint *)pScratchMem = uVar2; + *(uint *)(pScratchMem + 0x28) = __n + 1; + pScratchMem[__n + 0x2c] = -0x80; + if (0x38 < __n + 1) { + while (__n = *(uint *)(pScratchMem + 0x28), __n < 0x40) { + *(uint *)(pScratchMem + 0x28) = __n + 1; + pScratchMem[__n + 0x2c] = '\0'; + } + sha256_compress((sha256_state *)pScratchMem,pScratchMem + 0x2c,pScratchMem_00); + *(undefined4 *)(pScratchMem + 0x28) = 0; + } + while (__n = *(uint *)(pScratchMem + 0x28), __n < 0x38) { + *(uint *)(pScratchMem + 0x28) = __n + 1; + pScratchMem[__n + 0x2c] = '\0'; + } + uVar3 = *(undefined4 *)pScratchMem; + pScratchMem[0x68] = (UINT8)((uint)uVar3 >> 0x18); + pScratchMem[0x69] = (UINT8)((uint)uVar3 >> 0x10); + pScratchMem[0x6b] = (UINT8)uVar3; + uVar4 = *(undefined4 *)(pScratchMem + 4); + pScratchMem[0x6a] = (UINT8)((uint)uVar3 >> 8); + pScratchMem[100] = (UINT8)((uint)uVar4 >> 0x18); + pScratchMem[0x65] = (UINT8)((uint)uVar4 >> 0x10); + pScratchMem[0x67] = (UINT8)uVar4; + pScratchMem[0x66] = (UINT8)((uint)uVar4 >> 8); + sha256_compress((sha256_state *)pScratchMem,pScratchMem + 0x2c,pScratchMem_00); + puVar5 = (undefined4 *)(pScratchMem + 8); + do { + puVar5 = puVar5 + 1; + uVar3 = *puVar5; + *mac = (UINT8)((uint)uVar3 >> 0x18); + mac[1] = (UINT8)((uint)uVar3 >> 0x10); + mac[2] = (UINT8)((uint)uVar3 >> 8); + mac[3] = (UINT8)uVar3; + puVar5 = puVar5; + mac = mac + 4; + } while (puVar5 != (undefined4 *)(pScratchMem + 0x28)); + } + return; + } + msgBuf = *(UINT8 **)((int)addr + iVar7); + uVar2 = *(uint *)((int)len + iVar7); + if (__n < 0x41) { + while (iVar1 = *(int *)(pScratchMem + 0x28), uVar2 != 0) { + if ((iVar1 == 0) && (0x3f < uVar2)) { + iVar1 = sha256_compress((sha256_state *)pScratchMem,msgBuf,pScratchMem_00); + if (iVar1 < 0) break; + uVar6 = *(uint *)pScratchMem; + msgBuf = msgBuf + 0x40; + __n = uVar6 + 0x200; + *(uint *)pScratchMem = __n; + *(uint *)(pScratchMem + 4) = (uint)(__n < uVar6) + *(int *)(pScratchMem + 4); + uVar2 = uVar2 - 0x40; + } + else { + __n = 0x40U - iVar1; + if (uVar2 < 0x40U - iVar1) { + __n = uVar2; + } + memcpy(pScratchMem + 0x2c + iVar1,msgBuf,__n); + iVar1 = *(int *)(pScratchMem + 0x28); + msgBuf = msgBuf + __n; + uVar2 = uVar2 - __n; + *(uint *)(pScratchMem + 0x28) = iVar1 + __n; + if (iVar1 + __n == 0x40) { + iVar1 = sha256_compress((sha256_state *)pScratchMem,pScratchMem + 0x2c,pScratchMem_00); + if (iVar1 < 0) break; + uVar6 = *(uint *)pScratchMem; + *(undefined4 *)(pScratchMem + 0x28) = 0; + __n = uVar6 + 0x200; + *(uint *)pScratchMem = __n; + *(uint *)(pScratchMem + 4) = (uint)(__n < uVar6) + *(int *)(pScratchMem + 4); + } + } + } + } + iVar7 = iVar7 + 4; + } while( true ); +} + + + +// WARNING: Variable defined which should be unmapped: pScratchMem + +void hmac_sha256_vector(UINT8 *key,size_t key_len,size_t num_elem,UINT8 **addr,size_t *len, + UINT8 *mac) + +{ + size_t *mac_00; + UINT8 **ppUVar1; + size_t **ppsVar2; + UINT8 **len_00; + UINT8 **ppUVar3; + size_t *psVar4; + int iVar5; + size_t *psVar6; + size_t sStack600; + uint *apuStack596 [4]; + size_t *psStack580; + UINT8 *_addr [6]; + size_t _len [6]; + UINT8 pScratchMem [500]; + + mac_00 = (size_t *)(pScratchMem + 0x3c); + sStack600 = key_len; + apuStack596[0] = (uint *)key; + if (0x40 < key_len) { + apuStack596[0] = (uint *)key; + sha256_vector(1,(UINT8 **)apuStack596,&sStack600,(UINT8 *)mac_00,pScratchMem + 0x5c); + sStack600 = 0x20; + apuStack596[0] = mac_00; + } + memset(_len + 5,0,0x40); + memcpy(_len + 5,apuStack596[0],sStack600); + psVar6 = _len + 5; + do { + psVar4 = psVar6 + 1; + *psVar6 = *psVar6 ^ 0x36363636; + psVar6 = psVar4; + } while (psVar4 != mac_00); + psStack580 = _len + 5; + len_00 = _addr + 5; + _addr[5] = (UINT8 *)0x40; + iVar5 = 0; + ppsVar2 = &psStack580; + ppUVar3 = len_00; + while( true ) { + ppsVar2 = ppsVar2 + 1; + ppUVar3 = ppUVar3 + 1; + if (iVar5 == num_elem << 2) break; + *ppsVar2 = *(size_t **)((int)addr + iVar5); + ppUVar1 = (UINT8 **)((int)len + iVar5); + iVar5 = iVar5 + 4; + *ppUVar3 = *ppUVar1; + } + sha256_vector(num_elem + 1,(UINT8 **)&psStack580,(size_t *)len_00,mac,pScratchMem + 0x5c); + memset(_len + 5,0,0x40); + memcpy(_len + 5,apuStack596[0],sStack600); + psVar6 = _len + 5; + do { + psVar4 = psVar6 + 1; + *psVar6 = *psVar6 ^ 0x5c5c5c5c; + psVar6 = psVar4; + } while (psVar4 != mac_00); + psStack580 = _len + 5; + _addr[5] = (UINT8 *)0x40; + _len[0] = 0x20; + _addr[0] = mac; + sha256_vector(2,(UINT8 **)&psStack580,(size_t *)len_00,mac,pScratchMem + 0x5c); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +Status_e supplicantRestoreDefaults(void) + +{ + char "supplicantRestoreDefaults" [26]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantRestoreDefaults"); + pmkCacheInit(); + pmkCacheRomInit(); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230ada38); + return FW_SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantFuncInit(void) + +{ + char "supplicantFuncInit" [19]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantFuncInit"); + supplicantRestoreDefaults(); + dbg_test_print("%dms : Leave: %s\n",0x230ada54); + return; +} + + + +void KeyMgmtInit(cm_ConnectionInfo_t *connPtr) + +{ + UINT8 ssidLen; + apInfo_t *paVar1; + size_t sVar2; + UINT8 *pPassphrase; + + paVar1 = cm_GetApInfo(connPtr); + ROM_InitGTK(&(paVar1->bssData).grpKeyData,(paVar1->bssData).GNonce,connPtr->localMacAddr); + if ((paVar1->bssData).updatePassPhrase == 1) { + ssidLen = (connPtr->comData).SsIdLen; + pPassphrase = (paVar1->bssConfig).RsnConfig.PSKPassPhrase; + sVar2 = strlen((char *)pPassphrase); + pmkCacheGeneratePSK((UINT8 *)&connPtr->comData,ssidLen,pPassphrase,(UINT8)sVar2, + (paVar1->bssConfig).RsnConfig.PSKValue); + (paVar1->bssData).updatePassPhrase = 0; + } + return; +} + + + +BufferDesc_t * +PrepDefaultEapolMsg(cm_ConnectionInfo_t *connPtr,EAPOL_KeyMsg_Tx_t **pTxEapolPtr, + BufferDesc_t *pBufDesc) + +{ + apSpecificData_t *paVar1; + apInfo_t *paVar2; + BufferDesc_t *pBVar3; + uint nonTKIP; + EAPOL_KeyMsg_Tx_t *pEStack36; + EAPOL_KeyMsg_Tx_t *tx_eapol_ptr; + + paVar1 = cm_GetApData(connPtr); + paVar2 = cm_GetApInfo(connPtr); + pBVar3 = GetTxEAPOLBuffer(connPtr,&pEStack36,pBufDesc); + if (pBVar3 != (BufferDesc_t *)0x0) { + memset(pEStack36,0,0x72); + formEAPOLEthHdr(pEStack36,(IEEEtypes_MacAddr_t *)connPtr->peerMacAddr, + (IEEEtypes_MacAddr_t *)connPtr->localMacAddr); + nonTKIP = 1; + if (((byte)(paVar1->staData).keyMgmtInfo.rom.staUcstCipher & 8) == 0) { + nonTKIP = (uint)((byte)(paVar2->bssConfig).RsnConfig.mcstCipher >> 3) & 1; + } + SetEAPOLKeyDescTypeVersion + (pEStack36,*(uint *)&(paVar1->staData).keyMgmtInfo.rom >> 0x15 & 1,0,nonTKIP); + *pTxEapolPtr = pEStack36; + } + return pBVar3; +} + + + +// WARNING: Variable defined which should be unmapped: replay_cnt + +Status_e GeneratePWKMsg1(cm_ConnectionInfo_t *connPtr,BufferDesc_t *pBufDesc) + +{ + Status_e SVar1; + apSpecificData_t *paVar2; + BufferDesc_t *pBufDesc_00; + uint uVar3; + uint uVar4; + UINT32 UVar5; + EAPOL_KeyMsg_Tx_t *pEStack28; + EAPOL_KeyMsg_Tx_t *tx_eapol_ptr; + UINT32 replay_cnt [2]; + + paVar2 = cm_GetApData(connPtr); + pBufDesc_00 = PrepDefaultEapolMsg(connPtr,&pEStack28,pBufDesc); + if (pBufDesc_00 == (BufferDesc_t *)0x0) { + SVar1 = FAIL; + } + else { + UVar5 = (paVar2->staData).keyMgmtInfo.counterLo + 1; + (paVar2->staData).keyMgmtInfo.counterLo = UVar5; + if (UVar5 == 0) { + (paVar2->staData).keyMgmtInfo.counterHi = (paVar2->staData).keyMgmtInfo.counterHi + 1; + } + tx_eapol_ptr = (EAPOL_KeyMsg_Tx_t *)(paVar2->staData).keyMgmtInfo.counterHi; + supplicantGenerateRand((UINT8 *)&connPtr->TxRxCipherKeyBuf,0x20); + PopulateKeyMsg(pEStack28,&(paVar2->staData).keyMgmtInfo.rom.staUcstCipher,0x800, + (UINT32 *)&tx_eapol_ptr,(UINT8 *)&connPtr->TxRxCipherKeyBuf); + uVar3 = (uint)(pEStack28->keyMsg).key_material_len + 0x5f; + uVar4 = uVar3 & 0xffff; + (pEStack28->keyMsg).hdr_8021x.protocol_ver = (paVar2->staData).keyMgmtInfo.EAPOLProtoVersion; + (pEStack28->keyMsg).hdr_8021x.pckt_type = IEEE_8021X_PACKET_TYPE_EAPOL_KEY; + *(char *)&(pEStack28->keyMsg).hdr_8021x.pckt_body_len = (char)(uVar4 >> 8); + *(undefined *)((int)&(pEStack28->keyMsg).hdr_8021x.pckt_body_len + 1) = (char)uVar4; + UpdateEAPOLWcbLenAndTransmit(pBufDesc_00,(UINT16)(uVar3 * 0x10000 >> 0x10)); + SVar1 = FW_SUCCESS; + } + return SVar1; +} + + + +Status_e GeneratePWKMsg3(cm_ConnectionInfo_t *connPtr,BufferDesc_t *pBufDesc) + +{ + SecurityMode_t SVar1; + UINT16 frameLen; + BufferDesc_t *pBufDesc_00; + apSpecificData_t *paVar2; + apInfo_t *paVar3; + BOOLEAN BVar4; + uint8_t *pWPA2; + UINT32 UVar5; + Cipher_t *Cipher; + EAPOL_KeyMsg_Tx_t *pEStack44; + EAPOL_KeyMsg_Tx_t *tx_eapol_ptr; + UINT32 replay_cnt [2]; + + pBufDesc_00 = PrepDefaultEapolMsg(connPtr,&pEStack44,pBufDesc); + if (pBufDesc_00 != (BufferDesc_t *)0x0) { + paVar2 = cm_GetApData(connPtr); + paVar3 = cm_GetApInfo(connPtr); + UVar5 = (paVar2->staData).keyMgmtInfo.counterLo + 1; + (paVar2->staData).keyMgmtInfo.counterLo = UVar5; + if (UVar5 == 0) { + (paVar2->staData).keyMgmtInfo.counterHi = (paVar2->staData).keyMgmtInfo.counterHi + 1; + } + tx_eapol_ptr = (EAPOL_KeyMsg_Tx_t *)(paVar2->staData).keyMgmtInfo.counterHi; + Cipher = &(paVar2->staData).keyMgmtInfo.rom.staUcstCipher; + PopulateKeyMsg(pEStack44,Cipher, + ((ushort)(paVar2->staData).keyMgmtInfo.rom.staSecType & 0x20) << 10 | 0x880, + (UINT32 *)&tx_eapol_ptr,(UINT8 *)&connPtr->TxRxCipherKeyBuf); + SVar1 = (paVar2->staData).keyMgmtInfo.rom.staSecType; + pWPA2 = (uint8_t *)0x0; + if ((((ushort)SVar1 & 8) == 0) && (((ushort)SVar1 & 0x20) != 0)) { + pWPA2 = int_rsn_ie; + } + BVar4 = KeyData_UpdateKeyMaterial + (pEStack44,&(paVar2->staData).keyMgmtInfo.rom.staSecType,(void *)0x0,pWPA2); + if (BVar4 != 0) { + if (((ushort)(paVar2->staData).keyMgmtInfo.rom.staSecType & 0x20) == 0) { +LAB_23018ba0: + frameLen = KeyMgmtSta_PopulateEAPOLLengthMic + (pEStack44,(paVar2->staData).keyMgmtInfo.EAPOL_MIC_Key, + (paVar2->staData).keyMgmtInfo.EAPOLProtoVersion, + *(byte *)&(pEStack44->keyMsg).key_info.field_0x1 & 7); + UpdateEAPOLWcbLenAndTransmit(pBufDesc_00,frameLen); + return FW_SUCCESS; + } + prepareKDE(pEStack44,&(paVar3->bssData).grpKeyData,(Cipher_t *)&(paVar3->bssConfig).RsnConfig) + ; + BVar4 = Encrypt_keyData(pEStack44,(paVar2->staData).keyMgmtInfo.EAPOL_Encr_Key,Cipher); + if (BVar4 != 0) goto LAB_23018ba0; + } + vPortFree(pBufDesc_00->Buffer); + vPortFree(pBufDesc_00); + } + return FAIL; +} + + + +Status_e ProcessPWKMsg4(BufferDesc_t *pBufDesc) + +{ + SecurityMode_t SVar1; + cm_ConnectionInfo_t *connPtr; + Status_e SVar2; + apSpecificData_t *paVar3; + BOOLEAN BVar4; + + connPtr = (cm_ConnectionInfo_t *)pBufDesc->intf; + paVar3 = cm_GetApData(connPtr); + BVar4 = IsEAPOL_MICValid((EAPOL_KeyMsg_t *)pBufDesc->Buffer, + (paVar3->staData).keyMgmtInfo.EAPOL_MIC_Key); + if (BVar4 == 0) { + SVar2 = FAIL; + } + else { + (connPtr->TxRxCipherKeyBuf).cipher_key.ckd[0x44] = 1; + (connPtr->TxRxCipherKeyBuf).cipher_key.ckd[0x45] = 0; + (connPtr->TxRxCipherKeyBuf).cipher_key.ckd[0x40] = 0; + (connPtr->TxRxCipherKeyBuf).cipher_key.ckd[0x41] = 0; + (connPtr->TxRxCipherKeyBuf).cipher_key.ckd[0x42] = 0; + (connPtr->TxRxCipherKeyBuf).cipher_key.ckd[0x43] = 0; + add_key_to_mac(connPtr,'\x01'); + apm_sta_add(connPtr->staId); + SVar1 = (paVar3->staData).keyMgmtInfo.rom.staSecType; + (paVar3->staData).keyMgmtInfo.numHskTries = '\0'; + SVar2 = FW_SUCCESS; + if (((ushort)SVar1 & 0x20) != 0) { + (paVar3->staData).keyMgmtInfo.rom.keyMgmtState = HSK_END; + } + } + return SVar2; +} + + + +Status_e GenerateApEapolMsg(cm_ConnectionInfo_t *connPtr,keyMgmtState_e msgState, + BufferDesc_t *pBufDesc) + +{ + IEEEtypes_PwrMgmtMode_e IVar1; + uint uVar2; + Status_e SVar3; + apSpecificData_t *paVar4; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 in_register_0000202d; + + uVar2 = CONCAT31(in_register_0000202d,msgState); + paVar4 = cm_GetApData(connPtr); + if ((msgState & 1) == 0) { + uVar2 = uVar2 - 1 & 0xff; + } + IVar1 = (paVar4->staData).pwrSaveInfo.mode; + (paVar4->staData).keyMgmtInfo.rom.keyMgmtState = (keyMgmtState_e)uVar2; + if (IVar1 != PWR_MODE_PWR_SAVE) { + if (uVar2 == 1) { + SVar3 = GeneratePWKMsg1(connPtr,pBufDesc); + _SVar3 = CONCAT31(extraout_var,SVar3); + } + else { + if (uVar2 != 3) { + if (pBufDesc == (BufferDesc_t *)0x0) { + return FAIL; + } + vPortFree(pBufDesc->Buffer); + vPortFree(pBufDesc); + return FAIL; + } + SVar3 = GeneratePWKMsg3(connPtr,pBufDesc); + _SVar3 = CONCAT31(extraout_var_00,SVar3); + } + if (_SVar3 != 0) { + return (Status_e)_SVar3; + } + (paVar4->staData).keyMgmtInfo.rom.keyMgmtState = + (paVar4->staData).keyMgmtInfo.rom.keyMgmtState + MSG1_PENDING; + } + (paVar4->staData).keyMgmtInfo.numHskTries = (paVar4->staData).keyMgmtInfo.numHskTries + '\x01'; + return FW_SUCCESS; +} + + + +Status_e ProcessPWKMsg2(BufferDesc_t *pBufDesc) + +{ + cm_ConnectionInfo_t *connPtr; + EAPOL_KeyMsg_t *pKeyMsg; + Status_e SVar1; + apSpecificData_t *paVar2; + apInfo_t *paVar3; + BOOLEAN BVar4; + UINT8 *EAPOL_MIC_Key; + BOOLEAN in_fa0; + + connPtr = (cm_ConnectionInfo_t *)pBufDesc->intf; + paVar2 = cm_GetApData(connPtr); + paVar3 = cm_GetApInfo(connPtr); + pKeyMsg = (EAPOL_KeyMsg_t *)pBufDesc->Buffer; + EAPOL_MIC_Key = (paVar2->staData).keyMgmtInfo.EAPOL_MIC_Key; + KeyMgmtAp_DerivePTK((paVar3->bssConfig).RsnConfig.PSKValue, + (IEEEtypes_MacAddr_t *)connPtr->peerMacAddr, + (IEEEtypes_MacAddr_t *)(connPtr->comData).BssId, + (UINT8 *)&connPtr->TxRxCipherKeyBuf,pKeyMsg->key_nonce,EAPOL_MIC_Key, + (paVar2->staData).keyMgmtInfo.EAPOL_Encr_Key, + (KeyData_t *)((connPtr->TxRxCipherKeyBuf).cipher_key.ckd + 0x20),in_fa0); + BVar4 = IsEAPOL_MICValid(pKeyMsg,EAPOL_MIC_Key); + if (BVar4 != 0) { + (paVar2->staData).keyMgmtInfo.numHskTries = '\0'; + rsn_len = pKeyMsg[1].hdr_8021x.protocol_ver + '\x02'; + SVar1 = GenerateApEapolMsg(connPtr,MSG3_PENDING,(BufferDesc_t *)0x0); + return SVar1; + } + return FAIL; +} + + + +BOOLEAN SendEAPOLMsgUsingBufDesc(cm_ConnectionInfo_t *connPtr,BufferDesc_t *pBufDesc) + +{ + keyMgmtState_e msgState; + bool bVar1; + apSpecificData_t *paVar2; + + paVar2 = cm_GetApData(connPtr); + msgState = (paVar2->staData).keyMgmtInfo.rom.keyMgmtState; + bVar1 = (msgState & 1) != 0; + if (bVar1) { + GenerateApEapolMsg(connPtr,msgState,pBufDesc); + } + return (uint)bVar1; +} + + + +// WARNING: Variable defined which should be unmapped: rxCounterLo + +Status_e ProcessKeyMgmtDataAp(BufferDesc_t *pBufDesc) + +{ + keyMgmtState_e kVar1; + Status_e SVar2; + apSpecificData_t *paVar3; + void *pvVar4; + uint uStack24; + UINT32 rxCounterHi; + UINT32 rxCounterLo; + + paVar3 = cm_GetApData((cm_ConnectionInfo_t *)pBufDesc->intf); + pvVar4 = pBufDesc->Buffer; + if ((*(byte *)((int)pvVar4 + 5) & 4) == 0) { + memcpy(&uStack24,(void *)((int)pvVar4 + 9),4); + memcpy(&rxCounterHi,(void *)((int)pvVar4 + 0xd),4); + if (((paVar3->staData).keyMgmtInfo.counterHi == + (uStack24 >> 8 & 0xff00) + + (uStack24 & 0xff00) * 0x100 + uStack24 * 0x1000000 + (uStack24 >> 0x18)) && + ((paVar3->staData).keyMgmtInfo.counterLo == + (rxCounterHi >> 8 & 0xff00) + + rxCounterHi * 0x1000000 + (rxCounterHi >> 0x18) + (rxCounterHi & 0xff00) * 0x100)) { + kVar1 = (paVar3->staData).keyMgmtInfo.rom.keyMgmtState; + if (kVar1 == WAITING_4_MSG2) { + SVar2 = ProcessPWKMsg2(pBufDesc); + return SVar2; + } + if (kVar1 == WAITING_4_MSG4) { + SVar2 = ProcessPWKMsg4(pBufDesc); + return SVar2; + } + } + } + return FAIL; +} + + + +void InitStaKeyInfo(void *pConn,SecurityMode_t *secType,Cipher_t *pwCipher,UINT16 staRsnCap, + UINT8 akmType) + +{ + apKeyMgmtInfoSta_t *__s; + apSpecificData_t *paVar1; + + paVar1 = cm_GetApData((cm_ConnectionInfo_t *)pConn); + __s = &(paVar1->staData).keyMgmtInfo; + memset(__s,0,0x48); + InitKeyMgmtInfo((apKeyMgmtInfoStaRom_t *)__s,secType,pwCipher,staRsnCap,akmType); + (paVar1->staData).keyMgmtInfo.EAPOLProtoVersion = '\x01'; + return; +} + + + +void RemoveAPKeyInfo(void *pConn) + +{ + if (*(uint8_t *)((int)pConn + 3) != -1) { + mm_sec_machwkey_del(*(uint8_t *)((int)pConn + 3)); + return; + } + return; +} + + + +void InitGroupKey(cm_ConnectionInfo_t *connPtr) + +{ + uint8_t uVar1; + apInfo_t *paVar2; + int iVar3; + undefined3 extraout_var; + UINT32 UVar4; + + paVar2 = cm_GetApInfo(connPtr); + (paVar2->bssData).grpRekeyBcnCntConfigured = 0; + (paVar2->bssData).grpRekeyBcnCntRemaining = 0; + KeyMgmtInit(connPtr); + UVar4 = (paVar2->bssConfig).RsnConfig.GrpReKeyTime; + if (UVar4 != 0) { + iVar3 = UVar4 * 0x1e848 + -0x7d; + __udivdi3(); + (paVar2->bssData).grpRekeyBcnCntConfigured = iVar3 + 1U; + (paVar2->bssData).grpRekeyBcnCntRemaining = iVar3 + 1U; + } + uVar1 = add_key_to_mac(connPtr,'\0'); + connPtr->gtkHwKeyId = uVar1; + printf("gtkHwKeyId is %d\r\n",CONCAT31(extraout_var,uVar1)); + return; +} + + + +// WARNING: Variable defined which should be unmapped: inp_data + +void GenerateGTK_internal(KeyData_t *grpKeyData,UINT8 *nonce,IEEEtypes_Addr_t *StaMacAddr) + +{ + size_t prefix_len; + uchar auStack140 [4]; + UINT8 prefix [20]; + UINT8 GTK [32]; + UINT8 grpMasterKey [32]; + UINT8 inp_data [38]; + + memcpy(auStack140,"Group key expansion",0x14); + if ((grpKeyData != (KeyData_t *)0x0) && (nonce != (UINT8 *)0x0)) { + memcpy(grpMasterKey + 0x1c,StaMacAddr,6); + supplicantGenerateRand(nonce,0x20); + memcpy(inp_data + 2,nonce,0x20); + supplicantGenerateRand(GTK + 0x1c,0x20); + prefix_len = strlen((char *)auStack140); + Bl_PRF(GTK + 0x1c,0x20,auStack140,prefix_len,grpMasterKey + 0x1c,0x26,prefix + 0x10,0x20); + memcpy(grpKeyData,prefix + 0x10,0x10); + memcpy(grpKeyData->TxMICKey,GTK + 0xc,8); + memcpy(grpKeyData->RxMICKey,GTK + 0x14,8); + } + return; +} + + + +void PopulateKeyMsg(EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,Cipher_t *Cipher,UINT16 Type,UINT32 *replay_cnt, + UINT8 *Nonce) + +{ + byte bVar1; + undefined2 in_register_00002032; + int iVar2; + undefined uVar3; + byte bVar4; + uint uVar5; + + uVar5 = CONCAT22(in_register_00002032,Type); + if ((tx_eapol_ptr == (EAPOL_KeyMsg_Tx_t *)0x0) || (Cipher == (Cipher_t *)0x0)) { + return; + } + if (((byte)*Cipher & 4) == 0) { + if (((byte)*Cipher & 8) != 0) { + *(undefined *)&(tx_eapol_ptr->keyMsg).key_length = 0; + uVar3 = 0x10; + goto LAB_23018fae; + } + } + else { + *(undefined *)&(tx_eapol_ptr->keyMsg).key_length = 0; + uVar3 = 0x20; +LAB_23018fae: + *(undefined *)((int)&(tx_eapol_ptr->keyMsg).key_length + 1) = uVar3; + } + bVar1 = *(byte *)&(tx_eapol_ptr->keyMsg).key_info.field_0x1; + *(byte *)&(tx_eapol_ptr->keyMsg).key_info.field_0x1 = bVar1 | 0x80; + if ((int)(uVar5 << 0x14) < 0) { + *(byte *)&(tx_eapol_ptr->keyMsg).key_info.field_0x1 = bVar1 | 0x88; + if ((Type & 0x80) == 0) goto LAB_23018ff8; + bVar4 = *(byte *)&(tx_eapol_ptr->keyMsg).key_info; + *(byte *)&(tx_eapol_ptr->keyMsg).key_info.field_0x1 = bVar1 | 200; + bVar4 = bVar4 & 0xed | 1 | (byte)((uVar5 >> 0xf) << 1); + bVar1 = (byte)((uVar5 >> 0xf) << 4); + } + else { + bVar1 = (byte)((uVar5 >> 0xf) << 4); + bVar4 = *(byte *)&(tx_eapol_ptr->keyMsg).key_info & 0xec | 3; + } + *(byte *)&(tx_eapol_ptr->keyMsg).key_info = bVar1 | bVar4; +LAB_23018ff8: + uVar5 = *replay_cnt; + iVar2 = uVar5 * 0x1000000 + (uVar5 >> 0x18) + (uVar5 & 0xff00) * 0x100 + (uVar5 >> 8 & 0xff00); + *(char *)(tx_eapol_ptr->keyMsg).replay_cnt = (char)iVar2; + *(undefined *)((int)(tx_eapol_ptr->keyMsg).replay_cnt + 1) = (char)((uint)iVar2 >> 8); + *(undefined *)((int)(tx_eapol_ptr->keyMsg).replay_cnt + 2) = (char)((uint)iVar2 >> 0x10); + *(undefined *)((int)(tx_eapol_ptr->keyMsg).replay_cnt + 3) = (char)((uint)iVar2 >> 0x18); + uVar5 = replay_cnt[1]; + iVar2 = uVar5 * 0x1000000 + (uVar5 >> 0x18) + (uVar5 & 0xff00) * 0x100 + (uVar5 >> 8 & 0xff00); + *(char *)((tx_eapol_ptr->keyMsg).replay_cnt + 1) = (char)iVar2; + *(undefined *)((int)(tx_eapol_ptr->keyMsg).replay_cnt + 5) = (char)((uint)iVar2 >> 8); + *(undefined *)((int)(tx_eapol_ptr->keyMsg).replay_cnt + 6) = (char)((uint)iVar2 >> 0x10); + *(undefined *)((int)(tx_eapol_ptr->keyMsg).replay_cnt + 7) = (char)((uint)iVar2 >> 0x18); + memcpy((tx_eapol_ptr->keyMsg).key_nonce,Nonce,0x20); + return; +} + + + +void prepareKDE(EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,KeyData_t *grKey,Cipher_t *cipher) + +{ + uint uVar1; + uint uVar2; + int iVar3; + UINT8 *pUVar4; + UINT8 *__dest; + + if (tx_eapol_ptr != (EAPOL_KeyMsg_Tx_t *)0x0) { + if ((grKey != (KeyData_t *)0x0) && (cipher != (Cipher_t *)0x0)) { + pUVar4 = (tx_eapol_ptr->keyMsg).key_data + *(byte *)&(tx_eapol_ptr->keyMsg).key_material_len; + *pUVar4 = -0x23; + pUVar4[1] = '\x16'; + pUVar4[2] = '\0'; + pUVar4[3] = '\x0f'; + pUVar4[4] = -0x54; + pUVar4[5] = '\x01'; + pUVar4[6] = pUVar4[6] & 0xfc | 1; + memcpy(pUVar4 + 8,grKey,0x10); + __dest = pUVar4 + 0x18; + if (((byte)*cipher & 4) != 0) { + pUVar4[1] = pUVar4[1] + '\x10'; + memcpy(__dest,grKey->TxMICKey,8); + memcpy(pUVar4 + 0x20,grKey->RxMICKey,8); + __dest = pUVar4 + 0x28; + } + uVar1 = (uint)(tx_eapol_ptr->keyMsg).key_material_len + 2 + (uint)pUVar4[1]; + uVar2 = uVar1 & 0xffff; + *(char *)&(tx_eapol_ptr->keyMsg).key_material_len = (char)(uVar1 * 0x10000 >> 0x10); + *(undefined *)((int)&(tx_eapol_ptr->keyMsg).key_material_len + 1) = (char)(uVar2 >> 8); + uVar1 = -uVar2 & 7; + if (uVar1 != 0) { + *__dest = -0x23; + memset(__dest + 1,0,uVar1 - 1); + iVar3 = uVar1 + (tx_eapol_ptr->keyMsg).key_material_len; + *(char *)&(tx_eapol_ptr->keyMsg).key_material_len = (char)((uint)(iVar3 * 0x10000) >> 0x10); + *(undefined *)((int)&(tx_eapol_ptr->keyMsg).key_material_len + 1) = (char)((uint)iVar3 >> 8) + ; + } + } + return; + } + return; +} + + + +BOOLEAN Encrypt_keyData(EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,UINT8 *EAPOL_Encr_Key,Cipher_t *cipher) + +{ + void *pv; + UINT8 *cipher_00; + uint uVar1; + uint __n; + UINT8 *plain; + UINT8 aUStack48 [4]; + UINT8 key [16]; + + if (((tx_eapol_ptr != (EAPOL_KeyMsg_Tx_t *)0x0) && (EAPOL_Encr_Key != (UINT8 *)0x0)) && + (cipher != (Cipher_t *)0x0)) { + if (((byte)*cipher & 8) == 0) { + return (uint)((byte)*cipher >> 2) & 1; + } + pv = pvPortMalloc(0xc); + if (pv != (void *)0x0) { + cipher_00 = (UINT8 *)pvPortMalloc(400); + *(UINT8 **)((int)pv + 8) = cipher_00; + if (cipher_00 != (UINT8 *)0x0) { + memcpy(aUStack48,EAPOL_Encr_Key,0x10); + plain = (tx_eapol_ptr->keyMsg).key_data; + BL_AesWrap(aUStack48,'\x02',(uint)((tx_eapol_ptr->keyMsg).key_material_len >> 3),plain, + (UINT8 *)0x0,cipher_00); + uVar1 = (uint)(tx_eapol_ptr->keyMsg).key_material_len + 8; + __n = uVar1 & 0xffff; + *(char *)&(tx_eapol_ptr->keyMsg).key_material_len = (char)(uVar1 * 0x10000 >> 0x10); + *(undefined *)((int)&(tx_eapol_ptr->keyMsg).key_material_len + 1) = (char)(__n >> 8); + memcpy(plain,cipher_00,__n); + vPortFree(*(void **)((int)pv + 8)); + vPortFree(pv); + return 1; + } + } + return 0; + } + return 0; +} + + + +void KeyMgmtAp_DerivePTK(UINT8 *pPMK,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa,UINT8 *ANonce, + UINT8 *SNonce,UINT8 *EAPOL_MIC_Key,UINT8 *EAPOL_Encr_Key,KeyData_t *newPWKey + ,BOOLEAN use_kdf) + +{ + undefined auStack24 [4]; + UINT8 tmp [8]; + + KeyMgmtSta_DeriveKeys(pPMK,da,sa,ANonce,SNonce,EAPOL_MIC_Key,EAPOL_Encr_Key,newPWKey,use_kdf); + memcpy(auStack24,newPWKey->RxMICKey,8); + memcpy(newPWKey->RxMICKey,newPWKey->TxMICKey,8); + memcpy(newPWKey->TxMICKey,auStack24,8); + return; +} + + + +BOOLEAN KeyData_CopyWPAWP2(EAPOL_KeyMsg_Tx_t *pTxEAPOL,void *pIe) + +{ + size_t __n; + + if (pIe != (void *)0x0) { + __n = (uint)*(byte *)((int)pIe + 1) + 2; + *(char *)&(pTxEAPOL->keyMsg).key_material_len = (char)__n; + *(undefined *)((int)&(pTxEAPOL->keyMsg).key_material_len + 1) = (char)(__n >> 8); + memcpy((pTxEAPOL->keyMsg).key_data,pIe,__n); + return 1; + } + return 0; +} + + + +BOOLEAN KeyData_UpdateKeyMaterial + (EAPOL_KeyMsg_Tx_t *pTxEAPOL,SecurityMode_t *pSecType,void *pWPA,void *pWPA2) + +{ + BOOLEAN BVar1; + uint uVar2; + + if (((*(byte *)pSecType & 0x18) != 0) || + (uVar2 = 1, pWPA = pWPA2, (*(byte *)pSecType & 0x20) != 0)) { + BVar1 = KeyData_CopyWPAWP2(pTxEAPOL,pWPA); + uVar2 = (uint)(BVar1 != 0); + } + return uVar2; +} + + + +void ROM_InitGTK(KeyData_t *grpKeyData,UINT8 *nonce,IEEEtypes_Addr_t *StaMacAddr) + +{ + grpKeyData->TxIV32 = 0; + *(undefined4 *)&grpKeyData->TxIV16 = 0x10001; + GenerateGTK_internal(grpKeyData,nonce,StaMacAddr); + return; +} + + + +void InitKeyMgmtInfo(apKeyMgmtInfoStaRom_t *pKeyMgmtInfo,SecurityMode_t *secType,Cipher_t *pwCipher, + UINT16 staRsnCap,UINT8 akmType) + +{ + pKeyMgmtInfo->keyMgmtState = MSG1_PENDING; + memcpy(&pKeyMgmtInfo->staSecType,secType,2); + memcpy(&pKeyMgmtInfo->staUcstCipher,pwCipher,1); + pKeyMgmtInfo->staAkmType = akmType; + if ((*(byte *)secType & 0x20) != 0) { + pKeyMgmtInfo->staRsnCap = staRsnCap; + } + return; +} + + + +apInfo_t * cm_GetApInfo(cm_ConnectionInfo_t *connPtr) + +{ + if (connPtr != (cm_ConnectionInfo_t *)0x0) { + if (connPtr->conType == '\x02') { + return *(apInfo_t **)connPtr->specDat; + } + connPtr = (cm_ConnectionInfo_t *)0x0; + } + return (apInfo_t *)connPtr; +} + + + +apSpecificData_t * cm_GetApData(cm_ConnectionInfo_t *connPtr) + +{ + if (connPtr != (cm_ConnectionInfo_t *)0x0) { + if (connPtr->conType == '\x02') { + return (apSpecificData_t *)connPtr->specDat; + } + connPtr = (cm_ConnectionInfo_t *)0x0; + } + return (apSpecificData_t *)connPtr; +} + + + +Status_e cm_AllocAPResources(cm_ConnectionInfo_t *connPtr) + +{ + apSpecificData_t *paVar1; + BufferDesc_t *pBVar2; + void *pvVar3; + + paVar1 = cm_GetApData(connPtr); + if (paVar1->apInfoBuffDesc == (BufferDesc_t *)0x0) { + pBVar2 = (BufferDesc_t *)pvPortMalloc(0xc); + if (pBVar2 == (BufferDesc_t *)0x0) { + return FAIL; + } + pvVar3 = pvPortMalloc(0x120); + pBVar2->Buffer = pvVar3; + paVar1->apInfoBuffDesc = pBVar2; + paVar1->apInfo = (apInfo_t *)pBVar2->Buffer; + InitializeAp(connPtr); + } + return FW_SUCCESS; +} + + + +Status_e cm_AllocResources(cm_ConnectionInfo_t *connPtr) + +{ + Status_e SVar1; + + if (connPtr->conType == '\x02') { + SVar1 = cm_AllocAPResources(connPtr); + return SVar1; + } + return FW_SUCCESS; +} + + + +cm_ConnectionInfo_t * +cm_InitConnection(UINT8 conType,UINT8 bssType,UINT8 bssNum,IEEEtypes_MacAddr_t *bssId, + IEEEtypes_MacAddr_t *peerMacAddr,UINT8 channel,unkbyte0 *hostMdev) + +{ + cm_ConnectionInfo_t *connPtr; + Status_e SVar1; + undefined3 extraout_var; + IEEEtypes_Addr_t *__s; + + connPtr = (cm_ConnectionInfo_t *)pvPortMalloc(0xec); + if (connPtr != (cm_ConnectionInfo_t *)0x0) { + memset(connPtr,0,0xec); + connPtr->conType = conType; + SVar1 = cm_AllocResources(connPtr); + if (CONCAT31(extraout_var,SVar1) == 1) { + vPortFree(connPtr); + connPtr = (cm_ConnectionInfo_t *)0x0; + } + else { + if (peerMacAddr != (IEEEtypes_MacAddr_t *)0x0) { + memcpy(connPtr->peerMacAddr,peerMacAddr,6); + } + __s = (connPtr->comData).BssId; + memset(__s,0,6); + memset(&connPtr->comData,0,0x20); + (connPtr->comData).SsIdLen = '\0'; + if (bssId != (IEEEtypes_MacAddr_t *)0x0) { + memcpy(__s,bssId,6); + memcpy(connPtr->localMacAddr,bssId,6); + } + } + } + return connPtr; +} + + + +void cm_DeleteConnection(cm_ConnectionInfo_t *connPtr) + +{ + apSpecificData_t *paVar1; + + if (connPtr->conType == '\x02') { + paVar1 = cm_GetApData(connPtr); + if (paVar1->apInfoBuffDesc != (BufferDesc_t *)0x0) { + vPortFree(paVar1->apInfoBuffDesc->Buffer); + vPortFree(paVar1->apInfoBuffDesc); + paVar1->apInfoBuffDesc = (BufferDesc_t *)0x0; + paVar1->apInfo = (apInfo_t *)0x0; + } + } + vPortFree(connPtr); + return; +} + + + +void cm_SetPeerAddr(cm_ConnectionInfo_t *connPtr,IEEEtypes_MacAddr_t *bssId, + IEEEtypes_MacAddr_t *peerMacAddr) + +{ + if (bssId != (IEEEtypes_MacAddr_t *)0x0) { + memcpy((connPtr->comData).BssId,bssId,6); + } + if (peerMacAddr != (IEEEtypes_MacAddr_t *)0x0) { + memcpy(connPtr->peerMacAddr,peerMacAddr,6); + return; + } + return; +} + + + +void cm_SetComData(cm_ConnectionInfo_t *connPtr,char *ssid) + +{ + byte bVar1; + size_t sVar2; + + if (ssid != (char *)0x0) { + sVar2 = strlen(ssid); + (connPtr->comData).SsIdLen = (IEEEtypes_Len_t)sVar2; + memcpy(&connPtr->comData,ssid,0x20); + bVar1 = (connPtr->comData).SsIdLen; + if (bVar1 < 0x20) { + (connPtr->comData).SsId[bVar1] = '\0'; + } + return; + } + return; +} + + + +void rf_set_channel(uint8_t bandwidth,uint16_t channel_freq) + +{ + undefined2 in_register_0000202e; + + rfc_config_channel(CONCAT22(in_register_0000202e,channel_freq)); + return; +} + + + +void rf_dump_status(void) + +{ + return; +} + + + +int bl60x_check_mac_status(int *is_ok) + +{ + int iVar1; + dump_data_t *pdVar2; + + iVar1 = 0; + pdVar2 = dump_data_poll; + while( true ) { + if ((int)(uint)dump_data_ptr <= iVar1) { + *is_ok = 0; + return 0; + } + if (pdVar2->mac_debugRegHWSM2 != 0x8801e000) break; + iVar1 = iVar1 + 1; + pdVar2 = pdVar2 + 1; + } + *is_ok = 1; + return 0; +} + + + +void helper_record_dump(void) + +{ + uint32_t *puVar1; + dump_data_t *pdVar2; + int iVar3; + + pdVar2 = dump_data_poll; + puts("========= helper_record_dump\r\n"); + iVar3 = 0; + while (iVar3 < (int)(uint)dump_data_ptr) { + printf("[%d] time %ld, func %s\r\n",iVar3,pdVar2->time,pdVar2->func_name); + printf("MAC: %08lx: rxControlCs %d,txControlCs %d,macControlCs %d\r\n",pdVar2->mac_debugRegHWSM2 + ,pdVar2->mac_debugRegHWSM2 & 0x3f,pdVar2->mac_debugRegHWSM2 >> 8 & 0x1ff, + (uint)*(byte *)((int)&pdVar2->mac_debugRegHWSM2 + 3)); + iVar3 = iVar3 + 1; + printf("MAC: Coex %04x,Backoff %04x,MPIF %04x,MPIF2 %04x\r\n",(uint)pdVar2->mac_debugPortCoex, + (uint)pdVar2->mac_debugPortBackoff,(uint)pdVar2->mac_debugPortMacPhyIf, + (uint)pdVar2->mac_debugPortMacPhyIf2); + printf("PHY: MainFSM %04x,TDTX %04x,DSSSCCK1 %04x,DSSSCCKTx %04x\r\n", + (uint)pdVar2->phy_debugPortMainFSM,(uint)pdVar2->phy_debugPortTDTX, + (uint)pdVar2->phy_debugPortDSSSCCK1,(uint)pdVar2->phy_debugPortDSSSCCKTx); + puVar1 = &pdVar2->rf_state; + pdVar2 = pdVar2 + 1; + printf("RFC: RC %s, RF %s\r\n",rf_state_str[*puVar1]); + } + printf("\r\n\r\n"); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void helper_record_rc_rf_states(uint *param_1,uint *param_2) + +{ + uint uVar1; + + _DAT_40001220 = _DAT_40001220 & 0xfffffff | 0x20000000; + uVar1 = _DAT_40001224 >> 0x19; + *param_1 = _DAT_40001224 >> 0x1c & 7; + *param_2 = uVar1 & 7; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void helper_record_all_states(char *func_name) + +{ + uint32_t uVar1; + uint uVar2; + uint uVar3; + uint uVar4; + + uVar1 = _DAT_44b00120; + uVar4 = (uint)dump_data_ptr; + dump_data_poll[uVar4].func_name = func_name; + dump_data_poll[uVar4].time = uVar1; + helper_record_rc_rf_states(uVar4 * 0x28 + 0x42012ec0,uVar4 * 0x28 + 0x42012ec4); + dump_data_poll[uVar4].mac_debugRegHWSM1 = _DAT_44b00500; + dump_data_poll[uVar4].mac_debugRegHWSM2 = _DAT_44b00504; + _DAT_44b00510 = _DAT_44b00510 & 0xffff0000 | 0x31; + *(undefined4 *)&dump_data_poll[uVar4].mac_debugPortCoex = _DAT_44b0050c; + _DAT_44b00510 = _DAT_44b00510 & 0xffff0000 | 0x2f0b; + *(undefined4 *)&dump_data_poll[uVar4].mac_debugPortMacPhyIf = _DAT_44b0050c; + _DAT_44900068 = _DAT_44900068 & 0xffff0000 | 0x14; + _DAT_400000d0 = 4; + _DAT_400000d4 = 0x40000004; + _DAT_400000d8 = 0x80000004; + _DAT_400000dc = 0xc0000004; + uVar2 = _DAT_400000e0 & 0xfffffffe; + uVar3 = _DAT_400000e0 >> 1; + _DAT_400000e0 = uVar2; + dump_data_poll[uVar4].phy_debugPortTDTX = (uint16_t)uVar3; + dump_data_poll[uVar4].phy_debugPortMainFSM = (ushort)(uVar2 >> 0x11); + _DAT_44900074 = 0xb09; + uVar2 = _DAT_400000e0 & 0xfffffffe; + uVar3 = _DAT_400000e0 >> 1; + _DAT_400000e0 = uVar2; + dump_data_poll[uVar4].phy_debugPortDSSSCCK1 = (uint16_t)uVar3; + dump_data_poll[uVar4].phy_debugPortDSSSCCKTx = (ushort)(uVar2 >> 0x11); + dump_data_ptr = dump_data_ptr + 1 & 0xf; + return; +} + + + +int phyif_utils_decode(phyif_utils_recvtable_t *vec,int8_t *ppm) + +{ + char cVar1; + int8_t iVar2; + SItype SVar3; + + cVar1 = *(char *)((int)&vec->recvtable5 + 3); + if (((*(ushort *)((int)&vec->recvtable2 + 2) & 7) < 2) && ((vec->recvtable1 >> 0xc & 0xf) < 4)) { + __floatsidf(-(int)cVar1); + __muldf3(); + SVar3 = __fixdfsi(); + iVar2 = (int8_t)SVar3; + } + else { + iVar2 = (int8_t)((int)CONCAT11(*(undefined *)&vec->recvtable6,cVar1) / 0x7a); + } + *ppm = iVar2; + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_pwr_mgt_setf(uint8_t pwrmgt) + +{ + uint uVar1; + undefined3 in_register_00002029; + + uVar1 = CONCAT31(in_register_00002029,pwrmgt) << 2; + if ((uVar1 & 0xfffffffb) != 0) { + assert_err("(((uint32_t)pwrmgt << 2) & ~((uint32_t)0x00000004)) == 0","module",0x952); + } + _DAT_44b0004c = _DAT_44b0004c & 0xfffffffb | uVar1; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +chan_ctxt_tag * chan_get_next_chan(void) + +{ + int iVar1; + int iVar2; + chan_ctxt_tag *pcVar3; + uint uVar4; + ushort uVar5; + + iVar2 = _DAT_44b00120; + iVar1 = DAT_42022d20; + if (DAT_42022d30 != (chan_ctxt_tag *)0x0) { + if ((DAT_42022d20 != 0) && (*(char *)(DAT_42022d20 + 10) == '\x02')) { + return DAT_42022d30; + } + if (-1 < (_DAT_44b00120 + 0x1400) - DAT_42022d54) { + return DAT_42022d30; + } + if (DAT_42022d30->status == '\x04') { + return DAT_42022d30; + } + } + pcVar3 = DAT_42022d30; + if ((DAT_42022d20 != 0) && (*(int *)(DAT_42022d20 + 4) - DAT_42022d54 < 0)) { + pcVar3 = vif_info_tab[*(byte *)(DAT_42022d20 + 8)].chan_ctxt; + if (pcVar3 == (chan_ctxt_tag *)0x0) { + assert_err("p_next_chan_entry","module",0x129); + } + if (-1 < (iVar2 + 0x1400) - *(int *)(iVar1 + 4)) goto LAB_2301998c; + uVar4 = 0; + if (pcVar3->nb_res_slots < pcVar3->nb_rem_slots) { + uVar4 = (uint)(ushort)(pcVar3->nb_rem_slots - pcVar3->nb_res_slots); + } + if (((uint)(*(int *)(iVar1 + 4) - iVar2) >> 10 & 0xffff) <= uVar4) { + return pcVar3; + } + } + uVar5 = 0; + if (chan_ctxt_pool[0].status != '\0') { + pcVar3 = chan_ctxt_pool; + uVar5 = chan_ctxt_pool[0].nb_rem_slots; + } + if ((chan_ctxt_pool[1].status != '\0') && (uVar5 <= chan_ctxt_pool[1].nb_rem_slots)) { + pcVar3 = chan_ctxt_pool + 1; + uVar5 = chan_ctxt_pool[1].nb_rem_slots; + } + if ((chan_ctxt_pool[2].status != '\0') && (uVar5 <= chan_ctxt_pool[2].nb_rem_slots)) { + return chan_ctxt_pool + 2; + } +LAB_2301998c: + if (pcVar3 == (chan_ctxt_tag *)0x0) { + assert_err("p_next_chan_entry","module",0x175); + } + return pcVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void chan_conn_less_delay_prog(void) + +{ + DAT_42022d80 = DAT_42022d80 | 0x10; + mm_timer_set((mm_timer_tag *)&DAT_42022d68,_DAT_44b00120 + 30000); + return; +} + + + +void chan_upd_nb_rem_slots(uint32_t current_time) + +{ + ushort uVar1; + ushort uVar2; + int in_a1; + uint uVar3; + + uVar1 = *(ushort *)current_time; + uVar3 = (uint)(in_a1 - DAT_42022d7c) >> 10 & 0xffff; + uVar2 = (ushort)uVar3; + if (uVar1 < uVar3) { + uVar2 = uVar1; + } + *(ushort *)current_time = uVar1 - uVar2; + return; +} + + + +_Bool chan_tbtt_detect_conflict(void) + +{ + byte bVar1; + int in_a0; + int in_a1; + + if (((in_a0 - in_a1 < 0) || (bVar1 = 1, (in_a1 + 0x2800) - in_a0 < 0)) && + (bVar1 = 0, -1 < in_a1 - in_a0)) { + bVar1 = ~(byte)((uint)((in_a0 - in_a1) + 0x2800) >> 0x18) >> 7; + } + return (_Bool)bVar1; +} + + + +void chan_tbtt_insert(chan_tbtt_tag *p_tbtt_entry) + +{ + bool bVar1; + co_list_hdr list_hdr; + char cVar2; + _Bool _Var3; + undefined3 extraout_var; + undefined3 extraout_var_00; + co_list_hdr cVar4; + uint uVar5; + uint uVar6; + co_list_hdr prev_element; + co_list_hdr cVar7; + + list_hdr = (co_list_hdr)0x0; + cVar2 = '\0'; + cVar4 = DAT_42022d20; + prev_element = (co_list_hdr)0x0; + while (cVar4 != (co_list_hdr)0x0) { + if (cVar4 == (co_list_hdr)p_tbtt_entry) { + assert_err("p_elem != p_tbtt_entry","module",0x668); + } + uVar5 = p_tbtt_entry->time; + uVar6 = *(uint *)((int)cVar4 + 4); + cVar7 = cVar4; + if (*(char *)((int)cVar4 + 10) == '\x02') { + if ((uVar5 < uVar6) || + (_Var3 = chan_tbtt_detect_conflict(), CONCAT31(extraout_var_00,_Var3) != 0)) { +LAB_23019afc: + cVar2 = '\x01'; + bVar1 = false; + list_hdr = (co_list_hdr)p_tbtt_entry; + goto LAB_23019b44; + } + } + else { + _Var3 = chan_tbtt_detect_conflict(); + if (CONCAT31(extraout_var,_Var3) == 0) { + if (uVar5 < uVar6) break; + } + else { + if (p_tbtt_entry->priority <= *(byte *)((int)cVar4 + 9)) goto LAB_23019afc; + if (list_hdr == (co_list_hdr)0x0) { + list_hdr = cVar4; + } + cVar2 = cVar2 + '\x01'; + cVar7 = prev_element; + } + } + cVar4 = *(co_list_hdr *)cVar4; + prev_element = cVar7; + } + bVar1 = true; +LAB_23019b44: + while (cVar2 = cVar2 + -1, cVar2 != -1) { + if (list_hdr == (co_list_hdr)0x0) { + assert_err("p_delay_elem","module",0x6b1); + } + if (list_hdr != (co_list_hdr)p_tbtt_entry) { + if (*(char *)((int)list_hdr + 10) == '\x01') { + mm_timer_clear((mm_timer_tag *)&DAT_42022d38); + *(undefined *)((int)list_hdr + 10) = 0; + } + co_list_extract((co_list *)&DAT_42022d20,(co_list_hdr *)list_hdr); + } + co_list_push_back((co_list *)&DAT_42022d28,(co_list_hdr *)list_hdr); + list_hdr = *(co_list_hdr *)list_hdr; + } + if (!bVar1) { + return; + } + co_list_insert_after + ((co_list *)&DAT_42022d20,(co_list_hdr *)prev_element,(co_list_hdr *)p_tbtt_entry); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void chan_upd_ctxt_status(chan_ctxt_tag *p_chan_entry,uint8_t next_status) + +{ + undefined3 in_register_0000202d; + int iVar1; + ushort uVar2; + int iVar3; + uint32_t value; + + iVar1 = CONCAT31(in_register_0000202d,next_status); + if (iVar1 == 2) { + value = 0; + if (2 < p_chan_entry->idx) goto LAB_23019bbc; + iVar3 = 4000; + } + else { + value = 0; + if (iVar1 != 4) goto LAB_23019bbc; + if (p_chan_entry->idx < 3) { + if (1 < DAT_42022d82) { + if ((p_chan_entry->nb_res_slots < p_chan_entry->nb_rem_slots) && + (uVar2 = p_chan_entry->nb_rem_slots - p_chan_entry->nb_res_slots, 4 < uVar2)) { + iVar3 = (uint)uVar2 << 10; + DAT_42022d7c = _DAT_44b00120; + goto LAB_23019bba; + } + } + iVar1 = 5; + value = 0; + goto LAB_23019bbc; + } + iVar3 = (uint)p_chan_entry->nb_rem_slots << 10; + } +LAB_23019bba: + value = iVar3 + _DAT_44b00120; +LAB_23019bbc: + p_chan_entry->status = (uint8_t)iVar1; + if (value != 0) { + DAT_42022d60 = p_chan_entry; + mm_timer_set((mm_timer_tag *)&DAT_42022d58,value); + return; + } + if (iVar1 != 3) { + mm_timer_clear((mm_timer_tag *)&DAT_42022d58); + return; + } + return; +} + + + +void chan_switch_start(chan_ctxt_tag *p_chan_entry) + +{ + undefined4 *puVar1; + + if (DAT_42022d30 == p_chan_entry) { + if ((1 < DAT_42022d82) && (DAT_42022d30->idx < 3)) { + chan_upd_ctxt_status(p_chan_entry,'\x04'); + return; + } + } + else { + if (DAT_42022d34 == (chan_ctxt_tag *)0x0) { + DAT_42022d34 = p_chan_entry; + chan_upd_ctxt_status(p_chan_entry,'\x02'); + puVar1 = (undefined4 *)ke_msg_alloc(0x60,0,0xff,4); + *puVar1 = 0x2301a284; + ke_msg_send(); + return; + } + } + return; +} + + + +void chan_conn_less_delay_evt(void *env) + +{ + chan_ctxt_tag *p_chan_entry; + + if ((DAT_42022d80 & 1) == 0) { + if ((DAT_42022d80 & 2) == 0) { + return; + } + if ((DAT_42022d80 & 8) != 0) { + assert_err("(chan_env.status & CO_BIT(CHAN_ENV_SCAN_BIT)) == 0","module",0x2ce); + } + p_chan_entry = chan_ctxt_pool + 3; + DAT_42022d80 = DAT_42022d80 & 0xfd | 8; + } + else { + if ((DAT_42022d80 & 4) != 0) { + assert_err("(chan_env.status & CO_BIT(CHAN_ENV_ROC_BIT)) == 0","module",0x2c0); + } + p_chan_entry = chan_ctxt_pool + 4; + DAT_42022d80 = DAT_42022d80 & 0xfe | 4; + } + if (DAT_42022d34 != 0) { + return; + } + chan_switch_start(p_chan_entry); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void chan_tbtt_switch_evt(void *env) + +{ + ushort uVar1; + undefined4 uVar2; + ushort uVar3; + chan_ctxt_tag *p_chan_entry; + + uVar2 = _DAT_44b00120; + if ((1 < DAT_42022d82) && ((DAT_42022d80 & 0xc) == 0)) { + p_chan_entry = vif_info_tab[*(byte *)((int)env + 8)].chan_ctxt; + if ((DAT_42022d34 == (chan_ctxt_tag *)0x0) || (DAT_42022d34 == p_chan_entry)) { + *(undefined *)((int)env + 9) = 0; + chan_upd_nb_rem_slots(DAT_42022d30 + 0x12); + uVar1 = p_chan_entry->nb_res_slots; + uVar3 = uVar1; + if (10 < uVar1) { + uVar3 = 10; + } + p_chan_entry->nb_res_slots = uVar1 - uVar3; + DAT_42022d7c = uVar2; + *(undefined *)((int)env + 10) = 2; + if (DAT_42022d34 == (chan_ctxt_tag *)0x0) { + chan_switch_start(p_chan_entry); + return; + } + } + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void chan_tbtt_schedule(chan_tbtt_tag *p_tbtt_entry) + +{ + void *pvVar1; + chan_tbtt_tag *p_tbtt_entry_00; + uint uVar2; + uint32_t uVar3; + + if (p_tbtt_entry != (chan_tbtt_tag *)0x0) { + chan_tbtt_insert(p_tbtt_entry); + while (DAT_42022d28 != 0) { + p_tbtt_entry_00 = (chan_tbtt_tag *)co_list_pop_front((co_list *)&DAT_42022d28); + uVar2 = (uint)p_tbtt_entry_00->vif_index; + if (vif_info_tab[uVar2].type == '\0') { + uVar3 = sta_info_tab[vif_info_tab[uVar2].u[4]].bcn_int; + } + else { + uVar3 = (uint)*(ushort *)(vif_info_tab[uVar2].u + 0x2e2) << 10; + } + p_tbtt_entry_00->time = uVar3 + p_tbtt_entry_00->time; + if (p_tbtt_entry_00->priority < 5) { + p_tbtt_entry_00->priority = p_tbtt_entry_00->priority + 1; + } + chan_tbtt_insert(p_tbtt_entry_00); + } + } + pvVar1 = DAT_42022d20; + if ((DAT_42022d20 != (void *)0x0) && (*(char *)((int)DAT_42022d20 + 10) == '\0')) { + if ((*(int *)((int)DAT_42022d20 + 4) - _DAT_44b00120) + -2000 < 0) { + chan_tbtt_switch_evt(DAT_42022d20); + return; + } + DAT_42022d40 = DAT_42022d20; + *(undefined *)((int)DAT_42022d20 + 10) = 1; + mm_timer_set((mm_timer_tag *)&DAT_42022d38,*(uint32_t *)((int)pvVar1 + 4)); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void chan_cde_evt(void *env) + +{ + int iVar1; + uint uVar2; + int iVar3; + chan_ctxt_tag *p_chan_entry; + int iVar4; + co_list_hdr *pcVar5; + co_list_hdr cVar6; + undefined2 uVar7; + ushort uVar8; + uint uVar9; + + iVar4 = _DAT_44b00120; + p_chan_entry = DAT_42022d34; + if ((1 < DAT_42022d82) && (uVar2 = (uint)DAT_42022d80 & 0x2c, (DAT_42022d80 & 0x2c) == 0)) { + mm_timer_set((mm_timer_tag *)&DAT_42022d48,DAT_42022d78 + _DAT_44b00120); + DAT_42022d7c = iVar4; + uVar9 = 0; + cVar6 = (co_list_hdr)vif_mgmt_env.used_list.first; + while (cVar6 != (co_list_hdr)0x0) { + pcVar5 = ((co_list_hdr *)((int)cVar6 + 0x40))->next; + if (pcVar5 != (co_list_hdr *)0x0) { + uVar2 = uVar2 + 1 & 0xff; + if (((td_env[*(byte *)((int)cVar6 + 0x57)].status & 3) != 0) || + (*(char *)&((co_list_hdr *)((int)cVar6 + 0x58))->next == '\0')) { + uVar9 = uVar9 + 1 & 0xff; + } + *(undefined2 *)&pcVar5[4].next = 0; + *(undefined2 *)&pcVar5[5].next = 0; + } + cVar6 = *(co_list_hdr *)cVar6; + } + if (uVar2 != DAT_42022d78 / 0xc800) { + assert_warn("nb_vifs == (chan_env.cde_dur_us / (CHAN_VIF_NB_SLOTS * CHAN_SLOT_DURATION_US))", + "module",0x268); + } + if ((uVar9 == 0) || (uVar2 == uVar9)) { + iVar3 = 0; + iVar4 = 0x32; + } + else { + iVar4 = 10; + iVar3 = (int)((uVar2 - uVar9) * 0x280000 >> 0x10) / (int)uVar9; + } + cVar6 = (co_list_hdr)vif_mgmt_env.used_list.first; + while (cVar6 != (co_list_hdr)0x0) { + pcVar5 = ((co_list_hdr *)((int)cVar6 + 0x40))->next; + if (pcVar5 != (co_list_hdr *)0x0) { + if (((td_env[*(byte *)((int)cVar6 + 0x57)].status & 3) != 0) || + (iVar1 = iVar4, *(char *)&((co_list_hdr *)((int)cVar6 + 0x58))->next == '\0')) { + iVar1 = iVar3 + 0x32; + } + uVar7 = (undefined2)(((uint)*(ushort *)&pcVar5[4].next + iVar1) * 0x10000 >> 0x10); + *(undefined2 *)&pcVar5[4].next = uVar7; + *(undefined2 *)((int)&pcVar5[4].next + 2) = uVar7; + if (*(char *)((int)cVar6 + 0x56) == '\0') { + uVar2 = sta_info_tab[*(byte *)&((co_list_hdr *)((int)cVar6 + 0x60))->next].bcn_int; + } + else { + uVar2 = (uint)*(ushort *)((int)cVar6 + 0x33e) << 10; + } + uVar8 = (ushort)(DAT_42022d78 / uVar2); + if (DAT_42022d78 / uVar2 == 0) { + uVar8 = 1; + } + *(ushort *)&pcVar5[5].next = (uVar8 & 0xff) * 10 + *(short *)&pcVar5[5].next; + } + cVar6 = *(co_list_hdr *)cVar6; + } + if (DAT_42022d30 != (chan_ctxt_tag *)0x0) { + chan_upd_ctxt_status(DAT_42022d30,'\x01'); + } + p_chan_entry = chan_get_next_chan(); + if (env == (void *)0x0) { + chan_switch_start(p_chan_entry); + return; + } + } + DAT_42022d34 = p_chan_entry; + return; +} + + +/* +Unable to decompile 'chan_pre_switch_channel' +Cause: Exception while decompiling 2301a090: Decompiler process died + +*/ + + +void chan_goto_idle_cb(void) + +{ + undefined uVar1; + co_list_hdr *pcVar2; + co_list_hdr cVar3; + uint8_t uVar4; + undefined3 extraout_var; + int iVar5; + + mm_force_idle_req(); + pcVar2 = DAT_42022d30; + cVar3 = (co_list_hdr)vif_mgmt_env.used_list.first; + if (((DAT_42022d30 != (co_list_hdr *)0x0) && ((DAT_42022d80 & 0x20) == 0)) && + ((ps_env.ps_on == false || ((ps_env.prevent_sleep & 8) != 0)))) { + iVar5 = 0; + blmac_pwr_mgt_setf('\x01'); + while (cVar3 != (co_list_hdr)0x0) { + if ((((pcVar2 == ((co_list_hdr *)((int)cVar3 + 0x40))->next) && + (*(char *)((int)cVar3 + 0x56) == '\0')) && + (*(char *)&((co_list_hdr *)((int)cVar3 + 0x58))->next != '\0')) && + (*(char *)&((co_list_hdr *)((int)cVar3 + 0x60))->next != -1)) { + uVar1 = *(undefined *)((int)&pcVar2[5].next + 2); + *(undefined *)((int)&pcVar2[5].next + 2) = 6; + uVar4 = txl_frame_send_null_frame + (*(uint8_t *)&((co_list_hdr *)((int)cVar3 + 0x60))->next,chan_tx_cfm, + (void *)0x0); + if (CONCAT31(extraout_var,uVar4) == 0) { + iVar5 = iVar5 + 1; + } + *(undefined *)((int)&pcVar2[5].next + 2) = uVar1; + } + cVar3 = *(co_list_hdr *)cVar3; + } + DAT_42022d81 = (undefined)iVar5; + if (iVar5 != 0) { + chan_upd_ctxt_status(DAT_42022d34,'\x03'); + mm_active(); + return; + } + } + chan_pre_switch_channel(); + return; +} + + + +void chan_tx_cfm(void *dummy,uint32_t status) + +{ + if (DAT_42022d81 == '\0') { + assert_err("chan_env.cfm_cnt","module",0x48f); + } + DAT_42022d81 = DAT_42022d81 + -1; + if (DAT_42022d81 == '\0') { + mm_force_idle_req(); + chan_pre_switch_channel(); + return; + } + return; +} + + +/* +Unable to decompile 'chan_ctxt_op_evt' +Cause: Exception while decompiling 2301a3bc: Decompiler process died + +*/ + + +void chan_init(void) + +{ + chan_ctxt_tag *__s; + int iVar1; + + __s = chan_ctxt_pool; + memset(&chan_env,0,0x74); + iVar1 = 0; + do { + memset(__s,0,0x1c); + *(undefined2 *)(&__s->channel + 1) = 0xff; + *(undefined *)((int)&__s->nb_res_slots + 3) = 0xff; + if (iVar1 < 3) { + co_list_push_back((co_list *)&chan_env,(co_list_hdr *)__s); + } + else { + if (iVar1 == 3) { + chan_ctxt_pool[3].channel.center2_freq = 0; + chan_ctxt_pool[3].channel.type = '\0'; + } + } + iVar1 = iVar1 + 1; + __s = __s + 1; + } while (iVar1 != 5); + DAT_42022d3c = chan_tbtt_switch_evt; + DAT_42022d4c = chan_cde_evt; + DAT_42022d50 = 0; + DAT_42022d5c = chan_ctxt_op_evt; + DAT_42022d6c = chan_conn_less_delay_evt; + return; +} + + + +void chan_scan_req(uint8_t band,uint16_t freq,int8_t pwr,uint32_t duration_us,uint8_t vif_index) + +{ + if (chan_ctxt_pool[3].idx != -1) { + assert_err("p_scan_chan->idx == CHAN_CTXT_UNUSED","module",0x8a1); + } + chan_ctxt_pool[3].taskid = 0xff; + chan_ctxt_pool[3]._22_2_ = 0x301; + chan_ctxt_pool[3].nb_rem_slots = (uint16_t)(duration_us >> 10); + if ((DAT_42022d80 & 0x10) == 0) { + chan_ctxt_pool[3].channel.band = band; + chan_ctxt_pool[3].channel.prim20_freq = freq; + chan_ctxt_pool[3].channel.center1_freq = freq; + chan_ctxt_pool[3].channel.tx_power = pwr; + chan_ctxt_pool[3].vif_index = vif_index; + DAT_42022d80 = DAT_42022d80 | 2; + chan_conn_less_delay_prog(); + return; + } + chan_ctxt_pool[3].channel.band = band; + chan_ctxt_pool[3].channel.prim20_freq = freq; + chan_ctxt_pool[3].channel.center1_freq = freq; + chan_ctxt_pool[3].channel.tx_power = pwr; + chan_ctxt_pool[3].taskid = 0xff; + chan_ctxt_pool[3]._22_2_ = 0x301; + chan_ctxt_pool[3].vif_index = vif_index; + DAT_42022d80 = DAT_42022d80 | 2; + return; +} + + + +uint8_t chan_roc_req(mm_remain_on_channel_req *req,ke_task_id_t taskid) + +{ + byte bVar1; + undefined2 in_register_0000202e; + + if (req->op_code == '\0') { + if (chan_ctxt_pool[4].idx == -1) { + chan_ctxt_pool[4].idx = '\x04'; + chan_ctxt_pool[4].channel.band = req->band; + chan_ctxt_pool[4].channel.type = req->type; + chan_ctxt_pool[4].channel.prim20_freq = req->prim20_freq; + chan_ctxt_pool[4].channel.center1_freq = req->center1_freq; + chan_ctxt_pool[4].channel.center2_freq = req->center2_freq; + chan_ctxt_pool[4].status = '\x01'; + chan_ctxt_pool[4].nb_rem_slots = (uint16_t)(req->duration_ms * 1000 >> 10); + chan_ctxt_pool[4].vif_index = req->vif_index; + chan_ctxt_pool[4].channel.tx_power = req->tx_power; + chan_ctxt_pool[4].taskid = taskid; + if (CONCAT22(in_register_0000202e,taskid) != 0) { + bVar1 = DAT_42022d80 & 0x10; + if ((DAT_42022d80 & 0x10) != 0) { + chan_ctxt_pool[4].status = '\x01'; + chan_ctxt_pool[4].idx = '\x04'; + DAT_42022d80 = DAT_42022d80 | 1; + return '\0'; + } + DAT_42022d80 = DAT_42022d80 | 1; + chan_conn_less_delay_prog(); + return bVar1; + } + DAT_42022d80 = DAT_42022d80 | 4; + if (DAT_42022d34 != 0) { + chan_ctxt_pool[4].status = '\x01'; + chan_ctxt_pool[4].idx = '\x04'; + return '\0'; + } + chan_switch_start(chan_ctxt_pool + 4); + return '\0'; + } + } + else { + if (req->op_code == '\x01') { + if (chan_ctxt_pool[4].idx != -1) { + if (chan_ctxt_pool[4].status < 4) { + if (chan_ctxt_pool[4].status < 2) { + if (chan_ctxt_pool[4].status == '\x01') { + DAT_42022d80 = DAT_42022d80 & 0xfe; + } + } + else { + DAT_42022d34 = 0; + DAT_42022d80 = DAT_42022d80 & 0xfb; + } + } + else { + if (chan_ctxt_pool[4].status == '\x04') { + mm_timer_clear((mm_timer_tag *)&DAT_42022d58); + chan_ctxt_op_evt(chan_ctxt_pool + 4); + } + } + chan_ctxt_pool[4].idx = -1; + if ((DAT_42022d80 & 0x12) == 0x10) { + DAT_42022d80 = DAT_42022d80 & 0xef; + mm_timer_clear((mm_timer_tag *)&DAT_42022d68); + DAT_42022d80 = DAT_42022d80 & 0xef; + } + } + return '\0'; + } + } + return '\x01'; +} + + + +uint8_t chan_ctxt_add(mm_chan_ctxt_add_req *p_add_req,uint8_t *idx) + +{ + uint8_t uVar1; + int iVar2; + co_list_hdr *pcVar3; + int iVar4; + chan_ctxt_tag *pcVar5; + + pcVar5 = chan_ctxt_pool; + iVar4 = 0; + do { + if (pcVar5->idx != -1) { + iVar2 = memcmp(p_add_req,&pcVar5->channel,8); + if (iVar2 == 0) { + *idx = (uint8_t)iVar4; + return (uint8_t)iVar2; + } + } + iVar4 = iVar4 + 1; + pcVar5 = pcVar5 + 1; + } while (iVar4 != 3); + pcVar3 = co_list_pop_front((co_list *)&chan_env); + if (pcVar3 != (co_list_hdr *)0x0) { + uVar1 = (char)((int)(pcVar3 + -0x10808b21) >> 2) * -0x49; + *(uint8_t *)((int)&pcVar3[5].next + 3) = uVar1; + *idx = uVar1; + *(uint8_t *)&pcVar3[1].next = p_add_req->band; + *(uint8_t *)((int)&pcVar3[1].next + 1) = p_add_req->type; + *(uint16_t *)&pcVar3[2].next = p_add_req->center1_freq; + *(uint16_t *)((int)&pcVar3[2].next + 2) = p_add_req->center2_freq; + *(uint16_t *)((int)&pcVar3[1].next + 2) = p_add_req->prim20_freq; + *(int8_t *)&pcVar3[3].next = p_add_req->tx_power; + } + return (uint8_t)(pcVar3 == (co_list_hdr *)0x0); +} + + + +void chan_ctxt_del(uint8_t chan_idx) + +{ + undefined3 in_register_00002029; + int iVar1; + + iVar1 = CONCAT31(in_register_00002029,chan_idx); + if (chan_ctxt_pool[iVar1].idx == -1) { + assert_err("p_chan_entry->idx != CHAN_CTXT_UNUSED","module",0x989); + } + if (chan_ctxt_pool[iVar1].nb_linked_vif != '\0') { + assert_err("p_chan_entry->nb_linked_vif == 0","module",0x98b); + } + co_list_push_back((co_list *)&chan_env,(co_list_hdr *)(chan_ctxt_pool + iVar1)); + memset(chan_ctxt_pool + iVar1,0,0x1c); + chan_ctxt_pool[iVar1].taskid = 0xff; + chan_ctxt_pool[iVar1].idx = -1; + return; +} + + +/* +Unable to decompile 'chan_ctxt_update' +Cause: Exception while decompiling 2301a95a: Decompiler process died + +*/ + + +void chan_tbtt_switch_update(vif_info_tag *p_vif_entry,uint32_t tbtt_time) + +{ + if ((((p_vif_entry->chan_ctxt != (chan_ctxt_tag *)0x0) && (p_vif_entry->chan_ctxt->status != '\0') + ) && ((p_vif_entry->tbtt_switch).time != tbtt_time - 0x9c4)) && + (((p_vif_entry->tbtt_switch).time = tbtt_time - 0x9c4, 1 < DAT_42022d82 && + ((p_vif_entry->tbtt_switch).status != '\x02')))) { + (p_vif_entry->tbtt_switch).status = '\0'; + co_list_extract((co_list *)&DAT_42022d20,(co_list_hdr *)&p_vif_entry->tbtt_switch); + chan_tbtt_schedule(&p_vif_entry->tbtt_switch); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void chan_bcn_to_evt(vif_info_tag *p_vif_entry) + +{ + ushort uVar1; + int iVar2; + chan_ctxt_tag *p_chan_entry; + ushort uVar3; + uint uVar4; + + iVar2 = _DAT_44b00120; + if ((p_vif_entry->tbtt_switch).status == '\x02') { + (p_vif_entry->tbtt_switch).status = '\0'; + p_chan_entry = DAT_42022d30; + co_list_extract((co_list *)&DAT_42022d20,(co_list_hdr *)&p_vif_entry->tbtt_switch); + if (((1 < DAT_42022d82) && + (chan_tbtt_schedule(&p_vif_entry->tbtt_switch), (DAT_42022d80 & 0xc) == 0)) && + (DAT_42022d34 == 0)) { + chan_upd_nb_rem_slots((uint32_t)&p_chan_entry->nb_rem_slots); + uVar1 = p_chan_entry->nb_res_slots; + if (uVar1 != 0) { + uVar4 = (uint)(iVar2 - DAT_42022d7c) >> 10 & 0xffff; + uVar3 = (ushort)uVar4; + if (uVar1 < uVar4) { + uVar3 = uVar1; + } + p_chan_entry->nb_res_slots = uVar1 - uVar3; + } + DAT_42022d7c = iVar2; + p_chan_entry = chan_get_next_chan(); + if (DAT_42022d30 != p_chan_entry) { + chan_switch_start(p_chan_entry); + return; + } + } + } + return; +} + + + +void chan_bcn_detect_start(vif_info_tag *p_vif_entry) + +{ + byte bVar1; + chan_ctxt_tag *pcVar2; + undefined *puVar3; + + pcVar2 = p_vif_entry->chan_ctxt; + if (pcVar2 == (chan_ctxt_tag *)0x0) { + assert_err("p_chan_entry","module",0xb19); + } + if (((DAT_42022d80 & 0x40) == 0) && (1 < DAT_42022d82)) { + bVar1 = p_vif_entry->u[4]; + puVar3 = (undefined *)ke_msg_alloc(0x46,0,0,0x14); + *puVar3 = 0; + puVar3[1] = p_vif_entry->index; + puVar3[2] = (pcVar2->channel).band; + puVar3[3] = (pcVar2->channel).type; + *(uint16_t *)(puVar3 + 4) = (pcVar2->channel).prim20_freq; + *(uint16_t *)(puVar3 + 6) = (pcVar2->channel).center1_freq; + *(uint16_t *)(puVar3 + 8) = (pcVar2->channel).center2_freq; + *(uint *)(puVar3 + 0xc) = (sta_info_tab[bVar1].bcn_int - 5000) / 1000; + puVar3[0x10] = (pcVar2->channel).tx_power; + ke_msg_send(); + DAT_42022d80 = DAT_42022d80 | 0x40; + } + return; +} + + + +_Bool chan_is_on_channel(vif_info_tag *p_vif_entry) + +{ + chan_ctxt_tag *pcVar1; + + if (DAT_42022d30 != 0) { + if (*(byte *)(DAT_42022d30 + 0x17) < 3) { + pcVar1 = (chan_ctxt_tag *)((int)p_vif_entry->chan_ctxt - DAT_42022d30); + } + else { + pcVar1 = (chan_ctxt_tag *)((uint)*(byte *)(DAT_42022d30 + 0x19) - (uint)p_vif_entry->index); + } + return (_Bool)(pcVar1 == (chan_ctxt_tag *)0x0); + } + return false; +} + + + +_Bool chan_is_tx_allowed(vif_info_tag *p_vif_entry) + +{ + bool bVar1; + undefined3 extraout_var; + + bVar1 = (bool)chan_is_on_channel(p_vif_entry); + if ((CONCAT31(extraout_var,bVar1) != 0) && (DAT_42022d34 != 0)) { + bVar1 = *(char *)(DAT_42022d30 + 0x16) == '\x06'; + } + return (_Bool)bVar1; +} + + + +_Bool chan_is_on_operational_channel(vif_info_tag *p_vif_entry) + +{ + bool bVar1; + + bVar1 = false; + if ((DAT_42022d30 != (chan_ctxt_tag *)0x0) && (bVar1 = false, DAT_42022d30->idx < 3)) { + bVar1 = p_vif_entry->chan_ctxt == DAT_42022d30; + } + return (_Bool)bVar1; +} + + + +void chan_update_tx_power(chan_ctxt_tag *p_chan_entry) + +{ + int8_t iVar1; + int8_t iVar2; + char cVar3; + + if (p_chan_entry->nb_linked_vif == '\0') { + return; + } + iVar2 = '\x7f'; + if ((p_chan_entry == vif_info_tab[0].chan_ctxt) && + (iVar2 = vif_info_tab[0].user_tx_power, + vif_info_tab[0].tx_power < vif_info_tab[0].user_tx_power)) { + iVar2 = vif_info_tab[0].tx_power; + } + iVar1 = iVar2; + if (p_chan_entry == vif_info_tab[1].chan_ctxt) { + iVar1 = vif_info_tab[1].user_tx_power; + if (iVar2 < vif_info_tab[1].user_tx_power) { + iVar1 = iVar2; + } + cVar3 = vif_info_tab[1].tx_power; + if (vif_info_tab[1].tx_power < iVar1) goto LAB_2301acd2; + } + cVar3 = iVar1; + if (iVar1 == '\x7f') { + return; + } +LAB_2301acd2: + (p_chan_entry->channel).tx_power = cVar3; + return; +} + + + +void chan_ctxt_link(uint8_t vif_idx,uint8_t chan_idx) + +{ + uint8_t uVar1; + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + int iVar2; + chan_ctxt_tag *p_chan_entry; + + iVar2 = CONCAT31(in_register_0000202d,chan_idx); + p_chan_entry = chan_ctxt_pool + iVar2; + if (vif_info_tab[CONCAT31(in_register_00002029,vif_idx)].chan_ctxt != (chan_ctxt_tag *)0x0) { + assert_err("p_vif_entry->chan_ctxt == NULL","module",0x99c); + } + if (chan_ctxt_pool[iVar2].idx == -1) { + assert_err("p_chan_entry->idx != CHAN_CTXT_UNUSED","module",0x99d); + } + uVar1 = chan_ctxt_pool[iVar2].nb_linked_vif + '\x01'; + DAT_42022d78 = DAT_42022d78 + 0xc800; + vif_info_tab[CONCAT31(in_register_00002029,vif_idx)].chan_ctxt = p_chan_entry; + chan_ctxt_pool[iVar2].nb_linked_vif = uVar1; + if (uVar1 == '\x01') { + chan_ctxt_pool[iVar2].status = '\x01'; + DAT_42022d82 = DAT_42022d82 + '\x01'; + co_list_push_back((co_list *)&p_chan_entry,(co_list_hdr *)p_chan_entry); + if (DAT_42022d34 == 0) { + if ((DAT_42022d80 & 0xc) == 0) { + if (DAT_42022d82 == '\x01') { + chan_switch_start(p_chan_entry); + } + else { + chan_cde_evt((void *)0x0); + } + } + } + else { + *(undefined *)(DAT_42022d34 + 0x16) = 1; + DAT_42022d34 = 0; + } + } + chan_update_tx_power(p_chan_entry); + return; +} + + + +void chan_ctxt_unlink(uint8_t vif_idx) + +{ + chan_ctxt_tag *pcVar1; + chan_ctxt_tag *p_chan_entry; + undefined3 in_register_00002029; + int iVar2; + + iVar2 = CONCAT31(in_register_00002029,vif_idx); + p_chan_entry = vif_info_tab[iVar2].chan_ctxt; + if (p_chan_entry == (chan_ctxt_tag *)0x0) { + assert_err("p_chan_entry != NULL","module",0x9e4); + } + co_list_extract((co_list *)&DAT_42022d20,(co_list_hdr *)&vif_info_tab[iVar2].tbtt_switch); + vif_info_tab[iVar2].tbtt_switch.status = '\0'; + vif_info_tab[iVar2].chan_ctxt = (chan_ctxt_tag *)0x0; + p_chan_entry->nb_linked_vif = p_chan_entry->nb_linked_vif + -1; + pcVar1 = DAT_42022d34; + if (p_chan_entry->status != '\0') { + DAT_42022d78 = DAT_42022d78 + -0xc800; + if (p_chan_entry->nb_linked_vif != '\0') goto LAB_2301aeee; + co_list_extract((co_list *)&p_chan_entry,(co_list_hdr *)p_chan_entry); + p_chan_entry->status = '\0'; + DAT_42022d82 = DAT_42022d82 - 1; + if (DAT_42022d30 == p_chan_entry) { + DAT_42022d30 = (chan_ctxt_tag *)0x0; +LAB_2301aeba: + if (pcVar1 == (chan_ctxt_tag *)0x0) { + if (DAT_42022d82 < 2) { + if (DAT_42022d82 == 1) { + chan_switch_start(p_chan_entry); + } + } + else { + chan_cde_evt((void *)0x0); + } + goto LAB_2301aee0; + } + } + else { + if (pcVar1 != p_chan_entry) goto LAB_2301aeba; + DAT_42022d34 = (chan_ctxt_tag *)0x0; + } + DAT_42022d80 = DAT_42022d80 | 0x20; + } +LAB_2301aee0: + if (p_chan_entry->nb_linked_vif == '\0') { + chan_ctxt_del(p_chan_entry->idx); + } +LAB_2301aeee: + chan_tbtt_schedule((chan_tbtt_tag *)0x0); + chan_update_tx_power(p_chan_entry); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_dma_init(void) + +{ + co_list_init((co_list *)&hal_dma_env); + hal_dma_env.lli_cnt[0] = (uint16_t)_DAT_44a000a4; + co_list_init(hal_dma_env.prog + 1); + hal_dma_env.lli_cnt[1] = (uint16_t)_DAT_44a000ac; + return; +} + + +/* +Unable to decompile 'hal_dma_push' +Cause: Exception while decompiling 2301af52: Decompiler process died + +*/ + +/* +Unable to decompile 'hal_dma_evt' +Cause: Exception while decompiling 2301afe2: Decompiler process died + +*/ + + +void hal_mib_dump(void) + +{ + puts("---------- hal_mib_dump ----------\r\n"); + printf("machw_mib nx_rd_fifo_overflow_count is %u\r\n"); + puts("\r\n"); + return; +} + + + +int mm_monitor_channel_req_handler + (ke_msg_id_t msgid,mm_monitor_channel_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint16_t prim20_freq; + undefined4 *puVar1; + uint32_t uVar2; + uint16_t center1_freq; + + puVar1 = (undefined4 *)ke_msg_alloc(0x5f,src_id,dest_id,0x28); + center1_freq = (uint16_t)param->freq; + *puVar1 = 1; + puVar1[3] = 0x11111111; + puVar1[4] = 0x22222222; + puVar1[5] = 0x33333333; + puVar1[6] = 0x44444444; + puVar1[7] = 0x55555555; + puVar1[8] = 0x66666666; + puVar1[2] = 0; + puVar1[9] = 0x77777777; + uVar2 = param->freq; + puVar1[1] = uVar2; + prim20_freq = (uint16_t)uVar2; + if ((param->use_40Mhz != 0) && (center1_freq = prim20_freq + 10, param->higher_band == 0)) { + center1_freq = prim20_freq - 10; + } + phy_set_channel('\0',param->use_40Mhz != 0,prim20_freq,center1_freq,0,'\0'); + *puVar1 = 0; + ke_msg_send(puVar1); + return 0; +} + + + +int mm_monitor_enable_req_handler + (ke_msg_id_t msgid,mm_monitor_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined4 *puVar1; + uint32_t local_50; + phy_cfg_tag config; + + puVar1 = (undefined4 *)ke_msg_alloc(0x5d,src_id,dest_id,0x28); + *puVar1 = 1; + puVar1[3] = 0x11111111; + puVar1[4] = 0x22222222; + puVar1[5] = 0x33333333; + puVar1[6] = 0x44444444; + puVar1[7] = 0x55555555; + puVar1[8] = 0x66666666; + puVar1[2] = 0; + puVar1[9] = 0x77777777; + puVar1[1] = param->enable; + memset(&local_50,0,0x40); + local_50 = 0; + phy_init((phy_cfg_tag *)&local_50); + phy_set_channel('\0','\0',0x985,0x985,0,'\0'); + mm_active(); + *puVar1 = 0; + ke_msg_send(puVar1); + return 0; +} + + + +int mm_cfg_rssi_req_handler + (ke_msg_id_t msgid,mm_cfg_rssi_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + byte bVar1; + uint uVar2; + + uVar2 = (uint)param->vif_index; + if (vif_info_tab[uVar2].type != '\0') { + assert_err("vif_entry->type == VIF_STA","module",0x8fe); + } + vif_info_tab[uVar2].u[0x1a] = param->rssi_thold; + bVar1 = param->rssi_hyst; + vif_info_tab[uVar2].u[0x1c] = 0; + vif_info_tab[uVar2].u[0x1b] = bVar1; + return 0; +} + + + +int mm_set_ps_options_req_handler + (ke_msg_id_t msgid,mm_set_ps_options_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint uVar1; + + uVar1 = (uint)param->vif_index; + if (vif_info_tab[uVar1].type != '\0') { + assert_err("vif_entry->type == VIF_STA","module",0x815); + } + *(uint16_t *)vif_info_tab[uVar1].u = param->listen_interval; + *(_Bool *)(vif_info_tab[uVar1].u + 2) = param->dont_listen_bc_mc; + ke_msg_send_basic(0x4c,src_id,dest_id); + return 0; +} + + + +int mm_tim_update_req_handler + (ke_msg_id_t msgid,mm_tim_update_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + mm_tim_update(param); + return 1; +} + + + +int mm_bcn_change_req_handler + (ke_msg_id_t msgid,mm_bcn_change_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + mm_bcn_change(param); + return 1; +} + + + +int mm_remain_on_channel_req_handler + (ke_msg_id_t msgid,mm_remain_on_channel_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t uVar1; + uint8_t uVar2; + uint8_t *puVar3; + undefined2 in_register_00002036; + + uVar2 = chan_roc_req(param,src_id); + if (CONCAT22(in_register_00002036,src_id) != 0) { + puVar3 = (uint8_t *)ke_msg_alloc(0x47,src_id,dest_id,3); + uVar1 = param->op_code; + puVar3[1] = uVar2; + *puVar3 = uVar1; + puVar3[2] = '\x04'; + ke_msg_send(); + } + return 0; +} + + + +int mm_sta_del_req_handler + (ke_msg_id_t msgid,mm_sta_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + mm_sta_del(param->sta_idx); + ke_msg_send_basic(0xd,src_id,dest_id); + return 0; +} + + + +int mm_sta_add_req_handler + (ke_msg_id_t msgid,mm_sta_add_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t uVar1; + uint8_t *puVar2; + + puVar2 = (uint8_t *)ke_msg_alloc(0xb,src_id,dest_id,3); + uVar1 = mm_sta_add(param,puVar2 + 1,puVar2 + 2); + *puVar2 = uVar1; + ke_msg_send(puVar2); + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mm_key_del_req_handler + (ke_msg_id_t msgid,mm_key_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + if ((_DAT_44b000d8 >> 0x18) + 1 < (uint)param->hw_key_idx) { + assert_err("param->hw_key_idx <= MM_SEC_MAX_KEY_NBR","module",0x56e); + } + mm_sec_machwkey_del(param->hw_key_idx); + ke_msg_send_basic(0x27,src_id,dest_id); + return 0; +} + + + +int mm_key_add_req_handler + (ke_msg_id_t msgid,mm_key_add_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t uVar1; + undefined *puVar2; + + puVar2 = (undefined *)ke_msg_alloc(0x25,src_id,dest_id,2); + if (3 < param->key_idx) { + assert_err("param->key_idx < MAC_DEFAULT_KEY_COUNT","module",0x53d); + } + if (0x20 < (param->key).length) { + assert_err("param->key.length <= MAC_SEC_KEY_LEN","module",0x541); + } + if (5 < param->cipher_suite) { + assert_err("param->cipher_suite <= MAC_RSNIE_CIPHER_AES_CMAC","module",0x544); + } + uVar1 = mm_sec_machwkey_wr(param); + puVar2[1] = uVar1; + *puVar2 = 0; + ke_msg_send(puVar2); + return 0; +} + + + +int mm_set_power_req_handler + (ke_msg_id_t msgid,mm_set_power_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint uVar1; + uint8_t *idx; + + uVar1 = (uint)param->inst_nbr; + idx = (uint8_t *)ke_msg_alloc(0x2f,src_id,dest_id,2); + vif_info_tab[uVar1].user_tx_power = param->power; + idx[1] = vif_info_tab[uVar1].tx_power; + vif_info_tab[uVar1].tx_power = '\x7f'; + tpc_update_vif_tx_power(vif_info_tab + uVar1,(int8_t *)(idx + 1),idx); + ke_msg_send(idx); + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mm_set_idle_req_handler + (ke_msg_id_t msgid,mm_set_idle_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + int iVar1; + ke_state_t kVar2; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + + kVar2 = ke_state_get(dest_id); + if (CONCAT22(extraout_var,kVar2) == 3) { +LAB_2301b50c: + iVar1 = 2; + } + else { + mm_env.host_idle = param->hw_idle; + if (mm_env.host_idle == '\0') { + kVar2 = ke_state_get(dest_id); + if (CONCAT22(extraout_var_01,kVar2) == 2) goto LAB_2301b50c; + mm_active(); + } + else { + kVar2 = ke_state_get(dest_id); + if (CONCAT22(extraout_var_00,kVar2) != 0) { + if (CONCAT22(extraout_var_00,kVar2) == 2) { + return 2; + } + hal_machw_idle_req(); + ke_state_set(dest_id,2); + return 2; + } + if ((_DAT_44b00038 & 0xf) != 0) { + assert_err("blmac_current_state_getf() == HW_IDLE","module",0x47d); + } + mm_env._18_2_ = 0; + } + ke_msg_send_basic(0x23,src_id,dest_id); + iVar1 = 0; + } + return iVar1; +} + + +/* +Unable to decompile 'mm_reset_req_handler' +Cause: Exception while decompiling 2301b594: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mm_version_req_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined4 *puVar1; + + puVar1 = (undefined4 *)ke_msg_alloc(5,src_id,dest_id,0x18); + *puVar1 = 0x5040000; + puVar1[1] = _DAT_44b00004; + puVar1[2] = _DAT_44b00008; + phy_get_version(puVar1 + 3,puVar1 + 4); + puVar1[5] = 0x89df; + ke_msg_send(puVar1); + return 0; +} + + + +int mm_start_req_handler + (ke_msg_id_t msgid,mm_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(dest_id); + if (CONCAT22(extraout_var,kVar1) != 0) { + assert_err("ke_state_get(dest_id) == MM_IDLE","module",0x135); + } + phy_init((phy_cfg_tag *)param); + phy_set_channel('\0','\0',0x96c,0x96c,0,'\0'); + tpc_update_tx_power('\x10'); + ps_env.uapsd_timeout = param->uapsd_timeout * 1000; + mm_env.lp_clk_accuracy = param->lp_clk_accuracy; + ke_msg_send_basic(3,src_id,dest_id); + mm_active(); + hal_machw_idle_req(); + ke_state_set(dest_id,2); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling + +int mm_set_ps_mode_req_handler + (ke_msg_id_t msgid,mm_set_ps_mode_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + vif_info_tag *vif_entry; + + vif_entry = (vif_info_tag *)vif_mgmt_env.used_list.first; + if (param->new_state == '\x03') { + while (vif_entry != (vif_info_tag *)0x0) { + if ((vif_entry->type == '\0') && (vif_entry->active != false)) { + ps_polling_frame(vif_entry); + } + vif_entry = *(vif_info_tag **)&vif_entry->list_hdr; + } + ke_msg_send_basic(0x32,ps_env.taskid,0); + } + else { + ps_set_mode(param->new_state,src_id); + } + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mm_force_idle_req_handler + (ke_msg_id_t msgid,mm_force_idle_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + int iVar1; + ke_state_t kVar2; + undefined2 extraout_var; + + kVar2 = ke_state_get(dest_id); + if (CONCAT22(extraout_var,kVar2) == 0) { + if ((_DAT_44b00038 & 0xf) != 0) { + assert_err("blmac_current_state_getf() == HW_IDLE","module",0x4c0); + } + ke_state_set(dest_id,3); + iVar1 = 0; + (*param->cb)(param->cb); + } + else { + iVar1 = 2; + if (CONCAT22(extraout_var,kVar2) != 2) { + hal_machw_idle_req(); + ke_state_set(dest_id,2); + } + } + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mm_hw_config_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + char cVar1; + byte bVar2; + _Bool _Var3; + uint8_t uVar4; + uint16_t uVar5; + uint32_t uVar6; + uint32_t uVar7; + int iVar8; + uint8_t uVar9; + ke_state_t kVar10; + ke_msg_id_t id; + undefined2 in_register_0000202a; + undefined2 extraout_var; + uint8_t *puVar11; + uint32_t uVar12; + uint32_t uVar13; + uint uVar14; + uint uVar15; + uint uVar16; + + uVar16 = CONCAT22(in_register_0000202a,msgid); + kVar10 = ke_state_get(dest_id); + if (CONCAT22(extraout_var,kVar10) != 0) { + if (1 < (CONCAT22(extraout_var,kVar10) - 2U & 0xffff)) { + mm_env.prev_hw_state = (byte)_DAT_44b00038 & 0xf; + kVar10 = ke_state_get(dest_id); + mm_env.prev_mm_state = (uint8_t)kVar10; + hal_machw_idle_req(); + ke_state_set(dest_id,2); + } + return 2; + } + if ((_DAT_44b00038 & 0xf) != 0) { + assert_err("blmac_current_state_getf() == HW_IDLE","module",0x77b); + } + iVar8 = DAT_42022d30; + if (uVar16 == 0x16) { + (&mm_env.rx_filter_lmac_enable)[(uint)*(byte *)((int)param + 5) + 4] = *(uint32_t *)param; + if ((iVar8 != 0) && (*(char *)(iVar8 + 4) == *(char *)((int)param + 5))) { + _DAT_44b000dc = 0x10; + } + id = 0x17; +LAB_2301b92c: + ke_msg_send_basic(id,src_id,dest_id); + } + else { + if (0x16 < uVar16) { + if (uVar16 == 0x1e) { + uVar16 = (uint)*(byte *)((int)param + 3); + if (vif_info_tab[uVar16].type == '\0') { + if (*(char *)((int)param + 2) == '\0') { + mm_timer_clear(&vif_info_tab[uVar16].tbtt_timer); + } + else { + uVar14 = (uint)vif_info_tab[uVar16].u[4]; + mm_timer_set(&vif_info_tab[uVar16].tbtt_timer, + _DAT_44b00120 + sta_info_tab[uVar14].bcn_int); + uVar5 = *(uint16_t *)param; + uVar12 = sta_info_tab[uVar14].bcn_int; + *(undefined2 *)vif_info_tab[uVar16].u = 0; + sta_info_tab[uVar14].aid = uVar5; + uVar15 = (uint)mm_env.lp_clk_accuracy; + vif_info_tab[uVar16].u[2] = 0; + sta_info_tab[uVar14].drift = (uint16_t)(((uVar15 + 0x14) * uVar12) / 1000000); + iVar8 = _DAT_44b00120; + vif_info_tab[uVar16].u[0x18] = 0; + *(undefined4 *)(vif_info_tab[uVar16].u + 0x14) = 0; + *(int *)(vif_info_tab[uVar16].u + 8) = iVar8; + vif_info_tab[uVar16].prevent_sleep = vif_info_tab[uVar16].prevent_sleep | 1; + *(int *)(vif_info_tab[uVar16].u + 0x10) = _DAT_44b00120; + chan_bcn_detect_start(vif_info_tab + uVar16); + } + } + _Var3 = *(_Bool *)((int)param + 2); + vif_info_tab[uVar16].active = _Var3; + if (_Var3 != false) { + _DAT_44b00200 = vif_info_tab[uVar16].txq_params[3]; + _DAT_44b00204 = vif_info_tab[uVar16].txq_params[3]; + _DAT_44b00208 = vif_info_tab[uVar16].txq_params[3]; + _DAT_44b0020c = vif_info_tab[uVar16].txq_params[3]; + mm_env_max_ampdu_duration_set(); + } + id = 0x1f; + } + else { + if (uVar16 < 0x1f) { + if (uVar16 == 0x1a) { + uVar16 = (uint)*(byte *)((int)param + 6); + vif_info_tab[0].txq_params[uVar16 * 0x176 + (uint)*(byte *)((int)param + 5)] = + *(uint32_t *)param; + if (vif_info_tab[uVar16].active != false) { + cVar1 = *(char *)((int)param + 5); + uVar13 = *(uint32_t *)param; + uVar12 = _DAT_44b00200; + uVar6 = uVar13; + uVar7 = _DAT_44b00208; + if (((cVar1 != '\x01') && (uVar12 = uVar13, uVar6 = _DAT_44b00204, cVar1 != '\0')) && + (uVar12 = _DAT_44b00200, uVar7 = uVar13, cVar1 != '\x02')) { + uVar7 = _DAT_44b00208; + _DAT_44b0020c = uVar13; + } + _DAT_44b00208 = uVar7; + _DAT_44b00204 = uVar6; + _DAT_44b00200 = uVar12; + mm_env_max_ampdu_duration_set(); + } + if (vif_info_tab[uVar16].type == '\0') { + ps_uapsd_set(vif_info_tab + uVar16,*(uint8_t *)((int)param + 5), + *(_Bool *)((int)param + 4)); + } + id = 0x1b; + } + else { + if (uVar16 == 0x1c) { + bVar2 = *(byte *)param; + if (((uint)bVar2 << 0xe & 0x3e0000) != 0) { + assert_err("(((uint32_t)abgnmode << 14) & ~((uint32_t)0x0001C000)) == 0","module", + 0x834); + } + _DAT_44b0004c = _DAT_44b0004c & 0xfffe3fff | (uint)bVar2 << 0xe; + id = 0x1d; + } + else { + if (uVar16 != 0x18) goto LAB_2301b7e6; + memcpy(&vif_info_tab[*(byte *)((int)param + 6)].bssid,param,6); + if ((uint)vif_mgmt_env.vif_sta_cnt + (uint)vif_mgmt_env.vif_ap_cnt == 1) { + _DAT_44b00020 = *(undefined4 *)param; + _DAT_44b00024 = (uint)*(ushort *)((int)param + 4); + } + id = 0x19; + } + } + } + else { + if (uVar16 == 0x28) { + uVar9 = '\x05'; + if (*(char *)param != '\0') { + uVar9 = '\0'; + _DAT_44b00054 = _DAT_44b00054 | 0x80; + } + puVar11 = (uint8_t *)ke_msg_alloc(0x29,src_id,dest_id,3); + *puVar11 = *(uint8_t *)((int)param + 1); + uVar4 = *(uint8_t *)((int)param + 2); + puVar11[2] = uVar9; + puVar11[1] = uVar4; + goto LAB_2301b842; + } + if (uVar16 == 0x3b) { + chan_ctxt_update((mm_chan_ctxt_update_req *)param); + id = 0x3c; + } + else { + if (uVar16 != 0x20) goto LAB_2301b7e6; + id = 0x21; + _DAT_44b000e8 = + (uint)*(byte *)param * (_DAT_44b000e4 & 0xff) * 0x100 | (uint)*(byte *)param; + } + } + } + goto LAB_2301b92c; + } + if (uVar16 == 0xe) { + mm_env.rx_filter_umac = *(uint32_t *)param; + _DAT_44b00060 = mm_env.rx_filter_umac | mm_env.rx_filter_lmac_enable; + id = 0xf; + goto LAB_2301b92c; + } + if (0xe < uVar16) { + if (uVar16 == 0x12) { + _DAT_44b00090 = (uint)*(byte *)param | _DAT_44b00090 & 0xffffff00 | 0x80000000; + id = 0x13; + } + else { + if (uVar16 != 0x14) { + if (uVar16 != 0x10) goto LAB_2301b7e6; + puVar11 = (uint8_t *)ke_msg_alloc(0x11,src_id,dest_id,2); + if (*(uint8_t *)((int)param + 8) != '\0') { + phy_set_channel(*(uint8_t *)param,*(uint8_t *)((int)param + 1), + *(uint16_t *)((int)param + 2),*(uint16_t *)((int)param + 4), + *(uint16_t *)((int)param + 6),*(uint8_t *)((int)param + 8)); + } + goto LAB_2301b842; + } + uVar16 = (uint)*(byte *)((int)param + 2); + if (vif_info_tab[uVar16].type == '\0') { + sta_info_tab[vif_info_tab[uVar16].u[4]].bcn_int = (uint)*(ushort *)param << 10; + } + else { + vif_mgmt_set_ap_bcn_int(vif_info_tab + uVar16,*(ushort *)param); + } + id = 0x15; + } + goto LAB_2301b92c; + } + if (uVar16 != 6) { + if (uVar16 != 8) { +LAB_2301b7e6: + assert_err("0","module",0x7ae); + iVar8 = 2; + goto LAB_2301b932; + } + if (*(byte *)param < 2) { + vif_mgmt_unregister(*(byte *)param); + } + if (vif_mgmt_env.used_list.first == (co_list_hdr *)0x0) { + hal_machw_monitor_mode(); + } + id = 9; + goto LAB_2301b92c; + } + puVar11 = (uint8_t *)ke_msg_alloc(7,src_id,dest_id,2); + uVar9 = vif_mgmt_register((mac_addr *)((int)param + 1),*(uint8_t *)param, + *(_Bool *)((int)param + 7),puVar11 + 1); + *puVar11 = uVar9; +LAB_2301b842: + ke_msg_send(puVar11); + } + iVar8 = 0; +LAB_2301b932: + uVar16 = (uint)mm_env.prev_hw_state; + if ((uVar16 << 4 & 0xffffff0f) != 0) { + assert_err("(((uint32_t)nextstate << 4) & ~((uint32_t)0x000000F0)) == 0","module",0x5b9); + } + _DAT_44b00038 = uVar16 << 4; + ke_state_set(dest_id,(ushort)mm_env.prev_mm_state); + return iVar8; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int bl60x_edca_get(int ac,uint8_t *aifs,uint8_t *cwmin,uint8_t *cwmax,uint16_t *txop) + +{ + uint uVar1; + uint uVar2; + + uVar1 = _DAT_44b00200; + uVar2 = _DAT_44b00204; + if (ac != 1) { + if (ac < 2) { + if (ac == 0) { + *txop = (uint16_t)(_DAT_44b00200 >> 0xc); + *cwmax = (byte)(uVar1 >> 8) & 0xf; + *cwmin = (byte)(uVar1 >> 4) & 0xf; + *aifs = (byte)uVar1 & 0xf; + return 0; + } + } + else { + uVar2 = _DAT_44b00208; + if ((ac == 2) || (uVar2 = _DAT_44b0020c, ac == 3)) goto LAB_2301bd0e; + } + return -1; + } +LAB_2301bd0e: + *txop = (uint16_t)(uVar2 >> 0xc); + *cwmax = (byte)(uVar2 >> 8) & 0xf; + *cwmin = (byte)(uVar2 >> 4) & 0xf; + *aifs = (byte)uVar2 & 0xf; + return 0; +} + + + +void rx_swdesc_init(void) + +{ + rx_swdesc_tab[0].dma_hdrdesc = rx_dma_hdrdesc; + rx_swdesc_tab[1].dma_hdrdesc = &DAT_42041064; + rx_swdesc_tab[2].dma_hdrdesc = &DAT_420410c8; + rx_swdesc_tab[3].dma_hdrdesc = &DAT_4204112c; + rx_swdesc_tab[4].dma_hdrdesc = &DAT_42041190; + rx_swdesc_tab[5].dma_hdrdesc = &DAT_420411f4; + rx_swdesc_tab[6].dma_hdrdesc = &DAT_42041258; + rx_swdesc_tab[7].dma_hdrdesc = &DAT_420412bc; + rx_swdesc_tab[8].dma_hdrdesc = &DAT_42041320; + rx_swdesc_tab[9].dma_hdrdesc = &DAT_42041384; + rx_swdesc_tab[10].dma_hdrdesc = &DAT_420413e8; + rx_swdesc_tab[11].dma_hdrdesc = &DAT_4204144c; + rx_swdesc_tab[12].dma_hdrdesc = &DAT_420414b0; + return; +} + + + +int scan_cancel_req_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(2); + if (CONCAT22(extraout_var,kVar1) == 0) { + scan_send_cancel_cfm('\x01',src_id); + } + else { + DAT_4201ea53 = 1; + } + return 0; +} + + + +int scan_start_req_handler + (ke_msg_id_t msgid,scan_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + int iVar1; + ke_state_t kVar2; + undefined *puVar3; + undefined2 extraout_var; + + puVar3 = (undefined *)ke_msg_alloc(0x801,src_id,dest_id,1); + kVar2 = ke_state_get(2); + if (CONCAT22(extraout_var,kVar2) == 0) { + if (param->chan_cnt == '\0') { + assert_err("param->chan_cnt > 0","module",0x46); + } + *puVar3 = 0; + DAT_4201ea52 = 0; + iVar1 = 1; + param = param; + DAT_4201ea50 = src_id; + scan_ie_download(param); + } + else { + *puVar3 = 8; + iVar1 = 0; + } + ke_msg_send(puVar3); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +undefined4 mm_scan_channel_end_ind_handler(void) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(2); + if (CONCAT22(extraout_var,kVar1) != 3) { + assert_err("ke_state_get(TASK_SCAN) == SCAN_WAIT_BEACON_PROBE_RSP","module",0xc4); + } + mm_env.rx_filter_lmac_enable = mm_env.rx_filter_lmac_enable & 0xffffddff; + _DAT_44b00060 = mm_env.rx_filter_lmac_enable | mm_env.rx_filter_umac; + DAT_4201ea52 = DAT_4201ea52 + 1; + if ((DAT_4201ea52 < param->chan_cnt) && (DAT_4201ea53 == '\0')) { + scan_set_channel_request(); + } + else { + ke_msg_free(¶m[-1].add_ies); + if (DAT_4201ea53 == '\0') { + ke_msg_send_basic(0x802,DAT_4201ea50,2); + } + else { + scan_send_cancel_cfm('\0',DAT_4201ea50); + DAT_4201ea53 = '\0'; + } + ke_state_set(2,0); + } + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mm_scan_channel_start_ind_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + scan_start_req *psVar1; + uint uVar2; + ke_state_t kVar3; + undefined2 extraout_var; + + psVar1 = param; + uVar2 = (uint)DAT_4201ea52; + kVar3 = ke_state_get(2); + if (CONCAT22(extraout_var,kVar3) != 2) { + assert_err("ke_state_get(TASK_SCAN) == SCAN_WAIT_CHANNEL","module",0x9d); + } + mm_env.rx_filter_lmac_enable = mm_env.rx_filter_lmac_enable | 0x2200; + _DAT_44b00060 = mm_env.rx_filter_lmac_enable | mm_env.rx_filter_umac; + if ((psVar1->chan[uVar2].flags & 1) == 0) { + scan_probe_req_tx(); + } + ke_state_set(2,3); + return 0; +} + + + +void txl_buffer_reinit(void) + +{ + txl_buffer_env.list[0].first = (txl_buffer_tag *)0x0; + txl_buffer_env.list[0].last = (txl_buffer_tag *)0x0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_buffer_init(void) + +{ + uint uVar1; + txl_buffer_control *ptVar2; + txl_buffer_control *ptVar3; + uint8_t uVar4; + byte bVar5; + undefined3 extraout_var; + undefined3 extraout_var_00; + + txl_buffer_reinit(); + ptVar3 = txl_buffer_control_desc; + do { + *(undefined4 *)ptVar3->field_0 = 0xbadcab1e; + uVar4 = phy_get_ntx(); + *(int *)(ptVar3->field_0 + 4) = CONCAT31(extraout_var,uVar4) << 0xe; + bVar5 = phy_get_ntx(); + *(int *)(ptVar3->field_0 + 8) = (1 << ((uint)bVar5 + 1 & 0x1f)) + -1; + *(undefined4 *)(ptVar3->field_0 + 0xc) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x10) = 0xffff0704; + *(undefined4 *)(ptVar3->field_0 + 0x14) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x18) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x1c) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x20) = 0; + ptVar2 = ptVar3 + 1; + *(uint *)(ptVar3->field_0 + 0x24) = _DAT_44b000a0 & 0xff; + *(uint *)(ptVar3->field_0 + 0x28) = _DAT_44b000a0 & 0xff; + *(uint *)(ptVar3->field_0 + 0x2c) = _DAT_44b000a0 & 0xff; + uVar1 = _DAT_44b000a0; + ptVar3->mac_control_info = 0x2200; + ptVar3->phy_control_info = 0x3f0000; + *(uint *)(ptVar3->field_0 + 0x30) = uVar1 & 0xff; + ptVar3 = ptVar2; + } while (ptVar2 != txl_frame_buf_ctrl); + ptVar3 = txl_buffer_control_desc_bcmc; + do { + *(undefined4 *)ptVar3->field_0 = 0xbadcab1e; + uVar4 = phy_get_ntx(); + *(int *)(ptVar3->field_0 + 4) = CONCAT31(extraout_var_00,uVar4) << 0xe; + bVar5 = phy_get_ntx(); + *(int *)(ptVar3->field_0 + 8) = (1 << ((uint)bVar5 + 1 & 0x1f)) + -1; + *(undefined4 *)(ptVar3->field_0 + 0xc) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x10) = 0xffff0704; + *(undefined4 *)(ptVar3->field_0 + 0x14) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x18) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x1c) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x20) = 0; + uVar1 = _DAT_44b000a0; + ptVar2 = ptVar3 + 1; + *(undefined4 *)(ptVar3->field_0 + 0x28) = 0; + *(uint *)(ptVar3->field_0 + 0x24) = uVar1 & 0xff; + *(undefined4 *)(ptVar3->field_0 + 0x2c) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x30) = 0; + ptVar3->mac_control_info = 0; + ptVar3->phy_control_info = 0x3f0000; + ptVar3 = ptVar2; + } while (ptVar2 != txl_buffer_control_desc); + return; +} + + + +void txl_buffer_reset(void) + +{ + txl_buffer_env.list[0].first = (txl_buffer_tag *)0x0; + txl_buffer_env.list[0].last = (txl_buffer_tag *)0x0; + return; +} + + + +txl_buffer_tag * txl_buffer_alloc(txdesc *txdesc,uint8_t access_category,uint8_t user_idx) + +{ + ushort uVar1; + txl_buffer_tag *ptVar2; + txl_buffer_tag *ptVar3; + txl_buffer_control *ptVar4; + uint uVar5; + int iVar6; + int iVar7; + + uVar5 = (uint)(txdesc->umac).head_len; + *(uint8_t *)(txdesc->buf + 0x3b) = user_idx; + txdesc->buf[2] = (uVar5 + 0xf & 0xfffffff0) - uVar5; + txdesc->buf[0xe] = 0xcafefade; + uVar1 = (txdesc->host).flags; + txdesc->buf[1] = uVar5; + ptVar3 = (txl_buffer_tag *)txdesc->buf; + if ((uVar1 & 8) == 0) { + txu_cntrl_frame_build(txdesc,(int)txdesc->buf + uVar5 + 0x14c); + } + ptVar4 = (txdesc->umac).buf_control; + iVar6 = 0; + do { + iVar7 = iVar6 + 4; + *(undefined4 *)((int)txdesc->buf + iVar6 + 0xf0) = *(undefined4 *)(ptVar4->field_0 + iVar6); + iVar6 = iVar7; + } while (iVar7 != 0x3c); + ptVar2 = ptVar3; + if (txl_buffer_env.list[0].first != (txl_buffer_tag *)0x0) { + (txl_buffer_env.list[0].last)->next = ptVar3; + ptVar2 = txl_buffer_env.list[0].first; + } + txl_buffer_env.list[0].first = ptVar2; + txl_buffer_env.list[0].last = ptVar3; + txdesc->buf[4] = 0; + return ptVar3; +} + + + +void txl_buffer_update_thd(txdesc *txdesc) + +{ + char "txl_buffer_update_thd" [22]; + uint32_t *puVar1; + int iVar2; + tx_pbd *in_a2; + tx_pbd *ptVar3; + uint32_t uVar4; + txl_buffer_tag *ptVar5; + tx_hw_desc *ptVar6; + uint32_t uVar7; + + ptVar5 = (txdesc->lmac).buffer; + ptVar6 = (txdesc->lmac).hw_desc; + puVar1 = (txdesc->host).pbuf_chained_ptr; + iVar2 = 0; + ptVar3 = ptVar5->tbd_body; + while (*puVar1 != 0) { + ptVar3->upatterntx = 0xcafefade; + uVar4 = *puVar1; + ptVar3->datastartptr = uVar4; + uVar7 = puVar1[4]; + ptVar3->bufctrlinfo = 0; + iVar2 = iVar2 + 1; + ptVar3->dataendptr = (uVar4 + uVar7) - 1; + *(tx_pbd **)&ptVar3->next = ptVar3 + 1; + puVar1 = puVar1 + 1; + in_a2 = ptVar3; + ptVar3 = ptVar3 + 1; + } + if (iVar2 == 0) { + printf("%s: assert when set add_pbd chain\r\n","txl_buffer_update_thd"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + uVar4 = ptVar5->lenheader; + (ptVar5->tbd).upatterntx = 0xcafefade; + *(txl_buffer_tag **)&(ptVar5->tbd).datastartptr = ptVar5 + 1; + *(uint8_t **)&(ptVar5->tbd).dataendptr = ptVar5->tkip_mic_icv + uVar4 + 0xb; + *(tx_pbd **)&(ptVar5->tbd).next = ptVar5->tbd_body; + (ptVar5->tbd).bufctrlinfo = 0; + *(tx_pbd **)&(ptVar6->thd).field_3 = &ptVar5->tbd; + in_a2->bufctrlinfo = 0; + (ptVar6->thd).macctrlinfo2 = 0x100; + in_a2->next = 0; + return; +} + + + +void bam_init(void) + +{ + bam_env[0].sta_idx = -1; + ke_state_set(8,0); + return; +} + + + +void bam_send_air_action_frame + (int param_1,bam_env_tag *param_2,int param_3,uint8_t param_4,int param_5, + uint16_t param_6,cfm_func_ptr *param_7) + +{ + byte bVar1; + uint8_t ac; + uint16_t uVar2; + txl_frame_desc_tag *frame; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + txl_buffer_tag *ptVar3; + tx_hw_desc *ptVar4; + int iVar5; + uint uVar6; + char acStack72 [20]; + + bVar1 = sta_info_tab[param_1].inst_nbr; + uVar6 = (uint)bVar1; + phy_get_channel((phy_channel_info *)acStack72,'\0'); + frame = txl_frame_get((uint)(acStack72[0] != '\0'),0x100); + if (frame == (txl_frame_desc_tag *)0x0) { + return; + } + tpc_update_frame_tx_power(vif_info_tab + uVar6,frame); + ptVar3 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar3[1].length = 0xd0; + *(undefined *)((int)&ptVar3[1].length + 1) = 0; + *(undefined *)((int)&ptVar3[1].length + 2) = 0; + *(undefined *)((int)&ptVar3[1].length + 3) = 0; + *(uint16_t *)&ptVar3[1].lenheader = sta_info_tab[param_1].mac_addr.array[0]; + *(uint16_t *)((int)&ptVar3[1].lenheader + 2) = sta_info_tab[param_1].mac_addr.array[1]; + *(uint16_t *)&ptVar3[1].lenpad = sta_info_tab[param_1].mac_addr.array[2]; + *(uint16_t *)((int)&ptVar3[1].lenpad + 2) = vif_info_tab[uVar6].mac_addr.array[0]; + *(uint16_t *)&ptVar3[1].flags = vif_info_tab[uVar6].mac_addr.array[1]; + *(uint16_t *)((int)&ptVar3[1].flags + 2) = vif_info_tab[uVar6].mac_addr.array[2]; + if (vif_info_tab[uVar6].type == '\x02') { + *(uint16_t *)&ptVar3[1].next = vif_info_tab[uVar6].mac_addr.array[0]; + *(uint16_t *)((int)&ptVar3[1].next + 2) = vif_info_tab[uVar6].mac_addr.array[1]; + uVar2 = vif_info_tab[uVar6].mac_addr.array[2]; + } + else { + *(uint16_t *)&ptVar3[1].next = sta_info_tab[param_1].mac_addr.array[0]; + *(uint16_t *)((int)&ptVar3[1].next + 2) = sta_info_tab[param_1].mac_addr.array[1]; + uVar2 = sta_info_tab[param_1].mac_addr.array[2]; + } + *(uint16_t *)&ptVar3[1].txdesc = uVar2; + uVar6 = (uint)txl_cntrl_env.seqnbr; + txl_cntrl_env.seqnbr = (uint16_t)((uVar6 + 1) * 0x10000 >> 0x10); + iVar5 = (uVar6 + 1) * 0x100000; + *(undefined *)((int)&ptVar3[1].txdesc + 2) = (char)((uint)iVar5 >> 0x10); + *(undefined *)((int)&ptVar3[1].txdesc + 3) = (char)((uint)iVar5 >> 0x18); + (frame->txdesc).host.vif_idx = bVar1; + (frame->txdesc).host.staid = (uint8_t)param_1; + if (param_3 == 1) { + uVar2 = me_build_add_ba_rsp((uint32_t)ptVar3[1].dma_desc,param_2,(uint16_t)param_5,param_4, + param_6); + iVar5 = CONCAT22(extraout_var_00,uVar2); +LAB_2301c43c: + iVar5 = iVar5 + 0x18; + } + else { + if (param_3 == 0) { + ac = "\x01"[param_5 >> 2 & 0xf]; + uVar2 = me_build_add_ba_req((uint32_t)ptVar3[1].dma_desc,param_2); + iVar5 = CONCAT22(extraout_var,uVar2) + 0x18; + goto LAB_2301c3ee; + } + if (param_3 == 2) { + uVar2 = me_build_del_ba((uint32_t)ptVar3[1].dma_desc,param_2,param_6); + iVar5 = CONCAT22(extraout_var_01,uVar2); + goto LAB_2301c43c; + } + assert_warn("0","module",0x25d); + iVar5 = 0x18; + } + ac = '\x03'; +LAB_2301c3ee: + ptVar4 = (frame->txdesc).lmac.hw_desc; + (ptVar4->thd).field_5 = (ptVar4->thd).field_4 + -1 + iVar5; + (ptVar4->thd).frmlen = iVar5 + 4; + if (param_7 != (cfm_func_ptr *)0x0) { + (frame->cfm).cfm_func = param_7; + *(bam_env_tag **)&(frame->cfm).env = param_2; + } + txl_frame_push(frame,ac); + return; +} + + + +undefined4 rxu_mgt_ind_handler(int param_1) + +{ + int iVar1; + int iVar2; + byte bVar3; + byte bVar4; + ushort uVar5; + uint uVar6; + uint uVar7; + + if (*(char *)(param_1 + 0x1d) == '\0') { + uVar5 = *(ushort *)(param_1 + 0x1f); + bVar3 = *(byte *)(param_1 + 7); + bVar4 = *(byte *)(param_1 + 0x1e); + iVar1 = 0x234; + if ((uVar5 & 1) != 0) { + iVar1 = 0x238; + } + iVar2 = 0x244; + if ((uVar5 & 2) == 0) { + iVar2 = 600; + } + uVar7 = (uint)(uVar5 >> 6); + printf( + "-----------------> AABA Request:\r\n A-MSDU: %s\r\n Block Ack Policy: %s\r\n TID: %u\r\n Number of Buffers: %u\r\n" + ,iVar1 + 0x230ae000,iVar2 + 0x230ae000,(int)(uint)uVar5 >> 2 & 0xf,uVar7); + if (8 < uVar5 >> 6) { + uVar7 = 8; + } + uVar6 = SEXT24((short)((ushort)(uVar7 << 6) | uVar5 & 0x3e | 2)); + uVar7 = uVar6 & 0xffff; + printf( + "-----------------> AABA Response:\r\n A-MSDU: %s\r\n Block Ack Policy: %s\r\n TID: %u\r\n Number of Buffers: %u\r\n" + ,"Not Permitted","Immediate Block Ack",(int)uVar6 >> 2 & 0xf,uVar7 >> 6); + bam_send_air_action_frame((uint)bVar3,0,1,(uint)bVar4,uVar7,0,0); + return 0; + } + return 0; +} + + + +void co_pack8p(uint32_t dst,uint8_t *src,uint32_t len) + +{ + uint8_t *puVar1; + uint8_t *puVar2; + uint32_t uVar3; + + uVar3 = 0; + while (len != uVar3) { + puVar1 = src + uVar3; + puVar2 = (uint8_t *)(dst + uVar3); + uVar3 = uVar3 + 1; + *puVar2 = *puVar1; + } + return; +} + + + +int phy_freq_to_channel(uint8_t band,uint16_t freq) + +{ + undefined3 in_register_00002029; + undefined2 in_register_0000202e; + int iVar1; + int iVar2; + + iVar1 = CONCAT22(in_register_0000202e,freq); + if (CONCAT31(in_register_00002029,band) == 0) { + if (0x48 < (iVar1 - 0x96cU & 0xffff)) { + return 0; + } + if (iVar1 == 0x9b4) { + return 0xe; + } + iVar2 = -0x967; + } + else { + if (CONCAT31(in_register_00002029,band) != 1) { + return 0; + } + if (0x334 < (iVar1 - 0x138dU & 0xffff)) { + return 0; + } + iVar2 = -5000; + } + return (iVar1 + iVar2) / 5; +} + + + +uint16_t phy_channel_to_freq(uint8_t band,int channel) + +{ + undefined3 in_register_00002029; + int iVar1; + + if (CONCAT31(in_register_00002029,band) == 0) { + if (0xd < channel - 1U) { + return 0xffff; + } + if (channel == 0xe) { + return 0x9b4; + } + iVar1 = 0x967; + } + else { + if (0xa4 < channel - 1U) { + return 0xffff; + } + iVar1 = 5000; + } + return (uint16_t)((uint)((channel * 5 + iVar1) * 0x10000) >> 0x10); +} + + + +uint32_t me_add_ie_ssid(uint32_t *frame_addr,uint8_t ssid_len,uint8_t *p_ssid) + +{ + undefined3 in_register_0000202d; + uint32_t len; + + len = CONCAT31(in_register_0000202d,ssid_len); + *(undefined *)*frame_addr = 0; + *(uint8_t *)(*frame_addr + 1) = ssid_len; + if (len != 0) { + co_pack8p(*frame_addr + 2,p_ssid,len); + } + *frame_addr = *frame_addr + len + 2; + return len + 2; +} + + + +uint32_t me_add_ie_supp_rates(uint32_t *frame_addr,mac_rateset *p_rateset) + +{ + uint32_t len; + byte bVar1; + + bVar1 = p_rateset->length; + len = 8; + if (bVar1 < 9) { + len = (uint)bVar1; + } + *(undefined *)*frame_addr = 1; + if (8 < bVar1) { + bVar1 = 8; + } + *(byte *)(*frame_addr + 1) = bVar1; + co_pack8p(*frame_addr + 2,p_rateset->array,len); + *frame_addr = *frame_addr + len + 2; + return len + 2; +} + + + +uint32_t me_add_ie_ext_supp_rates(uint32_t *frame_addr,mac_rateset *p_rateset) + +{ + byte bVar1; + uint32_t uVar2; + uint32_t len; + + bVar1 = p_rateset->length; + *(undefined *)*frame_addr = 0x32; + uVar2 = (uint)bVar1 - 6; + len = (uint)bVar1 - 8; + *(undefined *)(*frame_addr + 1) = (char)len; + co_pack8p(*frame_addr + 2,p_rateset->array + 8,len); + *frame_addr = *frame_addr + uVar2; + return uVar2; +} + + + +uint32_t me_add_ie_ds(uint32_t *frame_addr,uint8_t channel) + +{ + *(undefined *)*frame_addr = 3; + *(undefined *)(*frame_addr + 1) = 1; + *(uint8_t *)(*frame_addr + 2) = channel; + *frame_addr = *frame_addr + 3; + return 3; +} + + + +uint32_t me_add_ie_erp(uint32_t *frame_addr,uint8_t erp_info) + +{ + *(undefined *)*frame_addr = 0x2a; + *(undefined *)(*frame_addr + 1) = 1; + *(uint8_t *)(*frame_addr + 2) = erp_info; + *frame_addr = *frame_addr + 3; + return 3; +} + + + +uint32_t me_add_ie_rsn(uint32_t *frame_addr,uint8_t enc_type) + +{ + undefined3 in_register_0000202d; + uint32_t uVar1; + uint32_t uVar2; + + if (CONCAT31(in_register_0000202d,enc_type) == 1) { + *(undefined *)*frame_addr = 0x30; + *(undefined *)(*frame_addr + 1) = 0x14; + uVar1 = *frame_addr; + *(uint8_t *)(uVar1 + 2) = enc_type; + *(undefined *)(uVar1 + 3) = 0; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 6) = 0xac; + *(undefined *)(uVar1 + 7) = 4; + *(undefined *)(uVar1 + 4) = 0; + *(undefined *)(uVar1 + 5) = 0xf; + uVar1 = *frame_addr; + *(uint8_t *)(uVar1 + 8) = enc_type; + *(undefined *)(uVar1 + 9) = 0; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 0xc) = 0xac; + *(undefined *)(uVar1 + 0xd) = 4; + *(undefined *)(uVar1 + 10) = 0; + *(undefined *)(uVar1 + 0xb) = 0xf; + uVar2 = *frame_addr; + uVar1 = 0x16; + *(uint8_t *)(uVar2 + 0xe) = enc_type; + *(undefined *)(uVar2 + 0xf) = 0; + uVar2 = *frame_addr; + *(undefined *)(uVar2 + 0x12) = 0xac; + *(undefined *)(uVar2 + 0x10) = 0; + *(undefined *)(uVar2 + 0x11) = 0xf; + *(undefined *)(uVar2 + 0x13) = 2; + uVar2 = *frame_addr; + *(undefined *)(uVar2 + 0x14) = 0; + *(undefined *)(uVar2 + 0x15) = 0; + } + else { + uVar1 = 0; + if (CONCAT31(in_register_0000202d,enc_type) == 2) { + *(undefined *)*frame_addr = 0x30; + *(undefined *)(*frame_addr + 1) = 0x18; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 2) = 1; + *(undefined *)(uVar1 + 3) = 0; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 4) = 0; + *(undefined *)(uVar1 + 5) = 0xf; + *(undefined *)(uVar1 + 6) = 0xac; + *(uint8_t *)(uVar1 + 7) = enc_type; + uVar1 = *frame_addr; + *(uint8_t *)(uVar1 + 8) = enc_type; + *(undefined *)(uVar1 + 9) = 0; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 10) = 0; + *(undefined *)(uVar1 + 0xb) = 0xf; + *(undefined *)(uVar1 + 0xc) = 0xac; + *(uint8_t *)(uVar1 + 0xd) = enc_type; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 0x11) = 4; + *(undefined *)(uVar1 + 0xe) = 0; + *(undefined *)(uVar1 + 0xf) = 0xf; + *(undefined *)(uVar1 + 0x10) = 0xac; + uVar2 = *frame_addr; + uVar1 = 0x1a; + *(undefined *)(uVar2 + 0x12) = 1; + *(undefined *)(uVar2 + 0x13) = 0; + uVar2 = *frame_addr; + *(undefined *)(uVar2 + 0x14) = 0; + *(undefined *)(uVar2 + 0x15) = 0xf; + *(undefined *)(uVar2 + 0x16) = 0xac; + *(uint8_t *)(uVar2 + 0x17) = enc_type; + uVar2 = *frame_addr; + *(undefined *)(uVar2 + 0x18) = 0; + *(undefined *)(uVar2 + 0x19) = 0; + } + } + *frame_addr = *frame_addr + uVar1; + return uVar1; +} + + + +uint32_t me_add_ie_wpa(uint32_t *frame_addr,uint8_t enc_type) + +{ + uint32_t uVar1; + undefined3 in_register_0000202d; + uint32_t uVar2; + + uVar1 = 0; + if (CONCAT31(in_register_0000202d,enc_type) == 2) { + *(undefined *)*frame_addr = 0xdd; + *(undefined *)(*frame_addr + 1) = 0x1c; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 5) = 1; + *(undefined *)(uVar1 + 2) = 0; + *(undefined *)(uVar1 + 3) = 0x50; + *(undefined *)(uVar1 + 4) = 0xf2; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 6) = 1; + *(undefined *)(uVar1 + 7) = 0; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 8) = 0; + *(undefined *)(uVar1 + 9) = 0x50; + *(undefined *)(uVar1 + 10) = 0xf2; + *(uint8_t *)(uVar1 + 0xb) = enc_type; + uVar1 = *frame_addr; + *(uint8_t *)(uVar1 + 0xc) = enc_type; + *(undefined *)(uVar1 + 0xd) = 0; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 0xe) = 0; + *(undefined *)(uVar1 + 0xf) = 0x50; + *(undefined *)(uVar1 + 0x10) = 0xf2; + *(uint8_t *)(uVar1 + 0x11) = enc_type; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 0x12) = 0; + *(undefined *)(uVar1 + 0x13) = 0x50; + *(undefined *)(uVar1 + 0x14) = 0xf2; + *(undefined *)(uVar1 + 0x15) = 4; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 0x16) = 1; + *(undefined *)(uVar1 + 0x17) = 0; + uVar2 = *frame_addr; + uVar1 = 0x1e; + *(undefined *)(uVar2 + 0x18) = 0; + *(undefined *)(uVar2 + 0x19) = 0x50; + *(undefined *)(uVar2 + 0x1a) = 0xf2; + *(uint8_t *)(uVar2 + 0x1b) = enc_type; + } + *frame_addr = *frame_addr + uVar1; + return uVar1; +} + + + +uint32_t me_add_ie_tim(uint32_t *frame_addr,uint8_t dtim_period) + +{ + *(undefined *)*frame_addr = 5; + *(undefined *)(*frame_addr + 1) = 4; + *(uint8_t *)(*frame_addr + 3) = dtim_period; + *frame_addr = *frame_addr + 6; + return 6; +} + + + +uint32_t me_add_ie_ht_capa(uint32_t *frame_addr) + +{ + uint16_t uVar1; + uint32_t uVar2; + uint uVar3; + + uVar3 = (uint)me_env.ht_cap.ht_capa_info; + *(undefined *)*frame_addr = 0x2d; + *(undefined *)(*frame_addr + 1) = 0x1a; + uVar2 = *frame_addr; + *(byte *)(uVar2 + 2) = (byte)(uVar3 & 0xfffffff3) | 0xc; + *(undefined *)(uVar2 + 3) = (char)((uVar3 & 0xfffffff3) >> 8); + *(uint8_t *)(*frame_addr + 4) = me_env.ht_cap.a_mpdu_param; + co_pack8p(*frame_addr + 5,me_env.ht_cap.mcs_rate,0x10); + uVar1 = me_env.ht_cap.ht_extended_capa; + uVar2 = *frame_addr; + *(undefined *)(uVar2 + 0x15) = (char)me_env.ht_cap.ht_extended_capa; + *(undefined *)(uVar2 + 0x16) = (char)(uVar1 >> 8); + co_pack8p(*frame_addr + 0x17,(uint8_t *)&me_env.ht_cap.tx_beamforming_capa,4); + *(uint8_t *)(*frame_addr + 0x1b) = me_env.ht_cap.asel_capa; + *frame_addr = *frame_addr + 0x1c; + return 0x1c; +} + + + +uint32_t me_add_ie_ht_oper(uint32_t *frame_addr,vif_info_tag *p_vif_entry) + +{ + chan_ctxt_tag *pcVar1; + int iVar2; + uint8_t uVar3; + uint32_t uVar4; + + pcVar1 = p_vif_entry->chan_ctxt; + *(undefined *)*frame_addr = 0x3d; + *(undefined *)(*frame_addr + 1) = 0x16; + iVar2 = phy_freq_to_channel((pcVar1->channel).band,(pcVar1->channel).prim20_freq); + *(undefined *)(*frame_addr + 2) = (char)iVar2; + uVar3 = (pcVar1->channel).type; + if ((uVar3 != '\0') && + (uVar3 = '\a', (pcVar1->channel).prim20_freq <= (pcVar1->channel).center1_freq)) { + uVar3 = '\x05'; + } + *(uint8_t *)(*frame_addr + 3) = uVar3; + uVar4 = *frame_addr; + *(undefined *)(uVar4 + 4) = 3; + *(undefined *)(uVar4 + 5) = 0; + uVar4 = *frame_addr; + *(undefined *)(uVar4 + 6) = 0; + *(undefined *)(uVar4 + 7) = 0; + *(undefined *)(*frame_addr + 8) = 0xff; + *frame_addr = *frame_addr + 0x18; + return 0x18; +} + + + +uint16_t me_build_authenticate + (uint32_t frame,uint16_t algo_type,uint16_t seq_nbr,uint16_t status_code, + uint32_t *challenge_array_ptr) + +{ + undefined *puVar1; + undefined *puVar2; + int iVar3; + + *(char *)frame = (char)algo_type; + *(undefined *)(frame + 2) = (char)seq_nbr; + *(undefined *)(frame + 4) = (char)status_code; + *(undefined *)(frame + 1) = (char)(algo_type >> 8); + *(undefined *)(frame + 3) = (char)(seq_nbr >> 8); + *(undefined *)(frame + 5) = (char)(status_code >> 8); + if (challenge_array_ptr != (uint32_t *)0x0) { + *(undefined *)(frame + 6) = 0x10; + *(undefined *)(frame + 7) = 0x80; + iVar3 = 0; + do { + puVar1 = (undefined *)((int)challenge_array_ptr + iVar3); + puVar2 = (undefined *)(frame + 8 + iVar3); + iVar3 = iVar3 + 1; + *puVar2 = *puVar1; + } while (iVar3 != 0x80); + return 0x88; + } + return 6; +} + + + +uint16_t me_build_deauthenticate(uint32_t frame,uint16_t reason_code) + +{ + *(char *)frame = (char)reason_code; + *(undefined *)(frame + 1) = (char)(reason_code >> 8); + return 2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +uint16_t me_build_associate_req + (uint32_t frame,mac_bss_info *bss,mac_addr *old_ap_addr_ptr,uint8_t vif_idx, + uint32_t *ie_addr,uint16_t *ie_len,sm_connect_req *con_par) + +{ + byte bVar1; + uint32_t *puVar2; + uint8_t uVar3; + ushort uVar4; + mac_ssid *pmVar5; + int8_t *piVar6; + uint uVar7; + uint16_t uVar8; + short sVar9; + int iVar10; + uint16_t uVar11; + uint32_t uVar12; + uint32_t uVar13; + uint uVar14; + char *pcVar15; + int8_t *dst; + uint uVar16; + uint uVar17; + uint uVar18; + uint uVar19; + me_chan_config_req *pmVar20; + char cVar21; + char cVar22; + uint uVar23; + uint8_t uVar24; + int8_t *apiStack100 [4]; + int8_t iStack81; + undefined2 uStack80; + undefined uStack78; + int8_t min; + int8_t max; + + uVar8 = con_par->listen_interval; + uVar4 = con_par->ie_len; + if (uVar8 == 0) { + uVar8 = 5; + } + apiStack100[0] = (int8_t *)frame; + uVar11 = me_build_capability(vif_idx); + *apiStack100[0] = (int8_t)uVar11; + apiStack100[0][1] = (int8_t)(uVar11 >> 8); + apiStack100[0][2] = (int8_t)uVar8; + apiStack100[0][3] = (int8_t)(uVar8 >> 8); + iVar10 = 4; + if (old_ap_addr_ptr != (mac_addr *)0x0) { + iVar10 = 10; + *(uint16_t *)(apiStack100[0] + 4) = old_ap_addr_ptr->array[0]; + *(uint16_t *)(apiStack100[0] + 6) = old_ap_addr_ptr->array[1]; + *(uint16_t *)(apiStack100[0] + 8) = old_ap_addr_ptr->array[2]; + } + apiStack100[0] = apiStack100[0] + iVar10; + *(int8_t **)ie_addr = apiStack100[0]; + uVar12 = me_add_ie_ssid((uint32_t *)apiStack100,(bss->ssid).length,(bss->ssid).array); + uVar13 = me_add_ie_supp_rates((uint32_t *)apiStack100,&bss->rate_set); + sVar9 = (short)iVar10 + (short)uVar13 + (short)uVar12; + if (8 < (bss->rate_set).length) { + uVar12 = me_add_ie_ext_supp_rates((uint32_t *)apiStack100,&bss->rate_set); + sVar9 = sVar9 + (short)uVar12; + } + if ((uVar11 & 0x100) != 0) { + dst = apiStack100[0] + 1; + *apiStack100[0] = '!'; + apiStack100[0] = apiStack100[0] + 2; + *dst = '\x02'; + phy_get_rf_gain_capab((int8_t *)&uStack80,&iStack81); + bVar1 = bss->chan->tx_power; + if ((char)bVar1 < (char)uStack80) { + uStack80 = uStack80 & 0xff00 | (ushort)bVar1; + } + *apiStack100[0] = iStack81; + apiStack100[0][1] = (char)uStack80; + dst = apiStack100[0] + 3; + apiStack100[0][2] = '$'; + apiStack100[0] = apiStack100[0] + 4; + if (bss->chan->band == '\0') { + pmVar20 = &me_env.chan; + iVar10 = 1; + uVar3 = me_env.chan.chan2G4_cnt; + } + else { + pmVar20 = (me_chan_config_req *)me_env.chan.chan5G; + iVar10 = 4; + uVar3 = me_env.chan.chan5G_cnt; + } + uVar19 = 0; + cVar21 = '\0'; + uVar24 = '\0'; + uVar7 = 0; + uVar17 = 0; + while( true ) { + piVar6 = apiStack100[0]; + uVar23 = uVar19 + 2 & 0xff; + pcVar15 = apiStack100[0] + 1; + if (uVar24 == uVar3) break; + uVar16 = uVar7; + uVar18 = uVar17; + if ((pmVar20->chan2G4[0].flags & 2) == 0) { + uVar14 = phy_freq_to_channel(pmVar20->chan2G4[0].band,pmVar20->chan2G4[0].freq); + uVar16 = uVar14 & 0xff; + uVar18 = uVar16; + cVar22 = cVar21; + if ((cVar21 != '\0') && (uVar18 = uVar17, (uVar14 & 0xff) - uVar7 != iVar10)) { + cVar22 = cVar21 + '\x01'; + *piVar6 = (int8_t)uVar17; + apiStack100[0] = piVar6 + 2; + *pcVar15 = cVar21; + uVar19 = uVar23; + } + cVar21 = cVar22 + '\x01'; + pmVar20 = (me_chan_config_req *)(pmVar20->chan2G4 + 1); + } + uVar24 = uVar24 + '\x01'; + uVar7 = uVar16; + uVar17 = uVar18; + } + *apiStack100[0] = (int8_t)uVar17; + sVar9 = sVar9 + 6 + (short)uVar23; + apiStack100[0] = apiStack100[0] + 2; + *pcVar15 = cVar21; + *dst = (int8_t)uVar23; + } + pmVar5 = &con_par->ssid; + iVar10 = -(int)con_par; + while ((sm_connect_req *)(&pmVar5->length + uVar4) != con_par) { + puVar2 = con_par->ie_buf; + dst = apiStack100[0] + iVar10 + (int)con_par; + con_par = (sm_connect_req *)(con_par->ssid).array; + *dst = *(int8_t *)puVar2; + } + uVar8 = sVar9 + uVar4; + dst = apiStack100[0] + uVar4; + apiStack100[0] = dst; + if ((bss->valid_flags & 1) != 0) { + memset(&uStack78,0,0xe); + uStack80 = 0x7dd; + min = 'P'; + co_pack8p((uint32_t)dst,(uint8_t *)&uStack80,9); + uVar8 = uVar8 + (ushort)uStack80._1_1_ + 2; + apiStack100[0] = apiStack100[0] + (uint)uStack80._1_1_ + 2; + } + if (((bss->valid_flags & 2) != 0) && (me_env.ht_supported != false)) { + uVar12 = me_add_ie_ht_capa((uint32_t *)apiStack100); + uVar8 = uVar8 + (short)uVar12; + } + *ie_len = (short)apiStack100[0] - (short)*ie_addr; + return uVar8; +} + + + +uint16_t me_build_add_ba_req(uint32_t frame,bam_env_tag *bam_env) + +{ + uint16_t uVar1; + uint uVar2; + int iVar3; + + *(undefined *)frame = 3; + *(undefined *)(frame + 1) = 0; + *(uint8_t *)(frame + 2) = bam_env->dialog_token; + uVar2 = (uint)bam_env->ba_policy << 1 | (uint)bam_env->tid << 2 | (uint)bam_env->buffer_size << 6; + *(undefined *)(frame + 3) = (char)uVar2; + *(undefined *)(frame + 4) = (char)(uVar2 >> 8); + uVar1 = bam_env->ba_timeout; + *(undefined *)(frame + 5) = (char)uVar1; + *(undefined *)(frame + 6) = (char)(uVar1 >> 8); + iVar3 = (uint)bam_env->ssn << 0x14; + *(undefined *)(frame + 7) = (char)((uint)iVar3 >> 0x10); + *(undefined *)(frame + 8) = (char)((uint)iVar3 >> 0x18); + return 9; +} + + + +uint16_t me_build_add_ba_rsp(uint32_t frame,bam_env_tag *bam_env,uint16_t param,uint8_t dialog_token + ,uint16_t status_code) + +{ + undefined2 in_register_0000203a; + + *(undefined *)frame = 3; + *(undefined *)(frame + 1) = 1; + *(undefined *)(frame + 5) = (char)param; + *(undefined *)(frame + 4) = (char)(status_code >> 8); + *(uint8_t *)(frame + 2) = dialog_token; + *(undefined *)(frame + 3) = (char)status_code; + *(undefined *)(frame + 6) = (char)(param >> 8); + if (CONCAT22(in_register_0000203a,status_code) == 0) { + *(undefined *)(frame + 7) = 0xd0; + *(undefined *)(frame + 8) = 7; + } + else { + *(undefined *)(frame + 7) = 0; + *(undefined *)(frame + 8) = 0; + } + return 9; +} + + + +uint16_t me_build_del_ba(uint32_t frame,bam_env_tag *bam_env,uint16_t reason_code) + +{ + byte bVar1; + + *(undefined *)frame = 3; + *(undefined *)(frame + 1) = 2; + bVar1 = (byte)(((uint)bam_env->tid << 0x1c) >> 0x18); + if (bam_env->dev_type == '\x01') { + bVar1 = bVar1 | 8; + } + *(undefined *)(frame + 2) = 0; + *(byte *)(frame + 3) = bVar1; + *(undefined *)(frame + 4) = (char)reason_code; + *(undefined *)(frame + 5) = (char)(reason_code >> 8); + return 6; +} + + + +void me_extract_rate_set(uint32_t buffer,uint16_t buflen,mac_rateset *mac_rate_set_ptr) + +{ + byte bVar1; + byte bVar2; + int iVar3; + undefined2 in_register_0000202e; + uint uVar4; + uint8_t *puVar5; + uint uVar6; + + mac_rate_set_ptr->length = '\0'; + iVar3 = mac_ie_find(CONCAT22(in_register_0000202e,buflen),1); + if (iVar3 != 0) { + bVar1 = *(byte *)(iVar3 + 1); + uVar4 = (uint)bVar1; + if (bVar1 < 0xd) { + puVar5 = mac_rate_set_ptr->array; + while (uVar4 = uVar4 - 1, uVar4 != 0xffffffff) { + *puVar5 = (puVar5 + 1)[iVar3 - (int)mac_rate_set_ptr]; + puVar5 = puVar5 + 1; + } + mac_rate_set_ptr->length = bVar1; + iVar3 = mac_ie_find(buffer,CONCAT22(in_register_0000202e,buflen),0x32); + if (iVar3 != 0) { + bVar1 = *(byte *)(iVar3 + 1); + uVar4 = (uint)bVar1; + if (0xc < mac_rate_set_ptr->length + uVar4) { + assert_err("mac_rate_set_ptr->length + elmt_length <= MAC_RATESET_LEN","module",0x396); + } + bVar2 = mac_rate_set_ptr->length; + if (bVar2 + uVar4 < 0xd) { + uVar6 = 0; + while (uVar4 != uVar6) { + mac_rate_set_ptr->array[bVar2 + uVar6] = *(uint8_t *)(iVar3 + 2 + uVar6); + uVar6 = uVar6 + 1; + } + mac_rate_set_ptr->length = bVar1 + mac_rate_set_ptr->length; + } + } + } + } + return; +} + + + +void me_extract_power_constraint(uint32_t buffer,uint16_t buflen,mac_bss_info *bss) + +{ + int iVar1; + uint8_t uVar2; + + iVar1 = mac_ie_find(0x20); + uVar2 = '\0'; + if (iVar1 != 0) { + uVar2 = *(uint8_t *)(iVar1 + 2); + } + bss->power_constraint = uVar2; + return; +} + + + +void me_extract_country_reg(int param_1) + +{ + uint16_t *puVar1; + int iVar2; + uint uVar3; + byte *pbVar4; + uint uVar5; + byte bVar6; + uint uVar7; + int iVar8; + + iVar2 = mac_ie_find(7); + if (iVar2 != 0) { + puVar1 = *(uint16_t **)(param_1 + 0x4c); + iVar8 = 1; + if (*(uint8_t *)(puVar1 + 1) != '\0') { + iVar8 = 4; + } + uVar3 = phy_freq_to_channel(*(uint8_t *)(puVar1 + 1),*puVar1); + uVar7 = 5; + while (uVar7 <= (uint)*(byte *)(iVar2 + 1) + 1) { + pbVar4 = (byte *)(uVar7 + iVar2); + uVar5 = (uint)*pbVar4; + bVar6 = 0; + while (bVar6 != pbVar4[1]) { + if (uVar5 == (uVar3 & 0xff)) { + *(byte *)(puVar1 + 2) = pbVar4[2]; + return; + } + bVar6 = bVar6 + 1; + uVar5 = uVar5 + iVar8 & 0xff; + } + uVar7 = uVar7 + 3 & 0xff; + } + } + return; +} + + + +void me_extract_mobility_domain(uint32_t buffer,uint16_t buflen,mac_bss_info *bss) + +{ + int iVar1; + + iVar1 = mac_ie_find(0x36); + if (iVar1 == 0) { + (bss->mde).mdid = 0; + (bss->mde).ft_capability_policy = '\0'; + } + else { + (bss->mde).mdid = *(uint16_t *)(iVar1 + 2); + (bss->mde).ft_capability_policy = *(uint8_t *)(iVar1 + 4); + } + return; +} + + + +uint me_extract_csa(undefined4 param_1,undefined4 param_2,undefined *param_3,int param_4) + +{ + byte bVar1; + byte bVar2; + bool band; + short sVar3; + uint16_t uVar4; + uint16_t uVar5; + uint16_t uVar6; + uint uVar7; + uint uVar8; + int iVar9; + int iVar10; + undefined uVar11; + + uVar7 = mac_ie_find(0x25); + uVar8 = mac_ie_find(param_1,param_2,0x3c); + if ((uVar7 | uVar8) == 0) { + return 0; + } + iVar9 = mac_ie_find(param_1,param_2,0x3e); + iVar10 = mac_ie_find(param_1,param_2,0xc4); + if (iVar10 != 0) { + iVar10 = mac_ie_find(iVar10 + 2,(uint)*(byte *)(iVar10 + 1),0xc2); + } + if (uVar7 == 0) { + bVar1 = *(byte *)(uVar8 + 5); + *param_3 = *(undefined *)(uVar8 + 2); + bVar2 = *(byte *)(uVar8 + 4); + } + else { + bVar1 = *(byte *)(uVar7 + 4); + *param_3 = *(undefined *)(uVar7 + 2); + bVar2 = *(byte *)(uVar7 + 3); + } + uVar7 = (uint)bVar1; + if (bVar1 == 0) { + uVar7 = 2; + } + band = 0xe < bVar2; + uVar4 = phy_channel_to_freq(band,(uint)bVar2); + if (iVar10 != 0) { + uVar8 = (uint)*(byte *)(iVar10 + 2) - 1 & 0xff; + bVar1 = *(byte *)(iVar10 + 4); + uVar11 = 1; + if (uVar8 < 3) { + uVar11 = *(undefined *)((int)&CSWTCH_115 + uVar8); + } + uVar5 = phy_channel_to_freq(band,(uint)*(byte *)(iVar10 + 3)); + uVar6 = 0; + if (bVar1 != 0) { + uVar6 = phy_channel_to_freq(band,(uint)bVar1); + } + goto LAB_2301d0a4; + } + if (iVar9 == 0) { +LAB_2301d106: + uVar6 = 0; + uVar11 = 0; + uVar5 = uVar4; + } + else { + sVar3 = 10; + if (*(char *)(iVar9 + 2) != '\x01') { + if (*(char *)(iVar9 + 2) != '\x03') goto LAB_2301d106; + sVar3 = -10; + } + uVar6 = 0; + uVar11 = 1; + uVar5 = uVar4 + sVar3; + } +LAB_2301d0a4: + *(uint16_t *)(param_4 + 6) = uVar6; + *(bool *)param_4 = band; + *(undefined *)(param_4 + 1) = uVar11; + *(uint16_t *)(param_4 + 2) = uVar4; + *(uint16_t *)(param_4 + 4) = uVar5; + return uVar7; +} + + + +// WARNING: Could not reconcile some variable overlaps + +uint16_t me_build_beacon(uint32_t frame,uint8_t vif_idx,uint16_t *tim_oft,uint8_t *tim_len, + uint8_t hidden_ssid) + +{ + uint8_t enc_type; + short sVar1; + uint16_t uVar2; + uint32_t uVar3; + uint32_t uVar4; + uint32_t uVar5; + uint32_t uVar6; + uint8_t ssid_len; + undefined3 in_register_0000202d; + int iVar7; + uint8_t *p_ssid; + undefined3 in_register_00002039; + uint uVar8; + int iVar9; + undefined *puVar10; + mac_rateset *p_rateset; + uint32_t uStack68; + undefined2 uStack64; + undefined uStack62; + undefined uStack61; + uint8_t wme_ie [16]; + + iVar7 = CONCAT31(in_register_0000202d,vif_idx); + enc_type = vif_info_tab[iVar7].bss_info.sec_type; + *(undefined *)frame = 0x80; + *(undefined *)(frame + 1) = 0; + *(undefined *)(frame + 2) = 0; + *(undefined *)(frame + 3) = 0; + uStack68 = frame; + memcpy((void *)(frame + 4),&mac_addr_bcst,6); + memcpy((void *)(frame + 10),&vif_info_tab[iVar7].mac_addr,6); + memcpy((void *)(frame + 0x10),&vif_info_tab[iVar7].mac_addr,6); + uVar8 = (uint)txl_cntrl_env.seqnbr; + txl_cntrl_env.seqnbr = (uint16_t)((uVar8 + 1) * 0x10000 >> 0x10); + iVar9 = (uVar8 + 1) * 0x100000; + *(undefined *)(frame + 0x16) = (char)((uint)iVar9 >> 0x10); + *(undefined *)(frame + 0x17) = (char)((uint)iVar9 >> 0x18); + uVar2 = vif_info_tab[iVar7].bss_info.beacon_interval; + *(undefined *)(uStack68 + 0x20) = (char)uVar2; + *(undefined *)(uStack68 + 0x21) = (char)(uVar2 >> 8); + uVar2 = me_build_capability(vif_idx); + if (enc_type != '\0') { + uVar2 = uVar2 | 0x10; + } + p_ssid = vif_info_tab[iVar7].bss_info.ssid.array; + *(undefined *)(uStack68 + 0x22) = (char)uVar2; + *(undefined *)(uStack68 + 0x23) = (char)(uVar2 >> 8); + uStack68 = uStack68 + 0x24; + if (CONCAT31(in_register_00002039,hidden_ssid) == 0) { + ssid_len = vif_info_tab[iVar7].bss_info.ssid.length; + } + else { + printf("Using Hidden SSID [%s]\r\n",p_ssid); + p_ssid = (uint8_t *)0x0; + ssid_len = '\0'; + } + uVar3 = me_add_ie_ssid(&uStack68,ssid_len,p_ssid); + p_rateset = &vif_info_tab[iVar7].bss_info.rate_set; + uVar4 = me_add_ie_supp_rates(&uStack68,p_rateset); + uVar8 = (uVar3 + 0x24 & 0xffff) + uVar4 & 0xffff; + if (8 < vif_info_tab[iVar7].bss_info.rate_set.length) { + uVar3 = me_add_ie_ext_supp_rates(&uStack68,p_rateset); + uVar8 = uVar8 + uVar3 & 0xffff; + } + uVar3 = me_add_ie_ds(&uStack68, + (char)((int)((uint)(vif_info_tab[iVar7].bss_info.chan)->freq - 0x96c) / 5) + + '\x01'); + *tim_oft = (uint16_t)((uVar8 + uVar3) * 0x10000 >> 0x10); + uVar4 = me_add_ie_tim(&uStack68,*(uint8_t *)&vif_info_tab[iVar7].bss_info.beacon_period); + *tim_len = (uint8_t)(uVar4 & 0xff); + uVar5 = me_add_ie_rsn(&uStack68,enc_type); + memcpy(int_rsn_ie,(void *)(uStack68 - (uVar5 & 0xff)),uVar5 & 0xff); + uVar6 = me_add_ie_erp(&uStack68,'\0'); + sVar1 = (short)(uVar8 + uVar3) + (short)(uVar4 & 0xff) + (short)uVar6 + ((ushort)uVar5 & 0xff); + if ((vif_info_tab[iVar7].bss_info.valid_flags & 2) != 0) { + uVar3 = me_add_ie_ht_capa(&uStack68); + uVar4 = me_add_ie_ht_oper(&uStack68,vif_info_tab + iVar7); + sVar1 = sVar1 + (short)uVar4 + (short)uVar3; + } + uVar3 = me_add_ie_wpa(&uStack68,enc_type); + uVar2 = sVar1 + (short)uVar3; + if ((vif_info_tab[iVar7].bss_info.valid_flags & 1) != 0) { + memset(&uStack62,0,0xe); + uStack64 = 0x7dd; + uStack61 = 0x50; + wme_ie._0_2_ = 0x2f2; + wme_ie[3] = '\x01'; + wme_ie[4] = vif_info_tab[iVar7].bss_info.edca_param.qos_info; + co_pack8p(uStack68,(uint8_t *)&uStack64,9); + *(char *)(uStack68 + 1) = *(char *)(uStack68 + 1) + '\x11'; + puVar10 = (undefined *)(uStack68 + 2 + (uint)uStack64._1_1_); + *puVar10 = 0; + uVar3 = vif_info_tab[iVar7].txq_params[1]; + puVar10[1] = (char)uVar3; + puVar10[2] = (char)(uVar3 >> 8); + puVar10[3] = (char)(uVar3 >> 0x10); + puVar10[4] = (char)(uVar3 >> 0x18); + uVar3 = vif_info_tab[iVar7].txq_params[0]; + puVar10[5] = (char)uVar3; + puVar10[6] = (char)(uVar3 >> 8); + puVar10[7] = (char)(uVar3 >> 0x10); + puVar10[8] = (char)(uVar3 >> 0x18); + uVar3 = vif_info_tab[iVar7].txq_params[2]; + puVar10[9] = (char)uVar3; + puVar10[10] = (char)(uVar3 >> 8); + puVar10[0xb] = (char)(uVar3 >> 0x10); + puVar10[0xc] = (char)(uVar3 >> 0x18); + uVar3 = vif_info_tab[iVar7].txq_params[3]; + puVar10[0xd] = (char)uVar3; + puVar10[0xe] = (char)(uVar3 >> 8); + puVar10[0xf] = (char)(uVar3 >> 0x10); + puVar10[0x10] = (char)(uVar3 >> 0x18); + uVar2 = uVar2 + (ushort)uStack64._1_1_ + 0x13; + } + return uVar2; +} + + + +// WARNING: Variable defined which should be unmapped: wme_ie +// WARNING: Could not reconcile some variable overlaps + +uint16_t me_build_probe_rsp(uint32_t frame,uint8_t vif_idx) + +{ + uint8_t enc_type; + short sVar1; + uint16_t uVar2; + uint32_t uVar3; + uint32_t uVar4; + int iVar5; + uint32_t uVar6; + undefined3 in_register_0000202d; + int iVar7; + scan_chan_tag *psVar8; + undefined *puVar9; + mac_rateset *p_rateset; + uint32_t uStack52; + undefined2 uStack48; + undefined uStack46; + undefined uStack45; + uint8_t wme_ie [16]; + + iVar7 = CONCAT31(in_register_0000202d,vif_idx); + enc_type = vif_info_tab[iVar7].bss_info.sec_type; + uVar2 = vif_info_tab[iVar7].bss_info.beacon_interval; + *(undefined *)(frame + 8) = (char)uVar2; + *(undefined *)(frame + 9) = (char)(uVar2 >> 8); + uStack52 = frame; + uVar2 = me_build_capability(vif_idx); + if (enc_type != '\0') { + uVar2 = uVar2 | 0x10; + } + *(undefined *)(uStack52 + 10) = (char)uVar2; + *(undefined *)(uStack52 + 0xb) = (char)(uVar2 >> 8); + uStack52 = uStack52 + 0xc; + p_rateset = &vif_info_tab[iVar7].bss_info.rate_set; + uVar3 = me_add_ie_ssid(&uStack52,vif_info_tab[iVar7].bss_info.ssid.length, + vif_info_tab[iVar7].bss_info.ssid.array); + uVar4 = me_add_ie_supp_rates(&uStack52,p_rateset); + sVar1 = (short)uVar3 + (short)uVar4 + 0xc; + if (8 < vif_info_tab[iVar7].bss_info.rate_set.length) { + uVar3 = me_add_ie_ext_supp_rates(&uStack52,p_rateset); + sVar1 = sVar1 + (short)uVar3; + } + psVar8 = vif_info_tab[iVar7].bss_info.chan; + iVar5 = phy_freq_to_channel(psVar8->band,psVar8->freq); + uVar3 = me_add_ie_ds(&uStack52,(uint8_t)iVar5); + uVar4 = me_add_ie_rsn(&uStack52,enc_type); + uVar6 = me_add_ie_erp(&uStack52,'\0'); + sVar1 = sVar1 + (short)uVar4 + (short)uVar3 + (short)uVar6; + if ((vif_info_tab[iVar7].bss_info.valid_flags & 2) != 0) { + uVar3 = me_add_ie_ht_capa(&uStack52); + uVar4 = me_add_ie_ht_oper(&uStack52,vif_info_tab + iVar7); + sVar1 = sVar1 + (short)uVar4 + (short)uVar3; + } + uVar3 = me_add_ie_wpa(&uStack52,enc_type); + uVar2 = sVar1 + (short)uVar3; + if ((vif_info_tab[iVar7].bss_info.valid_flags & 1) != 0) { + memset(&uStack46,0,0xe); + uStack48 = 0x7dd; + uStack45 = 0x50; + wme_ie._0_2_ = 0x2f2; + wme_ie[3] = '\x01'; + wme_ie[4] = vif_info_tab[iVar7].bss_info.edca_param.qos_info; + co_pack8p(uStack52,(uint8_t *)&uStack48,9); + *(char *)(uStack52 + 1) = *(char *)(uStack52 + 1) + '\x11'; + puVar9 = (undefined *)(uStack52 + 2 + (uint)uStack48._1_1_); + *puVar9 = 0; + uVar3 = vif_info_tab[iVar7].txq_params[1]; + puVar9[1] = (char)uVar3; + puVar9[2] = (char)(uVar3 >> 8); + puVar9[3] = (char)(uVar3 >> 0x10); + puVar9[4] = (char)(uVar3 >> 0x18); + uVar3 = vif_info_tab[iVar7].txq_params[0]; + puVar9[5] = (char)uVar3; + puVar9[6] = (char)(uVar3 >> 8); + puVar9[7] = (char)(uVar3 >> 0x10); + puVar9[8] = (char)(uVar3 >> 0x18); + uVar3 = vif_info_tab[iVar7].txq_params[2]; + puVar9[9] = (char)uVar3; + puVar9[10] = (char)(uVar3 >> 8); + puVar9[0xb] = (char)(uVar3 >> 0x10); + puVar9[0xc] = (char)(uVar3 >> 0x18); + uVar3 = vif_info_tab[iVar7].txq_params[3]; + puVar9[0xd] = (char)uVar3; + puVar9[0xe] = (char)(uVar3 >> 8); + puVar9[0xf] = (char)(uVar3 >> 0x10); + puVar9[0x10] = (char)(uVar3 >> 0x18); + uVar2 = uVar2 + (ushort)uStack48._1_1_ + 0x13; + } + return uVar2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +uint16_t me_build_associate_rsp + (uint32_t frame,uint8_t vif_idx,uint16_t status_code,me_sta_add_req *req) + +{ + uint8_t uVar1; + ushort uVar2; + uint16_t uVar3; + uint32_t uVar4; + uint32_t uVar5; + undefined3 in_register_0000202d; + int iVar6; + undefined2 in_register_00002032; + undefined *puStack52; + undefined2 uStack48; + undefined uStack46; + undefined uStack45; + uint8_t wme_ie [16]; + + iVar6 = CONCAT31(in_register_0000202d,vif_idx); + uVar1 = vif_info_tab[iVar6].bss_info.sec_type; + puStack52 = (undefined *)frame; + uVar3 = me_build_capability(vif_idx); + if (uVar1 != '\0') { + uVar3 = uVar3 | 0x10; + } + *puStack52 = (char)uVar3; + puStack52[1] = (char)(uVar3 >> 8); + uVar3 = 6; + puStack52[2] = (char)status_code; + puStack52[3] = (char)(status_code >> 8); + uVar2 = req->aid; + puStack52[4] = (char)uVar2; + puStack52[5] = (byte)((uint)uVar2 >> 8) | 0xc0; + puStack52 = puStack52 + 6; + if (CONCAT22(in_register_00002032,status_code) == 0) { + uVar4 = me_add_ie_supp_rates((uint32_t *)&puStack52,&req->rate_set); + uVar3 = (short)uVar4 + 6; + if (8 < (req->rate_set).length) { + uVar4 = me_add_ie_ext_supp_rates((uint32_t *)&puStack52,&req->rate_set); + uVar3 = uVar3 + (short)uVar4; + } + if ((req->flags & 2) != 0) { + uVar4 = me_add_ie_ht_capa((uint32_t *)&puStack52); + uVar5 = me_add_ie_ht_oper((uint32_t *)&puStack52,vif_info_tab + iVar6); + uVar3 = uVar3 + (short)uVar5 + (short)uVar4; + } + if ((req->flags & 1) != 0) { + memset(&uStack46,0,0xe); + uStack48 = 0x7dd; + uStack45 = 0x50; + wme_ie._0_2_ = 0x2f2; + wme_ie[3] = '\x01'; + wme_ie[4] = vif_info_tab[iVar6].bss_info.edca_param.qos_info; + co_pack8p((uint32_t)puStack52,(uint8_t *)&uStack48,9); + puStack52[1] = puStack52[1] + '\x11'; + puStack52 = puStack52 + (uint)uStack48._1_1_ + 2; + *puStack52 = 0; + uVar4 = vif_info_tab[iVar6].txq_params[1]; + puStack52[1] = (char)uVar4; + puStack52[2] = (char)(uVar4 >> 8); + puStack52[3] = (char)(uVar4 >> 0x10); + puStack52[4] = (char)(uVar4 >> 0x18); + uVar4 = vif_info_tab[iVar6].txq_params[0]; + puStack52[5] = (char)uVar4; + puStack52[6] = (char)(uVar4 >> 8); + puStack52[7] = (char)(uVar4 >> 0x10); + puStack52[8] = (char)(uVar4 >> 0x18); + uVar4 = vif_info_tab[iVar6].txq_params[2]; + puStack52[9] = (char)uVar4; + puStack52[10] = (char)(uVar4 >> 8); + puStack52[0xb] = (char)(uVar4 >> 0x10); + puStack52[0xc] = (char)(uVar4 >> 0x18); + uVar4 = vif_info_tab[iVar6].txq_params[3]; + puStack52[0xd] = (char)uVar4; + puStack52[0xe] = (char)(uVar4 >> 8); + puStack52[0xf] = (char)(uVar4 >> 0x10); + puStack52[0x10] = (char)(uVar4 >> 0x18); + uVar3 = uVar3 + (ushort)uStack48._1_1_ + 0x13; + } + } + return uVar3; +} + + + +int me_rc_set_rate_req_handler + (ke_msg_id_t msgid,me_rc_set_rate_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + byte bVar1; + uint16_t fixed_rate_config; + rc_sta_stats *rc_ss; + _Bool _Var2; + undefined3 extraout_var; + + bVar1 = param->sta_idx; + rc_ss = sta_info_tab[bVar1].pol_tbl.sta_stats; + if (rc_ss == (rc_sta_stats *)0x0) { + assert_err("rc_ss != NULL","module",0x31d); + } + fixed_rate_config = param->fixed_rate_cfg; + if (fixed_rate_config == 0xffff) { + rc_ss->fixed_rate_cfg = 0xffff; + rc_ss->info = rc_ss->info & 0x9f; + rc_update_bw_nss_max(sta_info_tab[bVar1].staid,rc_ss->bw_max,rc_ss->no_ss); + } + else { + _Var2 = rc_check_fixed_rate_config(rc_ss,fixed_rate_config); + if (CONCAT31(extraout_var,_Var2) != 0) { + rc_ss->fixed_rate_cfg = fixed_rate_config; + rc_ss->info = rc_ss->info & 0x9f | 0x20; + } + } + return 0; +} + + + +int me_rc_stats_req_handler + (ke_msg_id_t msgid,me_rc_stats_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + rc_sta_stats *rc_ss; + byte *pbVar1; + uint32_t uVar2; + uint uVar3; + + pbVar1 = (byte *)ke_msg_alloc(0x140f,src_id,dest_id,0xd0); + rc_ss = sta_info_tab[param->sta_idx].pol_tbl.sta_stats; + *pbVar1 = param->sta_idx; + if (rc_ss == (rc_sta_stats *)0x0) { + *(undefined2 *)(pbVar1 + 2) = 0; + } + else { + *(uint16_t *)(pbVar1 + 2) = rc_ss->no_samples; + uVar3 = 0; + *(uint16_t *)(pbVar1 + 4) = rc_ss->ampdu_len; + *(uint16_t *)(pbVar1 + 6) = rc_ss->ampdu_packets; + *(uint32_t *)(pbVar1 + 8) = rc_ss->avg_ampdu_len; + pbVar1[0xc] = rc_ss->sw_retry_step; + pbVar1[0xd] = rc_ss->sample_wait; + memcpy(pbVar1 + 0x10,rc_ss->retry,0x20); + memcpy(pbVar1 + 0x30,rc_ss->rate_stats,0x78); + while (uVar3 < rc_ss->no_samples) { + uVar2 = rc_calc_tp(rc_ss,(uint8_t)uVar3); + *(uint32_t *)(pbVar1 + (uVar3 + 0x28) * 4 + 8) = uVar2; + uVar3 = uVar3 + 1 & 0xffff; + } + } + ke_msg_send(pbVar1); + return 0; +} + + + +int me_traffic_ind_req_handler + (ke_msg_id_t msgid,me_traffic_ind_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint uVar1; + uint16_t *puVar2; + sta_ps_traffic sVar3; + sta_ps_traffic sVar4; + + uVar1 = (uint)param->sta_idx; + sVar4 = sta_info_tab[uVar1].traffic_avail; + if (param->uapsd == false) { + if (param->tx_avail == '\0') { + sVar4 = sVar4 & ~PS_TRAFFIC_HOST; + } + else { + sVar4 = sVar4 | PS_TRAFFIC_HOST; + } + sta_info_tab[uVar1].traffic_avail = sVar4; + } + else { + sVar3 = sVar4 & ~UAPSD_TRAFFIC_HOST; + if (param->tx_avail != '\0') { + sVar3 = sVar4 | UAPSD_TRAFFIC_HOST; + } + sta_info_tab[uVar1].traffic_avail = sVar3; + if (sta_info_tab[uVar1].info.uapsd_queues != '\x0f') goto LAB_2301da64; + } + puVar2 = (uint16_t *)ke_msg_alloc(0x41,0,5,4); + *puVar2 = sta_info_tab[uVar1].aid; + *(uint8_t *)((int)puVar2 + 3) = sta_info_tab[uVar1].inst_nbr; + *(uint8_t *)(puVar2 + 1) = param->tx_avail; + ke_msg_send(); +LAB_2301da64: + ke_msg_send_basic(0x140d,src_id,dest_id); + return 0; +} + + + +int me_sta_del_req_handler + (ke_msg_id_t msgid,me_sta_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t *puVar1; + undefined *puVar2; + + puVar1 = (uint8_t *)ke_msg_alloc(0xc,0,5,1); + *puVar1 = param->sta_idx; + ke_msg_send(); + if (param->tdls_sta != false) { + puVar2 = (undefined *)ke_msg_alloc(0x1413,5,6,2); + *puVar2 = 0; + puVar2[1] = sta_info_tab[param->sta_idx].inst_nbr; + ke_msg_send(); + } + ke_msg_send_basic(0x140a,src_id,dest_id); + return 0; +} + + + +int me_set_control_port_req_handler + (ke_msg_id_t msgid,me_set_control_port_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + byte bVar1; + undefined *puVar2; + uint8_t uVar3; + uint uVar4; + + uVar4 = (uint)param->sta_idx; + bVar1 = sta_info_tab[uVar4].inst_nbr; + uVar3 = (param->control_port_open != false) + '\x01'; + sta_info_tab[uVar4].ctrl_port_state = uVar3; + if ((vif_info_tab[bVar1].type == '\0') && (uVar3 == '\x02')) { + puVar2 = (undefined *)ke_msg_alloc(0x1413,5,6,2); + *puVar2 = 0; + puVar2[1] = sta_info_tab[uVar4].inst_nbr; + ke_msg_send(); + } + ke_msg_send_basic(0x1405,src_id,dest_id); + return 0; +} + + + +int me_chan_config_req_handler + (ke_msg_id_t msgid,me_chan_config_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + memcpy(&me_env.chan,param,0xfe); + ke_msg_send_basic(0x1403,src_id,dest_id); + return 0; +} + + + +int mm_set_ps_mode_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(dest_id); + if (CONCAT22(extraout_var,kVar1) != 1) { + assert_err("ke_state_get(dest_id) == ME_BUSY","module",699); + } + if (me_env.requester_id != 0xff) { + ke_msg_send_basic(0x1414,me_env.requester_id,dest_id); + } + ke_state_set(dest_id,0); + return 0; +} + + + +int mm_set_idle_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(dest_id); + if (CONCAT22(extraout_var,kVar1) != 1) { + assert_err("ke_state_get(dest_id) == ME_BUSY","module",0x252); + } + if (me_env.requester_id != 0xff) { + ke_msg_send_basic(0x1412,me_env.requester_id,dest_id); + } + ke_state_set(dest_id,0); + return 0; +} + + + +int me_config_req_handler + (ke_msg_id_t msgid,me_config_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t uVar1; + undefined *puVar2; + undefined3 extraout_var; + + puVar2 = (undefined *)ke_msg_alloc(0x31,0,5,1); + me_env.ht_supported = param->ht_supp; + memcpy(&me_env.ht_cap,param,0x20); + ke_msg_send_basic(0x1401,src_id,dest_id); + if (me_env.ht_supported == false) { + me_env._302_2_ = 0; + } + else { + uVar1 = phy_get_nss(); + me_env._302_2_ = + CONCAT11((char)(me_env.ht_cap.ht_capa_info >> 1), + (char)(CONCAT31(extraout_var,uVar1) + 1 >> 1)) & 0x1ff; + } + me_env.tx_lft = param->tx_lft; + me_env.ps_on = param->ps_on; + if (me_env.ps_on != false) { + me_env.requester_id = 0xff; + *puVar2 = 2; + ke_msg_send(puVar2); + ke_state_set(5,1); + } + return 0; +} + + + +int me_set_ps_disable_req_handler + (ke_msg_id_t msgid,me_set_ps_disable_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + char *pcVar2; + + if (me_env.ps_on != false) { + kVar1 = ke_state_get(5); + if (CONCAT22(extraout_var,kVar1) == 1) { + return 2; + } + if (me_env.ps_disable_vifs == 0) { + if (param->ps_disable != false) goto LAB_2301ddaa; + } + else { + if (param->ps_disable == false) { +LAB_2301ddaa: + pcVar2 = (char *)ke_msg_alloc(0x31,0,dest_id,1); + if (param->ps_disable == false) { + me_env.ps_disable_vifs = ~(1 << ((uint)param->vif_idx & 0x1f)) & me_env.ps_disable_vifs; + } + else { + me_env.ps_disable_vifs = 1 << ((uint)param->vif_idx & 0x1f) | me_env.ps_disable_vifs; + } + me_env.requester_id = src_id; + *pcVar2 = (me_env.ps_disable_vifs == 0) << 1; + ke_msg_send(); + ke_state_set(dest_id,1); + return 0; + } + me_env.ps_disable_vifs = 1 << ((uint)param->vif_idx & 0x1f) | me_env.ps_disable_vifs; + } + } + ke_msg_send_basic(0x1414,src_id,dest_id); + return 0; +} + + + +int me_set_active_req_handler + (ke_msg_id_t msgid,me_set_active_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + void *pvVar2; + + kVar1 = ke_state_get(5); + if (CONCAT22(extraout_var,kVar1) == 1) { + return 2; + } + if (me_env.active_vifs == 0) { + if (param->active != false) goto LAB_2301de44; + } + else { + if (param->active == false) { +LAB_2301de44: + pvVar2 = ke_msg_alloc(0x22,0,dest_id,1); + if (param->active == false) { + me_env.active_vifs = ~(1 << ((uint)param->vif_idx & 0x1f)) & me_env.active_vifs; + } + else { + me_env.active_vifs = 1 << ((uint)param->vif_idx & 0x1f) | me_env.active_vifs; + } + me_env.requester_id = src_id; + *(bool *)pvVar2 = me_env.active_vifs == 0; + ke_msg_send(); + ke_state_set(dest_id,1); + return 0; + } + me_env.active_vifs = 1 << ((uint)param->vif_idx & 0x1f) | me_env.active_vifs; + } + ke_msg_send_basic(0x1412,src_id,dest_id); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int me_sta_add_req_handler + (ke_msg_id_t msgid,me_sta_add_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + byte bVar1; + byte bVar2; + _Bool _Var3; + byte *sta_idx; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined *puVar4; + undefined3 extraout_var_01; + uint uVar5; + uint uVar6; + uint uVar7; + int iVar8; + uint8_t uStack81; + uint8_t hw_sta_idx; + uint32_t uStack80; + mm_sta_add_req sta_add_req; + + sta_idx = (byte *)ke_msg_alloc(0x1408,src_id,dest_id,3); + bVar1 = rxu_cntrl_get_pm(); + sta_add_req.mac_addr.array[1]._1_1_ = param->vif_idx; + uVar7 = (uint)sta_add_req.mac_addr.array[1]._1_1_; + if ((param->flags & 2) == 0) { + sta_add_req.mac_addr.array[1]._0_1_ = '\0'; + sta_add_req.paid_gid._0_2_ = 0; + } + else { + uVar5 = (uint)(param->ht_cap).a_mpdu_param; + sta_add_req.mac_addr.array[1]._0_1_ = '\x01'; + uVar6 = (int)uVar5 >> 2 & 7; + if (2 < uVar6) { + sta_add_req.mac_addr.array[1]._0_1_ = (uint8_t)(1 << (uVar6 - 3 & 0x1f)); + } + sta_add_req.paid_gid._0_2_ = (short)(1 << (uVar5 & 3) + 0xd) - 1; + } + sta_add_req.ampdu_size_max_vht = 0; + memcpy((void *)((int)&sta_add_req.paid_gid + 2),param,6); + sta_add_req.mac_addr.array[2]._1_1_ = param->rssi; + sta_add_req._16_4_ = param->tsflo; + sta_add_req.tsflo = param->tsfhi; + uStack80 = 0; + sta_add_req.tsfhi._0_1_ = param->data_rate; + bVar2 = mm_sta_add((mm_sta_add_req *)&stack0xffffffb0,sta_idx,&uStack81); + sta_idx[1] = bVar2; + if (CONCAT31(extraout_var_00,bVar2) != 0) goto LAB_2301e0aa; + uVar5 = (uint)*sta_idx; + memcpy(&sta_info_tab[uVar5].info,¶m->rate_set,0xd); + if ((param->flags & 1) == 0) { +LAB_2301dfac: + iVar8 = 0; + } + else { + uVar6 = sta_info_tab[uVar5].info.capa_flags; + sta_info_tab[uVar5].info.capa_flags = uVar6 | 1; + if (((param->flags & 2) == 0) || (me_env.ht_supported == false)) goto LAB_2301dfac; + sta_info_tab[uVar5].info.capa_flags = uVar6 | 3; + memcpy(&sta_info_tab[uVar5].info.ht_cap,¶m->ht_cap,0x20); + _Var3 = me_set_sta_ht_vht_param(sta_info_tab + uVar5,&vif_info_tab[uVar7].bss_info); + iVar8 = CONCAT31(extraout_var_01,_Var3); + } + sta_info_tab[uVar5].info.uapsd_queues = param->uapsd_queues; + sta_info_tab[uVar5].info.max_sp_len = param->max_sp_len; + sta_info_tab[uVar5].aid = param->aid; + me_init_rate(sta_info_tab + uVar5); + if (((param->flags & 0x10) != 0) && (bVar2 = param->opmode, -1 < (char)bVar2)) { + me_sta_bw_nss_max_upd(sta_info_tab[uVar5].staid,bVar2 & 3,bVar2 >> 4); + } + if (iVar8 != 0) { + me_sta_bw_nss_max_upd(sta_info_tab[uVar5].staid,-1,'\0'); + } + sta_info_tab[uVar5].pol_tbl.upd_field = sta_info_tab[uVar5].pol_tbl.upd_field | 0x10; + sta_info_tab[uVar5].ctrl_port_state = ((vif_info_tab[uVar7].flags & 1) == 0) + '\x01'; + sta_info_tab[uVar5].ctrl_port_ethertype = + *(ushort *)(vif_info_tab[uVar7].u + 0x2f0) >> 8 | + *(ushort *)(vif_info_tab[uVar7].u + 0x2f0) << 8; + sta_idx[2] = bVar1; + if (CONCAT31(extraout_var,bVar1) != 0) { + sta_info_tab[uVar5].ps_state = bVar1; + if (vif_info_tab[uVar7].u[0x2ee] == 0) { + uVar5 = (uint)vif_info_tab[uVar7].index + 10 & 0xff; + puVar4 = (undefined *)ke_msg_alloc(0x49,0xd,0,2); + sta_info_tab[uVar5].ps_state = '\x01'; + *puVar4 = (char)uVar5; + puVar4[1] = 1; + ke_msg_send(); + } + vif_info_tab[uVar7].u[0x2ee] = vif_info_tab[uVar7].u[0x2ee] + 1; + } +LAB_2301e0aa: + ke_msg_send(sta_idx); + return 0; +} + + + +void cfm_raw_send(void *env,uint32_t status) + +{ + printf("send complete, status is %08lX\r\n"); + return; +} + + + +int scanu_raw_send_req_handler + (ke_msg_id_t msgid,scanu_raw_send_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + size_t __n; + txl_frame_desc_tag *frame; + tx_hw_desc *ptVar1; + void *__src; + + printf("[FW] pkt address is %p, len is %lu\r\n",param->pkt,param->len); + scanu_raw_send_cfm('\0',src_id); + __src = param->pkt; + __n = param->len; + frame = txl_frame_get(0,0x100); + if (frame != (txl_frame_desc_tag *)0x0) { + memcpy((frame->txdesc).lmac.buffer + 1,__src,__n); + (frame->txdesc).host.staid = -1; + (frame->cfm).cfm_func = cfm_raw_send; + ptVar1 = (frame->txdesc).lmac.hw_desc; + (frame->txdesc).host.vif_idx = '\0'; + (frame->txdesc).umac.head_len = '\0'; + (frame->txdesc).umac.tail_len = '\0'; + *(txl_frame_desc_tag **)&(frame->cfm).env = frame; + (ptVar1->thd).field_5 = (ptVar1->thd).field_4 + (__n - 1); + (ptVar1->thd).frmlen = __n + 4; + txl_frame_push_force(frame,'\x03'); + } + return 0; +} + + + +int scanu_join_req_handler + (ke_msg_id_t msgid,scanu_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + vif_info_tab[param->vif_idx].bss_info.valid_flags = 0; + scanu_env._362_2_ = 1; + scanu_env.bssid.array._0_4_ = *(undefined4 *)(param->bssid).array; + scanu_env.bssid.array[2] = (param->bssid).array[2]; + scanu_env.param = param; + scanu_env.src_id = src_id; + if ((*(byte *)(param->bssid).array & 1) != 0) { + assert_err("!MAC_ADDR_GROUP(¶m->bssid)","module",0xb6); + } + scanu_start(); + return 1; +} + + + +int scanu_start_req_handler + (ke_msg_id_t msgid,scanu_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined2 in_register_0000202a; + + scanu_env._362_2_ = 0; + scanu_env.bssid.array._0_4_ = *(undefined4 *)(param->bssid).array; + scanu_env.bssid.array[2] = (param->bssid).array[2]; + scanu_env.param = param; + scanu_env.src_id = src_id; + scanu_start(CONCAT22(in_register_0000202a,msgid)); + return 1; +} + + + +int rxu_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + int iVar1; + + iVar1 = scanu_frame_handler(param); + return iVar1; +} + + + +int scan_done_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined2 in_register_0000202a; + + scanu_env.band = scanu_env.band + '\x01'; + scanu_scan_next(CONCAT22(in_register_0000202a,msgid)); + return 0; +} + + + +int scan_start_cfm_handler + (ke_msg_id_t msgid,scan_start_cfm *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + if (param->status != '\0') { + scanu_confirm(param->status); + return 0; + } + return 0; +} + + + +int me_set_ps_disable_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined2 extraout_var_02; + + kVar1 = ke_state_get(6); + if (((CONCAT22(extraout_var,kVar1) != 4) && + (kVar1 = ke_state_get(6), CONCAT22(extraout_var_00,kVar1) != 0)) && + (kVar1 = ke_state_get(6), CONCAT22(extraout_var_01,kVar1) != 8)) { + assert_err( + "(ke_state_get(TASK_SM) == SM_BSS_PARAM_SETTING) || (ke_state_get(TASK_SM) == SM_IDLE) || (ke_state_get(TASK_SM) == SM_DISCONNECTING)" + ,"module",0x1db); + } + kVar1 = ke_state_get(6); + if (CONCAT22(extraout_var_02,kVar1) == 4) { + sm_send_next_bss_param(); + } + return 0; +} + + + +int mm_bss_param_setting_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(6); + if (CONCAT22(extraout_var,kVar1) != 4) { + assert_err("ke_state_get(TASK_SM) == SM_BSS_PARAM_SETTING","module",0x1fa); + } + sm_send_next_bss_param(); + return 0; +} + + + +int sm_rsp_timeout_ind_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + undefined2 extraout_var_00; + + kVar1 = ke_state_get(6); + if ((CONCAT22(extraout_var,kVar1) == 5) || + (kVar1 = ke_state_get(6), CONCAT22(extraout_var_00,kVar1) == 6)) { + sm_connect_ind(0xb); + } + return 0; +} + + + +int scanu_start_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + mac_addr *pmStack24; + mac_addr *bssid; + scan_chan_tag *chan; + + pmStack24 = (mac_addr *)0x0; + bssid = (mac_addr *)0x0; + kVar1 = ke_state_get(6); + if (CONCAT22(extraout_var,kVar1) != 1) { + assert_err("ke_state_get(TASK_SM) == SM_SCANNING","module",0x10a); + } + sm_get_bss_params(&pmStack24,(scan_chan_tag **)&bssid); + if ((pmStack24 == (mac_addr *)0x0) || ((scan_chan_tag *)bssid == (scan_chan_tag *)0x0)) { + sm_connect_ind(0xc); + } + else { + sm_join_bss(pmStack24,(scan_chan_tag *)bssid,false); + } + return 0; +} + + + +int mm_connection_loss_ind_handler + (ke_msg_id_t msgid,mm_connection_loss_ind *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + int iVar1; + ke_state_t kVar2; + undefined2 extraout_var; + uint uVar3; + + uVar3 = (uint)param->inst_nbr; + kVar2 = ke_state_get(6); + iVar1 = 2; + if (CONCAT22(extraout_var,kVar2) == 0) { + iVar1 = 0; + if ((vif_info_tab[uVar3].type == '\0') && (vif_info_tab[uVar3].active != false)) { + ke_state_set(6,8); + sm_disconnect_process(vif_info_tab + uVar3,0x10); + } + } + return iVar1; +} + + + +int scanu_join_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + sm_connect_req *psVar1; + uint8_t uVar2; + ke_state_t kVar3; + undefined2 extraout_var_00; + undefined3 extraout_var; + void *pvVar4; + undefined uVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint8_t auStack33 [4]; + uint8_t chan_idx; + + psVar1 = sm_env.connect_param; + kVar3 = ke_state_get(6); + if (CONCAT22(extraout_var_00,kVar3) != 2) { + assert_err("ke_state_get(TASK_SM) == SM_JOINING","module",0x134); + } + uVar8 = (uint)psVar1->vif_idx; + if ((int)vif_info_tab[uVar8].bss_info.valid_flags < 0) { + uVar2 = sm_add_chan_ctx(auStack33); + if (CONCAT31(extraout_var,uVar2) == 0) { + pvVar4 = ke_msg_alloc(10,0,6,0x20); + chan_ctxt_link(psVar1->vif_idx,auStack33[0]); + *(uint8_t *)((int)pvVar4 + 0x11) = psVar1->vif_idx; + memcpy((void *)((int)pvVar4 + 10),&vif_info_tab[uVar8].bss_info.bssid,6); + *(undefined *)((int)pvVar4 + 0x12) = 0; + if ((vif_info_tab[uVar8].bss_info.valid_flags & 2) != 0) { + uVar6 = (uint)vif_info_tab[uVar8].bss_info.ht_cap.a_mpdu_param; + uVar5 = 1; + uVar7 = (int)uVar6 >> 2 & 7; + if (2 < uVar7) { + uVar5 = (undefined)(1 << (uVar7 - 3 & 0x1f)); + } + *(undefined *)((int)pvVar4 + 0x10) = uVar5; + *(short *)((int)pvVar4 + 8) = (short)(1 << (uVar6 & 3) + 0xd) + -1; + } + *(undefined4 *)((int)pvVar4 + 4) = 0; + ke_msg_send(pvVar4); + ke_state_set(6,3); + } + else { + sm_connect_ind(0xd); + } + vif_info_tab[uVar8].flags = psVar1->flags; + if ((psVar1->flags & 4) != 0) { + vif_info_tab[uVar8].bss_info.valid_flags = + vif_info_tab[uVar8].bss_info.valid_flags & 0xfffffff9; + } + } + else { + if (sm_env.join_passive == false) { + sm_connect_ind(0xe); + } + else { + sm_join_bss(&vif_info_tab[uVar8].bss_info.bssid,vif_info_tab[uVar8].bss_info.chan,true); + } + } + return 0; +} + + + +// WARNING: Variable defined which should be unmapped: chan + +int sm_connect_req_handler + (ke_msg_id_t msgid,sm_connect_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + int iVar1; + ke_state_t kVar2; + undefined2 extraout_var; + undefined *puVar3; + undefined2 extraout_var_00; + undefined uVar4; + uint uVar5; + mac_addr *pmStack40; + mac_addr *bssid; + scan_chan_tag *chan; + + pmStack40 = (mac_addr *)0x0; + bssid = (mac_addr *)0x0; + uVar5 = (uint)param->vif_idx; + kVar2 = ke_state_get(6); + if (CONCAT22(extraout_var,kVar2) == 8) { + return 2; + } + puVar3 = (undefined *)ke_msg_alloc(0x1801,src_id,dest_id,1); + kVar2 = ke_state_get(6); + if (CONCAT22(extraout_var_00,kVar2) == 0) { + if ((vif_info_tab[uVar5].type == '\0') && (vif_info_tab[uVar5].active == false)) { + if (param->auth_type != '\x02') { + if (vif_info_tab[uVar5].u[4] != 0xff) { + assert_err("vif->u.sta.ap_id == INVALID_STA_IDX","module",0x59); + } + if (vif_info_tab[uVar5].chan_ctxt != (chan_ctxt_tag *)0x0) { + assert_err("vif->chan_ctxt == NULL","module",0x5a); + } + } + } + else { + if (param->auth_type != '\x02') { + iVar1 = 0; + uVar4 = 9; + goto LAB_2301e67e; + } + } + if (sm_env.connect_param != (sm_connect_req *)0x0) { + assert_err("NULL == sm_env.connect_param","module",0x5d); + } + sm_env.connect_param = param; + if (sm_env.connect_ind != (sm_connect_ind *)0x0) { + assert_err("NULL == sm_env.connect_ind","module",0x61); + } + sm_env.connect_ind = (sm_connect_ind *)ke_msg_alloc(0x1802,src_id,dest_id,0x354); + sm_env.exist_ssid_idx = -1; + sm_env.ft_over_ds = false; + printf("connecting using vif_idx %u\r\n",(uint)param->vif_idx); + if (param->auth_type == '\x02') { + sm_env.ft_over_ds = true; + memcpy(&sm_env.ft_old_bssid,&vif_info_tab[param->vif_idx].bssid,6); + ke_state_set(6,8); + sm_disconnect_process(vif_info_tab + param->vif_idx,0); + } + else { + if ((param->chan).freq == 0xffff) { + sm_get_bss_params(&pmStack40,(scan_chan_tag **)&bssid); + } + else { + pmStack40 = ¶m->bssid; + bssid = (mac_addr *)¶m->chan; + } + if ((pmStack40 == (mac_addr *)0x0) || ((scan_chan_tag *)bssid == (scan_chan_tag *)0x0)) { + sm_scan_bss(pmStack40,(scan_chan_tag *)bssid); + } + else { + sm_join_bss(pmStack40,(scan_chan_tag *)bssid,false); + } + } + iVar1 = 1; + uVar4 = 0; + } + else { + iVar1 = 0; + uVar4 = 8; + } +LAB_2301e67e: + *puVar3 = uVar4; + ke_msg_send(puVar3); + return iVar1; +} + + + +int rxu_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + int iVar2; + ushort uVar3; + + uVar3 = param->framectrl & 0xfc; + if (uVar3 == 0xb0) { + kVar1 = ke_state_get(6); + if (CONCAT22(extraout_var,kVar1) == 5) { + sm_auth_handler(param); + } + } + else { + if ((uVar3 == 0x10) || (uVar3 == 0x30)) { + kVar1 = ke_state_get(6); + if (CONCAT22(extraout_var_00,kVar1) == 6) { + sm_assoc_rsp_handler(param); + } + } + else { + if (((uVar3 == 0xc0) || (uVar3 == 0xa0)) && + (kVar1 = ke_state_get(6), CONCAT22(extraout_var_01,kVar1) == 0)) { + iVar2 = sm_deauth_handler(param); + return iVar2; + } + } + } + return 0; +} + + + +int mm_set_vif_state_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + byte bVar1; + sm_connect_req *psVar2; + ke_state_t kVar3; + undefined2 extraout_var; + uint8_t *puVar4; + undefined *puVar5; + uint8_t uVar6; + uint uVar7; + + kVar3 = ke_state_get(6); + psVar2 = sm_env.connect_param; + if (CONCAT22(extraout_var,kVar3) == 7) { + uVar7 = (uint)(sm_env.connect_param)->vif_idx; + bVar1 = vif_info_tab[uVar7].u[4]; + puVar4 = (uint8_t *)ke_msg_alloc(0x4b,0,6,6); + *(_Bool *)(puVar4 + 4) = psVar2->dont_wait_bcmc; + *(uint16_t *)(puVar4 + 2) = psVar2->listen_interval; + *puVar4 = psVar2->vif_idx; + ke_msg_send(); + uVar6 = ((vif_info_tab[uVar7].flags & 1) == 0) + '\x01'; + sta_info_tab[bVar1].ctrl_port_state = uVar6; + sta_info_tab[bVar1].ctrl_port_ethertype = + psVar2->ctrl_port_ethertype >> 8 | psVar2->ctrl_port_ethertype << 8; + if (uVar6 == '\x02') { + puVar5 = (undefined *)ke_msg_alloc(0x1413,5,6,2); + *puVar5 = 0; + puVar5[1] = psVar2->vif_idx; + ke_msg_send(); + } + if ((*(uint *)&vif_info_tab[uVar7].bss_info.is_supplicant_enabled & 0x12800) == 0) { + sm_connect_ind(0); + } + } + return 0; +} + + + +int me_set_active_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + mac_addr *pmStack24; + mac_addr *bssid; + scan_chan_tag *chan; + + kVar1 = ke_state_get(6); + if ((CONCAT22(extraout_var,kVar1) != 4) && + (kVar1 = ke_state_get(6), CONCAT22(extraout_var_00,kVar1) != 8)) { + assert_err( + "(ke_state_get(TASK_SM) == SM_BSS_PARAM_SETTING) || (ke_state_get(TASK_SM) == SM_DISCONNECTING)" + ,"module",0x216); + } + kVar1 = ke_state_get(6); + if (CONCAT22(extraout_var_01,kVar1) == 8) { + if (sm_env.ft_over_ds == false) { + ke_state_set(6,0); + } + else { + pmStack24 = (mac_addr *)0x0; + bssid = (mac_addr *)0x0; + sm_get_bss_params(&pmStack24,(scan_chan_tag **)&bssid); + sm_join_bss(pmStack24,(scan_chan_tag *)bssid,false); + } + } + else { + if (sm_env.ft_over_ds == false) { + sm_auth_send(1,(uint32_t *)0x0); + } + else { + sm_assoc_req_send(); + } + } + return 0; +} + + + +int mm_sta_add_cfm_handler + (ke_msg_id_t msgid,mm_sta_add_cfm *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint uVar1; + ke_state_t kVar2; + undefined2 extraout_var; + uint uVar3; + uint uVar4; + + kVar2 = ke_state_get(6); + if (CONCAT22(extraout_var,kVar2) != 3) { + assert_err("ke_state_get(TASK_SM) == SM_STA_ADDING","module",0x19c); + } + if (param->status == '\0') { + uVar4 = (uint)param->sta_idx; + uVar1 = (uint)sta_info_tab[uVar4].inst_nbr; + memcpy(&sta_info_tab[uVar4].info,&vif_info_tab[uVar1].bss_info.rate_set,0xd); + uVar3 = vif_info_tab[uVar1].bss_info.valid_flags; + if ((uVar3 & 1) != 0) { + sta_info_tab[uVar4].info.capa_flags = sta_info_tab[uVar4].info.capa_flags | 1; + } + if ((uVar3 & 2) != 0) { + sta_info_tab[uVar4].info.capa_flags = sta_info_tab[uVar4].info.capa_flags | 2; + memcpy(&sta_info_tab[uVar4].info.ht_cap,&vif_info_tab[uVar1].bss_info,0x20); + me_set_sta_ht_vht_param(sta_info_tab + uVar4,&vif_info_tab[uVar1].bss_info); + } + sm_set_bss_param(); + } + else { + sm_connect_ind(0xf); + } + return 0; +} + + + +int sm_disconnect_req_handler + (ke_msg_id_t msgid,sm_disconnect_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + int iVar2; + + kVar1 = ke_state_get(6); + iVar2 = 2; + if (CONCAT22(extraout_var,kVar1) == 0) { + sm_disconnect(param->vif_idx,param->reason_code); + ke_msg_send_basic(0x1804,0xd,6); + iVar2 = 0; + } + return iVar2; +} + + + +int apm_sta_connect_timeout_ind_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t sta_idx; + sta_info_tag *psVar1; + TickType_t TVar2; + + TVar2 = xTaskGetTickCount(); + psVar1 = sta_info_tab; + sta_idx = '\0'; + do { + if ((psVar1->time_last_seen != 0) && (30000 < (int)(TVar2 - psVar1->time_last_seen))) { + apm_sta_fw_delete(sta_idx); + } + sta_idx = sta_idx + '\x01'; + psVar1 = psVar1 + 1; + } while (sta_idx != '\f'); + ke_timer_set(0x1c0a,7,5000000); + return 0; +} + + + +int rxu_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + undefined4 uVar1; + ushort uVar2; + + uVar2 = param->framectrl & 0xfc; + if (uVar2 == 0x40) { + apm_probe_req_handler(); + } + else { + if (uVar2 == 0xb0) { + apm_auth_handler(param); + } + else { + uVar1 = 0; + if ((param->framectrl & 0xfc) != 0) { + if (uVar2 != 0x20) { + if (uVar2 == 0xc0) { + apm_deauth_handler(param); + return 0; + } + if (uVar2 == 0xa0) { + apm_disassoc_handler(param); + return 0; + } + if (uVar2 != 0x80) { + return 0; + } + apm_beacon_handler(param); + return 0; + } + uVar1 = 1; + } + apm_assoc_req_handler(uVar1); + } + } + return 0; +} + + + +int apm_sta_add_cfm_handler + (ke_msg_id_t msgid,me_sta_add_cfm *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + if (uap_conn_info == (cm_ConnectionInfo_t *)0x0) { + apm_sta_add(param->sta_idx); + } + else { + uap_conn_info->staId = param->sta_idx; + SendEAPOLMsgUsingBufDesc(uap_conn_info,(BufferDesc_t *)0x0); + } + return 0; +} + + + +int apm_sta_del_req_handler + (ke_msg_id_t msgid,apm_sta_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *puVar1; + + puVar1 = (undefined *)ke_msg_alloc(0x1c0c,src_id,dest_id,3); + if ((vif_info_tab[param->vif_idx].type == '\x02') && (param->sta_idx < 0xd)) { + apm_sta_remove(param->vif_idx,param->sta_idx); + *puVar1 = 0; + } + else { + *puVar1 = 0xff; + } + ke_msg_send(puVar1); + return 0; +} + + +/* +Unable to decompile 'apm_stop_cac_req_handler' +Cause: Exception while decompiling 2301ebca: Decompiler process died + +*/ + + +int apm_conf_max_sta_req_handler + (ke_msg_id_t msgid,apm_conf_max_sta_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + apm_env.max_sta_supported = param->max_sta_supported; + if (0xc < apm_env.max_sta_supported) { + apm_env.max_sta_supported = 0xc; + } + ke_msg_send_basic(0x1c0e,src_id,dest_id); + return 0; +} + + +/* +Unable to decompile 'apm_start_cac_req_handler' +Cause: Exception while decompiling 2301ec70: Decompiler process died + +*/ + + +int me_set_ps_disable_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + + kVar1 = ke_state_get(7); + if ((CONCAT22(extraout_var,kVar1) != 1) && + (kVar1 = ke_state_get(7), CONCAT22(extraout_var_00,kVar1) != 0)) { + assert_err( + "(ke_state_get(TASK_APM) == APM_BSS_PARAM_SETTING) || (ke_state_get(TASK_APM) == APM_IDLE)" + ,"module",0xee); + } + kVar1 = ke_state_get(7); + if (CONCAT22(extraout_var_01,kVar1) == 1) { + apm_send_next_bss_param(); + } + return 0; +} + + + +int mm_bss_param_setting_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(7); + if (CONCAT22(extraout_var,kVar1) != 1) { + assert_err("ke_state_get(TASK_APM) == APM_BSS_PARAM_SETTING","module",0x110); + } + apm_send_next_bss_param(); + return 0; +} + + + +int mm_bcn_change_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(7); + if (CONCAT22(extraout_var,kVar1) != 2) { + assert_err("ke_state_get(TASK_APM) == APM_BCN_SETTING","module",0x156); + } + apm_start_cfm(0); + return 0; +} + + + +int apm_stop_req_handler + (ke_msg_id_t msgid,apm_stop_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint uVar1; + ke_state_t kVar2; + undefined2 extraout_var; + + uVar1 = (uint)param->vif_idx; + if ((vif_info_tab[uVar1].type == '\x02') && (vif_info_tab[uVar1].active != false)) { + kVar2 = ke_state_get(7); + if (CONCAT22(extraout_var,kVar2) != 0) { + return 2; + } + if (apm_env.apm_emb_enabled != false) { + apm_env.apm_emb_enabled = false; + } + apm_stop(vif_info_tab + uVar1); + if (uap_conn_info != (cm_ConnectionInfo_t *)0x0) { + RemoveAPKeyInfo(uap_conn_info); + cm_DeleteConnection(uap_conn_info); + uap_conn_info = (cm_ConnectionInfo_t *)0x0; + } + } + ke_msg_send_basic(0x1c03,src_id,dest_id); + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int apm_start_req_handler + (ke_msg_id_t msgid,apm_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint32_t uVar1; + char "apm_start_req_handler" [22]; + uint8_t uVar2; + _Bool _Var3; + ke_state_t kVar4; + uint16_t uVar5; + undefined2 extraout_var_01; + undefined3 extraout_var; + scan_chan_tag *psVar6; + undefined3 extraout_var_00; + int iVar7; + undefined *puVar8; + uint uVar9; + undefined uVar10; + uint8_t *ssid; + uint8_t uStack51; + int8_t iStack50; + uint8_t auStack49 [2]; + uint8_t chan_idx; + int8_t pwr; + uint8_t idx; + + printf("[WF] received APM Start %s:%d\r\n","apm_start_req_handler",0x4c); + uVar9 = (uint)param->vif_idx; + uVar10 = 4; + if (vif_info_tab[uVar9].type == '\x02') { + kVar4 = ke_state_get(7); + if (CONCAT22(extraout_var_01,kVar4) == 0) { + if (vif_info_tab[uVar9].active == false) { + if (vif_info_tab[uVar9].chan_ctxt != (chan_ctxt_tag *)0x0) { + assert_err("vif->chan_ctxt == NULL","module",0x67); + } + apm_env.param = param; + uVar2 = me_add_chan_ctx(&uStack51,¶m->chan,param->center_freq1,param->center_freq2, + param->ch_width); + uVar10 = 1; + if (CONCAT31(extraout_var,uVar2) == 0) { + psVar6 = me_freq_to_chan_ptr((param->chan).band,(param->chan).freq); + vif_info_tab[uVar9].bss_info.chan = psVar6; + psVar6->tx_power = (param->chan).tx_power; + vif_info_tab[uVar9].bss_info.center_freq1 = (uint16_t)param->center_freq1; + vif_info_tab[uVar9].bss_info.center_freq2 = (uint16_t)param->center_freq2; + uVar2 = param->ch_width; + if (uVar2 == '\x04') { + uVar2 = '\x03'; + } + vif_info_tab[uVar9].bss_info.bw = uVar2; + uVar2 = param->ch_width; + vif_info_tab[uVar9].bss_info.power_constraint = '\0'; + vif_info_tab[uVar9].bss_info.phy_bw = uVar2; + chan_ctxt_link(param->vif_idx,uStack51); + apm_env.apm_emb_enabled = param->apm_emb_enabled; + apm_env.hidden_ssid = param->hidden_ssid; + _Var3 = apm_embedded_enabled(vif_info_tab + uVar9); + if (CONCAT31(extraout_var_00,_Var3) != 0) { + me_get_basic_rates(¶m->rate_set,(mac_rateset *)param); + if (param->qos_supported != '\0') { + vif_info_tab[uVar9].bss_info.valid_flags = + vif_info_tab[uVar9].bss_info.valid_flags | 1; + } + if (me_env.ht_supported != false) { + vif_info_tab[uVar9].bss_info.valid_flags = + vif_info_tab[uVar9].bss_info.valid_flags | 2; + } + vif_info_tab[uVar9].bss_info.beacon_interval = param->bcn_int; + vif_info_tab[uVar9].bss_info.beacon_period = (ushort)param->beacon_period; + vif_info_tab[uVar9].bss_info.sec_type = param->ap_sec_type; + memcpy(&vif_info_tab[uVar9].bss_info.ssid,¶m->ssid,0x22); + vif_info_tab[uVar9].bss_info.ssid.array[vif_info_tab[uVar9].bss_info.ssid.length] = '\0' + ; + *(undefined4 *)vif_info_tab[uVar9].bss_info.bssid.array = + *(undefined4 *)vif_info_tab[uVar9].mac_addr.array; + vif_info_tab[uVar9].bss_info.bssid.array[2] = vif_info_tab[uVar9].mac_addr.array[2]; + memcpy(&vif_info_tab[uVar9].bss_info.rate_set,¶m->rate_set,0xd); + vif_info_tab[uVar9].txq_params[0] = _DAT_44b00200; + vif_info_tab[uVar9].txq_params[1] = _DAT_44b00204; + vif_info_tab[uVar9].txq_params[2] = _DAT_44b00208; + uVar1 = _DAT_44b0020c; + vif_info_tab[uVar9].bss_info.edca_param.qos_info = '\0'; + vif_info_tab[uVar9].txq_params[3] = uVar1; + *(undefined4 *)&vif_info_tab[uVar9].bss_info.aid_bitmap = 0xffff0000; + apm_env.bcn_buf = (uint8_t *)ke_malloc(0x14d); + uVar5 = me_build_beacon((uint32_t)apm_env.bcn_buf,vif_info_tab[uVar9].index, + ¶m->tim_oft,¶m->tim_len,apm_env.hidden_ssid); + param->bcn_len = uVar5; + if (param->ap_sec_type == '\0') { + uap_conn_info = (cm_ConnectionInfo_t *)0x0; + } + else { + uap_conn_info = + cm_InitConnection('\x02','\0','\0', + (IEEEtypes_MacAddr_t *)&vif_info_tab[uVar9].bss_info.bssid, + (IEEEtypes_MacAddr_t *)0x0,'\0',(unkbyte0 *)0x0); + ssid = vif_info_tab[uVar9].bss_info.ssid.array; + ap_setpsk(uap_conn_info,(CHAR *)ssid,(CHAR *)param->phrase); + cm_SetComData(uap_conn_info,(char *)ssid); + uap_conn_info->instNbr = param->vif_idx; + printf("%s:uap_conn_info->instNbr = %d\r\n",0x230ae7c0,(uint)uap_conn_info->instNbr); + InitGroupKey(uap_conn_info); + } + } + if ((param->chan).band == '\0') { + uVar5 = me_legacy_rate_bitfield_build(&vif_info_tab[uVar9].bss_info.rate_set,true); + if ((uVar5 & 0xf) == 0) { + vif_info_tab[uVar9].bss_info.high_11b_rate = '\x01'; + } + else { + iVar7 = __clzsi2((uint)uVar5 & 0xf); + vif_info_tab[uVar9].bss_info.high_11b_rate = '\x1f' - (char)iVar7; + } + } + apm_set_bss_param(); + iStack50 = (vif_info_tab[uVar9].bss_info.chan)->tx_power; + tpc_update_vif_tx_power(vif_info_tab + uVar9,&iStack50,auStack49); + printf("[WF] return with other handler\r\n"); + return 1; + } + } + else { + uVar10 = 9; + } + } + else { + uVar10 = 8; + } + } + printf("[WF] Sending APM CFM %s:%d\r\n",0x230ae7c0,0xcc); + puVar8 = (undefined *)ke_msg_alloc(0x1c01,src_id,dest_id,4); + *puVar8 = uVar10; + puVar8[1] = param->vif_idx; + ke_msg_send(); + return 0; +} + + + +int me_set_active_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + + kVar1 = ke_state_get(7); + if ((CONCAT22(extraout_var,kVar1) != 1) && + (kVar1 = ke_state_get(7), CONCAT22(extraout_var_00,kVar1) != 0)) { + assert_err( + "(ke_state_get(TASK_APM) == APM_BSS_PARAM_SETTING) || (ke_state_get(TASK_APM) == APM_IDLE)" + ,"module",0x12f); + } + kVar1 = ke_state_get(7); + if (CONCAT22(extraout_var_01,kVar1) == 1) { + if (apm_env.bss_config.first != (co_list_hdr *)0x0) { + assert_err("co_list_is_empty(&apm_env.bss_config)","module",0x135); + } + apm_bcn_set(); + } + return 0; +} + + + +int hostapd_mgt_ind_handler + (ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ushort uVar1; + + uVar1 = param->framectrl & 0xfc; + if ((uVar1 != 0x40) && (uVar1 != 0xb0)) { + return 0; + } + ke_state_get(10); + return 0; +} + + + +void dump_cfg_entries(void) + +{ + cfg_element_entry *pcVar1; + char *pcVar2; + char acStack64 [4]; + char strs [16]; + + puts("================= CFG TASK =================\r\n"); + pcVar1 = cfg_entrys_mm; + while (pcVar1 < &_fsymc_info_bloop) { + printf("entry %p\r\n",pcVar1); + printf(" task : %lu\r\n",(blog_level_t *)pcVar1->task); + printf(" element : %u\r\n",(uint)pcVar1->element); + printf(" type : %u\r\n",(uint)pcVar1->type); + printf(" name : %s\r\n",pcVar1->name); + pcVar2 = cfg_api_element_dump(pcVar1->val,*(CFG_ELEMENT_TYPE *)&pcVar1->type,acStack64); + printf(" type : %s\r\n",pcVar2); + printf(" val : %s\r\n"); + puts("------------------------\r\n"); + pcVar1 = pcVar1 + 1; + } + puts("---------------------------------------------\r\n"); + return; +} + + + +// WARNING: Variable defined which should be unmapped: val + +int cfg_start_req_handler + (ke_msg_id_t msgid,cfg_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined2 in_register_0000202a; + undefined *puVar1; + int iVar2; + undefined4 uStack20; + uint32_t val [1]; + + if (param->ops == 0) { + iVar2 = utils_tlv_bl_unpack_auto + ((uint32_t *)(param + 5),param[4].ops,*(uint16_t *)¶m[3].ops,&uStack20); + printf("unpack ret is %d, result is %lu\r\n",iVar2,uStack20); + cfg_api_element_set(param[1].ops,param[2].ops,param[3].ops,&uStack20,(void *)0x0); + } + else { + if (2 < param->ops) { + dump_cfg_entries(CONCAT22(in_register_0000202a,msgid)); + } + } + puVar1 = (undefined *)ke_msg_alloc(0x3001,src_id,dest_id,1); + *puVar1 = 0; + ke_msg_send(); + return 0; +} + + + +void dbg_test_print(char *fmt,...) + +{ + byte bVar1; + uint uVar2; + byte *pbVar3; + va_list args; + + if (dbg_env.filter_severity != 0) { + pbVar3 = (byte *)(fmt + 2); + do { + bVar1 = *fmt; + uVar2 = (uint)bVar1; + if (-1 < (char)bVar1) { + return; + } + if (bVar1 < 0x88) { + if ((~dbg_env.filter_module >> (uVar2 - 0x80 & 0x1f) & 1) != 0) { + return; + } + } + else { + if (5 < (uVar2 + 0x66 & 0xff)) { + assert_err("DBG_SEV_MIN <= prefix && prefix < DBG_SEV_MAX","module",0x297); + } + if (dbg_env.filter_severity <= uVar2 - 0x9a) { + return; + } + } + fmt = (char *)((byte *)fmt + 1); + } while (pbVar3 != (byte *)fmt); + } + return; +} + + + +int dbg_get_sys_stat_req_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined4 *puVar1; + + puVar1 = (undefined4 *)ke_msg_alloc(0x40a,src_id,dest_id,0xc); + *puVar1 = 0; + puVar1[1] = 0; + puVar1[2] = 0; + ke_msg_send(); + return 0; +} + + + +int dbg_mem_write_req_handler + (ke_msg_id_t msgid,dbg_mem_write_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint32_t **ppuVar1; + uint32_t **ppuVar2; + + ppuVar1 = (uint32_t **)ke_msg_alloc(0x403,src_id,dest_id,8); + *(uint32_t *)param->memaddr = param->memdata; + ppuVar2 = (uint32_t **)param->memaddr; + *(uint32_t ***)ppuVar1 = ppuVar2; + ppuVar1[1] = *ppuVar2; + ke_msg_send(); + return 0; +} + + + +int dbg_mem_read_req_handler + (ke_msg_id_t msgid,dbg_mem_read_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint32_t *puVar1; + + puVar1 = (uint32_t *)ke_msg_alloc(0x401,src_id,dest_id,8); + puVar1[1] = *(uint32_t *)param->memaddr; + *puVar1 = param->memaddr; + ke_msg_send(); + return 0; +} + + + +int dbg_set_sev_filter_req_handler + (ke_msg_id_t msgid,dbg_set_sev_filter_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + dbg_env.filter_severity = param->sev_filter; + ke_msg_send_basic(0x407,src_id,dest_id); + return 0; +} + + + +int dbg_set_mod_filter_req_handler + (ke_msg_id_t msgid,dbg_set_mod_filter_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + dbg_env.filter_module = param->mod_filter; + ke_msg_send_basic(0x405,src_id,dest_id); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling + +co_list_hdr * +ke_queue_extract(co_list *queue,anon_subr__Bool_co_list_hdr_ptr_uint32_t *func,uint32_t arg) + +{ + co_list_hdr cVar1; + co_list_hdr cVar2; + _Bool _Var3; + undefined3 extraout_var; + co_list_hdr cVar4; + + cVar4 = (co_list_hdr)queue->first; + cVar1 = (co_list_hdr)0x0; + do { + cVar2 = cVar1; + cVar1 = cVar4; + if (cVar1 == (co_list_hdr)0x0) { + return (co_list_hdr *)0; + } + _Var3 = (*func)((co_list_hdr *)cVar1,arg); + cVar4 = *(co_list_hdr *)cVar1; + } while (CONCAT31(extraout_var,_Var3) == 0); + if (cVar2 == (co_list_hdr)0x0) { + *(co_list_hdr *)&queue->first = cVar4; + } + else { + *(co_list_hdr *)cVar2 = cVar4; + } + if (*(int *)cVar1 == 0) { + *(co_list_hdr *)&queue->last = cVar2; + } + else { + *(undefined4 *)cVar1 = 0; + } + return (co_list_hdr *)cVar1; +} + + + +void bl_aes_128(UINT8 *key,UINT8 *input,UINT8 *output) + +{ + BL_AesEncrypt(key,'\x02',input,output); + return; +} + + + +void xor_128(UINT8 *a,UINT8 *b,UINT8 *out) + +{ + byte *pbVar1; + int iVar2; + byte *pbVar3; + byte *pbVar4; + + iVar2 = 0; + do { + pbVar1 = a + iVar2; + pbVar4 = b + iVar2; + pbVar3 = out + iVar2; + iVar2 = iVar2 + 1; + *pbVar3 = *pbVar1 ^ *pbVar4; + } while (iVar2 != 0x10); + return; +} + + + +void leftshift_onebit(UINT8 *input,UINT8 *output) + +{ + byte *pbVar1; + int iVar2; + byte bVar3; + byte *pbVar4; + + bVar3 = 0; + iVar2 = 0xf; + do { + pbVar1 = input + iVar2; + pbVar4 = output + iVar2; + iVar2 = iVar2 + -1; + *pbVar4 = bVar3 | *pbVar1 << 1; + bVar3 = *pbVar1 >> 7; + } while (iVar2 != -1); + return; +} + + + +// WARNING: Variable defined which should be unmapped: tmp + +void generate_subkey(UINT8 *key,UINT8 *K1,UINT8 *K2) + +{ + UINT8 local_40 [4]; + UINT8 L [16]; + UINT8 Z [16]; + UINT8 tmp [16]; + + memset(L + 0xc,0,0x10); + bl_aes_128(key,L + 0xc,local_40); + if ((char)local_40[0] < '\0') { + leftshift_onebit(local_40,Z + 0xc); + xor_128(Z + 0xc,"",K1); + } + else { + leftshift_onebit(local_40,K1); + } + if ((char)*K1 < '\0') { + leftshift_onebit(K1,Z + 0xc); + xor_128(Z + 0xc,"",K2); + } + else { + leftshift_onebit(K1,K2); + } + return; +} + + + +void padding(UINT8 *lastb,UINT8 *pad,int length) + +{ + int iVar1; + + iVar1 = 0; + do { + if (iVar1 < length) { + pad[iVar1] = lastb[iVar1]; + } + else { + if (length == iVar1) { + pad[length] = -0x80; + } + else { + pad[iVar1] = '\0'; + } + } + iVar1 = iVar1 + 1; + } while (iVar1 != 0x10); + return; +} + + + +void bl_aes_cmac(UINT8 *key,UINT8 *input,int length,UINT8 *mac) + +{ + int iVar1; + int iVar2; + UINT8 *a; + UINT8 *pUVar3; + UINT8 local_80 [4]; + UINT8 X [16]; + UINT8 Y [16]; + UINT8 M_last [16]; + UINT8 padded [16]; + UINT8 K1 [16]; + UINT8 K2 [16]; + + generate_subkey(key,padded + 0xc,K1 + 0xc); + iVar1 = (length + 0xf) / 0x10; + if (iVar1 == 0) { + iVar1 = 1; + } + else { + if ((length & 0xfU) == 0) { + pUVar3 = padded; + a = input + (iVar1 + -1) * 0x10; + goto LAB_2301f6f4; + } + } + padding(input + (iVar1 + -1) * 0x10,M_last + 0xc,length % 0x10); + pUVar3 = K1; + a = M_last + 0xc; +LAB_2301f6f4: + xor_128(a,pUVar3 + 0xc,Y + 0xc); + memset(local_80,0,0x10); + iVar2 = 0; + while (iVar2 < iVar1 + -1) { + xor_128(local_80,input + iVar2 * 0x10,X + 0xc); + bl_aes_128(key,X + 0xc,local_80); + iVar2 = iVar2 + 1; + } + xor_128(local_80,Y + 0xc,X + 0xc); + bl_aes_128(key,X + 0xc,local_80); + iVar1 = 0; + do { + pUVar3 = local_80 + iVar1; + a = mac + iVar1; + iVar1 = iVar1 + 1; + *a = *pUVar3; + } while (iVar1 != 0x10); + return; +} + + + +int BL_AES_MEMCMP(UINT8 *dst,UINT8 *src,int len) + +{ + int iVar1; + int iVar2; + + iVar2 = 0; + iVar1 = len; + while (len != iVar2) { + if (dst[iVar2] == src[iVar2]) { + iVar1 = iVar1 + -1; + } + iVar2 = iVar2 + 1; + } + return -(uint)(iVar1 != 0); +} + + + +void BL_AES_MEMSET(UINT8 *dst,UINT8 val,int size) + +{ + UINT8 *pUVar1; + + pUVar1 = dst; + while (pUVar1 != dst + size) { + *pUVar1 = val; + pUVar1 = pUVar1 + 1; + } + return; +} + + + +void BL_AES_MEMCPY(UINT8 *dst,UINT8 *src,int size) + +{ + UINT8 *pUVar1; + UINT8 *pUVar2; + int iVar3; + + if (dst < src) { + iVar3 = 0; + while (iVar3 != size) { + pUVar1 = src + iVar3; + pUVar2 = dst + iVar3; + iVar3 = iVar3 + 1; + *pUVar2 = *pUVar1; + } + return; + } + while (size = size + -1, size != -1) { + dst[size] = src[size]; + } + return; +} + + + +int BL_AesEncrypt(UINT8 *kek,UINT8 kekLen,UINT8 *data,UINT8 *ret) + +{ + undefined3 in_register_0000202d; + undefined auStack416 [4]; + UINT8 pBuf [400]; + + rijndael_set_key((rijndael_ctx *)auStack416,kek,CONCAT31(in_register_0000202d,kekLen) << 6,1); + rijndael_encrypt((rijndael_ctx *)auStack416,data,ret); + return 0; +} + + + +int BL_AesWrap(UINT8 *kek,UINT8 kekLen,UINT32 n,UINT8 *plain,UINT8 *keyIv,UINT8 *cipher) + +{ + int iVar1; + uint uVar2; + int iVar3; + int iVar4; + UINT8 aUStack72 [4]; + UINT8 a [8]; + UINT8 b [16]; + + if (n != 0) { + BL_AES_MEMSET(a + 4,'\0',0x10); + if (keyIv == (UINT8 *)0x0) { + keyIv = BL_DEFAULT_IV; + } + BL_AES_MEMCPY(aUStack72,keyIv,8); + BL_AES_MEMCPY(cipher + 8,plain,n << 3); + uVar2 = 0; + iVar4 = 6; + do { + iVar1 = 1; + while (iVar3 = iVar1 * 8, iVar1 != n + 1) { + BL_AES_MEMCPY(a + 4,aUStack72,8); + BL_AES_MEMCPY(b + 4,cipher + iVar3,8); + BL_AesEncrypt(kek,kekLen,a + 4,a + 4); + BL_AES_MEMCPY(aUStack72,a + 4,8); + a[3] = (char)uVar2 + (char)iVar1 ^ a[3]; + iVar1 = iVar1 + 1; + BL_AES_MEMCPY(cipher + iVar3,b + 4,8); + } + iVar4 = iVar4 + -1; + uVar2 = uVar2 + (n & 0xff) & 0xff; + } while (iVar4 != 0); + BL_AES_MEMCPY(cipher,aUStack72,8); + return 0; + } + return -1; +} + + + +int BL_AesUnWrap(UINT8 *kek,UINT8 kekLen,UINT32 n,UINT8 *cipher,UINT8 *keyIv,UINT8 *plain) + +{ + uint uVar1; + undefined3 in_register_0000202d; + UINT32 UVar2; + UINT8 *src; + int iVar3; + UINT8 aUStack472 [4]; + UINT8 a [8]; + UINT8 b [16]; + UINT8 pBuf [400]; + + if (n != 0) { + BL_AES_MEMSET(aUStack472,'\0',8); + BL_AES_MEMSET(a + 4,'\0',0x10); + BL_AES_MEMCPY(aUStack472,cipher,8); + uVar1 = (n & 0xff) * 5; + BL_AES_MEMCPY(plain,cipher + 8,n * 8); + rijndael_set_key((rijndael_ctx *)(b + 0xc),kek,CONCAT31(in_register_0000202d,kekLen) << 6,0); + iVar3 = 6; + do { + UVar2 = n; + src = plain + n * 8 + -8; + while (0 < (int)UVar2) { + BL_AES_MEMCPY(a + 4,aUStack472,8); + b[3] = (char)(uVar1 & 0xff) + (char)UVar2 ^ b[3]; + BL_AES_MEMCPY(b + 4,src,8); + rijndael_decrypt((rijndael_ctx *)(b + 0xc),a + 4,a + 4); + BL_AES_MEMCPY(aUStack472,a + 4,8); + BL_AES_MEMCPY(src,b + 4,8); + src = src + -8; + UVar2 = UVar2 - 1; + } + uVar1 = (uVar1 & 0xff) - (n & 0xff); + iVar3 = iVar3 + -1; + } while (iVar3 != 0); + if (keyIv == (UINT8 *)0x0) { + keyIv = BL_DEFAULT_IV; + } + iVar3 = BL_AES_MEMCMP(keyIv,aUStack472,8); + return -(uint)(iVar3 != 0); + } + return -1; +} + + + +// WARNING: Variable defined which should be unmapped: pBuf + +void Bl_hmac_md5(UINT8 *text_data,int text_len,UINT8 *key,int key_len,void *digest) + +{ + ulong *puVar1; + Bl_MD5_CTX *pBVar2; + Bl_MD5_CTX *context; + Bl_MD5_CTX *context_00; + undefined auStack584 [4]; + Bl_MD5_CTX tctx; + uchar pBuf [400]; + + if (0x40 < key_len) { + wpa_MD5Init((Bl_MD5_CTX *)auStack584); + wpa_MD5Update((Bl_MD5_CTX *)auStack584,key,key_len); + wpa_MD5Final(pBuf + 0x94,(Bl_MD5_CTX *)auStack584); + key_len = 0x10; + key = pBuf + 0x94; + } + memset(tctx.buffer + 0x3c,0,0x40); + memcpy(tctx.buffer + 0x3c,key,key_len); + context_00 = (Bl_MD5_CTX *)(pBuf + 0x3c); + pBVar2 = (Bl_MD5_CTX *)(tctx.buffer + 0x3c); + do { + puVar1 = pBVar2->state; + pBVar2->state[0] = pBVar2->state[0] ^ 0x36363636; + pBVar2 = (Bl_MD5_CTX *)(puVar1 + 1); + } while ((Bl_MD5_CTX *)(puVar1 + 1) != context_00); + wpa_MD5Init(context_00); + wpa_MD5Update(context_00,tctx.buffer + 0x3c,0x40); + wpa_MD5Update(context_00,text_data,text_len); + wpa_MD5Final((uchar *)digest,context_00); + memset(tctx.buffer + 0x3c,0,0x40); + memcpy(tctx.buffer + 0x3c,key,key_len); + pBVar2 = (Bl_MD5_CTX *)(tctx.buffer + 0x3c); + do { + context = (Bl_MD5_CTX *)(pBVar2->state + 1); + pBVar2->state[0] = pBVar2->state[0] ^ 0x5c5c5c5c; + pBVar2 = context; + } while (context != context_00); + wpa_MD5Init(context); + wpa_MD5Update(context,tctx.buffer + 0x3c,0x40); + wpa_MD5Update(context,(UINT8 *)digest,0x10); + wpa_MD5Final((uchar *)digest,context); + return; +} + + + +void Bl_hmac_sha1(uchar **ppText,int *pTextLen,int textNum,uchar *key,int key_len,uchar *output, + int outputLen) + +{ + uint *puVar1; + uint *__src; + uchar **ppuVar2; + int iVar3; + uint *Message_Digest; + uint local_1c0; + uchar pBuf [400]; + + if (0x40 < key_len) { + Bl_SHA1Init((Bl_SHA1_CTX *)(pBuf + 0x50)); + Bl_SHA1Update((Bl_SHA1_CTX *)(pBuf + 0x50),key,key_len); + Bl_SHA1Final((Bl_SHA1_CTX *)(pBuf + 0x50),key); + key_len = 0x14; + } + memset(&local_1c0,0,0x40); + memcpy(&local_1c0,key,key_len); + Message_Digest = (uint *)(pBuf + 0x3c); + puVar1 = &local_1c0; + do { + __src = puVar1 + 2; + *puVar1 = *puVar1 ^ 0x36363636; + puVar1[1] = puVar1[1] ^ 0x36363636; + puVar1 = __src; + } while (__src != Message_Digest); + Bl_SHA1Init((Bl_SHA1_CTX *)(pBuf + 0x50)); + Bl_SHA1Update((Bl_SHA1_CTX *)(pBuf + 0x50),(UINT8 *)&local_1c0,0x40); + iVar3 = 0; + while (iVar3 < textNum) { + puVar1 = (uint *)(pTextLen + iVar3); + ppuVar2 = ppText + iVar3; + iVar3 = iVar3 + 1; + Bl_SHA1Update((Bl_SHA1_CTX *)(pBuf + 0x50),*ppuVar2,*puVar1); + } + Bl_SHA1Final((Bl_SHA1_CTX *)(pBuf + 0x50),(UINT8 *)Message_Digest); + memset(&local_1c0,0,0x40); + memcpy(&local_1c0,key,key_len); + puVar1 = &local_1c0; + do { + __src = puVar1 + 2; + *puVar1 = *puVar1 ^ 0x5c5c5c5c; + puVar1[1] = puVar1[1] ^ 0x5c5c5c5c; + puVar1 = __src; + } while (__src != Message_Digest); + Bl_SHA1Init((Bl_SHA1_CTX *)(pBuf + 0x50)); + Bl_SHA1Update((Bl_SHA1_CTX *)(pBuf + 0x50),(UINT8 *)&local_1c0,0x40); + Bl_SHA1Update((Bl_SHA1_CTX *)(pBuf + 0x50),(UINT8 *)__src,0x14); + Bl_SHA1Final((Bl_SHA1_CTX *)(pBuf + 0x50),(UINT8 *)__src); + memcpy(output,__src,outputLen); + return; +} + + + +void Bl_PRF(uchar *key,int key_len,uchar *prefix,int prefix_len,uchar *data,int data_len, + uchar *output,int len) + +{ + char cVar1; + int iVar2; + int iVar3; + int iVar4; + int local_b0; + int total_len; + uchar *pText; + UINT8 prf_input [120]; + + total_len = (int)&pText; + memset(&pText,0,0x78); + if (prefix == (uchar *)0x0) { + memcpy(&pText,data,data_len); + local_b0 = data_len; + } + else { + memcpy(&pText,prefix,prefix_len); + local_b0 = prefix_len + 1 + data_len; + *(undefined *)((int)&pText + prefix_len) = 0; + memcpy((void *)((int)&pText + prefix_len + 1),data,data_len); + } + *(undefined *)((int)&pText + local_b0) = 0; + iVar4 = 0; + iVar3 = 0; + local_b0 = local_b0 + 1; + while( true ) { + iVar2 = (iVar3 * -0x14 + len) * 0x1000000; + cVar1 = (char)((uint)iVar2 >> 0x18); + if ((len + 0x13) / 0x14 <= iVar3) break; + if (0x14 < iVar2 >> 0x18) { + cVar1 = '\x14'; + } + Bl_hmac_sha1((uchar **)&total_len,&local_b0,1,key,key_len,output + iVar4,(int)cVar1); + iVar4 = iVar4 + (int)cVar1; + iVar3 = iVar3 + 1; + *(char *)((int)&total_len + local_b0 + 3) = *(char *)((int)&total_len + local_b0 + 3) + '\x01'; + } + return; +} + + + +void wpa_MD5Transform(UINT32 *state,ulong *block) + +{ + ulong uVar1; + ulong uVar2; + ulong uVar3; + ulong uVar4; + ulong uVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint uVar9; + uint uVar10; + uint uVar11; + uint uVar12; + ulong uVar13; + ulong uVar14; + ulong uVar15; + ulong uVar16; + ulong uVar17; + ulong uVar18; + ulong uVar19; + uint uVar20; + uint uVar21; + ulong uVar22; + ulong uVar23; + ulong uVar24; + ulong uVar25; + + uVar19 = *block; + uVar20 = state[2]; + uVar21 = state[3]; + uVar12 = state[1]; + uVar5 = block[1]; + uVar8 = ((uVar20 ^ uVar21) & uVar12 ^ uVar21) + *state + uVar19 + 0xd76aa478; + uVar9 = (uVar8 >> 0x19 | uVar8 * 0x80) + uVar12; + uVar22 = block[2]; + uVar8 = ((uVar12 ^ uVar20) & uVar9 ^ uVar20) + uVar5 + 0xe8c7b756 + uVar21; + uVar6 = (uVar8 >> 0x14 | uVar8 * 0x1000) + uVar9; + uVar8 = ((uVar12 ^ uVar9) & uVar6 ^ uVar12) + uVar22 + 0x242070db + uVar20; + uVar14 = block[3]; + uVar8 = (uVar8 * 0x20000 | uVar8 >> 0xf) + uVar6; + uVar7 = ((uVar9 ^ uVar6) & uVar8 ^ uVar9) + uVar14 + 0xc1bdceee + uVar12; + uVar24 = block[4]; + uVar7 = (uVar7 * 0x400000 | uVar7 >> 10) + uVar8; + uVar9 = ((uVar6 ^ uVar8) & uVar7 ^ uVar6) + uVar24 + 0xf57c0faf + uVar9; + uVar16 = block[5]; + uVar9 = (uVar9 >> 0x19 | uVar9 * 0x80) + uVar7; + uVar6 = ((uVar8 ^ uVar7) & uVar9 ^ uVar8) + uVar16 + 0x4787c62a + uVar6; + uVar1 = block[6]; + uVar6 = (uVar6 >> 0x14 | uVar6 * 0x1000) + uVar9; + uVar8 = ((uVar7 ^ uVar9) & uVar6 ^ uVar7) + uVar1 + 0xa8304613 + uVar8; + uVar18 = block[7]; + uVar8 = (uVar8 * 0x20000 | uVar8 >> 0xf) + uVar6; + uVar7 = ((uVar9 ^ uVar6) & uVar8 ^ uVar9) + uVar18 + 0xfd469501 + uVar7; + uVar4 = block[8]; + uVar7 = (uVar7 * 0x400000 | uVar7 >> 10) + uVar8; + uVar9 = ((uVar6 ^ uVar8) & uVar7 ^ uVar6) + uVar4 + 0x698098d8 + uVar9; + uVar2 = block[9]; + uVar9 = (uVar9 >> 0x19 | uVar9 * 0x80) + uVar7; + uVar6 = ((uVar8 ^ uVar7) & uVar9 ^ uVar8) + uVar2 + 0x8b44f7af + uVar6; + uVar13 = block[10]; + uVar6 = (uVar6 >> 0x14 | uVar6 * 0x1000) + uVar9; + uVar8 = ((uVar7 ^ uVar9) & uVar6 ^ uVar7) + (uVar13 - 0xa44f) + uVar8; + uVar23 = block[0xb]; + uVar8 = (uVar8 * 0x20000 | uVar8 >> 0xf) + uVar6; + uVar7 = ((uVar9 ^ uVar6) & uVar8 ^ uVar9) + uVar23 + 0x895cd7be + uVar7; + uVar15 = block[0xc]; + uVar7 = (uVar7 * 0x400000 | uVar7 >> 10) + uVar8; + uVar9 = ((uVar6 ^ uVar8) & uVar7 ^ uVar6) + uVar15 + 0x6b901122 + uVar9; + uVar25 = block[0xd]; + uVar9 = (uVar9 >> 0x19 | uVar9 * 0x80) + uVar7; + uVar6 = ((uVar8 ^ uVar7) & uVar9 ^ uVar8) + uVar25 + 0xfd987193 + uVar6; + uVar17 = block[0xe]; + uVar6 = (uVar6 >> 0x14 | uVar6 * 0x1000) + uVar9; + uVar8 = ((uVar7 ^ uVar9) & uVar6 ^ uVar7) + uVar17 + 0xa679438e + uVar8; + uVar3 = block[0xf]; + uVar8 = (uVar8 * 0x20000 | uVar8 >> 0xf) + uVar6; + uVar7 = ((uVar9 ^ uVar6) & uVar8 ^ uVar9) + uVar3 + 0x49b40821 + uVar7; + uVar7 = (uVar7 * 0x400000 | uVar7 >> 10) + uVar8; + uVar9 = ((uVar8 ^ uVar7) & uVar6 ^ uVar8) + uVar5 + 0xf61e2562 + uVar9; + uVar9 = (uVar9 >> 0x1b | uVar9 * 0x20) + uVar7; + uVar6 = ((uVar7 ^ uVar9) & uVar8 ^ uVar7) + uVar1 + 0xc040b340 + uVar6; + uVar6 = (uVar6 >> 0x17 | uVar6 * 0x200) + uVar9; + uVar8 = ((uVar9 ^ uVar6) & uVar7 ^ uVar9) + uVar23 + 0x265e5a51 + uVar8; + uVar8 = (uVar8 >> 0x12 | uVar8 * 0x4000) + uVar6; + uVar7 = ((uVar6 ^ uVar8) & uVar9 ^ uVar6) + uVar19 + 0xe9b6c7aa + uVar7; + uVar7 = (uVar7 * 0x100000 | uVar7 >> 0xc) + uVar8; + uVar9 = ((uVar8 ^ uVar7) & uVar6 ^ uVar8) + uVar16 + 0xd62f105d + uVar9; + uVar9 = (uVar9 >> 0x1b | uVar9 * 0x20) + uVar7; + uVar6 = ((uVar7 ^ uVar9) & uVar8 ^ uVar7) + uVar13 + 0x2441453 + uVar6; + uVar6 = (uVar6 >> 0x17 | uVar6 * 0x200) + uVar9; + uVar8 = ((uVar9 ^ uVar6) & uVar7 ^ uVar9) + uVar3 + 0xd8a1e681 + uVar8; + uVar8 = (uVar8 >> 0x12 | uVar8 * 0x4000) + uVar6; + uVar7 = ((uVar6 ^ uVar8) & uVar9 ^ uVar6) + uVar24 + 0xe7d3fbc8 + uVar7; + uVar7 = (uVar7 * 0x100000 | uVar7 >> 0xc) + uVar8; + uVar9 = ((uVar8 ^ uVar7) & uVar6 ^ uVar8) + uVar2 + 0x21e1cde6 + uVar9; + uVar9 = (uVar9 >> 0x1b | uVar9 * 0x20) + uVar7; + uVar6 = ((uVar7 ^ uVar9) & uVar8 ^ uVar7) + uVar17 + 0xc33707d6 + uVar6; + uVar6 = (uVar6 >> 0x17 | uVar6 * 0x200) + uVar9; + uVar8 = ((uVar9 ^ uVar6) & uVar7 ^ uVar9) + uVar14 + 0xf4d50d87 + uVar8; + uVar8 = (uVar8 >> 0x12 | uVar8 * 0x4000) + uVar6; + uVar7 = ((uVar6 ^ uVar8) & uVar9 ^ uVar6) + uVar4 + 0x455a14ed + uVar7; + uVar7 = (uVar7 * 0x100000 | uVar7 >> 0xc) + uVar8; + uVar9 = ((uVar8 ^ uVar7) & uVar6 ^ uVar8) + uVar25 + 0xa9e3e905 + uVar9; + uVar9 = (uVar9 >> 0x1b | uVar9 * 0x20) + uVar7; + uVar6 = ((uVar7 ^ uVar9) & uVar8 ^ uVar7) + uVar22 + 0xfcefa3f8 + uVar6; + uVar6 = (uVar6 >> 0x17 | uVar6 * 0x200) + uVar9; + uVar8 = ((uVar9 ^ uVar6) & uVar7 ^ uVar9) + uVar8 + uVar18 + 0x676f02d9; + uVar8 = (uVar8 >> 0x12 | uVar8 * 0x4000) + uVar6; + uVar7 = (uVar9 & (uVar6 ^ uVar8) ^ uVar6) + uVar15 + 0x8d2a4c8a + uVar7; + uVar7 = (uVar7 * 0x100000 | uVar7 >> 0xc) + uVar8; + uVar9 = uVar9 + (uVar16 - 0x5c6be) + (uVar6 ^ uVar8 ^ uVar7); + uVar10 = (uVar9 >> 0x1c | uVar9 * 0x10) + uVar7; + uVar6 = (uVar8 ^ uVar7 ^ uVar10) + uVar4 + 0x8771f681 + uVar6; + uVar6 = (uVar6 >> 0x15 | uVar6 * 0x800) + uVar10; + uVar8 = (uVar7 ^ uVar10 ^ uVar6) + uVar23 + 0x6d9d6122 + uVar8; + uVar8 = (uVar8 >> 0x10 | uVar8 * 0x10000) + uVar6; + uVar7 = (uVar10 ^ uVar6 ^ uVar8) + uVar17 + 0xfde5380c + uVar7; + uVar9 = (uVar7 * 0x800000 | uVar7 >> 9) + uVar8; + uVar7 = (uVar6 ^ uVar8 ^ uVar9) + uVar5 + 0xa4beea44 + uVar10; + uVar10 = (uVar7 >> 0x1c | uVar7 * 0x10) + uVar9; + uVar6 = (uVar8 ^ uVar9 ^ uVar10) + uVar6 + uVar24 + 0x4bdecfa9; + uVar6 = (uVar6 >> 0x15 | uVar6 * 0x800) + uVar10; + uVar8 = (uVar9 ^ uVar10 ^ uVar6) + uVar8 + uVar18 + 0xf6bb4b60; + uVar7 = (uVar8 >> 0x10 | uVar8 * 0x10000) + uVar6; + uVar8 = (uVar10 ^ uVar6 ^ uVar7) + uVar13 + 0xbebfbc70 + uVar9; + uVar9 = (uVar8 * 0x800000 | uVar8 >> 9) + uVar7; + uVar8 = (uVar6 ^ uVar7 ^ uVar9) + uVar10 + uVar25 + 0x289b7ec6; + uVar8 = (uVar8 >> 0x1c | uVar8 * 0x10) + uVar9; + uVar6 = (uVar7 ^ uVar9 ^ uVar8) + uVar6 + uVar19 + 0xeaa127fa; + uVar10 = (uVar6 >> 0x15 | uVar6 * 0x800) + uVar8; + uVar6 = (uVar9 ^ uVar8 ^ uVar10) + uVar14 + 0xd4ef3085 + uVar7; + uVar7 = (uVar6 >> 0x10 | uVar6 * 0x10000) + uVar10; + uVar6 = (uVar8 ^ uVar10 ^ uVar7) + uVar9 + uVar1 + 0x4881d05; + uVar6 = (uVar6 * 0x800000 | uVar6 >> 9) + uVar7; + uVar8 = (uVar10 ^ uVar7 ^ uVar6) + uVar8 + uVar2 + 0xd9d4d039; + uVar9 = (uVar8 >> 0x1c | uVar8 * 0x10) + uVar6; + uVar8 = (uVar7 ^ uVar6 ^ uVar9) + uVar10 + uVar15 + 0xe6db99e5; + uVar8 = (uVar8 >> 0x15 | uVar8 * 0x800) + uVar9; + uVar7 = (uVar6 ^ uVar9 ^ uVar8) + uVar3 + 0x1fa27cf8 + uVar7; + uVar7 = (uVar7 >> 0x10 | uVar7 * 0x10000) + uVar8; + uVar6 = (uVar9 ^ uVar8 ^ uVar7) + uVar6 + uVar22 + 0xc4ac5665; + uVar10 = (uVar6 * 0x800000 | uVar6 >> 9) + uVar7; + uVar6 = ((~uVar8 | uVar10) ^ uVar7) + uVar19 + 0xf4292244 + uVar9; + uVar9 = (uVar6 >> 0x1a | uVar6 * 0x40) + uVar10; + uVar8 = ((~uVar7 | uVar9) ^ uVar10) + uVar18 + 0x432aff97 + uVar8; + uVar8 = (uVar8 >> 0x16 | uVar8 * 0x400) + uVar9; + uVar6 = ((~uVar10 | uVar8) ^ uVar9) + uVar17 + 0xab9423a7 + uVar7; + uVar7 = (uVar6 >> 0x11 | uVar6 * 0x8000) + uVar8; + uVar6 = ((~uVar9 | uVar7) ^ uVar8) + uVar10 + uVar16 + 0xfc93a039; + uVar6 = (uVar6 * 0x200000 | uVar6 >> 0xb) + uVar7; + uVar9 = ((~uVar8 | uVar6) ^ uVar7) + uVar9 + uVar15 + 0x655b59c3; + uVar11 = (uVar9 >> 0x1a | uVar9 * 0x40) + uVar6; + uVar8 = ((~uVar7 | uVar11) ^ uVar6) + uVar8 + uVar14 + 0x8f0ccc92; + uVar10 = (uVar8 >> 0x16 | uVar8 * 0x400) + uVar11; + uVar8 = ((~uVar6 | uVar10) ^ uVar11) + (uVar13 - 0x100b83) + uVar7; + uVar7 = (uVar8 >> 0x11 | uVar8 * 0x8000) + uVar10; + uVar8 = ((~uVar11 | uVar7) ^ uVar10) + uVar5 + 0x85845dd1 + uVar6; + uVar9 = (uVar8 * 0x200000 | uVar8 >> 0xb) + uVar7; + uVar8 = ((~uVar10 | uVar9) ^ uVar7) + uVar11 + uVar4 + 0x6fa87e4f; + uVar6 = (uVar8 >> 0x1a | uVar8 * 0x40) + uVar9; + uVar8 = ((~uVar7 | uVar6) ^ uVar9) + uVar10 + uVar3 + 0xfe2ce6e0; + uVar8 = (uVar8 >> 0x16 | uVar8 * 0x400) + uVar6; + uVar7 = ((~uVar9 | uVar8) ^ uVar6) + uVar7 + uVar1 + 0xa3014314; + uVar7 = (uVar7 >> 0x11 | uVar7 * 0x8000) + uVar8; + uVar9 = ((~uVar6 | uVar7) ^ uVar8) + uVar25 + 0x4e0811a1 + uVar9; + uVar9 = (uVar9 * 0x200000 | uVar9 >> 0xb) + uVar7; + uVar6 = ((~uVar8 | uVar9) ^ uVar7) + uVar6 + uVar24 + 0xf7537e82; + uVar11 = (uVar6 >> 0x1a | uVar6 * 0x40) + uVar9; + uVar8 = ((~uVar7 | uVar11) ^ uVar9) + uVar8 + uVar23 + 0xbd3af235; + uVar10 = (uVar8 >> 0x16 | uVar8 * 0x400) + uVar11; + uVar8 = ((~uVar9 | uVar10) ^ uVar11) + uVar7 + uVar22 + 0x2ad7d2bb; + uVar6 = (uVar8 >> 0x11 | uVar8 * 0x8000) + uVar10; + uVar8 = ((~uVar11 | uVar6) ^ uVar10) + uVar2 + 0xeb86d391 + uVar9; + *state = uVar11 + *state; + state[2] = uVar20 + uVar6; + state[3] = uVar21 + uVar10; + state[1] = uVar12 + uVar6 + (uVar8 * 0x200000 | uVar8 >> 0xb); + memset(block,0,0x40); + return; +} + + + +void wpa_MD5Init(Bl_MD5_CTX *context) + +{ + context->state[0] = 0x67452301; + context->state[1] = 0xefcdab89; + context->state[2] = 0x98badcfe; + context->count[1] = 0; + context->count[0] = 0; + context->state[3] = 0x10325476; + return; +} + + + +void wpa_MD5Update(Bl_MD5_CTX *context,UINT8 *input,UINT32 inputLen) + +{ + uint uVar1; + uint __n; + + uVar1 = context->count[0]; + __n = uVar1 + inputLen * 8; + context->count[0] = __n; + uVar1 = uVar1 >> 3 & 0x3f; + if (__n < inputLen * 8) { + context->count[1] = context->count[1] + 1; + } + context->count[1] = (inputLen >> 0x1d) + context->count[1]; + __n = 0x40 - uVar1; + if (inputLen < __n) { + __n = 0; + } + else { + memcpy(context->buffer + uVar1,input,__n); + wpa_MD5Transform((UINT32 *)context,(ulong *)context->buffer); + while (__n + 0x3f < inputLen) { + memcpy(context->scratch,input + __n,0x40); + wpa_MD5Transform((UINT32 *)context,context->scratch); + __n = __n + 0x40; + } + uVar1 = 0; + } + memcpy(context->buffer + uVar1,input + __n,inputLen - __n); + return; +} + + + +void wpa_MD5Final(uchar *digest,Bl_MD5_CTX *context) + +{ + uint uVar1; + int iVar2; + UINT8 aUStack24 [4]; + uchar bits [8]; + + memcpy(aUStack24,context->count,8); + uVar1 = context->count[0] >> 3 & 0x3f; + if (uVar1 < 0x38) { + iVar2 = 0x38; + } + else { + iVar2 = 0x78; + } + wpa_MD5Update(context,PADDING,iVar2 - uVar1); + wpa_MD5Update(context,aUStack24,8); + memcpy(digest,context,0x10); + memset(context,0,0x98); + return; +} + + + +int rijndaelKeySetupEnc(u32 *rk,u8 *cipherKey,int keyBits) + +{ + uint uVar1; + uint uVar2; + u32 *puVar3; + u32 *puVar4; + + *rk = (uint)*cipherKey << 0x18 ^ (uint)cipherKey[1] << 0x10 ^ (uint)cipherKey[3] ^ + (uint)cipherKey[2] << 8; + rk[1] = (uint)cipherKey[4] << 0x18 ^ (uint)cipherKey[5] << 0x10 ^ (uint)cipherKey[7] ^ + (uint)cipherKey[6] << 8; + rk[2] = (uint)cipherKey[8] << 0x18 ^ (uint)cipherKey[9] << 0x10 ^ (uint)cipherKey[0xb] ^ + (uint)cipherKey[10] << 8; + rk[3] = (uint)cipherKey[0xc] << 0x18 ^ (uint)cipherKey[0xd] << 0x10 ^ (uint)cipherKey[0xf] ^ + (uint)cipherKey[0xe] << 8; + if (keyBits == 0x80) { + puVar3 = rcon; + puVar4 = rk + 0x24; + while( true ) { + uVar1 = *puVar3; + uVar2 = rk[3]; + puVar3 = puVar3 + 1; + uVar1 = *rk ^ uVar1 ^ (uint)Te4[uVar2 >> 0x18] ^ (uint)Te4[uVar2 & 0xff] << 8 ^ + (uint)Te4[uVar2 >> 0x10 & 0xff] << 0x18 ^ (uint)Te4[uVar2 >> 8 & 0xff] << 0x10; + rk[4] = uVar1; + uVar1 = uVar1 ^ rk[1]; + rk[5] = uVar1; + uVar1 = uVar1 ^ rk[2]; + rk[6] = uVar1; + rk[7] = uVar1 ^ uVar2; + if (rk == puVar4) break; + rk = rk + 4; + } + return 10; + } + return 0; +} + + + +void rijndael_set_key(rijndael_ctx *ctx,u8 *key,int bits,int encrypt) + +{ + int iVar1; + u32 *rk; + int iVar2; + u32 uVar3; + u32 *puVar4; + uint uVar5; + int *piVar6; + + rk = ctx->key; + iVar2 = rijndaelKeySetupEnc(rk,key,bits); + ctx->Nr = iVar2; + if (encrypt == 0) { + ctx->decrypt = 1; + if (iVar2 == 0) { + iVar2 = rijndaelKeySetupEnc(rk,key,bits); + } + puVar4 = rk; + piVar6 = &ctx->decrypt + iVar2 * 4; + while (encrypt < iVar2 * 4 - encrypt) { + uVar3 = *puVar4; + encrypt = encrypt + 4; + *puVar4 = piVar6[2]; + piVar6[2] = uVar3; + uVar3 = puVar4[1]; + puVar4[1] = piVar6[3]; + piVar6[3] = uVar3; + uVar3 = puVar4[2]; + puVar4[2] = piVar6[4]; + piVar6[4] = uVar3; + uVar3 = puVar4[3]; + puVar4[3] = piVar6[5]; + piVar6[5] = uVar3; + puVar4 = puVar4 + 4; + piVar6 = piVar6 + -4; + } + iVar1 = 1; + while (iVar1 < iVar2) { + puVar4 = rk + 4; + uVar5 = *puVar4; + iVar1 = iVar1 + 1; + *puVar4 = Td2[Te4[uVar5 >> 8 & 0xff]] ^ + Td0[Te4[uVar5 >> 0x18]] ^ Td3[Te4[uVar5 & 0xff]] ^ Td1[Te4[uVar5 >> 0x10 & 0xff]]; + uVar5 = rk[5]; + rk[5] = Td2[Te4[uVar5 >> 8 & 0xff]] ^ + Td0[Te4[uVar5 >> 0x18]] ^ Td3[Te4[uVar5 & 0xff]] ^ Td1[Te4[uVar5 >> 0x10 & 0xff]]; + uVar5 = rk[6]; + rk[6] = Td2[Te4[uVar5 >> 8 & 0xff]] ^ + Td0[Te4[uVar5 >> 0x18]] ^ Td3[Te4[uVar5 & 0xff]] ^ Td1[Te4[uVar5 >> 0x10 & 0xff]]; + uVar5 = rk[7]; + rk[7] = Td2[Te4[uVar5 >> 8 & 0xff]] ^ + Td0[Te4[uVar5 >> 0x18]] ^ Td3[Te4[uVar5 & 0xff]] ^ Td1[Te4[uVar5 >> 0x10 & 0xff]]; + rk = puVar4; + } + } + else { + ctx->decrypt = 0; + } + return; +} + + + +void rijndael_decrypt(rijndael_ctx *ctx,u8 *src,u8 *dst) + +{ + byte bVar1; + byte bVar2; + byte bVar3; + u32 *puVar4; + uint uVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint uVar9; + uint uVar10; + uint uVar11; + uint uVar12; + int iVar13; + uint uVar14; + int iVar15; + uint uVar16; + uint uVar17; + uint uVar18; + uint uVar19; + + uVar10 = (uint)*src << 0x18 ^ (uint)src[1] << 0x10 ^ (uint)src[3] ^ (uint)src[2] << 8 ^ + ctx->key[0]; + uVar16 = (uint)src[4] << 0x18 ^ (uint)src[5] << 0x10 ^ (uint)src[7] ^ (uint)src[6] << 8 ^ + ctx->key[1]; + uVar14 = (uint)src[8] << 0x18 ^ (uint)src[9] << 0x10 ^ (uint)src[0xb] ^ (uint)src[10] << 8 ^ + ctx->key[2]; + uVar11 = (uint)src[0xc] << 0x18 ^ (uint)src[0xd] << 0x10 ^ (uint)src[0xf] ^ (uint)src[0xe] << 8 ^ + ctx->key[3]; + iVar13 = ctx->Nr >> 1; + puVar4 = ctx->key; + iVar15 = iVar13; + while( true ) { + uVar5 = Td0[uVar10 >> 0x18] ^ Td3[uVar16 & 0xff] ^ puVar4[4] ^ + *(uint *)((int)Td1 + (uVar11 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Td2 + (uVar14 >> 6 & 0x3fc)); + iVar15 = iVar15 + -1; + uVar17 = uVar5 >> 0x10 & 0xff; + uVar6 = Td0[uVar16 >> 0x18] ^ Td3[uVar14 & 0xff] ^ puVar4[5] ^ + *(uint *)((int)Td1 + (uVar10 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Td2 + (uVar11 >> 6 & 0x3fc)); + uVar8 = Td0[uVar14 >> 0x18] ^ Td3[uVar11 & 0xff] ^ puVar4[6] ^ + *(uint *)((int)Td1 + (uVar16 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Td2 + (uVar10 >> 6 & 0x3fc)); + uVar12 = Td0[uVar11 >> 0x18] ^ Td3[uVar10 & 0xff] ^ puVar4[7] ^ + *(uint *)((int)Td1 + (uVar14 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Td2 + (uVar16 >> 6 & 0x3fc)); + uVar19 = uVar12 >> 0x10 & 0xff; + uVar18 = uVar8 >> 8 & 0xff; + uVar10 = puVar4[8]; + uVar16 = uVar12 >> 8 & 0xff; + uVar11 = uVar6 >> 0x10 & 0xff; + uVar14 = uVar5 >> 8 & 0xff; + uVar9 = uVar8 >> 0x10 & 0xff; + uVar7 = uVar6 >> 8 & 0xff; + if (iVar15 == 0) break; + uVar10 = Td0[uVar5 >> 0x18] ^ Td3[uVar6 & 0xff] ^ uVar10 ^ Td1[uVar19] ^ Td2[uVar18]; + uVar16 = Td0[uVar6 >> 0x18] ^ Td3[uVar8 & 0xff] ^ puVar4[9] ^ Td1[uVar17] ^ Td2[uVar16]; + uVar14 = Td0[uVar8 >> 0x18] ^ Td3[uVar12 & 0xff] ^ puVar4[10] ^ Td1[uVar11] ^ Td2[uVar14]; + uVar11 = Td0[uVar12 >> 0x18] ^ Td3[uVar5 & 0xff] ^ puVar4[0xb] ^ Td1[uVar9] ^ Td2[uVar7]; + puVar4 = puVar4 + 8; + } + puVar4 = ctx->key + iVar13 * 8; + uVar10 = (uint)Td4[uVar5 >> 0x18] << 0x18 ^ (uint)Td4[uVar19] << 0x10 ^ (uint)Td4[uVar6 & 0xff] ^ + (uint)Td4[uVar18] << 8 ^ uVar10; + *dst = (u8)(uVar10 >> 0x18); + dst[1] = (u8)(uVar10 >> 0x10); + dst[2] = (u8)(uVar10 >> 8); + bVar1 = Td4[uVar17]; + bVar2 = Td4[uVar6 >> 0x18]; + bVar3 = Td4[uVar8 & 0xff]; + dst[3] = (u8)uVar10; + uVar10 = (uint)bVar2 << 0x18 ^ (uint)bVar1 << 0x10 ^ (uint)bVar3 ^ (uint)Td4[uVar16] << 8 ^ + puVar4[1]; + dst[4] = (u8)(uVar10 >> 0x18); + dst[5] = (u8)(uVar10 >> 0x10); + dst[6] = (u8)(uVar10 >> 8); + dst[7] = (u8)uVar10; + bVar1 = Td4[uVar12 >> 0x18]; + uVar10 = (uint)Td4[uVar8 >> 0x18] << 0x18 ^ (uint)Td4[uVar11] << 0x10 ^ (uint)Td4[uVar12 & 0xff] ^ + (uint)Td4[uVar14] << 8 ^ puVar4[2]; + dst[8] = (u8)(uVar10 >> 0x18); + dst[9] = (u8)(uVar10 >> 0x10); + dst[0xb] = (u8)uVar10; + bVar2 = Td4[uVar9]; + dst[10] = (u8)(uVar10 >> 8); + uVar10 = (uint)bVar1 << 0x18 ^ (uint)bVar2 << 0x10 ^ (uint)Td4[uVar5 & 0xff] ^ + (uint)Td4[uVar7] << 8 ^ puVar4[3]; + dst[0xc] = (u8)(uVar10 >> 0x18); + dst[0xd] = (u8)(uVar10 >> 0x10); + dst[0xe] = (u8)(uVar10 >> 8); + dst[0xf] = (u8)uVar10; + return; +} + + + +void rijndael_encrypt(rijndael_ctx *ctx,u8 *src,u8 *dst) + +{ + byte bVar1; + byte bVar2; + byte bVar3; + u32 *puVar4; + uint uVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint uVar9; + uint uVar10; + uint uVar11; + uint uVar12; + int iVar13; + uint uVar14; + int iVar15; + uint uVar16; + uint uVar17; + uint uVar18; + uint uVar19; + + uVar10 = (uint)*src << 0x18 ^ (uint)src[1] << 0x10 ^ (uint)src[3] ^ (uint)src[2] << 8 ^ + ctx->key[0]; + uVar16 = (uint)src[4] << 0x18 ^ (uint)src[5] << 0x10 ^ (uint)src[7] ^ (uint)src[6] << 8 ^ + ctx->key[1]; + uVar14 = (uint)src[8] << 0x18 ^ (uint)src[9] << 0x10 ^ (uint)src[0xb] ^ (uint)src[10] << 8 ^ + ctx->key[2]; + uVar11 = (uint)src[0xc] << 0x18 ^ (uint)src[0xd] << 0x10 ^ (uint)src[0xf] ^ (uint)src[0xe] << 8 ^ + ctx->key[3]; + iVar13 = ctx->Nr >> 1; + puVar4 = ctx->key; + iVar15 = iVar13; + while( true ) { + uVar8 = Te0[uVar10 >> 0x18] ^ Te3[uVar11 & 0xff] ^ puVar4[4] ^ + *(uint *)((int)Te1 + (uVar16 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Te2 + (uVar14 >> 6 & 0x3fc)); + iVar15 = iVar15 + -1; + uVar6 = Te0[uVar16 >> 0x18] ^ Te3[uVar10 & 0xff] ^ puVar4[5] ^ + *(uint *)((int)Te1 + (uVar14 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Te2 + (uVar11 >> 6 & 0x3fc)); + uVar5 = Te0[uVar14 >> 0x18] ^ Te3[uVar16 & 0xff] ^ puVar4[6] ^ + *(uint *)((int)Te1 + (uVar11 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Te2 + (uVar10 >> 6 & 0x3fc)); + uVar12 = Te0[uVar11 >> 0x18] ^ Te3[uVar14 & 0xff] ^ puVar4[7] ^ + *(uint *)((int)Te1 + (uVar10 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Te2 + (uVar16 >> 6 & 0x3fc)); + uVar19 = uVar6 >> 0x10 & 0xff; + uVar18 = uVar5 >> 8 & 0xff; + uVar10 = puVar4[8]; + uVar17 = uVar5 >> 0x10 & 0xff; + uVar16 = uVar12 >> 8 & 0xff; + uVar11 = uVar12 >> 0x10 & 0xff; + uVar14 = uVar8 >> 8 & 0xff; + uVar9 = uVar8 >> 0x10 & 0xff; + uVar7 = uVar6 >> 8 & 0xff; + if (iVar15 == 0) break; + uVar10 = Te0[uVar8 >> 0x18] ^ Te3[uVar12 & 0xff] ^ uVar10 ^ Te1[uVar19] ^ Te2[uVar18]; + uVar16 = Te0[uVar6 >> 0x18] ^ Te3[uVar8 & 0xff] ^ puVar4[9] ^ Te1[uVar17] ^ Te2[uVar16]; + uVar14 = Te0[uVar5 >> 0x18] ^ Te3[uVar6 & 0xff] ^ puVar4[10] ^ Te1[uVar11] ^ Te2[uVar14]; + uVar11 = Te0[uVar12 >> 0x18] ^ Te3[uVar5 & 0xff] ^ puVar4[0xb] ^ Te1[uVar9] ^ Te2[uVar7]; + puVar4 = puVar4 + 8; + } + puVar4 = ctx->key + iVar13 * 8; + uVar10 = (uint)Te4[uVar8 >> 0x18] << 0x18 ^ (uint)Te4[uVar19] << 0x10 ^ (uint)Te4[uVar12 & 0xff] ^ + (uint)Te4[uVar18] << 8 ^ uVar10; + *dst = (u8)(uVar10 >> 0x18); + dst[1] = (u8)(uVar10 >> 0x10); + dst[2] = (u8)(uVar10 >> 8); + bVar1 = Te4[uVar17]; + bVar2 = Te4[uVar6 >> 0x18]; + bVar3 = Te4[uVar8 & 0xff]; + dst[3] = (u8)uVar10; + uVar10 = (uint)bVar2 << 0x18 ^ (uint)bVar1 << 0x10 ^ (uint)bVar3 ^ (uint)Te4[uVar16] << 8 ^ + puVar4[1]; + dst[4] = (u8)(uVar10 >> 0x18); + dst[5] = (u8)(uVar10 >> 0x10); + dst[6] = (u8)(uVar10 >> 8); + dst[7] = (u8)uVar10; + bVar1 = Te4[uVar12 >> 0x18]; + uVar10 = (uint)Te4[uVar5 >> 0x18] << 0x18 ^ (uint)Te4[uVar11] << 0x10 ^ (uint)Te4[uVar6 & 0xff] ^ + (uint)Te4[uVar14] << 8 ^ puVar4[2]; + dst[8] = (u8)(uVar10 >> 0x18); + dst[9] = (u8)(uVar10 >> 0x10); + dst[0xb] = (u8)uVar10; + bVar2 = Te4[uVar9]; + dst[10] = (u8)(uVar10 >> 8); + uVar10 = (uint)bVar1 << 0x18 ^ (uint)bVar2 << 0x10 ^ (uint)Te4[uVar5 & 0xff] ^ + (uint)Te4[uVar7] << 8 ^ puVar4[3]; + dst[0xc] = (u8)(uVar10 >> 0x18); + dst[0xd] = (u8)(uVar10 >> 0x10); + dst[0xe] = (u8)(uVar10 >> 8); + dst[0xf] = (u8)uVar10; + return; +} + + + +void Bl_SHA1ProcessMessageBlock(Bl_SHA1_CTX *context) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + UINT32 *pUVar4; + uint uVar5; + UINT32 *pUVar6; + UINT32 *pUVar7; + uint uVar8; + UINT32 UVar9; + uint uVar10; + uint uVar11; + UINT32 UVar12; + uint uVar13; + uint uVar14; + uint uVar15; + UINT32 UVar16; + + pUVar4 = context->Scratch; + pUVar6 = pUVar4; + do { + pUVar7 = pUVar6 + 1; + *pUVar6 = (uint)*(byte *)(pUVar6 + 0x10) << 0x18 | (uint)*(byte *)((int)pUVar6 + 0x41) << 0x10 | + (uint)*(byte *)((int)pUVar6 + 0x42) << 8 | (uint)*(byte *)((int)pUVar6 + 0x43); + pUVar6 = pUVar7; + } while ((UINT32 *)context->Message_Block != pUVar7); + uVar11 = 0; + uVar8 = context->Intermediate_Hash[2]; + uVar10 = context->Intermediate_Hash[0]; + UVar12 = context->Intermediate_Hash[1]; + uVar2 = context->Intermediate_Hash[3]; + UVar16 = context->Intermediate_Hash[4]; + do { + uVar13 = uVar2; + uVar3 = uVar10; + uVar2 = uVar8; + if ((uVar11 & 0x30) == 0) { + UVar9 = context->Scratch[uVar11]; + } + else { + uVar8 = pUVar4[uVar11 + 0xd & 0xf] ^ pUVar4[uVar11 + 8 & 0xf] ^ pUVar4[uVar11 & 0xf] ^ + pUVar4[uVar11 + 2 & 0xf]; + UVar9 = uVar8 >> 0x1f | uVar8 << 1; + pUVar4[uVar11 & 0xf] = UVar9; + } + uVar11 = uVar11 + 1; + uVar10 = UVar9 + ((uVar2 ^ uVar13) & UVar12 ^ uVar13) + + (uVar3 << 5 | uVar3 >> 0x1b) + 0x5a827999 + UVar16; + uVar8 = UVar12 << 0x1e | UVar12 >> 2; + UVar12 = uVar3; + UVar16 = uVar13; + } while (uVar11 != 0x14); + do { + uVar14 = uVar10; + uVar1 = uVar2; + uVar2 = uVar11 + 0xd; + uVar10 = uVar11 + 8; + uVar15 = uVar11 & 0xf; + uVar5 = uVar11 + 2; + uVar11 = uVar11 + 1; + uVar2 = pUVar4[uVar2 & 0xf] ^ pUVar4[uVar10 & 0xf] ^ pUVar4[uVar15] ^ pUVar4[uVar5 & 0xf]; + uVar2 = uVar2 >> 0x1f | uVar2 << 1; + pUVar4[uVar15] = uVar2; + uVar10 = (uVar3 ^ uVar8 ^ uVar1) + (uVar14 << 5 | uVar14 >> 0x1b) + 0x6ed9eba1 + uVar2 + uVar13; + uVar5 = uVar3 << 0x1e | uVar3 >> 2; + uVar2 = uVar8; + uVar3 = uVar14; + uVar8 = uVar5; + uVar13 = uVar1; + } while (uVar11 != 0x28); + do { + uVar8 = uVar10; + uVar13 = uVar11 + 0xd; + uVar10 = uVar11 + 8; + uVar15 = uVar11 & 0xf; + uVar3 = uVar11 + 2; + uVar11 = uVar11 + 1; + uVar10 = pUVar4[uVar13 & 0xf] ^ pUVar4[uVar10 & 0xf] ^ pUVar4[uVar15] ^ pUVar4[uVar3 & 0xf]; + uVar10 = uVar10 >> 0x1f | uVar10 << 1; + pUVar4[uVar15] = uVar10; + uVar10 = ((uVar5 | uVar2) & uVar14 | uVar5 & uVar2) + (uVar8 << 5 | uVar8 >> 0x1b) + 0x8f1bbcdc + + uVar10 + uVar1; + uVar13 = uVar14 << 0x1e | uVar14 >> 2; + uVar1 = uVar2; + uVar14 = uVar8; + uVar3 = uVar2; + uVar2 = uVar5; + uVar5 = uVar13; + } while (uVar11 != 0x3c); + do { + uVar15 = uVar13; + uVar5 = uVar2; + uVar1 = uVar10; + uVar10 = uVar11 + 0xd; + uVar13 = uVar11 + 8; + uVar2 = uVar11 & 0xf; + uVar14 = uVar11 + 2; + uVar11 = uVar11 + 1; + uVar10 = pUVar4[uVar10 & 0xf] ^ pUVar4[uVar13 & 0xf] ^ pUVar4[uVar2] ^ pUVar4[uVar14 & 0xf]; + uVar10 = uVar10 >> 0x1f | uVar10 << 1; + pUVar4[uVar2] = uVar10; + uVar10 = uVar10 + (uVar8 ^ uVar15 ^ uVar5) + (uVar1 << 5 | uVar1 >> 0x1b) + 0xca62c1d6 + uVar3; + uVar13 = uVar8 << 0x1e | uVar8 >> 2; + uVar8 = uVar1; + uVar3 = uVar5; + uVar2 = uVar15; + } while (uVar11 != 0x50); + context->Message_Block_Index = 0; + UVar12 = context->Intermediate_Hash[1]; + context->Intermediate_Hash[0] = uVar10 + context->Intermediate_Hash[0]; + context->Intermediate_Hash[1] = uVar1 + UVar12; + context->Intermediate_Hash[2] = uVar13 + context->Intermediate_Hash[2]; + context->Intermediate_Hash[3] = uVar15 + context->Intermediate_Hash[3]; + context->Intermediate_Hash[4] = uVar5 + context->Intermediate_Hash[4]; + return; +} + + + +int Bl_SHA1Init(Bl_SHA1_CTX *context) + +{ + if (context != (Bl_SHA1_CTX *)0x0) { + context->Intermediate_Hash[0] = 0x67452301; + context->Intermediate_Hash[1] = 0xefcdab89; + context->Intermediate_Hash[2] = 0x98badcfe; + context->Intermediate_Hash[3] = 0x10325476; + context->Length_Low = 0; + context->Length_High = 0; + context->Intermediate_Hash[4] = 0xc3d2e1f0; + *(undefined4 *)&context->Message_Block_Index = 0; + return 0; + } + return 1; +} + + + +int Bl_SHA1Final(Bl_SHA1_CTX *context,UINT8 *Message_Digest) + +{ + short sVar1; + ushort uVar2; + int iVar3; + uint uVar4; + UINT32 UVar5; + SINT16 *pSVar6; + + uVar4 = 1; + if (((context != (Bl_SHA1_CTX *)0x0) && (Message_Digest != (UINT8 *)0x0)) && + (uVar4 = (uint)context->Corrupted, context->Corrupted == 0)) { + if (context->Computed == '\0') { + iVar3 = (int)context->Message_Block_Index; + context->Message_Block_Index = (SINT16)((uint)((iVar3 + 1) * 0x10000) >> 0x10); + context->Message_Block[iVar3] = -0x80; + if (iVar3 < 0x38) { + while( true ) { + sVar1 = context->Message_Block_Index; + if (0x37 < (int)sVar1) break; + context->Message_Block_Index = sVar1 + 1; + context->Message_Block[(int)sVar1] = '\0'; + } + } + else { + while( true ) { + sVar1 = context->Message_Block_Index; + if (0x3f < (int)sVar1) break; + context->Message_Block_Index = sVar1 + 1; + context->Message_Block[(int)sVar1] = '\0'; + } + Bl_SHA1ProcessMessageBlock(context); + while( true ) { + sVar1 = context->Message_Block_Index; + if (0x37 < (int)sVar1) break; + context->Message_Block_Index = sVar1 + 1; + context->Message_Block[(int)sVar1] = '\0'; + } + } + UVar5 = context->Length_High; + *(ushort *)(context->Message_Block + 0x3a) = + *(ushort *)&context->Length_High << 8 | *(ushort *)&context->Length_High >> 8; + context->Message_Block[0x39] = (UINT8)(UVar5 >> 0x10); + uVar2 = *(ushort *)&context->Length_Low; + context->Message_Block[0x38] = (UINT8)(UVar5 >> 0x18); + UVar5 = context->Length_Low; + *(ushort *)(context->Message_Block + 0x3e) = uVar2 << 8 | uVar2 >> 8; + context->Message_Block[0x3d] = (UINT8)(UVar5 >> 0x10); + context->Message_Block[0x3c] = (UINT8)(UVar5 >> 0x18); + Bl_SHA1ProcessMessageBlock(context); + pSVar6 = (SINT16 *)context->Message_Block; + do { + *(UINT8 *)pSVar6 = '\0'; + pSVar6 = (SINT16 *)((int)pSVar6 + 1); + } while (&context->Message_Block_Index != pSVar6); + context->Length_Low = 0; + context->Length_High = 0; + context->Computed = '\x01'; + } + uVar4 = 0; + do { + Message_Digest[uVar4] = + (UINT8)(*(uint *)((int)context->Intermediate_Hash + (uVar4 & 0xfffffffc)) >> + ((~uVar4 & 3) << 3)); + uVar4 = uVar4 + 1; + } while (uVar4 != 0x14); + memset(context,0,0xa0); + return 0; + } + return uVar4; +} + + + +int Bl_SHA1Update(Bl_SHA1_CTX *context,UINT8 *message_array,uint length) + +{ + short sVar1; + UINT8 *pUVar2; + uint uVar3; + UINT32 UVar4; + int iVar5; + + if (length == 0) { + return 0; + } + uVar3 = 1; + if ((context != (Bl_SHA1_CTX *)0x0) && (message_array != (UINT8 *)0x0)) { + if (context->Computed == '\0') { + uVar3 = (uint)context->Corrupted; + if (context->Corrupted == 0) { + pUVar2 = message_array + length; + while ((message_array != pUVar2 && (context->Corrupted == '\0'))) { + sVar1 = context->Message_Block_Index; + iVar5 = ((int)sVar1 + 1) * 0x10000; + context->Message_Block_Index = (SINT16)((uint)iVar5 >> 0x10); + context->Message_Block[(int)sVar1] = *message_array; + UVar4 = context->Length_Low + 8; + context->Length_Low = UVar4; + if ((UVar4 == 0) && + (UVar4 = context->Length_High + 1, context->Length_High = UVar4, UVar4 == 0)) { + context->Corrupted = '\x01'; + } + if (iVar5 >> 0x10 == 0x40) { + Bl_SHA1ProcessMessageBlock(context); + } + message_array = message_array + 1; + } + uVar3 = 0; + } + } + else { + context->Corrupted = '\x03'; + uVar3 = 3; + } + } + return uVar3; +} + + + +void ap_setpsk(cm_ConnectionInfo_t *connPtr,CHAR *ssid,CHAR *passphrase) + +{ + apInfo_t *paVar1; + size_t sVar2; + + paVar1 = cm_GetApInfo(connPtr); + if (paVar1 != (apInfo_t *)0x0) { + sVar2 = strlen(ssid); + (paVar1->bssConfig).comData.SsIdLen = (IEEEtypes_Len_t)sVar2; + memcpy(&(paVar1->bssConfig).comData,ssid,0x20); + sVar2 = strlen(passphrase); + (paVar1->bssConfig).RsnConfig.PSKPassPhraseLen = (UINT8)sVar2; + memcpy((paVar1->bssConfig).RsnConfig.PSKPassPhrase,passphrase,0x40); + return; + } + return; +} + + + +void ap_resetConfiguration(cm_ConnectionInfo_t *connPtr) + +{ + ushort uVar1; + apInfo_t *paVar2; + apSpecificData_t *paVar3; + size_t sVar4; + + paVar2 = cm_GetApInfo(connPtr); + paVar3 = cm_GetApData(connPtr); + if ((paVar2 != (apInfo_t *)0x0) && (paVar3 != (apSpecificData_t *)0x0)) { + sVar4 = strlen("Marvell Micro AP"); + (paVar2->bssConfig).comData.SsIdLen = (IEEEtypes_Len_t)sVar4; + memcpy(&(paVar2->bssConfig).comData,"Marvell Micro AP",0x20); + (paVar2->bssData).updatePassPhrase = 1; + memset(&(paVar2->bssConfig).RsnConfig,0,0x7c); + uVar1 = *(ushort *)&(paVar2->bssConfig).RsnConfig; + (paVar2->bssConfig).RsnConfig.AuthKeyCount = 1; + *(ushort *)&(paVar2->bssConfig).RsnConfig = uVar1 & 0xf7 | 0x108; + *(ushort *)&(paVar2->bssConfig).RsnConfig.wpa2UcstCipher = + *(ushort *)&(paVar2->bssConfig).RsnConfig.wpa2UcstCipher & 0xf7 | 0x108; + (paVar2->bssConfig).RsnConfig.MaxPwsHskRetries = '\x03'; + (paVar2->bssConfig).RsnConfig.MaxGrpHskRetries = '\x03'; + (paVar2->bssConfig).RsnConfig.PwsHskTimeOut = 100; + (paVar2->bssConfig).RsnConfig.GrpHskTimeOut = 100; + (paVar2->bssConfig).RsnConfig.GrpReKeyTime = 0x15180; + } + return; +} + + + +void InitializeAp(cm_ConnectionInfo_t *connPtr) + +{ + ushort uVar1; + apInfo_t *paVar2; + apSpecificData_t *paVar3; + size_t sVar4; + + paVar2 = cm_GetApInfo(connPtr); + paVar3 = cm_GetApData(connPtr); + if ((paVar2 != (apInfo_t *)0x0) && (paVar3 != (apSpecificData_t *)0x0)) { + sVar4 = strlen("Marvell Micro AP"); + (paVar2->bssConfig).comData.SsIdLen = (IEEEtypes_Len_t)sVar4; + memcpy(&(paVar2->bssConfig).comData,"Marvell Micro AP",0x20); + (paVar2->bssData).updatePassPhrase = 1; + memset(&(paVar2->bssConfig).RsnConfig,0,0x7c); + uVar1 = *(ushort *)&(paVar2->bssConfig).RsnConfig; + (paVar2->bssConfig).RsnConfig.AuthKeyCount = 1; + *(ushort *)&(paVar2->bssConfig).RsnConfig = uVar1 & 0xf7 | 0x108; + *(ushort *)&(paVar2->bssConfig).RsnConfig.wpa2UcstCipher = + *(ushort *)&(paVar2->bssConfig).RsnConfig.wpa2UcstCipher & 0xf7 | 0x108; + (paVar2->bssConfig).RsnConfig.MaxPwsHskRetries = '\x03'; + (paVar2->bssConfig).RsnConfig.MaxGrpHskRetries = '\x03'; + (paVar2->bssConfig).RsnConfig.PwsHskTimeOut = 100; + (paVar2->bssConfig).RsnConfig.GrpHskTimeOut = 100; + (paVar2->bssConfig).RsnConfig.GrpReKeyTime = 0x15180; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +u32_conflict3 ipc_emb2app_rawstatus_get(void) + +{ + return _DAT_44800004; +} + + + +void ipc_host_init(ipc_host_env_tag *env,ipc_host_cb_tag *cb, + ipc_shared_env_tag_conflict3 *shared_env_ptr,void *pthis) + +{ + printf("[IPC] [TX] Low level size %d, driver size %d, total size %d\r\n",internel_cal_size_tx_desc + ,internel_cal_size_tx_hdr,internel_cal_size_tx_desc + internel_cal_size_tx_hdr); + utils_list_init(&tx_list_bl); + memset(env,0,0xe4); + *(ipc_shared_env_tag_conflict3 **)&env->shared = shared_env_ptr; + memcpy(env,cb,0x20); + env->rx_bufnb = 2; + env->rxdesc_nb = '\x02'; + env->ipc_e2amsg_bufnb = 8; + env->ipc_e2amsg_bufsz = 0x3e0; + env->pthis = pthis; + env->rx_bufsz = 0x800; + env->tx_host_id = env->tx_host_id0; + env->txdesc = (txdesc_host *)shared_env_ptr->txdesc0; + memset((txdesc_host *)shared_env_ptr->txdesc0,0,0xcc0); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int ipc_host_msg_push(ipc_host_env_tag *env,void *msg_buf,uint16_t len) + +{ + undefined2 in_register_00002032; + int iVar1; + ipc_shared_env_tag_conflict30 *piVar2; + int iVar3; + + iVar1 = *(int *)((int)msg_buf + 0xc); + piVar2 = env->shared; + iVar3 = 0; + while (iVar3 < CONCAT22(in_register_00002032,len)) { + *(undefined4 *)((int)(piVar2->msg_a2e_buf).msg + iVar3) = *(undefined4 *)(iVar1 + iVar3); + iVar3 = iVar3 + 4; + } + env->msga2e_hostid = msg_buf; + _DAT_44800000 = 2; + return 0; +} + + + +uint32_t ipc_host_get_rawstatus(ipc_host_env_tag *env) + +{ + u32_conflict3 uVar1; + + uVar1 = ipc_emb2app_rawstatus_get(); + return uVar1; +} + + + +txdesc_host * ipc_host_txdesc_get(ipc_host_env_tag *env) + +{ + uint uVar1; + uint uVar2; + + uVar1 = env->txdesc_used_idx; + uVar2 = env->txdesc_free_idx; + if (uVar2 < uVar1) { + used_issue = used_issue + 1; + } + if (uVar1 + 4 != uVar2) { + if (uVar2 - uVar1 < 5) { + return env->txdesc + (uVar2 & 3); + } + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + return (txdesc_host *)0x0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_host_txdesc_push(ipc_host_env_tag *env,void *host_id) + +{ + uint uVar1; + + uVar1 = env->txdesc_free_idx & 3; + env->txdesc[uVar1].ready = 0xffffffff; + env->tx_host_id[uVar1] = host_id; + env->txdesc_free_idx = env->txdesc_free_idx + 1; + _DAT_44800000 = 0x100; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_host_irq(ipc_host_env_tag *env,uint32_t status) + +{ + uint uVar1; + uint8_t uVar2; + int iVar3; + undefined3 extraout_var; + void *pvVar4; + anon_subr_uint8_t_void_ptr_void_ptr_for_recv_msgack_ind *paVar5; + uint uVar6; + int *piVar7; + uint uVar8; + + uVar1 = _DAT_4480001c | status; + _DAT_44800008 = status; + if ((uVar1 & 0x780) != 0) { + piVar7 = nx_txdesc_cnt_msk; + uVar8 = 7; + do { + if ((1 << (uVar8 & 0x1f) & uVar1) != 0) { + while( true ) { + uVar6 = env->txdesc_used_idx & *piVar7; + if ((env->tx_host_id[uVar6] == (void *)0x0) || + (iVar3 = (*(env->cb).send_data_cfm)(env->pthis,env->tx_host_id[uVar6]), iVar3 != 0)) + break; + env->tx_host_id[uVar6] = (void *)0x0; + env->txdesc_used_idx = env->txdesc_used_idx + 1; + bl_tx_notify(); + } + } + uVar8 = uVar8 + 1; + piVar7 = (int *)((uint *)piVar7 + 1); + } while (uVar8 != 0xb); + } + bl_tx_resend(); + if ((uVar1 & 4) != 0) { + pvVar4 = env->msga2e_hostid; + env->msga2e_cnt = env->msga2e_cnt + '\x01'; + paVar5 = (env->cb).recv_msgack_ind; + env->msga2e_hostid = (void *)0x0; + (*paVar5)(env->pthis,pvVar4); + } + if ((uVar1 & 1) != 0) { + do { + uVar2 = (*(env->cb).recv_dbg_ind) + (env->pthis, + (&(env->cb).recv_data_ind)[((uint)env->ipc_host_dbg_idx + 0x16) * 2]); + } while (CONCAT31(extraout_var,uVar2) == 0); + } + if ((uVar1 & 0x10) != 0) { + (*(env->cb).prim_tbtt_ind)(env->pthis); + } + if ((uVar1 & 0x20) != 0) { + // WARNING: Could not recover jumptable at 0x23021b72. Too many branches + // WARNING: Treating indirect jump as call + (*(env->cb).sec_tbtt_ind)(env->pthis); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_host_enable_irq(ipc_host_env_tag *env,uint32_t value) + +{ + _DAT_4480000c = value; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_host_disable_irq_e2a(void) + +{ + _DAT_44800010 = 0x7ff; + return; +} + + + +int bl_main_disconnect(void) + +{ + bl_send_sm_disconnect_req(&wifi_hw,0x34); + return 0; +} + + + +int bl_main_powersaving(int mode) + +{ + int iVar1; + + iVar1 = bl_send_mm_powersaving_req(&wifi_hw,mode); + return iVar1; +} + + + +int bl_main_denoise(int mode) + +{ + int iVar1; + + iVar1 = bl_send_mm_denoise_req(&wifi_hw,mode); + return iVar1; +} + + + +int bl_main_monitor(void) + +{ + undefined auStack56 [4]; + mm_monitor_cfm cfm; + + memset(auStack56,0,0x28); + bl_send_monitor_enable(&wifi_hw,(mm_monitor_cfm *)auStack56); + return 0; +} + + + +int bl_main_phy_up(void) + +{ + int iVar1; + + iVar1 = bl_send_start(&wifi_hw); + if (iVar1 == 0) { + wifi_hw.drv_flags = wifi_hw.drv_flags | 4; + } + else { + iVar1 = -1; + } + return iVar1; +} + + + +int bl_main_monitor_channel_set(int channel,int use_40MHZ) + +{ + undefined auStack56 [4]; + mm_monitor_channel_cfm cfm; + + bl_send_monitor_channel_set(&wifi_hw,(mm_monitor_channel_cfm *)auStack56,channel,use_40MHZ); + return 0; +} + + + +int bl_main_if_remove(uint8_t vif_index) + +{ + undefined3 in_register_00002029; + + printf("[WF] MM_REMOVE_IF_REQ Sending with vif_index %u...\r\n", + CONCAT31(in_register_00002029,vif_index)); + bl_send_remove_if(&wifi_hw,vif_index); + printf("[WF] MM_REMOVE_IF_REQ Done\r\n"); + return 0; +} + + + +int bl_main_raw_send(uint8_t *pkt,int len) + +{ + int iVar1; + + iVar1 = bl_send_scanu_raw_send(&wifi_hw,pkt,len); + return iVar1; +} + + + +int bl_main_rate_config(uint8_t sta_idx,uint16_t fixed_rate_cfg) + +{ + int iVar1; + + iVar1 = bl_send_me_rate_config_req(&wifi_hw,sta_idx,fixed_rate_cfg); + return iVar1; +} + + + +int bl_main_set_country_code(char *country_code) + +{ + bl_msg_update_channel_cfg(country_code); + bl_send_me_chan_config_req(&wifi_hw); + return 0; +} + + + +int bl_main_get_channel_nums(void) + +{ + return channel_num_default; +} + + + +int bl_main_if_add(int is_sta,netif *netif,uint8_t *vif_index) + +{ + uint uVar1; + int iVar2; + undefined *puVar3; + mm_add_if_cfm amStack36 [2]; + mm_add_if_cfm add_if_cfm; + + if (is_sta == 0) { + puVar3 = &UNK_230b0f08; + } + else { + puVar3 = &UNK_230b0f04; + } + printf("[WF] MM_ADD_IF_REQ Sending: %s\r\n",puVar3); + iVar2 = bl_send_add_if(&wifi_hw,netif->hwaddr,(is_sta == 0) + NL80211_IFTYPE_STATION,false, + amStack36); + printf("[WF] MM_ADD_IF_REQ Done\r\n"); + if (iVar2 == 0) { + if (amStack36[0].status == '\0') { + uVar1 = (uint)amStack36[0].inst_nbr; + if (is_sta != 0) { + wifi_hw.vif_index_sta = (uint)amStack36[0].inst_nbr; + uVar1 = wifi_hw.vif_index_ap; + } + wifi_hw.vif_index_ap = uVar1; + *vif_index = amStack36[0].inst_nbr; + printf("[WF] vif_index from LAMC is %d\r\n"); + wifi_hw.vif_table[amStack36[0].inst_nbr].dev = netif; + wifi_hw.vif_table[amStack36[0].inst_nbr].up = true; + } + else { + printf("%s: Status Error(%d)\n",&UNK_230b0f4c); + iVar2 = -5; + } + } + return iVar2; +} + + + +int bl_main_apm_start(char *ssid,char *password,int channel,uint8_t vif_index,uint8_t hidden_ssid) + +{ + int iVar1; + undefined3 in_register_00002035; + apm_start_cfm local_24; + apm_start_cfm start_ap_cfm; + + memset(&local_24,0,4); + printf("[WF] APM_START_REQ Sending with vif_index %u\r\n",CONCAT31(in_register_00002035,vif_index) + ); + iVar1 = bl_send_apm_start_req(&wifi_hw,&local_24,ssid,password,channel,vif_index,hidden_ssid); + printf("[WF] APM_START_REQ Done\r\n"); + printf("[WF] status is %02X\r\n",(uint)local_24.status); + printf("[WF] vif_idx is %02X\r\n",(uint)local_24.vif_idx); + printf("[WF] ch_idx is %02X\r\n",(uint)local_24.ch_idx); + printf("[WF] bcmc_idx is %02X\r\n",(uint)local_24.bcmc_idx); + wifi_hw.ap_bcmc_idx = (uint)local_24.bcmc_idx; + return iVar1; +} + + + +int bl_main_apm_stop(uint8_t vif_index) + +{ + undefined3 in_register_00002029; + int iVar1; + + printf("[WF] APM_STOP_REQ Sending with vif_index %u\r\n",CONCAT31(in_register_00002029,vif_index)) + ; + iVar1 = bl_send_apm_stop_req(&wifi_hw,vif_index); + printf("[WF] APM_STOP_REQ Done\r\n"); + return iVar1; +} + + + +int bl_main_apm_sta_cnt_get(uint8_t *sta_cnt) + +{ + *sta_cnt = '\f'; + return 0; +} + + + +int bl_main_apm_sta_info_get(wifi_apm_sta_info *apm_sta_info,uint8_t idx) + +{ + undefined3 in_register_0000202d; + int iVar1; + + iVar1 = CONCAT31(in_register_0000202d,idx); + if (wifi_hw.sta_table[iVar1].is_used != '\0') { + apm_sta_info->sta_idx = wifi_hw.sta_table[iVar1].sta_idx; + apm_sta_info->is_used = wifi_hw.sta_table[iVar1].is_used; + apm_sta_info->rssi = (int)wifi_hw.sta_table[iVar1].rssi; + apm_sta_info->tsflo = wifi_hw.sta_table[iVar1].tsflo; + apm_sta_info->tsfhi = wifi_hw.sta_table[iVar1].tsfhi; + apm_sta_info->data_rate = wifi_hw.sta_table[iVar1].data_rate; + memcpy(apm_sta_info->sta_mac,wifi_hw.sta_table + iVar1,6); + return 0; + } + return 0; +} + + + +int bl_main_apm_sta_delete(uint8_t sta_idx) + +{ + byte vif_idx; + undefined3 in_register_00002029; + int iVar1; + int iVar2; + apm_sta_del_cfm aStack36; + apm_sta_del_cfm sta_del_cfm; + + iVar1 = CONCAT31(in_register_00002029,sta_idx); + memset(&aStack36,0,3); + vif_idx = wifi_hw.sta_table[iVar1].vif_idx; + printf("[WF] APM_STA_DEL_REQ: sta_idx = %u, vif_idx = %u\r\n",iVar1,(uint)vif_idx); + bl_send_apm_sta_del_req(&wifi_hw,&aStack36,sta_idx,vif_idx); + iVar2 = -1; + if (aStack36.status == '\0') { + memset(wifi_hw.sta_table + iVar1,0,0x1c); + iVar2 = 0; + } + return iVar2; +} + + + +int bl_main_apm_remove_all_sta(void) + +{ + uint8_t sta_idx; + u8 *puVar1; + + puVar1 = &wifi_hw.sta_table[0].is_used; + sta_idx = '\0'; + do { + if (*puVar1 == '\x01') { + bl_main_apm_sta_delete(sta_idx); + } + sta_idx = sta_idx + '\x01'; + puVar1 = puVar1 + 0x1c; + } while (sta_idx != '\f'); + return 0; +} + + + +int bl_main_conf_max_sta(uint8_t max_sta_supported) + +{ + int iVar1; + + iVar1 = bl_send_apm_conf_max_sta_req(&wifi_hw,max_sta_supported); + return iVar1; +} + + + +int bl_main_cfg_task_req + (uint32_t ops,uint32_t task,uint32_t element,uint32_t type,void *arg1,void *arg2) + +{ + int iVar1; + + iVar1 = bl_send_cfg_task_req(&wifi_hw,ops,task,element,type,arg1,arg2); + return iVar1; +} + + + +int bl_main_scan(void) + +{ + bl_send_scanu_req(&wifi_hw); + return 0; +} + + + +int bl_cfg80211_connect(bl_hw *bl_hw,cfg80211_connect_params *sme) + +{ + int iVar1; + sm_connect_cfm asStack20 [4]; + sm_connect_cfm sm_connect_cfm; + + iVar1 = bl_send_sm_connect_req(bl_hw,sme,asStack20); + if (iVar1 == 0) { + iVar1 = -5; + if ((byte)asStack20[0] < 10) { + iVar1 = (int)(char)CSWTCH_6[(byte)asStack20[0]]; + } + } + return iVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bl_main_connect(uint8_t *ssid,int ssid_len,uint8_t *psk,int psk_len,uint8_t *pmk,int pmk_len, + uint8_t *mac,uint8_t band,uint16_t freq) + +{ + short in_stack_00000000; + nl80211_band anStack272 [4]; + cfg80211_connect_params sme; + + memset(anStack272,0,0xf0); + sme.crypto.cipher_group = 0; + sme.ssid_len._0_1_ = __NL80211_AUTHTYPE_NUM; + sme.pmk._0_1_ = (u8)psk_len; + sme.pmk._1_1_ = (u8)pmk_len; + if (mac != (uint8_t *)0x0) { + sme.channel_hint = (ieee80211_channel *)mac; + } + if (in_stack_00000000 != 0) { + sme.channel._4_4_ = 0; + anStack272[0] = band; + } + sme.bssid_hint = ssid; + sme.ssid = (u8 *)ssid_len; + sme.crypto.wep_tx_key = (int)psk; + sme.key = pmk; + bl_cfg80211_connect(&wifi_hw,(cfg80211_connect_params *)anStack272); + return 0; +} + + + +void bl_main_event_handle(void) + +{ + bl_irq_bottomhalf(&wifi_hw); + bl_tx_try_flush(); + return; +} + + + +void bl_main_lowlevel_init(void) + +{ + bl_irqs_init(&wifi_hw); + return; +} + + + +int bl_main_rtthread_start(bl_hw **bl_hw) + +{ + int iVar1; + char *fmt; + + bl_main_lowlevel_init(); + *bl_hw = &wifi_hw; + wifi_hw.vifs.next = &wifi_hw.vifs; + wifi_hw.vifs.prev = &wifi_hw.vifs; + wifi_hw.mod_params = &bl_mod_params; + iVar1 = bl_platform_on(&wifi_hw); + if (iVar1 == 0) { + ipc_host_enable_irq(wifi_hw.ipc_env,0x7ff); + bl_wifi_enable_irq(); + iVar1 = bl_send_reset(&wifi_hw); + if (iVar1 == 0) { + vTaskDelay(5); + iVar1 = bl_send_version_req(&wifi_hw,&wifi_hw.version_cfm); + if (iVar1 != 0) { + return 0; + } + printf("[version] lmac %u.%u.%u.%u\r\n",wifi_hw.version_cfm.version_lmac >> 0x18, + wifi_hw.version_cfm.version_lmac >> 0x10 & 0xff, + wifi_hw.version_cfm.version_lmac >> 8 & 0xff,wifi_hw.version_cfm.version_lmac & 0xff); + printf("[version] version_machw_1 %08X\r\n",wifi_hw.version_cfm.version_machw_1); + printf("[version] version_machw_2 %08X\r\n",wifi_hw.version_cfm.version_machw_2); + printf("[version] version_phy_1 %08X\r\n",wifi_hw.version_cfm.version_phy_1); + printf("[version] version_phy_2 %08X\r\n",wifi_hw.version_cfm.version_phy_2); + printf("[version] features %08X\r\n",wifi_hw.version_cfm.features); + iVar1 = bl_handle_dynparams(&wifi_hw); + if (iVar1 == 0) { + bl_send_me_config_req(&wifi_hw); + bl_send_me_chan_config_req(&wifi_hw); + wifi_hw.status = RWNX_INTERFACE_STATUS_UP; + return 0; + } + fmt = "bl_handle_dynparams Error\r\n"; + } + else { + fmt = "bl_send_reset Error\r\n"; + } + } + else { + fmt = "bl_platform_on Error\r\n"; + } + printf(fmt); + return 0; +} + + + +int bl_handle_dynparams(bl_hw *bl_hw) + +{ + ushort uVar1; + short sVar2; + char "bl_handle_dynparams" [20]; + int iVar3; + short sVar4; + uint uVar5; + bl_mod_params *pbVar6; + + uVar5 = bl_hw->flags; + bl_hw->flags = uVar5 | 0x40000; + pbVar6 = bl_hw->mod_params; + if (pbVar6->tdls != false) { + bl_hw->flags = uVar5 | 0x58000; + } + if (pbVar6->ap_uapsd_on != false) { + bl_hw->flags = bl_hw->flags | 0x4000; + } + if (5 < (uint)pbVar6->phy_cfg) { + pbVar6->phy_cfg = 2; + } + if (2 < (uint)bl_hw->mod_params->mcs_map) { + bl_hw->mod_params->mcs_map = 0; + } + uVar1 = (bl_hw->ht_cap).cap; + pbVar6 = bl_hw->mod_params; + iVar3 = pbVar6->nss; + (bl_hw->ht_cap).cap = uVar1 | 0x100; + if (pbVar6->ldpc_on != false) { + (bl_hw->ht_cap).cap = uVar1 | 0x101; + } + sVar2 = (short)iVar3; + if (pbVar6->use_2040 == false) { + (bl_hw->ht_cap).mcs.rx_highest = sVar2 * 0x41; + (bl_hw->ht_cap).mcs.rx_mask[0] = -1; + } + else { + uVar1 = (bl_hw->ht_cap).cap; + (bl_hw->ht_cap).mcs.rx_mask[4] = '\x01'; + (bl_hw->ht_cap).cap = uVar1 | 2; + (bl_hw->ht_cap).mcs.rx_highest = sVar2 * 0x87; + } + if (1 < iVar3) { + (bl_hw->ht_cap).cap = (bl_hw->ht_cap).cap | 0x80; + } + if (pbVar6->sgi != false) { + uVar1 = (bl_hw->ht_cap).cap; + (bl_hw->ht_cap).cap = uVar1 | 0x20; + if (pbVar6->use_2040 == false) { + sVar4 = 0x48; + } + else { + (bl_hw->ht_cap).cap = uVar1 | 0x60; + sVar4 = 0x96; + } + (bl_hw->ht_cap).mcs.rx_highest = sVar2 * sVar4; + } + (bl_hw->ht_cap).cap = (bl_hw->ht_cap).cap | 0xc; + if (pbVar6->ht_on == false) { + (bl_hw->ht_cap).ht_supported = false; + } + if (pbVar6->custregd != false) { + printf("\n\n%s: CAUTION: USING PERMISSIVE CUSTOM REGULATORY RULES\n\n","bl_handle_dynparams"); + return 0; + } + return 0; +} + + + +int bl_send_msg(bl_hw *bl_hw,void *msg_params,int reqcfm,lmac_msg_id_t reqid,void *cfm) + +{ + ushort uVar1; + lmac_msg_id_t lVar2; + bool bVar3; + char "bl_send_msg" [12]; + bl_cmd *__s; + int iVar4; + undefined2 in_register_00002036; + lmac_msg *pv; + + iVar4 = CONCAT22(in_register_00002036,reqid); + pv = (lmac_msg *)((int)msg_params + -8); + if ((((((bl_hw->drv_flags >> 2 & 1) == 0) && ((reqid & 0xfffd) != 1)) && (iVar4 != 5)) && + ((iVar4 != 0x23 && ((reqid & 0xfffd) != 0x1401)))) && (iVar4 != 0x32)) { + printf("%s: bypassing (RWNX_DEV_RESTARTING set) 0x%02x\n","bl_send_msg",iVar4); + } + else { + if (bl_hw->ipc_env != (ipc_host_env_tag *)0x0) { + uVar1 = *(ushort *)((int)msg_params + -8); + bVar3 = true; + if (((uVar1 != 0x41) && (uVar1 != 0x50)) && ((uVar1 + 0xebf4 & 0xfffb) != 0)) { + bVar3 = (uVar1 & 0xfffb) == 0x2408; + } + __s = (bl_cmd *)pvPortMalloc(0x40); + if (__s == (bl_cmd *)0x0) { + vPortFree(pv); + printf("%s: failed to allocate mem for cmd, size is %d\r\n",0x230b1188,0x40); + return -0xc; + } + memset(__s,0,0x40); + __s->result = 4; + lVar2 = *(lmac_msg_id_t *)((int)msg_params + -8); + __s->reqid = reqid; + __s->a2e_msg = pv; + __s->id = lVar2; + __s->e2a_msg = cfm; + if (bVar3) { + __s->flags = 1; + } + if (reqcfm != 0) { + __s->flags = __s->flags | 2; + } + iVar4 = (*(bl_hw->cmd_mgr).queue)(&bl_hw->cmd_mgr,__s); + if (!bVar3) { + vPortFree(__s); + return iVar4; + } + return __s->result; + } + printf("%s: bypassing (restart must have failed)\r\n",0x230b1188); + } + vPortFree(pv); + return -0x10; +} + + + +void * bl_msg_zalloc(lmac_msg_id_t id,lmac_task_id_t dest_id,uint16_t param_len) + +{ + lmac_msg_id_t *__s; + undefined2 in_register_00002032; + size_t xWantedSize; + + xWantedSize = CONCAT22(in_register_00002032,param_len) + 8; + __s = (lmac_msg_id_t *)pvPortMalloc(xWantedSize); + if (__s == (lmac_msg_id_t *)0x0) { + printf("%s: msg allocation failed\n",0x230b1178); + } + else { + memset(__s,0,xWantedSize); + *__s = id; + __s[1] = dest_id; + __s[2] = 100; + __s[3] = param_len; + __s = __s + 4; + } + return __s; +} + + + +void bl_msg_update_channel_cfg(char *code) + +{ + int iVar1; + int iVar2; + char *fmt; + ieee80211_dot_d *piVar3; + + piVar3 = country_list; + iVar1 = 0; + do { + iVar2 = strcmp(piVar3->code,code); + if (iVar2 == 0) { + fmt = "[WF] country code %s used, num of channel %d\r\n"; + channel_num_default = country_list[iVar1].channel_num; + channels_default = country_list[iVar1].channels; + goto LAB_23022596; + } + iVar1 = iVar1 + 1; + piVar3 = piVar3 + 1; + } while (iVar1 != 4); + channel_num_default = 0xe; + channels_default = bl_channels_24_JP; + fmt = "[WF] %s NOT found, using JP instead, num of channel %d\r\n"; +LAB_23022596: + printf(fmt,code,channel_num_default); + return; +} + + + +int bl_msg_get_channel_nums(void) + +{ + return channel_num_default; +} + + + +int bl_send_reset(bl_hw *bl_hw) + +{ + void *msg_params; + int iVar1; + + msg_params = bl_msg_zalloc(0,0,0); + if (msg_params != (void *)0x0) { + iVar1 = bl_send_msg(bl_hw,msg_params,1,1,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_monitor_enable(bl_hw *bl_hw,mm_monitor_cfm *cfm) + +{ + undefined4 *msg_params; + int iVar1; + + msg_params = (undefined4 *)bl_msg_zalloc(0x5c,0,4); + if (msg_params != (undefined4 *)0x0) { + *msg_params = 1; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x5d,cfm); + return iVar1; + } + return -0xc; +} + + + +int bl_send_monitor_channel_set(bl_hw *bl_hw,mm_monitor_channel_cfm *cfm,int channel,int use_40Mhz) + +{ + uint uVar1; + uint *msg_params; + int iVar2; + + msg_params = (uint *)bl_msg_zalloc(0x5e,0,0xc); + if (msg_params == (uint *)0x0) { + return -0xc; + } + if (channel - 1U < 0xe) { + if (channel == 0xe) { + uVar1 = 0x9b4; + } + else { + uVar1 = channel * 5 + 0x967U & 0xffff; + } + } + else { + uVar1 = 0xffff; + } + *msg_params = uVar1; + if (use_40Mhz == 0) { + msg_params[1] = 0; + } + else { + msg_params[1] = 1; + if (use_40Mhz != 1) { + msg_params[2] = 1; + goto LAB_230226b8; + } + } + msg_params[2] = 0; +LAB_230226b8: + iVar2 = bl_send_msg(bl_hw,msg_params,1,0x5f,cfm); + return iVar2; +} + + + +int bl_send_version_req(bl_hw *bl_hw,mm_version_cfm *cfm) + +{ + void *msg_params; + int iVar1; + + msg_params = bl_msg_zalloc(4,0,0); + if (msg_params != (void *)0x0) { + iVar1 = bl_send_msg(bl_hw,msg_params,1,5,cfm); + return iVar1; + } + return -0xc; +} + + + +int bl_send_me_config_req(bl_hw *bl_hw) + +{ + u8 *puVar1; + u16 *msg_params; + int iVar2; + u8 *puVar3; + ieee80211_mcs_info *piVar4; + + msg_params = (u16 *)bl_msg_zalloc(0x1400,5,0x34); + if (msg_params != (u16 *)0x0) { + printf("[ME] HT supp %d, VHT supp %d\r\n",1,0); + msg_params[0x17] = 1; + *msg_params = (bl_hw->ht_cap).cap; + *(u8 *)(msg_params + 1) = (bl_hw->ht_cap).ampdu_density << 2 | (bl_hw->ht_cap).ampdu_factor; + piVar4 = &(bl_hw->ht_cap).mcs; + puVar3 = (u8 *)((int)msg_params + 3); + while (piVar4 != (ieee80211_mcs_info *)&bl_hw->vif_started) { + puVar1 = piVar4->rx_mask; + piVar4 = (ieee80211_mcs_info *)(piVar4->rx_mask + 1); + *puVar3 = *puVar1; + puVar3 = puVar3 + 1; + } + msg_params[10] = 0; + *(undefined4 *)(msg_params + 0xc) = 0; + *(undefined *)(msg_params + 0xe) = 0; + *(_Bool *)(msg_params + 0x18) = bl_hw->mod_params->ps_on; + msg_params[0x16] = (u16)bl_hw->mod_params->tx_lft; + iVar2 = bl_send_msg(bl_hw,msg_params,1,0x1401,(void *)0x0); + return iVar2; + } + return -0xc; +} + + + +int bl_send_me_chan_config_req(bl_hw *bl_hw) + +{ + byte bVar1; + void *msg_params; + int iVar2; + uint uVar3; + u16 *puVar4; + + msg_params = bl_msg_zalloc(0x1402,5,0xfe); + if (msg_params == (void *)0x0) { + return -0xc; + } + *(undefined *)((int)msg_params + 0xfc) = 0; + iVar2 = 0; + while (iVar2 < channel_num_default) { + bVar1 = *(byte *)((int)msg_params + 0xfc); + puVar4 = (u16 *)((uint)bVar1 * 6 + (int)msg_params); + *(undefined *)((int)puVar4 + 3) = 0; + if ((channels_default[iVar2].flags & 1) != 0) { + *(undefined *)((int)puVar4 + 3) = 2; + } + uVar3 = channels_default[iVar2].flags; + *(undefined *)(puVar4 + 1) = 0; + *(byte *)((int)puVar4 + 3) = (uVar3 & 10) != 0 | *(byte *)((int)puVar4 + 3); + *puVar4 = channels_default[iVar2].center_freq; + *(char *)(puVar4 + 2) = (char)channels_default[iVar2].max_power; + uVar3 = (uint)bVar1 + 1 & 0xff; + *(undefined *)((int)msg_params + 0xfc) = (char)uVar3; + if (uVar3 == 0xe) break; + iVar2 = iVar2 + 1; + } + *(undefined *)((int)msg_params + 0xfd) = 0; + iVar2 = bl_send_msg(bl_hw,msg_params,1,0x1403,(void *)0x0); + return iVar2; +} + + + +int bl_send_me_rate_config_req(bl_hw *bl_hw,uchar sta_idx,uint16_t fixed_rate_cfg) + +{ + uchar *msg_params; + int iVar1; + + msg_params = (uchar *)bl_msg_zalloc(0x1410,5,4); + if (msg_params != (uchar *)0x0) { + *msg_params = sta_idx; + *(uint16_t *)(msg_params + 2) = fixed_rate_cfg; + iVar1 = bl_send_msg(bl_hw,msg_params,0,0,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_start(bl_hw *bl_hw) + +{ + void *__dest; + int iVar1; + + __dest = bl_msg_zalloc(2,0,0x48); + if (__dest != (void *)0x0) { + (bl_hw->phy_config).parameters[0] = 1; + memcpy(__dest,&bl_hw->phy_config,0x40); + *(int *)((int)__dest + 0x40) = bl_hw->mod_params->uapsd_timeout; + *(undefined2 *)((int)__dest + 0x44) = (short)bl_hw->mod_params->lp_clk_ppm; + iVar1 = bl_send_msg(bl_hw,__dest,1,3,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_add_if(bl_hw *bl_hw,uchar *mac,nl80211_iftype iftype,_Bool p2p,mm_add_if_cfm *cfm) + +{ + undefined *msg_params; + int iVar1; + undefined uVar2; + + msg_params = (undefined *)bl_msg_zalloc(6,0,8); + if (msg_params == (undefined *)0x0) { + return -0xc; + } + memcpy(msg_params + 1,mac,6); + switch((uint)iftype - 1 & 0xff) { + case 0: + uVar2 = 1; + break; + case 3: + return -1; + case 6: + uVar2 = 3; + break; + case 7: + msg_params[7] = 1; + default: + *msg_params = 0; + goto LAB_230229c2; + case 8: + msg_params[7] = 1; + case 2: + uVar2 = 2; + } + *msg_params = uVar2; +LAB_230229c2: + iVar1 = bl_send_msg(bl_hw,msg_params,1,7,cfm); + return iVar1; +} + + + +int bl_send_remove_if(bl_hw *bl_hw,uchar inst_nbr) + +{ + uchar *msg_params; + int iVar1; + + msg_params = (uchar *)bl_msg_zalloc(8,0,1); + if (msg_params != (uchar *)0x0) { + *msg_params = inst_nbr; + iVar1 = bl_send_msg(bl_hw,msg_params,1,9,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_scanu_req(bl_hw *bl_hw) + +{ + u16 uVar1; + u16 *msg_params; + int iVar2; + ieee80211_channel *piVar3; + int iVar4; + u16 *puVar5; + + msg_params = (u16 *)bl_msg_zalloc(0x1000,4,0x154); + if (msg_params != (u16 *)0x0) { + iVar4 = bl_hw->vif_index_sta; + msg_params[0xa6] = 0; + *(char *)(msg_params + 0xa7) = (char)iVar4; + iVar4 = channel_num_default; + *(undefined *)((int)msg_params + 0x14f) = (char)channel_num_default; + *(undefined4 *)(msg_params + 0xa0) = 0xffffffff; + msg_params[0xa2] = 0xffff; + msg_params[0xa8] = 0x100; + *(undefined4 *)(msg_params + 0xa4) = 0; + iVar2 = 0; + puVar5 = msg_params; + while (iVar2 < (int)(iVar4 & 0xffU)) { + piVar3 = channels_default + iVar2; + *(nl80211_band *)(puVar5 + 1) = piVar3->band; + uVar1 = piVar3->center_freq; + *(undefined *)((int)puVar5 + 3) = 1; + *puVar5 = uVar1; + *(char *)(puVar5 + 2) = (char)piVar3->max_reg_power; + iVar2 = iVar2 + 1; + puVar5 = puVar5 + 3; + } + iVar4 = bl_send_msg(bl_hw,msg_params,0,0,(void *)0x0); + return iVar4; + } + return -0xc; +} + + + +int bl_send_scanu_raw_send(bl_hw *bl_hw,uint8_t *pkt,int len) + +{ + uint8_t **msg_params; + int iVar1; + undefined auStack36 [4]; + scanu_raw_send_cfm cfm; + + msg_params = (uint8_t **)bl_msg_zalloc(0x1005,4,8); + if (msg_params == (uint8_t **)0x0) { + iVar1 = -0xc; + } + else { + *msg_params = pkt; + *(int *)(msg_params + 1) = len; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x1006,auStack36); + } + return iVar1; +} + + + +int bl_send_sm_connect_req(bl_hw *bl_hw,cfg80211_connect_params *sme,sm_connect_cfm *cfm) + +{ + _Bool _Var1; + char "bl_send_sm_connect_req" [23]; + undefined *msg_params; + int iVar2; + nl80211_auth_type nVar3; + u32_conflict15 uVar4; + uint uVar5; + uint uVar6; + __be16 _Var7; + u8 *puVar8; + uint __n; + + msg_params = (undefined *)bl_msg_zalloc(0x1800,6,0x1c4); + if (msg_params == (undefined *)0x0) { + return -0xc; + } + __n = 0; + if ((sme->crypto).n_ciphers_pairwise != 0) { + uVar4 = (sme->crypto).ciphers_pairwise[0]; + __n = 4; + if ((1 < uVar4 - 0xfac01) && (__n = 0, uVar4 == 0xfac05)) { + __n = 4; + } + } + if ((sme->crypto).control_port != false) { + __n = __n | 1; + } + if ((sme->crypto).control_port_no_encrypt != false) { + __n = __n | 2; + } + if (((sme->crypto).cipher_group & 0xfffffffb) != 0xfac01) { + __n = __n | 8; + } + if (sme->mfp == NL80211_MFP_REQUIRED) { + __n = __n | 0x10; + } + _Var7 = (sme->crypto).control_port_ethertype; + if (_Var7 == 0) { + _Var7 = 0x888e; + } + *(__be16 *)(msg_params + 0x34) = _Var7; + puVar8 = sme->bssid; + if (puVar8 == (u8 *)0x0) { +LAB_23022c0c: + memcpy(msg_params + 0x22,&mac_addr_bcst,6); + } + else { + if (*puVar8 == -1) { + uVar5 = 0; + if (((puVar8[1] == -1) && (puVar8[2] == -1)) && + ((puVar8[3] == -1 && ((puVar8[4] == -1 && (puVar8[5] == -1)))))) goto LAB_23022c0c; + } + else { + if ((((*puVar8 == '\0') && (puVar8[1] == '\0')) && (puVar8[2] == '\0')) && + ((puVar8[3] == '\0' && (uVar5 = (uint)puVar8[4], puVar8[4] == 0)))) { + if (puVar8[5] == '\0') goto LAB_23022c0c; + } + else { + uVar5 = 0; + } + } + do { + uVar6 = uVar5 + 1; + msg_params[uVar5 + 0x22] = sme->bssid[uVar5]; + uVar5 = uVar6; + } while (uVar6 != 6); + } + msg_params[0x3d] = (char)bl_hw->vif_index_sta; + if ((sme->channel).center_freq == 0) { + *(undefined2 *)(msg_params + 0x28) = 0xffff; + } + else { + msg_params[0x2a] = (sme->channel).band; + *(u16 *)(msg_params + 0x28) = (sme->channel).center_freq; + *(bool *)(msg_params + 0x2b) = ((sme->channel).flags & 10) != 0; + } + uVar5 = 0; + while (uVar5 < sme->ssid_len) { + msg_params[uVar5 + 1] = sme->ssid[uVar5]; + uVar5 = uVar5 + 1; + } + *msg_params = (char)sme->ssid_len; + *(uint *)(msg_params + 0x30) = __n; + __n = sme->ie_len; + if (0x100 < __n) { + printf("%s:%d\r\n","bl_send_sm_connect_req",0x30a); + return -0x16; + } + if (__n != 0) { + memcpy(msg_params + 0x40,sme->ie,__n); + } + *(short *)(msg_params + 0x36) = (short)sme->ie_len; + _Var1 = bl_mod_params.listen_bcmc; + *(short *)(msg_params + 0x38) = (short)bl_mod_params.listen_itv; + msg_params[0x3a] = _Var1 ^ 1; + nVar3 = sme->auth_type; + if (nVar3 == __NL80211_AUTHTYPE_NUM) { + nVar3 = NL80211_AUTHTYPE_OPEN_SYSTEM; + } + msg_params[0x3b] = nVar3; + msg_params[0x3c] = (char)bl_mod_params.uapsd_queues; + msg_params[0x140] = 1; + if (sme->key_len != 0) { + memcpy(msg_params + 0x141,sme->key,(uint)sme->key_len); + } + if (sme->pmk_len != 0) { + memcpy(msg_params + 0x181,sme->pmk,(uint)sme->pmk_len); + } + iVar2 = bl_send_msg(bl_hw,msg_params,1,0x1801,cfm); + return iVar2; +} + + + +int bl_send_sm_disconnect_req(bl_hw *bl_hw,u16 reason) + +{ + u16 *msg_params; + int iVar1; + + msg_params = (u16 *)bl_msg_zalloc(0x1803,6,4); + if (msg_params != (u16 *)0x0) { + *msg_params = reason; + *(char *)(msg_params + 1) = (char)bl_hw->vif_index_sta; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x1804,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_mm_powersaving_req(bl_hw *bl_hw,int mode) + +{ + undefined *msg_params; + int iVar1; + + msg_params = (undefined *)bl_msg_zalloc(0x31,0,1); + if (msg_params != (undefined *)0x0) { + *msg_params = (char)mode; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x32,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_mm_denoise_req(bl_hw *bl_hw,int mode) + +{ + undefined *msg_params; + int iVar1; + + msg_params = (undefined *)bl_msg_zalloc(0x30,0,1); + if (msg_params != (undefined *)0x0) { + *msg_params = (char)mode; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x32,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_apm_start_req + (bl_hw *bl_hw,apm_start_cfm *cfm,char *ssid,char *password,int channel,uchar vif_index + ,uchar hidden_ssid) + +{ + void *msg_params; + size_t __n; + int iVar1; + uint uVar2; + undefined auStack44 [4]; + uint8_t rate [12]; + + memcpy(auStack44,&DAT_230b116c,0xc); + msg_params = bl_msg_zalloc(0x1c00,7,0xa8); + if (msg_params == (void *)0x0) { + iVar1 = -0xc; + } + else { + *(undefined *)((int)msg_params + 0x10) = 0; + if (channel - 1U < 0xe) { + if (channel == 0xe) { + uVar2 = 0x9b4; + } + else { + uVar2 = channel * 5 + 0x967U & 0xffff; + } + } + else { + uVar2 = 0xffff; + } + *(undefined2 *)((int)msg_params + 0xe) = (short)uVar2; + *(uint *)((int)msg_params + 0x14) = uVar2; + *(undefined2 *)((int)msg_params + 0x28) = 100; + *(undefined4 *)((int)msg_params + 0x2c) = 8; + *(undefined2 *)((int)msg_params + 0x30) = 0x8e88; + *(undefined *)((int)msg_params + 0x32) = 6; + *(uchar *)((int)msg_params + 0x1d) = hidden_ssid; + *(uchar *)((int)msg_params + 0x33) = vif_index; + *(undefined *)((int)msg_params + 0x11) = 0; + *(undefined *)((int)msg_params + 0x12) = 0; + *(undefined4 *)((int)msg_params + 0x18) = 0; + *(undefined *)((int)msg_params + 0x1c) = 0; + *(undefined4 *)((int)msg_params + 0x20) = 0; + *(undefined4 *)((int)msg_params + 0x24) = 0; + __n = strlen(password); + *(undefined *)((int)msg_params + 0x34) = 1; + *(bool *)((int)msg_params + 0x66) = __n != 0; + __n = strlen(ssid); + memcpy((void *)((int)msg_params + 0x45),ssid,__n); + __n = strlen(password); + memcpy((void *)((int)msg_params + 0x67),password,__n); + __n = strlen(ssid); + *(undefined *)((int)msg_params + 0x44) = (char)__n; + *(undefined *)((int)msg_params + 0x35) = 0xc; + memcpy((void *)((int)msg_params + 0x36),auStack44,0xc); + *(undefined2 *)((int)msg_params + 0x42) = 0x101; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x1c01,cfm); + } + return iVar1; +} + + + +int bl_send_apm_stop_req(bl_hw *bl_hw,uchar vif_idx) + +{ + uchar *msg_params; + int iVar1; + + msg_params = (uchar *)bl_msg_zalloc(0x1c02,7,1); + if (msg_params != (uchar *)0x0) { + *msg_params = vif_idx; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x1c03,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_apm_sta_del_req(bl_hw *bl_hw,apm_sta_del_cfm *cfm,uchar sta_idx,uchar vif_idx) + +{ + uchar *msg_params; + int iVar1; + + msg_params = (uchar *)bl_msg_zalloc(0x1c0b,7,2); + if (msg_params != (uchar *)0x0) { + msg_params[1] = sta_idx; + *msg_params = vif_idx; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x1c0c,cfm); + return iVar1; + } + return -0xc; +} + + + +int bl_send_apm_conf_max_sta_req(bl_hw *bl_hw,uchar max_sta_supported) + +{ + uchar *msg_params; + int iVar1; + + msg_params = (uchar *)bl_msg_zalloc(0x1c0d,7,1); + if (msg_params != (uchar *)0x0) { + *msg_params = max_sta_supported; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x1c0e,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_cfg_task_req + (bl_hw *bl_hw,uint32_t ops,uint32_t task,uint32_t element,uint32_t type,void *arg1, + void *arg2) + +{ + uint32_t *msg_params; + int iVar1; + TickType_t TVar2; + uint32_t uVar3; + + msg_params = (uint32_t *)bl_msg_zalloc(0x3000,0xc,0x24); + if (msg_params == (uint32_t *)0x0) { + return -0xc; + } + *msg_params = ops; + if (ops < 3) { + if (ops == 0) { + msg_params[1] = task; + msg_params[2] = element; + msg_params[3] = type; + uVar3 = utils_tlv_bl_pack_auto(msg_params + 5,8,(uint16_t)type,arg1); + msg_params[4] = uVar3; + } + } + else { + if (ops != 3) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ASSERT: %s:%d\r\n",TVar2,&UNK_230b1c9c,&UNK_230b1c90,0x40f, + &UNK_230b1c90,0x40f); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + msg_params[1] = task; + msg_params[2] = element; + msg_params[4] = 0; + } + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x3001,(void *)0x0); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int bl_platform_on(bl_hw *bl_hw) + +{ + int iVar1; + + ipc_shenv = &ipc_shared_env; + iVar1 = bl_ipc_init(bl_hw,(ipc_shared_env_tag_conflict21 *)&ipc_shared_env); + if (iVar1 == 0) { + _DAT_44800008 = 0xffffffff; + } + return iVar1; +} + + + +int bl_rx_chan_pre_switch_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + return 0; +} + + + +int bl_rx_rssi_status_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + if (cb_rssi != (wifi_event_rssi_cb_t *)0x0) { + (*cb_rssi)(cb_rssi_env,*(int8_t *)((int)msg->param + 2)); + return 0; + } + return 0; +} + + + +int bl_rx_apm_sta_del_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + printf("[WF] APM_STA_DEL_IND\r\n"); + printf("[WF] sta_idx %u\r\n",(uint)*(byte *)msg->param); + if (*(byte *)msg->param < 0xc) { + bl_hw->sta_table[*(byte *)msg->param].is_used = '\0'; + } + else { + printf("[WF] --------- Potential illegal sta_idx\r\n"); + } + aos_post_event(2,0x16,(uint)*(byte *)msg->param); + return 0; +} + + + +int bl_rx_apm_sta_add_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + byte bVar1; + int *piVar2; + + printf("[WF] APM_STA_ADD_IND\r\n"); + printf("[WF] flags %08X\r\n",msg->param[0]); + printf("[WF] MAC %02X:%02X:%02X:%02X:%02X:%02X\r\n",(uint)*(byte *)(msg->param + 1), + (uint)*(byte *)((int)msg->param + 5),(uint)*(byte *)((int)msg->param + 6), + (uint)*(byte *)((int)msg->param + 7),(uint)*(byte *)(msg->param + 2), + (uint)*(byte *)((int)msg->param + 9)); + printf("[WF] vif_idx %u\r\n",(uint)*(byte *)((int)msg->param + 10)); + printf("[WF] sta_idx %u\r\n",(uint)*(byte *)((int)msg->param + 0xb)); + bVar1 = *(byte *)((int)msg->param + 0xb); + if (bVar1 < 0xc) { + memcpy(bl_hw->sta_table + (uint)bVar1,msg->param + 1,6); + piVar2 = &bl_hw->is_up + (uint)bVar1 * 7; + *(undefined *)((int)piVar2 + 0xc99) = *(undefined *)((int)msg->param + 0xb); + *(undefined *)((int)piVar2 + 0xc9a) = *(undefined *)((int)msg->param + 10); + *(undefined *)(piVar2 + 0x326) = 1; + *(undefined *)(piVar2 + 0x327) = *(undefined *)(msg->param + 3); + piVar2[0x328] = msg->param[4]; + piVar2[0x329] = msg->param[5]; + *(undefined *)(piVar2 + 0x32a) = *(undefined *)(msg->param + 6); + } + else { + printf("[WF] ------ Potential illegal sta_idx\r\n"); + } + aos_post_event(2,0x15,(uint)*(byte *)((int)msg->param + 0xb)); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void notify_event_scan_done(int join_scan) + +{ + wifi_event wStack24; + uint8_t buffer [8]; + + memset(&wStack24,0,4); + memset(buffer,0,4); + buffer._0_4_ = 0xec; + wStack24 = (wifi_event)((uint)(join_scan != 0) + 1); + if (cb_event != (wifi_event_cb_t *)0x0) { + (*cb_event)(cb_event_env,&wStack24); + } + return; +} + + + +int bl_rx_scanu_join_cfm(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + notify_event_scan_done(1); + return 0; +} + + + +int bl_rx_scanu_start_cfm(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + notify_event_scan_done(0); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bl_rx_chan_switch_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + wifi_event wStack24; + uint8_t buffer [8]; + + buffer._0_4_ = (uint)*(byte *)msg->param; + memset(&wStack24,0,4); + memset(buffer,0,4); + wStack24 = (wifi_event)0x0; + if (cb_event != (wifi_event_cb_t *)0x0) { + (*cb_event)(cb_event_env,&wStack24); + } + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bl_rx_sm_connect_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + netif *netif; + sm_reason_code *psVar1; + uint uVar2; + int iVar3; + u32_l local_40; + wifi_event_sm_connect_ind ind_new; + + psVar1 = reason_list; + iVar3 = 0; + do { + if (psVar1->reason_code == *(uint16_t *)msg->param) goto LAB_230233f2; + iVar3 = iVar3 + 1; + psVar1 = psVar1 + 1; + } while (iVar3 != 0x10); + iVar3 = 0; +LAB_230233f2: + printf("[RX] Connection Status\r\n"); + printf("[RX] status_code %u\r\n",(uint)*(ushort *)msg->param); + printf("[RX] connect result: %s\r\n",reason_list[iVar3].action); + printf("[RX] MAC %02X:%02X:%02X:%02X:%02X:%02X\r\n",(uint)*(byte *)((int)msg->param + 2), + (uint)*(byte *)((int)msg->param + 3),(uint)*(byte *)(msg->param + 1), + (uint)*(byte *)((int)msg->param + 5),(uint)*(byte *)((int)msg->param + 6), + (uint)*(byte *)((int)msg->param + 7)); + printf("[RX] vif_idx %u\r\n",(uint)*(byte *)((int)msg->param + 9)); + printf("[RX] ap_idx %u\r\n",(uint)*(byte *)((int)msg->param + 10)); + printf("[RX] ch_idx %u\r\n",(uint)*(byte *)((int)msg->param + 0xb)); + printf("[RX] qos %u\r\n",(uint)*(byte *)(msg->param + 3)); + printf("[RX] acm %u\r\n",(uint)*(byte *)((int)msg->param + 0xd)); + printf("[RX] assoc_req_ie_len %u\r\n",(uint)*(ushort *)((int)msg->param + 0xe)); + printf("[RX] assoc_rsp_ie_len %u\r\n",(uint)*(ushort *)(msg->param + 4)); + printf("[RX] aid %u\r\n",(uint)*(ushort *)(msg->param + 0xcd)); + printf("[RX] band %u\r\n",(uint)*(byte *)((int)msg->param + 0x336)); + printf("[RX] center_freq %u\r\n",(uint)*(ushort *)(msg->param + 0xce)); + printf("[RX] width %u\r\n",(uint)*(byte *)((int)msg->param + 0x33a)); + printf("[RX] center_freq1 %u\r\n",msg->param[0xcf]); + printf("[RX] center_freq2 %u\r\n",msg->param[0xd0]); + if (*(short *)msg->param == 0) { + bl_hw->sta_idx = (uint)*(byte *)((int)msg->param + 10); + bl_hw->is_up = 1; + } + else { + bl_hw->is_up = 0; + } + memset(&local_40,0,0x20); + local_40 = msg->param[0]; + ind_new._0_4_ = msg->param[1]; + ind_new.bssid[2] = *(uint8_t *)((int)msg->param + 9); + ind_new.bssid[3] = *(uint8_t *)((int)msg->param + 10); + ind_new.bssid[4] = *(uint8_t *)((int)msg->param + 0xb); + ind_new._8_4_ = (uint)*(byte *)(msg->param + 3); + ind_new.qos._0_2_ = *(uint16_t *)(msg->param + 0xcd); + ind_new.qos._2_1_ = *(uint8_t *)((int)msg->param + 0x336); + ind_new.aid = *(uint16_t *)(msg->param + 0xce); + ind_new.band = *(uint8_t *)((int)msg->param + 0x33a); + ind_new._20_4_ = msg->param[0xcf]; + ind_new.center_freq1 = msg->param[0xd0]; + if (cb_sm_connect_ind != (wifi_event_sm_connect_ind_cb_t *)0x0) { + (*cb_sm_connect_ind)(cb_sm_connect_ind_env,(wifi_event_sm_connect_ind *)&local_40); + } + if (*(short *)msg->param == 0) { + uVar2 = (uint)*(byte *)((int)msg->param + 9); + if (bl_hw->vif_table + uVar2 != (bl_vif *)0x0) { + netif = (netif *)(&bl_hw->is_up + uVar2 * 0x31)[0xda]; + if (netif != (netif *)0x0) { + netifapi_netif_common(netif,netif_set_link_up,(netifapi_errt_fn)0x0); + netifapi_netif_common + ((netif *)(&bl_hw->is_up + uVar2 * 0x31)[0xda],netif_set_default, + (netifapi_errt_fn)0x0); + return 0; + } + } + printf("[RX] -------- CRITICAL when check netif. ptr is %p:%p\r\n"); + } + return 0; +} + + + +// WARNING: Variable defined which should be unmapped: ind_new +// WARNING: Could not reconcile some variable overlaps + +int bl_rx_sm_disconnect_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + netif *netif; + uint uVar1; + ip4_addr_t iStack28; + ip4_addr_t addr_any; + wifi_event_sm_disconnect_ind ind_new; + + iStack28 = (ip4_addr_t)ipaddr_addr("0.0.0.0"); + printf("[RX] sm_disconnect_ind\r\n reason_code %u\r\n",(uint)*(ushort *)msg->param); + printf("[RX] vif_idx %u\r\n",(uint)*(byte *)((int)msg->param + 2)); + printf("[RX] ft_over_ds %u\r\n",(uint)*(byte *)((int)msg->param + 3)); + if (cb_sm_disconnect_ind != (wifi_event_sm_disconnect_ind_cb_t *)0x0) { + memset(&addr_any,0,8); + addr_any.addr._0_2_ = *(uint16_t *)msg->param; + addr_any.addr._2_1_ = *(uint8_t *)((int)msg->param + 2); + (*cb_sm_disconnect_ind)(cb_sm_disconnect_ind_env,(wifi_event_sm_disconnect_ind *)&addr_any); + } + uVar1 = (uint)*(byte *)((int)msg->param + 2); + if (bl_hw->vif_table + uVar1 != (bl_vif *)0x0) { + netif = (netif *)(&bl_hw->is_up + uVar1 * 0x31)[0xda]; + if (netif != (netif *)0x0) { + netifapi_netif_common(netif,netif_set_link_down,(netifapi_errt_fn)0x0); + netifapi_netif_set_addr + ((netif *)(&bl_hw->is_up + uVar1 * 0x31)[0xda],&iStack28,&iStack28,&iStack28); + } + } + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +undefined4 bl_rx_scanu_result_ind(int param_1,longlong param_2) + +{ + uchar uVar1; + void *__src; + undefined3 extraout_var; + uint __n; + SecurityMode_t *security_mode; + _Bool wpa2_prefered; + byte bVar2; + ushort uVar3; + int iVar4; + byte *pbVar5; + byte *pbVar6; + _Bool _Stack121; + uint8_t auStack120 [32]; + undefined2 uStack88; + undefined2 uStack86; + undefined2 uStack84; + undefined auStack82 [33]; + int8_t iStack49; + int8_t iStack48; + int8_t iStack47; + byte bStack46; + uint8_t uStack45; + undefined4 uStack44; + undefined4 uStack40; + uint uStack36; + SecurityMode_t aSStack32 [4]; + + _Stack121 = false; + memset(auStack120,0,0x20); + security_mode = (SecurityMode_t *)0x80; + uVar3 = *(ushort *)(param_1 + 0x24) & 0xfc; + if (uVar3 != 0x80) { + if (uVar3 != 0x50) { + printf("Bug Scan IND?\r\n"); + return 0; + } + printf("Probe Response\r\n"); + if (cb_probe_resp_ind == (wifi_event_probe_resp_ind_cb_t *)0x0) { + return 0; + } + (*cb_probe_resp_ind)((void *)0x0,param_2); + return 0; + } + if (cb_beacon_ind == (wifi_event_beacon_ind_cb_t *)0x0) { + return 0; + } + memset(&uStack88,0,0x38); + uVar3 = *(ushort *)(param_1 + 8); + pbVar6 = (byte *)(param_1 + 0x48); + iVar4 = 0; + pbVar5 = pbVar6; + while (iVar4 < (int)(uint)uVar3) { + security_mode = (SecurityMode_t *)(uint)*pbVar5; + __n = (uint)pbVar5[1]; + if (*pbVar5 == 0) { + if (pbVar5[1] < 0x21) { + uStack36 = __n; + memcpy(auStack82,pbVar5 + 2,__n); + security_mode = aSStack32; + auStack82[pbVar5[1]] = 0; + } + break; + } + iVar4 = iVar4 + __n + 2; + pbVar5 = pbVar5 + __n + 2; + } + iVar4 = 0; + pbVar5 = pbVar6; + while (iVar4 < (int)(uint)*(ushort *)(param_1 + 8)) { + security_mode = (SecurityMode_t *)(uint)pbVar5[1]; + if (*pbVar5 == 3) { + if (pbVar5[1] < 0x21) { + bStack46 = pbVar5[2]; + } + break; + } + security_mode = security_mode + 1; + iVar4 = &security_mode->field_0x0 + iVar4; + pbVar5 = pbVar5 + (int)security_mode; + } + if ((*(ushort *)(param_1 + 0x46) & 0x10) == 0) { + uStack45 = '\0'; + goto LAB_2302385a; + } + __n = (uint)uVar3 - 0x24 & 0xffff; + __src = (void *)mac_ie_find(pbVar6,__n,0x30); + iVar4 = 0; + if (__src != (void *)0x0) { + wpa2_prefered = (_Bool)(uStack40._1_1_ | 0x20); + uStack40 = uStack40 | 0x2000; + memcpy(auStack120,__src,(uint)*(byte *)((int)__src + 1) + 2 & 0xff); + uVar1 = process_rsn_ie(auStack120,(Cipher_t *)((int)&uStack44 + 3),(Cipher_t *)&uStack40, + &_Stack121,security_mode,wpa2_prefered); + iVar4 = CONCAT31(extraout_var,uVar1); + } + __src = (void *)mac_vsie_find(pbVar6,__n,&DAT_230b1dc0,4); + if ((__src != (void *)0x0) && (uStack40 = uStack40 | 0x800, iVar4 == 0)) { + memcpy(auStack120,__src,(uint)*(byte *)((int)__src + 1) + 2 & 0xff); + process_wpa_ie(auStack120,(Cipher_t *)((int)&uStack44 + 1),(Cipher_t *)((int)&uStack44 + 2)); + } + if ((uStack40 & 0x2800) == 0x2800) { + bVar2 = (byte)uStack40._0_1_ | (byte)uStack44._2_1_; + __n = (uint)bVar2 & 8; + if ((bVar2 & 4) == 0) { + if ((bVar2 & 8) != 0) { + if (((uStack44 & 0x8000800) == 0) && ((uStack44 & 0x4000400) != 0)) goto LAB_23023844; +LAB_230238cc: + bVar2 = 2; + goto next; + } + } + else { +LAB_23023840: + bVar2 = 3; + if (__n != 0) { +LAB_23023844: + bVar2 = 4; + } +next: + uStack44 = uStack44 & 0xffffff00 | (uint)bVar2; + if ((uStack40 & 0x2800) != 0x2800) goto LAB_23023926; + } + uStack45 = '\x04'; + } + else { + if ((uStack40 & 0x800) == 0) { + if ((uStack40 & 0x2000) == 0) { + uStack44 = CONCAT31(uStack44._1_3_,1); + } + else { + __n = uStack40 & 8; + if ((uStack40 & 4) != 0) goto LAB_23023840; + if ((uStack40 & 8) != 0) { + uStack44._1_1_ = uStack44._3_1_; + goto LAB_230238fa; + } + } + } + else { + __n = (uint)(byte)uStack44._2_1_ & 8; + if ((uStack44 & 0x40000) != 0) goto LAB_23023840; + if ((uStack44 & 0x80000) != 0) { +LAB_230238fa: + if ((((byte)uStack44._1_1_ & 8) != 0) || (((byte)uStack44._1_1_ & 4) == 0)) + goto LAB_230238cc; + goto LAB_23023844; + } + } +LAB_23023926: + if ((uStack40 & 0x2000) == 0) { + if ((uStack40 & 0x800) == 0) { + uStack45 = '\x01'; + } + else { + uStack45 = '\x02'; + } + } + else { + uStack45 = '\x03'; + } + } +LAB_2302385a: + iStack49 = *(int8_t *)(param_1 + 0x20); + iStack48 = *(int8_t *)(param_1 + 0x21); + iStack47 = *(int8_t *)(param_1 + 0x22); + uStack88 = *(undefined2 *)(param_1 + 0x34); + uStack86 = *(undefined2 *)(param_1 + 0x36); + uStack84 = *(undefined2 *)(param_1 + 0x38); + (*cb_beacon_ind)(cb_beacon_ind_env,(wifi_event_beacon_ind_conflict *)&uStack88); + return 0; +} + + + +undefined4 bl_rx_mesh_path_update_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_mesh_proxy_update_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_remain_on_channel_exp_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_ps_change_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_traffic_req_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_csa_counter_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_csa_finish_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_csa_traffic_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_channel_survey_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_dbg_error_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_tdls_chan_switch_cfm(void) + +{ + return 0; +} + + + +undefined4 bl_rx_tdls_chan_switch_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_tdls_chan_switch_base_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_tdls_peer_ps_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_me_tkip_mic_failure_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_me_tx_credits_update_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_mesh_path_create_cfm(void) + +{ + return 0; +} + + + +undefined4 bl_rx_mesh_peer_update_ind(void) + +{ + return 0; +} + + + +int bl_rx_sm_connect_ind_cb_register(void *env,wifi_event_sm_connect_ind_cb_t *cb) + +{ + cb_sm_connect_ind = cb; + cb_sm_connect_ind_env = env; + return 0; +} + + + +int bl_rx_sm_disconnect_ind_cb_register(void *env,wifi_event_sm_disconnect_ind_cb_t *cb) + +{ + cb_sm_disconnect_ind = cb; + cb_sm_disconnect_ind_env = env; + return 0; +} + + + +int bl_rx_beacon_ind_cb_register(void *env,wifi_event_beacon_ind_cb_t *cb) + +{ + cb_beacon_ind = cb; + cb_beacon_ind_env = env; + return 0; +} + + + +int bl_rx_probe_resp_ind_cb_register(void *env,wifi_event_probe_resp_ind_cb_t *cb) + +{ + cb_probe_resp_ind = cb; + return 0; +} + + + +int bl_rx_pkt_cb_register(void *env,wifi_event_pkt_cb_t *cb) + +{ + cb_pkt = cb; + cb_pkt_env = env; + return 0; +} + + + +int bl_rx_pkt_cb_unregister(void *env) + +{ + cb_pkt = (wifi_event_pkt_cb_t *)0x0; + cb_pkt_env = (void *)0x0; + return 0; +} + + + +int bl_rx_rssi_cb_register(void *env,wifi_event_rssi_cb_t *cb) + +{ + cb_rssi = cb; + cb_rssi_env = env; + return 0; +} + + + +int bl_rx_event_register(void *env,wifi_event_cb_t *cb) + +{ + cb_event = cb; + cb_event_env = env; + return 0; +} + + + +void bl_rx_e2a_handler(void *arg) + +{ + // WARNING: Could not recover jumptable at 0x23023aa4. Too many branches + // WARNING: Treating indirect jump as call + (*wifi_hw.cmd_mgr.msgind) + ((bl_cmd_mgr *)0x420230a4,(ipc_e2a_msg *)arg, + (msg_cb_fct *)msg_hdlrs[*(ushort *)arg >> 10][(uint)*(ushort *)arg & 0x3ff]); + return; +} + + + +void bl_rx_pkt_cb(uint8_t *pkt,int len) + +{ + if (cb_pkt != (wifi_event_pkt_cb_t *)0x0) { + // WARNING: Could not recover jumptable at 0x23023abe. Too many branches + // WARNING: Treating indirect jump as call + (*cb_pkt)(cb_pkt_env,pkt,len); + return; + } + return; +} + + + +void bl_tx_push(bl_hw *bl_hw,bl_txhdr_conflict1 *txhdr) + +{ + hostdesc *phVar1; + hostdesc *phVar2; + txdesc_host *ptVar3; + hostdesc_conflict44 *phVar4; + uint32_t *host_id; + + host_id = txhdr->p; + ptVar3 = ipc_host_txdesc_get(bl_hw->ipc_env); + if (&ptVar3->host == (hostdesc *)0x0) { + printf("%d:ASSERT_ERR(host)\n",0x37); + } + phVar1 = &ptVar3->host; + phVar4 = &txhdr->host; + do { + phVar2 = (hostdesc *)((int)&phVar1->pbuf_addr + 1); + *(undefined *)&phVar1->pbuf_addr = *(undefined *)&phVar4->pbuf_addr; + phVar1 = phVar2; + phVar4 = (hostdesc_conflict44 *)((int)&phVar4->pbuf_addr + 1); + } while ((hostdesc *)ptVar3->pad_txdesc != phVar2); + ipc_host_txdesc_push(bl_hw->ipc_env,host_id); + (bl_hw->stats).cfm_balance = (bl_hw->stats).cfm_balance + 1; + return; +} + + + +void bl_tx_resend(void) + +{ + bl_hw *bl_hw; + txdesc_host *ptVar1; + uint uVar2; + + vTaskEnterCritical(); + while ((txhdr_pos_r != txhdr_pos_w && + (ptVar1 = ipc_host_txdesc_get(bl_hw_static->ipc_env), bl_hw = bl_hw_static, + ptVar1 != (txdesc_host *)0x0))) { + uVar2 = txhdr_pos_r & 7; + txhdr_hodler[uVar2]->status = 0; + bl_tx_push(bl_hw,(bl_txhdr_conflict1 *)txhdr_hodler[uVar2]); + txhdr_pos_r = txhdr_pos_r + 1; + } + vTaskExitCritical(); + return; +} + + + +void bl_tx_try_flush(void) + +{ + txdesc_host *ptVar1; + bl_txhdr_conflict1 *txhdr; + + vTaskEnterCritical(); + while ((ptVar1 = ipc_host_txdesc_get(bl_hw_static->ipc_env), ptVar1 != (txdesc_host *)0x0 && + (txhdr = (bl_txhdr_conflict1 *)utils_list_pop_front(&tx_list_bl), + txhdr != (bl_txhdr_conflict1 *)0x0))) { + bl_tx_push(bl_hw_static,txhdr); + } + vTaskExitCritical(); + return; +} + + + +int bl_txdatacfm(void *pthis,void *host_id) + +{ + bl_txhdr_conflict *pbVar1; + int iVar2; + + pbVar1 = (bl_txhdr_conflict *)((-*(int *)((int)host_id + 4) & 3U) + *(int *)((int)host_id + 4)); + iVar2 = pbVar1->status; + if (iVar2 == 0) { + return -1; + } + if (iVar2 << 0xf < 0) { + if (((txhdr_pos_w + 1 ^ txhdr_pos_r) & 7) != 0) { + puts(" push back\r\n"); + txhdr_hodler[txhdr_pos_w & 7] = pbVar1; + txhdr_pos_w = txhdr_pos_w + 1; + return 0; + } + puts(" NOT push back when no mem\r\n"); + } + pbuf_free((pbuf *)host_id); + return 0; +} + + + +void bl_tx_notify(void) + +{ + if (taskHandle_output != (TaskHandle_t)0x0) { + xTaskGenericNotify(taskHandle_output,0,eIncrement,(uint32_t *)0x0); + return; + } + return; +} + + + +err_t bl_output(bl_hw *bl_hw,netif *netif,pbuf *p,int is_sta) + +{ + u16_t uVar1; + undefined2 uVar2; + utils_list_hdr *list_hdr; + err_t eVar3; + u8_t uVar4; + undefined3 extraout_var; + undefined uVar5; + pbuf *ppVar6; + uint8_t *mac; + int iVar7; + utils_list_hdr *puVar8; + + if ((bl_hw == (bl_hw *)0x0) || ((netif->flags & 4) == 0)) { + printf("[TX] wifi is down, return now\r\n"); + eVar3 = -0xb; + } + else { + if (taskHandle_output == (TaskHandle_t)0x0) { + taskHandle_output = xTaskGetCurrentTaskHandle(); + } + mac = (uint8_t *)p->payload; + uVar1 = p->tot_len; + bl_hw_static = bl_hw; + uVar4 = pbuf_header(p,0x80); + if (CONCAT31(extraout_var,uVar4) == 0) { + list_hdr = (utils_list_hdr *)((-(int)p->payload & 3U) + (int)p->payload); + memset(list_hdr,0,0x5c); + *(pbuf **)&list_hdr[2].next = p; + memcpy(list_hdr + 7,mac,6); + memcpy((void *)((int)&list_hdr[8].next + 2),mac + 6,6); + *(pbuf **)&list_hdr[3].next = p; + uVar2 = *(undefined2 *)(mac + 0xc); + *(undefined *)((int)&list_hdr[0xd].next + 2) = 0; + *(undefined2 *)&list_hdr[10].next = uVar2; + if (is_sta == 0) { + uVar5 = *(undefined *)&bl_hw->vif_index_ap; + } + else { + uVar5 = *(undefined *)&bl_hw->vif_index_sta; + } + *(undefined *)((int)&list_hdr[0xd].next + 3) = uVar5; + *(undefined2 *)((int)&list_hdr[0xe].next + 2) = 0; + *(u16_t *)&list_hdr[5].next = uVar1 - 0xe; + if (is_sta == 0) { + iVar7 = bl_utils_idx_lookup(bl_hw,mac); + *(char *)&list_hdr[0xe].next = (char)iVar7; + } + else { + *(char *)&list_hdr[0xe].next = (char)bl_hw->sta_idx; + } + puVar8 = list_hdr + 0xf; + iVar7 = 0; + ppVar6 = p; + do { + if (iVar7 == 0) { + list_hdr[0xf].next = (utils_list_hdr *)((int)ppVar6->payload + 0x8e); + list_hdr[0x13].next = (utils_list_hdr *)((uint)ppVar6->len - 0x8e); + } + else { + if (iVar7 == 4) { + printf("[TX] [PBUF] Please fix for bigger chained pbuf, total_len %d\r\n", + (uint)p->tot_len); + } + puVar8->next = (utils_list_hdr *)ppVar6->payload; + puVar8[4].next = (utils_list_hdr *)(uint)ppVar6->len; + } + ppVar6 = ppVar6->next; + iVar7 = iVar7 + 1; + puVar8 = puVar8 + 1; + } while (ppVar6 != (pbuf *)0x0); + if (2 < iVar7) { + printf("[TX] [LOOP] Chain Used %d\r\n",iVar7); + } + list_hdr[4].next = (utils_list_hdr *)0x11111111; + list_hdr[6].next = list_hdr + 1; + list_hdr[1].next = (utils_list_hdr *)0x0; + pbuf_ref(p); + vTaskEnterCritical(); + utils_list_push_back(&tx_list_bl,list_hdr); + vTaskExitCritical(); + bl_irq_handler(); + eVar3 = '\0'; + } + else { + printf("[TX] Reserve room failed for header\r\n"); + eVar3 = -0xc; + } + } + return eVar3; +} + + + +u8 bl_radarind(void *pthis,void *hostid) + +{ + return '\0'; +} + + + +u8 bl_msgackind(void *pthis,void *hostid) + +{ + (**(code **)((int)pthis + 0x24))((int)pthis + 4,*(code **)((int)pthis + 0x24)); + return '\0'; +} + + + +void bl_prim_tbtt_ind(void *pthis) + +{ + return; +} + + + +void my_pbuf_free_custom(pbuf *p) + +{ + bl60x_firmwre_mpdu_free(p[1].payload); + return; +} + + + +undefined4 bl_dbgind(void) + +{ + return 0; +} + + + +void bl_sec_tbtt_ind(void) + +{ + return; +} + + + +void my_pbuf_free_custom_fake(void) + +{ + return; +} + + + +// WARNING: Control flow encountered bad instruction data + +int tcpip_stack_input(void *swdesc,uchar status,void *hwhdr,uint msdu_offset,wifi_pkt *pkt) + +{ + if ((status & 1) == 0) { + return -1; + } + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +int bl_utils_idx_lookup(bl_hw *bl_hw,uint8_t *mac) + +{ + bl_sta *__s1; + int iVar1; + int iVar2; + + __s1 = bl_hw->sta_table; + iVar1 = 0; + while ((__s1->is_used == '\0' || (iVar2 = memcmp(__s1,mac,6), iVar2 != 0))) { + iVar1 = iVar1 + 1; + __s1 = __s1 + 1; + if (iVar1 == 0xc) { + return wifi_hw.ap_bcmc_idx; + } + } + return iVar1; +} + + + +int bl_ipc_init(bl_hw *bl_hw,ipc_shared_env_tag_conflict21 *ipc_shared_mem) + +{ + code *local_30; + ipc_host_cb_tag cb; + + memset(&local_30,0,0x20); + cb.recv_data_ind = bl_radarind; + cb.recv_msg_ind = bl_msgackind; + cb.recv_msgack_ind = bl_dbgind; + local_30 = bl_txdatacfm; + cb.recv_dbg_ind = bl_prim_tbtt_ind; + cb.prim_tbtt_ind = bl_sec_tbtt_ind; + cb.send_data_cfm = (anon_subr_int_void_ptr_void_ptr_for_send_data_cfm *)0x0; + cb.recv_radar_ind = (anon_subr_uint8_t_void_ptr_void_ptr_for_recv_radar_ind *)0x0; + ipc_env = (ipc_host_env_tag *)pvPortMalloc(0xe4); + bl_hw->ipc_env = ipc_env; + ipc_host_init(ipc_env,(ipc_host_cb_tag *)&local_30,(ipc_shared_env_tag_conflict3 *)ipc_shared_mem, + bl_hw); + bl_cmd_mgr_init(&bl_hw->cmd_mgr); + return 0; +} + + + +void bl_utils_dump(void) + +{ + int iVar1; + uint uVar2; + int iVar3; + + puts("---------- bl_utils_dump -----------\r\n"); + printf("txdesc_free_idx: %lu(%lu)\r\n",ipc_env->txdesc_free_idx,ipc_env->txdesc_free_idx & 3); + printf("txdesc_used_idx: %lu(%lu)\r\n",ipc_env->txdesc_used_idx,ipc_env->txdesc_used_idx & 3); + iVar1 = 0; + printf("tx_host_id0 cnt: %d(used %ld)\r\n",4,ipc_env->txdesc_free_idx - ipc_env->txdesc_used_idx); + puts(" list: pbuf status ptr status\r\n"); + do { + uVar2 = ipc_env->txdesc_used_idx + iVar1; + if (uVar2 == ipc_env->txdesc_free_idx) break; + iVar1 = iVar1 + 1; + iVar3 = *(int *)((&(ipc_env->cb).recv_radar_ind)[(uVar2 & 3) + 0x10] + 4); + iVar3 = (-iVar3 & 3U) + iVar3; + printf(" [%lu]%p(%p:%08lX)\r\n",*(undefined4 *)(iVar3 + 0x18),*(undefined4 *)(iVar3 + 4)); + } while (iVar1 != 4); + puts("========== bl_utils_dump End =======\r\n"); + return; +} + + + +_Bool stateSnifferGuard(void *ch,event *event) + +{ + return (_Bool)(ch == (void *)(uint)*(byte *)event->data); +} + + + +_Bool stateConnectedIPYesGuard_ip_update(void *ch,event *event) + +{ + return (_Bool)(ch == (void *)(uint)*(byte *)event->data); +} + + + +void printErrMsg(void *stateData,event *event) + +{ + printf("ENTERED ERROR STATE!"); + return; +} + + + +void stateSnifferExit(void *stateData,event *event) + +{ + printf("[WF][SM] Exiting %s state\r\n",stateData); + return; +} + + + +void stateSnifferAction(void *oldStateData,event *event,void *newStateData) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n",oldStateData); + return; +} + + + +void stateConnectedIPNoAction_ipgot(void *oldStateData,event *event,void *newStateData) + +{ + uint *puVar1; + uint *puVar2; + uint uVar3; + uint uVar4; + + puVar1 = (uint *)((int)event->data + 0xd); + puVar2 = (uint *)((int)event->data + 0x11); + uVar4 = *puVar1; + uVar3 = *puVar2; + printf( + "[WF][SM] IP GOT IP:%u.%u.%u.%u, MASK: %u.%u.%u.%u, Gateway: %u.%u.%u.%u, dns1: %u.%u.%u.%u, dns2: %u.%u.%u.%u\r\n" + ,uVar4 & 0xff,uVar4 >> 8 & 0xff,(uint)(*(uint3 *)puVar1 >> 0x10),uVar4 >> 0x18,uVar3 & 0xff + ,uVar3 >> 8 & 0xff,(uint)(*(uint3 *)puVar2 >> 0x10)); + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n",oldStateData,newStateData); + return; +} + + + +void stateGlobalEnter(void *stateData,event *event) + +{ + printf("[WF][SM] Entering %s state\r\n",stateData); + return; +} + + + +void stateGlobalAction(void *oldStateData,event *event,void *newStateData) + +{ + printf("[WF][SM] Global Action\r\n"); + return; +} + + + +void stateConnectingEnter(void *stateData,event *event) + +{ + printf("[WF][SM] Entering %s state\r\n",stateData); + aos_post_event(2,8,0); + return; +} + + + +_Bool stateSnifferGuard_ChannelSet(void *ch,event *event) + +{ + byte *pbVar1; + + pbVar1 = (byte *)event->data; + if (ch == (void *)(uint)*pbVar1) { + bl_main_monitor_channel_set(*(int *)(pbVar1 + 1),*(int *)(pbVar1 + 5)); + return false; + } + return false; +} + + + +_Bool stateIdleGuard_sniffer(void *ev,event *event) + +{ + if (ev == (void *)(uint)*(byte *)event->data) { + bl_main_monitor(); + return true; + } + return false; +} + + + +void stateConnectedIPNoExit(void *stateData,event *event) + +{ + printf("[WF][SM] Exiting %s state\r\n",stateData); + xTimerGenericCommand((TimerHandle_t)((int)stateData + 0x20),3,0,(BaseType_t *)0x0,0); + xTimerGenericCommand((TimerHandle_t)((int)stateData + 0x20),5,0,(BaseType_t *)0x0,0); + return; +} + + + +void stateDisconnect_action_idle(void *oldStateData,event *event,void *newStateData) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n",oldStateData); + printf("[WF][SM] Removing STA interface...\r\n"); + bl_main_if_remove(wifiMgmr.wlan_sta.vif_index); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void stateDisconnect_action_reconnect(void *oldStateData,event *event,void *newStateData) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n",oldStateData); + printf("[WF][SM] Action Connect\r\n"); + printf(" ssid %s\r\n",(uint8_t *)((int)oldStateData + 0x4d)); + printf(" ssid len %u\r\n",*(undefined4 *)((int)oldStateData + 0x6e)); + printf(" psk %s\r\n",(uint8_t *)((int)oldStateData + 0x72)); + printf(" psk len %u\r\n",*(undefined4 *)((int)oldStateData + 0xf4)); + printf(" pmk %s\r\n",(uint8_t *)((int)oldStateData + 0xb3)); + printf(" pmk len %u\r\n",*(undefined4 *)((int)oldStateData + 0xf8)); + printf(" mac %02X:%02X:%02X:%02X:%02X:%02X\r\n", + (uint)*(byte *)((int)oldStateData + 0x101),(uint)*(byte *)((int)oldStateData + 0x100), + (uint)*(byte *)((int)oldStateData + 0xff),(uint)*(byte *)((int)oldStateData + 0xfe), + (uint)*(byte *)((int)oldStateData + 0xfd),(uint)*(byte *)((int)oldStateData + 0xfc)); + bl_main_connect((uint8_t *)((int)oldStateData + 0x4d),*(int *)((int)oldStateData + 0x6e), + (uint8_t *)((int)oldStateData + 0x72),*(int *)((int)oldStateData + 0xf4), + (uint8_t *)((int)oldStateData + 0xb3),*(int *)((int)oldStateData + 0xf8), + (uint8_t *)((int)oldStateData + 0xfc),'\0',_DAT_00000010); + aos_post_event(2,3,0); + return; +} + + + +void ip_obtaining_timeout(timer_cb_arg_t data) + +{ + pvTimerGetTimerID((TimerHandle_t)data); + printf("[WF][SM] IP obtaining timeout\r\n"); + wifi_mgmr_api_fw_disconnect(); + return; +} + + + +void stateConnectedIPNoEnter(void *stateData,event *event) + +{ + uint32_t uVar1; + uint32_t uVar2; + uint32_t uVar3; + uint32_t uVar4; + uint32_t uVar5; + TickType_t xOptionalValue; + ip4_addr_t iStack44; + ip4_addr_t addr_ipaddr; + ip4_addr_t addr_netmask; + ip4_addr_t addr_gw; + + printf("[WF][SM] Entering %s state\r\n",stateData); + xTimerCreateStatic("wifi IP obtaining",15000,0,stateData,ip_obtaining_timeout, + (StaticTimer_t *)(TimerHandle_t)((int)stateData + 0x20)); + xOptionalValue = xTaskGetTickCount(); + xTimerGenericCommand + ((TimerHandle_t)((int)stateData + 0x20),1,xOptionalValue,(BaseType_t *)0x0,0xffffffff); + vTaskEnterCritical(); + uVar5 = wifiMgmr.wlan_sta.ipv4.dns2; + uVar4 = wifiMgmr.wlan_sta.ipv4.dns1; + uVar3 = wifiMgmr.wlan_sta.ipv4.gw; + uVar2 = wifiMgmr.wlan_sta.ipv4.mask; + uVar1 = wifiMgmr.wlan_sta.ipv4.ip; + vTaskExitCritical(); + if (uVar1 == 0) { + printf("[WF][SM] DHCP Starting...%p\r\n",0x42023f68); + wifi_netif_dhcp_start((netif *)&wifiMgmr.wlan_sta.netif); + } + else { + printf("[WF][SM] Static IP Starting...%p\r\n",0x42023f68); + iStack44 = (ip_addr_t)uVar4; + dns_setserver('\0',(ip_addr_t *)&iStack44); + iStack44 = (ip_addr_t)uVar5; + dns_setserver('\x01',(ip_addr_t *)&iStack44); + iStack44 = (ip_addr_t)uVar1; + addr_ipaddr = uVar2; + addr_netmask = uVar3; + netifapi_netif_common((netif *)&wifiMgmr.wlan_sta.netif,dhcp_stop,(netifapi_errt_fn)0x0); + netifapi_netif_set_addr((netif *)&wifiMgmr.wlan_sta.netif,&iStack44,&addr_ipaddr,&addr_netmask); + } + aos_post_event(2,4,0); + return; +} + + + +_Bool stateConnectedIPNoGuard_disconnect(void *ch,event *event) + +{ + if (ch == (void *)(uint)*(byte *)event->data) { + bl_main_disconnect(); + return false; + } + return false; +} + + + +_Bool stateConnectedIPYesGuard_disconnect(void *ch,event *event) + +{ + if (ch == (void *)(uint)*(byte *)event->data) { + bl_main_disconnect(); + return false; + } + return false; +} + + + +_Bool stateConnectedIPYesGuard_rcconfig(void *ch,event *event) + +{ + byte *pbVar1; + + pbVar1 = (byte *)event->data; + if (ch == (void *)(uint)*pbVar1) { + printf("[WF][SM] rate config, use sta_idx 0, rate_config %04X\r\n",*(undefined4 *)(pbVar1 + 1)); + bl_main_rate_config('\0',*(uint16_t *)(pbVar1 + 1)); + } + return false; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void stateIdleAction_connect(void *oldStateData,event *event,void *newStateData) + +{ + void *pvVar1; + wifi_mgmr_profile_msg_t *profile_msg; + char *pcVar2; + + pvVar1 = event->data; + *(undefined *)((int)pvVar1 + 0x2d) = 0; + *(undefined *)((int)pvVar1 + 0x72) = 0; + printf("[WF][SM] Action Connect\r\n"); + profile_msg = (wifi_mgmr_profile_msg_t *)((int)pvVar1 + 0xd); + printf(" ssid %s\r\n",profile_msg); + printf(" ssid len %u\r\n",*(undefined4 *)((int)pvVar1 + 0x2e)); + printf(" psk %s\r\n",(uint8_t *)((int)pvVar1 + 0x32)); + printf(" psk len %u\r\n",*(undefined4 *)((int)pvVar1 + 0xb4)); + printf(" pmk %s\r\n",(uint8_t *)((int)pvVar1 + 0x73)); + printf(" pmk len %u\r\n",*(undefined4 *)((int)pvVar1 + 0xb8)); + printf(" channel band %d\r\n",(uint)*(byte *)((int)pvVar1 + 0xc2)); + printf(" channel freq %d\r\n",(uint)*(ushort *)((int)pvVar1 + 0xc3)); + printf(" mac %02X:%02X:%02X:%02X:%02X:%02X\r\n",(uint)*(byte *)((int)pvVar1 + 0xc1), + (uint)*(byte *)((int)pvVar1 + 0xc0),(uint)*(byte *)((int)pvVar1 + 0xbf), + (uint)*(byte *)((int)pvVar1 + 0xbe),(uint)*(byte *)((int)pvVar1 + 0xbd), + (uint)*(byte *)((int)pvVar1 + 0xbc)); + if (*(char *)((int)pvVar1 + 0xc5) == '\0') { + pcVar2 = "false"; + } + else { + pcVar2 = "true"; + } + printf(" dhcp status: %s\r\n",pcVar2); + wifi_mgmr_profile_add(&wifiMgmr,profile_msg,-1); + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n",oldStateData,newStateData); + bl_main_connect((uint8_t *)profile_msg,*(int *)((int)pvVar1 + 0x2e), + (uint8_t *)((int)pvVar1 + 0x32),*(int *)((int)pvVar1 + 0xb4), + (uint8_t *)((int)pvVar1 + 0x73),*(int *)((int)pvVar1 + 0xb8), + (uint8_t *)((int)pvVar1 + 0xbc),*(uint8_t *)((int)pvVar1 + 0xc2),_DAT_00000010); + return; +} + + + +_Bool stateGlobal_cfg_req(void *ch,event *event) + +{ + char *pcVar1; + + pcVar1 = (char *)event->data; + if (*pcVar1 == '\x16') { + bl_main_cfg_task_req + (*(uint32_t *)(pcVar1 + 0xd),*(uint32_t *)(pcVar1 + 0x11),*(uint32_t *)(pcVar1 + 0x15) + ,*(uint32_t *)(pcVar1 + 0x19),pcVar1 + 0x21,(void *)0x0); + return false; + } + return false; +} + + + +_Bool stateGlobalGuard_fw_powersaving(void *ch,event *event) + +{ + char *pcVar1; + + pcVar1 = (char *)event->data; + if (*pcVar1 == '\x10') { + printf("------>>>>>> Powersaving CMD, mode: %u\r\n",*(undefined4 *)(pcVar1 + 1)); + bl_main_powersaving(*(int *)(pcVar1 + 1)); + } + return false; +} + + + +_Bool stateGlobalGuard_conf_max_sta(void *ev,event *event) + +{ + char *pcVar1; + + pcVar1 = (char *)event->data; + if (*pcVar1 == '\n') { + printf("[WF][SM] Conf max sta supported %lu...\r\n",*(undefined4 *)(pcVar1 + 1)); + bl_main_conf_max_sta(pcVar1[1]); + } + return false; +} + + + +_Bool stateGlobalGuard_AP(void *ev,event *event) + +{ + char "stateGlobalGuard_AP" [20]; + char *pcVar1; + int iVar2; + + pcVar1 = (char *)event->data; + if (*pcVar1 == '\b') { + iVar2 = bl_main_if_add(0,(netif *)&wifiMgmr.wlan_ap.netif,&wifiMgmr.wlan_ap.vif_index); + if (iVar2 == 0) { + netifapi_netif_common + ((netif *)&wifiMgmr.wlan_ap.netif,netif_set_link_up,(netifapi_errt_fn)0x0); + netifapi_netif_common((netif *)&wifiMgmr.wlan_ap.netif,dhcpd_start,(netifapi_errt_fn)0x0); + printf("[WF][SM] start AP with ssid %s;\r\n",pcVar1 + 0x11); + printf("[WF][SM] pwd %s;\r\n",pcVar1 + 0x37); + printf("[WF][SM] channel %ld;\r\n",*(undefined4 *)(pcVar1 + 0xd)); + bl_main_apm_start(pcVar1 + 0x11,pcVar1 + 0x37,*(int *)(pcVar1 + 0xd), + wifiMgmr.wlan_ap.vif_index,pcVar1[0x32]); + wifiMgmr.inf_ap_enabled = 1; + dns_server_init(); + aos_post_event(2,0xb,0); + } + else { + printf("[WF][SM] %s: add AP iface failed\r\n","stateGlobalGuard_AP"); + } + } + return false; +} + + + +_Bool stateGlobalGuard_scan_beacon(void *ch,event *event) + +{ + byte bVar1; + bool bVar2; + byte *pbVar3; + int iVar4; + int iVar5; + TickType_t TVar6; + size_t sVar7; + int iVar8; + int iVar9; + TickType_t TVar10; + uint32_t uVar11; + wifi_mgmr_t *pwVar12; + int iVar13; + wifi_mgmr_scan_item_t *__s; + uint32_t uVar14; + + pbVar3 = (byte *)event->data; + if (ch == (void *)(uint)*pbVar3) { + pwVar12 = &wifiMgmr; + if ((((int)(uint)pbVar3[0x3b] <= wifiMgmr.channel_nums) && (pbVar3[0x3b] != 0)) && + ((pbVar3[0xd] != 0 || ((wifiMgmr.features & 1) != 0)))) { + TVar6 = xTaskGetTickCount(); + bVar2 = false; + uVar14 = 0xffffffff; + iVar4 = -1; + iVar13 = 0; + iVar9 = -1; + do { + iVar5 = iVar13; + if (wifiMgmr.channel_nums < (int)(uint)pwVar12->scan_items[0].channel) { + memset(pwVar12->scan_items,0,0x3c); + pwVar12->scan_items[0].is_used = '\0'; + } + else { + if (pwVar12->scan_items[0].is_used != '\0') { + uVar11 = pwVar12->scan_items[0].timestamp_lastseen; + if ((!bVar2) || ((int)(uVar11 - uVar14) < 0)) { + iVar4 = iVar13; + uVar14 = uVar11; + } + iVar8 = memcmp(pwVar12->scan_items[0].bssid,pbVar3 + 0x35,6); + iVar5 = iVar9; + bVar2 = true; + if ((iVar8 == 0) && + (iVar9 = strcmp((char *)(pbVar3 + 0xd),(char *)pwVar12->scan_items), bVar2 = true, + iVar9 == 0)) { + if (((char)pbVar3[0x3c] < wifiMgmr.scan_items[iVar13].rssi) && + (TVar10 = xTaskGetTickCount(), + (int)(TVar10 - wifiMgmr.scan_items[iVar13].timestamp_lastseen) < 3000)) { + return false; + } + wifiMgmr.scan_items[iVar13].channel = pbVar3[0x3b]; + wifiMgmr.scan_items[iVar13].rssi = pbVar3[0x3c]; + wifiMgmr.scan_items[iVar13].ppm_abs = pbVar3[0x3d]; + bVar1 = pbVar3[0x3e]; + wifiMgmr.scan_items[iVar13].timestamp_lastseen = TVar6; + wifiMgmr.scan_items[iVar13].ppm_rel = bVar1; + wifiMgmr.scan_items[iVar13].auth = pbVar3[0x3f]; + wifiMgmr.scan_items[iVar13].cipher = pbVar3[0x40]; + return false; + } + } + } + iVar13 = iVar13 + 1; + pwVar12 = (wifi_mgmr_t *)&(pwVar12->wlan_sta).netif.input; + iVar9 = iVar5; + } while (iVar13 != 0x32); + if ((iVar5 != -1) || (iVar5 = iVar4, iVar4 != -1)) { + __s = wifiMgmr.scan_items + iVar5; + memset(__s,0,0x3c); + strncpy((char *)__s,(char *)(pbVar3 + 0xd),0x20); + wifiMgmr.scan_items[iVar5].ssid_tail[0] = '\0'; + sVar7 = strlen((char *)__s); + wifiMgmr.scan_items[iVar5].ssid_len = sVar7; + memcpy(wifiMgmr.scan_items[iVar5].bssid,pbVar3 + 0x35,6); + wifiMgmr.scan_items[iVar5].channel = pbVar3[0x3b]; + bVar1 = pbVar3[0x3c]; + wifiMgmr.scan_items[iVar5].timestamp_lastseen = TVar6; + wifiMgmr.scan_items[iVar5].rssi = bVar1; + wifiMgmr.scan_items[iVar5].auth = pbVar3[0x3f]; + wifiMgmr.scan_items[iVar5].cipher = pbVar3[0x40]; + wifiMgmr.scan_items[iVar5].is_used = '\x01'; + } + } + } + return false; +} + + + +void __reload_tsen(timer_cb_arg_t data) + +{ + pvTimerGetTimerID((TimerHandle_t)data); + wifi_mgmr_api_fw_tsen_reload(); + return; +} + + + +void event_cb_wifi_event_mgmr(input_event_t *event,void *private_data) + +{ + if (event->code == 0x14) { + aos_post_delayed_action(0x55,trigger_auto_denoise,(void *)0x0); + return; + } + return; +} + + + +void trigger_auto_denoise(void *arg) + +{ + if (auto_repeat != 0) { + wifi_mgmr_api_denoise_enable(); + aos_post_delayed_action(0x55,trigger_auto_denoise,(void *)0x0); + return; + } + return; +} + + + +void stateDisconnect_exit(void *stateData,event *event) + +{ + printf("[WF][SM] Exiting %s state\r\n",stateData); + if (*(char *)((int)stateData + 0x4c) != '\0') { + printf("Delete Timer.\r\n"); + xTimerGenericCommand((TimerHandle_t)((int)stateData + 0x20),3,0,(BaseType_t *)0x0,0); + xTimerGenericCommand((TimerHandle_t)((int)stateData + 0x20),5,0,(BaseType_t *)0x0,0); + *(undefined *)((int)stateData + 0x4c) = 0; + return; + } + printf("Delete Timer Skipped\r\n"); + return; +} + + + +void disconnect_retry(timer_cb_arg_t data) + +{ + void *pvVar1; + int iVar2; + + pvVar1 = pvTimerGetTimerID((TimerHandle_t)data); + iVar2 = wifi_mgmr_profile_get(&wifiMgmr,(wifi_mgmr_profile_msg_t *)((int)pvVar1 + 0x4d)); + if (iVar2 != 0) { + printf("[WF][SM] Retry Again --->>> retry Abort, since profile copy failed\r\n"); + return; + } + printf("[WF][SM] Retry Again --->>> retry connect\r\n"); + wifi_mgmr_api_reconnect(); + return; +} + + + +_Bool stateGlobalGuard_fw_disconnect(void *ch,event *event) + +{ + if (*(char *)event->data == '\x0f') { + printf("Disconnect CMD\r\n"); + bl_main_disconnect(); + return false; + } + return false; +} + + + +void stateConnectedIPYes_exit(void *stateData,event *event) + +{ + ip4_addr_t iStack20; + ip4_addr_t addr_ipaddr; + + iStack20 = (ip4_addr_t)0x0; + printf("[WF][SM] Exiting %s state\r\n",stateData); + netifapi_netif_common((netif *)&wifiMgmr.wlan_sta.netif,dhcp_stop,(netifapi_errt_fn)0x0); + netifapi_netif_set_addr((netif *)&wifiMgmr.wlan_sta.netif,&iStack20,&iStack20,&iStack20); + if (auto_repeat != 0) { + auto_repeat = 0; + bl_main_denoise(0); + } + return; +} + + + +_Bool stateGlobalGuard_denoise(void *ev,event *event) + +{ + int mode; + + if (*(char *)event->data != '\f') { + return false; + } + if (*(int *)(event->data + 1) == 0) { + auto_repeat = 0; + mode = 0; + } + else { + if (wifiMgmr.m.currentState != &stateConnectedIPYes) { + return false; + } + mode = 3; + if (auto_repeat == 0) { + auto_repeat = 1; + bl_main_denoise(1); + aos_post_event(2,0x14,0); + return false; + } + } + bl_main_denoise(mode); + return false; +} + + + +_Bool stateIdleGuard_connect(void *ev,event *event) + +{ + int iVar1; + + if (ev == (void *)(uint)*(byte *)event->data) { + iVar1 = bl_main_if_add(1,(netif *)&wifiMgmr.wlan_sta.netif,&wifiMgmr.wlan_sta.vif_index); + if (iVar1 != 0) { + printf("[WF][SM] %s: add STA iface failed\r\n","stateIdleGuard_connect"); + } + return (_Bool)(iVar1 == 0); + } + return false; +} + + + +_Bool stateIfaceDownGuard_phyup(void *ev,event *event) + +{ + bool bVar1; + int iVar2; + + if (ev == (void *)(uint)*(byte *)event->data) { + iVar2 = bl_main_phy_up(); + bVar1 = iVar2 == 0; + } + else { + printf("[WF][SM] state mismatch\r\n"); + bVar1 = false; + } + return (_Bool)bVar1; +} + + + +_Bool stateSnifferGuard_raw_send(void *ch,event *event) + +{ + char *pcVar1; + + if (((wifiMgmr.m.currentState != &stateIdle) && (wifiMgmr.m.currentState != &stateIfaceDown)) && + (pcVar1 = (char *)event->data, *pcVar1 == '\x15')) { + bl_main_raw_send(*(uint8_t **)(pcVar1 + 1),*(int *)(pcVar1 + 5)); + return false; + } + return false; +} + + + +_Bool stateGlobalGuard_stop(void *ev,event *event) + +{ + if (*(char *)event->data == '\t') { + printf("[WF][SM] Stoping AP interface...\r\n"); + bl_main_apm_stop(wifiMgmr.wlan_ap.vif_index); + printf("[WF][SM] Removing and deauth all sta client...\r\n"); + bl_main_apm_remove_all_sta(); + printf("[WF][SM] Removing AP interface...\r\n"); + bl_main_if_remove(wifiMgmr.wlan_ap.vif_index); + printf("[WF][SM] Stopping DHCP on AP interface...\r\n"); + netifapi_netif_common((netif *)&wifiMgmr.wlan_ap.netif,(netifapi_void_fn)0x0,dhcp_server_stop); + printf("[WF][SM] Removing ETH interface ...\r\n"); + netifapi_netif_common((netif *)&wifiMgmr.wlan_ap.netif,netif_remove,(netifapi_errt_fn)0x0); + wifiMgmr.inf_ap_enabled = 0; + aos_post_event(2,0xc,0); + return false; + } + return false; +} + + + +_Bool stateGlobalGuard_enable_autoreconnect(void *ch,event *event) + +{ + if (ch == (void *)(uint)*(byte *)event->data) { + printf("Enable Auto Reconnect\r\n"); + wifi_mgmr_profile_autoreconnect_enable(&wifiMgmr,-1); + return false; + } + return false; +} + + + +_Bool stateGlobalGuard_disable_autoreconnect(void *ch,event *event) + +{ + bool bVar1; + + if (ch == (void *)(uint)*(byte *)event->data) { + bVar1 = wifiMgmr.m.currentState != &stateDisconnect; + if (bVar1) { + printf("Disable Auto Reconnect\r\n"); + wifi_mgmr_profile_autoreconnect_disable(&wifiMgmr,-1); + } + else { + printf("Disable Autoreconnect in Disconnec State\r\n"); + printf("[WF][SM] Removing STA interface...\r\n"); + bl_main_if_remove(wifiMgmr.wlan_sta.vif_index); + } + return (_Bool)!bVar1; + } + return false; +} + + + +// WARNING: Variable defined which should be unmapped: is_ok + +void stateDisconnect_enter(void *stateData,event *event) + +{ + int iVar1; + TickType_t xOptionalValue; + uint uVar2; + uint uStack20; + int is_ok; + + uStack20 = 0; + printf("[WF][SM] Entering %s state\r\n",stateData); + iVar1 = wifi_mgmr_profile_autoreconnect_is_enabled(&wifiMgmr,-1); + if (iVar1 == 0) { + printf("[WF][SM] Will NOT retry connect\r\n"); + } + else { + xTimerCreateStatic("wifi disconnect",2000,0,stateData,disconnect_retry, + (StaticTimer_t *)(TimerHandle_t)((int)stateData + 0x20)); + printf("[WF][SM] Will retry in 2000 ticks\r\n"); + xOptionalValue = xTaskGetTickCount(); + xTimerGenericCommand + ((TimerHandle_t)((int)stateData + 0x20),1,xOptionalValue,(BaseType_t *)0x0,0xffffffff) + ; + *(undefined *)((int)stateData + 0x4c) = 1; + } + aos_post_event(2,5,(uint)wifiMgmr.wifi_mgmr_stat_info.status_code); + uVar2 = bl60x_check_mac_status((int *)&uStack20); + if ((uVar2 | uStack20) == 0) { + aos_post_event(2,0x17,0); + helper_record_dump(); + } + if ((wifiMgmr.pending_task & 1) != 0) { + printf("[WF][SM] Pending Scan Sent\r\n"); + bl_main_scan(); + wifiMgmr.pending_task = wifiMgmr.pending_task & 0xfffffffe; + } + return; +} + + + +_Bool stateGlobalGuard_fw_scan(void *ch,event *event) + +{ + if (*(char *)event->data == '\x12') { + if (((wifiMgmr.m.currentState == &stateConnecting) || + (wifiMgmr.m.currentState == &stateConnectedIPNo)) || + (wifiMgmr.m.currentState == &stateDisconnect)) { + printf("------>>>>>> Scan CMD Pending\r\n"); + wifiMgmr.pending_task = wifiMgmr.pending_task | 1; + } + else { + if (((wifiMgmr.m.currentState == &stateIdle) || + (wifiMgmr.m.currentState == &stateConnectedIPYes)) || + (wifiMgmr.m.currentState == &stateSniffer)) { + printf("------>>>>>> Scan CMD\r\n"); + bl_main_scan(); + } + else { + printf("------>>>>>> FW busy\r\n"); + aos_post_event(2,9,1); + } + } + return false; + } + return false; +} + + + +uint stateDisconnect_guard(uint param_1,int param_2) + +{ + return (uint)(param_1 == (uint)**(byte **)(param_2 + 4)); +} + + + +void stateGlobalExit(void) + +{ + printf("[WF][SM] Entering %s state\r\n"); + return; +} + + + +void stateSnifferEnter(void) + +{ + printf("[WF][SM] Entering %s state\r\n"); + return; +} + + + +uint stateConnectingGuard(uint param_1,int param_2) + +{ + return (uint)(param_1 == (uint)**(byte **)(param_2 + 4)); +} + + + +void stateConnectingAction_connected(void) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n"); + return; +} + + + +void stateConnectingAction_disconnect(void) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n"); + return; +} + + + +void stateConnectingExit(void) + +{ + printf("[WF][SM] Exiting %s state\r\n"); + return; +} + + + +void stateIdleAction_sniffer(void) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n"); + return; +} + + + +void stateIdleEnter(void) + +{ + printf("[WF][SM] Entering %s state\r\n"); + return; +} + + + +void stateIdleExit(void) + +{ + printf("[WF][SM] Entering %s state\r\n"); + return; +} + + + +void stateIfaceDownAction_phyup(void) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n"); + return; +} + + + +void stateIfaceDownEnter(void) + +{ + printf("[WF][SM] Entering %s state\r\n"); + return; +} + + + +void stateIfaceDownExit(void) + +{ + printf("[WF][SM] Exiting %s state\r\n"); + return; +} + + + +uint stateConnectedIPNoGuard(uint param_1,int param_2) + +{ + return (uint)(param_1 == (uint)**(byte **)(param_2 + 4)); +} + + + +void stateConnectedIPNoAction_disconnect(void) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n"); + return; +} + + + +uint stateConnectedIPYesGuard(uint param_1,int param_2) + +{ + return (uint)(param_1 == (uint)**(byte **)(param_2 + 4)); +} + + + +void stateConnectedIPYes_action(void) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n"); + return; +} + + + +void stateConnectedIPYes_enter(void *stateData,event *event) + +{ + printf("[WF][SM] Entering %s state\r\n",stateData); + aos_post_event(2,7,0); + if ((wifiMgmr.pending_task & 1) != 0) { + printf("[WF][SM] Pending Scan Sent\r\n"); + bl_main_scan(); + wifiMgmr.pending_task = wifiMgmr.pending_task & 0xfffffffe; + } + return; +} + + + +char * wifi_mgmr_auth_to_str(uint8_t auth) + +{ + undefined3 in_register_00002029; + + switch(CONCAT31(in_register_00002029,auth)) { + case 0: + return "Open"; + case 1: + return "WEP"; + case 2: + return "WPA-PSK"; + case 3: + return "WPA2-PSK"; + case 4: + return "WPA2-PSK/WPA-PSK"; + case 5: + return "WPA/WPA2-Enterprise"; + default: + return "Unknown"; + } +} + + + +char * wifi_mgmr_cipher_to_str(uint8_t cipher) + +{ + undefined3 in_register_00002029; + int iVar1; + + iVar1 = CONCAT31(in_register_00002029,cipher); + if (iVar1 == 0) { + return "NONE"; + } + if (iVar1 == 1) { + return "WEP"; + } + if (iVar1 == 2) { + return "AES"; + } + if (iVar1 != 3) { + if (iVar1 != 4) { + return "Unknown"; + } + return "TKIP/AES"; + } + return "TKIP"; +} + + + +int wifi_mgmr_event_notify(wifi_mgmr_msg_t *msg) + +{ + size_t sVar1; + int iVar2; + + while (wifiMgmr.ready == '\0') { + printf("Wait Wi-Fi Mgmr Start up...\r\n"); + vTaskDelay(0x14); + } + sVar1 = xStreamBufferSend((StreamBufferHandle_t)&wifiMgmr.mq,msg,msg->len,0xffffffff); + iVar2 = 0; + if (sVar1 == 0) { + printf("Failed when send msg 0x%p, len dec:%u\r\n",msg,msg->len); + iVar2 = -1; + } + return iVar2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void wifi_mgmr_start(void) + +{ + TickType_t xOptionalValue; + size_t sVar1; + void *pvRxData; + int16_t iStack274; + int16_t temp; + int iStack272; + event ev; + uint8_t buffer [232]; + + pvRxData = (void *)((int)&ev.data + 1); + iStack272 = 1; + ev.type = (int)pvRxData; + stateM_init(&wifiMgmr.m,&stateIfaceDown,&stateError); + wifi_mgmr_event_init(); + aos_register_event_filter(2,event_cb_wifi_event_mgmr,(void *)0x0); + aos_post_event(2,2,0); + hal_sys_capcode_update(-1,-1); + printf("[WF][SM] reload tsen \r\n"); + xTimerCreateStatic("wifi reload tsen",10000,1,&state_tsen_reload_data,__reload_tsen, + (StaticTimer_t *)&state_tsen_reload_data.timer); + xOptionalValue = xTaskGetTickCount(); + xTimerGenericCommand + ((TimerHandle_t)&state_tsen_reload_data.timer,1,xOptionalValue,(BaseType_t *)0x0, + 0xffffffff); + do { + while( true ) { + do { + sVar1 = xStreamBufferReceive((StreamBufferHandle_t)&wifiMgmr.mq,pvRxData,0xe0,0xffffffff); + } while (sVar1 == 0); + if (ev.data._1_1_ != 0xd) break; + iStack274 = 0; + if ((((wifiMgmr.m.currentState == &stateConnecting) || + (wifiMgmr.m.currentState == &stateDisconnect)) || + (wifiMgmr.m.currentState == &stateConnectedIPYes)) || + ((wifiMgmr.m.currentState == &stateSniffer || + (wifiMgmr.m.currentState == &stateConnectedIPNo)))) { + bl_tsen_adc_get(&iStack274,0); + phy_tcal_callback(iStack274); + } + } + iStack272 = 1; + if (0xd < ev.data._1_1_) { + iStack272 = (uint)(0x16 < ev.data._1_1_) << 1; + } + stateM_handleEvent(&wifiMgmr.m,(event *)&stack0xfffffef0); + } while( true ); +} + + + +void _wifi_mgmr_entry(void *pvParameters) + +{ + wifi_conf_t *conf; + TaskHandle_t aptStack36 [4]; + code *pcStack20; + + pcStack20 = wifi_mgmr_start_background; + conf = (wifi_conf_t *)wifi_mgmr_start(); + wifi_mgmr_drv_init(conf); + aptStack36[0] = (TaskHandle_t)0x0; + xTaskCreate(_wifi_mgmr_entry,"wifi_mgmr",0x300,(void *)0x0,0x1c,aptStack36); + return; +} + + + +void wifi_mgmr_start_background(wifi_conf_t *conf) + +{ + TaskHandle_t ptStack20; + TaskHandle_t xHandle; + + wifi_mgmr_drv_init(conf); + ptStack20 = (TaskHandle_t)0x0; + xTaskCreate(_wifi_mgmr_entry,"wifi_mgmr",0x300,(void *)0x0,0x1c,&ptStack20); + return; +} + + + +int wifi_mgmr_init(void) + +{ + StreamBufferHandle_t pSVar1; + + pSVar1 = xStreamBufferGenericCreateStatic + (0x8c0,0,1,wifiMgmr.mq_pool,(StaticStreamBuffer_t *)&wifiMgmr.mq); + wifiMgmr.ready = '\x01'; + wifiMgmr.scan_item_timeout = 15000; + return (uint)(pSVar1 == (StreamBufferHandle_t)0x0); +} + + + +int wifi_mgmr_status_code_clean_internal(void) + +{ + wifiMgmr.wifi_mgmr_stat_info.status_code = 0; + return 0; +} + + + +int wifi_mgmr_state_get_internal(int *state) + +{ + uint16_t uVar1; + int iVar2; + + uVar1 = wifiMgmr.wifi_mgmr_stat_info.status_code; + if (wifiMgmr.m.currentState == &stateIdle) { + if (wifiMgmr.inf_ap_enabled != 0) { + iVar2 = 0x11; + goto LAB_23025a70; + } + iVar2 = 1; + } + else { + if (wifiMgmr.m.currentState == &stateConnecting) { + if (wifiMgmr.inf_ap_enabled != 0) { + iVar2 = 0x12; + goto LAB_23025a70; + } + iVar2 = 2; + } + else { + if (wifiMgmr.m.currentState == &stateConnectedIPNo) { + if (wifiMgmr.inf_ap_enabled == 0) { + iVar2 = 3; + } + else { + iVar2 = 0x13; + } + goto LAB_23025a70; + } + if (wifiMgmr.m.currentState == &stateConnectedIPYes) { + if (wifiMgmr.inf_ap_enabled == 0) { + iVar2 = 4; + } + else { + iVar2 = 0x14; + } + goto LAB_23025a70; + } + if (wifiMgmr.m.currentState != &stateDisconnect) { + if (wifiMgmr.m.currentState == &stateIfaceDown) { + iVar2 = 6; + } + else { + if (wifiMgmr.m.currentState != &stateSniffer) { + *state = 0; + return 0; + } + iVar2 = 7; + } + goto LAB_23025a70; + } + if (wifiMgmr.inf_ap_enabled != 0) { + iVar2 = 0x15; + goto LAB_23025a70; + } + iVar2 = 5; + } + } + *state = iVar2; + if (uVar1 == 8) { + iVar2 = 8; + } + else { + if (uVar1 != 0xc) { + return 0; + } + iVar2 = 9; + } +LAB_23025a70: + *state = iVar2; + return 0; +} + + + +void wifi_mgmr_set_connect_stat_info(wifi_event_sm_connect_ind *ind,uint8_t type_ind) + +{ + uint8_t uVar1; + uint8_t *puVar2; + uint8_t *puVar3; + + wifiMgmr.wifi_mgmr_stat_info.status_code = ind->status_code; + puVar2 = ind->bssid; + puVar3 = wifiMgmr.wifi_mgmr_stat_info.bssid; + do { + uVar1 = *puVar2; + puVar2 = puVar2 + 1; + *puVar3 = uVar1; + puVar3 = puVar3 + 1; + } while (puVar2 != &ind->vif_idx); + wifiMgmr.wifi_mgmr_stat_info.type_ind = type_ind; + wifiMgmr.wifi_mgmr_stat_info.chan_freq = ind->center_freq; + wifiMgmr.wifi_mgmr_stat_info.chan_band = ind->band; + return; +} + + + +int wifi_mgmr_set_country_code_internal(char *country_code) + +{ + bl_main_set_country_code(country_code); + strncpy(wifiMgmr.country_code,country_code,3); + wifiMgmr.country_code[2] = '\0'; + wifiMgmr.channel_nums = bl_main_get_channel_nums(); + return 0; +} + + + +int wifi_mgmr_ap_sta_cnt_get_internal(uint8_t *sta_cnt) + +{ + bl_main_apm_sta_cnt_get(sta_cnt); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +int wifi_mgmr_ap_sta_info_get_internal(wifi_mgmr_sta_basic_info_t *sta_info_internal,uint8_t idx) + +{ + undefined2 uStack40; + wifi_apm_sta_info apm_sta_info; + + memset(&uStack40,0,0x18); + bl_main_apm_sta_info_get((wifi_apm_sta_info *)&uStack40,idx); + *(undefined2 *)sta_info_internal = uStack40; + sta_info_internal->rssi = apm_sta_info.tsflo; + sta_info_internal->tsflo = apm_sta_info.tsfhi; + sta_info_internal->tsfhi = apm_sta_info.sta_mac._2_4_; + sta_info_internal->data_rate = (uint8_t)apm_sta_info.rssi; + memcpy(sta_info_internal->sta_mac,&uStack40 + 1,6); + return 0; +} + + + +int wifi_mgmr_ap_sta_delete_internal(uint8_t sta_idx) + +{ + bl_main_apm_sta_delete(sta_idx); + return 0; +} + + + +int wifi_mgmr_scan_complete_notify(void) + +{ + wifi_mgmr_scan_complete_callback(); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int wifi_mgmr_api_connect(char *ssid,char *psk,char *pmk,uint8_t *mac,uint8_t band,uint16_t freq) + +{ + size_t __n; + int iVar1; + undefined3 in_register_00002039; + undefined2 in_register_0000203e; + WIFI_MGMR_EVENT_T WStack232; + undefined uStack231; + undefined uStack230; + undefined uStack229; + uint8_t buffer [198]; + + memset(&WStack232,0,0xc6); + WStack232 = WIFI_MGMR_EVENT_APP_CONNECT; + uStack231 = 0x44; + uStack230 = 0x33; + uStack229 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = -0x3a; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + __n = strlen(ssid); + buffer._42_2_ = (undefined2)__n; + buffer._44_2_ = (undefined2)(__n >> 0x10); + memcpy(buffer + 9,ssid,__n); + buffer[41] = '\0'; + if (psk == (char *)0x0) { + buffer._176_4_ = 0; +LAB_23025cc8: + buffer[110] = '\0'; + if (pmk == (char *)0x0) { + buffer._180_4_ = 0; + } + else { + buffer._180_4_ = strlen(pmk); + if (buffer._180_4_ != 0) { + if (buffer._180_4_ != 0x40) goto LAB_23025d26; + memcpy(buffer + 0x6f,pmk,0x40); + } + } + buffer[175] = '\0'; + if (mac != (uint8_t *)0x0) { + memcpy(buffer + 0xb8,mac,6); + } + if (CONCAT22(in_register_0000203e,freq) != 0) { + buffer[191] = (uint8_t)freq; + buffer[192] = (uint8_t)(freq >> 8); + buffer[190] = band; + printf("wifi mgmr band:%d freq: %d\r\n",CONCAT31(in_register_00002039,band), + CONCAT22(in_register_0000203e,freq)); + } + buffer[193] = '\x01'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack232); + iVar1 = 0; + } + else { + buffer._176_4_ = strlen(psk); + if (buffer._176_4_ < 0x41) { + if (buffer._176_4_ != 0) { + memcpy(buffer + 0x2e,psk,buffer._176_4_); + } + goto LAB_23025cc8; + } +LAB_23025d26: + iVar1 = -1; + } + return iVar1; +} + + + +int wifi_mgmr_api_cfg_req + (uint32_t ops,uint32_t task,uint32_t element,uint32_t type,uint32_t length, + uint32_t *buf) + +{ + int iVar1; + WIFI_MGMR_EVENT_T WStack100; + undefined uStack99; + undefined uStack98; + undefined uStack97; + uint8_t buffer [65]; + + if (length < 0x21) { + memset(&WStack100,0,0x41); + WStack100 = WIFI_MGMR_EVENT_FW_CFG_REQ; + uStack99 = 0x44; + uStack98 = 0x33; + uStack97 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + iVar1 = length + 0xc6; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[6] = (uint8_t)((uint)iVar1 >> 8); + buffer[7] = (uint8_t)((uint)iVar1 >> 0x10); + buffer[10] = (uint8_t)(ops >> 8); + buffer[11] = (uint8_t)(ops >> 0x10); + buffer[14] = (uint8_t)(task >> 8); + buffer[15] = (uint8_t)(task >> 0x10); + buffer[18] = (uint8_t)(element >> 8); + buffer[19] = (uint8_t)(element >> 0x10); + buffer[22] = (uint8_t)(type >> 8); + buffer[23] = (uint8_t)(type >> 0x10); + buffer[5] = (uint8_t)iVar1; + buffer[9] = (uint8_t)ops; + buffer[13] = (uint8_t)task; + buffer[17] = (uint8_t)element; + buffer[21] = (uint8_t)type; + buffer[26] = (uint8_t)(length >> 8); + buffer[27] = (uint8_t)(length >> 0x10); + buffer[8] = (uint8_t)((uint)iVar1 >> 0x18); + buffer[12] = (uint8_t)(ops >> 0x18); + buffer[16] = (uint8_t)(task >> 0x18); + buffer[20] = (uint8_t)(element >> 0x18); + buffer[24] = (uint8_t)(type >> 0x18); + buffer[25] = (uint8_t)length; + buffer[28] = (uint8_t)(length >> 0x18); + if (length != 0) { + memcpy(buffer + 0x1d,buf,length); + } + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack100); + return 0; + } + return -1; +} + + + +// WARNING: Variable defined which should be unmapped: buffer + +int wifi_mgmr_api_ip_got(uint32_t ip,uint32_t mask,uint32_t gw,uint32_t dns1,uint32_t dns2) + +{ + WIFI_MGMR_EVENT_T WStack52; + undefined uStack51; + undefined uStack50; + undefined uStack49; + uint8_t buffer [33]; + + memset(&WStack52,0,0x21); + WStack52 = WIFI_MGMR_EVENT_APP_IP_GOT; + uStack51 = 0x44; + uStack50 = 0x33; + uStack49 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '!'; + buffer[10] = (uint8_t)(ip >> 8); + buffer[11] = (uint8_t)(ip >> 0x10); + buffer[14] = (uint8_t)(mask >> 8); + buffer[15] = (uint8_t)(mask >> 0x10); + buffer[18] = (uint8_t)(gw >> 8); + buffer[19] = (uint8_t)(gw >> 0x10); + buffer[9] = (uint8_t)ip; + buffer[13] = (uint8_t)mask; + buffer[17] = (uint8_t)gw; + buffer[21] = (uint8_t)dns1; + buffer[22] = (uint8_t)(dns1 >> 8); + buffer[12] = (uint8_t)(ip >> 0x18); + buffer[16] = (uint8_t)(mask >> 0x18); + buffer[20] = (uint8_t)(gw >> 0x18); + buffer[23] = (uint8_t)(dns1 >> 0x10); + buffer[24] = (uint8_t)(dns1 >> 0x18); + buffer[25] = (uint8_t)dns2; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + buffer[26] = (uint8_t)(dns2 >> 8); + buffer[27] = (uint8_t)(dns2 >> 0x10); + buffer[28] = (uint8_t)(dns2 >> 0x18); + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack52); + return 0; +} + + + +int wifi_mgmr_api_ip_update(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_GLB_IP_UPDATE; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_reconnect(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_RECONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_disable_autoreconnect(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_GLB_DISABLE_AUTORECONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_enable_autoreconnect(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_GLB_ENABLE_AUTORECONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_disconnect(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_DISCONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_rate_config(uint16_t config) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_RC_CONFIG; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + uStack31 = (undefined)config; + buffer[4] = 'U'; + uStack30 = (undefined)(config >> 8); + uStack29 = 0; + buffer[0] = '\0'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_conf_max_sta(uint8_t max_sta_supported) + +{ + WIFI_MGMR_EVENT_T local_20; + uint8_t uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_CONF_MAX_STA; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + uStack30 = 0; + uStack29 = 0; + buffer[0] = '\0'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + uStack31 = max_sta_supported; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_ifaceup(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_PHY_UP; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_sniffer_enable(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_SNIFFER; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_scan_item_beacon + (uint8_t channel,int8_t rssi,uint8_t auth,uint8_t *mac,uint8_t *ssid,int len, + int8_t ppm_abs,int8_t ppm_rel,uint8_t cipher) + +{ + WIFI_MGMR_EVENT_T WStack108; + undefined uStack107; + undefined uStack106; + undefined uStack105; + uint8_t buffer [73]; + + memset(&WStack108,0,0x49); + WStack108 = WIFI_MGMR_EVENT_GLB_SCAN_IND_BEACON; + uStack107 = 0x44; + uStack106 = 0x33; + uStack105 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = 'I'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + memcpy(buffer + 9,ssid,len); + buffer[45] = (uint8_t)len; + buffer[46] = (uint8_t)((uint)len >> 8); + buffer[47] = (uint8_t)((uint)len >> 0x10); + buffer[48] = (uint8_t)((uint)len >> 0x18); + buffer[41] = '\0'; + memcpy(buffer + 0x31,mac,6); + buffer[55] = channel; + buffer[56] = rssi; + buffer[57] = ppm_abs; + buffer[58] = ppm_rel; + buffer[59] = auth; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack108); + return 0; +} + + + +int wifi_mgmr_api_fw_disconnect(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_FW_DISCONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_fw_tsen_reload(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + local_20 = WIFI_MGMR_EVENT_APP_RELOAD_TSEN; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_fw_scan(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_FW_SCAN; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_fw_powersaving(int mode) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_FW_POWERSAVING; + uStack30 = (undefined)((uint)mode >> 8); + uStack29 = (undefined)((uint)mode >> 0x10); + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + uStack31 = (undefined)mode; + buffer[4] = 'U'; + buffer[0] = (uint8_t)((uint)mode >> 0x18); + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int wifi_mgmr_api_ap_start(char *ssid,char *passwd,int channel,uint8_t hidden_ssid) + +{ + size_t sVar1; + int iVar2; + undefined3 in_register_00002035; + WIFI_MGMR_EVENT_T WStack156; + undefined uStack155; + undefined uStack154; + undefined uStack153; + uint8_t buffer [124]; + + if (ssid == (char *)0x0) { + return -1; + } + memset(&WStack156,0,0x7c); + sVar1 = strlen(ssid); + buffer[47] = (uint8_t)sVar1; + buffer._48_4_ = buffer._48_4_ & 0xff000000 | sVar1 >> 8; + if (sVar1 < 0x21) { + if (passwd != (char *)0x0) { + buffer._116_4_ = strlen(passwd); + if (0x20 < buffer._116_4_) goto LAB_23026744; + } + WStack156 = WIFI_MGMR_EVENT_APP_AP_START; + uStack155 = 0x44; + uStack154 = 0x33; + uStack153 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '|'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + memcpy(buffer + 0xd,ssid,(uint)buffer[47] | buffer._48_4_ << 8); + if (passwd == (char *)0x0) { + buffer._116_4_ = 0; + } + else { + memcpy(buffer + 0x33,passwd,buffer._116_4_); + } + buffer[9] = (uint8_t)channel; + buffer[10] = (uint8_t)((uint)channel >> 8); + buffer[46] = CONCAT31(in_register_00002035,hidden_ssid) != 0; + buffer[11] = (uint8_t)((uint)channel >> 0x10); + buffer[12] = (uint8_t)((uint)channel >> 0x18); + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack156); + iVar2 = 0; + } + else { +LAB_23026744: + iVar2 = -1; + } + return iVar2; +} + + + +int wifi_mgmr_api_ap_stop(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_AP_STOP; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_idle(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + local_20 = WIFI_MGMR_EVENT_APP_IDLE; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_denoise_enable(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_DENOISE; + uStack31 = 1; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + uStack30 = 0; + uStack29 = 0; + buffer[0] = '\0'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_denoise_disable(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_DENOISE; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + uStack31 = 0; + uStack30 = 0; + uStack29 = 0; + buffer[0] = '\0'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_raw_send(uint8_t *pkt,int len) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_FW_DATA_RAW_SEND; + uStack30 = (undefined)((uint)pkt >> 8); + uStack29 = (undefined)((uint)pkt >> 0x10); + buffer[2] = (uint8_t)((uint)len >> 8); + uStack31 = SUB41(pkt,0); + buffer[1] = (uint8_t)len; + buffer[3] = (uint8_t)((uint)len >> 0x10); + buffer[0] = (uint8_t)((uint)pkt >> 0x18); + buffer[4] = (uint8_t)((uint)len >> 0x18); + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_set_country_code(char *country_code) + +{ + wifi_mgmr_set_country_code_internal(country_code); + return 0; +} + + + +void cmd_rf_dump(char *buf,int len,int argc,char **argv) + +{ + return; +} + + + +void cmd_dump_reset(char *buf,int len,int argc,char **argv) + +{ + pkt_counter = 10; + return; +} + + + +void cmd_wifi_power_table_update(char *buf,int len,int argc,char **argv) + +{ + int8_t aiStack56 [4]; + int8_t power_table_test [38]; + + memcpy(aiStack56,&DAT_230b348c,0x26); + bl_tpc_update_power_table(aiStack56); + return; +} + + + +void cmd_wifi_state_get(char *buf,int len,int argc,char **argv) + +{ + char *fmt; + int iStack20; + int state; + + iStack20 = 0; + wifi_mgmr_state_get(&iStack20); + switch(iStack20) { + case 0: + fmt = "wifi state unknown\r\n"; + break; + case 1: + fmt = "wifi state idle\r\n"; + break; + case 2: + fmt = "wifi state connecting\r\n"; + break; + case 3: + fmt = "wifi state connected ip getting\r\n"; + break; + case 4: + fmt = "wifi state connected ip got\r\n"; + break; + case 5: + fmt = "wifi state disconnect\r\n"; + break; + case 6: + fmt = "wifi state ifdown\r\n"; + break; + case 7: + fmt = "wifi state sniffer\r\n"; + break; + case 8: + fmt = "wifi state psk error\r\n"; + break; + case 9: + fmt = "wifi state no ap found\r\n"; + break; + default: + goto switchD_23026a10_caseD_a; + case 0x11: + fmt = "wifi state with ap idle\r\n"; + break; + case 0x12: + fmt = "wifi state with ap connecting\r\n"; + break; + case 0x13: + fmt = "wifi state with ap connected ip getting\r\n"; + break; + case 0x14: + fmt = "wifi state with ap connected ip got\r\n"; + break; + case 0x15: + fmt = "wifi state with ap disconnect\r\n"; + } + printf(fmt); +switchD_23026a10_caseD_a: + return; +} + + + +void wifi_sta_get_state_cmd(char *buf,int len,int argc,char **argv) + +{ + char "wifi_sta_get_state_cmd" [23]; + char *fmt; + int iStack20; + int state; + + iStack20 = 0; + wifi_mgmr_state_get(&iStack20); + printf("%s:wifi state = 0x%x\r\n","wifi_sta_get_state_cmd",iStack20); + if (iStack20 == 0) { + fmt = "wifi current state: WIFI_STATE_UNKNOWN\r\n"; + } + else { + if (iStack20 == 1) { + fmt = "wifi current state: WIFI_STATE_IDLE\r\n"; + } + else { + if (iStack20 == 2) { + fmt = "wifi current state: WIFI_STATE_CONNECTING\r\n"; + } + else { + if (iStack20 == 3) { + fmt = "wifi current state: WIFI_STATE_CONNECTED_IP_GETTING\r\n"; + } + else { + if (iStack20 == 4) { + fmt = "wifi current state: WIFI_STATE_CONNECTED_IP_GOT\r\n"; + } + else { + if (iStack20 == 5) { + fmt = "wifi current state: WIFI_STATE_DISCONNECT\r\n"; + } + else { + if (iStack20 == 0x11) { + fmt = "wifi current state: WIFI_STATE_WITH_AP_IDLE\r\n"; + } + else { + if (iStack20 == 0x12) { + fmt = "wifi current state: WIFI_STATE_WITH_AP_CONNECTING\r\n"; + } + else { + if (iStack20 == 0x13) { + fmt = "wifi current state: WIFI_STATE_WITH_AP_CONNECTED_IP_GETTING\r\n"; + } + else { + if (iStack20 == 0x14) { + fmt = "wifi current state: WIFI_STATE_WITH_AP_CONNECTED_IP_GOT\r\n"; + } + else { + if (iStack20 == 0x15) { + fmt = "wifi current state: WIFI_STATE_WITH_AP_DISCONNECT\r\n"; + } + else { + if (iStack20 == 6) { + fmt = "wifi current state: WIFI_STATE_IFDOWN\r\n"; + } + else { + if (iStack20 == 7) { + fmt = "wifi current state: WIFI_STATE_SNIFFER\r\n"; + } + else { + if (iStack20 == 8) { + fmt = "wifi current state: WIFI_STATE_PSK_ERROR\r\n"; + } + else { + if (iStack20 == 9) { + fmt = "wifi current state: WIFI_STATE_NO_AP_FOUND\r\n"; + } + else { + fmt = "wifi current state: invalid\r\n"; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + printf(fmt); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void wifi_edca_dump_cmd(char *buf,int len,int argc,char **argv) + +{ + byte local_15; + byte local_14; + byte local_13; + uint8_t aifs; + ushort uStack18; + uint8_t cwmin; + uint8_t cwmax; + uint16_t txop; + + local_15 = 0; + local_14 = 0; + local_13 = 0; + uStack18 = 0; + puts("EDCA Statistic:\r\n"); + bl60x_edca_get(0,&local_15,&local_14,&local_13,(uint16_t *)&stack0xffffffee); + puts(" AC_BK:"); + printf("aifs %3u, cwmin %3u, cwmax %3u, txop %4u\r\n",(uint)local_15,(uint)local_14,(uint)local_13 + ,(uint)uStack18); + bl60x_edca_get(1,&local_15,&local_14,&local_13,(uint16_t *)&stack0xffffffee); + puts(" AC_BE:"); + printf("aifs %3u, cwmin %3u, cwmax %3u, txop %4u\r\n",(uint)local_15,(uint)local_14,(uint)local_13 + ,(uint)uStack18); + bl60x_edca_get(2,&local_15,&local_14,&local_13,(uint16_t *)&stack0xffffffee); + puts(" AC_VI:"); + printf("aifs %3u, cwmin %3u, cwmax %3u, txop %4u\r\n",(uint)local_15,(uint)local_14,(uint)local_13 + ,(uint)uStack18); + bl60x_edca_get(3,&local_15,&local_14,&local_13,(uint16_t *)&stack0xffffffee); + puts(" AC_VO:"); + printf("aifs %3u, cwmin %3u, cwmax %3u, txop %4u\r\n",(uint)local_15,(uint)local_14,(uint)local_13 + ,(uint)uStack18); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void wifi_ap_sta_list_get_cmd(char *buf,int len,int argc,char **argv) + +{ + char cVar1; + uint uVar2; + char *fmt; + wifi_ap_data_rate *pwVar3; + byte bStack77; + uint8_t sta_cnt; + uint uStack76; + int state; + wifi_sta_basic_info sta_info; + + uStack76 = 0; + bStack77 = 0; + wifi_mgmr_state_get((int *)&stack0xffffffb4); + if ((uStack76 & 0x10) == 0) { + fmt = "wifi AP is not enabled, state = %d\r\n"; + uVar2 = uStack76; + } + else { + wifi_mgmr_ap_sta_cnt_get(&bStack77); + if (bStack77 != 0) { + memset(&state,0,0x18); + printf("sta list:\r\n"); + printf( + "-----------------------------------------------------------------------------------\r\n" + ); + printf( + "No. StaIndex Mac-Address Signal DateRate TimeStamp\r\n" + ); + printf( + "-----------------------------------------------------------------------------------\r\n" + ); + uVar2 = 0; + do { + if (bStack77 <= uVar2) { + return; + } + wifi_mgmr_ap_sta_info_get((wifi_sta_basic_info *)&state,(uint8_t)uVar2); + if ((state._1_1_ != '\0') && ((uint8_t)state != -0x11)) { + pwVar3 = data_rate_list; + cVar1 = '\0'; + do { + if (pwVar3->data_rate == (uint8_t)sta_info.rssi) break; + cVar1 = cVar1 + '\x01'; + pwVar3 = pwVar3 + 1; + } while (cVar1 != '\f'); + printf( + " %u %u %02X:%02X:%02X:%02X:%02X:%02X %d %s 0x%llx\r\n" + ,uVar2,(uint)state._2_1_,(uint)state._3_1_,(uint)sta_info.sta_idx, + (uint)sta_info.is_used,(uint)sta_info.sta_mac[0]); + } + uVar2 = uVar2 + 1 & 0xff; + } while( true ); + } + uVar2 = 0; + fmt = "no sta connect current AP, sta_cnt = %d\r\n"; + } + printf(fmt,uVar2); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void wifi_ap_sta_delete_cmd(char *buf,int len,int argc,char **argv) + +{ + char cVar1; + byte idx; + char *fmt; + size_t sVar2; + char *pcVar3; + char *__s; + byte bVar4; + char cVar5; + byte bStack45; + uint8_t sta_cnt; + char *pcStack44; + int state; + wifi_sta_basic_info sta_info; + + pcStack44 = (char *)0x0; + bStack45 = 0; + if (argc == 2) { + wifi_mgmr_state_get((int *)&stack0xffffffd4); + if (((uint)pcStack44 & 0x10) == 0) { + fmt = "wifi AP is not enabled, state = %d\r\n"; + pcVar3 = pcStack44; + } + else { + printf("Delete Sta No.%s \r\n",argv[1]); + __s = argv[1]; + idx = 0; + sVar2 = strlen(__s); + cVar5 = '\x01'; + fmt = __s + sVar2; + *fmt = '\0'; + pcVar3 = fmt; + while ((int)(fmt + -(int)pcVar3) < (int)sVar2) { + cVar1 = pcVar3[-1]; + bVar4 = cVar1 - 0x30; + if (9 < bVar4) { + if ((byte)(cVar1 + 0x9fU) < 6) { + bVar4 = cVar1 + 0xa9; + } + else { + bVar4 = 0; + if ((byte)(cVar1 + 0xbfU) < 6) { + bVar4 = cVar1 - 0x37; + } + } + } + pcVar3 = pcVar3 + -1; + idx = idx + bVar4 * cVar5; + cVar5 = cVar5 * '\n'; + } + pcVar3 = (char *)(uint)idx; + printf("sta_str: %s, str_len: %d, sta_num: %d, q: %s\r\n",__s,pcVar3); + printf("sta num = %d \r\n",pcVar3); + wifi_mgmr_ap_sta_cnt_get(&bStack45); + if ((bStack45 == 0) || ((char *)(uint)bStack45 < pcVar3)) { + fmt = "no valid sta in list or sta idx(%d) is invalid\r\n"; + pcVar3 = (char *)(uint)bStack45; + } + else { + memset(&state,0,0x18); + wifi_mgmr_ap_sta_info_get((wifi_sta_basic_info *)&state,idx); + if ((state._1_1_ != '\0') && ((uint8_t)state != -0x11)) { + printf("sta info: No.%u,sta_idx = %u,mac = %02X:%02X:%02X:%02X:%02X:%02X,rssi = %d\r\n", + pcVar3,(uint)state._2_1_,(uint)state._3_1_,(uint)sta_info.sta_idx, + (uint)sta_info.is_used,(uint)sta_info.sta_mac[0]); + wifi_mgmr_ap_sta_delete((uint8_t)state); + return; + } + fmt = "No.%d sta is invalid\r\n"; + } + } + } + else { + fmt = "[USAGE]: %s sta_num\r\n"; + pcVar3 = *argv; + } + printf(fmt,pcVar3); + return; +} + + + +void cmd_wifi_coex_pta_force_off(char *buf,int len,int argc,char **argv) + +{ + coex_wifi_pta_forece_enable(0); + return; +} + + + +void cmd_wifi_coex_pta_force_on(char *buf,int len,int argc,char **argv) + +{ + coex_wifi_pta_forece_enable(1); + return; +} + + + +void cmd_wifi_coex_pti_force_off(char *buf,int len,int argc,char **argv) + +{ + coex_wifi_pti_forece_enable(0); + return; +} + + + +void cmd_wifi_coex_pti_force_on(char *buf,int len,int argc,char **argv) + +{ + coex_wifi_pti_forece_enable(1); + return; +} + + + +void cmd_wifi_coex_rf_force_off(char *buf,int len,int argc,char **argv) + +{ + coex_wifi_rf_forece_enable(0); + return; +} + + + +void cmd_wifi_coex_rf_force_on(char *buf,int len,int argc,char **argv) + +{ + coex_wifi_rf_forece_enable(1); + return; +} + + + +void cmd_wifi_mib(char *buf,int len,int argc,char **argv) + +{ + hal_mib_dump(); + utils_hexdump(*argv,0x1e); + return; +} + + + +void cmd_wifi_cfg(char *buf,int len,int argc,char **argv) + +{ + uint uVar1; + uint32_t task; + int iVar2; + uint32_t ops; + uint32_t length; + uint32_t *buf_00; + uint32_t element; + uint32_t type; + uint32_t uStack88; + uint32_t val [1]; + getopt_env_t getopt_env; + + type = 0; + utils_getopt_init((getopt_env_t *)val,0); + element = 0; + task = 0; + uVar1 = 4; + while (iVar2 = utils_getopt((getopt_env_t *)val,argc,argv,":c:T:e:t:v:"), iVar2 != -1) { + if (iVar2 == 99) { + iVar2 = strcmp("dump",(char *)val); + if (iVar2 == 0) { + uVar1 = 3; + } + else { + iVar2 = strcmp("set",(char *)val); + if (iVar2 == 0) { + uVar1 = 0; + } + else { + iVar2 = strcmp("get",(char *)val); + if (iVar2 == 0) { + uVar1 = 1; + } + else { + iVar2 = strcmp("reset",(char *)val); + if (iVar2 == 0) { + uVar1 = 2; + } + } + } + } + } + else { + if (iVar2 < 100) { + if (iVar2 == 0x3f) { + printf("%s: unknown option %c\r\n",*argv,getopt_env.opterr); + return; + } + if (iVar2 == 0x54) { + type = atoi((char *)val); + } + } + else { + if (iVar2 == 0x74) { + task = atoi((char *)val); + } + else { + if (iVar2 == 0x76) { + uStack88 = atoi((char *)val); + } + else { + if (iVar2 == 0x65) { + element = atoi((char *)val); + } + } + } + } + } + } + printf("Target CFG Element Info, task: %lu, element %lu, type %lu, val %lu\r\n",task,element,type, + uStack88); + if (uVar1 == 2) { + printf(" OPS: %s\r\n",0x230b6cd4); + buf_00 = (uint32_t *)0x0; + length = 0; + type = 0; + ops = 2; + } + else { + if (uVar1 < 3) { + if (uVar1 == 1) { + printf(" OPS: %s\r\n",0x230c0e50); + buf_00 = &uStack88; + length = 4; + ops = 1; + goto LAB_23027068; + } + } + else { + if (uVar1 == 3) { + printf(" OPS: %s\r\n",0x230c0e64); + buf_00 = (uint32_t *)0x0; + length = 0; + type = 0; + element = 0; + task = 0; + ops = 3; + goto LAB_23027068; + } + if (uVar1 == 4) { + printf("UNKNOWN OPS\r\n"); + return; + } + } + printf(" OPS: %s\r\n",0x230c0e28); + buf_00 = &uStack88; + length = 4; + ops = 0; + } +LAB_23027068: + wifi_mgmr_cfg_req(ops,task,element,type,length,buf_00); + return; +} + + + +void cmd_wifi_ap_stop(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_ap_stop((wifi_interface_t *)0x0); + printf("--->>> cmd_wifi_ap_stop\r\n"); + return; +} + + + +// WARNING: Variable defined which should be unmapped: ssid_name + +void cmd_wifi_ap_start(char *buf,int len,int argc,char **argv) + +{ + wifi_interface_t *interface; + uint hidden_ssid; + char *passwd; + int channel; + uint8_t auStack56 [3]; + byte bStack53; + uint8_t mac [6]; + char ssid_name [32]; + + memset(auStack56,0,6); + bl_wifi_mac_addr_get(auStack56); + memset(mac + 4,0,0x20); + snprintf((char *)(mac + 4),0x20,"BL60X_uAP_%02X%02X%02X",(uint)bStack53,(uint)mac[0],(uint)mac[1]) + ; + interface = (wifi_interface_t *)wifi_mgmr_ap_enable(); + if (argc == 1) { + channel = 1; + passwd = (char *)0x0; + hidden_ssid = 0; + } + else { + channel = atoi(argv[1]); + if (10 < channel - 1U) { + return; + } + passwd = "12345678"; + hidden_ssid = (uint)(argc == 3); + } + wifi_mgmr_ap_start(interface,(char *)(mac + 4),hidden_ssid,passwd,channel); + return; +} + + + +void wifi_sniffer_off_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_sniffer_disable(); + wifi_mgmr_sniffer_unregister((void *)0x0); + return; +} + + + +void wifi_sniffer_on_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_sniffer_enable(); + wifi_mgmr_sniffer_register((void *)0x0,sniffer_cb); + return; +} + + + +int wifi_denoise_disable_cmd(void) + +{ + WIFI_MGMR_EVENT_T WStack32; + undefined uStack31; + undefined uStack30; + undefined uStack29; + undefined uStack28; + undefined uStack27; + undefined uStack26; + undefined uStack25; + undefined uStack24; + undefined uStack23; + undefined uStack22; + undefined uStack21; + undefined uStack20; + + memset(&WStack32,0,0xd); + WStack32 = WIFI_MGMR_EVENT_APP_DENOISE; + uStack27 = 0x88; + uStack26 = 0x77; + uStack25 = 0x66; + uStack24 = 0x55; + uStack31 = 0; + uStack30 = 0; + uStack29 = 0; + uStack28 = 0; + uStack23 = 0xd; + uStack22 = 0; + uStack21 = 0; + uStack20 = 0; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack32); + return 0; +} + + + +int wifi_denoise_enable_cmd(void) + +{ + WIFI_MGMR_EVENT_T WStack32; + undefined uStack31; + undefined uStack30; + undefined uStack29; + undefined uStack28; + undefined uStack27; + undefined uStack26; + undefined uStack25; + undefined uStack24; + undefined uStack23; + undefined uStack22; + undefined uStack21; + undefined uStack20; + + memset(&WStack32,0,0xd); + WStack32 = WIFI_MGMR_EVENT_APP_DENOISE; + uStack31 = 1; + uStack27 = 0x88; + uStack26 = 0x77; + uStack25 = 0x66; + uStack24 = 0x55; + uStack30 = 0; + uStack29 = 0; + uStack28 = 0; + uStack23 = 0xd; + uStack22 = 0; + uStack21 = 0; + uStack20 = 0; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack32); + return 0; +} + + + +void wifi_power_saving_off_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_sta_powersaving(0); + return; +} + + + +void wifi_power_saving_on_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_sta_powersaving(2); + return; +} + + + +void wifi_rc_fixed_disable(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_rate_config(0xffff); + return; +} + + + +int wifi_disable_autoreconnect_cmd(void) + +{ + wifi_mgmr_api_disable_autoreconnect(); + return 0; +} + + + +int wifi_enable_autoreconnect_cmd(void) + +{ + wifi_mgmr_api_enable_autoreconnect(); + return 0; +} + + + +void wifi_disconnect_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_sta_disconnect(); + vTaskDelay(1000); + wifi_mgmr_sta_disable((wifi_interface_t *)0x0); + return; +} + + + +int wifi_sta_ip_unset_cmd(void) + +{ + int iVar1; + + iVar1 = wifi_mgmr_sta_ip_set(0,0,0,0,0); + return iVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void wifi_sta_ip_info(char *buf,int len,int argc,char **argv) + +{ + char *pcVar1; + ip4_addr_t iStack80; + ip4_addr_t ip; + ip4_addr_t gw; + ip4_addr_t mask; + ip4_addr_t dns1; + ip4_addr_t dns2; + int rssi; + int8_t power_rate_table [38]; + + wifi_mgmr_sta_ip_get((uint32_t *)&iStack80,(uint32_t *)&ip,(uint32_t *)&gw); + wifi_mgmr_sta_dns_get((uint32_t *)&mask,(uint32_t *)&dns1); + wifi_mgmr_rssi_get((int *)&dns2); + bl_tpc_power_table_get((int8_t *)&rssi); + printf("RSSI: %ddbm\r\n",dns2); + pcVar1 = ip4addr_ntoa(&iStack80); + printf("IP : %s \r\n",pcVar1); + pcVar1 = ip4addr_ntoa(&gw); + printf("MASK: %s \r\n",pcVar1); + pcVar1 = ip4addr_ntoa(&ip); + printf("GW : %s \r\n",pcVar1); + pcVar1 = ip4addr_ntoa(&mask); + printf("DNS1: %s \r\n",pcVar1); + pcVar1 = ip4addr_ntoa(&dns1); + printf("DNS2: %s \r\n",pcVar1); + puts("Power Table (dbm):\r\n"); + puts("--------------------------------\r\n"); + printf(" 11b: %u %u %u %u (1Mbps 2Mbps 5.5Mbps 11Mbps)\r\n",(int)(char)rssi, + (int)rssi._1_1_,(int)rssi._2_1_,(int)rssi._3_1_); + printf( + " 11g: %u %u %u %u %u %u %u %u (6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps)\r\n" + ,(int)power_rate_table[4],(int)power_rate_table[5],(int)power_rate_table[6], + (int)power_rate_table[7],(int)power_rate_table[8],(int)power_rate_table[9], + (int)power_rate_table[10]); + printf(" 11n: %u %u %u %u %u %u %u %u (MCS0 ~ MCS7)\r\n",(int)power_rate_table[12], + (int)power_rate_table[13],(int)power_rate_table[14],(int)power_rate_table[15], + (int)power_rate_table[16],(int)power_rate_table[17],(int)power_rate_table[18]); + puts("--------------------------------\r\n"); + return; +} + + + +void cmd_wifi_raw_send(char *buf,int len,int argc,char **argv) + +{ + uint32_t seq; + char *s; + int iVar1; + + iVar1 = seq << 4; + packet_raw[22] = (uint8_t)iVar1; + seq = seq + 1; + packet_raw[23] = (uint8_t)((uint)iVar1 >> 8); + iVar1 = wifi_mgmr_raw_80211_send(packet_raw,0x18); + if (iVar1 == 0) { + s = "Raw send succeed\r\n"; + } + else { + s = "Raw send failed\r\n"; + } + puts(s); + return; +} + + + +void wifi_scan_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_scan((void *)0x0,(scan_complete_cb_t *)0x0); + return; +} + + + +void sniffer_cb(void *env,uint8_t *pkt,int len) + +{ + TickType_t TVar1; + + sniffer_counter_5067 = sniffer_counter_5067 + 1; + TVar1 = xTaskGetTickCount(); + if (10000 < (int)(TVar1 - last_tick_5069)) { + last_tick_5069 = xTaskGetTickCount(); + } + return; +} + + + +void cmd_wifi_dump(char *buf,int len,int argc,char **argv) + +{ + if (argc < 2) { + puts("[CLI] Dump statistic use normal mode\r\n"); + vTaskEnterCritical(); + } + else { + puts("[CLI] Dump statistic use forced mode\r\n"); + vTaskEnterCritical(); + } + bl60x_fw_dump_statistic((uint)(argc >= 2)); + vTaskExitCritical(); + return; +} + + + +void cmd_wifi_ap_conf_max_sta(char *buf,int len,int argc,char **argv) + +{ + int iVar1; + + if (argc != 2) { + printf("Usage: wifi_ap_max_sta [num]\r\n"); + return; + } + iVar1 = atoi(argv[1]); + printf("Conf Max Sta to %d\r\n",iVar1); + wifi_mgmr_conf_max_sta((uint8_t)iVar1); + return; +} + + + +void wifi_mon_cmd(char *buf,int len,int argc,char **argv) + +{ + if (1 < argc) { + wifi_mgmr_sniffer_enable(); + return; + } + wifi_mgmr_sniffer_register((void *)0x0,sniffer_cb); + return; +} + + + +void wifi_rc_fixed_enable(char *buf,int len,int argc,char **argv) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + char *pcVar4; + uint uVar5; + + if (argc != 4) { + printf("rc_fix_en [b/g/n] [MCS] [GI]"); + return; + } + uVar1 = atoi(argv[1]); + uVar5 = uVar1 & 0xff; + uVar2 = atoi(argv[2]); + uVar3 = atoi(argv[3]); + if (uVar5 == 1) { + pcVar4 = "n mode"; + } + else { + pcVar4 = "b/g mdoe"; + } + printf("wifi set mode:%s, mcs:%d, gi:%d\r\n",pcVar4,uVar2 & 0xff,uVar3 & 0xff); + if (uVar5 == 1) { + uVar1 = ((uVar1 & 0xff) << 0xc | (uVar3 & 0xff) << 9) & 0xffff | uVar2 & 0xff; + } + else { + uVar1 = 0; + if (uVar5 == 0) { + uVar1 = uVar2 & 0xff | 0x600; + } + } + printf("wifi rc:0x%x\r\n",uVar1); + wifi_mgmr_rate_config((uint16_t)uVar1); + return; +} + + + +void wifi_connect_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_interface_t *wifi_interface; + + if (argc != 3) { + printf("[USAGE]: %s [ssid] [password]\r\n",*argv); + return; + } + wifi_interface = (wifi_interface_t *)wifi_mgmr_sta_enable(); + wifi_mgmr_sta_connect(wifi_interface,argv[1],argv[2],(char *)0x0,(uint8_t *)0x0,'\0',0); + return; +} + + + +void wifi_sta_ip_set_cmd(char *buf,int len,int argc,char **argv) + +{ + ip4_addr_t ip; + ip4_addr_t mask; + ip4_addr_t gw; + ip4_addr_t dns1; + ip4_addr_t dns2; + ip4_addr_t iStack56; + ip4_addr_t addr; + char addr_str [20]; + + if (argc == 6) { + ip = (ip4_addr_t)ipaddr_addr(argv[1]); + mask = (ip4_addr_t)ipaddr_addr(argv[2]); + gw = (ip4_addr_t)ipaddr_addr(argv[3]); + dns1 = (ip4_addr_t)ipaddr_addr(argv[4]); + dns2 = (ip4_addr_t)ipaddr_addr(argv[5]); + iStack56 = ip; + ip4addr_ntoa_r(&iStack56,(char *)&addr,0x14); + puts("IP : "); + puts((char *)&addr); + puts("\r\n"); + iStack56 = mask; + ip4addr_ntoa_r(&iStack56,(char *)&addr,0x14); + puts("MASK: "); + puts((char *)&addr); + puts("\r\n"); + iStack56 = gw; + ip4addr_ntoa_r(&iStack56,(char *)&addr,0x14); + puts("GW : "); + puts((char *)&addr); + puts("\r\n"); + iStack56 = dns1; + ip4addr_ntoa_r(&iStack56,(char *)&addr,0x14); + puts("DNS1: "); + puts((char *)&addr); + puts("\r\n"); + iStack56 = dns2; + ip4addr_ntoa_r(&iStack56,(char *)&addr,0x14); + puts("DNS2: "); + puts((char *)&addr); + puts("\r\n"); + wifi_mgmr_sta_ip_set((uint32_t)ip,(uint32_t)mask,(uint32_t)gw,(uint32_t)dns1,(uint32_t)dns2); + } + else { + puts("Illegal CMD format\r\n"); + } + return; +} + + + +void wifi_scan_filter_cmd(char *buf,int len,int argc,char **argv) + +{ + if (argc == 2) { + wifi_mgmr_scan_filter_hidden_ssid((uint)(*argv[1] == '1')); + return; + } + return; +} + + + +void wifi_capcode_cmd(char *buf,int len,int argc,char **argv) + +{ + uint8_t uVar1; + char *fmt; + undefined3 extraout_var; + int iVar2; + char *pcVar3; + + if (argc - 1U < 2) { + if (argc != 1) { + iVar2 = atoi(argv[1]); + printf("Setting capcode to %d\r\n",iVar2); + if (0 < iVar2) { + hal_sys_capcode_update((uint8_t)iVar2,(uint8_t)iVar2); + return; + } + return; + } + uVar1 = hal_sys_capcode_get(); + pcVar3 = (char *)CONCAT31(extraout_var,uVar1); + fmt = "Capcode %u is being used\r\n"; + } + else { + pcVar3 = *argv; + fmt = "Usage: %s capcode\r\n"; + } + printf(fmt,pcVar3); + return; +} + + + +int wifi_mgmr_cli_scanlist(void) + +{ + byte bVar1; + byte bVar2; + byte bVar3; + byte bVar4; + byte bVar5; + byte bVar6; + wifi_mgmr_t *pwVar7; + int iVar8; + TickType_t TVar9; + + printf("cached scan list\r\n"); + pwVar7 = &wifiMgmr; + printf( + "****************************************************************************************************\r\n" + ); + iVar8 = 0; + do { + if (pwVar7->scan_items[0].is_used == '\0') { +LAB_230278d6: + printf("index[%02d]: empty\r\n",iVar8); + } + else { + TVar9 = xTaskGetTickCount(); + if ((uint)wifiMgmr.scan_item_timeout <= TVar9 - pwVar7->scan_items[0].timestamp_lastseen) + goto LAB_230278d6; + bVar1 = pwVar7->scan_items[0].channel; + bVar2 = pwVar7->scan_items[0].bssid[0]; + bVar3 = pwVar7->scan_items[0].bssid[1]; + bVar4 = pwVar7->scan_items[0].bssid[2]; + bVar5 = pwVar7->scan_items[0].bssid[3]; + bVar6 = pwVar7->scan_items[0].bssid[4]; + wifi_mgmr_auth_to_str(pwVar7->scan_items[0].auth); + wifi_mgmr_cipher_to_str(pwVar7->scan_items[0].cipher); + printf( + "index[%02d]: channel %02u, bssid %02X:%02X:%02X:%02X:%02X:%02X, rssi %3d, ppm abs:rel %3d : %3d, auth %20s, cipher:%12s, SSID %s\r\n" + ,iVar8,(uint)bVar1,(uint)bVar2,(uint)bVar3,(uint)bVar4,(uint)bVar5,(uint)bVar6); + } + iVar8 = iVar8 + 1; + pwVar7 = (wifi_mgmr_t *)&(pwVar7->wlan_sta).netif.input; + if (iVar8 == 0x32) { + printf( + "----------------------------------------------------------------------------------------------------\r\n" + ); + return 0; + } + } while( true ); +} + + + +int wifi_mgmr_ext_dump_needed(void) + +{ + bool bVar1; + + bVar1 = 0 < pkt_counter; + if (bVar1) { + pkt_counter = pkt_counter + -1; + } + return (uint)bVar1; +} + + + +int wifi_mgmr_cli_init(void) + +{ + return 0; +} + + + +int mac_is_unvalid(uint8_t *mac) + +{ + int iVar1; + + iVar1 = 1; + do { + if (mac[iVar1] != *mac) { + return 0; + } + iVar1 = iVar1 + 1; + } while (iVar1 != 6); + return (uint)((byte)(*mac - 1) < 0xfe) ^ 1; +} + + + +void cb_scan_item_parse(wifi_mgmr_ap_item_t *env,uint32_t *param1,wifi_mgmr_ap_item_t *item) + +{ + size_t sVar1; + uint uVar2; + + uVar2 = *param1; + if (uVar2 < 0x32) { + env = env + uVar2; + env->channel = item->channel; + env->rssi = item->rssi; + memcpy(env->bssid,item->bssid,6); + memcpy(env,item,0x20); + env->ssid_tail[0] = '\0'; + sVar1 = strlen((char *)env); + env->ssid_len = sVar1; + env->auth = item->auth; + *param1 = uVar2 + 1; + } + return; +} + + + +void cb_scan_complete(void *data,void *param) + +{ + printf("scan complete status: %d, ssid_len = %lu\r\n",*(undefined4 *)param, + *(undefined4 *)((int)data + 0x24)); + if (scan_sig != (SemaphoreHandle_t)0x0) { + xQueueGenericSend((QueueHandle_t)scan_sig,(void *)0x0,0,0); + return; + } + return; +} + + + +int wifi_mgmr_drv_init(wifi_conf_t *conf) + +{ + bl606a0_wifi_init(conf); + wifi_mgmr_api_set_country_code((char *)conf); + wifi_mgmr_init(); + wifi_mgmr_api_ifaceup(); + return 0; +} + + + +// WARNING: Variable defined which should be unmapped: gw + +wifi_interface_t wifi_mgmr_sta_enable(void) + +{ + int done; + int iVar1; + ip4_addr_t iStack28; + ip4_addr_t ipaddr; + ip4_addr_t netmask; + ip4_addr_t gw; + + if (done == 1) { + printf("----- BUG FIXME? NOT do STA enable again\r\n"); + } + else { + done = 1; + printf("---------STA enable\r\n"); + wifiMgmr.wlan_sta.mode = 0; + iStack28 = (ip4_addr_t)0x0; + ipaddr = 0; + netmask = 0; + memcpy(wifiMgmr.wlan_sta.netif.hwaddr,wifiMgmr.wlan_sta.mac,6); + iVar1 = mac_is_unvalid(wifiMgmr.wlan_sta.netif.hwaddr); + if (iVar1 != 0) { + bl_wifi_mac_addr_get(wifiMgmr.wlan_sta.netif.hwaddr); + iVar1 = mac_is_unvalid(wifiMgmr.wlan_sta.netif.hwaddr); + if (iVar1 != 0) { + wifiMgmr.wlan_sta.netif.hwaddr._0_2_ = 0x50c0; + wifiMgmr.wlan_sta.netif.hwaddr._2_4_ = 0x100c943; + } + memcpy(wifiMgmr.wlan_sta.mac,wifiMgmr.wlan_sta.netif.hwaddr,6); + } + netifapi_netif_add((netif *)&wifiMgmr.wlan_sta.netif,&iStack28,&ipaddr,&netmask,(void *)0x0, + bl606a0_wifi_netif_init,tcpip_input); + wifiMgmr.wlan_sta.netif.name = 0x7473; + wifiMgmr.wlan_sta.netif.flags = wifiMgmr.wlan_sta.netif.flags | 0x24; + netif_set_default((netif *)&wifiMgmr.wlan_sta.netif); + netif_set_up((netif *)&wifiMgmr.wlan_sta.netif); + } + return &wifiMgmr.wlan_sta; +} + + + +int wifi_mgmr_sta_disable(wifi_interface_t *interface) + +{ + wifi_mgmr_api_idle(); + return 0; +} + + + +int wifi_mgmr_sta_ip_get(uint32_t *ip,uint32_t *gw,uint32_t *mask) + +{ + *ip = wifiMgmr.wlan_sta.netif.ip_addr; + *mask = wifiMgmr.wlan_sta.netif.netmask; + *gw = wifiMgmr.wlan_sta.netif.gw; + return 0; +} + + + +int wifi_mgmr_sta_dns_get(uint32_t *dns1,uint32_t *dns2) + +{ + ip_addr_t *piVar1; + + piVar1 = dns_getserver('\0'); + *dns1 = piVar1->addr; + piVar1 = dns_getserver('\x01'); + *dns2 = piVar1->addr; + return 0; +} + + + +int wifi_mgmr_sta_ip_set(uint32_t ip,uint32_t mask,uint32_t gw,uint32_t dns1,uint32_t dns2) + +{ + vTaskEnterCritical(); + wifiMgmr.wlan_sta.ipv4.ip = ip; + wifiMgmr.wlan_sta.ipv4.mask = mask; + wifiMgmr.wlan_sta.ipv4.gw = gw; + wifiMgmr.wlan_sta.ipv4.dns1 = dns1; + wifiMgmr.wlan_sta.ipv4.dns2 = dns2; + vTaskExitCritical(); + wifi_mgmr_api_ip_update(); + return 0; +} + + + +int wifi_mgmr_sta_ip_unset(void) + +{ + int iVar1; + + iVar1 = wifi_mgmr_sta_ip_set(0,0,0,0,0); + return iVar1; +} + + + +int wifi_mgmr_sta_disconnect(void) + +{ + wifi_mgmr_api_disconnect(); + return 0; +} + + + +int wifi_mgmr_sta_powersaving(int ps) + +{ + if ((ps == 1) || (ps == 2)) { + wifi_mgmr_api_fw_powersaving(ps); + ps = 0; + } + else { + if (ps == 0) { + wifi_mgmr_api_fw_powersaving(0); + } + else { + ps = -1; + } + } + return ps; +} + + + +int wifi_mgmr_sta_autoconnect_enable(void) + +{ + wifi_mgmr_api_enable_autoreconnect(); + return 0; +} + + + +int wifi_mgmr_sta_autoconnect_disable(void) + +{ + wifi_mgmr_api_disable_autoreconnect(); + return 0; +} + + + +void wifi_mgmr_sta_connect_ind_stat_get(wifi_mgmr_sta_connect_ind_stat_info_t *wifi_mgmr_ind_stat) + +{ + size_t __n; + + __n = strlen(wifiMgmr.wifi_mgmr_stat_info.ssid); + if (0 < (int)__n) { + memcpy(wifi_mgmr_ind_stat->ssid,wifiMgmr.wifi_mgmr_stat_info.ssid,__n); + wifi_mgmr_ind_stat->ssid[__n] = '\0'; + } + __n = strlen(wifiMgmr.wifi_mgmr_stat_info.psk); + if (0 < (int)__n) { + memcpy(wifi_mgmr_ind_stat->psk,wifiMgmr.wifi_mgmr_stat_info.psk,__n); + wifi_mgmr_ind_stat->psk[__n] = '\0'; + } + memcpy(wifi_mgmr_ind_stat->bssid,wifiMgmr.wifi_mgmr_stat_info.bssid,6); + wifi_mgmr_ind_stat->status_code = wifiMgmr.wifi_mgmr_stat_info.status_code; + wifi_mgmr_ind_stat->chan_band = wifiMgmr.wifi_mgmr_stat_info.chan_band; + wifi_mgmr_ind_stat->chan_freq = wifiMgmr.wifi_mgmr_stat_info.chan_freq; + wifi_mgmr_ind_stat->type_ind = wifiMgmr.wifi_mgmr_stat_info.type_ind; + printf("wifi mgmr ind status code = %d\r\n"); + printf("ssid: %s, psk: %s, band: %d, freq: %d, type_ind: %d\r\n",wifi_mgmr_ind_stat->ssid, + wifi_mgmr_ind_stat->psk,(uint)wifi_mgmr_ind_stat->chan_band, + (uint)wifi_mgmr_ind_stat->chan_freq,(uint)wifi_mgmr_ind_stat->type_ind); + printf("bssid: %02x%02x%02x%02x%02x%02x\r\n",(uint)wifi_mgmr_ind_stat->bssid[0], + (uint)wifi_mgmr_ind_stat->bssid[1],(uint)wifi_mgmr_ind_stat->bssid[2], + (uint)wifi_mgmr_ind_stat->bssid[3],(uint)wifi_mgmr_ind_stat->bssid[4], + (uint)wifi_mgmr_ind_stat->bssid[5]); + return; +} + + + +void wifi_mgmr_sta_ssid_set(char *ssid) + +{ + size_t __n; + + __n = strlen(ssid); + if (__n != 0) { + __n = strlen(ssid); + memcpy(wifiMgmr.wifi_mgmr_stat_info.ssid,ssid,__n); + return; + } + return; +} + + + +void wifi_mgmr_sta_psk_set(char *psk) + +{ + size_t __n; + + __n = strlen(psk); + if (__n != 0) { + __n = strlen(psk); + memcpy(wifiMgmr.wifi_mgmr_stat_info.psk,psk,__n); + return; + } + return; +} + + + +int wifi_mgmr_sta_connect + (wifi_interface_t *wifi_interface,char *ssid,char *psk,char *pmk,uint8_t *mac, + uint8_t band,uint16_t freq) + +{ + int iVar1; + + wifi_mgmr_sta_ssid_set(ssid); + wifi_mgmr_sta_psk_set(psk); + iVar1 = wifi_mgmr_api_connect(ssid,psk,pmk,mac,band,freq); + return iVar1; +} + + + +// WARNING: Variable defined which should be unmapped: gw + +wifi_interface_t wifi_mgmr_ap_enable(void) + +{ + int iVar1; + ip4_addr_t iStack28; + ip4_addr_t ipaddr; + ip4_addr_t netmask; + ip4_addr_t gw; + + wifiMgmr.wlan_ap.mode = 1; + iStack28 = (ip4_addr_t)0x10ba8c0; + ipaddr = 0xffffff; + netmask = 0; + memcpy(wifiMgmr.wlan_ap.netif.hwaddr,wifiMgmr.wlan_ap.mac,6); + iVar1 = mac_is_unvalid(wifiMgmr.wlan_ap.netif.hwaddr); + if (iVar1 != 0) { + bl_wifi_mac_addr_get(wifiMgmr.wlan_ap.netif.hwaddr); + iVar1 = mac_is_unvalid(wifiMgmr.wlan_ap.netif.hwaddr); + if (iVar1 != 0) { + wifiMgmr.wlan_ap.netif.hwaddr._0_2_ = 0x50c0; + wifiMgmr.wlan_ap.netif.hwaddr._2_4_ = 0x100c943; + } + memcpy(wifiMgmr.wlan_ap.mac,wifiMgmr.wlan_ap.netif.hwaddr,6); + } + netifapi_netif_add((netif *)&wifiMgmr.wlan_ap.netif,&iStack28,&ipaddr,&netmask,(void *)0x0, + bl606a0_wifi_netif_init,tcpip_input); + wifiMgmr.wlan_ap.netif.name = 0x7061; + netif_set_default((netif *)&wifiMgmr.wlan_ap.netif); + netif_set_up((netif *)&wifiMgmr.wlan_ap.netif); + return &wifiMgmr.wlan_ap; +} + + + +int wifi_mgmr_ap_mac_get(uint8_t *mac) + +{ + int iVar1; + + bl_efuse_read_mac(wifiMgmr.wlan_ap.mac); + iVar1 = mac_is_unvalid(wifiMgmr.wlan_ap.mac); + if (iVar1 != 0) { + wifiMgmr.wlan_ap.mac[0] = -0x40; + wifiMgmr.wlan_ap.mac._1_2_ = 0x4350; + wifiMgmr.wlan_ap.mac._3_2_ = 0xc9; + wifiMgmr.wlan_ap.mac[5] = '\x01'; + } + memcpy(mac,wifiMgmr.wlan_ap.mac,6); + return 0; +} + + + +int wifi_mgmr_ap_ip_get(uint32_t *ip,uint32_t *gw,uint32_t *mask) + +{ + *ip = wifiMgmr.wlan_ap.netif.ip_addr; + *gw = wifiMgmr.wlan_ap.netif.netmask; + *mask = wifiMgmr.wlan_ap.netif.gw; + return 0; +} + + + +int wifi_mgmr_ap_start(wifi_interface_t *interface,char *ssid,int hidden_ssid,char *passwd, + int channel) + +{ + wifi_mgmr_api_ap_start(ssid,passwd,channel,(uint8_t)hidden_ssid); + return 0; +} + + + +int wifi_mgmr_ap_stop(wifi_interface_t *interface) + +{ + wifi_mgmr_api_ap_stop(); + return 0; +} + + + +int wifi_mgmr_ap_sta_cnt_get(uint8_t *sta_cnt) + +{ + wifi_mgmr_ap_sta_cnt_get_internal(sta_cnt); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +int wifi_mgmr_ap_sta_info_get(wifi_sta_basic_info *sta_info,uint8_t idx) + +{ + undefined2 uStack40; + wifi_mgmr_sta_basic_info sta_info_internal; + + memset(&uStack40,0,0x18); + wifi_mgmr_ap_sta_info_get_internal((wifi_mgmr_sta_basic_info_t *)&uStack40,idx); + *(undefined2 *)sta_info = uStack40; + sta_info->rssi = sta_info_internal.tsflo; + sta_info->tsflo = sta_info_internal.tsfhi; + sta_info->tsfhi = sta_info_internal.sta_mac._2_4_; + sta_info->data_rate = (uint8_t)sta_info_internal.rssi; + memcpy(sta_info->sta_mac,&uStack40 + 1,6); + return 0; +} + + + +int wifi_mgmr_ap_sta_delete(uint8_t sta_idx) + +{ + wifi_mgmr_ap_sta_delete_internal(sta_idx); + return 0; +} + + + +int wifi_mgmr_sniffer_register(void *env,sniffer_cb_t *cb) + +{ + bl_rx_pkt_cb_register(env,(wifi_event_pkt_cb_t *)cb); + return 0; +} + + + +int wifi_mgmr_sniffer_unregister(void *env) + +{ + bl_rx_pkt_cb_unregister(env); + return 0; +} + + + +int wifi_mgmr_sniffer_enable(void) + +{ + wifi_mgmr_api_sniffer_enable(); + return 0; +} + + + +int wifi_mgmr_sniffer_disable(void) + +{ + wifi_mgmr_api_idle(); + return 0; +} + + + +int wifi_mgmr_rate_config(uint16_t config) + +{ + WIFI_MGMR_EVENT_T WStack32; + undefined uStack31; + undefined uStack30; + undefined uStack29; + undefined uStack28; + undefined uStack27; + undefined uStack26; + undefined uStack25; + undefined uStack24; + undefined uStack23; + undefined uStack22; + undefined uStack21; + undefined uStack20; + + memset(&WStack32,0,0xd); + WStack32 = WIFI_MGMR_EVENT_APP_RC_CONFIG; + uStack27 = 0x88; + uStack26 = 0x77; + uStack25 = 0x66; + uStack31 = (undefined)config; + uStack24 = 0x55; + uStack30 = (undefined)(config >> 8); + uStack29 = 0; + uStack28 = 0; + uStack23 = 0xd; + uStack22 = 0; + uStack21 = 0; + uStack20 = 0; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack32); + return 0; +} + + + +int wifi_mgmr_conf_max_sta(uint8_t max_sta_supported) + +{ + WIFI_MGMR_EVENT_T WStack32; + uint8_t uStack31; + undefined uStack30; + undefined uStack29; + undefined uStack28; + undefined uStack27; + undefined uStack26; + undefined uStack25; + undefined uStack24; + undefined uStack23; + undefined uStack22; + undefined uStack21; + undefined uStack20; + + memset(&WStack32,0,0xd); + WStack32 = WIFI_MGMR_EVENT_APP_CONF_MAX_STA; + uStack27 = 0x88; + uStack26 = 0x77; + uStack25 = 0x66; + uStack24 = 0x55; + uStack30 = 0; + uStack29 = 0; + uStack28 = 0; + uStack23 = 0xd; + uStack22 = 0; + uStack21 = 0; + uStack20 = 0; + uStack31 = max_sta_supported; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack32); + return 0; +} + + + +int wifi_mgmr_state_get(int *state) + +{ + uint16_t uVar1; + int iVar2; + + uVar1 = wifiMgmr.wifi_mgmr_stat_info.status_code; + if (wifiMgmr.m.currentState == &stateIdle) { + if (wifiMgmr.inf_ap_enabled != 0) { + iVar2 = 0x11; + goto LAB_23025a70; + } + iVar2 = 1; + } + else { + if (wifiMgmr.m.currentState == &stateConnecting) { + if (wifiMgmr.inf_ap_enabled != 0) { + iVar2 = 0x12; + goto LAB_23025a70; + } + iVar2 = 2; + } + else { + if (wifiMgmr.m.currentState == &stateConnectedIPNo) { + if (wifiMgmr.inf_ap_enabled == 0) { + iVar2 = 3; + } + else { + iVar2 = 0x13; + } + goto LAB_23025a70; + } + if (wifiMgmr.m.currentState == &stateConnectedIPYes) { + if (wifiMgmr.inf_ap_enabled == 0) { + iVar2 = 4; + } + else { + iVar2 = 0x14; + } + goto LAB_23025a70; + } + if (wifiMgmr.m.currentState != &stateDisconnect) { + if (wifiMgmr.m.currentState == &stateIfaceDown) { + iVar2 = 6; + } + else { + if (wifiMgmr.m.currentState != &stateSniffer) { + *state = 0; + return 0; + } + iVar2 = 7; + } + goto LAB_23025a70; + } + if (wifiMgmr.inf_ap_enabled != 0) { + iVar2 = 0x15; + goto LAB_23025a70; + } + iVar2 = 5; + } + } + *state = iVar2; + if (uVar1 == 8) { + iVar2 = 8; + } + else { + if (uVar1 != 0xc) { + return 0; + } + iVar2 = 9; + } +LAB_23025a70: + *state = iVar2; + return 0; +} + + + +int wifi_mgmr_rssi_get(int *rssi) + +{ + *rssi = (int)wifiMgmr.wlan_sta.field_5; + return 0; +} + + + +int wifi_mgmr_raw_80211_send(uint8_t *pkt,int len) + +{ + if (len < 0x1e1) { + wifi_mgmr_api_raw_send(pkt,len); + return 0; + } + return -1; +} + + + +int wifi_mgmr_scan(void *data,scan_complete_cb_t *cb) + +{ + scan_cb = cb; + scan_data = data; + wifi_mgmr_api_fw_scan(); + return 0; +} + + + +int wifi_mgmr_cfg_req(uint32_t ops,uint32_t task,uint32_t element,uint32_t type,uint32_t length, + uint32_t *buf) + +{ + int iVar1; + WIFI_MGMR_EVENT_T WStack100; + undefined uStack99; + undefined uStack98; + undefined uStack97; + undefined uStack96; + undefined uStack95; + undefined uStack94; + undefined uStack93; + undefined uStack92; + undefined uStack91; + undefined uStack90; + undefined uStack89; + undefined uStack88; + undefined uStack87; + undefined uStack86; + undefined uStack85; + undefined uStack84; + undefined uStack83; + undefined uStack82; + undefined uStack81; + undefined uStack80; + undefined uStack79; + undefined uStack78; + undefined uStack77; + undefined uStack76; + undefined uStack75; + undefined uStack74; + undefined uStack73; + undefined uStack72; + undefined uStack71; + undefined uStack70; + undefined uStack69; + undefined uStack68; + undefined auStack67 [39]; + + if (length < 0x21) { + memset(&WStack100,0,0x41); + WStack100 = WIFI_MGMR_EVENT_FW_CFG_REQ; + uStack99 = 0x44; + uStack98 = 0x33; + uStack97 = 0x22; + uStack96 = 0x11; + uStack95 = 0x88; + uStack94 = 0x77; + iVar1 = length + 0xc6; + uStack93 = 0x66; + uStack92 = 0x55; + uStack90 = (undefined)((uint)iVar1 >> 8); + uStack89 = (undefined)((uint)iVar1 >> 0x10); + uStack86 = (undefined)(ops >> 8); + uStack85 = (undefined)(ops >> 0x10); + uStack82 = (undefined)(task >> 8); + uStack81 = (undefined)(task >> 0x10); + uStack78 = (undefined)(element >> 8); + uStack77 = (undefined)(element >> 0x10); + uStack74 = (undefined)(type >> 8); + uStack73 = (undefined)(type >> 0x10); + uStack91 = (undefined)iVar1; + uStack87 = (undefined)ops; + uStack83 = (undefined)task; + uStack79 = (undefined)element; + uStack75 = (undefined)type; + uStack70 = (undefined)(length >> 8); + uStack69 = (undefined)(length >> 0x10); + uStack88 = (undefined)((uint)iVar1 >> 0x18); + uStack84 = (undefined)(ops >> 0x18); + uStack80 = (undefined)(task >> 0x18); + uStack76 = (undefined)(element >> 0x18); + uStack72 = (undefined)(type >> 0x18); + uStack71 = (undefined)length; + uStack68 = (undefined)(length >> 0x18); + if (length != 0) { + memcpy(auStack67,buf,length); + } + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack100); + return 0; + } + return -1; +} + + + +int wifi_mgmr_scan_filter_hidden_ssid(int filter) + +{ + vTaskEnterCritical(); + if (filter == 0) { + wifiMgmr.features = wifiMgmr.features | 1; + } + else { + wifiMgmr.features = wifiMgmr.features & 0xfffffffe; + } + vTaskExitCritical(); + return 0; +} + + + +int wifi_mgmr_scan_complete_callback(void) + +{ + char "wifi_mgmr_scan_complete_callback" [33]; + undefined4 uStack20; + int status; + + uStack20 = 0; + printf("%s: scan complete\r\n","wifi_mgmr_scan_complete_callback"); + if (scan_cb != (scan_complete_cb_t *)0x0) { + uStack20 = 1; + (*scan_cb)(scan_data,&uStack20); + } + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int wifi_mgmr_scan_ap_all(wifi_mgmr_ap_item_t *env,uint32_t *param1,scan_item_cb_t *cb) + +{ + wifi_mgmr_t *pwVar1; + TickType_t TVar2; + undefined auStack84 [4]; + wifi_mgmr_ap_item_t item; + + pwVar1 = &wifiMgmr; + do { + if (pwVar1->scan_items[0].is_used != '\0') { + TVar2 = xTaskGetTickCount(); + if (TVar2 - pwVar1->scan_items[0].timestamp_lastseen < (uint)wifiMgmr.scan_item_timeout) { + memcpy(auStack84,pwVar1->scan_items,0x20); + item.ssid[28] = '\0'; + item._32_4_ = strlen(auStack84); + memcpy(&item.ssid_len,pwVar1->scan_items[0].bssid,6); + item.bssid[2] = pwVar1->scan_items[0].channel; + item.bssid[4] = pwVar1->scan_items[0].rssi; + item.bssid[3] = pwVar1->scan_items[0].auth; + (*cb)(env,param1,(wifi_mgmr_ap_item_t *)auStack84); + } + } + pwVar1 = (wifi_mgmr_t *)&(pwVar1->wlan_sta).netif.input; + } while (pwVar1 != (wifi_mgmr_t *)0x42024af4); + return 0; +} + + + +int wifi_mgmr_all_ap_scan(wifi_mgmr_ap_item_t **ap_ary,uint32_t *num) + +{ + wifi_mgmr_ap_item_t *env; + BaseType_t BVar1; + uint32_t uStack36; + uint32_t counter; + + uStack36 = 0; + if (((ap_ary != (wifi_mgmr_ap_item_t **)0x0) && (num != (uint32_t *)0x0)) && + (env = (wifi_mgmr_ap_item_t *)pvPortMalloc(0xa28), env != (wifi_mgmr_ap_item_t *)0x0)) { + memset(env,0,0xa28); + scan_sig = (SemaphoreHandle_t)xQueueGenericCreate(1,0,'\x03'); + if (scan_sig != (SemaphoreHandle_t)0x0) { + scan_cb = cb_scan_complete; + scan_data = env; + wifi_mgmr_api_fw_scan(); + BVar1 = xQueueSemaphoreTake((QueueHandle_t)scan_sig,0xffffffff); + if (BVar1 == 1) { + printf("wifi scan Done\r\n"); + } + wifi_mgmr_cli_scanlist(); + wifi_mgmr_scan_ap_all(env,&uStack36,cb_scan_item_parse); + *num = uStack36; + *ap_ary = env; + vQueueDelete((QueueHandle_t)scan_sig); + return 0; + } + vPortFree(env); + } + return -1; +} + + + +char * wifi_mgmr_status_code_str(uint16_t status_code) + +{ + undefined2 in_register_0000202a; + + if (CONCAT22(in_register_0000202a,status_code) < 0x11) { + return *(char **)(CSWTCH_17 + CONCAT22(in_register_0000202a,status_code) * 4); + } + return "Unknown Status Code"; +} + + + +int wifi_mgmr_profile_add(wifi_mgmr_t *mgmr,wifi_mgmr_profile_msg_t *profile_msg,int index) + +{ + wifi_mgmr_profile_t *__s; + int iVar1; + + if (index == -1) { + __s = mgmr->profiles; + if (__s == (wifi_mgmr_profile_t *)0x0) { + return -1; + } + } + else { + if (mgmr->profiles[0].isUsed == '\0') { + iVar1 = 0; + } + else { + if (mgmr->profiles[1].isUsed != '\0') { + return -1; + } + iVar1 = 1; + } + mgmr->profile_active_index = iVar1; + __s = mgmr->profiles + iVar1; + printf("[WF][PF] Using free profile, idx is @%d\r\n"); + } + memset(__s,0,0xc4); + *(undefined2 *)&__s->isActive = 0x100; + __s->ssid_len = profile_msg->ssid_len; + __s->psk_len = profile_msg->psk_len; + __s->pmk_len = profile_msg->pmk_len; + __s->priority = -1; + memcpy(__s,profile_msg,0x21); + memcpy(__s->psk,profile_msg->psk,0x41); + memcpy(__s->pmk,profile_msg->pmk,0x41); + memcpy(__s->mac,profile_msg->mac,6); + __s->dhcp_use = profile_msg->dhcp_use; + return 0; +} + + + +int wifi_mgmr_profile_get(wifi_mgmr_t *mgmr,wifi_mgmr_profile_msg_t *profile_msg) + +{ + int iVar1; + uint8_t *puVar2; + undefined4 uVar3; + + if (mgmr->profiles[0].isUsed == '\x01') { + iVar1 = 0; + } + else { + iVar1 = 1; + if (mgmr->profiles[1].isUsed != '\x01') { + return -1; + } + } + printf("[WF][PF] Using profile, idx is @%d\r\n",iVar1); + memset(profile_msg,0,0xb9); + puVar2 = &mgmr->ready + iVar1 * 0xc4; + uVar3 = *(undefined4 *)(puVar2 + 0x114); + *(char *)&profile_msg->ssid_len = (char)uVar3; + *(undefined *)((int)&profile_msg->ssid_len + 1) = (char)((uint)uVar3 >> 8); + *(undefined *)((int)&profile_msg->ssid_len + 2) = (char)((uint)uVar3 >> 0x10); + *(undefined *)((int)&profile_msg->ssid_len + 3) = (char)((uint)uVar3 >> 0x18); + uVar3 = *(undefined4 *)(puVar2 + 0x15c); + *(char *)&profile_msg->psk_len = (char)uVar3; + *(undefined *)((int)&profile_msg->psk_len + 1) = (char)((uint)uVar3 >> 8); + *(undefined *)((int)&profile_msg->psk_len + 2) = (char)((uint)uVar3 >> 0x10); + *(undefined *)((int)&profile_msg->psk_len + 3) = (char)((uint)uVar3 >> 0x18); + uVar3 = *(undefined4 *)(puVar2 + 0x1a4); + *(char *)&profile_msg->pmk_len = (char)uVar3; + *(undefined *)((int)&profile_msg->pmk_len + 1) = (char)((uint)uVar3 >> 8); + *(undefined *)((int)&profile_msg->pmk_len + 2) = (char)((uint)uVar3 >> 0x10); + *(undefined *)((int)&profile_msg->pmk_len + 3) = (char)((uint)uVar3 >> 0x18); + profile_msg->dhcp_use = puVar2[0x1ae]; + memcpy(profile_msg,mgmr->profiles + iVar1,0x21); + memcpy(profile_msg->psk,mgmr->profiles[iVar1].psk,0x41); + memcpy(profile_msg->pmk,mgmr->profiles[iVar1].pmk,0x41); + memcpy(profile_msg->mac,mgmr->profiles[iVar1].mac,6); + return 0; +} + + + +int wifi_mgmr_profile_autoreconnect_is_enabled(wifi_mgmr_t *mgmr,int index) + +{ + return (uint)(mgmr->disable_autoreconnect == '\0'); +} + + + +int wifi_mgmr_profile_autoreconnect_disable(wifi_mgmr_t *mgmr,int index) + +{ + mgmr->disable_autoreconnect = '\x01'; + return 0; +} + + + +int wifi_mgmr_profile_autoreconnect_enable(wifi_mgmr_t *mgmr,int index) + +{ + mgmr->disable_autoreconnect = '\0'; + return 0; +} + + + +int wifi_netif_dhcp_start(netif *netif) + +{ + netifapi_netif_common(netif,(netifapi_void_fn)0x0,dhcp_start); + return 0; +} + + + +void cb_rssi_ind(void *env,int8_t rssi) + +{ + wifiMgmr.wlan_sta.field_5 = rssi; + return; +} + + + +void cb_probe_resp_ind(void *env) + +{ + printf("timestamp = 0x%llx\r\n"); + return; +} + + + +void cb_beacon_ind(void *env,wifi_event_beacon_ind_conflict4 *ind) + +{ + wifi_mgmr_api_scan_item_beacon + (ind->channel,ind->rssi,ind->auth,(uint8_t *)ind,ind->ssid,ind->ssid_len,ind->ppm_abs, + ind->ppm_rel,DAT_00000010); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void cb_disconnect_ind(void *env,wifi_event_sm_disconnect_ind *ind) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + wifi_mgmr_msg_t msg_wifi; + + memset(&local_20,0,0xd); + printf("sending disconnect\r\n"); + local_20 = WIFI_MGMR_EVENT_FW_IND_DISCONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + msg_wifi.ev = WIFI_MGMR_EVENT_FW_CHANNEL_SET; + msg_wifi.data1._0_1_ = 0x88; + msg_wifi.data1._1_1_ = 0x77; + msg_wifi.data1._2_1_ = 0x66; + msg_wifi.data1._3_1_ = 0x55; + msg_wifi.data2._0_1_ = 0xd; + wifiMgmr.wifi_mgmr_stat_info.type_ind = '\x02'; + wifiMgmr.wifi_mgmr_stat_info.status_code = ind->reason_code; + msg_wifi.data2._1_1_ = 0; + msg_wifi.data2._2_1_ = 0; + msg_wifi.data2._3_1_ = 0; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void cb_connect_ind(void *env,wifi_event_sm_connect_ind *ind) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + wifi_mgmr_msg_t msg_wifi; + + memset(&local_20,0,0xd); + local_20 = (ind->status_code == 0) + WIFI_MGMR_EVENT_FW_IND_DISCONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + msg_wifi.ev = WIFI_MGMR_EVENT_FW_CHANNEL_SET; + msg_wifi.data1._0_1_ = 0x88; + msg_wifi.data1._1_1_ = 0x77; + msg_wifi.data1._2_1_ = 0x66; + msg_wifi.data1._3_1_ = 0x55; + msg_wifi.data2._0_1_ = 0xd; + msg_wifi.data2._1_1_ = 0; + msg_wifi.data2._2_1_ = 0; + msg_wifi.data2._3_1_ = 0; + wifi_mgmr_set_connect_stat_info(ind,'\x01'); + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return; +} + + + +void cb_event_ind(void *env,wifi_event *event) + +{ + int iVar1; + uint16_t code; + uint32_t uVar2; + + uVar2 = event->id; + if (uVar2 == 1) { + puts("[WIFI] [IND] SCAN Done\r\n"); + wifi_mgmr_scan_complete_notify(); + code = 9; +LAB_23028648: + aos_post_event(2,code,0); + return; + } + if (uVar2 == 0) { + uVar2 = event[1].id; + iVar1 = -0x490; + wifiMgmr.channel = uVar2; + } + else { + if (uVar2 == 2) { + code = 10; + goto LAB_23028648; + } + iVar1 = -0x454; + } + printf((char *)(BasePoint_x_256 + iVar1),uVar2); + return; +} + + + +int wifi_mgmr_event_init(void) + +{ + bl_rx_sm_connect_ind_cb_register((void *)0x0,cb_connect_ind); + bl_rx_sm_disconnect_ind_cb_register((void *)0x0,cb_disconnect_ind); + bl_rx_beacon_ind_cb_register((void *)0x0,cb_beacon_ind); + bl_rx_probe_resp_ind_cb_register((void *)0x0,cb_probe_resp_ind); + bl_rx_rssi_cb_register((void *)0x0,cb_rssi_ind); + bl_rx_event_register((void *)0x0,cb_event_ind); + return 0; +} + + + +void cmd_mgr_print(bl_cmd_mgr *cmd_mgr) + +{ + list_head *plVar1; + + xQueueSemaphoreTake((QueueHandle_t)cmd_mgr->lock,0xffffffff); + plVar1 = (cmd_mgr->cmds).next; + while (plVar1 != &cmd_mgr->cmds) { + plVar1 = plVar1->next; + } + xQueueGenericSend((QueueHandle_t)cmd_mgr->lock,(void *)0x0,0,0); + return; +} + + + +void cmd_complete(bl_cmd *cmd) + +{ + ushort uVar1; + int *in_a1; + int iVar2; + int *piVar3; + + (cmd->list).next = (list_head *)((int)&(cmd->list).next[-1].prev + 3); + piVar3 = (int *)in_a1[1]; + iVar2 = *in_a1; + *(int **)(iVar2 + 4) = piVar3; + *piVar3 = iVar2; + *in_a1 = 0x100100; + in_a1[1] = 0x200200; + uVar1 = *(ushort *)(in_a1 + 6); + *(ushort *)(in_a1 + 6) = uVar1 | 0x20; + if ((uVar1 & 1) != 0) { + vPortFree(in_a1); + return; + } + if ((uVar1 & 0x18) == 0) { + in_a1[0xf] = 0; + xEventGroupSetBits((EventGroupHandle_t)(in_a1 + 7),1); + return; + } + return; +} + + + +int cmd_mgr_msgind(bl_cmd_mgr *cmd_mgr,ipc_e2a_msg *msg,msg_cb_fct *cb) + +{ + bool bVar1; + bl_cmd *pbVar2; + int iVar3; + + xQueueSemaphoreTake((QueueHandle_t)cmd_mgr->lock,0xffffffff); + pbVar2 = (bl_cmd *)(cmd_mgr->cmds).next; + do { + if (pbVar2 == (bl_cmd *)&cmd_mgr->cmds) { + bVar1 = false; +LAB_2302879c: + xQueueGenericSend((QueueHandle_t)cmd_mgr->lock,(void *)0x0,0,0); + if ((!bVar1) && (cb != (msg_cb_fct *)0x0)) { + (*cb)((bl_hw *)&cmd_mgr[-1].drain,(bl_cmd *)0x0,msg); + } + return 0; + } + if (((pbVar2->reqid == msg->id) && ((pbVar2->flags & 0x10) != 0)) && + ((cb == (msg_cb_fct *)0x0 || + (iVar3 = (*cb)((bl_hw *)&cmd_mgr[-1].drain,pbVar2,msg), iVar3 == 0)))) { + pbVar2->flags = pbVar2->flags & 0xffef; + if ((pbVar2->e2a_msg != (char *)0x0) && (msg->param_len != 0)) { + memcpy(pbVar2->e2a_msg,msg->param,(uint)msg->param_len); + } + bVar1 = true; + if ((pbVar2->flags & 0x18) == 0) { + cmd_complete((bl_cmd *)&cmd_mgr->queue_sz); + } + goto LAB_2302879c; + } + pbVar2 = (bl_cmd *)(pbVar2->list).next; + } while( true ); +} + + + +int cmd_mgr_llind(bl_cmd_mgr *cmd_mgr,bl_cmd *cmd) + +{ + ushort uVar1; + char "cmd_mgr_llind" [14]; + bl_cmd *msg_buf; + bl_cmd *pbVar2; + _Bool __warned; + + xQueueSemaphoreTake((QueueHandle_t)cmd_mgr->lock,0xffffffff); + msg_buf = (bl_cmd *)(cmd_mgr->cmds).next; + pbVar2 = (bl_cmd *)0x0; + do { + if (msg_buf == (bl_cmd *)&cmd_mgr->cmds) { + msg_buf = (bl_cmd *)0x0; + if (pbVar2 != (bl_cmd *)0x0) { +LAB_2302886c: + uVar1 = cmd->flags; + cmd->flags = uVar1 & 0xfff7; + if ((uVar1 & 0x10) == 0) { + cmd_complete((bl_cmd *)&cmd_mgr->queue_sz); + } + if (msg_buf != (bl_cmd *)0x0) { +LAB_23028888: + msg_buf->flags = msg_buf->flags & 0xfffb; + ipc_host_msg_push(*(ipc_host_env_tag **)(cmd_mgr + 1),msg_buf, + (uint16_t)(((uint)msg_buf->a2e_msg->param_len + 8) * 0x10000 >> 0x10)); + vPortFree(msg_buf->a2e_msg); + } + } + xQueueGenericSend((QueueHandle_t)cmd_mgr->lock,(void *)0x0,0,0); + return 0; + } + if ((pbVar2 == (bl_cmd *)0x0) && ((list_head *)msg_buf->tkn == (list_head *)cmd->tkn)) { + pbVar2 = msg_buf; + if ((msg_buf != cmd) && (__warned == false)) { + printf("%s:%d\r\n","cmd_mgr_llind",0xcf); + __warned = true; + } + } + else { + if ((msg_buf->flags & 4) != 0) { + if (pbVar2 == (bl_cmd *)0x0) goto LAB_23028888; + goto LAB_2302886c; + } + } + msg_buf = (bl_cmd *)(msg_buf->list).next; + } while( true ); +} + + + +undefined4 cmd_mgr_queue(char *param_1,char **param_2) + +{ + bool bVar1; + ushort uVar2; + undefined4 uVar3; + EventBits_t EVar4; + char *pcVar5; + char **ppcVar6; + int iVar7; + + xQueueSemaphoreTake(*(QueueHandle_t *)(param_1 + 0x18),0xffffffff); + if (*param_1 == '\x02') { + param_2[0xf] = &DAT_00000020; + xQueueGenericSend(*(QueueHandle_t *)(param_1 + 0x18),(void *)0x0,0,0); + uVar3 = 0xffffffe0; + } + else { + if (param_1 + 0x10 == *(char **)(param_1 + 0x10)) { + bVar1 = false; + } + else { + if (*(int *)(param_1 + 8) == *(int *)(param_1 + 0xc)) { + param_2[0xf] = &DAT_0000000c; + xQueueGenericSend(*(QueueHandle_t *)(param_1 + 0x18),(void *)0x0,0,0); + return 0xfffffff4; + } + bVar1 = false; + if ((*(ushort *)(*(int *)(param_1 + 0x14) + 0x18) & 0xc) != 0) { + bVar1 = true; + *(ushort *)(param_2 + 6) = *(ushort *)(param_2 + 6) | 4; + } + } + if ((*(ushort *)(param_2 + 6) & 2) == 0) { + uVar2 = 8; + } + else { + uVar2 = 0x18; + } + *(ushort *)(param_2 + 6) = *(ushort *)(param_2 + 6) | uVar2; + pcVar5 = *(char **)(param_1 + 4); + *(char **)(param_1 + 4) = pcVar5 + 1; + param_2[5] = pcVar5; + param_2[0xf] = &DAT_00000004; + if ((*(ushort *)(param_2 + 6) & 1) == 0) { + xEventGroupCreateStatic((StaticEventGroup_t *)(param_2 + 7)); + } + ppcVar6 = *(char ***)(param_1 + 0x14); + *(char ***)(param_1 + 0x14) = param_2; + *param_2 = param_1 + 0x10; + *(char ***)(param_2 + 1) = ppcVar6; + *(char ***)ppcVar6 = param_2; + iVar7 = *(int *)(param_1 + 8); + *(int *)(param_1 + 8) = iVar7 + 1; + xQueueGenericSend(*(QueueHandle_t *)(param_1 + 0x18),(void *)0x0,0,0); + if (!bVar1) { + ipc_host_msg_push(*(ipc_host_env_tag **)(param_1 + 0x30),param_2, + (uint16_t)(((uint)*(ushort *)(param_2[3] + 6) + 8) * 0x10000 >> 0x10)); + vPortFree(param_2[3]); + } + if ((*(ushort *)(param_2 + 6) & 1) == 0) { + EVar4 = xEventGroupWaitBits((EventGroupHandle_t)(param_2 + 7),1,1,0,(iVar7 + 1) * 1000000); + if ((EVar4 & 1) == 0) { + xQueueSemaphoreTake(*(QueueHandle_t *)(param_1 + 0x18),0xffffffff); + *param_1 = '\x02'; + if ((*(ushort *)(param_2 + 6) & 0x20) == 0) { + param_2[0xf] = (char *)0x6e; + cmd_complete((bl_cmd *)(param_1 + 8)); + } + xQueueGenericSend(*(QueueHandle_t *)(param_1 + 0x18),(void *)0x0,0,0); + } + vEventGroupDelete((EventGroupHandle_t)(param_2 + 7)); + } + else { + param_2[0xf] = (char *)0x0; + } + uVar3 = 0; + } + return uVar3; +} + + + +void cmd_mgr_drain(bl_cmd_mgr *cmd_mgr) + +{ + list_head *plVar1; + list_head *plVar2; + list_head *plVar3; + list_head *plVar4; + + xQueueSemaphoreTake((QueueHandle_t)cmd_mgr->lock,0xffffffff); + plVar2 = (cmd_mgr->cmds).next; + plVar3 = plVar2->next; + while (plVar1 = plVar3, plVar2 != &cmd_mgr->cmds) { + plVar4 = plVar2->prev; + plVar3 = plVar2->next; + plVar3->prev = plVar4; + plVar4->next = plVar3; + plVar2->next = (list_head *)0x100100; + plVar2->prev = (list_head *)0x200200; + cmd_mgr->queue_sz = cmd_mgr->queue_sz - 1; + if ((*(ushort *)&plVar2[3].next & 1) == 0) { + xEventGroupSetBits((EventGroupHandle_t)&plVar2[3].prev,1); + } + plVar3 = plVar1->next; + plVar2 = plVar1; + } + xQueueGenericSend((QueueHandle_t)cmd_mgr->lock,(void *)0x0,0,0); + return; +} + + + +void bl_cmd_mgr_init(bl_cmd_mgr *cmd_mgr) + +{ + QueueHandle_t pQVar1; + + (cmd_mgr->cmds).next = &cmd_mgr->cmds; + (cmd_mgr->cmds).prev = &cmd_mgr->cmds; + pQVar1 = xQueueCreateMutex('\x01'); + cmd_mgr->max_queue_sz = 8; + cmd_mgr->queue = cmd_mgr_queue; + cmd_mgr->print = cmd_mgr_print; + cmd_mgr->drain = cmd_mgr_drain; + cmd_mgr->llind = cmd_mgr_llind; + *(QueueHandle_t *)&cmd_mgr->lock = pQVar1; + cmd_mgr->msgind = cmd_mgr_msgind; + return; +} + + + +int bl_irqs_init(bl_hw *bl_hw) + +{ + return 0; +} + + + +void bl_irq_bottomhalf(bl_hw *bl_hw) + +{ + uint uVar1; + uint status; + TickType_t TVar2; + + xTaskGetTickCount(); + uVar1 = 0; + status = ipc_host_get_rawstatus(bl_hw->ipc_env); + do { + while (status != 0) { + uVar1 = uVar1 | status; + ipc_host_irq(bl_hw->ipc_env,status); + status = ipc_host_get_rawstatus(bl_hw->ipc_env); + } + TVar2 = xTaskGetTickCount(); + if ((uVar1 & 8) != 0) { + (bl_hw->stats).last_rx = TVar2; + } + if ((uVar1 & 0x780) != 0) { + (bl_hw->stats).last_tx = TVar2; + } + ipc_host_enable_irq(bl_hw->ipc_env,0x7ff); + status = ipc_host_get_rawstatus(bl_hw->ipc_env); + } while (status != 0); + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void goToErrorState(stateMachine *fsm,event *event) + +{ + state *psVar1; + + fsm->previousState = fsm->currentState; + psVar1 = fsm->errorState; + fsm->currentState = psVar1; + if ((psVar1 != (state *)0x0) && + (psVar1->entryAction != (anon_subr_void_void_ptr_event_ptr_for_entryAction *)0x0)) { + // WARNING: Could not recover jumptable at 0x23028b7e. Too many branches + // WARNING: Treating indirect jump as call + (*psVar1->entryAction)(psVar1->data); + return; + } + return; +} + + + +void stateM_init(stateMachine *fsm,state *initialState,state *errorState) + +{ + if (fsm != (stateMachine *)0x0) { + fsm->currentState = initialState; + fsm->previousState = (state *)0x0; + fsm->errorState = errorState; + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +int stateM_handleEvent(stateMachine *fsm,event *event) + +{ + state *psVar1; + state *psVar2; + int iVar3; + int *piVar4; + uint uVar5; + + if (fsm == (stateMachine *)0x0) { + return -2; + } + iVar3 = -2; + if (event != (event *)0x0) { + psVar1 = fsm->currentState; + if (psVar1 == (state *)0x0) { +LAB_23028bac: + goToErrorState(fsm,event); + iVar3 = -1; + } + else { + psVar2 = (state *)psVar1->numTransitions; + while (psVar2 != (state *)0x0) { + uVar5 = 0; + while (uVar5 < psVar1->numTransitions) { + piVar4 = &psVar1->transitions->eventType + uVar5 * 5; + if ((*piVar4 == event->type) && + (((code *)piVar4[2] == (code *)0x0 || + (iVar3 = (*(code *)piVar4[2])(piVar4[1],event), iVar3 != 0)))) { + psVar1 = (state *)piVar4[4]; + if ((state *)piVar4[4] != (state *)0x0) { + do { + psVar2 = psVar1; + psVar1 = psVar2->entryState; + } while (psVar2->entryState != (state *)0x0); + psVar1 = fsm->currentState; + if ((psVar1 != psVar2) && + (psVar1->exitAction != (anon_subr_void_void_ptr_event_ptr_for_exitAction *)0x0)) { + (*psVar1->exitAction)(psVar1->data,event); + } + if ((code *)piVar4[3] != (code *)0x0) { + (*(code *)piVar4[3])(fsm->currentState->data,event,psVar2->data); + } + if ((fsm->currentState != psVar2) && + (psVar2->entryAction != (anon_subr_void_void_ptr_event_ptr_for_entryAction *)0x0)) + { + (*psVar2->entryAction)(psVar2->data,event); + } + psVar1 = fsm->currentState; + fsm->currentState = psVar2; + fsm->previousState = psVar1; + if (psVar1 == psVar2) { + return 1; + } + if (fsm->errorState == psVar2) { + return -1; + } + if (psVar2->numTransitions == 0) { + return 3; + } + return 0; + } + goto LAB_23028bac; + } + uVar5 = uVar5 + 1; + } + psVar1 = psVar1->parentState; + psVar2 = psVar1; + } + iVar3 = 2; + } + } + return iVar3; +} + + + +void netif_status_callback(netif *netif) + +{ + uint32_t ip; + char *pcVar1; + ip_addr_t *piVar2; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + + pcVar1 = ip4addr_ntoa((ip4_addr_t *)&netif->ip_addr); + printf("[lwip] netif status callback\r\n IP: %s\r\n",pcVar1); + pcVar1 = ip4addr_ntoa((ip4_addr_t *)&netif->netmask); + printf(" MK: %s\r\n",pcVar1); + pcVar1 = ip4addr_ntoa((ip4_addr_t *)&netif->gw); + printf(" GW: %s\r\n",pcVar1); + if (((ip4_addr_t *)&netif->ip_addr != (ip4_addr_t *)0x0) && ((netif->ip_addr).addr != 0)) { + wifi_mgmr_api_ip_update(); + mask = (netif->netmask).addr; + gw = (netif->gw).addr; + ip = (netif->ip_addr).addr; + piVar2 = dns_getserver('\0'); + dns1 = piVar2->addr; + piVar2 = dns_getserver('\x01'); + wifi_mgmr_api_ip_got(ip,mask,gw,dns1,piVar2->addr); + return; + } + printf(" SKIP Notify for set Empty Address\r\n"); + return; +} + + + +err_t wifi_tx(netif *netif,pbuf *p) + +{ + err_t eVar1; + TickType_t TVar2; + pbuf *ppVar3; + + ppVar3 = p; + if (p->tot_len < 0x5eb) { + do { + ppVar3 = ppVar3->next; + } while (ppVar3 != (pbuf *)0x0); + eVar1 = '\0'; + bl_output(bl606a0_sta,netif,p,(uint)(netif[-1].client_data[1] == (void *)0x0)); + } + else { + TVar2 = xTaskGetTickCount(); + eVar1 = -0xc; + if (2000 < TVar2 - ticks_7281) { + printf("[TX] %s, TX size too big: %u bytes\r\n",&__func___7282,(uint)p->tot_len); + ticks_7281 = xTaskGetTickCount(); + } + } + return eVar1; +} + + + +err_t bl606a0_wifi_netif_init(netif *netif) + +{ + netif->hostname = "bl606a0"; + netif->mtu = 0x5dc; + *(undefined2 *)&netif->hwaddr_len = 0xa06; + netif->output = etharp_output; + netif->linkoutput = wifi_tx; + netif_set_status_callback(netif,netif_status_callback); + return '\0'; +} + + + +int bl606a0_wifi_init(wifi_conf_t *conf) + +{ + int iVar1; + byte bStack24; + byte bStack23; + byte bStack22; + byte bStack21; + uint8_t mac [6]; + + printf("\r\n\r\n[BL] Initi Wi-Fi"); + memset(&bStack24,0,6); + bl_wifi_mac_addr_get(&bStack24); + printf(" with MAC #### %02X:%02X:%02X:%02X:%02X:%02X ####\r\n",(uint)bStack24,(uint)bStack23, + (uint)bStack22,(uint)bStack21,(uint)mac[0],(uint)mac[1]); + bl_msg_update_channel_cfg((char *)conf); + printf("-----------------------------------------------------\r\n"); + bl_wifi_clock_enable(); + memset(&bl606a0_sta,0,4); + iVar1 = bl_main_rtthread_start((bl_hw **)&bl606a0_sta); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_wlcoex_set(int param_1) + +{ + if (param_1 == 0) { + _DAT_28000100 = _DAT_28000100 & 0xffddff0c; + } + else { + _DAT_28000100 = _DAT_28000100 | 0x2200f3; + } + _DAT_28000074 = _DAT_28000074 & 0xffe0ffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void coex_dump_ble(void) + +{ + uint uVar1; + + puts("============= Coex BLE: coexif==================\r\n"); + printf("value is %08lx\r\n",_DAT_28000100); + uVar1 = _DAT_28000100; + printf("mwsscanfreqmsk is %u\r\n",_DAT_28000100 >> 0x18 & 3); + printf("wlcrxpriomode is %u\r\n",uVar1 >> 0x14 & 3); + printf("wlctxpriomode is %u\r\n",uVar1 >> 0x10 & 3); + printf("mwstxfrqmsk is %u\r\n",uVar1 >> 0xe & 3); + printf("mwsrxfrqmsk is %u\r\n",uVar1 >> 0xc & 3); + printf("mwstxmsk is %u\r\n",uVar1 >> 10 & 3); + printf("mwsrxmsk is %u\r\n",uVar1 >> 8 & 3); + printf("wlantxmsk is %u\r\n",uVar1 >> 6 & 3); + printf("wlanrxmsk is %u\r\n",uVar1 >> 4 & 3); + printf("mwswcien is %u\r\n",uVar1 >> 3 & 1); + printf("mwscoexen is %u\r\n",uVar1 >> 2 & 1); + printf("syncgenen is %u\r\n",uVar1 >> 1 & 1); + printf("wlancoexen is %u\r\n"); + return; +} + + + +uint32_t BLE_ROM_patch(void *pRet,...) + +{ + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void blecontroller_main(void *pvParameters) + +{ + BaseType_t BVar1; + char acStack24 [4]; + rw_task_msg_t msg; + + (*ble_memset_ptr)(acStack24,0,8); + do { + BVar1 = xQueueReceive(xRwmainQueue,acStack24,0xffffffff); + if ((BVar1 == 1) && (acStack24[0] == '\x01')) { + hci_send_2_controller(msg._0_4_); + } + rwip_schedule(); + } while( true ); +} + + + +void BLE_ROM_hook_init(void) + +{ + _rom_patch_hook = BLE_ROM_patch; + ble_memcmp_ptr = memcmp; + ble_memcpy_ptr = memcpy; + ble_memset_ptr = memset; + ble_post_task_ptr = rw_main_task_post_from_fw; + return; +} + + + +_Bool rw_main_task_post(void *msg,uint32_t timeout) + +{ + BaseType_t BVar1; + + if (msg != (void *)0x0) { + BVar1 = xQueueGenericSend(xRwmainQueue,msg,timeout,0); + return (_Bool)(BVar1 == 1); + } + return false; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void rw_main_task_post_from_fw(void) + +{ + BaseType_t BStack28; + BaseType_t xHigherPriorityTaskWoken; + rw_task_msg_t msg; + + xHigherPriorityTaskWoken._0_1_ = 2; + if (TrapNetCounter == 0) { + rw_main_task_post(&xHigherPriorityTaskWoken,0xffffffff); + } + else { + BStack28 = 0; + xQueueGenericSendFromISR(xRwmainQueue,&xHigherPriorityTaskWoken,&BStack28,0); + if (BStack28 == 1) { + vTaskSwitchContext(); + } + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void bdaddr_init(void) + +{ + uint8_t uVar1; + uint8_t uVar2; + byte bStack24; + byte bStack23; + undefined2 uStack22; + uint8_t addr [6]; + + bl_wifi_mac_addr_get(&bStack24); + uVar2 = addr[1]; + uVar1 = addr[0]; + addr[1] = bStack24; + addr[0] = bStack23; + bStack23 = uVar1; + uStack22 = uStack22 >> 8 | uStack22 << 8; + if (uVar2 == -1) { + bStack23 = uVar1 + 1; + bStack24 = 0; + } + else { + bStack24 = uVar2 + 1; + } + co_bdaddr_set(&bStack24); + printf("BD_ADDR:%02x:%02x:%02x:%02x:%02x:%02x\r\n",(uint)addr[0],(uint)uStack22._1_1_, + (uint)(byte)uStack22,(uint)bStack23,(uint)bStack24); + return; +} + + + +void ble_controller_init(uint8_t task_priority) + +{ + undefined3 in_register_00002029; + + BLE_ROM_hook_init(); + rfc_init(40000000); + Is_ext_scan_enable = '\0'; + Is_ready_to_rec_auxpacket = '\0'; + rwble_isr_clear(); + bl_irq_pending_clear(0x48); + bl_irq_register(0x48,rwble_isr); + bl_irq_enable(0x48); + bdaddr_init(); + rwip_init(error); + xRwmainQueue = xQueueGenericCreate(0x14,8,'\0'); + xTaskCreate(blecontroller_main,"blecontroller",0x200,(void *)0x0, + CONCAT31(in_register_00002029,task_priority),(TaskHandle_t *)&rw_main_task_hdl); + return; +} + + + +void ble_controller_deinit(void) + +{ + BaseType_t BVar1; + undefined auStack24 [4]; + int iStack20; + + (*ble_memset_ptr)(auStack24,0,8); + bl_irq_disable(0x48); + vTaskDelete((TaskHandle_t)rw_main_task_hdl); + rw_main_task_hdl = 0; + while (BVar1 = xQueueReceive(xRwmainQueue,auStack24,0), BVar1 == 1) { + if (iStack20 != 0) { + ble_ke_msg_free((ke_msg *)(iStack20 + -0xc)); + } + } + vQueueDelete(xRwmainQueue); + xRwmainQueue = (QueueHandle_t)0x0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rwble_init(void) + +{ + em_buf_init(); + lld_init(false); + llc_init(); + llm_init(false); + _DAT_28000050 = 0; + return; +} + + +/* +Unable to decompile 'rwble_reset' +Cause: Exception while decompiling 2302924a: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rwble_isr_clear(void) + +{ + if (_DAT_28000010 != 0) { + _DAT_28000018 = 0xffffffff; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rwble_isr(void) + +{ + uint uVar1; + + while (uVar1 = _DAT_28000010, _DAT_28000010 != 0) { + if ((_DAT_28000010 & 4) != 0) { + _DAT_28000018 = 4; + rwip_wakeup(); + } + if ((uVar1 & 1) != 0) { + _DAT_28000018 = 1; + rwip_wakeup_end(); + ea_finetimer_isr(); + } + if ((uVar1 & 0x80) != 0) { + _DAT_28000018 = 0x80; + ea_finetimer_isr(); + } + if ((uVar1 & 8) != 0) { + _DAT_28000018 = 8; + if ((uVar1 & 2) != 0) { + _DAT_28000018 = 2; + uVar1 = uVar1 & 0xfffffffd; + } + if ((int)(uVar1 << 0xf) < 0) { + if (Is_ready_to_rec_auxpacket == '\0') { + Is_ready_to_rec_auxpacket = '\x01'; + } + _DAT_28000018 = 0x10000; + } + lld_evt_end_isr(false); + } + if ((uVar1 & 0x10008) == 0x10000) { + if (Is_ready_to_rec_auxpacket == '\0') { + Is_ready_to_rec_auxpacket = '\x01'; + Rec_sync_basecnt = _DAT_280000a8; + Rec_sync_fnt = _DAT_280000ac; + } + _DAT_28000018 = 0x10000; + if ((uVar1 & 2) != 0) { + _DAT_28000018 = 2; + uVar1 = uVar1 & 0xfffffffd; + } + lld_evt_afs_isr((uint8_t)(Rec_sync_fnt >> 0x10)); + } + if ((uVar1 & 0x100) != 0) { + _DAT_28000018 = 0x100; + if ((uVar1 & 2) != 0) { + _DAT_28000018 = 2; + uVar1 = uVar1 & 0xfffffffd; + } + lld_evt_end_isr(true); + } + if ((uVar1 & 2) != 0) { + _DAT_28000018 = 2; + lld_evt_rx_isr(); + } + if ((uVar1 & 0x200) != 0) { + _DAT_28000018 = 0x200; + ea_sw_isr(); + } + if ((uVar1 & 0x40) != 0) { + _DAT_28000018 = 0x40; + lld_evt_timer_isr(); + } + if ((uVar1 & 0x10) != 0) { + _DAT_28000018 = 0x10; + lld_crypt_isr(); + } + if ((uVar1 & 0x20) != 0) { + _DAT_28000018 = 0x20; + } + } + return; +} + + + +uint8_t ea_conflict_check(ea_elt_tag *evt_a,ea_elt_tag *evt_b) + +{ + uint8_t uVar1; + uint uVar2; + uint uVar3; + int iVar4; + uint uVar5; + + uVar2 = evt_b->timestamp - evt_a->timestamp & 0x7ffffff; + uVar5 = (uint)evt_a->delay; + uVar3 = (uint)evt_b->delay; + if (uVar2 < 0x4000001) { + if (uVar2 == 0) goto LAB_23029436; +LAB_23029482: + iVar4 = (uVar5 + evt_a->duration_min) - uVar3; + uVar1 = '\0'; + if ((0 < iVar4) && (uVar1 = '\0', (int)((iVar4 + -1) / -0x271 + uVar2) < 1)) { + uVar1 = '\x01'; + iVar4 = iVar4 - (uint)evt_b->duration_min; + if (0 < iVar4) { + return ((int)((iVar4 + -1) / -0x271 + uVar2) < 1) + '\x01'; + } + } + } + else { + uVar2 = -(evt_a->timestamp - evt_b->timestamp & 0x7ffffff); + if (uVar2 == 0) { +LAB_23029436: + if (uVar5 < uVar3) goto LAB_23029482; + } + iVar4 = (uVar3 + (uint)evt_b->duration_min) - uVar5; + uVar1 = '\x05'; + if ((0 < iVar4) && (-1 < (int)((iVar4 + -1) / 0x271 + uVar2))) { + iVar4 = ((uVar5 + evt_a->duration_min) - uVar3) - (uint)evt_b->duration_min; + uVar1 = '\x04'; + if (iVar4 < 1) { + uVar1 = ((int)(iVar4 / -0x271 + uVar2) < 0) + '\x03'; + } + } + } + return uVar1; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ea_elt_cancel(ea_elt_tag *param_1) + +{ + ushort uVar1; + ea_elt_tag *peVar2; + uint8_t uVar3; + undefined3 extraout_var; + uint uVar4; + uint uVar5; + ea_elt_tag *evt_b; + uint uVar6; + uint uVar7; + ea_elt_tag *peVar8; + ea_elt_tag *evt_a; + ea_elt_tag *elt_ref_hdr; + ea_elt_tag *elt_ref_hdr_00; + + peVar8 = (ea_elt_tag *)ea_env.elt_canceled.first; + evt_a = (ea_elt_tag *)0; +LAB_230294fe: + do { + do { + elt_ref_hdr = evt_a; + evt_a = peVar8; + if (evt_a == (ea_elt_tag *)0x0) { + if (ea_env.elt_canceled.first != (co_list_hdr *)0x0) { + _DAT_28000000 = _DAT_28000000 & 0xefffffff | 0x10000000; + } + return; + } + uVar1 = evt_a->asap_settings; + peVar8 = *(ea_elt_tag **)&evt_a->hdr; + } while ((uVar1 >> 0xe == 0) || (uVar5 = (int)(uint)uVar1 >> 4 & 0x3f, uVar5 == 0)); + uVar4 = (uint)uVar1 & 0xfffffc0f; + evt_a->current_prio = ((byte)uVar1 & 0xf) + evt_a->current_prio; + uVar5 = (uVar5 - 1) * 0x10; + uVar6 = uVar5 & 0xffff | uVar4; + evt_a->asap_settings = (ushort)uVar5 | (ushort)uVar4; + uVar5 = (int)uVar6 >> 0xc & 3; + peVar2 = param_1; + elt_ref_hdr_00 = (ea_elt_tag *)0x0; + while (evt_b = peVar2, evt_b != (ea_elt_tag *)0x0) { + uVar3 = ea_conflict_check(evt_a,evt_b); + if (CONCAT31(extraout_var,uVar3) == 0) break; + if (CONCAT31(extraout_var,uVar3) != 5) { + uVar4 = (uint)evt_b->delay + (uint)evt_b->duration_min; + uVar7 = uVar4 / 0x271 + evt_b->timestamp; + if ((uint)evt_a->delay < uVar4 % 0x271) { + uVar7 = uVar7 + 1; + } + if (uVar5 == 1) { + uVar7 = uVar7 | 1; + } + else { + if (uVar5 == 0) { + uVar7 = uVar7 + 1 & 0xfffffffe; + } + } + uVar7 = uVar7 & 0x7ffffff; + evt_a->timestamp = uVar7; + if (1 < uVar6 >> 0xe) { + uVar4 = evt_a->asap_limit - uVar7 & 0x7ffffff; + if (0x4000000 < uVar4) { + uVar4 = -(uVar7 - evt_a->asap_limit & 0x7ffffff); + } + if ((int)uVar4 < (int)((uint)evt_a->duration_min / 0x271)) goto LAB_230294fe; + } + } + peVar2 = *(ea_elt_tag **)&evt_b->hdr; + elt_ref_hdr_00 = evt_b; + } + ble_co_list_extract_after(&ea_env.elt_canceled,(co_list_hdr *)elt_ref_hdr,(co_list_hdr *)evt_a); + ble_co_list_insert_after((co_list *)&ea_env,(co_list_hdr *)elt_ref_hdr_00,(co_list_hdr *)evt_a); + evt_a = elt_ref_hdr; + } while( true ); +} + + + +void ea_init(_Bool reset) + +{ + ble_co_list_init((co_list *)&ea_env); + ble_co_list_init(&ea_env.elt_canceled); + ble_co_list_init(&ea_env.interval_list); + ea_env.elt_prog = (ea_elt_tag *)0x0; + ea_env.finetarget_time = 0xffffffff; + return; +} + + + +ea_elt_tag * ea_elt_create(uint16_t size_of_env) + +{ + undefined2 in_register_0000202a; + ea_elt_tag *peVar1; + uint32_t size; + + size = CONCAT22(in_register_0000202a,size_of_env) + 0x2c; + peVar1 = (ea_elt_tag *)ble_ke_malloc(size,'\0'); + if (peVar1 != (ea_elt_tag *)0x0) { + (*ble_memset_ptr)(peVar1,0,size); + } + return peVar1; +} + + + +ea_interval_tag * ea_interval_create(void) + +{ + ea_interval_tag *peVar1; + + peVar1 = (ea_interval_tag *)ble_ke_malloc(0x10,'\0'); + (*ble_memset_ptr)(peVar1,0,0x10); + return peVar1; +} + + + +void ea_interval_insert(ea_interval_tag *interval_to_add) + +{ + ble_co_list_push_back(0x4201319c,interval_to_add); + return; +} + + + +void ea_interval_remove(ea_interval_tag *interval_to_remove) + +{ + ble_co_list_extract(&ea_env.interval_list,(co_list_hdr *)interval_to_remove,'\0'); + return; +} + + + +void ea_sw_isr(void) + +{ + co_list_hdr *pcVar1; + + while (ea_env.elt_canceled.first != (co_list_hdr *)0x0) { + pcVar1 = ble_co_list_pop_front(&ea_env.elt_canceled); + if (pcVar1[9].next != (co_list_hdr *)0x0) { + (*(code *)pcVar1[9].next)(); + } + } + return; +} + + + +uint8_t ea_offset_req(ea_param_input *input_param,ea_param_output *output_param) + +{ + uint16_t uVar1; + ushort uVar2; + uint uVar3; + uint uVar4; + co_list_hdr cVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint8_t uVar9; + uint uVar10; + int iVar11; + uint uVar12; + uint uVar13; + uint uVar14; + + uVar13 = (uint)output_param->interval; + if (output_param->interval != 0) { + uVar14 = output_param->duration & 0xffff; + if (uVar14 != 0) { + if (input_param->action == '\x01') { + uVar6 = (uint)input_param->offset; + } + else { + uVar6 = (uint)input_param->odd_offset; + } + uVar3 = output_param->duration & 0xffff; + cVar5 = (co_list_hdr)ea_env.interval_list.first; +LAB_2302974c: + do { + uVar7 = uVar6; + if (cVar5 == (co_list_hdr)0x0) { + uVar9 = '\x03'; + if (uVar7 < uVar13) { +LAB_2302975c: + output_param->offset = (uint16_t)uVar7; + uVar9 = '\0'; + } + return uVar9; + } + if (uVar13 <= uVar7) { + return '\x03'; + } + uVar1 = input_param->role; + if (uVar1 == 0xff) goto LAB_2302975c; + uVar2 = *(ushort *)&((co_list_hdr *)((int)cVar5 + 4))->next; + uVar6 = (uint)uVar2; + if (((uVar2 != 0) && + (uVar2 = *(ushort *)&((co_list_hdr *)((int)cVar5 + 8))->next, uVar10 = (uint)uVar2, + uVar2 != 0)) && (*(uint16_t *)((int)cVar5 + 10) != input_param->conhdl)) { + uVar4 = uVar6; + if (uVar13 < uVar6) { + uVar4 = uVar13; + } + if ((*(uint16_t *)&((co_list_hdr *)((int)cVar5 + 0xc))->next == uVar1) && + ((uVar1 != 1 || (*(uint16_t *)((int)cVar5 + 0xe) == input_param->linkid)))) { + if (uVar4 < uVar3 + uVar10) { + return '\x03'; + } + iVar11 = uVar10 - 1; + uVar10 = (uint)*(ushort *)((int)cVar5 + 6) % uVar4; + } + else { + if (uVar4 < uVar3 + uVar10) { + return '\x03'; + } + iVar11 = uVar10 + 1; + uVar10 = (int)(*(ushort *)((int)cVar5 + 6) + uVar4 + -1) % uVar4 & 0xffff; + } + uVar12 = iVar11 + uVar10 & 0xffff; + if ((uVar13 % uVar4 == 0) && (uVar6 % uVar4 == 0)) { + uVar6 = uVar7 % uVar4; + uVar8 = uVar6 + (uVar14 - 1) & 0xffff; + if (uVar6 < uVar10) { + if (uVar8 < uVar10) { +LAB_2302982e: + if (uVar8 < uVar12) goto LAB_23029832; + } + } + else { + if (uVar12 < uVar6) { + if (uVar8 < uVar10) { + if (uVar10 == uVar6) goto LAB_2302982e; + } + else { + if ((uVar8 <= uVar12) || (uVar6 <= uVar10)) goto LAB_2302980c; + } +LAB_23029832: + if (((uVar12 < uVar4) || (uVar12 % uVar4 < uVar6)) && + ((uVar8 < uVar4 || (uVar8 % uVar4 < uVar10)))) goto LAB_230297d4; + } + } +LAB_2302980c: + cVar5 = (co_list_hdr)ea_env.interval_list.first; + uVar6 = uVar13; + if (input_param->action != '\x01') { + uVar6 = (int)(uVar12 + 1) % uVar4; + while (uVar6 <= uVar7) { + uVar6 = uVar6 + uVar4 & 0xffff; + } + if (input_param->odd_offset == false) { + if ((uVar6 & 1) == 0) goto LAB_2302974c; + } + else { + if ((uVar6 & 1) != 0) goto LAB_2302974c; + } + uVar6 = uVar6 + 1 & 0xffff; + } + goto LAB_2302974c; + } + } +LAB_230297d4: + cVar5 = *(co_list_hdr *)cVar5; + uVar6 = uVar7; + } while( true ); + } + } + return '\x01'; +} + + + +// WARNING: Removing unreachable block (ram,0x2302989c) + +uint32_t ea_time_get_halfslot_rounded(void) + +{ + // WARNING: Do nothing block with infinite loop + do { + } while( true ); +} + + + +// WARNING: Removing unreachable block (ram,0x230298bc) + +uint32_t ea_time_get_slot_rounded(void) + +{ + // WARNING: Do nothing block with infinite loop + do { + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ea_prog_timer(void) + +{ + byte bVar1; + _Bool time_msb; + uint32_t uVar2; + uint uVar3; + co_list_hdr cVar4; + + ea_env.finetarget_time = 0xffffffff; + uVar2 = ea_time_get_slot_rounded(); + if (ea_env.elt_wait.first == (co_list_hdr *)0x0) { + if (ea_env.finetarget_time == 0xffffffff) { + _DAT_2800000c = _DAT_2800000c & 0xffffff7f; + _DAT_28000018 = 0x80; + goto LAB_230299b0; + } + } + else { + ea_env.finetarget_time = + (uint)((int)ea_env.elt_wait.first[2].next - + (uint)*(byte *)((int)&ea_env.elt_wait.first[6].next + 1)) & 0x7ffffff; + if (ea_env.elt_prog != (ea_elt_tag *)0x0) { + if (((ea_env.elt_prog)->current_prio < *(byte *)((int)&ea_env.elt_wait.first[5].next + 2)) && + ((int)((uint)*(ushort *)&ea_env.elt_wait.first[4].next << 0x14) < 0)) { + bVar1 = (ea_env.elt_prog)->stop_latency2; + } + else { + bVar1 = (ea_env.elt_prog)->stop_latency1; + } + if ((uint)*(byte *)((int)&ea_env.elt_wait.first[6].next + 1) < (uint)bVar1) { + ea_env.finetarget_time = + (uint)((int)ea_env.elt_wait.first[2].next - (uint)bVar1) & 0x7ffffff; + uVar3 = ea_env.finetarget_time - uVar2 & 0x7ffffff; + if ((0x4000000 < uVar3) || (uVar3 == 0)) { + ea_env.finetarget_time = uVar2 + 1 & 0x7ffffff; + } + } + } + } + uVar2 = ea_time_get_slot_rounded(); + if (uVar2 - ea_env.finetarget_time < 0x3ffffff) { + ea_env.finetarget_time = uVar2 + 1 & 0x7ffffff; + } + _DAT_280000f8 = ea_env.finetarget_time; + if ((_DAT_2800000c >> 7 & 1) == 0) { + _DAT_28000018 = 0x80; + _DAT_2800000c = _DAT_2800000c | 0x80; + } +LAB_230299b0: + if ((time_msb != false) && + (cVar4 = (co_list_hdr)ea_env.interval_list.first, -1 < (int)(uVar2 << 5))) { + while (cVar4 != (co_list_hdr)0x0) { + uVar3 = (uint)*(ushort *)&((co_list_hdr *)((int)cVar4 + 4))->next; + *(undefined2 *)((int)cVar4 + 6) = + (short)((int)((uVar3 - 0x8000000 % uVar3) + (uint)*(ushort *)((int)cVar4 + 6)) % uVar3); + cVar4 = *(co_list_hdr *)cVar4; + } + } + return; +} + + +/* +Unable to decompile 'ea_elt_insert' +Cause: Exception while decompiling 23029a00: Decompiler process died + +*/ + +/* +Unable to decompile 'ea_elt_remove' +Cause: Exception while decompiling 23029c6e: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ea_finetimer_isr(void) + +{ + byte bVar1; + ea_elt_tag *peVar2; + uint32_t uVar3; + co_list_hdr *pcVar4; + ea_elt_tag *peVar5; + uint uVar6; + + peVar2 = ea_env.elt_prog; + pcVar4 = ea_env.elt_wait.first; + uVar3 = ea_time_get_halfslot_rounded(); + if (peVar2 != (ea_elt_tag *)0x0) { + if (pcVar4 == (co_list_hdr *)0x0) goto LAB_23029d80; + if ((peVar2->current_prio < *(byte *)((int)&pcVar4[5].next + 2)) && + ((int)((uint)*(ushort *)&pcVar4[4].next << 0x14) < 0)) { + bVar1 = peVar2->stop_latency2; + } + else { + bVar1 = peVar2->stop_latency1; + } + uVar6 = (uint)((int)pcVar4[2].next - uVar3) & 0x7ffffff; + if ((0x4000000 < uVar6) || (uVar6 <= bVar1)) { + if (peVar2->ea_cb_stop != (anon_subr_void_ea_elt_tag_ptr_for_ea_cb_stop *)0x0) { + (*peVar2->ea_cb_stop)(peVar2); + } + ea_env.elt_prog = (ea_elt_tag *)0x0; + } + } + if (pcVar4 != (co_list_hdr *)0x0) { + do { + uVar6 = (uint)((int)pcVar4[2].next - (uint)*(byte *)((int)&pcVar4[6].next + 1)) & 0x7ffffff; + if ((uVar6 - uVar3 & 0x7ffffff) < 0x3ffffff) { + if (uVar6 == uVar3) { + peVar5 = (ea_elt_tag *)ble_co_list_pop_front((co_list *)&ea_env); + if ((ea_env.elt_prog != (ea_elt_tag *)0x0) && + ((ea_env.elt_prog)->ea_cb_stop != (anon_subr_void_ea_elt_tag_ptr_for_ea_cb_stop *)0x0)) + { + (*(ea_env.elt_prog)->ea_cb_stop)(peVar2); + } + ea_env.elt_prog = peVar5; + if (peVar5->ea_cb_start != (anon_subr_void_ea_elt_tag_ptr_for_ea_cb_start *)0x0) { + (*peVar5->ea_cb_start)(peVar5); + } + } + break; + } + pcVar4 = ble_co_list_pop_front((co_list *)&ea_env); + ble_co_list_push_back(0x42013194,pcVar4); + pcVar4 = ea_env.elt_wait.first; + } while (ea_env.elt_wait.first != (co_list_hdr *)0x0); + } +LAB_23029d80: + if (ea_env.elt_canceled.first != (co_list_hdr *)0x0) { + _DAT_28000000 = _DAT_28000000 & 0xefffffff | 0x10000000; + } + ea_prog_timer(); + return; +} + + + +void ea_interval_duration_req(ea_param_input *input_param,ea_param_output *output_param) + +{ + bool bVar1; + co_list_hdr cVar2; + uint uVar3; + uint uVar4; + byte bVar5; + uint uVar6; + uint uVar7; + uint32_t uVar8; + uint uVar9; + + uVar3 = (uint)input_param->interval_max; + output_param->interval = input_param->interval_max; + uVar9 = (uint)input_param->interval_min; + if (uVar3 <= uVar9) goto LAB_23029e26; + bVar5 = 0; + cVar2 = (co_list_hdr)ea_env.interval_list.first; + uVar4 = 0xffff; + while (cVar2 != (co_list_hdr)0x0) { + bVar5 = bVar5 + 1; + uVar6 = uVar4; + if ((*(uint16_t *)((int)cVar2 + 10) != input_param->conhdl) && + (uVar6 = (uint)*(ushort *)&((co_list_hdr *)((int)cVar2 + 4))->next, uVar4 < uVar6)) { + uVar6 = uVar4; + } + cVar2 = *(co_list_hdr *)cVar2; + uVar4 = uVar6; + } + if (bVar5 < 2) { + uVar4 = (uint)input_param->pref_period; + if (input_param->pref_period != 0) { + uVar6 = (int)uVar3 / (int)uVar4; +LAB_23029e12: + uVar7 = uVar4 * uVar6 & 0xffff; + goto LAB_23029e1a; + } + uVar7 = 0xffff; + } + else { + if (uVar4 <= uVar3) { + uVar6 = uVar3 / uVar4; + goto LAB_23029e12; + } + uVar7 = 0xffff; + uVar6 = uVar3; + do { + bVar1 = uVar4 % uVar6 != 0; + if (!bVar1) { + uVar7 = uVar6; + } + uVar6 = uVar6 - 2 & 0xffff; + } while ((uVar9 <= uVar6) && (bVar1)); +LAB_23029e1a: + if (uVar7 < uVar9) goto LAB_23029e26; + } + if (uVar7 <= uVar3) { + output_param->interval = (uint16_t)uVar7; + } +LAB_23029e26: + uVar8 = input_param->duration_min; + if (uVar8 < 2) { + uVar8 = 2; + } + output_param->duration = uVar8; + return; +} + + + +void hci_send_2_host(void *param) + +{ + byte bVar1; + ushort uVar2; + ke_msg *msg; + void *pvVar3; + uint uVar4; + uint uVar5; + + uVar2 = *(ushort *)((int)param + -8); + msg = (ke_msg *)((int)param + -0xc); + if (uVar2 == 0x803) { + bVar1 = *(byte *)((int)param + -4); + uVar4 = (uint)bVar1; + if (bVar1 < 0x40) goto LAB_23029ee2; + if ((bVar1 < 0x58) && + (uVar5 = uVar4 - 0x40 & 0xff, + ((int)(uint)hci_env.evt_msk_page_2.mask[uVar5 >> 3] >> (uVar5 - (uVar4 - 0x40 & 0xf8) & 0x1f) + & 1U) == 0)) goto switchD_23029ed4_caseD_4; +switchD_23029ed4_caseD_2: + hci_build_evt(msg); + } + else { + if (uVar2 == 0x804) { + uVar4 = 0x3e; +LAB_23029ee2: + uVar5 = uVar4 - 1 & 0xff; + if (((int)(uint)hci_env.evt_msk.mask[uVar5 >> 3] >> (uVar5 - (uVar4 - 1 & 0xf8) & 0x1f) & 1U) + == 0) goto switchD_23029ed4_caseD_4; + } + switch((uint)uVar2 - 0x801 & 0xffff) { + case 0: + case 1: + if (uVar2 == 0x801) { + hci_build_cc_evt(msg,'\0'); + } + break; + case 2: + goto switchD_23029ed4_caseD_2; + case 3: + hci_build_le_evt(msg); + break; + default: +switchD_23029ed4_caseD_4: + ble_ke_msg_free(msg); + return; + case 5: + pvVar3 = ble_ke_msg_alloc(0x806,*(ke_task_id_t *)((int)param + -6), + *(ke_task_id_t *)((int)param + -4),8); + (*ble_memcpy_ptr)(pvVar3,param,8); + ble_ke_msg_free(msg); + msg = (ke_msg *)((int)pvVar3 + -0xc); + param = pvVar3; + } + } + msg->dest_id = 4; + ble_ke_msg_send(param); + return; +} + + + +void hci_send_2_controller(int param_1) + +{ + hci_cmd_desc_tag *phVar1; + ushort uVar2; + + if (*(short *)(param_1 + -8) == 0x805) { + phVar1 = hci_look_for_cmd_desc(*(uint16_t *)(param_1 + -4)); + if (phVar1 == (hci_cmd_desc_tag *)0x0) goto switchD_2302a00c_caseD_4; + switch((uint)phVar1->dest_field & 0xf) { + case 0: + case 2: + uVar2 = 0; + break; + case 1: + case 3: + goto switchD_2302a00c_caseD_1; + default: + goto switchD_2302a00c_caseD_4; + case 8: + uVar2 = 3; + } + } + else { + if (*(short *)(param_1 + -8) != 0x807) goto switchD_2302a00c_caseD_4; +switchD_2302a00c_caseD_1: + if (1 < *(ushort *)(param_1 + -6)) { +switchD_2302a00c_caseD_4: + ble_ke_msg_free((ke_msg *)(param_1 + -0xc)); + return; + } + uVar2 = (ushort)(((uint)*(ushort *)(param_1 + -6) & 0xff) << 8) | 1; + } + *(ushort *)(param_1 + -6) = uVar2; + ble_ke_msg_send(param_1); + return; +} + + + +uint8_t hci_evt_mask_set(evt_mask *evt_msk,uint8_t page) + +{ + undefined3 in_register_0000202d; + byte *pbVar1; + int iVar2; + hci_env_tag *phVar3; + + if (CONCAT31(in_register_0000202d,page) == 2) { + (*ble_memcpy_ptr)((void *)0x42025724,evt_msk,8); + } + else { + if (CONCAT31(in_register_0000202d,page) == 3) { + (*ble_memcpy_ptr)(&hci_env,evt_msk,8); + iVar2 = 0; + phVar3 = &hci_env; + do { + pbVar1 = hci_rsvd_evt_msk.mask + iVar2; + iVar2 = iVar2 + 1; + (phVar3->evt_msk).mask[0] = *pbVar1 | (phVar3->evt_msk).mask[0]; + phVar3 = (hci_env_tag *)((phVar3->evt_msk).mask + 1); + } while (iVar2 != 8); + } + } + return '\0'; +} + + + +void hci_init(void) + +{ + (*ble_memset_ptr)(&hci_env,0,0x10); + hci_evt_mask_set(&hci_def_evt_msk,'\x03'); + hci_tl_init(false); + hci_fc_init(); + return; +} + + + +void hci_reset(void) + +{ + (*ble_memset_ptr)(&hci_env,0,0x10); + hci_evt_mask_set(&hci_def_evt_msk,'\x03'); + hci_tl_init(true); + hci_fc_init(); + return; +} + + +/* +Unable to decompile 'rwip_reset' +Cause: Exception while decompiling 2302a114: Decompiler process died + +*/ + + +void rwip_init(uint32_t error) + +{ + (*ble_memset_ptr)(&rwip_env,0,0x10); + ble_ke_init(); + ble_ke_mem_init('\0',(uint8_t *)rwip_heap_ram,0xaff); + ble_ke_mem_init('\x01',rwip_heap_em,0x10b6); + ble_rf_init((rwip_rf_api_conflict1 *)&rwip_rf); + ecc_init(0); + hci_init(); + rwble_init(); + ea_init(false); + rwip_env._8_4_ = 200; + rwip_env.sleep_acc_error = 0; + rwip_env._12_2_ = 0x101; + rwip_reset(); + return; +} + + + +void rwip_schedule(void) + +{ + if ((rwip_env.prevent_sleep & 1) == 0) { + ble_ke_event_schedule(); + return; + } + return; +} + + + +void rwip_wakeup_delay_set(uint16_t wakeup_delay) + +{ + undefined2 in_register_0000202a; + + rwip_env.lp_cycle_wakeup_delay = + (uint)(CONCAT22(in_register_0000202a,wakeup_delay) << 0xf) / 1000000; + return; +} + + +/* +Unable to decompile 'rwip_prevent_sleep_set' +Cause: Exception while decompiling 2302a21e: Decompiler process died + +*/ + + +void rwip_wakeup(void) + +{ + rwip_prevent_sleep_set(1); + lld_sleep_wakeup(); + return; +} + + +/* +Unable to decompile 'rwip_prevent_sleep_clear' +Cause: Exception while decompiling 2302a250: Decompiler process died + +*/ + + +void rwip_wakeup_end(void) + +{ + if ((rwip_env.prevent_sleep & 1) != 0) { + lld_sleep_wakeup_end(); + ble_ke_event_set('\x03'); + rwip_prevent_sleep_clear(1); + return; + } + return; +} + + + +uint32_t rwip_sleep_lpcycles_2_us(uint32_t lpcycles) + +{ + uint uVar1; + + uVar1 = rwip_env.sleep_acc_error + lpcycles * 0x109; + rwip_env.sleep_acc_error = uVar1 & 0x1ff; + return lpcycles * 0x1e + (uVar1 >> 9); +} + + + +uint32_t rwip_us_2_lpcycles(uint32_t us) + +{ + return (us << 0xf) / 1000000; +} + + + +void ble_co_list_init(co_list *list) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,list,_rom_patch_hook); + if (uVar1 == 0) { + list->first = (co_list_hdr *)0x0; + list->last = (co_list_hdr *)0x0; + } + return; +} + + + +void ble_co_list_push_back(int *param_1,undefined4 *param_2) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,param_2,_rom_patch_hook); + if (uVar1 == 0) { + if (*param_1 == 0) { + *(undefined4 **)param_1 = param_2; + } + else { + *(undefined4 **)param_1[1] = param_2; + } + *(undefined4 **)(param_1 + 1) = param_2; + *param_2 = 0; + } + return; +} + + + +void ble_co_list_push_front(co_list *list,co_list_hdr *list_hdr) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,list,list_hdr,_rom_patch_hook); + if (uVar1 == 0) { + if (list->first == (co_list_hdr *)0x0) { + list->last = list_hdr; + } + list_hdr->next = list->first; + list->first = list_hdr; + } + return; +} + + + +co_list_hdr * ble_co_list_pop_front(co_list *list) + +{ + uint32_t uVar1; + co_list_hdr *pcVar2; + co_list_hdr *pcStack20; + co_list_hdr *element; + + uVar1 = (*_rom_patch_hook)(&pcStack20,list,_rom_patch_hook); + if (((uVar1 == 0) && (pcStack20 = list->first, pcStack20 != (co_list_hdr *)0x0)) && + (pcVar2 = pcStack20->next, list->first = pcVar2, pcVar2 == (co_list_hdr *)0x0)) { + list->last = (co_list_hdr *)0x0; + } + return pcStack20; +} + + + +// WARNING: Variable defined which should be unmapped: found +// WARNING: Type propagation algorithm not settling + +_Bool ble_co_list_extract(co_list *list,co_list_hdr *list_hdr,uint8_t nb_following) + +{ + int iVar1; + uint32_t uVar2; + undefined3 in_register_00002031; + co_list_hdr cVar3; + co_list_hdr cVar4; + co_list_hdr cVar5; + char acStack17 [4]; + _Bool found; + + iVar1 = CONCAT31(in_register_00002031,nb_following); + acStack17[0] = '\0'; + uVar2 = (*_rom_patch_hook)(acStack17,list,list_hdr,iVar1,_rom_patch_hook); + if (uVar2 == 0) { + cVar4 = (co_list_hdr)0x0; + cVar5 = (co_list_hdr)list->first; + while (cVar5 != (co_list_hdr)0x0) { + if (cVar5 == (co_list_hdr)list_hdr) { + acStack17[0] = '\x01'; + goto LAB_2302a3f0; + } + cVar4 = cVar5; + cVar5 = *(co_list_hdr *)cVar5; + } + if (acStack17[0] != '\0') { +LAB_2302a3f0: + while (cVar3 = *(co_list_hdr *)cVar5, iVar1 != 0) { + iVar1 = iVar1 + -1; + cVar5 = cVar3; + } + if (cVar4 == (co_list_hdr)0x0) { + *(co_list_hdr *)&list->first = cVar3; + } + else { + *(co_list_hdr *)cVar4 = cVar3; + } + if ((co_list_hdr)((co_list_hdr *)&list->last)->next == cVar5) { + *(co_list_hdr *)&((co_list_hdr *)&list->last)->next = cVar4; + } + } + } + return (_Bool)acStack17[0]; +} + + + +void ble_co_list_extract_after(co_list *list,co_list_hdr *elt_ref_hdr,co_list_hdr *elt_to_rem_hdr) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,list,elt_ref_hdr,elt_to_rem_hdr,_rom_patch_hook); + if (uVar1 == 0) { + if (elt_ref_hdr == (co_list_hdr *)0x0) { + list->first = list->first->next; + } + else { + elt_ref_hdr->next = elt_to_rem_hdr->next; + } + if (list->last == elt_to_rem_hdr) { + list->last = elt_ref_hdr; + } + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +_Bool ble_co_list_find(co_list *list,co_list_hdr *list_hdr) + +{ + uint32_t uVar1; + co_list_hdr cVar2; + bool abStack17 [4]; + _Bool ret; + + uVar1 = (*_rom_patch_hook)(abStack17,list,list_hdr,_rom_patch_hook); + if (uVar1 == 0) { + cVar2 = (co_list_hdr)list->first; + while ((cVar2 != (co_list_hdr)list_hdr && (cVar2 != (co_list_hdr)0x0))) { + cVar2 = *(co_list_hdr *)cVar2; + } + abStack17[0] = (co_list_hdr)list_hdr == cVar2; + } + return (_Bool)abStack17[0]; +} + + + +void ble_co_list_merge(int *param_1,int *param_2) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,param_2,_rom_patch_hook); + if (uVar1 == 0) { + if (*param_1 == 0) { + *param_1 = *param_2; + } + else { + *(int *)param_1[1] = *param_2; + } + param_1[1] = param_2[1]; + *param_2 = 0; + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void ble_co_list_insert_after(co_list *list,co_list_hdr *elt_ref_hdr,co_list_hdr *elt_to_add_hdr) + +{ + uint32_t uVar1; + co_list_hdr cVar2; + + uVar1 = (*_rom_patch_hook)((void *)0x0,list,elt_ref_hdr,elt_to_add_hdr,_rom_patch_hook); + if (uVar1 == 0) { + if (elt_ref_hdr == (co_list_hdr *)0x0) { +LAB_2302a502: + ble_co_list_push_back(list,elt_to_add_hdr); + return; + } + cVar2 = (co_list_hdr)list->first; + while (cVar2 != (co_list_hdr)elt_ref_hdr) { + if (cVar2 == (co_list_hdr)0x0) goto LAB_2302a502; + cVar2 = *(co_list_hdr *)cVar2; + } + if (elt_ref_hdr->next == (co_list_hdr *)0x0) { + list->last = elt_to_add_hdr; + } + elt_to_add_hdr->next = elt_ref_hdr->next; + elt_ref_hdr->next = elt_to_add_hdr; + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +uint16_t ble_co_list_size(co_list *list) + +{ + uint32_t uVar1; + int *piVar2; + uint16_t auStack18 [2]; + uint16_t count; + + auStack18[0] = 0; + uVar1 = (*_rom_patch_hook)(auStack18,list,_rom_patch_hook); + if (uVar1 == 0) { + piVar2 = (int *)list->first; + while (piVar2 != (int *)0x0) { + auStack18[0] = auStack18[0] + 1; + piVar2 = (int *)*piVar2; + } + } + return auStack18[0]; +} + + + +void co_bdaddr_set(uint8_t *bdaddr) + +{ + // WARNING: Could not recover jumptable at 0x2302a58c. Too many branches + // WARNING: Treating indirect jump as call + (*ble_memcpy_ptr)(&co_default_bdaddr,bdaddr,6); + return; +} + + + +_Bool co_bdaddr_compare(bd_addr *bd_address1,bd_addr *bd_address2) + +{ + int iVar1; + + iVar1 = 0; + do { + if (bd_address1->addr[iVar1] != bd_address2->addr[iVar1]) { + return false; + } + iVar1 = iVar1 + 1; + } while (iVar1 != 6); + return true; +} + + + +void Mont2GF(uint8_t reg_idx) + +{ + sec_eng_pka0_pld(8,Inv_r,'\r','\x03','9',false); + sec_eng_pka0_clir('\x01','\x03','\x06','\0'); + sec_eng_pka0_clir('\x01','\x03','\a','\0'); + sec_eng_pka0_lmul('\0','\x04','\x03','\x03',reg_idx,'\x03','\r'); + sec_eng_pka0_mrem('\0','\x03',reg_idx,'\x04','\x03','\x03','\0'); + sec_eng_pka0_clir('\x01','\x04','\x03','\0'); + return; +} + + + +void getFinalPoint(uint8_t reg_idx) + +{ + sec_eng_pka0_clir('\x01','\x03','\x06','\0'); + sec_eng_pka0_clir('\x01','\x03','\a','\0'); + sec_eng_pka0_lmul('\0','\x04','\x03','\x03',reg_idx,'\x03','\x0e'); + sec_eng_pka0_mrem('\0','\x03',reg_idx,'\x04','\x03','\x03','\0'); + sec_eng_pka0_clir('\x01','\x04','\x03','\0'); + return; +} + + + +void pka_point_addition(uint8_t x1_idx,uint8_t x2_idx,uint8_t ret_idx) + +{ + uint8_t s0_reg_idx; + uint8_t s1_reg_idx; + uint8_t s1_reg_idx_00; + + s1_reg_idx = x1_idx + '\x02'; + s0_reg_idx = x1_idx + '\x01'; + sec_eng_pka0_mmul('\0','\x03','\r','\x03',x2_idx + '\x01','\x03',s1_reg_idx,'\x03',DAT_00000010); + s1_reg_idx_00 = x2_idx + '\x02'; + sec_eng_pka0_mmul('\0','\x03','\x0e','\x03',s0_reg_idx,'\x03',s1_reg_idx_00,'\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x0f','\x03',x2_idx,'\x03',s1_reg_idx,'\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x10','\x03',x1_idx,'\x03',s1_reg_idx_00,'\x03',DAT_00000010); + sec_eng_pka0_msub('\0','\x03','\r','\x03','\r','\x03','\x0e','\x03',DAT_00000010); + sec_eng_pka0_msub('\0','\x03','\x0f','\x03','\x0f','\x03','\x10','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',x1_idx,'\x03',s1_reg_idx,'\x03',s1_reg_idx_00,'\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',s0_reg_idx,'\x03','\x0f','\x03','\x0f','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',s1_reg_idx,'\x03',s0_reg_idx,'\x03','\x0f','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x11','\x03','\r','\x03','\r','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x11','\x03','\x11','\x03',x1_idx,'\x03',DAT_00000010); + sec_eng_pka0_msub('\0','\x03','\x11','\x03','\x11','\x03',s1_reg_idx,'\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x12','\x03','\t','\x03',s0_reg_idx,'\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x12','\x03','\x12','\x03','\x10','\x03',DAT_00000010); + sec_eng_pka0_msub('\0','\x03','\x12','\x03','\x11','\x03','\x12','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',s0_reg_idx,'\x03',s0_reg_idx,'\x03','\x10','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x0e','\x03',s1_reg_idx,'\x03','\x0e','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',ret_idx + '\x02','\x03',s1_reg_idx,'\x03',x1_idx,'\x03',DAT_00000010 + ); + sec_eng_pka0_mmul('\0','\x03',ret_idx,'\x03','\x0f','\x03','\x12','\x03',DAT_00000010); + sec_eng_pka0_msub('\0','\x03',s0_reg_idx,'\x03',s0_reg_idx,'\x03','\x12','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',s0_reg_idx,'\x03','\r','\x03',s0_reg_idx,'\x03',DAT_00000010); + sec_eng_pka0_msub('\x01','\x03',ret_idx + '\x01','\x03',s0_reg_idx,'\x03','\x0e','\x03', + DAT_00000010); + sec_eng_pka0_wait_4_isr(); + sec_eng_pka0_clear_int(); + return; +} + + + +void pka_read_result(ECC_Jacobian_Point256 *point,uint8_t idx) + +{ + sec_eng_pka0_read_data('\x03',idx,(uint32_t *)point,'\b'); + sec_eng_pka0_read_data('\x03',idx + '\x01',(uint32_t *)&point->y,'\b'); + sec_eng_pka0_read_data('\x03',idx + '\x02',(uint32_t *)&point->z,'\b'); + return; +} + + + +void pka_cp_x2_to_x1(uint8_t x1_idx,uint8_t x2_idx) + +{ + sec_eng_pka0_movdat('\0','\x03',x1_idx,'\x03',x2_idx); + sec_eng_pka0_movdat('\0','\x03',x1_idx + '\x01','\x03',x2_idx + '\x01'); + sec_eng_pka0_movdat('\0','\x03',x1_idx + '\x02','\x03',x2_idx + '\x02'); + return; +} + + + +void pka_point_inf_check(uint8_t x1_idx,uint8_t *p1_eq_inf) + +{ + byte bVar1; + byte bVar2; + uint uVar3; + byte abStack33 [4]; + uint8_t bitval; + + sec_eng_pka0_lcmp(abStack33,'\x03',x1_idx,'\x03','\b'); + bVar1 = abStack33[0]; + sec_eng_pka0_lcmp(abStack33,'\x03',x1_idx + '\x01','\x03','\x13'); + uVar3 = (uint)abStack33[0]; + sec_eng_pka0_lcmp(abStack33,'\x03','\x14','\x03',x1_idx + '\x01'); + bVar2 = abStack33[0]; + sec_eng_pka0_lcmp(abStack33,'\x03',x1_idx + '\x02','\x03','\b'); + *(bool *)p1_eq_inf = + (byte)(bVar2 << 2 | (byte)((uVar3 << 0x19) >> 0x18) | bVar1 | abStack33[0] << 3) == 0xf; + return; +} + + + +void GF2Mont(u_int32 *numA,u_int32 *result) + +{ + sec_eng_pka0_pld(8,(uint32_t *)&bigHexP256,'\0','\x03','9',false); + sec_eng_pka0_pld(8,numA,'\x01','\x03','9',false); + sec_eng_pka0_lmul2n('\0','\x04','\x01','\x03','\x01',0x100); + sec_eng_pka0_mrem('\0','\x03','\x04','\x04','\x01','\x03','\0'); + sec_eng_pka0_read_data('\x03','\x04',result,'\b'); + sec_eng_pka0_clir('\x01','\x04','\x01','\0'); + return; +} + + + +// WARNING: Variable defined which should be unmapped: pka_p1_eq_inf + +void pka_point_double(uint8_t x_idx) + +{ + uint8_t s0_reg_idx; + uint8_t s0_reg_idx_00; + uint8_t auStack17 [4]; + uint8_t pka_p1_eq_inf; + + pka_point_inf_check(x_idx,auStack17); + if (auStack17[0] == '\0') { + s0_reg_idx = x_idx + '\x02'; + sec_eng_pka0_mmul('\0','\x03','\r','\x03',x_idx,'\x03',x_idx,'\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x0e','\x03',s0_reg_idx,'\x03',s0_reg_idx,'\x03',DAT_00000010); + sec_eng_pka0_msub('\0','\x03','\r','\x03','\r','\x03','\x0e','\x03',DAT_00000010); + s0_reg_idx_00 = x_idx + '\x01'; + sec_eng_pka0_mmul('\0','\x03','\r','\x03','\n','\x03','\r','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x0e','\x03',s0_reg_idx_00,'\x03',s0_reg_idx,'\x03',DAT_00000010) + ; + sec_eng_pka0_mmul('\0','\x03','\x0f','\x03',x_idx,'\x03',s0_reg_idx_00,'\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',s0_reg_idx,'\x03','\r','\x03','\r','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x0f','\x03','\x0f','\x03','\x0e','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',x_idx,'\x03','\f','\x03','\x0f','\x03',DAT_00000010); + sec_eng_pka0_msub('\0','\x03',s0_reg_idx,'\x03',s0_reg_idx,'\x03',x_idx,'\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',x_idx,'\x03','\t','\x03',s0_reg_idx,'\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',x_idx,'\x03',x_idx,'\x03','\x0e','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x0f','\x03','\v','\x03','\x0f','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x10','\x03','\x0e','\x03','\x0e','\x03',DAT_00000010); + sec_eng_pka0_msub('\0','\x03','\x0f','\x03','\x0f','\x03',s0_reg_idx,'\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',s0_reg_idx_00,'\x03',s0_reg_idx_00,'\x03',s0_reg_idx_00,'\x03', + DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x0f','\x03','\x0f','\x03','\r','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',s0_reg_idx_00,'\x03','\f','\x03',s0_reg_idx_00,'\x03',DAT_00000010 + ); + sec_eng_pka0_mmul('\0','\x03',s0_reg_idx_00,'\x03',s0_reg_idx_00,'\x03','\x10','\x03', + DAT_00000010); + sec_eng_pka0_msub('\0','\x03',s0_reg_idx_00,'\x03','\x0f','\x03',s0_reg_idx_00,'\x03', + DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',s0_reg_idx,'\x03','\x0e','\x03','\x10','\x03',DAT_00000010); + sec_eng_pka0_mmul('\x01','\x03',s0_reg_idx,'\x03','\f','\x03',s0_reg_idx,'\x03',DAT_00000010); + sec_eng_pka0_wait_4_isr(); + sec_eng_pka0_clear_int(); + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: pka_p1_eq_inf + +void pka_addition_win(ECC_Jacobian_Point256 *src1,ECC_Jacobian_Point256 *src2, + ECC_Jacobian_Point256 *ret) + +{ + uint8_t x2_idx; + byte bStack18; + byte abStack17 [3]; + uint8_t pka_p1_eq_inf; + uint8_t pka_p2_eq_inf; + + sec_eng_pka0_pld(8,(uint32_t *)src1,'\x15','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)&src1->y,'\x16','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)&src1->z,'\x17','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)src2,'\x18','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)&src2->y,'\x19','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)&src2->z,'\x1a','\x03','9',false); + pka_point_inf_check('\x15',&bStack18); + pka_point_inf_check('\x18',abStack17); + if (bStack18 == 1) { + x2_idx = '\x18'; + if (abStack17[0] != 0) goto LAB_2302ad40; + } + else { + if ((bStack18 | abStack17[0]) == 0) { + pka_point_addition('\x15','\x18','\x1b'); + goto LAB_2302ad5c; + } +LAB_2302ad40: + x2_idx = '\x02'; + } + pka_cp_x2_to_x1('\x1b',x2_idx); +LAB_2302ad5c: + pka_read_result(ret,'\x1b'); + return; +} + + + +void ecc_multiplication_event_handler(uint8_t param_1) + +{ + bool bVar1; + byte bVar2; + ke_task_id_t dest_id; + co_list_hdr *mem_ptr; + co_list_hdr *pcVar3; + undefined *puVar4; + ECC_Jacobian_Point256 *src1; + uint uVar5; + co_list_hdr *pcVar6; + undefined *puVar7; + undefined *puVar8; + int iVar9; + undefined4 *puVar10; + byte bStack113; + byte bStack112; + undefined2 uStack110; + undefined4 uStack84; + undefined4 uStack80; + undefined4 uStack76; + undefined4 uStack72; + undefined4 uStack40; + undefined4 uStack36; + + ble_ke_event_clear('\0'); + mem_ptr = ble_co_list_pop_front((co_list *)&ecc_env); + if (mem_ptr == (co_list_hdr *)0x0) goto LAB_2302aee6; + if (mem_ptr[1].next == (co_list_hdr *)0x0) { + dest_id = *(ke_task_id_t *)((int)&mem_ptr[0x48].next + 2); + if (dest_id != 0xff) { + puVar4 = (undefined *)ble_ke_msg_alloc(*(ke_msg_id_t *)&mem_ptr[0x48].next,dest_id,0xff,0x40); + Mont2GF('\x02'); + Mont2GF('\x03'); + (*ble_memset_ptr)(&bStack112,0,0x20); + uStack84 = 2; + sec_eng_pka0_pld(8,&bStack112,'\r','\x03','9',false); + sec_eng_pka0_lsub('\0','\x03','\r','\x03','\0','\x03','\r'); + sec_eng_pka0_mexp('\x01','\x03','\x0e','\x03','\x04','\x03','\r','\x03',DAT_00000010); + sec_eng_pka0_wait_4_isr(); + sec_eng_pka0_clear_int(); + Mont2GF('\x0e'); + getFinalPoint('\x02'); + getFinalPoint('\x03'); + (*ble_memset_ptr)(&bStack112,0,0x20); + uStack80 = 0; + uStack76 = 0; + (*ble_memset_ptr)(&uStack72,0,0x20); + uStack40 = 0; + uStack36 = 0; + sec_eng_pka0_read_data('\x03','\x02',&bStack112,'\b'); + sec_eng_pka0_read_data('\x03','\x03',&uStack72,'\b'); + if (*(char *)&mem_ptr[0x4b].next == '\x02') { + ble_ke_free(mem_ptr[0x4c].next); + mem_ptr[0x4c].next = (co_list_hdr *)0x0; + } + ble_ke_free(mem_ptr); + puVar7 = puVar4 + 0x1c; + puVar10 = &bStack112; + do { + puVar7[3] = *(undefined *)((int)puVar10 + 3); + puVar7[2] = (char)*(undefined2 *)((int)puVar10 + 2); + puVar7[1] = (char)((uint)*puVar10 >> 8); + *puVar7 = (char)*puVar10; + bVar1 = puVar4 != puVar7; + puVar7 = puVar7 + -4; + puVar10 = puVar10 + 1; + } while (bVar1); + puVar7 = puVar4 + 0x3c; + puVar10 = &uStack72; + do { + puVar8 = puVar7 + -4; + puVar7[3] = *(undefined *)((int)puVar10 + 3); + puVar7[2] = (char)*(undefined2 *)((int)puVar10 + 2); + puVar7[1] = (char)((uint)*puVar10 >> 8); + *puVar7 = (char)*puVar10; + puVar7 = puVar8; + puVar10 = puVar10 + 1; + } while (puVar8 != puVar4 + 0x1c); + ble_ke_msg_send(puVar4); + } + goto LAB_2302aee6; + } + bVar2 = *(byte *)&mem_ptr[0x4b].next; + pcVar6 = mem_ptr[0x4a].next; + if (((int)&((co_list_hdr *)(uint)bVar2)[-1].next + 3U & 0xff) < 2) { + if (bVar2 == 1) { + src1 = ECC_4Win_Look_up_table; + } + else { + src1 = (ECC_Jacobian_Point256 *)mem_ptr[0x4c].next; + } + uVar5 = (uint)pcVar6 & 0x1f; + iVar9 = ((((uint)mem_ptr[(0x3fU - (int)pcVar6 >> 5) + 0x3e].next >> uVar5 & 1) * 2 + + ((uint)mem_ptr[(0x7fU - (int)pcVar6 >> 5) + 0x3e].next >> uVar5 & 1)) * 2 + + ((uint)mem_ptr[(0xbfU - (int)pcVar6 >> 5) + 0x3e].next >> uVar5 & 1)) * 2 + + ((uint)mem_ptr[(0xffU - (int)pcVar6 >> 5) + 0x3e].next >> uVar5 & 1); + if (iVar9 != 0) { + src1 = src1 + iVar9 + -1; + sec_eng_pka0_pld(8,(uint32_t *)src1,'\x15','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)&src1->y,'\x16','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)&src1->z,'\x17','\x03','9',false); + pka_point_inf_check('\x02',&bStack113); + pka_point_inf_check('\x15',(uint8_t *)&bStack112); + if (bStack113 == 1) { + if (bStack112 == 0) { + pka_cp_x2_to_x1('\x02','\x15'); + } + } + else { + if ((bStack113 | bStack112) == 0) { + pka_point_addition('\x02','\x15','\x02'); + } + } + } + if (mem_ptr[0x4a].next == (co_list_hdr *)0x0) { + mem_ptr[1].next = (co_list_hdr *)0x0; + } + else { + pka_point_double('\x02'); + pcVar6 = (co_list_hdr *)((int)&mem_ptr[0x4a].next[-1].next + 3); +LAB_2302aeb4: + mem_ptr[0x4a].next = pcVar6; + } + } + else { + if (bVar2 == 3) { + pka_point_double('\x05'); + pcVar6 = (co_list_hdr *)((int)&(mem_ptr[0x4a].next)->next + 1); + mem_ptr[0x4a].next = pcVar6; + if (pcVar6 == (co_list_hdr *)0x40) { + src1 = (ECC_Jacobian_Point256 *)(mem_ptr[0x4c].next + 0x1e); + } + else { + if (pcVar6 != (co_list_hdr *)0x80) { + if (pcVar6 == (co_list_hdr *)0xc0) { + pka_read_result((ECC_Jacobian_Point256 *)(mem_ptr[0x4c].next + 0xd2),'\x05'); + *(undefined *)&mem_ptr[0x4b].next = 4; + mem_ptr[0x4a].next = (co_list_hdr *)(uint)bVar2; + } + goto LAB_2302aedc; + } + src1 = (ECC_Jacobian_Point256 *)(mem_ptr[0x4c].next + 0x5a); + } + pka_read_result(src1,'\x05'); + } + else { + if (bVar2 == 4) { + if (pcVar6 == (co_list_hdr *)0x3) { + src1 = (ECC_Jacobian_Point256 *)mem_ptr[0x4c].next; + pka_addition_win(src1,src1 + 1,src1 + 2); + pcVar6 = (co_list_hdr *)0x5; + } + else { + if (pcVar6 == (co_list_hdr *)0x5) { + src1 = (ECC_Jacobian_Point256 *)mem_ptr[0x4c].next; + pka_addition_win(src1,src1 + 3,src1 + 4); + pcVar6 = (co_list_hdr *)0x6; + } + else { + if (pcVar6 == (co_list_hdr *)0x6) { + pcVar6 = mem_ptr[0x4c].next; + pka_addition_win((ECC_Jacobian_Point256 *)(pcVar6 + 0x1e), + (ECC_Jacobian_Point256 *)(pcVar6 + 0x5a), + (ECC_Jacobian_Point256 *)(pcVar6 + 0x96)); + pcVar6 = (co_list_hdr *)0x7; + } + else { + if (pcVar6 == (co_list_hdr *)0x7) { + src1 = (ECC_Jacobian_Point256 *)mem_ptr[0x4c].next; + pka_addition_win(src1,src1 + 5,src1 + 6); + pcVar6 = (co_list_hdr *)0x9; + } + else { + if (6 < (int)&pcVar6[-3].next + 3U) goto LAB_2302aedc; + pcVar3 = mem_ptr[0x4c].next; + pka_addition_win((ECC_Jacobian_Point256 *)(pcVar3 + 0xd2), + (ECC_Jacobian_Point256 *)(pcVar3 + (int)pcVar6 * 0x1e + -0x10e), + (ECC_Jacobian_Point256 *)(pcVar3 + (int)pcVar6 * 0x1e + -0x1e)); + if (mem_ptr[0x4a].next == (co_list_hdr *)0xf) { + *(undefined *)&mem_ptr[0x4b].next = 2; + pcVar6 = (co_list_hdr *)0x3f; + } + else { + pcVar6 = (co_list_hdr *)((int)&(mem_ptr[0x4a].next)->next + 1); + } + } + } + } + } + goto LAB_2302aeb4; + } + } + } +LAB_2302aedc: + ble_co_list_push_back(&ecc_env,mem_ptr); +LAB_2302aee6: + if (ecc_env.ongoing_mul.first != (co_list_hdr *)0x0) { + ble_ke_event_set('\0'); + } + return; +} + + + +void ecc_init(int param_1) + +{ + co_list_hdr *mem_ptr; + + if (param_1 != 0) { + while (ecc_env.ongoing_mul.first != (co_list_hdr *)0x0) { + mem_ptr = ble_co_list_pop_front((co_list *)&ecc_env); + ble_ke_free(mem_ptr); + } + } + ble_co_list_init((co_list *)&ecc_env); + ble_ke_event_callback_set('\0',ecc_multiplication_event_handler); + return; +} + + + +// WARNING: Variable defined which should be unmapped: PointP_Jacobian + +uint8_t ecc_generate_key256(u_int8 key_type,u_int8 *secret_key,u_int8 *public_key_x, + u_int8 *public_key_y,ke_msg_id_t msg_id,ke_task_id_t task_id) + +{ + bool bVar1; + u_int32 *numA; + void *pvVar2; + ECC_Jacobian_Point256 *point; + byte *pbVar3; + byte *pbVar4; + byte *pbVar5; + int iVar6; + u_int32 *numA_00; + int *piVar7; + int local_148; + bigHex256 PrivateKey256; + bigHex256 BigHex_1; + ECC_Point256 PublicKey256; + ECC_Jacobian_Point256 PointP_Jacobian; + + sec_eng_pka0_reset(); + numA_00 = &BigHex_1.sign; + local_148 = 0; + BigHex_1.sign = 0; + PublicKey256.x.sign = 0; + numA = numA_00; + pbVar3 = public_key_x + 0x1c; + pbVar4 = public_key_y + 0x1c; + pbVar5 = secret_key + 0x1c; + piVar7 = &local_148; + do { + *piVar7 = (uint)pbVar5[3] * 0x1000000 + (uint)pbVar5[2] * 0x10000 + (uint)*pbVar5 + + (uint)pbVar5[1] * 0x100; + *numA = (uint)pbVar3[3] * 0x1000000 + (uint)pbVar3[2] * 0x10000 + (uint)*pbVar3 + + (uint)pbVar3[1] * 0x100; + numA[10] = (uint)pbVar4[3] * 0x1000000 + (uint)pbVar4[2] * 0x10000 + (uint)*pbVar4 + + (uint)pbVar4[1] * 0x100; + bVar1 = secret_key != pbVar5; + numA = numA + 1; + pbVar3 = pbVar3 + -4; + pbVar4 = pbVar4 + -4; + pbVar5 = pbVar5 + -4; + piVar7 = piVar7 + 1; + } while (bVar1); + iVar6 = 0; + piVar7 = &local_148; + do { + if (*piVar7 != 0) break; + iVar6 = iVar6 + 1; + piVar7 = piVar7 + 1; + } while (iVar6 != 8); + PrivateKey256.num[7] = 8 - iVar6; + iVar6 = 0; + numA = numA_00; + do { + if (*numA != 0) break; + iVar6 = iVar6 + 1; + numA = numA + 1; + } while (iVar6 != 8); + PublicKey256.x.num[7] = 8 - iVar6; + iVar6 = 0; + numA = numA_00; + do { + if (numA[10] != 0) break; + iVar6 = iVar6 + 1; + numA = numA + 1; + } while (iVar6 != 8); + PublicKey256.y.num[7] = 8 - iVar6; + PublicKey256.x.len = 0; + PublicKey256.y.len = 0; + pvVar2 = ble_ke_malloc(0x134,'\0'); + *(u_int8 *)((int)pvVar2 + 300) = key_type; + *(ke_msg_id_t *)((int)pvVar2 + 0x120) = msg_id; + *(ke_task_id_t *)((int)pvVar2 + 0x122) = task_id; + GF2Mont(numA_00,numA_00); + numA = &PublicKey256.x.sign; + GF2Mont(numA,numA); + BigHex_1.num[7] = 1; + BigHex_1.len = 0; + (*ble_memset_ptr)(&PrivateKey256.sign,0,0x20); + (*ble_memcpy_ptr)(&PrivateKey256.sign,Bar_1,0x20); + (*ble_memcpy_ptr)(&PublicKey256.y.sign,numA_00,0x20); + PointP_Jacobian.x.num[7] = PublicKey256.x.num[7]; + PointP_Jacobian.x.len = PublicKey256.x.len; + (*ble_memcpy_ptr)(&PointP_Jacobian.x.sign,&PublicKey256.x.sign,0x20); + PointP_Jacobian.y.num[7] = PublicKey256.y.num[7]; + PointP_Jacobian.y.len = PublicKey256.y.len; + (*ble_memcpy_ptr)(&PointP_Jacobian.y.sign,&PrivateKey256.sign,0x20); + PointP_Jacobian.z.num[7] = BigHex_1.num[7]; + PointP_Jacobian.z.len = BigHex_1.len; + (*ble_memcpy_ptr)((uint32_t *)((int)pvVar2 + 0x80),&PublicKey256.y.sign,0x20); + *(u_int32 *)((int)pvVar2 + 0xa0) = PointP_Jacobian.x.num[7]; + *(u_int32 *)((int)pvVar2 + 0xa4) = PointP_Jacobian.x.len; + (*ble_memcpy_ptr)((uint32_t *)((int)pvVar2 + 0xa8),&PointP_Jacobian.x.sign,0x20); + *(u_int32 *)((int)pvVar2 + 200) = PointP_Jacobian.y.num[7]; + *(u_int32 *)((int)pvVar2 + 0xcc) = PointP_Jacobian.y.len; + (*ble_memcpy_ptr)((uint32_t *)((int)pvVar2 + 0xd0),&PointP_Jacobian.y.sign,0x20); + *(u_int32 *)((int)pvVar2 + 0xf0) = PointP_Jacobian.z.num[7]; + *(u_int32 *)((int)pvVar2 + 0xf4) = PointP_Jacobian.z.len; + (*ble_memcpy_ptr)((void *)((int)pvVar2 + 0xf8),&local_148,0x20); + *(u_int32 *)((int)pvVar2 + 0x118) = PrivateKey256.num[7]; + *(u_int32 *)((int)pvVar2 + 0x11c) = PrivateKey256.len; + BigHex_1.num[7] = 1; + BigHex_1.len = 0; + (*ble_memset_ptr)(&PrivateKey256.sign,0,0x20); + BigHex_1.num[6] = 0; + (*ble_memcpy_ptr)((uint32_t *)((int)pvVar2 + 8),&PrivateKey256.sign,0x20); + *(u_int32 *)((int)pvVar2 + 0x28) = BigHex_1.num[7]; + *(u_int32 *)((int)pvVar2 + 0x2c) = BigHex_1.len; + (*ble_memcpy_ptr)(&PrivateKey256.sign,Bar_1,0x20); + (*ble_memcpy_ptr)((uint32_t *)((int)pvVar2 + 0x30),&PrivateKey256.sign,0x20); + *(u_int32 *)((int)pvVar2 + 0x50) = BigHex_1.num[7]; + *(u_int32 *)((int)pvVar2 + 0x54) = BigHex_1.len; + (*ble_memset_ptr)(&PrivateKey256.sign,0,0x20); + BigHex_1.num[6] = 0; + (*ble_memcpy_ptr)((uint32_t *)((int)pvVar2 + 0x58),&PrivateKey256.sign,0x20); + *(u_int32 *)((int)pvVar2 + 0x78) = BigHex_1.num[7]; + *(u_int32 *)((int)pvVar2 + 0x7c) = BigHex_1.len; + (*ble_memset_ptr)(&PrivateKey256.sign,0,0x20); + BigHex_1.num[6] = 1; + sec_eng_pka0_pld(8,(uint32_t *)&bigHexP256,'\0','\x03','9',false); + sec_eng_pka0_pld(8,Nprime,'\x01','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)((int)pvVar2 + 8),'\x02','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)((int)pvVar2 + 0x30),'\x03','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)((int)pvVar2 + 0x58),'\x04','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)((int)pvVar2 + 0x80),'\x05','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)((int)pvVar2 + 0xa8),'\x06','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)((int)pvVar2 + 0xd0),'\a','\x03','9',false); + sec_eng_pka0_pld(8,&PrivateKey256.sign,'\b','\x03','9',false); + sec_eng_pka0_pld(8,Bar_2,'\t','\x03','9',false); + sec_eng_pka0_pld(8,Bar_3,'\n','\x03','9',false); + sec_eng_pka0_pld(8,Bar_4,'\v','\x03','9',false); + sec_eng_pka0_pld(8,Bar_8,'\f','\x03','9',false); + sec_eng_pka0_pld(8,Bar_1p1,'\x13','\x03','9',false); + sec_eng_pka0_pld(8,Bar_1m1,'\x14','\x03','9',false); + *(undefined4 *)((int)pvVar2 + 0x128) = 0x3f; + *(undefined4 *)((int)pvVar2 + 0x124) = 0; + *(undefined4 *)((int)pvVar2 + 4) = 8; + if (*(char *)((int)pvVar2 + 300) == '\x02') { + point = (ECC_Jacobian_Point256 *)ble_ke_malloc(0x708,'\0'); + *(ECC_Jacobian_Point256 **)((int)pvVar2 + 0x130) = point; + pka_read_result(point,'\x05'); + *(undefined *)((int)pvVar2 + 300) = 3; + *(undefined4 *)((int)pvVar2 + 0x128) = 0; + } + ble_co_list_push_back(&ecc_env,pvVar2); + ble_ke_event_set('\0'); + return '\0'; +} + + + +void ecc_gen_new_public_key(u_int8 *secret_key,ke_msg_id_t msg_id,ke_task_id_t task_id) + +{ + ecc_generate_key256('\x01',secret_key,BasePoint_x_256,BasePoint_y_256,msg_id,task_id); + return; +} + + + +void ecc_gen_new_secret_key(uint8_t *secret_key256,_Bool forced) + +{ + int iVar1; + undefined3 in_register_0000202d; + + if (CONCAT31(in_register_0000202d,forced) != 0) { + return; + } + do { + iVar1 = bl_rand(); + *secret_key256 = (uint8_t)iVar1; + secret_key256[1] = (uint8_t)((uint)iVar1 >> 8); + secret_key256[2] = (uint8_t)((uint)iVar1 >> 0x10); + secret_key256[3] = (uint8_t)((uint)iVar1 >> 0x18); + iVar1 = bl_rand(); + secret_key256[4] = (uint8_t)iVar1; + secret_key256[5] = (uint8_t)((uint)iVar1 >> 8); + secret_key256[6] = (uint8_t)((uint)iVar1 >> 0x10); + secret_key256[7] = (uint8_t)((uint)iVar1 >> 0x18); + iVar1 = bl_rand(); + secret_key256[8] = (uint8_t)iVar1; + secret_key256[9] = (uint8_t)((uint)iVar1 >> 8); + secret_key256[10] = (uint8_t)((uint)iVar1 >> 0x10); + secret_key256[0xb] = (uint8_t)((uint)iVar1 >> 0x18); + iVar1 = bl_rand(); + secret_key256[0xc] = (uint8_t)iVar1; + secret_key256[0xd] = (uint8_t)((uint)iVar1 >> 8); + secret_key256[0xe] = (uint8_t)((uint)iVar1 >> 0x10); + secret_key256[0xf] = (uint8_t)((uint)iVar1 >> 0x18); + iVar1 = bl_rand(); + secret_key256[0x10] = (uint8_t)iVar1; + secret_key256[0x11] = (uint8_t)((uint)iVar1 >> 8); + secret_key256[0x12] = (uint8_t)((uint)iVar1 >> 0x10); + secret_key256[0x13] = (uint8_t)((uint)iVar1 >> 0x18); + iVar1 = bl_rand(); + secret_key256[0x14] = (uint8_t)iVar1; + secret_key256[0x15] = (uint8_t)((uint)iVar1 >> 8); + secret_key256[0x16] = (uint8_t)((uint)iVar1 >> 0x10); + secret_key256[0x17] = (uint8_t)((uint)iVar1 >> 0x18); + iVar1 = bl_rand(); + secret_key256[0x18] = (uint8_t)iVar1; + secret_key256[0x19] = (uint8_t)((uint)iVar1 >> 8); + secret_key256[0x1a] = (uint8_t)((uint)iVar1 >> 0x10); + secret_key256[0x1b] = (uint8_t)((uint)iVar1 >> 0x18); + iVar1 = bl_rand(); + secret_key256[0x1c] = (uint8_t)iVar1; + secret_key256[0x1d] = (uint8_t)((uint)iVar1 >> 8); + secret_key256[0x1e] = (uint8_t)((uint)iVar1 >> 0x10); + secret_key256[0x1f] = (uint8_t)((uint)iVar1 >> 0x18); + iVar1 = 0x1f; + do { + if (secret_key256[iVar1] != '\0') goto LAB_2302b788; + iVar1 = iVar1 + -1; + } while (iVar1 != -1); + if (*secret_key256 != '\0') { +LAB_2302b788: + iVar1 = 0x1f; + while( true ) { + if (maxSecretKey_256[iVar1] < secret_key256[iVar1]) break; + if ((secret_key256[iVar1] < maxSecretKey_256[iVar1]) || (iVar1 = iVar1 + -1, iVar1 == -1)) { + return; + } + } + } + } while( true ); +} + + + +void ble_ke_event_init(void) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,_rom_patch_hook); + if (uVar1 == 0) { + // WARNING: Could not recover jumptable at 0x2302b7e2. Too many branches + // WARNING: Treating indirect jump as call + (*ble_memset_ptr)(&ble_ke_event_env,0,0x30); + return; + } + return; +} + + + +uint8_t ble_ke_event_callback_set(uint8_t event_type,intCallback_Type *p_callback) + +{ + undefined3 in_register_00002029; + uint uVar1; + uint32_t uVar2; + uint8_t auStack17 [4]; + uint8_t status; + + uVar1 = CONCAT31(in_register_00002029,event_type); + uVar2 = (*_rom_patch_hook)(auStack17,uVar1,p_callback,_rom_patch_hook); + if ((uVar2 == 0) && (auStack17[0] = '\x03', uVar1 < 10)) { + *(intCallback_Type **)(ble_ke_event_env.callback + uVar1) = p_callback; + auStack17[0] = '\0'; + } + return auStack17[0]; +} + + +/* +Unable to decompile 'ble_ke_event_set' +Cause: +Low-level Error: Assignment to constant at r0x2302b872 +*/ + +/* +Unable to decompile 'ble_ke_event_clear' +Cause: Exception while decompiling 2302b894: Decompiler process died + +*/ + + +void ble_ke_event_flush(void) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,_rom_patch_hook); + if (uVar1 == 0) { + ble_ke_event_env.event_field = 0; + } + return; +} + + + +void ble_ke_event_schedule(void) + +{ + uint32_t uVar1; + uint uVar2; + + uVar1 = (*_rom_patch_hook)((void *)0x0,_rom_patch_hook); + if (uVar1 == 0) { + while (ble_ke_event_env.event_field != 0) { + ble_ke_event_env.state = '\x01'; + uVar2 = 0; + do { + if ((0x80000000U >> (uVar2 & 0x1f) & ble_ke_event_env.event_field) != 0) break; + uVar2 = uVar2 + 1; + } while (uVar2 != 0x20); + if (ble_ke_event_env.callback[0x1f - uVar2 & 0xff] != (p_callback_t)0x0) { + (*ble_ke_event_env.callback[0x1f - uVar2 & 0xff])(); + } + } + ble_ke_event_env.state = '\0'; + } + return; +} + + + +_Bool ble_ke_mem_is_in_heap(uint8_t type,void *mem_ptr) + +{ + undefined3 in_register_00002029; + int iVar1; + uint32_t uVar2; + co_list_hdr *pcVar3; + undefined auStack17 [4]; + _Bool ret; + + iVar1 = CONCAT31(in_register_00002029,type); + uVar2 = (*_rom_patch_hook)(auStack17,iVar1,mem_ptr,_rom_patch_hook); + if (uVar2 == 0) { + pcVar3 = (&ble_ke_env.queue_saved.first)[iVar1 + 4]; + auStack17[0] = 0; + if ((pcVar3 <= mem_ptr) && + (mem_ptr <= + (void *)((int)&pcVar3->next + + (uint)*(ushort *)((int)&ble_ke_env.queue_sent.first + (iVar1 + 0x10) * 2)))) { + auStack17[0] = 1; + } + } + return (_Bool)auStack17[0]; +} + + +/* +Unable to decompile 'ble_ke_mem_init' +Cause: Exception while decompiling 2302b9da: Decompiler process died + +*/ + +/* +Unable to decompile 'ble_ke_malloc' +Cause: Exception while decompiling 2302ba5a: Decompiler process died + +*/ + +/* +Unable to decompile 'ble_ke_free' +Cause: Exception while decompiling 2302bb4a: Decompiler process died + +*/ + + +_Bool ble_ke_is_free(void *mem_ptr) + +{ + uint32_t uVar1; + bool abStack17 [4]; + _Bool ret; + + uVar1 = (*_rom_patch_hook)(abStack17,mem_ptr,_rom_patch_hook); + if (uVar1 == 0) { + abStack17[0] = *(short *)((int)mem_ptr + -4) != -0x7cc8; + } + return (_Bool)abStack17[0]; +} + + + +void * ble_ke_msg_alloc(ke_msg_id_t id,ke_task_id_t dest_id,ke_task_id_t src_id,uint16_t param_len) + +{ + anon_subr_void_ptr_void_ptr_int_uint *paVar1; + undefined2 in_register_0000202a; + uint32_t uVar2; + undefined2 in_register_0000202e; + undefined2 in_register_00002032; + undefined2 in_register_00002036; + uint uVar3; + undefined4 *puStack36; + void *param_ptr; + + uVar3 = CONCAT22(in_register_00002036,param_len); + puStack36 = (undefined4 *)0x0; + uVar2 = (*_rom_patch_hook)(&puStack36,CONCAT22(in_register_0000202a,id), + CONCAT22(in_register_0000202e,dest_id), + CONCAT22(in_register_00002032,src_id),uVar3,_rom_patch_hook); + if (uVar2 == 0) { + puStack36 = (undefined4 *)ble_ke_malloc(uVar3 + 0xc,'\0'); + *puStack36 = 0xffffffff; + paVar1 = ble_memset_ptr; + *(ke_msg_id_t *)(puStack36 + 1) = id; + *(ke_task_id_t *)((int)puStack36 + 6) = dest_id; + *(ke_task_id_t *)(puStack36 + 2) = src_id; + *(uint16_t *)((int)puStack36 + 10) = param_len; + puStack36 = puStack36 + 3; + (*paVar1)(puStack36,0,uVar3); + } + return puStack36; +} + + +/* +Unable to decompile 'ble_ke_msg_send' +Cause: Exception while decompiling 2302bcfa: Decompiler process died + +*/ + +/* +Unable to decompile 'ble_ke_msg_get_sent_num' +Cause: Exception while decompiling 2302bd48: Decompiler process died + +*/ + + +void ble_ke_msg_send_basic(ke_msg_id_t id,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined2 in_register_0000202a; + uint32_t uVar1; + undefined2 in_register_0000202e; + undefined2 in_register_00002032; + + uVar1 = (*_rom_patch_hook)((void *)0x0,CONCAT22(in_register_0000202a,id), + CONCAT22(in_register_0000202e,dest_id), + CONCAT22(in_register_00002032,src_id),_rom_patch_hook); + if (uVar1 == 0) { + ble_ke_msg_alloc(id,dest_id,src_id,0); + ble_ke_msg_send(); + return; + } + return; +} + + + +void ble_ke_msg_free(ke_msg *msg) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,msg,_rom_patch_hook); + if (uVar1 == 0) { + ble_ke_free(msg); + return; + } + return; +} + + + +_Bool ble_cmp_abs_time(co_list_hdr *timerA,co_list_hdr *timerB) + +{ + uint32_t uVar1; + byte abStack17 [4]; + _Bool result; + + uVar1 = (*_rom_patch_hook)(abStack17,timerA,timerB,_rom_patch_hook); + if (uVar1 == 0) { + abStack17[0] = (byte)((uint)((int)timerA[2].next - (int)timerB[2].next) >> 0x16) & 1; + } + return (_Bool)abStack17[0]; +} + + + +_Bool ble_cmp_timer_id(co_list_hdr *timer,uint32_t timer_task) + +{ + uint32_t uVar1; + bool abStack17 [4]; + _Bool result; + + uVar1 = (*_rom_patch_hook)(abStack17,timer,timer_task,_rom_patch_hook); + if ((uVar1 == 0) && (abStack17[0] = false, (uint)*(ushort *)&timer[1].next == timer_task >> 0x10)) + { + abStack17[0] = (uint)*(ushort *)((int)&timer[1].next + 2) == (timer_task & 0xffff); + } + return (_Bool)abStack17[0]; +} + + + +// WARNING: Removing unreachable block (ram,0x2302beaa) +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t ble_ke_time(void) + +{ + uint32_t uVar1; + uint32_t uStack20; + uint32_t time; + + uVar1 = (*_rom_patch_hook)(&uStack20,_rom_patch_hook); + if (uVar1 == 0) { + do { + } while( true ); + } + return uStack20; +} + + + +_Bool ble_ke_time_cmp(uint32_t newer,uint32_t older) + +{ + uint32_t uVar1; + byte abStack17 [4]; + _Bool result; + + uVar1 = (*_rom_patch_hook)(abStack17,newer,older,_rom_patch_hook); + if (uVar1 == 0) { + abStack17[0] = ((byte)(newer - older >> 0x16) ^ 1) & 1; + } + return (_Bool)abStack17[0]; +} + + + +_Bool ble_ke_time_past(uint32_t time) + +{ + uint32_t newer; + _Bool a_Stack17 [4]; + _Bool result; + + newer = (*_rom_patch_hook)(a_Stack17,time,_rom_patch_hook); + if (newer == 0) { + newer = ble_ke_time(); + a_Stack17[0] = ble_ke_time_cmp(newer,time); + } + return a_Stack17[0]; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ble_ke_timer_hw_set(ke_timer *timer) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,timer,_rom_patch_hook); + if (uVar1 == 0) { + if (timer == (ke_timer *)0x0) { + _DAT_2800000c = _DAT_2800000c & 0xffffffbf; + } + else { + _DAT_280000f4 = timer->time; + if ((_DAT_2800000c >> 6 & 1) == 0) { + _DAT_28000018 = 0x40; + _DAT_2800000c = _DAT_2800000c | 0x40; + } + } + } + return; +} + + + +void ble_ke_timer_schedule(void) + +{ + _Bool _Var1; + uint32_t uVar2; + undefined3 extraout_var; + co_list_hdr *mem_ptr; + undefined3 extraout_var_00; + + uVar2 = (*_rom_patch_hook)((void *)0x0,_rom_patch_hook); + if (uVar2 != 0) { + return; + } + do { + ble_ke_event_clear('\x03'); + mem_ptr = ble_ke_env.queue_timer.first; + if (ble_ke_env.queue_timer.first == (co_list_hdr *)0x0) { + ble_ke_timer_hw_set((ke_timer *)0x0); + return; + } + _Var1 = ble_ke_time_past((int)&ble_ke_env.queue_timer.first[2].next[-1].next + 3); + if (CONCAT31(extraout_var,_Var1) == 0) { + ble_ke_timer_hw_set((ke_timer *)mem_ptr); + _Var1 = ble_ke_time_past((uint32_t)mem_ptr[2].next); + if (CONCAT31(extraout_var_00,_Var1) == 0) { + return; + } + } + mem_ptr = ble_co_list_pop_front(&ble_ke_env.queue_timer); + ble_ke_msg_send_basic + (*(ke_msg_id_t *)&mem_ptr[1].next,*(ke_task_id_t *)((int)&mem_ptr[1].next + 2),0xff); + ble_ke_free(mem_ptr); + } while( true ); +} + + + +void ble_ke_timer_init(void) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,_rom_patch_hook); + if (uVar1 == 0) { + ble_ke_event_callback_set('\x03',ble_ke_timer_schedule); + return; + } + return; +} + + + +void ble_ke_timer_set(ke_msg_id_t timer_id,ke_task_id_t task_id,uint32_t delay) + +{ + bool bVar1; + _Bool _Var2; + undefined2 in_register_0000202a; + uint uVar3; + uint32_t uVar4; + co_list_hdr *element; + undefined3 extraout_var; + undefined2 in_register_0000202e; + uint uVar5; + + uVar5 = CONCAT22(in_register_0000202e,task_id); + uVar3 = CONCAT22(in_register_0000202a,timer_id); + uVar4 = (*_rom_patch_hook)((void *)0x0,uVar3,uVar5,delay,_rom_patch_hook); + if (uVar4 == 0) { + if (delay < 0x400000) { + if (delay == 0) { + delay = 1; + } + } + else { + delay = 0x3fffff; + } + bVar1 = false; + if ((ble_ke_env.queue_timer.first != (co_list_hdr *)0x0) && + ((uint)*(ushort *)&ble_ke_env.queue_timer.first[1].next == uVar3)) { + bVar1 = (uint)*(ushort *)((int)&ble_ke_env.queue_timer.first[1].next + 2) == uVar5; + } + element = ble_ke_queue_extract(&ble_ke_env.queue_timer,ble_cmp_timer_id,uVar3 << 0x10 | uVar5); + if (element == (co_list_hdr *)0x0) { + element = (co_list_hdr *)ble_ke_malloc(0xc,'\0'); + *(ke_msg_id_t *)&element[1].next = timer_id; + *(ke_task_id_t *)((int)&element[1].next + 2) = task_id; + } + uVar4 = ble_ke_time(); + element[2].next = (co_list_hdr *)(delay + uVar4 & 0x7fffff); + ble_ke_queue_insert(&ble_ke_env.queue_timer,element,ble_cmp_abs_time); + if ((bVar1) || (ble_ke_env.queue_timer.first == element)) { + ble_ke_timer_hw_set((ke_timer *)ble_ke_env.queue_timer.first); + } + _Var2 = ble_ke_time_past(delay + uVar4); + if (CONCAT31(extraout_var,_Var2) != 0) { + ble_ke_event_set('\x03'); + return; + } + } + return; +} + + + +void ble_ke_timer_clear(ke_msg_id_t timer_id,ke_task_id_t task_id) + +{ + co_list_hdr *pcVar1; + _Bool _Var2; + undefined2 in_register_0000202a; + uint uVar3; + uint32_t uVar4; + undefined3 extraout_var; + co_list_hdr *mem_ptr; + undefined2 in_register_0000202e; + uint uVar5; + + uVar5 = CONCAT22(in_register_0000202e,task_id); + uVar3 = CONCAT22(in_register_0000202a,timer_id); + uVar4 = (*_rom_patch_hook)((void *)0x0,uVar3,uVar5,_rom_patch_hook); + mem_ptr = ble_ke_env.queue_timer.first; + if ((uVar4 == 0) && (ble_ke_env.queue_timer.first != (co_list_hdr *)0x0)) { + if (((uint)*(ushort *)&ble_ke_env.queue_timer.first[1].next == uVar3) && + ((uint)*(ushort *)((int)&ble_ke_env.queue_timer.first[1].next + 2) == uVar5)) { + ble_co_list_pop_front(&ble_ke_env.queue_timer); + pcVar1 = ble_ke_env.queue_timer.first; + ble_ke_timer_hw_set((ke_timer *)ble_ke_env.queue_timer.first); + if ((pcVar1 != (co_list_hdr *)0x0) && + (_Var2 = ble_ke_time_past((uint32_t)pcVar1[2].next), CONCAT31(extraout_var,_Var2) != 0)) { + ble_ke_event_set('\x03'); + } + } + else { + mem_ptr = ble_ke_queue_extract(&ble_ke_env.queue_timer,ble_cmp_timer_id,uVar3 << 0x10 | uVar5) + ; + if (mem_ptr == (co_list_hdr *)0x0) { + return; + } + } + ble_ke_free(mem_ptr); + return; + } + return; +} + + + +_Bool ble_ke_timer_active(ke_msg_id_t timer_id,ke_task_id_t task_id) + +{ + undefined2 in_register_0000202a; + uint32_t uVar1; + undefined2 in_register_0000202e; + co_list_hdr cVar2; + undefined auStack17 [4]; + _Bool result; + + uVar1 = (*_rom_patch_hook)(auStack17,CONCAT22(in_register_0000202a,timer_id), + CONCAT22(in_register_0000202e,task_id),_rom_patch_hook); + cVar2 = (co_list_hdr)ble_ke_env.queue_timer.first; + if (uVar1 == 0) { + while (cVar2 != (co_list_hdr)0x0) { + if (((uint)*(ushort *)&((co_list_hdr *)((int)cVar2 + 4))->next == + CONCAT22(in_register_0000202a,timer_id)) && + ((uint)*(ushort *)((int)cVar2 + 6) == CONCAT22(in_register_0000202e,task_id))) { + return true; + } + cVar2 = *(co_list_hdr *)cVar2; + } + auStack17[0] = 0; + } + return (_Bool)auStack17[0]; +} + + + +void ble_ke_init(void) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,_rom_patch_hook); + if (uVar1 == 0) { + (*ble_memset_ptr)((void *)0x420262bc,0,8); + (*ble_memset_ptr)((void *)0x420262c4,0,4); + ble_ke_event_init(); + ble_ke_env.queue_saved.first = (co_list_hdr *)0x0; + ble_ke_env.queue_saved.last = (co_list_hdr *)0x0; + ble_ke_env.queue_sent.first = (co_list_hdr *)0x0; + ble_ke_env.queue_sent.last = (co_list_hdr *)0x0; + ble_ke_env.queue_timer.first = (co_list_hdr *)0x0; + ble_ke_env.queue_timer.last = (co_list_hdr *)0x0; + ble_ke_task_init(); + ble_ke_timer_init(); + return; + } + return; +} + + + +void ble_ke_flush(void) + +{ + uint32_t uVar1; + ke_msg *msg; + co_list_hdr *mem_ptr; + + uVar1 = (*_rom_patch_hook)((void *)0x0,_rom_patch_hook); + if (uVar1 != 0) { + return; + } + while (msg = (ke_msg *)ble_co_list_pop_front((co_list *)&ble_ke_env), msg != (ke_msg *)0x0) { + ble_ke_msg_free(msg); + } + while (msg = (ke_msg *)ble_co_list_pop_front(&ble_ke_env.queue_saved), msg != (ke_msg *)0x0) { + ble_ke_msg_free(msg); + } + while (mem_ptr = ble_co_list_pop_front(&ble_ke_env.queue_timer), mem_ptr != (co_list_hdr *)0x0) { + ble_ke_free(mem_ptr); + } + ble_ke_event_flush(); + return; +} + + + +void rf_force_agc_enable(_Bool en) + +{ + return; +} + + + +uint8_t rf_txpwr_dbm_get(uint8_t txpwr_idx,uint8_t modulation) + +{ + return (uint8_t)g_txpower_dbm; +} + + + +int8_t rf_rssi_convert(uint8_t rssi_reg) + +{ + undefined3 in_register_00002029; + + return (int8_t)((uint)((2 - CONCAT31(in_register_00002029,rssi_reg)) * 0x1000000) >> 0x18); +} + + + +uint32_t rf_reg_rd(uint16_t addr) + +{ + return 0; +} + + + +void rf_reg_wr(uint16_t addr,uint32_t value) + +{ + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_sleep(void) + +{ + _DAT_28000030 = _DAT_28000030 | 7; + return; +} + + + +_Bool rf_txpwr_dec(uint8_t dec) + +{ + _Bool _Var1; + undefined3 in_register_00002029; + undefined3 extraout_var; + + _Var1 = rfc_config_power_ble + ((int)g_txpower_offset + + ((int)g_txpower_dbm - CONCAT31(in_register_00002029,dec))); + if (CONCAT31(extraout_var,_Var1) != 0) { + g_txpower_dbm = g_txpower_dbm - dec; + } + return _Var1; +} + + + +_Bool rf_txpwr_inc(uint8_t inc) + +{ + _Bool _Var1; + undefined3 in_register_00002029; + undefined3 extraout_var; + + _Var1 = rfc_config_power_ble + ((int)g_txpower_offset + (int)g_txpower_dbm + CONCAT31(in_register_00002029,inc) + ); + if (CONCAT31(extraout_var,_Var1) != 0) { + g_txpower_dbm = inc + g_txpower_dbm; + } + return _Var1; +} + + + +void rf_txpwr_max_set(int8_t txpwr_dbm) + +{ + _Bool _Var1; + undefined3 in_register_00002029; + int iVar2; + undefined3 extraout_var; + + iVar2 = CONCAT31(in_register_00002029,txpwr_dbm); + if (g_txpower_dbm == '\x7f') { + iVar2 = 0xf; + } + g_txpower_dbm = (int8_t)iVar2; + _Var1 = rfc_config_power_ble(iVar2 + g_txpower_offset); + if (CONCAT31(extraout_var,_Var1) == 0) { + rfc_config_power_ble((int)g_txpower_offset + 0xf); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_reset(void) + +{ + _DAT_28000080 = _DAT_28000080 & 0x80000000 | 0x3c0042; + _DAT_280001a4 = 10; + _DAT_280001a8 = 0x7d; + _DAT_280001ac = _DAT_280001ac & 0xffffffc0 | 0x28; + bz_phy_reset(); + rf_txpwr_max_set(g_txpower_dbm); + return; +} + + + +void ble_rf_set_pwr_offset(int8_t offset) + +{ + g_txpower_offset = offset; + return; +} + + + +void ble_controller_set_tx_pwr(int ble_tx_power) + +{ + _Bool _Var1; + undefined3 extraout_var; + + g_txpower_dbm = (int8_t)ble_tx_power; + _Var1 = rfc_config_power_ble((int)g_txpower_dbm + (int)g_txpower_offset); + if (CONCAT31(extraout_var,_Var1) == 0) { + rfc_config_power_ble((int)g_txpower_offset + 0xf); + return; + } + return; +} + + + +void ble_rf_init(rwip_rf_api_conflict1 *api) + +{ + api->reg_rd = rf_reg_rd; + api->reg_wr = rf_reg_wr; + api->txpwr_dbm_get = rf_txpwr_dbm_get; + api->txpwr_max = '\x0f'; + api->txpwr_max_set = rf_txpwr_max_set; + api->txpwr_inc = rf_txpwr_inc; + api->txpwr_dec = rf_txpwr_dec; + api->sleep = rf_sleep; + api->reset = rf_reset; + api->force_agc_enable = rf_force_agc_enable; + api->rssi_convert = rf_rssi_convert; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pka0_write_common_op_first_cfg + (uint8_t s0_reg_index,uint8_t s0_reg_type,uint8_t d_reg_index,uint8_t d_reg_type, + uint8_t op,_Bool last_op) + +{ + uint uVar1; + undefined3 in_register_00002039; + uint uStack36; + pka0_common_op_first_cfg cfg; + + (*ble_memset_ptr)(&uStack36,0,4); + uVar1 = ((uint)s0_reg_type & 0xf) << 8; + uStack36 = uStack36 & 0xfffff000 | (uint)s0_reg_index | uVar1; + if (CONCAT31(in_register_00002039,op) != 0x19) { + uStack36 = (uint)s0_reg_index | uVar1 | (uint)d_reg_index << 0xc | + ((uint)d_reg_type & 0xf) << 0x14; + } + _DAT_40004340 = uStack36 & 0xffffff | ((uint)op & 0x7f) << 0x18 | (uint)last_op << 0x1f; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pka0_write_common_op_snd_cfg_S1(uint8_t s1_reg_index,uint8_t s1_reg_type) + +{ + undefined3 in_register_00002029; + uint uStack20; + pka0_common_op_snd_cfg_S1_only cfg; + + (*ble_memset_ptr)(&uStack20,0,4); + _DAT_40004340 = + (uStack20 & 0xfff00fff | CONCAT31(in_register_00002029,s1_reg_index) << 0xc) & 0xff0fffff | + ((uint)s1_reg_type & 0xf) << 0x14; + return; +} + + + +// WARNING: Variable defined which should be unmapped: cfg +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pka0_write_common_op_snd_cfg_S1_S2 + (uint8_t s1_reg_index,uint8_t s1_reg_type,uint8_t s2_reg_index,uint8_t s2_reg_type) + +{ + undefined3 in_register_00002029; + uint uStack20; + pka0_common_op_snd_cfg_S1_S2 cfg; + + (*ble_memset_ptr)(&uStack20,0,4); + _DAT_40004340 = + (uStack20 & 0xfff00fff | CONCAT31(in_register_00002029,s1_reg_index) << 0xc) & 0xff0ff000 | + ((uint)s1_reg_type & 0xf) << 0x14 | (uint)s2_reg_index | ((uint)s2_reg_type & 0xf) << 8; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_eng_pka0_reset(void) + +{ + _DAT_40004300 = 8; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_eng_pka0_clear_int(void) + +{ + _DAT_40004300 = _DAT_40004300 & 0xfffffdff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_eng_pka0_pld(uint16_t size,uint32_t *data,uint8_t reg_index,uint8_t reg_type,uint8_t op, + _Bool last_op) + +{ + int iVar1; + undefined2 in_register_0000202a; + undefined3 in_register_00002031; + uint uVar2; + + _DAT_40004340 = + (uint)size & 0xfff | CONCAT31(in_register_00002031,reg_index) << 0xc | + ((uint)reg_type & 0xf) << 0x14 | ((uint)op & 0x7f) << 0x18 | (uint)last_op << 0x1f; + uVar2 = 0; + while ((int)uVar2 < CONCAT22(in_register_0000202a,size)) { + iVar1 = 0x340; + if ((size & 7) == 0) { + iVar1 = 0x360; + } + *(uint32_t *)(&DAT_40004000 + (uVar2 & 7) * 4 + iVar1) = data[uVar2]; + uVar2 = uVar2 + 1; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_eng_pka0_wait_4_isr(void) + +{ + do { + } while ((_DAT_40004300 & 0x100) == 0); + return; +} + + + +// WARNING: Variable defined which should be unmapped: ret_data +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_eng_pka0_read_data(uint8_t reg_ype,uint8_t reg_idx,uint32_t *result,uint8_t ret_size) + +{ + int iVar1; + undefined3 in_register_00002035; + uint uVar2; + uint uVar3; + undefined4 uStack36; + uint32_t ret_data; + + uVar3 = (uint)reg_ype - 1 & 0xff; + uVar2 = 0; + if (uVar3 < 10) { + uVar2 = (uint)*(ushort *)(CSWTCH_9 + uVar3 * 2); + } + if (CONCAT31(in_register_00002035,ret_size) <= (uVar2 & 0xff)) { + _DAT_40004340 = 0; + sec_eng_pka0_wait_4_isr(); + uVar2 = 0; + sec_eng_pka0_clear_int(); + while ((int)uVar2 < (int)CONCAT31(in_register_00002035,ret_size)) { + uVar3 = uVar2 & 7; + iVar1 = 0x360; + if ((ret_size & 7) != 0) { + iVar1 = 0x340; + } + uStack36 = *(undefined4 *)(&DAT_40004000 + uVar3 * 4 + iVar1); + uVar2 = uVar2 + 1; + (*ble_memcpy_ptr)(result + uVar3,&uStack36,4); + } + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_eng_pka0_clir(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t size) + +{ + _DAT_40004340 = 0; + sec_eng_pka0_wait_4_isr(); + sec_eng_pka0_clear_int(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_eng_pka0_movdat(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type, + uint8_t s0_reg_idx) + +{ + undefined3 in_register_00002029; + + pka0_write_common_op_first_cfg + (s0_reg_idx,s0_reg_type,d_reg_idx,d_reg_type,'2', + (_Bool)(CONCAT31(in_register_00002029,last_op) != 0)); + _DAT_40004340 = 0; + if (CONCAT31(in_register_00002029,last_op) != 0) { + sec_eng_pka0_wait_4_isr(); + sec_eng_pka0_clear_int(); + return; + } + _DAT_40004340 = 0; + return; +} + + + +void sec_eng_pka0_msub(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type, + uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx,uint8_t s2_reg_type, + uint8_t s2_reg_idx) + +{ + undefined3 in_register_00002029; + uint8_t in_stack_00000000; + + pka0_write_common_op_first_cfg + (s0_reg_idx,s0_reg_type,d_reg_idx,d_reg_type,'\'', + (_Bool)(CONCAT31(in_register_00002029,last_op) != 0)); + pka0_write_common_op_snd_cfg_S1_S2(s1_reg_idx,s1_reg_type,in_stack_00000000,s2_reg_type); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_eng_pka0_mrem(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type, + uint8_t s0_reg_idx,uint8_t s2_reg_type,uint8_t s2_reg_idx) + +{ + undefined3 in_register_00002029; + uint uStack20; + pka0_common_op_snd_cfg_S2_only cfg; + + pka0_write_common_op_first_cfg + (s0_reg_idx,s0_reg_type,d_reg_idx,d_reg_type,'&', + (_Bool)(CONCAT31(in_register_00002029,last_op) != 0)); + (*ble_memset_ptr)(&uStack20,0,4); + _DAT_40004340 = uStack20 & 0xfffff000 | (uint)s2_reg_idx | ((uint)s2_reg_type & 0xf) << 8; + return; +} + + + +void sec_eng_pka0_mmul(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type, + uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx,uint8_t s2_reg_type, + uint8_t s2_reg_idx) + +{ + undefined3 in_register_00002029; + uint8_t in_stack_00000000; + + pka0_write_common_op_first_cfg + (s0_reg_idx,s0_reg_type,d_reg_idx,d_reg_type,'%', + (_Bool)(CONCAT31(in_register_00002029,last_op) != 0)); + pka0_write_common_op_snd_cfg_S1_S2(s1_reg_idx,s1_reg_type,in_stack_00000000,s2_reg_type); + return; +} + + + +void sec_eng_pka0_mexp(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type, + uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx,uint8_t s2_reg_type, + uint8_t s2_reg_idx) + +{ + undefined3 in_register_00002029; + uint8_t in_stack_00000000; + + pka0_write_common_op_first_cfg + (s0_reg_idx,s0_reg_type,d_reg_idx,d_reg_type,'#', + (_Bool)(CONCAT31(in_register_00002029,last_op) != 0)); + pka0_write_common_op_snd_cfg_S1_S2(s1_reg_idx,s1_reg_type,in_stack_00000000,s2_reg_type); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_eng_pka0_lcmp(uint8_t *cout,uint8_t s0_reg_type,uint8_t s0_reg_idx,uint8_t s1_reg_type, + uint8_t s1_reg_idx) + +{ + pka0_write_common_op_first_cfg(s0_reg_idx,s0_reg_type,'\0','\0','\x19',true); + pka0_write_common_op_snd_cfg_S1(s1_reg_idx,s1_reg_type); + sec_eng_pka0_wait_4_isr(); + sec_eng_pka0_clear_int(); + *cout = (byte)((uint)_DAT_40004300 >> 0x18) & 1; + return; +} + + + +void sec_eng_pka0_lsub(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type, + uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx) + +{ + undefined3 in_register_00002029; + + pka0_write_common_op_first_cfg + (s0_reg_idx,s0_reg_type,d_reg_idx,d_reg_type,'\x17', + (_Bool)(CONCAT31(in_register_00002029,last_op) != 0)); + pka0_write_common_op_snd_cfg_S1(s1_reg_idx,s1_reg_type); + return; +} + + + +void sec_eng_pka0_lmul(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type, + uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx) + +{ + undefined3 in_register_00002029; + + pka0_write_common_op_first_cfg + (s0_reg_idx,s0_reg_type,d_reg_idx,d_reg_type,'\x16', + (_Bool)(CONCAT31(in_register_00002029,last_op) != 0)); + pka0_write_common_op_snd_cfg_S1(s1_reg_idx,s1_reg_type); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_eng_pka0_lmul2n(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type, + uint8_t s0_reg_idx,uint16_t bit_shift) + +{ + uint uStack36; + pka0_bit_shift_op_cfg cfg; + + (*ble_memset_ptr)(&uStack36,0,4); + pka0_write_common_op_first_cfg(s0_reg_idx,s0_reg_type,d_reg_idx,d_reg_type,'\x13',false); + _DAT_40004340 = uStack36 & 0xffff8000 | (uint)bit_shift & 0x7fff; + return; +} + + + +void em_buf_init(void) + +{ + em_desc_node *peVar1; + undefined2 *puVar2; + uint uVar3; + em_buf_env_tag *peVar4; + int iVar5; + uint uVar6; + ushort *puVar7; + ushort *puVar8; + em_buf_env_tag *peVar9; + + em_buf_env.rx_current = '\0'; + ble_co_list_init((co_list *)&em_buf_env); + ble_co_list_init(&em_buf_env.tx_buff_free); + em_buf_env.tx_desc = (em_buf_tx_desc *)&DAT_280082ca; + peVar9 = &em_buf_env; + peVar4 = &em_buf_env; + uVar3 = 0; + puVar2 = (undefined2 *)&DAT_280082ce; + do { + uVar6 = uVar3 & 0xffff; + peVar4->tx_desc_node[0].idx = (uint16_t)uVar3; + uVar3 = uVar3 + 1; + peVar4 = (em_buf_env_tag *)&(peVar4->tx_buff_free).last; + *puVar2 = (short)((uVar6 * 0x26 + 0x43e) * 0x10000 >> 0x10); + puVar2[2] = 0; + puVar2[1] = 0; + puVar2[-1] = puVar2[-1] & 0xffdf; + puVar2[-1] = puVar2[-1] & 0xffdf; + puVar2[-2] = 0x8000; + puVar2 = puVar2 + 5; + } while (uVar3 != 6); + puVar2 = (undefined2 *)&DAT_2800830a; + do { + peVar9->tx_desc_node[6].idx = (uint16_t)uVar3; + *puVar2 = 0; + puVar2[2] = 0; + puVar2[1] = 0; + peVar1 = peVar9->tx_desc_node; + puVar2[-1] = puVar2[-1] & 0xffdf; + uVar3 = uVar3 + 1; + peVar9 = (em_buf_env_tag *)&(peVar9->tx_buff_free).last; + puVar2[-1] = puVar2[-1] & 0xffdf; + puVar2[-2] = 0x8000; + ble_co_list_push_back(&em_buf_env,peVar1 + 6); + puVar2 = puVar2 + 5; + } while (uVar3 != 0x1a); + em_buf_env.tx_buff_node[0]._4_4_ = 0x5220000; + ble_co_list_push_back(0x420262d0,0x42026410); + em_buf_env.tx_buff_node[1]._4_4_ = 0x6260001; + ble_co_list_push_back(0x420262d0,0x42026418); + iVar5 = 0; + puVar2 = (undefined2 *)&DAT_280083d6; + do { + iVar5 = iVar5 + 1; + *puVar2 = (short)((uint)((iVar5 * 0x104 + 0x626) * 0x10000) >> 0x10); + puVar2[-4] = ((ushort)iVar5 & 7) * 0xe + 0x3ce; + puVar2[2] = 0; + puVar2[-2] = puVar2[-2] & 0xffdf; + puVar2[-2] = puVar2[-2] & 0xffdf; + puVar2 = puVar2 + 7; + } while (iVar5 != 8); + puVar7 = (ushort *)&DAT_2800809e; + do { + puVar8 = puVar7 + 0x2e; + *puVar7 = *puVar7 & 0xbfff; + puVar7[9] = puVar7[9] & 0xfcff; + puVar7[0x25] = 0; + puVar7 = puVar8; + } while (puVar8 != (ushort *)0x2800820e); + return; +} + + + +void em_buf_rx_free(uint8_t hdl) + +{ + undefined3 in_register_00002029; + + *(ushort *)(&DAT_280083ce + CONCAT31(in_register_00002029,hdl) * 0xe) = + (ushort)(((uint)*(ushort *)(&DAT_280083ce + CONCAT31(in_register_00002029,hdl) * 0xe) << 0x11 + ) >> 0x11); + return; +} + + + +uint8_t * em_buf_rx_buff_addr_get(uint16_t rx_hdl) + +{ + undefined2 in_register_0000202a; + + return &DAT_28008000 + *(ushort *)(&DAT_280083d6 + CONCAT22(in_register_0000202a,rx_hdl) * 0xe); +} + + +/* +Unable to decompile 'em_buf_tx_free' +Cause: Exception while decompiling 2302cc7e: Decompiler process died + +*/ + + +void llc_init(void) + +{ + ble_ke_task_create('\x01',&TASK_DESC_LLC); + ble_ke_state_set(1,'\x7f'); + ble_ke_state_set(0x101,'\x7f'); + // WARNING: Could not recover jumptable at 0x2302cd78. Too many branches + // WARNING: Treating indirect jump as call + (*ble_memset_ptr)(llc_env,0,8); + return; +} + + + +void llc_stop(int param_1) + +{ + void *pvVar1; + int iVar2; + + ble_ke_state_set((ushort)(param_1 << 8) | 1,'\x7f'); + if (llc_env[param_1] != (llc_env_tag *)0x0) { + iVar2 = 0; + do { + pvVar1 = llc_env[param_1]->operation[iVar2]; + if (pvVar1 != (void *)0x0) { + ble_ke_msg_free((ke_msg *)((int)pvVar1 + -0xc)); + } + iVar2 = iVar2 + 1; + } while (iVar2 != 4); + ble_ke_free(llc_env[param_1]); + llc_env[param_1] = (llc_env_tag *)0x0; + llm_util_bl_rem((uint16_t)param_1); + return; + } + return; +} + + + +void llc_reset(void) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + undefined2 extraout_var_00; + + kVar1 = ble_ke_state_get(1); + if (CONCAT22(extraout_var,kVar1) != 0x7f) { + llc_stop(0); + } + kVar1 = ble_ke_state_get(0x101); + if (CONCAT22(extraout_var_00,kVar1) != 0x7f) { + llc_stop(1); + return; + } + return; +} + + + +void llc_discon_event_complete_send + (ke_task_id_t src_id,uint8_t status,uint8_t conhdl,uint8_t reason) + +{ + uint8_t *param; + ke_task_id_t dest_id; + undefined3 in_register_00002031; + + dest_id = (ke_task_id_t)CONCAT31(in_register_00002031,conhdl); + param = (uint8_t *)ble_ke_msg_alloc(0x803,dest_id,5,6); + *param = status; + param[4] = reason; + *(ke_task_id_t *)(param + 2) = dest_id; + hci_send_2_host(param); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void llc_le_con_cmp_evt_send(uint8_t status,uint16_t conhdl,llc_create_con_req_ind *param) + +{ + ushort uVar1; + undefined *param_00; + _Bool _Var2; + uint8_t uVar3; + undefined3 in_register_00002029; + int iVar4; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + bd_addr *pbVar5; + undefined *puVar6; + anon_subr_void_ptr_void_ptr_void_ptr_uint *paVar7; + undefined *puVar8; + ushort *puVar9; + + iVar4 = CONCAT31(in_register_00002029,status); + _Var2 = llm_util_check_evt_mask('\0'); + if ((CONCAT31(extraout_var,_Var2) == 0) && + (_Var2 = llm_util_check_evt_mask('\t'), CONCAT31(extraout_var_02,_Var2) == 0)) { + return; + } + _Var2 = llm_util_check_evt_mask('\t'); + if (CONCAT31(extraout_var_00,_Var2) != 0) { + param_00 = (undefined *)ble_ke_msg_alloc(0x804,conhdl,0,0x20); + *param_00 = 10; + param_00[1] = status; + *(uint16_t *)(param_00 + 2) = conhdl; + if (iVar4 != 0) { + if (iVar4 != 0x3c) goto LAB_2302cf5c; + param_00[4] = 1; + uVar3 = param->peer_addr_type; + *(undefined2 *)(param_00 + 2) = 0; + param_00[5] = uVar3; + paVar7 = ble_memcpy_ptr; + *(undefined2 *)(param_00 + 0x18) = 0; + *(undefined2 *)(param_00 + 0x1a) = 0; + *(undefined2 *)(param_00 + 0x1c) = 0; + (*paVar7)(param_00 + 6,¶m->peer_addr,6); + (*ble_memset_ptr)(param_00 + 0x12,0,6); + pbVar5 = (bd_addr *)0x0; + puVar8 = param_00 + 0xc; + paVar7 = (anon_subr_void_ptr_void_ptr_void_ptr_uint *)ble_memset_ptr; + goto LAB_2302cff4; + } + uVar3 = lld_get_mode(conhdl); + *(bool *)(param_00 + 4) = CONCAT31(extraout_var_03,uVar3) != 3; + uVar1 = param->ral_ptr; + puVar8 = param_00 + 0xc; + if (uVar1 == 0) { + (*ble_memset_ptr)(puVar8,0,6); + puVar8 = param_00 + 0x12; +LAB_2302d0be: + (*ble_memset_ptr)(puVar8,0,6); + } + else { + puVar9 = (ushort *)(&DAT_2800822e + (((uint)uVar1 - 0x22e) / 0x34 & 0xff) * 0x34); + if (((*puVar9 >> 1 & 1) == 0) || ((param->filter_policy != '\0' && ((*puVar9 >> 3 & 1) == 0))) + ) { + puVar6 = (undefined *)0x0; + paVar7 = (anon_subr_void_ptr_void_ptr_void_ptr_uint *)ble_memset_ptr; + } + else { + puVar6 = &DAT_28008000 + ((uint)uVar1 + 0x12 & 0xffff); + paVar7 = ble_memcpy_ptr; + } + (*paVar7)(param_00 + 0x12,puVar6,6); + if (((*puVar9 >> 5 & 1) == 0) || ((param_00[4] == '\x01' && ((_DAT_28008154 >> 2 & 1) == 0)))) + goto LAB_2302d0be; + (*ble_memcpy_ptr)(puVar8,&DAT_28008000 + ((uint)param->ral_ptr + 0x2e & 0xffff),6); + } + param_00[5] = param->peer_addr_type; + (*ble_memcpy_ptr)(param_00 + 6,¶m->peer_addr,6); + *(uint16_t *)(param_00 + 0x18) = param->con_int; + *(uint16_t *)(param_00 + 0x1a) = param->con_lat; + *(uint16_t *)(param_00 + 0x1c) = param->sup_to; + if (param_00[4] == '\0') { + param_00[0x1e] = 0; + } + else { + param_00[0x1e] = param->sleep_clk_acc; + } + goto LAB_2302cf5c; + } + param_00 = (undefined *)ble_ke_msg_alloc(0x804,conhdl,0,0x14); + *param_00 = 1; + param_00[1] = status; + *(uint16_t *)(param_00 + 2) = conhdl; + if (iVar4 != 0) { + if (iVar4 != 0x3c) goto LAB_2302cf5c; + param_00[4] = 1; + uVar3 = param->peer_addr_type; + *(undefined2 *)(param_00 + 2) = 0; + *(undefined2 *)(param_00 + 0xc) = 0; + param_00[5] = uVar3; + paVar7 = ble_memcpy_ptr; + *(undefined2 *)(param_00 + 0xe) = 0; + *(undefined2 *)(param_00 + 0x10) = 0; + pbVar5 = ¶m->peer_addr; + puVar8 = param_00 + 6; +LAB_2302cff4: + (*paVar7)(puVar8,pbVar5,6); + goto LAB_2302cf5c; + } + uVar3 = lld_get_mode(conhdl); + *(bool *)(param_00 + 4) = CONCAT31(extraout_var_01,uVar3) != 3; + puVar8 = param_00 + 6; + if ((param->ral_ptr == 0) || + ((*(ushort *)(&DAT_2800822e + (((uint)param->ral_ptr - 0x22e) / 0x34 & 0xff) * 0x34) >> 1 & 1) + == 0)) { +LAB_2302cf9c: + param_00[5] = param->peer_addr_type & 1; + (*ble_memcpy_ptr)(puVar8,¶m->peer_addr,6); + } + else { + if ((param->filter_policy != '\0') && + ((*(ushort *)(&DAT_2800822e + (((uint)param->ral_ptr - 0x22e) / 0x34 & 0xff) * 0x34) >> 3 & 1 + ) == 0)) { + (*ble_memset_ptr)(puVar8,0,6); + goto LAB_2302cf9c; + } + param_00[5] = 1; + (*ble_memcpy_ptr)(puVar8,&DAT_28008000 + ((uint)param->ral_ptr + 0x12 & 0xffff),6); + } + *(uint16_t *)(param_00 + 0xc) = param->con_int; + *(uint16_t *)(param_00 + 0xe) = param->con_lat; + *(uint16_t *)(param_00 + 0x10) = param->sup_to; + if (param_00[4] == '\0') { + param_00[0x12] = 0; + } + else { + param_00[0x12] = param->sleep_clk_acc; + } +LAB_2302cf5c: + hci_send_2_host(param_00); + return; +} + + + +void llc_le_ch_sel_algo_evt_send(uint8_t chSel,uint16_t conhdl,llc_create_con_req_ind *param) + +{ + _Bool _Var1; + undefined3 extraout_var; + undefined *param_00; + + _Var1 = llm_util_check_evt_mask('\x13'); + if (CONCAT31(extraout_var,_Var1) != 0) { + param_00 = (undefined *)ble_ke_msg_alloc(0x804,conhdl,0,6); + *param_00 = 0x14; + param_00[4] = chSel; + *(uint16_t *)(param_00 + 2) = conhdl; + hci_send_2_host(param_00); + return; + } + return; +} + + + +void llc_start(llc_create_con_req_ind *param_1,ea_elt_tag *param_2) + +{ + ushort conhdl; + ushort uVar1; + anon_subr_void_ptr_void_ptr_int_uint *paVar2; + uint16_t uVar3; + llc_env_tag *plVar4; + llc_env_tag **pplVar5; + ushort task_id; + uint delay; + llc_env_tag *plVar6; + uint uVar7; + + conhdl = *(ushort *)¶m_2[2].ea_cb_start; + uVar7 = (uint)conhdl; + task_id = conhdl << 8 | 1; + if (llc_env[uVar7] == (llc_env_tag *)0x0) { + plVar4 = (llc_env_tag *)ble_ke_malloc(0xa8,'\0'); + llc_env[uVar7] = plVar4; + } + paVar2 = ble_memset_ptr; + plVar4 = llc_env[uVar7]; + plVar4->peer_sup_conn_param_req = true; + (*paVar2)(&plVar4->peer_version,0,6); + llm_util_get_channel_map(&plVar4->ch_map); + llm_util_get_channel_map(&plVar4->n_ch_map); + if (*(char *)((int)¶m_2[2].ea_cb_stop + 3) == '\x03') { + (*ble_memset_ptr)(&plVar4->chnl_assess,0,0x28); + delay = (uint)llm_le_env.ch_map_assess.assess_timer; + (plVar4->chnl_assess).reassess_count = llm_le_env.ch_map_assess.reassess_count; + ble_ke_timer_set(0x105,task_id,delay); + if (*(ushort *)((int)¶m_2[2].linked_element + 2) < 2) { + (plVar4->chnl_assess).latency_en = false; + } + else { + (plVar4->chnl_assess).latency_en = true; + } + } + plVar4->elt = param_2; + uVar1 = param_1->sup_to; + plVar4->sup_to = uVar1; + ble_ke_timer_set(0x101,task_id,(uint)uVar1); + plVar4->disc_reason = '\b'; + plVar4->llc_status = 0; + plVar4->disc_event_sent = false; + llm_util_get_supp_features(&plVar4->feats_used); + plVar4->operation[0] = (void *)0x0; + plVar4->operation[1] = (void *)0x0; + plVar4->operation[2] = (void *)0x0; + plVar4->operation[3] = (void *)0x0; + ble_ke_state_set(task_id,'\0'); + pplVar5 = llc_env + uVar7; + plVar6 = *pplVar5; + plVar6->auth_payl_to = 3000; + plVar6->loc_proc_state = '\0'; + plVar6->rem_proc_state = '\0'; + llc_util_set_auth_payl_to_margin((lld_evt_tag *)¶m_2->env); + uVar3 = llm_le_env.data_len_val.conn_initial_max_tx_octets; + (plVar4->data_len_ext_info).send_req_not_allowed = false; + (plVar4->data_len_ext_info).conn_max_tx_octets = uVar3; + (plVar4->data_len_ext_info).conn_max_tx_time = llm_le_env.data_len_val.conn_initial_max_tx_time; + *(undefined4 *)&(plVar4->data_len_ext_info).conn_max_rx_octets = 0x1b00fb; + (plVar4->data_len_ext_info).conn_eff_max_rx_octets = 0x1b; + *(undefined4 *)&(plVar4->data_len_ext_info).conn_max_rx_time = 0x1480848; + (plVar4->data_len_ext_info).conn_eff_max_rx_time = 0x148; + (plVar4->data_len_ext_info).data_len_ext_flag = + (plVar4->data_len_ext_info).data_len_ext_flag & 0xfe | 2; + (*pplVar5)->operation[0] = (void *)0x0; + (*pplVar5)->operation[1] = (void *)0x0; + plVar4 = *pplVar5; + plVar4->operation[2] = (void *)0x0; + plVar4->operation[3] = (void *)0x0; + plVar4->encryption_state = '\0'; + llc_le_con_cmp_evt_send('\0',conhdl,param_1); + llc_le_ch_sel_algo_evt_send + ((byte)((ushort)*(undefined2 *)(&DAT_2800809e + uVar7 * 0x5c) >> 0xe) & 1,conhdl,param_1 + ); + return; +} + + + +void llc_con_update_complete_send(uint8_t status,uint16_t conhdl,lld_evt_tag *evt) + +{ + undefined *param; + undefined2 in_register_0000202e; + uint16_t uVar1; + void *pvVar2; + + param = (undefined *)ble_ke_msg_alloc(0x804,conhdl,0,10); + *param = 3; + *(uint16_t *)(param + 2) = conhdl; + param[1] = status; + if (evt == (lld_evt_tag *)0x0) { + pvVar2 = llc_env[CONCAT22(in_register_0000202e,conhdl)]->operation[0]; + if (pvVar2 == (void *)0x0) { + *(undefined2 *)(param + 4) = 0; + *(undefined2 *)(param + 6) = 0; + *(undefined2 *)(param + 8) = 0; + goto LAB_2302d418; + } + *(undefined2 *)(param + 4) = *(undefined2 *)((int)pvVar2 + 0xe); + *(undefined2 *)(param + 6) = *(undefined2 *)((int)pvVar2 + 6); + uVar1 = *(uint16_t *)((int)pvVar2 + 8); + } + else { + *(uint16_t *)(param + 4) = evt->interval >> 1; + *(short *)(param + 6) = *(short *)(evt->evt + 10) + -1; + uVar1 = llc_env[CONCAT22(in_register_0000202e,conhdl)]->sup_to; + } + *(uint16_t *)(param + 8) = uVar1; +LAB_2302d418: + hci_send_2_host(param); + return; +} + + + +void llc_ltk_req_send(uint16_t conhdl,llcp_enc_req *param) + +{ + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x804,conhdl,0,0xe); + *(uint16_t *)(param_00 + 2) = conhdl; + *param_00 = 5; + *(undefined2 *)(param_00 + 0xc) = *(undefined2 *)param->ediv; + (*ble_memcpy_ptr)(param_00 + 4,¶m->rand,8); + hci_send_2_host(param_00); + return; +} + + + +void llc_feats_rd_event_send(uint8_t status,uint16_t conhdl,le_features *feats) + +{ + _Bool _Var1; + undefined3 extraout_var; + undefined *param; + + _Var1 = llm_util_check_evt_mask('\x03'); + if (CONCAT31(extraout_var,_Var1) != 0) { + param = (undefined *)ble_ke_msg_alloc(0x804,conhdl,0,0xc); + *param = 4; + param[1] = status; + *(uint16_t *)(param + 2) = conhdl; + (*ble_memcpy_ptr)(param + 4,feats,8); + hci_send_2_host(param); + return; + } + return; +} + + + +void llc_version_rd_event_send(uint8_t status,uint16_t conhdl) + +{ + uint8_t *param; + undefined2 in_register_0000202e; + llc_env_tag *plVar1; + + param = (uint8_t *)ble_ke_msg_alloc(0x803,conhdl,0xc,10); + *(uint16_t *)(param + 2) = conhdl; + *param = status; + *(uint16_t *)(param + 6) = (llc_env[CONCAT22(in_register_0000202e,conhdl)]->peer_version).compid; + plVar1 = llc_env[CONCAT22(in_register_0000202e,conhdl)]; + *(uint16_t *)(param + 8) = (plVar1->peer_version).subvers; + param[4] = (plVar1->peer_version).vers; + hci_send_2_host(param); + return; +} + + + +void llc_common_cmd_complete_send(uint16_t opcode,uint8_t status,uint16_t conhdl) + +{ + uint8_t *param; + + param = (uint8_t *)ble_ke_msg_alloc(0x801,conhdl,opcode,4); + *param = status; + *(uint16_t *)(param + 2) = conhdl; + hci_send_2_host(param); + return; +} + + + +void llc_common_cmd_status_send(uint16_t opcode,uint8_t status,uint16_t conhdl) + +{ + uint8_t *param; + + param = (uint8_t *)ble_ke_msg_alloc(0x802,conhdl,opcode,1); + *param = status; + hci_send_2_host(param); + return; +} + + + +void llc_common_flush_occurred_send(uint16_t conhdl) + +{ + uint16_t *param; + + param = (uint16_t *)ble_ke_msg_alloc(0x803,conhdl,0x11,2); + *param = conhdl; + hci_send_2_host(param); + return; +} + + + +void llc_common_enc_key_ref_comp_evt_send(uint16_t conhdl,uint8_t status) + +{ + uint8_t *param; + + param = (uint8_t *)ble_ke_msg_alloc(0x803,conhdl,0x30,4); + *(uint16_t *)(param + 2) = conhdl; + *param = status; + hci_send_2_host(param); + return; +} + + + +void llc_common_enc_change_evt_send(uint16_t conhdl,uint8_t enc_status,uint8_t status) + +{ + undefined2 in_register_0000202a; + uint8_t *param; + ushort task_id; + undefined3 in_register_0000202d; + llc_env_tag *plVar1; + + task_id = conhdl << 8 | 1; + if (CONCAT31(in_register_0000202d,enc_status) == 0) { + ble_ke_timer_clear(0x103,task_id); + ble_ke_timer_clear(0x104,task_id); + } + else { + plVar1 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + ble_ke_timer_set(0x103,task_id,(uint)plVar1->auth_payl_to - (uint)plVar1->auth_payl_to_margin); + ble_ke_timer_set(0x104,task_id, + (uint)llc_env[CONCAT22(in_register_0000202a,conhdl)]->auth_payl_to); + } + param = (uint8_t *)ble_ke_msg_alloc(0x803,conhdl,8,6); + *(uint16_t *)(param + 2) = conhdl; + param[4] = enc_status; + *param = status; + hci_send_2_host(param); + return; +} + + + +void llc_common_nb_of_pkt_comp_evt_send(uint16_t conhdl,uint8_t nb_of_pkt) + +{ + undefined *param; + undefined3 in_register_0000202d; + + param = (undefined *)ble_ke_msg_alloc(0x803,conhdl,0x13,6); + *(uint16_t *)(param + 2) = conhdl; + *(short *)(param + 4) = (short)CONCAT31(in_register_0000202d,nb_of_pkt); + *param = 1; + hci_send_2_host(param); + return; +} + + + +void llc_con_update_ind(uint16_t conhdl,ea_elt_tag *elt_new) + +{ + ushort uVar1; + _Bool _Var2; + undefined2 in_register_0000202a; + undefined3 extraout_var; + + uVar1 = llc_env[CONCAT22(in_register_0000202a,conhdl)]->llc_status; + if ((uVar1 & 0xc0) != 0) { + llc_env[CONCAT22(in_register_0000202a,conhdl)]->llc_status = uVar1 & 0xff3f; + _Var2 = llm_util_check_evt_mask('\x02'); + if (CONCAT31(extraout_var,_Var2) != 0) { + llc_con_update_complete_send('\0',conhdl,(lld_evt_tag *)&elt_new->env); + } + } + if (*(ushort *)((int)&elt_new[2].linked_element + 2) < 2) { + (llc_env[CONCAT22(in_register_0000202a,conhdl)]->chnl_assess).latency_en = false; + } + else { + (llc_env[CONCAT22(in_register_0000202a,conhdl)]->chnl_assess).latency_en = true; + } + return; +} + + + +void llc_lsto_con_update(uint16_t conhdl) + +{ + llc_env_tag *plVar1; + undefined2 in_register_0000202a; + uint uVar2; + + plVar1 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + uVar2 = (uint)plVar1->sup_to; + if ((uint)plVar1->sup_to < (uint)plVar1->n_sup_to) { + uVar2 = (uint)plVar1->n_sup_to; + } + plVar1->sup_to = (uint16_t)((uVar2 << 0x11) >> 0x10); + ble_ke_timer_set(0x101,conhdl << 8 | 1,(uVar2 << 0x11) >> 0x10); + plVar1->llc_status = plVar1->llc_status | 0x20; + return; +} + + + +void llc_map_update_ind(uint16_t conhdl) + +{ + llc_env_tag *plVar1; + uint8_t uVar2; + undefined2 in_register_0000202a; + int iVar3; + + plVar1 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + uVar2 = llm_util_check_map_validity((uint8_t *)&plVar1->n_ch_map,'\x05'); + iVar3 = CONCAT22(in_register_0000202a,conhdl) * 0x5c; + *(undefined2 *)(iVar3 + 0x280080aa) = *(undefined2 *)(plVar1->n_ch_map).map; + *(undefined2 *)(iVar3 + 0x280080ac) = *(undefined2 *)((plVar1->n_ch_map).map + 2); + *(undefined2 *)(iVar3 + 0x280080ae) = CONCAT11(uVar2,(plVar1->n_ch_map).map[4]); + memcpy(&plVar1->ch_map,&plVar1->n_ch_map,5); + return; +} + + + +void llc_con_update_finished(int param_1) + +{ + ushort uVar1; + uint8_t uVar2; + ushort id; + ke_state_t kVar3; + undefined3 extraout_var; + llc_env_tag *plVar4; + + id = (ushort)(param_1 << 8) | 1; + kVar3 = ble_ke_state_get(id); + if ((kVar3 & 0xf) != 0xf) { + uVar2 = lld_get_mode((uint16_t)param_1); + if (CONCAT31(extraout_var,uVar2) == 3) { + llc_util_clear_operation_ptr(param_1,0); + ble_ke_state_set(id,(byte)kVar3 & 0xfe); + llc_env[param_1]->loc_proc_state = '\0'; + } + else { + plVar4 = llc_env[param_1]; + uVar1 = plVar4->llc_status; + if ((uVar1 & 0x400) == 0) { + plVar4->llc_status = uVar1 | 0x800; + } + else { + ble_ke_state_set(id,(byte)kVar3 & 0xfd); + plVar4 = llc_env[param_1]; + plVar4->rem_proc_state = '\0'; + plVar4->llc_status = plVar4->llc_status & 0xfbff; + } + } + } + return; +} + + + +void llc_map_update_finished(int param_1) + +{ + ushort uVar1; + uint8_t uVar2; + ushort id; + ke_state_t kVar3; + undefined3 extraout_var; + llc_env_tag *plVar4; + + id = (ushort)(param_1 << 8) | 1; + kVar3 = ble_ke_state_get(id); + if ((kVar3 & 0xf) != 0xf) { + uVar2 = lld_get_mode((uint16_t)param_1); + if (CONCAT31(extraout_var,uVar2) == 3) { + ble_ke_state_set(id,(byte)kVar3 & 0xfe); + llc_env[param_1]->loc_proc_state = '\0'; + } + else { + plVar4 = llc_env[param_1]; + uVar1 = plVar4->llc_status; + if ((uVar1 & 0x400) == 0) { + plVar4->llc_status = uVar1 | 0x800; + } + else { + ble_ke_state_set(id,(byte)kVar3 & 0xfd); + plVar4 = llc_env[param_1]; + plVar4->rem_proc_state = '\0'; + plVar4->llc_status = plVar4->llc_status & 0xfbff; + } + } + } + return; +} + + + +void lld_evt_winsize_change(lld_evt_tag *evt,_Bool instant) + +{ + undefined3 in_register_0000202d; + uint uVar1; + uint uVar2; + + uVar1 = *(uint *)evt->evt; + if ((int)(uVar1 << 0x10) < 0) { + uVar1 = (uVar1 & 0x7fff) * 0x271; + } + uVar1 = uVar1 + *(int *)(evt->evt + 4) * 2; + uVar2 = uVar1; + if (uVar1 < 0xe) { + uVar2 = 0xe; + } + if (((uint)(evt->interval >> 1) * (uint)*(ushort *)(evt->evt + 10) * 0x271 - 0x96 <= uVar2) && + (CONCAT31(in_register_0000202d,instant) == 0)) { + evt->evt_flag = evt->evt_flag | 0x10; + return; + } + if (0x3fff < uVar1) { + uVar2 = ((uVar2 + 0x270) / 0x271 | 0xffff8000) & 0xffff; + if ((evt->anchor_point).finetime_cnt == 0) goto LAB_2302da0a; + uVar2 = uVar2 + 1; + } + uVar2 = uVar2 & 0xffff; +LAB_2302da0a: + *(undefined2 *)((uint)evt->conhdl * 0x5c + 0x280080a2) = (short)uVar2; + *(uint *)evt->evt = uVar2; + return; +} + + + +void lld_evt_slave_time_compute(ea_elt_tag *elt,uint16_t slot_offset) + +{ + ushort uVar1; + int iVar2; + undefined2 in_register_0000202e; + uint uVar3; + uint uVar4; + int iVar5; + anon_subr_void_ea_elt_tag_ptr_for_ea_cb_cancel *paVar6; + uint16_t uVar7; + void *pvVar8; + + pvVar8 = elt->env; + uVar3 = CONCAT22(in_register_0000202e,slot_offset) * 0x271 + (uint)*(ushort *)&elt[1].hdr.next; + iVar5 = (uint)*(ushort *)&elt[2].ea_cb_start * 0x5c; + uVar1 = *(ushort *)(iVar5 + 0x280080a2); + if ((short)uVar1 < 0) { + iVar2 = (((uint)uVar1 << 0x11) >> 0x12) * -0x271; + } + else { + iVar2 = -(uint)(uVar1 >> 1); + } + uVar4 = (uVar3 + iVar2) - 0x21; + elt->env = (void *)(uVar3 / 0x271 + (int)pvVar8 & 0x7ffffff); + *(short *)&elt[1].hdr.next = (short)(uVar3 % 0x271); + elt->timestamp = uVar4 / 0x271 + (int)pvVar8 & 0x7ffffff; + if ((short)uVar1 < 0) { + uVar7 = uVar1 & 0x7fff; + } + else { + uVar7 = (uint16_t)(((uint)uVar1 / 0x271 + 1) * 0x10000 >> 0x10); + } + paVar6 = elt[1].ea_cb_cancel; + elt->duration_min = uVar7; + elt->duration_min = (uVar7 + *(short *)(paVar6 + 8)) * 0x271; + uVar7 = (uint16_t)(uVar4 % 0x271); + *(uint16_t *)(iVar5 + 0x28008090) = uVar7; + elt->delay = uVar7; + return; +} + + + +void lld_evt_prevent_stop(ea_elt_tag *elt) + +{ + return; +} + + + +void lld_evt_deferred_elt_push(ea_elt_tag *elt,uint8_t type,uint8_t rx_desc_cnt) + +{ + void *pvVar1; + + pvVar1 = ble_ke_malloc(0xc,'\0'); + *(ea_elt_tag **)((int)pvVar1 + 4) = elt; + *(uint8_t *)((int)pvVar1 + 8) = type; + *(uint8_t *)((int)pvVar1 + 9) = rx_desc_cnt; + ble_co_list_push_back(0x42026440,pvVar1); + return; +} + + + +void lld_evt_elt_wait_insert(ea_elt_tag *elt) + +{ + void *pvVar1; + + pvVar1 = ble_ke_malloc(8,'\0'); + *(ea_elt_tag **)((int)pvVar1 + 4) = elt; + ble_co_list_push_back(0x42026438,pvVar1); + return; +} + + +/* +Unable to decompile 'lld_evt_deferred_elt_pop' +Cause: Exception while decompiling 2302db4e: Decompiler process died + +*/ + + +// WARNING: Removing unreachable block (ram,0x2302dbd0) +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t lld_evt_get_next_free_slot(void) + +{ + if (lld_evt_env.elt_prog.first != (co_list_hdr *)0x0) { + return (int)&(lld_evt_env.elt_prog.last[2].next)->next + + (uint)*(ushort *)((int)&lld_evt_env.elt_prog.last[4].next + 2) / 0x271 & 0x7ffffff; + } + do { + } while( true ); +} + + + +lld_evt_wait_tag * lld_evt_elt_wait_get(ea_elt_tag *elt) + +{ + co_list_hdr list_hdr; + lld_evt_wait_tag *plVar1; + + list_hdr = (co_list_hdr)lld_evt_env.elt_wait.first; + if (elt == (ea_elt_tag *)0x0) { + plVar1 = (lld_evt_wait_tag *)ble_co_list_pop_front(&lld_evt_env.elt_wait); + return plVar1; + } + while( true ) { + if (list_hdr == (co_list_hdr)0x0) { + return (lld_evt_wait_tag *)0x0; + } + if ((ea_elt_tag *)((co_list_hdr *)((int)list_hdr + 4))->next == elt) break; + list_hdr = *(co_list_hdr *)list_hdr; + } + ble_co_list_extract(&lld_evt_env.elt_wait,(co_list_hdr *)list_hdr,'\0'); + return (lld_evt_wait_tag *)list_hdr; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_evt_schedule(ea_elt_tag *elt) + +{ + char cVar1; + uint uVar2; + ushort *puVar3; + lld_evt_wait_tag *mem_ptr; + uint uVar4; + int iVar5; + ea_elt_tag *peVar6; + uint uVar7; + + if (elt == (ea_elt_tag *)0x0) { + return; + } + uVar2 = elt->timestamp; + mem_ptr = lld_evt_elt_wait_get(elt); + if (mem_ptr != (lld_evt_wait_tag *)0x0) { + ble_ke_free(mem_ptr); + } + cVar1 = *(char *)((int)&elt[2].ea_cb_stop + 3); + if ((cVar1 == '\0') || (cVar1 == '\x05')) { + if ((*(byte *)((int)&elt[2].ea_cb_cancel + 2) & 0x10) != 0) goto LAB_2302dc44; + llm_util_adv_data_update(); + if (((llm_le_env.advertising_params)->adv_ldc_flag == false) && + (peVar6 = (ea_elt_tag *)((int)elt[2].linked_element - elt->timestamp), + _DAT_28008160 = SUB42(peVar6,0), (int)peVar6 * 0x10000 >> 0x10 < 1)) { + _DAT_28008160 = 1; + } + } + if (*(char *)((int)&elt[2].ea_cb_stop + 3) == '\x01') { + if ((*(byte *)((int)&elt[2].ea_cb_cancel + 2) & 0x10) != 0) { +LAB_2302dc44: + lld_evt_deferred_elt_push(elt,'\x01','\0'); + return; + } + iVar5 = (int)((int)elt[2].linked_element - elt->timestamp) * 0x10000; + _DAT_280081bc = (ushort)((uint)iVar5 >> 0x10); + if (iVar5 >> 0x10 < 1) { + _DAT_280081bc = 1; + } + _DAT_280081b6 = _DAT_280081bc | 0x8000; + peVar6 = elt->linked_element; + if (peVar6 != (ea_elt_tag *)0x0) { + uVar4 = (uint)*(ushort *)&peVar6[2].ea_cb_stop; + uVar7 = uVar4 - (elt->timestamp - peVar6->timestamp & 0x7ffffff) % uVar4 & 0xffff; + if (uVar7 < 6) { + uVar7 = uVar7 + uVar4 & 0xffff; + } + _DAT_280081ba = (undefined2)(((uVar7 >> 1) - 1) * 0x10000 >> 0x10); + } + } + puVar3 = (ushort *)(((uVar2 & 0xf) + 0xa002000) * 4); + *puVar3 = 0; + if ((byte)(*(char *)((int)&elt[2].ea_cb_stop + 3) - 3U) < 2) { + lld_util_dle_set_cs_fields(*(uint16_t *)&elt[2].ea_cb_start); + } + *(undefined2 *)((uint)*(ushort *)&elt[2].ea_cb_start * 0x5c + 0x280080d8) = + *(undefined2 *)&elt[2].timestamp; + *puVar3 = *puVar3 & 0xffcf; + *puVar3 = *puVar3 & 0xfff0 | 2; + puVar3[1] = *(ushort *)((int)&elt[2].ea_cb_start + 2); + lld_pdu_tx_prog(&elt->env); + ble_co_list_push_back(&lld_evt_env,elt); + return; +} + + +/* +Unable to decompile 'lld_evt_delete_elt_push' +Cause: Exception while decompiling 2302dd8c: Decompiler process died + +*/ + +/* +Unable to decompile 'lld_evt_deffered_elt_handler' +Cause: Exception while decompiling 2302ddee: Decompiler process died + +*/ + + +void lld_evt_channel_next(uint16_t conhdl,int16_t nb_inc) + +{ + undefined2 in_register_0000202a; + ushort *puVar1; + ushort uVar2; + undefined2 in_register_0000202e; + int iVar3; + + puVar1 = (ushort *)(&DAT_2800809e + CONCAT22(in_register_0000202a,conhdl) * 0x5c); + iVar3 = (int)(((int)(uint)*puVar1 >> 8 & 0x1fU) * CONCAT22(in_register_0000202e,nb_inc) + + ((uint)*puVar1 & 0x3f)) % 0x25; + uVar2 = (ushort)iVar3; + if (iVar3 < 0) { + uVar2 = uVar2 + 0x25; + } + *puVar1 = uVar2 | *puVar1 & 0xffc0; + return; +} + + +/* +Unable to decompile 'lld_evt_init' +Cause: Exception while decompiling 2302df44: Decompiler process died + +*/ + +/* +Unable to decompile 'lld_evt_init_evt' +Cause: Exception while decompiling 2302e056: Decompiler process died + +*/ + +/* +Unable to decompile 'lld_evt_elt_delete' +Cause: Exception while decompiling 2302e0a8: Decompiler process died + +*/ + +/* +Unable to decompile 'lld_evt_delete_elt_handler' +Cause: Exception while decompiling 2302e196: Decompiler process died + +*/ + + +uint16_t lld_evt_drift_compute(uint16_t delay,uint8_t master_sca) + +{ + undefined2 in_register_0000202a; + undefined3 in_register_0000202d; + + return (uint16_t) + (((uint)co_sca2ppm[lld_evt_env.sca] + + (uint)co_sca2ppm[CONCAT31(in_register_0000202d,master_sca)]) * + CONCAT22(in_register_0000202a,delay) * 0x29 >> 0x10); +} + + + +void lld_evt_rxwin_compute(ea_elt_tag *elt) + +{ + _Bool instant; + ushort uVar1; + uint16_t uVar2; + undefined2 extraout_var; + + uVar2 = lld_evt_drift_compute + ((uint16_t) + (((uint)*(ushort *)((int)&elt[2].timestamp + 2) + 1) * + (uint)*(ushort *)&elt[2].ea_cb_stop * 0x10000 >> 0x10),elt[2].current_prio); + uVar1 = *(ushort *)&elt[2].ea_cb_start; + elt[2].hdr.next = (co_list_hdr *)CONCAT22(extraout_var,uVar2); + instant = (_Bool)elt[2].start_latency; + elt[1].env = (void *)(uint)*(ushort *)((uint)uVar1 * 0x5c + 0x280080a2); + lld_evt_winsize_change((lld_evt_tag *)&elt->env,instant); + return; +} + + +/* +Unable to decompile 'lld_evt_restart' +Cause: Exception while decompiling 2302e2c6: Decompiler process died + +*/ + +/* +Unable to decompile 'lld_evt_elt_insert' +Cause: Exception while decompiling 2302eaa0: Decompiler process died + +*/ + + +void lld_evt_canceled(ea_elt_tag *elt) + +{ + lld_evt_wait_tag *mem_ptr; + int iVar1; + + mem_ptr = lld_evt_elt_wait_get(elt); + if (mem_ptr != (lld_evt_wait_tag *)0x0) { + ble_ke_free(mem_ptr); + } + if (elt->current_prio < 0x1f) { + elt->current_prio = elt->current_prio + 1; + } + iVar1 = lld_evt_restart(elt,1); + if (iVar1 != 0) { + lld_evt_elt_insert(elt,true); + return; + } + lld_evt_deferred_elt_push(elt,'\x01','\0'); + ble_ke_event_set('\b'); + return; +} + + +/* +Unable to decompile 'lld_evt_schedule_next' +Cause: Exception while decompiling 2302eb66: Decompiler process died + +*/ + + +ea_elt_tag * lld_evt_scan_create(uint16_t handle,uint16_t latency) + +{ + ea_elt_tag *elt; + uint32_t uVar1; + + elt = ea_elt_create(0x58); + lld_evt_init_evt((lld_evt_tag *)&elt->env); + *(undefined *)((int)&elt[2].ea_cb_stop + 3) = 1; + *(uint16_t *)&elt[2].ea_cb_start = handle; + *(short *)((int)&elt[2].linked_element + 2) = latency + 1; + *(short *)((int)&elt[2].ea_cb_start + 2) = handle * 0x5c + 0x8e; + lld_util_priority_set(elt,'\0'); + elt->ea_cb_start = lld_evt_schedule; + elt->ea_cb_cancel = lld_evt_canceled; + elt->ea_cb_stop = lld_evt_prevent_stop; + elt->duration_min = 0x9c4; + elt->asap_settings = 0x6051; + elt->stop_latency1 = '\0'; + *(undefined2 *)&elt->stop_latency2 = 0x200; + uVar1 = ea_time_get_halfslot_rounded(); + elt->timestamp = uVar1; + return elt; +} + + + +ea_elt_tag * +lld_evt_move_to_master + (ea_elt_tag *elt_scan,uint16_t conhdl,llc_create_con_req_ind *pdu_tx,uint8_t rx_hdl) + +{ + ushort uVar1; + uint16_t uVar2; + uint uVar3; + uint uVar4; + ea_interval_tag *interval_to_add; + uint32_t uVar5; + undefined3 in_register_00002035; + uint uVar6; + uint uVar7; + ea_elt_tag *elt; + uint uVar8; + + elt = elt_scan->linked_element; + interval_to_add = ea_interval_create(); + uVar8 = (uint)*(ushort *)&elt[2].ea_cb_stop; + uVar4 = elt->timestamp; + uVar1 = *(ushort *)((uint)*(ushort *)&elt_scan[2].ea_cb_start * 0x5c + 0x280080cc); + elt_scan->linked_element = (ea_elt_tag *)0x0; + lld_scan_stop(elt_scan); + uVar5 = ea_time_get_halfslot_rounded(); + uVar4 = uVar4 % uVar8; + uVar7 = (int)elt_scan->env + + (((uint)*(ushort *)&elt_scan[1].hdr.next + + (uint)(*(ushort *)(&DAT_280083d2 + CONCAT31(in_register_00002035,rx_hdl) * 0xe) >> 8) * + 8 + 0x48e) / 0x271 - 1) & 0x7ffffff; + uVar3 = (uVar8 + uVar7) - (uVar7 - uVar4 & 0x7ffffff) % uVar8 & 0x7ffffff; + uVar6 = uVar3 - uVar7 & 0x7ffffff; + if (0x4000000 < uVar6) { + uVar6 = -(uVar7 - uVar3 & 0x7ffffff); + } + if ((int)uVar6 < (int)(((uint)uVar1 << 0x11) >> 0x10)) { + uVar3 = uVar3 + uVar8 & 0x7ffffff; + } + uVar6 = uVar5 - uVar3 & 0x7ffffff; + if (0x4000000 < uVar6) { + if ((uVar3 - uVar5 & 0x7ffffff) != 0) goto LAB_2302ef2e; + uVar6 = 0; + } + uVar6 = (int)uVar6 / (int)uVar8 + 1; + uVar7 = uVar6 & 0xffff; + lld_evt_channel_next(conhdl,(int16_t)uVar7); + *(short *)&elt[2].timestamp = (short)(uVar6 * 0x10000 >> 0x10) + *(short *)&elt[2].timestamp; + uVar3 = uVar3 + uVar7 * uVar8 & 0x7ffffff; +LAB_2302ef2e: + uVar2 = *(uint16_t *)&elt[2].ea_cb_stop; + elt->timestamp = uVar3; + interval_to_add->interval_used = uVar2; + interval_to_add->bandwidth_used = elt->duration_min / 0x271; + uVar2 = *(uint16_t *)&elt[2].ea_cb_start; + interval_to_add->offset_used = (uint16_t)uVar4; + interval_to_add->role_used = 0; + interval_to_add->conhdl_used = uVar2; + interval_to_add->linkid = *(short *)&elt[2].ea_cb_start * 0x5c + 0x8e; + ea_interval_insert(interval_to_add); + *(ea_interval_tag **)&elt[1].ea_cb_cancel = interval_to_add; + lld_util_priority_set(elt,'\x02'); + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = *(byte *)((int)&elt[2].ea_cb_cancel + 2) | 2; + return elt; +} + + + +// WARNING: Could not reconcile some variable overlaps + +ea_elt_tag * +lld_evt_update_create + (ea_elt_tag *elt_old,uint16_t ce_len,uint16_t mininterval,uint16_t maxinterval, + uint16_t latency,uint8_t pref_period,lld_evt_update_tag *upd_par) + +{ + uint8_t uVar1; + ea_elt_tag *elt; + undefined3 extraout_var; + ea_elt_tag *peVar2; + uint uVar3; + uint16_t uVar4; + undefined2 in_register_00002036; + uint uVar5; + uint uVar6; + uint32_t uVar7; + uint16_t uStack84; + ea_param_output set_param; + ea_param_input input_param; + + uVar5 = CONCAT22(in_register_00002036,maxinterval); + elt = ea_elt_create(0x58); + if (elt == (ea_elt_tag *)0x0) { + return (ea_elt_tag *)0x0; + } + (*ble_memcpy_ptr)(elt,elt_old,0x2c); + lld_evt_init_evt((lld_evt_tag *)&elt->env); + *(short *)((int)&elt[2].linked_element + 2) = latency + 1; + *(undefined *)((int)&elt[2].ea_cb_stop + 3) = 3; + set_param.offset = mininterval; + set_param._10_2_ = maxinterval; + ea_interval_duration_req((ea_param_input *)&set_param.offset,(ea_param_output *)&uStack84); + uVar1 = ea_offset_req((ea_param_input *)&set_param.offset,(ea_param_output *)&uStack84); + if (CONCAT31(extraout_var,uVar1) == 0) { + *(uint16_t *)&elt[2].ea_cb_stop = uStack84; + lld_util_connection_param_set(elt,(ea_param_output *)&uStack84); + peVar2 = (ea_elt_tag *)elt->timestamp; + uVar5 = (uint)*(ushort *)((int)&elt_old[2].linked_element + 2) * 0x60000; + uVar4 = *(short *)&elt_old[2].timestamp + (short)(uVar5 >> 0x10); + uVar3 = 0x7ffffff; + uVar5 = (uint)*(ushort *)&elt_old[2].ea_cb_stop * (uVar5 >> 0x10) + elt_old->timestamp & + 0x7ffffff; + uVar6 = uVar5 - (int)peVar2 & 0x7ffffff; + if (uVar6 < 0x4000001) goto LAB_2302f0ba; + } + else { + uVar4 = 0; + uVar3 = 1; + peVar2 = elt; + lld_evt_delete_elt_push(elt,true,false); + ebreak(); + } + uVar6 = -((uint)((int)peVar2 - uVar5) & uVar3); +LAB_2302f0ba: + uVar3 = (uint)*(ushort *)&elt[2].ea_cb_stop; + elt->timestamp = + (uint)((int)&(peVar2->hdr).next + ((int)((uVar3 - 1) + uVar6) / (int)uVar3) * uVar3) & + 0x7ffffff; + upd_par->win_size = '\x01'; + *(uint16_t *)&elt_old[2].linked_element = uVar4; + uVar7 = elt->timestamp; + upd_par->instant = uVar4; + upd_par->win_offset = (uint16_t)((uVar7 - uVar5) * 0x20 >> 6); + elt_old->linked_element = elt; + *(undefined *)((int)&elt_old[2].delay + 1) = 1; + return elt; +} + + + +// WARNING: Could not reconcile some variable overlaps +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +ea_elt_tag * +lld_evt_move_to_slave + (llc_create_con_req_ind *con_par,llm_pdu_con_req_rx *con_req_pdu,ea_elt_tag *elt_adv, + uint16_t conhdl) + +{ + byte master_sca; + byte bVar1; + byte bVar2; + short sVar3; + undefined2 uVar4; + ushort uVar5; + undefined2 uVar6; + uint8_t uVar7; + uint16_t delay; + ea_elt_tag *elt; + ea_interval_tag *interval_to_add; + undefined2 extraout_var_01; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined *puVar8; + undefined2 extraout_var_02; + ushort uVar9; + void *pvVar10; + uint uVar11; + ushort uStack100; + ea_param_output set_param; + ea_param_input input_param; + + elt = ea_elt_create(0x58); + interval_to_add = ea_interval_create(); + uVar5 = _DAT_28008198; + uVar6 = _DAT_28008196; + uVar4 = _DAT_28008194; + uVar11 = (uint)con_req_pdu->winoffset; + master_sca = con_req_pdu->hop_sca; + bVar1 = con_req_pdu->winsize; + con_par->filter_policy = (uint8_t)((ushort)_DAT_28008154 >> 8); + if (elt == (ea_elt_tag *)0x0) { + lld_evt_delete_elt_push(elt_adv,true,false); + } + else { + lld_evt_init_evt((lld_evt_tag *)&elt->env); + lld_evt_delete_elt_push(elt_adv,true,false); + *(uint16_t *)&elt[2].ea_cb_start = conhdl; + master_sca = master_sca >> 5; + *(uint16_t *)&elt[2].ea_cb_stop = con_par->con_int << 1; + delay = con_par->con_lat; + elt[2].current_prio = master_sca; + elt[2].start_latency = '\0'; + *(short *)((int)&elt[2].linked_element + 2) = delay + 1; + *(undefined *)((int)&elt[2].ea_cb_stop + 3) = 4; + *(undefined2 *)&elt[2].asap_limit = 2; + bVar2 = elt_adv->start_latency; + elt->duration_min = 0x4e2; + elt->start_latency = bVar2; + if (uVar11 << 1 <= (uint)bVar2) { + uVar9 = con_par->con_int; + lld_evt_channel_next(conhdl,1); + uVar11 = uVar11 + uVar9 & 0xffff; + *(undefined2 *)&elt[2].timestamp = 1; + } + delay = (uint16_t)((uVar11 * 2 + (uint)bVar1 + 2) * 0x10000 >> 0x10); + delay = lld_evt_drift_compute(delay,master_sca); + elt[2].hdr.next = (co_list_hdr *)CONCAT22(extraout_var_01,delay); + pvVar10 = (void *)CONCAT22(uVar6,uVar4); + elt[1].env = (void *)((uint)bVar1 * 0x4e2 + -0x21); + lld_evt_winsize_change((lld_evt_tag *)&elt->env,true); + uVar9 = 0x3a8 - (uVar5 & 0x3ff); + if (0x270 < uVar9) { + uVar9 = 0x137 - (uVar5 & 0x3ff); + pvVar10 = (void *)((int)pvVar10 + 1); + } + sVar3 = *(short *)&elt[2].ea_cb_start; + *(ushort *)&elt[1].hdr.next = uVar9; + elt->env = pvVar10; + elt->asap_settings = 0x6000; + *(short *)((int)&elt[2].ea_cb_start + 2) = sVar3 * 0x5c + 0x8e; + elt->ea_cb_start = lld_evt_schedule; + elt->ea_cb_cancel = lld_evt_canceled; + elt->ea_cb_stop = lld_evt_prevent_stop; + lld_util_priority_set(elt,'\x02'); + set_param.offset = *(uint16_t *)&elt[2].ea_cb_stop; + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = *(byte *)((int)&elt[2].ea_cb_cancel + 2) | 2; + uStack100 = 0; + set_param._0_4_ = 0; + set_param.duration._0_2_ = 0; + set_param._10_2_ = set_param.offset; + ea_interval_duration_req((ea_param_input *)&set_param.offset,(ea_param_output *)&uStack100); + uVar7 = ea_offset_req((ea_param_input *)&set_param.offset,(ea_param_output *)&uStack100); + if (CONCAT31(extraout_var,uVar7) != 0) { + uVar7 = ea_offset_req((ea_param_input *)&set_param.offset,(ea_param_output *)&uStack100); + if (CONCAT31(extraout_var_00,uVar7) == 0) { + puVar8 = (undefined *)ble_ke_msg_alloc(0x109,conhdl << 8 | 1,2,0x22); + *puVar8 = 1; + uVar5 = uStack100 >> 1; + *(ushort *)(puVar8 + 2) = uVar5; + *(ushort *)(puVar8 + 4) = uVar5; + *(ushort *)(puVar8 + 0xe) = uVar5; + *(ushort *)(puVar8 + 0x10) = uVar5; + sVar3 = *(short *)((int)&elt[2].linked_element + 2); + puVar8[0x12] = 0; + *(short *)(puVar8 + 6) = sVar3 + -1; + *(undefined2 *)(puVar8 + 8) = 3000; + uVar4 = *(undefined2 *)&elt[2].timestamp; + *(undefined2 *)(puVar8 + 0x14) = uVar4; + *(undefined2 *)(puVar8 + 10) = uVar4; + *(undefined2 *)(puVar8 + 0xc) = *(undefined2 *)&elt[2].timestamp; + delay = lld_util_get_peer_offset((uint16_t)set_param.duration,uStack100,elt->timestamp); + *(short *)(puVar8 + 0x16) = (short)(CONCAT22(extraout_var_02,delay) >> 1); + *(undefined2 *)(puVar8 + 0x18) = 0xffff; + *(undefined2 *)(puVar8 + 0x1a) = 0xffff; + *(undefined2 *)(puVar8 + 0x1c) = 0xffff; + *(undefined2 *)(puVar8 + 0x1e) = 0xffff; + *(undefined2 *)(puVar8 + 0x20) = 0xffff; + ble_ke_msg_send(puVar8); + } + } + interval_to_add->offset_used = (uint16_t)(elt->timestamp % (uint)*(ushort *)&elt[2].ea_cb_stop); + interval_to_add->interval_used = *(uint16_t *)&elt[2].ea_cb_stop; + interval_to_add->bandwidth_used = 2; + interval_to_add->conhdl_used = *(uint16_t *)&elt[2].ea_cb_start; + interval_to_add->role_used = 1; + interval_to_add->linkid = *(short *)&elt[2].ea_cb_start * 0x5c + 0x8e; + ea_interval_insert(interval_to_add); + *(ea_interval_tag **)&elt[1].ea_cb_cancel = interval_to_add; + lld_evt_slave_time_compute(elt,delay); + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = *(byte *)((int)&elt[2].ea_cb_cancel + 2) | 1; + } + return elt; +} + + + +void lld_evt_slave_update(llcp_con_upd_ind *param_pdu,ea_elt_tag *elt_old) + +{ + uint8_t master_sca; + byte bVar1; + short sVar2; + uint16_t uVar3; + ea_elt_tag *peVar4; + undefined2 extraout_var; + llc_env_tag *plVar5; + + if (*(uint16_t *)&elt_old[2].timestamp == param_pdu->instant) { + plVar5 = llc_env[*(ushort *)&elt_old[2].ea_cb_start]; + if ((((uint)*(ushort *)&elt_old[2].ea_cb_stop != (uint)param_pdu->interv << 1) || + ((uint)*(ushort *)((int)&elt_old[2].linked_element + 2) != (uint)param_pdu->latency + 1)) || + (plVar5->sup_to != plVar5->n_sup_to)) { + plVar5->llc_status = plVar5->llc_status | 0x80; + } + *(uint16_t *)&elt_old[2].ea_cb_stop = param_pdu->interv << 1; + *(short *)((int)&elt_old[2].linked_element + 2) = param_pdu->latency + 1; + *(uint16_t *)&elt_old[2].linked_element = param_pdu->instant; + *(undefined *)((int)&elt_old[2].delay + 1) = 1; + *(byte *)((int)&elt_old[2].ea_cb_cancel + 2) = *(byte *)((int)&elt_old[2].ea_cb_cancel + 2) | 9; + return; + } + peVar4 = ea_elt_create(0x58); + if (peVar4 != (ea_elt_tag *)0x0) { + (*ble_memcpy_ptr)(peVar4,elt_old,0x2c); + lld_evt_init_evt((lld_evt_tag *)&peVar4->env); + *(undefined2 *)&peVar4[2].ea_cb_start = *(undefined2 *)&elt_old[2].ea_cb_start; + *(uint16_t *)&peVar4[2].ea_cb_stop = param_pdu->interv << 1; + *(short *)((int)&peVar4[2].linked_element + 2) = param_pdu->latency + 1; + *(undefined *)((int)&peVar4[2].ea_cb_stop + 3) = 4; + master_sca = elt_old[2].current_prio; + peVar4[2].current_prio = master_sca; + *(undefined2 *)&peVar4[2].asap_limit = *(undefined2 *)&elt_old[2].asap_limit; + *(byte *)((int)&peVar4[2].ea_cb_cancel + 2) = *(byte *)((int)&peVar4[2].ea_cb_cancel + 2) | 1; + peVar4->duration_min = 0xffff; + uVar3 = lld_evt_drift_compute + ((uint16_t) + ((((uint)param_pdu->win_off + (uint)param_pdu->win_size) * 2 + + (uint)*(ushort *)&elt_old[2].ea_cb_stop) * 0x10000 >> 0x10),master_sca); + peVar4[2].hdr.next = (co_list_hdr *)CONCAT22(extraout_var,uVar3); + peVar4[1].env = (void *)((uint)param_pdu->win_size * 0x4e2 + -0x21); + elt_old->linked_element = peVar4; + bVar1 = *(byte *)((int)&elt_old[2].ea_cb_cancel + 2); + sVar2 = *(short *)&elt_old[2].timestamp; + *(uint16_t *)&elt_old[2].linked_element = param_pdu->instant; + *(undefined *)((int)&elt_old[2].delay + 1) = 1; + *(uint16_t *)((int)&elt_old[2].asap_limit + 2) = param_pdu->win_off; + *(uint8_t *)&elt_old[2].delay = param_pdu->win_size; + *(byte *)((int)&elt_old[2].ea_cb_cancel + 2) = bVar1 | 1; + if (sVar2 == (uint16_t)(param_pdu->instant - 1)) { + *(byte *)((int)&elt_old[2].ea_cb_cancel + 2) = bVar1 | 9; + } + } + return; +} + + + +ea_elt_tag * +lld_evt_adv_create(uint16_t handle,uint16_t mininterval,uint16_t maxinterval,_Bool restart_pol) + +{ + ea_elt_tag *elt; + uint32_t uVar1; + undefined3 in_register_00002035; + + elt = ea_elt_create(0x58); + lld_evt_init_evt((lld_evt_tag *)&elt->env); + elt->duration_min = 0x9c4; + *(uint16_t *)&elt[2].ea_cb_start = handle; + *(undefined2 *)((int)&elt[2].ea_cb_stop + 2) = 0; + *(uint16_t *)&elt[2].ea_cb_stop = maxinterval; + *(short *)((int)&elt[2].ea_cb_start + 2) = handle * 0x5c + 0x8e; + lld_util_priority_set(elt,'\x05'); + *(undefined2 *)&elt->stop_latency2 = 0x200; + elt->ea_cb_start = lld_evt_schedule; + elt->ea_cb_cancel = lld_evt_canceled; + elt->ea_cb_stop = lld_evt_prevent_stop; + elt->stop_latency1 = '\0'; + elt->asap_settings = 0x6000; + if (CONCAT31(in_register_00002035,restart_pol) == 0) { + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = *(byte *)((int)&elt[2].ea_cb_cancel + 2) | 0x20; + } + uVar1 = ea_time_get_halfslot_rounded(); + elt->timestamp = uVar1; + return elt; +} + + + +void lld_evt_end(ea_elt_tag *elt) + +{ + byte bVar1; + ushort uVar2; + byte bVar3; + bool bVar4; + char "lld_evt_end" [12]; + uint uVar5; + uint32_t uVar6; + uint8_t rx_desc_cnt; + char cVar7; + bool bVar8; + char cVar9; + int iVar10; + ea_elt_tag *peVar11; + + iVar10 = (uint)*(ushort *)&elt[2].ea_cb_start * 0x5c; + uVar2 = *(ushort *)(iVar10 + 0x280080e2); + uVar5 = (uint)(*(ushort *)(iVar10 + 0x280080e4) >> 8) + + (uint)(*(ushort *)(iVar10 + 0x280080e2) >> 8) & 0xff; + if (((*(ushort *)(iVar10 + 0x280080e6) >> 7 & 1) != 0) && (uVar5 == 0)) { + bVar4 = true; +LAB_2302f740: + bVar8 = false; + goto LAB_2302f7e8; + } + bVar1 = *(byte *)((int)&elt[2].ea_cb_cancel + 2); + if ((bVar1 & 0x10) == 0) { + if ((bVar1 & 0x40) == 0) { + elt->current_prio = *(uint8_t *)((int)&elt[2].ea_cb_cancel + 1); + if (uVar5 == 0) goto LAB_2302f702; + goto LAB_2302f6ba; + } + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = bVar1 & 0xbf; + cVar7 = *(char *)((int)&elt[2].ea_cb_stop + 3); + cVar9 = '\x01'; + if (uVar5 == 0) { +LAB_2302f702: + cVar9 = *(char *)((int)&elt[2].ea_cb_stop + 3); + if (cVar9 != '\0') { + cVar7 = '\x01'; + goto LAB_2302f70a; + } + if ((llm_le_env.advertising_params)->adv_ldc_flag != false) goto LAB_2302f6ba; + } + else { +LAB_2302f70a: + if (cVar9 != cVar7) goto LAB_2302f6ba; + } + uVar6 = lld_evt_get_next_free_slot(); + elt->asap_settings = 0xa051; + peVar11 = elt[2].linked_element; + elt->timestamp = uVar6; + *(ea_elt_tag **)&elt->asap_limit = peVar11; + iVar10 = ea_elt_insert(elt); + if (iVar10 != 0) goto LAB_2302f6ba; + lld_evt_elt_wait_insert(elt); + bVar4 = false; + bVar8 = false; + if (uVar5 == 0) goto LAB_2302f740; + } + else { +LAB_2302f6ba: + bVar8 = true; + } + bVar4 = bVar8; + bVar1 = *(byte *)((int)&elt[2].ea_cb_stop + 2); + if (uVar5 < bVar1) { + printf("%s:rx_desc_cnt is less than evt->rx_cnt,assert!!!\r\n","lld_evt_end"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + bVar3 = (byte)uVar5; + lld_pdu_rx_handler((lld_evt_tag *)&elt->env,bVar3 - bVar1); + if (*(char *)((int)&elt[2].ea_cb_stop + 3) == '\x02') { + lld_evt_deferred_elt_push(elt,'\x02',bVar3 & 1); + } + else { + bVar1 = *(byte *)((int)&elt[2].ea_cb_stop + 2); + if (uVar5 < bVar1) { + rx_desc_cnt = '\0'; + } + else { + rx_desc_cnt = bVar3 - bVar1; + } + lld_evt_deferred_elt_push(elt,'\x01',rx_desc_cnt); + elt[2].stop_latency1 = + (byte)(*(ushort *) + (&DAT_280083d2 + + ((int)((uint)em_buf_env.rx_current + (uVar5 - 1)) % 8 & 0xffU) * 0xe) >> 4) & 1; + } + if (((*(char *)((int)&elt[2].ea_cb_stop + 3) == '\x01') && (*(char *)&elt[2].timestamp != '\0')) + && ((uVar2 & 0xff) != 0)) { + *(undefined *)((int)&elt[2].timestamp + 1) = 1; + } + *(undefined *)((int)&elt[2].ea_cb_stop + 2) = 0; + ble_ke_event_set('\b'); + bVar8 = true; +LAB_2302f7e8: + bVar1 = *(byte *)((int)&elt[2].ea_cb_cancel + 2); + if (((bVar1 & 0x30) == 0) && (bVar4)) { + iVar10 = lld_evt_restart(elt,0); + if (iVar10 != 0) { + lld_evt_elt_insert(elt,false); + return; + } + } + else { + if (((bVar1 & 0x10) != 0) && (!bVar8)) { + lld_evt_delete_elt_push(elt,true,true); + return; + } + } + return; +} + + + +void lld_evt_rx(ea_elt_tag *elt) + +{ + byte rx_desc_cnt; + + rx_desc_cnt = (byte)((ushort)*(undefined2 *) + ((uint)*(ushort *)&elt[2].ea_cb_start * 0x5c + 0x28008092) >> 8); + lld_pdu_rx_handler((lld_evt_tag *)&elt->env,rx_desc_cnt >> 4); + rx_desc_cnt = rx_desc_cnt >> 4; + *(char *)((int)&elt[2].ea_cb_stop + 2) = *(char *)((int)&elt[2].ea_cb_stop + 2) + rx_desc_cnt; + lld_evt_deferred_elt_push(elt,'\0',rx_desc_cnt); + ble_ke_event_set('\b'); + return; +} + + + +void lld_evt_rx_afs(ea_elt_tag *elt,uint8_t num) + +{ + byte bVar1; + undefined3 in_register_0000202d; + + bVar1 = *(byte *)((int)&elt[2].ea_cb_stop + 2); + if ((uint)bVar1 < CONCAT31(in_register_0000202d,num)) { + lld_pdu_rx_handler((lld_evt_tag *)&elt->env,num - bVar1); + *(uint8_t *)((int)&elt[2].ea_cb_stop + 2) = num; + lld_evt_deferred_elt_push(elt,'\0','\0'); + ble_ke_event_set('\b'); + return; + } + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void lld_evt_timer_isr(void) + +{ + ble_ke_event_set('\x03'); + return; +} + + + +void lld_evt_end_isr(_Bool apfm) + +{ + undefined3 in_register_00002029; + ea_elt_tag *elt; + + elt = (ea_elt_tag *)ble_co_list_pop_front((co_list *)&lld_evt_env); + ea_elt_remove(); + if (CONCAT31(in_register_00002029,apfm) == 0) { + if (elt->asap_settings >> 0xe != 0) { + elt->asap_settings = 0; + } + } + else { + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = *(byte *)((int)&elt[2].ea_cb_cancel + 2) | 0x40; + } + lld_evt_end(elt); + return; +} + + + +void lld_evt_rx_isr(void) + +{ + if (lld_evt_env.elt_prog.first != (co_list_hdr *)0x0) { + lld_evt_rx((ea_elt_tag *)lld_evt_env.elt_prog.first); + return; + } + return; +} + + + +void lld_evt_afs_isr(uint8_t num) + +{ + if (lld_evt_env.elt_prog.first != (co_list_hdr *)0x0) { + lld_evt_rx_afs((ea_elt_tag *)lld_evt_env.elt_prog.first,num); + return; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void lld_pdu_llcp_con_param_req_unpk(uint16_t pdu_ptr,uint8_t parlen,uint8_t *param) + +{ + undefined2 in_register_0000202a; + int iVar1; + undefined2 auStack34 [2]; + uint16_t res; + + iVar1 = CONCAT22(in_register_0000202a,pdu_ptr); + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + iVar1,2); + *(undefined2 *)(param + 2) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 2U & 0xffff),2); + *(undefined2 *)(param + 4) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 4U & 0xffff),2); + *(undefined2 *)(param + 6) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 6U & 0xffff),2); + *(undefined2 *)(param + 8) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 8U & 0xffff),1); + param[10] = (uint8_t)auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 9U & 0xffff),2); + *(undefined2 *)(param + 0xc) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0xbU & 0xffff),2); + *(undefined2 *)(param + 0xe) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0xdU & 0xffff),2); + *(undefined2 *)(param + 0x10) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0xfU & 0xffff),2); + *(undefined2 *)(param + 0x12) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0x11U & 0xffff),2); + *(undefined2 *)(param + 0x14) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0x13U & 0xffff),2); + *(undefined2 *)(param + 0x16) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0x15U & 0xffff),2); + *(undefined2 *)(param + 0x18) = auStack34[0]; + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void lld_pdu_llcp_con_param_rsp_unpk(uint16_t pdu_ptr,uint8_t parlen,uint8_t *param) + +{ + undefined2 in_register_0000202a; + int iVar1; + undefined2 auStack34 [2]; + uint16_t res; + + iVar1 = CONCAT22(in_register_0000202a,pdu_ptr); + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + iVar1,2); + *(undefined2 *)(param + 2) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 2U & 0xffff),2); + *(undefined2 *)(param + 4) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 4U & 0xffff),2); + *(undefined2 *)(param + 6) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 6U & 0xffff),2); + *(undefined2 *)(param + 8) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 8U & 0xffff),1); + param[10] = (uint8_t)auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 9U & 0xffff),2); + *(undefined2 *)(param + 0xc) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0xbU & 0xffff),2); + *(undefined2 *)(param + 0xe) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0xdU & 0xffff),2); + *(undefined2 *)(param + 0x10) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0xfU & 0xffff),2); + *(undefined2 *)(param + 0x12) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0x11U & 0xffff),2); + *(undefined2 *)(param + 0x14) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0x13U & 0xffff),2); + *(undefined2 *)(param + 0x16) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0x15U & 0xffff),2); + *(undefined2 *)(param + 0x18) = auStack34[0]; + return; +} + + + +void lld_pdu_llcp_length_req_unpk(uint16_t pdu_ptr,uint8_t parlen,uint8_t *param) + +{ + undefined2 in_register_0000202a; + int iVar1; + undefined2 auStack34 [2]; + uint16_t res; + + iVar1 = CONCAT22(in_register_0000202a,pdu_ptr); + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + iVar1,2); + *(undefined2 *)(param + 2) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 2U & 0xffff),2); + *(undefined2 *)(param + 4) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 4U & 0xffff),2); + *(undefined2 *)(param + 6) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 6U & 0xffff),2); + *(undefined2 *)(param + 8) = auStack34[0]; + return; +} + + + +void lld_pdu_llcp_length_rsp_unpk(uint16_t pdu_ptr,uint8_t parlen,uint8_t *param) + +{ + undefined2 in_register_0000202a; + int iVar1; + undefined2 auStack34 [2]; + uint16_t res; + + iVar1 = CONCAT22(in_register_0000202a,pdu_ptr); + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + iVar1,2); + *(undefined2 *)(param + 2) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 2U & 0xffff),2); + *(undefined2 *)(param + 4) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 4U & 0xffff),2); + *(undefined2 *)(param + 6) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 6U & 0xffff),2); + *(undefined2 *)(param + 8) = auStack34[0]; + return; +} + + + +uint8_t lld_pdu_pack(uint8_t *p_data,uint8_t *p_length,char *format) + +{ + byte bVar1; + undefined2 uVar2; + uint8_t *puVar3; + uint8_t *puVar4; + uint uVar5; + uint uVar6; + undefined2 *puVar7; + undefined4 *puVar8; + undefined4 uVar9; + undefined4 *puVar10; + + puVar3 = p_data; + puVar8 = (undefined4 *)p_data; + while( true ) { + while( true ) { + while( true ) { + puVar10 = puVar8; + puVar4 = puVar3; + if (*format == 0) { + *p_length = (char)puVar4 - (char)p_data; + return '\0'; + } + uVar6 = (uint)(byte)*format - 0x30; + uVar5 = 0; + if ((uVar6 & 0xff) < 10) { + while( true ) { + uVar5 = uVar6 & 0xffff; + format = (char *)((byte *)format + 1); + if (9 < ((uint)(byte)*format - 0x30 & 0xff)) break; + uVar6 = uVar5 * 10 + -0x30 + (uint)(byte)*format; + } + } + bVar1 = *format; + format = (char *)((byte *)format + 1); + if (bVar1 != 0x48) break; + puVar7 = (undefined2 *)((uint)((int)puVar10 + 1) & 0xfffffffe); + uVar2 = *puVar7; + *puVar4 = (uint8_t)uVar2; + puVar4[1] = (uint8_t)((ushort)uVar2 >> 8); + puVar3 = puVar4 + 2; + puVar8 = (undefined4 *)(puVar7 + 1); + } + if (bVar1 != 0x4c) break; + puVar8 = (undefined4 *)((uint)((int)puVar10 + 3) & 0xfffffffc); + uVar9 = *puVar8; + *puVar4 = (uint8_t)uVar9; + puVar4[1] = (uint8_t)((uint)uVar9 >> 8); + puVar4[2] = (uint8_t)((uint)uVar9 >> 0x10); + puVar4[3] = (uint8_t)((uint)uVar9 >> 0x18); + puVar3 = puVar4 + 4; + puVar8 = puVar8 + 1; + } + if (bVar1 != 0x42) break; + *puVar4 = *(uint8_t *)puVar10; + puVar3 = puVar4 + 1; + puVar8 = (undefined4 *)((int)puVar10 + 1); + if (1 < uVar5) { + (*ble_memcpy_ptr)(puVar4 + 1,(undefined4 *)((int)puVar10 + 1),uVar5 - 1); + puVar3 = puVar4 + uVar5; + puVar8 = (undefined4 *)((int)puVar10 + uVar5); + } + } + return '\x01'; +} + + +/* +Unable to decompile 'lld_pdu_tx_flush_list' +Cause: Exception while decompiling 2302feb2: Decompiler process died + +*/ + + +void lld_pdu_cntl_aligned_unpk(uint16_t pdu_ptr,uint8_t parlen,uint8_t *param) + +{ + undefined2 in_register_0000202a; + undefined3 in_register_0000202d; + + if (CONCAT31(in_register_0000202d,parlen) != 0) { + // WARNING: Could not recover jumptable at 0x2302ff40. Too many branches + // WARNING: Treating indirect jump as call + (*ble_memcpy_ptr)(param + 1,&DAT_28008000 + CONCAT22(in_register_0000202a,pdu_ptr), + CONCAT31(in_register_0000202d,parlen)); + return; + } + return; +} + + +/* +Unable to decompile 'lld_pdu_check' +Cause: Exception while decompiling 2302ff44: Decompiler process died + +*/ + +/* +Unable to decompile 'lld_pdu_tx_loop' +Cause: Exception while decompiling 23030120: Decompiler process died + +*/ + + +void lld_pdu_data_tx_push(lld_evt_tag *evt,em_desc_node *txnode,_Bool can_be_freed,_Bool encrypted) + +{ + undefined3 in_register_00002031; + undefined3 in_register_00002035; + int iVar1; + + iVar1 = (uint)*(byte *)&txnode->idx * 10; + *(undefined2 *)(&DAT_280082ca + iVar1) = 0; + if (CONCAT31(in_register_00002035,encrypted) != 0) { + txnode->length = txnode->length + '\x04'; + } + *(undefined2 *)(&DAT_280082cc + iVar1) = *(undefined2 *)&txnode->llid; + *(uint16_t *)(&DAT_280082ce + iVar1) = txnode->buffer_ptr; + if (CONCAT31(in_register_00002031,can_be_freed) != 0) { + *(uint16_t *)(&DAT_280082d2 + iVar1) = txnode->buffer_idx | 0x8000; + evt->evt[0x1c] = evt->evt[0x1c] + 1; + } + if (((evt->tx_prog).first == (co_list_hdr *)0x0) || + (*(uint16_t *)(&DAT_280082ca + (uint)*(ushort *)&(evt->tx_prog).last[1].next * 10) = + txnode->idx * 10 + 0x2ca | + *(ushort *)(&DAT_280082ca + (uint)*(ushort *)&(evt->tx_prog).last[1].next * 10) & 0x8000, + (evt->tx_prog).first == (co_list_hdr *)0x0)) { + *(em_desc_node **)&(evt->tx_prog).first = txnode; + } + else { + *(em_desc_node **)&((evt->tx_prog).last)->next = txnode; + } + *(em_desc_node **)&(evt->tx_prog).last = txnode; + (txnode->hdr).next = (co_list_hdr *)0x0; + return; +} + + +/* +Unable to decompile 'lld_pdu_data_send' +Cause: Exception while decompiling 2303021e: Decompiler process died + +*/ + +/* +Unable to decompile 'lld_pdu_tx_push' +Cause: Exception while decompiling 2303028a: Decompiler process died + +*/ + + +// WARNING: Type propagation algorithm not settling + +void lld_pdu_tx_prog(lld_evt_tag *param_1) + +{ + uint uVar1; + byte bVar2; + co_list_hdr list_hdr; + byte bVar3; + uint8_t opcode; + uint16_t uVar4; + undefined2 extraout_var_00; + em_desc_node *txnode; + undefined3 extraout_var; + _Bool encrypted; + co_list_hdr *pcVar5; + uint uVar6; + short sVar7; + ushort *puVar8; + int *piVar9; + uint uVar10; + uint uVar11; + uint uVar12; + co_list_hdr *p_data; + int iVar13; + uint uVar14; + uint uVar15; + byte abStack65 [13]; + + list_hdr = (co_list_hdr)(param_1->tx_llcp_pdu_rdy).first; + uVar12 = (uint)param_1->conhdl; + if ((list_hdr != (co_list_hdr)0x0) && (*(short *)(&DAT_280082ca + uVar12 * 10) < 0)) { + bVar2 = llc_env[uVar12]->encryption_state; + if ((bVar2 & 4) == 0) { +LAB_23030522: + ble_co_list_extract(¶m_1->tx_llcp_pdu_rdy,(co_list_hdr *)list_hdr,'\0'); + p_data = ((co_list_hdr *)list_hdr)[2].next; + if (((char *)lld_pdu_llcp_pk_desc_tab[*(byte *)&p_data->next].pack_fmt != (char *)0x0) && + (opcode = lld_pdu_pack((uint8_t *)p_data,abStack65, + (char *)lld_pdu_llcp_pk_desc_tab[*(byte *)&p_data->next].pack_fmt), + CONCAT31(extraout_var,opcode) == 0)) { + (*ble_memcpy_ptr)(&DAT_28008000 + + *(ushort *) + (&DAT_280082ce + (uint)*(ushort *)&((co_list_hdr *)list_hdr)[1].next * 10 + ),p_data,(uint)abStack65[0]); + ble_ke_free(((co_list_hdr *)list_hdr)[2].next); + if ((llc_env[uVar12]->encryption_state & 1) != 0) { + abStack65[0] = abStack65[0] + 4; + } + puVar8 = (ushort *)(&DAT_280082cc + uVar12 * 10); + *puVar8 = (ushort)abStack65[0] << 8 | *puVar8 & 0xff; + *puVar8 = *puVar8 & 0xfffc | 3; + *(undefined2 *)(&DAT_280082ca + (uint)param_1->conhdl * 10) = 0; + if ((param_1->tx_prog).first != (co_list_hdr *)0x0) { + *(ushort *)(&DAT_280082ca + (uint)*(ushort *)&(param_1->tx_prog).last[1].next * 10) = + *(short *)&((co_list_hdr *)list_hdr)[1].next * 10 + 0x2caU | + *(ushort *)(&DAT_280082ca + (uint)*(ushort *)&(param_1->tx_prog).last[1].next * 10) & + 0x8000; + } + ble_co_list_push_back(¶m_1->tx_prog,list_hdr); + param_1->evt[0x1c] = param_1->evt[0x1c] + 1; + } + } + else { + do { + opcode = *(uint8_t *)&((co_list_hdr *)((int)list_hdr + 0xc))->next; + if ((bVar2 & 0x20) == 0) { + bVar3 = llc_llcp_get_autorize(opcode); + bVar3 = bVar3 & 1; + } + else { + bVar3 = llc_llcp_get_autorize(opcode); + bVar3 = bVar3 & 2; + } + if (bVar3 != 0) goto LAB_23030522; + list_hdr = *(co_list_hdr *)list_hdr; + } while (list_hdr != (co_list_hdr)0x0); + } + } + bVar2 = 1; + if (param_1->conhdl < 2) { + bVar2 = (llc_env[uVar12]->encryption_state >> 2 ^ 1) & 1; + } + if (((param_1->tx_acl_rdy).first != (co_list_hdr *)0x0) && (bVar2 != 0)) { + if (param_1->conhdl < 2) { + uVar4 = ble_co_list_size((co_list *)&em_buf_env); + uVar11 = CONCAT22(extraout_var_00,uVar4); + p_data = (param_1->tx_acl_rdy).first; + if (p_data != (co_list_hdr *)0x0) { + bVar3 = llc_env[param_1->conhdl]->encryption_state; + pcVar5 = p_data->next; + (param_1->tx_acl_rdy).first = pcVar5; + if (pcVar5 == (co_list_hdr *)0x0) { + (param_1->tx_acl_rdy).last = (co_list_hdr *)0x0; + } + encrypted = (_Bool)(bVar3 & 1); + uVar1 = (uint)bVar3 & 1; + uVar10 = 0; + while( true ) { + iVar13 = (int)*(short *)&p_data[2].next; + uVar14 = (uint)*(ushort *)(param_1->evt + 0x16) & 0xff; + if ((uint)*(ushort *)(param_1->evt + 0x14) < + (iVar13 + 10 + ((uVar1 << 0x12) >> 0x10)) * 0x80000 >> 0x10) { + uVar6 = (int)((uint)*(ushort *)(param_1->evt + 0x14) + uVar1 * -0x20 + -0x50) >> 3; + if ((int)((uint)*(ushort *)(param_1->evt + 0x16) + uVar1 * -4) < (int)(uVar6 & 0xff)) { + uVar14 = uVar14 + uVar1 * -4 & 0xff; + } + else { + uVar14 = uVar6 & 0xff; + } + } + if ((int)uVar14 < iVar13) { + uVar14 = uVar14 & 0xfe; + } + uVar6 = (iVar13 + -1) / (int)uVar14 + 1U & 0xff; + if (uVar11 < uVar6) { + pcVar5 = (param_1->tx_acl_rdy).first; + if (pcVar5 == (co_list_hdr *)0x0) { + (param_1->tx_acl_rdy).last = p_data; + } + p_data->next = pcVar5; + (param_1->tx_acl_rdy).first = p_data; + goto LAB_2303066e; + } + uVar4 = 0; + uVar15 = 0; + bVar3 = bVar2; + while( true ) { + txnode = (em_desc_node *)ble_co_list_pop_front((co_list *)&em_buf_env); + if (bVar3 == 0) { + txnode->llid = '\x01'; + uVar15 = uVar14 + uVar15 & 0xffff; + } + else { + bVar3 = *(byte *)((int)&p_data[2].next + 2) & 3; + if (bVar3 != 1) { + bVar3 = 2; + } + txnode->llid = bVar3; + uVar15 = (uint)*(ushort *)((int)&p_data[3].next[1].next + 2); + uVar4 = *(uint16_t *)&p_data[3].next[1].next; + } + opcode = (uint8_t)uVar14; + if (iVar13 <= (int)uVar14) { + opcode = (uint8_t)iVar13; + } + txnode->length = opcode; + txnode->buffer_idx = uVar4; + txnode->buffer_ptr = (uint16_t)uVar15; + iVar13 = (int)((iVar13 - uVar14) * 0x10000) >> 0x10; + if (iVar13 < 1) break; + lld_pdu_data_tx_push(param_1,txnode,false,encrypted); + bVar3 = 0; + } + lld_pdu_data_tx_push(param_1,txnode,true,encrypted); + uVar10 = uVar10 + uVar6 & 0xff; + uVar11 = uVar11 - uVar6 & 0xffff; + if ((param_1->tx_acl_tofree).first == (co_list_hdr *)0x0) { + (param_1->tx_acl_tofree).first = p_data; + } + else { + ((param_1->tx_acl_tofree).last)->next = p_data; + } + (param_1->tx_acl_tofree).last = p_data; + p_data->next = (co_list_hdr *)0x0; + if (10 < uVar10) goto LAB_2303066e; + p_data = (param_1->tx_acl_rdy).first; + if (p_data == (co_list_hdr *)0x0) break; + pcVar5 = p_data->next; + (param_1->tx_acl_rdy).first = pcVar5; + if (pcVar5 == (co_list_hdr *)0x0) { + (param_1->tx_acl_rdy).last = (co_list_hdr *)0x0; + } + } + } + } + else { + ble_co_list_merge(¶m_1->tx_prog,¶m_1->tx_acl_rdy); + } + ble_co_list_init(¶m_1->tx_acl_rdy); + } +LAB_2303066e: + piVar9 = (int *)(param_1->tx_prog).first; + puVar8 = (ushort *)(uVar12 * 0x5c + 0x2800808e); + if (piVar9 == (int *)0x0) { + *puVar8 = *puVar8 & 0x1f | 0xf000; + sVar7 = 0; + } + else { + do { + if (-1 < *(short *)(&DAT_280082ca + (uint)*(ushort *)(piVar9 + 1) * 10)) { + sVar7 = *(ushort *)(piVar9 + 1) * 10 + 0x2ca; + goto LAB_230306ac; + } + piVar9 = (int *)*piVar9; + } while (piVar9 != (int *)0x0); + sVar7 = 0; +LAB_230306ac: + *puVar8 = *puVar8 & 0x1f | 0xf600; + } + *(short *)(uVar12 * 0x5c + 0x280080a4) = sVar7; + return; +} + + +/* +Unable to decompile 'lld_pdu_tx_flush' +Cause: Exception while decompiling 23030760: Decompiler process died + +*/ + + +uint8_t lld_pdu_adv_pack(uint8_t code,uint8_t *buf,uint8_t *p_len) + +{ + uint8_t uVar1; + undefined3 in_register_00002029; + + if ((char *)lld_pdu_adv_pk_desc_tab[CONCAT31(in_register_00002029,code)].pack_fmt != (char *)0x0) + { + uVar1 = lld_pdu_pack(buf,p_len, + (char *)lld_pdu_adv_pk_desc_tab[CONCAT31(in_register_00002029,code)]. + pack_fmt); + return uVar1; + } + return '\x02'; +} + + + +void lld_pdu_rx_handler(lld_evt_tag *evt,uint8_t nb_rx_desc) + +{ + uint8_t uVar1; + ushort uVar2; + ushort uVar3; + void *pvVar4; + byte *pbVar5; + undefined2 *puVar6; + ushort dest_id; + uint uVar7; + byte bVar8; + int iVar9; + llcp_pdu_unpk_func_t *plVar10; + uint8_t hdl; + uint uVar11; + byte *pbVar12; + + uVar11 = (uint)em_buf_env.rx_current; + do { + nb_rx_desc = nb_rx_desc + -1; + hdl = (uint8_t)uVar11; + if (nb_rx_desc == -1) { + em_buf_env.rx_current = hdl; + return; + } + if ((evt->evt_flag & 0x10) == 0) { + pvVar4 = ble_ke_malloc(0x10,'\0'); + iVar9 = uVar11 * 0xe; + dest_id = *(ushort *)(&DAT_280083d2 + iVar9); + *(uint8_t *)((int)pvVar4 + 4) = hdl; + *(uint16_t *)((int)pvVar4 + 6) = evt->conhdl; + uVar2 = *(ushort *)(iVar9 + 0x280083d0); + *(ushort *)((int)pvVar4 + 8) = uVar2; + uVar3 = *(ushort *)(iVar9 + 0x280083d4); + *(undefined *)((int)pvVar4 + 5) = 0; + *(byte *)((int)pvVar4 + 0xd) = (byte)(uVar3 >> 0xf); + *(byte *)((int)pvVar4 + 0xb) = (byte)((uint)uVar3 >> 8) & 0x3f; + *(undefined *)((int)pvVar4 + 0xc) = (char)uVar3; + if (((evt->evt_flag & 1) != 0) && ((uVar2 & 0x40) == 0)) { + evt->evt_flag = evt->evt_flag & 0xfe; + } + if (1 < (ushort)(*(short *)((int)pvVar4 + 6) - 2U)) { + *(undefined *)((int)pvVar4 + 10) = (char)((uint)dest_id >> 8); + if (((evt->evt_flag & 2) != 0) && ((*(ushort *)((int)pvVar4 + 8) & 1) == 0)) { + evt->evt_flag = evt->evt_flag & 0xfd; + llc_env[*(ushort *)((int)pvVar4 + 6)]->llc_status = + llc_env[*(ushort *)((int)pvVar4 + 6)]->llc_status | 0x100; + } + if (((*(ushort *)((int)pvVar4 + 8) & 0x13f) == 0) && (*(char *)((int)pvVar4 + 10) != '\0')) + { + uVar2 = *(ushort *)((int)pvVar4 + 6); + uVar7 = (uint)dest_id & 3; + if ((llc_env[(uint)uVar2]->encryption_state & 2) != 0) { + *(char *)((int)pvVar4 + 10) = *(char *)((int)pvVar4 + 10) + -4; + } + if ((dest_id & 3) != 0) { + if (uVar7 < 3) { + dest_id = uVar2 << 8 | 1; + puVar6 = (undefined2 *)ble_ke_msg_alloc(0x100,dest_id,dest_id,8); + *puVar6 = *(undefined2 *)((int)pvVar4 + 6); + bVar8 = *(byte *)((int)pvVar4 + 10); + *(char *)(puVar6 + 1) = (char)uVar7; + puVar6[2] = (ushort)bVar8; + *(undefined *)(puVar6 + 3) = *(undefined *)((int)pvVar4 + 4); + ble_ke_msg_send(); + goto LAB_23030a78; + } + if (uVar7 != 3) goto LAB_230309fe; + uVar7 = (uint)uVar2 << 8; + dest_id = (ushort)uVar7 | 1; + hdl = *(uint8_t *)((int)pvVar4 + 10); + pbVar5 = (byte *)ble_ke_msg_alloc(0x10a,dest_id,dest_id,0x1c); + pbVar12 = pbVar5 + 2; + dest_id = *(ushort *)(&DAT_280083d6 + (uint)*(byte *)((int)pvVar4 + 4) * 0xe); + (*ble_memcpy_ptr)(pbVar12,&DAT_28008000 + dest_id,1); + bVar8 = pbVar5[2]; + if (bVar8 < 0x16) { + uVar1 = lld_pdu_llcp_pk_desc_tab[bVar8].pdu_len; + if (uVar1 != hdl) { + bVar8 = 0x1e; + goto LAB_230309e6; + } + plVar10 = lld_pdu_llcp_pk_desc_tab[bVar8].unpack_func; + *pbVar5 = 0; + (*plVar10)(dest_id + 1,uVar1 + -1,pbVar12); + } + else { + bVar8 = 0x19; +LAB_230309e6: + *pbVar5 = bVar8; + } + llc_llcp_recv_handler(uVar7 & 0xffff | 1,(uint)*pbVar5,pbVar12,1); + ble_ke_msg_send(pbVar5); + } + } +LAB_230309fe: + em_buf_rx_free(*(uint8_t *)((int)pvVar4 + 4)); + *(undefined *)((int)pvVar4 + 5) = 1; + } +LAB_23030a78: + ble_co_list_push_back(0x42026448,pvVar4); + } + else { + em_buf_rx_free(hdl); + } + uVar11 = uVar11 + 1 & 7; + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_sleep_init(void) + +{ + uint32_t uVar1; + uint32_t uVar2; + uint32_t uVar3; + + (*ble_memset_ptr)(&lld_sleep_env,0,0x14); + uVar1 = rwip_us_2_lpcycles(5000); + uVar2 = rwip_us_2_lpcycles(5000); + uVar3 = rwip_us_2_lpcycles(0x271); + _DAT_2800003c = uVar3 & 0xffff | uVar1 << 0x15 | (uVar2 & 0xffff) << 10; + rwip_wakeup_delay_set(5000); + _DAT_28000030 = _DAT_28000030 & 0x7fffffff; + lld_sleep_env.last_sleep_dur = 0; + lld_sleep_env._8_2_ = 0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_sleep_wakeup(void) + +{ + uint32_t uVar1; + uint32_t lpcycles; + + _DAT_28000030 = _DAT_28000030 & 0x7fffffff; + if (lld_sleep_env.pds_reset == false) { + lpcycles = _DAT_28000038; + uVar1 = _DAT_28000038; + if (lld_sleep_env.sw_wakeup != false) { + lld_sleep_env._8_2_ = 0; + lpcycles = _DAT_28000038 - lld_sleep_env.last_sleep_dur; + uVar1 = lld_sleep_env.last_sleep_dur; + } + lld_sleep_env.last_sleep_dur = uVar1; + lpcycles = rwip_sleep_lpcycles_2_us(lpcycles); + _DAT_28000044 = (lpcycles + lld_evt_env.hw_wa_sleep_compensation) / 0x271; + _DAT_28000040 = + (_DAT_28000044 * 0x271 - (lpcycles + lld_evt_env.hw_wa_sleep_compensation)) + 0x270 & + 0xffff; + lld_evt_env.hw_wa_sleep_compensation = _DAT_28000040 == 0; + if ((bool)lld_evt_env.hw_wa_sleep_compensation) { + _DAT_28000044 = _DAT_28000044 + 1; + _DAT_28000040 = 0x270; + } + _DAT_2800000c = 1; + _DAT_28000018 = 1; + _DAT_28000030 = _DAT_28000030 | 8; + return; + } + _DAT_2800000c = 1; + _DAT_28000018 = 1; + _DAT_28000030 = _DAT_28000030 | 8; + _DAT_28000040 = lld_sleep_env.finetimecnt; + _DAT_28000044 = lld_sleep_env.basetimecnt; + lld_sleep_env._8_2_ = 0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_sleep_wakeup_end(void) + +{ + _DAT_2800000c = lld_sleep_env.irq_mask; + return; +} + + + +uint16_t lld_util_instant_get(void *event,uint8_t action) + +{ + uint16_t uVar1; + + *(uint8_t *)((int)event + 0x45) = action; + uVar1 = (uint16_t) + (((uint)*(ushort *)((int)event + 0x36) * 6 + (uint)*(ushort *)((int)event + 0x38)) * + 0x10000 >> 0x10); + *(uint16_t *)((int)event + 0x34) = uVar1; + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_util_set_bd_address(bd_addr *bd_addr,uint8_t type) + +{ + undefined3 in_register_0000202d; + + _DAT_28000024 = *(undefined4 *)bd_addr->addr; + _DAT_28000028 = + (uint)*(ushort *)(bd_addr->addr + 4) | _DAT_28000028 & 0xfffe0000 | + CONCAT31(in_register_0000202d,type) << 0x10; + return; +} + + + +uint8_t lld_util_freq2chnl(uint8_t freq) + +{ + char cVar1; + undefined3 in_register_00002029; + uint uVar2; + + uVar2 = CONCAT31(in_register_00002029,freq); + if (uVar2 == 0xc) { + return '&'; + } + if (uVar2 != 0x27) { + if (uVar2 != 0) { + if (uVar2 < 0xc) { + cVar1 = -1; + } + else { + cVar1 = -2; + } + return freq + cVar1; + } + freq = '%'; + } + return freq; +} + + + +uint16_t lld_util_get_local_offset(uint16_t PeerOffset,uint16_t Interval,uint32_t AnchorPoint) + +{ + undefined2 in_register_0000202a; + undefined2 in_register_0000202e; + + return (uint16_t) + ((int)(CONCAT22(in_register_0000202a,PeerOffset) + + AnchorPoint % CONCAT22(in_register_0000202e,Interval)) % + CONCAT22(in_register_0000202e,Interval)); +} + + + +uint16_t lld_util_get_peer_offset(uint16_t LocalOffset,uint16_t Interval,uint32_t AnchorPoint) + +{ + undefined2 in_register_0000202a; + undefined2 in_register_0000202e; + uint uVar1; + + uVar1 = CONCAT22(in_register_0000202e,Interval); + return (uint16_t) + ((int)((CONCAT22(in_register_0000202a,LocalOffset) + uVar1) - AnchorPoint % uVar1) % uVar1) + ; +} + + + +void lld_util_connection_param_set(ea_elt_tag *elt,ea_param_output *param) + +{ + ushort uVar1; + uint uVar2; + ushort uVar3; + + uVar3 = param->interval; + uVar2 = (uint)uVar3 - (uint)elt->start_latency; + if (uVar2 < param->duration) { + param->duration = uVar2; + } + if (param->duration == 0) { + param->duration = 2; + } + uVar1 = param->offset; + param->duration = param->duration * 0x271; + uVar2 = elt->timestamp % (uint)uVar3; + if (uVar1 < uVar2) { + uVar3 = (uVar3 + uVar1) - (short)uVar2; + } + else { + if ((uVar2 != 0) || (uVar1 != 0)) { + uVar3 = uVar1 - (short)uVar2; + } + } + param->offset = uVar3; + return; +} + + + +void lld_util_dle_set_cs_fields(uint16_t conhdl) + +{ + undefined2 in_register_0000202a; + int iVar1; + + iVar1 = CONCAT22(in_register_0000202a,conhdl) * 0x5c; + *(ushort *)(&DAT_280080b0 + iVar1) = + *(ushort *)(&DAT_280080b0 + iVar1) & 0xff00 | + (ushort)*(byte *)&(llc_env[CONCAT22(in_register_0000202a,conhdl)]->data_len_ext_info). + conn_eff_max_rx_octets; + *(uint16_t *)(iVar1 + 0x280080b2) = + (llc_env[CONCAT22(in_register_0000202a,conhdl)]->data_len_ext_info).conn_eff_max_rx_time; + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void lld_util_anchor_point_move(ea_elt_tag *elt_connect) + +{ + short sVar1; + undefined2 uVar2; + ushort uVar3; + uint8_t uVar4; + undefined3 extraout_var; + undefined *puVar5; + uint uVar6; + ushort uStack52; + ea_param_output set_param; + ea_param_input input_param; + + set_param.duration._0_2_ = 0; + uStack52 = *(ushort *)&elt_connect[2].ea_cb_stop; + set_param._0_4_ = (int)((uint)elt_connect->duration_min + 0x270) / 0x271; + uVar4 = ea_offset_req((ea_param_input *)&set_param.offset,(ea_param_output *)&uStack52); + if (CONCAT31(extraout_var,uVar4) == 0) { + puVar5 = (undefined *) + ble_ke_msg_alloc(0x109,*(short *)&elt_connect[2].ea_cb_start << 8 | 1,2,0x22); + *puVar5 = 1; + uVar6 = (uint)uStack52; + uVar3 = uStack52 >> 1; + *(ushort *)(puVar5 + 2) = uVar3; + *(ushort *)(puVar5 + 4) = uVar3; + *(ushort *)(puVar5 + 0xe) = uVar3; + *(ushort *)(puVar5 + 0x10) = uVar3; + sVar1 = *(short *)((int)&elt_connect[2].linked_element + 2); + puVar5[0x12] = 0; + *(short *)(puVar5 + 6) = sVar1 + -1; + *(undefined2 *)(puVar5 + 8) = 3000; + uVar2 = *(undefined2 *)&elt_connect[2].timestamp; + *(undefined2 *)(puVar5 + 0x14) = uVar2; + *(undefined2 *)(puVar5 + 10) = uVar2; + *(undefined2 *)(puVar5 + 0xc) = *(undefined2 *)&elt_connect[2].timestamp; + *(short *)(puVar5 + 0x16) = + (short)(((int)(((ushort)set_param.duration + uVar6) - elt_connect->timestamp % uVar6) % + uVar6 & 0xffffU) >> 1); + *(undefined2 *)(puVar5 + 0x18) = 0xffff; + *(undefined2 *)(puVar5 + 0x1a) = 0xffff; + *(undefined2 *)(puVar5 + 0x1c) = 0xffff; + *(undefined2 *)(puVar5 + 0x1e) = 0xffff; + *(undefined2 *)(puVar5 + 0x20) = 0xffff; + ble_ke_msg_send(); + } + return; +} + + + +void lld_util_flush_list(co_list *list) + +{ + co_list_hdr *mem_ptr; + + while (mem_ptr = ble_co_list_pop_front(list), mem_ptr != (co_list_hdr *)0x0) { + ble_ke_free(mem_ptr); + } + return; +} + + + +_Bool lld_util_instant_ongoing(ea_elt_tag *elt) + +{ + return (_Bool)(*(char *)((int)&elt[2].delay + 1) != '\0'); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_util_compute_ce_max(ea_elt_tag *elt,uint16_t tx_time,uint16_t rx_time) + +{ + undefined2 in_register_0000202e; + int iVar1; + uint uVar2; + int iVar3; + ushort *puVar4; + uint uVar5; + + iVar1 = (uint)*(ushort *)&elt[2].ea_cb_start * 0x5c; + if (*(char *)((int)&elt[2].ea_cb_stop + 3) == '\x03') { + uVar2 = _DAT_28000000 >> 4 & 0xf; + } + else { + uVar2 = (uint)*(ushort *)(iVar1 + 0x280080a2); + if ((short)*(ushort *)(iVar1 + 0x280080a2) < 0) { + iVar3 = ((uVar2 << 0x11) >> 0x12) * 0x271; + goto LAB_23030ebe; + } + } + iVar3 = (int)uVar2 >> 1; +LAB_23030ebe: + uVar2 = CONCAT22(in_register_0000202e,tx_time) + 0x15c; + if ((*(ushort *)(iVar1 + 0x28008092) & 0x200) != 0) { + uVar2 = CONCAT22(in_register_0000202e,tx_time) + 0x17c; + } + uVar5 = ((((((uint)*(ushort *)&elt[2].ea_cb_stop - (uint)elt->start_latency) + -1) * 0x271 - iVar3 + ) / uVar2) * uVar2 - (uVar2 >> 1)) / 0x271; + if (0x96 < (int)((uVar2 - 0x271) * uVar5)) { + uVar5 = uVar5 - 1; + } + *(ushort *)(iVar1 + 0x280080a8) = (ushort)uVar5; + puVar4 = (ushort *)((uint)*(ushort *)&elt[2].ea_cb_start * 0x5c + 0x280080a6); + if (uVar5 < *puVar4) { + *puVar4 = (ushort)uVar5; + } + return; +} + + + +void lld_util_priority_set(ea_elt_tag *elt,uint8_t priority_index) + +{ + undefined3 in_register_0000202d; + uint8_t uVar1; + + switch(CONCAT31(in_register_0000202d,priority_index)) { + case 0: + uVar1 = '\x05'; + break; + case 1: + uVar1 = '\x05'; + break; + case 2: + uVar1 = '\x14'; + break; + case 3: + uVar1 = '\n'; + break; + case 4: + uVar1 = '\x0f'; + break; + case 5: + if ((llm_le_env.advertising_params)->adv_ldc_flag != false) goto switchD_23030f46_caseD_7; + case 6: + uVar1 = '\n'; + break; + default: +switchD_23030f46_caseD_7: + uVar1 = '\x05'; + } + elt->current_prio = uVar1; + *(uint8_t *)((int)&elt[2].ea_cb_cancel + 1) = uVar1; + return; +} + + + +uint8_t lld_util_get_tx_pkt_cnt(ea_elt_tag *elt) + +{ + return elt[2].stop_latency2; +} + + + +void lld_util_eff_tx_time_set(ea_elt_tag *elt,uint16_t max_tx_time,uint16_t max_tx_size) + +{ + elt[2].asap_settings = max_tx_time; + elt[2].duration_min = max_tx_size; + return; +} + + + +// WARNING: Could not reconcile some variable overlaps +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_init(_Bool reset) + +{ + _Bool _Var1; + undefined3 in_register_00002029; + undefined3 extraout_var; + bd_addr *pbVar2; + anon_subr_void_ptr_void_ptr_void_ptr_uint *paVar3; + undefined2 *puVar4; + undefined4 uStack24; + bd_addr bd_addr; + + if (CONCAT31(in_register_00002029,reset) == 0) { + ble_ke_task_create('\x02',&TASK_DESC_LLD); + } + _DAT_280000f0 = _DAT_280000f0 & 0xfc00fe00 | 0x1b800d2; + _DAT_2800000c = 0x1033a; + _DAT_28000000 = _DAT_28000000 & 0xffcfff0f | 0xe0; + _Var1 = co_bdaddr_compare(&co_null_bdaddr,&co_default_bdaddr); + if (CONCAT31(extraout_var,_Var1) == 0) { + pbVar2 = &co_default_bdaddr; + paVar3 = ble_memcpy_ptr; + } + else { + pbVar2 = (bd_addr *)0x7; + paVar3 = (anon_subr_void_ptr_void_ptr_void_ptr_uint *)ble_memset_ptr; + } + (*paVar3)(&uStack24,pbVar2,6); + ecc_gen_new_secret_key(llm_le_env.secret_key256,false); + _DAT_28000024 = uStack24; + _DAT_28000028 = (uint)bd_addr.addr._0_2_; + _DAT_28000000 = _DAT_28000000 | 0x200; + _DAT_28000090 = 7; + _DAT_280000b0 = 0x1fe; + _DAT_280000b4 = 0x216; + _DAT_280000b8 = 0x404; + _DAT_28000120 = 0x22e; + _DAT_28000124 = 3; + puVar4 = (undefined2 *)&DAT_28008000; + _DAT_2800814c = 0xbed6; + _DAT_2800814e = 0x8e89; + _DAT_28008150 = 0x5555; + _DAT_28008152 = 0x55; + _DAT_28008162 = 0; + _DAT_28008164 = 0; + _DAT_28008166 = 0; + _DAT_280081a8 = 0xbed6; + _DAT_280081aa = 0x8e89; + _DAT_280081ac = 0x5555; + _DAT_280081ae = 0x55; + _DAT_280081be = 0; + _DAT_280081c0 = 0; + _DAT_280081c2 = 0; + _DAT_28008168 = 0; + _DAT_2800816a = 0; + _DAT_280081c4 = 0; + _DAT_280081c6 = 0; + _DAT_2800002c = 0x3ce; + _DAT_28008158 = (ushort)rwip_rf.txpwr_max; + _DAT_2800814a = _DAT_2800814a & 0xfff | 0x2000; + _DAT_2800819e = _DAT_2800819e & 0xff7f; + _DAT_28008154 = 0; + _DAT_280081b4 = (ushort)rwip_rf.txpwr_max; + _DAT_280081a6 = _DAT_280081a6 & 0xfff | 0x2000; + _DAT_280081fa = _DAT_280081fa & 0xff7f; + _DAT_280081b0 = 0; + _DAT_28008194 = 0; + _DAT_28008196 = 0; + _DAT_28008198 = 0; + _DAT_2800819a = 0; + _DAT_2800819c = 0; + _DAT_280081f0 = 0; + _DAT_280081f2 = 0; + _DAT_280081f4 = 0; + _DAT_280081f6 = 0; + _DAT_280081f8 = 0; + do { + *puVar4 = 0; + puVar4[1] = 0; + puVar4 = puVar4 + 2; + } while (puVar4 != (undefined2 *)0x28008040); + lld_evt_init(CONCAT31(in_register_00002029,reset)); + lld_sleep_init(); + _DAT_28008146 = _DAT_28008146 & 0xf8ff; + _DAT_280081a2 = _DAT_280081a2 & 0xf8ff; + lld_wlcoex_set(1); + _DAT_28000000 = _DAT_28000000 | 0x100; + _DAT_280000e0 = _DAT_280000e0 & 0xffffefff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_core_reset(void) + +{ + undefined2 *puVar1; + + do { + } while ((int)(_DAT_28000000 & 0xfffffeff | 0x80000000) < 0); + _DAT_28000000 = _DAT_28000000 & 0xbffffeff | 0xc0000000; + do { + } while ((int)(_DAT_28000000 << 1) < 0); + puVar1 = (undefined2 *)&DAT_28008000; + do { + *puVar1 = 0; + puVar1[1] = 0; + puVar1 = puVar1 + 2; + } while (puVar1 != (undefined2 *)0x28008040); + _DAT_28008146 = _DAT_28008146 & 0xf8ff; + _DAT_280081a2 = _DAT_280081a2 & 0xf8ff; + lld_wlcoex_set(1); + _DAT_2800000c = 0; + _DAT_28000018 = 0xffffffff; + return; +} + + +/* +Unable to decompile 'lld_adv_start' +Cause: Exception while decompiling 23031358: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_adv_stop(ea_elt_tag *elt) + +{ + _Bool _Var1; + undefined3 extraout_var; + + _Var1 = lld_evt_elt_delete(elt,true,true); + if (CONCAT31(extraout_var,_Var1) == 0) { + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = *(byte *)((int)&elt[2].ea_cb_cancel + 2) | 0x10; + _DAT_28000000 = _DAT_28000000 | 0x2000000; + } + return; +} + + +/* +Unable to decompile 'lld_scan_start' +Cause: Exception while decompiling 23031548: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_scan_stop(ea_elt_tag *elt) + +{ + _Bool _Var1; + undefined3 extraout_var; + + _Var1 = lld_evt_elt_delete(elt,true,true); + if (CONCAT31(extraout_var,_Var1) == 0) { + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = *(byte *)((int)&elt[2].ea_cb_cancel + 2) | 0x10; + _DAT_28000000 = _DAT_28000000 | 0x1000000; + } + return; +} + + +/* +Unable to decompile 'lld_con_start' +Cause: Exception while decompiling 230316f4: Decompiler process died + +*/ + + +ea_elt_tag * +lld_move_to_master(ea_elt_tag *elt,uint16_t conhdl,llc_create_con_req_ind *param,uint8_t rx_hdl) + +{ + int iVar1; + ea_elt_tag *elt_00; + undefined2 in_register_0000202e; + undefined3 in_register_00002035; + ushort *puVar2; + + elt_00 = lld_evt_move_to_master(elt,conhdl,param,rx_hdl); + iVar1 = CONCAT22(in_register_0000202e,conhdl) * 0x5c; + *(ushort *)(&DAT_2800809e + iVar1) = + (ushort)(((uint)(*(ushort *)(&DAT_280083d2 + CONCAT31(in_register_00002035,rx_hdl) * 0xe) >> + 5) & 1) << 0xe) | *(ushort *)(&DAT_2800809e + iVar1) & 0xbfff; + lld_util_eff_tx_time_set(elt_00,0x148,0x1b); + lld_util_compute_ce_max(elt_00,0x148,0x148); + *(undefined2 *)(iVar1 + 0x280080a6) = *(undefined2 *)(iVar1 + 0x280080a8); + *(ushort *)(&DAT_280082ca + CONCAT22(in_register_0000202e,conhdl) * 10) = + (ushort)(((uint)*(ushort *)(&DAT_280082ca + CONCAT22(in_register_0000202e,conhdl) * 10) << + 0x11) >> 0x11) | 0x8000; + puVar2 = (ushort *)(iVar1 + 0x28008092); + *puVar2 = *puVar2 & 0xfeff; + *puVar2 = *puVar2 & 0xfdff; + *puVar2 = *puVar2 & 0xfbff; + *(undefined2 *)(iVar1 + 0x2800809c) = 0; + *(undefined2 *)(iVar1 + 0x280080cc) = 0; + *(undefined2 *)(iVar1 + 0x280080ce) = 0; + *(undefined2 *)(iVar1 + 0x280080d0) = 0; + *(undefined2 *)(iVar1 + 0x280080d2) = 0; + *(undefined2 *)(iVar1 + 0x280080d4) = 0; + *(undefined2 *)(iVar1 + 0x280080d6) = 0; + *(undefined2 *)(iVar1 + 0x280080d8) = 0; + *(undefined2 *)(iVar1 + 0x280080a4) = 0; + *puVar2 = *puVar2 & 0xf7ff; + lld_evt_elt_insert(elt_00,true); + return elt_00; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void lld_con_update_req(ea_elt_tag *elt_old,llc_con_upd_req_ind *param,llcp_con_upd_ind *param_pdu) + +{ + ea_elt_tag *peVar1; + uint16_t ce_len; + uint16_t uStack24; + uint16_t uStack22; + lld_evt_update_tag upd_par; + + _ce_len = (uint)param->ce_len_min + 1 & 0xfffffffe; + ce_len = (uint16_t)_ce_len; + if (_ce_len < 2) { + ce_len = 2; + } + peVar1 = lld_evt_update_create + (elt_old,ce_len,(uint16_t)(((uint)param->interval_min << 0x11) >> 0x10), + (uint16_t)(((uint)param->interval_max << 0x11) >> 0x10),param->con_latency, + param->pref_period,(lld_evt_update_tag *)&uStack24); + param_pdu->timeout = param->superv_to; + param_pdu->interv = *(ushort *)&peVar1[2].ea_cb_stop >> 1; + param_pdu->latency = param->con_latency; + param_pdu->win_size = (uint8_t)upd_par.win_offset; + param_pdu->win_off = uStack24; + param_pdu->instant = uStack22; + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +uint8_t lld_con_update_after_param_req + (uint16_t conhdl,ea_elt_tag *elt_old,llc_con_upd_req_ind *param, + llcp_con_upd_ind *param_pdu,_Bool bypass_offchk) + +{ + ushort uVar1; + int iVar2; + uint8_t uVar3; + uint16_t uVar4; + undefined2 in_register_0000202a; + ea_elt_tag *elt; + undefined2 extraout_var_01; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint uVar5; + undefined3 in_register_00002039; + uint uVar6; + uint uVar7; + uint uVar8; + uint uVar9; + llc_env_tag *plVar10; + uint16_t uVar11; + uint uVar12; + uint uVar13; + uint16_t local_54; + ea_param_output set_param; + ea_param_input input_param; + + set_param.offset = param->interval_min << 1; + set_param._10_2_ = param->interval_max << 1; + uVar4 = param->offset0; + ea_interval_duration_req((ea_param_input *)&set_param.offset,(ea_param_output *)&local_54); + if (param->offset0 != 0xffff) { + uVar6 = (uint)*(ushort *)&elt_old[2].timestamp; + uVar8 = (uint)param->ref_con_event_count; + if (uVar8 < uVar6) { + iVar2 = -((uVar6 - uVar8) * (uint)*(ushort *)&elt_old[2].ea_cb_stop); + } + else { + iVar2 = (uVar8 - uVar6) * (uint)*(ushort *)&elt_old[2].ea_cb_stop; + } + lld_util_get_local_offset + ((uint16_t)(((uint)param->offset0 << 0x11) >> 0x10),local_54, + elt_old->timestamp + iVar2); + } + if (((uVar4 == 0xffff) || + (uVar3 = ea_offset_req((ea_param_input *)&set_param.offset,(ea_param_output *)&local_54), + CONCAT31(extraout_var,uVar3) == 0)) || + (uVar3 = ea_offset_req((ea_param_input *)&set_param.offset,(ea_param_output *)&local_54), + CONCAT31(extraout_var_00,uVar3) == 0)) { + uVar3 = '\0'; + } + else { + uVar3 = '\x1f'; + if (CONCAT31(in_register_00002039,bypass_offchk) == 0) { + return '\x1f'; + } + } + elt = ea_elt_create(0x58); + if (elt != (ea_elt_tag *)0x0) { + (*ble_memcpy_ptr)(elt,elt_old,0x2c); + lld_evt_init_evt((lld_evt_tag *)&elt->env); + *(short *)((int)&elt[2].linked_element + 2) = param->con_latency + 1; + *(undefined *)((int)&elt[2].ea_cb_stop + 3) = 3; + *(uint16_t *)&elt[2].ea_cb_stop = local_54; + uVar6 = (uint)param->offset0; + if (param->offset0 == 0xffff) { + uVar4 = lld_util_get_peer_offset((uint16_t)set_param.duration,local_54,elt_old->timestamp); + uVar1 = *(ushort *)&elt_old[2].timestamp; + uVar6 = CONCAT22(extraout_var_01,uVar4) >> 1 & 0xffff; + } + else { + uVar1 = param->ref_con_event_count; + } + uVar9 = (uint)uVar1; + uVar8 = (uint)*(ushort *)&elt_old[2].ea_cb_stop; + uVar7 = (uint)*(ushort *)((int)&elt_old[2].linked_element + 2) * 0x70000 >> 0x10; + uVar12 = ((uint)*(ushort *)&elt_old[2].timestamp - 1) + uVar7; + uVar13 = uVar12 & 0xffff; + uVar5 = (uint)*(ushort *)&elt[2].ea_cb_stop; + if (uVar13 < uVar9) { + iVar2 = (uVar9 - uVar13) * uVar8 + uVar6 * 2; + } + else { + iVar2 = uVar5 - (int)((uVar13 - uVar9) * uVar8 + uVar6 * -2) % uVar5; + } + uVar6 = iVar2 % uVar5 & 0xffff; + elt->timestamp = uVar6 + ((uVar7 - 1) * uVar8 + elt_old->timestamp & 0x7ffffff) & 0x7ffffff; + elt_old->linked_element = elt; + plVar10 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + uVar11 = (uint16_t)(uVar12 * 0x10000 >> 0x10); + *(uint16_t *)&elt_old[2].linked_element = uVar11; + *(undefined *)((int)&elt_old[2].delay + 1) = 1; + lld_util_compute_ce_max + (elt,(plVar10->data_len_ext_info).conn_eff_max_tx_time, + (plVar10->data_len_ext_info).conn_eff_max_rx_time); + iVar2 = (uint)*(ushort *)&elt_old[2].ea_cb_start * 0x5c; + *(undefined2 *)(iVar2 + 0x280080a6) = *(undefined2 *)(iVar2 + 0x280080a8); + param_pdu->timeout = param->superv_to; + param_pdu->interv = *(ushort *)&elt[2].ea_cb_stop >> 1; + uVar4 = param->con_latency; + param_pdu->win_size = '\x01'; + param_pdu->win_off = (uint16_t)(uVar6 >> 1); + param_pdu->latency = uVar4; + param_pdu->instant = uVar11; + } + return uVar3; +} + + + +// WARNING: Variable defined which should be unmapped: input_param +// WARNING: Could not reconcile some variable overlaps + +uint8_t lld_con_param_rsp(uint16_t conhdl,ea_elt_tag *elt,llc_con_upd_req_ind *param) + +{ + uint8_t uVar1; + uint16_t uVar2; + undefined3 extraout_var; + undefined2 extraout_var_00; + uint uVar3; + uint uVar4; + int iVar5; + uint16_t local_34; + ea_param_output set_param; + ea_param_input input_param; + + set_param.offset = param->interval_min << 1; + set_param._10_2_ = param->interval_max << 1; + ea_interval_duration_req((ea_param_input *)&set_param.offset,(ea_param_output *)&local_34); + if (param->offset0 != 0xffff) { + uVar3 = (uint)*(ushort *)&elt[2].timestamp; + uVar4 = (uint)param->ref_con_event_count; + if (uVar4 < uVar3) { + iVar5 = -((uVar3 - uVar4) * (uint)*(ushort *)&elt[2].ea_cb_stop); + } + else { + iVar5 = (uVar4 - uVar3) * (uint)*(ushort *)&elt[2].ea_cb_stop; + } + lld_util_get_local_offset + ((uint16_t)(((uint)param->offset0 << 0x11) >> 0x10),local_34,elt->timestamp + iVar5); + } + uVar1 = ea_offset_req((ea_param_input *)&set_param.offset,(ea_param_output *)&local_34); + if (CONCAT31(extraout_var,uVar1) == 0) { + param->pref_period = '\0'; + param->interval_min = local_34 >> 1; + param->interval_max = local_34 >> 1; + if (param->offset0 == 0xffff) { + uVar2 = lld_util_get_peer_offset((uint16_t)set_param.duration,local_34,elt->timestamp); + param->offset0 = (uint16_t)(CONCAT22(extraout_var_00,uVar2) >> 1); + param->ref_con_event_count = *(uint16_t *)&elt[2].timestamp; + } + param->offset1 = 0xffff; + param->offset2 = 0xffff; + param->offset3 = 0xffff; + param->offset4 = 0xffff; + param->offset5 = 0xffff; + } + else { + uVar1 = '\x1f'; + } + return uVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void lld_con_param_req(uint16_t conhdl,ea_elt_tag *elt,llc_con_upd_req_ind *param) + +{ + ushort Interval; + uint8_t uVar1; + uint16_t uVar2; + undefined3 extraout_var; + undefined2 extraout_var_00; + uint uVar3; + uint uVar4; + ushort local_34; + ea_param_output set_param; + ea_param_input input_param; + + set_param.offset = param->con_intv_min << 1; + set_param._10_2_ = param->con_intv_max << 1; + ea_interval_duration_req((ea_param_input *)&set_param.offset,(ea_param_output *)&local_34); + uVar3 = (uint)local_34; + uVar4 = elt->timestamp; + uVar1 = ea_offset_req((ea_param_input *)&set_param.offset,(ea_param_output *)&local_34); + Interval = set_param._10_2_; + if (CONCAT31(extraout_var,uVar1) == 0) { + Interval = local_34; + } + param->interval_min = Interval >> 1; + param->interval_max = Interval >> 1; + uVar2 = lld_util_get_peer_offset((uint16_t)(uVar4 % uVar3),Interval,elt->timestamp); + param->offset0 = (uint16_t)(CONCAT22(extraout_var_00,uVar2) >> 1); + param->pref_period = '\0'; + param->ref_con_event_count = *(short *)&elt[2].timestamp + 2; + param->offset1 = 0xffff; + param->offset2 = 0xffff; + param->offset3 = 0xffff; + param->offset4 = 0xffff; + param->offset5 = 0xffff; + return; +} + + + +void lld_con_stop(ea_elt_tag *elt) + +{ + lld_evt_delete_elt_push(elt,true,true); + return; +} + + + +uint8_t lld_get_mode(uint16_t conhdl) + +{ + uint8_t uVar1; + undefined2 in_register_0000202a; + int iVar2; + ea_elt_tag *peVar3; + + iVar2 = CONCAT22(in_register_0000202a,conhdl); + peVar3 = llm_le_env.elt; + if ((iVar2 != 2) && (peVar3 = llm_le_env.elt_coext_scan, iVar2 != 3)) { + if (llc_env[iVar2] == (llc_env_tag *)0x0) { + return '\b'; + } + peVar3 = llc_env[iVar2]->elt; + } + uVar1 = '\b'; + if (peVar3 != (ea_elt_tag *)0x0) { + uVar1 = *(uint8_t *)((int)&peVar3[2].ea_cb_stop + 3); + } + return uVar1; +} + + + +ea_elt_tag * +lld_move_to_slave(llc_create_con_req_ind *con_par,llm_pdu_con_req_rx *con_req_pdu, + ea_elt_tag *elt_adv,uint16_t conhdl,uint8_t rx_hdl) + +{ + int iVar1; + uint8_t uVar2; + ea_elt_tag *elt; + undefined2 in_register_00002036; + undefined3 in_register_00002039; + ushort *puVar3; + + iVar1 = CONCAT22(in_register_00002036,conhdl) * 0x5c; + *(undefined2 *)(iVar1 + 0x2800808e) = 3; + puVar3 = (ushort *)(iVar1 + 0x28008092); + *(ushort *)(&DAT_280082ca + CONCAT22(in_register_00002036,conhdl) * 10) = + *(ushort *)(&DAT_280082ca + CONCAT22(in_register_00002036,conhdl) * 10) & 0x7fff | 0x8000; + *(ushort *)(&DAT_2800809e + iVar1) = + (ushort)(((uint)(*(ushort *)(&DAT_280083d2 + CONCAT31(in_register_00002039,rx_hdl) * 0xe) >> + 5) & 1) << 0xe) | ((ushort)con_req_pdu->hop_sca & 0x1f) << 8 | 0x8000; + *(undefined2 *)(iVar1 + 0x28008094) = *(undefined2 *)(con_req_pdu->aa).addr; + *(undefined2 *)(iVar1 + 0x28008096) = *(undefined2 *)((con_req_pdu->aa).addr + 2); + *(undefined2 *)(iVar1 + 0x28008098) = *(undefined2 *)(con_req_pdu->crcinit).crc; + *(ushort *)(iVar1 + 0x2800809a) = (ushort)(con_req_pdu->crcinit).crc[2]; + *(ushort *)(iVar1 + 0x280080a0) = (ushort)rwip_rf.txpwr_max; + *puVar3 = (ushort)(((uint)*puVar3 << 0x14) >> 0x14) | 0x2000; + *puVar3 = *puVar3 & 0xffe0 | conhdl & 0x1f; + *(undefined2 *)(iVar1 + 0x280080aa) = *(undefined2 *)(con_req_pdu->chm).map; + *(undefined2 *)(iVar1 + 0x280080ac) = *(undefined2 *)((con_req_pdu->chm).map + 2); + uVar2 = llm_util_check_map_validity((uint8_t *)&con_req_pdu->chm,'\x05'); + *(undefined2 *)(iVar1 + 0x280080ae) = CONCAT11(uVar2,(con_req_pdu->chm).map[4]); + *puVar3 = *puVar3 & 0xfeff; + *puVar3 = *puVar3 & 0xfdff; + *puVar3 = *puVar3 & 0xfbff; + *(undefined2 *)(iVar1 + 0x2800809c) = 0; + *(ushort *)(iVar1 + 0x280080e6) = *(ushort *)(iVar1 + 0x280080e6) & 0xff7f; + *(undefined2 *)(iVar1 + 0x280080dc) = 0; + *(undefined2 *)(iVar1 + 0x280080de) = 0; + *(undefined2 *)(iVar1 + 0x280080e0) = 0; + *(undefined2 *)(iVar1 + 0x280080e2) = 0; + *(undefined2 *)(iVar1 + 0x280080e4) = 0; + elt = lld_evt_move_to_slave(con_par,con_req_pdu,elt_adv,conhdl); + lld_util_eff_tx_time_set(elt,0x148,0x1b); + lld_util_compute_ce_max(elt,0x148,0x148); + *(undefined2 *)(iVar1 + 0x280080a6) = *(undefined2 *)(iVar1 + 0x280080a8); + *(undefined2 *)(&DAT_280080b0 + iVar1) = 0; + *(undefined2 *)(iVar1 + 0x280080b2) = 0; + *(undefined2 *)(iVar1 + 0x280080cc) = 0; + *(undefined2 *)(iVar1 + 0x280080ce) = 0; + *(undefined2 *)(iVar1 + 0x280080d0) = 0; + *(undefined2 *)(iVar1 + 0x280080d2) = 0; + *(undefined2 *)(iVar1 + 0x280080d4) = 0; + *(undefined2 *)(iVar1 + 0x280080d6) = 0; + *(undefined2 *)(iVar1 + 0x280080d8) = 0; + *(undefined2 *)(iVar1 + 0x280080a4) = 0; + *puVar3 = *puVar3 & 0xf7ff; + lld_evt_elt_insert(elt,true); + return elt; +} + + + +void lld_ch_map_ind(ea_elt_tag *elt,uint16_t instant) + +{ + byte bVar1; + ushort uVar2; + undefined2 in_register_0000202e; + + *(undefined *)((int)&elt[2].delay + 1) = 2; + bVar1 = *(byte *)((int)&elt[2].ea_cb_cancel + 2); + uVar2 = *(ushort *)&elt[2].timestamp; + *(uint16_t *)&elt[2].linked_element = instant; + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = bVar1 | 1; + if ((uint)uVar2 == (CONCAT22(in_register_0000202e,instant) - 1 & 0xffff)) { + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = bVar1 | 9; + return; + } + if ((uint)uVar2 == CONCAT22(in_register_0000202e,instant)) { + llc_map_update_ind(*(uint16_t *)&elt[2].ea_cb_start); + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = *(byte *)((int)&elt[2].ea_cb_cancel + 2) | 8; + return; + } + return; +} + + + +void lld_con_update_ind(ea_elt_tag *elt_old,llcp_con_upd_ind *param_pdu) + +{ + lld_evt_slave_update(param_pdu,elt_old); + return; +} + + + +void lld_crypt_isr(void) + +{ + ble_ke_event_set('\x01'); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +ea_elt_tag * lld_test_mode_tx(em_desc_node *txdesc,uint8_t tx_freq,uint8_t tx_phy) + +{ + short sVar1; + uint8_t uVar2; + ea_elt_tag *elt; + undefined3 extraout_var; + undefined3 in_register_00002031; + int iVar3; + + iVar3 = CONCAT31(in_register_00002031,tx_phy); + sVar1 = (short)iVar3; + elt = lld_evt_adv_create(2,0,1,false); + *(undefined *)((int)&elt[2].ea_cb_stop + 3) = 2; + _DAT_280000e0 = _DAT_280000e0 & 0xfffff7ff | 0x800; + _DAT_28008184 = 0; + _DAT_28008186 = 0; + _DAT_28008188 = 0; + _DAT_28008146 = 0x1c; + _DAT_2800814c = 0x4129; + _DAT_2800814e = 0x7176; + _DAT_28008158 = _DAT_28008158 & 0xff00 | 0xf; + _DAT_28008148 = 0; + _DAT_2800819e = _DAT_2800819e & 0xff7f; + _DAT_2800814a = _DAT_2800814a & 0xffe0 | 2; + _DAT_28008194 = 0; + _DAT_28008196 = 0; + _DAT_28008198 = 0; + _DAT_2800819a = 0; + _DAT_2800819c = 0; + uVar2 = lld_util_freq2chnl(tx_freq); + _DAT_28008156 = (ushort)CONCAT31(extraout_var,uVar2) | _DAT_28008156 & 0xffc0; + if (iVar3 != 0) { + if (iVar3 == 4) { + sVar1 = 3; + _DAT_280081a0 = _DAT_280081a0 & 0xffcf | 0x10; + } + else { + if (iVar3 == 3) { + _DAT_280081a0 = _DAT_280081a0 & 0xffcf; + } + } + _DAT_280081a0 = sVar1 - 1U & 0xff | _DAT_280081a0 & 0xfffc; + } + lld_pdu_tx_push(elt,txdesc); + lld_pdu_tx_loop((lld_evt_tag *)&elt->env); + lld_evt_elt_insert(elt,true); + return elt; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +ea_elt_tag * lld_test_mode_rx(uint8_t rx_freq) + +{ + uint8_t uVar1; + ea_elt_tag *elt; + undefined3 extraout_var; + + elt = lld_evt_adv_create(2,0,1,false); + *(undefined *)((int)&elt[2].ea_cb_stop + 3) = 2; + _DAT_280000e0 = _DAT_280000e0 & 0xf7ffffff | 0x8000000; + _DAT_2800818a = 0; + _DAT_2800818c = 0; + _DAT_2800818e = 0; + _DAT_28008146 = 0x1d; + _DAT_2800815a = 0x804b; + orig_rxsyncwinszdef = (byte)_DAT_280001ac & 0x3f; + _DAT_280001ac = _DAT_280001ac & 0xffffffc0 | 0xf; + orig_rfrxtmda = (uint8_t)(_DAT_28000078 >> 0x1c); + _DAT_28000078 = _DAT_28000078 & 0xfffffff | 0xf0000000; + _DAT_40002850 = _DAT_40002850 & 0xcfffffff | 0x10000000; + _DAT_28000000 = _DAT_28000000 & 0xffff7fff; + _DAT_2800814c = 0x4129; + _DAT_2800814e = 0x7176; + _DAT_28008148 = 0; + _DAT_28008168 = 0xff; + _DAT_2800816a = 0; + _DAT_2800819e = _DAT_2800819e & 0xff7f; + _DAT_2800814a = _DAT_2800814a & 0xffe0 | 2; + _DAT_28008194 = 0; + _DAT_28008196 = 0; + _DAT_28008198 = 0; + _DAT_2800819a = 0; + _DAT_2800819c = 0; + uVar1 = lld_util_freq2chnl(rx_freq); + _DAT_28008156 = (ushort)CONCAT31(extraout_var,uVar1) | _DAT_28008156 & 0xffc0; + (*rwip_rf.force_agc_enable)(false); + lld_evt_elt_insert(elt,true); + return elt; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_test_stop(ea_elt_tag *elt) + +{ + _DAT_28000000 = _DAT_28000000 | 0x4000000; + (*rwip_rf.force_agc_enable)(true); + _DAT_280000e0 = 0; + return; +} + + + +// WARNING: Variable defined which should be unmapped: tmp_addr + +uint16_t llm_util_bd_addr_wl_position(bd_addr *bd_address,uint8_t bd_addr_type) + +{ + int iVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined auStack40 [4]; + bd_addr tmp_addr; + + iVar1 = 0; + if ((bd_addr_type & 1) == 0) { + do { + (*ble_memcpy_ptr)(auStack40,(void *)(iVar1 * 6 + 0x280081fe),6); + _Var2 = co_bdaddr_compare((bd_addr *)auStack40,bd_address); + if (CONCAT31(extraout_var,_Var2) != 0) { + return (uint16_t)iVar1; + } + iVar1 = iVar1 + 1; + } while (iVar1 != 4); + } + else { + do { + (*ble_memcpy_ptr)(auStack40,(void *)(iVar1 * 6 + 0x28008216),6); + _Var2 = co_bdaddr_compare((bd_addr *)auStack40,bd_address); + if (CONCAT31(extraout_var_00,_Var2) != 0) { + return (uint16_t)iVar1; + } + iVar1 = iVar1 + 1; + } while (iVar1 != 4); + } + return 4; +} + + + +uint8_t llm_util_check_address_validity(bd_addr *bd_address,uint8_t addr_type) + +{ + _Bool _Var1; + uint8_t uVar2; + undefined3 extraout_var; + + _Var1 = co_bdaddr_compare(bd_address,&co_null_bdaddr); + if (CONCAT31(extraout_var,_Var1) == 0) { + uVar2 = '\0'; + } + else { + uVar2 = '\x12'; + } + return uVar2; +} + + + +uint8_t llm_util_check_map_validity(uint8_t *channel_map,uint8_t nb_octet) + +{ + uint uVar1; + undefined3 in_register_0000202d; + uint uVar2; + uint uVar3; + uint uVar4; + + uVar4 = (uint)*channel_map & 0xf8; + if (((*channel_map & 0xf8) != 0) && (uVar4 = 0, CONCAT31(in_register_0000202d,nb_octet) == 1)) { + return '\0'; + } + uVar3 = 0; + while( true ) { + if (CONCAT31(in_register_0000202d,nb_octet) <= (uVar3 & 0xff)) { + return (uint8_t)uVar4; + } + if (((uVar3 & 0xff) == 4) && ((channel_map[uVar3] & 0xe0) != 0)) break; + uVar2 = 0; + do { + uVar1 = uVar2 & 0x1f; + uVar2 = uVar2 + 1; + uVar4 = uVar4 + ((int)(uint)channel_map[uVar3] >> uVar1 & 1U) & 0xff; + } while (uVar2 != 8); + uVar3 = uVar3 + 1; + } + return '&'; +} + + + +void llm_util_apply_bd_addr(uint8_t addr_type) + +{ + undefined3 in_register_00002029; + bd_addr *bd_addr; + uint8_t type; + + if ((CONCAT31(in_register_00002029,addr_type) == 1) || + (CONCAT31(in_register_00002029,addr_type) == 3)) { + type = '\x01'; + bd_addr = &llm_le_env.rand_add; + } + else { + type = '\0'; + bd_addr = &llm_le_env.public_add; + } + lld_util_set_bd_address(bd_addr,type); + return; +} + + + +_Bool llm_util_check_evt_mask(uint8_t event_id) + +{ + undefined3 in_register_00002029; + uint uVar1; + + uVar1 = CONCAT31(in_register_00002029,event_id); + return (_Bool)((byte)((int)(uint)llm_le_env.eventmask.mask[uVar1 >> 3] >> + (uVar1 - (uVar1 & 0xfffffff8) & 0x1f)) & 1); +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void llm_util_get_channel_map(le_chnl_map *map) + +{ + // WARNING: Could not recover jumptable at 0x23032afe. Too many branches + // WARNING: Treating indirect jump as call + (*ble_memcpy_ptr)((void *)0x42026492,(void *)0x5); + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void llm_util_get_supp_features(le_features *feats) + +{ + // WARNING: Could not recover jumptable at 0x23032b12. Too many branches + // WARNING: Treating indirect jump as call + (*ble_memcpy_ptr)(&llm_local_le_feats,(void *)0x8); + return; +} + + + +void llm_util_adv_data_update(void) + +{ + if ((llm_le_env.advertising_params)->adv_data_req != (ke_msg *)0x0) { + llm_set_adv_data((hci_le_set_adv_data_cmd *)((llm_le_env.advertising_params)->adv_data_req + 1)) + ; + ble_ke_msg_free((llm_le_env.advertising_params)->adv_data_req); + (llm_le_env.advertising_params)->adv_data_req = (ke_msg *)0x0; + } + if ((llm_le_env.advertising_params)->scan_rsp_req != (ke_msg *)0x0) { + llm_set_scan_rsp_data + ((hci_le_set_scan_rsp_data_cmd *)((llm_le_env.advertising_params)->scan_rsp_req + 1)); + ble_ke_msg_free((llm_le_env.advertising_params)->scan_rsp_req); + (llm_le_env.advertising_params)->scan_rsp_req = (ke_msg *)0x0; + } + return; +} + + + +uint8_t llm_util_bl_check(bd_addr *bd_addr_to_add,uint8_t bd_addr_type,uint16_t *conhdl, + uint8_t wl_flag_action,_Bool *in_wl) + +{ + co_list_hdr cVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 in_register_00002035; + int iVar3; + + iVar3 = CONCAT31(in_register_00002035,wl_flag_action); + cVar1 = (co_list_hdr)llm_le_env.cnx_list.first; + do { + if (cVar1 == (co_list_hdr)0x0) { + return '\0'; + } + if ((bd_addr_to_add == (bd_addr *)0x0) && (iVar3 == 1)) { + *(undefined *)((int)cVar1 + 0xd) = 0; + } + else { + _Var2 = co_bdaddr_compare(bd_addr_to_add,(bd_addr *)((int)cVar1 + 4)); + if ((CONCAT31(extraout_var,_Var2) != 0) && + (*(byte *)&((co_list_hdr *)((int)cVar1 + 0xc))->next == (bd_addr_type & 1))) { + if (conhdl != (uint16_t *)0x0) { + *conhdl = *(uint16_t *)((int)cVar1 + 10); + } + if (iVar3 == 1) { + *(undefined *)((int)cVar1 + 0xd) = 0; + } + else { + if (iVar3 == 2) { + *(undefined *)((int)cVar1 + 0xd) = 1; + } + } + if (in_wl == (_Bool *)0x0) { + return '\v'; + } + *in_wl = *(_Bool *)((int)cVar1 + 0xd); + return '\v'; + } + } + cVar1 = *(co_list_hdr *)cVar1; + } while( true ); +} + + + +// WARNING: Variable defined which should be unmapped: found + +_Bool llm_util_bd_addr_in_wl(bd_addr *bd_address,uint8_t bd_addr_type,_Bool *in_black_list) + +{ + uint8_t uVar1; + uint16_t uVar2; + undefined3 extraout_var; + undefined2 extraout_var_00; + _Bool a_Stack17 [4]; + _Bool found; + + a_Stack17[0] = false; + if (in_black_list != (_Bool *)0x0) { + *in_black_list = false; + } + uVar1 = llm_util_bl_check(bd_address,bd_addr_type,(uint16_t *)0x0,'\0',a_Stack17); + if ((CONCAT31(extraout_var,uVar1) == 0xb) && (in_black_list != (_Bool *)0x0)) { + *in_black_list = true; + } + if ((a_Stack17[0] == false) && + (uVar2 = llm_util_bd_addr_wl_position(bd_address,bd_addr_type), + CONCAT22(extraout_var_00,uVar2) < 4)) { + a_Stack17[0] = true; + } + return a_Stack17[0]; +} + + + +uint8_t llm_util_bl_add(bd_addr *bd_addr_to_add,uint8_t bd_addr_type,uint16_t conhdl) + +{ + uint8_t uVar1; + uint16_t uVar2; + void *pvVar3; + undefined2 extraout_var; + + pvVar3 = ble_ke_malloc(0x10,'\0'); + uVar1 = '\a'; + if (pvVar3 != (void *)0x0) { + (*ble_memcpy_ptr)((bd_addr *)((int)pvVar3 + 4),bd_addr_to_add,6); + *(uint16_t *)((int)pvVar3 + 10) = conhdl; + *(byte *)((int)pvVar3 + 0xc) = bd_addr_type & 1; + uVar2 = llm_util_bd_addr_wl_position(bd_addr_to_add,bd_addr_type); + *(bool *)((int)pvVar3 + 0xd) = CONCAT22(extraout_var,uVar2) < 4; + ble_co_list_push_back(0x42026478,pvVar3); + uVar1 = '\0'; + if (*(char *)((int)pvVar3 + 0xd) != '\0') { + llm_wl_dev_rem((bd_addr *)((int)pvVar3 + 4),bd_addr_type & 1); + } + } + return uVar1; +} + + + +uint8_t llm_util_bl_rem(uint16_t conhdl) + +{ + co_list_hdr list_hdr; + undefined2 in_register_0000202a; + + list_hdr = (co_list_hdr)llm_le_env.cnx_list.first; + while( true ) { + if (list_hdr == (co_list_hdr)0x0) { + return '\x02'; + } + if ((uint)*(ushort *)((int)list_hdr + 10) == CONCAT22(in_register_0000202a,conhdl)) break; + list_hdr = *(co_list_hdr *)list_hdr; + } + ble_co_list_extract(&llm_le_env.cnx_list,(co_list_hdr *)list_hdr,'\0'); + if (*(char *)((int)list_hdr + 0xd) != '\0') { + llm_wl_dev_add((bd_addr *)((int)list_hdr + 4), + *(uint8_t *)&((co_list_hdr *)((int)list_hdr + 0xc))->next); + } + ble_ke_free((void *)list_hdr); + return '\0'; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void llm_end_evt_defer(void) + +{ + ke_state_t kVar1; + undefined *param; + undefined2 uVar2; + undefined auStack36 [4]; + llc_create_con_req_ind msg_param; + + kVar1 = ble_ke_state_get(0); + if ((kVar1 & 0xf0) == 0x10) { + if (((llm_le_env.advertising_params)->type == '\x01') && + ((llm_le_env.advertising_params)->adv_ldc_flag == false)) { + (*ble_memcpy_ptr)(&msg_param.sup_to,&(llm_le_env.advertising_params)->peer_addr,6); + msg_param.peer_addr.addr[2] = (llm_le_env.advertising_params)->peer_addr_type; + llc_le_con_cmp_evt_send('<',0,(llc_create_con_req_ind *)auStack36); + lld_evt_delete_elt_push(llm_le_env.elt,true,false); + kVar1 = ble_ke_state_get(0); + ble_ke_state_set(0,(byte)kVar1 & 0xf); + } + } + if ((llm_le_env.test_mode.directtesttype != '\x03') && (llm_le_env.test_mode.end_of_tst != false)) + { + param = (undefined *)ble_ke_msg_alloc(0x801,0,0x201f,4); + llm_le_env.test_mode.end_of_tst = false; + if (llm_le_env.test_mode.directtesttype == '\x01') { + _DAT_280001ac = _DAT_280001ac & 0xffffffc0 | (uint)orig_rxsyncwinszdef; + _DAT_28000078 = (uint)orig_rfrxtmda << 0x1c | _DAT_28000078 & 0xfffffff; + _DAT_40002850 = _DAT_40002850 & 0xcfffffff | 0x20000000; + } + _DAT_28000000 = _DAT_28000000 & 0xfffb7fff | 0x8000; + uVar2 = 0; + if (llm_le_env.test_mode.directtesttype != '\0') { + uVar2 = _DAT_2800818a; + } + *(undefined2 *)(param + 2) = uVar2; + llm_le_env.test_mode.directtesttype = '\x03'; + *param = 0; + hci_send_2_host(param); + ble_ke_msg_send_basic(1,0,0); + } + return; +} + + + +_Bool llm_pdu_defer(uint16_t status,uint8_t rx_hdl,uint8_t tx_cnt) + +{ + undefined uVar1; + ke_state_t kVar2; + undefined2 extraout_var; + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + uint uVar3; + + kVar2 = ble_ke_state_get(0); + _kVar2 = CONCAT22(extraout_var,kVar2); + if ((kVar2 & 0xf) == 2) { + if ((status & 3) == 0) { + uVar1 = 0; + if (CONCAT31(in_register_00002031,tx_cnt) != 0) { + llm_con_req_tx_cfm(rx_hdl); + uVar1 = 1; + } + goto LAB_23032e92; + } + if (_kVar2 == 0x23) { + uVar1 = 0; + goto LAB_23032e92; + } + } + else { + uVar1 = 0; + if ((_kVar2 == 0x23) || (_kVar2 == 0)) goto LAB_23032e92; + } + uVar1 = 0; + if (((_kVar2 != 0x24) && ((status & 0x1f) == 0)) && + (((uint)*(ushort *)(&DAT_280083d2 + CONCAT31(in_register_0000202d,rx_hdl) * 0xe) & 0xf) < 7)) { + uVar3 = 1 << ((uint)*(ushort *)(&DAT_280083d2 + CONCAT31(in_register_0000202d,rx_hdl) * 0xe) & + 0xf); + if ((uVar3 & 0x57) == 0) { + if (((uVar3 & 0x20) != 0) && ((kVar2 & 0xf0) == 0x10)) { + llm_con_req_ind(rx_hdl,status); + } + } + else { + if ((kVar2 & 0xf) == 1) { + llm_le_adv_report_ind(rx_hdl); + } + } + } +LAB_23032e92: + em_buf_rx_free(rx_hdl); + return (_Bool)uVar1; +} + + + +void llm_wlpub_addr_set(uint16_t elem_index,bd_addr *bdaddr) + +{ + undefined2 *puVar1; + undefined2 in_register_0000202a; + undefined2 *puVar2; + bd_addr *pbVar3; + + pbVar3 = bdaddr + 1; + puVar2 = (undefined2 *)(CONCAT22(in_register_0000202a,elem_index) * 6 + 0x280081fe); + do { + puVar1 = (undefined2 *)bdaddr->addr; + bdaddr = (bd_addr *)(bdaddr->addr + 2); + *puVar2 = *puVar1; + puVar2 = puVar2 + 1; + } while (pbVar3 != bdaddr); + return; +} + + + +void llm_wlpriv_addr_set(uint16_t elem_index,bd_addr *bdaddr) + +{ + undefined2 *puVar1; + undefined2 in_register_0000202a; + undefined2 *puVar2; + bd_addr *pbVar3; + + pbVar3 = bdaddr + 1; + puVar2 = (undefined2 *)(CONCAT22(in_register_0000202a,elem_index) * 6 + 0x28008216); + do { + puVar1 = (undefined2 *)bdaddr->addr; + bdaddr = (bd_addr *)(bdaddr->addr + 2); + *puVar2 = *puVar1; + puVar2 = puVar2 + 1; + } while (pbVar3 != bdaddr); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void llm_con_req_ind(uint8_t rx_hdl,uint16_t status) + +{ + ushort uVar1; + int iVar2; + uint8_t uVar3; + ke_state_t kVar4; + undefined3 in_register_00002029; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + uint16_t local_5a; + ushort uStack88; + uint16_t conhdl; + llc_create_con_req_ind param; + llm_pdu_con_req_rx data; + + iVar2 = CONCAT31(in_register_00002029,rx_hdl) * 0xe; + (*ble_memcpy_ptr)(¶m.sleep_clk_acc,&DAT_28008000 + *(ushort *)(&DAT_280083d6 + iVar2),0x22); + if (0xc76 < ((uint)data.interval - 10 & 0xffff)) { + return; + } + if (0xc7a < ((uint)data._18_2_ - 6 & 0xffff)) { + return; + } + if (499 < data.winoffset) { + return; + } + if ((uint)data.interval << 2 <= ((uint)data.winoffset + 1) * (uint)data._18_2_) { + return; + } + uVar3 = llc_util_get_free_conhdl(&local_5a); + if (CONCAT31(extraout_var,uVar3) != 0) { + return; + } + if ((status & 0x200) == 0) { + uVar1 = *(ushort *)(iVar2 + 0x280083d8); + if (uVar1 != 0) { + (*ble_memcpy_ptr)(¶m.sleep_clk_acc,&DAT_28008000 + ((uint)uVar1 + 0x18 & 0xffff),6); + param.peer_addr.addr[2] = + (byte)*(undefined2 *)(&DAT_2800822e + (((uint)uVar1 - 0x22e) / 0x34 & 0xff) * 0x34) & 2 | + (byte)*(undefined2 *)(&DAT_2800822e + (((uint)uVar1 - 0x22e) / 0x34 & 0xff) * 0x34) & 1; + goto LAB_23033054; + } + } + uVar1 = 0; + param.peer_addr.addr[2] = (byte)(*(ushort *)(&DAT_280083d2 + iVar2) >> 6) & 1; +LAB_23033054: + uVar3 = llm_util_bl_check((bd_addr *)¶m.sleep_clk_acc,param.peer_addr.addr[2],&local_5a,'\0', + (_Bool *)0x0); + if (CONCAT31(extraout_var_00,uVar3) == 0) { + uVar3 = llm_util_bl_add((bd_addr *)¶m.sleep_clk_acc,param.peer_addr.addr[2],local_5a); + if (CONCAT31(extraout_var_01,uVar3) == 0) { + uStack88 = data._18_2_; + conhdl = data.winoffset; + param.con_int = data.interval; + param.peer_addr.addr[4] = data.chm.map[1] >> 5; + param.peer_addr.addr[3] = data.chm.map[1] & 0x1f; + param.con_lat = uVar1; + (*ble_memcpy_ptr)(¶m.sup_to,¶m.sleep_clk_acc,6); + llm_le_env.elt = + lld_move_to_slave((llc_create_con_req_ind *)&uStack88, + (llm_pdu_con_req_rx *)¶m.sleep_clk_acc,llm_le_env.elt,local_5a, + rx_hdl); + llc_start(&uStack88,llm_le_env.elt); + llm_le_env.elt = (ea_elt_tag *)0x0; + llc_util_update_channel_map(local_5a,(le_chnl_map *)&data.latency); + } + kVar4 = ble_ke_state_get(0); + ble_ke_state_set(0,(byte)kVar4 & 0xf); + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void llm_le_adv_report_ind(uint8_t rx_hdl) + +{ + ushort uVar1; + ushort uVar2; + co_list_hdr cVar3; + uint uVar4; + uint uVar5; + undefined *param; + _Bool _Var6; + int8_t iVar7; + uint16_t uVar8; + undefined3 in_register_00002029; + undefined2 extraout_var_02; + void *pvVar9; + undefined2 extraout_var_03; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + byte bVar10; + undefined uVar11; + ushort *puVar12; + ushort *puVar13; + int iVar14; + undefined auStack72 [4]; + bd_addr adv_addr; + bd_addr inita; + bd_addr adva; + + iVar14 = CONCAT31(in_register_00002029,rx_hdl) * 0xe; + puVar12 = (ushort *)(&DAT_280083d2 + iVar14); + puVar13 = (ushort *)(&DAT_280083d6 + iVar14); + uVar1 = *puVar12; + (*ble_memcpy_ptr)(auStack72,&DAT_28008000 + *puVar13,6); + uVar5 = (uint)uVar1 & 0xf; + cVar3 = (co_list_hdr)llm_le_env.adv_list.first; + if (((llm_le_env.scanning_params)->filter_duplicate == '\x01') || (uVar5 == 1)) { + while (cVar3 != (co_list_hdr)0x0) { + _Var6 = co_bdaddr_compare((bd_addr *)auStack72,(bd_addr *)((int)cVar3 + 5)); + if ((CONCAT31(extraout_var_00,_Var6) != 0) && + ((uint)*(byte *)&((co_list_hdr *)((int)cVar3 + 4))->next == uVar5)) { + return; + } + cVar3 = *(co_list_hdr *)cVar3; + } + uVar8 = ble_co_list_size(&llm_le_env.adv_list); + if (CONCAT22(extraout_var_02,uVar8) == 10) { + return; + } + pvVar9 = ble_ke_malloc(0xc,'\0'); + (*ble_memcpy_ptr)((void *)((int)pvVar9 + 5),auStack72,6); + *(undefined *)((int)pvVar9 + 4) = (char)uVar5; + ble_co_list_push_back(0x42026468,pvVar9); + } + if (Is_ext_scan_enable != '\0') { + return; + } + uVar8 = ble_ke_msg_get_sent_num(); + if (0x14 < CONCAT22(extraout_var_03,uVar8)) { + return; + } + uVar1 = *(ushort *)(iVar14 + 0x280083d8); + uVar4 = (uint)uVar1; + uVar2 = *(ushort *)(iVar14 + 0x280083d0); + (*ble_memcpy_ptr)(adv_addr.addr + 4,&DAT_28008000 + ((uint)*puVar13 + 6 & 0xffff),6); + (*ble_memcpy_ptr)(inita.addr + 4,&DAT_28008000 + *puVar13,6); + if (((((uVar5 == 1) && (1 < (llm_le_env.scanning_params)->filterpolicy)) && + ((*puVar12 >> 7 & 1) != 0)) && ((inita.addr[1] & 0xc0) == 0x40)) && + ((uVar1 == 0 || ((uVar2 & 0x600) == 0x600)))) { + _Var6 = llm_util_check_evt_mask('\n'); + if (CONCAT31(extraout_var,_Var6) == 0) { + return; + } + param = (undefined *)ble_ke_msg_alloc(0x804,0,0,0x12); + *param = 0xb; + param[1] = 1; + iVar7 = (*rwip_rf.rssi_convert)((uint8_t)*(undefined2 *)(iVar14 + 0x280083d4)); + param[0x11] = iVar7; + param[2] = (byte)*puVar12 & 0xf; + if (uVar1 == 0) { + (*ble_memcpy_ptr)(&DAT_28008000 + *puVar13,(void *)0x6,(uint)ble_memcpy_ptr); + param[3] = (byte)(*puVar12 >> 6) & 1; + (*ble_memcpy_ptr)(param + 0xb,adv_addr.addr + 4,6); + param[10] = 1; + } + else { + (*ble_memcpy_ptr)(param + 4,&DAT_28008000 + (uVar4 + 0x18 & 0xffff),6); + bVar10 = (byte)*(undefined2 *)(&DAT_2800822e + ((uVar4 - 0x22e) / 0x34 & 0xff) * 0x34) & 1; + param[3] = bVar10; + if ((adva.addr[1] & 0xc0) == 0x40) { + param[3] = bVar10 | 2; + } + (*ble_memcpy_ptr)(param + 0xb,adv_addr.addr + 4,6); + param[10] = 1; + } + goto LAB_23033314; + } + _Var6 = llm_util_check_evt_mask('\x01'); + if (CONCAT31(extraout_var_01,_Var6) == 0) { + return; + } + param = (undefined *)ble_ke_msg_alloc(0x804,0,0,0x2b); + param[1] = 1; + *param = 2; + iVar7 = (*rwip_rf.rssi_convert)((uint8_t)*(undefined2 *)(iVar14 + 0x280083d4)); + param[0x2a] = iVar7; + uVar5 = (uint)*puVar12 & 0xf; + uVar11 = (undefined)uVar5; + if (uVar5 == 2) { + uVar11 = 3; +LAB_230333ce: + param[2] = uVar11; + } + else { + if (uVar5 != 6) goto LAB_230333ce; + param[2] = 2; + } + if (param[2] == '\x01') { + param[10] = 0; + } + else { + uVar5 = (uint)(*puVar12 >> 8) - 6 & 0xff; + if (uVar5 < 0x20) { + param[10] = (char)uVar5; + } + else { + param[10] = 0x1f; + } + (*ble_memcpy_ptr)(param + 0xb,&DAT_28008000 + ((uint)*puVar13 + 6 & 0xffff), + (uint)(byte)param[10]); + } + if ((uVar1 == 0) || ((uVar2 & 0x600) == 0x200)) { + (*ble_memcpy_ptr)(param + 4,&DAT_28008000 + *puVar13,6); + bVar10 = (byte)(*puVar12 >> 6) & 1; + } + else { + (*ble_memcpy_ptr)(param + 4,&DAT_28008000 + (uVar4 + 0x18 & 0xffff),6); + bVar10 = (byte)*(undefined2 *)(&DAT_2800822e + ((uVar4 - 0x22e) / 0x34 & 0xff) * 0x34) & 1; + param[3] = bVar10; + if ((adva.addr[1] & 0xc0) != 0x40) goto LAB_23033314; + bVar10 = bVar10 | 2; + } + param[3] = bVar10; +LAB_23033314: + hci_send_2_host(param); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void llm_con_req_tx_cfm(uint8_t rx_hdl) + +{ + int iVar1; + uint8_t uVar2; + ke_state_t kVar3; + undefined3 in_register_00002029; + undefined3 extraout_var; + undefined auStack88 [4]; + llm_pdu_adv rxdata; + llc_create_con_req_ind param; + llm_pdu_con_req_tx txdata; + + iVar1 = CONCAT31(in_register_00002029,rx_hdl) * 0xe; + (*ble_memcpy_ptr)(auStack88,&DAT_28008000 + *(ushort *)(&DAT_280083d6 + iVar1),6); + (*ble_memcpy_ptr)(¶m.sleep_clk_acc,&DAT_28008000 + _DAT_280082ec,0x16); + param.con_lat = *(ushort *)(iVar1 + 0x280083d8); + if (param.con_lat == 0) { + param.peer_addr.addr[2] = (byte)(*(ushort *)(&DAT_280083d2 + iVar1) >> 6) & 1; + (*ble_memcpy_ptr)(¶m.sup_to,auStack88,6); + } + else { + (*ble_memcpy_ptr)(¶m.sup_to,&DAT_28008000 + ((uint)param.con_lat + 0x18 & 0xffff),6); + param.peer_addr.addr[2] = + (byte)*(undefined2 *)(&DAT_2800822e + (((uint)param.con_lat - 0x22e) / 0x34 & 0xff) * 0x34) + & 2 | (byte)*(undefined2 *) + (&DAT_2800822e + (((uint)param.con_lat - 0x22e) / 0x34 & 0xff) * 0x34) & 1; + } + param.peer_addr.addr[4] = txdata.chm.map[1] >> 5; + param.peer_addr.addr[3] = txdata.chm.map[1] & 0x1f; + if ((llm_le_env.elt_coext_scan != (ea_elt_tag *)0x0) && + (uVar2 = llm_util_bl_add((bd_addr *)¶m.sup_to,param.peer_addr.addr[2], + llm_le_env.conhdl_alloc), CONCAT31(extraout_var,uVar2) == 0)) { + llm_le_env.elt_coext_scan = + lld_move_to_master(llm_le_env.elt_coext_scan,llm_le_env.conhdl_alloc, + (llc_create_con_req_ind *)&rxdata.adva_data,rx_hdl); + llc_start(&rxdata.adva_data,llm_le_env.elt_coext_scan); + llm_le_env.elt_coext_scan = (ea_elt_tag *)0x0; + } + kVar3 = ble_ke_state_get(0); + ble_ke_state_set(0,(byte)kVar3 & 0xf0); + return; +} + + + +void llm_common_cmd_complete_send(uint16_t opcode,uint8_t status) + +{ + uint8_t *param; + + param = (uint8_t *)ble_ke_msg_alloc(0x801,0,opcode,1); + *param = status; + hci_send_2_host(param); + return; +} + + + +void llm_common_cmd_status_send(uint16_t opcode,uint8_t status) + +{ + uint8_t *param; + + param = (uint8_t *)ble_ke_msg_alloc(0x802,0,opcode,1); + *param = status; + hci_send_2_host(param); + return; +} + + +/* +Unable to decompile 'llm_test_mode_start_tx' +Cause: Exception while decompiling 2303362e: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t llm_test_mode_start_rx(hci_le_rx_test_cmd *param) + +{ + advertising_pdu_params *paVar1; + uint8_t uVar2; + + if (param->rx_freq < 0x28) { + if (llm_le_env.advertising_params == (advertising_pdu_params *)0x0) { + llm_le_env.advertising_params = (advertising_pdu_params *)ble_ke_malloc(0x24,'\0'); + (*ble_memset_ptr)(llm_le_env.advertising_params,0,0x24); + paVar1 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->intervalmin = 0x800; + paVar1->type = '\0'; + paVar1->intervalmax = 0x800; + paVar1->filterpolicy = '\0'; + paVar1 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->channelmap = '\a'; + paVar1->adv_ldc_flag = true; + _DAT_280082fe = (ushort)paVar1->type | 0x600; + _DAT_280082f4 = 0x604; + } + _DAT_28000000 = _DAT_28000000 & 0xfffbffff | 0x40000; + ble_ke_state_set(0,'$'); + llm_le_env.elt = lld_test_mode_rx(param->rx_freq); + uVar2 = '\x1f'; + if (llm_le_env.elt != (ea_elt_tag *)0x0) { + llm_le_env.test_mode.directtesttype = '\x01'; + uVar2 = '\0'; + } + return uVar2; + } + return '\x12'; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t llm_set_adv_param(hci_le_set_adv_param_cmd *param) + +{ + uint8_t uVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + advertising_pdu_params *paVar2; + bd_addr *bd_address; + + if ((((((param->adv_intv_max < param->adv_intv_min) || (7 < param->adv_chnl_map)) || + (3 < param->adv_filt_policy)) || + (((param->adv_type & 0xfb) == 0 && (param->adv_intv_min < 0x20)))) || + ((3 < param->own_addr_type || (1 < param->peer_addr_type)))) || + ((param->adv_type != 1 && (0x4000 < param->adv_intv_max)))) { + return '\x12'; + } + if (llm_le_env.advertising_params == (advertising_pdu_params *)0x0) { + llm_le_env.advertising_params = (advertising_pdu_params *)ble_ke_malloc(0x24,'\0'); + (*ble_memset_ptr)(llm_le_env.advertising_params,0,0x24); + paVar2 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->intervalmin = 0x800; + paVar2->type = '\0'; + paVar2->intervalmax = 0x800; + paVar2->filterpolicy = '\0'; + paVar2 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->channelmap = '\a'; + paVar2->adv_ldc_flag = true; + _DAT_280082fe = (ushort)paVar2->type | 0x600; + _DAT_280082f4 = 0x604; + } + paVar2 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->type = '\b'; + paVar2->adv_ldc_flag = true; + if (4 < param->adv_type) { + return '\x12'; + } + bd_address = ¶m->peer_addr; + switch(param->adv_type) { + default: + paVar2->type = '\x01'; + _DAT_280082e0 = 0xc21; + uVar1 = llm_util_check_address_validity(bd_address,param->peer_addr_type); + if (CONCAT31(extraout_var,uVar1) == 0) { + _DAT_280082e0 = (ushort)param->peer_addr_type << 7 | _DAT_280082e0 & 0xff7f; + (*ble_memcpy_ptr)(&DAT_28008000 + _DAT_280082e2,bd_address,6); + } + paVar2 = llm_le_env.advertising_params; + if (param->adv_type != '\x04') { + (llm_le_env.advertising_params)->adv_ldc_flag = false; + goto LAB_23033aac; + } + break; + case '\x02': + paVar2->type = '\x06'; + case '\0': + if (paVar2->type != '\x06') { + paVar2->type = '\0'; + } + case '\x03': + if ((paVar2->type != '\x06') && (paVar2->type != '\0')) { + paVar2->type = '\x02'; + } + paVar2->filterpolicy = param->adv_filt_policy; + } + paVar2->intervalmax = param->adv_intv_max; + paVar2->intervalmin = param->adv_intv_min; +LAB_23033aac: + paVar2 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->peer_addr_type = param->peer_addr_type; + (*ble_memcpy_ptr)(&paVar2->peer_addr,bd_address,6); + (llm_le_env.advertising_params)->own_addr_type = param->own_addr_type; + uVar1 = llm_util_check_map_validity(¶m->adv_chnl_map,'\x01'); + if (CONCAT31(extraout_var_00,uVar1) == 0) { + uVar1 = '\x12'; + } + else { + uVar1 = '\0'; + (llm_le_env.advertising_params)->channelmap = param->adv_chnl_map; + } + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t llm_set_adv_en(hci_le_set_adv_en_cmd *param) + +{ + byte bVar1; + advertising_pdu_params *paVar2; + uint8_t uVar3; + _Bool _Var4; + ke_state_t kVar5; + undefined3 extraout_var; + em_desc_node *adv_pdu; + + if (param->adv_en == '\0') { + kVar5 = ble_ke_state_get(0); + ble_ke_state_set(0,(byte)kVar5 & 0xf | 0x20); + lld_adv_stop(llm_le_env.elt); + return '\0'; + } + if (llm_le_env.advertising_params == (advertising_pdu_params *)0x0) { + llm_le_env.advertising_params = (advertising_pdu_params *)ble_ke_malloc(0x24,'\0'); + (*ble_memset_ptr)(llm_le_env.advertising_params,0,0x24); + paVar2 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->intervalmin = 0x800; + paVar2->type = '\0'; + paVar2->intervalmax = 0x800; + paVar2->filterpolicy = '\0'; + paVar2 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->channelmap = '\a'; + paVar2->adv_ldc_flag = true; + _DAT_280082fe = (ushort)paVar2->type | 0x600; + _DAT_280082f4 = 0x604; + } + _Var4 = co_bdaddr_compare(&llm_le_env.rand_add,&co_null_bdaddr); + if ((CONCAT31(extraout_var,_Var4) == 0) || + (((llm_le_env.advertising_params)->own_addr_type & 1) == 0)) { + llm_util_apply_bd_addr((llm_le_env.advertising_params)->own_addr_type); + bVar1 = (llm_le_env.advertising_params)->type; + if (bVar1 == 1) { + adv_pdu = em_buf_env.tx_desc_node + 2; +LAB_23033c1e: + llm_le_env.elt = + lld_adv_start(llm_le_env.advertising_params,adv_pdu,(em_desc_node *)0x0,rwip_rf.txpwr_max + ); + if (llm_le_env.elt == (ea_elt_tag *)0x0) goto LAB_23033bae; + } + else { + if (((bVar1 != 0) && (bVar1 != 2)) && (bVar1 != 6)) { + return '\x12'; + } + _DAT_280082fe = + (ushort)(((uint)(llm_le_env.advertising_params)->datalen + 6 & 0xff) << 8) | + (ushort)bVar1 | 0x20; + if ((llm_le_env.advertising_params)->type == '\x02') { + adv_pdu = em_buf_env.tx_desc_node + 5; + goto LAB_23033c1e; + } + _DAT_280082f4 = + (ushort)(((uint)(llm_le_env.advertising_params)->scanrsplen + 6 & 0xff) << 8) | 0x24; + llm_le_env.elt = + lld_adv_start(llm_le_env.advertising_params,em_buf_env.tx_desc_node + 5, + em_buf_env.tx_desc_node + 4,rwip_rf.txpwr_max); + if (llm_le_env.elt == (ea_elt_tag *)0x0) { + return '\x1f'; + } + } + kVar5 = ble_ke_state_get(0); + ble_ke_state_set(0,(byte)kVar5 & 0xf | 0x10); + uVar3 = '\0'; + } + else { +LAB_23033bae: + uVar3 = '\x12'; + } + return uVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t llm_set_adv_data(hci_le_set_adv_data_cmd *param) + +{ + byte bVar1; + advertising_pdu_params *paVar2; + + if (param->adv_data_len < 0x20) { + if (llm_le_env.advertising_params == (advertising_pdu_params *)0x0) { + llm_le_env.advertising_params = (advertising_pdu_params *)ble_ke_malloc(0x24,'\0'); + (*ble_memset_ptr)(llm_le_env.advertising_params,0,0x24); + paVar2 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->intervalmin = 0x800; + paVar2->type = '\0'; + paVar2->intervalmax = 0x800; + paVar2->filterpolicy = '\0'; + paVar2 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->channelmap = '\a'; + paVar2->adv_ldc_flag = true; + _DAT_280082fe = (ushort)paVar2->type | 0x600; + _DAT_280082f4 = 0x604; + } + bVar1 = param->adv_data_len; + (llm_le_env.advertising_params)->datalen = bVar1; + if (bVar1 != 0) { + (*ble_memcpy_ptr)(&DAT_28008000 + _DAT_28008300,¶m->data,(uint)bVar1); + } + _DAT_280082fe = + (ushort)(((uint)(llm_le_env.advertising_params)->datalen + 6 & 0xff) << 8) | + _DAT_280082fe & 0xff; + return '\0'; + } + return '\x12'; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t llm_set_scan_rsp_data(hci_le_set_scan_rsp_data_cmd *param) + +{ + byte bVar1; + advertising_pdu_params *paVar2; + + if (param->scan_rsp_data_len < 0x20) { + if (llm_le_env.advertising_params == (advertising_pdu_params *)0x0) { + llm_le_env.advertising_params = (advertising_pdu_params *)ble_ke_malloc(0x24,'\0'); + (*ble_memset_ptr)(llm_le_env.advertising_params,0,0x24); + paVar2 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->intervalmin = 0x800; + paVar2->type = '\0'; + paVar2->intervalmax = 0x800; + paVar2->filterpolicy = '\0'; + paVar2 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->channelmap = '\a'; + paVar2->adv_ldc_flag = true; + _DAT_280082fe = (ushort)paVar2->type | 0x600; + _DAT_280082f4 = 0x604; + } + bVar1 = param->scan_rsp_data_len; + (llm_le_env.advertising_params)->scanrsplen = bVar1; + if (bVar1 != 0) { + (*ble_memcpy_ptr)(&DAT_28008000 + _DAT_280082f6,¶m->data,(uint)bVar1); + } + _DAT_280082f4 = + (ushort)(((uint)(llm_le_env.advertising_params)->scanrsplen + 6 & 0xff) << 8) | + _DAT_280082f4 & 0xff; + return '\0'; + } + return '\x12'; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t llm_set_scan_param(hci_le_set_scan_param_cmd *param) + +{ + uint8_t uVar1; + + if (param->scan_window <= param->scan_intv) { + uVar1 = '\x12'; + if ((((param->scan_type < 2) && ((ushort)(param->scan_window - 4) < 0x3ffd)) && + ((ushort)(param->scan_intv - 4) < 0x3ffd)) && (param->scan_filt_policy < 4)) { + if (llm_le_env.scanning_params == (scanning_pdu_params *)0x0) { + llm_le_env.scanning_params = (scanning_pdu_params *)ble_ke_malloc(0xc,'\0'); + (*ble_memset_ptr)(llm_le_env.scanning_params,0,0xc); + } + uVar1 = '\0'; + (llm_le_env.scanning_params)->filterpolicy = param->scan_filt_policy; + (llm_le_env.scanning_params)->interval = param->scan_intv; + (llm_le_env.scanning_params)->window = param->scan_window; + (llm_le_env.scanning_params)->type = param->scan_type; + (llm_le_env.scanning_params)->own_addr_type = param->own_addr_type; + if (param->scan_type == '\x01') { + _DAT_280082ea = 0xc03; + } + } + return uVar1; + } + return '\x12'; +} + + + +uint8_t llm_set_scan_en(hci_le_set_scan_en_cmd *param) + +{ + _Bool _Var1; + ke_state_t kVar2; + undefined3 extraout_var; + em_desc_node *scan_req_pdu; + + if (param->scan_en == '\0') { + kVar2 = ble_ke_state_get(0); + ble_ke_state_set(0,(byte)kVar2 & 0xf0 | 3); + lld_scan_stop(llm_le_env.elt_coext_scan); + lld_util_flush_list(&llm_le_env.adv_list); + return '\0'; + } + if (llm_le_env.scanning_params == (scanning_pdu_params *)0x0) { + llm_le_env.scanning_params = (scanning_pdu_params *)ble_ke_malloc(0xc,'\0'); + (llm_le_env.scanning_params)->filterpolicy = '\0'; + (llm_le_env.scanning_params)->interval = 0x10; + (llm_le_env.scanning_params)->window = 8; + (llm_le_env.scanning_params)->type = '\0'; + (llm_le_env.scanning_params)->filter_duplicate = '\0'; + } + _Var1 = co_bdaddr_compare(&llm_le_env.rand_add,&co_null_bdaddr); + if (((CONCAT31(extraout_var,_Var1) != 0) && + (((llm_le_env.scanning_params)->own_addr_type & 1) != 0)) && + ((llm_le_env.scanning_params)->type == '\x01')) { + return '\x12'; + } + (llm_le_env.scanning_params)->filter_duplicate = param->filter_duplic_en; + llm_util_apply_bd_addr((llm_le_env.scanning_params)->own_addr_type); + if ((llm_le_env.scanning_params)->type == '\0') { + scan_req_pdu = (em_desc_node *)0x0; + } + else { + if ((llm_le_env.scanning_params)->type != '\x01') goto LAB_23033fd2; + scan_req_pdu = em_buf_env.tx_desc_node + 3; + } + llm_le_env.elt_coext_scan = lld_scan_start(llm_le_env.scanning_params,scan_req_pdu); + if (llm_le_env.elt_coext_scan == (ea_elt_tag *)0x0) { + return '\x1f'; + } +LAB_23033fd2: + kVar2 = ble_ke_state_get(0); + ble_ke_state_set(0,(byte)kVar2 & 0xf0 | 1); + return '\0'; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void llm_wl_clr(void) + +{ + uint16_t elem_index; + uint16_t uVar1; + + elem_index = 0; + do { + uVar1 = elem_index + 1; + llm_wlpriv_addr_set(elem_index,&llm_dflt_bdaddr); + elem_index = uVar1; + } while (uVar1 != 4); + elem_index = 0; + do { + uVar1 = elem_index + 1; + llm_wlpub_addr_set(elem_index,&llm_dflt_bdaddr); + elem_index = uVar1; + } while (uVar1 != 4); + _DAT_2800822e = _DAT_2800822e & 0xdfff; + _DAT_28008262 = _DAT_28008262 & 0xdfff; + _DAT_28008296 = _DAT_28008296 & 0xdfff; + llm_le_env.nb_dev_in_wl = '\0'; + llm_le_env.nb_dev_in_hw_wl = '\0'; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void llm_init(_Bool reset) + +{ + undefined3 in_register_00002029; + int iVar1; + ke_msg *msg; + + if (CONCAT31(in_register_00002029,reset) == 0) { + ble_ke_task_create(reset,&TASK_DESC_LLM); + ble_ke_event_callback_set('\x01',llm_encryption_done); + } + else { + if (llm_le_env.advertising_params != (advertising_pdu_params *)0x0) { + if ((llm_le_env.advertising_params)->adv_data_req != (ke_msg *)0x0) { + ble_ke_msg_free((llm_le_env.advertising_params)->adv_data_req); + } + if ((llm_le_env.advertising_params)->scan_rsp_req != (ke_msg *)0x0) { + ble_ke_msg_free((llm_le_env.advertising_params)->scan_rsp_req); + } + ble_ke_free(llm_le_env.advertising_params); + } + if (llm_le_env.scanning_params != (scanning_pdu_params *)0x0) { + ble_ke_free(llm_le_env.scanning_params); + } + lld_util_flush_list(&llm_le_env.adv_list); + lld_util_flush_list(&llm_le_env.cnx_list); + } + ble_ke_state_set(0,'\0'); + llm_le_env.test_mode.directtesttype = '\x03'; + llm_le_env.last_opcode = false; + llm_le_env.elt_coext_scan = (ea_elt_tag *)0x0; + llm_le_env.test_mode.end_of_tst = false; + iVar1 = bl_rand(); + llm_le_env.aa.intrand = (uint8_t)iVar1; + llm_le_env.aa.ct1_idx = '\0'; + llm_le_env.aa.ct2_idx = '\0'; + (*ble_memset_ptr)((void *)0x42026492,0xff,4); + llm_le_env.ch_map_assess.ch_map.map[4] = '\x1f'; + llm_le_env.elt = (ea_elt_tag *)0x0; + llm_wl_clr(); + llm_le_env.p256_byte_process_timeout = 0x10; + llm_le_env.cur_ecc_multiplication = LLM_ECC_IDLE; + llm_le_env.eventmask.mask[0] = '\x1f'; + (*ble_memset_ptr)((void *)0x42026499,0,7); + llm_le_env.enc_pend = false; + llm_le_env.scanning_params = (scanning_pdu_params *)0x0; + ble_co_list_init(&llm_le_env.adv_list); + llm_le_env.advertising_params = (advertising_pdu_params *)0x0; + (*ble_memset_ptr)((void *)0x420264bb,0,6); + llm_le_env.public_add.addr[0] = (uint8_t)_DAT_28000024; + llm_le_env.public_add.addr[1] = (uint8_t)((uint)_DAT_28000024 >> 8); + llm_le_env.public_add.addr[2] = (uint8_t)((uint)_DAT_28000024 >> 0x10); + llm_le_env.public_add.addr[3] = (uint8_t)((uint)_DAT_28000024 >> 0x18); + llm_le_env.public_add.addr[4] = (uint8_t)_DAT_28000028; + llm_le_env.public_add.addr[5] = (uint8_t)((uint)_DAT_28000028 >> 8); + while (msg = (ke_msg *)ble_co_list_pop_front((co_list *)&llm_le_env), msg != (ke_msg *)0x0) { + ble_ke_msg_free(msg); + } + ble_co_list_init((co_list *)&llm_le_env); + ble_co_list_init(&llm_le_env.cnx_list); + memcpy(&llm_le_env.data_len_val,&llm_local_data_len_values,0xc); + llm_le_env.ch_map_assess._0_4_ = 0xaf60064; + llm_le_env.ch_map_assess._4_2_ = 0x8c4; + llm_le_env.ch_map_assess.llm_le_set_host_ch_class_cmd_sto = true; + llm_le_env.opcode2 = 0; + llm_le_env.state2 = '\0'; + llm_le_env.opcode = 0; + llm_le_env.state = '\0'; + return; +} + + + +void llm_wl_dev_add(bd_addr *bd_addr,uint8_t bd_addr_type) + +{ + uint16_t elem_index; + undefined3 in_register_0000202d; + + elem_index = llm_util_bd_addr_wl_position(&llm_dflt_bdaddr,bd_addr_type); + if (CONCAT31(in_register_0000202d,bd_addr_type) == 0) { + llm_wlpub_addr_set(elem_index,bd_addr); + } + else { + if (CONCAT31(in_register_0000202d,bd_addr_type) == 1) { + llm_wlpriv_addr_set(elem_index,bd_addr); + } + } + llm_le_env.nb_dev_in_hw_wl = llm_le_env.nb_dev_in_hw_wl + '\x01'; + return; +} + + + +void llm_wl_dev_rem(bd_addr *bd_addr,uint8_t bd_addr_type) + +{ + uint16_t elem_index; + undefined2 extraout_var; + undefined3 in_register_0000202d; + + elem_index = llm_util_bd_addr_wl_position(bd_addr,bd_addr_type); + if (CONCAT22(extraout_var,elem_index) < 4) { + if (CONCAT31(in_register_0000202d,bd_addr_type) == 1) { + llm_wlpriv_addr_set(elem_index,&llm_dflt_bdaddr); + } + else { + llm_wlpub_addr_set(elem_index,&llm_dflt_bdaddr); + } + llm_le_env.nb_dev_in_hw_wl = llm_le_env.nb_dev_in_hw_wl + -1; + } + return; +} + + + +uint8_t llm_wl_dev_add_hdl(bd_addr *bd_addr,uint8_t bd_addr_type) + +{ + _Bool _Var1; + uint8_t uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 in_register_0000202d; + + if (1 < CONCAT31(in_register_0000202d,bd_addr_type)) { + return '\x12'; + } + _Var1 = llm_util_bd_addr_in_wl(bd_addr,bd_addr_type,(_Bool *)0x0); + if (CONCAT31(extraout_var,_Var1) == 0) { + uVar2 = '\a'; + if (llm_le_env.nb_dev_in_wl < 4) { + uVar2 = llm_util_bl_check(bd_addr,bd_addr_type,(uint16_t *)0x0,'\x02',(_Bool *)0x0); + if (CONCAT31(extraout_var_00,uVar2) != 0xb) { + llm_wl_dev_add(bd_addr,bd_addr_type); + } + uVar2 = '\0'; + llm_le_env.nb_dev_in_wl = llm_le_env.nb_dev_in_wl + '\x01'; + } + } + else { + uVar2 = '\x12'; + } + return uVar2; +} + + + +uint8_t llm_wl_dev_rem_hdl(bd_addr *bd_addr,uint8_t bd_addr_type) + +{ + uint8_t uVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 in_register_0000202d; + _Bool a_Stack17 [4]; + _Bool in_black_list; + + if (1 < CONCAT31(in_register_0000202d,bd_addr_type)) { + return '\x12'; + } + _Var2 = llm_util_bd_addr_in_wl(bd_addr,bd_addr_type,a_Stack17); + if (CONCAT31(extraout_var,_Var2) == 0) { + uVar1 = '\x12'; + } + else { + if (a_Stack17[0] == false) { + llm_wl_dev_rem(bd_addr,bd_addr_type); + } + else { + llm_util_bl_check(bd_addr,bd_addr_type,(uint16_t *)0x0,'\x01',(_Bool *)0x0); + } + uVar1 = '\0'; + llm_le_env.nb_dev_in_wl = llm_le_env.nb_dev_in_wl + -1; + } + return uVar1; +} + + + +uint8_t llm_create_con(hci_le_create_con_cmd *param) + +{ + byte bVar1; + ushort uVar2; + uint8_t uVar3; + uint8_t uVar4; + _Bool _Var5; + ke_state_t kVar6; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + + uVar3 = llc_util_get_free_conhdl(&llm_le_env.conhdl_alloc); + if (CONCAT31(extraout_var,uVar3) != 0) { + return '\t'; + } + if (param->init_filt_policy == '\x01') { + if (llm_le_env.nb_dev_in_hw_wl == '\0') { + return (llm_le_env.nb_dev_in_wl == '\0') + '\v'; + } + } + else { + uVar4 = llm_util_bl_check(¶m->peer_addr,param->peer_addr_type,&llm_le_env.conhdl_alloc,'\0', + (_Bool *)0x0); + if (CONCAT31(extraout_var_00,uVar4) != 0) { + return uVar4; + } + } + if (param->scan_window <= param->scan_intv) { + uVar2 = param->con_intv_max; + if ((uint)uVar2 < (uint)param->con_intv_min) { + return '\x12'; + } + if (0x3ffc < (ushort)(param->scan_window - 4)) { + return '\x12'; + } + if (0x3ffc < (ushort)(param->scan_intv - 4)) { + return '\x12'; + } + if (param->ce_len_max < param->ce_len_min) { + return '\x12'; + } + if (param->con_intv_min < 6) { + return '\x12'; + } + if (0xc80 < uVar2) { + return '\x12'; + } + if (0xc76 < ((uint)param->superv_to - 10 & 0xffff)) { + return '\x12'; + } + if (499 < param->con_latency) { + return '\x12'; + } + if ((uint)param->superv_to << 2 <= ((uint)param->con_latency + 1) * (uint)uVar2) { + return '\x12'; + } + _Var5 = co_bdaddr_compare(&llm_le_env.rand_add,&co_null_bdaddr); + bVar1 = param->own_addr_type; + if ((CONCAT31(extraout_var_01,_Var5) != 0) && ((bVar1 & 1) != 0)) { + return '\x12'; + } + if ((llm_le_env.enh_priv_info & 1) == 0) { + if ((bVar1 & 2) != 0) { + return '\x12'; + } + } + else { + if ((bVar1 & 2) != 0) goto LAB_230344b8; + } + if ((param->peer_addr_type & 2) == 0) { +LAB_230344b8: + kVar6 = ble_ke_state_get(0); + ble_ke_state_set(0,(byte)kVar6 & 0xf0 | 2); + llm_le_env.elt_coext_scan = + (ea_elt_tag *)lld_con_start(param,0x420262fc,(uint)llm_le_env.conhdl_alloc); + if (llm_le_env.elt_coext_scan == (ea_elt_tag *)0x0) { + return '\x1f'; + } + return uVar3; + } + } + return '\x12'; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void llm_encryption_start(llm_enc_req *param) + +{ + _DAT_280000c4 = *(undefined4 *)(param->key).ltk; + _DAT_280000c8 = *(undefined4 *)((param->key).ltk + 4); + _DAT_280000cc = *(undefined4 *)((param->key).ltk + 8); + _DAT_280000d0 = *(undefined4 *)((param->key).ltk + 0xc); + (*ble_memcpy_ptr)((void *)0x2800806e,param->plain_data,0x10); + _DAT_280000d4 = 0x6e; + _DAT_280000c0 = 1; + llm_le_env.enc_pend = true; + rwip_prevent_sleep_set(0x10); + return; +} + + + +void llm_encryption_done(void) + +{ + ke_msg *msg; + undefined *param; + + msg = (ke_msg *)ble_co_list_pop_front((co_list *)&llm_le_env); + ble_ke_event_clear('\x01'); + if (msg != (ke_msg *)0x0) { + if ((msg->src_id & 0xff) == 1) { + param = (undefined *)ble_ke_msg_alloc(5,msg->src_id,0,0x11); + (*ble_memcpy_ptr)(param + 1,(void *)0x2800807e,0x10); + *param = 0; + ble_ke_msg_send(param); + } + else { + param = (undefined *)ble_ke_msg_alloc(0x801,0,0x2017,0x11); + (*ble_memcpy_ptr)(param + 1,(void *)0x2800807e,0x10); + *param = 0; + hci_send_2_host(param); + } + ble_ke_msg_free(msg); + if (llm_le_env.enc_req.first != (co_list_hdr *)0x0) { + llm_encryption_start((llm_enc_req *)(llm_le_env.enc_req.first + 3)); + return; + } + rwip_prevent_sleep_clear(0x10); + llm_le_env.enc_pend = false; + } + return; +} + + + +void hci_fc_init(void) + +{ + // WARNING: Could not recover jumptable at 0x23034688. Too many branches + // WARNING: Treating indirect jump as call + (*ble_memset_ptr)(&hci_fc_env,0,10); + return; +} + + + +uint8_t hci_fc_acl_buf_size_set(uint16_t acl_pkt_len,uint16_t nb_acl_pkts) + +{ + undefined2 in_register_0000202a; + undefined2 in_register_0000202e; + uint8_t uVar1; + + uVar1 = '\x12'; + if (((CONCAT22(in_register_0000202a,acl_pkt_len) != 0) && + (CONCAT22(in_register_0000202e,nb_acl_pkts) != 0)) && + (uVar1 = '\x11', 0x3fc < CONCAT22(in_register_0000202a,acl_pkt_len))) { + uVar1 = '\0'; + hci_fc_env.host_set.acl_pkt_len = acl_pkt_len; + hci_fc_env.host_set.acl_pkt_nb = nb_acl_pkts; + } + return uVar1; +} + + + +uint8_t hci_fc_acl_en(_Bool flow_enable) + +{ + uint8_t uVar1; + ke_state_t kVar2; + undefined2 extraout_var; + undefined2 extraout_var_00; + + kVar2 = ble_ke_state_get(1); + if ((CONCAT22(extraout_var,kVar2) == 0x7f) && + (kVar2 = ble_ke_state_get(0x101), CONCAT22(extraout_var_00,kVar2) == 0x7f)) { + uVar1 = '\0'; + hci_fc_env.host_set.acl_flow_cntl_en = flow_enable; + } + else { + uVar1 = '\f'; + } + return uVar1; +} + + + +void hci_fc_host_nb_acl_pkts_complete(uint16_t acl_pkt_nb) + +{ + undefined2 in_register_0000202a; + uint16_t uVar1; + + uVar1 = 0; + if (CONCAT22(in_register_0000202a,acl_pkt_nb) < (uint)hci_fc_env.cntr) { + uVar1 = hci_fc_env.cntr - acl_pkt_nb; + } + hci_fc_env.cntr = uVar1; + return; +} + + + +uint8_t hci_pack_bytes(uint8_t **pp_in,uint8_t **pp_out,uint8_t *p_in_end,uint8_t *p_out_end, + uint8_t len) + +{ + uint8_t uVar1; + undefined3 in_register_00002039; + uint uVar2; + + uVar2 = CONCAT31(in_register_00002039,len); + uVar1 = '\x01'; + if (*pp_in + uVar2 <= p_in_end) { + uVar1 = '\0'; + if (p_out_end != (uint8_t *)0x0) { + uVar1 = (p_out_end < *pp_out + uVar2) << 1; + (*ble_memcpy_ptr)(*pp_out,*pp_in,uVar2); + } + *pp_in = *pp_in + uVar2; + *pp_out = *pp_out + uVar2; + } + return uVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +uint8_t hci_host_nb_cmp_pkts_cmd_pkupk(uint8_t *out,uint8_t *in,uint16_t *out_len,uint16_t in_len) + +{ + uint8_t *p_in_end; + uint8_t uVar1; + uint8_t uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined2 in_register_00002036; + uint uVar3; + int iVar4; + uint8_t *p_out_end; + uint8_t *puStack56; + uint8_t *p_in; + uint8_t *p_out; + + if (in == (uint8_t *)0x0) { + *out_len = 0xe; + uVar2 = '\0'; + } + else { + p_in_end = in + CONCAT22(in_register_00002036,in_len); + p_out_end = out + *out_len; + puStack56 = in; + p_in = out; + uVar1 = hci_pack_bytes(&puStack56,&p_in,p_in_end,p_out_end,'\x01'); + uVar2 = uVar1; + if (CONCAT31(extraout_var,uVar1) == 0) { + uVar3 = 0; + while( true ) { + uVar2 = uVar1; + if ((*in <= uVar3) || (&DAT_0000000e < p_in + -(int)out)) break; + iVar4 = (uVar3 + 1) * 2; + p_in = out + iVar4; + uVar2 = hci_pack_bytes(&puStack56,&p_in,p_in_end,p_out_end,'\x02'); + if (CONCAT31(extraout_var_00,uVar2) != 0) break; + p_in = out + iVar4 + 6; + uVar2 = hci_pack_bytes(&puStack56,&p_in,p_in_end,p_out_end,'\x02'); + if (CONCAT31(extraout_var_01,uVar2) != 0) break; + uVar3 = uVar3 + 1 & 0xff; + } + } + *out_len = (short)p_in - (short)out; + } + return uVar2; +} + + + +// WARNING: Variable defined which should be unmapped: temp_out +// WARNING: Could not reconcile some variable overlaps + +uint8_t hci_le_adv_report_evt_pkupk(uint8_t *out,uint8_t *in,uint16_t *out_len,uint16_t in_len) + +{ + uint8_t *p_out_end; + uint8_t uVar1; + uint8_t uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + undefined3 extraout_var_05; + undefined3 extraout_var_06; + undefined2 in_register_00002036; + uint8_t **ppuVar3; + int iVar4; + uint8_t **ppuStack84; + uint8_t *p_in; + uint8_t *p_out; + hci_le_adv_report_evt temp_out; + + if (in == (uint8_t *)0x0) { + *out_len = 0; + uVar1 = '\0'; + } + else { + if (out == (uint8_t *)0x0) { + p_out_end = temp_out.adv_rep[0].data + 0x1c; + out = (uint8_t *)&p_out; + } + else { + p_out_end = out + *out_len; + } + in = in + CONCAT22(in_register_00002036,in_len); + ppuStack84 = (uint8_t **)out; + p_in = out; + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack84,&p_in,in,p_out_end,'\x01'); + if (CONCAT31(extraout_var,uVar1) == 0) { + ppuStack84 = (uint8_t **)((int)out + 1); + uVar2 = hci_pack_bytes((uint8_t **)&ppuStack84,&p_in,in,p_out_end,'\x01'); + uVar1 = uVar2; + if (CONCAT31(extraout_var_00,uVar2) == 0) { + ppuVar3 = (uint8_t **)((int)out + 10); + iVar4 = 0; + while (uVar1 = uVar2, iVar4 < (int)(uint)*(byte *)((int)out + 1)) { + ppuStack84 = ppuVar3 + -2; + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack84,&p_in,in,p_out_end,'\x01'); + if (CONCAT31(extraout_var_01,uVar1) != 0) break; + ppuStack84 = (uint8_t **)((int)ppuVar3 + -7); + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack84,&p_in,in,p_out_end,'\x01'); + if (CONCAT31(extraout_var_02,uVar1) != 0) break; + ppuStack84 = (uint8_t **)((int)ppuVar3 + -6); + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack84,&p_in,in,p_out_end,'\x06'); + if (CONCAT31(extraout_var_03,uVar1) != 0) break; + ppuStack84 = ppuVar3; + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack84,&p_in,in,p_out_end,'\x01'); + if (CONCAT31(extraout_var_04,uVar1) != 0) break; + ppuStack84 = (uint8_t **)((int)ppuVar3 + 1); + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack84,&p_in,in,p_out_end,*(uint8_t *)ppuVar3); + if (CONCAT31(extraout_var_05,uVar1) != 0) break; + ppuStack84 = ppuVar3 + 8; + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack84,&p_in,in,p_out_end,'\x01'); + ppuVar3 = (uint8_t **)((int)ppuVar3 + 0x29); + if (CONCAT31(extraout_var_06,uVar1) != 0) break; + iVar4 = iVar4 + 1; + } + } + } + *out_len = (short)p_in - (short)out; + } + return uVar1; +} + + + +// WARNING: Variable defined which should be unmapped: temp_out +// WARNING: Could not reconcile some variable overlaps + +uint8_t hci_le_dir_adv_report_evt_pkupk(uint8_t *out,uint8_t *in,uint16_t *out_len,uint16_t in_len) + +{ + uint8_t *p_out_end; + uint8_t uVar1; + uint8_t uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + undefined3 extraout_var_05; + undefined3 extraout_var_06; + undefined2 in_register_00002036; + uint8_t **ppuVar3; + int iVar4; + uint8_t **ppuStack60; + uint8_t *p_in; + uint8_t *p_out; + hci_le_dir_adv_rep_evt temp_out; + + if (in == (uint8_t *)0x0) { + *out_len = 0; + uVar1 = '\0'; + } + else { + if (out == (uint8_t *)0x0) { + p_out_end = temp_out.adv_rep[0].dir_addr.addr + 3; + out = (uint8_t *)&p_out; + } + else { + p_out_end = out + *out_len; + } + in = in + CONCAT22(in_register_00002036,in_len); + ppuStack60 = (uint8_t **)out; + p_in = out; + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack60,&p_in,in,p_out_end,'\x01'); + if (CONCAT31(extraout_var,uVar1) == 0) { + ppuStack60 = (uint8_t **)((int)out + 1); + uVar2 = hci_pack_bytes((uint8_t **)&ppuStack60,&p_in,in,p_out_end,'\x01'); + uVar1 = uVar2; + if (CONCAT31(extraout_var_00,uVar2) == 0) { + ppuVar3 = (uint8_t **)((int)out + 0x11); + iVar4 = 0; + while (uVar1 = uVar2, iVar4 < (int)(uint)*(byte *)((int)out + 1)) { + ppuStack60 = (uint8_t **)((int)ppuVar3 + -0xf); + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack60,&p_in,in,p_out_end,'\x01'); + if (CONCAT31(extraout_var_01,uVar1) != 0) break; + ppuStack60 = (uint8_t **)((int)ppuVar3 + -0xe); + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack60,&p_in,in,p_out_end,'\x01'); + if (CONCAT31(extraout_var_02,uVar1) != 0) break; + ppuStack60 = (uint8_t **)((int)ppuVar3 + -0xd); + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack60,&p_in,in,p_out_end,'\x06'); + if (CONCAT31(extraout_var_03,uVar1) != 0) break; + ppuStack60 = (uint8_t **)((int)ppuVar3 + -7); + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack60,&p_in,in,p_out_end,'\x01'); + if (CONCAT31(extraout_var_04,uVar1) != 0) break; + ppuStack60 = (uint8_t **)((int)ppuVar3 + -6); + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack60,&p_in,in,p_out_end,'\x06'); + if (CONCAT31(extraout_var_05,uVar1) != 0) break; + ppuStack60 = ppuVar3; + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack60,&p_in,in,p_out_end,'\x01'); + ppuVar3 = ppuVar3 + 4; + if (CONCAT31(extraout_var_06,uVar1) != 0) break; + iVar4 = iVar4 + 1; + } + } + } + *out_len = (short)p_in - (short)out; + } + return uVar1; +} + + + +hci_cmd_desc_tag * hci_look_for_cmd_desc(uint16_t opcode) + +{ + undefined2 in_register_0000202a; + hci_cmd_desc_tag *phVar1; + uint16_t uVar2; + uint uVar3; + int iVar4; + + uVar3 = CONCAT22(in_register_0000202a,opcode) >> 10; + if (uVar3 == 1) { + iVar4 = 0; + } + else { + if (uVar3 == 3) { + iVar4 = 1; + } + else { + if (uVar3 == 4) { + iVar4 = 2; + } + else { + if (uVar3 == 5) { + iVar4 = 3; + } + else { + if (uVar3 == 8) { + iVar4 = 4; + } + else { + if (uVar3 != 0x3f) { + return (hci_cmd_desc_tag *)0x0; + } + iVar4 = 5; + } + } + } + } + } + phVar1 = hci_cmd_desc_root_tab[iVar4].cmd_desc_tab; + uVar2 = 0; + if (phVar1 != (hci_cmd_desc_tag *)0x0) { + while( true ) { + if (uVar2 == hci_cmd_desc_root_tab[iVar4].nb_cmds) { + return (hci_cmd_desc_tag *)0x0; + } + if ((phVar1->opcode & 0x3ff) == (opcode & 0x3ff)) break; + uVar2 = uVar2 + 1; + phVar1 = phVar1 + 1; + } + return phVar1; + } + return (hci_cmd_desc_tag *)0x0; +} + + + +hci_evt_desc_tag * hci_look_for_evt_desc(uint8_t code) + +{ + undefined3 in_register_00002029; + hci_evt_desc_tag *phVar1; + int iVar2; + + phVar1 = hci_evt_desc_tab; + iVar2 = 0; + do { + if ((uint)phVar1->code == CONCAT31(in_register_00002029,code)) { + return hci_evt_desc_tab + iVar2; + } + iVar2 = iVar2 + 1; + phVar1 = phVar1 + 1; + } while (iVar2 != 9); + return (hci_evt_desc_tag *)0x0; +} + + + +hci_evt_desc_tag * hci_look_for_le_evt_desc(uint8_t subcode) + +{ + undefined3 in_register_00002029; + hci_evt_desc_tag *phVar1; + int iVar2; + + phVar1 = hci_evt_le_desc_tab; + iVar2 = 0; + do { + if ((uint)phVar1->code == CONCAT31(in_register_00002029,subcode)) { + return hci_evt_le_desc_tab + iVar2; + } + iVar2 = iVar2 + 1; + phVar1 = phVar1 + 1; + } while (iVar2 != 0xc); + return (hci_evt_desc_tag *)0x0; +} + + + +void hci_tl_init(_Bool reset) + +{ + undefined3 in_register_00002029; + + if (CONCAT31(in_register_00002029,reset) == 0) { + (*ble_memset_ptr)(&hci_tl_env,0,0x1c); + ble_co_list_init((co_list *)&hci_tl_env); + ble_co_list_init(&hci_tl_env.acl_queue); + hci_tl_env.tx_state = '\x01'; + } + hci_tl_env.nb_h2c_cmd_pkts = '\x05'; + return; +} + + + +uint16_t hci_util_read_array_size(char **fmt_cursor) + +{ + byte *pbVar1; + uint uVar2; + + pbVar1 = (byte *)*fmt_cursor; + *(byte **)fmt_cursor = pbVar1 + 1; + uVar2 = (uint)*pbVar1 - 0x30; + while( true ) { + pbVar1 = (byte *)*fmt_cursor; + if (9 < (byte)(*pbVar1 - 0x30)) break; + *(byte **)fmt_cursor = pbVar1 + 1; + uVar2 = (uVar2 & 0xffff) * 10 + ((uint)*pbVar1 - 0x30); + } + return (uint16_t)(uVar2 & 0xffff); +} + + + +HCI_PACK_STATUS hci_util_pack(uint8_t *inout,uint16_t *inout_len,char *format) + +{ + char cVar1; + undefined2 uVar2; + uint8_t *puVar3; + undefined4 *puVar4; + uint16_t uVar5; + undefined2 extraout_var; + uint8_t *puVar6; + char *pcVar7; + uint uVar8; + undefined4 *puVar9; + undefined2 *puVar10; + undefined4 *puVar11; + undefined4 uVar12; + HCI_PACK_STATUS HVar13; + undefined4 *puVar14; + char *pcStack68; + char *cursor; + + puVar14 = (undefined4 *)(inout + *inout_len); + HVar13 = HCI_PACK_OK; + puVar6 = inout; + puVar9 = (undefined4 *)inout; + pcStack68 = format; +LAB_23034c16: + do { + do { + while( true ) { + while( true ) { + while( true ) { + puVar4 = puVar9; + puVar3 = puVar6; + if (*pcStack68 == '\0') { + if (HVar13 == HCI_PACK_OK) { + *inout_len = (short)puVar3 - (short)inout; + } + return HVar13; + } + if (HVar13 != HCI_PACK_OK) { + return HVar13; + } + uVar8 = 0; + if ((byte)(*pcStack68 - 0x30U) < 10) { + uVar5 = hci_util_read_array_size(&pcStack68); + uVar8 = CONCAT22(extraout_var,uVar5); + } + pcVar7 = pcStack68 + 1; + cVar1 = *pcStack68; + puVar6 = puVar3; + pcStack68 = pcVar7; + if (cVar1 != 'H') break; + puVar10 = (undefined2 *)((uint)((int)puVar4 + 1) & 0xfffffffe); + puVar9 = (undefined4 *)(puVar10 + 1); + if (inout != (uint8_t *)0x0) { + if (puVar14 < puVar9) goto LAB_23034d0e; + uVar2 = *puVar10; + *puVar3 = (uint8_t)uVar2; + puVar3[1] = (uint8_t)((ushort)uVar2 >> 8); + } + puVar6 = puVar3 + 2; + } + if (cVar1 != 'L') break; + puVar11 = (undefined4 *)((uint)((int)puVar4 + 3) & 0xfffffffc); + puVar9 = puVar11 + 1; + if (inout != (uint8_t *)0x0) { + if (puVar14 < puVar9) goto LAB_23034d0e; + uVar12 = *puVar11; + *puVar3 = (uint8_t)uVar12; + puVar3[1] = (uint8_t)((uint)uVar12 >> 8); + puVar3[2] = (uint8_t)((uint)uVar12 >> 0x10); + puVar3[3] = (uint8_t)((uint)uVar12 >> 0x18); + } + puVar6 = puVar3 + 4; + } + if (cVar1 == 'B') break; + HVar13 = HCI_PACK_WRONG_FORMAT; + puVar9 = puVar4; + } + puVar9 = (undefined4 *)((int)puVar4 + 1); + if (inout != (uint8_t *)0x0) { + if (puVar14 < puVar9) goto LAB_23034d0e; + *puVar3 = *(uint8_t *)puVar4; + } + puVar6 = puVar3 + 1; + } while (uVar8 < 2); + if (inout != (uint8_t *)0x0) { + puVar4 = puVar9; + if (puVar14 < (undefined4 *)((int)puVar4 + uVar8)) { +LAB_23034d0e: + HVar13 = HCI_PACK_IN_BUF_OVFLW; + puVar9 = puVar4; + goto LAB_23034c16; + } + (*ble_memcpy_ptr)(puVar6,puVar9,uVar8 - 1); + } + puVar6 = puVar3 + uVar8; + puVar9 = (undefined4 *)((int)puVar4 + uVar8); + } while( true ); +} + + + +HCI_PACK_STATUS +hci_util_unpack(uint8_t *out,uint8_t *in,uint16_t *out_len,uint16_t in_len,char *format) + +{ + char cVar1; + bool bVar2; + bool bVar3; + undefined4 *puVar4; + undefined4 *puVar5; + undefined4 *puVar6; + uint16_t uVar7; + undefined2 extraout_var; + undefined2 in_register_00002036; + char *pcVar8; + undefined2 *puVar9; + HCI_PACK_STATUS HVar10; + undefined4 *puVar11; + uint uVar12; + undefined4 *puVar13; + char *pcStack68; + char *cursor; + + puVar13 = (undefined4 *)(in + CONCAT22(in_register_00002036,in_len)); + puVar11 = (undefined4 *)(out + *out_len); + bVar2 = in != (uint8_t *)0x0; + bVar3 = out != (uint8_t *)0x0; + HVar10 = 0; + puVar6 = (undefined4 *)out; + pcStack68 = format; +LAB_23034d64: + do { + puVar5 = puVar6; + puVar4 = (undefined4 *)in; + if ((*pcStack68 == '\0') || (HVar10 != HCI_PACK_OK)) { + if (puVar13 < puVar4) { + HVar10 = HCI_PACK_IN_BUF_OVFLW; + } + *out_len = (short)puVar5 - (short)out; + return HVar10; + } + uVar12 = 0; + if ((byte)(*pcStack68 - 0x30U) < 10) { + uVar7 = hci_util_read_array_size(&pcStack68); + uVar12 = CONCAT22(extraout_var,uVar7); + } + pcVar8 = pcStack68 + 1; + cVar1 = *pcStack68; + puVar6 = puVar5; + pcStack68 = pcVar8; + if (cVar1 != 'H') { + if (cVar1 == 'L') { + puVar5 = (undefined4 *)((uint)((int)puVar5 + 3) & 0xfffffffc); + if (bVar3 && bVar2) { + if (puVar13 < puVar4 + 1) { +LAB_23034e98: + HVar10 = 1; + in = (uint8_t *)puVar4; + goto LAB_23034d64; + } + if (puVar11 < puVar5 + 1) goto LAB_23034ea0; + *puVar5 = *puVar4; + } + in = (uint8_t *)(puVar4 + 1); + puVar6 = puVar5 + 1; + goto LAB_23034d64; + } + if (cVar1 == 'B') { + in = (uint8_t *)((int)puVar4 + 1); + if (bVar3 && bVar2) { + if (puVar13 < in) goto LAB_23034e98; + if (puVar11 < (undefined4 *)((int)puVar5 + 1)) goto LAB_23034ea0; + *(undefined *)puVar5 = *(undefined *)puVar4; + } + puVar6 = (undefined4 *)((int)puVar5 + 1); + if (1 < uVar12) { + if (bVar3 && bVar2) { + puVar4 = (undefined4 *)in; + if (puVar13 < (undefined4 *)((int)puVar4 + uVar12)) goto LAB_23034e98; + if (puVar11 < (undefined4 *)((int)puVar5 + uVar12)) goto LAB_23034ea0; + (*ble_memcpy_ptr)(puVar6,in,uVar12 - 1); + } + in = (uint8_t *)(undefined4 *)((int)puVar4 + uVar12); + puVar6 = (undefined4 *)((int)puVar5 + uVar12); + } + } + else { + HVar10 = 3; + in = (uint8_t *)puVar4; + } + goto LAB_23034d64; + } + puVar9 = (undefined2 *)((uint)((int)puVar5 + 1) & 0xfffffffe); + if (bVar3 && bVar2) { + if (puVar13 < (undefined4 *)((int)puVar4 + 2)) goto LAB_23034e98; + if (puVar11 < puVar9 + 1) { +LAB_23034ea0: + HVar10 = 2; + in = (uint8_t *)puVar4; + goto LAB_23034d64; + } + *puVar9 = *(undefined2 *)puVar4; + } + in = (uint8_t *)(undefined4 *)((int)puVar4 + 2); + puVar6 = (undefined4 *)(puVar9 + 1); + } while( true ); +} + + + +// WARNING: Variable defined which should be unmapped: ret_par_len + +uint8_t * hci_build_cc_evt(ke_msg *msg,int8_t nb_h2c_cmd_pkts) + +{ + uint16_t opcode; + hci_cmd_desc_tag *phVar1; + code *format; + uint16_t auStack18 [2]; + uint16_t ret_par_len; + + opcode = msg->src_id; + auStack18[0] = msg->param_len; + phVar1 = hci_look_for_cmd_desc(opcode); + if ((phVar1 == (hci_cmd_desc_tag *)0x0) || (auStack18[0] == 0)) { + if (opcode != 0) { + *(undefined *)&msg[1].hdr.next = 1; + } + } + else { + format = (code *)phVar1->ret_par_fmt; + if (format != (code *)0x0) { + if ((char)phVar1->dest_field < '\0') { + (*format)(msg + 1,auStack18); + } + else { + hci_util_pack((uint8_t *)(msg + 1),auStack18,(char *)format); + } + } + } + msg->param_len = auStack18[0]; + return (uint8_t *)((int)&msg->dest_id + 1); +} + + + +uint8_t * hci_build_evt(ke_msg *msg) + +{ + hci_evt_desc_tag *phVar1; + code *format; + uint16_t auStack18 [2]; + uint16_t par_len; + + auStack18[0] = msg->param_len; + phVar1 = hci_look_for_evt_desc(*(uint8_t *)&msg->src_id); + if (phVar1 != (hci_evt_desc_tag *)0x0) { + format = (code *)phVar1->par_fmt; + if (format != (code *)0x0) { + if (phVar1->special_pack == '\0') { + hci_util_pack((uint8_t *)(msg + 1),auStack18,(char *)format); + } + else { + (*format)(msg + 1,auStack18,(uint)auStack18[0]); + } + } + msg->param_len = auStack18[0]; + } + return (uint8_t *)&msg->param_len; +} + + + +uint8_t * hci_build_le_evt(ke_msg *msg) + +{ + HCI_PACK_STATUS HVar1; + hci_evt_desc_tag *phVar2; + undefined3 extraout_var; + uint uVar3; + code *format; + uint16_t auStack18 [2]; + uint16_t par_len; + + auStack18[0] = msg->param_len; + phVar2 = hci_look_for_le_evt_desc(*(uint8_t *)&msg[1].hdr.next); + if ((phVar2 != (hci_evt_desc_tag *)0x0) && + (format = (code *)phVar2->par_fmt, format != (code *)0x0)) { + if (phVar2->special_pack == '\0') { + HVar1 = hci_util_pack((uint8_t *)(msg + 1),auStack18,(char *)format); + uVar3 = CONCAT31(extraout_var,HVar1); + } + else { + uVar3 = (*format)(msg + 1,auStack18,(uint)auStack18[0]); + uVar3 = uVar3 & 0xff; + } + if (uVar3 == 0) { + msg->param_len = auStack18[0]; + } + } + return (uint8_t *)&msg->param_len; +} + + + +uint8_t * hci_build_acl_rx_data(ke_msg *msg) + +{ + byte bVar1; + ke_msg_id_t kVar2; + uint8_t *puVar3; + uint uVar4; + + puVar3 = em_buf_rx_buff_addr_get((ushort)*(byte *)&msg[1].dest_id); + bVar1 = *(byte *)((int)&msg[1].hdr.next + 2); + uVar4 = (uint)*(ushort *)&msg[1].hdr.next & 0xfff; + puVar3[-4] = (uint8_t)uVar4; + puVar3[-3] = (uint8_t)((((uint)bVar1 << 0xc | uVar4) << 0x10) >> 0x18); + kVar2 = msg[1].id; + puVar3[-2] = (uint8_t)kVar2; + puVar3[-1] = (uint8_t)(kVar2 >> 8); + return puVar3 + -4; +} + + + +// WARNING: Type propagation algorithm not settling + +co_list_hdr * +ble_ke_queue_extract(co_list *queue,anon_subr__Bool_co_list_hdr_ptr_uint32_t *func,uint32_t arg) + +{ + co_list_hdr cVar1; + _Bool _Var2; + uint32_t uVar3; + undefined3 extraout_var; + co_list_hdr cStack36; + co_list_hdr *element; + + uVar3 = (*_rom_patch_hook)(&cStack36,queue,func,arg,_rom_patch_hook); + if (uVar3 == 0) { + cVar1 = (co_list_hdr)0x0; + cStack36 = (co_list_hdr)queue->first; + while (cStack36 != (co_list_hdr)0x0) { + _Var2 = (*func)((co_list_hdr *)cStack36,arg); + if (CONCAT31(extraout_var,_Var2) != 0) { + if (cVar1 == (co_list_hdr)0x0) { + *(co_list_hdr *)&queue->first = *(co_list_hdr *)cStack36; + } + else { + *(co_list_hdr *)cVar1 = *(co_list_hdr *)cStack36; + } + if (*(co_list_hdr *)cStack36 != (co_list_hdr)0x0) { + *(co_list_hdr *)cStack36 = (co_list_hdr)0x0; + return (co_list_hdr *)cStack36; + } + *(co_list_hdr *)&((co_list_hdr *)&queue->last)->next = cVar1; + return (co_list_hdr *)cStack36; + } + cVar1 = cStack36; + cStack36 = *(co_list_hdr *)cStack36; + } + } + return (co_list_hdr *)cStack36; +} + + + +// WARNING: Type propagation algorithm not settling + +void ble_ke_queue_insert(co_list *queue,co_list_hdr *element, + anon_subr__Bool_co_list_hdr_ptr_co_list_hdr_ptr *cmp) + +{ + co_list_hdr cVar1; + co_list_hdr cVar2; + _Bool _Var3; + uint32_t uVar4; + undefined3 extraout_var; + co_list_hdr cVar5; + + uVar4 = (*_rom_patch_hook)((void *)0x0,queue,element,cmp,_rom_patch_hook); + if (uVar4 == 0) { + cVar1 = (co_list_hdr)queue->first; + cVar5 = (co_list_hdr)(co_list_hdr *)0x0; + while (cVar2 = cVar1, cVar2 != (co_list_hdr)0x0) { + _Var3 = (*cmp)(element,(co_list_hdr *)cVar2); + if (CONCAT31(extraout_var,_Var3) != 0) goto LAB_230350c8; + cVar1 = *(co_list_hdr *)cVar2; + cVar5 = cVar2; + } + queue->last = element; +LAB_230350c8: + *(co_list_hdr *)&element->next = cVar2; + if (cVar5 == (co_list_hdr)0x0) { + queue->first = element; + } + else { + ((co_list_hdr *)cVar5)->next = element; + } + } + return; +} + + + +_Bool ble_cmp_dest_id(co_list_hdr *msg,uint32_t dest_id) + +{ + uint32_t uVar1; + bool abStack17 [4]; + _Bool result; + + uVar1 = (*_rom_patch_hook)(abStack17,msg,dest_id,_rom_patch_hook); + if (uVar1 == 0) { + abStack17[0] = (uint)*(ushort *)((int)&msg[1].next + 2) == dest_id; + } + return (_Bool)abStack17[0]; +} + + +/* +Unable to decompile 'ble_ke_task_saved_update' +Cause: Exception while decompiling 23035122: Decompiler process died + +*/ + + +ke_msg_func_t * ble_ke_handler_search(ke_msg_id_t msg_id,ke_state_handler *state_handler) + +{ + ushort uVar1; + undefined2 in_register_0000202a; + uint32_t uVar2; + uint uVar3; + ke_msg_func_t *pkStack20; + ke_msg_func_t *func; + + uVar2 = (*_rom_patch_hook)(&pkStack20,CONCAT22(in_register_0000202a,msg_id),state_handler, + _rom_patch_hook); + if (uVar2 == 0) { + uVar3 = (uint)state_handler->msg_cnt; + do { + uVar3 = uVar3 - 1; + if (uVar3 == 0xffffffff) { + return (ke_msg_func_t *)0x0; + } + uVar1 = state_handler->msg_table[uVar3].id; + } while ((CONCAT22(in_register_0000202a,msg_id) != (uint)uVar1) && (uVar1 != 0xffff)); + pkStack20 = state_handler->msg_table[uVar3].func; + } + return pkStack20; +} + + + +// WARNING: Variable defined which should be unmapped: func + +ke_msg_func_t * ble_ke_task_handler_get(ke_msg_id_t msg_id,ke_task_id_t task_id) + +{ + uint uVar1; + ke_task_desc *pkVar2; + undefined2 in_register_0000202a; + uint32_t uVar3; + undefined2 in_register_0000202e; + ke_msg_func_t *pkStack20; + ke_msg_func_t *func; + + pkStack20 = (ke_msg_func_t *)0x0; + uVar3 = (*_rom_patch_hook)(&pkStack20,CONCAT22(in_register_0000202a,msg_id), + CONCAT22(in_register_0000202e,task_id),_rom_patch_hook); + if (uVar3 == 0) { + pkVar2 = ble_ke_task_env.task_list[(uint)task_id & 0xff].p_desc; + if ((pkVar2->idx_max != 0) && + (uVar1 = CONCAT22(in_register_0000202e,task_id) >> 8, uVar1 < pkVar2->idx_max)) { + if (pkVar2->state_handler != (ke_state_handler *)0x0) { + pkStack20 = ble_ke_handler_search + (msg_id,pkVar2->state_handler + *(byte *)(uVar1 + (int)pkVar2->state)) + ; + } + if ((pkStack20 == (ke_msg_func_t *)0x0) && + (pkVar2->default_handler != (ke_state_handler *)0x0)) { + pkStack20 = ble_ke_handler_search(msg_id,pkVar2->default_handler); + } + } + } + return pkStack20; +} + + +/* +Unable to decompile 'ble_ke_task_schedule' +Cause: Exception while decompiling 2303525e: Decompiler process died + +*/ + + +void ble_ke_task_init(void) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,_rom_patch_hook); + if (uVar1 == 0) { + (*ble_memset_ptr)(&ble_ke_task_env,0,0x14); + ble_ke_event_callback_set('\x02',ble_ke_task_schedule); + return; + } + return; +} + + +/* +Unable to decompile 'ble_ke_task_create' +Cause: Exception while decompiling 23035342: Decompiler process died + +*/ + + +void ble_ke_state_set(ke_task_id_t id,ke_state_t_conflict state_id) + +{ + undefined2 in_register_0000202a; + uint32_t uVar1; + undefined3 in_register_0000202d; + uint uVar2; + ke_task_desc *pkVar3; + byte *pbVar4; + + uVar1 = (*_rom_patch_hook)((void *)0x0,CONCAT22(in_register_0000202a,id), + CONCAT31(in_register_0000202d,state_id),_rom_patch_hook); + if (uVar1 == 0) { + if (((uint)id & 0xff) < 5) { + pkVar3 = ble_ke_task_env.task_list[(uint)id & 0xff].p_desc; + uVar2 = CONCAT22(in_register_0000202a,id) >> 8; + if ((uVar2 < pkVar3->idx_max) && + (pbVar4 = (byte *)((int)pkVar3->state + uVar2), + (uint)*pbVar4 != CONCAT31(in_register_0000202d,state_id))) { + *pbVar4 = state_id; + ble_ke_task_saved_update(id); + return; + } + } + else { + ebreak(); + } + } + return; +} + + +/* +Unable to decompile 'ble_ke_state_get' +Cause: Exception while decompiling 23035412: Decompiler process died + +*/ + +/* +Unable to decompile 'llc_llcp_send' +Cause: Exception while decompiling 23035474: Decompiler process died + +*/ + + +undefined4 llcp_ping_rsp_handler(int param_1,ke_task_id_t param_2) + +{ + llc_env_tag *plVar1; + ke_state_t kVar2; + + kVar2 = ble_ke_state_get(param_2); + plVar1 = llc_env[param_1]; + if ((plVar1->encryption_state & 8) == 0) { + if (((kVar2 & 1) != 0) && (plVar1->loc_proc_state == '\x05')) { + ble_ke_state_set(param_2,(byte)kVar2 & 0xfe); + plVar1->loc_proc_state = '\0'; + ble_ke_timer_clear(0x102,param_2); + } + } + else { + llc_util_dicon_procedure((uint16_t)param_1,'='); + } + return 0; +} + + + +int llcp_terminate_ind_handler + (uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_terminate_ind *param) + +{ + uint8_t uVar1; + undefined2 in_register_0000202a; + undefined3 extraout_var; + llc_env_tag *plVar2; + + ble_ke_timer_clear(0x102,dest_id); + plVar2 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + plVar2->disc_reason = param->err_code; + plVar2->llc_status = plVar2->llc_status | 0x200; + ble_ke_state_set(dest_id,'\x0f'); + uVar1 = lld_get_mode(conhdl); + if (CONCAT31(extraout_var,uVar1) == 4) { + llc_util_dicon_procedure(conhdl,param->err_code); + } + return 0; +} + + +/* +Unable to decompile 'llcp_enc_rsp_handler' +Cause: Exception while decompiling 230355f2: Decompiler process died + +*/ + + +void llc_llcp_reject_ind(int param_1,ke_task_id_t param_2,int param_3,int param_4) + +{ + byte bVar1; + uint8_t uVar2; + _Bool _Var3; + ke_state_t kVar4; + uint16_t conhdl; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + llc_env_tag *plVar5; + + kVar4 = ble_ke_state_get(param_2); + plVar5 = llc_env[param_1]; + ble_ke_timer_clear(0x102,param_2); + conhdl = (uint16_t)param_1; + bVar1 = (byte)kVar4; + if ((kVar4 & 1) == 0) { + if ((((kVar4 & 2) != 0) && (param_4 != 0)) && ((llc_env[param_1]->encryption_state & 8) == 0)) { + if (plVar5->rem_proc_state != '\x03') { + return; + } + ble_ke_state_set(param_2,bVar1 & 0xfd); + plVar5->rem_proc_state = '\0'; + return; + } +LAB_230358e8: + if ((llc_env[param_1]->encryption_state & 8) == 0) { + return; + } + llc_util_dicon_procedure(conhdl,'='); + return; + } + switch((uint)plVar5->loc_proc_state - 4 & 0xff) { + case 0: + if ((llc_env[param_1]->encryption_state & 8) != 0) goto LAB_230358e8; + ble_ke_timer_clear(0x102,param_2); + break; + case 1: + break; + case 2: + case 5: + goto LAB_2303588a; + case 3: + if ((param_4 == 0) || ((llc_env[param_1]->encryption_state & 8) != 0)) goto LAB_230358e8; + ble_ke_timer_clear(0x102,param_2); + if ((param_3 == 0x1a) && (uVar2 = lld_get_mode(conhdl), CONCAT31(extraout_var_00,uVar2) == 3)) { + *(undefined *)llc_env[param_1]->operation[0] = 2; + ble_ke_msg_send(); + return; + } + if ((plVar5->llc_status & 0x40) != 0) { + plVar5->llc_status = plVar5->llc_status & 0xffbf; + _Var3 = llm_util_check_evt_mask('\x02'); + if (CONCAT31(extraout_var_01,_Var3) != 0) { + llc_con_update_complete_send((uint8_t)param_3,conhdl,(lld_evt_tag *)&plVar5->elt->env); + } + } + llc_util_clear_operation_ptr(param_1,0); + break; + default: + goto LAB_230358e8; + case 9: + case 10: + case 0xb: + case 0xc: + ble_ke_timer_clear(0x102,param_2); + uVar2 = lld_get_mode(conhdl); + if (CONCAT31(extraout_var,uVar2) != 3) { + return; + } + if ((llc_env[param_1]->encryption_state & 0x10) != 0) { + return; + } + llc_env[param_1]->encryption_state = '\0'; + llc_common_enc_change_evt_send(conhdl,'\0',(uint8_t)param_3); + ble_ke_state_set(param_2,bVar1 & 0xfe); + plVar5->loc_proc_state = '\0'; + ble_ke_state_set(param_2,bVar1 & 0xfa); + return; + } + ble_ke_state_set(param_2,bVar1 & 0xfe); + plVar5->loc_proc_state = '\0'; +LAB_2303588a: + return; +} + + + +int llcp_reject_ind_ext_handler + (uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_reject_ind_ext *param) + +{ + undefined2 in_register_0000202a; + + llc_llcp_reject_ind(CONCAT22(in_register_0000202a,conhdl),(uint)param->err_code,1); + return 0; +} + + + +int llcp_reject_ind_handler + (uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_reject_ind *param) + +{ + undefined2 in_register_0000202a; + + llc_llcp_reject_ind(CONCAT22(in_register_0000202a,conhdl),(uint)param->err_code,0); + return 0; +} + + +/* +Unable to decompile 'llcp_pause_enc_req_handler' +Cause: Exception while decompiling 2303593e: Decompiler process died + +*/ + + +undefined4 llcp_start_enc_req_handler(int param_1,ke_task_id_t param_2) + +{ + uint8_t uVar1; + llc_env_tag *plVar2; + ke_state_t kVar3; + + kVar3 = ble_ke_state_get(param_2); + plVar2 = llc_env[param_1]; + if (((plVar2->encryption_state & 8) != 0) && ((plVar2->loc_proc_state - 0xe & 0xfd) != 0)) { + llc_util_dicon_procedure((uint16_t)param_1,'='); + } + uVar1 = plVar2->loc_proc_state; + if ((kVar3 & 1) == 0) { + if (uVar1 == '\x0e') goto LAB_23035a9a; + } + else { + if (uVar1 == '\x0e') { +LAB_23035a9a: + plVar2->loc_proc_state = '\x0f'; + return 0; + } + if (uVar1 != '\x10') { + return 0; + } + } + plVar2->loc_proc_state = '\x11'; + ble_ke_msg_send_basic(0x106,param_2,param_2); + return 0; +} + + +/* +Unable to decompile 'llcp_enc_req_handler' +Cause: Exception while decompiling 23035ab0: Decompiler process died + +*/ + + +undefined4 llcp_unknown_rsp_handler(int param_1,ke_task_id_t param_2,int param_3) + +{ + llc_env_tag *plVar1; + uint8_t uVar2; + _Bool _Var3; + ke_state_t kVar4; + uint16_t conhdl; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined *param; + + kVar4 = ble_ke_state_get(param_2); + plVar1 = llc_env[param_1]; + conhdl = (uint16_t)param_1; + if (((plVar1->encryption_state & 8) != 0) && (plVar1->loc_proc_state != '\r')) { + llc_util_dicon_procedure(conhdl,'='); + return 0; + } + if ((kVar4 & 1) == 0) { + return 0; + } + switch((uint)plVar1->loc_proc_state - 1 & 0xff) { + case 0: + if (*(char *)(param_3 + 1) != '\x0e') { + return 0; + } + ble_ke_timer_clear(0x102,param_2); + llc_feats_rd_event_send('\x1a',conhdl,&plVar1->feats_used); + break; + default: + goto switchD_23035c3a_caseD_1; + case 3: + if (*(char *)(param_3 + 1) != '\x14') { + return 0; + } + ble_ke_timer_clear(0x102,param_2); + (plVar1->data_len_ext_info).send_req_not_allowed = true; + _Var3 = llm_util_check_evt_mask('\x06'); + if ((CONCAT31(extraout_var_01,_Var3) != 0) && + (((plVar1->data_len_ext_info).data_len_ext_flag & 2) == 0)) { + param = (undefined *)ble_ke_msg_alloc(0x804,conhdl,0x3e,0xc); + *param = 7; + *(uint16_t *)(param + 2) = conhdl; + *(uint16_t *)(param + 8) = (plVar1->data_len_ext_info).conn_eff_max_rx_octets; + *(uint16_t *)(param + 10) = (plVar1->data_len_ext_info).conn_eff_max_rx_time; + *(uint16_t *)(param + 4) = (plVar1->data_len_ext_info).conn_eff_max_tx_octets; + *(uint16_t *)(param + 6) = (plVar1->data_len_ext_info).conn_eff_max_tx_time; + hci_send_2_host(param); + (plVar1->data_len_ext_info).data_len_ext_flag = + (plVar1->data_len_ext_info).data_len_ext_flag | 2; + } + break; + case 4: + if (*(char *)(param_3 + 1) != '\x12') { + return 0; + } + ble_ke_state_set(param_2,(byte)kVar4 & 0xfe); + plVar1->loc_proc_state = '\0'; + ble_ke_timer_clear(0x102,param_2); + return 0; + case 6: + if (*(char *)(param_3 + 1) != '\x0f') { + return 0; + } + ble_ke_timer_clear(0x102,param_2); + plVar1->peer_sup_conn_param_req = false; + uVar2 = lld_get_mode(conhdl); + if (CONCAT31(extraout_var,uVar2) == 3) { + *(undefined *)llc_env[param_1]->operation[0] = 2; + ble_ke_msg_send(); + return 0; + } + if ((plVar1->llc_status & 0x40) != 0) { + plVar1->llc_status = plVar1->llc_status & 0xffbf; + _Var3 = llm_util_check_evt_mask('\x02'); + if (CONCAT31(extraout_var_00,_Var3) != 0) { + llc_con_update_complete_send('\x1a',conhdl,(lld_evt_tag *)&plVar1->elt->env); + } + } + llc_util_clear_operation_ptr(param_1,0); + break; + case 0xc: + if ((plVar1->encryption_state & 0x10) != 0) { + return 0; + } + plVar1->encryption_state = '\0'; + llc_common_enc_change_evt_send(conhdl,'\0','\x1a'); + } + ble_ke_state_set(param_2,(byte)kVar4 & 0xfe); + plVar1->loc_proc_state = '\0'; +switchD_23035c3a_caseD_1: + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void llc_llcp_version_ind_pdu_send(uint16_t conhdl) + +{ + undefined4 uStack24; + llcp_vers_ind pdu; + + uStack24 = 0x7af090c; + pdu._0_2_ = 0x321; + llc_llcp_send((uint8_t)conhdl,&uStack24,'\f'); + return; +} + + + +undefined4 llcp_vers_ind_handler(int param_1,ke_task_id_t param_2,int param_3) + +{ + ushort uVar1; + uint16_t uVar2; + llc_env_tag *plVar3; + ke_state_t kVar4; + uint16_t conhdl; + + kVar4 = ble_ke_state_get(param_2); + plVar3 = llc_env[param_1]; + conhdl = (uint16_t)param_1; + if ((plVar3->encryption_state & 8) == 0) { + uVar1 = plVar3->llc_status; + (plVar3->peer_version).vers = *(uint8_t *)(param_3 + 1); + (plVar3->peer_version).compid = *(uint16_t *)(param_3 + 2); + uVar2 = *(uint16_t *)(param_3 + 4); + plVar3->llc_status = uVar1 | 2; + (plVar3->peer_version).subvers = uVar2; + if (((kVar4 & 1) == 0) || (plVar3->loc_proc_state != '\x02')) { + if (((int)(uint)uVar1 >> 1 & 1U) == 0) { + llc_llcp_version_ind_pdu_send(conhdl); + } + } + else { + ble_ke_timer_clear(0x102,param_2); + llc_version_rd_event_send('\0',conhdl); + plVar3->loc_proc_state = '\0'; + ble_ke_state_set(param_2,(byte)kVar4 & 0xfe); + } + } + else { + llc_util_dicon_procedure(conhdl,'='); + } + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void llc_llcp_ch_map_update_pdu_send(uint16_t conhdl) + +{ + llc_env_tag *plVar1; + undefined2 in_register_0000202a; + uint8_t uStack24; + undefined auStack23 [3]; + llcp_channel_map_ind pdu; + + plVar1 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + uStack24 = '\x01'; + pdu.ch_map.map._1_2_ = lld_util_instant_get(&plVar1->elt->env,'\x02'); + (*ble_memcpy_ptr)(auStack23,&plVar1->n_ch_map,5); + llc_llcp_send((uint8_t)conhdl,&uStack24,uStack24); + return; +} + + + +void llc_llcp_pause_enc_req_pdu_send(uint16_t conhdl) + +{ + uint8_t auStack20 [4]; + llcp_pause_enc_req pdu; + + auStack20[0] = '\n'; + ble_ke_timer_set(0x102,conhdl << 8 | 1,4000); + llc_llcp_send((uint8_t)conhdl,auStack20,auStack20[0]); + return; +} + + + +void llc_llcp_pause_enc_rsp_pdu_send(uint16_t conhdl) + +{ + undefined2 in_register_0000202a; + ushort *puVar1; + undefined auStack20 [4]; + llcp_pause_enc_rsp pdu; + + auStack20[0] = 0xb; + puVar1 = (ushort *)(CONCAT22(in_register_0000202a,conhdl) * 0x5c + 0x28008092); + *puVar1 = *puVar1 & 0xfeff; + llc_env[CONCAT22(in_register_0000202a,conhdl)]->encryption_state = + llc_env[CONCAT22(in_register_0000202a,conhdl)]->encryption_state & 0xfd; + llc_llcp_send((uint8_t)conhdl,auStack20,'\v'); + return; +} + + +/* +Unable to decompile 'llcp_pause_enc_rsp_handler' +Cause: Exception while decompiling 23035f58: Decompiler process died + +*/ + + +// WARNING: Variable defined which should be unmapped: pdu +// WARNING: Could not reconcile some variable overlaps + +void llc_llcp_enc_req_pdu_send(uint16_t conhdl,hci_le_start_enc_cmd *param) + +{ + int iVar1; + undefined2 in_register_0000202a; + llc_env_tag *plVar2; + uint8_t uStack56; + undefined auStack55 [3]; + llcp_enc_req pdu; + + uStack56 = '\x03'; + pdu.rand.nb[4] = (uint8_t)param->enc_div; + pdu.rand.nb[5] = (uint8_t)(param->enc_div >> 8); + plVar2 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + (*ble_memcpy_ptr)(auStack55,¶m->nb,8); + (*ble_memcpy_ptr)(pdu.skdm.skdiv + 4,(plVar2->encrypt).randn,4); + iVar1 = CONCAT22(in_register_0000202a,conhdl) * 0x5c; + (*ble_memcpy_ptr)(pdu.rand.nb + 6,(plVar2->encrypt).randn + 4,8); + *(undefined2 *)(iVar1 + 0x280080c4) = pdu.skdm.skdiv._4_2_; + *(undefined2 *)(iVar1 + 0x280080c6) = pdu.skdm.skdiv._6_2_; + (*ble_memcpy_ptr)(&(plVar2->encrypt).ltk,¶m->ltk,0x10); + (*ble_memcpy_ptr)(&plVar2->encrypt,pdu.rand.nb + 6,8); + *(ushort *)(iVar1 + 0x28008092) = *(ushort *)(iVar1 + 0x28008092) & 0xfeff; + plVar2 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + plVar2->encryption_state = plVar2->encryption_state & 0xfd; + ble_ke_timer_set(0x102,conhdl << 8 | 1,4000); + llc_llcp_send((uint8_t)conhdl,&uStack56,uStack56); + return; +} + + + +// WARNING: Variable defined which should be unmapped: pdu +// WARNING: Could not reconcile some variable overlaps + +void llc_llcp_enc_rsp_pdu_send(uint16_t conhdl,llcp_enc_req *param) + +{ + llc_env_tag *plVar1; + undefined2 in_register_0000202a; + int iVar2; + uint8_t local_20; + undefined auStack31 [3]; + llcp_enc_rsp pdu; + + plVar1 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + local_20 = '\x04'; + (*ble_memcpy_ptr)(pdu.skds.skdiv + 4,(plVar1->encrypt).randn,4); + (*ble_memcpy_ptr)(auStack31,(plVar1->encrypt).randn + 4,8); + iVar2 = CONCAT22(in_register_0000202a,conhdl) * 0x5c; + *(undefined2 *)(iVar2 + 0x280080c8) = pdu.skds.skdiv._4_2_; + *(undefined2 *)(iVar2 + 0x280080ca) = pdu.skds.skdiv._6_2_; + (*ble_memcpy_ptr)((plVar1->encrypt).skd.skd + 8,auStack31,8); + llc_llcp_send((uint8_t)conhdl,&local_20,local_20); + return; +} + + + +void llc_llcp_start_enc_rsp_pdu_send(uint16_t conhdl) + +{ + uint16_t rx_time; + uint16_t tx_time; + undefined2 in_register_0000202a; + ushort *puVar1; + llc_env_tag *plVar2; + uint8_t auStack20 [4]; + llcp_start_enc_rsp pdu; + + auStack20[0] = '\x06'; + puVar1 = (ushort *)(CONCAT22(in_register_0000202a,conhdl) * 0x5c + 0x28008092); + *puVar1 = *puVar1 | 0x300; + plVar2 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + rx_time = (plVar2->data_len_ext_info).conn_eff_max_rx_time; + tx_time = (plVar2->data_len_ext_info).conn_eff_max_tx_time; + plVar2->encryption_state = plVar2->encryption_state | 3; + lld_util_compute_ce_max(plVar2->elt,tx_time,rx_time); + llc_llcp_send((uint8_t)conhdl,auStack20,auStack20[0]); + return; +} + + +/* +Unable to decompile 'llcp_start_enc_rsp_handler' +Cause: Exception while decompiling 230362be: Decompiler process died + +*/ + + +void llc_llcp_reject_ind_pdu_send(uint16_t conhdl,uint8_t rej_opcode,uint8_t reason) + +{ + undefined2 in_register_0000202a; + undefined3 in_register_0000202d; + uint8_t opcode; + llc_env_tag *plVar1; + undefined uStack20; + uint8_t uStack19; + uint8_t uStack18; + llcp_reject_ind_ext pdu; + + plVar1 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + if ((((plVar1->llc_status & 1) == 0) || (((plVar1->feats_used).feats[0] & 4) == 0)) && + (CONCAT31(in_register_0000202d,rej_opcode) < 0xe)) { + uStack20 = 0xd; + if ((CONCAT31(in_register_0000202d,rej_opcode) - 3 & 0xfd) == 0) { + plVar1->encryption_state = '\0'; + } + opcode = '\r'; + uStack19 = reason; + } + else { + uStack20 = 0x11; + opcode = '\x11'; + uStack19 = rej_opcode; + uStack18 = reason; + } + llc_llcp_send((uint8_t)conhdl,&uStack20,opcode); + return; +} + + +/* +Unable to decompile 'llcp_length_rsp_handler' +Cause: Exception while decompiling 23036494: Decompiler process died + +*/ + + +int llcp_con_param_rsp_handler + (uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_con_param_rsp *param) + +{ + uint8_t uVar1; + _Bool _Var2; + ke_state_t kVar3; + undefined2 in_register_0000202a; + undefined3 extraout_var; + undefined *puVar4; + undefined3 extraout_var_00; + llc_env_tag *plVar5; + ushort uVar6; + ea_elt_tag *peVar7; + + kVar3 = ble_ke_state_get(dest_id); + plVar5 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + if ((plVar5->encryption_state & 8) == 0) { + if (plVar5->loc_proc_state == '\a') { + ble_ke_timer_clear(0x102,dest_id); + uVar1 = lld_get_mode(conhdl); + if (CONCAT31(extraout_var,uVar1) == 3) { + plVar5 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + puVar4 = (undefined *)plVar5->operation[0]; + if ((*(ushort *)(puVar4 + 4) < param->interval_min) || + (param->interval_max < *(ushort *)(puVar4 + 2))) { + peVar7 = plVar5->elt; + llc_llcp_reject_ind_pdu_send(conhdl,'\x10',' '); + if ((plVar5->llc_status & 0x40) != 0) { + plVar5->llc_status = plVar5->llc_status & 0xffbf; + _Var2 = llm_util_check_evt_mask('\x02'); + if (CONCAT31(extraout_var_00,_Var2) != 0) { + llc_con_update_complete_send(' ',conhdl,(lld_evt_tag *)&peVar7->env); + } + } + ble_ke_state_set(dest_id,(byte)kVar3 & 0xfe); + plVar5->loc_proc_state = '\0'; + llc_util_clear_operation_ptr(CONCAT22(in_register_0000202a,conhdl),0); + } + else { + *puVar4 = 4; + *(uint16_t *)(puVar4 + 2) = param->interval_min; + *(uint16_t *)(puVar4 + 4) = param->interval_max; + uVar6 = param->latency; + if (param->latency < *(ushort *)(puVar4 + 6)) { + uVar6 = *(ushort *)(puVar4 + 6); + } + *(ushort *)(puVar4 + 6) = uVar6; + uVar6 = param->timeout; + if (param->timeout < *(ushort *)(puVar4 + 8)) { + uVar6 = *(ushort *)(puVar4 + 8); + } + *(ushort *)(puVar4 + 8) = uVar6; + *(ushort *)(puVar4 + 10) = plVar5->elt->duration_min / 0x271; + *(ushort *)(puVar4 + 0xc) = plVar5->elt->duration_min / 0x271; + ble_ke_msg_send(); + } + } + } + else { + llc_llcp_reject_ind_pdu_send(conhdl,param->opcode,'\x1f'); + } + } + else { + llc_util_dicon_procedure(conhdl,'='); + } + return 0; +} + + + +undefined4 llcp_feats_rsp_handler(int param_1,ke_task_id_t param_2,uint8_t *param_3) + +{ + byte *pbVar1; + llc_env_tag *plVar2; + ke_state_t kVar3; + uint16_t conhdl; + le_features *plVar4; + encrypt_conflict *peVar5; + encrypt_conflict *peVar6; + + kVar3 = ble_ke_state_get(param_2); + plVar2 = llc_env[param_1]; + conhdl = (uint16_t)param_1; + if ((plVar2->encryption_state & 8) == 0) { + if (((kVar3 & 1) == 0) || (plVar2->loc_proc_state != '\x01')) { + llc_llcp_reject_ind_pdu_send(conhdl,*param_3,'\x11'); + } + else { + ble_ke_timer_clear(0x102,(ushort)(param_1 << 8) | 1); + plVar4 = (le_features *)(param_3 + 1); + peVar5 = (encrypt_conflict *)&plVar2->feats_used; + do { + pbVar1 = plVar4->feats; + peVar6 = (encrypt_conflict *)((peVar5->skd).skd + 1); + plVar4 = (le_features *)(plVar4->feats + 1); + (peVar5->skd).skd[0] = (peVar5->skd).skd[0] & *pbVar1; + peVar5 = peVar6; + } while (peVar6 != &plVar2->encrypt); + plVar2->llc_status = plVar2->llc_status | 1; + llc_feats_rd_event_send('\0',conhdl,(le_features *)(param_3 + 1)); + plVar2->loc_proc_state = '\0'; + ble_ke_state_set(param_2,(byte)kVar3 & 0xfe); + } + } + else { + llc_util_dicon_procedure(conhdl,'='); + } + return 0; +} + + + +int llcp_channel_map_ind_handler(int param_1,ke_task_id_t param_2,int param_3,uint8_t *param_4) + +{ + uint16_t instant; + ushort uVar1; + llc_env_tag *plVar2; + _Bool _Var3; + uint8_t reason; + ke_state_t kVar4; + uint16_t conhdl; + undefined3 extraout_var; + undefined3 extraout_var_00; + int iVar5; + ea_elt_tag *elt; + + kVar4 = ble_ke_state_get(param_2); + plVar2 = llc_env[param_1]; + iVar5 = (uint)(param_3 != 0) << 1; + conhdl = (uint16_t)param_1; + if (param_3 == 0) { + if (param_4[-1] == 0) goto LAB_230368ac; + switch((uint)param_4[-1] - 1 & 0xff) { + case 0: + goto switchD_230368e8_caseD_0; + case 1: + goto switchD_230368e8_caseD_1; + case 2: +switchD_230368e8_caseD_2: + reason = '('; + goto LAB_23036994; + case 3: + goto switchD_230368e8_caseD_3; + case 4: + goto switchD_230368e8_caseD_4; + default: + return iVar5; + } + } + param_4[-1] = '\0'; +LAB_230368ac: + if ((llc_env[param_1]->encryption_state & 8) != 0) { + param_4[-1] = '\x04'; + if (param_3 != 0) { + return iVar5; + } +switchD_230368e8_caseD_3: + reason = '='; +LAB_23036994: + llc_util_dicon_procedure(conhdl,reason); + return iVar5; + } + _Var3 = lld_util_instant_ongoing(plVar2->elt); + if (CONCAT31(extraout_var,_Var3) == 0) { + reason = lld_get_mode(conhdl); + if ((CONCAT31(extraout_var_00,reason) == 4) && ((kVar4 & 2) == 0)) { + elt = plVar2->elt; + instant = *(uint16_t *)(param_4 + 6); + if ((ushort)(instant - *(short *)&elt[2].timestamp) < 0x7fff) { + memcpy(&plVar2->n_ch_map,param_4 + 1,5); + lld_ch_map_ind(elt,instant); + param_4[-1] = '\x01'; + if (param_3 != 0) { + return iVar5; + } +switchD_230368e8_caseD_0: + uVar1 = plVar2->llc_status; + if (-1 < (int)((uint)uVar1 << 0x14)) { + plVar2->llc_status = uVar1 | 0x400; + plVar2->rem_proc_state = '\x01'; + ble_ke_state_set(param_2,(byte)kVar4 | 2); + return iVar5; + } + plVar2->llc_status = uVar1 & 0xf7ff; + return iVar5; + } + param_4[-1] = '\x03'; + if (param_3 != 0) { + return iVar5; + } + goto switchD_230368e8_caseD_2; + } + param_4[-1] = '\x05'; + if (param_3 != 0) { + return iVar5; + } +switchD_230368e8_caseD_4: + reason = '\x11'; + goto LAB_230369a0; + } + param_4[-1] = '\x02'; + if (param_3 != 0) { + return iVar5; + } +switchD_230368e8_caseD_1: + reason = '#'; +LAB_230369a0: + llc_llcp_reject_ind_pdu_send(conhdl,*param_4,reason); + return iVar5; +} + + + +int llcp_con_upd_ind_handler(int param_1,ke_task_id_t param_2,int param_3,llcp_con_upd_ind *param_4) + +{ + byte bVar1; + ushort uVar2; + llc_env_tag *plVar3; + _Bool _Var4; + uint8_t reason; + ke_state_t kVar5; + uint16_t conhdl; + undefined3 extraout_var; + undefined3 extraout_var_00; + byte state_id; + int iVar6; + + plVar3 = llc_env[param_1]; + kVar5 = ble_ke_state_get(param_2); + state_id = (byte)kVar5; + iVar6 = (uint)(param_3 != 0) << 1; + conhdl = (uint16_t)param_1; + if (param_3 == 0) { + bVar1 = *(byte *)((int)¶m_4[-1].instant + 1); + if (bVar1 == 0) goto LAB_23036a18; + switch((uint)bVar1 - 1 & 0xff) { + case 0: + goto switchD_23036a56_caseD_0; + case 1: + goto switchD_23036a56_caseD_1; + case 2: +switchD_23036a56_caseD_2: + reason = '('; + goto LAB_23036b6a; + case 3: + goto switchD_23036a56_caseD_3; + case 4: + goto switchD_23036a56_caseD_4; + default: + return iVar6; + } + } + *(undefined *)((int)¶m_4[-1].instant + 1) = 0; +LAB_23036a18: + if ((llc_env[param_1]->encryption_state & 8) != 0) { + *(undefined *)((int)¶m_4[-1].instant + 1) = 4; + if (param_3 != 0) { + return iVar6; + } +switchD_23036a56_caseD_3: + reason = '='; +LAB_23036b6a: + llc_util_dicon_procedure(conhdl,reason); + return iVar6; + } + _Var4 = lld_util_instant_ongoing(plVar3->elt); + if (CONCAT31(extraout_var,_Var4) == 0) { + reason = lld_get_mode(conhdl); + if (CONCAT31(extraout_var_00,reason) == 4) { + if ((ushort)(param_4->instant - *(short *)&plVar3->elt[2].timestamp) < 0x7fff) { + uVar2 = *(ushort *)&plVar3->elt[2].ea_cb_stop >> 1; + if ((uint)uVar2 <= (uint)param_4->win_size) { + param_4->win_size = (char)uVar2 + -1; + } + plVar3->n_sup_to = param_4->timeout; + lld_con_update_ind(plVar3->elt,param_4); + *(undefined *)((int)¶m_4[-1].instant + 1) = 1; + if (param_3 != 0) { + return iVar6; + } +switchD_23036a56_caseD_0: + if (((kVar5 & 1) != 0) && ((byte)(plVar3->loc_proc_state - 7) < 2)) { + ble_ke_timer_clear(0x102,param_2); + state_id = state_id & 0xfe; + plVar3->loc_proc_state = '\0'; + ble_ke_state_set(param_2,state_id); + llc_util_clear_operation_ptr(param_1,0); + } + if (plVar3->rem_proc_state == '\x03') { + ble_ke_timer_clear(0x102,param_2); + } + uVar2 = plVar3->llc_status; + if (-1 < (int)((uint)uVar2 << 0x14)) { + plVar3->llc_status = uVar2 | 0x400; + plVar3->rem_proc_state = '\x04'; + ble_ke_state_set(param_2,state_id | 2); + return iVar6; + } + plVar3->llc_status = uVar2 & 0xf7ff; + return iVar6; + } + *(undefined *)((int)¶m_4[-1].instant + 1) = 3; + if (param_3 != 0) { + return iVar6; + } + goto switchD_23036a56_caseD_2; + } + *(undefined *)((int)¶m_4[-1].instant + 1) = 5; + if (param_3 != 0) { + return iVar6; + } +switchD_23036a56_caseD_4: + reason = '\x11'; + goto LAB_23036a6e; + } + *(undefined *)((int)¶m_4[-1].instant + 1) = 2; + if (param_3 != 0) { + return iVar6; + } +switchD_23036a56_caseD_1: + reason = '#'; +LAB_23036a6e: + llc_llcp_reject_ind_pdu_send(conhdl,param_4->opcode,reason); + return iVar6; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void llc_llcp_con_update_pdu_send(uint16_t conhdl,llcp_con_upd_ind *param) + +{ + undefined uStack28; + uint8_t uStack27; + uint16_t uStack26; + llcp_con_upd_ind pdu; + + uStack27 = param->win_size; + uStack26 = param->win_off; + uStack28 = 0; + pdu._0_2_ = param->interv; + pdu.win_off = param->latency; + pdu.interv = param->timeout; + pdu.latency = param->instant; + llc_llcp_send((uint8_t)conhdl,&uStack28,'\0'); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void llc_llcp_con_param_req_pdu_send(uint16_t conhdl,llc_con_upd_req_ind *param) + +{ + undefined auStack44 [2]; + uint16_t uStack42; + llcp_con_param_req pdu; + + auStack44[0] = 0xf; + uStack42 = param->interval_min; + pdu._0_2_ = param->interval_max; + pdu.interval_min = param->con_latency; + pdu.interval_max = param->superv_to; + pdu.latency._0_1_ = param->pref_period; + pdu.timeout = param->ref_con_event_count; + pdu._10_2_ = param->offset0; + pdu.ref_con_event_count = param->offset1; + pdu.offset0 = param->offset2; + pdu.offset1 = param->offset3; + pdu.offset2 = param->offset4; + pdu.offset3 = param->offset5; + llc_llcp_send((uint8_t)conhdl,auStack44,'\x0f'); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void llc_llcp_con_param_rsp_pdu_send(uint16_t conhdl,llc_con_upd_req_ind *param) + +{ + undefined auStack44 [2]; + uint16_t uStack42; + llcp_con_param_rsp pdu; + + auStack44[0] = 0x10; + uStack42 = param->interval_min; + pdu._0_2_ = param->interval_max; + pdu.interval_min = param->con_latency; + pdu.interval_max = param->superv_to; + pdu.latency._0_1_ = param->pref_period; + pdu.timeout = param->ref_con_event_count; + pdu._10_2_ = param->offset0; + pdu.ref_con_event_count = param->offset1; + pdu.offset0 = param->offset2; + pdu.offset1 = param->offset3; + pdu.offset2 = param->offset4; + pdu.offset3 = param->offset5; + llc_llcp_send((uint8_t)conhdl,auStack44,'\x10'); + return; +} + + + +undefined4 llcp_con_param_req_handler(int param_1,ke_task_id_t param_2,uint8_t *param_3) + +{ + ushort uVar1; + ushort uVar2; + uint8_t reason; + _Bool _Var3; + ke_state_t kVar4; + uint16_t conhdl; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined *puVar5; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + uint8_t rej_opcode; + uint uVar6; + uint uVar7; + uint uVar8; + llc_env_tag *plVar9; + llc_con_upd_req_ind lStack68; + + kVar4 = ble_ke_state_get(param_2); + plVar9 = llc_env[param_1]; + conhdl = (uint16_t)param_1; + if ((plVar9->encryption_state & 8) != 0) { + llc_util_dicon_procedure(conhdl,'='); + return 0; + } + if ((kVar4 & 2) == 0) { + reason = lld_get_mode(conhdl); + if ((CONCAT31(extraout_var,reason) != 3) || ((kVar4 & 1) == 0)) { +LAB_23036d6c: + uVar1 = *(ushort *)(param_3 + 2); + uVar7 = (uint)*(ushort *)(param_3 + 4); + if (((((uVar7 < uVar1) || (uVar2 = *(ushort *)(param_3 + 6), 499 < uVar2)) || + (0xc80 < *(ushort *)(param_3 + 4))) || + ((uVar1 < 6 || (uVar6 = (uint)*(ushort *)(param_3 + 8), 0xc76 < (uVar6 - 10 & 0xffff))))) + || (uVar6 << 2 <= ((uint)uVar2 + 1) * uVar7)) { + reason = '\x1e'; + } + else { + uVar8 = (uint)(*(ushort *)&plVar9->elt[2].ea_cb_stop >> 1); + if (((uVar8 < uVar1) || (uVar7 < uVar8)) || + (((uint)uVar2 != (uint)*(ushort *)((int)&plVar9->elt[2].linked_element + 2) - 1 || + ((uint)plVar9->sup_to != uVar6)))) { + _Var3 = llm_util_check_evt_mask('\x05'); + if (CONCAT31(extraout_var_00,_Var3) != 0) { + puVar5 = (undefined *)ble_ke_msg_alloc(0x109,param_2,param_2,0x22); + *puVar5 = 3; + goto LAB_23036e02; + } + reason = '\x1a'; + } + else { + reason = lld_get_mode(conhdl); + if (CONCAT31(extraout_var_01,reason) == 3) { + puVar5 = (undefined *)ble_ke_msg_alloc(0x109,param_2,param_2,0x22); + *puVar5 = 2; + *(undefined2 *)(puVar5 + 2) = *(undefined2 *)(param_3 + 2); + *(undefined2 *)(puVar5 + 4) = *(undefined2 *)(param_3 + 4); + *(uint16_t *)(puVar5 + 8) = plVar9->sup_to; + *(ushort *)(puVar5 + 10) = plVar9->elt->duration_min / 0x271; + *(ushort *)(puVar5 + 0xc) = plVar9->elt->duration_min / 0x271; +LAB_23036e02: + *(undefined2 *)(puVar5 + 0xe) = *(undefined2 *)(param_3 + 2); + *(undefined2 *)(puVar5 + 0x10) = *(undefined2 *)(param_3 + 4); + *(undefined2 *)(puVar5 + 6) = *(undefined2 *)(param_3 + 6); + *(undefined2 *)(puVar5 + 8) = *(undefined2 *)(param_3 + 8); + puVar5[0x12] = param_3[10]; + *(undefined2 *)(puVar5 + 0x14) = *(undefined2 *)(param_3 + 0xc); + *(undefined2 *)(puVar5 + 0x16) = *(undefined2 *)(param_3 + 0xe); + *(undefined2 *)(puVar5 + 0x18) = *(undefined2 *)(param_3 + 0x10); + *(undefined2 *)(puVar5 + 0x1a) = *(undefined2 *)(param_3 + 0x12); + *(undefined2 *)(puVar5 + 0x1c) = *(undefined2 *)(param_3 + 0x14); + *(undefined2 *)(puVar5 + 0x1e) = *(undefined2 *)(param_3 + 0x16); + *(undefined2 *)(puVar5 + 0x20) = *(undefined2 *)(param_3 + 0x18); + ble_ke_msg_send(); + return 0; + } + reason = lld_get_mode(conhdl); + if (CONCAT31(extraout_var_02,reason) != 4) { + return 0; + } + lStack68.interval_min = *(uint16_t *)(param_3 + 2); + lStack68.interval_max = *(uint16_t *)(param_3 + 4); + lStack68.con_latency = *(uint16_t *)(param_3 + 6); + lStack68.superv_to = *(uint16_t *)(param_3 + 8); + lStack68.pref_period = param_3[10]; + lStack68.ref_con_event_count = *(uint16_t *)(param_3 + 0xc); + lStack68.offset0 = *(uint16_t *)(param_3 + 0xe); + lStack68.offset1 = *(uint16_t *)(param_3 + 0x10); + lStack68.offset2 = *(uint16_t *)(param_3 + 0x12); + lStack68.offset3 = *(uint16_t *)(param_3 + 0x14); + lStack68.offset4 = *(uint16_t *)(param_3 + 0x16); + lStack68.offset5 = *(uint16_t *)(param_3 + 0x18); + reason = lld_con_param_rsp(conhdl,plVar9->elt,&lStack68); + if (CONCAT31(extraout_var_03,reason) == 0) { + plVar9->rem_proc_state = '\x03'; + ble_ke_state_set(param_2,(byte)kVar4 | 2); + llc_llcp_con_param_rsp_pdu_send(conhdl,&lStack68); + ble_ke_timer_set(0x102,param_2,4000); + return 0; + } + reason = ' '; + } + } + rej_opcode = '\x0f'; + goto LAB_23036d36; + } + reason = plVar9->loc_proc_state; + if ((reason == '\a') || (reason == '\t')) goto LAB_23036d2e; + if (reason != '\x06') goto LAB_23036d6c; + reason = '*'; + } + else { +LAB_23036d2e: + reason = '#'; + } + rej_opcode = *param_3; +LAB_23036d36: + llc_llcp_reject_ind_pdu_send(conhdl,rej_opcode,reason); + return 0; +} + + + +void llc_llcp_feats_req_pdu_send(uint16_t conhdl) + +{ + uint8_t uVar1; + undefined3 extraout_var; + uint8_t uStack28; + undefined auStack27 [3]; + llcp_feats_req pdu; + + uVar1 = lld_get_mode(conhdl); + uStack28 = '\x0e'; + if (CONCAT31(extraout_var,uVar1) == 3) { + uStack28 = '\b'; + } + llm_util_get_supp_features((le_features *)auStack27); + llc_llcp_send((uint8_t)conhdl,&uStack28,uStack28); + return; +} + + + +void llc_llcp_feats_rsp_pdu_send(uint16_t conhdl) + +{ + undefined2 in_register_0000202a; + uint8_t uStack28; + uint8_t auStack27 [3]; + llcp_feats_rsp pdu; + + uStack28 = '\t'; + llm_util_get_supp_features((le_features *)auStack27); + auStack27[0] = (llc_env[CONCAT22(in_register_0000202a,conhdl)]->feats_used).feats[0]; + llc_llcp_send((uint8_t)conhdl,&uStack28,uStack28); + return; +} + + + +void llc_llcp_start_enc_req_pdu_send(uint16_t conhdl) + +{ + undefined2 in_register_0000202a; + int iVar1; + undefined auStack20 [4]; + llcp_start_enc_req pdu; + + iVar1 = CONCAT22(in_register_0000202a,conhdl) * 0x5c; + *(ushort *)(iVar1 + 0x28008092) = *(ushort *)(iVar1 + 0x28008092) | 0x100; + llc_env[CONCAT22(in_register_0000202a,conhdl)]->encryption_state = + llc_env[CONCAT22(in_register_0000202a,conhdl)]->encryption_state | 2; + *(undefined2 *)(iVar1 + 0x280080cc) = 0; + *(undefined2 *)(iVar1 + 0x280080ce) = 0; + *(undefined2 *)(iVar1 + 0x280080d0) = 0; + *(undefined2 *)(iVar1 + 0x280080d2) = 0; + *(undefined2 *)(iVar1 + 0x280080d4) = 0; + *(undefined2 *)(iVar1 + 0x280080d6) = 0; + auStack20[0] = 5; + llc_llcp_send((uint8_t)conhdl,auStack20,'\x05'); + return; +} + + + +// WARNING: Variable defined which should be unmapped: pdu + +void llc_llcp_terminate_ind_pdu_send(uint16_t conhdl,uint8_t err_code) + +{ + ushort id; + ke_state_t kVar1; + undefined2 in_register_0000202a; + undefined3 in_register_0000202d; + uint8_t uVar2; + llc_env_tag *plVar3; + uint8_t uStack20; + uint8_t uStack19; + llcp_terminate_ind pdu; + + id = conhdl << 8 | 1; + plVar3 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + kVar1 = ble_ke_state_get(id); + uVar2 = '\x16'; + if (CONCAT31(in_register_0000202d,err_code) != 0x13) { + uVar2 = err_code; + } + plVar3->disc_reason = uVar2; + uStack20 = '\x02'; + uStack19 = err_code; + ble_ke_state_set(id,(byte)kVar1 | 0xf); + llc_llcp_send((uint8_t)conhdl,&uStack20,uStack20); + ble_ke_timer_set(0x102,id,(uint)plVar3->sup_to); + return; +} + + + +void llc_llcp_unknown_rsp_send_pdu(uint16_t conhdl,uint8_t unk_type) + +{ + undefined uStack20; + uint8_t uStack19; + llcp_unknown_rsp pdu; + + uStack20 = 7; + uStack19 = unk_type; + llc_llcp_send((uint8_t)conhdl,&uStack20,'\a'); + return; +} + + + +int llc_llcp_unknown_ind_handler(uint16_t conhdl,uint8_t opcode) + +{ + undefined2 in_register_0000202a; + + if ((llc_env[CONCAT22(in_register_0000202a,conhdl)]->encryption_state & 8) == 0) { + llc_llcp_unknown_rsp_send_pdu(conhdl,opcode); + } + else { + llc_util_dicon_procedure(conhdl,'='); + } + return 0; +} + + + +int llcp_feats_req_handler(uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_feats_req *param) + +{ + uint8_t uVar1; + undefined2 in_register_0000202a; + undefined3 extraout_var; + encrypt_conflict *peVar2; + encrypt_conflict *peVar3; + llc_env_tag *plVar4; + + plVar4 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + uVar1 = lld_get_mode(conhdl); + if ((CONCAT31(extraout_var,uVar1) == 4) || (param->opcode != '\b')) { + if ((llc_env[CONCAT22(in_register_0000202a,conhdl)]->encryption_state & 8) == 0) { + peVar2 = (encrypt_conflict *)&plVar4->feats_used; + do { + param = (llcp_feats_req *)¶m->feats; + peVar3 = (encrypt_conflict *)((peVar2->skd).skd + 1); + (peVar2->skd).skd[0] = (peVar2->skd).skd[0] & param->opcode; + peVar2 = peVar3; + } while (peVar3 != &plVar4->encrypt); + plVar4->llc_status = plVar4->llc_status | 1; + llc_llcp_feats_rsp_pdu_send(conhdl); + } + else { + llc_util_dicon_procedure(conhdl,'='); + } + } + else { + llc_llcp_unknown_ind_handler(conhdl,'\b'); + } + return 0; +} + + + +int llcp_slave_feature_req_handler + (uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_slave_feature_req *param) + +{ + uint8_t uVar1; + undefined3 extraout_var; + int iVar2; + + uVar1 = lld_get_mode(conhdl); + if (CONCAT31(extraout_var,uVar1) == 3) { + iVar2 = llcp_feats_req_handler(conhdl,dest_id,int_ctx,(llcp_feats_req *)param); + return iVar2; + } + llc_llcp_unknown_ind_handler(conhdl,'\x0e'); + return 0; +} + + + +void llc_llcp_ping_req_pdu_send(uint16_t conhdl) + +{ + undefined auStack20 [4]; + llcp_ping_req pdu; + + auStack20[0] = 0x12; + llc_llcp_send((uint8_t)conhdl,auStack20,'\x12'); + return; +} + + + +void llc_llcp_ping_rsp_pdu_send(uint16_t conhdl) + +{ + undefined auStack20 [4]; + llcp_ping_rsp pdu; + + auStack20[0] = 0x13; + llc_llcp_send((uint8_t)conhdl,auStack20,'\x13'); + return; +} + + + +int llcp_ping_req_handler(uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,void *param) + +{ + undefined2 in_register_0000202a; + + if ((llc_env[CONCAT22(in_register_0000202a,conhdl)]->encryption_state & 8) == 0) { + llc_llcp_ping_rsp_pdu_send(conhdl); + } + else { + llc_util_dicon_procedure(conhdl,'='); + } + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void llc_llcp_length_req_pdu_send(uint16_t conhdl) + +{ + undefined2 in_register_0000202a; + llc_env_tag *plVar1; + undefined auStack28 [2]; + uint16_t uStack26; + llcp_length_req pdu; + + plVar1 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + auStack28[0] = 0x14; + uStack26 = (plVar1->data_len_ext_info).conn_max_rx_octets; + pdu._0_2_ = (plVar1->data_len_ext_info).conn_max_rx_time; + pdu.max_rx_octets = (plVar1->data_len_ext_info).conn_max_tx_octets; + pdu.max_rx_time = (plVar1->data_len_ext_info).conn_max_tx_time; + llc_llcp_send((uint8_t)conhdl,auStack28,'\x14'); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void llc_llcp_length_rsp_pdu_send(uint16_t conhdl) + +{ + undefined2 in_register_0000202a; + llc_env_tag *plVar1; + undefined auStack28 [2]; + uint16_t uStack26; + llcp_length_rsp pdu; + + plVar1 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + auStack28[0] = 0x15; + uStack26 = (plVar1->data_len_ext_info).conn_max_rx_octets; + pdu._0_2_ = (plVar1->data_len_ext_info).conn_max_rx_time; + pdu.max_rx_octets = (plVar1->data_len_ext_info).conn_max_tx_octets; + pdu.max_rx_time = (plVar1->data_len_ext_info).conn_max_tx_time; + llc_llcp_send((uint8_t)conhdl,auStack28,'\x15'); + return; +} + + +/* +Unable to decompile 'llcp_length_req_handler' +Cause: Exception while decompiling 2303733a: Decompiler process died + +*/ + + +// WARNING: Exceeded maximum restarts with more pending + +int llc_llcp_recv_handler(uint param_1,int param_2,byte *param_3,int param_4) + +{ + ke_state_t kVar1; + int iVar2; + + kVar1 = ble_ke_state_get((ke_task_id_t)param_1); + if ((kVar1 & 0x7f) != 0x7f) { + if ((((kVar1 & 0xf) != 0xf) || ((*param_3 & 0xfb) == 2)) && + ((llc_env[param_1 >> 8]->llc_status & 8) == 0)) { + if (param_2 == 0) { + if ((param_4 == 0) || (llcp_pdu_handler[*param_3].int_ctx_allowed != false)) { + // WARNING: Could not recover jumptable at 0x23037536. Too many branches + // WARNING: Treating indirect jump as call + iVar2 = (*llcp_pdu_handler[*param_3].handler)((uint16_t)param_1,(ke_task_id_t)param_3); + return iVar2; + } + } + else { + if ((param_2 == 0x19) && (param_4 == 0)) { + iVar2 = llc_llcp_unknown_ind_handler((uint16_t)(param_1 >> 8),*param_3); + return iVar2; + } + } + } + } + return (uint)(param_4 != 0) << 1; +} + + + +uint8_t llc_llcp_get_autorize(uint8_t opcode) + +{ + undefined3 in_register_00002029; + + if (CONCAT31(in_register_00002029,opcode) < 0x16) { + return llcp_pdu_handler[CONCAT31(in_register_00002029,opcode)].enc_auth; + } + return '\0'; +} + + + +int llc_dft_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + return 0; +} + + + +undefined4 llm_enc_ind_handler(int param_1,uint param_2) + +{ + uint8_t uVar1; + ke_state_t id; + uint16_t conhdl; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined2 *puVar2; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + uint uVar3; + llc_env_tag *plVar4; + + id = (ke_task_id_t)param_2; + id = ble_ke_state_get(id); + if ((id & 0xf) != 0xf) { + plVar4 = llc_env[param_2 >> 8]; + conhdl = (uint16_t)(param_2 >> 8); + if (((plVar4->loc_proc_state == '\x13') && + (uVar1 = lld_get_mode(conhdl), CONCAT31(extraout_var_01,uVar1) == 3)) || + ((plVar4->rem_proc_state == '\x0e' && + (uVar1 = lld_get_mode(conhdl), CONCAT31(extraout_var,uVar1) == 4)))) { + (*ble_memcpy_ptr)((plVar4->encrypt).randn,(void *)(param_1 + 1),0x10); + } + else { + uVar1 = lld_get_mode(conhdl); + if (((CONCAT31(extraout_var_00,uVar1) != 4) || ((id & 2) == 0)) || + (plVar4->rem_proc_state != '\n')) { + uVar1 = lld_get_mode(conhdl); + if (CONCAT31(extraout_var_02,uVar1) != 3) { + return 0; + } + if ((id & 1) == 0) { + return 0; + } + if (1 < (byte)(plVar4->loc_proc_state - 0xe)) { + return 0; + } + } + puVar2 = (undefined2 *)((param_2 >> 8) * 0x5c + 0x280080b4); + uVar3 = 0xf; + do { + *puVar2 = CONCAT11(*(undefined *)(param_1 + uVar3),((undefined *)(param_1 + uVar3))[1]); + uVar3 = uVar3 - 2 & 0xff; + puVar2 = puVar2 + 1; + } while (uVar3 != 0xff); + } + ble_ke_msg_send_basic(0x106,id,id); + } + return 0; +} + + + +int llc_llcp_recv_ind_handler + (ke_msg_id_t msgid,llc_llcp_recv_ind *ind,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + int iVar1; + undefined2 in_register_00002032; + + iVar1 = llc_llcp_recv_handler(CONCAT22(in_register_00002032,dest_id),(uint)ind->status,ind->pdu,0) + ; + return iVar1; +} + + + +undefined4 llc_chmap_update_req_ind_handler(uint param_1) + +{ + ke_state_t kVar1; + uint16_t conhdl; + int iVar2; + llc_env_tag *plVar3; + + kVar1 = ble_ke_state_get((ke_task_id_t)param_1); + if (((kVar1 & 0xf) != 0xf) && ((kVar1 & 4) == 0)) { + if ((kVar1 & 1) != 0) { + return 2; + } + plVar3 = llc_env[param_1 >> 8]; + conhdl = (uint16_t)(param_1 >> 8); + _conhdl = llc_ch_assess_get_current_ch_map(conhdl); + iVar2 = (*ble_memcmp_ptr)(_conhdl,&plVar3->n_ch_map,5); + if (iVar2 != 0) { + ble_ke_state_set((ke_task_id_t)param_1,(byte)kVar1 | 1); + plVar3->loc_proc_state = '\x06'; + llc_llcp_ch_map_update_pdu_send(conhdl); + } + } + return 0; +} + + + +undefined4 llc_auth_payl_real_to_ind_handler(uint param_1) + +{ + ke_state_t id; + ke_task_id_t *param; + llc_env_tag *plVar1; + + id = (ke_task_id_t)param_1; + id = ble_ke_state_get(id); + if ((id & 0xf) != 0xf) { + plVar1 = llc_env[param_1 >> 8]; + ble_ke_timer_set(0x103,id,(uint)plVar1->auth_payl_to - (uint)plVar1->auth_payl_to_margin); + ble_ke_timer_set(0x104,id,(uint)llc_env[param_1 >> 8]->auth_payl_to); + id = (ke_task_id_t)(param_1 >> 8); + param = (ke_task_id_t *)ble_ke_msg_alloc(0x803,id,0x57,2); + *param = id; + hci_send_2_host(param); + } + return 0; +} + + + +undefined4 llc_con_upd_req_ind_handler(llc_con_upd_req_ind *param_1,uint param_2) + +{ + byte bVar1; + _Bool _Var2; + uint8_t uVar3; + ke_state_t id; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined *param; + undefined3 extraout_var_01; + uint16_t dest_id; + uint uVar4; + llc_env_tag *plVar5; + llcp_con_upd_ind lStack44; + + id = (ke_task_id_t)param_2; + id = ble_ke_state_get(id); + if ((id & 0xf) == 0xf) { + return 0; + } + uVar4 = param_2 >> 8; + if (((id & 1) != 0) && (llc_env[uVar4]->operation[0] == (void *)0x0)) { + return 2; + } + if (((id & 2) != 0) && (llc_env[uVar4]->rem_proc_state == '\x04')) { + return 2; + } + if ((id & 4) != 0) { + return 2; + } + plVar5 = llc_env[uVar4]; + if (4 < param_1->operation) { + return 0; + } + dest_id = (uint16_t)(param_2 >> 8); + bVar1 = (byte)id; + switch(param_1->operation) { + case '\x01': + param_1->superv_to = plVar5->sup_to; + break; + case '\x02': + uVar3 = lld_get_mode(dest_id); + if (CONCAT31(extraout_var_01,uVar3) != 3) { + return 0; + } + case '\x04': + lld_con_update_after_param_req(dest_id,plVar5->elt,param_1,&lStack44,true); + goto LAB_2303790c; + case '\x03': + param = (undefined *)ble_ke_msg_alloc(0x804,dest_id,0x3e,0xc); + *param = 6; + *(uint16_t *)(param + 2) = dest_id; + *(uint16_t *)(param + 4) = param_1->interval_min; + *(uint16_t *)(param + 6) = param_1->interval_max; + *(uint16_t *)(param + 8) = param_1->con_latency; + *(uint16_t *)(param + 10) = param_1->superv_to; + hci_send_2_host(param); + *(llc_con_upd_req_ind **)(llc_env[uVar4]->operation + 1) = param_1; + plVar5->rem_proc_state = '\x02'; + ble_ke_state_set(id,bVar1 | 2); + return 1; + } + param_1->pref_period = '\0'; + if ((plVar5->peer_sup_conn_param_req == false) || + ((((plVar5->llc_status & 1) != 0 && (((plVar5->feats_used).feats[0] & 2) == 0)) && + (_Var2 = llm_util_check_evt_mask('\x05'), CONCAT31(extraout_var,_Var2) != 0)))) { + param_1->interval_min = param_1->con_intv_min; + param_1->interval_max = param_1->con_intv_max; + uVar3 = lld_get_mode(dest_id); + if (CONCAT31(extraout_var_00,uVar3) != 3) { + return 0; + } + lld_con_update_req(plVar5->elt,param_1,&lStack44); +LAB_2303790c: + plVar5->n_sup_to = param_1->superv_to; + llc_llcp_con_update_pdu_send(dest_id,&lStack44); + param_1->interval_min = lStack44.interv; + param_1->con_latency = lStack44.latency; + ble_ke_state_set(id,bVar1 | 1); + plVar5->loc_proc_state = '\t'; + } + else { + if (param_1->operation != '\x01') { + plVar5->llc_status = plVar5->llc_status | 0x40; + lld_con_param_req(dest_id,plVar5->elt,param_1); + } + llc_llcp_con_param_req_pdu_send(dest_id,param_1); + ble_ke_state_set(id,bVar1 | 1); + plVar5->loc_proc_state = '\a'; + ble_ke_timer_set(0x102,id,4000); + } + *(llc_con_upd_req_ind **)llc_env[uVar4]->operation = param_1; + return 1; +} + + + +undefined4 llc_length_req_ind_handler(uint param_1) + +{ + llc_env_tag *plVar1; + ke_state_t id; + void *pvVar2; + + id = (ke_task_id_t)param_1; + id = ble_ke_state_get(id); + if ((id & 0xf) != 0xf) { + if ((id & 5) != 0) { + return 2; + } + plVar1 = llc_env[param_1 >> 8]; + pvVar2 = plVar1->operation[3]; + if (pvVar2 != (void *)0x0) { + (plVar1->data_len_ext_info).conn_max_tx_octets = *(uint16_t *)((int)pvVar2 + 2); + (plVar1->data_len_ext_info).conn_max_tx_time = *(uint16_t *)((int)pvVar2 + 4); + } + llc_util_clear_operation_ptr(param_1 >> 8,3); + if (((plVar1->data_len_ext_info).data_len_ext_flag & 1) == 0) { + ble_ke_state_set(id,(byte)id | 1); + plVar1->loc_proc_state = '\x04'; + llc_llcp_length_req_pdu_send((uint16_t)(param_1 >> 8)); + ble_ke_timer_set(0x102,id,4000); + } + } + return 0; +} + + + +void llc_task_random_gen_request(ke_task_id_t dest_id) + +{ + void *pvVar1; + void *pvVar2; + void *pvVar3; + int iStack36; + uint32_t randn; + + pvVar2 = ble_ke_msg_alloc(4,0,dest_id,0x20); + iStack36 = 0; + pvVar1 = pvVar2; + do { + iStack36 = bl_rand(); + (*ble_memcpy_ptr)(pvVar1,&iStack36,4); + iStack36 = bl_rand(); + pvVar3 = (void *)((int)pvVar1 + 0x10); + pvVar1 = (void *)((int)pvVar1 + 4); + (*ble_memcpy_ptr)(pvVar3,&iStack36,4); + } while (pvVar1 != (void *)((int)pvVar2 + 0x10)); + ble_ke_msg_send(pvVar2); + return; +} + + + +undefined4 llc_enc_mgt_ind_handler(uint param_1) + +{ + byte bVar1; + uint uVar2; + void *pvVar3; + uint8_t conhdl; + _Bool _Var4; + ke_state_t id; + undefined3 extraout_var; + undefined3 extraout_var_00; + hci_le_start_enc_cmd *param; + llc_env_tag *plVar5; + int iVar6; + llc_env_tag **pplVar7; + + id = (ke_task_id_t)param_1; + id = ble_ke_state_get(id); + if ((id & 0xf) == 0xf) { + return 0; + } + uVar2 = param_1 >> 8; + _conhdl = (uint16_t)(param_1 >> 8); + conhdl = lld_get_mode(_conhdl); + if (CONCAT31(extraout_var,conhdl) == 3) { + if ((id & 1) == 0) { + return 0; + } + plVar5 = llc_env[uVar2]; + switch((uint)plVar5->loc_proc_state - 10 & 0xff) { + case 0: + if ((plVar5->encryption_state & 3) == 3) { + plVar5->encryption_state = plVar5->encryption_state | 0x30; + llc_env[uVar2]->loc_proc_state = '\v'; + llc_llcp_pause_enc_req_pdu_send(_conhdl); + return 0; + } + case 2: + llc_task_random_gen_request(id); + llc_env[uVar2]->loc_proc_state = '\x13'; + break; + case 4: + plVar5->loc_proc_state = '\x10'; + break; + case 5: + case 7: + iVar6 = uVar2 * 0x5c; + *(undefined2 *)(iVar6 + 0x280080cc) = 0; + *(undefined2 *)(iVar6 + 0x280080ce) = 0; + *(undefined2 *)(iVar6 + 0x280080d0) = 0; + *(undefined2 *)(iVar6 + 0x280080d2) = 0; + *(undefined2 *)(iVar6 + 0x280080d4) = 0; + *(undefined2 *)(iVar6 + 0x280080d6) = 0; + llc_env[uVar2]->loc_proc_state = '\x12'; + llc_llcp_start_enc_rsp_pdu_send(_conhdl); + goto LAB_23037c02; + case 9: + plVar5->loc_proc_state = '\r'; + param = (hci_le_start_enc_cmd *)plVar5->operation[2]; + llc_env[uVar2]->encryption_state = llc_env[uVar2]->encryption_state & 0xdf; + llc_llcp_enc_req_pdu_send(_conhdl,param); + goto LAB_23037b9a; + } + } + else { + if ((id & 2) == 0) { + return 0; + } + pplVar7 = llc_env + uVar2; + plVar5 = *pplVar7; + bVar1 = plVar5->rem_proc_state; + if (bVar1 == 8) { + _Var4 = llm_util_check_evt_mask('\x04'); + if (CONCAT31(extraout_var_00,_Var4) != 0) { + llc_task_random_gen_request(id); + (*pplVar7)->rem_proc_state = '\x0e'; + return 0; + } + if (((*pplVar7)->encryption_state & 0x10) == 0) { + if ((id & 1) != 0) { + ble_ke_timer_set(0x102,id,4000); + } + llc_llcp_reject_ind_pdu_send(_conhdl,'\x03','\x06'); + ble_ke_state_set(id,(byte)id & 0xfd); + ble_ke_state_set(id,(byte)id & 0xf9); + llc_env[uVar2]->rem_proc_state = '\0'; + } + else { + llc_llcp_terminate_ind_pdu_send(_conhdl,'\x06'); + } + } + else { + if (bVar1 < 9) { + if (bVar1 != 5) { + return 0; + } + plVar5->encryption_state = plVar5->encryption_state | 0x30; + plVar5->rem_proc_state = '\x06'; + llc_llcp_pause_enc_rsp_pdu_send(_conhdl); +LAB_23037c02: + ble_ke_timer_set(0x102,id,4000); + return 0; + } + if (bVar1 == 10) { + llc_llcp_start_enc_req_pdu_send(_conhdl); + (*pplVar7)->rem_proc_state = '\v'; + goto LAB_23037c02; + } + if (bVar1 != 0xe) { + return 0; + } + pvVar3 = plVar5->operation[2]; + plVar5->rem_proc_state = '\t'; + (*ble_memcpy_ptr)(&plVar5->encrypt,(void *)((int)pvVar3 + 0xd),8); + *(undefined2 *)(uVar2 * 0x5c + 0x280080c4) = *(undefined2 *)((int)pvVar3 + 0x15); + *(undefined2 *)(uVar2 * 0x5c + 0x280080c6) = *(undefined2 *)((int)pvVar3 + 0x17); + llc_llcp_enc_rsp_pdu_send(_conhdl,(llcp_enc_req *)((int)pvVar3 + 2)); + llc_ltk_req_send(_conhdl,(llcp_enc_req *)((int)pvVar3 + 2)); + } +LAB_23037b9a: + llc_util_clear_operation_ptr(uVar2,2); + } + return 0; +} + + + +undefined4 llc_chnl_assess_timer_handler(uint param_1) + +{ + uint8_t conhdl; + ke_state_t id; + undefined3 extraout_var; + uint8_t uVar1; + llc_env_tag *plVar2; + le_chnl_map lStack48; + le_chnl_map alStack40 [4]; + + plVar2 = llc_env[param_1 >> 8]; + id = (ke_task_id_t)param_1; + id = ble_ke_state_get(id); + if ((id & 0xf) != 0xf) { + if (plVar2->loc_proc_state != '\x06') { + llm_util_get_channel_map(alStack40); + _conhdl = (uint16_t)(param_1 >> 8); + conhdl = llc_ch_assess_get_local_ch_map(_conhdl,&lStack48,alStack40); + uVar1 = (plVar2->chnl_assess).reassess_count + -1; + (plVar2->chnl_assess).reassess_count = uVar1; + if ((uVar1 == '\0') || (CONCAT31(extraout_var,conhdl) < 2)) { + llc_ch_assess_reass_ch(_conhdl,&lStack48,alStack40,conhdl); + } + (*ble_memcpy_ptr)(&plVar2->n_ch_map,&lStack48,5); + ble_ke_msg_send_basic(0x108,id,id); + } + ble_ke_timer_set(0x105,id,(uint)llm_le_env.ch_map_assess.assess_timer); + } + return 0; +} + + + +int llc_llcp_rsp_to_ind_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined2 in_register_00002032; + + llc_util_dicon_procedure((uint16_t)(CONCAT22(in_register_00002032,dest_id) >> 8),'\"'); + return 0; +} + + + +undefined4 llc_link_sup_to_ind_handler(uint param_1) + +{ + ke_state_t kVar1; + + kVar1 = ble_ke_state_get((ke_task_id_t)param_1); + if ((kVar1 & 0x7f) != 0x7f) { + if ((*(byte *)((int)&llc_env[param_1 >> 8]->elt[2].ea_cb_cancel + 2) & 2) == 0) { + llc_util_dicon_procedure((uint16_t)(param_1 >> 8),'\b'); + } + else { + ble_ke_timer_set(0x101,(ke_task_id_t)param_1 & 0xff00 | 1,(uint)llc_env[param_1 >> 8]->sup_to) + ; + } + } + return 0; +} + + + +undefined4 llc_auth_payl_nearly_to_ind_handler(uint param_1) + +{ + _Bool _Var1; + ke_state_t id; + undefined3 extraout_var; + + id = (ke_task_id_t)param_1; + id = ble_ke_state_get(id); + if ((id & 0xf) != 0xf) { + if ((id & 1) == 0) { + if ((id & 4) != 0) { + return 2; + } + _Var1 = ble_ke_timer_active(0x102,id); + if (CONCAT31(extraout_var,_Var1) == 0) { + ble_ke_state_set(id,(byte)id | 1); + llc_env[param_1 >> 8]->loc_proc_state = '\x05'; + llc_llcp_ping_req_pdu_send((uint16_t)(param_1 >> 8)); + ble_ke_timer_set(0x102,id,4000); + } + } + else { + if (llc_env[param_1 >> 8]->loc_proc_state != '\x05') { + return 2; + } + } + } + return 0; +} + + + +undefined4 llc_data_ind_handler(void *param_1,uint param_2) + +{ + ke_state_t kVar1; + uint16_t conhdl; + + kVar1 = ble_ke_state_get((ke_task_id_t)param_2); + if ((kVar1 & 0xf) == 0xf) { + em_buf_rx_free(*(uint8_t *)((int)param_1 + 6)); + } + else { + conhdl = (uint16_t)(param_2 >> 8); + if ((llc_env[param_2 >> 8]->encryption_state & 8) == 0) { + *(undefined2 *)((int)param_1 + -8) = 0x806; + *(uint16_t *)((int)param_1 + -6) = conhdl; + hci_send_2_host(param_1); + return 1; + } + em_buf_rx_free(*(uint8_t *)((int)param_1 + 6)); + llc_util_dicon_procedure(conhdl,'='); + } + return 0; +} + + + +undefined4 lld_stop_ind_handler(uint param_1) + +{ + uint uVar1; + _Bool _Var2; + ke_state_t id; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined3 extraout_var; + uint16_t conhdl; + ushort *puVar3; + uint8_t status; + llc_env_tag *plVar4; + + id = (ke_task_id_t)param_1; + id = ble_ke_state_get(id); + if (CONCAT22(extraout_var_00,id) != 0x7f) { + uVar1 = param_1 >> 8; + puVar3 = (ushort *)(uVar1 * 0x5c + 0x28008092); + *puVar3 = *puVar3 & 0xfcff; + plVar4 = llc_env[uVar1]; + status = plVar4->disc_reason; + id = ble_ke_state_get(id); + if ((CONCAT22(extraout_var_01,id) != 0xf) && + (status = '\b', (llc_env[uVar1]->llc_status & 0x100) == 0)) { + status = '>'; + } + if ((id & 1) != 0) { + conhdl = (uint16_t)(param_1 >> 8); + switch((uint)plVar4->loc_proc_state - 1 & 0xff) { + case 0: + llc_feats_rd_event_send(status,conhdl,&plVar4->feats_used); + break; + case 1: + llc_version_rd_event_send(status,conhdl); + break; + case 6: + case 7: + case 8: + _Var2 = llm_util_check_evt_mask('\x02'); + if ((CONCAT31(extraout_var,_Var2) != 0) && ((plVar4->llc_status & 0x40) != 0)) { + llc_con_update_complete_send(status,conhdl,(lld_evt_tag *)0x0); + } + break; + case 9: + case 10: + case 0xb: + case 0xc: + case 0xd: + case 0xe: + case 0xf: + case 0x10: + case 0x11: + case 0x12: + if ((llc_env[uVar1]->encryption_state & 0x10) == 0) { + llc_common_enc_change_evt_send(conhdl,'\0',status); + } + else { + llc_common_enc_key_ref_comp_evt_send(conhdl,status); + } + } + } + llc_discon_event_complete_send(id,'\0',(uint8_t)(param_1 >> 8),status); + ble_ke_timer_clear(0x101,id); + ble_ke_timer_clear(0x102,id); + ble_ke_timer_clear(0x103,id); + ble_ke_timer_clear(0x104,id); + llc_stop(uVar1); + } + return 0; +} + + +/* +Unable to decompile 'llc_check_trafic_paused' +Cause: Exception while decompiling 230380e4: Decompiler process died + +*/ + + +uint8_t llc_util_get_free_conhdl(uint16_t *conhdl) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + undefined2 extraout_var_00; + uint16_t uVar2; + + kVar1 = ble_ke_state_get(1); + if (CONCAT22(extraout_var,kVar1) == 0x7f) { + uVar2 = 0; + } + else { + kVar1 = ble_ke_state_get(0x101); + if (CONCAT22(extraout_var_00,kVar1) != 0x7f) { + return '\t'; + } + uVar2 = 1; + } + *conhdl = uVar2; + return '\0'; +} + + + +uint8_t llc_util_get_nb_active_link(void) + +{ + bool bVar1; + ke_state_t kVar2; + undefined2 extraout_var; + undefined2 extraout_var_00; + + kVar2 = ble_ke_state_get(1); + bVar1 = CONCAT22(extraout_var,kVar2) != 0x7f; + kVar2 = ble_ke_state_get(0x101); + if (CONCAT22(extraout_var_00,kVar2) != 0x7f) { + bVar1 = (bool)(bVar1 + '\x01'); + } + return (uint8_t)bVar1; +} + + +/* +Unable to decompile 'llc_util_dicon_procedure' +Cause: Exception while decompiling 230381be: Decompiler process died + +*/ + + +// WARNING: Exceeded maximum restarts with more pending + +void llc_util_update_channel_map(uint16_t conhdl,le_chnl_map *map) + +{ + undefined2 in_register_0000202a; + + // WARNING: Could not recover jumptable at 0x23038232. Too many branches + // WARNING: Treating indirect jump as call + (*ble_memcpy_ptr)(&llc_env[CONCAT22(in_register_0000202a,conhdl)]->ch_map,(void *)0x5); + return; +} + + + +void llc_util_set_auth_payl_to_margin(lld_evt_tag *evt) + +{ + int iVar1; + uint16_t uVar2; + uint uVar3; + + iVar1 = (uint)evt->interval * (uint)*(ushort *)(evt->evt + 10); + uVar3 = iVar1 * 8; + while ((uint)llc_env[evt->conhdl]->auth_payl_to << 4 < uVar3) { + uVar3 = uVar3 - iVar1; + } + uVar2 = (uint16_t)(uVar3 >> 4); + if (uVar3 >> 4 == 0) { + uVar2 = 1; + } + llc_env[evt->conhdl]->auth_payl_to_margin = uVar2; + return; +} + + + +void llc_util_clear_operation_ptr(int param_1,int param_2) + +{ + void *pvVar1; + + pvVar1 = llc_env[param_1]->operation[param_2]; + if (pvVar1 != (void *)0x0) { + llc_env[param_1]->operation[param_2] = (void *)0x0; + ble_ke_msg_free((ke_msg *)((int)pvVar1 + -0xc)); + return; + } + return; +} + + + +void llc_util_bw_mgt(uint16_t conhdl) + +{ + uint uVar1; + uint uVar2; + ea_elt_tag *elt_connect; + uint8_t uVar3; + undefined2 in_register_0000202a; + undefined3 extraout_var; + undefined3 extraout_var_00; + llc_env_tag *plVar4; + + plVar4 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + if (plVar4 == (llc_env_tag *)0x0) { + return; + } + elt_connect = plVar4->elt; + uVar1 = (uint)(plVar4->data_len_ext_info).conn_eff_max_rx_time + + (uint)(plVar4->data_len_ext_info).conn_eff_max_tx_time + 0x96; + uVar2 = uVar1 & 0xffff; + if ((uint)*(ushort *)(elt_connect[1].ea_cb_cancel + 8) * 0x2710000 >> 0x10 < uVar2) { + *(short *)(elt_connect[1].ea_cb_cancel + 8) = (short)((int)(uVar2 + 0x270) / 0x271); + uVar3 = lld_get_mode(conhdl); + if (CONCAT31(extraout_var,uVar3) == 3) { + elt_connect->duration_min = (uint16_t)(uVar1 * 0x10000 >> 0x10); + } + uVar3 = llc_util_get_nb_active_link(); + if (CONCAT31(extraout_var_00,uVar3) != 1) { + lld_util_anchor_point_move(elt_connect); + return; + } + } + return; +} + + + +void llc_end_evt_defer(int param_1) + +{ + ke_state_t kVar1; + llc_env_tag *plVar2; + + if (llc_env[param_1] != (llc_env_tag *)0x0) { + kVar1 = ble_ke_state_get((ushort)(param_1 << 8) | 1); + if ((kVar1 & 0xf) == 0xf) { + plVar2 = llc_env[param_1]; + if ((plVar2->llc_status & 0x200) != 0) { + plVar2->llc_status = plVar2->llc_status & 0xfdff; + llc_util_dicon_procedure((uint16_t)param_1,plVar2->disc_reason); + } + } + llc_util_bw_mgt((uint16_t)param_1); + return; + } + return; +} + + +/* +Unable to decompile 'llc_pdu_llcp_tx_ack_defer' +Cause: Exception while decompiling 23038380: Decompiler process died + +*/ + + +void llc_pdu_acl_tx_ack_defer(uint16_t conhdl,uint8_t tx_cnt) + +{ + undefined2 in_register_0000202a; + undefined3 in_register_0000202d; + + if (llc_env[CONCAT22(in_register_0000202a,conhdl)] != (llc_env_tag *)0x0) { + if (CONCAT31(in_register_0000202d,tx_cnt) != 0) { + llc_common_nb_of_pkt_comp_evt_send(conhdl,tx_cnt); + } + llc_check_trafic_paused((uint8_t)conhdl); + return; + } + return; +} + + + +void llc_pdu_defer(uint16_t conhdl,uint16_t status,uint8_t rssi,uint8_t channel,uint8_t length) + +{ + int8_t iVar1; + undefined2 in_register_0000202a; + int iVar2; + ushort task_id; + undefined2 in_register_0000202e; + undefined3 in_register_00002035; + undefined3 in_register_00002039; + llc_env_tag *plVar3; + llc_env_tag **pplVar4; + llc_env_tag *plVar5; + + iVar2 = CONCAT22(in_register_0000202a,conhdl); + pplVar4 = llc_env + iVar2; + plVar5 = *pplVar4; + if (plVar5 != (llc_env_tag *)0x0) { + iVar1 = (*rwip_rf.rssi_convert)(rssi); + plVar3 = *pplVar4; + plVar5->rssi = iVar1; + llc_ch_assess_local(iVar2,CONCAT22(in_register_0000202e,status),(int)plVar3->rssi, + CONCAT31(in_register_00002035,channel)); + if ((status & 0x1d) == 0) { + task_id = conhdl << 8 | 1; + ble_ke_timer_set(0x101,task_id,(uint)(*pplVar4)->sup_to); + if (((((status & 0x120) == 0) && (CONCAT31(in_register_00002039,length) != 0)) && + (plVar5 = *pplVar4, (plVar5->encryption_state & 3) == 3)) && + ((plVar5->llc_status & 8) == 0)) { + ble_ke_timer_set(0x103,task_id, + (uint)plVar5->auth_payl_to - (uint)plVar5->auth_payl_to_margin); + ble_ke_timer_set(0x104,task_id,(uint)(*pplVar4)->auth_payl_to); + } + } + else { + if ((status & 0x10) != 0) { + llc_util_dicon_procedure(conhdl,'='); + } + } + plVar5 = llc_env[iVar2]; + if ((plVar5->llc_status & 0x20) != 0) { + plVar5->llc_status = plVar5->llc_status & 0xffdf; + plVar5->sup_to = plVar5->n_sup_to; + } + } + return; +} + + + +int llm_dft_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + return 0; +} + + + +int llm_le_set_host_ch_class_cmd_sto_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + llm_le_env.ch_map_assess.llm_le_set_host_ch_class_cmd_sto = true; + return 0; +} + + + +int llm_ecc_result_ind_handler + (ke_msg_id_t msgid,ecc_result_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *param_00; + _Bool _Var1; + undefined3 extraout_var; + undefined *puVar2; + undefined3 extraout_var_00; + + if (llm_le_env.cur_ecc_multiplication == LLM_DHKEY_GENERATION) { + _Var1 = llm_util_check_evt_mask('\b'); + if (CONCAT31(extraout_var,_Var1) == 0) { + llm_le_env.cur_ecc_multiplication = LLM_ECC_IDLE; + return 0; + } + param_00 = (undefined *)ble_ke_msg_alloc(0x804,0,0x3e,0x22); + *param_00 = 9; + param_00[1] = 0; + puVar2 = param_00 + 2; + } + else { + if (llm_le_env.cur_ecc_multiplication != LLM_PUBLIC_KEY_GENERATION) { + llm_le_env.cur_ecc_multiplication = LLM_ECC_IDLE; + return 0; + } + _Var1 = llm_util_check_evt_mask('\a'); + if (CONCAT31(extraout_var_00,_Var1) == 0) { + llm_le_env.cur_ecc_multiplication = LLM_ECC_IDLE; + return 0; + } + param_00 = (undefined *)ble_ke_msg_alloc(0x804,0,0x3e,0x42); + *param_00 = 8; + param_00[1] = 0; + (*ble_memcpy_ptr)(param_00 + 2,param,0x20); + param = (ecc_result_ind *)param->key_res_y; + puVar2 = param_00 + 0x22; + } + (*ble_memcpy_ptr)(puVar2,param,0x20); + hci_send_2_host(param_00); + llm_le_env.cur_ecc_multiplication = LLM_ECC_IDLE; + return 0; +} + + + +int llm_enc_req_handler(ke_msg_id_t msgid,llm_enc_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + ble_co_list_push_back(&llm_le_env,param[-1].plain_data + 4); + if (llm_le_env.enc_pend == false) { + llm_encryption_start(param); + } + return 1; +} + + + +int lld_stop_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + byte state_id; + + kVar1 = ble_ke_state_get(0); + if (((kVar1 & 0xf0) != 0x20) && (kVar1 = ble_ke_state_get(0), (kVar1 & 0xf) != 3)) { + return 0; + } + kVar1 = ble_ke_state_get(0); + if (CONCAT22(extraout_var,kVar1) == 0x23) { + if ((llm_le_env.state & 0xf0) == 0x10) { + llm_common_cmd_complete_send(llm_le_env.opcode,'\0'); + llm_le_env.state = llm_le_env.state & 0xf; + } + llm_le_env.elt = (ea_elt_tag *)0x0; + if ((byte)(llm_le_env.state2 - 1) < 2) { +LAB_230387b6: + llm_common_cmd_complete_send(llm_le_env.opcode2,'\0'); + if (llm_le_env.state2 == '\x02') { + llc_le_con_cmp_evt_send('\x02',0xffff,(llc_create_con_req_ind *)0x0); + } + llm_le_env.state2 = llm_le_env.state2 & 0xf0; + } + } + else { + kVar1 = ble_ke_state_get(0); + if (((kVar1 & 0xf0) == 0x20) && (llm_le_env.last_opcode == false)) { + if ((llm_le_env.state & 0xf0) == 0x10) { + llm_common_cmd_complete_send(llm_le_env.opcode,'\0'); + llm_le_env.state = llm_le_env.state & 0xf; + } + llm_le_env.elt = (ea_elt_tag *)0x0; + goto LAB_230387e8; + } + kVar1 = ble_ke_state_get(0); + if (((kVar1 & 0xf) != 3) || (llm_le_env.last_opcode == false)) { + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + if (((byte)(llm_le_env.state2 - 1) < 2) || (llm_le_env.state2 == '\x11')) goto LAB_230387b6; + } + llm_le_env.elt_coext_scan = (ea_elt_tag *)0x0; +LAB_230387e8: + kVar1 = ble_ke_state_get(0); + if (llm_le_env.elt == (ea_elt_tag *)0x0) { + state_id = 0; + if (llm_le_env.elt_coext_scan != (ea_elt_tag *)0x0) { + state_id = (byte)kVar1 & 0xf; + } + } + else { + if (llm_le_env.elt_coext_scan != (ea_elt_tag *)0x0) { + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + state_id = (byte)kVar1 & 0xf0; + } + ble_ke_state_set(0,state_id); + llm_le_env.conhdl_alloc = 0xffff; + return 0; +} + + + +void llc_ch_assess_local(int param_1,uint param_2,int param_3,int param_4) + +{ + char cVar1; + int8_t iVar2; + + param_4 = (int)llc_env[param_1]->operation + param_4; + cVar1 = *(char *)(param_4 + 0x14); + if ((param_2 & 1) == 0) { + if ((param_2 & 8) != 0) goto LAB_2303888a; + cVar1 = cVar1 + '\x03'; + } + else { + if (llm_le_env.ch_map_assess.rssi_noise_limit < param_3) { +LAB_2303888a: + cVar1 = cVar1 + -3; + } + else { + cVar1 = cVar1 + -1; + if ((llc_env[param_1]->chnl_assess).latency_en != false) goto LAB_2303889a; + } + } + *(char *)(param_4 + 0x14) = cVar1; +LAB_2303889a: + iVar2 = llm_le_env.ch_map_assess.lower_limit; + if ((*(char *)(param_4 + 0x14) < llm_le_env.ch_map_assess.lower_limit) || + (iVar2 = llm_le_env.ch_map_assess.upper_limit, + llm_le_env.ch_map_assess.upper_limit < *(char *)(param_4 + 0x14))) { + *(int8_t *)(param_4 + 0x14) = iVar2; + } + return; +} + + + +uint8_t llc_ch_assess_get_local_ch_map(uint16_t conhdl,le_chnl_map *map,le_chnl_map *hostmap) + +{ + llc_env_tag *plVar1; + uint8_t uVar2; + undefined2 in_register_0000202a; + uint uVar3; + int iVar4; + uint uVar5; + + plVar1 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + (*ble_memset_ptr)(map,0,5); + uVar3 = 0x24; + uVar2 = '\0'; + do { + iVar4 = (int)(char)uVar3 >> 3; + uVar5 = 1 << (uVar3 & 7) & 0xff; + if (((hostmap->map[iVar4] & uVar5) != 0) && + (llm_le_env.ch_map_assess.lower_limit < (plVar1->chnl_assess).rcvd_quality[uVar3])) { + uVar2 = uVar2 + '\x01'; + map->map[iVar4] = (byte)uVar5 | map->map[iVar4]; + } + uVar3 = uVar3 - 1; + } while (uVar3 != 0xffffffff); + return uVar2; +} + + + +le_chnl_map * llc_ch_assess_get_current_ch_map(uint16_t conhdl) + +{ + undefined2 in_register_0000202a; + + return &llc_env[CONCAT22(in_register_0000202a,conhdl)]->ch_map; +} + + + +void llc_ch_assess_reass_ch(uint16_t conhdl,le_chnl_map *map,le_chnl_map *hostmap,uint8_t nb_chgood) + +{ + undefined2 in_register_0000202a; + uint uVar1; + undefined3 in_register_00002035; + uint uVar2; + uint uVar3; + char cVar4; + byte *pbVar5; + llc_env_tag *plVar6; + + plVar6 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + uVar1 = 10; + if (2 < CONCAT31(in_register_00002035,nb_chgood)) { + uVar1 = CONCAT31(in_register_00002035,nb_chgood) * 0x20 + 0x7f >> 7; + } + cVar4 = '%'; + (plVar6->chnl_assess).reassess_count = llm_le_env.ch_map_assess.reassess_count; + uVar3 = (uint)(plVar6->chnl_assess).reassess_cursor; + do { + uVar2 = uVar3 + 0xb & 0xff; + if (0x24 < uVar2) { + uVar2 = uVar3 - 0x1a & 0xff; + } + pbVar5 = map->map + (uVar2 >> 3); + uVar3 = 1 << (uVar2 & 7) & 0xff; + if (((uVar3 & *pbVar5) == 0) && ((hostmap->map[uVar2 >> 3] & uVar3) != 0)) { + (plVar6->chnl_assess).rcvd_quality[uVar2] = '\0'; + *pbVar5 = (byte)uVar3 | *pbVar5; + uVar1 = uVar1 - 1 & 0xffff; + } + cVar4 = cVar4 + -1; + } while ((cVar4 != '\0') && (uVar3 = uVar2, uVar1 != 0)); + (plVar6->chnl_assess).reassess_cursor = (uint8_t)uVar2; + return; +} + + + +undefined4 hci_le_set_data_len_cmd_handler(ushort *param_1,ke_task_id_t param_2,uint16_t param_3) + +{ + undefined4 uVar1; + ke_state_t kVar2; + uint8_t status; + llc_env_tag *plVar3; + + kVar2 = ble_ke_state_get(param_2); + if ((kVar2 & 0xf) == 0xf) { + status = '\f'; + } + else { + plVar3 = llc_env[*param_1]; + if ((plVar3->data_len_ext_info).send_req_not_allowed == false) { + if ((((ushort)(param_1[1] - 0x1b) < 0xe1) && ((ushort)(param_1[2] - 0x148) < 0x701)) && + (*param_1 < 3)) { + if (((plVar3->data_len_ext_info).conn_eff_max_tx_octets != param_1[1]) || + ((plVar3->data_len_ext_info).conn_eff_max_tx_time != param_1[2])) { + *(ushort **)(plVar3->operation + 3) = param_1; + ble_ke_msg_send_basic(0x107,param_2,param_2); + status = '\0'; + uVar1 = 1; + goto LAB_23038a96; + } + status = '\0'; + } + else { + status = '\x12'; + } + } + else { + status = '\x1a'; + } + } + uVar1 = 0; +LAB_23038a96: + llc_common_cmd_complete_send(param_3,status,*param_1); + return uVar1; +} + + + +undefined4 +hci_le_rem_con_param_req_neg_reply_cmd_handler + (ushort *param_1,ke_task_id_t param_2,uint16_t param_3) + +{ + ke_state_t kVar1; + uint8_t status; + + kVar1 = ble_ke_state_get(param_2); + status = '\f'; + if ((((kVar1 & 0xf) != 0xf) && ((kVar1 & 2) != 0)) && + (llc_env[*param_1]->rem_proc_state == '\x02')) { + status = '\x12'; + if (*(char *)(param_1 + 1) == ';') { + llc_util_clear_operation_ptr(1); + ble_ke_state_set(param_2,(byte)kVar1 & 0xfd); + llc_env[*param_1]->rem_proc_state = '\0'; + llc_llcp_reject_ind_pdu_send(*param_1,'\x0f',*(uint8_t *)(param_1 + 1)); + status = '\0'; + } + } + llc_common_cmd_complete_send(param_3,status,*param_1); + return 0; +} + + + +undefined4 +hci_le_rem_con_param_req_reply_cmd_handler(ushort *param_1,ke_task_id_t param_2,uint16_t param_3) + +{ + llc_con_upd_req_ind *param; + uint8_t status; + uint8_t uVar1; + ke_state_t kVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + ushort uVar3; + llc_env_tag *plVar4; + + kVar2 = ble_ke_state_get(param_2); + status = '\f'; + if (((kVar2 & 0xf) != 0xf) && ((kVar2 & 2) != 0)) { + plVar4 = llc_env[*param_1]; + if (plVar4->rem_proc_state == '\x02') { + param = (llc_con_upd_req_ind *)plVar4->operation[1]; + status = lld_get_mode(*param_1); + if (CONCAT31(extraout_var,status) == 3) { + param->operation = '\x02'; + uVar3 = param->interval_min; + if (param_1[1] < param->interval_min) { + uVar3 = param_1[1]; + } + param->interval_min = uVar3; + uVar3 = param->interval_max; + if (param->interval_max < param_1[2]) { + uVar3 = param_1[2]; + } + param->interval_max = uVar3; + param->con_latency = param_1[3]; + uVar3 = param->superv_to; + if (param->superv_to < param_1[4]) { + uVar3 = param_1[4]; + } + param->superv_to = uVar3; + ble_ke_msg_send(param); + ble_ke_state_set(param_2,(byte)kVar2 & 0xfd); + plVar4->rem_proc_state = '\0'; + llc_env[*param_1]->operation[1] = (void *)0x0; + status = '\0'; + } + else { + uVar1 = lld_get_mode(*param_1); + status = '\0'; + if (CONCAT31(extraout_var_00,uVar1) == 4) { + param->interval_min = param_1[1]; + param->interval_max = param_1[2]; + param->con_latency = param_1[3]; + param->superv_to = param_1[4]; + lld_con_param_rsp(*param_1,plVar4->elt,param); + plVar4->rem_proc_state = '\x03'; + llc_llcp_con_param_rsp_pdu_send(*param_1,param); + ble_ke_timer_set(0x102,param_2,4000); + llc_util_clear_operation_ptr((uint)*param_1,1); + status = '\0'; + } + } + } + } + llc_common_cmd_complete_send(param_3,status,*param_1); + return 0; +} + + +/* +Unable to decompile 'hci_le_ltk_req_neg_reply_cmd_handler' +Cause: Exception while decompiling 23038cc6: Decompiler process died + +*/ + + +undefined4 hci_le_ltk_req_reply_cmd_handler(ushort *param_1,ke_task_id_t param_2,uint16_t param_3) + +{ + ke_state_t kVar1; + void *pvVar2; + uint8_t status; + + kVar1 = ble_ke_state_get(param_2); + status = '\f'; + if ((((kVar1 & 0xf) != 0xf) && ((kVar1 & 2) != 0)) && (llc_env[*param_1]->rem_proc_state == '\t')) + { + pvVar2 = ble_ke_msg_alloc(4,0,param_2,0x20); + (*ble_memcpy_ptr)(pvVar2,param_1 + 1,0x10); + (*ble_memcpy_ptr)((void *)((int)pvVar2 + 0x10),&llc_env[*param_1]->encrypt,0x10); + ble_ke_msg_send(pvVar2); + status = '\0'; + llc_env[*param_1]->rem_proc_state = '\n'; + } + llc_common_cmd_complete_send(param_3,status,*param_1); + return 0; +} + + + +undefined4 hci_disconnect_cmd_handler(uint16_t *param_1,ke_task_id_t param_2,uint16_t param_3) + +{ + ke_state_t kVar1; + uint8_t status; + int iVar2; + undefined4 local_18; + undefined2 uStack20; + undefined uStack18; + + kVar1 = ble_ke_state_get(param_2); + status = '\f'; + if ((kVar1 & 0xf) != 0xf) { + local_18 = 0x15141305; + uStack20 = 0x291a; + uStack18 = 0x3b; + iVar2 = 0; + do { + if (*(uint8_t *)((int)&local_18 + iVar2) == *(uint8_t *)(param_1 + 1)) { + llc_llcp_terminate_ind_pdu_send(*param_1,*(uint8_t *)(param_1 + 1)); + status = '\0'; + goto LAB_23038ea8; + } + iVar2 = iVar2 + 1; + } while (iVar2 != 7); + status = '\x12'; + } +LAB_23038ea8: + if (llc_env[*param_1]->disc_event_sent == false) { + llc_common_cmd_status_send(param_3,status,*param_1); + llc_env[*param_1]->disc_event_sent = true; + } + llc_env[*param_1]->disc_event_sent = false; + return 0; +} + + +/* +Unable to decompile 'hci_le_start_enc_cmd_handler' +Cause: Exception while decompiling 23038ef8: Decompiler process died + +*/ + + +int hci_le_rd_rem_used_feats_cmd_handler + (ke_msg_id_t msgid,hci_le_rd_rem_used_feats_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + ke_state_t kVar1; + byte status; + + kVar1 = ble_ke_state_get(dest_id); + if ((kVar1 & 0xf) == 0xf) { + status = 0xc; + } + else { + if ((llc_env[param->conhdl]->llc_status & 1) == 0) { + status = (byte)kVar1 & 5; + if ((kVar1 & 5) != 0) { + return 2; + } + ble_ke_state_set(dest_id,(byte)kVar1 | 1); + llc_env[param->conhdl]->loc_proc_state = '\x01'; + llc_llcp_feats_req_pdu_send(param->conhdl); + ble_ke_timer_set(0x102,dest_id,4000); + } + else { + status = 0; + } + } + llc_common_cmd_status_send(src_id,status,param->conhdl); + if ((llc_env[param->conhdl]->llc_status & 1) != 0) { + llc_feats_rd_event_send('\0',param->conhdl,&llc_env[param->conhdl]->feats_used); + } + return 0; +} + + + +undefined4 hci_le_rd_chnl_map_cmd_handler(ke_task_id_t *param_1,ke_task_id_t param_2) + +{ + ke_state_t kVar1; + undefined *param; + undefined uVar2; + + param = (undefined *)ble_ke_msg_alloc(0x801,*param_1,0x2015,10); + kVar1 = ble_ke_state_get(param_2); + uVar2 = 0xc; + if ((kVar1 & 0xf) != 0xf) { + (*ble_memcpy_ptr)(param + 4,&llc_env[*param_1]->ch_map,5); + uVar2 = 0; + } + *param = uVar2; + *(ke_task_id_t *)(param + 2) = *param_1; + hci_send_2_host(param); + return 0; +} + + + +undefined4 hci_rd_auth_payl_to_cmd_handler(ke_task_id_t *param_1,uint param_2) + +{ + ke_state_t kVar1; + undefined *param; + + kVar1 = ble_ke_state_get((ke_task_id_t)param_2); + param = (undefined *)ble_ke_msg_alloc(0x801,*param_1,0xc7b,6); + if ((kVar1 & 0xf) == 0xf) { + *param = 0xc; + } + else { + *param = 0; + *(uint16_t *)(param + 4) = llc_env[param_2 >> 8]->auth_payl_to; + } + *(ke_task_id_t *)(param + 2) = *param_1; + hci_send_2_host(param); + return 0; +} + + + +undefined4 hci_rd_rssi_cmd_handler(ke_task_id_t *param_1,ke_task_id_t param_2) + +{ + ke_state_t kVar1; + undefined *param; + + param = (undefined *)ble_ke_msg_alloc(0x801,*param_1,0x1405,6); + kVar1 = ble_ke_state_get(param_2); + if ((kVar1 & 0xf) == 0xf) { + *param = 0xc; + param[4] = 0; + } + else { + *param = 0; + param[4] = llc_env[*param_1]->rssi; + } + *(ke_task_id_t *)(param + 2) = *param_1; + hci_send_2_host(param); + return 0; +} + + + +undefined4 hci_rd_tx_pwr_lvl_cmd_handler(ke_task_id_t *param_1,ke_task_id_t param_2) + +{ + uint8_t uVar1; + ke_state_t kVar2; + undefined *param; + undefined uVar3; + + param = (undefined *)ble_ke_msg_alloc(0x801,*param_1,0xc2d,6); + kVar2 = ble_ke_state_get(param_2); + if ((kVar2 & 0xf) == 0xf) { + uVar3 = 0xc; +LAB_23039266: + *param = uVar3; + param[4] = 0; + } + else { + *param = 0; + if (*(char *)(param_1 + 1) == '\0') { + uVar1 = (*rwip_rf.txpwr_dbm_get) + ((uint8_t)*(undefined2 *)((uint)*param_1 * 0x5c + 0x280080a0),'\x01'); + } + else { + if (*(char *)(param_1 + 1) != '\x01') { + uVar3 = 0x12; + goto LAB_23039266; + } + uVar1 = (*rwip_rf.txpwr_dbm_get)(rwip_rf.txpwr_max,'\x01'); + } + param[4] = uVar1; + } + *(ke_task_id_t *)(param + 2) = *param_1; + hci_send_2_host(param); + return 0; +} + + + +undefined4 hci_le_con_update_cmd_handler(ushort *param_1,ke_task_id_t param_2,uint16_t param_3) + +{ + byte bVar1; + ushort uVar2; + ushort uVar3; + uint8_t status; + _Bool _Var4; + ke_state_t kVar5; + undefined3 extraout_var; + undefined *puVar6; + undefined3 extraout_var_00; + byte status_00; + uint uVar7; + uint uVar8; + uint uVar9; + llc_env_tag *plVar10; + lld_evt_tag *evt; + ea_elt_tag *peVar11; + + kVar5 = ble_ke_state_get(param_2); + if ((kVar5 & 0xf) == 0xf) { + evt = (lld_evt_tag *)0x0; + status = -1; + status_00 = 0xc; + goto LAB_23039434; + } + plVar10 = llc_env[*param_1]; + peVar11 = plVar10->elt; + status = lld_get_mode(*param_1); + evt = (lld_evt_tag *)&peVar11->env; + if (CONCAT31(extraout_var,status) == 4) { + if ((plVar10->llc_status & 1) != 0) { + bVar1 = (plVar10->feats_used).feats[0]; + status = '\x1a'; + status_00 = bVar1 & 2; + if ((bVar1 & 2) == 0) goto LAB_23039434; + } + if (plVar10->peer_sup_conn_param_req != false) goto LAB_2303934a; + status = '\x1a'; +LAB_23039428: + status_00 = 0; + } + else { +LAB_2303934a: + uVar2 = param_1[1]; + uVar8 = (uint)param_1[2]; + if (uVar2 <= uVar8) { + if (((((uint)param_1[5] <= (uint)param_1[6]) && (param_1[2] < 0xc81)) && (5 < uVar2)) && + (((uVar3 = param_1[3], uVar3 < 500 && + (uVar7 = (uint)param_1[4], (uVar7 - 10 & 0xffff) < 0xc77)) && + (((uint)uVar3 + 1) * uVar8 < uVar7 << 2)))) { + uVar9 = (uint)(*(ushort *)&peVar11[2].ea_cb_stop >> 1); + if (((uVar9 < uVar2) || (uVar8 < uVar9)) || + ((uVar8 = (uint)plVar10->elt->duration_min / 0x4e2, uVar8 < (uint)param_1[5] || + ((((uint)param_1[6] < uVar8 || ((uint)plVar10->sup_to != uVar7)) || + (status = '\0', + (uint)*(ushort *)((int)&peVar11[2].linked_element + 2) - 1 != (uint)uVar3)))))) { + puVar6 = (undefined *)ble_ke_msg_alloc(0x109,param_2,param_2,0x22); + *puVar6 = 0; + status = -1; + *(ushort *)(puVar6 + 2) = param_1[1]; + *(ushort *)(puVar6 + 4) = param_1[2]; + *(ushort *)(puVar6 + 6) = param_1[3]; + *(ushort *)(puVar6 + 8) = param_1[4]; + *(ushort *)(puVar6 + 10) = param_1[5]; + *(ushort *)(puVar6 + 0xc) = param_1[6]; + ble_ke_msg_send(); + } + goto LAB_23039428; + } + } + status = -1; + status_00 = 0x12; + } +LAB_23039434: + llc_common_cmd_status_send(param_3,status_00,*param_1); + _Var4 = llm_util_check_evt_mask('\x02'); + if ((CONCAT31(extraout_var_00,_Var4) != 0) && (status != -1)) { + llc_con_update_complete_send(status,*param_1,evt); + } + return 0; +} + + + +undefined4 hci_wr_auth_payl_to_cmd_handler(ke_task_id_t *param_1,uint param_2) + +{ + llc_env_tag **pplVar1; + ke_state_t id; + undefined *param; + undefined uVar2; + llc_env_tag *plVar3; + + id = (ke_task_id_t)param_2; + id = ble_ke_state_get(id); + param = (undefined *)ble_ke_msg_alloc(0x801,*param_1,0xc7c,4); + if ((id & 0xf) == 0xf) { + uVar2 = 0xc; + } + else { + pplVar1 = llc_env + (param_2 >> 8); + if ((uint)*(ushort *)&(*pplVar1)->elt[2].ea_cb_stop * + (uint)*(ushort *)((int)&(*pplVar1)->elt[2].linked_element + 2) <= (uint)param_1[1] << 4) { + *param = 0; + plVar3 = *pplVar1; + plVar3->auth_payl_to = param_1[1]; + llc_util_set_auth_payl_to_margin((lld_evt_tag *)&plVar3->elt->env); + plVar3 = *pplVar1; + if ((plVar3->encryption_state & 3) == 3) { + ble_ke_timer_set(0x103,id,(uint)plVar3->auth_payl_to - (uint)plVar3->auth_payl_to_margin); + ble_ke_timer_set(0x104,id,(uint)(*pplVar1)->auth_payl_to); + } + goto LAB_2303952c; + } + uVar2 = 0x12; + } + *param = uVar2; +LAB_2303952c: + *(ke_task_id_t *)(param + 2) = *param_1; + hci_send_2_host(param); + return 0; +} + + + +int hci_flush_cmd_handler + (ke_msg_id_t msgid,hci_basic_conhdl_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + ushort dest_id_00; + undefined *param_00; + + dest_id_00 = param->conhdl; + param_00 = (undefined *)ble_ke_msg_alloc(0x801,dest_id_00,0xc08,4); + llc_common_flush_occurred_send(dest_id_00); + lld_pdu_tx_flush(&llc_env[dest_id_00]->elt->env); + *(ushort *)(param_00 + 2) = dest_id_00; + *param_00 = 0; + hci_send_2_host(param_00); + return 0; +} + + + +undefined4 hci_rd_rem_ver_info_cmd_handler(uint16_t *param_1,uint param_2,uint16_t param_3) + +{ + ke_state_t id; + uint8_t status; + uint16_t conhdl; + + id = (ke_task_id_t)param_2; + id = ble_ke_state_get(id); + if ((id & 0xf) == 0xf) { + conhdl = *param_1; + status = '\f'; + } + else { + if ((llc_env[param_2 >> 8]->llc_status & 2) != 0) { + llc_common_cmd_status_send(param_3,'\0',*param_1); + llc_version_rd_event_send('\0',(uint16_t)(param_2 >> 8)); + return 0; + } + if ((id & 5) != 0) { + return 2; + } + ble_ke_state_set(id,(byte)id | 1); + llc_env[param_2 >> 8]->loc_proc_state = '\x02'; + llc_llcp_version_ind_pdu_send(*param_1); + ble_ke_timer_set(0x102,id,4000); + conhdl = *param_1; + status = '\0'; + } + llc_common_cmd_status_send(param_3,status,conhdl); + return 0; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +int llc_hci_command_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_msg_handler *pkVar1; + undefined2 in_register_00002036; + int iVar2; + + pkVar1 = llc_hci_command_handler_tab; + iVar2 = 0; + do { + if ((uint)pkVar1->id == CONCAT22(in_register_00002036,src_id)) { + if (llc_hci_command_handler_tab[iVar2].func == (ke_msg_func_t *)0x0) { + return 0; + } + // WARNING: Could not recover jumptable at 0x23039680. Too many branches + // WARNING: Treating indirect jump as call + iVar2 = (*llc_hci_command_handler_tab[iVar2].func) + ((ke_msg_id_t)CONCAT22(in_register_00002036,src_id)); + return iVar2; + } + iVar2 = iVar2 + 1; + pkVar1 = pkVar1 + 1; + } while (iVar2 != 0x10); + return 0; +} + + +/* +Unable to decompile 'llc_hci_acl_data_tx_handler' +Cause: Exception while decompiling 2303968e: Decompiler process died + +*/ + + +int hci_vsc_set_tx_pwr(ke_msg_id_t msgid,hci_vsc_set_tx_pwr_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t status; + + status = '\x12'; + if ((byte)param->power < 0x15) { + (*rwip_rf.txpwr_max_set)(param->power); + status = '\0'; + } + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_le_wr_rfpath_compensation_cmd_handler + (ke_msg_id_t msgid,hci_le_wr_rfpath_cps_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + g_rf_txpath_compensation_value = param->rf_txpath_compensation_value; + g_rf_rxpath_compensation_value = param->rf_rxpath_compensation_value; + llm_common_cmd_complete_send(src_id,'\0'); + return 0; +} + + + +int hci_wr_le_host_supp_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + llm_local_supp_feats[1][0] = *(char *)param << 1 | llm_local_supp_feats[1][0]; + llm_common_cmd_complete_send(src_id,'\0'); + return 0; +} + + + +int hci_le_wr_suggted_dft_data_len_cmd_handler + (ke_msg_id_t msgid,hci_le_wr_suggted_dft_data_len_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t status; + + status = '\x12'; + if (((ushort)(param->suggted_max_tx_octets - 0x1b) < 0xe1) && + ((ushort)(param->suggted_max_tx_time - 0x148) < 0x701)) { + llm_le_env.data_len_val.conn_initial_max_tx_time = param->suggted_max_tx_time; + status = '\0'; + llm_le_env.data_len_val.conn_initial_max_tx_octets = param->suggted_max_tx_octets; + } + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_le_set_evt_mask_cmd_handler + (ke_msg_id_t msgid,hci_le_set_evt_mask_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + (*ble_memcpy_ptr)(&llm_le_env.eventmask,param,8); + llm_common_cmd_complete_send(src_id,'\0'); + return 0; +} + + + +int hci_le_rd_rfpath_compensation_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint16_t uVar1; + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x204c,6); + *(uint16_t *)(param_00 + 2) = g_rf_txpath_compensation_value; + uVar1 = g_rf_rxpath_compensation_value; + *param_00 = 0; + *(uint16_t *)(param_00 + 4) = uVar1; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_le_rd_trans_pwr_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t uVar1; + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x204b,3); + param_00[1] = 0; + uVar1 = rwip_rf.txpwr_max; + *param_00 = 0; + param_00[2] = uVar1; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_rd_buff_size_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x1005,10); + *(undefined2 *)(param_00 + 6) = 0; + *(undefined2 *)(param_00 + 2) = 0; + param_00[4] = 0; + *(undefined2 *)(param_00 + 8) = 0; + *param_00 = 0; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_rd_local_supp_feats_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,src_id,9); + (*ble_memcpy_ptr)(param_00 + 1,llm_local_supp_feats,8); + *param_00 = 0; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_rd_local_supp_cmds_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x1002,0x41); + (*ble_memcpy_ptr)(param_00 + 1,&llm_local_cmds,0x40); + *param_00 = 0; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_rd_local_ver_info_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined2 *param_00; + + param_00 = (undefined2 *)ble_ke_msg_alloc(0x801,0,0x1001,10); + param_00[4] = 0x321; + param_00[1] = 0x321; + *param_00 = 0x900; + param_00[3] = 0x7af; + *(undefined *)(param_00 + 2) = 9; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_rd_bd_addr_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x1009,7); + (*ble_memcpy_ptr)(param_00 + 1,(void *)0x420264c1,6); + *param_00 = 0; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_le_rd_max_data_len_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint16_t uVar1; + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x202f,10); + *(uint16_t *)(param_00 + 6) = llm_le_env.data_len_val.suppted_max_rx_octets; + *(uint16_t *)(param_00 + 8) = llm_le_env.data_len_val.suppted_max_rx_time; + *(uint16_t *)(param_00 + 2) = llm_le_env.data_len_val.suppted_max_tx_octets; + uVar1 = llm_le_env.data_len_val.suppted_max_tx_time; + *param_00 = 0; + *(uint16_t *)(param_00 + 4) = uVar1; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_le_rd_suggted_dft_data_len_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint16_t uVar1; + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x2023,6); + *(uint16_t *)(param_00 + 2) = llm_le_env.data_len_val.conn_initial_max_tx_octets; + uVar1 = llm_le_env.data_len_val.conn_initial_max_tx_time; + *param_00 = 0; + *(uint16_t *)(param_00 + 4) = uVar1; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_le_rd_supp_states_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x201c,9); + (*ble_memcpy_ptr)(param_00 + 1,&llm_local_le_states,8); + *param_00 = 0; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_le_rd_wl_size_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x200f,2); + *param_00 = 0; + param_00[1] = 4; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_le_rd_adv_ch_tx_pw_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t uVar1; + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x2007,2); + uVar1 = (*rwip_rf.txpwr_dbm_get)(rwip_rf.txpwr_max,'\x01'); + param_00[1] = uVar1; + *param_00 = 0; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_le_rd_local_supp_feats_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x2003,9); + (*ble_memcpy_ptr)(param_00 + 1,&llm_local_le_feats,8); + *param_00 = 0; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_le_rd_buff_size_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint16_t uVar1; + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x2002,6); + param_00[4] = 2; + uVar1 = llm_le_env.data_len_val.suppted_max_tx_octets; + *param_00 = 0; + *(uint16_t *)(param_00 + 2) = uVar1; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_le_generate_dhkey_cmd_handler + (ke_msg_id_t msgid,hci_le_generate_dh_key_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t status; + int iVar1; + hci_le_generate_dh_key_cmd *phVar2; + + iVar1 = 0; + do { + if (param->public_key[iVar1] != '\0') { + status = '\0'; + goto LAB_23039bcc; + } + iVar1 = iVar1 + 1; + } while (iVar1 != 0x20); + status = '\x12'; +LAB_23039bcc: + phVar2 = (hci_le_generate_dh_key_cmd *)(param->public_key + 0x20); + do { + if (phVar2->public_key[0] != '\0') goto LAB_23039be4; + phVar2 = (hci_le_generate_dh_key_cmd *)(phVar2->public_key + 1); + } while (param + 1 != phVar2); + status = '\x12'; +LAB_23039be4: + if (llm_le_env.cur_ecc_multiplication == LLM_ECC_IDLE) { + if (status == '\0') { + llm_le_env.cur_ecc_multiplication = LLM_DHKEY_GENERATION; + status = ecc_generate_key256('\x02',llm_le_env.secret_key256,(u_int8 *)param, + (u_int8 *) + (hci_le_generate_dh_key_cmd *)(param->public_key + 0x20),6,0); + } + } + else { + status = '\f'; + } + llm_common_cmd_status_send(src_id,status); + return 0; +} + + + +int hci_host_nb_cmp_pkts_cmd_handler + (ke_msg_id_t msgid,hci_host_nb_cmp_pkts_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint16_t acl_pkt_nb; + uint8_t status; + uint8_t uVar1; + ushort *puVar2; + + puVar2 = param->con_hdl; + acl_pkt_nb = 0; + uVar1 = '\0'; + status = '\0'; + while (param->nb_of_hdl != uVar1) { + if (*puVar2 < 2) { + acl_pkt_nb = acl_pkt_nb + puVar2[3]; + } + else { + status = '\x12'; + } + uVar1 = uVar1 + '\x01'; + puVar2 = puVar2 + 1; + } + hci_fc_host_nb_acl_pkts_complete(acl_pkt_nb); + if (status != '\0') { + llm_common_cmd_complete_send(src_id,status); + } + return 0; +} + + + +int hci_host_buf_size_cmd_handler + (ke_msg_id_t msgid,hci_host_buf_size_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t status; + + status = hci_fc_acl_buf_size_set(param->acl_pkt_len,param->nb_acl_pkts); + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_set_evt_mask_page_2_cmd_handler + (ke_msg_id_t msgid,hci_set_evt_mask_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t status; + + status = hci_evt_mask_set((evt_mask *)param,'\x02'); + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_set_evt_mask_cmd_handler + (ke_msg_id_t msgid,hci_set_evt_mask_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t status; + + status = hci_evt_mask_set((evt_mask *)param,'\x03'); + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_set_ctrl_to_host_flow_ctrl_cmd_handler + (ke_msg_id_t msgid,hci_set_ctrl_to_host_flow_ctrl_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + byte bVar1; + uint8_t status; + + bVar1 = param->flow_cntl; + status = '\x12'; + if (bVar1 < 4) { + status = hci_fc_acl_en((_Bool)(bVar1 == 1 || bVar1 == 3)); + } + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_reset_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined2 in_register_0000202a; + + rwip_reset(CONCAT22(in_register_0000202a,msgid)); + llm_common_cmd_complete_send(src_id,'\0'); + return 0; +} + + + +int hci_le_tx_test_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t status; + ke_state_t kVar1; + undefined2 extraout_var; + undefined2 in_register_00002036; + + kVar1 = ble_ke_state_get(0); + status = (uint8_t)kVar1; + if (CONCAT22(extraout_var,kVar1) == 0) { + if (CONCAT22(in_register_00002036,src_id) == 0x201e) { + status = llm_test_mode_start_tx((hci_le_tx_test_cmd *)param); + } + } + else { + status = '\f'; + } + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_le_rx_test_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t status; + ke_state_t kVar1; + undefined2 extraout_var; + undefined2 in_register_00002036; + + kVar1 = ble_ke_state_get(0); + status = (uint8_t)kVar1; + if (CONCAT22(extraout_var,kVar1) == 0) { + if (CONCAT22(in_register_00002036,src_id) == 0x201d) { + status = llm_test_mode_start_rx((hci_le_rx_test_cmd *)param); + } + } + else { + status = '\f'; + } + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_le_rand_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *param_00; + int iVar1; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x2018,9); + iVar1 = bl_rand(); + param_00[1] = (char)iVar1; + param_00[2] = (char)((uint)iVar1 >> 8); + param_00[3] = (char)((uint)iVar1 >> 0x10); + param_00[4] = (char)((uint)iVar1 >> 0x18); + iVar1 = bl_rand(); + param_00[5] = (char)iVar1; + param_00[6] = (char)((uint)iVar1 >> 8); + param_00[8] = (char)((uint)iVar1 >> 0x18); + param_00[7] = (char)((uint)iVar1 >> 0x10); + *param_00 = 0; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_le_enc_cmd_handler + (ke_msg_id_t msgid,hci_le_enc_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + *(undefined2 *)(param[-1].plain_data + 8) = 4; + *(undefined2 *)(param[-1].plain_data + 0xc) = 8; + ble_co_list_push_back(&llm_le_env,param[-1].plain_data + 4); + if (llm_le_env.enc_pend == false) { + llm_encryption_start((llm_enc_req *)param); + } + return 1; +} + + + +int hci_le_wl_mngt_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t status; + ke_state_t kVar1; + undefined2 in_register_0000202a; + int iVar2; + uint16_t auStack34 [2]; + uint16_t conhdl; + + iVar2 = CONCAT22(in_register_0000202a,msgid); + kVar1 = ble_ke_state_get(0); + if ((((kVar1 & 0xf0) != 0x10) || + (status = '\f', (llm_le_env.advertising_params)->filterpolicy == '\0')) && + ((1 < ((uint)kVar1 & 0xf) - 1 || + (status = '\f', (llm_le_env.scanning_params)->filterpolicy == '\0')))) { + if (iVar2 == 0x2011) { + status = llm_wl_dev_add_hdl((bd_addr *)((int)param + 1),*(uint8_t *)param); + } + else { + if (iVar2 == 0x2012) { + status = llm_wl_dev_rem_hdl((bd_addr *)((int)param + 1),*(uint8_t *)param); + } + else { + status = '\0'; + if (iVar2 == 0x2010) { + llm_wl_clr(); + llm_util_bl_check((bd_addr *)0x0,'\0',auStack34,'\x01',(_Bool *)0x0); + } + } + } + } + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_le_set_host_ch_class_cmd_handler + (ke_msg_id_t msgid,hci_le_set_host_ch_class_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t uVar1; + uint8_t status; + + status = '\f'; + if (llm_le_env.ch_map_assess.llm_le_set_host_ch_class_cmd_sto != false) { + uVar1 = llm_util_check_map_validity((uint8_t *)param,'\x05'); + ble_ke_timer_set(0,0,100); + llm_le_env.ch_map_assess.llm_le_set_host_ch_class_cmd_sto = false; + status = '\x12'; + if ((byte)(uVar1 - 2) < 0x24) { + memcpy(&llm_le_env.ch_map_assess.ch_map,param,5); + status = '\0'; + } + } + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_le_create_con_cmd_handler + (ke_msg_id_t msgid,hci_le_create_con_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t status; + ke_state_t kVar1; + undefined2 extraout_var_00; + undefined3 extraout_var; + uint uVar2; + + kVar1 = ble_ke_state_get(0); + _kVar1 = CONCAT22(extraout_var_00,kVar1); + if (_kVar1 == 0x10) { +LAB_23039fb6: + status = llm_create_con(param); + if (CONCAT31(extraout_var,status) == 0) { + llm_le_env.opcode2 = src_id; + kVar1 = ble_ke_state_get(0); + llm_le_env.state2 = (uint8_t)kVar1; + llm_le_env.last_opcode = true; + } + } + else { + if (_kVar1 < 0x11) { + if (_kVar1 == 0) goto LAB_23039fb6; + uVar2 = 3; + } + else { + if (_kVar1 == 0x20) goto LAB_23039fb6; + if (_kVar1 == 0x23) { + return 2; + } + uVar2 = 0x13; + } + status = '\f'; + if (_kVar1 == uVar2) { + return 2; + } + } + llm_common_cmd_status_send(src_id,status); + return 0; +} + + + +int hci_le_set_scan_en_cmd_handler + (ke_msg_id_t msgid,hci_le_set_scan_en_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t status; + ke_state_t kVar1; + undefined2 extraout_var_00; + undefined3 extraout_var; + uint uVar2; + + kVar1 = ble_ke_state_get(0); + _kVar1 = CONCAT22(extraout_var_00,kVar1); + if (_kVar1 == 0x12) { +LAB_2303a0b6: + status = '\f'; + goto LAB_2303a054; + } + if (_kVar1 < 0x13) { + if (_kVar1 == 2) goto LAB_2303a0b6; + if (_kVar1 < 3) { + uVar2 = 1; + } + else { + if (_kVar1 == 3) { + return 2; + } + uVar2 = 0x11; + } + if (_kVar1 == uVar2) goto LAB_2303a0b0; +LAB_2303a018: + status = '\f'; + if (param->scan_en != '\x01') goto LAB_2303a054; + } + else { + if (_kVar1 != 0x21) { + if (_kVar1 < 0x22) { + uVar2 = 0x13; + } + else { + if (_kVar1 == 0x22) goto LAB_2303a0b6; + uVar2 = 0x23; + } + if (_kVar1 == uVar2) { + return 2; + } + goto LAB_2303a018; + } +LAB_2303a0b0: + if (param->scan_en != '\0') goto LAB_2303a0b6; + } + kVar1 = ble_ke_state_get(0); + llm_le_env.state2 = (uint8_t)kVar1; + llm_le_env.last_opcode = true; + llm_le_env.opcode2 = src_id; + status = llm_set_scan_en(param); + if ((CONCAT31(extraout_var,status) == 0) && (param->scan_en != '\x01')) { + return 0; + } +LAB_2303a054: + llm_common_cmd_complete_send(src_id,status); + llm_le_env.last_opcode = true; + llm_le_env.state2 = llm_le_env.state2 & 0xf0; + return 0; +} + + + +int hci_le_set_scan_param_cmd_handler + (ke_msg_id_t msgid,hci_le_set_scan_param_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t status; + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ble_ke_state_get(0); + _kVar1 = CONCAT22(extraout_var,kVar1); + status = '\f'; + if (((_kVar1 != 0x11) && (_kVar1 != 0x21)) && (_kVar1 != 1)) { + status = llm_set_scan_param(param); + } + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + +/* +Unable to decompile 'hci_le_set_scan_rsp_data_cmd_handler' +Cause: Exception while decompiling 2303a0fc: Decompiler process died + +*/ + + +int hci_le_set_adv_en_cmd_handler + (ke_msg_id_t msgid,hci_le_set_adv_en_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t status; + ke_state_t kVar1; + undefined2 extraout_var_00; + undefined3 extraout_var; + + kVar1 = ble_ke_state_get(0); + _kVar1 = CONCAT22(extraout_var_00,kVar1); + if (_kVar1 < 0x10) { +LAB_2303a1ee: + status = '\f'; + if (param->adv_en != '\x01') goto LAB_2303a1fa; + } + else { + if (0x13 < _kVar1) { + if ((_kVar1 - 0x20 & 0xff) < 4) { + return 2; + } + goto LAB_2303a1ee; + } + status = '\f'; + if (param->adv_en != '\0') goto LAB_2303a1fa; + } + kVar1 = ble_ke_state_get(0); + llm_le_env.state = (uint8_t)kVar1; + llm_le_env.opcode = src_id; + status = llm_set_adv_en(param); + if ((CONCAT31(extraout_var,status) == 0) && (param->adv_en != '\x01')) { + llm_le_env.last_opcode = false; + return 0; + } +LAB_2303a1fa: + llm_common_cmd_complete_send(src_id,status); + llm_le_env.last_opcode = false; + return 0; +} + + +/* +Unable to decompile 'hci_le_set_adv_data_cmd_handler' +Cause: Exception while decompiling 2303a204: Decompiler process died + +*/ + + +int hci_le_set_adv_param_cmd_handler + (ke_msg_id_t msgid,hci_le_set_adv_param_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t status; + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ble_ke_state_get(0); + status = '\f'; + if (3 < CONCAT22(extraout_var,kVar1) - 0x10U) { + status = llm_set_adv_param(param); + } + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_le_set_rand_add_cmd_handler + (ke_msg_id_t msgid,hci_le_set_rand_addr_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t status; + _Bool _Var1; + ke_state_t kVar2; + undefined2 extraout_var_00; + undefined3 extraout_var; + + kVar2 = ble_ke_state_get(0); + status = '\f'; + if (CONCAT22(extraout_var_00,kVar2) == 0) { + _Var1 = co_bdaddr_compare((bd_addr *)param,&co_null_bdaddr); + if (CONCAT31(extraout_var,_Var1) == 0) { + (*ble_memcpy_ptr)((void *)0x420264bb,param,6); + status = (uint8_t)kVar2; + } + else { + status = '\x12'; + } + } + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_le_rd_local_p256_public_key_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + t_key_multi_type status; + + status = llm_le_env.cur_ecc_multiplication; + if (llm_le_env.cur_ecc_multiplication != LLM_ECC_IDLE) { + status = 0xc; + } + llm_common_cmd_status_send(src_id,status); + if (status == LLM_ECC_IDLE) { + ecc_gen_new_secret_key(llm_le_env.secret_key256,false); + llm_le_env.cur_ecc_multiplication = LLM_PUBLIC_KEY_GENERATION; + ecc_gen_new_public_key(llm_le_env.secret_key256,6,0); + } + return 0; +} + + + +int hci_le_test_end_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + undefined *param_00; + + kVar1 = ble_ke_state_get(0); + if (CONCAT22(extraout_var,kVar1) == 0x24) { + llm_le_env.test_mode.end_of_tst = true; + lld_test_stop(llm_le_env.elt); + ble_ke_state_set(0,'#'); + } + else { + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x201f,4); + *(undefined2 *)(param_00 + 2) = 0; + *param_00 = 0xc; + hci_send_2_host(param_00); + } + return 0; +} + + + +int hci_le_create_con_cancel_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ble_ke_state_get(0); + _kVar1 = CONCAT22(extraout_var,kVar1); + if (((_kVar1 == 0x12) || (_kVar1 == 0x22)) || (_kVar1 == 2)) { + lld_scan_stop(llm_le_env.elt_coext_scan); + llm_le_env.state2 = llm_le_env.state2 & 0xf0 | 2; + llm_le_env.last_opcode = true; + llm_le_env.opcode2 = src_id; + kVar1 = ble_ke_state_get(0); + ble_ke_state_set(0,(byte)kVar1 & 0xf0 | 3); + } + else { + llm_common_cmd_complete_send(src_id,'\f'); + } + return 0; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +int hci_command_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_msg_handler *pkVar1; + undefined2 in_register_00002036; + uint uVar2; + int iVar3; + + uVar2 = CONCAT22(in_register_00002036,src_id); + pkVar1 = llm_hci_command_handler_tab; + iVar3 = 0; + do { + if ((uint)pkVar1->id == uVar2) { + if (llm_hci_command_handler_tab[iVar3].func == (ke_msg_func_t *)0x0) { + return 0; + } + // WARNING: Could not recover jumptable at 0x2303a45e. Too many branches + // WARNING: Treating indirect jump as call + iVar3 = (*llm_hci_command_handler_tab[iVar3].func)((ke_msg_id_t)uVar2,(void *)uVar2); + return iVar3; + } + iVar3 = iVar3 + 1; + pkVar1 = pkVar1 + 1; + } while (iVar3 != 0x2d); + return 0; +} + + + +char * bearer2str(bt_mesh_prov_bearer_t bearer) + +{ + undefined3 in_register_00002029; + + if (CONCAT31(in_register_00002029,bearer) == 1) { + return "PB-ADV"; + } + if (CONCAT31(in_register_00002029,bearer) != 2) { + return "unknown"; + } + return "PB-GATT"; +} + + + +int fault_test(bt_mesh_model *model,uint8_t test_id,uint16_t cid) + +{ + int iVar1; + undefined3 in_register_0000202d; + undefined2 in_register_00002032; + + iVar1 = -0x16; + if ((CONCAT22(in_register_00002032,cid) == 0x5f1) && (CONCAT31(in_register_0000202d,test_id) == 0) + ) { + iVar1 = 0; + } + return iVar1; +} + + + +void attn_on(bt_mesh_model *model) + +{ + return; +} + + + +void lpn_cb(u16_t friend_addr,_Bool established) + +{ + undefined2 in_register_0000202a; + char *fmt; + undefined3 in_register_0000202d; + + if (CONCAT31(in_register_0000202d,established) == 0) { + fmt = "Friendship (as LPN) lost with Friend 0x%04x\r\n"; + } + else { + fmt = "Friendship (as LPN) established to Friend 0x%04x\r\n"; + } + printf(fmt,CONCAT22(in_register_0000202a,friend_addr)); + return; +} + + + +int fault_get_reg(bt_mesh_model *model,u16_t cid,u8_t *test_id,u8_t *faults,u8_t *fault_count) + +{ + byte bVar1; + int iVar2; + undefined2 in_register_0000202e; + + if (CONCAT22(in_register_0000202e,cid) == 0x5f1) { + printf("Sending registered faults\r\n"); + *test_id = '\0'; + bVar1 = *fault_count; + iVar2 = 0; + *fault_count = '\0'; + do { + if (bVar1 <= *fault_count) break; + if (reg_faults[iVar2] != '\0') { + *faults = reg_faults[iVar2]; + faults = faults + 1; + *fault_count = *fault_count + '\x01'; + } + iVar2 = iVar2 + 1; + } while (iVar2 != 8); + iVar2 = 0; + } + else { + printf("Faults requested for unknown Company ID 0x%04x\r\n"); + iVar2 = -0x16; + } + return iVar2; +} + + + +void prov_reset(void) + +{ + printf("The local node has been reset and needs reprovisioning\r\n"); + return; +} + + + +void prov_complete(u16_t net_idx,u16_t addr) + +{ + undefined2 in_register_0000202a; + undefined2 in_register_0000202e; + + printf("Local node provisioned, net_idx 0x%04x address 0x%04x\r\n", + CONCAT22(in_register_0000202a,net_idx),CONCAT22(in_register_0000202e,addr)); + net.local = addr; + net.dst = addr; + net.net_idx = net_idx; + return; +} + + + +void link_close(bt_mesh_prov_bearer_t bearer) + +{ + char *pcVar1; + + pcVar1 = bearer2str(bearer); + printf("Provisioning link closed on %s\r\n",pcVar1); + return; +} + + + +void link_open(bt_mesh_prov_bearer_t bearer) + +{ + char *pcVar1; + + pcVar1 = bearer2str(bearer); + printf("Provisioning link opened on %s\r\n",pcVar1); + return; +} + + + +void prov_input_complete(void) + +{ + printf("Input complete\r\n"); + return; +} + + + +int input(bt_mesh_input_action_t act,u8_t size) + +{ + undefined3 in_register_00002029; + int iVar1; + char *fmt; + undefined3 in_register_0000202d; + + iVar1 = CONCAT31(in_register_00002029,act); + if (iVar1 == 4) { + fmt = "Enter a number (max %u digits) with: input-num \r\n"; + } + else { + if (iVar1 != 8) { + printf("Unknown input action %u (size %u) requested!\r\n",iVar1, + CONCAT31(in_register_0000202d,size)); + return -0x16; + } + fmt = "Enter a string (max %u chars) with: input-str \r\n"; + } + printf(fmt); + input_act = act; + input_size = size; + return 0; +} + + + +int output_string(char *str) + +{ + printf("OOB String: %s\r\n",str); + return 0; +} + + + +int output_number(bt_mesh_output_action_t action,u32_t_conflict number) + +{ + printf("OOB Number: %u\r\n"); + return 0; +} + + + +// WARNING: Variable defined which should be unmapped: net_buf_data_msg +// WARNING: Could not reconcile some variable overlaps + +void vendor_data_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + char *pcVar1; + u8_t **ppuStack100; + net_buf_simple msg; + u8_t net_buf_data_msg [72]; + + ppuStack100 = &msg.__buf; + msg.data = (u8_t *)0x480000; + msg._4_4_ = &msg.__buf; + pcVar1 = bt_hex_real(buf->data,(uint)buf->len); + printf("data[%s]\n",pcVar1); + bt_mesh_model_msg_init((net_buf_simple *)&ppuStack100,0xc2003f); + net_buf_simple_add_mem((net_buf_simple *)&ppuStack100,buf->data,(uint)buf->len); + bt_mesh_model_send(model,ctx,(net_buf_simple *)&ppuStack100,(bt_mesh_send_cb *)0x0,(void *)0x0); + return; +} + + + +void blemesh_lpn_set(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + _Bool lpn_enabled; + char *fmt; + int iVar1; + uint8_t auStack17 [4]; + u8_t enable; + + get_uint8_from_string(argv + 1,auStack17); + if (auStack17[0] == '\0') { + if (lpn_enabled == false) { + fmt = "LPN already disabled\r\n"; + } + else { + iVar1 = bt_mesh_lpn_set(false); + if (iVar1 == 0) { + lpn_enabled = false; + fmt = "Disable LPN successfully\r\n"; + } + else { + fmt = "Failed to disable LPN\r\n"; + } + } + } + else { + if (lpn_enabled == false) { + iVar1 = bt_mesh_lpn_set(true); + if (iVar1 == 0) { + lpn_enabled = true; + fmt = "Enable LPN successfully\r\n"; + } + else { + fmt = "Failed to enable LPN\r\n"; + } + } + else { + fmt = "LPN already enabled\r\n"; + } + } + printf(fmt); + return; +} + + + +void blemesh_rpl_clr(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + memset(bt_mesh.rpl,0,0x28); + return; +} + + + +int fault_clear(bt_mesh_model *model,uint16_t cid) + +{ + undefined2 in_register_0000202e; + + if (CONCAT22(in_register_0000202e,cid) == 0x5f1) { + memset(reg_faults,0,8); + return 0; + } + return -0x16; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void blemesh_seg_send(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + _Bool _Var1; + u8_t uVar2; + char *fmt; + undefined3 extraout_var; + int iVar3; + uint16_t uStack152; + uint16_t uStack150; + uint16_t src; + uint16_t dst; + net_buf_simple sdu; + uint8_t payload [12]; + bt_mesh_net_tx tx; + bt_mesh_msg_ctx ctx; + u8_t net_buf_data_sdu [72]; + + _src = &ctx.srv_send; + sdu.data = (u8_t *)0x480000; + sdu._4_4_ = &ctx.srv_send; + sdu.__buf = (u8_t *)0xff; + payload._0_4_ = 0; + payload._4_4_ = 0; + if (argc != 3) { + fmt = "Number of Parameters is not correct\r\n"; +LAB_2303a7b4: + printf(fmt); + return; + } + _Var1 = bt_mesh_is_provisioned(); + if (CONCAT31(extraout_var,_Var1) == 0) { + fmt = "Local node is not yet provisioned\r\n"; + goto LAB_2303a7b4; + } + get_uint16_from_string(argv + 1,&uStack152); + get_uint16_from_string(argv + 2,&uStack150); + memset(&ctx.app_idx,0,0x12); + tx.src = net.net_idx; + if (bt_mesh.app_keys[0].net_idx == 0xffff) { + tx._10_2_ = bt_mesh.app_keys[1].net_idx; + if (bt_mesh.app_keys[1].net_idx == 0xffff) goto LAB_2303a830; + iVar3 = 1; + } + else { + iVar3 = 0; + } + tx._10_2_ = bt_mesh.app_keys[iVar3].app_idx; +LAB_2303a830: + payload._8_4_ = (bt_mesh_subnet *)0x0; + ctx.net_idx = uStack150; + ctx.recv_dst._0_1_ = 1; + tx.sub = (bt_mesh_subnet *)0x0; + tx.ctx = (bt_mesh_msg_ctx *)0x0; + payload._8_4_ = bt_mesh_subnet_get(net.net_idx); + tx.sub = (bt_mesh_subnet *)&tx.src; + tx.ctx = (bt_mesh_msg_ctx *)((uint)tx.ctx & 0xffff0000 | (uint)uStack152); + uVar2 = bt_mesh_net_transmit_get(); + tx.ctx._0_3_ = CONCAT12(uVar2,tx.ctx._0_2_); + tx.ctx = (bt_mesh_msg_ctx *)((uint)tx.ctx & 0xff000000 | (uint)(uint3)tx.ctx); + printf("Sending segmented message\r\n"); + net_buf_simple_add_mem((net_buf_simple *)&src,&sdu.__buf,0xc); + bt_mesh_trans_send((bt_mesh_net_tx_conflict7 *)(payload + 8),(net_buf_simple *)&src, + (bt_mesh_send_cb *)0x0,(void *)0x0); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void blemesh_net_send(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + _Bool _Var1; + u8_t xmit; + char *fmt; + undefined3 extraout_var; + net_buf *buf; + uint8_t uStack74; + uint8_t uStack73; + uint16_t uStack72; + uint8_t ttl; + uint8_t ctl; + uint16_t src; + uint16_t dst; + bt_mesh_net_tx tx; + uint8_t payload [16]; + bt_mesh_msg_ctx ctx; + + tx._8_4_ = 0; + payload._0_4_ = 0; + payload._4_4_ = 0; + payload._8_4_ = 0; + if (argc == 5) { + _Var1 = bt_mesh_is_provisioned(); + if (CONCAT31(extraout_var,_Var1) == 0) { + fmt = "Local node is not yet provisioned\r\n"; + } + else { + get_uint8_from_string(argv + 1,&uStack74); + get_uint8_from_string(argv + 2,&uStack73); + get_uint16_from_string(argv + 3,&uStack72); + get_uint16_from_string(argv + 4,(uint16_t *)&ttl); + memset(&ctx.app_idx,0,0x12); + payload._12_2_ = net.net_idx; + if (uStack73 == '\0') { + payload._14_2_ = 0xfffe; + } + else { + payload._14_2_ = 0xffff; + } + _src = (bt_mesh_subnet *)0x0; + tx.sub = (bt_mesh_subnet *)0x0; + ctx.net_idx = _ttl; + tx.ctx = (bt_mesh_msg_ctx *)0x0; + ctx.recv_dst._1_1_ = uStack74; + _src = bt_mesh_subnet_get(net.net_idx); + tx.sub = (bt_mesh_subnet *)(payload + 0xc); + tx.ctx = (bt_mesh_msg_ctx *)((uint)tx.ctx & 0xffff0000 | (uint)uStack72); + xmit = bt_mesh_net_transmit_get(); + tx.ctx._0_3_ = CONCAT12(xmit,(u16_t)tx.ctx); + tx.ctx = (bt_mesh_msg_ctx *)((uint)tx.ctx & 0xff000000 | (uint)(uint3)tx.ctx); + buf = bt_mesh_adv_create(BT_MESH_ADV_DATA,xmit,0); + if (buf != (net_buf *)0x0) { + printf("Sending network packet\r\n"); + net_buf_simple_reserve((net_buf_simple *)&buf->field_4,9); + net_buf_simple_add_mem((net_buf_simple *)&buf->field_4,&tx.src,0x10); + bt_mesh_net_send((bt_mesh_net_tx_conflict4 *)&src,buf,(bt_mesh_send_cb *)0x0,(void *)0x0); + return; + } + fmt = "Out of network buffers\r\n"; + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt); + return; +} + + + +void blemesh_reset(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + bt_mesh_reset(); + printf("Local node reset complete\r\n"); + return; +} + + + +void blemesh_input_str(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + size_t sVar1; + uint uVar2; + + if (argc == 2) { + if (input_act == BT_MESH_ENTER_STRING) { + sVar1 = strlen(argv[1]); + uVar2 = (uint)input_size; + if (sVar1 < uVar2) { + fmt = "Too short input (%u characters required)\r\n"; + } + else { + uVar2 = bt_mesh_input_string(argv[1]); + if (uVar2 == 0) { + input_act = BT_MESH_NO_INPUT; + return; + } + fmt = "String input failed (err %d)\r\n"; + } + printf(fmt,uVar2); + return; + } + fmt = "A string hasn\'t been requested!\r\n"; + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt); + return; +} + + + +void blemesh_input_num(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + ulong num; + size_t sVar1; + uint uVar2; + + if (argc == 2) { + num = strtoul(argv[1],(char **)0x0,10); + if (input_act == BT_MESH_ENTER_NUMBER) { + sVar1 = strlen(argv[1]); + uVar2 = (uint)input_size; + if (sVar1 < uVar2) { + fmt = "Too short input (%u digits required)\r\n"; + } + else { + uVar2 = bt_mesh_input_number(num); + if (uVar2 == 0) { + input_act = BT_MESH_NO_INPUT; + return; + } + fmt = "Numeric input failed (err %d)\r\n"; + } + printf(fmt,uVar2); + return; + } + fmt = "A number hasn\'t been requested!\r\n"; + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt); + return; +} + + + +void blemesh_ivu_test(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + uint8_t auStack17 [4]; + uint8_t enable; + + if (argc == 2) { + get_uint8_from_string(argv + 1,auStack17); + if (auStack17[0] == '\0') { + fmt = "IV Update test mode disabled\r\n"; + } + else { + fmt = "IV Update test mode enabled\r\n"; + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt); + return; +} + + + +void blemesh_set_dev_uuid(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + if (argc != 2) { + printf("Number of Parameters is not correct\r\n"); + return; + } + printf("device uuid is %s\r\n",argv[1]); + get_bytearray_from_string(argv + 1,dev_uuid,0x10); + return; +} + + + +void blemesh_fault_set(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + int iVar1; + char *fmt; + size_t sVar2; + uint array_size; + byte *pbVar3; + uint8_t auStack33 [4]; + uint8_t type; + + if (argc == 3) { + get_uint8_from_string(argv + 1,auStack33); + if (auStack33[0] == '\0') { + sVar2 = strlen(argv[2]); + array_size = 4; + if (sVar2 < 8) { + memset(cur_faults,0,4); + sVar2 = strlen(argv[2]); + array_size = sVar2 >> 1; + } + get_bytearray_from_string(argv + 2,cur_faults,array_size); + printf("Current Fault: "); + iVar1 = 0; + do { + pbVar3 = cur_faults + iVar1; + iVar1 = iVar1 + 1; + printf("%02X",(uint)*pbVar3); + } while (iVar1 != 4); + } + else { + sVar2 = strlen(argv[2]); + array_size = 8; + if (sVar2 < 0x10) { + memset(reg_faults,0,8); + sVar2 = strlen(argv[2]); + array_size = sVar2 >> 1; + } + get_bytearray_from_string(argv + 2,reg_faults,array_size); + printf("Registered Fault: "); + iVar1 = 0; + do { + pbVar3 = reg_faults + iVar1; + iVar1 = iVar1 + 1; + printf("%02X",(uint)*pbVar3); + } while (iVar1 != 8); + } + fmt = "\r\n"; + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt); + return; +} + + + +void blemesh_pb(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + int iVar1; + char *pcVar2; + char *fmt; + bt_mesh_prov_bearer_t bStack18; + uint8_t auStack17 [3]; + uint8_t bearer; + uint8_t enable; + + if (argc != 3) { + printf("Number of Parameters is not correct\r\n"); + return; + } + get_uint8_from_string(argv + 1,&bStack18); + get_uint8_from_string(argv + 2,auStack17); + if (auStack17[0] == '\0') { + iVar1 = bt_mesh_prov_disable(bStack18); + if (iVar1 == 0) { + pcVar2 = bearer2str(bStack18); + fmt = "%s disabled\r\n"; + goto LAB_2303acd6; + } + pcVar2 = bearer2str(bStack18); + fmt = "Failed to disable %s (err %d)\r\n"; + } + else { + iVar1 = bt_mesh_prov_enable(bStack18); + if (iVar1 == 0) { + pcVar2 = bearer2str(bStack18); + fmt = "%s enabled\r\n"; +LAB_2303acd6: + printf(fmt,pcVar2); + return; + } + pcVar2 = bearer2str(bStack18); + fmt = "Failed to enable %s (err %d)\r\n"; + } + printf(fmt,pcVar2,iVar1); + return; +} + + + +void blemesh_init(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + _Bool _Var1; + char *fmt; + int iVar2; + undefined3 extraout_var; + undefined auStack40 [4]; + bt_addr_le_t adv_addr; + u8_t uuid [16]; + + if (blemesh_inited == false) { + bt_get_local_public_address((bt_addr_le_t *)auStack40); + stack0xffffffe0 = 0xaf07; + memcpy(dev_uuid,adv_addr.a.val + 3,0x10); + iVar2 = bt_mesh_init((bt_mesh_prov_conflict5 *)&prov,&comp); + if (iVar2 == 0) { + blemesh_inited = true; + printf("Init successfully \r\n"); + _Var1 = bt_mesh_is_provisioned(); + if (CONCAT31(extraout_var,_Var1) == 0) { + fmt = "Use pb-adv or pb-gatt to enable advertising\r\n"; + } + else { + fmt = "Mesh network restored from flash\r\n"; + } + printf(fmt); + bt_mesh_lpn_set_cb(lpn_cb); + return; + } + fmt = "Failed to init \r\n"; + } + else { + fmt = "Has initialized \r\n"; + } + printf(fmt); + return; +} + + + +void attn_off(void) + +{ + return; +} + + + +void blemesh_iv_update(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + _Bool enable_00; + char *fmt; + undefined3 extraout_var; + atomic_val_t aVar1; + uint8_t auStack17 [4]; + uint8_t enable; + + if (argc == 2) { + enable_00 = bt_mesh_is_provisioned(); + if (CONCAT31(extraout_var,enable_00) != 0) { + get_uint8_from_string(argv + 1,auStack17); + if (auStack17[0] == '\0') { + printf("IV Update procedure stopped\r\n"); + aVar1 = atomic_get(bt_mesh.flags); + if ((aVar1 >> 3 & 1U) == 0) { + return; + } + enable_00 = false; + } + else { + printf("IV Update procedure started\r\n"); + aVar1 = atomic_get(bt_mesh.flags); + if ((aVar1 >> 3 & 1U) != 0) { + return; + } + enable_00 = true; + } + bt_mesh_beacon_ivu_initiator(enable_00); + return; + } + fmt = "Local node is not yet provisioned\r\n"; + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt); + return; +} + + + +int fault_get_cur(bt_mesh_model *model,u8_t *test_id,u16_t *company_id,u8_t *faults, + u8_t *fault_count) + +{ + byte bVar1; + int iVar2; + + printf("Sending current faults\r\n"); + *test_id = '\0'; + *company_id = 0x5f1; + bVar1 = *fault_count; + iVar2 = 0; + *fault_count = '\0'; + do { + if (bVar1 <= *fault_count) { + return 0; + } + if (cur_faults[iVar2] != '\0') { + *faults = cur_faults[iVar2]; + faults = faults + 1; + *fault_count = *fault_count + '\x01'; + } + iVar2 = iVar2 + 1; + } while (iVar2 != 4); + return 0; +} + + + +void show_faults(u8_t test_id,u16_t cid,u8_t *faults,size_t fault_count) + +{ + byte bVar1; + byte *pbVar2; + undefined3 in_register_00002029; + undefined2 in_register_0000202e; + + if (fault_count == 0) { + printf("Health Test ID 0x%02x Company ID 0x%04x: no faults\r\n", + CONCAT31(in_register_00002029,test_id),CONCAT22(in_register_0000202e,cid)); + return; + } + pbVar2 = faults + fault_count; + printf("Health Test ID 0x%02x Company ID 0x%04x Fault Count %zu:\r\n", + CONCAT31(in_register_00002029,test_id),CONCAT22(in_register_0000202e,cid)); + while (faults != pbVar2) { + bVar1 = *faults; + faults = faults + 1; + printf("\t0x%02x",(uint)bVar1); + } + return; +} + + + +void health_current_status + (bt_mesh_health_cli *cli,u16_t addr,u8_t test_id,u16_t cid,u8_t *faults, + size_t fault_count) + +{ + undefined2 in_register_0000202e; + + printf("Health Current Status from 0x%04x\r\n",CONCAT22(in_register_0000202e,addr)); + show_faults(test_id,cid,faults,fault_count); + return; +} + + + +int blemesh_cli_register(void) + +{ + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int send_friend_poll(void) + +{ + u16_t uVar1; + int iVar2; + byte bStack53; + u8_t fsn; + bt_mesh_subnet *pbStack52; + bt_mesh_net_tx_conflict tx; + bt_mesh_msg_ctx ctx; + + memset(&ctx.app_idx,0,0x12); + tx.ctx = (bt_mesh_msg_ctx *)0x0; + tx.src = bt_mesh.sub[0].net_idx; + tx._10_2_ = 0xffff; + ctx.net_idx = bt_mesh.lpn.frnd; + pbStack52 = bt_mesh.sub; + tx.sub = (bt_mesh_subnet *)&tx.src; + uVar1 = bt_mesh_primary_addr(); + tx.ctx = (bt_mesh_msg_ctx *)((uint)tx.ctx & 0xfe000000 | (uint)uVar1 | 0x1090000); + bStack53 = (byte)(bt_mesh.lpn._12_4_ >> 3) & 1; + if (bt_mesh.lpn.sent_req == '\0') { + iVar2 = bt_mesh_ctl_send((bt_mesh_net_tx_conflict7 *)&stack0xffffffcc,'\x01',&bStack53,1, + (u64_t *)0x0,&req_sent_cb,(void *)0x0); + if (iVar2 == 0) { + bt_mesh.lpn._12_4_ = bt_mesh.lpn._12_4_ & 0xfffffffd; + bt_mesh.lpn.sent_req = '\x01'; + } + } + else { + iVar2 = 0; + if (bt_mesh.lpn.sent_req != '\x01') { + bt_mesh.lpn._12_4_ = bt_mesh.lpn._12_4_ | 2; + } + } + return iVar2; +} + + + +void group_zero(atomic_t *target) + +{ + atomic_set(target,0); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void clear_friendship(_Bool force,_Bool disable) + +{ + u8_t uVar1; + u16_t uVar2; + undefined3 in_register_00002029; + bt_mesh_cfg_srv *pbVar3; + undefined3 in_register_0000202d; + ushort uStack72; + ushort uStack70; + bt_mesh_ctl_friend_clear req; + bt_mesh_net_tx_conflict tx; + bt_mesh_msg_ctx ctx; + + pbVar3 = bt_mesh_cfg_get(); + if (((CONCAT31(in_register_00002029,force) == 0) && ((bt_mesh.lpn._12_4_ & 0x30) == 0x10)) && + (bt_mesh.lpn.req_attempts < 2)) { + memset(&ctx.app_idx,0,0x12); + tx.ctx = (bt_mesh_msg_ctx *)0x0; + tx.src = bt_mesh.sub[0].net_idx; + tx._10_2_ = 0xffff; + ctx.net_idx = bt_mesh.lpn.frnd; + req = bt_mesh.sub; + tx.sub = (bt_mesh_subnet *)&tx.src; + uVar2 = bt_mesh_primary_addr(); + tx.ctx = (bt_mesh_msg_ctx *)((uint)tx.ctx & 0xffff0000 | (uint)uVar2); + uVar1 = bt_mesh_net_transmit_get(); + tx.ctx._0_3_ = CONCAT12(uVar1,(ushort)tx.ctx); + tx.ctx = (bt_mesh_msg_ctx *)((uint)tx.ctx & 0xff000000 | (uint)(uint3)tx.ctx); + uStack72 = (ushort)tx.ctx << 8 | (ushort)tx.ctx >> 8; + uStack70 = bt_mesh.lpn.counter << 8 | bt_mesh.lpn.counter >> 8; + bt_mesh_ctl_send((bt_mesh_net_tx_conflict7 *)&req,'\x05',&uStack72,4,(u64_t *)0x0,&clear_sent_cb + ,(void *)0x0); + bt_mesh.lpn._12_4_ = + bt_mesh.lpn._12_4_ & 0xffffff00 | + (uint)(byte)(bt_mesh.lpn._12_1_ & 0xfb | (byte)(((uint)disable & 1) << 2)); + } + else { + bt_mesh_rx_reset(); + k_delayed_work_cancel(&bt_mesh.lpn.timer); + friend_cred_del(bt_mesh.sub[0].net_idx,bt_mesh.lpn.frnd); + bt_mesh.lpn.old_friend = 0; + if ((bt_mesh.lpn._12_4_ & 0x20) == 0) { + bt_mesh.lpn.old_friend = bt_mesh.lpn.frnd; + } + if ((lpn_cb != (anon_subr_void_u16_t__Bool_conflict *)0x0) && (bt_mesh.lpn.frnd != 0)) { + (*lpn_cb)(bt_mesh.lpn.frnd,false); + } + bt_mesh.lpn._12_4_ = bt_mesh.lpn._12_4_ & 0xffff00c3; + bt_mesh.lpn.sent_req = '\0'; + bt_mesh.lpn._4_4_ = 0; + group_zero(bt_mesh.lpn.added); + group_zero(bt_mesh.lpn.pending); + group_zero(bt_mesh.lpn.to_remove); + bt_mesh.lpn._12_4_ = bt_mesh.lpn._12_4_ | 1; + if (((pbVar3->hb_pub).feat & 8) != 0) { + bt_mesh_heartbeat_send(); + } + if (CONCAT31(in_register_0000202d,disable) == 0) { + bt_mesh.lpn.state = shaStateError; + k_delayed_work_submit(&bt_mesh.lpn.timer,8000); + } + else { + bt_mesh.lpn.state = shaSuccess; + } + } + return; +} + + + +int atomic_test_and_clear_bit(atomic_t *target,int bit) + +{ + uint uVar1; + uint uVar2; + + uVar1 = 1 << (bit & 0x1fU); + uVar2 = atomic_and(target,~uVar1); + return (uint)((uVar2 & uVar1) != 0); +} + + + +int atomic_test_bit(atomic_t *target,int bit) + +{ + atomic_val_t aVar1; + + aVar1 = atomic_get(target); + return aVar1 >> (bit & 0x1fU) & 1; +} + + + +void friend_req_sent(u16_t duration,int err,void *user_data) + +{ + undefined2 in_register_0000202a; + + if (err != 0) { + printf("Sending Friend Request failed (err %d)\r\n"); + return; + } + bt_mesh.lpn.adv_duration = duration; + k_delayed_work_submit(&bt_mesh.lpn.timer,CONCAT22(in_register_0000202a,duration) + 0x44c); + bt_mesh.lpn.state = TID_5; + return; +} + + + +void friend_clear_sent(int err,void *user_data) + +{ + bt_mesh_scan_enable(); + bt_mesh.lpn.req_attempts = bt_mesh.lpn.req_attempts + '\x01'; + if (err != 0) { + printf("Sending Friend Request failed (err %d)\r\n"); + bt_mesh.lpn.state = shaStateError; + clear_friendship(false,(_Bool)((byte)(bt_mesh.lpn._12_4_ >> 2) & 1)); + return; + } + bt_mesh.lpn.state = shaNull; + k_delayed_work_submit(&bt_mesh.lpn.timer,0x44c); + return; +} + + + +void req_sent(u16_t duration,int err,void *user_data) + +{ + undefined2 in_register_0000202a; + uint32_t delay; + + if (err != 0) { + printf("Sending request failed (err %d)\r\n"); + bt_mesh.lpn.sent_req = '\0'; + group_zero(bt_mesh.lpn.pending); + return; + } + bt_mesh.lpn.req_attempts = bt_mesh.lpn.req_attempts + '\x01'; + if ((bt_mesh.lpn._12_1_ & 0x10) == 0) { + delay = CONCAT22(in_register_0000202a,duration) + 100 + (uint)bt_mesh.lpn.recv_win; + } + else { + bt_mesh.lpn.state = TID_7; + delay = 0x5a; + } + bt_mesh.lpn.adv_duration = duration; + k_delayed_work_submit(&bt_mesh.lpn.timer,delay); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +_Bool sub_update(u8_t op) + +{ + bt_mesh_net_conflict9 *pbVar1; + uint bit; + u16_t uVar2; + undefined3 in_register_00002029; + USItype x; + int iVar3; + int iVar4; + u8_t uStack112; + undefined auStack111 [3]; + bt_mesh_ctl_friend_sub req; + bt_mesh_net_tx_conflict tx; + bt_mesh_msg_ctx ctx; + + x = atomic_get(bt_mesh.lpn.added); + memset(&ctx.app_idx,0,0x12); + tx.ctx = (bt_mesh_msg_ctx *)0x0; + tx.src = bt_mesh.sub[0].net_idx; + tx._10_2_ = 0xffff; + ctx.net_idx = bt_mesh.lpn.frnd; + stack0xffffff9c = bt_mesh.sub; + tx.sub = (bt_mesh_subnet *)&tx.src; + uVar2 = bt_mesh_primary_addr(); + tx.ctx = (bt_mesh_msg_ctx *)((uint)tx.ctx & 0xfe000000 | (uint)uVar2 | 0x1090000); + if (bt_mesh.lpn.sent_req == '\0') { + iVar4 = 0; + pbVar1 = &bt_mesh; + bit = 0; + do { + if ((pbVar1->lpn).groups[0] != 0) { + if (CONCAT31(in_register_00002029,op) == 7) { + iVar3 = atomic_test_bit(bt_mesh.lpn.added,bit); + if (iVar3 == 0) { +LAB_2303b3bc: + iVar3 = __popcountsi2(x); + if ((uint)bt_mesh.lpn.queue_size <= (uint)(iVar3 + iVar4)) { + printf("Friend Queue Size exceeded\r\n"); + break; + } + uVar2 = (pbVar1->lpn).groups[0]; + iVar3 = iVar4 * 2; + iVar4 = iVar4 + 1; + auStack111[iVar3] = (char)(uVar2 >> 8); + auStack111[iVar3 + 1] = (char)uVar2; + atomic_or(bt_mesh.lpn.pending,1 << (bit & 0x1f)); + if (iVar4 == 5) { + iVar4 = 5; + goto LAB_2303b442; + } + } + } + else { + iVar3 = atomic_test_bit(bt_mesh.lpn.to_remove,bit); + if (iVar3 != 0) goto LAB_2303b3bc; + } + } + bit = bit + 1; + pbVar1 = (bt_mesh_net_conflict9 *)((int)&pbVar1->iv_index + 2); + } while (bit != 8); + if (iVar4 != 0) { +LAB_2303b442: + uStack112 = bt_mesh.lpn.xact_next; + bt_mesh.lpn.xact_next = bt_mesh.lpn.xact_next + '\x01'; + iVar4 = bt_mesh_ctl_send((bt_mesh_net_tx_conflict7 *)((int)req.addr_list + 7),op,&uStack112, + iVar4 * 2 + 1,(u64_t *)0x0,&req_sent_cb,(void *)0x0); + if (-1 < iVar4) { + bt_mesh.lpn.xact_pending = uStack112; + bt_mesh.lpn.sent_req = op; + return true; + } + } + group_zero(bt_mesh.lpn.pending); + } + return false; +} + + + +void friend_response_received(void) + +{ + if (bt_mesh.lpn.sent_req == '\x01') { + bt_mesh.lpn._12_1_ = bt_mesh.lpn._12_1_ ^ 8; + } + k_delayed_work_cancel(&bt_mesh.lpn.timer); + bt_mesh_scan_disable(); + bt_mesh.lpn.state = TID_6; + bt_mesh.lpn.sent_req = '\0'; + bt_mesh.lpn.req_attempts = '\0'; + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int send_friend_req(void) + +{ + u16_t uVar1; + bt_mesh_comp *pbVar2; + int iVar3; + undefined4 local_40; + bt_mesh_ctl_friend_req req; + bt_mesh_net_tx_conflict tx; + bt_mesh_msg_ctx ctx; + + pbVar2 = bt_mesh_comp_get(); + memset(&ctx.app_idx,0,0x12); + tx.ctx = (bt_mesh_msg_ctx *)0x0; + tx.src = bt_mesh.sub[0].net_idx; + tx._10_2_ = 0xffff; + ctx.net_idx = 0xfffd; + stack0xffffffcc = bt_mesh.sub; + tx.sub = (bt_mesh_subnet *)&tx.src; + uVar1 = bt_mesh_primary_addr(); + local_40 = 0x1006401; + req.criteria = ','; + tx.ctx = (bt_mesh_msg_ctx *)((uint)tx.ctx & 0xff000000 | (uint)uVar1 | 0x90000); + req.recv_delay = (u8_t)bt_mesh.lpn._16_4_; + req.poll_to[0] = (u8_t)((uint)bt_mesh.lpn._16_4_ >> 8); + req.poll_to[1] = (u8_t)pbVar2->elem_count; + req._4_2_ = bt_mesh.lpn.counter << 8 | bt_mesh.lpn.counter >> 8; + iVar3 = bt_mesh_ctl_send((bt_mesh_net_tx_conflict7 *)&req.lpn_counter,'\x03',&local_40,10, + (u64_t *)0x0,&friend_req_sent_cb,(void *)0x0); + return iVar3; +} + + + +void lpn_timeout(k_work *work) + +{ + u8_t op; + int iVar1; + _Bool disable; + uint32_t delay; + byte bVar2; + + op = bt_mesh.lpn.sent_req; + switch((uint)(byte)bt_mesh.lpn.state - 1 & 0xff) { + case 0: + disable = (_Bool)((byte)(bt_mesh.lpn._12_4_ >> 2) & 1); + goto LAB_2303b5d2; + case 1: + bt_mesh.lpn.state = shaStateError; + case 2: + send_friend_req(); + return; + case 3: + bt_mesh_scan_enable(); + k_delayed_work_submit(&bt_mesh.lpn.timer,(uint)bt_mesh.lpn.adv_duration + 1000); + bt_mesh.lpn.state = TID_5; + break; + case 4: + printf("No acceptable Friend Offers received\r\n"); + bt_mesh.lpn.sent_req = '\0'; + bt_mesh.lpn._12_4_ = + bt_mesh.lpn._12_4_ & 0xffff | (uint)(ushort)(bt_mesh.lpn.counter + 1) << 0x10; + bt_mesh.lpn.state = shaStateError; + delay = 8000; +LAB_2303b63a: + k_delayed_work_submit(&bt_mesh.lpn.timer,delay); + return; + case 5: + bVar2 = 2; + if (2999 < (int)((0x1ce8 - ((uint)bt_mesh.lpn.recv_win + (uint)bt_mesh.lpn.adv_duration + 100)) + * 4)) { + bVar2 = 4; + } + if (bt_mesh.lpn.req_attempts < bVar2) { + bt_mesh.lpn.sent_req = '\0'; + if (1 < op) { + sub_update(op); + return; + } + send_friend_poll(); + return; + } + printf("No response from Friend after %u retries\r\n"); + bt_mesh.lpn.req_attempts = '\0'; + goto LAB_2303b6ac; + case 6: + k_delayed_work_submit + (&bt_mesh.lpn.timer,(uint)bt_mesh.lpn.recv_win + (uint)bt_mesh.lpn.adv_duration + 10); + bt_mesh_scan_enable(); + bt_mesh.lpn.state = WPA_WPA2_IN_USE; + break; + case 7: + if ((bt_mesh.lpn._12_4_ & 0x10) != 0) { + printf("No response from Friend during ReceiveWindow\r\n"); + bt_mesh_scan_disable(); + bt_mesh.lpn.state = TID_6; + delay = 100; + goto LAB_2303b63a; + } + if (bt_mesh.lpn.req_attempts < 6) { + printf("Retrying first Friend Poll\r\n"); + bt_mesh.lpn.sent_req = '\0'; + iVar1 = send_friend_poll(); + if (iVar1 == 0) { + return; + } + } + printf("Timed out waiting for first Friend Update\r\n"); +LAB_2303b6ac: + disable = false; +LAB_2303b5d2: + clear_friendship(false,disable); + return; + } + return; +} + + + +s32_t poll_timeout(void) + +{ + _Bool _Var1; + undefined3 extraout_var; + int iVar2; + int iVar3; + + _Var1 = bt_mesh_tx_in_progress(); + if (CONCAT31(extraout_var,_Var1) == 0) { + iVar3 = (0x1ce8 - ((uint)bt_mesh.lpn.recv_win + (uint)bt_mesh.lpn.adv_duration + 100)) * 4; + iVar2 = bt_mesh.lpn.poll_timeout; + if ((bt_mesh.lpn.poll_timeout < iVar3) && + (iVar2 = bt_mesh.lpn.poll_timeout << 1, bt_mesh.lpn.poll_timeout = iVar2, iVar3 < iVar2)) { + iVar2 = iVar3; + bt_mesh.lpn.poll_timeout = iVar3; + } + } + else { + iVar2 = (0x1ce8 - ((uint)bt_mesh.lpn.recv_win + (uint)bt_mesh.lpn.adv_duration + 100)) * 4; + if (1000 < iVar2) { + iVar2 = 1000; + } + } + return iVar2; +} + + + +void bt_mesh_lpn_disable(_Bool force) + +{ + if (bt_mesh.lpn.state != shaSuccess) { + clear_friendship(force,true); + return; + } + return; +} + + + +int bt_mesh_lpn_set(_Bool enable) + +{ + _Bool _Var1; + undefined3 in_register_00002029; + int iVar2; + undefined3 extraout_var; + + iVar2 = CONCAT31(in_register_00002029,enable); + if (iVar2 == 0) { + if (bt_mesh.lpn.state == shaSuccess) { + return 0; + } + } + else { + if (bt_mesh.lpn.state != shaSuccess) { + return 0; + } + } + _Var1 = bt_mesh_is_provisioned(); + if (CONCAT31(extraout_var,_Var1) == 0) { + if (iVar2 == 0) { + bt_mesh.lpn.state = shaSuccess; + } + else { + bt_mesh.lpn.state = shaStateError; + } + } + else { + if (iVar2 == 0) { + bt_mesh_lpn_disable(false); + } + else { + bt_mesh.lpn.state = shaStateError; + send_friend_req(); + } + } + return 0; +} + + + +void bt_mesh_lpn_msg_received(bt_mesh_net_rx_conflict *rx) + +{ + if (bt_mesh.lpn.state == shaInputTooLong) { + k_delayed_work_submit(&bt_mesh.lpn.timer,0); + return; + } + if (bt_mesh.lpn.sent_req != '\x01') { + printf("Unexpected message withouth a preceding Poll\r\n"); + return; + } + friend_response_received(); + send_friend_poll(); + return; +} + + + +int bt_mesh_lpn_friend_offer(bt_mesh_net_rx_conflict *rx,net_buf_simple *buf) + +{ + u8_t *puVar1; + char *fmt; + friend_cred *cred; + int iVar2; + + if (buf->len < 6) { + fmt = "Too short Friend Offer\r\n"; + } + else { + if (bt_mesh.lpn.state != TID_5) { + printf("Ignoring unexpected Friend Offer\r\n"); + return 0; + } + puVar1 = buf->data; + if (*puVar1 != '\0') { + bt_mesh.lpn.frnd = (rx->ctx).addr; + cred = friend_cred_create(rx->sub,bt_mesh.lpn.frnd,bt_mesh.lpn.counter, + *(ushort *)(puVar1 + 4) >> 8 | *(ushort *)(puVar1 + 4) << 8); + if (cred == (friend_cred *)0x0) { + bt_mesh.lpn.frnd = 0; + return -0xc; + } + k_delayed_work_cancel(&bt_mesh.lpn.timer); + bt_mesh.lpn.recv_win = *puVar1; + bt_mesh.lpn.queue_size = puVar1[1]; + iVar2 = send_friend_poll(); + if (iVar2 != 0) { + friend_cred_clear(cred); + bt_mesh.lpn.frnd = 0; + bt_mesh.lpn.recv_win = '\0'; + bt_mesh.lpn.queue_size = '\0'; + return iVar2; + } + bt_mesh.lpn.counter = bt_mesh.lpn.counter + 1; + return 0; + } + fmt = "Prohibited ReceiveWindow value\r\n"; + } + printf(fmt); + return -0x16; +} + + + +int bt_mesh_lpn_friend_clear_cfm(bt_mesh_net_rx_conflict *rx,net_buf_simple *buf) + +{ + ushort uVar1; + ushort uVar2; + u16_t uVar3; + char *fmt; + undefined2 extraout_var; + + if (buf->len < 4) { + printf("Too short Friend Clear Confirm\r\n"); + return -0x16; + } + if (bt_mesh.lpn.state == shaNull) { + uVar1 = *(ushort *)buf->data; + uVar2 = *(ushort *)(buf->data + 1); + uVar3 = bt_mesh_primary_addr(); + if ((CONCAT22(extraout_var,uVar3) == (((uint)uVar1 & 0xff) << 8 | (uint)(uVar1 >> 8))) && + (bt_mesh.lpn._12_4_ >> 0x10 == (((uint)uVar2 & 0xff) << 8 | (uint)(uVar2 >> 8)))) { + bt_mesh.lpn._12_4_ = bt_mesh.lpn._12_4_ | 0x20; + clear_friendship(false,(_Bool)((byte)(bt_mesh.lpn._12_4_ >> 2) & 1)); + return 0; + } + fmt = "Invalid parameters in Friend Clear Confirm\r\n"; + } + else { + fmt = "Ignoring unexpected Friend Clear Confirm\r\n"; + } + printf(fmt); + return 0; +} + + + +void bt_mesh_lpn_group_add(u16_t group) + +{ + ushort uVar1; + undefined2 in_register_0000202a; + uint uVar2; + bt_mesh_net_conflict9 *pbVar3; + u16_t *puVar4; + + pbVar3 = &bt_mesh; + uVar2 = 0; + puVar4 = (u16_t *)0x0; + do { + if (uVar2 == 8) { + if (puVar4 == (u16_t *)0x0) { + printf("Friend Subscription List exceeded!\r\n"); + } + else { + *puVar4 = group; + bt_mesh.lpn._12_4_ = bt_mesh.lpn._12_4_ | 1; + } +LAB_2303ba22: + if (((bt_mesh.lpn._12_4_ >> 4 & 1) != 0) && (bt_mesh.lpn.sent_req == '\0')) { + sub_update('\a'); + return; + } + return; + } + uVar1 = (pbVar3->lpn).groups[0]; + if (CONCAT22(in_register_0000202a,group) == (uint)uVar1) { + atomic_and(bt_mesh.lpn.to_remove,~(1 << (uVar2 & 0x1f))); + goto LAB_2303ba22; + } + if ((puVar4 == (u16_t *)0x0) && (uVar1 == 0)) { + puVar4 = (pbVar3->lpn).groups; + } + uVar2 = uVar2 + 1; + pbVar3 = (bt_mesh_net_conflict9 *)((int)&pbVar3->iv_index + 2); + } while( true ); +} + + + +void bt_mesh_lpn_group_del(u16_t *groups,size_t group_count) + +{ + u16_t uVar1; + uint bit; + int iVar2; + bt_mesh_net_conflict9 *pbVar3; + u16_t *puVar4; + + puVar4 = groups + group_count; + while (groups != puVar4) { + uVar1 = *groups; + if (uVar1 != 0) { + pbVar3 = &bt_mesh; + bit = 0; + do { + if ((pbVar3->lpn).groups[0] == uVar1) { + iVar2 = atomic_test_bit(bt_mesh.lpn.added,bit); + if ((iVar2 == 0) && (iVar2 = atomic_test_bit(bt_mesh.lpn.pending,bit), iVar2 == 0)) { + (pbVar3->lpn).groups[0] = 0; + } + else { + atomic_or(bt_mesh.lpn.to_remove,1 << (bit & 0x1f)); + bt_mesh.lpn._12_4_ = bt_mesh.lpn._12_4_ | 1; + } + } + bit = bit + 1; + pbVar3 = (bt_mesh_net_conflict9 *)((int)&pbVar3->iv_index + 2); + } while (bit != 8); + } + groups = groups + 1; + } + if (((bt_mesh.lpn._12_4_ >> 4 & 1) != 0) && (bt_mesh.lpn.sent_req == '\0')) { + sub_update('\b'); + return; + } + return; +} + + + +int bt_mesh_lpn_friend_sub_cfm(bt_mesh_net_rx_conflict *rx,net_buf_simple *buf) + +{ + int bit; + char *fmt; + atomic_val_t value; + uint32_t delay; + uint uVar1; + int iVar2; + + if (buf->len == 0) { + printf("Too short Friend Subscription Confirm\r\n"); + return -0x16; + } + if (bt_mesh.lpn.sent_req == '\0') { + fmt = "No pending subscription list message\r\n"; +LAB_2303bba4: + printf(fmt); + return 0; + } + if (*buf->data != bt_mesh.lpn.xact_pending) { + printf("Transaction mismatch (0x%02x != 0x%02x)\r\n"); + return 0; + } + if (bt_mesh.lpn.sent_req == '\a') { + value = atomic_get(bt_mesh.lpn.pending); + atomic_or(bt_mesh.lpn.added,value); + group_zero(bt_mesh.lpn.pending); + } + else { + if (bt_mesh.lpn.sent_req != '\b') { + fmt = "Unexpected Friend Subscription Confirm\r\n"; + goto LAB_2303bba4; + } + uVar1 = atomic_get(bt_mesh.lpn.pending); + atomic_and(bt_mesh.lpn.added,~uVar1); + bit = 0; + do { + iVar2 = atomic_test_and_clear_bit(bt_mesh.lpn.pending,bit); + if ((iVar2 != 0) && (iVar2 = atomic_test_and_clear_bit(bt_mesh.lpn.to_remove,bit), iVar2 != 0) + ) { + bt_mesh.lpn.groups[bit] = 0; + } + bit = bit + 1; + } while (bit != 8); + } + friend_response_received(); + if ((bt_mesh.lpn._12_1_ & 1) != 0) { + sub_update('\a'); + sub_update('\b'); + if (bt_mesh.lpn.sent_req == '\0') { + bt_mesh.lpn._12_1_ = bt_mesh.lpn._12_1_ & 0xfe; + } + } + if ((bt_mesh.lpn._12_1_ & 2) != 0) { + send_friend_poll(); + } + if (bt_mesh.lpn.sent_req == '\0') { + delay = poll_timeout(); + k_delayed_work_submit(&bt_mesh.lpn.timer,delay); + return 0; + } + return 0; +} + + + +int bt_mesh_lpn_friend_update(bt_mesh_net_rx_conflict *rx,net_buf_simple *buf) + +{ + int iVar1; + byte *pbVar2; + _Bool _Var3; + char *fmt; + uint uVar4; + bt_mesh_cfg_srv *pbVar5; + undefined3 extraout_var; + uint32_t delay; + bt_mesh_subnet *sub; + + if (buf->len < 6) { + fmt = "Too short Friend Update\r\n"; +LAB_2303bcbe: + printf(fmt); + iVar1 = -0x16; + } + else { + if (bt_mesh.lpn.sent_req == '\x01') { + sub = rx->sub; + if ((sub->kr_phase != '\x02') || ((*(byte *)&rx->field_0x20 & 2) != 0)) { + pbVar2 = buf->data; + iVar1 = atomic_test_bit(bt_mesh.flags,3); + if ((iVar1 != 0) && + (uVar4 = atomic_test_bit(bt_mesh.flags,2), uVar4 == ((uint)(*pbVar2 >> 1) & 1))) { + bt_mesh_beacon_ivu_initiator(false); + } + if ((bt_mesh.lpn._12_1_ & 0x10) != 0) { +LAB_2303bdb0: + friend_response_received(); + uVar4 = *(uint *)(pbVar2 + 1); + _Var3 = bt_mesh_kr_update(sub,*pbVar2 & 1, + (_Bool)((byte)(*(uint *)&rx->field_0x20 >> 1) & 1)); + if (CONCAT31(extraout_var,_Var3) != 0) { + bt_mesh_net_beacon_update(sub); + } + bt_mesh_net_iv_update + (uVar4 >> 0x18 | uVar4 << 0x18 | uVar4 >> 8 & 0xff00 | (uVar4 & 0xff00) << 8, + (_Bool)(*pbVar2 >> 1 & 1)); + if ((bt_mesh.lpn._12_1_ & 1) != 0) { + sub_update('\a'); + sub_update('\b'); + if (bt_mesh.lpn.sent_req == '\0') { + bt_mesh.lpn._12_1_ = bt_mesh.lpn._12_1_ & 0xfe; + } + } + if (pbVar2[5] != 0) { + send_friend_poll(); + } + if (bt_mesh.lpn.sent_req != '\0') { + return 0; + } + delay = poll_timeout(); + k_delayed_work_submit(&bt_mesh.lpn.timer,delay); + return 0; + } + pbVar5 = bt_mesh_cfg_get(); + if ((*(byte *)&rx->field_0x20 & 4) != 0) { + bt_mesh.lpn._12_1_ = bt_mesh.lpn._12_1_ | 0x10; + if (((pbVar5->hb_pub).feat & 8) != 0) { + bt_mesh_heartbeat_send(); + } + if (lpn_cb != (anon_subr_void_u16_t__Bool_conflict *)0x0) { + (*lpn_cb)(bt_mesh.lpn.frnd,true); + } + bt_mesh.lpn.poll_timeout = + (0x1ce8 - ((uint)bt_mesh.lpn.recv_win + (uint)bt_mesh.lpn.adv_duration + 100)) * 4; + goto LAB_2303bdb0; + } + fmt = "Friend Update with wrong credentials\r\n"; + goto LAB_2303bcbe; + } + fmt = "Ignoring Phase 2 KR Update secured using old key\r\n"; + } + else { + fmt = "Unexpected friend update\r\n"; + } + printf(fmt); + iVar1 = 0; + } + return iVar1; +} + + + +int bt_mesh_lpn_poll(void) + +{ + int iVar1; + + if ((bt_mesh.lpn._12_1_ & 0x10) != 0) { + iVar1 = send_friend_poll(); + return iVar1; + } + return -0xb; +} + + + +void bt_mesh_lpn_set_cb(anon_subr_void_u16_t__Bool_conflict *cb) + +{ + lpn_cb = cb; + return; +} + + + +int bt_mesh_lpn_init(void) + +{ + k_delayed_work_init(&bt_mesh.lpn.timer,lpn_timeout); + if (bt_mesh.lpn.state == shaStateError) { + bt_mesh_scan_enable(); + send_friend_req(); + } + else { + bt_mesh_scan_enable(); + } + return 0; +} + + + +void gen_onoff_set(bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + bt_mesh_model_gen_cb *pbVar1; + u8_t uVar2; + u8_t tid; + _Bool _Var3; + undefined3 extraout_var; + undefined3 extraout_var_00; + net_buf_simple *in_a2; + undefined auStack40 [4]; + int64_t recv_time; + + if (ctx == (bt_mesh_msg_ctx *)0x0) { + printf("%s, Invalid model user_data\r\n","gen_onoff_set"); + } + else { + uVar2 = net_buf_simple_pull_u8(in_a2); + _uVar2 = CONCAT31(extraout_var,uVar2); + if (_uVar2 < 2) { + tid = net_buf_simple_pull_u8(in_a2); + _Var3 = bt_mesh_srv_check_rcvd_msg_with_last + (tid,buf->len,buf->size,(int64_t *)auStack40, + (bt_mesh_last_rcvd_msg *)&ctx->recv_rssi); + pbVar1 = gen_cb; + if (CONCAT31(extraout_var_00,_Var3) == 0) { + if ((uint)*(byte *)&ctx->addr != _uVar2) { + *(u8_t *)&ctx->addr = uVar2; + if (pbVar1 != (bt_mesh_model_gen_cb *)0x0) { + (*pbVar1)(uVar2); + } + } + bt_mesh_srv_update_last_rcvd_msg + ((bt_mesh_last_rcvd_msg *)&ctx->recv_rssi,tid,buf->len,buf->size); + } + } + else { + printf("%s, Invalid OnOff value 0x%02x\r\n","gen_onoff_set",_uVar2); + } + } + return; +} + + + +void gen_onoff_set_unack(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + gen_onoff_set((bt_mesh_msg_ctx *)model->user_data,(net_buf_simple *)ctx); + return; +} + + + +// WARNING: Variable defined which should be unmapped: msg + +void send_onoff_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx) + +{ + int iVar1; + void *pvVar2; + u8_t auStack40 [4]; + u8_t net_buf_data_msg [9]; + net_buf_simple msg; + + register0x0000203c = auStack40; + pvVar2 = model->user_data; + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 8),0x8204); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 8),*(u8_t *)((int)pvVar2 + 4)); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 8), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar1 != 0) { + printf("%s, Unable to send onoff status\r\n","send_onoff_status"); + } + return; +} + + + +void gen_onoff_set_with_ack(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + gen_onoff_set((bt_mesh_msg_ctx *)model->user_data,(net_buf_simple *)ctx); + send_onoff_status(model,ctx); + return; +} + + + +void gen_onoff_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + if (model->user_data == (void *)0x0) { + printf("%s, Invalid model user_data\r\n","gen_onoff_get"); + return; + } + send_onoff_status(model,ctx); + return; +} + + + +void publish_start(u16_t duration,int err,void *user_data) + +{ + int iVar1; + u32_t_conflict uVar2; + + if (err != 0) { + printf("Failed to publish: err %d\r\n"); + return; + } + iVar1 = *(int *)((int)user_data + 8); + if ((*(uint *)(iVar1 + 0xc) & 7) == ((uint)*(byte *)(iVar1 + 9) & 7)) { + uVar2 = k_uptime_get_32(); + *(u32_t_conflict *)(iVar1 + 0x10) = uVar2; + } + return; +} + + + +int model_send(bt_mesh_model *model,bt_mesh_net_tx_conflict2 *tx,_Bool implicit_bind, + net_buf_simple *msg,bt_mesh_send_cb *cb,void *cb_data) + +{ + u16_t uVar1; + _Bool _Var2; + undefined3 extraout_var; + int iVar3; + size_t sVar4; + undefined3 in_register_00002031; + + _Var2 = bt_mesh_is_provisioned(); + if (CONCAT31(extraout_var,_Var2) == 0) { + printf("Local node is not yet provisioned\r\n"); + iVar3 = -0xb; + } + else { + sVar4 = net_buf_simple_tailroom(msg); + if (sVar4 < 4) { + printf("Not enough tailroom for TransMIC\r\n"); + } + else { + if (0x44 < msg->len) { + printf("Too big message\r\n"); + return -0x24; + } + if (((CONCAT31(in_register_00002031,implicit_bind) != 0) || + (uVar1 = tx->ctx->app_idx, model->keys[0] == uVar1)) || (model->keys[1] == uVar1)) { + iVar3 = bt_mesh_trans_send((bt_mesh_net_tx_conflict7 *)tx,msg,cb,cb_data); + return iVar3; + } + printf("Model not bound to AppKey 0x%04x\r\n"); + } + iVar3 = -0x16; + } + return iVar3; +} + + + +void mod_init(bt_mesh_model *mod,bt_mesh_elem *elem,_Bool vnd,_Bool primary,void *user_data) + +{ + undefined3 in_register_00002031; + + if (mod->pub != (bt_mesh_model_pub *)0x0) { + mod->pub->mod = mod; + k_delayed_work_init(&mod->pub->timer,mod_publish); + } + *(undefined4 *)mod->keys = 0xffffffff; + mod->elem_idx = (u8_t)((int)((int)elem - (int)dev_comp->elem) >> 4); + if (CONCAT31(in_register_00002031,vnd) == 0) { + mod->mod_idx = (char)((int)((int)mod - (int)elem->models) >> 2) * -0x49; + if (*(short *)&mod->field_0 == 0) { + bt_mesh_cfg_srv_init(mod,primary); + } + if (*(short *)&mod->field_0 == 2) { + bt_mesh_health_srv_init(mod,primary); + return; + } + } + else { + mod->mod_idx = (char)((int)((int)mod - (int)elem->vnd_models) >> 2) * -0x49; + } + return; +} + + + +void bt_mesh_model_foreach + (anon_subr_void_bt_mesh_model_ptr_bt_mesh_elem_ptr__Bool__Bool_void_ptr *func, + void *user_data) + +{ + bt_mesh_elem *pbVar1; + uint uVar2; + int iVar3; + + uVar2 = 0; + while (uVar2 < dev_comp->elem_count) { + pbVar1 = dev_comp->elem + uVar2; + iVar3 = 0; + while (iVar3 < (int)(uint)pbVar1->model_count) { + (*func)(pbVar1->models + iVar3,pbVar1,false,(_Bool)(uVar2 == 0),user_data); + iVar3 = iVar3 + 1; + } + iVar3 = 0; + while (iVar3 < (int)(uint)pbVar1->vnd_model_count) { + (*func)(pbVar1->vnd_models + iVar3,pbVar1,true,(_Bool)(uVar2 == 0),user_data); + iVar3 = iVar3 + 1; + } + uVar2 = uVar2 + 1; + } + return; +} + + + +s32_t bt_mesh_model_pub_period_get(bt_mesh_model *mod) + +{ + byte bVar1; + uint uVar2; + s32_t sVar3; + int iVar4; + bt_mesh_model_pub *pbVar5; + + pbVar5 = mod->pub; + if (pbVar5 == (bt_mesh_model_pub *)0x0) { + sVar3 = 0; + } + else { + uVar2 = (uint)pbVar5->period; + bVar1 = pbVar5->period >> 6; + if (bVar1 == 2) { + uVar2 = uVar2 & 0x3f; + iVar4 = 10000; + } + else { + if (bVar1 == 3) { + uVar2 = uVar2 & 0x3f; + iVar4 = 600000; + } + else { + if (bVar1 == 1) { + uVar2 = uVar2 & 0x3f; + iVar4 = 1000; + } + else { + iVar4 = 100; + } + } + } + sVar3 = uVar2 * iVar4; + if ((*(byte *)&pbVar5->field_0xb & 0x20) != 0) { + return sVar3 >> ((uint)*(byte *)&pbVar5->field_0xb & 0xf); + } + } + return sVar3; +} + + + +void publish_sent(int err,void *user_data) + +{ + uint uVar1; + u32_t_conflict uVar2; + uint32_t delay; + int iVar3; + + iVar3 = *(int *)((int)user_data + 8); + if ((*(byte *)(iVar3 + 0xc) & 7) == 0) { + uVar1 = bt_mesh_model_pub_period_get((bt_mesh_model *)user_data); + if (uVar1 == 0) { + return; + } + uVar2 = k_uptime_get_32(); + if (uVar1 < uVar2 - *(int *)(iVar3 + 0x10)) { + printf("Publication sending took longer than the period\r\n"); + delay = 1; + } + else { + delay = (*(int *)(iVar3 + 0x10) + uVar1) - uVar2; + if (delay == 0) { + return; + } + } + } + else { + delay = ((uint)(*(byte *)(iVar3 + 9) >> 3) + 1) * 0x32; + } + k_delayed_work_submit((k_delayed_work *)(*(int *)((int)user_data + 8) + 0x1c),delay); + return; +} + + + +bt_mesh_elem * bt_mesh_model_elem(bt_mesh_model *mod) + +{ + return dev_comp->elem + mod->elem_idx; +} + + + +int bt_mesh_comp_register(bt_mesh_comp *comp) + +{ + if (comp->elem_count != 0) { + dev_comp = comp; + bt_mesh_model_foreach(mod_init,(void *)0x0); + return 0; + } + return -0x16; +} + + + +void bt_mesh_comp_provision(u16_t addr) + +{ + bt_mesh_comp *pbVar1; + undefined2 in_register_0000202a; + uint uVar2; + + pbVar1 = dev_comp; + uVar2 = 0; + dev_primary_addr = addr; + while (uVar2 < pbVar1->elem_count) { + pbVar1->elem[uVar2].addr = + (u16_t)((CONCAT22(in_register_0000202a,addr) + uVar2) * 0x10000 >> 0x10); + uVar2 = uVar2 + 1; + } + return; +} + + + +void bt_mesh_comp_unprovision(void) + +{ + dev_primary_addr = 0; + bt_mesh_model_foreach(mod_init,(void *)0x0); + return; +} + + + +u16_t bt_mesh_primary_addr(void) + +{ + return dev_primary_addr; +} + + + +u16_t * bt_mesh_model_find_group(bt_mesh_model *mod,u16_t addr) + +{ + undefined2 in_register_0000202e; + int iVar1; + + if ((uint)mod->groups[0] == CONCAT22(in_register_0000202e,addr)) { + iVar1 = 0; + } + else { + if ((uint)mod->groups[1] != CONCAT22(in_register_0000202e,addr)) { + return (u16_t *)0x0; + } + iVar1 = 1; + } + return (u16_t *)(anon_union_for_field_0 *)((int)&mod->field_0 + (iVar1 + 8) * 2); +} + + + +bt_mesh_elem * bt_mesh_elem_find(u16_t addr) + +{ + undefined2 in_register_0000202a; + uint uVar1; + size_t sVar2; + int iVar3; + bt_mesh_elem *pbVar4; + + uVar1 = CONCAT22(in_register_0000202a,addr); + sVar2 = 0; + do { + if (sVar2 == dev_comp->elem_count) { + return (bt_mesh_elem *)0x0; + } + pbVar4 = dev_comp->elem + sVar2; + if ((uVar1 ^ 0x8000) < 0x7f01) { + iVar3 = 0; + while (iVar3 < (int)(uint)pbVar4->model_count) { + if ((uint)pbVar4->models[iVar3].groups[0] == uVar1) { + return pbVar4; + } + if ((uint)pbVar4->models[iVar3].groups[1] == uVar1) { + return pbVar4; + } + iVar3 = iVar3 + 1; + } + iVar3 = 0; + while (iVar3 < (int)(uint)pbVar4->vnd_model_count) { + if ((uint)pbVar4->vnd_models[iVar3].groups[0] == uVar1) { + return pbVar4; + } + if ((uint)pbVar4->vnd_models[iVar3].groups[1] == uVar1) { + return pbVar4; + } + iVar3 = iVar3 + 1; + } + } + else { + if ((uint)pbVar4->addr == uVar1) { + return pbVar4; + } + } + sVar2 = sVar2 + 1; + } while( true ); +} + + + +u8_t bt_mesh_elem_count(void) + +{ + return *(u8_t *)&dev_comp->elem_count; +} + + + +_Bool bt_mesh_fixed_group_match(u16_t addr) + +{ + u8_t uVar1; + undefined2 in_register_0000202a; + uint uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + + uVar2 = CONCAT22(in_register_0000202a,addr); + if (uVar2 == 0xfffe) { + uVar1 = bt_mesh_relay_get(); + _uVar1 = CONCAT31(extraout_var_00,uVar1); + } + else { + if (0xfffe < uVar2) { + return true; + } + if (uVar2 != 0xfffd) { + return false; + } + uVar1 = bt_mesh_friend_get(); + _uVar1 = CONCAT31(extraout_var,uVar1); + } + return (_Bool)(_uVar1 == 1); +} + + + +void bt_mesh_model_recv(bt_mesh_net_rx_conflict2 *rx,net_buf_simple *buf) + +{ + ushort uVar1; + byte bVar2; + bt_mesh_model *pbVar3; + u8_t uVar4; + _Bool _Var5; + u16_t addr; + char *fmt; + undefined3 extraout_var; + undefined2 extraout_var_02; + undefined3 extraout_var_00; + undefined2 extraout_var_03; + undefined3 extraout_var_01; + size_t sVar6; + u8_t uVar7; + uint uVar8; + bt_mesh_elem *pbVar9; + bt_mesh_model_op *pbVar10; + uint uVar11; + + bVar2 = *buf->data >> 6; + if (bVar2 == 2) { + if (buf->len < 2) { + fmt = "Too short payload for 2-octet OpCode\r\n"; + goto LAB_2303c4f2; + } + addr = net_buf_simple_pull_be16(buf); + uVar8 = CONCAT22(extraout_var_02,addr); + } + else { + if (bVar2 == 3) { + if (buf->len < 3) { + fmt = "Too short payload for 3-octet OpCode\r\n"; + goto LAB_2303c4f2; + } + uVar4 = net_buf_simple_pull_u8(buf); + addr = net_buf_simple_pull_le16(buf); + uVar8 = CONCAT31(extraout_var_00,uVar4) << 0x10 | CONCAT22(extraout_var_03,addr); + } + else { + if (*buf->data == 0x7f) { + fmt = "Ignoring RFU OpCode\r\n"; +LAB_2303c4f2: + printf(fmt); + printf("Unable to decode OpCode\r\n"); + return; + } + uVar4 = net_buf_simple_pull_u8(buf); + uVar8 = CONCAT31(extraout_var,uVar4); + } + } + uVar11 = 0; + do { + if (dev_comp->elem_count <= uVar11) { + return; + } + addr = (rx->ctx).recv_dst; + pbVar9 = dev_comp->elem + uVar11; + if ((short)addr < 1) { + if (((addr ^ 0x8000) < 0x7f01) || + ((uVar11 == 0 && + (_Var5 = bt_mesh_fixed_group_match(addr), CONCAT31(extraout_var_01,_Var5) != 0)))) + goto LAB_2303c5ca; + } + else { + if (pbVar9->addr == addr) { +LAB_2303c5ca: + if (uVar8 < 0x10000) { + pbVar3 = pbVar9->models; + uVar4 = pbVar9->model_count; + } + else { + pbVar3 = pbVar9->vnd_models; + uVar4 = pbVar9->vnd_model_count; + } + uVar1 = (rx->ctx).recv_dst; + addr = (rx->ctx).app_idx; + uVar7 = '\0'; + while (uVar4 != uVar7) { + if ((((0x7f00 < (uVar1 ^ 0x8000)) || (pbVar3->groups[0] == uVar1)) || + (pbVar3->groups[1] == uVar1)) && + ((pbVar3->keys[0] == addr || (pbVar3->keys[1] == addr)))) { + pbVar10 = pbVar3->op; + while (pbVar10->func != + (anon_subr_void_bt_mesh_model_ptr_bt_mesh_msg_ctx_ptr_net_buf_simple_ptr_for_func + *)0x0) { + if (pbVar10->opcode == uVar8) { + if ((uint)buf->len < pbVar10->min_len) { + printf("Too short message for OpCode 0x%08x\r\n",uVar8); + } + else { + (rx->ctx).srv_send = true; + (rx->ctx).recv_op = uVar8; + (rx->ctx).model = pbVar3; + sVar6 = net_buf_simple_headroom(buf); + addr = buf->len; + (*pbVar10->func)(pbVar3,&rx->ctx,buf); + buf->data = buf->__buf + (sVar6 & 0xffff); + buf->len = addr; + } + goto LAB_2303c5ea; + } + pbVar10 = pbVar10 + 1; + } + } + uVar7 = uVar7 + '\x01'; + pbVar3 = pbVar3 + 1; + } + } + } +LAB_2303c5ea: + uVar11 = uVar11 + 1; + } while( true ); +} + + + +void bt_mesh_model_msg_init(net_buf_simple *msg,u32_t_conflict opcode) + +{ + if (msg->__buf == (u8_t *)0x0) { + *(net_buf_simple **)&msg->__buf = msg + 1; + } + msg->len = 0; + msg->data = msg->__buf; + if (opcode < 0x100) { + net_buf_simple_add_u8(msg,(u8_t)opcode); + return; + } + if (opcode < 0x10000) { + net_buf_simple_add_be16(msg,(u16_t)opcode); + return; + } + net_buf_simple_add_u8(msg,(u8_t)(opcode >> 0x10)); + net_buf_simple_add_le16(msg,(u16_t)opcode); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bt_mesh_model_send(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *msg, + bt_mesh_send_cb *cb,void *cb_data) + +{ + u8_t uVar1; + bt_mesh_elem *pbVar2; + int iVar3; + bt_mesh_subnet *pbStack28; + bt_mesh_net_tx_conflict2 tx; + + pbStack28 = (bt_mesh_subnet *)0x0; + tx.sub = (bt_mesh_subnet *)0x0; + tx.ctx = (bt_mesh_msg_ctx *)0x0; + pbStack28 = bt_mesh_subnet_get(ctx->net_idx); + tx.sub = (bt_mesh_subnet *)ctx; + pbVar2 = bt_mesh_model_elem(model); + tx.ctx = (bt_mesh_msg_ctx *)((uint)tx.ctx & 0xffff0000 | (uint)pbVar2->addr); + uVar1 = bt_mesh_net_transmit_get(); + tx.ctx._0_3_ = CONCAT12(uVar1,(u16_t)tx.ctx); + tx.ctx = (bt_mesh_msg_ctx *)((uint)tx.ctx & 0xff000000 | (uint)(uint3)tx.ctx); + iVar3 = model_send(model,(bt_mesh_net_tx_conflict2 *)&pbStack28,false,msg,cb,cb_data); + return iVar3; +} + + + +// WARNING: Variable defined which should be unmapped: net_buf_data_sdu +// WARNING: Could not reconcile some variable overlaps + +int bt_mesh_model_publish(bt_mesh_model *model) + +{ + bt_mesh_model_pub *pbVar1; + int err; + u8_t uVar2; + bt_mesh_elem *pbVar3; + bt_mesh_app_key *pbVar4; + _Bool *p_Stack136; + net_buf_simple sdu; + bt_mesh_net_tx_conflict2 tx; + bt_mesh_msg_ctx ctx; + u8_t net_buf_data_sdu [72]; + + p_Stack136 = &ctx.srv_send; + sdu.data = (u8_t *)0x480000; + sdu._4_4_ = &ctx.srv_send; + pbVar1 = model->pub; + tx.sub = (bt_mesh_subnet *)memset(&tx.src,0,0x18); + sdu.__buf = (u8_t *)0x0; + tx.ctx = (bt_mesh_msg_ctx *)0x0; + pbVar3 = bt_mesh_model_elem(model); + err = -0x23; + tx.ctx = (bt_mesh_msg_ctx *)((uint)tx.ctx & 0xffff0000 | (uint)pbVar3->addr); + uVar2 = bt_mesh_net_transmit_get(); + tx.ctx._0_3_ = CONCAT12(uVar2,tx.ctx._0_2_); + tx.ctx = (bt_mesh_msg_ctx *)((uint)tx.ctx & 0xff000000 | (uint)(uint3)tx.ctx); + if (pbVar1 != (bt_mesh_model_pub *)0x0) { + if ((pbVar1->addr == 0) || + (pbVar4 = bt_mesh_app_key_find(pbVar1->key), pbVar4 == (bt_mesh_app_key *)0x0)) { + err = -0x31; + } + else { + if (pbVar1->msg->len < 0x45) { + if ((*(byte *)&pbVar1->field_0xc & 7) != 0) { + printf("Clearing publish retransmit timer\r\n"); + k_delayed_work_cancel(&pbVar1->timer); + } + net_buf_simple_add_mem + ((net_buf_simple *)&p_Stack136,pbVar1->msg->data,(uint)pbVar1->msg->len); + ctx.net_idx = pbVar1->addr; + ctx.recv_dst._1_1_ = pbVar1->ttl; + tx._10_2_ = pbVar4->app_idx; + tx.src = pbVar4->net_idx; + tx.ctx = (bt_mesh_msg_ctx *) + ((uint)tx.ctx & 0xffffff | + (uint)(tx.ctx._3_1_ & 0xfe | (byte)((uint)*(undefined4 *)&pbVar1->ttl >> 0x1c) & 1) + << 0x18); + sdu.__buf = (u8_t *)bt_mesh_subnet_get(tx.src); + *(byte *)&pbVar1->field_0xc = *(byte *)&pbVar1->field_0xc & 0xf8 | pbVar1->retransmit & 7; + err = model_send(model,(bt_mesh_net_tx_conflict2 *)&sdu.__buf,true, + (net_buf_simple *)&p_Stack136,&pub_sent_cb,model); + if (err != 0) { + *(byte *)&pbVar1->field_0xc = *(byte *)&pbVar1->field_0xc & 0xf8; + publish_sent(err,model); + } + } + else { + printf("Message does not fit maximum SDU size\r\n"); + err = -0x24; + } + } + } + return err; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void mod_publish(k_work *work) + +{ + bt_mesh_model_pub *pbVar1; + u8_t uVar2; + uint32_t delay; + bt_mesh_elem *pbVar3; + bt_mesh_app_key *pbVar4; + int iVar5; + bt_mesh_model *mod; + _Bool *p_Stack152; + net_buf_simple sdu; + bt_mesh_net_tx_conflict2 tx; + bt_mesh_msg_ctx ctx; + u8_t net_buf_data_sdu [72]; + + mod = (bt_mesh_model *)work[-3].flags[0]; + delay = bt_mesh_model_pub_period_get(mod); + if ((*(byte *)work[-2].flags & 7) == 0) { + if (delay != 0) { + iVar5 = (*(code *)work[-1].flags[0])(mod,(code *)work[-1].flags[0]); + if (iVar5 == 0) { + iVar5 = bt_mesh_model_publish((bt_mesh_model *)work[-3].flags[0]); + if (iVar5 != 0) { + printf("Publishing failed (err %d)\r\n",iVar5); + } + } + else { + printf("Failed to update publication message\r\n"); + } + } + } + else { + p_Stack152 = &ctx.srv_send; + sdu.data = (u8_t *)0x480000; + sdu._4_4_ = &ctx.srv_send; + pbVar1 = mod->pub; + tx.sub = (bt_mesh_subnet *)memset(&tx.src,0,0x18); + ctx.net_idx = pbVar1->addr; + ctx.recv_dst._1_1_ = pbVar1->ttl; + sdu.__buf = (u8_t *)0x0; + tx.ctx = (bt_mesh_msg_ctx *)0x0; + pbVar3 = bt_mesh_model_elem(mod); + tx.ctx = (bt_mesh_msg_ctx *)((uint)tx.ctx & 0xffff0000 | (uint)pbVar3->addr); + uVar2 = bt_mesh_net_transmit_get(); + tx.ctx = (bt_mesh_msg_ctx *) + CONCAT13((byte)((uint)tx.ctx >> 0x18) & 0xfe | + (byte)((uint)*(undefined4 *)&pbVar1->ttl >> 0x1c) & 1, + CONCAT12(uVar2,tx.ctx._0_2_)); + pbVar4 = bt_mesh_app_key_find(pbVar1->key); + iVar5 = -0x31; + if (pbVar4 != (bt_mesh_app_key *)0x0) { + sdu.__buf = (u8_t *)bt_mesh_subnet_get(pbVar4->net_idx); + tx.src = pbVar4->net_idx; + tx._10_2_ = pbVar4->app_idx; + net_buf_simple_add_mem((net_buf_simple *)&p_Stack152,pbVar1->msg->data,(uint)pbVar1->msg->len) + ; + *(byte *)&pbVar1->field_0xc = + *(byte *)&pbVar1->field_0xc & 0xf8 | (char)*(undefined4 *)&pbVar1->field_0xc + 7U & 7; + iVar5 = bt_mesh_trans_send((bt_mesh_net_tx_conflict7 *)&sdu.__buf, + (net_buf_simple *)&p_Stack152,&pub_sent_cb,mod); + if (iVar5 == 0) { + return; + } + } + printf("Failed to retransmit (err %d)\r\n",iVar5); + *(byte *)work[-2].flags = *(byte *)work[-2].flags & 0xf8; + if (delay != 0) { + k_delayed_work_submit((k_delayed_work *)work,delay); + } + } + return; +} + + + +bt_mesh_model * bt_mesh_model_find_vnd(bt_mesh_elem *elem,u16_t company,u16_t id) + +{ + undefined2 in_register_0000202e; + undefined2 in_register_00002032; + uint uVar1; + bt_mesh_model *pbVar2; + + uVar1 = 0; + while( true ) { + if ((uint)elem->vnd_model_count <= (uVar1 & 0xff)) { + return (bt_mesh_model *)0x0; + } + pbVar2 = elem->vnd_models + uVar1; + if (((uint)*(ushort *)&pbVar2->field_0 == CONCAT22(in_register_0000202e,company)) && + ((uint)*(ushort *)((int)&pbVar2->field_0 + 2) == CONCAT22(in_register_00002032,id))) break; + uVar1 = uVar1 + 1; + } + return pbVar2; +} + + + +bt_mesh_model * bt_mesh_model_find(bt_mesh_elem *elem,u16_t id) + +{ + undefined2 in_register_0000202e; + uint uVar1; + bt_mesh_model *pbVar2; + + uVar1 = 0; + do { + if ((uint)elem->model_count <= (uVar1 & 0xff)) { + return (bt_mesh_model *)0x0; + } + pbVar2 = elem->models + uVar1; + uVar1 = uVar1 + 1; + } while ((uint)*(ushort *)&pbVar2->field_0 != CONCAT22(in_register_0000202e,id)); + return pbVar2; +} + + + +bt_mesh_comp * bt_mesh_comp_get(void) + +{ + return dev_comp; +} + + + +bt_mesh_adv_conflict2 * adv_alloc(int id) + +{ + return (bt_mesh_adv_conflict2 *)(adv_pool + id); +} + + + +// WARNING: Variable defined which should be unmapped: ad +// WARNING: Could not reconcile some variable overlaps + +void adv_thread(void *p1) + +{ + byte bVar1; + code **ppcVar2; + net_buf *buf; + char *fmt; + s32_t timeout; + int iVar3; + code **ppcVar4; + uint uVar5; + code *pcVar6; + int dur_ms; + undefined2 local_40; + u16_t uStack62; + bt_le_adv_param param; + bt_data ad; + + do { + buf = net_buf_get(&adv_queue,0); + while (buf == (net_buf *)0x0) { + timeout = bt_mesh_proxy_adv_start(); + buf = net_buf_get(&adv_queue,timeout); + bt_mesh_proxy_adv_stop(); + } + bVar1 = *(byte *)(*(int *)buf->user_data + 8); + if ((bVar1 & 4) == 0) { + net_buf_unref(buf); + } + else { + *(byte *)(*(int *)buf->user_data + 8) = bVar1 & 0xfb; + uVar5 = 0x14; + if (bt_dev.hci_version < 9) { + uVar5 = 100; + } + ppcVar4 = *(code ***)buf->user_data; + ppcVar2 = (code **)*ppcVar4; + pcVar6 = ppcVar4[1]; + iVar3 = (uint)(*(byte *)((int)ppcVar4 + 9) >> 3) + 1; + if (uVar5 <= (uint)(iVar3 * 10)) { + uVar5 = iVar3 * 10; + } + local_40 = 0; + param.interval_max._0_1_ = ")*+$\x1d"[(uint)ppcVar4[2] & 3]; + dur_ms = (((uint)*(byte *)((int)ppcVar4 + 9) & 7) + 1) * (uVar5 + 10) + 0x1e; + param.interval_max._1_1_ = (undefined)*(undefined2 *)((int)&buf->field_4 + 4); + uStack62 = (u16_t)((int)(uVar5 << 3) / 5); + param._0_2_ = uStack62; + iVar3 = bt_le_adv_start((bt_le_adv_param *)&local_40,(bt_data *)¶m.interval_max,1, + (bt_data *)0x0,0); + net_buf_unref(buf); + if ((ppcVar2 != (code **)0x0) && (*ppcVar2 != (code *)0x0)) { + (**ppcVar2)(dur_ms,iVar3,pcVar6); + } + if (iVar3 == 0) { + k_sleep(dur_ms); + iVar3 = bt_le_adv_stop(); + if ((ppcVar2 != (code **)0x0) && (ppcVar2[1] != (code *)0x0)) { + (*ppcVar2[1])(pcVar6); + } + if (iVar3 == 0) goto LAB_2303cb5a; + fmt = "Stopping advertising failed: err %d\r\n"; + } + else { + fmt = "Advertising failed: err %d\r\n"; + } + printf(fmt,iVar3); + } +LAB_2303cb5a: + k_yield(); + } while( true ); +} + + + +void bt_mesh_scan_cb(bt_addr_le_t *addr,s8_t rssi,u8_t adv_type,net_buf_simple *buf) + +{ + u16_t uVar1; + u8_t len; + undefined3 extraout_var; + size_t sVar2; + int iVar3; + undefined3 in_register_00002031; + + if (CONCAT31(in_register_00002031,adv_type) != 3) { + return; + } + while( true ) { + if (buf->len < 2) { + return; + } + len = net_buf_simple_pull_u8(buf); + _len = CONCAT31(extraout_var,len); + if (_len == 0) break; + if ((uint)buf->len < (_len & 0xffff)) { + printf("AD malformed\r\n"); + return; + } + sVar2 = net_buf_simple_headroom(buf); + uVar1 = buf->len; + len = net_buf_simple_pull_u8(buf); + iVar3 = CONCAT31(iVar3._1_3_,len); + buf->len = (short)_len - 1; + if (iVar3 == 0x2a) { + bt_mesh_net_recv(buf,rssi,BT_MESH_NET_IF_ADV); + } + else { + if (iVar3 == 0x2b) { + bt_mesh_beacon_recv(buf); + } + else { + if (iVar3 == 0x29) { + bt_mesh_pb_adv_recv(buf); + } + } + } + buf->len = uVar1; + buf->data = buf->__buf + (sVar2 & 0xffff); + net_buf_simple_pull(buf,_len); + } + return; +} + + + +net_buf * bt_mesh_adv_create_from_pool + (net_buf_pool *pool,bt_mesh_adv_alloc_t *get_id,bt_mesh_adv_type type,u8_t xmit, + s32_t timeout) + +{ + net_buf *buf; + atomic_val_t aVar1; + int iVar2; + bt_mesh_adv_conflict *__s; + + aVar1 = atomic_get(bt_mesh.flags); + if ((aVar1 >> 1 & 1U) == 0) { + buf = net_buf_alloc_fixed(pool,timeout); + if (buf != (net_buf *)0x0) { + iVar2 = net_buf_id(buf); + __s = (*get_id)(iVar2); + *(bt_mesh_adv_conflict **)buf->user_data = __s; + memset(__s,0,0xc); + __s->xmit = xmit; + *(byte *)&__s->field_0x8 = *(byte *)&__s->field_0x8 & 0xfc | type & 3; + } + } + else { + printf("Refusing to allocate buffer while suspended\r\n"); + buf = (net_buf *)0x0; + } + return buf; +} + + + +net_buf * bt_mesh_adv_create(bt_mesh_adv_type type,u8_t xmit,s32_t timeout) + +{ + net_buf *pnVar1; + + pnVar1 = bt_mesh_adv_create_from_pool(&adv_buf_pool,adv_alloc,type,xmit,timeout); + return pnVar1; +} + + + +void bt_mesh_adv_update(void) + +{ + net_buf *buf; + + buf = bt_mesh_adv_create(BT_MESH_ADV_BEACON,'\0',0); + *(byte *)(*(int *)buf->user_data + 8) = *(byte *)(*(int *)buf->user_data + 8) & 0xfb; + buf = net_buf_ref(buf); + net_buf_put(&adv_queue,buf); + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void bt_mesh_adv_send(net_buf *buf,bt_mesh_send_cb *cb,void *cb_data) + +{ + net_buf *buf_00; + + *(bt_mesh_send_cb **)&(*(bt_mesh_send_cb **)buf->user_data)->start = cb; + *(void **)(*(int *)buf->user_data + 4) = cb_data; + *(byte *)(*(int *)buf->user_data + 8) = *(byte *)(*(int *)buf->user_data + 8) | 4; + buf_00 = net_buf_ref(buf); + net_buf_put(&adv_queue,buf_00); + return; +} + + + +void bt_mesh_adv_init(void) + +{ + k_queue_init((k_queue *)&adv_buf_pool,0x3c); + k_queue_init((k_queue *)&adv_queue,0x14); + k_thread_create(&adv_thread_data,"BT Mesh adv",0x400,adv_thread,0x1c); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bt_mesh_scan_enable(void) + +{ + int iVar1; + undefined4 uStack24; + bt_le_scan_param scan_param; + + uStack24 = DAT_4200ee70; + scan_param._0_2_ = DAT_4200ee74; + iVar1 = bt_le_scan_start(&uStack24,bt_mesh_scan_cb); + if (iVar1 != 0) { + if (iVar1 == -0x45) { + iVar1 = 0; + } + else { + printf("starting scan failed (err %d)\r\n",iVar1); + } + } + return iVar1; +} + + + +int bt_mesh_scan_disable(void) + +{ + int iVar1; + + iVar1 = bt_le_scan_stop(); + if (iVar1 != 0) { + if (iVar1 == -0x45) { + iVar1 = 0; + } + else { + printf("stopping scan failed (err %d)\r\n",iVar1); + } + } + return iVar1; +} + + + +void beacon_complete(int err,void *user_data) + +{ + u32_t_conflict uVar1; + bt_mesh_subnet *sub; + + uVar1 = k_uptime_get_32(); + *(u32_t_conflict *)user_data = uVar1; + return; +} + + + +void bt_mesh_beacon_create(bt_mesh_subnet *sub,net_buf_simple *buf) + +{ + int iVar1; + u8_t val; + + val = bt_mesh_net_flags(sub); + net_buf_simple_add_u8(buf,'\x01'); + iVar1 = 0x89; + if (sub->kr_flag == false) { + iVar1 = 0x30; + } + net_buf_simple_add_u8(buf,val); + net_buf_simple_add_mem(buf,(void *)(&sub->field_0x21 + iVar1),8); + net_buf_simple_add_be32(buf,bt_mesh.iv_index); + net_buf_simple_add_mem(buf,sub->auth,8); + return; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +void beacon_send(k_work *work) + +{ + u8_t uVar1; + bt_mesh_net_conflict9 *pbVar2; + _Bool _Var3; + u8_t uVar4; + undefined3 extraout_var; + undefined3 extraout_var_00; + u32_t_conflict uVar5; + net_buf *buf; + undefined3 extraout_var_01; + atomic_val_t aVar6; + char *__s; + bt_mesh_prov_conflict8 *pbVar7; + int iVar8; + size_t len; + size_t sVar9; + u16_t val; + uint32_t delay; + uint uVar10; + net_buf_simple *buf_00; + char *pcStack88; + bt_mesh_sg sg; + u8_t uri_hash [16]; + u8_t zero [16]; + + _Var3 = bt_prov_active(); + if (CONCAT31(extraout_var,_Var3) != 0) goto LAB_2303ceec; + _Var3 = bt_mesh_is_provisioned(); + uVar1 = bt_mesh.sub[1].beacons_cur; + uVar4 = bt_mesh.sub[0].beacons_cur; + if (CONCAT31(extraout_var_00,_Var3) != 0) { + pbVar2 = &bt_mesh; + first_half_5767 = first_half_5767 ^ 1; + if (first_half_5767 == 0) { + if (bt_mesh.sub[0].net_idx != 0xffff) { + bt_mesh.sub[0].beacons_cur = '\0'; + bt_mesh.sub[0].beacons_last = uVar4; + } + if (bt_mesh.sub[1].net_idx != 0xffff) { + bt_mesh.sub[1].beacons_cur = '\0'; + bt_mesh.sub[1].beacons_last = uVar1; + } + } + uVar5 = k_uptime_get_32(); + do { + if ((pbVar2->sub[0].net_idx != 0xffff) && + ((uVar10 = uVar5 - pbVar2->sub[0].beacon_sent, 599999 < uVar10 || + (((uint)pbVar2->sub[0].beacons_last + 1) * 10000 - 5000 <= uVar10)))) { + buf = bt_mesh_adv_create(BT_MESH_ADV_BEACON,'\b',0); + if (buf == (net_buf *)0x0) { + printf("Unable to allocate beacon buffer\r\n"); + break; + } + bt_mesh_beacon_create(pbVar2->sub,(net_buf_simple *)&buf->field_4); + bt_mesh_adv_send(buf,(bt_mesh_send_cb *)&send_cb_5746,pbVar2->sub); + net_buf_unref(buf); + } + pbVar2 = (bt_mesh_net_conflict9 *)&pbVar2->frnd[1].seg[0].queue.tail; + } while (pbVar2 != (bt_mesh_net_conflict9 *)0x4200d884); + uVar4 = bt_mesh_beacon_get(); + if ((CONCAT31(extraout_var_01,uVar4) != 1) && + (aVar6 = atomic_get(bt_mesh.flags), (aVar6 >> 3 & 1U) == 0)) { + return; + } + delay = 10000; + goto LAB_2303cfbe; + } + sg.len = 0; + uri_hash._0_4_ = 0; + uri_hash._4_4_ = 0; + uri_hash._8_4_ = 0; + buf = bt_mesh_adv_create(BT_MESH_ADV_BEACON,'\n',0); + if (buf == (net_buf *)0x0) { + __s = "Unable to allocate beacon buffer\r\n"; +LAB_2303d040: + printf(__s); + } + else { + pbVar7 = bt_mesh_prov_get(); + buf_00 = (net_buf_simple *)&buf->field_4; + net_buf_simple_add_u8(buf_00,'\0'); + net_buf_simple_add_mem(buf_00,pbVar7->uuid,0x10); + __s = pbVar7->uri; + if (__s == (char *)0x0) { +LAB_2303d0d4: + val = pbVar7->oob_info; + } + else { + uri_hash._12_4_ = 0; + sg.data = (void *)strlen(__s); + pcStack88 = __s; + iVar8 = bt_mesh_aes_cmac(uri_hash + 0xc,(bt_mesh_sg *)&pcStack88,1,(u8_t *)&sg.len); + if (iVar8 != 0) goto LAB_2303d0d4; + val = pbVar7->oob_info | 2; + } + net_buf_simple_add_be16(buf_00,val); + if (pbVar7->uri != (char *)0x0) { + net_buf_simple_add_mem(buf_00,&sg.len,4); + } + bt_mesh_adv_send(buf,(bt_mesh_send_cb *)0x0,(void *)0x0); + net_buf_unref(buf); + if (pbVar7->uri != (char *)0x0) { + buf = bt_mesh_adv_create(BT_MESH_ADV_URI,'\n',0); + if (buf == (net_buf *)0x0) { + __s = "Unable to allocate URI buffer\r\n"; + goto LAB_2303d040; + } + len = strlen(pbVar7->uri); + sVar9 = net_buf_simple_tailroom((net_buf_simple *)&buf->field_4); + if (sVar9 < len) { + printf("Too long URI to fit advertising data\r\n"); + } + else { + net_buf_simple_add_mem((net_buf_simple *)&buf->field_4,pbVar7->uri,len); + bt_mesh_adv_send(buf,(bt_mesh_send_cb *)0x0,(void *)0x0); + } + net_buf_unref(buf); + } + } +LAB_2303ceec: + delay = 5000; +LAB_2303cfbe: + k_delayed_work_submit(&beacon_timer,delay); + return; +} + + + +void bt_mesh_beacon_init(void) + +{ + k_delayed_work_init(&beacon_timer,beacon_send); + return; +} + + + +void bt_mesh_beacon_ivu_initiator(_Bool enable) + +{ + u8_t uVar1; + undefined3 in_register_00002029; + undefined3 extraout_var; + + if (CONCAT31(in_register_00002029,enable) != 0) { + atomic_or(bt_mesh.flags,8); + k_work_submit((k_work *)&beacon_timer); + return; + } + atomic_and(bt_mesh.flags,-9); + uVar1 = bt_mesh_beacon_get(); + if (CONCAT31(extraout_var,uVar1) == 0) { + k_delayed_work_cancel(&beacon_timer); + return; + } + return; +} + + + +void bt_mesh_beacon_recv(net_buf_simple *buf) + +{ + u8_t uVar1; + byte flags; + _Bool _Var2; + _Bool _Var3; + char *fmt; + undefined3 extraout_var; + u32_t_conflict iv_index; + bt_mesh_subnet *sub; + int iVar4; + bt_mesh_subnet *sub_00; + atomic_val_t aVar5; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + uint uVar6; + u8_t *net_id; + u8_t *__src; + _Bool a_Stack33 [4]; + _Bool new_key; + + if (buf->len == 0) { + fmt = "Too short beacon\r\n"; +LAB_2303d196: + printf(fmt); + return; + } + uVar1 = net_buf_simple_pull_u8(buf); + uVar6 = CONCAT31(extraout_var,uVar1); + if (uVar6 == 0) { + return; + } + if (uVar6 != 1) { + fmt = "Unknown beacon type 0x%02x\r\n"; +LAB_2303d1be: + printf(fmt,uVar6); + return; + } + uVar6 = (uint)buf->len; + if (buf->len < 0x15) { + fmt = "Too short secure beacon (len %u)\r\n"; + goto LAB_2303d1be; + } + net_id = buf->data; + if ((bt_mesh.sub[0].net_idx != 0xffff) && + (iVar4 = memcmp(bt_mesh.sub[0].beacon_cache,net_id,0x15), iVar4 == 0)) { + sub = bt_mesh.sub; + goto update_stats; + } + if ((bt_mesh.sub[1].net_idx != 0xffff) && + (iVar4 = memcmp(bt_mesh.sub[1].beacon_cache,net_id,0x15), iVar4 == 0)) { + sub = bt_mesh.sub + 1; + goto update_stats; + } + __src = buf->data; + flags = net_buf_simple_pull_u8(buf); + net_id = (u8_t *)net_buf_simple_pull_mem(buf,8); + iv_index = net_buf_simple_pull_be32(buf); + sub = bt_mesh_subnet_find(net_id,flags,iv_index,buf->data,a_Stack33); + if (sub == (bt_mesh_subnet *)0x0) { + return; + } + if ((sub->kr_phase == '\x02') && (a_Stack33[0] == false)) { + fmt = "Ignoring Phase 2 KR Update secured using old key\r\n"; + goto LAB_2303d196; + } + memcpy(sub->beacon_cache,__src,0x15); + sub_00 = bt_mesh_subnet_get(0); + if (((sub_00 != (bt_mesh_subnet *)0x0) && (sub->net_idx != 0)) && (bt_mesh.iv_index < iv_index)) + goto update_stats; + aVar5 = atomic_get(bt_mesh.flags); + uVar6 = ((uint)flags & 2) >> 1; + if (((aVar5 >> 3 & 1U) != 0) && (aVar5 = atomic_get(bt_mesh.flags), uVar6 == (aVar5 >> 2 & 1U))) { + bt_mesh_beacon_ivu_initiator(false); + } + _Var2 = bt_mesh_net_iv_update(iv_index,SUB41(uVar6,0)); + _Var3 = bt_mesh_kr_update(sub,flags & 1,a_Stack33[0]); + if (CONCAT31(extraout_var_01,_Var3) == 0) { + if (CONCAT31(extraout_var_00,_Var2) == 0) goto update_stats; +LAB_2303d2f4: + sub_00 = (bt_mesh_subnet *)0x0; + } + else { + bt_mesh_net_beacon_update(sub); + sub_00 = sub; + if (CONCAT31(extraout_var_00,_Var2) != 0) goto LAB_2303d2f4; + } + bt_mesh_net_sec_update(sub_00); +update_stats: + uVar1 = bt_mesh_beacon_get(); + if (CONCAT31(extraout_var_02,uVar1) != 1) { + return; + } + if (sub->beacons_cur == -1) { + return; + } + sub->beacons_cur = sub->beacons_cur + '\x01'; + return; +} + + + +void bt_mesh_beacon_enable(void) + +{ + _Bool _Var1; + undefined3 extraout_var; + + _Var1 = bt_mesh_is_provisioned(); + if (CONCAT31(extraout_var,_Var1) != 0) { + if (bt_mesh.sub[0].net_idx != 0xffff) { + bt_mesh.sub[0]._4_2_ = 0; + bt_mesh_net_beacon_update(bt_mesh.sub); + } + if (bt_mesh.sub[1].net_idx != 0xffff) { + bt_mesh.sub[1]._4_2_ = 0; + bt_mesh_net_beacon_update(bt_mesh.sub + 1); + } + } + k_work_submit((k_work *)&beacon_timer); + return; +} + + + +void bt_mesh_beacon_disable(void) + +{ + atomic_val_t aVar1; + + aVar1 = atomic_get(bt_mesh.flags); + if ((aVar1 >> 3 & 1U) == 0) { + k_delayed_work_cancel(&beacon_timer); + return; + } + return; +} + + + +void hb_pub_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t **ppuVar1; + u8_t uVar2; + u16_t uVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + u8_t *puVar4; + u16_t *puVar5; + + if (cli->op_pending != 6) { + printf("Unexpected Heartbeat Publication Status message\r\n"); + return; + } + ppuVar1 = (u8_t **)cli->op_param; + puVar4 = *ppuVar1; + uVar2 = net_buf_simple_pull_u8(buf); + *puVar4 = uVar2; + puVar5 = (u16_t *)ppuVar1[1]; + if (puVar5 != (u16_t *)0x0) { + uVar3 = net_buf_simple_pull_le16(buf); + *puVar5 = uVar3; + puVar4 = ppuVar1[1]; + uVar2 = net_buf_simple_pull_u8(buf); + puVar4[2] = uVar2; + puVar4 = ppuVar1[1]; + uVar2 = net_buf_simple_pull_u8(buf); + puVar4[3] = uVar2; + puVar4 = ppuVar1[1]; + uVar2 = net_buf_simple_pull_u8(buf); + puVar4[4] = uVar2; + uVar2 = net_buf_simple_pull_u8(buf); + *(short *)(ppuVar1[1] + 6) = (short)CONCAT31(extraout_var,uVar2); + uVar2 = net_buf_simple_pull_u8(buf); + *(short *)(ppuVar1[1] + 8) = (short)CONCAT31(extraout_var_00,uVar2); + } + k_sem_give(&cli->op_sync); + return; +} + + + +void hb_sub_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t **ppuVar1; + u8_t uVar2; + u16_t uVar3; + u8_t *puVar4; + u16_t *puVar5; + + if (cli->op_pending != 0x803c) { + printf("Unexpected Heartbeat Subscription Status message\r\n"); + return; + } + ppuVar1 = (u8_t **)cli->op_param; + puVar4 = *ppuVar1; + uVar2 = net_buf_simple_pull_u8(buf); + *puVar4 = uVar2; + puVar5 = (u16_t *)ppuVar1[1]; + uVar3 = net_buf_simple_pull_le16(buf); + *puVar5 = uVar3; + puVar4 = ppuVar1[1]; + uVar3 = net_buf_simple_pull_le16(buf); + *(u16_t *)(puVar4 + 2) = uVar3; + puVar4 = ppuVar1[1]; + uVar2 = net_buf_simple_pull_u8(buf); + puVar4[4] = uVar2; + puVar4 = ppuVar1[1]; + uVar2 = net_buf_simple_pull_u8(buf); + puVar4[5] = uVar2; + puVar4 = ppuVar1[1]; + uVar2 = net_buf_simple_pull_u8(buf); + puVar4[6] = uVar2; + puVar4 = ppuVar1[1]; + uVar2 = net_buf_simple_pull_u8(buf); + puVar4[7] = uVar2; + k_sem_give(&cli->op_sync); + return; +} + + + +void mod_pub_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + short sVar1; + short *psVar2; + u8_t uVar3; + u16_t uVar4; + char *fmt; + undefined2 extraout_var; + bt_mesh_msg_ctx *pbVar5; + u16_t *puVar6; + int iVar7; + + if (cli->op_pending == 0x8019) { + psVar2 = (short *)cli->op_param; + ctx = (bt_mesh_msg_ctx *)(uint)(ushort)psVar2[1]; + if (psVar2[1] == 0xffff) { + if (0xc < buf->len) { + fmt = "Unexpected Mod Pub Status with Vendor Model\r\n"; + goto LAB_2303d538; + } + sVar1 = *(short *)(buf->data + 10); + pbVar5 = ctx; + } + else { + if (buf->len < 0xe) { + fmt = "Unexpected Mod Pub Status with SIG Model\r\n"; + goto LAB_2303d538; + } + sVar1 = *(short *)(buf->data + 0xc); + pbVar5 = (bt_mesh_msg_ctx *)(uint)*(ushort *)(buf->data + 10); + } + if ((*psVar2 == sVar1) && (ctx == pbVar5)) { + uVar3 = net_buf_simple_pull_u8(buf); + uVar4 = net_buf_simple_pull_le16(buf); + if ((uint)(ushort)psVar2[2] != CONCAT22(extraout_var,uVar4)) { + printf("Model Pub Status for unexpected element (0x%04x)\r\n",CONCAT22(extraout_var,uVar4)); + return; + } + if (*(u8_t **)(psVar2 + 4) != (u8_t *)0x0) { + **(u8_t **)(psVar2 + 4) = uVar3; + } + puVar6 = *(u16_t **)(psVar2 + 6); + if (puVar6 != (u16_t *)0x0) { + uVar4 = net_buf_simple_pull_le16(buf); + *puVar6 = uVar4; + iVar7 = *(int *)(psVar2 + 6); + uVar4 = net_buf_simple_pull_le16(buf); + *(u16_t *)(iVar7 + 2) = uVar4; + *(byte *)(*(int *)(psVar2 + 6) + 4) = + (byte)((ushort)*(undefined2 *)(*(int *)(psVar2 + 6) + 2) >> 0xc) & 1; + *(ushort *)(*(int *)(psVar2 + 6) + 2) = + (ushort)(((uint)*(ushort *)(*(int *)(psVar2 + 6) + 2) << 0x14) >> 0x14); + iVar7 = *(int *)(psVar2 + 6); + uVar3 = net_buf_simple_pull_u8(buf); + *(u8_t *)(iVar7 + 5) = uVar3; + iVar7 = *(int *)(psVar2 + 6); + uVar3 = net_buf_simple_pull_u8(buf); + *(u8_t *)(iVar7 + 6) = uVar3; + iVar7 = *(int *)(psVar2 + 6); + uVar3 = net_buf_simple_pull_u8(buf); + *(u8_t *)(iVar7 + 7) = uVar3; + } + k_sem_give(&cli->op_sync); + return; + } + fmt = "Mod Pub Model ID or Company ID mismatch\r\n"; + } + else { + fmt = "Unexpected Model Pub Status message\r\n"; + } +LAB_2303d538: + printf(fmt,ctx); + return; +} + + + +void relay_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t uVar1; + u8_t **ppuVar2; + u8_t *puVar3; + + if (cli->op_pending != 0x8028) { + printf("Unexpected Relay Status message\r\n"); + return; + } + ppuVar2 = (u8_t **)cli->op_param; + puVar3 = *ppuVar2; + uVar1 = net_buf_simple_pull_u8(buf); + *puVar3 = uVar1; + puVar3 = ppuVar2[1]; + uVar1 = net_buf_simple_pull_u8(buf); + *puVar3 = uVar1; + k_sem_give(&cli->op_sync); + return; +} + + + +void key_idx_unpack(net_buf_simple *buf,u16_t *idx1,u16_t *idx2) + +{ + *idx1 = (ushort)(((uint)*(ushort *)buf->data << 0x14) >> 0x14); + *idx2 = *(ushort *)(buf->data + 1) >> 4; + net_buf_simple_pull(buf,3); + return; +} + + + +// WARNING: Variable defined which should be unmapped: net_idx + +void app_key_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + bt_mesh_cfg_cli *pbVar1; + u8_t uVar2; + char *fmt; + u8_t **ppuVar3; + u16_t uStack20; + u16_t uStack18; + u16_t net_idx; + u16_t app_idx; + + if (cli->op_pending == 0x8003) { + uVar2 = net_buf_simple_pull_u8(buf); + key_idx_unpack(buf,&uStack20,&uStack18); + pbVar1 = cli; + ppuVar3 = (u8_t **)cli->op_param; + if ((*(u16_t *)(ppuVar3 + 1) == uStack20) && (*(u16_t *)((int)ppuVar3 + 6) == uStack18)) { + if (*ppuVar3 != (u8_t *)0x0) { + **ppuVar3 = uVar2; + } + k_sem_give(&pbVar1->op_sync); + return; + } + fmt = "App Key Status key indices did not match\r\n"; + } + else { + fmt = "Unexpected App Key Status message\r\n"; + } + printf(fmt); + return; +} + + + +// WARNING: Variable defined which should be unmapped: net_idx + +void net_key_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + bt_mesh_cfg_cli *pbVar1; + u8_t uVar2; + char *fmt; + u8_t *puVar3; + u16_t uStack20; + u16_t uStack18; + u16_t net_idx; + u16_t app_idx; + + if (cli->op_pending == 0x8044) { + uVar2 = net_buf_simple_pull_u8(buf); + key_idx_unpack(buf,&uStack20,&uStack18); + pbVar1 = cli; + if (*(u16_t *)(cli->op_param + 1) == uStack20) { + puVar3 = *(u8_t **)cli->op_param; + if (puVar3 != (u8_t *)0x0) { + *puVar3 = uVar2; + } + k_sem_give(&pbVar1->op_sync); + return; + } + fmt = "Net Key Status key index does not match\r\n"; + } + else { + fmt = "Unexpected Net Key Status message\r\n"; + } + printf(fmt); + return; +} + + + +void comp_data_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t uVar1; + size_t sVar2; + size_t len; + u8_t **ppuVar3; + u8_t *puVar4; + + if (cli->op_pending != 2) { + printf("Unexpected Composition Data Status\r\n"); + return; + } + ppuVar3 = (u8_t **)cli->op_param; + puVar4 = *ppuVar3; + uVar1 = net_buf_simple_pull_u8(buf); + *puVar4 = uVar1; + sVar2 = net_buf_simple_tailroom((net_buf_simple *)ppuVar3[1]); + len = (size_t)buf->len; + if (sVar2 < len) { + len = net_buf_simple_tailroom((net_buf_simple *)ppuVar3[1]); + } + net_buf_simple_add_mem((net_buf_simple *)ppuVar3[1],buf->data,len); + k_sem_give(&cli->op_sync); + return; +} + + + +void mod_sub_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + bt_mesh_cfg_cli *pbVar1; + uint uVar2; + u8_t uVar3; + u16_t uVar4; + u16_t uVar5; + u16_t uVar6; + char *fmt; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined2 extraout_var_02; + u8_t **ppuVar7; + + if (cli->op_pending == 0x801f) { + uVar3 = net_buf_simple_pull_u8(buf); + uVar4 = net_buf_simple_pull_le16(buf); + uVar5 = net_buf_simple_pull_le16(buf); + if (buf->len < 4) { + uVar2 = 0xffff; + } + else { + uVar6 = net_buf_simple_pull_le16(buf); + uVar2 = CONCAT22(extraout_var_01,uVar6); + } + uVar6 = net_buf_simple_pull_le16(buf); + pbVar1 = cli; + ppuVar7 = (u8_t **)cli->op_param; + if (((((uint)*(ushort *)(ppuVar7 + 1) == CONCAT22(extraout_var,uVar4)) && + ((uint)*(ushort *)(ppuVar7 + 4) == CONCAT22(extraout_var_02,uVar6))) && + (((ushort *)ppuVar7[3] == (ushort *)0x0 || + ((uint)*(ushort *)ppuVar7[3] == CONCAT22(extraout_var_00,uVar5))))) && + ((uint)*(ushort *)((int)ppuVar7 + 0x12) == uVar2)) { + if ((u16_t *)ppuVar7[2] != (u16_t *)0x0) { + *(u16_t *)ppuVar7[2] = uVar5; + } + if (*ppuVar7 != (u8_t *)0x0) { + **ppuVar7 = uVar3; + } + k_sem_give(&pbVar1->op_sync); + return; + } + fmt = "Model Subscription Status parameters did not match\r\n"; + } + else { + fmt = "Unexpected Model Subscription Status message\r\n"; + } + printf(fmt); + return; +} + + + +void mod_app_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + bt_mesh_cfg_cli *pbVar1; + uint uVar2; + u8_t uVar3; + u16_t uVar4; + u16_t uVar5; + u16_t uVar6; + char *fmt; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined2 extraout_var_02; + u8_t **ppuVar7; + + if (cli->op_pending == 0x803e) { + uVar3 = net_buf_simple_pull_u8(buf); + uVar4 = net_buf_simple_pull_le16(buf); + uVar5 = net_buf_simple_pull_le16(buf); + if (buf->len < 4) { + uVar2 = 0xffff; + } + else { + uVar6 = net_buf_simple_pull_le16(buf); + uVar2 = CONCAT22(extraout_var_01,uVar6); + } + uVar6 = net_buf_simple_pull_le16(buf); + pbVar1 = cli; + ppuVar7 = (u8_t **)cli->op_param; + if (((((uint)*(ushort *)(ppuVar7 + 1) == CONCAT22(extraout_var,uVar4)) && + ((uint)*(ushort *)((int)ppuVar7 + 6) == CONCAT22(extraout_var_00,uVar5))) && + ((uint)*(ushort *)(ppuVar7 + 2) == CONCAT22(extraout_var_02,uVar6))) && + ((uint)*(ushort *)((int)ppuVar7 + 10) == uVar2)) { + if (*ppuVar7 != (u8_t *)0x0) { + **ppuVar7 = uVar3; + } + k_sem_give(&pbVar1->op_sync); + return; + } + fmt = "Model App Status parameters did not match\r\n"; + } + else { + fmt = "Unexpected Model App Status message\r\n"; + } + printf(fmt); + return; +} + + + +void state_status_u8(net_buf_simple *buf,u32_t_conflict expect_status) + +{ + u8_t *puVar1; + u8_t uVar2; + + if (cli->op_pending != expect_status) { + printf("Unexpected Status (0x%08x != 0x%08x)\r\n"); + return; + } + puVar1 = (u8_t *)cli->op_param; + uVar2 = net_buf_simple_pull_u8(buf); + *puVar1 = uVar2; + k_sem_give(&cli->op_sync); + return; +} + + + +void gatt_proxy_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + state_status_u8(buf,0x8014); + return; +} + + + +void friend_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + state_status_u8(buf,0x8011); + return; +} + + + +void ttl_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + state_status_u8(buf,0x800e); + return; +} + + + +void beacon_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + state_status_u8(buf,0x800b); + return; +} + + + +_Bool app_key_is_valid(u16_t app_idx) + +{ + bool bVar1; + undefined2 in_register_0000202a; + + if (((bt_mesh.app_keys[0].net_idx == 0xffff) || + (bVar1 = true, (uint)bt_mesh.app_keys[0].app_idx != CONCAT22(in_register_0000202a,app_idx))) + && (bVar1 = false, bt_mesh.app_keys[1].net_idx != 0xffff)) { + bVar1 = (uint)bt_mesh.app_keys[1].app_idx == CONCAT22(in_register_0000202a,app_idx); + } + return (_Bool)bVar1; +} + + + +void key_idx_pack(net_buf_simple *buf,u16_t idx1,u16_t idx2) + +{ + net_buf_simple_add_le16(buf,idx1 | idx2 << 0xc); + net_buf_simple_add_u8(buf,(u8_t)(idx2 >> 4)); + return; +} + + + +void send_krp_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,u16_t idx,u8_t phase,u8_t status) + +{ + int iVar1; + u8_t auStack40 [4]; + u8_t net_buf_data_msg [10]; + net_buf_simple msg; + + register0x0000203c = auStack40; + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 8),0x8017); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 8),status); + net_buf_simple_add_le16((net_buf_simple *)(net_buf_data_msg + 8),idx); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 8),phase); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 8), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar1 != 0) { + printf("Unable to send Key Refresh State Status\r\n"); + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: msg + +void send_friend_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx) + +{ + int iVar1; + void *pvVar2; + u8_t auStack36 [4]; + u8_t net_buf_data_msg [7]; + net_buf_simple msg; + + register0x0000203c = auStack36; + pvVar2 = model->user_data; + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 4),0x8011); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 4),*(u8_t *)((int)pvVar2 + 9)); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 4), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar1 != 0) { + printf("Unable to send Friend Status\r\n"); + } + return; +} + + + +void friend_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx) + +{ + int iVar1; + void *pvVar2; + u8_t auStack36 [8]; + u8_t *puStack28; + undefined4 uStack24; + u8_t *puStack20; + + puStack28 = auStack36; + pvVar2 = model->user_data; + uStack24 = 0x70000; + puStack20 = auStack36; + bt_mesh_model_msg_init((net_buf_simple *)&puStack28,0x8011); + net_buf_simple_add_u8((net_buf_simple *)&puStack28,*(u8_t *)((int)pvVar2 + 9)); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)&puStack28,(bt_mesh_send_cb *)0x0, + (void *)0x0); + if (iVar1 != 0) { + printf("Unable to send Friend Status\r\n"); + } + return; +} + + + +void net_key_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + int iVar1; + u16_t val; + u8_t auStack40 [4]; + u8_t net_buf_data_msg [9]; + net_buf_simple msg; + + register0x0000203c = auStack40; + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 8),0x8043); + if (bt_mesh.sub[1].net_idx == 0xffff) { + val = bt_mesh.sub[0].net_idx; + if (bt_mesh.sub[0].net_idx == 0xffff) goto LAB_2303dc1a; + } + else { + val = bt_mesh.sub[1].net_idx; + if (bt_mesh.sub[0].net_idx != 0xffff) { + key_idx_pack((net_buf_simple *)(net_buf_data_msg + 8),bt_mesh.sub[0].net_idx, + bt_mesh.sub[1].net_idx); + goto LAB_2303dc1a; + } + } + net_buf_simple_add_le16((net_buf_simple *)(net_buf_data_msg + 8),val); +LAB_2303dc1a: + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 8), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar1 != 0) { + printf("Unable to send NetKey List\r\n"); + } + return; +} + + + +void send_net_key_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,u16_t idx,u8_t status) + +{ + int iVar1; + u8_t auStack40 [4]; + u8_t net_buf_data_msg [9]; + net_buf_simple msg; + + register0x0000203c = auStack40; + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 8),0x8044); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 8),status); + net_buf_simple_add_le16((net_buf_simple *)(net_buf_data_msg + 8),idx); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 8), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar1 != 0) { + printf("Unable to send NetKey Status\r\n"); + } + return; +} + + + +void krp_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u16_t net_idx; + undefined2 extraout_var; + bt_mesh_subnet *pbVar1; + u8_t phase; + u8_t status; + + net_idx = net_buf_simple_pull_le16(buf); + if (0xfff < CONCAT22(extraout_var,net_idx)) { + printf("Invalid NetKeyIndex 0x%04x\r\n",CONCAT22(extraout_var,net_idx)); + return; + } + pbVar1 = bt_mesh_subnet_get(net_idx); + if (pbVar1 == (bt_mesh_subnet *)0x0) { + status = '\x04'; + phase = '\0'; + } + else { + status = '\0'; + phase = pbVar1->kr_phase; + } + send_krp_status(model,ctx,net_idx,phase,status); + return; +} + + + +void node_identity_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t val; + u16_t net_idx; + undefined2 extraout_var; + int iVar1; + u8_t auStack56 [4]; + u8_t net_buf_data_msg [10]; + net_buf_simple msg; + + register0x0000203c = auStack56; + net_idx = net_buf_simple_pull_le16(buf); + if (CONCAT22(extraout_var,net_idx) < 0x1000) { + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 8),0x8048); + _val = bt_mesh_subnet_get(net_idx); + val = (u8_t)_val; + if (_val == (bt_mesh_subnet *)0x0) { + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 8),'\x04'); + } + else { + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 8),'\0'); + val = _val->node_id; + } + net_buf_simple_add_le16((net_buf_simple *)(net_buf_data_msg + 8),net_idx); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 8),val); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 8), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar1 != 0) { + printf("Unable to send Node Identity Status\r\n"); + } + } + else { + printf("Invalid NetKeyIndex 0x%04x\r\n",CONCAT22(extraout_var,net_idx)); + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void app_key_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u16_t net_idx; + undefined2 extraout_var; + bt_mesh_subnet *pbVar1; + int iVar2; + u16_t val; + u8_t auStack56 [4]; + u8_t net_buf_data_msg [12]; + net_buf_simple msg; + + net_buf_data_msg._8_4_ = auStack56; + net_idx = net_buf_simple_pull_le16(buf); + _net_idx = CONCAT22(extraout_var,net_idx); + if (_net_idx < 0x1000) { + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 8),0x8002); + pbVar1 = bt_mesh_subnet_get(net_idx); + net_buf_simple_add_u8 + ((net_buf_simple *)(net_buf_data_msg + 8),(pbVar1 == (bt_mesh_subnet *)0x0) << 2); + net_buf_simple_add_le16((net_buf_simple *)(net_buf_data_msg + 8),net_idx); + if (pbVar1 != (bt_mesh_subnet *)0x0) { + net_idx = bt_mesh.app_keys[0].app_idx; + if ((uint)bt_mesh.app_keys[0].net_idx != _net_idx) { + net_idx = 0xffff; + } + val = net_idx; + if (((uint)bt_mesh.app_keys[1].net_idx == _net_idx) && + (val = bt_mesh.app_keys[1].app_idx, net_idx != 0xffff)) { + key_idx_pack((net_buf_simple *)(net_buf_data_msg + 8),net_idx,bt_mesh.app_keys[1].app_idx); + } + else { + if (val != 0xffff) { + net_buf_simple_add_le16((net_buf_simple *)(net_buf_data_msg + 8),val); + } + } + } + iVar2 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 8), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar2 != 0) { + printf("Unable to send AppKey List\r\n"); + } + } + else { + printf("Invalid NetKeyIndex 0x%04x\r\n",_net_idx); + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void hb_pub_send_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,u8_t status,hb_pub_param *orig_msg + ) + +{ + ushort uVar1; + void *__dest; + int iVar2; + u8_t val; + u8_t **ppuStack60; + net_buf_simple msg; + u8_t net_buf_data_msg [15]; + + ppuStack60 = &msg.__buf; + msg.data = (u8_t *)0xf0000; + __dest = model->user_data; + msg._4_4_ = &msg.__buf; + bt_mesh_model_msg_init((net_buf_simple *)&ppuStack60,6); + net_buf_simple_add_u8((net_buf_simple *)&ppuStack60,status); + if (orig_msg == (hb_pub_param *)0x0) { + net_buf_simple_add_le16((net_buf_simple *)&ppuStack60,*(u16_t *)((int)__dest + 0x30)); + uVar1 = *(ushort *)((int)__dest + 0x32); + val = '\0'; + if (((uVar1 != 0) && (val = '\x01', uVar1 != 1)) && (val = -1, uVar1 != 0xffff)) { + iVar2 = __clzsi2((uint)uVar1 - 1); + val = '!' - (char)iVar2; + } + net_buf_simple_add_u8((net_buf_simple *)&ppuStack60,val); + net_buf_simple_add_u8((net_buf_simple *)&ppuStack60,*(u8_t *)((int)__dest + 0x34)); + net_buf_simple_add_u8((net_buf_simple *)&ppuStack60,*(u8_t *)((int)__dest + 0x35)); + net_buf_simple_add_le16((net_buf_simple *)&ppuStack60,*(u16_t *)((int)__dest + 0x36)); + net_buf_simple_add_le16((net_buf_simple *)&ppuStack60,*(u16_t *)((int)__dest + 0x38)); + } + else { + __dest = net_buf_simple_add((net_buf_simple *)&ppuStack60,9); + memcpy(__dest,orig_msg,9); + } + iVar2 = bt_mesh_model_send(model,ctx,(net_buf_simple *)&ppuStack60,(bt_mesh_send_cb *)0x0, + (void *)0x0); + if (iVar2 != 0) { + printf("Unable to send Heartbeat Publication Status\r\n"); + } + return; +} + + + +void heartbeat_pub_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + hb_pub_send_status(model,ctx,'\0',(hb_pub_param *)0x0); + return; +} + + + +// WARNING: Variable defined which should be unmapped: net_buf_data_msg +// WARNING: Could not reconcile some variable overlaps + +void send_mod_sub_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,u8_t status,u16_t elem_addr, + u16_t sub_addr,u8_t *mod_id,_Bool vnd) + +{ + void *__dest; + int iVar1; + size_t __n; + undefined3 in_register_00002041; + u8_t **ppuStack44; + net_buf_simple msg; + u8_t net_buf_data_msg [15]; + + ppuStack44 = &msg.__buf; + msg.data = (u8_t *)0xf0000; + msg._4_4_ = &msg.__buf; + bt_mesh_model_msg_init((net_buf_simple *)&ppuStack44,0x801f); + net_buf_simple_add_u8((net_buf_simple *)&ppuStack44,status); + net_buf_simple_add_le16((net_buf_simple *)&ppuStack44,elem_addr); + net_buf_simple_add_le16((net_buf_simple *)&ppuStack44,sub_addr); + if (CONCAT31(in_register_00002041,vnd) == 0) { + __dest = net_buf_simple_add((net_buf_simple *)&ppuStack44,2); + __n = 2; + } + else { + __dest = net_buf_simple_add((net_buf_simple *)&ppuStack44,4); + __n = 4; + } + memcpy(__dest,mod_id,__n); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)&ppuStack44,(bt_mesh_send_cb *)0x0, + (void *)0x0); + if (iVar1 != 0) { + printf("Unable to send Model Subscription Status\r\n"); + } + return; +} + + + +void krp_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t status; + u16_t net_idx; + undefined2 extraout_var_00; + undefined3 extraout_var; + bt_mesh_subnet *sub; + u8_t phase; + + net_idx = net_buf_simple_pull_le16(buf); + status = net_buf_simple_pull_u8(buf); + _status = CONCAT31(extraout_var,status); + if (0xfff < CONCAT22(extraout_var_00,net_idx)) { + printf("Invalid NetKeyIndex 0x%04x\r\n",CONCAT22(extraout_var_00,net_idx)); + return; + } + sub = bt_mesh_subnet_get(net_idx); + if (sub == (bt_mesh_subnet *)0x0) { + status = '\x04'; + phase = '\0'; + goto LAB_2303e04e; + } + status = sub->kr_phase; + if (1 < (_status - 2U & 0xff)) { +LAB_2303e07e: + printf("Prohibited transition %u -> %u\r\n"); + return; + } + if (status == '\0') { + if (_status == 2) goto LAB_2303e07e; + } + else { + if (status == '\x01') { + if (_status == 2) { + *(undefined2 *)&sub->kr_flag = 0x201; + } + else { +LAB_2303e0ba: + if (_status != 3) goto LAB_2303e0ac; + bt_mesh_net_revoke_keys(sub); + friend_cred_refresh(ctx->net_idx); + *(undefined2 *)&sub->kr_flag = 0; + } + bt_mesh_net_beacon_update(sub); + } + else { + if (status == '\x02') goto LAB_2303e0ba; + } + } +LAB_2303e0ac: + status = '\0'; + phase = sub->kr_phase; +LAB_2303e04e: + send_krp_status(model,ctx,net_idx,phase,status); + return; +} + + + +// WARNING: Variable defined which should be unmapped: msg + +void lpn_timeout_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + int iVar1; + u16_t val; + char *fmt; + bt_mesh_friend_conflict45 *pbVar2; + s32_t sVar3; + u8_t auStack40 [4]; + u8_t net_buf_data_msg [11]; + net_buf_simple msg; + + register0x0000203c = auStack40; + val = net_buf_simple_pull_le16(buf); + if ((short)val < 1) { + fmt = "Invalid LPNAddress; ignoring msg\r\n"; + } + else { + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 8),0x802e); + net_buf_simple_add_le16((net_buf_simple *)(net_buf_data_msg + 8),val); + pbVar2 = bt_mesh_friend_find(0xffff,val,true,true); + iVar1 = 0; + if (pbVar2 != (bt_mesh_friend_conflict45 *)0x0) { + sVar3 = k_delayed_work_remaining_get(&pbVar2->timer); + iVar1 = sVar3 / 100; + } + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 8),(u8_t)iVar1); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 8),(u8_t)((uint)iVar1 >> 8)); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 8),(u8_t)((uint)iVar1 >> 0x10)); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 8), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar1 == 0) { + return; + } + fmt = "Unable to send LPN PollTimeout Status\r\n"; + } + printf(fmt); + return; +} + + + +void friend_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + byte bVar1; + void *pvVar2; + + bVar1 = *buf->data; + if (1 < bVar1) { + printf("Invalid Friend value 0x%02x\r\n",(uint)bVar1); + return; + } + pvVar2 = model->user_data; + if (pvVar2 == (void *)0x0) { + printf("No Configuration Server context available\r\n"); + } + else { + if ((uint)*(byte *)((int)pvVar2 + 9) != (uint)bVar1) { + *(byte *)((int)pvVar2 + 9) = bVar1; + if (bVar1 == 0) { + bt_mesh_friend_clear_net_idx(0xffff); + } + if ((*(ushort *)((int)pvVar2 + 0x36) & 4) != 0) { + bt_mesh_heartbeat_send(); + } + } + } + send_friend_status(model,ctx); + return; +} + + + +void node_reset(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + int iVar1; + u8_t auStack36 [4]; + u8_t net_buf_data_msg [6]; + net_buf_simple msg; + + register0x0000203c = auStack36; + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 4),0x804a); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 4), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar1 != 0) { + printf("Unable to send Node Reset Status\r\n"); + } + vTaskDelay(500); + bt_mesh_reset(); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void mod_sub_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u16_t addr; + u16_t id; + char *fmt; + bt_mesh_elem *elem; + bt_mesh_model *pbVar1; + int iVar2; + u8_t val; + u8_t **ppuStack60; + net_buf_simple msg; + u8_t net_buf_data_msg [15]; + + ppuStack60 = &msg.__buf; + msg.data = (u8_t *)0xf0000; + msg._4_4_ = &msg.__buf; + addr = net_buf_simple_pull_le16(buf); + if ((short)addr < 1) { + fmt = "Prohibited element address\r\n"; + goto LAB_2303e292; + } + id = net_buf_simple_pull_le16(buf); + bt_mesh_model_msg_init((net_buf_simple *)&ppuStack60,0x802a); + elem = bt_mesh_elem_find(addr); + val = '\x01'; + if (elem == (bt_mesh_elem *)0x0) { +LAB_2303e2d2: + net_buf_simple_add_u8((net_buf_simple *)&ppuStack60,val); + net_buf_simple_add_le16((net_buf_simple *)&ppuStack60,addr); +LAB_2303e2e2: + net_buf_simple_add_le16((net_buf_simple *)&ppuStack60,id); + } + else { + pbVar1 = bt_mesh_model_find(elem,id); + if (pbVar1 == (bt_mesh_model *)0x0) { + val = '\x02'; + goto LAB_2303e2d2; + } + net_buf_simple_add_u8((net_buf_simple *)&ppuStack60,'\0'); + net_buf_simple_add_le16((net_buf_simple *)&ppuStack60,addr); + net_buf_simple_add_le16((net_buf_simple *)&ppuStack60,id); + if (pbVar1->groups[0] != 0) { + net_buf_simple_add_le16((net_buf_simple *)&ppuStack60,pbVar1->groups[0]); + } + id = pbVar1->groups[1]; + if (id != 0) goto LAB_2303e2e2; + } + iVar2 = bt_mesh_model_send(model,ctx,(net_buf_simple *)&ppuStack60,(bt_mesh_send_cb *)0x0, + (void *)0x0); + if (iVar2 == 0) { + return; + } + fmt = "Unable to send Model Subscription List\r\n"; +LAB_2303e292: + printf(fmt); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void mod_sub_get_vnd(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u16_t addr; + u16_t company; + u16_t id; + char *fmt; + bt_mesh_elem *elem; + bt_mesh_model *pbVar1; + int iVar2; + u8_t val; + u8_t **local_40; + net_buf_simple msg; + u8_t net_buf_data_msg [17]; + + local_40 = &msg.__buf; + msg.data = (u8_t *)0x110000; + msg._4_4_ = &msg.__buf; + addr = net_buf_simple_pull_le16(buf); + if ((short)addr < 1) { + fmt = "Prohibited element address\r\n"; + goto LAB_2303e36a; + } + company = net_buf_simple_pull_le16(buf); + id = net_buf_simple_pull_le16(buf); + bt_mesh_model_msg_init((net_buf_simple *)&local_40,0x802c); + elem = bt_mesh_elem_find(addr); + val = '\x01'; + if (elem == (bt_mesh_elem *)0x0) { +LAB_2303e3b6: + net_buf_simple_add_u8((net_buf_simple *)&local_40,val); + net_buf_simple_add_le16((net_buf_simple *)&local_40,addr); + net_buf_simple_add_le16((net_buf_simple *)&local_40,company); +LAB_2303e3ce: + net_buf_simple_add_le16((net_buf_simple *)&local_40,id); + } + else { + pbVar1 = bt_mesh_model_find_vnd(elem,company,id); + if (pbVar1 == (bt_mesh_model *)0x0) { + val = '\x02'; + goto LAB_2303e3b6; + } + net_buf_simple_add_u8((net_buf_simple *)&local_40,'\0'); + net_buf_simple_add_le16((net_buf_simple *)&local_40,addr); + net_buf_simple_add_le16((net_buf_simple *)&local_40,company); + net_buf_simple_add_le16((net_buf_simple *)&local_40,id); + if (pbVar1->groups[0] != 0) { + net_buf_simple_add_le16((net_buf_simple *)&local_40,pbVar1->groups[0]); + } + id = pbVar1->groups[1]; + if (id != 0) goto LAB_2303e3ce; + } + iVar2 = bt_mesh_model_send(model,ctx,(net_buf_simple *)&local_40,(bt_mesh_send_cb *)0x0, + (void *)0x0); + if (iVar2 == 0) { + return; + } + fmt = "Unable to send Vendor Model Subscription List\r\n"; +LAB_2303e36a: + printf(fmt); + return; +} + + + +void net_key_update(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + byte bVar1; + u16_t net_idx; + undefined2 extraout_var; + bt_mesh_subnet *sub; + int iVar2; + u8_t status; + + net_idx = net_buf_simple_pull_le16(buf); + if (0xfff < CONCAT22(extraout_var,net_idx)) { + printf("Invalid NetKeyIndex 0x%04x\r\n",CONCAT22(extraout_var,net_idx)); + return; + } + sub = bt_mesh_subnet_get(net_idx); + status = '\x04'; + if (sub == (bt_mesh_subnet *)0x0) goto LAB_2303e47e; + bVar1 = sub->kr_phase; + if (bVar1 == 1) { + iVar2 = memcmp(buf->data,sub->keys + 1,0x10); + if (iVar2 != 0) { +LAB_2303e47c: + status = '\v'; + goto LAB_2303e47e; + } + } + else { + if (bVar1 == 0) { + iVar2 = memcmp(buf->data,sub->keys,0x10); + if (iVar2 == 0) { + return; + } + } + else { + if (bVar1 < 4) goto LAB_2303e47c; + } + iVar2 = bt_mesh_net_keys_create(sub->keys + 1,buf->data); + if ((iVar2 != 0) || (iVar2 = friend_cred_update(sub), iVar2 != 0)) { + status = '\x10'; + goto LAB_2303e47e; + } + sub->kr_phase = '\x01'; + bt_mesh_net_beacon_update(sub); + } + status = '\0'; +LAB_2303e47e: + send_net_key_status(model,ctx,net_idx,status); + return; +} + + + +void net_key_add(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u16_t net_idx; + undefined2 extraout_var; + bt_mesh_subnet *sub; + u8_t status; + int iVar1; + + net_idx = net_buf_simple_pull_le16(buf); + _net_idx = CONCAT22(extraout_var,net_idx); + if (0xfff < _net_idx) { + printf("Invalid NetKeyIndex 0x%04x\r\n",_net_idx); + return; + } + sub = bt_mesh_subnet_get(net_idx); + if (sub == (bt_mesh_subnet *)0x0) { + if (bt_mesh.sub[0].net_idx == 0xffff) { + iVar1 = 0; + } + else { + status = '\x05'; + if (bt_mesh.sub[1].net_idx != 0xffff) goto LAB_2303e588; + iVar1 = 1; + } + sub = bt_mesh.sub + iVar1; + } + if ((uint)sub->net_idx == _net_idx) { + iVar1 = memcmp(buf->data,sub->keys,0x10); + status = '\x06'; + if (iVar1 != 0) goto LAB_2303e588; + } + else { + iVar1 = bt_mesh_net_keys_create(sub->keys,buf->data); + status = '\x10'; + if (iVar1 != 0) goto LAB_2303e588; + sub->net_idx = net_idx; + bt_mesh_net_beacon_update(sub); + sub->node_id = '\0'; + bt_mesh_proxy_beacon_send(sub); + bt_mesh_adv_update(); + } + status = '\0'; +LAB_2303e588: + send_net_key_status(model,ctx,net_idx,status); + return; +} + + + +void key_idx_unpack(net_buf_simple *buf,u16_t *idx1,u16_t *idx2) + +{ + *idx1 = (ushort)(((uint)*(ushort *)buf->data << 0x14) >> 0x14); + *idx2 = *(ushort *)(buf->data + 1) >> 4; + net_buf_simple_pull(buf,3); + return; +} + + + +u8_t _mod_pub_set(bt_mesh_model *model,u16_t pub_addr,u16_t app_idx,u8_t cred_flag,u8_t ttl, + u8_t period,u8_t retransmit) + +{ + bt_mesh_model_pub *pbVar1; + k_delayed_work *work; + bt_mesh_app_key *pbVar2; + uint32_t delay; + undefined2 in_register_0000202e; + undefined3 in_register_0000203d; + + pbVar1 = model->pub; + if ((pbVar1 == (bt_mesh_model_pub *)0x0) || + ((pbVar1->update == (anon_subr_int_bt_mesh_model_ptr_for_update *)0x0 && + (CONCAT31(in_register_0000203d,period) != 0)))) { + return '\a'; + } + if (CONCAT22(in_register_0000202e,pub_addr) == 0) { + if (pbVar1->addr == 0) { + return '\0'; + } + pbVar1->addr = 0; + model->pub->key = 0; + *(byte *)&model->pub->field_0xb = *(byte *)&model->pub->field_0xb & 0xef; + model->pub->ttl = '\0'; + model->pub->period = '\0'; + model->pub->retransmit = '\0'; + *(byte *)&model->pub->field_0xc = *(byte *)&model->pub->field_0xc & 0xf8; + work = &model->pub->timer; + if (model->pub->update == (anon_subr_int_bt_mesh_model_ptr_for_update *)0x0) { + return '\0'; + } + } + else { + pbVar2 = bt_mesh_app_key_find(app_idx); + if (pbVar2 == (bt_mesh_app_key *)0x0) { + return '\x03'; + } + model->pub->addr = pub_addr; + model->pub->key = app_idx; + *(byte *)&model->pub->field_0xb = + (byte)(((uint)cred_flag & 1) << 4) | *(byte *)&model->pub->field_0xb & 0xef; + model->pub->ttl = ttl; + model->pub->period = period; + model->pub->retransmit = retransmit; + if (model->pub->update == (anon_subr_int_bt_mesh_model_ptr_for_update *)0x0) { + return '\0'; + } + delay = bt_mesh_model_pub_period_get(model); + work = &model->pub->timer; + if (delay != 0) { + k_delayed_work_submit(work,delay); + return '\0'; + } + } + k_delayed_work_cancel(work); + return '\0'; +} + + + +u8_t mod_unbind(bt_mesh_model *model,u16_t key_idx) + +{ + ushort *puVar1; + undefined2 in_register_0000202e; + + puVar1 = model->keys; + do { + if ((uint)*puVar1 == CONCAT22(in_register_0000202e,key_idx)) { + *puVar1 = 0xffff; + if ((model->pub != (bt_mesh_model_pub *)0x0) && + ((uint)model->pub->key == CONCAT22(in_register_0000202e,key_idx))) { + _mod_pub_set(model,0,0,'\0','\0','\0','\0'); + } + } + puVar1 = puVar1 + 1; + } while (puVar1 != model->groups); + return '\0'; +} + + + +void create_mod_app_status + (net_buf_simple *msg,_Bool vnd,u16_t elem_addr,u16_t app_idx,u8_t status,u8_t *mod_id + ) + +{ + void *__dest; + undefined3 in_register_0000202d; + size_t __n; + + bt_mesh_model_msg_init(msg,0x803e); + net_buf_simple_add_u8(msg,status); + net_buf_simple_add_le16(msg,elem_addr); + net_buf_simple_add_le16(msg,app_idx); + if (CONCAT31(in_register_0000202d,vnd) == 0) { + __dest = net_buf_simple_add(msg,2); + __n = 2; + } + else { + __dest = net_buf_simple_add(msg,4); + __n = 4; + } + memcpy(__dest,mod_id,__n); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void send_mod_pub_status(bt_mesh_model *cfg_mod,bt_mesh_msg_ctx *ctx,u16_t elem_addr,u16_t pub_addr, + _Bool vnd,u8_t status,u8_t *mod_id) + +{ + void *__s; + int iVar1; + size_t __n; + undefined3 in_register_00002039; + undefined3 in_register_0000203d; + int *piVar2; + void *in_a7; + u8_t **ppuStack64; + net_buf_simple msg; + u8_t net_buf_data_msg [20]; + + piVar2 = (int *)CONCAT31(in_register_0000203d,status); + ppuStack64 = &msg.__buf; + msg.data = (u8_t *)0x140000; + msg._4_4_ = &msg.__buf; + bt_mesh_model_msg_init((net_buf_simple *)&ppuStack64,0x8019); + net_buf_simple_add_u8((net_buf_simple *)&ppuStack64,(u8_t)mod_id); + net_buf_simple_add_le16((net_buf_simple *)&ppuStack64,elem_addr); + if (mod_id == (u8_t *)0x0) { + net_buf_simple_add_le16((net_buf_simple *)&ppuStack64,pub_addr); + net_buf_simple_add_le16 + ((net_buf_simple *)&ppuStack64, + *(ushort *)(*piVar2 + 6) | (ushort)((*(uint *)(*piVar2 + 8) >> 0x1c & 1) << 0xc)); + net_buf_simple_add_u8((net_buf_simple *)&ppuStack64,*(u8_t *)(*piVar2 + 8)); + net_buf_simple_add_u8((net_buf_simple *)&ppuStack64,*(u8_t *)(*piVar2 + 10)); + net_buf_simple_add_u8((net_buf_simple *)&ppuStack64,*(u8_t *)(*piVar2 + 9)); + } + else { + __s = net_buf_simple_add((net_buf_simple *)&ppuStack64,7); + memset(__s,0,7); + } + if (CONCAT31(in_register_00002039,vnd) == 0) { + __s = net_buf_simple_add((net_buf_simple *)&ppuStack64,2); + __n = 2; + } + else { + __s = net_buf_simple_add((net_buf_simple *)&ppuStack64,4); + __n = 4; + } + memcpy(__s,in_a7,__n); + iVar1 = bt_mesh_model_send(cfg_mod,ctx,(net_buf_simple *)&ppuStack64,(bt_mesh_send_cb *)0x0, + (void *)0x0); + if (iVar1 != 0) { + printf("Unable to send Model Publication Status\r\n"); + } + return; +} + + + +bt_mesh_model * get_model(bt_mesh_elem *elem,net_buf_simple *buf,_Bool *vnd) + +{ + u16_t company; + u16_t id; + bt_mesh_model *pbVar1; + + if (buf->len < 4) { + company = net_buf_simple_pull_le16(buf); + *vnd = false; + pbVar1 = bt_mesh_model_find(elem,company); + return pbVar1; + } + company = net_buf_simple_pull_le16(buf); + id = net_buf_simple_pull_le16(buf); + *vnd = true; + pbVar1 = bt_mesh_model_find_vnd(elem,company,id); + return pbVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void mod_app_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t val; + u16_t addr; + char *fmt; + int iVar1; + bt_mesh_model *elem; + u32_t_conflict opcode; + size_t len; + u8_t *mem; + _Bool _Stack65; + _Bool vnd; + u8_t **ppuStack64; + net_buf_simple msg; + u8_t net_buf_data_msg [19]; + + ppuStack64 = &msg.__buf; + msg.data = (u8_t *)0x130000; + msg._4_4_ = &msg.__buf; + addr = net_buf_simple_pull_le16(buf); + if ((short)addr < 1) { + fmt = "Prohibited element address\r\n"; + } + else { + mem = buf->data; + elem = (bt_mesh_model *)bt_mesh_elem_find(addr); + if (elem == (bt_mesh_model *)0x0) { + val = '\x01'; + _Stack65 = buf->len == 4; + } + else { + elem = get_model((bt_mesh_elem *)elem,buf,&_Stack65); + val = (elem == (bt_mesh_model *)0x0) << 1; + } + if (_Stack65 == false) { + opcode = 0x804c; + } + else { + opcode = 0x804e; + } + bt_mesh_model_msg_init((net_buf_simple *)&stack0xffffffc0,opcode); + net_buf_simple_add_u8((net_buf_simple *)&stack0xffffffc0,val); + net_buf_simple_add_le16((net_buf_simple *)&stack0xffffffc0,addr); + len = 4; + if (_Stack65 == false) { + len = 2; + } + net_buf_simple_add_mem((net_buf_simple *)&stack0xffffffc0,mem,len); + if (elem != (bt_mesh_model *)0x0) { + if (elem->keys[0] != 0xffff) { + net_buf_simple_add_le16((net_buf_simple *)&stack0xffffffc0,elem->keys[0]); + } + addr = *(u16_t *)((int)elem->keys + 2); + if (addr != 0xffff) { + net_buf_simple_add_le16((net_buf_simple *)&stack0xffffffc0,addr); + } + } + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)&stack0xffffffc0,(bt_mesh_send_cb *)0x0, + (void *)0x0); + if (iVar1 == 0) { + return; + } + fmt = "Unable to send Model Application List message\r\n"; + } + printf(fmt); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void mod_app_unbind(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + _Bool _Var1; + u8_t status; + u16_t addr; + u16_t app_idx; + char *fmt; + bt_mesh_elem *elem; + int iVar2; + bt_mesh_model *model_00; + undefined3 extraout_var; + u8_t *mod_id; + _Bool _Stack61; + _Bool vnd; + u8_t **ppuStack60; + net_buf_simple msg; + u8_t net_buf_data_msg [15]; + + ppuStack60 = &msg.__buf; + msg.data = (u8_t *)0xf0000; + msg._4_4_ = &msg.__buf; + addr = net_buf_simple_pull_le16(buf); + if ((short)addr < 1) { + fmt = "Prohibited element address\r\n"; + } + else { + app_idx = net_buf_simple_pull_le16(buf); + mod_id = buf->data; + elem = bt_mesh_elem_find(addr); + if (elem == (bt_mesh_elem *)0x0) { + status = '\x01'; + _Stack61 = buf->len == 4; + } + else { + model_00 = get_model(elem,buf,&_Stack61); + status = '\x02'; + if (model_00 != (bt_mesh_model *)0x0) { + _Var1 = app_key_is_valid(app_idx); + status = '\x03'; + if (CONCAT31(extraout_var,_Var1) != 0) { + status = mod_unbind(model_00,app_idx); + } + } + } + create_mod_app_status + ((net_buf_simple *)&stack0xffffffc4,(_Bool)_Stack61,addr,app_idx,status,mod_id); + iVar2 = bt_mesh_model_send(model,ctx,(net_buf_simple *)&stack0xffffffc4,(bt_mesh_send_cb *)0x0, + (void *)0x0); + if (iVar2 == 0) { + return; + } + fmt = "Unable to send Model App Unbind Status response\r\n"; + } + printf(fmt); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void mod_app_bind(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + _Bool _Var1; + u16_t addr; + u16_t app_idx; + char *fmt; + undefined2 extraout_var_00; + bt_mesh_elem *elem; + int iVar2; + bt_mesh_model *pbVar3; + undefined3 extraout_var; + u8_t status; + u8_t *mod_id; + _Bool _Stack61; + _Bool vnd; + u8_t **ppuStack60; + net_buf_simple msg; + u8_t net_buf_data_msg [15]; + + ppuStack60 = &msg.__buf; + msg.data = (u8_t *)0xf0000; + msg._4_4_ = &msg.__buf; + addr = net_buf_simple_pull_le16(buf); + if ((short)addr < 1) { + fmt = "Prohibited element address\r\n"; + goto LAB_2303eb02; + } + app_idx = net_buf_simple_pull_le16(buf); + mod_id = buf->data; + elem = bt_mesh_elem_find(addr); + if (elem == (bt_mesh_elem *)0x0) { + status = '\x01'; + _Stack61 = buf->len == 4; + } + else { + pbVar3 = get_model(elem,buf,&_Stack61); + status = '\x02'; + if (pbVar3 != (bt_mesh_model *)0x0) { + if (pbVar3 == model) { + printf("Client tried to bind AppKey to Configuration Model\r\n"); + status = '\r'; + } + else { + _Var1 = app_key_is_valid(app_idx); + status = '\x03'; + if (CONCAT31(extraout_var,_Var1) != 0) { + status = '\0'; + if ((CONCAT22(extraout_var_00,app_idx) != (uint)pbVar3->keys[0]) && + (CONCAT22(extraout_var_00,app_idx) != (uint)pbVar3->keys[1])) { + if (pbVar3->keys[0] == 0xffff) { + iVar2 = 0; + } + else { + status = '\x05'; + if (pbVar3->keys[1] != 0xffff) goto send_status; + iVar2 = 1; + } + pbVar3->keys[iVar2] = app_idx; + status = '\0'; + } + } + } + } + } +send_status: + create_mod_app_status + ((net_buf_simple *)&stack0xffffffc4,(_Bool)_Stack61,addr,app_idx,status,mod_id); + iVar2 = bt_mesh_model_send(model,ctx,(net_buf_simple *)&stack0xffffffc4,(bt_mesh_send_cb *)0x0, + (void *)0x0); + if (iVar2 == 0) { + return; + } + fmt = "Unable to send Model App Bind Status response\r\n"; +LAB_2303eb02: + printf(fmt); + return; +} + + + +// WARNING: Variable defined which should be unmapped: vnd + +void mod_pub_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t ttl; + u8_t period; + u8_t retransmit; + char elem; + u16_t addr; + u16_t pub_addr; + u16_t uVar1; + undefined3 extraout_var; + bt_mesh_model *model_00; + undefined3 extraout_var_00; + u8_t *mod_id; + _Bool a_Stack49 [4]; + _Bool vnd; + + addr = net_buf_simple_pull_le16(buf); + if ((short)addr < 1) { + printf("Prohibited element address\r\n"); + } + else { + pub_addr = net_buf_simple_pull_le16(buf); + uVar1 = net_buf_simple_pull_le16(buf); + ttl = net_buf_simple_pull_u8(buf); + if ((CONCAT31(extraout_var,ttl) - 0x80U & 0xff) < 0x7f) { + printf("Invalid TTL value 0x%02x\r\n",CONCAT31(extraout_var,ttl)); + } + else { + period = net_buf_simple_pull_u8(buf); + retransmit = net_buf_simple_pull_u8(buf); + _elem = bt_mesh_elem_find(addr); + elem = (char)_elem; + if (_elem == (bt_mesh_elem *)0x0) { + mod_id = &DAT_00000001; + a_Stack49[0] = buf->len == 4; + } + else { + model_00 = get_model(_elem,buf,a_Stack49); + elem = (char)model_00; + mod_id = (u8_t *)0x2; + if (model_00 != (bt_mesh_model *)0x0) { + ttl = _mod_pub_set(model_00,pub_addr,(ushort)(((uint)uVar1 << 0x14) >> 0x14), + (byte)(uVar1 >> 0xc) & 1,ttl,period,retransmit); + mod_id = (u8_t *)CONCAT31(extraout_var_00,ttl); + } + } + send_mod_pub_status(model,ctx,addr,pub_addr,(_Bool)a_Stack49[0],elem + '\b',mod_id); + } + } + return; +} + + + +void mod_pub_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + char cVar1; + u16_t addr; + bt_mesh_elem *elem; + u16_t pub_addr; + u8_t *mod_id; + _Bool a_Stack33 [4]; + _Bool vnd; + + addr = net_buf_simple_pull_le16(buf); + if ((short)addr < 1) { + printf("Prohibited element address\r\n"); + return; + } + elem = bt_mesh_elem_find(addr); + cVar1 = (char)elem; + if (elem == (bt_mesh_elem *)0x0) { + mod_id = &DAT_00000001; + a_Stack33[0] = buf->len == 4; + } + else { + _cVar1 = get_model(elem,buf,a_Stack33); + cVar1 = (char)_cVar1; + if (_cVar1 == (bt_mesh_model *)0x0) { + mod_id = (u8_t *)0x2; + } + else { + if (_cVar1->pub != (bt_mesh_model_pub *)0x0) { + pub_addr = _cVar1->pub->addr; + mod_id = (u8_t *)0x0; + goto send_status; + } + mod_id = (u8_t *)0x7; + } + } + pub_addr = 0; +send_status: + send_mod_pub_status(model,ctx,addr,pub_addr,(_Bool)a_Stack33[0],cVar1 + '\b',mod_id); + return; +} + + + +void mod_sub_del(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u16_t addr; + bt_mesh_elem *elem; + bt_mesh_model *mod; + u16_t *puVar1; + u8_t status; + u8_t *mod_id; + _Bool _Stack35; + u16_t uStack34; + _Bool vnd; + u16_t sub_addr; + + addr = net_buf_simple_pull_le16(buf); + if ((short)addr < 1) { + printf("Prohibited element address\r\n"); + } + else { + uStack34 = net_buf_simple_pull_le16(buf); + mod_id = buf->data; + elem = bt_mesh_elem_find(addr); + if (elem == (bt_mesh_elem *)0x0) { + status = '\x01'; + _Stack35 = buf->len == 4; + } + else { + mod = get_model(elem,buf,&_Stack35); + status = '\x02'; + if ((mod != (bt_mesh_model *)0x0) && (status = '\x01', (ushort)(uStack34 + 0x4000) < 0x3f01)) + { + bt_mesh_lpn_group_del(&uStack34,1); + puVar1 = bt_mesh_model_find_group(mod,uStack34); + status = '\0'; + if (puVar1 != (u16_t *)0x0) { + *puVar1 = 0; + } + } + } + send_mod_sub_status(model,ctx,status,addr,uStack34,mod_id,(_Bool)_Stack35); + } + return; +} + + + +void mod_sub_add(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u16_t addr; + u16_t addr_00; + bt_mesh_elem *elem; + bt_mesh_model *mod; + u16_t *puVar1; + u8_t status; + u8_t *mod_id; + _Bool a_Stack33 [4]; + _Bool vnd; + + addr = net_buf_simple_pull_le16(buf); + if ((short)addr < 1) { + printf("Prohibited element address\r\n"); + return; + } + addr_00 = net_buf_simple_pull_le16(buf); + mod_id = buf->data; + elem = bt_mesh_elem_find(addr); + if (elem == (bt_mesh_elem *)0x0) { + status = '\x01'; + a_Stack33[0] = buf->len == 4; + } + else { + mod = get_model(elem,buf,a_Stack33); + status = '\x02'; + if ((mod != (bt_mesh_model *)0x0) && (status = '\x01', (ushort)(addr_00 + 0x4000) < 0x3f01)) { + puVar1 = bt_mesh_model_find_group(mod,addr_00); + status = '\0'; + if (puVar1 == (u16_t *)0x0) { + if (mod->groups[0] == 0) { + mod->groups[0] = addr_00; + } + else { + status = '\x05'; + if (mod->groups[1] != 0) goto send_status; + mod->groups[1] = addr_00; + } + bt_mesh_lpn_group_add(addr_00); + status = '\0'; + } + } + } +send_status: + send_mod_sub_status(model,ctx,status,addr,addr_00,mod_id,(_Bool)a_Stack33[0]); + return; +} + + + +// WARNING: Variable defined which should be unmapped: vnd + +void mod_sub_va_del(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u16_t addr; + void *__s2; + bt_mesh_elem *elem; + bt_mesh_model *mod; + u16_t *puVar1; + int iVar2; + u8_t status; + u8_t *mod_id; + _Bool _Stack35; + u16_t uStack34; + _Bool vnd; + u16_t sub_addr; + + addr = net_buf_simple_pull_le16(buf); + if ((short)addr < 1) { + printf("Prohibited element address\r\n"); + } + else { + __s2 = net_buf_simple_pull_mem(buf,0x10); + mod_id = buf->data; + elem = bt_mesh_elem_find(addr); + if (elem == (bt_mesh_elem *)0x0) { + uStack34 = 0; + status = '\x01'; + _Stack35 = buf->len == 4; + } + else { + mod = get_model(elem,buf,&_Stack35); + if (mod == (bt_mesh_model *)0x0) { + uStack34 = 0; + status = '\x02'; + } + else { + iVar2 = memcmp(labels[0].uuid,__s2,0x10); + if (iVar2 == 0) { + uStack34 = labels[0].addr; + status = '\0'; + labels[0].ref = labels[0].ref - 1; + if (labels[0].addr != 0) { + bt_mesh_lpn_group_del(&uStack34,1); + puVar1 = bt_mesh_model_find_group(mod,uStack34); + status = '\f'; + if (puVar1 != (u16_t *)0x0) { + *puVar1 = 0; + status = '\0'; + } + } + } + else { + uStack34 = 0; + status = '\f'; + } + } + } + send_mod_sub_status(model,ctx,status,addr,uStack34,mod_id,(_Bool)_Stack35); + } + return; +} + + + +u8_t va_add(u8_t *label_uuid,u16_t *addr) + +{ + int iVar1; + + if (labels[0].ref == 0) { + iVar1 = bt_mesh_virtual_addr(label_uuid,addr); + if (iVar1 < 0) { + return '\x10'; + } + labels[0].ref = 1; + labels[0].addr = *addr; + memcpy(labels[0].uuid,label_uuid,0x10); + } + else { + iVar1 = memcmp(labels[0].uuid,label_uuid,0x10); + if (iVar1 != 0) { + return '\x05'; + } + *addr = labels[0].addr; + labels[0].ref = labels[0].ref + 1; + } + return '\0'; +} + + + +// WARNING: Variable defined which should be unmapped: vnd + +void mod_pub_va_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t ttl; + u8_t period; + u8_t retransmit; + char elem; + u16_t addr; + u16_t uVar1; + u8_t *virtual_label; + undefined3 extraout_var; + u8_t *mod_id; + bt_mesh_model *model_00; + int iVar2; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + _Bool _Stack51; + u16_t local_32; + _Bool vnd; + u16_t pub_addr; + + addr = net_buf_simple_pull_le16(buf); + if ((short)addr < 1) { + printf("Prohibited element address\r\n"); + } + else { + virtual_label = (u8_t *)net_buf_simple_pull_mem(buf,0x10); + uVar1 = net_buf_simple_pull_le16(buf); + ttl = net_buf_simple_pull_u8(buf); + if ((CONCAT31(extraout_var,ttl) - 0x80U & 0xff) < 0x7f) { + printf("Invalid TTL value 0x%02x\r\n",CONCAT31(extraout_var,ttl)); + } + else { + period = net_buf_simple_pull_u8(buf); + retransmit = net_buf_simple_pull_u8(buf); + _elem = bt_mesh_elem_find(addr); + elem = (char)_elem; + if (_elem == (bt_mesh_elem *)0x0) { + local_32 = 0; + mod_id = &DAT_00000001; + _Stack51 = buf->len == 4; + } + else { + model_00 = get_model(_elem,buf,&_Stack51); + elem = (char)model_00; + if (model_00 == (bt_mesh_model *)0x0) { + local_32 = 0; + mod_id = (u8_t *)0x2; + } + else { + iVar2 = bt_mesh_virtual_addr(virtual_label,&local_32); + if (iVar2 < 0) { + local_32 = 0; + mod_id = &DAT_00000010; + } + else { + ttl = _mod_pub_set(model_00,local_32,(ushort)(((uint)uVar1 << 0x14) >> 0x14), + (byte)(uVar1 >> 0xc) & 1,ttl,period,retransmit); + mod_id = (u8_t *)CONCAT31(extraout_var_00,ttl); + if (mod_id == (u8_t *)0x0) { + ttl = va_add(virtual_label,&local_32); + mod_id = (u8_t *)CONCAT31(extraout_var_01,ttl); + } + } + } + } + send_mod_pub_status(model,ctx,addr,local_32,(_Bool)_Stack51,elem + '\b',mod_id); + } + } + return; +} + + + +void mod_sub_va_add(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t status; + u16_t addr; + u8_t *label_uuid; + bt_mesh_elem *elem; + bt_mesh_model *mod; + undefined3 extraout_var; + u16_t *puVar1; + int iVar2; + u8_t *mod_id; + _Bool _Stack35; + u16_t local_22; + _Bool vnd; + u16_t sub_addr; + + addr = net_buf_simple_pull_le16(buf); + if ((short)addr < 1) { + printf("Prohibited element address\r\n"); + return; + } + label_uuid = (u8_t *)net_buf_simple_pull_mem(buf,0x10); + mod_id = buf->data; + elem = bt_mesh_elem_find(addr); + if (elem == (bt_mesh_elem *)0x0) { + local_22 = 0; + status = '\x01'; + _Stack35 = buf->len == 4; + } + else { + mod = get_model(elem,buf,&_Stack35); + if (mod == (bt_mesh_model *)0x0) { + local_22 = 0; + status = '\x02'; + } + else { + status = va_add(label_uuid,&local_22); + if ((CONCAT31(extraout_var,status) == 0) && + (puVar1 = bt_mesh_model_find_group(mod,local_22), puVar1 == (u16_t *)0x0)) { + if (mod->groups[0] == 0) { + iVar2 = 0; + } + else { + if (mod->groups[1] != 0) { + status = '\x05'; + goto send_status; + } + iVar2 = 1; + } + *(u16_t *)((int)&mod->field_0 + (iVar2 + 8) * 2) = local_22; + bt_mesh_lpn_group_add(local_22); + } + } + } +send_status: + send_mod_sub_status(model,ctx,status,addr,local_22,mod_id,(_Bool)_Stack35); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void dev_comp_data_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + bt_mesh_elem *pbVar1; + u8_t uVar2; + undefined3 extraout_var; + bt_mesh_comp *pbVar3; + int iVar4; + size_t sVar5; + uint uVar6; + bt_mesh_model *pbVar7; + u8_t **ppuStack132; + net_buf_simple sdu; + u8_t net_buf_data_sdu [72]; + + ppuStack132 = &sdu.__buf; + sdu.data = (u8_t *)0x480000; + sdu._4_4_ = &sdu.__buf; + uVar2 = net_buf_simple_pull_u8(buf); + if (CONCAT31(extraout_var,uVar2) != 0) { + printf("Composition page %u not available\r\n",CONCAT31(extraout_var,uVar2)); + } + bt_mesh_model_msg_init((net_buf_simple *)&ppuStack132,2); + net_buf_simple_add_u8((net_buf_simple *)&ppuStack132,'\0'); + pbVar3 = bt_mesh_comp_get(); + net_buf_simple_add_le16((net_buf_simple *)&ppuStack132,pbVar3->cid); + uVar6 = 0; + net_buf_simple_add_le16((net_buf_simple *)&ppuStack132,pbVar3->pid); + net_buf_simple_add_le16((net_buf_simple *)&ppuStack132,pbVar3->vid); + net_buf_simple_add_le16((net_buf_simple *)&ppuStack132,5); + net_buf_simple_add_le16((net_buf_simple *)&ppuStack132,0xf); + do { + if (pbVar3->elem_count <= uVar6) { + iVar4 = bt_mesh_model_send(model,ctx,(net_buf_simple *)&ppuStack132,(bt_mesh_send_cb *)0x0, + (void *)0x0); + if (iVar4 != 0) { + iVar4 = 600; +LAB_2303f34e: + printf(&UNK_230b8000 + iVar4); + } + return; + } + pbVar1 = pbVar3->elem + uVar6; + sVar5 = net_buf_simple_tailroom((net_buf_simple *)&ppuStack132); + if (sVar5 < ((uint)pbVar1->model_count + (uint)pbVar1->vnd_model_count + 2) * 2) { + printf("Too large device composition\r\n"); + iVar4 = 0x234; + goto LAB_2303f34e; + } + net_buf_simple_add_le16((net_buf_simple *)&ppuStack132,pbVar1->loc); + net_buf_simple_add_u8((net_buf_simple *)&ppuStack132,pbVar1->model_count); + net_buf_simple_add_u8((net_buf_simple *)&ppuStack132,pbVar1->vnd_model_count); + iVar4 = 0; + while (iVar4 < (int)(uint)pbVar1->model_count) { + net_buf_simple_add_le16 + ((net_buf_simple *)&ppuStack132,*(u16_t *)&pbVar1->models[iVar4].field_0); + iVar4 = iVar4 + 1; + } + iVar4 = 0; + while (iVar4 < (int)(uint)pbVar1->vnd_model_count) { + pbVar7 = pbVar1->vnd_models; + net_buf_simple_add_le16((net_buf_simple *)&ppuStack132,*(u16_t *)&pbVar7[iVar4].field_0); + net_buf_simple_add_le16 + ((net_buf_simple *)&ppuStack132,*(u16_t *)((int)&pbVar7[iVar4].field_0 + 2)); + iVar4 = iVar4 + 1; + } + uVar6 = uVar6 + 1; + } while( true ); +} + + + +// WARNING: Type propagation algorithm not settling + +u8_t app_key_set(u16_t net_idx,u16_t app_idx,u8_t *val,_Bool update) + +{ + ushort uVar1; + undefined2 in_register_0000202a; + bt_mesh_subnet *pbVar2; + bt_mesh_app_key *pbVar3; + int iVar4; + undefined3 in_register_00002035; + bt_mesh_app_keys *out; + + pbVar2 = bt_mesh_subnet_get(net_idx); + if (pbVar2 == (bt_mesh_subnet *)0x0) { + return '\x04'; + } + pbVar3 = bt_mesh_app_key_find(app_idx); + if (CONCAT31(in_register_00002035,update) == 0) { + if (pbVar3 != (bt_mesh_app_key *)0x0) { + uVar1 = pbVar3->net_idx; + if ((uint)uVar1 != CONCAT22(in_register_0000202a,net_idx)) { + return '\x04'; + } + iVar4 = memcmp(pbVar3->keys[0].val,val,0x10); + if (iVar4 != 0) { + if ((uint)pbVar3->net_idx != (uint)uVar1) { + return '\x04'; + } + return '\x06'; + } + return '\0'; + } + if (bt_mesh.app_keys[0].net_idx == 0xffff) { + iVar4 = -0x790; + } + else { + if (bt_mesh.app_keys[1].net_idx != 0xffff) { + return '\x05'; + } + iVar4 = -0x768; + } + pbVar3 = (bt_mesh_app_key *)((int)&attrs[5].write + iVar4); + out = (bt_mesh_app_keys *)((int)&attrs[5].user_data + iVar4 + 1); + } + else { + if (pbVar3 == (bt_mesh_app_key *)0x0) { + return '\x03'; + } + if ((uint)pbVar3->net_idx != CONCAT22(in_register_0000202a,net_idx)) { + return '\x11'; + } + if (pbVar2->kr_phase != '\x01') { + return '\v'; + } + if (pbVar3->updated != false) { + iVar4 = memcmp(pbVar3->keys[1].val,val,0x10); + if (iVar4 == 0) { + return '\0'; + } + return '\v'; + } + out = pbVar3->keys + 1; + pbVar3->updated = true; + } + iVar4 = bt_mesh_k4(val,(u8_t *)out); + if (iVar4 == 0) { + pbVar3->net_idx = net_idx; + pbVar3->app_idx = app_idx; + memcpy(out->val,val,0x10); + return '\0'; + } + if (CONCAT31(in_register_00002035,update) != 0) { + pbVar3->updated = false; + return '\t'; + } + return '\t'; +} + + + +// WARNING: Variable defined which should be unmapped: msg + +void app_key_update(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t val; + int iVar1; + u16_t uStack44; + u16_t uStack42; + u16_t key_net_idx; + u16_t key_app_idx; + u8_t net_buf_data_msg [10]; + net_buf_simple msg; + + register0x0000203c = &key_net_idx; + key_idx_unpack(buf,&uStack44,&uStack42); + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 8),0x8003); + val = app_key_set(uStack44,uStack42,buf->data,true); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 8),val); + key_idx_pack((net_buf_simple *)(net_buf_data_msg + 8),uStack44,uStack42); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 8), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar1 != 0) { + printf("Unable to send App Key Status response\r\n"); + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: msg + +void app_key_add(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t val; + int iVar1; + u16_t uStack44; + u16_t uStack42; + u16_t key_net_idx; + u16_t key_app_idx; + u8_t net_buf_data_msg [10]; + net_buf_simple msg; + + register0x0000203c = &key_net_idx; + key_idx_unpack(buf,&uStack44,&uStack42); + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 8),0x8003); + val = app_key_set(uStack44,uStack42,buf->data,false); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 8),val); + key_idx_pack((net_buf_simple *)(net_buf_data_msg + 8),uStack44,uStack42); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 8), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar1 != 0) { + printf("Unable to send App Key Status response\r\n"); + } + return; +} + + + +u16_t hb_pwr2(u8_t val) + +{ + undefined3 in_register_00002029; + int iVar1; + + iVar1 = CONCAT31(in_register_00002029,val); + if (iVar1 == 0) { + return 0; + } + if ((iVar1 != 0xff) && (iVar1 != 0x11)) { + return (u16_t)(1 << (iVar1 - 1U & 0x1f)); + } + return 0xffff; +} + + + +void hb_publish(k_work *work) + +{ + ushort uVar1; + short sVar2; + u16_t uVar3; + bt_mesh_subnet *pbVar4; + undefined2 extraout_var; + uint delay; + + pbVar4 = bt_mesh_subnet_get(*(u16_t *)work[3].flags); + if (pbVar4 == (bt_mesh_subnet *)0x0) { + printf("No matching subnet for idx 0x%02x\r\n",(uint)*(ushort *)work[3].flags); + *(undefined2 *)&work[3]._reserved = 0; + } + else { + uVar1 = *(ushort *)((int)&work[3]._reserved + 2); + if (uVar1 != 0) { + uVar3 = hb_pwr2(*(u8_t *)&work[3].handler); + delay = (uint)(CONCAT22(extraout_var,uVar3) * 0x3e80000) >> 0x10; + if ((delay != 0) && (1 < uVar1)) { + k_delayed_work_submit((k_delayed_work *)work,delay); + } + bt_mesh_heartbeat_send(); + sVar2 = *(short *)((int)&work[3]._reserved + 2); + if (sVar2 != -1) { + *(short *)((int)&work[3]._reserved + 2) = sVar2 + -1; + } + } + } + return; +} + + + +void heartbeat_pub_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + undefined uVar1; + ushort uVar2; + ushort net_idx; + ushort uVar3; + void *pvVar4; + u16_t uVar5; + char *fmt; + bt_mesh_subnet *pbVar6; + u8_t status; + hb_pub_param *orig_msg; + + orig_msg = (hb_pub_param *)buf->data; + uVar2 = *(ushort *)&orig_msg->status; + if ((uVar2 ^ 0x8000) < 0x4000) { + status = '\x01'; + goto LAB_2303f77e; + } + if (((byte)(*(char *)((int)&orig_msg->status + 2) - 0x12U) < 0xed) || + (0x10 < *(byte *)((int)&orig_msg->status + 3))) { + status = '\x0f'; + goto LAB_2303f77e; + } + if ((*(byte *)&orig_msg->pub ^ 0x80) < 0x7f) { + fmt = "Invalid TTL value 0x%02x\r\n"; +LAB_2303f6d8: + printf(fmt); + return; + } + net_idx = *(ushort *)((int)&orig_msg->pub + 3); + if (0xfff < net_idx) { + fmt = "Invalid NetKeyIndex 0x%04x\r\n"; + goto LAB_2303f6d8; + } + uVar3 = *(ushort *)((int)&orig_msg->pub + 1); + pvVar4 = model->user_data; + pbVar6 = bt_mesh_subnet_get(net_idx); + if (pbVar6 == (bt_mesh_subnet *)0x0) { + status = '\x04'; + goto LAB_2303f77e; + } + *(ushort *)((int)pvVar4 + 0x30) = uVar2; + uVar1 = *(undefined *)((int)&orig_msg->status + 3); + *(ushort *)((int)pvVar4 + 0x36) = uVar3 & 0xf; + *(undefined *)((int)pvVar4 + 0x34) = uVar1; + *(ushort *)((int)pvVar4 + 0x38) = net_idx; + if (uVar2 == 0) { + *(undefined4 *)((int)pvVar4 + 0x30) = 0; + *(undefined2 *)((int)pvVar4 + 0x34) = 0; +LAB_2303f74e: + k_delayed_work_cancel((k_delayed_work *)((int)pvVar4 + 0xc)); + } + else { + uVar5 = hb_pwr2(*(u8_t *)((int)&orig_msg->status + 2)); + *(u16_t *)((int)pvVar4 + 0x32) = uVar5; + *(undefined *)((int)pvVar4 + 0x35) = *(undefined *)&orig_msg->pub; + if ((*(char *)((int)&orig_msg->status + 3) == '\0') || + (*(char *)((int)&orig_msg->status + 2) == '\0')) goto LAB_2303f74e; + k_work_submit((k_work *)(k_delayed_work *)((int)pvVar4 + 0xc)); + } + orig_msg = (hb_pub_param *)0x0; + status = '\0'; +LAB_2303f77e: + hb_pub_send_status(model,ctx,status,orig_msg); + return; +} + + + +void _mod_unbind(bt_mesh_model *mod,bt_mesh_elem *elem,_Bool vnd,_Bool primary,void *user_data) + +{ + u16_t app_idx; + _Bool _Var1; + undefined3 extraout_var; + + app_idx = *(u16_t *)user_data; + _Var1 = app_key_is_valid(app_idx); + if (CONCAT31(extraout_var,_Var1) != 0) { + mod_unbind(mod,app_idx); + return; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void hb_sub_send_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx) + +{ + ushort uVar1; + void *pvVar2; + bt_mesh_model *pbVar3; + int iVar4; + u8_t val; + bt_mesh_msg_ctx *pbVar5; + USItype x; + u8_t **ppuStack60; + net_buf_simple msg; + u8_t net_buf_data_msg [15]; + + ppuStack60 = &msg.__buf; + pvVar2 = model->user_data; + msg.data = (u8_t *)0xf0000; + msg._4_4_ = &msg.__buf; + pbVar3 = model; + pbVar5 = ctx; + k_uptime_get(); + if (((int)*(bt_mesh_msg_ctx **)((int)pvVar2 + 0x44) < (int)pbVar5) || + ((pbVar5 == *(bt_mesh_msg_ctx **)((int)pvVar2 + 0x44) && + (*(bt_mesh_model **)((int)pvVar2 + 0x40) < pbVar3)))) { + x = 0; + } + else { + pbVar3 = (bt_mesh_model *)((int)*(bt_mesh_model **)((int)pvVar2 + 0x40) - (int)pbVar3); + __divdi3(); + x = (uint)pbVar3 & 0xffff; + } + bt_mesh_model_msg_init((net_buf_simple *)&ppuStack60,0x803c); + net_buf_simple_add_u8((net_buf_simple *)&ppuStack60,'\0'); + net_buf_simple_add_le16((net_buf_simple *)&ppuStack60,*(u16_t *)((int)pvVar2 + 0x48)); + net_buf_simple_add_le16((net_buf_simple *)&ppuStack60,*(u16_t *)((int)pvVar2 + 0x4a)); + val = '\0'; + if ((x != 0) && (val = -1, x != 0xffff)) { + iVar4 = __clzsi2(x); + val = ' ' - (char)iVar4; + } + net_buf_simple_add_u8((net_buf_simple *)&ppuStack60,val); + uVar1 = *(ushort *)((int)pvVar2 + 0x4c); + val = '\0'; + if ((uVar1 != 0) && (val = -1, uVar1 != 0xffff)) { + iVar4 = __clzsi2((uint)uVar1); + val = ' ' - (char)iVar4; + } + net_buf_simple_add_u8((net_buf_simple *)&ppuStack60,val); + net_buf_simple_add_u8((net_buf_simple *)&ppuStack60,*(u8_t *)((int)pvVar2 + 0x4e)); + net_buf_simple_add_u8((net_buf_simple *)&ppuStack60,*(u8_t *)((int)pvVar2 + 0x4f)); + iVar4 = bt_mesh_model_send(model,ctx,(net_buf_simple *)&ppuStack60,(bt_mesh_send_cb *)0x0, + (void *)0x0); + if (iVar4 != 0) { + printf("Unable to send Heartbeat Subscription Status\r\n"); + } + return; +} + + + +void heartbeat_sub_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + void *pvVar1; + + pvVar1 = model->user_data; + if ((*(short *)((int)pvVar1 + 0x48) == 0) || (*(short *)((int)pvVar1 + 0x4a) == 0)) { + *(undefined4 *)((int)pvVar1 + 0x48) = 0; + *(undefined4 *)((int)pvVar1 + 0x4c) = 0; + } + hb_sub_send_status(model,ctx); + return; +} + + + +void heartbeat_sub_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + void *pvVar1; + uint uVar2; + u8_t val; + u16_t uVar3; + u16_t uVar4; + u16_t uVar5; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined3 extraout_var; + char *fmt; + undefined2 extraout_var_02; + uint uVar6; + undefined2 extraout_var_03; + + pvVar1 = model->user_data; + uVar3 = net_buf_simple_pull_le16(buf); + uVar4 = net_buf_simple_pull_le16(buf); + _uVar4 = CONCAT22(extraout_var_01,uVar4); + val = net_buf_simple_pull_u8(buf); + _val = CONCAT31(extraout_var,val); + if (CONCAT22(extraout_var_00,uVar3) << 0x10 < 0) { + fmt = "Prohibited source address\r\n"; + } + else { + if ((0x3fff < (_uVar4 - 0x8000U & 0xffff)) && (0xfb < (_uVar4 + 0x100U & 0xffff))) { + if ((short)uVar4 < 1) { +LAB_2303f98a: + if (0x11 < _val) { + printf("Prohibited subscription period 0x%02x\r\n"); + return; + } + if (((CONCAT22(extraout_var_00,uVar3) == 0) || (_uVar4 == 0)) || (_val == 0)) { + *(undefined4 *)((int)pvVar1 + 0x48) = 0; + *(undefined *)((int)pvVar1 + 0x4e) = 0x7f; + uVar2 = 0; + } + else { + *(u16_t *)((int)pvVar1 + 0x4a) = uVar4; + *(u16_t *)((int)pvVar1 + 0x48) = uVar3; + *(undefined4 *)((int)pvVar1 + 0x4c) = 0x7f0000; + uVar3 = hb_pwr2(val); + uVar2 = CONCAT22(extraout_var_03,uVar3) * 1000; + } + uVar6 = (uint)*(ushort *)((int)pvVar1 + 0x4a); + bt_mesh_set_hb_sub_dst(*(ushort *)((int)pvVar1 + 0x4a)); + if (uVar2 == 0) { + *(undefined4 *)((int)pvVar1 + 0x40) = 0; + *(undefined4 *)((int)pvVar1 + 0x44) = 0; + } + else { + k_uptime_get(); + *(uint *)((int)pvVar1 + 0x40) = uVar6 + uVar2; + *(int *)((int)pvVar1 + 0x44) = ((int)uVar2 >> 0x1f) + _val + (uint)(uVar6 + uVar2 < uVar2) + ; + } + hb_sub_send_status(model,ctx); + if (uVar2 == 0) { + *(undefined *)((int)pvVar1 + 0x4e) = 0; + } + return; + } + uVar5 = bt_mesh_primary_addr(); + if (CONCAT22(extraout_var_02,uVar5) == _uVar4) goto LAB_2303f98a; + } + fmt = "Prohibited destination address\r\n"; + } + printf(fmt); + return; +} + + + +void bt_mesh_app_key_del(bt_mesh_app_key *key,_Bool store) + +{ + u16_t uStack20; + _Bool _Stack18; + unbind_data data; + + uStack20 = key->app_idx; + _Stack18 = store; + bt_mesh_model_foreach(_mod_unbind,&uStack20); + key->net_idx = 0xffff; + memset(key->keys,0,0x22); + key->app_idx = 0xffff; + key->updated = false; + return; +} + + + +// WARNING: Variable defined which should be unmapped: msg + +void app_key_del(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t val; + bt_mesh_subnet *pbVar1; + bt_mesh_app_key *key; + int iVar2; + u16_t uStack44; + u16_t local_2a; + u16_t key_net_idx; + u16_t key_app_idx; + u8_t net_buf_data_msg [10]; + net_buf_simple msg; + + register0x0000203c = &key_net_idx; + key_idx_unpack(buf,&uStack44,&local_2a); + val = '\x04'; + pbVar1 = bt_mesh_subnet_get(uStack44); + if (pbVar1 != (bt_mesh_subnet *)0x0) { + val = '\0'; + key = bt_mesh_app_key_find(local_2a); + if ((key != (bt_mesh_app_key *)0x0) && (val = '\x11', key->net_idx == uStack44)) { + bt_mesh_app_key_del(key,true); + val = '\0'; + } + } + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 8),0x8003); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 8),val); + key_idx_pack((net_buf_simple *)(net_buf_data_msg + 8),uStack44,local_2a); + iVar2 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 8), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar2 != 0) { + printf("Unable to send App Key Status response\r\n"); + } + return; +} + + + +int bt_mesh_cfg_srv_init(bt_mesh_model *model,_Bool primary) + +{ + bt_mesh_cfg_srv *pbVar1; + char *fmt; + undefined3 in_register_0000202d; + + pbVar1 = (bt_mesh_cfg_srv *)model->user_data; + if (pbVar1 == (bt_mesh_cfg_srv *)0x0) { + fmt = "No Configuration Server context provided\r\n"; + } + else { + if (((pbVar1->relay < 3) && (pbVar1->beacon < 2)) && (-1 < (char)pbVar1->default_ttl)) { + model->keys[0] = 0xfffe; + k_delayed_work_init((k_delayed_work *)&pbVar1->hb_pub,hb_publish); + (pbVar1->hb_pub).net_idx = 0xffff; + *(undefined4 *)&(pbVar1->hb_sub).expiry = 0; + *(undefined4 *)((int)&(pbVar1->hb_sub).expiry + 4) = 0; + pbVar1->model = model; + conf = pbVar1; + return 0; + } + fmt = "Invalid values in configuration\r\n"; + } + printf(fmt,CONCAT31(in_register_0000202d,primary)); + return -0x16; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void bt_mesh_heartbeat(u16_t src,u16_t dst,u8_t hops,u16_t feat) + +{ + u16_t uVar1; + bt_mesh_cfg_srv *pbVar2; + anon_subr_void_u16_t_u16_t_u8_t_u16_t_for_func *UNRECOVERED_JUMPTABLE; + undefined2 in_register_0000202a; + uint uVar3; + char *fmt; + uint uVar4; + undefined2 in_register_0000202e; + uint uVar5; + uint uVar6; + undefined3 in_register_00002031; + undefined2 in_register_00002036; + byte bVar7; + uint uVar8; + longlong lVar9; + + pbVar2 = conf; + uVar5 = CONCAT22(in_register_0000202e,dst); + uVar3 = CONCAT22(in_register_0000202a,src); + if (conf == (bt_mesh_cfg_srv *)0x0) { + fmt = "No configuaration server context available\r\n"; + } + else { + if (((uint)(conf->hb_sub).src == uVar3) && ((uint)(conf->hb_sub).dst == uVar5)) { + uVar4 = uVar3; + uVar6 = uVar5; + lVar9 = k_uptime_get(); + uVar8 = *(uint *)((int)&(pbVar2->hb_sub).expiry + 4); + if ((int)uVar6 <= (int)uVar8) { + if ((uVar8 != uVar6) || (uVar4 <= *(uint *)&(pbVar2->hb_sub).expiry)) { + bVar7 = (pbVar2->hb_sub).min_hops; + if (CONCAT31(in_register_00002031,hops) < (uint)bVar7) { + bVar7 = hops; + } + (pbVar2->hb_sub).min_hops = bVar7; + bVar7 = (pbVar2->hb_sub).max_hops; + if ((uint)bVar7 < CONCAT31(in_register_00002031,hops)) { + bVar7 = hops; + } + (pbVar2->hb_sub).max_hops = bVar7; + uVar1 = (pbVar2->hb_sub).count; + if (uVar1 != 0xffff) { + (pbVar2->hb_sub).count = uVar1 + 1; + } + UNRECOVERED_JUMPTABLE = (pbVar2->hb_sub).func; + if (UNRECOVERED_JUMPTABLE != (anon_subr_void_u16_t_u16_t_u8_t_u16_t_for_func *)0x0) { + // WARNING: Could not recover jumptable at 0x2303fc46. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE) + ((u16_t)uVar3,(u16_t)uVar5,(u8_t)CONCAT22(in_register_00002036,feat), + (u16_t)(int)lVar9); + return; + } + return; + } + } + fmt = "Heartbeat subscription period expired\r\n"; + } + else { + fmt = "No subscription for received heartbeat\r\n"; + } + } + printf(fmt); + return; +} + + + +u8_t bt_mesh_net_transmit_get(void) + +{ + u8_t uVar1; + + uVar1 = '\0'; + if (conf != (bt_mesh_cfg_srv *)0x0) { + uVar1 = conf->net_transmit; + } + return uVar1; +} + + + +void net_transmit_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t val; + int iVar1; + u8_t auStack36 [4]; + u8_t net_buf_data_msg [7]; + net_buf_simple msg; + + register0x0000203c = auStack36; + if (model->user_data == (void *)0x0) { + printf("No Configuration Server context available\r\n"); + } + else { + *(u8_t *)((int)model->user_data + 4) = *buf->data; + } + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 4),0x8025); + val = bt_mesh_net_transmit_get(); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 4),val); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 4), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar1 != 0) { + printf("Unable to send Network Transmit Status\r\n"); + } + return; +} + + + +void net_transmit_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t val; + int iVar1; + u8_t auStack36 [4]; + u8_t net_buf_data_msg [7]; + net_buf_simple msg; + + register0x0000203c = auStack36; + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 4),0x8025); + val = bt_mesh_net_transmit_get(); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 4),val); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 4), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar1 != 0) { + printf("Unable to send Config Network Transmit Status\r\n"); + } + return; +} + + + +u8_t bt_mesh_relay_get(void) + +{ + u8_t uVar1; + + uVar1 = '\x02'; + if (conf != (bt_mesh_cfg_srv *)0x0) { + uVar1 = conf->relay; + } + return uVar1; +} + + + +u8_t bt_mesh_friend_get(void) + +{ + u8_t uVar1; + + uVar1 = '\x02'; + if (conf != (bt_mesh_cfg_srv *)0x0) { + uVar1 = conf->frnd; + } + return uVar1; +} + + + +u8_t bt_mesh_relay_retransmit_get(void) + +{ + u8_t uVar1; + + uVar1 = '\0'; + if (conf != (bt_mesh_cfg_srv *)0x0) { + uVar1 = conf->relay_retransmit; + } + return uVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void relay_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + byte bVar1; + byte bVar2; + u8_t val; + int iVar3; + void *pvVar4; + u8_t auStack36 [4]; + u8_t net_buf_data_msg [8]; + net_buf_simple msg; + + net_buf_data_msg._4_4_ = auStack36; + pvVar4 = model->user_data; + if (pvVar4 == (void *)0x0) { + printf("No Configuration Server context available\r\n"); + } + else { + bVar1 = *buf->data; + if (1 < bVar1) { + printf("Invalid Relay value 0x%02x\r\n"); + return; + } + bVar2 = *(byte *)((int)pvVar4 + 5); + if (bVar2 != 2) { + *(byte *)((int)pvVar4 + 5) = bVar1; + *(u8_t *)((int)pvVar4 + 6) = buf->data[1]; + } + if (((*(ushort *)((int)pvVar4 + 0x36) & 1) != 0) && (bVar2 != 2 && bVar1 != bVar2)) { + bt_mesh_heartbeat_send(); + } + } + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 4),0x8028); + val = bt_mesh_relay_get(); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 4),val); + val = bt_mesh_relay_retransmit_get(); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 4),val); + iVar3 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 4), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar3 != 0) { + printf("Unable to send Relay Status response\r\n"); + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void relay_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t val; + int iVar1; + u8_t auStack36 [4]; + u8_t net_buf_data_msg [8]; + net_buf_simple msg; + + net_buf_data_msg._4_4_ = auStack36; + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 4),0x8028); + val = bt_mesh_relay_get(); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 4),val); + val = bt_mesh_relay_retransmit_get(); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 4),val); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 4), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar1 != 0) { + printf("Unable to send Config Relay Status response\r\n"); + } + return; +} + + + +u8_t bt_mesh_beacon_get(void) + +{ + u8_t uVar1; + + uVar1 = '\0'; + if (conf != (bt_mesh_cfg_srv *)0x0) { + uVar1 = conf->beacon; + } + return uVar1; +} + + + +void beacon_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + byte bVar1; + u8_t val; + int iVar2; + void *pvVar3; + u8_t auStack36 [4]; + u8_t net_buf_data_msg [7]; + net_buf_simple msg; + + register0x0000203c = auStack36; + pvVar3 = model->user_data; + if (pvVar3 == (void *)0x0) { + printf("No Configuration Server context available\r\n"); + } + else { + bVar1 = *buf->data; + if (1 < bVar1) { + printf("Invalid Config Beacon value 0x%02x\r\n"); + return; + } + if (*(byte *)((int)pvVar3 + 7) != bVar1) { + *(byte *)((int)pvVar3 + 7) = bVar1; + if (bVar1 == 0) { + bt_mesh_beacon_disable(); + } + else { + bt_mesh_beacon_enable(); + } + } + } + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 4),0x800b); + val = bt_mesh_beacon_get(); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 4),val); + iVar2 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 4), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar2 != 0) { + printf("Unable to send Config Beacon Status response\r\n"); + } + return; +} + + + +void beacon_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t val; + int iVar1; + u8_t auStack36 [4]; + u8_t net_buf_data_msg [7]; + net_buf_simple msg; + + register0x0000203c = auStack36; + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 4),0x800b); + val = bt_mesh_beacon_get(); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 4),val); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 4), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar1 != 0) { + printf("Unable to send Config Beacon Status response\r\n"); + } + return; +} + + + +u8_t bt_mesh_gatt_proxy_get(void) + +{ + u8_t uVar1; + + uVar1 = '\x02'; + if (conf != (bt_mesh_cfg_srv *)0x0) { + uVar1 = conf->gatt_proxy; + } + return uVar1; +} + + + +void node_identity_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t val; + u16_t net_idx; + undefined2 extraout_var_01; + char *fmt; + undefined3 extraout_var; + bt_mesh_subnet *sub; + int iVar1; + undefined3 extraout_var_00; + u8_t auStack56 [4]; + u8_t net_buf_data_msg [10]; + net_buf_simple msg; + + register0x0000203c = auStack56; + net_idx = net_buf_simple_pull_le16(buf); + _val = CONCAT22(extraout_var_01,net_idx); + if (_val < 0x1000) { + val = net_buf_simple_pull_u8(buf); + _val = CONCAT31(extraout_var,val); + if (_val < 2) { + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 8),0x8048); + sub = bt_mesh_subnet_get(net_idx); + if (sub == (bt_mesh_subnet *)0x0) { + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 8),'\x04'); + net_buf_simple_add_le16((net_buf_simple *)(net_buf_data_msg + 8),net_idx); + } + else { + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 8),'\0'); + net_buf_simple_add_le16((net_buf_simple *)(net_buf_data_msg + 8),net_idx); + val = bt_mesh_gatt_proxy_get(); + if (CONCAT31(extraout_var_00,val) == 1) { + if (_val == 0) { + bt_mesh_proxy_identity_stop(sub); + } + else { + bt_mesh_proxy_identity_start(sub); + } + bt_mesh_adv_update(); + } + val = sub->node_id; + } + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 8),val); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 8), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar1 == 0) { + return; + } + printf("Unable to send Node Identity Status\r\n"); + return; + } + fmt = "Invalid Node ID value 0x%02x\r\n"; + } + else { + fmt = "Invalid NetKeyIndex 0x%04x\r\n"; + } + printf(fmt,_val); + return; +} + + + +void send_gatt_proxy_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx) + +{ + u8_t val; + int iVar1; + u8_t auStack36 [4]; + u8_t net_buf_data_msg [7]; + net_buf_simple msg; + + register0x0000203c = auStack36; + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 4),0x8014); + val = bt_mesh_gatt_proxy_get(); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 4),val); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 4), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar1 != 0) { + printf("Unable to send GATT Proxy Status\r\n"); + } + return; +} + + + +void gatt_proxy_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx) + +{ + u8_t val; + int iVar1; + u8_t auStack36 [8]; + u8_t *puStack28; + undefined4 uStack24; + u8_t *puStack20; + + puStack28 = auStack36; + uStack24 = 0x70000; + puStack20 = auStack36; + bt_mesh_model_msg_init((net_buf_simple *)&puStack28,0x8014); + val = bt_mesh_gatt_proxy_get(); + net_buf_simple_add_u8((net_buf_simple *)&puStack28,val); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)&puStack28,(bt_mesh_send_cb *)0x0, + (void *)0x0); + if (iVar1 != 0) { + printf("Unable to send GATT Proxy Status\r\n"); + } + return; +} + + + +void gatt_proxy_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + byte bVar1; + u8_t uVar2; + undefined3 extraout_var; + void *pvVar3; + + bVar1 = *buf->data; + if (1 < bVar1) { + printf("Invalid GATT Proxy value 0x%02x\r\n",(uint)bVar1); + return; + } + uVar2 = bt_mesh_gatt_proxy_get(); + if (CONCAT31(extraout_var,uVar2) != 2) { + pvVar3 = model->user_data; + if (pvVar3 == (void *)0x0) { + printf("No Configuration Server context available\r\n"); + } + else { + if ((uint)*(byte *)((int)pvVar3 + 8) != (uint)bVar1) { + *(byte *)((int)pvVar3 + 8) = bVar1; + if (bVar1 == 0) { + if (bt_mesh.sub[0].net_idx != 0xffff) { + bt_mesh_proxy_identity_stop(bt_mesh.sub); + } + if (bt_mesh.sub[1].net_idx != 0xffff) { + bt_mesh_proxy_identity_stop(bt_mesh.sub + 1); + } + bt_mesh_proxy_gatt_disconnect(); + } + bt_mesh_adv_update(); + if ((*(ushort *)((int)pvVar3 + 0x36) & 2) != 0) { + bt_mesh_heartbeat_send(); + } + } + } + } + send_gatt_proxy_status(model,ctx); + return; +} + + + +u8_t bt_mesh_default_ttl_get(void) + +{ + u8_t uVar1; + + uVar1 = '\a'; + if (conf != (bt_mesh_cfg_srv *)0x0) { + uVar1 = conf->default_ttl; + } + return uVar1; +} + + + +void default_ttl_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t val; + int iVar1; + void *pvVar2; + u8_t auStack36 [4]; + u8_t net_buf_data_msg [7]; + net_buf_simple msg; + + register0x0000203c = auStack36; + pvVar2 = model->user_data; + if (pvVar2 == (void *)0x0) { + printf("No Configuration Server context available\r\n"); + } + else { + val = *buf->data; + if (((char)val < '\0') || (val == '\x01')) { + printf("Prohibited Default TTL value 0x%02x\r\n"); + return; + } + if (*(u8_t *)((int)pvVar2 + 10) != val) { + *(u8_t *)((int)pvVar2 + 10) = val; + } + } + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 4),0x800e); + val = bt_mesh_default_ttl_get(); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 4),val); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 4), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar1 != 0) { + printf("Unable to send Default TTL Status response\r\n"); + } + return; +} + + + +void default_ttl_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t val; + int iVar1; + u8_t auStack36 [4]; + u8_t net_buf_data_msg [7]; + net_buf_simple msg; + + register0x0000203c = auStack36; + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 4),0x800e); + val = bt_mesh_default_ttl_get(); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 4),val); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 4), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar1 != 0) { + printf("Unable to send Default TTL Status response\r\n"); + } + return; +} + + + +u8_t * bt_mesh_label_uuid_get(u16_t addr) + +{ + undefined2 in_register_0000202a; + + if ((uint)labels[0].addr != CONCAT22(in_register_0000202a,addr)) { + printf("No matching Label UUID for 0x%04x\r\n",CONCAT22(in_register_0000202a,addr)); + return (u8_t *)0x0; + } + return labels[0].uuid; +} + + + +size_t mod_sub_list_clear(bt_mesh_model *mod) + +{ + u16_t addr; + bt_mesh_model_op **ppbVar1; + size_t sVar2; + u8_t *__s2; + int iVar3; + + ppbVar1 = (bt_mesh_model_op **)mod->groups; + sVar2 = 0; + do { + addr = *(u16_t *)ppbVar1; + if ((ushort)(addr + 0x8000) < 0x4000) { + __s2 = bt_mesh_label_uuid_get(addr); + *(u16_t *)ppbVar1 = 0; + sVar2 = sVar2 + 1; + if (__s2 == (u8_t *)0x0) { + printf("Label UUID not found\r\n"); + } + else { + iVar3 = memcmp(labels[0].uuid,__s2,0x10); + if (iVar3 == 0) { + labels[0].ref = labels[0].ref - 1; + } + } + } + else { + if (addr != 0) { + *(u16_t *)ppbVar1 = 0; + sVar2 = sVar2 + 1; + } + } + ppbVar1 = (bt_mesh_model_op **)((int)ppbVar1 + 2); + } while (&mod->op != ppbVar1); + return sVar2; +} + + + +void mod_sub_del_all(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u16_t addr; + bt_mesh_elem *elem; + bt_mesh_model *mod; + u8_t status; + u8_t *mod_id; + _Bool a_Stack33 [4]; + _Bool vnd; + + addr = net_buf_simple_pull_le16(buf); + if ((short)addr < 1) { + printf("Prohibited element address\r\n"); + } + else { + mod_id = buf->data; + elem = bt_mesh_elem_find(addr); + if (elem == (bt_mesh_elem *)0x0) { + status = '\x01'; + a_Stack33[0] = buf->len == 4; + } + else { + mod = get_model(elem,buf,a_Stack33); + status = '\x02'; + if (mod != (bt_mesh_model *)0x0) { + bt_mesh_lpn_group_del(mod->groups,2); + mod_sub_list_clear(mod); + status = '\0'; + } + } + send_mod_sub_status(model,ctx,status,addr,0,mod_id,(_Bool)a_Stack33[0]); + } + return; +} + + + +void mod_sub_va_overwrite(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t status; + u16_t addr; + u8_t *label_uuid; + bt_mesh_elem *elem; + bt_mesh_model *mod; + undefined3 extraout_var; + u8_t *mod_id; + _Bool _Stack35; + u16_t uStack34; + _Bool vnd; + u16_t sub_addr; + + uStack34 = 0; + addr = net_buf_simple_pull_le16(buf); + if ((short)addr < 1) { + printf("Prohibited element address\r\n"); + } + else { + label_uuid = (u8_t *)net_buf_simple_pull_mem(buf,0x10); + mod_id = buf->data; + elem = bt_mesh_elem_find(addr); + if (elem == (bt_mesh_elem *)0x0) { + status = '\x01'; + _Stack35 = buf->len == 4; + } + else { + mod = get_model(elem,buf,&_Stack35); + status = '\x02'; + if (mod != (bt_mesh_model *)0x0) { + bt_mesh_lpn_group_del(mod->groups,2); + mod_sub_list_clear(mod); + status = va_add(label_uuid,&uStack34); + if (CONCAT31(extraout_var,status) == 0) { + mod->groups[0] = uStack34; + bt_mesh_lpn_group_add(uStack34); + } + } + } + send_mod_sub_status(model,ctx,status,addr,uStack34,mod_id,(_Bool)_Stack35); + } + return; +} + + + +void mod_sub_overwrite(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u16_t addr; + u16_t group; + bt_mesh_elem *elem; + bt_mesh_model *mod; + u8_t status; + u8_t *mod_id; + _Bool a_Stack33 [4]; + _Bool vnd; + + addr = net_buf_simple_pull_le16(buf); + if ((short)addr < 1) { + printf("Prohibited element address\r\n"); + } + else { + group = net_buf_simple_pull_le16(buf); + mod_id = buf->data; + elem = bt_mesh_elem_find(addr); + if (elem == (bt_mesh_elem *)0x0) { + status = '\x01'; + a_Stack33[0] = buf->len == 4; + } + else { + mod = get_model(elem,buf,a_Stack33); + status = '\x02'; + if ((mod != (bt_mesh_model *)0x0) && (status = '\x01', (ushort)(group + 0x4000) < 0x3f01)) { + bt_mesh_lpn_group_del(mod->groups,2); + mod_sub_list_clear(mod); + mod->groups[0] = group; + bt_mesh_lpn_group_add(group); + status = '\0'; + } + } + send_mod_sub_status(model,ctx,status,addr,group,mod_id,(_Bool)a_Stack33[0]); + } + return; +} + + + +size_t mod_reset(bt_mesh_model *mod) + +{ + u16_t addr; + bt_mesh_model_op **ppbVar1; + size_t sVar2; + u8_t *__s2; + int iVar3; + + ppbVar1 = (bt_mesh_model_op **)mod->groups; + sVar2 = 0; + do { + addr = *(u16_t *)ppbVar1; + if ((ushort)(addr + 0x8000) < 0x4000) { + __s2 = bt_mesh_label_uuid_get(addr); + *(u16_t *)ppbVar1 = 0; + sVar2 = sVar2 + 1; + if (__s2 == (u8_t *)0x0) { + printf("Label UUID not found\r\n"); + } + else { + iVar3 = memcmp(labels[0].uuid,__s2,0x10); + if (iVar3 == 0) { + labels[0].ref = labels[0].ref - 1; + } + } + } + else { + if (addr != 0) { + *(u16_t *)ppbVar1 = 0; + sVar2 = sVar2 + 1; + } + } + ppbVar1 = (bt_mesh_model_op **)((int)ppbVar1 + 2); + } while (&mod->op != ppbVar1); + return sVar2; +} + + + +bt_mesh_cfg_srv * bt_mesh_cfg_get(void) + +{ + return conf; +} + + + +void bt_mesh_subnet_del(bt_mesh_subnet *sub,_Bool store) + +{ + bt_mesh_cfg_srv *pbVar1; + + pbVar1 = conf; + if ((conf != (bt_mesh_cfg_srv *)0x0) && ((conf->hb_pub).net_idx == sub->net_idx)) { + *(undefined4 *)&(conf->hb_pub).dst = 0; + *(undefined2 *)&(pbVar1->hb_pub).period = 0; + k_delayed_work_cancel((k_delayed_work *)&pbVar1->hb_pub); + } + if (bt_mesh.app_keys[0].net_idx == sub->net_idx) { + bt_mesh_app_key_del(bt_mesh.app_keys,store); + } + if (bt_mesh.app_keys[1].net_idx == sub->net_idx) { + bt_mesh_app_key_del(bt_mesh.app_keys + 1,store); + } + bt_mesh_friend_clear_net_idx(sub->net_idx); + memset(sub,0,0xe4); + sub->net_idx = 0xffff; + return; +} + + + +void net_key_del(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u16_t net_idx; + undefined2 extraout_var; + bt_mesh_subnet *sub; + u8_t status; + + net_idx = net_buf_simple_pull_le16(buf); + _net_idx = CONCAT22(extraout_var,net_idx); + if (0xfff < _net_idx) { + printf("Invalid NetKeyIndex 0x%04x\r\n",_net_idx); + return; + } + sub = bt_mesh_subnet_get(net_idx); + status = '\0'; + if ((sub != (bt_mesh_subnet *)0x0) && (status = '\f', (uint)ctx->net_idx != _net_idx)) { + bt_mesh_subnet_del(sub,true); + status = '\0'; + } + send_net_key_status(model,ctx,net_idx,status); + return; +} + + + +void bt_mesh_cfg_reset(void) + +{ + bt_mesh_cfg_srv *pbVar1; + + pbVar1 = conf; + if (conf != (bt_mesh_cfg_srv *)0x0) { + bt_mesh_set_hb_sub_dst(0); + *(undefined4 *)&(pbVar1->hb_sub).expiry = 0; + *(undefined4 *)((int)&(pbVar1->hb_sub).expiry + 4) = 0; + *(undefined4 *)&(pbVar1->hb_sub).src = 0; + if (bt_mesh.sub[0].net_idx != 0xffff) { + bt_mesh_subnet_del(bt_mesh.sub,true); + } + if (bt_mesh.sub[1].net_idx != 0xffff) { + bt_mesh_subnet_del(bt_mesh.sub + 1,true); + } + bt_mesh_model_foreach(mod_reset,(void *)0x0); + memset(labels,0,0x14); + return; + } + return; +} + + + +void sys_put_be32(u32_t_conflict val,u8_t *dst) + +{ + dst[1] = (u8_t)(val >> 0x10); + *dst = (u8_t)(val >> 0x18); + dst[2] = (u8_t)(val >> 8); + dst[3] = (u8_t)val; + return; +} + + + +int bt_mesh_ccm_encrypt(u8_t *param_1,void *param_2,int param_3,uint param_4,int param_5,int param_6 + ,int param_7,size_t param_8) + +{ + byte bVar1; + ushort uVar2; + uint uVar3; + int iVar4; + byte *pbVar5; + byte *pbVar6; + byte *pbVar7; + uint uVar8; + int iVar9; + uint uVar10; + uint uVar11; + uint uVar12; + byte local_90 [14]; + ushort uStack130; + byte local_80 [16]; + byte local_70 [16]; + byte local_60 [16]; + byte local_50 [28]; + + local_90[0] = 1; + memcpy(local_90 + 1,param_2,0xd); + uStack130 = 0; + iVar4 = bt_encrypt_be(param_1,local_90,local_80); + if (iVar4 != 0) { + return iVar4; + } + if (param_8 == 8) { + local_90[0] = 0x59; + if (param_6 == 0) { + local_90[0] = 0x19; + } + } + else { + local_90[0] = 0x49; + if (param_6 == 0) { + local_90[0] = 9; + } + } + memcpy(local_90 + 1,param_2,0xd); + uStack130 = (ushort)(param_4 << 8) | (ushort)(param_4 >> 8) & 0xff; + iVar4 = bt_encrypt_be(param_1,local_90,local_50); + if (iVar4 != 0) { + return iVar4; + } + if (param_6 != 0) { + uVar12 = 2; + local_90[0] = local_50[0]; + local_90[1] = local_50[1] ^ (byte)param_6; + uVar8 = param_6 + 2; + iVar4 = 0; + while (pbVar7 = (byte *)(param_5 + iVar4), uVar3 = uVar12, 0x10 < uVar8) { + do { + bVar1 = *pbVar7; + uVar8 = uVar3 + 1; + pbVar7 = pbVar7 + 1; + local_90[uVar3] = local_50[uVar3] ^ bVar1; + uVar3 = uVar8; + } while (uVar8 != 0x10); + iVar4 = iVar4 + (0x10 - uVar12); + iVar9 = bt_encrypt_be(param_1,local_90,local_50); + uVar8 = 2; + uVar12 = 0; + if (iVar9 != 0) { + return iVar9; + } + } + while (uVar12 < uVar8) { + pbVar5 = local_90 + uVar12; + pbVar6 = local_50 + uVar12; + bVar1 = *pbVar7; + uVar12 = uVar12 + 1; + pbVar7 = pbVar7 + 1; + *pbVar5 = *pbVar6 ^ bVar1; + } + while (uVar8 != 0x10) { + local_90[uVar8] = local_50[uVar8]; + uVar8 = uVar8 + 1; + } + iVar4 = bt_encrypt_be(param_1,local_90,local_50); + if (iVar4 != 0) { + return iVar4; + } + } + uVar8 = param_4 + 0xf >> 4; + uVar12 = param_4 & 0xf; + if (uVar12 == 0) { + uVar12 = 0x10; + } + uVar3 = 0; + iVar4 = param_7; + do { + if (uVar8 == uVar3) { + memcpy((void *)(param_7 + param_4),local_60,param_8); + return 0; + } + uVar3 = uVar3 + 1; + uVar2 = (ushort)(uVar3 >> 8); + if (uVar8 == uVar3) { + uVar11 = 0; + while (uVar10 = uVar12, uVar11 < uVar12) { + pbVar5 = local_90 + uVar11; + pbVar6 = local_50 + uVar11; + pbVar7 = (byte *)(param_3 + uVar11); + uVar11 = uVar11 + 1; + *pbVar5 = *pbVar6 ^ *pbVar7; + } + while (uVar10 != 0x10) { + local_90[uVar10] = local_50[uVar10]; + uVar10 = uVar10 + 1; + } + iVar9 = bt_encrypt_be(param_1,local_90,local_50); + if (iVar9 != 0) { + return iVar9; + } + iVar9 = 0; + do { + pbVar5 = local_60 + iVar9; + pbVar6 = local_80 + iVar9; + pbVar7 = local_50 + iVar9; + iVar9 = iVar9 + 1; + *pbVar5 = *pbVar6 ^ *pbVar7; + } while (iVar9 != 0x10); + local_90[0] = 1; + memcpy(local_90 + 1,param_2,0xd); + uStack130 = (short)uVar3 * 0x100 | uVar2 & 0xff; + iVar9 = bt_encrypt_be(param_1,local_90,local_70); + if (iVar9 != 0) { + return iVar9; + } + uVar11 = 0; + do { + pbVar6 = (byte *)(param_3 + uVar11); + pbVar7 = local_70 + uVar11; + pbVar5 = (byte *)(iVar4 + uVar11); + uVar11 = uVar11 + 1; + *pbVar5 = *pbVar6 ^ *pbVar7; + } while (uVar11 < uVar12); + } + else { + iVar9 = 0; + do { + pbVar5 = local_90 + iVar9; + pbVar6 = local_50 + iVar9; + pbVar7 = (byte *)(param_3 + iVar9); + iVar9 = iVar9 + 1; + *pbVar5 = *pbVar6 ^ *pbVar7; + } while (iVar9 != 0x10); + iVar9 = bt_encrypt_be(param_1,local_90,local_50); + if (iVar9 != 0) { + return iVar9; + } + local_90[0] = 1; + memcpy(local_90 + 1,param_2,0xd); + uStack130 = (short)uVar3 * 0x100 | uVar2 & 0xff; + iVar9 = bt_encrypt_be(param_1,local_90,local_70); + if (iVar9 != 0) { + return iVar9; + } + iVar9 = 0; + do { + pbVar6 = (byte *)(param_3 + iVar9); + pbVar7 = local_70 + iVar9; + pbVar5 = (byte *)(iVar4 + iVar9); + iVar9 = iVar9 + 1; + *pbVar5 = *pbVar6 ^ *pbVar7; + } while (iVar9 != 0x10); + } + param_3 = param_3 + 0x10; + iVar4 = iVar4 + 0x10; + } while( true ); +} + + + +int bt_mesh_ccm_decrypt(u8_t *param_1,void *param_2,int param_3,uint param_4,int param_5,int param_6 + ,void *param_7,size_t param_8) + +{ + byte bVar1; + ushort uVar2; + ushort uVar3; + int iVar4; + uint __n; + int iVar5; + int iVar6; + byte *pbVar7; + byte *pbVar8; + byte *pbVar9; + uint uVar10; + uint uVar11; + uint uVar12; + uint uVar13; + byte local_a0 [16]; + byte local_90 [14]; + ushort uStack130; + byte local_80 [16]; + byte local_70 [16]; + byte local_60 [44]; + + if (param_4 == 0) { + return 0xffffffea; + } + local_90[0] = 1; + memcpy(local_90 + 1,param_2,0xd); + uStack130 = 0; + iVar5 = bt_encrypt_be(param_1,local_90,local_80); + if (iVar5 != 0) { + return iVar5; + } + if (param_8 == 8) { + local_90[0] = 0x59; + if (param_6 == 0) { + local_90[0] = 0x19; + } + } + else { + local_90[0] = 0x49; + if (param_6 == 0) { + local_90[0] = 9; + } + } + memcpy(local_90 + 1,param_2,0xd); + uStack130 = (ushort)(param_4 << 8) | (ushort)(param_4 >> 8) & 0xff; + iVar5 = bt_encrypt_be(param_1,local_90,local_60); + if (iVar5 != 0) { + return iVar5; + } + if (param_6 != 0) { + iVar5 = 0; + uVar10 = 2; + local_90[0] = local_60[0]; + local_90[1] = (byte)param_6 ^ local_60[1]; + __n = param_6 + 2; + while (pbVar9 = (byte *)(param_5 + iVar5), uVar13 = uVar10, 0x10 < __n) { + do { + bVar1 = *pbVar9; + __n = uVar13 + 1; + pbVar9 = pbVar9 + 1; + local_90[uVar13] = local_60[uVar13] ^ bVar1; + uVar13 = __n; + } while (__n != 0x10); + iVar5 = iVar5 + (0x10 - uVar10); + iVar6 = bt_encrypt_be(param_1,local_90,local_60); + __n = 2; + uVar10 = 0; + if (iVar6 != 0) { + return iVar6; + } + } + while (uVar10 < __n) { + pbVar7 = local_90 + uVar10; + pbVar8 = local_60 + uVar10; + bVar1 = *pbVar9; + uVar10 = uVar10 + 1; + pbVar9 = pbVar9 + 1; + *pbVar7 = *pbVar8 ^ bVar1; + } + while (__n != 0x10) { + local_90[__n] = local_60[__n]; + __n = __n + 1; + } + iVar5 = bt_encrypt_be(param_1,local_90,local_60); + if (iVar5 != 0) { + return iVar5; + } + } + __n = param_4 & 0xf; + if (__n == 0) { + __n = 0x10; + } + uVar10 = param_4 + 0xf >> 4 & 0xffff; + uVar13 = 0; + iVar5 = param_3; + do { + if (uVar10 <= uVar13) { + iVar5 = memcmp(local_60 + 0x10,(void *)(param_3 + param_4),param_8); + if (iVar5 != 0) { + iVar5 = -0x4d; + } + return iVar5; + } + uVar13 = uVar13 + 1; + uVar2 = (short)uVar13 * 0x100; + uVar3 = (ushort)(uVar13 >> 8) & 0xff; + if (uVar10 == uVar13) { + local_90[0] = 1; + memcpy(local_90 + 1,param_2,0xd); + uStack130 = uVar2 | uVar3; + iVar6 = bt_encrypt_be(param_1,local_90,local_70); + if (iVar6 != 0) { + return iVar6; + } + uVar11 = 0; + while (uVar11 < __n) { + pbVar7 = local_a0 + uVar11; + pbVar9 = local_70 + uVar11; + pbVar8 = (byte *)(iVar5 + uVar11); + uVar11 = uVar11 + 1; + *pbVar7 = *pbVar8 ^ *pbVar9; + } + memcpy(param_7,local_a0,__n); + uVar11 = 0; + do { + pbVar7 = local_90 + uVar11; + pbVar8 = local_60 + uVar11; + pbVar9 = local_a0 + uVar11; + uVar11 = uVar11 + 1; + *pbVar7 = *pbVar8 ^ *pbVar9; + uVar12 = __n; + } while (uVar11 < __n); + while (uVar12 != 0x10) { + local_90[uVar12] = local_60[uVar12]; + uVar12 = uVar12 + 1; + } + iVar6 = bt_encrypt_be(param_1,local_90,local_60); + if (iVar6 != 0) { + return iVar6; + } + iVar6 = 0; + do { + iVar4 = iVar6 + 0x10; + pbVar7 = local_80 + iVar6; + pbVar9 = local_60 + iVar6; + iVar6 = iVar6 + 1; + local_60[iVar4] = *pbVar7 ^ *pbVar9; + } while (iVar6 != 0x10); + } + else { + local_90[0] = 1; + memcpy(local_90 + 1,param_2,0xd); + uStack130 = uVar2 | uVar3; + iVar6 = bt_encrypt_be(param_1,local_90,local_70); + if (iVar6 != 0) { + return iVar6; + } + iVar6 = 0; + do { + pbVar7 = local_a0 + iVar6; + pbVar9 = local_70 + iVar6; + pbVar8 = (byte *)(iVar5 + iVar6); + iVar6 = iVar6 + 1; + *pbVar7 = *pbVar8 ^ *pbVar9; + } while (iVar6 != 0x10); + memcpy(param_7,local_a0,0x10); + iVar6 = 0; + do { + pbVar7 = local_90 + iVar6; + pbVar8 = local_60 + iVar6; + pbVar9 = local_a0 + iVar6; + iVar6 = iVar6 + 1; + *pbVar7 = *pbVar8 ^ *pbVar9; + } while (iVar6 != 0x10); + iVar6 = bt_encrypt_be(param_1,local_90,local_60); + if (iVar6 != 0) { + return iVar6; + } + } + param_7 = (void *)((int)param_7 + 0x10); + iVar5 = iVar5 + 0x10; + } while( true ); +} + + + +// WARNING: Variable defined which should be unmapped: sched + +int bt_mesh_aes_cmac(u8_t *key,bt_mesh_sg *sg,size_t sg_len,u8_t *mac) + +{ + int iVar1; + undefined auStack280 [4]; + tc_cmac_struct state; + tc_aes_key_sched_struct sched; + + iVar1 = tc_cmac_setup((TCCmacState_t)auStack280,key,(TCAesKeySched_t)((int)&state.countdown + 4)); + if (iVar1 != 0) { + while (sg_len != 0) { + iVar1 = tc_cmac_update((TCCmacState_t)auStack280,(uint8_t *)sg->data,sg->len); + if (iVar1 == 0) { + return -5; + } + sg_len = sg_len - 1; + sg = sg + 1; + } + iVar1 = tc_cmac_final(mac,(TCCmacState_t)auStack280); + if (iVar1 != 0) { + return 0; + } + } + return -5; +} + + + +int bt_mesh_aes_cmac_one(u8_t *key,void *m,size_t len,u8_t *mac) + +{ + int iVar1; + void *pvStack24; + bt_mesh_sg sg; + + pvStack24 = m; + sg.data = (void *)len; + iVar1 = bt_mesh_aes_cmac(key,(bt_mesh_sg *)&pvStack24,1,mac); + return iVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +_Bool bt_mesh_s1(char *m,u8_t *salt) + +{ + size_t len; + int iVar1; + undefined4 uStack32; + u8_t zero [16]; + + uStack32 = 0; + zero._0_4_ = 0; + zero._4_4_ = 0; + zero._8_4_ = 0; + len = strlen(m); + iVar1 = bt_mesh_aes_cmac_one((u8_t *)&uStack32,m,len,salt); + return (_Bool)(iVar1 != 0); +} + + + +int bt_mesh_k1(u8_t *ikm,size_t ikm_len,u8_t *salt,char *info,u8_t *okm) + +{ + int iVar1; + size_t len; + + iVar1 = bt_mesh_aes_cmac_one(salt,ikm,ikm_len,okm); + if (-1 < iVar1) { + len = strlen(info); + iVar1 = bt_mesh_aes_cmac_one(okm,info,len,okm); + return iVar1; + } + return iVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bt_mesh_k2(u8_t *n,u8_t *p,size_t p_len,u8_t *net_id,u8_t *enc_key,u8_t *priv_key) + +{ + u8_t *mac; + _Bool _Var1; + undefined3 extraout_var; + int iVar2; + u8_t auStack104 [3]; + u8_t pad; + u8_t salt [16]; + u8_t out [16]; + u8_t t [16]; + bt_mesh_sg sg [3]; + + _Var1 = bt_mesh_s1("smk2",auStack104); + if (CONCAT31(extraout_var,_Var1) == 0) { + iVar2 = bt_mesh_aes_cmac_one(auStack104,n,0x10,out + 0xc); + if (iVar2 == 0) { + mac = salt + 0xc; + t._12_4_ = (u8_t *)0x0; + iVar2 = bt_mesh_aes_cmac(out + 0xc,(bt_mesh_sg *)(t + 0xc),3,mac); + if (iVar2 == 0) { + *net_id = out[11] & 0x7f; + t._12_4_ = mac; + iVar2 = bt_mesh_aes_cmac(out + 0xc,(bt_mesh_sg *)(t + 0xc),3,mac); + if (iVar2 == 0) { + memcpy(enc_key,mac,0x10); + iVar2 = bt_mesh_aes_cmac(out + 0xc,(bt_mesh_sg *)(t + 0xc),3,mac); + if (iVar2 == 0) { + memcpy(priv_key,mac,0x10); + } + } + } + } + } + else { + iVar2 = 1; + } + return iVar2; +} + + + +int bt_mesh_k3(u8_t *n,u8_t *out) + +{ + _Bool _Var1; + undefined3 extraout_var; + int iVar2; + undefined4 uStack56; + u8_t id64 [5]; + u8_t tmp [16]; + u8_t t [16]; + + uStack56 = DAT_4200ee78; + id64[0] = DAT_4200ee7c; + _Var1 = bt_mesh_s1("smk3",id64 + 4); + if (CONCAT31(extraout_var,_Var1) == 0) { + iVar2 = bt_mesh_aes_cmac_one(id64 + 4,n,0x10,tmp + 0xc); + if ((iVar2 == 0) && (iVar2 = bt_mesh_aes_cmac_one(tmp + 0xc,&uStack56,5,id64 + 4), iVar2 == 0)) + { + memcpy(out,tmp + 4,8); + } + } + else { + iVar2 = 1; + } + return iVar2; +} + + + +int bt_mesh_k4(u8_t *n,u8_t *out) + +{ + _Bool _Var1; + undefined3 extraout_var; + int iVar2; + undefined4 uStack52; + u8_t id6 [4]; + u8_t tmp [16]; + u8_t t [16]; + + uStack52 = DAT_4200ee80; + _Var1 = bt_mesh_s1("smk4",id6); + if (CONCAT31(extraout_var,_Var1) == 0) { + iVar2 = bt_mesh_aes_cmac_one(id6,n,0x10,tmp + 0xc); + if ((iVar2 == 0) && (iVar2 = bt_mesh_aes_cmac_one(tmp + 0xc,&uStack52,4,id6), iVar2 == 0)) { + *out = tmp[11] & 0x3f; + } + } + else { + iVar2 = 1; + } + return iVar2; +} + + + +int bt_mesh_id128(u8_t *n,char *s,u8_t *out) + +{ + _Bool _Var1; + undefined3 extraout_var; + int iVar2; + u8_t auStack32 [4]; + u8_t salt [16]; + + _Var1 = bt_mesh_s1(s,auStack32); + if (CONCAT31(extraout_var,_Var1) == 0) { + iVar2 = bt_mesh_k1(n,0x10,auStack32,"id128\x01",out); + } + else { + iVar2 = 1; + } + return iVar2; +} + + + +// WARNING: Variable defined which should be unmapped: tmp +// WARNING: Could not reconcile some variable overlaps + +int bt_mesh_net_obfuscate(u8_t *pdu,u32_t_conflict iv_index,u8_t *privacy_key) + +{ + byte bVar1; + int iVar2; + byte *pbVar3; + byte *pbVar4; + byte *pbVar5; + undefined4 local_30; + u8_t priv_rand [16]; + u8_t tmp [16]; + + local_30 = 0; + priv_rand._0_4_ = 0; + priv_rand._4_4_ = 0; + priv_rand._8_4_ = 0; + sys_put_be32(iv_index,priv_rand + 1); + memcpy(priv_rand + 5,pdu + 7,7); + iVar2 = bt_encrypt_be(privacy_key,(u8_t *)&local_30,priv_rand + 0xc); + if (iVar2 == 0) { + pbVar3 = priv_rand + 0xc; + pbVar4 = pdu + 1; + do { + bVar1 = *pbVar3; + pbVar5 = pbVar4 + 1; + pbVar3 = pbVar3 + 1; + *pbVar4 = *pbVar4 ^ bVar1; + pbVar4 = pbVar5; + } while (pdu + 7 != pbVar5); + } + return iVar2; +} + + + +// WARNING: Variable defined which should be unmapped: nonce + +int bt_mesh_net_encrypt(u8_t *key,net_buf_simple *buf,u32_t_conflict iv_index,_Bool proxy) + +{ + size_t len; + int iVar1; + undefined3 in_register_00002035; + u8_t *puVar2; + short local_20; + u8_t uStack30; + u8_t uStack29; + u8_t nonce [13]; + + puVar2 = buf->data; + len = 4; + if ((char)puVar2[1] < '\0') { + len = 8; + } + uStack30 = puVar2[2]; + uStack29 = puVar2[3]; + nonce[0] = puVar2[4]; + nonce[1] = puVar2[5]; + nonce[2] = puVar2[6]; + if (CONCAT31(in_register_00002035,proxy) == 0) { + local_20 = (ushort)puVar2[1] << 8; + } + else { + local_20 = 3; + } + nonce[3] = '\0'; + nonce[4] = '\0'; + sys_put_be32(iv_index,nonce + 5); + iVar1 = bt_mesh_ccm_encrypt(key,&local_20,buf->data + 7,(uint)buf->len - 7,0,0,len); + if (iVar1 == 0) { + net_buf_simple_add(buf,len); + } + return iVar1; +} + + + +// WARNING: Variable defined which should be unmapped: nonce + +int bt_mesh_net_decrypt(u8_t *key,net_buf_simple *buf,u32_t_conflict iv_index,_Bool proxy) + +{ + int iVar1; + undefined3 in_register_00002035; + uint uVar2; + u8_t *puVar3; + short local_20; + u8_t uStack30; + u8_t uStack29; + u8_t nonce [13]; + + puVar3 = buf->data; + iVar1 = 4; + if ((char)puVar3[1] < '\0') { + iVar1 = 8; + } + uStack30 = puVar3[2]; + uStack29 = puVar3[3]; + nonce[0] = puVar3[4]; + nonce[1] = puVar3[5]; + nonce[2] = puVar3[6]; + if (CONCAT31(in_register_00002035,proxy) == 0) { + local_20 = (ushort)puVar3[1] << 8; + } + else { + local_20 = 3; + } + nonce[3] = '\0'; + nonce[4] = '\0'; + sys_put_be32(iv_index,nonce + 5); + uVar2 = (uint)buf->len - iVar1; + buf->len = (u16_t)(uVar2 * 0x10000 >> 0x10); + iVar1 = bt_mesh_ccm_decrypt(key,&local_20,buf->data + 7,(uVar2 & 0xffff) - 7,0,0,iVar1); + return iVar1; +} + + + +// WARNING: Variable defined which should be unmapped: nonce + +int bt_mesh_app_encrypt(u8_t *key,_Bool dev_key,u8_t aszmic,net_buf_simple *buf,u8_t *ad,u16_t src, + u16_t dst,u32_t_conflict seq_num,u32_t_conflict iv_index) + +{ + size_t len; + int iVar1; + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + u32_t_conflict in_stack_00000000; + char cStack32; + u8_t auStack31 [3]; + u8_t nonce [13]; + + cStack32 = (CONCAT31(in_register_0000202d,dev_key) != 0) + '\x01'; + sys_put_be32(CONCAT31(in_register_00002031,aszmic) << 0x1f | seq_num,auStack31); + nonce[2] = (u8_t)src; + nonce[1] = (u8_t)(src >> 8); + nonce[3] = (u8_t)(dst >> 8); + nonce[4] = (u8_t)dst; + sys_put_be32(in_stack_00000000,nonce + 5); + len = 4; + if (CONCAT31(in_register_00002031,aszmic) != 0) { + len = 8; + } + iVar1 = bt_mesh_ccm_encrypt(key,&cStack32,buf->data,(uint)buf->len,ad, + (uint)(ad != (u8_t *)0x0) << 4,len); + if (iVar1 == 0) { + net_buf_simple_add(buf,len); + } + return iVar1; +} + + + +int bt_mesh_app_decrypt(u8_t *key,_Bool dev_key,u8_t aszmic,net_buf_simple *buf,net_buf_simple *out, + u8_t *ad,u16_t src,u16_t dst,u32_t_conflict seq_num,u32_t_conflict iv_index) + +{ + int iVar1; + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + undefined4 uVar2; + uint in_stack_00000000; + u32_t_conflict in_stack_00000004; + char cStack48; + u8_t auStack47 [3]; + u8_t nonce [13]; + + cStack48 = (CONCAT31(in_register_0000202d,dev_key) != 0) + '\x01'; + sys_put_be32(CONCAT31(in_register_00002031,aszmic) << 0x1f | in_stack_00000000,auStack47); + nonce[1] = (u8_t)(src >> 8); + nonce[2] = (u8_t)src; + nonce[3] = (u8_t)(dst >> 8); + nonce[4] = (u8_t)dst; + sys_put_be32(in_stack_00000004,nonce + 5); + uVar2 = 4; + if (CONCAT31(in_register_00002031,aszmic) != 0) { + uVar2 = 8; + } + iVar1 = bt_mesh_ccm_decrypt(key,&cStack48,buf->data,(uint)buf->len,ad, + (uint)(ad != (u8_t *)0x0) << 4,out->data,uVar2); + if (iVar1 == 0) { + net_buf_simple_add(out,(uint)buf->len); + } + return iVar1; +} + + + +u8_t bt_mesh_fcs_calc(u8_t *data,u8_t data_len) + +{ + byte *pbVar1; + undefined3 in_register_0000202d; + uint uVar2; + + uVar2 = 0xff; + pbVar1 = data; + while (pbVar1 != data + CONCAT31(in_register_0000202d,data_len)) { + uVar2 = (uint)""[uVar2 ^ *pbVar1]; + pbVar1 = pbVar1 + 1; + } + return (u8_t)~(byte)uVar2; +} + + + +_Bool bt_mesh_fcs_check(net_buf_simple *buf,u8_t received_fcs) + +{ + undefined3 in_register_0000202d; + byte *pbVar1; + uint uVar2; + + uVar2 = 0xff; + pbVar1 = buf->data; + while (((uint)pbVar1 & 0xffff) != ((uint)(buf->data + buf->len) & 0xffff)) { + uVar2 = (uint)""[uVar2 ^ *pbVar1]; + pbVar1 = pbVar1 + 1; + } + return (_Bool)(""[uVar2 ^ CONCAT31(in_register_0000202d,received_fcs)] == -0x31); +} + + + +int bt_mesh_virtual_addr(u8_t *virtual_label,u16_t *addr) + +{ + _Bool _Var1; + undefined3 extraout_var; + int iVar2; + u8_t auStack48 [4]; + u8_t salt [16]; + u8_t tmp [16]; + + _Var1 = bt_mesh_s1("vtad",auStack48); + if (CONCAT31(extraout_var,_Var1) == 0) { + iVar2 = bt_mesh_aes_cmac_one(auStack48,virtual_label,0x10,salt + 0xc); + if (iVar2 == 0) { + *addr = (ushort)(((uint)CONCAT11(tmp[10],tmp[11]) << 0x12) >> 0x12) | 0x8000; + } + } + else { + iVar2 = 1; + } + return iVar2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bt_mesh_prov_conf_salt(u8_t *conf_inputs,u8_t *salt) + +{ + int iVar1; + undefined4 local_20; + u8_t conf_salt_key [16]; + + local_20 = 0; + conf_salt_key._0_4_ = 0; + conf_salt_key._4_4_ = 0; + conf_salt_key._8_4_ = 0; + iVar1 = bt_mesh_aes_cmac_one((u8_t *)&local_20,conf_inputs,0x91,salt); + return iVar1; +} + + + +int bt_mesh_prov_conf_key(u8_t *dhkey,u8_t *conf_salt,u8_t *conf_key) + +{ + int iVar1; + + iVar1 = bt_mesh_k1(dhkey,0x20,conf_salt,"prck",conf_key); + return iVar1; +} + + + +int bt_mesh_prov_conf(u8_t *conf_key,u8_t *rand,u8_t *auth,u8_t *conf) + +{ + int iVar1; + u8_t *local_20; + bt_mesh_sg sg [2]; + + sg[0].data = &DAT_00000010; + sg[1].data = &DAT_00000010; + local_20 = rand; + sg[0].len = (size_t)auth; + iVar1 = bt_mesh_aes_cmac(conf_key,(bt_mesh_sg *)&local_20,2,conf); + return iVar1; +} + + + +int bt_mesh_prov_decrypt(u8_t *key,u8_t *nonce,u8_t *data,u8_t *out) + +{ + int iVar1; + + iVar1 = bt_mesh_ccm_decrypt(0x19,0,0,out,8); + return iVar1; +} + + + +int bt_mesh_beacon_auth(u8_t *beacon_key,u8_t flags,u8_t *net_id,u32_t_conflict iv_index,u8_t *auth) + +{ + int iVar1; + u8_t uStack48; + undefined auStack47 [3]; + u8_t msg [13]; + u8_t tmp [16]; + + uStack48 = flags; + memcpy(auStack47,net_id,8); + sys_put_be32(iv_index,msg + 5); + iVar1 = bt_mesh_aes_cmac_one(beacon_key,&uStack48,0xd,msg + 0xc); + if (iVar1 == 0) { + memcpy(auth,msg + 0xc,8); + } + return iVar1; +} + + + +void health_period_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t *puVar1; + u8_t uVar2; + + if (health_cli->op_pending != 0x8037) { + printf("Unexpected Health Period Status message\r\n"); + return; + } + puVar1 = *(u8_t **)health_cli->op_param; + uVar2 = net_buf_simple_pull_u8(buf); + *puVar1 = uVar2; + k_sem_give(&health_cli->op_sync); + return; +} + + + +void health_current_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + code *UNRECOVERED_JUMPTABLE; + void *pvVar1; + u8_t uVar2; + u16_t uVar3; + undefined3 extraout_var; + undefined2 extraout_var_00; + + pvVar1 = model->user_data; + uVar2 = net_buf_simple_pull_u8(buf); + uVar3 = net_buf_simple_pull_le16(buf); + UNRECOVERED_JUMPTABLE = *(code **)((int)pvVar1 + 4); + if (UNRECOVERED_JUMPTABLE == (code *)0x0) { + printf("No Current Status callback available\r\n"); + return; + } + // WARNING: Could not recover jumptable at 0x230414c4. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE) + (pvVar1,(uint)ctx->addr,CONCAT31(extraout_var,uVar2),CONCAT22(extraout_var_00,uVar3), + buf->data,(uint)buf->len); + return; +} + + + +void health_fault_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + ushort *puVar1; + u8_t uVar2; + u16_t uVar3; + char *fmt; + undefined3 extraout_var; + undefined2 extraout_var_00; + + if (health_cli->op_pending == 5) { + puVar1 = (ushort *)health_cli->op_param; + uVar2 = net_buf_simple_pull_u8(buf); + if ((*(byte **)(puVar1 + 2) == (byte *)0x0) || + ((uint)**(byte **)(puVar1 + 2) == CONCAT31(extraout_var,uVar2))) { + uVar3 = net_buf_simple_pull_le16(buf); + if ((uint)*puVar1 == CONCAT22(extraout_var_00,uVar3)) { + if (*(u8_t **)(puVar1 + 4) != (u8_t *)0x0) { + **(u8_t **)(puVar1 + 4) = uVar2; + } + if (**(uint **)(puVar1 + 8) < (uint)buf->len) { + printf("Got more faults than there\'s space for\r\n"); + } + else { + **(uint **)(puVar1 + 8) = (uint)buf->len; + } + memcpy(*(void **)(puVar1 + 6),buf->data,**(size_t **)(puVar1 + 8)); + k_sem_give(&health_cli->op_sync); + return; + } + fmt = "Health fault with unexpected Company ID\r\n"; + } + else { + fmt = "Health fault with unexpected Test ID\r\n"; + } + } + else { + fmt = "Unexpected Health Fault Status message\r\n"; + } + printf(fmt); + return; +} + + + +void health_attention_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t *puVar1; + u8_t uVar2; + + if (health_cli->op_pending != 0x8007) { + printf("Unexpected Health Attention Status message\r\n"); + return; + } + puVar1 = *(u8_t **)health_cli->op_param; + if (puVar1 != (u8_t *)0x0) { + uVar2 = net_buf_simple_pull_u8(buf); + *puVar1 = uVar2; + } + k_sem_give(&health_cli->op_sync); + return; +} + + + +void attention_off(k_work *work) + +{ + code *UNRECOVERED_JUMPTABLE; + + if ((work[-1].flags[0] != 0) && + (UNRECOVERED_JUMPTABLE = *(code **)(work[-1].flags[0] + 0x14), + UNRECOVERED_JUMPTABLE != (code *)0x0)) { + // WARNING: Could not recover jumptable at 0x230415da. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(work[-1].handler); + return; + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: msg + +void send_attention_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx) + +{ + s32_t sVar1; + int iVar2; + u8_t auStack36 [4]; + u8_t net_buf_data_msg [7]; + net_buf_simple msg; + + register0x0000203c = auStack36; + sVar1 = k_delayed_work_remaining_get((k_delayed_work *)((int)model->user_data + 8)); + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 4),0x8007); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_msg + 4),(u8_t)(sVar1 / 1000)); + iVar2 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 4), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar2 != 0) { + printf("Unable to send Attention Status\r\n"); + } + return; +} + + + +void attention_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx) + +{ + s32_t sVar1; + int iVar2; + u8_t auStack36 [8]; + u8_t *puStack28; + undefined4 uStack24; + u8_t *puStack20; + + puStack28 = auStack36; + uStack24 = 0x70000; + puStack20 = auStack36; + sVar1 = k_delayed_work_remaining_get((k_delayed_work *)((int)model->user_data + 8)); + bt_mesh_model_msg_init((net_buf_simple *)&puStack28,0x8007); + net_buf_simple_add_u8((net_buf_simple *)&puStack28,(u8_t)(sVar1 / 1000)); + iVar2 = bt_mesh_model_send(model,ctx,(net_buf_simple *)&puStack28,(bt_mesh_send_cb *)0x0, + (void *)0x0); + if (iVar2 != 0) { + printf("Unable to send Attention Status\r\n"); + } + return; +} + + + +void health_period_set_unrel(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + byte bVar1; + undefined3 extraout_var; + + bVar1 = net_buf_simple_pull_u8(buf); + if (0xf < CONCAT31(extraout_var,bVar1)) { + printf("Prohibited period value %u\r\n",CONCAT31(extraout_var,bVar1)); + return; + } + *(byte *)&model->pub->field_0xb = *(byte *)&model->pub->field_0xb & 0xf0 | bVar1 & 0xf; + return; +} + + + +void send_health_period_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx) + +{ + int iVar1; + u8_t auStack36 [4]; + u8_t net_buf_data_msg [7]; + net_buf_simple msg; + + register0x0000203c = auStack36; + bt_mesh_model_msg_init((net_buf_simple *)(net_buf_data_msg + 4),0x8037); + net_buf_simple_add_u8 + ((net_buf_simple *)(net_buf_data_msg + 4),*(byte *)&model->pub->field_0xb & 0xf); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)(net_buf_data_msg + 4), + (bt_mesh_send_cb *)0x0,(void *)0x0); + if (iVar1 != 0) { + printf("Unable to send Health Period Status\r\n"); + } + return; +} + + + +void health_period_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + health_period_set_unrel(model,ctx,buf); + send_health_period_status(model,ctx); + return; +} + + + +void health_period_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx) + +{ + int iVar1; + u8_t auStack36 [8]; + u8_t *puStack28; + undefined4 uStack24; + u8_t *puStack20; + + puStack28 = auStack36; + uStack24 = 0x70000; + puStack20 = auStack36; + bt_mesh_model_msg_init((net_buf_simple *)&puStack28,0x8037); + net_buf_simple_add_u8((net_buf_simple *)&puStack28,*(byte *)&model->pub->field_0xb & 0xf); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)&puStack28,(bt_mesh_send_cb *)0x0, + (void *)0x0); + if (iVar1 != 0) { + printf("Unable to send Health Period Status\r\n"); + } + return; +} + + + +void health_fault_test_unrel(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + code *UNRECOVERED_JUMPTABLE; + void *pvVar1; + u8_t uVar2; + u16_t uVar3; + undefined3 extraout_var; + undefined2 extraout_var_00; + int iVar4; + + pvVar1 = model->user_data; + uVar2 = net_buf_simple_pull_u8(buf); + uVar3 = net_buf_simple_pull_le16(buf); + iVar4 = *(int *)((int)pvVar1 + 4); + if ((iVar4 != 0) && + (UNRECOVERED_JUMPTABLE = *(code **)(iVar4 + 0xc), UNRECOVERED_JUMPTABLE != (code *)0x0)) { + // WARNING: Could not recover jumptable at 0x23041744. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(model,CONCAT31(extraout_var,uVar2),CONCAT22(extraout_var_00,uVar3)); + return; + } + return; +} + + + +void health_fault_clear_unrel(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + code *UNRECOVERED_JUMPTABLE; + void *pvVar1; + u16_t uVar2; + undefined2 extraout_var; + int iVar3; + + pvVar1 = model->user_data; + uVar2 = net_buf_simple_pull_le16(buf); + iVar3 = *(int *)((int)pvVar1 + 4); + if ((iVar3 != 0) && + (UNRECOVERED_JUMPTABLE = *(code **)(iVar3 + 8), UNRECOVERED_JUMPTABLE != (code *)0x0)) { + // WARNING: Could not recover jumptable at 0x2304177a. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(model,CONCAT22(extraout_var,uVar2)); + return; + } + return; +} + + + +void health_get_registered(bt_mesh_model *mod,u16_t company_id,net_buf_simple *msg) + +{ + undefined *puVar1; + size_t sVar2; + undefined2 in_register_0000202e; + int iVar3; + code *pcVar4; + void *pvVar5; + byte abStack33 [4]; + u8_t fault_count; + + pvVar5 = mod->user_data; + bt_mesh_model_msg_init(msg,5); + puVar1 = (undefined *)net_buf_simple_add(msg,1); + net_buf_simple_add_le16(msg,company_id); + iVar3 = *(int *)((int)pvVar5 + 4); + if ((iVar3 == 0) || (*(int *)(iVar3 + 4) == 0)) { + printf("No callback for getting faults\r\n"); + } + else { + sVar2 = net_buf_simple_tailroom(msg); + pcVar4 = *(code **)(*(int *)((int)pvVar5 + 4) + 4); + abStack33[0] = (char)sVar2 - 4; + iVar3 = (*pcVar4)(mod,CONCAT22(in_register_0000202e,company_id),puVar1,msg->data + msg->len, + abStack33,pcVar4); + if (iVar3 == 0) { + net_buf_simple_add(msg,(uint)abStack33[0]); + return; + } + printf("Failed to get faults (err %d)\r\n",iVar3); + } + *puVar1 = 0; + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void health_fault_test(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t uVar1; + u16_t company_id; + undefined3 extraout_var; + undefined2 extraout_var_00; + int iVar2; + code *pcVar3; + void *pvVar4; + u8_t **ppuStack116; + net_buf_simple sdu; + u8_t net_buf_data_sdu [72]; + + ppuStack116 = &sdu.__buf; + pvVar4 = model->user_data; + sdu.data = (u8_t *)0x480000; + sdu._4_4_ = &sdu.__buf; + uVar1 = net_buf_simple_pull_u8(buf); + company_id = net_buf_simple_pull_le16(buf); + iVar2 = *(int *)((int)pvVar4 + 4); + if (((iVar2 == 0) || (pcVar3 = *(code **)(iVar2 + 0xc), pcVar3 == (code *)0x0)) || + (iVar2 = (*pcVar3)(model,CONCAT31(extraout_var,uVar1),CONCAT22(extraout_var_00,company_id)), + iVar2 == 0)) { + health_get_registered(model,company_id,(net_buf_simple *)&ppuStack116); + iVar2 = bt_mesh_model_send(model,ctx,(net_buf_simple *)&ppuStack116,(bt_mesh_send_cb *)0x0, + (void *)0x0); + if (iVar2 != 0) { + printf("Unable to send Health Current Status response\r\n"); + } + } + else { + printf("Running fault test failed with err %d\r\n",iVar2); + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void health_fault_clear(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u16_t company_id; + undefined2 extraout_var; + int iVar1; + code *pcVar2; + void *pvVar3; + u8_t **ppuStack116; + net_buf_simple sdu; + u8_t net_buf_data_sdu [72]; + + ppuStack116 = &sdu.__buf; + pvVar3 = model->user_data; + sdu.data = (u8_t *)0x480000; + sdu._4_4_ = &sdu.__buf; + company_id = net_buf_simple_pull_le16(buf); + iVar1 = *(int *)((int)pvVar3 + 4); + if ((iVar1 != 0) && (pcVar2 = *(code **)(iVar1 + 8), pcVar2 != (code *)0x0)) { + (*pcVar2)(model,CONCAT22(extraout_var,company_id)); + } + health_get_registered(model,company_id,(net_buf_simple *)&ppuStack116); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)&ppuStack116,(bt_mesh_send_cb *)0x0, + (void *)0x0); + if (iVar1 != 0) { + printf("Unable to send Health Current Status response\r\n"); + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void health_fault_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u16_t company_id; + int iVar1; + u8_t **ppuStack100; + net_buf_simple sdu; + u8_t net_buf_data_sdu [72]; + + ppuStack100 = &sdu.__buf; + sdu.data = (u8_t *)0x480000; + sdu._4_4_ = &sdu.__buf; + company_id = net_buf_simple_pull_le16(buf); + health_get_registered(model,company_id,(net_buf_simple *)&ppuStack100); + iVar1 = bt_mesh_model_send(model,ctx,(net_buf_simple *)&ppuStack100,(bt_mesh_send_cb *)0x0, + (void *)0x0); + if (iVar1 != 0) { + printf("Unable to send Health Current Status response\r\n"); + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: fault_count + +int health_pub_update(bt_mesh_model *mod) + +{ + u16_t uVar1; + net_buf_simple *msg; + undefined *puVar2; + undefined *puVar3; + bt_mesh_comp *pbVar4; + size_t sVar5; + int iVar6; + int *piVar7; + code *pcVar8; + bt_mesh_model_pub *pbVar9; + void *pvVar10; + byte bStack35; + undefined2 uStack34; + u8_t fault_count; + u16_t company_id; + + pbVar9 = mod->pub; + pvVar10 = mod->user_data; + msg = pbVar9->msg; + bt_mesh_model_msg_init(msg,4); + puVar2 = (undefined *)net_buf_simple_add(msg,1); + puVar3 = (undefined *)net_buf_simple_add(msg,2); + pbVar4 = bt_mesh_comp_get(); + piVar7 = *(int **)((int)pvVar10 + 4); + if ((piVar7 == (int *)0x0) || (*piVar7 == 0)) { + printf("No callback for getting faults\r\n"); + } + else { + sVar5 = net_buf_simple_tailroom(msg); + bStack35 = (byte)sVar5; + pcVar8 = **(code ***)((int)pvVar10 + 4); + iVar6 = (*pcVar8)(mod,puVar2,&uStack34,msg->data + msg->len,&bStack35,pcVar8); + if (iVar6 == 0) { + *puVar3 = (char)uStack34; + puVar3[1] = (char)((ushort)uStack34 >> 8); + net_buf_simple_add(msg,(uint)bStack35); + goto LAB_23041a24; + } + printf("Failed to get faults (err %d)\r\n",iVar6); + } + uVar1 = pbVar4->cid; + *puVar3 = (char)uVar1; + puVar3[1] = (char)(uVar1 >> 8); + *puVar2 = 0; + bStack35 = 0; +LAB_23041a24: + *(byte *)&pbVar9->field_0xb = *(byte *)&pbVar9->field_0xb & 0xdf | (bStack35 != 0) << 5; + return 0; +} + + + +int bt_mesh_health_srv_init(bt_mesh_model *model,_Bool primary) + +{ + bt_mesh_health_srv *pbVar1; + char *fmt; + undefined3 in_register_0000202d; + + pbVar1 = (bt_mesh_health_srv *)model->user_data; + if (pbVar1 == (bt_mesh_health_srv *)0x0) { + if (CONCAT31(in_register_0000202d,primary) != 0) { + fmt = "No Health Server context provided\r\n"; +LAB_23041a80: + printf(fmt); + return -0x16; + } + } + else { + if (model->pub == (bt_mesh_model_pub *)0x0) { + fmt = "Health Server has no publication support\r\n"; + goto LAB_23041a80; + } + model->pub->update = health_pub_update; + k_delayed_work_init(&pbVar1->attn_timer,attention_off); + pbVar1->model = model; + if (CONCAT31(in_register_0000202d,primary) != 0) { + health_srv = pbVar1; + } + } + return 0; +} + + + +void bt_mesh_attention(bt_mesh_model *model,u8_t time) + +{ + anon_subr_void_bt_mesh_model_ptr_for_attn_off *UNRECOVERED_JUMPTABLE; + bt_mesh_health_srv *pbVar1; + undefined3 in_register_0000202d; + anon_subr_void_bt_mesh_model_ptr_for_attn_on *paVar2; + + if (model == (bt_mesh_model *)0x0) { + if (health_srv == (bt_mesh_health_srv *)0x0) { + printf("No Health Server available\r\n"); + return; + } + model = health_srv->model; + pbVar1 = health_srv; + } + else { + pbVar1 = (bt_mesh_health_srv *)model->user_data; + } + if (CONCAT31(in_register_0000202d,time) != 0) { + if ((pbVar1->cb != (bt_mesh_health_srv_cb *)0x0) && + (paVar2 = pbVar1->cb->attn_on, paVar2 != (anon_subr_void_bt_mesh_model_ptr_for_attn_on *)0x0) + ) { + (*paVar2)(model); + } + k_delayed_work_submit(&pbVar1->attn_timer,CONCAT31(in_register_0000202d,time) * 1000); + return; + } + k_delayed_work_cancel(&pbVar1->attn_timer); + if ((pbVar1->cb != (bt_mesh_health_srv_cb *)0x0) && + (UNRECOVERED_JUMPTABLE = pbVar1->cb->attn_off, + UNRECOVERED_JUMPTABLE != (anon_subr_void_bt_mesh_model_ptr_for_attn_off *)0x0)) { + // WARNING: Could not recover jumptable at 0x23041b4c. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(model); + return; + } + return; +} + + + +void attention_set_unrel(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + u8_t time; + + time = net_buf_simple_pull_u8(buf); + bt_mesh_attention(model,time); + return; +} + + + +void attention_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf) + +{ + attention_set_unrel(model,ctx,buf); + send_attention_status(model,ctx); + return; +} + + + +int bt_mesh_provision(u8_t *net_key,u16_t net_idx,u8_t flags,u32_t_conflict iv_index,u16_t addr, + u8_t *dev_key) + +{ + int iVar1; + uint uVar2; + int iVar3; + undefined2 in_register_0000202e; + undefined3 in_register_00002031; + byte *pbVar4; + + iVar1 = 0; + printf("\nmesh provision, network key :"); + do { + pbVar4 = net_key + iVar1; + iVar1 = iVar1 + 1; + printf("%02x",(uint)*pbVar4); + } while (iVar1 != 0x10); + printf("\nmesh provision, device key :"); + iVar1 = 0; + do { + pbVar4 = dev_key + iVar1; + iVar1 = iVar1 + 1; + printf("%02x",(uint)*pbVar4); + } while (iVar1 != 0x10); + printf("\nmesh provison, network key index :0x%04x flags :0x%02x iv index :0x%04x\n", + CONCAT22(in_register_0000202e,net_idx),CONCAT31(in_register_00002031,flags),iv_index); + uVar2 = atomic_or(bt_mesh.flags,1); + iVar1 = -0x45; + if ((uVar2 & 1) == 0) { + iVar3 = bt_mesh_proxy_prov_disable(false); + iVar1 = bt_mesh_net_create(net_idx,flags,net_key,iv_index); + if (iVar1 == 0) { + bt_mesh.seq = 0; + bt_mesh_comp_provision(addr); + memcpy(bt_mesh.dev_key,dev_key,0x10); + bt_mesh_net_start(); + } + else { + atomic_and(bt_mesh.flags,-2); + if (iVar3 == 0) { + bt_mesh_proxy_prov_enable(); + } + } + } + return iVar1; +} + + + +void bt_mesh_reset(void) + +{ + uint uVar1; + + uVar1 = atomic_get(bt_mesh.flags); + if ((uVar1 & 1) != 0) { + bt_mesh.iv_index = 0; + bt_mesh.seq = 0; + memset(bt_mesh.flags,0,4); + k_delayed_work_cancel(&bt_mesh.ivu_timer); + bt_mesh_cfg_reset(); + bt_mesh_rx_reset(); + bt_mesh_tx_reset(); + bt_mesh_lpn_disable(true); + bt_mesh_friend_clear_net_idx(0xffff); + bt_mesh_proxy_gatt_disable(); + memset(bt_mesh.dev_key,0,0x10); + bt_mesh_scan_disable(); + bt_mesh_beacon_disable(); + bt_mesh_comp_unprovision(); + bt_mesh_prov_reset(); + return; + } + return; +} + + + +_Bool bt_mesh_is_provisioned(void) + +{ + atomic_val_t aVar1; + + aVar1 = atomic_get(bt_mesh.flags); + return (_Bool)((byte)aVar1 & 1); +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bt_mesh_prov_enable(bt_mesh_prov_bearer_t bearers) + +{ + int iVar1; + _Bool _Var2; + undefined3 extraout_var; + bt_mesh_prov_conflict8 *pbVar3; + undefined4 uStack36; + bt_uuid_128 uuid; + + _Var2 = bt_mesh_is_provisioned(); + iVar1 = -0x45; + if (CONCAT31(extraout_var,_Var2) == 0) { + pbVar3 = bt_mesh_prov_get(); + uStack36 = 2; + uuid._0_4_ = 0; + uuid.val._3_4_ = 0; + uuid.val._7_4_ = 0; + uuid.val[11] = '\0'; + memcpy((void *)((int)&uStack36 + 1),pbVar3->uuid,0x10); + if ((bearers & BT_MESH_PROV_ADV) != 0) { + bt_mesh_scan_enable(); + bt_mesh_beacon_enable(); + } + iVar1 = 0; + if ((bearers & BT_MESH_PROV_GATT) != 0) { + bt_mesh_proxy_prov_enable(); + bt_mesh_adv_update(); + } + } + return iVar1; +} + + + +int bt_mesh_prov_disable(bt_mesh_prov_bearer_t bearers) + +{ + int iVar1; + _Bool _Var2; + undefined3 extraout_var; + + _Var2 = bt_mesh_is_provisioned(); + iVar1 = -0x45; + if (CONCAT31(extraout_var,_Var2) == 0) { + if ((bearers & BT_MESH_PROV_ADV) != 0) { + bt_mesh_beacon_disable(); + bt_mesh_scan_disable(); + } + iVar1 = 0; + if ((bearers & BT_MESH_PROV_GATT) != 0) { + bt_mesh_proxy_prov_disable(true); + } + } + return iVar1; +} + + + +int bt_mesh_init(bt_mesh_prov_conflict5 *prov,bt_mesh_comp *comp) + +{ + int iVar1; + + iVar1 = bt_mesh_comp_register(comp); + if ((iVar1 == 0) && (iVar1 = bt_mesh_prov_init((bt_mesh_prov_conflict8 *)prov), iVar1 == 0)) { + bt_mesh_net_init(); + bt_mesh_trans_init(); + bt_mesh_beacon_init(); + bt_mesh_adv_init(); + bt_mesh_proxy_init(); + } + return iVar1; +} + + + +void send_cb_finalize(bt_mesh_send_cb *cb,void *cb_data) + +{ + if (cb == (bt_mesh_send_cb *)0x0) { + return; + } + if (cb->start != (anon_subr_void_u16_t_int_void_ptr_for_start *)0x0) { + (*cb->start)(0,0,cb_data); + } + if (cb->end != (anon_subr_void_int_void_ptr_for_end *)0x0) { + // WARNING: Could not recover jumptable at 0x23041e42. Too many branches + // WARNING: Treating indirect jump as call + (*cb->end)(0,cb_data); + return; + } + return; +} + + + +_Bool auth_match(bt_mesh_subnet_keys *keys,u8_t *net_id,u8_t flags,u32_t_conflict iv_index, + u8_t *auth) + +{ + int iVar1; + char *pcVar2; + char *pcVar3; + u8_t auStack40 [4]; + u8_t net_auth [8]; + + iVar1 = memcmp(net_id,keys->net_id,8); + if (iVar1 == 0) { + bt_mesh_beacon_auth(keys->beacon,flags,keys->net_id,iv_index,auStack40); + iVar1 = memcmp(auth,auStack40,8); + if (iVar1 == 0) { + return true; + } + pcVar2 = bt_hex_real(auth,8); + pcVar3 = bt_hex_real(auStack40,8); + printf("Authentication Value %s != %s\r\n",pcVar2,pcVar3); + } + return false; +} + + + +// WARNING: Variable defined which should be unmapped: hash2 + +int net_decrypt(u8_t *enc,u8_t *priv,u8_t *data,size_t data_len,bt_mesh_net_rx_conflict4 *rx, + net_buf_simple *buf) + +{ + u16_t uVar1; + void *__dest; + int iVar2; + u64_t *puVar3; + uint uVar4; + bt_conn *pbVar5; + int iStack36; + u32_t_conflict hash2; + + *(byte *)&rx->field_0x20 = + *(byte *)&rx->field_0x20 & 0xfe | (byte)bt_mesh.iv_index & 1 ^ *data >> 7; + buf->len = 0; + buf->data = buf->__buf; + __dest = net_buf_simple_add(buf,data_len); + memcpy(__dest,data,data_len); + iVar2 = bt_mesh_net_obfuscate(buf->data,bt_mesh.iv_index - (*(uint *)&rx->field_0x20 & 1),priv); + if (iVar2 == 0) { + if ((*(byte *)&rx->field_0x20 & 0x30) == 0) { + pbVar5 = (bt_conn *) + ((bt_mesh.iv_index - (*(uint *)&rx->field_0x20 & 1)) * 0x100 | (uint)buf->data[2]); + memcpy(&iStack36,buf->data + 3,4); + puVar3 = msg_cache; + do { + if ((((prov_link *)puVar3)->flags[0] == iStack36) && (((prov_link *)puVar3)->conn == pbVar5) + ) { + printf("Duplicate found in Network Message Cache\r\n"); + return -0x45; + } + puVar3 = (u64_t *)((prov_link *)puVar3)->dhkey; + } while ((prov_link *)puVar3 != &link); + uVar4 = (uint)msg_cache_next; + rx->msg_cache_idx = msg_cache_next; + *(int *)(msg_cache + uVar4) = iStack36; + *(bt_conn **)((int)msg_cache + uVar4 * 8 + 4) = pbVar5; + msg_cache_next = (u16_t)((uVar4 + 1 & 0xffff) % 0xc); + } + uVar1 = CONCAT11(buf->data[5],buf->data[6]); + (rx->ctx).addr = uVar1; + if ((short)uVar1 < 1) { + printf("Ignoring non-unicast src addr 0x%04x\r\n"); + iVar2 = -0x16; + } + else { + iVar2 = bt_mesh_net_decrypt(enc,buf,bt_mesh.iv_index - (*(uint *)&rx->field_0x20 & 1), + (_Bool)((*(byte *)&rx->field_0x20 & 0x30) == 0x30)); + } + } + else { + iVar2 = -2; + } + return iVar2; +} + + + +int atomic_test_bit(void) + +{ + atomic_val_t aVar1; + + aVar1 = atomic_get(bt_mesh.flags); + return aVar1 >> 2 & 1; +} + + + +bt_mesh_subnet * bt_mesh_subnet_get(u16_t net_idx) + +{ + undefined2 in_register_0000202a; + uint uVar1; + int iVar2; + bt_mesh_subnet *pbVar3; + + uVar1 = CONCAT22(in_register_0000202a,net_idx); + if (uVar1 == 0xffff) { + pbVar3 = bt_mesh.sub; + } + else { + if ((uint)bt_mesh.sub[0].net_idx == uVar1) { + iVar2 = 0; + } + else { + if ((uint)bt_mesh.sub[1].net_idx != uVar1) { + return (bt_mesh_subnet *)0x0; + } + iVar2 = 1; + } + pbVar3 = bt_mesh.sub + iVar2; + } + return pbVar3; +} + + + +// WARNING: Variable defined which should be unmapped: p + +int bt_mesh_net_keys_create(bt_mesh_subnet_keys *keys,u8_t *key) + +{ + int iVar1; + char *fmt; + u8_t auStack20 [3]; + u8_t uStack17; + u8_t p [1]; + u8_t nid; + + auStack20[0] = '\0'; + iVar1 = bt_mesh_k2(key,auStack20,1,&uStack17,keys->enc,keys->privacy); + if (iVar1 == 0) { + memcpy(keys,key,0x10); + keys->nid = uStack17; + iVar1 = bt_mesh_k3(key,keys->net_id); + if (iVar1 == 0) { + iVar1 = bt_mesh_id128(key,"nkik",keys->identity); + if (iVar1 == 0) { + iVar1 = bt_mesh_id128(key,"nkbk",keys->beacon); + if (iVar1 == 0) { + return 0; + } + fmt = "Unable to generate beacon key\r\n"; + } + else { + fmt = "Unable to generate IdentityKey\r\n"; + } + } + else { + fmt = "Unable to generate Net ID\r\n"; + } + } + else { + fmt = "Unable to generate NID, EncKey & PrivacyKey\r\n"; + } + printf(fmt); + return iVar1; +} + + + +int friend_cred_set(friend_cred *cred,u8_t idx,u8_t *net_key) + +{ + u16_t uVar1; + u16_t uVar2; + int iVar3; + undefined3 in_register_0000202d; + u8_t uStack44; + undefined uStack43; + undefined uStack42; + undefined uStack41; + u8_t p [9]; + + iVar3 = CONCAT31(in_register_0000202d,idx); + uVar1 = cred->addr; + if (bt_mesh.lpn.frnd == uVar1) { + uVar1 = bt_mesh_primary_addr(); + uVar2 = cred->addr; + } + else { + uVar2 = bt_mesh_primary_addr(); + } + uStack44 = '\x01'; + uStack43 = (undefined)(uVar1 >> 8); + uStack41 = (undefined)(uVar2 >> 8); + p[0] = (u8_t)uVar2; + p[2] = (u8_t)cred->lpn_counter; + p[1] = (u8_t)(cred->lpn_counter >> 8); + p[3] = (u8_t)(cred->frnd_counter >> 8); + p[4] = (u8_t)cred->frnd_counter; + uStack42 = (undefined)uVar1; + iVar3 = bt_mesh_k2(net_key,&uStack44,9,(u8_t *)(cred->cred + iVar3),cred->cred[iVar3].enc, + cred->cred[iVar3].privacy); + if (iVar3 != 0) { + printf("Unable to generate NID, EncKey & PrivacyKey\r\n"); + } + return iVar3; +} + + + +void friend_cred_refresh(u16_t net_idx) + +{ + undefined2 in_register_0000202a; + + if ((friend_cred[0].addr != 0) && + ((uint)friend_cred[0].net_idx == CONCAT22(in_register_0000202a,net_idx))) { + memcpy(friend_cred[0].cred,friend_cred[0].cred + 1,0x21); + } + if ((friend_cred[1].addr != 0) && + ((uint)friend_cred[1].net_idx == CONCAT22(in_register_0000202a,net_idx))) { + memcpy(friend_cred[1].cred,friend_cred[1].cred + 1,0x21); + return; + } + return; +} + + + +int friend_cred_update(bt_mesh_subnet *sub) + +{ + int iVar1; + + if ((((friend_cred[0].addr == 0) || (friend_cred[0].net_idx != sub->net_idx)) || + (iVar1 = friend_cred_set(friend_cred,'\x01',(u8_t *)(sub->keys + 1)), iVar1 == 0)) && + (((friend_cred[1].addr == 0 || (friend_cred[1].net_idx != sub->net_idx)) || + (iVar1 = friend_cred_set(friend_cred + 1,'\x01',(u8_t *)(sub->keys + 1)), iVar1 == 0)))) { + iVar1 = 0; + } + return iVar1; +} + + + +void friend_cred_clear(friend_cred *cred) + +{ + cred->net_idx = 0xffff; + cred->addr = 0; + cred->lpn_counter = 0; + cred->frnd_counter = 0; + memset(cred->cred,0,0x42); + return; +} + + + +friend_cred * +friend_cred_create(bt_mesh_subnet *sub,u16_t addr,u16_t lpn_counter,u16_t frnd_counter) + +{ + u16_t uVar1; + friend_cred *cred; + undefined2 in_register_0000202e; + int iVar2; + + if ((friend_cred[0].addr == 0) || + ((CONCAT22(in_register_0000202e,addr) == (uint)friend_cred[0].addr && + (friend_cred[0].net_idx == sub->net_idx)))) { + iVar2 = 0; + } + else { + if ((friend_cred[1].addr != 0) && + ((CONCAT22(in_register_0000202e,addr) != (uint)friend_cred[1].addr || + (friend_cred[1].net_idx != sub->net_idx)))) { + printf("No free friend credential slots\r\n"); + return (friend_cred *)0x0; + } + iVar2 = 1; + } + cred = friend_cred + iVar2; + uVar1 = sub->net_idx; + friend_cred[iVar2].addr = addr; + friend_cred[iVar2].lpn_counter = lpn_counter; + cred->net_idx = uVar1; + friend_cred[iVar2].frnd_counter = frnd_counter; + iVar2 = friend_cred_set(cred,'\0',(u8_t *)sub->keys); + if (iVar2 == 0) { + if (sub->kr_flag == false) { + return cred; + } + iVar2 = friend_cred_set(cred,'\x01',(u8_t *)(sub->keys + 1)); + if (iVar2 == 0) { + return cred; + } + } + friend_cred_clear(cred); + return (friend_cred *)0x0; +} + + + +int friend_cred_del(u16_t net_idx,u16_t addr) + +{ + undefined2 in_register_0000202a; + friend_cred *cred; + undefined2 in_register_0000202e; + + if (((uint)friend_cred[0].addr == CONCAT22(in_register_0000202e,addr)) && + ((uint)friend_cred[0].net_idx == CONCAT22(in_register_0000202a,net_idx))) { + cred = friend_cred; + } + else { + if (((uint)friend_cred[1].addr != CONCAT22(in_register_0000202e,addr)) || + ((uint)friend_cred[1].net_idx != CONCAT22(in_register_0000202a,net_idx))) { + return -2; + } + cred = friend_cred + 1; + } + friend_cred_clear(cred); + return 0; +} + + + +int friend_cred_get(bt_mesh_subnet *sub,u16_t addr,u8_t *nid,u8_t **enc,u8_t **priv) + +{ + undefined2 in_register_0000202e; + uint uVar1; + int iVar2; + + uVar1 = CONCAT22(in_register_0000202e,addr); + if (friend_cred[0].net_idx == sub->net_idx) { + if (uVar1 == 0) { + iVar2 = 0; + goto LAB_23042418; + } + iVar2 = 0; + if ((uint)friend_cred[0].addr == uVar1) goto LAB_23042418; + } + if (friend_cred[1].net_idx != sub->net_idx) { + return -2; + } + if ((uVar1 != 0) && ((uint)friend_cred[1].addr != uVar1)) { + return -2; + } + iVar2 = 1; +LAB_23042418: + if (nid != (u8_t *)0x0) { + *nid = friend_cred[iVar2].cred[sub->kr_flag].nid; + } + if (enc != (u8_t **)0x0) { + *enc = friend_cred[iVar2].cred[sub->kr_flag].enc; + } + if (priv != (u8_t **)0x0) { + *priv = friend_cred[iVar2].cred[sub->kr_flag].privacy; + } + return 0; +} + + + +u8_t bt_mesh_net_flags(bt_mesh_subnet *sub) + +{ + _Bool _Var1; + int iVar2; + + _Var1 = false; + if (sub != (bt_mesh_subnet *)0x0) { + _Var1 = sub->kr_flag; + } + iVar2 = atomic_test_bit(); + if (iVar2 != 0) { + _Var1 = (_Bool)(_Var1 | 2); + } + return (u8_t)_Var1; +} + + + +int bt_mesh_net_beacon_update(bt_mesh_subnet *sub) + +{ + u8_t flags; + int iVar1; + + flags = bt_mesh_net_flags(sub); + iVar1 = 0x89; + if (sub->kr_flag == false) { + iVar1 = 0x30; + } + iVar1 = (int)&sub->beacon_sent + iVar1; + iVar1 = bt_mesh_beacon_auth((u8_t *)(iVar1 + 0x49),flags,(u8_t *)(iVar1 + 0x21),bt_mesh.iv_index, + sub->auth); + return iVar1; +} + + + +int bt_mesh_net_create(u16_t idx,u8_t flags,u8_t *key,u32_t_conflict iv_index) + +{ + int iVar1; + + memset(msg_cache,0,0x60); + msg_cache_next = 0; + bt_mesh.sub[0].kr_flag = (_Bool)(flags & 1); + if ((flags & 1) == 0) { + iVar1 = bt_mesh_net_keys_create(bt_mesh.sub[0].keys,key); + if (iVar1 == 0) goto LAB_23042542; + } + else { + iVar1 = bt_mesh_net_keys_create(bt_mesh.sub[0].keys + 1,key); + if (iVar1 == 0) { + bt_mesh.sub[0].kr_phase = '\x02'; +LAB_23042542: + bt_mesh.sub[0].node_id = '\0'; + bt_mesh.iv_index = iv_index; + bt_mesh.sub[0].net_idx = idx; + if ((flags & 2) == 0) { + atomic_and(bt_mesh.flags,-5); + } + else { + atomic_or(bt_mesh.flags,4); + } + bt_mesh.ivu_duration = '`'; + bt_mesh_net_beacon_update(bt_mesh.sub); + return 0; + } + } + return -5; +} + + + +void bt_mesh_net_revoke_keys(bt_mesh_subnet *sub) + +{ + memcpy(sub->keys,sub->keys + 1,0x59); + if ((bt_mesh.app_keys[0].net_idx == sub->net_idx) && (bt_mesh.app_keys[0].updated != false)) { + memcpy(bt_mesh.app_keys[0].keys,bt_mesh.app_keys[0].keys + 1,0x11); + bt_mesh.app_keys[0].updated = false; + } + if ((bt_mesh.app_keys[1].net_idx == sub->net_idx) && (bt_mesh.app_keys[1].updated != false)) { + memcpy(bt_mesh.app_keys[1].keys,bt_mesh.app_keys[1].keys + 1,0x11); + bt_mesh.app_keys[1].updated = false; + } + return; +} + + + +_Bool bt_mesh_kr_update(bt_mesh_subnet *sub,u8_t new_kr,_Bool new_key) + +{ + u8_t uVar1; + undefined3 in_register_0000202d; + uint uVar2; + undefined uVar3; + undefined3 in_register_00002031; + + uVar2 = CONCAT31(in_register_0000202d,new_kr); + uVar1 = sub->kr_phase; + if (((uint)sub->kr_flag == uVar2) || (uVar1 != '\0')) { + *(bool *)&sub->kr_flag = uVar2 != 0; + if (uVar2 == 0) { + if (uVar1 == '\x01') { + if (CONCAT31(in_register_00002031,new_key) == 0) { + return new_key; + } + } + else { + if (uVar1 != '\x02') goto LAB_23042628; + } + bt_mesh_net_revoke_keys(sub); + friend_cred_refresh(sub->net_idx); + sub->kr_phase = '\0'; + } + else { + if (uVar1 != '\x01') { + return false; + } + sub->kr_phase = '\x02'; + } + uVar3 = 1; + } + else { + printf("KR change in normal operation. Are we blacklisted?\r\n"); +LAB_23042628: + uVar3 = 0; + } + return (_Bool)uVar3; +} + + + +void bt_mesh_rpl_reset(void) + +{ + bt_mesh_net_conflict9 *pbVar1; + + pbVar1 = &bt_mesh; + do { + if (pbVar1->rpl[0].src != 0) { + if (pbVar1->rpl[0].old_iv == false) { + pbVar1->rpl[0].old_iv = true; + } + else { + memset(pbVar1->rpl,0,8); + } + } + pbVar1 = (bt_mesh_net_conflict9 *)pbVar1->flags; + } while (pbVar1 != (bt_mesh_net_conflict9 *)0x4200d6e4); + return; +} + + + +void bt_mesh_net_sec_update(bt_mesh_subnet *sub) + +{ + u8_t uVar1; + u16_t net_idx; + undefined3 extraout_var; + + if (sub == (bt_mesh_subnet *)0x0) { + net_idx = 0xffff; + } + else { + net_idx = sub->net_idx; + } + bt_mesh_friend_sec_update(net_idx); + uVar1 = bt_mesh_gatt_proxy_get(); + if (CONCAT31(extraout_var,uVar1) == 1) { + bt_mesh_proxy_beacon_send(sub); + return; + } + return; +} + + + +_Bool bt_mesh_net_iv_update(u32_t_conflict iv_index,_Bool iv_update) + +{ + _Bool _Var1; + int iVar2; + char *fmt; + undefined3 extraout_var; + undefined3 in_register_0000202d; + int iVar3; + + iVar3 = CONCAT31(in_register_0000202d,iv_update); + iVar2 = atomic_test_bit(); + if (iVar2 == 0) { + if (bt_mesh.iv_index == iv_index) { + return false; + } + if ((iv_index < bt_mesh.iv_index) || (bt_mesh.iv_index + 0x2a < iv_index)) { + fmt = "IV Index out of sync: 0x%08x != 0x%08x\r\n"; + goto LAB_2304271c; + } + if (iv_index <= bt_mesh.iv_index + 1) { + if (bt_mesh.iv_index + 1 == iv_index) { + if (iVar3 == 0) { + printf("Ignoring new index in normal mode\r\n"); + return iv_update; + } + } + else { + if (iVar3 == 0) { + return iv_update; + } + } + goto LAB_230427e4; + } + printf("Performing IV Index Recovery\r\n"); + memset(bt_mesh.rpl,0,0x28); + bt_mesh.seq = 0; + bt_mesh.iv_index = iv_index; + if (iVar3 == 0) goto LAB_23042820; + } + else { + if (bt_mesh.iv_index != iv_index) { + fmt = "IV Index mismatch: 0x%08x != 0x%08x\r\n"; +LAB_2304271c: + printf(fmt,iv_index); + return false; + } + if (iVar3 != 0) { + return false; + } +LAB_230427e4: + if (bt_mesh.ivu_duration < 0x60) { + printf("IV Update before minimum duration\r\n"); + return false; + } + if (iVar3 == 0) { + _Var1 = bt_mesh_tx_in_progress(); + if (CONCAT31(extraout_var,_Var1) != 0) { + printf("IV Update deferred because of pending transfer\r\n"); + atomic_or(bt_mesh.flags,0x20); + return iv_update; + } +LAB_23042820: + atomic_and(bt_mesh.flags,-5); + goto LAB_23042778; + } + } + atomic_or(bt_mesh.flags,4); +LAB_23042778: + bt_mesh.ivu_duration = '\0'; + if (iVar3 == 0) { + bt_mesh.seq = 0; + } + else { + bt_mesh.iv_index = iv_index; + bt_mesh_rpl_reset(); + } + k_delayed_work_submit(&bt_mesh.ivu_timer,0xa4cb800); + if (bt_mesh.sub[0].net_idx != 0xffff) { + bt_mesh_net_beacon_update(bt_mesh.sub); + } + if (bt_mesh.sub[1].net_idx != 0xffff) { + bt_mesh_net_beacon_update(bt_mesh.sub + 1); + return true; + } + return true; +} + + + +void ivu_refresh(k_work *work) + +{ + int iVar1; + + bt_mesh.ivu_duration = bt_mesh.ivu_duration + 0x30; + if (bt_mesh.ivu_duration < 0x60) { + k_delayed_work_submit(&bt_mesh.ivu_timer,0xa4cb800); + return; + } + iVar1 = atomic_test_bit(); + if (iVar1 != 0) { + bt_mesh_beacon_ivu_initiator(true); + bt_mesh_net_iv_update(bt_mesh.iv_index,false); + return; + } + return; +} + + + +u32_t_conflict bt_mesh_next_seq(void) + +{ + u32_t_conflict uVar1; + int iVar2; + + uVar1 = bt_mesh.seq; + bt_mesh.seq = bt_mesh.seq + 1; + iVar2 = atomic_test_bit(); + if (((iVar2 == 0) && (8000000 < bt_mesh.seq)) && + ((bt_mesh.sub[0].net_idx == 0 || (bt_mesh.sub[1].net_idx == 0)))) { + bt_mesh_beacon_ivu_initiator(true); + bt_mesh_net_iv_update(bt_mesh.iv_index + 1,true); + bt_mesh_net_sec_update((bt_mesh_subnet *)0x0); + } + return uVar1; +} + + + +int bt_mesh_net_resend(bt_mesh_subnet *sub,net_buf *buf,_Bool new_key,bt_mesh_send_cb *cb, + void *cb_data) + +{ + undefined uVar1; + undefined uVar2; + u32_t_conflict uVar3; + u8_t *pdu; + _Bool _Var4; + int iVar5; + char *fmt; + u32_t_conflict uVar6; + undefined3 extraout_var; + undefined3 in_register_00002031; + net_buf_simple *buf_00; + u8_t *privacy_key; + + uVar3 = bt_mesh.iv_index; + pdu = *(u8_t **)&buf->field_4; + privacy_key = sub->keys[CONCAT31(in_register_00002031,new_key)].privacy; + iVar5 = atomic_test_bit(); + iVar5 = bt_mesh_net_obfuscate(pdu,uVar3 - iVar5,privacy_key); + uVar3 = bt_mesh.iv_index; + if (iVar5 == 0) { + iVar5 = atomic_test_bit(); + pdu = sub->keys[CONCAT31(in_register_00002031,new_key)].enc; + buf_00 = (net_buf_simple *)&buf->field_4; + iVar5 = bt_mesh_net_decrypt(pdu,buf_00,uVar3 - iVar5,false); + if (iVar5 == 0) { + uVar6 = bt_mesh_next_seq(); + *(undefined *)(*(int *)&buf->field_4 + 2) = (char)(uVar6 >> 0x10); + *(undefined *)(*(int *)&buf->field_4 + 3) = (char)(uVar6 >> 8); + uVar3 = bt_mesh.iv_index; + *(undefined *)(*(int *)&buf->field_4 + 4) = (char)uVar6; + uVar1 = *(undefined *)(*(int *)&buf->field_4 + 7); + uVar2 = *(undefined *)(*(int *)&buf->field_4 + 8); + iVar5 = atomic_test_bit(); + iVar5 = bt_mesh_net_encrypt(pdu,buf_00,uVar3 - iVar5,false); + uVar3 = bt_mesh.iv_index; + if (iVar5 == 0) { + pdu = *(u8_t **)&buf->field_4; + iVar5 = atomic_test_bit(); + iVar5 = bt_mesh_net_obfuscate(pdu,uVar3 - iVar5,privacy_key); + if (iVar5 == 0) { + _Var4 = bt_mesh_proxy_relay(buf_00,CONCAT11(uVar1,uVar2)); + if (CONCAT31(extraout_var,_Var4) != 0) { + send_cb_finalize(cb,cb_data); + return 0; + } + bt_mesh_adv_send(buf,cb,cb_data); + return 0; + } + fmt = "obfuscate failed (err %d)\r\n"; + } + else { + fmt = "encrypt failed (err %d)\r\n"; + } + } + else { + fmt = "decrypt failed (err %d)\r\n"; + } + } + else { + fmt = "deobfuscate failed (err %d)\r\n"; + } + printf(fmt,iVar5); + return iVar5; +} + + + +int bt_mesh_net_encode(bt_mesh_net_tx_conflict4 *tx,net_buf_simple *buf,_Bool proxy) + +{ + u16_t uVar1; + uint uVar2; + u8_t *privacy_key; + u8_t *key; + size_t sVar3; + char *fmt; + undefined *puVar4; + u32_t_conflict uVar5; + byte val; + int iVar6; + bt_mesh_subnet *pbVar7; + + uVar1 = tx->ctx->app_idx; + if ((uVar1 == 0xffff) && (sVar3 = net_buf_simple_tailroom(buf), sVar3 < 8)) { + fmt = "Insufficient MIC space for CTL PDU\r\n"; +LAB_23042a6c: + printf(fmt); + return -0x16; + } + sVar3 = net_buf_simple_tailroom(buf); + if (sVar3 < 4) { + fmt = "Insufficient MIC space for PDU\r\n"; + goto LAB_23042a6c; + } + net_buf_simple_push_be16(buf,tx->ctx->addr); + net_buf_simple_push_be16(buf,tx->src); + puVar4 = (undefined *)net_buf_simple_push(buf,3); + uVar5 = bt_mesh_next_seq(); + *puVar4 = (char)(uVar5 >> 0x10); + puVar4[1] = (char)(uVar5 >> 8); + puVar4[2] = (char)uVar5; + val = tx->ctx->send_ttl; + if (uVar1 == 0xffff) { + val = val | 0x80; + } + net_buf_simple_push_u8(buf,val); + pbVar7 = tx->sub; + if ((*(byte *)&tx->field_0xb & 1) == 0) { + *(byte *)&tx->field_0xb = *(byte *)&tx->field_0xb & 0xfe; +LAB_23042bb2: + uVar2 = (uint)pbVar7->kr_flag; + val = pbVar7->keys[uVar2].nid; + key = pbVar7->keys[uVar2].enc; + privacy_key = pbVar7->keys[uVar2].privacy; + } + else { + iVar6 = 0; + if (friend_cred[0].net_idx != pbVar7->net_idx) { + if (friend_cred[1].net_idx != pbVar7->net_idx) { + printf("Falling back to master credentials\r\n"); + *(byte *)&tx->field_0xb = *(byte *)&tx->field_0xb & 0xfe; + pbVar7 = tx->sub; + goto LAB_23042bb2; + } + iVar6 = 1; + } + uVar2 = (uint)pbVar7->kr_flag; + val = friend_cred[iVar6].cred[uVar2].nid; + key = friend_cred[iVar6].cred[uVar2].enc; + privacy_key = friend_cred[iVar6].cred[uVar2].privacy; + } + iVar6 = atomic_test_bit(); + net_buf_simple_push_u8(buf,val | ((char)bt_mesh.iv_index - (char)iVar6) * -0x80); + uVar5 = bt_mesh.iv_index; + iVar6 = atomic_test_bit(); + iVar6 = bt_mesh_net_encrypt(key,buf,uVar5 - iVar6,proxy); + uVar5 = bt_mesh.iv_index; + if (iVar6 != 0) { + return iVar6; + } + key = buf->data; + iVar6 = atomic_test_bit(); + iVar6 = bt_mesh_net_obfuscate(key,uVar5 - iVar6,privacy_key); + return iVar6; +} + + + +int bt_mesh_net_send(bt_mesh_net_tx_conflict4 *tx,net_buf *buf,bt_mesh_send_cb *cb,void *cb_data) + +{ + u8_t uVar1; + _Bool _Var2; + int iVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + net_buf *buf_00; + bt_mesh_elem *pbVar4; + bt_mesh_msg_ctx *pbVar5; + + pbVar5 = tx->ctx; + if (pbVar5->send_ttl == -1) { + uVar1 = bt_mesh_default_ttl_get(); + pbVar5->send_ttl = uVar1; + } + iVar3 = bt_mesh_net_encode(tx,(net_buf_simple *)&buf->field_4,false); + if (iVar3 == 0) { + if (((tx->ctx->send_ttl == '\x01') || + (_Var2 = bt_mesh_proxy_relay((net_buf_simple *)&buf->field_4,tx->ctx->addr), + CONCAT31(extraout_var,_Var2) == 0)) || ((short)tx->ctx->addr < 1)) { + _Var2 = bt_mesh_fixed_group_match(tx->ctx->addr); + if ((CONCAT31(extraout_var_00,_Var2) == 0) && + (pbVar4 = bt_mesh_elem_find(tx->ctx->addr), pbVar4 == (bt_mesh_elem *)0x0)) { + if (tx->ctx->send_ttl != '\x01') { + bt_mesh_adv_send(buf,cb,cb_data); + } + } + else { + if ((cb != (bt_mesh_send_cb *)0x0) && + (cb->start != (anon_subr_void_u16_t_int_void_ptr_for_start *)0x0)) { + (*cb->start)(0,0,cb_data); + } + buf_00 = net_buf_ref(buf); + net_buf_slist_put(&bt_mesh.local_queue,buf_00); + if ((cb != (bt_mesh_send_cb *)0x0) && + (cb->end != (anon_subr_void_int_void_ptr_for_end *)0x0)) { + (*cb->end)(0,cb_data); + } + k_work_submit(&bt_mesh.local_work); + } + } + else { + send_cb_finalize(cb,cb_data); + } + } + net_buf_unref(buf); + return iVar3; +} + + + +bt_mesh_subnet * +bt_mesh_subnet_find(u8_t *net_id,u8_t flags,u32_t_conflict iv_index,u8_t *auth,_Bool *new_key) + +{ + _Bool _Var1; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + bt_mesh_subnet *pbVar2; + + if (bt_mesh.sub[0].net_idx == 0xffff) { +LAB_23042d44: + if (bt_mesh.sub[1].net_idx != 0xffff) { + _Var1 = auth_match(bt_mesh.sub[1].keys,net_id,flags,iv_index,auth); + if (CONCAT31(extraout_var_01,_Var1) != 0) { + pbVar2 = bt_mesh.sub + 1; + goto LAB_23042d66; + } + if ((bt_mesh.sub[1].kr_phase != '\0') && + (_Var1 = auth_match(bt_mesh.sub[1].keys + 1,net_id,flags,iv_index,auth), + CONCAT31(extraout_var_02,_Var1) != 0)) { + pbVar2 = bt_mesh.sub + 1; +LAB_23042da0: + *new_key = true; + return pbVar2; + } + } + pbVar2 = (bt_mesh_subnet *)0x0; + } + else { + _Var1 = auth_match(bt_mesh.sub[0].keys,net_id,flags,iv_index,auth); + if (CONCAT31(extraout_var,_Var1) == 0) { + if ((bt_mesh.sub[0].kr_phase != '\0') && + (_Var1 = auth_match(bt_mesh.sub[0].keys + 1,net_id,flags,iv_index,auth), + CONCAT31(extraout_var_00,_Var1) != 0)) { + pbVar2 = bt_mesh.sub; + goto LAB_23042da0; + } + goto LAB_23042d44; + } + pbVar2 = bt_mesh.sub; +LAB_23042d66: + *new_key = false; + } + return pbVar2; +} + + + +int bt_mesh_net_decode(net_buf_simple *data,bt_mesh_net_if net_if,bt_mesh_net_rx_conflict4 *rx, + net_buf_simple *buf) + +{ + u16_t uVar1; + uint data_len; + char *fmt; + int iVar2; + bt_mesh_elem *pbVar3; + undefined3 in_register_0000202d; + u8_t *puVar4; + byte bVar5; + int iVar6; + bt_mesh_net_conflict9 *pbVar7; + byte *data_00; + + if (data->len < 0x12) { + printf("Dropping too short mesh packet (len %u)\r\n"); + fmt = bt_hex_real(data->data,(uint)data->len); + printf("%s\r\n",fmt); + return -0x16; + } + *(byte *)&rx->field_0x20 = *(byte *)&rx->field_0x20 & 0xcf | (byte)(((uint)net_if & 3) << 4); + data_00 = data->data; + data_len = (uint)data->len; + pbVar7 = &bt_mesh; + iVar6 = 0; + while (uVar1 = pbVar7->sub[0].net_idx, uVar1 == 0xffff) { +LAB_23043054: + pbVar7 = (bt_mesh_net_conflict9 *)&pbVar7->frnd[1].seg[0].queue.tail; + if (iVar6 != 0) { + return -2; + } + iVar6 = 1; + } + if (friend_cred[0].net_idx == uVar1) { + if ((friend_cred[0].cred[0].nid != (*data_00 & 0x7f)) || + (iVar2 = net_decrypt(friend_cred[0].cred[0].enc,friend_cred[0].cred[0].privacy,data_00, + data_len,rx,buf), iVar2 != 0)) { + if ((pbVar7->sub[0].kr_phase == '\0') || + ((friend_cred[0].cred[1].nid != (*data_00 & 0x7f) || + (iVar2 = net_decrypt(friend_cred[0].cred[1].enc,friend_cred[0].cred[1].privacy,data_00, + data_len,rx,buf), iVar2 != 0)))) goto LAB_23042eca; +LAB_23043010: + *(byte *)&rx->field_0x20 = *(byte *)&rx->field_0x20 | 2; + } +LAB_23042fd2: + bVar5 = *(byte *)&rx->field_0x20 | 4; + } + else { +LAB_23042eca: + if (friend_cred[1].net_idx == pbVar7->sub[0].net_idx) { + if ((friend_cred[1].cred[0].nid == (*data_00 & 0x7f)) && + (iVar2 = net_decrypt(friend_cred[1].cred[0].enc,friend_cred[1].cred[0].privacy,data_00, + data_len,rx,buf), iVar2 == 0)) goto LAB_23042fd2; + if ((pbVar7->sub[0].kr_phase != '\0') && + ((friend_cred[1].cred[1].nid == (*data_00 & 0x7f) && + (iVar2 = net_decrypt(friend_cred[1].cred[1].enc,friend_cred[1].cred[1].privacy,data_00, + data_len,rx,buf), iVar2 == 0)))) goto LAB_23043010; + } + if ((pbVar7->sub[0].keys[0].nid == (*data_00 & 0x7f)) && + (iVar2 = net_decrypt(pbVar7->sub[0].keys[0].enc,pbVar7->sub[0].keys[0].privacy,data_00, + data_len,rx,buf), iVar2 == 0)) goto LAB_23042f16; + if (((pbVar7->sub[0].kr_phase == '\0') || (pbVar7->sub[0].keys[1].nid != (*data_00 & 0x7f))) || + (iVar2 = net_decrypt(pbVar7->sub[0].keys[1].enc,pbVar7->sub[0].keys[1].privacy,data_00, + data_len,rx,buf), iVar2 != 0)) goto LAB_23043054; + bVar5 = *(byte *)&rx->field_0x20 | 2; + } + *(byte *)&rx->field_0x20 = bVar5; +LAB_23042f16: + uVar1 = bt_mesh.sub[iVar6].net_idx; + rx->sub = pbVar7->sub; + (rx->ctx).net_idx = uVar1; + (rx->ctx).app_idx = 0xffff; + bVar5 = buf->data[1]; + (rx->ctx).recv_ttl = bVar5 & 0x7f; + (rx->ctx).send_ttl = -((bVar5 & 0x7f) != 0); + *(byte *)&rx->field_0x20 = *(byte *)&rx->field_0x20 & 0xf7 | (buf->data[1] >> 7) << 3; + puVar4 = buf->data; + rx->seq = (uint)puVar4[2] << 0x10 | (uint)puVar4[3] << 8 | (uint)puVar4[4]; + uVar1 = CONCAT11(buf->data[7],buf->data[8]); + (rx->ctx).recv_dst = uVar1; + if ((CONCAT31(in_register_0000202d,net_if) == 3) || (uVar1 != 0)) { + if (0xfb < (ushort)(uVar1 + 0x100)) { + if ((CONCAT31(in_register_0000202d,net_if) != 1) && + (pbVar3 = bt_mesh_elem_find((rx->ctx).addr), pbVar3 != (bt_mesh_elem *)0x0)) { + return -0x4d; + } + return 0; + } + fmt = "Destination address is RFU; dropping packet\r\n"; + } + else { + fmt = "Destination address is unassigned; dropping packet\r\n"; + } + printf(fmt); + return -0x4d; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void bt_mesh_net_recv(net_buf_simple *data,s8_t rssi,bt_mesh_net_if net_if) + +{ + byte bVar1; + ushort uVar2; + u8_t *puVar3; + _Bool _Var4; + u8_t xmit; + undefined3 extraout_var; + int iVar5; + size_t sVar6; + undefined3 extraout_var_00; + bt_mesh_elem *pbVar7; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + net_buf *buf_00; + int iVar8; + char *fmt; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + undefined3 extraout_var_05; + undefined3 extraout_var_06; + undefined3 in_register_00002031; + uint uVar9; + net_buf_simple *buf_01; + u8_t **local_70; + net_buf_simple buf; + u8_t net_buf_data_buf [29]; + bt_mesh_net_rx_conflict4 rx; + + local_70 = &buf.__buf; + buf.data = (u8_t *)0x1d0000; + buf._4_4_ = &buf.__buf; + memset(net_buf_data_buf + 0x1c,0,0x24); + _Var4 = bt_mesh_is_provisioned(); + if (CONCAT31(extraout_var,_Var4) == 0) { + return; + } + iVar5 = bt_mesh_net_decode(data,net_if,(bt_mesh_net_rx_conflict4 *)(net_buf_data_buf + 0x1c), + (net_buf_simple *)&local_70); + if (iVar5 != 0) { + return; + } + sVar6 = net_buf_simple_headroom((net_buf_simple *)&local_70); + puVar3 = buf.data; + if (CONCAT31(in_register_00002031,net_if) == 2) { + bt_mesh_proxy_addr_add(data,rx.ctx.net_idx); + } + _Var4 = bt_mesh_fixed_group_match(rx.ctx.app_idx); + uVar9 = 1; + if (CONCAT31(extraout_var_00,_Var4) == 0) { + pbVar7 = bt_mesh_elem_find(rx.ctx.app_idx); + uVar9 = (uint)(pbVar7 != (bt_mesh_elem *)0x0); + } + uVar2 = (ushort)(rx.seq >> 0x10); + iVar5 = bt_mesh_trans_recv(&local_70,net_buf_data_buf + 0x1c); + if (iVar5 == -0xb) { + printf("Removing rejected message from Network Message Cache\r\n"); + *(undefined4 *)(msg_cache + (uint)uVar2) = 0; + *(undefined4 *)((int)msg_cache + (uint)uVar2 * 8 + 4) = 0; + msg_cache_next = uVar2; + } + if ((0 < (short)rx.ctx.app_idx) && ((rx.seq & 0x80 | uVar9 << 6) != 0)) { + return; + } + local_70 = (u8_t **)((int)buf._4_4_ + (sVar6 & 0xffff)); + buf.data = (u8_t *)((uint)puVar3 & 0xffff | (uint)buf.data._2_2_ << 0x10); + if ((rx.seq & 0x30) == 0x10) { + if (rx.ctx.addr._1_1_ == 1) { + return; + } +LAB_230431ba: + xmit = bt_mesh_net_transmit_get(); + } + else { + if (rx.ctx.addr._1_1_ < 2) { + return; + } + if ((rx.seq & 0x30) != 0) goto LAB_230431ba; + xmit = bt_mesh_relay_get(); + if ((CONCAT31(extraout_var_01,xmit) != 1) && + (xmit = bt_mesh_gatt_proxy_get(), CONCAT31(extraout_var_02,xmit) != 1)) { + return; + } + if ((rx.seq & 0x30) != 0) goto LAB_230431ba; + xmit = bt_mesh_relay_retransmit_get(); + } + buf_00 = bt_mesh_adv_create(BT_MESH_ADV_DATA,xmit,0); + if (buf_00 == (net_buf *)0x0) { + printf("Out of relay buffers\r\n"); + return; + } + if ((rx.seq & 0x30) != 0x10) { + ((u8_t *)local_70)[1] = ((u8_t *)local_70)[1] & 0x80; + ((u8_t *)local_70)[1] = rx.ctx.addr._1_1_ - 1 | ((u8_t *)local_70)[1]; + } + buf_01 = (net_buf_simple *)&buf_00->field_4; + net_buf_simple_add_mem(buf_01,local_70,(uint)buf.data & 0xffff); + iVar5 = (uint)*(byte *)(stack0xffffffbc + 0x1e) * 0x59; + if ((rx.seq & 4) != 0) { + bVar1 = *(byte *)(stack0xffffffbc + iVar5 + 0x40); + **(byte **)&buf_00->field_4 = **(byte **)&buf_00->field_4 & 0x80; + **(byte **)&buf_00->field_4 = bVar1 | **(byte **)&buf_00->field_4; + } + iVar8 = bt_mesh_net_encrypt((u8_t *)(stack0xffffffbc + iVar5 + 0x41),buf_01, + bt_mesh.iv_index - (rx.seq & 1),false); + if (iVar8 == 0) { + iVar5 = bt_mesh_net_obfuscate + (*(u8_t **)&buf_00->field_4,bt_mesh.iv_index - (rx.seq & 1), + (u8_t *)(stack0xffffffbc + iVar5 + 0x69)); + if (iVar5 == 0) { + xmit = bt_mesh_gatt_proxy_get(); + if ((((CONCAT31(extraout_var_03,xmit) != 1) && ((rx.seq & 0x30) != 0x10)) || + (_Var4 = bt_mesh_proxy_relay(buf_01,rx.ctx.app_idx), CONCAT31(extraout_var_05,_Var4) == 0) + ) || ((short)rx.ctx.app_idx < 1)) { + uVar9 = (rx.seq & 0x30) >> 4; + if (uVar9 != 1) { + if (uVar9 == 0) { + xmit = bt_mesh_relay_get(); + iVar5 = CONCAT31(extraout_var_06,xmit); + } + else { + if (uVar9 != 2) goto done; + xmit = bt_mesh_gatt_proxy_get(); + iVar5 = CONCAT31(extraout_var_04,xmit); + } + if (iVar5 != 1) goto done; + } + bt_mesh_adv_send(buf_00,(bt_mesh_send_cb *)0x0,(void *)0x0); + } + goto done; + } + fmt = "Re-obfuscating failed\r\n"; + } + else { + fmt = "Re-encrypting failed\r\n"; + } + printf(fmt); +done: + net_buf_unref(buf_00); + return; +} + + + +void bt_mesh_net_local(k_work *work) + +{ + net_buf *buf; + + while (buf = net_buf_slist_get(&bt_mesh.local_queue), buf != (net_buf *)0x0) { + bt_mesh_net_recv((net_buf_simple *)&buf->field_4,'\0',BT_MESH_NET_IF_LOCAL); + net_buf_unref(buf); + } + return; +} + + + +void bt_mesh_net_start(void) + +{ + u16_t net_idx; + u8_t uVar1; + u16_t addr; + undefined3 extraout_var; + undefined3 extraout_var_00; + + uVar1 = bt_mesh_beacon_get(); + if (CONCAT31(extraout_var,uVar1) == 1) { + bt_mesh_beacon_enable(); + } + else { + bt_mesh_beacon_disable(); + } + uVar1 = bt_mesh_gatt_proxy_get(); + if (CONCAT31(extraout_var_00,uVar1) != 2) { + bt_mesh_proxy_gatt_enable(); + bt_mesh_adv_update(); + } + bt_mesh_lpn_init(); + bt_mesh_friend_init(); + net_idx = bt_mesh.sub[0].net_idx; + addr = bt_mesh_primary_addr(); + bt_mesh_prov_complete(net_idx,addr); + return; +} + + + +void bt_mesh_net_init(void) + +{ + k_delayed_work_init(&bt_mesh.ivu_timer,ivu_refresh); + k_work_init(&bt_mesh.local_work,bt_mesh_net_local); + return; +} + + + +void ack_complete(u16_t duration,int err,void *user_data) + +{ + pending_ack = -1; + return; +} + + + +void prov_capabilities(u8_t *data) + +{ + return; +} + + + +void prov_failed(u8_t *data) + +{ + printf("Error: 0x%02x\r\n",(uint)*data); + return; +} + + + +void prov_buf_init(net_buf_simple *buf,u8_t type) + +{ + net_buf_simple_reserve(buf,5); + net_buf_simple_add_u8(buf,type); + return; +} + + + +net_buf * adv_buf_create(void) + +{ + net_buf *pnVar1; + + pnVar1 = bt_mesh_adv_create(BT_MESH_ADV_PROV,'\n',400); + if (pnVar1 == (net_buf *)0x0) { + printf("Out of provisioning buffers\r\n"); + } + return pnVar1; +} + + + +void free_segments(void) + +{ + prov_link *ppVar1; + net_buf *buf; + + ppVar1 = &link; + do { + buf = (ppVar1->tx).buf[0]; + if (buf == (net_buf *)0x0) { + return; + } + (ppVar1->tx).buf[0] = (net_buf *)0x0; + ppVar1 = (prov_link *)&ppVar1->conn; + *(byte *)(*(int *)buf->user_data + 8) = *(byte *)(*(int *)buf->user_data + 8) & 0xfb; + net_buf_unref(buf); + } while (ppVar1 != (prov_link *)0x4201446c); + return; +} + + + +void prov_clear_tx(void) + +{ + k_delayed_work_cancel(&link.tx.retransmit); + free_segments(); + return; +} + + + +void gen_prov_ack(prov_rx *rx,net_buf_simple *buf) + +{ + if (link.tx.buf[0] != (net_buf *)0x0) { + if (rx->xact_id == link.tx.id) { + prov_clear_tx(); + return; + } + } + return; +} + + + +void send_reliable(undefined4 param_1,undefined4 param_2) + +{ + prov_link *ppVar1; + int iVar2; + net_buf *buf; + bt_mesh_send_cb *cb; + + k_uptime_get(); + ppVar1 = &link; + iVar2 = 0; + link.tx.start._0_4_ = param_1; + link.tx.start._4_4_ = param_2; + do { + buf = (ppVar1->tx).buf[0]; + if (buf == (net_buf *)0x0) { + return; + } + iVar2 = iVar2 + 1; + if ((iVar2 == 3) || (cb = (bt_mesh_send_cb *)0x0, (ppVar1->tx).buf[1] == (net_buf *)0x0)) { + cb = &buf_sent_cb; + } + bt_mesh_adv_send(buf,cb,(void *)0x0); + ppVar1 = (prov_link *)&ppVar1->conn; + } while (iVar2 != 3); + return; +} + + + +int prov_send(net_buf_simple *buf) + +{ + u8_t val; + int iVar1; + net_buf *pnVar2; + size_t len; + net_buf_simple *buf_00; + u8_t val_00; + prov_link *ppVar3; + + k_delayed_work_submit(&link.prot_timer,60000); + if (link.conn != (bt_conn *)0x0) { + iVar1 = bt_mesh_proxy_send(link.conn,'\x03',buf); + return iVar1; + } + prov_clear_tx(); + pnVar2 = adv_buf_create(); + iVar1 = -0x37; + if (pnVar2 != (net_buf *)0x0) { + val_00 = -0x80; + if ((byte)(link.tx.id - 1) < 0xfe) { + val_00 = link.tx.id + '\x01'; + } + buf_00 = (net_buf_simple *)&pnVar2->field_4; + link.tx.id = val_00; + net_buf_simple_add_be32(buf_00,link.id); + net_buf_simple_add_u8(buf_00,val_00); + iVar1 = 0; + if (0x14 < *(byte *)&buf->len) { + iVar1 = ((uint)*(byte *)&buf->len - 0x14 & 0xff) / 0x17 + 1; + } + net_buf_simple_add_u8(buf_00,(u8_t)(iVar1 << 2)); + net_buf_simple_add_be16(buf_00,buf->len); + val = bt_mesh_fcs_calc(buf->data,*(u8_t *)&buf->len); + net_buf_simple_add_u8(buf_00,val); + len = (size_t)buf->len; + if (0x14 < buf->len) { + len = 0x14; + } + link.tx.buf[0] = pnVar2; + net_buf_simple_add_mem(buf_00,buf->data,len); + net_buf_simple_pull(buf,len); + iVar1 = 0; + ppVar3 = &link; + while (buf->len != 0) { + if (iVar1 == 8) { + printf("Too big message\r\n"); + free_segments(); + return -7; + } + pnVar2 = adv_buf_create(); + iVar1 = iVar1 + 4; + if (pnVar2 == (net_buf *)0x0) { + free_segments(); + return -0x37; + } + (ppVar3->tx).buf[1] = pnVar2; + len = (size_t)buf->len; + if (0x17 < buf->len) { + len = 0x17; + } + buf_00 = (net_buf_simple *)&pnVar2->field_4; + net_buf_simple_add_be32(buf_00,link.id); + net_buf_simple_add_u8(buf_00,val_00); + net_buf_simple_add_u8(buf_00,(byte)iVar1 | 2); + net_buf_simple_add_mem(buf_00,buf->data,len); + net_buf_simple_pull(buf,len); + ppVar3 = (prov_link *)&ppVar3->conn; + } + send_reliable(); + iVar1 = 0; + } + return iVar1; +} + + + +void send_input_complete(void) + +{ + int iVar1; + u8_t auStack36 [4]; + u8_t net_buf_data_buf [6]; + net_buf_simple buf; + + register0x0000203c = auStack36; + prov_buf_init((net_buf_simple *)(net_buf_data_buf + 4),'\x04'); + iVar1 = prov_send((net_buf_simple *)(net_buf_data_buf + 4)); + if (iVar1 != 0) { + printf("Failed to send Provisioning Input Complete\r\n"); + } + link.expect = '\x05'; + return; +} + + + +int bearer_ctl_send(u8_t op,void *data,u8_t data_len) + +{ + net_buf *pnVar1; + int iVar2; + undefined3 in_register_00002031; + net_buf_simple *buf; + + prov_clear_tx(); + pnVar1 = adv_buf_create(); + if (pnVar1 == (net_buf *)0x0) { + iVar2 = -0x37; + } + else { + buf = (net_buf_simple *)&pnVar1->field_4; + net_buf_simple_add_be32(buf,link.id); + net_buf_simple_add_u8(buf,'\0'); + net_buf_simple_add_u8(buf,op << 2 | 3); + net_buf_simple_add_mem(buf,data,CONCAT31(in_register_00002031,data_len)); + link.tx.buf[0] = pnVar1; + send_reliable(); + iVar2 = 0; + } + return iVar2; +} + + + +void prov_send_fail_msg(u8_t err) + +{ + int iVar1; + u8_t auStack36 [4]; + u8_t net_buf_data_buf [7]; + net_buf_simple buf; + + register0x0000203c = auStack36; + prov_buf_init((net_buf_simple *)(net_buf_data_buf + 4),'\t'); + net_buf_simple_add_u8((net_buf_simple *)(net_buf_data_buf + 4),err); + iVar1 = prov_send((net_buf_simple *)(net_buf_data_buf + 4)); + if (iVar1 != 0) { + printf("Failed to send Provisioning Failed message\r\n"); + } + atomic_or((atomic_t *)&link,0x20); + return; +} + + + +int reset_state(void) + +{ + bt_pub_key_cb pub_key_cb; + int iVar1; + + k_delayed_work_cancel(&link.prot_timer); + if (link.conf_inputs[0] != '\0') { + bt_mesh_attention((bt_mesh_model *)0x0,'\0'); + } + if (link.conn != (bt_conn *)0x0) { + bt_conn_unref(link.conn); + } + memset(&link,0,0x148); + link.rx.prev_id = -1; + link.rx.buf = bt_mesh_proxy_get_buf(); + iVar1 = bt_pub_key_gen((bt_pub_key_cb *)&ram0x4200eb50); + if (iVar1 != 0) { + printf("Failed to generate public key (%d)\r\n",iVar1); + } + return iVar1; +} + + + +void reset_adv_link(void) + +{ + prov_clear_tx(); + if (prov->link_close != (anon_subr_void_bt_mesh_prov_bearer_t_for_link_close *)0x0) { + (*prov->link_close)(BT_MESH_PROV_ADV); + } + reset_state(); + return; +} + + + +// WARNING: Variable defined which should be unmapped: net_buf_data_cfm +// WARNING: Could not reconcile some variable overlaps + +void prov_confirm(u8_t *data) + +{ + int iVar1; + char *fmt; + u8_t *conf; + u8_t **ppuStack52; + net_buf_simple cfm; + u8_t net_buf_data_cfm [22]; + + memcpy(link.conf,data,0x10); + ppuStack52 = &cfm.__buf; + cfm.data = (u8_t *)0x160000; + cfm._4_4_ = &cfm.__buf; + iVar1 = bt_mesh_prov_conf_salt(link.conf_inputs,link.conf_salt); + if (iVar1 == 0) { + iVar1 = bt_mesh_prov_conf_key(link.dhkey,link.conf_salt,link.conf_key); + if (iVar1 == 0) { + iVar1 = bt_rand(link.rand,0x10); + if (iVar1 == 0) { + prov_buf_init((net_buf_simple *)&ppuStack52,'\x05'); + conf = (u8_t *)net_buf_simple_add((net_buf_simple *)&ppuStack52,0x10); + iVar1 = bt_mesh_prov_conf(link.conf_key,link.rand,link.auth,conf); + if (iVar1 == 0) { + iVar1 = prov_send((net_buf_simple *)&ppuStack52); + if (iVar1 != 0) { + printf("Failed to send Provisioning Confirm\r\n"); + return; + } + link.expect = '\x06'; + return; + } + fmt = "Unable to generate confirmation value\r\n"; + } + else { + fmt = "Unable to generate random number\r\n"; + } + } + else { + fmt = "Unable to generate confirmation key\r\n"; + } + } + else { + fmt = "Unable to generate confirmation salt\r\n"; + } + printf(fmt); + prov_send_fail_msg('\a'); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void prov_invite(u8_t *data) + +{ + u8_t val; + int iVar1; + u8_t **local_30; + net_buf_simple buf; + u8_t net_buf_data_buf [17]; + + local_30 = &buf.__buf; + buf.data = (u8_t *)0x110000; + buf._4_4_ = &buf.__buf; + if (*data != '\0') { + bt_mesh_attention((bt_mesh_model *)0x0,*data); + } + link.conf_inputs[0] = *data; + prov_buf_init((net_buf_simple *)&local_30,'\x01'); + val = bt_mesh_elem_count(); + net_buf_simple_add_u8((net_buf_simple *)&local_30,val); + net_buf_simple_add_be16((net_buf_simple *)&local_30,1); + net_buf_simple_add_u8((net_buf_simple *)&local_30,'\0'); + net_buf_simple_add_u8((net_buf_simple *)&local_30,prov->static_val != (u8_t *)0x0); + net_buf_simple_add_u8((net_buf_simple *)&local_30,prov->output_size); + net_buf_simple_add_be16((net_buf_simple *)&local_30,prov->output_actions); + net_buf_simple_add_u8((net_buf_simple *)&local_30,prov->input_size); + net_buf_simple_add_be16((net_buf_simple *)&local_30,prov->input_actions); + memcpy(link.conf_inputs + 1,(void *)((int)local_30 + 1),0xb); + iVar1 = prov_send((net_buf_simple *)&local_30); + if (iVar1 == 0) { + link.expect = '\x02'; + } + else { + printf("Failed to send capabilities\r\n"); + } + return; +} + + + +void buf_sent(int err,void *user_data) + +{ + if (link.tx.buf[0] != (net_buf *)0x0) { + k_delayed_work_submit(&link.tx.retransmit,500); + return; + } + return; +} + + + +void gen_prov_ack_send(u8_t xact_id) + +{ + net_buf_simple *buf; + undefined3 in_register_00002029; + net_buf *buf_00; + undefined **cb; + + if (((uint)pending_ack != CONCAT31(in_register_00002029,xact_id)) && + (buf_00 = adv_buf_create(), buf_00 != (net_buf *)0x0)) { + cb = (undefined **)0x0; + if (pending_ack == -1) { + cb = &cb_5925; + pending_ack = xact_id; + } + buf = (net_buf_simple *)&buf_00->field_4; + net_buf_simple_add_be32(buf,link.id); + net_buf_simple_add_u8(buf,xact_id); + net_buf_simple_add_u8(buf,'\x01'); + bt_mesh_adv_send(buf_00,(bt_mesh_send_cb *)cb,(void *)0x0); + net_buf_unref(buf_00); + return; + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: sg +// WARNING: Could not reconcile some variable overlaps + +void prov_random(u8_t *data) + +{ + u8_t err; + int iVar1; + char *fmt; + u8_t *puStack108; + net_buf_simple rnd; + u8_t conf_verify [16]; + u8_t prov_salt_key [16]; + u8_t net_buf_data_rnd [21]; + bt_mesh_sg sg [3]; + + puStack108 = prov_salt_key + 0xc; + rnd.data = (u8_t *)0x150000; + rnd._4_4_ = prov_salt_key + 0xc; + iVar1 = bt_mesh_prov_conf(link.conf_key,data,link.auth,(u8_t *)&rnd.__buf); + if (iVar1 == 0) { + iVar1 = memcmp(&rnd.__buf,link.conf,0x10); + if (iVar1 != 0) { + printf("Invalid confirmation value\r\n"); + err = '\x04'; + goto LAB_23043b1a; + } + prov_buf_init((net_buf_simple *)&puStack108,'\x06'); + net_buf_simple_add_mem((net_buf_simple *)&puStack108,link.rand,0x10); + iVar1 = prov_send((net_buf_simple *)&puStack108); + if (iVar1 != 0) { + printf("Failed to send Provisioning Random\r\n"); + return; + } + stack0xffffffd8 = link.conf_salt; + conf_verify._12_4_ = 0; + prov_salt_key._0_4_ = 0; + prov_salt_key._4_4_ = 0; + prov_salt_key._8_4_ = 0; + iVar1 = bt_mesh_aes_cmac(conf_verify + 0xc,(bt_mesh_sg *)(net_buf_data_rnd + 0x14),3, + link.prov_salt); + if (iVar1 == 0) { + link.expect = '\a'; + return; + } + fmt = "Failed to generate provisioning salt\r\n"; + } + else { + fmt = "Unable to calculate confirmation verification\r\n"; + } + printf(fmt); + err = '\a'; +LAB_23043b1a: + prov_send_fail_msg(err); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void prov_data(u8_t *data) + +{ + bt_conn *pbVar1; + u8_t err; + int iVar2; + char *fmt; + u8_t auStack144 [4]; + u8_t net_buf_data_msg [6]; + net_buf_simple msg; + u8_t nonce [13]; + u8_t session_key [16]; + u8_t dev_key [16]; + u8_t pdu [25]; + + register0x0000203c = auStack144; + msg.data = (u8_t *)0x60000; + msg._4_4_ = auStack144; + iVar2 = bt_mesh_k1(link.dhkey,0x20,link.prov_salt,"prsk",nonce + 0xc); + if (iVar2 == 0) { + iVar2 = bt_mesh_k1(link.dhkey,0x20,link.prov_salt,"prsn",dev_key + 0xc); + if (iVar2 == 0) { + memcpy(&msg.__buf,dev_key + 0xf,0xd); + iVar2 = bt_mesh_prov_decrypt(nonce + 0xc,(u8_t *)&msg.__buf,data,dev_key + 0xc); + if (iVar2 != 0) { + printf("Unable to decrypt provisioning data\r\n"); + err = '\x06'; + goto LAB_23043c32; + } + iVar2 = bt_mesh_k1(link.dhkey,0x20,link.prov_salt,"prdk",session_key + 0xc); + if (iVar2 == 0) { + prov_buf_init((net_buf_simple *)(net_buf_data_msg + 4),'\b'); + iVar2 = prov_send((net_buf_simple *)(net_buf_data_msg + 4)); + pbVar1 = link.conn; + if (iVar2 != 0) { + printf("Failed to send Provisioning Complete\r\n"); + return; + } + link.expect = -1; + iVar2 = bt_mesh_provision(dev_key + 0xc,CONCAT11(pdu[12],pdu[13]),pdu[14], + CONCAT22(CONCAT11(pdu[15],pdu[16]),CONCAT11(pdu[17],pdu[18])), + CONCAT11(pdu[19],pdu[20]),session_key + 0xc); + if (iVar2 != 0) { + printf("Failed to provision (err %d)\r\n",iVar2); + return; + } + if (pbVar1 == (bt_conn *)0x0) { + return; + } + bt_mesh_proxy_identity_enable(); + return; + } + fmt = "Unable to generate device key\r\n"; + } + else { + fmt = "Unable to generate session nonce\r\n"; + } + } + else { + fmt = "Unable to generate session key\r\n"; + } + printf(fmt); + err = '\a'; +LAB_23043c32: + prov_send_fail_msg(err); + return; +} + + + +void sys_memcpy_swap(void *dst,void *src) + +{ + undefined *puVar1; + + puVar1 = (undefined *)((int)src + 0x1f); + do { + puVar1 = puVar1 + -1; + *(undefined *)dst = *puVar1; + dst = (undefined *)dst + 1; + puVar1 = puVar1; + } while (puVar1 != (undefined *)((int)src + -1)); + return; +} + + + +void prov_dh_key_gen(void) + +{ + int iVar1; + u8_t auStack80 [4]; + u8_t remote_pk [64]; + + sys_memcpy_swap(auStack80,link.conf_inputs + 0x11); + sys_memcpy_swap(remote_pk + 0x1c,link.conf_inputs + 0x31); + iVar1 = bt_dh_key_gen(auStack80,send_pub_key); + if (iVar1 != 0) { + printf("Failed to generate DHKey\r\n"); + prov_send_fail_msg('\a'); + } + return; +} + + + +void prov_pub_key(u8_t *data) + +{ + u8_t *puVar1; + + memcpy(link.conf_inputs + 0x11,data,0x40); + puVar1 = bt_pub_key_get(); + if (puVar1 == (u8_t *)0x0) { + prov_clear_tx(); + atomic_or((atomic_t *)&link,1); + printf("Waiting for local public key\r\n"); + return; + } + prov_dh_key_gen(); + return; +} + + + +void prov_start(u8_t *data) + +{ + byte bVar1; + byte bVar2; + bt_mesh_output_action_t bVar3; + bt_mesh_input_action_t bVar4; + char cVar5; + uint len; + char *fmt; + int iVar6; + uint uVar7; + atomic_val_t value; + size_t __n; + byte bVar8; + u32_t_conflict *puVar9; + uint uVar10; + uint uStack68; + u32_t_conflict num; + uchar str [9]; + + uVar7 = (uint)*data; + if (*data == 0) { + uVar7 = (uint)data[1]; + if (data[1] == 0) { + memcpy(link.conf_inputs + 0xc,data,5); + link.expect = '\x03'; + bVar8 = data[2]; + bVar1 = data[3]; + uVar10 = (uint)bVar1; + bVar2 = data[4]; + len = (uint)bVar2; + if (bVar8 == 1) { + if ((bVar2 | bVar1) == 0) { + memcpy((void *)((int)&link + (0x5c - (uint)prov->static_val_len)),prov->static_val, + (uint)prov->static_val_len); + __n = 0x10 - (uint)prov->static_val_len; +LAB_23043e5c: + memset(link.auth,0,__n); + return; + } + } + else { + if (bVar8 == 0) { + if ((bVar2 | bVar1) == 0) { + __n = 0x10; + goto LAB_23043e5c; + } + } + else { + if (bVar8 == 2) { + if (bVar1 < 5) { + bVar3 = *(bt_mesh_output_action_t *)((int)&CSWTCH_53 + uVar10); + if (((bVar3 != BT_MESH_NO_OUTPUT) && (((uint)prov->output_actions & (uint)bVar3) != 0) + ) && (len <= prov->output_size)) { + if (bVar3 == BT_MESH_DISPLAY_STRING) { + bt_rand(&num,len); + puVar9 = # + while (len != uVar7) { + cVar5 = (char)((uint)*(byte *)puVar9 % 0x24); + bVar8 = cVar5 + 0x37; + if ((uint)*(byte *)puVar9 % 0x24 < 10) { + bVar8 = cVar5 + 0x30; + } + *(byte *)puVar9 = bVar8; + uVar7 = uVar7 + 1 & 0xff; + puVar9 = (u32_t_conflict *)((int)puVar9 + 1); + } + *(undefined *)((int)&num + len) = 0; + memcpy(link.auth,&num,len); + memset(link.auth + len,0,0x10 - len); + iVar6 = (*prov->output_string)((char *)&num); + } + else { + memcpy(&num,&DAT_230b91c8,0x20); + bt_rand(&uStack68,4); + uStack68 = uStack68 % (&num)[len - 1]; + link.auth[13] = (u8_t)(uStack68 >> 0x10); + link.auth._14_2_ = (ushort)(uStack68 >> 8) & 0xff | (ushort)(uStack68 << 8); + link.auth[12] = (u8_t)(uStack68 >> 0x18); + memset(link.auth,0,0xc); + iVar6 = (*prov->output_number)(bVar3,uStack68); + } + goto LAB_23043f24; + } + } + } + else { + if ((bVar8 == 3) && (uVar10 <= bVar8)) { + bVar4 = *(bt_mesh_input_action_t *)((int)&CSWTCH_54 + uVar10); + if ((bVar4 != BT_MESH_NO_INPUT) && + ((((uint)prov->input_actions & (uint)bVar4) != 0 && (len <= prov->input_size)))) { + value = 8; + if (bVar4 != BT_MESH_ENTER_STRING) { + value = 4; + } + atomic_or((atomic_t *)&link,value); + iVar6 = (*prov->input)(bVar4,bVar2); +LAB_23043f24: + if (-1 < iVar6) { + return; + } + } + } + } + } + } + printf("Invalid authentication method: 0x%02x; action: 0x%02x; size: 0x%02x\r\n",(uint)data[2] + ,(uint)data[3],(uint)data[4]); + goto LAB_23043dda; + } + fmt = "Invalid public key type: 0x%02x\r\n"; + } + else { + fmt = "Unknown algorithm 0x%02x\r\n"; + } + printf(fmt,uVar7); +LAB_23043dda: + prov_send_fail_msg('\x02'); + return; +} + + + +void pub_key_ready(u8_t *pkey) + +{ + uint uVar1; + + if (pkey == (u8_t *)0x0) { + printf("Public key not available\r\n"); + return; + } + uVar1 = atomic_and((atomic_t *)&link,-2); + if ((uVar1 & 1) != 0) { + prov_dh_key_gen(); + return; + } + return; +} + + + +void prov_complete(void) + +{ + return; +} + + + +void prov_retransmit(k_work *work) + +{ + prov_link *ppVar1; + int iVar2; + atomic_val_t aVar3; + uint uVar4; + uint uVar5; + net_buf *buf; + int in_a1; + bt_mesh_send_cb *cb; + longlong lVar6; + + aVar3 = atomic_get((atomic_t *)&link); + uVar4 = aVar3 >> 1 & 1; + if (uVar4 == 0) { + printf("Link not active\r\n"); + return; + } + lVar6 = k_uptime_get(); + ppVar1 = &link; + uVar5 = (uint)(uVar4 < uVar4 - (int)link.tx.start); + if (((int)((in_a1 - link.tx.start._4_4_) - uVar5) < 1) && + ((in_a1 - link.tx.start._4_4_ != uVar5 || (uVar4 - (int)link.tx.start < 0x7531)))) { + iVar2 = 0; + do { + buf = (ppVar1->tx).buf[0]; + if (buf == (net_buf *)0x0) { + return; + } + iVar2 = iVar2 + 1; + if ((*(byte *)(*(int *)buf->user_data + 8) & 4) == 0) { + if ((iVar2 == 3) || (cb = (bt_mesh_send_cb *)0x0, (ppVar1->tx).buf[1] == (net_buf *)0x0)) { + cb = &buf_sent_cb; + } + bt_mesh_adv_send(buf,cb,(void *)0x0); + } + ppVar1 = (prov_link *)&ppVar1->conn; + } while (iVar2 != 3); + return; + } + printf("Giving up transaction\r\n",(int)lVar6); + reset_adv_link(); + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void prov_input_complete(u8_t *data) + +{ + uint uVar1; + + uVar1 = atomic_and((atomic_t *)&link,-0x11); + if ((uVar1 & 0x10) != 0) { + if (prov->input_complete != (anon_subr_void_for_input_complete *)0x0) { + // WARNING: Could not recover jumptable at 0x2304412a. Too many branches + // WARNING: Treating indirect jump as call + (*prov->input_complete)(); + return; + } + } + return; +} + + + +void prov_msg_recv(void) + +{ + byte bVar1; + uint uVar2; + _Bool _Var3; + u8_t err; + undefined3 extraout_var; + atomic_val_t aVar4; + + bVar1 = *(link.rx.buf)->data; + uVar2 = (uint)bVar1; + k_delayed_work_submit(&link.prot_timer,60000); + _Var3 = bt_mesh_fcs_check(link.rx.buf,link.rx.fcs); + if (CONCAT31(extraout_var,_Var3) == 0) { + printf("Incorrect FCS\r\n"); + return; + } + gen_prov_ack_send(link.rx.id); + link.rx.prev_id = link.rx.id; + link.rx.id = '\0'; + aVar4 = atomic_get((atomic_t *)&link); + if ((aVar4 >> 5 & 1U) == 0) { + if (bVar1 != 9) { + if ((uint)link.expect != uVar2) { + printf("Unexpected msg 0x%02x != 0x%02x\r\n"); + goto LAB_230441b4; + } + if (9 < link.expect) { + printf("Unknown provisioning PDU type 0x%02x\r\n"); + err = '\x01'; + goto LAB_230441b6; + } + } + if ((uint)prov_handlers[uVar2].len + 1 == (uint)(link.rx.buf)->len) { + // WARNING: Could not recover jumptable at 0x23044244. Too many branches + // WARNING: Treating indirect jump as call + (*prov_handlers[uVar2].func)((link.rx.buf)->data + 1); + return; + } + printf("Invalid length %u for type 0x%02x\r\n",uVar2); + err = '\x02'; + } + else { + printf("Unexpected msg 0x%02x on invalidated link\r\n"); +LAB_230441b4: + err = '\x03'; + } +LAB_230441b6: + prov_send_fail_msg(err); + return; +} + + + +void gen_prov_cont(prov_rx *rx,net_buf_simple *buf) + +{ + uint uVar1; + uint uVar2; + + if ((link.rx.seg == '\0') && (link.rx.prev_id == rx->xact_id)) { + printf("Resending ack\r\n"); + gen_prov_ack_send(rx->xact_id); + return; + } + if (link.rx.id != rx->xact_id) { + printf("Data for unknown transaction (%u != %u)\r\n"); + return; + } + uVar2 = (uint)link.rx.last_seg; + uVar1 = (uint)(rx->gpc >> 2); + if (uVar2 < uVar1) { + printf("Invalid segment index %u\r\n",uVar1); +LAB_230442c4: + prov_send_fail_msg('\x02'); + return; + } + if (uVar2 == uVar1) { + if ((uVar2 * -0x17 + 3 + (uint)*(byte *)&(link.rx.buf)->len & 0xff) != (uint)buf->len) { + printf("Incorrect last seg len: %u != %u\r\n"); + goto LAB_230442c4; + } + } + if ((link.rx.seg >> (uVar1 & 0x1f) & 1) == 0) { + printf("Ignoring already received segment\r\n"); + return; + } + memcpy((link.rx.buf)->data + (uVar1 - 1) * 0x17 + 0x14,buf->data,(uint)buf->len); + uVar1 = ~(1 << (uVar1 & 0x1f)) & (uint)link.rx.seg; + link.rx.seg = (u8_t)uVar1; + if (uVar1 == 0) { + prov_msg_recv(); + return; + } + return; +} + + + +void gen_prov_start(prov_rx *rx,net_buf_simple *buf) + +{ + ushort uVar1; + byte bVar2; + net_buf_simple *pnVar3; + u16_t uVar4; + char *fmt; + + pnVar3 = link.rx.buf; + if (link.rx.seg != '\0') { + printf("Got Start while there are unreceived segments\r\n"); + return; + } + if (link.rx.prev_id == rx->xact_id) { + printf("Resending ack\r\n"); + gen_prov_ack_send(rx->xact_id); + return; + } + uVar4 = net_buf_simple_pull_be16(buf); + pnVar3->len = uVar4; + link.rx.id = rx->xact_id; + link.rx.fcs = net_buf_simple_pull_u8(buf); + uVar1 = (link.rx.buf)->len; + if (uVar1 == 0) { + fmt = "Ignoring zero-length provisioning PDU\r\n"; + } + else { + if ((link.rx.buf)->size < uVar1) { + printf("Too large provisioning PDU (%u bytes)\r\n"); + goto LAB_2304441c; + } + bVar2 = rx->gpc >> 2; + if ((bVar2 == 0) || (0x14 < uVar1)) { + link.rx.seg = (char)(1 << ((uint)bVar2 + 1 & 0x1f)) + -1; + link.rx.last_seg = rx->gpc >> 2; + memcpy((link.rx.buf)->data,buf->data,(uint)buf->len); + bVar2 = link.rx.seg & 0xfe; + link.rx.seg = link.rx.seg & 0xfe; + if (bVar2 == 0) { + prov_msg_recv(); + return; + } + return; + } + fmt = "Too small total length for multi-segment PDU\r\n"; + } + printf(fmt); +LAB_2304441c: + prov_send_fail_msg('\x02'); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void send_pub_key(u8_t *dhkey) + +{ + char *fmt; + u8_t *src; + void *dst; + int iVar1; + atomic_val_t aVar2; + u8_t **ppuStack116; + net_buf_simple buf; + u8_t net_buf_data_buf [70]; + + ppuStack116 = &buf.__buf; + buf.data = (u8_t *)0x460000; + buf._4_4_ = &buf.__buf; + if (dhkey == (u8_t *)0x0) { + fmt = "DHKey generation failed\r\n"; + } + else { + sys_memcpy_swap(link.dhkey,dhkey); + src = bt_pub_key_get(); + if (src != (u8_t *)0x0) { + prov_buf_init((net_buf_simple *)&ppuStack116,'\x03'); + dst = net_buf_simple_add((net_buf_simple *)&ppuStack116,0x20); + sys_memcpy_swap(dst,src); + dst = net_buf_simple_add((net_buf_simple *)&ppuStack116,0x20); + sys_memcpy_swap(dst,src + 0x20); + memcpy(link.conf_inputs + 0x51,(void *)((int)ppuStack116 + 1),0x40); + iVar1 = prov_send((net_buf_simple *)&ppuStack116); + if (iVar1 != 0) { + printf("Failed to send Public Key\r\n"); + return; + } + aVar2 = atomic_get((atomic_t *)&link); + if (((aVar2 >> 2 & 1U) == 0) && + (aVar2 = atomic_get((atomic_t *)&link), (aVar2 >> 3 & 1U) == 0)) { + link.expect = '\x05'; + return; + } + link.expect = -1; + return; + } + fmt = "No public key available\r\n"; + } + printf(fmt); + prov_send_fail_msg('\a'); + return; +} + + + +void gen_prov_ctl(prov_rx *rx,net_buf_simple *buf) + +{ + u8_t **ppuVar1; + byte bVar2; + net_buf_simple *pnVar3; + int iVar4; + atomic_val_t aVar5; + uint uVar6; + + bVar2 = rx->gpc >> 2; + uVar6 = (uint)bVar2; + if (bVar2 == 1) { + atomic_get((atomic_t *)&link); + return; + } + if (bVar2 == 0) { + uVar6 = (uint)buf->len; + if (0xf < buf->len) { + aVar5 = atomic_get((atomic_t *)&link); + if ((aVar5 >> 1 & 1U) == 0) { + iVar4 = memcmp(buf->data,prov->uuid,0x10); + if (iVar4 != 0) { + return; + } + if (prov->link_open != (anon_subr_void_bt_mesh_prov_bearer_t_for_link_open *)0x0) { + (*prov->link_open)(BT_MESH_PROV_ADV); + } + link.id = rx->link_id; + atomic_or((atomic_t *)&link,2); + pnVar3 = link.rx.buf; + ppuVar1 = &(link.rx.buf)->__buf; + (link.rx.buf)->len = 0; + pnVar3->data = *ppuVar1; + bearer_ctl_send('\x01',(void *)0x0,'\0'); + link.expect = '\0'; + return; + } + if ((link.id == rx->link_id) && (link.expect == '\0')) { + bearer_ctl_send('\x01',(void *)0x0,'\0'); + return; + } + printf("Ignoring bearer open: link already active\r\n"); + return; + } + iVar4 = 0x36c; + } + else { + if (bVar2 == 2) { + aVar5 = atomic_get((atomic_t *)&link); + if ((aVar5 >> 1 & 1U) == 0) { + return; + } + reset_adv_link(); + return; + } + iVar4 = 0x3c4; + } + printf("Unable to generate Net ID\r\n" + iVar4 + 0x14,uVar6); + return; +} + + + +int bt_mesh_input_number(u32_t_conflict num) + +{ + uint uVar1; + int iVar2; + + uVar1 = atomic_and((atomic_t *)&link,-5); + if ((uVar1 & 4) == 0) { + iVar2 = -0x16; + } + else { + link.auth[13] = (u8_t)(num >> 0x10); + link.auth._14_2_ = (ushort)(num >> 8) & 0xff | (ushort)(num << 8); + link.auth[12] = (u8_t)(num >> 0x18); + send_input_complete(); + iVar2 = 0; + } + return iVar2; +} + + + +int bt_mesh_input_string(char *str) + +{ + uint uVar1; + int iVar2; + + uVar1 = atomic_and((atomic_t *)&link,-9); + if ((uVar1 & 8) == 0) { + iVar2 = -0x16; + } + else { + strncpy((char *)link.auth,str,(uint)prov->input_size); + send_input_complete(); + iVar2 = 0; + } + return iVar2; +} + + + +int bt_mesh_pb_gatt_recv(bt_conn *conn,net_buf_simple *buf) + +{ + u8_t uVar1; + char *fmt; + undefined3 extraout_var; + uint uVar2; + + if (link.conn != conn) { + printf("Data for unexpected connection\r\n"); + return -0x39; + } + if (buf->len == 0) { + uVar2 = 0; + fmt = "Too short provisioning packet (len %u)\r\n"; +LAB_230447a0: + printf(fmt,uVar2); + } + else { + uVar1 = net_buf_simple_pull_u8(buf); + _uVar1 = CONCAT31(extraout_var,uVar1); + if (_uVar1 != 9) { + uVar2 = (uint)link.expect; + if (uVar2 != _uVar1) { + printf("Unexpected msg 0x%02x != 0x%02x\r\n",_uVar1); + prov_send_fail_msg('\x03'); + return -0x16; + } + if (9 < link.expect) { + fmt = "Unknown provisioning PDU type 0x%02x\r\n"; + goto LAB_230447a0; + } + } + if (prov_handlers[_uVar1].len == buf->len) { + (*prov_handlers[_uVar1].func)(buf->data); + return 0; + } + printf("Invalid length %u for type 0x%02x\r\n",_uVar1); + } + return -0x16; +} + + + +int bt_mesh_pb_gatt_open(bt_conn *conn) + +{ + uint uVar1; + + uVar1 = atomic_or((atomic_t *)&link,2); + uVar1 = uVar1 & 2; + if (uVar1 == 0) { + link.conn = bt_conn_ref(conn); + link.expect = '\0'; + if (prov->link_open != (anon_subr_void_bt_mesh_prov_bearer_t_for_link_open *)0x0) { + (*prov->link_open)(BT_MESH_PROV_GATT); + } + } + else { + uVar1 = 0xfffffff0; + } + return uVar1; +} + + + +int bt_mesh_pb_gatt_close(bt_conn *conn) + +{ + int iVar1; + + if (link.conn == conn) { + if (prov->link_close != (anon_subr_void_bt_mesh_prov_bearer_t_for_link_close *)0x0) { + (*prov->link_close)(BT_MESH_PROV_GATT); + } + iVar1 = reset_state(); + return iVar1; + } + printf("Not connected\r\n"); + return -0x39; +} + + + +void protocol_timeout(k_work *work) + +{ + undefined auStack17 [4]; + u8_t reason; + + if (link.conn == (bt_conn *)0x0) { + auStack17[0] = 1; + link.rx.seg = '\0'; + bearer_ctl_send('\x02',auStack17,'\x01'); + reset_state(); + } + else { + bt_mesh_pb_gatt_close(link.conn); + } + return; +} + + + +bt_mesh_prov_conflict8 * bt_mesh_prov_get(void) + +{ + return prov; +} + + + +_Bool bt_prov_active(void) + +{ + atomic_val_t aVar1; + + aVar1 = atomic_get((atomic_t *)&link); + return (_Bool)((byte)(aVar1 >> 1) & 1); +} + + + +// WARNING: Variable defined which should be unmapped: rx +// WARNING: Could not reconcile some variable overlaps + +void bt_mesh_pb_adv_recv(net_buf_simple *buf) + +{ + _Bool _Var1; + undefined3 extraout_var; + char *fmt; + undefined3 extraout_var_00; + atomic_val_t aVar2; + u32_t_conflict uStack24; + prov_rx rx; + + _Var1 = bt_prov_active(); + if ((CONCAT31(extraout_var,_Var1) == 0) && + (_Var1 = bt_mesh_is_provisioned(), CONCAT31(extraout_var_00,_Var1) != 0)) { + return; + } + if (buf->len < 6) { + fmt = "Too short provisioning packet (len %u)\r\n"; + } + else { + uStack24 = net_buf_simple_pull_be32(buf); + rx.link_id._0_1_ = net_buf_simple_pull_u8(buf); + rx.link_id._1_1_ = net_buf_simple_pull_u8(buf); + aVar2 = atomic_get((atomic_t *)&link); + if (((aVar2 >> 1 & 1U) != 0) && (link.id != uStack24)) { + return; + } + if ((uint)gen_prov[(uint)rx.link_id._1_1_ & 3].min_len <= (uint)buf->len) { + aVar2 = atomic_get((atomic_t *)&link); + if (((aVar2 >> 1 & 1U) == 0) && (gen_prov[(uint)rx.link_id._1_1_ & 3].require_link != false)) + { + return; + } + (*gen_prov[(uint)rx.link_id._1_1_ & 3].func)((prov_rx *)&uStack24,buf); + return; + } + fmt = "Too short GPC message type %u\r\n"; + } + printf(fmt); + return; +} + + + +int bt_mesh_prov_init(bt_mesh_prov_conflict8 *prov_info) + +{ + int iVar1; + + if (prov_info != (bt_mesh_prov_conflict8 *)0x0) { + k_delayed_work_init(&link.prot_timer,protocol_timeout); + prov = prov_info; + k_delayed_work_init(&link.tx.retransmit,prov_retransmit); + iVar1 = reset_state(); + return iVar1; + } + printf("No provisioning context provided\r\n"); + return -0x16; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void bt_mesh_prov_complete(u16_t net_idx,u16_t addr) + +{ + if (prov->complete != (anon_subr_void_u16_t_u16_t_for_complete *)0x0) { + // WARNING: Could not recover jumptable at 0x23044a4a. Too many branches + // WARNING: Treating indirect jump as call + (*prov->complete)(); + return; + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void bt_mesh_prov_reset(void) + +{ + if (prov->reset != (anon_subr_void_for_reset *)0x0) { + // WARNING: Could not recover jumptable at 0x23044a5e. Too many branches + // WARNING: Treating indirect jump as call + (*prov->reset)(); + return; + } + return; +} + + + +ssize_t prov_ccc_read(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset) + +{ + ssize_t sVar1; + + sVar1 = bt_gatt_attr_read(conn,attr,buf,len,offset,attr->user_data,2); + return sVar1; +} + + + +ssize_t proxy_ccc_read(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset) + +{ + ssize_t sVar1; + + sVar1 = bt_gatt_attr_read(conn,attr,buf,len,offset,attr->user_data,2); + return sVar1; +} + + + +void proxy_sar_timeout(k_work *work) + +{ + printf("Proxy SAR timeout\r\n"); + if ((bt_conn *)work[-2].handler != (bt_conn *)0x0) { + bt_conn_disconnect((bt_conn *)work[-2].handler,'\x13'); + return; + } + return; +} + + + +bt_mesh_proxy_client_conflict * find_client(bt_conn *conn) + +{ + int iVar1; + + if (conn == clients[0].conn) { + iVar1 = 0; + } + else { + if (conn != clients[1].conn) { + return (bt_mesh_proxy_client_conflict *)0x0; + } + iVar1 = 1; + } + return (bt_mesh_proxy_client_conflict *)(clients + iVar1); +} + + + +ssize_t prov_ccc_write(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset,u8_t flags) + +{ + short sVar1; + ssize_t sVar2; + bt_mesh_proxy_client_conflict *pbVar3; + undefined2 in_register_00002036; + + sVar2 = -0xd; + if (CONCAT22(in_register_00002036,len) == 2) { + sVar1 = *(short *)buf; + *(short *)attr->user_data = sVar1; + if (sVar1 == 1) { + pbVar3 = find_client(conn); + sVar2 = 2; + if (pbVar3->filter_type == shaSuccess) { + pbVar3->filter_type = shaStateError; + bt_mesh_pb_gatt_open(conn); + sVar2 = 2; + } + } + else { + printf("Client wrote 0x%04x instead enabling notify\r\n"); + sVar2 = 2; + } + } + return sVar2; +} + + + +ssize_t proxy_ccc_write(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset,u8_t flags + ) + +{ + ssize_t sVar1; + bt_mesh_proxy_client_conflict *pbVar2; + undefined2 in_register_00002036; + + sVar1 = -0xd; + if (CONCAT22(in_register_00002036,len) == 2) { + if (*(short *)buf == 1) { + pbVar2 = find_client(conn); + sVar1 = 2; + if (pbVar2->filter_type == shaSuccess) { + pbVar2->filter_type = shaNull; + k_work_submit(&pbVar2->send_beacons); + sVar1 = 2; + } + } + else { + printf("Client wrote 0x%04x instead enabling notify\r\n"); + sVar1 = 2; + } + } + return sVar1; +} + + + +void filter_add(u16_t addr) + +{ + ushort uVar1; + undefined2 in_register_0000202a; + uint in_a1; + + if (((in_a1 != 0) && + (uVar1 = *(ushort *)CONCAT22(in_register_0000202a,addr), in_a1 != (uint)uVar1)) && + (uVar1 == 0)) { + *(ushort *)CONCAT22(in_register_0000202a,addr) = (ushort)in_a1; + } + return; +} + + + +bt_mesh_subnet * next_sub(void) + +{ + uint uVar1; + u8_t uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + + uVar1 = next_idx & 1; + if ((bt_mesh.sub[uVar1].net_idx == 0xffff) || + ((bt_mesh.sub[uVar1].node_id != '\x01' && + (uVar2 = bt_mesh_gatt_proxy_get(), CONCAT31(extraout_var,uVar2) != 1)))) { + uVar1 = next_idx + 1U & 1; + if ((bt_mesh.sub[uVar1].net_idx == 0xffff) || + ((bt_mesh.sub[uVar1].node_id != '\x01' && + (uVar2 = bt_mesh_gatt_proxy_get(), CONCAT31(extraout_var_00,uVar2) != 1)))) { + return (bt_mesh_subnet *)0x0; + } + } + next_idx = next_idx + 1U & 1; + return bt_mesh.sub + uVar1; +} + + + +void proxy_disconnected(bt_conn *conn,u8_t reason) + +{ + int iVar1; + + conn_count = conn_count + -1; + if (conn == clients[0].conn) { + iVar1 = 0; + } + else { + iVar1 = 1; + if (conn != clients[1].conn) goto LAB_23044c64; + } + if (clients[iVar1].filter_type == shaStateError) { + bt_mesh_pb_gatt_close(conn); + } + k_delayed_work_cancel(&clients[iVar1].sar_timer); + bt_conn_unref(clients[iVar1].conn); + clients[iVar1].conn = (bt_conn *)0x0; +LAB_23044c64: + bt_mesh_adv_update(); + return; +} + + + +void proxy_connected(bt_conn *conn,u8_t err) + +{ + int iVar1; + bt_conn *pbVar2; + undefined3 in_register_0000202d; + u8_t *puVar3; + + conn_count = conn_count + 1; + proxy_adv_enabled = false; + if (conn_count < 2) { + bt_mesh_adv_update(CONCAT31(in_register_0000202d,err)); + } + if (clients[0].conn == (bt_conn *)0x0) { + iVar1 = 0; + } + else { + iVar1 = 1; + if (clients[1].conn != (bt_conn *)0x0) { + printf("No free Proxy Client objects\r\n"); + return; + } + } + pbVar2 = bt_conn_ref(conn); + clients[iVar1].conn = pbVar2; + clients[iVar1].filter_type = shaSuccess; + memset(clients[iVar1].filter,0,2); + puVar3 = clients[iVar1].buf.__buf; + clients[iVar1].buf.len = 0; + clients[iVar1].buf.data = puVar3; + return; +} + + + +// WARNING: Variable defined which should be unmapped: params +// WARNING: Could not reconcile some variable overlaps + +int proxy_send(bt_conn *conn,void *data,u16_t len) + +{ + bt_gatt_attr_conflict1 *pbVar1; + int iVar2; + undefined auStack40 [4]; + bt_gatt_notify_params params; + + if (gatt_svc == MBEDTLS_SSL_SERVER_HELLO) { + memset(auStack40,0,0x18); + pbVar1 = proxy_attrs; + } + else { + if (gatt_svc != MBEDTLS_SSL_CLIENT_HELLO) { + return 0; + } + memset(auStack40,0,0x18); + pbVar1 = prov_attrs; + } + params.uuid = (bt_uuid *)(pbVar1 + 3); + params.attr = (bt_gatt_attr *)data; + params.data._0_2_ = len; + iVar2 = bt_gatt_notify_cb(conn,(bt_gatt_notify_params_conflict2 *)auStack40); + return iVar2; +} + + + +int proxy_segment_and_send(bt_conn *conn,u8_t type,net_buf_simple *msg) + +{ + uint len; + u16_t len_00; + undefined2 extraout_var; + uint uVar1; + int iVar2; + byte val; + + len_00 = bt_gatt_get_mtu(conn); + uVar1 = CONCAT22(extraout_var,len_00) - 3; + len = uVar1 & 0xffff; + val = type & 0x3f; + if (msg->len < len) { + net_buf_simple_push_u8(msg,val); + iVar2 = proxy_send(conn,msg->data,msg->len); + return iVar2; + } + net_buf_simple_push_u8(msg,val | 0x40); + len_00 = (u16_t)(uVar1 * 0x10000 >> 0x10); + proxy_send(conn,msg->data,len_00); + net_buf_simple_pull(msg,len); + while( true ) { + if (msg->len == 0) { + return 0; + } + if ((uint)msg->len + 1 < len) break; + net_buf_simple_push_u8(msg,val | 0x80); + proxy_send(conn,msg->data,len_00); + net_buf_simple_pull(msg,len); + } + net_buf_simple_push_u8(msg,type | 0xc0); + proxy_send(conn,msg->data,msg->len); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int beacon_send(bt_conn *conn,bt_mesh_subnet *sub) + +{ + int iVar1; + u8_t **ppuStack52; + net_buf_simple buf; + u8_t net_buf_data_buf [23]; + + ppuStack52 = &buf.__buf; + buf.data = (u8_t *)0x170000; + buf._4_4_ = &buf.__buf; + net_buf_simple_reserve((net_buf_simple *)&ppuStack52,1); + bt_mesh_beacon_create(sub,(net_buf_simple *)&ppuStack52); + iVar1 = proxy_segment_and_send(conn,'\x01',(net_buf_simple *)&ppuStack52); + return iVar1; +} + + + +void proxy_send_beacons(k_work *work) + +{ + if (bt_mesh.sub[0].net_idx != 0xffff) { + beacon_send((bt_conn *)work[-1].handler,bt_mesh.sub); + } + if (bt_mesh.sub[1].net_idx != 0xffff) { + beacon_send((bt_conn *)work[-1].handler,bt_mesh.sub + 1); + return; + } + return; +} + + + +void send_filter_status(bt_mesh_proxy_client_conflict *client,bt_mesh_net_rx_conflict6 *rx, + net_buf_simple *buf) + +{ + u16_t uVar1; + int iVar2; + char *fmt; + bt_mesh_subnet *pbStack28; + bt_mesh_net_tx_conflict5 tx; + + pbStack28 = rx->sub; + tx.sub = (bt_mesh_subnet *)&rx->ctx; + tx.ctx = (bt_mesh_msg_ctx *)0x0; + uVar1 = bt_mesh_primary_addr(); + tx.ctx = (bt_mesh_msg_ctx *)((uint)tx.ctx & 0xffff0000 | (uint)uVar1); + *(undefined2 *)&(tx.sub)->beacons_last = 0; + buf->len = 0; + buf->data = buf->__buf; + net_buf_simple_reserve(buf,10); + net_buf_simple_add_u8(buf,'\x03'); + net_buf_simple_add_u8(buf,client->filter_type != shaNull); + net_buf_simple_add_be16(buf,(ushort)(client->filter[0] != 0)); + iVar2 = bt_mesh_net_encode((bt_mesh_net_tx_conflict4 *)&pbStack28,buf,true); + if (iVar2 == 0) { + iVar2 = proxy_segment_and_send(client->conn,'\x02',buf); + if (iVar2 == 0) { + return; + } + fmt = "Failed to send proxy cfg message (err %d)\r\n"; + } + else { + fmt = "Encoding Proxy cfg message failed (err %d)\r\n"; + } + printf(fmt,iVar2); + return; +} + + + +// WARNING: Variable defined which should be unmapped: rx +// WARNING: Could not reconcile some variable overlaps + +void proxy_complete_pdu(bt_mesh_proxy_client_conflict *client) + +{ + byte bVar1; + u8_t uVar2; + u16_t uVar3; + char *fmt; + uint uVar4; + undefined3 extraout_var; + undefined2 extraout_var_00; + int iVar5; + u8_t **local_60; + net_buf_simple buf; + u8_t net_buf_data_buf [29]; + bt_mesh_net_rx_conflict6 rx; + + bVar1 = client->msg_type; + if (bVar1 == 1) { + bt_mesh_beacon_recv(&client->buf); + goto LAB_23044fdc; + } + if (bVar1 == 0) { + bt_mesh_net_recv(&client->buf,'\0',BT_MESH_NET_IF_PROXY); + goto LAB_23044fdc; + } + if (bVar1 == 2) { + local_60 = &buf.__buf; + buf.data = (u8_t *)0x1d0000; + buf._4_4_ = &buf.__buf; + uVar4 = bt_mesh_net_decode(&client->buf,BT_MESH_NET_IF_PROXY_CFG, + (bt_mesh_net_rx_conflict4 *)(net_buf_data_buf + 0x1c), + (net_buf_simple *)&local_60); + if (uVar4 == 0) { + net_buf_simple_pull((net_buf_simple *)&local_60,9); + if ((u16_t)buf.data == 0) { + printf("Too short proxy configuration PDU\r\n"); + goto LAB_23044fdc; + } + uVar2 = net_buf_simple_pull_u8((net_buf_simple *)&local_60); + uVar4 = CONCAT31(extraout_var,uVar2); + if (uVar4 == 1) { + while (1 < (u16_t)buf.data) { + net_buf_simple_pull_be16((net_buf_simple *)&local_60); + filter_add((short)client + 4); + } + } + else { + if (uVar2 == '\0') { + if ((u16_t)buf.data == 0) { + printf("Too short Filter Set message\r\n",uVar4); + } + else { + uVar2 = net_buf_simple_pull_u8((net_buf_simple *)&local_60); + iVar5 = CONCAT31(iVar5._1_3_,uVar2); + if (iVar5 == 0) { + memset(client->filter,0,2); + client->filter_type = shaNull; + } + else { + if (iVar5 == 1) { + memset(client->filter,0,2); + client->filter_type = shaInputTooLong; + } + else { + printf("Prohibited Filter Type 0x%02x\r\n",iVar5); + } + } + } + } + else { + if (uVar4 != (uint)bVar1) { + fmt = "Unhandled configuration OpCode 0x%02x\r\n"; + goto LAB_23045022; + } + while (1 < (u16_t)buf.data) { + uVar3 = net_buf_simple_pull_be16((net_buf_simple *)&local_60); + if ((CONCAT22(extraout_var_00,uVar3) != 0) && + ((uint)client->filter[0] == CONCAT22(extraout_var_00,uVar3))) { + client->filter[0] = 0; + } + } + } + } + send_filter_status(client,(bt_mesh_net_rx_conflict6 *)(net_buf_data_buf + 0x1c), + (net_buf_simple *)&local_60); + goto LAB_23044fdc; + } + fmt = "Failed to decode Proxy Configuration (err %d)\r\n"; + } + else { + if (bVar1 == 3) { + bt_mesh_pb_gatt_recv(client->conn,&client->buf); + goto LAB_23044fdc; + } + fmt = "Unhandled Message Type 0x%02x\r\n"; + uVar4 = (uint)bVar1; + } +LAB_23045022: + printf(fmt,uVar4); +LAB_23044fdc: + (client->buf).len = 0; + (client->buf).data = (client->buf).__buf; + return; +} + + + +ssize_t proxy_recv(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset,u8_t flags) + +{ + byte bVar1; + u16_t uVar2; + byte bVar3; + bt_mesh_proxy_client_conflict *client; + char *fmt; + size_t sVar4; + uint len_00; + undefined2 in_register_00002036; + int iVar5; + net_buf_simple *buf_00; + + iVar5 = CONCAT22(in_register_00002036,len); + client = find_client(conn); + if (client == (bt_mesh_proxy_client_conflict *)0x0) { + return -0x39; + } + if (iVar5 == 0) { + fmt = "Too small Proxy PDU\r\n"; + } + else { + if ((attr->user_data != (void *)0x0) == ((*(byte *)buf & 0x3f) == 3)) { + buf_00 = &client->buf; + len_00 = iVar5 - 1; + sVar4 = net_buf_simple_tailroom(buf_00); + if (sVar4 < len_00) { + fmt = "Too big proxy PDU\r\n"; + } + else { + bVar1 = *(byte *)buf; + uVar2 = (client->buf).len; + bVar3 = bVar1 >> 6; + if (bVar3 == 2) { + if (uVar2 == 0) { + fmt = "Continuation with no prior data\r\n"; + } + else { + if (client->msg_type == (bVar1 & 0x3f)) { + k_delayed_work_submit(&client->sar_timer,20000); +LAB_230451ea: + net_buf_simple_add_mem(buf_00,(void *)((int)buf + 1),len_00); + return iVar5; + } + fmt = "Unexpected message type in continuation\r\n"; + } + } + else { + if (bVar3 == 3) { + if (uVar2 == 0) { + fmt = "Last SAR PDU with no prior data\r\n"; + } + else { + if (client->msg_type == (bVar1 & 0x3f)) { + k_delayed_work_cancel(&client->sar_timer); + goto LAB_230451b0; + } + fmt = "Unexpected message type in last SAR PDU\r\n"; + } + } + else { + if (bVar3 == 1) { + if (uVar2 == 0) { + k_delayed_work_submit(&client->sar_timer,20000); + client->msg_type = *(byte *)buf & 0x3f; + goto LAB_230451ea; + } + fmt = "First PDU while a pending incomplete one\r\n"; + } + else { + if (uVar2 == 0) { + client->msg_type = bVar1; +LAB_230451b0: + net_buf_simple_add_mem(buf_00,(void *)((int)buf + 1),len_00); + proxy_complete_pdu(client); + return iVar5; + } + fmt = "Complete PDU while a pending incomplete one\r\n"; + } + } + } + } + } + else { + fmt = "Proxy PDU type doesn\'t match GATT service\r\n"; + } + } + printf(fmt); + return -0x16; +} + + + +void bt_mesh_proxy_beacon_send(bt_mesh_subnet *sub) + +{ + do { + if (sub != (bt_mesh_subnet *)0x0) { + if (clients[0].conn != (bt_conn *)0x0) { + beacon_send(clients[0].conn,sub); + } + if (clients[1].conn == (bt_conn *)0x0) { + return; + } + beacon_send(clients[1].conn,sub); + return; + } + if (bt_mesh.sub[0].net_idx != 0xffff) { + bt_mesh_proxy_beacon_send(bt_mesh.sub); + } + sub = bt_mesh.sub + 1; + } while (bt_mesh.sub[1].net_idx != 0xffff); + return; +} + + + +void bt_mesh_proxy_identity_start(bt_mesh_subnet *sub) + +{ + u32_t_conflict uVar1; + + sub->node_id = '\x01'; + uVar1 = k_uptime_get_32(); + sub->node_id_start = uVar1; + next_idx = ((int)(sub[-0x4a1be6].beacon_cache + 0x12) >> 2) * -0x47dc11f7; + return; +} + + + +void bt_mesh_proxy_identity_stop(bt_mesh_subnet *sub) + +{ + sub->node_id = '\0'; + sub->node_id_start = 0; + return; +} + + + +int bt_mesh_proxy_identity_enable(void) + +{ + _Bool _Var1; + undefined3 extraout_var; + bool bVar2; + int iVar3; + + _Var1 = bt_mesh_is_provisioned(); + iVar3 = -0xb; + if (CONCAT31(extraout_var,_Var1) != 0) { + bVar2 = false; + if ((bt_mesh.sub[0].net_idx != 0xffff) && (bt_mesh.sub[0].node_id != '\x02')) { + bt_mesh_proxy_identity_start(bt_mesh.sub); + bVar2 = true; + } + if ((bt_mesh.sub[1].net_idx == 0xffff) || (bt_mesh.sub[1].node_id == '\x02')) { + if (!bVar2) { + return 0; + } + } + else { + bt_mesh_proxy_identity_start(bt_mesh.sub + 1); + } + bt_mesh_adv_update(); + iVar3 = 0; + } + return iVar3; +} + + + +net_buf_simple * bt_mesh_proxy_get_buf(void) + +{ + clients[0].buf.data = clients[0].buf.__buf; + clients[0].buf.len = 0; + return &clients[0].buf; +} + + + +int bt_mesh_proxy_prov_enable(void) + +{ + int iVar1; + + iVar1 = -0x45; + if ((gatt_svc != MBEDTLS_SSL_CLIENT_HELLO) && + (iVar1 = -0x10, gatt_svc == MBEDTLS_SSL_HELLO_REQUEST)) { + bt_gatt_service_register(&prov_svc); + prov_fast_adv = true; + gatt_svc = MBEDTLS_SSL_CLIENT_HELLO; + if (clients[0].conn != (bt_conn *)0x0) { + clients[0].filter_type = shaStateError; + } + iVar1 = 0; + if (clients[1].conn != (bt_conn *)0x0) { + clients[1].filter_type = shaStateError; + } + } + return iVar1; +} + + + +int bt_mesh_proxy_prov_disable(_Bool disconnect) + +{ + undefined3 in_register_00002029; + int iVar1; + + if (gatt_svc == MBEDTLS_SSL_HELLO_REQUEST) { + iVar1 = -0x45; + } + else { + iVar1 = -0x10; + if (gatt_svc == MBEDTLS_SSL_CLIENT_HELLO) { + bt_gatt_service_unregister(&prov_svc); + gatt_svc = MBEDTLS_SSL_HELLO_REQUEST; + if ((clients[0].conn != (bt_conn *)0x0) && (clients[0].filter_type == shaStateError)) { + if (CONCAT31(in_register_00002029,disconnect) == 0) { + bt_mesh_pb_gatt_close(clients[0].conn); + clients[0].filter_type = shaSuccess; + } + else { + bt_conn_disconnect(clients[0].conn,'\x13'); + } + } + if ((clients[1].conn != (bt_conn *)0x0) && (clients[1].filter_type == shaStateError)) { + if (CONCAT31(in_register_00002029,disconnect) == 0) { + bt_mesh_pb_gatt_close(clients[1].conn); + clients[1].filter_type = shaSuccess; + } + else { + bt_conn_disconnect(clients[1].conn,'\x13'); + } + } + bt_mesh_adv_update(); + iVar1 = 0; + } + } + return iVar1; +} + + + +int bt_mesh_proxy_gatt_enable(void) + +{ + int iVar1; + + iVar1 = -0x45; + if ((gatt_svc != MBEDTLS_SSL_SERVER_HELLO) && + (iVar1 = -0x10, gatt_svc == MBEDTLS_SSL_HELLO_REQUEST)) { + bt_gatt_service_register(&proxy_svc); + gatt_svc = MBEDTLS_SSL_SERVER_HELLO; + if (clients[0].conn != (bt_conn *)0x0) { + clients[0].filter_type = shaNull; + } + iVar1 = 0; + if (clients[1].conn != (bt_conn *)0x0) { + clients[1].filter_type = shaNull; + } + } + return iVar1; +} + + + +void bt_mesh_proxy_gatt_disconnect(void) + +{ + if ((clients[0].conn != (bt_conn *)0x0) && ((byte)(clients[0].filter_type - 1U) < 2)) { + clients[0].filter_type = shaSuccess; + bt_conn_disconnect(clients[0].conn,'\x13'); + } + if ((clients[1].conn != (bt_conn *)0x0) && ((byte)(clients[1].filter_type - 1U) < 2)) { + clients[1].filter_type = shaSuccess; + bt_conn_disconnect(clients[1].conn,'\x13'); + return; + } + return; +} + + + +int bt_mesh_proxy_gatt_disable(void) + +{ + int iVar1; + + iVar1 = -0x45; + if ((gatt_svc != MBEDTLS_SSL_HELLO_REQUEST) && + (iVar1 = -0x10, gatt_svc == MBEDTLS_SSL_SERVER_HELLO)) { + bt_mesh_proxy_gatt_disconnect(); + bt_gatt_service_unregister(&proxy_svc); + iVar1 = 0; + gatt_svc = MBEDTLS_SSL_HELLO_REQUEST; + } + return iVar1; +} + + + +void bt_mesh_proxy_addr_add(net_buf_simple *buf,u16_t addr) + +{ + char cVar1; + undefined2 in_register_0000202e; + + cVar1 = *(char *)((int)&buf[-5].__buf + 2); + if (cVar1 == '\x01') { + filter_add((short)buf - 0x34); + return; + } + if (cVar1 == '\x02') { + if (CONCAT22(in_register_0000202e,addr) == 0) { + return; + } + if ((uint)*(ushort *)&buf[-5].__buf == CONCAT22(in_register_0000202e,addr)) { + *(undefined2 *)&buf[-5].__buf = 0; + return; + } + } + return; +} + + + +int bt_mesh_proxy_send(bt_conn *conn,u8_t type,net_buf_simple *msg) + +{ + bt_mesh_proxy_client_conflict *pbVar1; + int iVar2; + undefined3 in_register_0000202d; + + pbVar1 = find_client(conn); + if (pbVar1 == (bt_mesh_proxy_client_conflict *)0x0) { + printf("No Proxy Client found\r\n"); + iVar2 = -0x39; + } + else { + if ((pbVar1->filter_type == shaStateError) == (CONCAT31(in_register_0000202d,type) == 3)) { + iVar2 = proxy_segment_and_send(conn,type,msg); + return iVar2; + } + printf("Invalid PDU type for Proxy Client\r\n"); + iVar2 = -0x16; + } + return iVar2; +} + + + +// WARNING: Variable defined which should be unmapped: net_buf_data_msg +// WARNING: Could not reconcile some variable overlaps + +_Bool bt_mesh_proxy_relay(net_buf_simple *buf,u16_t dst) + +{ + bt_mesh_proxy_client *pbVar1; + undefined uVar2; + undefined2 in_register_0000202e; + u8_t **ppuStack76; + net_buf_simple msg; + u8_t net_buf_data_msg [32]; + + pbVar1 = clients; + uVar2 = 0; + do { + ppuStack76 = &msg.__buf; + msg.data = (u8_t *)0x200000; + if (pbVar1->conn != (bt_conn *)0x0) { + if (pbVar1->filter_type == shaNull) { + if ((uint)pbVar1->filter[0] == CONCAT22(in_register_0000202e,dst)) { +LAB_230456a6: + msg._4_4_ = ppuStack76; + net_buf_simple_reserve((net_buf_simple *)&ppuStack76,1); + net_buf_simple_add_mem((net_buf_simple *)&ppuStack76,buf->data,(uint)buf->len); + bt_mesh_proxy_send(pbVar1->conn,'\0',(net_buf_simple *)&ppuStack76); + uVar2 = 1; + } + } + else { + if ((pbVar1->filter_type == shaInputTooLong) && + ((uint)pbVar1->filter[0] != CONCAT22(in_register_0000202e,dst))) goto LAB_230456a6; + } + } + pbVar1 = pbVar1 + 1; + if (pbVar1 == (bt_mesh_proxy_client *)&conn_callbacks) { + return (_Bool)uVar2; + } + } while( true ); +} + + + +// WARNING: Could not reconcile some variable overlaps + +s32_t bt_mesh_proxy_adv_start(void) + +{ + bool bVar1; + _Bool _Var2; + bt_le_adv_param *param; + _Bool _Var3; + u8_t uVar4; + u16_t uVar5; + undefined3 extraout_var; + bt_mesh_prov_conflict8 *pbVar6; + char *__s; + size_t sVar7; + size_t sVar8; + uint uVar9; + undefined3 extraout_var_00; + bt_mesh_subnet *pbVar10; + u32_t_conflict uVar11; + undefined2 extraout_var_04; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + size_t sd_len; + int iVar12; + u8_t local_40 [4]; + bt_data prov_sd [2]; + + if (gatt_svc == MBEDTLS_SSL_HELLO_REQUEST) { + return -1; + } + _Var3 = bt_mesh_is_provisioned(); + if (CONCAT31(extraout_var,_Var3) != 0) goto LAB_23045804; + if (prov_fast_adv == false) { + param = &slow_adv_param; + } + else { + param = &fast_adv_param; + } + pbVar6 = bt_mesh_prov_get(); + __s = bt_get_name(); + sVar7 = strlen(__s); + memcpy(prov_svc_data + 2,pbVar6->uuid,0x10); + prov_svc_data._18_2_ = (ushort)pbVar6->oob_info >> 8 | pbVar6->oob_info << 8; + if (pbVar6->uri == (char *)0x0) { +LAB_23045760: + uVar9 = 0x1f; + sd_len = 0; +LAB_2304578e: + if (sVar7 != 0) { + iVar12 = sd_len * 8; + if (uVar9 - 2 < sVar7) { + local_40[iVar12] = 8; + local_40[iVar12 + 1] = (char)(uVar9 - 2); + } + else { + local_40[iVar12] = 9; + local_40[iVar12 + 1] = (char)sVar7; + } + *(char **)(prov_sd + sd_len) = __s; + sd_len = sd_len + 1; + } + } + else { + sVar8 = strlen(pbVar6->uri); + if (0x1d < sVar8) { + printf("Too long URI to fit advertising packet\r\n"); + goto LAB_23045760; + } + local_40[1] = (u8_t)sVar8; + local_40[0] = '$'; + prov_sd[0]._0_4_ = (u8_t *)pbVar6->uri; + uVar9 = 0x1d - sVar8; + sd_len = 1; + if (2 < uVar9) goto LAB_2304578e; + } + iVar12 = bt_le_adv_start(param,prov_ad,3,(bt_data *)local_40,sd_len); + if ((iVar12 == 0) && (proxy_adv_enabled = true, prov_fast_adv != false)) { + prov_fast_adv = false; + proxy_adv_enabled = true; + return 60000; + } +LAB_23045804: + _Var3 = bt_mesh_is_provisioned(); + if (CONCAT31(extraout_var_00,_Var3) != 0) { + pbVar10 = next_sub(); + while (conn_count != 2) { + if (pbVar10 == (bt_mesh_subnet *)0x0) { + printf("No subnets to advertise on\r\n"); + return -1; + } + _Var3 = (_Bool)pbVar10->node_id; + uVar9 = 0xffffffff; + _Var2 = proxy_adv_enabled; + if (_Var3 == true) { + uVar11 = k_uptime_get_32(); + if (uVar11 - pbVar10->node_id_start < 60000) { + uVar9 = (pbVar10->node_id_start + 60000) - uVar11; + proxy_svc_data[2] = _Var3; + iVar12 = bt_rand(proxy_svc_data + 0xb,8); + _Var2 = proxy_adv_enabled; + if (iVar12 == 0) { + memset(local_40,0,6); + memcpy((void *)&prov_sd[0].field_0x2,proxy_svc_data + 0xb,8); + uVar5 = bt_mesh_primary_addr(); + prov_sd[1]._2_2_ = (ushort)(CONCAT22(extraout_var_04,uVar5) >> 8) | uVar5 << 8; + iVar12 = bt_encrypt_be((u8_t *)((int)&pbVar10->beacon_sent + + ((uint)pbVar10->kr_flag + 1) * 0x59),local_40,local_40); + _Var2 = proxy_adv_enabled; + if (iVar12 == 0) { + memcpy(proxy_svc_data + 3,&prov_sd[0].data,8); + iVar12 = bt_le_adv_start(&fast_adv_param,node_id_ad,3,(bt_data *)0x0,0); + _Var2 = _Var3; + if (iVar12 != 0) { + printf("Failed to advertise using Node ID (err %d)\r\n",iVar12); + _Var2 = proxy_adv_enabled; + } + } + } + } + else { + pbVar10->node_id = '\0'; + pbVar10->node_id_start = 0; + _Var2 = proxy_adv_enabled; + } + } + proxy_adv_enabled = _Var2; + _Var3 = proxy_adv_enabled; + if (pbVar10->node_id != '\0') { +LAB_2304594a: + proxy_adv_enabled = _Var3; + bVar1 = false; + if ((bt_mesh.sub[0].net_idx != 0xffff) && + ((bt_mesh.sub[0].node_id == '\x01' || + (uVar4 = bt_mesh_gatt_proxy_get(), CONCAT31(extraout_var_02,uVar4) == 1)))) { + bVar1 = true; + } + if (bt_mesh.sub[1].net_idx == 0xffff) { + return uVar9; + } + if ((bt_mesh.sub[1].node_id != '\x01') && + (uVar4 = bt_mesh_gatt_proxy_get(), CONCAT31(extraout_var_03,uVar4) != 1)) { + return uVar9; + } + if (!bVar1) { + return uVar9; + } + if (10000 < uVar9) { + return 10000; + } + return uVar9; + } + _Var3 = (_Bool)bt_mesh_gatt_proxy_get(); + if (CONCAT31(extraout_var_01,_Var3) == 1) { + proxy_svc_data[2] = '\0'; + memcpy(proxy_svc_data + 3,pbVar10->keys[pbVar10->kr_flag].net_id,8); + iVar12 = bt_le_adv_start(&slow_adv_param,net_id_ad,3,(bt_data *)0x0,0); + if (iVar12 != 0) { + printf("Failed to advertise using Network ID (err %d)\r\n",iVar12); + _Var3 = proxy_adv_enabled; + } + goto LAB_2304594a; + } + pbVar10 = next_sub(); + } + } + return -1; +} + + + +int bt_mesh_proxy_adv_stop(int param_1) + +{ + if (proxy_adv_enabled != false) { + param_1 = bt_le_adv_stop(); + if (param_1 != 0) { + printf("Failed to stop advertising (err %d)\r\n"); + return param_1; + } + proxy_adv_enabled = false; + } + return param_1; +} + + + +int bt_mesh_proxy_init(void) + +{ + clients[0].buf.size = 0x44; + clients[0].buf.__buf = client_buf_data; + k_delayed_work_init(&clients[0].sar_timer,proxy_sar_timeout); + clients[1].buf.size = 0x44; + clients[1].buf.__buf = client_buf_data + 0x44; + k_delayed_work_init(&clients[1].sar_timer,proxy_sar_timeout); + bt_conn_cb_register(&conn_callbacks); + return 0; +} + + + +void send_cb_finalize(bt_mesh_send_cb *cb,void *cb_data) + +{ + if (cb == (bt_mesh_send_cb *)0x0) { + return; + } + if (cb->start != (anon_subr_void_u16_t_int_void_ptr_for_start *)0x0) { + (*cb->start)(0,0,cb_data); + } + if (cb->end != (anon_subr_void_int_void_ptr_for_end *)0x0) { + // WARNING: Could not recover jumptable at 0x23045aa2. Too many branches + // WARNING: Treating indirect jump as call + (*cb->end)(0,cb_data); + return; + } + return; +} + + + +void seg_first_send_start(u16_t duration,int err,void *user_data) + +{ + code *UNRECOVERED_JUMPTABLE; + + if ((*(code ***)((int)user_data + 0x30) != (code **)0x0) && + (UNRECOVERED_JUMPTABLE = **(code ***)((int)user_data + 0x30), + UNRECOVERED_JUMPTABLE != (code *)0x0)) { + // WARNING: Could not recover jumptable at 0x23045abe. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(*(undefined4 *)((int)user_data + 0x34)); + return; + } + return; +} + + + +_Bool is_replay(bt_mesh_net_rx_conflict8 *rx,bt_mesh_rpl **match) + +{ + byte bVar1; + char cVar2; + u16_t uVar3; + u16_t uVar4; + bt_mesh_rpl *pbVar5; + int iVar6; + int iVar7; + + bVar1 = *(byte *)&rx->field_0x20; + if ((bVar1 & 0x30) != 0x10) { + if ((bVar1 & 0x40) == 0) { + return false; + } + pbVar5 = bt_mesh.rpl; + iVar6 = 0; + while( true ) { + uVar3 = pbVar5->src; + if (uVar3 == 0) break; + uVar4 = (rx->ctx).addr; + if (uVar3 == uVar4) { + iVar7 = iVar6 + 0x78; + cVar2 = *(char *)((int)&bt_mesh.local_work._reserved + iVar7 * 8 + 2); + if ((bVar1 & 1) == 0) { + if (cVar2 == '\0') goto LAB_23045b4a; + } + else { + if (cVar2 == '\0') { + return true; + } +LAB_23045b4a: + if ((k_work_handler_t *)rx->seq <= (&bt_mesh.local_work.handler)[iVar7 * 2]) { + return true; + } + } + if (match != (bt_mesh_rpl **)0x0) { + *match = pbVar5; + return false; + } + *(u16_t *)(&bt_mesh.local_work._reserved + iVar7 * 2) = uVar4; + goto LAB_23045b0a; + } + iVar6 = iVar6 + 1; + pbVar5 = pbVar5 + 1; + if (iVar6 == 5) { + printf("RPL is full!\r\n"); + return true; + } + } + if (match != (bt_mesh_rpl **)0x0) { + *match = pbVar5; + return (_Bool)(char)uVar3; + } + *(u16_t *)(&bt_mesh.local_work._reserved + (iVar6 + 0x78) * 2) = (rx->ctx).addr; +LAB_23045b0a: + (&bt_mesh.local_work.handler)[(iVar6 + 0x78) * 2] = (k_work_handler_t *)rx->seq; + *(byte *)((int)&bt_mesh.local_work._reserved + (iVar6 + 0x78) * 8 + 2) = + (byte)*(undefined4 *)&rx->field_0x20 & 1; + } + return false; +} + + + +void seg_sent(int err,void *user_data) + +{ + uint32_t delay; + + delay = 0x32; + if (0 < *(short *)((int)user_data + 0x28)) { + delay = (uint)*(byte *)((int)user_data + 0x2c) * 0x32 + 400; + } + k_delayed_work_submit((k_delayed_work *)((int)user_data + 0x38),delay); + return; +} + + + +s32_t ack_timeout(seg_rx_conflict1 *rx) + +{ + uint uVar1; + u8_t uVar2; + undefined3 extraout_var; + int iVar3; + s32_t sVar4; + + uVar1 = (uint)rx->ttl; + if (rx->ttl == 0xff) { + uVar2 = bt_mesh_default_ttl_get(); + uVar1 = CONCAT31(extraout_var,uVar2); + } + iVar3 = __popcountsi2(rx->block); + sVar4 = (((*(uint *)&rx->field_0x10 & 0x1f) + 1) - iVar3) * 100 + uVar1 * 0x32 + 0x96; + if (sVar4 < 400) { + sVar4 = 400; + } + return sVar4; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int sdu_recv(bt_mesh_net_rx_conflict8 *rx,u32_t_conflict seq,u8_t hdr,u8_t aszmic, + net_buf_simple *buf) + +{ + bt_mesh_net_conflict9 *pbVar1; + char *fmt; + int iVar2; + bt_mesh_app_keys *pbVar3; + undefined3 in_register_00002035; + short sVar4; + ushort uVar5; + u16_t addr; + int iVar6; + u8_t *ad; + u32_t_conflict in_fa0; + u32_t_conflict in_fa1; + u8_t **ppuStack180; + net_buf_simple sdu; + u8_t net_buf_data_sdu [104]; + + ppuStack180 = &sdu.__buf; + sdu.data = (u8_t *)0x680000; + sdu._4_4_ = &sdu.__buf; + uVar5 = 5; + if (CONCAT31(in_register_00002035,aszmic) != 0) { + uVar5 = 9; + } + if (buf->len < uVar5) { + fmt = "Too short SDU + MIC\r\n"; + } + else { + if ((*(byte *)&rx->field_0x20 & 0x40) == 0) { + return 0; + } + addr = (rx->ctx).recv_dst; + ad = (u8_t *)0x0; + if ((addr ^ 0x8000) < 0x4000) { + ad = bt_mesh_label_uuid_get(addr); + } + sVar4 = 8; + if (CONCAT31(in_register_00002035,aszmic) == 0) { + sVar4 = 4; + } + buf->len = buf->len - sVar4; + if ((hdr & 0x40) == 0) { + iVar2 = bt_mesh_app_decrypt(bt_mesh.dev_key,true,aszmic,buf,(net_buf_simple *)&ppuStack180,ad, + (rx->ctx).addr,(rx->ctx).recv_dst,in_fa0,in_fa1); + addr = 0xfffe; + if (iVar2 == 0) { +LAB_23045d82: + (rx->ctx).app_idx = addr; + bt_mesh_model_recv((bt_mesh_net_rx_conflict2 *)rx,(net_buf_simple *)&ppuStack180); + return iVar2; + } + fmt = "Unable to decrypt with DevKey\r\n"; + } + else { + pbVar1 = &bt_mesh; + iVar6 = 0; + while( true ) { + if (pbVar1->app_keys[0].net_idx == rx->sub->net_idx) { + if (((*(byte *)&rx->field_0x20 & 2) == 0) || + (pbVar3 = pbVar1->app_keys[0].keys + 1, pbVar1->app_keys[0].updated == false)) { + pbVar3 = pbVar1->app_keys[0].keys; + } + if (pbVar3->id == (hdr & 0x3f)) { + ppuStack180 = sdu._4_4_; + sdu.data = (u8_t *)((uint)sdu.data & 0xffff0000); + iVar2 = bt_mesh_app_decrypt(pbVar3->val,false,aszmic,buf,(net_buf_simple *)&ppuStack180, + ad,(rx->ctx).addr,(rx->ctx).recv_dst,in_fa0,in_fa1); + if (iVar2 == 0) { + addr = bt_mesh.app_keys[iVar6].app_idx; + goto LAB_23045d82; + } + printf("Unable to decrypt with AppKey 0x%03x\r\n",(uint)pbVar1->app_keys[0].app_idx); + } + } + pbVar1 = (bt_mesh_net_conflict9 *)&pbVar1->frnd[0].num_elem; + if (iVar6 == 1) break; + iVar6 = 1; + } + fmt = "No matching AppKey\r\n"; + } + } + printf(fmt); + return -0x16; +} + + + +void seg_send_start(u16_t duration,int err,void *user_data) + +{ + uint32_t delay; + + if (err != 0) { + delay = 0x32; + if (0 < *(short *)((int)user_data + 0x28)) { + delay = (uint)*(byte *)((int)user_data + 0x2c) * 0x32 + 400; + } + k_delayed_work_submit((k_delayed_work *)((int)user_data + 0x38),delay); + return; + } + return; +} + + + +void seg_rx_reset(seg_rx_conflict1 *rx,_Bool full_reset) + +{ + int iVar1; + undefined3 in_register_0000202d; + DItype DVar2; + + k_delayed_work_cancel(&rx->ack); + if (*(char *)&rx->field_0x10 < '\0') { + iVar1 = 1; + DVar2 = __ashldi3(1); + if (rx->block != iVar1 - 1U) { + printf("Clearing incomplete buffers from Friend queue\r\n",(int)DVar2); + bt_mesh_friend_clear_incomplete(rx->sub,rx->src,rx->dst,&rx->seq_auth); + } + } + *(byte *)&rx->field_0x10 = *(byte *)&rx->field_0x10 & 0xbf; + if (CONCAT31(in_register_0000202d,full_reset) != 0) { + *(undefined4 *)&rx->seq_auth = 0; + *(undefined4 *)((int)&rx->seq_auth + 4) = 0; + rx->sub = (bt_mesh_subnet *)0x0; + *(undefined4 *)&rx->src = 0; + } + return; +} + + + +void seg_tx_reset(seg_tx_conflict1 *tx) + +{ + u8_t uVar1; + net_buf **ppnVar2; + _Bool _Var3; + uint uVar4; + undefined3 extraout_var; + int iVar5; + + k_delayed_work_cancel(&tx->retransmit); + *(undefined4 *)&tx->seq_auth = 0; + uVar1 = tx->nack_count; + tx->cb = (bt_mesh_send_cb *)0x0; + tx->cb_data = (void *)0x0; + *(undefined4 *)((int)&tx->seq_auth + 4) = 0; + tx->sub = (bt_mesh_subnet *)0x0; + tx->dst = 0; + if (uVar1 != '\0') { + ppnVar2 = tx->seg; + iVar5 = 0; + do { + if (*ppnVar2 != (net_buf *)0x0) { + net_buf_unref(*ppnVar2); + *ppnVar2 = (net_buf *)0x0; + } + iVar5 = iVar5 + 1; + ppnVar2 = ppnVar2 + 1; + } while (iVar5 <= (int)((uint)*(ushort *)&tx->field_0x2a & 0x1f)); + tx->nack_count = '\0'; + uVar4 = atomic_and(bt_mesh.flags,-0x21); + if (((uVar4 & 0x20) != 0) && + (_Var3 = bt_mesh_net_iv_update(bt_mesh.iv_index,false), CONCAT31(extraout_var,_Var3) != 0)) { + bt_mesh_net_sec_update((bt_mesh_subnet *)0x0); + return; + } + } + return; +} + + + +void seg_tx_complete(seg_tx_conflict1 *tx,int err) + +{ + anon_subr_void_int_void_ptr_for_end *paVar1; + + if ((tx->cb != (bt_mesh_send_cb *)0x0) && + (paVar1 = tx->cb->end, paVar1 != (anon_subr_void_int_void_ptr_for_end *)0x0)) { + (*paVar1)(err,tx->cb_data); + } + seg_tx_reset(tx); + return; +} + + + +void seg_tx_send_unacked(seg_tx_conflict1 *tx) + +{ + char cVar1; + int err; + net_buf *buf; + int iVar2; + net_buf **ppnVar3; + + ppnVar3 = tx->seg; + err = 0; + do { + buf = *ppnVar3; + if ((buf != (net_buf *)0x0) && (iVar2 = *(int *)buf->user_data, (*(byte *)(iVar2 + 8) & 4) == 0) + ) { + cVar1 = *(char *)(iVar2 + 10); + *(char *)(iVar2 + 10) = cVar1 + -1; + if (cVar1 == '\0') { + printf("Ran out of retransmit attempts\r\n"); + err = -0x3c; +LAB_23045f4e: + seg_tx_complete(tx,err); + return; + } + iVar2 = bt_mesh_net_resend(tx->sub,buf,(_Bool)((byte)(*(uint *)&tx->dst >> 0x15) & 1), + &seg_sent_cb,tx); + if (iVar2 != 0) { + printf("Sending segment failed\r\n"); + err = -5; + goto LAB_23045f4e; + } + } + err = err + 1; + ppnVar3 = ppnVar3 + 1; + if ((int)((uint)*(ushort *)&tx->field_0x2a & 0x1f) < err) { + return; + } + } while( true ); +} + + + +void seg_retransmit(k_work *work) + +{ + seg_tx_send_unacked((seg_tx_conflict1 *)&work[-5].handler); + return; +} + + + +// WARNING: Type propagation algorithm not settling + +int ctl_recv(bt_mesh_net_rx_conflict8 *rx,u8_t hdr,net_buf_simple *buf,u64_t *seq_auth) + +{ + u8_t uVar1; + u16_t uVar2; + byte bVar3; + u16_t feat; + undefined2 extraout_var; + u32_t_conflict data; + int iVar4; + char *fmt; + int err; + uint uVar5; + seg_tx_conflict *psVar6; + undefined4 uVar7; + uint uVar8; + + bVar3 = hdr & 0x7f; + if ((hdr & 0x7f) == 0) { + if (buf->len < 6) { + fmt = "Too short ack message\r\n"; + goto LAB_23046020; + } + feat = net_buf_simple_pull_be16(buf); + uVar8 = ((uint)feat & 0x7ffc) >> 2; + if (-1 < *(char *)&rx->field_0x20) { + data = net_buf_simple_pull_be32(buf); + uVar2 = (rx->ctx).addr; + psVar6 = seg_tx; + iVar4 = 0; + do { + uVar5 = *(uint *)&psVar6->seq_auth; + uVar7 = *(undefined4 *)((int)&psVar6->seq_auth + 4); + if ((uVar5 & 0x1fff) == uVar8) { + if (psVar6->dst != uVar2) { + if (((CONCAT22(extraout_var,feat) >> 0xf & 0xffff) == 0) || + ((uint)psVar6->nack_count != ((uint)*(ushort *)&seg_tx[iVar4].field_0x2a & 0x1f) + 1) + ) goto LAB_23046112; + seg_tx[iVar4].dst = uVar2; + } + *(uint *)seq_auth = uVar5; + *(undefined4 *)((int)seq_auth + 4) = uVar7; + if (data == 0) { + printf("SDU canceled\r\n"); + err = -0x48; + goto LAB_2304610a; + } + uVar8 = find_msb_set(data); + if (uVar8 - 1 <= ((uint)*(ushort *)&seg_tx[iVar4].field_0x2a & 0x1f)) { + k_delayed_work_cancel(&seg_tx[iVar4].retransmit); + while (uVar8 = find_lsb_set(data), uVar8 != 0) { + err = iVar4 * 0x18 + (uVar8 - 1); + if (seg_tx[0].seg[err] != (net_buf *)0x0) { + net_buf_unref(seg_tx[0].seg[err]); + uVar1 = seg_tx[iVar4].nack_count; + seg_tx[0].seg[err] = (net_buf *)0x0; + seg_tx[iVar4].nack_count = uVar1 + -1; + } + data = data & ~(1 << (uVar8 - 1 & 0x1f)); + } + if (seg_tx[iVar4].nack_count != '\0') { + seg_tx_send_unacked((seg_tx_conflict1 *)(seg_tx + iVar4)); + return 0; + } + err = 0; +LAB_2304610a: + seg_tx_complete((seg_tx_conflict1 *)(seg_tx + iVar4),err); + return 0; + } + fmt = "Too large segment number in ack\r\n"; + goto LAB_23046020; + } +LAB_23046112: + psVar6 = psVar6 + 1; + if (iVar4 == 1) goto LAB_23046368; + iVar4 = 1; + } while( true ); + } + uVar5 = bt_mesh.iv_index - (*(uint *)&rx->field_0x20 & 1); + *(uint *)seq_auth = uVar5 * 0x1000000 | uVar8; + *(uint *)((int)seq_auth + 4) = uVar5 >> 8; + } + else { + if (bVar3 == 10) { + if (buf->len < 3) { + fmt = "Too short heartbeat message\r\n"; + goto LAB_23046020; + } + if ((rx->ctx).recv_dst == hb_sub_dst) { + bVar3 = net_buf_simple_pull_u8(buf); + feat = net_buf_simple_pull_be16(buf); + bt_mesh_heartbeat((rx->ctx).addr,(rx->ctx).recv_dst, + ('\x01' - (rx->ctx).recv_ttl) + (bVar3 & 0x7f),feat); + } + else { + printf("Ignoring heartbeat to non-subscribed destination\r\n"); + } + } + else { + if ((*(byte *)&rx->field_0x20 & 0x40) != 0) { + if ((bt_mesh.lpn._12_4_ >> 4 & 1) == 0) { + switch(bVar3) { + case 1: + iVar4 = bt_mesh_friend_poll((bt_mesh_net_rx_conflict10 *)rx,buf); + return iVar4; + case 3: + iVar4 = bt_mesh_friend_req((bt_mesh_net_rx_conflict10 *)rx,buf); + return iVar4; + case 5: + iVar4 = bt_mesh_friend_clear((bt_mesh_net_rx_conflict10 *)rx,buf); + return iVar4; + case 6: + iVar4 = bt_mesh_friend_clear_cfm((bt_mesh_net_rx_conflict10 *)rx,buf); + return iVar4; + case 7: + iVar4 = bt_mesh_friend_sub_add((bt_mesh_net_rx_conflict10 *)rx,buf); + return iVar4; + case 8: + iVar4 = bt_mesh_friend_sub_rem((bt_mesh_net_rx_conflict10 *)rx,buf); + return iVar4; + } + } + if (bVar3 == 4) { + iVar4 = bt_mesh_lpn_friend_offer((bt_mesh_net_rx_conflict *)rx,buf); + return iVar4; + } + if ((rx->ctx).addr == bt_mesh.lpn.frnd) { + if (bVar3 == 6) { + iVar4 = bt_mesh_lpn_friend_clear_cfm((bt_mesh_net_rx_conflict *)rx,buf); + return iVar4; + } + if ((*(byte *)&rx->field_0x20 & 4) == 0) { + fmt = "Message from friend with wrong credentials\r\n"; + goto LAB_23046020; + } + if (bVar3 == 2) { + iVar4 = bt_mesh_lpn_friend_update((bt_mesh_net_rx_conflict *)rx,buf); + return iVar4; + } + if (bVar3 == 9) { + iVar4 = bt_mesh_lpn_friend_sub_cfm((bt_mesh_net_rx_conflict *)rx,buf); + return iVar4; + } + } + printf("Unhandled TransOpCode 0x%02x\r\n"); + return -2; + } + } + } + return 0; +LAB_23046368: + fmt = "No matching TX context for ack\r\n"; +LAB_23046020: + printf(fmt); + return -0x16; +} + + + +void bt_mesh_set_hb_sub_dst(u16_t addr) + +{ + hb_sub_dst = addr; + return; +} + + + +_Bool bt_mesh_tx_in_progress(void) + +{ + return (_Bool)((seg_tx[0].nack_count | seg_tx[1].nack_count) != 0); +} + + + +bt_mesh_app_key * bt_mesh_app_key_find(u16_t app_idx) + +{ + undefined2 in_register_0000202a; + bt_mesh_app_key *pbVar1; + + if ((bt_mesh.app_keys[0].net_idx == 0xffff) || + ((uint)bt_mesh.app_keys[0].app_idx != CONCAT22(in_register_0000202a,app_idx))) { + pbVar1 = (bt_mesh_app_key *)0x0; + if ((bt_mesh.app_keys[1].net_idx != 0xffff) && + ((uint)bt_mesh.app_keys[1].app_idx == CONCAT22(in_register_0000202a,app_idx))) { + pbVar1 = bt_mesh.app_keys + 1; + } + } + else { + pbVar1 = bt_mesh.app_keys; + } + return pbVar1; +} + + + +int bt_mesh_trans_send(bt_mesh_net_tx_conflict7 *tx,net_buf_simple *msg,bt_mesh_send_cb *cb, + void *cb_data) + +{ + u16_t app_idx; + u16_t dst; + u16_t src; + bt_mesh_app_keys *pbVar1; + u32_t_conflict seq_num; + u8_t *key; + u8_t uVar2; + _Bool _Var3; + size_t len; + char *fmt; + uint uVar4; + int iVar5; + bt_mesh_app_key *pbVar6; + atomic_val_t aVar7; + undefined3 extraout_var; + net_buf *buf; + undefined3 extraout_var_00; + net_buf *pnVar8; + int iVar9; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + bt_mesh_friend_pdu_type type; + byte val; + undefined4 uVar10; + bt_mesh_send_cb *cb_00; + uint uVar11; + u8_t *ad; + bt_mesh_subnet *pbVar12; + bt_mesh_msg_ctx *pbVar13; + net_buf_simple *buf_00; + uint uVar14; + seg_tx_conflict1 *tx_00; + u32_t_conflict in_fa0; + byte bStack88; + bt_mesh_send_cb *pbStack76; + + len = net_buf_simple_tailroom(msg); + if (len < 4) { + fmt = "Insufficient tailroom for Transport MIC\r\n"; + } + else { + if (0xb < msg->len) { + tx->ctx->send_rel = true; + } + pbVar13 = tx->ctx; + app_idx = pbVar13->app_idx; + if (app_idx == 0xfffe) { + key = bt_mesh.dev_key; + *(byte *)&tx->field_0xb = *(byte *)&tx->field_0xb & 3; + } + else { + pbVar6 = bt_mesh_app_key_find(app_idx); + if (pbVar6 == (bt_mesh_app_key *)0x0) { + return -0x16; + } + if ((tx->sub->kr_phase == '\x02') && (pbVar6->updated != false)) { + uVar2 = pbVar6->keys[1].id; + pbVar1 = pbVar6->keys + 1; + } + else { + pbVar1 = pbVar6->keys; + uVar2 = pbVar6->keys[0].id; + } + key = pbVar1->val; + *(byte *)&tx->field_0xb = *(byte *)&tx->field_0xb & 3 | uVar2 << 2; + } + _Var3 = pbVar13->send_rel; + uVar4 = (uint)_Var3; + if (_Var3 != false) { + len = net_buf_simple_tailroom(msg); + uVar4 = (uint)(len < 8) ^ 1; + } + *(byte *)&tx->field_0xb = (byte)((uVar4 & 1) << 1) | *(byte *)&tx->field_0xb & 0xfd; + app_idx = tx->ctx->addr; + ad = (u8_t *)0x0; + if ((app_idx ^ 0x8000) < 0x4000) { + ad = bt_mesh_label_uuid_get(app_idx); + } + seq_num = bt_mesh.seq; + uVar10 = *(undefined4 *)&tx->src; + app_idx = tx->ctx->app_idx; + dst = tx->ctx->addr; + src = tx->src; + atomic_get(bt_mesh.flags); + iVar5 = bt_mesh_app_encrypt(key,(_Bool)(app_idx == 0xfffe),(byte)((uint)uVar10 >> 0x19) & 1,msg, + ad,src,dst,seq_num,in_fa0); + seq_num = bt_mesh.iv_index; + if (iVar5 != 0) { + return iVar5; + } + pbVar13 = tx->ctx; + if (pbVar13->send_rel == false) { + buf = bt_mesh_adv_create(BT_MESH_ADV_DATA,tx->xmit,0); + if (buf == (net_buf *)0x0) { + printf("Out of network buffers\r\n"); + return -0x37; + } + buf_00 = (net_buf_simple *)&buf->field_4; + net_buf_simple_reserve(buf_00,9); + val = 0; + if (tx->ctx->app_idx != 0xfffe) { + val = (byte)((uint)*(undefined4 *)&tx->src >> 0x1a) | 0x40; + } + net_buf_simple_add_u8(buf_00,val); + net_buf_simple_add_mem(buf_00,msg->data,(uint)msg->len); + _Var3 = bt_mesh_friend_queue_has_space + (tx->sub->net_idx,tx->src,tx->ctx->addr,(u64_t *)0x0,'\x01'); + if (CONCAT31(extraout_var_01,_Var3) == 0) { + if (0 < (short)tx->ctx->addr) { + printf("Not enough space in Friend Queue\r\n"); + net_buf_unref(buf); + return -0x37; + } + printf("No space in Friend Queue\r\n"); + } + else { + _Var3 = bt_mesh_friend_enqueue_tx + ((bt_mesh_net_tx_conflict9 *)tx,BT_MESH_FRIEND_PDU_SINGLE,(u64_t *)0x0, + '\x01',buf_00); + if ((CONCAT31(extraout_var_02,_Var3) != 0) && (0 < (short)tx->ctx->addr)) { + net_buf_unref(buf); + send_cb_finalize(cb,cb_data); + return 0; + } + } + iVar5 = bt_mesh_net_send((bt_mesh_net_tx_conflict4 *)tx,buf,cb,cb_data); + return iVar5; + } + if (msg->len != 0) { + if (0x48 < msg->len) { + printf("Not enough segment buffers for length %u\r\n"); + return -0x24; + } + if (seg_tx[0].nack_count == '\0') { + iVar5 = 0; + } + else { + if (seg_tx[1].nack_count != '\0') { + printf("No multi-segment message contexts available\r\n"); + return -0x10; + } + iVar5 = 1; + } + bStack88 = 0x80; + tx_00 = (seg_tx_conflict1 *)(seg_tx + iVar5); + if (pbVar13->app_idx != 0xfffe) { + bStack88 = (byte)((uint)*(undefined4 *)&tx->src >> 0x1a) | 0xc0; + } + seg_tx[iVar5].dst = pbVar13->addr; + val = (byte)(((uint)msg->len - 1) / 0xc) & 0x1f; + *(byte *)&seg_tx[iVar5].field_0x2a = *(byte *)&seg_tx[iVar5].field_0x2a & 0xe0 | val; + seg_tx[iVar5].nack_count = val + 1; + aVar7 = atomic_get(bt_mesh.flags); + uVar4 = seq_num - (aVar7 >> 2 & 1U); + *(uint *)&seg_tx[iVar5].seq_auth = uVar4 * 0x1000000 | bt_mesh.seq; + *(uint *)((int)&seg_tx[iVar5].seq_auth + 4) = uVar4 >> 8; + pbVar12 = tx->sub; + seg_tx[iVar5].sub = pbVar12; + _Var3 = pbVar12->kr_flag; + seg_tx[iVar5].cb_data = cb_data; + *(byte *)&seg_tx[iVar5].field_0x2a = + *(byte *)&seg_tx[iVar5].field_0x2a & 0xdf | (byte)(((uint)_Var3 & 1) << 5); + seg_tx[iVar5].cb = cb; + uVar2 = tx->ctx->send_ttl; + if (uVar2 == -1) { + uVar2 = bt_mesh_default_ttl_get(); + seg_tx[iVar5].ttl = uVar2; + } + else { + seg_tx[iVar5].ttl = uVar2; + } + uVar4 = (uint)*(ushort *)&seg_tx[iVar5].seq_auth & 0x1fff; + _Var3 = bt_mesh_friend_queue_has_space + ((seg_tx[iVar5].sub)->net_idx,tx->src,seg_tx[iVar5].dst, + &seg_tx[iVar5].seq_auth, + ((byte)*(undefined2 *)&seg_tx[iVar5].field_0x2a & 0x1f) + 1); + if ((CONCAT31(extraout_var,_Var3) == 0) && (0 < (short)seg_tx[iVar5].dst)) { + printf("Not enough space in Friend Queue for %u segments\r\n", + ((uint)*(ushort *)&seg_tx[iVar5].field_0x2a & 0x1f) + 1); + } + else { + pbStack76 = &seg_sent_cb; + uVar14 = 0; + while( true ) { + if (msg->len == 0) { + if (seg_tx[iVar5].seg[0] == (net_buf *)0x0) { + seg_tx_reset(tx_00); + send_cb_finalize(cb,cb_data); + } + if ((bt_mesh.lpn._12_4_ >> 4 & 1) != 0) { + bt_mesh_lpn_poll(); + return 0; + } + return 0; + } + buf = bt_mesh_adv_create(BT_MESH_ADV_DATA,tx->xmit,0); + if (buf == (net_buf *)0x0) break; + buf_00 = (net_buf_simple *)&buf->field_4; + *(undefined *)(*(int *)buf->user_data + 10) = 4; + net_buf_simple_reserve(buf_00,9); + net_buf_simple_add_u8(buf_00,bStack88); + net_buf_simple_add_u8 + (buf_00,(byte)(*(uint *)&tx->src >> 0x12) & 0x80 | (byte)(uVar4 >> 6)); + net_buf_simple_add_u8(buf_00,(byte)(uVar14 >> 3) | (byte)((uVar4 << 0x1a) >> 0x18)); + net_buf_simple_add_u8 + (buf_00,(byte)(uVar14 << 5) | + (byte)*(undefined2 *)&seg_tx[iVar5].field_0x2a & 0x1f); + len = (size_t)msg->len; + if (0xc < msg->len) { + len = 0xc; + } + net_buf_simple_add_mem(buf_00,msg->data,len); + net_buf_simple_pull(msg,len); + type = BT_MESH_FRIEND_PDU_COMPLETE; + uVar11 = (uint)*(ushort *)&seg_tx[iVar5].field_0x2a & 0x1f; + if (uVar14 != uVar11) { + type = BT_MESH_FRIEND_PDU_PARTIAL; + } + _Var3 = bt_mesh_friend_enqueue_tx + ((bt_mesh_net_tx_conflict9 *)tx,type,&seg_tx[iVar5].seq_auth, + (char)uVar11 + '\x01',buf_00); + if ((CONCAT31(extraout_var_00,_Var3) == 0) || ((short)tx->ctx->addr < 1)) { + pnVar8 = net_buf_ref(buf); + seg_tx[0].seg[iVar5 * 0x18 + uVar14] = pnVar8; + cb_00 = pbStack76; + if (uVar14 == 0) { + cb_00 = &first_sent_cb; + } + iVar9 = bt_mesh_net_send((bt_mesh_net_tx_conflict4 *)tx,buf,cb_00,tx_00); + if (iVar9 != 0) { + printf("Sending segment failed\r\n"); + seg_tx_reset(tx_00); + return iVar9; + } + } + else { + net_buf_unref(buf); + } + uVar14 = uVar14 + 1 & 0xff; + } + printf("Out of segment buffers\r\n"); + } + seg_tx_reset(tx_00); + return -0x37; + } + fmt = "Zero-length SDU not allowed\r\n"; + } + printf(fmt); + return -0x16; +} + + + +int bt_mesh_ctl_send(bt_mesh_net_tx_conflict7 *tx,u8_t ctl_op,void *data,size_t data_len, + u64_t *seq_auth,bt_mesh_send_cb *cb,void *cb_data) + +{ + net_buf_simple *buf; + _Bool _Var1; + net_buf *buf_00; + int iVar2; + undefined3 extraout_var; + + buf_00 = bt_mesh_adv_create(BT_MESH_ADV_DATA,tx->xmit,0); + if (buf_00 == (net_buf *)0x0) { + printf("Out of transport buffers\r\n"); + iVar2 = -0x37; + } + else { + buf = (net_buf_simple *)&buf_00->field_4; + net_buf_simple_reserve(buf,9); + net_buf_simple_add_u8(buf,ctl_op & 0x7f); + net_buf_simple_add_mem(buf,data,data_len); + _Var1 = bt_mesh_friend_enqueue_tx + ((bt_mesh_net_tx_conflict9 *)tx,BT_MESH_FRIEND_PDU_SINGLE,seq_auth,'\x01',buf) + ; + if ((CONCAT31(extraout_var,_Var1) == 0) || ((short)tx->ctx->addr < 1)) { + iVar2 = bt_mesh_net_send((bt_mesh_net_tx_conflict4 *)tx,buf_00,cb,cb_data); + return iVar2; + } + net_buf_unref(buf_00); + iVar2 = 0; + } + return iVar2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int send_ack(bt_mesh_subnet *sub,u16_t src,u16_t dst,u8_t ttl,u64_t *seq_auth,u32_t_conflict block, + u8_t obo) + +{ + u8_t uVar1; + u16_t uVar2; + char *fmt; + int iVar3; + undefined3 in_register_00002041; + uint uVar4; + ushort uStack76; + undefined uStack74; + undefined uStack73; + u8_t buf [6]; + bt_mesh_net_tx_conflict7 tx; + bt_mesh_msg_ctx ctx; + + memset(&ctx.app_idx,0,0x12); + tx.src = sub->net_idx; + tx._10_2_ = 0xffff; + tx.sub = (bt_mesh_subnet *)&tx.src; + tx.ctx = (bt_mesh_msg_ctx *)0x0; + tx.ctx._2_2_ = 0; + uVar2 = src; + unique0x10000063 = sub; + ctx.net_idx = dst; + ctx.recv_dst._1_1_ = ttl; + if (CONCAT31(in_register_00002041,obo) != 0) { + uVar2 = bt_mesh_primary_addr(); + } + tx.ctx = (bt_mesh_msg_ctx *)CONCAT22(tx.ctx._2_2_,uVar2); + uVar1 = bt_mesh_net_transmit_get(); + tx.ctx._0_3_ = CONCAT12(uVar1,tx.ctx._0_2_); + tx.ctx = (bt_mesh_msg_ctx *)((uint)tx.ctx & 0xff000000 | (uint)(uint3)tx.ctx); + if ((bt_mesh.lpn._12_4_ >> 4 & 1) == 0) { + if (0 < (short)src) { + uVar4 = ((uint)*(ushort *)seq_auth << 0x13) >> 0x11 | + CONCAT31(in_register_00002041,obo) << 0xf; + uStack76 = (ushort)(uVar4 << 8) | (ushort)(uVar4 >> 8) & 0xff; + uStack73 = (undefined)(block >> 0x10); + buf._0_2_ = (ushort)(block >> 8) & 0xff | (ushort)(block << 8); + uStack74 = (undefined)(block >> 0x18); + iVar3 = bt_mesh_ctl_send((bt_mesh_net_tx_conflict7 *)(buf + 4),'\0',&uStack76,6,(u64_t *)0x0, + (bt_mesh_send_cb *)0x0,(void *)0x0); + return iVar3; + } + fmt = "Not sending ack for non-unicast address\r\n"; + } + else { + fmt = "Not sending ack when LPN is enabled\r\n"; + } + printf(fmt); + return 0; +} + + + +void seg_ack(k_work *work) + +{ + u32_t_conflict uVar1; + uint32_t delay; + + uVar1 = k_uptime_get_32(); + if (60000 < uVar1 - work[-1].flags[0]) { + printf("Incomplete timer expired\r\n"); + seg_rx_reset((seg_rx_conflict1 *)&work[-3].handler,false); + return; + } + send_ack((bt_mesh_subnet *)work[-3].handler,*(u16_t *)((int)&work[-1]._reserved + 2), + *(u16_t *)&work[-1]._reserved,*(u8_t *)((int)work[-2].flags + 2),(u64_t *)(work + -2), + (u32_t_conflict)work[-1].handler,(byte)((uint)work[-2].flags[0] >> 7) & 1); + delay = ack_timeout((seg_rx_conflict1 *)&work[-3].handler); + k_delayed_work_submit((k_delayed_work *)work,delay); + return; +} + + + +int bt_mesh_trans_recv(net_buf_simple *param_1,bt_mesh_net_rx_conflict8 *param_2) + +{ + ushort uVar1; + seg_rx_conflict *rx; + k_delayed_work *work; + _Bool _Var2; + byte bVar3; + u8_t hdr; + u16_t uVar4; + size_t sVar5; + undefined3 extraout_var; + undefined3 extraout_var_00; + int iVar6; + undefined3 extraout_var_01; + char *fmt; + u32_t_conflict uVar7; + s32_t sVar8; + uint32_t delay; + undefined3 extraout_var_02; + int iVar9; + u64_t *seq_auth; + u8_t *puVar10; + uint uVar11; + uint uVar12; + uint uVar13; + bt_mesh_friend_pdu_type type; + uint uVar14; + seg_rx_conflict *rx_00; + uint uVar15; + uint uVar16; + u8_t *puVar17; + u8_t seg_count; + DItype DVar18; + bt_mesh_rpl *pbStack76; + uint uStack72; + uint uStack68; + + uStack68 = 0xffffffff; + uStack72 = 0xffffffff; + _Var2 = bt_mesh_friend_match(param_2->sub->net_idx,(param_2->ctx).recv_dst); + *(byte *)¶m_2->field_0x20 = *(byte *)¶m_2->field_0x20 & 0x7f | _Var2 << 7; + net_buf_simple_pull(param_1,9); + if ((((bt_mesh.lpn._12_4_ >> 4 & 1) != 0) && ((*(byte *)¶m_2->field_0x20 & 0x30) == 0)) && + ((bt_mesh.lpn.state != WPA_WPA2_IN_USE || ((*(byte *)¶m_2->field_0x20 & 4) == 0)))) { + printf("Ignoring unexpected message in Low Power mode\r\n"); + return 0xfffffff5; + } + sVar5 = net_buf_simple_headroom(param_1); + puVar17 = param_1->data; + uVar1 = param_1->len; + if ((char)*puVar17 < '\0') { + if ((*(uint *)¶m_2->field_0x20 & 0xc0) == 0) { + return 0; + } + pbStack76 = (bt_mesh_rpl *)0x0; + if (uVar1 < 5) { + printf("Too short segmented message (len %u)\r\n"); +LAB_23046c88: + seg_count = '\0'; + goto LAB_23046c8a; + } + _Var2 = is_replay(param_2,&pbStack76); + if (CONCAT31(extraout_var,_Var2) != 0) { + printf("Replay: src 0x%04x dst 0x%04x seq 0x%06x\r\n",(uint)(param_2->ctx).recv_dst, + param_2->seq); + goto LAB_23046c88; + } + net_buf_simple_pull(param_1,1); + uVar4 = net_buf_simple_pull_be16(param_1); + bVar3 = net_buf_simple_pull_u8(param_1); + uVar15 = ((uint)uVar4 & 3) << 3; + uVar12 = CONCAT31(extraout_var_00,bVar3) >> 5; + uVar14 = (uint)bVar3 & 0x1f; + uVar16 = uVar15 | uVar12 & 0xff; + if (uVar14 < uVar16) { + printf("SegO greater than SegN (%u > %u)\r\n",uVar14); + goto LAB_23046c88; + } + uVar13 = bt_mesh.iv_index - (*(uint *)¶m_2->field_0x20 & 1); + uStack68 = uVar13 >> 8; + uStack72 = uVar13 * 0x1000000 | + param_2->seq - (param_2->seq - (((uint)uVar4 & 0x7ffc) >> 2) & 0x1fff); + iVar9 = *(int *)&(param_2->ctx).addr; + seg_count = (u8_t)(uVar14 + 1); + rx = seg_rx; + if (iVar9 != seg_rx[0]._20_4_) { +LAB_23046d62: + if (seg_rx[1]._20_4_ == iVar9) { + if ((uStack68 <= seg_rx[1].seq_auth._4_4_) && + ((uStack68 != seg_rx[1].seq_auth._4_4_ || (uStack72 <= (uint)seg_rx[1].seq_auth)))) { + iVar9 = 1; + rx = seg_rx + 1; + uVar13 = (uint)seg_rx[1].seq_auth; + uVar11 = seg_rx[1].seq_auth._4_4_; + goto LAB_23047228; + } + rx_00 = seg_rx + 1; + if ((seg_rx[1]._16_1_ & 0x40) != 0) goto LAB_23046dd8; + } +LAB_23046d86: + iVar9 = 8; + if ((*(uint *)¶m_2->field_0x20 >> 3 & 1) == 0) { + iVar9 = 0xc; + } + if (0x6b < iVar9 * uVar14) { + printf("Too big incoming SDU length\r\n"); + send_ack(param_2->sub,(param_2->ctx).recv_dst,(param_2->ctx).addr,(param_2->ctx).send_ttl, + (u64_t *)&uStack72,0,(byte)(*(uint *)¶m_2->field_0x20 >> 7) & 1); +LAB_23046dce: + type = BT_MESH_FRIEND_PDU_SINGLE; + iVar9 = -0x24; + goto LAB_23046e9a; + } + if (((*(uint *)¶m_2->field_0x20 & 0xc0) == 0x80) && + (_Var2 = bt_mesh_friend_queue_has_space + (param_2->sub->net_idx,(param_2->ctx).addr,(param_2->ctx).recv_dst, + (u64_t *)&uStack72,seg_count), CONCAT31(extraout_var_01,_Var2) == 0)) { + printf("No space in Friend Queue for %u segments\r\n",uVar14 + 1); + send_ack(param_2->sub,(param_2->ctx).recv_dst,(param_2->ctx).addr,(param_2->ctx).send_ttl, + (u64_t *)&uStack72,0,(byte)(*(uint *)¶m_2->field_0x20 >> 7) & 1); + type = BT_MESH_FRIEND_PDU_SINGLE; + iVar9 = -0x37; + goto LAB_23046e9a; + } + if ((seg_rx[0]._16_1_ & 0x40) == 0) { + iVar9 = 0; + } + else { + if ((seg_rx[1]._16_1_ & 0x40) != 0) { + printf("No free slots for new incoming segmented messages\r\n"); + type = BT_MESH_FRIEND_PDU_SINGLE; + iVar9 = -0xc; + goto LAB_23046e9a; + } + rx = seg_rx + 1; + iVar9 = 1; + } + bVar3 = *(byte *)&seg_rx[iVar9].field_0x10; + puVar10 = seg_rx[iVar9].buf.__buf; + seg_rx[iVar9].buf.len = 0; + *(byte *)&seg_rx[iVar9].field_0x10 = bVar3 | 0x40; + seg_rx[iVar9].buf.data = puVar10; + seg_rx[iVar9].sub = param_2->sub; + uVar13 = *(uint *)¶m_2->field_0x20; + *(uint *)((int)&seg_rx[iVar9].seq_auth + 4) = uStack68; + *(uint *)&seg_rx[iVar9].seq_auth = uStack72; + *(byte *)&seg_rx[iVar9].field_0x10 = + bVar3 & 0xc0 | 0x40 | (byte)((uVar13 & 8) << 2) | (byte)uVar14; + seg_rx[iVar9].hdr = *puVar17; + seg_rx[iVar9].ttl = (param_2->ctx).send_ttl; + seg_rx[iVar9].src = (param_2->ctx).addr; + uVar4 = (param_2->ctx).recv_dst; + seg_rx[iVar9].block = 0; + seg_rx[iVar9].dst = uVar4; + *(byte *)&rx->field_0x10 = + *(byte *)&rx->field_0x10 & 0x7f | (byte)*(undefined4 *)¶m_2->field_0x20 & 0x80; +found_rx: + if ((((seg_rx_conflict1 *)rx)->block >> (uVar15 | uVar12 & 0x1f) & 1) != 0) { + printf("Received already received fragment\r\n"); + type = BT_MESH_FRIEND_PDU_SINGLE; + iVar9 = -0x45; + goto LAB_23046e9a; + } + uVar13 = *(uint *)&((seg_rx_conflict1 *)rx)->field_0x10 >> 5 & 1; + if (uVar16 == uVar14) { + iVar9 = 8; + if (uVar13 == 0) { + iVar9 = 0xc; + } + uVar14 = (uint)param_1->len + uVar16 * iVar9; + (((seg_rx_conflict1 *)rx)->buf).len = (u16_t)(uVar14 * 0x10000 >> 0x10); + if (0x6c < (uVar14 & 0xffff)) { + printf("Too large SDU len\r\n"); + send_ack(param_2->sub,(param_2->ctx).recv_dst,(param_2->ctx).addr,(param_2->ctx).send_ttl, + (u64_t *)&uStack72,0, + (byte)(*(uint *)&((seg_rx_conflict1 *)rx)->field_0x10 >> 7) & 1); + seg_rx_reset((seg_rx_conflict1 *)rx,true); + goto LAB_23046dce; + } + } + else { + uVar14 = 8; + if (uVar13 == 0) { + uVar14 = 0xc; + } + if (uVar14 != (uint)param_1->len) { + fmt = "Incorrect segment size for message type\r\n"; + goto LAB_2304723c; + } + } + uVar7 = k_uptime_get_32(); + work = &((seg_rx_conflict1 *)rx)->ack; + ((seg_rx_conflict1 *)rx)->last = uVar7; + sVar8 = k_delayed_work_remaining_get(work); + if ((sVar8 == 0) && ((bt_mesh.lpn._12_4_ >> 4 & 1) == 0)) { + delay = ack_timeout((seg_rx_conflict1 *)rx); + k_delayed_work_submit(work,delay); + } + iVar9 = 8; + if ((*(uint *)&((seg_rx_conflict1 *)rx)->field_0x10 >> 5 & 1) == 0) { + iVar9 = 0xc; + } + memcpy((((seg_rx_conflict1 *)rx)->buf).data + iVar9 * uVar16,param_1->data,(uint)param_1->len) + ; + iVar9 = 1; + uVar12 = 1 << (uVar15 | uVar12 & 0x1f) | ((seg_rx_conflict1 *)rx)->block; + ((seg_rx_conflict1 *)rx)->block = uVar12; + __ashldi3(1); + if (uVar12 == iVar9 - 1U) { + if (pbStack76 != (bt_mesh_rpl *)0x0) { + pbStack76->src = (param_2->ctx).addr; + pbStack76->seq = param_2->seq; + pbStack76->old_iv = (byte)*(undefined4 *)¶m_2->field_0x20 & 1; + } + k_delayed_work_cancel(work); + send_ack(param_2->sub,(param_2->ctx).recv_dst,(param_2->ctx).addr,(param_2->ctx).send_ttl, + (u64_t *)&uStack72,((seg_rx_conflict1 *)rx)->block, + (byte)(*(uint *)&((seg_rx_conflict1 *)rx)->field_0x10 >> 7) & 1); + if ((*(byte *)¶m_2->field_0x20 & 8) == 0) { + iVar9 = sdu_recv(param_2,*(uint *)&((seg_rx_conflict1 *)rx)->seq_auth & 0xffffff,*puVar17, + puVar17[1] >> 7,&((seg_rx_conflict1 *)rx)->buf); + } + else { + iVar9 = ctl_recv(param_2,*puVar17,&((seg_rx_conflict1 *)rx)->buf,(u64_t *)&uStack72); + } + seg_rx_reset((seg_rx_conflict1 *)rx,false); + type = BT_MESH_FRIEND_PDU_COMPLETE; + goto LAB_23046e9a; + } + type = BT_MESH_FRIEND_PDU_PARTIAL; + goto LAB_2304719e; + } + if ((seg_rx[0].seq_auth._4_4_ < uStack68) || + ((uStack68 == seg_rx[0].seq_auth._4_4_ && ((uint)seg_rx[0].seq_auth < uStack72)))) { + rx_00 = rx; + if ((seg_rx[0]._16_1_ & 0x40) == 0) goto LAB_23046d62; +LAB_23046dd8: + printf("Duplicate SDU from src 0x%04x\r\n",(uint)(param_2->ctx).addr); + seg_rx_reset((seg_rx_conflict1 *)rx_00,true); + goto LAB_23046d86; + } + iVar9 = 0; + uVar13 = (uint)seg_rx[0].seq_auth; + uVar11 = seg_rx[0].seq_auth._4_4_; +LAB_23047228: + if ((uStack68 < uVar11) || ((uVar11 == uStack68 && (uStack72 < uVar13)))) { + fmt = "Ignoring old SeqAuth\r\n"; +LAB_2304723c: + printf(fmt); + goto LAB_23046c8a; + } + if ((*puVar17 != seg_rx[iVar9].hdr) || ((*(uint *)&seg_rx[iVar9].field_0x10 & 0x1f) != uVar14)) + { + fmt = "Invalid segment for ongoing session\r\n"; + goto LAB_2304723c; + } + if ((*(uint *)&seg_rx[iVar9].field_0x10 >> 5 & 1) != (*(uint *)¶m_2->field_0x20 >> 3 & 1)) { + fmt = "Inconsistent CTL in segment\r\n"; + goto LAB_2304723c; + } + type = *(bt_mesh_friend_pdu_type *)&seg_rx[iVar9].field_0x10 & 0x40; + if ((*(bt_mesh_friend_pdu_type *)&seg_rx[iVar9].field_0x10 & 0x40) != BT_MESH_FRIEND_PDU_SINGLE) + goto found_rx; + iVar6 = 1; + DVar18 = __ashldi3(1); + if (seg_rx[iVar9].block == iVar6 - 1U) { + printf("Got segment for already complete SDU\r\n",(int)DVar18); + send_ack(param_2->sub,(param_2->ctx).recv_dst,(param_2->ctx).addr,(param_2->ctx).send_ttl, + (u64_t *)&uStack72,seg_rx[iVar9].block, + (byte)(*(uint *)&seg_rx[iVar9].field_0x10 >> 7) & 1); + iVar9 = -0x45; + if (pbStack76 != (bt_mesh_rpl *)0x0) { + pbStack76->src = (param_2->ctx).addr; + pbStack76->seq = param_2->seq; + pbStack76->old_iv = (byte)*(undefined4 *)¶m_2->field_0x20 & 1; + } + goto LAB_23046e9a; + } + printf("Got segment for canceled SDU\r\n",(int)DVar18); + } + else { + if (uVar1 == 0) { + printf("Too small unsegmented PDU\r\n"); + } + else { + _Var2 = is_replay(param_2,(bt_mesh_rpl **)0x0); + if (CONCAT31(extraout_var_02,_Var2) == 0) { + hdr = net_buf_simple_pull_u8(param_1); + type = *(bt_mesh_friend_pdu_type *)¶m_2->field_0x20 & 8; + if ((*(bt_mesh_friend_pdu_type *)¶m_2->field_0x20 & 8) != BT_MESH_FRIEND_PDU_SINGLE) { + iVar9 = ctl_recv(param_2,hdr,param_1,(u64_t *)&uStack72); + seg_count = '\x01'; + type = BT_MESH_FRIEND_PDU_SINGLE; + goto LAB_23046e9a; + } + seg_count = '\x01'; + if ((*(uint *)¶m_2->field_0x20 & 0xc0) != 0) { + iVar9 = sdu_recv(param_2,param_2->seq,hdr,'\0',param_1); + seg_count = '\x01'; + goto LAB_23046e9a; + } +LAB_2304719e: + iVar9 = 0; + goto LAB_23046e9a; + } + printf("Replay: src 0x%04x dst 0x%04x seq 0x%06x\r\n",(uint)(param_2->ctx).recv_dst, + param_2->seq); + } + seg_count = '\x01'; +LAB_23046c8a: + type = BT_MESH_FRIEND_PDU_SINGLE; + } + iVar9 = -0x16; +LAB_23046e9a: + if (((bt_mesh.lpn._12_4_ >> 4 & 1) != 0) && (bt_mesh.lpn.state == WPA_WPA2_IN_USE)) { + bt_mesh_lpn_msg_received((bt_mesh_net_rx_conflict *)param_2); + } + param_1->len = uVar1; + param_1->data = param_1->__buf + (sVar5 & 0xffff); + if ((*(char *)¶m_2->field_0x20 < '\0') && (iVar9 == 0)) { + if ((uStack72 == 0xffffffff) && (uStack68 == 0xffffffff)) { + seq_auth = (u64_t *)0x0; + } + else { + seq_auth = (u64_t *)&uStack72; + } + bt_mesh_friend_enqueue_rx((bt_mesh_net_rx_conflict10 *)param_2,type,seq_auth,seg_count,param_1); + } + return iVar9; +} + + + +void bt_mesh_rx_reset(void) + +{ + seg_rx_reset((seg_rx_conflict1 *)seg_rx,true); + seg_rx_reset((seg_rx_conflict1 *)(seg_rx + 1),true); + memset(bt_mesh.rpl,0,0x28); + return; +} + + + +void bt_mesh_tx_reset(void) + +{ + seg_tx_reset((seg_tx_conflict1 *)seg_tx); + seg_tx_reset((seg_tx_conflict1 *)(seg_tx + 1)); + return; +} + + + +void bt_mesh_trans_init(void) + +{ + k_delayed_work_init(&seg_tx[0].retransmit,seg_retransmit); + k_delayed_work_init(&seg_tx[1].retransmit,seg_retransmit); + k_delayed_work_init(&seg_rx[0].ack,seg_ack); + seg_rx[0].buf.__buf = seg_rx_buf_data; + seg_rx[0].buf.data = seg_rx_buf_data; + k_delayed_work_init(&seg_rx[1].ack,seg_ack); + seg_rx[1].buf.data = (u8_t *)((int)seg_rx_buf_data + 0x6c); + seg_rx[1].buf.__buf = (u8_t *)((int)seg_rx_buf_data + 0x6c); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void bt_mesh_heartbeat_send(void) + +{ + u8_t uVar1; + bt_mesh_cfg_srv *pbVar2; + bt_mesh_elem *pbVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + u8_t uStack56; + undefined uStack55; + bool bStack54; + anon_struct_for_hb hb; + bt_mesh_net_tx_conflict7 tx; + bt_mesh_msg_ctx ctx; + + pbVar2 = bt_mesh_cfg_get(); + memset(&ctx.app_idx,0,0x12); + tx._10_2_ = 0xffff; + ctx.net_idx = (pbVar2->hb_pub).dst; + tx.src = (pbVar2->hb_pub).net_idx; + _hb = (bt_mesh_subnet *)0x0; + ctx.recv_dst._1_1_ = (pbVar2->hb_pub).ttl; + tx.sub = (bt_mesh_subnet *)0x0; + tx.ctx = (bt_mesh_msg_ctx *)0x0; + _hb = bt_mesh_subnet_get(tx.src); + tx.sub = (bt_mesh_subnet *)&tx.src; + pbVar3 = bt_mesh_model_elem(pbVar2->model); + tx.ctx = (bt_mesh_msg_ctx *)((uint)tx.ctx & 0xffff0000 | (uint)pbVar3->addr); + uVar1 = bt_mesh_net_transmit_get(); + tx.ctx._0_3_ = CONCAT12(uVar1,(u16_t)tx.ctx); + tx.ctx = (bt_mesh_msg_ctx *)((uint)tx.ctx & 0xff000000 | (uint)(uint3)tx.ctx); + if ((pbVar2->hb_pub).dst != 0) { + uStack56 = (pbVar2->hb_pub).ttl; + uVar1 = bt_mesh_relay_get(); + bStack54 = CONCAT31(extraout_var,uVar1) == 1; + uVar1 = bt_mesh_gatt_proxy_get(); + if (CONCAT31(extraout_var_00,uVar1) == 1) { + bStack54 = (bool)(bStack54 | 2); + } + uVar1 = bt_mesh_friend_get(); + if (CONCAT31(extraout_var_01,uVar1) == 1) { + bStack54 = (bool)(bStack54 | 4); + } + if ((bt_mesh.lpn._12_4_ >> 4 & 1) != 0) { + bStack54 = (bool)(bStack54 | 8); + } + uStack55 = 0; + bt_mesh_ctl_send((bt_mesh_net_tx_conflict7 *)&hb,'\n',&uStack56,3,(u64_t *)0x0, + (bt_mesh_send_cb *)0x0,(void *)0x0); + } + return; +} + + + +bt_mesh_adv_conflict7 * adv_alloc(int id) + +{ + return (bt_mesh_adv_conflict7 *)(adv_pool + id); +} + + + +void friend_purge_old_ack(int param_1,int *param_2,uint param_3) + +{ + net_buf *pnVar1; + net_buf *pnVar2; + net_buf *pnVar3; + net_buf *buf; + int iVar4; + + pnVar1 = (net_buf *)0x0; + pnVar2 = *(net_buf **)(param_1 + 0x4c); + do { + buf = pnVar2; + pnVar3 = pnVar1; + if (buf == (net_buf *)0x0) { + return; + } + iVar4 = *(int *)buf->user_data; + pnVar2 = (net_buf *)buf->field_0; + pnVar1 = buf; + } while ((((uint)*(ushort *)(iVar4 + 10) != param_3) || (*(int *)(iVar4 + 0x10) != *param_2)) || + (*(int *)(iVar4 + 0x14) != param_2[1])); + if (pnVar3 == (net_buf *)0x0) { + *(net_buf **)(param_1 + 0x4c) = pnVar2; + if (buf == *(net_buf **)(param_1 + 0x50)) { + *(net_buf **)(param_1 + 0x50) = pnVar2; + } + } + else { + *(net_buf **)&pnVar3->field_0 = pnVar2; + if (buf == *(net_buf **)(param_1 + 0x50)) { + *(net_buf **)(param_1 + 0x50) = pnVar3; + } + } + buf->field_0 = 0; + *(int *)(param_1 + 0x54) = *(int *)(param_1 + 0x54) + -1; + buf->field_0 = 0; + net_buf_unref(buf); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void send_friend_clear(bt_mesh_friend_conflict45 *frnd) + +{ + u8_t uVar1; + u16_t uVar2; + ushort uStack56; + ushort uStack54; + bt_mesh_ctl_friend_clear req; + bt_mesh_net_tx_conflict9 tx; + bt_mesh_msg_ctx ctx; + + memset(&ctx.app_idx,0,0x12); + tx.src = frnd->net_idx; + tx.ctx = (bt_mesh_msg_ctx *)0x0; + tx._10_2_ = 0xffff; + ctx.net_idx = (frnd->clear).frnd; + ctx.recv_dst._1_1_ = 0x7f; + req = bt_mesh.sub; + tx.sub = (bt_mesh_subnet *)&tx.src; + uVar2 = bt_mesh_primary_addr(); + tx.ctx = (bt_mesh_msg_ctx *)((uint)tx.ctx & 0xffff0000 | (uint)uVar2); + uVar1 = bt_mesh_net_transmit_get(); + tx.ctx._0_3_ = CONCAT12(uVar1,(u16_t)tx.ctx); + tx.ctx = (bt_mesh_msg_ctx *)((uint)tx.ctx & 0xff000000 | (uint)(uint3)tx.ctx); + uStack56 = frnd->lpn << 8 | frnd->lpn >> 8; + uStack54 = frnd->lpn_counter << 8 | frnd->lpn_counter >> 8; + bt_mesh_ctl_send((bt_mesh_net_tx_conflict7 *)&req,'\x05',&uStack56,4,(u64_t *)0x0,&clear_sent_cb, + frnd); + return; +} + + + +void friend_clear_sent(int err,void *user_data) + +{ + k_delayed_work_submit + ((k_delayed_work *)((int)user_data + 0x60), + (uint)*(ushort *)((int)user_data + 0x5e) * 1000); + *(short *)((int)user_data + 0x5e) = *(short *)((int)user_data + 0x5e) << 1; + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +net_buf * create_friend_pdu(bt_mesh_friend_conflict45 *frnd,friend_pdu_info_conflict *info, + net_buf_simple *sdu) + +{ + bt_mesh_subnet *sub; + net_buf *buf; + uint uVar1; + char *fmt; + byte val; + int iVar2; + net_buf_simple *buf_00; + byte bStack41; + u8_t nid; + u8_t *puStack40; + u8_t *enc; + u8_t *priv; + + sub = bt_mesh_subnet_get(frnd->net_idx); + buf = bt_mesh_adv_create_from_pool(&friend_buf_pool,adv_alloc,BT_MESH_ADV_DATA,'\b',0); + if (buf == (net_buf *)0x0) { + return (net_buf *)0x0; + } + *(u16_t *)(*(int *)buf->user_data + 10) = info->src; + iVar2 = *(int *)buf->user_data; + *(undefined4 *)(iVar2 + 0x10) = 0xffffffff; + *(undefined4 *)(iVar2 + 0x14) = 0xffffffff; + if ((*(char *)&info->field_0x7 < '\0') && ((*sdu->data & 0x7f) == 4)) { + uVar1 = (uint)sub->kr_flag; + puStack40 = sub->keys[uVar1].enc; + enc = sub->keys[uVar1].privacy; + bStack41 = sub->keys[uVar1].nid; + } + else { + iVar2 = friend_cred_get(sub,frnd->lpn,&bStack41,(u8_t **)&stack0xffffffd8,&enc); + if (iVar2 != 0) { + fmt = "friend_cred_get failed\r\n"; + goto failed; + } + } + buf_00 = (net_buf_simple *)&buf->field_4; + net_buf_simple_add_u8(buf_00,(byte)(info->iv_index << 7) | bStack41); + val = (byte)((uint)*(undefined4 *)info->seq >> 0x18); + if (*(char *)&info->field_0x7 < '\0') { + val = val | 0x80; + } + else { + val = val & 0x7f; + } + net_buf_simple_add_u8(buf_00,val); + net_buf_simple_add_mem(buf_00,info->seq,3); + net_buf_simple_add_be16(buf_00,info->src); + net_buf_simple_add_be16(buf_00,info->dst); + net_buf_simple_add_mem(buf_00,sdu->data,(uint)sdu->len); + iVar2 = bt_mesh_net_encrypt(puStack40,buf_00,info->iv_index,false); + if (iVar2 == 0) { + iVar2 = bt_mesh_net_obfuscate(*(u8_t **)&buf->field_4,info->iv_index,enc); + if (iVar2 == 0) { + return buf; + } + fmt = "Re-obfuscating failed\r\n"; + } + else { + fmt = "Re-encrypting failed\r\n"; + } +failed: + printf(fmt); + net_buf_unref(buf); + return (net_buf *)0x0; +} + + + +void clear_timeout(k_work *work) + +{ + u32_t_conflict uVar1; + + uVar1 = k_uptime_get_32(); + if ((uint)((int)work[-8].handler << 1) < uVar1 - (int)work[-1].handler) { + *(undefined2 *)work[-1].flags = 0; + return; + } + send_friend_clear((bt_mesh_friend_conflict45 *)(work + -8)); + return; +} + + + +_Bool friend_lpn_matches(bt_mesh_friend_conflict45 *frnd,u16_t net_idx,u16_t addr) + +{ + ushort uVar1; + undefined uVar2; + undefined2 in_register_0000202e; + undefined2 in_register_00002032; + uint uVar3; + bool bVar4; + + uVar3 = CONCAT22(in_register_00002032,addr); + if ((*(byte *)&frnd->field_0x3 & 0x40) == 0) { + uVar2 = 0; + } + else { + uVar2 = 0; + if ((uint)frnd->net_idx == CONCAT22(in_register_0000202e,net_idx)) { + if ((short)addr < 1) { + uVar2 = 1; + if (((uint)frnd->sub_list[0] != uVar3) && ((uint)frnd->sub_list[1] != uVar3)) { + return (_Bool)((uint)frnd->sub_list[2] == uVar3); + } + } + else { + uVar1 = frnd->lpn; + if (uVar1 != 0) { + bVar4 = false; + if ((uint)uVar1 <= uVar3) { + bVar4 = (int)uVar3 < (int)((uint)frnd->num_elem + (uint)uVar1); + } + return (_Bool)bVar4; + } + } + } + } + return (_Bool)uVar2; +} + + + +_Bool friend_queue_has_space + (bt_mesh_friend_conflict45 *frnd,u16_t addr,u64_t *seq_auth,u8_t seg_count) + +{ + undefined2 in_register_0000202e; + undefined3 in_register_00002035; + sys_snode_t *psVar1; + _snode *p_Var2; + + if ((((seq_auth != (u64_t *)0x0) && + (psVar1 = frnd->seg[0].queue.head, psVar1 != (sys_snode_t *)0x0)) && + (p_Var2 = psVar1[5].next, + (uint)*(ushort *)((int)&p_Var2[2].next + 2) == CONCAT22(in_register_0000202e,addr))) && + ((p_Var2[4].next == *(_snode **)seq_auth && (p_Var2[5].next == *(_snode **)((int)seq_auth + 4)) + ))) { + return true; + } + return (_Bool)(CONCAT31(in_register_00002035,seg_count) < 0x10 - (uint)frnd->seg[0].seg_count); +} + + + +void buf_send_start(u16_t duration,int err,void *user_data) + +{ + byte bVar1; + + bVar1 = *(byte *)((int)user_data + 3); + *(byte *)((int)user_data + 3) = bVar1 & 0xef; + if ((bVar1 & 0x40) == 0) { + net_buf_unref(*(net_buf **)((int)user_data + 0x48)); + *(undefined4 *)((int)user_data + 0x48) = 0; + return; + } + return; +} + + + +void buf_send_end(int err,void *user_data) + +{ + uint32_t delay; + + if ((*(byte *)((int)user_data + 3) & 4) != 0) { + printf("Another request before previous completed sending\r\n"); + return; + } + if ((*(byte *)((int)user_data + 3) & 0x40) == 0) { + delay = 1000; + } + else { + delay = *(uint32_t *)((int)user_data + 4); + } + k_delayed_work_submit((k_delayed_work *)((int)user_data + 0x18),delay); + return; +} + + + +void purge_buffers(sys_slist_t *list) + +{ + net_buf *buf; + sys_snode_t *psVar1; + + while (buf = (net_buf *)list->head, buf != (net_buf *)0x0) { + psVar1 = (sys_snode_t *)buf->field_0; + list->head = psVar1; + if (buf == (net_buf *)list->tail) { + list->tail = psVar1; + } + buf->field_0 = 0; + buf->flags = buf->flags & 0xfe; + net_buf_unref(buf); + } + return; +} + + + +void friend_clear(bt_mesh_friend_conflict45 *frnd) + +{ + byte bVar1; + int iVar2; + + k_delayed_work_cancel(&frnd->timer); + friend_cred_del(frnd->net_idx,frnd->lpn); + if (frnd->last != (net_buf *)0x0) { + if ((*(byte *)&frnd->field_0x3 & 0x10) != 0) { + iVar2 = *(int *)frnd->last->user_data; + *(byte *)(iVar2 + 8) = *(byte *)(iVar2 + 8) & 0xfb; + } + net_buf_unref(frnd->last); + frnd->last = (net_buf *)0x0; + } + purge_buffers(&frnd->queue); + purge_buffers((sys_slist_t *)frnd->seg); + bVar1 = *(byte *)&frnd->field_0x3; + frnd->seg[0].seg_count = '\0'; + frnd->queue_size = 0; + *(byte *)&frnd->field_0x3 = bVar1 & 0x8a; + memset(frnd->sub_list,0,6); + return; +} + + + +void friend_timeout(k_work *work) + +{ + byte bVar1; + ushort uVar2; + bt_mesh_send_cb buf_sent_cb; + char *fmt; + k_work_handler_t *pkVar3; + k_work_handler_t **ppkVar4; + + bVar1 = *(byte *)((int)&work[-2]._reserved + 3); + if (((bVar1 & 2) != 0) && (work[4]._reserved != (void *)0x0)) { + *(byte *)((int)&work[-2]._reserved + 3) = bVar1 & 0xfd; +send_last: + *(byte *)((int)&work[-2]._reserved + 3) = *(byte *)((int)&work[-2]._reserved + 3) & 0xfb | 0x10; + bt_mesh_adv_send((net_buf *)work[4]._reserved,(bt_mesh_send_cb *)&ram0x230cba28, + (bt_mesh_friend_conflict45 *)(work + -2)); + return; + } + if (((uint)work[-2]._reserved & 0x44000000) == 0x40000000) { + uVar2 = *(ushort *)&work[-2]._reserved; + fmt = "Friendship lost with 0x%04x\r\n"; + } + else { + ppkVar4 = (k_work_handler_t **)work[4].handler; + if (ppkVar4 != (k_work_handler_t **)0x0) { + pkVar3 = *ppkVar4; + work[4].handler = pkVar3; + if (ppkVar4 == (k_work_handler_t **)work[4].flags[0]) { + *(k_work_handler_t **)work[4].flags = pkVar3; + } + *(k_work_handler_t ***)&work[4]._reserved = ppkVar4; + *(byte *)((int)ppkVar4 + 5) = (byte)*(k_work_handler_t *)((int)ppkVar4 + 5) & 0xfe; + *(undefined4 *)work[4]._reserved = 0; + work[5]._reserved = (void *)((int)work[5]._reserved + -1); + goto send_last; + } + work[4]._reserved = (void *)0x0; + uVar2 = *(ushort *)&work[-2]._reserved; + fmt = "Friendship not established with 0x%04x\r\n"; + } + printf(fmt,(uint)uVar2); + friend_clear((bt_mesh_friend_conflict45 *)(work + -2)); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +net_buf * encode_friend_ctl(bt_mesh_friend_conflict45 *frnd,u8_t ctl_op,net_buf_simple *sdu) + +{ + u32_t_conflict uVar1; + atomic_val_t aVar2; + net_buf *pnVar3; + u16_t uStack28; + u16_t uStack26; + friend_pdu_info_conflict info; + + net_buf_simple_push_u8(sdu,ctl_op); + uStack28 = bt_mesh_primary_addr(); + uStack26 = frnd->lpn; + info.dst._1_1_ = 0x80; + uVar1 = bt_mesh_next_seq(); + info._4_4_ = bt_mesh.iv_index; + info.src._0_1_ = (u8_t)(uVar1 >> 0x10); + info.dst._0_1_ = (u8_t)uVar1; + info.src._1_1_ = (u8_t)(uVar1 >> 8); + aVar2 = atomic_get(bt_mesh.flags); + info._4_4_ = info._4_4_ - (aVar2 >> 2 & 1U); + pnVar3 = create_friend_pdu(frnd,(friend_pdu_info_conflict *)&uStack28,sdu); + return pnVar3; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void enqueue_sub_cfm(bt_mesh_friend_conflict45 *frnd,u8_t xact) + +{ + u8_t *puVar1; + net_buf *pnVar2; + u8_t auStack32 [4]; + u8_t net_buf_data_sdu [2]; + net_buf_simple sdu; + + _net_buf_data_sdu = auStack32; + net_buf_simple_reserve((net_buf_simple *)net_buf_data_sdu,1); + puVar1 = (u8_t *)net_buf_simple_add((net_buf_simple *)net_buf_data_sdu,1); + *puVar1 = xact; + pnVar2 = encode_friend_ctl(frnd,'\t',(net_buf_simple *)net_buf_data_sdu); + if (pnVar2 == (net_buf *)0x0) { + printf("Unable to encode Subscription List Confirmation\r\n"); + } + else { + if (frnd->last != (net_buf *)0x0) { + net_buf_unref(frnd->last); + } + frnd->last = pnVar2; + *(byte *)&frnd->field_0x3 = *(byte *)&frnd->field_0x3 | 2; + } + return; +} + + + +_Bool friend_queue_prepare_space + (bt_mesh_friend_conflict45 *frnd,u16_t addr,u64_t *seq_auth,u8_t seg_count) + +{ + uint uVar1; + _Bool _Var2; + undefined3 extraout_var; + net_buf *buf; + undefined3 in_register_00002035; + sys_snode_t *psVar3; + byte bVar4; + + if (CONCAT31(in_register_00002035,seg_count) < 0x11) { + _Var2 = friend_queue_has_space(frnd,addr,seq_auth,seg_count); + if (CONCAT31(extraout_var,_Var2) == 0) { + return _Var2; + } + bVar4 = 0; + uVar1 = 0x10 - frnd->queue_size; + while( true ) { + if ((bVar4 == 0) && (CONCAT31(in_register_00002035,seg_count) <= (uVar1 & 0xff))) { + return _Var2; + } + buf = (net_buf *)(frnd->queue).head; + if (buf == (net_buf *)0x0) break; + psVar3 = (sys_snode_t *)buf->field_0; + (frnd->queue).head = psVar3; + if (buf == (net_buf *)(frnd->queue).tail) { + (frnd->queue).tail = psVar3; + } + uVar1 = (uVar1 & 0xff) + 1; + frnd->queue_size = frnd->queue_size - 1; + buf->field_0 = 0; + bVar4 = buf->flags & 1; + buf->flags = buf->flags & 0xfe; + net_buf_unref(buf); + } + printf("Unable to free up enough buffers\r\n"); + } + return false; +} + + + +void enqueue_update(bt_mesh_friend_conflict45 *frnd,u8_t md) + +{ + uint uVar1; + uint uVar2; + u32_t_conflict uVar3; + u8_t uVar4; + bt_mesh_subnet *sub; + u8_t *puVar5; + net_buf *buf; + u8_t auStack52 [4]; + u8_t net_buf_data_sdu [7]; + net_buf_simple sdu; + + register0x0000203c = auStack52; + sub = bt_mesh_subnet_get(frnd->net_idx); + net_buf_simple_reserve((net_buf_simple *)(net_buf_data_sdu + 4),1); + puVar5 = (u8_t *)net_buf_simple_add((net_buf_simple *)(net_buf_data_sdu + 4),6); + uVar4 = bt_mesh_net_flags(sub); + *puVar5 = uVar4; + uVar3 = bt_mesh.iv_index; + uVar2 = bt_mesh.iv_index >> 0x10; + uVar1 = bt_mesh.iv_index & 0xff00; + puVar5[1] = (u8_t)(bt_mesh.iv_index >> 0x18); + puVar5[2] = (u8_t)uVar2; + puVar5[3] = (u8_t)((uVar1 << 8) >> 0x10); + puVar5[4] = (u8_t)uVar3; + puVar5[5] = md; + buf = encode_friend_ctl(frnd,'\x02',(net_buf_simple *)(net_buf_data_sdu + 4)); + if (buf == (net_buf *)0x0) { + printf("Unable to encode Friend Update\r\n"); + } + else { + *(byte *)&frnd->field_0x3 = *(byte *)&frnd->field_0x3 & 0xf7; + net_buf_slist_put(&frnd->queue,buf); + frnd->queue_size = frnd->queue_size + 1; + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void enqueue_friend_pdu(bt_mesh_friend_conflict45 *frnd,bt_mesh_friend_pdu_type type,u8_t seg_count, + net_buf *buf) + +{ + undefined3 in_register_0000202d; + sys_snode_t *psVar1; + _snode *p_Var2; + int iVar3; + sys_snode_t *psVar4; + sys_snode_t sVar5; + + if (CONCAT31(in_register_0000202d,type) == 0) { + if ((*(byte *)&frnd->field_0x3 & 8) != 0) { + enqueue_update(frnd,'\x01'); + } + net_buf_slist_put(&frnd->queue,buf); + frnd->queue_size = frnd->queue_size + 1; + } + else { + iVar3 = *(int *)buf->user_data; + psVar1 = frnd->seg[0].queue.head; + if (psVar1 == (sys_snode_t *)0x0) { + frnd->seg[0].seg_count = seg_count; + } + else { + p_Var2 = psVar1[5].next; + if (*(short *)((int)&p_Var2[2].next + 2) != *(short *)(iVar3 + 10)) { +LAB_23047bdc: + printf("No free friend segment RX contexts for 0x%04x\r\n"); + net_buf_unref(buf); + return; + } + if (p_Var2[4].next != *(_snode **)(iVar3 + 0x10)) goto LAB_23047bdc; + if (p_Var2[5].next != *(_snode **)(iVar3 + 0x14)) goto LAB_23047bdc; + } + net_buf_slist_put((sys_slist_t *)frnd->seg,buf); + if (CONCAT31(in_register_0000202d,type) == 2) { + if ((*(byte *)&frnd->field_0x3 & 8) != 0) { + enqueue_update(frnd,'\x01'); + } + sVar5 = (sys_snode_t)((sys_snode_t *)&frnd->seg[0].queue.head)->next; + while (sVar5 != (sys_snode_t)0x0) { + iVar3 = *(int *)((int)sVar5 + 0x14); + *(undefined4 *)(iVar3 + 0x10) = 0xffffffff; + *(undefined4 *)(iVar3 + 0x14) = 0xffffffff; + frnd->queue_size = frnd->queue_size + 1; + sVar5 = *(sys_snode_t *)sVar5; + } + psVar1 = (frnd->queue).tail; + p_Var2 = (_snode *)frnd->seg[0].queue.head; + psVar4 = frnd->seg[0].queue.tail; + if (psVar1 == (sys_snode_t *)0x0) { + *(_snode **)&(frnd->queue).head = p_Var2; + } + else { + psVar1->next = p_Var2; + } + (frnd->queue).tail = psVar4; + frnd->seg[0].queue.head = (sys_snode_t *)0x0; + frnd->seg[0].queue.tail = (sys_snode_t *)0x0; + frnd->seg[0].seg_count = '\0'; + } + else { + buf->flags = buf->flags | 1; + } + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +bt_mesh_friend_conflict45 * +bt_mesh_friend_find(u16_t net_idx,u16_t lpn_addr,_Bool valid,_Bool established) + +{ + ushort uVar1; + undefined2 in_register_0000202a; + undefined2 in_register_0000202e; + undefined3 in_register_00002031; + undefined3 in_register_00002035; + int iVar2; + bt_mesh_net_conflict9 *pbVar3; + + pbVar3 = &bt_mesh; + iVar2 = 0; + while ((((CONCAT31(in_register_00002031,valid) != 0 && + ((*(byte *)&bt_mesh.frnd[iVar2].field_0x3 & 0x20) == 0)) || + ((CONCAT31(in_register_00002035,established) != 0 && + ((*(byte *)&bt_mesh.frnd[iVar2].field_0x3 & 0x40) == 0)))) || + ((((CONCAT22(in_register_0000202a,net_idx) != 0xffff && + ((uint)pbVar3->frnd[0].net_idx != CONCAT22(in_register_0000202a,net_idx))) || + (uVar1 = pbVar3->frnd[0].lpn, uVar1 == 0)) || + ((CONCAT22(in_register_0000202e,lpn_addr) < (uint)uVar1 || + ((int)((uint)pbVar3->frnd[0].num_elem + (uint)uVar1) <= + (int)CONCAT22(in_register_0000202e,lpn_addr)))))))) { + pbVar3 = (bt_mesh_net_conflict9 *)&pbVar3->frnd[0].clear.timer.work.handler; + if (iVar2 == 1) { + return (bt_mesh_friend_conflict45 *)0x0; + } + iVar2 = 1; + } + return (bt_mesh_friend_conflict45 *)(bt_mesh.frnd + iVar2); +} + + + +void bt_mesh_friend_clear_net_idx(u16_t net_idx) + +{ + undefined2 in_register_0000202a; + uint uVar1; + + uVar1 = CONCAT22(in_register_0000202a,net_idx); + if ((bt_mesh.frnd[0].net_idx != 0xffff) && + ((uVar1 == 0xffff || (uVar1 == (uint)bt_mesh.frnd[0].net_idx)))) { + friend_clear((bt_mesh_friend_conflict45 *)bt_mesh.frnd); + } + if ((bt_mesh.frnd[1].net_idx != 0xffff) && + ((uVar1 == 0xffff || (uVar1 == (uint)bt_mesh.frnd[1].net_idx)))) { + friend_clear((bt_mesh_friend_conflict45 *)(bt_mesh.frnd + 1)); + return; + } + return; +} + + + +void bt_mesh_friend_sec_update(u16_t net_idx) + +{ + undefined2 in_register_0000202a; + uint uVar1; + + uVar1 = CONCAT22(in_register_0000202a,net_idx); + if ((bt_mesh.frnd[0].net_idx != 0xffff) && + ((uVar1 == 0xffff || (uVar1 == (uint)bt_mesh.frnd[0].net_idx)))) { + bt_mesh.frnd[0]._3_1_ = bt_mesh.frnd[0]._3_1_ | 8; + } + if ((bt_mesh.frnd[1].net_idx != 0xffff) && + ((uVar1 == 0xffff || (uVar1 == (uint)bt_mesh.frnd[1].net_idx)))) { + bt_mesh.frnd[1]._3_1_ = bt_mesh.frnd[1]._3_1_ | 8; + return; + } + return; +} + + + +int bt_mesh_friend_clear(bt_mesh_net_rx_conflict10 *rx,net_buf_simple *buf) + +{ + ushort uVar1; + ushort *puVar2; + uint uVar3; + int iVar4; + bt_mesh_friend_conflict45 *frnd; + uint uVar5; + ushort uStack48; + ushort uStack46; + bt_mesh_ctl_friend_clear_confirm cfm; + bt_mesh_net_tx_conflict9 tx; + + cfm = rx->sub; + puVar2 = (ushort *)buf->data; + bt_mesh_primary_addr(); + bt_mesh_net_transmit_get(); + if (buf->len < 4) { + printf("Too short Friend Clear\r\n"); + iVar4 = -0x16; + } + else { + uVar1 = *puVar2 >> 8; + uVar5 = (uint)*puVar2 << 8; + uVar3 = ((uint)puVar2[1] & 0xff) << 8 | (uint)(puVar2[1] >> 8); + frnd = bt_mesh_friend_find(rx->sub->net_idx,uVar1 | (ushort)uVar5,false,false); + if (frnd == (bt_mesh_friend_conflict45 *)0x0) { + printf("No matching LPN addr 0x%04x\r\n",(uint)uVar1 | uVar5 & 0xffff); + } + else { + if ((int)(uVar3 - frnd->lpn_counter) < 0x100) { + (rx->ctx).send_ttl = '\x7f'; + uStack48 = *puVar2; + uStack46 = puVar2[1]; + bt_mesh_ctl_send((bt_mesh_net_tx_conflict7 *)&cfm,'\x06',&uStack48,4,(u64_t *)0x0, + (bt_mesh_send_cb *)0x0,(void *)0x0); + friend_clear(frnd); + } + else { + printf("LPN Counter out of range (old %u new %u)\r\n",uVar3); + } + } + iVar4 = 0; + } + return iVar4; +} + + + +int bt_mesh_friend_sub_add(bt_mesh_net_rx_conflict10 *rx,net_buf_simple *buf) + +{ + ushort lpn_addr; + u8_t xact; + u16_t uVar1; + int iVar2; + bt_mesh_friend_conflict45 *frnd; + + if (buf->len < 3) { + printf("Too short Friend Subscription Add\r\n"); + iVar2 = -0x16; + } + else { + lpn_addr = (rx->ctx).addr; + frnd = bt_mesh_friend_find(rx->sub->net_idx,lpn_addr,true,true); + if (frnd == (bt_mesh_friend_conflict45 *)0x0) { + printf("No matching LPN addr 0x%04x\r\n",(uint)lpn_addr); + } + else { + if ((*(byte *)&frnd->field_0x3 & 0x10) == 0) { + *(byte *)&frnd->field_0x3 = *(byte *)&frnd->field_0x3 | 4; + k_delayed_work_submit(&frnd->timer,(uint)frnd->recv_delay + 0x33); + xact = net_buf_simple_pull_u8(buf); + while (1 < buf->len) { + uVar1 = net_buf_simple_pull_be16(buf); + if (frnd->sub_list[0] == 0) { + iVar2 = 0; +LAB_23047f1a: + (&frnd->lpn)[iVar2 + 8] = uVar1; + } + else { + if (frnd->sub_list[1] == 0) { + iVar2 = 1; + goto LAB_23047f1a; + } + if (frnd->sub_list[2] == 0) { + iVar2 = 2; + goto LAB_23047f1a; + } + printf("No space in friend subscription list\r\n"); + } + } + enqueue_sub_cfm(frnd,xact); + } + else { + printf("Previous buffer not yet sent!\r\n"); + } + } + iVar2 = 0; + } + return iVar2; +} + + + +int bt_mesh_friend_sub_rem(bt_mesh_net_rx_conflict10 *rx,net_buf_simple *buf) + +{ + ushort lpn_addr; + u8_t xact; + u16_t uVar1; + int iVar2; + bt_mesh_friend_conflict45 *frnd; + undefined2 extraout_var; + + if (buf->len < 3) { + printf("Too short Friend Subscription Remove\r\n"); + iVar2 = -0x16; + } + else { + lpn_addr = (rx->ctx).addr; + frnd = bt_mesh_friend_find(rx->sub->net_idx,lpn_addr,true,true); + if (frnd == (bt_mesh_friend_conflict45 *)0x0) { + printf("No matching LPN addr 0x%04x\r\n",(uint)lpn_addr); + } + else { + if ((*(byte *)&frnd->field_0x3 & 0x10) == 0) { + *(byte *)&frnd->field_0x3 = *(byte *)&frnd->field_0x3 | 4; + k_delayed_work_submit(&frnd->timer,(uint)frnd->recv_delay + 0x33); + xact = net_buf_simple_pull_u8(buf); + while (1 < buf->len) { + uVar1 = net_buf_simple_pull_be16(buf); + _uVar1 = CONCAT22(extraout_var,uVar1); + if ((uint)frnd->sub_list[0] == _uVar1) { + iVar2 = 0; + goto LAB_23047ffe; + } + if ((uint)frnd->sub_list[1] == _uVar1) { + iVar2 = 1; + goto LAB_23047ffe; + } + if ((uint)frnd->sub_list[2] == _uVar1) { + iVar2 = 2; +LAB_23047ffe: + (&frnd->lpn)[iVar2 + 8] = 0; + } + } + enqueue_sub_cfm(frnd,xact); + } + else { + printf("Previous buffer not yet sent!\r\n"); + } + } + iVar2 = 0; + } + return iVar2; +} + + + +int bt_mesh_friend_poll(bt_mesh_net_rx_conflict10 *rx,net_buf_simple *buf) + +{ + ushort lpn_addr; + uint uVar1; + char *fmt; + bt_mesh_friend_conflict45 *frnd; + net_buf *buf_00; + byte *pbVar2; + + pbVar2 = buf->data; + if (buf->len == 0) { + fmt = "Too short Friend Poll\r\n"; + } + else { + lpn_addr = (rx->ctx).addr; + frnd = bt_mesh_friend_find(rx->sub->net_idx,lpn_addr,true,false); + if (frnd == (bt_mesh_friend_conflict45 *)0x0) { + printf("No matching LPN addr 0x%04x\r\n",(uint)lpn_addr); + return 0; + } + uVar1 = (uint)*pbVar2 & 0xfffffffe; + if ((*pbVar2 & 0xfe) == 0) { + if ((*(byte *)&frnd->field_0x3 & 0x10) != 0) { + printf("Previous buffer not yet sent\r\n"); + return uVar1; + } + *(byte *)&frnd->field_0x3 = *(byte *)&frnd->field_0x3 | 4; + k_delayed_work_submit(&frnd->timer,(uint)frnd->recv_delay + 0x33); + if ((*(byte *)&frnd->field_0x3 & 0x40) == 0) { + *(byte *)&frnd->field_0x3 = *(byte *)&frnd->field_0x3 | 0x40; + } + buf_00 = frnd->last; + if (*pbVar2 == (*(byte *)&frnd->field_0x3 & 1)) { + if (buf_00 != (net_buf *)0x0) { + *(byte *)&frnd->field_0x3 = *(byte *)&frnd->field_0x3 | 2; + return uVar1; + } + } + else { + if (buf_00 != (net_buf *)0x0) { + net_buf_unref(buf_00); + frnd->last = (net_buf *)0x0; + } + } + *(byte *)&frnd->field_0x3 = *(byte *)&frnd->field_0x3 & 0xfe | *pbVar2 & 1; + if ((frnd->queue).head != (sys_snode_t *)0x0) { + return uVar1; + } + enqueue_update(frnd,'\0'); + return uVar1; + } + fmt = "Prohibited (non-zero) padding bits\r\n"; + } + printf(fmt); + return -0x16; +} + + + +int bt_mesh_friend_clear_cfm(bt_mesh_net_rx_conflict10 *rx,net_buf_simple *buf) + +{ + int iVar1; + u16_t uVar2; + ushort uVar3; + bt_mesh_friend_conflict31 *pbVar4; + + if (buf->len < 4) { + printf("Too short Friend Clear Confirm\r\n"); + return -0x16; + } + uVar2 = (rx->ctx).addr; + if (bt_mesh.frnd[0].clear.frnd == uVar2) { + pbVar4 = bt_mesh.frnd; + } + else { + if (bt_mesh.frnd[1].clear.frnd != uVar2) { + printf("No pending clear procedure for 0x%02x\r\n"); + return 0; + } + pbVar4 = bt_mesh.frnd + 1; + } + uVar3 = *(ushort *)buf->data; + if ((uint)pbVar4->lpn == (((uint)uVar3 & 0xff) << 8 | (uint)(uVar3 >> 8))) { + uVar3 = *(ushort *)(buf->data + 1); + if ((uint)pbVar4->lpn_counter == (((uint)uVar3 & 0xff) << 8 | (uint)(uVar3 >> 8))) { + k_delayed_work_cancel(&(pbVar4->clear).timer); + (pbVar4->clear).frnd = 0; + return 0; + } + iVar1 = 0x564; + } + else { + iVar1 = 0x538; + } + printf("Too big incoming SDU length\r\n" + iVar1 + 0x10); + return 0; +} + + + +int bt_mesh_friend_req(bt_mesh_net_rx_conflict10 *rx,net_buf_simple *buf) + +{ + s8_t sVar1; + u16_t uVar2; + byte *pbVar3; + char *fmt; + bt_mesh_friend_conflict45 *frnd; + bt_mesh_elem *pbVar4; + u32_t_conflict uVar5; + undefined *puVar6; + net_buf *pnVar7; + uint uVar8; + uint32_t delay; + ushort lpn_addr; + uint uVar9; + int iVar10; + u8_t auStack52 [4]; + u8_t net_buf_data_sdu [7]; + net_buf_simple sdu; + + pbVar3 = buf->data; + if (buf->len < 10) { + fmt = "Too short Friend Request\r\n"; +LAB_230481fa: + printf(fmt); + } + else { + uVar8 = (uint)pbVar3[1]; + if (pbVar3[1] < 10) { + fmt = "Prohibited ReceiveDelay (0x%02x)\r\n"; + } + else { + uVar8 = (uint)pbVar3[2] << 0x10 | (uint)pbVar3[3] << 8 | (uint)pbVar3[4]; + if (uVar8 - 10 < 0x34bbf6) { + if (pbVar3[7] == 0) { + fmt = "Prohibited NumElements value (0x00)\r\n"; + } + else { + lpn_addr = (rx->ctx).addr; + uVar9 = (uint)pbVar3[7] + (uint)lpn_addr; + if ((uVar9 == 1) || (0x8000 < uVar9)) { + fmt = "LPN elements stretch outside of unicast range\r\n"; + } + else { + if ((*pbVar3 & 7) != 0) { + if ((uint)(1 << ((uint)*pbVar3 & 7)) < 0x11) { + frnd = bt_mesh_friend_find(rx->sub->net_idx,lpn_addr,true,false); + if (frnd == (bt_mesh_friend_conflict45 *)0x0) { + if (bt_mesh.frnd[0]._0_4_ << 2 < 0) { + if (bt_mesh.frnd[1]._0_4_ << 2 < 0) { + printf("No free Friend contexts for new LPN\r\n"); + return -0xc; + } + iVar10 = 1; + } + else { + iVar10 = 0; + } + frnd = (bt_mesh_friend_conflict45 *)(bt_mesh.frnd + iVar10); + *(byte *)&bt_mesh.frnd[iVar10].field_0x3 = + *(byte *)&bt_mesh.frnd[iVar10].field_0x3 | 0x20; + } + else { + printf("Existing LPN re-requesting Friendship\r\n"); + friend_clear(frnd); + } + frnd->lpn = (rx->ctx).addr; + frnd->num_elem = pbVar3[7]; + frnd->net_idx = rx->sub->net_idx; + frnd->recv_delay = pbVar3[1]; + frnd->poll_to = uVar8 * 100; + frnd->lpn_counter = *(ushort *)(pbVar3 + 8) << 8 | *(ushort *)(pbVar3 + 8) >> 8; + lpn_addr = *(ushort *)(pbVar3 + 5) << 8 | *(ushort *)(pbVar3 + 5) >> 8; + (frnd->clear).frnd = lpn_addr; + if ((0 < (short)lpn_addr) && + (pbVar4 = bt_mesh_elem_find(lpn_addr), pbVar4 == (bt_mesh_elem *)0x0)) { + uVar5 = k_uptime_get_32(); + (frnd->clear).start = uVar5 + frnd->poll_to * 2; + (frnd->clear).repeat_sec = 1; + send_friend_clear(frnd); + } + iVar10 = (uint)*(byte *)((int)&fact_5870 + ((uint)(*pbVar3 >> 3) & 3)) * 0xff - + (uint)*(byte *)((int)&fact_5870 + ((uint)(*pbVar3 >> 5) & 3)) * + (int)(rx->ctx).recv_rssi; + delay = iVar10 / 10; + if (iVar10 < 1000) { + delay = 100; + } + k_delayed_work_submit(&frnd->timer,delay); + friend_cred_create(rx->sub,frnd->lpn,frnd->lpn_counter,frnd->counter); + register0x0000203c = auStack52; + sVar1 = (rx->ctx).recv_rssi; + net_buf_simple_reserve((net_buf_simple *)(net_buf_data_sdu + 4),1); + puVar6 = (undefined *)net_buf_simple_add((net_buf_simple *)(net_buf_data_sdu + 4),6) + ; + *puVar6 = 0xff; + puVar6[1] = 0x10; + puVar6[2] = 3; + puVar6[3] = sVar1; + uVar2 = frnd->counter; + puVar6[4] = (char)(uVar2 >> 8); + puVar6[5] = (char)uVar2; + pnVar7 = encode_friend_ctl(frnd,'\x04',(net_buf_simple *)(net_buf_data_sdu + 4)); + if (pnVar7 == (net_buf *)0x0) { + printf("Unable to encode Friend Offer\r\n"); + } + else { + frnd->counter = frnd->counter + 1; + if (frnd->last != (net_buf *)0x0) { + net_buf_unref(frnd->last); + } + frnd->last = pnVar7; + *(byte *)&frnd->field_0x3 = *(byte *)&frnd->field_0x3 | 2; + } + } + else { + printf("We have a too small Friend Queue size (%u < %u)\r\n",0x10); + } + return 0; + } + fmt = "Prohibited Minimum Queue Size in Friend Request\r\n"; + } + } + goto LAB_230481fa; + } + fmt = "Prohibited PollTimeout (0x%06x)\r\n"; + } + printf(fmt,uVar8); + } + return -0x16; +} + + + +int bt_mesh_friend_init(void) + +{ + bt_mesh.frnd[0].net_idx = 0xffff; + bt_mesh.frnd[0].queue.head = (sys_snode_t *)0x0; + bt_mesh.frnd[0].queue.tail = (sys_snode_t *)0x0; + k_delayed_work_init(&bt_mesh.frnd[0].timer,friend_timeout); + k_delayed_work_init(&bt_mesh.frnd[0].clear.timer,clear_timeout); + bt_mesh.frnd[1].net_idx = 0xffff; + bt_mesh.frnd[0].seg[0].queue.head = (sys_snode_t *)0x0; + bt_mesh.frnd[0].seg[0].queue.tail = (sys_snode_t *)0x0; + bt_mesh.frnd[1].queue.head = (sys_snode_t *)0x0; + bt_mesh.frnd[1].queue.tail = (sys_snode_t *)0x0; + k_delayed_work_init(&bt_mesh.frnd[1].timer,friend_timeout); + k_delayed_work_init(&bt_mesh.frnd[1].clear.timer,clear_timeout); + bt_mesh.frnd[1].seg[0].queue.head = (sys_snode_t *)0x0; + bt_mesh.frnd[1].seg[0].queue.tail = (sys_snode_t *)0x0; + return 0; +} + + + +_Bool bt_mesh_friend_match(u16_t net_idx,u16_t addr) + +{ + _Bool _Var1; + undefined3 extraout_var; + + _Var1 = friend_lpn_matches((bt_mesh_friend_conflict45 *)bt_mesh.frnd,net_idx,addr); + if (CONCAT31(extraout_var,_Var1) == 0) { + _Var1 = friend_lpn_matches((bt_mesh_friend_conflict45 *)(bt_mesh.frnd + 1),net_idx,addr); + return _Var1; + } + return _Var1; +} + + + +_Bool bt_mesh_friend_queue_has_space + (u16_t net_idx,u16_t src,u16_t dst,u64_t *seq_auth,u8_t seg_count) + +{ + _Bool _Var1; + _Bool _Var2; + _Bool _Var3; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 in_register_00002039; + + _Var1 = friend_lpn_matches((bt_mesh_friend_conflict45 *)bt_mesh.frnd,net_idx,dst); + _Var2 = false; + if ((CONCAT31(extraout_var,_Var1) != 0) && (CONCAT31(in_register_00002039,seg_count) < 0x11)) { + _Var2 = friend_queue_has_space((bt_mesh_friend_conflict45 *)bt_mesh.frnd,src,seq_auth,seg_count) + ; + } + _Var3 = friend_lpn_matches((bt_mesh_friend_conflict45 *)(bt_mesh.frnd + 1),net_idx,dst); + if (CONCAT31(extraout_var_00,_Var3) == 0) { + if (CONCAT31(extraout_var,_Var1) == 0) { + _Var2 = true; + } + } + else { + if ((CONCAT31(in_register_00002039,seg_count) < 0x11) && + (_Var1 = friend_queue_has_space + ((bt_mesh_friend_conflict45 *)(bt_mesh.frnd + 1),src,seq_auth,seg_count), + CONCAT31(extraout_var_01,_Var1) != 0)) { + _Var2 = _Var1; + } + } + return _Var2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void bt_mesh_friend_enqueue_rx + (bt_mesh_net_rx_conflict10 *rx,bt_mesh_friend_pdu_type type,u64_t *seq_auth, + u8_t seg_count,net_buf_simple *sbuf) + +{ + bt_mesh_friend_conflict45 *frnd; + u8_t uVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + net_buf *buf; + undefined3 in_register_0000202d; + int iVar3; + byte bVar4; + u32_t_conflict uVar5; + undefined4 uVar6; + undefined4 uStack60; + friend_pdu_info_conflict info; + + if (((char)*(byte *)&rx->field_0x20 < '\0') && + ((1 < (rx->ctx).recv_ttl || ((*(byte *)&rx->field_0x20 & 0x30) == 0x10)))) { + uVar1 = bt_mesh_friend_get(); + if (CONCAT31(extraout_var,uVar1) == 1) { + frnd = (bt_mesh_friend_conflict45 *)bt_mesh.frnd; + do { + _Var2 = friend_lpn_matches(frnd,rx->sub->net_idx,(rx->ctx).recv_dst); + if ((CONCAT31(extraout_var_00,_Var2) != 0) && + (_Var2 = friend_queue_prepare_space(frnd,(rx->ctx).addr,seq_auth,seg_count), + CONCAT31(extraout_var_01,_Var2) != 0)) { + if ((CONCAT31(in_register_0000202d,type) == 0) && (seq_auth != (u64_t *)0x0)) { + friend_purge_old_ack(frnd,seq_auth,(uint)(rx->ctx).addr); + } + uStack60 = *(undefined4 *)&(rx->ctx).addr; + bVar4 = (rx->ctx).recv_ttl; + if ((*(byte *)&rx->field_0x20 & 0x30) != 0x10) { + bVar4 = bVar4 - 1; + } + info.dst._1_1_ = bVar4 & 0x7f | (byte)(*(uint *)&rx->field_0x20 << 4) & 0x80; + uVar5 = rx->seq; + info.src._0_1_ = (u8_t)(uVar5 >> 0x10); + info.dst._0_1_ = (u8_t)uVar5; + info.src._1_1_ = (u8_t)(uVar5 >> 8); + info._4_4_ = bt_mesh.iv_index - (*(uint *)&rx->field_0x20 & 1); + buf = create_friend_pdu(frnd,(friend_pdu_info_conflict *)&uStack60,sbuf); + if (buf == (net_buf *)0x0) { + printf("Failed to encode Friend buffer\r\n"); + } + else { + if (seq_auth != (u64_t *)0x0) { + iVar3 = *(int *)buf->user_data; + uVar6 = *(undefined4 *)((int)seq_auth + 4); + *(undefined4 *)(iVar3 + 0x10) = *(undefined4 *)seq_auth; + *(undefined4 *)(iVar3 + 0x14) = uVar6; + } + enqueue_friend_pdu(frnd,type,seg_count,buf); + } + } + frnd = frnd + 1; + } while (frnd != (bt_mesh_friend_conflict45 *)&bt_mesh.lpn); + } + return; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +_Bool bt_mesh_friend_enqueue_tx + (bt_mesh_net_tx_conflict9 *tx,bt_mesh_friend_pdu_type type,u64_t *seq_auth, + u8_t seg_count,net_buf_simple *sbuf) + +{ + u16_t net_idx; + u16_t addr; + u32_t_conflict uVar1; + bt_mesh_friend_conflict45 *frnd; + _Bool _Var2; + u8_t uVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + u32_t_conflict uVar4; + atomic_val_t aVar5; + net_buf *buf; + undefined4 uVar6; + undefined3 in_register_0000202d; + bt_mesh_msg_ctx *pbVar7; + int iVar8; + undefined uVar9; + int iVar10; + u16_t uStack76; + u16_t uStack74; + friend_pdu_info_conflict info; + + net_idx = tx->sub->net_idx; + addr = tx->ctx->addr; + _Var2 = friend_lpn_matches((bt_mesh_friend_conflict45 *)bt_mesh.frnd,net_idx,addr); + if (((CONCAT31(extraout_var,_Var2) == 0) && + (_Var2 = friend_lpn_matches((bt_mesh_friend_conflict45 *)(bt_mesh.frnd + 1),net_idx,addr), + CONCAT31(extraout_var_00,_Var2) == 0)) || + (uVar3 = bt_mesh_friend_get(), CONCAT31(extraout_var_01,uVar3) != 1)) { + uVar9 = 0; + } + else { + frnd = (bt_mesh_friend_conflict45 *)bt_mesh.frnd; + iVar10 = 0; + do { + _Var2 = friend_lpn_matches(frnd,tx->sub->net_idx,tx->ctx->addr); + if (CONCAT31(extraout_var_02,_Var2) != 0) { + _Var2 = friend_queue_prepare_space(frnd,tx->src,seq_auth,seg_count); + iVar8 = CONCAT31(extraout_var_03,_Var2); + if (iVar8 != 0) { + if ((CONCAT31(in_register_0000202d,type) == 0) && (seq_auth != (u64_t *)0x0)) { + friend_purge_old_ack(frnd,seq_auth,(uint)tx->src); + } + pbVar7 = tx->ctx; + uStack76 = tx->src; + uStack74 = pbVar7->addr; + info.dst._1_1_ = pbVar7->send_ttl & 0x7f | (pbVar7->app_idx == 0xffff) << 7; + uVar4 = bt_mesh_next_seq(); + uVar1 = bt_mesh.iv_index; + info.src._0_1_ = (u8_t)(uVar4 >> 0x10); + info.dst._0_1_ = (u8_t)uVar4; + info.src._1_1_ = (u8_t)(uVar4 >> 8); + aVar5 = atomic_get(bt_mesh.flags); + info._4_4_ = uVar1 - (aVar5 >> 2 & 1U); + buf = create_friend_pdu(frnd,(friend_pdu_info_conflict *)&uStack76,sbuf); + iVar10 = iVar8; + if (buf == (net_buf *)0x0) { + printf("Failed to encode Friend buffer\r\n"); + } + else { + if (seq_auth != (u64_t *)0x0) { + iVar8 = *(int *)buf->user_data; + uVar6 = *(undefined4 *)seq_auth; + *(undefined4 *)(iVar8 + 0x14) = *(undefined4 *)((int)seq_auth + 4); + *(undefined4 *)(iVar8 + 0x10) = uVar6; + } + enqueue_friend_pdu(frnd,type,seg_count,buf); + } + } + } + uVar9 = (undefined)iVar10; + frnd = frnd + 1; + } while (frnd != (bt_mesh_friend_conflict45 *)&bt_mesh.lpn); + } + return (_Bool)uVar9; +} + + + +void bt_mesh_friend_clear_incomplete(bt_mesh_subnet *sub,u16_t src,u16_t dst,u64_t *seq_auth) + +{ + _Bool _Var1; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined2 in_register_0000202e; + uint uVar2; + _snode *p_Var3; + + uVar2 = CONCAT22(in_register_0000202e,src); + _Var1 = friend_lpn_matches((bt_mesh_friend_conflict45 *)bt_mesh.frnd,sub->net_idx,dst); + if ((((CONCAT31(extraout_var,_Var1) != 0) && + (bt_mesh.frnd[0].seg[0].queue.head != (sys_snode_t *)0x0)) && + (p_Var3 = bt_mesh.frnd[0].seg[0].queue.head[5].next, + (uint)*(ushort *)((int)&p_Var3[2].next + 2) == uVar2)) && + (p_Var3[4].next == *(_snode **)seq_auth)) { + if (p_Var3[5].next == *(_snode **)((int)seq_auth + 4)) { + printf("Clearing incomplete segments for 0x%04x\r\n",uVar2); + purge_buffers((sys_slist_t *)bt_mesh.frnd[0].seg); + bt_mesh.frnd[0].seg[0].seg_count = '\0'; + } + } + _Var1 = friend_lpn_matches((bt_mesh_friend_conflict45 *)(bt_mesh.frnd + 1),sub->net_idx,dst); + if (((CONCAT31(extraout_var_00,_Var1) != 0) && + (bt_mesh.frnd[1].seg[0].queue.head != (sys_snode_t *)0x0)) && + ((p_Var3 = bt_mesh.frnd[1].seg[0].queue.head[5].next, + (uint)*(ushort *)((int)&p_Var3[2].next + 2) == uVar2 && + (p_Var3[4].next == *(_snode **)seq_auth)))) { + if (p_Var3[5].next == *(_snode **)((int)seq_auth + 4)) { + printf("Clearing incomplete segments for 0x%04x\r\n",uVar2); + purge_buffers((sys_slist_t *)bt_mesh.frnd[1].seg); + bt_mesh.frnd[1].seg[0].seg_count = '\0'; + } + } + return; +} + + + +void bt_mesh_srv_update_last_rcvd_msg + (bt_mesh_last_rcvd_msg *last_msg,u8_t tid,u16_t src_addr,u16_t dst_addr) + +{ + undefined4 in_a4; + undefined4 in_a5; + + last_msg->tid = tid; + last_msg->src_addr = src_addr; + last_msg->dst_addr = dst_addr; + *(undefined4 *)&last_msg->rcvd_time = in_a4; + *(undefined4 *)((int)&last_msg->rcvd_time + 4) = in_a5; + return; +} + + + +_Bool bt_mesh_srv_check_rcvd_msg_with_last + (u8_t tid,u16_t src_addr,u16_t dst_addr,int64_t *rcvd_time, + bt_mesh_last_rcvd_msg *last_msg) + +{ + undefined3 in_register_00002029; + uint uVar1; + undefined2 in_register_0000202e; + uint uVar2; + undefined2 in_register_00002032; + uint uVar3; + + uVar1 = CONCAT31(in_register_00002029,tid); + uVar2 = CONCAT22(in_register_0000202e,src_addr); + k_uptime_get(); + *(uint *)rcvd_time = uVar1; + *(uint *)((int)rcvd_time + 4) = uVar2; + if ((uint)last_msg->tid == CONCAT31(in_register_00002029,tid)) { + if ((uint)last_msg->src_addr != CONCAT22(in_register_0000202e,src_addr)) { + return false; + } + if ((uint)last_msg->dst_addr != CONCAT22(in_register_00002032,dst_addr)) { + return false; + } + uVar3 = uVar1 - *(int *)&last_msg->rcvd_time; + uVar1 = (uint)(uVar1 < uVar3); + uVar2 = uVar2 - *(int *)((int)&last_msg->rcvd_time + 4); + if ((int)(uVar2 - uVar1) < 1) { + if (uVar2 != uVar1) { + return true; + } + if (uVar3 < 0x1771) { + return true; + } + } + } + return false; +} + + + +void k_queue_init(k_queue *queue,int size) + +{ + QueueHandle_t pQVar1; + + pQVar1 = xQueueGenericCreate(size,5,'\0'); + *(QueueHandle_t *)&queue->hdl = pQVar1; + if (pQVar1 == (QueueHandle_t)0x0) { + vAssertCalled(); + } + *(sys_dlist_t **)&(queue->poll_events).field_0 = &queue->poll_events; + *(sys_dlist_t **)&(queue->poll_events).field_1 = &queue->poll_events; + return; +} + + + +void k_queue_insert(k_queue *queue,void *prev,void *data) + +{ + BaseType_t BVar1; + void *apvStack20 [4]; + + apvStack20[0] = data; + BVar1 = xQueueGenericSend((QueueHandle_t)queue->hdl,apvStack20,0xffffffff,0); + if (BVar1 != 1) { + vAssertCalled(); + } + return; +} + + + +void k_queue_append(k_queue *queue,void *data) + +{ + k_queue_insert(queue,(void *)0x0,data); + return; +} + + + +void k_queue_free(k_queue *queue) + +{ + if ((queue != (k_queue *)0x0) && ((QueueHandle_t)queue->hdl != (QueueHandle_t)0x0)) { + vQueueDelete((QueueHandle_t)queue->hdl); + queue->hdl = (void *)0x0; + return; + } + printf("Queue is NULL\n\r\n"); + return; +} + + + +void k_queue_prepend(k_queue *queue,void *data) + +{ + k_queue_insert(queue,(void *)0x0,data); + return; +} + + + +void k_queue_append_list(k_queue *queue,void *head,void *tail) + +{ + while (head != (void *)0x0) { + k_queue_append(queue,head); + head = *(void **)head; + } + return; +} + + + +void * k_queue_get(k_queue *queue,s32_t timeout) + +{ + BaseType_t BVar1; + void *pvVar2; + void *pvStack20; + void *msg; + + pvStack20 = (void *)0x0; + if (timeout == -1) { + timeout = 0xffffffff; + } + BVar1 = xQueueReceive((QueueHandle_t)queue->hdl,&pvStack20,timeout); + pvVar2 = (void *)0x0; + if (BVar1 == 1) { + pvVar2 = pvStack20; + } + return pvVar2; +} + + + +int k_queue_is_empty(k_queue *queue) + +{ + UBaseType_t UVar1; + + UVar1 = uxQueueMessagesWaiting((QueueHandle_t)queue->hdl); + return (uint)(UVar1 == 0); +} + + + +int k_queue_get_cnt(k_queue *queue) + +{ + UBaseType_t UVar1; + + UVar1 = uxQueueMessagesWaiting((QueueHandle_t)queue->hdl); + return UVar1; +} + + + +int k_sem_init(k_sem *sem,uint initial_count,uint limit) + +{ + int iVar1; + QueueHandle_t pQVar2; + + if (sem == (k_sem *)0x0) { + printf("sem is NULL\n\r\n"); + iVar1 = -0x16; + } + else { + pQVar2 = xQueueCreateCountingSemaphore(limit,initial_count); + *(QueueHandle_t *)&(sem->sem).hdl = pQVar2; + *(sys_dlist_t **)&(sem->poll_events).field_0 = &sem->poll_events; + *(sys_dlist_t **)&(sem->poll_events).field_1 = &sem->poll_events; + iVar1 = 0; + } + return iVar1; +} + + + +int k_sem_take(k_sem *sem,uint32_t timeout) + +{ + BaseType_t BVar1; + + if (sem != (k_sem *)0x0) { + BVar1 = xQueueSemaphoreTake((QueueHandle_t)(sem->sem).hdl,timeout); + return -(uint)(BVar1 != 1); + } + return -1; +} + + + +int k_sem_give(k_sem *sem) + +{ + int iVar1; + BaseType_t BVar2; + + if (sem == (k_sem *)0x0) { + printf("sem is NULL\n\r\n"); + iVar1 = -0x16; + } + else { + BVar2 = xQueueGenericSend((QueueHandle_t)(sem->sem).hdl,(void *)0x0,0,0); + iVar1 = -(uint)(BVar2 != 1); + } + return iVar1; +} + + + +int k_sem_delete(k_sem *sem) + +{ + QueueHandle_t xQueue; + int iVar1; + + if ((sem == (k_sem *)0x0) || + (xQueue = (QueueHandle_t)(sem->sem).hdl, xQueue == (QueueHandle_t)0x0)) { + printf("sem is NULL\n\r\n"); + iVar1 = -0x16; + } + else { + vQueueDelete(xQueue); + iVar1 = 0; + (sem->sem).hdl = (void *)0x0; + } + return iVar1; +} + + + +uint k_sem_count_get(k_sem *sem) + +{ + UBaseType_t UVar1; + + UVar1 = uxQueueMessagesWaiting((QueueHandle_t)(sem->sem).hdl); + return UVar1; +} + + + +int k_thread_create(k_thread *new_thread,char *name,size_t stack_size,k_thread_entry_t entry, + int prio) + +{ + xTaskCreate((TaskFunction_t *)entry,name,(uint16_t)(stack_size >> 2),(void *)0x0,prio, + (TaskHandle_t *)new_thread); + return -(uint)(new_thread->task == 0); +} + + + +void k_thread_delete(k_thread *new_thread) + +{ + if ((new_thread != (k_thread *)0x0) && ((TaskHandle_t)new_thread->task != (TaskHandle_t)0x0)) { + vTaskDelete((TaskHandle_t)new_thread->task); + new_thread->task = 0; + return; + } + printf("task is NULL\n\r\n"); + return; +} + + + +int k_yield(void) + +{ + ecall(); + return 0; +} + + + +void k_sleep(s32_t dur_ms) + +{ + vTaskDelay((uint)(dur_ms * 1000) / 1000); + return; +} + + + +uint irq_lock(void) + +{ + vTaskEnterCritical(); + return 1; +} + + + +void irq_unlock(void) + +{ + if ((xSchedulerRunning != 0) && (pxCurrentTCB->uxCriticalNesting != 0)) { + vTaskExitCritical(); + return; + } + return; +} + + + +void k_timer_init(k_timer_t_conflict *timer,k_timer_handler_t_conflict handle,void *args) + +{ + TimerHandle_t ptVar1; + + if (timer == (k_timer_t_conflict *)0x0) { + vAssertCalled(); + } + timer->args = args; + timer->handler = handle; + ptVar1 = xTimerCreate("Timer",1000,0,(void *)0x0,(TimerCallbackFunction_t *)handle); + *(TimerHandle_t *)&(timer->timer).hdl = ptVar1; + if (ptVar1 == (TimerHandle_t)0x0) { + vAssertCalled(); + return; + } + return; +} + + + +void k_timer_stop(k_timer_t_conflict *timer) + +{ + BaseType_t BVar1; + + if (timer == (k_timer_t_conflict *)0x0) { + vAssertCalled(); + } + BVar1 = xTimerGenericCommand((TimerHandle_t)(timer->timer).hdl,3,0,(BaseType_t *)0x0,0); + if (BVar1 != 1) { + vAssertCalled(); + return; + } + return; +} + + + +void k_timer_delete(k_timer_t_conflict *timer) + +{ + BaseType_t BVar1; + + if (timer == (k_timer_t_conflict *)0x0) { + vAssertCalled(); + } + BVar1 = xTimerGenericCommand((TimerHandle_t)(timer->timer).hdl,5,0,(BaseType_t *)0x0,0); + if (BVar1 != 1) { + vAssertCalled(); + return; + } + return; +} + + + +longlong k_now_ms(void) + +{ + longlong in_fa0; + + xTaskGetTickCount(); + return in_fa0; +} + + + +longlong k_uptime_get(void) + +{ + longlong in_fa0; + + xTaskGetTickCount(); + return in_fa0; +} + + + +u32_t_conflict k_uptime_get_32(void) + +{ + u32_t_conflict in_a0; + + k_now_ms(); + return in_a0; +} + + + +void k_timer_start(k_timer_t_conflict *timer,uint32_t timeout) + +{ + TimerHandle_t xTimer; + k_timer_t_conflict *pkVar1; + BaseType_t BVar2; + TickType_t xOptionalValue; + + pkVar1 = timer; + if (timer == (k_timer_t_conflict *)0x0) { + pkVar1 = (k_timer_t_conflict *)vAssertCalled(); + } + timer->timeout = timeout; + k_now_ms(); + *(k_timer_t_conflict **)&timer->start_ms = pkVar1; + BVar2 = xTimerGenericCommand((TimerHandle_t)(timer->timer).hdl,3,0,(BaseType_t *)0x0,0); + if (BVar2 != 1) { + vAssertCalled(); + } + BVar2 = xTimerGenericCommand + ((TimerHandle_t)(timer->timer).hdl,4,(timeout * 1000) / 1000,(BaseType_t *)0x0,0 + ); + if (BVar2 != 1) { + vAssertCalled(); + } + xTimer = (TimerHandle_t)(timer->timer).hdl; + xOptionalValue = xTaskGetTickCount(); + BVar2 = xTimerGenericCommand(xTimer,1,xOptionalValue,(BaseType_t *)0x0,0); + if (BVar2 != 1) { + vAssertCalled(); + return; + } + return; +} + + + +void k_get_random_byte_array(uint8_t *buf,size_t len) + +{ + uint8_t *puVar1; + int iVar2; + + puVar1 = buf + len; + while (buf != puVar1) { + iVar2 = bl_rand(); + *buf = (uint8_t)iVar2; + buf = buf + 1; + } + return; +} + + + +void * k_malloc(size_t xWantedSize) + +{ + size_t sVar1; + size_t sVar2; + BlockLink_t *pBVar3; + A_BLOCK_LINK *pAVar4; + BlockLink_t *pxBlockToInsert; + uint uVar5; + uint uVar6; + + if (pxEnd == (BlockLink_t *)0x0) { + vAssertCalled(); + } + vTaskSuspendAll(); + sVar2 = xFreeBytesRemaining; + sVar1 = xBlockAllocatedBit; + if (((xBlockAllocatedBit & xWantedSize) == 0) && (xWantedSize != 0)) { + uVar6 = xWantedSize + 8; + if ((uVar6 & 7) != 0) { + uVar6 = (uVar6 & 0xfffffff8) + 8; + } + if ((uVar6 != 0) && (uVar6 <= xFreeBytesRemaining)) { + pAVar4 = xStart.pxNextFreeBlock; + pBVar3 = &xStart; + do { + pxBlockToInsert = pBVar3; + pBVar3 = (BlockLink_t *)pAVar4; + if (uVar6 <= pBVar3->xBlockSize) break; + pAVar4 = pBVar3->pxNextFreeBlock; + } while (pBVar3->pxNextFreeBlock != (A_BLOCK_LINK *)0x0); + if (pxEnd != pBVar3) { + pAVar4 = pxBlockToInsert->pxNextFreeBlock; + pxBlockToInsert->pxNextFreeBlock = pBVar3->pxNextFreeBlock; + uVar5 = pBVar3->xBlockSize; + pAVar4 = pAVar4 + 1; + if (0x10 < uVar5 - uVar6) { + pxBlockToInsert = (BlockLink_t *)((int)&pBVar3->pxNextFreeBlock + uVar6); + pxBlockToInsert->xBlockSize = uVar5 - uVar6; + pBVar3->xBlockSize = uVar6; + prvInsertBlockIntoFreeList(pxBlockToInsert); + uVar5 = pBVar3->xBlockSize; + } + xFreeBytesRemaining = sVar2 - uVar5; + if (xFreeBytesRemaining < xMinimumEverFreeBytesRemaining) { + xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; + } + pBVar3->xBlockSize = sVar1 | uVar5; + pBVar3->pxNextFreeBlock = (A_BLOCK_LINK *)0x0; + xTaskResumeAll(); + if (pAVar4 != (A_BLOCK_LINK *)0x0) { + return pAVar4; + } + goto LAB_230648be; + } + } + } + xTaskResumeAll(); +LAB_230648be: + vApplicationMallocFailedHook(); + return (void *)0x0; +} + + + +void k_free(void *pv) + +{ + uint uVar1; + + if (pv == (void *)0x0) { + return; + } + uVar1 = *(uint *)((int)pv + -4); + if ((uVar1 & xBlockAllocatedBit) == 0) { + vAssertCalled(); + if (*(int *)((int)pv + -8) == 0) { + uVar1 = *(uint *)((int)pv + -4); + if ((uVar1 & xBlockAllocatedBit) == 0) { + return; + } + goto LAB_230649ce; + } + } + else { + if (*(int *)((int)pv + -8) == 0) goto LAB_230649ce; + } + vAssertCalled(); + uVar1 = *(uint *)((int)pv + -4); + if (((uVar1 & xBlockAllocatedBit) == 0) || (*(int *)((int)pv + -8) != 0)) { + return; + } +LAB_230649ce: + *(uint *)((int)pv + -4) = ~xBlockAllocatedBit & uVar1; + vTaskSuspendAll(); + xFreeBytesRemaining = *(int *)((int)pv + -4) + xFreeBytesRemaining; + prvInsertBlockIntoFreeList((BlockLink_t *)((int)pv + -8)); + xTaskResumeAll(); + return; +} + + + +int atomic_cas(atomic_t *target,atomic_val_t old_value,atomic_val_t new_value) + +{ + int iVar1; + + irq_lock(); + iVar1 = *target; + if (iVar1 == old_value) { + *target = new_value; + } + irq_unlock(); + return (uint)(iVar1 == old_value); +} + + + +atomic_val_t atomic_inc(atomic_t *target) + +{ + int iVar1; + + irq_lock(); + iVar1 = *target; + *target = iVar1 + 1; + irq_unlock(); + return iVar1; +} + + + +atomic_val_t atomic_dec(atomic_t *target) + +{ + int iVar1; + + irq_lock(); + iVar1 = *target; + *target = iVar1 + -1; + irq_unlock(); + return iVar1; +} + + + +atomic_val_t atomic_get(atomic_t *target) + +{ + return *target; +} + + + +atomic_val_t atomic_set(atomic_t *target,atomic_val_t value) + +{ + atomic_t aVar1; + + irq_lock(); + aVar1 = *target; + *target = value; + irq_unlock(); + return aVar1; +} + + + +atomic_val_t atomic_clear(atomic_t *target) + +{ + atomic_t aVar1; + + irq_lock(); + aVar1 = *target; + *target = 0; + irq_unlock(); + return aVar1; +} + + + +atomic_val_t atomic_or(atomic_t *target,atomic_val_t value) + +{ + uint uVar1; + + irq_lock(); + uVar1 = *target; + *target = value | uVar1; + irq_unlock(); + return uVar1; +} + + + +atomic_val_t atomic_and(atomic_t *target,atomic_val_t value) + +{ + uint uVar1; + + irq_lock(); + uVar1 = *target; + *target = value & uVar1; + irq_unlock(); + return uVar1; +} + + + +void fixed_data_unref(net_buf *buf,u8_t *data) + +{ + return; +} + + + +net_buf_pool * net_buf_pool_get(int id) + +{ + return &acl_tx_pool + id; +} + + + +int net_buf_id(net_buf *buf) + +{ + return (int)((int)buf - (int)(&acl_tx_pool)[buf->pool_id].__bufs) >> 5; +} + + + +u8_t * fixed_data_alloc(net_buf *buf,size_t *size,s32_t timeout) + +{ + uint *puVar1; + int iVar2; + uint uVar3; + + puVar1 = (uint *)((&acl_tx_pool)[buf->pool_id].alloc)->alloc_data; + uVar3 = *size; + if (*puVar1 < *size) { + uVar3 = *puVar1; + } + *size = uVar3; + iVar2 = net_buf_id(buf); + return (u8_t *)(iVar2 * *puVar1 + puVar1[1]); +} + + + +// WARNING: Could not reconcile some variable overlaps + +net_buf * net_buf_alloc_len(net_buf_pool *pool,size_t size,s32_t timeout) + +{ + ushort uVar1; + net_buf *data; + u32_t_conflict uVar2; + uint uVar3; + u32_t_conflict uVar4; + u8_t *puVar5; + size_t asStack36 [2]; + + asStack36[0] = size; + uVar2 = k_uptime_get_32(); + uVar3 = irq_lock(); + if (pool->uninit_count == 0) { + irq_unlock(); + data = (net_buf *)k_queue_get((k_queue *)pool,timeout); + if (data == (net_buf *)0x0) { + return (net_buf *)0x0; + } + } + else { + if ((pool->uninit_count < pool->buf_count) && + (data = (net_buf *)k_queue_get((k_queue *)pool,0), data != (net_buf *)0x0)) { + irq_unlock(uVar3); + } + else { + uVar1 = pool->uninit_count; + pool->uninit_count = uVar1 - 1; + irq_unlock(uVar3); + data = pool->__bufs + ((uint)pool->buf_count - (uint)uVar1); + data->pool_id = (char)((int)&pool[-0x25b763f].__bufs >> 2) * -0x49; + } + } + if (asStack36[0] == 0) { + *(undefined4 *)((int)&data->field_4 + 8) = 0; + } + else { + if (1 < timeout + 1U) { + uVar4 = k_uptime_get_32(); + uVar3 = uVar4 - uVar2; + if ((uint)timeout < uVar4 - uVar2) { + uVar3 = timeout; + } + timeout = timeout - uVar3; + } + puVar5 = (*((&acl_tx_pool)[data->pool_id].alloc)->cb->alloc)(data,asStack36,timeout); + *(u8_t **)((int)&data->field_4 + 8) = puVar5; + if (puVar5 == (u8_t *)0x0) { + k_queue_prepend((k_queue *)(&acl_tx_pool + data->pool_id),data); + return (net_buf *)0x0; + } + } + data->field_0 = 0; + *(undefined2 *)&data->ref = 1; + *(undefined2 *)((int)&data->field_4 + 4) = 0; + *(undefined2 *)((int)&data->field_4 + 6) = (undefined2)asStack36[0]; + *(undefined4 *)&data->field_4 = *(undefined4 *)((int)&data->field_4 + 8); + return data; +} + + + +net_buf * net_buf_alloc_fixed(net_buf_pool *pool,s32_t timeout) + +{ + net_buf *pnVar1; + + pnVar1 = net_buf_alloc_len(pool,*(size_t *)pool->alloc->alloc_data,timeout); + return pnVar1; +} + + + +net_buf * net_buf_get(k_fifo *fifo,s32_t timeout) + +{ + net_buf *pnVar1; + net_buf *pnVar2; + net_buf *pnVar3; + + pnVar2 = (net_buf *)k_queue_get((k_queue *)fifo,timeout); + pnVar1 = pnVar2; + if (pnVar2 != (net_buf *)0x0) { + while ((pnVar1->flags & 1) != 0) { + pnVar3 = (net_buf *)k_queue_get((k_queue *)fifo,0); + *(net_buf **)&pnVar1->field_0 = pnVar3; + pnVar1->flags = pnVar1->flags & 0xfe; + pnVar1 = pnVar3; + } + pnVar1->field_0 = 0; + } + return pnVar2; +} + + + +void net_buf_simple_reserve(net_buf_simple *buf,size_t reserve) + +{ + buf->data = buf->__buf + reserve; + return; +} + + + +void net_buf_slist_put(sys_slist_t *list,net_buf *buf) + +{ + sys_snode_t sVar1; + + sVar1 = (sys_snode_t)buf; + while (*(sys_snode_t *)sVar1 != (sys_snode_t)0x0) { + *(byte *)((int)sVar1 + 5) = *(byte *)((int)sVar1 + 5) | 1; + sVar1 = *(sys_snode_t *)sVar1; + } + irq_lock(); + if (list->tail == (sys_snode_t *)0x0) { + *(net_buf **)&list->head = buf; + } + else { + *(net_buf **)&list->tail->next = buf; + } + *(sys_snode_t *)&list->tail = sVar1; + irq_unlock(); + return; +} + + + +// WARNING: Type propagation algorithm not settling + +net_buf * net_buf_slist_get(sys_slist_t *list) + +{ + sys_snode_t sVar1; + sys_snode_t *psVar2; + sys_snode_t sVar3; + sys_snode_t sVar4; + + irq_lock(); + sVar4 = (sys_snode_t)list->head; + if (sVar4 != (sys_snode_t)0x0) { + psVar2 = *(sys_snode_t **)sVar4; + list->head = psVar2; + if (sVar4 == (sys_snode_t)((sys_snode_t *)&list->tail)->next) { + list->tail = psVar2; + } + } + irq_unlock(); + sVar1 = sVar4; + if (sVar4 != (sys_snode_t)0x0) { + while ((*(byte *)((int)sVar1 + 5) & 1) != 0) { + irq_lock(); + sVar3 = (sys_snode_t)list->head; + if (sVar3 != (sys_snode_t)0x0) { + psVar2 = *(sys_snode_t **)sVar3; + list->head = psVar2; + if (sVar3 == (sys_snode_t)((sys_snode_t *)&list->tail)->next) { + list->tail = psVar2; + } + } + *(sys_snode_t *)sVar1 = sVar3; + irq_unlock(); + *(byte *)((int)sVar1 + 5) = *(byte *)((int)sVar1 + 5) & 0xfe; + sVar1 = *(sys_snode_t *)sVar1; + } + *(undefined4 *)sVar1 = 0; + } + return (net_buf *)sVar4; +} + + + +void net_buf_put(k_fifo *fifo,net_buf *buf) + +{ + net_buf *tail; + + tail = buf; + while ((net_buf *)tail->field_0 != (net_buf *)0x0) { + tail->flags = tail->flags | 1; + tail = (net_buf *)tail->field_0; + } + k_queue_append_list((k_queue *)fifo,buf,tail); + return; +} + + + +void net_buf_unref(net_buf *buf) + +{ + byte bVar1; + u8_t *puVar2; + u8_t uVar3; + net_buf *pnVar4; + + while( true ) { + if (buf == (net_buf *)0x0) { + return; + } + pnVar4 = (net_buf *)buf->field_0; + uVar3 = buf->ref + -1; + buf->ref = uVar3; + if (uVar3 != '\0') break; + puVar2 = *(u8_t **)((int)&buf->field_4 + 8); + if (puVar2 != (u8_t *)0x0) { + if ((buf->flags & 2) == 0) { + (*((&acl_tx_pool)[buf->pool_id].alloc)->cb->unref)(buf,puVar2); + } + *(undefined4 *)((int)&buf->field_4 + 8) = 0; + } + bVar1 = buf->pool_id; + *(undefined4 *)&buf->field_4 = 0; + buf->field_0 = 0; + if ((&acl_tx_pool)[bVar1].destroy == (anon_subr_void_net_buf_ptr_for_destroy *)0x0) { + k_queue_prepend((k_queue *)(&acl_tx_pool + bVar1),buf); + } + else { + (*(&acl_tx_pool)[bVar1].destroy)(buf); + } + buf = pnVar4; + if (&acl_tx_pool + bVar1 == &hci_rx_pool) { + bl_handle_queued_msg(); + return; + } + } + return; +} + + + +net_buf * net_buf_ref(net_buf *buf) + +{ + buf->ref = buf->ref + '\x01'; + return buf; +} + + + +void net_buf_frag_insert(net_buf *parent,net_buf *frag) + +{ + net_buf *pnVar1; + net_buf *pnVar2; + + pnVar1 = frag; + if (parent->field_0 != 0) { + do { + pnVar2 = pnVar1; + pnVar1 = (net_buf *)pnVar2->field_0; + } while (pnVar1 != (net_buf *)0x0); + pnVar2->field_0 = parent->field_0; + } + *(net_buf **)&parent->field_0 = frag; + return; +} + + + +net_buf * net_buf_frag_add(net_buf *head,net_buf *frag) + +{ + net_buf *parent; + net_buf *pnVar1; + + pnVar1 = head; + if (head != (net_buf *)0x0) { + do { + parent = pnVar1; + pnVar1 = (net_buf *)parent->field_0; + } while (pnVar1 != (net_buf *)0x0); + net_buf_frag_insert(parent,frag); + return head; + } + frag->ref = frag->ref + '\x01'; + return frag; +} + + + +net_buf * net_buf_frag_del(net_buf *parent,net_buf *frag) + +{ + net_buf *pnVar1; + + if (parent != (net_buf *)0x0) { + parent->field_0 = frag->field_0; + } + pnVar1 = (net_buf *)frag->field_0; + frag->field_0 = 0; + net_buf_unref(frag); + return pnVar1; +} + + + +void * net_buf_simple_add(net_buf_simple *buf,size_t len) + +{ + ushort uVar1; + + uVar1 = buf->len; + buf->len = (short)len + uVar1; + return buf->data + uVar1; +} + + + +void * net_buf_simple_add_mem(net_buf_simple *buf,void *mem,size_t len) + +{ + ushort uVar1; + void *pvVar2; + + uVar1 = buf->len; + buf->len = uVar1 + (short)len; + pvVar2 = memcpy(buf->data + uVar1,mem,len); + return pvVar2; +} + + + +u8_t * net_buf_simple_add_u8(net_buf_simple *buf,u8_t val) + +{ + ushort uVar1; + u8_t *puVar2; + + uVar1 = buf->len; + puVar2 = buf->data; + buf->len = uVar1 + 1; + puVar2[uVar1] = val; + return puVar2 + uVar1; +} + + + +void net_buf_simple_add_le16(net_buf_simple *buf,u16_t val) + +{ + ushort uVar1; + u8_t *puVar2; + + uVar1 = buf->len; + puVar2 = buf->data; + buf->len = uVar1 + 2; + puVar2[uVar1] = (u8_t)val; + (puVar2 + uVar1)[1] = (u8_t)(val >> 8); + return; +} + + + +void net_buf_simple_add_be16(net_buf_simple *buf,u16_t val) + +{ + ushort uVar1; + u8_t *puVar2; + + uVar1 = buf->len; + puVar2 = buf->data; + buf->len = uVar1 + 2; + puVar2[uVar1] = (u8_t)(val >> 8); + (puVar2 + uVar1)[1] = (u8_t)val; + return; +} + + + +void net_buf_simple_add_be32(net_buf_simple *buf,u32_t_conflict val) + +{ + u8_t *puVar1; + + puVar1 = buf->data + buf->len; + buf->len = buf->len + 4; + puVar1[1] = (u8_t)(val >> 0x10); + *puVar1 = (u8_t)(val >> 0x18); + puVar1[2] = (u8_t)(val >> 8); + puVar1[3] = (u8_t)val; + return; +} + + + +void * net_buf_simple_push(net_buf_simple *buf,size_t len) + +{ + u8_t *puVar1; + + puVar1 = buf->data; + buf->data = puVar1 + -len; + buf->len = (short)len + buf->len; + return puVar1 + -len; +} + + + +void net_buf_simple_push_le16(net_buf_simple *buf,u16_t val) + +{ + u8_t *puVar1; + + puVar1 = buf->data; + buf->data = puVar1 + -2; + buf->len = buf->len + 2; + puVar1[-2] = (u8_t)val; + puVar1[-1] = (u8_t)(val >> 8); + return; +} + + + +void net_buf_simple_push_be16(net_buf_simple *buf,u16_t val) + +{ + u8_t *puVar1; + + puVar1 = buf->data; + buf->data = puVar1 + -2; + buf->len = buf->len + 2; + puVar1[-2] = (u8_t)(val >> 8); + puVar1[-1] = (u8_t)val; + return; +} + + + +void net_buf_simple_push_u8(net_buf_simple *buf,u8_t val) + +{ + u8_t *puVar1; + + puVar1 = buf->data; + buf->data = puVar1 + -1; + buf->len = buf->len + 1; + puVar1[-1] = val; + return; +} + + + +void * net_buf_simple_pull(net_buf_simple *buf,size_t len) + +{ + u8_t *puVar1; + + buf->len = buf->len - (short)len; + puVar1 = buf->data; + buf->data = puVar1 + len; + return puVar1 + len; +} + + + +void * net_buf_simple_pull_mem(net_buf_simple *buf,size_t len) + +{ + u8_t *puVar1; + + puVar1 = buf->data; + buf->len = buf->len - (short)len; + buf->data = puVar1 + len; + return puVar1; +} + + + +u8_t net_buf_simple_pull_u8(net_buf_simple *buf) + +{ + u8_t uVar1; + + uVar1 = *buf->data; + net_buf_simple_pull(buf,1); + return uVar1; +} + + + +u16_t net_buf_simple_pull_le16(net_buf_simple *buf) + +{ + u16_t uVar1; + + uVar1 = *(u16_t *)buf->data; + net_buf_simple_pull(buf,2); + return uVar1; +} + + + +u16_t net_buf_simple_pull_be16(net_buf_simple *buf) + +{ + ushort uVar1; + + uVar1 = *(ushort *)buf->data; + net_buf_simple_pull(buf,2); + return (u16_t)(uVar1 >> 8 | uVar1 << 8); +} + + + +u32_t_conflict net_buf_simple_pull_be32(net_buf_simple *buf) + +{ + uint uVar1; + + uVar1 = *(uint *)buf->data; + net_buf_simple_pull(buf,4); + return uVar1 >> 0x18 | uVar1 << 0x18 | uVar1 >> 8 & 0xff00 | (uVar1 & 0xff00) << 8; +} + + + +size_t net_buf_simple_headroom(net_buf_simple *buf) + +{ + return (size_t)(buf->data + -(int)buf->__buf); +} + + + +size_t net_buf_simple_tailroom(net_buf_simple *buf) + +{ + return ((uint)buf->size - (uint)buf->len) - (int)(buf->data + -(int)buf->__buf); +} + + + +size_t net_buf_append_bytes + (net_buf *buf,size_t len,void *value,s32_t timeout, + net_buf_allocator_cb *allocate_cb,void *user_data) + +{ + net_buf *pnVar1; + uint len_00; + net_buf *frag; + size_t sVar2; + + pnVar1 = buf; + do { + frag = pnVar1; + pnVar1 = (net_buf *)frag->field_0; + } while ((net_buf *)frag->field_0 != (net_buf *)0x0); + sVar2 = 0; + while( true ) { + len_00 = net_buf_simple_tailroom((net_buf_simple *)&frag->field_4); + if (len < len_00) { + len_00 = len; + } + len_00 = len_00 & 0xffff; + len = len - len_00; + net_buf_simple_add_mem((net_buf_simple *)&frag->field_4,value,len_00); + sVar2 = sVar2 + len_00; + value = (void *)((int)value + len_00); + if ((len == 0) || (frag = (*allocate_cb)(timeout,user_data), frag == (net_buf *)0x0)) break; + net_buf_frag_add(buf,frag); + } + return sVar2; +} + + + +char * bt_hex_real(void *buf,size_t len) + +{ + char "0123456789abcdef" [17]; + char str [128]; + byte *pbVar1; + char *pcVar2; + + if (0x3f < len) { + len = 0x3f; + } + pbVar1 = (byte *)buf; + pcVar2 = (char *)&ram0x42015364; + while (pbVar1 != (byte *)((int)buf + len)) { + *pcVar2 = "0123456789abcdef"[*pbVar1 >> 4]; + pcVar2[1] = *(char *)(((uint)*pbVar1 & 0xf) + 0x230baa4c); + pbVar1 = pbVar1 + 1; + pcVar2 = pcVar2 + 2; + } + *(undefined *)(len * 2 + 0x42015364) = 0; + return (char *)0x42015364; +} + + + +// WARNING: Variable defined which should be unmapped: type + +char * bt_addr_le_str_real(bt_addr_le_t *addr) + +{ + u8_t uVar1; + char str [30]; + char *__src; + char acStack28 [4]; + char type [10]; + + uVar1 = addr->type; + if (uVar1 == '\x01') { + __src = "random"; + } + else { + if (uVar1 == '\0') { + __src = "public"; + } + else { + if (uVar1 == '\x02') { + __src = "public-id"; + } + else { + if (uVar1 != '\x03') { + snprintf(acStack28,10,"0x%02x"); + goto LAB_23049622; + } + __src = "random-id"; + } + } + } + strcpy(acStack28,__src); +LAB_23049622: + snprintf((char *)&ram0x420153e4,0x1e,"%02X:%02X:%02X:%02X:%02X:%02X (%s)",(uint)(addr->a).val[5], + (uint)(addr->a).val[4],(uint)(addr->a).val[3],(uint)(addr->a).val[2], + (uint)(addr->a).val[1]); + return (char *)0x420153e4; +} + + + +void k_work_submit_to_queue(k_work_q *work_q,k_work *work) + +{ + uint uVar1; + + uVar1 = atomic_or(work->flags,1); + if ((uVar1 & 1) == 0) { + k_queue_append((k_queue *)work_q,work); + return; + } + return; +} + + + +void work_queue_main(void *p1) + +{ + void *pvVar1; + uint uVar2; + + do { + pvVar1 = k_queue_get((k_queue *)&g_work_queue_main,-1); + uVar2 = atomic_and((atomic_t *)((int)pvVar1 + 8),-2); + if ((uVar2 & 1) != 0) { + (**(code **)((int)pvVar1 + 4))(pvVar1,*(code **)((int)pvVar1 + 4)); + } + k_yield(); + } while( true ); +} + + + +int k_work_q_start(void) + +{ + int iVar1; + + timer_records[0].timer = (void *)0x0; + timer_records[0].delay_work = (k_delayed_work *)0x0; + timer_records[1].timer = (void *)0x0; + timer_records[1].delay_work = (k_delayed_work *)0x0; + timer_records[2].timer = (void *)0x0; + timer_records[2].delay_work = (k_delayed_work *)0x0; + timer_records[3].timer = (void *)0x0; + timer_records[3].delay_work = (k_delayed_work *)0x0; + timer_records[4].timer = (void *)0x0; + timer_records[4].delay_work = (k_delayed_work *)0x0; + k_queue_init((k_queue *)&g_work_queue_main,0x14); + iVar1 = k_thread_create(&work_q_thread,"work_q_thread",0x800,work_queue_main,0x1e); + return iVar1; +} + + + +int k_work_init(k_work *work,k_work_handler_t *handler) + +{ + atomic_and(work->flags,-2); + work->handler = handler; + return 0; +} + + + +void k_work_submit(k_work *work) + +{ + k_work_submit_to_queue(&g_work_queue_main,work); + return; +} + + + +void k_delayed_work_init(k_delayed_work *work,k_work_handler_t *handler) + +{ + k_work_init((k_work *)work,handler); + k_timer_init((k_timer_t_conflict *)&work->timer,work_timeout,work); + work->work_q = (k_work_q *)0x0; + return; +} + + + +s32_t k_delayed_work_remaining_get(k_delayed_work *work) + +{ + uint32_t uVar1; + uint32_t uVar2; + s32_t sVar3; + + if (work != (k_delayed_work *)0x0) { + uVar1 = (work->timer).timeout; + uVar2 = (work->timer).start_ms; + k_now_ms(); + sVar3 = (uVar1 + uVar2) - (int)work; + if (sVar3 < 0) { + sVar3 = 0; + } + return sVar3; + } + return 0; +} + + + +void k_delayed_work_del_timer(k_delayed_work *work) + +{ + if ((work != (k_delayed_work *)0x0) && ((work->timer).timer.hdl != (void *)0x0)) { + k_timer_delete((k_timer_t_conflict *)&work->timer); + (work->timer).timer.hdl = (void *)0x0; + return; + } + return; +} + + + +int add_timer_record(k_delayed_work *delay_work) + +{ + _snode *p_Var1; + timer_rec_d *ptVar2; + timer_rec_d *ptVar3; + int iVar4; + + p_Var1 = (_snode *)(delay_work->timer).timer.hdl; + ptVar2 = timer_records; + ptVar3 = timer_records; + do { + if ((((bt_conn_tx *)ptVar3)->node).next == p_Var1) { + return 0; + } + ptVar3 = (timer_rec_d *)&((bt_conn_tx *)ptVar3)->user_data; + } while ((bt_conn_tx *)ptVar3 != conn_tx); + iVar4 = 0; + do { + if ((ptVar2->timer).hdl == (void *)0x0) { + *(_snode **)&timer_records[iVar4].timer.hdl = p_Var1; + timer_records[iVar4].delay_work = delay_work; + return 0; + } + iVar4 = iVar4 + 1; + ptVar2 = ptVar2 + 1; + } while (iVar4 != 5); + return -1; +} + + + +int remv_timer_record(k_delayed_work *delay_work) + +{ + timer_rec_d *ptVar1; + int iVar2; + + ptVar1 = timer_records; + iVar2 = 0; + do { + if ((ptVar1->timer).hdl == (delay_work->timer).timer.hdl) { + timer_records[iVar2].timer.hdl = (void *)0x0; + return 0; + } + iVar2 = iVar2 + 1; + ptVar1 = ptVar1 + 1; + } while (iVar2 != 5); + return 0; +} + + + +int k_delayed_work_cancel(k_delayed_work *work) + +{ + uint uVar1; + uint uVar2; + + uVar1 = irq_lock(); + uVar2 = atomic_get((work->work).flags); + uVar2 = uVar2 & 1; + if (uVar2 == 0) { + if (work->work_q == (k_work_q *)0x0) { + uVar2 = 0xffffffea; + } + else { + k_timer_stop((k_timer_t_conflict *)&work->timer); + remv_timer_record(work); + work->work_q = (k_work_q *)0x0; + (work->timer).timeout = 0; + (work->timer).start_ms = 0; + } + } + else { + uVar2 = 0xffffffbc; + } + irq_unlock(uVar1); + return uVar2; +} + + + +int k_delayed_work_submit(k_delayed_work *work,uint32_t delay) + +{ + uint uVar1; + int iVar2; + + uVar1 = irq_lock(); + if (work->work_q != (k_work_q *)0x0) { + iVar2 = -0x30; + if (work->work_q != &g_work_queue_main) goto done; + iVar2 = k_delayed_work_cancel(work); + if (iVar2 < 0) goto done; + } + work->work_q = &g_work_queue_main; + if (delay == 0) { + k_work_submit_to_queue(&g_work_queue_main,(k_work *)work); + work->work_q = (k_work_q *)0x0; + } + else { + k_timer_start((k_timer_t_conflict *)&work->timer,delay); + iVar2 = add_timer_record(work); + if (iVar2 == 0) goto done; + vAssertCalled(); + } + iVar2 = 0; +done: + irq_unlock(uVar1); + return iVar2; +} + + + +timer_rec_d * get_timer_record(void *hdl) + +{ + timer_rec_d *ptVar1; + int iVar2; + + ptVar1 = timer_records; + iVar2 = 0; + do { + if ((ptVar1->timer).hdl == hdl) { + return timer_records + iVar2; + } + iVar2 = iVar2 + 1; + ptVar1 = ptVar1 + 1; + } while (iVar2 != 5); + return (timer_rec_d *)0x0; +} + + + +void work_timeout(void *timer) + +{ + k_delayed_work *work; + timer_rec_d *ptVar1; + + ptVar1 = get_timer_record(timer); + if (ptVar1 == (timer_rec_d *)0x0) { + vAssertCalled(); + } + work = ptVar1->delay_work; + k_timer_stop((k_timer_t_conflict *)&work->timer); + k_work_submit_to_queue(work->work_q,(k_work *)work); + work->work_q = (k_work_q *)0x0; + (ptVar1->timer).hdl = (void *)0x0; + return; +} + + + +void reverse_bytearray(uint8_t *src,uint8_t *result,int array_size) + +{ + uint8_t *puVar1; + int iVar2; + + result = result + array_size; + iVar2 = 0; + while (result = result + -1, iVar2 < array_size) { + puVar1 = src + iVar2; + iVar2 = iVar2 + 1; + *result = *puVar1; + } + return; +} + + + +uint find_msb_set(uint32_t data) + +{ + uint uVar1; + int iVar2; + + if (data != 0) { + uVar1 = 0x80000000; + iVar2 = 0; + while ((uVar1 & data) == 0) { + iVar2 = iVar2 + 1; + uVar1 = uVar1 >> 1; + } + data = 0x20 - iVar2; + } + return data; +} + + + +uint find_lsb_set(uint32_t data) + +{ + uint uVar1; + uint uVar2; + + uVar2 = 0; + if (data != 0) { + uVar1 = 1; + uVar2 = 0; + while (uVar2 = uVar2 + 1, (uVar1 & data) == 0) { + uVar1 = uVar1 << 1; + } + } + return uVar2; +} + + + +void gf_double(uint8_t *out,uint8_t *in) + +{ + byte *pbVar1; + byte *pbVar2; + uint uVar3; + + uVar3 = (int)(char)*in >> 0x1f & 0x87; + pbVar1 = out + 0xf; + pbVar2 = in + 0xf; + while( true ) { + *pbVar1 = (byte)uVar3 ^ *pbVar2 << 1; + if (pbVar2 == in) break; + uVar3 = (uint)(*pbVar2 >> 7); + pbVar1 = pbVar1 + -1; + pbVar2 = pbVar2 + -1; + } + return; +} + + + +int tc_cmac_erase(TCCmacState_t s) + +{ + if (s != (TCCmacState_t)0x0) { + _set(s,0,0x58); + return 1; + } + return 0; +} + + + +int tc_cmac_init(TCCmacState_t s) + +{ + if (s != (TCCmacState_t)0x0) { + _set(s,0,0x10); + _set(s->leftover,0,0x10); + s->leftover_offset = 0; + *(undefined4 *)&s->countdown = 0; + *(undefined4 *)((int)&s->countdown + 4) = 0x10000; + return 1; + } + return 0; +} + + + +int tc_cmac_setup(TCCmacState_t s,uint8_t *key,TCAesKeySched_t sched) + +{ + if ((s != (TCCmacState_t)0x0) && (key != (uint8_t *)0x0)) { + _set(s,0,0x58); + s->sched = sched; + tc_aes128_set_encrypt_key(sched,key); + _set(s,0,0x10); + tc_aes_encrypt((uint8_t *)s,(uint8_t *)s,s->sched); + gf_double(s->K1,(uint8_t *)s); + gf_double(s->K2,s->K1); + tc_cmac_init(s); + return 1; + } + return 0; +} + + + +int tc_cmac_update(TCCmacState_t s,uint8_t *data,size_t data_length) + +{ + uint8_t *puVar1; + byte *pbVar2; + uint to_len; + byte *pbVar3; + uint uVar4; + TCCmacState_t ptVar5; + int iVar6; + uint uVar7; + + if (s == (TCCmacState_t)0x0) { + return 0; + } + if (data_length == 0) { + return 1; + } + if (data == (uint8_t *)0x0) { + return 0; + } + uVar4 = *(uint *)&s->countdown; + to_len = *(uint *)((int)&s->countdown + 4); + if ((uVar4 | to_len) == 0) { + return 0; + } + uVar7 = s->leftover_offset; + *(uint *)&s->countdown = uVar4 - 1; + *(int *)((int)&s->countdown + 4) = (uint)(uVar4 - 1 < uVar4) + (to_len - 1); + to_len = data_length; + if (uVar7 != 0) { + to_len = 0x10 - uVar7; + if (data_length < to_len) { + _copy(s->leftover + uVar7,data_length,data,data_length); + data_length = data_length + s->leftover_offset; + goto LAB_23049b56; + } + _copy(s->leftover + uVar7,to_len,data,to_len); + data_length = (data_length - 0x10) + uVar7; + data = data + to_len; + s->leftover_offset = 0; + ptVar5 = s; + do { + puVar1 = ptVar5->iv; + ptVar5->iv[0] = ptVar5->iv[0] ^ ptVar5->leftover[0]; + ptVar5 = (TCCmacState_t)(puVar1 + 1); + } while ((TCCmacState_t)s->K1 != (TCCmacState_t)(puVar1 + 1)); + tc_aes_encrypt((uint8_t *)s,(uint8_t *)s,s->sched); + to_len = data_length; + } + while (0x10 < data_length) { + iVar6 = 0; + do { + pbVar2 = s->iv + iVar6; + pbVar3 = data + (to_len - data_length) + iVar6; + iVar6 = iVar6 + 1; + *pbVar2 = *pbVar3 ^ *pbVar2; + } while (iVar6 != 0x10); + tc_aes_encrypt((uint8_t *)s,(uint8_t *)s,s->sched); + data_length = data_length - 0x10; + } + if (data_length == 0) { + return 1; + } + _copy(s->leftover,data_length,data + (to_len - data_length),data_length); +LAB_23049b56: + s->leftover_offset = data_length; + return 1; +} + + + +int tc_cmac_final(uint8_t *tag,TCCmacState_t s) + +{ + byte *pbVar1; + uint8_t *puVar2; + int iVar3; + uint uVar4; + TCCmacState_t ptVar5; + + if ((tag != (uint8_t *)0x0) && (s != (TCCmacState_t)0x0)) { + uVar4 = s->leftover_offset; + if (uVar4 == 0x10) { + puVar2 = s->K1; + } + else { + _set(s->leftover + uVar4,0,0x10 - uVar4); + puVar2 = s->K2; + s->leftover[s->leftover_offset] = -0x80; + } + iVar3 = 0; + ptVar5 = s; + do { + pbVar1 = puVar2 + iVar3; + iVar3 = iVar3 + 1; + ptVar5->iv[0] = ptVar5->iv[0] ^ ptVar5->leftover[0] ^ *pbVar1; + ptVar5 = (TCCmacState_t)(ptVar5->iv + 1); + } while (iVar3 != 0x10); + tc_aes_encrypt(tag,(uint8_t *)s,s->sched); + tc_cmac_erase(s); + return 1; + } + return 0; +} + + + +uint _copy(uint8_t *to,uint to_len,uint8_t *from,uint from_len) + +{ + if (from_len <= to_len) { + memcpy(to,from,from_len); + return from_len; + } + return 0; +} + + + +void * _set(void *__s,int __c,size_t __n) + +{ + uint uVar1; + uint extraout_a1; + uint *puVar2; + uint *puVar3; + void *pvVar4; + uint uVar5; + + uVar1 = 0xf; + if (0xf < __n) { + uVar5 = (uint)__s & 0xf; + puVar3 = (uint *)__s; + if (uVar5 != 0) { + pvVar4 = __s; + __s = (void *)(*(code *)(uVar5 * 4 + 0x230a3abc))(); + puVar3 = (uint *)((int)pvVar4 - (uVar5 - 0x10)); + __n = __n + (uVar5 - 0x10); + __c = extraout_a1; + if (__n <= uVar1) goto LAB_230a3aac; + } + if (__c != 0) { + uVar5 = __c & 0xffU | (__c & 0xffU) << 8; + __c = uVar5 | uVar5 << 0x10; + } + uVar5 = __n & 0xfffffff0; + __n = __n & 0xf; + puVar2 = (uint *)(uVar5 + (int)puVar3); + do { + *puVar3 = __c; + puVar3[1] = __c; + puVar3[2] = __c; + puVar3[3] = __c; + puVar3 = puVar3 + 4; + } while (puVar3 < puVar2); + if (__n == 0) { + return __s; + } + } +LAB_230a3aac: + // WARNING: Could not recover jumptable at 0x230a3abc. Too many branches + // WARNING: Treating indirect jump as call + pvVar4 = (void *)(*(code *)(&UNK_230a3ac0 + (uVar1 - __n) * 4))(); + return pvVar4; +} + + + +uint8_t _double_byte(uint8_t a) + +{ + undefined3 in_register_00002029; + + return a << 1 ^ (char)(CONCAT31(in_register_00002029,a) >> 7) * '\x1b'; +} + + + +rx_msg_struct * bl_find_valid_queued_entry(void) + +{ + int iVar1; + int iVar2; + undefined auStack40 [4]; + rx_msg_struct empty_msg; + + iVar1 = 0; + memset(auStack40,0,8); + do { + iVar2 = memcmp(msg_array + iVar1,auStack40,8); + if (iVar2 == 0) { + return msg_array + iVar1; + } + iVar1 = iVar1 + 1; + } while (iVar1 != 9); + return (rx_msg_struct *)0x0; +} + + + +void bl_onchiphci_rx_packet_handler + (uint8_t pkt_type,uint16_t src_id,uint8_t *param,uint8_t param_len,void *rx_buf) + +{ + uint8_t uVar1; + bool bVar2; + uint32_t monitor; + undefined uVar3; + bt_buf_type type; + undefined3 in_register_00002029; + int iVar4; + undefined *puVar5; + int iVar6; + rx_msg_struct *data; + void *__dest; + uint uVar7; + undefined2 in_register_0000202e; + undefined3 in_register_00002035; + size_t xWantedSize; + size_t len; + + xWantedSize = CONCAT31(in_register_00002035,param_len); + iVar4 = CONCAT31(in_register_00002029,pkt_type); + uVar3 = (undefined)src_id; + uVar3 = (undefined)(src_id >> 8); + if (rx_buf == (void *)0x0) { + if (iVar4 == 1) { + type = BT_BUF_ACL_IN; +LAB_23049d58: + rx_buf = bt_buf_get_rx(type,0); + } + else { + if (1 < (iVar4 - 2U & 0xff)) { + if (((iVar4 == 4) && (*param == '\x02')) && (iVar6 = bt_buf_get_rx_avail_cnt(), iVar6 < 2)) + goto LAB_23049d72; + type = BT_BUF_EVT; + goto LAB_23049d58; + } + rx_buf = bt_buf_get_cmd_complete(-1); + } + if ((net_buf *)rx_buf == (net_buf *)0x0) { +LAB_23049d72: + monitor = monitor + 1; + if ((monitor & 0xff) == 0) { + puts("hci_rx_pool is not available\n"); + } + if (((iVar4 != 4) || (*param != '\x02')) && + (data = bl_find_valid_queued_entry(), data != (rx_msg_struct *)0x0)) { + *(undefined *)&data->src_id = uVar3; + data->pkt_type = pkt_type; + *(undefined *)((int)&data->src_id + 1) = uVar3; + if (xWantedSize != 0) { + __dest = k_malloc(xWantedSize); + *(undefined *)((int)&data->param + 1) = (char)((uint)__dest >> 8); + *(char *)&data->param = (char)__dest; + *(undefined *)((int)&data->param + 2) = (char)((uint)__dest >> 0x10); + *(undefined *)((int)&data->param + 3) = (char)((uint)__dest >> 0x18); + memcpy(__dest,param,xWantedSize); + } + data->param_len = param_len; + k_queue_append(&msg_queue,data); + return; + } + return; + } + monitor = 0; + } + puVar5 = (undefined *) + ((uint)*(ushort *)((int)&((net_buf *)rx_buf)->field_4 + 4) + + *(int *)&((net_buf *)rx_buf)->field_4); + switch(iVar4 - 1U & 0xff) { + case 0: + ((net_buf *)rx_buf)->user_data[0] = '\x03'; + uVar7 = bt_onchiphci_hanlde_rx_acl(param,puVar5); + len = uVar7 & 0xffff; + goto LAB_23049ea4; + case 1: + *puVar5 = 0xe; + puVar5[1] = param_len + '\x03'; + puVar5[3] = uVar3; + puVar5[2] = 1; + puVar5[4] = uVar3; + len = xWantedSize + 5; + memcpy(puVar5 + 5,param,xWantedSize); + bVar2 = true; + break; + case 2: + *puVar5 = 0xf; + puVar5[1] = 4; + uVar1 = *param; + puVar5[4] = uVar3; + puVar5[2] = uVar1; + puVar5[3] = 1; + puVar5[5] = uVar3; + bVar2 = true; + len = 6; + break; + case 3: + ((net_buf *)rx_buf)->user_data[0] = '\x01'; + *puVar5 = 0x3e; + puVar5[1] = param_len; + len = xWantedSize + 2; + memcpy(puVar5 + 2,param,xWantedSize); +LAB_23049ea4: + bVar2 = false; + break; + case 4: + ((net_buf *)rx_buf)->user_data[0] = '\x01'; + *puVar5 = uVar3; + puVar5[1] = param_len; + bVar2 = CONCAT22(in_register_0000202e,src_id) == 0x13; + len = xWantedSize + 2; + memcpy(puVar5 + 2,param,xWantedSize); + break; + default: + return; + } + net_buf_simple_add((net_buf_simple *)&((net_buf *)rx_buf)->field_4,len); + if (bVar2) { + bt_recv_prio(); + return; + } + hci_driver_enque_recvq((net_buf *)rx_buf); + return; +} + + + +void bl_handle_queued_msg(void) + +{ + int iVar1; + net_buf *rx_buf; + uint8_t *__s; + + iVar1 = k_queue_is_empty(&msg_queue); + if (iVar1 == 0) { + rx_buf = bt_buf_get_rx(BT_BUF_ACL_IN,0); + if (rx_buf != (net_buf *)0x0) { + __s = (uint8_t *)k_queue_get(&msg_queue,0); + bl_onchiphci_rx_packet_handler + (*__s,*(uint16_t *)(__s + 1),*(uint8_t **)(__s + 3),__s[7],rx_buf); + if (*(void **)(__s + 3) != (void *)0x0) { + k_free(*(void **)(__s + 3)); + } + memset(__s,0,8); + return; + } + } + return; +} + + + +void bl_onchiphci_interface_deinit(void) + +{ + void *pvVar1; + + while (pvVar1 = k_queue_get(&msg_queue,0), pvVar1 != (void *)0x0) { + if (*(void **)((int)pvVar1 + 3) != (void *)0x0) { + k_free(*(void **)((int)pvVar1 + 3)); + } + } + k_queue_free(&msg_queue); + return; +} + + + +uint8_t bl_onchiphci_interface_init(void) + +{ + uint8_t uVar1; + + memset(msg_array,0,0x48); + k_queue_init(&msg_queue,9); + uVar1 = bt_onchiphci_interface_init(bl_onchiphci_rx_packet_handler); + return uVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bl_onchiphci_send_2_controller(net_buf *buf) + +{ + ushort uVar1; + int iVar2; + ushort dest_id; + byte pkt_type; + ushort *puVar3; + ushort uStack44; + byte bStack42; + hci_pkt_struct pkt; + + pkt_type = buf->user_data[0]; + if (pkt_type == 0) { + dest_id = *(ushort *)((int)&buf->field_4 + 4); + if ((2 < dest_id) && + (puVar3 = *(ushort **)&buf->field_4, (uint)*(byte *)(puVar3 + 1) <= (uint)dest_id)) { + uStack44 = *puVar3; + net_buf_simple_pull((net_buf_simple *)&buf->field_4,3); + pkt.p._0_4_ = *(byte **)&buf->field_4; + dest_id = 0; + if ((((uint)uStack44 - 0x2013 & 0xffff) < 0x20) && + (dest_id = (ushort)pkt_type, (1 << ((uint)uStack44 - 0x2013 & 0x1f) & 0xa000e1cdU) != 0)) { + dest_id = (ushort)*(byte *)pkt.p; + } + pkt.p._4_4_ = pkt.p._4_4_ & 0xffffff00 | (uint)*(byte *)(puVar3 + 1); +LAB_2304a0b2: + iVar2 = bt_onchiphci_send(pkt_type,dest_id,(hci_pkt_struct *)&uStack44); + return iVar2; + } + } + else { + if ((pkt_type == 2) && (3 < *(ushort *)((int)&buf->field_4 + 4))) { + dest_id = (*(ushort **)&buf->field_4)[1]; + uVar1 = **(ushort **)&buf->field_4; + net_buf_simple_pull((net_buf_simple *)&buf->field_4,4); + if (dest_id <= *(ushort *)((int)&buf->field_4 + 4)) { + pkt.p._4_4_ = *(uint *)&buf->field_4; + pkt.p._0_4_ = (byte *)CONCAT22(pkt.p._2_2_,dest_id); + dest_id = (ushort)(((uint)uVar1 << 0x14) >> 0x14); + bStack42 = (byte)(uVar1 >> 0xc); + pkt_type = 1; + uStack44 = dest_id; + goto LAB_2304a0b2; + } + } + } + return -0x16; +} + + + +int hci_driver_send(net_buf *buf) + +{ + int iVar1; + + if (*(short *)((int)&buf->field_4 + 4) == 0) { + printf("Empty HCI packet\r\n"); + iVar1 = -0x16; + } + else { + iVar1 = bl_onchiphci_send_2_controller(buf); + net_buf_unref(buf); + } + return iVar1; +} + + + +int hci_driver_open(void) + +{ + k_queue_init((k_queue *)&recv_fifo,0x14); + k_thread_create(&recv_thread_data,"recv_thread",0xc00,recv_thread,0x1c); + return 0; +} + + + +void recv_thread(void *p1) + +{ + net_buf *buf; + + do { + buf = net_buf_get(&recv_fifo,-1); + if (buf != (net_buf *)0x0) { + bt_recv(buf); + } + k_yield(); + } while( true ); +} + + + +void hci_driver_enque_recvq(net_buf *buf) + +{ + net_buf_put(&recv_fifo,buf); + return; +} + + + +int hci_driver_init(void) + +{ + bt_hci_driver_register(&drv); + return 0; +} + + + +int atomic_test_bit(atomic_t *target,int bit) + +{ + atomic_val_t aVar1; + + aVar1 = atomic_get(target); + return aVar1 >> (bit & 0x1fU) & 1; +} + + + +void tx_free(bt_conn_tx *tx) + +{ + tx->cb = (bt_conn_tx_cb_t *)0x0; + tx->user_data = (void *)0x0; + tx->pending_no_cb = 0; + k_queue_append((k_queue *)&free_tx,tx); + return; +} + + + +// WARNING: Type propagation algorithm not settling + +int send_frag(ushort *param_1,net_buf *param_2,int param_3,int param_4) + +{ + ushort uVar1; + bt_conn_tx *tx; + undefined *puVar2; + bt_conn_tx *pbVar3; + int iVar4; + bt_conn_tx *pbVar5; + undefined4 uVar6; + int *unaff_s6; + + tx = *(bt_conn_tx **)param_2->user_data; + k_sem_take(&bt_dev.le.pkts,0xffffffff); + if (*(char *)((int)param_1 + 0xd) == '\x04') { + puVar2 = (undefined *)net_buf_simple_push((net_buf_simple *)¶m_2->field_4,4); + uVar1 = *param_1; + *puVar2 = (char)uVar1; + puVar2[1] = (byte)((uint)(param_3 << 0xc) >> 8) | (byte)((uint)uVar1 >> 8); + iVar4 = (uint)*(ushort *)((int)¶m_2->field_4 + 4) - 4; + puVar2[2] = (char)((uint)(iVar4 * 0x10000) >> 0x10); + puVar2[3] = (char)((uint)iVar4 >> 8); + irq_lock(); + if (tx == (bt_conn_tx *)0x0) { + iVar4 = *(int *)(param_1 + 0xc); + if (iVar4 == 0) { + unaff_s6 = (int *)(param_1 + 0xe); + iVar4 = *(int *)(param_1 + 0xe); + } + else { + unaff_s6 = (int *)(iVar4 + 0xc); + iVar4 = *(int *)(iVar4 + 0xc); + } + *unaff_s6 = iVar4 + 1; + } + else { + tx->node = 0; + if (*(bt_conn_tx **)(param_1 + 0xc) == (bt_conn_tx *)0x0) { + *(bt_conn_tx **)(param_1 + 0xc) = tx; + *(bt_conn_tx **)(param_1 + 10) = tx; + } + else { + *(bt_conn_tx **)&(*(bt_conn_tx **)(param_1 + 0xc))->node = tx; + *(bt_conn_tx **)(param_1 + 0xc) = tx; + } + } + irq_unlock(); + param_2->user_data[0] = '\x02'; + iVar4 = bt_send(param_2); + if (iVar4 == 0) { + return 1; + } + printf("Unable to send to driver (err %d)\r\n"); + irq_lock(); + if (tx == (bt_conn_tx *)0x0) { + *unaff_s6 = *unaff_s6 + -1; + } + else { + pbVar3 = (bt_conn_tx *)0x0; + pbVar5 = *(bt_conn_tx **)(param_1 + 10); + while (pbVar5 != (bt_conn_tx *)0x0) { + if (tx == pbVar5) { + uVar6 = tx->node; + if (pbVar3 == (bt_conn_tx *)0x0) { + *(undefined4 *)(param_1 + 10) = uVar6; + if (tx == *(bt_conn_tx **)(param_1 + 0xc)) { + *(undefined4 *)(param_1 + 0xc) = uVar6; + } + } + else { + pbVar3->node = uVar6; + if (tx == *(bt_conn_tx **)(param_1 + 0xc)) { + *(bt_conn_tx **)(param_1 + 0xc) = pbVar3; + } + } + tx->node = 0; + break; + } + pbVar3 = pbVar5; + pbVar5 = *(bt_conn_tx **)&pbVar5->node; + } + } + irq_unlock(); + } + k_sem_give(&bt_dev.le.pkts); + if (tx != (bt_conn_tx *)0x0) { + tx_free(tx); + } + if (param_4 != 0) { + net_buf_unref(param_2); + param_4 = 0; + } + return param_4; +} + + + +void notify_connected(bt_conn *conn) + +{ + bt_conn_cb *pbVar1; + + pbVar1 = callback_list; + while (pbVar1 != (bt_conn_cb *)0x0) { + if (pbVar1->connected != (anon_subr_void_bt_conn_ptr_u8_t_for_connected *)0x0) { + (*pbVar1->connected)(conn,conn->err); + } + pbVar1 = (bt_conn_cb *)pbVar1[1].disconnected; + } + if (conn->err == '\0') { + bt_gatt_connected(conn); + return; + } + return; +} + + + +void bt_conn_reset_rx_state(bt_conn *conn) + +{ + if (conn->rx_len != 0) { + net_buf_unref(conn->rx); + conn->rx = (net_buf *)0x0; + conn->rx_len = 0; + return; + } + return; +} + + + +void conn_cleanup(bt_conn *conn) + +{ + net_buf *buf; + void *pvVar1; + + while (buf = net_buf_get((k_fifo *)(k_queue *)&conn->tx_queue,0), buf != (net_buf *)0x0) { + if (*(bt_conn_tx **)buf->user_data != (bt_conn_tx *)0x0) { + tx_free(*(bt_conn_tx **)buf->user_data); + } + net_buf_unref(buf); + } + bt_conn_reset_rx_state(conn); + k_delayed_work_submit(&conn->update_work,0); + k_queue_free((k_queue *)&conn->tx_queue); + pvVar1 = (conn->update_work).timer.timer.hdl; + (conn->tx_queue)._queue.hdl = (void *)0x0; + if (pvVar1 != (void *)0x0) { + k_delayed_work_del_timer(&conn->update_work); + return; + } + return; +} + + + +void tx_notify(bt_conn *conn) + +{ + bt_conn_tx *tx; + uint uVar1; + void *pvVar2; + _snode *p_Var3; + bt_conn_tx_cb_t *pbVar4; + + while( true ) { + uVar1 = irq_lock(); + tx = (bt_conn_tx *)(conn->tx_complete).head; + if (tx == (bt_conn_tx *)0x0) break; + p_Var3 = (tx->node).next; + *(_snode **)&(conn->tx_complete).head = p_Var3; + if (tx == (bt_conn_tx *)(conn->tx_complete).tail) { + *(_snode **)&(conn->tx_complete).tail = p_Var3; + } + irq_unlock(uVar1); + pvVar2 = tx->user_data; + pbVar4 = tx->cb; + tx_free(tx); + (*pbVar4)(conn,pvVar2); + } + irq_unlock(); + return; +} + + + +void tx_complete_work(k_work *work) + +{ + tx_notify((bt_conn *)work[-4].flags); + return; +} + + + +k_sem * bt_conn_get_pkts(bt_conn *conn) + +{ + return &bt_dev.le.pkts; +} + + + +void notify_le_param_updated(bt_conn *conn) + +{ + bt_conn_cb *pbVar1; + int iVar2; + + iVar2 = atomic_test_bit(conn->flags,9); + pbVar1 = callback_list; + if ((((iVar2 != 0) && (*(ushort *)(conn->field_20 + 0x18) <= *(ushort *)(conn->field_20 + 0x16))) + && (*(ushort *)(conn->field_20 + 0x16) <= *(ushort *)(conn->field_20 + 0x1a))) && + (*(int *)(conn->field_20 + 0x1c) == *(int *)(conn->field_20 + 0x20))) { + atomic_and(conn->flags,-0x201); + pbVar1 = callback_list; + } + while (pbVar1 != (bt_conn_cb *)0x0) { + if (pbVar1->le_param_updated != + (anon_subr_void_bt_conn_ptr_u16_t_u16_t_u16_t_for_le_param_updated *)0x0) { + (*pbVar1->le_param_updated) + (conn,*(u16_t *)(conn->field_20 + 0x16),*(u16_t *)(conn->field_20 + 0x1c), + *(u16_t *)(conn->field_20 + 0x1e)); + } + pbVar1 = (bt_conn_cb *)pbVar1[1].disconnected; + } + return; +} + + + +_Bool le_param_req(bt_conn *conn,bt_le_conn_param *param) + +{ + bt_conn_cb *pbVar1; + _Bool _Var2; + _Bool _Var3; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + + _Var2 = bt_le_conn_params_valid(param); + pbVar1 = callback_list; + if (CONCAT31(extraout_var,_Var2) == 0) { +LAB_2304a4e4: + _Var2 = false; + } + else { + while (pbVar1 != (bt_conn_cb *)0x0) { + if ((pbVar1->le_param_req != + (anon_subr__Bool_bt_conn_ptr_bt_le_conn_param_ptr_for_le_param_req *)0x0) && + ((_Var3 = (*pbVar1->le_param_req)(conn,param), CONCAT31(extraout_var_00,_Var3) == 0 || + (_Var3 = bt_le_conn_params_valid(param), CONCAT31(extraout_var_01,_Var3) == 0)))) + goto LAB_2304a4e4; + pbVar1 = (bt_conn_cb *)pbVar1[1].disconnected; + } + } + return _Var2; +} + + + +_Bool le_check_valid_conn(void) + +{ + atomic_val_t aVar1; + bool bVar2; + + aVar1 = atomic_get(&conns[0].ref); + bVar2 = true; + if (aVar1 == 0) { + aVar1 = atomic_get(&conns[1].ref); + bVar2 = aVar1 != 0; + } + return (_Bool)bVar2; +} + + + +void bt_conn_identity_resolved(bt_conn *conn) + +{ + bt_conn_cb *pbVar1; + byte *pbVar2; + + pbVar2 = conn->field_20 + 0xe; + if (conn->role != '\0') { + pbVar2 = conn->field_20 + 7; + } + pbVar1 = callback_list; + while (pbVar1 != (bt_conn_cb *)0x0) { + if (pbVar1->_next != (bt_conn_cb *)0x0) { + (*(code *)pbVar1->_next)(conn,pbVar2,conn->field_20); + } + pbVar1 = (bt_conn_cb *)pbVar1[1].disconnected; + } + return; +} + + + +int bt_conn_le_start_encryption(bt_conn *conn,u8_t *rand,u8_t *ediv,u8_t *ltk,size_t len) + +{ + u16_t uVar1; + net_buf *buf; + undefined *puVar2; + int iVar3; + + buf = bt_hci_cmd_create(0x2019,'\x1c'); + if (buf != (net_buf *)0x0) { + puVar2 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,0x1c); + uVar1 = conn->handle; + *puVar2 = (char)uVar1; + puVar2[1] = (char)(uVar1 >> 8); + memcpy(puVar2 + 2,rand,8); + memcpy(puVar2 + 10,ediv,2); + memcpy(puVar2 + 0xc,ltk,len); + if (len < 0x10) { + memset(puVar2 + 0xc + len,0,0x10 - len); + } + iVar3 = bt_hci_cmd_send_sync(0x2019,buf,(net_buf **)0x0); + return iVar3; + } + return -0x37; +} + + + +void bt_conn_security_changed(bt_conn *param_1,int param_2) + +{ + bt_conn_cb *pbVar1; + + pbVar1 = callback_list; + while (pbVar1 != (bt_conn_cb *)0x0) { + if (pbVar1[1].connected != (anon_subr_void_bt_conn_ptr_u8_t_for_connected *)0x0) { + (*pbVar1[1].connected)(param_1,param_1->sec_level); + } + pbVar1 = (bt_conn_cb *)pbVar1[1].disconnected; + } + if ((param_2 == 0) && (1 < (byte)param_1->sec_level)) { + bt_keys_update_usage(param_1->id,(bt_addr_le_t *)param_1->field_20); + return; + } + return; +} + + + +int bt_conn_set_security(bt_conn *conn,bt_security_t sec) + +{ + int iVar1; + undefined3 in_register_0000202d; + + if (conn->state == BT_CONN_CONNECTED) { + iVar1 = 0; + if (((uint)(byte)conn->sec_level < CONCAT31(in_register_0000202d,sec)) && + ((uint)(byte)conn->required_sec_level < CONCAT31(in_register_0000202d,sec))) { + if (sec < '\0') { + atomic_or(conn->flags,0x800); + } + else { + atomic_and(conn->flags,-0x801); + } + conn->required_sec_level = sec & 0x7f; + iVar1 = bt_smp_start_security(conn); + if (iVar1 != 0) { + conn->required_sec_level = conn->sec_level; + } + } + return iVar1; + } + return -0x39; +} + + + +bt_security_t bt_conn_get_security(bt_conn *conn) + +{ + return conn->sec_level; +} + + + +void bt_conn_cb_register(bt_conn_cb *cb) + +{ + bt_conn_cb *pbVar1; + + pbVar1 = cb; + *(bt_conn_cb **)&cb[1].disconnected = callback_list; + callback_list = pbVar1; + return; +} + + + +void bt_conn_recv(bt_conn *conn,net_buf *buf,u8_t flags) + +{ + ushort uVar1; + char *fmt; + size_t sVar2; + undefined3 in_register_00002031; + int iVar3; + uint uVar4; + + iVar3 = CONCAT31(in_register_00002031,flags); + tx_notify(conn); + if (iVar3 == 1) { + if (conn->rx_len == 0) { + fmt = "Unexpected L2CAP continuation\r\n"; + } + else { + uVar4 = (uint)*(ushort *)((int)&buf->field_4 + 4); + if (conn->rx_len < uVar4) { + fmt = "L2CAP data overflow\r\n"; + } + else { + sVar2 = net_buf_simple_tailroom((net_buf_simple *)&conn->rx->field_4); + if (uVar4 <= sVar2) { + net_buf_simple_add_mem + ((net_buf_simple *)&conn->rx->field_4,*(void **)&buf->field_4, + (uint)*(ushort *)((int)&buf->field_4 + 4)); + conn->rx_len = conn->rx_len - *(short *)((int)&buf->field_4 + 4); + net_buf_unref(buf); + if (conn->rx_len != 0) { + return; + } + buf = conn->rx; + conn->rx_len = 0; + conn->rx = (net_buf *)0x0; + goto LAB_2304a814; + } + fmt = "Not enough buffer space for L2CAP data\r\n"; + } + } + printf(fmt); + } + else { + if (iVar3 == 2) { + uVar1 = **(ushort **)&buf->field_4; + if (conn->rx_len != 0) { + printf("Unexpected first L2CAP frame\r\n"); + bt_conn_reset_rx_state(conn); + } + uVar4 = ((uint)uVar1 - (uint)*(ushort *)((int)&buf->field_4 + 4)) + 4; + conn->rx_len = (u16_t)(uVar4 * 0x10000 >> 0x10); + if ((uVar4 & 0xffff) != 0) { + conn->rx = buf; + return; + } +LAB_2304a814: + if ((uint)**(ushort **)&buf->field_4 + 4 == (uint)*(ushort *)((int)&buf->field_4 + 4)) { + bt_l2cap_recv(conn,buf); + return; + } + printf("ACL len mismatch (%u != %u)\r\n"); + goto LAB_2304a7aa; + } + printf("Unexpected ACL flags (0x%02x)\r\n",iVar3); + } + bt_conn_reset_rx_state(conn); +LAB_2304a7aa: + net_buf_unref(buf); + return; +} + + + +int bt_conn_send_cb(bt_conn *conn,net_buf *buf,bt_conn_tx_cb_t *cb,void *user_data) + +{ + int iVar1; + bt_conn_tx *tx; + + if (conn->state == BT_CONN_CONNECTED) { + if (cb == (bt_conn_tx_cb_t *)0x0) { + *(undefined4 *)buf->user_data = 0; + } + else { + tx = (bt_conn_tx *)k_queue_get((k_queue *)&free_tx,-1); + if (tx == (bt_conn_tx *)0x0) { + printf("Unable to allocate TX context\r\n"); + net_buf_unref(buf); + return -0x37; + } + if (conn->state != BT_CONN_CONNECTED) { + printf("Disconnected while allocating context\r\n"); + net_buf_unref(buf); + tx_free(tx); + goto LAB_2304a888; + } + tx->cb = cb; + tx->user_data = user_data; + tx->pending_no_cb = 0; + *(bt_conn_tx **)buf->user_data = tx; + } + net_buf_put(&conn->tx_queue,buf); + k_sem_give(&g_poll_sem); + iVar1 = 0; + } + else { + printf("not connected!\r\n"); + net_buf_unref(buf); +LAB_2304a888: + iVar1 = -0x39; + } + return iVar1; +} + + + +int bt_conn_prepare_events(k_poll_event *events) + +{ + int iVar1; + int iVar2; + atomic_val_t aVar3; + uint uVar4; + + conn_change.signaled = 0; + k_poll_event_init(events,1,0,&conn_change); + aVar3 = atomic_get(&conns[0].ref); + iVar1 = 1; + if (aVar3 != 0) { + if ((conns[0].state == BT_CONN_DISCONNECTED) && + (uVar4 = atomic_and(conns[0].flags,-0x41), (uVar4 & 0x40) != 0)) { + conn_cleanup(conns); + iVar1 = 1; + } + else { + iVar1 = 1; + if (conns[0].state == BT_CONN_CONNECTED) { + k_poll_event_init(events + 1,3,0,&conns[0].tx_queue); + *(undefined *)&events[1].field_0xc = 1; + iVar1 = 2; + } + } + } + aVar3 = atomic_get(&conns[1].ref); + iVar2 = iVar1; + if (aVar3 != 0) { + if ((conns[1].state == BT_CONN_DISCONNECTED) && + (uVar4 = atomic_and(conns[1].flags,-0x41), (uVar4 & 0x40) != 0)) { + conn_cleanup(conns + 1); + } + else { + if (conns[1].state == BT_CONN_CONNECTED) { + iVar2 = iVar1 + 1; + k_poll_event_init(events + iVar1,3,0,&conns[1].tx_queue); + *(undefined *)&events[iVar1].field_0xc = 1; + } + } + } + return iVar2; +} + + + +bt_conn * bt_conn_add_le(u8_t id,bt_addr_le_t *peer) + +{ + int iVar1; + atomic_val_t aVar2; + + iVar1 = atomic_get(&conns[0].ref); + if (iVar1 != 0) { + aVar2 = atomic_get(&conns[1].ref); + if (aVar2 != 0) { + return (bt_conn *)0x0; + } + iVar1 = 1; + } + memset(conns + iVar1,0,0xa0); + k_delayed_work_init(&conns[iVar1].update_work,conn_update_timeout); + k_work_init(&conns[iVar1].tx_complete_work,tx_complete_work); + atomic_set(&conns[iVar1].ref,1); + conns[iVar1].id = id; + memcpy(conns[iVar1].field_20,peer,7); + conns[iVar1].sec_level = BT_SECURITY_LOW; + conns[iVar1].required_sec_level = BT_SECURITY_LOW; + conns[iVar1].type = '\x01'; + *(undefined4 *)(conns[iVar1].field_20 + 0x18) = 0x280018; + return conns + iVar1; +} + + + +void bt_conn_set_state(bt_conn *conn,bt_conn_state_t state) + +{ + bt_conn_state_t bVar1; + bt_conn_tx *tx; + uint uVar2; + undefined3 in_register_0000202d; + _snode *p_Var3; + + bVar1 = conn->state; + if ((uint)bVar1 == CONCAT31(in_register_0000202d,state)) { + printf("no transition\r\n"); + return; + } + conn->state = state; + if (bVar1 == BT_CONN_DISCONNECTED) { + atomic_inc(&conn->ref); + } + else { + if ((bVar1 == BT_CONN_CONNECT) && (conn->type == '\x01')) { + k_delayed_work_cancel(&conn->update_work); + } + } + switch(conn->state) { + case BT_CONN_DISCONNECTED: + if (conn->type != '\x04') { + if (((uint)bVar1 - 4 & 0xff) < 2) { + do { + uVar2 = irq_lock(); + if (conn->pending_no_cb == 0) { + tx = (bt_conn_tx *)(conn->tx_pending).head; + if (tx != (bt_conn_tx *)0x0) { + p_Var3 = (tx->node).next; + *(_snode **)&(conn->tx_pending).head = p_Var3; + if (tx == (bt_conn_tx *)(conn->tx_pending).tail) { + *(_snode **)&(conn->tx_pending).tail = p_Var3; + } + } + irq_unlock(uVar2); + if (tx == (bt_conn_tx *)0x0) { + tx_notify(conn); + if (conn->type == '\x01') { + k_delayed_work_cancel(&conn->update_work); + } + atomic_or(conn->flags,0x40); + k_poll_signal_raise(&conn_change,0); + return; + } + irq_lock(); + conn->pending_no_cb = tx->pending_no_cb; + tx->pending_no_cb = 0; + irq_unlock(); + tx_free(tx); + } + else { + conn->pending_no_cb = conn->pending_no_cb - 1; + irq_unlock(); + } + k_sem_give(&bt_dev.le.pkts); + } while( true ); + } + if (bVar1 != BT_CONN_CONNECT) { + if ((bVar1 != BT_CONN_CONNECT_SCAN) && (bVar1 != BT_CONN_CONNECT_DIR_ADV)) { + return; + } + if (conn->err == '\0') goto LAB_2304ab78; + } + notify_connected(conn); + } +LAB_2304ab78: + atomic_dec(&conn->ref); + return; + case BT_CONN_CONNECT_SCAN: + case BT_CONN_CONNECT_DIR_ADV: + case BT_CONN_DISCONNECT: + break; + case BT_CONN_CONNECT: + if (conn->type == '\x01') { + k_delayed_work_submit(&conn->update_work,3000); + return; + } + break; + case BT_CONN_CONNECTED: + if (conn->type != '\x04') { + k_queue_init((k_queue *)&conn->tx_queue,0x14); + k_poll_signal_raise(&conn_change,0); + (conn->channels).head = (sys_snode_t *)0x0; + (conn->channels).tail = (sys_snode_t *)0x0; + bt_l2cap_connected(conn); + notify_connected(conn); + return; + } + break; + default: + printf("no valid (%u) state was set\r\n",CONCAT31(in_register_0000202d,state)); + return; + } + return; +} + + + +bt_conn * bt_conn_lookup_handle(u16_t handle) + +{ + bt_conn *pbVar1; + undefined2 in_register_0000202a; + atomic_val_t aVar2; + int iVar3; + + pbVar1 = conns; + aVar2 = atomic_get(&conns[0].ref); + if (((aVar2 == 0) || (1 < (byte)(conns[0].state + ~BT_CONN_CONNECT))) || + ((uint)conns[0].handle != CONCAT22(in_register_0000202a,handle))) { + pbVar1 = conns + 1; + aVar2 = atomic_get(&conns[1].ref); + if (aVar2 == 0) { + return (bt_conn *)0x0; + } + if (1 < (byte)(conns[1].state + ~BT_CONN_CONNECT)) { + return (bt_conn *)0x0; + } + if ((uint)conns[1].handle != CONCAT22(in_register_0000202a,handle)) { + return (bt_conn *)0x0; + } + iVar3 = 0xa0; + } + else { + iVar3 = 0; + } + atomic_inc(&pbVar1->ref); + return (bt_conn *)((int)&conns[0].handle + iVar3); +} + + + +int bt_conn_addr_le_cmp(bt_conn *conn,bt_addr_le_t *peer) + +{ + int iVar1; + + iVar1 = memcmp(peer,conn->field_20,7); + if (iVar1 != 0) { + iVar1 = 0x7e; + if (conn->role != '\0') { + iVar1 = 0x77; + } + iVar1 = memcmp(peer,(void *)((int)&conn->handle + iVar1),7); + return iVar1; + } + return 0; +} + + + +bt_conn * bt_conn_lookup_state_le(bt_addr_le_t *peer,bt_conn_state_t state) + +{ + atomic_val_t aVar1; + int iVar2; + undefined3 in_register_0000202d; + int iVar3; + + aVar1 = atomic_get(&conns[0].ref); + if ((((aVar1 == 0) || (conns[0].type != '\x01')) || + ((peer != (bt_addr_le_t *)0x0 && (iVar2 = bt_conn_addr_le_cmp(conns,peer), iVar2 != 0)))) || + ((uint)conns[0].state != CONCAT31(in_register_0000202d,state))) { + aVar1 = atomic_get(&conns[1].ref); + if (((aVar1 == 0) || (conns[1].type != '\x01')) || + (((peer != (bt_addr_le_t *)0x0 && (iVar2 = bt_conn_addr_le_cmp(conns + 1,peer), iVar2 != 0)) + || ((uint)conns[1].state != CONCAT31(in_register_0000202d,state))))) { + return (bt_conn *)0x0; + } + iVar2 = 0x5b4; + iVar3 = 0xa0; + } + else { + iVar2 = 0x514; + iVar3 = 0; + } + atomic_inc((atomic_t *)(net_buf_friend_buf_pool[6].user_data + iVar2 + 8)); + return (bt_conn *)((int)&conns[0].handle + iVar3); +} + + + +bt_conn * bt_conn_lookup_addr_le(u8_t id,bt_addr_le_t *peer) + +{ + bt_conn *pbVar1; + bt_conn *pbVar2; + undefined3 in_register_00002029; + atomic_val_t aVar3; + int iVar4; + + pbVar1 = conns; + aVar3 = atomic_get(&conns[0].ref); + if ((((aVar3 == 0) || (conns[0].type != '\x01')) || + ((uint)conns[0].id != CONCAT31(in_register_00002029,id))) || + (iVar4 = bt_conn_addr_le_cmp(conns,peer), iVar4 != 0)) { + pbVar1 = conns + 1; + aVar3 = atomic_get(&conns[1].ref); + if (((aVar3 != 0) && (conns[1].type == '\x01')) && + ((uint)conns[1].id == CONCAT31(in_register_00002029,id))) { + pbVar2 = conns + 1; + iVar4 = bt_conn_addr_le_cmp(conns + 1,peer); + if (iVar4 == 0) goto LAB_2304ae70; + } + pbVar2 = (bt_conn *)0x0; + } + else { + pbVar2 = conns; +LAB_2304ae70: + atomic_inc(&pbVar1->ref); + } + return pbVar2; +} + + + +bt_conn * bt_conn_lookup_state_le(bt_addr_le_t *peer,bt_conn_state_t state) + +{ + atomic_val_t aVar1; + int iVar2; + undefined3 in_register_0000202d; + int iVar3; + + aVar1 = atomic_get(&conns[0].ref); + if ((((aVar1 == 0) || (conns[0].type != '\x01')) || + ((peer != (bt_addr_le_t *)0x0 && (iVar2 = bt_conn_addr_le_cmp(conns,peer), iVar2 != 0)))) || + ((uint)conns[0].state != CONCAT31(in_register_0000202d,state))) { + aVar1 = atomic_get(&conns[1].ref); + if (((aVar1 == 0) || (conns[1].type != '\x01')) || + (((peer != (bt_addr_le_t *)0x0 && (iVar2 = bt_conn_addr_le_cmp(conns + 1,peer), iVar2 != 0)) + || ((uint)conns[1].state != CONCAT31(in_register_0000202d,state))))) { + return (bt_conn *)0x0; + } + iVar2 = 0x5b4; + iVar3 = 0xa0; + } + else { + iVar2 = 0x514; + iVar3 = 0; + } + atomic_inc((atomic_t *)(net_buf_friend_buf_pool[6].user_data + iVar2 + 8)); + return (bt_conn *)((int)&conns[0].handle + iVar3); +} + + + +void bt_conn_foreach(int type,anon_subr_void_bt_conn_ptr_void_ptr *func,void *data) + +{ + atomic_val_t aVar1; + + aVar1 = atomic_get(&conns[0].ref); + if ((aVar1 != 0) && (((uint)conns[0].type & type) != 0)) { + (*func)(conns,data); + } + aVar1 = atomic_get(&conns[1].ref); + if ((aVar1 != 0) && (((uint)conns[1].type & type) != 0)) { + // WARNING: Could not recover jumptable at 0x2304aefe. Too many branches + // WARNING: Treating indirect jump as call + (*func)((bt_conn *)0x4201556c,data); + return; + } + return; +} + + + +void bt_conn_disconnect_all(u8_t id) + +{ + u8_t auStack17 [13]; + + auStack17[0] = id; + bt_conn_foreach(7,disconnect_all,auStack17); + return; +} + + + +bt_conn * bt_conn_ref(bt_conn *conn) + +{ + atomic_inc(&conn->ref); + return conn; +} + + + +void bt_conn_unref(bt_conn *conn) + +{ + atomic_dec(&conn->ref); + return; +} + + + +bt_addr_le_t * bt_conn_get_dst(bt_conn *conn) + +{ + return (bt_addr_le_t *)conn->field_20; +} + + + +int bt_conn_get_info(bt_conn *conn,bt_conn_info *info) + +{ + info->type = conn->type; + info->role = conn->role; + info->id = conn->id; + if (conn->type == '\x01') { + *(byte **)(info->field_3 + 4) = conn->field_20; + *(bt_addr_le_t **)info->field_3 = bt_dev.id_addr + conn->id; + if (conn->role == '\0') { + *(byte **)(info->field_3 + 8) = conn->field_20 + 7; + *(byte **)(info->field_3 + 0xc) = conn->field_20 + 0xe; + } + else { + *(byte **)(info->field_3 + 8) = conn->field_20 + 0xe; + *(byte **)(info->field_3 + 0xc) = conn->field_20 + 7; + } + *(undefined2 *)(info->field_3 + 0x10) = *(undefined2 *)(conn->field_20 + 0x16); + *(undefined2 *)(info->field_3 + 0x12) = *(undefined2 *)(conn->field_20 + 0x1c); + *(undefined2 *)(info->field_3 + 0x14) = *(undefined2 *)(conn->field_20 + 0x1e); + return 0; + } + return -0x16; +} + + + +int bt_conn_get_remote_dev_info(bt_conn_info *info) + +{ + int iVar1; + int iVar2; + atomic_val_t aVar3; + + iVar2 = atomic_get(&conns[0].ref); + if (iVar2 != 0) { + bt_conn_get_info(conns,info); + iVar2 = 1; + } + aVar3 = atomic_get(&conns[1].ref); + iVar1 = iVar2; + if (aVar3 != 0) { + iVar1 = iVar2 + 1; + bt_conn_get_info(conns + 1,info + iVar2); + } + return iVar1; +} + + + +int bt_conn_disconnect(bt_conn *conn,u8_t reason) + +{ + u16_t uVar1; + int iVar2; + net_buf *buf; + undefined *puVar3; + + switch((uint)conn->state - 1 & 0xff) { + case 0: + conn->err = reason; + bt_conn_set_state(conn,BT_CONN_DISCONNECTED); + bt_le_scan_update(false); + case 4: + iVar2 = 0; + break; + case 1: + conn->err = reason; + bt_conn_set_state(conn,BT_CONN_DISCONNECTED); + iVar2 = bt_le_adv_stop(); + return iVar2; + case 2: + k_delayed_work_cancel(&conn->update_work); + iVar2 = bt_hci_cmd_send(0x200e,(net_buf *)0x0); + return iVar2; + case 3: + buf = bt_hci_cmd_create(0x406,'\x03'); + iVar2 = -0x37; + if (buf != (net_buf *)0x0) { + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,3); + uVar1 = conn->handle; + puVar3[2] = reason; + *puVar3 = (char)uVar1; + puVar3[1] = (char)(uVar1 >> 8); + iVar2 = bt_hci_cmd_send(0x406,buf); + if (iVar2 == 0) { + bt_conn_set_state(conn,BT_CONN_DISCONNECT); + } + } + break; + default: + iVar2 = -0x39; + } + return iVar2; +} + + + +void disconnect_all(bt_conn *conn,void *data) + +{ + if ((conn->id == *(u8_t *)data) && (conn->state == BT_CONN_CONNECTED)) { + bt_conn_disconnect(conn,'\x13'); + return; + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: dst + +bt_conn * bt_conn_create_le(bt_addr_le_t *peer,bt_le_conn_param *param) + +{ + bt_conn_state_t bVar1; + _Bool _Var2; + int iVar3; + undefined3 extraout_var; + bt_conn *conn; + bt_addr_le_t *__src; + u8_t auStack24 [4]; + bt_addr_le_t dst; + + iVar3 = atomic_test_bit(bt_dev.flags,1); + if ((((iVar3 != 0) && (_Var2 = bt_le_conn_params_valid(param), CONCAT31(extraout_var,_Var2) != 0)) + && (iVar3 = atomic_test_bit(bt_dev.flags,0xb), iVar3 == 0)) && + (iVar3 = atomic_test_bit(bt_dev.flags,0xf), iVar3 == 0)) { + conn = bt_conn_lookup_addr_le('\0',peer); + if (conn == (bt_conn *)0x0) { + if ((byte)(peer->type - 2) < 2) { + memcpy(auStack24,peer,7); + auStack24[0] = auStack24[0] + -2; + } + else { + __src = bt_lookup_id_addr('\0',peer); + memcpy(auStack24,__src,7); + } + conn = bt_conn_add_le('\0',(bt_addr_le_t *)auStack24); + if (conn != (bt_conn *)0x0) goto start_scan; + } + else { + bVar1 = conn->state; + if (bVar1 == BT_CONN_CONNECT_SCAN) { + *(u16_t *)(conn->field_20 + 0x18) = param->interval_min; + *(u16_t *)(conn->field_20 + 0x1a) = param->interval_max; + *(u16_t *)(conn->field_20 + 0x1c) = param->latency; + *(u16_t *)(conn->field_20 + 0x1e) = param->timeout; + return conn; + } + if (bVar1 == BT_CONN_DISCONNECTED) { + printf("Found valid but disconnected conn object\r\n"); +start_scan: + *(u16_t *)(conn->field_20 + 0x18) = param->interval_min; + *(u16_t *)(conn->field_20 + 0x1a) = param->interval_max; + *(u16_t *)(conn->field_20 + 0x1c) = param->latency; + *(u16_t *)(conn->field_20 + 0x1e) = param->timeout; + bt_conn_set_state(conn,BT_CONN_CONNECT_SCAN); + bt_le_scan_update(true); + return conn; + } + if ((byte)(bVar1 + ~BT_CONN_CONNECT_DIR_ADV) < 2) { + return conn; + } + atomic_dec(&conn->ref); + } + } + return (bt_conn *)0x0; +} + + + +int bt_conn_le_conn_update(bt_conn *conn,bt_le_conn_param *param) + +{ + u16_t uVar1; + net_buf *buf; + undefined *__s; + int iVar2; + + buf = bt_hci_cmd_create(0x2013,'\x0e'); + if (buf != (net_buf *)0x0) { + __s = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,0xe); + memset(__s,0,0xe); + uVar1 = conn->handle; + *__s = (char)uVar1; + __s[1] = (char)(uVar1 >> 8); + uVar1 = param->interval_min; + __s[2] = (char)uVar1; + __s[3] = (char)(uVar1 >> 8); + uVar1 = param->interval_max; + __s[4] = (char)uVar1; + __s[5] = (char)(uVar1 >> 8); + uVar1 = param->latency; + __s[6] = (char)uVar1; + __s[7] = (char)(uVar1 >> 8); + uVar1 = param->timeout; + __s[8] = (char)uVar1; + __s[9] = (char)(uVar1 >> 8); + iVar2 = bt_hci_cmd_send_sync(0x2013,buf,(net_buf **)0x0); + return iVar2; + } + return -0x37; +} + + + +int send_conn_le_param_update(bt_conn *conn,bt_le_conn_param *param) + +{ + int iVar1; + + if (((((bt_dev.le.features[0] & 2) == 0) || ((conn->field_20[0x24] & 2) == 0)) || + (iVar1 = atomic_test_bit(conn->flags,10), iVar1 != 0)) && (conn->role != '\0')) { + iVar1 = bt_l2cap_update_conn_param(conn,param); + return iVar1; + } + iVar1 = bt_conn_le_conn_update(conn,param); + if (iVar1 == 0) { + *(u16_t *)(conn->field_20 + 0x20) = param->latency; + *(u16_t *)(conn->field_20 + 0x22) = param->timeout; + } + return iVar1; +} + + + +void conn_update_timeout(k_work *work) + +{ + bt_conn *conn; + uint uVar1; + bt_le_conn_param *param; + bt_conn_cb *pbVar2; + void *local_20; + atomic_t aStack28; + undefined4 uStack24; + undefined4 uStack20; + + param = (bt_le_conn_param *)&local_20; + conn = (bt_conn *)work[-7].flags; + if (*(char *)((int)work[-6].flags + 1) == '\0') { + bt_l2cap_disconnected(conn); + pbVar2 = callback_list; + while (pbVar2 != (bt_conn_cb *)0x0) { + if (pbVar2->disconnected != (anon_subr_void_bt_conn_ptr_u8_t_for_disconnected *)0x0) { + (*pbVar2->disconnected)(conn,*(u8_t *)work[-6].flags); + } + pbVar2 = (bt_conn_cb *)pbVar2[1].disconnected; + } + atomic_dec(work[-1].flags); + } + else { + if (*(char *)((int)work[-7].flags + 2) == '\x01') { + if (*(char *)((int)work[-7].flags + 3) == '\0') { + bt_hci_cmd_send(0x200e,(net_buf *)0x0); + } + else { + uVar1 = atomic_and((atomic_t *)(work + -6),-0x201); + if ((uVar1 & 0x200) == 0) { + uStack24 = DAT_4200ee84; + uStack20 = DAT_4200ee88; + param = (bt_le_conn_param *)&uStack24; + } + else { + local_20 = work[5]._reserved; + aStack28 = work[5].flags[0]; + } + send_conn_le_param_update(conn,param); + atomic_or((atomic_t *)(work + -6),0x100); + } + } + } + return; +} + + + +int bt_conn_le_param_update(bt_conn *conn,bt_le_conn_param *param) + +{ + int iVar1; + + if ((((param->interval_min <= *(ushort *)(conn->field_20 + 0x16)) && + (*(ushort *)(conn->field_20 + 0x16) <= param->interval_max)) && + (*(u16_t *)(conn->field_20 + 0x1c) == param->latency)) && + (*(u16_t *)(conn->field_20 + 0x1e) == param->timeout)) { + atomic_and(conn->flags,-0x201); + return -0x45; + } + if (conn->role != '\0') { + iVar1 = atomic_test_bit(conn->flags,8); + if (iVar1 == 0) { + *(u16_t *)(conn->field_20 + 0x18) = param->interval_min; + *(u16_t *)(conn->field_20 + 0x1a) = param->interval_max; + *(u16_t *)(conn->field_20 + 0x20) = param->latency; + *(u16_t *)(conn->field_20 + 0x22) = param->timeout; + atomic_or(conn->flags,0x200); + return 0; + } + } + iVar1 = send_conn_le_param_update(conn,param); + return iVar1; +} + + + +net_buf * bt_conn_create_pdu_timeout(net_buf_pool *pool,size_t reserve,s32_t timeout) + +{ + net_buf *pnVar1; + + if (pool == (net_buf_pool *)0x0) { + pool = &acl_tx_pool; + } + pnVar1 = net_buf_alloc_fixed(pool,timeout); + if (pnVar1 == (net_buf *)0x0) { + printf("Unable to allocate buffer: timeout %d\r\n",timeout); + } + else { + net_buf_simple_reserve((net_buf_simple *)&pnVar1->field_4,reserve + 5); + } + return pnVar1; +} + + + +net_buf * create_frag(net_buf *buf) + +{ + net_buf *buf_00; + size_t len; + int in_a1; + net_buf_simple *buf_01; + uint uVar1; + + buf_00 = bt_conn_create_pdu_timeout((net_buf_pool *)0x0,0,-1); + if (*(char *)&buf->field_0 == '\x04') { + *(undefined4 *)buf_00->user_data = 0; + uVar1 = (uint)bt_dev.le.mtu; + buf_01 = (net_buf_simple *)&buf_00->field_4; + len = net_buf_simple_tailroom(buf_01); + if (uVar1 < len) { + len = (size_t)bt_dev.le.mtu; + } + else { + len = net_buf_simple_tailroom(buf_01); + len = len & 0xffff; + } + net_buf_simple_add_mem(buf_01,*(void **)(in_a1 + 8),len); + net_buf_simple_pull((net_buf_simple *)(in_a1 + 8),len); + } + else { + net_buf_unref(buf_00); + buf_00 = (net_buf *)0x0; + } + return buf_00; +} + + + +void bt_conn_process_tx(bt_conn *param_1) + +{ + uint uVar1; + net_buf *buf; + int iVar2; + net_buf *pnVar3; + undefined4 uVar4; + + if ((param_1->state == BT_CONN_DISCONNECTED) && + (uVar1 = atomic_and(param_1->flags,-0x41), (uVar1 & 0x40) != 0)) { + conn_cleanup(param_1); + return; + } + buf = net_buf_get(¶m_1->tx_queue,0); + if (buf == (net_buf *)0x0) { + vAssertCalled(); + } + if (bt_dev.le.mtu < *(ushort *)((int)&buf->field_4 + 4)) { + pnVar3 = create_frag((net_buf *)¶m_1->state); + if (pnVar3 != (net_buf *)0x0) { + uVar4 = 0; + while (iVar2 = send_frag(param_1,uVar4,1), iVar2 != 0) { + if (*(ushort *)((int)&buf->field_4 + 4) <= bt_dev.le.mtu) { + uVar4 = 1; + goto LAB_2304b5da; + } + pnVar3 = create_frag((net_buf *)¶m_1->state); + if (pnVar3 == (net_buf *)0x0) break; + uVar4 = 1; + } + } + } + else { + uVar4 = 0; +LAB_2304b5da: + iVar2 = send_frag(param_1,buf,uVar4,0); + if (iVar2 != 0) { + return; + } + } + net_buf_unref(buf); + return; +} + + + +int bt_conn_auth_cb_register(bt_conn_auth_cb *cb) + +{ + bt_conn_auth_cb *pbVar1; + + if (cb == (bt_conn_auth_cb *)0x0) { + bt_auth = (bt_conn_auth_cb *)0x0; + pbVar1 = bt_auth; + } + else { + if (bt_auth != (bt_conn_auth_cb *)0x0) { + return -0x45; + } + pbVar1 = cb; + if (cb->cancel == (anon_subr_void_bt_conn_ptr_for_cancel *)0x0) { + if (cb->passkey_display != (anon_subr_void_bt_conn_ptr_uint_for_passkey_display *)0x0) { + return -0x16; + } + if (cb->passkey_entry != (anon_subr_void_bt_conn_ptr_for_passkey_entry *)0x0) { + return -0x16; + } + if (cb->passkey_confirm != (anon_subr_void_bt_conn_ptr_uint_for_passkey_confirm *)0x0) { + return -0x16; + } + pbVar1 = cb; + if (cb->pairing_confirm != (anon_subr_void_bt_conn_ptr_for_pairing_confirm *)0x0) { + return -0x16; + } + } + } + bt_auth = pbVar1; + return 0; +} + + + +int bt_conn_auth_passkey_entry(bt_conn *conn,uint passkey) + +{ + if ((bt_auth != (bt_conn_auth_cb *)0x0) && (conn->type == '\x01')) { + bt_smp_auth_passkey_entry(conn,passkey); + return 0; + } + return -0x16; +} + + + +int bt_conn_auth_passkey_confirm(bt_conn *conn) + +{ + int iVar1; + + if ((bt_auth != (bt_conn_auth_cb *)0x0) && (conn->type == '\x01')) { + iVar1 = bt_smp_auth_passkey_confirm(conn); + return iVar1; + } + return -0x16; +} + + + +int bt_conn_auth_cancel(bt_conn *conn) + +{ + int iVar1; + + if ((bt_auth != (bt_conn_auth_cb *)0x0) && (conn->type == '\x01')) { + iVar1 = bt_smp_auth_cancel(conn); + return iVar1; + } + return -0x16; +} + + + +int bt_conn_auth_pairing_confirm(bt_conn *conn) + +{ + int iVar1; + + if ((bt_auth != (bt_conn_auth_cb *)0x0) && (conn->type == '\x01')) { + iVar1 = bt_smp_auth_pairing_confirm(conn); + return iVar1; + } + return -0x16; +} + + + +u8_t bt_conn_index(bt_conn *conn) + +{ + return (u8_t)((char)((int)&conn[-0x699bbb].tx_pending >> 5) * -0x33); +} + + + +int bt_conn_init(void) + +{ + bt_conn *data; + bt_conn *pbVar1; + int iVar2; + atomic_val_t aVar3; + int iVar4; + + if (queue_inited == false) { + k_queue_init((k_queue *)&acl_tx_pool,2); + } + k_queue_init((k_queue *)&free_tx,0x14); + data = (bt_conn *)conn_tx; + do { + pbVar1 = (bt_conn *)&data->rx; + k_queue_append((k_queue *)&free_tx,data); + data = pbVar1; + } while (pbVar1 != conns); + bt_att_init(); + iVar2 = bt_smp_init(); + if (iVar2 == 0) { + bt_l2cap_init(); + aVar3 = atomic_get(&conns[0].ref); + if ((aVar3 != 0) && (iVar4 = atomic_test_bit(conns[0].flags,0), iVar4 != 0)) { + conns[0].id = '\0'; + bt_conn_set_state(conns,BT_CONN_CONNECT_SCAN); + } + aVar3 = atomic_get(&conns[1].ref); + if ((aVar3 != 0) && (iVar4 = atomic_test_bit(conns[1].flags,0), iVar4 != 0)) { + conns[1].id = '\0'; + bt_conn_set_state(conns + 1,BT_CONN_CONNECT_SCAN); + } + } + return iVar2; +} + + + +int bt_rand(void *buf,size_t len) + +{ + k_get_random_byte_array((uint8_t *)buf,len); + return 0; +} + + + +// WARNING: Variable defined which should be unmapped: s + +int bt_encrypt_le(u8_t *key,u8_t *plaintext,u8_t *enc_data) + +{ + u8_t uVar1; + int iVar2; + u8_t *puVar3; + u8_t *puVar4; + u8_t *puVar5; + u8_t auStack208 [4]; + u8_t tmp [16]; + tc_aes_key_sched_struct s; + + puVar3 = auStack208; + puVar4 = key + 0xf; + do { + puVar5 = puVar4 + -1; + *puVar3 = *puVar4; + puVar3 = puVar3 + 1; + puVar4 = puVar5; + } while (key + -1 != puVar5); + iVar2 = tc_aes128_set_encrypt_key((TCAesKeySched_t)(tmp + 0xc),auStack208); + if (iVar2 != 0) { + puVar3 = auStack208; + puVar4 = plaintext + 0xf; + do { + puVar5 = puVar4 + -1; + *puVar3 = *puVar4; + puVar3 = puVar3 + 1; + puVar4 = puVar5; + } while (puVar5 != plaintext + -1); + iVar2 = tc_aes_encrypt(enc_data,auStack208,(TCAesKeySched_t)(tmp + 0xc)); + if (iVar2 != 0) { + puVar4 = enc_data + 7; + puVar3 = enc_data + 0xf; + do { + uVar1 = *enc_data; + puVar5 = puVar3 + -1; + *enc_data = *puVar3; + *puVar3 = uVar1; + enc_data = enc_data + 1; + puVar3 = puVar5; + } while (puVar4 != puVar5); + return 0; + } + } + return -0x16; +} + + + +int bt_encrypt_be(u8_t *key,u8_t *plaintext,u8_t *enc_data) + +{ + int iVar1; + undefined auStack192 [4]; + tc_aes_key_sched_struct s; + + iVar1 = tc_aes128_set_encrypt_key((TCAesKeySched_t)auStack192,key); + if ((iVar1 != 0) && + (iVar1 = tc_aes_encrypt(enc_data,plaintext,(TCAesKeySched_t)auStack192), iVar1 != 0)) { + return 0; + } + return -0x16; +} + + + +void sys_slist_remove(sys_slist_t *list,sys_snode_t *prev_node,sys_snode_t *node) + +{ + sys_snode_t *psVar1; + + psVar1 = (sys_snode_t *)node->next; + if (prev_node == (sys_snode_t *)0x0) { + list->head = psVar1; + if (list->tail == node) { + list->tail = psVar1; + } + } + else { + *(sys_snode_t **)&prev_node->next = psVar1; + if (list->tail == node) { + list->tail = prev_node; + } + } + node->next = (_snode *)0x0; + return; +} + + + +u8_t found_attr(bt_gatt_attr *attr,void *user_data) + +{ + *(bt_gatt_attr **)user_data = attr; + return '\0'; +} + + + +u16_t find_static_attr(bt_gatt_attr *attr) + +{ + anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *paVar1; + bt_gatt_service_static *pbVar2; + uint uVar3; + + pbVar2 = &_1_gatt_svc; + uVar3 = 1; + do { + if (&att_fixed_chan <= pbVar2) { + return 0; + } + paVar1 = (anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *)0x0; + while( true ) { + if (paVar1 == ((bt_l2cap_fixed_chan *)pbVar2)->accept) break; + if (attr == (bt_gatt_attr *)((int)paVar1 * 0x14 + *(int *)pbVar2)) { + return (u16_t)((uint)(paVar1 + uVar3) & 0xffff); + } + paVar1 = paVar1 + 1; + } + pbVar2 = (bt_gatt_service_static *)&((bt_l2cap_fixed_chan *)pbVar2)->node; + uVar3 = (uint)(paVar1 + uVar3) & 0xffff; + } while( true ); +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void gatt_ccc_changed(bt_gatt_attr *attr,_bt_gatt_ccc_conflict2 *ccc) + +{ + ushort uVar1; + ushort uVar2; + + uVar1 = ccc->cfg[1].value; + uVar2 = ccc->cfg[0].value; + if (uVar2 < uVar1) { + uVar2 = uVar1; + } + if (ccc->value != uVar2) { + ccc->value = uVar2; + if (ccc->cfg_changed != (anon_subr_void_bt_gatt_attr_ptr_u16_t_for_cfg_changed *)0x0) { + // WARNING: Could not recover jumptable at 0x2304b93c. Too many branches + // WARNING: Treating indirect jump as call + (*ccc->cfg_changed)(); + return; + } + } + return; +} + + + +void gatt_indicate_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + undefined3 in_register_0000202d; + + // WARNING: Could not recover jumptable at 0x2304b948. Too many branches + // WARNING: Treating indirect jump as call + (**(code **)((int)user_data + 0x20)) + (*(undefined4 *)((int)user_data + 0x1c),CONCAT31(in_register_0000202d,err)); + return; +} + + + +void sc_restore_rsp(bt_conn *conn,bt_gatt_attr *attr,u8_t err) + +{ + return; +} + + + +void gatt_subscription_remove(bt_conn *conn,sys_snode_t *prev,bt_gatt_subscribe_params *params) + +{ + sys_slist_remove(&subscriptions,prev,¶ms->node); + // WARNING: Could not recover jumptable at 0x2304b97c. Too many branches + // WARNING: Treating indirect jump as call + (*params->notify)(conn,params,(void *)0x0,0); + return; +} + + + +void gatt_mtu_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + // WARNING: Could not recover jumptable at 0x2304b984. Too many branches + // WARNING: Treating indirect jump as call + (**(code **)((int)user_data + 0x18))(user_data); + return; +} + + + +void gatt_write_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + // WARNING: Could not recover jumptable at 0x2304b98c. Too many branches + // WARNING: Treating indirect jump as call + (**(code **)((int)user_data + 0x18))(user_data); + return; +} + + + +bt_gatt_ccc_cfg * find_ccc_cfg(bt_conn *conn,_bt_gatt_ccc_conflict2 *ccc) + +{ + int iVar1; + undefined4 uStack24; + undefined2 uStack20; + undefined uStack18; + + if (conn == (bt_conn *)0x0) { + uStack24 = 0; + uStack20 = 0; + uStack18 = 0; + iVar1 = memcmp(&ccc->cfg[0].peer,&uStack24,7); + if (iVar1 == 0) { +LAB_2304b9b2: + iVar1 = 0; + goto LAB_2304b9b4; + } + uStack24 = 0; + uStack20 = 0; + uStack18 = 0; + iVar1 = memcmp(&ccc->cfg[1].peer,&uStack24,7); + } + else { + if ((conn->id == ccc->cfg[0].id) && + (iVar1 = bt_conn_addr_le_cmp(conn,&ccc->cfg[0].peer), iVar1 == 0)) goto LAB_2304b9b2; + if (conn->id != ccc->cfg[1].id) { + return (bt_gatt_ccc_cfg *)0x0; + } + iVar1 = bt_conn_addr_le_cmp(conn,&ccc->cfg[1].peer); + } + if (iVar1 != 0) { + return (bt_gatt_ccc_cfg *)0x0; + } + iVar1 = 10; +LAB_2304b9b4: + return (bt_gatt_ccc_cfg *)(&ccc->cfg[0].id + iVar1); +} + + + +int gatt_notify(bt_conn *conn,u16_t handle,bt_gatt_notify_params_conflict2 *params) + +{ + net_buf *buf; + undefined *puVar1; + int iVar2; + + buf = bt_att_create_pdu(conn,'\x1b',(uint)params->len + 2); + if (buf != (net_buf *)0x0) { + puVar1 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + *puVar1 = (char)handle; + puVar1[1] = (char)(handle >> 8); + net_buf_simple_add((net_buf_simple *)&buf->field_4,(uint)params->len); + memcpy(puVar1 + 2,params->data,(uint)params->len); + iVar2 = bt_att_send(conn,buf,(bt_conn_tx_cb_t *)params->func,params->user_data); + return iVar2; + } + printf("No buffer available to send notification\r\n"); + return -0xc; +} + + + +void gatt_read_multiple_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + code *UNRECOVERED_JUMPTABLE; + undefined3 in_register_0000202d; + int iVar1; + undefined2 in_register_00002036; + + iVar1 = CONCAT31(in_register_0000202d,err); + UNRECOVERED_JUMPTABLE = *(code **)((int)user_data + 0x18); + if ((iVar1 == 0) && (CONCAT22(in_register_00002036,length) != 0)) { + (*UNRECOVERED_JUMPTABLE)(user_data,pdu,CONCAT22(in_register_00002036,length),0); + UNRECOVERED_JUMPTABLE = *(code **)((int)user_data + 0x18); + iVar1 = 0; + } + // WARNING: Could not recover jumptable at 0x2304bac8. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(conn,iVar1,user_data,0,0); + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void gatt_write_ccc_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + sys_snode_t sVar1; + undefined3 in_register_0000202d; + sys_snode_t prev; + sys_snode_t sVar2; + + atomic_and((atomic_t *)((int)user_data + 0x2c),-3); + if (CONCAT31(in_register_0000202d,err) == 0) { + // WARNING: Could not recover jumptable at 0x2304bb3c. Too many branches + // WARNING: Treating indirect jump as call + (**(code **)((int)user_data + 0x20))(conn,user_data,0,0); + return; + } + if (subscriptions.head != (sys_snode_t *)0x0) { + sVar1 = (sys_snode_t)(subscriptions.head)->next; + sVar2 = (sys_snode_t)subscriptions.head; + while( true ) { + prev = sVar1; + if (sVar2 == (sys_snode_t)((int)user_data + 0x30)) { + gatt_subscription_remove(conn,(sys_snode_t *)prev,(bt_gatt_subscribe_params *)user_data); + return; + } + if (prev == (sys_snode_t)0x0) break; + sVar1 = *(sys_snode_t *)prev; + sVar2 = prev; + } + } + return; +} + + + +int gatt_send(bt_conn *conn,net_buf *buf,bt_att_func_t *func,void *params) + +{ + int iVar1; + + if (params == (void *)0x0) { + iVar1 = bt_att_send(conn,buf,(bt_conn_tx_cb_t *)0x0,(void *)0x0); + } + else { + *(net_buf **)((int)params + 0x10) = buf; + *(bt_att_func_t **)((int)params + 4) = func; + *(undefined4 *)((int)params + 8) = 0; + iVar1 = bt_att_req_send(conn,(bt_att_req_conflict28 *)params); + } + if (iVar1 != 0) { + printf("Error sending ATT PDU: %d\r\n",iVar1); + } + return iVar1; +} + + + +int gatt_indicate(bt_conn *conn,u16_t handle,bt_gatt_indicate_params_conflict2 *params) + +{ + net_buf *buf; + undefined *puVar1; + int iVar2; + code *func; + + buf = bt_att_create_pdu(conn,'\x1d',(uint)params->len + 2); + if (buf != (net_buf *)0x0) { + puVar1 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + *puVar1 = (char)handle; + puVar1[1] = (char)(handle >> 8); + net_buf_simple_add((net_buf_simple *)&buf->field_4,(uint)params->len); + memcpy(puVar1 + 2,params->data,(uint)params->len); + if (params->func == (bt_gatt_indicate_func_t *)0x0) { + params = (bt_gatt_indicate_params_conflict2 *)0x0; + func = (bt_att_func_t *)0x0; + } + else { + func = gatt_indicate_rsp; + } + iVar2 = gatt_send(conn,buf,func,params); + return iVar2; + } + printf("No buffer available to send indication\r\n"); + return -0xc; +} + + + +undefined4 match_uuid(undefined4 param_1,undefined4 *param_2) + +{ + *param_2 = param_1; + return 0; +} + + + +void sc_indicate_rsp(bt_conn *conn,bt_gatt_attr *attr,u8_t err) + +{ + uint uVar1; + + atomic_and(gatt_sc.flags,-3); + uVar1 = atomic_get(gatt_sc.flags); + if ((uVar1 & 1) != 0) { + k_delayed_work_submit((k_delayed_work *)&gatt_sc.work,0); + return; + } + return; +} + + + +u8_t disconnected_cb(bt_gatt_attr *attr,void *user_data) + +{ + bool bVar1; + bt_addr_le_t *peer; + _Bool _Var2; + bt_conn *conn; + int iVar3; + undefined3 extraout_var; + void *pvVar4; + undefined4 uStack56; + undefined2 uStack52; + undefined uStack50; + + if (attr->write == bt_gatt_attr_write_ccc) { + pvVar4 = attr->user_data; + if (*(short *)((int)pvVar4 + 0x14) != 0) { + peer = (bt_addr_le_t *)((int)pvVar4 + 1); + bVar1 = false; + do { + if (*(short *)(peer + 1) != 0) { + if ((*(u8_t *)((int)user_data + 8) == peer[-1].a.val[5]) && + (iVar3 = bt_conn_addr_le_cmp((bt_conn *)user_data,peer), iVar3 == 0)) { + _Var2 = bt_addr_le_is_bonded + (*(u8_t *)((int)user_data + 8),(bt_addr_le_t *)((int)user_data + 0x70) + ); + if (CONCAT31(extraout_var,_Var2) == 0) { + uStack56 = 0; + uStack52 = 0; + uStack50 = 0; + memcpy(peer,&uStack56,7); + peer[-1].a.val[5] = '\0'; + *(undefined2 *)(peer + 1) = 0; + } + else { + memcpy(peer,(bt_addr_le_t *)((int)user_data + 0x70),7); + } + } + else { + conn = bt_conn_lookup_addr_le(peer[-1].a.val[5],peer); + if (conn != (bt_conn *)0x0) { + if (conn->state == BT_CONN_CONNECTED) { + bVar1 = true; + } + bt_conn_unref(conn); + } + } + } + peer = (bt_addr_le_t *)(peer[1].a.val + 2); + } while (peer != (bt_addr_le_t *)((int)pvVar4 + 0x15)); + if (!bVar1) { + *(undefined2 *)((int)pvVar4 + 0x14) = 0; + if (*(code **)((int)pvVar4 + 0x18) != (code *)0x0) { + (**(code **)((int)pvVar4 + 0x18))(attr,0); + } + } + } + return '\x01'; + } + return '\x01'; +} + + + +gatt_sc_cfg * find_sc_cfg(u8_t id,bt_addr_le_t *addr) + +{ + int iVar1; + undefined3 in_register_00002029; + int iVar2; + gatt_sc_cfg *pgVar3; + + pgVar3 = sc_cfg; + iVar1 = 0; + do { + if ((uint)pgVar3->id == CONCAT31(in_register_00002029,id)) { + iVar2 = memcmp(&pgVar3->peer,addr,7); + if (iVar2 == 0) { + return sc_cfg + iVar1; + } + } + iVar1 = iVar1 + 1; + pgVar3 = pgVar3 + 1; + } while (iVar1 != 4); + return (gatt_sc_cfg *)0x0; +} + + + +int gatt_write_ccc(bt_conn *conn,u16_t handle,u16_t value,bt_gatt_subscribe_params *params) + +{ + net_buf *buf; + undefined *puVar1; + int iVar2; + + buf = bt_att_create_pdu(conn,'\x12',4); + if (buf != (net_buf *)0x0) { + puVar1 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + *puVar1 = (char)handle; + puVar1[1] = (char)(handle >> 8); + net_buf_simple_add_le16((net_buf_simple *)&buf->field_4,value); + atomic_or(params->flags,2); + iVar2 = gatt_send(conn,buf,gatt_write_ccc_rsp,params); + return iVar2; + } + return -0xc; +} + + + +ssize_t read_appearance(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset) + +{ + size_t __n; + undefined2 in_register_00002036; + undefined2 in_register_0000203a; + uint uVar1; + undefined2 auStack18 [2]; + u16_t appearance; + + uVar1 = CONCAT22(in_register_0000203a,offset); + auStack18[0] = 0x341; + __n = 0xfffffff9; + if (uVar1 < 3) { + __n = 2 - uVar1; + if ((int)CONCAT22(in_register_00002036,len) < (int)(2 - uVar1)) { + __n = CONCAT22(in_register_00002036,len); + } + memcpy(buf,(void *)((int)auStack18 + uVar1),__n); + } + return __n; +} + + + +// WARNING: Could not reconcile some variable overlaps + +ssize_t read_ppcp(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset) + +{ + size_t __n; + undefined2 in_register_00002036; + undefined2 in_register_0000203a; + uint uVar1; + undefined4 uStack24; + anon_struct_for_ppcp ppcp; + + uVar1 = CONCAT22(in_register_0000203a,offset); + uStack24 = 0x280018; + ppcp._0_4_ = 0x1900000; + __n = 0xfffffff9; + if (uVar1 < 9) { + __n = 8 - uVar1; + if ((int)CONCAT22(in_register_00002036,len) < (int)(8 - uVar1)) { + __n = CONCAT22(in_register_00002036,len); + } + memcpy(buf,(void *)((int)&uStack24 + uVar1),__n); + } + return __n; +} + + + +ssize_t read_name(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset) + +{ + uint __n; + char *__s; + size_t sVar1; + undefined2 in_register_00002036; + undefined2 in_register_0000203a; + uint uVar2; + + uVar2 = CONCAT22(in_register_0000203a,offset); + __s = bt_get_name(); + sVar1 = strlen(__s); + __n = 0xfffffff9; + if (uVar2 <= (sVar1 & 0xffff)) { + __n = (sVar1 & 0xffff) - uVar2; + if ((int)CONCAT22(in_register_00002036,len) < (int)__n) { + __n = CONCAT22(in_register_00002036,len); + } + __n = __n & 0xffff; + memcpy(buf,__s + uVar2,__n); + } + return __n; +} + + + +ssize_t bt_gatt_attr_read_ccc(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset) + +{ + size_t __n; + bt_gatt_ccc_cfg *pbVar1; + undefined2 in_register_00002036; + undefined2 in_register_0000203a; + uint uVar2; + u16_t auStack18 [2]; + u16_t value; + + uVar2 = CONCAT22(in_register_0000203a,offset); + pbVar1 = find_ccc_cfg(conn,(_bt_gatt_ccc_conflict2 *)attr->user_data); + auStack18[0] = 0; + if (pbVar1 != (bt_gatt_ccc_cfg *)0x0) { + auStack18[0] = pbVar1->value; + } + __n = 0xfffffff9; + if (uVar2 < 3) { + __n = 2 - uVar2; + if ((int)CONCAT22(in_register_00002036,len) < (int)(2 - uVar2)) { + __n = CONCAT22(in_register_00002036,len); + } + memcpy(buf,(void *)((int)auStack18 + uVar2),__n); + } + return __n; +} + + + +ssize_t bt_gatt_attr_read_service(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset) + +{ + size_t __n; + char *pcVar1; + undefined2 in_register_00002036; + size_t sVar2; + undefined2 in_register_0000203a; + uint uVar3; + undefined2 *puVar4; + undefined2 auStack18 [2]; + u16_t uuid16; + + uVar3 = CONCAT22(in_register_0000203a,offset); + sVar2 = CONCAT22(in_register_00002036,len); + pcVar1 = (char *)attr->user_data; + if (*pcVar1 == '\0') { + auStack18[0] = *(undefined2 *)(pcVar1 + 2); + if (2 < uVar3) { + return -7; + } + __n = 2 - uVar3; + if ((int)sVar2 < (int)(2 - uVar3)) { + __n = sVar2; + } + puVar4 = auStack18; + } + else { + puVar4 = (undefined2 *)(pcVar1 + 1); + if (0x10 < uVar3) { + return -7; + } + __n = 0x10 - uVar3; + if ((int)sVar2 < (int)(0x10 - uVar3)) { + __n = sVar2; + } + } + memcpy(buf,(void *)((int)puVar4 + uVar3),__n); + return __n; +} + + + +void sc_save(u8_t id,bt_addr_le_t *peer,u16_t start,u16_t end) + +{ + ushort uVar1; + ushort uVar2; + gatt_sc_cfg *pgVar3; + undefined2 in_register_00002032; + undefined2 in_register_00002036; + undefined4 uStack40; + undefined2 uStack36; + u8_t uStack34; + + pgVar3 = find_sc_cfg(id,peer); + if (pgVar3 == (gatt_sc_cfg *)0x0) { + uStack40 = 0; + uStack36 = 0; + uStack34 = '\0'; + pgVar3 = find_sc_cfg('\0',(bt_addr_le_t *)&uStack40); + if (pgVar3 == (gatt_sc_cfg *)0x0) { + printf("unable to save SC: no cfg left\r\n"); + return; + } + pgVar3->id = id; + memcpy(&pgVar3->peer,peer,7); + } + uVar1 = (pgVar3->data).start; + uVar2 = (pgVar3->data).end; + if (uVar1 == 0) { + if (uVar2 == 0) { + (pgVar3->data).start = start; + goto LAB_2304c028; + } + } + else { + if (CONCAT22(in_register_00002032,start) < (uint)uVar1) { + (pgVar3->data).start = start; + } + } + if (CONCAT22(in_register_00002036,end) <= (uint)uVar2) { + return; + } +LAB_2304c028: + (pgVar3->data).end = end; + return; +} + + + +_Bool sc_ccc_cfg_write(bt_conn *conn,bt_gatt_attr *attr,u16_t value) + +{ + gatt_sc_cfg *__s; + undefined2 in_register_00002032; + + if (CONCAT22(in_register_00002032,value) == 2) { + sc_save(conn->id,(bt_addr_le_t *)conn->field_20,0,0); + } + else { + __s = find_sc_cfg(conn->id,(bt_addr_le_t *)conn->field_20); + if (__s != (gatt_sc_cfg *)0x0) { + memset(__s,0,0xc); + } + } + return true; +} + + + +u8_t notify_cb(bt_gatt_attr *attr,void *user_data) + +{ + bt_addr_le_t *peer; + gatt_sc_cfg *pgVar1; + _Bool _Var2; + bt_conn *conn; + undefined3 extraout_var; + int iVar3; + u16_t handle; + u16_t *puVar4; + _bt_gatt_ccc_conflict2 *p_Var5; + undefined4 uStack56; + undefined2 uStack52; + undefined uStack50; + + if (attr->write != bt_gatt_attr_write_ccc) { + return '\x01'; + } + p_Var5 = (_bt_gatt_ccc_conflict2 *)attr->user_data; + if (p_Var5 == &sc_ccc) { + pgVar1 = sc_cfg; + do { + peer = (bt_addr_le_t *) + ((int)&(((bt_gatt_indicate_params_conflict3 *)pgVar1)->_req).node.next + 1); + uStack56 = 0; + uStack52 = 0; + uStack50 = 0; + iVar3 = memcmp(peer,&uStack56,7); + if (iVar3 != 0) { + conn = bt_conn_lookup_state_le(peer,BT_CONN_CONNECTED); + if (conn == (bt_conn *)0x0) { + puVar4 = *(u16_t **)(*(int *)((int)user_data + 8) + 0x24); + sc_save(*(u8_t *)&(((bt_gatt_indicate_params_conflict3 *)pgVar1)->_req).node.next,peer, + *puVar4,puVar4[1]); + } + else { + bt_conn_unref(conn); + } + } + pgVar1 = (gatt_sc_cfg *)&(((bt_gatt_indicate_params_conflict3 *)pgVar1)->_req).state; + } while ((bt_gatt_indicate_params_conflict3 *)pgVar1 != sc_restore_params); + } + peer = &p_Var5->cfg[0].peer; + do { + if ((*(short *)(peer + 1) == *(short *)((int)user_data + 4)) && + (conn = bt_conn_lookup_addr_le(peer[-1].a.val[5],peer), conn != (bt_conn *)0x0)) { + if ((conn->state == BT_CONN_CONNECTED) && + ((p_Var5->cfg_match == (anon_subr__Bool_bt_conn_ptr_bt_gatt_attr_ptr_for_cfg_match *)0x0 || + (_Var2 = (*p_Var5->cfg_match)(conn,attr), CONCAT31(extraout_var,_Var2) != 0)))) { + handle = attr->handle - 1; + if (*(short *)((int)user_data + 4) == 2) { + iVar3 = gatt_indicate(conn,handle, + *(bt_gatt_indicate_params_conflict2 **)((int)user_data + 8)); + } + else { + iVar3 = gatt_notify(conn,handle, + (bt_gatt_notify_params_conflict2 *) + *(bt_gatt_indicate_params_conflict2 **)((int)user_data + 8)); + } + bt_conn_unref(conn); + if (iVar3 < 0) { + return '\0'; + } + *(undefined4 *)user_data = 0; + } + else { + bt_conn_unref(conn); + } + } + peer = (bt_addr_le_t *)(peer[1].a.val + 2); + if ((bt_addr_le_t *)((int)&p_Var5->value + 1) == peer) { + return '\x01'; + } + } while( true ); +} + + + +void sc_indicate(u16_t start,u16_t end) + +{ + u16_t uVar1; + undefined2 in_register_0000202a; + bt_conn *conn; + uint uVar2; + atomic_val_t aVar3; + undefined2 in_register_0000202e; + + conn = bt_conn_lookup_state_le((bt_addr_le_t *)0x0,BT_CONN_CONNECTED); + if ((conn == (bt_conn *)0x0) || + (uVar2 = atomic_or(gatt_sc.flags,1), uVar1 = start, (uVar2 & 1) != 0)) { + if (CONCAT22(in_register_0000202a,start) < (uint)gatt_sc.start) { + gatt_sc.start = start; + uVar1 = start; + if (CONCAT22(in_register_0000202e,end) <= (uint)gatt_sc.end) goto submit; + } + else { + uVar1 = gatt_sc.start; + if (CONCAT22(in_register_0000202e,end) <= (uint)gatt_sc.end) { + return; + } + } + } + gatt_sc.start = uVar1; + gatt_sc.end = end; +submit: + aVar3 = atomic_get(gatt_sc.flags); + if (((aVar3 >> 1 & 1U) == 0) && (conn != (bt_conn *)0x0)) { + k_delayed_work_submit((k_delayed_work *)&gatt_sc.work,10); + bt_conn_unref(conn); + return; + } + return; +} + + + +ssize_t bt_gatt_attr_write_ccc + (bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset,u8_t flags) + +{ + uint uVar1; + _Bool _Var2; + bt_gatt_ccc_cfg *pbVar3; + undefined3 extraout_var; + undefined2 in_register_00002036; + undefined2 in_register_0000203a; + int iVar4; + _bt_gatt_ccc_conflict2 *ccc; + undefined4 uStack40; + undefined2 uStack36; + undefined uStack34; + + iVar4 = CONCAT22(in_register_00002036,len); + ccc = (_bt_gatt_ccc_conflict2 *)attr->user_data; + if (CONCAT22(in_register_0000203a,offset) != 0) { + return -7; + } + if (1 < (iVar4 - 1U & 0xffff)) { + return -0xd; + } + uVar1 = (uint)*(byte *)buf; + if (iVar4 != 1) { + uVar1 = (uint)CONCAT11(*(undefined *)((int)buf + 1),*(byte *)buf); + } + pbVar3 = find_ccc_cfg(conn,ccc); + if (pbVar3 == (bt_gatt_ccc_cfg *)0x0) { + if (uVar1 == 0) { + return iVar4; + } + pbVar3 = find_ccc_cfg((bt_conn *)0x0,ccc); + if (pbVar3 == (bt_gatt_ccc_cfg *)0x0) { + printf("No space to store CCC cfg\r\n"); + return -0x11; + } + memcpy(&pbVar3->peer,conn->field_20,7); + pbVar3->id = conn->id; + } + if ((ccc->cfg_write == (anon_subr__Bool_bt_conn_ptr_bt_gatt_attr_ptr_u16_t_for_cfg_write *)0x0) || + (_Var2 = (*ccc->cfg_write)(conn,attr,(u16_t)uVar1), CONCAT31(extraout_var,_Var2) != 0)) { + pbVar3->value = (u16_t)uVar1; + if ((uint)ccc->value != uVar1) { + gatt_ccc_changed(attr,ccc); + } + if (uVar1 == 0) { + uStack40 = 0; + uStack36 = 0; + uStack34 = 0; + memcpy(&pbVar3->peer,&uStack40,7); + pbVar3->id = '\0'; + pbVar3->value = 0; + } + } + else { + iVar4 = -3; + } + return iVar4; +} + + + +void bt_gatt_init(void) + +{ + anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept **ppaVar1; + bool bVar2; + int iVar3; + uint uVar4; + bt_gatt_service_static *pbVar5; + + iVar3 = atomic_cas(&init,0,1); + if (iVar3 != 0) { + uVar4 = (uint)last_static_handle; + bVar2 = false; + pbVar5 = &_1_gatt_svc; + while (pbVar5 < &att_fixed_chan) { + ppaVar1 = &((bt_l2cap_fixed_chan *)pbVar5)->accept; + pbVar5 = (bt_gatt_service_static *)&((bt_l2cap_fixed_chan *)pbVar5)->node; + uVar4 = (uint)(*ppaVar1 + uVar4) & 0xffff; + bVar2 = true; + } + if (bVar2) { + last_static_handle = (u16_t)uVar4; + } + k_delayed_work_init((k_delayed_work *)&gatt_sc.work,sc_process); + return; + } + return; +} + + + +void bt_gatt_deinit(void) + +{ + k_delayed_work_del_timer((k_delayed_work *)&gatt_sc.work); + return; +} + + + +undefined4 bt_gatt_service_unregister(int *param_1) + +{ + sys_snode_t prev_node; + sys_snode_t sVar1; + + prev_node = (sys_snode_t)0x0; + sVar1 = (sys_snode_t)db.head; + while( true ) { + if (sVar1 == (sys_snode_t)0x0) { + return 0xfffffffe; + } + if ((sys_snode_t)(param_1 + 2) == sVar1) break; + prev_node = sVar1; + sVar1 = *(sys_snode_t *)sVar1; + } + sys_slist_remove(&db,(sys_snode_t *)prev_node,(sys_snode_t *)(param_1 + 2)); + sc_indicate(*(u16_t *)(*param_1 + 0x10),*(u16_t *)(param_1[1] * 0x14 + *param_1 + -4)); + return 0; +} + + + +ssize_t bt_gatt_attr_read(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t buf_len,u16_t offset, + void *value,u16_t value_len) + +{ + uint __n; + undefined2 in_register_00002036; + undefined2 in_register_0000203a; + uint uVar1; + undefined2 in_register_00002042; + + uVar1 = CONCAT22(in_register_0000203a,offset); + __n = 0xfffffff9; + if (uVar1 <= CONCAT22(in_register_00002042,value_len)) { + __n = CONCAT22(in_register_00002042,value_len) - uVar1; + if ((int)CONCAT22(in_register_00002036,buf_len) < (int)__n) { + __n = CONCAT22(in_register_00002036,buf_len); + } + __n = __n & 0xffff; + memcpy(buf,(void *)((int)value + uVar1),__n); + } + return __n; +} + + + +uint16_t bt_gatt_attr_value_handle(bt_gatt_attr *attr) + +{ + u16_t uVar1; + undefined2 extraout_var; + uint16_t uVar2; + + if (attr == (bt_gatt_attr *)0x0) { + uVar2 = 0; + } + else { + uVar2 = 0; + if ((attr->read == bt_gatt_attr_read_chrc) && + (uVar2 = *(uint16_t *)((int)attr->user_data + 4), uVar2 == 0)) { + if (attr->handle == 0) { + uVar1 = find_static_attr(attr); + return (uint16_t)((uint)((CONCAT22(extraout_var,uVar1) + 1) * 0x10000) >> 0x10); + } + uVar2 = attr->handle + 1; + } + } + return uVar2; +} + + + +uint lexical_block_0(bt_gatt_attr *param_1) + +{ + ushort uVar1; + u16_t uVar2; + uint uVar3; + + uVar1 = *(ushort *)((int)param_1->user_data + 4); + uVar3 = (uint)uVar1; + if (uVar1 == 0) { + if (param_1->handle == 0) { + uVar2 = find_static_attr(param_1); + return (uint)uVar2 + 1 & 0xffff; + } + uVar3 = (uint)param_1->handle + 1 & 0xffff; + } + return uVar3; +} + + + +ssize_t bt_gatt_attr_read_chrc(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset) + +{ + char **ppcVar1; + uint __n; + uint16_t uVar2; + char *pcVar3; + undefined2 in_register_00002036; + undefined2 in_register_0000203a; + uint uVar4; + uint uVar5; + u8_t auStack52 [4]; + gatt_chrc pdu; + + uVar4 = CONCAT22(in_register_0000203a,offset); + ppcVar1 = (char **)attr->user_data; + auStack52[0] = *(u8_t *)((int)ppcVar1 + 6); + uVar2 = bt_gatt_attr_value_handle(attr); + auStack52[1] = (u8_t)uVar2; + auStack52[2] = (u8_t)(uVar2 >> 8); + pcVar3 = *ppcVar1; + if (*pcVar3 == '\0') { + auStack52[3] = (u8_t)*(undefined2 *)(pcVar3 + 2); + pdu.properties = (u8_t)((ushort)*(undefined2 *)(pcVar3 + 2) >> 8); + uVar5 = 5; + } + else { + memcpy(auStack52 + 3,pcVar3 + 1,0x10); + uVar5 = 0x13; + } + __n = 0xfffffff9; + if (uVar4 <= uVar5) { + __n = uVar5 - uVar4; + if ((int)CONCAT22(in_register_00002036,len) < (int)(uVar5 - uVar4)) { + __n = CONCAT22(in_register_00002036,len); + } + __n = __n & 0xffff; + memcpy(buf,auStack52 + uVar4,__n); + } + return __n; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void bt_gatt_foreach_attr_type + (u16_t start_handle,u16_t end_handle,bt_uuid *uuid,void *attr_data, + uint16_t num_matches,bt_gatt_attr_func_t *func,void *user_data) + +{ + uint uVar1; + anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *paVar2; + sys_snode_t sVar3; + u8_t uVar4; + undefined2 in_register_0000202a; + anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *paVar5; + undefined3 extraout_var; + undefined3 extraout_var_00; + int iVar6; + undefined2 in_register_0000202e; + undefined2 in_register_0000203a; + sys_snode_t sVar7; + _snode *p_Var8; + anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *paVar9; + bt_gatt_attr *pbVar10; + anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *paVar11; + bt_gatt_service_static *pbVar12; + bt_uuid *pbStack84; + bt_gatt_attr attr; + + uVar1 = CONCAT22(in_register_0000203a,num_matches); + paVar5 = (anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *) + CONCAT22(in_register_0000202a,start_handle); + if (uVar1 == 0) { + uVar1 = 0xffff; + } + if (paVar5 <= (anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *) + (uint)last_static_handle) { + pbVar12 = &_1_gatt_svc; + paVar9 = (anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *)0x1; + while (pbVar12 < &att_fixed_chan) { + if (((bt_l2cap_fixed_chan *)pbVar12)->accept + (int)paVar9 < paVar5) { + paVar2 = (anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *) + ((uint)(((bt_l2cap_fixed_chan *)pbVar12)->accept + (int)paVar9) & 0xffff); + } + else { + paVar11 = (anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *)0x0; + while( true ) { + paVar2 = (anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *) + ((uint)(paVar11 + (int)paVar9) & 0xffff); + if (((bt_l2cap_fixed_chan *)pbVar12)->accept <= paVar11) break; + memcpy(&pbStack84,(void *)((int)paVar11 * 0x14 + *(int *)pbVar12),0x14); + attr.user_data._0_2_ = (u16_t)((uint)((int)(paVar11 + (int)paVar9) * 0x10000) >> 0x10); + if ((anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *) + CONCAT22(in_register_0000202e,end_handle) < paVar2) { + return; + } + if (((paVar5 <= paVar2) && + ((uuid == (bt_uuid *)0x0 || (iVar6 = bt_uuid_cmp(uuid,pbStack84), iVar6 == 0)))) && + ((attr_data == (void *)0x0 || + ((anon_subr_ssize_t_bt_conn_ptr_bt_gatt_attr_ptr_void_ptr_u16_t_u16_t_u8_t_for_write * + )attr_data == attr.write)))) { + uVar1 = uVar1 - 1 & 0xffff; + uVar4 = (*func)((bt_gatt_attr *)&pbStack84,user_data); + if (uVar1 == 0) { + return; + } + if (CONCAT31(extraout_var,uVar4) == 0) { + return; + } + } + paVar11 = paVar11 + 1; + } + } + pbVar12 = (bt_gatt_service_static *)&((bt_l2cap_fixed_chan *)pbVar12)->node; + paVar9 = paVar2; + } + } + sVar3 = (sys_snode_t)db.head; + if (db.head != (sys_snode_t *)0x0) { + while ((sys_snode_t *)((int)sVar3 + -8) != (sys_snode_t *)0x0) { + sVar7 = *(sys_snode_t *)sVar3; + if (((sVar7 == (sys_snode_t)0x0) || (sVar7 == (sys_snode_t)0x8)) || + (paVar5 < (anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *) + (uint)*(ushort *)(*(int *)((int)sVar7 + -8) + 0x10))) { + p_Var8 = (_snode *)0x0; + while (p_Var8 < ((sys_snode_t *)((int)sVar3 + -4))->next) { + pbVar10 = (bt_gatt_attr *)(((sys_snode_t *)((int)sVar3 + -8))->next + (int)p_Var8 * 5); + if ((anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *) + CONCAT22(in_register_0000202e,end_handle) < + (anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *)(uint)pbVar10->handle) { + return; + } + if (((paVar5 <= (anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *) + (uint)pbVar10->handle) && + ((uuid == (bt_uuid *)0x0 || (iVar6 = bt_uuid_cmp(uuid,pbVar10->uuid), iVar6 == 0)))) + && ((attr_data == (void *)0x0 || (attr_data == pbVar10->user_data)))) { + uVar1 = uVar1 - 1 & 0xffff; + uVar4 = (*func)(pbVar10,user_data); + if (uVar1 == 0) { + return; + } + if (CONCAT31(extraout_var_00,uVar4) == 0) { + return; + } + } + p_Var8 = (_snode *)((int)&p_Var8->next + 1); + } + } + sVar3 = *(sys_snode_t *)sVar3; + if (sVar3 == (sys_snode_t)0x0) { + return; + } + } + } + return; +} + + + +void bt_gatt_foreach_attr + (u16_t start_handle,u16_t end_handle,bt_gatt_attr_func_t *func,void *user_data) + +{ + bt_gatt_foreach_attr_type(start_handle,end_handle,(bt_uuid *)0x0,(void *)0x0,0,func,user_data); + return; +} + + + +int bt_gatt_service_register(bt_uuid **param_1) + +{ + ushort start_handle; + sys_snode_t *psVar1; + sys_snode_t *psVar2; + u16_t start_handle_00; + int iVar3; + bt_conn *conn; + undefined2 extraout_var; + undefined2 extraout_var_00; + uint uVar4; + sys_snode_t sVar5; + sys_snode_t *psVar6; + sys_snode_t *psVar7; + sys_snode_t *psVar8; + uint uVar9; + bt_uuid *pbVar10; + short sVar11; + uint uVar12; + bt_gatt_attr *pbStack88; + bt_uuid abStack84 [2]; + undefined2 uStack82; + bt_uuid abStack80 [2]; + undefined2 uStack78; + int iStack76; + undefined2 uStack72; + bt_gatt_notify_params_conflict2 *pbStack68; + bt_uuid **ppbStack60; + sys_slist_t *psStack56; + undefined4 uStack52; + bt_uuid abStack44 [2]; + undefined2 uStack42; + undefined auStack40 [2]; + undefined2 uStack38; + bt_gatt_attr *pbStack36; + + bt_gatt_init(); + abStack44[0] = (bt_uuid)0x0; + uStack42 = 0x1800; + iVar3 = bt_uuid_cmp(*(bt_uuid **)*param_1,abStack44); + if (iVar3 == 0) { + return 0xffffffbb; + } + pbStack68 = (bt_gatt_notify_params_conflict2 *)auStack40; + auStack40[0] = 0; + uStack38 = 0x1801; + uStack52 = 0x2304c6aa; + conn = (bt_conn *)bt_uuid_cmp(*(bt_uuid **)*param_1,(bt_uuid *)pbStack68); + if (conn == (bt_conn *)0x0) { + return 0xffffffbb; + } + pbVar10 = *param_1; + sVar11 = *(short *)(param_1 + 1); + if (db.head == (sys_snode_t *)0x0) { + uVar9 = (uint)last_static_handle; + uVar12 = 0; +LAB_2304c70c: + while ((psVar1 = db.tail, pbVar10 != (bt_uuid *)0x0 && (sVar11 != 0))) { + start_handle = *(ushort *)(pbVar10 + 0x10); + if (start_handle == 0) { + *(short *)(pbVar10 + 0x10) = (short)((uVar9 + 1) * 0x10000 >> 0x10); + uVar4 = uVar9 + 1 & 0xffff; + } + else { + uVar4 = (uint)start_handle; + if ((uint)start_handle <= uVar9) { + pbStack36 = (bt_gatt_attr *)0x0; + bt_gatt_foreach_attr(start_handle,start_handle,found_attr,&pbStack36); + uVar4 = uVar9; + if (pbStack36 != (bt_gatt_attr *)0x0) { + printf("Unable to register handle 0x%04x\r\n"); + return 0xffffffea; + } + } + } + sVar11 = sVar11 + -1; + pbVar10 = pbVar10 + 0x14; + uVar9 = uVar4; + } + if ((uVar12 == 0) || (uVar12 < (uint)*(ushort *)(*param_1 + 0x10))) { +LAB_2304c726: + psVar8 = (sys_snode_t *)(param_1 + 2); + psVar8->next = (_snode *)0x0; + psVar2 = psVar8; + if (db.tail != (sys_snode_t *)0x0) { + *(sys_snode_t **)&(db.tail)->next = psVar8; +LAB_2304c7a4: + psVar8 = db.head; + psVar2 = (sys_snode_t *)(param_1 + 2); + } + } + else { + psVar8 = db.head; + psVar2 = db.tail; + if (db.head != (sys_snode_t *)0x0) { + psVar6 = (sys_snode_t *)0x0; + sVar5 = (sys_snode_t)db.head; + while (psVar7 = (sys_snode_t *)((int)sVar5 + -8), psVar7 != (sys_snode_t *)0x0) { + if ((uint)*(ushort *)(*param_1 + 0x10) < (uint)*(ushort *)&psVar7->next[4].next) { + psVar8 = (sys_snode_t *)(param_1 + 2); + if (psVar6 == (sys_snode_t *)0x0) { + *(sys_snode_t **)(param_1 + 2) = db.head; + db.head = psVar8; + psVar2 = db.tail; + if (psVar1 == (sys_snode_t *)0x0) goto LAB_2304c7a4; + } + else { + if (psVar6[2].next == (_snode *)0x0) goto LAB_2304c726; + *(_snode **)(param_1 + 2) = psVar6[2].next; + *(sys_snode_t **)&psVar6[2].next = psVar8; + psVar8 = db.head; + psVar2 = db.tail; + } + break; + } + sVar5 = *(sys_snode_t *)sVar5; + psVar6 = psVar7; + if (sVar5 == (sys_snode_t)0x0) break; + } + } + } + db.tail = psVar2; + db.head = psVar8; + sc_indicate(*(u16_t *)(*param_1 + 0x10),*(u16_t *)(*param_1 + (int)param_1[1] * 0x14 + -4)); + return 0; + } + if (db.tail != (sys_snode_t *)0x0) { + uVar9 = (uint)*(ushort *)&db.tail[-2].next[(int)db.tail[-1].next * 5 + -1].next; + uVar12 = uVar9; + goto LAB_2304c70c; + } + ebreak(); + psStack56 = &db; + pbStack88 = pbStack68->attr; + if ((conn != (bt_conn *)0x0) && (conn->state != BT_CONN_CONNECTED)) { + return 0xffffffc7; + } + start_handle_00 = pbStack88->handle; + ppbStack60 = param_1; + if ((start_handle_00 == 0) && + (start_handle_00 = find_static_attr(pbStack88), CONCAT22(extraout_var,start_handle_00) == 0)) { +LAB_2304c7f6: + iStack76 = -2; + } + else { + if (pbStack68->uuid != (bt_uuid *)0x0) { + pbStack88 = (bt_gatt_attr *)0x0; + bt_gatt_foreach_attr_type + (start_handle_00,0xffff,pbStack68->uuid,(void *)0x0,1,match_uuid,&pbStack88); + if ((pbStack88 == (bt_gatt_attr *)0x0) || + ((start_handle_00 = pbStack88->handle, start_handle_00 == 0 && + (start_handle_00 = find_static_attr(pbStack88), + CONCAT22(extraout_var_00,start_handle_00) == 0)))) goto LAB_2304c7f6; + } + abStack84[0] = (bt_uuid)0x0; + uStack82 = 0x2803; + iVar3 = bt_uuid_cmp(pbStack88->uuid,abStack84); + if (iVar3 == 0) { + if ((*(byte *)((int)pbStack88->user_data + 6) & 0x10) == 0) { + return 0xffffffea; + } + start_handle_00 = bt_gatt_attr_value_handle(pbStack88); + } + if (conn == (bt_conn *)0x0) { + iStack76 = -0x39; + uStack72 = 1; + uStack78 = 0x2902; + abStack80[0] = (bt_uuid)0x0; + bt_gatt_foreach_attr_type(start_handle_00,0xffff,abStack80,(void *)0x0,1,notify_cb,&iStack76); + } + else { + iStack76 = gatt_notify(conn,start_handle_00,pbStack68); + } + } + return iStack76; +} + + + +// WARNING: Variable defined which should be unmapped: data +// WARNING: Could not reconcile some variable overlaps + +int bt_gatt_notify_cb(bt_conn *conn,bt_gatt_notify_params_conflict2 *params) + +{ + u16_t start_handle; + undefined2 extraout_var; + undefined2 extraout_var_00; + int iVar1; + bt_gatt_attr *pbStack40; + bt_gatt_attr *attr; + bt_uuid abStack32 [2]; + undefined2 uStack30; + int iStack28; + notify_data data; + + pbStack40 = params->attr; + if ((conn != (bt_conn *)0x0) && (conn->state != BT_CONN_CONNECTED)) { + return -0x39; + } + start_handle = pbStack40->handle; + if ((start_handle == 0) && + (start_handle = find_static_attr(pbStack40), CONCAT22(extraout_var,start_handle) == 0)) { +LAB_2304c7f6: + iStack28 = -2; + } + else { + if (params->uuid != (bt_uuid *)0x0) { + pbStack40 = (bt_gatt_attr *)0x0; + bt_gatt_foreach_attr_type + (start_handle,0xffff,params->uuid,(void *)0x0,1,match_uuid,&pbStack40); + if ((pbStack40 == (bt_gatt_attr *)0x0) || + ((start_handle = pbStack40->handle, start_handle == 0 && + (start_handle = find_static_attr(pbStack40), CONCAT22(extraout_var_00,start_handle) == 0)) + )) goto LAB_2304c7f6; + } + attr._0_1_ = 0; + attr._2_2_ = 0x2803; + iVar1 = bt_uuid_cmp(pbStack40->uuid,(bt_uuid *)&attr); + if (iVar1 == 0) { + if ((*(byte *)((int)pbStack40->user_data + 6) & 0x10) == 0) { + return -0x16; + } + start_handle = bt_gatt_attr_value_handle(pbStack40); + } + if (conn == (bt_conn *)0x0) { + iStack28 = -0x39; + data.err._0_2_ = 1; + uStack30 = 0x2902; + abStack32[0] = (bt_uuid)0x0; + data._4_4_ = params; + bt_gatt_foreach_attr_type(start_handle,0xffff,abStack32,(void *)0x0,1,notify_cb,&iStack28); + } + else { + iStack28 = gatt_notify(conn,start_handle,params); + } + } + return iStack28; +} + + + +// WARNING: Variable defined which should be unmapped: data +// WARNING: Could not reconcile some variable overlaps + +int bt_gatt_indicate(bt_conn *conn,bt_gatt_indicate_params_conflict2 *params) + +{ + u16_t start_handle; + undefined2 extraout_var; + undefined2 extraout_var_00; + int iVar1; + bt_gatt_attr *pbStack40; + bt_gatt_attr *attr; + bt_uuid abStack32 [2]; + undefined2 uStack30; + int iStack28; + notify_data data; + + pbStack40 = params->attr; + if ((conn != (bt_conn *)0x0) && (conn->state != BT_CONN_CONNECTED)) { + return -0x39; + } + start_handle = pbStack40->handle; + if ((start_handle == 0) && + (start_handle = find_static_attr(pbStack40), CONCAT22(extraout_var,start_handle) == 0)) { +LAB_2304c8e6: + iStack28 = -2; + } + else { + if (params->uuid != (bt_uuid *)0x0) { + pbStack40 = (bt_gatt_attr *)0x0; + bt_gatt_foreach_attr_type + (start_handle,0xffff,params->uuid,(void *)0x0,1,match_uuid,&pbStack40); + if ((pbStack40 == (bt_gatt_attr *)0x0) || + ((start_handle = pbStack40->handle, start_handle == 0 && + (start_handle = find_static_attr(pbStack40), CONCAT22(extraout_var_00,start_handle) == 0)) + )) goto LAB_2304c8e6; + } + attr._0_1_ = 0; + attr._2_2_ = 0x2803; + iVar1 = bt_uuid_cmp(pbStack40->uuid,(bt_uuid *)&attr); + if (iVar1 == 0) { + if ((*(byte *)((int)params->attr->user_data + 6) & 0x20) == 0) { + return -0x16; + } + start_handle = bt_gatt_attr_value_handle(params->attr); + } + if (conn == (bt_conn *)0x0) { + iStack28 = -0x39; + data.err._0_2_ = 2; + uStack30 = 0x2902; + abStack32[0] = (bt_uuid)0x0; + data._4_4_ = params; + bt_gatt_foreach_attr_type(start_handle,0xffff,abStack32,(void *)0x0,1,notify_cb,&iStack28); + } + else { + iStack28 = gatt_indicate(conn,start_handle,params); + } + } + return iStack28; +} + + + +// WARNING: Variable defined which should be unmapped: sc_range + +void sc_process(k_work *work) + +{ + int iVar1; + atomic_t aStack20; + u16_t sc_range [2]; + + aStack20 = work[-1].flags[0]; + atomic_and((atomic_t *)(work + 3),-2); + work[-2].handler = (k_work_handler_t *)0x230bad18; + work[-2].flags[0] = 0x2304bc2e; + *(atomic_t **)&work[-1]._reserved = &aStack20; + *(undefined2 *)work[-1].flags = 0; + *(undefined2 *)((int)work[-1].flags + 2) = 0; + *(undefined2 *)&work[-1].handler = 4; + iVar1 = bt_gatt_indicate((bt_conn *)0x0,(bt_gatt_indicate_params_conflict2 *)(work + -4)); + if (iVar1 == 0) { + atomic_or((atomic_t *)(work + 3),2); + } + return; +} + + + +u16_t bt_gatt_get_mtu(bt_conn *conn) + +{ + u16_t uVar1; + bt_att *pbVar2; + + pbVar2 = att_chan_get(conn); + if (pbVar2 == (bt_att *)0x0) { + uVar1 = 0; + } + else { + uVar1 = (pbVar2->chan).tx.mtu; + } + return uVar1; +} + + + +u8_t bt_gatt_check_perm(bt_conn *conn,bt_gatt_attr *attr,u8_t mask) + +{ + byte bVar1; + bt_security_t bVar2; + undefined3 extraout_var; + byte bVar3; + + bVar1 = attr->perm; + if ((((mask & 1) == 0) || + ((bVar3 = 2, (bVar1 & 0x15) != 0 && + (attr->read != + (anon_subr_ssize_t_bt_conn_ptr_bt_gatt_attr_ptr_void_ptr_u16_t_u16_t_for_read *)0x0)))) && + (((mask & 2) == 0 || + ((bVar3 = 3, (bVar1 & 0x2a) != 0 && + (attr->write != + (anon_subr_ssize_t_bt_conn_ptr_bt_gatt_attr_ptr_void_ptr_u16_t_u16_t_u8_t_for_write *)0x0))) + ))) { + bVar1 = bVar1 & mask; + if (((bVar1 & 0x30) != 0) && + (bVar2 = bt_conn_get_security(conn), CONCAT31(extraout_var,bVar2) < 3)) { + return '\x05'; + } + bVar3 = bVar1 & 0xc; + if (((bVar1 & 0xc) != 0) && (bVar3 = 0, conn->encrypt == '\0')) { + bVar3 = 0xf; + } + } + return (u8_t)bVar3; +} + + + +u8_t update_ccc(bt_gatt_attr *attr,void *user_data) + +{ + bt_conn *conn; + u8_t uVar1; + bt_security_t bVar2; + int iVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + gatt_sc_cfg *pgVar4; + undefined3 extraout_var_01; + bt_addr_le_t *peer; + uint uVar5; + _bt_gatt_ccc_conflict2 *ccc; + ushort uStack52; + ushort uStack50; + u16_t sc_range [2]; + + if (attr->write != bt_gatt_attr_write_ccc) { + return '\x01'; + } + ccc = (_bt_gatt_ccc_conflict2 *)attr->user_data; + conn = *(bt_conn **)user_data; + peer = &ccc->cfg[0].peer; + do { + iVar3 = bt_conn_addr_le_cmp(conn,peer); + if (iVar3 == 0) { + uVar1 = bt_gatt_check_perm(conn,attr,'*'); + iVar3 = CONCAT31(extraout_var,uVar1); + if (iVar3 == 0) { +LAB_2304cb0a: + if (*(short *)(peer + 1) != 0) { + gatt_ccc_changed(attr,ccc); + if (ccc != &sc_ccc) { + return '\x01'; + } + pgVar4 = find_sc_cfg(conn->id,(bt_addr_le_t *)conn->field_20); + if (pgVar4 == (gatt_sc_cfg *)0x0) { + return '\x01'; + } + uStack52 = (pgVar4->data).start; + uStack50 = (pgVar4->data).end; + if ((uStack52 | uStack50) == 0) { + return '\x01'; + } + uVar1 = bt_conn_index(conn); + iVar3 = CONCAT31(extraout_var_01,uVar1); + sc_restore_params[iVar3].attr = (bt_gatt_attr *)0x230bad18; + sc_restore_params[iVar3].func = sc_restore_rsp; + *(ushort **)&sc_restore_params[iVar3].data = &uStack52; + sc_restore_params[iVar3].len = 4; + iVar3 = bt_gatt_indicate(conn,(bt_gatt_indicate_params_conflict2 *) + (sc_restore_params + iVar3)); + if (iVar3 != 0) { + printf("SC restore indication failed\r\n"); + } + memset(&pgVar4->data,0,4); + return '\x01'; + } + } + else { + if (iVar3 == 3) { + printf("CCC %p not writable\r\n",attr); + } + else { + uVar5 = 2; + if (iVar3 == 5) { + uVar5 = 3; + } + bVar2 = bt_conn_get_security(conn); + if (uVar5 <= CONCAT31(extraout_var_00,bVar2)) goto LAB_2304cb0a; + if (*(byte *)((int)user_data + 4) < uVar5) { + *(undefined *)((int)user_data + 4) = (char)uVar5; + } + } + } + } + peer = (bt_addr_le_t *)(peer[1].a.val + 2); + if (peer == (bt_addr_le_t *)((int)&ccc->value + 1)) { + return '\x01'; + } + } while( true ); +} + + + +int bt_gatt_exchange_mtu(bt_conn *conn,bt_gatt_exchange_params *params) + +{ + net_buf *buf; + undefined *puVar1; + int iVar2; + + if (conn->state != BT_CONN_CONNECTED) { + return -0x39; + } + buf = bt_att_create_pdu(conn,'\x02',2); + if (buf != (net_buf *)0x0) { + puVar1 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + *puVar1 = 0xf7; + puVar1[1] = 0; + iVar2 = gatt_send(conn,buf,gatt_mtu_rsp,params); + return iVar2; + } + return -0xc; +} + + + +int bt_gatt_discover(bt_conn *conn,bt_gatt_discover_params *params) + +{ + undefined2 uVar1; + int iVar2; + net_buf *buf; + undefined *puVar3; + u16_t val; + code *func; + undefined *puVar4; + bt_uuid *pbVar5; + net_buf_simple *buf_00; + bt_uuid abStack56 [2]; + undefined2 uStack54; + bt_uuid abStack52 [2]; + undefined2 uStack50; + bt_uuid abStack48 [2]; + undefined2 uStack46; + bt_uuid abStack44 [2]; + undefined2 uStack42; + undefined auStack40 [2]; + undefined2 uStack38; + undefined auStack36 [2]; + undefined2 uStack34; + + if (conn->state != BT_CONN_CONNECTED) { + return -0x39; + } + switch(params->type) { + case '\0': + case '\x01': + if (params->uuid == (bt_uuid *)0x0) { + buf = bt_att_create_pdu(conn,'\x10',4); + if (buf == (net_buf *)0x0) goto LAB_2304cc6a; + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,4); + uVar1 = *(undefined2 *)¶ms->field_3; + *puVar3 = (char)uVar1; + puVar3[1] = (char)((ushort)uVar1 >> 8); + val = params->end_handle; + puVar3[2] = (char)val; + puVar3[3] = (char)(val >> 8); + if (params->type == '\0') { + val = 0x2800; + } + else { + val = 0x2801; + } + net_buf_simple_add_le16((net_buf_simple *)&buf->field_4,val); + func = gatt_read_group_rsp; + goto LAB_2304cd10; + } + buf = bt_att_create_pdu(conn,'\x06',6); + if (buf != (net_buf *)0x0) { + buf_00 = (net_buf_simple *)&buf->field_4; + puVar3 = (undefined *)net_buf_simple_add(buf_00,6); + uVar1 = *(undefined2 *)¶ms->field_3; + *puVar3 = (char)uVar1; + puVar3[1] = (char)((ushort)uVar1 >> 8); + val = params->end_handle; + puVar3[2] = (char)val; + puVar3[3] = (char)(val >> 8); + if (params->type == '\0') { + uStack34 = 0x2800; + auStack36[0] = 0; + puVar4 = auStack36; + } + else { + uStack38 = 0x2801; + auStack40[0] = 0; + puVar4 = auStack40; + } + uVar1 = *(undefined2 *)(puVar4 + 2); + puVar3[4] = (char)uVar1; + puVar3[5] = (char)((ushort)uVar1 >> 8); + pbVar5 = params->uuid; + if (pbVar5->type == '\0') { + net_buf_simple_add_le16(buf_00,*(u16_t *)(pbVar5 + 2)); + } + else { + if (pbVar5->type != '\x02') { + printf("Unknown UUID type %u\r\n"); + net_buf_unref(buf); + return -0x16; + } + net_buf_simple_add_mem(buf_00,pbVar5 + 1,0x10); + } + func = gatt_find_type_rsp; + goto LAB_2304cd10; + } + goto LAB_2304cc6a; + case '\x02': + case '\x03': + buf = bt_att_create_pdu(conn,'\b',4); + if (buf == (net_buf *)0x0) goto LAB_2304cc6a; + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,4); + uVar1 = *(undefined2 *)¶ms->field_3; + *puVar3 = (char)uVar1; + puVar3[1] = (char)((ushort)uVar1 >> 8); + val = params->end_handle; + puVar3[2] = (char)val; + puVar3[3] = (char)(val >> 8); + if (params->type == '\x02') { + val = 0x2802; + } + else { + val = 0x2803; + } + net_buf_simple_add_le16((net_buf_simple *)&buf->field_4,val); + func = gatt_read_type_rsp; + goto LAB_2304cd10; + case '\x04': + if (params->uuid != (bt_uuid *)0x0) { + abStack56[0] = (bt_uuid)0x0; + uStack54 = 0x2800; + iVar2 = bt_uuid_cmp(params->uuid,abStack56); + if (iVar2 == 0) { + return -0x16; + } + abStack52[0] = (bt_uuid)0x0; + uStack50 = 0x2801; + iVar2 = bt_uuid_cmp(params->uuid,abStack52); + if (iVar2 == 0) { + return -0x16; + } + abStack48[0] = (bt_uuid)0x0; + uStack46 = 0x2802; + iVar2 = bt_uuid_cmp(params->uuid,abStack48); + if (iVar2 == 0) { + return -0x16; + } + abStack44[0] = (bt_uuid)0x0; + uStack42 = 0x2803; + iVar2 = bt_uuid_cmp(params->uuid,abStack44); + if (iVar2 == 0) { + return -0x16; + } + } +switchD_2304cc58_caseD_5: + buf = bt_att_create_pdu(conn,'\x04',4); + if (buf == (net_buf *)0x0) { +LAB_2304cc6a: + iVar2 = -0xc; + } + else { + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,4); + uVar1 = *(undefined2 *)¶ms->field_3; + *puVar3 = (char)uVar1; + puVar3[1] = (char)((ushort)uVar1 >> 8); + val = params->end_handle; + func = gatt_find_info_rsp; + puVar3[2] = (char)val; + puVar3[3] = (char)(val >> 8); +LAB_2304cd10: + iVar2 = gatt_send(conn,buf,func,params); + } + return iVar2; + case '\x05': + goto switchD_2304cc58_caseD_5; + default: + printf("Invalid discovery type: %u\r\n"); + return -0x16; + } +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void gatt_discover_next(bt_conn *conn,u16_t last_handle,bt_gatt_discover_params *params) + +{ + int iVar1; + undefined2 in_register_0000202e; + + iVar1 = CONCAT22(in_register_0000202e,last_handle); + if (iVar1 != 0) { + if (iVar1 == 0xffff) { + *(undefined2 *)¶ms->field_3 = 0xffff; + goto done; + } + *(short *)¶ms->field_3 = (short)((iVar1 + 1U) * 0x10000 >> 0x10); + if ((uint)params->end_handle < (iVar1 + 1U & 0xffff)) goto done; + } + iVar1 = bt_gatt_discover(conn,params); + if (iVar1 == 0) { + return; + } +done: + // WARNING: Could not recover jumptable at 0x2304ced2. Too many branches + // WARNING: Treating indirect jump as call + (*params->func)(conn,(bt_gatt_attr *)0x0); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void gatt_find_type_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + u16_t last_handle; + int iVar1; + undefined3 in_register_0000202d; + undefined2 in_register_00002036; + uint uVar2; + uint uVar3; + undefined auStack84 [2]; + undefined2 uStack82; + undefined auStack80 [2]; + undefined2 uStack78; + undefined4 uStack76; + bt_gatt_service_val value; + bt_gatt_attr attr; + + uVar2 = CONCAT22(in_register_00002036,length); + uVar3 = CONCAT31(in_register_0000202d,err); + if (uVar3 == 0) { + last_handle = 0; + while (3 < uVar2) { + last_handle = *(u16_t *)((int)pdu + uVar3 * 4 + 2); + if (*(char *)((int)user_data + 0x28) == '\0') { + auStack84[0] = 0; + uStack82 = 0x2800; + value._4_4_ = auStack84; + } + else { + auStack80[0] = 0; + uStack78 = 0x2801; + value._4_4_ = auStack80; + } + uStack76 = *(undefined4 *)((int)user_data + 0x18); + value.uuid._0_2_ = last_handle; + iVar1 = (**(code **)((int)user_data + 0x1c)) + (conn,&value.end_handle,user_data,*(code **)((int)user_data + 0x1c)); + if (iVar1 == 0) { + return; + } + uVar3 = uVar3 + 1 & 0xff; + uVar2 = uVar2 - 4 & 0xffff; + } + if (uVar2 == 0) { + gatt_discover_next(conn,last_handle,(bt_gatt_discover_params *)user_data); + return; + } + } + (**(code **)((int)user_data + 0x1c))(conn,0,user_data,*(code **)((int)user_data + 0x1c)); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void gatt_read_group_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + ushort last_handle; + int iVar1; + void *__dest; + undefined3 in_register_0000202d; + size_t __n; + uint uVar2; + code *pcVar3; + ushort *puVar4; + undefined auStack120 [2]; + undefined2 uStack118; + undefined auStack116 [2]; + undefined2 uStack114; + u16_t *puStack112; + bt_gatt_service_val value; + anon_union u; + bt_gatt_attr attr; + + if (CONCAT31(in_register_0000202d,err) != 0) { + pcVar3 = *(code **)((int)user_data + 0x1c); + goto LAB_2304cfee; + } + if (*(char *)pdu == '\x06') { + value.end_handle._0_1_ = '\0'; +LAB_2304d03e: + uVar2 = (uint)length - 1; + puVar4 = (ushort *)((int)pdu + 1); + last_handle = 0; + while (uVar2 = uVar2 & 0xffff, *(byte *)pdu <= uVar2) { + stack0xffffffac = (undefined *)0x0; + if (((*puVar4 == 0) || (last_handle = puVar4[1], last_handle == 0)) || (last_handle < *puVar4) + ) goto done; + if ((char)value.end_handle == '\0') { + __n = 2; + __dest = (void *)&value.field_0x6; +LAB_2304d100: + memcpy(__dest,puVar4 + 2,__n); + } + else { + if ((char)value.end_handle == '\x02') { + __n = 0x10; + __dest = (void *)((int)&value.end_handle + 1); + goto LAB_2304d100; + } + } + if (*(char *)((int)user_data + 0x28) == '\0') { + auStack116[0] = 0; + uStack114 = 0x2800; + unique0x10000079 = auStack116; + } + else { + auStack120[0] = 0; + uStack118 = 0x2801; + unique0x1000007d = auStack120; + } + puStack112 = &value.end_handle; + value.uuid._0_2_ = last_handle; + iVar1 = (**(code **)((int)user_data + 0x1c)) + (conn,u + 0x10,user_data,*(code **)((int)user_data + 0x1c)); + if (iVar1 == 0) { + return; + } + uVar2 = uVar2 - (uint)*(byte *)pdu; + puVar4 = (ushort *)((int)puVar4 + (uint)*(byte *)pdu); + } + if ((uVar2 == 0) && (last_handle != 0)) { + gatt_discover_next(conn,last_handle,(bt_gatt_discover_params *)user_data); + return; + } + } + else { + if (*(char *)pdu == '\x14') { + value.end_handle._0_1_ = '\x02'; + goto LAB_2304d03e; + } + printf("Invalid data len %u\r\n"); + } +done: + pcVar3 = *(code **)((int)user_data + 0x1c); +LAB_2304cfee: + (*pcVar3)(conn,0,user_data,pcVar3); + return; +} + + + +// WARNING: Variable defined which should be unmapped: u_1 +// WARNING: Could not reconcile some variable overlaps + +void gatt_read_type_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + char cVar1; + undefined2 uVar2; + ushort last_handle; + uint uVar3; + int iVar4; + net_buf *buf; + undefined *puVar5; + undefined3 in_register_0000202d; + code *pcVar6; + ushort *puVar7; + undefined auStack104 [2]; + undefined2 uStack102; + undefined auStack100 [2]; + undefined2 uStack98; + u16_t *puStack96; + bt_gatt_include value; + anon_union u; + anon_union u_1; + + if (CONCAT31(in_register_0000202d,err) != 0) { + pcVar6 = *(code **)((int)user_data + 0x1c); + goto LAB_2304d142; + } + cVar1 = *(char *)pdu; + if (*(char *)((int)user_data + 0x28) == '\x02') { + if (cVar1 == '\x06') { + stack0xffffffbc = (undefined *)((uint)stack0xffffffbc & 0xffffff00 | 2); +LAB_2304d168: + uVar3 = (uint)length - 1; + puVar7 = (ushort *)((int)pdu + 1); + last_handle = 0; + while (uVar3 = uVar3 & 0xffff, *(byte *)pdu <= uVar3) { + last_handle = *puVar7; + if (last_handle == 0) goto done; + value.uuid._0_2_ = puVar7[1]; + value.uuid._2_2_ = puVar7[2]; + if (u[16] == 0) { + stack0xffffffbc = (undefined *)((uint)stack0xffffffbc & 0xffff | (uint)puVar7[3] << 0x10); + puStack96 = (u16_t *)(u + 0x10); + } + else { + if (u[16] == 2) { + *(ushort *)((int)user_data + 0x20) = last_handle; + *(ushort *)((int)user_data + 0x22) = (ushort)value.uuid; + *(ushort *)((int)user_data + 0x24) = value.uuid._2_2_; + buf = bt_att_create_pdu(conn,'\n',2); + if (buf == (net_buf *)0x0) { + last_handle = 0xfff4; + } + else { + puVar5 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + uVar2 = *(undefined2 *)((int)user_data + 0x22); + *puVar5 = (char)uVar2; + puVar5[1] = (char)((ushort)uVar2 >> 8); + uVar3 = gatt_send(conn,buf,read_included_uuid_cb,user_data); + last_handle = (ushort)(uVar3 & 0xffff); + if ((uVar3 & 0xffff) == 0) { + return; + } + } + goto LAB_2304d294; + } + } + if ((*(bt_uuid **)((int)user_data + 0x18) == (bt_uuid *)0x0) || + (iVar4 = bt_uuid_cmp((bt_uuid *)(u + 0x10),*(bt_uuid **)((int)user_data + 0x18)), + iVar4 == 0)) { + u._0_4_ = 0; + u._4_4_ = 0; + auStack104[0] = 0; + uStack102 = 0x2802; + u._12_4_ = (uint)last_handle; + value._4_4_ = auStack104; + u._8_4_ = &puStack96; + iVar4 = (**(code **)((int)user_data + 0x1c)) + (conn,&value.start_handle,user_data,*(code **)((int)user_data + 0x1c)); + if (iVar4 == 0) { + return; + } + } + uVar3 = uVar3 - (uint)*(byte *)pdu; + puVar7 = (ushort *)((int)puVar7 + (uint)*(byte *)pdu); + } + goto LAB_2304d192; + } + if (cVar1 == '\b') { + stack0xffffffbc = (undefined *)((uint)stack0xffffffbc & 0xffffff00); + goto LAB_2304d168; + } +LAB_2304d2b6: + printf("Invalid data len %u\r\n"); + } + else { + if (cVar1 == '\a') { + value._4_4_ = (undefined *)((uint)value._5_3_ << 8); + } + else { + if (cVar1 != '\x15') goto LAB_2304d2b6; + value._4_4_ = (undefined *)CONCAT31(value._5_3_,2); + } + uVar3 = (uint)length - 1; + puVar7 = (ushort *)((int)pdu + 1); + last_handle = 0; + while (uVar3 = uVar3 & 0xffff, *(byte *)pdu <= uVar3) { + last_handle = *puVar7; + if (last_handle == 0) goto done; + if ((char)value.start_handle == '\0') { + value._4_4_ = (undefined *) + ((uint)value._4_4_ & 0xffff | (uint)*(ushort *)((int)puVar7 + 5) << 0x10); + } + else { + if ((char)value.start_handle == '\x02') { + memcpy((void *)((int)&value.start_handle + 1),(void *)((int)puVar7 + 5),0x10); + } + } + if (*(bt_uuid **)((int)user_data + 0x18) == (bt_uuid *)0x0) { +LAB_2304d322: + auStack100[0] = 0; + uStack98 = 0x2803; + value.uuid._0_2_ = *(ushort *)((int)puVar7 + 3); + value.uuid._2_2_ = CONCAT11(value.uuid._3_1_,*(undefined *)(puVar7 + 1)); + puStack96 = &value.start_handle; + unique0x100000f4 = auStack100; + iVar4 = (**(code **)((int)user_data + 0x1c)) + (conn,u + 0x10,user_data,*(code **)((int)user_data + 0x1c)); + if (iVar4 == 0) { + return; + } + } + else { + iVar4 = bt_uuid_cmp((bt_uuid *)&value.start_handle,*(bt_uuid **)((int)user_data + 0x18)); + if (iVar4 == 0) goto LAB_2304d322; + } + uVar3 = uVar3 - (uint)*(byte *)pdu; + puVar7 = (ushort *)((int)puVar7 + (uint)*(byte *)pdu); + } +LAB_2304d192: + if ((uVar3 == 0) && (last_handle != 0)) { +LAB_2304d294: + gatt_discover_next(conn,last_handle,(bt_gatt_discover_params *)user_data); + return; + } + } +done: + pcVar6 = *(code **)((int)user_data + 0x1c); +LAB_2304d142: + (*pcVar6)(conn,0,user_data,pcVar6); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void read_included_uuid_cb(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + int iVar1; + undefined2 in_register_00002036; + undefined auStack68 [2]; + undefined2 uStack66; + u16_t *puStack64; + bt_gatt_include value; + anon_union_for_u u; + + if (CONCAT22(in_register_00002036,length) == 0x10) { + value.uuid._0_2_ = *(undefined2 *)((int)user_data + 0x22); + value.uuid._2_2_ = *(undefined2 *)((int)user_data + 0x24); + value.start_handle._0_1_ = 2; + puStack64 = &value.start_handle; + memcpy((void *)((int)&value.start_handle + 1),pdu,0x10); + if ((*(bt_uuid **)((int)user_data + 0x18) == (bt_uuid *)0x0) || + (iVar1 = bt_uuid_cmp((bt_uuid *)&value.start_handle,*(bt_uuid **)((int)user_data + 0x18)), + iVar1 == 0)) { + uStack66 = 0x2802; + register0x0000203c = auStack68; + auStack68[0] = 0; + iVar1 = (**(code **)((int)user_data + 0x1c)) + (conn,u + 0x10,user_data,*(code **)((int)user_data + 0x1c)); + if (iVar1 == 0) { + return; + } + } + gatt_discover_next(conn,*(u16_t *)((int)user_data + 0x20),(bt_gatt_discover_params *)user_data); + } + else { + printf("Invalid data len %u\r\n",CONCAT22(in_register_00002036,length)); + (**(code **)((int)user_data + 0x1c))(conn,0,user_data,*(code **)((int)user_data + 0x1c)); + } + return; +} + + + +void gatt_find_info_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + bt_uuid bVar1; + bool bVar2; + uint uVar3; + u16_t *puVar4; + int iVar5; + undefined3 in_register_0000202d; + u16_t last_handle; + uint uVar6; + bt_uuid abStack104 [2]; + undefined2 uStack102; + bt_uuid abStack100 [2]; + undefined2 uStack98; + bt_uuid abStack96 [2]; + undefined2 uStack94; + bt_uuid abStack92 [2]; + undefined2 uStack90; + bt_uuid bStack88; + undefined uStack87; + u16_t uStack86; + anon_union_for_u u; + + if (CONCAT31(in_register_0000202d,err) == 0) { + bVar1 = *(bt_uuid *)pdu; + if (bVar1 == (bt_uuid)0x1) { + bStack88 = (bt_uuid)0x0; + uVar6 = 4; + } + else { + if (bVar1 != (bt_uuid)0x2) { + printf("Invalid format %u\r\n"); + goto done; + } + uVar6 = 0x12; + bStack88 = bVar1; + } + uVar3 = (uint)length - 1 & 0xffff; + if (uVar6 <= uVar3) { + uVar3 = uVar3 / uVar6; + puVar4 = (u16_t *)((int)pdu + 1); + bVar2 = false; + last_handle = 0; + do { + if (uVar3 == 0) { + gatt_discover_next(conn,last_handle,(bt_gatt_discover_params *)user_data); + return; + } + last_handle = *puVar4; + if (bVar2) { +LAB_2304d4f2: + bVar2 = false; + } + else { + if (bStack88 == (bt_uuid)0x0) { + uStack86 = puVar4[1]; + } + else { + if (bStack88 == (bt_uuid)0x2) { + memcpy(&uStack87,puVar4 + 1,0x10); + } + } + if ((*(bt_uuid **)((int)user_data + 0x18) != (bt_uuid *)0x0) && + (iVar5 = bt_uuid_cmp(&bStack88,*(bt_uuid **)((int)user_data + 0x18)), iVar5 != 0)) + goto LAB_2304d4f2; + if (*(char *)((int)user_data + 0x28) != '\x04') { +LAB_2304d592: + unique0x10000057 = &bStack88; + iVar5 = (**(code **)((int)user_data + 0x1c)) + (conn,u + 0x10,user_data,*(code **)((int)user_data + 0x1c)); + if (iVar5 == 0) { + return; + } + goto LAB_2304d4f2; + } + abStack104[0] = (bt_uuid)0x0; + uStack102 = 0x2800; + iVar5 = bt_uuid_cmp(&bStack88,abStack104); + if (iVar5 == 0) goto LAB_2304d4f2; + abStack100[0] = (bt_uuid)0x0; + uStack98 = 0x2801; + iVar5 = bt_uuid_cmp(&bStack88,abStack100); + if (iVar5 == 0) goto LAB_2304d4f2; + abStack96[0] = (bt_uuid)0x0; + uStack94 = 0x2802; + iVar5 = bt_uuid_cmp(&bStack88,abStack96); + if (iVar5 == 0) goto LAB_2304d4f2; + abStack92[0] = (bt_uuid)0x0; + uStack90 = 0x2803; + iVar5 = bt_uuid_cmp(&bStack88,abStack92); + if (iVar5 != 0) goto LAB_2304d592; + bVar2 = true; + } + uVar3 = uVar3 - 1; + puVar4 = (u16_t *)((int)puVar4 + uVar6); + } while( true ); + } + } +done: + (**(code **)((int)user_data + 0x1c))(conn,0,user_data,*(code **)((int)user_data + 0x1c)); + return; +} + + + +int bt_gatt_read(bt_conn *conn,bt_gatt_read_params *params) + +{ + undefined2 uVar1; + net_buf *buf; + int iVar2; + undefined *puVar3; + char *pcVar4; + uint uVar5; + code *func; + net_buf_simple *buf_00; + + if (conn->state != BT_CONN_CONNECTED) { + return -0x39; + } + uVar5 = params->handle_count; + if (uVar5 == 0) { + buf = bt_att_create_pdu(conn,'\b',4); + if (buf == (net_buf *)0x0) { + return -0xc; + } + buf_00 = (net_buf_simple *)&buf->field_4; + puVar3 = (undefined *)net_buf_simple_add(buf_00,4); + uVar1 = *(undefined2 *)¶ms->field_3; + *puVar3 = (char)uVar1; + puVar3[1] = (char)((ushort)uVar1 >> 8); + uVar1 = *(undefined2 *)((int)¶ms->field_3 + 2); + puVar3[2] = (char)uVar1; + puVar3[3] = (char)((ushort)uVar1 >> 8); + pcVar4 = *(char **)((int)¶ms->field_3 + 4); + if (*pcVar4 == '\0') { + net_buf_simple_add_le16(buf_00,*(u16_t *)(pcVar4 + 2)); + } + else { + net_buf_simple_add_mem(buf_00,pcVar4 + 1,0x10); + } + } + else { + if (1 < uVar5) { + buf = bt_att_create_pdu(conn,'\x0e',uVar5 << 1); + if (buf == (net_buf *)0x0) { + return -0xc; + } + uVar5 = 0; + while (uVar5 < params->handle_count) { + iVar2 = uVar5 * 2; + uVar5 = uVar5 + 1 & 0xff; + net_buf_simple_add_le16 + ((net_buf_simple *)&buf->field_4,*(u16_t *)(*(int *)¶ms->field_3 + iVar2)); + } + func = gatt_read_multiple_rsp; + goto LAB_2304d686; + } + if (*(short *)((int)¶ms->field_3 + 2) == 0) { + buf = bt_att_create_pdu(conn,'\n',2); + if (buf == (net_buf *)0x0) { + return -0xc; + } + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + uVar1 = *(undefined2 *)¶ms->field_3; + *puVar3 = (char)uVar1; + puVar3[1] = (char)((ushort)uVar1 >> 8); + } + else { + buf = bt_att_create_pdu(conn,'\f',4); + if (buf == (net_buf *)0x0) { + return -0xc; + } + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,4); + uVar1 = *(undefined2 *)¶ms->field_3; + *puVar3 = (char)uVar1; + puVar3[1] = (char)((ushort)uVar1 >> 8); + uVar1 = *(undefined2 *)((int)¶ms->field_3 + 2); + puVar3[2] = (char)uVar1; + puVar3[3] = (char)((ushort)uVar1 >> 8); + } + } + func = gatt_read_rsp; +LAB_2304d686: + iVar2 = gatt_send(conn,buf,func,params); + return iVar2; +} + + + +void gatt_read_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + code *UNRECOVERED_JUMPTABLE; + uint uVar1; + u16_t uVar2; + int iVar3; + undefined2 extraout_var; + undefined3 in_register_0000202d; + undefined2 in_register_00002036; + int iVar4; + uint uVar5; + short *psVar6; + + iVar4 = CONCAT22(in_register_00002036,length); + iVar3 = CONCAT31(in_register_0000202d,err); + if ((iVar3 == 0) && (iVar4 != 0)) { + if (*(int *)((int)user_data + 0x1c) == 0) { + uVar1 = iVar4 - 1; + psVar6 = (short *)((int)pdu + 1); + while (uVar1 = uVar1 & 0xffff, uVar1 != 0) { + if (*psVar6 == 0) { + printf("Invalid handle\r\n"); + return; + } + uVar5 = (uint)*(byte *)pdu; + if (uVar1 < uVar5) { + uVar5 = uVar1; + } + *(short *)((int)user_data + 0x20) = *psVar6; + iVar3 = (**(code **)((int)user_data + 0x18)) + (conn,0,user_data,psVar6 + 1,uVar5 - 2 & 0xffff, + *(code **)((int)user_data + 0x18)); + if (iVar3 == 0) { + return; + } + if (uVar1 < *(byte *)pdu) break; + if (*(short *)((int)user_data + 0x22) == *(short *)((int)user_data + 0x20)) + goto LAB_2304d7e2; + *(short *)((int)user_data + 0x20) = *(short *)((int)user_data + 0x20) + 1; + uVar1 = uVar1 - (uint)*(byte *)pdu; + psVar6 = (short *)((int)psVar6 + (uint)*(byte *)pdu); + } + } + else { + iVar3 = (**(code **)((int)user_data + 0x18)) + (user_data,pdu,iVar4,*(code **)((int)user_data + 0x18)); + if (iVar3 == 0) { + return; + } + uVar2 = bt_att_get_mtu(conn); + if (iVar4 < CONCAT22(extraout_var,uVar2) + -1) { +LAB_2304d7e2: + UNRECOVERED_JUMPTABLE = *(code **)((int)user_data + 0x18); + iVar3 = 0; + goto LAB_2304d73c; + } + *(short *)((int)user_data + 0x22) = length + *(short *)((int)user_data + 0x22); + } + iVar3 = bt_gatt_read(conn,(bt_gatt_read_params *)user_data); + if (-1 < iVar3) { + return; + } + UNRECOVERED_JUMPTABLE = *(code **)((int)user_data + 0x18); + iVar3 = 0xe; + } + else { + UNRECOVERED_JUMPTABLE = *(code **)((int)user_data + 0x18); + } +LAB_2304d73c: + // WARNING: Could not recover jumptable at 0x2304d74c. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(conn,iVar3,user_data,0,0); + return; +} + + + +int bt_gatt_write_without_response_cb + (bt_conn *conn,u16_t handle,void *data,u16_t length,_Bool sign, + bt_gatt_complete_func_t *func,void *user_data) + +{ + net_buf *buf; + undefined *puVar1; + int iVar2; + u8_t op; + size_t len; + undefined2 in_register_00002036; + size_t __n; + undefined3 in_register_00002039; + + __n = CONCAT22(in_register_00002036,length); + if (conn->state != BT_CONN_CONNECTED) { + return -0x39; + } + if ((conn->encrypt == '\0') && (CONCAT31(in_register_00002039,sign) != 0)) { + len = __n + 0xe; + op = -0x2e; + } + else { + len = __n + 2; + op = 'R'; + } + buf = bt_att_create_pdu(conn,op,len); + if (buf != (net_buf *)0x0) { + puVar1 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + *puVar1 = (char)handle; + puVar1[1] = (char)(handle >> 8); + memcpy(puVar1 + 2,data,__n); + net_buf_simple_add((net_buf_simple *)&buf->field_4,__n); + iVar2 = bt_att_send(conn,buf,(bt_conn_tx_cb_t *)func,user_data); + return iVar2; + } + return -0xc; +} + + + +int bt_gatt_write(bt_conn *conn,bt_gatt_write_params *params) + +{ + ushort uVar1; + u16_t uVar2; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined *puVar3; + net_buf *buf; + int iVar4; + code *func; + size_t __n; + + if (conn->state != BT_CONN_CONNECTED) { + return -0x39; + } + if ((params->offset == 0) && + (uVar1 = params->length, uVar2 = bt_att_get_mtu(conn), + (uint)uVar1 <= CONCAT22(extraout_var_00,uVar2) - 3U)) { + buf = bt_att_create_pdu(conn,'\x12',(uint)params->length + 2); + if (buf != (net_buf *)0x0) { + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + uVar2 = params->handle; + *puVar3 = (char)uVar2; + puVar3[1] = (char)(uVar2 >> 8); + memcpy(puVar3 + 2,params->data,(uint)params->length); + net_buf_simple_add((net_buf_simple *)&buf->field_4,(uint)params->length); + func = gatt_write_rsp; + goto LAB_2304da18; + } + } + else { + uVar1 = params->length; + uVar2 = bt_att_get_mtu(conn); + if ((uint)uVar1 < CONCAT22(extraout_var,uVar2) - 5U) { + __n = (size_t)params->length; + } + else { + uVar2 = bt_att_get_mtu(conn); + __n = (uint)uVar2 - 5 & 0xffff; + } + buf = bt_att_create_pdu(conn,'\x16',__n + 4); + if (buf != (net_buf *)0x0) { + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,4); + uVar2 = params->handle; + *puVar3 = (char)uVar2; + puVar3[1] = (char)(uVar2 >> 8); + uVar2 = params->offset; + puVar3[2] = (char)uVar2; + puVar3[3] = (char)(uVar2 >> 8); + memcpy(puVar3 + 4,params->data,__n); + net_buf_simple_add((net_buf_simple *)&buf->field_4,__n); + params->offset = params->offset + (short)__n; + func = gatt_prepare_write_rsp; + params->data = (void *)((int)params->data + __n); + params->length = params->length - (short)__n; +LAB_2304da18: + iVar4 = gatt_send(conn,buf,func,params); + return iVar4; + } + } + return -0xc; +} + + + +void gatt_prepare_write_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + net_buf *buf; + undefined *puVar1; + undefined3 in_register_0000202d; + undefined2 in_register_00002036; + + if (CONCAT31(in_register_0000202d,err) != 0) { + // WARNING: Could not recover jumptable at 0x2304da3a. Too many branches + // WARNING: Treating indirect jump as call + (**(code **)((int)user_data + 0x18))(user_data,CONCAT22(in_register_00002036,length)); + return; + } + if (*(short *)((int)user_data + 0x24) == 0) { + buf = bt_att_create_pdu(conn,'\x18',1); + if (buf != (net_buf *)0x0) { + puVar1 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,1); + *puVar1 = 1; + gatt_send(conn,buf,gatt_write_rsp,user_data); + return; + } + return; + } + bt_gatt_write(conn,(bt_gatt_write_params *)user_data); + return; +} + + + +int bt_gatt_subscribe(bt_conn *conn,bt_gatt_subscribe_params *params) + +{ + bool bVar1; + sys_snode_t *psVar2; + bt_gatt_subscribe_params *pbVar3; + _snode *p_Var4; + int iVar5; + + if (conn->state != BT_CONN_CONNECTED) { + return -0x39; + } + pbVar3 = (bt_gatt_subscribe_params *)subscriptions.head; + if (subscriptions.head != (sys_snode_t *)0x0) { + pbVar3 = (bt_gatt_subscribe_params *)(subscriptions.head + -0xc); + } + bVar1 = false; + while (pbVar3 != (bt_gatt_subscribe_params *)0x0) { + if (pbVar3 == params) { + return -0x45; + } + iVar5 = bt_conn_addr_le_cmp(conn,&pbVar3->_peer); + if (((iVar5 == 0) && (pbVar3->value_handle == params->value_handle)) && + (params->value <= pbVar3->value)) { + bVar1 = true; + } + if ((pbVar3 == (bt_gatt_subscribe_params *)0xffffffd0) || + (p_Var4 = (pbVar3->node).next, p_Var4 == (_snode *)0x0)) break; + pbVar3 = (bt_gatt_subscribe_params *)(p_Var4 + -0xc); + } + if ((bVar1) || (iVar5 = gatt_write_ccc(conn,params->ccc_handle,params->value,params), iVar5 == 0)) + { + memcpy(¶ms->_peer,conn->field_20,7); + psVar2 = ¶ms->node; + *(sys_snode_t **)&(params->node).next = subscriptions.head; + subscriptions.head = psVar2; + if (subscriptions.tail == (sys_snode_t *)0x0) { + subscriptions.tail = ¶ms->node; + } + iVar5 = 0; + } + return iVar5; +} + + + +int bt_gatt_unsubscribe(bt_conn *conn,bt_gatt_subscribe_params *params) + +{ + bool bVar1; + bool bVar2; + bt_gatt_subscribe_params *pbVar3; + bt_gatt_subscribe_params *pbVar4; + int iVar5; + uint uVar6; + sys_snode_t *node; + bt_gatt_subscribe_params *pbVar7; + sys_snode_t *prev_node; + + if (conn->state != BT_CONN_CONNECTED) { + return -0x39; + } + pbVar7 = (bt_gatt_subscribe_params *)0x0; + pbVar3 = (bt_gatt_subscribe_params *)subscriptions.head; + if (subscriptions.head != (sys_snode_t *)0x0) { + pbVar7 = (bt_gatt_subscribe_params *)(subscriptions.head + -0xc); + if (pbVar7 == (bt_gatt_subscribe_params *)0x0) { + pbVar3 = (bt_gatt_subscribe_params *)0x0; + } + else { + pbVar3 = (bt_gatt_subscribe_params *)(subscriptions.head)->next; + if (pbVar3 != (bt_gatt_subscribe_params *)0x0) { + pbVar3 = (bt_gatt_subscribe_params *)&pbVar3[-1]._req.func; + } + } + } + bVar1 = false; + bVar2 = false; + prev_node = (sys_snode_t *)0x0; + while (pbVar4 = pbVar3, pbVar7 != (bt_gatt_subscribe_params *)0x0) { + node = &pbVar7->node; + if (pbVar7 == params) { + sys_slist_remove(&subscriptions,prev_node,node); + uVar6 = atomic_get(params->flags); + if ((uVar6 & 2) != 0) { + bt_att_req_cancel(conn,params); + } + bVar1 = true; + node = prev_node; + } + else { + iVar5 = bt_conn_addr_le_cmp(conn,&pbVar7->_peer); + if ((iVar5 == 0) && (pbVar7->value_handle == params->value_handle)) { + bVar2 = true; + } + } + pbVar3 = (bt_gatt_subscribe_params *)0x0; + pbVar7 = pbVar4; + prev_node = node; + if ((pbVar4 != (bt_gatt_subscribe_params *)0x0) && + (pbVar3 = (bt_gatt_subscribe_params *)(pbVar4->node).next, + pbVar3 != (bt_gatt_subscribe_params *)0x0)) { + pbVar3 = (bt_gatt_subscribe_params *)&pbVar3[-1]._req.func; + } + } + if (bVar1) { + if (!bVar2) { + params->value = 0; + iVar5 = gatt_write_ccc(conn,params->ccc_handle,0,params); + return iVar5; + } + (*params->notify)(conn,params,(void *)0x0,0); + iVar5 = 0; + } + else { + iVar5 = -0x16; + } + return iVar5; +} + + + +void bt_gatt_notification(bt_conn *conn,u16_t handle,void *data,u16_t length) + +{ + bt_gatt_subscribe_params *pbVar1; + bt_gatt_subscribe_params *pbVar2; + bt_gatt_subscribe_params *params; + u8_t uVar3; + int iVar4; + undefined3 extraout_var; + undefined2 in_register_0000202e; + + if (subscriptions.head == (sys_snode_t *)0x0) { + return; + } + params = (bt_gatt_subscribe_params *)(subscriptions.head + -0xc); + if (params != (bt_gatt_subscribe_params *)0x0) { + pbVar1 = (bt_gatt_subscribe_params *)(subscriptions.head)->next; + if (pbVar1 != (bt_gatt_subscribe_params *)0x0) { + pbVar1 = (bt_gatt_subscribe_params *)&pbVar1[-1]._req.func; + } + while( true ) { + pbVar2 = pbVar1; + iVar4 = bt_conn_addr_le_cmp(conn,¶ms->_peer); + if (((iVar4 == 0) && ((uint)params->value_handle == CONCAT22(in_register_0000202e,handle))) && + (uVar3 = (*params->notify)(conn,params,data,length), CONCAT31(extraout_var,uVar3) == 0)) { + bt_gatt_unsubscribe(conn,params); + } + if (pbVar2 == (bt_gatt_subscribe_params *)0x0) break; + pbVar1 = (bt_gatt_subscribe_params *)(pbVar2->node).next; + params = pbVar2; + if (pbVar1 != (bt_gatt_subscribe_params *)0x0) { + pbVar1 = (bt_gatt_subscribe_params *)&pbVar1[-1]._req.func; + } + } + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void bt_gatt_connected(bt_conn *conn) + +{ + sys_snode_t sVar1; + _Bool _Var2; + bt_security_t bVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + int iVar4; + char *key_00; + char acStack64 [4]; + char id_str [4]; + conn_data data; + char key [36]; + + data.conn._0_1_ = 1; + id_str = conn; + _Var2 = bt_addr_le_is_bonded(conn->id,(bt_addr_le_t *)conn->field_20); + if (CONCAT31(extraout_var,_Var2) != 0) { + key_00 = (char *)0x0; + if (conn->id != '\0') { + u8_to_dec(acStack64,'\x04',conn->id); + key_00 = acStack64; + } + bt_settings_encode_key(&data.sec,0x24,"ccc",(bt_addr_le_t *)conn->field_20,key_00); + } + bt_gatt_foreach_attr(1,0xffff,update_ccc,id_str); + bVar3 = bt_conn_get_security(conn); + sVar1 = (sys_snode_t)subscriptions.head; + if (CONCAT31(extraout_var_00,bVar3) < (uint)(byte)data.conn) { + bt_conn_set_security(conn,(byte)data.conn); + sVar1 = (sys_snode_t)subscriptions.head; + } + while ((sVar1 != (sys_snode_t)0x0 && + ((bt_gatt_subscribe_params *)((int)sVar1 + -0x30) != (bt_gatt_subscribe_params *)0x0))) { + iVar4 = bt_conn_addr_le_cmp(conn,(bt_addr_le_t *)((int)sVar1 + -0x18)); + if (iVar4 == 0) { + gatt_write_ccc(conn,*(u16_t *)((int)sVar1 + -10), + *(u16_t *)&((sys_snode_t *)((int)sVar1 + -8))->next, + (bt_gatt_subscribe_params *)((int)sVar1 + -0x30)); + } + sVar1 = *(sys_snode_t *)sVar1; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void bt_gatt_encrypt_change(bt_conn *conn) + +{ + bt_conn *pbStack24; + conn_data data; + + data.conn._0_1_ = 1; + pbStack24 = conn; + bt_gatt_foreach_attr(1,0xffff,update_ccc,&pbStack24); + return; +} + + + +_Bool bt_gatt_change_aware(bt_conn *conn,_Bool req) + +{ + return true; +} + + + +void bt_gatt_disconnected(bt_conn *conn) + +{ + bt_gatt_subscribe_params *params; + bt_gatt_subscribe_params *pbVar1; + bt_gatt_subscribe_params *pbVar2; + _Bool _Var3; + int iVar4; + undefined3 extraout_var; + uint uVar5; + sys_snode_t *prev; + + bt_gatt_foreach_attr(1,0xffff,disconnected_cb,conn); + if ((subscriptions.head != (sys_snode_t *)0x0) && + ((bt_gatt_subscribe_params *)(subscriptions.head + -0xc) != (bt_gatt_subscribe_params *)0x0)) { + pbVar1 = (bt_gatt_subscribe_params *)(subscriptions.head)->next; + if (pbVar1 != (bt_gatt_subscribe_params *)0x0) { + pbVar1 = (bt_gatt_subscribe_params *)&pbVar1[-1]._req.func; + } + prev = (sys_snode_t *)0x0; + params = (bt_gatt_subscribe_params *)(subscriptions.head + -0xc); +LAB_2304de12: + pbVar2 = pbVar1; + iVar4 = bt_conn_addr_le_cmp(conn,¶ms->_peer); + if (iVar4 == 0) { + _Var3 = bt_addr_le_is_bonded(conn->id,(bt_addr_le_t *)conn->field_20); + if ((CONCAT31(extraout_var,_Var3) != 0) && + (uVar5 = atomic_get(params->flags), (uVar5 & 1) == 0)) { + if ((params->_peer).type != '\0') { + memcpy(¶ms->_peer,(bt_addr_le_t *)conn->field_20,7); + } + goto LAB_2304de20; + } + params->value = 0; + gatt_subscription_remove(conn,prev,params); + } + else { +LAB_2304de20: + prev = ¶ms->node; + } + if (pbVar2 != (bt_gatt_subscribe_params *)0x0) { + pbVar1 = (bt_gatt_subscribe_params *)(pbVar2->node).next; + params = pbVar2; + if (pbVar1 != (bt_gatt_subscribe_params *)0x0) { + pbVar1 = (bt_gatt_subscribe_params *)&pbVar1[-1]._req.func; + } + goto LAB_2304de12; + } + } + return; +} + + + +void le_dhkey_complete(net_buf *buf) + +{ + u8_t *puVar1; + + if (dh_key_cb != (bt_dh_key_cb_t *)0x0) { + puVar1 = (u8_t *)0x0; + if (**(char **)&buf->field_4 == '\0') { + puVar1 = (u8_t *)(*(char **)&buf->field_4 + 1); + } + (*dh_key_cb)(puVar1); + dh_key_cb = (bt_dh_key_cb_t *)0x0; + return; + } + return; +} + + + +void hci_data_buf_overflow(net_buf *buf) + +{ + printf("Data buffer overflow (link type 0x%02x)\r\n",(uint)**(byte **)&buf->field_4); + return; +} + + + +int atomic_test_bit(atomic_t *target,int bit) + +{ + atomic_val_t aVar1; + + aVar1 = atomic_get(target); + return aVar1 >> (bit & 0x1fU) & 1; +} + + + +void bt_addr_le_copy(bt_addr_le_t *dst,bt_addr_le_t *src) + +{ + memcpy(dst,src,7); + return; +} + + + +void le_pkey_complete(net_buf *buf) + +{ + bt_pub_key_cb *pbVar1; + u8_t *puVar2; + char *pcVar3; + + pcVar3 = *(char **)&buf->field_4; + atomic_and(bt_dev.flags,-0x21); + if (*pcVar3 == '\0') { + memcpy(pub_key,pcVar3 + 1,0x40); + atomic_or(bt_dev.flags,0x10); + } + pbVar1 = pub_key_cb; + while (pbVar1 != (bt_pub_key_cb *)0x0) { + puVar2 = pub_key; + if (*pcVar3 != '\0') { + puVar2 = (u8_t *)0x0; + } + (*pbVar1->func)(puVar2); + pbVar1 = pbVar1->_next; + } + pub_key_cb = (bt_pub_key_cb *)0x0; + return; +} + + + +void atomic_set_bit_to(atomic_t *target,int bit,_Bool val) + +{ + uint value; + undefined3 in_register_00002031; + + value = 1 << (bit & 0x1fU); + if (CONCAT31(in_register_00002031,val) != 0) { + atomic_or(target + ((uint)bit >> 5),value); + return; + } + atomic_and(target + ((uint)bit >> 5),~value); + return; +} + + + +void slave_update_conn_param(bt_conn *conn) + +{ + int iVar1; + + iVar1 = atomic_test_bit(conn->flags,8); + if (iVar1 == 0) { + k_delayed_work_submit(&conn->update_work,5000); + return; + } + return; +} + + + +void le_remote_feat_complete(net_buf *buf) + +{ + ushort handle; + bt_conn *conn; + char *pcVar1; + + pcVar1 = *(char **)&buf->field_4; + handle = *(ushort *)(pcVar1 + 1); + conn = bt_conn_lookup_handle(handle); + if (conn == (bt_conn *)0x0) { + printf("Unable to lookup conn for handle %u\r\n",(uint)handle); + return; + } + if (*pcVar1 == '\0') { + memcpy(conn->field_20 + 0x24,pcVar1 + 3,8); + } + if (conn->role == '\x01') { + slave_update_conn_param(conn); + } + bt_conn_unref(conn); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void le_conn_update_complete(net_buf *buf) + +{ + ushort handle; + char *pcVar1; + bt_conn *conn; + uint uVar2; + undefined4 uStack24; + bt_le_conn_param param; + + pcVar1 = *(char **)&buf->field_4; + handle = *(ushort *)(pcVar1 + 1); + conn = bt_conn_lookup_handle(handle); + if (conn == (bt_conn *)0x0) { + printf("Unable to lookup conn for handle %u\r\n",(uint)handle); + } + else { + if (*pcVar1 == '\0') { + *(undefined2 *)(conn->field_20 + 0x16) = *(undefined2 *)(pcVar1 + 3); + *(undefined2 *)(conn->field_20 + 0x1c) = *(undefined2 *)(pcVar1 + 5); + *(undefined2 *)(conn->field_20 + 0x1e) = *(undefined2 *)(pcVar1 + 7); + notify_le_param_updated(conn); + } + else { + if (((*pcVar1 == '\x1a') && (conn->role == '\x01')) && + (uVar2 = atomic_or(conn->flags,0x400), (uVar2 & 0x400) == 0)) { + uStack24 = *(undefined4 *)(conn->field_20 + 0x18); + param._0_4_ = *(undefined4 *)(conn->field_20 + 0x20); + bt_l2cap_update_conn_param(conn,(bt_le_conn_param *)&uStack24); + } + } + bt_conn_unref(conn); + } + return; +} + + + +void hci_num_completed_packets(net_buf *buf) + +{ + ushort handle; + sys_snode_t *psVar1; + uint uVar2; + bt_conn *conn; + k_sem *sem; + byte *pbVar3; + _snode *p_Var4; + sys_snode_t *psVar5; + short sVar6; + int iVar7; + byte *pbVar8; + + pbVar8 = *(byte **)&buf->field_4; + iVar7 = 0; + do { + if ((int)(uint)*pbVar8 <= iVar7) { + return; + } + pbVar3 = pbVar8 + iVar7 * 4; + handle = *(ushort *)(pbVar3 + 1); + sVar6 = *(short *)(pbVar3 + 3); + uVar2 = irq_lock(); + conn = bt_conn_lookup_handle(handle); + if (conn == (bt_conn *)0x0) { + irq_unlock(uVar2); + printf("No connection for handle %u\r\n",(uint)handle); + } + else { + irq_unlock(uVar2); + while (sVar6 != 0) { + uVar2 = irq_lock(); + if (conn->pending_no_cb == 0) { + psVar1 = (conn->tx_pending).head; + if (psVar1 != (sys_snode_t *)0x0) { + p_Var4 = psVar1->next; + *(_snode **)&(conn->tx_pending).head = p_Var4; + if (psVar1 == (conn->tx_pending).tail) { + *(_snode **)&(conn->tx_pending).tail = p_Var4; + } + } + irq_unlock(uVar2); + if (psVar1 == (sys_snode_t *)0x0) { + printf("packets count mismatch\r\n"); + break; + } + irq_lock(); + *(_snode **)&conn->pending_no_cb = psVar1[3].next; + psVar1[3].next = (_snode *)0x0; + psVar1->next = (_snode *)0x0; + psVar5 = (conn->tx_complete).tail; + if (psVar5 == (sys_snode_t *)0x0) { + (conn->tx_complete).tail = psVar1; + (conn->tx_complete).head = psVar1; + } + else { + *(sys_snode_t **)&psVar5->next = psVar1; + (conn->tx_complete).tail = psVar1; + } + irq_unlock(); + k_work_submit(&conn->tx_complete_work); + sem = bt_conn_get_pkts(conn); + k_sem_give(sem); + sem = &g_poll_sem; + } + else { + conn->pending_no_cb = conn->pending_no_cb - 1; + irq_unlock(); + sem = bt_conn_get_pkts(conn); + } + sVar6 = sVar6 + -1; + k_sem_give(sem); + } + bt_conn_unref(conn); + } + iVar7 = iVar7 + 1; + } while( true ); +} + + + +void update_sec_level(bt_conn *conn) + +{ + int iVar1; + bt_security_t bVar2; + + if (conn->encrypt == '\0') { + conn->sec_level = BT_SECURITY_LOW; + return; + } + iVar1 = *(int *)(conn->field_20 + 0x2c); + if ((iVar1 == 0) || ((*(byte *)(iVar1 + 9) & 1) == 0)) { + bVar2 = BT_SECURITY_MEDIUM; + } + else { + if (((*(byte *)(iVar1 + 9) & 0x10) == 0) || (*(char *)(iVar1 + 8) != '\x10')) { + bVar2 = BT_SECURITY_L3; + } + else { + bVar2 = BT_SECURITY_L4; + } + } + conn->sec_level = bVar2; + if ((byte)conn->sec_level < (byte)conn->required_sec_level) { + printf("Failed to set required security level\r\n"); + bt_conn_disconnect(conn,'\x05'); + return; + } + return; +} + + + +void hci_encrypt_key_refresh_complete(net_buf *buf) + +{ + ushort handle; + byte *pbVar1; + bt_conn *conn; + uint uVar2; + + pbVar1 = *(byte **)&buf->field_4; + handle = *(ushort *)(pbVar1 + 1); + conn = bt_conn_lookup_handle(handle); + if (conn == (bt_conn *)0x0) { + printf("Unable to look up conn with handle %u\r\n",(uint)handle); + return; + } + if (*pbVar1 == 0) { + if (conn->type == '\x01') { + bt_smp_update_keys(conn); + update_sec_level(conn); + } + conn->required_sec_level = conn->sec_level; + bt_l2cap_encrypt_change(conn,*pbVar1); + uVar2 = 0; + } + else { + conn->required_sec_level = conn->sec_level; + bt_l2cap_encrypt_change(conn,*pbVar1); + uVar2 = 8; + if (*pbVar1 < 0x2a) { + uVar2 = (uint)(byte)CSWTCH_71[*pbVar1]; + } + } + bt_conn_security_changed(conn,uVar2); + bt_conn_unref(conn); + return; +} + + + +void hci_encrypt_change(net_buf *buf) + +{ + byte bVar1; + ushort handle; + byte *pbVar2; + bt_conn *conn; + uint uVar3; + + pbVar2 = *(byte **)&buf->field_4; + handle = *(ushort *)(pbVar2 + 1); + conn = bt_conn_lookup_handle(handle); + if (conn == (bt_conn *)0x0) { + printf("Unable to look up conn with handle %u\r\n",(uint)handle); + return; + } + if (*pbVar2 == 0) { + bVar1 = pbVar2[3]; + conn->encrypt = bVar1; + if (conn->type == '\x01') { + if (bVar1 != 0) { + bt_smp_update_keys(conn); + } + update_sec_level(conn); + } + conn->required_sec_level = conn->sec_level; + bt_l2cap_encrypt_change(conn,*pbVar2); + uVar3 = 0; + } + else { + conn->required_sec_level = conn->sec_level; + bt_l2cap_encrypt_change(conn,*pbVar2); + uVar3 = 8; + if (*pbVar2 < 0x2a) { + uVar3 = (uint)(byte)CSWTCH_71[*pbVar2]; + } + } + bt_conn_security_changed(conn,uVar3); + bt_conn_unref(conn); + return; +} + + + +bt_conn * find_pending_connect(bt_addr_le_t *peer_addr) + +{ + bt_conn *pbVar1; + + pbVar1 = bt_conn_lookup_state_le(peer_addr,BT_CONN_CONNECT); + if (pbVar1 == (bt_conn *)0x0) { + pbVar1 = bt_conn_lookup_state_le(peer_addr,BT_CONN_CONNECT_DIR_ADV); + return pbVar1; + } + return pbVar1; +} + + + +void hci_vendor_event(net_buf *buf) + +{ + undefined2 uVar1; + size_t sVar2; + + if (hci_vnd_evt_cb != (bt_hci_vnd_evt_cb_t *)0x0) { + sVar2 = net_buf_simple_headroom((net_buf_simple *)&buf->field_4); + uVar1 = *(undefined2 *)((int)&buf->field_4 + 4); + (*hci_vnd_evt_cb)((net_buf_simple *)&buf->field_4); + *(size_t *)&buf->field_4 = *(int *)((int)&buf->field_4 + 8) + (sVar2 & 0xffff); + *(undefined2 *)((int)&buf->field_4 + 4) = uVar1; + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void handle_event(u8_t event,net_buf *buf,event_handler *handlers,size_t num_handlers) + +{ + undefined3 in_register_00002029; + uint uVar1; + char *pcVar2; + uint len; + event_handler *peVar3; + + uVar1 = CONCAT31(in_register_00002029,event); + peVar3 = handlers + num_handlers; + do { + if ((uint)handlers->event == uVar1) { + if ((uint)*(ushort *)((int)&buf->field_4 + 4) < (uint)handlers->min_len) { + printf("Too small (%u bytes) event 0x%02x\r\n",uVar1); + return; + } + // WARNING: Could not recover jumptable at 0x2304e492. Too many branches + // WARNING: Treating indirect jump as call + (*handlers->handler)(); + return; + } + handlers = handlers + 1; + } while (handlers != peVar3); + len = (uint)*(ushort *)((int)&buf->field_4 + 4); + pcVar2 = bt_hex_real(*(void **)&buf->field_4,len); + printf("Unhandled event 0x%02x len %u: %s\r\n",uVar1,len,pcVar2); + return; +} + + + +void hci_le_meta_event(net_buf *buf) + +{ + u8_t *puVar1; + + puVar1 = (u8_t *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,1); + handle_event(*puVar1,buf,meta_events,9); + return; +} + + + +void hci_cmd_done(u16_t opcode,u8_t status,net_buf *buf) + +{ + byte bVar1; + undefined2 in_register_0000202a; + uint uVar2; + net_buf_pool *pnVar3; + int iVar4; + undefined3 in_register_0000202d; + cmd_state_set *pcVar5; + + uVar2 = CONCAT22(in_register_0000202a,opcode); + pnVar3 = net_buf_pool_get((uint)buf->pool_id); + if (pnVar3 != &hci_cmd_pool) { + bVar1 = buf->pool_id; + pnVar3 = net_buf_pool_get((uint)bVar1); + printf("opcode 0x%04x pool id %u pool %p != &hci_cmd_pool %p\r\n",uVar2,(uint)bVar1,pnVar3, + &hci_cmd_pool); + return; + } + iVar4 = net_buf_id(buf); + if ((uint)cmd_data[iVar4].opcode != uVar2) { + iVar4 = net_buf_id(buf); + printf("OpCode 0x%04x completed instead of expected 0x%04x\r\n",uVar2, + (uint)cmd_data[iVar4].opcode); + } + iVar4 = net_buf_id(buf); + if ((cmd_data[iVar4].state != (cmd_state_set *)0x0) && + (CONCAT31(in_register_0000202d,status) == 0)) { + iVar4 = net_buf_id(buf); + pcVar5 = cmd_data[iVar4].state; + atomic_set_bit_to(pcVar5->target,pcVar5->bit,pcVar5->val); + } + iVar4 = net_buf_id(buf); + if (cmd_data[iVar4].sync != (k_sem *)0x0) { + iVar4 = net_buf_id(buf); + cmd_data[iVar4].status = status; + iVar4 = net_buf_id(buf); + k_sem_give(cmd_data[iVar4].sync); + return; + } + return; +} + + + +void hci_cmd_status(net_buf *buf) + +{ + u8_t uVar1; + u8_t *puVar2; + + puVar2 = (u8_t *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,4); + uVar1 = puVar2[1]; + hci_cmd_done(*(u16_t *)(puVar2 + 2),*puVar2,buf); + if (uVar1 != '\0') { + k_sem_give(&bt_dev.ncmd_sem); + return; + } + return; +} + + + +void hci_cmd_complete(net_buf *buf) + +{ + char cVar1; + char *pcVar2; + + pcVar2 = (char *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,3); + cVar1 = *pcVar2; + hci_cmd_done(*(u16_t *)(pcVar2 + 1),**(u8_t **)&buf->field_4,buf); + if (cVar1 != '\0') { + k_sem_give(&bt_dev.ncmd_sem); + return; + } + return; +} + + + +int id_find(bt_addr_le_t *addr) + +{ + uint uVar1; + int iVar2; + + uVar1 = 0; + while( true ) { + if (bt_dev.id_count <= uVar1) { + return -2; + } + iVar2 = memcmp(addr,bt_dev.id_addr + uVar1,7); + if (iVar2 == 0) break; + uVar1 = uVar1 + 1 & 0xff; + } + return uVar1; +} + + + +void sys_put_le64(u8_t *dst) + +{ + undefined4 in_a1; + undefined *in_a2; + + in_a2[1] = (char)((uint)dst >> 8); + *in_a2 = (char)dst; + in_a2[2] = 0; + in_a2[3] = (char)((uint)dst >> 0x18); + in_a2[4] = 0; + in_a2[5] = (char)((uint)in_a1 >> 8); + in_a2[6] = 0; + in_a2[7] = (char)((uint)in_a1 >> 0x18); + return; +} + + + +net_buf * bt_hci_cmd_create(u16_t opcode,u8_t param_len) + +{ + net_buf *buf; + int iVar1; + undefined *puVar2; + + buf = net_buf_alloc_fixed(&hci_cmd_pool,-1); + net_buf_simple_reserve((net_buf_simple *)&buf->field_4,1); + buf->user_data[0] = '\0'; + iVar1 = net_buf_id(buf); + cmd_data[iVar1].opcode = opcode; + iVar1 = net_buf_id(buf); + cmd_data[iVar1].sync = (k_sem *)0x0; + iVar1 = net_buf_id(buf); + cmd_data[iVar1].state = (cmd_state_set *)0x0; + puVar2 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,3); + *puVar2 = (char)opcode; + puVar2[1] = (char)(opcode >> 8); + puVar2[2] = param_len; + return buf; +} + + + +int bt_hci_cmd_send_sync(u16_t opcode,net_buf *buf,net_buf **rsp) + +{ + undefined2 in_register_0000202a; + int iVar1; + int iVar2; + undefined auStack44 [4]; + k_sem sync_sem; + + if ((buf == (net_buf *)0x0) && (buf = bt_hci_cmd_create(opcode,'\0'), buf == (net_buf *)0x0)) { + return -0x37; + } + k_sem_init((k_sem *)auStack44,0,1); + iVar1 = net_buf_id(buf); + cmd_data[iVar1].sync = (k_sem *)auStack44; + iVar1 = net_buf_id(buf); + cmd_data[iVar1].status = -1; + net_buf_ref(buf); + net_buf_put(&bt_dev.cmd_tx_queue,buf); + k_sem_give(&g_poll_sem); + k_sem_take((k_sem *)auStack44,10000); + k_sem_delete((k_sem *)auStack44); + iVar1 = net_buf_id(buf); + if (cmd_data[iVar1].status == '\0') { + if (rsp == (net_buf **)0x0) { + net_buf_unref(buf); + } + else { + *rsp = buf; + } + iVar1 = 0; + } + else { + iVar2 = net_buf_id(buf); + iVar1 = -0x3d; + if ((cmd_data[iVar2].status != '\t') && (iVar1 = -5, cmd_data[iVar2].status == -1)) { + printf("k_sem_take timeout with opcode 0x%04x\r\n",CONCAT22(in_register_0000202a,opcode)); + vAssertCalled(); + iVar1 = -0x4f; + } + net_buf_unref(buf); + } + return iVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int set_le_scan_enable(u8_t enable) + +{ + undefined3 in_register_00002029; + net_buf *buf; + u8_t *puVar1; + int iVar2; + atomic_t *paStack44; + cmd_state_set state; + + buf = bt_hci_cmd_create(0x200c,'\x02'); + if (buf == (net_buf *)0x0) { + iVar2 = -0x37; + } + else { + puVar1 = (u8_t *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + if (CONCAT31(in_register_00002029,enable) == 1) { + iVar2 = atomic_test_bit(bt_dev.flags,0xd); + puVar1[1] = (u8_t)iVar2; + } + else { + puVar1[1] = '\0'; + } + *puVar1 = enable; + state.bit._0_1_ = (_Bool)(enable & 1); + state.target = (atomic_t *)&DAT_0000000a; + paStack44 = (atomic_t *)0x4200ddcc; + iVar2 = net_buf_id(buf); + cmd_data[iVar2].state = (cmd_state_set *)&paStack44; + iVar2 = bt_hci_cmd_send_sync(0x200c,buf,(net_buf **)0x0); + } + return iVar2; +} + + + +int set_random_address(bt_addr_t *addr) + +{ + int iVar1; + net_buf *buf; + + iVar1 = memcmp(addr,&bt_dev.random_addr.a,6); + if (iVar1 != 0) { + buf = bt_hci_cmd_create(0x2005,'\x06'); + iVar1 = -0x37; + if (buf != (net_buf *)0x0) { + net_buf_simple_add_mem((net_buf_simple *)&buf->field_4,addr,6); + iVar1 = bt_hci_cmd_send_sync(0x2005,buf,(net_buf **)0x0); + if (iVar1 == 0) { + memcpy(&bt_dev.random_addr.a,addr,6); + bt_dev.random_addr.type = '\x01'; + } + } + } + return iVar1; +} + + + +int le_set_private_addr(void) + +{ + int iVar1; + undefined auStack24 [4]; + bt_addr_t nrpa; + + iVar1 = bt_rand(auStack24,6); + if (iVar1 == 0) { + nrpa.val[1] = nrpa.val[1] & 0x3f; + iVar1 = set_random_address((bt_addr_t *)auStack24); + } + return iVar1; +} + + + +int hci_id_add(bt_addr_le_t *addr,u8_t *val) + +{ + net_buf *buf; + bt_addr_le_t *dst; + int iVar1; + + buf = bt_hci_cmd_create(0x2027,'\''); + if (buf != (net_buf *)0x0) { + dst = (bt_addr_le_t *)net_buf_simple_add((net_buf_simple *)&buf->field_4,0x27); + bt_addr_le_copy(dst,addr); + memcpy(dst + 1,val,0x10); + memset(dst[3].a.val + 1,0,0x10); + iVar1 = bt_hci_cmd_send_sync(0x2027,buf,(net_buf **)0x0); + return iVar1; + } + return -0x37; +} + + + +void keys_add_id(bt_keys *keys,void *data) + +{ + hci_id_add(&keys->addr,(u8_t *)&keys->irk); + return; +} + + + +int addr_res_enable(u8_t enable) + +{ + net_buf *buf; + int iVar1; + + buf = bt_hci_cmd_create(0x202d,'\x01'); + if (buf != (net_buf *)0x0) { + net_buf_simple_add_u8((net_buf_simple *)&buf->field_4,enable); + iVar1 = bt_hci_cmd_send_sync(0x202d,buf,(net_buf **)0x0); + return iVar1; + } + return -0x37; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int set_advertise_enable(_Bool enable) + +{ + undefined3 in_register_00002029; + net_buf *buf; + int iVar1; + atomic_t *paStack28; + cmd_state_set state; + + buf = bt_hci_cmd_create(0x200a,'\x01'); + if (buf == (net_buf *)0x0) { + iVar1 = -0x37; + } + else { + net_buf_simple_add_u8 + ((net_buf_simple *)&buf->field_4,CONCAT31(in_register_00002029,enable) != 0); + paStack28 = (atomic_t *)0x4200ddcc; + state.target = (atomic_t *)0x6; + state.bit._0_1_ = enable; + iVar1 = net_buf_id(buf); + cmd_data[iVar1].state = (cmd_state_set *)&paStack28; + iVar1 = bt_hci_cmd_send_sync(0x200a,buf,(net_buf **)0x0); + } + return iVar1; +} + + + +void hci_disconn_complete(net_buf *buf) + +{ + ushort handle; + char *pcVar1; + bt_conn *conn; + int iVar2; + + pcVar1 = *(char **)&buf->field_4; + if (*pcVar1 == '\0') { + handle = *(ushort *)(pcVar1 + 1); + conn = bt_conn_lookup_handle(handle); + if (conn == (bt_conn *)0x0) { + printf("Unable to look up conn with handle %u\r\n",(uint)handle); + } + else { + conn->err = pcVar1[3]; + bt_conn_set_state(conn,BT_CONN_DISCONNECTED); + conn->handle = 0; + if (conn->type != '\x01') { + bt_conn_unref(conn); + return; + } + bt_conn_unref(conn); + atomic_clear(&conn->ref); + } + iVar2 = atomic_test_bit(bt_dev.flags,9); + if ((iVar2 != 0) && (iVar2 = atomic_test_bit(bt_dev.flags,6), iVar2 == 0)) { + set_advertise_enable(true); + return; + } + } + return; +} + + + +int set_ad(u16_t hci_op,bt_ad *ad,size_t ad_len) + +{ + net_buf *buf; + byte *__s; + int iVar1; + uint uVar2; + size_t __n; + byte bVar3; + uint uVar4; + bt_ad *pbVar5; + bt_data *pbVar6; + uint uVar7; + + buf = bt_hci_cmd_create(hci_op,' '); + if (buf == (net_buf *)0x0) { + return -0x37; + } + __s = (byte *)net_buf_simple_add((net_buf_simple *)&buf->field_4,0x20); + pbVar5 = ad + ad_len; + memset(__s,0,0x20); + do { + if (ad == pbVar5) { + iVar1 = bt_hci_cmd_send_sync(hci_op,buf,(net_buf **)0x0); + return iVar1; + } + pbVar6 = ad->data; + uVar7 = 0; + while (uVar7 < ad->len) { + __n = (size_t)pbVar6->data_len; + uVar4 = (uint)*__s; + bVar3 = pbVar6->type; + if (0x1d < uVar4 + __n) { + __n = 0x1d - uVar4; + if ((bVar3 != 9) || (__n == 0)) { + net_buf_unref(buf); + printf("Too big advertising data\r\n"); + return -0x16; + } + bVar3 = 8; + } + __s[uVar4 + 1] = (char)__n + 1; + uVar2 = uVar4 + 2 & 0xff; + *__s = (byte)uVar2; + __s[(uVar4 + 1 & 0xff) + 1] = bVar3; + memcpy(__s + uVar2 + 1,pbVar6->data,__n); + uVar7 = uVar7 + 1; + pbVar6 = pbVar6 + 1; + *__s = (char)__n + *__s; + } + ad = ad + 1; + } while( true ); +} + + + +// WARNING: Variable defined which should be unmapped: d +// WARNING: Could not reconcile some variable overlaps + +int le_adv_update(bt_data *ad,size_t ad_len,bt_data *sd,size_t sd_len,_Bool connectable, + _Bool use_name) + +{ + int iVar1; + size_t sVar2; + size_t sVar3; + undefined3 in_register_00002039; + undefined3 in_register_0000203d; + undefined uStack40; + undefined uStack39; + bt_data data; + bt_ad d [2]; + + d[0].len = 0; + data.data = (u8_t *)ad; + iVar1 = set_ad(0x2008,(bt_ad *)&data.data,1); + if (iVar1 == 0) { + data.data = (u8_t *)sd; + if (CONCAT31(in_register_0000203d,use_name) != 0) { + if (sd != (bt_data *)0x0) { + sVar3 = 0; + while (sVar3 != sd_len) { + if ((byte)(sd[sVar3].type - 8) < 2) { + return -0x16; + } + sVar3 = sVar3 + 1; + } + } + sVar2 = strlen(bt_dev.name); + uStack40 = 9; + d[0].len = (size_t)&uStack40; + uStack39 = (undefined)sVar2; + data._0_4_ = 0x4200de18; + } + if (((data.data != (u8_t *)0x0) || (d[0].len != 0)) || + (CONCAT31(in_register_00002039,connectable) != 0)) { + iVar1 = set_ad(0x2009,(bt_ad *)&data.data,2); + } + } + return iVar1; +} + + + +bt_addr_le_t * bt_lookup_id_addr(u8_t id,bt_addr_le_t *addr) + +{ + bt_keys *pbVar1; + + pbVar1 = bt_keys_find_irk(id,addr); + if (pbVar1 != (bt_keys *)0x0) { + addr = &pbVar1->addr; + } + return addr; +} + + + +_Bool bt_le_conn_params_valid(bt_le_conn_param *param) + +{ + ushort uVar1; + bool bVar2; + + uVar1 = param->interval_max; + bVar2 = false; + if (((((uint)param->interval_min <= (uint)uVar1) && (bVar2 = false, 5 < param->interval_min)) && + (uVar1 < 0xc81)) && ((param->latency < 500 && (((uint)param->timeout - 10 & 0xffff) < 0xc77))) + ) { + bVar2 = ((uint)param->latency + 1) * (uint)uVar1 < (uint)param->timeout << 2; + } + return (_Bool)bVar2; +} + + + +int bt_unpair(u8_t id,bt_addr_le_t *addr) + +{ + undefined3 in_register_00002029; + int iVar1; + bt_conn *conn; + bt_keys *keys; + undefined4 uStack24; + undefined2 uStack20; + undefined uStack18; + + if (CONCAT31(in_register_00002029,id) != 0) { + return -0x16; + } + if (addr == (bt_addr_le_t *)0x0) { +LAB_2304ede8: + bt_conn_disconnect_all('\0'); + bt_keys_clear_all('\0'); + return 0; + } + uStack24 = 0; + uStack20 = 0; + uStack18 = 0; + iVar1 = memcmp(addr,&uStack24,7); + if (iVar1 == 0) goto LAB_2304ede8; + conn = bt_conn_lookup_addr_le('\0',addr); + if (conn != (bt_conn *)0x0) { + keys = (bt_keys *)0x0; + if (conn->type == '\x01') { + keys = *(bt_keys **)(conn->field_20 + 0x2c); + *(undefined4 *)(conn->field_20 + 0x2c) = 0; + } + bt_conn_disconnect(conn,'\x13'); + bt_conn_unref(conn); + if (keys != (bt_keys *)0x0) goto LAB_2304ee30; + } + keys = bt_keys_find_addr('\0',addr); + if (keys == (bt_keys *)0x0) { + return 0; + } +LAB_2304ee30: + bt_keys_clear(keys); + return 0; +} + + + +void bt_id_add(bt_keys *keys) + +{ + bt_conn *conn; + int iVar1; + int iVar2; + int iVar3; + char *fmt; + net_buf *buf; + undefined auStack40 [4]; + bt_hci_cp_le_set_privacy_mode cp; + + if ((bt_dev.le.rl_size == '\0') || (bt_dev.le.rl_size < bt_dev.le.rl_entries)) { + bt_dev.le.rl_entries = bt_dev.le.rl_entries + '\x01'; + return; + } + conn = bt_conn_lookup_state_le((bt_addr_le_t *)0x0,BT_CONN_CONNECT); + if (conn != (bt_conn *)0x0) { + atomic_or(bt_dev.flags,0x20000); + keys->flags = keys->flags | 4; + bt_conn_unref(conn); + return; + } + iVar1 = atomic_test_bit(bt_dev.flags,6); + if (iVar1 != 0) { + set_advertise_enable(false); + } + iVar2 = atomic_test_bit(bt_dev.flags,10); + if (iVar2 != 0) { + set_le_scan_enable('\0'); + } + if ((bt_dev.le.rl_entries == '\0') || (iVar3 = addr_res_enable('\0'), iVar3 == 0)) { + if (bt_dev.le.rl_entries == bt_dev.le.rl_size) { + printf("Resolving list size exceeded. Switching to host.\r\n"); + iVar3 = bt_hci_cmd_send_sync(0x2029,(net_buf *)0x0,(net_buf **)0x0); + if (iVar3 == 0) { + bt_dev.le.rl_entries = bt_dev.le.rl_entries + '\x01'; + goto done; + } + fmt = "Failed to clear resolution list\r\n"; + } + else { + iVar3 = hci_id_add(&keys->addr,(u8_t *)&keys->irk); + if (iVar3 == 0) { + bt_dev.le.rl_entries = bt_dev.le.rl_entries + '\x01'; + if ((bt_dev.supported_commands[39] & 4) == 0) { + fmt = "Set privacy mode command is not supported\r\n"; + } + else { + bt_addr_le_copy((bt_addr_le_t *)auStack40,&keys->addr); + cp.id_addr.a.val[2] = '\x01'; + buf = bt_hci_cmd_create(0x204e,'\b'); + if (buf != (net_buf *)0x0) { + net_buf_simple_add_mem((net_buf_simple *)&buf->field_4,auStack40,8); + iVar3 = bt_hci_cmd_send_sync(0x204e,buf,(net_buf **)0x0); + if (iVar3 == 0) goto done; + } + fmt = "Failed to set privacy mode\r\n"; + } + } + else { + fmt = "Failed to add IRK to controller\r\n"; + } + } + } + else { + fmt = "Failed to disable address resolution\r\n"; + } + printf(fmt); +done: + addr_res_enable('\x01'); + if (iVar2 != 0) { + set_le_scan_enable('\x01'); + } + if (iVar1 != 0) { + set_advertise_enable(true); + } + return; +} + + + +void bt_id_del(bt_keys *keys) + +{ + bt_conn *conn; + int iVar1; + int iVar2; + int iVar3; + net_buf *buf; + bt_addr_le_t *dst; + + if ((bt_dev.le.rl_size == '\0') || ((uint)bt_dev.le.rl_size + 1 < (uint)bt_dev.le.rl_entries)) { + bt_dev.le.rl_entries = bt_dev.le.rl_entries + -1; + } + else { + conn = bt_conn_lookup_state_le((bt_addr_le_t *)0x0,BT_CONN_CONNECT); + if (conn != (bt_conn *)0x0) { + atomic_or(bt_dev.flags,0x20000); + keys->flags = keys->flags | 8; + bt_conn_unref(conn); + return; + } + iVar1 = atomic_test_bit(bt_dev.flags,6); + if (iVar1 != 0) { + set_advertise_enable(false); + } + iVar2 = atomic_test_bit(bt_dev.flags,10); + if (iVar2 != 0) { + set_le_scan_enable('\0'); + } + iVar3 = addr_res_enable('\0'); + if (iVar3 == 0) { + if (bt_dev.le.rl_size < bt_dev.le.rl_entries) { + bt_dev.le.rl_entries = bt_dev.le.rl_entries + -1; + keys->keys = keys->keys & 0xfffd; + bt_keys_foreach(2,keys_add_id,(void *)0x0); + } + else { + buf = bt_hci_cmd_create(0x2028,'\a'); + if (buf != (net_buf *)0x0) { + dst = (bt_addr_le_t *)net_buf_simple_add((net_buf_simple *)&buf->field_4,7); + bt_addr_le_copy(dst,&keys->addr); + iVar3 = bt_hci_cmd_send_sync(0x2028,buf,(net_buf **)0x0); + if (iVar3 == 0) { + bt_dev.le.rl_entries = bt_dev.le.rl_entries + -1; + } + else { + printf("Failed to remove IRK from controller\r\n"); + } + } + } + } + else { + printf("Disabling address resolution failed (err %d)\r\n",iVar3); + } + if (bt_dev.le.rl_entries != '\0') { + addr_res_enable('\x01'); + } + if (iVar2 != 0) { + set_le_scan_enable('\x01'); + } + if (iVar1 != 0) { + set_advertise_enable(true); + return; + } + } + return; +} + + + +void update_pending_id(bt_keys *keys,void *data) + +{ + byte bVar1; + + bVar1 = keys->flags; + if ((bVar1 & 4) != 0) { + keys->flags = bVar1 & 0xfb; + bt_id_add(keys); + return; + } + if ((bVar1 & 8) != 0) { + keys->flags = bVar1 & 0xf7; + bt_id_del(keys); + return; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void bt_data_parse(net_buf_simple *ad,anon_subr__Bool_bt_data_ptr_void_ptr *func,void *user_data) + +{ + u8_t uVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 extraout_var_00; + u8_t uStack40; + u8_t uStack39; + bt_data data; + + while( true ) { + if (ad->len < 2) { + return; + } + uVar1 = net_buf_simple_pull_u8(ad); + _uVar1 = CONCAT31(extraout_var,uVar1); + if (_uVar1 == 0) { + return; + } + if ((uint)ad->len < (_uVar1 & 0xffff)) { + printf("Malformed data\r\n"); + return; + } + uStack40 = net_buf_simple_pull_u8(ad); + data._0_4_ = ad->data; + uStack39 = (u8_t)(_uVar1 - 1); + _Var2 = (*func)((bt_data *)&uStack40,user_data); + if (CONCAT31(extraout_var_00,_Var2) == 0) break; + net_buf_simple_pull(ad,_uVar1 - 1); + } + return; +} + + + +int bt_addr_le_create_static(bt_addr_le_t *addr) + +{ + int iVar1; + + addr->type = '\x01'; + iVar1 = bt_rand(&addr->a,6); + if (iVar1 == 0) { + (addr->a).val[5] = (addr->a).val[5] | 0xc0; + } + return iVar1; +} + + + +void id_create(u8_t id,bt_addr_le_t *addr) + +{ + bool bVar1; + bt_addr_le_t *dst; + undefined3 in_register_00002029; + int iVar2; + bt_addr_le_t *dst_00; + undefined4 local_20; + undefined2 uStack28; + undefined uStack26; + undefined auStack24 [4]; + bt_addr_le_t new_addr; + + dst = bt_dev.id_addr + CONCAT31(in_register_00002029,id); + if (addr != (bt_addr_le_t *)0x0) { + local_20 = 0; + uStack28 = 0; + uStack26 = 0; + iVar2 = memcmp(addr,&local_20,7); + dst_00 = dst; + if (iVar2 != 0) goto LAB_2304f258; + } + do { + bt_addr_le_create_static((bt_addr_le_t *)auStack24); + iVar2 = id_find((bt_addr_le_t *)auStack24); + } while (-1 < iVar2); + bt_addr_le_copy(dst,(bt_addr_le_t *)auStack24); + bVar1 = addr == (bt_addr_le_t *)0x0; + dst_00 = addr; + addr = dst; + if (bVar1) { + return; + } +LAB_2304f258: + bt_addr_le_copy(dst_00,addr); + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +int bt_send(net_buf *buf) + +{ + int iVar1; + + // WARNING: Could not recover jumptable at 0x2304f292. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*(bt_dev.drv)->send)(); + return iVar1; +} + + + +int bt_hci_cmd_send(u16_t opcode,net_buf *buf) + +{ + undefined2 in_register_0000202a; + int iVar1; + + if ((buf == (net_buf *)0x0) && (buf = bt_hci_cmd_create(opcode,'\0'), buf == (net_buf *)0x0)) { + return -0x37; + } + if (CONCAT22(in_register_0000202a,opcode) == 0xc35) { + iVar1 = bt_send(buf); + if (iVar1 != 0) { + printf("Unable to send to driver (err %d)\r\n",iVar1); + net_buf_unref(buf); + } + } + else { + net_buf_put(&bt_dev.cmd_tx_queue,buf); + k_sem_give(&g_poll_sem); + iVar1 = 0; + } + return iVar1; +} + + + +int bt_le_set_data_len(bt_conn *conn,u16_t tx_octets,u16_t tx_time) + +{ + u16_t uVar1; + net_buf *buf; + undefined *puVar2; + int iVar3; + + buf = bt_hci_cmd_create(0x2022,'\x06'); + if (buf != (net_buf *)0x0) { + puVar2 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,6); + uVar1 = conn->handle; + puVar2[2] = (char)tx_octets; + puVar2[4] = (char)tx_time; + *puVar2 = (char)uVar1; + puVar2[1] = (char)(uVar1 >> 8); + puVar2[3] = (char)(tx_octets >> 8); + puVar2[5] = (char)(tx_time >> 8); + iVar3 = bt_hci_cmd_send(0x2022,buf); + return iVar3; + } + printf("bt_le_set_data_len, Failed to create LE Set Data Length Command\r\n"); + return -0x37; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int start_le_scan(u8_t scan_type,u16_t interval,u16_t window) + +{ + undefined3 in_register_00002029; + int iVar1; + net_buf *buf; + u8_t uStack40; + undefined uStack39; + undefined uStack38; + undefined uStack37; + bt_hci_cp_le_set_scan_param set_param; + + memset(&uStack40,0,7); + uStack37 = (undefined)window; + uStack39 = (undefined)interval; + set_param.scan_type = (u8_t)(window >> 8); + uStack38 = (undefined)(interval >> 8); + uStack40 = scan_type; + iVar1 = atomic_test_bit(bt_dev.flags,0xe); + set_param.interval._1_1_ = iVar1 != 0; + set_param.interval._0_1_ = bt_dev.id_addr[0].type; + if ((CONCAT31(in_register_00002029,scan_type) == 1) && + (iVar1 = atomic_test_bit(bt_dev.flags,6), iVar1 == 0)) { + iVar1 = le_set_private_addr(); + set_param.interval._0_1_ = scan_type; + } + else { + if ((u8_t)set_param.interval != '\x01') goto LAB_2304f40c; + iVar1 = set_random_address(&bt_dev.id_addr[0].a); + } + if (iVar1 != 0) { + return iVar1; + } +LAB_2304f40c: + buf = bt_hci_cmd_create(0x200b,'\a'); + iVar1 = -0x37; + if (buf != (net_buf *)0x0) { + net_buf_simple_add_mem((net_buf_simple *)&buf->field_4,&uStack40,7); + bt_hci_cmd_send(0x200b,buf); + iVar1 = set_le_scan_enable('\x01'); + if (iVar1 == 0) { + atomic_set_bit_to(bt_dev.flags,0xc,(_Bool)(CONCAT31(in_register_00002029,scan_type) == 1)); + } + } + return iVar1; +} + + + +int bt_le_scan_update(_Bool fast_scan) + +{ + undefined3 in_register_00002029; + int iVar1; + bt_conn *conn; + u16_t interval; + u16_t window; + + iVar1 = atomic_test_bit(bt_dev.flags,0xb); + if (iVar1 == 0) { + iVar1 = atomic_test_bit(bt_dev.flags,10); + if ((iVar1 != 0) && (iVar1 = set_le_scan_enable('\0'), iVar1 != 0)) { + return iVar1; + } + conn = bt_conn_lookup_state_le((bt_addr_le_t *)0x0,BT_CONN_CONNECT); + if (conn == (bt_conn *)0x0) { + conn = bt_conn_lookup_state_le((bt_addr_le_t *)0x0,BT_CONN_CONNECT_SCAN); + if (conn != (bt_conn *)0x0) { + atomic_and(bt_dev.flags,-0x2001); + bt_conn_unref(conn); + if (CONCAT31(in_register_00002029,fast_scan) == 0) { + window = 0x12; + interval = 0x800; + } + else { + window = 0x30; + interval = 0x60; + } + iVar1 = start_le_scan('\0',interval,window); + return iVar1; + } + } + else { + bt_conn_unref(conn); + } + } + return 0; +} + + + +void le_adv_report(net_buf *buf) + +{ + byte bVar1; + undefined2 uVar2; + bt_le_scan_cb_t_conflict1 *pbVar3; + u8_t uVar4; + undefined3 extraout_var; + byte *pbVar5; + size_t sVar6; + int iVar7; + bt_conn *conn; + net_buf *buf_00; + undefined *__s; + bt_addr_le_t *src; + uint uVar8; + net_buf_simple *buf_01; + bt_addr_le_t *addr; + uint uVar9; + u8_t auStack72 [4]; + bt_addr_le_t id_addr; + + buf_01 = (net_buf_simple *)&buf->field_4; + uVar4 = net_buf_simple_pull_u8(buf_01); + uVar8 = CONCAT31(extraout_var,uVar4); + do { + if (uVar8 == 0) { + return; + } + if (*(ushort *)((int)&buf->field_4 + 4) < 9) { + printf("Unexpected end of buffer\r\n"); + return; + } + pbVar5 = (byte *)net_buf_simple_pull_mem(buf_01,9); + addr = (bt_addr_le_t *)(pbVar5 + 1); + bVar1 = pbVar5[(uint)pbVar5[8] + 9]; + if ((byte)(pbVar5[1] - 2) < 2) { + bt_addr_le_copy((bt_addr_le_t *)auStack72,addr); + auStack72[0] = auStack72[0] + -2; + } + else { + src = bt_lookup_id_addr(bt_dev.adv_id,addr); + bt_addr_le_copy((bt_addr_le_t *)auStack72,src); + } + if (scan_dev_found_cb != (bt_le_scan_cb_t_conflict1 *)0x0) { + sVar6 = net_buf_simple_headroom(buf_01); + pbVar3 = scan_dev_found_cb; + uVar2 = *(undefined2 *)((int)&buf->field_4 + 4); + *(ushort *)((int)&buf->field_4 + 4) = (ushort)pbVar5[8]; + (*pbVar3)((bt_addr_le_t *)auStack72,bVar1,*pbVar5,buf_01); + *(undefined2 *)((int)&buf->field_4 + 4) = uVar2; + *(size_t *)&buf->field_4 = *(int *)((int)&buf->field_4 + 8) + (sVar6 & 0xffff); + } + bVar1 = *pbVar5; + iVar7 = atomic_test_bit(bt_dev.flags,0xb); + if (((iVar7 == 0) && (bVar1 < 2)) && + (conn = bt_conn_lookup_state_le((bt_addr_le_t *)auStack72,BT_CONN_CONNECT_SCAN), + conn != (bt_conn *)0x0)) { + iVar7 = atomic_test_bit(bt_dev.flags,10); + if ((iVar7 == 0) || (iVar7 = set_le_scan_enable('\0'), iVar7 == 0)) { + src = (bt_addr_le_t *)(conn->field_20 + 0xe); + bt_addr_le_copy(src,addr); + uVar9 = (uint)conn->id; + if ((bt_dev.id_addr[uVar9].type != '\x01') || + (iVar7 = set_random_address(&bt_dev.id_addr[uVar9].a), iVar7 == 0)) { + uVar4 = bt_dev.id_addr[uVar9].type; + buf_00 = bt_hci_cmd_create(0x200d,'\x19'); + if (buf_00 != (net_buf *)0x0) { + __s = (undefined *)net_buf_simple_add((net_buf_simple *)&buf_00->field_4,0x19); + memset(__s,0,0x19); + *__s = 0x60; + __s[1] = 0; + __s[2] = 0x60; + __s[3] = 0; + if ((bt_dev.le.rl_size != '\0') && (bt_dev.le.rl_entries <= bt_dev.le.rl_size)) { + src = (bt_addr_le_t *)conn->field_20; + } + bt_addr_le_copy((bt_addr_le_t *)(__s + 5),src); + __s[0xc] = uVar4; + uVar2 = *(undefined2 *)(conn->field_20 + 0x18); + __s[0xd] = (char)uVar2; + __s[0xe] = (char)((ushort)uVar2 >> 8); + uVar2 = *(undefined2 *)(conn->field_20 + 0x1a); + __s[0xf] = (char)uVar2; + __s[0x10] = (char)((ushort)uVar2 >> 8); + uVar2 = *(undefined2 *)(conn->field_20 + 0x1c); + __s[0x11] = (char)uVar2; + __s[0x12] = (char)((ushort)uVar2 >> 8); + uVar2 = *(undefined2 *)(conn->field_20 + 0x1e); + __s[0x13] = (char)uVar2; + __s[0x14] = (char)((ushort)uVar2 >> 8); + iVar7 = bt_hci_cmd_send_sync(0x200d,buf_00,(net_buf **)0x0); + if (iVar7 == 0) { + bt_conn_set_state(conn,BT_CONN_CONNECT); + bt_conn_unref(conn); + goto LAB_2304f716; + } + } + } + } + conn->err = '\x1f'; + bt_conn_set_state(conn,BT_CONN_DISCONNECTED); + bt_conn_unref(conn); + bt_le_scan_update(false); + } +LAB_2304f716: + net_buf_simple_pull(buf_01,(uint)pbVar5[8] + 1); + uVar8 = uVar8 - 1 & 0xff; + } while( true ); +} + + + +void le_ltk_request(net_buf *buf) + +{ + ushort handle; + undefined uVar1; + ushort *puVar2; + _Bool _Var3; + u16_t opcode; + bt_conn *conn; + undefined3 extraout_var; + net_buf *buf_00; + undefined *puVar4; + undefined auStack48 [4]; + u8_t ltk [16]; + + puVar2 = *(ushort **)&buf->field_4; + handle = *puVar2; + conn = bt_conn_lookup_handle(handle); + if (conn == (bt_conn *)0x0) { + printf("Unable to lookup conn for handle %u\r\n",(uint)handle); + return; + } + _Var3 = bt_smp_request_ltk(conn,(u16_t)*(undefined4 *)(puVar2 + 1),*(u8_t **)(puVar2 + 3)); + uVar1 = (undefined)(handle >> 8); + if (CONCAT31(extraout_var,_Var3) == 0) { + buf_00 = bt_hci_cmd_create(0x201b,'\x02'); + if (buf_00 == (net_buf *)0x0) goto LAB_2304f806; + puVar4 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf_00->field_4,2); + *puVar4 = (char)handle; + puVar4[1] = uVar1; + opcode = 0x201b; + } + else { + buf_00 = bt_hci_cmd_create(0x201a,'\x12'); + if (buf_00 == (net_buf *)0x0) { +LAB_2304f806: + printf("Out of command buffers\r\n"); + goto LAB_2304f812; + } + puVar4 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf_00->field_4,0x12); + *puVar4 = (char)handle; + puVar4[1] = uVar1; + memcpy(puVar4 + 2,auStack48,0x10); + opcode = 0x201a; + } + bt_hci_cmd_send(opcode,buf_00); +LAB_2304f812: + bt_conn_unref(conn); + return; +} + + + +void le_conn_param_neg_reply(u16_t handle,u8_t reason) + +{ + net_buf *buf; + undefined *puVar1; + + buf = bt_hci_cmd_create(0x2021,'\x03'); + if (buf == (net_buf *)0x0) { + printf("Unable to allocate buffer\r\n"); + return; + } + puVar1 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,3); + *puVar1 = (char)handle; + puVar1[1] = (char)(handle >> 8); + puVar1[2] = reason; + bt_hci_cmd_send(0x2021,buf); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void le_conn_param_req(net_buf *buf) + +{ + ushort handle; + _Bool _Var1; + bt_conn *conn; + undefined3 extraout_var; + net_buf *buf_00; + undefined *__s; + ushort *puVar2; + undefined2 uStack40; + ushort uStack38; + bt_le_conn_param param; + + puVar2 = *(ushort **)&buf->field_4; + handle = *puVar2; + uStack40 = puVar2[1]; + uStack38 = puVar2[2]; + param.interval_min = puVar2[3]; + param.interval_max = puVar2[4]; + conn = bt_conn_lookup_handle(handle); + if (conn == (bt_conn *)0x0) { + printf("Unable to lookup conn for handle %u\r\n",(uint)handle); + le_conn_param_neg_reply(handle,'\x02'); + } + else { + _Var1 = le_param_req(conn,(bt_le_conn_param *)&uStack40); + if (CONCAT31(extraout_var,_Var1) == 0) { + le_conn_param_neg_reply(handle,'\x1e'); + } + else { + buf_00 = bt_hci_cmd_create(0x2020,'\x0e'); + if (buf_00 != (net_buf *)0x0) { + __s = (undefined *)net_buf_simple_add((net_buf_simple *)&buf_00->field_4,0xe); + memset(__s,0,0xe); + *__s = (char)handle; + __s[1] = (char)(handle >> 8); + __s[2] = (undefined)uStack40; + __s[3] = uStack40._1_1_; + __s[4] = (char)uStack38; + __s[5] = (char)(uStack38 >> 8); + __s[6] = (undefined)param.interval_min; + __s[7] = param.interval_min._1_1_; + __s[8] = (char)param.interval_max; + __s[9] = (char)(param.interval_max >> 8); + bt_hci_cmd_send(0x2020,buf_00); + } + } + bt_conn_unref(conn); + } + return; +} + + + +void enh_conn_complete(bt_hci_evt_le_enh_conn_complete *evt) + +{ + u8_t uVar1; + u16_t uVar2; + ushort uVar3; + atomic_val_t aVar4; + bt_conn *conn; + int iVar5; + net_buf *buf; + undefined *puVar6; + u8_t local_30; + undefined auStack47 [3]; + bt_addr_le_t peer_addr; + bt_addr_le_t id_addr; + + uVar3 = evt->handle; + aVar4 = atomic_and(bt_dev.flags,-0x20001); + if (aVar4 << 0xe < 0) { + bt_keys_foreach(2,update_pending_id,(void *)0x0); + } + if (evt->status != '\0') { + conn = find_pending_connect((bt_addr_le_t *)0x0); + if (conn == (bt_conn *)0x0) { + return; + } + uVar1 = evt->status; + conn->err = uVar1; + if (uVar1 == '<') { + atomic_and(bt_dev.flags,-0x41); + } + else { + if (uVar1 != '\x02') { + printf("Unexpected status 0x%02x\r\n"); + bt_conn_unref(conn); + return; + } + } + bt_conn_set_state(conn,BT_CONN_DISCONNECTED); + goto done; + } + bt_addr_le_copy((bt_addr_le_t *)(peer_addr.a.val + 3),&evt->peer_addr); + if ((byte)(peer_addr.a.val[3] - 2) < 2) { + peer_addr.a.val[3] = peer_addr.a.val[3] - 2; + memcpy(&local_30 + 1,&evt->peer_rpa,6); + local_30 = '\x01'; + } + else { + bt_addr_le_copy((bt_addr_le_t *)&local_30,&evt->peer_addr); + } + conn = find_pending_connect((bt_addr_le_t *)(peer_addr.a.val + 3)); + if ((evt->role == '\x01') && (atomic_and(bt_dev.flags,-0x41), conn == (bt_conn *)0x0)) { + conn = bt_conn_add_le(bt_dev.adv_id,(bt_addr_le_t *)(peer_addr.a.val + 3)); + } + if (evt->role == '\0') { + if (conn == (bt_conn *)0x0) { + conn = bt_conn_add_le('\0',(bt_addr_le_t *)(peer_addr.a.val + 3)); + goto LAB_2304fb1c; + } + } + else { +LAB_2304fb1c: + if (conn == (bt_conn *)0x0) { + printf("Unable to add new conn for handle %u\r\n",(uint)uVar3); + return; + } + } + conn->handle = uVar3; + bt_addr_le_copy((bt_addr_le_t *)conn->field_20,(bt_addr_le_t *)(peer_addr.a.val + 3)); + *(u16_t *)(conn->field_20 + 0x16) = evt->interval; + *(u16_t *)(conn->field_20 + 0x1c) = evt->latency; + *(u16_t *)(conn->field_20 + 0x1e) = evt->supv_timeout; + uVar1 = evt->role; + conn->err = '\0'; + conn->role = uVar1; + if (uVar1 == '\x01') { + bt_addr_le_copy((bt_addr_le_t *)(conn->field_20 + 7),(bt_addr_le_t *)&local_30); + bt_addr_le_copy((bt_addr_le_t *)(conn->field_20 + 0xe),bt_dev.id_addr + conn->id); + iVar5 = atomic_test_bit(bt_dev.flags,9); + if ((iVar5 != 0) && ((bt_dev.le.states._4_4_ & 0x40) != 0)) { + set_advertise_enable(true); + } + } + if (conn->role == '\0') { + iVar5 = atomic_test_bit(bt_dev.flags,0xf); + if (iVar5 != 0) { + conn->id = '\0'; + atomic_and(bt_dev.flags,-0x8001); + } + bt_addr_le_copy((bt_addr_le_t *)(conn->field_20 + 0xe),(bt_addr_le_t *)&local_30); + bt_addr_le_copy((bt_addr_le_t *)(conn->field_20 + 7),bt_dev.id_addr + conn->id); + } + bt_conn_set_state(conn,BT_CONN_CONNECTED); + if (conn->state == BT_CONN_CONNECTED) { + if (((evt->role == '\0') || ((bt_dev.le.features[0] & 8) != 0)) && + (buf = bt_hci_cmd_create(0x2016,'\x02'), buf != (net_buf *)0x0)) { + puVar6 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + uVar2 = conn->handle; + *puVar6 = (char)uVar2; + puVar6[1] = (char)(uVar2 >> 8); + bt_hci_cmd_send(0x2016,buf); + } + else { + if (conn->role == '\x01') { + slave_update_conn_param(conn); + } + } + } +done: + bt_conn_unref(conn); + bt_le_scan_update(false); + return; +} + + + +void le_enh_conn_complete(net_buf *buf) + +{ + enh_conn_complete(*(bt_hci_evt_le_enh_conn_complete **)&buf->field_4); + return; +} + + + +void le_legacy_conn_complete(net_buf *buf) + +{ + u8_t *puVar1; + u8_t src; + undefined4 local_40; + undefined2 uStack60; + undefined4 uStack56; + undefined2 uStack52; + u8_t uStack48; + u8_t uStack47; + u8_t uStack46; + u8_t uStack45; + bt_hci_evt_le_enh_conn_complete enh; + + puVar1 = *(u8_t **)&buf->field_4; + uStack48 = *puVar1; + uStack47 = puVar1[1]; + uStack46 = puVar1[2]; + uStack45 = puVar1[3]; + enh.peer_rpa.val[2] = (u8_t)*(undefined2 *)(puVar1 + 0xb); + enh.peer_rpa.val[3] = (u8_t)((ushort)*(undefined2 *)(puVar1 + 0xb) >> 8); + enh.peer_rpa.val[4] = (u8_t)*(undefined2 *)(puVar1 + 0xd); + enh.peer_rpa.val[5] = (u8_t)((ushort)*(undefined2 *)(puVar1 + 0xd) >> 8); + enh.interval._0_1_ = (undefined)*(undefined2 *)(puVar1 + 0xf); + enh.interval._1_1_ = (undefined)((ushort)*(undefined2 *)(puVar1 + 0xf) >> 8); + enh.latency._0_1_ = puVar1[0x11]; + bt_addr_le_copy((bt_addr_le_t *)&enh,(bt_addr_le_t *)(puVar1 + 4)); + local_40 = 0; + uStack60 = 0; + memcpy(enh.peer_addr.a.val + 2,&local_40,6); + src = '\0'; + if (puVar1[3] == '\x01') { + src = bt_dev.adv_id; + } + _src = (bt_hci_evt_le_enh_conn_complete *)bt_lookup_id_addr(src,(bt_addr_le_t *)&enh); + if (_src == &enh) { + uStack56 = 0; + uStack52 = 0; + memcpy(enh.local_rpa.val + 2,&uStack56,6); + } + else { + memcpy(enh.local_rpa.val + 2,&enh.handle,6); + bt_addr_le_copy((bt_addr_le_t *)&enh,(bt_addr_le_t *)_src); + enh.status = enh.status + '\x02'; + } + enh_conn_complete((bt_hci_evt_le_enh_conn_complete *)&uStack48); + return; +} + + + +void hci_tx_thread(void *p1) + +{ + k_poll_event events [4]; + int num_events; + int iVar1; + net_buf *buf; + uint uVar2; + int iVar3; + + do { + events[0]._12_4_ = events[0]._12_4_ & 0xffff0fff; + num_events = bt_conn_prepare_events((k_poll_event *)0x4200de4c); + num_events = num_events + 1; + iVar1 = k_poll((k_poll_event *)0x4200de38,num_events,-1); + iVar3 = 0x4200de38; + if (iVar1 != 0) { + vAssertCalled(); + } + while (num_events != 0) { + uVar2 = *(uint *)(iVar3 + 0xc) >> 0xc & 0xf; + if (uVar2 != 2) { + if (uVar2 == 4) { + if (*(char *)(iVar3 + 0xc) == '\0') { + buf = net_buf_get(&bt_dev.cmd_tx_queue,0); + if (buf == (net_buf *)0x0) { + vAssertCalled(); + } + k_sem_take(&bt_dev.ncmd_sem,0xffffffff); + if (bt_dev.sent_cmd != (net_buf *)0x0) { + printf("Uncleared pending sent_cmd\r\n"); + net_buf_unref(bt_dev.sent_cmd); + bt_dev.sent_cmd = (net_buf *)0x0; + } + bt_dev.sent_cmd = net_buf_ref(buf); + iVar1 = bt_send(buf); + if (iVar1 != 0) { + printf("Unable to send to driver (err %d)\r\n",iVar1); + k_sem_give(&bt_dev.ncmd_sem); + iVar1 = net_buf_id(buf); + hci_cmd_done(cmd_data[iVar1].opcode,'\x1f',(net_buf *)0x0); + net_buf_unref(bt_dev.sent_cmd); + bt_dev.sent_cmd = (net_buf *)0x0; + net_buf_unref(buf); + } + } + else { + if (*(char *)(iVar3 + 0xc) == '\x01') { + bt_conn_process_tx(*(int *)(iVar3 + 0x10) + -0x34); + } + } + } + else { + if (uVar2 != 0) { + printf("Unexpected k_poll event state %u\r\n"); + } + } + } + num_events = num_events + -1; + iVar3 = iVar3 + 0x14; + } + k_yield(); + } while( true ); +} + + + +int bt_recv(net_buf *buf) + +{ + byte bVar1; + ushort uVar2; + ushort uVar3; + ushort uVar4; + u8_t uVar5; + ushort handle; + ushort *puVar6; + bt_conn *conn; + byte *pbVar7; + + bVar1 = buf->user_data[0]; + if (bVar1 == 1) { + if ((uint)*(ushort *)((int)&buf->field_4 + 4) <= (uint)bVar1) { + vAssertCalled(); + } + pbVar7 = (byte *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,2); + if ((*pbVar7 < 0x1b) && ((1 << ((uint)*pbVar7 & 0x1f) & 0x408c000U) != 0)) { + vAssertCalled(); + } + handle_event(*pbVar7,buf,normal_events,5); + } + else { + if (bVar1 != 3) { + printf("Invalid buf type %u\r\n"); + net_buf_unref(buf); + return -0x16; + } + if ((uint)*(ushort *)((int)&buf->field_4 + 4) <= (uint)bVar1) { + vAssertCalled(); + } + puVar6 = (ushort *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,4); + uVar3 = puVar6[1]; + uVar4 = *puVar6; + uVar2 = *(ushort *)((int)&buf->field_4 + 4); + handle = (ushort)(((uint)uVar4 << 0x14) >> 0x14); + *(ushort *)(buf->user_data + 2) = handle; + buf->user_data[1] = -1; + if (uVar3 == uVar2) { + conn = bt_conn_lookup_handle(handle); + if (conn != (bt_conn *)0x0) { + uVar5 = bt_conn_index(conn); + buf->user_data[1] = uVar5; + bt_conn_recv(conn,buf,(byte)(uVar4 >> 0xc)); + bt_conn_unref(conn); + return 0; + } + printf("Unable to find conn for handle %u\r\n",(uint)*(ushort *)(buf->user_data + 2)); + } + else { + printf("ACL data length mismatch (%u != %u)\r\n"); + } + } + net_buf_unref(buf); + return 0; +} + + + +undefined4 bt_recv_prio(net_buf *param_1) + +{ + byte *pbVar1; + + if (param_1->user_data[0] != '\x01') { + vAssertCalled(); + } + if (*(ushort *)((int)¶m_1->field_4 + 4) < 2) { + vAssertCalled(); + } + pbVar1 = (byte *)net_buf_simple_pull_mem((net_buf_simple *)¶m_1->field_4,2); + if (*pbVar1 < 0x1b) { + if ((1 << ((uint)*pbVar1 & 0x1f) & 0x408c000U) != 0) goto LAB_2305000e; + } + vAssertCalled(); +LAB_2305000e: + handle_event(*pbVar1,param_1,prio_events,4); + net_buf_unref(param_1); + return 0; +} + + + +int bt_hci_driver_register(bt_hci_driver *drv) + +{ + int iVar1; + + if (bt_dev.drv == (bt_hci_driver *)0x0) { + iVar1 = -0x16; + if ((drv->open != (anon_subr_int_for_open *)0x0) && + (drv->send != (anon_subr_int_net_buf_ptr_for_send *)0x0)) { + iVar1 = 0; + bt_dev.drv = drv; + } + } + else { + iVar1 = -0x45; + } + return iVar1; +} + + + +void bt_finalize_init(void) + +{ + atomic_or(bt_dev.flags,2); + bt_le_scan_update(false); + return; +} + + + +void bt_delete_queue(k_fifo *queue_to_del) + +{ + net_buf *buf; + + while (buf = net_buf_get(queue_to_del,0), buf != (net_buf *)0x0) { + net_buf_unref(buf); + } + k_queue_free((k_queue *)queue_to_del); + return; +} + + + +int bt_disable_action(void) + +{ + bt_gatt_deinit(); + k_thread_delete(&tx_thread_data); + k_thread_delete(&recv_thread_data); + k_thread_delete(&work_q_thread); + bt_delete_queue(&recv_fifo); + bt_delete_queue((k_fifo *)&g_work_queue_main); + bt_delete_queue(&bt_dev.cmd_tx_queue); + k_queue_free((k_queue *)&free_tx); + k_sem_delete(&bt_dev.ncmd_sem); + k_sem_delete(&g_poll_sem); + k_sem_delete(&sc_local_pkey_ready); + k_sem_delete(&bt_dev.le.pkts); + queue_inited = true; + atomic_and(bt_dev.flags,-2); + bl_onchiphci_interface_deinit(); + ble_controller_deinit(); + return 0; +} + + + +int bt_disable(void) + +{ + _Bool _Var1; + undefined3 extraout_var; + int iVar2; + + _Var1 = le_check_valid_conn(); + if (((CONCAT31(extraout_var,_Var1) == 0) && + (iVar2 = atomic_test_bit(bt_dev.flags,0xb), iVar2 == 0)) && + (iVar2 = atomic_test_bit(bt_dev.flags,6), iVar2 == 0)) { + iVar2 = bt_disable_action(); + return iVar2; + } + return -1; +} + + + +// WARNING: Variable defined which should be unmapped: sd +// WARNING: Could not reconcile some variable overlaps + +int bt_set_name(char *name) + +{ + size_t sVar1; + int iVar2; + u8_t local_20; + undefined uStack31; + bt_data data [1]; + bt_ad sd; + + data[0].data = &local_20; + sVar1 = strlen(name); + if (sVar1 < 0x1e) { + iVar2 = strcmp(bt_dev.name,name); + if (iVar2 != 0) { + strncpy(bt_dev.name,name,0x1e); + iVar2 = atomic_test_bit(bt_dev.flags,7); + if (iVar2 != 0) { + local_20 = '\t'; + sVar1 = strlen(name); + uStack31 = (undefined)sVar1; + data[0]._0_4_ = name; + set_ad(0x2009,(bt_ad *)&data[0].data,1); + iVar2 = atomic_test_bit(bt_dev.flags,6); + if (iVar2 != 0) { + set_advertise_enable(false); + set_advertise_enable(true); + } + } + } + iVar2 = 0; + } + else { + iVar2 = -0xc; + } + return iVar2; +} + + + +int bt_enable(bt_ready_cb_t *cb) + +{ + int iVar1; + uint uVar2; + + if (bt_dev.drv == (bt_hci_driver *)0x0) { + printf("No HCI driver registered\r\n"); + iVar1 = -0x13; + } + else { + uVar2 = atomic_or(bt_dev.flags,1); + iVar1 = -0x45; + if ((uVar2 & 1) == 0) { + k_work_init(&bt_dev.init,init_work); + k_work_q_start(); + k_sem_init(&bt_dev.ncmd_sem,1,1); + k_queue_init((k_queue *)&bt_dev.cmd_tx_queue,0x14); + if (queue_inited == false) { + k_queue_init((k_queue *)&hci_cmd_pool,2); + k_queue_init((k_queue *)&hci_rx_pool,10); + } + k_sem_init(&g_poll_sem,0,1); + bt_set_name("BL602-BLE-DEV"); + ready_cb = cb; + k_thread_create(&tx_thread_data,"hci_tx_thread",0x600,hci_tx_thread,0x1d); + iVar1 = (*(bt_dev.drv)->open)((bt_dev.drv)->open); + if (iVar1 == 0) { + k_work_submit(&bt_dev.init); + } + else { + printf("HCI driver open failed (%d)\r\n",iVar1); + } + } + } + return iVar1; +} + + + +char * bt_get_name(void) + +{ + return bt_dev.name; +} + + + +int bt_id_create(bt_addr_le_t *addr,u8_t *irk) + +{ + bool bVar1; + u8_t id; + uint uVar2; + int iVar3; + u8_t uVar4; + uint uVar5; + undefined4 uStack40; + undefined2 uStack36; + undefined uStack34; + + if (addr != (bt_addr_le_t *)0x0) { + uStack40 = 0; + uStack36 = 0; + uStack34 = 0; + iVar3 = memcmp(addr,&uStack40,7); + if (iVar3 != 0) { + if ((addr->type != '\x01') || (((addr->a).val[5] & 0xc0) != 0xc0)) { + printf("Only static random identity address supported\r\n"); + return -0x16; + } + iVar3 = id_find(addr); + if (-1 < iVar3) { + return -0x45; + } + } + } + id = bt_dev.id_count; + uVar2 = 0xffffffea; + if (irk == (u8_t *)0x0) { + uVar5 = (uint)bt_dev.id_count; + uVar2 = 0xfffffff4; + if (bt_dev.id_count != '\x01') { + uVar4 = bt_dev.id_count + '\x01'; + bVar1 = bt_dev.id_count == '\0'; + bt_dev.id_count = uVar4; + if ((bVar1) && (iVar3 = atomic_test_bit(bt_dev.flags,1), iVar3 == 0)) { + atomic_or(bt_dev.flags,8); + } + id_create(id,addr); + uVar2 = uVar5; + } + } + return uVar2; +} + + + +int bt_setup_id_addr(void) + +{ + int iVar1; + + iVar1 = bt_id_create((bt_addr_le_t *)0x0,(u8_t *)0x0); + return iVar1; +} + + + +void init_work(k_work *work) + +{ + void *__s1; + uint8_t uVar1; + undefined3 extraout_var; + int iVar2; + uint initial_count; + net_buf *buf; + u8_t *dst; + undefined *puVar3; + net_buf *pnStack36; + net_buf *rsp; + undefined4 uStack24; + undefined2 uStack20; + + uVar1 = bl_onchiphci_interface_init(); + iVar2 = CONCAT31(extraout_var,uVar1); + if (iVar2 != 0) goto LAB_23050590; + if (((bt_dev.drv)->quirks & 1) == 0) { + iVar2 = bt_hci_cmd_send_sync(0xc03,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_23050590; + if (**(char **)&pnStack36->field_4 == '\0') { + scan_dev_found_cb = (bt_le_scan_cb_t_conflict1 *)0x0; + initial_count = atomic_get(bt_dev.flags); + atomic_set(bt_dev.flags,initial_count & 0xd); + } + net_buf_unref(pnStack36); + } + iVar2 = bt_hci_cmd_send_sync(0x1003,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_23050590; + memcpy(bt_dev.features,(void *)(*(int *)&pnStack36->field_4 + 1),8); + net_buf_unref(pnStack36); + iVar2 = bt_hci_cmd_send_sync(0x1001,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_23050590; + iVar2 = *(int *)&pnStack36->field_4; + bt_dev.hci_version = *(u8_t *)(iVar2 + 1); + bt_dev.hci_revision = *(u16_t *)(iVar2 + 2); + bt_dev.lmp_version = *(u8_t *)(iVar2 + 4); + bt_dev.lmp_subversion = *(u16_t *)(iVar2 + 7); + bt_dev.manufacturer = *(u16_t *)(iVar2 + 5); + net_buf_unref(pnStack36); + iVar2 = atomic_test_bit(bt_dev.flags,3); + if (iVar2 == 0) { + iVar2 = bt_hci_cmd_send_sync(0x1009,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_23050590; + rsp = (net_buf *)0x0; + __s1 = (void *)(*(int *)&pnStack36->field_4 + 1); + iVar2 = memcmp(__s1,&rsp,6); + if (iVar2 != 0) { + uStack24 = DAT_4200ee8c; + uStack20 = DAT_4200ee90; + iVar2 = memcmp(__s1,&uStack24,6); + if (iVar2 != 0) { + memcpy(&bt_dev.id_addr[0].a,__s1,6); + bt_dev.id_addr[0].type = '\0'; + bt_dev.id_count = '\x01'; + } + } + net_buf_unref(pnStack36); + } + iVar2 = bt_hci_cmd_send_sync(0x1002,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_23050590; + memcpy(bt_dev.supported_commands,(void *)(*(int *)&pnStack36->field_4 + 1),0x40); + net_buf_unref(pnStack36); + if ((bt_dev.features[0][4] & 0x40) == 0) { + printf("Non-LE capable controller detected!\r\n"); + iVar2 = -0x13; + goto LAB_23050590; + } + iVar2 = bt_hci_cmd_send_sync(0x2003,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_23050590; + memcpy(&bt_dev.le,(void *)(*(int *)&pnStack36->field_4 + 1),8); + net_buf_unref(pnStack36); + iVar2 = bt_hci_cmd_send_sync(0x2002,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_23050590; + bt_dev.le.mtu = *(u16_t *)(*(int *)&pnStack36->field_4 + 1); + if (bt_dev.le.mtu != 0) { + initial_count = (uint)*(byte *)(*(int *)&pnStack36->field_4 + 3); + k_sem_init(&bt_dev.le.pkts,initial_count,initial_count); + } + net_buf_unref(pnStack36); + if ((bt_dev.features[0][4] & 0x20) == 0) { + buf = bt_hci_cmd_create(0xc6d,'\x02'); + if (buf != (net_buf *)0x0) { + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + *puVar3 = 1; + puVar3[1] = 0; + iVar2 = bt_hci_cmd_send_sync(0xc6d,buf,(net_buf **)0x0); + if (iVar2 != 0) goto LAB_23050590; + goto LAB_23050618; + } + } + else { +LAB_23050618: + if ((bt_dev.supported_commands[28] & 8) != 0) { + iVar2 = bt_hci_cmd_send_sync(0x201c,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_23050590; + bt_dev.le.states._0_4_ = *(undefined4 *)(*(int *)&pnStack36->field_4 + 1); + bt_dev.le.states._4_4_ = *(undefined4 *)(*(int *)&pnStack36->field_4 + 5); + net_buf_unref(pnStack36); + } + if ((bt_dev.le.features[0] & 0x40) != 0) { + iVar2 = bt_hci_cmd_send_sync(0x202a,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_23050590; + bt_dev.le.rl_size = *(u8_t *)(*(int *)&pnStack36->field_4 + 1); + net_buf_unref(pnStack36); + } + iVar2 = bt_hci_cmd_send_sync(0x200f,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_23050590; + bt_dev.le.wl_size = *(u8_t *)(*(int *)&pnStack36->field_4 + 1); + net_buf_unref(pnStack36); + buf = bt_hci_cmd_create(0x2001,'\b'); + if (buf != (net_buf *)0x0) { + net_buf_simple_add((net_buf_simple *)&buf->field_4,8); + initial_count = 0x202; + if ((bt_dev.le.features[0] & 0x40) == 0) { + initial_count = 3; + } + dst = (u8_t *)(initial_count | 0x2c); + if ((bt_dev.le.features[0] & 2) == 0) { + dst = (u8_t *)(initial_count | 0xc); + } + if ((bt_dev.le.features[0] & 1) != 0) { + dst = (u8_t *)((uint)dst | 0x10); + } + if ((bt_dev.supported_commands[34] & 6) == 6) { + dst = (u8_t *)((uint)dst | 0x180); + } + sys_put_le64(dst); + iVar2 = bt_hci_cmd_send_sync(0x2001,buf,(net_buf **)0x0); + if (iVar2 == 0) { + if (((bt_dev.features[0][4] & 0x20) == 0) && (bt_dev.le.mtu == 0)) { + iVar2 = bt_hci_cmd_send_sync(0x1005,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_23050590; + if (bt_dev.le.mtu == 0) { + bt_dev.le.mtu = *(u16_t *)(*(int *)&pnStack36->field_4 + 1); + initial_count = (uint)*(ushort *)(*(int *)&pnStack36->field_4 + 4); + k_sem_init(&bt_dev.le.pkts,initial_count,initial_count); + } + net_buf_unref(pnStack36); + } + buf = bt_hci_cmd_create(0xc01,'\b'); + iVar2 = -0x37; + if (buf != (net_buf *)0x0) { + net_buf_simple_add((net_buf_simple *)&buf->field_4,8); + if ((bt_dev.le.features[0] & 1) == 0) { + dst = (u8_t *)0x2008810; + } + else { + dst = (u8_t *)0x2008890; + } + sys_put_le64(dst); + iVar2 = bt_hci_cmd_send_sync(0xc01,buf,(net_buf **)0x0); + if (iVar2 == 0) { + if ((bt_dev.id_count == '\0') && (iVar2 = bt_setup_id_addr(), iVar2 != 0)) { + printf("Unable to set identity address\r\n"); + } + else { + iVar2 = bt_conn_init(); + if (iVar2 == 0) { + bt_finalize_init(); + } + } + } + } + } + goto LAB_23050590; + } + } + iVar2 = -0x37; +LAB_23050590: + if (ready_cb != (bt_ready_cb_t *)0x0) { + (*ready_cb)(iVar2); + } + return; +} + + + +_Bool bt_addr_le_is_bonded(u8_t id,bt_addr_le_t *addr) + +{ + bool bVar1; + bt_keys *pbVar2; + + pbVar2 = bt_keys_find_addr(id,addr); + if (pbVar2 == (bt_keys *)0x0) { + bVar1 = false; + } + else { + bVar1 = pbVar2->keys != 0; + } + return (_Bool)bVar1; +} + + + +int bt_le_adv_start_internal + (byte *param_1,bt_data *param_2,size_t param_3,bt_data *param_4,size_t param_5, + bt_addr_le_t *param_6) + +{ + byte bVar1; + int iVar2; + net_buf *buf; + uint uVar3; + undefined4 uStack72; + undefined2 uStack68; + undefined uStack66; + undefined2 uStack64; + undefined2 uStack62; + byte bStack60; + byte bStack59; + bt_addr_le_t bStack58; + u8_t uStack51; + undefined uStack50; + + iVar2 = atomic_test_bit(bt_dev.flags,1); + if (iVar2 == 0) { + return 0xfffffff5; + } + if ((uint)*param_1 < (uint)bt_dev.id_count) { + uStack72 = 0; + uStack68 = 0; + uStack66 = 0; + iVar2 = memcmp(bt_dev.id_addr + (uint)*param_1,&uStack72,7); + if (((iVar2 != 0) && + (((bVar1 = param_1[1], (bVar1 & 1) != 0 || (8 < bt_dev.hci_version)) || + (0x9f < *(ushort *)(param_1 + 2))))) && + ((bt_dev.le.wl_entries != '\0' || (((bVar1 & 0x40) == 0 && (-1 < (char)bVar1)))))) { + if (((bVar1 & 0x10) != 0) || (param_6 == (bt_addr_le_t *)0x0)) { + if (*(ushort *)(param_1 + 4) < *(ushort *)(param_1 + 2)) { + return 0xffffffea; + } + if (*(ushort *)(param_1 + 2) < 0x20) { + return 0xffffffea; + } + if (0x4000 < *(ushort *)(param_1 + 4)) { + return 0xffffffea; + } + } + iVar2 = atomic_test_bit(bt_dev.flags,6); + if (iVar2 != 0) { + return 0xffffffbb; + } + memset(&uStack64,0,0xf); + uStack64 = *(undefined2 *)(param_1 + 2); + uStack62 = *(undefined2 *)(param_1 + 4); + uStack51 = adv_ch_map; + if (bt_dev.adv_id != *param_1) { + atomic_and(bt_dev.flags,-0x10001); + } + bVar1 = param_1[1]; + if ((bVar1 & 0x40) == 0) { + uStack50 = 2; + if (-1 < (char)bVar1) { + uStack50 = 0; + } + } + else { + uStack50 = 3; + if (-1 < (char)bVar1) { + uStack50 = 1; + } + } + bt_dev.adv_id = *param_1; + uVar3 = (uint)bt_dev.adv_id; + bVar1 = param_1[1]; + bStack60 = bVar1 & 1; + if ((bVar1 & 1) == 0) { + if ((bVar1 & 4) != 0) { + if (bt_dev.id_addr[uVar3].type == '\x01') { + iVar2 = set_random_address(&bt_dev.id_addr[uVar3].a); + } + bStack59 = bt_dev.id_addr[uVar3].type; + if (iVar2 != 0) { + return iVar2; + } + } + bStack60 = 2; + if (param_4 == (bt_data *)0x0) { + bStack60 = 3; + } + } + else { + if ((bt_dev.id_addr[uVar3].type == '\x01') && + (iVar2 = set_random_address(&bt_dev.id_addr[uVar3].a), iVar2 != 0)) { + return iVar2; + } + bStack59 = bt_dev.id_addr[uVar3].type; + if (param_6 == (bt_addr_le_t *)0x0) { + bStack60 = 0; + } + else { + if ((param_1[1] & 0x10) != 0) { + bStack60 = 4; + } + bt_addr_le_copy(&bStack58,param_6); + if (((bt_dev.le.features[0] & 0x40) != 0) && ((param_1[1] & 0x20) != 0)) { + bStack59 = bStack59 | 2; + } + } + } + buf = bt_hci_cmd_create(0x2006,'\x0f'); + if (buf == (net_buf *)0x0) { + return 0xffffffc9; + } + net_buf_simple_add_mem((net_buf_simple *)&buf->field_4,&uStack64,0xf); + iVar2 = bt_hci_cmd_send_sync(0x2006,buf,(net_buf **)0x0); + if (iVar2 == 0) { + if ((param_6 == (bt_addr_le_t *)0x0) && + (iVar2 = le_adv_update(param_2,param_3,param_4,param_5,(_Bool)(param_1[1] & 1), + (_Bool)(param_1[1] >> 3 & 1)), iVar2 != 0)) { + return iVar2; + } + iVar2 = set_advertise_enable(true); + if (iVar2 == 0) { + atomic_set_bit_to(bt_dev.flags,9,(_Bool)((param_1[1] >> 1 ^ 1) & 1)); + atomic_set_bit_to(bt_dev.flags,7,(_Bool)(param_1[1] >> 3 & 1)); + atomic_set_bit_to(bt_dev.flags,8,(_Bool)(param_1[1] & 1)); + return 0; + } + return iVar2; + } + return iVar2; + } + } + return 0xffffffea; +} + + + +int set_adv_channel_map(u8_t channel) + +{ + if ((byte)(channel - 1) < 7) { + adv_ch_map = channel; + return 0; + } + return -1; +} + + + +int bt_get_local_public_address(bt_addr_le_t *adv_addr) + +{ + bt_addr_le_copy(adv_addr,(bt_addr_le_t *)&bt_dev); + return 0; +} + + + +int bt_get_local_ramdon_address(bt_addr_le_t *adv_addr) + +{ + bt_addr_le_copy(adv_addr,&bt_dev.random_addr); + return 0; +} + + + +int bt_le_adv_start(bt_le_adv_param *param,bt_data *ad,size_t ad_len,bt_data *sd,size_t sd_len) + +{ + int iVar1; + + if ((param->options & 0x10) == 0) { + iVar1 = bt_le_adv_start_internal(); + return iVar1; + } + return -0x16; +} + + + +int bt_le_adv_stop(void) + +{ + int iVar1; + + atomic_and(bt_dev.flags,-0x201); + iVar1 = atomic_test_bit(bt_dev.flags,6); + if (iVar1 != 0) { + iVar1 = set_advertise_enable(false); + if (iVar1 != 0) { + return iVar1; + } + iVar1 = atomic_test_bit(bt_dev.flags,10); + if ((iVar1 != 0) && (iVar1 = atomic_test_bit(bt_dev.flags,0xc), iVar1 != 0)) { + le_set_private_addr(); + return 0; + } + } + return 0; +} + + + +int bt_le_scan_start(byte *param_1,bt_le_scan_cb_t_conflict1 *param_2) + +{ + int iVar1; + int iVar2; + uint uVar3; + + iVar2 = atomic_test_bit(bt_dev.flags,1); + iVar1 = -0xb; + if ((((iVar2 != 0) && (iVar1 = -0x16, *param_1 < 2)) && ((param_1[1] & 0xfc) == 0)) && + ((bt_dev.le.wl_entries != '\0' || ((param_1[1] & 2) == 0)))) { + iVar1 = -0x16; + if (((ushort)(*(ushort *)(param_1 + 2) - 4) < 0x3ffd) && + (((ushort)(*(ushort *)(param_1 + 4) - 4) < 0x3ffd && + (*(ushort *)(param_1 + 4) <= *(ushort *)(param_1 + 2))))) { + uVar3 = atomic_or(bt_dev.flags,0x800); + iVar1 = -0x45; + if ((uVar3 & 0x800) == 0) { + iVar1 = atomic_test_bit(bt_dev.flags,10); + if ((iVar1 == 0) || (iVar1 = set_le_scan_enable('\0'), iVar1 == 0)) { + atomic_set_bit_to(bt_dev.flags,0xd,(_Bool)(param_1[1] & 1)); + atomic_set_bit_to(bt_dev.flags,0xe,(_Bool)(param_1[1] >> 1 & 1)); + iVar1 = start_le_scan(*param_1,*(u16_t *)(param_1 + 2),*(u16_t *)(param_1 + 4)); + if (iVar1 == 0) { + scan_dev_found_cb = param_2; + return 0; + } + } + atomic_and(bt_dev.flags,-0x801); + } + } + } + return iVar1; +} + + + +int bt_le_scan_stop(void) + +{ + atomic_val_t aVar1; + int iVar2; + + aVar1 = atomic_and(bt_dev.flags,-0x801); + if (aVar1 << 0x14 < 0) { + scan_dev_found_cb = (bt_le_scan_cb_t_conflict1 *)0x0; + iVar2 = bt_le_scan_update(false); + return iVar2; + } + return -0x45; +} + + + +int bt_set_tx_pwr(int8_t power) + +{ + net_buf *buf; + int iVar1; + int8_t aiStack20 [4]; + bt_hci_cp_vs_set_tx_pwr set_param; + + if ((byte)power < 0x15) { + memset(aiStack20,0,1); + aiStack20[0] = power; + buf = bt_hci_cmd_create(0xfc61,'\x01'); + iVar1 = -0x37; + if (buf != (net_buf *)0x0) { + net_buf_simple_add_mem((net_buf_simple *)&buf->field_4,aiStack20,1); + iVar1 = bt_hci_cmd_send_sync(0xfc61,buf,(net_buf **)0x0); + } + return iVar1; + } + return 0x12; +} + + + +int bt_buf_get_rx_avail_cnt(void) + +{ + int iVar1; + + iVar1 = k_queue_get_cnt((k_queue *)&hci_rx_pool); + return iVar1 + (uint)hci_rx_pool.uninit_count; +} + + + +net_buf * bt_buf_get_rx(bt_buf_type type,s32_t timeout) + +{ + net_buf *pnVar1; + + pnVar1 = net_buf_alloc_fixed(&hci_rx_pool,timeout); + if (pnVar1 != (net_buf *)0x0) { + net_buf_simple_reserve((net_buf_simple *)&pnVar1->field_4,1); + pnVar1->user_data[0] = type; + } + return pnVar1; +} + + + +net_buf * bt_buf_get_cmd_complete(s32_t timeout) + +{ + net_buf *pnVar1; + + irq_lock(); + pnVar1 = bt_dev.sent_cmd; + bt_dev.sent_cmd = (net_buf *)0x0; + irq_unlock(); + if (pnVar1 == (net_buf *)0x0) { + pnVar1 = bt_buf_get_rx(BT_BUF_EVT,timeout); + return pnVar1; + } + pnVar1->user_data[0] = '\x01'; + *(undefined2 *)((int)&pnVar1->field_4 + 4) = 0; + net_buf_simple_reserve((net_buf_simple *)&pnVar1->field_4,1); + return pnVar1; +} + + + +int bt_pub_key_gen(bt_pub_key_cb *new_cb) + +{ + bt_pub_key_cb *pbVar1; + uint uVar2; + bt_pub_key_cb *pbVar3; + int iVar4; + + if ((bt_dev.supported_commands[34] & 6) == 6) { + pbVar1 = new_cb; + if (pub_key_cb != (bt_pub_key_cb *)0x0) { + pbVar1 = pub_key_cb; + do { + pbVar3 = pbVar1; + pbVar1 = pub_key_cb; + if (new_cb->func == pbVar3->func) goto LAB_23050e74; + pbVar1 = pbVar3->_next; + } while (pbVar3->_next != (bt_pub_key_cb *)0x0); + pbVar3->_next = new_cb; + pbVar1 = pub_key_cb; + } +LAB_23050e74: + pub_key_cb = pbVar1; + uVar2 = atomic_or(bt_dev.flags,0x20); + iVar4 = 0; + if ((uVar2 & 0x20) == 0) { + atomic_and(bt_dev.flags,-0x11); + iVar4 = bt_hci_cmd_send_sync(0x2025,(net_buf *)0x0,(net_buf **)0x0); + if (iVar4 != 0) { + printf("Sending LE P256 Public Key command failed\r\n"); + atomic_and(bt_dev.flags,-0x21); + pub_key_cb = (bt_pub_key_cb *)0x0; + } + } + } + else { + printf("ECC HCI commands not available\r\n"); + iVar4 = -0x23; + } + return iVar4; +} + + + +u8_t * bt_pub_key_get(void) + +{ + int iVar1; + u8_t *puVar2; + + iVar1 = atomic_test_bit(bt_dev.flags,4); + puVar2 = (u8_t *)0x0; + if (iVar1 != 0) { + puVar2 = pub_key; + } + return puVar2; +} + + + +int bt_dh_key_gen(u8_t *remote_pk,bt_dh_key_cb_t *cb) + +{ + int iVar1; + net_buf *buf; + void *__dest; + int iVar2; + + if ((dh_key_cb == (bt_dh_key_cb_t *)0x0) && (iVar2 = atomic_test_bit(bt_dev.flags,5), iVar2 == 0)) + { + iVar1 = atomic_test_bit(bt_dev.flags,4); + iVar2 = -0x31; + if (iVar1 != 0) { + dh_key_cb = cb; + buf = bt_hci_cmd_create(0x2026,'@'); + if (buf == (net_buf *)0x0) { + dh_key_cb = (bt_dh_key_cb_t *)0x0; + iVar2 = -0x37; + } + else { + __dest = net_buf_simple_add((net_buf_simple *)&buf->field_4,0x40); + memcpy(__dest,remote_pk,0x40); + iVar2 = bt_hci_cmd_send_sync(0x2026,buf,(net_buf **)0x0); + if (iVar2 != 0) { + dh_key_cb = (bt_dh_key_cb_t *)0x0; + } + } + } + } + else { + iVar2 = -0x10; + } + return iVar2; +} + + + +void sys_slist_remove(sys_slist_t *list,sys_snode_t *prev_node,sys_snode_t *node) + +{ + sys_snode_t *psVar1; + + psVar1 = (sys_snode_t *)node->next; + if (prev_node == (sys_snode_t *)0x0) { + list->head = psVar1; + if (list->tail == node) { + list->tail = psVar1; + } + } + else { + *(sys_snode_t **)&prev_node->next = psVar1; + if (list->tail == node) { + list->tail = prev_node; + } + } + node->next = (_snode *)0x0; + return; +} + + + +size_t net_buf_frags_len(net_buf *buf) + +{ + anon_union_for_field_4 *paVar1; + size_t sVar2; + + sVar2 = 0; + while (buf != (net_buf *)0x0) { + paVar1 = &buf->field_4; + buf = (net_buf *)buf->field_0; + sVar2 = sVar2 + *(ushort *)((int)paVar1 + 4); + } + return sVar2; +} + + + +u8_t get_ident(void) + +{ + u8_t ident; + u8_t uVar1; + + uVar1 = ident + '\x01'; + if (uVar1 == '\0') { + uVar1 = '\x01'; + } + return uVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +bt_l2cap_le_chan * __l2cap_lookup_ident(bt_conn *conn,u16_t ident,_Bool remove) + +{ + sys_snode_t node; + undefined2 in_register_0000202e; + undefined3 in_register_00002031; + sys_snode_t sVar1; + sys_snode_t prev_node; + + node = (sys_snode_t)(conn->channels).head; + if (node != (sys_snode_t)0x0) { + prev_node = (sys_snode_t)0x0; + do { + sVar1 = (sys_snode_t)((int)node + -8); + if (sVar1 == (sys_snode_t)0x0) { + return (bt_l2cap_le_chan *)0; + } + if ((uint)*(byte *)&((sys_snode_t *)((int)node + 0x34))->next == + CONCAT22(in_register_0000202e,ident)) { + if (CONCAT31(in_register_00002031,remove) == 0) { + return (bt_l2cap_le_chan *)sVar1; + } + sys_slist_remove(&conn->channels,(sys_snode_t *)prev_node,(sys_snode_t *)node); + return (bt_l2cap_le_chan *)sVar1; + } + sVar1 = *(sys_snode_t *)node; + prev_node = node; + node = sVar1; + } while (sVar1 != (sys_snode_t)0x0); + node = (sys_snode_t)0x0; + } + return (bt_l2cap_le_chan *)node; +} + + + +bt_l2cap_server * l2cap_server_lookup_psm(u16_t psm) + +{ + undefined2 in_register_0000202a; + sys_snode_t sVar1; + sys_snode_t sVar2; + + sVar2 = (sys_snode_t)servers.head; + while (((sVar1 = sVar2, sVar2 != (sys_snode_t)0x0 && + (sVar1 = (sys_snode_t)((int)sVar2 + -8), sVar1 != (sys_snode_t)0x0)) && + ((uint)*(ushort *)sVar1 != CONCAT22(in_register_0000202a,psm)))) { + sVar2 = *(sys_snode_t *)sVar2; + } + return (bt_l2cap_server *)sVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +bt_l2cap_le_chan * l2cap_remove_rx_cid(bt_conn *conn,u16_t cid) + +{ + sys_snode_t sVar1; + sys_snode_t node; + undefined2 in_register_0000202e; + sys_snode_t prev_node; + + sVar1 = (sys_snode_t)0x0; + if (((CONCAT22(in_register_0000202e,cid) - 0x40 & 0xffff) < 0x40) && + (sVar1 = (sys_snode_t)(conn->channels).head, sVar1 != (sys_snode_t)0x0)) { + prev_node = (sys_snode_t)0x0; + node = sVar1; + do { + if ((sys_snode_t)((int)node + -8) == (sys_snode_t)0x0) { + return (bt_l2cap_le_chan *)0; + } + if ((uint)*(ushort *)&((sys_snode_t *)((int)node + 0x38))->next == + CONCAT22(in_register_0000202e,cid)) { + sys_slist_remove(&conn->channels,(sys_snode_t *)prev_node,(sys_snode_t *)node); + return (bt_l2cap_le_chan *)((int)node + -8); + } + sVar1 = *(sys_snode_t *)node; + prev_node = node; + node = sVar1; + } while (sVar1 != (sys_snode_t)0x0); + } + return (bt_l2cap_le_chan *)sVar1; +} + + + +void l2cap_chan_sdu_sent(bt_conn *conn,void *user_data) + +{ + code *UNRECOVERED_JUMPTABLE; + + UNRECOVERED_JUMPTABLE = *(code **)(*(int *)((int)user_data + 4) + 0x14); + if (UNRECOVERED_JUMPTABLE != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x2305108c. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(user_data); + return; + } + return; +} + + + +net_buf * l2cap_alloc_frag(s32_t timeout,void *user_data) + +{ + net_buf *pnVar1; + + // WARNING: Could not recover jumptable at 0x23051098. Too many branches + // WARNING: Treating indirect jump as call + pnVar1 = (net_buf *)(**(code **)(*(int *)((int)user_data + 4) + 0xc))(user_data); + return pnVar1; +} + + + +void l2cap_connected(bt_l2cap_chan *chan) + +{ + return; +} + + + +void l2cap_chan_destroy(bt_l2cap_chan *chan) + +{ + net_buf *buf; + + k_delayed_work_cancel(&chan->rtx_work); + if ((net_buf *)chan[1].status[0] != (net_buf *)0x0) { + net_buf_unref((net_buf *)chan[1].status[0]); + chan[1].status[0] = 0; + } + while (buf = net_buf_get((k_fifo *)&chan[1].rtx_work.timer.args,0), buf != (net_buf *)0x0) { + net_buf_unref(buf); + } + while (buf = net_buf_get((k_fifo *)&chan[2].destroy,0), buf != (net_buf *)0x0) { + net_buf_unref(buf); + } + if (*(net_buf **)&chan[1].state != (net_buf *)0x0) { + net_buf_unref(*(net_buf **)&chan[1].state); + *(undefined4 *)&chan[1].state = 0; + *(undefined2 *)&chan[1].ident = 0; + } + return; +} + + + +void l2cap_chan_tx_init(bt_l2cap_le_chan *chan) + +{ + memset(&chan->tx,0,0x14); + k_sem_init(&(chan->tx).credits,0,0xffffffff); + k_queue_init((k_queue *)&chan->tx_queue,0x14); + return; +} + + + +void l2cap_chan_rx_init(bt_l2cap_le_chan *chan) + +{ + u16_t uVar1; + ushort uVar2; + + if ((chan->rx).mtu == 0) { + (chan->rx).mtu = 0xf5; + } + uVar2 = (chan->rx).mtu; + if ((chan->rx).init_credits == 0) { + if (((chan->chan).ops)->alloc_buf == + (anon_subr_net_buf_ptr_bt_l2cap_chan_ptr_for_alloc_buf *)0x0) { + uVar1 = 9; + } + else { + uVar1 = (u16_t)((int)((uint)uVar2 + 0xf6) / 0xf7); + } + (chan->rx).init_credits = uVar1; + } + if (0xf5 < uVar2) { + uVar2 = 0xf5; + } + (chan->rx).mps = uVar2 + 2; + k_sem_init(&(chan->rx).credits,0,0xffffffff); + return; +} + + + +int l2cap_accept(bt_conn *conn,bt_l2cap_chan **chan) + +{ + int iVar1; + + if (bt_l2cap_pool[0].chan.chan.conn == (bt_conn *)0x0) { + iVar1 = 0; + } + else { + if (bt_l2cap_pool[1].chan.chan.conn != (bt_conn *)0x0) { + printf("No available L2CAP context for conn %p\r\n",conn); + return -0xc; + } + iVar1 = 1; + } + bt_l2cap_pool[iVar1].chan.chan.ops = (bt_l2cap_chan_ops *)0x4200de88; + *(bt_l2cap **)chan = bt_l2cap_pool + iVar1; + return 0; +} + + + +net_buf * l2cap_create_le_sig_pdu(u8_t code,u8_t ident,u16_t len) + +{ + undefined3 in_register_00002029; + net_buf *pnVar1; + u8_t *puVar2; + + pnVar1 = bt_conn_create_pdu_timeout((net_buf_pool *)0x0,4,2000); + if (pnVar1 == (net_buf *)0x0) { + printf("Unable to allocate buffer for op 0x%02x\r\n",CONCAT31(in_register_00002029,code)); + } + else { + puVar2 = (u8_t *)net_buf_simple_add((net_buf_simple *)&pnVar1->field_4,4); + puVar2[2] = (u8_t)len; + *puVar2 = code; + puVar2[1] = ident; + puVar2[3] = (u8_t)(len >> 8); + } + return pnVar1; +} + + + +void l2cap_chan_tx_give_credits(bt_l2cap_le_chan *chan,u16_t credits) + +{ + anon_subr_void_bt_l2cap_chan_ptr_atomic_t_ptr_for_status *UNRECOVERED_JUMPTABLE; + atomic_t *target; + uint uVar1; + + while (credits = credits - 1, credits != 0xffff) { + k_sem_give(&(chan->tx).credits); + } + target = (chan->chan).status; + uVar1 = atomic_or(target,1); + if ((uVar1 & 1) != 0) { + UNRECOVERED_JUMPTABLE = ((chan->chan).ops)->status; + if (UNRECOVERED_JUMPTABLE != (anon_subr_void_bt_l2cap_chan_ptr_atomic_t_ptr_for_status *)0x0) { + // WARNING: Could not recover jumptable at 0x2305126e. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)((bt_l2cap_chan *)chan,target); + return; + } + } + return; +} + + + +void l2cap_disconnected(void) + +{ + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void bt_l2cap_chan_remove(bt_conn *conn,bt_l2cap_chan *ch) + +{ + sys_snode_t prev_node; + sys_snode_t node; + sys_snode_t sVar1; + + node = (sys_snode_t)(conn->channels).head; + if (node != (sys_snode_t)0x0) { + prev_node = (sys_snode_t)0x0; + do { + if (node == (sys_snode_t)&DAT_00000008) { + return; + } + if ((bt_l2cap_chan *)((int)node + -8) == ch) { + sys_slist_remove(&conn->channels,(sys_snode_t *)prev_node,(sys_snode_t *)node); + return; + } + sVar1 = *(sys_snode_t *)node; + prev_node = node; + node = sVar1; + } while (sVar1 != (sys_snode_t)0x0); + } + return; +} + + + +void bt_l2cap_chan_del(bt_l2cap_chan *chan) + +{ + anon_subr_void_bt_l2cap_chan_ptr_for_disconnected *paVar1; + + if (chan->conn != (bt_conn *)0x0) { + paVar1 = chan->ops->disconnected; + if (paVar1 != (anon_subr_void_bt_l2cap_chan_ptr_for_disconnected *)0x0) { + (*paVar1)(chan); + } + chan->conn = (bt_conn *)0x0; + } + chan->state = BT_L2CAP_DISCONNECTED; + chan->psm = 0; + if (chan->destroy != (bt_l2cap_chan_destroy_t *)0x0) { + (*chan->destroy)(chan); + } + if ((chan->rtx_work).timer.timer.hdl != (void *)0x0) { + k_delayed_work_del_timer(&chan->rtx_work); + return; + } + return; +} + + + +void l2cap_rtx_timeout(k_work *work) + +{ + bt_l2cap_chan *ch; + + ch = (bt_l2cap_chan *)work[-2].flags; + printf("chan %p timeout\r\n",ch); + bt_l2cap_chan_remove((bt_conn *)work[-2].flags[0],ch); + bt_l2cap_chan_del(ch); + return; +} + + + +void bt_l2cap_disconnected(bt_conn *conn) + +{ + bt_l2cap_chan *pbVar1; + bt_l2cap_chan *pbVar2; + bt_l2cap_chan *chan; + sys_snode_t *psVar3; + + psVar3 = (conn->channels).head; + if ((psVar3 != (sys_snode_t *)0x0) && + (chan = (bt_l2cap_chan *)(psVar3 + -2), chan != (bt_l2cap_chan *)0x0)) { + pbVar1 = (bt_l2cap_chan *)psVar3->next; + if (pbVar1 != (bt_l2cap_chan *)0x0) { + pbVar1 = (bt_l2cap_chan *)&pbVar1[-1].state; + } + while (pbVar2 = pbVar1, bt_l2cap_chan_del(chan), pbVar2 != (bt_l2cap_chan *)0x0) { + pbVar1 = (bt_l2cap_chan *)(pbVar2->node).next; + chan = pbVar2; + if (pbVar1 != (bt_l2cap_chan *)0x0) { + pbVar1 = (bt_l2cap_chan *)&pbVar1[-1].state; + } + } + return; + } + return; +} + + + +net_buf * bt_l2cap_create_pdu_timeout(net_buf_pool *pool,size_t reserve,s32_t timeout) + +{ + net_buf *pnVar1; + + pnVar1 = bt_conn_create_pdu_timeout(pool,reserve + 4,timeout); + return pnVar1; +} + + + +int bt_l2cap_send_cb(bt_conn *conn,u16_t cid,net_buf *buf,bt_conn_tx_cb_t *cb,void *user_data) + +{ + ushort uVar1; + undefined *puVar2; + int iVar3; + + puVar2 = (undefined *)net_buf_simple_push((net_buf_simple *)&buf->field_4,4); + uVar1 = *(ushort *)((int)&buf->field_4 + 4); + puVar2[2] = (char)cid; + iVar3 = (uint)uVar1 - 4; + *puVar2 = (char)((uint)(iVar3 * 0x10000) >> 0x10); + puVar2[1] = (char)((uint)iVar3 >> 8); + puVar2[3] = (char)(cid >> 8); + iVar3 = bt_conn_send_cb(conn,buf,cb,user_data); + return iVar3; +} + + + +void bt_l2cap_send(bt_conn *conn,u16_t cid,net_buf *buf) + +{ + bt_l2cap_send_cb(conn,cid,buf,(bt_conn_tx_cb_t *)0x0,(void *)0x0); + return; +} + + + +void l2cap_chan_send_credits(bt_l2cap_le_chan *chan,u16_t credits) + +{ + u16_t uVar1; + uint uVar2; + uint uVar3; + u8_t ident; + net_buf *buf; + undefined *puVar4; + undefined2 in_register_0000202e; + + uVar2 = (uint)(chan->rx).init_credits; + if (CONCAT22(in_register_0000202e,credits) < uVar2) { + uVar2 = CONCAT22(in_register_0000202e,credits); + } + uVar3 = uVar2 & 0xffff; + while (uVar3 = uVar3 - 1 & 0xffff, uVar3 != 0xffff) { + k_sem_give(&(chan->rx).credits); + } + ident = get_ident(); + buf = l2cap_create_le_sig_pdu('\x16',ident,4); + if (buf != (net_buf *)0x0) { + puVar4 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,4); + uVar1 = (chan->rx).cid; + puVar4[2] = (char)uVar2; + *puVar4 = (char)uVar1; + puVar4[1] = (char)(uVar1 >> 8); + puVar4[3] = (char)((uVar2 & 0xffff) >> 8); + bt_l2cap_send((chan->chan).conn,5,buf); + return; + } + return; +} + + + +int l2cap_le_conn_req(bt_l2cap_le_chan *ch) + +{ + u16_t uVar1; + u8_t ident; + net_buf *buf; + undefined *puVar2; + int iVar3; + + ident = get_ident(); + (ch->chan).ident = ident; + buf = l2cap_create_le_sig_pdu('\x14',ident,10); + if (buf == (net_buf *)0x0) { + iVar3 = -0xc; + } + else { + puVar2 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,10); + uVar1 = (ch->chan).psm; + *puVar2 = (char)uVar1; + puVar2[1] = (char)(uVar1 >> 8); + uVar1 = (ch->rx).cid; + puVar2[2] = (char)uVar1; + puVar2[3] = (char)(uVar1 >> 8); + uVar1 = (ch->rx).mtu; + puVar2[4] = (char)uVar1; + puVar2[5] = (char)(uVar1 >> 8); + uVar1 = (ch->rx).mps; + puVar2[6] = (char)uVar1; + puVar2[7] = (char)(uVar1 >> 8); + uVar1 = (ch->rx).init_credits; + puVar2[8] = (char)uVar1; + puVar2[9] = (char)(uVar1 >> 8); + k_delayed_work_submit(&(ch->chan).rtx_work,40000); + bt_l2cap_send((ch->chan).conn,5,buf); + iVar3 = 0; + } + return iVar3; +} + + + +// WARNING: Type propagation algorithm not settling + +void bt_l2cap_encrypt_change(bt_conn *conn,u8_t hci_status) + +{ + bt_l2cap_le_chan *ch; + undefined3 in_register_0000202d; + int *piVar1; + + piVar1 = (int *)(conn->channels).head; + if (piVar1 == (int *)0x0) { + return; + } + do { + ch = (bt_l2cap_le_chan *)(piVar1 + 0xfffffffe); + if (ch == (bt_l2cap_le_chan *)0x0) { + return; + } + if ((*(char *)(piVar1 + 0xc) == '\x01') && (*(char *)(piVar1 + 0xd) == '\0')) { + if (CONCAT31(in_register_0000202d,hci_status) == 0) { + l2cap_le_conn_req(ch); + } + else { + bt_l2cap_chan_remove((ch->chan).conn,(bt_l2cap_chan *)ch); + bt_l2cap_chan_del((bt_l2cap_chan *)ch); + } + } + if (*(code **)(piVar1[0xffffffff] + 8) != (code *)0x0) { + (**(code **)(piVar1[0xffffffff] + 8))(ch,CONCAT31(in_register_0000202d,hci_status)); + } + piVar1 = (int *)*piVar1; + } while (piVar1 != (int *)0x0); + return; +} + + + +void l2cap_send_reject(bt_conn *conn,u8_t ident,u16_t reason,void *data,u8_t data_len) + +{ + net_buf *buf; + undefined *puVar1; + undefined3 in_register_00002039; + + buf = l2cap_create_le_sig_pdu('\x01',ident,(short)CONCAT31(in_register_00002039,data_len) + 2); + if (buf != (net_buf *)0x0) { + puVar1 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + *puVar1 = (char)reason; + puVar1[1] = (char)(reason >> 8); + if (data != (void *)0x0) { + net_buf_simple_add_mem + ((net_buf_simple *)&buf->field_4,data,CONCAT31(in_register_00002039,data_len)); + } + bt_l2cap_send(conn,5,buf); + return; + } + return; +} + + + +int l2cap_chan_le_send(bt_l2cap_le_chan *ch,net_buf *buf,u16_t sdu_hdr_len) + +{ + u16_t cid; + atomic_t *target; + int iVar1; + size_t sVar2; + net_buf *buf_00; + net_buf_pool *pool; + bt_conn *conn; + uint uVar3; + uint len; + undefined2 in_register_00002032; + anon_subr_void_bt_l2cap_chan_ptr_atomic_t_ptr_for_status *paVar4; + int iVar5; + net_buf_simple *buf_01; + k_sem *sem; + + iVar5 = CONCAT22(in_register_00002032,sdu_hdr_len); + sem = &(ch->tx).credits; + iVar1 = k_sem_take(sem,0); + if (iVar1 != 0) { + return -0xb; + } + if ((uint)*(ushort *)((int)&buf->field_4 + 4) + iVar5 <= (uint)(ch->tx).mps) { + sVar2 = net_buf_simple_headroom((net_buf_simple *)&buf->field_4); + if (((iVar5 + 9U & 0xffff) <= sVar2) && (buf->field_0 == 0)) { + if (iVar5 != 0) { + sVar2 = net_buf_frags_len(buf); + net_buf_simple_push_le16((net_buf_simple *)&buf->field_4,(u16_t)sVar2); + } + buf_00 = net_buf_ref(buf); + if (buf_00 == (net_buf *)0x0) { + return -0xc; + } + goto LAB_230516bc; + } + } + pool = net_buf_pool_get((uint)buf->pool_id); + buf_00 = net_buf_alloc_fixed(pool,0); + if (buf_00 == (net_buf *)0x0) { + buf_00 = bt_conn_create_pdu_timeout((net_buf_pool *)0x0,4,-1); + if (buf_00 == (net_buf *)0x0) { + return -0xc; + } + } + else { + net_buf_simple_reserve((net_buf_simple *)&buf_00->field_4,9); + } + buf_01 = (net_buf_simple *)&buf_00->field_4; + if (iVar5 != 0) { + sVar2 = net_buf_frags_len(buf); + net_buf_simple_add_le16(buf_01,(u16_t)sVar2); + } + sVar2 = net_buf_simple_tailroom(buf_01); + uVar3 = (uint)(ch->tx).mps - iVar5; + if (sVar2 < uVar3) { + uVar3 = net_buf_simple_tailroom(buf_01); + } + len = (uint)*(ushort *)((int)&buf->field_4 + 4); + if ((uVar3 & 0xffff) < len) { + len = uVar3 & 0xffff; + } + net_buf_simple_add_mem(buf_01,*(void **)&buf->field_4,len); + net_buf_simple_pull((net_buf_simple *)&buf->field_4,len); +LAB_230516bc: + conn = (ch->chan).conn; + if (conn == (bt_conn *)0x0) { + net_buf_unref(buf); + iVar5 = -0x36; + } + else { + cid = (ch->tx).cid; + iVar5 = (uint)*(ushort *)((int)&buf_00->field_4 + 4) - iVar5; + if (((buf == buf_00) || (*(short *)((int)&buf->field_4 + 4) == 0)) && + (((ch->chan).ops)->sent != (anon_subr_void_bt_l2cap_chan_ptr_for_sent *)0x0)) { + bt_l2cap_send_cb(conn,cid,buf_00,l2cap_chan_sdu_sent,ch); + } + else { + bt_l2cap_send(conn,cid,buf_00); + } + uVar3 = k_sem_count_get(sem); + if (uVar3 == 0) { + target = (ch->chan).status; + atomic_and(target,-2); + paVar4 = ((ch->chan).ops)->status; + if (paVar4 != (anon_subr_void_bt_l2cap_chan_ptr_atomic_t_ptr_for_status *)0x0) { + (*paVar4)((bt_l2cap_chan *)ch,target); + } + } + } + return iVar5; +} + + + +int l2cap_chan_le_send_sdu(bt_l2cap_le_chan *param_1,net_buf **param_2,ushort param_3) + +{ + net_buf *buf; + int iVar1; + size_t sVar2; + uint uVar3; + ushort auStack34 [5]; + + buf = *param_2; + auStack34[0] = param_3; + sVar2 = net_buf_frags_len(buf); + uVar3 = (uint)auStack34[0]; + iVar1 = -0x24; + if ((int)(uVar3 + sVar2) <= (int)(uint)(param_1->tx).mtu) { + if ((*(short *)((int)&buf->field_4 + 4) == 0) && ((net_buf *)buf->field_0 != (net_buf *)0x0)) { + buf = (net_buf *)buf->field_0; + } + if (auStack34[0] == 0) { + iVar1 = l2cap_chan_le_send(param_1,buf,2); + if (iVar1 < 0) { +LAB_23051794: + if (iVar1 == -0xb) { + memcpy(buf->user_data,auStack34,2); + } + *param_2 = buf; + return iVar1; + } + auStack34[0] = (ushort)iVar1; + } + iVar1 = 0; + while ((int)(uint)auStack34[0] < (int)(uVar3 + sVar2)) { + if (*(short *)((int)&buf->field_4 + 4) == 0) { + buf = net_buf_frag_del((net_buf *)0x0,buf); + } + iVar1 = l2cap_chan_le_send(param_1,buf,0); + if (iVar1 < 0) goto LAB_23051794; + auStack34[0] = auStack34[0] + (short)iVar1; + } + net_buf_unref(buf); + } + return iVar1; +} + + + +bt_l2cap_chan * bt_l2cap_le_lookup_tx_cid(bt_conn *conn,u16_t cid) + +{ + bt_conn *pbVar1; + bt_conn *pbVar2; + undefined2 in_register_0000202e; + + pbVar2 = (bt_conn *)(conn->channels).head; + while (((pbVar1 = pbVar2, pbVar2 != (bt_conn *)0x0 && + (pbVar1 = (bt_conn *)&(&pbVar2[-1].update_work)[2].work.handler, pbVar1 != (bt_conn *)0x0) + ) && ((uint)*(ushort *)&(&pbVar2->channels)[1].tail != CONCAT22(in_register_0000202e,cid)) + )) { + pbVar2 = *(bt_conn **)&pbVar2->handle; + } + return (bt_l2cap_chan *)pbVar1; +} + + + +bt_l2cap_chan * bt_l2cap_le_lookup_rx_cid(bt_conn *conn,u16_t cid) + +{ + bt_conn *pbVar1; + bt_conn *pbVar2; + undefined2 in_register_0000202e; + + pbVar2 = (bt_conn *)(conn->channels).head; + while (((pbVar1 = pbVar2, pbVar2 != (bt_conn *)0x0 && + (pbVar1 = (bt_conn *)&(&pbVar2[-1].update_work)[2].work.handler, pbVar1 != (bt_conn *)0x0) + ) && ((uint)*(ushort *)&pbVar2->tx_queue != CONCAT22(in_register_0000202e,cid)))) { + pbVar2 = *(bt_conn **)&pbVar2->handle; + } + return (bt_l2cap_chan *)pbVar1; +} + + + +_Bool l2cap_chan_add(bt_conn *conn,bt_l2cap_chan *chan,bt_l2cap_chan_destroy_t *destroy) + +{ + short sVar1; + undefined uVar2; + u16_t cid; + bt_l2cap_chan *pbVar3; + sys_snode_t *psVar4; + _snode *p_Var5; + + if ((chan == (bt_l2cap_chan *)0x0) || (*(short *)&chan[1].conn == 0)) { + cid = 0x40; + do { + if (chan != (bt_l2cap_chan *)0x0) { + pbVar3 = bt_l2cap_le_lookup_rx_cid(conn,cid); + if (pbVar3 == (bt_l2cap_chan *)0x0) { + *(u16_t *)&chan[1].conn = cid; + goto LAB_23051860; + } + } + cid = cid + 1; + } while (cid != 0x80); + printf("Unable to allocate L2CAP CID\r\n"); + uVar2 = 0; + } + else { +LAB_23051860: + k_delayed_work_init(&chan->rtx_work,l2cap_rtx_timeout); + (chan->node).next = (_snode *)0x0; + psVar4 = (conn->channels).tail; + p_Var5 = (_snode *)&chan->node; + if (psVar4 == (sys_snode_t *)0x0) { + *(_snode **)&(conn->channels).tail = p_Var5; + *(_snode **)&(conn->channels).head = p_Var5; + } + else { + psVar4->next = p_Var5; + *(_snode **)&(conn->channels).tail = p_Var5; + } + sVar1 = *(short *)&chan[1].conn; + chan->conn = conn; + *(bt_l2cap_chan_destroy_t **)&chan->destroy = destroy; + uVar2 = 1; + if ((ushort)(sVar1 - 0x40U) < 0x40) { + k_work_init((k_work *)(chan + 2),l2cap_rx_process); + k_queue_init((k_queue *)&chan[2].destroy,0x14); + chan->state = BT_L2CAP_CONNECT; + } + } + return (_Bool)uVar2; +} + + + +// WARNING: Variable defined which should be unmapped: chan + +void bt_l2cap_connected(bt_conn *conn) + +{ + undefined2 uVar1; + bt_l2cap_fixed_chan *pbVar2; + _Bool _Var3; + int iVar4; + undefined3 extraout_var; + code *pcVar5; + anon_subr_void_bt_l2cap_chan_ptr_for_connected *paVar6; + anon_subr_void_bt_l2cap_chan_ptr_atomic_t_ptr_for_status *paVar7; + bt_l2cap_chan *local_14; + bt_l2cap_chan *chan; + + pbVar2 = &att_fixed_chan; + do { + if (&boot2_partition_table <= pbVar2) { + return; + } + pcVar5 = (code *)(((anon_struct_conflict529 *)pbVar2)->table).ptTable.magicCode; + iVar4 = (*pcVar5)(conn,&local_14,pcVar5); + if (-1 < iVar4) { + uVar1 = *(undefined2 *)pbVar2; + *(undefined2 *)&local_14[1].conn = uVar1; + *(undefined2 *)&local_14[1].rtx_work.work.handler = uVar1; + _Var3 = l2cap_chan_add(conn,local_14,(bt_l2cap_chan_destroy_t *)0x0); + if (CONCAT31(extraout_var,_Var3) == 0) { + return; + } + paVar6 = local_14->ops->connected; + if (paVar6 != (anon_subr_void_bt_l2cap_chan_ptr_for_connected *)0x0) { + (*paVar6)(local_14); + } + atomic_or(local_14->status,1); + paVar7 = local_14->ops->status; + if (paVar7 != (anon_subr_void_bt_l2cap_chan_ptr_atomic_t_ptr_for_status *)0x0) { + (*paVar7)(local_14,local_14->status); + } + } + pbVar2 = (bt_l2cap_fixed_chan *)&(((anon_struct_conflict529 *)pbVar2)->table).ptTable.age; + } while( true ); +} + + + +void bt_l2cap_recv(bt_conn *conn,net_buf *buf) + +{ + ushort cid; + void *pvVar1; + bt_l2cap_chan *pbVar2; + net_buf *buf_00; + + if (*(ushort *)((int)&buf->field_4 + 4) < 4) { + printf("Too small L2CAP PDU received\r\n"); + } + else { + pvVar1 = net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,4); + cid = *(ushort *)((int)pvVar1 + 2); + pbVar2 = bt_l2cap_le_lookup_rx_cid(conn,cid); + if (pbVar2 == (bt_l2cap_chan *)0x0) { + printf("Ignoring data for unknown CID 0x%04x\r\n",(uint)cid); + } + else { + if ((ushort)(*(short *)&pbVar2[1].conn - 0x40U) < 0x40) { + buf_00 = net_buf_ref(buf); + net_buf_put((k_fifo *)&pbVar2[2].destroy,buf_00); + k_work_submit((k_work *)(pbVar2 + 2)); + return; + } + (*pbVar2->ops->recv)(pbVar2,buf); + } + } + net_buf_unref(buf); + return; +} + + + +int bt_l2cap_update_conn_param(bt_conn *conn,bt_le_conn_param *param) + +{ + u16_t uVar1; + u8_t ident; + net_buf *buf; + undefined *puVar2; + int iVar3; + + ident = get_ident(); + buf = l2cap_create_le_sig_pdu('\x12',ident,8); + if (buf == (net_buf *)0x0) { + iVar3 = -0xc; + } + else { + puVar2 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,8); + uVar1 = param->interval_min; + *puVar2 = (char)uVar1; + puVar2[1] = (char)(uVar1 >> 8); + uVar1 = param->interval_max; + puVar2[2] = (char)uVar1; + puVar2[3] = (char)(uVar1 >> 8); + uVar1 = param->latency; + puVar2[4] = (char)uVar1; + puVar2[5] = (char)(uVar1 >> 8); + uVar1 = param->timeout; + puVar2[6] = (char)uVar1; + puVar2[7] = (char)(uVar1 >> 8); + bt_l2cap_send(conn,5,buf); + iVar3 = 0; + } + return iVar3; +} + + + +void bt_l2cap_init(void) + +{ + return; +} + + + +int bt_l2cap_chan_disconnect(bt_l2cap_chan *chan) + +{ + undefined2 uVar1; + u8_t ident; + net_buf *buf; + int iVar2; + undefined *puVar3; + + if (chan->conn != (bt_conn *)0x0) { + ident = get_ident(); + chan->ident = ident; + buf = l2cap_create_le_sig_pdu('\x06',ident,4); + iVar2 = -0xc; + if (buf != (net_buf *)0x0) { + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,4); + uVar1 = *(undefined2 *)&chan[1].conn; + *puVar3 = (char)uVar1; + puVar3[1] = (char)((ushort)uVar1 >> 8); + uVar1 = *(undefined2 *)&chan[1].rtx_work.work.handler; + puVar3[2] = (char)uVar1; + puVar3[3] = (char)((ushort)uVar1 >> 8); + k_delayed_work_submit(&chan->rtx_work,2000); + bt_l2cap_send(chan->conn,5,buf); + chan->state = BT_L2CAP_DISCONNECT; + iVar2 = 0; + } + return iVar2; + } + return -0x39; +} + + + +void l2cap_chan_le_recv_seg(bt_l2cap_le_chan *param_1,net_buf *param_2) + +{ + ushort uVar1; + u16_t credits; + size_t sVar2; + char *fmt; + uint uVar3; + int iVar4; + uint uVar5; + bt_l2cap_chan_ops *pbVar6; + net_buf *buf; + k_sem *sem; + u16_t auStack34 [7]; + + buf = param_1->_sdu; + auStack34[0] = 0; + sVar2 = net_buf_frags_len(buf); + if ((sVar2 & 0xffff) != 0) { + memcpy(auStack34,buf->user_data,2); + } + if ((uint)param_1->_sdu_len < (sVar2 & 0xffff) + (uint)*(ushort *)((int)¶m_2->field_4 + 4)) { + fmt = "SDU length mismatch\r\n"; + } + else { + auStack34[0] = auStack34[0] + 1; + memcpy(param_1->_sdu->user_data,auStack34,2); + sVar2 = net_buf_append_bytes + (param_1->_sdu,(uint)*(ushort *)((int)¶m_2->field_4 + 4), + *(void **)¶m_2->field_4,0,l2cap_alloc_frag,param_1); + if ((uint)*(ushort *)((int)¶m_2->field_4 + 4) == (sVar2 & 0xffff)) { + buf = param_1->_sdu; + sVar2 = net_buf_frags_len(buf); + credits = auStack34[0]; + if (param_1->_sdu_len <= sVar2) { + pbVar6 = (param_1->chan).ops; + param_1->_sdu = (net_buf *)0x0; + param_1->_sdu_len = 0; + iVar4 = (*pbVar6->recv)((bt_l2cap_chan *)param_1,buf); + if (iVar4 < 0) { + if (iVar4 == -0x44) { + return; + } + printf("err %d\r\n"); + bt_l2cap_chan_disconnect((bt_l2cap_chan *)param_1); + } + else { + l2cap_chan_send_credits(param_1,credits); + } + net_buf_unref(buf); + return; + } + sem = &(param_1->rx).credits; + uVar3 = k_sem_count_get(sem); + if (uVar3 != 0) { + return; + } + if ((param_1->rx).init_credits != auStack34[0]) { + return; + } + sVar2 = net_buf_frags_len(param_2); + uVar5 = (uint)(param_1->rx).mps; + uVar1 = param_1->_sdu_len; + uVar3 = k_sem_count_get(sem); + iVar4 = ((uVar1 + uVar5 + -1) - sVar2) / uVar5 - uVar3; + if ((short)iVar4 < 1) { + return; + } + l2cap_chan_send_credits(param_1,(u16_t)((uint)(iVar4 * 0x10000) >> 0x10)); + return; + } + fmt = "Unable to store SDU\r\n"; + } + printf(fmt); + bt_l2cap_chan_disconnect((bt_l2cap_chan *)param_1); + return; +} + + + +void l2cap_rx_process(k_work *work) + +{ + bt_l2cap_le_chan *chan; + u16_t uVar1; + net_buf *buf; + int iVar2; + char *fmt; + undefined2 extraout_var; + k_work_handler_t *pkVar3; + code *pcVar4; + + chan = (bt_l2cap_le_chan *)&work[-0xb].handler; + do { + buf = net_buf_get((k_fifo *)(work + 1),0); + if (buf == (net_buf *)0x0) { + return; + } + iVar2 = k_sem_take((k_sem *)&work[-5].handler,0); + if (iVar2 != 0) { + fmt = "No credits to receive packet\r\n"; + goto LAB_23051cd4; + } + if (work[-1].handler != (k_work_handler_t *)0x0) { +LAB_23051cec: + l2cap_chan_le_recv_seg(chan,buf); + goto LAB_23051cde; + } + uVar1 = net_buf_simple_pull_le16((net_buf_simple *)&buf->field_4); + fmt = "Invalid SDU length\r\n"; + if ((uint)*(ushort *)((int)work[-6].flags + 2) < CONCAT22(extraout_var,uVar1)) { +LAB_23051cd4: + printf(fmt); +LAB_23051cd8: + bt_l2cap_chan_disconnect((bt_l2cap_chan *)chan); + } + else { + pcVar4 = *(code **)(work[-0xb].flags[0] + 0xc); + if (pcVar4 != (code *)0x0) { + pkVar3 = (k_work_handler_t *)(*pcVar4)(chan); + work[-1].handler = pkVar3; + if (pkVar3 != (k_work_handler_t *)0x0) { + *(u16_t *)work[-1].flags = uVar1; + goto LAB_23051cec; + } + fmt = "Unable to allocate buffer for SDU\r\n"; + goto LAB_23051cd4; + } + pcVar4 = *(code **)(work[-0xb].flags[0] + 0x10); + iVar2 = (*pcVar4)(chan,buf,pcVar4); + if (iVar2 != 0) { + if (iVar2 == -0x44) goto LAB_23051cde; + printf("err %d\r\n",iVar2); + goto LAB_23051cd8; + } + l2cap_chan_send_credits(chan,1); + } +LAB_23051cde: + net_buf_unref(buf); + } while( true ); +} + + + +// WARNING: Could not reconcile some variable overlaps + +int l2cap_recv(bt_l2cap_chan *chan_1,net_buf *buf) + +{ + ushort credits; + u16_t cid; + u16_t credits_00; + u16_t credits_01; + ushort uVar1; + u16_t *__s; + _Bool remove; + char *fmt; + byte *pbVar2; + net_buf *buf_00; + bt_l2cap_server *pbVar3; + undefined3 extraout_var; + bt_l2cap_le_chan *chan_00; + uint uVar4; + bt_l2cap_le_chan *pbVar5; + int iVar6; + undefined3 extraout_var_00; + bt_conn *conn; + byte ident; + undefined *data; + u8_t data_len; + int iVar7; + bt_security_t bVar8; + u16_t psm; + bt_l2cap_chan_ops *pbVar9; + anon_subr_void_bt_l2cap_chan_ptr_for_connected *paVar10; + bt_l2cap_chan **ppbVar11; + bt_l2cap_le_chan *local_38; + bt_l2cap_chan *chan; + + if (*(ushort *)((int)&buf->field_4 + 4) < 4) { + fmt = "Too small L2CAP signaling PDU\r\n"; + goto LAB_23051d78; + } + pbVar2 = (byte *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,4); + credits = *(ushort *)((int)&buf->field_4 + 4); + if ((uint)*(ushort *)(pbVar2 + 2) != (uint)credits) { + printf("L2CAP length mismatch (%u != %u)\r\n",(uint)credits); + return 0; + } + ident = pbVar2[1]; + if (ident == 0) { + fmt = "Invalid ident value in L2CAP PDU\r\n"; + goto LAB_23051d78; + } + switch((uint)*pbVar2 - 1 & 0xff) { + case 0: + chan_00 = __l2cap_lookup_ident(chan_1->conn,(ushort)ident,true); + break; + default: + printf("Unknown L2CAP PDU code 0x%02x\r\n"); + data_len = '\0'; + data = (undefined *)0x0; + psm = 0; + ident = pbVar2[1]; + conn = chan_1->conn; + goto LAB_2305211c; + case 5: + if (3 < credits) { + __s = *(u16_t **)&buf->field_4; + conn = chan_1->conn; + chan_00 = l2cap_remove_rx_cid(conn,*__s); + if (chan_00 != (bt_l2cap_le_chan *)0x0) { + buf_00 = l2cap_create_le_sig_pdu('\a',ident,4); + if (buf_00 == (net_buf *)0x0) { + return 0; + } + data = (undefined *)net_buf_simple_add((net_buf_simple *)&buf_00->field_4,4); + psm = (chan_00->rx).cid; + *data = (char)psm; + data[1] = (char)(psm >> 8); + psm = (chan_00->tx).cid; + data[2] = (char)psm; + data[3] = (char)(psm >> 8); + bt_l2cap_chan_del((bt_l2cap_chan *)chan_00); + goto LAB_23051ed6; + } + data = &local_38; + psm = 2; + local_38 = (bt_l2cap_le_chan *)CONCAT22(*__s,__s[1]); + data_len = '\x04'; + goto LAB_2305211c; + } + goto LAB_23051e14; + case 6: + if (credits < 4) { + fmt = "Too small LE disconn rsp packet size\r\n"; + goto LAB_23051d78; + } + chan_00 = l2cap_remove_rx_cid(chan_1->conn,*(u16_t *)(*(int *)&buf->field_4 + 2)); + break; + case 0x11: + if (credits < 8) { + fmt = "Too small LE conn update param req\r\n"; + goto LAB_23051d78; + } + conn = chan_1->conn; + if (conn->role == '\0') { + ppbVar11 = *(bt_l2cap_chan ***)&buf->field_4; + local_38 = (bt_l2cap_le_chan *)*ppbVar11; + chan._0_2_ = *(u16_t *)(ppbVar11 + 1); + chan._2_2_ = *(u16_t *)((int)ppbVar11 + 6); + buf_00 = l2cap_create_le_sig_pdu('\x13',ident,2); + if (buf_00 == (net_buf *)0x0) { + return 0; + } + remove = le_param_req(conn,(bt_le_conn_param *)&local_38); + pbVar2 = (byte *)net_buf_simple_add((net_buf_simple *)&buf_00->field_4,2); + *pbVar2 = remove ^ 1; + pbVar2[1] = 0; + bt_l2cap_send(conn,5,buf_00); + if (CONCAT31(extraout_var_00,remove) == 0) { + return 0; + } + bt_conn_le_conn_update(conn,(bt_le_conn_param *)&local_38); + return 0; + } + data_len = '\0'; + data = (undefined *)0x0; + psm = 0; +LAB_2305211c: + l2cap_send_reject(conn,ident,psm,data,data_len); + return 0; + case 0x12: + if (1 < credits) { + return 0; + } + fmt = "Too small LE conn param rsp\r\n"; + goto LAB_23051d78; + case 0x13: + if (9 < credits) { + __s = *(u16_t **)&buf->field_4; + credits = __s[2]; + if ((credits < 0x17) || (uVar1 = __s[3], uVar1 < 0x17)) { + fmt = "Invalid LE-Conn Req params\r\n"; + goto LAB_23051d78; + } + psm = *__s; + conn = chan_1->conn; + cid = __s[1]; + credits_00 = __s[4]; + buf_00 = l2cap_create_le_sig_pdu('\x15',ident,10); + if (buf_00 == (net_buf *)0x0) { + return 0; + } + __s = (u16_t *)net_buf_simple_add((net_buf_simple *)&buf_00->field_4,10); + memset(__s,0,10); + pbVar3 = l2cap_server_lookup_psm(psm); + psm = 2; + if (pbVar3 != (bt_l2cap_server *)0x0) { + if ((byte)conn->sec_level < (byte)pbVar3->sec_level) { + psm = 5; + } + else { + if (0x3f < (ushort)(cid - 0x40)) { + __s[4] = 9; + goto LAB_23051ed6; + } + local_38 = (bt_l2cap_le_chan *)bt_l2cap_le_lookup_tx_cid(conn,cid); + psm = 10; + if (local_38 == (bt_l2cap_le_chan *)0x0) { + iVar6 = (*pbVar3->accept)(conn,(bt_l2cap_chan **)&local_38); + if (iVar6 < 0) { + psm = 6; + if (iVar6 != -0xd) { + if (iVar6 < -0xc) { + iVar7 = -0x23; + psm = 2; + } + else { + psm = 4; + if (iVar6 == -0xc) goto LAB_23051eb6; + iVar7 = -1; + psm = 7; + } + if (iVar6 != iVar7) { + psm = 0xb; + } + } + } + else { + (local_38->chan).required_sec_level = pbVar3->sec_level; + remove = l2cap_chan_add(conn,(bt_l2cap_chan *)local_38,l2cap_chan_destroy); + chan_00 = local_38; + psm = 4; + if (CONCAT31(extraout_var,remove) != 0) { + l2cap_chan_tx_init(local_38); + (chan_00->tx).cid = cid; + (chan_00->tx).mtu = credits; + (chan_00->tx).init_credits = credits_00; + (chan_00->tx).mps = uVar1; + l2cap_chan_tx_give_credits(chan_00,credits_00); + l2cap_chan_rx_init(chan_00); + psm = (chan_00->rx).init_credits; + while (psm = psm - 1, psm != 0xffff) { + k_sem_give(&(chan_00->rx).credits); + } + (local_38->chan).psm = pbVar3->psm; + (local_38->chan).state = BT_L2CAP_CONNECTED; + paVar10 = ((local_38->chan).ops)->connected; + if (paVar10 != (anon_subr_void_bt_l2cap_chan_ptr_for_connected *)0x0) { + (*paVar10)((bt_l2cap_chan *)local_38); + } + *__s = (chan_00->rx).cid; + __s[2] = (chan_00->rx).mps; + __s[1] = (chan_00->rx).mtu; + psm = (chan_00->rx).init_credits; + __s[4] = 0; + __s[3] = psm; + goto LAB_23051ed6; + } + } + } + } + } +LAB_23051eb6: + __s[4] = psm; +LAB_23051ed6: + bt_l2cap_send(conn,5,buf_00); + return 0; + } +LAB_23051e14: + fmt = "Too small LE conn req packet size\r\n"; +LAB_23051d78: + printf(fmt); + return 0; + case 0x14: + if (credits < 10) { + fmt = "Too small LE conn rsp packet size\r\n"; + goto LAB_23051d78; + } + __s = *(u16_t **)&buf->field_4; + conn = chan_1->conn; + credits = __s[4]; + psm = *__s; + cid = __s[1]; + credits_00 = __s[2]; + credits_01 = __s[3]; + if (((credits & 0xfff7) == 0) || (remove = true, credits == 5)) { + remove = false; + } + chan_00 = __l2cap_lookup_ident(conn,(ushort)ident,remove); + if (chan_00 == (bt_l2cap_le_chan *)0x0) { + printf("Cannot find channel for ident %u\r\n",(uint)ident); + return 0; + } + k_delayed_work_cancel(&(chan_00->chan).rtx_work); + (chan_00->chan).ident = '\0'; + if ((credits != 5) && (credits != 8)) { + if (credits == 0) { + (chan_00->chan).state = BT_L2CAP_CONNECTED; + pbVar9 = (chan_00->chan).ops; + (chan_00->tx).cid = psm; + (chan_00->tx).mtu = cid; + (chan_00->tx).mps = credits_00; + paVar10 = pbVar9->connected; + if (paVar10 != (anon_subr_void_bt_l2cap_chan_ptr_for_connected *)0x0) { + (*paVar10)((bt_l2cap_chan *)chan_00); + } + l2cap_chan_tx_give_credits(chan_00,credits_01); + psm = (chan_00->rx).init_credits; + while (psm = psm - 1, psm != 0xffff) { + k_sem_give(&(chan_00->rx).credits); + } + return 0; + } + goto LAB_230520ac; + } + if (credits == 5) { + ident = (chan_00->chan).required_sec_level; + if (ident < 2) goto LAB_2305208e; + if (ident == 2) { + bVar8 = BT_SECURITY_L3; + } + else { + if (ident != 3) goto LAB_230520a2; + bVar8 = BT_SECURITY_L4; + } +LAB_23052090: + (chan_00->chan).required_sec_level = bVar8; + iVar6 = bt_conn_set_security((chan_00->chan).conn,(chan_00->chan).required_sec_level); + if (iVar6 == 0) { + return 0; + } + } + else { + if ((credits == 8) && ((byte)(chan_00->chan).required_sec_level < 2)) { +LAB_2305208e: + bVar8 = BT_SECURITY_MEDIUM; + goto LAB_23052090; + } + } +LAB_230520a2: + bt_l2cap_chan_remove(conn,(bt_l2cap_chan *)chan_00); + goto LAB_230520ac; + case 0x15: + if (credits < 4) { + fmt = "Too small LE Credits packet size\r\n"; + } + else { + __s = *(u16_t **)&buf->field_4; + chan_00 = (bt_l2cap_le_chan *)bt_l2cap_le_lookup_tx_cid(chan_1->conn,*__s); + if (chan_00 != (bt_l2cap_le_chan *)0x0) { + credits = __s[1]; + uVar4 = k_sem_count_get(&(chan_00->tx).credits); + if (0xffff < uVar4 + credits) { + printf("Credits overflow\r\n"); + bt_l2cap_chan_disconnect((bt_l2cap_chan *)chan_00); + return 0; + } + l2cap_chan_tx_give_credits(chan_00,credits); + while( true ) { + pbVar5 = (bt_l2cap_le_chan *)chan_00->tx_buf; + if (pbVar5 == (bt_l2cap_le_chan *)0x0) { + pbVar5 = (bt_l2cap_le_chan *)net_buf_get(&chan_00->tx_queue,0); + } + else { + chan_00->tx_buf = (net_buf *)0x0; + } + if (pbVar5 == (bt_l2cap_le_chan *)0x0) break; + local_38 = pbVar5; + iVar6 = l2cap_chan_le_send_sdu + (chan_00,&local_38, + (uint)*(ushort *)&(pbVar5->chan).rtx_work.work.handler); + if (iVar6 < 0) { + if (iVar6 != -0xb) { + return 0; + } + *(bt_l2cap_le_chan **)&chan_00->tx_buf = local_38; + return 0; + } + } + return 0; + } + fmt = "Unable to find channel of LE Credits packet\r\n"; + } + goto LAB_23051d78; + } + if (chan_00 == (bt_l2cap_le_chan *)0x0) { + return 0; + } +LAB_230520ac: + bt_l2cap_chan_del((bt_l2cap_chan *)chan_00); + return 0; +} + + + +void uuid_to_uuid128(bt_uuid *src,bt_uuid_128 *dst) + +{ + u8_t uVar1; + undefined2 uVar2; + void *pvVar3; + undefined4 uVar4; + + uVar1 = src->type; + if (uVar1 == '\x01') { + pvVar3 = memcpy(dst,&uuid128_base,0x11); + uVar4 = *(undefined4 *)(src + 4); + *(undefined *)((int)pvVar3 + 0xd) = (char)uVar4; + *(undefined *)((int)pvVar3 + 0xf) = (char)((uint)uVar4 >> 0x10); + *(undefined *)((int)pvVar3 + 0xe) = (char)((uint)uVar4 >> 8); + *(undefined *)((int)pvVar3 + 0x10) = (char)((uint)uVar4 >> 0x18); + } + else { + if (uVar1 == '\0') { + pvVar3 = memcpy(dst,&uuid128_base,0x11); + uVar2 = *(undefined2 *)(src + 2); + *(undefined *)((int)pvVar3 + 0xd) = (char)uVar2; + *(undefined *)((int)pvVar3 + 0xe) = (char)((ushort)uVar2 >> 8); + } + else { + if (uVar1 == '\x02') { + memcpy(dst,src,0x11); + return; + } + } + } + return; +} + + + +int bt_uuid_cmp(bt_uuid *u1,bt_uuid *u2) + +{ + u8_t uVar1; + int iVar2; + uint uVar3; + uint uVar4; + undefined uStack56; + undefined auStack55 [3]; + bt_uuid_128 uuid1; + undefined auStack35 [3]; + bt_uuid_128 uuid2; + + uVar1 = u2->type; + if (uVar1 == u1->type) { + if (uVar1 == '\x01') { + uVar3 = *(uint *)(u1 + 4); + uVar4 = *(uint *)(u2 + 4); + } + else { + if (uVar1 != '\0') { + if (uVar1 != '\x02') { + return -0x16; + } + u2 = u2 + 1; + u1 = u1 + 1; + goto LAB_230523c0; + } + uVar3 = (uint)*(ushort *)(u1 + 2); + uVar4 = (uint)*(ushort *)(u2 + 2); + } + iVar2 = uVar3 - uVar4; + } + else { + uuid_to_uuid128(u1,(bt_uuid_128 *)&uStack56); + uuid_to_uuid128(u2,(bt_uuid_128 *)(uuid1.val + 0xf)); + u2 = (bt_uuid *)auStack35; + u1 = (bt_uuid *)(&uStack56 + 1); +LAB_230523c0: + iVar2 = memcmp(u1,u2,0x10); + } + return iVar2; +} + + + +_Bool bt_uuid_create(bt_uuid *uuid,u8_t *data,u8_t data_len) + +{ + undefined3 in_register_00002031; + int iVar1; + + iVar1 = CONCAT31(in_register_00002031,data_len); + if (iVar1 == 4) { + uuid->type = '\x01'; + *(undefined4 *)(uuid + 4) = *(undefined4 *)data; + } + else { + if (iVar1 == 0x10) { + uuid->type = '\x02'; + memcpy(uuid + 1,data,0x10); + return true; + } + if (iVar1 != 2) { + return false; + } + uuid->type = '\0'; + *(undefined2 *)(uuid + 2) = *(undefined2 *)data; + } + return true; +} + + + +// WARNING: Variable defined which should be unmapped: tmp5 + +void bt_uuid_to_str(bt_uuid *uuid,char *str,size_t len) + +{ + u8_t uVar1; + uint uVar2; + undefined auStack32 [2]; + ushort uStack30; + u16_t tmp0; + u16_t tmp2; + u16_t tmp3; + u16_t tmp4; + u32_t_conflict tmp1; + u32_t_conflict tmp5; + + uVar1 = uuid->type; + if (uVar1 == '\x01') { + uVar2 = *(uint *)(uuid + 4); + } + else { + if (uVar1 != '\0') { + if (uVar1 != '\x02') { + memset(str,0,len); + return; + } + memcpy(auStack32,uuid + 1,2); + memcpy(&tmp3,uuid + 3,4); + memcpy(&uStack30,uuid + 7,2); + memcpy(&tmp0,uuid + 9,2); + memcpy(&tmp2,uuid + 0xb,2); + memcpy(&tmp1,uuid + 0xd,4); + snprintf(str,len,"%08x-%04x-%04x-%04x-%08x%04x",tmp1,(uint)tmp2,(uint)tmp0,(uint)uStack30, + _tmp3); + return; + } + uVar2 = (uint)*(ushort *)(uuid + 2); + } + snprintf(str,len,"%04x",uVar2); + return; +} + + + +void sys_memcpy_swap(void *dst,void *src,size_t length) + +{ + undefined *puVar1; + undefined *puVar2; + undefined *puVar3; + + puVar1 = (undefined *)dst; + puVar3 = (undefined *)((int)src + (length - 1)); + do { + puVar2 = puVar1 + 1; + *puVar1 = *puVar3; + puVar1 = puVar2; + puVar3 = puVar3 + -1; + } while ((undefined *)(length + (int)dst) != puVar2); + return; +} + + + +void sys_mem_swap(void *buf,size_t length) + +{ + undefined uVar1; + undefined *puVar2; + undefined *puVar3; + int iVar4; + + iVar4 = (int)buf + length; + puVar2 = (undefined *)buf; + do { + uVar1 = *puVar2; + puVar3 = puVar2 + 1; + *puVar2 = *(undefined *)(iVar4 + -1); + *(undefined *)(iVar4 + -1) = uVar1; + iVar4 = iVar4 + -1; + puVar2 = puVar3; + } while (puVar3 != (undefined *)((length >> 1) + (int)buf)); + return; +} + + + +u8_t get_io_capa(void) + +{ + u8_t uVar1; + anon_subr_void_bt_conn_ptr_uint_for_passkey_display *paVar2; + + uVar1 = '\x03'; + if (bt_auth != (bt_conn_auth_cb *)0x0) { + paVar2 = bt_auth->passkey_display; + if ((paVar2 == (anon_subr_void_bt_conn_ptr_uint_for_passkey_display *)0x0) || + (bt_auth->passkey_entry == (anon_subr_void_bt_conn_ptr_for_passkey_entry *)0x0)) { + if ((sc_supported != false) && + ((paVar2 != (anon_subr_void_bt_conn_ptr_uint_for_passkey_display *)0x0 && + (bt_auth->passkey_confirm != (anon_subr_void_bt_conn_ptr_uint_for_passkey_confirm *)0x0))) + ) { + return '\x01'; + } + } + else { + if (bt_auth->passkey_confirm != (anon_subr_void_bt_conn_ptr_uint_for_passkey_confirm *)0x0) { + return '\x04'; + } + if (sc_supported == false) { + return '\x04'; + } + } + uVar1 = '\x02'; + if ((bt_auth->passkey_entry == (anon_subr_void_bt_conn_ptr_for_passkey_entry *)0x0) && + (uVar1 = '\x03', paVar2 != (anon_subr_void_bt_conn_ptr_uint_for_passkey_display *)0x0)) { + uVar1 = '\0'; + } + } + return uVar1; +} + + + +bt_smp * smp_chan_get(bt_conn *conn) + +{ + bt_smp *pbVar1; + + pbVar1 = (bt_smp *)bt_l2cap_le_lookup_rx_cid(conn,6); + if (pbVar1 == (bt_smp *)0x0) { + printf("Unable to find SMP channel\r\n"); + } + return pbVar1; +} + + + +void atomic_set_bit(atomic_t *target,int bit) + +{ + atomic_or(target,1 << (bit & 0x1fU)); + return; +} + + + +int atomic_test_bit(atomic_t *target,int bit) + +{ + atomic_val_t aVar1; + + aVar1 = atomic_get(target); + return aVar1 >> (bit & 0x1fU) & 1; +} + + + +void smp_reset(bt_smp *smp) + +{ + bt_conn *pbVar1; + int bit; + + pbVar1 = (smp->chan).chan.conn; + k_delayed_work_cancel(&smp->work); + smp->method = '\0'; + atomic_set(&smp->allowed_cmds,0); + atomic_set(smp->flags,0); + if (pbVar1->required_sec_level != pbVar1->sec_level) { + pbVar1->required_sec_level = pbVar1->sec_level; + } + bit = 0xb; + if (pbVar1->role != '\0') { + bit = 1; + } + atomic_set_bit(&smp->allowed_cmds,bit); + return; +} + + + +void smp_pairing_complete(bt_smp *smp,u8_t status) + +{ + bool bVar1; + uint uVar2; + int iVar3; + undefined3 in_register_0000202d; + uint uVar4; + anon_subr_void_bt_conn_ptr__Bool_for_pairing_complete *paVar5; + + if (CONCAT31(in_register_0000202d,status) == 0) { + iVar3 = atomic_test_bit(smp->flags,0xc); + if (bt_auth == (bt_conn_auth_cb *)0x0) goto LAB_2305267c; + paVar5 = bt_auth->pairing_complete; + bVar1 = iVar3 != 0; + } + else { + uVar4 = CONCAT31(in_register_0000202d,status) - 1U & 0xff; + uVar2 = 8; + if (uVar4 < 0xe) { + uVar2 = (uint)(byte)CSWTCH_108[uVar4]; + } + bVar1 = (bool)SUB41(uVar2,0); + iVar3 = atomic_test_bit(smp->flags,2); + if (iVar3 == 0) { + bt_conn_security_changed((smp->chan).chan.conn,uVar2); + } + if (bt_auth == (bt_conn_auth_cb *)0x0) goto LAB_2305267c; + paVar5 = (anon_subr_void_bt_conn_ptr__Bool_for_pairing_complete *)bt_auth->pairing_failed; + } + if (paVar5 != (anon_subr_void_bt_conn_ptr__Bool_for_pairing_complete *)0x0) { + (*paVar5)((smp->chan).chan.conn,(_Bool)bVar1); + } +LAB_2305267c: + smp_reset(smp); + return; +} + + + +// WARNING: Variable defined which should be unmapped: sched + +int bt_smp_aes_cmac(u8_t *key,u8_t *in,size_t len,u8_t *out) + +{ + int iVar1; + undefined auStack280 [4]; + tc_cmac_struct state; + tc_aes_key_sched_struct sched; + + iVar1 = tc_cmac_setup((TCCmacState_t)auStack280,key,(TCAesKeySched_t)((int)&state.countdown + 4)); + if (((iVar1 != 0) && (iVar1 = tc_cmac_update((TCCmacState_t)auStack280,in,len), iVar1 != 0)) && + (iVar1 = tc_cmac_final(out,(TCCmacState_t)auStack280), iVar1 != 0)) { + return 0; + } + return -5; +} + + + +int smp_sign_buf(u8_t *key,u8_t *msg,u16_t len) + +{ + size_t length; + int iVar1; + undefined2 in_register_00002032; + undefined4 uStack68; + u32_t_conflict cnt; + u8_t key_s [16]; + u8_t tmp [16]; + + length = CONCAT22(in_register_00002032,len) + 4; + uStack68 = *(undefined4 *)(msg + CONCAT22(in_register_00002032,len)); + sys_mem_swap(msg,length); + sys_memcpy_swap(&cnt,key,0x10); + iVar1 = bt_smp_aes_cmac((u8_t *)&cnt,msg,length,key_s + 0xc); + if (iVar1 == 0) { + sys_mem_swap(key_s + 0xc,0x10); + memcpy(tmp,&uStack68,4); + sys_mem_swap(msg,length); + memcpy(msg + CONCAT22(in_register_00002032,len),tmp,0xc); + } + else { + printf("Data signing failed\r\n"); + } + return iVar1; +} + + + +// WARNING: Variable defined which should be unmapped: m + +int smp_f4(u8_t *u,u8_t *v,u8_t *x,u8_t z,u8_t *res) + +{ + int iVar1; + u8_t auStack100 [4]; + u8_t xs [16]; + u8_t m [65]; + + sys_memcpy_swap(xs + 0xc,u,0x20); + sys_memcpy_swap(m + 0x1c,v,0x20); + m[60] = z; + sys_memcpy_swap(auStack100,x,0x10); + iVar1 = bt_smp_aes_cmac(auStack100,xs + 0xc,0x41,res); + if (iVar1 == 0) { + sys_mem_swap(res,0x10); + } + return iVar1; +} + + + +u8_t sc_smp_check_confirm(bt_smp *smp) + +{ + int iVar1; + byte z; + u8_t uVar2; + u8_t auStack32 [4]; + u8_t cfm [16]; + + switch(smp->method) { + case '\0': + case '\x03': + z = 0; + break; + case '\x01': + case '\x02': + z = (byte)(smp->passkey >> ((uint)smp->passkey_round & 0x1f)) & 1 | 0x80; + break; + default: + return '\b'; + case '\x05': + return '\0'; + } + iVar1 = smp_f4(smp->pkey,sc_public_key,smp->rrnd,z,auStack32); + uVar2 = '\b'; + if (iVar1 == 0) { + iVar1 = memcmp(smp->pcnf,auStack32,0x10); + uVar2 = (iVar1 != 0) << 2; + } + return uVar2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int smp_f5(u8_t *w,u8_t *n1,u8_t *n2,bt_addr_le_t *a1,bt_addr_le_t *a2,u8_t *mackey,u8_t *ltk) + +{ + u8_t salt [16]; + int iVar1; + u8_t auStack152 [4]; + u8_t t [16]; + u8_t ws [32]; + u8_t m [53]; + + memset(ws + 0x1c,0,0x35); + ws[29] = 'b'; + ws._30_2_ = 0x6c74; + m[0] = 'e'; + m[47] = '\x01'; + sys_memcpy_swap(t + 0xc,w,0x20); + iVar1 = bt_smp_aes_cmac((u8_t *)&ram0x230bbdcc,t + 0xc,0x20,auStack152); + if (iVar1 == 0) { + sys_memcpy_swap(m + 1,n1,0x10); + sys_memcpy_swap(m + 0x11,n2,0x10); + m[33] = a1->type; + sys_memcpy_swap(m + 0x22,&a1->a,6); + m[40] = a2->type; + sys_memcpy_swap(m + 0x29,&a2->a,6); + iVar1 = bt_smp_aes_cmac(auStack152,ws + 0x1c,0x35,mackey); + if (iVar1 == 0) { + sys_mem_swap(mackey,0x10); + ws[28] = '\x01'; + iVar1 = bt_smp_aes_cmac(auStack152,ws + 0x1c,0x35,ltk); + if (iVar1 == 0) { + sys_mem_swap(ltk,0x10); + } + } + } + return iVar1; +} + + + +// WARNING: Variable defined which should be unmapped: m + +int smp_f6(u8_t *w,u8_t *n1,u8_t *n2,u8_t *r,u8_t *iocap,bt_addr_le_t *a1,bt_addr_le_t *a2, + u8_t *check) + +{ + int iVar1; + u8_t auStack100 [4]; + u8_t ws [16]; + u8_t m [65]; + + sys_memcpy_swap(ws + 0xc,n1,0x10); + sys_memcpy_swap(m + 0xc,n2,0x10); + sys_memcpy_swap(m + 0x1c,r,0x10); + sys_memcpy_swap(m + 0x2c,iocap,3); + m[47] = a1->type; + memcpy(m + 0x30,&a1->a,6); + sys_memcpy_swap(m + 0x30,&a1->a,6); + m[54] = a2->type; + memcpy(m + 0x37,&a2->a,6); + sys_memcpy_swap(m + 0x37,&a2->a,6); + sys_memcpy_swap(auStack100,w,0x10); + iVar1 = bt_smp_aes_cmac(auStack100,ws + 0xc,0x41,check); + if (iVar1 == 0) { + sys_mem_swap(check,0x10); + } + return iVar1; +} + + + +// WARNING: Variable defined which should be unmapped: m + +int smp_g2(u8_t *u,u8_t *v,u8_t *x,u8_t *y,u32_t_conflict *passkey) + +{ + int iVar1; + uint uVar2; + u8_t auStack112 [4]; + u8_t xs [16]; + u8_t m [80]; + + sys_memcpy_swap(xs + 0xc,u,0x20); + sys_memcpy_swap(m + 0x1c,v,0x20); + sys_memcpy_swap(m + 0x3c,y,0x10); + sys_memcpy_swap(auStack112,x,0x10); + iVar1 = bt_smp_aes_cmac(auStack112,xs + 0xc,0x50,auStack112); + if (iVar1 == 0) { + memcpy(passkey,xs + 8,4); + uVar2 = *passkey; + *passkey = (uVar2 >> 0x18 | uVar2 << 0x18 | uVar2 >> 8 & 0xff00 | (uVar2 & 0xff00) << 8) % + 1000000; + } + return iVar1; +} + + + +int atomic_test_and_clear_bit(atomic_t *target,int bit) + +{ + uint uVar1; + uint uVar2; + + uVar1 = 1 << (bit & 0x1fU); + uVar2 = atomic_and(target + ((uint)bit >> 5),~uVar1); + return (uint)((uVar2 & uVar1) != 0); +} + + + +u8_t display_passkey(bt_smp *smp) + +{ + u8_t uVar1; + int iVar2; + + iVar2 = bt_rand(&smp->passkey,4); + uVar1 = '\b'; + if (iVar2 == 0) { + smp->passkey_round = '\0'; + uVar1 = '\0'; + smp->passkey = smp->passkey % 1000000; + if ((bt_auth != (bt_conn_auth_cb *)0x0) && + (bt_auth->passkey_display != (anon_subr_void_bt_conn_ptr_uint_for_passkey_display *)0x0)) { + atomic_set_bit(smp->flags,10); + (*bt_auth->passkey_display)((smp->chan).chan.conn,smp->passkey); + } + } + return uVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +_Bool update_keys_check(bt_smp *smp) + +{ + bt_conn *pbVar1; + bt_keys *pbVar2; + int iVar3; + byte bVar4; + + pbVar1 = (smp->chan).chan.conn; + if (*(int *)(pbVar1->field_20 + 0x2c) == 0) { + pbVar2 = bt_keys_get_addr(pbVar1->id,(bt_addr_le_t *)pbVar1->field_20); + *(bt_keys **)(pbVar1->field_20 + 0x2c) = pbVar2; + } + iVar3 = *(int *)(pbVar1->field_20 + 0x2c); + if ((iVar3 != 0) && ((*(ushort *)(iVar3 + 10) & 0x24) != 0)) { + bVar4 = smp->prsp[4]; + if (smp->preq[4] < smp->prsp[4]) { + bVar4 = smp->preq[4]; + } + if ((bVar4 < *(byte *)(iVar3 + 8)) || + (((*(ushort *)(iVar3 + 10) & 0x20) != 0 && + (iVar3 = atomic_test_bit(smp->flags,5), iVar3 == 0)))) { + return false; + } + if ((*(byte *)(*(int *)(pbVar1->field_20 + 0x2c) + 9) & 1) != 0) { + return (_Bool)(smp->method != '\0'); + } + } + return true; +} + + + +u8_t smp_pairing_failed(bt_smp *smp,net_buf *buf) + +{ + atomic_t *target; + int iVar1; + bt_keys *keys; + byte *pbVar2; + bt_conn *pbVar3; + + pbVar2 = *(byte **)&buf->field_4; + pbVar3 = (smp->chan).chan.conn; + printf("reason 0x%x\r\n",(uint)*pbVar2); + target = smp->flags; + iVar1 = atomic_test_and_clear_bit(target,9); + if ((((iVar1 != 0) || (iVar1 = atomic_test_and_clear_bit(target,10), iVar1 != 0)) && + (bt_auth != (bt_conn_auth_cb *)0x0)) && + (bt_auth->cancel != (anon_subr_void_bt_conn_ptr_for_cancel *)0x0)) { + (*bt_auth->cancel)(pbVar3); + } + iVar1 = atomic_test_bit(target,2); + if ((iVar1 != 0) && + (keys = *(bt_keys **)(((smp->chan).chan.conn)->field_20 + 0x2c), keys != (bt_keys *)0x0)) { + bt_keys_clear(keys); + } + smp_pairing_complete(smp,*pbVar2); + return '\0'; +} + + + +void smp_timeout(k_work *work) + +{ + int iVar1; + bt_keys *keys; + + printf("SMP Timeout\r\n"); + iVar1 = atomic_test_bit(work[-0x14].flags,2); + if ((iVar1 != 0) && (keys = *(bt_keys **)(work[-0x21].flags[0] + 0x9c), keys != (bt_keys *)0x0)) { + bt_keys_clear(keys); + } + atomic_set_bit(work[-0x14].flags,4); + smp_pairing_complete((bt_smp *)work[-0x21].flags,'\b'); + return; +} + + + +u8_t smp_ident_info(bt_smp *smp,net_buf *buf) + +{ + bt_addr_le_t *addr; + int iVar1; + bt_keys *pbVar2; + char *pcVar3; + bt_conn *pbVar4; + void *__src; + + iVar1 = atomic_test_bit(smp->flags,0xc); + if (iVar1 != 0) { + pbVar4 = (smp->chan).chan.conn; + __src = *(void **)&buf->field_4; + addr = (bt_addr_le_t *)pbVar4->field_20; + pbVar2 = bt_keys_get_type(2,pbVar4->id,addr); + if (pbVar2 == (bt_keys *)0x0) { + pcVar3 = bt_addr_le_str_real(addr); + printf("Unable to get keys for %s\r\n",pcVar3); + return '\b'; + } + memcpy(&pbVar2->irk,__src,0x10); + } + atomic_set_bit(&smp->allowed_cmds,9); + return '\0'; +} + + + +u8_t smp_encrypt_info(bt_smp *smp,net_buf *buf) + +{ + bt_addr_le_t *addr; + int iVar1; + bt_keys *pbVar2; + char *pcVar3; + bt_conn *pbVar4; + void *__src; + + iVar1 = atomic_test_bit(smp->flags,0xc); + if (iVar1 != 0) { + pbVar4 = (smp->chan).chan.conn; + __src = *(void **)&buf->field_4; + addr = (bt_addr_le_t *)pbVar4->field_20; + pbVar2 = bt_keys_get_type(4,pbVar4->id,addr); + if (pbVar2 == (bt_keys *)0x0) { + pcVar3 = bt_addr_le_str_real(addr); + printf("Unable to get keys for %s\r\n",pcVar3); + return '\b'; + } + memcpy((pbVar2->ltk).val,__src,0x10); + } + atomic_set_bit(&smp->allowed_cmds,7); + return '\0'; +} + + + +// WARNING: Variable defined which should be unmapped: passkey + +u8_t legacy_request_tk(bt_smp *smp) + +{ + bt_conn *pbVar1; + bt_keys *pbVar2; + int iVar3; + u8_t uVar4; + uint uStack20; + u32_t_conflict passkey; + + pbVar1 = (smp->chan).chan.conn; + pbVar2 = bt_keys_find_addr(pbVar1->id,(bt_addr_le_t *)pbVar1->field_20); + uVar4 = smp->method; + if (((pbVar2 == (bt_keys *)0x0) || ((pbVar2->flags & 1) == 0)) || (uVar4 != '\0')) { + if (uVar4 == '\x01') { + atomic_set_bit(smp->flags,9); + (*bt_auth->passkey_entry)(pbVar1); + } + else { + if (uVar4 == '\0') { + return '\0'; + } + if (uVar4 != '\x02') { + printf("Unknown pairing method (%u)\r\n"); + goto LAB_23052df2; + } + iVar3 = bt_rand(&uStack20,4); + if (iVar3 != 0) { + return '\b'; + } + uStack20 = uStack20 % 1000000; + if ((bt_auth != (bt_conn_auth_cb *)0x0) && + (bt_auth->passkey_display != (anon_subr_void_bt_conn_ptr_uint_for_passkey_display *)0x0)) { + atomic_set_bit(smp->flags,10); + (*bt_auth->passkey_display)(pbVar1,uStack20); + } + smp->tk[0] = (u8_t)uStack20; + smp->tk[2] = (u8_t)(uStack20 >> 0x10); + smp->tk[1] = (u8_t)(uStack20 >> 8); + smp->tk[3] = (u8_t)(uStack20 >> 0x18); + } + uVar4 = '\0'; + } + else { + printf("JustWorks failed, authenticated keys present\r\n"); +LAB_23052df2: + uVar4 = '\b'; + } + return uVar4; +} + + + +void bt_smp_disconnected(bt_l2cap_chan *chan) + +{ + bt_keys *keys; + + keys = *(bt_keys **)(chan->conn->field_20 + 0x2c); + k_delayed_work_cancel((k_delayed_work *)&chan[6].ops); + if (chan[6].rtx_work.work.handler != (k_work_handler_t *)0x0) { + k_delayed_work_del_timer((k_delayed_work *)&chan[6].ops); + } + if ((chan->rtx_work).timer.timer.hdl != (void *)0x0) { + k_delayed_work_del_timer(&chan->rtx_work); + } + if ((keys != (bt_keys *)0x0) && ((keys->keys == 0 || ((keys->flags & 2) != 0)))) { + bt_keys_clear(keys); + } + memset(chan,0,0x1a8); + return; +} + + + +void bt_smp_connected(bt_l2cap_chan *chan) + +{ + k_delayed_work_init((k_delayed_work *)&chan[6].ops,smp_timeout); + smp_reset((bt_smp *)chan); + return; +} + + + +u8_t get_auth(u8_t auth) + +{ + u8_t uVar1; + byte bVar2; + undefined3 in_register_00002029; + undefined3 extraout_var; + byte in_a1; + byte bVar3; + + bVar2 = in_a1 & 0xf; + if (sc_supported == false) { + bVar2 = in_a1 & 7; + } + uVar1 = get_io_capa(); + if ((CONCAT31(extraout_var,uVar1) == 3) || + (bVar3 = bVar2 | 4, *(byte *)CONCAT31(in_register_00002029,auth) < 3)) { + bVar3 = bVar2 & 0xb; + } + bVar2 = bVar3 & 0xfe; + if (bondable != false) { + bVar2 = bVar3 | 1; + } + return (u8_t)bVar2; +} + + + +_Bool sec_level_reachable(void) + +{ + u8_t uVar1; + uint in_a0; + undefined3 extraout_var; + undefined3 extraout_var_00; + _Bool _Var2; + + if (in_a0 == 3) { + uVar1 = get_io_capa(); + _Var2 = true; + if (((CONCAT31(extraout_var_00,uVar1) == 3) && + (_Var2 = false, bt_auth != (bt_conn_auth_cb *)0x0)) && + (bt_auth->oob_data_request != + (anon_subr_void_bt_conn_ptr_bt_conn_oob_info_ptr_for_oob_data_request *)0x0)) { + _Var2 = oobd_present; + } + return (_Bool)(_Var2 & 1); + } + if (3 < in_a0) { + if (in_a0 == 4) { + uVar1 = get_io_capa(); + if ((CONCAT31(extraout_var,uVar1) != 3) || + (((_Var2 = false, bt_auth != (bt_conn_auth_cb *)0x0 && + (bt_auth->oob_data_request != + (anon_subr_void_bt_conn_ptr_bt_conn_oob_info_ptr_for_oob_data_request *)0x0)) && + (oobd_present != false)))) { + _Var2 = sc_supported; + } + return (_Bool)(_Var2 & 1); + } + return false; + } + return (_Bool)(in_a0 != 0); +} + + + +int bt_smp_accept(bt_conn *conn,bt_l2cap_chan **chan) + +{ + int iVar1; + + if (bt_smp_pool[0].chan.chan.conn == (bt_conn *)0x0) { + iVar1 = 0; + } + else { + if (bt_smp_pool[1].chan.chan.conn != (bt_conn *)0x0) { + printf("No available SMP context for conn %p\r\n",conn); + return -0xc; + } + iVar1 = 1; + } + bt_smp_pool[iVar1].chan.chan.ops = (bt_l2cap_chan_ops *)0x4200dea4; + *(bt_smp **)chan = bt_smp_pool + iVar1; + return 0; +} + + + +_Bool smp_keys_check(bt_conn *conn) + +{ + byte bVar1; + bt_keys *pbVar2; + int iVar3; + + if (*(int *)(conn->field_20 + 0x2c) == 0) { + pbVar2 = bt_keys_find(0x20,conn->id,(bt_addr_le_t *)conn->field_20); + *(bt_keys **)(conn->field_20 + 0x2c) = pbVar2; + if (pbVar2 == (bt_keys *)0x0) { + pbVar2 = bt_keys_find(4,conn->id,(bt_addr_le_t *)conn->field_20); + *(bt_keys **)(conn->field_20 + 0x2c) = pbVar2; + } + } + iVar3 = *(int *)(conn->field_20 + 0x2c); + bVar1 = 0; + if (((iVar3 != 0) && ((*(ushort *)(iVar3 + 10) & 0x24) != 0)) && + (bVar1 = 1, 2 < (byte)conn->required_sec_level)) { + bVar1 = *(byte *)(iVar3 + 9) & 1; + } + return (_Bool)bVar1; +} + + + +u8_t get_pair_method(bt_smp *smp,u8_t remote_io) + +{ + byte bVar1; + byte bVar2; + u8_t uVar3; + int iVar4; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 in_register_0000202d; + uint uVar5; + + uVar5 = CONCAT31(in_register_0000202d,remote_io); + iVar4 = atomic_test_bit(smp->flags,5); + bVar2 = (byte)iVar4; + if (iVar4 == 0) { + if ((uVar5 < 5) && (bVar1 = smp->preq[3] | smp->prsp[3], bVar2 = bVar1 & 4, (bVar1 & 4) != 0)) { + uVar3 = get_io_capa(); + bVar2 = ""[CONCAT31(extraout_var,uVar3) + uVar5 * 5]; + if (bVar2 == 4) { + bVar2 = (((smp->chan).chan.conn)->role == '\0') + 1; + } + } + } + else { + if (((((smp->preq[3] & smp->prsp[3] & 8) == 0) || + (bVar2 = 5, ((smp->preq[2] | smp->prsp[2]) & 1) == 0)) && (bVar2 = 0, uVar5 < 5)) && + (bVar1 = smp->preq[3] | smp->prsp[3], bVar2 = bVar1 & 4, (bVar1 & 4) != 0)) { + uVar3 = get_io_capa(); + bVar2 = ""[CONCAT31(extraout_var_00,uVar3) + uVar5 * 5]; + } + } + return (u8_t)bVar2; +} + + + +net_buf * smp_create_pdu(bt_smp *smp,u8_t op) + +{ + int iVar1; + net_buf *pnVar2; + u8_t *puVar3; + s32_t timeout; + + iVar1 = atomic_test_bit(smp->flags,4); + timeout = 0; + if (iVar1 == 0) { + timeout = 30000; + } + pnVar2 = bt_l2cap_create_pdu_timeout((net_buf_pool *)0x0,0,timeout); + if (pnVar2 == (net_buf *)0x0) { + atomic_set_bit(smp->flags,4); + } + else { + puVar3 = (u8_t *)net_buf_simple_add((net_buf_simple *)&pnVar2->field_4,1); + *puVar3 = op; + } + return pnVar2; +} + + + +void smp_send(bt_smp *smp,net_buf *buf,bt_conn_tx_cb_t *cb) + +{ + bt_l2cap_send_cb((smp->chan).chan.conn,6,buf,cb,(void *)0x0); + k_delayed_work_submit(&smp->work,30000); + return; +} + + + +u8_t sc_smp_send_dhkey_check(bt_smp *smp,u8_t *e) + +{ + u8_t uVar1; + net_buf *buf; + void *__dest; + + buf = smp_create_pdu(smp,'\r'); + if (buf == (net_buf *)0x0) { + uVar1 = '\b'; + } + else { + __dest = net_buf_simple_add((net_buf_simple *)&buf->field_4,0x10); + memcpy(__dest,e,0x10); + smp_send(smp,buf,(bt_conn_tx_cb_t *)0x0); + uVar1 = '\0'; + } + return uVar1; +} + + + +u8_t compute_and_send_master_dhcheck(bt_smp *smp) + +{ + u8_t uVar1; + int iVar2; + bt_le_oob_sc_data *__src; + size_t __n; + bt_conn *pbVar3; + u8_t auStack64 [4]; + u8_t e [16]; + u8_t r [16]; + + memset(e + 0xc,0,0x10); + switch(smp->method) { + case '\0': + case '\x03': + break; + case '\x01': + case '\x02': + __n = 4; + __src = (bt_le_oob_sc_data *)&smp->passkey; +LAB_23053250: + memcpy(e + 0xc,__src,__n); + break; + default: + goto switchD_23053248_caseD_4; + case '\x05': + __src = smp->oobd_remote; + if (__src != (bt_le_oob_sc_data *)0x0) { + __n = 0x10; + goto LAB_23053250; + } + } + pbVar3 = (smp->chan).chan.conn; + iVar2 = smp_f5(smp->dhkey,smp->prnd,smp->rrnd,(bt_addr_le_t *)(pbVar3->field_20 + 7), + (bt_addr_le_t *)(pbVar3->field_20 + 0xe),smp->mackey,smp->tk); + if ((iVar2 == 0) && + (pbVar3 = (smp->chan).chan.conn, + iVar2 = smp_f6(smp->mackey,smp->prnd,smp->rrnd,e + 0xc,smp->preq + 1, + (bt_addr_le_t *)(pbVar3->field_20 + 7),(bt_addr_le_t *)(pbVar3->field_20 + 0xe), + auStack64), iVar2 == 0)) { + atomic_set_bit(&smp->allowed_cmds,0xd); + uVar1 = sc_smp_send_dhkey_check(smp,auStack64); + } + else { +switchD_23053248_caseD_4: + uVar1 = '\b'; + } + return uVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +u8_t compute_and_check_and_send_slave_dhcheck(bt_smp *smp) + +{ + u8_t *mackey; + u8_t uVar1; + int iVar2; + undefined3 extraout_var; + bt_le_oob_sc_data *__src; + size_t __n; + bt_conn *pbVar3; + u8_t *n1; + u8_t *n2; + u8_t auStack80 [4]; + u8_t re [16]; + u8_t e [16]; + u8_t r [16]; + + memset(e + 0xc,0,0x10); + switch(smp->method) { + case '\0': + case '\x03': + break; + case '\x01': + case '\x02': + __n = 4; + __src = (bt_le_oob_sc_data *)&smp->passkey; +LAB_23053304: + memcpy(e + 0xc,__src,__n); + break; + default: + goto LAB_230533be; + case '\x05': + __src = smp->oobd_remote; + if (__src != (bt_le_oob_sc_data *)0x0) { + __n = 0x10; + goto LAB_23053304; + } + } + pbVar3 = (smp->chan).chan.conn; + n1 = smp->rrnd; + n2 = smp->prnd; + mackey = smp->mackey; + iVar2 = smp_f5(smp->dhkey,n1,n2,(bt_addr_le_t *)(pbVar3->field_20 + 7), + (bt_addr_le_t *)(pbVar3->field_20 + 0xe),mackey,smp->tk); + if ((iVar2 == 0) && + (pbVar3 = (smp->chan).chan.conn, + iVar2 = smp_f6(mackey,n2,n1,e + 0xc,smp->prsp + 1,(bt_addr_le_t *)(pbVar3->field_20 + 0xe), + (bt_addr_le_t *)(pbVar3->field_20 + 7),re + 0xc), iVar2 == 0)) { + if (smp->method == '\x05') { + if (smp->oobd_local == (bt_le_oob_sc_data *)0x0) { + memset(e + 0xc,0,0x10); + } + else { + memcpy(e + 0xc,smp->oobd_local,0x10); + } + } + pbVar3 = (smp->chan).chan.conn; + iVar2 = smp_f6(mackey,n1,n2,e + 0xc,smp->preq + 1,(bt_addr_le_t *)(pbVar3->field_20 + 7), + (bt_addr_le_t *)(pbVar3->field_20 + 0xe),auStack80); + if (iVar2 == 0) { + iVar2 = memcmp(smp->e,auStack80,0x10); + if (iVar2 != 0) { + return '\v'; + } + uVar1 = sc_smp_send_dhkey_check(smp,re + 0xc); + if (CONCAT31(extraout_var,uVar1) != 0) { + return uVar1; + } + atomic_set_bit(smp->flags,1); + return uVar1; + } + } +LAB_230533be: + return '\b'; +} + + + +// WARNING: Variable defined which should be unmapped: r +// WARNING: Type propagation algorithm not settling + +u8_t smp_dhkey_check(bt_smp *smp,net_buf *buf) + +{ + atomic_t *target; + u8_t uVar1; + int iVar2; + bt_le_oob_sc_data *__src; + size_t __n; + uint len; + bt_conn *pbVar3; + void *__src_00; + u8_t auStack60 [4]; + u8_t ediv [2]; + u8_t rand [8]; + u8_t e [16]; + u8_t r [16]; + + __src_00 = *(void **)&buf->field_4; + uVar1 = ((smp->chan).chan.conn)->role; + if (uVar1 != '\0') { + if (uVar1 == '\x01') { + target = smp->flags; + atomic_and(target,-0x8001); + memcpy(smp->e,__src_00,0x10); + iVar2 = atomic_test_bit(target,7); + if ((iVar2 == 0) && (iVar2 = atomic_test_bit(target,9), iVar2 == 0)) { + uVar1 = compute_and_check_and_send_slave_dhcheck(smp); + return uVar1; + } + atomic_set_bit(target,8); + } + return '\0'; + } + memset(e + 0xc,0,0x10); + switch(smp->method) { + case '\0': + case '\x03': + break; + case '\x01': + case '\x02': + __n = 4; + __src = (bt_le_oob_sc_data *)&smp->passkey; +LAB_2305341a: + memcpy(e + 0xc,__src,__n); + break; + default: + goto LAB_230534a6; + case '\x05': + __src = smp->oobd_local; + if (__src != (bt_le_oob_sc_data *)0x0) { + __n = 0x10; + goto LAB_2305341a; + } + } + pbVar3 = (smp->chan).chan.conn; + iVar2 = smp_f6(smp->mackey,smp->rrnd,smp->prnd,e + 0xc,smp->prsp + 1, + (bt_addr_le_t *)(pbVar3->field_20 + 0xe),(bt_addr_le_t *)(pbVar3->field_20 + 7), + rand + 4); + if (iVar2 == 0) { + iVar2 = memcmp(rand + 4,__src_00,0x10); + if (iVar2 != 0) { + return '\v'; + } + len = (uint)smp->prsp[4]; + if ((uint)smp->preq[4] < (uint)smp->prsp[4]) { + len = (uint)smp->preq[4]; + } + memset(auStack60,0,2); + memset(ediv,0,8); + iVar2 = bt_conn_le_start_encryption((smp->chan).chan.conn,ediv,auStack60,smp->tk,len); + if (-1 < iVar2) { + atomic_set_bit(smp->flags,1); + return 0; + } + } +LAB_230534a6: + return '\b'; +} + + + +u8_t smp_send_pairing_random(bt_smp *smp) + +{ + u8_t uVar1; + net_buf *buf; + void *__dest; + + buf = smp_create_pdu(smp,'\x04'); + if (buf == (net_buf *)0x0) { + uVar1 = '\b'; + } + else { + __dest = net_buf_simple_add((net_buf_simple *)&buf->field_4,0x10); + memcpy(__dest,smp->prnd,0x10); + smp_send(smp,buf,(bt_conn_tx_cb_t *)0x0); + uVar1 = '\0'; + } + return uVar1; +} + + + +u8_t sc_send_public_key(bt_smp *smp) + +{ + u8_t uVar1; + net_buf *buf; + void *__dest; + + buf = smp_create_pdu(smp,'\f'); + if (buf == (net_buf *)0x0) { + uVar1 = '\b'; + } + else { + __dest = net_buf_simple_add((net_buf_simple *)&buf->field_4,0x40); + memcpy(__dest,sc_public_key,0x20); + memcpy((void *)((int)__dest + 0x20),sc_public_key + 0x20,0x20); + smp_send(smp,buf,(bt_conn_tx_cb_t *)0x0); + uVar1 = '\0'; + } + return uVar1; +} + + + +u8_t send_pairing_rsp(bt_smp *smp) + +{ + u8_t uVar1; + net_buf *buf; + void *__dest; + + buf = smp_create_pdu(smp,'\x02'); + if (buf == (net_buf *)0x0) { + uVar1 = '\b'; + } + else { + __dest = net_buf_simple_add((net_buf_simple *)&buf->field_4,6); + memcpy(__dest,smp->prsp + 1,6); + smp_send(smp,buf,(bt_conn_tx_cb_t *)0x0); + uVar1 = '\0'; + } + return uVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +u8_t bt_smp_distribute_keys(bt_smp *smp) + +{ + byte bVar1; + bt_keys *keys; + bt_conn *pbVar2; + char *fmt; + int iVar3; + net_buf *buf; + void *__dest; + bt_keys *keys_00; + atomic_t *target; + undefined auStack60 [4]; + anon_struct_for_rand rand; + + pbVar2 = (smp->chan).chan.conn; + keys_00 = *(bt_keys **)(pbVar2->field_20 + 0x2c); + if (keys_00 == (bt_keys *)0x0) { + fmt = bt_addr_le_str_real((bt_addr_le_t *)pbVar2->field_20); + printf("No keys space for %s\r\n",fmt); + return '\b'; + } + target = smp->flags; + iVar3 = atomic_test_bit(target,5); + if ((iVar3 == 0) && ((smp->local_dist & 1) != 0)) { + keys = *(bt_keys **)(((smp->chan).chan.conn)->field_20 + 0x2c); + bt_rand(auStack60,0x1a); + buf = smp_create_pdu(smp,'\x06'); + if (buf == (net_buf *)0x0) { + fmt = "Unable to allocate Encrypt Info buffer\r\n"; + } + else { + __dest = net_buf_simple_add((net_buf_simple *)&buf->field_4,0x10); + memcpy(__dest,auStack60,(uint)keys->enc_size); + bVar1 = keys->enc_size; + if (bVar1 < 0x10) { + memset((void *)((uint)bVar1 + (int)__dest),0,0x10 - (uint)bVar1); + } + smp_send(smp,buf,(bt_conn_tx_cb_t *)0x0); + buf = smp_create_pdu(smp,'\a'); + if (buf != (net_buf *)0x0) { + __dest = net_buf_simple_add((net_buf_simple *)&buf->field_4,10); + memcpy((void *)((int)__dest + 2),rand.key + 0xc,8); + memcpy(__dest,rand.rand + 4,2); + smp_send(smp,buf,smp_ident_sent); + iVar3 = atomic_test_bit(target,0xc); + if (iVar3 != 0) { + bt_keys_add_type(keys,1); + memcpy((keys->slave_ltk).val,auStack60,0x10); + memcpy(&keys->slave_ltk,rand.key + 0xc,8); + memcpy((keys->slave_ltk).ediv,rand.rand + 4,2); + } + goto LAB_2305366a; + } + fmt = "Unable to allocate Master Ident buffer\r\n"; + } + printf(fmt); + } +LAB_2305366a: + if ((smp->local_dist & 4) == 0) { + return smp->local_dist & 4; + } + buf = smp_create_pdu(smp,'\n'); + if (buf == (net_buf *)0x0) { + printf("Unable to allocate Signing Info buffer\r\n"); + return '\b'; + } + __dest = net_buf_simple_add((net_buf_simple *)&buf->field_4,0x10); + bt_rand(__dest,0x10); + iVar3 = atomic_test_bit(target,0xc); + if (iVar3 != 0) { + bt_keys_add_type(keys_00,8); + memcpy(&keys_00->local_csrk,__dest,0x10); + (keys_00->local_csrk).cnt = 0; + } + smp_send(smp,buf,smp_sign_info_sent); + return '\0'; +} + + + +u8_t smp_signing_info(bt_smp *smp,net_buf *buf) + +{ + bt_conn *pbVar1; + u8_t uVar2; + int iVar3; + bt_keys *pbVar4; + char *pcVar5; + undefined3 extraout_var; + byte bVar6; + void *__src; + + pbVar1 = (smp->chan).chan.conn; + iVar3 = atomic_test_bit(smp->flags,0xc); + if (iVar3 != 0) { + __src = *(void **)&buf->field_4; + pbVar4 = bt_keys_get_type(0x10,pbVar1->id,(bt_addr_le_t *)pbVar1->field_20); + if (pbVar4 == (bt_keys *)0x0) { + pcVar5 = bt_addr_le_str_real((bt_addr_le_t *)pbVar1->field_20); + printf("Unable to get keys for %s\r\n",pcVar5); + return '\b'; + } + memcpy(&pbVar4->remote_csrk,__src,0x10); + } + bVar6 = smp->remote_dist & 0xfb; + smp->remote_dist = bVar6; + if (((bVar6 | pbVar1->role) != 0) || + (uVar2 = bt_smp_distribute_keys(smp), CONCAT31(extraout_var,uVar2) == 0)) { + if (*(short *)&smp->local_dist == 0) { + smp_pairing_complete(smp,'\0'); + } + uVar2 = '\0'; + } + return uVar2; +} + + + +u8_t smp_master_ident(bt_smp *smp,net_buf *buf) + +{ + bt_conn *pbVar1; + u8_t uVar2; + int bit; + bt_keys *pbVar3; + char *pcVar4; + undefined3 extraout_var; + void *__src; + + pbVar1 = (smp->chan).chan.conn; + bit = atomic_test_bit(smp->flags,0xc); + if (bit != 0) { + __src = *(void **)&buf->field_4; + pbVar3 = bt_keys_get_type(4,pbVar1->id,(bt_addr_le_t *)pbVar1->field_20); + if (pbVar3 == (bt_keys *)0x0) { + pcVar4 = bt_addr_le_str_real((bt_addr_le_t *)pbVar1->field_20); + printf("Unable to get keys for %s\r\n",pcVar4); + return '\b'; + } + memcpy((pbVar3->ltk).ediv,__src,2); + memcpy(&pbVar3->ltk,(void *)((int)__src + 2),8); + smp->remote_dist = smp->remote_dist & 0xfe; + } + bit = 8; + if ((smp->remote_dist & 2) == 0) { + if ((smp->remote_dist & 4) == 0) goto LAB_230538b2; + bit = 10; + } + atomic_set_bit(&smp->allowed_cmds,bit); +LAB_230538b2: + if (((pbVar1->role != '\0') || (smp->remote_dist != '\0')) || + (uVar2 = bt_smp_distribute_keys(smp), CONCAT31(extraout_var,uVar2) == 0)) { + if (*(short *)&smp->local_dist == 0) { + smp_pairing_complete(smp,'\0'); + } + uVar2 = '\0'; + } + return uVar2; +} + + + +int smp_init(bt_smp *smp) + +{ + int iVar1; + int iVar2; + + memset(&smp->allowed_cmds,0,0xec); + iVar2 = bt_rand(smp->prnd,0x10); + iVar1 = 8; + if (iVar2 == 0) { + atomic_set_bit(&smp->allowed_cmds,5); + sc_public_key = bt_pub_key_get(); + k_sem_init(&sc_local_pkey_ready,0,1); + iVar1 = iVar2; + } + return iVar1; +} + + + +int smp_send_pairing_req(bt_conn *conn) + +{ + int iVar1; + _Bool _Var2; + u8_t uVar3; + bt_smp *smp; + int iVar4; + undefined3 extraout_var; + bt_keys *pbVar5; + net_buf *buf; + u8_t *__src; + atomic_t *target; + + smp = smp_chan_get(conn); + iVar1 = -0x39; + if (smp != (bt_smp *)0x0) { + target = smp->flags; + iVar4 = atomic_test_bit(target,4); + iVar1 = -5; + if (iVar4 == 0) { + iVar1 = atomic_test_bit(target,3); + if ((iVar1 == 0) && (iVar1 = atomic_test_bit(target,1), iVar1 == 0)) { + iVar1 = -0x16; + _Var2 = sec_level_reachable(); + if (CONCAT31(extraout_var,_Var2) != 0) { + if (*(int *)(conn->field_20 + 0x2c) == 0) { + pbVar5 = bt_keys_get_addr(conn->id,(bt_addr_le_t *)conn->field_20); + *(bt_keys **)(conn->field_20 + 0x2c) = pbVar5; + if (pbVar5 == (bt_keys *)0x0) { + return -0xc; + } + } + iVar1 = smp_init(smp); + if ((iVar1 == 0) && (buf = smp_create_pdu(smp,'\x01'), buf != (net_buf *)0x0)) { + __src = (u8_t *)net_buf_simple_add((net_buf_simple *)&buf->field_4,6); + uVar3 = get_auth((char)conn + '\n'); + __src[2] = uVar3; + uVar3 = get_io_capa(); + _Var2 = oobd_present; + *__src = uVar3; + *(_Bool *)(__src + 1) = _Var2; + __src[3] = '\x10'; + __src[4] = '\x05'; + __src[5] = '\a'; + *(undefined2 *)&smp->local_dist = 0x705; + smp->preq[0] = '\x01'; + memcpy(smp->preq + 1,__src,6); + smp_send(smp,buf,(bt_conn_tx_cb_t *)0x0); + atomic_set_bit(&smp->allowed_cmds,2); + atomic_set_bit(&smp->allowed_cmds,0xb); + atomic_set_bit(target,3); + } + else { + iVar1 = -0x37; + } + } + } + else { + iVar1 = -0x10; + } + } + } + return iVar1; +} + + + +u8_t smp_security_request(bt_smp *smp,net_buf *buf) + +{ + bt_conn *conn; + atomic_t *target; + u8_t uVar1; + int bit; + bt_keys *pbVar2; + undefined3 extraout_var; + int iVar3; + byte *pbVar4; + uint uVar5; + + target = smp->flags; + conn = (smp->chan).chan.conn; + pbVar4 = *(byte **)&buf->field_4; + bit = atomic_test_bit(target,3); + if (bit != 0) { + return '\0'; + } + bit = atomic_test_bit(target,1); + if (bit != 0) { + return '\0'; + } + uVar5 = (uint)*pbVar4 & 7; + if (sc_supported != false) { + uVar5 = (uint)*pbVar4 & 0xf; + } + if (*(int *)(conn->field_20 + 0x2c) == 0) { + pbVar2 = bt_keys_find(0x20,conn->id,(bt_addr_le_t *)conn->field_20); + *(bt_keys **)(conn->field_20 + 0x2c) = pbVar2; + if (pbVar2 == (bt_keys *)0x0) { + pbVar2 = bt_keys_find(4,conn->id,(bt_addr_le_t *)conn->field_20); + *(bt_keys **)(conn->field_20 + 0x2c) = pbVar2; + } +LAB_23053ae2: + bit = *(int *)(conn->field_20 + 0x2c); + if (bit != 0) { + if (((uVar5 & 4) == 0) || ((*(byte *)(bit + 9) & 1) != 0)) { + if (((uVar5 & 8) == 0) || ((*(ushort *)(bit + 10) & 0x20) != 0)) { + iVar3 = bt_conn_le_start_encryption + (conn,(u8_t *)(bit + 0xc),(u8_t *)(bit + 0x14),(u8_t *)(bit + 0x16), + (uint)*(byte *)(bit + 8)); + bit = 1; + if (iVar3 < 0) { + return '\b'; + } + goto LAB_23053ab2; + } + } + else { + uVar1 = get_io_capa(); + if (CONCAT31(extraout_var,uVar1) == 3) { + printf("Unsupported auth requirements: 0x%x, repairing\r\n",uVar5); + } + } + } + } + else { + if ((*(ushort *)(*(int *)(conn->field_20 + 0x2c) + 10) & 0x24) != 0) goto LAB_23053ae2; + } + bit = smp_send_pairing_req(conn); + if (bit < 0) { + return '\b'; + } + bit = 0xe; +LAB_23053ab2: + atomic_set_bit(target,bit); + return '\0'; +} + + + +// WARNING: Type propagation algorithm not settling + +u8_t smp_pairing_req(bt_smp *smp,net_buf *buf) + +{ + u8_t *__src; + byte bVar1; + u8_t uVar2; + _Bool _Var3; + int iVar4; + undefined3 extraout_var; + bt_keys *pbVar5; + undefined3 extraout_var_00; + atomic_t *target; + bt_conn *pbVar6; + + __src = *(u8_t **)&buf->field_4; + if (9 < (byte)(__src[3] - 7)) { + return '\x06'; + } + pbVar6 = (smp->chan).chan.conn; + if (*(int *)(pbVar6->field_20 + 0x2c) == 0) { + pbVar5 = bt_keys_get_addr(pbVar6->id,(bt_addr_le_t *)pbVar6->field_20); + *(bt_keys **)(pbVar6->field_20 + 0x2c) = pbVar5; + if (pbVar5 == (bt_keys *)0x0) { + return '\b'; + } + } + target = smp->flags; + iVar4 = atomic_test_bit(target,0xe); + if ((iVar4 == 0) && (iVar4 = smp_init(smp), iVar4 != 0)) { + return (u8_t)iVar4; + } + smp->preq[0] = '\x01'; + memcpy(smp->preq + 1,__src,6); + smp->prsp[0] = '\x02'; + bVar1 = get_auth((char)pbVar6 + '\n'); + smp->prsp[3] = bVar1; + uVar2 = get_io_capa(); + _Var3 = oobd_present; + smp->prsp[1] = uVar2; + *(_Bool *)(smp->prsp + 2) = _Var3; + smp->prsp[4] = '\x10'; + smp->prsp[5] = __src[4] & 7; + smp->prsp[6] = __src[5] & 5; + if (((bVar1 & 8) != 0) && ((__src[2] & 8) != 0)) { + atomic_set_bit(target,5); + smp->prsp[5] = smp->prsp[5] & 6; + smp->prsp[6] = smp->prsp[6] & 4; + } + if (((smp->prsp[3] & 0x20) != 0) && ((__src[2] & 0x20) != 0)) { + atomic_set_bit(target,0x13); + } + smp->local_dist = smp->prsp[6]; + smp->remote_dist = smp->prsp[5]; + if (((smp->prsp[3] & 1) != 0) && ((__src[2] & 1) != 0)) { + atomic_set_bit(target,0xc); + } + atomic_set_bit(target,3); + uVar2 = get_pair_method(smp,*__src); + smp->method = uVar2; + _Var3 = update_keys_check(smp); + if (CONCAT31(extraout_var,_Var3) == 0) { +LAB_23053c84: + uVar2 = '\x03'; + } + else { + iVar4 = atomic_test_bit(target,5); + uVar2 = smp->method; + if (iVar4 == 0) { + if (((uVar2 != '\0') || (iVar4 = atomic_test_bit(target,0xe), iVar4 != 0)) || + ((bt_auth == (bt_conn_auth_cb *)0x0 || + (bt_auth->pairing_confirm == (anon_subr_void_bt_conn_ptr_for_pairing_confirm *)0x0)))) { + uVar2 = send_pairing_rsp(smp); + if (CONCAT31(extraout_var_00,uVar2) == 0) { + atomic_set_bit(&smp->allowed_cmds,3); + uVar2 = legacy_request_tk(smp); + return uVar2; + } + return uVar2; + } + } + else { + if (pbVar6->required_sec_level == BT_SECURITY_L4) { + if (uVar2 != '\0') { + bVar1 = smp->preq[4]; + if (smp->prsp[4] < smp->preq[4]) { + bVar1 = smp->prsp[4]; + } + if (bVar1 != 0x10) { + return 6; + } + goto LAB_23053d3c; + } + goto LAB_23053c84; + } + if ((((uVar2 != '\0') || (iVar4 = atomic_test_bit(target,0xe), iVar4 != 0)) || + (bt_auth == (bt_conn_auth_cb *)0x0)) || + (bt_auth->pairing_confirm == (anon_subr_void_bt_conn_ptr_for_pairing_confirm *)0x0)) { +LAB_23053d3c: + atomic_set_bit(&smp->allowed_cmds,0xc); + uVar2 = send_pairing_rsp(smp); + return uVar2; + } + } + atomic_set_bit(target,9); + (*bt_auth->pairing_confirm)((smp->chan).chan.conn); + } + return uVar2; +} + + + +void smp_check_complete(bt_conn *conn,u8_t dist_complete) + +{ + bt_smp *smp; + + smp = (bt_smp *)bt_l2cap_le_lookup_tx_cid(conn,6); + smp->local_dist = ~dist_complete & smp->local_dist; + if (*(short *)&smp->local_dist == 0) { + smp_pairing_complete(smp,'\0'); + return; + } + return; +} + + + +void smp_sign_info_sent(bt_conn *conn,void *user_data) + +{ + if (conn->type == '\x01') { + smp_check_complete(conn,'\x04'); + return; + } + return; +} + + + +void le_sc_oob_config_set_isra_3_constprop_19(int *param_1,char *param_2) + +{ + byte bVar1; + char cVar2; + + bVar1 = *(byte *)((int)param_1 + 0xaa); + if (*(char *)(*param_1 + 3) == '\0') { + cVar2 = (char)((uint)bVar1 & 1) + '\x01'; + if (((*(byte *)((int)param_1 + 0xa3) & 1) == 0) && (cVar2 = '\x03', (bVar1 & 1) != 0)) { + cVar2 = '\0'; + } + } + else { + cVar2 = (char)(((uint)bVar1 & 1) << 1); + if (((*(byte *)((int)param_1 + 0xa3) & 1) == 0) && (cVar2 = '\x03', (bVar1 & 1) != 0)) { + cVar2 = '\x01'; + } + } + *param_2 = cVar2; + return; +} + + + +int smp_error(bt_smp *smp,u8_t reason) + +{ + net_buf *buf; + u8_t *puVar1; + int iVar2; + + smp_pairing_complete(smp,reason); + buf = smp_create_pdu(smp,'\x05'); + if (buf == (net_buf *)0x0) { + iVar2 = -0x37; + } + else { + puVar1 = (u8_t *)net_buf_simple_add((net_buf_simple *)&buf->field_4,1); + *puVar1 = reason; + bt_l2cap_send_cb((smp->chan).chan.conn,6,buf,(bt_conn_tx_cb_t *)0x0,(void *)0x0); + iVar2 = 0; + } + return iVar2; +} + + + +void bt_smp_dhkey_ready(u8_t *dhkey) + +{ + atomic_t *target; + u8_t reason; + int iVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + bt_smp *smp; + + iVar1 = atomic_test_and_clear_bit(bt_smp_pool[0].flags,7); + if (iVar1 == 0) { + iVar1 = atomic_test_and_clear_bit(bt_smp_pool[1].flags,7); + if (iVar1 == 0) { + return; + } + iVar1 = 1; + } + else { + iVar1 = 0; + } + reason = '\v'; + smp = bt_smp_pool + iVar1; + if (dhkey == (u8_t *)0x0) { +LAB_23053ee4: + smp_error(smp,reason); + return; + } + memcpy(bt_smp_pool[iVar1].dhkey,dhkey,0x20); + target = bt_smp_pool[iVar1].flags; + iVar1 = atomic_test_bit(target,9); + if ((iVar1 != 0) || (iVar1 = atomic_test_bit(target,0xf), iVar1 != 0)) { + atomic_set_bit(target,8); + return; + } + iVar1 = atomic_test_bit(target,8); + if (iVar1 != 0) { + if (((smp->chan).chan.conn)->role == '\0') { + reason = compute_and_send_master_dhcheck(smp); + iVar1 = CONCAT31(extraout_var,reason); + } + else { + reason = compute_and_check_and_send_slave_dhcheck(smp); + iVar1 = CONCAT31(extraout_var_00,reason); + } + reason = (u8_t)iVar1; + if (iVar1 != 0) goto LAB_23053ee4; + } + return; +} + + + +int bt_smp_recv(bt_l2cap_chan *chan,net_buf *buf) + +{ + byte bVar1; + u8_t reason; + byte *pbVar2; + int iVar3; + undefined3 extraout_var; + uint uVar4; + + if (*(short *)((int)&buf->field_4 + 4) == 0) { + printf("Too small SMP PDU received\r\n"); + } + else { + pbVar2 = (byte *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,1); + iVar3 = atomic_test_bit((atomic_t *)&chan[2].rtx_work.work_q,4); + bVar1 = *pbVar2; + if (iVar3 == 0) { + if ((bVar1 < 0xe) && + (handlers[(uint)bVar1].func != (anon_subr_u8_t_bt_smp_ptr_net_buf_ptr_for_func *)0x0)) { + iVar3 = atomic_test_and_clear_bit(chan[2].rtx_work.work.flags,(uint)bVar1); + uVar4 = (uint)*pbVar2; + if (iVar3 == 0) { + printf("Unexpected SMP code 0x%02x\r\n",uVar4); + reason = '\b'; + if (*pbVar2 == 5) { + return 0; + } + } + else { + if ((uint)handlers[uVar4].expect_len == (uint)*(ushort *)((int)&buf->field_4 + 4)) { + reason = (*handlers[uVar4].func)((bt_smp *)chan,buf); + if (CONCAT31(extraout_var,reason) == 0) { + return 0; + } + } + else { + printf("Invalid len %u for code 0x%02x\r\n"); + reason = '\n'; + } + } + } + else { + printf("Unhandled SMP code 0x%02x\r\n"); + reason = '\a'; + } + smp_error((bt_smp *)chan,reason); + } + else { + printf("SMP command (code 0x%02x) received after timeout\r\n"); + } + } + return 0; +} + + + +void bt_smp_encrypt_change(bt_l2cap_chan *chan,u8_t hci_status) + +{ + byte bVar1; + k_work_q **target; + u8_t uVar2; + int bit; + undefined3 extraout_var; + undefined3 in_register_0000202d; + bt_conn *pbVar3; + + target = &chan[2].rtx_work.work_q; + pbVar3 = chan->conn; + atomic_and((atomic_t *)target,-3); + if (CONCAT31(in_register_0000202d,hci_status) != 0) { + return; + } + if (pbVar3->encrypt == '\0') { + return; + } + bit = atomic_test_bit((atomic_t *)target,3); + if (bit == 0) { + smp_reset((bt_smp *)chan); + return; + } + bit = atomic_test_bit((atomic_t *)target,5); + if (bit != 0) { + if (((*(byte *)&chan[6].conn & 8) != 0) && ((*(byte *)((int)&chan[6].conn + 1) & 8) != 0)) { + atomic_set_bit((atomic_t *)target,0x10); + } + *(ushort *)&chan[6].conn = *(ushort *)&chan[6].conn & 0xf7f7; + } + bVar1 = *(byte *)((int)&chan[6].conn + 1); + bit = 6; + if (((bVar1 & 1) == 0) && (bit = 8, (bVar1 & 2) == 0)) { + if ((bVar1 & 4) == 0) goto LAB_23054088; + bit = 10; + } + atomic_set_bit(chan[2].rtx_work.work.flags,bit); +LAB_23054088: + atomic_set_bit((atomic_t *)target,2); + if ((((pbVar3->role != '\0') || (*(char *)((int)&chan[6].conn + 1) == '\0')) && + (uVar2 = bt_smp_distribute_keys((bt_smp *)chan), CONCAT31(extraout_var,uVar2) == 0)) && + (*(short *)&chan[6].conn == 0)) { + smp_pairing_complete((bt_smp *)chan,'\0'); + return; + } + return; +} + + + +u8_t smp_send_pairing_confirm(bt_smp *smp) + +{ + byte z; + net_buf *buf; + u8_t *res; + int iVar1; + + z = smp->method; + if (z < 3) { + if (z != 0) { + z = (byte)(smp->passkey >> ((uint)smp->passkey_round & 0x1f)) & 1 | 0x80; + goto LAB_23054110; + } + } + else { + if (z != 3) { + return '\b'; + } + } + z = 0; +LAB_23054110: + buf = smp_create_pdu(smp,'\x03'); + if (buf == (net_buf *)0x0) { + return '\b'; + } + res = (u8_t *)net_buf_simple_add((net_buf_simple *)&buf->field_4,0x10); + iVar1 = smp_f4(sc_public_key,smp->pkey,smp->prnd,z,res); + if (iVar1 != 0) { + net_buf_unref(buf); + return '\b'; + } + smp_send(smp,buf,(bt_conn_tx_cb_t *)0x0); + atomic_and(smp->flags,-2); + return '\0'; +} + + + +void smp_ident_sent(bt_conn *conn,void *user_data) + +{ + if (conn->type == '\x01') { + smp_check_complete(conn,'\x01'); + return; + } + return; +} + + + +int smp_c1(u8_t *k,u8_t *r,u8_t *preq,u8_t *pres,bt_addr_le_t *ia,bt_addr_le_t *ra,u8_t *enc_data) + +{ + byte bVar1; + byte *pbVar2; + int iVar3; + byte *pbVar4; + byte *pbVar5; + byte local_40; + u8_t uStack63; + byte abStack62 [2]; + u8_t p1 [16]; + u8_t p2 [16]; + + local_40 = ia->type; + uStack63 = ra->type; + memcpy(&local_40 + 2,preq,7); + memcpy(p1 + 5,pres,7); + iVar3 = 0; + do { + pbVar2 = r + iVar3; + pbVar5 = &local_40 + iVar3; + pbVar4 = enc_data + iVar3; + iVar3 = iVar3 + 1; + *pbVar4 = *pbVar2 ^ *pbVar5; + } while (iVar3 != 0x10); + iVar3 = bt_encrypt_le(k,enc_data,enc_data); + if (iVar3 == 0) { + memcpy(p1 + 0xc,&ra->a,6); + memcpy(p2 + 2,&ia->a,6); + memset(p2 + 8,0,4); + pbVar2 = p1 + 0xc; + pbVar5 = enc_data; + while (enc_data + 0x10 != pbVar5) { + bVar1 = *pbVar2; + pbVar2 = pbVar2 + 1; + *pbVar5 = *pbVar5 ^ bVar1; + pbVar5 = pbVar5 + 1; + } + iVar3 = bt_encrypt_le(k,enc_data,enc_data); + } + return iVar3; +} + + + +u8_t legacy_send_pairing_confirm(bt_smp *smp) + +{ + net_buf *buf; + u8_t *enc_data; + int iVar1; + bt_conn *pbVar2; + + pbVar2 = (smp->chan).chan.conn; + buf = smp_create_pdu(smp,'\x03'); + if (buf != (net_buf *)0x0) { + enc_data = (u8_t *)net_buf_simple_add((net_buf_simple *)&buf->field_4,0x10); + iVar1 = smp_c1(smp->tk,smp->prnd,smp->preq,smp->prsp,(bt_addr_le_t *)(pbVar2->field_20 + 7), + (bt_addr_le_t *)(pbVar2->field_20 + 0xe),enc_data); + if (iVar1 == 0) { + smp_send(smp,buf,(bt_conn_tx_cb_t *)0x0); + atomic_and(smp->flags,-2); + return '\0'; + } + net_buf_unref(buf); + } + return '\b'; +} + + + +u8_t legacy_pairing_confirm(bt_smp *smp) + +{ + u8_t uVar1; + int bit; + + bit = 3; + if (((smp->chan).chan.conn)->role != '\0') { + bit = atomic_test_bit(smp->flags,9); + if (bit != 0) { + atomic_set_bit(smp->flags,0); + return '\0'; + } + bit = 4; + } + atomic_set_bit(&smp->allowed_cmds,bit); + uVar1 = legacy_send_pairing_confirm(smp); + return uVar1; +} + + + +u8_t smp_pairing_confirm(bt_smp *smp,net_buf *buf) + +{ + atomic_t *target; + u8_t uVar1; + int iVar2; + void *__src; + + __src = *(void **)&buf->field_4; + target = smp->flags; + atomic_and(target,-0x401); + memcpy(smp->pcnf,__src,0x10); + if (((smp->chan).chan.conn)->role == '\0') { + atomic_set_bit(&smp->allowed_cmds,4); + uVar1 = smp_send_pairing_random(smp); + return uVar1; + } + iVar2 = atomic_test_bit(target,5); + if (iVar2 != 0) { + if (smp->method == '\x01') { + iVar2 = atomic_test_bit(target,9); + if (iVar2 != 0) { + atomic_set_bit(target,0); + return '\0'; + } + } + else { + if (smp->method != '\x02') { + return '\b'; + } + } + atomic_set_bit(&smp->allowed_cmds,4); + uVar1 = smp_send_pairing_confirm(smp); + return uVar1; + } + uVar1 = legacy_pairing_confirm(smp); + return uVar1; +} + + + +u8_t smp_pairing_rsp(bt_smp *smp,net_buf *buf) + +{ + u8_t *__src; + u8_t uVar1; + _Bool _Var2; + undefined3 extraout_var; + int iVar3; + undefined3 extraout_var_00; + byte bVar4; + atomic_t *target; + bt_conn *pbVar5; + + __src = *(u8_t **)&buf->field_4; + if (9 < (byte)(__src[3] - 7)) { + return '\x06'; + } + pbVar5 = (smp->chan).chan.conn; + smp->local_dist = smp->local_dist & __src[4]; + smp->remote_dist = smp->remote_dist & __src[5]; + smp->prsp[0] = '\x02'; + memcpy(smp->prsp + 1,__src,6); + if (((__src[2] & 8) != 0) && ((smp->preq[3] & 8) != 0)) { + atomic_set_bit(smp->flags,5); + } + if (((__src[2] & 0x20) != 0) && ((smp->preq[3] & 0x20) != 0)) { + atomic_set_bit(smp->flags,0x13); + } + if (((__src[2] & 1) != 0) && ((smp->preq[3] & 1) != 0)) { + atomic_set_bit(smp->flags,0xc); + } + uVar1 = get_pair_method(smp,*__src); + smp->method = uVar1; + _Var2 = update_keys_check(smp); + if (CONCAT31(extraout_var,_Var2) == 0) { +LAB_23054484: + uVar1 = '\x03'; + } + else { + target = smp->flags; + iVar3 = atomic_test_bit(target,5); + uVar1 = smp->method; + if (iVar3 == 0) { + if (((uVar1 != '\0') || (iVar3 = atomic_test_bit(target,0xe), iVar3 == 0)) || + ((bt_auth == (bt_conn_auth_cb *)0x0 || + (bt_auth->pairing_confirm == (anon_subr_void_bt_conn_ptr_for_pairing_confirm *)0x0)))) { + uVar1 = legacy_request_tk(smp); + if (CONCAT31(extraout_var_00,uVar1) != 0) { + return uVar1; + } + iVar3 = atomic_test_bit(target,9); + if (iVar3 == 0) { + atomic_set_bit(&smp->allowed_cmds,3); + uVar1 = legacy_send_pairing_confirm(smp); + return uVar1; + } + atomic_set_bit(target,0); + return uVar1; + } + } + else { + if (pbVar5->required_sec_level == BT_SECURITY_L4) { + if (uVar1 == '\0') goto LAB_23054484; + bVar4 = smp->prsp[4]; + if (smp->preq[4] < smp->prsp[4]) { + bVar4 = smp->preq[4]; + } + if (bVar4 != 0x10) { + return '\x06'; + } + } + *(ushort *)&smp->local_dist = *(ushort *)&smp->local_dist & 0x604; + if ((((uVar1 != '\0') || (iVar3 = atomic_test_bit(target,0xe), iVar3 == 0)) || + (bt_auth == (bt_conn_auth_cb *)0x0)) || + (bt_auth->pairing_confirm == (anon_subr_void_bt_conn_ptr_for_pairing_confirm *)0x0)) { + if (sc_public_key != (u8_t *)0x0) { + atomic_set_bit(&smp->allowed_cmds,0xc); + atomic_and(&smp->allowed_cmds,-0x801); + uVar1 = sc_send_public_key(smp); + return uVar1; + } + atomic_set_bit(target,6); + return '\0'; + } + } + atomic_set_bit(target,9); + (*bt_auth->pairing_confirm)((smp->chan).chan.conn); + } + return uVar1; +} + + + +u8_t smp_ident_addr_info(bt_smp *smp,net_buf *buf) + +{ + byte bVar1; + bt_conn *conn; + u8_t uVar2; + char *pcVar3; + int iVar4; + bt_keys *keys; + undefined3 extraout_var; + byte *pbVar5; + bt_addr_le_t *addr; + bt_addr_le_t *addr_00; + + addr = *(bt_addr_le_t **)&buf->field_4; + conn = (smp->chan).chan.conn; + if ((addr->type == '\0') || (((addr->a).val[5] & 0xc0) == 0xc0)) { + iVar4 = atomic_test_bit(smp->flags,0xc); + if (iVar4 != 0) { + addr_00 = (bt_addr_le_t *)conn->field_20; + keys = bt_keys_get_type(2,conn->id,addr_00); + if (keys == (bt_keys *)0x0) { + pcVar3 = bt_addr_le_str_real(addr_00); + printf("Unable to get keys for %s\r\n",pcVar3); + return '\b'; + } + pbVar5 = conn->field_20 + 7; + if (conn->role == '\0') { + pbVar5 = conn->field_20 + 0xe; + } + if ((((*pbVar5 == 1) && ((pbVar5[6] & 0xc0) == 0x40)) && + (memcpy(&(keys->irk).rpa,pbVar5 + 1,6), conn->field_20[0] != 0)) && + ((conn->field_20[6] & 0xc0) != 0xc0)) { + memcpy(&keys->addr,addr,7); + memcpy(addr_00,addr,7); + bt_conn_identity_resolved(conn); + } + bt_id_add(keys); + } + bVar1 = smp->remote_dist; + smp->remote_dist = bVar1 & 0xfd; + if ((bVar1 & 4) != 0) { + atomic_set_bit(&smp->allowed_cmds,10); + } + if (((conn->role != '\0') || (smp->remote_dist != '\0')) || + (uVar2 = bt_smp_distribute_keys(smp), CONCAT31(extraout_var,uVar2) == 0)) { + if (*(short *)&smp->local_dist == 0) { + smp_pairing_complete(smp,'\0'); + } + uVar2 = '\0'; + } + } + else { + pcVar3 = bt_addr_le_str_real(addr); + printf("Invalid identity %s\r\n",pcVar3); + pcVar3 = bt_addr_le_str_real((bt_addr_le_t *)conn->field_20); + printf(" for %s\r\n",pcVar3); + uVar2 = '\n'; + } + return uVar2; +} + + + +u8_t smp_public_key_slave(bt_smp *smp) + +{ + u8_t uVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + int bit; + + switch(smp->method) { + case '\0': + case '\x03': + atomic_set_bit(&smp->allowed_cmds,4); + uVar1 = smp_send_pairing_confirm(smp); + if (CONCAT31(extraout_var,uVar1) != 0) { + return uVar1; + } + goto LAB_23054756; + case '\x01': + atomic_set_bit(&smp->allowed_cmds,3); + atomic_set_bit(smp->flags,9); + (*bt_auth->passkey_entry)((smp->chan).chan.conn); + goto LAB_23054756; + case '\x02': + uVar1 = display_passkey(smp); + bit = 3; + if (CONCAT31(extraout_var_00,uVar1) != 0) { + return uVar1; + } + break; + case '\x04': + return '\b'; + case '\x05': + bit = 4; + break; + default: + return '\b'; + } + atomic_set_bit(&smp->allowed_cmds,bit); +LAB_23054756: + bit = bt_dh_key_gen(smp->pkey,bt_smp_dhkey_ready); + uVar1 = '\b'; + if (bit == 0) { + atomic_set_bit(smp->flags,7); + uVar1 = '\0'; + } + return uVar1; +} + + + +// WARNING: Variable defined which should be unmapped: info +// WARNING: Type propagation algorithm not settling + +u8_t smp_public_key(bt_smp *smp,net_buf *buf) + +{ + void *__src; + bt_conn *pbVar1; + u8_t uVar2; + int bit; + bt_keys *pbVar3; + int iVar4; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + u8_t *remote_pk; + bt_conn_oob_info abStack20 [2]; + bt_conn_oob_info info; + + __src = *(void **)&buf->field_4; + remote_pk = smp->pkey; + memcpy(remote_pk,__src,0x20); + memcpy(smp->pkey + 0x20,(void *)((int)__src + 0x20),0x20); + bit = memcmp(remote_pk,sc_debug_public_key,0x40); + if (bit == 0) { + atomic_set_bit(smp->flags,0xd); + pbVar1 = (smp->chan).chan.conn; + if (*(int *)(pbVar1->field_20 + 0x2c) == 0) { + pbVar3 = bt_keys_get_addr(pbVar1->id,(bt_addr_le_t *)pbVar1->field_20); + *(bt_keys **)(pbVar1->field_20 + 0x2c) = pbVar3; + } + bit = *(int *)(pbVar1->field_20 + 0x2c); + if (((bit != 0) && ((*(ushort *)(bit + 10) & 0x24) != 0)) && ((*(byte *)(bit + 9) & 2) != 0)) { + return '\x03'; + } + } + if (((smp->chan).chan.conn)->role != '\0') { + if (sc_public_key != (u8_t *)0x0) { + uVar2 = sc_send_public_key(smp); + if (CONCAT31(extraout_var_01,uVar2) != 0) { + return uVar2; + } + uVar2 = smp_public_key_slave(smp); + return uVar2; + } + bit = 6; + goto LAB_2305485e; + } + switch(smp->method) { + case '\0': + case '\x03': + atomic_set_bit(&smp->allowed_cmds,3); + break; + case '\x01': + atomic_set_bit(smp->flags,9); + (*bt_auth->passkey_entry)((smp->chan).chan.conn); + break; + case '\x02': + uVar2 = display_passkey(smp); + if (CONCAT31(extraout_var,uVar2) != 0) { + return uVar2; + } + atomic_set_bit(&smp->allowed_cmds,3); + uVar2 = smp_send_pairing_confirm(smp); + if (CONCAT31(extraout_var_00,uVar2) != 0) { + return uVar2; + } + break; + default: + goto switchD_23054840_caseD_4; + case '\x05': + bit = bt_rand(smp->prnd,0x10); + if (bit == 0) { + if (bt_auth == (bt_conn_auth_cb *)0x0) { + return '\x02'; + } + if (bt_auth->oob_data_request == + (anon_subr_void_bt_conn_ptr_bt_conn_oob_info_ptr_for_oob_data_request *)0x0) { + return '\x02'; + } + abStack20[0] = (bt_conn_oob_info)0x301; + le_sc_oob_config_set_isra_3_constprop_19(smp,&abStack20[0].field_1); + smp->oobd_local = (bt_le_oob_sc_data *)0x0; + smp->oobd_remote = (bt_le_oob_sc_data *)0x0; + atomic_set_bit(smp->flags,0xb); + (*bt_auth->oob_data_request)((smp->chan).chan.conn,abStack20); + break; + } + goto switchD_23054840_caseD_4; + } + iVar4 = bt_dh_key_gen(remote_pk,bt_smp_dhkey_ready); + bit = 7; + if (iVar4 == 0) { +LAB_2305485e: + atomic_set_bit(smp->flags,bit); + uVar2 = '\0'; + } + else { +switchD_23054840_caseD_4: + uVar2 = '\b'; + } + return uVar2; +} + + + +void bt_smp_pkey_ready(u8_t *pkey) + +{ + u8_t reason; + int iVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + + sc_public_key = pkey; + if (pkey == (u8_t *)0x0) { + printf("Public key not available\r\n"); + return; + } + k_sem_give(&sc_local_pkey_ready); + iVar1 = atomic_test_bit(bt_smp_pool[0].flags,6); + if (iVar1 != 0) { + if ((bt_smp_pool[0].chan.chan.conn)->role == '\0') { + reason = sc_send_public_key(bt_smp_pool); + if (CONCAT31(extraout_var_02,reason) != 0) { + smp_error(bt_smp_pool,reason); + } + atomic_set_bit(&bt_smp_pool[0].allowed_cmds,0xc); + } + else { + reason = sc_send_public_key(bt_smp_pool); + if ((CONCAT31(extraout_var,reason) != 0) || + (reason = smp_public_key_slave(bt_smp_pool), CONCAT31(extraout_var_01,reason) != 0)) { + smp_error(bt_smp_pool,reason); + } + } + } + iVar1 = atomic_test_bit(bt_smp_pool[1].flags,6); + if (iVar1 != 0) { + if ((bt_smp_pool[1].chan.chan.conn)->role == '\0') { + reason = sc_send_public_key(bt_smp_pool + 1); + if (CONCAT31(extraout_var_00,reason) != 0) { + smp_error(bt_smp_pool + 1,reason); + } + atomic_set_bit(&bt_smp_pool[1].allowed_cmds,0xc); + return; + } + reason = sc_send_public_key(bt_smp_pool + 1); + if ((CONCAT31(extraout_var_03,reason) != 0) || + (reason = smp_public_key_slave(bt_smp_pool + 1), CONCAT31(extraout_var_04,reason) != 0)) { + smp_error(bt_smp_pool + 1,reason); + return; + } + } + return; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +u8_t smp_pairing_random(bt_smp *smp,net_buf *buf) + +{ + u8_t uVar1; + int bit; + undefined3 extraout_var; + int iVar2; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + uint len; + u8_t uVar3; + atomic_t *target; + u8_t *x; + bt_conn *conn; + u8_t *k; + u8_t auStack60 [4]; + u8_t ediv [2]; + u8_t rand [8]; + u32_t_conflict passkey; + undefined auStack40 [8]; + + x = smp->rrnd; + memcpy(x,*(void **)&buf->field_4,0x10); + target = smp->flags; + bit = atomic_test_bit(target,5); + conn = (smp->chan).chan.conn; + if (bit == 0) { + k = smp->tk; + bit = smp_c1(k,x,smp->preq,smp->prsp,(bt_addr_le_t *)(conn->field_20 + 7), + (bt_addr_le_t *)(conn->field_20 + 0xe),rand + 4); + if (bit != 0) { + return '\b'; + } + bit = memcmp(smp->pcnf,rand + 4,0x10); + if (bit != 0) { + return '\x04'; + } + uVar1 = conn->role; + if (uVar1 != '\0') { + memcpy(rand + 4,x,8); + memcpy(auStack40,smp->prnd,8); + bit = bt_encrypt_le(k,rand + 4,rand + 4); + if (bit != 0) { + return '\b'; + } + memcpy(k,rand + 4,0x10); + bit = 1; +LAB_23054b28: + atomic_set_bit(target,bit); + uVar1 = smp_send_pairing_random(smp); + return uVar1; + } + memcpy(rand + 4,smp->prnd,8); + memcpy(auStack40,x,8); + bit = bt_encrypt_le(k,rand + 4,rand + 4); + if (bit != 0) { + return '\b'; + } + memset(auStack60,0,2); + memset(ediv,0,8); + len = (uint)smp->prsp[4]; + if ((uint)smp->preq[4] < (uint)smp->prsp[4]) { + len = (uint)smp->preq[4]; + } + bit = bt_conn_le_start_encryption(conn,ediv,auStack60,rand + 4,len); + if (bit != 0) { + printf("Failed to start encryption\r\n"); + return '\b'; + } + bit = 1; +LAB_23054af6: + atomic_set_bit(target,bit); + return uVar1; + } + if (conn->role == '\0') { + uVar1 = sc_smp_check_confirm(smp); + if (CONCAT31(extraout_var,uVar1) != 0) { + return uVar1; + } + switch(smp->method) { + case '\x01': + case '\x02': + uVar3 = smp->passkey_round + '\x01'; + smp->passkey_round = uVar3; + if (uVar3 != '\x14') { + bit = bt_rand(smp->prnd,0x10); + if (bit != 0) { + return '\b'; + } + atomic_set_bit(&smp->allowed_cmds,3); + uVar1 = smp_send_pairing_confirm(smp); + return uVar1; + } + case '\0': + case '\x05': + iVar2 = atomic_test_bit(target,7); + bit = 8; + if (iVar2 == 0) { + uVar1 = compute_and_send_master_dhcheck(smp); + return uVar1; + } + goto LAB_23054af6; + case '\x03': + bit = smp_g2(sc_public_key,smp->pkey,smp->prnd,x,(u32_t_conflict *)(rand + 4)); + if (bit == 0) { + atomic_set_bit(target,9); + atomic_set_bit(target,8); + (*bt_auth->passkey_confirm)((smp->chan).chan.conn,rand._4_4_); + return uVar1; + } + } + } + else { + switch(smp->method) { + case '\x01': + case '\x02': + uVar1 = sc_smp_check_confirm(smp); + if (CONCAT31(extraout_var_00,uVar1) != 0) { + return uVar1; + } + atomic_set_bit(&smp->allowed_cmds,3); + uVar1 = smp_send_pairing_random(smp); + if (CONCAT31(extraout_var_01,uVar1) != 0) { + return uVar1; + } + uVar3 = smp->passkey_round + '\x01'; + smp->passkey_round = uVar3; + if (uVar3 != '\x14') { + bit = bt_rand(smp->prnd,0x10); + if (bit != 0) { + return '\b'; + } + return uVar1; + } + atomic_set_bit(&smp->allowed_cmds,0xd); + bit = 0xf; + goto LAB_23054af6; + case '\x03': + bit = smp_g2(smp->pkey,sc_public_key,x,smp->prnd,(u32_t_conflict *)(rand + 4)); + if (bit != 0) { + return '\b'; + } + atomic_set_bit(target,9); + (*bt_auth->passkey_confirm)((smp->chan).chan.conn,rand._4_4_); + case '\0': + atomic_set_bit(&smp->allowed_cmds,0xd); + bit = 0xf; + goto LAB_23054b28; + case '\x05': + bit = bt_rand(smp->prnd,0x10); + if (bit == 0) { + if (bt_auth == (bt_conn_auth_cb *)0x0) { + return '\x02'; + } + if (bt_auth->oob_data_request == + (anon_subr_void_bt_conn_ptr_bt_conn_oob_info_ptr_for_oob_data_request *)0x0) { + return '\x02'; + } + rand._4_4_ = CONCAT22(rand._6_2_,0x301); + le_sc_oob_config_set_isra_3_constprop_19(smp,rand + 5); + smp->oobd_local = (bt_le_oob_sc_data *)0x0; + smp->oobd_remote = (bt_le_oob_sc_data *)0x0; + atomic_set_bit(target,0xb); + (*bt_auth->oob_data_request)((smp->chan).chan.conn,(bt_conn_oob_info *)(rand + 4)); + return '\0'; + } + } + } + return '\b'; +} + + + +// WARNING: Type propagation algorithm not settling + +_Bool bt_smp_request_ltk(bt_conn *conn,u16_t ediv,u8_t *ltk) + +{ + byte bVar1; + uint __n; + bt_smp *smp; + int iVar2; + bt_keys *pbVar3; + undefined2 in_register_0000202e; + short in_a3; + void *in_a4; + short sStack42; + uint uStack40; + u8_t *puStack36; + + uStack40 = CONCAT22(in_register_0000202e,ediv); + sStack42 = in_a3; + puStack36 = ltk; + smp = smp_chan_get(conn); + if (smp == (bt_smp *)0x0) { + return false; + } + if ((sStack42 == 0) && ((uStack40 | (uint)puStack36) == 0)) { + iVar2 = atomic_test_bit(smp->flags,3); + if ((iVar2 != 0) && (iVar2 = atomic_test_bit(smp->flags,1), iVar2 != 0)) { + __n = (uint)smp->prsp[4]; + if ((uint)smp->preq[4] < (uint)smp->prsp[4]) { + __n = (uint)smp->preq[4]; + } + memcpy(in_a4,smp->tk,__n); + if (__n < 0x10) { + memset((void *)((int)in_a4 + __n),0,0x10 - __n); + } + goto LAB_23054d6e; + } + } + if (*(int *)(conn->field_20 + 0x2c) == 0) { + pbVar3 = bt_keys_find(0x20,conn->id,(bt_addr_le_t *)conn->field_20); + *(bt_keys **)(conn->field_20 + 0x2c) = pbVar3; + if (pbVar3 == (bt_keys *)0x0) { + pbVar3 = bt_keys_find(1,conn->id,(bt_addr_le_t *)conn->field_20); + *(bt_keys **)(conn->field_20 + 0x2c) = pbVar3; + } + } + iVar2 = *(int *)(conn->field_20 + 0x2c); + if ((sStack42 == 0) && ((uStack40 | (uint)puStack36) == 0)) { + if (iVar2 == 0) goto LAB_23054e54; + if ((*(ushort *)(iVar2 + 10) & 0x20) != 0) { + bVar1 = *(byte *)(iVar2 + 8); + __n = (uint)bVar1; + memcpy(in_a4,(void *)(iVar2 + 0x16),__n); + if (bVar1 < 0x10) { + memset((void *)((int)in_a4 + __n),0,0x10 - __n); + return true; + } + return true; + } + } + else { + if (iVar2 == 0) goto LAB_23054e54; + } + if ((((*(ushort *)(iVar2 + 10) & 1) != 0) && + (iVar2 = memcmp((void *)(iVar2 + 100),&uStack40,8), iVar2 == 0)) && + (iVar2 = memcmp((void *)(*(int *)(conn->field_20 + 0x2c) + 0x6c),&sStack42,2), iVar2 == 0)) { + bVar1 = *(byte *)(*(int *)(conn->field_20 + 0x2c) + 8); + __n = (uint)bVar1; + memcpy(in_a4,(void *)(*(int *)(conn->field_20 + 0x2c) + 0x6e),__n); + if (bVar1 < 0x10) { + memset((void *)((int)in_a4 + __n),0,0x10 - __n); + } +LAB_23054d6e: + atomic_set_bit(smp->flags,1); + return true; + } +LAB_23054e54: + iVar2 = atomic_test_bit(smp->flags,0xe); + if (iVar2 != 0) { + bt_conn_security_changed((smp->chan).chan.conn,2); + } + smp_reset(smp); + return false; +} + + + +// WARNING: Variable defined which should be unmapped: sig + +int bt_smp_sign_verify(bt_conn *conn,net_buf *buf) + +{ + bt_keys *pbVar1; + char *pcVar2; + int iVar3; + bt_addr_le_t *addr; + u32_t_conflict local_20; + u32_t_conflict cnt; + u8_t sig [12]; + + memcpy(&cnt,(void *)(*(int *)&buf->field_4 + ((uint)*(ushort *)((int)&buf->field_4 + 4) - 0xc)), + 0xc); + addr = (bt_addr_le_t *)conn->field_20; + pbVar1 = bt_keys_find(0x10,conn->id,addr); + if (pbVar1 == (bt_keys *)0x0) { + pcVar2 = bt_addr_le_str_real(addr); + printf("Unable to find Remote CSRK for %s\r\n",pcVar2); + iVar3 = -2; + } + else { + local_20 = (pbVar1->remote_csrk).cnt; + memcpy((void *)(*(int *)&buf->field_4 + ((uint)*(ushort *)((int)&buf->field_4 + 4) - 0xc)), + &local_20,4); + iVar3 = smp_sign_buf((u8_t *)&pbVar1->remote_csrk,*(u8_t **)&buf->field_4, + (u16_t)(((uint)*(ushort *)((int)&buf->field_4 + 4) - 0xc) * 0x10000 >> 0x10 + )); + if (iVar3 == 0) { + iVar3 = memcmp(&cnt,(void *)(*(int *)&buf->field_4 + + ((uint)*(ushort *)((int)&buf->field_4 + 4) - 0xc)),0xc); + if (iVar3 == 0) { + (pbVar1->remote_csrk).cnt = (pbVar1->remote_csrk).cnt + 1; + } + else { + pcVar2 = bt_addr_le_str_real(addr); + printf("Unable to verify signature for %s\r\n",pcVar2); + iVar3 = -0x4d; + } + } + else { + pcVar2 = bt_addr_le_str_real(addr); + printf("Unable to create signature for %s\r\n",pcVar2); + iVar3 = -5; + } + } + return iVar3; +} + + + +// WARNING: Variable defined which should be unmapped: cnt + +int bt_smp_sign(bt_conn *conn,net_buf *buf) + +{ + bt_keys *pbVar1; + char *pcVar2; + int iVar3; + bt_addr_le_t *addr; + u32_t_conflict uStack20; + u32_t_conflict cnt; + + addr = (bt_addr_le_t *)conn->field_20; + pbVar1 = bt_keys_find(8,conn->id,addr); + if (pbVar1 == (bt_keys *)0x0) { + pcVar2 = bt_addr_le_str_real(addr); + printf("Unable to find local CSRK for %s\r\n",pcVar2); + iVar3 = -2; + } + else { + net_buf_simple_add((net_buf_simple *)&buf->field_4,0xc); + uStack20 = (pbVar1->local_csrk).cnt; + memcpy((void *)(*(int *)&buf->field_4 + ((uint)*(ushort *)((int)&buf->field_4 + 4) - 0xc)), + &uStack20,4); + iVar3 = smp_sign_buf((u8_t *)&pbVar1->local_csrk,*(u8_t **)&buf->field_4, + (u16_t)(((uint)*(ushort *)((int)&buf->field_4 + 4) - 0xc) * 0x10000 >> 0x10 + )); + if (iVar3 == 0) { + (pbVar1->local_csrk).cnt = (pbVar1->local_csrk).cnt + 1; + } + else { + pcVar2 = bt_addr_le_str_real(addr); + printf("Unable to create signature for %s\r\n",pcVar2); + iVar3 = -5; + } + } + return iVar3; +} + + + +// WARNING: Type propagation algorithm not settling + +int bt_smp_auth_passkey_entry(bt_conn *conn,uint passkey) + +{ + u8_t uVar1; + bt_smp *smp; + int bit; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + bt_conn *pbVar2; + atomic_t *target; + uint auStack36 [4]; + + smp = smp_chan_get(conn); + if (smp == (bt_smp *)0x0) { + return -0x16; + } + target = smp->flags; + bit = atomic_test_and_clear_bit(target,9); + if (bit == 0) { + return 0xffffffea; + } + bit = atomic_test_bit(target,5); + if (bit == 0) { + auStack36[0] = passkey; + memcpy(smp->tk,auStack36,4); + bit = atomic_test_and_clear_bit(target,0); + if (bit == 0) { + return 0; + } + uVar1 = legacy_pairing_confirm(smp); + if (CONCAT31(extraout_var,uVar1) == 0) { + bit = 3; + if (((smp->chan).chan.conn)->role != '\0') { + bit = 4; + } + atomic_set_bit(&smp->allowed_cmds,bit); + return 0; + } + smp_error(smp,'\x01'); + return 0; + } + pbVar2 = (smp->chan).chan.conn; + smp->passkey = passkey; + if (pbVar2->role == '\0') { + uVar1 = smp_send_pairing_confirm(smp); + if (CONCAT31(extraout_var_00,uVar1) == 0) { + bit = 3; +LAB_2305507e: + atomic_set_bit(&smp->allowed_cmds,bit); + return 0; + } + } + else { + bit = atomic_test_bit(target,0); + if (bit == 0) { + return 0; + } + uVar1 = smp_send_pairing_confirm(smp); + bit = 4; + if (CONCAT31(extraout_var_01,uVar1) == 0) goto LAB_2305507e; + } + smp_error(smp,'\x01'); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling + +int bt_smp_auth_passkey_confirm(bt_conn *conn) + +{ + atomic_t *target; + u8_t uVar1; + bt_smp *smp; + int iVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + + smp = smp_chan_get(conn); + if (smp != (bt_smp *)0x0) { + target = smp->flags; + iVar2 = atomic_test_and_clear_bit(target,9); + if (iVar2 != 0) { + iVar2 = atomic_test_bit(target,7); + if ((iVar2 != 0) || (iVar2 = atomic_test_bit(target,0xf), iVar2 != 0)) { + atomic_set_bit(target,8); + return 0; + } + iVar2 = atomic_test_bit(target,8); + if (iVar2 == 0) { + return 0; + } + if (((smp->chan).chan.conn)->role == '\0') { + uVar1 = compute_and_send_master_dhcheck(smp); + iVar2 = CONCAT31(extraout_var,uVar1); + } + else { + uVar1 = compute_and_check_and_send_slave_dhcheck(smp); + iVar2 = CONCAT31(extraout_var_00,uVar1); + } + if (iVar2 == 0) { + return 0; + } + smp_error(smp,(u8_t)iVar2); + return 0; + } + } + return -0x16; +} + + + +int bt_smp_auth_cancel(bt_conn *conn) + +{ + bt_smp *smp; + int iVar1; + u8_t reason; + + smp = smp_chan_get(conn); + if ((smp != (bt_smp *)0x0) && (iVar1 = atomic_test_and_clear_bit(smp->flags,9), iVar1 != 0)) { + switch(smp->method) { + case '\0': + reason = '\b'; + break; + case '\x01': + case '\x02': + reason = '\x01'; + break; + case '\x03': + reason = '\x04'; + break; + default: + return 0; + case '\x05': + reason = '\x02'; + } + iVar1 = smp_error(smp,reason); + return iVar1; + } + return -0x16; +} + + + +int bt_smp_auth_pairing_confirm(bt_conn *conn) + +{ + atomic_t *target; + u8_t uVar1; + bt_smp *smp; + int iVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + + smp = smp_chan_get(conn); + if (smp != (bt_smp *)0x0) { + target = smp->flags; + iVar2 = atomic_test_and_clear_bit(target,9); + if (iVar2 != 0) { + if (conn->role != '\0') { + iVar2 = atomic_test_bit(target,5); + if (iVar2 == 0) { + atomic_set_bit(&smp->allowed_cmds,3); + uVar1 = send_pairing_rsp(smp); + return CONCAT31(extraout_var_01,uVar1); + } + atomic_set_bit(&smp->allowed_cmds,0xc); + uVar1 = send_pairing_rsp(smp); + if (CONCAT31(extraout_var_02,uVar1) == 0) { + return 0; + } + return -5; + } + iVar2 = atomic_test_bit(target,5); + if (iVar2 == 0) { + atomic_set_bit(&smp->allowed_cmds,3); + uVar1 = legacy_send_pairing_confirm(smp); + return CONCAT31(extraout_var,uVar1); + } + if (sc_public_key != (u8_t *)0x0) { + atomic_set_bit(&smp->allowed_cmds,0xc); + uVar1 = sc_send_public_key(smp); + return CONCAT31(extraout_var_00,uVar1); + } + atomic_set_bit(target,6); + return 0; + } + } + return -0x16; +} + + + +int bt_smp_start_security(bt_conn *conn) + +{ + int iVar1; + _Bool _Var2; + u8_t uVar3; + undefined3 extraout_var; + atomic_t *target; + bt_smp *smp; + undefined3 extraout_var_00; + bt_keys *pbVar4; + undefined3 extraout_var_01; + net_buf *buf; + u8_t *puVar5; + + if (conn->role == '\0') { + smp = smp_chan_get(conn); + if (smp != (bt_smp *)0x0) { + iVar1 = atomic_test_bit(conn->flags,0xb); + if ((iVar1 != 0) || (_Var2 = smp_keys_check(conn), CONCAT31(extraout_var,_Var2) == 0)) { + iVar1 = smp_send_pairing_req(conn); + return iVar1; + } + target = smp->flags; + iVar1 = atomic_test_bit(target,3); + if ((iVar1 != 0) || (iVar1 = atomic_test_bit(target,1), iVar1 != 0)) { + return -0x10; + } + iVar1 = *(int *)(conn->field_20 + 0x2c); + iVar1 = bt_conn_le_start_encryption + (conn,(u8_t *)(iVar1 + 0xc),(u8_t *)(iVar1 + 0x14),(u8_t *)(iVar1 + 0x16), + (uint)*(byte *)(iVar1 + 8)); + if (iVar1 != 0) { + return iVar1; + } + atomic_set_bit(&smp->allowed_cmds,0xb); +LAB_230552d4: + atomic_set_bit(target,1); + return iVar1; + } +LAB_23055250: + iVar1 = -0x39; + } + else { + if (conn->role == '\x01') { + smp = smp_chan_get(conn); + if (smp == (bt_smp *)0x0) goto LAB_23055250; + target = smp->flags; + iVar1 = atomic_test_bit(target,4); + if (iVar1 != 0) { + return -5; + } + iVar1 = atomic_test_bit(target,3); + if (iVar1 != 0) { + return -0x10; + } + iVar1 = atomic_test_bit(target,1); + if (iVar1 != 0) { + return -0x10; + } + _Var2 = sec_level_reachable(); + if ((CONCAT31(extraout_var_00,_Var2) != 0) || + ((iVar1 = atomic_test_bit(conn->flags,0xb), iVar1 == 0 && + (_Var2 = smp_keys_check(conn), CONCAT31(extraout_var_01,_Var2) != 0)))) { + if (*(int *)(conn->field_20 + 0x2c) == 0) { + pbVar4 = bt_keys_get_addr(conn->id,(bt_addr_le_t *)conn->field_20); + *(bt_keys **)(conn->field_20 + 0x2c) = pbVar4; + if (pbVar4 == (bt_keys *)0x0) { + return -0xc; + } + } + iVar1 = smp_init(smp); + if ((iVar1 != 0) || (buf = smp_create_pdu(smp,'\v'), buf == (net_buf *)0x0)) { + return -0x37; + } + puVar5 = (u8_t *)net_buf_simple_add((net_buf_simple *)&buf->field_4,1); + uVar3 = get_auth((char)conn + '\n'); + *puVar5 = uVar3; + bt_l2cap_send_cb(conn,6,buf,(bt_conn_tx_cb_t *)0x0,(void *)0x0); + atomic_set_bit(target,0xe); + target = &smp->allowed_cmds; + goto LAB_230552d4; + } + } + iVar1 = -0x16; + } + return iVar1; +} + + + +void bt_smp_update_keys(bt_conn *conn) + +{ + bt_smp *smp; + int iVar1; + bt_keys *pbVar2; + char *pcVar3; + byte bVar4; + int iVar5; + atomic_t *target; + + smp = smp_chan_get(conn); + if (smp != (bt_smp *)0x0) { + target = smp->flags; + iVar1 = atomic_test_bit(target,3); + if (iVar1 != 0) { + if (*(bt_keys **)(conn->field_20 + 0x2c) != (bt_keys *)0x0) { + bt_keys_clear(*(bt_keys **)(conn->field_20 + 0x2c)); + } + pbVar2 = bt_keys_get_addr(conn->id,(bt_addr_le_t *)conn->field_20); + *(bt_keys **)(conn->field_20 + 0x2c) = pbVar2; + if (pbVar2 == (bt_keys *)0x0) { + pcVar3 = bt_addr_le_str_real((bt_addr_le_t *)conn->field_20); + printf("Unable to get keys for %s\r\n",pcVar3); + smp_error(smp,'\b'); + return; + } + iVar1 = atomic_test_bit(target,0xd); + if (iVar1 != 0) { + *(byte *)(*(int *)(conn->field_20 + 0x2c) + 9) = + *(byte *)(*(int *)(conn->field_20 + 0x2c) + 9) | 2; + } + bVar4 = *(byte *)(*(int *)(conn->field_20 + 0x2c) + 9); + if ((smp->method < 6) && ((1 << ((uint)smp->method & 0x1f) & 0x2eU) != 0)) { + bVar4 = bVar4 | 1; + } + else { + bVar4 = bVar4 & 0xfe; + } + *(byte *)(*(int *)(conn->field_20 + 0x2c) + 9) = bVar4; + bVar4 = smp->preq[4]; + if (smp->prsp[4] < smp->preq[4]) { + bVar4 = smp->prsp[4]; + } + *(byte *)(*(int *)(conn->field_20 + 0x2c) + 8) = bVar4; + iVar1 = atomic_test_bit(target,5); + iVar5 = *(int *)(conn->field_20 + 0x2c); + if (iVar1 == 0) { + *(byte *)(iVar5 + 9) = *(byte *)(iVar5 + 9) & 0xef; + } + else { + *(byte *)(iVar5 + 9) = *(byte *)(iVar5 + 9) | 0x10; + iVar1 = atomic_test_bit(target,0xc); + if (iVar1 != 0) { + bt_keys_add_type(*(bt_keys **)(conn->field_20 + 0x2c),0x20); + memcpy((void *)(*(int *)(conn->field_20 + 0x2c) + 0x16),smp->tk,0x10); + memset((void *)(*(int *)(conn->field_20 + 0x2c) + 0xc),0,8); + memset((void *)(*(int *)(conn->field_20 + 0x2c) + 0x14),0,2); + return; + } + } + } + } + return; +} + + + +int bt_smp_init(void) + +{ + bt_pub_key_cb pub_key_cb; + + k_sem_init(&sc_local_pkey_ready,0,1); + sc_supported = (_Bool)((bt_dev.supported_commands[34] & 6) == 6); + bt_pub_key_gen((bt_pub_key_cb *)&ram0x4200ec40); + return 0; +} + + + +bt_keys * bt_keys_find_addr(u8_t id,bt_addr_le_t *addr) + +{ + undefined3 in_register_00002029; + int iVar1; + + if (((uint)key_pool[0].id != CONCAT31(in_register_00002029,id)) || + (iVar1 = memcmp(&key_pool[0].addr,addr,7), iVar1 != 0)) { + if (((uint)key_pool[1].id != CONCAT31(in_register_00002029,id)) || + (iVar1 = memcmp(&key_pool[1].addr,addr,7), iVar1 != 0)) { + return (bt_keys *)0x0; + } + iVar1 = 1; + } + return key_pool + iVar1; +} + + + +bt_keys * bt_keys_find(int type,u8_t id,bt_addr_le_t *addr) + +{ + int iVar1; + undefined3 in_register_0000202d; + + if (((((uint)key_pool[0].keys & type) == 0) || + ((uint)key_pool[0].id != CONCAT31(in_register_0000202d,id))) || + (iVar1 = memcmp(&key_pool[0].addr,addr,7), iVar1 != 0)) { + if (((((uint)key_pool[1].keys & type) == 0) || + ((uint)key_pool[1].id != CONCAT31(in_register_0000202d,id))) || + (iVar1 = memcmp(&key_pool[1].addr,addr,7), iVar1 != 0)) { + return (bt_keys *)0x0; + } + iVar1 = 0x84; + } + else { + iVar1 = 0; + } + return (bt_keys *)(&key_pool[0].id + iVar1); +} + + + +bt_keys * bt_keys_get_addr(u8_t id,bt_addr_le_t *addr) + +{ + uint uVar1; + bt_keys *pbVar2; + undefined3 in_register_00002029; + int iVar3; + undefined4 local_30; + undefined2 uStack44; + undefined uStack42; + undefined4 uStack40; + undefined2 uStack36; + undefined uStack34; + + if (((uint)key_pool[0].id == CONCAT31(in_register_00002029,id)) && + (iVar3 = memcmp(&key_pool[0].addr,addr,7), iVar3 == 0)) { + iVar3 = 0; + } + else { + local_30 = 0; + uStack44 = 0; + uStack42 = 0; + iVar3 = memcmp(&key_pool[0].addr,&local_30,7); + uVar1 = 0; + if (iVar3 != 0) { + uVar1 = (uint)(key_pool[0].enc_size != '\0') << 1; + } + if (((uint)key_pool[1].id != CONCAT31(in_register_00002029,id)) || + (iVar3 = memcmp(&key_pool[1].addr,addr,7), iVar3 != 0)) { + if (uVar1 == 2) { + local_30 = 0; + uStack44 = 0; + uStack42 = 0; + iVar3 = memcmp(&key_pool[1].addr,&local_30,7); + if ((iVar3 == 0) || (key_pool[1].enc_size == '\0')) { + uVar1 = 1; + } + else { + pbVar2 = key_pool + 1; + if (key_pool[0].aging_counter <= key_pool[1].aging_counter) { + pbVar2 = key_pool; + } + bt_unpair(pbVar2->id,&pbVar2->addr); + uStack40 = 0; + uStack36 = 0; + uStack34 = 0; + iVar3 = memcmp(&pbVar2->addr,&uStack40,7); + if (iVar3 != 0) { + return (bt_keys *)0x0; + } + uVar1 = ((int)pbVar2[-0x8002c4].slave_ltk.ediv >> 2) * 0x3e0f83e1; + if (1 < uVar1) { + return (bt_keys *)0x0; + } + } + } + pbVar2 = key_pool + uVar1; + pbVar2->id = id; + memcpy(&key_pool[uVar1].addr,addr,7); + aging_counter_val = aging_counter_val + 1; + key_pool[uVar1].aging_counter = aging_counter_val; + last_keys_updated = pbVar2; + return pbVar2; + } + iVar3 = 0x84; + } + return (bt_keys *)(&key_pool[0].id + iVar3); +} + + + +void bt_keys_foreach(int type,anon_subr_void_bt_keys_ptr_void_ptr *func,void *data) + +{ + if (((uint)key_pool[0].keys & type) != 0) { + (*func)(key_pool,data); + } + if (((uint)key_pool[1].keys & type) != 0) { + // WARNING: Could not recover jumptable at 0x23055770. Too many branches + // WARNING: Treating indirect jump as call + (*func)((bt_keys *)0x42016d28,data); + return; + } + return; +} + + + +bt_keys * bt_keys_find(int type,u8_t id,bt_addr_le_t *addr) + +{ + int iVar1; + undefined3 in_register_0000202d; + + if (((((uint)key_pool[0].keys & type) == 0) || + ((uint)key_pool[0].id != CONCAT31(in_register_0000202d,id))) || + (iVar1 = memcmp(&key_pool[0].addr,addr,7), iVar1 != 0)) { + if (((((uint)key_pool[1].keys & type) == 0) || + ((uint)key_pool[1].id != CONCAT31(in_register_0000202d,id))) || + (iVar1 = memcmp(&key_pool[1].addr,addr,7), iVar1 != 0)) { + return (bt_keys *)0x0; + } + iVar1 = 0x84; + } + else { + iVar1 = 0; + } + return (bt_keys *)(&key_pool[0].id + iVar1); +} + + + +bt_keys * bt_keys_get_type(int type,u8_t id,bt_addr_le_t *addr) + +{ + bt_keys *pbVar1; + + pbVar1 = bt_keys_find(type,id,addr); + if ((pbVar1 == (bt_keys *)0x0) && (pbVar1 = bt_keys_get_addr(id,addr), pbVar1 != (bt_keys *)0x0)) + { + pbVar1->keys = (ushort)type | pbVar1->keys; + } + return pbVar1; +} + + + +bt_keys * bt_keys_find_irk(u8_t id,bt_addr_le_t *addr) + +{ + _Bool _Var1; + undefined3 in_register_00002029; + uint uVar2; + int iVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + + uVar2 = CONCAT31(in_register_00002029,id); + if ((addr->type != '\x01') || (((addr->a).val[5] & 0xc0) != 0x40)) { + return (bt_keys *)0x0; + } + if ((((key_pool[0].keys & 2) == 0) || ((uint)key_pool[0].id != uVar2)) || + (iVar3 = memcmp(&addr->a,&key_pool[0].irk.rpa,6), iVar3 != 0)) { + if ((((key_pool[1].keys & 2) == 0) || ((uint)key_pool[1].id != uVar2)) || + (iVar3 = memcmp(&addr->a,&key_pool[1].irk.rpa,6), iVar3 != 0)) { + if ((((key_pool[0].keys & 2) != 0) && ((uint)key_pool[0].id == uVar2)) && + (_Var1 = bt_rpa_irk_matches((u8_t *)&key_pool[0].irk,&addr->a), + CONCAT31(extraout_var,_Var1) != 0)) { + iVar3 = 0; +LAB_23055894: + memcpy(key_pool[0].irk.rpa.val + iVar3,&addr->a,6); + return (bt_keys *)(&key_pool[0].id + iVar3); + } + if (((key_pool[1].keys & 2) != 0) && ((uint)key_pool[1].id == uVar2)) { + _Var1 = bt_rpa_irk_matches((u8_t *)&key_pool[1].irk,&addr->a); + iVar3 = 0x84; + if (CONCAT31(extraout_var_00,_Var1) != 0) goto LAB_23055894; + } + return (bt_keys *)0x0; + } + iVar3 = 0x84; + } + else { + iVar3 = 0; + } + return (bt_keys *)(&key_pool[0].id + iVar3); +} + + + +bt_keys * bt_keys_find_addr(u8_t id,bt_addr_le_t *addr) + +{ + int iVar1; + undefined3 in_register_00002029; + + if (((uint)key_pool[0].id != CONCAT31(in_register_00002029,id)) || + (iVar1 = memcmp(&key_pool[0].addr,addr,7), iVar1 != 0)) { + if (((uint)key_pool[1].id != CONCAT31(in_register_00002029,id)) || + (iVar1 = memcmp(&key_pool[1].addr,addr,7), iVar1 != 0)) { + return (bt_keys *)0x0; + } + iVar1 = 1; + } + return key_pool + iVar1; +} + + + +void bt_keys_add_type(bt_keys *keys,int type) + +{ + keys->keys = (ushort)type | keys->keys; + return; +} + + + +void bt_keys_clear(bt_keys *keys) + +{ + if ((keys->keys & 2) != 0) { + bt_id_del(keys); + } + memset(keys,0,0x84); + return; +} + + + +void keys_clear_id(bt_keys *keys,void *data) + +{ + if (*(u8_t *)data == keys->id) { + bt_keys_clear(keys); + return; + } + return; +} + + + +void bt_keys_clear_all(u8_t id) + +{ + u8_t auStack17 [13]; + + auStack17[0] = id; + bt_keys_foreach(0x3f,keys_clear_id,auStack17); + return; +} + + + +void bt_keys_update_usage(u8_t id,bt_addr_le_t *addr) + +{ + bt_keys *pbVar1; + + pbVar1 = bt_keys_find_addr(id,addr); + if ((pbVar1 != (bt_keys *)0x0) && (last_keys_updated != pbVar1)) { + aging_counter_val = aging_counter_val + 1; + last_keys_updated = pbVar1; + pbVar1->aging_counter = aging_counter_val; + } + return; +} + + + +void bt_settings_encode_key(char *path,size_t path_size,char *subsys,bt_addr_le_t *addr,char *key) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + uint uVar4; + + uVar2 = (uint)(addr->a).val[4]; + uVar1 = (uint)(addr->a).val[5]; + uVar3 = (uint)(addr->a).val[3]; + uVar4 = (uint)(addr->a).val[2]; + if (key == (char *)0x0) { + snprintf(path,path_size,"bt/%s/%02x%02x%02x%02x%02x%02x%u",subsys,uVar1,uVar2,uVar3,uVar4); + } + else { + snprintf(path,path_size,"bt/%s/%02x%02x%02x%02x%02x%02x%u/%s",subsys,uVar1,uVar2,uVar3,uVar4); + } + return; +} + + + +u8_t notify_func(bt_conn *conn,bt_gatt_subscribe_params *params,void *data,u16_t length) + +{ + bool bVar1; + undefined2 in_register_00002036; + + bVar1 = params->value != 0; + if (bVar1) { + printf("Notification: data length %u\r\n",CONCAT22(in_register_00002036,length)); + } + else { + printf("Unsubscribed\r\n"); + params->value_handle = 0; + } + return (u8_t)bVar1; +} + + + +void le_param_updated(bt_conn *conn,u16_t interval,u16_t latency,u16_t timeout) + +{ + printf("LE conn param updated: int 0x%04x lat %d to %d \r\n"); + return; +} + + + +void ble_set_tx_pwr(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + byte abStack17 [4]; + u8_t power; + + if (argc == 2) { + get_uint8_from_string(argv + 1,abStack17); + if (0x14 < abStack17[0]) { + printf("ble_set_tx_pwr, invalid value, value shall be in [0x%x - 0x%x]\r\n",0,0x14); + return; + } + xWriteBufferLen = bt_set_tx_pwr(abStack17[0]); + if (xWriteBufferLen != 0) { + printf("ble_set_tx_pwr, Fail to set tx power (err %d)\r\n",xWriteBufferLen); + return; + } + fmt = "ble_set_tx_pwr, Set tx power successfully\r\n"; + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt,xWriteBufferLen); + return; +} + + + +void ble_unsubscribe(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + + if (default_conn == (bt_conn *)0x0) { + fmt = "Not connected\r\n"; + } + else { + xWriteBufferLen = 0x42017000; + if (subscribe_params.value_handle == 0) { + fmt = "No subscription found\r\n"; + } + else { + xWriteBufferLen = + bt_gatt_unsubscribe(default_conn,(bt_gatt_subscribe_params *)&subscribe_params); + if (xWriteBufferLen != 0) { + printf("Unsubscribe failed (err %d)\r\n",xWriteBufferLen); + return; + } + fmt = "Unsubscribe success\r\n"; + } + } + printf(fmt,xWriteBufferLen); + return; +} + + + +void write_func(bt_conn *conn,u8_t err,bt_gatt_write_params *params) + +{ + undefined3 in_register_0000202d; + + printf("Write complete: err %u \r\n",CONCAT31(in_register_0000202d,err)); + memset(&write_params,0,0x28); + return; +} + + + +void ble_exchange_mtu(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + + if (default_conn == (bt_conn *)0x0) { + fmt = "Not connected\r\n"; + } + else { + exchange_params.func = exchange_func; + xWriteBufferLen = bt_gatt_exchange_mtu(default_conn,&exchange_params); + if (xWriteBufferLen != 0) { + printf("Exchange failed (err %d)\r\n",xWriteBufferLen); + return; + } + fmt = "Exchange pending\r\n"; + } + printf(fmt,xWriteBufferLen); + return; +} + + + +void exchange_func(bt_conn *conn,u8_t err,bt_gatt_exchange_params *params) + +{ + u16_t uVar1; + undefined2 extraout_var; + undefined3 in_register_0000202d; + char *pcVar2; + + if (CONCAT31(in_register_0000202d,err) == 0) { + pcVar2 = "successful"; + } + else { + pcVar2 = "failed"; + } + uVar1 = bt_gatt_get_mtu(conn); + printf("Exchange %s MTU Size =%d \r\n",pcVar2,CONCAT22(extraout_var,uVar1)); + return; +} + + + +void ble_auth_pairing_confirm(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + if (default_conn == (bt_conn *)0x0) { + printf("Not connected\r\n"); + return; + } + bt_conn_auth_pairing_confirm(default_conn); + return; +} + + + +void ble_auth_passkey_confirm(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + if (default_conn == (bt_conn *)0x0) { + printf("Not connected\r\n"); + return; + } + bt_conn_auth_passkey_confirm(default_conn); + return; +} + + + +void ble_auth_cancel(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + if (default_conn == (bt_conn *)0x0) { + printf("Not connected\r\n"); + return; + } + bt_conn_auth_cancel(default_conn); + return; +} + + + +void ble_auth(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + int iVar1; + char *fmt; + + iVar1 = bt_conn_auth_cb_register(&auth_cb_display); + if (iVar1 == 0) { + fmt = "Register auth callback successfully\r\n"; + } + else { + fmt = "Auth callback has already been registered\r\n"; + } + printf(fmt); + return; +} + + + +void ble_security(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + uint8_t local_11 [4]; + u8_t sec_level; + + local_11[0] = '\x04'; + if (default_conn == (bt_conn *)0x0) { + fmt = "Please firstly choose the connection using ble_select_conn\r\n"; + } + else { + if (argc == 2) { + get_uint8_from_string(argv + 1,local_11); + } + xWriteBufferLen = bt_conn_set_security(default_conn,local_11[0]); + if (xWriteBufferLen != 0) { + printf("Failed to start security, (err %d) \r\n",xWriteBufferLen); + return; + } + fmt = "Start security successfully\r\n"; + } + printf(fmt,xWriteBufferLen); + return; +} + + + +void ble_select_conn(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + bt_conn *pbVar1; + uint8_t auStack32 [4]; + u8_t addr_val [6]; + bt_addr_le_t addr; + + if (argc == 3) { + get_uint8_from_string(argv + 1,addr_val + 4); + get_bytearray_from_string(argv + 2,auStack32,6); + reverse_bytearray(auStack32,addr_val + 5,6); + pbVar1 = bt_conn_lookup_addr_le('\0',(bt_addr_le_t *)(addr_val + 4)); + if (pbVar1 != (bt_conn *)0x0) { + if (default_conn == (bt_conn *)0x0) { + default_conn = pbVar1; + return; + } + bt_conn_unref(default_conn); + default_conn = pbVar1; + return; + } + fmt = "No matching connection found\r\n"; + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt); + return; +} + + + +void ble_disconnect(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + bt_conn *conn; + int iVar1; + uint8_t uStack33; + uint8_t auStack32 [3]; + s8_t type; + u8_t addr_val [6]; + bt_addr_le_t addr; + + uStack33 = -1; + if (argc == 3) { + get_uint8_from_string(argv + 1,&uStack33); + get_bytearray_from_string(argv + 2,auStack32,6); + reverse_bytearray(auStack32,addr_val + 5,6); + addr_val[4] = uStack33; + conn = bt_conn_lookup_addr_le('\0',(bt_addr_le_t *)(addr_val + 4)); + if (conn != (bt_conn *)0x0) { + iVar1 = bt_conn_disconnect(conn,'\x13'); + if (iVar1 == 0) { + fmt = "Disconnect successfully\r\n"; + } + else { + fmt = "Disconnection failed\r\n"; + } + printf(fmt); + bt_conn_unref(conn); + return; + } + fmt = "Not connected\r\n"; + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt); + return; +} + + + +// WARNING: Variable defined which should be unmapped: param + +void ble_connect(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + int iVar1; + int iVar2; + char *fmt; + bt_conn *pbVar3; + uint8_t uStack41; + byte local_28 [3]; + s8_t type; + u8_t addr_val [6]; + bt_addr_le_t addr; + bt_le_conn_param param; + + uStack41 = -1; + stack0xffffffe8 = DAT_4200ee94; + memset(local_28,0,6); + if (argc == 3) { + get_uint8_from_string(argv + 1,&uStack41); + addr_val[4] = uStack41; + get_bytearray_from_string(argv + 2,local_28,6); + iVar1 = 0; + do { + iVar2 = iVar1 + 1; + printf("addr[%d]:[0x%x]\r\n",iVar1,(uint)local_28[iVar1]); + iVar1 = iVar2; + } while (iVar2 != 6); + reverse_bytearray(local_28,addr_val + 5,6); + pbVar3 = bt_conn_create_le((bt_addr_le_t *)(addr_val + 4),(bt_le_conn_param *)(addr.a.val + 3)); + if (pbVar3 == (bt_conn *)0x0) { + fmt = "Connection failed\r\n"; + } + else { + fmt = "Connection pending\r\n"; + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt); + return; +} + + + +void ble_stop_advertise(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + int iVar1; + char *fmt; + + iVar1 = bt_le_adv_stop(); + if (iVar1 == 0) { + fmt = "Advertising stopped\r\n"; + } + else { + fmt = "Failed to stop advertising\r\n"; + } + printf(fmt); + return; +} + + + +void ble_get_device_name(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *pcVar1; + + pcVar1 = bt_get_name(); + if (pcVar1 != (char *)0x0) { + printf("device_name: %s\r\n",pcVar1); + return; + } + printf("Failed to read device name\r\n"); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void ble_start_advertise(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + u8_t *__s; + size_t sVar1; + int iVar2; + bt_data *sd; + u8_t auStack52 [4]; + u8_t auStack48 [4]; + u8_t auStack44 [2]; + byte local_2a; + byte local_29; + u8_t uStack40; + u8_t uStack39; + uint8_t adv_type; + uint8_t mode; + bt_le_adv_param param; + + if ((argc - 3U & 0xfffffffd) == 0) { + _adv_type = 0xa0; + param._0_2_ = 0xf0; + uStack40 = '\0'; + get_uint8_from_string(argv + 1,&local_2a); + printf("adv_type 0x%x\r\n",(uint)local_2a); + if (local_2a == 0) { + uStack39 = '\v'; + } + else { + if (local_2a == 1) { + uStack39 = '\b'; + } + else { + if (local_2a != 2) { + fmt = "Arg1 is invalid\r\n"; + goto LAB_23055e60; + } + uStack39 = '\0'; + } + } + get_uint8_from_string(argv + 2,&local_29); + printf("mode 0x%x\r\n",(uint)local_29); + if (local_29 < 3) { + if (local_29 == 0) { + auStack52[0] = '\x06'; + ad_discov[0].data = auStack52; + } + else { + if (local_29 == 1) { + auStack48[0] = '\x04'; + ad_discov[0].data = auStack48; + } + else { + auStack44[0] = '\x05'; + ad_discov[0].data = auStack44; + } + } + ad_discov[0]._0_2_ = 0x101; + __s = (u8_t *)bt_get_name(); + sVar1 = strlen((char *)__s); + ad_discov[1].type = '\t'; + ad_discov[1].data_len = (u8_t)sVar1; + ad_discov[1].data = __s; + if (argc == 5) { + get_uint16_from_string(argv + 3,(uint16_t *)&adv_type); + get_uint16_from_string(argv + 4,(uint16_t *)¶m); + printf("interval min 0x%x\r\n",(uint)_adv_type); + printf("interval max 0x%x\r\n",(uint)param._0_2_); + } + if (1 < local_2a) { + sd = (bt_data *)0x0; + } + else { + sd = ad_discov; + } + iVar2 = bt_le_adv_start((bt_le_adv_param *)&uStack40,ad_discov,2,sd,(uint)(1 >= local_2a)); + if (iVar2 != 0) { + printf("Failed to start advertising (err %d) \r\n",iVar2); + return; + } + fmt = "Advertising started\r\n"; + } + else { + fmt = "Arg2 is invalid\r\n"; + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } +LAB_23055e60: + printf(fmt); + return; +} + + + +void ble_set_adv_channel(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + int iVar1; + uint8_t auStack17 [4]; + u8_t channel; + + auStack17[0] = '\a'; + if (argc == 2) { + get_uint8_from_string(argv + 1,auStack17); + iVar1 = set_adv_channel_map(auStack17[0]); + if (iVar1 == 0) { + fmt = "Set adv channel success\r\n"; + } + else { + fmt = "Failed to Set adv channel\r\n"; + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt); + return; +} + + + +void ble_stop_scan(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + int iVar1; + + iVar1 = bt_le_scan_stop(); + if (iVar1 != 0) { + printf("Stopping scanning failed (err %d)\r\n",iVar1); + return; + } + printf("Scan successfully stopped \r\n"); + return; +} + + + +void ble_disable(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + int iVar1; + char *fmt; + + iVar1 = bt_disable(); + if (iVar1 == 0) { + fmt = "Disable bt successfully\r\n"; + } + else { + fmt = "Fail to disable bt, there is existed scan/adv/conn event \r\n"; + } + printf(fmt); + return; +} + + + +u8_t discover_func(bt_conn *conn,bt_gatt_attr *attr,bt_gatt_discover_params *params) + +{ + byte bVar1; + u8_t uVar2; + bt_uuid **ppbVar3; + char acStack56 [4]; + char str [37]; + + if (attr == (bt_gatt_attr *)0x0) { + printf("Discover complete\r\n"); + memset(params,0,0x2c); + uVar2 = '\0'; + } + else { + bVar1 = params->type; + if (bVar1 == 2) { + ppbVar3 = (bt_uuid **)attr->user_data; + bt_uuid_to_str(*ppbVar3,acStack56,0x25); + printf("Include %s found: handle %x, start %x, end %x\r\n",acStack56,(uint)attr->handle, + (uint)*(ushort *)(ppbVar3 + 1),(uint)*(ushort *)((int)ppbVar3 + 6)); + } + else { + if (bVar1 < 2) { + ppbVar3 = (bt_uuid **)attr->user_data; + bt_uuid_to_str(*ppbVar3,acStack56,0x25); + printf("Service %s found: start handle %x, end_handle %x\r\n",acStack56,(uint)attr->handle, + (uint)*(ushort *)(ppbVar3 + 1)); + } + else { + if (bVar1 == 3) { + ppbVar3 = (bt_uuid **)attr->user_data; + bt_uuid_to_str(*ppbVar3,acStack56,0x25); + printf("Characteristic %s found: attr->handle %x chrc->handle %x \r\n",acStack56, + (uint)attr->handle,(uint)*(ushort *)(ppbVar3 + 1)); + bVar1 = *(byte *)((int)ppbVar3 + 6); + printf("Properties: "); + if ((bVar1 & 1) != 0) { + printf("[bcast]\r\n"); + } + if ((bVar1 & 2) != 0) { + printf("[read]\r\n"); + } + if ((bVar1 & 8) != 0) { + printf("[write]\r\n"); + } + if ((bVar1 & 4) != 0) { + printf("[write w/w rsp]\r\n"); + } + if ((bVar1 & 0x10) != 0) { + printf("[notify]\r\n"); + } + if ((bVar1 & 0x20) != 0) { + printf("[indicate]"); + } + if ((bVar1 & 0x40) != 0) { + printf("[auth]\r\n"); + } + if (-1 < (char)bVar1) { + return '\x01'; + } + printf("[ext prop]\r\n"); + return '\x01'; + } + bt_uuid_to_str(attr->uuid,acStack56,0x25); + printf("Descriptor %s found: handle %x\r\n",acStack56,(uint)attr->handle); + } + } + uVar2 = '\x01'; + } + return uVar2; +} + + + +void ble_set_data_len(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + uint16_t uStack20; + uint16_t uStack18; + u16_t tx_octets; + u16_t tx_time; + + if (argc == 3) { + if (default_conn == (bt_conn *)0x0) { + fmt = "Not connected\r\n"; + } + else { + get_uint16_from_string(argv + 1,&uStack20); + get_uint16_from_string(argv + 2,&uStack18); + xWriteBufferLen = bt_le_set_data_len(default_conn,uStack20,uStack18); + if (xWriteBufferLen != 0) { + printf("ble_set_data_len, LE Set Data Length (err %d)\r\n",xWriteBufferLen); + return; + } + fmt = "ble_set_data_len, LE Set Data Length success\r\n"; + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt,xWriteBufferLen); + return; +} + + + +void ble_subscribe(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + + if (argc == 4) { + if (default_conn == (bt_conn *)0x0) { + fmt = "Not connected\r\n"; + } + else { + get_uint16_from_string(argv + 1,&subscribe_params.ccc_handle); + get_uint16_from_string(argv + 2,&subscribe_params.value_handle); + get_uint16_from_string(argv + 3,&subscribe_params.value); + subscribe_params.notify = notify_func; + xWriteBufferLen = + bt_gatt_subscribe(default_conn,(bt_gatt_subscribe_params *)&subscribe_params); + if (xWriteBufferLen != 0) { + printf("Subscribe failed (err %d)\r\n",xWriteBufferLen); + return; + } + fmt = "Subscribed\r\n"; + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt,xWriteBufferLen); + return; +} + + + +void ble_write(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + uint array_size; + + if (argc == 5) { + if (default_conn == (bt_conn *)0x0) { + fmt = "Not connected\r\n"; + } + else { + if (write_params.func == (bt_gatt_write_func_t *)0x0) { + get_uint16_from_string(argv + 1,&write_params.handle); + get_uint16_from_string(argv + 2,&write_params.offset); + get_uint16_from_string(argv + 3,&write_params.length); + array_size = (uint)write_params.length; + if (0x200 < write_params.length) { + array_size = 0x200; + } + get_bytearray_from_string(argv + 4,gatt_write_buf,array_size); + write_params.data = gatt_write_buf; + write_params.length = (u16_t)array_size; + write_params.func = write_func; + xWriteBufferLen = bt_gatt_write(default_conn,(bt_gatt_write_params *)&write_params); + if (xWriteBufferLen != 0) { + printf("Write failed (err %d)\r\n",xWriteBufferLen); + return; + } + fmt = "Write pending\r\n"; + } + else { + fmt = "Write ongoing\r\n"; + } + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt,xWriteBufferLen); + return; +} + + + +void ble_read(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + + if (argc == 3) { + if (default_conn == (bt_conn *)0x0) { + fmt = "Not connected\r\n"; + } + else { + get_uint16_from_string(argv + 1,(uint16_t *)&read_params.field_3); + get_uint16_from_string(argv + 2,(uint16_t *)((int)&read_params.field_3 + 2)); + read_params.func = read_func; + read_params.handle_count = 1; + xWriteBufferLen = bt_gatt_read(default_conn,(bt_gatt_read_params *)&read_params); + if (xWriteBufferLen != 0) { + printf("Read failed (err %d)\r\n",xWriteBufferLen); + return; + } + fmt = "Read pending\r\n"; + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt,xWriteBufferLen); + return; +} + + + +u8_t read_func(bt_conn *conn,u8_t err,bt_gatt_read_params *params,void *data,u16_t length) + +{ + int iVar1; + undefined3 in_register_0000202d; + undefined2 in_register_0000203a; + size_t __n; + byte *pbVar2; + undefined auStack56 [4]; + char str [22]; + + __n = CONCAT22(in_register_0000203a,length); + printf("Read complete: err %u length %u \r\n",CONCAT31(in_register_0000202d,err),__n); + memset(auStack56,0,0xf); + if ((__n - 1 & 0xffff) < 0x16) { + memcpy(auStack56,data,__n); + printf("device name : %s \r\n",auStack56); + iVar1 = 0; + while (iVar1 < (int)__n) { + pbVar2 = (byte *)((int)data + iVar1); + iVar1 = iVar1 + 1; + printf("buf=[0x%x]\r\n",(uint)*pbVar2); + } + } + if (data == (void *)0x0) { + memset(params,0,0x28); + } + return (u8_t)(data != (void *)0x0); +} + + + +_Bool data_cb(bt_data *data,void *user_data) + +{ + size_t __n; + + if ((uint)data->type - 8 < 2) { + __n = (size_t)data->data_len; + if (0x1d < data->data_len) { + __n = 0x1d; + } + memcpy(user_data,data->data,__n); + return false; + } + return true; +} + + + +void ble_discover(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + int iVar1; + bt_uuid_16 *pbVar2; + uint8_t auStack33 [4]; + u8_t disc_type; + + if (argc == 5) { + if (default_conn == (bt_conn *)0x0) { + fmt = "Not connected\r\n"; + } + else { + discover_params.func = discover_func; + discover_params.field_3._0_2_ = 1; + discover_params.end_handle = 0xffff; + get_uint8_from_string(argv + 1,auStack33); + if (auStack33[0] == '\0') { + discover_params.type = '\0'; + auStack33[0] = discover_params.type; + } + else { + if ((((auStack33[0] != '\x01') && (auStack33[0] != '\x02')) && (auStack33[0] != '\x03')) && + (auStack33[0] != '\x04')) { + fmt = "Invalid discovery type\r\n"; + goto LAB_230565a6; + } + } + discover_params.type = auStack33[0]; + get_uint16_from_string(argv + 2,&uuid.val); + pbVar2 = &uuid; + if (uuid.val == 0) { + pbVar2 = (bt_uuid_16 *)0x0; + } + discover_params.uuid = (bt_uuid *)pbVar2; + get_uint16_from_string(argv + 3,(uint16_t *)&discover_params.field_3); + get_uint16_from_string(argv + 4,&discover_params.end_handle); + iVar1 = bt_gatt_discover(default_conn,(bt_gatt_discover_params *)&discover_params); + if (iVar1 != 0) { + printf("Discover failed (err %d)\r\n",iVar1); + return; + } + fmt = "Discover pending\r\n"; + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } +LAB_230565a6: + printf(fmt); + return; +} + + + +void ble_auth_passkey(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + + if (argc == 2) { + if (default_conn == (bt_conn *)0x0) { + fmt = "Not connected\r\n"; + } + else { + xWriteBufferLen = atoi(argv[1]); + if ((uint)xWriteBufferLen < 1000000) { + bt_conn_auth_passkey_entry(default_conn,xWriteBufferLen); + return; + } + fmt = "Passkey should be between 0-999999\r\n"; + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt,xWriteBufferLen); + return; +} + + + +void ble_conn_update(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + undefined auStack24 [2]; + undefined auStack22 [2]; + bt_le_conn_param param; + + if (argc == 5) { + get_uint16_from_string(argv + 1,(uint16_t *)auStack24); + get_uint16_from_string(argv + 2,(uint16_t *)(auStack24 + 2)); + get_uint16_from_string(argv + 3,(uint16_t *)¶m); + get_uint16_from_string(argv + 4,¶m.interval_max); + xWriteBufferLen = bt_conn_le_param_update(default_conn,(bt_le_conn_param *)auStack24); + if (xWriteBufferLen != 0) { + printf("conn update failed (err %d)\r\n",xWriteBufferLen); + return; + } + fmt = "conn update initiated\r\n"; + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt,xWriteBufferLen); + return; +} + + + +void ble_unpair(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + int iVar1; + uint8_t auStack32 [4]; + u8_t addr_val [6]; + bt_addr_le_t addr; + + if (argc == 3) { + get_uint8_from_string(argv + 1,addr_val + 4); + get_bytearray_from_string(argv + 2,auStack32,6); + reverse_bytearray(auStack32,addr_val + 5,6); + iVar1 = bt_unpair('\0',(bt_addr_le_t *)(addr_val + 4)); + if (iVar1 == 0) { + fmt = "Unpair successfully\r\n"; + } + else { + fmt = "Failed to unpair\r\n"; + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt); + return; +} + + + +void ble_start_scan(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + uint8_t uStack24; + uint8_t uStack23; + uint16_t uStack22; + bt_le_scan_param scan_param; + + if (argc == 5) { + get_uint8_from_string(argv + 1,&uStack24); + get_uint8_from_string(argv + 2,&uStack23); + get_uint16_from_string(argv + 3,&uStack22); + get_uint16_from_string(argv + 4,(uint16_t *)&scan_param); + xWriteBufferLen = bt_le_scan_start(&uStack24,device_found); + if (xWriteBufferLen != 0) { + printf("Failed to start scan (err %d) \r\n",xWriteBufferLen); + return; + } + fmt = "Start scan successfully \r\n"; + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt,xWriteBufferLen); + return; +} + + + +void ble_set_device_name(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + size_t sVar1; + int iVar2; + char *fmt; + + sVar1 = strlen(argv[1]); + if ((sVar1 != 0) && (sVar1 = strlen(argv[1]), sVar1 < 0x1e)) { + iVar2 = bt_set_name(argv[1]); + if (iVar2 == 0) { + fmt = "Set the device name successfully\r\n"; + } + else { + fmt = "Failed to set device name\r\n"; + } + printf(fmt); + return; + } + sVar1 = strlen(argv[1]); + printf("Invaild lenth(%d)\r\n",sVar1); + return; +} + + + +void ble_init(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + + if (ble_inited == false) { + default_conn = (bt_conn *)0x0; + bt_conn_cb_register(&conn_callbacks); + ble_inited = true; + fmt = "Init successfully \r\n"; + } + else { + fmt = "Has initialized \r\n"; + } + printf(fmt); + return; +} + + + +// WARNING: Variable defined which should be unmapped: type + +int bt_addr_le_to_str(bt_addr_le_t *addr,char *str) + +{ + u8_t uVar1; + int iVar2; + char *__src; + char acStack28 [4]; + char type [10]; + + uVar1 = addr->type; + if (uVar1 == '\x01') { + __src = "random"; + } + else { + if (uVar1 == '\0') { + __src = "public"; + } + else { + if (uVar1 == '\x02') { + __src = "public-id"; + } + else { + if (uVar1 != '\x03') { + snprintf(acStack28,10,"0x%02x"); + goto LAB_23056932; + } + __src = "random-id"; + } + } + } + strcpy(acStack28,__src); +LAB_23056932: + iVar2 = snprintf(str,0x1e,"%02X:%02X:%02X:%02X:%02X:%02X (%s)",(uint)(addr->a).val[5], + (uint)(addr->a).val[4],(uint)(addr->a).val[3],(uint)(addr->a).val[2], + (uint)(addr->a).val[1]); + return iVar2; +} + + + +// WARNING: Variable defined which should be unmapped: name + +void device_found(bt_addr_le_t *addr,s8_t rssi,u8_t evtype,net_buf_simple *buf) + +{ + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + char acStack80 [4]; + char le_addr [30]; + char name [30]; + + memset(le_addr + 0x1c,0,0x1e); + bt_data_parse(buf,data_cb,le_addr + 0x1c); + bt_addr_le_to_str(addr,acStack80); + printf("[DEVICE]: %s, AD evt type %u, RSSI %i %s \r\n",acStack80, + CONCAT31(in_register_00002031,evtype),CONCAT31(in_register_0000202d,rssi),le_addr + 0x1c); + return; +} + + + +void ble_read_local_address(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + undefined auStack64 [4]; + bt_addr_le_t local_pub_addr; + bt_addr_le_t local_ram_addr; + char le_addr [30]; + + bt_get_local_public_address((bt_addr_le_t *)auStack64); + bt_addr_le_to_str((bt_addr_le_t *)auStack64,(char *)(local_ram_addr.a.val + 3)); + printf("Local public addr : %s\r\n",local_ram_addr.a.val + 3); + bt_get_local_ramdon_address((bt_addr_le_t *)(local_pub_addr.a.val + 3)); + bt_addr_le_to_str((bt_addr_le_t *)(local_pub_addr.a.val + 3),(char *)(local_ram_addr.a.val + 3)); + printf("Local random addr : %s\r\n",local_ram_addr.a.val + 3); + return; +} + + + +void connected(bt_conn *conn,u8_t err) + +{ + bt_addr_le_t *addr_00; + undefined3 in_register_0000202d; + char acStack48 [4]; + char addr [30]; + + addr_00 = bt_conn_get_dst(conn); + bt_addr_le_to_str(addr_00,acStack48); + if (CONCAT31(in_register_0000202d,err) == 0) { + printf("Connected: %s \r\n",acStack48); + if (default_conn == (bt_conn *)0x0) { + default_conn = conn; + } + } + else { + printf("Failed to connect to %s (%u) \r\n",acStack48); + } + return; +} + + + +void disconnected(bt_conn *conn,u8_t reason) + +{ + bt_addr_le_t *addr_00; + undefined3 in_register_0000202d; + char acStack48 [4]; + char addr [30]; + + addr_00 = bt_conn_get_dst(conn); + bt_addr_le_to_str(addr_00,acStack48); + printf("Disconnected: %s (reason %u) \r\n",acStack48,CONCAT31(in_register_0000202d,reason)); + if (default_conn == conn) { + default_conn = (bt_conn *)0x0; + } + return; +} + + + +void security_changed(bt_conn *conn,bt_security_t level,bt_security_err err) + +{ + bt_addr_le_t *addr_00; + undefined3 in_register_0000202d; + char acStack48 [4]; + char addr [30]; + + addr_00 = bt_conn_get_dst(conn); + bt_addr_le_to_str(addr_00,acStack48); + printf("Security changed: %s level %u \r\n",acStack48,CONCAT31(in_register_0000202d,level)); + return; +} + + + +void auth_passkey_display(bt_conn *conn,uint passkey) + +{ + bt_addr_le_t *addr_00; + char acStack48 [4]; + char addr [30]; + + addr_00 = bt_conn_get_dst(conn); + bt_addr_le_to_str(addr_00,acStack48); + printf("passkey_str is: %06u\r\n",passkey); + return; +} + + + +void auth_passkey_entry(bt_conn *conn) + +{ + bt_addr_le_t *addr_00; + char acStack48 [4]; + char addr [30]; + + addr_00 = bt_conn_get_dst(conn); + bt_addr_le_to_str(addr_00,acStack48); + printf("Enter passkey for %s\r\n",acStack48); + return; +} + + + +void auth_passkey_confirm(bt_conn *conn,uint passkey) + +{ + bt_addr_le_t *addr_00; + char acStack48 [4]; + char addr [30]; + + addr_00 = bt_conn_get_dst(conn); + bt_addr_le_to_str(addr_00,acStack48); + printf("Confirm passkey for %s: %06u\r\n",acStack48,passkey); + return; +} + + + +void auth_cancel(bt_conn *conn) + +{ + bt_addr_le_t *addr_00; + char acStack48 [4]; + char addr [30]; + + addr_00 = bt_conn_get_dst(conn); + bt_addr_le_to_str(addr_00,acStack48); + printf("Pairing cancelled: %s\r\n",acStack48); + return; +} + + + +void auth_pairing_confirm(bt_conn *conn) + +{ + bt_addr_le_t *addr_00; + char acStack48 [4]; + char addr [30]; + + addr_00 = bt_conn_get_dst(conn); + bt_addr_le_to_str(addr_00,acStack48); + printf("Confirm pairing for %s\r\n",acStack48); + return; +} + + + +void auth_pairing_complete(bt_conn *conn,_Bool bonded) + +{ + bt_addr_le_t *addr_00; + undefined3 in_register_0000202d; + char *pcVar1; + char acStack48 [4]; + char addr [30]; + + addr_00 = bt_conn_get_dst(conn); + bt_addr_le_to_str(addr_00,acStack48); + if (CONCAT31(in_register_0000202d,bonded) == 0) { + pcVar1 = "Paired"; + } + else { + pcVar1 = "Bonded"; + } + printf("%s with %s\r\n",pcVar1,acStack48); + return; +} + + + +void auth_pairing_failed(bt_conn *conn,bt_security_err reason) + +{ + bt_addr_le_t *addr_00; + char acStack48 [4]; + char addr [30]; + + addr_00 = bt_conn_get_dst(conn); + bt_addr_le_to_str(addr_00,acStack48); + printf("Pairing failed with %s\r\n",acStack48); + return; +} + + + +void identity_resolved(bt_conn *conn,bt_addr_le_t *rpa,bt_addr_le_t *identity) + +{ + char acStack80 [4]; + char addr_identity [30]; + char addr_rpa [30]; + + bt_addr_le_to_str(identity,acStack80); + bt_addr_le_to_str(rpa,addr_identity + 0x1c); + printf("Identity resolved %s -> %s \r\n",addr_identity + 0x1c,acStack80); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void ble_get_all_conn_info(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *pcVar1; + int iVar2; + int iVar3; + char acStack120 [4]; + char le_addr [30]; + bt_conn_info info [2]; + + iVar3 = bt_conn_get_remote_dev_info((bt_conn_info *)(le_addr + 0x1c)); + if (0 < iVar3) { + bt_addr_le_to_str(info[0].field_3._4_4_,acStack120); + printf("ble local device address: %s\r\n",acStack120); + } + printf("ble connected devices count: %d\r\n",iVar3); + iVar2 = 0; + pcVar1 = le_addr; + while (iVar2 < iVar3) { + bt_addr_le_to_str(*(bt_addr_le_t **)(pcVar1 + 0x2c),acStack120); + printf("[%d]: address %s\r\n",iVar2,acStack120); + iVar2 = iVar2 + 1; + pcVar1 = pcVar1 + 0x1c; + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: handle +// WARNING: Could not reconcile some variable overlaps + +void ble_write_without_rsp(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + int iVar1; + uint array_size; + _Bool _Stack21; + uint16_t uStack20; + _Bool sign; + u16_t uStack18; + u16_t handle; + u16_t len; + + if (argc == 5) { + if (default_conn != (bt_conn *)0x0) { + get_uint8_from_string(argv + 1,&_Stack21); + get_uint16_from_string(argv + 2,&uStack20); + get_uint16_from_string(argv + 3,(uint16_t *)&stack0xffffffee); + array_size = (uint)uStack18; + if (0x200 < uStack18) { + array_size = 0x200; + } + uStack18 = (u16_t)array_size; + get_bytearray_from_string(argv + 4,gatt_write_buf,array_size); + iVar1 = bt_gatt_write_without_response_cb + (default_conn,uStack20,gatt_write_buf,uStack18,_Stack21, + (bt_gatt_complete_func_t *)0x0,(void *)0x0); + printf("Write Complete (err %d)\r\n",iVar1); + return; + } + fmt = "Not connected\r\n"; + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt); + return; +} + + + +int ble_cli_register(void) + +{ + return 0; +} + + + +int ble_tp_recv(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset,u8_t flags) + +{ + return 0; +} + + + +void ble_tp_disconnected(bt_conn *conn,u8_t reason) + +{ + char "ble_tp_disconnected" [20]; + + printf("%s\n","ble_tp_disconnected"); + ble_tp_conn = (bt_conn *)0x0; + return; +} + + + +void ble_tp_connected(bt_conn *conn,u8_t err) + +{ + char "ble_tp_connected" [17]; + int iVar1; + + printf("%s\n","ble_tp_connected"); + ble_tp_conn = conn; + iVar1 = bt_le_set_data_len(conn,0xfb,0x848); + if (iVar1 == 0) { + printf("ble tp set data length success.\n"); + } + else { + printf("ble tp set data length failure, err: %d\n",iVar1); + } + exchg_mtu.func = ble_tp_tx_mtu_size; + iVar1 = bt_gatt_exchange_mtu(ble_tp_conn,&exchg_mtu); + if (iVar1 == 0) { + printf("ble tp exchange mtu size pending.\n",0); + return; + } + printf("ble tp exchange mtu size failure, err: %d\n",iVar1); + return; +} + + + +void ble_tp_ccc_cfg_changed(bt_gatt_attr *attr,u16_t value) + +{ + BaseType_t BVar1; + char *fmt; + undefined2 in_register_0000202e; + + if (CONCAT22(in_register_0000202e,value) == 1) { + BVar1 = xTaskCreate(ble_tp_notify_task,"bletp",0x100,(void *)0x0,0xf,&ble_tp_task_h); + if (BVar1 == 1) { + fmt = "Create throughput tx task success .\n"; + } + else { + fmt = "Create throughput tx taskfail .\n"; + } + printf(fmt); + return; + } + printf("Delete throughput tx task .\n"); + vTaskDelete(ble_tp_task_h); + return; +} + + + +void ble_tp_tx_mtu_size(bt_conn *conn,u8_t err,bt_gatt_exchange_params *params) + +{ + u16_t uVar1; + undefined2 extraout_var; + char *fmt; + undefined3 in_register_0000202d; + + _uVar1 = CONCAT31(in_register_0000202d,err); + if (_uVar1 == 0) { + uVar1 = bt_gatt_get_mtu(ble_tp_conn); + _uVar1 = CONCAT22(extraout_var,uVar1); + fmt = "ble tp echange mtu size success, mtu size: %d\n"; + tx_mtu_size = _uVar1; + } + else { + fmt = "ble tp echange mtu size failure, err: %d\n"; + } + printf(fmt,_uVar1); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void ble_tp_notify_task(void *pvParameters) + +{ + bt_conn *conn; + int iVar1; + undefined auStack300 [4]; + bt_gatt_notify_params_conflict3 params; + char data [244]; + + memset(data + 4,0,0xec); + params.user_data = (void *)0x4030201; + data._0_4_ = 0x8070605; + data[4] = '\t'; + do { + conn = ble_tp_conn; + iVar1 = tx_mtu_size + -3; + memset(auStack300,0,0x18); + params.uuid = (bt_uuid *)(attrs + 2); + params.data._0_2_ = (u16_t)((uint)(iVar1 * 0x10000) >> 0x10); + params.attr = (bt_gatt_attr *)¶ms.user_data; + bt_gatt_notify_cb(conn,(bt_gatt_notify_params_conflict2 *)auStack300); + } while( true ); +} + + + +void ble_tp_init(void) + +{ + bt_conn_cb_register(&ble_tp_conn_callbacks); + bt_gatt_service_register(&ble_tp_server); + return; +} + + + +// WARNING: Type propagation algorithm not settling + +_Bool polling_events(k_poll_event *events,int num_events,s32_t timeout,int *last_registered) + +{ + bool bVar1; + int iVar2; + uint uVar3; + k_poll_event *pkVar4; + int iVar5; + uint uVar6; + k_poll_event *pkVar7; + + iVar2 = 0; + bVar1 = true; + pkVar7 = events; + do { + if (num_events <= iVar2) { + return (_Bool)bVar1; + } + uVar3 = irq_lock(); + uVar6 = *(uint *)&pkVar7->field_0xc >> 8 & 0xf; + if (uVar6 == 2) { + uVar6 = k_sem_count_get((k_sem *)pkVar7->field_7); + if (uVar6 != 0) { + uVar6 = 3; + goto LAB_23057010; + } +LAB_23056fce: + if ((timeout != 0) && (bVar1)) { + uVar6 = *(uint *)&pkVar7->field_0xc >> 8 & 0xf; + if ((uVar6 == 2) || (uVar6 == 3)) { + iVar5 = pkVar7->field_7; + (pkVar7->_node).field_0 = iVar5 + 4; + pkVar4 = *(k_poll_event **)(iVar5 + 8); + *(k_poll_event **)&(pkVar7->_node).field_1 = pkVar4; + *(k_poll_event **)&pkVar4->_node = events + iVar2; + *(k_poll_event **)(iVar5 + 8) = events + iVar2; + } + else { + if (uVar6 == 1) { + iVar5 = pkVar7->field_7; + (pkVar7->_node).field_0 = iVar5; + pkVar4 = *(k_poll_event **)(iVar5 + 4); + *(k_poll_event **)&(pkVar7->_node).field_1 = pkVar4; + *(k_poll_event **)&pkVar4->_node = events + iVar2; + *(k_poll_event **)(iVar5 + 4) = events + iVar2; + } + } + pkVar7->poller = (_poller *)0x0; + *last_registered = *last_registered + 1; + } + } + else { + if (uVar6 == 3) { + iVar5 = k_queue_is_empty((k_queue *)pkVar7->field_7); + if (iVar5 == 0) { + uVar6 = 4; + goto LAB_23057010; + } + goto LAB_23056fce; + } + if ((uVar6 != 1) || (uVar6 = 2, *(int *)(pkVar7->field_7 + 8) == 0)) goto LAB_23056fce; +LAB_23057010: + pkVar7->poller = (_poller *)0x0; + bVar1 = false; + *(uint *)&pkVar7->field_0xc = + (*(uint *)&pkVar7->field_0xc >> 0xc & 0xf | uVar6) << 0xc | + *(uint *)&pkVar7->field_0xc & 0xffff0fff; + } + irq_unlock(uVar3); + iVar2 = iVar2 + 1; + pkVar7 = pkVar7 + 1; + } while( true ); +} + + + +void k_poll_event_init(k_poll_event *event,u32_t_conflict type,int mode,void *obj) + +{ + event->poller = (_poller *)0x0; + *(uint *)&event->field_0xc = + *(uint *)&event->field_0xc & 0xff | (type & 0xf) << 8 | (mode & 1U) << 0x10; + *(void **)&event->field_7 = obj; + return; +} + + + +int k_poll(k_poll_event *events,int num_events,s32_t timeout) + +{ + int iVar1; + _Bool _Var2; + undefined3 extraout_var; + uint uVar3; + uint uVar4; + int iVar5; + int iStack36; + int last_registered; + + iStack36 = -1; + _Var2 = polling_events(events,num_events,timeout,&iStack36); + if (CONCAT31(extraout_var,_Var2) != 0) { + k_sem_take(&g_poll_sem,timeout); + iStack36 = -1; + polling_events(events,num_events,timeout,&iStack36); + } + uVar3 = irq_lock(); + events = events + iStack36; + iVar1 = iStack36; + while (-1 < iVar1) { + events->poller = (_poller *)0x0; + uVar4 = *(uint *)&events->field_0xc >> 8 & 0xf; + if (((uVar4 == 2) || (uVar4 == 3)) || (uVar4 == 1)) { + iVar5 = (events->_node).field_0; + *(int *)(events->_node).field_1 = iVar5; + *(undefined4 *)(iVar5 + 4) = (events->_node).field_1; + } + irq_unlock(); + irq_lock(); + iVar1 = iVar1 + -1; + events = events + -1; + } + irq_unlock(uVar3); + return 0; +} + + + +int k_poll_signal_raise(k_poll_signal *signal,int result) + +{ + uint uVar1; + int iVar2; + k_poll_signal *pkVar3; + + uVar1 = irq_lock(); + signal->signaled = 1; + pkVar3 = (k_poll_signal *)(signal->poll_events).field_0; + signal->result = result; + if (signal != pkVar3) { + iVar2 = (pkVar3->poll_events).field_0; + *(int *)(pkVar3->poll_events).field_1 = iVar2; + *(undefined4 *)(iVar2 + 4) = (pkVar3->poll_events).field_1; + pkVar3->signaled = 0; + pkVar3->result = pkVar3->result | 0x2000; + k_sem_give(&g_poll_sem); + } + irq_unlock(uVar1); + return 0; +} + + + +_Bool bt_rpa_irk_matches(u8_t *irk,bt_addr_t *addr) + +{ + bool bVar1; + int iVar2; + undefined auStack36 [4]; + u8_t hash [3]; + undefined uStack29; + u8_t res [16]; + + memcpy(hash,addr->val + 3,3); + memset(&uStack29,0,0xd); + iVar2 = bt_encrypt_le(irk,hash,hash); + if (iVar2 == 0) { + memcpy(auStack36,hash,3); + iVar2 = memcmp(addr,auStack36,3); + bVar1 = iVar2 == 0; + } + else { + bVar1 = false; + } + return (_Bool)bVar1; +} + + + +u8_t u8_to_dec(char *buf,u8_t buflen,u8_t value) + +{ + undefined3 in_register_0000202d; + uint uVar1; + undefined3 in_register_00002031; + uint uVar2; + int iVar3; + uint uVar4; + u8_t uVar5; + + uVar2 = CONCAT31(in_register_00002031,value); + uVar1 = CONCAT31(in_register_0000202d,buflen); + iVar3 = 4; + uVar5 = '\0'; + uVar4 = 100; + while( true ) { + if (uVar1 == 0) { + return uVar5; + } + iVar3 = iVar3 + -1; + if (iVar3 == 0) break; + if (((uVar4 <= uVar2) || (uVar4 == 1)) || (uVar5 != '\0')) { + uVar5 = uVar5 + '\x01'; + *buf = (char)(uVar2 / uVar4) + '0'; + uVar1 = uVar1 - 1 & 0xff; + buf = buf + 1; + } + uVar2 = uVar2 % uVar4; + uVar4 = uVar4 / 10; + } + *buf = '\0'; + return uVar5; +} + + + +void add_round_key(uint8_t *s,uint *k) + +{ + *s = *(byte *)((int)k + 3) ^ *s; + s[1] = (byte)*(undefined2 *)((int)k + 2) ^ s[1]; + s[2] = (byte)(*k >> 8) ^ s[2]; + s[3] = (byte)*k ^ s[3]; + s[4] = *(byte *)((int)k + 7) ^ s[4]; + s[5] = (byte)*(undefined2 *)((int)k + 6) ^ s[5]; + s[6] = (byte)(k[1] >> 8) ^ s[6]; + s[7] = (byte)k[1] ^ s[7]; + s[8] = *(byte *)((int)k + 0xb) ^ s[8]; + s[9] = (byte)*(undefined2 *)((int)k + 10) ^ s[9]; + s[10] = (byte)(k[2] >> 8) ^ s[10]; + s[0xb] = (byte)k[2] ^ s[0xb]; + s[0xc] = *(byte *)((int)k + 0xf) ^ s[0xc]; + s[0xd] = (byte)*(undefined2 *)((int)k + 0xe) ^ s[0xd]; + s[0xe] = (byte)(k[3] >> 8) ^ s[0xe]; + s[0xf] = (byte)k[3] ^ s[0xf]; + return; +} + + + +void shift_rows(uint8_t *s) + +{ + uint8_t local_20; + uint8_t uStack31; + uint8_t uStack30; + uint8_t uStack29; + uint8_t t [16]; + + local_20 = *s; + t[11] = s[0xb]; + uStack31 = s[5]; + uStack30 = s[10]; + uStack29 = s[0xf]; + t[0] = s[4]; + t[1] = s[9]; + t[2] = s[0xe]; + t[3] = s[3]; + t[4] = s[8]; + t[5] = s[0xd]; + t[6] = s[2]; + t[7] = s[7]; + t[8] = s[0xc]; + t[9] = s[1]; + t[10] = s[6]; + _copy(s,0x10,&local_20,0x10); + return; +} + + + +void mult_row_column(uint8_t *out,uint8_t *in) + +{ + byte bVar1; + byte bVar2; + byte bVar3; + byte bVar4; + byte bVar5; + + bVar1 = _double_byte(*in); + bVar2 = _double_byte(in[1]); + *out = bVar1 ^ in[1] ^ in[2] ^ in[3] ^ bVar2; + bVar1 = *in; + bVar2 = _double_byte(in[1]); + bVar3 = _double_byte(in[2]); + out[1] = bVar2 ^ bVar1 ^ in[2] ^ in[3] ^ bVar3; + bVar1 = in[1]; + bVar2 = *in; + bVar3 = _double_byte(in[2]); + bVar4 = _double_byte(in[3]); + out[2] = bVar3 ^ bVar2 ^ bVar1 ^ in[3] ^ bVar4; + bVar4 = _double_byte(*in); + bVar1 = in[1]; + bVar2 = *in; + bVar3 = in[2]; + bVar5 = _double_byte(in[3]); + out[3] = bVar5 ^ bVar2 ^ bVar1 ^ bVar3 ^ bVar4; + return; +} + + + +int tc_aes128_set_encrypt_key(TCAesKeySched_t s,uint8_t *k) + +{ + int iVar1; + byte *pbVar2; + byte *pbVar3; + uint uVar4; + TCAesKeySched_t ptVar5; + uint uVar6; + uint uStack60; + uint rconst [11]; + + memcpy(&uStack60,&DAT_230bce48,0x2c); + iVar1 = 0; + if ((s != (TCAesKeySched_t)0x0) && (k != (uint8_t *)0x0)) { + pbVar2 = k; + ptVar5 = s; + do { + pbVar3 = pbVar2 + 4; + ptVar5->words[0] = + (uint)*pbVar2 << 0x18 | (uint)pbVar2[1] << 0x10 | (uint)pbVar2[3] | (uint)pbVar2[2] << 8; + pbVar2 = pbVar3; + ptVar5 = (TCAesKeySched_t)(ptVar5->words + 1); + } while (k + 0x10 != pbVar3); + uVar4 = 4; + do { + uVar6 = s->words[3]; + if ((uVar4 & 3) == 0) { + uVar6 = *(uint *)((int)&uStack60 + (uVar4 & 0xfffffffc)) ^ + ((uint)sbox[(uVar6 << 8) >> 0x10 & 0xff] << 0x10 | + (uint)sbox[(uVar6 << 8) >> 0x18] << 0x18 | (uint)sbox[uVar6 >> 0x18] | + (uint)sbox[uVar6 & 0xff] << 8); + } + uVar4 = uVar4 + 1; + s->words[4] = uVar6 ^ s->words[0]; + s = (TCAesKeySched_t)(s->words + 1); + } while (uVar4 != 0x2c); + iVar1 = 1; + } + return iVar1; +} + + + +int tc_aes_encrypt(uint8_t *out,uint8_t *in,TCAesKeySched_t s) + +{ + byte *pbVar1; + byte *pbVar2; + byte *out_00; + uint *k; + uint *puVar3; + byte local_40 [4]; + uint8_t state [16]; + uint8_t t [16]; + + if (((out != (uint8_t *)0x0) && (in != (uint8_t *)0x0)) && (s != (TCAesKeySched_t)0x0)) { + _copy(local_40,0x10,in,0x10); + add_round_key(local_40,(uint *)s); + out_00 = state + 0xc; + pbVar1 = local_40; + k = s->words + 4; + do { + do { + pbVar2 = pbVar1 + 1; + *pbVar1 = sbox[*pbVar1]; + pbVar1 = pbVar2; + } while (pbVar2 != out_00); + shift_rows(local_40); + mult_row_column(out_00,local_40); + mult_row_column(t,state); + mult_row_column(t + 4,state + 4); + mult_row_column(t + 8,state + 8); + _copy(local_40,0x10,out_00,0x10); + puVar3 = k + 4; + add_round_key(local_40,k); + pbVar2 = local_40; + pbVar1 = local_40; + k = puVar3; + } while (puVar3 != s->words + 0x28); + do { + pbVar1 = pbVar2 + 1; + *pbVar2 = sbox[*pbVar2]; + pbVar2 = pbVar1; + } while (out_00 != pbVar1); + shift_rows(local_40); + add_round_key(local_40,s->words + 0x28); + _copy(out,0x10,local_40,0x10); + _set(local_40,0,0x10); + return 1; + } + return 0; +} + + + +u8_t att_prepare_write_req(bt_att *att,net_buf *buf) + +{ + return '\x06'; +} + + + +att_type_t att_op_get_type(u8_t op) + +{ + att_type_t aVar1; + undefined3 in_register_00002029; + uint uVar2; + uint uVar3; + + uVar2 = CONCAT31(in_register_00002029,op); + if (uVar2 == 0xe) { +LAB_23057682: + aVar1 = ATT_REQUEST; + } + else { + if (uVar2 < 0xf) { + if (uVar2 == 7) { + return ATT_RESPONSE; + } + if (uVar2 < 8) { + if (uVar2 == 3) { + return ATT_RESPONSE; + } + if (3 < uVar2) { + if (uVar2 == 5) { + return ATT_RESPONSE; + } + goto LAB_23057682; + } + if (uVar2 == 1) { + return ATT_RESPONSE; + } + if (uVar2 == 2) { + return ATT_REQUEST; + } + } + else { + if (uVar2 == 10) { + return ATT_REQUEST; + } + if (10 < uVar2) { + if (uVar2 == 0xc) { + return ATT_REQUEST; + } + return ATT_RESPONSE; + } + if (uVar2 == 8) { + return ATT_REQUEST; + } + if (uVar2 == 9) { + return ATT_RESPONSE; + } + } + } + else { + if (uVar2 == 0x17) { + return ATT_RESPONSE; + } + if (uVar2 < 0x18) { + if (uVar2 == 0x11) { + return ATT_RESPONSE; + } + if (uVar2 < 0x12) { + if (uVar2 == 0xf) { + return ATT_RESPONSE; + } + if (uVar2 == 0x10) { + return ATT_REQUEST; + } + } + else { + if (uVar2 == 0x13) { + return ATT_RESPONSE; + } + if (uVar2 < 0x13) { + return ATT_REQUEST; + } + if (uVar2 == 0x16) { + return ATT_REQUEST; + } + } + } + else { + if (uVar2 == 0x1d) { + return ATT_INDICATION; + } + if (uVar2 < 0x1e) { + if (uVar2 == 0x19) { + return ATT_RESPONSE; + } + if (uVar2 < 0x19) { + return ATT_REQUEST; + } + uVar3 = 0x1b; + aVar1 = ATT_NOTIFICATION; + } + else { + if (uVar2 == 0x52) { + return ATT_COMMAND; + } + if (uVar2 == 0xd2) { + return ATT_COMMAND; + } + uVar3 = 0x1e; + aVar1 = ATT_CONFIRMATION; + } + if (uVar2 == uVar3) { + return aVar1; + } + } + } + aVar1 = ATT_UNKNOWN; + if ((op & 0x40) != 0) { + return ATT_COMMAND; + } + } + return aVar1; +} + + + +void att_req_destroy(bt_att_req_conflict28 *req) + +{ + if (req->buf != (net_buf *)0x0) { + net_buf_unref(req->buf); + } + if (req->destroy != (bt_att_destroy_t)0x0) { + (*req->destroy)(req); + } + memset(req,0,0x18); + return; +} + + + +u8_t att_notify(bt_att *att,net_buf *buf) + +{ + bt_conn *conn; + u16_t handle; + + conn = (att->chan).chan.conn; + handle = net_buf_simple_pull_le16((net_buf_simple *)&buf->field_4); + bt_gatt_notification(conn,handle,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4)); + return '\0'; +} + + + +void bt_gatt_foreach_attr + (u16_t start_handle,u16_t end_handle,bt_gatt_attr_func_t *func,void *user_data) + +{ + bt_gatt_foreach_attr_type(start_handle,end_handle,(bt_uuid *)0x0,(void *)0x0,0,func,user_data); + return; +} + + + +u8_t read_group_cb(bt_gatt_attr *attr,void *user_data) + +{ + byte bVar1; + ushort uVar2; + u16_t uVar3; + undefined uVar4; + u8_t uVar5; + int iVar6; + undefined *puVar7; + size_t len; + undefined uVar8; + bt_conn **ppbVar9; + bt_conn *pbVar10; + bt_uuid abStack40 [2]; + undefined2 uStack38; + bt_uuid abStack36 [2]; + undefined2 uStack34; + + ppbVar9 = *(bt_conn ***)user_data; + pbVar10 = *ppbVar9; + abStack40[0] = (bt_uuid)0x0; + uStack38 = 0x2800; + iVar6 = bt_uuid_cmp(attr->uuid,abStack40); + if (iVar6 != 0) { + abStack36[0] = (bt_uuid)0x0; + uStack34 = 0x2801; + iVar6 = bt_uuid_cmp(attr->uuid,abStack36); + if (iVar6 != 0) { + iVar6 = *(int *)((int)user_data + 0x10); + if (iVar6 == 0) { + return '\x01'; + } + uVar2 = attr->handle; + if (uVar2 <= *(ushort *)(iVar6 + 2)) { + return '\x01'; + } + *(undefined *)(iVar6 + 2) = (char)uVar2; + *(undefined *)(iVar6 + 3) = (char)(uVar2 >> 8); + return '\x01'; + } + } + iVar6 = bt_uuid_cmp(attr->uuid,*(bt_uuid **)((int)user_data + 4)); + if (iVar6 == 0) { + if ((**(byte **)((int)user_data + 0xc) == 0) || + ((int)(uint)**(byte **)((int)user_data + 0xc) <= + (int)((uint)*(ushort *)((int)ppbVar9 + 0x56) - + (uint)*(ushort *)(*(int *)((int)user_data + 8) + 0xc)))) { + puVar7 = (undefined *) + net_buf_simple_add((net_buf_simple *)(*(int *)((int)user_data + 8) + 8),4); + *(undefined **)((int)user_data + 0x10) = puVar7; + uVar3 = attr->handle; + uVar4 = (undefined)uVar3; + *puVar7 = uVar4; + uVar8 = (undefined)(uVar3 >> 8); + puVar7[1] = uVar8; + iVar6 = *(int *)((int)user_data + 0x10); + *(undefined *)(iVar6 + 3) = uVar8; + *(undefined *)(iVar6 + 2) = uVar4; + uVar2 = *(ushort *)(*(int *)((int)user_data + 8) + 0xc); + len = (*attr->read)(pbVar10,attr, + (void *)(*(int *)(*(int *)((int)user_data + 8) + 8) + (uint)uVar2), + *(short *)((int)ppbVar9 + 0x56) - uVar2,0); + if (-1 < (int)len) { + bVar1 = **(byte **)((int)user_data + 0xc); + if (bVar1 == 0) { + **(byte **)((int)user_data + 0xc) = (byte)(len + 4); + } + else { + if ((uint)bVar1 != len + 4) { + *(short *)(*(int *)((int)user_data + 8) + 0xc) = + *(short *)(*(int *)((int)user_data + 8) + 0xc) + -4; + goto LAB_23057838; + } + } + net_buf_simple_add((net_buf_simple *)(*(int *)((int)user_data + 8) + 8),len); + goto LAB_2305781c; + } + } +LAB_23057838: + uVar5 = '\0'; + } + else { + *(undefined4 *)((int)user_data + 0x10) = 0; +LAB_2305781c: + uVar5 = '\x01'; + } + return uVar5; +} + + + +u8_t read_type_cb(bt_gatt_attr *attr,void *user_data) + +{ + byte bVar1; + u16_t uVar2; + ushort uVar3; + bool bVar4; + char cVar5; + int iVar6; + undefined3 extraout_var; + undefined *puVar7; + size_t len; + bt_conn **ppbVar8; + bt_conn *conn; + + ppbVar8 = *(bt_conn ***)user_data; + conn = *ppbVar8; + bVar4 = true; + iVar6 = bt_uuid_cmp(attr->uuid,*(bt_uuid **)((int)user_data + 4)); + if (iVar6 == 0) { + bVar4 = (bool)bt_gatt_check_perm(conn,attr,'\x15'); + *(bool *)((int)user_data + 0x14) = bVar4; + if (CONCAT31(extraout_var,bVar4) == 0) { + puVar7 = (undefined *) + net_buf_simple_add((net_buf_simple *)(*(int *)((int)user_data + 8) + 8),2); + *(undefined **)((int)user_data + 0x10) = puVar7; + uVar2 = attr->handle; + *puVar7 = (char)uVar2; + puVar7[1] = (char)(uVar2 >> 8); + uVar3 = *(ushort *)(*(int *)((int)user_data + 8) + 0xc); + len = (*attr->read)(conn,attr, + (void *)(*(int *)(*(int *)((int)user_data + 8) + 8) + (uint)uVar3), + *(short *)((int)ppbVar8 + 0x56) - uVar3,0); + if ((int)len < 0) { + cVar5 = '\x0e'; + if (len + 0xff < 0xff) { + cVar5 = -(char)len; + } + *(char *)((int)user_data + 0x14) = cVar5; + } + else { + bVar1 = **(byte **)((int)user_data + 0xc); + if (bVar1 == 0) { + **(byte **)((int)user_data + 0xc) = (byte)(len + 2); + } + else { + if ((uint)bVar1 != len + 2) { + *(short *)(*(int *)((int)user_data + 8) + 0xc) = + *(short *)(*(int *)((int)user_data + 8) + 0xc) + -2; + return bVar4; + } + } + net_buf_simple_add((net_buf_simple *)(*(int *)((int)user_data + 8) + 8),len); + bVar4 = (int)(uint)**(byte **)((int)user_data + 0xc) < + (int)((uint)*(ushort *)((int)ppbVar8 + 0x56) - + (uint)*(ushort *)(*(int *)((int)user_data + 8) + 0xc)); + } + } + else { + bVar4 = (bool)**(char **)((int)user_data + 0xc); + if (bVar4 != false) { + *(undefined *)((int)user_data + 0x14) = 0; + bVar4 = false; + } + } + } + return (u8_t)bVar4; +} + + + +u8_t find_type_cb(bt_gatt_attr *attr,void *user_data) + +{ + byte data_len; + ushort uVar1; + u16_t uVar2; + undefined uVar3; + _Bool _Var4; + int iVar5; + uint uVar6; + undefined3 extraout_var; + char *fmt; + undefined3 extraout_var_00; + undefined *puVar7; + undefined uVar8; + bt_conn **ppbVar9; + bt_conn *pbVar10; + bt_uuid local_60 [2]; + undefined2 uStack94; + bt_uuid abStack92 [2]; + undefined2 uStack90; + u8_t auStack88 [4]; + u8_t uuid [16]; + bt_uuid_128 ref_uuid; + bt_uuid_128 recvd_uuid; + + ppbVar9 = *(bt_conn ***)user_data; + pbVar10 = *ppbVar9; + local_60[0] = (bt_uuid)0x0; + uStack94 = 0x2801; + iVar5 = bt_uuid_cmp(attr->uuid,local_60); + if (iVar5 == 0) goto skip; + abStack92[0] = (bt_uuid)0x0; + uStack90 = 0x2800; + iVar5 = bt_uuid_cmp(attr->uuid,abStack92); + if (iVar5 != 0) { + iVar5 = *(int *)((int)user_data + 8); + if (iVar5 == 0) { + return '\x01'; + } + uVar1 = attr->handle; + if (*(ushort *)(iVar5 + 2) < uVar1) { + *(undefined *)(iVar5 + 2) = (char)uVar1; + *(undefined *)(iVar5 + 3) = (char)(uVar1 >> 8); + return '\x01'; + } + return '\x01'; + } + if ((uint)*(ushort *)((int)ppbVar9 + 0x56) - (uint)*(ushort *)(*(int *)((int)user_data + 4) + 0xc) + < 4) { + return '\0'; + } + uVar6 = (*attr->read)(pbVar10,attr,auStack88,0x10,0); + if ((int)uVar6 < 0) goto skip; + data_len = *(byte *)((int)user_data + 0x10); + if ((uint)data_len == uVar6) { + iVar5 = memcmp(*(u8_t **)((int)user_data + 0xc),auStack88,(uint)data_len); +LAB_23057a9a: + if (iVar5 == 0) { + *(undefined *)((int)user_data + 0x11) = 0; + puVar7 = (undefined *) + net_buf_simple_add((net_buf_simple *)(*(int *)((int)user_data + 4) + 8),4); + *(undefined **)((int)user_data + 8) = puVar7; + uVar2 = attr->handle; + uVar3 = (undefined)uVar2; + *puVar7 = uVar3; + uVar8 = (undefined)(uVar2 >> 8); + puVar7[1] = uVar8; + iVar5 = *(int *)((int)user_data + 8); + *(undefined *)(iVar5 + 2) = uVar3; + *(undefined *)(iVar5 + 3) = uVar8; + return '\x01'; + } + } + else { + _Var4 = bt_uuid_create((bt_uuid *)(ref_uuid.val + 0xf),*(u8_t **)((int)user_data + 0xc),data_len + ); + if (CONCAT31(extraout_var,_Var4) == 0) { + uVar6 = (uint)*(byte *)((int)user_data + 0x10); + fmt = "Unable to create UUID: size %u\r\n"; + } + else { + _Var4 = bt_uuid_create((bt_uuid *)(uuid + 0xc),auStack88,(u8_t)uVar6); + if (CONCAT31(extraout_var_00,_Var4) != 0) { + iVar5 = bt_uuid_cmp((bt_uuid *)(ref_uuid.val + 0xf),(bt_uuid *)(uuid + 0xc)); + goto LAB_23057a9a; + } + fmt = "Unable to create UUID: size %d\r\n"; + } + printf(fmt,uVar6); + } +skip: + *(undefined4 *)((int)user_data + 8) = 0; + return '\x01'; +} + + + +u8_t find_info_cb(bt_gatt_attr *attr,void *user_data) + +{ + u16_t uVar1; + undefined2 uVar2; + bool bVar3; + char *pcVar4; + undefined *puVar5; + int iVar6; + int iVar7; + + iVar7 = *(int *)user_data; + if (*(int *)((int)user_data + 8) == 0) { + pcVar4 = (char *)net_buf_simple_add((net_buf_simple *)(*(int *)((int)user_data + 4) + 8),1); + *(char **)((int)user_data + 8) = pcVar4; + *pcVar4 = (attr->uuid->type != '\0') + '\x01'; + } + if (**(char **)((int)user_data + 8) == '\x01') { + if (attr->uuid->type != '\0') { + return '\0'; + } + puVar5 = (undefined *)net_buf_simple_add((net_buf_simple *)(*(int *)((int)user_data + 4) + 8),4) + ; + *(undefined **)((int)user_data + 0xc) = puVar5; + uVar1 = attr->handle; + *puVar5 = (char)uVar1; + puVar5[1] = (char)(uVar1 >> 8); + iVar6 = *(int *)((int)user_data + 0xc); + uVar2 = *(undefined2 *)(attr->uuid + 2); + *(undefined *)(iVar6 + 2) = (char)uVar2; + *(undefined *)(iVar6 + 3) = (char)((ushort)uVar2 >> 8); + bVar3 = (uint)*(ushort *)(iVar7 + 0x56) - (uint)*(ushort *)(*(int *)((int)user_data + 4) + 0xc) + < 5; + } + else { + if (**(char **)((int)user_data + 8) != '\x02') { + return '\0'; + } + if (attr->uuid->type != '\x02') { + return '\0'; + } + puVar5 = (undefined *) + net_buf_simple_add((net_buf_simple *)(*(int *)((int)user_data + 4) + 8),0x12); + *(undefined **)((int)user_data + 0xc) = puVar5; + uVar1 = attr->handle; + *puVar5 = (char)uVar1; + puVar5[1] = (char)(uVar1 >> 8); + memcpy((void *)(*(int *)((int)user_data + 0xc) + 2),attr->uuid + 1,0x10); + bVar3 = (uint)*(ushort *)(iVar7 + 0x56) - (uint)*(ushort *)(*(int *)((int)user_data + 4) + 0xc) + < 0x13; + } + return (u8_t)(bVar3 ^ 1); +} + + + +void bt_att_connected(bt_l2cap_chan *chan) + +{ + k_queue_init((k_queue *)chan[3].rtx_work.work.flags,0x14); + *(undefined2 *)((int)&chan[1].rtx_work.work.handler + 2) = 0x17; + *(undefined2 *)((int)&chan[1].conn + 2) = 0x17; + k_delayed_work_init((k_delayed_work *)&chan[2].rtx_work.timer.args,att_timeout); + chan[2].rtx_work.timer.timer.hdl = (void *)0x0; + chan[2].rtx_work.timer.handler = (k_timer_handler_t *)0x0; + return; +} + + + +bt_conn_tx_cb_t * att_cb(void) + +{ + att_type_t aVar1; + u8_t *in_a0; + uint uVar2; + code *pcVar3; + + aVar1 = att_op_get_type(*in_a0); + uVar2 = (uint)aVar1 - 1 & 0xff; + if (uVar2 < 5) { + pcVar3 = *(code **)(&CSWTCH_31 + uVar2 * 4); + } + else { + pcVar3 = att_pdu_sent; + } + return pcVar3; +} + + + +int att_send(bt_conn *conn,net_buf *buf,bt_conn_tx_cb_t *cb,void *user_data) + +{ + int iVar1; + + if (**(char **)&buf->field_4 == -0x2e) { + iVar1 = bt_smp_sign(conn,buf); + if (iVar1 != 0) { + printf("Error signing data\r\n"); + net_buf_unref(buf); + return iVar1; + } + } + if (cb == (bt_conn_tx_cb_t *)0x0) { + cb = att_cb(); + } + iVar1 = bt_l2cap_send_cb(conn,4,buf,cb,user_data); + return iVar1; +} + + + +int att_send_req(bt_att *att,bt_att_req_conflict28 *req) + +{ + bt_conn *conn; + int iVar1; + size_t sVar2; + net_buf *buf; + bt_conn_tx_cb_t *cb; + net_buf *buf_00; + + att->req = req; + iVar1 = k_sem_take(&att->tx_sem,0); + buf_00 = req->buf; + if (iVar1 < 0) { + k_queue_append((k_queue *)&att->tx_queue,buf_00); + iVar1 = 0; + } + else { + sVar2 = net_buf_simple_headroom((net_buf_simple *)&buf_00->field_4); + (req->state).offset = (u16_t)sVar2; + buf = req->buf; + (req->state).len = *(u16_t *)((int)&buf_00->field_4 + 4); + conn = (att->chan).chan.conn; + buf_00 = net_buf_ref(buf); + cb = att_cb(); + iVar1 = bt_l2cap_send_cb(conn,4,buf_00,cb,(void *)0x0); + if (iVar1 != 0) { + net_buf_unref(req->buf); + req->buf = (net_buf *)0x0; + } + } + return iVar1; +} + + + +u8_t att_handle_rsp(bt_att *att,void *pdu,u16_t len,u8_t err) + +{ + bt_att_req_conflict28 *req; + sys_snode_t *psVar1; + bt_att_func_t *pbVar2; + + k_delayed_work_cancel((k_delayed_work *)&att->timeout_work); + req = att->req; + if (req == (bt_att_req_conflict28 *)0x0) { + printf("No pending ATT request\r\n"); + } + else { + if (req != &cancel) { + if (req->buf != (net_buf *)0x0) { + net_buf_unref(req->buf); + att->req->buf = (net_buf *)0x0; + } + pbVar2 = att->req->func; + att->req->func = (bt_att_func_t *)0x0; + (*pbVar2)((att->chan).chan.conn,err,pdu,len,att->req); + if (att->req->func == (bt_att_func_t *)0x0) { + att_req_destroy(att->req); + } + } + att->req = (bt_att_req_conflict28 *)0x0; + } + req = (bt_att_req_conflict28 *)(att->reqs).head; + if (req != (bt_att_req_conflict28 *)0x0) { + psVar1 = (sys_snode_t *)(req->node).next; + (att->reqs).head = psVar1; + if (req == (bt_att_req_conflict28 *)(att->reqs).tail) { + (att->reqs).tail = psVar1; + } + att_send_req(att,req); + } + return '\0'; +} + + + +u8_t att_handle_find_info_rsp(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_handle_find_type_rsp(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_handle_read_type_rsp(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_handle_read_rsp(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_handle_read_blob_rsp(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_handle_read_mult_rsp(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_handle_read_group_rsp(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_handle_write_rsp(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_handle_prepare_write_rsp(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_handle_exec_write_rsp(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_confirm(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_error_rsp(bt_att *att,net_buf *buf) + +{ + byte bVar1; + u8_t err; + bt_conn *conn; + bt_security_t sec; + int iVar2; + net_buf *pnVar3; + bt_att_req_conflict28 *pbVar4; + + pbVar4 = att->req; + if ((pbVar4 == (bt_att_req_conflict28 *)0x0) || (pbVar4 == &cancel)) { + err = '\x0e'; + goto done; + } + pnVar3 = pbVar4->buf; + iVar2 = *(int *)&buf->field_4; + if (pnVar3 != (net_buf *)0x0) { + *(uint *)&pnVar3->field_4 = *(int *)((int)&pnVar3->field_4 + 8) + (uint)(pbVar4->state).offset; + *(u16_t *)((int)&pnVar3->field_4 + 4) = (pbVar4->state).len; + } + err = *(u8_t *)(iVar2 + 3); + if (att->req->retrying != false) goto done; + conn = (att->chan).chan.conn; + if (err == '\x05') { + bVar1 = conn->sec_level; + if (bVar1 < 2) goto LAB_23057e4a; + if (bVar1 == 2) { + sec = BT_SECURITY_L3; + } + else { + sec = BT_SECURITY_L4; + if (bVar1 != 3) goto done; + } + } + else { + if ((err != '\x0f') || (1 < (byte)conn->sec_level)) goto done; +LAB_23057e4a: + sec = BT_SECURITY_MEDIUM; + } + iVar2 = bt_conn_set_security(conn,sec); + if (iVar2 == 0) { + att->req->retrying = true; + return '\0'; + } +done: + err = att_handle_rsp(att,(void *)0x0,0,err); + return err; +} + + + +int bt_att_accept(bt_conn *conn,bt_l2cap_chan **chan) + +{ + int iVar1; + bt_att *__s; + + if (bt_req_pool[0].chan.chan.conn == (bt_conn *)0x0) { + __s = bt_req_pool; + iVar1 = 0; + } + else { + if (bt_req_pool[1].chan.chan.conn != (bt_conn *)0x0) { + printf("No available ATT context for conn %p\r\n",conn); + return -0xc; + } + __s = bt_req_pool + 1; + iVar1 = 1; + } + memset(__s,0,0xe4); + bt_req_pool[iVar1].chan.chan.ops = (bt_l2cap_chan_ops *)0x4200e034; + k_sem_init(&bt_req_pool[iVar1].tx_sem,10,10); + *(bt_att **)chan = bt_req_pool + iVar1; + return 0; +} + + + +u8_t att_mtu_rsp(bt_att *att,net_buf *buf) + +{ + u8_t err; + ushort *pdu; + u16_t len; + ushort uVar1; + + if (att != (bt_att *)0x0) { + pdu = *(ushort **)&buf->field_4; + uVar1 = *pdu; + if (uVar1 < 0x17) { + err = '\x04'; + len = 0; + pdu = (ushort *)0x0; + } + else { + if (0xf7 < uVar1) { + uVar1 = 0xf7; + } + (att->chan).rx.mtu = uVar1; + (att->chan).tx.mtu = uVar1; + len = *(u16_t *)((int)&buf->field_4 + 4); + err = '\0'; + } + err = att_handle_rsp(att,pdu,len,err); + return err; + } + return '\0'; +} + + + +// WARNING: Type propagation algorithm not settling + +void att_reset(bt_att *att) + +{ + int iVar1; + net_buf *buf; + bt_att_req_conflict28 *req; + bt_att_req_conflict28 *pbVar2; + + while (buf = (net_buf *)k_queue_get((k_queue *)&att->tx_queue,0), buf != (net_buf *)0x0) { + net_buf_unref(buf); + } + atomic_or(att->flags,4); + iVar1 = 10; + do { + iVar1 = iVar1 + -1; + k_sem_give(&att->tx_sem); + } while (iVar1 != 0); + req = (bt_att_req_conflict28 *)(att->reqs).head; + if (req != (bt_att_req_conflict28 *)0x0) { + pbVar2 = *(bt_att_req_conflict28 **)&req->node; + while( true ) { + if (req->func != (bt_att_func_t *)0x0) { + (*req->func)((bt_conn *)0x0,'\x0e',(void *)0x0,0,req); + } + att_req_destroy(req); + if (pbVar2 == (bt_att_req_conflict28 *)0x0) break; + req = pbVar2; + pbVar2 = *(bt_att_req_conflict28 **)&pbVar2->node; + } + } + req = att->req; + (att->reqs).head = (sys_snode_t *)0x0; + (att->reqs).tail = (sys_snode_t *)0x0; + if (req == (bt_att_req_conflict28 *)0x0) { + return; + } + att_handle_rsp(att,(void *)0x0,0,'\x0e'); + return; +} + + + +void bt_att_disconnected(bt_l2cap_chan *chan) + +{ + att_reset((bt_att *)chan); + bt_gatt_disconnected(chan->conn); + if (*(int *)&chan[2].state != 0) { + k_delayed_work_del_timer((k_delayed_work *)&chan[2].rtx_work.timer.args); + } + if (chan[3].rtx_work.work.flags[0] != 0) { + k_queue_free((k_queue *)chan[3].rtx_work.work.flags); + chan[3].rtx_work.work.flags[0] = 0; + } + if (chan[3].destroy != (bt_l2cap_chan_destroy_t *)0x0) { + k_sem_delete((k_sem *)&chan[3].destroy); + return; + } + return; +} + + + +void att_timeout(k_work *work) + +{ + printf("ATT Timeout\r\n"); + att_reset((bt_att *)(work + -0xe)); + bt_gatt_disconnected((bt_conn *)work[-0xe]._reserved); + work[-0xe]._reserved = (void *)0x0; + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void bt_att_encrypt_change(bt_l2cap_chan *chan,u8_t hci_status) + +{ + bt_conn *conn; + atomic_val_t aVar1; + bt_conn_tx_cb_t *cb; + undefined3 in_register_0000202d; + net_buf *buf; + k_work_q *pkVar2; + + if (CONCAT31(in_register_0000202d,hci_status) != 0) { + att_handle_rsp((bt_att *)chan,(void *)0x0,0,'\x05'); + return; + } + conn = chan->conn; + bt_gatt_encrypt_change(conn); + if (((conn->sec_level != BT_SECURITY_LOW) && + (pkVar2 = chan[2].rtx_work.work_q, pkVar2 != (k_work_q *)0x0)) && + (*(char *)&pkVar2[1].fifo._queue.poll_events.field_1 != '\0')) { + k_sem_take((k_sem *)&chan[3].destroy,0xffffffff); + if ((chan->conn->state == BT_CONN_CONNECTED) && + (aVar1 = atomic_get(chan[2].rtx_work.work.flags), (aVar1 >> 2 & 1U) != 0)) { + printf("Disconnected\r\n"); + k_sem_give((k_sem *)&chan[3].destroy); + return; + } + buf = (net_buf *)chan[2].rtx_work.work_q[1].fifo._queue.poll_events.field_0; + cb = att_cb(); + bt_l2cap_send_cb(conn,4,buf,cb,(void *)0x0); + chan[2].rtx_work.work_q[1].fifo._queue.poll_events.field_0 = 0; + } + return; +} + + + +undefined4 att_exec_write_req(void) + +{ + return 6; +} + + + +void att_pdu_sent(bt_conn *conn,void *user_data) + +{ + k_work_q *pkVar1; + bt_l2cap_chan *pbVar2; + net_buf *buf; + size_t sVar3; + int iVar4; + + pbVar2 = bt_l2cap_le_lookup_tx_cid(conn,4); + do { + buf = net_buf_get((k_fifo *)pbVar2[3].rtx_work.work.flags,0); + if (buf == (net_buf *)0x0) { + k_sem_give((k_sem *)&pbVar2[3].destroy); + return; + } + pkVar1 = pbVar2[2].rtx_work.work_q; + if ((pkVar1 != (k_work_q *)0x0) && ((net_buf *)pkVar1[1].fifo._queue.poll_events.field_0 == buf) + ) { + sVar3 = net_buf_simple_headroom((net_buf_simple *)&buf->field_4); + *(short *)&pkVar1[1].fifo._queue.hdl = (short)sVar3; + *(undefined2 *)((int)&pkVar1[1].fifo._queue.hdl + 2) = *(undefined2 *)((int)&buf->field_4 + 4) + ; + } + iVar4 = att_send(conn,buf,(bt_conn_tx_cb_t *)0x0,(void *)0x0); + } while (iVar4 != 0); + return; +} + + + +bt_att * att_chan_get(bt_conn *conn) + +{ + char *fmt; + bt_att *pbVar1; + atomic_val_t aVar2; + + if (conn->state == BT_CONN_CONNECTED) { + pbVar1 = (bt_att *)bt_l2cap_le_lookup_rx_cid(conn,4); + if (pbVar1 == (bt_att *)0x0) { + printf("Unable to find ATT channel\r\n"); + return (bt_att *)0x0; + } + aVar2 = atomic_get(pbVar1->flags); + if ((aVar2 >> 2 & 1U) == 0) { + return pbVar1; + } + fmt = "ATT context flagged as disconnected\r\n"; + } + else { + fmt = "Not connected\r\n"; + } + printf(fmt); + return (bt_att *)0x0; +} + + + +void att_req_sent(bt_conn *conn,void *user_data) + +{ + bt_l2cap_chan *pbVar1; + + pbVar1 = bt_l2cap_le_lookup_tx_cid(conn,4); + if (pbVar1[2].rtx_work.work_q != (k_work_q *)0x0) { + k_delayed_work_submit((k_delayed_work *)&pbVar1[2].rtx_work.timer.args,30000); + } + att_pdu_sent(conn,user_data); + return; +} + + + +void att_cfm_sent(bt_conn *conn,void *user_data) + +{ + bt_l2cap_le_lookup_tx_cid(conn,4); + att_pdu_sent(conn,user_data); + return; +} + + + +void att_rsp_sent(bt_conn *conn,void *user_data) + +{ + bt_l2cap_le_lookup_tx_cid(conn,4); + att_pdu_sent(conn,user_data); + return; +} + + + +u8_t write_cb(bt_gatt_attr *attr,void *user_data) + +{ + u8_t uVar1; + u8_t uVar2; + undefined3 extraout_var; + uint uVar3; + char cVar4; + + uVar2 = bt_gatt_check_perm(*(bt_conn **)user_data,attr,'*'); + *(u8_t *)((int)user_data + 0x14) = uVar2; + uVar1 = '\0'; + if (CONCAT31(extraout_var,uVar2) == 0) { + uVar3 = (*attr->write)(*(bt_conn **)user_data,attr,*(void **)((int)user_data + 0xc), + *(u16_t *)((int)user_data + 0x10),*(u16_t *)((int)user_data + 0x12), + (*(char *)((int)user_data + 8) == '\0') << 1); + if ((int)uVar3 < 0) { + cVar4 = '\x0e'; + if (uVar3 + 0xff < 0xff) { + cVar4 = -(char)uVar3; + } + } + else { + if (uVar3 == (uint)*(ushort *)((int)user_data + 0x10)) { + *(undefined *)((int)user_data + 0x14) = 0; + return '\x01'; + } + cVar4 = '\x0e'; + } + *(char *)((int)user_data + 0x14) = cVar4; + uVar1 = uVar2; + } + return uVar1; +} + + + +u8_t read_cb(bt_gatt_attr *attr,void *user_data) + +{ + ushort uVar1; + u8_t uVar2; + u8_t uVar3; + char cVar4; + void *pvVar5; + undefined3 extraout_var; + size_t len; + bt_conn *conn; + bt_conn **ppbVar6; + + ppbVar6 = *(bt_conn ***)user_data; + conn = *ppbVar6; + pvVar5 = net_buf_simple_add((net_buf_simple *)(*(int *)((int)user_data + 8) + 8),0); + *(void **)((int)user_data + 0xc) = pvVar5; + *(undefined *)((int)user_data + 0x10) = 0; + uVar3 = bt_gatt_check_perm(conn,attr,'\x15'); + *(u8_t *)((int)user_data + 0x10) = uVar3; + uVar2 = '\0'; + if (CONCAT31(extraout_var,uVar3) == 0) { + uVar1 = *(ushort *)(*(int *)((int)user_data + 8) + 0xc); + len = (*attr->read)(conn,attr,(void *)(*(int *)(*(int *)((int)user_data + 8) + 8) + (uint)uVar1) + ,*(short *)((int)ppbVar6 + 0x56) - uVar1,*(u16_t *)((int)user_data + 4)); + if ((int)len < 0) { + cVar4 = '\x0e'; + if (len + 0xff < 0xff) { + cVar4 = -(char)len; + } + *(char *)((int)user_data + 0x10) = cVar4; + uVar2 = uVar3; + } + else { + uVar2 = '\x01'; + net_buf_simple_add((net_buf_simple *)(*(int *)((int)user_data + 8) + 8),len); + } + } + return uVar2; +} + + + +net_buf * bt_att_create_pdu(bt_conn *conn,u8_t op,size_t len) + +{ + att_type_t aVar1; + bt_att *pbVar2; + undefined3 extraout_var; + u8_t *puVar3; + undefined3 in_register_0000202d; + s32_t timeout; + + pbVar2 = att_chan_get(conn); + if (pbVar2 != (bt_att *)0x0) { + if ((uint)(pbVar2->chan).tx.mtu < len + 1) { + printf("ATT MTU exceeded, max %u, wanted %zu\r\n"); + pbVar2 = (bt_att *)0x0; + } + else { + aVar1 = att_op_get_type(op); + if ((CONCAT31(extraout_var,aVar1) == 2) || (timeout = -1, CONCAT31(extraout_var,aVar1) == 4)) + { + timeout = 30000; + } + pbVar2 = (bt_att *)bt_l2cap_create_pdu_timeout((net_buf_pool *)0x0,0,timeout); + if (pbVar2 == (bt_att *)0x0) { + printf("Unable to allocate buffer for op 0x%02x\r\n",CONCAT31(in_register_0000202d,op)); + } + else { + puVar3 = (u8_t *)net_buf_simple_add((net_buf_simple *)&(pbVar2->chan).chan.node,1); + *puVar3 = op; + } + } + } + return (net_buf *)pbVar2; +} + + + +u8_t att_indicate(bt_att *att,net_buf *buf) + +{ + bt_conn *conn; + u16_t handle; + net_buf *buf_00; + + conn = (att->chan).chan.conn; + handle = net_buf_simple_pull_le16((net_buf_simple *)&buf->field_4); + bt_gatt_notification(conn,handle,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4)); + buf_00 = bt_att_create_pdu(conn,'\x1e',0); + if (buf_00 != (net_buf *)0x0) { + bt_l2cap_send_cb(conn,4,buf_00,att_cfm_sent,(void *)0x0); + } + return '\0'; +} + + + +u8_t att_mtu_req(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + net_buf *buf_00; + undefined *puVar2; + ushort uVar3; + bt_conn *conn; + + uVar3 = **(ushort **)&buf->field_4; + if (uVar3 < 0x17) { + uVar1 = '\x04'; + } + else { + conn = (att->chan).chan.conn; + buf_00 = bt_att_create_pdu(conn,'\x03',2); + uVar1 = '\x0e'; + if (buf_00 != (net_buf *)0x0) { + puVar2 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf_00->field_4,2); + *puVar2 = 0xf7; + puVar2[1] = 0; + bt_l2cap_send_cb(conn,4,buf_00,att_rsp_sent,(void *)0x0); + if (0xf7 < uVar3) { + uVar3 = 0xf7; + } + (att->chan).rx.mtu = uVar3; + (att->chan).tx.mtu = uVar3; + uVar1 = '\0'; + } + } + return uVar1; +} + + + +void send_err_rsp(bt_conn *conn,u8_t req,u16_t handle,u8_t err) + +{ + net_buf *buf; + u8_t *puVar1; + + buf = bt_att_create_pdu(conn,'\x01',4); + if (buf != (net_buf *)0x0) { + puVar1 = (u8_t *)net_buf_simple_add((net_buf_simple *)&buf->field_4,4); + puVar1[1] = (u8_t)handle; + *puVar1 = req; + puVar1[2] = (u8_t)(handle >> 8); + puVar1[3] = err; + bt_l2cap_send_cb(conn,4,buf,att_rsp_sent,(void *)0x0); + return; + } + return; +} + + + +int bt_att_recv(bt_l2cap_chan *chan,net_buf *buf) + +{ + att_type_t aVar1; + u8_t err; + byte *pbVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + byte op; + int iVar3; + att_handler_conflict2 *paVar4; + int iVar5; + + if (*(short *)((int)&buf->field_4 + 4) == 0) { + printf("Too small ATT PDU received\r\n"); + } + else { + pbVar2 = (byte *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,1); + paVar4 = handlers; + iVar5 = 0; + do { + if ((uint)paVar4->op == (uint)*pbVar2) { + if ((uint)*(ushort *)((int)&buf->field_4 + 4) < (uint)handlers[iVar5].expect_len) { + printf("Invalid len %u for code 0x%02x\r\n"); + iVar3 = 4; + } + else { + err = (*handlers[iVar5].func)((bt_att *)chan,buf); + iVar3 = CONCAT31(extraout_var_00,err); + } + err = (u8_t)iVar3; + if (handlers[iVar5].type != ATT_REQUEST) { + return 0; + } + if (iVar3 == 0) { + return 0; + } + op = *pbVar2; + if (op == 0) { + return 0; + } + goto LAB_230585ee; + } + iVar5 = iVar5 + 1; + paVar4 = paVar4 + 1; + } while (iVar5 != 0x1c); + printf("Unhandled ATT code 0x%02x\r\n",(uint)*pbVar2); + op = *pbVar2; + aVar1 = att_op_get_type(op); + if ((CONCAT31(extraout_var,aVar1) != 0) && (err = '\x06', op != 0)) { +LAB_230585ee: + send_err_rsp(chan->conn,op,0,err); + } + } + return 0; +} + + + +u8_t att_read_group_req(bt_att *att,net_buf *buf) + +{ + u16_t end_handle; + u16_t handle; + _Bool _Var1; + u16_t *puVar2; + undefined3 extraout_var; + int iVar3; + net_buf *buf_00; + char *pcVar4; + u8_t data_len; + bt_conn *conn; + bt_uuid abStack80 [2]; + undefined2 uStack78; + bt_uuid abStack76 [2]; + undefined2 uStack74; + bt_uuid abStack72 [4]; + anon_union_for_u u; + read_group_data data; + + data_len = *(char *)((int)&buf->field_4 + 4) + -4; + if ((data_len != '\x02') && (data_len != '\x10')) { + return '\x04'; + } + conn = (att->chan).chan.conn; + puVar2 = (u16_t *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,4); + handle = *puVar2; + end_handle = puVar2[1]; + _Var1 = bt_uuid_create(abStack72,(u8_t *)(puVar2 + 2),data_len); + if (CONCAT31(extraout_var,_Var1) == 0) { + return '\x0e'; + } + if (handle != 0) { + if (end_handle == 0) { + handle = 0; + } + else { + if (handle <= end_handle) { + abStack80[0] = (bt_uuid)0x0; + uStack78 = 0x2800; + iVar3 = bt_uuid_cmp(abStack72,abStack80); + if (iVar3 == 0) { +LAB_23058692: + conn = (att->chan).chan.conn; + memset(u + 0x10,0,0x14); + buf_00 = bt_att_create_pdu(conn,'\x11',1); + if (buf_00 == (net_buf *)0x0) { + return '\x0e'; + } + unique0x10000076 = att; + pcVar4 = (char *)net_buf_simple_add((net_buf_simple *)&buf_00->field_4,1); + *pcVar4 = '\0'; + bt_gatt_foreach_attr(handle,end_handle,read_group_cb,u + 0x10); + if (*pcVar4 != '\0') { + bt_l2cap_send_cb(conn,4,buf_00,att_rsp_sent,(void *)0x0); + return '\0'; + } + net_buf_unref(buf_00); + send_err_rsp(conn,'\x10',handle,'\n'); + return '\0'; + } + abStack76[0] = (bt_uuid)0x0; + uStack74 = 0x2801; + iVar3 = bt_uuid_cmp(abStack72,abStack76); + if (iVar3 == 0) goto LAB_23058692; + data_len = '\x10'; + goto LAB_2305870a; + } + } + } + data_len = '\x01'; +LAB_2305870a: + send_err_rsp(conn,'\x10',handle,data_len); + return '\0'; +} + + + +// WARNING: Could not reconcile some variable overlaps + +u8_t att_read_mult_req(bt_att *att,net_buf *buf) + +{ + bt_conn *conn; + u8_t uVar1; + u16_t start_handle; + bt_att *pbStack52; + read_data data; + + conn = (att->chan).chan.conn; + memset(&pbStack52,0,0x14); + data._4_4_ = bt_att_create_pdu(conn,'\x0f',0); + if (data._4_4_ == (net_buf *)0x0) { + uVar1 = '\x0e'; + } + else { + pbStack52 = att; + do { + if (*(ushort *)((int)&buf->field_4 + 4) < 2) { + bt_l2cap_send_cb(conn,4,data._4_4_,att_rsp_sent,(void *)0x0); + goto LAB_230587d0; + } + start_handle = net_buf_simple_pull_le16((net_buf_simple *)&buf->field_4); + data.rsp._0_1_ = '\x01'; + bt_gatt_foreach_attr(start_handle,start_handle,read_cb,&pbStack52); + } while ((u8_t)data.rsp == '\0'); + net_buf_unref(data._4_4_); + send_err_rsp(conn,'\x0e',start_handle,(u8_t)data.rsp); +LAB_230587d0: + uVar1 = '\0'; + } + return uVar1; +} + + + +// WARNING: Variable defined which should be unmapped: data +// WARNING: Could not reconcile some variable overlaps + +u8_t att_read_rsp(bt_att *att,u8_t op,u8_t rsp,u16_t handle,u16_t offset) + +{ + u8_t uVar1; + bt_conn *conn; + _Bool _Var2; + undefined3 extraout_var; + undefined2 in_register_00002036; + bt_att *pbStack52; + read_data data; + + conn = (att->chan).chan.conn; + _Var2 = bt_gatt_change_aware(conn,true); + uVar1 = '\x12'; + if ((CONCAT31(extraout_var,_Var2) != 0) && + (uVar1 = '\x01', CONCAT22(in_register_00002036,handle) != 0)) { + memset(&pbStack52,0,0x14); + data._4_4_ = bt_att_create_pdu(conn,rsp,0); + if (data._4_4_ == (net_buf *)0x0) { + uVar1 = '\x0e'; + } + else { + data.rsp._0_1_ = '\x01'; + pbStack52 = att; + data.att._0_2_ = offset; + bt_gatt_foreach_attr(handle,handle,read_cb,&pbStack52); + uVar1 = (u8_t)data.rsp; + if ((u8_t)data.rsp == '\0') { + bt_l2cap_send_cb(conn,4,data._4_4_,att_rsp_sent,(void *)0x0); + } + else { + net_buf_unref(data._4_4_); + send_err_rsp(conn,op,handle,(u8_t)data.rsp); + uVar1 = '\0'; + } + } + } + return uVar1; +} + + + +u8_t att_read_blob_req(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_read_rsp(att,'\f','\r',**(u16_t **)&buf->field_4,(*(u16_t **)&buf->field_4)[1]); + return uVar1; +} + + + +u8_t att_read_req(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_read_rsp(att,'\n','\v',**(u16_t **)&buf->field_4,0); + return uVar1; +} + + + +// WARNING: Removing unreachable block (ram,0x230589c6) +// WARNING: Could not reconcile some variable overlaps + +u8_t att_read_type_req(bt_att *att,net_buf *buf) + +{ + u16_t end_handle; + u16_t start_handle; + _Bool _Var1; + u16_t *puVar2; + undefined3 extraout_var; + net_buf *buf_00; + undefined *puVar3; + u8_t data_len; + bt_conn *conn; + bt_uuid abStack76 [4]; + anon_union_for_u u; + read_type_data data; + + data_len = *(char *)((int)&buf->field_4 + 4) + -4; + if ((data_len != '\x02') && (data_len != '\x10')) { + return '\x04'; + } + conn = (att->chan).chan.conn; + puVar2 = (u16_t *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,4); + start_handle = *puVar2; + end_handle = puVar2[1]; + _Var1 = bt_uuid_create(abStack76,(u8_t *)(puVar2 + 2),data_len); + if (CONCAT31(extraout_var,_Var1) == 0) { + return '\x0e'; + } + if (start_handle != 0) { + if (end_handle == 0) { + start_handle = 0; + } + else { + if (start_handle <= end_handle) { + conn = (att->chan).chan.conn; + memset(u + 0x10,0,0x18); + buf_00 = bt_att_create_pdu(conn,'\t',1); + if (buf_00 == (net_buf *)0x0) { + return '\x0e'; + } + unique0x10000060 = att; + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf_00->field_4,1); + *puVar3 = 0; + data.item._0_1_ = '\n'; + bt_gatt_foreach_attr(start_handle,end_handle,read_type_cb,u + 0x10); + net_buf_unref(buf_00); + goto LAB_2305897a; + } + } + } + data.item._0_1_ = '\x01'; +LAB_2305897a: + send_err_rsp(conn,'\b',start_handle,(u8_t)data.item); + return '\0'; +} + + + +// WARNING: Variable defined which should be unmapped: data +// WARNING: Could not reconcile some variable overlaps + +u8_t att_find_type_req(bt_att *att,net_buf *buf) + +{ + u16_t end_handle; + u16_t *puVar1; + int iVar2; + u16_t start_handle; + u8_t err; + bt_conn *conn; + bt_att_handle_group *pbVar3; + bt_uuid abStack60 [2]; + u16_t uStack58; + bt_uuid abStack56 [2]; + undefined2 uStack54; + bt_att *pbStack52; + find_type_data data; + + conn = (att->chan).chan.conn; + puVar1 = (u16_t *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,6); + start_handle = *puVar1; + if (start_handle != 0) { + end_handle = puVar1[1]; + if (end_handle == 0) { + start_handle = 0; + } + else { + if (start_handle <= end_handle) { + uStack58 = puVar1[2]; + pbVar3 = *(bt_att_handle_group **)&buf->field_4; + abStack60[0] = (bt_uuid)0x0; + abStack56[0] = (bt_uuid)0x0; + uStack54 = 0x2800; + iVar2 = bt_uuid_cmp(abStack60,abStack56); + if (iVar2 == 0) { + data.value._0_1_ = *(undefined *)((int)&buf->field_4 + 4); + conn = (att->chan).chan.conn; + memset(&pbStack52,0,0x14); + data.att = (bt_att *)bt_att_create_pdu(conn,'\a',0); + if (data.att == (bt_att *)0x0) { + return '\x0e'; + } + data.buf = (net_buf *)0x0; + data.value._1_1_ = '\n'; + pbStack52 = att; + data.group = pbVar3; + bt_gatt_foreach_attr(start_handle,end_handle,find_type_cb,&pbStack52); + if (data.value._1_1_ == '\0') { + bt_l2cap_send_cb(conn,4,(net_buf *)data.att,att_rsp_sent,(void *)0x0); + return '\0'; + } + net_buf_unref((net_buf *)data.att); + err = data.value._1_1_; + } + else { + err = '\n'; + } + goto LAB_23058a5c; + } + } + } + err = '\x01'; +LAB_23058a5c: + send_err_rsp(conn,'\x06',start_handle,err); + return '\0'; +} + + + +u8_t att_find_info_req(bt_att *att,net_buf *buf) + +{ + u16_t end_handle; + u16_t start_handle; + u8_t err; + bt_conn *conn; + bt_att *local_30; + find_info_data data; + + conn = (att->chan).chan.conn; + start_handle = **(u16_t **)&buf->field_4; + if (start_handle != 0) { + end_handle = (*(u16_t **)&buf->field_4)[1]; + if (end_handle == 0) { + start_handle = 0; + } + else { + if (start_handle <= end_handle) { + memset(&local_30,0,0x10); + data.att = (bt_att *)bt_att_create_pdu(conn,'\x05',0); + if (data.att == (bt_att *)0x0) { + return '\x0e'; + } + local_30 = att; + bt_gatt_foreach_attr(start_handle,end_handle,find_info_cb,&local_30); + if (data.buf != (net_buf *)0x0) { + bt_l2cap_send_cb(conn,4,(net_buf *)data.att,att_rsp_sent,(void *)0x0); + return '\0'; + } + net_buf_unref((net_buf *)data.att); + err = '\n'; + goto LAB_23058b4e; + } + } + } + err = '\x01'; +LAB_23058b4e: + send_err_rsp(conn,'\x04',start_handle,err); + return '\0'; +} + + + +// WARNING: Variable defined which should be unmapped: data +// WARNING: Could not reconcile some variable overlaps + +u8_t att_write_rsp(bt_conn *conn,u8_t req,u8_t rsp,u16_t handle,void *value,u16_t len) + +{ + u8_t uVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + undefined2 in_register_00002036; + bt_conn *pbStack56; + write_data_conflict data; + + _Var2 = bt_gatt_change_aware(conn,(_Bool)(CONCAT31(in_register_0000202d,req) != 0)); + uVar1 = '\x12'; + if ((CONCAT31(extraout_var,_Var2) != 0) && + (uVar1 = '\x01', CONCAT22(in_register_00002036,handle) != 0)) { + memset(&pbStack56,0,0x18); + if ((CONCAT31(in_register_00002031,rsp) != 0) && + (data.conn = (bt_conn *)bt_att_create_pdu(conn,rsp,0), data.conn == (bt_conn *)0x0)) { + return '\x0e'; + } + data.value._2_2_ = 0; + data.len._0_1_ = '\x01'; + pbStack56 = conn; + data.buf._0_1_ = req; + data._8_4_ = value; + data.value._0_2_ = len; + bt_gatt_foreach_attr(handle,handle,write_cb,&pbStack56); + if ((u8_t)data.len == '\0') { + if (data.conn != (bt_conn *)0x0) { + bt_l2cap_send_cb(conn,4,(net_buf *)data.conn,att_rsp_sent,(void *)0x0); + return '\0'; + } + } + else { + if ((CONCAT31(in_register_00002031,rsp) != 0) && + (net_buf_unref((net_buf *)data.conn), CONCAT31(in_register_0000202d,req) != 0)) { + send_err_rsp(conn,req,handle,(u8_t)data.len); + } + } + uVar1 = '\0'; + } + return uVar1; +} + + + +u8_t att_write_req(bt_att *att,net_buf *buf) + +{ + bt_conn *conn; + u8_t uVar1; + u16_t handle; + + conn = (att->chan).chan.conn; + handle = net_buf_simple_pull_le16((net_buf_simple *)&buf->field_4); + uVar1 = att_write_rsp(conn,'\x12','\x13',handle,*(void **)&buf->field_4, + *(u16_t *)((int)&buf->field_4 + 4)); + return uVar1; +} + + + +u8_t att_write_cmd(bt_att *att,net_buf *buf) + +{ + bt_conn *conn; + u8_t uVar1; + u16_t handle; + + conn = (att->chan).chan.conn; + handle = net_buf_simple_pull_le16((net_buf_simple *)&buf->field_4); + uVar1 = att_write_rsp(conn,'\0','\0',handle,*(void **)&buf->field_4, + *(u16_t *)((int)&buf->field_4 + 4)); + return uVar1; +} + + + +u8_t att_signed_write_cmd(bt_att *att,net_buf *buf) + +{ + u16_t handle; + u8_t uVar1; + int iVar2; + net_buf_simple *buf_00; + bt_conn *conn; + + conn = (att->chan).chan.conn; + buf_00 = (net_buf_simple *)&buf->field_4; + handle = **(u16_t **)&buf->field_4; + net_buf_simple_push(buf_00,1); + iVar2 = bt_smp_sign_verify(conn,buf); + if (iVar2 == 0) { + net_buf_simple_pull(buf_00,1); + net_buf_simple_pull(buf_00,2); + uVar1 = att_write_rsp(conn,'\0','\0',handle,*(void **)&buf->field_4, + (u16_t)(((uint)*(ushort *)((int)&buf->field_4 + 4) - 0xc) * 0x10000 >> + 0x10)); + return uVar1; + } + printf("Error verifying data\r\n"); + return '\0'; +} + + + +void bt_att_init(void) + +{ + anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept **ppaVar1; + bool bVar2; + int iVar3; + uint uVar4; + bt_gatt_service_static *pbVar5; + + iVar3 = atomic_cas(&init,0,1); + if (iVar3 != 0) { + uVar4 = (uint)last_static_handle; + bVar2 = false; + pbVar5 = &_1_gatt_svc; + while (pbVar5 < &att_fixed_chan) { + ppaVar1 = &((bt_l2cap_fixed_chan *)pbVar5)->accept; + pbVar5 = (bt_gatt_service_static *)&((bt_l2cap_fixed_chan *)pbVar5)->node; + uVar4 = (uint)(*ppaVar1 + uVar4) & 0xffff; + bVar2 = true; + } + if (bVar2) { + last_static_handle = (u16_t)uVar4; + } + k_delayed_work_init((k_delayed_work *)&gatt_sc.work,sc_process); + return; + } + return; +} + + + +u16_t bt_att_get_mtu(bt_conn *conn) + +{ + u16_t uVar1; + bt_att *pbVar2; + + pbVar2 = att_chan_get(conn); + if (pbVar2 == (bt_att *)0x0) { + uVar1 = 0; + } + else { + uVar1 = (pbVar2->chan).tx.mtu; + } + return uVar1; +} + + + +int bt_att_send(bt_conn *conn,net_buf *buf,bt_conn_tx_cb_t *cb,void *user_data) + +{ + int iVar1; + bt_att *pbVar2; + + pbVar2 = att_chan_get(conn); + if (pbVar2 == (bt_att *)0x0) { + net_buf_unref(buf); + iVar1 = -0x39; + } + else { + if ((cb == (bt_conn_tx_cb_t *)0x0) && (iVar1 = k_sem_take(&pbVar2->tx_sem,0), iVar1 < 0)) { + k_queue_append((k_queue *)&pbVar2->tx_queue,buf); + return 0; + } + iVar1 = att_send(conn,buf,cb,user_data); + if ((iVar1 != 0) && (cb == (bt_conn_tx_cb_t *)0x0)) { + k_sem_give(&pbVar2->tx_sem); + } + } + return iVar1; +} + + + +int bt_att_req_send(bt_conn *conn,bt_att_req_conflict28 *req) + +{ + bt_att *att; + int iVar1; + sys_snode_t *psVar2; + + att = att_chan_get(conn); + if (att == (bt_att *)0x0) { + net_buf_unref(req->buf); + iVar1 = -0x39; + req->buf = (net_buf *)0x0; + } + else { + if (att->req == (bt_att_req_conflict28 *)0x0) { + iVar1 = att_send_req(att,req); + return iVar1; + } + (req->node).next = (_snode *)0x0; + psVar2 = (att->reqs).tail; + if (psVar2 == (sys_snode_t *)0x0) { + *(bt_att_req_conflict28 **)&(att->reqs).tail = req; + *(bt_att_req_conflict28 **)&(att->reqs).head = req; + } + else { + *(bt_att_req_conflict28 **)&psVar2->next = req; + *(bt_att_req_conflict28 **)&(att->reqs).tail = req; + } + iVar1 = 0; + } + return iVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +void bt_att_req_cancel(bt_conn *param_1,sys_snode_t param_2) + +{ + bt_att *pbVar1; + sys_snode_t sVar2; + sys_snode_t sVar3; + + if ((param_1 == (bt_conn *)0x0) || (param_2 == (sys_snode_t)0x0)) { + return; + } + pbVar1 = att_chan_get(param_1); + if (pbVar1 == (bt_att *)0x0) { + return; + } + if ((sys_snode_t)((sys_snode_t *)&pbVar1->req)->next == param_2) { + pbVar1->req = &cancel; + } + else { + sVar2 = (sys_snode_t)0x0; + sVar3 = (sys_snode_t)(pbVar1->reqs).head; + while (sVar3 != (sys_snode_t)0x0) { + if (param_2 == sVar3) { + sVar3 = *(sys_snode_t *)param_2; + if (sVar2 == (sys_snode_t)0x0) { + sVar2 = (sys_snode_t)((sys_snode_t *)&(pbVar1->reqs).tail)->next; + *(sys_snode_t *)&(pbVar1->reqs).head = sVar3; + if (param_2 == sVar2) { + *(sys_snode_t *)&((sys_snode_t *)&(pbVar1->reqs).tail)->next = sVar3; + } + } + else { + *(sys_snode_t *)sVar2 = sVar3; + if (param_2 == (sys_snode_t)((sys_snode_t *)&(pbVar1->reqs).tail)->next) { + *(sys_snode_t *)&((sys_snode_t *)&(pbVar1->reqs).tail)->next = sVar2; + } + } + *(undefined4 *)param_2 = 0; + break; + } + sVar2 = sVar3; + sVar3 = *(sys_snode_t *)sVar3; + } + } + att_req_destroy((bt_att_req_conflict28 *)param_2); + return; +} + + + +uint32_t fdt32_ld(fdt32_t *p) + +{ + return (uint)*(byte *)((int)p + 2) << 8 | + (uint)*(byte *)p << 0x18 | (uint)*(byte *)((int)p + 1) << 0x10 | + (uint)*(byte *)((int)p + 3); +} + + + +int nextprop_(void *fdt,int offset) + +{ + uint32_t uVar1; + int iStack36; + int nextoffset; + + while( true ) { + uVar1 = fdt_next_tag(fdt,offset,&iStack36); + if (uVar1 == 3) { + return offset; + } + if (uVar1 == 9) break; + offset = iStack36; + if (uVar1 != 4) { + return -1; + } + } + if (iStack36 < 0) { + return iStack36; + } + return -0xb; +} + + + +fdt_property * fdt_get_property_by_offset_(void *fdt,int offset,int *lenp) + +{ + fdt_property *pfVar1; + uint32_t uVar2; + + uVar2 = fdt_check_prop_offset_(fdt,offset); + if ((int)uVar2 < 0) { + pfVar1 = (fdt_property *)0x0; + if (lenp == (int *)0x0) { + return (fdt_property *)0x0; + } + } + else { + uVar2 = fdt32_ld((fdt32_t *)((int)fdt + 8)); + pfVar1 = (fdt_property *)((int)fdt + uVar2 + offset); + if (lenp == (int *)0x0) { + return pfVar1; + } + uVar2 = fdt32_ld(&pfVar1->len); + } + *lenp = uVar2; + return pfVar1; +} + + + +char * fdt_get_string(void *fdt,int stroffset,int *lenp) + +{ + char *__s; + uint32_t uVar1; + void *pvVar2; + uint __n; + uint uVar3; + + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0xc)); + pvVar2 = (void *)fdt_ro_probe_(fdt); + if (pvVar2 == (void *)0x0) { + uVar3 = uVar1 + stroffset; + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 4)); + if (uVar3 < uVar1) { + __n = uVar1 - uVar3; + uVar1 = fdt32_ld((fdt32_t *)fdt); + if (uVar1 == 0xd00dfeed) { + if (-1 < stroffset) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x14)); + if (0x10 < uVar1) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x20)); + if (uVar1 <= (uint)stroffset) goto LAB_23059010; + if (uVar1 - stroffset < __n) { + __n = uVar1 - stroffset; + } + } +LAB_23058fb0: + __s = (char *)((int)fdt + uVar3); + pvVar2 = memchr(__s,0,__n); + if (pvVar2 != (void *)0x0) { + pvVar2 = (void *)((int)pvVar2 - (int)__s); + goto joined_r0x23059006; + } + pvVar2 = (void *)0xfffffff8; + goto fail; + } + } + else { + if (uVar1 != 0x2ff20112) { + pvVar2 = (void *)0xfffffff3; + goto fail; + } + if ((stroffset < 0) && + (uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x20)), -uVar1 <= (uint)stroffset)) { + if ((uint)-stroffset < __n) { + __n = -stroffset; + } + goto LAB_23058fb0; + } + } + } +LAB_23059010: + pvVar2 = (void *)0xfffffffc; + } +fail: + __s = (char *)0x0; +joined_r0x23059006: + if (lenp != (int *)0x0) { + *(void **)lenp = pvVar2; + } + return __s; +} + + + +char * fdt_get_name(void *fdt,int nodeoffset,int *len) + +{ + uint32_t uVar1; + size_t sVar2; + uint32_t uVar3; + char *__s; + + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 8)); + sVar2 = fdt_ro_probe_(fdt); + if ((sVar2 == 0) && (sVar2 = fdt_check_node_offset_(fdt,nodeoffset), -1 < (int)sVar2)) { + uVar3 = fdt32_ld((fdt32_t *)((int)fdt + 0x14)); + __s = (char *)((int)fdt + nodeoffset + uVar1 + 4); + if (uVar3 < 0x10) { + __s = strrchr(__s,0x2f); + if (__s == (char *)0x0) { + sVar2 = 0xfffffff5; + goto fail; + } + __s = __s + 1; + } + if (len == (int *)0x0) { + return __s; + } + sVar2 = strlen(__s); + } + else { +fail: + __s = (char *)0x0; + if (len == (int *)0x0) { + return (char *)0x0; + } + } + *len = sVar2; + return __s; +} + + + +int fdt_subnode_offset_namelen(void *fdt,int offset,char *name,int namelen) + +{ + int iVar1; + char *__s1; + void *pvVar2; + int iStack40; + int depth; + int olen; + + iVar1 = fdt_ro_probe_(fdt); + if (iVar1 == 0) { + iStack40 = 0; + while (-1 < offset) { + if (iStack40 < 0) goto LAB_230590be; + if ((((iStack40 == 1) && (__s1 = fdt_get_name(fdt,offset,&depth), __s1 != (char *)0x0)) && + (namelen <= depth)) && (iVar1 = memcmp(__s1,name,namelen), iVar1 == 0)) { + if (__s1[namelen] == '\0') { + return offset; + } + pvVar2 = memchr(name,0x40,namelen); + if ((pvVar2 == (void *)0x0) && (__s1[namelen] == '@')) { + return offset; + } + } + offset = fdt_next_node(fdt,offset,&iStack40); + } + iVar1 = offset; + if (iStack40 < 0) { +LAB_230590be: + iVar1 = -1; + } + } + return iVar1; +} + + + +int fdt_subnode_offset(void *fdt,int parentoffset,char *name) + +{ + size_t namelen; + int iVar1; + + namelen = strlen(name); + iVar1 = fdt_subnode_offset_namelen(fdt,parentoffset,name,namelen); + return iVar1; +} + + + +int fdt_first_property_offset(void *fdt,int nodeoffset) + +{ + int offset; + + offset = fdt_check_node_offset_(fdt,nodeoffset); + if (-1 < offset) { + offset = nextprop_(fdt,offset); + return offset; + } + return offset; +} + + + +int fdt_next_property_offset(void *fdt,int offset) + +{ + int offset_00; + + offset_00 = fdt_check_prop_offset_(fdt,offset); + if (-1 < offset_00) { + offset_00 = nextprop_(fdt,offset_00); + return offset_00; + } + return offset_00; +} + + + +// WARNING: Variable defined which should be unmapped: slen + +fdt_property * +fdt_get_property_namelen_(void *fdt,int offset,char *name,int namelen,int *lenp,int *poffset) + +{ + int offset_00; + fdt_property *pfVar1; + uint32_t stroffset; + char *__s1; + int iVar2; + int iStack36; + int slen; + + offset_00 = fdt_first_property_offset(fdt,offset); + do { + if (offset_00 < 0) { +LAB_230591bc: + if (lenp != (int *)0x0) { + *lenp = offset_00; + } + return (fdt_property *)0x0; + } + pfVar1 = fdt_get_property_by_offset_(fdt,offset_00,lenp); + if (pfVar1 == (fdt_property *)0x0) { + offset_00 = -0xd; + goto LAB_230591bc; + } + stroffset = fdt32_ld(&pfVar1->nameoff); + __s1 = fdt_get_string(fdt,stroffset,&iStack36); + if (((__s1 != (char *)0x0) && (namelen == iStack36)) && + (iVar2 = memcmp(__s1,name,namelen), iVar2 == 0)) { + if (poffset == (int *)0x0) { + return pfVar1; + } + *poffset = offset_00; + return pfVar1; + } + offset_00 = fdt_next_property_offset(fdt,offset_00); + } while( true ); +} + + + +void * fdt_getprop_namelen(void *fdt,int nodeoffset,char *name,int namelen,int *lenp) + +{ + fdt_property *pfVar1; + uint32_t uVar2; + int iStack20; + int poffset; + + pfVar1 = fdt_get_property_namelen_(fdt,nodeoffset,name,namelen,lenp,&iStack20); + if (pfVar1 != (fdt_property *)0x0) { + uVar2 = fdt32_ld((fdt32_t *)((int)fdt + 0x14)); + if (((uVar2 < 0x10) && ((iStack20 + 0xcU & 7) != 0)) && + (uVar2 = fdt32_ld(&pfVar1->len), 7 < uVar2)) { + pfVar1 = (fdt_property *)&pfVar1[1].len; + } + else { + pfVar1 = pfVar1 + 1; + } + } + return pfVar1; +} + + + +void * fdt_getprop(void *fdt,int nodeoffset,char *name,int *lenp) + +{ + size_t namelen; + void *pvVar1; + + namelen = strlen(name); + pvVar1 = fdt_getprop_namelen(fdt,nodeoffset,name,namelen,lenp); + return pvVar1; +} + + + +// WARNING: Variable defined which should be unmapped: length + +int fdt_stringlist_count(void *fdt,int nodeoffset,char *property) + +{ + int iVar1; + char *__string; + size_t sVar2; + char *pcVar3; + int iStack20; + int length; + + __string = (char *)fdt_getprop(fdt,nodeoffset,property,&iStack20); + iVar1 = iStack20; + if (__string != (char *)0x0) { + pcVar3 = __string + iStack20; + iVar1 = 0; + while (__string < pcVar3) { + sVar2 = strnlen(__string,(size_t)(pcVar3 + -(int)__string)); + iStack20 = sVar2 + 1; + __string = __string + iStack20; + if (pcVar3 < __string) { + return -0xf; + } + iVar1 = iVar1 + 1; + } + } + return iVar1; +} + + + +char * fdt_stringlist_get(void *fdt,int nodeoffset,char *property,int idx,int *lenp) + +{ + char *__string; + size_t sVar1; + int iVar2; + char *pcVar3; + int iStack36; + int length; + + __string = (char *)fdt_getprop(fdt,nodeoffset,property,&iStack36); + if (__string == (char *)0x0) { + if (lenp != (int *)0x0) { + *lenp = iStack36; + return (char *)0x0; + } + } + else { + pcVar3 = __string + iStack36; + while (__string < pcVar3) { + sVar1 = strnlen(__string,(size_t)(pcVar3 + -(int)__string)); + iStack36 = sVar1 + 1; + if (pcVar3 < __string + iStack36) { + iVar2 = -0xf; + if (lenp == (int *)0x0) { + return (char *)0x0; + } + goto LAB_2305933c; + } + if (idx == 0) { + if (lenp != (int *)0x0) { + *lenp = sVar1; + return __string; + } + return __string; + } + idx = idx + -1; + __string = __string + iStack36; + } + if (lenp != (int *)0x0) { + iVar2 = -1; +LAB_2305933c: + *lenp = iVar2; + } + } + return (char *)0x0; +} + + + +void blfdt(char *buf,int len,int argc,char **argv) + +{ + tc_fdt_wifi(); + tc_blfdtdump(); + return; +} + + + +int blfdt_cli_init(void) + +{ + return 0; +} + + + +uint32_t fdt32_ld(fdt32_t *p) + +{ + return (uint)*(byte *)((int)p + 2) << 8 | + (uint)*(byte *)p << 0x18 | (uint)*(byte *)((int)p + 1) << 0x10 | + (uint)*(byte *)((int)p + 3); +} + + + +int fdt_ro_probe_(void *fdt) + +{ + uint32_t uVar1; + int iVar2; + + uVar1 = fdt32_ld((fdt32_t *)fdt); + if (uVar1 == 0xd00dfeed) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x14)); + iVar2 = -10; + if (1 < uVar1) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x18)); + iVar2 = 0; + if (0x11 < uVar1) { + iVar2 = -10; + } + } + } + else { + iVar2 = -9; + if (uVar1 == 0x2ff20112) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x24)); + iVar2 = 0; + if (uVar1 == 0) { + iVar2 = -7; + } + } + } + return iVar2; +} + + + +void * fdt_offset_ptr(void *fdt,int offset,uint len) + +{ + uint32_t uVar1; + void *pvVar2; + uint uVar3; + + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 8)); + uVar3 = uVar1 + offset; + pvVar2 = (void *)0x0; + if ((uint)offset <= uVar3) { + pvVar2 = (void *)0x0; + if (uVar3 <= uVar3 + len) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 4)); + pvVar2 = (void *)0x0; + if (uVar3 + len <= uVar1) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x14)); + if (0x10 < uVar1) { + if (len + offset < (uint)offset) { + return (void *)0x0; + } + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x24)); + if (uVar1 < len + offset) { + return (void *)0x0; + } + } + pvVar2 = (void *)((int)fdt + uVar3); + } + } + } + return pvVar2; +} + + + +uint32_t fdt_next_tag(void *fdt,int startoffset,int *nextoffset) + +{ + int offset; + int offset_00; + uint *puVar1; + char *pcVar2; + void *pvVar3; + uint32_t uVar4; + uint uVar5; + uint uVar6; + + *nextoffset = -8; + puVar1 = (uint *)fdt_offset_ptr(fdt,startoffset,4); + if (puVar1 != (uint *)0x0) { + uVar5 = *puVar1; + offset = startoffset + 4; + uVar5 = uVar5 << 0x18 | uVar5 >> 0x18 | (uVar5 >> 8 & 0xff) << 0x10 | + (uVar5 >> 0x10 & 0xff) << 8; + *nextoffset = -0xb; + offset_00 = offset; + switch(uVar5) { + case 1: + do { + offset = offset_00 + 1; + pcVar2 = (char *)fdt_offset_ptr(fdt,offset_00,1); + if (pcVar2 == (char *)0x0) { + return 9; + } + offset_00 = offset; + } while (*pcVar2 != '\0'); + break; + case 2: + case 4: + case 9: + break; + case 3: + puVar1 = (uint *)fdt_offset_ptr(fdt,offset,4); + if (puVar1 == (uint *)0x0) { + return 9; + } + uVar6 = *puVar1; + uVar6 = uVar6 << 0x18 | uVar6 >> 0x18 | (uVar6 >> 8 & 0xff) << 0x10 | + (uVar6 >> 0x10 & 0xff) << 8; + uVar4 = fdt32_ld((fdt32_t *)((int)fdt + 0x14)); + offset = startoffset + 0xcU + uVar6; + if (((uVar4 < 0x10) && (7 < uVar6)) && ((startoffset + 0xcU & 7) != 0)) { + offset = offset + 4; + } + break; + default: + goto LAB_230594f4; + } + pvVar3 = fdt_offset_ptr(fdt,startoffset,offset - startoffset); + if (pvVar3 != (void *)0x0) { + *nextoffset = offset + 3U & 0xfffffffc; + return uVar5; + } + } +LAB_230594f4: + return 9; +} + + + +int fdt_check_node_offset_(void *fdt,int offset) + +{ + uint32_t uVar1; + int aiStack20 [4]; + + if (((offset < 0) || ((offset & 3U) != 0)) || + (aiStack20[0] = offset, uVar1 = fdt_next_tag(fdt,offset,aiStack20), uVar1 != 1)) { + aiStack20[0] = -4; + } + return aiStack20[0]; +} + + + +int fdt_check_prop_offset_(void *fdt,int offset) + +{ + uint32_t uVar1; + int aiStack20 [4]; + + if (((offset < 0) || ((offset & 3U) != 0)) || + (aiStack20[0] = offset, uVar1 = fdt_next_tag(fdt,offset,aiStack20), uVar1 != 3)) { + aiStack20[0] = -4; + } + return aiStack20[0]; +} + + + +int fdt_next_node(void *fdt,int offset,int *depth) + +{ + uint32_t uVar1; + int iVar2; + int iStack36; + int nextoffset; + + iStack36 = 0; + if (offset < 0) goto LAB_230595d6; + iStack36 = fdt_check_node_offset_(fdt,offset); + iVar2 = iStack36; + do { + if (iVar2 < 0) { + return iStack36; + } +LAB_230595d6: + do { + while (iVar2 = iStack36, uVar1 = fdt_next_tag(fdt,iStack36,&iStack36), uVar1 != 2) { + if (uVar1 == 9) { + if (iStack36 < 0) { + if (iStack36 != -8) { + return iStack36; + } + if (depth != (int *)0x0) { + return -8; + } + } + return -1; + } + if (uVar1 == 1) { + if (depth == (int *)0x0) { + return iVar2; + } + *depth = *depth + 1; + return iVar2; + } + } + } while (depth == (int *)0x0); + iVar2 = *depth + -1; + *depth = iVar2; + } while( true ); +} + + + +uint32_t fdt32_to_cpu(fdt32_t x) + +{ + return (x >> 0x10 & 0xff) << 8 | x << 0x18 | x >> 0x18 | (x >> 8 & 0xff) << 0x10; +} + + + +uint64_t fdt64_to_cpu(void) + +{ + uint64_t in_fa0; + + return in_fa0; +} + + + +uint32_t fdt32_ld(fdt32_t *p) + +{ + return (uint)*(byte *)((int)p + 2) << 8 | + (uint)*(byte *)p << 0x18 | (uint)*(byte *)((int)p + 1) << 0x10 | + (uint)*(byte *)((int)p + 3); +} + + + +_Bool util_is_printable_string(void *data,int len) + +{ + byte *pbVar1; + undefined uVar2; + byte *pbVar3; + byte *pbVar4; + + if (len == 0) { +LAB_2305970e: + uVar2 = 0; + } + else { + pbVar1 = (byte *)(len + (int)data); + uVar2 = 0; + if (pbVar1[-1] == 0) { + while (pbVar3 = (byte *)data, data < pbVar1) { + do { + pbVar4 = pbVar3; + if ((*pbVar3 == 0) || ((_ctype_[(uint)*pbVar3 + 1] & 0x97) == 0)) break; + pbVar3 = pbVar3 + 1; + pbVar4 = pbVar1; + } while (pbVar1 != pbVar3); + if ((*pbVar4 != 0) || ((byte *)data == pbVar4)) goto LAB_2305970e; + data = pbVar4 + 1; + } + uVar2 = 1; + } + } + return (_Bool)uVar2; +} + + + +void utilfdt_print_data(char *data,int len) + +{ + char *fmt; + _Bool _Var1; + undefined3 extraout_var; + size_t sVar2; + uint32_t uVar3; + undefined1 *puVar4; + int iVar5; + + if (len == 0) { + return; + } + _Var1 = util_is_printable_string(data,len); + if (CONCAT31(extraout_var,_Var1) != 0) { + printf(" = "); + fmt = data + len; + while( true ) { + printf("\"%s\"",data); + sVar2 = strlen(data); + data = data + sVar2 + 1; + if (fmt <= data) break; + printf(", "); + } + return; + } + if ((len & 3U) == 0) { + printf(" = <"); + iVar5 = 0; + while (iVar5 < len / 4) { + uVar3 = fdt32_to_cpu(*(fdt32_t *)(data + iVar5 * 4)); + puVar4 = (undefined1 *)0x230bed54; + if (len / 4 + -1 <= iVar5) { + puVar4 = &DAT_230c6dbc; + } + printf("0x%08x%s",uVar3,puVar4); + iVar5 = iVar5 + 1; + } + fmt = ">"; + } + else { + printf(" = ["); + iVar5 = 0; + while (iVar5 < len) { + puVar4 = (undefined1 *)0x230bed54; + if (len + -1 <= iVar5) { + puVar4 = &DAT_230c6dbc; + } + printf("%02x%s",(uint)(byte)data[iVar5],puVar4); + iVar5 = iVar5 + 1; + } + fmt = "]"; + } + printf(fmt); + return; +} + + + +undefined4 tc_blfdtdump(void) + +{ + uint8_t *__s; + uint *puVar1; + fdt32_t *pfVar2; + TickType_t TVar3; + uint32_t len; + uint32_t uVar4; + uint32_t uVar5; + uint32_t uVar6; + uint32_t uVar7; + uint32_t uVar8; + uint uVar9; + uint uVar10; + undefined *puVar11; + undefined4 uVar12; + size_t sVar13; + char *fmt; + uint uVar14; + uint uVar15; + int iVar16; + fdt32_t *pfVar17; + undefined *puVar18; + int iVar19; + fdt32_t *data; + uint64_t uVar20; + fdt32_t *pfStack72; + + __s = tc_wifi_dtb; + while( true ) { + if ((int)(&UNK_230be7fb + -(int)__s) < 4) break; + __s = (uint8_t *)memchr(__s,0xd0,-(int)__s + 0x230be7f7); + if ((fdt32_t *)__s == (fdt32_t *)0x0) goto LAB_23059a40; + len = fdt32_ld((fdt32_t *)__s); + if (len == 0xd00dfeed) { + puVar18 = &UNK_230be7fb + -(int)__s; + if ((((((undefined *)0x27 < puVar18) && (len = fdt32_ld((fdt32_t *)__s + 5), len < 0x12)) && + (len = fdt32_ld((fdt32_t *)__s + 6), len < 0x12)) && + ((puVar11 = (undefined *)fdt32_ld((fdt32_t *)__s + 1), puVar11 < puVar18 && + (puVar11 = (undefined *)fdt32_ld((fdt32_t *)__s + 2), puVar11 < puVar18)))) && + (puVar11 = (undefined *)fdt32_ld((fdt32_t *)__s + 3), puVar11 < puVar18)) + goto LAB_230598a2; + printf("%s: skipping fdt magic at offset %#tx\r\n","fdtbuff",(fdt32_t *)__s + -0x8c2f553); + } + __s = (uint8_t *)((int)__s + 1); + } + if (((fdt32_t *)__s == (fdt32_t *)0x0) || (&UNK_230be7fb + -(int)__s < (undefined *)0x28)) { +LAB_23059a40: + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %s: could not locate fdt magic\r\n",&DAT_230a9dd8, + "tc_blfdt_dump.c",0x149,"fdtbuff"); + printf("dump failed\r\n"); + uVar12 = 0xffffffff; + } + else { +LAB_230598a2: + printf("%s: found fdt at offset %#tx\r\n","fdtbuff",(fdt32_t *)__s + -0x8c2f553); + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] dump_blob.",TVar3,&DAT_230bd32c,"tc_blfdt_dump.c",0x153); + len = fdt32_to_cpu(((fdt32_t *)__s)[4]); + uVar4 = fdt32_to_cpu(((fdt32_t *)__s)[2]); + uVar5 = fdt32_to_cpu(((fdt32_t *)__s)[3]); + uVar6 = fdt32_to_cpu(((fdt32_t *)__s)[5]); + uVar7 = fdt32_to_cpu(((fdt32_t *)__s)[1]); + printf("/dts-v1/;\r\n"); + uVar8 = fdt32_to_cpu(*(fdt32_t *)__s); + printf("// magic:\t\t0x%lx\r\n",uVar8); + printf("// totalsize:\t\t0x%lx (%lu)\r\n",uVar7); + printf("// off_dt_struct:\t0x%lx\r\n",uVar4); + printf("// off_dt_strings:\t0x%lx\r\n",uVar5); + printf("// off_mem_rsvmap:\t0x%lx\r\n",len); + printf("// version:\t\t%lu\r\n",uVar6); + uVar7 = fdt32_to_cpu(((fdt32_t *)__s)[6]); + printf("// last_comp_version:\t%lu\r\n",uVar7); + if (1 < uVar6) { + uVar7 = fdt32_to_cpu(((fdt32_t *)__s)[7]); + printf("// boot_cpuid_phys:\t0x%lx\r\n",uVar7); + if (uVar6 != 2) { + uVar7 = fdt32_to_cpu(((fdt32_t *)__s)[8]); + printf("// size_dt_strings:\t0x%lx\r\n",uVar7); + if (0x10 < uVar6) { + uVar7 = fdt32_to_cpu(((fdt32_t *)__s)[9]); + printf("// size_dt_struct:\t0x%lx\r\n",uVar7); + } + } + } + printf("\r\n"); + puVar1 = (uint *)(len + (int)__s); + while( true ) { + uVar9 = *puVar1; + uVar14 = puVar1[1]; + fdt64_to_cpu(); + uVar10 = puVar1[2]; + uVar15 = puVar1[3]; + uVar20 = fdt64_to_cpu(); + if ((uVar9 | uVar10 | uVar15 | uVar14) == 0) break; + printf("/memreserve/ %#llx %#llx;\r\n",uVar10,uVar15,(int)uVar20); + puVar1 = puVar1 + 4; + } + iVar19 = 0; + pfStack72 = (fdt32_t *)&DAT_230c69d0; + pfVar17 = (fdt32_t *)((int)__s + uVar4); + while( true ) { + data = pfVar17 + 1; + len = fdt32_to_cpu(*pfVar17); + if (len == 9) break; + puVar18 = &DAT_230bd280; + if ((len < 10) && + (puVar18 = *(undefined **)(&names_3639 + len * 4), + *(undefined **)(&names_3639 + len * 4) == (undefined *)0x0)) { + puVar18 = &DAT_230bd280; + } + printf("// %04x: tag: 0x%08lx (%s)\r\n",(int)data + (-4 - (int)__s),len,puVar18); + if (len == 1) { + sVar13 = strlen((char *)data); + pfVar2 = data; + if (*(char *)(pfVar17 + 1) == '\0') { + pfVar2 = pfStack72; + } + printf("%*s%s {\r\n",&DAT_230c6dbc,pfVar2); + iVar19 = iVar19 + 1; + pfVar17 = (fdt32_t *)((int)data + sVar13 + 4 & 0xfffffffc); + } + else { + if (len == 2) { + iVar19 = iVar19 + -1; + fmt = "%*s};\r\n"; +LAB_23059ba4: + printf(fmt,&DAT_230c6dbc); + pfVar17 = data; + } + else { + if (len == 4) { + fmt = "%*s// [NOP]\r\n"; + goto LAB_23059ba4; + } + if (len != 3) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %*s ** Unknown tag 0x%08lx\r\n",&DAT_230a9dd8, + "tc_blfdt_dump.c",0xf7,iVar19 << 2,&DAT_230c6dbc,len); + break; + } + data = pfVar17 + 3; + len = fdt32_to_cpu(pfVar17[1]); + uVar4 = fdt32_to_cpu(pfVar17[2]); + iVar16 = (int)__s + uVar5 + uVar4; + if ((uVar6 < 0x10) && (7 < (int)len)) { + data = (fdt32_t *)((uint)((int)pfVar17 + 0x13) & 0xfffffff8); + } + printf("// %04x: string: %s\r\n",iVar16); + printf("// %04x: value\r\n",(fdt32_t *)((int)data - (int)__s)); + printf("%*s%s",iVar19 << 2,&DAT_230c6dbc,iVar16); + utilfdt_print_data((char *)data,len); + pfVar17 = (fdt32_t *)((int)data + len + 3 & 0xfffffffc); + printf(";\r\n"); + } + } + } + printf("dump successed\r\n"); + uVar12 = 0; + } + return uVar12; +} + + + +undefined4 tc_fdt_wifi_module(void) + +{ + int idx; + int parentoffset; + char *format; + int nodeoffset; + uint *puVar1; + TickType_t TVar2; + void *__src; + int iVar3; + undefined4 uVar4; + uint uVar5; + int iStack308; + undefined auStack304 [256]; + + iStack308 = 0; + parentoffset = fdt_subnode_offset(tc_wifi_dtb,0,"wifi"); + if (parentoffset < 1) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0x37; + format = "[%10u][%s: %s:%4d] wifi NULL.\r\n"; + } + else { + nodeoffset = fdt_subnode_offset(tc_wifi_dtb,parentoffset,"region"); + if (0 < nodeoffset) { + puVar1 = (uint *)fdt_getprop(tc_wifi_dtb,nodeoffset,"country_code",&iStack308); + if (puVar1 == (uint *)0x0) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0x42; + format = "[%10u][%s: %s:%4d] country_code NULL.\r\n"; + goto LAB_23059d34; + } + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar5 = *puVar1; + bl_printk("[%10u][%s: %s:%4d] value = %ld, lentmp = %d\r\n",TVar2,&DAT_230bd32c, + "tc_blfdt_wifi.c",0x40, + uVar5 << 0x18 | uVar5 >> 0x18 | (uVar5 >> 8 & 0xff) << 0x10 | + (uVar5 >> 0x10 & 0xff) << 8,iStack308); + } + nodeoffset = fdt_subnode_offset(tc_wifi_dtb,parentoffset,"mac"); + if (0 < nodeoffset) { + __src = fdt_getprop(tc_wifi_dtb,nodeoffset,"sta_mac_addr",&iStack308); + if (iStack308 != 6) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0x52; + format = "[%10u][%s: %s:%4d] sta_mac_addr NULL.\r\n"; + goto LAB_23059d34; + } + memcpy(auStack304,__src,6); + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] sta_mac :\r\n",TVar2,&DAT_230bd32c,"tc_blfdt_wifi.c",0x4f); + log_buf_out("tc_blfdt_wifi.c",0x50,auStack304,6,LOG_BUF_OUT_DATA_TYPE_HEX); + __src = fdt_getprop(tc_wifi_dtb,nodeoffset,"ap_mac_addr",&iStack308); + if (iStack308 == 6) { + memcpy(auStack304,__src,6); + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ap_mac :\r\n",TVar2,&DAT_230bd32c,"tc_blfdt_wifi.c",0x5c); + log_buf_out("tc_blfdt_wifi.c",0x5d,auStack304,6,LOG_BUF_OUT_DATA_TYPE_HEX); + } + } + nodeoffset = fdt_subnode_offset(tc_wifi_dtb,parentoffset,"ap"); + if (nodeoffset < 1) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0x98; + } + else { + iVar3 = fdt_stringlist_count(tc_wifi_dtb,nodeoffset,"ssid"); + if (0 < iVar3) { + idx = 0; + do { + format = fdt_stringlist_get(tc_wifi_dtb,nodeoffset,"ssid",idx,&iStack308); + if (0 < iStack308) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ap string[%d] = %s, lentmp = %d\r\n",TVar2,&DAT_230bd32c, + "tc_blfdt_wifi.c",0x6a,idx,format,iStack308); + } + idx = idx + 1; + } while (iVar3 != idx); + iVar3 = fdt_stringlist_count(tc_wifi_dtb,nodeoffset,"pwd"); + if (iVar3 < 1) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0x7d; + format = "[%10u][%s: %s:%4d] pwd NULL.\r\n"; + } + else { + idx = 0; + do { + format = fdt_stringlist_get(tc_wifi_dtb,nodeoffset,"pwd",idx,&iStack308); + if (0 < iStack308) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwd string[%d] = %s, lentmp = %d\r\n",TVar2, + &DAT_230bd32c,"tc_blfdt_wifi.c",0x79,idx,format,iStack308); + } + idx = idx + 1; + } while (iVar3 != idx); + puVar1 = (uint *)fdt_getprop(tc_wifi_dtb,nodeoffset,"ap_channel",&iStack308); + if (puVar1 == (uint *)0x0) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0x86; + format = "[%10u][%s: %s:%4d] ap_channel NULL.\r\n"; + } + else { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar5 = *puVar1; + bl_printk("[%10u][%s: %s:%4d] ap_channel = %ld\r\n",TVar2,&DAT_230bd32c, + "tc_blfdt_wifi.c",0x84, + uVar5 << 0x18 | uVar5 >> 0x18 | (uVar5 >> 8 & 0xff) << 0x10 | + (uVar5 >> 0x10 & 0xff) << 8); + iVar3 = fdt_stringlist_count(tc_wifi_dtb,nodeoffset,"auto_chan_detect"); + idx = 0; + if (iVar3 < 1) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0x94; + format = "[%10u][%s: %s:%4d] auto_chan_detect NULL.\r\n"; + } + else { + do { + format = fdt_stringlist_get(tc_wifi_dtb,nodeoffset,"auto_chan_detect",idx,&iStack308 + ); + if (0 < iStack308) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] auto_chan_detect string[%d] = %s, lentmp = %d\r\n", + TVar2,&DAT_230bd32c,"tc_blfdt_wifi.c",0x90,idx,format,iStack308); + } + idx = idx + 1; + } while (iVar3 != idx); + parentoffset = fdt_subnode_offset(tc_wifi_dtb,parentoffset,"brd_rf"); + if (parentoffset < 1) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0xdc; + format = "[%10u][%s: %s:%4d] brd_rf NULL.\r\n"; + } + else { + __src = fdt_getprop(tc_wifi_dtb,parentoffset,"xtal",&iStack308); + if (iStack308 == 0x14) { + memcpy(auStack304,__src,0x14); + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] xtal :\r\n",TVar2,&DAT_230bd32c,"tc_blfdt_wifi.c", + 0xa5); + log_buf_out("tc_blfdt_wifi.c",0xa6,auStack304,0x14,LOG_BUF_OUT_DATA_TYPE_HEX); + __src = fdt_getprop(tc_wifi_dtb,parentoffset,"pwr_table",&iStack308); + if (iStack308 != 0x100) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table NULL. lentmp = %d.\r\n",&DAT_230a9dd8, + "tc_blfdt_wifi.c",0xb4,iStack308); + return 0xffffffff; + } + memcpy(auStack304,__src,0x100); + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table :\r\n",TVar2,&DAT_230bd32c, + "tc_blfdt_wifi.c",0xb1); + log_buf_out("tc_blfdt_wifi.c",0xb2,auStack304,0x100,LOG_BUF_OUT_DATA_TYPE_HEX); + __src = fdt_getprop(tc_wifi_dtb,parentoffset,"channel_div_table",&iStack308); + if (iStack308 == 0x3c) { + memcpy(auStack304,__src,0x3c); + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] channel_div_table :\r\n",TVar2,&DAT_230bd32c, + "tc_blfdt_wifi.c",0xbd); + log_buf_out("tc_blfdt_wifi.c",0xbe,auStack304,0x3c,LOG_BUF_OUT_DATA_TYPE_HEX); + __src = fdt_getprop(tc_wifi_dtb,parentoffset,"channel_cnt_table",&iStack308); + if (iStack308 == 0x38) { + memcpy(auStack304,__src,0x38); + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] channel_cnt_table :\r\n",TVar2,&DAT_230bd32c, + "tc_blfdt_wifi.c",0xc9); + log_buf_out("tc_blfdt_wifi.c",0xca,auStack304,0x38,LOG_BUF_OUT_DATA_TYPE_HEX); + __src = fdt_getprop(tc_wifi_dtb,parentoffset,"lo_fcal_div",&iStack308); + if (iStack308 == 4) { + memcpy(auStack304,__src,4); + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] lo_fcal_div :\r\n",TVar2,&DAT_230bd32c, + "tc_blfdt_wifi.c",0xd5); + log_buf_out("tc_blfdt_wifi.c",0xd6,auStack304,4,LOG_BUF_OUT_DATA_TYPE_HEX); + return 0; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0xd8; + format = "[%10u][%s: %s:%4d] lo_fcal_div NULL.\r\n"; + } + else { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0xcc; + format = "[%10u][%s: %s:%4d] channel_cnt_table NULL.\r\n"; + } + } + else { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0xc0; + format = "[%10u][%s: %s:%4d] channel_div_table NULL.\r\n"; + } + } + else { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0xa8; + format = "[%10u][%s: %s:%4d] xtal NULL."; + } + } + } + } + } + goto LAB_23059d34; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0x6e; + } + format = "[%10u][%s: %s:%4d] ap NULL.\r\n"; + } +LAB_23059d34: + bl_printk(format,&DAT_230a9dd8,"tc_blfdt_wifi.c",uVar4); + return 0xffffffff; +} + + + +int tc_fdt_wifi(void) + +{ + int iVar1; + char *fmt; + + iVar1 = tc_fdt_wifi_module(); + if (iVar1 == 0) { + fmt = "fdt wifi module successed\r\n"; + } + else { + fmt = "fdt wifi module failed\r\n"; + } + printf(fmt); + return iVar1; +} + + + +void cmd_blog_info_dump(char *buf,int len,int argc,char **argv) + +{ + blog_info_t *pbVar1; + blog_info_t *pbVar2; + size_t __n; + int iVar3; + char *pcVar4; + byte *pbVar5; + byte **ppbVar6; + char local_b0 [4]; + char name_buf [128]; + + memset(local_b0,0,0x80); + bl_printk("blog code1 = %p - %p\r\n",&_fsymc_info_bloop,&_fsymf_info_bloopbloop_base); + bl_printk("blog code2 = %p - %p\r\n",&_fsymf_info_bloopbloop_base,&_bl_static_blogfile_code_end); + bl_printk("blog code3 = %p - %p\r\n",&_bl_static_blogfile_code_end,&_bl_static_blogfile_code_end); + pbVar1 = &_fsymc_info_bloop; + do { + if ((blog_info_t *)((int)&_fsymc_info_loopset.name + 3U) < pbVar1) { + return; + } + __n = strlen(pbVar1->name); + if (0x80 < __n) { + bl_printk("name too long.\r\n"); + return; + } + if (local_b0[0] == '\0') { +LAB_2305a648: + bl_printk("[%-48s] = [%d]\r\n",pbVar1->name,(uint)*pbVar1->level); + if ((local_b0[0] == '\0') || (iVar3 = strcmp(pbVar1->name,local_b0), iVar3 != 0)) { + pbVar2 = &_fsymf_info_bloopbloop_base; + strcpy(local_b0,pbVar1->name); + while (pbVar2 < (blog_info_t *)&_bl_static_blogfile_code_end) { + pcVar4 = strstr(pbVar2->name,pbVar1->name); + if (pcVar4 == pbVar2->name) { + ppbVar6 = (byte **)&_bl_static_blogfile_code_end; + bl_printk("[%-48s] = [%d]\r\n",pcVar4,(uint)*pbVar2->level); + while (ppbVar6 < &_bl_static_blogfile_code_end) { + pbVar5 = (byte *)strstr((char *)ppbVar6[1],pbVar2->name); + if (pbVar5 == ppbVar6[1]) { + bl_printk("[%-48s] = [%d]\r\n",pbVar5,(uint)**ppbVar6); + } + ppbVar6 = ppbVar6 + 2; + } + } + pbVar2 = pbVar2 + 1; + } + } + } + else { + iVar3 = strcmp(local_b0,pbVar1->name); + if (iVar3 != 0) { + __n = strlen(local_b0); + memset(local_b0,0,__n); + goto LAB_2305a648; + } + } + pbVar1 = pbVar1 + 1; + } while( true ); +} + + + +size_t blog_strcpy(size_t cur_len,char *dst,char *src) + +{ + char cVar1; + char *pcVar2; + + pcVar2 = src; + while ((cVar1 = *pcVar2, cVar1 != '\0' && (pcVar2 + (cur_len - (int)src) < (char *)0x100))) { + pcVar2 = pcVar2 + 1; + *dst = cVar1; + dst = dst + 1; + } + return (size_t)(pcVar2 + -(int)src); +} + + + +void cmd_blog_set_level(char *buf,int len,int argc,char **argv) + +{ + blog_info_t *pbVar1; + int iVar2; + char *format; + size_t sVar3; + int iVar4; + char *__s; + int iVar5; + blog_info_t *pbVar6; + blog_level_t bVar7; + int iVar8; + + if (argc != 3) { + bl_printk("arg error.\r\n"); + goto LAB_2305a716; + } + iVar2 = strcmp(argv[1],"all"); + if (iVar2 == 0) { + bVar7 = BLOG_LEVEL_ALL; +LAB_2305a7c4: + __s = argv[2]; + sVar3 = strlen(__s); + iVar5 = 0; + iVar2 = 0; + while (iVar2 < (int)sVar3) { + if (__s[iVar2] == '.') { + iVar5 = iVar5 + 1; + } + iVar2 = iVar2 + 1; + } + if (iVar5 == 0) { + pbVar1 = &_fsymf_info_bloopbloop_base; + pbVar6 = &_fsymc_info_bloop; + } + else { + if (iVar5 == 1) { + pbVar1 = (blog_info_t *)&_bl_static_blogfile_code_end; + pbVar6 = &_fsymf_info_bloopbloop_base; + } + else { + if (iVar5 != 2) { + __s = argv[2]; + format = "input name = %s not support.\r\n"; + goto LAB_2305a7bc; + } + pbVar1 = (blog_info_t *)&_bl_static_blogfile_code_end; + pbVar6 = (blog_info_t *)&_bl_static_blogfile_code_end; + } + } + iVar2 = ((int)((int)pbVar1 - (int)pbVar6) >> 3) + -1; + iVar5 = 0; + while (__s = argv[2], iVar5 <= iVar2) { + iVar8 = iVar5 + iVar2 >> 1; + pbVar1 = pbVar6 + iVar8; + iVar4 = strcmp(pbVar1->name,__s); + if (iVar4 < 0) { + iVar5 = iVar8 + 1; + } + else { + if (iVar4 == 0) { + *pbVar1->level = bVar7; + bl_printk("set %s = %d\r\n",pbVar1->name,(uint)*pbVar1->level); + return; + } + iVar2 = iVar8 + -1; + } + } + format = "input name = %s not find.\r\n"; + } + else { + iVar2 = strcmp(argv[1],"debug"); + bVar7 = BLOG_LEVEL_DEBUG; + if (iVar2 == 0) goto LAB_2305a7c4; + iVar2 = strcmp(argv[1],"info"); + bVar7 = BLOG_LEVEL_INFO; + if (iVar2 == 0) goto LAB_2305a7c4; + iVar2 = strcmp(argv[1],"warn"); + bVar7 = BLOG_LEVEL_WARN; + if (iVar2 == 0) goto LAB_2305a7c4; + iVar2 = strcmp(argv[1],"error"); + bVar7 = BLOG_LEVEL_ERROR; + if (iVar2 == 0) goto LAB_2305a7c4; + iVar2 = strcmp(argv[1],"assert"); + bVar7 = BLOG_LEVEL_ASSERT; + if (iVar2 == 0) goto LAB_2305a7c4; + iVar2 = strcmp(argv[1],"never"); + bVar7 = BLOG_LEVEL_NEVER; + if (iVar2 == 0) goto LAB_2305a7c4; + __s = argv[1]; + format = "input level = %s not support.\r\n"; + } +LAB_2305a7bc: + bl_printk(format,__s); +LAB_2305a716: + bl_printk("set blog error.\r\n"); + return; +} + + + +void blog_port_output(char *log,size_t size) + +{ + bl_printk("%.*s",log); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void blog_hexdump_out(char *name,uint8_t width,uint8_t *buf,uint16_t size) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + size_t sVar4; + size_t sVar5; + undefined3 in_register_0000202d; + undefined2 in_register_00002036; + uint uVar6; + uint uVar7; + size_t cur_len; + undefined4 uStack72; + char dump_string [8]; + + uVar6 = CONCAT22(in_register_00002036,size); + uStack72 = 0; + dump_string._0_4_ = 0; + uVar1 = 0; + while (uVar1 < uVar6) { + uVar3 = snprintf(log_buf,0x100,"[%s]: %04X-%04X: ",name,uVar1, + CONCAT31(in_register_0000202d,width) + uVar1 + -1); + if (0x100 < uVar3) { + uVar3 = 0x100; + } + cur_len = uVar3 & 0xffff; + uVar7 = 0; + uVar2 = CONCAT31(in_register_0000202d,width) & 0xffff; + uVar3 = uVar1; + while ((uVar7 & 0xffff) < uVar2) { + if ((int)uVar3 < (int)uVar6) { + snprintf((char *)&uStack72,8,"%02X ",(uint)buf[uVar3]); + } + else { + strncpy((char *)&uStack72," ",8); + } + sVar4 = blog_strcpy(cur_len,log_buf + cur_len,(char *)&uStack72); + uVar7 = uVar7 + 1; + cur_len = cur_len + sVar4 & 0xffff; + if ((uVar7 & 7) == 0) { + sVar4 = blog_strcpy(cur_len,log_buf + cur_len," "); + cur_len = cur_len + sVar4 & 0xffff; + } + uVar3 = uVar3 + 1; + } + sVar4 = blog_strcpy(cur_len,log_buf + cur_len," "); + cur_len = sVar4 + cur_len & 0xffff; + uVar3 = uVar1; + while ((uVar3 - uVar1 & 0xffff) < uVar2) { + if ((int)uVar3 < (int)uVar6) { + uVar7 = (uint)buf[uVar3]; + if (0x5e < uVar7 - 0x20) { + uVar7 = 0x2e; + } + snprintf((char *)&uStack72,8,"%c",uVar7); + sVar4 = blog_strcpy(cur_len,log_buf + cur_len,(char *)&uStack72); + cur_len = cur_len + sVar4 & 0xffff; + } + uVar3 = uVar3 + 1; + } + sVar5 = strlen("\r\n"); + if (0x100 < sVar5 + cur_len) { + sVar5 = strlen("\r\n"); + cur_len = 0x100 - sVar5 & 0xffff; + } + sVar4 = blog_strcpy(cur_len,log_buf + cur_len,"\r\n"); + blog_port_output(log_buf,sVar4 + cur_len & 0xffff); + uVar1 = uVar1 + uVar2 & 0xffff; + } + return; +} + + + +void blog_init(void) + +{ + blog_level_t **ppbVar1; + undefined *puVar2; + blog_info_t *pbVar3; + undefined4 *puVar4; + + bl_printk("\r\nblog init set power on level %d, %d, %d.\r\n",2,2); + pbVar3 = &_fsymc_info_bloop; + while (pbVar3 < &_fsymf_info_bloopbloop_base) { + ppbVar1 = &pbVar3->level; + pbVar3 = pbVar3 + 1; + **ppbVar1 = BLOG_LEVEL_INFO; + } + pbVar3 = &_fsymf_info_bloopbloop_base; + while (pbVar3 < (blog_info_t *)&_bl_static_blogfile_code_end) { + ppbVar1 = &pbVar3->level; + pbVar3 = pbVar3 + 1; + **ppbVar1 = BLOG_LEVEL_INFO; + } + puVar4 = (undefined4 *)&_bl_static_blogfile_code_end; + while (puVar4 < &_bl_static_blogfile_code_end) { + puVar2 = (undefined *)*puVar4; + puVar4 = puVar4 + 2; + *puVar2 = 2; + } + return; +} + + + +int ota_dump_cmd(void) + +{ + _dump_partition(); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +void ota_tcp_cmd(char **argv) + +{ + int iVar1; + uint32_t uVar2; + uint8_t uVar3; + hostent *phVar4; + char *s; + int s_00; + uchar *input; + undefined3 extraout_var; + int iVar5; + ssize_t sVar6; + uint addr; + int iVar7; + uint ilen; + int iVar8; + bl_mtd_handle_t local_150; + bl_mtd_handle_t handle; + uint32_t address; + uint32_t bin_size; + sockaddr_in dest; + uint8_t sha256_result [32]; + uint8_t sha256_img [32]; + char str [33]; + byte bStack206; + HALPartition_Entry_Config ptEntry; + iot_sha256_context ctx; + + phVar4 = lwip_gethostbyname(argv[1]); + if (phVar4 == (hostent *)0x0) { + s = "gethostbyname Failed\r\n"; + } + else { + s_00 = bl_mtd_open("FW",&local_150,1); + if (s_00 == 0) { + s_00 = lwip_socket(2,1,0); + if (s_00 < 0) { + printf("Error in socket\r\n"); + } + else { + memset(&bin_size,0,0x10); + bin_size._1_1_ = '\x02'; + bin_size._2_2_ = lwip_htons(0xd05); + handle = (bl_mtd_handle_t)((ip4_addr_t *)((ip4_addr_t *)phVar4->h_addr_list)->addr)->addr; + dest._0_4_ = (ip4_addr_t)handle; + s = ip4addr_ntoa((ip4_addr_t *)&handle); + input = (uchar *)pvPortMalloc(0x200); + uVar3 = hal_boot2_get_active_partition(); + printf("Starting OTA test. OTA bin addr is %p\r\n",input); + printf("[OTA] [TEST] activeID is %u\r\n",CONCAT31(extraout_var,uVar3)); + iVar5 = hal_boot2_get_active_entries(0,(HALPartition_Entry_Config *)(str + 0x20)); + if (iVar5 == 0) { + address = *(uint32_t *)(&ptEntry.type + ((uint)(bStack206 == 0) + 4) * 4); + iVar7 = *(int *)(ptEntry.name + (uint)(bStack206 == 0) * 4 + 5); + printf("Starting OTA test. OTA size is %lu\r\n"); + printf("[OTA] [TEST] activeIndex is %u, use OTA address=%08x\r\n",(uint)bStack206,iVar7); + printf("[OTA] [TEST] Erase flash with size %lu...",address); + bl_mtd_erase_all(local_150); + printf("Done\r\n"); + printf("Server ip Address : %s\r\n",s); + iVar5 = lwip_connect(s_00,(sockaddr *)&bin_size,0x10); + if (iVar5 == 0) { + utils_sha256_init((iot_sha256_context *)&ptEntry.age); + utils_sha256_starts((iot_sha256_context *)&ptEntry.age); + memset(dest.sin_zero + 4,0,0x20); + iVar5 = 0; + uVar2 = 0; + addr = 0; + ilen = 0; +LAB_2305acf6: + while (sVar6 = lwip_read(s_00,input + ilen,0x200 - ilen), -1 < sVar6) { + uVar2 = uVar2 + sVar6; + if (sVar6 == 0) { + printf("[OTA] [TEST] seems ota file ends unexpectedly, already transfer %u\r\n", + uVar2); + goto LAB_2305ad24; + } + printf("total = %d, ret = %d\n\r",uVar2,sVar6); + ilen = ilen + sVar6; + if (iVar5 != 0) { + if (address != uVar2) goto code_r0x2305aecc; + goto LAB_2305aee8; + } + if (0x1ff < ilen) { + if (ilen != 0x200) { + printf("[OTA] [TCP] Assert for unexpected error %d\r\n",ilen); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + memcpy(sha256_img + 0x1c,input,0x10); + str[12] = '\0'; + puts("[OTA] [HEADER] ota header is "); + puts((char *)(sha256_img + 0x1c)); + puts("\r\n"); + memcpy(sha256_img + 0x1c,input + 0x10,4); + str[0] = '\0'; + puts("[OTA] [HEADER] file type is "); + puts((char *)(sha256_img + 0x1c)); + puts("\r\n"); + s = strstr((char *)(sha256_img + 0x1c),"XZ"); + memcpy(&address,input + 0x14,4); + printf("[OTA] [HEADER] file length (exclude ota header) is %lu\r\n",address); + memcpy(sha256_img + 0x1c,input + 0x20,0x10); + str[12] = '\0'; + puts("[OTA] [HEADER] ver_hardware is "); + puts((char *)(sha256_img + 0x1c)); + puts("\r\n"); + memcpy(sha256_img + 0x1c,input + 0x30,0x10); + str[12] = '\0'; + puts("[OTA] [HEADER] ver_software is "); + puts((char *)(sha256_img + 0x1c)); + puts("\r\n"); + memcpy(sha256_img + 0x1c,input + 0x40,0x20); + str[28] = '\0'; + puts("[OTA] [HEADER] sha256 is "); + do { + iVar8 = iVar5 + 0x1c; + iVar5 = iVar5 + 1; + printf("%02X",(uint)sha256_img[iVar8]); + } while (iVar5 != 0x20); + puts("\r\n"); + memcpy(sha256_result + 0x1c,input + 0x40,0x20); + iVar5 = -0x100; + if (s == (char *)0x0) { + iVar5 = -0xfc; + } + uVar2 = uVar2 - 0x200; + printf("[OTA] [TCP] Update bin_size to %lu, file status %s\r\n",address, + iVar5 + 0x230bf000); + ilen = 0; + iVar5 = 1; + } + } + printf("ret = %d, err = %d\n\r",sVar6,errno); +LAB_2305ad24: + lwip_close(s_00); + vPortFree(input); + utils_sha256_free((iot_sha256_context *)&ptEntry.age); + goto LAB_2305abbc; + } + printf("Error in connect\r\n"); + lwip_close(s_00); + } + else { + printf("PtTable_Get_Active_Entries fail\r\n"); + } + vPortFree(input); + } +LAB_2305abbc: + bl_mtd_close(local_150); + return; + } + s = "Open Default FW partition failed\r\n"; + } + puts(s); + return; +code_r0x2305aecc: + if (0x1ff < ilen) { + if (ilen != 0x200) { + printf("[OTA] [TCP] Assert for unexpected error %d\r\n",ilen); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } +LAB_2305aee8: + printf("Will Write %u to %08X from %p\r\n",ilen,iVar7 + addr,input); + utils_sha256_update((iot_sha256_context *)&ptEntry.age,input,ilen); + bl_mtd_write(local_150,addr,ilen,input); + addr = addr + ilen; + ilen = 0; + if (uVar2 == address) { + utils_sha256_finish((iot_sha256_context *)&ptEntry.age,(uint8_t *)(dest.sin_zero + 4)); + puts("\r\nCalculated SHA256 Checksum:"); + do { + iVar8 = ilen + 4; + ilen = ilen + 1; + printf("%02X",(uint)(byte)dest.sin_zero[iVar8]); + } while (ilen != 0x20); + puts("\r\nHeader SET SHA256 Checksum:"); + iVar8 = 0; + do { + iVar1 = iVar8 + 0x1c; + iVar8 = iVar8 + 1; + printf("%02X",(uint)sha256_result[iVar1]); + } while (iVar8 != 0x20); + puts("\r\n"); + iVar8 = memcmp(sha256_result + 0x1c,dest.sin_zero + 4,0x20); + if (iVar8 != 0) { + printf("[OTA] [TCP] SHA256 NOT Correct\r\n"); + goto LAB_2305ad24; + } + printf("[OTA] [TCP] prepare OTA partition info\r\n"); + ptEntry.maxLen[1] = address; + printf("[OTA] [TCP] Update PARTITION, partition len is %lu\r\n"); + hal_boot2_update_ptable((HALPartition_Entry_Config *)(str + 0x20)); + printf("[OTA] [TCP] Rebooting\r\n"); + hal_reboot(); + ilen = 0; + } + } + goto LAB_2305acf6; +} + + + +void ota_tcp_cmd(char *buf,int len,int argc,char **argv) + +{ + if (argc != 2) { + printf("Usage: %s IP\r\n",*argv); + return; + } + ota_tcp_cmd(argv); + return; +} + + + +int bl_sys_ota_cli_init(void) + +{ + return 0; +} + + + +void wifiprov_ccc_cfg_changed(bt_gatt_attr *attr,u16_t value) + +{ + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void __bl_ble_sync_task(void *p_arg) + +{ + uint16_t mtu; + u16_t uVar1; + pro_handle_t ppVar2; + QueueHandle_t pQVar3; + BaseType_t BVar4; + int iVar5; + TickType_t TVar6; + undefined auStack308 [4]; + queue_buf recv_buf; + + cJSON_InitHooks(&__g_cjson_hooks); + ppVar2 = pro_trans_init((pro_dev *)((int)p_arg + 0xef0),&ble_gatt_func,(void *)0x0); + *(pro_handle_t *)((int)p_arg + 0x40c) = ppVar2; + *(undefined *)((int)p_arg + 0x61e) = 1; + pQVar3 = xQueueGenericCreateStatic(1,0,(uint8_t *)0x0,(StaticQueue_t *)((int)p_arg + 4),'\x03'); + *(QueueHandle_t *)p_arg = pQVar3; + pQVar3 = xQueueGenericCreateStatic + (2,0x104,(uint8_t *)((int)p_arg + 0x100),(StaticQueue_t *)((int)p_arg + 0xb0), + '\0'); + *(QueueHandle_t *)((int)p_arg + 0xac) = pQVar3; + mtu = 0; + while (*(char *)((int)p_arg + 0x620) == '\0') { + BVar4 = xQueueReceive(*(QueueHandle_t *)((int)p_arg + 0xac),auStack308,10000); + if (BVar4 == 1) { + if (*(bt_conn **)((int)p_arg + 0x684) != (bt_conn *)0x0) { + uVar1 = bt_gatt_get_mtu(*(bt_conn **)((int)p_arg + 0x684)); + mtu = uVar1 - 3; + } + iVar5 = pro_trans_read(*(pro_handle_t *)((int)p_arg + 0x40c),auStack308,recv_buf.buf._252_4_, + mtu); + if (((iVar5 != 0) && (_fsymc_level_blsync_ble < BLOG_LEVEL_WARN)) && + (_fsymf_level_blsync_bleblsync_ble < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar6 = xTaskGetTickCount(); + } + else { + TVar6 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] protocol analyze failed\r\n",TVar6,&DAT_230bd32c, + "blsync_ble.c",0x142); + } + } + else { + pro_trans_reset(*(pro_handle_t *)((int)p_arg + 0x40c)); + } + } + *(undefined *)((int)p_arg + 0x61e) = 0; + vTaskDelete(*(TaskHandle_t *)((int)p_arg + 0xee8)); + return; +} + + + +void scan_complete_cb(void *param) + +{ + byte bVar1; + bl_ble_sync_t *pbVar2; + + pbVar2 = gp_index; + gp_index->scaning = '\0'; + bVar1 = pbVar2->w_ap_item; + if (bVar1 < 0x32) { + memcpy(pbVar2->ap_item + bVar1,param,0x30); + gp_index->w_ap_item = gp_index->w_ap_item + '\x01'; + } + return; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +int __recv_event(void *p_drv,pro_event *p_event) + +{ + event_type_t eVar1; + bl_ble_sync_t *pbVar2; + blog_level_t bVar3; + SemaphoreHandle_t *ppQVar4; + pro_handle_t handle; + TickType_t TVar5; + wifi_conn *__dest; + code *pcVar6; + BaseType_t BVar7; + cJSON *object; + cJSON *item; + char *__s; + void *__src; + size_t bytes; + uint uVar8; + blesync_wifi_func *pbVar9; + anon_subr_void_wifi_conn_ptr_for_local_connect_remote_ap *paVar10; + anon_subr_void_for_local_disconnect_remote_ap *paVar11; + anon_subr_void_anon_subr_void_void_ptr_ptr_for_local_wifi_state_get *paVar12; + undefined4 uStack52; + char bssid [20]; + + uStack52 = 0; + bssid._0_4_ = 0; + bssid._4_4_ = 0; + bssid._8_4_ = 0; + bssid._12_4_ = 0; + if ((_fsymc_level_blsync_ble < BLOG_LEVEL_WARN) && + (_fsymf_level_blsync_bleblsync_ble < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] event type %d, id %d\r\n",TVar5,&DAT_230bd32c,"blsync_ble.c",0xa0, + (uint)p_event->type,p_event->event_id); + } + bVar3 = _fsymc_level_blsync_ble; + pbVar2 = gp_index; + eVar1 = p_event->type; + if (eVar1 == PROTOCOL_EVENT_DATA) { + uVar8 = p_event->event_id; + if (uVar8 == 2) { + memset(&gp_index->conn_info,0,0x20); + pbVar2 = gp_index; + (gp_index->conn_info).ssid_tail[0] = '\0'; + bytes = p_event->length; + __src = p_event->p_buf; + __dest = &pbVar2->conn_info; + } + else { + if (uVar8 != 3) { + if (uVar8 != (uint)eVar1) { + return 2; + } + return 0; + } + memset((gp_index->conn_info).pask,0,0x40); + bytes = p_event->length; + __src = p_event->p_buf; + __dest = (wifi_conn *)(gp_index->conn_info).pask; + } + memcpy(__dest,__src,bytes); + return 0; + } + if (eVar1 != PROTOCOL_EVENT_CMD) { + return 0; + } + switch(p_event->event_id) { + case 3: + pcVar6 = (code *)&gp_index->conn_info; + paVar10 = gp_index->wifi_func->local_connect_remote_ap; + if (paVar10 == (anon_subr_void_wifi_conn_ptr_for_local_connect_remote_ap *)0x0) { + return 0; + } + break; + case 4: + paVar11 = gp_index->wifi_func->local_disconnect_remote_ap; + if (paVar11 != (anon_subr_void_for_local_disconnect_remote_ap *)0x0) { + (*paVar11)(); + return 0; + } + return 0; + default: + return 2; + case 7: + pro_trans_layer_ack_read(gp_index->pro_handle,"v1.1.0",7); + return 0; + case 9: + pbVar9 = gp_index->wifi_func; + if (pbVar9->local_wifi_scan == + (anon_subr_void_anon_subr_void_void_ptr_ptr_for_local_wifi_scan *)0x0) { + return 0; + } + *(undefined2 *)&gp_index->w_ap_item = 0; + pbVar2->scaning = '\x01'; + paVar10 = (anon_subr_void_wifi_conn_ptr_for_local_connect_remote_ap *)pbVar9->local_wifi_scan; + pcVar6 = scan_complete_cb; + break; + case 0xb: + if (gp_index->w_ap_item == 0) { + return 1; + } + uVar8 = (uint)gp_index->r_ap_item; + if ((uint)gp_index->w_ap_item == uVar8) { + *(undefined2 *)&gp_index->w_ap_item = 0; + if (BLOG_LEVEL_INFO < bVar3) { + return 0; + } + if (_fsymf_level_blsync_bleblsync_ble < BLOG_LEVEL_WARN) { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] wifi list end\r\n",TVar5,&DAT_230bd32c,"blsync_ble.c",0xd2); + return 0; + } + return 0; + } + if ((_fsymc_level_blsync_ble < BLOG_LEVEL_WARN) && + (_fsymf_level_blsync_bleblsync_ble < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + gp_index->r_ap_item = gp_index->r_ap_item + '\x01'; + bl_printk("[%10u][%s: %s:%4d] item_nums %d\r\n",TVar5,&DAT_230bd32c,"blsync_ble.c",0xd6); + } + object = cJSON_CreateObject(); + ppQVar4 = &pbVar2->xSemaphore + uVar8 * 0xc; + sprintf((char *)&uStack52,"%02X:%02X:%02X:%02X:%02X:%02X",(uint)*(byte *)(ppQVar4 + 0x3f1), + (uint)*(byte *)((int)ppQVar4 + 0xfc5),(uint)*(byte *)((int)ppQVar4 + 0xfc6), + (uint)*(byte *)((int)ppQVar4 + 0xfc7),(uint)*(byte *)(ppQVar4 + 0x3f2), + (uint)*(byte *)((int)ppQVar4 + 0xfc9)); + __floatunsidf((uint)*(byte *)((int)ppQVar4 + 0xfca)); + item = cJSON_CreateNumber(); + cJSON_AddItemToObject(object,"chan",item); + item = cJSON_CreateString((char *)&uStack52); + cJSON_AddItemToObject(object,"bssid",item); + __floatsidf((int)*(char *)(ppQVar4 + 0x3f3)); + item = cJSON_CreateNumber(); + cJSON_AddItemToObject(object,"rssi",item); + item = cJSON_CreateString((char *)(pbVar2->ap_item + uVar8)); + cJSON_AddItemToObject(object,"ssid",item); + __floatunsidf((uint)*(byte *)((int)ppQVar4 + 0xfcb)); + item = cJSON_CreateNumber(); + cJSON_AddItemToObject(object,"auth",item); + __s = cJSON_Print(object); + handle = gp_index->pro_handle; + bytes = strlen(__s); + pro_trans_layer_ack_read(handle,__s,bytes); + cJSON_Delete(object); + goto LAB_2305b4c2; + case 0xc: + paVar10 = (anon_subr_void_wifi_conn_ptr_for_local_connect_remote_ap *)gp_index->complete_cb; + if (paVar10 == (anon_subr_void_wifi_conn_ptr_for_local_connect_remote_ap *)0x0) { + return 0; + } + pcVar6 = (code *)gp_index->p_arg; + break; + case 0xd: + paVar12 = gp_index->wifi_func->local_wifi_state_get; + if (paVar12 == (anon_subr_void_anon_subr_void_void_ptr_ptr_for_local_wifi_state_get *)0x0) { + return 0; + } + (*paVar12)(wifi_state_get_cb); + BVar7 = xQueueSemaphoreTake((QueueHandle_t)gp_index->xSemaphore,10000); + if (BVar7 != 1) { + return 2; + } + sprintf((char *)&uStack52,"%02X:%02X:%02X:%02X:%02X:%02X",(uint)(gp_index->state).bssid[0], + (uint)(gp_index->state).bssid[1],(uint)(gp_index->state).bssid[2], + (uint)(gp_index->state).bssid[3],(uint)(gp_index->state).bssid[4], + (uint)(gp_index->state).bssid[5]); + object = cJSON_CreateObject(); + __floatunsidf((uint)(gp_index->state).state); + item = cJSON_CreateNumber(); + cJSON_AddItemToObject(object,"state",item); + item = cJSON_CreateString((char *)&gp_index->state); + cJSON_AddItemToObject(object,"ip",item); + item = cJSON_CreateString((gp_index->state).gw); + cJSON_AddItemToObject(object,"gw",item); + item = cJSON_CreateString((gp_index->state).mask); + cJSON_AddItemToObject(object,"mask",item); + item = cJSON_CreateString((gp_index->state).ssid); + cJSON_AddItemToObject(object,"ssid",item); + item = cJSON_CreateString((char *)&uStack52); + cJSON_AddItemToObject(object,"bssid",item); + __s = cJSON_Print(object); + handle = gp_index->pro_handle; + bytes = strlen(__s); + pro_trans_layer_ack_read(handle,__s,bytes); + cJSON_Delete(object); +LAB_2305b4c2: + vPortFree(__s); + return 0; + } + (*paVar10)(pcVar6); + return 0; +} + + + +void wifi_state_get_cb(void *p_arg) + +{ + bl_ble_sync_t *pbVar1; + + pbVar1 = gp_index; + memcpy(&gp_index->state,p_arg,0x58); + xQueueGenericSend((QueueHandle_t)pbVar1->xSemaphore,(void *)0x0,0,0); + return; +} + + + +size_t write_data(bt_conn *param_1,uint8_t *param_2,size_t param_3) + +{ + bl_ble_sync_t *pbVar1; + blog_level_t bVar2; + TickType_t TVar3; + + bVar2 = _fsymc_level_blsync_ble; + gp_index->p_cur_conn = param_1; + if ((bVar2 < BLOG_LEVEL_WARN) && (_fsymf_level_blsync_bleblsync_ble < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] write length %d\r\n",TVar3,&DAT_230bd32c,"blsync_ble.c",0x7c, + param_3); + if ((_fsymc_level_blsync_ble < BLOG_LEVEL_WARN) && + (_fsymf_level_blsync_bleblsync_ble < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %s:\r\n",TVar3,&DAT_230bd32c,"blsync_ble.c",0x7d,0x230c73c8); + blog_hexdump_out("data",'\x10',param_2,(uint16_t)param_3); + } + } + pbVar1 = gp_index; + (gp_index->send_buf).len = param_3; + memcpy(&pbVar1->send_buf,param_2,param_3); + xQueueGenericSend(gp_index->xQueue1,&gp_index->send_buf,0,0); + return param_3; +} + + + +undefined4 __ble_bytes_send(uint8_t *param_1,uint param_2) + +{ + blog_level_t bVar1; + undefined4 uVar2; + TickType_t TVar3; + + uVar2 = 0xffffffff; + if ((gp_index->p_cur_conn != (bt_conn *)0x0) && (param_2 < 0x100)) { + memcpy(gp_index->attr_read_buf,param_1,param_2); + bVar1 = _fsymc_level_blsync_ble; + gp_index->rbuf_len = (uint16_t)param_2; + if ((bVar1 < BLOG_LEVEL_WARN) && (_fsymf_level_blsync_bleblsync_ble < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ble send size %d\r\n",&DAT_230bd32c,"blsync_ble.c",0x91,param_2 + ); + if ((_fsymc_level_blsync_ble < BLOG_LEVEL_WARN) && + (_fsymf_level_blsync_bleblsync_ble < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %s:\r\n",TVar3,&DAT_230bd32c,"blsync_ble.c",0x93,0x230c73c8); + blog_hexdump_out("data",'\x10',param_1,(uint16_t)param_2); + } + } + printf("\r\n"); + uVar2 = 0; + } + return uVar2; +} + + + +void blsync_disconnected(bt_conn *conn,u8_t reason) + +{ + printf("disconnected (reason %u)%s\r\n"); + blsync_conn = (bt_conn *)0x0; + return; +} + + + +void blsync_exchange_func(bt_conn *conn,u8_t err,bt_gatt_exchange_params *params) + +{ + undefined3 in_register_0000202d; + char *pcVar1; + + if (CONCAT31(in_register_0000202d,err) == 0) { + pcVar1 = "successful"; + } + else { + pcVar1 = "failed"; + } + printf("Exchange %s\r\n",pcVar1); + return; +} + + + +ssize_t read_data(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset) + +{ + TickType_t TVar1; + ssize_t sVar2; + + if (gp_index->rbuf_len == 0) { + sVar2 = -4; + } + else { + if ((_fsymc_level_blsync_ble < BLOG_LEVEL_WARN) && + (_fsymf_level_blsync_bleblsync_ble < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] read length %d\r\n",TVar1,&DAT_230bd32c,"blsync_ble.c",0x6d, + (uint)gp_index->rbuf_len); + } + pro_trans_ack(gp_index->pro_handle); + sVar2 = bt_gatt_attr_read(conn,attr,buf,len,offset,gp_index->attr_read_buf,gp_index->rbuf_len); + gp_index->rbuf_len = 0; + } + return sVar2; +} + + + +void blsync_connected(bt_conn *conn,u8_t err) + +{ + char "blsync_connected" [17]; + int iVar1; + + printf("%s\n","blsync_connected"); + blsync_conn = conn; + iVar1 = bt_le_set_data_len(conn,0xfb,0x848); + if (iVar1 == 0) { + printf("Set data length success.\n"); + } + else { + printf("Set data length failure, err: %d\n",iVar1); + } + blsync_exchg_mtu.func = blsync_exchange_func; + iVar1 = bt_gatt_exchange_mtu(blsync_conn,&blsync_exchg_mtu); + if (iVar1 == 0) { + printf("Exchange mtu size pending.\n",0); + return; + } + printf("Exchange mtu size failure, err: %d\n",iVar1); + return; +} + + + +int bl_ble_sync_start(bl_ble_sync_t *index,blesync_wifi_func *func,pfn_complete_cb_t *cb, + void *cb_arg) + +{ + uint uVar1; + int iVar2; + TickType_t TVar3; + TaskHandle_t ptVar4; + + if ((index == (bl_ble_sync_t *)0x0) || (func == (blesync_wifi_func *)0x0)) { + iVar2 = -1; + if ((_fsymc_level_blsync_ble < BLOG_LEVEL_WARN) && + (_fsymf_level_blsync_bleblsync_ble < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ble sync init failed\r\n",TVar3,&DAT_230bd32c,"blsync_ble.c", + 0x16d); + iVar2 = -1; + } + } + else { + memset(index,0,0x1908); + uVar1 = isRegister; + gp_index = index; + index->wifi_func = func; + index->complete_cb = cb; + index->p_arg = cb_arg; + *(undefined2 *)&index->task_runing = 0; + index->stop_flag = '\0'; + if (uVar1 == 0) { + isRegister = 1; + bt_conn_cb_register(&blsync_conn_callbacks); + } + bt_gatt_service_register(&wifiprov_server); + ptVar4 = xTaskCreateStatic(__bl_ble_sync_task,"pro",0x200,index,10,index->stack,&index->task); + index->task_handle = ptVar4; + iVar2 = 0; + } + return iVar2; +} + + + +int bl_ble_sync_stop(bl_ble_sync_t *index) + +{ + TaskHandle_t ptVar1; + + if (index == (bl_ble_sync_t *)0x0) { + return -1; + } + bt_gatt_service_unregister(&wifiprov_server); + index->stop_flag = '\x01'; + ptVar1 = xTaskGetCurrentTaskHandle(); + if (gp_index->task_handle == ptVar1) { + while (gp_index->scaning == '\x01') { + vTaskDelay(10); + } + vTaskDelete(index->task_handle); + } + else { + while ((gp_index->scaning == '\x01' || (index->task_runing == '\x01'))) { + vTaskDelay(10); + } + } + return 0; +} + + + +void * __malloc(size_t size) + +{ + void *pvVar1; + TickType_t TVar2; + + pvVar1 = pvPortMalloc(size); + if (((pvVar1 != (void *)0x0) && (_fsymc_level_blsync_ble < BLOG_LEVEL_WARN)) && + (_fsymf_level_blsync_bletransfer < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] malloc %p\r\n",TVar2,&DAT_230bd32c,"transfer.c",0x1e,pvVar1); + } + return pvVar1; +} + + + +void __free(void *ptr) + +{ + TickType_t TVar1; + + if (((ptr != (void *)0x0) && (_fsymc_level_blsync_ble < BLOG_LEVEL_WARN)) && + (_fsymf_level_blsync_bletransfer < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] free %p\r\n",TVar1,&DAT_230bd32c,"transfer.c",0x14,ptr); + } + vPortFree(ptr); + return; +} + + + +void __clear_dev(pro_handle_t handle) + +{ + *(undefined4 *)&handle->tol_len_now = 0; + __free(handle->pyld_buf); + handle->pyld_buf = (uint8_t *)0x0; + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int __protocol_send(pro_handle_t handle,uint8_t seq,uint8_t ack,uint8_t type,void *p_data, + uint16_t length) + +{ + ushort uVar1; + bool bVar2; + void *__dest; + BaseType_t BVar3; + undefined3 in_register_00002031; + undefined2 in_register_0000203e; + uint uVar4; + int iVar5; + uint uVar6; + char *pcVar7; + char cVar8; + uint uVar9; + byte bStack69; + byte bStack68; + uint8_t uStack67; + uint8_t dst_len; + ushort uStack66; + general_head head; + + uVar4 = CONCAT22(in_register_0000203e,length); + bStack68 = 0; + uStack66 = 0; + if (CONCAT31(in_register_00002031,ack) != 0) { + bStack68 = 8; + } + uVar6 = 0xfffffffd; + bStack68 = bStack68 | 0x10; + uStack67 = seq; + __dest = __malloc((uint)handle->mtu); + if (__dest != (void *)0x0) { + uVar9 = 0; + do { + bStack69 = 4; + uVar1 = handle->mtu; + if (uVar9 == 0) { + *(char *)((int)__dest + 4) = (char)length; + iVar5 = (uint)uVar1 - 6; + *(undefined *)((int)__dest + 5) = (char)(length >> 8); + bStack69 = 6; + handle->enc_handle->is_head = '\x01'; + cVar8 = '\x06'; + pcVar7 = (char *)((int)__dest + 6); + } + else { + iVar5 = (uint)uVar1 - 4; + cVar8 = '\x04'; + pcVar7 = (char *)((int)__dest + 4); + } + bStack69 = bStack69 + 1; + uVar6 = (*handle->enc_handle->pfnc->pfn_enc_write) + (handle->enc_handle->p_drv,'\x01',type,(uint8_t *)(pcVar7 + 1),&bStack69, + (uint8_t *)((int)p_data + uVar9),(char)length - (char)uVar9, + (int16_t)((uint)(((iVar5 * 0x10000 >> 0x10) + -1) * 0x10000) >> 0x10)); + handle->enc_handle->is_head = '\0'; + if ((int)uVar6 < 0) break; + uVar9 = uVar9 + (uVar6 & 0xff) & 0xffff; + if (uVar9 < uVar4) { + bVar2 = false; + } + else { + if (uVar4 != uVar9) { + uVar6 = 0xfffffffe; + break; + } + uStack66 = uStack66 | 0x8000; + bVar2 = true; + } + if ((uVar6 & 0xff) < uVar4) { + bStack68 = bStack68 | 2; + } + memcpy(__dest,&bStack68,2); + *(undefined *)((int)__dest + 2) = (char)uStack66; + *(undefined *)((int)__dest + 3) = (char)(uStack66 >> 8); + *pcVar7 = (bStack69 - 1) - cVar8; + (*handle->p_func->pfu_bytes_send)((void *)0x0,__dest,(uint)bStack69); + uStack67 = uStack67 + '\x01'; + uStack66 = uStack66 + 1; + BVar3 = xQueueSemaphoreTake((QueueHandle_t)handle->xSemaphore,10000); + if (BVar3 != 1) { + uVar6 = 0xfffffffc; + break; + } + } while (!bVar2); + __free(__dest); + } + return uVar6; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int pro_trans_read(pro_handle_t handle,void *buf,size_t bytes,uint16_t mtu) + +{ + uint8_t uVar1; + uint8_t *puVar2; + TickType_t TVar3; + uint8_t *puVar4; + uint uVar5; + int iVar6; + size_t sVar7; + int iVar8; + event_type_t eVar9; + byte local_36; + uint8_t uStack53; + byte bStack52; + uint8_t uStack51; + uint8_t dst_len; + uint8_t ev_id; + general_head head; + pro_event ev; + + if (handle == (pro_handle_t)0x0) { + return -2; + } + if (buf == (void *)0x0) { + return -2; + } + handle->mtu = mtu; + memcpy(&bStack52,buf,2); + uVar1 = uStack51; + if ((bStack52 & 1) != 0) { + if (handle->old_seq != uStack51) { + TVar3 = xTaskGetTickCount(); + *(TickType_t *)&handle->seq_start_ms = TVar3; + *(undefined4 *)((int)&handle->seq_start_ms + 4) = 0; + handle->old_seq = uVar1; + } + if ((*(uint *)&handle->seq_start_ms | *(uint *)((int)&handle->seq_start_ms + 4)) != 0) { + TVar3 = xTaskGetTickCount(); + iVar6 = *(int *)((int)&handle->seq_start_ms + 4); + uVar5 = TVar3 - *(int *)&handle->seq_start_ms; + iVar8 = -(uint)(TVar3 < uVar5); + if ((0 < iVar8 - iVar6) || ((iVar8 == iVar6 && (10000 < uVar5)))) { + __clear_dev(handle); + if (BLOG_LEVEL_INFO < _fsymc_level_blsync_ble) { + return -4; + } + if (BLOG_LEVEL_INFO < _fsymf_level_blsync_bletransfer) { + return -4; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] -----------timeout-----------\r\n",TVar3,&DAT_230bd32c, + "transfer.c",0x145); + return -4; + } + } + } + _dst_len = *(ushort *)((int)buf + 2); + eVar9 = bStack52 >> 4 & 3; + sVar7 = (size_t)*(byte *)((int)buf + 4); + if ((_dst_len & 0x7fff) == 0) { + puVar2 = (uint8_t *)((int)buf + 7); + handle->total_length = CONCAT11(*(undefined *)((int)buf + 5),*(byte *)((int)buf + 4)); + sVar7 = (size_t)*(byte *)((int)buf + 6); + if (bytes - 4 == sVar7 + 3) { + if (handle->pyld_buf != (uint8_t *)0x0) { + __clear_dev(handle); + } + if (handle->total_length == 0) { +LAB_2305bf76: + handle->enc_handle->is_head = '\x01'; + goto LAB_2305bf7e; + } + puVar4 = (uint8_t *)__malloc((uint)handle->total_length); + handle->pyld_buf = puVar4; + if (puVar4 != (uint8_t *)0x0) goto LAB_2305bf76; +LAB_2305bfb4: + iVar8 = -3; + goto __end; + } +LAB_2305bf62: + iVar8 = -2; + } + else { + puVar2 = (uint8_t *)((int)buf + 5); + if (bytes - 4 != sVar7 + 1) goto LAB_2305bf62; + handle->enc_handle->is_head = '\0'; +LAB_2305bf7e: + iVar8 = (*handle->enc_handle->pfnc->pfn_enc_read) + (handle->enc_handle->p_drv,eVar9,&uStack53, + handle->pyld_buf + handle->tol_len_now,&local_36,puVar2,sVar7); + if (iVar8 == 0) { + uVar5 = (uint)handle->tol_len_now + (uint)local_36; + handle->tol_len_now = (uint16_t)(uVar5 * 0x10000 >> 0x10); + if (((bStack52 & 2) != 0) && (-1 < (short)_dst_len)) goto __end; + if ((uint)handle->total_length != (uVar5 & 0xffff)) { + __clear_dev(handle); + goto LAB_2305bf62; + } + head.ctrl = eVar9; + if (handle->p_func->pfn_recv_event != + (anon_subr_int_void_ptr_pro_event_ptr_for_pfn_recv_event *)0x0) { + puVar2 = (uint8_t *)__malloc(0x100); + handle->ack_buf = puVar2; + if (puVar2 == (uint8_t *)0x0) goto LAB_2305bfb4; + iVar8 = (*handle->p_func->pfn_recv_event)(handle->p_drv,(pro_event *)&head); + } + } + __clear_dev(handle); + } +__end: + if ((bStack52 >> 3 & 1) == 0) { + __protocol_send(handle,uStack51,'\x01',(uint8_t)iVar8,handle->ack_buf, + (ushort)*(byte *)&handle->ack_len); + } + handle->ack_len = 0; + __free(handle->ack_buf); + handle->ack_buf = (uint8_t *)0x0; + return iVar8; +} + + + +int pro_trans_ack(pro_handle_t handle) + +{ + BaseType_t BVar1; + int iVar2; + + BVar1 = xQueueGenericSend((QueueHandle_t)handle->xSemaphore,(void *)0x0,0,0); + if (BVar1 == 1) { + iVar2 = 0; + } + else { + iVar2 = 2; + } + return iVar2; +} + + + +int pro_trans_layer_ack_read(pro_handle_t handle,void *ack_buf,size_t bytes) + +{ + int iVar1; + + if ((handle != (pro_handle_t)0x0) && (iVar1 = -2, ack_buf != (void *)0x0)) { + if (bytes < 0x101) { + iVar1 = -3; + if (handle->ack_buf != (uint8_t *)0x0) { + memcpy(handle->ack_buf,ack_buf,bytes); + iVar1 = 0; + handle->ack_len = (uint16_t)bytes; + } + } + return iVar1; + } + return -2; +} + + + +pro_handle_t pro_trans_init(pro_dev *p_dev,pro_func *p_func,void *p_drv) + +{ + enc_handle_t peVar1; + QueueHandle_t pQVar2; + + memset(p_dev,0,0xb0); + peVar1 = pro_encrypt_init(&p_dev->enc,&p_dev->enc); + p_dev->enc_handle = peVar1; + p_dev->p_func = p_func; + p_dev->p_drv = p_drv; + pQVar2 = xQueueGenericCreateStatic + (1,0,(uint8_t *)0x0,(StaticQueue_t *)&p_dev->xSemaphoreBuffer,'\x03'); + *(QueueHandle_t *)&p_dev->xSemaphore = pQVar2; + return (pro_handle_t)p_dev; +} + + + +void pro_trans_reset(pro_handle_t handle) + +{ + *(undefined4 *)&handle->tol_len_now = 0; + __free(handle->pyld_buf); + handle->pyld_buf = (uint8_t *)0x0; + return; +} + + + +int __pack_encrypt_read(void *p_drv,uint8_t pack_type,uint8_t *dst_id,uint8_t *dst_buf, + uint8_t *dst_len,uint8_t *src_buf,size_t src_lenght) + +{ + int iVar1; + undefined3 in_register_0000202d; + uint uVar2; + + if (*(char *)((int)p_drv + 0x10) == '\0') { + src_buf = src_buf + 1; + uVar2 = src_lenght - 1; + } + else { + src_buf = src_buf + 9; + uVar2 = src_lenght - 9; + } + *(bool *)((int)p_drv + 0xc) = CONCAT31(in_register_0000202d,pack_type) != 0; + // WARNING: Could not recover jumptable at 0x2305c138. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (**(code **)**(code ***)p_drv)((*(code ***)p_drv)[1],dst_buf,dst_len,src_buf,uVar2 & 0xff) + ; + return iVar1; +} + + + +int __pack_encrypt_write + (void *p_drv,uint8_t pack_type,uint8_t src_id,uint8_t *dst_buf,uint8_t *dst_len, + uint8_t *src_buf,uint8_t src_len,int16_t remain_len) + +{ + int iVar1; + undefined3 in_register_00002031; + undefined3 in_register_00002041; + short sVar2; + + *dst_buf = '\0'; + if (*(char *)((int)p_drv + 0x10) == '\0') { + dst_buf = dst_buf + 1; + sVar2 = remain_len + -1; + *dst_len = *dst_len + '\x01'; + } + else { + dst_buf[1] = '\0'; + dst_buf[2] = '\0'; + dst_buf[3] = '\0'; + dst_buf[4] = '\0'; + dst_buf[5] = '\0'; + dst_buf[6] = '\0'; + dst_buf[7] = '\0'; + dst_buf[8] = '\0'; + dst_buf = dst_buf + 9; + sVar2 = remain_len + -9; + *dst_len = *dst_len + '\t'; + } + *(undefined *)((int)p_drv + 0xc) = 1; + // WARNING: Could not recover jumptable at 0x2305c1a4. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (**(code **)(**(int **)p_drv + 4)) + ((*(int **)p_drv)[1],dst_buf,CONCAT31(in_register_00002031,src_id),src_buf, + CONCAT31(in_register_00002041,src_len),(int)sVar2); + return iVar1; +} + + + +enc_handle_t pro_encrypt_init(encrypt *p_enc,void *p_drv) + +{ + pyld_handle_t ppVar1; + + ppVar1 = pro_payload_init(&p_enc->pyld,&p_enc->pyld); + p_enc->pyld_handle = ppVar1; + p_enc->p_drv = p_drv; + p_enc->pfnc = &__g_enc_func; + return (enc_handle_t)p_enc; +} + + + +int __payload_write(void *p_arg,uint8_t *dst_buf,uint8_t *dst_len,uint8_t src_id,uint8_t *src_buf, + uint8_t src_len,int16_t remain_len) + +{ + uint8_t uVar1; + undefined3 in_register_0000203d; + uint uVar2; + short in_register_00002042; + uint __n; + + uVar2 = CONCAT31(in_register_0000203d,src_len); + if (in_register_00002042 < 0) { + return -2; + } + if (*(char *)((int)p_arg + 8) == '\0') { + __n = (int)(((uint)(ushort)remain_len - 1) * 0x10000) >> 0x10; + if ((int)uVar2 < (int)__n) { + __n = uVar2; + } + __n = __n & 0xff; + if (__n != 4) { + return -2; + } + *dst_buf = src_id; + memcpy(dst_buf + 1,src_buf,4); + uVar1 = *dst_len + '\x05'; + } + else { + __n = (int)(((uint)(ushort)remain_len - 2) * 0x10000) >> 0x10; + if ((int)uVar2 < (int)__n) { + __n = uVar2; + } + __n = __n & 0xff; + *dst_buf = (uint8_t)__n; + dst_buf[1] = src_id; + memcpy(dst_buf + 2,src_buf,__n); + uVar1 = *dst_len + '\x02' + (uint8_t)__n; + } + *dst_len = uVar1; + return __n; +} + + + +int __payload_read(void *p_arg,uint8_t *dst_buf,uint8_t *dst_type,uint8_t *dst_len,uint8_t *src_buf, + uint8_t src_len) + +{ + byte bVar1; + uint8_t *__src; + undefined3 in_register_0000203d; + uint uVar2; + + if (*(char *)((int)p_arg + 8) == '\0') { + if (CONCAT31(in_register_0000203d,src_len) != 5) { + return -2; + } + *dst_len = '\x04'; + __src = src_buf + 1; + *dst_type = *src_buf; + bVar1 = *dst_len; + } + else { + uVar2 = CONCAT31(in_register_0000203d,src_len) - 2; + if (uVar2 != (uint)*src_buf) { + return -2; + } + *dst_len = (uint8_t)uVar2; + __src = src_buf + 2; + *dst_type = src_buf[1]; + bVar1 = *dst_len; + } + memcpy(dst_buf,__src,(uint)bVar1); + return 0; +} + + + +pyld_handle_t pro_payload_init(payload *p_pyld,void *p_drv) + +{ + p_pyld->pfnc = (pro_pyld_func *)0x230cbaa4; + p_pyld->p_drv = p_drv; + return (pyld_handle_t)p_pyld; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void cmd_sys_time_now(char *buf,int len,int argc,char **argv) + +{ + UDItype UVar1; + undefined4 local_30; + uint64_t epoch_ms; + undefined auStack36 [4]; + utils_time_date_t date; + + local_30 = 0; + epoch_ms._0_4_ = 0; + puts("BL SYS TIME time is\r\n"); + bl_sys_time_get((uint64_t *)&local_30); + UVar1 = __udivdi3(); + utils_time_date_from_epoch(auStack36,(int)UVar1); + return; +} + + + +int bl_sys_time_cli_init(void) + +{ + return 0; +} + + + +void bl_sys_time_update(undefined4 param_1,undefined4 param_2) + +{ + time_synced._0_4_ = xTaskGetTickCount(); + epoch_time._0_4_ = param_1; + epoch_time._4_4_ = param_2; + time_synced._4_4_ = 0; + return; +} + + + +int bl_sys_time_get(uint64_t *epoch) + +{ + TickType_t TVar1; + int iVar2; + uint uVar3; + uint uVar4; + + if (((uint)epoch_time | epoch_time._4_4_) == 0) { + iVar2 = -1; + } + else { + TVar1 = xTaskGetTickCount(); + uVar4 = TVar1 - (int)time_synced; + uVar3 = (uint)epoch_time + uVar4; + iVar2 = ((int)uVar4 >> 0x1f) + epoch_time._4_4_; + *(uint *)epoch = uVar3; + *(int *)((int)epoch + 4) = (uint)(uVar3 < uVar4) + iVar2; + iVar2 = 0; + } + return iVar2; +} + + + +int bl_sys_time_sync_state(uint32_t *xTicksToJump) + +{ + bool bVar1; + TickType_t TVar2; + TickType_t TVar3; + uint uVar4; + uint64_t uVar5; + + if (sync_init != 0) { + vTaskEnterCritical(); + TVar2 = xTaskGetTickCount(); + TVar3 = TVar2; + uVar5 = bl_rtc_get_timestamp_ms(); + vTaskExitCritical((int)uVar5); + uVar4 = TVar3 - init_tick_rtc; + bVar1 = TVar2 - init_tick_rtos < uVar4; + if (bVar1) { + *xTicksToJump = (init_tick_rtos - TVar2) + uVar4; + } + return (uint)bVar1; + } + return -1; +} + + + +uint parse_hex4(char *str) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + uint uVar4; + uint uVar5; + + uVar1 = (uint)(byte)*str; + uVar5 = uVar1 - 0x30; + if (9 < (uVar5 & 0xff)) { + if ((uVar1 - 0x41 & 0xff) < 6) { + uVar5 = uVar1 - 0x37; + } + else { + if (5 < (uVar1 - 0x61 & 0xff)) { + return 0; + } + uVar5 = uVar1 - 0x57; + } + } + uVar2 = (uint)(byte)str[1]; + uVar1 = uVar2 - 0x30; + if (9 < (uVar1 & 0xff)) { + if ((uVar2 - 0x41 & 0xff) < 6) { + uVar1 = uVar2 - 0x37; + } + else { + if (5 < (uVar2 - 0x61 & 0xff)) { + return 0; + } + uVar1 = uVar2 - 0x57; + } + } + uVar3 = (uint)(byte)str[2]; + uVar2 = uVar3 - 0x30; + if (9 < (uVar2 & 0xff)) { + if ((uVar3 - 0x41 & 0xff) < 6) { + uVar2 = uVar3 - 0x37; + } + else { + if (5 < (uVar3 - 0x61 & 0xff)) { + return 0; + } + uVar2 = uVar3 - 0x57; + } + } + uVar3 = (uint)(byte)str[3]; + uVar4 = uVar3 - 0x30; + if (9 < (uVar4 & 0xff)) { + if ((uVar3 - 0x41 & 0xff) < 6) { + uVar4 = uVar3 - 0x37; + } + else { + if (5 < (uVar3 - 0x61 & 0xff)) { + return 0; + } + uVar4 = uVar3 - 0x57; + } + } + return uVar4 + ((uVar5 * 0x10 + uVar1) * 0x10 + uVar2) * 0x10; +} + + + +char * parse_string(cJSON *item,char *str) + +{ + byte *pbVar1; + uint uVar2; + uint uVar3; + byte *pbVar4; + byte *pbVar5; + byte bVar6; + size_t sVar7; + int iVar8; + byte *pbVar9; + byte *pbVar10; + + if (*str == '\"') { + sVar7 = 0; + pbVar9 = (byte *)(str + 1); + while( true ) { + bVar6 = *pbVar9; + sVar7 = sVar7 + 1; + if ((bVar6 == 0x22) || (bVar6 == 0)) break; + if (bVar6 == 0x5c) { + pbVar9 = pbVar9 + 2; + } + else { + pbVar9 = pbVar9 + 1; + } + } + pbVar1 = (byte *)(*cJSON_malloc)(sVar7); + pbVar9 = pbVar1; + pbVar5 = (byte *)(str + 1); + if (pbVar1 != (byte *)0x0) { + while ((bVar6 = *pbVar5, bVar6 != 0x22 && (bVar6 != 0))) { + pbVar4 = pbVar5 + 1; + if (bVar6 == 0x5c) { + bVar6 = pbVar5[1]; + if (bVar6 == 0x6e) { + bVar6 = 10; +LAB_2305c644: + *pbVar9 = bVar6; +LAB_2305c648: + pbVar10 = pbVar9 + 1; + } + else { + if (bVar6 < 0x6f) { + if (bVar6 == 0x62) { + bVar6 = 8; + } + else { + if (bVar6 != 0x66) { +LAB_2305c614: + *pbVar9 = bVar6; + goto LAB_2305c648; + } + bVar6 = 0xc; + } + *pbVar9 = bVar6; + pbVar10 = pbVar9 + 1; + } + else { + if (bVar6 == 0x74) { + bVar6 = 9; + goto LAB_2305c644; + } + if (bVar6 != 0x75) { + if (bVar6 == 0x72) { + bVar6 = 0xd; + } + goto LAB_2305c614; + } + uVar2 = parse_hex4((char *)(pbVar5 + 2)); + bVar6 = (byte)uVar2; + pbVar4 = pbVar5 + 5; + pbVar10 = pbVar9; + if ((0x3ff < uVar2 - 0xdc00) && (uVar2 != 0)) { + if (uVar2 - 0xd800 < 0x400) { + if ((pbVar5[6] == 0x5c) && (pbVar5[7] == 0x75)) { + uVar3 = parse_hex4((char *)(pbVar5 + 8)); + pbVar4 = pbVar5 + 0xb; + if (uVar3 - 0xdc00 < 0x400) { + uVar2 = ((uVar2 & 0x3ff) << 10 | uVar3 & 0x3ff) + 0x10000; +LAB_2305c6aa: + pbVar9[3] = (byte)uVar2 & 0x3f | 0x80; + uVar2 = uVar2 >> 6; + iVar8 = 4; +LAB_2305c6fa: + pbVar9[2] = (byte)uVar2 & 0x3f | 0x80; + uVar2 = uVar2 >> 6; + goto LAB_2305c716; + } + } + } + else { + if (uVar2 < 0x80) { + iVar8 = 1; + } + else { + if (0x7ff < uVar2) { + if (0xffff < uVar2) goto LAB_2305c6aa; + iVar8 = 3; + goto LAB_2305c6fa; + } + iVar8 = 2; +LAB_2305c716: + pbVar9[1] = (byte)uVar2 & 0x3f | 0x80; + bVar6 = (byte)(uVar2 >> 6); + } + pbVar10 = pbVar9 + iVar8; + *pbVar9 = bVar6 | ""[iVar8]; + } + } + } + } + pbVar5 = pbVar4 + 1; + pbVar9 = pbVar10; + } + else { + *pbVar9 = bVar6; + pbVar5 = pbVar4; + pbVar9 = pbVar9 + 1; + } + } + *pbVar9 = 0; + pbVar9 = pbVar5; + if (*pbVar5 == 0x22) { + pbVar9 = pbVar5 + 1; + } + *(byte **)&item->valuestring = pbVar1; + item->type = 4; + } + } + else { + pbVar9 = (byte *)0x0; + ep = str; + } + return (char *)pbVar9; +} + + + +char * skip(char *in) + +{ + while ((in != (char *)0x0 && ((byte)(*in - 1U) < 0x20))) { + in = in + 1; + } + return in; +} + + + +cJSON * cJSON_New_Item(void) + +{ + cJSON *__s; + + __s = (cJSON *)(*cJSON_malloc)(0x28); + if (__s != (cJSON *)0x0) { + memset(__s,0,0x28); + } + return __s; +} + + + +char * ensure(printbuffer *p,int needed) + +{ + uint uVar1; + size_t sVar2; + int iVar3; + char *__dest; + + __dest = (char *)0x0; + if ((p != (printbuffer *)0x0) && (__dest = p->buffer, __dest != (char *)0x0)) { + iVar3 = p->offset; + if (p->length < needed + iVar3) { + uVar1 = (needed + iVar3) - 1; + uVar1 = uVar1 | (int)uVar1 >> 1; + uVar1 = uVar1 | (int)uVar1 >> 2; + uVar1 = uVar1 | (int)uVar1 >> 4; + uVar1 = uVar1 | (int)uVar1 >> 8; + sVar2 = (uVar1 | (int)uVar1 >> 0x10) + 1; + __dest = (char *)(*cJSON_malloc)(sVar2); + if (__dest == (char *)0x0) { + (*cJSON_free)(p->buffer); + p->length = 0; + p->buffer = (char *)0x0; + return (char *)0x0; + } + memcpy(__dest,p->buffer,p->length); + (*cJSON_free)(p->buffer); + iVar3 = p->offset; + p->length = sVar2; + p->buffer = __dest; + } + __dest = __dest + iVar3; + } + return __dest; +} + + + +char * cJSON_strdup(char *str) + +{ + size_t sVar1; + char *__dest; + + sVar1 = strlen(str); + __dest = (char *)(*cJSON_malloc)(sVar1 + 1); + if (__dest != (char *)0x0) { + memcpy(__dest,str,sVar1 + 1); + } + return __dest; +} + + + +int update(printbuffer *p) + +{ + int iVar1; + size_t sVar2; + + iVar1 = 0; + if (p != (printbuffer *)0x0) { + iVar1 = 0; + if (p->buffer != (char *)0x0) { + iVar1 = p->offset; + sVar2 = strlen(p->buffer + iVar1); + iVar1 = iVar1 + sVar2; + } + } + return iVar1; +} + + + +char * print_number(cJSON *item,printbuffer *p) + +{ + __gcc_CMPtype _Var1; + char *buffer; + char *extraout_a0; + char *format; + undefined4 uVar2; + undefined4 uVar3; + double in_fa1; + + uVar3 = *(undefined4 *)((int)&item->valuedouble + 4); + uVar2 = *(undefined4 *)&item->valuedouble; + _Var1 = __eqdf2(); + if (_Var1 == 0) { + if (p == (printbuffer *)0x0) { + buffer = (char *)(*cJSON_malloc)(2); + } + else { + buffer = ensure(p,2); + } + if (buffer == (char *)0x0) { + return (char *)0x0; + } + strcpy(buffer,"0"); + return buffer; + } + __floatsidf(item->valueint); + __subdf3(); + fabs(in_fa1); + _Var1 = __ledf2(); + if (((_Var1 < 1) && (_Var1 = __ledf2(), _Var1 < 1)) && (_Var1 = __gedf2(), -1 < _Var1)) { + if (p == (printbuffer *)0x0) { + buffer = (char *)(*cJSON_malloc)(0x15); + } + else { + buffer = ensure(p,0x15); + } + if (buffer == (char *)0x0) { + return (char *)0x0; + } + sprintf(buffer,"%d",item->valueint); + return buffer; + } + if (p == (printbuffer *)0x0) { + in_fa1 = (double)(*cJSON_malloc)(0x40); + buffer = extraout_a0; + } + else { + buffer = ensure(p,0x40); + } + if (buffer == (char *)0x0) { + return (char *)0x0; + } + floor(in_fa1); + __subdf3(); + fabs(in_fa1); + _Var1 = __ledf2(); + if (_Var1 < 1) { + fabs(in_fa1); + _Var1 = __ledf2(); + if (_Var1 < 0) { + format = "%.0f"; + goto LAB_2305c9ac; + } + } + fabs(in_fa1); + _Var1 = __ledf2(); + if (-1 < _Var1) { + fabs(in_fa1); + _Var1 = __gedf2(); + if (_Var1 < 1) { + format = "%f"; + goto LAB_2305c9ac; + } + } + format = "%e"; +LAB_2305c9ac: + sprintf(buffer,format,uVar2,uVar3); + return buffer; +} + + + +char * print_string_ptr(char *str,printbuffer *p) + +{ + char cVar1; + int iVar2; + char *pcVar3; + bool bVar4; + bool bVar5; + byte bVar6; + byte *pbVar7; + char *__dest; + byte *pbVar8; + + bVar5 = false; + __dest = str; + while (cVar1 = *__dest, cVar1 != '\0') { + bVar4 = true; + if ((0x1e < (byte)(cVar1 - 1U)) && (cVar1 != '\"')) { + bVar4 = cVar1 == '\\'; + } + bVar5 = (bool)(bVar5 | bVar4); + __dest = __dest + 1; + } + if (bVar5) { + if (str == (char *)0x0) { + if (p == (printbuffer *)0x0) { + __dest = (char *)(*cJSON_malloc)(3); + } + else { + __dest = ensure(p,3); + } + if (__dest == (char *)0x0) { + return (char *)0x0; + } + strcpy(__dest,"\"\""); + return __dest; + } + iVar2 = 0; + pbVar8 = (byte *)str; + while( true ) { + bVar6 = *pbVar8; + if (bVar6 == 0) break; + __dest = strchr("\"\\\b\f\n\r\t",(uint)bVar6); + if (__dest == (char *)0x0) { + if (bVar6 < 0x20) { + iVar2 = iVar2 + 6; + } + else { + iVar2 = iVar2 + 1; + } + } + else { + iVar2 = iVar2 + 2; + } + pbVar8 = pbVar8 + 1; + } + if (p == (printbuffer *)0x0) { + pcVar3 = (char *)(*cJSON_malloc)(iVar2 + 3U); + } + else { + pcVar3 = ensure(p,iVar2 + 3U); + } + if (pcVar3 == (char *)0x0) { + return (char *)0x0; + } + *pcVar3 = '\"'; + pbVar8 = (byte *)(pcVar3 + 1); + while (bVar6 = *str, bVar6 != 0) { + pbVar7 = (byte *)str + 1; + if (((bVar6 < 0x20) || (bVar6 == 0x22)) || (bVar6 == 0x5c)) { + *pbVar8 = 0x5c; + bVar6 = *str; + if (bVar6 == 0xc) { + pbVar8[1] = 0x66; + pbVar8 = pbVar8 + 2; + str = (char *)pbVar7; + } + else { + if (bVar6 < 0xd) { + if (bVar6 == 9) { + bVar6 = 0x74; + } + else { + if (bVar6 == 10) { + bVar6 = 0x6e; + } + else { + if (bVar6 != 8) goto LAB_2305cc0a; + bVar6 = 0x62; + } + } + pbVar8[1] = bVar6; + pbVar8 = pbVar8 + 2; + str = (char *)pbVar7; + } + else { + if (bVar6 == 0x22) { + pbVar8[1] = 0x22; + pbVar8 = pbVar8 + 2; + str = (char *)pbVar7; + } + else { + if (bVar6 == 0x5c) { + pbVar8[1] = 0x5c; + pbVar8 = pbVar8 + 2; + str = (char *)pbVar7; + } + else { + if (bVar6 == 0xd) { + pbVar8[1] = 0x72; + pbVar8 = pbVar8 + 2; + str = (char *)pbVar7; + } + else { +LAB_2305cc0a: + sprintf((char *)(pbVar8 + 1),"u%04x"); + pbVar8 = pbVar8 + 6; + str = (char *)pbVar7; + } + } + } + } + } + } + else { + *pbVar8 = bVar6; + pbVar8 = pbVar8 + 1; + str = (char *)pbVar7; + } + } + *pbVar8 = 0x22; + } + else { + __dest = __dest + -(int)str; + if (p == (printbuffer *)0x0) { + pcVar3 = (char *)(*cJSON_malloc)((size_t)(__dest + 3)); + } + else { + pcVar3 = ensure(p,(int)(__dest + 3)); + } + if (pcVar3 == (char *)0x0) { + return (char *)0x0; + } + *pcVar3 = '\"'; + pbVar8 = (byte *)(pcVar3 + 1 + (int)__dest); + strcpy(pcVar3 + 1,str); + *pbVar8 = 0x22; + } + pbVar8[1] = 0; + return pcVar3; +} + + + +int cJSON_strcasecmp(char *s1,char *s2) + +{ + uint uVar1; + uint uVar2; + + uVar2 = (uint)(s2 != (char *)0x0); + if ((s1 != (char *)0x0) && (uVar2 = 1, s2 != (char *)0x0)) { + while( true ) { + uVar2 = (uint)(byte)*s1; + if ((_ctype_[uVar2 + 1] & 3) == 1) { + uVar2 = uVar2 + 0x20; + } + uVar1 = (uint)(byte)*s2; + if ((_ctype_[uVar1 + 1] & 3) == 1) { + uVar1 = uVar1 + 0x20; + } + if (uVar2 != uVar1) { + return uVar2 - uVar1; + } + if (*s1 == 0) break; + s1 = (char *)((byte *)s1 + 1); + s2 = (char *)((byte *)s2 + 1); + } + uVar2 = 0; + } + return uVar2; +} + + + +char * parse_value(cJSON *item,char *value) + +{ + char cVar1; + byte bVar2; + byte *pbVar3; + int i; + char *str; + SItype SVar4; + char *in; + cJSON *item_00; + cJSON *item_01; + char cVar5; + int iVar6; + int iVar7; + undefined4 uVar8; + double in_fa1; + double in_fa2; + + if (value == (char *)0x0) { + return (char *)0x0; + } + i = strncmp(value,"null",4); + if (i == 0) { + item->type = 2; +LAB_2305ccae: + return value + 4; + } + i = strncmp(value,"false",5); + if (i == 0) { + item->type = 0; + return value + 5; + } + i = strncmp(value,"true",4); + if (i == 0) { + item->type = 1; + item->valueint = 1; + goto LAB_2305ccae; + } + cVar1 = *value; + if (cVar1 == '\"') { + str = parse_string(item,value); + return str; + } + if (cVar1 == '-') { + value = value + 1; + } + else { + if (9 < (byte)(cVar1 - 0x30U)) { + if (cVar1 == '[') { + item->type = 5; + in = skip(value + 1); + if (*in == ']') { +LAB_2305cf28: + return in + 1; + } + item_00 = cJSON_New_Item(); + item->child = item_00; + str = ep; + if (item_00 != (cJSON *)0x0) { + str = skip(in); + str = parse_value(item_00,str); + in = skip(str); + while (str = ep, in != (char *)0x0) { + cVar1 = *in; + if (cVar1 != ',') { + cVar5 = ']'; +LAB_2305cf88: + if (cVar1 != cVar5) { + ep = in; + return (char *)0x0; + } + goto LAB_2305cf28; + } + item_01 = cJSON_New_Item(); + if (item_01 == (cJSON *)0x0) { + return (char *)0x0; + } + item_00->next = item_01; + item_01->prev = item_00; + str = skip(in + 1); + str = parse_value(item_01,str); + in = skip(str); + item_00 = item_01; + } + } + } + else { + str = value; + if (cVar1 == '{') { + item->type = 6; + in = skip(value + 1); + if (*in == '}') goto LAB_2305cf28; + item_00 = cJSON_New_Item(); + item->child = item_00; + str = ep; + if (item_00 != (cJSON *)0x0) { + str = skip(in); + str = parse_string(item_00,str); + in = skip(str); + str = ep; + if (in != (char *)0x0) { + str = item_00->valuestring; + item_00->valuestring = (char *)0x0; + item_00->string = str; + str = in; + if (*in == ':') { + str = skip(in + 1); + str = parse_value(item_00,str); + in = skip(str); + while (str = ep, in != (char *)0x0) { + cVar1 = *in; + if (cVar1 != ',') { + cVar5 = '}'; + goto LAB_2305cf88; + } + item_01 = cJSON_New_Item(); + if (item_01 == (cJSON *)0x0) { + return (char *)0x0; + } + item_00->next = item_01; + item_01->prev = item_00; + str = skip(in + 1); + str = parse_string(item_01,str); + str = skip(str); + if (str == (char *)0x0) { + return (char *)0x0; + } + in = item_01->valuestring; + item_01->valuestring = (char *)0x0; + item_01->string = in; + if (*str != ':') { + ep = str; + return (char *)0x0; + } + str = skip(str + 1); + str = parse_value(item_01,str); + in = skip(str); + item_00 = item_01; + } + } + } + } + } + } + ep = str; + return (char *)0x0; + } + } + if (*value == 0x30) { + value = (char *)((byte *)value + 1); + } + i = 0; + uVar8 = 0; + pbVar3 = (byte *)value; + if ((byte)(*value - 0x31U) < 9) { + do { + __muldf3(); + value = (char *)(pbVar3 + 1); + i = (uint)*pbVar3 - 0x30; + __floatsidf(i); + __adddf3(); + pbVar3 = (byte *)value; + } while ((byte)(*value - 0x30U) < 10); + } + if ((*value == 0x2e) && ((byte)(((byte *)value)[1] - 0x30) < 10)) { + pbVar3 = (byte *)value + 1; + do { + __muldf3(); + value = (char *)(pbVar3 + 1); + i = (uint)*pbVar3 - 0x30; + __floatsidf(i); + __adddf3(); + __subdf3(); + pbVar3 = (byte *)value; + } while ((byte)(*value - 0x30U) < 10); + } + if ((*value & 0xdfU) != 0x45) { + iVar7 = 1; + iVar6 = 0; + goto LAB_2305ceaa; + } + if (((byte *)value)[1] == 0x2b) { + value = (char *)((byte *)value + 2); +LAB_2305ce7a: + iVar7 = 1; + } + else { + if (((byte *)value)[1] != 0x2d) { + value = (char *)((byte *)value + 1); + goto LAB_2305ce7a; + } + value = (char *)((byte *)value + 2); + iVar7 = -1; + } + iVar6 = 0; + while (bVar2 = *value, ((uint)bVar2 - 0x30 & 0xff) < 10) { + value = (char *)((byte *)value + 1); + iVar6 = iVar6 * 10 + ((uint)bVar2 - 0x30); + } +LAB_2305ceaa: + __muldf3(); + __floatsidf(iVar6 * iVar7); + __adddf3(); + pow(in_fa1,in_fa2); + __muldf3(); + *(int *)&item->valuedouble = i; + *(undefined4 *)((int)&item->valuedouble + 4) = uVar8; + SVar4 = __fixdfsi(); + item->valueint = SVar4; + item->type = 3; + return (char *)(byte *)value; +} + + + +char * print_array(int depth,int fmt,printbuffer *p) + +{ + undefined4 *__dest; + size_t sVar1; + undefined *__dest_00; + char *__s; + int iVar2; + char **__s_00; + size_t __n; + printbuffer *in_a3; + char *pcVar3; + cJSON *item; + int iVar4; + char **ppcVar5; + + __dest = *(undefined4 **)depth; + iVar4 = 0; + while (__dest != (undefined4 *)0x0) { + iVar4 = iVar4 + 1; + __dest = (undefined4 *)*__dest; + } + if (iVar4 == 0) { + if (in_a3 == (printbuffer *)0x0) { + __dest = (undefined4 *)(*cJSON_malloc)(3); + } + else { + __dest = (undefined4 *)ensure(in_a3,3); + } + if (__dest != (undefined4 *)0x0) { + strcpy((char *)__dest,"[]"); + } + } + else { + if (in_a3 == (printbuffer *)0x0) { + __s_00 = (char **)(*cJSON_malloc)(iVar4 << 2); + if (__s_00 != (char **)0x0) { + memset(__s_00,0,iVar4 << 2); + item = *(cJSON **)depth; + iVar2 = 0; + sVar1 = 5; + ppcVar5 = __s_00; + while (item != (cJSON *)0x0) { + if (iVar2 != 0) goto LAB_2305d1ca; + __s = print_value(item,fmt + 1,(int)p,(printbuffer *)0x0); + *ppcVar5 = __s; + if (__s == (char *)0x0) { + iVar2 = 1; + } + else { + __n = strlen(__s); + sVar1 = sVar1 + (uint)(p != (printbuffer *)0x0) + 2 + __n; + } + item = item->next; + ppcVar5 = ppcVar5 + 1; + } + if ((iVar2 == 0) && + (__dest = (undefined4 *)(*cJSON_malloc)(sVar1), __dest != (undefined4 *)0x0)) { + *(undefined *)__dest = 0x5b; + __dest_00 = (undefined *)((int)__dest + 1); + *(undefined *)((int)__dest + 1) = 0; + ppcVar5 = __s_00; + do { + __n = strlen(*ppcVar5); + memcpy(__dest_00,*ppcVar5,__n); + __dest_00 = __dest_00 + __n; + if (iVar4 + -1 != iVar2) { + *__dest_00 = 0x2c; + if (p == (printbuffer *)0x0) { + __dest_00 = __dest_00 + 1; + } + else { + __dest_00[1] = 0x20; + __dest_00 = __dest_00 + 2; + } + *__dest_00 = 0; + } + __s = *ppcVar5; + iVar2 = iVar2 + 1; + ppcVar5 = ppcVar5 + 1; + (*cJSON_free)(__s); + } while (iVar4 != iVar2); + (*cJSON_free)(__s_00); + *__dest_00 = 0x5d; + __dest_00[1] = 0; + } + else { +LAB_2305d1ca: + iVar2 = 0; + do { + if (__s_00[iVar2] != (char *)0x0) { + (*cJSON_free)(__s_00[iVar2]); + } + iVar2 = iVar2 + 1; + } while (iVar4 != iVar2); + __dest = (undefined4 *)0x0; + (*cJSON_free)(__s_00); + } + } + } + else { + iVar4 = in_a3->offset; + __s = ensure(in_a3,1); + if (__s != (char *)0x0) { + *__s = '['; + in_a3->offset = in_a3->offset + 1; + item = *(cJSON **)depth; + while (item != (cJSON *)0x0) { + print_value(item,fmt + 1,(int)p,in_a3); + iVar2 = update(in_a3); + in_a3->offset = iVar2; + if (item->next != (cJSON *)0x0) { + __s = ensure(in_a3,(uint)(p != (printbuffer *)0x0) + 2); + if (__s == (char *)0x0) { + return (char *)0x0; + } + *__s = ','; + pcVar3 = __s + 1; + if (p != (printbuffer *)0x0) { + pcVar3 = __s + 2; + __s[1] = ' '; + } + *pcVar3 = '\0'; + in_a3->offset = in_a3->offset + (uint)(p != (printbuffer *)0x0) + 1; + } + item = item->next; + } + __s = ensure(in_a3,2); + if (__s != (char *)0x0) { + *__s = ']'; + __s[1] = '\0'; + __dest = (undefined4 *)(in_a3->buffer + iVar4); + } + } + } + } + return (char *)__dest; +} + + + +char * print_value(cJSON *item,int depth,int fmt,printbuffer *p) + +{ + char *str; + char *__src; + + if (item == (cJSON *)0x0) { + return (char *)0x0; + } + if (p != (printbuffer *)0x0) { + switch(*(undefined *)&item->type) { + case 0: + str = ensure(p,6); + if (str == (char *)0x0) { + return (char *)0x0; + } + __src = "false"; + break; + case 1: + str = ensure(p,5); + if (str == (char *)0x0) { + return (char *)0x0; + } + __src = "true"; + break; + case 2: + str = ensure(p,5); + if (str == (char *)0x0) { + return (char *)0x0; + } + __src = "null"; + break; + case 3: +LAB_2305d31c: + str = print_number(item,p); + return str; + case 4: +LAB_2305d32a: + str = print_string_ptr(item->valuestring,p); + return str; + case 5: +switchD_2305d2ca_caseD_5: + str = print_array((int)&item->child,depth,(printbuffer *)fmt); + return str; + case 6: +switchD_2305d2ca_caseD_6: + str = print_object((int)&item->child,depth,(printbuffer *)fmt); + return str; + default: +LAB_2305d2e4: + return (char *)0x0; + } + strcpy(str,__src); + return str; + } + switch(*(undefined *)&item->type) { + case 0: + str = "false"; + break; + case 1: + str = "true"; + break; + case 2: + str = "null"; + break; + case 3: + p = (printbuffer *)0x0; + goto LAB_2305d31c; + case 4: + p = (printbuffer *)0x0; + goto LAB_2305d32a; + case 5: + goto switchD_2305d2ca_caseD_5; + case 6: + goto switchD_2305d2ca_caseD_6; + default: + goto LAB_2305d2e4; + } + str = cJSON_strdup(str); + return str; +} + + + +char * print_object(int depth,int fmt,printbuffer *p) + +{ + size_t sVar1; + char *__s; + size_t sVar2; + char **__s_00; + char **__s_01; + size_t sVar3; + char *__dest; + printbuffer *in_a3; + int *piVar4; + char *__s_02; + int iVar5; + char **ppcVar6; + int needed; + int needed_00; + int needed_01; + char **ppcVar7; + size_t __n; + cJSON *item; + char **ppcStack88; + + piVar4 = *(int **)depth; + needed_00 = 0; + while (piVar4 != (int *)0x0) { + needed_00 = needed_00 + 1; + piVar4 = (int *)*piVar4; + } + if (needed_00 == 0) { + if (in_a3 == (printbuffer *)0x0) { + sVar2 = 3; + if (p != (printbuffer *)0x0) { + sVar2 = fmt + 4; + } + __s = (char *)(*cJSON_malloc)(sVar2); + } + else { + needed_00 = 3; + if (p != (printbuffer *)0x0) { + needed_00 = fmt + 4; + } + __s = ensure(in_a3,needed_00); + } + if (__s != (char *)0x0) { + *__s = '{'; + __s_02 = __s + 1; + if (p != (printbuffer *)0x0) { + __s[1] = '\n'; + __s_02 = __s + 2; + while ((int)(__s_02 + (-2 - (int)__s)) < fmt + -1) { + *__s_02 = '\t'; + __s_02 = __s_02 + 1; + } + } + *__s_02 = '}'; + __s_02[1] = '\0'; + return __s; + } + } + else { + if (in_a3 == (printbuffer *)0x0) { + __n = needed_00 << 2; + __s_00 = (char **)(*cJSON_malloc)(__n); + if (__s_00 != (char **)0x0) { + __s_01 = (char **)(*cJSON_malloc)(__n); + if (__s_01 != (char **)0x0) { + memset(__s_00,0,__n); + memset(__s_01,0,__n); + item = *(cJSON **)depth; + if (p == (printbuffer *)0x0) { + sVar2 = 7; + needed = 0; + } + else { + sVar2 = fmt + 8; + needed = fmt + 3; + } + needed_01 = 0; + ppcVar6 = __s_00; + ppcStack88 = __s_01; + while (item != (cJSON *)0x0) { + __s = print_string_ptr(item->string,(printbuffer *)0x0); + *ppcStack88 = __s; + __s_02 = print_value(item,fmt + 1,(int)p,(printbuffer *)0x0); + *ppcVar6 = __s_02; + if ((__s == (char *)0x0) || (__s_02 == (char *)0x0)) { + needed_01 = 1; + } + else { + sVar1 = strlen(__s_02); + sVar3 = strlen(__s); + sVar2 = needed + 2 + sVar2 + sVar1 + sVar3; + } + item = item->next; + ppcVar6 = ppcVar6 + 1; + ppcStack88 = ppcStack88 + 1; + } + if ((needed_01 == 0) && (__s = (char *)(*cJSON_malloc)(sVar2), __s != (char *)0x0)) { + *__s = '{'; + __s_02 = __s + 1; + if (p != (printbuffer *)0x0) { + __s_02 = __s + 2; + __s[1] = '\n'; + } + *__s_02 = '\0'; + needed = 0; + ppcVar6 = __s_00; + ppcVar7 = __s_01; + do { + __dest = __s_02; + if (p != (printbuffer *)0x0) { + iVar5 = 0; + while (__dest = __s_02 + iVar5, iVar5 < fmt + 1) { + *__dest = '\t'; + iVar5 = iVar5 + 1; + } + } + __n = strlen(*ppcVar7); + memcpy(__dest,*ppcVar7,__n); + __dest = __dest + __n; + *__dest = ':'; + __s_02 = __dest + 1; + if (p != (printbuffer *)0x0) { + __s_02 = __dest + 2; + __dest[1] = '\t'; + } + strcpy(__s_02,*ppcVar6); + __n = strlen(*ppcVar6); + __s_02 = __s_02 + __n; + if (needed_00 + -1 != needed) { + *__s_02 = ','; + __s_02 = __s_02 + 1; + } + if (p != (printbuffer *)0x0) { + *__s_02 = '\n'; + __s_02 = __s_02 + 1; + } + *__s_02 = '\0'; + __dest = *ppcVar7; + needed = needed + 1; + ppcVar7 = ppcVar7 + 1; + (*cJSON_free)(__dest); + __dest = *ppcVar6; + ppcVar6 = ppcVar6 + 1; + (*cJSON_free)(__dest); + } while (needed_00 != needed); + (*cJSON_free)(__s_01); + (*cJSON_free)(__s_00); + if (p != (printbuffer *)0x0) { + while (needed_01 < fmt) { + __s_02[needed_01] = '\t'; + needed_01 = needed_01 + 1; + } + if (fmt < 0) { + fmt = 0; + } + __s_02 = __s_02 + fmt; + } + *__s_02 = '}'; + __s_02[1] = '\0'; + return __s; + } + sVar1 = 0; + do { + if (*(void **)((int)__s_01 + sVar1) != (void *)0x0) { + (*cJSON_free)(*(void **)((int)__s_01 + sVar1)); + } + if (*(void **)((int)__s_00 + sVar1) != (void *)0x0) { + (*cJSON_free)(*(void **)((int)__s_00 + sVar1)); + } + sVar1 = sVar1 + 4; + } while (__n != sVar1); + (*cJSON_free)(__s_01); + } + (*cJSON_free)(__s_00); + } + } + else { + needed = (uint)(p != (printbuffer *)0x0) + 1; + needed_00 = in_a3->offset; + __s = ensure(in_a3,(uint)(p != (printbuffer *)0x0) + 2); + if (__s != (char *)0x0) { + *__s = '{'; + __s_02 = __s + 1; + if (p != (printbuffer *)0x0) { + __s_02 = __s + 2; + __s[1] = '\n'; + } + *__s_02 = '\0'; + needed_01 = fmt + 1; + in_a3->offset = in_a3->offset + needed; + item = *(cJSON **)depth; + while (item != (cJSON *)0x0) { + if (p != (printbuffer *)0x0) { + __s = ensure(in_a3,needed_01); + if (__s == (char *)0x0) { + return (char *)0x0; + } + iVar5 = 0; + while (iVar5 < needed_01) { + __s[iVar5] = '\t'; + iVar5 = iVar5 + 1; + } + in_a3->offset = in_a3->offset + needed_01; + } + print_string_ptr(item->string,in_a3); + iVar5 = update(in_a3); + in_a3->offset = iVar5; + __s = ensure(in_a3,needed); + if (__s == (char *)0x0) { + return (char *)0x0; + } + *__s = ':'; + if (p != (printbuffer *)0x0) { + __s[1] = '\t'; + } + in_a3->offset = in_a3->offset + needed; + print_value(item,needed_01,(int)p,in_a3); + iVar5 = update(in_a3); + in_a3->offset = iVar5; + iVar5 = (uint)(item->next != (cJSON *)0x0) + (uint)(p != (printbuffer *)0x0); + __s = ensure(in_a3,iVar5 + 1); + if (__s == (char *)0x0) { + return (char *)0x0; + } + if (item->next != (cJSON *)0x0) { + *__s = ','; + __s = __s + 1; + } + if (p != (printbuffer *)0x0) { + *__s = '\n'; + __s = __s + 1; + } + *__s = '\0'; + in_a3->offset = iVar5 + in_a3->offset; + item = item->next; + } + needed = 2; + if (p != (printbuffer *)0x0) { + needed = fmt + 2; + } + __s = ensure(in_a3,needed); + if (__s != (char *)0x0) { + if (p != (printbuffer *)0x0) { + needed_00 = 0; + while (needed_00 < fmt) { + __s[needed_00] = '\t'; + needed_00 = needed_00 + 1; + } + if (fmt < 0) { + fmt = 0; + } + __s = __s + fmt; + needed_00 = fmt; + } + *__s = '}'; + __s[1] = '\0'; + return in_a3->buffer + needed_00; + } + } + } + } + return (char *)0x0; +} + + + +void cJSON_InitHooks(cJSON_Hooks *hooks) + +{ + code *pcVar1; + + if (hooks == (cJSON_Hooks *)0x0) { + cJSON_malloc = malloc; + } + else { + pcVar1 = hooks->malloc_fn; + if (pcVar1 == (anon_subr_void_ptr_size_t *)0x0) { + pcVar1 = malloc; + } + cJSON_malloc = pcVar1; + if (hooks->free_fn != (anon_subr_void_void_ptr_for_free_fn *)0x0) { + cJSON_free = (anon_subr_void_void_ptr *)hooks->free_fn; + return; + } + } + cJSON_free = free; + return; +} + + + +void cJSON_Delete(cJSON *c) + +{ + cJSON *pcVar1; + + while (c != (cJSON *)0x0) { + pcVar1 = c->next; + if (((c->type & 0x100U) == 0) && + (((c->child == (cJSON *)0x0 || (cJSON_Delete(c->child), (c->type & 0x100U) == 0)) && + (c->valuestring != (char *)0x0)))) { + (*cJSON_free)(c->valuestring); + } + if (((c->type & 0x200U) == 0) && (c->string != (char *)0x0)) { + (*cJSON_free)(c->string); + } + (*cJSON_free)(c); + c = pcVar1; + } + return; +} + + + +cJSON * cJSON_ParseWithOpts(char *value,char **return_parse_end,int require_null_terminated) + +{ + cJSON *item; + char *value_00; + + item = cJSON_New_Item(); + ep = (char *)0x0; + if (item != (cJSON *)0x0) { + value_00 = skip(value); + value_00 = parse_value(item,value_00); + if (value_00 == (char *)0x0) { + cJSON_Delete(item); + } + else { + if ((require_null_terminated == 0) || (value_00 = skip(value_00), *value_00 == '\0')) { + if (return_parse_end == (char **)0x0) { + return item; + } + *return_parse_end = value_00; + return item; + } + cJSON_Delete(item); + ep = value_00; + } + item = (cJSON *)0x0; + } + return item; +} + + + +cJSON * cJSON_Parse(char *value) + +{ + cJSON *pcVar1; + + pcVar1 = cJSON_ParseWithOpts(value,(char **)0x0,0); + return pcVar1; +} + + + +char * cJSON_Print(cJSON *item) + +{ + char *pcVar1; + + pcVar1 = print_value(item,0,1,(printbuffer *)0x0); + return pcVar1; +} + + + +cJSON * cJSON_GetObjectItem(cJSON *object,char *string) + +{ + cJSON *pcVar1; + int iVar2; + + pcVar1 = object->child; + while ((pcVar1 != (cJSON *)0x0 && (iVar2 = cJSON_strcasecmp(pcVar1->string,string), iVar2 != 0))) + { + pcVar1 = pcVar1->next; + } + return pcVar1; +} + + + +void cJSON_AddItemToArray(cJSON *array,cJSON *item) + +{ + cJSON *pcVar1; + cJSON *pcVar2; + + if (item != (cJSON *)0x0) { + pcVar1 = array->child; + if (array->child == (cJSON *)0x0) { + array->child = item; + return; + } + do { + pcVar2 = pcVar1; + pcVar1 = pcVar2->next; + } while (pcVar2->next != (cJSON *)0x0); + pcVar2->next = item; + item->prev = pcVar2; + } + return; +} + + + +void cJSON_AddItemToObject(cJSON *object,char *string,cJSON *item) + +{ + char *pcVar1; + + if (item != (cJSON *)0x0) { + if (item->string != (char *)0x0) { + (*cJSON_free)(item->string); + } + pcVar1 = cJSON_strdup(string); + item->string = pcVar1; + cJSON_AddItemToArray(object,item); + return; + } + return; +} + + + +cJSON * cJSON_CreateNumber(void) + +{ + undefined4 in_a0; + cJSON *pcVar1; + SItype SVar2; + undefined4 in_a1; + + pcVar1 = cJSON_New_Item(); + if (pcVar1 != (cJSON *)0x0) { + pcVar1->type = 3; + *(undefined4 *)&pcVar1->valuedouble = in_a0; + *(undefined4 *)((int)&pcVar1->valuedouble + 4) = in_a1; + SVar2 = __fixdfsi(); + pcVar1->valueint = SVar2; + } + return pcVar1; +} + + + +cJSON * cJSON_CreateString(char *string) + +{ + cJSON *pcVar1; + char *pcVar2; + + pcVar1 = cJSON_New_Item(); + if (pcVar1 != (cJSON *)0x0) { + pcVar1->type = 4; + pcVar2 = cJSON_strdup(string); + pcVar1->valuestring = pcVar2; + } + return pcVar1; +} + + + +cJSON * cJSON_CreateObject(void) + +{ + cJSON *pcVar1; + + pcVar1 = cJSON_New_Item(); + if (pcVar1 != (cJSON *)0x0) { + pcVar1->type = 6; + } + return pcVar1; +} + + + +cli_command * cli_command_get(int idx,int *is_static_cmd) + +{ + cli_st *pcVar1; + cli_command *pcVar2; + + pcVar1 = cli; + pcVar2 = (cli_command *)0xffffffff; + if (-1 < idx) { + pcVar2 = (cli_command *)0xffffffff; + if ((uint)idx < cli->num_static_cmds + 8) { + if ((uint)idx < cli->num_static_cmds) { + if (is_static_cmd != (int *)0x0) { + *is_static_cmd = 1; + } + pcVar2 = pcVar1->static_cmds + idx; + } + else { + if (is_static_cmd != (int *)0x0) { + *is_static_cmd = 0; + } + pcVar2 = pcVar1->dynamic_cmds[idx - pcVar1->num_static_cmds]; + } + } + } + return pcVar2; +} + + + +void exit_cmd(char *buf,int len,int argc,char **argv) + +{ + cliexit = 1; + return; +} + + + +int cb_idnoe(void *arg,inode_t *node) + +{ + uint8_t uVar1; + char *pcVar2; + undefined4 uVar3; + + if (*(int *)arg == 0) { + *(undefined4 *)arg = 1; + printf("\tSize\t\t\t\t\t Name\t\t\tFiletype\r\n"); + printf("----------------------------------------------------------------------------------\r\n") + ; + } + uVar1 = node->type; + uVar3 = 0x1c; + if ((1 < (byte)(uVar1 - 1)) && (uVar3 = 0x50, uVar1 != '\x03')) { + uVar3 = 0; + } + if (uVar1 == '\x01') { + pcVar2 = "Char Device"; + } + else { + if (uVar1 == '\x02') { + pcVar2 = "Block Device"; + } + else { + if (uVar1 == '\x03') { + pcVar2 = "File System"; + } + else { + pcVar2 = "Unknown"; + } + } + } + printf("%10d\t\t%30s\t\t\t%s\r\n",uVar3,node->i_name,pcVar2); + return 0; +} + + + +void ota_cmd(char *buf,int len,int argc,char **argv) + +{ + aos_task_new("LOCAL OTA",tftp_ota_thread,(void *)0x0,0x1000); + return; +} + + + +void tftp_ota_thread(void *arg) + +{ + aos_task_exit(0); + return; +} + + + +void cat_cmd(char *buf,int len,int argc,char **argv) + +{ + int fd; + ssize_t sVar1; + byte local_11 [4]; + char ch; + + if (argc != 2) { + printf("invalid parameter!\r\n"); + } + fd = aos_open(argv[1],0); + if (fd < 0) { + printf("open %s failed!\r\n",argv[1]); + } + else { + while (sVar1 = aos_read(fd,local_11,1), sVar1 == 1) { + printf("%c",(uint)local_11[0]); + } + printf("\r\n"); + aos_close(fd); + } + return; +} + + + +void hexdump_cmd(char *buf,int len,int argc,char **argv) + +{ + int fd; + void *local_18; + romfs_filebuf_t filebuf; + + if (argc != 2) { + printf("invalid parameter!\r\n"); + } + fd = aos_open(argv[1],0); + if (fd < 0) { + printf("open %s failed!\r\n",argv[1]); + } + else { + memset(&local_18,0,8); + aos_ioctl(fd,1,(ulong)&local_18); + printf("Found file %s. XIP Addr %p, len %lu\r\n",argv[1],local_18,filebuf.buf); + utils_hexdump(local_18,(uint)filebuf.buf); + aos_close(fd); + } + return; +} + + + +int aos_cli_init(int use_thread) + +{ + cli_st *pcVar1; + int iVar2; + + cli = (cli_st *)aos_malloc(0x244); + iVar2 = 0xc; + if (cli != (cli_st *)0x0) { + memset(cli,0,0x244); + pcVar1 = cli; + cli->static_cmds = cmds_user; + pcVar1->echo_disabled = 0; + pcVar1->num_static_cmds = 0x88; + pcVar1->num_commands = 0x88; + pcVar1->initialized = 1; + iVar2 = 0; + } + return iVar2; +} + + + +void * aos_cli_event_cb_read_get(void) + +{ + return console_cb_read; +} + + + +int cli_putstr(char *msg) + +{ + int iVar1; + size_t sVar2; + ssize_t sVar3; + + sVar2 = strlen(msg); + iVar1 = 0; + while ((iVar1 < (int)sVar2 && + (sVar3 = aos_write(fd_console,msg + iVar1,sVar2 - iVar1), -1 < sVar3))) { + iVar1 = iVar1 + sVar3; + } + return 0; +} + + + +void ps_cmd(char *buf,int len,int argc,char **argv) + +{ + char *__dest; + char *__dest_00; + size_t sVar1; + int iVar2; + + __dest_00 = (char *)pvPortMalloc(0x600); + if (__dest_00 != (char *)0x0) { + strcpy(__dest_00,"Task"); + sVar1 = strlen(__dest_00); + __dest = __dest_00 + sVar1; + sVar1 = strlen("Task"); + iVar2 = sVar1 - (int)__dest; + while ((int)(__dest + iVar2) < 0xd) { + *__dest = ' '; + __dest = __dest + 1; + *__dest = '\0'; + } + strcpy(__dest, + "State Priority Stack # Base\r\n********************************************************\r\n" + ); + sVar1 = strlen( + "State Priority Stack # Base\r\n********************************************************\r\n" + ); + vTaskList(__dest + sVar1); + cli_putstr(__dest_00); + vPortFree(__dest_00); + return; + } + return; +} + + + +int aos_cli_printf(char *msg,...) + +{ + size_t sVar1; + int iVar2; + undefined4 in_a1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list ap; + char message [256]; + undefined4 uStack28; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack28 = in_a1; + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + memset(&ap,0,0x100); + sVar1 = 0; + if (esc_tag_len != '\0') { + strcpy((char *)&ap,esc_tag); + sVar1 = strlen(esc_tag); + } + iVar2 = vsnprintf((char *)((int)&ap + sVar1),0x100 - sVar1,msg,&uStack28); + if (0 < iVar2) { + cli_putstr((char *)&ap); + } + return 0; +} + + + +int proc_onecmd(int argc,char **argv) + +{ + cli_st *pcVar1; + cli_st *pcVar2; + char *__s1; + cli_command *pcVar3; + int iVar4; + uint idx; + uint uVar5; + char *__n; + char *__s2; + + if (argc < 1) { + return 0; + } + if (cli->echo_disabled == 0) { + printf("\r\n"); + } + __n = (char *)0x0; + __s1 = strchr(*argv,0x2e); + __s2 = *argv; + if (__s1 != (char *)0x0) { + __n = __s1 + -(int)__s2; + } + idx = 0; + uVar5 = 0; + while( true ) { + if (cli->num_static_cmds + 8 <= idx) { + return 1; + } + if (cli->num_commands <= uVar5) break; + pcVar3 = cli_command_get(idx,(int *)0x0); + __s1 = pcVar3->name; + if (__s1 != (char *)0x0) { + if (__n == (char *)0x0) { + iVar4 = strcmp(__s1,__s2); + } + else { + iVar4 = strncmp(__s1,__s2,(size_t)__n); + } + pcVar1 = cli; + if (iVar4 == 0) { + __s1 = (char *)aos_malloc(0x200); + pcVar2 = cli; + pcVar1->outbuf = __s1; + if (pcVar2->outbuf == (char *)0x0) { + aos_cli_printf("Error! cli alloc mem fail!\r\n"); + return 1; + } + memset(pcVar2->outbuf,0,0x200); + (*pcVar3->function)(cli->outbuf,0x200,argc,argv); + aos_cli_printf("%s",cli->outbuf); + aos_free(cli->outbuf); + cli->outbuf = (char *)0x0; + return 0; + } + uVar5 = uVar5 + 1; + } + idx = idx + 1; + } + return 1; +} + + + +void ls_cmd(char *buf,int len,int argc,char **argv) + +{ + stat *st; + int iVar1; + aos_dir_t *dir; + aos_dirent_t *paVar2; + char *msg; + size_t __n; + size_t sVar3; + undefined4 uStack180; + int env; + char path_name [128]; + + uStack180 = 0; + st = (stat *)pvPortMalloc(0x58); + memset(stat,0,0x58); + memset(&env,0,0x80); + if (argc == 2) { + iVar1 = strcmp(argv[1],"/sdcard"); + if (iVar1 == 0) { + dir = aos_opendir("/sdcard"); + if (dir == (aos_dir_t *)0x0) { + msg = "can not open sdcard\r\n"; +LAB_2305dfc4: + printf(msg); + goto LAB_2305df9e; + } + printf("\tSize\t\t\t\t\t Name\t\t\tFiletype\r\n"); + printf( + "----------------------------------------------------------------------------------\r\n" + ); + while (paVar2 = aos_readdir(dir), paVar2 != (aos_dirent_t *)0x0) { + snprintf((char *)&env,0x7f,"/sdcard/%s",&paVar2->field_0x5); + iVar1 = aos_stat((char *)&env,st); + if (iVar1 == 0) { + iVar1 = -0x504; + if (-1 < (int)(st->st_mode << 0x11)) { + iVar1 = -0x4e8; + } + printf("EasyFlash V%s is initialize fail.\r\n" + iVar1 + 0xc,st->st_size, + &paVar2->field_0x5); + } + } + } + else { + msg = argv[1]; + __n = strlen("/romfs"); + iVar1 = memcmp(msg,"/romfs",__n); + if (iVar1 != 0) { + iVar1 = strcmp(argv[1],"/"); + if (iVar1 != 0) { + msg = "un-supported direcotry!\r\n"; + goto LAB_2305e0ea; + } + goto LAB_2305e0d2; + } + dir = aos_opendir(argv[1]); + if (dir == (aos_dir_t *)0x0) { + msg = "can not open romfs\r\n"; + goto LAB_2305dfc4; + } + printf("\tSize\t\t\t\t\t Name\t\t\tFiletype\r\n"); + printf( + "----------------------------------------------------------------------------------\r\n" + ); + while (paVar2 = aos_readdir(dir), paVar2 != (aos_dirent_t *)0x0) { + memset(&env,0,0x80); + snprintf((char *)&env,0x7f,"%s",argv[1]); + __n = strlen((char *)&env); + if (*(char *)((int)&uStack180 + __n + 3) != '/') { + __n = strlen((char *)&env); + *(undefined *)((int)&env + __n) = 0x2f; + } + __n = strlen((char *)&env); + sVar3 = strlen((char *)&env); + snprintf((char *)((int)&env + __n),0x7f - sVar3,"%s",&paVar2->field_0x5); + iVar1 = aos_stat((char *)&env,st); + if (iVar1 == 0) { + iVar1 = -0x504; + if (-1 < (int)(st->st_mode << 0x11)) { + iVar1 = -0x4e8; + } + printf("EasyFlash V%s is initialize fail.\r\n" + iVar1 + 0xc,st->st_size, + &paVar2->field_0x5); + } + } + } + aos_closedir(dir); + } + else { + if (argc != 1) { + msg = "invalid parameter!\r\n"; +LAB_2305e0ea: + aos_cli_printf(msg); + goto LAB_2305df9e; + } +LAB_2305e0d2: + inode_forearch_name(cb_idnoe,&uStack180); + } +LAB_2305df9e: + vPortFree(st); + return; +} + + + +void uptime_cmd(char *buf,int len,int argc,char **argv) + +{ + char *pcVar1; + char *pcVar2; + int iVar3; + int iVar4; + longlong lVar5; + DItype DVar6; + + lVar5 = aos_now_ms(); + aos_cli_printf("UP time in ms %llu\r\n",buf,len,(int)lVar5); + pcVar1 = buf; + iVar3 = len; + __divdi3(); + __moddi3(); + pcVar2 = buf; + iVar4 = len; + __divdi3(); + __moddi3(); + __divdi3(); + __divdi3(); + DVar6 = __moddi3(); + aos_cli_printf("UP time in %llu days, %llu hours, %llu minutes, %llu seconds\r\n",buf,len,pcVar2, + iVar4,pcVar1,iVar3,(int)DVar6); + return; +} + + + +void reset_cmd(char *buf,int len,int argc,char **argv) + +{ + aos_cli_printf("system reset\r\n"); + hal_sys_reset(); + return; +} + + + +void poweroff_cmd(char *buf,int len,int argc,char **argv) + +{ + aos_cli_printf("poweroff\r\n"); + hal_poweroff(); + return; +} + + + +void reboot_cmd(char *buf,int len,int argc,char **argv) + +{ + aos_cli_printf("reboot\r\n"); + hal_reboot(); + return; +} + + + +// WARNING: Variable defined which should be unmapped: desc + +void version_cmd(char *buf,int len,int argc,char **argv) + +{ + int iVar1; + size_t sVar2; + int iStack76; + int num; + uint addr [4]; + uint size [4]; + char desc [4] [6]; + + iStack76 = 4; + aos_cli_printf("kernel version :posix\r\n"); + aos_cli_printf("release_bl_iot_sdk_1.6.11-1-g66bb28da-dirty"); + aos_cli_printf("\r\n"); + iVar1 = bl_chip_memory_ram(&iStack76,(uint *)&num,addr + 3,(char (*) [6])(size + 3)); + if (iVar1 == 0) { + aos_cli_printf("Memory Configuration on %d banks:\r\n",iStack76); + while (iVar1 < iStack76) { + aos_cli_printf(" [%d]%6s %6u Kbytes @ %p\r\n",iVar1,(int)size + iVar1 * 6 + 0xc, + addr[iVar1 + 3] >> 10,(&num)[iVar1]); + iVar1 = iVar1 + 1; + } + } + sVar2 = xPortGetFreeHeapSize(); + aos_cli_printf("Heap left: %d Bytes\r\n",sVar2); + return; +} + + + +void devname_cmd(char *buf,int len,int argc,char **argv) + +{ + aos_cli_printf("device name: %s\r\n",&UNK_230bf9d4); + return; +} + + + +void echo_cmd(char *buf,int len,int argc,char **argv) + +{ + int iVar1; + char *pcVar2; + + if (argc == 1) { + if (cli->echo_disabled == 0) { + pcVar2 = "Enabled"; + } + else { + pcVar2 = "Disabled"; + } + aos_cli_printf("Usage: echo on/off. Echo is currently %s\r\n",pcVar2); + return; + } + iVar1 = strcmp(argv[1],"on"); + if (iVar1 == 0) { + aos_cli_printf("Enable echo\r\n"); + cli->echo_disabled = 0; + } + else { + iVar1 = strcmp(argv[1],"off"); + if (iVar1 == 0) { + aos_cli_printf("Disable echo\r\n"); + cli->echo_disabled = 1; + } + } + return; +} + + + +void mmem_cmd(char *buf,int len,int argc,char **argv) + +{ + uint uVar1; + int iVar2; + uint uVar3; + + if (argc == 3) { + iVar2 = 4; +LAB_2305e382: + uVar1 = strtol(argv[2],(char **)0x0,0); + } + else { + if (argc == 4) { + iVar2 = strtol(argv[3],(char **)0x0,0); + goto LAB_2305e382; + } + if (argc != 2) goto LAB_2305e3a0; + uVar1 = 0; + iVar2 = 4; + } + len = strtol(argv[1],(char **)0x0,0); + if ((uint *)len != (uint *)0x0) { + if (iVar2 == 1) { + uVar3 = (uint)*(byte *)len; + *(byte *)len = (byte)uVar1; + uVar1 = (uint)*(byte *)len; + } + else { + if (iVar2 == 2) { + uVar3 = (uint)*(ushort *)len; + *(ushort *)len = (ushort)uVar1; + uVar1 = (uint)*(ushort *)len; + } + else { + uVar3 = *(uint *)len; + *(uint *)len = uVar1; + uVar1 = *(uint *)len; + } + } + aos_cli_printf("value on 0x%x change from 0x%x to 0x%x.\r\n",len,uVar3,uVar1); + return; + } +LAB_2305e3a0: + aos_cli_printf( + "m \r\naddr : address to modify\r\nvalue : new value (default is 0)\r\nwidth : width of unit, 1/2/4 (default is 4)\r\n" + ,len); + return; +} + + + +void pmem_cmd(char *buf,int len,int argc,char **argv) + +{ + ushort uVar1; + undefined4 *puVar2; + int iVar3; + undefined4 uVar4; + long lVar5; + uint uVar6; + char *pcStack52; + char *pos; + + pcStack52 = (char *)0x0; + if (argc == 3) { + lVar5 = 4; +LAB_2305e492: + iVar3 = strtol(argv[2],(char **)0x0,0); + if (0x400 < iVar3) { + iVar3 = 0x400; + } + } + else { + if (argc == 4) { + lVar5 = strtol(argv[3],(char **)0x0,0); + goto LAB_2305e492; + } + lVar5 = 4; + iVar3 = 0x10; + puVar2 = (undefined4 *)0x0; + if (argc != 2) goto LAB_2305e456; + } + puVar2 = (undefined4 *)strtol(argv[1],&pcStack52,0); +LAB_2305e456: + if ((pcStack52 == (char *)0x0) || (pcStack52 == argv[1])) { + aos_cli_printf( + "p \r\naddr : address to display\r\nnunits: number of units to display (default is 16)\r\nwidth : width of unit, 1/2/4 (default is 4)\r\n" + ); + } + else { + if (lVar5 == 1) { + uVar6 = 0; + while ((int)uVar6 < iVar3) { + if ((uVar6 & 0xf) == 0) { + aos_cli_printf("0x%08x:",(byte *)((int)puVar2 + uVar6)); + } + aos_cli_printf(" %02x",(uint)*(byte *)((int)puVar2 + uVar6)); + if ((uVar6 & 0xf) == 0xf) { + aos_cli_printf("\r\n"); + } + uVar6 = uVar6 + 1; + } + } + else { + if (lVar5 == 2) { + uVar6 = 0; + while ((int)uVar6 < iVar3) { + if ((uVar6 & 7) == 0) { + aos_cli_printf("0x%08x:",puVar2); + } + uVar1 = *(ushort *)puVar2; + puVar2 = (undefined4 *)((int)puVar2 + 2); + aos_cli_printf(" %04x",(uint)uVar1); + if ((uVar6 & 7) == 7) { + aos_cli_printf("\r\n"); + } + uVar6 = uVar6 + 1; + } + } + else { + uVar6 = 0; + while ((int)uVar6 < iVar3) { + if ((uVar6 & 3) == 0) { + aos_cli_printf("0x%08x:",puVar2); + } + uVar4 = *puVar2; + puVar2 = puVar2 + 1; + aos_cli_printf(" %08x",uVar4); + if ((uVar6 & 3) == 3) { + aos_cli_printf("\r\n"); + } + uVar6 = uVar6 + 1; + } + } + } + } + return; +} + + + +void help_cmd(char *buf,int len,int argc,char **argv) + +{ + cli_command *pcVar1; + uint idx; + char *pcVar2; + uint uVar3; + + aos_cli_printf("====Build-in Commands====\r\n"); + pcVar1 = built_ins; + aos_cli_printf("====Support %d cmds once, seperate by ; ====\r\n",4); + do { + if (pcVar1->name != (char *)0x0) { + pcVar2 = pcVar1->help; + if (pcVar1->help == (char *)0x0) { + pcVar2 = ""; + } + aos_cli_printf("%-25s: %s\r\n",pcVar2); + } + pcVar1 = pcVar1 + 1; + } while (pcVar1 != cmds_user); + aos_cli_printf("\r\n"); + aos_cli_printf("====User Commands====\r\n"); + uVar3 = 0x10; + idx = 0; + while ((idx < cli->num_static_cmds + 8 && (uVar3 < cli->num_commands))) { + pcVar1 = cli_command_get(idx,(int *)0x0); + if (((pcVar1 < built_ins) || ((cli_command *)((int)&built_ins[0xf].function + 3U) < pcVar1)) && + (pcVar1->name != (char *)0x0)) { + pcVar2 = pcVar1->help; + if (pcVar1->help == (char *)0x0) { + pcVar2 = ""; + } + aos_cli_printf("%-25s: %s\r\n",pcVar2); + uVar3 = uVar3 + 1; + } + idx = idx + 1; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int cli_getchar(char *inbuf) + +{ + int32_t iVar1; + uint uVar2; + uint32_t local_50; + uint32_t recv_size; + uart_dev_t uart_stdio; + + local_50 = 0; + memset(&recv_size,0,0x3c); + recv_size._0_1_ = '\0'; + iVar1 = hal_uart_recv_II((uart_dev_t *)&recv_size,inbuf,1,&local_50,0xffffffff); + if (iVar1 == 0) { + uVar2 = (uint)(local_50 == 1); + } + else { + uVar2 = 0; + } + return uVar2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void cli_main_input(char *buffer,int count) + +{ + byte bVar1; + char cVar2; + cli_st *pcVar3; + cli_st *pcVar4; + uint8_t uVar5; + anon_struct *paVar6; + undefined1 *argv; + size_t __n; + cli_command *pcVar7; + uint uVar8; + char *__s1; + char *__s; + anon_struct aVar9; + int iVar10; + byte *__src; + char *__s_00; + uint idx; + int iVar11; + size_t __n_00; + int iVar12; + uint uStack84; + anon_struct stat; + char c; + + pcVar3 = cli; + __s1 = cli->inbuf; + if (__s1 == (char *)0x0) { + __s1 = "inbuf_null\r\n"; +LAB_2305e7c4: + aos_cli_printf(__s1); + return; + } + iVar11 = 0; + uVar5 = esc_tag_len; +LAB_2305e6e6: + esc_tag_len = uVar5; + if (buffer == (char *)0x0) { + iVar12 = cli_getchar((char *)&stat); + if (iVar12 != 1) { + return; + } + } + else { + if (count <= iVar11) { + return; + } + __src = (byte *)(buffer + iVar11); + iVar11 = iVar11 + 1; + stat = (anon_struct)((uint)stat & 0xffffff00 | (uint)*__src); + } + pcVar4 = cli; + cVar2 = key1_4388; + if ((stat._0_1_ != '\n') && (stat._0_1_ != '\r')) { + uVar5 = esc_tag_len; + if (stat._0_1_ == '\x1b') { + esc_4387 = '\x01'; + key1_4388 = -1; + key2_4389 = -1; + } + else { + if (esc_4387 != '\0') { + if (key1_4388 < '\0') { + __s = (char *)(int)stat._0_1_; + key1_4388 = stat._0_1_; + if (__s == (char *)0x5b) goto LAB_2305e6e6; + __s1[pcVar3->bp] = '\x1b'; + idx = pcVar3->bp + 1; + pcVar3->bp = idx; + __s1[idx] = stat._0_1_; + pcVar3->bp = pcVar3->bp + 1; + if (cli->echo_disabled == 0) { + __s_00 = "\x1b%c"; +LAB_2305e84e: + printf(__s_00,__s); + } + } + else { + if ((key2_4389 < '\0') && (key2_4389 = stat._0_1_, stat._0_1_ == 't')) { + esc_tag[0] = '\x1b'; + esc_tag[1] = key1_4388; + esc_tag_len = '\x02'; + } + idx = SEXT14(key2_4389); + if (((idx & 0xff) - 0x41 & 0xff) < 2) { + __s_00 = __s1; + if (idx == 0x41) { + iVar10 = cli->his_idx; + iVar12 = iVar10; + do { + iVar12 = (iVar12 + 0xff) % 0x100; + if (cli->history[iVar12] != '\0') { + if (iVar10 != iVar12) { + do { + iVar12 = (iVar12 + 0xff) % 0x100; + } while (cli->history[iVar12] != '\0'); + iVar12 = (iVar12 + 1) % 0x100; + } + break; + } + } while (iVar10 != iVar12); + cli->his_idx = iVar12; + while (pcVar4->history[iVar10] != '\0') { + *__s_00 = pcVar4->history[iVar10]; + iVar10 = (iVar10 + 1) % 0x100; + __s_00 = __s_00 + 1; + } + } + else { + iVar10 = cli->his_idx; + iVar12 = iVar10; + while (cli->history[iVar12] != '\0') { + iVar12 = (iVar12 + 1) % 0x100; + } + if (iVar10 != iVar12) { + do { + iVar12 = (iVar12 + 1) % 0x100; + } while (cli->history[iVar12] == '\0'); + } + cli->his_idx = iVar12; + while (pcVar4->history[iVar10] != '\0') { + *__s_00 = pcVar4->history[iVar10]; + iVar10 = (iVar10 + 1) % 0x100; + __s_00 = __s_00 + 1; + } + } + *__s_00 = '\0'; + printf("\r\n# %s",__s1); + __n = strlen(__s1); + pcVar3->bp = __n; + esc_tag[0] = '\0'; + esc_tag_len = '\0'; + } + else { + if (idx == 0x74) { + if (0x3f < esc_tag_len) { + esc_tag[0] = '\0'; + esc_tag_len = '\0'; + esc_4387 = '\0'; + printf("Error: esc_tag buffer overflow\r\n"); + uVar5 = esc_tag_len; + goto LAB_2305e6e6; + } + idx = (uint)esc_tag_len + 1 & 0xff; + esc_tag[(uint)esc_tag_len] = stat._0_1_; + pcVar4 = cli; + uVar5 = (uint8_t)idx; + if (stat._0_1_ != 'm') goto LAB_2305e6e6; + esc_tag[idx] = '\0'; + esc_tag_len = esc_tag_len + '\x02'; + if (pcVar4->echo_disabled == 0) { + __s = esc_tag; + __s_00 = "%s"; + goto LAB_2305e84e; + } + } + else { + __s1[pcVar3->bp] = '\x1b'; + uVar8 = pcVar3->bp + 1; + pcVar3->bp = uVar8; + __s1[uVar8] = cVar2; + uVar8 = pcVar3->bp + 1; + pcVar3->bp = uVar8; + __s1[uVar8] = (char)(idx & 0xff); + pcVar3->bp = pcVar3->bp + 1; + if (cli->echo_disabled == 0) { + printf("\x1b%c%c"); + } + esc_tag[0] = '\0'; + esc_tag_len = '\0'; + } + } + } + esc_4387 = '\0'; + uVar5 = esc_tag_len; + goto LAB_2305e6e6; + } + __s1[pcVar3->bp] = stat._0_1_; + if ((stat._0_1_ == '\b') || (stat._0_1_ == '\x7f')) { + uVar5 = esc_tag_len; + if ((pcVar3->bp != 0) && + (pcVar3->bp = pcVar3->bp - 1, uVar5 = esc_tag_len, cli->echo_disabled == 0)) { + printf("%c %c",8,8); + uVar5 = esc_tag_len; + } + } + else { + if (stat._0_1_ == '\t') { + __s1[pcVar3->bp] = '\0'; + aos_cli_printf("\r\n"); + iVar12 = 0; + uVar8 = 0; + idx = 0; + __s_00 = (char *)0x0; + while ((idx < cli->num_static_cmds + 8 && (uVar8 < cli->num_commands))) { + pcVar7 = cli_command_get(idx,(int *)0x0); + __s = __s_00; + if (pcVar7->name != (char *)0x0) { + iVar10 = strncmp(__s1,pcVar7->name,pcVar3->bp); + if (iVar10 == 0) { + iVar12 = iVar12 + 1; + __s = pcVar7->name; + if (iVar12 != 1) { + if (iVar12 == 2) { + aos_cli_printf("%s %s ",__s_00); + __s = __s_00; + } + else { + aos_cli_printf("%s ",__s); + __s = __s_00; + } + } + } + uVar8 = uVar8 + 1; + } + idx = idx + 1; + __s_00 = __s; + } + if (iVar12 == 1) { + if ((__s_00 != (char *)0x0) && (__n = strlen(__s_00), __n < 0x100)) { + idx = pcVar3->bp; + memcpy(__s1 + idx,__s_00 + idx,__n - idx); + iVar12 = (__n - idx) + pcVar3->bp; + pcVar3->bp = iVar12 + 1; + __s1[iVar12] = ' '; + __s1[pcVar3->bp] = '\0'; + } + } + else { + if (1 < iVar12) { + aos_cli_printf("\r\n"); + } + } + aos_cli_printf("%s%s",&DAT_230bf950,__s1); + uVar5 = esc_tag_len; + } + else { + if (cli->echo_disabled == 0) { + printf("%c",(uint)stat & 0xff); + } + idx = pcVar3->bp + 1; + pcVar3->bp = idx; + uVar5 = esc_tag_len; + if (0xff < idx) { + aos_cli_printf("Error: input buffer overflow\r\n"); + aos_cli_printf("# "); + pcVar3->bp = 0; + return; + } + } + } + } + goto LAB_2305e6e6; + } + __s1[pcVar3->bp] = '\0'; + __s1 = pcVar4->inbuf; + pcVar3->bp = 0; + __n = strlen(__s1); + if (__n != 0) { + __s = cli->inbuf; + __n = strlen(__s); + pcVar3 = cli; + __n = __n + 1; + iVar11 = cli->his_cur; + __n_00 = 0x100 - iVar11; + cli->his_idx = iVar11; + __s_00 = pcVar3->history + iVar11; + iVar12 = iVar11 + __n + -1; + if ((int)__n_00 < (int)__n) { + iVar12 = iVar12 % 0x100; + cVar2 = pcVar3->history[iVar12]; + strncpy(__s_00,__s,__n_00); + __n = __n - __n_00; + __s = __s + __n_00; + __s_00 = cli->history; + } + else { + cVar2 = pcVar3->history[iVar11 + __n + -1]; + } + strncpy(__s_00,__s,__n); + pcVar3 = cli; + iVar11 = (iVar12 + 1) % 0x100; + cli->his_cur = iVar11; + if (cVar2 != '\0') { + while (iVar12 = (int)&pcVar3->initialized + iVar11, *(char *)(iVar12 + 0x144) != '\0') { + *(undefined *)(iVar12 + 0x144) = 0; + iVar11 = (iVar11 + 1) % 0x100; + } + } + } + stat = (anon_struct)0x0; + memset(argvall_4310,0,0x100); + memset(&stat,0,0x10); + memset(&uStack84,0,4); + iVar11 = 0; + paVar6 = &stat; + iVar12 = 0; + do { + __src = (byte *)(__s1 + iVar11); + bVar1 = *__src; + if (bVar1 != 0x20) { + if (0x20 < bVar1) { + if (bVar1 == 0x22) { + if (((iVar11 == 0) || (__s_00 = __s1 + iVar11 + -1, *__s_00 != '\\')) || + ((uStack84 & 1) == 0)) { + idx = uStack84 & 3; + if (idx != 1) { + if (idx == 2) goto LAB_2305ee5e; + if (idx == 0) { + aVar9 = *paVar6; + uStack84 = uStack84 & 0xfffffffc | 3; + *(int *)paVar6 = (int)aVar9 + 1; + *(char **)(argvall_4310 + (iVar12 * 0x10 + (int)aVar9) * 4) = __s1 + iVar11 + 1; + } + else { + if (idx == 3) { + uStack84._0_1_ = (byte)uStack84 & 0xfc; + goto LAB_2305ee24; + } + } + } + } + else { +LAB_2305edc0: + iVar11 = iVar11 + -1; + __n = strlen((char *)__src); + memcpy(__s_00,__src,__n + 1); + } + } + else { + if (bVar1 != 0x3b) goto LAB_2305e78e; + if (((iVar11 != 0) && (__s_00 = __s1 + iVar11 + -1, *__s_00 == '\\')) && + ((uStack84 & 1) != 0)) goto LAB_2305edc0; + if ((uStack84 & 2) != 0) goto LAB_2305ee5e; + if ((uStack84 & 3) == 1) { + uStack84 = uStack84 & 0xfffffffe; + *__src = 0; + if ((*paVar6 != (anon_struct)0x0) && (iVar12 = iVar12 + 1, iVar12 < 4)) { + paVar6 = &stat + iVar12; + } + } + } + goto LAB_2305ed18; + } + if (bVar1 != 0) { +LAB_2305e78e: + if ((uStack84 & 1) == 0) { + aVar9 = *paVar6; + uStack84 = uStack84 | 1; + *(int *)paVar6 = (int)aVar9 + 1; + *(byte **)(argvall_4310 + (iVar12 * 0x10 + (int)aVar9) * 4) = __src; + } + goto LAB_2305ed18; + } + if ((uStack84 & 2) == 0) { + uStack84 = uStack84 | 4; + goto LAB_2305ed18; + } +LAB_2305ee5e: + aos_cli_printf("syntax error\r\n"); + goto LAB_2305ed80; + } + if (((iVar11 != 0) && (__s_00 = __s1 + iVar11 + -1, *__s_00 == '\\')) && ((uStack84 & 1) != 0)) + goto LAB_2305edc0; + if ((uStack84 & 3) == 1) { + uStack84._0_1_ = (byte)uStack84 & 0xfe; +LAB_2305ee24: + uStack84 = uStack84 & 0xffffff00 | (uint)(byte)uStack84; + *__src = 0; + } +LAB_2305ed18: + } while ((((uStack84 & 4) == 0) && (iVar11 = iVar11 + 1, iVar11 < 0x100)) && + ((iVar12 < 4 && ((int)*paVar6 < 0x10)))); + if ((uStack84 & 2) != 0) goto LAB_2305ee5e; + paVar6 = &stat; + argv = argvall_4310; + idx = 0; + iVar11 = 0; + do { + iVar11 = iVar11 + 1; + uVar8 = proc_onecmd((int)*paVar6,(char **)argv); + idx = idx | uVar8; + if (iVar12 < iVar11) break; + paVar6 = paVar6 + 1; + argv = (undefined1 *)((char **)argv + 0x10); + } while (iVar11 != 4); + if (idx == 1) { + if (__s1 != (char *)0x0) { + aos_cli_printf("command \'%s\' not found\r\n",__s1); + } + } + else { + if (idx == 2) goto LAB_2305ee5e; + } +LAB_2305ed80: + aos_cli_printf("\r\n"); + esc_tag[0] = '\0'; + esc_tag_len = '\0'; + __s1 = "# "; + goto LAB_2305e7c4; +} + + + +void console_cb_read(int fd,void *param) + +{ + ssize_t count; + char acStack32 [4]; + char buffer [16]; + + count = aos_read(fd,acStack32,0x10); + if (0 < count) { + if (count < 0x11) { + fd_console = fd; + cli_main_input(acStack32,count); + } + else { + printf("-------------BUG from aos_read for ret\r\n"); + } + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void aos_cli_input_direct(char *buffer,int count) + +{ + byte bVar1; + char cVar2; + cli_st *pcVar3; + cli_st *pcVar4; + uint8_t uVar5; + uint *puVar6; + undefined1 *argv; + size_t __n; + cli_command *pcVar7; + uint uVar8; + char *__s1; + char *__s; + uint idx; + int iVar9; + byte *__src; + char *__s_00; + int iVar10; + size_t __n_00; + int iVar11; + uint uStack84; + uint auStack80 [7]; + + pcVar3 = cli; + __s1 = cli->inbuf; + if (__s1 == (char *)0x0) { + __s1 = "inbuf_null\r\n"; +LAB_2305e7c4: + aos_cli_printf(__s1); + return; + } + iVar10 = 0; + uVar5 = esc_tag_len; +LAB_2305e6e6: + esc_tag_len = uVar5; + if (buffer == (char *)0x0) { + iVar11 = cli_getchar((char *)auStack80); + if (iVar11 != 1) { + return; + } + } + else { + if (count <= iVar10) { + return; + } + __src = (byte *)(buffer + iVar10); + iVar10 = iVar10 + 1; + auStack80[0] = auStack80[0] & 0xffffff00 | (uint)*__src; + } + pcVar4 = cli; + cVar2 = key1_4388; + if (((char)auStack80[0] != '\n') && ((char)auStack80[0] != '\r')) { + uVar5 = esc_tag_len; + if ((char)auStack80[0] == '\x1b') { + esc_4387 = '\x01'; + key1_4388 = -1; + key2_4389 = -1; + } + else { + if (esc_4387 != '\0') { + if (key1_4388 < '\0') { + __s = (char *)(int)(char)auStack80[0]; + key1_4388 = (char)auStack80[0]; + if (__s == (char *)0x5b) goto LAB_2305e6e6; + __s1[pcVar3->bp] = '\x1b'; + idx = pcVar3->bp + 1; + pcVar3->bp = idx; + __s1[idx] = (char)auStack80[0]; + pcVar3->bp = pcVar3->bp + 1; + if (cli->echo_disabled == 0) { + __s_00 = "\x1b%c"; +LAB_2305e84e: + printf(__s_00,__s); + } + } + else { + if ((key2_4389 < '\0') && (key2_4389 = (char)auStack80[0], (char)auStack80[0] == 't')) { + esc_tag[0] = '\x1b'; + esc_tag[1] = key1_4388; + esc_tag_len = '\x02'; + } + idx = SEXT14(key2_4389); + if (((idx & 0xff) - 0x41 & 0xff) < 2) { + __s_00 = __s1; + if (idx == 0x41) { + iVar9 = cli->his_idx; + iVar11 = iVar9; + do { + iVar11 = (iVar11 + 0xff) % 0x100; + if (cli->history[iVar11] != '\0') { + if (iVar9 != iVar11) { + do { + iVar11 = (iVar11 + 0xff) % 0x100; + } while (cli->history[iVar11] != '\0'); + iVar11 = (iVar11 + 1) % 0x100; + } + break; + } + } while (iVar9 != iVar11); + cli->his_idx = iVar11; + while (pcVar4->history[iVar9] != '\0') { + *__s_00 = pcVar4->history[iVar9]; + iVar9 = (iVar9 + 1) % 0x100; + __s_00 = __s_00 + 1; + } + } + else { + iVar9 = cli->his_idx; + iVar11 = iVar9; + while (cli->history[iVar11] != '\0') { + iVar11 = (iVar11 + 1) % 0x100; + } + if (iVar9 != iVar11) { + do { + iVar11 = (iVar11 + 1) % 0x100; + } while (cli->history[iVar11] == '\0'); + } + cli->his_idx = iVar11; + while (pcVar4->history[iVar9] != '\0') { + *__s_00 = pcVar4->history[iVar9]; + iVar9 = (iVar9 + 1) % 0x100; + __s_00 = __s_00 + 1; + } + } + *__s_00 = '\0'; + printf("\r\n# %s",__s1); + __n = strlen(__s1); + pcVar3->bp = __n; + esc_tag[0] = '\0'; + esc_tag_len = '\0'; + } + else { + if (idx == 0x74) { + if (0x3f < esc_tag_len) { + esc_tag[0] = '\0'; + esc_tag_len = '\0'; + esc_4387 = '\0'; + printf("Error: esc_tag buffer overflow\r\n"); + uVar5 = esc_tag_len; + goto LAB_2305e6e6; + } + idx = (uint)esc_tag_len + 1 & 0xff; + esc_tag[(uint)esc_tag_len] = (char)auStack80[0]; + pcVar4 = cli; + uVar5 = (uint8_t)idx; + if ((char)auStack80[0] != 'm') goto LAB_2305e6e6; + esc_tag[idx] = '\0'; + esc_tag_len = esc_tag_len + '\x02'; + if (pcVar4->echo_disabled == 0) { + __s = esc_tag; + __s_00 = "%s"; + goto LAB_2305e84e; + } + } + else { + __s1[pcVar3->bp] = '\x1b'; + uVar8 = pcVar3->bp + 1; + pcVar3->bp = uVar8; + __s1[uVar8] = cVar2; + uVar8 = pcVar3->bp + 1; + pcVar3->bp = uVar8; + __s1[uVar8] = (char)(idx & 0xff); + pcVar3->bp = pcVar3->bp + 1; + if (cli->echo_disabled == 0) { + printf("\x1b%c%c"); + } + esc_tag[0] = '\0'; + esc_tag_len = '\0'; + } + } + } + esc_4387 = '\0'; + uVar5 = esc_tag_len; + goto LAB_2305e6e6; + } + __s1[pcVar3->bp] = (char)auStack80[0]; + if (((char)auStack80[0] == '\b') || ((char)auStack80[0] == '\x7f')) { + uVar5 = esc_tag_len; + if ((pcVar3->bp != 0) && + (pcVar3->bp = pcVar3->bp - 1, uVar5 = esc_tag_len, cli->echo_disabled == 0)) { + printf("%c %c",8,8); + uVar5 = esc_tag_len; + } + } + else { + if ((char)auStack80[0] == '\t') { + __s1[pcVar3->bp] = '\0'; + aos_cli_printf("\r\n"); + iVar11 = 0; + uVar8 = 0; + idx = 0; + __s_00 = (char *)0x0; + while ((idx < cli->num_static_cmds + 8 && (uVar8 < cli->num_commands))) { + pcVar7 = cli_command_get(idx,(int *)0x0); + __s = __s_00; + if (pcVar7->name != (char *)0x0) { + iVar9 = strncmp(__s1,pcVar7->name,pcVar3->bp); + if (iVar9 == 0) { + iVar11 = iVar11 + 1; + __s = pcVar7->name; + if (iVar11 != 1) { + if (iVar11 == 2) { + aos_cli_printf("%s %s ",__s_00); + __s = __s_00; + } + else { + aos_cli_printf("%s ",__s); + __s = __s_00; + } + } + } + uVar8 = uVar8 + 1; + } + idx = idx + 1; + __s_00 = __s; + } + if (iVar11 == 1) { + if ((__s_00 != (char *)0x0) && (__n = strlen(__s_00), __n < 0x100)) { + idx = pcVar3->bp; + memcpy(__s1 + idx,__s_00 + idx,__n - idx); + iVar11 = (__n - idx) + pcVar3->bp; + pcVar3->bp = iVar11 + 1; + __s1[iVar11] = ' '; + __s1[pcVar3->bp] = '\0'; + } + } + else { + if (1 < iVar11) { + aos_cli_printf("\r\n"); + } + } + aos_cli_printf("%s%s",&DAT_230bf950,__s1); + uVar5 = esc_tag_len; + } + else { + if (cli->echo_disabled == 0) { + printf("%c",auStack80[0] & 0xff); + } + idx = pcVar3->bp + 1; + pcVar3->bp = idx; + uVar5 = esc_tag_len; + if (0xff < idx) { + aos_cli_printf("Error: input buffer overflow\r\n"); + aos_cli_printf("# "); + pcVar3->bp = 0; + return; + } + } + } + } + goto LAB_2305e6e6; + } + __s1[pcVar3->bp] = '\0'; + __s1 = pcVar4->inbuf; + pcVar3->bp = 0; + __n = strlen(__s1); + if (__n != 0) { + __s = cli->inbuf; + __n = strlen(__s); + pcVar3 = cli; + __n = __n + 1; + iVar10 = cli->his_cur; + __n_00 = 0x100 - iVar10; + cli->his_idx = iVar10; + __s_00 = pcVar3->history + iVar10; + iVar11 = iVar10 + __n + -1; + if ((int)__n_00 < (int)__n) { + iVar11 = iVar11 % 0x100; + cVar2 = pcVar3->history[iVar11]; + strncpy(__s_00,__s,__n_00); + __n = __n - __n_00; + __s = __s + __n_00; + __s_00 = cli->history; + } + else { + cVar2 = pcVar3->history[iVar10 + __n + -1]; + } + strncpy(__s_00,__s,__n); + pcVar3 = cli; + iVar10 = (iVar11 + 1) % 0x100; + cli->his_cur = iVar10; + if (cVar2 != '\0') { + while (iVar11 = (int)&pcVar3->initialized + iVar10, *(char *)(iVar11 + 0x144) != '\0') { + *(undefined *)(iVar11 + 0x144) = 0; + iVar10 = (iVar10 + 1) % 0x100; + } + } + } + auStack80[0] = 0; + auStack80[1] = 0; + auStack80[2] = 0; + auStack80[3] = 0; + memset(argvall_4310,0,0x100); + memset(auStack80,0,0x10); + memset(&uStack84,0,4); + iVar10 = 0; + puVar6 = auStack80; + iVar11 = 0; + do { + __src = (byte *)(__s1 + iVar10); + bVar1 = *__src; + if (bVar1 != 0x20) { + if (0x20 < bVar1) { + if (bVar1 == 0x22) { + if (((iVar10 == 0) || (__s_00 = __s1 + iVar10 + -1, *__s_00 != '\\')) || + ((uStack84 & 1) == 0)) { + idx = uStack84 & 3; + if (idx != 1) { + if (idx == 2) goto LAB_2305ee5e; + if (idx == 0) { + idx = *puVar6; + uStack84 = uStack84 & 0xfffffffc | 3; + *puVar6 = idx + 1; + *(char **)(argvall_4310 + (iVar11 * 0x10 + idx) * 4) = __s1 + iVar10 + 1; + } + else { + if (idx == 3) { + uStack84._0_1_ = (byte)uStack84 & 0xfc; + goto LAB_2305ee24; + } + } + } + } + else { +LAB_2305edc0: + iVar10 = iVar10 + -1; + __n = strlen((char *)__src); + memcpy(__s_00,__src,__n + 1); + } + } + else { + if (bVar1 != 0x3b) goto LAB_2305e78e; + if (((iVar10 != 0) && (__s_00 = __s1 + iVar10 + -1, *__s_00 == '\\')) && + ((uStack84 & 1) != 0)) goto LAB_2305edc0; + if ((uStack84 & 2) != 0) goto LAB_2305ee5e; + if ((uStack84 & 3) == 1) { + uStack84 = uStack84 & 0xfffffffe; + *__src = 0; + if ((*puVar6 != 0) && (iVar11 = iVar11 + 1, iVar11 < 4)) { + puVar6 = auStack80 + iVar11; + } + } + } + goto LAB_2305ed18; + } + if (bVar1 != 0) { +LAB_2305e78e: + if ((uStack84 & 1) == 0) { + idx = *puVar6; + uStack84 = uStack84 | 1; + *puVar6 = idx + 1; + *(byte **)(argvall_4310 + (iVar11 * 0x10 + idx) * 4) = __src; + } + goto LAB_2305ed18; + } + if ((uStack84 & 2) == 0) { + uStack84 = uStack84 | 4; + goto LAB_2305ed18; + } +LAB_2305ee5e: + aos_cli_printf("syntax error\r\n"); + goto LAB_2305ed80; + } + if (((iVar10 != 0) && (__s_00 = __s1 + iVar10 + -1, *__s_00 == '\\')) && ((uStack84 & 1) != 0)) + goto LAB_2305edc0; + if ((uStack84 & 3) == 1) { + uStack84._0_1_ = (byte)uStack84 & 0xfe; +LAB_2305ee24: + uStack84 = uStack84 & 0xffffff00 | (uint)(byte)uStack84; + *__src = 0; + } +LAB_2305ed18: + } while ((((uStack84 & 4) == 0) && (iVar10 = iVar10 + 1, iVar10 < 0x100)) && + ((iVar11 < 4 && ((int)*puVar6 < 0x10)))); + if ((uStack84 & 2) != 0) goto LAB_2305ee5e; + puVar6 = auStack80; + argv = argvall_4310; + idx = 0; + iVar10 = 0; + do { + iVar10 = iVar10 + 1; + uVar8 = proc_onecmd(*puVar6,(char **)argv); + idx = idx | uVar8; + if (iVar11 < iVar10) break; + puVar6 = puVar6 + 1; + argv = (undefined1 *)((char **)argv + 0x10); + } while (iVar10 != 4); + if (idx == 1) { + if (__s1 != (char *)0x0) { + aos_cli_printf("command \'%s\' not found\r\n",__s1); + } + } + else { + if (idx == 2) goto LAB_2305ee5e; + } +LAB_2305ed80: + aos_cli_printf("\r\n"); + esc_tag[0] = '\0'; + esc_tag_len = '\0'; + __s1 = "# "; + goto LAB_2305e7c4; +} + + + +// WARNING: Variable defined which should be unmapped: qry +// WARNING: Could not reconcile some variable overlaps + +void get_dns_request(void *arg,udp_pcb *upcb,pbuf *p,ip_addr_t *addr,u16_t port) + +{ + u16_t uVar1; + int iVar2; + pbuf *buf; + uint uVar3; + char *dataptr; + char *pcVar4; + uint uVar5; + uint local_50; + int len; + dns_ans_hdr hdr; + dns_ans_hdr hdr_1; + dns_ans_ans qry; + + *(udp_pcb **)((int)arg + 0x108) = upcb; + *(ip_addr_t **)((int)arg + 0x10c) = addr; + *(u16_t *)((int)arg + 0x110) = port; + if (0xb < p->tot_len) { + pbuf_copy_partial(p,&len,0xc,0); + uVar1 = lwip_htons((u16_t)len); + *(u16_t *)((int)arg + 0x100) = uVar1; + uVar1 = lwip_htons(hdr.id); + *(u16_t *)((int)arg + 0x102) = uVar1; + local_50 = (uint)p->tot_len; + if (0xff < p->tot_len) { + local_50 = 0xff; + } + pbuf_copy_partial(p,arg,(u16_t)local_50,0xc); + iVar2 = utils_dns_domain_get((uint8_t *)arg,(uint8_t *)arg,(int *)&local_50); + if (iVar2 == 0) { + if ((0 < (int)local_50) && (*(char *)((int)arg + (local_50 - 1)) == '.')) { + local_50 = local_50 - 1; + } + *(undefined *)(local_50 + (int)arg) = 0; + } + } + pbuf_free(p); + buf = pbuf_alloc(PBUF_TRANSPORT,0x200,PBUF_RAM); + if (buf != (pbuf *)0x0) { + memset(&hdr.numauthrr,0,0xc); + pcVar4 = (char *)((int)arg + -1); + uVar3 = 0xc; + hdr.numauthrr = lwip_htons(*(u16_t *)((int)arg + 0x100)); + hdr.numextrarr = lwip_htons(0x8180); + hdr_1.id = lwip_htons(1); + hdr_1.flag = lwip_htons(1); + hdr_1.numquestions = lwip_htons(0); + hdr_1.numanswers = lwip_htons(0); + pbuf_take(buf,&hdr.numauthrr,0xc); + do { + dataptr = pcVar4 + 1; + uVar5 = 0; + pcVar4 = dataptr; + while ((*pcVar4 != '.' && (*pcVar4 != '\0'))) { + uVar5 = uVar5 + 1 & 0xff; + pcVar4 = pcVar4 + 1; + } + pbuf_put_at(buf,(u16_t)uVar3,(u8_t)uVar5); + pbuf_take_at(buf,dataptr,(u16_t)((uint)((int)(pcVar4 + -(int)dataptr) * 0x10000) >> 0x10), + (u16_t)((uVar3 + 1) * 0x10000 >> 0x10)); + uVar5 = uVar3 + uVar5 & 0xffff; + uVar3 = uVar5 + 1 & 0xffff; + } while (*pcVar4 != '\0'); + pbuf_put_at(buf,(u16_t)((uVar5 + 1) * 0x10000 >> 0x10),'\0'); + hdr_1.numauthrr = lwip_htons(1); + hdr_1.numextrarr = lwip_htons(1); + lwip_htons(0xc00c); + lwip_htons(1); + lwip_htons(1); + lwip_htons(0); + lwip_htonl(0x3c0004); + lwip_htonl(0xc0a8a901); + pbuf_take_at(buf,&hdr_1.numauthrr,0x14,(u16_t)((uVar5 + 2) * 0x10000 >> 0x10)); + pbuf_realloc(buf,(u16_t)((uVar5 + 0x16) * 0x10000 >> 0x10)); + udp_sendto(*(udp_pcb **)((int)arg + 0x108),buf,*(ip_addr_t **)((int)arg + 0x10c), + *(u16_t *)((int)arg + 0x110)); + pbuf_free(buf); + } + return; +} + + + +void dns_server_init(void) + +{ + err_t eVar1; + udp_pcb *pcb; + undefined3 extraout_var; + void *__s; + + pcb = udp_new(); + if (pcb == (udp_pcb *)0x0) { + return; + } + eVar1 = udp_bind(pcb,&ip_addr_any,0x35); + if ((CONCAT31(extraout_var,eVar1) == 0) && (__s = pvPortMalloc(0x114), __s != (void *)0x0)) { + memset(__s,0,4); + udp_recv(pcb,get_dns_request,__s); + return; + } + udp_remove(pcb); + return; +} + + + +EfErrCode easyflash_init(void) + +{ + EfErrCode EVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + char *format; + size_t local_18; + size_t default_env_set_size; + ef_env *default_env_set; + + local_18 = 0; + EVar1 = ef_port_init((ef_env **)&default_env_set_size,&local_18); + if ((CONCAT31(extraout_var,EVar1) == 0) && + (EVar1 = ef_env_init((ef_env *)default_env_set_size,local_18), + CONCAT31(extraout_var_00,EVar1) == 0)) { + format = "EasyFlash V%s is initialize success.\r\n"; + } + else { + format = "EasyFlash V%s is initialize fail.\r\n"; + } + ef_log_info(format,&UNK_230bffc4); + ef_log_info("You can get the latest version on https://github.com/armink/EasyFlash .\r\n"); + return EVar1; +} + + + +size_t get_status(uint8_t *status_table,size_t status_num) + +{ + size_t sVar1; + size_t sVar2; + + sVar2 = status_num - 1; + do { + sVar1 = sVar2; + sVar2 = sVar1 - 1; + if (sVar2 == 0xffffffff) { + return sVar1; + } + } while (status_table[sVar2] != '\0'); + return sVar1; +} + + + +void update_sector_cache(uint32_t sec_addr,uint32_t empty_addr) + +{ + sector_cache_node *psVar1; + int iVar2; + int iVar3; + uint32_t uVar4; + + psVar1 = sector_cache_table; + iVar2 = 4; + iVar3 = 0; + do { + uVar4 = psVar1->addr; + if ((sec_addr < empty_addr) && (empty_addr < sec_addr + 0x1000)) { + if (sec_addr == uVar4) { + psVar1 = sector_cache_table + iVar3; + goto LAB_2305f1dc; + } + if ((uVar4 == 0xffffffff) && (iVar2 == 4)) { + iVar2 = iVar3; + } + } + else { + if (sec_addr == uVar4) { + sector_cache_table[iVar3].addr = 0xffffffff; + return; + } + } + iVar3 = iVar3 + 1; + psVar1 = psVar1 + 1; + } while (iVar3 != 4); + if (iVar2 != 4) { + psVar1 = sector_cache_table + iVar2; + psVar1->addr = sec_addr; +LAB_2305f1dc: + psVar1->empty_addr = empty_addr; + } + return; +} + + + +uint32_t get_next_sector_addr(sector_meta_data_t pre_sec) + +{ + uint uVar1; + int iVar2; + + uVar1 = env_start_addr; + if (pre_sec->addr != 0xffffffff) { + if (pre_sec->combined == 0xffffffff) { + iVar2 = 0x1000; + } + else { + iVar2 = pre_sec->combined << 0xc; + } + uVar1 = iVar2 + pre_sec->addr; + if (env_start_addr + 0x8000 <= uVar1) { + return 0xffffffff; + } + } + return uVar1; +} + + + +_Bool gc_check_cb(sector_meta_data_t sector,void *arg1,void *arg2) + +{ + if (sector->check_ok != false) { + *(int *)arg1 = *(int *)arg1 + 1; + } + return false; +} + + + +void update_env_cache(char *name,size_t name_len,uint32_t addr) + +{ + uint32_t uVar1; + int iVar2; + env_cache_node *peVar3; + int iVar4; + int iVar5; + ushort uVar6; + + uVar1 = ef_calc_crc32(0,name,name_len); + peVar3 = env_cache_table; + uVar6 = 0xffff; + iVar5 = 0x10; + iVar2 = 0x10; + iVar4 = 0; + do { + if (addr == 0xffffffff) { + if ((uint)peVar3->name_crc == uVar1 >> 0x10) { + peVar3 = env_cache_table + iVar4; + env_cache_table[iVar4].addr = 0xffffffff; + goto LAB_2305f2da; + } + } + else { + if ((uint)peVar3->name_crc == uVar1 >> 0x10) { + env_cache_table[iVar4].addr = addr; + return; + } + if (peVar3->addr == 0xffffffff) { + if (iVar2 == 0x10) { + iVar2 = iVar4; + } + } + else { + if (peVar3->active != 0) { + peVar3->active = peVar3->active - 1; + } + if (peVar3->active < uVar6) { + iVar5 = iVar4; + uVar6 = peVar3->active; + } + } + } + iVar4 = iVar4 + 1; + peVar3 = peVar3 + 1; + } while (iVar4 != 0x10); + if ((iVar2 != 0x10) || (iVar2 = iVar5, iVar5 != 0x10)) { + peVar3 = env_cache_table + iVar2; + env_cache_table[iVar2].addr = addr; + peVar3->name_crc = (uint16_t)(uVar1 >> 0x10); +LAB_2305f2da: + peVar3->active = 0; + } + return; +} + + + +_Bool find_env_cb(env_node_obj_t env,void *arg1,void *arg2) + +{ + _Bool _Var1; + size_t sVar2; + int iVar3; + + sVar2 = strlen((char *)arg1); + if (((((uint)env->name_len == sVar2) && (_Var1 = env->crc_is_ok, _Var1 != false)) && + (env->status == ENV_WRITE)) && + (iVar3 = strncmp(env->name,(char *)arg1,(uint)env->name_len), iVar3 == 0)) { + *(undefined *)arg2 = 1; + } + else { + _Var1 = false; + } + return _Var1; +} + + + +_Bool sector_statistics_cb(sector_meta_data_t sector,void *arg1,void *arg2) + +{ + sector_store_status_t sVar1; + + if (sector->check_ok != false) { + sVar1 = (sector->status).store; + if (sVar1 == SECTOR_STORE_EMPTY) { + *(int *)arg1 = *(int *)arg1 + 1; + } + else { + if (sVar1 == SECTOR_STORE_USING) { + *(int *)arg2 = *(int *)arg2 + 1; + } + } + } + return false; +} + + + +_Bool alloc_env_cb(sector_meta_data_t sector,void *arg1,void *arg2) + +{ + sector_dirty_status_t sVar1; + _Bool _Var2; + + _Var2 = sector->check_ok; + if (_Var2 != false) { + if ((*(uint *)arg1 < sector->remain) && + ((sVar1 = (sector->status).dirty, sVar1 == SECTOR_DIRTY_FALSE || + ((sVar1 == SECTOR_DIRTY_TRUE && (gc_request == false)))))) { + *(uint32_t *)arg2 = sector->empty_env; + } + else { + _Var2 = false; + } + } + return _Var2; +} + + + +EfErrCode write_status(uint32_t addr,uint8_t *status_table,size_t status_num,size_t status_index) + +{ + EfErrCode EVar1; + + if (status_num <= status_index) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x111, + "(%s) has assert failed at %s.\r\n","status_index < status_num","write_status"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + if (status_table == (uint8_t *)0x0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x112, + "(%s) has assert failed at %s.\r\n","status_table","write_status"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + memset(status_table,0xff,status_num * 8 - 1 >> 3); + status_table[status_index - 1] = 0; + EVar1 = ef_port_write(addr + (status_index - 1),(uint32_t *)(status_table + (status_index - 1)),1) + ; + return EVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +EfErrCode read_env(env_node_obj_t env) + +{ + char "read_env" [9]; + uint uVar1; + uint32_t crc; + size_t size; + uint uVar2; + uint32_t uStack92; + env_hdr_data env_hdr; + uint8_t buf [32]; + + ef_port_read((env->addr).start,&uStack92,0x1c); + size = get_status((uint8_t *)&uStack92,6); + env->status = (env_status_t)(size & 0xff); + env->len = env_hdr.magic; + uVar2 = env_hdr.magic - 0x14; + if (uVar2 < 0x7fed) { + if (env_hdr.magic - 0xfed < 0x7013) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x223 + ,"(%s) has assert failed at %s.\r\n",0x230aa38c,"read_env"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + uVar1 = 0; + crc = 0; + while (uVar1 < uVar2) { + size = 0x20; + if (uVar2 <= uVar1 + 0x20) { + size = uVar2 - uVar1; + } + ef_port_read((env->addr).start + 0x14 + uVar1,&env_hdr.value_len,size); + crc = ef_calc_crc32(crc,&env_hdr.value_len,size); + uVar1 = uVar1 + size; + } + if (env_hdr.len == crc) { + crc = (env->addr).start + 0x1c; + env->crc_is_ok = true; + ef_port_read(crc,(uint32_t *)env->name,(uint)(byte)env_hdr.crc32); + (env->addr).value = crc + (byte)env_hdr.crc32; + env->value_len = env_hdr._20_4_; + env->name_len = (byte)env_hdr.crc32; + return EF_NO_ERR; + } + } + else { + env->len = 0x1c; + if ((size & 0xff) != 5) { + env->status = ENV_ERR_HDR; + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x21c + ,"Error: The ENV @0x%08X length has an error.\r\n",(env->addr).start); + write_status((env->addr).start,(uint8_t *)&uStack92,6,5); + } + } + env->crc_is_ok = false; + return EF_READ_ERR; +} + + + +// WARNING: Variable defined which should be unmapped: status_table + +EfErrCode update_sec_status(sector_meta_data_t sector,size_t new_env_len,_Bool *is_full) + +{ + sector_store_status_t sVar1; + EfErrCode EVar2; + uint8_t auStack20 [4]; + uint8_t status_table [3]; + + sVar1 = (sector->status).store; + if (sVar1 == SECTOR_STORE_EMPTY) { + EVar2 = write_status(sector->addr,auStack20,4,2); + } + else { + EVar2 = EF_NO_ERR; + if (sVar1 == SECTOR_STORE_USING) { + if ((sector->remain < 0x5c) || (sector->remain - new_env_len < 0x5c)) { + EVar2 = write_status(sector->addr,auStack20,4,3); + update_sector_cache(sector->addr,sector->addr + 0x1000); + if (is_full != (_Bool *)0x0) { + *is_full = true; + } + } + else { + if (is_full != (_Bool *)0x0) { + *is_full = false; + } + } + } + } + return EVar2; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +EfErrCode format_sector(uint32_t addr) + +{ + EfErrCode EVar1; + undefined3 extraout_var; + undefined uStack36; + undefined uStack33; + sector_hdr_data sec_hdr; + + if ((addr & 0xfff) != 0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x3b5, + "(%s) has assert failed at %s.\r\n","addr % SECTOR_SIZE == 0","format_sector"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + EVar1 = ef_port_erase(addr,0x1000); + if (CONCAT31(extraout_var,EVar1) == 0) { + memset(&uStack36,0xff,0x14); + memset(&uStack36,0xff,3); + uStack36 = 0; + memset(&uStack36 + 3,0xff,3); + sec_hdr._4_4_ = 0x30344645; + uStack33 = 0; + sec_hdr.magic = 0xffffffff; + sec_hdr.combined = 0xffffffff; + EVar1 = ef_port_write(addr,&uStack36,0x14); + update_sector_cache(addr,addr + 0x1000); + } + return EVar1; +} + + + +_Bool check_sec_hdr_cb(sector_meta_data_t sector,void *arg1,void *arg2) + +{ + if (sector->check_ok == false) { + ef_log_info("Warning: Sector header check failed. Format this sector (0x%08x).\r\n",sector->addr + ); + *(int *)arg1 = *(int *)arg1 + 1; + format_sector(sector->addr); + return false; + } + return false; +} + + + +_Bool print_env_cb(env_node_obj_t env,void *arg1,void *arg2) + +{ + _Bool _Var1; + uint uVar2; + uint uVar3; + size_t sVar4; + size_t size; + int iVar5; + _Bool _Var6; + uint32_t local_50; + uint8_t buf [32]; + + _Var1 = env->crc_is_ok; + if ((_Var1 != false) && (*(uint32_t *)arg1 = *(int *)arg1 + env->len, env->status == ENV_WRITE)) { + ef_print("%.*s=",(uint)env->name_len,env->name); + if (env->value_len < 0xf8c) { + iVar5 = 2; + _Var6 = false; + while( true ) { + uVar2 = 0; + while (uVar3 = env->value_len, uVar2 < uVar3) { + size = 0x20; + if (uVar3 <= uVar2 + 0x20) { + size = uVar3 - uVar2; + } + ef_port_read((env->addr).value + uVar2,&local_50,size); + sVar4 = 0; + if (_Var6 == false) { + while (size != sVar4) { + if (0x5e < (uint)*(byte *)((int)&local_50 + sVar4) - 0x20) goto LAB_2305f760; + sVar4 = sVar4 + 1; + } + } + else { + ef_print("%.*s",size,&local_50); + } + uVar2 = uVar2 + size; + } + if (iVar5 == 1) break; + iVar5 = 1; + _Var6 = _Var1; + } + } + else { +LAB_2305f760: + ef_print("blob @0x%08X %dbytes",(env->addr).value,env->value_len); + } + ef_print("\r\n"); + } + return false; +} + + + +// WARNING: Variable defined which should be unmapped: buf + +uint32_t get_next_env_addr(sector_meta_data_t sector,env_node_obj_t pre_env) + +{ + uint uVar1; + uint32_t uVar2; + sector_cache_node *psVar3; + uint addr; + int iVar4; + uint32_t *puVar5; + uint32_t uVar6; + uint32_t local_40; + uint8_t buf [32]; + + if ((sector->status).store != SECTOR_STORE_EMPTY) { + addr = (pre_env->addr).start; + uVar6 = sector->addr; + if (addr == 0xffffffff) { + return uVar6 + 0x14; + } + if (addr <= uVar6 + 0x1000) { + uVar1 = addr + 1; + if (pre_env->crc_is_ok != false) { + uVar1 = pre_env->len + addr; + } + psVar3 = sector_cache_table; + iVar4 = 0; + do { + if ((uVar1 & 0xfffff000) == psVar3->addr) { + if (uVar1 == sector_cache_table[iVar4].empty_addr) goto LAB_2305f80c; + break; + } + iVar4 = iVar4 + 1; + psVar3 = psVar3 + 1; + } while (iVar4 != 4); + addr = uVar1; + while (addr < uVar6 + 0xfec) { + ef_port_read(addr,&local_40,0x20); + uVar2 = addr - 8; + puVar5 = &local_40; + do { + if (uVar6 + 0xfe4 == uVar2) break; + if ((*puVar5 == 0x3034564b) && (uVar1 <= uVar2)) goto LAB_2305f80e; + uVar2 = uVar2 + 1; + puVar5 = (uint32_t *)((int)puVar5 + 1); + } while (addr + 0x14 != uVar2); + addr = addr + 0x1c; + } +LAB_2305f80c: + uVar2 = 0xffffffff; +LAB_2305f80e: + if ((sector->addr + 0x1000 < uVar2) || (pre_env->len == 0)) { + uVar2 = 0xffffffff; + } + return uVar2; + } + } + return 0xffffffff; +} + + + +// WARNING: Could not reconcile some variable overlaps + +EfErrCode read_sector_meta_data(uint32_t addr,sector_meta_data_t sector,_Bool traversal) + +{ + char cVar1; + EfErrCode EVar2; + uint uVar3; + size_t size; + undefined3 in_register_00002031; + sector_cache_node *psVar4; + int iVar5; + uint32_t uVar6; + uint32_t uVar7; + size_t sVar8; + uint addr_00; + char cVar9; + uint32_t uVar10; + undefined4 uStack188; + sector_hdr_data sec_hdr; + uint8_t buf [32]; + env_node_obj env_meta; + + if ((addr & 0xfff) != 0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x24a, + "(%s) has assert failed at %s.\r\n","addr % SECTOR_SIZE == 0", + "read_sector_meta_data"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + ef_port_read(addr,&uStack188,0x14); + sector->addr = addr; + sector->magic = sec_hdr._4_4_; + if (sec_hdr._4_4_ == 0x30344645) { + sector->combined = sec_hdr.magic; + sector->check_ok = true; + size = get_status((uint8_t *)&uStack188,4); + uVar3 = size & 0xff; + EVar2 = (EfErrCode)uVar3; + (sector->status).store = EVar2; + size = get_status((uint8_t *)((int)&uStack188 + 3),4); + (sector->status).dirty = (sector_dirty_status_t)size; + if (CONCAT31(in_register_00002031,traversal) != 0) { + sector->remain = 0; + sector->empty_env = addr + 0x14; + if (uVar3 == 1) { + sector->remain = 0xfec; + } + else { + if (uVar3 == 2) { + psVar4 = sector_cache_table; + iVar5 = 0; + do { + if (addr == psVar4->addr) { + uVar6 = sector_cache_table[iVar5].empty_addr; + sector->empty_env = uVar6; + sector->remain = (addr + 0x1000) - uVar6; + goto LAB_2305f95a; + } + iVar5 = iVar5 + 1; + psVar4 = psVar4 + 1; + } while (iVar5 != 4); + sector->remain = 0xfec; + do { + uVar6 = get_next_env_addr(sector,(env_node_obj_t)(buf + 0x1c)); + if (uVar6 == 0xffffffff) { + EVar2 = EF_NO_ERR; +LAB_2305f9f8: + uVar7 = sector->addr; + uVar6 = sector->empty_env; + uVar3 = uVar7 + 0x1000; + cVar9 = '\0'; + uVar10 = uVar6; + while (addr_00 = uVar10, addr_00 < uVar3) { + uVar10 = addr_00 + 0x20; + size = 0x20; + if (uVar3 <= uVar10) { + size = (uVar7 + 0x1020) - uVar10; + } + ef_port_read(addr_00,&sec_hdr.reserved,size); + sVar8 = 0; + while (size != sVar8) { + cVar1 = *(char *)((int)&sec_hdr.reserved + sVar8); + if ((cVar9 != -1) && (cVar1 == -1)) { + uVar6 = addr_00 + sVar8; + } + sVar8 = sVar8 + 1; + cVar9 = cVar1; + } + } + if (cVar9 != -1) { + uVar6 = uVar3; + } + if (sector->empty_env != uVar6) { + sector->empty_env = uVar6; + sector->remain = (sector->addr + 0x1000) - uVar6; + } + update_sector_cache(sector->addr,sector->empty_env); + return EVar2; + } + read_env((env_node_obj_t)(buf + 0x1c)); + if ((buf[29] == '\0') && ((buf[28] & 0xfb) != 1)) { + ef_log_info("Error: The ENV (@0x%08X) CRC32 check failed!\r\n",uVar6); + sector->remain = 0; + goto LAB_2305f9f8; + } + sector->empty_env = sector->empty_env + env_meta.magic; + sector->remain = sector->remain - env_meta.magic; + } while( true ); + } + } + } +LAB_2305f95a: + EVar2 = EF_NO_ERR; + } + else { + sector->check_ok = false; + sector->combined = 0xffffffff; + EVar2 = EF_ENV_INIT_FAILED; + } + return EVar2; +} + + + +void sector_iterator(sector_meta_data_t sector,sector_store_status_t status,void *arg1,void *arg2, + anon_subr__Bool_sector_meta_data_t_void_ptr_void_ptr *callback, + _Bool traversal_env) + +{ + _Bool _Var1; + uint32_t addr; + undefined3 extraout_var; + undefined3 in_register_0000202d; + undefined3 in_register_0000203d; + + sector->addr = 0xffffffff; + do { + do { + addr = get_next_sector_addr(sector); + if (addr == 0xffffffff) { + return; + } + read_sector_meta_data(addr,sector,false); + } while ((CONCAT31(in_register_0000202d,status) != 0) && + ((uint)(sector->status).store != CONCAT31(in_register_0000202d,status))); + if (CONCAT31(in_register_0000203d,traversal_env) != 0) { + read_sector_meta_data(addr,sector,true); + } + _Var1 = (*callback)(sector,arg1,arg2); + } while (CONCAT31(extraout_var,_Var1) == 0); + return; +} + + + +// WARNING: Variable defined which should be unmapped: using_sector + +uint32_t alloc_env(sector_meta_data_t sector,size_t env_size) + +{ + size_t asStack36 [2]; + uint32_t local_1c; + uint32_t empty_env; + size_t empty_sector; + size_t using_sector; + + local_1c = 0xffffffff; + empty_env = 0; + empty_sector = 0; + asStack36[0] = env_size; + sector_iterator(sector,SECTOR_STORE_UNUSED,&empty_env,&empty_sector,sector_statistics_cb,false); + if (empty_sector != 0) { + sector_iterator(sector,SECTOR_STORE_USING,asStack36,&local_1c,alloc_env_cb,true); + } + if ((empty_env != 0) && (local_1c == 0xffffffff)) { + if ((empty_env < 2) && (gc_request == false)) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x42d + ,"Trigger a GC check after alloc ENV failed.\r\n"); + gc_request = true; + } + else { + sector_iterator(sector,SECTOR_STORE_EMPTY,asStack36,&local_1c,alloc_env_cb,true); + } + } + return local_1c; +} + + + +void gc_collect(void) + +{ + uint uStack44; + size_t empty_sec; + sector_meta_data sector; + + uStack44 = 0; + sector_iterator((sector_meta_data_t)&empty_sec,SECTOR_STORE_EMPTY,&uStack44,(void *)0x0, + gc_check_cb,false); + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x4fa, + "The remain empty sector is %d, GC threshold is %d.\r\n",uStack44,1); + if (uStack44 < 2) { + sector_iterator((sector_meta_data_t)&empty_sec,SECTOR_STORE_UNUSED,(void *)0x0,(void *)0x0,do_gc + ,false); + } + gc_request = false; + return; +} + + + +uint32_t new_env(sector_meta_data_t sector,size_t env_size) + +{ + uint32_t uVar1; + + uVar1 = alloc_env(sector,env_size); + if ((uVar1 == 0xffffffff) && (gc_request != false)) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x4b6, + "Warning: Alloc an ENV (size %d) failed when new ENV. Now will GC then retry.\r\n", + env_size); + gc_collect(); + uVar1 = alloc_env(sector,env_size); + } + return uVar1; +} + + + +_Bool check_and_recovery_gc_cb(sector_meta_data_t sector,void *arg1,void *arg2) + +{ + if ((sector->check_ok != false) && ((sector->status).dirty == SECTOR_DIRTY_GC)) { + gc_request = true; + gc_collect(); + return false; + } + return false; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void env_iterator(env_node_obj_t env,void *arg1,void *arg2, + anon_subr__Bool_env_node_obj_t_void_ptr_void_ptr *callback) + +{ + EfErrCode EVar1; + _Bool _Var2; + uint32_t addr; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined uStack56; + sector_store_status_t sStack55; + sector_meta_data sector; + + sector._0_4_ = 0xffffffff; + do { + do { + addr = get_next_sector_addr((sector_meta_data_t)&uStack56); + if (addr == 0xffffffff) { + return; + } + EVar1 = read_sector_meta_data(addr,(sector_meta_data_t)&uStack56,false); + } while ((CONCAT31(extraout_var,EVar1) != 0) || (1 < (byte)(sStack55 + ~SECTOR_STORE_EMPTY))); + (env->addr).start = 0xffffffff; + while( true ) { + addr = get_next_env_addr((sector_meta_data_t)&uStack56,env); + (env->addr).start = addr; + if (addr == 0xffffffff) break; + read_env(env); + _Var2 = (*callback)(env,arg1,arg2); + if (CONCAT31(extraout_var_00,_Var2) != 0) { + return; + } + } + } while( true ); +} + + + +_Bool find_env(char *key,env_node_obj_t env) + +{ + char cVar1; + int iVar2; + size_t size; + uint32_t uVar3; + int iVar4; + uint16_t uVar5; + env_cache_node *peVar6; + char local_70; + char saved_name [64]; + + size = strlen(key); + uVar3 = ef_calc_crc32(0,key,size); + peVar6 = env_cache_table; + iVar2 = 0; + do { + if ((peVar6->addr != 0xffffffff) && ((uint)peVar6->name_crc == uVar3 >> 0x10)) { + ef_port_read(peVar6->addr + 0x1c,&local_70,0x40); + iVar4 = strncmp(key,(char *)&local_70,size); + if (iVar4 == 0) { + (env->addr).start = env_cache_table[iVar2].addr; + uVar5 = 0xffff; + if (env_cache_table[iVar2].active < 0xffef) { + uVar5 = env_cache_table[iVar2].active + 0x10; + } + env_cache_table[iVar2].active = uVar5; + read_env(env); + return true; + } + } + iVar2 = iVar2 + 1; + peVar6 = peVar6 + 1; + } while (iVar2 != 0x10); + local_70 = '\0'; + env_iterator(env,key,&local_70,find_env_cb); + cVar1 = local_70; + if (local_70 != '\0') { + update_env_cache(key,size,(env->addr).start); + } + return (_Bool)cVar1; +} + + + +EfErrCode del_env(char *key,env_node_obj_t old_env,_Bool complete_del) + +{ + _Bool last_is_complete_del; + int iVar1; + _Bool _Var2; + EfErrCode EVar3; + undefined3 extraout_var; + uint32_t addr; + undefined3 extraout_var_00; + size_t sVar4; + undefined3 extraout_var_01; + size_t name_len; + undefined3 in_register_00002031; + uint32_t uStack128; + uint8_t status_table [5]; + env_node_obj env; + + if (old_env == (env_node_obj_t)0x0) { + _Var2 = find_env(key,(env_node_obj_t)(status_table + 4)); + if (CONCAT31(extraout_var,_Var2) == 0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x447 + ,"Not found \'%s\' in ENV.\r\n",key); + return EF_ENV_NAME_ERR; + } + old_env = (env_node_obj_t)(status_table + 4); + } + addr = (old_env->addr).start; + if (CONCAT31(in_register_00002031,complete_del) == 0) { + EVar3 = write_status(addr,(uint8_t *)&uStack128,6,3); + iVar1 = CONCAT31(extraout_var_00,EVar3); + last_is_complete_del = true; + } + else { + EVar3 = write_status(addr,(uint8_t *)&uStack128,6,4); + iVar1 = CONCAT31(extraout_var_01,EVar3); + if ((last_is_complete_del == false) && (iVar1 == 0)) { + if (key == (char *)0x0) { + name_len = (size_t)old_env->name_len; + key = old_env->name; + } + else { + name_len = strlen(key); + } + update_env_cache(key,name_len,0xffffffff); + } + last_is_complete_del = false; + } + EVar3 = (EfErrCode)iVar1; + if (iVar1 == 0) { + addr = ((old_env->addr).start & 0xfffff000) + 3; + ef_port_read(addr,&uStack128,3); + sVar4 = get_status((uint8_t *)&uStack128,4); + if (sVar4 == 1) { + EVar3 = write_status(addr,(uint8_t *)&uStack128,4,2); + } + } + return EVar3; +} + + + +EfErrCode move_env(env_node_obj_t env) + +{ + EfErrCode EVar1; + uint32_t addr; + uint uVar2; + size_t new_env_len; + uint uVar3; + char *__src; + char cStack229; + undefined auStack228 [3]; + _Bool find_ok; + sector_meta_data sector; + uint8_t status_table [5]; + undefined auStack136 [4]; + env_node_obj env_bak; + + if (env->status == ENV_WRITE) { + del_env((char *)0x0,env,false); + } + addr = alloc_env((sector_meta_data_t)auStack228,env->len); + if (addr == 0xffffffff) { + return EF_ENV_FULL; + } + __src = env->name; + if (in_recovery_check != false) { + memset(§or.empty_env,0,0x41); + strncpy((char *)§or.empty_env,__src,(uint)env->name_len); + cStack229 = '\0'; + env_iterator((env_node_obj_t)auStack136,§or.empty_env,&cStack229,find_env_cb); + EVar1 = EF_NO_ERR; + if (cStack229 != '\0') goto __exit; + } + new_env_len = env->len; + update_sec_status((sector_meta_data_t)auStack228,new_env_len,(_Bool *)0x0); + write_status(addr,(uint8_t *)§or.empty_env,6,1); + uVar3 = new_env_len - 8; + uVar2 = 0; + EVar1 = EF_NO_ERR; + while (uVar2 < uVar3) { + new_env_len = 0x20; + if (uVar3 <= uVar2 + 0x20) { + new_env_len = uVar3 - uVar2; + } + ef_port_read((env->addr).start + 8 + uVar2,(uint32_t *)auStack136,new_env_len); + EVar1 = ef_port_write(addr + 8 + uVar2,(uint32_t *)auStack136,new_env_len); + uVar2 = uVar2 + new_env_len; + } + write_status(addr,(uint8_t *)§or.empty_env,6,2); + update_sector_cache(addr & 0xfffff000,env->value_len + 0x1c + (uint)env->name_len + addr); + update_env_cache(__src,(uint)env->name_len,addr); + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x4a6, + "Moved the ENV (%.*s) from 0x%08X to 0x%08X.\r\n",(uint)env->name_len,__src, + (env->addr).start,addr); +__exit: + del_env((char *)0x0,env,true); + return EVar1; +} + + + +_Bool check_and_recovery_env_cb(env_node_obj_t env,void *arg1,void *arg2) + +{ + _Bool _Var1; + EfErrCode EVar2; + undefined3 extraout_var; + uint8_t auStack24 [4]; + uint8_t status_table [5]; + + _Var1 = env->crc_is_ok; + if ((_Var1 == false) || (env->status != ENV_PRE_DELETE)) { + _Var1 = false; + if (env->status == ENV_PRE_WRITE) { + write_status((env->addr).start,auStack24,6,5); + _Var1 = true; + } + } + else { + ef_log_info("Found an ENV (%.*s) which has changed value failed. Now will recovery it.\r\n", + (uint)env->name_len,env->name); + EVar2 = move_env(env); + if (CONCAT31(extraout_var,EVar2) == 0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x6d5 + ,"Recovery the ENV successful.\r\n"); + _Var1 = false; + } + else { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x6d7 + , + "Warning: Moved an ENV (size %d) failed when recovery. Now will GC then retry.\r\n" + ,env->len); + } + } + return _Var1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +_Bool do_gc(sector_meta_data_t sector,void *arg1,void *arg2) + +{ + EfErrCode EVar1; + undefined3 extraout_var; + uint8_t auStack124 [4]; + uint8_t status_table [3]; + env_node_obj env; + + if ((sector->check_ok != false) && ((byte)((sector->status).dirty + ~SECTOR_DIRTY_FALSE) < 2)) { + write_status(sector->addr + 3,auStack124,4,3); + env.name._60_4_ = 0xffffffff; + while( true ) { + env.name._60_4_ = get_next_env_addr(sector,(env_node_obj_t)status_table); + if (env.name._60_4_ == 0xffffffff) break; + read_env((env_node_obj_t)status_table); + if ((((_Bool)status_table[1] != false) && ((byte)(status_table[0] + ~ENV_PRE_WRITE) < 2)) && + (EVar1 = move_env((env_node_obj_t)status_table), CONCAT31(extraout_var,EVar1) != 0)) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c", + 0x4e1,"Error: Moved the ENV (%.*s) for GC failed.\r\n",(uint)status_table[2], + &env.value_len); + } + } + format_sector(sector->addr); + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x4e6, + "Collect a sector @0x%08X\r\n",sector->addr); + return false; + } + return false; +} + + + +// WARNING: Could not reconcile some variable overlaps + +EfErrCode create_env_blob(sector_meta_data_t sector,char *key,void *value,size_t len) + +{ + size_t size; + uint size_00; + uint32_t addr; + EfErrCode EVar1; + size_t sVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + undefined auStack64 [3]; + _Bool _Stack61; + uint8_t align_data [1]; + _Bool is_full; + env_hdr_data env_hdr; + + addr = sector->empty_env; + _Stack61 = false; + sVar2 = strlen(key); + if (sVar2 < 0x41) { + memset(align_data,0xff,0x1c); + env_hdr._4_4_ = 0x3034564b; + sVar2 = strlen(key); + env_hdr.crc32._0_1_ = (byte)sVar2; + env_hdr.magic = len + 0x1c + (sVar2 & 0xff); + env_hdr._20_4_ = len; + if (env_hdr.magic < 0xfed) { + if ((addr == 0xffffffff) && (addr = new_env(sector,env_hdr.magic), addr == 0xffffffff)) { + return EF_ENV_FULL; + } + EVar1 = update_sec_status(sector,env_hdr.magic,&_Stack61); + if (CONCAT31(extraout_var,EVar1) == 0) { + env_hdr.len = ef_calc_crc32(0,&env_hdr.crc32,8); + env_hdr.len = ef_calc_crc32(env_hdr.len,key,(uint)(byte)env_hdr.crc32); + env_hdr.len = ef_calc_crc32(env_hdr.len,value,env_hdr._20_4_); + EVar1 = write_status(addr,align_data,6,1); + if ((CONCAT31(extraout_var_00,EVar1) == 0) && + (EVar1 = ef_port_write(addr + 8,(uint32_t *)(env_hdr.status_table + 4),0x14), + CONCAT31(extraout_var_01,EVar1) == 0)) { + size_00 = (uint)(byte)env_hdr.crc32; + memset(auStack64,0xff,1); + EVar1 = ef_port_write(addr + 0x1c,(uint32_t *)key,size_00); + if (_Stack61 == false) { + update_sector_cache(sector->addr, + env_hdr._20_4_ + 0x1c + (uint)(byte)env_hdr.crc32 + addr); + } + update_env_cache(key,(uint)(byte)env_hdr.crc32,addr); + size = env_hdr._20_4_; + if (CONCAT31(extraout_var_02,EVar1) == 0) { + size_00 = (uint)(byte)env_hdr.crc32; + memset(auStack64,0xff,1); + EVar1 = ef_port_write(size_00 + 0x1c + addr,(uint32_t *)value,size); + if (((CONCAT31(extraout_var_03,EVar1) == 0) && + (EVar1 = write_status(addr,align_data,6,2), CONCAT31(extraout_var_04,EVar1) == 0)) + && (_Stack61 != false)) { + ef_log_debug( + "/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c" + ,0x562,"Trigger a GC check after created ENV.\r\n"); + gc_request = true; + } + } + } + } + } + else { + ef_log_info("Error: The ENV size is too big\r\n"); + EVar1 = EF_ENV_FULL; + } + } + else { + ef_log_info("Error: The ENV name length is more than %d\r\n",0x40); + EVar1 = EF_ENV_NAME_ERR; + } + return EVar1; +} + + + +size_t ef_get_env_blob(char *key,void *value_buf,size_t buf_len,size_t *saved_value_len) + +{ + size_t sVar1; + _Bool _Var2; + TickType_t TVar3; + char *format; + size_t sVar4; + undefined3 extraout_var; + undefined4 uVar5; + undefined auStack120 [4]; + env_node_obj env; + + if (init_ok == false) { + ef_log_info("ENV isn\'t initialize OK.\r\n"); + sVar1 = 0; + } + else { + if ((key == (char *)0x0) || (value_buf == (void *)0x0)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar5 = 0x34c; + format = "[%10u][%s: %s:%4d] key = %p, value_buf = %p\r\n"; + } + else { + sVar4 = strlen(key); + if (sVar4 < 0x41) { + ef_port_env_lock(); + _Var2 = find_env(key,(env_node_obj_t)auStack120); + sVar1 = 0; + if (CONCAT31(extraout_var,_Var2) != 0) { + if (saved_value_len != (size_t *)0x0) { + *saved_value_len = env.len; + } + if (env.len < buf_len) { + buf_len = env.len; + } + ef_port_read(env.addr.start,(uint32_t *)value_buf,buf_len); + sVar1 = buf_len; + } + ef_port_env_unlock(); + return sVar1; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + key = (char *)strlen(key); + value_buf = (void *)0x40; + uVar5 = 0x351; + format = "[%10u][%s: %s:%4d] key err. %d > %d\r\n"; + } + bl_printk(format,TVar3,&DAT_230c03d4,&UNK_230c03c8,uVar5,key,value_buf); + sVar1 = 8; + } + return sVar1; +} + + + +char * ef_get_env(char *key) + +{ + char value [3981]; + char *pcVar1; + size_t sVar2; + size_t sVar3; + + sVar2 = ef_get_env_blob(key,(char *)&ram0x420175a8,0xf8c,(size_t *)0x0); + if (sVar2 == 0) { +LAB_2306044a: + pcVar1 = (char *)0x0; + } + else { + sVar3 = 0; + pcVar1 = (char *)0x420175a8; + do { + if (0x5e < (uint)*(byte *)(sVar3 + 0x420175a8) - 0x20) { + ef_log_info("Warning: The ENV value isn\'t string. Could not be returned\r\n"); + goto LAB_2306044a; + } + sVar3 = sVar3 + 1; + } while (sVar2 != sVar3); + *(undefined *)(sVar2 + 0x420175a8) = 0; + } + return pcVar1; +} + + + +EfErrCode ef_del_env(char *key) + +{ + EfErrCode EVar1; + TickType_t TVar2; + size_t sVar3; + EfErrCode result; + + if (init_ok == false) { + ef_log_info("Error: ENV isn\'t initialize OK.\r\n"); + EVar1 = EF_ENV_INIT_FAILED; + } + else { + if ((key == (char *)0x0) || (sVar3 = strlen(key), 0x40 < sVar3)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] key = %p\r\n",TVar2,&DAT_230c03d4,&UNK_230c03c8,0x57d,key); + EVar1 = EF_NO_ERR; + } + else { + ef_port_env_lock(); + EVar1 = del_env(key,(env_node_obj_t)0x0,true); + ef_port_env_unlock(); + } + } + return EVar1; +} + + + +EfErrCode ef_set_env_blob(char *key,void *value_buf,size_t buf_len) + +{ + _Bool _Var1; + EfErrCode EVar2; + TickType_t TVar3; + char *format; + size_t sVar4; + uint32_t uVar5; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined4 uVar6; + + if (init_ok == false) { + ef_log_info("ENV isn\'t initialize OK.\r\n"); + return EF_ENV_INIT_FAILED; + } + if ((key == (char *)0x0) || (value_buf == (void *)0x0)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar6 = 0x5d4; + format = "[%10u][%s: %s:%4d] key = %p, value_buf = %p\r\n"; + } + else { + sVar4 = strlen(key); + if (sVar4 < 0x41) { + if (buf_len < 0xf8d) { + ef_port_env_lock(); + sVar4 = strlen(key); + uVar5 = new_env((sector_meta_data_t)sector_3152,buf_len + 0x1c + sVar4); + EVar2 = EF_ENV_FULL; + if (uVar5 != 0xffffffff) { + _Var1 = find_env(key,(env_node_obj_t)env_3151); + if ((CONCAT31(extraout_var,_Var1) == 0) || + (EVar2 = del_env(key,(env_node_obj_t)env_3151,false), + CONCAT31(extraout_var_01,EVar2) == 0)) { + EVar2 = create_env_blob((sector_meta_data_t)sector_3152,key,value_buf,buf_len); + if ((CONCAT31(extraout_var,_Var1) != 0) && (CONCAT31(extraout_var_00,EVar2) == 0)) { + EVar2 = del_env(key,(env_node_obj_t)env_3151,true); + } + } + if (gc_request != false) { + gc_collect(); + } + } + ef_port_env_unlock(); + return EVar2; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + value_buf = (void *)0xf8c; + uVar6 = 0x5de; + format = "[%10u][%s: %s:%4d] buf_len err. %d > %d\r\n"; + key = (char *)buf_len; + } + else { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + key = (char *)strlen(key); + value_buf = (void *)0x40; + uVar6 = 0x5d9; + format = "[%10u][%s: %s:%4d] key err. %d > %d\r\n"; + } + } + bl_printk(format,TVar3,&DAT_230c03d4,&UNK_230c03c8,uVar6,key,value_buf); + return EF_ENV_ARG_ERR; +} + + + +EfErrCode ef_set_env(char *key,char *value) + +{ + EfErrCode EVar1; + size_t buf_len; + + buf_len = strlen(value); + EVar1 = ef_set_env_blob(key,value,buf_len); + return EVar1; +} + + + +EfErrCode ef_save_env(void) + +{ + return EF_NO_ERR; +} + + + +EfErrCode ef_env_set_default(void) + +{ + uint uVar1; + uint32_t addr; + EfErrCode EVar2; + undefined3 extraout_var; + size_t len; + ef_env *peVar3; + undefined auStack56 [4]; + sector_meta_data sector; + + if (default_env_set == (ef_env *)0x0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x621, + "(%s) has assert failed at %s.\r\n","default_env_set","ef_env_set_default"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + if (default_env_set_size == 0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x622, + "(%s) has assert failed at %s.\r\n","default_env_set_size","ef_env_set_default"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + ef_port_env_lock(); + addr = env_start_addr; + while (addr < env_start_addr + 0x8000) { + EVar2 = format_sector(addr); + if (CONCAT31(extraout_var,EVar2) != 0) goto __exit; + addr = addr + 0x1000; + } + uVar1 = 0; + while (uVar1 < default_env_set_size) { + len = default_env_set[uVar1].value_len; + if (len == 0) { + len = strlen((char *)default_env_set[uVar1].value); + } + sector.remain = 0xffffffff; + peVar3 = default_env_set + uVar1; + uVar1 = uVar1 + 1; + create_env_blob((sector_meta_data_t)auStack56,peVar3->key,peVar3->value,len); + } + EVar2 = EF_NO_ERR; +__exit: + ef_port_env_unlock(); + return EVar2; +} + + + +void ef_print_env(void) + +{ + int local_6c; + size_t using_size; + env_node_obj env; + + local_6c = 0; + if (init_ok == false) { + ef_log_info("ENV isn\'t initialize OK.\r\n"); + } + else { + ef_port_env_lock(); + env_iterator((env_node_obj_t)&using_size,&local_6c,(void *)0x0,print_env_cb); + ef_print("\r\nmode: next generation\r\n"); + ef_print("size: %lu/%lu bytes.\r\n",local_6c + 0x8c,0x7000); + ef_port_env_unlock(); + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: env + +EfErrCode ef_load_env(void) + +{ + int iStack132; + size_t check_failed_count; + sector_meta_data sector; + env_node_obj env; + + in_recovery_check = true; + iStack132 = 0; + sector_iterator((sector_meta_data_t)&check_failed_count,SECTOR_STORE_UNUSED,&iStack132,(void *)0x0 + ,check_sec_hdr_cb,false); + if (iStack132 == 8) { + ef_log_info("Warning: All sector header check failed. Set it to default.\r\n"); + ef_env_set_default(); + } + ef_port_env_lock(); + sector_iterator((sector_meta_data_t)&check_failed_count,SECTOR_STORE_UNUSED,(void *)0x0, + (void *)0x0,check_and_recovery_gc_cb,false); + while( true ) { + env_iterator((env_node_obj_t)§or.empty_env,(void *)0x0,(void *)0x0,check_and_recovery_env_cb + ); + if (gc_request == false) break; + gc_collect(); + } + in_recovery_check = false; + ef_port_env_unlock(); + return EF_NO_ERR; +} + + + +EfErrCode ef_env_init(ef_env *default_env,size_t default_env_size) + +{ + char "ef_env_init" [12]; + EfErrCode EVar1; + undefined3 extraout_var; + env_cache_node *peVar2; + + if (default_env == (ef_env *)0x0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x71e, + "(%s) has assert failed at %s.\r\n","default_env","ef_env_init"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + EVar1 = EF_NO_ERR; + if (init_ok == false) { + sector_cache_table[0].addr = 0xffffffff; + sector_cache_table[1].addr = 0xffffffff; + sector_cache_table[2].addr = 0xffffffff; + sector_cache_table[3].addr = 0xffffffff; + peVar2 = env_cache_table; + do { + peVar2->addr = 0xffffffff; + peVar2 = peVar2 + 1; + } while (peVar2 != (env_cache_node *)sector_3152); + env_start_addr = 0; + default_env_set = default_env; + default_env_set_size = default_env_size; + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x738, + "ENV start address is 0x%08X, size is %d bytes.\r\n",0,0x8000); + EVar1 = ef_load_env(); + if (CONCAT31(extraout_var,EVar1) == 0) { + init_ok = true; + } + } + return EVar1; +} + + + +EfErrCode ef_port_read(uint32_t addr,uint32_t *buf,size_t size) + +{ + int iVar1; + + iVar1 = bl_mtd_read(handle,addr,size,(uint8_t *)buf); + return (EfErrCode)((iVar1 < 0) << 1); +} + + + +EfErrCode ef_port_write(uint32_t addr,uint32_t *buf,size_t size) + +{ + EfErrCode EVar1; + int iVar2; + + iVar2 = bl_mtd_write(handle,addr,size,(uint8_t *)buf); + if (iVar2 < 0) { + EVar1 = EF_WRITE_ERR; + } + else { + EVar1 = EF_NO_ERR; + } + return EVar1; +} + + + +void ef_port_env_lock(void) + +{ + xQueueSemaphoreTake((QueueHandle_t)env_cache_lock,0xffffffff); + return; +} + + + +void ef_port_env_unlock(void) + +{ + xQueueGenericSend((QueueHandle_t)env_cache_lock,(void *)0x0,0,0); + return; +} + + + +void ef_log_debug(char *file,long line,char *format,...) + +{ + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list args; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + vprint(format,&uStack20); + return; +} + + + +EfErrCode ef_port_erase(uint32_t addr,size_t size) + +{ + char "ef_port_erase" [14]; + int iVar1; + + if ((addr & 0xfff) != 0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_port.c",0x77, + "(%s) has assert failed at %s.\r\n","addr % EF_ERASE_MIN_SIZE == 0","ef_port_erase" + ); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + iVar1 = bl_mtd_erase(handle,addr,size); + return (EfErrCode)((uint)iVar1 >> 0x1f); +} + + + +void ef_log_info(char *format,...) + +{ + undefined4 in_a1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list args; + undefined4 uStack28; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack28 = in_a1; + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + vprint(format,&uStack28); + return; +} + + + +// WARNING: Variable defined which should be unmapped: info +// WARNING: Could not reconcile some variable overlaps + +EfErrCode ef_port_init(ef_env **default_env,size_t *default_env_size) + +{ + int iVar1; + undefined auStack44 [4]; + bl_mtd_info_t info; + + iVar1 = bl_mtd_open("PSM",&handle,2); + if (iVar1 < 0) { + ef_log_info("[EF] [PART] [XIP] error when get PSM partition %d\r\n",iVar1); + puts("[EF] [PART] [XIP] Dead Loop. Reason: no Valid PSM partition found\r\n"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + memset(auStack44,0,0x1c); + bl_mtd_info(handle,(bl_mtd_info_t *)auStack44); + ef_log_info("[EF] Found Valid PSM partition, XIP Addr %08x, flash addr %08x\r\n",info.size, + info.name._12_4_); + *default_env = default_env_set; + *default_env_size = 1; + printf("*default_env_size = 0x%08x\r\n",1); + env_cache_lock = (SemaphoreHandle_t)xQueueCreateMutex('\x01'); + return EF_NO_ERR; +} + + + +void ef_print(char *format,...) + +{ + undefined4 in_a1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list args; + undefined4 uStack28; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack28 = in_a1; + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + vprint(format,&uStack28); + return; +} + + + +uint32_t ef_calc_crc32(uint32_t crc,void *buf,size_t size) + +{ + uint uVar1; + byte *pbVar2; + + uVar1 = ~crc; + pbVar2 = (byte *)buf; + while (pbVar2 != (byte *)(size + (int)buf)) { + uVar1 = uVar1 >> 8 ^ crc32_table[(*pbVar2 ^ uVar1) & 0xff]; + pbVar2 = pbVar2 + 1; + } + return ~uVar1; +} + + + +void psm_get_cmd(char *buf,int len,int argc,char **argv) + +{ + return; +} + + + +void psm_test_cmd(void) + +{ + size_t *psVar1; + EfErrCode EVar2; + void *__s; + void *__s_00; + undefined3 extraout_var; + size_t __n; + char *format; + int iVar3; + undefined *puVar4; + undefined4 uVar5; + size_t xWantedSize; + size_t sVar6; + size_t sStack92; + size_t local_58 [6]; + size_t asStack64 [3]; + + psVar1 = local_58; + memcpy(local_58,&DAT_230c0c54,0x18); + do { + sVar6 = *psVar1; + sStack92 = 0; + xWantedSize = sVar6 + 1; + __s = pvPortMalloc(xWantedSize); + __s_00 = pvPortMalloc(xWantedSize); + if ((__s == (void *)0x0) || (__s_00 == (void *)0x0)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] kvbin malloc %d byte error\r\n",&DAT_230bd32c,"easyflash_cli.c", + 0x3d); + if (__s != (void *)0x0) goto LAB_23060b82; + } + else { + memset(__s,0,xWantedSize); + memset(__s_00,0,xWantedSize); + xWantedSize = 0; + while (xWantedSize != sVar6) { + *(undefined *)((int)__s + xWantedSize) = 0x76; + xWantedSize = xWantedSize + 1; + } + EVar2 = ef_set_env_blob("1234567890123456789012345678901234567890123456789012345678901234",__s + ,xWantedSize); + iVar3 = CONCAT31(extraout_var,EVar2); + __n = ef_get_env_blob("1234567890123456789012345678901234567890123456789012345678901234", + __s_00,xWantedSize,&sStack92); + if ((iVar3 == 0) && (xWantedSize == __n)) { + iVar3 = memcmp(__s_00,__s,__n); + if (iVar3 == 0) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] kvbin set %ld byte bin -> read %ld byte -> memcmp success.\r\n" + ,&DAT_230bd32c,"easyflash_cli.c",0x56,__n,__n); + goto LAB_23060b82; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + iVar3 = 0; + uVar5 = 0x52; + puVar4 = &DAT_230a9dd8; + format = + "[%10u][%s: %s:%4d] kvbin set/get %ld byte , res1 = %ld, res2 = %d. memcmp error\r\n"; + sVar6 = __n; + } + else { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar5 = 0x4d; + puVar4 = &DAT_230c03d4; + format = "[%10u][%s: %s:%4d] kvbin set/get %ld byte error, res1 = %ld, res2 = %d.\r\n"; + } + bl_printk(format,puVar4,"easyflash_cli.c",uVar5,sVar6,iVar3,__n); +LAB_23060b82: + vPortFree(__s); + } + if (__s_00 != (void *)0x0) { + vPortFree(__s_00); + } + psVar1 = psVar1 + 1; + if (psVar1 == asStack64) { + ef_del_env("1234567890123456789012345678901234567890123456789012345678901234"); + return; + } + } while( true ); +} + + + +EfErrCode psm_erase_cmd(void) + +{ + uint uVar1; + uint32_t addr; + EfErrCode EVar2; + undefined3 extraout_var; + size_t len; + ef_env *peVar3; + sector_meta_data sStack56; + + if (default_env_set == (ef_env *)0x0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x621, + "(%s) has assert failed at %s.\r\n","default_env_set","ef_env_set_default"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + if (default_env_set_size == 0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x622, + "(%s) has assert failed at %s.\r\n","default_env_set_size","ef_env_set_default"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + ef_port_env_lock(); + addr = env_start_addr; + while (addr < env_start_addr + 0x8000) { + EVar2 = format_sector(addr); + if (CONCAT31(extraout_var,EVar2) != 0) goto __exit; + addr = addr + 0x1000; + } + uVar1 = 0; + while (uVar1 < default_env_set_size) { + len = default_env_set[uVar1].value_len; + if (len == 0) { + len = strlen((char *)default_env_set[uVar1].value); + } + sStack56.empty_env = 0xffffffff; + peVar3 = default_env_set + uVar1; + uVar1 = uVar1 + 1; + create_env_blob((sector_meta_data_t)&sStack56,peVar3->key,peVar3->value,len); + } + EVar2 = EF_NO_ERR; +__exit: + ef_port_env_unlock(); + return EVar2; +} + + + +void psm_dump_cmd(void) + +{ + int iStack108; + env_node_obj eStack104; + + iStack108 = 0; + if (init_ok == false) { + ef_log_info("ENV isn\'t initialize OK.\r\n"); + } + else { + ef_port_env_lock(); + env_iterator((env_node_obj_t)&eStack104,&iStack108,(void *)0x0,print_env_cb); + ef_print("\r\nmode: next generation\r\n"); + ef_print("size: %lu/%lu bytes.\r\n",iStack108 + 0x8c,0x7000); + ef_port_env_unlock(); + } + return; +} + + + +void psm_unset_cmd(char *buf,int len,int argc,char **argv) + +{ + if (argc != 2) { + printf("usage: psm_unset [key]\r\n"); + return; + } + ef_del_env(argv[1]); + ef_save_env(); + return; +} + + + +void psm_set_cmd(char *buf,int len,int argc,char **argv) + +{ + if (argc != 3) { + printf("usage: psm_set [key] [value]\r\n"); + return; + } + ef_set_env(argv[1],argv[2]); + ef_save_env(); + return; +} + + + +int easyflash_cli_init(void) + +{ + return 0; +} + + + +// WARNING: Removing unreachable block (ram,0x23060d3c) +// WARNING: Removing unreachable block (ram,0x23060d52) + +EventGroupHandle_t xEventGroupCreateStatic(StaticEventGroup_t *pxEventGroupBuffer) + +{ + size_t xSize; + + if (pxEventGroupBuffer == (StaticEventGroup_t *)0x0) { + vAssertCalled(); + } + else { + pxEventGroupBuffer->xDummy1 = 0; + vListInitialise((List_t *)&pxEventGroupBuffer->xDummy2); + pxEventGroupBuffer->ucDummy4 = '\x01'; + } + return (EventGroupHandle_t)pxEventGroupBuffer; +} + + + +EventBits_t +xEventGroupWaitBits(EventGroupHandle_t xEventGroup,EventBits_t uxBitsToWaitFor, + BaseType_t xClearOnExit,BaseType_t xWaitForAllBits,TickType_t xTicksToWait) + +{ + uint uVar1; + BaseType_t BVar2; + uint uVar3; + + if (xEventGroup == (EventGroupHandle_t)0x0) { + vAssertCalled(); + } + if (((uxBitsToWaitFor & 0xff000000) == 0) && (uxBitsToWaitFor != 0)) { + BVar2 = xTaskGetSchedulerState(); + if (BVar2 != 0) goto LAB_23060d84; +LAB_23060e04: + if (xTicksToWait == 0) goto LAB_23060d84; + vAssertCalled(); + vTaskSuspendAll(); + uVar1 = xEventGroup->uxEventBits; + uVar3 = uxBitsToWaitFor & uVar1; + if (xWaitForAllBits != 0) goto LAB_23060dc8; +LAB_23060d94: + if (uVar3 == 0) { +LAB_23060dcc: + if (xTicksToWait == 0) goto LAB_23060e1e; + uVar1 = (uint)(xClearOnExit != 0) << 0x18; + if (xWaitForAllBits != 0) { + uVar1 = uVar1 | 0x4000000; + } + vTaskPlaceOnUnorderedEventList + (&xEventGroup->xTasksWaitingForBits,uVar1 | uxBitsToWaitFor,xTicksToWait); + BVar2 = xTaskResumeAll(); + if (BVar2 == 0) { + ecall(); + } + uVar1 = uxTaskResetEventItemValue(); + if ((int)(uVar1 << 6) < 0) goto LAB_23060dfc; + vTaskEnterCritical(); + uVar1 = xEventGroup->uxEventBits; + if (xWaitForAllBits == 0) { + if ((uxBitsToWaitFor & uVar1) != 0) { +LAB_23060e44: + if (xClearOnExit != 0) { + xEventGroup->uxEventBits = ~uxBitsToWaitFor & uVar1; + } + } + } + else { + if (uxBitsToWaitFor == (uxBitsToWaitFor & uVar1)) goto LAB_23060e44; + } + vTaskExitCritical(); +LAB_23060dfc: + return uVar1 & 0xffffff; + } + } + else { + vAssertCalled(); + BVar2 = xTaskGetSchedulerState(); + if (BVar2 == 0) goto LAB_23060e04; +LAB_23060d84: + vTaskSuspendAll(); + uVar1 = xEventGroup->uxEventBits; + uVar3 = uxBitsToWaitFor & uVar1; + if (xWaitForAllBits == 0) goto LAB_23060d94; +LAB_23060dc8: + if (uxBitsToWaitFor != uVar3) goto LAB_23060dcc; + } + if (xClearOnExit != 0) { + xEventGroup->uxEventBits = ~uxBitsToWaitFor & uVar1; + xTaskResumeAll(); + return uVar1; + } +LAB_23060e1e: + xTaskResumeAll(); + return uVar1; +} + + + +EventBits_t xEventGroupSetBits(EventGroupHandle_t xEventGroup,EventBits_t uxBitsToSet) + +{ + xLIST_ITEM *pxEventListItem; + xLIST_ITEM *pxVar1; + uint uVar2; + uint uVar3; + xLIST_ITEM *pxVar4; + uint uVar5; + + if (xEventGroup == (EventGroupHandle_t)0x0) { + vAssertCalled(); + } + if ((uxBitsToSet & 0xff000000) != 0) { + vAssertCalled(); + } + vTaskSuspendAll(); + pxEventListItem = (xEventGroup->xTasksWaitingForBits).xListEnd.pxNext; + pxVar4 = (xLIST_ITEM *)&(xEventGroup->xTasksWaitingForBits).xListEnd; + uxBitsToSet = uxBitsToSet | xEventGroup->uxEventBits; + xEventGroup->uxEventBits = uxBitsToSet; + if (pxVar4 != pxEventListItem) { + uVar5 = 0; + do { + while( true ) { + uVar3 = ((ListItem_t *)pxEventListItem)->xItemValue; + uVar2 = uVar3 & 0xffffff; + pxVar1 = ((ListItem_t *)pxEventListItem)->pxNext; + if ((int)(uVar3 << 5) < 0) break; + if ((uVar2 & uxBitsToSet) != 0) { +LAB_23060ec2: + if ((int)(uVar3 << 7) < 0) { + uVar5 = uVar5 | uVar2; + } + vTaskRemoveFromUnorderedEventList((ListItem_t *)pxEventListItem,uxBitsToSet | 0x2000000); + uxBitsToSet = xEventGroup->uxEventBits; + } + pxEventListItem = pxVar1; + if (pxVar4 == pxVar1) goto LAB_23060ed8; + } + if (uVar2 == (uVar2 & uxBitsToSet)) goto LAB_23060ec2; + pxEventListItem = pxVar1; + } while (pxVar4 != pxVar1); +LAB_23060ed8: + uxBitsToSet = uxBitsToSet & ~uVar5; + } + xEventGroup->uxEventBits = uxBitsToSet; + xTaskResumeAll(); + return xEventGroup->uxEventBits; +} + + + +void vEventGroupDelete(EventGroupHandle_t xEventGroup) + +{ + ListItem_t *pxEventListItem; + UBaseType_t UVar1; + + vTaskSuspendAll(); + UVar1 = (xEventGroup->xTasksWaitingForBits).uxNumberOfItems; + while (UVar1 != 0) { + while (pxEventListItem = (ListItem_t *)(xEventGroup->xTasksWaitingForBits).xListEnd.pxNext, + pxEventListItem != (ListItem_t *)&(xEventGroup->xTasksWaitingForBits).xListEnd) { + vTaskRemoveFromUnorderedEventList(pxEventListItem,0x2000000); + if ((xEventGroup->xTasksWaitingForBits).uxNumberOfItems == 0) goto LAB_23060f4c; + } + vAssertCalled(); + vTaskRemoveFromUnorderedEventList + ((ListItem_t *)(xEventGroup->xTasksWaitingForBits).xListEnd.pxNext,0x2000000); + UVar1 = (xEventGroup->xTasksWaitingForBits).uxNumberOfItems; + } +LAB_23060f4c: + if (xEventGroup->ucStaticallyAllocated != '\0') { + xTaskResumeAll(); + return; + } + vPortFree(xEventGroup); + xTaskResumeAll(); + return; +} + + + +void vListInitialise(List_t *pxList) + +{ + ListItem_t *pLVar1; + + pLVar1 = (ListItem_t *)&pxList->xListEnd; + pxList->pxIndex = pLVar1; + (pxList->xListEnd).xItemValue = 0xffffffff; + *(ListItem_t **)&(pxList->xListEnd).pxNext = pLVar1; + *(ListItem_t **)&(pxList->xListEnd).pxPrevious = pLVar1; + pxList->uxNumberOfItems = 0; + return; +} + + + +void vListInitialiseItem(ListItem_t *pxItem) + +{ + pxItem->pvContainer = (xLIST *)0x0; + return; +} + + + +void vListInsertEnd(List_t *pxList,ListItem_t *pxNewListItem) + +{ + xLIST_ITEM *pxVar1; + ListItem_t *pLVar2; + + pLVar2 = pxList->pxIndex; + *(ListItem_t **)&pxNewListItem->pxNext = pLVar2; + pxVar1 = pLVar2->pxPrevious; + pxNewListItem->pxPrevious = pxVar1; + *(ListItem_t **)&pxVar1->pxNext = pxNewListItem; + *(ListItem_t **)&pLVar2->pxPrevious = pxNewListItem; + *(List_t **)&pxNewListItem->pvContainer = pxList; + pxList->uxNumberOfItems = pxList->uxNumberOfItems + 1; + return; +} + + + +void vListInsert(List_t *pxList,ListItem_t *pxNewListItem) + +{ + xLIST_ITEM *pxVar1; + xLIST_ITEM *pxVar2; + + pxVar2 = (xLIST_ITEM *)&pxList->xListEnd; + if (pxNewListItem->xItemValue == 0xffffffff) { + pxVar1 = (pxList->xListEnd).pxPrevious; + pxVar2 = pxVar1->pxNext; + } + else { + do { + pxVar1 = pxVar2; + pxVar2 = pxVar1->pxNext; + } while (pxVar2->xItemValue <= pxNewListItem->xItemValue); + } + pxNewListItem->pxNext = pxVar2; + *(ListItem_t **)&pxVar2->pxPrevious = pxNewListItem; + pxNewListItem->pxPrevious = pxVar1; + *(ListItem_t **)&pxVar1->pxNext = pxNewListItem; + *(List_t **)&pxNewListItem->pvContainer = pxList; + pxList->uxNumberOfItems = pxList->uxNumberOfItems + 1; + return; +} + + + +UBaseType_t uxListRemove(ListItem_t *pxItemToRemove) + +{ + xLIST_ITEM *pxVar1; + xLIST *pxVar2; + + pxVar1 = pxItemToRemove->pxPrevious; + pxVar2 = pxItemToRemove->pvContainer; + pxItemToRemove->pxNext->pxPrevious = pxVar1; + pxVar1->pxNext = pxItemToRemove->pxNext; + if (pxVar2->pxIndex != pxItemToRemove) { + pxItemToRemove->pvContainer = (xLIST *)0x0; + pxVar2->uxNumberOfItems = pxVar2->uxNumberOfItems - 1; + return pxVar2->uxNumberOfItems; + } + pxVar2->pxIndex = (ListItem_t *)pxItemToRemove->pxPrevious; + pxItemToRemove->pvContainer = (xLIST *)0x0; + pxVar2->uxNumberOfItems = pxVar2->uxNumberOfItems - 1; + return pxVar2->uxNumberOfItems; +} + + + +BaseType_t prvCopyDataToQueue(Queue_t *pxQueue,void *pvItemToQueue,BaseType_t xPosition) + +{ + UBaseType_t UVar1; + BaseType_t BVar2; + UBaseType_t UVar3; + size_t __n; + int8_t *piVar4; + int8_t *piVar5; + + __n = pxQueue->uxItemSize; + UVar1 = pxQueue->uxMessagesWaiting; + if (__n == 0) { + UVar1 = UVar1 + 1; + BVar2 = 0; + if (pxQueue->pcHead == (int8_t *)0x0) { + BVar2 = xTaskPriorityDisinherit(*(TaskHandle_t *)&pxQueue->u); + *(undefined4 *)&pxQueue->u = 0; + } + } + else { + if (xPosition == 0) { + UVar1 = UVar1 + 1; + memcpy(pxQueue->pcWriteTo,pvItemToQueue,__n); + piVar4 = pxQueue->pcWriteTo; + BVar2 = 0; + pxQueue->pcWriteTo = piVar4 + pxQueue->uxItemSize; + if (*(int8_t **)&pxQueue->u <= piVar4 + pxQueue->uxItemSize) { + pxQueue->uxMessagesWaiting = UVar1; + pxQueue->pcWriteTo = pxQueue->pcHead; + return 0; + } + } + else { + memcpy(*(void **)((int)&pxQueue->u + 4),pvItemToQueue,__n); + UVar3 = pxQueue->uxItemSize; + piVar4 = pxQueue->pcHead; + piVar5 = (int8_t *)(*(int *)((int)&pxQueue->u + 4) + -UVar3); + *(int8_t **)((int)&pxQueue->u + 4) = piVar5; + if (piVar5 < piVar4) { + *(int *)((int)&pxQueue->u + 4) = -UVar3 + *(int *)&pxQueue->u; + } + if (xPosition != 2) { + pxQueue->uxMessagesWaiting = UVar1 + 1; + return 0; + } + BVar2 = 0; + if (UVar1 == 0) { + UVar1 = 1; + } + } + } + pxQueue->uxMessagesWaiting = UVar1; + return BVar2; +} + + + +void prvCopyDataFromQueue(Queue_t *pxQueue,void *pvBuffer) + +{ + int8_t *__src; + size_t __n; + int8_t *piVar1; + + __n = pxQueue->uxItemSize; + if (__n != 0) { + piVar1 = *(int8_t **)&pxQueue->u; + __src = (int8_t *)(*(int *)((int)&pxQueue->u + 4) + __n); + *(int8_t **)((int)&pxQueue->u + 4) = __src; + if (piVar1 <= __src) { + __src = pxQueue->pcHead; + *(int8_t **)((int)&pxQueue->u + 4) = __src; + } + memcpy(pvBuffer,__src,__n); + return; + } + return; +} + + + +void prvUnlockQueue(Queue_t *pxQueue) + +{ + char cVar1; + int iVar2; + BaseType_t BVar3; + uint uVar4; + + vTaskEnterCritical(); + iVar2 = (int)pxQueue->cTxLock; + if ((0 < iVar2) && ((pxQueue->xTasksWaitingToReceive).uxNumberOfItems != 0)) { + do { + BVar3 = xTaskRemoveFromEventList(&pxQueue->xTasksWaitingToReceive); + if (BVar3 == 0) { + uVar4 = iVar2 - 1U & 0xff; + cVar1 = (char)uVar4; + } + else { + vTaskMissedYield(); + uVar4 = iVar2 - 1U & 0xff; + cVar1 = (char)uVar4; + } + } while ((uVar4 != 0) && + (iVar2 = (int)cVar1, (pxQueue->xTasksWaitingToReceive).uxNumberOfItems != 0)); + } + pxQueue->cTxLock = -1; + vTaskExitCritical(); + vTaskEnterCritical(); + iVar2 = (int)pxQueue->cRxLock; + if ((0 < iVar2) && ((pxQueue->xTasksWaitingToSend).uxNumberOfItems != 0)) { + do { + BVar3 = xTaskRemoveFromEventList(&pxQueue->xTasksWaitingToSend); + if (BVar3 == 0) { + uVar4 = iVar2 - 1U & 0xff; + cVar1 = (char)uVar4; + } + else { + vTaskMissedYield(); + uVar4 = iVar2 - 1U & 0xff; + cVar1 = (char)uVar4; + } + } while ((uVar4 != 0) && + (iVar2 = (int)cVar1, (pxQueue->xTasksWaitingToSend).uxNumberOfItems != 0)); + } + pxQueue->cRxLock = -1; + vTaskExitCritical(); + return; +} + + + +BaseType_t xQueueGenericReset(QueueHandle_t xQueue,BaseType_t xNewQueue) + +{ + BaseType_t BVar1; + int8_t *piVar2; + int iVar3; + + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + vTaskEnterCritical(); + piVar2 = xQueue->pcHead; + xQueue->uxMessagesWaiting = 0; + iVar3 = xQueue->uxItemSize * xQueue->uxLength; + xQueue->cRxLock = -1; + xQueue->pcWriteTo = piVar2; + xQueue->cTxLock = -1; + *(int8_t **)&xQueue->u = piVar2 + iVar3; + *(int8_t **)((int)&xQueue->u + 4) = piVar2 + (iVar3 - xQueue->uxItemSize); + if (xNewQueue == 0) { + if (((xQueue->xTasksWaitingToSend).uxNumberOfItems != 0) && + (BVar1 = xTaskRemoveFromEventList(&xQueue->xTasksWaitingToSend), BVar1 != 0)) { + ecall(); + vTaskExitCritical(); + return 1; + } + vTaskExitCritical(); + return 1; + } + vListInitialise(&xQueue->xTasksWaitingToSend); + vListInitialise(&xQueue->xTasksWaitingToReceive); + vTaskExitCritical(); + return 1; +} + + + +// WARNING: Removing unreachable block (ram,0x2306123a) + +QueueHandle_t +xQueueGenericCreateStatic + (UBaseType_t uxQueueLength,UBaseType_t uxItemSize,uint8_t *pucQueueStorage, + StaticQueue_t *pxStaticQueue,uint8_t ucQueueType) + +{ + size_t xSize; + + if (uxQueueLength == 0) { + vAssertCalled(); + } + if (pxStaticQueue == (StaticQueue_t *)0x0) { + vAssertCalled(); + } + if (pucQueueStorage == (uint8_t *)0x0) { + if (uxItemSize == 0) goto LAB_2306123e; + } + else { + if (uxItemSize != 0) goto LAB_2306123e; + } + vAssertCalled(); +LAB_2306123e: + if (pxStaticQueue != (StaticQueue_t *)0x0) { + pxStaticQueue->ucDummy6 = '\x01'; + if (uxItemSize == 0) { + pucQueueStorage = (uint8_t *)pxStaticQueue; + } + *(uint8_t **)pxStaticQueue->pvDummy1 = pucQueueStorage; + pxStaticQueue->uxDummy4[1] = uxQueueLength; + pxStaticQueue->uxDummy4[2] = uxItemSize; + xQueueGenericReset((QueueHandle_t)pxStaticQueue,1); + pxStaticQueue->ucDummy9 = ucQueueType; + } + return (QueueHandle_t)pxStaticQueue; +} + + + +QueueHandle_t +xQueueGenericCreate(UBaseType_t uxQueueLength,UBaseType_t uxItemSize,uint8_t ucQueueType) + +{ + QueueHandle_t xQueue; + + if (uxQueueLength == 0) { + vAssertCalled(); + } + if (uxItemSize == 0) { + xQueue = (QueueHandle_t)pvPortMalloc(0x50); + if (xQueue == (QueueHandle_t)0x0) { + return (QueueHandle_t)0x0; + } + xQueue->ucStaticallyAllocated = '\0'; + *(QueueHandle_t *)&xQueue->pcHead = xQueue; + } + else { + xQueue = (QueueHandle_t)pvPortMalloc(uxQueueLength * uxItemSize + 0x50); + if (xQueue == (QueueHandle_t)0x0) { + return (QueueHandle_t)0x0; + } + xQueue->ucStaticallyAllocated = '\0'; + *(QueueHandle_t *)&xQueue->pcHead = xQueue + 1; + } + xQueue->uxLength = uxQueueLength; + xQueue->uxItemSize = uxItemSize; + xQueueGenericReset(xQueue,1); + xQueue->ucQueueType = ucQueueType; + return xQueue; +} + + + +QueueHandle_t xQueueCreateCountingSemaphore(UBaseType_t uxMaxCount,UBaseType_t uxInitialCount) + +{ + bool bVar1; + QueueHandle_t pQVar2; + + if (uxMaxCount == 0) { + vAssertCalled(); + bVar1 = uxInitialCount == 0; + } + else { + bVar1 = uxInitialCount <= uxMaxCount; + } + if (!bVar1) { + vAssertCalled(); + } + pQVar2 = xQueueGenericCreate(uxMaxCount,0,'\x02'); + if (pQVar2 != (QueueHandle_t)0x0) { + pQVar2->uxMessagesWaiting = uxInitialCount; + } + return pQVar2; +} + + + +// WARNING: Variable defined which should be unmapped: xTimeOut + +BaseType_t +xQueueGenericSend(QueueHandle_t xQueue,void *pvItemToQueue,TickType_t xTicksToWait, + BaseType_t xCopyPosition) + +{ + bool bVar1; + BaseType_t BVar2; + int iVar3; + TickType_t local_34 [3]; + undefined auStack40 [4]; + TimeOut_t xTimeOut; + + local_34[0] = xTicksToWait; + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + if ((pvItemToQueue == (void *)0x0) && (xQueue->uxItemSize != 0)) { + vAssertCalled(); + } + if ((xCopyPosition == 2) && (xQueue->uxLength != 1)) { + vAssertCalled(); + } + BVar2 = xTaskGetSchedulerState(); + if ((BVar2 == 0) && (local_34[0] != 0)) { + vAssertCalled(); + } + vTaskEnterCritical(); + bVar1 = false; + if (xQueue->uxLength <= xQueue->uxMessagesWaiting) { + do { + if (xCopyPosition == 2) break; + if (local_34[0] == 0) { + vTaskExitCritical(); + return 0; + } + if (!bVar1) { + vTaskInternalSetTimeOutState((TimeOut_t *)auStack40); + } + vTaskExitCritical(); + vTaskSuspendAll(); + vTaskEnterCritical(); + if (xQueue->cRxLock == -1) { + xQueue->cRxLock = '\0'; + } + if (xQueue->cTxLock == -1) { + xQueue->cTxLock = '\0'; + } + vTaskExitCritical(); + BVar2 = xTaskCheckForTimeOut((TimeOut_t *)auStack40,local_34); + if (BVar2 != 0) { + prvUnlockQueue((Queue_t *)xQueue); + xTaskResumeAll(); + return 0; + } + vTaskEnterCritical(); + if (xQueue->uxMessagesWaiting == xQueue->uxLength) { + vTaskExitCritical(); + vTaskPlaceOnEventList(&xQueue->xTasksWaitingToSend,local_34[0]); + prvUnlockQueue((Queue_t *)xQueue); + BVar2 = xTaskResumeAll(); + if (BVar2 == 0) { + ecall(); + } + } + else { + vTaskExitCritical(); + prvUnlockQueue((Queue_t *)xQueue); + xTaskResumeAll(); + } + bVar1 = true; + vTaskEnterCritical(); + } while (xQueue->uxLength <= xQueue->uxMessagesWaiting); + } + iVar3 = prvCopyDataToQueue((Queue_t *)xQueue,pvItemToQueue,xCopyPosition); + if ((xQueue->xTasksWaitingToReceive).uxNumberOfItems != 0) { + iVar3 = xTaskRemoveFromEventList(&xQueue->xTasksWaitingToReceive); + } + if (iVar3 != 0) { + ecall(); + } + vTaskExitCritical(); + return 1; +} + + + +QueueHandle_t xQueueCreateMutexStatic(uint8_t ucQueueType,StaticQueue_t *pxStaticQueue) + +{ + QueueHandle_t xQueue; + + xQueue = xQueueGenericCreateStatic(1,0,(uint8_t *)0x0,pxStaticQueue,ucQueueType); + if (xQueue != (QueueHandle_t)0x0) { + *(undefined4 *)&xQueue->u = 0; + xQueue->pcHead = (int8_t *)0x0; + *(undefined4 *)((int)&xQueue->u + 4) = 0; + xQueueGenericSend(xQueue,(void *)0x0,0,0); + } + return xQueue; +} + + + +BaseType_t xQueueGiveMutexRecursive(QueueHandle_t xMutex) + +{ + BaseType_t BVar1; + TaskHandle_t ptVar2; + int iVar3; + TaskHandle_t ptVar4; + + if (xMutex == (QueueHandle_t)0x0) { + vAssertCalled(); + } + ptVar4 = *(TaskHandle_t *)&xMutex->u; + ptVar2 = xTaskGetCurrentTaskHandle(); + BVar1 = 0; + if (ptVar4 == ptVar2) { + iVar3 = *(int *)((int)&xMutex->u + 4) + -1; + *(int *)((int)&xMutex->u + 4) = iVar3; + BVar1 = 1; + if (iVar3 == 0) { + xQueueGenericSend(xMutex,(void *)0x0,0,0); + BVar1 = 1; + } + } + return BVar1; +} + + + +QueueHandle_t xQueueCreateMutex(uint8_t ucQueueType) + +{ + QueueHandle_t xQueue; + + xQueue = xQueueGenericCreate(1,0,ucQueueType); + if (xQueue != (QueueHandle_t)0x0) { + *(undefined4 *)&xQueue->u = 0; + xQueue->pcHead = (int8_t *)0x0; + *(undefined4 *)((int)&xQueue->u + 4) = 0; + xQueueGenericSend(xQueue,(void *)0x0,0,0); + } + return xQueue; +} + + + +BaseType_t +xQueueGenericSendFromISR + (QueueHandle_t xQueue,void *pvItemToQueue,BaseType_t *pxHigherPriorityTaskWoken, + BaseType_t xCopyPosition) + +{ + byte bVar1; + BaseType_t BVar2; + + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + if ((pvItemToQueue == (void *)0x0) && (xQueue->uxItemSize != 0)) { + vAssertCalled(); + } + if (xCopyPosition == 2) { + if (xQueue->uxLength != 1) { + vAssertCalled(); + } + } + else { + if (xQueue->uxLength <= xQueue->uxMessagesWaiting) { + return 0; + } + } + bVar1 = xQueue->cTxLock; + prvCopyDataToQueue((Queue_t *)xQueue,pvItemToQueue,xCopyPosition); + if (bVar1 == 0xff) { + if ((((xQueue->xTasksWaitingToReceive).uxNumberOfItems != 0) && + (BVar2 = xTaskRemoveFromEventList(&xQueue->xTasksWaitingToReceive), BVar2 != 0)) && + (pxHigherPriorityTaskWoken != (BaseType_t *)0x0)) { + *pxHigherPriorityTaskWoken = 1; + } + return 1; + } + xQueue->cTxLock = (int8_t)(((uint)bVar1 + 1) * 0x1000000 >> 0x18); + return 1; +} + + + +BaseType_t xQueueGiveFromISR(QueueHandle_t xQueue,BaseType_t *pxHigherPriorityTaskWoken) + +{ + BaseType_t BVar1; + int8_t *piVar2; + + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + if (xQueue->uxItemSize == 0) { + piVar2 = xQueue->pcHead; + } + else { + vAssertCalled(); + piVar2 = xQueue->pcHead; + } + if ((piVar2 == (int8_t *)0x0) && (*(int *)&xQueue->u != 0)) { + vAssertCalled(); + } + BVar1 = 0; + if (xQueue->uxMessagesWaiting < xQueue->uxLength) { + xQueue->uxMessagesWaiting = xQueue->uxMessagesWaiting + 1; + if (xQueue->cTxLock == 0xff) { + if ((((xQueue->xTasksWaitingToReceive).uxNumberOfItems != 0) && + (BVar1 = xTaskRemoveFromEventList(&xQueue->xTasksWaitingToReceive), BVar1 != 0)) && + (pxHigherPriorityTaskWoken != (BaseType_t *)0x0)) { + *pxHigherPriorityTaskWoken = 1; + return 1; + } + } + else { + xQueue->cTxLock = (int8_t)(((uint)(byte)xQueue->cTxLock + 1) * 0x1000000 >> 0x18); + } + BVar1 = 1; + } + return BVar1; +} + + + +BaseType_t xQueueReceive(QueueHandle_t xQueue,void *pvBuffer,TickType_t xTicksToWait) + +{ + BaseType_t BVar1; + UBaseType_t UVar2; + TickType_t local_34 [3]; + undefined auStack40 [4]; + TimeOut_t xTimeOut; + + local_34[0] = xTicksToWait; + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + if ((pvBuffer == (void *)0x0) && (xQueue->uxItemSize != 0)) { + vAssertCalled(); + } + BVar1 = xTaskGetSchedulerState(); + if ((BVar1 == 0) && (local_34[0] != 0)) { + vAssertCalled(); + } + vTaskEnterCritical(); + UVar2 = xQueue->uxMessagesWaiting; + if (UVar2 != 0) { +LAB_2306175c: + prvCopyDataFromQueue((Queue_t *)xQueue,pvBuffer); + xQueue->uxMessagesWaiting = UVar2 - 1; + if (((xQueue->xTasksWaitingToSend).uxNumberOfItems != 0) && + (BVar1 = xTaskRemoveFromEventList(&xQueue->xTasksWaitingToSend), BVar1 != 0)) { + ecall(); + } + vTaskExitCritical(); + return 1; + } + if (local_34[0] != 0) { + vTaskInternalSetTimeOutState((TimeOut_t *)auStack40); + do { + vTaskExitCritical(); + vTaskSuspendAll(); + vTaskEnterCritical(); + if (xQueue->cRxLock == -1) { + xQueue->cRxLock = '\0'; + } + if (xQueue->cTxLock == -1) { + xQueue->cTxLock = '\0'; + } + vTaskExitCritical(); + BVar1 = xTaskCheckForTimeOut((TimeOut_t *)auStack40,local_34); + if (BVar1 == 0) { + vTaskEnterCritical(); + if (xQueue->uxMessagesWaiting == 0) { + vTaskExitCritical(); + vTaskPlaceOnEventList(&xQueue->xTasksWaitingToReceive,local_34[0]); + prvUnlockQueue((Queue_t *)xQueue); + BVar1 = xTaskResumeAll(); + if (BVar1 == 0) { + ecall(); + } + goto LAB_23061750; + } + vTaskExitCritical(); + prvUnlockQueue((Queue_t *)xQueue); + xTaskResumeAll(); + vTaskEnterCritical(); + UVar2 = xQueue->uxMessagesWaiting; + } + else { + prvUnlockQueue((Queue_t *)xQueue); + xTaskResumeAll(); + vTaskEnterCritical(); + if (xQueue->uxMessagesWaiting == 0) break; + vTaskExitCritical(); +LAB_23061750: + vTaskEnterCritical(); + UVar2 = xQueue->uxMessagesWaiting; + } + if (UVar2 != 0) goto LAB_2306175c; + } while (local_34[0] != 0); + } + vTaskExitCritical(); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling + +BaseType_t xQueueSemaphoreTake(QueueHandle_t xQueue,TickType_t xTicksToWait) + +{ + bool bVar1; + BaseType_t BVar2; + TaskHandle_t ptVar3; + UBaseType_t uxHighestPriorityWaitingTask; + int iVar4; + TickType_t local_34 [3]; + undefined auStack40 [4]; + TimeOut_t xTimeOut; + + local_34[0] = xTicksToWait; + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + if (xQueue->uxItemSize != 0) { + vAssertCalled(); + } + BVar2 = xTaskGetSchedulerState(); + if ((BVar2 == 0) && (local_34[0] != 0)) { + vAssertCalled(); + } + vTaskEnterCritical(); + uxHighestPriorityWaitingTask = xQueue->uxMessagesWaiting; + iVar4 = 0; + bVar1 = false; + while( true ) { + if (uxHighestPriorityWaitingTask != 0) { + xQueue->uxMessagesWaiting = uxHighestPriorityWaitingTask - 1; + if (xQueue->pcHead == (int8_t *)0x0) { + ptVar3 = pvTaskIncrementMutexHeldCount(); + *(TaskHandle_t *)&xQueue->u = ptVar3; + } + if (((xQueue->xTasksWaitingToSend).uxNumberOfItems != 0) && + (BVar2 = xTaskRemoveFromEventList(&xQueue->xTasksWaitingToSend), BVar2 != 0)) { + ecall(); + } + vTaskExitCritical(); + return 1; + } + if (local_34[0] == 0) break; + if (!bVar1) { + vTaskInternalSetTimeOutState((TimeOut_t *)auStack40); + } + vTaskExitCritical(); + vTaskSuspendAll(); + vTaskEnterCritical(); + if (xQueue->cRxLock == -1) { + xQueue->cRxLock = '\0'; + } + if (xQueue->cTxLock == -1) { + xQueue->cTxLock = '\0'; + } + vTaskExitCritical(); + BVar2 = xTaskCheckForTimeOut((TimeOut_t *)auStack40,local_34); + if (BVar2 == 0) { + vTaskEnterCritical(); + if (xQueue->uxMessagesWaiting == 0) { + vTaskExitCritical(); + if (xQueue->pcHead == (int8_t *)0x0) { + vTaskEnterCritical(); + iVar4 = xTaskPriorityInherit(*(TaskHandle_t *)&xQueue->u); + vTaskExitCritical(); + } + vTaskPlaceOnEventList(&xQueue->xTasksWaitingToReceive,local_34[0]); + prvUnlockQueue((Queue_t *)xQueue); + BVar2 = xTaskResumeAll(); + if (BVar2 == 0) { + ecall(); + } + } + else { + vTaskExitCritical(); + prvUnlockQueue((Queue_t *)xQueue); + xTaskResumeAll(); + } + } + else { + prvUnlockQueue((Queue_t *)xQueue); + xTaskResumeAll(); + vTaskEnterCritical(); + if (xQueue->uxMessagesWaiting == 0) { + vTaskExitCritical(); + if (iVar4 == 0) { + return 0; + } + vTaskEnterCritical(); + uxHighestPriorityWaitingTask = (xQueue->xTasksWaitingToReceive).uxNumberOfItems; + if (uxHighestPriorityWaitingTask != 0) { + uxHighestPriorityWaitingTask = + 0x20 - ((xQueue->xTasksWaitingToReceive).xListEnd.pxNext)->xItemValue; + } + vTaskPriorityDisinheritAfterTimeout + (*(TaskHandle_t *)&xQueue->u,uxHighestPriorityWaitingTask); + vTaskExitCritical(); + return 0; + } + vTaskExitCritical(); + } + bVar1 = true; + vTaskEnterCritical(); + uxHighestPriorityWaitingTask = xQueue->uxMessagesWaiting; + } + if (iVar4 != 0) { + vAssertCalled(); + } + vTaskExitCritical(); + return 0; +} + + + +BaseType_t xQueueTakeMutexRecursive(QueueHandle_t xMutex,TickType_t xTicksToWait) + +{ + TaskHandle_t ptVar1; + TaskHandle_t ptVar2; + BaseType_t BVar3; + + if (xMutex == (QueueHandle_t)0x0) { + vAssertCalled(); + } + ptVar1 = *(TaskHandle_t *)&xMutex->u; + ptVar2 = xTaskGetCurrentTaskHandle(); + if (ptVar1 != ptVar2) { + BVar3 = xQueueSemaphoreTake(xMutex,xTicksToWait); + if (BVar3 != 0) { + *(int *)((int)&xMutex->u + 4) = *(int *)((int)&xMutex->u + 4) + 1; + } + return BVar3; + } + *(int *)((int)&xMutex->u + 4) = *(int *)((int)&xMutex->u + 4) + 1; + return 1; +} + + + +UBaseType_t uxQueueMessagesWaiting(QueueHandle_t xQueue) + +{ + UBaseType_t UVar1; + + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + vTaskEnterCritical(); + UVar1 = xQueue->uxMessagesWaiting; + vTaskExitCritical(); + return UVar1; +} + + + +void vQueueDelete(QueueHandle_t xQueue) + +{ + QueueHandle_t *ppQVar1; + int iVar2; + QueueRegistryItem_t *pQVar3; + + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + iVar2 = 0; + pQVar3 = xQueueRegistry; + do { + ppQVar1 = &pQVar3->xHandle; + pQVar3 = pQVar3 + 1; + if (*ppQVar1 == (QueueHandle_t)0x0) { + xQueueRegistry[iVar2].pcQueueName = (char *)0x0; + xQueueRegistry[iVar2].xHandle = (QueueHandle_t)0x0; + break; + } + iVar2 = iVar2 + 1; + } while (iVar2 != 8); + if (cRam00000046 != '\0') { + return; + } + vPortFree((void *)0x0); + return; + } + iVar2 = 0; + pQVar3 = xQueueRegistry; + do { + ppQVar1 = &pQVar3->xHandle; + pQVar3 = pQVar3 + 1; + if (xQueue == *ppQVar1) { + xQueueRegistry[iVar2].pcQueueName = (char *)0x0; + xQueueRegistry[iVar2].xHandle = (QueueHandle_t)0x0; + break; + } + iVar2 = iVar2 + 1; + } while (iVar2 != 8); + if (xQueue->ucStaticallyAllocated != '\0') { + return; + } + vPortFree(xQueue); + return; +} + + + +void vQueueAddToRegistry(QueueHandle_t xQueue,char *pcQueueName) + +{ + char **ppcVar1; + int iVar2; + QueueRegistryItem_t *pQVar3; + + iVar2 = 0; + pQVar3 = xQueueRegistry; + do { + ppcVar1 = &pQVar3->pcQueueName; + pQVar3 = pQVar3 + 1; + if (*ppcVar1 == (char *)0x0) { + xQueueRegistry[iVar2].pcQueueName = pcQueueName; + xQueueRegistry[iVar2].xHandle = xQueue; + return; + } + iVar2 = iVar2 + 1; + } while (iVar2 != 8); + return; +} + + + +void vQueueWaitForMessageRestricted + (QueueHandle_t xQueue,TickType_t xTicksToWait,BaseType_t xWaitIndefinitely) + +{ + vTaskEnterCritical(); + if (xQueue->cRxLock == -1) { + xQueue->cRxLock = '\0'; + } + if (xQueue->cTxLock == -1) { + xQueue->cTxLock = '\0'; + } + vTaskExitCritical(); + if (xQueue->uxMessagesWaiting != 0) { + prvUnlockQueue((Queue_t *)xQueue); + return; + } + vTaskPlaceOnEventListRestricted(&xQueue->xTasksWaitingToReceive,xTicksToWait,xWaitIndefinitely); + prvUnlockQueue((Queue_t *)xQueue); + return; +} + + + +void prvInitialiseNewStreamBuffer + (StreamBuffer_t *pxStreamBuffer,uint8_t *pucBuffer,size_t xBufferSizeBytes, + size_t xTriggerLevelBytes,uint8_t ucFlags) + +{ + uint8_t *puVar1; + + puVar1 = (uint8_t *)memset(pucBuffer,0x55,xBufferSizeBytes); + if (pucBuffer != puVar1) { + vAssertCalled(); + } + memset(pxStreamBuffer,0,0x24); + pxStreamBuffer->pucBuffer = pucBuffer; + pxStreamBuffer->xLength = xBufferSizeBytes; + pxStreamBuffer->xTriggerLevelBytes = xTriggerLevelBytes; + pxStreamBuffer->ucFlags = ucFlags; + return; +} + + + +size_t prvWriteBytesToBuffer(StreamBuffer_t *pxStreamBuffer,uint8_t *pucData,size_t xCount) + +{ + uint uVar1; + uint __n; + size_t __n_00; + + if (xCount == 0) { + vAssertCalled(); + uVar1 = pxStreamBuffer->xHead; + if (pxStreamBuffer->xLength < uVar1) { + __n_00 = 0; + goto LAB_23061bb4; + } + memcpy(pxStreamBuffer->pucBuffer + uVar1,pucData,0); + __n = pxStreamBuffer->xLength; + if (uVar1 < __n) goto LAB_23061b92; + } + else { + uVar1 = pxStreamBuffer->xHead; + __n_00 = pxStreamBuffer->xLength - uVar1; + if (xCount < __n_00) { + __n = uVar1 + xCount; + __n_00 = xCount; + } + else { + __n = uVar1 + __n_00; + } + if (pxStreamBuffer->xLength < __n) { +LAB_23061bb4: + vAssertCalled(); + } + memcpy(pxStreamBuffer->pucBuffer + uVar1,pucData,__n_00); + if (__n_00 < xCount) { + __n = xCount - __n_00; + if (pxStreamBuffer->xLength < __n) { + vAssertCalled(); + memcpy(pxStreamBuffer->pucBuffer,pucData + __n_00,__n); + } + else { + memcpy(pxStreamBuffer->pucBuffer,pucData + __n_00,__n); + } + } + __n = pxStreamBuffer->xLength; + uVar1 = uVar1 + xCount; + if (uVar1 < __n) goto LAB_23061b92; + } + uVar1 = uVar1 - __n; +LAB_23061b92: + pxStreamBuffer->xHead = uVar1; + return xCount; +} + + + +size_t prvReadBytesFromBuffer + (StreamBuffer_t *pxStreamBuffer,uint8_t *pucData,size_t xMaxCount, + size_t xBytesAvailable) + +{ + size_t sVar1; + uint __n; + + if (xMaxCount <= xBytesAvailable) { + xBytesAvailable = xMaxCount; + } + if (xBytesAvailable == 0) { + return 0; + } + sVar1 = pxStreamBuffer->xTail; + __n = pxStreamBuffer->xLength - sVar1; + if (xBytesAvailable < __n) { + __n = xBytesAvailable; + if (xBytesAvailable <= xMaxCount) goto LAB_23061c22; +LAB_23061c7c: + vAssertCalled(); + if (sVar1 + __n <= pxStreamBuffer->xLength) goto LAB_23061c2a; + } + else { + if (xMaxCount < __n) goto LAB_23061c7c; +LAB_23061c22: + if (sVar1 + __n <= pxStreamBuffer->xLength) goto LAB_23061c2a; + } + vAssertCalled(); +LAB_23061c2a: + memcpy(pucData,pxStreamBuffer->pucBuffer + sVar1,__n); + if (__n < xBytesAvailable) { + if (xMaxCount < xBytesAvailable) { + vAssertCalled(); + } + memcpy(pucData + __n,pxStreamBuffer->pucBuffer,xBytesAvailable - __n); + } + sVar1 = sVar1 + xBytesAvailable; + if (pxStreamBuffer->xLength <= sVar1) { + sVar1 = sVar1 - pxStreamBuffer->xLength; + } + pxStreamBuffer->xTail = sVar1; + return xBytesAvailable; +} + + + +StreamBufferHandle_t +xStreamBufferGenericCreate + (size_t xBufferSizeBytes,size_t xTriggerLevelBytes,BaseType_t xIsMessageBuffer) + +{ + uint8_t uVar1; + StreamBuffer_t *pxStreamBuffer; + uint8_t ucFlags; + + ucFlags = (uint8_t)xBufferSizeBytes; + if (xIsMessageBuffer == 1) { + uVar1 = '\x01'; + if (xBufferSizeBytes < 5) { + vAssertCalled(); + uVar1 = '\x01'; + } +joined_r0x23061d06: + ucFlags = uVar1; + if (xTriggerLevelBytes <= xBufferSizeBytes) goto joined_r0x23061cb4; + } + else { + uVar1 = '\0'; + if (xBufferSizeBytes != 0) goto joined_r0x23061d06; + vAssertCalled(); + if (xTriggerLevelBytes == 0) goto joined_r0x23061cb4; + } + vAssertCalled(); +joined_r0x23061cb4: + if (xTriggerLevelBytes == 0) { + xTriggerLevelBytes = 1; + } + pxStreamBuffer = (StreamBuffer_t *)pvPortMalloc(xBufferSizeBytes + 0x25); + if (pxStreamBuffer != (StreamBuffer_t *)0x0) { + prvInitialiseNewStreamBuffer + (pxStreamBuffer,(uint8_t *)(pxStreamBuffer + 1),xBufferSizeBytes + 1, + xTriggerLevelBytes,ucFlags); + } + return (StreamBufferHandle_t)pxStreamBuffer; +} + + + +// WARNING: Removing unreachable block (ram,0x23061d98) + +StreamBufferHandle_t +xStreamBufferGenericCreateStatic + (size_t xBufferSizeBytes,size_t xTriggerLevelBytes,BaseType_t xIsMessageBuffer, + uint8_t *pucStreamBufferStorageArea,StaticStreamBuffer_t *pxStaticStreamBuffer) + +{ + size_t xSize; + + if (pucStreamBufferStorageArea == (uint8_t *)0x0) { + vAssertCalled(); + } + if (pxStaticStreamBuffer == (StaticStreamBuffer_t *)0x0) { + vAssertCalled(); + } + if (xBufferSizeBytes < xTriggerLevelBytes) { + vAssertCalled(); + } + if (xTriggerLevelBytes == 0) { + xTriggerLevelBytes = 1; + } + if (xBufferSizeBytes < 5) { + vAssertCalled(); + } + if (pucStreamBufferStorageArea == (uint8_t *)0x0) { + pxStaticStreamBuffer = (StaticStreamBuffer_t *)0x0; + } + else { + if (pxStaticStreamBuffer != (StaticStreamBuffer_t *)0x0) { + prvInitialiseNewStreamBuffer + ((StreamBuffer_t *)pxStaticStreamBuffer,pucStreamBufferStorageArea,xBufferSizeBytes, + xTriggerLevelBytes,(xIsMessageBuffer != 0) + '\x02'); + pxStaticStreamBuffer->ucDummy3 = pxStaticStreamBuffer->ucDummy3 | 2; + } + } + return (StreamBufferHandle_t)pxStaticStreamBuffer; +} + + + +void vStreamBufferDelete(StreamBufferHandle_t xStreamBuffer) + +{ + if (xStreamBuffer == (StreamBufferHandle_t)0x0) { + vAssertCalled(); + if ((DAT_0000001c & 2) == 0) { + vPortFree((void *)0x0); + return; + } + memset((void *)0x0,0,0x24); + return; + } + if ((xStreamBuffer->ucFlags & 2) == 0) { + vPortFree(xStreamBuffer); + return; + } + memset(xStreamBuffer,0,0x24); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +size_t xStreamBufferSpacesAvailable(StreamBufferHandle_t xStreamBuffer) + +{ + uint uVar1; + size_t sVar2; + uint uVar3; + + if (xStreamBuffer == (StreamBufferHandle_t)0x0) { + vAssertCalled(); + sVar2 = (_DAT_00000008 + iRam00000000 + -1) - _DAT_00000004; + if (_DAT_00000008 <= sVar2) { + sVar2 = sVar2 - _DAT_00000008; + } + return sVar2; + } + uVar3 = xStreamBuffer->xLength; + uVar1 = (uVar3 + xStreamBuffer->xTail + -1) - xStreamBuffer->xHead; + if (uVar3 <= uVar1) { + return uVar1 - uVar3; + } + return uVar1; +} + + + +size_t xStreamBufferSend(StreamBufferHandle_t xStreamBuffer,void *pvTxData,size_t xDataLengthBytes, + TickType_t xTicksToWait) + +{ + TaskHandle_t ptVar1; + BaseType_t BVar2; + uint uVar3; + uint uVar4; + size_t sVar5; + TickType_t aTStack52 [2]; + size_t sStack44; + undefined auStack40 [4]; + TimeOut_t xTimeOut; + + aTStack52[0] = xTicksToWait; + if (pvTxData == (void *)0x0) { + vAssertCalled(); + } + if (xStreamBuffer == (StreamBufferHandle_t)0x0) { + vAssertCalled(); + } + sVar5 = xDataLengthBytes; + if (((xStreamBuffer->ucFlags & 1) == 0) || + (sVar5 = xDataLengthBytes + 4, xDataLengthBytes < sVar5)) { + if (aTStack52[0] != 0) goto LAB_23061e76; +LAB_23061f18: + uVar3 = xStreamBufferSpacesAvailable(xStreamBuffer); + if (uVar3 != 0) goto LAB_23061ec8; +LAB_23061f24: + sVar5 = 0; + } + else { + vAssertCalled(); + if (aTStack52[0] == 0) goto LAB_23061f18; +LAB_23061e76: + vTaskSetTimeOutState((TimeOut_t *)auStack40); + do { + vTaskEnterCritical(); + uVar3 = xStreamBufferSpacesAvailable(xStreamBuffer); + if (sVar5 <= uVar3) { + vTaskExitCritical(); + break; + } + xTaskNotifyStateClear((TaskHandle_t)0x0); + if (xStreamBuffer->xTaskWaitingToSend != (TaskHandle_t)0x0) { + vAssertCalled(); + } + ptVar1 = xTaskGetCurrentTaskHandle(); + xStreamBuffer->xTaskWaitingToSend = ptVar1; + vTaskExitCritical(); + xTaskNotifyWait(0,0,(uint32_t *)0x0,aTStack52[0]); + xStreamBuffer->xTaskWaitingToSend = (TaskHandle_t)0x0; + BVar2 = xTaskCheckForTimeOut((TimeOut_t *)auStack40,aTStack52); + } while (BVar2 == 0); + if (uVar3 == 0) goto LAB_23061f18; +LAB_23061ec8: + if ((xStreamBuffer->ucFlags & 1) == 0) { + sStack44 = xDataLengthBytes; + if (uVar3 < xDataLengthBytes) { + sStack44 = uVar3; + } + } + else { + if (uVar3 < sVar5) goto LAB_23061f24; + sStack44 = xDataLengthBytes; + prvWriteBytesToBuffer((StreamBuffer_t *)xStreamBuffer,(uint8_t *)&sStack44,4); + } + sVar5 = prvWriteBytesToBuffer((StreamBuffer_t *)xStreamBuffer,(uint8_t *)pvTxData,sStack44); + if (sVar5 != 0) { + uVar3 = xStreamBuffer->xLength; + uVar4 = (xStreamBuffer->xHead + uVar3) - xStreamBuffer->xTail; + if (uVar3 <= uVar4) { + uVar4 = uVar4 - uVar3; + } + if (xStreamBuffer->xTriggerLevelBytes <= uVar4) { + vTaskSuspendAll(); + if (xStreamBuffer->xTaskWaitingToReceive != (TaskHandle_t)0x0) { + xTaskGenericNotify(xStreamBuffer->xTaskWaitingToReceive,0,eNoAction,(uint32_t *)0x0); + xStreamBuffer->xTaskWaitingToReceive = (TaskHandle_t)0x0; + } + xTaskResumeAll(); + } + } + } + return sVar5; +} + + + +size_t xStreamBufferSendFromISR + (StreamBufferHandle_t xStreamBuffer,void *pvTxData,size_t xDataLengthBytes, + BaseType_t *pxHigherPriorityTaskWoken) + +{ + size_t sVar1; + uint uVar2; + uint uVar3; + size_t sVar4; + size_t asStack36 [3]; + + if (pvTxData == (void *)0x0) { + vAssertCalled(); + } + if (xStreamBuffer == (StreamBufferHandle_t)0x0) { + vAssertCalled(); + } + sVar4 = xDataLengthBytes; + if ((xStreamBuffer->ucFlags & 1) != 0) { + sVar4 = xDataLengthBytes + 4; + } + sVar1 = xStreamBufferSpacesAvailable(xStreamBuffer); + if (sVar1 == 0) { +LAB_23061f9a: + sVar4 = 0; + } + else { + if ((xStreamBuffer->ucFlags & 1) == 0) { + asStack36[0] = xDataLengthBytes; + if (sVar1 < xDataLengthBytes) { + asStack36[0] = sVar1; + } + } + else { + if (sVar1 < sVar4) goto LAB_23061f9a; + asStack36[0] = xDataLengthBytes; + prvWriteBytesToBuffer((StreamBuffer_t *)xStreamBuffer,(uint8_t *)asStack36,4); + } + sVar4 = prvWriteBytesToBuffer((StreamBuffer_t *)xStreamBuffer,(uint8_t *)pvTxData,asStack36[0]); + if (sVar4 != 0) { + uVar2 = xStreamBuffer->xLength; + uVar3 = (xStreamBuffer->xHead + uVar2) - xStreamBuffer->xTail; + if (uVar2 <= uVar3) { + uVar3 = uVar3 - uVar2; + } + if ((xStreamBuffer->xTriggerLevelBytes <= uVar3) && + (xStreamBuffer->xTaskWaitingToReceive != (TaskHandle_t)0x0)) { + xTaskGenericNotifyFromISR + (xStreamBuffer->xTaskWaitingToReceive,0,eNoAction,(uint32_t *)0x0, + pxHigherPriorityTaskWoken); + xStreamBuffer->xTaskWaitingToReceive = (TaskHandle_t)0x0; + } + } + } + return sVar4; +} + + + +size_t xStreamBufferReceive + (StreamBufferHandle_t xStreamBuffer,void *pvRxData,size_t xBufferLengthBytes, + TickType_t xTicksToWait) + +{ + bool bVar1; + byte bVar2; + size_t xBytesAvailable; + TaskHandle_t ptVar3; + uint uVar4; + uint uVar5; + uint xMaxCount; + size_t sVar6; + uint uStack36; + size_t xTempNextMessageLength; + + if (pvRxData == (void *)0x0) { + vAssertCalled(); + } + if (xStreamBuffer == (StreamBufferHandle_t)0x0) { + vAssertCalled(); + } + bVar2 = xStreamBuffer->ucFlags; + uVar5 = (uint)bVar2 & 1; + xMaxCount = uVar5 * 4; + if (xTicksToWait != 0) { + vTaskEnterCritical(); + uVar4 = xStreamBuffer->xLength; + xBytesAvailable = (xStreamBuffer->xHead + uVar4) - xStreamBuffer->xTail; + if (uVar4 <= xBytesAvailable) { + xBytesAvailable = xBytesAvailable - uVar4; + } + if (xMaxCount < xBytesAvailable) { + vTaskExitCritical(); + goto LAB_2306208a; + } + xTaskNotifyStateClear((TaskHandle_t)0x0); + if (xStreamBuffer->xTaskWaitingToReceive != (TaskHandle_t)0x0) { + vAssertCalled(); + } + ptVar3 = xTaskGetCurrentTaskHandle(); + xStreamBuffer->xTaskWaitingToReceive = ptVar3; + vTaskExitCritical(); + xTaskNotifyWait(0,0,(uint32_t *)0x0,xTicksToWait); + xStreamBuffer->xTaskWaitingToReceive = (TaskHandle_t)0x0; + } + uVar4 = xStreamBuffer->xLength; + xBytesAvailable = (xStreamBuffer->xHead + uVar4) - xStreamBuffer->xTail; + if (uVar4 <= xBytesAvailable) { + xBytesAvailable = xBytesAvailable - uVar4; + } + if (xBytesAvailable <= xMaxCount) { + return 0; + } +LAB_2306208a: + if ((bVar2 & 1) != 0) { + sVar6 = xStreamBuffer->xTail; + prvReadBytesFromBuffer + ((StreamBuffer_t *)xStreamBuffer,(uint8_t *)&uStack36,xMaxCount,xBytesAvailable); + xBytesAvailable = xBytesAvailable + uVar5 * -4; + bVar1 = xBufferLengthBytes < uStack36; + xBufferLengthBytes = uStack36; + if (bVar1) { + xStreamBuffer->xTail = sVar6; + xBufferLengthBytes = 0; + } + } + xBytesAvailable = + prvReadBytesFromBuffer + ((StreamBuffer_t *)xStreamBuffer,(uint8_t *)pvRxData,xBufferLengthBytes, + xBytesAvailable); + if (xBytesAvailable == 0) { + return 0; + } + vTaskSuspendAll(); + if (xStreamBuffer->xTaskWaitingToSend != (TaskHandle_t)0x0) { + xTaskGenericNotify(xStreamBuffer->xTaskWaitingToSend,0,eNoAction,(uint32_t *)0x0); + xStreamBuffer->xTaskWaitingToSend = (TaskHandle_t)0x0; + } + xTaskResumeAll(); + return xBytesAvailable; +} + + + +// WARNING: Variable defined which should be unmapped: xTempNextMessageLength + +size_t xStreamBufferReceiveFromISR + (StreamBufferHandle_t xStreamBuffer,void *pvRxData,size_t xBufferLengthBytes, + BaseType_t *pxHigherPriorityTaskWoken) + +{ + bool bVar1; + size_t xBytesAvailable; + uint uVar2; + uint uVar3; + uint xMaxCount; + size_t sVar4; + uint uStack36; + size_t xTempNextMessageLength; + + if (pvRxData == (void *)0x0) { + vAssertCalled(); + } + if (xStreamBuffer == (StreamBufferHandle_t)0x0) { + vAssertCalled(); + } + uVar2 = xStreamBuffer->xLength; + uVar3 = (uint)xStreamBuffer->ucFlags & 1; + xBytesAvailable = (xStreamBuffer->xHead + uVar2) - xStreamBuffer->xTail; + xMaxCount = uVar3 * 4; + if (uVar2 <= xBytesAvailable) { + xBytesAvailable = xBytesAvailable - uVar2; + } + if (xMaxCount < xBytesAvailable) { + if ((xStreamBuffer->ucFlags & 1) != 0) { + sVar4 = xStreamBuffer->xTail; + prvReadBytesFromBuffer + ((StreamBuffer_t *)xStreamBuffer,(uint8_t *)&uStack36,xMaxCount,xBytesAvailable); + xBytesAvailable = xBytesAvailable + uVar3 * -4; + bVar1 = xBufferLengthBytes < uStack36; + xBufferLengthBytes = uStack36; + if (bVar1) { + xStreamBuffer->xTail = sVar4; + xBufferLengthBytes = 0; + } + } + xBytesAvailable = + prvReadBytesFromBuffer + ((StreamBuffer_t *)xStreamBuffer,(uint8_t *)pvRxData,xBufferLengthBytes, + xBytesAvailable); + if (xBytesAvailable != 0) { + if (xStreamBuffer->xTaskWaitingToSend == (TaskHandle_t)0x0) { + return xBytesAvailable; + } + xTaskGenericNotifyFromISR + (xStreamBuffer->xTaskWaitingToSend,0,eNoAction,(uint32_t *)0x0, + pxHigherPriorityTaskWoken); + xStreamBuffer->xTaskWaitingToSend = (TaskHandle_t)0x0; + return xBytesAvailable; + } + } + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BaseType_t xStreamBufferIsEmpty(StreamBufferHandle_t xStreamBuffer) + +{ + if (xStreamBuffer != (StreamBufferHandle_t)0x0) { + return (uint)(xStreamBuffer->xHead == xStreamBuffer->xTail); + } + vAssertCalled(); + return (uint)(_DAT_00000004 == iRam00000000); +} + + + +void prvResetNextTaskUnblockTime(void) + +{ + xNextTaskUnblockTime = *(TickType_t *)((int)((pxDelayedTaskList->xListEnd).pxNext)->pvOwner + 4); + return; +} + + + +void prvInitialiseNewTask + (TaskFunction_t *pxTaskCode,char *pcName,uint32_t ulStackDepth,void *pvParameters, + UBaseType_t uxPriority,TaskHandle_t *pxCreatedTask,TCB_t *pxNewTCB) + +{ + char cVar1; + char *pcVar2; + char *pcVar3; + StackType_t *pSVar4; + + memset(pxNewTCB->pxStack,0xa5,ulStackDepth * 4); + pSVar4 = pxNewTCB->pxStack; + if (pcName == (char *)0x0) { + pxNewTCB->pcTaskName[0] = '\0'; + } + else { + pcVar2 = pcName + 0x10; + pcVar3 = pxNewTCB->pcTaskName; + do { + cVar1 = *pcName; + pcName = pcName + 1; + *pcVar3 = cVar1; + if (cVar1 == '\0') break; + pcVar3 = pcVar3 + 1; + } while (pcName != pcVar2); + pxNewTCB->pcTaskName[0xf] = '\0'; + } + if (0x1f < uxPriority) { + uxPriority = 0x1f; + } + pxNewTCB->uxPriority = uxPriority; + pxNewTCB->uxBasePriority = uxPriority; + pxNewTCB->uxMutexesHeld = 0; + vListInitialiseItem(&pxNewTCB->xStateListItem); + vListInitialiseItem(&pxNewTCB->xEventListItem); + pxNewTCB->ulNotifiedValue = 0; + *(TCB_t **)&(pxNewTCB->xStateListItem).pvOwner = pxNewTCB; + (pxNewTCB->xEventListItem).xItemValue = 0x20 - uxPriority; + *(TCB_t **)&(pxNewTCB->xEventListItem).pvOwner = pxNewTCB; + pxNewTCB->uxCriticalNesting = 0; + pxNewTCB->ucNotifyState = '\0'; + pSVar4 = (StackType_t *) + pxPortInitialiseStack + ((uint)(pSVar4 + (ulStackDepth - 1)) & 0xfffffff8,pxTaskCode,pvParameters); + pxNewTCB->pxTopOfStack = pSVar4; + if (pxCreatedTask != (TaskHandle_t *)0x0) { + *(TCB_t **)pxCreatedTask = pxNewTCB; + } + return; +} + + + +void prvDeleteTCB(TCB_t *pxTCB) + +{ + uint8_t uVar1; + + uVar1 = pxTCB->ucStaticallyAllocated; + if (uVar1 == '\0') { + vPortFree(pxTCB->pxStack); + vPortFree(pxTCB); + return; + } + if (uVar1 != '\x01') { + if (uVar1 == '\x02') { + return; + } + vAssertCalled(); + return; + } + vPortFree(pxTCB); + return; +} + + + +void prvAddCurrentTaskToDelayedList(TickType_t xTicksToWait,BaseType_t xCanBlockIndefinitely) + +{ + TickType_t TVar1; + uint uVar2; + UBaseType_t UVar3; + + TVar1 = xTickCount; + UVar3 = uxListRemove(&pxCurrentTCB->xStateListItem); + if (UVar3 == 0) { + uxTopReadyPriority = ~(1 << (pxCurrentTCB->uxPriority & 0x1f)) & uxTopReadyPriority; + } + if ((xTicksToWait == 0xffffffff) && (xCanBlockIndefinitely != 0)) { + vListInsertEnd(&xSuspendedTaskList,&pxCurrentTCB->xStateListItem); + return; + } + uVar2 = xTicksToWait + TVar1; + (pxCurrentTCB->xStateListItem).xItemValue = uVar2; + if (TVar1 <= uVar2) { + vListInsert(pxDelayedTaskList,&pxCurrentTCB->xStateListItem); + if (uVar2 < xNextTaskUnblockTime) { + xNextTaskUnblockTime = uVar2; + } + return; + } + vListInsert(pxOverflowDelayedTaskList,&pxCurrentTCB->xStateListItem); + return; +} + + + +void vTaskEnterCritical(void) + +{ + pxCurrentTCB->uxCriticalNesting = pxCurrentTCB->uxCriticalNesting + 1; + return; +} + + + +void vTaskExitCritical(void) + +{ + pxCurrentTCB->uxCriticalNesting = pxCurrentTCB->uxCriticalNesting - 1; + return; +} + + + +void prvAddNewTaskToReadyList(TCB_t *pxNewTCB) + +{ + uint uVar1; + List_t *pxList; + List_t *pLVar2; + + if (xSchedulerRunning != 0) { + vTaskEnterCritical(); + } + uxCurrentNumberOfTasks = uxCurrentNumberOfTasks + 1; + if (pxCurrentTCB == (TCB_t *)0x0) { + if (uxCurrentNumberOfTasks == 1) { + pxList = pxReadyTasksLists; + pxCurrentTCB = pxNewTCB; + do { + pLVar2 = pxList + 1; + vListInitialise(pxList); + pxList = pLVar2; + } while (pLVar2 != &xDelayedTaskList1); + vListInitialise(&xDelayedTaskList1); + vListInitialise(&xDelayedTaskList2); + vListInitialise(&xPendingReadyList); + vListInitialise(&xTasksWaitingTermination); + vListInitialise(&xSuspendedTaskList); + pxDelayedTaskList = &xDelayedTaskList1; + pxOverflowDelayedTaskList = &xDelayedTaskList2; + uVar1 = pxNewTCB->uxPriority; + } + else { + uVar1 = pxNewTCB->uxPriority; + pxCurrentTCB = pxNewTCB; + } + } + else { + uVar1 = pxNewTCB->uxPriority; + if ((xSchedulerRunning == 0) && (pxCurrentTCB->uxPriority <= uVar1)) { + pxCurrentTCB = pxNewTCB; + } + } + uxTaskNumber = uxTaskNumber + 1; + uxTopReadyPriority = 1 << (uVar1 & 0x1f) | uxTopReadyPriority; + pxNewTCB->uxTCBNumber = uxTaskNumber; + vListInsertEnd(pxReadyTasksLists + uVar1,&pxNewTCB->xStateListItem); + if ((xSchedulerRunning != 0) && (pxCurrentTCB->uxCriticalNesting != 0)) { + vTaskExitCritical(); + } + if ((xSchedulerRunning != 0) && (pxCurrentTCB->uxPriority < pxNewTCB->uxPriority)) { + ecall(); + } + return; +} + + +/* +Unable to decompile 'prvIdleTask' +Cause: Exception while decompiling 23062562: Decompiler process died + +*/ + + +// WARNING: Removing unreachable block (ram,0x2306264a) +// WARNING: Removing unreachable block (ram,0x23062690) + +TaskHandle_t +xTaskCreateStatic(TaskFunction_t *pxTaskCode,char *pcName,uint32_t ulStackDepth,void *pvParameters, + UBaseType_t uxPriority,StackType_t *puxStackBuffer,StaticTask_t *pxTaskBuffer) + +{ + TaskHandle_t ptVar1; + size_t xSize; + TaskHandle_t xReturn; + + ptVar1 = (TaskHandle_t)xSize; + if (puxStackBuffer == (StackType_t *)0x0) { + vAssertCalled(); + ptVar1 = (TaskHandle_t)xSize; + } + if (pxTaskBuffer == (StaticTask_t *)0x0) { + vAssertCalled(); + return (TaskHandle_t)0x0; + } + xSize = 0; + if (puxStackBuffer != (StackType_t *)0x0) { + pxTaskBuffer->uxDummy20 = '\x02'; + *(StackType_t **)&pxTaskBuffer->pxDummy6 = puxStackBuffer; + xSize = (size_t)ptVar1; + prvInitialiseNewTask + (pxTaskCode,pcName,ulStackDepth,pvParameters,uxPriority,(TaskHandle_t *)&xSize, + (TCB_t *)pxTaskBuffer); + prvAddNewTaskToReadyList((TCB_t *)pxTaskBuffer); + } + return (TaskHandle_t)xSize; +} + + + +BaseType_t +xTaskCreate(TaskFunction_t *pxTaskCode,char *pcName,uint16_t usStackDepth,void *pvParameters, + UBaseType_t uxPriority,TaskHandle_t *pxCreatedTask) + +{ + StackType_t *pv; + TCB_t *pxNewTCB; + BaseType_t BVar1; + undefined2 in_register_00002032; + + pv = (StackType_t *)pvPortMalloc(CONCAT22(in_register_00002032,usStackDepth) << 2); + if (pv == (StackType_t *)0x0) { + BVar1 = -1; + } + else { + pxNewTCB = (TCB_t *)pvPortMalloc(0x60); + if (pxNewTCB == (TCB_t *)0x0) { + vPortFree(pv); + BVar1 = -1; + } + else { + pxNewTCB->pxStack = pv; + pxNewTCB->ucStaticallyAllocated = '\0'; + prvInitialiseNewTask + (pxTaskCode,pcName,CONCAT22(in_register_00002032,usStackDepth),pvParameters, + uxPriority,pxCreatedTask,pxNewTCB); + prvAddNewTaskToReadyList(pxNewTCB); + BVar1 = 1; + } + } + return BVar1; +} + + + +void vTaskDelete(TaskHandle_t xTaskToDelete) + +{ + UBaseType_t UVar1; + + if (xSchedulerRunning != 0) { + vTaskEnterCritical(); + } + if (xTaskToDelete == (TaskHandle_t)0x0) { + xTaskToDelete = (TaskHandle_t)pxCurrentTCB; + } + UVar1 = uxListRemove(&((TCB_t *)xTaskToDelete)->xStateListItem); + if ((UVar1 == 0) && (pxReadyTasksLists[((TCB_t *)xTaskToDelete)->uxPriority].uxNumberOfItems == 0) + ) { + uxTopReadyPriority = ~(1 << (((TCB_t *)xTaskToDelete)->uxPriority & 0x1f)) & uxTopReadyPriority; + } + if ((((TCB_t *)xTaskToDelete)->xEventListItem).pvContainer != (xLIST *)0x0) { + uxListRemove(&((TCB_t *)xTaskToDelete)->xEventListItem); + } + uxTaskNumber = uxTaskNumber + 1; + if (pxCurrentTCB == (TCB_t *)xTaskToDelete) { + vListInsertEnd(&xTasksWaitingTermination,&((TCB_t *)xTaskToDelete)->xStateListItem); + uxDeletedTasksWaitingCleanUp = uxDeletedTasksWaitingCleanUp + 1; + } + else { + uxCurrentNumberOfTasks = uxCurrentNumberOfTasks - 1; + prvDeleteTCB((TCB_t *)xTaskToDelete); + if (pxDelayedTaskList->uxNumberOfItems == 0) { + xNextTaskUnblockTime = 0xffffffff; + } + else { + prvResetNextTaskUnblockTime(); + } + } + if ((xSchedulerRunning != 0) && (pxCurrentTCB->uxCriticalNesting != 0)) { + vTaskExitCritical(); + } + if ((xSchedulerRunning != 0) && (pxCurrentTCB == (TCB_t *)xTaskToDelete)) { + if (uxSchedulerSuspended == 0) { + ecall(); + } + else { + vAssertCalled(); + ecall(); + } + return; + } + return; +} + + +/* +Unable to decompile 'eTaskGetState' +Cause: Exception while decompiling 23062852: Decompiler process died + +*/ + +/* +Unable to decompile 'vTaskStartScheduler' +Cause: Exception while decompiling 23062920: Decompiler process died + +*/ + + +void vTaskSuspendAll(void) + +{ + uxSchedulerSuspended = uxSchedulerSuspended + 1; + return; +} + + + +TickType_t xTaskGetTickCount(void) + +{ + return xTickCount; +} + + + +BaseType_t xTaskGetTickCount2(TickType_t *ticks,BaseType_t *overflow) + +{ + BaseType_t BVar1; + + BVar1 = xNumOfOverflows; + *ticks = xTickCount; + *overflow = BVar1; + return 1; +} + + + +TickType_t xTaskGetTickCountFromISR(void) + +{ + return xTickCount; +} + + + +BaseType_t xTaskIncrementTick(void) + +{ + List_t *pLVar1; + List_t *pLVar2; + TickType_t TVar3; + void *pvVar4; + int iVar5; + int iVar6; + uint uVar7; + uint32_t uStack52; + uint32_t tmp; + + iVar6 = bl_sys_time_sync_state(&uStack52); + if (iVar6 != 0) { + if (uxSchedulerSuspended == 0) { + uVar7 = xTickCount + 1; + xTickCount = uVar7; + if (uVar7 == 0) { + if (pxDelayedTaskList->uxNumberOfItems != 0) { + vAssertCalled(); + } + pLVar2 = pxOverflowDelayedTaskList; + pLVar1 = pxDelayedTaskList; + pxDelayedTaskList = pxOverflowDelayedTaskList; + pxOverflowDelayedTaskList = pLVar1; + xNumOfOverflows = xNumOfOverflows + 1; + if (pLVar2->uxNumberOfItems == 0) { + xNextTaskUnblockTime = 0xffffffff; + } + else { + prvResetNextTaskUnblockTime(); + } + } + if (uVar7 < xNextTaskUnblockTime) { + iVar6 = 0; + TVar3 = xNextTaskUnblockTime; + } + else { + iVar6 = 0; + while (iVar5 = iVar6, pxDelayedTaskList->uxNumberOfItems != 0) { + while( true ) { + pvVar4 = ((pxDelayedTaskList->xListEnd).pxNext)->pvOwner; + TVar3 = *(uint *)((int)pvVar4 + 4); + if (uVar7 < *(uint *)((int)pvVar4 + 4)) goto LAB_23062b46; + uxListRemove((ListItem_t *)((int)pvVar4 + 4)); + if (*(int *)((int)pvVar4 + 0x28) != 0) { + uxListRemove((ListItem_t *)((int)pvVar4 + 0x18)); + } + uxTopReadyPriority = 1 << (*(uint *)((int)pvVar4 + 0x2c) & 0x1f) | uxTopReadyPriority; + vListInsertEnd(pxReadyTasksLists + *(uint *)((int)pvVar4 + 0x2c), + (ListItem_t *)((int)pvVar4 + 4)); + if (*(uint *)((int)pvVar4 + 0x2c) < pxCurrentTCB->uxPriority) break; + iVar6 = 1; + iVar5 = 1; + if (pxDelayedTaskList->uxNumberOfItems == 0) goto LAB_23062b2c; + } + } +LAB_23062b2c: + xNextTaskUnblockTime = 0xffffffff; + iVar6 = iVar5; + TVar3 = xNextTaskUnblockTime; + } +LAB_23062b46: + xNextTaskUnblockTime = TVar3; + if (1 < pxReadyTasksLists[pxCurrentTCB->uxPriority].uxNumberOfItems) { + iVar6 = 1; + } + } + else { + iVar6 = 0; + uxPendedTicks = uxPendedTicks + 1; + } + if (xYieldPending != 0) { + iVar6 = 1; + } + } + return iVar6; +} + + +/* +Unable to decompile 'xTaskResumeAll' +Cause: Exception while decompiling 23062b70: Decompiler process died + +*/ + + +void vTaskDelay(TickType_t xTicksToDelay) + +{ + BaseType_t BVar1; + + if (xTicksToDelay == 0) { + ecall(); + return; + } + if (uxSchedulerSuspended != 0) { + vAssertCalled(); + } + uxSchedulerSuspended = uxSchedulerSuspended + 1; + prvAddCurrentTaskToDelayedList(xTicksToDelay,0); + BVar1 = xTaskResumeAll(); + if (BVar1 == 0) { + ecall(); + } + return; +} + + + +void vTaskSwitchContext(void) + +{ + int iVar1; + StackType_t *pSVar2; + xLIST_ITEM *pxVar3; + + if (uxSchedulerSuspended == 0) { + xYieldPending = 0; + pSVar2 = pxCurrentTCB->pxStack; + if ((((*pSVar2 != 0xa5a5a5a5) || (pSVar2[1] != 0xa5a5a5a5)) || (pSVar2[2] != 0xa5a5a5a5)) || + (pSVar2[3] != 0xa5a5a5a5)) { + vApplicationStackOverflowHook((TaskHandle_t)pxCurrentTCB,pxCurrentTCB->pcTaskName); + } + iVar1 = __clzsi2(uxTopReadyPriority); + iVar1 = 0x1f - iVar1; + if (pxReadyTasksLists[iVar1].uxNumberOfItems == 0) { + vAssertCalled(); + } + pxVar3 = (pxReadyTasksLists[iVar1].pxIndex)->pxNext; + *(xLIST_ITEM **)&pxReadyTasksLists[iVar1].pxIndex = pxVar3; + if (pxVar3 == (xLIST_ITEM *)(iVar1 * 0x14 + 0x42018540)) { + pxVar3 = pxVar3->pxNext; + *(xLIST_ITEM **)&pxReadyTasksLists[iVar1].pxIndex = pxVar3; + } + pxCurrentTCB = (TCB_t *)pxVar3->pvOwner; + return; + } + xYieldPending = 1; + return; +} + + + +void vTaskPlaceOnEventList(List_t *pxEventList,TickType_t xTicksToWait) + +{ + if (pxEventList == (List_t *)0x0) { + vAssertCalled(); + } + vListInsert(pxEventList,&pxCurrentTCB->xEventListItem); + prvAddCurrentTaskToDelayedList(xTicksToWait,1); + return; +} + + + +void vTaskPlaceOnUnorderedEventList + (List_t *pxEventList,TickType_t xItemValue,TickType_t xTicksToWait) + +{ + ListItem_t *pxNewListItem; + + if (pxEventList == (List_t *)0x0) { + vAssertCalled(); + } + if (uxSchedulerSuspended == 0) { + vAssertCalled(); + } + pxNewListItem = &pxCurrentTCB->xEventListItem; + (pxCurrentTCB->xEventListItem).xItemValue = xItemValue | 0x80000000; + vListInsertEnd(pxEventList,pxNewListItem); + prvAddCurrentTaskToDelayedList(xTicksToWait,1); + return; +} + + + +void vTaskPlaceOnEventListRestricted + (List_t *pxEventList,TickType_t xTicksToWait,BaseType_t xWaitIndefinitely) + +{ + if (pxEventList == (List_t *)0x0) { + vAssertCalled(); + } + vListInsertEnd(pxEventList,&pxCurrentTCB->xEventListItem); + if (xWaitIndefinitely != 0) { + xTicksToWait = 0xffffffff; + } + prvAddCurrentTaskToDelayedList(xTicksToWait,xWaitIndefinitely); + return; +} + + + +BaseType_t xTaskRemoveFromEventList(List_t *pxEventList) + +{ + bool bVar1; + void *pvVar2; + + pvVar2 = ((pxEventList->xListEnd).pxNext)->pvOwner; + if (pvVar2 == (void *)0x0) { + vAssertCalled(); + } + uxListRemove((ListItem_t *)((int)pvVar2 + 0x18)); + if (uxSchedulerSuspended == 0) { + uxListRemove((ListItem_t *)((int)pvVar2 + 4)); + uxTopReadyPriority = 1 << (*(uint *)((int)pvVar2 + 0x2c) & 0x1f) | uxTopReadyPriority; + vListInsertEnd(pxReadyTasksLists + *(uint *)((int)pvVar2 + 0x2c),(ListItem_t *)((int)pvVar2 + 4) + ); + } + else { + vListInsertEnd(&xPendingReadyList,(ListItem_t *)((int)pvVar2 + 0x18)); + } + bVar1 = pxCurrentTCB->uxPriority < *(uint *)((int)pvVar2 + 0x2c); + if (bVar1) { + xYieldPending = 1; + } + return (uint)bVar1; +} + + + +void vTaskRemoveFromUnorderedEventList(ListItem_t *pxEventListItem,TickType_t xItemValue) + +{ + void *pvVar1; + + if (uxSchedulerSuspended == 0) { + vAssertCalled(); + pvVar1 = pxEventListItem->pvOwner; + pxEventListItem->xItemValue = xItemValue | 0x80000000; + } + else { + pvVar1 = pxEventListItem->pvOwner; + pxEventListItem->xItemValue = xItemValue | 0x80000000; + } + if (pvVar1 == (void *)0x0) { + vAssertCalled(); + } + uxListRemove(pxEventListItem); + uxListRemove((ListItem_t *)((int)pvVar1 + 4)); + uxTopReadyPriority = 1 << (*(uint *)((int)pvVar1 + 0x2c) & 0x1f) | uxTopReadyPriority; + vListInsertEnd(pxReadyTasksLists + *(uint *)((int)pvVar1 + 0x2c),(ListItem_t *)((int)pvVar1 + 4)); + if (pxCurrentTCB->uxPriority < *(uint *)((int)pvVar1 + 0x2c)) { + xYieldPending = 1; + } + return; +} + + +/* +Unable to decompile 'vTaskSetTimeOutState' +Cause: Exception while decompiling 23062fca: Decompiler process died + +*/ + + +void vTaskInternalSetTimeOutState(TimeOut_t *pxTimeOut) + +{ + TickType_t TVar1; + + TVar1 = xTickCount; + pxTimeOut->xOverflowCount = xNumOfOverflows; + pxTimeOut->xTimeOnEntering = TVar1; + return; +} + + +/* +Unable to decompile 'xTaskCheckForTimeOut' +Cause: Exception while decompiling 23063040: Decompiler process died + +*/ + + +void vTaskMissedYield(void) + +{ + xYieldPending = 1; + return; +} + + + +void vTaskGetInfo(TaskHandle_t xTask,TaskStatus_t *pxTaskStatus,BaseType_t xGetFreeStackSpace, + eTaskState eState) + +{ + eTaskState eVar1; + undefined3 in_register_00002035; + UBaseType_t UVar2; + uint uVar3; + + if (xTask == (TaskHandle_t)0x0) { + xTask = (TaskHandle_t)pxCurrentTCB; + } + pxTaskStatus->pcTaskName = xTask->pcTaskName; + pxTaskStatus->xHandle = xTask; + pxTaskStatus->uxCurrentPriority = xTask->uxPriority; + pxTaskStatus->pxStackBase = xTask->pxStack; + pxTaskStatus->xTaskNumber = xTask->uxTCBNumber; + UVar2 = xTask->uxBasePriority; + pxTaskStatus->ulRunTimeCounter = 0; + pxTaskStatus->uxBasePriority = UVar2; + if (CONCAT31(in_register_00002035,eState) == 5) { + eVar1 = eTaskGetState(xTask); + pxTaskStatus->eCurrentState = eVar1; + } + else { + if (pxCurrentTCB == (TCB_t *)xTask) { + pxTaskStatus->eCurrentState = eRunning; + } + else { + pxTaskStatus->eCurrentState = eState; + if (CONCAT31(in_register_00002035,eState) == 3) { + uxSchedulerSuspended = uxSchedulerSuspended + 1; + if ((xTask->xEventListItem).pvContainer != (xLIST *)0x0) { + pxTaskStatus->eCurrentState = eBlocked; + } + xTaskResumeAll(); + } + } + } + if (xGetFreeStackSpace != 0) { + if (*(char *)xTask->pxStack == -0x5b) { + uVar3 = 0; + do { + uVar3 = uVar3 + 1; + } while (*(char *)((int)xTask->pxStack + uVar3) == -0x5b); + pxTaskStatus->usStackHighWaterMark = (uint16_t)(uVar3 >> 2); + } + else { + pxTaskStatus->usStackHighWaterMark = 0; + } + return; + } + pxTaskStatus->usStackHighWaterMark = 0; + return; +} + + + +UBaseType_t +prvListTasksWithinSingleList(TaskStatus_t *pxTaskStatusArray,List_t *pxList,eTaskState eState) + +{ + TaskHandle_t xTask; + xLIST_ITEM *pxVar1; + int iVar2; + TaskHandle_t ptVar3; + + pxVar1 = pxList->pxIndex->pxNext; + *(xLIST_ITEM **)&pxList->pxIndex = pxVar1; + if (pxVar1 == (xLIST_ITEM *)&pxList->xListEnd) { + pxVar1 = (pxList->xListEnd).pxNext; + *(xLIST_ITEM **)&pxList->pxIndex = pxVar1; + } + ptVar3 = (TaskHandle_t)pxVar1->pvOwner; + iVar2 = 0; + while( true ) { + pxVar1 = pxVar1->pxNext; + *(xLIST_ITEM **)&pxList->pxIndex = pxVar1; + if ((xLIST_ITEM *)&pxList->xListEnd == pxVar1) { + pxVar1 = (pxList->xListEnd).pxNext; + *(xLIST_ITEM **)&pxList->pxIndex = pxVar1; + xTask = (TaskHandle_t)pxVar1->pvOwner; + vTaskGetInfo(xTask,pxTaskStatusArray,1,eState); + } + else { + xTask = (TaskHandle_t)pxVar1->pvOwner; + vTaskGetInfo(xTask,pxTaskStatusArray,1,eState); + } + if (ptVar3 == xTask) break; + iVar2 = iVar2 + 1; + pxTaskStatusArray = pxTaskStatusArray + 1; + pxVar1 = (xLIST_ITEM *)pxList->pxIndex; + } + return iVar2 + 1; +} + + + +UBaseType_t +uxTaskGetSystemState + (TaskStatus_t *pxTaskStatusArray,UBaseType_t uxArraySize,uint32_t *pulTotalRunTime) + +{ + int iVar1; + UBaseType_t UVar2; + int iVar3; + TaskStatus_t *pxTaskStatusArray_00; + UBaseType_t UVar4; + List_t *pxList; + + uxSchedulerSuspended = uxSchedulerSuspended + 1; + UVar4 = 0; + if (uxCurrentNumberOfTasks <= uxArraySize) { + pxList = pxReadyTasksLists + 0x1f; + iVar1 = 0x20; + UVar4 = 0; + iVar3 = 0; + do { + iVar1 = iVar1 + -1; + pxTaskStatusArray_00 = (TaskStatus_t *)(&pxTaskStatusArray->xHandle + iVar3 + UVar4); + if (pxReadyTasksLists[iVar1].uxNumberOfItems != 0) { + UVar2 = prvListTasksWithinSingleList(pxTaskStatusArray_00,pxList,eReady); + UVar4 = UVar4 + UVar2; + iVar3 = UVar4 * 8; + pxTaskStatusArray_00 = pxTaskStatusArray + UVar4; + } + pxList = pxList + -1; + } while (iVar1 != 0); + if (pxDelayedTaskList->uxNumberOfItems != 0) { + UVar2 = prvListTasksWithinSingleList(pxTaskStatusArray_00,pxDelayedTaskList,eBlocked); + UVar4 = UVar4 + UVar2; + pxTaskStatusArray_00 = pxTaskStatusArray + UVar4; + } + if (pxOverflowDelayedTaskList->uxNumberOfItems != 0) { + UVar2 = prvListTasksWithinSingleList(pxTaskStatusArray_00,pxOverflowDelayedTaskList,eBlocked); + UVar4 = UVar4 + UVar2; + pxTaskStatusArray_00 = pxTaskStatusArray + UVar4; + } + if (xTasksWaitingTermination.uxNumberOfItems != 0) { + UVar2 = prvListTasksWithinSingleList(pxTaskStatusArray_00,&xTasksWaitingTermination,eDeleted); + UVar4 = UVar4 + UVar2; + pxTaskStatusArray_00 = pxTaskStatusArray + UVar4; + } + if (xSuspendedTaskList.uxNumberOfItems != 0) { + UVar2 = prvListTasksWithinSingleList(pxTaskStatusArray_00,&xSuspendedTaskList,eSuspended); + UVar4 = UVar4 + UVar2; + } + if (pulTotalRunTime != (uint32_t *)0x0) { + *pulTotalRunTime = 0; + } + } + xTaskResumeAll(); + return UVar4; +} + + + +TaskHandle_t xTaskGetCurrentTaskHandle(void) + +{ + return (TaskHandle_t)pxCurrentTCB; +} + + + +BaseType_t xTaskGetSchedulerState(void) + +{ + BaseType_t BVar1; + + BVar1 = 1; + if (xSchedulerRunning != 0) { + BVar1 = (uint)(uxSchedulerSuspended == 0) << 1; + } + return BVar1; +} + + + +BaseType_t xTaskPriorityInherit(TaskHandle_t pxMutexHolder) + +{ + UBaseType_t UVar1; + uint uVar2; + + if (pxMutexHolder == (TaskHandle_t)0x0) { + return 0; + } + uVar2 = pxMutexHolder->uxPriority; + if (uVar2 < pxCurrentTCB->uxPriority) { + if (-1 < (int)(pxMutexHolder->xEventListItem).xItemValue) { + (pxMutexHolder->xEventListItem).xItemValue = 0x20 - pxCurrentTCB->uxPriority; + } + if ((List_t *)(pxMutexHolder->xStateListItem).pvContainer != pxReadyTasksLists + uVar2) { + pxMutexHolder->uxPriority = pxCurrentTCB->uxPriority; + return 1; + } + UVar1 = uxListRemove(&pxMutexHolder->xStateListItem); + if ((UVar1 == 0) && (pxReadyTasksLists[pxMutexHolder->uxPriority].uxNumberOfItems == 0)) { + uxTopReadyPriority = ~(1 << (pxMutexHolder->uxPriority & 0x1f)) & uxTopReadyPriority; + } + uVar2 = pxCurrentTCB->uxPriority; + uxTopReadyPriority = 1 << (uVar2 & 0x1f) | uxTopReadyPriority; + pxMutexHolder->uxPriority = uVar2; + vListInsertEnd(pxReadyTasksLists + uVar2,&pxMutexHolder->xStateListItem); + uVar2 = 1; + } + else { + uVar2 = (uint)(pxMutexHolder->uxBasePriority < pxCurrentTCB->uxPriority); + } + return uVar2; +} + + + +BaseType_t xTaskPriorityDisinherit(TaskHandle_t pxMutexHolder) + +{ + uint uVar1; + UBaseType_t UVar2; + + if (pxMutexHolder == (TaskHandle_t)0x0) { + return 0; + } + if (pxCurrentTCB != (TCB_t *)pxMutexHolder) { + vAssertCalled(); + } + if (pxMutexHolder->uxMutexesHeld == 0) { + vAssertCalled(); + UVar2 = pxMutexHolder->uxMutexesHeld - 1; + pxMutexHolder->uxMutexesHeld = UVar2; + if (pxMutexHolder->uxPriority == pxMutexHolder->uxBasePriority) { + return 0; + } + } + else { + UVar2 = pxMutexHolder->uxMutexesHeld - 1; + pxMutexHolder->uxMutexesHeld = UVar2; + if (pxMutexHolder->uxPriority == pxMutexHolder->uxBasePriority) { + return 0; + } + } + if (UVar2 != 0) { + return 0; + } + UVar2 = uxListRemove(&pxMutexHolder->xStateListItem); + if ((UVar2 == 0) && (pxReadyTasksLists[pxMutexHolder->uxPriority].uxNumberOfItems == 0)) { + uxTopReadyPriority = ~(1 << (pxMutexHolder->uxPriority & 0x1f)) & uxTopReadyPriority; + } + uVar1 = pxMutexHolder->uxBasePriority; + uxTopReadyPriority = 1 << (uVar1 & 0x1f) | uxTopReadyPriority; + pxMutexHolder->uxPriority = uVar1; + (pxMutexHolder->xEventListItem).xItemValue = 0x20 - uVar1; + vListInsertEnd(pxReadyTasksLists + uVar1,&pxMutexHolder->xStateListItem); + return 1; +} + + + +void vTaskPriorityDisinheritAfterTimeout + (TaskHandle_t pxMutexHolder,UBaseType_t uxHighestPriorityWaitingTask) + +{ + UBaseType_t UVar1; + TickType_t TVar2; + uint uVar3; + int iVar4; + uint uVar5; + + if (pxMutexHolder == (TaskHandle_t)0x0) { + return; + } + if (pxMutexHolder->uxMutexesHeld == 0) { + vAssertCalled(); + uVar5 = pxMutexHolder->uxBasePriority; + } + else { + uVar5 = pxMutexHolder->uxBasePriority; + } + if (uVar5 < uxHighestPriorityWaitingTask) { + uVar3 = pxMutexHolder->uxPriority; + if (uVar3 == uxHighestPriorityWaitingTask) { + return; + } + } + else { + uVar3 = pxMutexHolder->uxPriority; + uxHighestPriorityWaitingTask = uVar5; + if (uVar3 == uVar5) { + return; + } + } + if (pxMutexHolder->uxMutexesHeld == 1) { + if (pxCurrentTCB == (TCB_t *)pxMutexHolder) { + vAssertCalled(); + uVar3 = pxMutexHolder->uxPriority; + } + TVar2 = (pxMutexHolder->xEventListItem).xItemValue; + pxMutexHolder->uxPriority = uxHighestPriorityWaitingTask; + if (-1 < (int)TVar2) { + (pxMutexHolder->xEventListItem).xItemValue = 0x20 - uxHighestPriorityWaitingTask; + } + if ((List_t *)(pxMutexHolder->xStateListItem).pvContainer == pxReadyTasksLists + uVar3) { + UVar1 = uxListRemove(&pxMutexHolder->xStateListItem); + if (UVar1 == 0) { + uVar5 = pxMutexHolder->uxPriority; + iVar4 = uVar5 * 4; + uVar3 = 1 << (uVar5 & 0x1f); + if (pxReadyTasksLists[uVar5].uxNumberOfItems == 0) { + uxTopReadyPriority = ~uVar3 & uxTopReadyPriority; + } + } + else { + uVar5 = pxMutexHolder->uxPriority; + uVar3 = 1 << (uVar5 & 0x1f); + iVar4 = uVar5 << 2; + } + uxTopReadyPriority = uVar3 | uxTopReadyPriority; + vListInsertEnd((List_t *)(&pxReadyTasksLists[0].uxNumberOfItems + iVar4 + uVar5), + &pxMutexHolder->xStateListItem); + return; + } + } + return; +} + + + +void vTaskEnterCritical(void) + +{ + if (xSchedulerRunning == 0) { + return; + } + vTaskEnterCritical(); + return; +} + + + +void vTaskExitCritical(void) + +{ + if ((xSchedulerRunning != 0) && (pxCurrentTCB->uxCriticalNesting != 0)) { + vTaskExitCritical(); + return; + } + return; +} + + + +void vTaskList(char *pcWriteBuffer) + +{ + TaskStatus_t *pTVar1; + TaskStatus_t *pxTaskStatusArray; + UBaseType_t uxArraySize; + size_t sVar2; + char *pcVar3; + uint uVar4; + + uxArraySize = uxCurrentNumberOfTasks; + *pcWriteBuffer = '\0'; + pxTaskStatusArray = (TaskStatus_t *)pvPortMalloc(uxArraySize * 0x24); + if (pxTaskStatusArray != (TaskStatus_t *)0x0) { + uxArraySize = uxTaskGetSystemState(pxTaskStatusArray,uxArraySize,(uint32_t *)0x0); + if (uxArraySize != 0) { + pTVar1 = pxTaskStatusArray; + do { + uVar4 = 0; + if (pTVar1->eCurrentState < eInvalid) { + uVar4 = (uint)(byte)"XRBSD"[pTVar1->eCurrentState]; + } + strcpy(pcWriteBuffer,pTVar1->pcTaskName); + sVar2 = strlen(pcWriteBuffer); + if (sVar2 < 0xf) { + pcVar3 = pcWriteBuffer + sVar2; + do { + *pcVar3 = ' '; + pcVar3 = pcVar3 + 1; + } while (pcWriteBuffer + 0xf != pcVar3); + sVar2 = 0xf; + } + pcWriteBuffer = pcWriteBuffer + sVar2; + *pcWriteBuffer = '\0'; + sprintf(pcWriteBuffer,"\t%c\t%u\t%u\t%u\t%p\r\n",uVar4,pTVar1->uxCurrentPriority, + (uint)pTVar1->usStackHighWaterMark,pTVar1->xTaskNumber,pTVar1->pxStackBase); + sVar2 = strlen(pcWriteBuffer); + pTVar1 = pTVar1 + 1; + pcWriteBuffer = pcWriteBuffer + sVar2; + } while (pTVar1 != pxTaskStatusArray + uxArraySize); + } + vPortFree(pxTaskStatusArray); + return; + } + return; +} + + + +TickType_t uxTaskResetEventItemValue(void) + +{ + TickType_t TVar1; + + TVar1 = (pxCurrentTCB->xEventListItem).xItemValue; + (pxCurrentTCB->xEventListItem).xItemValue = 0x20 - pxCurrentTCB->uxPriority; + return TVar1; +} + + + +TaskHandle_t pvTaskIncrementMutexHeldCount(void) + +{ + if (pxCurrentTCB != (TCB_t *)0x0) { + pxCurrentTCB->uxMutexesHeld = pxCurrentTCB->uxMutexesHeld + 1; + } + return (TaskHandle_t)pxCurrentTCB; +} + + +/* +Unable to decompile 'ulTaskNotifyTake' +Cause: Exception while decompiling 230637ba: Decompiler process died + +*/ + +/* +Unable to decompile 'xTaskNotifyWait' +Cause: Exception while decompiling 23063860: Decompiler process died + +*/ + +/* +Unable to decompile 'xTaskGenericNotify' +Cause: +Low-level Error: Assignment to constant at r0x2306395a +*/ + + +BaseType_t +xTaskGenericNotifyFromISR + (TaskHandle_t xTaskToNotify,uint32_t ulValue,eNotifyAction eAction, + uint32_t *pulPreviousNotificationValue,BaseType_t *pxHigherPriorityTaskWoken) + +{ + uint8_t uVar1; + undefined3 in_register_00002031; + + if (xTaskToNotify == (TaskHandle_t)0x0) { + vAssertCalled(); + } + if (pulPreviousNotificationValue != (uint32_t *)0x0) { + *pulPreviousNotificationValue = xTaskToNotify->ulNotifiedValue; + } + uVar1 = xTaskToNotify->ucNotifyState; + xTaskToNotify->ucNotifyState = '\x02'; + switch(CONCAT31(in_register_00002031,eAction)) { + case 0: + break; + case 1: + xTaskToNotify->ulNotifiedValue = ulValue | xTaskToNotify->ulNotifiedValue; + break; + case 2: + xTaskToNotify->ulNotifiedValue = xTaskToNotify->ulNotifiedValue + 1; + break; + case 4: + if (uVar1 == '\x02') { + return 0; + } + case 3: + xTaskToNotify->ulNotifiedValue = ulValue; + break; + default: + if (xTaskToNotify->ulNotifiedValue != 0xffffffff) { + vAssertCalled(); + } + } + if (uVar1 == '\x01') { + if ((xTaskToNotify->xEventListItem).pvContainer != (xLIST *)0x0) { + vAssertCalled(); + } + if (uxSchedulerSuspended == 0) { + uxListRemove(&xTaskToNotify->xStateListItem); + uxTopReadyPriority = 1 << (xTaskToNotify->uxPriority & 0x1f) | uxTopReadyPriority; + vListInsertEnd(pxReadyTasksLists + xTaskToNotify->uxPriority,&xTaskToNotify->xStateListItem); + } + else { + vListInsertEnd(&xPendingReadyList,&xTaskToNotify->xEventListItem); + } + if (pxCurrentTCB->uxPriority < xTaskToNotify->uxPriority) { + if (pxHigherPriorityTaskWoken != (BaseType_t *)0x0) { + *pxHigherPriorityTaskWoken = 1; + } + xYieldPending = 1; + } + } + return 1; +} + + + +void vTaskNotifyGiveFromISR(TaskHandle_t xTaskToNotify,BaseType_t *pxHigherPriorityTaskWoken) + +{ + uint8_t uVar1; + + if (xTaskToNotify == (TaskHandle_t)0x0) { + vAssertCalled(); + } + uVar1 = xTaskToNotify->ucNotifyState; + xTaskToNotify->ucNotifyState = '\x02'; + xTaskToNotify->ulNotifiedValue = xTaskToNotify->ulNotifiedValue + 1; + if (uVar1 == '\x01') { + if ((xTaskToNotify->xEventListItem).pvContainer != (xLIST *)0x0) { + vAssertCalled(); + } + if (uxSchedulerSuspended == 0) { + uxListRemove(&xTaskToNotify->xStateListItem); + uxTopReadyPriority = 1 << (xTaskToNotify->uxPriority & 0x1f) | uxTopReadyPriority; + vListInsertEnd(pxReadyTasksLists + xTaskToNotify->uxPriority,&xTaskToNotify->xStateListItem); + } + else { + vListInsertEnd(&xPendingReadyList,&xTaskToNotify->xEventListItem); + } + if (pxCurrentTCB->uxPriority < xTaskToNotify->uxPriority) { + if (pxHigherPriorityTaskWoken != (BaseType_t *)0x0) { + *pxHigherPriorityTaskWoken = 1; + } + xYieldPending = 1; + return; + } + } + return; +} + + + +BaseType_t xTaskNotifyStateClear(TaskHandle_t xTask) + +{ + bool bVar1; + + if (xTask == (TaskHandle_t)0x0) { + xTask = (TaskHandle_t)pxCurrentTCB; + } + if (xSchedulerRunning != 0) { + vTaskEnterCritical(); + } + bVar1 = ((TCB_t *)xTask)->ucNotifyState == '\x02'; + if (bVar1) { + ((TCB_t *)xTask)->ucNotifyState = '\0'; + } + if ((xSchedulerRunning != 0) && (pxCurrentTCB->uxCriticalNesting != 0)) { + vTaskExitCritical(); + } + return (uint)bVar1; +} + + + +void prvCheckForValidListAndQueue(void) + +{ + uint8_t ucStaticTimerQueueStorage [64]; + StaticQueue_t xStaticTimerQueue; + + vTaskEnterCritical(); + if (xTimerQueue == (QueueHandle_t)0x0) { + vListInitialise(&xActiveTimerList1); + vListInitialise(&xActiveTimerList2); + pxCurrentTimerList = &xActiveTimerList1; + pxOverflowTimerList = &xActiveTimerList2; + xTimerQueue = xQueueGenericCreateStatic + (4,0x10,ucStaticTimerQueueStorage,&xStaticTimerQueue,'\0'); + if (xTimerQueue != (QueueHandle_t)0x0) { + vQueueAddToRegistry(xTimerQueue,"TmrQ"); + } + } + vTaskExitCritical(); + return; +} + + + +BaseType_t +prvInsertTimerInActiveList + (Timer_t *pxTimer,TickType_t xNextExpiryTime,TickType_t xTimeNow,TickType_t xCommandTime) + +{ + (pxTimer->xTimerListItem).xItemValue = xNextExpiryTime; + *(Timer_t **)&(pxTimer->xTimerListItem).pvOwner = pxTimer; + if (xTimeNow < xNextExpiryTime) { + if ((xCommandTime <= xTimeNow) || (xNextExpiryTime < xCommandTime)) { + vListInsert(pxCurrentTimerList,&pxTimer->xTimerListItem); + return 0; + } + } + else { + if (xTimeNow - xCommandTime < pxTimer->xTimerPeriodInTicks) { + vListInsert(pxOverflowTimerList,&pxTimer->xTimerListItem); + return 0; + } + } + return 1; +} + + + +BaseType_t xTimerCreateTimerTask(void) + +{ + StaticTask_t *pSStack28; + StaticTask_t *pxTimerTaskTCBBuffer; + StackType_t *pxTimerTaskStackBuffer; + uint32_t ulTimerTaskStackSize; + + prvCheckForValidListAndQueue(); + if (xTimerQueue != (QueueHandle_t)0x0) { + pSStack28 = (StaticTask_t *)0x0; + pxTimerTaskTCBBuffer = (StaticTask_t *)0x0; + vApplicationGetTimerTaskMemory + (&pSStack28,(StackType_t **)&pxTimerTaskTCBBuffer,(uint32_t *)&pxTimerTaskStackBuffer) + ; + xTimerTaskHandle = + xTaskCreateStatic(prvTimerTask,"Tmr Svc",(uint32_t)pxTimerTaskStackBuffer,(void *)0x0,0x1f, + (StackType_t *)pxTimerTaskTCBBuffer,pSStack28); + if (xTimerTaskHandle != (TaskHandle_t)0x0) { + return 1; + } + } + vAssertCalled(); + return 0; +} + + + +TimerHandle_t +xTimerCreate(char *pcTimerName,TickType_t xTimerPeriodInTicks,UBaseType_t uxAutoReload, + void *pvTimerID,TimerCallbackFunction_t *pxCallbackFunction) + +{ + TimerHandle_t ptVar1; + + ptVar1 = (TimerHandle_t)pvPortMalloc(0x2c); + if (ptVar1 != (TimerHandle_t)0x0) { + ptVar1->ucStatus = '\0'; + if (xTimerPeriodInTicks == 0) { + vAssertCalled(); + } + prvCheckForValidListAndQueue(); + ptVar1->pcTimerName = pcTimerName; + ptVar1->xTimerPeriodInTicks = xTimerPeriodInTicks; + ptVar1->pvTimerID = pvTimerID; + ptVar1->pxCallbackFunction = pxCallbackFunction; + vListInitialiseItem(&ptVar1->xTimerListItem); + if (uxAutoReload != 0) { + ptVar1->ucStatus = ptVar1->ucStatus | 4; + } + } + return ptVar1; +} + + + +// WARNING: Removing unreachable block (ram,0x23063e78) + +TimerHandle_t +xTimerCreateStatic(char *pcTimerName,TickType_t xTimerPeriodInTicks,UBaseType_t uxAutoReload, + void *pvTimerID,TimerCallbackFunction_t *pxCallbackFunction, + StaticTimer_t *pxTimerBuffer) + +{ + size_t xSize; + + if (pxTimerBuffer == (StaticTimer_t *)0x0) { + vAssertCalled(0x2c); + } + else { + pxTimerBuffer->ucDummy8 = '\x02'; + if (xTimerPeriodInTicks == 0) { + vAssertCalled(); + } + prvCheckForValidListAndQueue(); + *(char **)&pxTimerBuffer->pvDummy1 = pcTimerName; + pxTimerBuffer->xDummy3 = xTimerPeriodInTicks; + pxTimerBuffer->pvDummy5 = pvTimerID; + *(TimerCallbackFunction_t **)&pxTimerBuffer->pvDummy6 = pxCallbackFunction; + vListInitialiseItem((ListItem_t *)&pxTimerBuffer->xDummy2); + if (uxAutoReload != 0) { + pxTimerBuffer->ucDummy8 = pxTimerBuffer->ucDummy8 | 4; + } + } + return (TimerHandle_t)pxTimerBuffer; +} + + + +// WARNING: Could not reconcile some variable overlaps + +BaseType_t +xTimerGenericCommand + (TimerHandle_t xTimer,BaseType_t xCommandID,TickType_t xOptionalValue, + BaseType_t *pxHigherPriorityTaskWoken,TickType_t xTicksToWait) + +{ + BaseType_t BVar1; + BaseType_t BStack48; + DaemonTaskMessage_t xMessage; + + if (xTimer == (TimerHandle_t)0x0) { + vAssertCalled(); + } + BVar1 = 0; + if (xTimerQueue != (QueueHandle_t)0x0) { + BStack48 = xCommandID; + xMessage.xMessageID = xOptionalValue; + xMessage.u._0_4_ = xTimer; + if (5 < xCommandID) { + BVar1 = xQueueGenericSendFromISR(xTimerQueue,&BStack48,pxHigherPriorityTaskWoken,0); + return BVar1; + } + BVar1 = xTaskGetSchedulerState(); + if (BVar1 == 2) { + BVar1 = xQueueGenericSend(xTimerQueue,&BStack48,xTicksToWait,0); + return BVar1; + } + BVar1 = xQueueGenericSend(xTimerQueue,&BStack48,0,0); + } + return BVar1; +} + + + +void prvSwitchTimerLists(void) + +{ + List_t *pxList; + TimerHandle_t xTimer; + BaseType_t BVar1; + xLIST_ITEM *pxVar2; + uint uVar3; + uint xOptionalValue; + + while (pxList = pxCurrentTimerList, pxCurrentTimerList->uxNumberOfItems != 0) { + pxVar2 = (pxCurrentTimerList->xListEnd).pxNext; + xTimer = (TimerHandle_t)pxVar2->pvOwner; + xOptionalValue = pxVar2->xItemValue; + uxListRemove(&xTimer->xTimerListItem); + (*xTimer->pxCallbackFunction)(xTimer); + pxList = pxCurrentTimerList; + if ((xTimer->ucStatus & 4) != 0) { + uVar3 = xTimer->xTimerPeriodInTicks + xOptionalValue; + if (xOptionalValue < uVar3) { + (xTimer->xTimerListItem).xItemValue = uVar3; + *(TimerHandle_t *)&(xTimer->xTimerListItem).pvOwner = xTimer; + vListInsert(pxList,&xTimer->xTimerListItem); + } + else { + BVar1 = xTimerGenericCommand(xTimer,0,xOptionalValue,(BaseType_t *)0x0,0); + if (BVar1 == 0) { + vAssertCalled(); + } + } + } + } + pxCurrentTimerList = pxOverflowTimerList; + pxOverflowTimerList = pxList; + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void prvTimerTask(void *pvParameters) + +{ + uint xTimeNow; + BaseType_t BVar1; + TickType_t xTimeNow_00; + TickType_t TVar2; + uint xWaitIndefinitely; + UBaseType_t xCommandTime; + Timer_t *pxTimer; + uint uStack64; + DaemonTaskMessage_t xMessage; + + do { + xCommandTime = pxCurrentTimerList->uxNumberOfItems; + if (xCommandTime == 0) { + vTaskSuspendAll(pvParameters); + xTimeNow = xTaskGetTickCount(); + if (xTimeNow < xLastTime_2297) goto LAB_23064160; + xWaitIndefinitely = (uint)(pxOverflowTimerList->uxNumberOfItems == 0); +LAB_2306405a: + xLastTime_2297 = xTimeNow; + vQueueWaitForMessageRestricted(xTimerQueue,xCommandTime - xTimeNow,xWaitIndefinitely); + BVar1 = xTaskResumeAll(); + if (BVar1 == 0) { + ecall(); + } + } + else { + xCommandTime = ((pxCurrentTimerList->xListEnd).pxNext)->xItemValue; + vTaskSuspendAll(pvParameters); + xTimeNow = xTaskGetTickCount(); + if (xTimeNow < xLastTime_2297) { +LAB_23064160: + prvSwitchTimerLists(); + xLastTime_2297 = xTimeNow; + xTaskResumeAll(); + } + else { + xWaitIndefinitely = 0; + if (xTimeNow < xCommandTime) goto LAB_2306405a; + xLastTime_2297 = xTimeNow; + xTaskResumeAll(); + pxTimer = (Timer_t *)((pxCurrentTimerList->xListEnd).pxNext)->pvOwner; + uxListRemove(&pxTimer->xTimerListItem); + if ((pxTimer->ucStatus & 4) == 0) { + pxTimer->ucStatus = pxTimer->ucStatus & 0xfe; + } + else { + BVar1 = prvInsertTimerInActiveList + (pxTimer,pxTimer->xTimerPeriodInTicks + xCommandTime,xTimeNow, + xCommandTime); + if ((BVar1 != 0) && + (BVar1 = xTimerGenericCommand + ((TimerHandle_t)pxTimer,0,xCommandTime,(BaseType_t *)0x0,0), + BVar1 == 0)) { + vAssertCalled(); + } + } + (*pxTimer->pxCallbackFunction)((TimerHandle_t)pxTimer); + } + } + while (pvParameters = (void *)xQueueReceive(xTimerQueue,&uStack64,0), + pvParameters != (void *)0x0) { + if ((-1 < (int)uStack64) || + ((*(code *)xMessage.xMessageID)((Timer_t *)xMessage.u,xMessage.u._4_4_,xMessage.xMessageID) + , -1 < (int)uStack64)) { + pxTimer = (Timer_t *)xMessage.u; + if ((((Timer_t *)xMessage.u)->xTimerListItem).pvContainer != (xLIST *)0x0) { + uxListRemove(&((Timer_t *)xMessage.u)->xTimerListItem); + } + xTimeNow_00 = xTaskGetTickCount(); + if (xTimeNow_00 < xLastTime_2297) { + prvSwitchTimerLists(); + } + xLastTime_2297 = xTimeNow_00; + switch(uStack64) { + case 0: + case 1: + case 2: + case 6: + case 7: + pxTimer->ucStatus = pxTimer->ucStatus | 1; + BVar1 = prvInsertTimerInActiveList + (pxTimer,pxTimer->xTimerPeriodInTicks + xMessage.xMessageID,xTimeNow_00, + xMessage.xMessageID); + if (((BVar1 != 0) && + ((*pxTimer->pxCallbackFunction)((TimerHandle_t)pxTimer), (pxTimer->ucStatus & 4) != 0) + ) && (BVar1 = xTimerGenericCommand + ((TimerHandle_t)pxTimer,0, + xMessage.xMessageID + pxTimer->xTimerPeriodInTicks, + (BaseType_t *)0x0,0), BVar1 == 0)) { + vAssertCalled(); + } + break; + case 3: + case 8: + pxTimer->ucStatus = pxTimer->ucStatus & 0xfe; + break; + case 4: + case 9: + pxTimer->ucStatus = pxTimer->ucStatus | 1; + pxTimer->xTimerPeriodInTicks = xMessage.xMessageID; + TVar2 = xMessage.xMessageID; + if (xMessage.xMessageID == 0) { + vAssertCalled(); + TVar2 = pxTimer->xTimerPeriodInTicks; + } + prvInsertTimerInActiveList(pxTimer,TVar2 + xTimeNow_00,xTimeNow_00,xTimeNow_00); + break; + case 5: + if ((pxTimer->ucStatus & 2) == 0) { + vPortFree(pxTimer); + } + else { + pxTimer->ucStatus = pxTimer->ucStatus & 0xfe; + } + } + } + } + } while( true ); +} + + + +void * pvTimerGetTimerID(TimerHandle_t xTimer) + +{ + void *pvVar1; + + if (xTimer == (TimerHandle_t)0x0) { + vAssertCalled(); + } + vTaskEnterCritical(); + pvVar1 = xTimer->pvTimerID; + vTaskExitCritical(); + return pvVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void vPortSetupTimerInterrupt(void) + +{ + _DAT_02004000 = _DAT_0200bff8 + 10000; + _DAT_02004004 = (uint)(_DAT_0200bff8 + 10000 < _DAT_0200bff8) + _DAT_0200bffc; + ullNextTime._0_4_ = _DAT_0200bff8 + 20000; + ullNextTime._4_4_ = _DAT_0200bffc + (uint)(_DAT_0200bff8 + 20000 < _DAT_0200bff8); + return; +} + + +/* +Unable to decompile 'xPortStartScheduler' +Cause: Exception while decompiling 23064250: Decompiler process died + +*/ + +/* +Unable to decompile 'xPortStartFirstTask' +Cause: Exception while decompiling 23064600: Decompiler process died + +*/ + + +// WARNING: Removing unreachable block (ram,0x23064700) + +void pxPortInitialiseStack(int param_1,undefined4 param_2,undefined4 param_3) + +{ + int iVar1; + undefined4 *puVar2; + uint in_mstatus; + + *(uint *)(param_1 + -4) = in_mstatus & 0xfffffff7 | 0x1880; + *(undefined4 *)(param_1 + -0x5c) = param_3; + puVar2 = (undefined4 *)(param_1 + -0x74); + *puVar2 = 0; + iVar1 = 0x22; + while (iVar1 != 0) { + puVar2 = puVar2 + -1; + *puVar2 = 0; + iVar1 = iVar1 + -1; + } + puVar2[-1] = param_2; + return; +} + + + +void prvInsertBlockIntoFreeList(BlockLink_t *pxBlockToInsert) + +{ + size_t sVar1; + BlockLink_t *pBVar2; + BlockLink_t *pBVar3; + + pBVar3 = &xStart; + do { + pBVar2 = pBVar3; + pBVar3 = (BlockLink_t *)pBVar2->pxNextFreeBlock; + } while (pBVar3 < pxBlockToInsert); + sVar1 = pxBlockToInsert->xBlockSize; + if (pxBlockToInsert == (BlockLink_t *)(pBVar2->xBlockSize + (int)&pBVar2->pxNextFreeBlock)) { + sVar1 = pBVar2->xBlockSize + sVar1; + pBVar2->xBlockSize = sVar1; + pxBlockToInsert = pBVar2; + } + if ((pBVar3 == (BlockLink_t *)(sVar1 + (int)&pxBlockToInsert->pxNextFreeBlock)) && + (pBVar3 != pxEnd)) { + pxBlockToInsert->xBlockSize = sVar1 + pBVar3->xBlockSize; + pxBlockToInsert->pxNextFreeBlock = pBVar2->pxNextFreeBlock->pxNextFreeBlock; + } + else { + *(BlockLink_t **)&pxBlockToInsert->pxNextFreeBlock = pBVar3; + } + if (pxBlockToInsert != pBVar2) { + *(BlockLink_t **)&pBVar2->pxNextFreeBlock = pxBlockToInsert; + } + return; +} + + + +void * pvPortMalloc(size_t xWantedSize) + +{ + size_t sVar1; + size_t sVar2; + BlockLink_t *pBVar3; + A_BLOCK_LINK *pAVar4; + BlockLink_t *pxBlockToInsert; + uint uVar5; + uint uVar6; + + if (pxEnd == (BlockLink_t *)0x0) { + vAssertCalled(); + } + vTaskSuspendAll(); + sVar2 = xFreeBytesRemaining; + sVar1 = xBlockAllocatedBit; + if (((xBlockAllocatedBit & xWantedSize) == 0) && (xWantedSize != 0)) { + uVar6 = xWantedSize + 8; + if ((uVar6 & 7) != 0) { + uVar6 = (uVar6 & 0xfffffff8) + 8; + } + if ((uVar6 != 0) && (uVar6 <= xFreeBytesRemaining)) { + pAVar4 = xStart.pxNextFreeBlock; + pBVar3 = &xStart; + do { + pxBlockToInsert = pBVar3; + pBVar3 = (BlockLink_t *)pAVar4; + if (uVar6 <= pBVar3->xBlockSize) break; + pAVar4 = pBVar3->pxNextFreeBlock; + } while (pBVar3->pxNextFreeBlock != (A_BLOCK_LINK *)0x0); + if (pxEnd != pBVar3) { + pAVar4 = pxBlockToInsert->pxNextFreeBlock; + pxBlockToInsert->pxNextFreeBlock = pBVar3->pxNextFreeBlock; + uVar5 = pBVar3->xBlockSize; + pAVar4 = pAVar4 + 1; + if (0x10 < uVar5 - uVar6) { + pxBlockToInsert = (BlockLink_t *)((int)&pBVar3->pxNextFreeBlock + uVar6); + pxBlockToInsert->xBlockSize = uVar5 - uVar6; + pBVar3->xBlockSize = uVar6; + prvInsertBlockIntoFreeList(pxBlockToInsert); + uVar5 = pBVar3->xBlockSize; + } + xFreeBytesRemaining = sVar2 - uVar5; + if (xFreeBytesRemaining < xMinimumEverFreeBytesRemaining) { + xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; + } + pBVar3->xBlockSize = sVar1 | uVar5; + pBVar3->pxNextFreeBlock = (A_BLOCK_LINK *)0x0; + xTaskResumeAll(); + if (pAVar4 != (A_BLOCK_LINK *)0x0) { + return pAVar4; + } + goto LAB_230648be; + } + } + } + xTaskResumeAll(); +LAB_230648be: + vApplicationMallocFailedHook(); + return (void *)0x0; +} + + + +void vPortFree(void *pv) + +{ + uint uVar1; + + if (pv == (void *)0x0) { + return; + } + uVar1 = *(uint *)((int)pv + -4); + if ((uVar1 & xBlockAllocatedBit) == 0) { + vAssertCalled(); + if (*(int *)((int)pv + -8) == 0) { + uVar1 = *(uint *)((int)pv + -4); + if ((uVar1 & xBlockAllocatedBit) == 0) { + return; + } + goto LAB_230649ce; + } + } + else { + if (*(int *)((int)pv + -8) == 0) goto LAB_230649ce; + } + vAssertCalled(); + uVar1 = *(uint *)((int)pv + -4); + if (((uVar1 & xBlockAllocatedBit) == 0) || (*(int *)((int)pv + -8) != 0)) { + return; + } +LAB_230649ce: + *(uint *)((int)pv + -4) = ~xBlockAllocatedBit & uVar1; + vTaskSuspendAll(); + xFreeBytesRemaining = *(int *)((int)pv + -4) + xFreeBytesRemaining; + prvInsertBlockIntoFreeList((BlockLink_t *)((int)pv + -8)); + xTaskResumeAll(); + return; +} + + + +size_t xPortGetFreeHeapSize(void) + +{ + return xFreeBytesRemaining; +} + + + +void vPortDefineHeapRegions(HeapRegion_t *pxHeapRegions) + +{ + size_t sVar1; + BlockLink_t *pBVar2; + BlockLink_t *pBVar3; + BlockLink_t *pBVar4; + A_BLOCK_LINK *pAVar5; + int iVar6; + size_t sVar7; + + if (pxEnd == (BlockLink_t *)0x0) { + sVar1 = pxHeapRegions->xSizeInBytes; + pBVar4 = pxEnd; + } + else { + vAssertCalled(); + sVar1 = pxHeapRegions->xSizeInBytes; + pBVar4 = pxEnd; + } + pxEnd = pBVar4; + if (sVar1 == 0) { + xMinimumEverFreeBytesRemaining = 0; + } + else { + iVar6 = 0; + sVar7 = 0; + do { + pBVar3 = (BlockLink_t *)pxHeapRegions->pucStartAddress; + pBVar2 = pBVar3; + if (((uint)pBVar3 & 7) != 0) { + pBVar2 = (BlockLink_t *)((int)&pBVar3->xBlockSize + 3U & 0xfffffff8); + sVar1 = (int)pBVar3 + (sVar1 - (int)pBVar2); + } + if (iVar6 == 0) { + xStart.xBlockSize = 0; + pBVar3 = pBVar4; + xStart.pxNextFreeBlock = (A_BLOCK_LINK *)pBVar2; + } + else { + if (pBVar4 == (BlockLink_t *)0x0) { + vAssertCalled(); + pBVar4 = pxEnd; + } + pBVar3 = pBVar4; + if (pBVar2 <= pBVar4) { + vAssertCalled(); + pBVar3 = pxEnd; + } + } + pBVar4 = (BlockLink_t *)((int)&pBVar2[-1].pxNextFreeBlock + sVar1 & 0xfffffff8); + ((A_BLOCK_LINK *)pBVar4)->xBlockSize = 0; + ((A_BLOCK_LINK *)pBVar4)->pxNextFreeBlock = (A_BLOCK_LINK *)0x0; + pAVar5 = (A_BLOCK_LINK *)((int)pBVar4 - (int)pBVar2); + pxEnd = pBVar4; + *(A_BLOCK_LINK **)&pBVar2->xBlockSize = pAVar5; + *(BlockLink_t **)&pBVar2->pxNextFreeBlock = pBVar4; + if (pBVar3 != (BlockLink_t *)0x0) { + *(BlockLink_t **)&pBVar3->pxNextFreeBlock = pBVar2; + pAVar5 = (A_BLOCK_LINK *)pBVar2->xBlockSize; + } + sVar1 = pxHeapRegions[1].xSizeInBytes; + sVar7 = (int)&pAVar5->pxNextFreeBlock + sVar7; + iVar6 = iVar6 + 1; + pxHeapRegions = pxHeapRegions + 1; + } while (sVar1 != 0); + xMinimumEverFreeBytesRemaining = sVar7; + if (sVar7 != 0) { + xBlockAllocatedBit = 0x80000000; + xFreeBytesRemaining = sVar7; + return; + } + } + xFreeBytesRemaining = xMinimumEverFreeBytesRemaining; + vAssertCalled(); + xBlockAllocatedBit = 0x80000000; + return; +} + + + +void uart_generic_notify_handler(uint8_t id) + +{ + uint uVar1; + uint uVar2; + undefined3 in_register_00002029; + int iVar3; + uint32_t uVar4; + + iVar3 = CONCAT31(in_register_00002029,id); + uVar4 = uartAddr[iVar3]; + uVar2 = *(uint *)(uVar4 + 0x20); + uVar1 = *(uint *)(uVar4 + 0x24); + if (((uVar2 & 1) != 0) && ((uVar1 & 1) == 0)) { + *(undefined4 *)(uVar4 + 0x28) = 1; + } + if (((uVar2 & 2) != 0) && ((uVar1 & 2) == 0)) { + *(undefined4 *)(uVar4 + 0x28) = 2; + if (g_uart_notify_arg[iVar3].rx_cb != (cb_uart_notify_t *)0x0) { + (*g_uart_notify_arg[iVar3].rx_cb)(g_uart_notify_arg[iVar3].rx_cb_arg); + } + } + if (((uVar2 & 4) != 0) && ((uVar1 & 4) == 0)) { + if (g_uart_notify_arg[iVar3].tx_cb != (cb_uart_notify_t *)0x0) { + (*g_uart_notify_arg[iVar3].tx_cb)(g_uart_notify_arg[iVar3].tx_cb_arg); + } + } + if (((uVar2 & 8) != 0) && ((uVar1 & 8) == 0)) { + if (g_uart_notify_arg[iVar3].rx_cb != (cb_uart_notify_t *)0x0) { + (*g_uart_notify_arg[iVar3].rx_cb)(g_uart_notify_arg[iVar3].rx_cb_arg); + } + } + if (((uVar2 & 0x10) != 0) && ((uVar1 & 0x10) == 0)) { + *(undefined4 *)(uVar4 + 0x28) = 0x10; + if (g_uart_notify_arg[iVar3].rx_cb != (cb_uart_notify_t *)0x0) { + (*g_uart_notify_arg[iVar3].rx_cb)(g_uart_notify_arg[iVar3].rx_cb_arg); + } + } + if (((uVar2 & 0x20) != 0) && ((uVar1 & 0x20) == 0)) { + *(undefined4 *)(uVar4 + 0x28) = 0x20; + } + return; +} + + + +void UART0_IRQHandler(void) + +{ + uart_generic_notify_handler('\0'); + return; +} + + + +void UART1_IRQHandler(void) + +{ + uart_generic_notify_handler('\x01'); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bl_uart_init(uint8_t id,uint8_t tx_pin,uint8_t rx_pin,uint8_t cts_pin,uint8_t rts_pin, + uint32_t baudrate) + +{ + uint8_t uart_clk_init; + GLB_UART_SIG_FUN_Type fun; + undefined3 in_register_00002029; + GLB_UART_SIG_FUN_Type fun_00; + UART_FifoCfg_Type UStack60; + UART_FifoCfg_Type fifoCfg; + GLB_GPIO_Cfg_Type cfg; + UART_CFG_Type uartCfg; + + memcpy(&cfg.drive,&DAT_230c0f04,0x10); + UStack60 = DAT_4200ee9c; + if (uart_clk_init == '\0') { + GLB_Set_UART_CLK('\x01',HBN_UART_CLK_160M,'\x03'); + uart_clk_init = '\x01'; + } + fifoCfg.rxFifoDmaThreshold = '\a'; + fifoCfg._2_2_ = 2; + cfg._0_2_ = 0x101; + fifoCfg.txFifoDmaThreshold = rx_pin; + GLB_GPIO_Init((GLB_GPIO_Cfg_Type *)&fifoCfg); + fifoCfg._2_2_ = 2; + fifoCfg.txFifoDmaThreshold = tx_pin; + GLB_GPIO_Init((GLB_GPIO_Cfg_Type *)&fifoCfg); + if (CONCAT31(in_register_00002029,id) == 0) { + fun = GLB_UART_SIG_FUN_UART0_RXD; + fun_00 = GLB_UART_SIG_FUN_UART0_TXD; + } + else { + fun = GLB_UART_SIG_FUN_UART1_RXD; + fun_00 = GLB_UART_SIG_FUN_UART1_TXD; + } + GLB_UART_Fun_Sel(tx_pin & 7,fun_00); + GLB_UART_Fun_Sel(rx_pin & 7,fun); + stack0xffffffd0 = 40000000; + UART_IntMask(id,UART_INT_ALL,MASK); + UART_Disable(id,UART_TXRX); + UART_Init(id,(UART_CFG_Type *)&cfg.drive); + UART_TxFreeRun(id,ENABLE); + UART_FifoConfig(id,&UStack60); + UART_Enable(id,UART_TXRX); + return 0; +} + + + +int bl_uart_data_send(uint8_t id,uint8_t data) + +{ + uint32_t uVar1; + uint8_t uVar2; + undefined3 in_register_00002029; + undefined3 extraout_var; + + uVar1 = uartAddr[CONCAT31(in_register_00002029,id)]; + do { + uVar2 = UART_GetTxFifoCount(id); + } while (CONCAT31(extraout_var,uVar2) == 0); + *(uint8_t *)(uVar1 + 0x88) = data; + return 0; +} + + + +int bl_uart_data_recv(uint8_t id) + +{ + uint32_t uVar1; + uint8_t uVar2; + undefined3 in_register_00002029; + undefined3 extraout_var; + uint uVar3; + + uVar1 = uartAddr[CONCAT31(in_register_00002029,id)]; + uVar2 = UART_GetRxFifoCount(id); + if (CONCAT31(extraout_var,uVar2) == 0) { + uVar3 = 0xffffffff; + } + else { + uVar3 = (uint)*(byte *)(uVar1 + 0x8c); + } + return uVar3; +} + + + +int bl_uart_int_rx_enable(uint8_t id) + +{ + UART_SetRxTimeoutValue(id,'\x18'); + UART_IntMask(id,UART_INT_RX_FIFO_REQ,UNMASK); + UART_IntMask(id,UART_INT_RX_END,UNMASK); + UART_IntMask(id,UART_INT_RTO,UNMASK); + return 0; +} + + + +int bl_uart_int_rx_disable(uint8_t id) + +{ + UART_IntMask(id,UART_INT_RX_FIFO_REQ,MASK); + UART_IntMask(id,UART_INT_RX_END,MASK); + UART_IntMask(id,UART_INT_RTO,MASK); + return 0; +} + + + +int bl_uart_int_tx_enable(uint8_t id) + +{ + UART_IntMask(id,UART_INT_TX_FIFO_REQ,UNMASK); + return 0; +} + + + +int bl_uart_int_tx_disable(uint8_t id) + +{ + UART_IntMask(id,UART_INT_TX_FIFO_REQ,MASK); + return 0; +} + + + +int bl_uart_flush(uint8_t id) + +{ + uint8_t uVar1; + undefined3 extraout_var; + + do { + uVar1 = UART_GetTxFifoCount(id); + } while (CONCAT31(extraout_var,uVar1) != 0x20); + return 0; +} + + + +void bl_uart_getdefconfig(uint8_t id,uint8_t *parity) + +{ + if (parity != (uint8_t *)0x0) { + *parity = '\0'; + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: UartCfg +// WARNING: Could not reconcile some variable overlaps + +void bl_uart_setconfig(uint8_t id,uint32_t baudrate,UART_Parity_Type parity) + +{ + undefined auStack32 [4]; + UART_CFG_Type UartCfg; + + memcpy(auStack32,&DAT_230c0f14,0x10); + UartCfg.uartClk = baudrate; + UartCfg.baudRate._2_1_ = parity; + UART_Disable(id,UART_TXRX); + UART_Init(id,(UART_CFG_Type *)auStack32); + UART_TxFreeRun(id,ENABLE); + UART_Enable(id,UART_TXRX); + return; +} + + + +void bl_uart_setbaud(uint8_t id,uint32_t baud) + +{ + bl_uart_setconfig(id,baud,UART_PARITY_NONE); + return; +} + + + +int bl_uart_int_enable(uint8_t id) + +{ + undefined3 in_register_00002029; + uint source; + + if (CONCAT31(in_register_00002029,id) == 0) { + bl_uart_int_rx_enable(id); + bl_uart_int_tx_enable('\0'); + bl_irq_register(0x2d,UART0_IRQHandler); + source = 0x2d; + } + else { + if (CONCAT31(in_register_00002029,id) != 1) { + return -1; + } + bl_uart_int_rx_enable(id); + bl_uart_int_tx_enable('\x01'); + bl_irq_register(0x2e,UART1_IRQHandler); + source = 0x2e; + } + bl_irq_enable(source); + return 0; +} + + + +int bl_uart_int_disable(uint8_t id) + +{ + undefined3 in_register_00002029; + uint source; + + if (CONCAT31(in_register_00002029,id) == 0) { + bl_uart_int_rx_disable(id); + bl_uart_int_tx_disable('\0'); + bl_irq_unregister(0x2d,UART0_IRQHandler); + source = 0x2d; + } + else { + if (CONCAT31(in_register_00002029,id) != 1) { + return -1; + } + bl_uart_int_rx_disable(id); + bl_uart_int_tx_disable('\x01'); + bl_irq_unregister(0x2e,UART1_IRQHandler); + source = 0x2e; + } + bl_irq_disable(source); + return 0; +} + + + +int bl_uart_int_rx_notify_register(uint8_t id,cb_uart_notify_t *cb,void *arg) + +{ + undefined3 in_register_00002029; + uint uVar1; + + uVar1 = CONCAT31(in_register_00002029,id); + if (uVar1 < 2) { + g_uart_notify_arg[uVar1].rx_cb = cb; + g_uart_notify_arg[uVar1].rx_cb_arg = arg; + return 0; + } + return -1; +} + + + +int bl_uart_int_tx_notify_register(uint8_t id,cb_uart_notify_t *cb,void *arg) + +{ + undefined3 in_register_00002029; + uint uVar1; + + uVar1 = CONCAT31(in_register_00002029,id); + if (uVar1 < 2) { + g_uart_notify_arg[uVar1].tx_cb = cb; + g_uart_notify_arg[uVar1].tx_cb_arg = arg; + return 0; + } + return -1; +} + + + +// WARNING: Removing unreachable block (ram,0x23064f74) + +int bl_chip_info(char *info) + +{ + char *pcVar1; + undefined *__src; + uint uVar2; + uint in_register_90000c04; + uint32_t misa; + + uVar2 = in_register_90000c04 >> 0x1e; + if (uVar2 == 2) { + memcpy(info,&DAT_230c11e8,4); + pcVar1 = info + 4; + } + else { + if (uVar2 == 3) { + memcpy(info,"RV128",5); + pcVar1 = info + 5; + } + else { + pcVar1 = info + 4; + if (uVar2 == 1) { + __src = &DAT_230c11e0; + } + else { + __src = &DAT_230c11f8; + } + memcpy(info,__src,4); + } + } + *pcVar1 = '-'; + pcVar1 = pcVar1 + 1; + uVar2 = 0; + do { + if ((1 << (uVar2 & 0x1f) & in_register_90000c04) != 0) { + *pcVar1 = (char)uVar2 + 'A'; + pcVar1 = pcVar1 + 1; + } + uVar2 = uVar2 + 1; + } while (uVar2 != 0x1a); + *pcVar1 = '\0'; + return 0; +} + + + +int bl_chip_banner(char **banner) + +{ + *banner = + "██████╗ ██╗ ██████╗ ██████╗ ██████╗\n\r██╔══██╗██║ ██╔════╝ ██╔═████╗╚════██╗\n\r██████╔╝██║ ███████╗ ██║██╔██║ █████╔╝\n\r██╔══██╗██║ ██╔═══██╗████╔╝██║██╔═══╝\n\r██████╔╝███████╗╚██████╔╝╚██████╔╝███████╗\n\r╚═════╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝\n\r" + ; + return 0; +} + + + +int bl_chip_memory_ram(int *num,uint *addr,uint *size,char (*desc) [6]) + +{ + if (2 < *num) { + *num = 3; + *addr = 0x23000000; + *size = 0x400000; + strcpy((char *)desc,"flash"); + addr[1] = 0x4200c000; + size[1] = 0x34000; + strcpy((char *)(desc + 1),"tcm"); + addr[2] = 0x42040000; + size[2] = 0xa000; + strcpy((char *)(desc + 2),"wifi"); + return 0; + } + return -1; +} + + + +int bl_sys_reset_por(void) + +{ + GLB_SW_POR_Reset(); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void bl_sys_reset_system(void) + +{ + GLB_SW_System_Reset(); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +int bl_sys_isxipaddr(uint32_t addr) + +{ + return (uint)(((addr & 0xff000000) + 0xdd000000 & 0xdf000000) == 0); +} + + + +// WARNING: Removing unreachable block (ram,0x23065106) +// WARNING: Removing unreachable block (ram,0x2306510c) + +int bl_sys_em_config(void) + +{ + GLB_Set_EM_Sel(GLB_EM_8KB); + return 0; +} + + +/* +Unable to decompile 'bl_sys_early_init' +Cause: Exception while decompiling 2306511e: Decompiler process died + +*/ + + +int bl_sys_init(void) + +{ + bl_sys_em_config(); + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void bl_dma_int_process(void) + +{ + uint uVar1; + uint uVar2; + int iVar3; + uint uVar4; + uint uVar5; + uint uVar6; + uint uVar7; + int *piStack52; + dma_ctx *pstctx; + + uVar1 = _DAT_4000c00c; + uVar2 = _DAT_4000c004; + uVar5 = 0; + bl_irq_ctx_get(0x1f,&piStack52); + do { + uVar4 = 1 << (uVar5 & 0x1f); + uVar7 = uVar4 & uVar2; + uVar6 = uVar4 & uVar1; + if (uVar7 == 0) { + if (uVar6 != 0) { +LAB_23065190: + uVar2 = _DAT_4000c010 | uVar4; + _DAT_4000c010 = uVar2; + goto LAB_2306519a; + } + } + else { + uVar2 = _DAT_4000c008 | uVar4; + _DAT_4000c008 = uVar2; + if (uVar6 != 0) goto LAB_23065190; +LAB_2306519a: + iVar3 = *(int *)(*piStack52 + 4); + while (iVar3 != *piStack52) { + if (*(uint *)(iVar3 + 8) == uVar5) { + if ((*(code **)(iVar3 + 0xc) != (code *)0x0) && (uVar7 != 0)) { + (**(code **)(iVar3 + 0xc))(); + } + if ((*(code **)(iVar3 + 0x10) != (code *)0x0) && (uVar6 != 0)) { + (**(code **)(iVar3 + 0x10))(); + } + } + iVar3 = *(int *)(iVar3 + 4); + } + } + uVar5 = uVar5 + 1; + if (uVar5 == 4) { + return; + } + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int bl_dma_int_clear(int ch) + +{ + uint uVar1; + + uVar1 = 1 << (ch & 0x1fU); + if ((_DAT_4000c004 & uVar1 & 0xff) != 0) { + _DAT_4000c008 = _DAT_4000c008 | uVar1; + } + if ((_DAT_4000c00c & uVar1 & 0xff) != 0) { + _DAT_4000c010 = uVar1 | _DAT_4000c010; + } + return 0; +} + + + +void bl_dma_IRQHandler(void) + +{ + utils_list_hdr *puVar1; + TickType_t TVar2; + + bl_dma_int_clear(0); + puVar1 = utils_list_pop_front(&dma_copy_list); + if (puVar1 == (utils_list_hdr *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_dma < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [INT] ASSERT here for empty chain\r\n",TVar2,&DAT_230bd32c, + &UNK_230c120c,0x9d); + } + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + if (puVar1[1].next != (utils_list_hdr *)0x0) { + (*(code *)puVar1[1].next)(puVar1[2].next); + } + if (dma_copy_list.first != (utils_list_hdr *)0x0) { + DMA_LLI_Update('\0',(uint32_t)(dma_copy_list.first + 3)); + DMA_Channel_Enable('\0'); + return; + } + return; +} + + + +int bl_dma_irq_register(int channel,void *tc_handler,void *interr_handler,void *ctx) + +{ + int iVar1; + TickType_t TVar2; + int *piVar3; + int **ppiVar4; + int *piStack36; + dma_ctx *pstctx; + + if (((uint)channel < 5) && (tc_handler != (void *)0x0)) { + bl_irq_ctx_get(0x1f,&piStack36); + iVar1 = *(int *)(*piStack36 + 4); + while (*piStack36 != iVar1) { + if (channel == *(int *)(iVar1 + 8)) { + if (BLOG_LEVEL_WARN < _fsymc_level_hal_drv) { + return -1; + } + if (BLOG_LEVEL_WARN < _fsymf_level_hal_drvbl_dma) { + return -1; + } + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] channel %d already register \r\n",TVar2,&DAT_230c03d4, + &UNK_230c120c,0x124,*(undefined4 *)(iVar1 + 8)); + return -1; + } + iVar1 = *(int *)(iVar1 + 4); + } + piVar3 = (int *)pvPortMalloc(0x18); + if (((piVar3 == (int *)0x0) && (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvbl_dma < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] malloc dma node failed. \r\n",TVar2,&DAT_230a9dd8,&UNK_230c120c, + 0x12a); + } + piVar3[2] = channel; + *(void **)(piVar3 + 3) = tc_handler; + *(void **)(piVar3 + 4) = interr_handler; + *(void **)(piVar3 + 5) = ctx; + iVar1 = *piStack36; + ppiVar4 = *(int ***)(iVar1 + 4); + *piVar3 = iVar1; + *(int ***)(piVar3 + 1) = ppiVar4; + *(int **)(iVar1 + 4) = piVar3; + *ppiVar4 = piVar3; + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvbl_dma < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] not valid para \r\n",TVar2,&DAT_230a9dd8,&UNK_230c120c,0x11c); + } + } + return -1; +} + + + +void bl_dma_init(void) + +{ + void **ctx; + char *format; + void *pvVar1; + undefined4 uVar2; + undefined2 uStack20; + DMA_Periph_Req_Type DStack18; + DMA_LLI_Cfg_Type lliCfg; + + uStack20 = 0; + DStack18 = DMA_REQ_UART0_RX; + utils_list_init(&dma_copy_list); + ctx = (void **)pvPortMalloc(4); + if (ctx == (void **)0x0) { + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvbl_dma) { + return; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar2 = 0x180; + format = "[%10u][%s: %s:%4d] malloc dma ctx failed \r\n"; + } + else { + pvVar1 = pvPortMalloc(8); + *ctx = pvVar1; + if (pvVar1 != (void *)0x0) { + *(void **)((int)pvVar1 + 4) = pvVar1; + *(void **)pvVar1 = pvVar1; + DMA_Enable(); + DMA_IntMask('\0',DMA_INT_ALL,MASK); + DMA_IntMask('\0',DMA_INT_TCOMPLETED,UNMASK); + DMA_IntMask('\0',DMA_INT_ERR,UNMASK); + DMA_LLI_Init('\0',(DMA_LLI_Cfg_Type *)&uStack20); + bl_irq_register_with_ctx(0x1f,bl_dma_int_process,ctx); + bl_dma_irq_register(0,bl_dma_IRQHandler,(void *)0x0,(void *)0x0); + bl_irq_enable(0x1f); + return; + } + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvbl_dma) { + return; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar2 = 0x187; + format = "[%10u][%s: %s:%4d] malloc dma pstqueue failed \r\n"; + } + bl_printk(format,&DAT_230a9dd8,&UNK_230c120c,uVar2); + return; +} + + + +void _irq_num_check(int irqnum) + +{ + TickType_t TVar1; + + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && (_fsymf_level_hal_drvbl_irq < BLOG_LEVEL_ASSERT) + ) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] illegal irqnum %d\r\n",TVar1,&DAT_230a9dd8,"bl_irq.c",0x70,irqnum) + ; + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void bl_irq_enable(uint source) + +{ + (&DAT_02800400)[source] = 1; + return; +} + + + +void bl_irq_disable(uint source) + +{ + (&DAT_02800400)[source] = 0; + return; +} + + + +void bl_irq_pending_clear(uint source) + +{ + (&DAT_02800000)[source] = 0; + return; +} + + + +void bl_irq_register_with_ctx(int irqnum,void *handler,void *ctx) + +{ + TickType_t TVar1; + + if (0x4f < (uint)irqnum) { + _irq_num_check(irqnum); + } + if (handler_list[irqnum] == (anon_subr_void *)0x0) goto LAB_23065664; + if (handler_list[irqnum] == (anon_subr_void *)handler) { +LAB_230656d6: + handler_list[irqnum] = handler; + if ((anon_subr_void *)ctx == (anon_subr_void *)0x0) { + handler_list[irqnum + 0x50] = (anon_subr_void *)0x0; + } + else { + handler_list[irqnum + 0x50] = ctx; + } + } + else { + if (_fsymc_level_hal_drv < BLOG_LEVEL_ERROR) { + if (_fsymf_level_hal_drvbl_irq < BLOG_LEVEL_ERROR) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] IRQ %d already registered with %p \r\n",TVar1,&DAT_230c03d4, + "bl_irq.c",0x7e,irqnum,handler_list[irqnum]); + goto LAB_23065664; + } + if ((anon_subr_void *)handler != (anon_subr_void *)0x0) goto LAB_230656d6; + } + else { +LAB_23065664: + if ((anon_subr_void *)handler != (anon_subr_void *)0x0) goto LAB_230656d6; + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return; + } + } + if (_fsymf_level_hal_drvbl_irq < BLOG_LEVEL_ASSERT) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] handler is NULL pointer! \r\n",TVar1,&DAT_230a9dd8,"bl_irq.c", + 0x82); + return; + } + } + return; +} + + + +void bl_irq_ctx_get(int irqnum,void **ctx) + +{ + if (0x4f < (uint)irqnum) { + _irq_num_check(irqnum); + } + *(anon_subr_void **)ctx = handler_list[irqnum + 0x50]; + return; +} + + + +void bl_irq_register(int irqnum,void *handler) + +{ + bl_irq_register_with_ctx(irqnum,handler,(void *)0x0); + return; +} + + + +void bl_irq_unregister(int irqnum,void *handler) + +{ + TickType_t TVar1; + + if (0x4f < (uint)irqnum) { + _irq_num_check(irqnum); + } + if (((handler_list[irqnum] != (anon_subr_void *)handler) && + (_fsymc_level_hal_drv < BLOG_LEVEL_ERROR)) && (_fsymf_level_hal_drvbl_irq < BLOG_LEVEL_ERROR)) + { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] IRQ %d:%p Not match with registered %p\r\n",TVar1,&DAT_230c03d4, + "bl_irq.c",0xa8,irqnum,handler,handler_list[irqnum]); + } + handler_list[irqnum] = handler; + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void interrupt_entry(uint32_t mcause) + +{ + anon_subr_void *UNRECOVERED_JUMPTABLE_00; + uint uVar1; + + uVar1 = mcause & 0x7ffffff; + if (uVar1 < 0x50) { + UNRECOVERED_JUMPTABLE_00 = handler_list[uVar1]; + if (UNRECOVERED_JUMPTABLE_00 != (anon_subr_void *)0x0) { + if (handler_list[uVar1 + 0x50] != (anon_subr_void *)0x0) { + // WARNING: Could not recover jumptable at 0x230657fc. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE_00)(); + return; + } + // WARNING: Could not recover jumptable at 0x230657fe. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE_00)(); + return; + } + } + printf("Cannot handle mcause 0x%lx:%lu, adjust to externel(0x%lx:%lu)\r\n",uVar1,uVar1 - 0x10); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void exception_entry(uint32_t mcause,uint32_t mepc,uint32_t mtval,uintptr_t *regs) + +{ + char *s; + + if ((mcause & 0x3ff) == 4) { + misaligned_load_trap(mcause,mepc); + return; + } + if ((mcause & 0x3ff) != 6) { + puts("Exception Entry--->>>\r\n"); + printf("mcause %08lx, mepc %08lx, mtval %08lx\r\n",mcause,mepc,mtval); + printf("Exception code: %lu\r\n",mcause & 0xffff); + switch(mcause & 0xffff) { + case 0: + s = " msg: Instruction address misaligned\r\n"; + break; + case 1: + s = " msg: Instruction access fault\r\n"; + break; + case 2: + s = " msg: Illegal instruction\r\n"; + break; + case 3: + s = " msg: Breakpoint\r\n"; + break; + case 4: + s = " msg: Load address misaligned\r\n"; + break; + case 5: + s = " msg: Load access fault\r\n"; + break; + case 6: + s = " msg: Store/AMO access misaligned\r\n"; + break; + case 7: + s = " msg: Store/AMO access fault\r\n"; + break; + case 8: + s = " msg: Environment call from U-mode\r\n"; + break; + case 9: + s = " msg: Environment call from S-mode\r\n"; + break; + case 10: + case 0xe: + s = " msg: Reserved\r\n"; + break; + case 0xb: + s = " msg: Environment call from M-mode\r\n"; + break; + case 0xc: + s = " msg: Instruction page fault\r\n"; + break; + case 0xd: + s = " msg: Load page fault\r\n"; + break; + case 0xf: + s = " msg: Store/AMO page fault\r\n"; + break; + default: + s = " msg: Reserved default exception\r\n"; + } + puts(s); + backtrace_riscv(printf,regs); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + misaligned_store_trap(mcause,mepc); + return; +} + + + +void bl_irq_init(void) + +{ + undefined *puVar1; + + puts("[IRQ] Clearing and Disable all the pending IRQ...\r\n"); + puVar1 = &DAT_02800400; + do { + *puVar1 = 0; + puVar1 = puVar1 + 1; + } while (puVar1 != (undefined *)0x2800480); + puVar1 = &DAT_02800000; + do { + *puVar1 = 0; + puVar1 = puVar1 + 1; + } while (puVar1 != (undefined *)0x2800080); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void _trng_trigger(void) + +{ + if ((_DAT_40004200 & 1) == 0) { + _DAT_40004200 = _DAT_40004200 | 0x606; + _DAT_4000422c = trng_buffer[0]; + _DAT_40004230 = trng_buffer[1]; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void wait_trng4feed(void) + +{ + do { + } while ((_DAT_40004200 & 1) != 0); + _DAT_40004200 = _DAT_40004200 & 0xfffffffd | 0x200; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && (_fsymf_level_hal_drvbl_sec < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Feed random number is %08lx\r\n","DEBUG ","bl_sec.c",0x5b, + trng_buffer[0]); + } + trng_buffer[0] = _DAT_40004208; + trng_buffer[1] = _DAT_4000420c; + trng_buffer[2] = _DAT_40004210; + trng_buffer[3] = _DAT_40004214; + trng_buffer[4] = _DAT_40004218; + trng_buffer[5] = _DAT_4000421c; + trng_buffer[6] = _DAT_40004220; + trng_buffer[7] = _DAT_40004224; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_trng_IRQHandler(uint param_1,int param_2) + +{ + aos_now_ms(); + if ((param_2 < 1) && ((param_2 != 0 || (param_1 < 2000)))) { + puts("[BL] [SEC] TRNG Handler\r\n"); + } + _DAT_40004200 = _DAT_40004200 & 0xfffffffd | 0x200; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && (_fsymf_level_hal_drvbl_sec < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] random number is %08lx\r\n","DEBUG ","bl_sec.c",0xab, + trng_buffer[0]); + } + trng_buffer[0] = _DAT_40004208; + trng_buffer[1] = _DAT_4000420c; + trng_buffer[2] = _DAT_40004210; + trng_buffer[3] = _DAT_40004214; + trng_buffer[4] = _DAT_40004218; + trng_buffer[5] = _DAT_4000421c; + trng_buffer[6] = _DAT_40004220; + trng_buffer[7] = _DAT_40004224; + return; +} + + + +uint32_t bl_sec_get_random_word(void) + +{ + uint uVar1; + + uVar1 = trng_idx & 7; + if (uVar1 == 0) { + trng_idx = uVar1; + _trng_trigger(); + } + trng_idx = uVar1 + 1; + return trng_buffer[uVar1]; +} + + + +void bl_rand_stream(uint8_t *buf,int len) + +{ + size_t __n; + int iVar1; + + if (trng_idx != 0) { + _trng_trigger(); + wait_trng4feed(); + trng_idx = 0; + } + iVar1 = 0; + while (0 < len) { + if (trng_idx != 0) { + _trng_trigger(); + wait_trng4feed(); + trng_idx = 0; + } + __n = len; + if (0x20 < len) { + __n = 0x20; + } + memcpy(buf + iVar1,trng_buffer,__n); + iVar1 = iVar1 + __n; + len = len - __n; + trng_idx = 0x1f; + } + _trng_trigger(); + wait_trng4feed(); + trng_idx = 0; + return; +} + + + +int bl_rand(void) + +{ + int iVar1; + uint32_t uVar2; + + iVar1 = 0x13; + do { + uVar2 = bl_sec_get_random_word(); + iVar1 = iVar1 + -1; + if (iVar1 == 0) { + puts("[BL] [SEC] Failed after loop (17)\r\n"); + break; + } + } while (uVar2 == 0); + return uVar2 >> 1; +} + + + +int bl_sec_init(void) + +{ + g_bl_sec_sha_mutex = + (SemaphoreHandle_t)xQueueCreateMutexStatic('\x01',(StaticQueue_t *)&sha_mutex_buf); + _trng_trigger(); + wait_trng4feed(); + _trng_trigger(); + wait_trng4feed(); + bl_irq_register(0x1c,sec_trng_IRQHandler); + bl_irq_enable(0x1c); + return 0; +} + + + +int bl_sec_test(void) + +{ + int iVar1; + + bl_printk("------------------TRNG TEST---------------------------------\r\n"); + iVar1 = bl_rand(); + bl_printk("**********TRNG TEST rand[%08x]**************\r\n",iVar1); + iVar1 = bl_rand(); + bl_printk("**********TRNG TEST rand[%08x]**************\r\n",iVar1); + bl_printk("------------------------------------------------------------\r\n"); + return 0; +} + + + +// WARNING: Variable defined which should be unmapped: val + +void cmd_gpio_get(char *buf,int len,int argc,char **argv) + +{ + TickType_t TVar1; + int iVar2; + int iVar3; + undefined *puVar4; + uint8_t auStack17 [4]; + uint8_t val; + + if (argc == 2) { + iVar2 = atoi(argv[1]); + if (iVar2 < 0) { + puts("Illegal arg\r\n"); + } + else { + iVar3 = bl_gpio_input_get((uint8_t)iVar2,auStack17); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_gpio_cli < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + if (iVar3 == 0) { + if (auStack17[0] == '\0') { + puVar4 = &UNK_230c1988; + } + else { + puVar4 = &UNK_230c1980; + } + } + else { + puVar4 = &UNK_230c197c; + } + bl_printk("[%10u][%s: %s:%4d] GPIO%d val is %s\r\n",TVar1,&DAT_230bd32c,"bl_gpio_cli.c",0x72 + ,iVar2,puVar4); + } + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_gpio_cli < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Usage: %s 24\r\n get GPIO24 value\r\n",TVar1,&DAT_230bd32c, + "bl_gpio_cli.c",0x66,*argv); + } + } + return; +} + + + +void cmd_gpio_set(char *buf,int len,int argc,char **argv) + +{ + TickType_t TVar1; + int iVar2; + int iVar3; + undefined *puVar4; + + if (argc == 3) { + iVar2 = atoi(argv[1]); + iVar3 = atoi(argv[2]); + if ((-1 < iVar2) && (-1 < iVar3)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_gpio_cli < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + if (iVar3 == 0) { + puVar4 = &UNK_230c1a0c; + } + else { + puVar4 = &UNK_230c1980; + } + bl_printk("[%10u][%s: %s:%4d] GPIO%d is set to %s\r\n",TVar1,&DAT_230bd32c,"bl_gpio_cli.c", + 0x59,iVar2,puVar4); + } + bl_gpio_output_set((uint8_t)iVar2,iVar3 != 0); + return; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvbl_gpio_cli < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Illegal arg\r\n",TVar1,&DAT_230a9dd8,"bl_gpio_cli.c",0x53); + return; + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_gpio_cli < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Usage: %s 24 1\r\n set GPIO24 output to high\r\n",TVar1, + &DAT_230bd32c,"bl_gpio_cli.c",0x4d,*argv); + return; + } + } + return; +} + + + +void cmd_gpio_func(char *buf,int len,int argc,char **argv) + +{ + TickType_t TVar1; + int iVar2; + int iVar3; + int iVar4; + int iVar5; + char *pcVar6; + char *pcVar7; + + if (argc == 5) { + iVar2 = atoi(argv[1]); + iVar3 = atoi(argv[2]); + iVar4 = atoi(argv[3]); + iVar5 = atoi(argv[4]); + if ((((-1 < iVar2) && (-1 < iVar3)) && (-1 < iVar4)) && (-1 < iVar5)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_gpio_cli < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + if (iVar3 == 0) { + pcVar6 = "output"; + } + else { + pcVar6 = "input"; + } + if (iVar4 == 0) { + pcVar7 = "null"; + } + else { + pcVar7 = "Active"; + } + bl_printk("[%10u][%s: %s:%4d] GPIO%d is set %s with %s pullup %s pulldown\r\n",TVar1, + &DAT_230bd32c,"bl_gpio_cli.c",0x3e,iVar2,pcVar6,pcVar7); + } + if (iVar3 != 0) { + bl_gpio_enable_input((uint8_t)iVar2,iVar4 != 0,iVar5 != 0); + return; + } + bl_gpio_enable_output((uint8_t)iVar2,iVar4 != 0,iVar5 != 0); + return; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvbl_gpio_cli < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Illegal arg\r\n",TVar1,&DAT_230a9dd8,"bl_gpio_cli.c",0x36); + return; + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_gpio_cli < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Usage: %s 24 1 1 0\r\n set GPIO24 to input with pullup\r\n", + TVar1,&DAT_230bd32c,"bl_gpio_cli.c",0x2e,*argv); + return; + } + } + return; +} + + + +int bl_gpio_cli_init(void) + +{ + return 0; +} + + + +int bl_efuse_read_mac(uint8_t *mac) + +{ + EF_Ctrl_Read_MAC_Address(mac); + return 0; +} + + + +int bl_efuse_read_mac_factory(uint8_t *mac) + +{ + int8_t iVar1; + undefined3 extraout_var; + + iVar1 = mfg_media_read_macaddr(mac,'\x01'); + return -(uint)(CONCAT31(extraout_var,iVar1) != 0); +} + + + +int bl_efuse_read_capcode(uint8_t *capcode) + +{ + int8_t iVar1; + undefined3 extraout_var; + + iVar1 = mfg_media_read_xtal_capcode(capcode,'\x01'); + return -(uint)(CONCAT31(extraout_var,iVar1) != 0); +} + + + +int bl_efuse_read_pwroft(int8_t *poweroffset) + +{ + int8_t iVar1; + undefined3 extraout_var; + + iVar1 = mfg_media_read_poweroffset(poweroffset,'\x01'); + return -(uint)(CONCAT31(extraout_var,iVar1) != 0); +} + + + +int bl_wifi_clock_enable(void) + +{ + int called; + + return 0; +} + + + +int bl_wifi_enable_irq(void) + +{ + bl_irq_register(0x46,mac_irq); + bl_irq_register(0x4f,bl_irq_handler); + bl_irq_enable(0x46); + bl_irq_enable(0x4f); + puts("Enable BMX IRQ\r\n"); + return 0; +} + + + +int bl_wifi_sta_mac_addr_set(uint8_t *mac) + +{ + memcpy(&wifi_env,mac,6); + return 0; +} + + + +int bl_wifi_ap_mac_addr_set(uint8_t *mac) + +{ + memcpy(wifi_env.ap_mac_addr_board,mac,6); + return 0; +} + + + +int bl_wifi_mac_addr_get(uint8_t *mac) + +{ + memcpy(mac,&wifi_env,6); + return 0; +} + + + +int bl_wifi_country_code_set(uint8_t country_code) + +{ + wifi_env.country_code = country_code; + return 0; +} + + + +int bl_wifi_ap_info_set(uint8_t *ssid,uint8_t ssid_len,uint8_t *psk,uint8_t psk_len,uint8_t chan) + +{ + undefined3 in_register_0000202d; + undefined3 in_register_00002035; + + memset(&wifi_env.ap_info,0,99); + memcpy(&wifi_env.ap_info,ssid,CONCAT31(in_register_0000202d,ssid_len)); + memcpy(wifi_env.ap_info.psk,psk,CONCAT31(in_register_00002035,psk_len)); + wifi_env.ap_info.chan = chan; + wifi_env.ap_info_en = '\x01'; + return 0; +} + + + +int bl_wifi_sta_info_set + (uint8_t *ssid,uint8_t ssid_len,uint8_t *psk,uint8_t psk_len,int autoconnect) + +{ + undefined3 in_register_0000202d; + undefined3 in_register_00002035; + + memset(&wifi_env.sta_info,0,99); + memcpy(&wifi_env.sta_info,ssid,CONCAT31(in_register_0000202d,ssid_len)); + memcpy(wifi_env.sta_info.psk,psk,CONCAT31(in_register_00002035,psk_len)); + wifi_env.sta_info_en = (uint8_t)autoconnect; + return 0; +} + + + +int cmd_timer_start(void) + +{ + TIMER_CFG_Type TStack40; + + memcpy(&TStack40,&DAT_230c3054,0x18); + TIMER_IntMask(TIMER_CH1,TIMER_INT_ALL,MASK); + TIMER_Disable(TStack40.timerCh); + TIMER_Init(&TStack40); + TIMER_ClearIntStatus(TStack40.timerCh,TIMER_COMP_ID_0); + TIMER_ClearIntStatus(TStack40.timerCh,TIMER_COMP_ID_1); + TIMER_ClearIntStatus(TStack40.timerCh,TIMER_COMP_ID_2); + TIMER_IntMask(TStack40.timerCh,TIMER_INT_COMP_0,UNMASK); + TIMER_IntMask(TStack40.timerCh,TIMER_INT_COMP_1,MASK); + TIMER_IntMask(TStack40.timerCh,TIMER_INT_COMP_2,MASK); + TIMER_Enable(TStack40.timerCh); + bl_irq_enable(0x35); + bl_irq_register(0x35,int_timer_cb); + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void cmd_wdt_disable(void) + +{ + _DAT_4000a564 = _DAT_4000a564 & 0xfffffffe; + _DAT_4000a59c = _DAT_4000a59c & 0xffff0000 | 0xbaba; + _DAT_4000a5a0 = _DAT_4000a5a0 & 0xffff0000 | 0xeb10; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void cmd_wdt_feed(void) + +{ + _DAT_4000a598 = _DAT_4000a598 | 1; + _DAT_4000a59c = _DAT_4000a59c & 0xffff0000 | 0xbaba; + _DAT_4000a5a0 = _DAT_4000a5a0 & 0xffff0000 | 0xeb10; + return; +} + + + +void cmd_wdt_init(int param_1,undefined4 *param_2) + +{ + int ms; + + if (param_1 != 2) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Usage: %s ms\r\n",&DAT_230bd32c,"bl_wdt_cli.c",0x2a,*param_2); + return; + } + ms = atoi((char *)param_2[1]); + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Init WDT with %dms\r\n",&DAT_230bd32c,"bl_wdt_cli.c",0x2e,ms); + if (0 < ms) { + bl_wdt_init(ms); + return; + } + return; +} + + + +int bl_wdt_cli_init(void) + +{ + return 0; +} + + + +uint32_t fdt32_to_cpu(fdt32_t x) + +{ + return (x >> 0x10 & 0xff) << 8 | x << 0x18 | x >> 0x18 | (x >> 8 & 0xff) << 0x10; +} + + + +int dev_uart_init(uint8_t id,char *path,uint32_t rx_buf_size,uint32_t tx_buf_size) + +{ + uart_dev_t **ppuVar1; + undefined3 in_register_00002029; + uint uVar2; + TickType_t TVar3; + char *format; + void *pvVar4; + int iVar5; + undefined4 uVar6; + uart_dev_t *__s; + + uVar2 = CONCAT31(in_register_00002029,id); + if ((uVar2 < 3) && (path != (char *)0x0)) { + if (uVar2 == 0) { + ppuVar1 = &dev_uart0; + __s = dev_uart0; + } + else { + if (uVar2 != 1) { + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return -1; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_uart) { + return -1; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar6 = 0x74; + format = "[%10u][%s: %s:%4d] err.\r\n"; + goto LAB_230664ec; + } + ppuVar1 = &dev_uart1; + __s = dev_uart1; + } + if (__s == (uart_dev_t *)0x0) { + __s = (uart_dev_t *)pvPortMalloc(0x3c); + *ppuVar1 = __s; + if (__s == (uart_dev_t *)0x0) { + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return -1; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_uart) { + return -1; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar6 = 0x3c; + } + else { + memset(__s,0,0x3c); + (*ppuVar1)->read_block_flag = '\x02'; + (*ppuVar1)->priv = (void *)0x0; + __s = *ppuVar1; + pvVar4 = pvPortMalloc(4); + __s->priv = pvVar4; + if ((*ppuVar1)->priv != (void *)0x0) { + memset((*ppuVar1)->priv,0,4); + (*ppuVar1)->rx_buf_size = rx_buf_size; + (*ppuVar1)->tx_buf_size = tx_buf_size; + if (*ppuVar1 == (uart_dev_t *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] mem err.\r\n",TVar3,&DAT_230a9dd8,"hal_uart.c",0x50); + } + } + else { + (*ppuVar1)->port = id; + (*ppuVar1)->read_block_flag = '\x02'; + ((*ppuVar1)->config).baud_rate = 0x1c200; + ((*ppuVar1)->config).data_width = DATA_WIDTH_8BIT; + ((*ppuVar1)->config).parity = NO_PARITY; + ((*ppuVar1)->config).stop_bits = STOP_BITS_1; + ((*ppuVar1)->config).flow_control = FLOW_CONTROL_DISABLED; + ((*ppuVar1)->config).mode = MODE_TX_RX; + } + iVar5 = aos_register_driver(path,(file_ops_t *)&uart_ops,*ppuVar1); + return iVar5; + } + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return -1; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_uart) { + return -1; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar6 = 0x45; + } + format = "[%10u][%s: %s:%4d] mem err.\r\n"; + goto LAB_230664ec; + } + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return -1; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_uart) { + return -1; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar6 = 0x36; + } + else { + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return -1; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_uart) { + return -1; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar6 = 0x65; + } + format = "[%10u][%s: %s:%4d] arg err.\r\n"; +LAB_230664ec: + bl_printk(format,TVar3,&DAT_230a9dd8,"hal_uart.c",uVar6); + return -1; +} + + + +int32_t hal_uart_send_trigger(uart_dev_t *uart) + +{ + bl_uart_int_tx_enable(uart->port); + return 0; +} + + + +int32_t hal_uart_send_trigger_off(uart_dev_t *uart) + +{ + bl_uart_int_tx_disable(uart->port); + return 0; +} + + + +int32_t hal_uart_init(uart_dev_t *uart) + +{ + int iVar1; + int iVar2; + hal_uart_parity_t ahStack17 [4]; + uint8_t parity; + + iVar2 = aos_mutex_new((aos_mutex_t *)uart->priv); + iVar1 = -1; + if (iVar2 == 0) { + bl_uart_getdefconfig(uart->port,ahStack17); + if (ahStack17[0] == NO_PARITY) { + (uart->config).parity = NO_PARITY; + } + else { + if (ahStack17[0] != ODD_PARITY) { + ahStack17[0] = EVEN_PARITY; + } + (uart->config).parity = ahStack17[0]; + } + bl_uart_int_enable(uart->port); + iVar1 = iVar2; + } + return iVar1; +} + + + +int32_t hal_uart_recv_II(uart_dev_t *uart,void *data,uint32_t expect_size,uint32_t *recv_size, + uint32_t timeout) + +{ + uint32_t uVar1; + int iVar2; + + uVar1 = 0; + while (uVar1 != expect_size) { + iVar2 = bl_uart_data_recv(uart->port); + if (iVar2 < 0) break; + *(undefined *)((int)data + uVar1) = (char)iVar2; + uVar1 = uVar1 + 1; + } + *recv_size = uVar1; + return 0; +} + + + +int32_t hal_uart_send(uart_dev_t *uart,void *data,uint32_t size,uint32_t timeout) + +{ + uint8_t data_00; + uint8_t *puVar1; + + puVar1 = (uint8_t *)((int)data + size); + while ((uint8_t *)data != puVar1) { + data_00 = *(uint8_t *)data; + data = (uint8_t *)data + 1; + bl_uart_data_send(uart->port,data_00); + } + return 0; +} + + + +int32_t hal_uart_finalize(uart_dev_t *uart) + +{ + aos_mutex_t *mutex; + + mutex = (aos_mutex_t *)uart->priv; + bl_uart_int_disable(uart->port); + aos_mutex_free(mutex); + return 0; +} + + + +int32_t hal_uart_notify_register(uart_dev_t *uart,hal_uart_int_t type,anon_subr_void_void_ptr *cb) + +{ + undefined3 in_register_0000202d; + + if (CONCAT31(in_register_0000202d,type) == 0) { + bl_uart_int_tx_notify_register(uart->port,(cb_uart_notify_t *)cb,uart); + } + else { + if (CONCAT31(in_register_0000202d,type) != 1) { + return -1; + } + bl_uart_int_rx_notify_register(uart->port,(cb_uart_notify_t *)cb,uart); + } + return 0; +} + + + +undefined4 vfs_uart_init(void *param_1,int param_2) + +{ + int nodeoffset; + char *property; + int nodeoffset_00; + TickType_t TVar1; + fdt32_t *pfVar2; + uint32_t baudrate; + uint32_t uVar3; + int iVar4; + char *__s2; + uint32_t uVar5; + undefined4 uVar6; + int iVar7; + char *name; + fdt32_t x; + fdt32_t x_00; + char **ppcVar8; + uint32_t rx_buf_size; + uint32_t tx_buf_size; + fdt32_t x_01; + uint8_t uStack152; + char **ppcStack148; + uint local_7c; + char *pcStack120; + char *pcStack116; + char *local_70; + undefined4 uStack108; + byte bStack104; + uint8_t uStack92; + uint8_t uStack80; + uint8_t uStack68; + char *apcStack64 [3]; + + if (inited == '\x01') { + return 0; + } + pcStack120 = "uart@4000A000"; + pcStack116 = "uart@4000A100"; + local_7c = 0; + memcpy(&local_70,&PTR_DAT_230c1c04,0x30); + ppcStack148 = &pcStack120; + iVar7 = 0; + do { + name = *ppcStack148; + nodeoffset = fdt_subnode_offset(param_1,param_2,name); + if (nodeoffset < 1) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 300; + goto LAB_2306688a; + } + } + else { + name = (char *)fdt_stringlist_count(param_1,nodeoffset,"status"); + if (name == &DAT_00000001) { + name = fdt_stringlist_get(param_1,nodeoffset,"status",0,(int *)&local_7c); + if ((local_7c == 4) && (nodeoffset_00 = memcmp(&DAT_230c1d48,name,4), nodeoffset_00 == 0)) { + name = (char *)fdt_stringlist_count(param_1,nodeoffset,"path"); + if (name == &DAT_00000001) { + name = fdt_stringlist_get(param_1,nodeoffset,"path",0,(int *)&local_7c); + if (((0x20 < local_7c) && (_fsymc_level_hal_drv < BLOG_LEVEL_WARN)) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] path lentmp = %d\r\n",TVar1,&DAT_230bd32c, + "hal_uart.c",0x144,iVar7,local_7c); + } + pfVar2 = (fdt32_t *)fdt_getprop(param_1,nodeoffset,"baudrate",(int *)&local_7c); + if (pfVar2 == (fdt32_t *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x14b; + name = "[%10u][%s: %s:%4d] uart[%d] baudrate NULL.\r\n"; +LAB_23066ab6: + bl_printk(name,&DAT_230bd32c,"hal_uart.c",uVar6,iVar7); + } + } + else { + x_00 = *pfVar2; + pfVar2 = (fdt32_t *)fdt_getprop(param_1,nodeoffset,"id",(int *)&local_7c); + if (pfVar2 == (fdt32_t *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x153; + name = "[%10u][%s: %s:%4d] uart[%d] id NULL.\r\n"; + goto LAB_23066ab6; + } + } + else { + x = *pfVar2; + nodeoffset_00 = fdt_subnode_offset(param_1,nodeoffset,"buf_size"); + if (nodeoffset_00 < 1) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] buf_size NULL, will use default.\r\n", + TVar1,&DAT_230bd32c,"hal_uart.c",0x15b,iVar7); + } + tx_buf_size = 0x200; + rx_buf_size = 0x200; +LAB_23066c3a: + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] rx_buf_size %d, tx_buf_size %d\r\n",TVar1 + ,&DAT_230bd32c,"hal_uart.c",0x16c,iVar7,rx_buf_size,tx_buf_size); + } + baudrate = fdt32_to_cpu(x_00); + uVar3 = fdt32_to_cpu(x); + ppcVar8 = &local_70; + do { + nodeoffset_00 = fdt_subnode_offset(param_1,nodeoffset,"feature"); + if (nodeoffset_00 < 1) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] feature NULL.\r\n",TVar1, + &DAT_230bd32c,"hal_uart.c",0x171,iVar7); + } + } + else { + property = *ppcVar8; + iVar4 = fdt_stringlist_count(param_1,nodeoffset_00,property); + if (iVar4 == 1) { + __s2 = fdt_stringlist_get(param_1,nodeoffset_00,property,0,(int *)&local_7c) + ; + if ((local_7c == 4) && + (nodeoffset_00 = memcmp(&DAT_230c1d48,__s2,4), nodeoffset_00 == 0)) { + nodeoffset_00 = fdt_subnode_offset(param_1,nodeoffset,"pin"); + if (nodeoffset_00 < 1) { + if ((BLOG_LEVEL_INFO < _fsymc_level_hal_drv) || + (BLOG_LEVEL_INFO < _fsymf_level_hal_drvhal_uart)) goto LAB_23066df4; + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] pin NULL.\r\n",TVar1, + &DAT_230bd32c,"hal_uart.c",0x182,iVar7); + break; + } + property = ppcVar8[1]; + pfVar2 = (fdt32_t *) + fdt_getprop(param_1,nodeoffset_00,property,(int *)&local_7c); + if (pfVar2 == (fdt32_t *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] %s NULL.\r\n",TVar1, + &DAT_230bd32c,"hal_uart.c",0x187,iVar7,property); + } + } + else { + uVar5 = fdt32_to_cpu(*pfVar2); + *(char *)(ppcVar8 + 2) = (char)uVar5; + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] %s status = %s lentmp = %d\r\n", + TVar1,&DAT_230bd32c,"hal_uart.c",0x17b,iVar7,property,__s2); + } + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] %s countindex = %d.\r\n",TVar1, + &DAT_230bd32c,"hal_uart.c",0x176,iVar7,property,iVar4); + } + } + } + ppcVar8 = ppcVar8 + 3; + } while (apcStack64 != ppcVar8); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] id = %d, %s = %d, %s = %d, %s = %d, %s = %d baudrate = %ld.\r\n" + ,TVar1,&DAT_230bd32c,"hal_uart.c",0x192,uVar3 & 0xff,uStack108, + (uint)bStack104); + } +LAB_23066df4: + uStack152 = (uint8_t)uVar3; + bl_uart_flush(uStack152); + bl_uart_init(uStack152,bStack104,uStack92,uStack80,uStack68,baudrate); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] bl_uart_init %d ok.\r\n",TVar1,&DAT_230bd32c, + "hal_uart.c",0x19a,uVar3 & 0xff); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] bl_uart_init %d baudrate = %ld ok.\r\n",TVar1, + &DAT_230bd32c,"hal_uart.c",0x19b,uVar3 & 0xff,baudrate); + } + } + nodeoffset = dev_uart_init(uStack152,name,rx_buf_size,tx_buf_size); + if (((nodeoffset != 0) && (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] dev_uart_init err.\r\n",&DAT_230a9dd8,"hal_uart.c" + ,0x19e); + } + } + else { + pfVar2 = (fdt32_t *)fdt_getprop(param_1,nodeoffset_00,"rx_size",(int *)&local_7c); + if (pfVar2 == (fdt32_t *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + name = "rx_size"; + uVar6 = 0x161; +LAB_2306688a: + property = "[%10u][%s: %s:%4d] uart[%d] %s NULL.\r\n"; + goto LAB_230668fe; + } + } + else { + x_01 = *pfVar2; + pfVar2 = (fdt32_t *) + fdt_getprop(param_1,nodeoffset_00,"tx_size",(int *)&local_7c); + if (pfVar2 != (fdt32_t *)0x0) { + rx_buf_size = fdt32_to_cpu(x_01); + tx_buf_size = fdt32_to_cpu(*pfVar2); + goto LAB_23066c3a; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + name = "tx_size"; + uVar6 = 0x167; + goto LAB_2306688a; + } + } + } + } + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x13e; + property = "[%10u][%s: %s:%4d] uart[%d] path_countindex = %d NULL.\r\n"; + goto LAB_230668fe; + } + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x137; + property = "[%10u][%s: %s:%4d] uart[%d] status = %s\r\n"; + goto LAB_230668fe; + } + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x132; + property = "[%10u][%s: %s:%4d] uart[%d] status_countindex = %d NULL.\r\n"; +LAB_230668fe: + bl_printk(property,&DAT_230bd32c,"hal_uart.c",uVar6,iVar7,name); + } + } + } + ppcStack148 = ppcStack148 + 1; + if (iVar7 != 0) { + inited = (int8_t)iVar7; + return 0; + } + iVar7 = 1; + } while( true ); +} + + + +int32_t hal_uart_send_flush(uart_dev_t *uart,uint32_t timeout) + +{ + bl_uart_flush(uart->port); + return 0; +} + + + +void hal_uart_setbaud(uart_dev_t *uart,uint32_t baud) + +{ + bl_uart_setbaud(uart->port,baud); + return; +} + + + +void hal_uart_setconfig(uart_dev_t *uart,uint32_t baud,hal_uart_parity_t parity) + +{ + bl_uart_setconfig(uart->port,baud,parity); + return; +} + + + +undefined4 hal_gpio_init_from_dts(void *param_1,int param_2) + +{ + uint uVar1; + uint *puVar2; + int nodeoffset; + char *format; + TickType_t TVar3; + int iVar4; + char *format_00; + undefined *puVar5; + undefined4 uVar6; + uint uVar7; + int iVar8; + int local_5c; + char acStack88 [11]; + undefined uStack77; + uint uStack76; + char cStack72; + byte bStack71; + byte bStack70; + undefined uStack69; + uint uStack68; + + uStack76 = 0; + puVar2 = (uint *)fdt_getprop(param_1,param_2,"max_num",(int *)&uStack76); + uVar1 = 0xffffffff; + if (puVar2 != (uint *)0x0) { + uVar1 = *puVar2; + uVar1 = uVar1 << 0x18 | uVar1 >> 0x18 | (uVar1 >> 8 & 0xff) << 0x10 | + (uVar1 >> 0x10 & 0xff) << 8; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvhal_gpio < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [HAL] [GPIO] Max num is %d\r\n",&DAT_230bd32c,"hal_gpio.c",0xb5, + uVar1); + } + iVar8 = 0; + do { + if ((int)uVar1 <= iVar8) { + return 0; + } + snprintf(acStack88,0xb,"gpio%u",iVar8); + uStack77 = 0; + local_5c = 0; + nodeoffset = fdt_subnode_offset(param_1,param_2,acStack88); + if (nodeoffset < 0) { + if (BLOG_LEVEL_INFO < _fsymc_level_hal_drv) { + return 0; + } + if (BLOG_LEVEL_INFO < _fsymf_level_hal_drvhal_gpio) { + return 0; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %s NOT found\r\n",&DAT_230bd32c,"hal_gpio.c",0x61,acStack88); + return 0; + } + memset(&uStack76,0,0xc); + cStack72 = '\0'; + format = fdt_stringlist_get(param_1,nodeoffset,"status",0,&local_5c); + if ((local_5c == 4) && (iVar4 = memcmp(&DAT_230c1d48,format,4), iVar4 == 0)) { + puVar2 = (uint *)fdt_getprop(param_1,nodeoffset,"pin",&local_5c); + if (puVar2 == (uint *)0x0) { + if ((BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) || + (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_gpio)) goto LAB_230671ba; + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x70; + format = "[%10u][%s: %s:%4d] no pin found for %s\r\n"; +LAB_23067278: + bl_printk(format,&DAT_230a9dd8,"hal_gpio.c",uVar6,acStack88); + } + else { + uVar7 = *puVar2; + uStack76 = (uVar7 >> 0x10 & 0xff) << 8 | + uVar7 << 0x18 | uVar7 >> 0x18 | (uVar7 >> 8 & 0xff) << 0x10; + format = fdt_stringlist_get(param_1,nodeoffset,"feature",0,&local_5c); + if ((local_5c != 3) || (iVar4 = memcmp("led",format,3), iVar4 != 0)) { + if ((BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) || + (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_gpio)) goto LAB_230671ba; + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x79; +LAB_230673fa: + puVar5 = &DAT_230a9dd8; + format_00 = "[%10u][%s: %s:%4d] %s: unvalid GPIO config %3s\r\n"; + goto LAB_230672ae; + } + bStack71 = 0; + format = fdt_stringlist_get(param_1,nodeoffset,"active",0,&local_5c); + if (local_5c == 2) { + iVar4 = memcmp(&DAT_230c21a4,format,2); + if (iVar4 == 0) { + bStack70 = 1; + } + else { + if ((local_5c != 2) || (iVar4 = memcmp(&DAT_230c21a8,format,2), iVar4 != 0)) + goto LAB_23067436; + bStack70 = 0; + } + format = fdt_stringlist_get(param_1,nodeoffset,"mode",0,&local_5c); + if ((local_5c == 5) && (iVar4 = memcmp("blink",format,5), iVar4 == 0)) { + uStack69 = 0; + } + else { + if ((local_5c != 9) || (iVar4 = memcmp("heartbeat",format,9), iVar4 != 0)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_gpio < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x8d; + goto LAB_230673fa; + } + goto LAB_230671ba; + } + uStack69 = 1; + } + puVar2 = (uint *)fdt_getprop(param_1,nodeoffset,"time",&local_5c); + if (puVar2 == (uint *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_gpio < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x93; + format = "[%10u][%s: %s:%4d] %s: unvalid GPIO config\r\n"; + goto LAB_23067278; + } + } + else { + uVar7 = *puVar2; + uStack68 = (uVar7 >> 0x10 & 0xff) << 8 | + uVar7 << 0x18 | uVar7 >> 0x18 | (uVar7 >> 8 & 0xff) << 0x10; + cStack72 = '\x01'; + } + } + else { +LAB_23067436: + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_gpio < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x83; + goto LAB_230673fa; + } + } + } + } + else { + if ((BLOG_LEVEL_INFO < _fsymc_level_hal_drv) || + (BLOG_LEVEL_INFO < _fsymf_level_hal_drvhal_gpio)) goto LAB_230671ba; + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x6a; + puVar5 = &DAT_230bd32c; + format_00 = "[%10u][%s: %s:%4d] [%s] status = %s\r\n"; +LAB_230672ae: + bl_printk(format_00,puVar5,"hal_gpio.c",uVar6,acStack88,format); + } +LAB_230671ba: + if (cStack72 == '\x01') { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_gpio < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] New CONF: GPIO%02u: feature %u, active %u, mode %u, time %u\r\n" + ,TVar3,&DAT_230bd32c,"hal_gpio.c",0xa6,uStack76,(uint)bStack71,(uint)bStack70); + } + loopset_led_trigger(uStack76,uStack68); + } + else { + if (((cStack72 == '\0') && (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvhal_gpio < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %s: unvalid GPIO config\r\n",&DAT_230a9dd8,"hal_gpio.c",0xc3, + acStack88); + } + } + iVar8 = iVar8 + 1; + } while( true ); +} + + + +void _dump_partition(void) + +{ + int iVar1; + anon_struct_conflict529 *paVar2; + + bl_printk("======= PtTable_Config @%p=======\r\n",0x4200efac); + bl_printk("magicCode 0x%08X;",boot2_partition_table.table.ptTable.magicCode); + bl_printk(" version 0x%04X;",(uint)boot2_partition_table.table.ptTable.version); + bl_printk(" entryCnt %u;",(uint)boot2_partition_table.table.ptTable.entryCnt); + bl_printk(" age %lu;",boot2_partition_table.table.ptTable.age); + bl_printk(" crc32 0x%08X\r\n"); + bl_printk( + "idx type device activeIndex name Address[0] Address[1] Length[0] Length[1] age\r\n" + ); + iVar1 = 0; + paVar2 = &boot2_partition_table; + while( true ) { + if ((int)(uint)boot2_partition_table.table.ptTable.entryCnt <= iVar1) break; + bl_printk("[%02d] ",iVar1); + iVar1 = iVar1 + 1; + bl_printk(" %02u",(uint)(paVar2->table).ptEntries[0].type); + bl_printk(" %u",(uint)(paVar2->table).ptEntries[0].device); + bl_printk(" %u",(uint)(paVar2->table).ptEntries[0].activeIndex); + bl_printk(" %8s",(paVar2->table).ptEntries[0].name); + bl_printk(" %p",(paVar2->table).ptEntries[0].Address[0]); + bl_printk(" %p",(paVar2->table).ptEntries[0].Address[1]); + bl_printk(" %p",(paVar2->table).ptEntries[0].maxLen[0]); + bl_printk(" %p",(paVar2->table).ptEntries[0].maxLen[1]); + bl_printk(" %lu\r\n"); + paVar2 = (anon_struct_conflict529 *)((paVar2->table).ptEntries[0].Address + 1); + } + return; +} + + + +int hal_boot2_update_ptable(HALPartition_Entry_Config *ptEntry_hal) + +{ + uint8_t uVar1; + PtTable_Error_Type PVar2; + undefined3 extraout_var; + + *(bool *)&ptEntry_hal->activeIndex = ptEntry_hal->activeIndex == '\0'; + uVar1 = boot2_partition_table.partition_active_idx; + ptEntry_hal->age = ptEntry_hal->age + 1; + PVar2 = PtTable_Update_Entry + ((SPI_Flash_Cfg_Type *)0x0,uVar1 == '\0',&boot2_partition_table.table, + (PtTable_Entry_Config *)ptEntry_hal); + return CONCAT31(extraout_var,PVar2); +} + + + +uint32_t hal_boot2_get_flash_addr(void) + +{ + return (uint32_t) + (&__boot2_flashCfg_src + (uint)boot2_partition_table.table.ptTable.entryCnt * 0x24); +} + + + +int hal_boot2_partition_bus_addr + (char *name,uint32_t *addr0,uint32_t *addr1,uint32_t *size0,uint32_t *size1, + int *active) + +{ + byte bVar1; + uint uVar2; + uint uVar3; + int iVar4; + anon_struct_conflict529 *paVar5; + uint uVar6; + uint uVar7; + anon_struct_conflict529 *paVar8; + + if (boot2_partition_table.table.ptTable.magicCode != 0x54504642) { + return -5; + } + paVar8 = &boot2_partition_table; + paVar5 = &boot2_partition_table; + uVar2 = 0; + while ((int)uVar2 < (int)(uint)boot2_partition_table.table.ptTable.entryCnt) { + iVar4 = strcmp((char *)(paVar5->table).ptEntries[0].name,name); + paVar5 = (anon_struct_conflict529 *)((paVar5->table).ptEntries[0].Address + 1); + if (iVar4 == 0) break; + uVar2 = uVar2 + 1; + } + iVar4 = -2; + if (uVar2 != (uint)boot2_partition_table.table.ptTable.entryCnt) { + uVar7 = boot2_partition_table.table.ptEntries[uVar2].Address[0]; + uVar6 = boot2_partition_table.table.ptEntries[uVar2].Address[1]; + *active = (uint)boot2_partition_table.table.ptEntries[uVar2].activeIndex; + *size0 = boot2_partition_table.table.ptEntries[uVar2].maxLen[0]; + uVar3 = 0; + *size1 = *(uint32_t *)((int)&boot2_partition_table.table.ptTable + (uVar2 + 1) * 0x24 + 4); + while ((int)uVar3 < (int)(uint)boot2_partition_table.table.ptTable.entryCnt) { + iVar4 = strcmp((char *)(paVar8->table).ptEntries[0].name,"FW"); + paVar8 = (anon_struct_conflict529 *)((paVar8->table).ptEntries[0].Address + 1); + if (iVar4 == 0) break; + uVar3 = uVar3 + 1; + } + iVar4 = -0x48; + if (uVar3 != (uint)boot2_partition_table.table.ptTable.entryCnt) { + if (uVar7 != 0) { + if (uVar7 < boot2_partition_table.table.ptEntries[uVar3].Address[0]) { + return -0x16; + } + if (uVar7 < boot2_partition_table.table.ptEntries[uVar3].Address[1]) { + return -0x16; + } + } + if (uVar6 != 0) { + if (uVar6 < boot2_partition_table.table.ptEntries[uVar3].Address[0]) { + return -0x16; + } + if (uVar6 < boot2_partition_table.table.ptEntries[uVar3].Address[1]) { + return -0x16; + } + } + iVar4 = -0xe; + bVar1 = boot2_partition_table.table.ptEntries[uVar3].activeIndex; + if (bVar1 < 2) { + iVar4 = 0; + *addr0 = (uVar7 + 0x22fff000) - + (&boot2_partition_table.table.ptTable.crc32)[(uint)bVar1 + uVar3 * 9 + 4]; + *addr1 = (uVar6 + 0x22fff000) - + (&boot2_partition_table.table.ptTable.crc32) + [uVar3 * 9 + (uint)boot2_partition_table.table.ptEntries[uVar3].activeIndex + 4]; + } + } + } + return iVar4; +} + + + +int hal_boot2_partition_bus_addr_active(char *name,uint32_t *addr,uint32_t *size) + +{ + int iVar1; + uint32_t uStack36; + uint32_t addr0; + uint32_t addr1; + uint32_t size0; + uint32_t size1; + int active; + + iVar1 = hal_boot2_partition_bus_addr(name,&uStack36,&addr0,&addr1,&size0,(int *)&size1); + if (iVar1 == 0) { + if (size1 != 0) { + uStack36 = addr0; + } + *addr = uStack36; + if (size1 != 0) { + addr1 = size0; + } + *size = addr1; + } + return iVar1; +} + + + +int hal_boot2_partition_bus_addr_inactive(char *name,uint32_t *addr,uint32_t *size) + +{ + int iVar1; + uint32_t uStack36; + uint32_t addr0; + uint32_t addr1; + uint32_t size0; + uint32_t size1; + int active; + + iVar1 = hal_boot2_partition_bus_addr(name,&uStack36,&addr0,&addr1,&size0,(int *)&size1); + if (iVar1 == 0) { + if (size1 != 0) { + addr0 = uStack36; + } + *addr = addr0; + if (size1 != 0) { + size0 = addr1; + } + *size = size0; + } + return iVar1; +} + + + +int hal_boot2_partition_addr + (char *name,uint32_t *addr0,uint32_t *addr1,uint32_t *size0,uint32_t *size1, + int *active) + +{ + uint uVar1; + anon_struct_conflict529 *paVar2; + int iVar3; + + if (boot2_partition_table.table.ptTable.magicCode == 0x54504642) { + paVar2 = &boot2_partition_table; + uVar1 = 0; + while ((int)uVar1 < (int)(uint)boot2_partition_table.table.ptTable.entryCnt) { + iVar3 = strcmp((char *)(paVar2->table).ptEntries[0].name,name); + paVar2 = (anon_struct_conflict529 *)((paVar2->table).ptEntries[0].Address + 1); + if (iVar3 == 0) break; + uVar1 = uVar1 + 1; + } + iVar3 = -2; + if (uVar1 != (uint)boot2_partition_table.table.ptTable.entryCnt) { + *addr0 = boot2_partition_table.table.ptEntries[uVar1].Address[0]; + *addr1 = boot2_partition_table.table.ptEntries[uVar1].Address[1]; + *size0 = boot2_partition_table.table.ptEntries[uVar1].maxLen[0]; + *size1 = *(uint32_t *)((int)&boot2_partition_table.table.ptTable + (uVar1 + 1) * 0x24 + 4); + iVar3 = 0; + *active = (uint)boot2_partition_table.table.ptEntries[uVar1].activeIndex; + } + } + else { + iVar3 = -5; + } + return iVar3; +} + + + +int hal_boot2_partition_addr_active(char *name,uint32_t *addr,uint32_t *size) + +{ + int iVar1; + uint32_t uStack36; + uint32_t addr0; + uint32_t addr1; + uint32_t size0; + uint32_t size1; + int active; + + iVar1 = hal_boot2_partition_addr(name,&uStack36,&addr0,&addr1,&size0,(int *)&size1); + if (iVar1 == 0) { + if (size1 != 0) { + uStack36 = addr0; + } + *addr = uStack36; + if (size1 != 0) { + addr1 = size0; + } + *size = addr1; + } + return iVar1; +} + + + +int hal_boot2_partition_addr_inactive(char *name,uint32_t *addr,uint32_t *size) + +{ + int iVar1; + uint32_t uStack36; + uint32_t addr0; + uint32_t addr1; + uint32_t size0; + uint32_t size1; + int active; + + iVar1 = hal_boot2_partition_addr(name,&uStack36,&addr0,&addr1,&size0,(int *)&size1); + if (iVar1 == 0) { + if (size1 != 0) { + addr0 = uStack36; + } + *addr = addr0; + if (size1 != 0) { + size0 = addr1; + } + *size = size0; + } + return iVar1; +} + + + +uint8_t hal_boot2_get_active_partition(void) + +{ + return boot2_partition_table.partition_active_idx; +} + + + +int hal_boot2_get_active_entries(int type,HALPartition_Entry_Config *ptEntry_hal) + +{ + PtTable_Error_Type PVar1; + undefined3 extraout_var; + + PVar1 = PtTable_Get_Active_Entries + (&boot2_partition_table.table,(PtTable_Entry_Type)type, + (PtTable_Entry_Config *)ptEntry_hal); + return -(uint)(CONCAT31(extraout_var,PVar1) != 0); +} + + + +int hal_boot2_dump(void) + +{ + _dump_partition(); + return 0; +} + + + +int hal_boot2_init(void) + +{ + TickType_t TVar1; + + boot2_partition_table.partition_active_idx = __boot2_pt_addr_src; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvhal_boot2 < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [HAL] [BOOT2] Active Partition[%u] consumed %d Bytes\r\n",TVar1, + &DAT_230bd32c,"hal_boot2.c",0x114,(uint)boot2_partition_table.partition_active_idx, + 0x254); + } + _dump_partition(); + bl_flash_config_update(); + return 0; +} + + + +int hal_reboot(void) + +{ + GLB_SW_POR_Reset(); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void hal_sys_reset(void) + +{ + GLB_SW_System_Reset(); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void hal_poweroff(void) + +{ + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_sys_capcode_update(uint8_t capin,uint8_t capout) + +{ + uint8_t capin_static; + uint8_t capout_static; + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + + if ((CONCAT31(in_register_00002029,capin) != 0xff) && + (CONCAT31(in_register_0000202d,capout) != 0xff)) { + (*_DAT_2101081c)(); + return; + } + // WARNING: Could not recover jumptable at 0x23067b1a. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_2101081c)((uint)capin_static,(uint)capout_static); + return; +} + + + +uint8_t hal_sys_capcode_get(void) + +{ + uint8_t uVar1; + + uVar1 = AON_Get_Xtal_CapCode(); + return uVar1; +} + + + +uint32_t fdt32_to_cpu(fdt32_t x) + +{ + return (x >> 0x10 & 0xff) << 8 | x << 0x18 | x >> 0x18 | (x >> 8 & 0xff) << 0x10; +} + + + +uint32_t hal_board_get_factory_addr(void) + +{ + return factory_addr; +} + + + +// WARNING: Could not reconcile some variable overlaps + +undefined4 hal_board_cfg(void) + +{ + char cVar1; + byte bVar2; + uint32_t ble_tx_power; + int parentoffset; + TickType_t TVar3; + int nodeoffset; + int iVar4; + char *format; + size_t sVar5; + uint32_t uVar6; + uint32_t uVar7; + void *__src; + uint32_t autoconnect; + fdt32_t x; + int iVar8; + int iVar9; + char *pcVar10; + uint8_t chan; + undefined4 uVar11; + size_t *psVar12; + size_t *psVar13; + byte *pbVar14; + fdt32_t *pfVar15; + uint8_t capin; + uint8_t psk_len; + fdt32_t *pfVar16; + int iStack220; + byte local_c4 [4]; + uint32_t uStack192; + int iStack188; + size_t sStack184; + size_t local_b4; + size_t local_b0; + int8_t iStack170; + size_t local_a0 [3]; + size_t asStack146 [4]; + undefined4 local_80; + byte bStack124; + byte bStack123; + + parentoffset = hal_boot2_partition_addr_active("factory",&factory_addr,&uStack192); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [MAIN] [BOARD] [FLASH] addr from partition is %08x, ret is %d\r\n" + ,TVar3,&DAT_230bd32c,"hal_board.c",0x376,factory_addr,parentoffset); + } + if (factory_addr == 0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] [MAIN] [BOARD] [FLASH] Dead loop. Reason: NO valid Param Parition found\r\n" + ,TVar3,&DAT_230a9dd8,"hal_board.c",0x378); + } + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + parentoffset = hal_boot2_partition_bus_addr_active("factory",&factory_addr,&uStack192); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [MAIN] [BOARD] [XIP] addr from partition is %08x, ret is %d\r\n", + TVar3,&DAT_230bd32c,"hal_board.c",0x37e,factory_addr,parentoffset); + } + ble_tx_power = factory_addr; + if (factory_addr == 0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] [MAIN] [BOARD] [XIP] Dead loop. Reason: NO valid Param Parition found\r\n" + ,TVar3,&DAT_230a9dd8,"hal_board.c",0x380); + } + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + iStack188 = 0; + parentoffset = fdt_subnode_offset((void *)factory_addr,0,"wifi"); + if (((parentoffset < 1) && (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] wifi NULL.\r\n",TVar3,&DAT_230a9dd8,"hal_board.c",0x242); + } + nodeoffset = fdt_subnode_offset((void *)ble_tx_power,parentoffset,"brd_rf"); + if (0 < nodeoffset) { + local_a0[0] = 0; + iVar4 = fdt_stringlist_count((void *)ble_tx_power,nodeoffset,"xtal_mode"); + if (iVar4 == 1) { + format = fdt_stringlist_get((void *)ble_tx_power,nodeoffset,"xtal_mode",0,(int *)local_a0); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] xtal_mode length %d\r\n",TVar3,&DAT_230bd32c,"hal_board.c", + 0x141,local_a0[0]); + } + if ((int)local_a0[0] < 3) { + memcpy(&local_b0,format,local_a0[0]); + local_b0 = local_b0 & 0xff00ffff; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] xtal_mode is %s\r\n",TVar3,&DAT_230bd32c,"hal_board.c",0x145 + ,&local_b0); + } + sVar5 = strlen((char *)&local_b0); + iVar4 = 0; + while (iVar4 < (int)sVar5) { + if (*(char *)((int)&local_b0 + iVar4) == 'F') { + local_80 = 0; + pfVar15 = (fdt32_t *)fdt_getprop((void *)ble_tx_power,nodeoffset,"xtal",&local_80); + if (local_80 == 0x14) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + autoconnect = fdt32_to_cpu(*pfVar15); + uVar6 = fdt32_to_cpu(pfVar15[1]); + uVar7 = fdt32_to_cpu(pfVar15[2]); + fdt32_to_cpu(pfVar15[3]); + fdt32_to_cpu(pfVar15[4]); + bl_printk("[%10u][%s: %s:%4d] xtal dtb in DEC :%u %u %u %u %u\r\n",TVar3, + &DAT_230bd32c,"hal_board.c",0xf9,autoconnect & 0xff,uVar6 & 0xff, + uVar7 & 0xff); + } + autoconnect = fdt32_to_cpu(*pfVar15); + capin = (uint8_t)autoconnect; + autoconnect = fdt32_to_cpu(pfVar15[1]); + local_80._0_1_ = (byte)autoconnect; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] get xtal from F ready\r\n",TVar3,"DEBUG ", + "hal_board.c",0x114); + } + goto LAB_23067fc6; + } + if (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) { + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] xtal dtb NULL.",TVar3,&DAT_230a9dd8,"hal_board.c", + 0x100); + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x117; + format = "[%10u][%s: %s:%4d] get xtal from F failed\r\n"; + goto LAB_23068330; + } + } + } + else { + if (*(char *)((int)&local_b0 + iVar4) != 'M') { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ASSERT: %s:%d\r\n",TVar3,&UNK_230b1c9c,"hal_board.c", + 0x128,"hal_board.c",0x128); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + local_80 = local_80 & 0xffffff00; + iVar8 = bl_efuse_read_capcode((uint8_t *)&local_80); + if (iVar8 == 0) { + capin = (byte)local_80; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] get xtal from M ready\r\n",TVar3,"DEBUG ", + "hal_board.c",0x11f); + } + goto LAB_23067fc6; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x122; + format = "[%10u][%s: %s:%4d] get xtal from M failed\r\n"; +LAB_23068330: + bl_printk(format,TVar3,"DEBUG ","hal_board.c",uVar11); + } + } + iVar4 = iVar4 + 1; + if (iVar4 == 2) break; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Using Default xtal\r\n",TVar3,&DAT_230bd32c,"hal_board.c", + 0x12e); + } + local_80._0_1_ = '2'; + capin = '2'; +LAB_23067fc6: + hal_sys_capcode_update(capin,(byte)local_80); + } + } + __src = fdt_getprop((void *)ble_tx_power,nodeoffset,"channel_div_table",&iStack188); + if (iStack188 == 0x3c) { + iVar4 = 0; + do { + autoconnect = fdt32_to_cpu(*(fdt32_t *)((int)__src + iVar4)); + *(uint32_t *)((int)&local_80 + iVar4) = autoconnect; + iVar4 = iVar4 + 4; + } while (iVar4 != 0x3c); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] channel_div_table :\r\n",TVar3,&DAT_230bd32c,"hal_board.c",600 + ); + } + log_buf_out("hal_board.c",0x259,&local_80,0x3c,LOG_BUF_OUT_DATA_TYPE_HEX); + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] channel_div_table NULL.\r\n",TVar3,&DAT_230a9dd8,"hal_board.c" + ,0x25b); + } + } + pfVar15 = (fdt32_t *)fdt_getprop((void *)ble_tx_power,nodeoffset,"channel_cnt_table",&iStack188) + ; + if (iStack188 == 0x38) { + pfVar16 = pfVar15 + 0xe; + psVar12 = local_a0; + do { + x = *pfVar15; + pfVar15 = pfVar15 + 1; + autoconnect = fdt32_to_cpu(x); + *(short *)psVar12 = (short)autoconnect; + psVar12 = (size_t *)((int)psVar12 + 2); + } while (pfVar16 != pfVar15); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] channel_cnt_table :\r\n",TVar3,&DAT_230bd32c,"hal_board.c", + 0x263); + } + log_buf_out("hal_board.c",0x264,local_a0,0x38,LOG_BUF_OUT_DATA_TYPE_HEX); + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] channel_cnt_table NULL.\r\n",TVar3,&DAT_230a9dd8,"hal_board.c" + ,0x266); + } + } + pfVar15 = (fdt32_t *)fdt_getprop((void *)ble_tx_power,nodeoffset,"lo_fcal_div",&iStack188); + if (iStack188 == 4) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + x = *pfVar15; + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + autoconnect = fdt32_to_cpu(x); + bl_printk("[%10u][%s: %s:%4d] lo_fcal_div : %d\r\n",TVar3,&DAT_230bd32c,"hal_board.c",0x26c, + autoconnect & 0xffff); + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] lo_fcal_div NULL.\r\n",TVar3,&DAT_230a9dd8,"hal_board.c",0x26e + ); + } + } + } + nodeoffset = fdt_subnode_offset((void *)ble_tx_power,parentoffset,"mac"); + if (0 < nodeoffset) { + local_b4 = 0; + iVar4 = fdt_stringlist_count((void *)ble_tx_power,nodeoffset,"mode"); + if (iVar4 == 1) { + format = fdt_stringlist_get((void *)ble_tx_power,nodeoffset,"mode",0,(int *)&local_b4); + bl_printk("MAC address mode length %d\r\n",local_b4); + if ((int)local_b4 < 4) { + memcpy(&local_b0,format,local_b4); + local_b0 = local_b0 & 0xffffff; + bl_printk("MAC address mode is %s\r\n",&local_b0); + sVar5 = strlen((char *)&local_b0); + iVar4 = 0; + do { + if ((int)sVar5 <= iVar4) break; + cVar1 = *(char *)((int)&local_b0 + iVar4); + if (cVar1 == 'F') { + __src = fdt_getprop((void *)ble_tx_power,nodeoffset,"sta_mac_addr",(int *)local_a0); + if (local_a0[0] == 6) { + memcpy(&local_80,__src,6); + bl_wifi_sta_mac_addr_set((uint8_t *)&local_80); + __src = fdt_getprop((void *)ble_tx_power,nodeoffset,"ap_mac_addr",(int *)local_a0); + if (local_a0[0] == 6) { + memcpy(&local_80,__src,6); + bl_wifi_ap_mac_addr_set((uint8_t *)&local_80); + if (BLOG_LEVEL_DEBUG < _fsymc_level_hal_drv) goto LAB_2306858a; + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x9b; + format = "[%10u][%s: %s:%4d] get MAC from F ready\r\n"; + goto LAB_23068586; + } + goto LAB_23068594; + } + if (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) { + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x54; + format = "[%10u][%s: %s:%4d] ap_mac_addr NULL.\r\n"; + goto LAB_23068ac4; + } + goto LAB_23068ac8; + } + } + else { + if (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) { + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x47; + format = "[%10u][%s: %s:%4d] sta_mac_addr NULL.\r\n"; +LAB_23068ac4: + bl_printk(format,TVar3,&DAT_230a9dd8,"hal_board.c",uVar11); + } +LAB_23068ac8: + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x9e; + format = "[%10u][%s: %s:%4d] get MAC from F failed\r\n"; + goto LAB_2306829a; + } + } + } + } + else { + if (cVar1 == 'M') { + iVar8 = bl_efuse_read_mac_factory((uint8_t *)&local_80); + if (iVar8 == 0) { + if (((byte)(bStack123 | + bStack124 | + local_80._3_1_ | local_80._2_1_ | (byte)local_80 | local_80._1_1_) != 0) + && (((byte)local_80 & local_80._1_1_ & local_80._2_1_ & local_80._3_1_ & + bStack124 & bStack123) != 1)) { + if (BLOG_LEVEL_DEBUG < _fsymc_level_hal_drv) goto LAB_2306858a; + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0xa6; + format = "[%10u][%s: %s:%4d] get MAC from M ready\r\n"; + goto LAB_23068586; + } + goto LAB_23068594; + } + } + if ((BLOG_LEVEL_DEBUG < _fsymc_level_hal_drv) || + (BLOG_LEVEL_DEBUG < _fsymf_level_hal_drvhal_board)) goto LAB_2306829e; + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0xa9; + format = "[%10u][%s: %s:%4d] get MAC from M failed\r\n"; + } + else { + if (cVar1 != 'B') { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ASSERT: %s:%d\r\n",TVar3,&UNK_230b1c9c,"hal_board.c", + 0xaf,"hal_board.c",0xaf); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + bl_efuse_read_mac((uint8_t *)&local_80); + if (((byte)(bStack123 | + bStack124 | + local_80._3_1_ | local_80._2_1_ | (byte)local_80 | local_80._1_1_) != 0) && + (((byte)local_80 & local_80._1_1_ & local_80._2_1_ & local_80._3_1_ & bStack124 & + bStack123) != 1)) { + if (BLOG_LEVEL_DEBUG < _fsymc_level_hal_drv) goto LAB_2306858a; + if (BLOG_LEVEL_DEBUG < _fsymf_level_hal_drvhal_board) goto LAB_23068594; + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x90; + format = "[%10u][%s: %s:%4d] get MAC from B ready\r\n"; +LAB_23068586: + bl_printk(format,TVar3,"DEBUG ","hal_board.c",uVar11); + goto LAB_2306858a; + } + if ((BLOG_LEVEL_DEBUG < _fsymc_level_hal_drv) || + (BLOG_LEVEL_DEBUG < _fsymf_level_hal_drvhal_board)) goto LAB_2306829e; + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x93; + format = "[%10u][%s: %s:%4d] get MAC from B failed\r\n"; + } +LAB_2306829a: + bl_printk(format,TVar3,"DEBUG ","hal_board.c",uVar11); + } +LAB_2306829e: + iVar4 = iVar4 + 1; + } while (iVar4 != 3); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Using Default MAC address\r\n",TVar3,&DAT_230bd32c, + "hal_board.c",0xb5); + } + memcpy(&local_80,&mac_default_3792,6); +LAB_2306858a: + if (_fsymc_level_hal_drv < BLOG_LEVEL_WARN) { +LAB_23068594: + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Set MAC addrress %02X:%02X:%02X:%02X:%02X:%02X\r\n",TVar3, + &DAT_230bd32c,"hal_board.c",0xc0,local_80 & 0xff,local_80 >> 8 & 0xff, + local_80 >> 0x10 & 0xff); + } + } + bl_wifi_ap_mac_addr_set((uint8_t *)&local_80); + bl_wifi_sta_mac_addr_set((uint8_t *)&local_80); + } + } + } + nodeoffset = fdt_subnode_offset((void *)ble_tx_power,parentoffset,"region"); + if (0 < nodeoffset) { + pfVar15 = (fdt32_t *)fdt_getprop((void *)ble_tx_power,nodeoffset,"country_code",&iStack188); + if (iStack188 == 4) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + autoconnect = fdt32_to_cpu(*pfVar15); + bl_printk("[%10u][%s: %s:%4d] country_code : %d\r\n",TVar3,&DAT_230bd32c,"hal_board.c",0x27f + ,autoconnect & 0xff); + } + autoconnect = fdt32_to_cpu(*pfVar15); + bl_wifi_country_code_set((uint8_t)autoconnect); + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] country_code NULL.\r\n",TVar3,&DAT_230a9dd8,"hal_board.c", + 0x283); + } + } + } + nodeoffset = fdt_subnode_offset((void *)ble_tx_power,parentoffset,"brd_rf"); + if (nodeoffset < 1) goto LAB_23069298; + __src = fdt_getprop((void *)ble_tx_power,nodeoffset,"pwr_table_11b",&iStack188); + if (iStack188 == 0x10) { + iVar4 = 0; + do { + autoconnect = fdt32_to_cpu(*(fdt32_t *)(iVar4 * 4 + (int)__src)); + *(undefined *)((int)&local_80 + iVar4) = (char)autoconnect; + iVar4 = iVar4 + 1; + } while (iVar4 != 4); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table_11b :%u %u %u %u\r\n",TVar3,&DAT_230bd32c, + "hal_board.c",0x298,local_80 & 0xff,local_80 >> 8 & 0xff,local_80 >> 0x10 & 0xff); + } + bl_tpc_update_power_rate_11b((int8_t *)&local_80); + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table_11b NULL. lentmp = %d\r\n",TVar3,&DAT_230a9dd8, + "hal_board.c",0x29b,iStack188); + } + } + __src = fdt_getprop((void *)ble_tx_power,nodeoffset,"pwr_table_11g",&iStack188); + if (iStack188 == 0x20) { + iVar4 = 0; + do { + autoconnect = fdt32_to_cpu(*(fdt32_t *)(iVar4 * 4 + (int)__src)); + *(undefined *)((int)&local_80 + iVar4) = (char)autoconnect; + iVar4 = iVar4 + 1; + } while (iVar4 != 8); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table_11g :%u %u %u %u %u %u %u %u\r\n",TVar3,&DAT_230bd32c, + "hal_board.c",0x2ac,local_80 & 0xff,local_80 >> 8 & 0xff,local_80 >> 0x10 & 0xff); + } + bl_tpc_update_power_rate_11g((int8_t *)&local_80); + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table_11g NULL. lentmp = %d\r\n",TVar3,&DAT_230a9dd8, + "hal_board.c",0x2af,iStack188); + } + } + __src = fdt_getprop((void *)ble_tx_power,nodeoffset,"pwr_table_11n",&iStack188); + if (iStack188 == 0x20) { + iVar4 = 0; + do { + autoconnect = fdt32_to_cpu(*(fdt32_t *)(iVar4 * 4 + (int)__src)); + *(undefined *)((int)&local_80 + iVar4) = (char)autoconnect; + iVar4 = iVar4 + 1; + } while (iVar4 != 8); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table_11n :%u %u %u %u %u %u %u %u\r\n",TVar3,&DAT_230bd32c, + "hal_board.c",0x2c0,local_80 & 0xff,local_80 >> 8 & 0xff,local_80 >> 0x10 & 0xff); + } + bl_tpc_update_power_rate_11n((int8_t *)&local_80); + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table_11n NULL. lentmp = %d\r\n",TVar3,&DAT_230a9dd8, + "hal_board.c",0x2c3,iStack188); + } + } + sStack184 = 0; + iVar4 = fdt_stringlist_count((void *)ble_tx_power,nodeoffset,"pwr_mode"); + if (iVar4 != 1) goto LAB_23069298; + format = fdt_stringlist_get((void *)ble_tx_power,nodeoffset,"pwr_mode",0,(int *)&sStack184); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_mode length %d\r\n",TVar3,&DAT_230bd32c,"hal_board.c",0x1c1, + sStack184); + } + if (2 < (int)sStack184) goto LAB_23069298; + memcpy(local_c4,format,sStack184); + local_c4[2] = 0; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_mode is %s\r\n",TVar3,&DAT_230bd32c,"hal_board.c",0x1c5, + local_c4); + } + memset(&local_b0,0,0xe); + memset(local_a0,0,0xe); + sVar5 = strlen((char *)local_c4); + pbVar14 = local_c4; + iStack220 = 0; + iVar8 = 0; + do { + if ((int)sVar5 <= iVar8) break; + bVar2 = *pbVar14; + if (bVar2 == 0x46) { +LAB_23068e2a: + local_b4 = 0; + __src = fdt_getprop((void *)ble_tx_power,nodeoffset,"pwr_offset",(int *)&local_b4); + if (local_b4 != 0x38) { + if (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) { + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_offset NULL. lentmp = %d\r\n",TVar3,&DAT_230a9dd8, + "hal_board.c",0x15f,local_b4); + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x1a0; + format = "[%10u][%s: %s:%4d] get pwr offset from F(f) failed\r\n"; + goto LAB_23069178; + } + } + goto LAB_230690ee; + } + nodeoffset = 0; + do { + autoconnect = fdt32_to_cpu(*(fdt32_t *)(nodeoffset * 4 + (int)__src)); + *(undefined *)((int)local_a0 + nodeoffset) = (char)autoconnect; + nodeoffset = nodeoffset + 1; + } while (nodeoffset != 0xe); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_offset from dtb:\r\n",TVar3,&DAT_230bd32c,"hal_board.c", + 0x156); + } + log_buf_out("hal_board.c",0x157,local_a0,0xe,LOG_BUF_OUT_DATA_TYPE_HEX); + psVar12 = local_a0; + do { + psVar13 = (size_t *)((int)psVar12 + 1); + *(char *)psVar12 = *(char *)psVar12 + -10; + psVar12 = psVar13; + } while (asStack146 != psVar13); + if (_fsymc_level_hal_drv < BLOG_LEVEL_WARN) { + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_offset from dtb (rebase on %d):\r\n",TVar3,&DAT_230bd32c + ,"hal_board.c",0x15b,10); + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] get pwr offset from F(f) ready\r\n",TVar3,"DEBUG ", + "hal_board.c",399); + } + } + if (*pbVar14 == 0x42) { + nodeoffset = 0; + do { + *(undefined *)((int)&local_b0 + nodeoffset) = *(undefined *)((int)local_a0 + nodeoffset); + nodeoffset = nodeoffset + 1; + } while (nodeoffset != 0xe); + if ((BLOG_LEVEL_DEBUG < _fsymc_level_hal_drv) || + (BLOG_LEVEL_DEBUG < _fsymf_level_hal_drvhal_board)) goto LAB_23069274; + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x195; + pcVar10 = "DEBUG "; + format = "[%10u][%s: %s:%4d] Use pwr offset from F only\r\n"; + goto LAB_23069086; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Use pwr offset from f in incremental mode\r\n",TVar3,"DEBUG ", + "hal_board.c",0x199); + } + nodeoffset = 0; + psVar12 = &local_b0; + do { + format = (char *)((int)local_a0 + nodeoffset); + nodeoffset = nodeoffset + 1; + *(char *)psVar12 = *format + *(char *)psVar12; + psVar12 = (size_t *)((int)psVar12 + 1); + } while (nodeoffset != 0xe); + goto LAB_23069274; + } + if (bVar2 < 0x47) { + if (bVar2 != 0x42) { +LAB_230689ce: + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ASSERT: %s:%d\r\n",TVar3,&UNK_230b1c9c,"hal_board.c",0x1a6, + "hal_board.c",0x1a6); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + } + else { + if (bVar2 != 0x62) { + if (bVar2 != 0x66) goto LAB_230689ce; + goto LAB_23068e2a; + } + } + iVar9 = bl_efuse_read_pwroft((int8_t *)local_a0); + if (iVar9 != 0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x186; + format = "[%10u][%s: %s:%4d] get pwr offset from B(b) failed\r\n"; +LAB_23069178: + bl_printk(format,TVar3,"DEBUG ","hal_board.c",uVar11); + } + goto LAB_230690ee; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] get pwr offset from B(b) ready\r\n",TVar3,&DAT_230bd32c, + "hal_board.c",0x175); + } + log_buf_out("hal_board.c",0x176,local_a0,0xe,LOG_BUF_OUT_DATA_TYPE_INT8); + if (*pbVar14 == 0x42) goto LAB_23069032; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Use pwr offset from b in incremental mode\r\n",TVar3,"DEBUG ", + "hal_board.c",0x180); + } + psVar12 = &local_b0; + do { + format = (char *)((int)local_a0 + iVar9); + iVar9 = iVar9 + 1; + *(char *)psVar12 = *format + *(char *)psVar12; + psVar12 = (size_t *)((int)psVar12 + 1); + iStack220 = iVar4; + } while (iVar9 != 0xe); +LAB_230690ee: + iVar8 = iVar8 + 1; + pbVar14 = pbVar14 + 1; + } while (iVar8 != 2); + if (((iStack220 == 0) && (_fsymc_level_hal_drv < BLOG_LEVEL_WARN)) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x1ac; + pcVar10 = "\x1b[32mINFO \x1b[0m"; + format = "[%10u][%s: %s:%4d] Using Default pwr offset\r\n"; + goto LAB_23069086; + } +LAB_23069274: + log_buf_out("hal_board.c",0x1ae,&local_b0,0xe,LOG_BUF_OUT_DATA_TYPE_INT8); + ble_rf_set_pwr_offset(iStack170); + phy_powroffset_set((int8_t *)&local_b0); +LAB_23069298: + local_b0 = 0; + nodeoffset = fdt_subnode_offset((void *)ble_tx_power,parentoffset,"ap"); + if (0 < nodeoffset) { + iVar4 = fdt_stringlist_count((void *)ble_tx_power,nodeoffset,"ssid"); + if ((iVar4 == 1) && + (format = fdt_stringlist_get((void *)ble_tx_power,nodeoffset,"ssid",0,(int *)&local_b0), + local_b0 - 1 < 0x1f)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ap_ssid string[%d] = %s, ap_ssid_len = %d\r\n",TVar3, + &DAT_230bd32c,"hal_board.c",0x213,0,format,local_b0); + } + memcpy(local_a0,format,local_b0); + *(undefined *)((int)local_a0 + local_b0) = 0; + capin = (uint8_t)local_b0; + } + else { + capin = '\0'; + } + iVar4 = fdt_stringlist_count((void *)ble_tx_power,nodeoffset,"pwd"); + if ((iVar4 == 1) && + (format = fdt_stringlist_get((void *)ble_tx_power,nodeoffset,"pwd",0,(int *)&local_b0), + local_b0 - 1 < 0x1f)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ap_psk string[%d] = %s, ap_psk_len = %d\r\n",TVar3, + &DAT_230bd32c,"hal_board.c",0x21e,0,format,local_b0); + } + memcpy(&local_80,format,local_b0); + *(undefined *)((int)&local_80 + local_b0) = 0; + psk_len = (uint8_t)local_b0; + } + else { + psk_len = '\0'; + } + pfVar15 = (fdt32_t *)fdt_getprop((void *)ble_tx_power,nodeoffset,"ap_channel",(int *)&local_b0); + if (pfVar15 == (fdt32_t *)0x0) { + chan = '\0'; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (chan = '\0', _fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ap_channel NULL.\r\n",TVar3,&DAT_230a9dd8,"hal_board.c",0x22b) + ; + chan = '\0'; + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + autoconnect = fdt32_to_cpu(*pfVar15); + bl_printk("[%10u][%s: %s:%4d] ap_channel = %ld\r\n",TVar3,&DAT_230bd32c,"hal_board.c",0x227, + autoconnect); + } + autoconnect = fdt32_to_cpu(*pfVar15); + chan = (uint8_t)autoconnect; + } + bl_wifi_ap_info_set((uint8_t *)local_a0,capin,(uint8_t *)&local_80,psk_len,chan); + } + local_b0 = 0; + parentoffset = fdt_subnode_offset((void *)ble_tx_power,parentoffset,"sta"); + if (0 < parentoffset) { + nodeoffset = fdt_stringlist_count((void *)ble_tx_power,parentoffset,"ssid"); + if ((nodeoffset == 1) && + (format = fdt_stringlist_get((void *)ble_tx_power,parentoffset,"ssid",0,(int *)&local_b0), + local_b0 - 1 < 0x1f)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [STA] ap_ssid string[%d] = %s, ap_ssid_len = %d\r\n",TVar3, + &DAT_230bd32c,"hal_board.c",0x1df,0,format,local_b0); + } + memcpy(local_a0,format,local_b0); + *(undefined *)((int)local_a0 + local_b0) = 0; + capin = (uint8_t)local_b0; + } + else { + capin = '\0'; + } + nodeoffset = fdt_stringlist_count((void *)ble_tx_power,parentoffset,"pwd"); + if ((nodeoffset == 1) && + (format = fdt_stringlist_get((void *)ble_tx_power,parentoffset,"pwd",0,(int *)&local_b0), + local_b0 - 1 < 0x1f)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [STA] ap_psk string[%d] = %s, ap_psk_len = %d\r\n",TVar3, + &DAT_230bd32c,"hal_board.c",0x1ea,0,format,local_b0); + } + memcpy(&local_80,format,local_b0); + *(undefined *)((int)&local_80 + local_b0) = 0; + psk_len = (uint8_t)local_b0; + } + else { + psk_len = '\0'; + } + pfVar15 = (fdt32_t *) + fdt_getprop((void *)ble_tx_power,parentoffset,"auto_connect_enable",(int *)&local_b0); + autoconnect = 0; + if (pfVar15 != (fdt32_t *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + autoconnect = fdt32_to_cpu(*pfVar15); + bl_printk("[%10u][%s: %s:%4d] auto_connect_enable = %ld\r\n",TVar3,&DAT_230bd32c, + "hal_board.c",0x1f2,autoconnect); + } + autoconnect = fdt32_to_cpu(*pfVar15); + } + bl_wifi_sta_info_set((uint8_t *)local_a0,capin,(uint8_t *)&local_80,psk_len,autoconnect); + } + parentoffset = fdt_subnode_offset((void *)ble_tx_power,0,"bluetooth"); + if (((parentoffset < 1) && (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] bt NULL.\r\n",TVar3,&DAT_230a9dd8,"hal_board.c",0x2cd); + } + parentoffset = fdt_subnode_offset((void *)ble_tx_power,parentoffset,"brd_rf"); + if (0 < parentoffset) { + pfVar15 = (fdt32_t *)fdt_getprop((void *)ble_tx_power,parentoffset,"pwr_table_ble",&iStack188); + ble_tx_power = 0; + if (pfVar15 != (fdt32_t *)0x0) { + ble_tx_power = fdt32_to_cpu(*pfVar15); + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] set pwr_table_ble = %ld in dts\r\n",&DAT_230bd32c,"hal_board.c", + 0x2d9,ble_tx_power); + } + ble_controller_set_tx_pwr(ble_tx_power); + } + return 0; +LAB_23069032: + do { + *(undefined *)((int)&local_b0 + iVar9) = *(undefined *)((int)local_a0 + iVar9); + iVar9 = iVar9 + 1; + } while (iVar9 != 0xe); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) + { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x17c; + pcVar10 = "DEBUG "; + format = "[%10u][%s: %s:%4d] Use pwr offset from B only\r\n"; +LAB_23069086: + bl_printk(format,TVar3,pcVar10,"hal_board.c",uVar11); + } + goto LAB_23069274; +} + + + +// WARNING: Control flow encountered bad instruction data + +void bl_tsen_adc_get(void) + +{ + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +uint64_t bl_rtc_get_counter(void) + +{ + uint64_t in_fa0; + uint32_t uStack24; + uint32_t valLow; + uint32_t valHigh; + + HBN_Get_RTC_Timer_Val(&uStack24,&valLow); + return in_fa0; +} + + + +uint64_t bl_rtc_get_timestamp_ms(void) + +{ + uint64_t uVar1; + + uVar1 = bl_rtc_get_counter(); + return uVar1; +} + + + +int hal_wifi_start_firmware_task(void) + +{ + StackType_t wifi_fw_stack [1536]; + StaticTask_t wifi_fw_task; + + xTaskCreateStatic(wifi_main,"fw",0x600,(void *)0x0,0x1e,(StackType_t *)&ram0x42018be4, + (StaticTask_t *)&ram0x4201a3e4); + return 0; +} + + + +PtTable_Error_Type +PtTable_Update_Entry + (SPI_Flash_Cfg_Type *pFlashCfg,PtTable_ID_Type targetTableID,PtTable_Stuff_Config *ptStuff + ,PtTable_Entry_Config *ptEntry) + +{ + uint uVar1; + PtTable_Error_Type PVar2; + uint32_t len; + uint32_t uVar3; + undefined3 in_register_0000202d; + PtTable_Entry_Config *__dest; + PtTable_Entry_Config *dataIn; + uint32_t addr; + + if ((ptEntry == (PtTable_Entry_Config *)0x0) || (ptStuff == (PtTable_Stuff_Config *)0x0)) { + return PT_ERROR_PARAMETER; + } + dataIn = ptStuff->ptEntries; + PVar2 = PT_ERROR_TABLE_NOT_VALID; + if (CONCAT31(in_register_0000202d,targetTableID) != 2) { + addr = 0xe000; + if (CONCAT31(in_register_0000202d,targetTableID) != 0) { + addr = 0xf000; + } + uVar1 = 0; + __dest = dataIn; + while (uVar1 < (ptStuff->ptTable).entryCnt) { + if (__dest->type == ptEntry->type) { + memcpy(__dest,ptEntry,0x24); + break; + } + uVar1 = uVar1 + 1; + __dest = __dest + 1; + } + if ((uint)(ptStuff->ptTable).entryCnt == uVar1) { + if (0xf < uVar1) { + return PT_ERROR_ENTRY_UPDATE_FAIL; + } + memcpy(dataIn + uVar1,ptEntry,0x24); + (ptStuff->ptTable).entryCnt = (ptStuff->ptTable).entryCnt + 1; + } + (ptStuff->ptTable).age = (ptStuff->ptTable).age + 1; + len = BFLB_Soft_CRC32(ptStuff,0xc); + uVar1 = (uint)(ptStuff->ptTable).entryCnt; + (ptStuff->ptTable).crc32 = len; + len = uVar1 * 0x24; + uVar3 = BFLB_Soft_CRC32(dataIn,len); + *(uint32_t *)(dataIn + uVar1) = uVar3; + uVar1 = bl_flash_erase(addr,len + 0x14); + if ((uVar1 & 0xff) == 0) { + uVar1 = bl_flash_write(addr,(uint8_t *)ptStuff,0x254); + if ((uVar1 & 0xff) == 0) { + return (PtTable_Error_Type)(uVar1 & 0xff); + } + } + PVar2 = PT_ERROR_FALSH_WRITE; + } + return PVar2; +} + + + +PtTable_Error_Type +PtTable_Get_Active_Entries + (PtTable_Stuff_Config *ptStuff,PtTable_Entry_Type type,PtTable_Entry_Config *ptEntry) + +{ + undefined3 in_register_0000202d; + PtTable_Entry_Config *pPVar1; + uint uVar2; + + if (ptStuff == (PtTable_Stuff_Config *)0x0) { + return PT_ERROR_PARAMETER; + } + if (ptEntry != (PtTable_Entry_Config *)0x0) { + uVar2 = 0; + pPVar1 = ptStuff->ptEntries; + while( true ) { + if ((ptStuff->ptTable).entryCnt <= uVar2) { + return PT_ERROR_ENTRY_NOT_FOUND; + } + if ((uint)pPVar1->type == CONCAT31(in_register_0000202d,type)) break; + uVar2 = uVar2 + 1; + pPVar1 = pPVar1 + 1; + } + memcpy(ptEntry,ptStuff->ptEntries + uVar2,0x24); + return PT_ERROR_SUCCESS; + } + return PT_ERROR_PARAMETER; +} + + + +void int_timer_cb(void) + +{ + BaseType_t BVar1; + + TIMER_ClearIntStatus(TIMER_CH1,TIMER_COMP_ID_0); + BVar1 = xTaskIncrementTick(); + if (BVar1 != 0) { + vTaskSwitchContext(); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t bl_timer_now_us(void) + +{ + uint32_t uVar1; + + uVar1 = _DAT_0200bff8; + __udivdi3(); + return uVar1; +} + + + +int bl_timer_tick_enable(void) + +{ + TIMER_Chan_Type aTStack40 [4]; + TIMER_CFG_Type timerCh1Cfg; + + memcpy(aTStack40,&DAT_230c3054,0x18); + TIMER_IntMask(TIMER_CH1,TIMER_INT_ALL,MASK); + TIMER_Disable(aTStack40[0]); + TIMER_Init((TIMER_CFG_Type *)aTStack40); + TIMER_ClearIntStatus(aTStack40[0],TIMER_COMP_ID_0); + TIMER_ClearIntStatus(aTStack40[0],TIMER_COMP_ID_1); + TIMER_ClearIntStatus(aTStack40[0],TIMER_COMP_ID_2); + TIMER_IntMask(aTStack40[0],TIMER_INT_COMP_0,UNMASK); + TIMER_IntMask(aTStack40[0],TIMER_INT_COMP_1,MASK); + TIMER_IntMask(aTStack40[0],TIMER_INT_COMP_2,MASK); + TIMER_Enable(aTStack40[0]); + bl_irq_enable(0x35); + bl_irq_register(0x35,int_timer_cb); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bl_gpio_enable_output(uint8_t pin,uint8_t pullup,uint8_t pulldown) + +{ + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + uint8_t uStack24; + uint8_t uStack23; + uint8_t uStack22; + uint8_t uStack21; + GLB_GPIO_Cfg_Type cfg; + + cfg._0_2_ = 0x100; + uStack23 = '\v'; + uStack22 = '\x01'; + if (CONCAT31(in_register_0000202d,pullup) == 0) { + uStack21 = '\x02'; + } + else { + uStack21 = '\0'; + } + if (CONCAT31(in_register_00002031,pulldown) != 0) { + uStack21 = '\x01'; + } + uStack24 = pin; + GLB_GPIO_Init((GLB_GPIO_Cfg_Type *)&uStack24); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bl_gpio_enable_input(uint8_t pin,uint8_t pullup,uint8_t pulldown) + +{ + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + uint8_t uStack24; + uint8_t uStack23; + uint8_t uStack22; + uint8_t uStack21; + GLB_GPIO_Cfg_Type cfg; + + cfg._0_2_ = 0x100; + uStack23 = '\v'; + uStack22 = '\0'; + if (CONCAT31(in_register_0000202d,pullup) == 0) { + uStack21 = '\x02'; + } + else { + uStack21 = '\0'; + } + if (CONCAT31(in_register_00002031,pulldown) != 0) { + uStack21 = '\x01'; + } + uStack24 = pin; + GLB_GPIO_Init((GLB_GPIO_Cfg_Type *)&uStack24); + return 0; +} + + + +int bl_gpio_output_set(uint8_t pin,uint8_t value) + +{ + undefined3 in_register_0000202d; + + GLB_GPIO_Write(pin,(uint)(CONCAT31(in_register_0000202d,value) != 0)); + return 0; +} + + + +int bl_gpio_input_get(uint8_t pin,uint8_t *value) + +{ + uint32_t uVar1; + + uVar1 = GLB_GPIO_Read(pin); + *value = (uint8_t)uVar1; + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int bl_flash_erase(uint32_t addr,int len) + +{ + if (boot2_flashCfg.flashCfg.mid != '\0') { + (*_DAT_21010ab0)(0x4200f204,addr,len,_DAT_21010ab0); + return 0; + } + return -1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int bl_flash_write(uint32_t addr,uint8_t *src,int len) + +{ + if (boot2_flashCfg.flashCfg.mid != '\0') { + (*_DAT_21010aac)(0x4200f204,addr,src,len,_DAT_21010aac); + return 0; + } + return -1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int bl_flash_read(uint32_t addr,uint8_t *dst,int len) + +{ + if (boot2_flashCfg.flashCfg.mid != '\0') { + (*_DAT_21010aa8)(0x4200f204,addr,dst,len,_DAT_21010aa8); + return 0; + } + return -1; +} + + + +undefined4 bl_flash_config_update(void) + +{ + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ======= FlashCfg magiccode @%p, code 0x%08lX =======\r\n", + &DAT_230bd32c,"bl_flash.c",0x60,&__boot2_flashCfg_src,boot2_flashCfg.magic); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN) + ) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] mid \t\t0x%X\r\n",&DAT_230bd32c,"bl_flash.c",0x61, + (uint)boot2_flashCfg.flashCfg.mid); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] clkDelay \t0x%X\r\n",&DAT_230bd32c,"bl_flash.c",0x62, + (uint)boot2_flashCfg.flashCfg.clkDelay); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] clkInvert \t0x%X\r\n",&DAT_230bd32c,"bl_flash.c",99, + (uint)boot2_flashCfg.flashCfg.clkInvert); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] sector size\t%uKBytes\r\n",&DAT_230bd32c,"bl_flash.c",100, + (uint)boot2_flashCfg.flashCfg.sectorSize); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] page size\t%uBytes\r\n",&DAT_230bd32c,"bl_flash.c",0x65, + (uint)boot2_flashCfg.flashCfg.pageSize); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] ---------------------------------------------------------------\r\n" + ,&DAT_230bd32c,"bl_flash.c",0x66); + } + } + } + } + } + } + } + return 0; +} + + + +void * bl_flash_get_flashCfg(void) + +{ + return &boot2_flashCfg.flashCfg; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void bl_wdt_feed(void) + +{ + _DAT_4000a598 = _DAT_4000a598 | 1; + _DAT_4000a59c = _DAT_4000a59c & 0xffff0000 | 0xbaba; + _DAT_4000a5a0 = _DAT_4000a5a0 & 0xffff0000 | 0xeb10; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void bl_wdt_disable(void) + +{ + _DAT_4000a564 = _DAT_4000a564 & 0xfffffffe; + _DAT_4000a59c = _DAT_4000a59c & 0xffff0000 | 0xbaba; + _DAT_4000a5a0 = _DAT_4000a5a0 & 0xffff0000 | 0xeb10; + return; +} + + + +int bl_wdt_init(int ms) + +{ + if (ms < 0xfff) { + WDT_Disable(); + WDT_Set_Clock(TIMER_CLKSRC_32K,'\x01'); + WDT_SetCompValue((uint16_t)((uint)(ms << 0x14) >> 0x10)); + WDT_ResetCounterValue(); + WDT_IntMask(WDT_INT,MASK); + WDT_Enable(); + return 0; + } + return -1; +} + + + +void proc_entry_looprt(void *pvParameters) + +{ + bloop_run(&looprt); + do { + puts("--->>> Error terminated looprt\r\n"); + vTaskDelay(1000); + } while( true ); +} + + + +void looprt_evt_notify_async(uint task,uint32_t evt_map) + +{ + bloop_evt_set_async(&looprt,task,evt_map); + return; +} + + + +void looprt_evt_status_dump(void) + +{ + bloop_status_dump(&looprt); + return; +} + + + +void looprt_evt_schedule(int task,uint32_t evt_map,int delay_ms) + +{ + loop_timer *timer; + + timer = (loop_timer *)pvPortMalloc(0x24); + if (timer != (loop_timer *)0x0) { + bloop_timer_init(timer,1); + bloop_timer_configure + (timer,delay_ms,(anon_subr_void_loop_ctx_ptr_loop_timer_ptr_void_ptr *)0x0,(void *)0x0 + ,task,evt_map); + bloop_timer_register(&looprt,timer); + return; + } + return; +} + + + +int looprt_start(StackType_t *proc_stack_looprt,int stack_count,StaticTask_t *proc_task_looprt) + +{ + bloop_init(&looprt); + bloop_handler_register(&looprt,&bloop_handler_sys,0x1f); + looprt_evt_status_dump(); + xTaskCreateStatic(proc_entry_looprt,"bloop_rt",stack_count,(void *)0x0,0x1a,proc_stack_looprt, + proc_task_looprt); + bloop_wait_startup(&looprt); + return 0; +} + + + +int looprt_start_auto(void) + +{ + bloop_init(&looprt); + bloop_handler_register(&looprt,&bloop_handler_sys,0x1f); + looprt_evt_status_dump(); + xTaskCreate(proc_entry_looprt,"bloop_rt",0x1000,(void *)0x0,0x1a,(TaskHandle_t *)0x0); + bloop_wait_startup(&looprt); + return 0; +} + + + +int looprt_handler_register(loop_evt_handler *handler,int priority) + +{ + int iVar1; + + if (looprt.looper != (TaskHandle_t)0x0) { + iVar1 = bloop_handler_register(&looprt,handler,priority); + return iVar1; + } + return -1; +} + + + +int looprt_timer_register(loop_timer *timer) + +{ + bloop_timer_register(&looprt,timer); + return 0; +} + + + +void cmd_looprt_test(char *buf,int len,int argc,char **argv) + +{ + puts("====== looprt test ======\r\n"); + printf("struct loop_ctx size is %d\r\n",0x4a0); + printf("MSG size is %d\r\n",0x18); + looprt_start_auto(); + return; +} + + + +void cmd_looprt_test_status(char *buf,int len,int argc,char **argv) + +{ + puts("====== looprt test status ======\r\n"); + looprt_evt_status_dump(); + return; +} + + + +void cmd_looprt_test_evt(char *buf,int len,int argc,char **argv) + +{ + puts("====== looprt EVT ======\r\n"); + looprt_evt_notify_async(0x1f,0); + return; +} + + + +void cmd_looprt_test_evt_dump(char *buf,int len,int argc,char **argv) + +{ + puts("====== looprt EVT status ======\r\n"); + looprt_evt_notify_async(0x1f,1); + return; +} + + + +void cmd_looprt_test_schedule_evt1(char *buf,int len,int argc,char **argv) + +{ + puts("====== looprt Schedule EVT1 ======\r\n"); + looprt_evt_schedule(0x1f,1,20000); + return; +} + + + +void cmd_looprt_test_schedule_evt2(char *buf,int len,int argc,char **argv) + +{ + puts("====== looprt Schedule EVT2 ======\r\n"); + looprt_evt_schedule(0x1f,1,10000); + return; +} + + + +int looprt_test_cli_init(void) + +{ + return 0; +} + + + +void _cb_led_trigger(loop_ctx *loop,loop_timer *timer,void *arg) + +{ + TickType_t TVar1; + undefined *puVar2; + + bl_gpio_output_set(*(uint8_t *)((int)arg + 0x30),*(int *)((int)arg + 0x38) != 0); + if ((_fsymc_level_loopset < BLOG_LEVEL_INFO) && + (_fsymf_level_loopsetloopset_led < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + if (*(int *)((int)arg + 0x38) == 0) { + puVar2 = &DAT_230c21a8; + } + else { + puVar2 = &DAT_230c21a4; + } + bl_printk("[%10u][%s: %s:%4d] [LED] [CB] Set pin %d to %s\r\n",TVar1,"DEBUG ","loopset_led.c", + 0x95,*(undefined4 *)((int)arg + 0x30),puVar2); + } + *(uint *)((int)arg + 0x38) = (uint)(*(int *)((int)arg + 0x38) == 0); + return; +} + + + +int _led_bloop_msg(loop_ctx *loop,loop_evt_handler *handler,loop_msg *msg) + +{ + TickType_t TVar1; + + if ((_fsymc_level_loopset < BLOG_LEVEL_INFO) && + (_fsymf_level_loopsetloopset_led < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] [LED] [MSG] called with msg info\r\n priority %u\r\n dst %u\r\n msgid %u\r\n src %u\r\n arg1 %p\r\n arg2 %p\r\n" + ,TVar1,"DEBUG ","loopset_led.c",0x78,(uint)*(byte *)&msg->u, + (uint)*(byte *)((int)&msg->u + 1),(uint)*(byte *)((int)&msg->u + 2)); + return 0; + } + return 0; +} + + + +int _led_bloop_evt(loop_ctx *loop,loop_evt_handler *handler,uint32_t *bitmap_evt, + uint32_t *evt_type_map) + +{ + char **ppcVar1; + uint uVar2; + TickType_t TVar3; + char *pcVar4; + undefined *puVar5; + char *pcVar6; + char **ppcVar7; + char **ppcVar8; + + uVar2 = *evt_type_map; + do { + if ((uVar2 & 1) == 0) { + if ((uVar2 & 2) == 0) { + if (uVar2 != 0) { + printf("[ASSERT] [ERR] %s:%d\r\n","loopset_led.c",0x5e); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + break; + } + pcVar6 = handler[1].name; + ppcVar7 = (char **)0x0; + ppcVar1 = *(char ***)(pcVar6 + 0xc); + if (ppcVar1 != (char **)0x0) { + ppcVar7 = (char **)ppcVar1[1]; + } + while (ppcVar8 = ppcVar7, ppcVar1 != (char **)(pcVar6 + 8)) { + if ((_fsymc_level_loopset < BLOG_LEVEL_WARN) && + (_fsymf_level_loopsetloopset_led < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(loop); + } + puVar5 = &DAT_230c21a4; + if (ppcVar1[0xd] == (char *)0x0) { + puVar5 = &DAT_230c21a8; + } + pcVar4 = "Hearbeat"; + if (ppcVar1[0xb] == (char *)0x0) { + pcVar4 = "Blink"; + } + bl_printk("[%10u][%s: %s:%4d] [LED] New Trigger: PIN %d, active level %s, type %s\r\n", + TVar3,&DAT_230bd32c,"loopset_led.c",0x4b,ppcVar1[0xc],puVar5,pcVar4); + } + loop = (loop_ctx *)looprt_timer_register((loop_timer *)(ppcVar1 + 2)); + ppcVar7 = (char **)ppcVar1[1]; + pcVar4 = *ppcVar1; + *(char ***)(pcVar4 + 4) = ppcVar7; + *ppcVar7 = pcVar4; + ppcVar7 = *(char ***)(pcVar6 + 4); + *ppcVar1 = pcVar6; + *(char ***)(ppcVar1 + 1) = ppcVar7; + *(char ***)(pcVar6 + 4) = ppcVar1; + *(char ***)ppcVar7 = ppcVar1; + ppcVar1 = ppcVar8; + ppcVar7 = (char **)0x0; + if (ppcVar8 != (char **)0x0) { + ppcVar7 = (char **)ppcVar8[1]; + } + } + uVar2 = uVar2 & 0xfffffffd; + } + else { + uVar2 = uVar2 & 0xfffffffe; + } + } while (uVar2 != 0); + *evt_type_map = 0; + return 0; +} + + + +int loopset_led_hook_on_looprt(void) + +{ + loop_evt_handler_holder _led_bloop_handler_holder; + int iVar1; + + led_ctx.trigger_queue.next = &led_ctx; + led_ctx.trigger_queue.prev = &led_ctx; + led_ctx.waiting_queue.next = (utils_dlist_s *)&led_ctx.waiting_queue; + led_ctx.waiting_queue.prev = (utils_dlist_s *)&led_ctx.waiting_queue; + iVar1 = looprt_handler_register((loop_evt_handler *)(loop_evt_handler_holder *)&ram0x230c34b0,1); + return iVar1; +} + + + +void loopset_led_trigger(int pin,uint timeon_ms) + +{ + utils_dlist_s **ppuVar1; + loop_timer *timer; + utils_dlist_s *__s; + TickType_t TVar2; + + __s = (utils_dlist_s *)pvPortMalloc(0x3c); + if (__s == (utils_dlist_s *)0x0) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ASSERT: %s:%d\r\n",TVar2,&UNK_230b1c9c,"loopset_led.c",0x9e, + "loopset_led.c",0x9e); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + memset(__s,0,0x3c); + timer = (loop_timer *)(__s + 1); + *(int *)&__s[6].prev = pin; + bloop_timer_init(timer,0); + bloop_timer_repeat_enable(timer); + bloop_timer_configure(timer,timeon_ms,_cb_led_trigger,__s,1,1); + bl_gpio_enable_output((uint8_t)pin,'\0','\0'); + vTaskEnterCritical(); + __s->prev = (utils_dlist_s *)0x4201a8ec; + __s->next = led_ctx.waiting_queue.next; + ppuVar1 = &(led_ctx.waiting_queue.next)->prev; + led_ctx.waiting_queue.next = __s; + *ppuVar1 = __s; + vTaskExitCritical(); + looprt_evt_notify_async(1,2); + return; +} + + + +err_t sys_mbox_new(sys_mbox_t *mbox,int size) + +{ + QueueHandle_t pQVar1; + u16_t uVar2; + + pQVar1 = xQueueGenericCreate(0x32,4,'\0'); + *(QueueHandle_t *)mbox = pQVar1; + uVar2 = (u16_t)(((uint)lwip_stats.sys.mbox.used + 1) * 0x10000 >> 0x10); + if ((uint)lwip_stats.sys.mbox.max < ((uint)lwip_stats.sys.mbox.used + 1 & 0xffff)) { + lwip_stats.sys.mbox.max = uVar2; + } + lwip_stats.sys.mbox.used = uVar2; + return (err_t)-(*mbox == (sys_mbox_t)0x0); +} + + + +void sys_mbox_free(sys_mbox_t *mbox) + +{ + UBaseType_t UVar1; + + UVar1 = uxQueueMessagesWaiting((QueueHandle_t)*mbox); + if (UVar1 != 0) { + lwip_stats.sys.mbox.err = lwip_stats.sys.mbox.err + 1; + } + vQueueDelete((QueueHandle_t)*mbox); + lwip_stats.sys.mbox.used = lwip_stats.sys.mbox.used - 1; + return; +} + + + +void sys_mbox_post(sys_mbox_t *mbox,void *data) + +{ + BaseType_t BVar1; + void *apvStack20 [2]; + + apvStack20[0] = data; + do { + BVar1 = xQueueGenericSend((QueueHandle_t)*mbox,apvStack20,0xffffffff,0); + } while (BVar1 != 1); + return; +} + + + +err_t sys_mbox_trypost(sys_mbox_t *mbox,void *msg) + +{ + err_t eVar1; + BaseType_t BVar2; + void *apvStack20 [4]; + + apvStack20[0] = msg; + BVar2 = xQueueGenericSend((QueueHandle_t)*mbox,apvStack20,0,0); + if (BVar2 == 1) { + eVar1 = '\0'; + } + else { + eVar1 = -1; + lwip_stats.sys.mbox.err = lwip_stats.sys.mbox.err + 1; + } + return eVar1; +} + + + +u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox,void **msg,u32_t timeout) + +{ + TickType_t TVar1; + BaseType_t BVar2; + TickType_t TVar3; + void *local_24; + void *dummyptr; + + TVar1 = xTaskGetTickCount(); + if (msg == (void **)0x0) { + msg = &local_24; + } + if (timeout == 0) { + do { + BVar2 = xQueueReceive((QueueHandle_t)*mbox,msg,0xffffffff); + } while (BVar2 != 1); + } + else { + BVar2 = xQueueReceive((QueueHandle_t)*mbox,msg,timeout); + if (BVar2 != 1) { + *msg = (void *)0x0; + return 0xffffffff; + } + } + TVar3 = xTaskGetTickCount(); + return TVar3 - TVar1; +} + + + +u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox,void **msg) + +{ + BaseType_t BVar1; + void *pvStack20; + void *dummyptr; + + if (msg == (void **)0x0) { + msg = &pvStack20; + } + BVar1 = xQueueReceive((QueueHandle_t)*mbox,msg,0); + return -(uint)(BVar1 != 1); +} + + + +uint sys_mbox_valid(int *param_1) + +{ + return (uint)(*param_1 != 0); +} + + + +void sys_mbox_set_invalid(undefined4 *param_1) + +{ + *param_1 = 0; + return; +} + + + +err_t sys_sem_new(sys_sem_t *sem,u8_t count) + +{ + err_t eVar1; + QueueHandle_t xQueue; + undefined3 in_register_0000202d; + uint uVar2; + + xQueue = xQueueGenericCreate(1,0,'\x03'); + *(QueueHandle_t *)sem = xQueue; + if (xQueue != (QueueHandle_t)0x0) { + xQueueGenericSend(xQueue,(void *)0x0,0,0); + } + if ((QueueHandle_t)*sem == (QueueHandle_t)0x0) { + lwip_stats.sys.sem.err = lwip_stats.sys.sem.err + 1; + eVar1 = -1; + } + else { + if (CONCAT31(in_register_0000202d,count) == 0) { + xQueueSemaphoreTake((QueueHandle_t)*sem,1); + } + uVar2 = (uint)lwip_stats.sys.sem.used; + lwip_stats.sys.sem.used = (u16_t)((uVar2 + 1) * 0x10000 >> 0x10); + eVar1 = '\0'; + if ((uint)lwip_stats.sys.sem.max < (uVar2 + 1 & 0xffff)) { + eVar1 = '\0'; + lwip_stats.sys.sem.max = lwip_stats.sys.sem.used; + } + } + return eVar1; +} + + + +u32_t sys_arch_sem_wait(sys_sem_t *sem,u32_t timeout) + +{ + TickType_t TVar1; + BaseType_t BVar2; + TickType_t TVar3; + + TVar1 = xTaskGetTickCount(); + if (timeout == 0) { + do { + BVar2 = xQueueSemaphoreTake((QueueHandle_t)*sem,0xffffffff); + } while (BVar2 != 1); + } + else { + BVar2 = xQueueSemaphoreTake((QueueHandle_t)*sem,timeout); + if (BVar2 != 1) { + return 0xffffffff; + } + } + TVar3 = xTaskGetTickCount(); + return TVar3 - TVar1; +} + + + +void sys_sem_free(sys_sem_t *sem) + +{ + lwip_stats.sys.sem.used = lwip_stats.sys.sem.used - 1; + vQueueDelete((QueueHandle_t)*sem); + return; +} + + + +int sys_sem_valid(sys_sem_t *sem) + +{ + return (uint)(*sem != (sys_sem_t)0x0); +} + + + +void sys_sem_set_invalid(sys_sem_t *sem) + +{ + *sem = (sys_sem_t)0x0; + return; +} + + + +void sys_init(void) + +{ + s_nextthread = 0; + return; +} + + + +err_t sys_mutex_new(sys_mutex_t *mutex) + +{ + err_t eVar1; + QueueHandle_t pQVar2; + uint uVar3; + + pQVar2 = xQueueCreateMutex('\x01'); + *(QueueHandle_t *)mutex = pQVar2; + if (pQVar2 == (QueueHandle_t)0x0) { + lwip_stats.sys.mutex.err = lwip_stats.sys.mutex.err + 1; + eVar1 = -1; + } + else { + uVar3 = (uint)lwip_stats.sys.mutex.used; + lwip_stats.sys.mutex.used = (u16_t)((uVar3 + 1) * 0x10000 >> 0x10); + eVar1 = '\0'; + if ((uint)lwip_stats.sys.mutex.max < (uVar3 + 1 & 0xffff)) { + eVar1 = '\0'; + lwip_stats.sys.mutex.max = lwip_stats.sys.mutex.used; + } + } + return eVar1; +} + + + +void sys_mutex_lock(sys_mutex_t *mutex) + +{ + sys_arch_sem_wait((sys_sem_t *)mutex,0); + return; +} + + + +void sys_mutex_unlock(sys_mutex_t *mutex) + +{ + xQueueGenericSend((QueueHandle_t)*mutex,(void *)0x0,0,0); + return; +} + + + +void sys_sem_signal(sys_mutex_t *mutex) + +{ + xQueueGenericSend((QueueHandle_t)*mutex,(void *)0x0,0,0); + return; +} + + + +sys_thread_t sys_thread_new(char *name,lwip_thread_fn *thread,void *arg,int stacksize,int prio) + +{ + BaseType_t BVar1; + TaskHandle_t ptStack20; + TaskHandle_t CreatedTask; + + if (s_nextthread < 6) { + BVar1 = xTaskCreate((TaskFunction_t *)thread,name,(uint16_t)stacksize,arg,prio,&ptStack20); + if (BVar1 != 1) { + ptStack20 = (sys_thread_t)0x0; + } + return ptStack20; + } + return (sys_thread_t)0x0; +} + + + +sys_prot_t sys_arch_protect(void) + +{ + vTaskEnterCritical(); + return 1; +} + + + +void sys_arch_unprotect(void) + +{ + if ((xSchedulerRunning != 0) && (pxCurrentTCB->uxCriticalNesting != 0)) { + vTaskExitCritical(); + return; + } + return; +} + + + +TickType_t sys_now(void) + +{ + return xTickCount; +} + + + +// WARNING: Variable defined which should be unmapped: addr + +hostent * lwip_gethostbyname(char *name) + +{ + char *s_aliases; + ip_addr_t s_hostent_addr; + ip_addr_t *s_phostent_addr [2]; + hostent s_hostent; + char s_hostname [257]; + err_t eVar1; + undefined3 extraout_var; + hostent *phVar2; + ip_addr_t iStack20; + ip_addr_t addr; + + eVar1 = netconn_gethostbyname(name,&iStack20); + if (CONCAT31(extraout_var,eVar1) == 0) { + s_hostent_addr = (u32_t)iStack20; + s_phostent_addr[0] = (ip_addr_t *)0x4200f5b8; + s_phostent_addr[1] = (ip_addr_t *)0x0; + strncpy((char *)0x4201a908,name,0x100); + phVar2 = (hostent *)0x4201a8f4; + } + else { + h_errno = 0xd2; + phVar2 = (hostent *)0x0; + } + return phVar2; +} + + + +err_t netifapi_do_netif_add(tcpip_api_call_data *m) + +{ + err_t eVar1; + netif *pnVar2; + + pnVar2 = netif_add(*(netif **)(m + 1),(ip4_addr_t *)m[1].sem,*(ip4_addr_t **)(m + 2), + (ip4_addr_t *)m[2].sem,*(void **)(m + 3),(netif_init_fn_conflict *)m[3].sem, + *(netif_input_fn **)(m + 4)); + if (pnVar2 == (netif *)0x0) { + eVar1 = -0xc; + } + else { + eVar1 = '\0'; + } + return eVar1; +} + + + +err_t netifapi_do_netif_set_addr(tcpip_api_call_data *m) + +{ + netif_set_addr(*(netif **)(m + 1),(ip4_addr_t *)m[1].sem,*(ip4_addr_t **)(m + 2), + (ip4_addr_t *)m[2].sem); + return '\0'; +} + + + +err_t netifapi_do_netif_common(tcpip_api_call_data *m) + +{ + err_t eVar1; + + if (*(code **)(m + 2) != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x2306a8da. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (**(code **)(m + 2))(); + return eVar1; + } + (*(code *)m[1].sem)(*(undefined4 *)(m + 1),m[1].sem); + return '\0'; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netifapi_netif_add(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw, + void *state,netif_init_fn init,netif_input_fn *input) + +{ + err_t eVar1; + undefined auStack52 [4]; + netifapi_msg msg; + + if (ipaddr == (ip4_addr_t *)0x0) { + ipaddr = (ip4_addr_t *)&ip_addr_any; + } + if (netmask == (ip4_addr_t *)0x0) { + netmask = (ip4_addr_t *)&ip_addr_any; + } + if (gw == (ip4_addr_t *)0x0) { + gw = (ip4_addr_t *)&ip_addr_any; + } + msg.call.sem = (sys_sem_t)netif; + msg.netif = (netif *)ipaddr; + msg.msg._0_4_ = netmask; + msg.msg._4_4_ = gw; + msg.msg._8_4_ = state; + msg.msg._12_4_ = init; + msg.msg._16_4_ = input; + eVar1 = tcpip_api_call(netifapi_do_netif_add,(tcpip_api_call_data *)auStack52); + return eVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netifapi_netif_set_addr(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw) + +{ + err_t eVar1; + undefined auStack52 [4]; + netifapi_msg msg; + + if (ipaddr == (ip4_addr_t *)0x0) { + ipaddr = (ip4_addr_t *)&ip_addr_any; + } + if (netmask == (ip4_addr_t *)0x0) { + netmask = (ip4_addr_t *)&ip_addr_any; + } + if (gw == (ip4_addr_t *)0x0) { + gw = (ip4_addr_t *)&ip_addr_any; + } + msg.call.sem = (sys_sem_t)netif; + msg.netif = (netif *)ipaddr; + msg.msg._0_4_ = netmask; + msg.msg._4_4_ = gw; + eVar1 = tcpip_api_call(netifapi_do_netif_set_addr,(tcpip_api_call_data *)auStack52); + return eVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netifapi_netif_common(netif *netif,netifapi_void_fn voidfunc,netifapi_errt_fn errtfunc) + +{ + err_t eVar1; + undefined auStack52 [4]; + netifapi_msg msg; + + msg.call.sem = (sys_sem_t)netif; + msg.netif = (netif *)voidfunc; + msg.msg._0_4_ = errtfunc; + eVar1 = tcpip_api_call(netifapi_do_netif_common,(tcpip_api_call_data *)auStack52); + return eVar1; +} + + + +int alloc_socket(netconn *newconn,int accepted) + +{ + int iVar1; + u16_t uVar2; + lwip_sock *plVar3; + + uVar2 = (u16_t)accepted; + plVar3 = sockets; + iVar1 = 0; + do { + sys_arch_protect(); + if (plVar3->conn == (netconn *)0x0) { + sockets[iVar1].conn = newconn; + sys_arch_unprotect(); + sockets[iVar1].lastdata = 0; + sockets[iVar1].rcvevent = 0; + if ((newconn->type & 0xf0) != NETCONN_TCP) { + uVar2 = 1; + } + sockets[iVar1].sendevent = uVar2; + sockets[iVar1].errevent = 0; + return iVar1; + } + iVar1 = iVar1 + 1; + sys_arch_unprotect(); + plVar3 = plVar3 + 1; + } while (iVar1 != 0x15); + return -1; +} + + + +ssize_t lwip_recv_tcp(lwip_sock *sock,void *mem,size_t len,int flags) + +{ + size_t len_00; + err_t err; + pbuf *ppVar1; + undefined3 extraout_var; + int iVar2; + void *dataptr; + u8_t apiflags; + uint uVar3; + pbuf *ppStack52; + pbuf *p; + + if ((int)len < 0) { + len = 0x7fffffff; + } + apiflags = '\b'; + if ((flags & 8U) != 0) { + apiflags = '\f'; + } + len_00 = 0; + do { + ppVar1 = (pbuf *)sock->lastdata; + if ((pbuf *)sock->lastdata == (pbuf *)0x0) { + err = netconn_recv_tcp_pbuf_flags(sock->conn,&ppStack52,apiflags); + if (CONCAT31(extraout_var,err) != 0) { + if (len_00 == 0) { + iVar2 = err_to_errno(err); + if (iVar2 != 0) { + errno = iVar2; + } + return -(uint)(CONCAT31(extraout_var,err) != -0xf); + } + if ((flags & 1U) != 0) { + return len_00; + } + goto LAB_2306aa9e; + } + *(pbuf **)&sock->lastdata = ppStack52; + ppVar1 = ppStack52; + } + ppStack52 = ppVar1; + uVar3 = (uint)ppStack52->tot_len; + if ((int)len <= (int)uVar3) { + uVar3 = len & 0xffff; + } + dataptr = (void *)((int)mem + len_00); + len_00 = uVar3 + len_00; + pbuf_copy_partial(ppStack52,dataptr,(u16_t)uVar3,0); + if ((flags & 1U) != 0) { + if (len_00 != 0) { + return len_00; + } + goto LAB_2306ab0e; + } + if ((int)(ppStack52->tot_len - uVar3) < 1) { + sock->lastdata = 0; + pbuf_free(ppStack52); + } + else { + ppVar1 = pbuf_free_header(ppStack52,(u16_t)uVar3); + *(pbuf **)&sock->lastdata = ppVar1; + } + len = len - uVar3; + apiflags = '\x1c'; + } while (0 < (int)len); + if (len_00 == 0) { +LAB_2306ab0e: + len_00 = 0; + } + else { +LAB_2306aa9e: + netconn_tcp_recvd(sock->conn,len_00); + } + return len_00; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int lwip_sock_make_addr(u16_t port,sockaddr *from,socklen_t *fromlen) + +{ + int iVar1; + undefined2 in_register_0000202a; + size_t *in_a3; + uint uVar2; + undefined2 uStack32; + u16_t uStack30; + sockaddr_aligned saddr; + + uStack32 = 0x210; + uStack30 = lwip_htons((u16_t)from); + saddr._0_4_ = *(undefined4 *)CONCAT22(in_register_0000202a,port); + memset(saddr + 4,0,8); + uVar2 = (uint)(byte)uStack32; + iVar1 = 1; + if ((uVar2 <= *in_a3) && (iVar1 = 0, uVar2 < *in_a3)) { + *in_a3 = uVar2; + } + memcpy(fromlen,&uStack32,*in_a3); + return iVar1; +} + + + +void free_socket(lwip_sock *sock,int is_tcp) + +{ + netbuf *buf; + netconn *conn; + + sys_arch_protect(); + buf = (netbuf *)sock->lastdata; + conn = sock->conn; + sock->lastdata = 0; + sock->conn = (netconn *)0x0; + sys_arch_unprotect(); + if (buf != (netbuf *)0x0) { + if (is_tcp == 0) { + netbuf_delete(buf); + } + else { + pbuf_free((pbuf *)buf); + } + } + if (conn != (netconn *)0x0) { + netconn_delete(conn); + return; + } + return; +} + + + +err_t lwip_recvfrom_udp_raw(lwip_sock *sock,int flags,msghdr *msg,u16_t *datagram_len) + +{ + ushort uVar1; + uint uVar2; + err_t eVar3; + undefined3 extraout_var; + uint uVar4; + uint uVar5; + int iVar6; + netbuf *pnStack52; + netbuf *buf; + + if ((msg->msg_iov != (iovec *)0x0) || (eVar3 = -0x10, msg->msg_iovlen < 1)) { + pnStack52 = (netbuf *)sock->lastdata; + if (pnStack52 == (netbuf *)0x0) { + eVar3 = netconn_recv_udp_raw_netbuf_flags(sock->conn,&pnStack52,((flags & 8U) != 0) << 2); + if (CONCAT31(extraout_var,eVar3) != 0) { + return eVar3; + } + *(netbuf **)&sock->lastdata = pnStack52; + } + iVar6 = 0; + uVar2 = 0; + uVar1 = pnStack52->p->tot_len; + while ((iVar6 < msg->msg_iovlen && (uVar2 < uVar1))) { + uVar4 = msg->msg_iov[iVar6].iov_len; + uVar5 = uVar1 - uVar2 & 0xffff; + if (uVar4 <= uVar5) { + uVar5 = uVar4 & 0xffff; + } + pbuf_copy_partial(pnStack52->p,msg->msg_iov[iVar6].iov_base,(u16_t)uVar5,(u16_t)uVar2); + uVar2 = uVar2 + uVar5 & 0xffff; + iVar6 = iVar6 + 1; + } + if (((socklen_t *)msg->msg_name != (socklen_t *)0x0) && (msg->msg_namelen != 0)) { + lwip_sock_make_addr((short)pnStack52 + 8,(sockaddr *)(uint)pnStack52->port, + (socklen_t *)msg->msg_name); + } + msg->msg_flags = 0; + if (msg->msg_control != (void *)0x0) { + msg->msg_controllen = 0; + } + if ((flags & 1U) == 0) { + sock->lastdata = 0; + netbuf_delete(pnStack52); + } + *datagram_len = uVar1; + eVar3 = '\0'; + } + return eVar3; +} + + + +lwip_sock * get_socket(int fd) + +{ + lwip_sock *plVar1; + + if ((0x14 < (uint)fd) || (plVar1 = sockets + fd, plVar1->conn == (netconn *)0x0)) { + errno = 9; + plVar1 = (lwip_sock *)0x0; + } + return plVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +void lwip_setsockopt_callback(void *arg) + +{ + ip4_addr_t iVar1; + err_t eVar2; + ip4_addr_t *name; + sys_mutex_t mutex; + lwip_sock *plVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + netif *netif; + netconn *pnVar4; + lwip_socket_multicast_pair *plVar5; + uint uVar6; + int iVar7; + byte bVar8; + netconn_type nVar9; + int iVar10; + u32_t uVar11; + uint fd; + ip4_addr_t iStack40; + ip4_addr_t if_addr; + ip4_addr_t multi_addr; + + fd = *(uint *)arg; + iVar1 = (ip4_addr_t)((ip4_addr_t *)((int)arg + 4))->addr; + iVar10 = *(int *)((int)arg + 8); + bVar8 = (byte)iVar10; + uVar6 = *(uint *)((int)arg + 0x10); + name = *(ip4_addr_t **)((int)arg + 0xc); + if ((0x14 < fd) || (pnVar4 = sockets[fd].conn, pnVar4 == (netconn *)0x0)) { + iVar1 = (ip4_addr_t)0x9; + goto LAB_2306ad60; + } + if (iVar1 == (ip4_addr_t)0x6) { + iVar1 = (ip4_addr_t)0x16; + if ((((uVar6 < 4) || (iVar7 = pnVar4->pcb, iVar7 == 0)) || + (iVar1 = (ip4_addr_t)0x5c, (pnVar4->type & 0xf0) != NETCONN_TCP)) || + ((iVar1 = (ip4_addr_t)0x16, *(char *)(iVar7 + 0x14) == '\x01' || + (iVar1 = (ip4_addr_t)0x5c, 4 < iVar10 - 1U)))) goto LAB_2306ad60; + iVar1 = (ip4_addr_t)name->addr; + switch(iVar10) { + case 1: + if (iVar1 == (ip4_addr_t)0x0) { + *(ushort *)(iVar7 + 0x1a) = *(ushort *)(iVar7 + 0x1a) & 0xffbf; + goto LAB_2306ad60; + } + *(ushort *)(iVar7 + 0x1a) = *(ushort *)(iVar7 + 0x1a) | 0x40; + break; + case 3: + iVar1 = (ip4_addr_t)((int)iVar1 * 1000); + case 2: + *(ip4_addr_t *)&((ip4_addr_t *)(iVar7 + 0x94))->addr = iVar1; + break; + case 4: + *(int *)(iVar7 + 0x98) = (int)iVar1 * 1000; + break; + case 5: + *(ip4_addr_t *)&((ip4_addr_t *)(iVar7 + 0x9c))->addr = iVar1; + } +LAB_2306addc: + iVar1 = (ip4_addr_t)0x0; + goto LAB_2306ad60; + } + if (iVar1 == (ip4_addr_t)0xfff) { + if (iVar10 == 0x1005) { + iVar1 = (ip4_addr_t)0x16; + if ((uVar6 < 0x10) || (iVar10 = name->addr * 1000 + *(int *)(name + 2) / 1000, iVar10 < 0)) + goto LAB_2306ad60; + pnVar4->send_timeout = iVar10; + } + else { + if (iVar10 < 0x1006) { + if (((iVar10 != 8) && (iVar10 != 0x20)) && (iVar10 != 4)) goto switchD_2306aeb8_caseD_7; + if (iVar10 == 0x20) { + iVar1 = (ip4_addr_t)0x5c; + if ((pnVar4->type & 0xf0) != NETCONN_UDP) goto LAB_2306ad60; + } + else { + if ((iVar10 != 4) && (iVar10 != 8)) { + bVar8 = 0; + } + } + iVar1 = (ip4_addr_t)0x16; + if ((uVar6 < 4) || (iVar10 = pnVar4->pcb, iVar1 = (ip4_addr_t)0x16, iVar10 == 0)) + goto LAB_2306ad60; + iVar1 = (ip4_addr_t)name->addr; + if (iVar1 == (ip4_addr_t)0x0) { + *(byte *)(iVar10 + 9) = *(byte *)(iVar10 + 9) & ~bVar8; + goto LAB_2306ad60; + } + *(byte *)(iVar10 + 9) = *(byte *)(iVar10 + 9) | bVar8; + } + else { + if (iVar10 == 0x100a) { + iVar1 = (ip4_addr_t)0x16; + if (((uVar6 < 4) || (iVar10 = pnVar4->pcb, iVar10 == 0)) || + (iVar1 = (ip4_addr_t)0x5c, (pnVar4->type & 0xf0) != NETCONN_UDP)) goto LAB_2306ad60; + iVar1 = (ip4_addr_t)name->addr; + if (iVar1 == (ip4_addr_t)0x0) { + bVar8 = *(byte *)(iVar10 + 0x10) & 0xfe; + goto LAB_2306ae42; + } + *(byte *)(iVar10 + 0x10) = *(byte *)(iVar10 + 0x10) | 1; + } + else { + if (iVar10 == 0x100b) { + iVar1 = (ip4_addr_t)0x16; + if (uVar6 < 6) goto LAB_2306ad60; + netif = (netif *)0x0; + if (*(char *)&name->addr != '\0') { + netif = netif_find((char *)name); + iVar1 = (ip4_addr_t)0x13; + if (netif == (netif *)0x0) goto LAB_2306ad60; + } + pnVar4 = sockets[fd].conn; + nVar9 = pnVar4->type & 0xf0; + if (nVar9 == NETCONN_UDP) { + udp_bind_netif((udp_pcb *)pnVar4->pcb,netif); + } + else { + if (nVar9 != NETCONN_RAW) { + iVar1 = (ip4_addr_t)0x0; + if (nVar9 == NETCONN_TCP) { + tcp_bind_netif((tcp_pcb *)pnVar4->pcb,netif); + } + goto LAB_2306ad60; + } + raw_bind_netif((raw_pcb *)pnVar4->pcb,netif); + } + } + else { + if (iVar10 != 0x1006) goto switchD_2306aeb8_caseD_7; + iVar1 = (ip4_addr_t)0x16; + if ((uVar6 < 0x10) || + (uVar11 = name->addr * 1000 + *(int *)(name + 2) / 1000, (int)uVar11 < 0)) + goto LAB_2306ad60; + pnVar4->recv_timeout = uVar11; + } + } + } + } + goto LAB_2306addc; + } + if (iVar1 != (ip4_addr_t)0x0) goto switchD_2306aeb8_caseD_7; + switch(iVar10) { + case 1: + if ((3 < uVar6) && (pnVar4->pcb != 0)) { + *(undefined *)(pnVar4->pcb + 10) = (char)name->addr; + goto LAB_2306ad60; + } + goto LAB_2306b0b6; + case 2: + if ((3 < uVar6) && (pnVar4->pcb != 0)) { + *(undefined *)(pnVar4->pcb + 0xb) = (char)name->addr; + goto LAB_2306ad60; + } +LAB_2306b0b6: + iVar1 = (ip4_addr_t)0x16; + goto LAB_2306ad60; + case 3: + case 4: + if ((uVar6 < 8) || (pnVar4->pcb == 0)) goto LAB_2306b0b6; + if ((pnVar4->type & 0xf0) == NETCONN_UDP) { + iStack40 = (ip4_addr_t)name[1].addr; + if_addr = name->addr; + if (iVar10 == 3) { + plVar3 = get_socket(fd); + if (plVar3 != (lwip_sock *)0x0) { + plVar5 = socket_ipv4_multicast_memberships; + iVar10 = 0; + do { + if (plVar5->sock == (lwip_sock *)0x0) { + socket_ipv4_multicast_memberships[iVar10].sock = plVar3; + *(ip4_addr_t *)&socket_ipv4_multicast_memberships[iVar10].if_addr.addr = iStack40; + socket_ipv4_multicast_memberships[iVar10].multi_addr.addr = if_addr; + eVar2 = igmp_joingroup(&iStack40,&if_addr); + iVar10 = CONCAT31(extraout_var,eVar2); + goto LAB_2306afb8; + } + iVar10 = iVar10 + 1; + plVar5 = plVar5 + 1; + } while (iVar10 != 0x15); + } + iVar1 = (ip4_addr_t)0xc; + } + else { + eVar2 = igmp_leavegroup(&iStack40,&if_addr); + iVar10 = CONCAT31(extraout_var_00,eVar2); + plVar3 = get_socket(fd); + if (plVar3 != (lwip_sock *)0x0) { + plVar5 = socket_ipv4_multicast_memberships; + iVar7 = 0; + do { + if (((plVar3 == plVar5->sock) && ((ip4_addr_t)(plVar5->if_addr).addr == iStack40)) && + ((plVar5->multi_addr).addr == if_addr)) { + socket_ipv4_multicast_memberships[iVar7].sock = (lwip_sock *)0x0; + socket_ipv4_multicast_memberships[iVar7].if_addr.addr = 0; + socket_ipv4_multicast_memberships[iVar7].multi_addr.addr = 0; + break; + } + iVar7 = iVar7 + 1; + plVar5 = plVar5 + 1; + } while (iVar7 != 0x15); + } +LAB_2306afb8: + if (iVar10 != 0) { + iVar1 = (ip4_addr_t)0x63; + } + } + goto LAB_2306ad60; + } + break; + case 5: + if ((uVar6 == 0) || (pnVar4->pcb == 0)) goto LAB_2306b0b6; + if ((pnVar4->type & 0xf0) == NETCONN_UDP) { + *(undefined *)(pnVar4->pcb + 0x1d) = *(undefined *)&name->addr; + goto LAB_2306ad60; + } + break; + case 6: + if ((uVar6 < 4) || (pnVar4->pcb == 0)) goto LAB_2306b0b6; + if ((pnVar4->type & 0xf0) == NETCONN_UDP) { + ((ip4_addr_t *)(pnVar4->pcb + 0x18))->addr = name->addr; + goto LAB_2306ad60; + } + break; + case 7: + if ((uVar6 == 0) || (iVar10 = pnVar4->pcb, iVar10 == 0)) goto LAB_2306b0b6; + if ((pnVar4->type & 0xf0) == NETCONN_UDP) { + if (*(char *)&name->addr == '\0') { + bVar8 = *(byte *)(iVar10 + 0x10) & 0xf7; + } + else { + bVar8 = *(byte *)(iVar10 + 0x10) | 8; + } +LAB_2306ae42: + *(byte *)(iVar10 + 0x10) = bVar8; + goto LAB_2306ad60; + } + } +switchD_2306aeb8_caseD_7: + iVar1 = (ip4_addr_t)0x5c; +LAB_2306ad60: + mutex = *(sys_mutex_t *)((int)arg + 0x18); + *(ip4_addr_t *)&((ip4_addr_t *)((int)arg + 0x14))->addr = iVar1; + sys_sem_signal((sys_mutex_t *)mutex); + return; +} + + + +void event_callback(netconn *conn,netconn_evt evt,u16_t len) + +{ + short sVar1; + u16_t uVar2; + u16_t uVar3; + bool bVar4; + lwip_select_cb *plVar5; + lwip_select_cb *plVar6; + uint fd; + sys_prot_t sVar7; + lwip_sock *plVar8; + undefined3 in_register_0000202d; + nfds_t nVar9; + int iVar10; + ushort *puVar11; + uint uVar12; + uint uVar13; + + if (conn == (netconn *)0x0) { + return; + } + fd = conn->socket; + if ((int)fd < 0) { + sVar7 = sys_arch_protect(); + fd = conn->socket; + if ((int)fd < 0) { + if (CONCAT31(in_register_0000202d,evt) == 0) { + conn->socket = fd - 1; + } + goto LAB_2306b0fa; + } + sys_arch_unprotect(sVar7); + } + plVar8 = get_socket(fd); + if (plVar8 == (lwip_sock *)0x0) { + return; + } + sVar7 = sys_arch_protect(); + bVar4 = true; + switch(CONCAT31(in_register_0000202d,evt)) { + case 0: + iVar10 = ((uint)(ushort)plVar8->rcvevent + 1) * 0x10000; + plVar8->rcvevent = (s16_t)((uint)iVar10 >> 0x10); + bVar4 = iVar10 >> 0x10 < 2; + break; + case 1: + plVar8->rcvevent = plVar8->rcvevent + -1; + goto LAB_2306b1ae; + case 2: + uVar2 = plVar8->sendevent; + plVar8->sendevent = 1; + bVar4 = uVar2 == 0; + break; + case 3: + plVar8->sendevent = 0; +LAB_2306b1ae: + bVar4 = false; + break; + case 4: + bVar4 = true; + plVar8->errevent = 1; + } + if ((plVar8->select_waiting != '\0') && (bVar4)) { + sVar1 = plVar8->rcvevent; + uVar2 = plVar8->sendevent; + uVar3 = plVar8->errevent; + sys_arch_unprotect(); + sVar7 = sys_arch_protect(); + uVar12 = fd >> 5; + uVar13 = 1 << (fd & 0x1f); + plVar5 = select_cb_list; + while (plVar6 = plVar5, iVar10 = select_cb_ctr, plVar6 != (lwip_select_cb *)0x0) { + if (plVar6->sem_signalled == 0) { + if (plVar6->poll_fds == (pollfd *)0x0) { + if (((((0 < sVar1) && (plVar6->readset != (_types_fd_set *)0x0)) && + ((uVar13 & plVar6->readset->fds_bits[uVar12]) != 0)) || + (((uVar2 != 0 && (plVar6->writeset != (_types_fd_set *)0x0)) && + ((uVar13 & plVar6->writeset->fds_bits[uVar12]) != 0)))) || + (((uVar3 != 0 && (plVar6->exceptset != (_types_fd_set *)0x0)) && + ((uVar13 & plVar6->exceptset->fds_bits[uVar12]) != 0)))) { +LAB_2306b25e: + plVar6->sem_signalled = 1; + sys_sem_signal((sys_mutex_t *)&plVar6->sem); + } + } + else { + puVar11 = (ushort *)&plVar6->poll_fds->events; + nVar9 = 0; + while (nVar9 != plVar6->poll_nfds) { + if ((fd == *(uint *)(puVar11 + -2)) && + ((((0 < sVar1 && ((*puVar11 & 1) != 0)) || ((uVar2 != 0 && ((*puVar11 & 2) != 0)))) + || (uVar3 != 0)))) goto LAB_2306b25e; + nVar9 = nVar9 + 1; + puVar11 = puVar11 + 4; + } + } + } + sys_arch_unprotect(sVar7); + sVar7 = sys_arch_protect(); + plVar5 = select_cb_list; + if (select_cb_ctr == iVar10) { + plVar5 = plVar6->next; + } + } + } +LAB_2306b0fa: + sys_arch_unprotect(sVar7); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int lwip_accept(int s,sockaddr *addr,socklen_t *addrlen) + +{ + int iVar1; + err_t err; + lwip_sock *plVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + int iVar3; + u16_t uStack58; + u16_t port; + netconn *pnStack56; + netconn *newconn; + ip_addr_t naddr; + sockaddr_aligned tempaddr; + + uStack58 = 0; + plVar2 = get_socket(s); + if (plVar2 == (lwip_sock *)0x0) { + return -1; + } + err = netconn_accept(plVar2->conn,(netconn **)&stack0xffffffc8); + if (CONCAT31(extraout_var,err) == 0) { + iVar3 = alloc_socket(pnStack56,1); + if (iVar3 == -1) { + netconn_delete(pnStack56); + errno = 0x17; + return -1; + } + sys_arch_protect(); + iVar1 = pnStack56->socket; + pnStack56->socket = iVar3; + sys_arch_unprotect(); + if (pnStack56->callback != (netconn_callback *)0x0) { + iVar1 = (int)(short)~(ushort)iVar1; + while (0 < iVar1) { + iVar1 = iVar1 + -1; + (*pnStack56->callback)(pnStack56,NETCONN_EVT_RCVPLUS,0); + } + } + if (addr == (sockaddr *)0x0) { + return iVar3; + } + if (addrlen == (socklen_t *)0x0) { + return iVar3; + } + err = netconn_getaddr(pnStack56,(ip_addr_t *)&newconn,&uStack58,'\0'); + if (CONCAT31(extraout_var_00,err) == 0) { + naddr.addr._0_2_ = 0x210; + naddr.addr._2_2_ = lwip_htons(uStack58); + tempaddr._0_4_ = (ip_addr_t)newconn; + memset(tempaddr + 4,0,8); + if ((uint)(byte)naddr.addr < *addrlen) { + *addrlen = (uint)(byte)naddr.addr; + } + memcpy(addr,&naddr,*addrlen); + return iVar3; + } + netconn_delete(pnStack56); + free_socket(sockets + iVar3,1); + } + else { + if ((plVar2->conn->type & 0xf0) != NETCONN_TCP) { + errno = 0x5f; + return -1; + } + if (CONCAT31(extraout_var,err) == -0xf) { + errno = 0x16; + return -1; + } + } + iVar3 = err_to_errno(err); + if (iVar3 != 0) { + errno = iVar3; + } + return -1; +} + + + +// WARNING: Type propagation algorithm not settling + +int lwip_bind(int s,sockaddr *name,socklen_t namelen) + +{ + err_t err; + u16_t port; + lwip_sock *plVar1; + int iVar2; + undefined3 extraout_var; + ip_addr_t iStack20; + ip_addr_t local_addr; + + plVar1 = get_socket(s); + if (plVar1 != (lwip_sock *)0x0) { + if (((namelen == 0x10) && (name->sa_family == '\x02')) && (((uint)name & 3) == 0)) { + iStack20 = (ip_addr_t)((ip_addr_t *)(name->sa_data + 2))->addr; + port = lwip_htons(*(u16_t *)name->sa_data); + err = netconn_bind(plVar1->conn,&iStack20,port); + if (CONCAT31(extraout_var,err) == 0) { + return 0; + } + } + else { + err = -0x10; + } + iVar2 = err_to_errno(err); + if (iVar2 != 0) { + errno = iVar2; + } + } + return -1; +} + + + +// WARNING: Type propagation algorithm not settling + +int lwip_close(int s) + +{ + lwip_socket_multicast_pair *plVar1; + uint is_tcp; + err_t err; + lwip_sock *sock; + netconn *pnVar2; + undefined3 extraout_var; + int iVar3; + ip_addr_t iStack40; + ip_addr_t multi_addr; + ip_addr_t if_addr; + + sock = get_socket(s); + if (sock != (lwip_sock *)0x0) { + is_tcp = 0; + if (sock->conn != (netconn *)0x0) { + is_tcp = (uint)((sock->conn->type & 0xf0) == NETCONN_TCP); + } + pnVar2 = (netconn *)get_socket(s); + if (pnVar2 != (netconn *)0x0) { + plVar1 = socket_ipv4_multicast_memberships; + do { + if (pnVar2 == ((lwip_sock *)plVar1)->conn) { + iStack40 = (ip_addr_t)((ip_addr_t *)&((lwip_sock *)plVar1)->rcvevent)->addr; + ((lwip_sock *)plVar1)->conn = (netconn *)0x0; + *(undefined4 *)&((lwip_sock *)plVar1)->rcvevent = 0; + multi_addr = ((ip_addr_t *)&((lwip_sock *)plVar1)->lastdata)->addr; + ((lwip_sock *)plVar1)->lastdata = 0; + netconn_join_leave_group(*(netconn **)&pnVar2->type,&iStack40,&multi_addr,NETCONN_LEAVE); + } + plVar1 = (lwip_socket_multicast_pair *)&((lwip_sock *)plVar1)->errevent; + } while ((lwip_sock *)plVar1 != sockets); + } + err = netconn_prepare_delete(sock->conn); + if (CONCAT31(extraout_var,err) == 0) { + free_socket(sock,is_tcp); + return 0; + } + iVar3 = err_to_errno(err); + if (iVar3 != 0) { + errno = iVar3; + } + } + return -1; +} + + + +// WARNING: Type propagation algorithm not settling + +int lwip_connect(int s,sockaddr *name,socklen_t namelen) + +{ + err_t err; + u16_t port; + lwip_sock *plVar1; + undefined3 extraout_var; + int iVar2; + undefined3 extraout_var_00; + ip_addr_t iStack20; + ip_addr_t remote_addr; + + plVar1 = get_socket(s); + if (plVar1 == (lwip_sock *)0x0) { + return 0xffffffff; + } + if (name->sa_family == '\0') { + err = netconn_disconnect(plVar1->conn); + iVar2 = CONCAT31(extraout_var,err); + } + else { + if (((namelen != 0x10) || (name->sa_family != '\x02')) || (((uint)name & 3) != 0)) { + err = -0x10; + goto LAB_2306b520; + } + iStack20 = (ip_addr_t)((ip_addr_t *)(name->sa_data + 2))->addr; + port = lwip_htons(*(u16_t *)name->sa_data); + err = netconn_connect(plVar1->conn,&iStack20,port); + iVar2 = CONCAT31(extraout_var_00,err); + } + err = (err_t)iVar2; + if (iVar2 == 0) { + return 0; + } +LAB_2306b520: + iVar2 = err_to_errno(err); + if (iVar2 != 0) { + errno = iVar2; + } + return -1; +} + + + +int lwip_listen(int s,int backlog) + +{ + err_t err; + lwip_sock *plVar1; + undefined3 extraout_var; + int iVar2; + u8_t backlog_00; + + plVar1 = get_socket(s); + if (plVar1 != (lwip_sock *)0x0) { + if (backlog < 0) { + backlog = 0; + } + backlog_00 = (u8_t)backlog; + if (0xff < backlog) { + backlog_00 = -1; + } + err = netconn_listen_with_backlog(plVar1->conn,backlog_00); + if (CONCAT31(extraout_var,err) == 0) { + return 0; + } + if ((plVar1->conn->type & 0xf0) == NETCONN_TCP) { + iVar2 = err_to_errno(err); + if (iVar2 != 0) { + errno = iVar2; + } + } + else { + errno = 0x5f; + } + } + return -1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +ssize_t lwip_recvfrom(int s,void *mem,size_t len,int flags,sockaddr *from,socklen_t *fromlen) + +{ + uint uVar1; + err_t err; + lwip_sock *sock; + ssize_t sVar2; + undefined3 extraout_var; + int iVar3; + socklen_t sVar4; + u16_t uStack70; + u16_t datagram_len; + void *pvStack68; + iovec vec; + msghdr msg; + + sock = get_socket(s); + if (sock != (lwip_sock *)0x0) { + if ((sock->conn->type & 0xf0) == NETCONN_TCP) { + sVar2 = lwip_recv_tcp(sock,mem,len,flags); + if (from == (sockaddr *)0x0) { + return sVar2; + } + if (fromlen == (socklen_t *)0x0) { + return sVar2; + } + netconn_getaddr(sock->conn,(ip_addr_t *)&vec.iov_len,(u16_t *)&stack0xffffffbc,'\0'); + lwip_sock_make_addr((short)register0x00002008 - 0x3c,(sockaddr *)((uint)pvStack68 & 0xffff), + (socklen_t *)from); + return sVar2; + } + uStack70 = 0; + sVar4 = 0; + if (fromlen != (socklen_t *)0x0) { + sVar4 = *fromlen; + } + pvStack68 = mem; + vec.iov_base = (void *)len; + vec.iov_len = (size_t)from; + err = lwip_recvfrom_udp_raw(sock,flags,(msghdr *)&vec.iov_len,&uStack70); + if (CONCAT31(extraout_var,err) == 0) { + uVar1 = (uint)uStack70; + if (len < (uint)uStack70) { + uVar1 = len; + } + if (fromlen == (socklen_t *)0x0) { + return uVar1; + } + *fromlen = sVar4; + return uVar1; + } + iVar3 = err_to_errno(err); + if (iVar3 != 0) { + errno = iVar3; + } + } + return -1; +} + + + +ssize_t lwip_read(int s,void *mem,size_t len) + +{ + ssize_t sVar1; + + sVar1 = lwip_recvfrom(s,mem,len,0,(sockaddr *)0x0,(socklen_t *)0x0); + return sVar1; +} + + + +ssize_t lwip_recv(int s,void *mem,size_t len,int flags) + +{ + ssize_t sVar1; + + sVar1 = lwip_recvfrom(s,mem,len,flags,(sockaddr *)0x0,(socklen_t *)0x0); + return sVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +ssize_t lwip_sendto(int s,void *data,size_t size,int flags,sockaddr *to,socklen_t tolen) + +{ + err_t eVar1; + lwip_sock *plVar2; + ssize_t sVar3; + int iVar4; + void *pvVar5; + undefined3 extraout_var; + int iVar6; + pbuf *ppStack52; + netbuf buf; + + plVar2 = get_socket(s); + if (plVar2 == (lwip_sock *)0x0) { + return -1; + } + if ((plVar2->conn->type & 0xf0) == NETCONN_TCP) { + sVar3 = lwip_send(s,data,size,flags); + return sVar3; + } + if (0xffff < size) { + errno = 0x5a; + return -1; + } + if (to != (sockaddr *)0x0) { + if ((tolen != 0x10) || (to->sa_family != '\x02')) goto LAB_2306b6fc; + tolen = (uint)to & 3; + } + if (tolen == 0) { + buf.p = (pbuf *)0x0; + ppStack52 = (pbuf *)0x0; + buf.addr.addr._2_1_ = '\0'; + if (to == (sockaddr *)0x0) { + buf.ptr = (pbuf *)0x0; + buf.addr.addr._0_2_ = 0; + } + else { + buf.ptr = *(pbuf **)(to->sa_data + 2); + buf.addr.addr._0_2_ = lwip_htons(*(u16_t *)to->sa_data); + } + pvVar5 = netbuf_alloc((netbuf *)&ppStack52,(u16_t)size); + iVar4 = -1; + if (pvVar5 != (void *)0x0) { + if ((plVar2->conn->type & 0xf0) == NETCONN_RAW) { + memcpy(ppStack52->payload,data,size); + } + else { + buf.port = lwip_chksum_copy(ppStack52->payload,data,(u16_t)size); + buf.addr.addr._2_1_ = '\x02'; + } + eVar1 = netconn_send(plVar2->conn,(netbuf *)&ppStack52); + iVar4 = CONCAT31(extraout_var,eVar1); + } + netbuf_free((netbuf *)&ppStack52); + iVar6 = err_to_errno((err_t)iVar4); + if (iVar6 != 0) { + errno = iVar6; + } + if (iVar4 != 0) { + return -1; + } + return size; + } +LAB_2306b6fc: + iVar4 = err_to_errno(-0x10); + if (iVar4 != 0) { + errno = iVar4; + } + return -1; +} + + + +ssize_t lwip_send(int s,void *data,size_t size,int flags) + +{ + err_t err; + lwip_sock *plVar1; + ssize_t sVar2; + undefined3 extraout_var; + int iVar3; + byte bVar4; + size_t sStack20; + size_t written; + + plVar1 = get_socket(s); + if (plVar1 != (lwip_sock *)0x0) { + if ((plVar1->conn->type & 0xf0) != NETCONN_TCP) { + sVar2 = lwip_sendto(s,data,size,flags,(sockaddr *)0x0,0); + return sVar2; + } + bVar4 = 3; + if ((flags & 0x10U) == 0) { + bVar4 = 1; + } + sStack20 = 0; + err = netconn_write_partly(plVar1->conn,data,size,bVar4 | (byte)(flags >> 1) & 4,&sStack20); + iVar3 = err_to_errno(err); + if (iVar3 != 0) { + errno = iVar3; + } + if (CONCAT31(extraout_var,err) == 0) { + return sStack20; + } + } + return -1; +} + + + +int lwip_socket(int domain,int type,int protocol) + +{ + netconn_type t; + netconn *newconn; + int iVar1; + u8_t proto; + + if (type == 2) { + t = NETCONN_UDPLITE; + if (protocol != 0x88) { + t = NETCONN_UDP; + } + proto = '\0'; + } + else { + if (type == 3) { + proto = (u8_t)protocol; + t = NETCONN_RAW; + } + else { + if (type != 1) { + errno = 0x16; + return -1; + } + proto = '\0'; + t = NETCONN_TCP; + } + } + newconn = netconn_new_with_proto_and_callback(t,proto,event_callback); + if (newconn == (netconn *)0x0) { + errno = 0x69; + return -1; + } + iVar1 = alloc_socket(newconn,0); + if (iVar1 != -1) { + newconn->socket = iVar1; + return iVar1; + } + netconn_delete(newconn); + errno = 0x17; + return -1; +} + + + +int lwip_setsockopt(int s,int level,int optname,void *optval,socklen_t optlen) + +{ + err_t err; + lwip_sock *plVar1; + undefined3 extraout_var; + socklen_t sVar2; + int iStack44; + lwip_setgetsockopt_data data; + + plVar1 = get_socket(s); + sVar2 = errno; + if (plVar1 != (lwip_sock *)0x0) { + if (optval == (void *)0x0) { + errno = 0xe; + sVar2 = errno; + } + else { + data.optlen = 0; + data.err = (int)&plVar1->conn->op_completed; + iStack44 = s; + data.s = level; + data.level = optname; + data.optname = (int)optval; + data.optval = optlen; + err = tcpip_callback(lwip_setsockopt_callback,&iStack44); + if (CONCAT31(extraout_var,err) == 0) { + sys_arch_sem_wait((sys_sem_t *)data.err,0); + sVar2 = data.optlen; + if (data.optlen == 0) { + return 0; + } + } + else { + sVar2 = err_to_errno(err); + if (sVar2 == 0) { + return -1; + } + } + } + } + errno = sVar2; + return -1; +} + + + +void tcpip_thread(void *arg) + +{ + byte *mem; + undefined uVar1; + memp_t type; + u32_t timeout; + int iVar2; + undefined *puVar3; + byte *pbStack36; + tcpip_msg *msg; + + if (tcpip_init_done != (tcpip_init_done_fn)0x0) { + (*tcpip_init_done)(tcpip_init_done_arg); + } +switchD_2306b98c_caseD_5: + do { + while (timeout = sys_timeouts_sleeptime(), timeout != 0xffffffff) { + if ((timeout != 0) && + (timeout = sys_arch_mbox_fetch(&tcpip_mbox,&pbStack36,timeout), timeout != 0xffffffff)) + goto LAB_2306b97a; + sys_check_timeouts(); + } + sys_arch_mbox_fetch(&tcpip_mbox,&pbStack36,0); +LAB_2306b97a: + mem = pbStack36; + } while (pbStack36 == (byte *)0x0); + switch(*pbStack36) { + case 0: + case 4: + (**(code **)(pbStack36 + 4))(*(undefined4 *)(pbStack36 + 8),*(code **)(pbStack36 + 4)); + goto switchD_2306b98c_caseD_5; + case 1: + puVar3 = *(undefined **)(pbStack36 + 8); + uVar1 = (**(code **)(pbStack36 + 4))(puVar3,*(code **)(pbStack36 + 4)); + *puVar3 = uVar1; + sys_sem_signal((sys_mutex_t *)*(sys_mutex_t *)(mem + 0xc)); + goto switchD_2306b98c_caseD_5; + case 2: + iVar2 = (**(code **)(pbStack36 + 0xc)) + (*(undefined4 *)(pbStack36 + 4),*(undefined4 *)(pbStack36 + 8), + *(code **)(pbStack36 + 0xc)); + if (iVar2 != 0) { + pbuf_free(*(pbuf **)(mem + 4)); + } + type = MEMP_TCPIP_MSG_INPKT; + break; + case 3: + (**(code **)(pbStack36 + 4))(*(undefined4 *)(pbStack36 + 8),*(code **)(pbStack36 + 4)); + type = MEMP_TCPIP_MSG_API; + break; + default: + goto switchD_2306b98c_caseD_5; + } + memp_free(type,mem); + goto switchD_2306b98c_caseD_5; +} + + + +err_t tcpip_inpkt(pbuf *p,netif *inp,netif_input_fn *input_fn) + +{ + err_t eVar1; + undefined *msg; + undefined3 extraout_var; + + sys_mbox_valid(&tcpip_mbox); + msg = (undefined *)memp_malloc(MEMP_TCPIP_MSG_INPKT); + if (msg == (undefined *)0x0) { + printf("[LWIP] NO TCP MSG\r\n"); + } + else { + *(netif **)(msg + 8) = inp; + *msg = 2; + *(pbuf **)(msg + 4) = p; + *(netif_input_fn **)(msg + 0xc) = input_fn; + eVar1 = sys_mbox_trypost(&tcpip_mbox,msg); + if (CONCAT31(extraout_var,eVar1) == 0) { + return eVar1; + } + printf("[LWIP] NO MBOX\r\n"); + memp_free(MEMP_TCPIP_MSG_INPKT,msg); + } + return -1; +} + + + +err_t tcpip_input(pbuf *p,netif *inp) + +{ + err_t eVar1; + code *input_fn; + + if ((inp->flags & 0x18) == 0) { + input_fn = ip4_input; + } + else { + input_fn = ethernet_input; + } + eVar1 = tcpip_inpkt(p,inp,input_fn); + return eVar1; +} + + + +err_t tcpip_callback(tcpip_callback_fn function,void *ctx) + +{ + err_t eVar1; + undefined *data; + + sys_mbox_valid(&tcpip_mbox); + data = (undefined *)memp_malloc(MEMP_TCPIP_MSG_API); + if (data == (undefined *)0x0) { + eVar1 = -1; + } + else { + *data = 3; + *(void **)(data + 8) = ctx; + *(tcpip_callback_fn *)(data + 4) = function; + sys_mbox_post(&tcpip_mbox,data); + eVar1 = '\0'; + } + return eVar1; +} + + + +err_t tcpip_try_callback(tcpip_callback_fn function,void *ctx) + +{ + err_t eVar1; + undefined *msg; + undefined3 extraout_var; + + sys_mbox_valid(&tcpip_mbox); + msg = (undefined *)memp_malloc(MEMP_TCPIP_MSG_API); + if (msg != (undefined *)0x0) { + *(void **)(msg + 8) = ctx; + *msg = 3; + *(tcpip_callback_fn *)(msg + 4) = function; + eVar1 = sys_mbox_trypost(&tcpip_mbox,msg); + if (CONCAT31(extraout_var,eVar1) == 0) { + return eVar1; + } + memp_free(MEMP_TCPIP_MSG_API,msg); + } + return -1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t tcpip_send_msg_wait_sem(tcpip_callback_fn fn,void *apimsg,sys_sem_t *sem) + +{ + undefined auStack32 [4]; + tcpip_msg msg; + + sys_sem_valid(sem); + sys_mbox_valid(&tcpip_mbox); + auStack32[0] = 0; + msg._0_4_ = fn; + msg.msg._0_4_ = apimsg; + sys_mbox_post(&tcpip_mbox,auStack32); + sys_arch_sem_wait(sem,0); + return '\0'; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t tcpip_api_call(tcpip_api_call_fn *fn,tcpip_api_call_data *call) + +{ + sys_sem_t *sem; + err_t eVar1; + undefined3 extraout_var; + undefined local_30 [4]; + tcpip_msg msg; + + sem = &call->sem; + eVar1 = sys_sem_new(sem,'\0'); + if (CONCAT31(extraout_var,eVar1) == 0) { + sys_mbox_valid(&tcpip_mbox); + local_30[0] = 1; + msg._0_4_ = fn; + msg.msg._0_4_ = call; + msg.msg._4_4_ = sem; + sys_mbox_post(&tcpip_mbox,local_30); + sys_arch_sem_wait(msg.msg._4_4_,0); + sys_sem_free(sem); + eVar1 = call->err; + } + return eVar1; +} + + + +void tcpip_init(tcpip_init_done_fn initfunc,void *arg) + +{ + lwip_init(); + tcpip_init_done = initfunc; + tcpip_init_done_arg = arg; + sys_mbox_new(&tcpip_mbox,0x32); + sys_thread_new("TCP/IP",tcpip_thread,(void *)0x0,4000,0x1e); + return; +} + + + +u16_t lwip_htons(u16_t n) + +{ + undefined2 in_register_0000202a; + + return (u16_t)((ushort)(CONCAT22(in_register_0000202a,n) >> 8) | n << 8); +} + + + +u32_t lwip_htonl(u32_t n) + +{ + return n >> 8 & 0xff00 | n << 0x18 | n >> 0x18 | (n & 0xff00) << 8; +} + + + +int lwip_strnicmp(char *str1,char *str2,size_t len) + +{ + byte bVar1; + int iVar2; + + iVar2 = 0; + while( true ) { + bVar1 = str1[iVar2]; + if ((bVar1 != str2[iVar2]) && + ((0x19 < (byte)((bVar1 | 0x20) + 0x9f) || + ((byte)(bVar1 | 0x20) != (byte)(str2[iVar2] | 0x20U))))) break; + if ((len - 1 == iVar2) || (iVar2 = iVar2 + 1, bVar1 == 0)) { + return 0; + } + } + return 1; +} + + + +void dns_call_found(u8_t idx,ip_addr_t *addr) + +{ + undefined3 in_register_00002029; + int iVar1; + + iVar1 = CONCAT31(in_register_00002029,idx); + if (dns_requests[iVar1].found != (dns_found_callback *)0x0) { + (*dns_requests[iVar1].found)(dns_table[iVar1].name,addr,dns_requests[iVar1].arg); + } + dns_requests[iVar1].found = (dns_found_callback *)0x0; + return; +} + + + +// WARNING: Variable defined which should be unmapped: hdr + +err_t dns_send(u8_t idx) + +{ + u8_t *dataptr; + u8_t *puVar1; + err_t eVar2; + undefined3 in_register_00002029; + int iVar3; + size_t sVar4; + pbuf *buf; + uint uVar5; + uint uVar6; + uint uVar7; + undefined4 local_40; + dns_query qry; + dns_hdr hdr; + + iVar3 = CONCAT31(in_register_00002029,idx); + if (dns_servers[dns_table[iVar3].server_idx].addr == 0) { + dns_call_found(idx,(ip_addr_t *)0x0); + eVar2 = '\0'; + dns_table[iVar3].state = '\0'; + } + else { + sVar4 = strlen(dns_table[iVar3].name); + buf = pbuf_alloc(PBUF_TRANSPORT,(u16_t)((sVar4 + 0x12) * 0x10000 >> 0x10),PBUF_RAM); + eVar2 = -1; + if (buf != (pbuf *)0x0) { + memset(&qry,0,0xc); + qry.type = lwip_htons(dns_table[iVar3].txid); + qry.cls._0_1_ = 1; + puVar1 = &dns_table[iVar3].seqno; + pbuf_take(buf,&qry,0xc); + uVar6 = 0xc; + do { + dataptr = puVar1 + 1; + uVar5 = 0; + puVar1 = dataptr; + while ((*puVar1 != '.' && (*puVar1 != '\0'))) { + uVar5 = uVar5 + 1 & 0xff; + puVar1 = puVar1 + 1; + } + if (0xfffe < uVar6 + uVar5) { + pbuf_free(buf); + return -6; + } + pbuf_put_at(buf,(u16_t)uVar6,(u8_t)uVar5); + pbuf_take_at(buf,dataptr,(u16_t)((uint)((int)(puVar1 + -(int)dataptr) * 0x10000) >> 0x10), + (u16_t)((uVar6 + 1) * 0x10000 >> 0x10)); + uVar7 = uVar6 + uVar5 & 0xffff; + uVar5 = uVar7 + 1; + uVar6 = uVar5 & 0xffff; + } while (*puVar1 != '\0'); + pbuf_put_at(buf,(u16_t)(uVar5 * 0x10000 >> 0x10),'\0'); + local_40 = 0x1000100; + pbuf_take_at(buf,&local_40,4,(u16_t)((uVar7 + 2) * 0x10000 >> 0x10)); + eVar2 = udp_sendto(dns_pcbs,buf,dns_servers + dns_table[iVar3].server_idx,0x35); + pbuf_free(buf); + } + } + return eVar2; +} + + + +void dns_check_entry(u8_t i) + +{ + undefined3 in_register_00002029; + int iVar1; + u8_t uVar2; + u16_t uVar3; + uint uVar4; + uint uVar5; + u32_t uVar6; + dns_table_entry_conflict1 *pdVar7; + + iVar1 = CONCAT31(in_register_00002029,i); + uVar2 = dns_table[iVar1].state; + if (uVar2 != '\x02') { + if (uVar2 != '\x03') { + if (uVar2 != '\x01') { + return; + } + uVar4 = (uint)dns_txid; + do { + uVar5 = uVar4 + 1; + uVar4 = uVar5 & 0xffff; + pdVar7 = dns_table; + while ((pdVar7->state != '\x02' || ((uint)pdVar7->txid != uVar4))) { + pdVar7 = pdVar7 + 1; + if (pdVar7 == (dns_table_entry_conflict1 *)arp_table) { + uVar3 = (u16_t)(uVar5 * 0x10000 >> 0x10); + dns_txid = uVar3; + *(undefined2 *)&dns_table[iVar1].state = 2; + dns_table[iVar1].txid = uVar3; + *(undefined2 *)&dns_table[iVar1].tmr = 1; + goto LAB_2306bede; + } + } + } while( true ); + } + uVar6 = dns_table[iVar1].ttl; + if ((uVar6 != 0) && (uVar6 = uVar6 - 1, dns_table[iVar1].ttl = uVar6, uVar6 != 0)) { + return; + } +LAB_2306bf3a: + dns_table[iVar1].state = '\0'; + return; + } + uVar2 = dns_table[iVar1].tmr + -1; + dns_table[iVar1].tmr = uVar2; + if (uVar2 != '\0') { + return; + } + uVar2 = dns_table[iVar1].retries + '\x01'; + dns_table[iVar1].retries = uVar2; + if (uVar2 == '\x04') { + if ((dns_table[iVar1].server_idx != '\0') || (dns_servers[1] == 0)) { + dns_call_found(i,(ip_addr_t *)0x0); + goto LAB_2306bf3a; + } + dns_table[iVar1].server_idx = '\x01'; + *(undefined2 *)&dns_table[iVar1].tmr = 1; + } + else { + dns_table[iVar1].tmr = uVar2; + } +LAB_2306bede: + dns_send(i); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void dns_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port) + +{ + u8_t i; + uint uVar1; + u16_t uVar2; + u16_t uVar3; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined2 extraout_var_02; + uint uVar4; + int iVar5; + undefined2 extraout_var_03; + uint uVar6; + undefined2 extraout_var_04; + undefined2 extraout_var_05; + u32_t uVar7; + undefined2 extraout_var_06; + dns_table_entry_conflict1 *pdVar8; + byte *pbVar9; + int iVar10; + uint uVar11; + byte *pbVar12; + short sStack96; + short sStack94; + dns_query qry; + ip4_addr_t ip4addr; + dns_hdr hdr; + dns_answer ans; + + if (0xf < p->tot_len) { + uVar2 = pbuf_copy_partial(p,&ip4addr,0xc,0); + uVar1 = CONCAT22(extraout_var,uVar2); + if (uVar1 == 0xc) { + iVar10 = 0; + uVar2 = lwip_htons((u16_t)ip4addr.addr); + pdVar8 = dns_table; + do { + i = (u8_t)iVar10; + if ((pdVar8->state == '\x02') && ((uint)pdVar8->txid == CONCAT22(extraout_var_00,uVar2))) { + uVar2 = lwip_htons(hdr.id); + uVar3 = lwip_htons(hdr._2_2_); + uVar11 = CONCAT22(extraout_var_02,uVar3); + if ((ip4addr.addr._2_1_ < '\0') && + ((CONCAT22(extraout_var_01,uVar2) == 1 && + (addr->addr == dns_servers[dns_table[iVar10].server_idx].addr)))) { + pbVar12 = (byte *)dns_table[iVar10].name; + goto LAB_2306c032; + } + break; + } + iVar10 = iVar10 + 1; + pdVar8 = pdVar8 + 1; + } while (iVar10 != 4); + } + } + goto ignore_packet; + while( true ) { + pbVar9 = pbVar12 + uVar4; + while( true ) { + uVar1 = uVar1 + 1 & 0xffff; + if (pbVar12 == pbVar9) break; + uVar4 = pbuf_try_get_at(p,(u16_t)uVar1); + if ((int)uVar4 < 0) goto ignore_packet; + uVar6 = (uint)*pbVar12; + if ((_ctype_[uVar6 + 1] & 3) == 1) { + uVar6 = uVar6 + 0x20; + } + uVar4 = uVar4 & 0xff; + if ((_ctype_[uVar4 + 1] & 3) == 1) { + uVar4 = uVar4 + 0x20; + } + if ((uVar6 != uVar4) || (uVar1 == 0xffff)) goto ignore_packet; + pbVar12 = pbVar12 + 1; + } + pbVar12 = pbVar12 + 1; + iVar5 = pbuf_try_get_at(p,(u16_t)uVar1); + if (iVar5 < 0) goto ignore_packet; + if (iVar5 == 0) break; +LAB_2306c032: + uVar4 = pbuf_try_get_at(p,(u16_t)uVar1); + if ((((int)uVar4 < 0) || (uVar1 == 0xffff)) || ((uVar4 & 0xc0) == 0xc0)) goto ignore_packet; + } + if (uVar1 != 0xffff) { + uVar4 = uVar1 + 1 & 0xffff; + if (((uVar4 != 0xffff) && + (uVar2 = pbuf_copy_partial(p,&sStack96,4,(u16_t)((uVar1 + 1) * 0x10000 >> 0x10)), + CONCAT22(extraout_var_03,uVar2) == 4)) && + ((sStack94 == 0x100 && ((sStack96 == 0x100 && (uVar4 < 0xfffc)))))) { + if ((ip4addr.addr._3_1_ & 0xf) == 0) { + uVar1 = uVar1 + 5; + while ((uVar1 = uVar1 & 0xffff, uVar11 != 0 && (uVar1 < p->tot_len))) { + do { + uVar4 = uVar1 + 1 & 0xffff; + uVar6 = pbuf_try_get_at(p,(u16_t)uVar1); + if (((int)uVar6 < 0) || (uVar4 == 0)) goto ignore_packet; + if ((uVar6 & 0xc0) == 0xc0) break; + uVar6 = uVar6 + uVar4; + if ((int)(uint)p->tot_len <= (int)uVar6) goto ignore_packet; + uVar1 = uVar6 & 0xffff; + iVar5 = pbuf_try_get_at(p,(u16_t)(uVar6 * 0x10000 >> 0x10)); + if (iVar5 < 0) goto ignore_packet; + uVar4 = uVar1; + } while (iVar5 != 0); + if (uVar4 == 0xffff) goto ignore_packet; + uVar1 = uVar4 + 1 & 0xffff; + if (((uVar1 == 0xffff) || + (uVar2 = pbuf_copy_partial(p,&hdr.numauthrr,10,(u16_t)((uVar4 + 1) * 0x10000 >> 0x10)) + , CONCAT22(extraout_var_04,uVar2) != 10)) || (0xfff5 < uVar1)) goto ignore_packet; + uVar1 = uVar4 + 0xb & 0xffff; + if (((hdr.numextrarr == 0x100) && (hdr.numauthrr == 0x100)) && ((u16_t)ans.ttl == 0x400)) + { + uVar2 = pbuf_copy_partial(p,&qry,4,(u16_t)((uVar4 + 0xb) * 0x10000 >> 0x10)); + if (CONCAT22(extraout_var_05,uVar2) == 4) { + *(dns_query *)&dns_table[iVar10].ipaddr = qry; + pbuf_free(p); + uVar7 = lwip_htonl(ans._0_4_); + dns_table[iVar10].state = '\x03'; + if (uVar7 < 0x93a81) { + dns_table[iVar10].ttl = uVar7; + } + else { + dns_table[iVar10].ttl = 0x93a80; + } + dns_call_found(i,&dns_table[iVar10].ipaddr); + if (dns_table[iVar10].ttl != 0) { + return; + } + if (dns_table[iVar10].state != '\x03') { + return; + } + dns_table[iVar10].state = '\0'; + return; + } + goto ignore_packet; + } + uVar2 = lwip_htons((u16_t)ans.ttl); + if (0xffff < (int)(CONCAT22(extraout_var_06,uVar2) + uVar1)) goto ignore_packet; + uVar2 = lwip_htons((u16_t)ans.ttl); + uVar1 = uVar2 + uVar1; + uVar11 = uVar11 - 1 & 0xffff; + } + } + else { + if ((dns_table[iVar10].server_idx == '\0') && (dns_servers[1] != 0)) { + *(undefined2 *)&dns_table[iVar10].tmr = 0x301; + dns_check_entry(i); + goto ignore_packet; + } + } + pbuf_free(p); + dns_call_found(i,(ip_addr_t *)0x0); + dns_table[iVar10].state = '\0'; + return; + } + } +ignore_packet: + pbuf_free(p); + return; +} + + + +void dns_init(void) + +{ + if (dns_pcbs == (udp_pcb *)0x0) { + dns_pcbs = udp_new_ip_type(); + udp_bind(dns_pcbs,&ip_addr_any,0); + udp_recv(dns_pcbs,dns_recv,(void *)0x0); + return; + } + return; +} + + + +void dns_setserver(u8_t numdns,ip_addr_t *dnsserver) + +{ + undefined3 in_register_00002029; + u32_t uVar1; + + if (CONCAT31(in_register_00002029,numdns) < 2) { + if (dnsserver == (ip_addr_t *)0x0) { + uVar1 = 0; + } + else { + uVar1 = dnsserver->addr; + } + dns_servers[CONCAT31(in_register_00002029,numdns)].addr = uVar1; + } + return; +} + + + +ip_addr_t * dns_getserver(u8_t numdns) + +{ + undefined3 in_register_00002029; + + if (CONCAT31(in_register_00002029,numdns) < 2) { + return dns_servers + CONCAT31(in_register_00002029,numdns); + } + return &ip_addr_any; +} + + + +void dns_tmr(void) + +{ + dns_check_entry('\0'); + dns_check_entry('\x01'); + dns_check_entry('\x02'); + dns_check_entry('\x03'); + return; +} + + + +err_t dns_gethostbyname_addrtype + (char *hostname,ip_addr_t *addr,dns_found_callback *found,void *callback_arg, + u8_t dns_addrtype) + +{ + u8_t uVar1; + uint uVar2; + size_t __n; + int iVar3; + int iVar4; + uint uVar5; + byte bVar6; + err_t eVar7; + byte bVar8; + uint uVar9; + dns_table_entry_conflict1 *pdVar10; + dns_table_entry_conflict1 *pdVar11; + + if (addr == (ip_addr_t *)0x0) { + return -0x10; + } + if ((((hostname == (char *)0x0) || (*hostname == '\0')) || (dns_pcbs == (udp_pcb *)0x0)) || + (__n = strlen(hostname), 0xff < __n)) { + eVar7 = -0x10; + } + else { + iVar3 = ip4addr_aton(hostname,(ip4_addr_t *)addr); + eVar7 = '\0'; + if (iVar3 == 0) { + pdVar10 = dns_table; + pdVar11 = dns_table; + iVar3 = 0; + do { + if ((pdVar11->state == '\x03') && + (iVar4 = lwip_strnicmp(hostname,pdVar11->name,0x100), iVar4 == 0)) { + addr->addr = dns_table[iVar3].ipaddr.addr; + return '\0'; + } + uVar1 = dns_seqno; + iVar3 = iVar3 + 1; + pdVar11 = pdVar11 + 1; + } while (iVar3 != 4); + eVar7 = -6; + if (dns_servers[0] != 0) { + uVar9 = 0; + uVar2 = 4; + bVar6 = 0; + do { + uVar5 = uVar9 & 0xff; + if (pdVar10->state == '\0') goto LAB_2306c486; + if ((pdVar10->state == '\x03') && (bVar8 = dns_seqno - pdVar10->seqno, bVar6 < bVar8)) { + uVar2 = uVar5; + bVar6 = bVar8; + } + uVar9 = uVar9 + 1; + pdVar10 = pdVar10 + 1; + } while (uVar9 != 4); + eVar7 = -1; + if ((uVar2 != 4) && + (eVar7 = -1, uVar5 = uVar2, uVar9 = uVar2, dns_table[uVar2].state == '\x03')) { +LAB_2306c486: + iVar3 = uVar9 * 0x110; + (&dns_table[0].state)[iVar3] = '\x01'; + (&dns_table[0].seqno)[iVar3] = uVar1; + dns_requests[uVar5].found = found; + dns_requests[uVar5].arg = callback_arg; + memcpy(dns_table[0].name + iVar3,hostname,__n); + dns_table[0].name[iVar3 + __n] = '\0'; + dns_seqno = dns_seqno + '\x01'; + dns_check_entry((u8_t)uVar5); + eVar7 = -5; + } + } + } + } + return eVar7; +} + + + +err_t dns_gethostbyname(char *hostname,ip_addr_t *addr,dns_found_callback *found,void *callback_arg) + +{ + err_t eVar1; + + eVar1 = dns_gethostbyname_addrtype(hostname,addr,found,callback_arg,'\0'); + return eVar1; +} + + + +u16_t lwip_standard_chksum(void *dataptr,int len) + +{ + byte bVar1; + ushort uVar2; + uint uVar3; + uint uVar4; + uint uVar5; + int iVar6; + u16_t t; + ushort uStack2; + + uStack2 = 0; + uVar3 = (uint)dataptr & 1; + if ((uVar3 != 0) && (0 < len)) { + bVar1 = *(byte *)dataptr; + len = len + -1; + dataptr = (void *)((int)dataptr + 1); + uStack2 = (ushort)bVar1 << 8; + } + uVar5 = (uint)dataptr & 3; + if ((uVar5 != 0) && (uVar5 = 0, 1 < len)) { + uVar5 = (uint)*(ushort *)dataptr; + len = len + -2; + dataptr = (void *)((int)dataptr + 2); + } + while (7 < len) { + uVar4 = *(int *)dataptr + uVar5; + if (uVar4 < uVar5) { + uVar4 = uVar4 + 1; + } + uVar5 = ((int *)dataptr)[1] + uVar4; + if (uVar5 < uVar4) { + uVar5 = uVar5 + 1; + } + len = len + -8; + dataptr = (int *)dataptr + 2; + } + iVar6 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + while (1 < len) { + len = len + -2; + iVar6 = iVar6 + (uint)*(ushort *)dataptr; + dataptr = (int *)((int)dataptr + 2); + } + if (len == 1) { + uStack2 = uStack2 | *(byte *)dataptr; + } + uVar5 = ((uint)uStack2 + iVar6 >> 0x10) + ((uint)uStack2 + iVar6 & 0xffff); + iVar6 = (uVar5 >> 0x10) + (uVar5 & 0xffff); + uVar2 = (ushort)iVar6; + if (uVar3 != 0) { + uVar2 = (ushort)((uint)iVar6 >> 8) & 0xff | uVar2 * 0x100; + } + return (u16_t)uVar2; +} + + + +u16_t inet_chksum_pseudo(pbuf *p,u8_t proto,u16_t proto_len,ip4_addr_t *src,ip4_addr_t *dest) + +{ + bool bVar1; + int iVar2; + u16_t uVar3; + u16_t uVar4; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined3 in_register_0000202d; + uint uVar5; + + uVar5 = (src->addr >> 0x10) + (dest->addr & 0xffff) + (dest->addr >> 0x10) + (src->addr & 0xffff); + uVar5 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + uVar5 = (uVar5 >> 0x10) + (uVar5 & 0xffff); + bVar1 = false; + while (p != (pbuf *)0x0) { + uVar3 = lwip_standard_chksum(p->payload,(uint)p->len); + uVar5 = uVar5 + CONCAT22(extraout_var_01,uVar3); + uVar5 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + if ((p->len & 1) != 0) { + bVar1 = (bool)(bVar1 ^ 1); + uVar5 = uVar5 >> 8 & 0xff | uVar5 * 0x100 & 0xffff; + } + p = p->next; + } + if (bVar1) { + uVar5 = uVar5 >> 8 & 0xff | (uVar5 & 0xff) << 8; + } + uVar3 = lwip_htons((u16_t)CONCAT31(in_register_0000202d,proto)); + uVar4 = lwip_htons(proto_len); + uVar5 = uVar5 + CONCAT22(extraout_var_00,uVar4) + CONCAT22(extraout_var,uVar3); + iVar2 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + return (u16_t)~((short)iVar2 + (short)((uint)iVar2 >> 0x10)); +} + + + +u16_t ip_chksum_pseudo(pbuf *p,u8_t proto,u16_t proto_len,ip4_addr_t *src,ip4_addr_t *dest) + +{ + bool bVar1; + int iVar2; + u16_t uVar3; + u16_t uVar4; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined3 in_register_0000202d; + uint uVar5; + + uVar5 = (src->addr >> 0x10) + (dest->addr & 0xffff) + (dest->addr >> 0x10) + (src->addr & 0xffff); + uVar5 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + uVar5 = (uVar5 >> 0x10) + (uVar5 & 0xffff); + bVar1 = false; + while (p != (pbuf *)0x0) { + uVar3 = lwip_standard_chksum(p->payload,(uint)p->len); + uVar5 = uVar5 + CONCAT22(extraout_var_01,uVar3); + uVar5 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + if ((p->len & 1) != 0) { + bVar1 = (bool)(bVar1 ^ 1); + uVar5 = uVar5 >> 8 & 0xff | uVar5 * 0x100 & 0xffff; + } + p = p->next; + } + if (bVar1) { + uVar5 = uVar5 >> 8 & 0xff | (uVar5 & 0xff) << 8; + } + uVar3 = lwip_htons((u16_t)CONCAT31(in_register_0000202d,proto)); + uVar4 = lwip_htons(proto_len); + uVar5 = uVar5 + CONCAT22(extraout_var_00,uVar4) + CONCAT22(extraout_var,uVar3); + iVar2 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + return (u16_t)~((short)iVar2 + (short)((uint)iVar2 >> 0x10)); +} + + + +u16_t inet_chksum_pseudo_partial + (pbuf *p,u8_t proto,u16_t proto_len,u16_t chksum_len,ip4_addr_t *src, + ip4_addr_t *dest) + +{ + bool bVar1; + int iVar2; + u16_t uVar3; + u16_t uVar4; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined3 in_register_0000202d; + undefined2 in_register_00002036; + uint uVar5; + uint uVar6; + uint uVar7; + + uVar5 = CONCAT22(in_register_00002036,chksum_len); + uVar6 = (src->addr >> 0x10) + (dest->addr & 0xffff) + (dest->addr >> 0x10) + (src->addr & 0xffff); + uVar6 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + uVar6 = (uVar6 >> 0x10) + (uVar6 & 0xffff); + bVar1 = false; + while ((p != (pbuf *)0x0 && (uVar5 != 0))) { + uVar7 = (uint)p->len; + if (uVar5 < (uint)p->len) { + uVar7 = uVar5; + } + uVar3 = lwip_standard_chksum(p->payload,uVar7 & 0xffff); + uVar6 = uVar6 + CONCAT22(extraout_var_01,uVar3); + uVar6 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + uVar5 = uVar5 - (uVar7 & 0xffff) & 0xffff; + if ((p->len & 1) != 0) { + bVar1 = (bool)(bVar1 ^ 1); + uVar6 = uVar6 >> 8 & 0xff | uVar6 * 0x100 & 0xffff; + } + p = p->next; + } + if (bVar1) { + uVar6 = uVar6 >> 8 & 0xff | (uVar6 & 0xff) << 8; + } + uVar3 = lwip_htons((u16_t)CONCAT31(in_register_0000202d,proto)); + uVar4 = lwip_htons(proto_len); + uVar6 = uVar6 + CONCAT22(extraout_var_00,uVar4) + CONCAT22(extraout_var,uVar3); + iVar2 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + return (u16_t)~((short)iVar2 + (short)((uint)iVar2 >> 0x10)); +} + + + +u16_t ip_chksum_pseudo_partial + (pbuf *p,u8_t proto,u16_t proto_len,u16_t chksum_len,ip4_addr_t *src, + ip4_addr_t *dest) + +{ + bool bVar1; + int iVar2; + u16_t uVar3; + u16_t uVar4; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined3 in_register_0000202d; + uint uVar5; + undefined2 in_register_00002036; + uint uVar6; + uint uVar7; + + uVar5 = CONCAT22(in_register_00002036,chksum_len); + uVar6 = (src->addr >> 0x10) + (dest->addr & 0xffff) + (dest->addr >> 0x10) + (src->addr & 0xffff); + uVar6 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + uVar6 = (uVar6 >> 0x10) + (uVar6 & 0xffff); + bVar1 = false; + while ((p != (pbuf *)0x0 && (uVar5 != 0))) { + uVar7 = (uint)p->len; + if (uVar5 < (uint)p->len) { + uVar7 = uVar5; + } + uVar3 = lwip_standard_chksum(p->payload,uVar7 & 0xffff); + uVar6 = uVar6 + CONCAT22(extraout_var_01,uVar3); + uVar6 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + uVar5 = uVar5 - (uVar7 & 0xffff) & 0xffff; + if ((p->len & 1) != 0) { + bVar1 = (bool)(bVar1 ^ 1); + uVar6 = uVar6 >> 8 & 0xff | uVar6 * 0x100 & 0xffff; + } + p = p->next; + } + if (bVar1) { + uVar6 = uVar6 >> 8 & 0xff | (uVar6 & 0xff) << 8; + } + uVar3 = lwip_htons((u16_t)CONCAT31(in_register_0000202d,proto)); + uVar4 = lwip_htons(proto_len); + uVar6 = uVar6 + CONCAT22(extraout_var_00,uVar4) + CONCAT22(extraout_var,uVar3); + iVar2 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + return (u16_t)~((short)iVar2 + (short)((uint)iVar2 >> 0x10)); +} + + + +u16_t inet_chksum(void *dataptr,u16_t len) + +{ + u16_t uVar1; + undefined2 in_register_0000202e; + + uVar1 = lwip_standard_chksum(dataptr,CONCAT22(in_register_0000202e,len)); + return ~uVar1; +} + + + +u16_t inet_chksum_pbuf(pbuf *p) + +{ + bool bVar1; + ushort uVar2; + uint uVar3; + u16_t uVar4; + undefined2 extraout_var; + + bVar1 = false; + uVar3 = 0; + while (uVar2 = (ushort)uVar3, p != (pbuf *)0x0) { + uVar4 = lwip_standard_chksum(p->payload,(uint)p->len); + uVar3 = uVar3 + CONCAT22(extraout_var,uVar4); + uVar3 = (uVar3 & 0xffff) + (uVar3 >> 0x10); + if ((p->len & 1) != 0) { + bVar1 = (bool)(bVar1 ^ 1); + uVar3 = uVar3 >> 8 & 0xff | uVar3 * 0x100 & 0xffff; + } + p = p->next; + } + if (bVar1) { + uVar2 = (ushort)(uVar3 >> 8) & 0xff | (ushort)((uVar3 & 0xff) << 8); + } + return (u16_t)~uVar2; +} + + + +u16_t lwip_chksum_copy(void *dst,void *src,u16_t len) + +{ + u16_t uVar1; + undefined2 in_register_00002032; + + memcpy(dst,src,CONCAT22(in_register_00002032,len)); + uVar1 = lwip_standard_chksum(dst,CONCAT22(in_register_00002032,len)); + return uVar1; +} + + + +void lwip_init(void) + +{ + stats_init(); + sys_init(); + mem_init(); + memp_init(); + netif_init(); + udp_init(); + tcp_init(); + igmp_init(); + dns_init(); + sys_timeouts_init(); + return; +} + + + +void dhcp_set_state(dhcp *dhcp,u8_t new_state) + +{ + undefined3 in_register_0000202d; + + if ((uint)dhcp->state != CONCAT31(in_register_0000202d,new_state)) { + dhcp->state = new_state; + dhcp->tries = '\0'; + dhcp->request_timeout = 0; + } + return; +} + + + +u16_t dhcp_option_short(u16_t options_out_len,u8_t *options,u16_t value) + +{ + undefined2 in_register_0000202a; + int iVar1; + + iVar1 = CONCAT22(in_register_0000202a,options_out_len); + options[iVar1] = (u8_t)(value >> 8); + options[iVar1 + 1U & 0xffff] = (u8_t)value; + return (u16_t)((uint)((iVar1 + 2) * 0x10000) >> 0x10); +} + + + +u16_t dhcp_option_long(u16_t options_out_len,u8_t *options,u32_t value) + +{ + undefined2 in_register_0000202a; + int iVar1; + + iVar1 = CONCAT22(in_register_0000202a,options_out_len); + options[iVar1] = (u8_t)(value >> 0x18); + options[iVar1 + 1U & 0xffff] = (u8_t)(value >> 0x10); + options[iVar1 + 2U & 0xffff] = (u8_t)(value >> 8); + options[iVar1 + 3U & 0xffff] = (u8_t)value; + return (u16_t)((uint)((iVar1 + 4) * 0x10000) >> 0x10); +} + + + +pbuf * dhcp_create_msg(netif *netif,dhcp *dhcp,u8_t message_type,u16_t *options_out_len) + +{ + u8_t uVar1; + u32_t xid; + undefined *__s; + u32_t uVar2; + undefined3 in_register_00002031; + int iVar3; + u8_t *puVar4; + u8_t *puVar5; + pbuf *ppVar6; + + iVar3 = CONCAT31(in_register_00002031,message_type); + if (((netif == (netif *)0x0) || (dhcp == (dhcp *)0x0)) || + (ppVar6 = pbuf_alloc(PBUF_TRANSPORT,0x134,PBUF_RAM), ppVar6 == (pbuf *)0x0)) { + ppVar6 = (pbuf *)0x0; + } + else { + if ((iVar3 != 3) || (dhcp->state == '\x03')) { + if (dhcp->tries == '\0') { + xid = bl_rand(); + } + dhcp->xid = xid; + } + __s = (undefined *)ppVar6->payload; + memset(__s,0,0x134); + *__s = 1; + __s[1] = 1; + __s[2] = netif->hwaddr_len; + uVar2 = lwip_htonl(dhcp->xid); + __s[4] = (char)uVar2; + __s[5] = (char)(uVar2 >> 8); + __s[6] = (char)(uVar2 >> 0x10); + __s[7] = (char)(uVar2 >> 0x18); + if (((iVar3 == 4) || ((iVar3 - 7U & 0xff) < 2)) || + ((iVar3 == 3 && ((byte)(dhcp->state - 4) < 2)))) { + uVar2 = (netif->ip_addr).addr; + __s[0xc] = (char)uVar2; + __s[0xd] = (char)(uVar2 >> 8); + __s[0xe] = (char)(uVar2 >> 0x10); + __s[0xf] = (char)(uVar2 >> 0x18); + } + puVar5 = netif->hwaddr; + puVar4 = __s + 0x1c; + do { + uVar1 = *puVar5; + puVar5 = puVar5 + 1; + *puVar4 = uVar1; + puVar4 = puVar4 + 1; + } while (puVar5 != &netif->hwaddr_len); + __s[0xec] = 99; + __s[0xef] = 99; + __s[0xed] = 0x82; + __s[0xf0] = 0x35; + __s[0xf1] = 1; + __s[0xee] = 0x53; + __s[0xf2] = message_type; + *options_out_len = 3; + } + return ppVar6; +} + + + +void dhcp_option_trailer(u16_t options_out_len,u8_t *options,pbuf *p_out) + +{ + undefined2 in_register_0000202a; + uint uVar1; + + uVar1 = CONCAT22(in_register_0000202a,options_out_len) + 1U & 0xffff; + options[CONCAT22(in_register_0000202a,options_out_len)] = -1; + options = options + uVar1; + while (uVar1 < 0x44) { + *options = '\0'; + uVar1 = uVar1 + 1 & 0xffff; + options = options + 1; + } + pbuf_realloc(p_out,(u16_t)((uVar1 + 0xf0) * 0x10000 >> 0x10)); + return; +} + + + +err_t dhcp_discover(netif *netif) + +{ + u8_t *options; + dhcp *dhcp; + pbuf *p_out; + undefined2 extraout_var; + uint uVar1; + int iVar2; + u16_t auStack34 [2]; + u16_t options_out_len; + + dhcp = (dhcp *)netif->client_data[0]; + (dhcp->offered_ip_addr).addr = 0; + dhcp_set_state(dhcp,'\x06'); + p_out = dhcp_create_msg(netif,dhcp,'\x01',auStack34); + if (p_out != (pbuf *)0x0) { + uVar1 = (uint)auStack34[0]; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar1] = '9'; + options[uVar1 + 1 & 0xffff] = '\x02'; + auStack34[0] = (u16_t)((uVar1 + 2) * 0x10000 >> 0x10); + auStack34[0] = dhcp_option_short(auStack34[0],options,netif->mtu); + options[CONCAT22(extraout_var,auStack34[0])] = '7'; + options[CONCAT22(extraout_var,auStack34[0]) + 1U & 0xffff] = '\x04'; + auStack34[0] = auStack34[0] + 2; + iVar2 = 0; + do { + options[(uint)auStack34[0]] = "\x01\x03\x1c\x06"[iVar2]; + auStack34[0] = (u16_t)(((uint)auStack34[0] + 1) * 0x10000 >> 0x10); + iVar2 = iVar2 + 1; + } while (iVar2 != 4); + dhcp_option_trailer(auStack34[0],options,p_out); + udp_sendto_if_src(dhcp_pcb,p_out,&ip_addr_broadcast,0x43,netif,&ip_addr_any); + pbuf_free(p_out); + } + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + if (dhcp->tries < 6) { + uVar1 = (uint)((1 << ((uint)dhcp->tries & 0x1f)) * 0x3e80000) >> 0x10; + } + else { + uVar1 = 60000; + } + dhcp->request_timeout = (u16_t)((int)(uVar1 + 499) / 500); + return '\0'; +} + + + +void dhcp_check(netif *netif) + +{ + dhcp *dhcp; + + dhcp = (dhcp *)netif->client_data[0]; + dhcp_set_state(dhcp,'\b'); + etharp_query(netif,&dhcp->offered_ip_addr,(pbuf *)0x0); + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + dhcp->request_timeout = 1; + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void dhcp_bind(netif *netif) + +{ + byte bVar1; + dhcp *dhcp; + u16_t uVar2; + uint uVar3; + int iVar4; + ip4_addr_t iStack24; + ip4_addr_t sn_mask; + ip4_addr_t gw_addr; + + if (netif == (netif *)0x0) { + return; + } + dhcp = (dhcp *)netif->client_data[0]; + if (dhcp == (dhcp *)0x0) { + return; + } + dhcp->lease_used = 0; + if (dhcp->offered_t0_lease != 0xffffffff) { + uVar3 = dhcp->offered_t0_lease + 0x1e; + if (uVar3 < 0x3c0000) { + uVar3 = uVar3 / 0x3c; + uVar2 = (u16_t)uVar3; + if (uVar3 == 0) { + dhcp->t0_timeout = 1; + goto LAB_2306cc34; + } + } + else { + uVar2 = 0xffff; + } + dhcp->t0_timeout = uVar2; + } +LAB_2306cc34: + if (dhcp->offered_t1_renew != 0xffffffff) { + uVar3 = dhcp->offered_t1_renew + 0x1e; + if (uVar3 < 0x3c0000) { + uVar3 = uVar3 / 0x3c; + uVar2 = (u16_t)uVar3; + if (uVar3 != 0) goto LAB_2306cc56; + dhcp->t1_timeout = 1; + } + else { + uVar2 = 0xffff; +LAB_2306cc56: + dhcp->t1_timeout = uVar2; + } + dhcp->t1_renew_time = dhcp->t1_timeout; + } + if (dhcp->offered_t2_rebind == 0xffffffff) goto LAB_2306cc90; + uVar3 = dhcp->offered_t2_rebind + 0x1e; + if (uVar3 < 0x3c0000) { + uVar3 = uVar3 / 0x3c; + uVar2 = (u16_t)uVar3; + if (uVar3 != 0) goto LAB_2306cc84; + dhcp->t2_timeout = 1; + } + else { + uVar2 = 0xffff; +LAB_2306cc84: + dhcp->t2_timeout = uVar2; + } + dhcp->t2_rebind_time = dhcp->t2_timeout; +LAB_2306cc90: + if ((dhcp->t2_timeout <= dhcp->t1_timeout) && (dhcp->t2_timeout != 0)) { + dhcp->t1_timeout = 0; + } + if (dhcp->subnet_mask_given == '\0') { + bVar1 = *(byte *)&(dhcp->offered_ip_addr).addr; + if ((char)bVar1 < '\0') { + if (bVar1 < 0xc0) { + iVar4 = 0x10000; + } + else { + iVar4 = 0x1000000; + } + iStack24 = (ip4_addr_t)(iVar4 - 1); + } + else { + iStack24 = (ip4_addr_t)0xff; + } + } + else { + iStack24 = (ip4_addr_t)(dhcp->offered_sn_mask).addr; + } + sn_mask = (dhcp->offered_gw_addr).addr; + if ((ip4_addr_t)sn_mask == (ip4_addr_t)0x0) { + sn_mask = (dhcp->offered_ip_addr).addr & (uint)iStack24 | 0x1000000; + } + dhcp_set_state(dhcp,'\n'); + netif_set_addr(netif,&dhcp->offered_ip_addr,&iStack24,&sn_mask); + return; +} + + + +err_t dhcp_inc_pcb_refcount(void) + +{ + udp_pcb *pcb; + + if (dhcp_pcb_refcount == '\0') { + pcb = udp_new(); + if (pcb == (udp_pcb *)0x0) { + dhcp_pcb = pcb; + return -1; + } + dhcp_pcb = pcb; + pcb->so_options = pcb->so_options | 0x20; + udp_bind(pcb,&ip_addr_any,0x44); + udp_connect(dhcp_pcb,&ip_addr_any,0x43); + udp_recv(dhcp_pcb,dhcp_recv,(void *)0x0); + } + dhcp_pcb_refcount = dhcp_pcb_refcount + '\x01'; + return '\0'; +} + + + +u16_t dhcp_option_hostname(u16_t options_out_len,u8_t *options) + +{ + undefined2 in_register_0000202a; + int iVar1; + size_t sVar2; + u8_t **in_a2; + u8_t *puVar3; + u8_t *puVar4; + uint uVar5; + uint uVar6; + uint uVar7; + + iVar1 = CONCAT22(in_register_0000202a,options_out_len); + if ((*in_a2 != (u8_t *)0x0) && (sVar2 = strlen((char *)*in_a2), sVar2 != 0)) { + puVar3 = *in_a2; + uVar6 = 0x41U - iVar1; + if (sVar2 < 0x41U - iVar1) { + uVar6 = sVar2; + } + options[iVar1] = '\f'; + uVar5 = iVar1 + 2U & 0xffff; + options[iVar1 + 1U & 0xffff] = (u8_t)uVar6; + puVar4 = puVar3; + uVar7 = uVar5; + while (puVar4 != puVar3 + uVar6) { + options[uVar7] = *puVar4; + uVar7 = uVar7 + 1 & 0xffff; + puVar4 = puVar4 + 1; + } + options_out_len = (short)uVar5 + (short)uVar6; + } + return options_out_len; +} + + + +err_t dhcp_reboot(netif *netif) + +{ + u8_t *options; + dhcp *dhcp; + err_t eVar1; + u16_t options_out_len_00; + pbuf *p_out; + undefined2 extraout_var; + u32_t value; + undefined2 extraout_var_00; + uint uVar2; + int iVar3; + u16_t auStack34 [2]; + u16_t options_out_len; + + dhcp = (dhcp *)netif->client_data[0]; + dhcp_set_state(dhcp,'\x03'); + p_out = dhcp_create_msg(netif,dhcp,'\x03',auStack34); + eVar1 = -1; + if (p_out != (pbuf *)0x0) { + uVar2 = (uint)auStack34[0]; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar2] = '9'; + options[uVar2 + 1 & 0xffff] = '\x02'; + auStack34[0] = (u16_t)((uVar2 + 2) * 0x10000 >> 0x10); + options_out_len_00 = dhcp_option_short(auStack34[0],options,0x240); + iVar3 = CONCAT22(extraout_var,options_out_len_00); + options[iVar3] = '2'; + options[iVar3 + 1U & 0xffff] = '\x04'; + options_out_len_00 = (u16_t)((uint)((iVar3 + 2) * 0x10000) >> 0x10); + auStack34[0] = options_out_len_00; + value = lwip_htonl((dhcp->offered_ip_addr).addr); + auStack34[0] = dhcp_option_long(options_out_len_00,options,value); + options[CONCAT22(extraout_var_00,auStack34[0])] = '7'; + options[CONCAT22(extraout_var_00,auStack34[0]) + 1U & 0xffff] = '\x04'; + auStack34[0] = auStack34[0] + 2; + iVar3 = 0; + do { + options[(uint)auStack34[0]] = "\x01\x03\x1c\x06"[iVar3]; + auStack34[0] = (u16_t)(((uint)auStack34[0] + 1) * 0x10000 >> 0x10); + iVar3 = iVar3 + 1; + } while (iVar3 != 4); + auStack34[0] = dhcp_option_hostname(auStack34[0],options); + dhcp_option_trailer(auStack34[0],options,p_out); + eVar1 = udp_sendto_if(dhcp_pcb,p_out,&ip_addr_broadcast,0x43,netif); + pbuf_free(p_out); + } + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + if (dhcp->tries < 10) { + uVar2 = (uint)dhcp->tries * 0x3e80000 >> 0x10; + } + else { + uVar2 = 10000; + } + dhcp->request_timeout = (u16_t)((int)(uVar2 + 499) / 500); + return eVar1; +} + + + +err_t dhcp_select(netif *netif) + +{ + u8_t *options; + dhcp *dhcp; + err_t eVar1; + u16_t options_out_len_00; + pbuf *p_out; + undefined2 extraout_var; + u32_t value; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + uint uVar2; + int iVar3; + u16_t auStack34 [2]; + u16_t options_out_len; + + eVar1 = -0x10; + if (netif != (netif *)0x0) { + dhcp = (dhcp *)netif->client_data[0]; + eVar1 = -6; + if (dhcp != (dhcp *)0x0) { + dhcp_set_state(dhcp,'\x01'); + p_out = dhcp_create_msg(netif,dhcp,'\x03',auStack34); + eVar1 = -1; + if (p_out != (pbuf *)0x0) { + uVar2 = (uint)auStack34[0]; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar2] = '9'; + options[uVar2 + 1 & 0xffff] = '\x02'; + auStack34[0] = (u16_t)((uVar2 + 2) * 0x10000 >> 0x10); + options_out_len_00 = dhcp_option_short(auStack34[0],options,netif->mtu); + iVar3 = CONCAT22(extraout_var,options_out_len_00); + options[iVar3] = '2'; + options[iVar3 + 1U & 0xffff] = '\x04'; + options_out_len_00 = (u16_t)((uint)((iVar3 + 2) * 0x10000) >> 0x10); + auStack34[0] = options_out_len_00; + value = lwip_htonl((dhcp->offered_ip_addr).addr); + options_out_len_00 = dhcp_option_long(options_out_len_00,options,value); + iVar3 = CONCAT22(extraout_var_00,options_out_len_00); + options[iVar3] = '6'; + options[iVar3 + 1U & 0xffff] = '\x04'; + options_out_len_00 = (u16_t)((uint)((iVar3 + 2) * 0x10000) >> 0x10); + auStack34[0] = options_out_len_00; + value = lwip_htonl((dhcp->server_ip_addr).addr); + auStack34[0] = dhcp_option_long(options_out_len_00,options,value); + options[CONCAT22(extraout_var_01,auStack34[0])] = '7'; + options[CONCAT22(extraout_var_01,auStack34[0]) + 1U & 0xffff] = '\x04'; + auStack34[0] = auStack34[0] + 2; + iVar3 = 0; + do { + options[(uint)auStack34[0]] = "\x01\x03\x1c\x06"[iVar3]; + auStack34[0] = (u16_t)(((uint)auStack34[0] + 1) * 0x10000 >> 0x10); + iVar3 = iVar3 + 1; + } while (iVar3 != 4); + auStack34[0] = dhcp_option_hostname(auStack34[0],options); + dhcp_option_trailer(auStack34[0],options,p_out); + eVar1 = udp_sendto_if_src(dhcp_pcb,p_out,&ip_addr_broadcast,0x43,netif,&ip_addr_any); + pbuf_free(p_out); + } + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + if (dhcp->tries < 6) { + uVar2 = (uint)((1 << ((uint)dhcp->tries & 0x1f)) * 0x3e80000) >> 0x10; + } + else { + uVar2 = 60000; + } + dhcp->request_timeout = (u16_t)((int)(uVar2 + 499) / 500); + } + } + return eVar1; +} + + + +void dhcp_dec_pcb_refcount(void) + +{ + dhcp_pcb_refcount = dhcp_pcb_refcount + -1; + if (dhcp_pcb_refcount == '\0') { + udp_remove(dhcp_pcb); + dhcp_pcb = (udp_pcb *)0x0; + return; + } + return; +} + + + +void dhcp_handle_ack(dhcp_msg *msg_in) + +{ + u8_t uVar1; + u32_t uVar2; + int in_a1; + uint uVar3; + ip_addr_t iStack20; + ip_addr_t dns_addr; + + uVar1 = dhcp_rx_options_given[3]; + *(undefined4 *)(msg_in->chaddr + 4) = 0; + *(undefined4 *)(msg_in->chaddr + 8) = 0; + if (uVar1 != '\0') { + *(u32_t *)(msg_in->chaddr + 0xc) = dhcp_rx_options_val[3]; + } + uVar3 = dhcp_rx_options_val[4]; + if (dhcp_rx_options_given[4] == '\0') { + uVar3 = *(uint *)(msg_in->chaddr + 0xc) >> 1; + } + *(uint *)msg_in->sname = uVar3; + uVar3 = dhcp_rx_options_val[5]; + if (dhcp_rx_options_given[5] == '\0') { + uVar3 = (uint)(*(int *)(msg_in->chaddr + 0xc) * 7) >> 3; + } + *(uint *)(msg_in->sname + 4) = uVar3; + *(undefined4 *)msg_in->chaddr = *(undefined4 *)(in_a1 + 0x10); + if (dhcp_rx_options_given[6] == '\0') { + *(undefined *)((int)&msg_in->xid + 3) = 0; + } + else { + uVar2 = lwip_htonl(dhcp_rx_options_val[6]); + *(u32_t *)(msg_in->chaddr + 4) = uVar2; + *(undefined *)((int)&msg_in->xid + 3) = 1; + } + if (dhcp_rx_options_given[7] != '\0') { + uVar2 = lwip_htonl(dhcp_rx_options_val[7]); + *(u32_t *)(msg_in->chaddr + 8) = uVar2; + } + if (dhcp_rx_options_given[8] != '\0') { + iStack20 = (ip_addr_t)lwip_htonl(dhcp_rx_options_val[8]); + dns_setserver('\0',&iStack20); + if (dhcp_rx_options_given[9] != '\0') { + iStack20 = (ip_addr_t)lwip_htonl(dhcp_rx_options_val[9]); + dns_setserver('\x01',&iStack20); + } + } + return; +} + + + +void dhcp_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port) + +{ + byte bVar1; + byte bVar2; + bool bVar3; + pbuf **pppVar4; + netif *netif; + uint uVar5; + void *pvVar6; + u16_t uVar7; + u32_t uVar8; + undefined2 extraout_var; + void *pvVar9; + uint uVar10; + char *pcVar11; + uint uVar12; + u8_t *puVar13; + u32_t *puVar14; + pbuf *buf; + uint uVar15; + uint uVar16; + int iVar17; + uint uVar18; + void *pvStack96; + u32_t uStack68; + u32_t value; + + netif = ip_data.current_input_netif; + puVar14 = (u32_t *)(ip_data.current_input_netif)->client_data[0]; + if ((((puVar14 != (u32_t *)0x0) && (*(char *)(puVar14 + 1) != '\0')) && (0x2b < p->len)) && + (pcVar11 = (char *)p->payload, *pcVar11 == '\x02')) { + uVar16 = 0; + do { + if (((uint)(ip_data.current_input_netif)->hwaddr_len <= (uVar16 & 0xff)) || (uVar16 == 6)) { + uVar8 = lwip_htonl(*(u32_t *)(pcVar11 + 4)); + if ((uVar8 == *puVar14) && (memset(dhcp_rx_options_given,0,10), 0x2b < p->len)) { + uVar16 = (uint)p->tot_len; + bVar3 = false; + uVar18 = 0xf0; + buf = p; + goto LAB_2306d36a; + } + break; + } + puVar13 = (ip_data.current_input_netif)->hwaddr + uVar16; + iVar17 = uVar16 + 0x1c; + uVar16 = uVar16 + 1; + } while (pcVar11[iVar17] == *puVar13); + } +free_pbuf_and_return: + pbuf_free(p); + return; +LAB_2306d36a: + do { + uVar12 = (uint)buf->len; + if (uVar18 < uVar12) { + pvStack96 = buf->payload; + uVar12 = uVar18; +LAB_2306d5ac: + if (uVar16 <= uVar12) goto LAB_2306d5c2; + bVar2 = *(byte *)((int)pvStack96 + uVar12); + if (bVar2 == 0xff) goto LAB_2306d5c2; + uVar15 = uVar12 + 2 & 0xffff; + if (uVar15 < uVar12) break; + if (uVar12 + 1 < (uint)buf->len) { + bVar1 = ((byte *)((int)pvStack96 + uVar12))[1]; +LAB_2306d400: + uVar10 = (uint)bVar1; + if (bVar2 == 0x33) { + if (bVar1 != 4) break; + uVar5 = 4; + iVar17 = 3; + } + else { + if (bVar2 < 0x34) { + if (bVar2 == 1) { + if (bVar1 == 4) { + uVar5 = 4; + iVar17 = 6; + goto LAB_2306d486; + } + break; + } + if (bVar2 == 0) goto LAB_2306d572; + if (bVar2 != 3) goto LAB_2306d41e; + if (uVar10 <= bVar2) break; + iVar17 = 7; + uVar5 = 4; + } + else { + if (bVar2 == 0x36) { +LAB_2306d558: + if (uVar10 != 4) break; + uVar5 = 4; + iVar17 = 2; + } + else { + if (bVar2 < 0x37) { + if (bVar2 == 0x34) goto LAB_2306d542; +LAB_2306d450: + if (bVar2 == 0x35) { + if (uVar10 != 1) break; + uVar5 = 1; + iVar17 = 1; + } + else { +LAB_2306d422: + iVar17 = -1; + uVar5 = 0; + } + } + else { + if (bVar2 == 0x3a) goto LAB_2306d566; +LAB_2306d46c: + if (bVar2 != 0x3b) goto LAB_2306d422; + if (uVar10 != 4) break; + uVar5 = 4; + iVar17 = 5; + } + } + } + } + } + else { + if (buf->next != (pbuf *)0x0) { + bVar1 = *(byte *)buf->next->payload; + goto LAB_2306d400; + } + if (bVar2 == 0x33) break; + if (bVar2 < 0x34) { + if (bVar2 == 1) break; + if (bVar2 != 0) { + if (bVar2 != 3) { + uVar10 = 0; +LAB_2306d41e: + if (bVar2 != 6) goto LAB_2306d422; + if ((uVar10 & 3) == 0) { + uVar5 = uVar10; + if (8 < uVar10) { + uVar5 = 8; + } + if (uVar5 <= uVar10) { + iVar17 = 8; + goto LAB_2306d486; + } + } + } + break; + } +LAB_2306d572: + uVar12 = uVar12 + 1 & 0xffff; + goto LAB_2306d57a; + } + if (bVar2 == 0x36) { + uVar10 = 0; + goto LAB_2306d558; + } + if (bVar2 < 0x37) { + if (bVar2 != 0x34) { + uVar10 = 0; + goto LAB_2306d450; + } + uVar10 = 0; +LAB_2306d542: + if ((uVar10 != 1) || (uVar18 != 0xf0)) break; + uVar5 = 1; + iVar17 = 0; + } + else { + if (bVar2 != 0x3a) { + uVar10 = 0; + goto LAB_2306d46c; + } + uVar10 = 0; +LAB_2306d566: + if (uVar10 != 4) break; + uVar5 = 4; + iVar17 = 4; + } + } +LAB_2306d486: + if (0xfffd < uVar10 + uVar12) break; + uVar12 = uVar10 + uVar15 & 0xffff; + if (uVar5 != 0) { + uStack68 = 0; + puVar13 = dhcp_rx_options_given + iVar17; + while (*puVar13 == '\0') { + uVar10 = uVar5; + if (4 < uVar5) { + uVar10 = 4; + } + uVar7 = pbuf_copy_partial(buf,&uStack68,(u16_t)uVar10,(u16_t)uVar15); + if (uVar10 != CONCAT22(extraout_var,uVar7)) goto free_pbuf_and_return; + if (uVar5 < 5) { + if (uVar5 == 4) { + uStack68 = lwip_htonl(uStack68); + } + else { + if (uVar5 != 1) goto free_pbuf_and_return; + uStack68 = uStack68 & 0xff; + } + dhcp_rx_options_given[iVar17] = '\x01'; + dhcp_rx_options_val[iVar17] = uStack68; + break; + } + if ((uVar5 & 3) != 0) goto free_pbuf_and_return; + *puVar13 = '\x01'; + uVar8 = lwip_htonl(uStack68); + dhcp_rx_options_val[iVar17] = uVar8; + uVar10 = uVar15 + 4 & 0xffff; + uVar5 = uVar5 - 4 & 0xff; + puVar13 = puVar13 + 1; + if (uVar10 < uVar15) goto free_pbuf_and_return; + iVar17 = iVar17 + 1; + uVar15 = uVar10; + } + } +LAB_2306d57a: + uVar15 = (uint)buf->len; + if (uVar15 <= uVar12) { + uVar12 = uVar12 - uVar15 & 0xffff; + uVar16 = uVar16 - uVar15 & 0xffff; + if ((uVar16 <= uVar12) || (buf = buf->next, buf == (pbuf *)0x0)) break; + pvStack96 = buf->payload; + } + goto LAB_2306d5ac; + } + pppVar4 = &buf->next; + uVar18 = uVar18 - uVar12 & 0xffff; + uVar16 = uVar16 - uVar12 & 0xffff; + buf = *pppVar4; + } while (*pppVar4 != (pbuf *)0x0); + goto free_pbuf_and_return; +LAB_2306d5c2: + if (dhcp_rx_options_given[0] != '\0') { + dhcp_rx_options_given[0] = '\0'; + if (dhcp_rx_options_val[0] == 1) { +LAB_2306d676: + uVar16 = 0xec; + uVar18 = 0x6c; + buf = p; + goto LAB_2306d36a; + } + if (dhcp_rx_options_val[0] == 2) goto LAB_2306d660; + if (dhcp_rx_options_val[0] == 3) { + bVar3 = true; + goto LAB_2306d676; + } + } + if (!bVar3) { + if (dhcp_rx_options_given[1] == '\0') goto free_pbuf_and_return; + pvVar9 = p->payload; + if ((char)dhcp_rx_options_val[1] != '\x05') { + if ((char)dhcp_rx_options_val[1] == '\x06') { + if (((byte)(*(char *)((int)puVar14 + 5) - 3U) < 3) || + (*(char *)((int)puVar14 + 5) == '\x01')) { + dhcp_set_state((dhcp *)netif->client_data[0],'\f'); + netif_set_addr(netif,(ip4_addr_t *)&ip_addr_any,(ip4_addr_t *)&ip_addr_any, + (ip4_addr_t *)&ip_addr_any); + dhcp_discover(netif); + } + } + else { + if ((((char)dhcp_rx_options_val[1] == '\x02') && (*(char *)((int)puVar14 + 5) == '\x06')) && + (dhcp_rx_options_given[2] != '\0')) { + pvVar6 = netif->client_data[0]; + *(undefined2 *)((int)pvVar6 + 8) = 0; + uVar8 = lwip_htonl(dhcp_rx_options_val[2]); + *(u32_t *)((int)pvVar6 + 0x18) = uVar8; + *(undefined4 *)((int)pvVar6 + 0x1c) = *(undefined4 *)((int)pvVar9 + 0x10); + dhcp_select(netif); + } + } + goto free_pbuf_and_return; + } + if (*(char *)((int)puVar14 + 5) == '\x01') { + dhcp_handle_ack((dhcp_msg *)netif->client_data[0]); + if ((netif->flags & 8) != 0) { + dhcp_check(netif); + goto free_pbuf_and_return; + } + } + else { + if (2 < (byte)(*(char *)((int)puVar14 + 5) - 3U)) goto free_pbuf_and_return; + dhcp_handle_ack((dhcp_msg *)netif->client_data[0]); + } + dhcp_bind(netif); + goto free_pbuf_and_return; + } +LAB_2306d660: + bVar3 = false; + uVar16 = 0x6c; + uVar18 = 0x2c; + buf = p; + goto LAB_2306d36a; +} + + + +void dhcp_network_changed(netif *netif) + +{ + byte bVar1; + void *pvVar2; + + pvVar2 = netif->client_data[0]; + if (pvVar2 == (void *)0x0) { + return; + } + bVar1 = *(byte *)((int)pvVar2 + 5); + if (bVar1 < 6) { + if (2 < bVar1) { +LAB_2306d7a6: + *(undefined *)((int)pvVar2 + 6) = 0; + dhcp_reboot(netif); + return; + } + if (bVar1 == 0) { + return; + } + } + else { + if (bVar1 == 10) goto LAB_2306d7a6; + } + *(undefined *)((int)pvVar2 + 6) = 0; + dhcp_discover(netif); + return; +} + + + +void dhcp_arp_reply(netif *netif,ip4_addr_t *addr) + +{ + dhcp *dhcp; + u8_t *options; + pbuf *p_out; + u32_t value; + uint uVar1; + u16_t options_out_len_00; + u16_t auStack34 [2]; + u16_t options_out_len; + + if (netif != (netif *)0x0) { + dhcp = (dhcp *)netif->client_data[0]; + if (((dhcp != (dhcp *)0x0) && (dhcp->state == '\b')) && + (addr->addr == (dhcp->offered_ip_addr).addr)) { + dhcp_set_state(dhcp,'\f'); + p_out = dhcp_create_msg(netif,dhcp,'\x04',auStack34); + if (p_out != (pbuf *)0x0) { + uVar1 = (uint)auStack34[0]; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar1] = '2'; + options[uVar1 + 1 & 0xffff] = '\x04'; + options_out_len_00 = (u16_t)((uVar1 + 2) * 0x10000 >> 0x10); + auStack34[0] = options_out_len_00; + value = lwip_htonl((dhcp->offered_ip_addr).addr); + auStack34[0] = dhcp_option_long(options_out_len_00,options,value); + dhcp_option_trailer(auStack34[0],options,p_out); + udp_sendto_if_src(dhcp_pcb,p_out,&ip_addr_broadcast,0x43,netif,&ip_addr_any); + pbuf_free(p_out); + } + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + dhcp->request_timeout = 0x14; + } + return; + } + return; +} + + + +err_t dhcp_renew(netif *netif) + +{ + u8_t *options; + dhcp *dhcp; + err_t eVar1; + pbuf *p_out; + undefined2 extraout_var; + uint uVar2; + int iVar3; + u16_t auStack34 [2]; + u16_t options_out_len; + + dhcp = (dhcp *)netif->client_data[0]; + dhcp_set_state(dhcp,'\x05'); + p_out = dhcp_create_msg(netif,dhcp,'\x03',auStack34); + eVar1 = -1; + if (p_out != (pbuf *)0x0) { + uVar2 = (uint)auStack34[0]; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar2] = '9'; + options[uVar2 + 1 & 0xffff] = '\x02'; + auStack34[0] = (u16_t)((uVar2 + 2) * 0x10000 >> 0x10); + auStack34[0] = dhcp_option_short(auStack34[0],options,netif->mtu); + options[CONCAT22(extraout_var,auStack34[0])] = '7'; + options[CONCAT22(extraout_var,auStack34[0]) + 1U & 0xffff] = '\x04'; + auStack34[0] = auStack34[0] + 2; + iVar3 = 0; + do { + options[(uint)auStack34[0]] = "\x01\x03\x1c\x06"[iVar3]; + auStack34[0] = (u16_t)(((uint)auStack34[0] + 1) * 0x10000 >> 0x10); + iVar3 = iVar3 + 1; + } while (iVar3 != 4); + auStack34[0] = dhcp_option_hostname(auStack34[0],options); + dhcp_option_trailer(auStack34[0],options,p_out); + eVar1 = udp_sendto_if(dhcp_pcb,p_out,&dhcp->server_ip_addr,0x43,netif); + pbuf_free(p_out); + } + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + if (dhcp->tries < 10) { + uVar2 = (uint)dhcp->tries * 0x7d00000 >> 0x10; + } + else { + uVar2 = 20000; + } + dhcp->request_timeout = (u16_t)((int)(uVar2 + 499) / 500); + return eVar1; +} + + + +u8_t dhcp_supplied_address(netif *netif) + +{ + byte bVar1; + bool bVar2; + + if ((netif != (netif *)0x0) && (netif->client_data[0] != (void *)0x0)) { + bVar1 = *(byte *)((int)netif->client_data[0] + 5); + bVar2 = true; + if (bVar1 != 10) { + bVar2 = (uint)bVar1 - 4 < 2; + } + return (u8_t)bVar2; + } + return '\0'; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +void dhcp_release_and_stop(netif *netif) + +{ + dhcp *dhcp; + u8_t uVar1; + undefined3 extraout_var; + pbuf *p_out; + u32_t value; + uint uVar2; + u8_t *options; + u16_t options_out_len_00; + u16_t uStack38; + u16_t options_out_len; + ip_addr_t n; + ip_addr_t server_ip_addr; + + dhcp = (dhcp *)netif->client_data[0]; + if ((dhcp != (dhcp *)0x0) && (dhcp->state != '\0')) { + n = (ip_addr_t)(dhcp->server_ip_addr).addr; + (dhcp->offered_ip_addr).addr = 0; + (dhcp->server_ip_addr).addr = 0; + (dhcp->offered_sn_mask).addr = 0; + (dhcp->offered_gw_addr).addr = 0; + dhcp->offered_t2_rebind = 0; + dhcp->offered_t1_renew = 0; + dhcp->offered_t0_lease = 0; + dhcp->t1_renew_time = 0; + *(undefined4 *)&dhcp->t2_rebind_time = 0; + dhcp->t0_timeout = 0; + uVar1 = dhcp_supplied_address(netif); + if ((CONCAT31(extraout_var,uVar1) != 0) && + (p_out = dhcp_create_msg(netif,dhcp,'\a',&uStack38), p_out != (pbuf *)0x0)) { + uVar2 = (uint)uStack38; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar2] = '6'; + options[uVar2 + 1 & 0xffff] = '\x04'; + options_out_len_00 = (u16_t)((uVar2 + 2) * 0x10000 >> 0x10); + uStack38 = options_out_len_00; + value = lwip_htonl((u32_t)n); + uStack38 = dhcp_option_long(options_out_len_00,options,value); + dhcp_option_trailer(uStack38,options,p_out); + udp_sendto_if(dhcp_pcb,p_out,(ip_addr_t *)&stack0xffffffdc,0x43,netif); + pbuf_free(p_out); + } + netif_set_addr(netif,(ip4_addr_t *)&ip_addr_any,(ip4_addr_t *)&ip_addr_any, + (ip4_addr_t *)&ip_addr_any); + dhcp_set_state(dhcp,'\0'); + if (dhcp->pcb_allocated != '\0') { + dhcp_dec_pcb_refcount(); + dhcp->pcb_allocated = '\0'; + } + } + return; +} + + + +err_t dhcp_start(netif *netif) + +{ + err_t eVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + dhcp *dhcp; + + if (netif == (netif *)0x0) { + return -0x10; + } + if ((netif->flags & 1) == 0) { + return -0x10; + } + dhcp = (dhcp *)netif->client_data[0]; + if (0x23f < netif->mtu) { + if (dhcp == (dhcp *)0x0) { + dhcp = (dhcp *)mem_malloc(0x34); + if (dhcp == (dhcp *)0x0) { + return -1; + } + *(dhcp **)netif->client_data = dhcp; + } + else { + if (dhcp->pcb_allocated != '\0') { + dhcp_dec_pcb_refcount(); + } + } + memset(dhcp,0,0x34); + eVar1 = dhcp_inc_pcb_refcount(); + if (CONCAT31(extraout_var,eVar1) == 0) { + dhcp->pcb_allocated = '\x01'; + if ((netif->flags & 4) == 0) { + dhcp_set_state(dhcp,'\x02'); + return eVar1; + } + eVar1 = dhcp_discover(netif); + if (CONCAT31(extraout_var_00,eVar1) == 0) { + return eVar1; + } + dhcp_release_and_stop(netif); + } + } + return -1; +} + + + +void dhcp_coarse_tmr(void) + +{ + short sVar1; + netif *netif; + dhcp *dhcp; + pbuf *p_out; + undefined2 extraout_var; + uint uVar2; + void *pvVar3; + int iVar4; + u8_t *options; + u16_t auStack50 [2]; + u16_t options_out_len; + + netif = netif_list; + while (netif != (netif *)0x0) { + pvVar3 = netif->client_data[0]; + if ((pvVar3 != (void *)0x0) && (*(char *)((int)pvVar3 + 5) != '\0')) { + if ((*(ushort *)((int)pvVar3 + 0x14) == 0) || + (uVar2 = (uint)*(ushort *)((int)pvVar3 + 0x12) + 1, + *(undefined2 *)((int)pvVar3 + 0x12) = (short)(uVar2 * 0x10000 >> 0x10), + (uint)*(ushort *)((int)pvVar3 + 0x14) != (uVar2 & 0xffff))) { + sVar1 = *(short *)((int)pvVar3 + 0x10); + if ((sVar1 == 0) || (*(short *)((int)pvVar3 + 0x10) = sVar1 + -1, sVar1 != 1)) { + sVar1 = *(short *)((int)pvVar3 + 0xe); + if ((sVar1 != 0) && (*(short *)((int)pvVar3 + 0xe) = sVar1 + -1, sVar1 == 1)) { + pvVar3 = netif->client_data[0]; + if (((*(byte *)((int)pvVar3 + 5) & 0xfb) == 1) || (*(byte *)((int)pvVar3 + 5) == 10)) { + dhcp_renew(netif); + iVar4 = (uint)*(ushort *)((int)pvVar3 + 0xc) - (uint)*(ushort *)((int)pvVar3 + 0x12); + if (1 < iVar4) { + *(undefined2 *)((int)pvVar3 + 0xe) = (short)(iVar4 >> 1); + } + } + } + } + else { + dhcp = (dhcp *)netif->client_data[0]; + if ((dhcp->state < 0xb) && ((0x432U >> ((uint)dhcp->state & 0x1f) & 1) != 0)) { + dhcp_set_state(dhcp,'\x04'); + p_out = dhcp_create_msg(netif,dhcp,'\x03',auStack50); + if (p_out != (pbuf *)0x0) { + uVar2 = (uint)auStack50[0]; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar2] = '9'; + options[uVar2 + 1 & 0xffff] = '\x02'; + auStack50[0] = (u16_t)((uVar2 + 2) * 0x10000 >> 0x10); + auStack50[0] = dhcp_option_short(auStack50[0],options,netif->mtu); + options[CONCAT22(extraout_var,auStack50[0])] = '7'; + options[CONCAT22(extraout_var,auStack50[0]) + 1U & 0xffff] = '\x04'; + auStack50[0] = auStack50[0] + 2; + iVar4 = 0; + do { + options[(uint)auStack50[0]] = "\x01\x03\x1c\x06"[iVar4]; + auStack50[0] = (u16_t)(((uint)auStack50[0] + 1) * 0x10000 >> 0x10); + iVar4 = iVar4 + 1; + } while (iVar4 != 4); + auStack50[0] = dhcp_option_hostname(auStack50[0],options); + dhcp_option_trailer(auStack50[0],options,p_out); + udp_sendto_if(dhcp_pcb,p_out,&ip_addr_broadcast,0x43,netif); + pbuf_free(p_out); + } + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + uVar2 = 10000; + if (dhcp->tries < 10) { + uVar2 = (uint)dhcp->tries * 0x3e80000 >> 0x10; + } + dhcp->request_timeout = (u16_t)((int)(uVar2 + 499) / 500); + iVar4 = (uint)dhcp->t0_timeout - (uint)dhcp->lease_used; + if (1 < iVar4) { + dhcp->t2_rebind_time = (u16_t)(iVar4 >> 1); + } + } + } + } + else { + dhcp_release_and_stop(netif); + dhcp_start(netif); + } + } + netif = netif->next; + } + return; +} + + + +void dhcp_fine_tmr(void) + +{ + char cVar1; + ushort uVar2; + netif *netif; + void *pvVar3; + + netif = netif_list; + do { + if (netif == (netif *)0x0) { + return; + } + pvVar3 = netif->client_data[0]; + if (pvVar3 != (void *)0x0) { + uVar2 = *(ushort *)((int)pvVar3 + 8); + if (uVar2 < 2) { + if (uVar2 == 1) { + *(undefined2 *)((int)pvVar3 + 8) = 0; + pvVar3 = netif->client_data[0]; + cVar1 = *(char *)((int)pvVar3 + 5); + if ((cVar1 == '\f') || (cVar1 == '\x06')) { +LAB_2306de14: + dhcp_discover(netif); + } + else { + if (cVar1 == '\x01') { + if (*(byte *)((int)pvVar3 + 6) < 6) { + dhcp_select(netif); + } + else { + dhcp_release_and_stop(netif); + dhcp_start(netif); + } + } + else { + if (cVar1 == '\b') { + if (*(byte *)((int)pvVar3 + 6) < 2) { + dhcp_check(netif); + } + else { + dhcp_bind(netif); + } + } + else { + if (cVar1 == '\x03') { + if (1 < *(byte *)((int)pvVar3 + 6)) goto LAB_2306de14; + dhcp_reboot(netif); + } + } + } + } + } + } + else { + *(short *)((int)pvVar3 + 8) = uVar2 - 1; + } + } + netif = netif->next; + } while( true ); +} + + + +// WARNING: Type propagation algorithm not settling + +void dhcp_stop(netif *netif) + +{ + dhcp *dhcp; + u8_t uVar1; + undefined3 extraout_var; + pbuf *p_out; + u32_t value; + uint uVar2; + u8_t *options; + u16_t options_out_len; + u16_t uStack38; + ip_addr_t aiStack36 [3]; + + dhcp = (dhcp *)netif->client_data[0]; + if ((dhcp != (dhcp *)0x0) && (dhcp->state != '\0')) { + aiStack36[0] = (ip_addr_t)(dhcp->server_ip_addr).addr; + (dhcp->offered_ip_addr).addr = 0; + (dhcp->server_ip_addr).addr = 0; + (dhcp->offered_sn_mask).addr = 0; + (dhcp->offered_gw_addr).addr = 0; + dhcp->offered_t2_rebind = 0; + dhcp->offered_t1_renew = 0; + dhcp->offered_t0_lease = 0; + dhcp->t1_renew_time = 0; + *(undefined4 *)&dhcp->t2_rebind_time = 0; + dhcp->t0_timeout = 0; + uVar1 = dhcp_supplied_address(netif); + if ((CONCAT31(extraout_var,uVar1) != 0) && + (p_out = dhcp_create_msg(netif,dhcp,'\a',&uStack38), p_out != (pbuf *)0x0)) { + uVar2 = (uint)uStack38; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar2] = '6'; + options[uVar2 + 1 & 0xffff] = '\x04'; + options_out_len = (u16_t)((uVar2 + 2) * 0x10000 >> 0x10); + uStack38 = options_out_len; + value = lwip_htonl((u32_t)aiStack36[0]); + uStack38 = dhcp_option_long(options_out_len,options,value); + dhcp_option_trailer(uStack38,options,p_out); + udp_sendto_if(dhcp_pcb,p_out,aiStack36,0x43,netif); + pbuf_free(p_out); + } + netif_set_addr(netif,(ip4_addr_t *)&ip_addr_any,(ip4_addr_t *)&ip_addr_any, + (ip4_addr_t *)&ip_addr_any); + dhcp_set_state(dhcp,'\0'); + if (dhcp->pcb_allocated != '\0') { + dhcp_dec_pcb_refcount(); + dhcp->pcb_allocated = '\0'; + } + } + return; +} + + + +void etharp_free_entry(int i) + +{ + pbuf *p; + + p = arp_table[i].q; + if (p != (pbuf *)0x0) { + pbuf_free(p); + arp_table[i].q = (pbuf *)0x0; + } + arp_table[i].state = '\0'; + return; +} + + + +s16_t etharp_find_entry(ip4_addr_t *ipaddr,u8_t flags,netif *netif) + +{ + ushort uVar1; + ushort uVar2; + int iVar3; + int iVar4; + int i; + undefined3 in_register_0000202d; + etharp_entry *peVar5; + int iVar6; + s16_t sVar7; + int iVar8; + uint uVar9; + int iVar10; + ushort uVar11; + ushort uVar12; + + peVar5 = arp_table; + uVar2 = 0; + uVar12 = 0; + uVar11 = 0; + iVar3 = 10; + iVar8 = 0; + iVar10 = 10; + iVar4 = 10; + iVar6 = 10; + do { + i = iVar6; + if (iVar6 == 10) { + i = iVar8; + } + if (peVar5->state != '\0') { + if ((ipaddr != (ip4_addr_t *)0x0) && (ipaddr->addr == (peVar5->ipaddr).addr)) { + if (netif == (netif *)0x0) { + return (s16_t)iVar8; + } + if (peVar5->netif == netif) { + return (s16_t)iVar8; + } + } + uVar1 = peVar5->ctime; + if (peVar5->state == '\x01') { + if (peVar5->q == (pbuf *)0x0) { + i = iVar6; + if (uVar12 <= uVar1) { + iVar4 = iVar8; + uVar12 = uVar1; + } + } + else { + i = iVar6; + if (uVar11 <= uVar1) { + iVar3 = iVar8; + uVar11 = uVar1; + } + } + } + else { + i = iVar6; + if (uVar2 <= uVar1) { + iVar10 = iVar8; + uVar2 = uVar1; + } + } + } + uVar9 = iVar8 + 1U & 0xffff; + peVar5 = peVar5 + 1; + iVar8 = (int)(short)uVar9; + iVar6 = i; + if (uVar9 == 10) { + sVar7 = -1; + if (CONCAT31(in_register_0000202d,flags) == 1) { + if (i == 10) { + i = iVar10; + if (((iVar10 == 10) && (i = iVar4, iVar4 == 10)) && (i = iVar3, iVar3 == 10)) { + return -1; + } + etharp_free_entry(i); + } + sVar7 = (s16_t)i; + if (ipaddr != (ip4_addr_t *)0x0) { + arp_table[i].ipaddr.addr = ipaddr->addr; + } + arp_table[i].ctime = 0; + arp_table[i].netif = netif; + } + return sVar7; + } + } while( true ); +} + + + +err_t etharp_raw(netif *netif,eth_addr *ethsrc_addr,eth_addr *ethdst_addr,eth_addr *hwsrc_addr, + ip4_addr_t *ipsrc_addr,eth_addr *hwdst_addr,ip4_addr_t *ipdst_addr,u16_t opcode) + +{ + undefined *puVar1; + err_t eVar2; + u16_t uVar3; + pbuf *p; + + p = pbuf_alloc(PBUF_LINK,0x1c,PBUF_RAM); + if (p == (pbuf *)0x0) { + eVar2 = -1; + lwip_stats.etharp.memerr = lwip_stats.etharp.memerr + 1; + } + else { + puVar1 = (undefined *)p->payload; + uVar3 = lwip_htons(opcode); + puVar1[6] = (char)uVar3; + puVar1[7] = (char)(uVar3 >> 8); + memcpy(puVar1 + 8,hwsrc_addr,6); + memcpy(puVar1 + 0x12,hwdst_addr,6); + memcpy(puVar1 + 0xe,ipsrc_addr,4); + memcpy(puVar1 + 0x18,ipdst_addr,4); + puVar1[1] = 1; + puVar1[2] = 8; + puVar1[4] = 6; + puVar1[5] = 4; + *puVar1 = 0; + puVar1[3] = 0; + ethernet_output(netif,p,ethsrc_addr,ethdst_addr,0x806); + lwip_stats.etharp.xmit = lwip_stats.etharp.xmit + 1; + pbuf_free(p); + eVar2 = '\0'; + } + return eVar2; +} + + + +void etharp_cleanup_netif(netif *netif) + +{ + etharp_entry *peVar1; + int i; + + peVar1 = arp_table; + i = 0; + do { + if ((peVar1->state != '\0') && (peVar1->netif == netif)) { + etharp_free_entry(i); + } + i = i + 1; + peVar1 = peVar1 + 1; + } while (i != 10); + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void etharp_input(pbuf *p,netif *netif) + +{ + bool bVar1; + short *psVar2; + u8_t uVar3; + s16_t sVar4; + undefined3 extraout_var; + short extraout_var_00; + ip4_addr_t iVar5; + eth_addr *dst; + u8_t flags; + pbuf *p_00; + ip4_addr_t iStack56; + ip4_addr_t sipaddr; + ip4_addr_t dipaddr; + + if (netif != (netif *)0x0) { + psVar2 = (short *)p->payload; + if ((((*psVar2 == 0x100) && (*(char *)(psVar2 + 2) == '\x06')) && + (*(char *)((int)psVar2 + 5) == '\x04')) && (psVar2[1] == 8)) { + lwip_stats.etharp.recv = lwip_stats.etharp.recv + 1; + memcpy(&iStack56,psVar2 + 7,4); + memcpy(&sipaddr,psVar2 + 0xc,4); + iVar5 = (ip4_addr_t)(netif->ip_addr).addr; + dst = (eth_addr *)(psVar2 + 4); + if ((iVar5 == (ip4_addr_t)0x0) || (iVar5 != (ip4_addr_t)sipaddr)) { + bVar1 = false; + flags = '\x02'; + } + else { + bVar1 = true; + flags = '\x01'; + } + if (((iStack56 != (ip4_addr_t)0x0) && + (uVar3 = ip4_addr_isbroadcast_u32((u32_t)iStack56,netif), + CONCAT31(extraout_var,uVar3) == 0)) && (((uint)iStack56 & 0xf0) != 0xe0)) { + sVar4 = etharp_find_entry(&iStack56,flags,netif); + _sVar4 = CONCAT22(extraout_var_00,sVar4); + if (-1 < extraout_var_00) { + arp_table[_sVar4].state = '\x02'; + arp_table[_sVar4].netif = netif; + memcpy(&arp_table[_sVar4].ethaddr,dst,6); + p_00 = arp_table[_sVar4].q; + arp_table[_sVar4].ctime = 0; + if (p_00 != (pbuf *)0x0) { + arp_table[_sVar4].q = (pbuf *)0x0; + ethernet_output(netif,p_00,(eth_addr *)netif->hwaddr,dst,0x800); + pbuf_free(p_00); + } + } + } + if (psVar2[3] == 0x100) { + if (bVar1) { + etharp_raw(netif,(eth_addr *)netif->hwaddr,dst,(eth_addr *)netif->hwaddr, + (ip4_addr_t *)&netif->ip_addr,dst,&iStack56,2); + } + } + else { + if (psVar2[3] == 0x200) { + dhcp_arp_reply(netif,&iStack56); + } + else { + lwip_stats.etharp.err = lwip_stats.etharp.err + 1; + } + } + } + else { + lwip_stats.etharp.proterr = lwip_stats.etharp.proterr + 1; + lwip_stats.etharp.drop = lwip_stats.etharp.drop + 1; + } + pbuf_free(p); + return; + } + return; +} + + + +err_t etharp_request(netif *netif,ip4_addr_t *ipaddr) + +{ + err_t eVar1; + + eVar1 = etharp_raw(netif,(eth_addr *)netif->hwaddr,ðbroadcast,(eth_addr *)netif->hwaddr, + (ip4_addr_t *)&netif->ip_addr,ðzero,ipaddr,1); + return eVar1; +} + + + +void etharp_tmr(void) + +{ + u8_t uVar1; + etharp_entry *peVar2; + int i; + uint uVar3; + uint uVar4; + + peVar2 = arp_table; + i = 0; + do { + uVar1 = peVar2->state; + if (uVar1 != '\0') { + uVar3 = (uint)peVar2->ctime + 1; + uVar4 = uVar3 & 0xffff; + peVar2->ctime = (u16_t)(uVar3 * 0x10000 >> 0x10); + if (uVar4 < 300) { + if (uVar1 == '\x01') { + if (4 < uVar4) goto LAB_2306e2e8; + etharp_request(peVar2->netif,&peVar2->ipaddr); + } + else { + if (uVar1 == '\x03') { + peVar2->state = '\x04'; + } + else { + if (uVar1 == '\x04') { + peVar2->state = '\x02'; + } + } + } + } + else { +LAB_2306e2e8: + etharp_free_entry(i); + } + } + i = i + 1; + peVar2 = peVar2 + 1; + if (i == 10) { + return; + } + } while( true ); +} + + + +err_t etharp_output_to_arp_index(netif *netif,pbuf *q,netif_addr_idx_t arp_idx) + +{ + err_t eVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 in_register_00002031; + int iVar2; + eth_addr *ethsrc_addr; + + iVar2 = CONCAT31(in_register_00002031,arp_idx); + ethsrc_addr = (eth_addr *)netif->hwaddr; + if (arp_table[iVar2].state == '\x02') { + if (arp_table[iVar2].ctime < 0x11d) { + if (arp_table[iVar2].ctime < 0x10e) goto LAB_2306e380; + eVar1 = etharp_raw(netif,ethsrc_addr,&arp_table[iVar2].ethaddr,ethsrc_addr, + (ip4_addr_t *)&netif->ip_addr,ðzero,&arp_table[iVar2].ipaddr,1); + _eVar1 = CONCAT31(extraout_var_00,eVar1); + } + else { + eVar1 = etharp_request(netif,&arp_table[iVar2].ipaddr); + _eVar1 = CONCAT31(extraout_var,eVar1); + } + if (_eVar1 == 0) { + arp_table[iVar2].state = '\x03'; + } + } +LAB_2306e380: + eVar1 = ethernet_output(netif,q,ethsrc_addr,&arp_table[iVar2].ethaddr,0x800); + return eVar1; +} + + + +err_t etharp_query(netif *netif,ip4_addr_t *ipaddr,pbuf *q) + +{ + pbuf **pppVar1; + u8_t uVar2; + err_t eVar3; + ushort uVar4; + undefined3 extraout_var; + short extraout_var_00; + pbuf *ppVar5; + uint uVar6; + + uVar2 = ip4_addr_isbroadcast_u32(ipaddr->addr,netif); + if (((CONCAT31(extraout_var,uVar2) != 0) || ((ipaddr->addr & 0xf0) == 0xe0)) || + (ipaddr->addr == 0)) { + return -0x10; + } + uVar4 = etharp_find_entry(ipaddr,'\x01',netif); + if (extraout_var_00 < 0) { + if (q != (pbuf *)0x0) { + lwip_stats.etharp.memerr = lwip_stats.etharp.memerr + 1; + } + return (err_t)uVar4; + } + uVar6 = (uint)uVar4 & 0xff; + if (arp_table[uVar6].state == '\0') { + arp_table[uVar6].state = '\x01'; + arp_table[uVar6].netif = netif; + } + else { + eVar3 = -1; + if (q != (pbuf *)0x0) goto LAB_2306e45e; + } + eVar3 = etharp_request(netif,ipaddr); + if (q == (pbuf *)0x0) { + return eVar3; + } +LAB_2306e45e: + if (1 < arp_table[uVar6].state) { + etharp_cached_entry = (netif_addr_idx_t)uVar6; + eVar3 = ethernet_output(netif,q,(eth_addr *)netif->hwaddr,&arp_table[uVar6].ethaddr,0x800); + return eVar3; + } + ppVar5 = q; + if (arp_table[uVar6].state == 1) { + do { + if ((ppVar5->type_internal & 0x40) != 0) { + q = pbuf_clone(PBUF_LINK,PBUF_RAM,q); + if (q == (pbuf *)0x0) { + lwip_stats.etharp.memerr = lwip_stats.etharp.memerr + 1; + return -1; + } + goto LAB_2306e4c4; + } + pppVar1 = &ppVar5->next; + ppVar5 = *pppVar1; + } while (*pppVar1 != (pbuf *)0x0); + pbuf_ref(q); +LAB_2306e4c4: + if (arp_table[uVar6].q != (pbuf *)0x0) { + pbuf_free(arp_table[uVar6].q); + } + arp_table[uVar6].q = q; + eVar3 = '\0'; + } + return eVar3; +} + + + +// WARNING: Variable defined which should be unmapped: mcastaddr + +err_t etharp_output(netif *netif,pbuf *q,ip4_addr_t *ipaddr) + +{ + netif_addr_idx_t nVar1; + u8_t uVar2; + err_t eVar3; + undefined3 extraout_var; + eth_addr *dst; + uint uVar4; + uint uVar5; + etharp_entry *peVar6; + undefined2 uStack24; + u8_t uStack22; + byte bStack21; + eth_addr mcastaddr; + + uVar2 = ip4_addr_isbroadcast_u32(ipaddr->addr,netif); + uVar4 = CONCAT31(extraout_var,uVar2); + if (uVar4 == 0) { + uVar5 = ipaddr->addr; + if ((uVar5 & 0xf0) != 0xe0) { + if (((((netif->ip_addr).addr ^ uVar5) & (netif->netmask).addr) != 0) && + ((uVar5 & 0xffff) != 0xfea9)) { + if ((netif->gw).addr == 0) { + return -4; + } + ipaddr = (ip4_addr_t *)&netif->gw; + } + uVar5 = (uint)etharp_cached_entry; + peVar6 = arp_table; + if (((arp_table[uVar5].state < 2) || (arp_table[uVar5].netif != netif)) || + (ipaddr->addr != arp_table[uVar5].ipaddr.addr)) { + while (((peVar6->state < 2 || (peVar6->netif != netif)) || + (nVar1 = (netif_addr_idx_t)uVar4, ipaddr->addr != (peVar6->ipaddr).addr))) { + uVar4 = uVar4 + 1 & 0xff; + peVar6 = peVar6 + 1; + if (uVar4 == 10) { + eVar3 = etharp_query(netif,ipaddr,q); + return eVar3; + } + } + } + else { + lwip_stats.etharp.cachehit = lwip_stats.etharp.cachehit + 1; + nVar1 = etharp_cached_entry; + } + etharp_cached_entry = nVar1; + eVar3 = etharp_output_to_arp_index(netif,q,etharp_cached_entry); + return eVar3; + } + uStack24 = 1; + uStack22 = '^'; + dst = (eth_addr *)&uStack24; + bStack21 = *(byte *)((int)&ipaddr->addr + 1) & 0x7f; + mcastaddr.addr[0] = *(u8_t *)((int)&ipaddr->addr + 2); + mcastaddr.addr[1] = *(u8_t *)((int)&ipaddr->addr + 3); + } + else { + dst = ðbroadcast; + } + eVar3 = ethernet_output(netif,q,(eth_addr *)netif->hwaddr,dst,0x800); + return eVar3; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void igmp_send(netif *netif,igmp_group *group,u8_t type) + +{ + u8_t *dataptr; + u16_t uVar1; + pbuf *p; + undefined3 in_register_00002031; + ip4_addr_t *dest; + u8_t uVar2; + u8_t uVar3; + u8_t uVar4; + u32_t uVar5; + ip4_addr_t iStack40; + ip4_addr_t src; + u16_t ra [2]; + + iStack40 = (ip4_addr_t)0; + p = pbuf_alloc(PBUF_TRANSPORT,8,PBUF_RAM); + if (p == (pbuf *)0x0) { + lwip_stats.igmp.memerr = lwip_stats.igmp.memerr + 1; + } + else { + iStack40 = (ip4_addr_t)(netif->ip_addr).addr; + uVar5 = (group->group_address).addr; + dataptr = (u8_t *)p->payload; + uVar4 = (u8_t)(uVar5 >> 0x18); + uVar2 = (u8_t)(uVar5 >> 8); + uVar3 = (u8_t)(uVar5 >> 0x10); + if (CONCAT31(in_register_00002031,type) == 0x16) { + dataptr[7] = uVar4; + dataptr[4] = (u8_t)uVar5; + dataptr[5] = uVar2; + dataptr[6] = uVar3; + dest = &group->group_address; + group->last_reporter_flag = '\x01'; + } + else { + dataptr[4] = (u8_t)uVar5; + dataptr[5] = uVar2; + dataptr[6] = uVar3; + dataptr[7] = uVar4; + dest = &allrouters; + } + *dataptr = type; + dataptr[1] = '\0'; + dataptr[2] = '\0'; + dataptr[3] = '\0'; + uVar1 = inet_chksum(dataptr,8); + dataptr[2] = (u8_t)uVar1; + dataptr[3] = (u8_t)(uVar1 >> 8); + src = 0x494; + lwip_stats.igmp.xmit = lwip_stats.igmp.xmit + 1; + ip4_output_if_opt(p,&iStack40,dest,'\x01','\0','\x02',netif,&src,_DAT_00000010); + pbuf_free(p); + } + return; +} + + + +void igmp_delaying_member(igmp_group *group,u8_t maxresp) + +{ + uint uVar1; + undefined3 in_register_0000202d; + uint uVar2; + + uVar2 = CONCAT31(in_register_0000202d,maxresp); + if ((group->group_state != '\x02') && + ((group->group_state != '\x01' || ((group->timer != 0 && (group->timer <= uVar2)))))) { + return; + } + if (2 < uVar2) { + uVar1 = bl_rand(); + group->timer = (u16_t)(uVar1 % uVar2); + if (uVar1 % uVar2 != 0) goto LAB_2306e772; + } + group->timer = 1; +LAB_2306e772: + group->group_state = '\x01'; + return; +} + + + +void igmp_init(void) + +{ + allrouters = 0x20000e0; + allsystems = 0x10000e0; + return; +} + + + +err_t igmp_stop(netif *netif) + +{ + void **mem; + void *pvVar1; + + mem = (void **)netif->client_data[1]; + netif->client_data[1] = (void *)0x0; + while (mem != (void **)0x0) { + pvVar1 = *mem; + if (netif->igmp_mac_filter != (netif_igmp_mac_filter_fn *)0x0) { + (*netif->igmp_mac_filter)(netif,(ip4_addr_t *)(mem + 1),NETIF_DEL_MAC_FILTER); + } + memp_free(MEMP_IGMP_GROUP,mem); + mem = (void **)pvVar1; + } + return '\0'; +} + + + +// WARNING: Type propagation algorithm not settling + +void igmp_report_groups(netif *netif) + +{ + igmp_group *group; + + if ((igmp_group *)netif->client_data[1] != (igmp_group *)0x0) { + group = ((igmp_group *)netif->client_data[1])->next; + while (group != (igmp_group *)0x0) { + igmp_delaying_member(group,'\x05'); + group = group->next; + } + return; + } + return; +} + + + +igmp_group * igmp_lookfor_group(netif *ifp,ip4_addr_t *addr) + +{ + igmp_group *piVar1; + + piVar1 = (igmp_group *)ifp->client_data[1]; + while ((piVar1 != (igmp_group *)0x0 && ((piVar1->group_address).addr != addr->addr))) { + piVar1 = piVar1->next; + } + return piVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +igmp_group * igmp_lookup_group(netif *ifp,ip4_addr_t *addr) + +{ + igmp_group *piVar1; + igmp_group *piVar2; + u32_t uVar3; + + piVar2 = igmp_lookfor_group(ifp,addr); + if (piVar2 == (igmp_group *)0x0) { + piVar1 = (igmp_group *)ifp->client_data[1]; + piVar2 = (igmp_group *)memp_malloc(MEMP_IGMP_GROUP); + if (piVar2 != (igmp_group *)0x0) { + uVar3 = 0; + if (addr != (ip4_addr_t *)0x0) { + uVar3 = addr->addr; + } + (piVar2->group_address).addr = uVar3; + *(undefined4 *)&piVar2->last_reporter_flag = 0; + piVar2->use = '\0'; + if (piVar1 == (igmp_group *)0x0) { + piVar2->next = (igmp_group *)0x0; + *(igmp_group **)(ifp->client_data + 1) = piVar2; + } + else { + piVar2->next = piVar1->next; + piVar1->next = piVar2; + } + } + } + return piVar2; +} + + + +err_t igmp_start(netif *netif) + +{ + err_t eVar1; + igmp_group *piVar2; + + piVar2 = igmp_lookup_group(netif,&allsystems); + if (piVar2 == (igmp_group *)0x0) { + eVar1 = -1; + } + else { + piVar2->group_state = '\x02'; + piVar2->use = piVar2->use + '\x01'; + eVar1 = '\0'; + if (netif->igmp_mac_filter != (netif_igmp_mac_filter_fn *)0x0) { + (*netif->igmp_mac_filter)(netif,&allsystems,NETIF_ADD_MAC_FILTER); + eVar1 = '\0'; + } + } + return eVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +void igmp_input(pbuf *p,netif *inp,ip4_addr_t *dest) + +{ + ip4_addr_t iVar1; + char *dataptr; + u16_t uVar2; + undefined2 extraout_var; + igmp_group *group; + ip4_addr_t iStack36; + ip4_addr_t groupaddr; + + lwip_stats.igmp.recv = lwip_stats.igmp.recv + 1; + if (p->len < 8) { + pbuf_free(p); + lwip_stats.igmp.lenerr = lwip_stats.igmp.lenerr + 1; + return; + } + dataptr = (char *)p->payload; + uVar2 = inet_chksum(dataptr,p->len); + if (CONCAT22(extraout_var,uVar2) != 0) { + pbuf_free(p); + lwip_stats.igmp.chkerr = lwip_stats.igmp.chkerr + 1; + return; + } + group = igmp_lookfor_group(inp,dest); + if (group == (igmp_group *)0x0) { + pbuf_free(p); + lwip_stats.igmp.drop = lwip_stats.igmp.drop + 1; + return; + } + if (*dataptr == '\x11') { + iVar1 = (ip4_addr_t)((ip4_addr_t *)(dataptr + 4))->addr; + if (dest->addr == allsystems) { + if (iVar1 == (ip4_addr_t)0x0) { + if (dataptr[1] == '\0') { + lwip_stats.igmp.rx_v1 = lwip_stats.igmp.rx_v1 + 1; + dataptr[1] = '\n'; + } + else { + lwip_stats.igmp.rx_general = lwip_stats.igmp.rx_general + 1; + } + if ((igmp_group *)inp->client_data[1] != (igmp_group *)0x0) { + group = ((igmp_group *)inp->client_data[1])->next; + while (group != (igmp_group *)0x0) { + igmp_delaying_member(group,dataptr[1]); + group = group->next; + } + } + goto LAB_2306e9ba; + } + iStack36 = iVar1; + group = igmp_lookfor_group(inp,&iStack36); + if (group == (igmp_group *)0x0) { + lwip_stats.igmp.drop = lwip_stats.igmp.drop + 1; + goto LAB_2306e9ba; + } + } + else { + if (iVar1 == (ip4_addr_t)0x0) goto LAB_2306e95c; + } + lwip_stats.igmp.rx_group = lwip_stats.igmp.rx_group + 1; + igmp_delaying_member(group,dataptr[1]); + } + else { + if (*dataptr == '\x16') { + lwip_stats.igmp.rx_report = lwip_stats.igmp.rx_report + 1; + if (group->group_state == '\x01') { + *(undefined4 *)&group->last_reporter_flag = 0x200; + } + goto LAB_2306e9ba; + } +LAB_2306e95c: + lwip_stats.igmp.proterr = lwip_stats.igmp.proterr + 1; + } +LAB_2306e9ba: + pbuf_free(p); + return; +} + + + +err_t igmp_joingroup_netif(netif *netif,ip4_addr_t *groupaddr) + +{ + u16_t uVar1; + igmp_group *group; + uint uVar2; + err_t eVar3; + + if (((groupaddr->addr & 0xf0) == 0xe0) && (eVar3 = -6, groupaddr->addr != allsystems)) { + if ((netif->flags & 0x20) != 0) { + group = igmp_lookup_group(netif,groupaddr); + eVar3 = -1; + if (group != (igmp_group *)0x0) { + if (group->group_state == '\0') { + if ((group->use == '\0') && (netif->igmp_mac_filter != (netif_igmp_mac_filter_fn *)0x0)) { + (*netif->igmp_mac_filter)(netif,groupaddr,NETIF_ADD_MAC_FILTER); + } + lwip_stats.igmp.tx_join = lwip_stats.igmp.tx_join + 1; + igmp_send(netif,group,'\x16'); + uVar2 = bl_rand(); + uVar1 = (u16_t)(uVar2 % 5); + if (uVar2 % 5 == 0) { + uVar1 = 1; + } + group->timer = uVar1; + group->group_state = '\x01'; + } + group->use = group->use + '\x01'; + eVar3 = '\0'; + } + } + return eVar3; + } + return -6; +} + + + +err_t igmp_joingroup(ip4_addr_t *ifaddr,ip4_addr_t *groupaddr) + +{ + netif *netif; + err_t eVar1; + int iVar2; + undefined3 extraout_var; + + if ((groupaddr->addr & 0xf0) != 0xe0) { + return -6; + } + iVar2 = -6; + eVar1 = -6; + netif = netif_list; + if (groupaddr->addr != allsystems) { + while (eVar1 = (err_t)iVar2, netif != (netif *)0x0) { + if (((netif->flags & 0x20) != 0) && + (((ifaddr == (ip4_addr_t *)0x0 || (ifaddr->addr == 0)) || + (ifaddr->addr == (netif->ip_addr).addr)))) { + eVar1 = igmp_joingroup_netif(netif,groupaddr); + iVar2 = CONCAT31(extraout_var,eVar1); + if (iVar2 != 0) { + return eVar1; + } + } + netif = netif->next; + } + } + return eVar1; +} + + + +err_t igmp_leavegroup_netif(netif *netif,ip4_addr_t *groupaddr) + +{ + igmp_group *piVar1; + igmp_group *group; + err_t eVar2; + igmp_group *piVar3; + + if (((groupaddr->addr & 0xf0) != 0xe0) || (eVar2 = -6, groupaddr->addr == allsystems)) { + return -6; + } + if ((netif->flags & 0x20) != 0) { + group = igmp_lookfor_group(netif,groupaddr); + eVar2 = -6; + if (group != (igmp_group *)0x0) { + if (group->use < 2) { + piVar1 = (igmp_group *)netif->client_data[1]; + do { + piVar3 = piVar1; + if (piVar3 == (igmp_group *)0x0) goto LAB_2306eb90; + piVar1 = piVar3->next; + } while (group != piVar3->next); + piVar3->next = group->next; +LAB_2306eb90: + if (group->last_reporter_flag != '\0') { + lwip_stats.igmp.tx_leave = lwip_stats.igmp.tx_leave + 1; + igmp_send(netif,group,'\x17'); + } + if (netif->igmp_mac_filter != (netif_igmp_mac_filter_fn *)0x0) { + (*netif->igmp_mac_filter)(netif,groupaddr,NETIF_DEL_MAC_FILTER); + } + memp_free(MEMP_IGMP_GROUP,group); + } + else { + group->use = group->use - 1; + } + eVar2 = '\0'; + } + } + return eVar2; +} + + + +err_t igmp_leavegroup(ip4_addr_t *ifaddr,ip4_addr_t *groupaddr) + +{ + netif *netif; + int iVar1; + err_t eVar2; + undefined3 extraout_var; + + eVar2 = -6; + if ((groupaddr->addr & 0xf0) == 0xe0) { + iVar1 = -6; + eVar2 = -6; + netif = netif_list; + if (groupaddr->addr != allsystems) { + while (eVar2 = (err_t)iVar1, netif != (netif *)0x0) { + if (((netif->flags & 0x20) != 0) && + (((ifaddr == (ip4_addr_t *)0x0 || (ifaddr->addr == 0)) || + (ifaddr->addr == (netif->ip_addr).addr)))) { + eVar2 = igmp_leavegroup_netif(netif,groupaddr); + if (iVar1 != 0) { + iVar1 = CONCAT31(extraout_var,eVar2); + } + } + netif = netif->next; + } + } + } + return eVar2; +} + + + +void igmp_tmr(void) + +{ + igmp_group *group; + netif *netif; + uint uVar1; + + netif = netif_list; + while (netif != (netif *)0x0) { + group = (igmp_group *)netif->client_data[1]; + while (group != (igmp_group *)0x0) { + if ((((group->timer != 0) && + (uVar1 = (uint)group->timer - 1, group->timer = (u16_t)(uVar1 * 0x10000 >> 0x10), + (uVar1 & 0xffff) == 0)) && (group->group_state == '\x01')) && + ((group->group_address).addr != allsystems)) { + group->group_state = '\x02'; + lwip_stats.igmp.tx_report = lwip_stats.igmp.tx_report + 1; + igmp_send(netif,group,'\x16'); + } + group = group->next; + } + netif = netif->next; + } + return; +} + + + +int ip4_input_accept(netif *netif) + +{ + u8_t uVar1; + int iVar2; + undefined3 extraout_var; + u32_t uVar3; + + if ((netif->flags & 1) == 0) { + return 0; + } + uVar3 = (netif->ip_addr).addr; + iVar2 = 0; + if (uVar3 != 0) { + iVar2 = 1; + if (uVar3 != ip_data.current_iphdr_dest) { + uVar1 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_dest,netif); + return (uint)(CONCAT31(extraout_var,uVar1) != 0); + } + } + return iVar2; +} + + + +netif * ip4_route(ip4_addr_t *dest) + +{ + byte bVar1; + netif *pnVar2; + netif *pnVar3; + uint uVar4; + uint uVar5; + + uVar5 = dest->addr; + pnVar2 = netif_list; + if (((uVar5 & 0xf0) != 0xe0) || + (pnVar3 = ip4_default_multicast_netif, ip4_default_multicast_netif == (netif *)0x0)) { + while (pnVar2 != (netif *)0x0) { + bVar1 = pnVar2->flags; + if ((((bVar1 & 1) != 0) && ((bVar1 >> 2 & 1) != 0)) && + (uVar4 = (pnVar2->ip_addr).addr, uVar4 != 0)) { + if (((uVar4 ^ uVar5) & (pnVar2->netmask).addr) == 0) { + return pnVar2; + } + if (((bVar1 & 2) == 0) && (uVar5 == (pnVar2->gw).addr)) { + return pnVar2; + } + } + pnVar2 = pnVar2->next; + } + if (((netif_default == (netif *)0x0) || ((netif_default->flags & 5) != 5)) || + (((netif_default->ip_addr).addr == 0 || (pnVar3 = netif_default, (uVar5 & 0xff) == 0x7f)))) { + lwip_stats.ip.rterr = lwip_stats.ip.rterr + 1; + return (netif *)0x0; + } + } + return pnVar3; +} + + + +err_t ip4_input(pbuf *p,netif *inp) + +{ + byte bVar1; + uint uVar2; + u8_t uVar3; + raw_input_state_t rVar4; + u16_t new_len; + undefined2 extraout_var_02; + undefined2 extraout_var_03; + igmp_group *piVar5; + undefined3 extraout_var; + int iVar6; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + ip_hdr *dataptr; + netif *netif; + uint uVar7; + + lwip_stats.ip.recv = lwip_stats.ip.recv + 1; + dataptr = (ip_hdr *)p->payload; + bVar1 = dataptr->_v_hl; + if (bVar1 >> 4 != 4) { + pbuf_free(p); + lwip_stats.ip.drop = lwip_stats.ip.drop + 1; + lwip_stats.ip.err = lwip_stats.ip.err + 1; + return '\0'; + } + new_len = lwip_htons(dataptr->_len); + uVar7 = (uint)bVar1 & 0xf; + uVar2 = (uVar7 << 0x12) >> 0x10; + if (CONCAT22(extraout_var_02,new_len) < (uint)p->tot_len) { + pbuf_realloc(p,new_len); + } + if (((p->len < uVar2) || ((uint)p->tot_len < CONCAT22(extraout_var_02,new_len))) || (uVar2 < 0x14) + ) { + pbuf_free(p); + lwip_stats.ip.lenerr = lwip_stats.ip.lenerr + 1; + goto LAB_2306ee68; + } + new_len = inet_chksum(dataptr,(u16_t)((uVar7 << 0x12) >> 0x10)); + if (CONCAT22(extraout_var_03,new_len) != 0) { + pbuf_free(p); + lwip_stats.ip.chkerr = lwip_stats.ip.chkerr + 1; + goto LAB_2306ee68; + } + ip_data.current_iphdr_dest = (dataptr->dest).addr; + ip_data.current_iphdr_src = (dataptr->src).addr; + netif = inp; + if ((ip_data.current_iphdr_dest & 0xf0) == 0xe0) { + if (((inp->flags & 0x20) == 0) || + (piVar5 = igmp_lookfor_group(inp,(ip4_addr_t *)&ip_data.current_iphdr_dest), + piVar5 == (igmp_group *)0x0)) goto LAB_2306eeee; + if ((ip_data.current_iphdr_dest != 0x10000e0) || (ip_data.current_iphdr_src != 0)) + goto LAB_2306ef1e; + } + else { + iVar6 = ip4_input_accept(inp); + if (iVar6 == 0) { + netif = netif_list; + if ((char)ip_data.current_iphdr_dest.addr != '\x7f') { + while (netif != (netif *)0x0) { + if ((netif != inp) && (iVar6 = ip4_input_accept(netif), iVar6 != 0)) goto LAB_2306ef1e; + netif = netif->next; + } + } + } + else { + if (inp != (netif *)0x0) goto LAB_2306ef1e; + } +LAB_2306eeee: + if ((dataptr->_proto != '\x11') || (netif = inp, (&dataptr->_len)[uVar7 * 2] != 0x4400)) { + netif = (netif *)0x0; +LAB_2306ef1e: + if ((ip_data.current_iphdr_src != 0) && + ((uVar3 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_src,inp), + CONCAT31(extraout_var,uVar3) != 0 || ((ip_data.current_iphdr_src & 0xf0) == 0xe0)))) { + pbuf_free(p); + goto LAB_2306ee68; + } + } + if (netif == (netif *)0x0) { + lwip_stats.ip.drop = lwip_stats.ip.drop + 1; + pbuf_free(p); + return '\0'; + } + } + if (((uint)*(byte *)&dataptr->_offset & 0x3f | (uint)*(byte *)((int)&dataptr->_offset + 1) << 8) + == 0) { + ip_data.current_ip_header_tot_len = (u16_t)(((uint)dataptr->_v_hl & 0xf) << 2); + ip_data.current_netif = netif; + ip_data.current_input_netif = inp; + ip_data.current_ip4_header = dataptr; + rVar4 = raw_input(p,inp); + if (CONCAT31(extraout_var_00,rVar4) != 1) { + pbuf_remove_header(p,uVar7 * 4); + bVar1 = dataptr->_proto; + if (bVar1 == 2) { + igmp_input(p,inp,(ip4_addr_t *)&ip_data.current_iphdr_dest); + } + else { + if (bVar1 < 3) { + if (bVar1 == 1) { + icmp_input(p,inp); + ip_data.current_netif = (netif *)0x0; + ip_data.current_input_netif = (netif *)0x0; + ip_data.current_ip4_header = (ip_hdr *)0x0; + ip_data.current_ip_header_tot_len = 0; + ip_data.current_iphdr_src = 0; + ip_data.current_iphdr_dest = 0; + return '\0'; + } + } + else { + if (bVar1 == 6) { + tcp_input(p,inp); + ip_data.current_netif = (netif *)0x0; + ip_data.current_input_netif = (netif *)0x0; + ip_data.current_ip4_header = (ip_hdr *)0x0; + ip_data.current_ip_header_tot_len = 0; + ip_data.current_iphdr_src = 0; + ip_data.current_iphdr_dest = 0; + return '\0'; + } + if (bVar1 == 0x11) { + udp_input(p,inp); + ip_data.current_netif = (netif *)0x0; + ip_data.current_input_netif = (netif *)0x0; + ip_data.current_ip4_header = (ip_hdr *)0x0; + ip_data.current_ip_header_tot_len = 0; + ip_data.current_iphdr_src = 0; + ip_data.current_iphdr_dest = 0; + return '\0'; + } + } + if (CONCAT31(extraout_var_00,rVar4) != 2) { + uVar3 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_dest,netif); + if ((CONCAT31(extraout_var_01,uVar3) == 0) && + ((ip_data.current_iphdr_dest & 0xf0) != 0xe0)) { + pbuf_header_force(p,(s16_t)(uVar7 * 4)); + icmp_dest_unreach(p,ICMP_DUR_PROTO); + } + lwip_stats.ip.proterr = lwip_stats.ip.proterr + 1; + lwip_stats.ip.drop = lwip_stats.ip.drop + 1; + } + pbuf_free(p); + } + } + ip_data.current_netif = (netif *)0x0; + ip_data.current_input_netif = (netif *)0x0; + ip_data.current_ip4_header = (ip_hdr *)0x0; + ip_data.current_ip_header_tot_len = 0; + ip_data.current_iphdr_src = 0; + ip_data.current_iphdr_dest = 0; + return '\0'; + } + pbuf_free(p); + lwip_stats.ip.opterr = lwip_stats.ip.opterr + 1; +LAB_2306ee68: + lwip_stats.ip.drop = lwip_stats.ip.drop + 1; + return '\0'; +} + + + +// WARNING: Type propagation algorithm not settling + +err_t ip4_output_if_opt_src + (pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto,netif *netif, + void *ip_options,u16_t optlen) + +{ + uint header_size_increment; + undefined *puVar1; + uint uVar2; + u8_t uVar3; + err_t eVar4; + u16_t uVar5; + u16_t n; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined2 extraout_var_01; + undefined2 extraout_var_02; + undefined3 in_register_00002035; + undefined3 in_register_00002039; + int iVar6; + undefined3 in_register_0000203d; + int iVar7; + uint uVar8; + uint __n; + int iVar9; + ushort in_stack_00000000; + ip4_addr_t iStack52; + ip4_addr_t dest_addr; + + __n = (uint)in_stack_00000000; + if (dest == (ip4_addr_t *)0x0) { + if (0x13 < p->len) { + dest = &iStack52; + iStack52 = (ip4_addr_t)((ip4_addr_t *)((int)p->payload + 0x10))->addr; + goto LAB_2306f2a0; + } + } + else { + if (in_stack_00000000 == 0) { + uVar2 = 0x14; + iVar9 = 0; + } + else { + if (0x28 < in_stack_00000000) { + lwip_stats.ip.err = lwip_stats.ip.err + 1; + return -6; + } + header_size_increment = __n + 3 & 0xfffc; + uVar3 = pbuf_add_header(p,header_size_increment); + uVar2 = header_size_increment + 0x14 & 0xffff; + if (CONCAT31(extraout_var,uVar3) != 0) goto LAB_2306f136; + memcpy(p->payload,ip_options,__n); + if (__n < header_size_increment) { + memset((void *)((int)p->payload + __n),0,header_size_increment - __n); + } + iVar7 = 0; + iVar9 = 0; + do { + iVar6 = iVar7 * 2; + iVar7 = iVar7 + 1; + iVar9 = iVar9 + (uint)*(ushort *)(iVar6 + (int)p->payload); + } while (iVar7 < (int)(header_size_increment >> 1)); + } + uVar3 = pbuf_add_header(p,0x14); + if (CONCAT31(extraout_var_00,uVar3) == 0) { + puVar1 = (undefined *)p->payload; + puVar1[8] = ttl; + puVar1[9] = proto; + header_size_increment = dest->addr; + uVar8 = CONCAT31(in_register_00002035,ttl) << 8 | CONCAT31(in_register_0000203d,proto); + puVar1[0x10] = (char)header_size_increment; + puVar1[0x11] = (char)(header_size_increment >> 8); + puVar1[0x12] = (char)(header_size_increment >> 0x10); + __n = uVar2 >> 2 & 0xff | 0x40; + *puVar1 = (char)__n; + __n = __n << 8 | CONCAT31(in_register_00002039,tos); + puVar1[0x13] = (char)(header_size_increment >> 0x18); + puVar1[1] = tos; + uVar5 = lwip_htons(p->tot_len); + puVar1[2] = (char)uVar5; + n = ip_id; + puVar1[3] = (char)(uVar5 >> 8); + puVar1[6] = 0; + puVar1[7] = 0; + n = lwip_htons(n); + puVar1[5] = (char)(n >> 8); + puVar1[4] = (char)n; + ip_id = ip_id + 1; + if (src == (ip4_addr_t *)0x0) { + uVar2 = 0; + } + else { + uVar2 = src->addr; + } + puVar1[0xf] = (char)(uVar2 >> 0x18); + puVar1[0xc] = (char)uVar2; + puVar1[0xd] = (char)(uVar2 >> 8); + __n = (uVar2 & 0xffff) + + CONCAT22(extraout_var_02,n) + + (((int)__n >> 8 | __n << 8) & 0xffff) + + ((uVar8 << 8 | (int)uVar8 >> 8) & 0xffff) + + (header_size_increment & 0xffff) + (header_size_increment >> 0x10) + iVar9 + + CONCAT22(extraout_var_01,uVar5) + (uVar2 >> 0x10); + puVar1[0xe] = (char)(uVar2 >> 0x10); + __n = (__n & 0xffff) + (__n >> 0x10); + __n = ~((__n >> 0x10) + __n); + puVar1[10] = (char)__n; + puVar1[0xb] = (char)(__n >> 8); +LAB_2306f2a0: + lwip_stats.ip.xmit = lwip_stats.ip.xmit + 1; + eVar4 = (*netif->output)(netif,p,dest); + return eVar4; + } + } +LAB_2306f136: + lwip_stats.ip.err = lwip_stats.ip.err + 1; + return -2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +err_t ip4_output_if_opt(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto, + netif *netif,void *ip_options,u16_t optlen) + +{ + err_t eVar1; + + if ((dest != (ip4_addr_t *)0x0) && ((src == (ip4_addr_t *)0x0 || (src->addr == 0)))) { + src = (ip4_addr_t *)&netif->ip_addr; + } + eVar1 = ip4_output_if_opt_src(p,src,dest,ttl,tos,proto,netif,ip_options,optlen); + return eVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +err_t ip4_output_if(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto, + netif *netif) + +{ + err_t eVar1; + + eVar1 = ip4_output_if_opt(p,src,dest,ttl,tos,proto,netif,(void *)0x0,_DAT_00000010); + return eVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +err_t ip4_output_if_src(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto, + netif *netif) + +{ + err_t eVar1; + + eVar1 = ip4_output_if_opt_src(p,src,dest,ttl,tos,proto,netif,(void *)0x0,_DAT_00000010); + return eVar1; +} + + + +u8_t ip4_addr_isbroadcast_u32(u32_t addr,netif *netif) + +{ + byte bVar1; + uint uVar2; + uint uVar3; + + if (addr - 1 < 0xfffffffe) { + bVar1 = netif->flags & 2; + if ((netif->flags & 2) != 0) { + uVar3 = (netif->ip_addr).addr; + bVar1 = 0; + if ((uVar3 != addr) && (uVar2 = (netif->netmask).addr, ((uVar3 ^ addr) & uVar2) == 0)) { + uVar2 = ~uVar2; + return (u8_t)((uVar2 & addr) == uVar2); + } + } + } + else { + bVar1 = 1; + } + return (u8_t)bVar1; +} + + + +int ip4addr_aton(char *cp,ip4_addr_t *addr) + +{ + byte bVar1; + int iVar2; + u32_t n; + u32_t *puVar3; + uint uVar4; + uint uVar5; + int iVar6; + u32_t uStack32; + u32_t parts [4]; + + bVar1 = *cp; + puVar3 = &uStack32; +LAB_2306f39c: + uVar5 = (uint)bVar1; + if ((_ctype_[uVar5 + 1] & 4) == 0) { + return 0; + } + iVar6 = 10; + if (bVar1 == 0x30) { + uVar5 = (uint)(byte)cp[1]; + if ((uVar5 & 0xdf) == 0x58) { + uVar5 = (uint)(byte)cp[2]; + iVar6 = 0x10; + cp = cp + 2; + } + else { + cp = cp + 1; + iVar6 = 8; + } + } + n = 0; + do { + bVar1 = _ctype_[uVar5 + 1]; + if ((bVar1 & 4) == 0) { + if ((iVar6 != 0x10) || ((bVar1 & 0x44) == 0)) break; + iVar2 = 0x61; + if ((bVar1 & 3) != 2) { + iVar2 = 0x41; + } + n = n << 4 | (uVar5 + 10) - iVar2; + } + else { + n = (iVar6 * n + uVar5) - 0x30; + } + uVar5 = (uint)(byte)cp[1]; + cp = cp + 1; + } while( true ); + if (uVar5 == 0x2e) { + if (puVar3 == parts + 2) { + return 0; + } + *puVar3 = n; + bVar1 = cp[1]; + cp = cp + 1; + puVar3 = puVar3 + 1; + goto LAB_2306f39c; + } + if ((uVar5 != 0) && ((bVar1 & 8) == 0)) { + return 0; + } + iVar6 = (int)((int)puVar3 - (int)&uStack32) >> 2; + iVar2 = iVar6 + 1; + if (iVar2 == 2) { + if (0xffffff < n) { + return 0; + } + if (0xff < uStack32) { + return 0; + } + uVar5 = uStack32 << 0x18; + } + else { + if (iVar2 < 3) { + if (iVar6 == -1) { + return 0; + } + goto LAB_2306f44a; + } + if (iVar2 == 3) { + if (0xffff < n) { + return 0; + } + if (0xff < uStack32) { + return 0; + } + if (0xff < parts[0]) { + return 0; + } + uVar5 = uStack32 << 0x18; + uVar4 = parts[0] << 0x10; + } + else { + if (iVar2 != 4) goto LAB_2306f44a; + if (0xff < n) { + return 0; + } + if (0xff < uStack32) { + return 0; + } + if (0xff < parts[0]) { + return 0; + } + if (0xff < parts[1]) { + return 0; + } + uVar5 = uStack32 << 0x18 | parts[0] << 0x10; + uVar4 = parts[1] << 8; + } + uVar5 = uVar5 | uVar4; + } + n = n | uVar5; +LAB_2306f44a: + if (addr != (ip4_addr_t *)0x0) { + n = lwip_htonl(n); + addr->addr = n; + return 1; + } + return 1; +} + + + +u32_t ipaddr_addr(char *cp) + +{ + int iVar1; + ip4_addr_t iStack20; + ip4_addr_t val; + + iVar1 = ip4addr_aton(cp,&iStack20); + if (iVar1 == 0) { + iStack20 = (ip4_addr_t)0xffffffff; + } + return (u32_t)iStack20; +} + + + +// WARNING: Could not reconcile some variable overlaps + +char * ip4addr_ntoa_r(ip4_addr_t *addr,char *buf,int buflen) + +{ + bool bVar1; + uint uVar2; + int iVar3; + int iVar4; + byte *pbVar5; + uint uVar6; + char *pcVar7; + uint uVar8; + uint uVar9; + char *pcVar10; + u32_t s_addr; + char local_8 [4]; + char inv [3]; + + _inv = addr->addr; + iVar3 = 0; + pbVar5 = (byte *)inv; + pcVar10 = buf; + while( true ) { + uVar2 = 0; + uVar9 = (uint)*pbVar5; + do { + uVar8 = uVar2; + uVar6 = uVar9 / 10; + local_8[uVar8] = (char)(uVar9 % 10) + '0'; + bVar1 = 9 < uVar9; + uVar2 = uVar8 + 1 & 0xff; + uVar9 = uVar6; + } while (bVar1); + *pbVar5 = (byte)uVar6; + iVar4 = iVar3; + pcVar7 = pcVar10; + while (iVar3 = iVar4 + 1, uVar8 != 0xff) { + if (buflen <= iVar4) { + return (char *)0x0; + } + *pcVar7 = local_8[uVar8]; + iVar4 = iVar3; + pcVar7 = pcVar7 + 1; + uVar8 = uVar8 - 1 & 0xff; + } + if (buflen <= iVar4) break; + *pcVar7 = '.'; + pbVar5 = pbVar5 + 1; + pcVar10 = pcVar7 + 1; + if (pbVar5 == (byte *)register0x00002008) { + *pcVar7 = '\0'; + return buf; + } + } + return (char *)0x0; +} + + + +char * ip4addr_ntoa(ip4_addr_t *addr) + +{ + char str [16]; + char *pcVar1; + + pcVar1 = ip4addr_ntoa_r(addr,(char *)&ram0x4201b1a8,0x10); + return pcVar1; +} + + + +void mem_init(void) + +{ + ram = ram_heap; + ram_heap._0_4_ = 0x2000; + ram_heap[4] = '\0'; + ram_end = (mem *)(ram_heap + 0x2000); + ram_heap._8192_4_ = 0x20002000; + ram_heap[8196] = '\x01'; + lfree = (mem *)ram_heap; + lwip_stats.mem.avail = 0x2000; + sys_mutex_new(&mem_mutex); + return; +} + + + +void mem_free(uint param_1) + +{ + ushort uVar1; + ushort uVar2; + short sVar3; + u8_t *puVar4; + mem *pmVar5; + mem *pmVar6; + mem *pmVar7; + uint uVar8; + mem *pmVar9; + + if (param_1 == 0) { + return; + } + if ((((param_1 & 3) == 0) && (pmVar6 = (mem *)(param_1 - 8), ram <= pmVar6)) && + ((mem *)(param_1 + 0xc) <= ram_end)) { + sys_mutex_lock(&mem_mutex); + pmVar5 = ram_end; + puVar4 = ram; + pmVar9 = lfree; + if (*(char *)(param_1 - 4) != '\0') { + uVar1 = *(ushort *)(param_1 - 8); + if ((uVar1 < 0x2001) && (uVar2 = *(ushort *)(param_1 - 6), uVar2 < 0x2001)) { + pmVar7 = (mem *)((int)pmVar6 - (int)ram); + uVar8 = (uint)pmVar7 & 0xffff; + if ((uVar8 == (uint)uVar2) || ((uint)*(ushort *)(ram + (uint)uVar2) == uVar8)) { + if (((mem *)(ram + uVar1) == ram_end) || ((uint)((mem *)(ram + uVar1))->prev == uVar8)) { + *(undefined *)(param_1 - 4) = 0; + if (pmVar6 < pmVar9) { + lfree = pmVar6; + } + sVar3 = (short)((uint)((int)pmVar7 * 0x10000) >> 0x10); + lwip_stats.mem.used = (lwip_stats.mem.used - uVar1) + sVar3; + pmVar9 = (mem *)(puVar4 + *(ushort *)(param_1 - 8)); + if (((pmVar6 != pmVar9) && (pmVar9->used == '\0')) && (pmVar5 != pmVar9)) { + if (pmVar9 == lfree) { + lfree = pmVar6; + } + *(mem_size_t *)(param_1 - 8) = pmVar9->next; + if (pmVar9->next != 0x2000) { + *(short *)(puVar4 + (uint)pmVar9->next + 2) = sVar3; + } + } + uVar1 = *(ushort *)(param_1 - 6); + pmVar9 = (mem *)(puVar4 + uVar1); + if ((pmVar6 != pmVar9) && (pmVar9->used == '\0')) { + if (pmVar6 == lfree) { + lfree = pmVar9; + } + pmVar9->next = *(mem_size_t *)(param_1 - 8); + if (*(ushort *)(param_1 - 8) != 0x2000) { + *(ushort *)(puVar4 + (uint)*(ushort *)(param_1 - 8) + 2) = uVar1; + } + } + sys_mutex_unlock(&mem_mutex); + return; + } + } + } + } + sys_mutex_unlock(&mem_mutex); + } + sys_arch_protect(); + lwip_stats.mem.illegal = lwip_stats.mem.illegal + 1; + sys_arch_unprotect(); + return; +} + + + +mem * mem_trim(mem *param_1,uint param_2) + +{ + mem_size_t mVar1; + short sVar2; + u8_t *puVar3; + uint uVar4; + mem_size_t mVar5; + uint uVar6; + uint uVar7; + mem *pmVar8; + mem *pmVar9; + undefined2 uVar10; + uint uVar11; + uint uVar12; + uint uVar13; + + uVar4 = param_2 + 3 & 0xfffc; + if (uVar4 < 0xc) { + uVar4 = 0xc; + } + else { + if (0x2000 < uVar4) { + return (mem *)0; + } + } + if (uVar4 < param_2) { + return (mem *)0; + } + if ((param_1 < ram) || (ram_end <= param_1)) { + sys_arch_protect(); + lwip_stats.mem.illegal = lwip_stats.mem.illegal + 1; + sys_arch_unprotect(); + return param_1; + } + uVar6 = (int)param_1 + (-8 - (int)ram); + uVar11 = (uint)*(ushort *)¶m_1[-2].used - 8; + uVar7 = uVar6 & 0xffff; + uVar12 = uVar11 & 0xffff; + uVar13 = uVar12 - uVar7 & 0xffff; + if (uVar13 < uVar4) { + return (mem *)0; + } + if (uVar13 == uVar4) { + return param_1; + } + sys_mutex_lock(&mem_mutex); + puVar3 = ram; + pmVar8 = (mem *)(ram + *(ushort *)¶m_1[-2].used); + mVar5 = (mem_size_t)uVar7; + if (pmVar8->used == '\0') { + uVar6 = uVar7 + 8 + uVar4; + mVar1 = pmVar8->next; + pmVar9 = (mem *)(ram + (uVar6 & 0xffff)); + if (lfree == pmVar8) { + lfree = pmVar9; + } + pmVar9->used = '\0'; + pmVar9->next = mVar1; + pmVar9->prev = mVar5; + uVar10 = (undefined2)(uVar6 * 0x10000 >> 0x10); + *(undefined2 *)¶m_1[-2].used = uVar10; + if (pmVar9->next != 0x2000) { + *(undefined2 *)(puVar3 + (uint)pmVar9->next + 2) = uVar10; + } + sVar2 = (mVar5 - (short)uVar12) + lwip_stats.mem.used; + } + else { + if (uVar13 < uVar4 + 0x14) goto LAB_2306f86e; + uVar7 = uVar7 + 8 + uVar4; + pmVar8 = (mem *)(ram + (uVar7 & 0xffff)); + if (pmVar8 < lfree) { + lfree = pmVar8; + } + pmVar8->used = '\0'; + mVar1 = *(mem_size_t *)¶m_1[-2].used; + pmVar8->prev = mVar5; + pmVar8->next = mVar1; + uVar10 = (undefined2)(uVar7 * 0x10000 >> 0x10); + *(undefined2 *)¶m_1[-2].used = uVar10; + if (pmVar8->next != 0x2000) { + *(undefined2 *)(puVar3 + (uint)pmVar8->next + 2) = uVar10; + } + sVar2 = ((short)(uVar6 * 0x10000 >> 0x10) - (short)(uVar11 * 0x10000 >> 0x10)) + + lwip_stats.mem.used; + } + lwip_stats.mem.used = (short)uVar4 + sVar2; +LAB_2306f86e: + sys_mutex_unlock(&mem_mutex); + return param_1; +} + + + +mem_size_t * mem_malloc(uint param_1) + +{ + ushort uVar1; + u8_t *puVar2; + mem_size_t *pmVar3; + mem *pmVar4; + uint uVar5; + uint uVar6; + ushort *puVar7; + mem_size_t mVar8; + uint uVar9; + uint uVar10; + mem *pmVar11; + + if (param_1 == 0) { +LAB_2306f960: + pmVar3 = (mem_size_t *)0x0; + } + else { + uVar5 = param_1 + 3 & 0xfffc; + if (uVar5 < 0xc) { + uVar5 = 0xc; + } + else { + if (0x2000 < uVar5) { + return (mem_size_t *)0; + } + } + pmVar3 = (mem_size_t *)0x0; + if (param_1 <= uVar5) { + sys_mutex_lock(&mem_mutex); + puVar2 = ram; + pmVar11 = lfree; + uVar9 = (uint)((int)lfree - (int)ram) & 0xffff; + do { + uVar10 = uVar9; + if (0x2000 - uVar5 <= uVar10) { + lwip_stats.mem.err = lwip_stats.mem.err + 1; + sys_mutex_unlock(&mem_mutex); + goto LAB_2306f960; + } + pmVar4 = (mem *)(ram + uVar10); + uVar9 = (uint)pmVar4->next; + } while ((pmVar4->used != '\0') || (uVar6 = (-8 - uVar10) + uVar9, uVar6 < uVar5)); + if (uVar6 < uVar5 + 0x14) { + pmVar4->used = '\x01'; + uVar10 = (uVar9 + lwip_stats.mem.used) - uVar10; + lwip_stats.mem.used = (mem_size_t)(uVar10 * 0x10000 >> 0x10); + if ((uint)lwip_stats.mem.max < (uVar10 & 0xffff)) { + lwip_stats.mem.max = lwip_stats.mem.used; + } + } + else { + uVar9 = uVar5 + 8 + uVar10; + puVar7 = (ushort *)(ram + (uVar9 & 0xffff)); + *(undefined *)(puVar7 + 2) = 0; + uVar1 = pmVar4->next; + puVar7[1] = (ushort)uVar10; + *puVar7 = uVar1; + mVar8 = (mem_size_t)(uVar9 * 0x10000 >> 0x10); + pmVar4->next = mVar8; + pmVar4->used = '\x01'; + if (*puVar7 != 0x2000) { + *(mem_size_t *)(puVar2 + (uint)*puVar7 + 2) = mVar8; + } + uVar5 = uVar5 + (uint)lwip_stats.mem.used + 8; + lwip_stats.mem.used = (mem_size_t)(uVar5 * 0x10000 >> 0x10); + if ((uint)lwip_stats.mem.max < (uVar5 & 0xffff)) { + lwip_stats.mem.max = lwip_stats.mem.used; + } + } + if (pmVar11 == pmVar4) { + while ((lfree = pmVar11, pmVar11->used != '\0' && (ram_end != pmVar11))) { + pmVar11 = (mem *)(puVar2 + pmVar11->next); + } + } + sys_mutex_unlock(&mem_mutex); + pmVar3 = &pmVar4[1].prev; + } + } + return pmVar3; +} + + + +void * mem_calloc(mem_size_t count,mem_size_t size) + +{ + void *__s; + undefined2 in_register_0000202a; + undefined2 in_register_0000202e; + uint __n; + + __n = CONCAT22(in_register_0000202a,count) * CONCAT22(in_register_0000202e,size); + __s = (void *)0x0; + if (__n == (__n & 0xffff)) { + __s = (void *)mem_malloc(__n & 0xffff); + if (__s != (void *)0x0) { + memset(__s,0,__n); + } + } + return __s; +} + + + +// WARNING: Type propagation algorithm not settling + +void * do_memp_malloc_pool(memp_desc *desc) + +{ + memp mVar1; + sys_prot_t sVar2; + stats_mem *psVar3; + + sVar2 = sys_arch_protect(); + mVar1 = (memp)((memp *)desc->tab)->next; + if (mVar1 == (memp)0x0) { + desc->stats->err = desc->stats->err + 1; + } + else { + *(memp *)&((memp *)desc->tab)->next = *(memp *)mVar1; + desc->stats->used = desc->stats->used + 1; + psVar3 = desc->stats; + if (psVar3->max < psVar3->used) { + psVar3->max = psVar3->used; + } + } + sys_arch_unprotect(sVar2); + return (void *)mVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +void memp_init_pool(memp_desc *desc) + +{ + int iVar1; + memp mVar2; + + iVar1 = 0; + *desc->tab = (memp *)0x0; + mVar2 = (memp)((uint)(desc->base + 3) & 0xfffffffc); + while (iVar1 < (int)(uint)desc->num) { + iVar1 = iVar1 + 1; + *(memp **)mVar2 = ((memp *)desc->tab)->next; + *(memp *)&((memp *)desc->tab)->next = mVar2; + mVar2 = (memp)((int)mVar2 + (uint)desc->size); + } + desc->stats->avail = desc->num; + return; +} + + + +void memp_init(void) + +{ + stats_ *psVar1; + int iVar2; + memp_desc *desc; + + iVar2 = 0; + psVar1 = &lwip_stats; + do { + desc = *(memp_desc **)((int)memp_pools + iVar2); + iVar2 = iVar2 + 4; + memp_init_pool(desc); + psVar1->memp[0] = desc->stats; + psVar1 = (stats_ *)&(psVar1->link).fw; + } while (iVar2 != 0x3c); + return; +} + + + +void * memp_malloc(memp_t type) + +{ + undefined3 in_register_00002029; + void *pvVar1; + + if (CONCAT31(in_register_00002029,type) < 0xf) { + pvVar1 = do_memp_malloc_pool(memp_pools[CONCAT31(in_register_00002029,type)]); + return pvVar1; + } + return (void *)0x0; +} + + + +void memp_free(memp_t type,void *mem) + +{ + memp_desc *pmVar1; + undefined3 in_register_00002029; + + if ((CONCAT31(in_register_00002029,type) < 0xf) && (mem != (void *)0x0)) { + pmVar1 = memp_pools[CONCAT31(in_register_00002029,type)]; + sys_arch_protect(); + pmVar1->stats->used = pmVar1->stats->used - 1; + *(memp **)mem = *pmVar1->tab; + *pmVar1->tab = mem; + sys_arch_unprotect(); + return; + } + return; +} + + + +err_t netif_null_output_ip4(netif *netif,pbuf *p,ip4_addr_t *ipaddr) + +{ + return -0xc; +} + + + +void netif_issue_reports(netif *netif,u8_t report_type) + +{ + if (((netif->flags & 5) != 5) || ((report_type & 1) == 0)) { + return; + } + if ((netif->ip_addr).addr != 0) { + if ((netif->flags & 8) != 0) { + etharp_request(netif,(ip4_addr_t *)&netif->ip_addr); + } + if ((netif->flags & 0x20) != 0) { + igmp_report_groups(netif); + return; + } + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: new_addr +// WARNING: Type propagation algorithm not settling + +int netif_do_set_ipaddr(netif *netif,ip4_addr_t *ipaddr,ip_addr_t *old_addr) + +{ + ip_addr_t iVar1; + ip_addr_t iStack20; + ip_addr_t new_addr; + + iVar1 = (ip_addr_t)(netif->ip_addr).addr; + iStack20 = (ip_addr_t)ipaddr->addr; + if (iStack20 != iVar1) { + *(ip_addr_t *)&old_addr->addr = iVar1; + tcp_netif_ip_addr_changed(old_addr,&iStack20); + udp_netif_ip_addr_changed(old_addr,&iStack20); + raw_netif_ip_addr_changed(old_addr,&iStack20); + (netif->ip_addr).addr = ipaddr->addr; + netif_issue_reports(netif,'\x01'); + if (netif->status_callback != (netif_status_callback_fn *)0x0) { + (*netif->status_callback)(netif); + } + return 1; + } + return 0; +} + + + +void netif_init(void) + +{ + return; +} + + + +void netif_set_ipaddr(netif *netif,ip4_addr_t *ipaddr) + +{ + ip_addr_t iStack20; + ip_addr_t old_addr; + + if (netif != (netif *)0x0) { + if (ipaddr == (ip4_addr_t *)0x0) { + ipaddr = (ip4_addr_t *)&ip_addr_any; + } + netif_do_set_ipaddr(netif,ipaddr,&iStack20); + return; + } + return; +} + + + +void netif_set_netmask(netif *netif,ip4_addr_t *netmask) + +{ + if (netif != (netif *)0x0) { + if (netmask == (ip4_addr_t *)0x0) { + netmask = (ip4_addr_t *)&ip_addr_any; + } + if (netmask->addr != (netif->netmask).addr) { + (netif->netmask).addr = netmask->addr; + } + } + return; +} + + + +void netif_set_gw(netif *netif,ip4_addr_t *gw) + +{ + if (netif != (netif *)0x0) { + if (gw == (ip4_addr_t *)0x0) { + gw = (ip4_addr_t *)&ip_addr_any; + } + if (gw->addr != (netif->gw).addr) { + (netif->gw).addr = gw->addr; + } + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: old_addr + +void netif_set_addr(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw) + +{ + bool bVar1; + ip_addr_t iStack20; + ip_addr_t old_addr; + + if (ipaddr == (ip4_addr_t *)0x0) { + ipaddr = (ip4_addr_t *)&ip_addr_any; + } + if (netmask == (ip4_addr_t *)0x0) { + netmask = (ip4_addr_t *)&ip_addr_any; + } + if (gw == (ip4_addr_t *)0x0) { + gw = (ip4_addr_t *)&ip_addr_any; + } + bVar1 = ipaddr->addr == 0; + if (bVar1) { + netif_do_set_ipaddr(netif,ipaddr,&iStack20); + } + if (netmask->addr != (netif->netmask).addr) { + (netif->netmask).addr = netmask->addr; + } + if (gw->addr != (netif->gw).addr) { + (netif->gw).addr = gw->addr; + } + if (!bVar1) { + netif_do_set_ipaddr(netif,ipaddr,&iStack20); + } + return; +} + + + +netif * netif_add(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw,void *state, + netif_init_fn_conflict *init,netif_input_fn *input) + +{ + u8_t uVar1; + err_t eVar2; + undefined3 extraout_var; + netif *pnVar3; + + if ((netif != (netif *)0x0) && (init != (netif_init_fn_conflict *)0x0)) { + if (ipaddr == (ip4_addr_t *)0x0) { + ipaddr = (ip4_addr_t *)&ip_addr_any; + } + if (netmask == (ip4_addr_t *)0x0) { + netmask = (ip4_addr_t *)&ip_addr_any; + } + if (gw == (ip4_addr_t *)0x0) { + gw = (ip4_addr_t *)&ip_addr_any; + } + netif->output = netif_null_output_ip4; + (netif->ip_addr).addr = 0; + (netif->netmask).addr = 0; + (netif->gw).addr = 0; + netif->mtu = 0; + netif->flags = '\0'; + memset(netif->client_data,0,0xc); + netif->state = state; + uVar1 = netif_num; + netif->input = input; + netif->num = uVar1; + netif->status_callback = (netif_status_callback_fn *)0x0; + netif->link_callback = (netif_status_callback_fn *)0x0; + netif->igmp_mac_filter = (netif_igmp_mac_filter_fn *)0x0; + netif_set_addr(netif,ipaddr,netmask,gw); + eVar2 = (*init)(netif); + if (CONCAT31(extraout_var,eVar2) == 0) { + do { + if (netif->num == -1) { + netif->num = '\0'; + } + uVar1 = netif->num; + pnVar3 = netif_list; + while( true ) { + if (pnVar3 == (netif *)0x0) { + netif_num = '\0'; + if (uVar1 != -2) { + netif_num = uVar1 + '\x01'; + } + netif->next = netif_list; + if ((netif->flags & 0x20) == 0) { + netif_list = netif; + return netif; + } + netif_list = netif; + igmp_start(netif); + return netif; + } + if (pnVar3->num == uVar1) break; + pnVar3 = pnVar3->next; + } + netif->num = uVar1 + '\x01'; + } while( true ); + } + } + return (netif *)0x0; +} + + + +void netif_set_default(netif *netif) + +{ + netif_default = netif; + return; +} + + + +void netif_set_up(netif *netif) + +{ + if (netif == (netif *)0x0) { + return; + } + if ((netif->flags & 1) == 0) { + netif->flags = netif->flags | 1; + if (netif->status_callback != (netif_status_callback_fn *)0x0) { + (*netif->status_callback)(netif); + } + netif_issue_reports(netif,'\x03'); + return; + } + return; +} + + + +void netif_set_down(netif *netif) + +{ + byte bVar1; + + if (netif == (netif *)0x0) { + return; + } + bVar1 = netif->flags; + if ((bVar1 & 1) != 0) { + netif->flags = bVar1 & 0xfe; + if ((bVar1 & 8) != 0) { + etharp_cleanup_netif(netif); + } + if (netif->status_callback != (netif_status_callback_fn *)0x0) { + // WARNING: Could not recover jumptable at 0x2306fea8. Too many branches + // WARNING: Treating indirect jump as call + (*netif->status_callback)(netif); + return; + } + } + return; +} + + + +void netif_remove(netif *netif) + +{ + netif *pnVar1; + ip_addr_t *old_addr; + netif *pnVar2; + + if (netif == (netif *)0x0) { + return; + } + if ((netif->ip_addr).addr != 0) { + old_addr = &netif->ip_addr; + tcp_netif_ip_addr_changed(old_addr,(ip_addr_t *)0x0); + udp_netif_ip_addr_changed(old_addr,(ip_addr_t *)0x0); + raw_netif_ip_addr_changed(old_addr,(ip_addr_t *)0x0); + } + if ((netif->flags & 0x20) != 0) { + igmp_stop(netif); + } + if ((netif->flags & 1) != 0) { + netif_set_down(netif); + } + if (netif_default == netif) { + netif_default = (netif *)0x0; + } + pnVar1 = netif_list; + if (netif_list == netif) { + netif_list = netif->next; + } + else { + do { + pnVar2 = pnVar1; + if (pnVar2 == (netif *)0x0) { + return; + } + pnVar1 = pnVar2->next; + } while (pnVar2->next != netif); + pnVar2->next = netif->next; + } + return; +} + + + +void netif_set_status_callback(netif *netif,netif_status_callback_fn *status_callback) + +{ + if (netif != (netif *)0x0) { + netif->status_callback = status_callback; + } + return; +} + + + +void netif_set_link_up(netif *netif) + +{ + if (netif == (netif *)0x0) { + return; + } + if ((netif->flags & 4) == 0) { + netif->flags = netif->flags | 4; + dhcp_network_changed(netif); + netif_issue_reports(netif,'\x03'); + if (netif->link_callback != (netif_status_callback_fn *)0x0) { + // WARNING: Could not recover jumptable at 0x2306ff7a. Too many branches + // WARNING: Treating indirect jump as call + (*netif->link_callback)(netif); + return; + } + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void netif_set_link_down(netif *netif) + +{ + if (netif != (netif *)0x0) { + if ((netif->flags & 4) != 0) { + netif->flags = netif->flags & 0xfb; + if (netif->link_callback != (netif_status_callback_fn *)0x0) { + // WARNING: Could not recover jumptable at 0x2306ffa0. Too many branches + // WARNING: Treating indirect jump as call + (*netif->link_callback)(); + return; + } + } + } + return; +} + + + +netif * netif_get_by_index(u8_t idx) + +{ + undefined3 in_register_00002029; + netif *pnVar1; + netif *pnVar2; + + pnVar1 = netif_list; + pnVar2 = (netif *)0x0; + if (CONCAT31(in_register_00002029,idx) != 0) { + while ((pnVar2 = pnVar1, pnVar1 != (netif *)0x0 && + (((uint)pnVar1->num + 1 & 0xff) != CONCAT31(in_register_00002029,idx)))) { + pnVar1 = pnVar1->next; + } + } + return pnVar2; +} + + + +netif * netif_find(char *name) + +{ + uint uVar1; + netif *pnVar2; + + if (name == (char *)0x0) { + return (netif *)0x0; + } + uVar1 = atoi(name + 2); + pnVar2 = netif_list; + while( true ) { + if (pnVar2 == (netif *)0x0) { + return (netif *)0x0; + } + if ((((uint)pnVar2->num == (uVar1 & 0xff)) && (*name == pnVar2->name[0])) && + (name[1] == pnVar2->name[1])) break; + pnVar2 = pnVar2->next; + } + return pnVar2; +} + + + +pbuf * pbuf_skip_const(pbuf *in,u16_t in_offset,u16_t *out_offset) + +{ + pbuf *ppVar1; + undefined2 in_register_0000202e; + + if ((in != (pbuf *)0x0) && ((uint)in->len <= CONCAT22(in_register_0000202e,in_offset))) { + ppVar1 = pbuf_skip_const(in->next,(u16_t)((CONCAT22(in_register_0000202e,in_offset) - + (uint)in->len) * 0x10000 >> 0x10),out_offset); + return ppVar1; + } + if (out_offset != (u16_t *)0x0) { + *out_offset = in_offset; + } + return in; +} + + + +void pbuf_free_ooseq_callback(void *arg) + +{ + tcp_pcb *pcb; + + sys_arch_protect(); + pbuf_free_ooseq_pending = '\0'; + sys_arch_unprotect(); + pcb = tcp_active_pcbs; + while( true ) { + if (pcb == (tcp_pcb *)0x0) { + return; + } + if (pcb->ooseq != (tcp_seg *)0x0) break; + pcb = pcb->next; + } + tcp_free_ooseq(pcb); + return; +} + + + +u8_t pbuf_add_header_impl(pbuf *p,size_t header_size_increment,u8_t force) + +{ + u8_t uVar1; + pbuf *ppVar2; + undefined3 in_register_00002031; + uint uVar3; + + if (p == (pbuf *)0x0) { + uVar1 = '\x01'; + } + else { + uVar1 = '\x01'; + if ((header_size_increment < 0x10000) && (uVar1 = '\0', header_size_increment != 0)) { + uVar3 = (uint)p->tot_len + (header_size_increment & 0xffff); + uVar1 = '\x01'; + if ((header_size_increment & 0xffff) <= (uVar3 & 0xffff)) { + if ((char)p->type_internal < '\0') { + ppVar2 = (pbuf *)((int)p->payload - header_size_increment); + if (ppVar2 < p + 1) { + return '\x01'; + } + } + else { + if (CONCAT31(in_register_00002031,force) == 0) { + return '\x01'; + } + ppVar2 = (pbuf *)((int)p->payload - header_size_increment); + } + *(pbuf **)&p->payload = ppVar2; + p->tot_len = (u16_t)(uVar3 * 0x10000 >> 0x10); + p->len = (short)header_size_increment + p->len; + return '\0'; + } + } + } + return uVar1; +} + + + +pbuf * pbuf_alloc_reference(void *payload,u16_t length,pbuf_type type) + +{ + pbuf *ppVar1; + + ppVar1 = (pbuf *)memp_malloc(MEMP_PBUF); + if (ppVar1 != (pbuf *)0x0) { + ppVar1->next = (pbuf *)0x0; + ppVar1->payload = payload; + ppVar1->tot_len = length; + ppVar1->len = length; + ppVar1->type_internal = (u8_t)type; + ppVar1->flags = '\0'; + *(undefined2 *)&ppVar1->ref = 1; + } + return ppVar1; +} + + + +pbuf * pbuf_alloced_custom(pbuf_layer l,u16_t length,pbuf_type type,pbuf_custom *p,void *payload_mem + ,u16_t payload_mem_len) + +{ + undefined3 in_register_00002029; + uint uVar1; + undefined2 in_register_0000202e; + undefined2 in_register_0000203e; + + uVar1 = CONCAT31(in_register_00002029,l) + 3U & 0xfffffffc; + if (CONCAT22(in_register_0000202e,length) + uVar1 <= + CONCAT22(in_register_0000203e,payload_mem_len)) { + if (payload_mem != (void *)0x0) { + payload_mem = (void *)((int)payload_mem + uVar1); + } + (p->pbuf).flags = '\x02'; + (p->pbuf).next = (pbuf *)0x0; + (p->pbuf).payload = payload_mem; + (p->pbuf).tot_len = length; + (p->pbuf).len = length; + (p->pbuf).type_internal = (u8_t)type; + *(undefined2 *)&(p->pbuf).ref = 1; + return (pbuf *)p; + } + return (pbuf *)0x0; +} + + + +u8_t pbuf_add_header(pbuf *p,size_t header_size_increment) + +{ + u8_t uVar1; + + uVar1 = pbuf_add_header_impl(p,header_size_increment,'\0'); + return uVar1; +} + + + +u8_t pbuf_remove_header(pbuf *p,size_t header_size_decrement) + +{ + u8_t uVar1; + + if (p == (pbuf *)0x0) { + uVar1 = '\x01'; + } + else { + uVar1 = '\x01'; + if ((header_size_decrement < 0x10000) && (uVar1 = '\0', header_size_decrement != 0)) { + uVar1 = '\x01'; + if ((header_size_decrement & 0xffff) <= (uint)p->len) { + p->len = p->len - (short)header_size_decrement; + p->payload = (void *)(header_size_decrement + (int)p->payload); + p->tot_len = p->tot_len - (short)header_size_decrement; + return '\0'; + } + } + } + return uVar1; +} + + + +u8_t pbuf_header(pbuf *p,s16_t header_size_increment) + +{ + u8_t uVar1; + short in_register_0000202e; + + if (in_register_0000202e < 0) { + uVar1 = pbuf_remove_header(p,-CONCAT22(in_register_0000202e,header_size_increment)); + return uVar1; + } + uVar1 = pbuf_add_header_impl(p,CONCAT22(in_register_0000202e,header_size_increment),'\0'); + return uVar1; +} + + + +u8_t pbuf_header_force(pbuf *p,s16_t header_size_increment) + +{ + u8_t uVar1; + short in_register_0000202e; + + if (in_register_0000202e < 0) { + uVar1 = pbuf_remove_header(p,-CONCAT22(in_register_0000202e,header_size_increment)); + return uVar1; + } + uVar1 = pbuf_add_header_impl(p,CONCAT22(in_register_0000202e,header_size_increment),'\x01'); + return uVar1; +} + + + +u8_t pbuf_free(pbuf *p) + +{ + u8_t uVar1; + u8_t uVar2; + pbuf *ppVar3; + memp_t type; + byte bVar4; + + uVar1 = '\0'; + if (p != (pbuf *)0x0) { + uVar1 = '\0'; + do { + sys_arch_protect(); + uVar2 = p->ref + -1; + p->ref = uVar2; + sys_arch_unprotect(); + if (uVar2 != '\0') { + return uVar1; + } + ppVar3 = p->next; + if ((p->flags & 2) == 0) { + type = MEMP_PBUF_POOL; + bVar4 = p->type_internal & 0xf; + if (bVar4 != 2) { + if (bVar4 != 1) { + if ((p->type_internal & 0xf) == 0) { + mem_free(p); + } + goto LAB_230701ea; + } + type = MEMP_PBUF; + } + memp_free(type,p); + } + else { + (*(code *)p[1].next)(p,p[1].next); + } +LAB_230701ea: + uVar1 = uVar1 + '\x01'; + p = ppVar3; + } while (ppVar3 != (pbuf *)0x0); + } + return uVar1; +} + + + +pbuf * pbuf_alloc(pbuf_layer layer,u16_t length,pbuf_type type) + +{ + u8_t uVar1; + uint uVar2; + uint uVar3; + pbuf *ppVar4; + err_t eVar5; + undefined3 in_register_00002029; + pbuf *p; + pbuf *ppVar6; + undefined3 extraout_var; + undefined2 in_register_0000202e; + undefined2 in_register_00002032; + uint uVar7; + pbuf *ppVar8; + + uVar7 = CONCAT22(in_register_00002032,type); + uVar3 = CONCAT22(in_register_0000202e,length); + if (uVar7 != 0x41) { + if (uVar7 < 0x42) { + if (uVar7 == 1) goto LAB_230702d0; + } + else { + uVar2 = CONCAT31(in_register_00002029,layer) & 0xffff; + if (uVar7 == 0x182) { + p = (pbuf *)0x0; + ppVar8 = (pbuf *)0x0; + while (ppVar6 = (pbuf *)memp_malloc(MEMP_PBUF_POOL), ppVar6 != (pbuf *)0x0) { + uVar7 = 0x2f8 - (uVar2 + 3 & 0xfffffffc); + if (uVar3 < (uVar7 & 0xffff)) { + uVar7 = uVar3; + } + ppVar6->next = (pbuf *)0x0; + ppVar6->payload = (void *)((int)&ppVar6[1].next + uVar2 + 3 & 0xfffffffc); + ppVar6->tot_len = (u16_t)uVar3; + ppVar6->len = (u16_t)uVar7; + *(undefined4 *)&ppVar6->type_internal = 0x10082; + ppVar4 = ppVar6; + if (p != (pbuf *)0x0) { + ppVar8->next = ppVar6; + ppVar4 = p; + } + uVar3 = uVar3 - (uVar7 & 0xffff) & 0xffff; + uVar2 = 0; + p = ppVar4; + ppVar8 = ppVar6; + if (uVar3 == 0) { + return ppVar4; + } + } + sys_arch_protect(); + uVar1 = pbuf_free_ooseq_pending; + pbuf_free_ooseq_pending = '\x01'; + sys_arch_unprotect(); + if ((uVar1 == '\0') && + (eVar5 = tcpip_try_callback(pbuf_free_ooseq_callback,(void *)0x0), + CONCAT31(extraout_var,eVar5) != 0)) { + sys_arch_protect(); + pbuf_free_ooseq_pending = '\0'; + sys_arch_unprotect(); + } + if (p != (pbuf *)0x0) { + pbuf_free(p); + } + } + else { + if (uVar7 == 0x280) { + uVar7 = uVar3 + 3 & 0xfffffffc; + uVar3 = (uVar2 + 3 & 0xfffffffc) + uVar7 & 0xffff; + if ((uVar7 <= uVar3) && (uVar7 <= (uVar3 + 0x10 & 0xffff))) { + p = (pbuf *)mem_malloc(); + if (p == (pbuf *)0x0) { + return (pbuf *)0x0; + } + p->next = (pbuf *)0x0; + p->payload = (void *)((int)&p[1].next + CONCAT31(in_register_00002029,layer) + 3 & + 0xfffffffc); + p->tot_len = length; + p->len = length; + *(undefined4 *)&p->type_internal = 0x10080; + return p; + } + } + } + } + return (pbuf *)0x0; + } +LAB_230702d0: + p = pbuf_alloc_reference((void *)0x0,length,type); + return p; +} + + + +void pbuf_realloc(pbuf *p,u16_t new_len) + +{ + ushort uVar1; + uint uVar2; + undefined2 in_register_0000202e; + uint uVar3; + + uVar2 = CONCAT22(in_register_0000202e,new_len); + uVar1 = p->tot_len; + if (uVar2 < uVar1) { + while (uVar3 = (uint)p->len, uVar3 < uVar2) { + p->tot_len = p->tot_len + (new_len - uVar1); + uVar2 = uVar2 - uVar3 & 0xffff; + p = p->next; + } + if ((((p->type_internal & 0xf) == 0) && (uVar3 != uVar2)) && ((p->flags & 2) == 0)) { + p = (pbuf *)mem_trim(p,(int)p->payload + (uVar2 - (int)p) & 0xffff); + } + p->len = (u16_t)uVar2; + p->tot_len = (u16_t)uVar2; + if (p->next != (pbuf *)0x0) { + pbuf_free(p->next); + } + p->next = (pbuf *)0x0; + return; + } + return; +} + + + +pbuf * pbuf_free_header(pbuf *q,u16_t size) + +{ + pbuf *ppVar1; + undefined2 in_register_0000202e; + uint header_size_decrement; + + header_size_decrement = CONCAT22(in_register_0000202e,size); + while( true ) { + if (header_size_decrement == 0) { + return q; + } + if (q == (pbuf *)0x0) break; + if (header_size_decrement < q->len) { + pbuf_remove_header(q,header_size_decrement); + return q; + } + ppVar1 = q->next; + header_size_decrement = header_size_decrement - q->len & 0xffff; + q->next = (pbuf *)0x0; + pbuf_free(q); + q = ppVar1; + } + return (pbuf *)0x0; +} + + + +u16_t pbuf_clen(pbuf *p) + +{ + u16_t uVar1; + + uVar1 = 0; + while (p != (pbuf *)0x0) { + uVar1 = uVar1 + 1; + p = p->next; + } + return uVar1; +} + + + +void pbuf_ref(pbuf *p) + +{ + if (p != (pbuf *)0x0) { + sys_arch_protect(); + p->ref = p->ref + '\x01'; + sys_arch_unprotect(); + return; + } + return; +} + + + +void pbuf_cat(pbuf *h,pbuf *t) + +{ + pbuf *ppVar1; + + if (h != (pbuf *)0x0) { + if (t == (pbuf *)0x0) { + return; + } + do { + ppVar1 = h; + ppVar1->tot_len = (u16_t)(((uint)ppVar1->tot_len + (uint)t->tot_len) * 0x10000 >> 0x10); + h = ppVar1->next; + } while (ppVar1->next != (pbuf *)0x0); + ppVar1->next = t; + } + return; +} + + + +void pbuf_chain(pbuf *h,pbuf *t) + +{ + pbuf_cat(h,t); + pbuf_ref(t); + return; +} + + + +err_t pbuf_copy(pbuf *p_to,pbuf *p_from) + +{ + err_t eVar1; + uint uVar2; + uint __n; + uint uVar3; + uint uVar4; + + if (p_to == (pbuf *)0x0) { + return -0x10; + } + if ((p_from == (pbuf *)0x0) || (p_to->tot_len < p_from->tot_len)) { +LAB_2307051a: + eVar1 = -0x10; + } + else { + uVar4 = 0; + uVar3 = 0; + do { + __n = p_to->len - uVar3; + uVar2 = p_from->len - uVar4; + if (uVar2 < __n) { + __n = uVar2; + } + memcpy((void *)((int)p_to->payload + uVar3),(void *)((int)p_from->payload + uVar4),__n); + uVar4 = uVar4 + __n; + uVar3 = uVar3 + __n; + if (p_from->len <= uVar4) { + p_from = p_from->next; + uVar4 = 0; + } + if (uVar3 == (uint)p_to->len) { + p_to = p_to->next; + if (p_to == (pbuf *)0x0) { + if (p_from == (pbuf *)0x0) { + return '\0'; + } + goto LAB_2307051a; + } + uVar3 = 0; + } + if ((((p_from != (pbuf *)0x0) && (p_from->len == p_from->tot_len)) && + (p_from->next != (pbuf *)0x0)) || + ((p_to->len == p_to->tot_len && (p_to->next != (pbuf *)0x0)))) { + return -6; + } + } while (p_from != (pbuf *)0x0); + eVar1 = '\0'; + } + return eVar1; +} + + + +u16_t pbuf_copy_partial(pbuf *buf,void *dataptr,u16_t len,u16_t offset) + +{ + u16_t uVar1; + uint uVar2; + uint uVar3; + uint __n; + undefined2 in_register_00002032; + undefined2 in_register_00002036; + uint uVar4; + + uVar4 = CONCAT22(in_register_00002036,offset); + uVar3 = CONCAT22(in_register_00002032,len); + uVar1 = 0; + if (buf != (pbuf *)0x0) { + uVar2 = 0; + uVar1 = 0; + if (dataptr != (void *)0x0) { + while ((uVar1 = (u16_t)uVar2, uVar3 != 0 && (buf != (pbuf *)0x0))) { + __n = (uint)buf->len; + if ((uVar4 == 0) || (uVar4 < __n)) { + __n = __n - uVar4 & 0xffff; + if (uVar3 < __n) { + __n = uVar3; + } + __n = __n & 0xffff; + memcpy((void *)((int)dataptr + uVar2),(void *)((int)buf->payload + uVar4),__n); + uVar2 = uVar2 + __n & 0xffff; + uVar3 = uVar3 - __n & 0xffff; + uVar4 = 0; + } + else { + uVar4 = uVar4 - __n & 0xffff; + } + buf = buf->next; + } + } + } + return uVar1; +} + + + +err_t pbuf_take(pbuf *buf,void *dataptr,u16_t len) + +{ + uint uVar1; + err_t eVar2; + undefined2 in_register_00002032; + uint __n; + int iVar3; + + uVar1 = CONCAT22(in_register_00002032,len); + if (buf != (pbuf *)0x0) { + eVar2 = -0x10; + if (dataptr != (void *)0x0) { + eVar2 = -1; + iVar3 = 0; + if (uVar1 <= buf->tot_len) { + while (uVar1 != 0) { + __n = (uint)buf->len; + if (uVar1 < (uint)buf->len) { + __n = uVar1; + } + memcpy(buf->payload,(void *)((int)dataptr + iVar3),__n); + buf = buf->next; + uVar1 = uVar1 - __n; + iVar3 = iVar3 + __n; + } + eVar2 = '\0'; + } + } + return eVar2; + } + return -0x10; +} + + + +err_t pbuf_take_at(pbuf *buf,void *dataptr,u16_t len,u16_t offset) + +{ + err_t eVar1; + pbuf *ppVar2; + undefined2 in_register_00002032; + size_t sVar3; + uint uVar4; + uint uVar5; + size_t __n; + u16_t auStack34 [2]; + u16_t target_offset; + + sVar3 = CONCAT22(in_register_00002032,len); + ppVar2 = pbuf_skip_const(buf,offset,auStack34); + if (ppVar2 == (pbuf *)0x0) { + eVar1 = -1; + } + else { + uVar4 = (uint)auStack34[0]; + eVar1 = -1; + if ((int)(uVar4 + sVar3) <= (int)(uint)ppVar2->tot_len) { + uVar5 = ppVar2->len - uVar4; + __n = sVar3; + if ((int)uVar5 < (int)sVar3) { + __n = uVar5 & 0xffff; + } + memcpy((void *)((int)ppVar2->payload + uVar4),dataptr,__n); + eVar1 = '\0'; + if ((sVar3 - __n & 0xffff) != 0) { + eVar1 = pbuf_take(ppVar2->next,(void *)((int)dataptr + __n), + (u16_t)((sVar3 - __n) * 0x10000 >> 0x10)); + } + } + } + return eVar1; +} + + + +pbuf * pbuf_clone(pbuf_layer layer,pbuf_type type,pbuf *p) + +{ + pbuf *p_to; + + p_to = pbuf_alloc(layer,p->tot_len,type); + if (p_to != (pbuf *)0x0) { + pbuf_copy(p_to,p); + } + return p_to; +} + + + +int pbuf_try_get_at(pbuf *p,u16_t offset) + +{ + pbuf *ppVar1; + uint uVar2; + u16_t auStack18 [2]; + u16_t q_idx; + + ppVar1 = pbuf_skip_const(p,offset,auStack18); + uVar2 = 0xffffffff; + if (ppVar1 != (pbuf *)0x0) { + uVar2 = 0xffffffff; + if ((uint)auStack18[0] < (uint)ppVar1->len) { + uVar2 = (uint)*(byte *)((int)ppVar1->payload + (uint)auStack18[0]); + } + } + return uVar2; +} + + + +u8_t pbuf_get_at(pbuf *p,u16_t offset) + +{ + u8_t uVar1; + + _uVar1 = pbuf_try_get_at(p,offset); + uVar1 = (u8_t)_uVar1; + if (_uVar1 < 0) { + uVar1 = '\0'; + } + return uVar1; +} + + + +void pbuf_put_at(pbuf *p,u16_t offset,u8_t data) + +{ + pbuf *ppVar1; + u16_t auStack18 [2]; + u16_t q_idx; + + ppVar1 = pbuf_skip_const(p,offset,auStack18); + if ((ppVar1 != (pbuf *)0x0) && ((uint)auStack18[0] < (uint)ppVar1->len)) { + *(u8_t *)((int)ppVar1->payload + (uint)auStack18[0]) = data; + } + return; +} + + + +u16_t pbuf_memcmp(pbuf *p,u16_t offset,void *s2,u16_t n) + +{ + byte *pbVar1; + ushort *puVar2; + uint uVar3; + u8_t uVar4; + undefined3 extraout_var; + undefined2 in_register_0000202e; + undefined2 in_register_00002036; + short sVar5; + uint uVar6; + + uVar3 = CONCAT22(in_register_0000202e,offset); + if ((int)(uint)p->tot_len < (int)(uVar3 + CONCAT22(in_register_00002036,n))) { + return 0xffff; + } + do { + puVar2 = &p->len; + if (uVar3 < *puVar2) break; + p = p->next; + uVar3 = uVar3 - *puVar2 & 0xffff; + } while (p != (pbuf *)0x0); + uVar6 = 0; + do { + _sVar5 = uVar6 & 0xffff; + sVar5 = (short)_sVar5; + if (CONCAT22(in_register_00002036,n) <= _sVar5) { + return 0; + } + uVar4 = pbuf_get_at(p,(u16_t)((_sVar5 + uVar3) * 0x10000 >> 0x10)); + pbVar1 = (byte *)((int)s2 + uVar6); + uVar6 = uVar6 + 1; + } while ((uint)*pbVar1 == CONCAT31(extraout_var,uVar4)); + if (0xfffe < _sVar5) { + sVar5 = -2; + } + return sVar5 + 1; +} + + + +u16_t pbuf_memfind(pbuf *p,void *mem,u16_t mem_len,u16_t start_offset) + +{ + ushort uVar1; + uint uVar2; + u16_t uVar3; + undefined2 extraout_var; + undefined2 in_register_00002032; + undefined2 in_register_00002036; + + uVar2 = CONCAT22(in_register_00002036,start_offset); + uVar1 = p->tot_len; + if ((int)(CONCAT22(in_register_00002032,mem_len) + uVar2) <= (int)(uint)uVar1) { + while (uVar2 <= ((uint)uVar1 - CONCAT22(in_register_00002032,mem_len) & 0xffff)) { + uVar3 = pbuf_memcmp(p,(u16_t)uVar2,mem,mem_len); + if (CONCAT22(extraout_var,uVar3) == 0) { + return (u16_t)uVar2; + } + uVar2 = uVar2 + 1 & 0xffff; + } + } + return 0xffff; +} + + + +raw_input_state_t raw_input(pbuf *p,netif *inp) + +{ + u8_t uVar1; + raw_pcb *prVar2; + raw_pcb *prVar3; + u8_t uVar4; + raw_input_state_t rVar5; + u8_t uVar6; + undefined3 extraout_var; + undefined3 extraout_var_00; + u32_t uVar7; + raw_pcb *prVar8; + + uVar4 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_dest,ip_data.current_netif); + uVar1 = *(u8_t *)((int)p->payload + 9); + rVar5 = RAW_INPUT_NONE; + prVar2 = raw_pcbs; + prVar8 = (raw_pcb *)0x0; + do { + prVar3 = prVar2; + if (prVar3 == (raw_pcb *)0x0) { + return rVar5; + } + if ((prVar3->protocol == uVar1) && + ((prVar3->netif_idx == '\0' || + (prVar3->netif_idx == (u8_t)((ip_data.current_input_netif)->num + '\x01'))))) { + uVar7 = (prVar3->local_ip).addr; + if (CONCAT31(extraout_var,uVar4) == 0) { + if ((uVar7 == 0) || (ip_data.current_iphdr_dest == uVar7)) goto LAB_230708a6; + } + else { + if (uVar7 == 0) { +LAB_230708a6: + if ((((prVar3->flags & 1) == 0) || ((prVar3->remote_ip).addr == ip_data.current_iphdr_src) + ) && (prVar3->recv != (raw_recv_fn *)0x0)) { + uVar6 = (*prVar3->recv)(prVar3->recv_arg,prVar3,p,(ip_addr_t *)0x42026928); + if (CONCAT31(extraout_var_00,uVar6) != 0) { + if (prVar8 == (raw_pcb *)0x0) { + return RAW_INPUT_EATEN; + } + prVar8->next = prVar3->next; + prVar3->next = raw_pcbs; + raw_pcbs = prVar3; + return RAW_INPUT_EATEN; + } + rVar5 = RAW_INPUT_DELIVERED; + } + } + } + } + prVar2 = prVar3->next; + prVar8 = prVar3; + } while( true ); +} + + + +err_t raw_bind(raw_pcb *pcb,ip_addr_t *ipaddr) + +{ + err_t eVar1; + + eVar1 = -6; + if ((pcb != (raw_pcb *)0x0) && (ipaddr != (ip_addr_t *)0x0)) { + (pcb->local_ip).addr = ipaddr->addr; + eVar1 = '\0'; + } + return eVar1; +} + + + +void raw_bind_netif(raw_pcb *pcb,netif *netif) + +{ + u8_t uVar1; + + uVar1 = '\0'; + if (netif != (netif *)0x0) { + uVar1 = netif->num + '\x01'; + } + pcb->netif_idx = uVar1; + return; +} + + + +err_t raw_connect(raw_pcb *pcb,ip_addr_t *ipaddr) + +{ + if ((pcb != (raw_pcb *)0x0) && (ipaddr != (ip_addr_t *)0x0)) { + (pcb->remote_ip).addr = ipaddr->addr; + pcb->flags = pcb->flags | 1; + return '\0'; + } + return -6; +} + + + +void raw_recv(raw_pcb *pcb,raw_recv_fn *recv,void *recv_arg) + +{ + pcb->recv = recv; + pcb->recv_arg = recv_arg; + return; +} + + + +err_t raw_sendto_if_src(raw_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,netif *netif,ip_addr_t *src_ip) + +{ + err_t eVar1; + u8_t ttl; + undefined3 extraout_var; + pbuf *h; + undefined3 extraout_var_00; + + if ((((pcb == (raw_pcb *)0x0) || (dst_ip == (ip_addr_t *)0x0)) || (netif == (netif *)0x0)) || + (src_ip == (ip_addr_t *)0x0)) { + return -6; + } + if ((pcb->flags & 2) != 0) { + if (p->len < 0x14) { + return -6; + } + eVar1 = ip4_output_if(p,(ip4_addr_t *)src_ip,(ip4_addr_t *)0x0,'\0','\0','\0',netif); + return eVar1; + } + if (0xffeb < p->tot_len) { + return -1; + } + ttl = pbuf_add_header(p,0x14); + if (CONCAT31(extraout_var,ttl) == 0) { + ttl = pbuf_remove_header(p,0x14); + h = p; + if (CONCAT31(extraout_var_00,ttl) != 0) { + return -1; + } + } + else { + h = pbuf_alloc(PBUF_IP,0,PBUF_RAM); + if (h == (pbuf *)0x0) { + return -1; + } + if (p->tot_len != 0) { + pbuf_chain(h,p); + } + } + if ((pcb->flags & 4) == 0) { +LAB_23070a1a: + if ((dst_ip->addr & 0xf0) == 0xe0) { + ttl = pcb->mcast_ttl; + goto LAB_23070a2e; + } + } + else { + if ((dst_ip->addr & 0xf0) == 0xe0) { + h->flags = h->flags | 4; + goto LAB_23070a1a; + } + } + ttl = pcb->ttl; +LAB_23070a2e: + eVar1 = ip4_output_if(h,(ip4_addr_t *)src_ip,(ip4_addr_t *)dst_ip,ttl,pcb->tos,pcb->protocol,netif + ); + if (p != h) { + pbuf_free(h); + return eVar1; + } + return eVar1; +} + + + +err_t raw_sendto(raw_pcb *pcb,pbuf *p,ip_addr_t *ipaddr) + +{ + err_t eVar1; + netif *netif; + raw_pcb *src_ip; + uint uVar2; + + if ((pcb == (raw_pcb *)0x0) || (ipaddr == (ip_addr_t *)0x0)) { + return -6; + } + if (pcb->netif_idx == '\0') { + if (((ipaddr->addr & 0xf0) == 0xe0) && + (netif = netif_get_by_index(pcb->mcast_ifindex), netif != (netif *)0x0)) goto LAB_23070ab6; + netif = ip4_route((ip4_addr_t *)ipaddr); + } + else { + netif = netif_get_by_index(pcb->netif_idx); + } + if (netif == (netif *)0x0) { + return -4; + } +LAB_23070ab6: + uVar2 = (pcb->local_ip).addr; + if ((uVar2 == 0) || (src_ip = pcb, (uVar2 & 0xf0) == 0xe0)) { + src_ip = (raw_pcb *)&netif->ip_addr; + } + eVar1 = raw_sendto_if_src(pcb,p,ipaddr,netif,(ip_addr_t *)src_ip); + return eVar1; +} + + + +err_t raw_send(raw_pcb *pcb,pbuf *p) + +{ + err_t eVar1; + + eVar1 = raw_sendto(pcb,p,&pcb->remote_ip); + return eVar1; +} + + + +void raw_remove(raw_pcb *pcb) + +{ + raw_pcb *prVar1; + raw_pcb *prVar2; + + prVar1 = raw_pcbs; + if (raw_pcbs == pcb) { + raw_pcbs = pcb->next; + } + else { + do { + prVar2 = prVar1; + if ((prVar2 == (raw_pcb *)0x0) || (prVar1 = prVar2->next, prVar1 == (raw_pcb *)0x0)) + goto LAB_23070b04; + } while (prVar1 != pcb); + prVar2->next = pcb->next; + } +LAB_23070b04: + memp_free(MEMP_RAW_PCB,pcb); + return; +} + + + +raw_pcb * raw_new(u8_t proto) + +{ + raw_pcb *prVar1; + raw_pcb *__s; + + __s = (raw_pcb *)memp_malloc(MEMP_RAW_PCB); + if (__s != (raw_pcb *)0x0) { + memset(__s,0,0x1c); + __s->ttl = -1; + __s->mcast_ttl = -1; + __s->protocol = proto; + prVar1 = __s; + __s->next = raw_pcbs; + raw_pcbs = prVar1; + } + return __s; +} + + + +raw_pcb * raw_new_ip_type(u8_t type,u8_t proto) + +{ + raw_pcb *prVar1; + + prVar1 = raw_new(proto); + return prVar1; +} + + + +void raw_netif_ip_addr_changed(ip_addr_t *old_addr,ip_addr_t *new_addr) + +{ + raw_pcb *prVar1; + + if ((((old_addr != (ip_addr_t *)0x0) && (old_addr->addr != 0)) && (new_addr != (ip_addr_t *)0x0)) + && (prVar1 = raw_pcbs, new_addr->addr != 0)) { + while (prVar1 != (raw_pcb *)0x0) { + if ((prVar1->local_ip).addr == old_addr->addr) { + (prVar1->local_ip).addr = new_addr->addr; + } + prVar1 = prVar1->next; + } + } + return; +} + + + +void stats_init(void) + +{ + return; +} + + + +u16_t tcp_new_port(void) + +{ + uint uVar1; + uint uVar2; + u32_t uVar3; + tcp_pcb ***ppptVar4; + + uVar2 = 0x4000; +again: + tcp_port = tcp_port + 1; + if (tcp_port == 0xffff) { + tcp_port = 0xc000; + } + ppptVar4 = tcp_pcb_lists; + do { + uVar3 = (((tcp_pcb *)*ppptVar4)->local_ip).addr; + while (uVar3 != 0) { + if (*(u16_t *)(uVar3 + 0x16) == tcp_port) { + uVar1 = uVar2 - 1; + uVar2 = uVar1 & 0xffff; + if (uVar2 == 0) { + return (u16_t)(uVar1 * 0x10000 >> 0x10); + } + goto again; + } + uVar3 = *(u32_t *)(uVar3 + 0xc); + } + ppptVar4 = (tcp_pcb ***)((tcp_pcb **)ppptVar4 + 1); + if (ppptVar4 == (tcp_pcb ***)&switchdataD_230c3774) { + return tcp_port; + } + } while( true ); +} + + + +err_t tcp_close_shutdown_fin(tcp_pcb *pcb) + +{ + err_t eVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + tcp_state tVar2; + + tVar2 = pcb->state; + if (tVar2 != ESTABLISHED) { + if (tVar2 == CLOSE_WAIT) { + eVar1 = tcp_send_fin(pcb); + _eVar1 = CONCAT31(extraout_var_00,eVar1); + if (_eVar1 != 0) goto LAB_23070c34; + tVar2 = LAST_ACK; + goto LAB_23070c12; + } + if (tVar2 != SYN_RCVD) { + return '\0'; + } + } + eVar1 = tcp_send_fin(pcb); + _eVar1 = CONCAT31(extraout_var,eVar1); + if (_eVar1 != 0) { +LAB_23070c34: + if (_eVar1 == -1) { + pcb->flags = pcb->flags | 8; + return '\0'; + } + return (err_t)_eVar1; + } + tVar2 = FIN_WAIT_1; +LAB_23070c12: + pcb->state = tVar2; + tcp_output(pcb); + return '\0'; +} + + + +void tcp_init(void) + +{ + uint uVar1; + + uVar1 = bl_rand(); + tcp_port = (u16_t)(((uVar1 & 0x3fff) - 0x4000) * 0x10000 >> 0x10); + printf("-------------------->>>>>>>> LWIP tcp_port %u\r\n"); + return; +} + + + +void tcp_free(tcp_pcb *pcb) + +{ + memp_free(MEMP_TCP_PCB,pcb); + return; +} + + + +err_t tcp_bind(tcp_pcb *pcb,ip_addr_t *ipaddr,u16_t port) + +{ + tcp_pcb *ptVar1; + err_t eVar2; + undefined2 extraout_var; + int iVar3; + undefined2 in_register_00002032; + tcp_pcb ***ppptVar4; + u32_t *puVar5; + + if (ipaddr == (ip_addr_t *)0x0) { + ipaddr = &ip_addr_any; + } + eVar2 = -0x10; + if ((pcb != (tcp_pcb *)0x0) && (eVar2 = -6, pcb->state == CLOSED)) { + if (CONCAT22(in_register_00002032,port) == 0) { + port = tcp_new_port(); + if (CONCAT22(extraout_var,port) == 0) { + return -2; + } + } + else { + ppptVar4 = tcp_pcb_lists; + iVar3 = 0; + do { + puVar5 = (u32_t *)(((tcp_pcb *)*ppptVar4)->local_ip).addr; + while (puVar5 != (u32_t *)0x0) { + if ((((uint)*(ushort *)((int)puVar5 + 0x16) == CONCAT22(in_register_00002032,port)) && + (((pcb->so_options & 4) == 0 || ((*(byte *)((int)puVar5 + 9) & 4) == 0)))) && + ((*puVar5 == 0 || ((ipaddr->addr == 0 || (*puVar5 == ipaddr->addr)))))) { + return -8; + } + puVar5 = (u32_t *)puVar5[3]; + } + iVar3 = iVar3 + 1; + ppptVar4 = (tcp_pcb ***)((tcp_pcb **)ppptVar4 + 1); + } while ((uint)((pcb->so_options & 4) == 0) + 3 != iVar3); + } + if (ipaddr->addr != 0) { + (pcb->local_ip).addr = ipaddr->addr; + } + pcb->local_port = port; + ptVar1 = pcb; + pcb->next = tcp_bound_pcbs; + tcp_bound_pcbs = ptVar1; + tcp_timer_needed(); + eVar2 = '\0'; + } + return eVar2; +} + + + +void tcp_bind_netif(tcp_pcb *pcb,netif *netif) + +{ + u8_t uVar1; + + uVar1 = '\0'; + if (netif != (netif *)0x0) { + uVar1 = netif->num + '\x01'; + } + pcb->netif_idx = uVar1; + return; +} + + + +tcp_pcb * tcp_listen_with_backlog_and_err(tcp_pcb *pcb,u8_t backlog,err_t *err) + +{ + u8_t uVar1; + tcp_pcb *ptVar2; + tcp_pcb *ptVar3; + err_t eVar4; + tcp_pcb *ptVar5; + + if (pcb == (tcp_pcb *)0x0) { + ptVar3 = (tcp_pcb *)0x0; + eVar4 = -0x10; + } + else { + if (pcb->state == CLOSED) { + ptVar3 = tcp_listen_pcbs; + if ((pcb->so_options & 4) != 0) { + while (ptVar3 != (tcp_pcb *)0x0) { + if ((ptVar3->local_port == pcb->local_port) && + ((ptVar3->local_ip).addr == (pcb->local_ip).addr)) { + eVar4 = -8; + goto LAB_23070e32; + } + ptVar3 = ptVar3->next; + } + } + ptVar3 = (tcp_pcb *)memp_malloc(MEMP_TCP_PCB_LISTEN); + eVar4 = -1; + if (ptVar3 != (tcp_pcb *)0x0) { + ptVar3->callback_arg = pcb->callback_arg; + ptVar3->local_port = pcb->local_port; + ptVar3->state = LISTEN; + ptVar3->prio = pcb->prio; + uVar1 = pcb->so_options; + ptVar3->netif_idx = '\0'; + ptVar3->so_options = uVar1; + ptVar3->ttl = pcb->ttl; + ptVar3->tos = pcb->tos; + (ptVar3->local_ip).addr = (pcb->local_ip).addr; + if (pcb->local_port != 0) { + ptVar2 = tcp_bound_pcbs; + if (tcp_bound_pcbs == pcb) { + tcp_bound_pcbs = pcb->next; + } + else { + do { + ptVar5 = ptVar2; + if (ptVar5 == (tcp_pcb *)0x0) goto LAB_23070dc4; + ptVar2 = ptVar5->next; + } while (ptVar5->next != pcb); + ptVar5->next = pcb->next; + } +LAB_23070dc4: + pcb->next = (tcp_pcb *)0x0; + } + tcp_free(pcb); + *(undefined4 *)&ptVar3->remote_port = 0x2307137e; + ptVar2 = ptVar3; + ptVar3->next = tcp_listen_pcbs; + tcp_listen_pcbs = ptVar2; + tcp_timer_needed(); + eVar4 = '\0'; + } + } + else { + eVar4 = -0xf; +LAB_23070e32: + ptVar3 = (tcp_pcb *)0x0; + } + } + if (err != (err_t *)0x0) { + *err = eVar4; + } + return ptVar3; +} + + + +u32_t tcp_update_rcv_ann_wnd(tcp_pcb *pcb) + +{ + u32_t uVar1; + u32_t uVar2; + u32_t uVar3; + uint uVar4; + + uVar3 = pcb->rcv_ann_right_edge; + uVar2 = pcb->rcv_nxt; + uVar4 = (uint)pcb->mss; + uVar1 = (pcb->rcv_wnd - uVar3) + uVar2; + if (0x408 < pcb->mss) { + uVar4 = 0x408; + } + if (-1 < (int)(uVar1 - uVar4)) { + pcb->rcv_ann_wnd = pcb->rcv_wnd; + return uVar1; + } + if ((int)(uVar2 - uVar3) < 1) { + pcb->rcv_ann_wnd = (short)uVar3 - (short)uVar2; + } + else { + pcb->rcv_ann_wnd = 0; + } + return 0; +} + + + +void tcp_recved(tcp_pcb *pcb,u16_t len) + +{ + u32_t uVar1; + tcpwnd_size_t tVar2; + + if (pcb == (tcp_pcb *)0x0) { + return; + } + tVar2 = len + pcb->rcv_wnd; + if ((0x810 < tVar2) || (tVar2 < pcb->rcv_wnd)) { + tVar2 = 0x810; + } + pcb->rcv_wnd = tVar2; + uVar1 = tcp_update_rcv_ann_wnd(pcb); + if (0x407 < uVar1) { + pcb->flags = pcb->flags | 2; + tcp_output(pcb); + return; + } + return; +} + + + +void tcp_seg_free(tcp_seg *seg) + +{ + if (seg == (tcp_seg *)0x0) { + return; + } + if (seg->p != (pbuf *)0x0) { + pbuf_free(seg->p); + } + memp_free(MEMP_TCP_SEG,seg); + return; +} + + + +void tcp_segs_free(tcp_seg *seg) + +{ + tcp_seg *ptVar1; + + if (seg != (tcp_seg *)0x0) { + do { + ptVar1 = seg->next; + tcp_seg_free(seg); + seg = ptVar1; + } while (ptVar1 != (tcp_seg *)0x0); + return; + } + return; +} + + + +void tcp_setprio(tcp_pcb *pcb,u8_t prio) + +{ + if (pcb != (tcp_pcb *)0x0) { + pcb->prio = prio; + } + return; +} + + + +tcp_seg * tcp_seg_copy(tcp_seg *seg) + +{ + tcp_seg *__dest; + + __dest = (tcp_seg *)memp_malloc(MEMP_TCP_SEG); + if (__dest != (tcp_seg *)0x0) { + memcpy(__dest,seg,0x14); + pbuf_ref(__dest->p); + } + return __dest; +} + + + +void tcp_arg(tcp_pcb *pcb,void *arg) + +{ + if (pcb != (tcp_pcb *)0x0) { + pcb->callback_arg = arg; + } + return; +} + + + +void tcp_recv(tcp_pcb *pcb,tcp_recv_fn *recv) + +{ + if (pcb != (tcp_pcb *)0x0) { + pcb->recv = recv; + } + return; +} + + + +void tcp_sent(tcp_pcb *pcb,tcp_sent_fn *sent) + +{ + if (pcb != (tcp_pcb *)0x0) { + pcb->sent = sent; + } + return; +} + + + +void tcp_err(tcp_pcb *pcb,tcp_err_fn *err) + +{ + if (pcb != (tcp_pcb *)0x0) { + pcb->errf = err; + } + return; +} + + + +void tcp_accept(tcp_pcb *pcb,tcp_accept_fn accept) + +{ + if ((pcb != (tcp_pcb *)0x0) && (pcb->state == LISTEN)) { + *(tcp_accept_fn *)&pcb->remote_port = accept; + } + return; +} + + + +void tcp_poll(tcp_pcb *pcb,tcp_poll_fn *poll,u8_t interval) + +{ + if (pcb != (tcp_pcb *)0x0) { + pcb->poll = poll; + pcb->pollinterval = interval; + } + return; +} + + + +u32_t tcp_next_iss(tcp_pcb *pcb) + +{ + u32_t iss; + + return iss + tcp_ticks; +} + + + +u16_t tcp_eff_send_mss_netif(u16_t sendmss,netif *outif,ip_addr_t *dest) + +{ + ushort uVar1; + u16_t uVar2; + undefined2 in_register_0000202a; + uint uVar3; + + uVar2 = sendmss; + if (outif != (netif *)0x0) { + uVar1 = outif->mtu; + if (((uVar1 != 0) && (uVar2 = 0, 0x28 < uVar1)) && + (uVar3 = (uint)uVar1 - 0x28 & 0xffff, uVar2 = (u16_t)uVar3, + CONCAT22(in_register_0000202a,sendmss) < uVar3)) { + uVar2 = sendmss; + } + } + return uVar2; +} + + + +err_t tcp_connect(tcp_pcb *pcb,ip_addr_t *ipaddr,u16_t port,tcp_connected_fn connected) + +{ + u16_t uVar1; + err_t eVar2; + u16_t uVar3; + netif *outif; + undefined2 extraout_var_00; + u32_t uVar4; + undefined3 extraout_var; + undefined2 in_register_00002032; + tcp_pcb *ptVar5; + tcp_pcb *ptVar6; + + eVar2 = -0x10; + if (((pcb != (tcp_pcb *)0x0) && (ipaddr != (ip_addr_t *)0x0)) && + (eVar2 = -10, pcb->state == CLOSED)) { + (pcb->remote_ip).addr = ipaddr->addr; + pcb->remote_port = port; + if (pcb->netif_idx == '\0') { + outif = ip4_route((ip4_addr_t *)&pcb->remote_ip); + } + else { + outif = netif_get_by_index(pcb->netif_idx); + } + eVar2 = -4; + if (outif != (netif *)0x0) { + if ((pcb->local_ip).addr == 0) { + (pcb->local_ip).addr = (outif->ip_addr).addr; + } + uVar1 = pcb->local_port; + if (uVar1 == 0) { + uVar3 = tcp_new_port(); + pcb->local_port = uVar3; + if (CONCAT22(extraout_var_00,uVar3) == 0) { + return -2; + } + } + else { + ptVar5 = tcp_active_pcbs; + if ((pcb->so_options & 4) != 0) { + while (ptVar6 = tcp_tw_pcbs, ptVar5 != (tcp_pcb *)0x0) { + if (((ptVar5->local_port == uVar1) && + ((uint)ptVar5->remote_port == CONCAT22(in_register_00002032,port))) && + (((ptVar5->local_ip).addr == (pcb->local_ip).addr && + ((ptVar5->remote_ip).addr == ipaddr->addr)))) { + return -8; + } + ptVar5 = ptVar5->next; + } + while (ptVar6 != (tcp_pcb *)0x0) { + if (((ptVar6->local_port == uVar1) && + ((uint)ptVar6->remote_port == CONCAT22(in_register_00002032,port))) && + (((ptVar6->local_ip).addr == (pcb->local_ip).addr && + ((ptVar6->remote_ip).addr == ipaddr->addr)))) { + return -8; + } + ptVar6 = ptVar6->next; + } + } + } + uVar4 = tcp_next_iss(pcb); + *(undefined4 *)&pcb->rcv_wnd = 0x8100810; + pcb->snd_nxt = uVar4; + pcb->snd_wnd = 0x810; + uVar4 = uVar4 - 1; + pcb->lastack = uVar4; + pcb->snd_wl2 = uVar4; + pcb->snd_lbb = uVar4; + pcb->mss = 0x218; + pcb->rcv_nxt = 0; + pcb->rcv_ann_right_edge = 0; + uVar3 = tcp_eff_send_mss_netif(0x218,outif,&pcb->remote_ip); + pcb->mss = uVar3; + pcb->cwnd = 1; + pcb->connected = connected; + eVar2 = tcp_enqueue_flags(pcb,'\x02'); + if (CONCAT31(extraout_var,eVar2) == 0) { + pcb->state = SYN_SENT; + if (uVar1 != 0) { + ptVar5 = tcp_bound_pcbs; + if (tcp_bound_pcbs == pcb) { + tcp_bound_pcbs = pcb->next; + } + else { + do { + ptVar6 = ptVar5; + if (ptVar6 == (tcp_pcb *)0x0) goto LAB_23071102; + ptVar5 = ptVar6->next; + } while (ptVar6->next != pcb); + ptVar6->next = pcb->next; + } + } +LAB_23071102: + ptVar5 = pcb; + pcb->next = tcp_active_pcbs; + tcp_active_pcbs = ptVar5; + tcp_timer_needed(); + tcp_active_pcbs_changed = '\x01'; + tcp_output(pcb); + } + } + } + return eVar2; +} + + + +err_t tcp_tcp_get_tcp_addrinfo(tcp_pcb *pcb,int local,ip_addr_t *addr,u16_t *port) + +{ + u16_t uVar1; + + if (pcb == (tcp_pcb *)0x0) { + return -6; + } + if (local == 0) { + if (addr != (ip_addr_t *)0x0) { + addr->addr = (pcb->remote_ip).addr; + } + if (port == (u16_t *)0x0) { + return '\0'; + } + uVar1 = pcb->remote_port; + } + else { + if (addr != (ip_addr_t *)0x0) { + addr->addr = (pcb->local_ip).addr; + } + if (port == (u16_t *)0x0) { + return '\0'; + } + uVar1 = pcb->local_port; + } + *port = uVar1; + return '\0'; +} + + + +void tcp_free_ooseq(tcp_pcb *pcb) + +{ + if (pcb->ooseq != (tcp_seg *)0x0) { + tcp_segs_free(pcb->ooseq); + pcb->ooseq = (tcp_seg *)0x0; + return; + } + return; +} + + + +void tcp_pcb_purge(tcp_pcb *pcb) + +{ + if (((pcb != (tcp_pcb *)0x0) && (LISTEN < pcb->state)) && (pcb->state != TIME_WAIT)) { + if (pcb->refused_data != (pbuf *)0x0) { + pbuf_free(pcb->refused_data); + pcb->refused_data = (pbuf *)0x0; + } + if (pcb->ooseq != (tcp_seg *)0x0) { + tcp_free_ooseq(pcb); + } + pcb->rtime = -1; + tcp_segs_free(pcb->unsent); + tcp_segs_free(pcb->unacked); + pcb->unsent = (tcp_seg *)0x0; + pcb->unacked = (tcp_seg *)0x0; + pcb->unsent_oversize = 0; + return; + } + return; +} + + + +void tcp_pcb_remove(tcp_pcb **pcblist,tcp_pcb *pcb) + +{ + tcp_pcb *ptVar1; + tcp_pcb *ptVar2; + + ptVar1 = *pcblist; + if (*pcblist == pcb) { + *pcblist = pcb->next; + } + else { + do { + ptVar2 = ptVar1; + if (ptVar2 == (tcp_pcb *)0x0) goto LAB_23071212; + ptVar1 = ptVar2->next; + } while (ptVar2->next != pcb); + ptVar2->next = pcb->next; + } +LAB_23071212: + pcb->next = (tcp_pcb *)0x0; + tcp_pcb_purge(pcb); + if (((pcb->state != TIME_WAIT) && (pcb->state != LISTEN)) && ((pcb->flags & 1) != 0)) { + pcb->flags = pcb->flags | 2; + tcp_output(pcb); + } + pcb->state = CLOSED; + pcb->local_port = 0; + return; +} + + + +void tcp_abandon(tcp_pcb *pcb,int reset) + +{ + tcp_pcb *ptVar1; + u16_t uVar2; + tcp_pcb *ptVar3; + tcp_err_fn *UNRECOVERED_JUMPTABLE; + void *pvVar4; + u32_t seqno; + u32_t ackno; + + if (pcb == (tcp_pcb *)0x0) { + return; + } + if (pcb->state == TIME_WAIT) { + tcp_pcb_remove(&tcp_tw_pcbs,pcb); + tcp_free(pcb); + return; + } + seqno = pcb->snd_nxt; + ackno = pcb->rcv_nxt; + UNRECOVERED_JUMPTABLE = pcb->errf; + pvVar4 = pcb->callback_arg; + uVar2 = pcb->local_port; + if (pcb->state == CLOSED) { + reset = 0; + if (uVar2 != 0) { + ptVar1 = tcp_bound_pcbs; + if (tcp_bound_pcbs == pcb) { + tcp_bound_pcbs = pcb->next; + } + else { + do { + ptVar3 = ptVar1; + if (ptVar3 == (tcp_pcb *)0x0) goto LAB_230712d8; + ptVar1 = ptVar3->next; + } while (ptVar3->next != pcb); + ptVar3->next = pcb->next; + } +LAB_230712d8: + pcb->next = (tcp_pcb *)0x0; + uVar2 = 0; + reset = 0; + } + } + else { + tcp_pcb_remove(&tcp_active_pcbs,pcb); + tcp_active_pcbs_changed = '\x01'; + } + if (pcb->unacked != (tcp_seg *)0x0) { + tcp_segs_free(pcb->unacked); + } + if (pcb->unsent != (tcp_seg *)0x0) { + tcp_segs_free(pcb->unsent); + } + if (pcb->ooseq != (tcp_seg *)0x0) { + tcp_segs_free(pcb->ooseq); + } + if (reset != 0) { + tcp_rst(pcb,seqno,ackno,(ip_addr_t *)pcb,&pcb->remote_ip,uVar2,pcb->remote_port); + } + tcp_free(pcb); + if (UNRECOVERED_JUMPTABLE == (tcp_err_fn *)0x0) { + return; + } + // WARNING: Could not recover jumptable at 0x23071334. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(pvVar4,-0xd); + return; +} + + + +void tcp_abort(tcp_pcb *pcb) + +{ + tcp_abandon(pcb,1); + return; +} + + + +err_t tcp_accept_null(void *arg,tcp_pcb *pcb,err_t err) + +{ + tcp_abort(pcb); + return -0xd; +} + + + +void tcp_netif_ip_addr_changed_pcblist(tcp_pcb *pcb_list) + +{ + tcp_pcb *in_a1; + tcp_pcb *pcb; + + while (pcb = in_a1, pcb != (tcp_pcb *)0x0) { + in_a1 = pcb->next; + if ((pcb->local_ip).addr == (pcb_list->local_ip).addr) { + tcp_abort(pcb); + } + } + return; +} + + + +void tcp_netif_ip_addr_changed(ip_addr_t *old_addr,ip_addr_t *new_addr) + +{ + u32_t *puVar1; + + if (old_addr == (ip_addr_t *)0x0) { + return; + } + if (old_addr->addr != 0) { + tcp_netif_ip_addr_changed_pcblist((tcp_pcb *)old_addr); + tcp_netif_ip_addr_changed_pcblist((tcp_pcb *)old_addr); + if ((new_addr != (ip_addr_t *)0x0) && (puVar1 = tcp_listen_pcbs, new_addr->addr != 0)) { + while (puVar1 != (u32_t *)0x0) { + if (*puVar1 == old_addr->addr) { + *puVar1 = new_addr->addr; + } + puVar1 = (u32_t *)puVar1[3]; + } + } + } + return; +} + + + +void tcp_kill_state(tcp_state state) + +{ + undefined3 in_register_00002029; + uint uVar1; + tcp_pcb *pcb; + uint uVar2; + tcp_pcb *ptVar3; + + uVar1 = 0; + pcb = (tcp_pcb *)0x0; + ptVar3 = tcp_active_pcbs; + while (ptVar3 != (tcp_pcb *)0x0) { + if (((uint)ptVar3->state == CONCAT31(in_register_00002029,state)) && + (uVar2 = tcp_ticks - ptVar3->tmr, uVar1 <= uVar2)) { + uVar1 = uVar2; + pcb = ptVar3; + } + ptVar3 = ptVar3->next; + } + if (pcb != (tcp_pcb *)0x0) { + tcp_abandon(pcb,0); + return; + } + return; +} + + + +tcp_pcb * tcp_alloc(u8_t prio) + +{ + u32_t uVar1; + tcp_pcb *pcb; + undefined3 in_register_00002029; + uint uVar2; + uint uVar3; + uint uVar4; + tcp_pcb *ptVar5; + int iVar6; + + iVar6 = CONCAT31(in_register_00002029,prio); + pcb = (tcp_pcb *)memp_malloc(MEMP_TCP_PCB); + ptVar5 = tcp_active_pcbs; + if (pcb != (tcp_pcb *)0x0) goto LAB_2307151a; + while (pcb = ptVar5, pcb != (tcp_pcb *)0x0) { + ptVar5 = pcb->next; + if ((pcb->flags & 8) != 0) { + pcb->flags = pcb->flags & 0xfff7; + tcp_close_shutdown_fin(pcb); + } + } + uVar3 = 0; + ptVar5 = tcp_tw_pcbs; + while (ptVar5 != (tcp_pcb *)0x0) { + uVar4 = tcp_ticks - ptVar5->tmr; + if (uVar3 <= uVar4) { + pcb = ptVar5; + uVar3 = uVar4; + } + ptVar5 = ptVar5->next; + } + if (pcb != (tcp_pcb *)0x0) { + tcp_abort(pcb); + } + pcb = (tcp_pcb *)memp_malloc(MEMP_TCP_PCB); + if (pcb == (tcp_pcb *)0x0) { + tcp_kill_state(LAST_ACK); + pcb = (tcp_pcb *)memp_malloc(MEMP_TCP_PCB); + if (pcb == (tcp_pcb *)0x0) { + tcp_kill_state(CLOSING); + pcb = (tcp_pcb *)memp_malloc(MEMP_TCP_PCB); + if (pcb == (tcp_pcb *)0x0) { + if ((char)prio < '\0') { + iVar6 = 0x7f; +LAB_230715dc: + uVar3 = iVar6 - 1U & 0xff; + uVar4 = 0; + ptVar5 = tcp_active_pcbs; + while (ptVar5 != (tcp_pcb *)0x0) { + uVar2 = (uint)ptVar5->prio; + if ((uVar2 < uVar3) || ((uVar2 == uVar3 && (uVar4 <= tcp_ticks - ptVar5->tmr)))) { + uVar4 = tcp_ticks - ptVar5->tmr; + pcb = ptVar5; + uVar3 = uVar2; + } + ptVar5 = ptVar5->next; + } + if (pcb != (tcp_pcb *)0x0) { + tcp_abort(pcb); + } + } + else { + if (iVar6 != 0) goto LAB_230715dc; + } + pcb = (tcp_pcb *)memp_malloc(MEMP_TCP_PCB); + if (pcb == (tcp_pcb *)0x0) { + return (tcp_pcb *)0x0; + } + lwip_stats.memp[2]->err = lwip_stats.memp[2]->err - 1; + } + lwip_stats.memp[2]->err = lwip_stats.memp[2]->err - 1; + } + lwip_stats.memp[2]->err = lwip_stats.memp[2]->err - 1; + } + lwip_stats.memp[2]->err = lwip_stats.memp[2]->err - 1; +LAB_2307151a: + memset(pcb,0,0xa4); + pcb->snd_buf = 0x1580; + *(undefined4 *)&pcb->rcv_wnd = 0x8100810; + pcb->ttl = -1; + pcb->rto = 6; + pcb->sv = 6; + *(undefined4 *)&pcb->rtime = 0x218ffff; + uVar1 = tcp_ticks; + pcb->prio = prio; + pcb->tmr = uVar1; + pcb->last_timer = tcp_timer_ctr; + *(undefined4 *)&pcb->cwnd = 0x15800001; + pcb->recv = tcp_recv_null; + pcb->keep_idle = 7200000; + pcb->keep_intvl = 75000; + pcb->keep_cnt = 9; + return pcb; +} + + + +tcp_pcb * tcp_new_ip_type(u8_t type) + +{ + tcp_pcb *ptVar1; + + ptVar1 = tcp_alloc('@'); + return ptVar1; +} + + + +err_t tcp_close_shutdown(tcp_pcb *pcb,u8_t rst_on_unacked_data) + +{ + tcp_state tVar1; + err_t eVar2; + undefined3 in_register_0000202d; + tcp_pcb *ptVar3; + tcp_pcb *ptVar4; + tcp_pcb ***ppptVar5; + + tVar1 = pcb->state; + if (((CONCAT31(in_register_0000202d,rst_on_unacked_data) == 0) || + ((tVar1 != ESTABLISHED && (tVar1 != CLOSE_WAIT)))) || + ((pcb->refused_data == (pbuf *)0x0 && (pcb->rcv_wnd == 0x810)))) { + if (tVar1 == LISTEN) { + ppptVar5 = tcp_pcb_lists; + do { + ptVar3 = *ppptVar5[1]; + while (ptVar3 != (tcp_pcb *)0x0) { + if (pcb == (tcp_pcb *)ptVar3->listener) { + ptVar3->listener = (tcp_pcb_listen *)0x0; + } + ptVar3 = ptVar3->next; + } + ppptVar5 = ppptVar5 + 1; + } while (ppptVar5 != (tcp_pcb ***)0x230c3770); + tcp_pcb_remove((tcp_pcb **)&tcp_listen_pcbs,pcb); + memp_free(MEMP_TCP_PCB_LISTEN,pcb); + return '\0'; + } + if (tVar1 == CLOSED) { + if (pcb->local_port != 0) { + ptVar3 = tcp_bound_pcbs; + if (tcp_bound_pcbs == pcb) { + tcp_bound_pcbs = pcb->next; + } + else { + do { + ptVar4 = ptVar3; + if (ptVar4 == (tcp_pcb *)0x0) goto LAB_230716f2; + ptVar3 = ptVar4->next; + } while (ptVar4->next != pcb); + ptVar4->next = pcb->next; + } +LAB_230716f2: + pcb->next = (tcp_pcb *)0x0; + } + } + else { + if (tVar1 != SYN_SENT) { + eVar2 = tcp_close_shutdown_fin(pcb); + return eVar2; + } + tcp_pcb_remove(&tcp_active_pcbs,pcb); + tcp_active_pcbs_changed = '\x01'; + } + } + else { + tcp_rst(pcb,pcb->snd_nxt,pcb->rcv_nxt,(ip_addr_t *)pcb,&pcb->remote_ip,pcb->local_port, + pcb->remote_port); + tcp_pcb_purge(pcb); + ptVar3 = tcp_active_pcbs; + if (tcp_active_pcbs == pcb) { + tcp_active_pcbs = pcb->next; + } + else { + do { + ptVar4 = ptVar3; + if (ptVar4 == (tcp_pcb *)0x0) goto LAB_23071684; + ptVar3 = ptVar4->next; + } while (ptVar4->next != pcb); + ptVar4->next = pcb->next; + } +LAB_23071684: + ptVar3 = tcp_input_pcb; + tcp_active_pcbs_changed = '\x01'; + pcb->next = (tcp_pcb *)0x0; + if (ptVar3 == pcb) { + tcp_trigger_input_pcb_close(); + return '\0'; + } + } + tcp_free(pcb); + return '\0'; +} + + + +err_t tcp_close(tcp_pcb *pcb) + +{ + err_t eVar1; + + if (pcb != (tcp_pcb *)0x0) { + if (pcb->state != LISTEN) { + pcb->flags = pcb->flags | 0x10; + } + eVar1 = tcp_close_shutdown(pcb,'\x01'); + return eVar1; + } + return -0x10; +} + + + +err_t tcp_recv_null(void *arg,tcp_pcb *pcb,pbuf *p,err_t err) + +{ + err_t eVar1; + undefined3 in_register_00002035; + + if (pcb == (tcp_pcb *)0x0) { + return -0x10; + } + if (p != (pbuf *)0x0) { + tcp_recved(pcb,p->tot_len); + pbuf_free(p); + return '\0'; + } + if (CONCAT31(in_register_00002035,err) == 0) { + eVar1 = tcp_close(pcb); + return eVar1; + } + return '\0'; +} + + + +err_t tcp_process_refused_data(tcp_pcb *pcb) + +{ + byte bVar1; + err_t eVar2; + err_t eVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + pbuf *p; + + if (pcb == (tcp_pcb *)0x0) { + return -0x10; + } + p = pcb->refused_data; + bVar1 = p->flags; + pcb->refused_data = (pbuf *)0x0; + if (pcb->recv == (tcp_recv_fn *)0x0) { + eVar2 = tcp_recv_null((void *)0x0,pcb,p,'\0'); + _eVar2 = CONCAT31(extraout_var_01,eVar2); + } + else { + eVar2 = (*pcb->recv)(pcb->callback_arg,pcb,p,'\0'); + _eVar2 = CONCAT31(extraout_var,eVar2); + } + eVar2 = (err_t)_eVar2; + if (_eVar2 == 0) { + if ((bVar1 & 0x20) == 0) { + return eVar2; + } + if (pcb->rcv_wnd != 0x810) { + pcb->rcv_wnd = pcb->rcv_wnd + 1; + } + if (pcb->recv == (tcp_recv_fn *)0x0) { + return eVar2; + } + eVar3 = (*pcb->recv)(pcb->callback_arg,pcb,(pbuf *)0x0,'\0'); + if (CONCAT31(extraout_var_00,eVar3) != -0xd) { + return eVar2; + } + } + else { + if (_eVar2 != -0xd) { + pcb->refused_data = p; + return -5; + } + } + return -0xd; +} + + + +void tcp_fasttmr(void) + +{ + tcp_pcb *pcb; + tcp_pcb *ptVar1; + + tcp_timer_ctr = tcp_timer_ctr + '\x01'; + pcb = tcp_active_pcbs; + while( true ) { + if (pcb == (tcp_pcb *)0x0) { + return; + } + if (pcb->last_timer == tcp_timer_ctr) break; + pcb->last_timer = tcp_timer_ctr; + if ((pcb->flags & 1) != 0) { + pcb->flags = pcb->flags | 2; + tcp_output(pcb); + pcb->flags = pcb->flags & 0xfffc; + } + if ((pcb->flags & 8) != 0) { + pcb->flags = pcb->flags & 0xfff7; + tcp_close_shutdown_fin(pcb); + } + ptVar1 = pcb->next; + if (pcb->refused_data == (pbuf *)0x0) goto LAB_230718e8; + tcp_active_pcbs_changed = '\0'; + tcp_process_refused_data(pcb); + pcb = tcp_active_pcbs; + if (tcp_active_pcbs_changed == '\0') { +LAB_230718e8: + pcb = ptVar1; + } + } + ptVar1 = pcb->next; + goto LAB_230718e8; +} + + + +err_t tcp_shutdown(tcp_pcb *pcb,int shut_rx,int shut_tx) + +{ + tcp_state tVar1; + err_t eVar2; + u8_t rst_on_unacked_data; + + rst_on_unacked_data = (u8_t)shut_rx; + if (pcb == (tcp_pcb *)0x0) { + return -0x10; + } + tVar1 = pcb->state; + if (tVar1 == LISTEN) { +LAB_2307194e: + eVar2 = -0xb; + } + else { + if (shut_rx == 0) { + if (shut_tx != 0) { + if ((tVar1 < CLOSING) && ((1 << ((uint)tVar1 & 0x1f) & 0x98U) != 0)) goto LAB_23071940; + goto LAB_2307194e; + } + } + else { + rst_on_unacked_data = '\x01'; + pcb->flags = pcb->flags | 0x10; + if (shut_tx != 0) { +LAB_23071940: + eVar2 = tcp_close_shutdown(pcb,rst_on_unacked_data); + return eVar2; + } + if (pcb->refused_data != (pbuf *)0x0) { + pbuf_free(pcb->refused_data); + pcb->refused_data = (pbuf *)0x0; + } + } + eVar2 = '\0'; + } + return eVar2; +} + + + +void tcp_slowtmr(void) + +{ + tcp_state tVar1; + short sVar2; + tcp_pcb *pcb; + uint uVar3; + tcp_err_fn *ptVar4; + err_t eVar5; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + uint uVar6; + byte bVar7; + uint uVar8; + u32_t uVar9; + byte bVar10; + s16_t sVar11; + void *pvVar12; + tcp_pcb *ptVar13; + tcp_pcb *pcb_00; + + tcp_ticks = tcp_ticks + 1; + tcp_timer_ctr = tcp_timer_ctr + '\x01'; + do { + pcb_00 = tcp_active_pcbs; + ptVar13 = (tcp_pcb *)0x0; +LAB_230719b8: + do { + while( true ) { + pcb = pcb_00; + pcb_00 = tcp_tw_pcbs; + if (pcb == (tcp_pcb *)0x0) { + while (pcb_00 != (tcp_pcb *)0x0) { + if (tcp_ticks - pcb_00->tmr < 0xf1) { + pcb = pcb_00; + pcb_00 = pcb_00->next; + } + else { + tcp_pcb_purge(pcb_00); + ptVar13 = pcb_00->next; + if (pcb != (tcp_pcb *)0x0) { + pcb->next = pcb_00->next; + ptVar13 = tcp_tw_pcbs; + } + tcp_tw_pcbs = ptVar13; + ptVar13 = pcb_00->next; + tcp_free(pcb_00); + pcb_00 = ptVar13; + } + } + return; + } + if (pcb->last_timer != tcp_timer_ctr) break; + pcb_00 = pcb->next; + ptVar13 = pcb; + } + pcb->last_timer = tcp_timer_ctr; + if (pcb->state == SYN_SENT) { + bVar7 = 5; + } + else { + bVar7 = 0xb; + } + uVar3 = 1; + if (pcb->nrtx <= bVar7) { + uVar3 = (uint)pcb->persist_backoff; + if (pcb->persist_backoff == 0) { + sVar2 = pcb->rtime; + if (sVar2 < 0) { +LAB_23071c0e: + if (pcb->rtime < pcb->rto) goto LAB_23071a68; + } + else { + if (sVar2 != 0x7fff) { + pcb->rtime = sVar2 + 1; + goto LAB_23071c0e; + } + } + eVar5 = tcp_rexmit_rto_prepare(pcb); + if ((CONCAT31(extraout_var_02,eVar5) == 0) || + ((pcb->unacked == (tcp_seg *)0x0 && (pcb->unsent != (tcp_seg *)0x0)))) { + if (pcb->state != SYN_SENT) { + uVar6 = (uint)pcb->nrtx; + if (0xc < pcb->nrtx) { + uVar6 = 0xc; + } + _sVar11 = ((int)pcb->sa >> 3) + (int)pcb->sv << + ((uint)"\x01\x02\x03\x04\x05\x06\a\a\a\a\a\a\a"[uVar6] & 0x1f); + sVar11 = (s16_t)_sVar11; + if (0x7ffe < _sVar11) { + sVar11 = 0x7fff; + } + pcb->rto = sVar11; + } + pcb->rtime = 0; + uVar6 = (uint)pcb->snd_wnd; + if ((uint)pcb->cwnd < (uint)pcb->snd_wnd) { + uVar6 = (uint)pcb->cwnd; + } + uVar8 = (uint)pcb->mss << 0x11; + pcb->ssthresh = (tcpwnd_size_t)(uVar6 >> 1); + if (uVar6 >> 1 < uVar8 >> 0x10) { + pcb->ssthresh = (tcpwnd_size_t)(uVar8 >> 0x10); + } + pcb->cwnd = pcb->mss; + pcb->bytes_acked = 0; + tcp_rexmit_rto_commit(pcb); + goto LAB_23071a6a; + } + } + else { + if (0xb < pcb->persist_probe) { + uVar3 = 1; + goto LAB_23071a6a; + } + bVar7 = *(byte *)((int)&ip_addr_broadcast.addr + uVar3 + 3); + if ((bVar7 <= pcb->persist_cnt) || + (bVar10 = pcb->persist_cnt + 1, pcb->persist_cnt = bVar10, bVar7 <= bVar10)) { + if (pcb->snd_wnd == 0) { + eVar5 = tcp_zero_window_probe(pcb); + if (CONCAT31(extraout_var_01,eVar5) == 0) goto LAB_23071b58; + } + else { + eVar5 = tcp_split_unsent_seg(pcb,pcb->snd_wnd); + if ((CONCAT31(extraout_var,eVar5) != 0) || + (eVar5 = tcp_output(pcb), CONCAT31(extraout_var_00,eVar5) != 0)) { +LAB_23071b58: + pcb->persist_cnt = '\0'; + if (pcb->persist_backoff < 7) { + pcb->persist_backoff = pcb->persist_backoff + 1; + } + } + } + } + } +LAB_23071a68: + uVar3 = 0; + } +LAB_23071a6a: + tVar1 = pcb->state; + if (((tVar1 == FIN_WAIT_2) && ((pcb->flags & 0x10) != 0)) && (0x28 < tcp_ticks - pcb->tmr)) { + uVar3 = uVar3 + 1 & 0xff; + } + bVar7 = pcb->so_options & 8; + if (((pcb->so_options & 8) != 0) && + ((tVar1 == ESTABLISHED || (bVar7 = 0, tVar1 == CLOSE_WAIT)))) { + uVar6 = tcp_ticks - pcb->tmr; + if ((pcb->keep_intvl * pcb->keep_cnt + pcb->keep_idle) / 500 < uVar6) { + uVar3 = uVar3 + 1 & 0xff; + bVar7 = 1; + } + else { + bVar7 = 0; + if ((((uint)pcb->keep_cnt_sent * pcb->keep_intvl + pcb->keep_idle) / 500 < uVar6) && + (eVar5 = tcp_keepalive(pcb), bVar7 = 0, CONCAT31(extraout_var_03,eVar5) == 0)) { + pcb->keep_cnt_sent = pcb->keep_cnt_sent + '\x01'; + } + } + } + if ((pcb->ooseq != (tcp_seg *)0x0) && ((uint)((int)pcb->rto * 6) <= tcp_ticks - pcb->tmr)) { + tcp_free_ooseq(pcb); + } + tVar1 = pcb->state; + if (tVar1 == SYN_RCVD) { + if (0x28 < tcp_ticks - pcb->tmr) { + uVar3 = uVar3 + 1 & 0xff; + } +LAB_23071b1a: + if (uVar3 == 0) { + pcb_00 = pcb->next; + bVar7 = pcb->polltmr + 1; + pcb->polltmr = bVar7; + ptVar13 = pcb; + if (pcb->pollinterval <= bVar7) { + pcb->polltmr = '\0'; + tcp_active_pcbs_changed = '\0'; + if (pcb->poll != (tcp_poll_fn *)0x0) { + eVar5 = (*pcb->poll)(pcb->callback_arg,pcb); + if (tcp_active_pcbs_changed != '\0') break; + if (CONCAT31(extraout_var_04,eVar5) != 0) goto LAB_230719b8; + } + tcp_output(pcb); + } + goto LAB_230719b8; + } + } + else { + if (tVar1 == LAST_ACK) { + uVar9 = pcb->tmr; + uVar6 = 0xf0; + } + else { + if ((tVar1 != FIN_WAIT_1) && (tVar1 != CLOSING)) goto LAB_23071b1a; + uVar9 = pcb->tmr; + uVar6 = 10; + } + if (tcp_ticks - uVar9 <= uVar6) goto LAB_23071b1a; + } + ptVar4 = pcb->errf; + tcp_pcb_purge(pcb); + pcb_00 = pcb->next; + if (ptVar13 != (tcp_pcb *)0x0) { + ptVar13->next = pcb->next; + pcb_00 = tcp_active_pcbs; + } + tcp_active_pcbs = pcb_00; + if (bVar7 != 0) { + tcp_rst(pcb,pcb->snd_nxt,pcb->rcv_nxt,(ip_addr_t *)pcb,&pcb->remote_ip,pcb->local_port, + pcb->remote_port); + } + pvVar12 = pcb->callback_arg; + pcb_00 = pcb->next; + tcp_free(pcb); + tcp_active_pcbs_changed = '\0'; + } while ((ptVar4 == (tcp_err_fn *)0x0) || + ((*ptVar4)(pvVar12,-0xd), tcp_active_pcbs_changed == '\0')); + } while( true ); +} + + + +void tcp_tmr(void) + +{ + tcp_fasttmr(); + tcp_timer = tcp_timer + 1; + if ((tcp_timer & 1) != 0) { + tcp_slowtmr(); + return; + } + return; +} + + + +u8_t tcp_get_next_optbyte(void) + +{ + uint uVar1; + + uVar1 = (uint)tcp_optidx; + if ((tcphdr_opt2 != (u8_t *)0x0) && (tcphdr_opt1len <= uVar1)) { + tcp_optidx = tcp_optidx + 1; + return tcphdr_opt2[uVar1 - tcphdr_opt1len & 0xff]; + } + tcp_optidx = tcp_optidx + 1; + return *(u8_t *)((int)&tcphdr[1].src + uVar1); +} + + + +void tcp_oos_insert_segment(tcp_seg *cseg,tcp_seg *next) + +{ + u32_t uVar1; + ushort uVar2; + tcp_seg *ptVar3; + u16_t new_len; + int iVar4; + tcp_hdr *ptVar5; + + new_len = lwip_htons(cseg->tcphdr->_hdrlen_rsvd_flags); + if ((new_len & 1) == 0) { + do { + iVar4 = cseg->len + seqno; + uVar1 = next->tcphdr->seqno; + if ((int)(iVar4 - (next->len + uVar1)) < 0) { + if (0 < (int)(iVar4 - uVar1)) { + new_len = (u16_t)((uVar1 - seqno) * 0x10000 >> 0x10); + cseg->len = new_len; + pbuf_realloc(cseg->p,new_len); + } + goto LAB_23071e0c; + } + new_len = lwip_htons(next->tcphdr->_hdrlen_rsvd_flags); + if ((new_len & 1) != 0) { + uVar2 = cseg->tcphdr->_hdrlen_rsvd_flags; + new_len = lwip_htons(1); + ptVar5 = cseg->tcphdr; + uVar2 = new_len | uVar2; + *(char *)&ptVar5->_hdrlen_rsvd_flags = (char)uVar2; + *(undefined *)((int)&ptVar5->_hdrlen_rsvd_flags + 1) = (char)((uint)uVar2 >> 8); + } + ptVar3 = next->next; + tcp_seg_free(next); + next = ptVar3; + } while (ptVar3 != (tcp_seg *)0x0); + } + else { + tcp_segs_free(next); + } + next = (tcp_seg *)0x0; +LAB_23071e0c: + cseg->next = next; + return; +} + + + +void tcp_parseopt(undefined2 *param_1) + +{ + uint uVar1; + u8_t uVar2; + byte bVar3; + undefined2 uVar4; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + + tcp_optidx = 0; + while( true ) { + while( true ) { + do { + uVar1 = (uint)tcphdr_optlen; + if (uVar1 <= tcp_optidx) { + return; + } + uVar2 = tcp_get_next_optbyte(); + } while (CONCAT31(extraout_var,uVar2) == 1); + if (uVar2 == '\0') { + return; + } + if (CONCAT31(extraout_var,uVar2) == 2) break; + uVar2 = tcp_get_next_optbyte(); + if (CONCAT31(extraout_var_02,uVar2) < 2) { + return; + } + tcp_optidx = (tcp_optidx - 2) + (short)CONCAT31(extraout_var_02,uVar2); + } + uVar2 = tcp_get_next_optbyte(); + if (CONCAT31(extraout_var_00,uVar2) != 4) { + return; + } + if (uVar1 <= (uint)tcp_optidx + 1) break; + bVar3 = tcp_get_next_optbyte(); + uVar2 = tcp_get_next_optbyte(); + uVar1 = CONCAT31(extraout_var_01,uVar2) & 0xffff | ((uint)bVar3 << 0x18) >> 0x10; + uVar4 = (undefined2)uVar1; + if (0x2af < (uVar1 - 1 & 0xffff)) { + uVar4 = 0x2b0; + } + *param_1 = uVar4; + } + return; +} + + + +int tcp_input_delayed_close(tcp_pcb *pcb) + +{ + if ((recv_flags & 0x10) != 0) { + if (((pcb->flags & 0x10) == 0) && (pcb->errf != (tcp_err_fn *)0x0)) { + (*pcb->errf)(pcb->callback_arg,-0xf); + } + tcp_pcb_remove(&tcp_active_pcbs,pcb); + tcp_free(pcb); + return 1; + } + return 0; +} + + + +tcp_seg * tcp_free_acked_segments(tcp_seg *seg_list) + +{ + ushort uVar1; + tcp_seg *ptVar2; + u16_t uVar3; + u32_t uVar4; + tcp_seg *in_a1; + + while( true ) { + if (in_a1 == (tcp_seg *)0x0) { + return (tcp_seg *)0x0; + } + uVar4 = lwip_htonl(in_a1->tcphdr->seqno); + uVar1 = in_a1->len; + uVar3 = lwip_htons(in_a1->tcphdr->_hdrlen_rsvd_flags); + if (0 < (int)((uVar1 - ackno) + uVar4 + (uint)((uVar3 & 3) != 0))) break; + ptVar2 = in_a1->next; + uVar3 = pbuf_clen(in_a1->p); + *(u16_t *)&seg_list->next = *(short *)&seg_list->next - uVar3; + recv_acked = in_a1->len + recv_acked; + tcp_seg_free(in_a1); + in_a1 = ptVar2; + } + return in_a1; +} + + + +void tcp_receive(tcp_pcb *pcb) + +{ + ushort n; + ushort uVar1; + short sVar2; + tcp_seg *cseg; + tcp_seg *next; + u16_t new_len; + u16_t uVar3; + int iVar4; + u32_t uVar5; + pbuf *p; + u32_t uVar6; + uint header_size_decrement; + u32_t uVar7; + uint uVar8; + tcp_hdr *ptVar9; + tcpwnd_size_t tVar10; + short sVar11; + tcpflags_t tVar12; + uint uVar13; + uint uVar14; + tcp_seg *ptVar15; + + uVar5 = seqno; + uVar7 = ackno; + if ((flags & 0x10) != 0) { + n = pcb->snd_wnd; + uVar6 = pcb->snd_wl2; + if ((((int)(pcb->snd_wl1 - seqno) < 0) || + ((pcb->snd_wl1 == seqno && ((int)(uVar6 - ackno) < 0)))) || + ((uVar6 == ackno && ((uint)n < (uint)tcphdr->wnd)))) { + uVar1 = tcphdr->wnd; + pcb->snd_wnd = uVar1; + if (pcb->snd_wnd_max < uVar1) { + pcb->snd_wnd_max = uVar1; + } + pcb->snd_wl1 = uVar5; + pcb->snd_wl2 = uVar7; + } + uVar13 = uVar7 - pcb->lastack; + if ((int)uVar13 < 1) { + if ((((tcplen == 0) && ((uint)pcb->snd_wnd + pcb->snd_wl2 == (uint)n + uVar6)) && + (-1 < pcb->rtime)) && (pcb->lastack == uVar7)) { + if (pcb->dupacks != -1) { + pcb->dupacks = pcb->dupacks + '\x01'; + } + if (pcb->dupacks < 4) { + if (pcb->dupacks != 3) goto LAB_23072146; + } + else { + tVar10 = pcb->mss + pcb->cwnd; + if (tVar10 < pcb->cwnd) { + tVar10 = 0xffff; + } + pcb->cwnd = tVar10; + } + tcp_rexmit_fast(pcb); + } + else { + pcb->dupacks = '\0'; + } + } + else { + if ((int)(uVar7 - pcb->snd_nxt) < 1) { + if ((pcb->flags & 4) != 0) { + pcb->flags = pcb->flags & 0xfffb; + pcb->bytes_acked = 0; + pcb->cwnd = pcb->ssthresh; + } + pcb->lastack = uVar7; + pcb->rto = (pcb->sa >> 3) + pcb->sv; + *(undefined2 *)&pcb->nrtx = 0; + if (SYN_RCVD < pcb->state) { + header_size_decrement = (uint)pcb->cwnd; + uVar13 = uVar13 & 0xffff; + if (header_size_decrement < pcb->ssthresh) { + uVar8 = ((uint)((pcb->flags & 0x800) == 0) + 1) * (uint)pcb->mss; + if (uVar13 < (uVar8 & 0xffff)) { + uVar8 = uVar13; + } + } + else { + uVar13 = uVar13 + pcb->bytes_acked; + uVar8 = uVar13 & 0xffff; + sVar11 = (short)uVar8; + if (uVar8 < pcb->bytes_acked) { + sVar11 = -1; + } + else { + if (uVar8 < header_size_decrement) { + pcb->bytes_acked = (tcpwnd_size_t)(uVar13 * 0x10000 >> 0x10); + goto LAB_230724a2; + } + } + pcb->bytes_acked = sVar11 - pcb->cwnd; + uVar8 = (uint)pcb->mss; + } + uVar13 = header_size_decrement + uVar8 & 0xffff; + tVar10 = (tcpwnd_size_t)uVar13; + if (uVar13 < header_size_decrement) { + tVar10 = 0xffff; + } + pcb->cwnd = tVar10; + } +LAB_230724a2: + cseg = tcp_free_acked_segments((tcp_seg *)&pcb->snd_queuelen); + pcb->unacked = cseg; + cseg = tcp_free_acked_segments((tcp_seg *)&pcb->snd_queuelen); + ptVar15 = pcb->unacked; + pcb->unsent = cseg; + pcb->polltmr = '\0'; + pcb->rtime = -(ushort)(ptVar15 == (tcp_seg *)0x0); + if (cseg == (tcp_seg *)0x0) { + pcb->unsent_oversize = 0; + } + pcb->snd_buf = pcb->snd_buf + recv_acked; + if ((int)((uint)pcb->flags << 0x14) < 0) { + if (ptVar15 == (tcp_seg *)0x0) { + if (cseg != (tcp_seg *)0x0) { + uVar7 = pcb->rto_end; + ptVar9 = cseg->tcphdr; + goto LAB_2307251e; + } + } + else { + uVar7 = pcb->rto_end; + ptVar9 = ptVar15->tcphdr; +LAB_2307251e: + uVar5 = lwip_htonl(ptVar9->seqno); + if (0 < (int)(uVar7 - uVar5)) goto LAB_23072146; + } + pcb->flags = pcb->flags & 0xf7ff; + } + } + else { + tcp_send_empty_ack(pcb); + } + } +LAB_23072146: + if ((pcb->rttest != 0) && ((int)(pcb->rtseq - ackno) < 0)) { + uVar8 = (uint)(ushort)tcp_ticks; + header_size_decrement = pcb->rttest & 0xffff; + uVar13 = (int)pcb->sa >> 3 & 0xffff; + uVar14 = (uVar8 - header_size_decrement) - uVar13 & 0xffff; + iVar4 = (int)(short)uVar14; + sVar11 = (short)((uVar14 + (int)pcb->sa) * 0x10000 >> 0x10); + pcb->sa = sVar11; + if (iVar4 < 0) { + iVar4 = (int)(((header_size_decrement - uVar8) + uVar13) * 0x10000) >> 0x10; + } + pcb->rttest = 0; + sVar2 = (short)((uint)((((int)pcb->sv - ((int)pcb->sv >> 2)) + iVar4) * 0x10000) >> 0x10); + pcb->sv = sVar2; + pcb->rto = (sVar11 >> 3) + sVar2; + } + } + uVar7 = pcb->rcv_nxt; + if ((tcplen == 0) || (FIN_WAIT_2 < pcb->state)) { + if ((-1 < (int)(seqno - uVar7)) && ((int)(((seqno + 1) - uVar7) - (uint)pcb->rcv_wnd) < 1)) { + return; + } + tVar12 = pcb->flags; + } + else { + uVar13 = uVar7 - seqno; + if (((int)(uVar13 - 1) < 0) || (0 < (int)(((1 - seqno) - (uint)tcplen) + uVar7))) { + if ((int)(seqno - uVar7) < 0) { + pcb->flags = pcb->flags | 2; + } + } + else { + header_size_decrement = uVar13 & 0xffff; + inseg.len = inseg.len - (short)(uVar13 * 0x10000 >> 0x10); + iVar4 = (inseg.p)->tot_len - header_size_decrement; + p = inseg.p; + while (n = p->len, n < header_size_decrement) { + p->tot_len = (u16_t)((uint)(iVar4 * 0x10000) >> 0x10); + p->len = 0; + header_size_decrement = header_size_decrement - n & 0xffff; + p = p->next; + } + pbuf_remove_header(p,header_size_decrement); + ptVar9 = inseg.tcphdr; + uVar7 = pcb->rcv_nxt; + seqno = uVar7; + *(char *)&(inseg.tcphdr)->seqno = (char)uVar7; + *(undefined *)((int)&ptVar9->seqno + 1) = (char)(uVar7 >> 8); + *(undefined *)((int)&ptVar9->seqno + 2) = (char)(uVar7 >> 0x10); + *(undefined *)((int)&ptVar9->seqno + 3) = (char)(uVar7 >> 0x18); + } + uVar7 = pcb->rcv_nxt; + if (((int)(seqno - uVar7) < 0) || (0 < (int)(((seqno + 1) - uVar7) - (uint)pcb->rcv_wnd))) { +LAB_230727a6: + tcp_send_empty_ack(pcb); + return; + } + if (seqno != uVar7) { + cseg = pcb->ooseq; + ptVar15 = (tcp_seg *)0x0; + if (pcb->ooseq == (tcp_seg *)0x0) { + cseg = tcp_seg_copy(&inseg); + pcb->ooseq = cseg; + } + else { + do { + next = cseg; + uVar7 = next->tcphdr->seqno; + if (seqno == uVar7) { + if ((next->len < inseg.len) && (cseg = tcp_seg_copy(&inseg), cseg != (tcp_seg *)0x0)) { + if (ptVar15 == (tcp_seg *)0x0) { + pcb->ooseq = cseg; + } + else { + ptVar15->next = cseg; + } +LAB_2307280c: + tcp_oos_insert_segment(cseg,next); + } + goto LAB_230727a6; + } + if (ptVar15 == (tcp_seg *)0x0) { + if ((int)(seqno - uVar7) < 0) { + cseg = tcp_seg_copy(&inseg); + if (cseg != (tcp_seg *)0x0) { + pcb->ooseq = cseg; + goto LAB_2307280c; + } + goto LAB_230727a6; + } + } + else { + if ((-1 < (int)((seqno - 1) - ptVar15->tcphdr->seqno)) && + ((int)((seqno + 1) - uVar7) < 1)) { + cseg = tcp_seg_copy(&inseg); + if (cseg != (tcp_seg *)0x0) { + uVar7 = ptVar15->tcphdr->seqno; + if (0 < (int)((ptVar15->len + uVar7) - seqno)) { + new_len = (u16_t)((seqno - uVar7) * 0x10000 >> 0x10); + ptVar15->len = new_len; + pbuf_realloc(ptVar15->p,new_len); + } + ptVar15->next = cseg; + goto LAB_2307280c; + } + goto LAB_230727a6; + } + } + cseg = next->next; + ptVar15 = next; + } while (next->next != (tcp_seg *)0x0); + if ((0 < (int)(seqno - uVar7)) && + (new_len = lwip_htons(next->tcphdr->_hdrlen_rsvd_flags), (new_len & 1) == 0)) { + cseg = tcp_seg_copy(&inseg); + next->next = cseg; + if (cseg != (tcp_seg *)0x0) { + uVar7 = next->tcphdr->seqno; + if (0 < (int)((next->len + uVar7) - seqno)) { + new_len = (u16_t)((seqno - uVar7) * 0x10000 >> 0x10); + next->len = new_len; + pbuf_realloc(next->p,new_len); + } + if (0 < (int)(((tcplen + seqno) - pcb->rcv_nxt) - (uint)pcb->rcv_wnd)) { + new_len = lwip_htons(next->next->tcphdr->_hdrlen_rsvd_flags); + if ((new_len & 1) != 0) { + n = next->next->tcphdr->_hdrlen_rsvd_flags; + new_len = lwip_htons(n); + new_len = lwip_htons(new_len & 0x3e); + ptVar9 = next->next->tcphdr; + uVar13 = (uint)n & 0xffffc0ff | (uint)new_len; + *(char *)&ptVar9->_hdrlen_rsvd_flags = (char)uVar13; + *(undefined *)((int)&ptVar9->_hdrlen_rsvd_flags + 1) = (char)(uVar13 >> 8); + } + next->next->len = (pcb->rcv_wnd - (short)seqno) + (short)pcb->rcv_nxt; + pbuf_realloc(next->next->p,next->next->len); + new_len = next->next->len; + uVar3 = lwip_htons(next->next->tcphdr->_hdrlen_rsvd_flags); + tcplen = new_len + ((uVar3 & 3) != 0); + } + } + } + } + goto LAB_230727a6; + } + uVar13 = (uint)inseg.len; + new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + uVar13 = ((new_len & 3) != 0) + uVar13; + tcplen = (u16_t)(uVar13 * 0x10000 >> 0x10); + if ((uint)pcb->rcv_wnd < (uVar13 & 0xffff)) { + new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + if ((new_len & 1) != 0) { + n = (inseg.tcphdr)->_hdrlen_rsvd_flags; + new_len = lwip_htons(n); + new_len = lwip_htons(new_len & 0x3e); + ptVar9 = inseg.tcphdr; + uVar13 = (uint)n & 0xffffc0ff | (uint)new_len; + *(char *)&(inseg.tcphdr)->_hdrlen_rsvd_flags = (char)uVar13; + *(undefined *)((int)&ptVar9->_hdrlen_rsvd_flags + 1) = (char)(uVar13 >> 8); + } + inseg.len = pcb->rcv_wnd; + new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + if ((new_len & 2) != 0) { + inseg.len = inseg.len - 1; + } + pbuf_realloc(inseg.p,inseg.len); + new_len = inseg.len; + uVar3 = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + tcplen = new_len + ((uVar3 & 3) != 0); + } + if (pcb->ooseq != (tcp_seg *)0x0) { + new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + if ((new_len & 1) == 0) { + cseg = pcb->ooseq; + while (cseg != (tcp_seg *)0x0) { + uVar7 = cseg->tcphdr->seqno; + if ((int)((tcplen + seqno) - (cseg->len + uVar7)) < 0) { + if (0 < (int)((tcplen + seqno) - uVar7)) { + inseg.len = (short)uVar7 - (short)seqno; + new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + if ((new_len & 2) != 0) { + inseg.len = inseg.len - 1; + } + pbuf_realloc(inseg.p,inseg.len); + new_len = inseg.len; + uVar3 = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + tcplen = new_len + ((uVar3 & 3) != 0); + } + break; + } + new_len = lwip_htons(cseg->tcphdr->_hdrlen_rsvd_flags); + if (((new_len & 1) != 0) && + (new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags), (new_len & 2) == 0)) { + n = (inseg.tcphdr)->_hdrlen_rsvd_flags; + new_len = lwip_htons(1); + ptVar9 = inseg.tcphdr; + n = n | new_len; + *(char *)&(inseg.tcphdr)->_hdrlen_rsvd_flags = (char)n; + *(undefined *)((int)&ptVar9->_hdrlen_rsvd_flags + 1) = (char)((uint)n >> 8); + new_len = inseg.len; + uVar3 = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + tcplen = new_len + ((uVar3 & 3) != 0); + } + ptVar15 = cseg->next; + tcp_seg_free(cseg); + cseg = ptVar15; + } + pcb->ooseq = cseg; + } + else { + while (cseg = pcb->ooseq, cseg != (tcp_seg *)0x0) { + pcb->ooseq = cseg->next; + tcp_seg_free(cseg); + } + } + } + tVar10 = pcb->rcv_wnd - tcplen; + pcb->rcv_nxt = seqno + tcplen; + pcb->rcv_wnd = tVar10; + tcp_update_rcv_ann_wnd(pcb); + if ((inseg.p)->tot_len != 0) { + recv_data = inseg.p; + inseg.p = (pbuf *)0x0; + } + new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + if ((new_len & 1) != 0) { + recv_flags = recv_flags | 0x20; + } + while (cseg = pcb->ooseq, cseg != (tcp_seg *)0x0) { + uVar7 = cseg->tcphdr->seqno; + if (uVar7 != pcb->rcv_nxt) break; + n = cseg->len; + seqno = uVar7; + new_len = lwip_htons(cseg->tcphdr->_hdrlen_rsvd_flags); + pcb->rcv_nxt = (uint)((new_len & 3) != 0) + (uint)n + pcb->rcv_nxt; + lwip_htons(cseg->tcphdr->_hdrlen_rsvd_flags); + new_len = cseg->len; + uVar3 = lwip_htons(cseg->tcphdr->_hdrlen_rsvd_flags); + pcb->rcv_wnd = pcb->rcv_wnd - (((uVar3 & 3) != 0) + new_len); + tcp_update_rcv_ann_wnd(pcb); + p = cseg->p; + if (p->tot_len != 0) { + if (recv_data != (pbuf *)0x0) { + pbuf_cat(recv_data,p); + p = recv_data; + } + recv_data = p; + cseg->p = (pbuf *)0x0; + } + new_len = lwip_htons(cseg->tcphdr->_hdrlen_rsvd_flags); + if (((new_len & 1) != 0) && (recv_flags = recv_flags | 0x20, pcb->state == ESTABLISHED)) { + pcb->state = CLOSE_WAIT; + } + pcb->ooseq = cseg->next; + tcp_seg_free(cseg); + } + n = pcb->flags; + if ((n & 1) == 0) { + tVar12 = n | 1; + goto LAB_23072774; + } + tVar12 = n & 0xfffe; + } + tVar12 = tVar12 | 2; +LAB_23072774: + pcb->flags = tVar12; + return; +} + + + +// WARNING: Restarted to delay deadcode elimination for space: ram + +void tcp_input(pbuf *p,netif *inp) + +{ + ushort uVar1; + u16_t uVar2; + byte bVar3; + tcp_hdr *ptVar4; + tcp_hdr *ptVar5; + tcp_pcb *ptVar6; + u8_t uVar7; + err_t eVar8; + u16_t sendmss; + tcpwnd_size_t tVar9; + undefined3 extraout_var; + undefined2 extraout_var_08; + undefined2 extraout_var_09; + undefined3 extraout_var_00; + tcp_pcb *pcb; + u32_t uVar10; + netif *outif; + undefined3 extraout_var_01; + undefined2 extraout_var_10; + tcp_seg *seg; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + undefined3 extraout_var_05; + undefined3 extraout_var_06; + undefined3 extraout_var_07; + uint header_size_decrement; + u32_t ackno; + int iVar11; + tcp_state tVar12; + u16_t uVar13; + tcpflags_t tVar14; + uint uVar15; + void *pvVar16; + tcp_accept_fn paVar17; + uint uVar18; + tcp_pcb *ptVar19; + pbuf *p_00; + u16_t remote_port; + tcp_pcb *ptVar20; + tcp_pcb *pcb_00; + + lwip_stats.tcp.recv = lwip_stats.tcp.recv + 1; + tcphdr = (tcp_hdr *)p->payload; + if (p->len < 0x14) goto LAB_23072a4e; + uVar7 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_dest,ip_data.current_netif); + if ((CONCAT31(extraout_var,uVar7) == 0) && ((ip_data.current_iphdr_dest & 0xf0) != 0xe0)) { + sendmss = ip_chksum_pseudo(p,'\x06',p->tot_len,(ip4_addr_t *)&ip_data.current_iphdr_src, + (ip4_addr_t *)&ip_data.current_iphdr_dest); + if (CONCAT22(extraout_var_08,sendmss) == 0) { + sendmss = lwip_htons(tcphdr->_hdrlen_rsvd_flags); + header_size_decrement = CONCAT22(extraout_var_09,sendmss) >> 10 & 0xfc; + if ((0x13 < header_size_decrement) && (header_size_decrement <= p->tot_len)) { + tcphdr_optlen = (u16_t)((header_size_decrement - 0x14) * 0x10000 >> 0x10); + tcphdr_opt2 = (u8_t *)0x0; + if (p->len < header_size_decrement) { + pbuf_remove_header(p,0x14); + sendmss = tcphdr_optlen; + uVar1 = p->len; + header_size_decrement = (uint)tcphdr_optlen; + tcphdr_opt1len = uVar1; + pbuf_remove_header(p,(uint)uVar1); + p_00 = p->next; + header_size_decrement = header_size_decrement - (uint)uVar1 & 0xffff; + if (p_00->len < header_size_decrement) goto LAB_23072a4e; + tcphdr_opt2 = (u8_t *)p_00->payload; + pbuf_remove_header(p_00,header_size_decrement); + p->tot_len = (uVar1 + p->tot_len) - sendmss; + } + else { + tcphdr_opt1len = tcphdr_optlen; + pbuf_remove_header(p,header_size_decrement); + } + ptVar4 = tcphdr; + sendmss = lwip_htons(tcphdr->src); + *(char *)&ptVar4->src = (char)sendmss; + *(undefined *)((int)&ptVar4->src + 1) = (char)(sendmss >> 8); + ptVar4 = tcphdr; + sendmss = lwip_htons(tcphdr->dest); + *(char *)&ptVar4->dest = (char)sendmss; + *(undefined *)((int)&ptVar4->dest + 1) = (char)(sendmss >> 8); + ptVar4 = tcphdr; + seqno = lwip_htonl(tcphdr->seqno); + *(undefined *)((int)&ptVar4->seqno + 1) = (char)(seqno >> 8); + *(undefined *)((int)&ptVar4->seqno + 2) = (char)(seqno >> 0x10); + *(char *)&ptVar4->seqno = (char)seqno; + *(undefined *)((int)&ptVar4->seqno + 3) = (char)(seqno >> 0x18); + ptVar4 = tcphdr; + ackno = lwip_htonl(tcphdr->ackno); + *(undefined *)((int)&ptVar4->ackno + 1) = (char)(ackno >> 8); + *(undefined *)((int)&ptVar4->ackno + 2) = (char)(ackno >> 0x10); + *(char *)&ptVar4->ackno = (char)ackno; + *(undefined *)((int)&ptVar4->ackno + 3) = (char)(ackno >> 0x18); + ptVar4 = tcphdr; + sendmss = lwip_htons(tcphdr->wnd); + ptVar5 = tcphdr; + *(char *)&ptVar4->wnd = (char)sendmss; + *(undefined *)((int)&ptVar4->wnd + 1) = (char)(sendmss >> 8); + sendmss = lwip_htons(ptVar5->_hdrlen_rsvd_flags); + ptVar19 = tcp_active_pcbs; + ptVar6 = tcp_listen_pcbs; + ptVar4 = tcphdr; + flags = (byte)sendmss & 0x3f; + tcplen = p->tot_len; + header_size_decrement = (uint)tcplen; + if (((sendmss & 3) == 0) || + (uVar15 = header_size_decrement + 1, tcplen = (u16_t)(uVar15 * 0x10000 >> 0x10), + header_size_decrement <= (uVar15 & 0xffff))) { + uVar2 = tcplen; + pcb = tcp_active_pcbs; + ptVar20 = (tcp_pcb *)0x0; +LAB_23072c90: + pcb_00 = pcb; + pcb = tcp_tw_pcbs; + if (pcb_00 == (tcp_pcb *)0x0) goto LAB_23072ef6; + if (((((pcb_00->netif_idx != '\0') && + (pcb_00->netif_idx != (u8_t)((ip_data.current_input_netif)->num + '\x01'))) || + (pcb_00->remote_port != tcphdr->src)) || + ((pcb_00->local_port != tcphdr->dest || + ((pcb_00->remote_ip).addr != ip_data.current_iphdr_src)))) || + ((pcb_00->local_ip).addr != ip_data.current_iphdr_dest)) goto LAB_23072e1c; + if (ptVar20 == (tcp_pcb *)0x0) { + lwip_stats.tcp.cachehit = lwip_stats.tcp.cachehit + 1; + } + else { + tcp_active_pcbs = pcb_00; + ptVar20->next = pcb_00->next; + pcb_00->next = ptVar19; + } + inseg.len = p->tot_len; + recv_data = (pbuf *)0x0; + recv_flags = '\0'; + recv_acked = 0; + inseg.next = (tcp_seg *)0x0; + inseg.tcphdr = ptVar4; + inseg.p = p; + if ((sendmss & 8) != 0) { + p->flags = p->flags | 1; + } + if ((pcb_00->refused_data != (pbuf *)0x0) && + ((eVar8 = tcp_process_refused_data(pcb_00), CONCAT31(extraout_var_00,eVar8) == -0xd || + ((pcb_00->refused_data != (pbuf *)0x0 && (tcplen != 0)))))) { + if (pcb_00->rcv_ann_wnd == 0) { + tcp_send_empty_ack(pcb_00); + } + lwip_stats.tcp.drop = lwip_stats.tcp.drop + 1; + goto aborted; + } + uVar7 = flags; + tcp_input_pcb = pcb_00; + if ((flags & 4) != 0) { + if (pcb_00->state == SYN_SENT) { + if (pcb_00->snd_nxt != ackno) goto switchD_230731b2_caseD_8; + } + else { + if (pcb_00->rcv_nxt != seqno) { + iVar11 = seqno - pcb_00->rcv_nxt; + if ((-1 < iVar11) && ((int)(iVar11 - (uint)pcb_00->rcv_wnd) < 1)) goto LAB_2307313e; + goto switchD_230731b2_caseD_8; + } + } + recv_flags = recv_flags | 8; + tVar14 = pcb_00->flags & 0xfffe; +LAB_230730f8: + pcb_00->flags = tVar14; + goto switchD_230731b2_caseD_8; + } + bVar3 = flags & 2; + tVar14 = pcb_00->flags; + if (((flags & 2) != 0) && (1 < (byte)(pcb_00->state + ~LISTEN))) { +LAB_23073160: + tVar14 = tVar14 | 2; + goto LAB_230730f8; + } + if ((tVar14 & 0x10) == 0) { + pcb_00->tmr = tcp_ticks; + } + *(undefined2 *)&pcb_00->persist_probe = 0; + if (tcphdr_optlen != 0) { + tcp_parseopt(&pcb_00->mss); + } + ackno = seqno; + switch((uint)pcb_00->state - 2 & 0xff) { + case 0: + if (((uVar7 & 0x12) != 0x12) || (uVar10 = pcb_00->lastack + 1, uVar10 != ackno)) { + if (((uVar7 & 0x10) != 0) && + (tcp_rst(pcb_00,ackno,seqno + tcplen,&ip_data.current_iphdr_dest, + &ip_data.current_iphdr_src,tcphdr->dest,tcphdr->src), pcb_00->nrtx < 6)) { + pcb_00->rtime = 0; + tcp_rexmit_rto(pcb_00); + } + goto switchD_230731b2_caseD_8; + } + pcb_00->lastack = uVar10; + uVar10 = ackno + 1; + pcb_00->rcv_nxt = uVar10; + pcb_00->rcv_ann_right_edge = uVar10; + sendmss = pcb_00->mss; + uVar2 = tcphdr->wnd; + pcb_00->snd_wl1 = ackno - 1; + pcb_00->snd_wnd = uVar2; + pcb_00->snd_wnd_max = uVar2; + pcb_00->state = ESTABLISHED; + outif = ip4_route((ip4_addr_t *)&pcb_00->remote_ip); + sendmss = tcp_eff_send_mss_netif + (sendmss,outif,(ip_addr_t *)(ip4_addr_t *)&pcb_00->remote_ip); + iVar11 = CONCAT22(extraout_var_10,sendmss); + uVar15 = iVar11 << 1; + pcb_00->mss = sendmss; + tVar9 = 0x111c; + header_size_decrement = uVar15; + if (uVar15 < 0x111c) { + header_size_decrement = 0x111c; + } + if ((uint)(iVar11 << 2) < header_size_decrement) { + tVar9 = (tcpwnd_size_t)((uint)(iVar11 << 0x12) >> 0x10); + } + else { + if (0x111c < uVar15) { + tVar9 = (tcpwnd_size_t)((uint)(iVar11 << 0x11) >> 0x10); + } + } + pcb_00->cwnd = tVar9; + seg = pcb_00->unacked; + pcb_00->snd_queuelen = pcb_00->snd_queuelen - 1; + if (seg == (tcp_seg *)0x0) { + seg = pcb_00->unsent; + pcb_00->unsent = seg->next; + } + else { + pcb_00->unacked = seg->next; + } + tcp_seg_free(seg); + if (pcb_00->unacked == (tcp_seg *)0x0) { + pcb_00->rtime = -1; + } + else { + pcb_00->rtime = 0; + pcb_00->nrtx = '\0'; + } + if ((pcb_00->connected == (tcp_connected_fn)0x0) || + (eVar8 = (*pcb_00->connected)(pcb_00->callback_arg,pcb_00,'\0'), + CONCAT31(extraout_var_02,eVar8) != -0xd)) { +LAB_2307313e: + tVar14 = pcb_00->flags; + goto LAB_23073160; + } + goto aborted; + case 1: + if ((uVar7 & 0x10) == 0) { + if ((bVar3 != 0) && (pcb_00->rcv_nxt - 1 == seqno)) { + tcp_rexmit(pcb_00); + } + goto switchD_230731b2_caseD_8; + } + if (((int)((ackno - 1) - pcb_00->lastack) < 0) || (0 < (int)(ackno - pcb_00->snd_nxt))) + { + tcp_rst(pcb_00,ackno,seqno + tcplen,&ip_data.current_iphdr_dest, + &ip_data.current_iphdr_src,tcphdr->dest,tcphdr->src); + goto switchD_230731b2_caseD_8; + } + pcb_00->state = ESTABLISHED; + if ((pcb_00->listener == (tcp_pcb_listen *)0x0) || + (paVar17 = pcb_00->listener->accept, paVar17 == (tcp_accept_fn)0x0)) + goto LAB_23073312; + eVar8 = (*paVar17)(pcb_00->callback_arg,pcb_00,'\0'); + if (CONCAT31(extraout_var_03,eVar8) != 0) { + if (CONCAT31(extraout_var_03,eVar8) == -0xd) goto aborted; + goto LAB_23073312; + } + tcp_receive(pcb_00); + if (recv_acked != 0) { + recv_acked = recv_acked - 1; + } + uVar18 = (uint)pcb_00->mss; + uVar15 = uVar18 << 1; + tVar9 = 0x111c; + header_size_decrement = uVar15; + if (uVar15 < 0x111c) { + header_size_decrement = 0x111c; + } + if (uVar18 << 2 < header_size_decrement) { + tVar9 = (tcpwnd_size_t)((uVar18 << 0x12) >> 0x10); + } + else { + if (0x111c < uVar15) { + tVar9 = (tcpwnd_size_t)((uVar18 << 0x11) >> 0x10); + } + } + pcb_00->cwnd = tVar9; + break; + case 2: + case 5: + tcp_receive(pcb_00); + break; + case 3: + tcp_receive(pcb_00); + if ((recv_flags & 0x20) != 0) { + if ((((flags & 0x10) == 0) || (pcb_00->snd_nxt != ackno)) || + (pcb_00->unsent != (tcp_seg *)0x0)) { + pcb_00->flags = pcb_00->flags | 2; + tVar12 = CLOSING; + goto LAB_23073384; + } + pcb_00->flags = pcb_00->flags | 2; + tcp_pcb_purge(pcb_00); + ptVar6 = tcp_active_pcbs; + if (pcb_00 == tcp_active_pcbs) goto LAB_23073430; + goto LAB_23073446; + } + if ((((flags & 0x10) == 0) || (pcb_00->snd_nxt != ackno)) || + (pcb_00->unsent != (tcp_seg *)0x0)) goto switchD_230731b2_caseD_8; + tVar12 = FIN_WAIT_2; + goto LAB_23073384; + case 4: + tcp_receive(pcb_00); + if ((recv_flags & 0x20) == 0) goto switchD_230731b2_caseD_8; + pcb_00->flags = pcb_00->flags | 2; + tcp_pcb_purge(pcb_00); + ptVar6 = tcp_active_pcbs; + if (pcb_00 == tcp_active_pcbs) goto LAB_23073430; + goto LAB_230734c2; + case 6: + tcp_receive(pcb_00); + if ((((flags & 0x10) == 0) || (pcb_00->snd_nxt != ackno)) || + (pcb_00->unsent != (tcp_seg *)0x0)) goto switchD_230731b2_caseD_8; + tcp_pcb_purge(pcb_00); + ptVar6 = tcp_active_pcbs; + if (pcb_00 != tcp_active_pcbs) goto LAB_230734fc; +LAB_23073430: + tcp_active_pcbs = pcb_00->next; + goto LAB_23073448; + case 7: + tcp_receive(pcb_00); + if ((((flags & 0x10) != 0) && (pcb_00->snd_nxt == ackno)) && + (pcb_00->unsent == (tcp_seg *)0x0)) { + recv_flags = recv_flags | 0x10; + } + default: + goto switchD_230731b2_caseD_8; + } + if ((recv_flags & 0x20) == 0) goto switchD_230731b2_caseD_8; + pcb_00->flags = pcb_00->flags | 2; + tVar12 = CLOSE_WAIT; +LAB_23073384: + pcb_00->state = tVar12; + goto switchD_230731b2_caseD_8; + } + } +LAB_23072a4e: + lwip_stats.tcp.lenerr = lwip_stats.tcp.lenerr + 1; + } + else { + lwip_stats.tcp.chkerr = lwip_stats.tcp.chkerr + 1; + } + } + else { + lwip_stats.tcp.proterr = lwip_stats.tcp.proterr + 1; + } + lwip_stats.tcp.drop = lwip_stats.tcp.drop + 1; +LAB_23072ed2: + pbuf_free(p); + return; +LAB_23072ef6: + if (pcb == (tcp_pcb *)0x0) goto code_r0x23072ef8; + if ((((pcb->netif_idx == '\0') || + (pcb->netif_idx == (u8_t)((ip_data.current_input_netif)->num + '\x01'))) && + ((remote_port = pcb->remote_port, remote_port == tcphdr->src && + ((uVar13 = pcb->local_port, uVar13 == tcphdr->dest && + (ip_data.current_iphdr_src == (pcb->remote_ip).addr)))))) && + (ip_data.current_iphdr_dest == (pcb->local_ip).addr)) { + if ((sendmss & 4) != 0) goto LAB_23072ed2; + if ((sendmss & 2) == 0) { + if ((sendmss & 1) != 0) { + pcb->tmr = tcp_ticks; + } + } + else { + iVar11 = seqno - pcb->rcv_nxt; + if ((-1 < iVar11) && ((int)(iVar11 - (uint)pcb->rcv_wnd) < 1)) { + ackno = tcplen + seqno; + goto LAB_23072eac; + } + } + if (uVar2 == 0) goto LAB_23072ed2; + pcb->flags = pcb->flags | 2; + goto LAB_23072ece; + } + pcb = pcb->next; + goto LAB_23072ef6; +code_r0x23072ef8: + ptVar20 = (tcp_pcb *)0x0; + pcb_00 = (tcp_pcb *)0x0; + ptVar19 = tcp_listen_pcbs; + while (ptVar19 != (tcp_pcb *)0x0) { + if (((ptVar19->netif_idx == '\0') || + (ptVar19->netif_idx == (u8_t)((ip_data.current_input_netif)->num + '\x01'))) && + (ptVar19->local_port == tcphdr->dest)) { + ackno = (ptVar19->local_ip).addr; + if (ip_data.current_iphdr_dest == ackno) goto LAB_23072f54; + if (ackno == 0) { + ptVar20 = ptVar19; + pcb_00 = pcb; + } + } + pcb = ptVar19; + ptVar19 = ptVar19->next; + } + pcb = pcb_00; + ptVar19 = ptVar20; + if (ptVar20 == (tcp_pcb *)0x0) { + sendmss = lwip_htons(tcphdr->_hdrlen_rsvd_flags); + if ((sendmss & 4) != 0) goto LAB_23072ed2; + lwip_stats.tcp.proterr = lwip_stats.tcp.proterr + 1; + lwip_stats.tcp.drop = lwip_stats.tcp.drop + 1; + remote_port = tcphdr->src; + uVar13 = tcphdr->dest; + ackno = seqno + tcplen; + pcb = (tcp_pcb *)0x0; + } + else { +LAB_23072f54: + if (pcb == (tcp_pcb *)0x0) { + lwip_stats.tcp.cachehit = lwip_stats.tcp.cachehit + 1; + } + else { + tcp_listen_pcbs = ptVar19; + pcb->next = ptVar19->next; + ptVar19->next = ptVar6; + } + if ((sendmss & 4) != 0) goto LAB_23072ed2; + if ((sendmss & 0x10) == 0) { + if ((sendmss & 2) != 0) { + pcb = tcp_alloc(ptVar19->prio); + ptVar4 = tcphdr; + if (pcb == (tcp_pcb *)0x0) { + lwip_stats.tcp.memerr = lwip_stats.tcp.memerr + 1; + if (*(code **)&ptVar19->remote_port != (code *)0x0) { + (**(code **)&ptVar19->remote_port)(ptVar19->callback_arg,0,0xffffffff); + } + } + else { + (pcb->local_ip).addr = ip_data.current_iphdr_dest; + (pcb->remote_ip).addr = ip_data.current_iphdr_src; + pcb->local_port = ptVar19->local_port; + pcb->remote_port = ptVar4->src; + pcb->state = SYN_RCVD; + ackno = seqno + 1; + pcb->rcv_nxt = ackno; + pcb->rcv_ann_right_edge = ackno; + uVar10 = tcp_next_iss(pcb); + ackno = seqno; + pcb->snd_wl2 = uVar10; + pcb->snd_nxt = uVar10; + pcb->lastack = uVar10; + pcb->snd_lbb = uVar10; + pcb->snd_wl1 = ackno - 1; + pvVar16 = ptVar19->callback_arg; + *(tcp_pcb **)&pcb->listener = ptVar19; + pcb->callback_arg = pvVar16; + pcb->so_options = ptVar19->so_options & 0xc; + pcb->netif_idx = ptVar19->netif_idx; + ptVar6 = pcb; + pcb->next = tcp_active_pcbs; + tcp_active_pcbs = ptVar6; + tcp_timer_needed(); + tcp_active_pcbs_changed = '\x01'; + if (tcphdr_optlen != 0) { + tcp_parseopt(&pcb->mss); + } + uVar2 = tcphdr->wnd; + sendmss = pcb->mss; + pcb->snd_wnd = uVar2; + pcb->snd_wnd_max = uVar2; + outif = ip4_route((ip4_addr_t *)&pcb->remote_ip); + sendmss = tcp_eff_send_mss_netif(sendmss,outif,(ip_addr_t *)(ip4_addr_t *)&pcb->remote_ip) + ; + pcb->mss = sendmss; + eVar8 = tcp_enqueue_flags(pcb,'\x12'); + if (CONCAT31(extraout_var_01,eVar8) == 0) { +LAB_23072ece: + tcp_output(pcb); + } + else { + tcp_abandon(pcb,0); + } + } + } + goto LAB_23072ed2; + } + remote_port = tcphdr->src; + uVar13 = tcphdr->dest; + ackno = seqno + tcplen; + pcb = ptVar19; + } +LAB_23072eac: + tcp_rst(pcb,ackno,ackno,&ip_data.current_iphdr_dest,&ip_data.current_iphdr_src,uVar13,remote_port) + ; + goto LAB_23072ed2; +LAB_23072e1c: + pcb = pcb_00->next; + ptVar20 = pcb_00; + goto LAB_23072c90; + while (ptVar6 = ptVar19->next, pcb_00 != ptVar19->next) { +LAB_230734fc: + ptVar19 = ptVar6; + if (ptVar19 == (tcp_pcb *)0x0) goto LAB_23073448; + } + goto LAB_2307343e; + while (ptVar6 = ptVar19->next, pcb_00 != ptVar19->next) { +LAB_230734c2: + ptVar19 = ptVar6; + if (ptVar19 == (tcp_pcb *)0x0) goto LAB_23073448; + } + goto LAB_2307343e; + while (ptVar6 = ptVar19->next, pcb_00 != ptVar19->next) { +LAB_23073446: + ptVar19 = ptVar6; + if (ptVar19 == (tcp_pcb *)0x0) goto LAB_23073448; + } +LAB_2307343e: + ptVar19->next = pcb_00->next; +LAB_23073448: + tcp_active_pcbs_changed = '\x01'; + pcb_00->state = TIME_WAIT; + ptVar6 = pcb_00; + pcb_00->next = tcp_tw_pcbs; + tcp_tw_pcbs = ptVar6; + tcp_timer_needed(); +switchD_230731b2_caseD_8: + if ((recv_flags & 8) == 0) { + if (recv_acked != 0) { + if ((pcb_00->sent != (tcp_sent_fn *)0x0) && + (eVar8 = (*pcb_00->sent)(pcb_00->callback_arg,pcb_00,recv_acked), + CONCAT31(extraout_var_04,eVar8) == -0xd)) goto aborted; + recv_acked = 0; + } + iVar11 = tcp_input_delayed_close(pcb_00); + if (iVar11 == 0) { + if (recv_data != (pbuf *)0x0) { + if ((pcb_00->flags & 0x10) != 0) { + pbuf_free(recv_data); +LAB_23073312: + tcp_abort(pcb_00); + goto aborted; + } + if (pcb_00->recv == (tcp_recv_fn *)0x0) { + eVar8 = tcp_recv_null((void *)0x0,pcb_00,recv_data,'\0'); + iVar11 = CONCAT31(extraout_var_06,eVar8); + } + else { + eVar8 = (*pcb_00->recv)(pcb_00->callback_arg,pcb_00,recv_data,'\0'); + iVar11 = CONCAT31(extraout_var_05,eVar8); + } + if (iVar11 == -0xd) goto aborted; + if (iVar11 != 0) { + pcb_00->refused_data = recv_data; + } + } + if ((recv_flags & 0x20) != 0) { + p_00 = pcb_00->refused_data; + if (p_00 == (pbuf *)0x0) { + if (pcb_00->rcv_wnd != 0x810) { + pcb_00->rcv_wnd = pcb_00->rcv_wnd + 1; + } + if ((pcb_00->recv != (tcp_recv_fn *)0x0) && + (eVar8 = (*pcb_00->recv)(pcb_00->callback_arg,pcb_00,(pbuf *)0x0,'\0'), + CONCAT31(extraout_var_07,eVar8) == -0xd)) goto aborted; + } + else { + p_00->flags = p_00->flags | 0x20; + } + } + tcp_input_pcb = (tcp_pcb *)0x0; + iVar11 = tcp_input_delayed_close(pcb_00); + if (iVar11 == 0) { + tcp_output(pcb_00); + } + } + } + else { + if (pcb_00->errf != (tcp_err_fn *)0x0) { + (*pcb_00->errf)(pcb_00->callback_arg,-0xe); + } + tcp_pcb_remove(&tcp_active_pcbs,pcb_00); + tcp_free(pcb_00); + } +aborted: + tcp_input_pcb = (tcp_pcb *)0x0; + recv_data = (pbuf *)0x0; + if (inseg.p != (pbuf *)0x0) { + pbuf_free(inseg.p); + inseg.p = (pbuf *)0x0; + } + return; +} + + + +void tcp_trigger_input_pcb_close(void) + +{ + recv_flags = recv_flags | 0x10; + return; +} + + + +void tcp_seg_add_chksum(u16_t chksum,u16_t len,u16_t *seg_chksum,u8_t *seg_chksum_swapped) + +{ + ushort uVar1; + undefined2 in_register_0000202a; + uint uVar2; + + uVar2 = CONCAT22(in_register_0000202a,chksum) + (uint)*seg_chksum; + uVar2 = uVar2 + (uVar2 >> 0x10) & 0xffff; + uVar1 = (ushort)uVar2; + if ((len & 1) != 0) { + *seg_chksum_swapped = '\x01' - *seg_chksum_swapped; + uVar1 = (ushort)(uVar2 >> 8) | (ushort)(uVar2 << 8); + } + *seg_chksum = uVar1; + return; +} + + + +tcp_seg * tcp_create_segment(tcp_pcb *pcb,pbuf *p,u8_t hdrflags,u32_t seqno,u8_t optflags) + +{ + tcp_seg *seg; + u8_t uVar1; + u16_t uVar2; + undefined3 extraout_var; + u32_t uVar3; + undefined3 in_register_00002031; + tcp_hdr *ptVar4; + + seg = (tcp_seg *)memp_malloc(MEMP_TCP_SEG); + if (seg == (tcp_seg *)0x0) { + pbuf_free(p); + } + else { + seg->flags = optflags; + seg->next = (tcp_seg *)0x0; + seg->p = p; + uVar2 = p->tot_len; + seg->chksum = 0; + seg->len = uVar2 + ((ushort)optflags & 1) * -4; + seg->chksum_swapped = '\0'; + uVar1 = pbuf_add_header(p,0x14); + if (CONCAT31(extraout_var,uVar1) == 0) { + ptVar4 = (tcp_hdr *)seg->p->payload; + seg->tcphdr = ptVar4; + uVar2 = lwip_htons(pcb->local_port); + *(char *)&ptVar4->src = (char)uVar2; + *(undefined *)((int)&ptVar4->src + 1) = (char)(uVar2 >> 8); + ptVar4 = seg->tcphdr; + uVar2 = lwip_htons(pcb->remote_port); + *(char *)&ptVar4->dest = (char)uVar2; + *(undefined *)((int)&ptVar4->dest + 1) = (char)(uVar2 >> 8); + ptVar4 = seg->tcphdr; + uVar3 = lwip_htonl(seqno); + *(char *)&ptVar4->seqno = (char)uVar3; + *(undefined *)((int)&ptVar4->seqno + 1) = (char)(uVar3 >> 8); + *(undefined *)((int)&ptVar4->seqno + 3) = (char)(uVar3 >> 0x18); + *(undefined *)((int)&ptVar4->seqno + 2) = (char)(uVar3 >> 0x10); + ptVar4 = seg->tcphdr; + uVar2 = lwip_htons((((ushort)optflags & 1) + 5) * 0x1000 | + (ushort)CONCAT31(in_register_00002031,hdrflags)); + *(char *)&ptVar4->_hdrlen_rsvd_flags = (char)uVar2; + *(undefined *)((int)&ptVar4->_hdrlen_rsvd_flags + 1) = (char)(uVar2 >> 8); + ptVar4 = seg->tcphdr; + *(undefined *)&ptVar4->urgp = 0; + *(undefined *)((int)&ptVar4->urgp + 1) = 0; + } + else { + lwip_stats.tcp.err = lwip_stats.tcp.err + 1; + tcp_seg_free(seg); + seg = (tcp_seg *)0x0; + } + } + return seg; +} + + + +pbuf * tcp_output_alloc_header_common + (u32_t ackno,u16_t datalen,u32_t seqno_be,u16_t src_port,u16_t dst_port,u8_t flags, + u16_t wnd) + +{ + undefined *puVar1; + u16_t uVar2; + pbuf *ppVar3; + u32_t uVar4; + undefined2 in_register_0000202e; + undefined3 in_register_0000203d; + + ppVar3 = pbuf_alloc(PBUF_IP,(u16_t)((uint)((CONCAT22(in_register_0000202e,datalen) + 0x14) * + 0x10000) >> 0x10),PBUF_RAM); + if (ppVar3 != (pbuf *)0x0) { + puVar1 = (undefined *)ppVar3->payload; + uVar2 = lwip_htons(src_port); + *puVar1 = (char)uVar2; + puVar1[1] = (char)(uVar2 >> 8); + uVar2 = lwip_htons(dst_port); + puVar1[2] = (char)uVar2; + puVar1[4] = (char)seqno_be; + puVar1[5] = (char)(seqno_be >> 8); + puVar1[3] = (char)(uVar2 >> 8); + puVar1[6] = (char)(seqno_be >> 0x10); + puVar1[7] = (char)(seqno_be >> 0x18); + uVar4 = lwip_htonl(ackno); + puVar1[8] = (char)uVar4; + puVar1[9] = (char)(uVar4 >> 8); + puVar1[0xb] = (char)(uVar4 >> 0x18); + puVar1[10] = (char)(uVar4 >> 0x10); + uVar2 = lwip_htons((ushort)CONCAT31(in_register_0000203d,flags) | 0x5000); + puVar1[0xc] = (char)uVar2; + puVar1[0xd] = (char)(uVar2 >> 8); + uVar2 = lwip_htons(wnd); + puVar1[0xe] = (char)uVar2; + puVar1[0xf] = (char)(uVar2 >> 8); + puVar1[0x10] = 0; + puVar1[0x11] = 0; + puVar1[0x12] = 0; + puVar1[0x13] = 0; + } + return ppVar3; +} + + + +pbuf * tcp_output_alloc_header(tcp_pcb *pcb,u16_t datalen,u32_t seqno_be) + +{ + pbuf *ppVar1; + + ppVar1 = tcp_output_alloc_header_common + (pcb->rcv_nxt,datalen,seqno_be,pcb->local_port,pcb->remote_port,'\x10', + pcb->rcv_ann_wnd); + if (ppVar1 != (pbuf *)0x0) { + pcb->rcv_ann_right_edge = pcb->rcv_nxt + (uint)pcb->rcv_ann_wnd; + } + return ppVar1; +} + + + +err_t tcp_output_control_segment(tcp_pcb *pcb,pbuf *p,ip_addr_t *src,ip_addr_t *dst) + +{ + err_t eVar1; + u16_t uVar2; + netif *netif; + u8_t ttl; + u8_t tos; + void *pvVar3; + + if ((pcb == (tcp_pcb *)0x0) || (pcb->netif_idx == '\0')) { + netif = ip4_route((ip4_addr_t *)dst); + } + else { + netif = netif_get_by_index(pcb->netif_idx); + } + eVar1 = -4; + if (netif != (netif *)0x0) { + pvVar3 = p->payload; + uVar2 = ip_chksum_pseudo(p,'\x06',p->tot_len,(ip4_addr_t *)src,(ip4_addr_t *)dst); + *(undefined *)((int)pvVar3 + 0x10) = (char)uVar2; + *(undefined *)((int)pvVar3 + 0x11) = (char)(uVar2 >> 8); + if (pcb == (tcp_pcb *)0x0) { + tos = '\0'; + ttl = -1; + } + else { + ttl = pcb->ttl; + tos = pcb->tos; + } + lwip_stats.tcp.xmit = lwip_stats.tcp.xmit + 1; + eVar1 = ip4_output_if(p,(ip4_addr_t *)src,(ip4_addr_t *)dst,ttl,tos,'\x06',netif); + } + pbuf_free(p); + return eVar1; +} + + + +err_t tcp_write(tcp_pcb *pcb,void *arg,u16_t len,u8_t apiflags) + +{ + ushort uVar1; + tcp_seg *ptVar2; + u16_t chksum_00; + u16_t uVar3; + u16_t len_00; + undefined2 in_register_00002032; + uint uVar4; + uint uVar5; + uint uVar6; + uint uVar7; + tcp_hdr *ptVar8; + err_t eVar9; + err_t eVar10; + uint uVar11; + tcp_seg *ptVar12; + tcp_seg *seg; + tcp_seg *ptVar13; + uint uVar14; + pbuf *p; + tcp_seg *ptVar15; + u8_t uStack67; + u16_t uStack66; + u8_t chksum_swapped; + u16_t chksum; + + uVar4 = CONCAT22(in_register_00002032,len); + if (pcb == (tcp_pcb *)0x0) { + return -0x10; + } + uVar5 = (uint)pcb->mss; + uVar7 = (uint)(pcb->snd_wnd_max >> 1); + if (uVar5 < uVar7) { + uVar7 = uVar5; + } + if (uVar7 == 0) { + uVar7 = uVar5; + } + if (arg == (void *)0x0) { + return -0x10; + } + if ((pcb->state != CLOSE_WAIT) && (2 < (byte)(pcb->state + ~LISTEN))) { + return -0xb; + } + if (uVar4 == 0) { +LAB_23073a12: + ptVar2 = pcb->unsent; + uVar3 = pcb->snd_queuelen; + if (ptVar2 == (tcp_seg *)0x0) { + ptVar15 = (tcp_seg *)0x0; + uVar5 = 0; + uVar11 = 0; + } + else { + do { + ptVar15 = ptVar2; + ptVar2 = ptVar15->next; + } while (ptVar2 != (tcp_seg *)0x0); + uVar5 = (uint)pcb->unsent_oversize; + uVar11 = 0; + if (pcb->unsent_oversize != 0) { + uVar11 = (uVar7 - ptVar15->len) + ((uint)ptVar15->flags & 1) * -4; + uVar14 = uVar5; + if (uVar4 < uVar5) { + uVar14 = uVar4; + } + if ((uVar14 & 0xffff) < (uVar11 & 0xffff)) { + uVar11 = uVar14; + } + uVar11 = uVar11 & 0xffff; + uVar5 = uVar5 - uVar11 & 0xffff; + ptVar2 = ptVar15; + } + } + seg = (tcp_seg *)0x0; + ptVar13 = (tcp_seg *)0x0; + uVar14 = uVar11; + while (uVar14 < uVar4) { + uVar6 = uVar4 - uVar14; + if (uVar7 < (uVar4 - uVar14 & 0xffff)) { + uVar6 = uVar7; + } + uStack66 = 0; + uStack67 = '\0'; + p = pbuf_alloc(PBUF_TRANSPORT,(u16_t)uVar7,PBUF_RAM); + if (p == (pbuf *)0x0) { +memerr: + pcb->flags = pcb->flags | 0x80; + lwip_stats.tcp.memerr = lwip_stats.tcp.memerr + 1; + if (seg != (tcp_seg *)0x0) { + tcp_segs_free(seg); + } + goto LAB_230739d2; + } + uVar1 = p->len; + len_00 = (u16_t)uVar6; + p->tot_len = len_00; + p->len = len_00; + chksum_00 = lwip_chksum_copy(p->payload,(void *)((int)arg + uVar14),len_00); + tcp_seg_add_chksum(chksum_00,len_00,&uStack66,&uStack67); + chksum_00 = pbuf_clen(p); + uVar3 = uVar3 + chksum_00; + uVar5 = (uint)uVar1 - (uVar6 & 0xffff) & 0xffff; + if (0x10 < uVar3) { + pbuf_free(p); + goto memerr; + } + ptVar2 = tcp_create_segment(pcb,p,'\0',pcb->snd_lbb + uVar14,'\0'); + if (ptVar2 == (tcp_seg *)0x0) goto memerr; + ptVar2->chksum = uStack66; + ptVar2->chksum_swapped = uStack67; + ptVar2->flags = ptVar2->flags | 4; + ptVar12 = ptVar2; + if (seg != (tcp_seg *)0x0) { + ptVar13->next = ptVar2; + ptVar12 = seg; + } + uVar14 = uVar14 + (uVar6 & 0xffff) & 0xffff; + seg = ptVar12; + ptVar13 = ptVar2; + } + if (uVar11 != 0) { + p = ptVar15->p; + while (chksum_00 = (u16_t)uVar11, p != (pbuf *)0x0) { + p->tot_len = p->tot_len + chksum_00; + if (p->next == (pbuf *)0x0) { + len_00 = lwip_chksum_copy((void *)((int)p->payload + (uint)p->len),arg,chksum_00); + tcp_seg_add_chksum(len_00,chksum_00,&ptVar15->chksum,&ptVar15->chksum_swapped); + ptVar15->flags = ptVar15->flags | 4; + p->len = p->len + chksum_00; + } + p = p->next; + } + ptVar15->len = chksum_00 + ptVar15->len; + } + pcb->unsent_oversize = (u16_t)uVar5; + if (ptVar15 == (tcp_seg *)0x0) { + pcb->unsent = seg; + } + else { + ptVar15->next = seg; + } + pcb->snd_queuelen = uVar3; + pcb->snd_lbb = pcb->snd_lbb + uVar4; + pcb->snd_buf = pcb->snd_buf - len; + eVar10 = '\0'; + eVar9 = '\0'; + if (((ptVar2 != (tcp_seg *)0x0) && (eVar9 = eVar10, ptVar2->tcphdr != (tcp_hdr *)0x0)) && + ((apiflags & 2) == 0)) { + uVar1 = ptVar2->tcphdr->_hdrlen_rsvd_flags; + uVar3 = lwip_htons(8); + ptVar8 = ptVar2->tcphdr; + uVar1 = uVar3 | uVar1; + *(char *)&ptVar8->_hdrlen_rsvd_flags = (char)uVar1; + *(undefined *)((int)&ptVar8->_hdrlen_rsvd_flags + 1) = (char)((uint)uVar1 >> 8); + } + } + else { + if (uVar4 <= pcb->snd_buf) { + if (pcb->snd_queuelen < 0x10) goto LAB_23073a12; + lwip_stats.tcp.memerr = lwip_stats.tcp.memerr + 1; + } + pcb->flags = pcb->flags | 0x80; +LAB_230739d2: + eVar9 = -1; + } + return eVar9; +} + + + +err_t tcp_split_unsent_seg(tcp_pcb *pcb,u16_t split) + +{ + byte bVar1; + ushort *puVar2; + ushort uVar3; + tcp_seg *ptVar4; + uint uVar5; + u16_t len; + u16_t uVar6; + pbuf *p; + undefined2 extraout_var; + u32_t uVar7; + tcp_seg *ptVar8; + undefined2 in_register_0000202e; + byte hdrflags; + tcp_hdr *ptVar9; + int iVar10; + uint uVar11; + uint uVar12; + u8_t uStack51; + u16_t uStack50; + u8_t chksum_swapped; + u16_t chksum; + + uVar5 = CONCAT22(in_register_0000202e,split); + ptVar4 = pcb->unsent; + uStack50 = 0; + uStack51 = '\0'; + if (ptVar4 != (tcp_seg *)0x0) { + if (uVar5 == 0) { + return -6; + } + uVar11 = (uint)ptVar4->len; + if (uVar11 <= uVar5) { + return '\0'; + } + bVar1 = ptVar4->flags; + iVar10 = ((uint)bVar1 & 1) * 4; + uVar12 = uVar11 - uVar5 & 0xffff; + p = pbuf_alloc(PBUF_TRANSPORT,(u16_t)((uVar12 + iVar10) * 0x10000 >> 0x10),PBUF_RAM); + if ((p != (pbuf *)0x0) && + (len = pbuf_copy_partial(ptVar4->p,(void *)((int)p->payload + iVar10), + (u16_t)((uVar11 - uVar5) * 0x10000 >> 0x10), + (u16_t)((((uint)ptVar4->p->tot_len - (uint)ptVar4->len) + uVar5) * + 0x10000 >> 0x10)), CONCAT22(extraout_var,len) == uVar12)) { + uVar6 = inet_chksum((void *)((int)p->payload + iVar10),len); + tcp_seg_add_chksum(~uVar6,len,&uStack50,&uStack51); + len = lwip_htons(ptVar4->tcphdr->_hdrlen_rsvd_flags); + hdrflags = (byte)len & 8; + if ((len & 8) == 0) { + len = len & 0x3f; + } + else { + len = len & 0x37; + hdrflags = 8; + } + if ((len & 1) != 0) { + len = len & 0xfe; + hdrflags = hdrflags | 1; + } + uVar7 = lwip_htonl(ptVar4->tcphdr->seqno); + ptVar8 = tcp_create_segment(pcb,p,hdrflags,uVar5 + uVar7,bVar1 & 0xfb); + if (ptVar8 != (tcp_seg *)0x0) { + ptVar8->chksum = uStack50; + ptVar8->chksum_swapped = uStack51; + ptVar8->flags = ptVar8->flags | 4; + uVar6 = pbuf_clen(ptVar4->p); + pcb->snd_queuelen = pcb->snd_queuelen - uVar6; + pbuf_realloc(ptVar4->p, + (u16_t)(((uint)ptVar4->p->tot_len + (uVar5 - uVar11 & 0xffff)) * 0x10000 >> + 0x10)); + ptVar4->len = (short)((uVar5 - uVar11) * 0x10000 >> 0x10) + ptVar4->len; + uVar3 = ptVar4->tcphdr->_hdrlen_rsvd_flags; + len = lwip_htons(len); + ptVar9 = ptVar4->tcphdr; + uVar3 = uVar3 | len; + *(char *)&ptVar9->_hdrlen_rsvd_flags = (char)uVar3; + *(undefined *)((int)&ptVar9->_hdrlen_rsvd_flags + 1) = (char)((uint)uVar3 >> 8); + len = pbuf_clen(ptVar4->p); + pcb->snd_queuelen = len + pcb->snd_queuelen; + p = ptVar4->p; + ptVar4->chksum = 0; + ptVar4->chksum_swapped = '\0'; + uVar5 = (uint)p->tot_len - (uint)ptVar4->len; + while( true ) { + uVar5 = uVar5 & 0xffff; + puVar2 = &p->len; + if (uVar5 <= *puVar2) break; + p = p->next; + uVar5 = uVar5 - *puVar2; + if (p == (pbuf *)0x0) goto LAB_23073e8e; + } + do { + len = inet_chksum((void *)((int)p->payload + uVar5), + (u16_t)((p->len - uVar5) * 0x10000 >> 0x10)); + tcp_seg_add_chksum(~len,(u16_t)((p->len - uVar5) * 0x10000 >> 0x10),&ptVar4->chksum, + &ptVar4->chksum_swapped); + p = p->next; + uVar5 = 0; + } while (p != (pbuf *)0x0); +LAB_23073e8e: + len = pbuf_clen(ptVar8->p); + pcb->snd_queuelen = len + pcb->snd_queuelen; + ptVar8->next = ptVar4->next; + ptVar4->next = ptVar8; + ptVar4 = ptVar8->next; + if (ptVar4 != (tcp_seg *)0x0) { + return '\0'; + } + pcb->unsent_oversize = 0; + return (err_t)ptVar4; + } + } + lwip_stats.tcp.memerr = lwip_stats.tcp.memerr + 1; + if (p != (pbuf *)0x0) { + pbuf_free(p); + } + } + return -1; +} + + + +err_t tcp_enqueue_flags(tcp_pcb *pcb,u8_t flags) + +{ + err_t eVar1; + u16_t uVar2; + pbuf *p; + tcp_seg *ptVar3; + uint uVar4; + tcp_seg *ptVar5; + tcp_seg *ptVar6; + + uVar4 = ((uint)flags & 2) >> 1; + p = pbuf_alloc(PBUF_TRANSPORT,(u16_t)(uVar4 << 2),PBUF_RAM); + if ((p == (pbuf *)0x0) || + (ptVar3 = tcp_create_segment(pcb,p,flags,pcb->snd_lbb,(u8_t)uVar4), ptVar3 == (tcp_seg *)0x0)) + { + eVar1 = -1; + pcb->flags = pcb->flags | 0x80; + lwip_stats.tcp.memerr = lwip_stats.tcp.memerr + 1; + } + else { + ptVar5 = pcb->unsent; + if (pcb->unsent == (tcp_seg *)0x0) { + pcb->unsent = ptVar3; + } + else { + do { + ptVar6 = ptVar5; + ptVar5 = ptVar6->next; + } while (ptVar5 != (tcp_seg *)0x0); + ptVar6->next = ptVar3; + } + pcb->unsent_oversize = 0; + if ((flags & 3) != 0) { + pcb->snd_lbb = pcb->snd_lbb + 1; + } + if ((flags & 1) != 0) { + pcb->flags = pcb->flags | 0x20; + } + uVar2 = pbuf_clen(ptVar3->p); + pcb->snd_queuelen = uVar2 + pcb->snd_queuelen; + eVar1 = '\0'; + } + return eVar1; +} + + + +err_t tcp_send_fin(tcp_pcb *pcb) + +{ + ushort uVar1; + tcp_seg *ptVar2; + tcp_seg *ptVar3; + err_t eVar4; + u16_t uVar5; + tcp_hdr *ptVar6; + + ptVar2 = pcb->unsent; + if (pcb->unsent != (tcp_seg *)0x0) { + do { + ptVar3 = ptVar2; + ptVar2 = ptVar3->next; + } while (ptVar3->next != (tcp_seg *)0x0); + uVar5 = lwip_htons(ptVar3->tcphdr->_hdrlen_rsvd_flags); + if ((uVar5 & 7) == 0) { + uVar1 = ptVar3->tcphdr->_hdrlen_rsvd_flags; + uVar5 = lwip_htons(1); + ptVar6 = ptVar3->tcphdr; + uVar1 = uVar5 | uVar1; + *(char *)&ptVar6->_hdrlen_rsvd_flags = (char)uVar1; + *(undefined *)((int)&ptVar6->_hdrlen_rsvd_flags + 1) = (char)((uint)uVar1 >> 8); + pcb->flags = pcb->flags | 0x20; + return '\0'; + } + } + eVar4 = tcp_enqueue_flags(pcb,'\x01'); + return eVar4; +} + + + +err_t tcp_rexmit_rto_prepare(tcp_pcb *pcb) + +{ + u8_t uVar1; + ushort uVar2; + tcp_seg *ptVar3; + u16_t uVar4; + u32_t uVar5; + tcp_seg *ptVar6; + + ptVar3 = pcb->unacked; + if (pcb->unacked != (tcp_seg *)0x0) { + do { + uVar1 = ptVar3->p->ref; + if (ptVar3->next == (tcp_seg *)0x0) { + if (uVar1 != '\x01') { + return -6; + } + ptVar3->next = pcb->unsent; + ptVar6 = pcb->unacked; + pcb->unacked = (tcp_seg *)0x0; + pcb->unsent = ptVar6; + pcb->flags = pcb->flags | 0x800; + uVar5 = lwip_htonl(ptVar3->tcphdr->seqno); + uVar2 = ptVar3->len; + uVar4 = lwip_htons(ptVar3->tcphdr->_hdrlen_rsvd_flags); + pcb->rto_end = (uint)((uVar4 & 3) != 0) + uVar5 + uVar2; + pcb->rttest = 0; + return '\0'; + } + ptVar3 = ptVar3->next; + } while (uVar1 == '\x01'); + } + return -6; +} + + + +err_t tcp_rexmit(tcp_pcb *pcb) + +{ + tcp_seg *ptVar1; + u32_t uVar2; + u32_t uVar3; + err_t eVar4; + tcp_seg *ptVar5; + + ptVar1 = pcb->unacked; + eVar4 = -6; + if ((ptVar1 != (tcp_seg *)0x0) && (eVar4 = -6, ptVar1->p->ref == '\x01')) { + ptVar5 = (tcp_seg *)&pcb->unsent; + pcb->unacked = ptVar1->next; + while (ptVar5->next != (tcp_seg *)0x0) { + uVar2 = lwip_htonl(ptVar5->next->tcphdr->seqno); + uVar3 = lwip_htonl(ptVar1->tcphdr->seqno); + if (-1 < (int)(uVar2 - uVar3)) break; + ptVar5 = ptVar5->next; + } + ptVar1->next = ptVar5->next; + ptVar5->next = ptVar1; + if (ptVar1->next == (tcp_seg *)0x0) { + pcb->unsent_oversize = 0; + } + if (pcb->nrtx != -1) { + pcb->nrtx = pcb->nrtx + '\x01'; + } + pcb->rttest = 0; + eVar4 = '\0'; + } + return eVar4; +} + + + +void tcp_rexmit_fast(tcp_pcb *pcb) + +{ + err_t eVar1; + undefined3 extraout_var; + uint uVar2; + uint uVar3; + + if (pcb->unacked != (tcp_seg *)0x0) { + if (((pcb->flags & 4) == 0) && (eVar1 = tcp_rexmit(pcb), CONCAT31(extraout_var,eVar1) == 0)) { + uVar3 = (uint)pcb->snd_wnd; + if ((uint)pcb->cwnd < (uint)pcb->snd_wnd) { + uVar3 = (uint)pcb->cwnd; + } + pcb->ssthresh = (tcpwnd_size_t)((int)uVar3 >> 1); + uVar2 = (uint)pcb->mss << 1; + if ((uint)((int)uVar3 >> 1) < uVar2) { + pcb->ssthresh = (tcpwnd_size_t)uVar2; + } + pcb->rtime = 0; + pcb->cwnd = pcb->mss * 3 + pcb->ssthresh; + pcb->flags = pcb->flags | 4; + } + return; + } + return; +} + + + +void tcp_rst(tcp_pcb *pcb,u32_t seqno,u32_t ackno,ip_addr_t *param_4,ip_addr_t *remote_ip, + u16_t param_6,u16_t remote_port) + +{ + u32_t seqno_be; + pbuf *p; + + seqno_be = lwip_htonl(seqno); + p = tcp_output_alloc_header_common(ackno,0,seqno_be,param_6,remote_port,'\x14',0x1008); + if (p != (pbuf *)0x0) { + tcp_output_control_segment(pcb,p,param_4,remote_ip); + return; + } + return; +} + + + +err_t tcp_send_empty_ack(tcp_pcb *pcb) + +{ + err_t eVar1; + u32_t seqno_be; + pbuf *p; + undefined3 extraout_var; + tcpflags_t tVar2; + + seqno_be = lwip_htonl(pcb->snd_nxt); + p = tcp_output_alloc_header(pcb,0,seqno_be); + if (p == (pbuf *)0x0) { + eVar1 = -2; + pcb->flags = pcb->flags | 3; + } + else { + eVar1 = tcp_output_control_segment(pcb,p,(ip_addr_t *)pcb,&pcb->remote_ip); + if (CONCAT31(extraout_var,eVar1) == 0) { + tVar2 = pcb->flags & 0xfffc; + } + else { + tVar2 = pcb->flags | 3; + } + pcb->flags = tVar2; + } + return eVar1; +} + + + +err_t tcp_output(tcp_pcb *pcb) + +{ + ushort uVar1; + ushort uVar2; + bool bVar3; + short sVar4; + tcp_seg *ptVar5; + tcp_seg *seg; + err_t eVar6; + u16_t proto_len; + u16_t uVar7; + netif *outif; + u32_t uVar8; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + uint uVar9; + undefined3 extraout_var; + u32_t uVar10; + tcp_hdr *ptVar11; + pbuf *p; + tcp_seg *ptVar12; + tcp_seg *ptVar13; + uint uVar14; + ip4_addr_t *dest; + + if (tcp_input_pcb == pcb) { + return '\0'; + } + seg = pcb->unsent; + if (seg == (tcp_seg *)0x0) { + uVar1 = pcb->flags; + } + else { + uVar1 = pcb->cwnd; + uVar2 = pcb->snd_wnd; + dest = (ip4_addr_t *)&pcb->remote_ip; + if (pcb->netif_idx == '\0') { + outif = ip4_route(dest); + } + else { + outif = netif_get_by_index(pcb->netif_idx); + } + if (outif == (netif *)0x0) { + return -4; + } + if ((pcb->local_ip).addr == 0) { + (pcb->local_ip).addr = (outif->ip_addr).addr; + } + uVar14 = (uint)uVar1; + if ((uint)uVar2 < (uint)uVar1) { + uVar14 = (uint)uVar2; + } + uVar8 = lwip_htonl(seg->tcphdr->seqno); + if (uVar8 + ((uint)seg->len - pcb->lastack) <= uVar14) { + pcb->persist_backoff = '\0'; + ptVar12 = pcb->unacked; + ptVar13 = pcb->unacked; + while (ptVar5 = ptVar12, ptVar5 != (tcp_seg *)0x0) { + ptVar12 = ptVar5->next; + ptVar13 = ptVar5; + } + do { + uVar8 = lwip_htonl(seg->tcphdr->seqno); + if ((uVar14 < (uVar8 - pcb->lastack) + (uint)seg->len) || + (((((lwip_htons(seg->tcphdr->_hdrlen_rsvd_flags), pcb->unacked != (tcp_seg *)0x0 && + ((pcb->flags & 0x44) == 0)) && + ((ptVar12 = pcb->unsent, ptVar12 == (tcp_seg *)0x0 || + ((ptVar12->next == (tcp_seg *)0x0 && (ptVar12->len < pcb->mss)))))) && + (pcb->snd_buf != 0)) && ((pcb->snd_queuelen < 0x10 && ((pcb->flags & 0xa0) == 0)))))) { + if (pcb->unsent != (tcp_seg *)0x0) goto output_done; + break; + } + if (pcb->state != SYN_SENT) { + uVar1 = seg->tcphdr->_hdrlen_rsvd_flags; + proto_len = lwip_htons(0x10); + ptVar11 = seg->tcphdr; + uVar1 = proto_len | uVar1; + *(char *)&ptVar11->_hdrlen_rsvd_flags = (char)uVar1; + *(undefined *)((int)&ptVar11->_hdrlen_rsvd_flags + 1) = (char)((uint)uVar1 >> 8); + } + if (seg->p->ref == '\x01') { + ptVar11 = seg->tcphdr; + uVar8 = lwip_htonl(pcb->rcv_nxt); + *(char *)&ptVar11->ackno = (char)uVar8; + *(undefined *)((int)&ptVar11->ackno + 1) = (char)(uVar8 >> 8); + *(undefined *)((int)&ptVar11->ackno + 2) = (char)(uVar8 >> 0x10); + *(undefined *)((int)&ptVar11->ackno + 3) = (char)(uVar8 >> 0x18); + ptVar11 = seg->tcphdr; + proto_len = lwip_htons(pcb->rcv_ann_wnd); + *(char *)&ptVar11->wnd = (char)proto_len; + *(undefined *)((int)&ptVar11->wnd + 1) = (char)(proto_len >> 8); + pcb->rcv_ann_right_edge = pcb->rcv_nxt + (uint)pcb->rcv_ann_wnd; + if ((seg->flags & 1) != 0) { + ptVar11 = seg->tcphdr; + proto_len = tcp_eff_send_mss_netif(0x2b0,outif,(ip_addr_t *)dest); + uVar8 = lwip_htonl(CONCAT22(extraout_var_00,proto_len) | 0x2040000); + *(u32_t *)(ptVar11 + 1) = uVar8; + } + if (pcb->rtime < 0) { + pcb->rtime = 0; + } + if (pcb->rttest == 0) { + pcb->rttest = tcp_ticks; + uVar8 = lwip_htonl(seg->tcphdr->seqno); + pcb->rtseq = uVar8; + } + p = seg->p; + sVar4 = (short)((uint)((int)((int)seg->tcphdr - (int)p->payload) * 0x10000) >> 0x10); + p->len = p->len - sVar4; + seg->p->tot_len = seg->p->tot_len - sVar4; + ptVar11 = seg->tcphdr; + *(tcp_hdr **)&seg->p->payload = ptVar11; + *(undefined *)&ptVar11->chksum = 0; + *(undefined *)((int)&ptVar11->chksum + 1) = 0; + if ((seg->flags & 4) == 0) { + lwip_htons(seg->tcphdr->_hdrlen_rsvd_flags); + } + p = seg->p; + proto_len = p->tot_len; + uVar7 = lwip_htons(seg->tcphdr->_hdrlen_rsvd_flags); + proto_len = ip_chksum_pseudo_partial + (p,'\x06',proto_len, + (ushort)(CONCAT22(extraout_var_01,uVar7) >> 10) & 0xfc, + (ip4_addr_t *)pcb,dest); + bVar3 = seg->chksum_swapped != '\0'; + if (bVar3) { + seg->chksum_swapped = '\0'; + seg->chksum = seg->chksum >> 8 | seg->chksum << 8; + } + ptVar11 = seg->tcphdr; + uVar9 = (uint)seg->chksum + (~(uint)proto_len & 0xffff); + uVar9 = ~((uVar9 >> 0x10) + uVar9); + *(char *)&ptVar11->chksum = (char)uVar9; + *(undefined *)((int)&ptVar11->chksum + 1) = (char)(uVar9 >> 8); + lwip_stats.tcp.xmit = lwip_stats.tcp.xmit + 1; + eVar6 = ip4_output_if(seg->p,(ip4_addr_t *)pcb,dest,pcb->ttl,pcb->tos,'\x06',outif); + if (bVar3) { + seg->chksum_swapped = '\x01'; + seg->chksum = seg->chksum >> 8 | seg->chksum << 8; + } + if (CONCAT31(extraout_var,eVar6) != 0) { + pcb->flags = pcb->flags | 0x80; + return eVar6; + } + } + pcb->unsent = seg->next; + if (pcb->state != SYN_SENT) { + pcb->flags = pcb->flags & 0xfffc; + } + uVar8 = lwip_htonl(seg->tcphdr->seqno); + uVar1 = seg->len; + proto_len = lwip_htons(seg->tcphdr->_hdrlen_rsvd_flags); + uVar8 = (uint)((proto_len & 3) != 0) + uVar8 + uVar1; + if ((int)(pcb->snd_nxt - uVar8) < 0) { + pcb->snd_nxt = uVar8; + } + uVar1 = seg->len; + proto_len = lwip_htons(seg->tcphdr->_hdrlen_rsvd_flags); + if ((uint)((proto_len & 3) != 0) + (uint)uVar1 == 0) { + tcp_seg_free(seg); + } + else { + seg->next = (tcp_seg *)0x0; + if (pcb->unacked == (tcp_seg *)0x0) { + pcb->unacked = seg; + ptVar13 = seg; + } + else { + uVar8 = lwip_htonl(seg->tcphdr->seqno); + uVar10 = lwip_htonl(ptVar13->tcphdr->seqno); + ptVar12 = (tcp_seg *)&pcb->unacked; + if ((int)(uVar8 - uVar10) < 0) { + while (ptVar12->next != (tcp_seg *)0x0) { + uVar8 = lwip_htonl(ptVar12->next->tcphdr->seqno); + uVar10 = lwip_htonl(seg->tcphdr->seqno); + if (-1 < (int)(uVar8 - uVar10)) break; + ptVar12 = ptVar12->next; + } + seg->next = ptVar12->next; + ptVar12->next = seg; + } + else { + ptVar13->next = seg; + ptVar13 = seg; + } + } + } + seg = pcb->unsent; + } while (seg != (tcp_seg *)0x0); + pcb->unsent_oversize = 0; + goto output_done; + } + if ((((uint)pcb->snd_wnd == uVar14) && (pcb->unacked == (tcp_seg *)0x0)) && + (pcb->persist_backoff == '\0')) { + *(undefined2 *)&pcb->persist_cnt = 0x100; + pcb->persist_probe = '\0'; + } + uVar1 = pcb->flags; + } + if ((uVar1 & 2) != 0) { + eVar6 = tcp_send_empty_ack(pcb); + return eVar6; + } +output_done: + pcb->flags = pcb->flags & 0xff7f; + return '\0'; +} + + + +void tcp_rexmit_rto_commit(tcp_pcb *pcb) + +{ + if (pcb->nrtx != -1) { + pcb->nrtx = pcb->nrtx + '\x01'; + } + tcp_output(pcb); + return; +} + + + +void tcp_rexmit_rto(tcp_pcb *pcb) + +{ + err_t eVar1; + undefined3 extraout_var; + + eVar1 = tcp_rexmit_rto_prepare(pcb); + if (CONCAT31(extraout_var,eVar1) == 0) { + tcp_rexmit_rto_commit(pcb); + return; + } + return; +} + + + +err_t tcp_keepalive(tcp_pcb *pcb) + +{ + err_t eVar1; + u32_t seqno_be; + pbuf *p; + + seqno_be = lwip_htonl(pcb->snd_nxt - 1); + p = tcp_output_alloc_header(pcb,0,seqno_be); + if (p != (pbuf *)0x0) { + eVar1 = tcp_output_control_segment(pcb,p,(ip_addr_t *)pcb,&pcb->remote_ip); + return eVar1; + } + return -1; +} + + + +err_t tcp_zero_window_probe(tcp_pcb *pcb) + +{ + ushort uVar1; + uint uVar2; + err_t eVar3; + u16_t uVar4; + pbuf *p; + u32_t uVar5; + tcp_seg *ptVar6; + void *pvVar7; + + ptVar6 = pcb->unsent; + if (ptVar6 == (tcp_seg *)0x0) { + eVar3 = '\0'; + } + else { + if (pcb->persist_probe != -1) { + pcb->persist_probe = pcb->persist_probe + '\x01'; + } + uVar2 = 0; + uVar4 = lwip_htons(ptVar6->tcphdr->_hdrlen_rsvd_flags); + if ((uVar4 & 1) != 0) { + uVar2 = (uint)(ptVar6->len == 0); + } + p = tcp_output_alloc_header(pcb,(ushort)uVar2 ^ 1,ptVar6->tcphdr->seqno); + if (p != (pbuf *)0x0) { + pvVar7 = p->payload; + if (uVar2 == 0) { + pbuf_copy_partial(ptVar6->p,(void *)((int)pvVar7 + 0x14),1, + (u16_t)(((uint)ptVar6->p->tot_len - (uint)ptVar6->len) * 0x10000 >> 0x10)) + ; + } + else { + uVar1 = *(ushort *)((int)pvVar7 + 0xc); + uVar4 = lwip_htons(0x11); + uVar2 = (int)(short)(uVar1 & 0xc0ff) | (uint)uVar4; + *(undefined *)((int)pvVar7 + 0xc) = (char)uVar2; + *(undefined *)((int)pvVar7 + 0xd) = (char)(uVar2 >> 8); + } + uVar5 = lwip_htonl(ptVar6->tcphdr->seqno); + if ((int)(pcb->snd_nxt - (uVar5 + 1)) < 0) { + pcb->snd_nxt = uVar5 + 1; + } + eVar3 = tcp_output_control_segment(pcb,p,(ip_addr_t *)pcb,&pcb->remote_ip); + return eVar3; + } + eVar3 = -1; + } + return eVar3; +} + + + +void sys_timeout_abs(u32_t abs_time,sys_timeout_handler *handler,void *arg) + +{ + sys_timeo *psVar1; + sys_timeo *psVar2; + sys_timeo *psVar3; + + psVar1 = (sys_timeo *)memp_malloc(MEMP_SYS_TIMEOUT); + psVar2 = next_timeout; + psVar3 = next_timeout; + if (psVar1 != (sys_timeo *)0x0) { + psVar1->next = (sys_timeo *)0x0; + psVar1->h = handler; + psVar1->arg = arg; + psVar1->time = abs_time; + psVar3 = psVar1; + if (psVar2 != (sys_timeo *)0x0) { + if ((int)(abs_time - psVar2->time) < 0) { + psVar1->next = psVar2; + } + else { + do { + psVar3 = psVar2; + psVar2 = psVar3->next; + if (psVar2 == (sys_timeo *)0x0) break; + } while (-1 < (int)(abs_time - psVar2->time)); + psVar1->next = psVar2; + psVar3->next = psVar1; + psVar3 = next_timeout; + } + } + } + next_timeout = psVar3; + return; +} + + + +void lwip_cyclic_timer(void *arg) + +{ + TickType_t TVar1; + u32_t abs_time; + u32_t uVar2; + + (**(code **)((int)arg + 4))(*(code **)((int)arg + 4)); + TVar1 = sys_now(); + uVar2 = current_timeout_due_time + *(int *)arg; + abs_time = TVar1 + *(int *)arg; + if (-1 < (int)(uVar2 - TVar1)) { + abs_time = uVar2; + } + sys_timeout_abs(abs_time,lwip_cyclic_timer,arg); + return; +} + + + +void sys_timeout(u32_t msecs,sys_timeout_handler *handler,void *arg) + +{ + TickType_t TVar1; + + TVar1 = sys_now(); + sys_timeout_abs(TVar1 + msecs,handler,arg); + return; +} + + + +void tcp_timer_needed(void) + +{ + if ((tcpip_tcp_timer_active == 0) && + ((tcp_active_pcbs != (tcp_pcb *)0x0 || (tcp_tw_pcbs != (tcp_pcb *)0x0)))) { + tcpip_tcp_timer_active = 1; + sys_timeout(0xfa,tcpip_tcp_timer,(void *)0x0); + return; + } + return; +} + + + +void tcpip_tcp_timer(void *arg) + +{ + tcp_tmr(); + if ((tcp_active_pcbs == (tcp_pcb *)0x0) && (tcp_tw_pcbs == (tcp_pcb *)0x0)) { + tcpip_tcp_timer_active = 0; + return; + } + sys_timeout(0xfa,tcpip_tcp_timer,(void *)0x0); + return; +} + + + +void sys_timeouts_init(void) + +{ + u32_t *arg; + u32_t *puVar1; + + arg = &DAT_230c379c; + do { + puVar1 = arg + 2; + sys_timeout(*arg,lwip_cyclic_timer,arg); + arg = puVar1; + } while (puVar1 != (u32_t *)CSWTCH_13); + return; +} + + + +void sys_untimeout(sys_timeout_handler *handler,void *arg) + +{ + sys_timeo *psVar1; + sys_timeo *psVar2; + sys_timeo *mem; + + psVar1 = (sys_timeo *)0x0; + mem = next_timeout; + if (next_timeout != (sys_timeo *)0x0) { + do { + psVar2 = mem->next; + if ((mem->h == handler) && (mem->arg == arg)) { + if (psVar1 != (sys_timeo *)0x0) { + psVar1->next = psVar2; + psVar2 = next_timeout; + } + next_timeout = psVar2; + memp_free(MEMP_SYS_TIMEOUT,mem); + return; + } + psVar1 = mem; + mem = psVar2; + } while (psVar2 != (sys_timeo *)0x0); + } + return; +} + + + +void sys_check_timeouts(void) + +{ + sys_timeo *mem; + sys_timeout_handler *psVar1; + void *pvVar2; + TickType_t TVar3; + + TVar3 = sys_now(); + while ((mem = next_timeout, next_timeout != (sys_timeo *)0x0 && + (-1 < (int)(TVar3 - next_timeout->time)))) { + psVar1 = next_timeout->h; + pvVar2 = next_timeout->arg; + current_timeout_due_time = next_timeout->time; + next_timeout = next_timeout->next; + memp_free(MEMP_SYS_TIMEOUT,mem); + if (psVar1 != (sys_timeout_handler *)0x0) { + (*psVar1)(pvVar2); + } + } + return; +} + + + +u32_t sys_timeouts_sleeptime(void) + +{ + u32_t uVar1; + TickType_t TVar2; + + uVar1 = 0xffffffff; + if (next_timeout != (sys_timeo *)0x0) { + TVar2 = sys_now(); + uVar1 = next_timeout->time - TVar2; + if ((int)uVar1 < 0) { + uVar1 = 0; + } + } + return uVar1; +} + + + +void udp_init(void) + +{ + int iVar1; + + iVar1 = bl_rand(); + udp_port = (ushort)((uint)(iVar1 << 0x12) >> 0x12) + 0xc000; + return; +} + + + +void udp_input(pbuf *p,netif *inp) + +{ + udp_pcb *puVar1; + udp_pcb *puVar2; + u8_t uVar3; + u16_t uVar4; + u16_t uVar5; + undefined3 extraout_var; + undefined2 extraout_var_01; + undefined2 extraout_var_02; + undefined2 extraout_var_03; + undefined3 extraout_var_00; + u32_t uVar6; + uint uVar7; + udp_pcb *puVar8; + udp_pcb *puVar9; + udp_pcb *puVar10; + u16_t *puVar11; + + lwip_stats.udp.recv = lwip_stats.udp.recv + 1; + if (p->len < 8) { + lwip_stats.udp.lenerr = lwip_stats.udp.lenerr + 1; + lwip_stats.udp.drop = lwip_stats.udp.drop + 1; + } + else { + puVar11 = (u16_t *)p->payload; + uVar3 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_dest,ip_data.current_netif); + _uVar3 = CONCAT31(extraout_var,uVar3); + uVar4 = lwip_htons(*puVar11); + uVar5 = lwip_htons(puVar11[1]); + puVar1 = udp_pcbs; + puVar9 = (udp_pcb *)0x0; + puVar2 = udp_pcbs; + puVar8 = (udp_pcb *)0x0; + while (puVar10 = puVar2, puVar10 != (udp_pcb *)0x0) { + if (((uint)puVar10->local_port == CONCAT22(extraout_var_02,uVar5)) && + ((puVar10->netif_idx == '\0' || + (puVar10->netif_idx == (u8_t)((ip_data.current_input_netif)->num + '\x01'))))) { + uVar7 = (puVar10->local_ip).addr; + if (_uVar3 == 0) { + if ((uVar7 == 0) || (uVar7 == ip_data.current_iphdr_dest)) goto LAB_23074ca6; + } + else { + if ((uVar7 == 0) || + ((ip_data.current_iphdr_dest == 0xffffffff || + (((uVar7 ^ ip_data.current_iphdr_dest) & (inp->netmask).addr) == 0)))) { +LAB_23074ca6: + if ((puVar10->flags & 4) != 0) goto LAB_23074cdc; + if (puVar9 == (udp_pcb *)0x0) { +LAB_23074cca: + puVar9 = puVar10; + } + else { + if ((_uVar3 == 0) || (ip_data.current_iphdr_dest != 0xffffffff)) { + if (uVar7 != 0) goto LAB_23074cca; + } + else { + uVar6 = (inp->ip_addr).addr; + if (((puVar9->local_ip).addr != uVar6) && (uVar6 == uVar7)) goto LAB_23074cca; + } + } +LAB_23074cdc: + if (((uint)puVar10->remote_port == CONCAT22(extraout_var_01,uVar4)) && + ((uVar6 = (puVar10->remote_ip).addr, uVar6 == 0 || + (uVar6 == ip_data.current_iphdr_src)))) { + if (puVar8 == (udp_pcb *)0x0) { + lwip_stats.udp.cachehit = lwip_stats.udp.cachehit + 1; + } + else { + udp_pcbs = puVar10; + puVar8->next = puVar10->next; + puVar10->next = puVar1; + } + goto LAB_23074d00; + } + } + } + } + puVar2 = puVar10->next; + puVar8 = puVar10; + } + puVar10 = puVar9; + if ((puVar9 != (udp_pcb *)0x0) || ((inp->ip_addr).addr == ip_data.current_iphdr_dest)) { +LAB_23074d00: + if ((puVar11[3] == 0) || + (uVar5 = ip_chksum_pseudo(p,'\x11',p->tot_len,(ip4_addr_t *)&ip_data.current_iphdr_src, + (ip4_addr_t *)&ip_data.current_iphdr_dest), + CONCAT22(extraout_var_03,uVar5) == 0)) { + uVar3 = pbuf_remove_header(p,8); + if (CONCAT31(extraout_var_00,uVar3) == 0) { + if (puVar10 != (udp_pcb *)0x0) { + if (puVar10->recv != (udp_recv_fn *)0x0) { + // WARNING: Could not recover jumptable at 0x23074d8a. Too many branches + // WARNING: Treating indirect jump as call + (*puVar10->recv)(puVar10->recv_arg,puVar10,p,(ip_addr_t *)0x42026928,uVar4); + return; + } + goto LAB_23074be2; + } + if ((_uVar3 == 0) && ((ip_data.current_iphdr_dest & 0xf0) != 0xe0)) { + pbuf_header_force(p,(s16_t)(((uint)ip_data.current_ip_header_tot_len + 8) * 0x10000 >> + 0x10)); + icmp_dest_unreach(p,ICMP_DUR_PORT); + } + lwip_stats.udp.proterr = lwip_stats.udp.proterr + 1; + } + } + else { + lwip_stats.udp.chkerr = lwip_stats.udp.chkerr + 1; + } + lwip_stats.udp.drop = lwip_stats.udp.drop + 1; + } + } +LAB_23074be2: + pbuf_free(p); + return; +} + + + +err_t udp_bind(udp_pcb *pcb,ip_addr_t *ipaddr,u16_t port) + +{ + bool bVar1; + err_t eVar2; + undefined2 in_register_00002032; + u32_t uVar3; + udp_pcb *puVar4; + short sVar5; + + if (ipaddr == (ip_addr_t *)0x0) { + ipaddr = &ip_addr_any; + } + eVar2 = -0x10; + puVar4 = udp_pcbs; + if (pcb != (udp_pcb *)0x0) { + while (puVar4 != (udp_pcb *)0x0) { + if (puVar4 == pcb) { + bVar1 = true; + goto LAB_23074de2; + } + puVar4 = puVar4->next; + } + bVar1 = false; +LAB_23074de2: + puVar4 = udp_pcbs; + if (CONCAT22(in_register_00002032,port) == 0) { + sVar5 = 0x4000; + do { + puVar4 = udp_pcbs; + if (udp_port == 0xffff) { + port = 0xc000; + } + else { + port = udp_port + 1; + } + while( true ) { + udp_port = port; + if (puVar4 == (udp_pcb *)0x0) goto LAB_23074e0a; + if (puVar4->local_port == port) break; + puVar4 = puVar4->next; + } + sVar5 = sVar5 + -1; + if (sVar5 == 0) { + return -8; + } + } while( true ); + } + while (puVar4 != (udp_pcb *)0x0) { + if ((puVar4 != pcb) && + ((((pcb->so_options & 4) == 0 || ((puVar4->so_options & 4) == 0)) && + ((uint)puVar4->local_port == CONCAT22(in_register_00002032,port))))) { + uVar3 = (puVar4->local_ip).addr; + if (uVar3 == ipaddr->addr) { + return -8; + } + if (ipaddr->addr == 0) { + return -8; + } + if (uVar3 == 0) { + return -8; + } + } + puVar4 = puVar4->next; + } +LAB_23074e0a: + uVar3 = ipaddr->addr; + pcb->local_port = port; + (pcb->local_ip).addr = uVar3; + if (!bVar1) { + puVar4 = pcb; + pcb->next = udp_pcbs; + udp_pcbs = puVar4; + } + eVar2 = '\0'; + } + return eVar2; +} + + + +err_t udp_sendto_if_src_chksum + (udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif,u8_t have_chksum + ,u16_t chksum,ip_addr_t *src_ip) + +{ + u8_t ttl; + err_t eVar1; + u16_t uVar2; + undefined2 uVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + pbuf *h; + undefined2 extraout_var_01; + uint uVar4; + undefined2 extraout_var_02; + undefined3 in_register_0000203d; + undefined *puVar5; + + if (pcb == (udp_pcb *)0x0) { + return -0x10; + } + if (p == (pbuf *)0x0) { + return -0x10; + } + if (dst_ip == (ip_addr_t *)0x0) { + return -0x10; + } + if (src_ip == (ip_addr_t *)0x0) { + return -0x10; + } + if (netif == (netif *)0x0) { + return -0x10; + } + if ((pcb->local_port == 0) && + (eVar1 = udp_bind(pcb,(ip_addr_t *)pcb,0), CONCAT31(extraout_var,eVar1) != 0)) { + return eVar1; + } + if (p->tot_len < 0xfff8) { + ttl = pbuf_add_header(p,8); + h = p; + if (CONCAT31(extraout_var_00,ttl) != 0) { + h = pbuf_alloc(PBUF_IP,8,PBUF_RAM); + if (h == (pbuf *)0x0) goto LAB_23074ed0; + if (p->tot_len != 0) { + pbuf_chain(h,p); + } + } + puVar5 = (undefined *)h->payload; + uVar2 = lwip_htons(pcb->local_port); + *puVar5 = (char)uVar2; + puVar5[1] = (char)(uVar2 >> 8); + uVar2 = lwip_htons(dst_port); + puVar5[2] = (char)uVar2; + puVar5[3] = (char)(uVar2 >> 8); + puVar5[6] = 0; + puVar5[7] = 0; + if (((pcb->flags & 8) != 0) && ((dst_ip->addr & 0xf0) == 0xe0)) { + h->flags = h->flags | 4; + } + uVar2 = lwip_htons(h->tot_len); + puVar5[4] = (char)uVar2; + puVar5[5] = (char)(uVar2 >> 8); + if ((pcb->flags & 1) == 0) { + if (CONCAT31(in_register_0000203d,have_chksum) == 0) { + uVar2 = ip_chksum_pseudo(h,'\x11',h->tot_len,(ip4_addr_t *)src_ip,(ip4_addr_t *)dst_ip); + uVar4 = CONCAT22(extraout_var_02,uVar2); + } + else { + uVar2 = ip_chksum_pseudo_partial + (h,'\x11',h->tot_len,8,(ip4_addr_t *)src_ip,(ip4_addr_t *)dst_ip); + uVar4 = CONCAT22(extraout_var_01,uVar2) + (~(uint)chksum & 0xffff); + uVar4 = uVar4 + (uVar4 >> 0x10) & 0xffff; + } + uVar3 = (undefined2)uVar4; + if (uVar4 == 0) { + uVar3 = 0xffff; + } + puVar5[6] = (char)uVar3; + puVar5[7] = (char)((ushort)uVar3 >> 8); + } + if ((dst_ip->addr & 0xf0) == 0xe0) { + ttl = pcb->mcast_ttl; + } + else { + ttl = pcb->ttl; + } + eVar1 = ip4_output_if_src(h,(ip4_addr_t *)src_ip,(ip4_addr_t *)dst_ip,ttl,pcb->tos,'\x11',netif) + ; + if (h != p) { + pbuf_free(h); + } + lwip_stats.udp.xmit = lwip_stats.udp.xmit + 1; + } + else { +LAB_23074ed0: + eVar1 = -1; + } + return eVar1; +} + + + +err_t udp_sendto_if_chksum + (udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif,u8_t have_chksum + ,u16_t chksum) + +{ + err_t eVar1; + uint uVar2; + udp_pcb *src_ip; + + if ((((pcb != (udp_pcb *)0x0) && (p != (pbuf *)0x0)) && (dst_ip != (ip_addr_t *)0x0)) && + (netif != (netif *)0x0)) { + uVar2 = (pcb->local_ip).addr; + if ((uVar2 == 0) || ((uVar2 & 0xf0) == 0xe0)) { + src_ip = (udp_pcb *)&netif->ip_addr; + } + else { + src_ip = pcb; + if (uVar2 != (netif->ip_addr).addr) { + return -4; + } + } + eVar1 = udp_sendto_if_src_chksum + (pcb,p,dst_ip,dst_port,netif,have_chksum,chksum,(ip_addr_t *)src_ip); + return eVar1; + } + return -0x10; +} + + + +err_t udp_sendto_chksum(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,u8_t have_chksum, + u16_t chksum) + +{ + err_t eVar1; + netif *netif; + u32_t uVar2; + + if (((pcb == (udp_pcb *)0x0) || (p == (pbuf *)0x0)) || (dst_ip == (ip_addr_t *)0x0)) { + return -0x10; + } + if (pcb->netif_idx == '\0') { + if ((dst_ip->addr & 0xf0) == 0xe0) { + if (pcb->mcast_ifindex == '\0') { + uVar2 = (pcb->mcast_ip4).addr; + if ((uVar2 == 0) || (uVar2 == 0xffffffff)) goto LAB_230750c4; + netif = ip4_route(&pcb->mcast_ip4); + } + else { + netif = netif_get_by_index(pcb->mcast_ifindex); + } + if (netif != (netif *)0x0) goto LAB_230750d8; + } +LAB_230750c4: + netif = ip4_route((ip4_addr_t *)dst_ip); + } + else { + netif = netif_get_by_index(pcb->netif_idx); + } + if (netif == (netif *)0x0) { + lwip_stats.udp.rterr = lwip_stats.udp.rterr + 1; + return -4; + } +LAB_230750d8: + eVar1 = udp_sendto_if_chksum(pcb,p,dst_ip,dst_port,netif,have_chksum,chksum); + return eVar1; +} + + + +err_t udp_send_chksum(udp_pcb *pcb,pbuf *p,u8_t have_chksum,u16_t chksum) + +{ + err_t eVar1; + + if ((pcb != (udp_pcb *)0x0) && (p != (pbuf *)0x0)) { + eVar1 = udp_sendto_chksum(pcb,p,&pcb->remote_ip,pcb->remote_port,have_chksum,chksum); + return eVar1; + } + return -0x10; +} + + + +err_t udp_sendto(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port) + +{ + err_t eVar1; + + eVar1 = udp_sendto_chksum(pcb,p,dst_ip,dst_port,'\0',0); + return eVar1; +} + + + +err_t udp_send(udp_pcb *pcb,pbuf *p) + +{ + err_t eVar1; + + if ((pcb != (udp_pcb *)0x0) && (p != (pbuf *)0x0)) { + eVar1 = udp_sendto(pcb,p,&pcb->remote_ip,pcb->remote_port); + return eVar1; + } + return -0x10; +} + + + +err_t udp_sendto_if(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif) + +{ + err_t eVar1; + + eVar1 = udp_sendto_if_chksum(pcb,p,dst_ip,dst_port,netif,'\0',0); + return eVar1; +} + + + +err_t udp_sendto_if_src(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif, + ip_addr_t *src_ip) + +{ + err_t eVar1; + + eVar1 = udp_sendto_if_src_chksum(pcb,p,dst_ip,dst_port,netif,'\0',0,src_ip); + return eVar1; +} + + + +void udp_bind_netif(udp_pcb *pcb,netif *netif) + +{ + u8_t uVar1; + + uVar1 = '\0'; + if (netif != (netif *)0x0) { + uVar1 = netif->num + '\x01'; + } + pcb->netif_idx = uVar1; + return; +} + + + +err_t udp_connect(udp_pcb *pcb,ip_addr_t *ipaddr,u16_t port) + +{ + err_t eVar1; + undefined3 extraout_var; + udp_pcb *puVar2; + u32_t uVar3; + + if ((pcb == (udp_pcb *)0x0) || (ipaddr == (ip_addr_t *)0x0)) { + return -0x10; + } + if ((pcb->local_port != 0) || + (eVar1 = udp_bind(pcb,(ip_addr_t *)pcb,0), CONCAT31(extraout_var,eVar1) == 0)) { + uVar3 = ipaddr->addr; + pcb->remote_port = port; + (pcb->remote_ip).addr = uVar3; + pcb->flags = pcb->flags | 4; + puVar2 = udp_pcbs; + while (puVar2 != (udp_pcb *)0x0) { + if (puVar2 == pcb) goto LAB_230751b4; + puVar2 = puVar2->next; + } + pcb->next = udp_pcbs; + udp_pcbs = pcb; +LAB_230751b4: + eVar1 = '\0'; + } + return eVar1; +} + + + +void udp_disconnect(udp_pcb *pcb) + +{ + byte bVar1; + + if (pcb != (udp_pcb *)0x0) { + bVar1 = pcb->flags; + (pcb->remote_ip).addr = 0; + pcb->remote_port = 0; + pcb->netif_idx = '\0'; + pcb->flags = bVar1 & 0xfb; + } + return; +} + + + +void udp_recv(udp_pcb *pcb,udp_recv_fn *recv,void *recv_arg) + +{ + if (pcb != (udp_pcb *)0x0) { + pcb->recv = recv; + pcb->recv_arg = recv_arg; + } + return; +} + + + +void udp_remove(udp_pcb *pcb) + +{ + udp_pcb *puVar1; + udp_pcb *puVar2; + + if (pcb == (udp_pcb *)0x0) { + return; + } + puVar1 = udp_pcbs; + if (udp_pcbs == pcb) { + udp_pcbs = pcb->next; + } + else { + do { + puVar2 = puVar1; + if ((puVar2 == (udp_pcb *)0x0) || (puVar1 = puVar2->next, puVar1 == (udp_pcb *)0x0)) + goto LAB_23075216; + } while (puVar1 != pcb); + puVar2->next = pcb->next; + } +LAB_23075216: + memp_free(MEMP_UDP_PCB,pcb); + return; +} + + + +udp_pcb * udp_new(void) + +{ + udp_pcb *__s; + + __s = (udp_pcb *)memp_malloc(MEMP_UDP_PCB); + if (__s != (udp_pcb *)0x0) { + memset(__s,0,0x28); + __s->ttl = -1; + __s->mcast_ttl = -1; + } + return __s; +} + + + +udp_pcb * udp_new_ip_type(void) + +{ + udp_pcb *__s; + + __s = (udp_pcb *)memp_malloc(MEMP_UDP_PCB); + if (__s != (udp_pcb *)0x0) { + memset(__s,0,0x28); + __s->ttl = -1; + __s->mcast_ttl = -1; + } + return __s; +} + + + +void udp_netif_ip_addr_changed(ip_addr_t *old_addr,ip_addr_t *new_addr) + +{ + udp_pcb *puVar1; + + if ((((old_addr != (ip_addr_t *)0x0) && (old_addr->addr != 0)) && (new_addr != (ip_addr_t *)0x0)) + && (puVar1 = udp_pcbs, new_addr->addr != 0)) { + while (puVar1 != (udp_pcb *)0x0) { + if ((puVar1->local_ip).addr == old_addr->addr) { + (puVar1->local_ip).addr = new_addr->addr; + } + puVar1 = puVar1->next; + } + } + return; +} + + + +err_t ethernet_input(pbuf *p,netif *netif) + +{ + short sVar1; + u8_t uVar2; + byte *__s1; + undefined3 extraout_var; + int iVar3; + undefined3 extraout_var_00; + byte bVar4; + + if (p->len < 0xf) { +LAB_230752a0: + lwip_stats.etharp.proterr = lwip_stats.etharp.proterr + 1; + } + else { + if (p->if_idx == '\0') { + p->if_idx = netif->num + '\x01'; + } + __s1 = (byte *)p->payload; + sVar1 = *(short *)(__s1 + 0xc); + if ((*__s1 & 1) != 0) { + if (*__s1 == 1) { + if ((__s1[1] == 0) && (__s1[2] == 0x5e)) { + bVar4 = p->flags | 0x10; +LAB_230752fe: + p->flags = bVar4; + } + } + else { + iVar3 = memcmp(__s1,ðbroadcast,6); + if (iVar3 == 0) { + bVar4 = p->flags | 8; + goto LAB_230752fe; + } + } + } + if (sVar1 == 8) { + if (((netif->flags & 8) != 0) && + (uVar2 = pbuf_remove_header(p,0xe), CONCAT31(extraout_var_00,uVar2) == 0)) { + ip4_input(p,netif); + return '\0'; + } + goto free_and_return; + } + if (sVar1 != 0x608) goto LAB_230752a0; + if ((netif->flags & 8) == 0) goto free_and_return; + uVar2 = pbuf_remove_header(p,0xe); + if (CONCAT31(extraout_var,uVar2) == 0) { + etharp_input(p,netif); + return '\0'; + } + lwip_stats.etharp.lenerr = lwip_stats.etharp.lenerr + 1; + } + lwip_stats.etharp.drop = lwip_stats.etharp.drop + 1; +free_and_return: + pbuf_free(p); + return '\0'; +} + + + +err_t ethernet_output(netif *netif,pbuf *p,eth_addr *src,eth_addr *dst,u16_t eth_type) + +{ + void *__dest; + u8_t uVar1; + err_t eVar2; + u16_t uVar3; + undefined3 extraout_var; + + uVar3 = lwip_htons(eth_type); + uVar1 = pbuf_add_header(p,0xe); + if (CONCAT31(extraout_var,uVar1) == 0) { + __dest = p->payload; + *(undefined *)((int)__dest + 0xc) = (char)uVar3; + *(undefined *)((int)__dest + 0xd) = (char)(uVar3 >> 8); + memcpy(__dest,dst,6); + memcpy((void *)((int)__dest + 6),src,6); + // WARNING: Could not recover jumptable at 0x230753f6. Too many branches + // WARNING: Treating indirect jump as call + eVar2 = (*netif->linkoutput)(netif,p); + return eVar2; + } + lwip_stats.link.lenerr = lwip_stats.link.lenerr + 1; + return -2; +} + + + +err_t netconn_apimsg(tcpip_callback_fn_conflict *fn,api_msg *apimsg) + +{ + err_t eVar1; + undefined3 extraout_var; + + eVar1 = tcpip_send_msg_wait_sem((tcpip_callback_fn)fn,apimsg,&apimsg->conn->op_completed); + if (CONCAT31(extraout_var,eVar1) == 0) { + eVar1 = apimsg->err; + } + return eVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_close_shutdown(netconn *conn,u8_t how) + +{ + err_t eVar1; + netconn *pnStack52; + api_msg msg; + + if (conn != (netconn *)0x0) { + pnStack52 = conn; + msg.err = how; + msg.msg._0_4_ = sys_now(); + eVar1 = netconn_apimsg(lwip_netconn_do_close,(api_msg *)&pnStack52); + return eVar1; + } + return -0x10; +} + + + +// WARNING: Variable defined which should be unmapped: msg + +netconn * netconn_new_with_proto_and_callback(netconn_type t,u8_t proto,netconn_callback *callback) + +{ + err_t eVar1; + netconn *mem; + undefined3 extraout_var; + netconn *pnStack52; + api_msg msg; + + mem = netconn_alloc(t,callback); + if (mem != (netconn *)0x0) { + pnStack52 = mem; + msg.err = proto; + eVar1 = netconn_apimsg(lwip_netconn_do_newconn,(api_msg *)&pnStack52); + if (CONCAT31(extraout_var,eVar1) != 0) { + sys_mbox_valid(&mem->recvmbox); + sys_mbox_valid(&mem->acceptmbox); + sys_sem_valid(&mem->op_completed); + sys_sem_free(&mem->op_completed); + sys_mbox_free(&mem->recvmbox); + memp_free(MEMP_NETCONN,mem); + mem = (netconn *)0x0; + } + } + return mem; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_prepare_delete(netconn *conn) + +{ + err_t eVar1; + netconn *pnStack52; + api_msg msg; + + if (conn != (netconn *)0x0) { + pnStack52 = conn; + msg.msg._0_4_ = sys_now(); + eVar1 = netconn_apimsg(lwip_netconn_do_delconn,(api_msg *)&pnStack52); + return eVar1; + } + return '\0'; +} + + + +err_t netconn_delete(netconn *conn) + +{ + err_t eVar1; + undefined3 extraout_var; + + eVar1 = '\0'; + if ((conn != (netconn *)0x0) && + (eVar1 = netconn_prepare_delete(conn), CONCAT31(extraout_var,eVar1) == 0)) { + netconn_free(conn); + } + return eVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_getaddr(netconn *conn,ip_addr_t *addr,u16_t *port,u8_t local) + +{ + err_t eVar1; + netconn *pnStack52; + api_msg msg; + + if (conn == (netconn *)0x0) { + return -0x10; + } + if ((addr != (ip_addr_t *)0x0) && (port != (u16_t *)0x0)) { + pnStack52 = conn; + msg._4_4_ = addr; + msg.msg._0_4_ = port; + msg.msg[4] = local; + eVar1 = netconn_apimsg(lwip_netconn_do_getaddr,(api_msg *)&pnStack52); + return eVar1; + } + return -0x10; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_bind(netconn *conn,ip_addr_t *addr,u16_t port) + +{ + err_t eVar1; + netconn *pnStack52; + api_msg msg; + + if (conn != (netconn *)0x0) { + if (addr == (ip_addr_t *)0x0) { + addr = &ip_addr_any; + } + pnStack52 = conn; + msg._4_4_ = addr; + msg.msg._0_2_ = port; + eVar1 = netconn_apimsg(lwip_netconn_do_bind,(api_msg *)&pnStack52); + return eVar1; + } + return -0x10; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_connect(netconn *conn,ip_addr_t *addr,u16_t port) + +{ + err_t eVar1; + netconn *pnStack52; + api_msg msg; + + if (conn != (netconn *)0x0) { + if (addr == (ip_addr_t *)0x0) { + addr = &ip_addr_any; + } + pnStack52 = conn; + msg._4_4_ = addr; + msg.msg._0_2_ = port; + eVar1 = netconn_apimsg(lwip_netconn_do_connect,(api_msg *)&pnStack52); + return eVar1; + } + return -0x10; +} + + + +err_t netconn_disconnect(netconn *conn) + +{ + err_t eVar1; + netconn *pnStack52; + api_msg msg; + + if (conn != (netconn *)0x0) { + pnStack52 = conn; + eVar1 = netconn_apimsg(lwip_netconn_do_disconnect,(api_msg *)&pnStack52); + return eVar1; + } + return -0x10; +} + + + +err_t netconn_listen_with_backlog(netconn *conn,u8_t backlog) + +{ + err_t eVar1; + netconn *pnStack52; + api_msg msg; + + if (conn != (netconn *)0x0) { + pnStack52 = conn; + eVar1 = netconn_apimsg(lwip_netconn_do_listen,(api_msg *)&pnStack52); + return eVar1; + } + return -0x10; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_tcp_recvd(netconn *conn,size_t len) + +{ + err_t eVar1; + netconn *pnStack52; + api_msg msg; + + if (conn == (netconn *)0x0) { + return -0x10; + } + if ((conn->type & 0xf0) == NETCONN_TCP) { + pnStack52 = conn; + msg._4_4_ = len; + eVar1 = netconn_apimsg(lwip_netconn_do_recv,(api_msg *)&pnStack52); + return eVar1; + } + return -0x10; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_send(netconn *conn,netbuf *buf) + +{ + err_t eVar1; + netconn *pnStack52; + api_msg msg; + + if (conn != (netconn *)0x0) { + pnStack52 = conn; + msg._4_4_ = buf; + eVar1 = netconn_apimsg(lwip_netconn_do_send,(api_msg *)&pnStack52); + return eVar1; + } + return -0x10; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_write_vectors_partly + (netconn *conn,netvector *vectors,u16_t vectorcnt,u8_t apiflags, + size_t *bytes_written) + +{ + err_t eVar1; + int iVar2; + undefined3 extraout_var; + undefined2 in_register_00002032; + size_t *psVar3; + uint uVar4; + netconn *pnStack52; + api_msg msg; + + if (conn == (netconn *)0x0) { + return -0x10; + } + eVar1 = -6; + if ((conn->type & 0xf0) == NETCONN_TCP) { + if ((((uint)((conn->flags & 2 | apiflags & 4) != 0) | conn->send_timeout) != 0) && + (bytes_written == (size_t *)0x0)) { + return -6; + } + psVar3 = &vectors->len; + iVar2 = 0; + msg.msg._8_4_ = 0; + while (iVar2 < CONCAT22(in_register_00002032,vectorcnt)) { + uVar4 = *psVar3; + psVar3 = psVar3 + 2; + msg.msg._8_4_ = msg.msg._8_4_ + uVar4; + if (msg.msg._8_4_ < uVar4) { + return -6; + } + iVar2 = iVar2 + 1; + } + if (msg.msg._8_4_ != 0) { + if ((int)msg.msg._8_4_ < 0) { + if (bytes_written == (size_t *)0x0) { + return -6; + } + msg.msg._8_4_ = 0x7fffffff; + } + msg.msg._4_4_ = 0; + msg.msg._12_4_ = 0; + pnStack52 = conn; + msg._4_4_ = vectors; + msg.msg._0_2_ = vectorcnt; + msg.msg[16] = apiflags; + if (conn->send_timeout == 0) { + msg.msg._20_4_ = 0; + } + else { + msg.msg._20_4_ = sys_now(); + } + eVar1 = netconn_apimsg(lwip_netconn_do_write,(api_msg *)&pnStack52); + if (CONCAT31(extraout_var,eVar1) == 0) { + if (bytes_written == (size_t *)0x0) { + eVar1 = '\0'; + } + else { + *bytes_written = msg.msg._12_4_; + } + } + return eVar1; + } + eVar1 = '\0'; + } + return eVar1; +} + + + +err_t netconn_write_partly + (netconn *conn,void *dataptr,size_t size,u8_t apiflags,size_t *bytes_written) + +{ + err_t eVar1; + void *pvStack24; + netvector vector; + + pvStack24 = dataptr; + vector.ptr = (void *)size; + eVar1 = netconn_write_vectors_partly(conn,(netvector *)&pvStack24,1,apiflags,bytes_written); + return eVar1; +} + + + +err_t netconn_err(netconn *conn) + +{ + err_t eVar1; + + eVar1 = '\0'; + if (conn != (netconn *)0x0) { + sys_arch_protect(); + eVar1 = conn->pending_err; + conn->pending_err = '\0'; + sys_arch_unprotect(); + } + return eVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_accept(netconn *conn,netconn **new_conn) + +{ + err_t eVar1; + undefined3 extraout_var; + int iVar2; + u32_t uVar3; + sys_mbox_t *mbox; + err_t eStack37; + err_t err; + netconn *pnStack36; + void *accept_ptr; + + if ((new_conn == (netconn **)0x0) || (*new_conn = (netconn *)0x0, conn == (netconn *)0x0)) { + eVar1 = -0x10; + } + else { + eVar1 = netconn_err(conn); + if (CONCAT31(extraout_var,eVar1) == 0) { + mbox = &conn->acceptmbox; + eStack37 = eVar1; + iVar2 = sys_mbox_valid(mbox); + if ((iVar2 != 0) && ((conn->flags & 1) == 0)) { + if ((conn->flags & 2) == 0) { + uVar3 = sys_arch_mbox_fetch(mbox,(void **)&stack0xffffffdc,conn->recv_timeout); + if (uVar3 == 0xffffffff) { + return -3; + } + } + else { + uVar3 = sys_arch_mbox_tryfetch(mbox,(void **)&stack0xffffffdc); + if (uVar3 == 0xffffffff) { + return -7; + } + } + if (conn->callback != (netconn_callback *)0x0) { + (*conn->callback)(conn,NETCONN_EVT_RCVMINUS,0); + } + iVar2 = lwip_netconn_is_err_msg(pnStack36,&eStack37); + if (iVar2 != 0) { + return eStack37; + } + if (pnStack36 != (netconn *)0x0) { + *new_conn = pnStack36; + return eVar1; + } + } + eVar1 = -0xf; + } + } + return eVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_recv_data(netconn *conn,void **new_buf,u8_t apiflags) + +{ + err_t eVar1; + int iVar2; + undefined3 extraout_var; + u32_t uVar3; + undefined3 extraout_var_00; + void **ppvVar4; + sys_mbox_t *mbox; + err_t eStack37; + err_t err; + void **msg; + void *buf; + + msg = (void **)0x0; + if ((new_buf == (void **)0x0) || (*new_buf = (void *)0x0, conn == (netconn *)0x0)) { + return -0x10; + } + mbox = &conn->recvmbox; + iVar2 = sys_mbox_valid(mbox); + if (iVar2 == 0) { + eVar1 = netconn_err(conn); + if (CONCAT31(extraout_var,eVar1) == 0) { + return -0xb; + } + return eVar1; + } + if (((apiflags & 4 | conn->flags & 3) == 0) && (conn->pending_err == '\0')) { + uVar3 = sys_arch_mbox_fetch(mbox,(void **)&stack0xffffffdc,conn->recv_timeout); + if (uVar3 == 0xffffffff) { + return -3; + } + } + else { + uVar3 = sys_arch_mbox_tryfetch(mbox,(void **)&stack0xffffffdc); + if (uVar3 == 0xffffffff) { + eVar1 = netconn_err(conn); + if (CONCAT31(extraout_var_00,eVar1) != 0) { + return eVar1; + } + if ((conn->flags & 1) != 0) { + return -0xb; + } + return -7; + } + } + if ((conn->type & 0xf0) == NETCONN_TCP) { + iVar2 = lwip_netconn_is_err_msg(msg,&eStack37); + ppvVar4 = msg; + if (iVar2 != 0) { + if (eStack37 == -0xf) { + return '\0'; + } + return eStack37; + } + } + else { + ppvVar4 = (void **)*msg; + } + if (conn->callback != (netconn_callback *)0x0) { + (*conn->callback)(conn,NETCONN_EVT_RCVMINUS,*(u16_t *)(ppvVar4 + 2)); + } + *(void ***)new_buf = msg; + return '\0'; +} + + + +err_t netconn_recv_udp_raw_netbuf_flags(netconn *conn,netbuf **new_buf,u8_t apiflags) + +{ + err_t eVar1; + + if ((conn != (netconn *)0x0) && ((conn->type & 0xf0) != NETCONN_TCP)) { + eVar1 = netconn_recv_data(conn,new_buf,apiflags); + return eVar1; + } + return -0x10; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_recv_data_tcp(netconn *conn,pbuf **new_buf,u8_t apiflags) + +{ + err_t eVar1; + int iVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint uVar3; + pbuf *ppVar4; + netconn *pnStack68; + api_msg msg; + + iVar2 = sys_mbox_valid(&conn->recvmbox); + if (iVar2 == 0) { + return -0xb; + } + if ((char)conn->flags < '\0') { + conn->flags = conn->flags & 0x7f; + } + else { + eVar1 = netconn_recv_data(conn,new_buf,apiflags); + if (CONCAT31(extraout_var_00,eVar1) != 0) { + return eVar1; + } + ppVar4 = *new_buf; + if ((apiflags & 8) == 0) { + uVar3 = 1; + if (ppVar4 != (pbuf *)0x0) { + uVar3 = (uint)ppVar4->tot_len; + } + if ((conn->type & 0xf0) == NETCONN_TCP) { + pnStack68 = conn; + msg._4_4_ = uVar3; + netconn_apimsg(lwip_netconn_do_recv,(api_msg *)&pnStack68); + } + } + if (ppVar4 != (pbuf *)0x0) { + return eVar1; + } + if ((apiflags & 0x10) != 0) { + conn->flags = conn->flags | 0x80; + return -7; + } + } + if (conn->callback != (netconn_callback *)0x0) { + (*conn->callback)(conn,NETCONN_EVT_RCVMINUS,0); + } + if (conn->pcb == 0) { + eVar1 = netconn_err(conn); + if (CONCAT31(extraout_var,eVar1) == 0) { + eVar1 = -0xe; + } + } + else { + netconn_close_shutdown(conn,'\x01'); + eVar1 = -0xf; + } + return eVar1; +} + + + +err_t netconn_recv_tcp_pbuf_flags(netconn *conn,pbuf **new_buf,u8_t apiflags) + +{ + err_t eVar1; + + if ((conn != (netconn *)0x0) && ((conn->type & 0xf0) == NETCONN_TCP)) { + eVar1 = netconn_recv_data_tcp(conn,new_buf,apiflags); + return eVar1; + } + return -0x10; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_join_leave_group + (netconn *conn,ip_addr_t *multiaddr,ip_addr_t *netif_addr,netconn_igmp join_or_leave + ) + +{ + err_t eVar1; + netconn *pnStack52; + api_msg msg; + + if (conn != (netconn *)0x0) { + if (multiaddr == (ip_addr_t *)0x0) { + multiaddr = &ip_addr_any; + } + if (netif_addr == (ip_addr_t *)0x0) { + netif_addr = &ip_addr_any; + } + pnStack52 = conn; + msg._4_4_ = multiaddr; + msg.msg._0_4_ = netif_addr; + msg.msg[5] = join_or_leave; + eVar1 = netconn_apimsg(lwip_netconn_do_join_leave_group,(api_msg *)&pnStack52); + return eVar1; + } + return -0x10; +} + + + +err_t netconn_gethostbyname(char *name,ip_addr_t *addr) + +{ + err_t eVar1; + err_t eVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined auStack36 [3]; + err_t err; + sys_sem_t sem; + dns_api_msg msg; + + eVar2 = -0x10; + if ((name != (char *)0x0) && (addr != (ip_addr_t *)0x0)) { + sem = (sys_sem_t)name; + eVar1 = sys_sem_new((sys_sem_t *)auStack36,'\0'); + eVar2 = eVar1; + if (CONCAT31(extraout_var,eVar1) == 0) { + eVar2 = tcpip_send_msg_wait_sem(lwip_netconn_do_gethostbyname,&sem,(sys_sem_t *)auStack36); + sys_sem_free((sys_sem_t *)auStack36); + if (CONCAT31(extraout_var_00,eVar2) == 0) { + eVar2 = eVar1; + } + } + } + return eVar2; +} + + + +void lwip_netconn_do_dns_found(char *name,ip_addr_t *ipaddr,void *arg) + +{ + if (ipaddr == (ip_addr_t *)0x0) { + **(undefined **)((int)arg + 0xc) = 0xfa; + } + else { + **(undefined **)((int)arg + 0xc) = 0; + **(u32_t **)((int)arg + 4) = ipaddr->addr; + } + sys_sem_signal((sys_mutex_t *)*(sys_mutex_t *)((int)arg + 8)); + return; +} + + + +void recv_udp(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port) + +{ + ushort uVar1; + err_t eVar2; + int iVar3; + netbuf *buf; + undefined3 extraout_var; + u32_t uVar4; + + if (arg != (void *)0x0) { + iVar3 = sys_mbox_valid((sys_mbox_t *)((int)arg + 0x10)); + if ((iVar3 != 0) && (buf = (netbuf *)memp_malloc(MEMP_NETBUF), buf != (netbuf *)0x0)) { + buf->p = p; + buf->ptr = p; + uVar4 = 0; + if (addr != (ip_addr_t *)0x0) { + uVar4 = addr->addr; + } + (buf->addr).addr = uVar4; + buf->port = port; + uVar1 = p->tot_len; + eVar2 = sys_mbox_trypost((sys_mbox_t *)((int)arg + 0x10),buf); + if (CONCAT31(extraout_var,eVar2) != 0) { + netbuf_delete(buf); + return; + } + if (*(code **)((int)arg + 0x2c) != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x23075b00. Too many branches + // WARNING: Treating indirect jump as call + (**(code **)((int)arg + 0x2c))(arg,0,(uint)uVar1); + return; + } + return; + } + } + pbuf_free(p); + return; +} + + + +void setup_tcp(netconn *conn) + +{ + tcp_pcb *pcb; + + pcb = (tcp_pcb *)conn->pcb; + tcp_arg(pcb,conn); + tcp_recv(pcb,recv_tcp); + tcp_sent(pcb,sent_tcp); + tcp_poll(pcb,poll_tcp,'\x02'); + tcp_err(pcb,err_tcp); + return; +} + + + +err_t lwip_netconn_do_connected(void *arg,tcp_pcb *pcb,err_t err) + +{ + byte bVar1; + err_t eVar2; + sys_mutex_t mutex; + undefined3 in_register_00002031; + + eVar2 = -6; + if (arg != (void *)0x0) { + mutex = *(sys_mutex_t *)((int)arg + 0x28); + if (mutex != (sys_mutex_t)0x0) { + *(err_t *)&mutex->pcWriteTo = err; + mutex = (sys_mutex_t)(**(int **)((int)arg + 0x28) + 0xc); + } + if (((*(byte *)arg & 0xf0) == 0x10) && (CONCAT31(in_register_00002031,err) == 0)) { + setup_tcp((netconn *)arg); + } + bVar1 = *(byte *)((int)arg + 0x24); + *(undefined4 *)((int)arg + 0x28) = 0; + *(undefined *)((int)arg + 1) = 0; + *(byte *)((int)arg + 0x24) = bVar1 & 0xfb; + if (*(code **)((int)arg + 0x2c) != (code *)0x0) { + (**(code **)((int)arg + 0x2c))(arg,2,0); + } + eVar2 = '\0'; + if ((bVar1 & 4) == 0) { + sys_sem_signal((sys_mutex_t *)mutex); + } + } + return eVar2; +} + + + +void err_tcp(void *arg,err_t err) + +{ + char cVar1; + byte bVar2; + sys_sem_t *sem; + int iVar3; + uint uVar4; + void *msg; + + sys_arch_protect(); + cVar1 = *(char *)((int)arg + 1); + *(undefined4 *)((int)arg + 4) = 0; + *(byte *)((int)arg + 0x24) = *(byte *)((int)arg + 0x24) | 1; + *(err_t *)((int)arg + 8) = err; + *(undefined *)((int)arg + 1) = 0; + sys_arch_unprotect(); + if (*(code **)((int)arg + 0x2c) != (code *)0x0) { + (**(code **)((int)arg + 0x2c))(arg,4,0); + } + if (*(code **)((int)arg + 0x2c) != (code *)0x0) { + (**(code **)((int)arg + 0x2c))(arg,0,0); + } + if (*(code **)((int)arg + 0x2c) != (code *)0x0) { + (**(code **)((int)arg + 0x2c))(arg,2,0); + } + uVar4 = (uint)(byte)err + 0xf & 0xff; + msg = (void *)0x0; + if (uVar4 < 3) { + msg = *(void **)(CSWTCH_13 + uVar4 * 4); + } + iVar3 = sys_mbox_valid((sys_mbox_t *)((int)arg + 0x10)); + if (iVar3 != 0) { + sys_mbox_trypost((sys_mbox_t *)((int)arg + 0x10),msg); + } + iVar3 = sys_mbox_valid((sys_mbox_t *)((int)arg + 0x14)); + if (iVar3 != 0) { + sys_mbox_trypost((sys_mbox_t *)((int)arg + 0x14),msg); + } + if (((cVar1 == '\x01') || ((byte)(cVar1 - 3U) < 2)) && + (bVar2 = *(byte *)((int)arg + 0x24), *(byte *)((int)arg + 0x24) = bVar2 & 0xfb, + (bVar2 & 4) == 0)) { + if (cVar1 == '\x04') { + err = '\0'; + } + *(err_t *)(*(int *)((int)arg + 0x28) + 4) = err; + sem = (sys_sem_t *)(**(int **)((int)arg + 0x28) + 0xc); + sys_sem_valid(sem); + *(undefined4 *)((int)arg + 0x28) = 0; + sys_sem_signal((sys_mutex_t *)sem); + return; + } + return; +} + + + +err_t lwip_netconn_do_writemore(netconn *conn) + +{ + ushort uVar1; + bool bVar2; + err_t eVar3; + TickType_t TVar4; + netconn *pnVar5; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + uint uVar6; + api_msg *paVar7; + int iVar8; + uint uVar9; + int iVar10; + uint uVar11; + byte apiflags; + byte bVar12; + + apiflags = conn->current_msg->msg[0x14]; + bVar12 = conn->flags & 2 | apiflags & 4; + if (conn->send_timeout == 0) { +LAB_23075d3a: + do { + paVar7 = conn->current_msg; + uVar9 = (*(int **)paVar7->msg)[1] - *(int *)(paVar7->msg + 8); + if (uVar9 < 0x10000) { + uVar11 = uVar9 & 0xffff; + } + else { + apiflags = apiflags | 2; + uVar11 = 0xffff; + } + uVar1 = ((tcp_pcb *)conn->pcb)->snd_buf; + uVar6 = (uint)uVar1; + if (uVar6 < uVar11) { + if (bVar12 == 0) { + apiflags = apiflags | 2; + } + else { + if (uVar1 == 0) { + iVar8 = -7; + if (*(int *)(paVar7->msg + 0x10) != 0) { + iVar8 = 0; + } + goto LAB_23075d72; + } + } +LAB_23075dd0: + bVar2 = false; + if (((uVar9 & 0xffff) == uVar6) && (1 < *(ushort *)(paVar7->msg + 4))) goto LAB_23075de2; + } + else { + uVar6 = uVar11; + if ((uVar11 != 0xffff) || (uVar9 < 0x10000)) goto LAB_23075dd0; +LAB_23075de2: + apiflags = apiflags | 2; + bVar2 = true; + } + eVar3 = tcp_write((tcp_pcb *)conn->pcb, + (void *)(**(int **)paVar7->msg + *(int *)(paVar7->msg + 8)),(u16_t)uVar6, + apiflags); + iVar8 = CONCAT31(extraout_var_00,eVar3); + if (iVar8 != 0) { + if (1 < (iVar8 + 1U & 0xff)) goto LAB_23075d22; + iVar8 = -1; + break; + } + *(uint *)(conn->current_msg->msg + 0x10) = *(int *)(conn->current_msg->msg + 0x10) + uVar6; + *(uint *)(conn->current_msg->msg + 8) = uVar6 + *(int *)(conn->current_msg->msg + 8); + paVar7 = conn->current_msg; + if (*(int *)(paVar7->msg + 8) == *(int *)(*(int *)paVar7->msg + 4)) { + *(short *)(paVar7->msg + 4) = *(short *)(paVar7->msg + 4) + -1; + paVar7 = conn->current_msg; + if (*(short *)(paVar7->msg + 4) != 0) { + *(int *)paVar7->msg = *(int *)paVar7->msg + 8; + *(undefined4 *)(conn->current_msg->msg + 8) = 0; + } + } + } while (bVar2); + if (bVar12 == 0) { +LAB_23075e4a: + if (((*(ushort *)(conn->pcb + 100) < 0xac1) || (7 < *(ushort *)(conn->pcb + 0x66))) && + (conn->callback != (netconn_callback *)0x0)) { + (*conn->callback)(conn,NETCONN_EVT_SENDMINUS,0); + } + } + else { +LAB_23075d72: + if (*(uint *)(conn->current_msg->msg + 0xc) <= *(uint *)(conn->current_msg->msg + 0x10)) + goto LAB_23075e4a; + if (conn->callback != (netconn_callback *)0x0) { + (*conn->callback)(conn,NETCONN_EVT_SENDMINUS,0); + } + conn->flags = conn->flags | 0x10; + } + eVar3 = (err_t)iVar8; + if (iVar8 != 0) { + if (iVar8 != -1) goto LAB_23075d22; + eVar3 = tcp_output((tcp_pcb *)conn->pcb); + if (CONCAT31(extraout_var_01,eVar3) == -4) goto LAB_23075db2; + if (bVar12 == 0) { + return '\0'; + } + iVar8 = *(int *)(conn->current_msg->msg + 0x10); + goto LAB_23075d1c; + } + iVar8 = *(int *)(conn->current_msg->msg + 0x10); + iVar10 = *(int *)(conn->current_msg->msg + 0xc); + eVar3 = tcp_output((tcp_pcb *)conn->pcb); + if (CONCAT31(extraout_var,eVar3) == -4) { +LAB_23075db2: + eVar3 = -4; + goto LAB_23075d22; + } + if (iVar8 != iVar10 && bVar12 == 0) { + return '\0'; + } + } + else { + TVar4 = sys_now(); + if ((int)(TVar4 - *(int *)(conn->current_msg->msg + 0x18)) < conn->send_timeout) + goto LAB_23075d3a; + iVar8 = *(int *)(conn->current_msg->msg + 0x10); +LAB_23075d1c: + eVar3 = -7; + if (iVar8 == 0) goto LAB_23075d22; + } + eVar3 = '\0'; +LAB_23075d22: + pnVar5 = conn->current_msg->conn; + conn->current_msg->err = eVar3; + conn->current_msg = (api_msg *)0x0; + conn->state = NETCONN_NONE; + sys_sem_signal((sys_mutex_t *)&pnVar5->op_completed); + return '\0'; +} + + + +err_t lwip_netconn_do_close_internal(netconn *conn) + +{ + byte bVar1; + bool bVar2; + tcp_pcb *pcb; + netconn *pnVar3; + err_t eVar4; + undefined3 extraout_var; + undefined3 extraout_var_00; + TickType_t TVar5; + int iVar6; + int iVar7; + + bVar1 = conn->current_msg->msg[0]; + pcb = (tcp_pcb *)conn->pcb; + if (((bVar1 == 3) || + (((bVar1 & 1) != 0 && (((byte)(pcb->state + ~ESTABLISHED) < 2 || (pcb->state == CLOSING)))))) + || ((bVar2 = false, (bVar1 & 2) != 0 && ((pcb->flags & 0x10) != 0)))) { + tcp_arg(pcb,(void *)0x0); + bVar2 = true; + } + if (pcb->state == LISTEN) { + tcp_accept(pcb,(tcp_accept_fn)0x0); + if (!bVar2) { +LAB_23075f20: + eVar4 = tcp_shutdown(pcb,(uint)bVar1 & 1,(uint)bVar1 & 2); + iVar6 = CONCAT31(extraout_var,eVar4); + goto LAB_23075f68; + } + } + else { + if ((bVar1 & 1) != 0) { + tcp_recv(pcb,(tcp_recv_fn *)0x0); + tcp_accept(pcb,(tcp_accept_fn)0x0); + } + if ((bVar1 & 2) != 0) { + tcp_sent(pcb,(tcp_sent_fn *)0x0); + } + if (!bVar2) goto LAB_23075f20; + tcp_poll(pcb,(tcp_poll_fn *)0x0,'\0'); + tcp_err(pcb,(tcp_err_fn *)0x0); + } + eVar4 = tcp_close(pcb); + iVar6 = CONCAT31(extraout_var_00,eVar4); +LAB_23075f68: + if ((iVar6 != 0) && (iVar6 == -1)) { + iVar7 = conn->send_timeout; + if (iVar7 < 1) { + iVar7 = 5000; + } + TVar5 = sys_now(); + if ((int)(TVar5 - *(int *)(conn->current_msg->msg + 4)) < iVar7) { + if ((bVar1 & 2) != 0) { + tcp_sent(pcb,sent_tcp); + } + tcp_poll(pcb,poll_tcp,'\x01'); + tcp_err(pcb,err_tcp); + tcp_arg(pcb,conn); + return (err_t)iVar6; + } + if (bVar2) { + tcp_abort(pcb); + iVar6 = 0; + } + } + pnVar3 = conn->current_msg->conn; + conn->current_msg->err = (err_t)iVar6; + conn->current_msg = (api_msg *)0x0; + conn->state = NETCONN_NONE; + if (iVar6 == 0) { + if (bVar2) { + conn->pcb = 0; + if (conn->callback != (netconn_callback *)0x0) { + (*conn->callback)(conn,NETCONN_EVT_ERROR,0); + } + } + if (((bVar1 & 1) != 0) && (conn->callback != (netconn_callback *)0x0)) { + (*conn->callback)(conn,NETCONN_EVT_RCVPLUS,0); + } + if (((bVar1 & 2) != 0) && (conn->callback != (netconn_callback *)0x0)) { + (*conn->callback)(conn,NETCONN_EVT_SENDPLUS,0); + } + } + sys_sem_signal((sys_mutex_t *)&pnVar3->op_completed); + return '\0'; +} + + + +err_t poll_tcp(void *arg,tcp_pcb *pcb) + +{ + int iVar1; + + if (*(char *)((int)arg + 1) == '\x01') { + lwip_netconn_do_writemore((netconn *)arg); + } + else { + if (*(char *)((int)arg + 1) == '\x04') { + lwip_netconn_do_close_internal((netconn *)arg); + } + } + if (((((*(byte *)((int)arg + 0x24) & 0x10) != 0) && (iVar1 = *(int *)((int)arg + 4), iVar1 != 0)) + && (0xac0 < *(ushort *)(iVar1 + 100))) && (*(ushort *)(iVar1 + 0x66) < 8)) { + *(byte *)((int)arg + 0x24) = *(byte *)((int)arg + 0x24) & 0xef; + if (*(code **)((int)arg + 0x2c) != (code *)0x0) { + (**(code **)((int)arg + 0x2c))(arg,2,0); + } + } + return '\0'; +} + + + +u8_t recv_raw(void *arg,raw_pcb *pcb,pbuf *p,ip_addr_t *addr) + +{ + ushort uVar1; + err_t eVar2; + int iVar3; + pbuf *p_00; + netbuf *buf; + undefined3 extraout_var; + u16_t len; + + if (arg != (void *)0x0) { + iVar3 = sys_mbox_valid((sys_mbox_t *)((int)arg + 0x10)); + if ((iVar3 != 0) && (p_00 = pbuf_clone(PBUF_RAW,PBUF_RAM,p), p_00 != (pbuf *)0x0)) { + buf = (netbuf *)memp_malloc(MEMP_NETBUF); + if (buf == (netbuf *)0x0) { + pbuf_free(p_00); + } + else { + buf->p = p_00; + buf->ptr = p_00; + (buf->addr).addr = ip_data.current_iphdr_src; + buf->port = (ushort)pcb->protocol; + uVar1 = p_00->tot_len; + eVar2 = sys_mbox_trypost((sys_mbox_t *)((int)arg + 0x10),buf); + if (CONCAT31(extraout_var,eVar2) == 0) { + if (*(code **)((int)arg + 0x2c) != (code *)0x0) { + (**(code **)((int)arg + 0x2c))(arg,0,(uint)uVar1); + } + } + else { + netbuf_delete(buf); + } + } + } + return '\0'; + } + return '\0'; +} + + + +err_t sent_tcp(void *arg,tcp_pcb *pcb,u16_t len) + +{ + undefined2 in_register_00002032; + int iVar1; + + if (arg != (void *)0x0) { + if (*(char *)((int)arg + 1) == '\x01') { + lwip_netconn_do_writemore((netconn *)arg); + } + else { + if (*(char *)((int)arg + 1) == '\x04') { + lwip_netconn_do_close_internal((netconn *)arg); + } + } + iVar1 = *(int *)((int)arg + 4); + if (((iVar1 != 0) && (0xac0 < *(ushort *)(iVar1 + 100))) && (*(ushort *)(iVar1 + 0x66) < 8)) { + *(byte *)((int)arg + 0x24) = *(byte *)((int)arg + 0x24) & 0xef; + if (*(code **)((int)arg + 0x2c) != (code *)0x0) { + (**(code **)((int)arg + 0x2c))(arg,2,CONCAT22(in_register_00002032,len)); + } + } + return '\0'; + } + return '\0'; +} + + + +err_t recv_tcp(void *arg,tcp_pcb *pcb,pbuf *p,err_t err) + +{ + err_t eVar1; + int iVar2; + undefined3 extraout_var; + uint uVar3; + + if (arg == (void *)0x0) { + return -6; + } + iVar2 = sys_mbox_valid((sys_mbox_t *)((int)arg + 0x10)); + if (iVar2 == 0) { + if (p != (pbuf *)0x0) { + tcp_recved(pcb,p->tot_len); + pbuf_free(p); + } + } + else { + if (p == (pbuf *)0x0) { + uVar3 = 0; + p = (pbuf *)""; + } + else { + uVar3 = (uint)p->tot_len; + } + eVar1 = sys_mbox_trypost((sys_mbox_t *)((int)arg + 0x10),p); + if (CONCAT31(extraout_var,eVar1) != 0) { + return -1; + } + if (*(code **)((int)arg + 0x2c) != (code *)0x0) { + (**(code **)((int)arg + 0x2c))(arg,0,uVar3); + return eVar1; + } + } + return '\0'; +} + + + +int lwip_netconn_is_err_msg(void *msg,err_t *err) + +{ + err_t eVar1; + + if ((u8_t *)msg == "") { + eVar1 = -0xd; + } + else { + if ((u8_t *)msg == "") { + eVar1 = -0xe; + } + else { + if ((u8_t *)msg != "") { + return 0; + } + eVar1 = -0xf; + } + } + *err = eVar1; + return 1; +} + + + +void lwip_netconn_do_newconn(void *m) + +{ + byte *pbVar1; + tcp_pcb *ptVar2; + raw_pcb *pcb; + udp_pcb *puVar3; + byte bVar4; + undefined uVar5; + int iVar6; + + pbVar1 = *(byte **)m; + *(undefined *)((int)m + 4) = 0; + if (*(int *)(pbVar1 + 4) != 0) goto LAB_230762c0; + bVar4 = *pbVar1 & 0xf0; + if (bVar4 == 0x20) { + puVar3 = udp_new_ip_type(); + *(udp_pcb **)(pbVar1 + 4) = puVar3; + iVar6 = *(int *)(*(char **)m + 4); + if (iVar6 != 0) { + if (**(char **)m == '\"') { + *(undefined *)(iVar6 + 0x10) = 1; + } + udp_recv(*(udp_pcb **)((int)*(void **)m + 4),recv_udp,*(void **)m); +LAB_230762ba: + if (*(int *)(*(int *)m + 4) != 0) goto LAB_230762c0; + } +LAB_2307630a: + uVar5 = 0xff; + } + else { + if (bVar4 == 0x40) { + pcb = raw_new_ip_type('\0',*(u8_t *)((int)m + 8)); + *(raw_pcb **)(pbVar1 + 4) = pcb; + pcb = *(raw_pcb **)((int)*(void **)m + 4); + if (pcb != (raw_pcb *)0x0) { + raw_recv(pcb,recv_raw,*(void **)m); + goto LAB_230762ba; + } + goto LAB_2307630a; + } + if (bVar4 == 0x10) { + ptVar2 = tcp_new_ip_type('\0'); + *(tcp_pcb **)(pbVar1 + 4) = ptVar2; + if ((*(netconn **)m)->pcb != 0) { + setup_tcp(*(netconn **)m); + goto LAB_230762ba; + } + goto LAB_2307630a; + } + uVar5 = 0xfa; + } + *(undefined *)((int)m + 4) = uVar5; +LAB_230762c0: + sys_sem_signal((sys_mutex_t *)(*(int *)m + 0xc)); + return; +} + + + +netconn * netconn_alloc(netconn_type t,netconn_callback *callback) + +{ + err_t eVar1; + netconn *mem; + undefined3 extraout_var; + undefined3 extraout_var_00; + int size; + + mem = (netconn *)memp_malloc(MEMP_NETCONN); + if (mem == (netconn *)0x0) { + return (netconn *)0x0; + } + mem->pending_err = '\0'; + mem->type = t; + mem->pcb = 0; + t = t & 0xf0; + if (t == NETCONN_UDP) { +LAB_2307634c: + size = 2000; + } + else { + if (t != NETCONN_RAW) { + if (t != NETCONN_TCP) goto free_and_return; + goto LAB_2307634c; + } + size = 0; + } + eVar1 = sys_mbox_new(&mem->recvmbox,size); + if (CONCAT31(extraout_var,eVar1) == 0) { + eVar1 = sys_sem_new(&mem->op_completed,'\0'); + if (CONCAT31(extraout_var_00,eVar1) == 0) { + sys_mbox_set_invalid(&mem->acceptmbox); + mem->state = NETCONN_NONE; + mem->socket = -1; + mem->callback = callback; + mem->current_msg = (api_msg *)0x0; + mem->send_timeout = 0; + mem->recv_timeout = 0; + mem->flags = '\0'; + return mem; + } + sys_mbox_free(&mem->recvmbox); + } +free_and_return: + memp_free(MEMP_NETCONN,mem); + return (netconn *)0x0; +} + + + +void netconn_free(netconn *conn) + +{ + sys_mbox_valid(&conn->recvmbox); + sys_mbox_valid(&conn->acceptmbox); + sys_sem_free(&conn->op_completed); + sys_sem_set_invalid(&conn->op_completed); + memp_free(MEMP_NETCONN,conn); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void netconn_drain(netconn *conn) + +{ + netconn *conn_00; + sys_mbox_t *mbox; + int iVar1; + u32_t uVar2; + err_t eStack37; + err_t err; + netconn *pnStack36; + void *mem; + + mbox = &conn->recvmbox; + iVar1 = sys_mbox_valid(mbox); + if (iVar1 != 0) { + while (uVar2 = sys_arch_mbox_tryfetch(mbox,(void **)&stack0xffffffdc), uVar2 != 0xffffffff) { + if ((conn->type & 0xf0) == NETCONN_TCP) { + iVar1 = lwip_netconn_is_err_msg(pnStack36,&eStack37); + if (iVar1 == 0) { + pbuf_free((pbuf *)pnStack36); + } + } + else { + netbuf_delete((netbuf *)pnStack36); + } + } + sys_mbox_free(mbox); + sys_mbox_set_invalid(mbox); + } + mbox = &conn->acceptmbox; + iVar1 = sys_mbox_valid(mbox); + if (iVar1 != 0) { + while (uVar2 = sys_arch_mbox_tryfetch(mbox,(void **)&stack0xffffffdc), uVar2 != 0xffffffff) { + iVar1 = lwip_netconn_is_err_msg(pnStack36,&eStack37); + conn_00 = pnStack36; + if (iVar1 == 0) { + netconn_drain(pnStack36); + if ((tcp_pcb *)conn_00->pcb != (tcp_pcb *)0x0) { + tcp_abort((tcp_pcb *)conn_00->pcb); + conn_00->pcb = 0; + } + netconn_free(conn_00); + } + } + sys_mbox_free(mbox); + sys_mbox_set_invalid(mbox); + } + return; +} + + + +err_t accept_function(void *arg,tcp_pcb *newpcb,err_t err) + +{ + tcp_pcb *pcb; + err_t eVar1; + err_t eVar2; + int iVar3; + undefined3 extraout_var; + netconn *conn; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 in_register_00002031; + sys_mbox_t *mbox; + + if (arg != (void *)0x0) { + mbox = (sys_mbox_t *)((int)arg + 0x14); + iVar3 = sys_mbox_valid(mbox,CONCAT31(in_register_00002031,err)); + if (iVar3 != 0) { + if (newpcb != (tcp_pcb *)0x0) { + conn = netconn_alloc(*(netconn_type *)arg,*(netconn_callback **)((int)arg + 0x2c)); + if (conn == (netconn *)0x0) { + eVar2 = sys_mbox_trypost(mbox,""); + eVar1 = -1; + if (CONCAT31(extraout_var_00,eVar2) != 0) { + return -1; + } + } + else { + *(tcp_pcb **)&conn->pcb = newpcb; + setup_tcp(conn); + eVar1 = sys_mbox_trypost(mbox,conn); + if (CONCAT31(extraout_var_01,eVar1) != 0) { + pcb = (tcp_pcb *)conn->pcb; + tcp_arg(pcb,(void *)0x0); + tcp_recv(pcb,(tcp_recv_fn *)0x0); + tcp_sent(pcb,(tcp_sent_fn *)0x0); + tcp_poll(pcb,(tcp_poll_fn *)0x0,'\0'); + tcp_err(pcb,(tcp_err_fn *)0x0); + conn->pcb = 0; + sys_mbox_free(&conn->recvmbox); + sys_mbox_set_invalid(&conn->recvmbox); + netconn_free(conn); + return -1; + } + } + if (*(code **)((int)arg + 0x2c) == (code *)0x0) { + return eVar1; + } + (**(code **)((int)arg + 0x2c))(arg,0,0); + return eVar1; + } + eVar1 = sys_mbox_trypost(mbox,""); + if ((CONCAT31(extraout_var,eVar1) == 0) && (*(code **)((int)arg + 0x2c) != (code *)0x0)) { + (**(code **)((int)arg + 0x2c))(arg,0,0); + } + } + } + return -6; +} + + + +void lwip_netconn_do_delconn(void *m) + +{ + netconn *conn; + int iVar1; + raw_pcb *pcb; + byte *pbVar2; + byte bVar3; + + conn = *(netconn **)m; + if (((conn->state & ~NETCONN_LISTEN) == NETCONN_NONE) || + ((conn->state == NETCONN_CONNECT && ((conn->flags & 4) != 0)))) { + *(undefined *)((int)m + 4) = 0; + netconn_drain(conn); + pbVar2 = *(byte **)m; + pcb = *(raw_pcb **)(pbVar2 + 4); + if (pcb != (raw_pcb *)0x0) { + bVar3 = *pbVar2 & 0xf0; + if (bVar3 == 0x20) { + *(undefined4 *)&pcb[1].netif_idx = 0; + udp_remove(*(udp_pcb **)(*(int *)m + 4)); + } + else { + if (bVar3 == 0x40) { + raw_remove(pcb); + } + else { + if (bVar3 == 0x10) { + pbVar2[1] = 4; + *(undefined *)((int)m + 8) = 3; + *(void **)(*(int *)m + 0x28) = m; + lwip_netconn_do_close_internal(*(netconn **)m); + return; + } + } + } + *(undefined4 *)(*(int *)m + 4) = 0; + } + if (*(code **)(*(int *)m + 0x2c) != (code *)0x0) { + (**(code **)(*(int *)m + 0x2c))(0,0); + } + if (*(code **)(*(int *)m + 0x2c) != (code *)0x0) { + (**(code **)(*(int *)m + 0x2c))(2,0); + } + } + else { + *(undefined *)((int)m + 4) = 0xfb; + } + iVar1 = sys_sem_valid((sys_sem_t *)(*(int *)m + 0xc)); + if (iVar1 != 0) { + sys_sem_signal((sys_mutex_t *)(*(int *)m + 0xc)); + return; + } + return; +} + + + +void lwip_netconn_do_bind(void *m) + +{ + err_t eVar1; + tcp_pcb *pcb; + byte bVar2; + + eVar1 = -6; + pcb = *(tcp_pcb **)(*(byte **)m + 4); + if (pcb != (tcp_pcb *)0x0) { + bVar2 = **(byte **)m & 0xf0; + if (bVar2 == 0x20) { + eVar1 = udp_bind((udp_pcb *)pcb,*(ip_addr_t **)((int)m + 8),*(u16_t *)((int)m + 0xc)); + } + else { + if (bVar2 == 0x40) { + eVar1 = raw_bind((raw_pcb *)pcb,*(ip_addr_t **)((int)m + 8)); + } + else { + if (bVar2 == 0x10) { + eVar1 = tcp_bind(pcb,*(ip_addr_t **)((int)m + 8),*(u16_t *)((int)m + 0xc)); + } + else { + eVar1 = -6; + } + } + } + } + *(err_t *)((int)m + 4) = eVar1; + sys_sem_signal((sys_mutex_t *)(*(int *)m + 0xc)); + return; +} + + + +void lwip_netconn_do_connect(void *m) + +{ + err_t eVar1; + udp_pcb *pcb; + undefined3 extraout_var; + netconn *conn; + netconn_type nVar2; + int iVar3; + int iVar4; + + conn = *(netconn **)m; + pcb = (udp_pcb *)conn->pcb; + if (pcb == (udp_pcb *)0x0) { + eVar1 = -0xf; + } + else { + nVar2 = conn->type & 0xf0; + if (nVar2 == NETCONN_UDP) { + eVar1 = udp_connect(pcb,*(ip_addr_t **)((int)m + 8),*(u16_t *)((int)m + 0xc)); + } + else { + if (nVar2 == NETCONN_RAW) { + eVar1 = raw_connect((raw_pcb *)pcb,*(ip_addr_t **)((int)m + 8)); + } + else { + eVar1 = -6; + if (nVar2 == NETCONN_TCP) { + if (conn->state == NETCONN_CONNECT) { + eVar1 = -9; + } + else { + eVar1 = -10; + if (conn->state == NETCONN_NONE) { + setup_tcp(conn); + eVar1 = tcp_connect(*(tcp_pcb **)(*(int *)m + 4),*(ip_addr_t **)((int)m + 8), + *(u16_t *)((int)m + 0xc),lwip_netconn_do_connected); + if (CONCAT31(extraout_var,eVar1) == 0) { + iVar3 = *(int *)m; + *(undefined *)(iVar3 + 1) = 3; + iVar4 = *(int *)m; + if ((*(byte *)(iVar3 + 0x24) & 2) == 0) { + *(byte *)(iVar4 + 0x24) = *(byte *)(iVar4 + 0x24) & 0xfb; + *(void **)(*(int *)m + 0x28) = m; + return; + } + eVar1 = -5; + *(byte *)(iVar4 + 0x24) = *(byte *)(iVar4 + 0x24) | 4; + } + } + } + } + } + } + } + *(err_t *)((int)m + 4) = eVar1; + sys_sem_signal((sys_mutex_t *)(*(int *)m + 0xc)); + return; +} + + + +void lwip_netconn_do_disconnect(void *m) + +{ + if ((**(byte **)m & 0xf0) == 0x20) { + udp_disconnect(*(udp_pcb **)(*(byte **)m + 4)); + *(undefined *)((int)m + 4) = 0; + } + else { + *(undefined *)((int)m + 4) = 0xfa; + } + sys_sem_signal((sys_mutex_t *)(*(int *)m + 0xc)); + return; +} + + + +void lwip_netconn_do_listen(void *m) + +{ + tcp_pcb *pcb; + int iVar1; + byte *pbVar2; + err_t aeStack17 [4]; + err_t err; + + pbVar2 = *(byte **)m; + pcb = *(tcp_pcb **)(pbVar2 + 4); + if (pcb != (tcp_pcb *)0x0) { + if ((*pbVar2 & 0xf0) != 0x10) { + aeStack17[0] = -0x10; + goto LAB_23076840; + } + if (pbVar2[1] == 0) { + if (pcb->state == CLOSED) { + pcb = tcp_listen_with_backlog_and_err(pcb,-1,aeStack17); + if (pcb != (tcp_pcb *)0x0) { + iVar1 = sys_mbox_valid(*(int *)m + 0x10); + if (iVar1 != 0) { + sys_mbox_free((sys_mbox_t *)(*(int *)m + 0x10)); + sys_mbox_set_invalid(*(int *)m + 0x10); + } + aeStack17[0] = '\0'; + iVar1 = sys_mbox_valid(*(int *)m + 0x14); + if (iVar1 == 0) { + aeStack17[0] = sys_mbox_new((sys_mbox_t *)(*(int *)m + 0x14),2000); + } + if (aeStack17[0] == '\0') { + *(undefined *)(*(int *)m + 1) = 2; + *(tcp_pcb **)(*(int *)m + 4) = pcb; + tcp_arg(*(tcp_pcb **)((int)*(void **)m + 4),*(void **)m); + tcp_accept(*(tcp_pcb **)(*(int *)m + 4),accept_function); + } + else { + tcp_close(pcb); + *(undefined4 *)(*(int *)m + 4) = 0; + } + } + } + else { + aeStack17[0] = -6; + } + goto LAB_23076840; + } + if (pbVar2[1] == 2) { + aeStack17[0] = '\0'; + goto LAB_23076840; + } + } + aeStack17[0] = -0xb; +LAB_23076840: + *(char *)((int)m + 4) = aeStack17[0]; + sys_sem_signal((sys_mutex_t *)(*(int *)m + 0xc)); + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void lwip_netconn_do_send(void *m) + +{ + err_t eVar1; + undefined3 extraout_var; + byte have_chksum; + pbuf *ppVar2; + udp_pcb *pcb; + + eVar1 = netconn_err(*(netconn **)m); + if (CONCAT31(extraout_var,eVar1) == 0) { + eVar1 = -0xb; + pcb = *(udp_pcb **)(*(byte **)m + 4); + if (pcb != (udp_pcb *)0x0) { + have_chksum = **(byte **)m & 0xf0; + if (have_chksum == 0x20) { + ppVar2 = *(pbuf **)((int)m + 8); + have_chksum = ppVar2->ref & 2; + if (((ip_addr_t *)&ppVar2->tot_len == (ip_addr_t *)0x0) || + (*(pbuf **)&ppVar2->tot_len == (pbuf *)0x0)) { + eVar1 = udp_send_chksum(pcb,ppVar2->next,have_chksum,*(u16_t *)&ppVar2[1].next); + } + else { + eVar1 = udp_sendto_chksum(pcb,ppVar2->next,(ip_addr_t *)&ppVar2->tot_len, + *(u16_t *)&ppVar2->type_internal,have_chksum, + *(u16_t *)&ppVar2[1].next); + } + } + else { + if (have_chksum == 0x40) { + ppVar2 = *(pbuf **)((int)m + 8); + if (((ip_addr_t *)&ppVar2->tot_len == (ip_addr_t *)0x0) || + (*(pbuf **)&ppVar2->tot_len == (pbuf *)0x0)) { + eVar1 = raw_send((raw_pcb *)pcb,ppVar2->next); + } + else { + eVar1 = raw_sendto((raw_pcb *)pcb,ppVar2->next,(ip_addr_t *)&ppVar2->tot_len); + } + } + } + } + } + *(err_t *)((int)m + 4) = eVar1; + sys_sem_signal((sys_mutex_t *)(*(int *)m + 0xc)); + return; +} + + + +void lwip_netconn_do_recv(void *m) + +{ + uint uVar1; + uint uVar2; + + *(undefined *)((int)m + 4) = 0; + if ((*(int *)(*(byte **)m + 4) != 0) && ((**(byte **)m & 0xf0) == 0x10)) { + uVar1 = *(uint *)((int)m + 8); + do { + uVar2 = uVar1; + if (0xffff < uVar1) { + uVar2 = 0xffff; + } + uVar1 = uVar1 - uVar2; + tcp_recved(*(tcp_pcb **)(*(int *)m + 4),(u16_t)uVar2); + } while (uVar1 != 0); + } + sys_sem_signal((sys_mutex_t *)(*(int *)m + 0xc)); + return; +} + + + +void lwip_netconn_do_write(void *m) + +{ + err_t eVar1; + undefined3 extraout_var; + byte *pbVar2; + + eVar1 = netconn_err(*(netconn **)m); + pbVar2 = *(byte **)m; + if ((CONCAT31(extraout_var,eVar1) == 0) && (eVar1 = -6, (*pbVar2 & 0xf0) == 0x10)) { + if (pbVar2[1] == 0) { + eVar1 = -0xb; + if (*(int *)(pbVar2 + 4) != 0) { + pbVar2[1] = 1; + *(void **)(*(int *)m + 0x28) = m; + lwip_netconn_do_writemore(*(netconn **)m); + return; + } + } + else { + eVar1 = -5; + } + } + *(err_t *)((int)m + 4) = eVar1; + sys_sem_signal((sys_mutex_t *)(pbVar2 + 0xc)); + return; +} + + + +void lwip_netconn_do_getaddr(void *m) + +{ + byte *pbVar1; + undefined2 *puVar2; + byte bVar3; + undefined2 uVar4; + undefined4 *puVar5; + undefined4 uVar6; + int iVar7; + + puVar5 = *(undefined4 **)(*(int *)m + 4); + if (puVar5 == (undefined4 *)0x0) { +LAB_23076a16: + *(undefined *)((int)m + 4) = 0xf5; + } + else { + if (*(char *)((int)m + 0x10) == '\0') { + uVar6 = puVar5[1]; + } + else { + uVar6 = *puVar5; + } + **(undefined4 **)((int)m + 8) = uVar6; + pbVar1 = *(byte **)m; + *(undefined *)((int)m + 4) = 0; + bVar3 = *pbVar1 & 0xf0; + if (bVar3 == 0x20) { + iVar7 = *(int *)(pbVar1 + 4); + if (*(char *)((int)m + 0x10) == '\0') { + if ((*(byte *)(iVar7 + 0x10) & 4) == 0) goto LAB_23076a16; + puVar2 = *(undefined2 **)((int)m + 0xc); + uVar4 = *(undefined2 *)(iVar7 + 0x14); + } + else { + puVar2 = *(undefined2 **)((int)m + 0xc); + uVar4 = *(undefined2 *)(iVar7 + 0x12); + } + } + else { + if (bVar3 == 0x40) { + if (*(char *)((int)m + 0x10) != '\0') { + **(ushort **)((int)m + 0xc) = (ushort)*(byte *)(*(int *)(pbVar1 + 4) + 0x10); + goto LAB_23076a34; + } + goto LAB_23076a16; + } + if (bVar3 != 0x10) goto LAB_23076a34; + iVar7 = *(int *)(pbVar1 + 4); + if (*(char *)((int)m + 0x10) == '\0') { + if (*(byte *)(iVar7 + 0x14) < 2) goto LAB_23076a16; + uVar4 = *(undefined2 *)(iVar7 + 0x18); + } + else { + uVar4 = *(undefined2 *)(iVar7 + 0x16); + } + puVar2 = *(undefined2 **)((int)m + 0xc); + } + *puVar2 = uVar4; + } +LAB_23076a34: + sys_sem_signal((sys_mutex_t *)(*(int *)m + 0xc)); + return; +} + + + +void lwip_netconn_do_close(void *m) + +{ + netconn_state nVar1; + netconn *conn; + undefined uVar2; + + conn = *(netconn **)m; + if ((conn->pcb != 0) && ((conn->type & 0xf0) == NETCONN_TCP)) { + nVar1 = conn->state; + if (((*(byte *)((int)m + 8) == 3) || (nVar1 != NETCONN_LISTEN)) && (nVar1 != NETCONN_CONNECT)) { + if (nVar1 != NETCONN_WRITE) { + if ((*(byte *)((int)m + 8) & 1) != 0) { + netconn_drain(conn); + } + *(undefined *)(*(int *)m + 1) = 4; + *(void **)(*(int *)m + 0x28) = m; + lwip_netconn_do_close_internal(*(netconn **)m); + return; + } + uVar2 = 0xfb; + goto LAB_23076aa6; + } + } + uVar2 = 0xf5; +LAB_23076aa6: + *(undefined *)((int)m + 4) = uVar2; + sys_sem_signal((sys_mutex_t *)&conn->op_completed); + return; +} + + + +void lwip_netconn_do_join_leave_group(void *m) + +{ + err_t eVar1; + + *(undefined *)((int)m + 4) = 0xf5; + if (*(int *)(*(byte **)m + 4) != 0) { + if ((**(byte **)m & 0xf0) == 0x20) { + if (*(char *)((int)m + 0x11) == '\0') { + eVar1 = igmp_joingroup(*(ip4_addr_t **)((int)m + 0xc),*(ip4_addr_t **)((int)m + 8)); + } + else { + eVar1 = igmp_leavegroup(*(ip4_addr_t **)((int)m + 0xc),*(ip4_addr_t **)((int)m + 8)); + } + *(err_t *)((int)m + 4) = eVar1; + } + else { + *(undefined *)((int)m + 4) = 0xfa; + } + } + sys_sem_signal((sys_mutex_t *)(*(int *)m + 0xc)); + return; +} + + + +void lwip_netconn_do_gethostbyname(void *arg) + +{ + err_t *peVar1; + err_t eVar2; + + peVar1 = *(err_t **)((int)arg + 0xc); + eVar2 = dns_gethostbyname_addrtype + (*(char **)arg,*(ip_addr_t **)((int)arg + 4),lwip_netconn_do_dns_found,arg,'\0') + ; + *peVar1 = eVar2; + if (**(char **)((int)arg + 0xc) != -5) { + sys_sem_signal((sys_mutex_t *)*(sys_mutex_t *)((int)arg + 8)); + return; + } + return; +} + + + +int err_to_errno(err_t err) + +{ + undefined3 in_register_00002029; + + if ((CONCAT31(in_register_00002029,err) + 0x10U & 0xff) < 0x11) { + return err_to_errno_table[CONCAT31(in_register_00002029,err) * 0x3fffffff]; + } + return 5; +} + + + +void netbuf_delete(netbuf *buf) + +{ + if (buf == (netbuf *)0x0) { + return; + } + if (buf->p != (pbuf *)0x0) { + pbuf_free(buf->p); + buf->ptr = (pbuf *)0x0; + buf->p = (pbuf *)0x0; + } + memp_free(MEMP_NETBUF,buf); + return; +} + + + +void * netbuf_alloc(netbuf *buf,u16_t size) + +{ + pbuf *ppVar1; + void *pvVar2; + + if (buf == (netbuf *)0x0) { + return (void *)0x0; + } + if (buf->p != (pbuf *)0x0) { + pbuf_free(buf->p); + } + ppVar1 = pbuf_alloc(PBUF_TRANSPORT,size,PBUF_RAM); + buf->p = ppVar1; + if (ppVar1 == (pbuf *)0x0) { + pvVar2 = (void *)0x0; + } + else { + buf->ptr = ppVar1; + pvVar2 = ppVar1->payload; + } + return pvVar2; +} + + + +void netbuf_free(netbuf *buf) + +{ + if (buf != (netbuf *)0x0) { + if (buf->p != (pbuf *)0x0) { + pbuf_free(buf->p); + } + buf->ptr = (pbuf *)0x0; + buf->p = (pbuf *)0x0; + buf->flags = '\0'; + buf->toport_chksum = 0; + return; + } + return; +} + + + +void icmp_input(pbuf *p,netif *inp) + +{ + ip_hdr *__src; + u32_t uVar1; + uint uVar2; + uint __n; + void *dataptr; + u8_t uVar3; + err_t eVar4; + u16_t uVar5; + undefined3 extraout_var; + undefined2 extraout_var_05; + undefined3 extraout_var_00; + pbuf *p_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + uint uVar6; + short sVar7; + undefined *puVar8; + + __src = ip_data.current_ip4_header; + lwip_stats.icmp.recv = lwip_stats.icmp.recv + 1; + uVar2 = (uint)(ip_data.current_ip4_header)->_v_hl & 0xf; + __n = uVar2 * 4; + if ((__n < 0x14) || (p->len < 4)) { +lenerr: + pbuf_free(p); + lwip_stats.icmp.lenerr = lwip_stats.icmp.lenerr + 1; + } + else { + if (*(char *)p->payload == '\0') goto LAB_23076e20; + if (*(char *)p->payload != '\b') { + lwip_stats.icmp.proterr = lwip_stats.icmp.proterr + 1; + lwip_stats.icmp.drop = lwip_stats.icmp.drop + 1; + goto LAB_23076e20; + } + if (((ip_data.current_iphdr_dest & 0xf0) != 0xe0) && + (uVar3 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_dest,ip_data.current_netif), + CONCAT31(extraout_var,uVar3) == 0)) { + if (p->tot_len < 8) goto lenerr; + uVar5 = inet_chksum_pbuf(p); + if (CONCAT22(extraout_var_05,uVar5) != 0) { + pbuf_free(p); + lwip_stats.icmp.chkerr = lwip_stats.icmp.chkerr + 1; + return; + } + uVar2 = uVar2 << 0x12; + uVar3 = pbuf_add_header(p,__n + 0x8e); + if (CONCAT31(extraout_var_00,uVar3) == 0) { + uVar3 = pbuf_remove_header(p,__n + 0x8e); + if (CONCAT31(extraout_var_04,uVar3) == 0) { +LAB_23076d68: + puVar8 = (undefined *)p->payload; + uVar3 = pbuf_add_header(p,__n); + uVar1 = ip_data.current_iphdr_dest; + if (CONCAT31(extraout_var_03,uVar3) == 0) { + dataptr = p->payload; + *(undefined *)((int)dataptr + 0xc) = (char)ip_data.current_iphdr_dest; + *(undefined *)((int)dataptr + 0xd) = (char)(uVar1 >> 8); + *(undefined *)((int)dataptr + 0xe) = (char)(uVar1 >> 0x10); + *(undefined *)((int)dataptr + 0xf) = (char)(uVar1 >> 0x18); + uVar1 = ip_data.current_iphdr_src; + *(undefined *)((int)dataptr + 0x10) = (char)ip_data.current_iphdr_src; + *(undefined *)((int)dataptr + 0x11) = (char)(uVar1 >> 8); + *(undefined *)((int)dataptr + 0x12) = (char)(uVar1 >> 0x10); + *(undefined *)((int)dataptr + 0x13) = (char)(uVar1 >> 0x18); + *puVar8 = 0; + if (*(ushort *)(puVar8 + 2) < 0xfff8) { + sVar7 = 8; + } + else { + sVar7 = 9; + } + sVar7 = *(ushort *)(puVar8 + 2) + sVar7; + puVar8[2] = (char)sVar7; + puVar8[3] = (char)((ushort)sVar7 >> 8); + *(undefined *)((int)dataptr + 8) = 0xff; + *(undefined *)((int)dataptr + 10) = 0; + *(undefined *)((int)dataptr + 0xb) = 0; + uVar5 = inet_chksum(dataptr,(u16_t)(uVar2 >> 0x10)); + *(undefined *)((int)dataptr + 10) = (char)uVar5; + *(undefined *)((int)dataptr + 0xb) = (char)(uVar5 >> 8); + lwip_stats.icmp.xmit = lwip_stats.icmp.xmit + 1; + ip4_output_if(p,(ip4_addr_t *)&ip_data.current_iphdr_dest,(ip4_addr_t *)0x0,-1,'\0', + '\x01',inp); + } +LAB_23076e20: + pbuf_free(p); + return; + } + } + else { + uVar6 = (uint)p->tot_len + (uVar2 >> 0x10); + if (((uint)p->tot_len <= (uVar6 & 0xffff)) && + (p_00 = pbuf_alloc(PBUF_LINK,(u16_t)(uVar6 * 0x10000 >> 0x10),PBUF_RAM), + p_00 != (pbuf *)0x0)) { + if (__n + 8 <= (uint)p_00->len) { + memcpy(p_00->payload,__src,__n); + uVar3 = pbuf_remove_header(p_00,__n); + if ((CONCAT31(extraout_var_01,uVar3) == 0) && + (eVar4 = pbuf_copy(p_00,p), CONCAT31(extraout_var_02,eVar4) == 0)) { + pbuf_free(p); + p = p_00; + goto LAB_23076d68; + } + } + pbuf_free(p_00); + } + } + } + pbuf_free(p); + lwip_stats.icmp.err = lwip_stats.icmp.err + 1; + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void icmp_dest_unreach(pbuf *p,icmp_dur_type t) + +{ + undefined *dataptr; + u16_t uVar1; + pbuf *p_00; + netif *netif; + void *pvVar2; + ip4_addr_t iStack36; + ip4_addr_t iphdr_src; + + p_00 = pbuf_alloc(PBUF_IP,0x24,PBUF_RAM); + if (p_00 != (pbuf *)0x0) { + dataptr = (undefined *)p_00->payload; + pvVar2 = p->payload; + *dataptr = 3; + dataptr[1] = t; + dataptr[4] = 0; + dataptr[5] = 0; + dataptr[6] = 0; + dataptr[7] = 0; + memcpy((void *)((int)p_00->payload + 8),p->payload,0x1c); + iStack36 = (ip4_addr_t)((ip4_addr_t *)((int)pvVar2 + 0xc))->addr; + netif = ip4_route(&iStack36); + if (netif != (netif *)0x0) { + dataptr[2] = 0; + dataptr[3] = 0; + uVar1 = inet_chksum(dataptr,p_00->len); + dataptr[2] = (char)uVar1; + dataptr[3] = (char)(uVar1 >> 8); + lwip_stats.icmp.xmit = lwip_stats.icmp.xmit + 1; + ip4_output_if(p_00,(ip4_addr_t *)0x0,&iStack36,-1,'\0','\x01',netif); + } + pbuf_free(p_00); + } + return; +} + + + +u8_t * dhcp_server_option_find(u8_t *buf,u16_t len,u8_t option) + +{ + undefined2 in_register_0000202e; + byte *pbVar1; + undefined3 in_register_00002031; + + pbVar1 = buf + CONCAT22(in_register_0000202e,len); + while ((buf < pbVar1 && (*buf != 0xff))) { + if ((uint)*buf == CONCAT31(in_register_00002031,option)) { + return buf; + } + buf = buf + (uint)buf[1] + 2; + } + return (u8_t *)0x0; +} + + + +// WARNING: Type propagation algorithm not settling + +dhcp_client_node * dhcp_client_find_by_ip(uint8_t *ip) + +{ + dhcp_client_node *pdVar1; + void *in_a1; + ip4_addr_t iStack20; + uint32_t ipval; + + memcpy(&iStack20,in_a1,4); + pdVar1 = *(dhcp_client_node **)ip; + while ((pdVar1 != (dhcp_client_node *)0x0 && (iStack20 != (ip4_addr_t)(pdVar1->ipaddr).addr))) { + pdVar1 = pdVar1->next; + } + return pdVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +void dhcp_server_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *recv_addr,u16_t port) + +{ + byte bVar1; + u8_t uVar2; + char *pcVar3; + pbuf *p_to; + u8_t *puVar4; + u32_t n; + u32_t uVar5; + int iVar6; + u16_t len; + undefined4 *puVar7; + dhcp_client_node *pdVar8; + undefined4 *puVar9; + undefined4 *puVar10; + u8_t *buf; + ip_addr_t iStack56; + ip_addr_t addr; + u32_t tmp; + + iStack56 = (ip_addr_t)recv_addr->addr; + if (((p->len < 0x2c) || (p_to = pbuf_alloc(PBUF_TRANSPORT,0x5dc,PBUF_RAM), p_to == (pbuf *)0x0)) + || (p_to->tot_len < p->tot_len)) goto LAB_23076fc0; + pbuf_copy(p_to,p); + pbuf_free(p); + pcVar3 = (char *)p_to->payload; + p = p_to; + if (((*pcVar3 != '\x01') || (*(int *)(pcVar3 + 0xec) != 0x63538263)) || + (bVar1 = pcVar3[2], 6 < bVar1)) goto LAB_23076fc0; + buf = (u8_t *)(pcVar3 + 0xf0); + len = (u16_t)(((uint)p_to->tot_len - 0xf0) * 0x10000 >> 0x10); + puVar4 = dhcp_server_option_find(buf,len,'5'); + if (puVar4 == (u8_t *)0x0) goto LAB_23076fc0; + uVar2 = puVar4[2]; + if (uVar2 == '\x01') { + pdVar8 = *(dhcp_client_node **)((int)arg + 0xc); + while (pdVar8 != (dhcp_client_node *)0x0) { + iVar6 = memcmp(pdVar8->chaddr,pcVar3 + 0x1c,(uint)bVar1); + if (iVar6 == 0) goto LAB_23077114; + pdVar8 = pdVar8->next; + } + puVar4 = dhcp_server_option_find(buf,len,'2'); + if ((puVar4 == (u8_t *)0x0) || + (pdVar8 = dhcp_client_find_by_ip((uint8_t *)((int)arg + 0xc)), + pdVar8 == (dhcp_client_node *)0x0)) { + while (pdVar8 = dhcp_client_find_by_ip((uint8_t *)((int)arg + 0xc)), + pdVar8 != (dhcp_client_node *)0x0) { + n = lwip_htonl(*(u32_t *)((int)arg + 0x18)); + n = n + 1; + uVar5 = lwip_htonl(*(u32_t *)((int)arg + 0x14)); + if (uVar5 < n) { + n = lwip_htonl(*(u32_t *)((int)arg + 0x10)); + } + uVar5 = lwip_htonl(n); + *(u32_t *)((int)arg + 0x18) = uVar5; + } + pdVar8 = (dhcp_client_node *)mem_malloc(0x14); + if (pdVar8 == (dhcp_client_node *)0x0) goto LAB_23076fc0; + memcpy(pdVar8->chaddr,pcVar3 + 0x1c,(uint)(byte)pcVar3[2]); + (pdVar8->ipaddr).addr = *(u32_t *)((int)arg + 0x18); + pdVar8->next = *(dhcp_client_node **)((int)arg + 0xc); + *(dhcp_client_node **)((int)arg + 0xc) = pdVar8; + } +LAB_23077114: + pdVar8->lease_end = 0x80510100; + *pcVar3 = '\x02'; + pcVar3[3] = '\0'; + pcVar3[8] = '\0'; + pcVar3[9] = '\0'; + memcpy(pcVar3 + 0x14,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0xed] = -0x7e; + pcVar3[0xec] = 'c'; + pcVar3[0xef] = 'c'; + pcVar3[0x2c] = '\0'; + pcVar3[0x6c] = '\0'; + pcVar3[0xee] = 'S'; + memcpy(pcVar3 + 0x10,&pdVar8->ipaddr,4); + pcVar3[0xf0] = '5'; + pcVar3[0xf1] = '\x01'; + pcVar3[0xf2] = '\x02'; +LAB_23077184: + pcVar3[0xf3] = '6'; + pcVar3[0xf4] = '\x04'; + memcpy(pcVar3 + 0xf5,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0xf9] = '3'; + pcVar3[0xfa] = '\x04'; + addr = 0x15180; + memcpy(pcVar3 + 0xfb,&addr,4); + pcVar3[0xff] = '\x01'; + pcVar3[0x100] = '\x04'; + memcpy(pcVar3 + 0x101,(void *)(*(int *)((int)arg + 4) + 8),4); + pcVar3[0x105] = '\x06'; + pcVar3[0x106] = '\x04'; + memcpy(pcVar3 + 0x107,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0x10b] = '\x03'; + pcVar3[0x10c] = '\x04'; + memcpy(pcVar3 + 0x10d,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0x111] = -1; + if (0x112 < p_to->tot_len) { + len = 0x112; +LAB_2307721c: + pbuf_realloc(p_to,len); + } + } + else { + if (uVar2 != '\x03') { + if (uVar2 == '\a') { + puVar7 = *(undefined4 **)((int)arg + 0xc); + puVar10 = (undefined4 *)0x0; + while (puVar9 = puVar7, puVar9 != (undefined4 *)0x0) { + iVar6 = memcmp(puVar9 + 1,pcVar3 + 0x1c,(uint)(byte)pcVar3[2]); + puVar7 = (undefined4 *)*puVar9; + if (iVar6 == 0) { + if (*(undefined4 **)((int)arg + 0xc) == puVar9) { + *(undefined4 **)((int)arg + 0xc) = puVar7; + } + else { + *(undefined4 **)puVar10 = puVar7; + } + mem_free(puVar9); + break; + } + puVar7 = (undefined4 *)*puVar7; + puVar10 = puVar9; + } + } + goto LAB_23076fc0; + } + pdVar8 = *(dhcp_client_node **)((int)arg + 0xc); + while (pdVar8 != (dhcp_client_node *)0x0) { + iVar6 = memcmp(pdVar8->chaddr,pcVar3 + 0x1c,(uint)bVar1); + if (iVar6 == 0) goto LAB_23077376; + pdVar8 = pdVar8->next; + } + puVar4 = dhcp_server_option_find(buf,len,'2'); + if ((puVar4 != (u8_t *)0x0) && + (pdVar8 = dhcp_client_find_by_ip((uint8_t *)((int)arg + 0xc)), + pdVar8 != (dhcp_client_node *)0x0)) { + iVar6 = memcmp(pdVar8->chaddr,pcVar3 + 0x1c,(uint)(byte)pcVar3[2]); + if (iVar6 == 0) { +LAB_23077376: + pdVar8->lease_end = 0x80510100; + *pcVar3 = '\x02'; + pcVar3[3] = '\0'; + pcVar3[8] = '\0'; + pcVar3[9] = '\0'; + memcpy(pcVar3 + 0x14,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0xed] = -0x7e; + pcVar3[0xec] = 'c'; + pcVar3[0xef] = 'c'; + pcVar3[0x2c] = '\0'; + pcVar3[0x6c] = '\0'; + pcVar3[0xee] = 'S'; + memcpy(pcVar3 + 0x10,&pdVar8->ipaddr,4); + pcVar3[0xf0] = '5'; + pcVar3[0xf1] = '\x01'; + pcVar3[0xf2] = '\x05'; + goto LAB_23077184; + } + puts("IP Found, but MAC address is NOT the same\r\n"); + } + *pcVar3 = '\x02'; + pcVar3[3] = '\0'; + pcVar3[8] = '\0'; + pcVar3[9] = '\0'; + memcpy(pcVar3 + 0x14,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0xed] = -0x7e; + pcVar3[0xee] = 'S'; + pcVar3[0xec] = 'c'; + pcVar3[0xef] = 'c'; + pcVar3[0x2c] = '\0'; + pcVar3[0x6c] = '\0'; + memset(pcVar3 + 0x10,0,4); + pcVar3[0xf0] = '5'; + pcVar3[0xf1] = '\x01'; + pcVar3[0xf2] = '\x06'; + pcVar3[0xf3] = '6'; + pcVar3[0xf4] = '\x04'; + memcpy(pcVar3 + 0xf5,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0xf9] = -1; + if (0xfa < p_to->tot_len) { + len = 0xfa; + goto LAB_2307721c; + } + } + iStack56 = (ip_addr_t)0xffffffff; + udp_sendto_if(pcb,p_to,&iStack56,port,*(netif **)((int)arg + 4)); +LAB_23076fc0: + pbuf_free(p); + return; +} + + + +err_t dhcp_server_start(netif *netif,ip4_addr_t *start,ip4_addr_t *end) + +{ + udp_pcb *puVar1; + dhcp_server *__s; + + __s = lw_dhcp_server; + while (__s != (dhcp_server *)0x0) { + if (__s->netif == netif) { + (__s->start).addr = start->addr; + (__s->end).addr = end->addr; + (__s->current).addr = start->addr; + return '\0'; + } + __s = __s->next; + } + __s = (dhcp_server *)mem_malloc(0x1c); + if (__s != (dhcp_server *)0x0) { + memset(__s,0,0x1c); + __s->netif = netif; + __s->node_list = (dhcp_client_node *)0x0; + __s->next = lw_dhcp_server; + lw_dhcp_server = __s; + (__s->start).addr = start->addr; + (__s->end).addr = end->addr; + (__s->current).addr = start->addr; + puVar1 = udp_new(); + __s->pcb = puVar1; + if (puVar1 != (udp_pcb *)0x0) { + puVar1->so_options = puVar1->so_options | 0x20; + udp_bind(__s->pcb,&ip_addr_any,0x43); + udp_recv(__s->pcb,dhcp_server_recv,__s); + return '\0'; + } + } + return -1; +} + + + +err_t dhcp_server_stop(netif *netif) + +{ + dhcp_server *pdVar1; + + pdVar1 = lw_dhcp_server; + while( true ) { + if (pdVar1 == (dhcp_server *)0x0) { + printf("[DHCP] [DHCPD] CRITICAL: no dhcp_server instance found\r\n"); + return -6; + } + if (pdVar1->netif == netif) break; + pdVar1 = pdVar1->next; + } + if (pdVar1->pcb != (udp_pcb *)0x0) { + udp_remove(pdVar1->pcb); + } + lw_dhcp_server = (dhcp_server *)0x0; + mem_free(pdVar1); + return '\0'; +} + + + +void dhcpd_start(netif *netif) + +{ + err_t eVar1; + char *fmt; + undefined3 extraout_var; + ip4_addr_t *piVar2; + ip4_addr_t iStack60; + ip4_addr_t ip_start; + ip4_addr_t ip_end; + char str_tmp [20]; + + dhcp_stop(netif); + set_if(netif,"192.168.169.1","0.0.0.0","255.255.255.0"); + netif_set_up(netif); + memcpy(&ip_end,"192.168.169.1",0xe); + fmt = strchr((char *)&ip_end,0x2e); + if (((fmt == (char *)0x0) || (fmt = strchr(fmt + 1,0x2e), fmt == (char *)0x0)) || + (fmt = strchr(fmt + 1,0x2e), fmt == (char *)0x0)) { + piVar2 = &ip_end; + fmt = "[DHCP] DHCPD_SERVER_IP: %s error!\r\n"; + } + else { + sprintf(fmt + 1,"%d",2); + ip4addr_aton((char *)&ip_end,&iStack60); + printf("[DHCP] ip_start: [%s]\r\n",&ip_end); + sprintf(fmt + 1,"%d",0xfe); + ip4addr_aton((char *)&ip_end,&ip_start); + printf("[DHCP] ip_start: [%s]\r\n",&ip_end); + eVar1 = dhcp_server_start(netif,&iStack60,&ip_start); + piVar2 = (ip4_addr_t *)CONCAT31(extraout_var,eVar1); + if (piVar2 == (ip4_addr_t *)0x0) { + return; + } + fmt = "[DHCP] dhcp_server_start res: %d.\r\n"; + } + printf(fmt,piVar2); + return; +} + + + +void iperf_server_udp_entry(char *name) + +{ + size_t sVar1; + char *__dest; + + sVar1 = strlen(name); + __dest = (char *)pvPortMalloc(sVar1 + 1); + strcpy(__dest,name); + aos_task_new("ipus",iperf_server_udp,__dest,0x1000); + return; +} + + + +void iperf_client_udp_entry(char *name) + +{ + size_t sVar1; + char *__dest; + + sVar1 = strlen(name); + __dest = (char *)pvPortMalloc(sVar1 + 4); + strcpy(__dest,name); + aos_task_new("ipu",iperf_client_udp,__dest,0x1000); + return; +} + + + +void iperf_server_entry(char *name) + +{ + size_t sVar1; + char *__dest; + + sVar1 = strlen(name); + __dest = (char *)pvPortMalloc(sVar1 + 4); + strcpy(__dest,name); + aos_task_new("ips",iperf_server,__dest,0x1000); + return; +} + + + +void iperf_client_tcp_entry(char *name) + +{ + size_t sVar1; + char *__dest; + + sVar1 = strlen(name); + __dest = (char *)pvPortMalloc(sVar1 + 4); + strcpy(__dest,name); + aos_task_new("ipc",iperf_client_tcp,__dest,0x1000); + return; +} + + + +// WARNING: Control flow encountered bad instruction data + +void iperf_server_udp(void *arg) + +{ + err_t eVar1; + udp_pcb *pcb; + undefined3 extraout_var; + ip_addr_t iStack84; + ip_addr_t source_ip; + iperf_server_udp_ctx context; + + if (arg == (void *)0x0) { + vAssertCalled(); + } + pcb = udp_new(); + if (pcb == (udp_pcb *)0x0) { + printf("Create UDP Control block failed!\r\n"); + } + else { + iStack84 = (ip_addr_t)ipaddr_addr((char *)arg); + eVar1 = udp_bind(pcb,&iStack84,0x1389); + if (CONCAT31(extraout_var,eVar1) == 0) { + printf("bind UDP socket successfully!\r\n"); + memset(&source_ip,0,0x40); + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); + } + printf("Bind failed!\r\n"); + udp_remove(pcb); + } + vPortFree(arg); + return; +} + + + +// WARNING: Control flow encountered bad instruction data + +void iperf_server_udp_recv_fn(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port) + +{ + char speed [32]; + + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +// WARNING: Control flow encountered bad instruction data + +void iperf_client_udp(void *arg) + +{ + sockaddr_in laddr; + sockaddr_in raddr; + char speed [64]; + + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +// WARNING: Control flow encountered bad instruction data + +void iperf_server(void *arg) + +{ + uint32_t sin_size; + int flag; + sockaddr_in server_addr; + sockaddr_in client_addr; + char speed [32]; + + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +// WARNING: Control flow encountered bad instruction data + +void iperf_client_tcp(void *arg) + +{ + int flag; + sockaddr_in addr; + char speed [32]; + + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +void ipus_test_cmd(char *buf,int len,int argc,char **argv) + +{ + char *name; + + if (argc == 1) { + printf("[NET] [IPC] [IPUS] Connecting with default address 0.0.0.0\r\n"); + name = "0.0.0.0"; + } + else { + if (argc != 2) { + printf("[NET] [IPC] [IPUS] illegal address\r\n"); + return; + } + name = argv[1]; + } + iperf_server_udp_entry(name); + return; +} + + + +void ipu_test_cmd(char *buf,int len,int argc,char **argv) + +{ + char *name; + + if (argc == 1) { + printf("[NET] [IPC] [IPU] Connecting with default address 192.168.11.1\r\n"); + name = "192.168.11.1"; + } + else { + if (argc != 2) { + printf("[NET] [IPC] [IPU] illegal address\r\n"); + return; + } + name = argv[1]; + } + iperf_client_udp_entry(name); + return; +} + + + +void ipc_test_cmd(char *buf,int len,int argc,char **argv) + +{ + char *name; + + if (argc == 1) { + printf("[NET] [IPC] [IPC] Connecting with default address 192.168.11.1\r\n"); + name = "192.168.11.1"; + } + else { + if (argc != 2) { + printf("[NET] [IPC] [IPC] illegal address\r\n"); + return; + } + name = argv[1]; + } + iperf_client_tcp_entry(name); + return; +} + + + +void ips_test_cmd(char *buf,int len,int argc,char **argv) + +{ + char *name; + + if (argc == 1) { + puts("[NET] [IPC] [IPS] Starting iperf server on 0.0.0.0\r\n"); + name = "192.168.11.1"; + } + else { + if (argc != 2) { + printf("[NET] [IPC] [IPS] illegal address\r\n"); + return; + } + name = argv[1]; + } + iperf_server_entry(name); + return; +} + + + +int network_netutils_iperf_cli_register(void) + +{ + return 0; +} + + + +int dirent_type(void *addr) + +{ + int iVar1; + byte bVar2; + + bVar2 = *(byte *)((int)addr + 3) & 7; + if ((*(byte *)((int)addr + 3) & 7) == 0) { + iVar1 = 0; + } + else { + iVar1 = 2; + if ((bVar2 != 2) && (iVar1 = 3, bVar2 == 1)) { + return 1; + } + } + return iVar1; +} + + + +uint32_t dirent_hardfh(void *addr) + +{ + uint uVar1; + + uVar1 = *(uint *)addr; + return uVar1 << 0x18 | uVar1 >> 0x18 & 0xfffffff0 | (uVar1 & 0xff00) << 8 | uVar1 >> 8 & 0xff00; +} + + + +uint32_t dirent_childaddr(void *addr) + +{ + uint uVar1; + + uVar1 = *(uint *)((int)addr + 4); + return uVar1 << 0x18 | uVar1 >> 0x18 & 0xfffffff0 | (uVar1 & 0xff00) << 8 | uVar1 >> 8 & 0xff00; +} + + + +uint32_t dirent_size(void *addr) + +{ + uint uVar1; + + uVar1 = *(uint *)((int)addr + 8); + return uVar1 << 0x18 | uVar1 >> 0x18 | (uVar1 & 0xff00) << 8 | uVar1 >> 8 & 0xff00; +} + + + +int romfs_close(file_t *fp) + +{ + fp->f_arg = (void *)0x0; + fp->offset = 0; + return -1; +} + + + +int romfs_ioctl(file_t *fp,int cmd,ulong arg) + +{ + size_t sVar1; + uint32_t uVar2; + int iVar3; + void *pvVar4; + + iVar3 = -2; + if (((fp != (file_t *)0x0) && (arg != 0)) && (iVar3 = -3, cmd == 1)) { + pvVar4 = fp->f_arg; + sVar1 = strlen((char *)((int)pvVar4 + 0x10)); + *(size_t *)arg = (sVar1 + 0x10 & 0xfffffff0) + 0x10 + (int)pvVar4; + uVar2 = dirent_size(fp->f_arg); + *(uint32_t *)(arg + 4) = uVar2; + return 0; + } + return iVar3; +} + + + +ssize_t romfs_read(file_t *fp,char *buf,size_t length) + +{ + size_t sVar1; + uint32_t uVar2; + uint uVar3; + void *__src; + + __src = fp->f_arg; + sVar1 = strlen((char *)((int)__src + 0x10)); + uVar2 = dirent_size(fp->f_arg); + uVar3 = fp->offset; + if (uVar3 < uVar2) { + __src = (void *)((sVar1 + 0x10 & 0xfffffff0) + 0x10 + uVar3 + (int)__src); + if (uVar3 + length < uVar2) { + memcpy(buf,__src,length); + fp->offset = fp->offset + length; + } + else { + length = uVar2 - uVar3; + memcpy(buf,__src,length); + fp->offset = uVar2; + } + } + else { + length = 0; + } + return length; +} + + + +undefined4 file_info(char *param_1,char **param_2,char **param_3) + +{ + char *addr; + char *pcVar1; + char *pcVar2; + size_t __n; + int iVar3; + uint32_t uVar4; + TickType_t TVar5; + + addr = *param_2; + pcVar1 = *param_3; + __n = strlen(param_1); + if (__n < 0x41) { + if (romfs_root == addr) { + __n = strlen(addr + 0x10); + addr = addr + (__n + 0x10 & 0xfffffff0) + 0x50; + } + do { + iVar3 = dirent_type(addr); + if (iVar3 == 1) { + __n = strlen(param_1); + iVar3 = memcmp(param_1,addr + 0x10,__n); + if ((iVar3 == 0) && (__n = strlen(param_1), addr[__n + 0x10] == '\0')) { + uVar4 = dirent_hardfh(addr); + pcVar2 = romfs_root; + if (uVar4 == 0) goto LAB_23078418; +LAB_23078416: + pcVar1 = pcVar2 + uVar4; +LAB_23078418: + *param_2 = addr; + *param_3 = pcVar1; + return 0; + } + } + else { + if (iVar3 == 2) { + __n = strlen(param_1); + iVar3 = memcmp(param_1,addr + 0x10,__n); + if ((iVar3 == 0) && (__n = strlen(param_1), pcVar2 = romfs_root, addr[__n + 0x10] == '\0') + ) { + uVar4 = dirent_hardfh(addr); + goto LAB_23078416; + } + } + else { + if (iVar3 != 0) { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + iVar3 = dirent_type(addr); + bl_printk("[%10u][%s: %s:%4d] addr_start = %p, dirent_type(addr_start) = %d\r\n",TVar5, + &DAT_230a9dd8,"bl_romfs.c",0xe6,addr,iVar3); + log_buf_out("bl_romfs.c",0xe7,addr,8,LOG_BUF_OUT_DATA_TYPE_HEX); + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] unknow the dirent_type.\r\n",&DAT_230a9dd8,"bl_romfs.c", + 0xe8); + return 0xffffffff; + } + } + } + pcVar2 = romfs_root; + uVar4 = dirent_hardfh(addr); + addr = pcVar2 + uVar4; + } while (addr < pcVar1); + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] start >= end, not found path = %s, addr_start = %p, addr_end = %p\r\n" + ,&DAT_230c03d4,"bl_romfs.c",0xef,param_1,addr,pcVar1); + } + return 0xffffffff; +} + + + +int romfs_closedir(file_t *fp,aos_dir_t *dir) + +{ + if (dir != (aos_dir_t *)0x0) { + aos_free(dir); + return 0; + } + return -1; +} + + + +off_t romfs_lseek(file_t *fp,off_t off,int whence) + +{ + size_t sVar1; + uint32_t uVar2; + + if (fp == (file_t *)0x0) { + return -1; + } + uVar2 = dirent_size(fp->f_arg); + if (whence == 0) { + if (off < 0) { + printf("not support whence.\r\n"); + return -2; + } + } + else { + if (whence == 2) { + sVar1 = uVar2; + if (0 < off) { + printf("not support whence.\r\n"); + return -3; + } + } + else { + if (whence != 1) { + printf("not support whence.\r\n"); + return -4; + } + sVar1 = fp->offset; + } + off = off + sVar1; + if (off < 0) goto LAB_230785b6; + } + if ((uint)off <= uVar2) { + fp->offset = off; + return off; + } +LAB_230785b6: + printf("not support whence.\r\n"); + return -5; +} + + + +aos_dirent_t * romfs_readdir(file_t *fp,aos_dir_t *dir) + +{ + uint32_t uVar1; + int iVar2; + char *pcVar3; + uint uVar4; + void *addr; + void *addr_00; + + if (dir == (aos_dir_t *)0x0) { + return (aos_dirent_t *)0x0; + } +LAB_23078622: + do { + pcVar3 = romfs_root; + if ((void *)dir[2].dd_vfs_fd == (void *)0x0) { + dir[2].dd_vfs_fd = dir[1].dd_vfs_fd; + } + else { + addr_00 = (void *)dir[1].dd_rsv; + if (addr_00 <= (void *)dir[2].dd_vfs_fd) { + return (aos_dirent_t *)0x0; + } + while( true ) { + addr = (void *)dir[2].dd_vfs_fd; + if (addr_00 <= addr) { + return (aos_dirent_t *)0x0; + } + uVar1 = dirent_hardfh(addr); + if (uVar1 == 0) break; + if (addr == (void *)0x0) { + return (aos_dirent_t *)0x0; + } + iVar2 = dirent_type(addr); + if (iVar2 - 1U < 2) break; + *(char **)&dir[2].dd_vfs_fd = pcVar3 + uVar1; + } + } + strncpy((char *)((int)&dir[3].dd_vfs_fd + 1),(char *)(dir[2].dd_vfs_fd + 0x10),0x40); + addr_00 = (void *)dir[2].dd_vfs_fd; + *(undefined *)((int)&dir[0xb].dd_vfs_fd + 1) = 0; + uVar1 = dirent_hardfh(addr_00); + if (uVar1 == 0) { + pcVar3 = (char *)dir[1].dd_rsv; + } + else { + pcVar3 = romfs_root + uVar1; + } + *(char **)&dir[2].dd_vfs_fd = pcVar3; + uVar4 = dir[3].dd_vfs_fd & 0xffff00; + if (uVar4 == 0x2e2e00) { + if (*(char *)((int)&dir[3].dd_vfs_fd + 3) != '\0') goto LAB_23078658; + goto LAB_23078622; + } + if (uVar4 != 0x2e00) { +LAB_23078658: + return (aos_dirent_t *)&dir[2].dd_rsv; + } + } while( true ); +} + + + +uint32_t dirent_file(char *path,void **p_addr_start_input,void **p_addr_end_input) + +{ + bool bVar1; + char *pcVar2; + size_t __n; + size_t sVar3; + int iVar4; + TickType_t TVar5; + char *format; + char *pcVar6; + uint32_t uVar7; + undefined4 uVar8; + uint uVar9; + char *pcStack124; + char *addr_start; + char *addr_end; + char name [65]; + + __n = strlen(path); + sVar3 = strlen("/romfs"); + if (sVar3 <= __n) { + __n = strlen("/romfs"); + iVar4 = memcmp(path,"/romfs",__n); + if (iVar4 == 0) { + __n = strlen("/romfs"); + path = path + __n; + if (*path == '/') { + path = path + 1; +LAB_23078778: + bVar1 = false; + uVar9 = *(uint *)(romfs_root + 8); + pcStack124 = romfs_root; + addr_start = romfs_root + + (uVar9 >> 8 & 0xff00 | uVar9 << 0x18 | uVar9 >> 0x18 | (uVar9 & 0xff00) << 8); + do { + if (*path == '\0') { +LAB_230788ce: + *(char **)p_addr_start_input = pcStack124; + *(char **)p_addr_end_input = addr_start; + return 0; + } + pcVar6 = strchr(path,0x2f); + pcVar2 = pcStack124; + format = romfs_root; + if (bVar1) { + uVar7 = dirent_childaddr(pcStack124); + pcStack124 = format + uVar7; + if (pcVar2 == pcStack124) { + return 0xfffffffe; + } + } + if (pcVar6 == (char *)0x0) { + __n = strlen(path); + if (0x40 < __n) { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + uVar8 = 0x138; + format = "[%10u][%s: %s:%4d] name too long!\r\n"; + goto LAB_23078736; + } + iVar4 = file_info(path,&pcStack124,&addr_start); + if (iVar4 != 0) { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] file info error, p_name = %s, addr_start = %p, addr_end = %p\r\n" + ,TVar5,&DAT_230c03d4,"bl_romfs.c",0x13c,path,pcStack124,addr_start); + return 0xffffffff; + } + goto LAB_230788ce; + } + memset(&addr_end,0,0x41); + memcpy(&addr_end,path,(size_t)(pcVar6 + -(int)path)); + iVar4 = file_info(&addr_end,&pcStack124,&addr_start); + if (iVar4 != 0) { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + uVar8 = 0x147; + format = "[%10u][%s: %s:%4d] file info error.\r\n"; + goto LAB_23078736; + } + path = pcVar6 + 1; + bVar1 = true; + } while( true ); + } + if (*path == '\0') goto LAB_23078778; + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + uVar8 = 0x11a; + } + else { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + uVar8 = 0x115; + } + format = "[%10u][%s: %s:%4d] not support path.\r\n"; +LAB_23078736: + bl_printk(format,TVar5,&DAT_230a9dd8,"bl_romfs.c",uVar8); + } + return 0xffffffff; +} + + + +// WARNING: Variable defined which should be unmapped: end_addr + +aos_dir_t * romfs_opendir(file_t *fp,char *path) + +{ + char *pcVar1; + TickType_t TVar2; + aos_dir_t *__s; + uint32_t uVar3; + size_t sVar4; + char *pcStack24; + char *start_addr; + char *end_addr; + + if (romfs_root == (char *)0x0) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] romfs_root is null.\r\n",TVar2,&DAT_230a9dd8,"bl_romfs.c",0x20d); + return (aos_dir_t *)0x0; + } + __s = (aos_dir_t *)aos_malloc(0x5d); + if (__s != (aos_dir_t *)0x0) { + memset(__s,0,0x5d); + uVar3 = dirent_file(path,&pcStack24,&start_addr); + pcVar1 = romfs_root; + if (uVar3 == 0) { + if (pcStack24 == romfs_root) { + sVar4 = strlen(pcStack24 + 0x10); + *(char **)&__s[1].dd_vfs_fd = pcStack24 + (sVar4 + 0x10 & 0xfffffff0) + 0x50; + } + else { + uVar3 = dirent_childaddr(pcStack24); + if (uVar3 == 0) { + return (aos_dir_t *)0x0; + } + *(char **)&__s[1].dd_vfs_fd = pcVar1 + uVar3; + } + __s[2].dd_vfs_fd = 0; + *(char **)&__s[1].dd_rsv = start_addr; + return __s; + } + aos_free(__s); + } + return (aos_dir_t *)0x0; +} + + + +// WARNING: Variable defined which should be unmapped: end_addr + +int romfs_stat(file_t *fp,char *path,stat *st) + +{ + char *addr; + uint32_t uVar1; + TickType_t TVar2; + int iVar3; + uint32_t uVar4; + mode_t mVar5; + char *pcStack24; + char *start_addr; + char *end_addr; + + pcStack24 = (char *)0x0; + start_addr = (char *)0x0; + uVar1 = dirent_file(path,&pcStack24,&start_addr); + addr = pcStack24; + if (uVar1 == 0) { + if (pcStack24 == romfs_root) { + st->st_size = 0; + } + else { + iVar3 = dirent_type(pcStack24); + if (iVar3 == 1) { + st->st_size = 0; + mVar5 = 0x4000; + } + else { + if (iVar3 != 2) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] dirent_type err.\r\n",TVar2,&DAT_230c03d4,"bl_romfs.c",0x1fa + ); + return -2; + } + uVar4 = dirent_size(addr); + st->st_size = uVar4; + mVar5 = 0x8000; + } + st->st_mode = mVar5; + } + } + else { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] dirent_file res = %d\r\n",TVar2,&DAT_230c03d4,"bl_romfs.c",0x1ea, + uVar1); + uVar1 = 0xffffffff; + } + return uVar1; +} + + + +int romfs_open(file_t *fp,char *path,int flags) + +{ + bool bVar1; + char cVar2; + TickType_t TVar3; + char *format; + size_t sVar4; + size_t __n; + int iVar5; + uint32_t uVar6; + undefined4 uVar7; + size_t unaff_s4; + void *pvStack40; + char *start_addr; + char *end_addr; + + if (romfs_root == (char *)0x0) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar7 = 0x162; + format = "[%10u][%s: %s:%4d] romfs_root is null.\r\n"; + } + else { + sVar4 = strlen(path); + __n = strlen("/romfs"); + iVar5 = strncmp(path,"/romfs",__n); + if (iVar5 == 0) { + __n = 0; + do { + if (sVar4 == __n) { + uVar6 = dirent_file(path,&pvStack40,&start_addr); + if (uVar6 != 0) { + return -2; + } + fp->offset = 0; + fp->f_arg = pvStack40; + return 0; + } + cVar2 = path[__n]; + if (0x19 < (byte)(cVar2 + 0x9fU)) { + if (((byte)(cVar2 + 0xbfU) < 0x1a) || ((byte)(cVar2 - 0x30U) < 10)) { + if (cVar2 == '/') goto LAB_23078c2e; + } + else { + if (cVar2 == '/') { +LAB_23078c2e: + if (__n == 0) { + unaff_s4 = 0; + } + else { + bVar1 = __n == unaff_s4; + unaff_s4 = __n; + if (bVar1) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar7 = 0x73; + format = "[%10u][%s: %s:%4d] format error.\r\n"; + goto LAB_23078b74; + } + } + } + else { + if ((cVar2 != '_') && (1 < (byte)(cVar2 - 0x2dU))) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] is_path_ch. i = %d\r\n",TVar3,&DAT_230a9dd8, + "bl_romfs.c",0x69,__n); + goto LAB_23078c00; + } + } + } + } + __n = __n + 1; + } while( true ); + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar7 = 0x61; + format = "[%10u][%s: %s:%4d] format is error.\r\n"; +LAB_23078b74: + bl_printk(format,TVar3,&DAT_230a9dd8,"bl_romfs.c",uVar7); +LAB_23078c00: + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar7 = 0x168; + format = "[%10u][%s: %s:%4d] path format is error.\r\n"; + } + bl_printk(format,TVar3,&DAT_230a9dd8,"bl_romfs.c",uVar7); + return -1; +} + + + +// WARNING: Variable defined which should be unmapped: info + +int romfs_register(void) + +{ + uint __s1; + int iVar1; + TickType_t TVar2; + char *format; + size_t __n; + undefined4 uVar3; + undefined auStack44 [4]; + bl_mtd_info_t info; + + iVar1 = bl_mtd_open("media",&handle_romfs,2); + if (iVar1 == 0) { + memset(auStack44,0,0x1c); + bl_mtd_info(handle_romfs,(bl_mtd_info_t *)auStack44); + __s1 = info.size; + if ((void *)info.size == (void *)0x0) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar3 = 0x8d; + format = "[%10u][%s: %s:%4d] romfs has no XIP-Addr\r\n"; + } + else { + __n = strlen("-rom1fs-"); + iVar1 = memcmp((void *)__s1,"-rom1fs-",__n); + if (iVar1 == 0) { + romfs_root = (char *)info.size; + log_buf_out("bl_romfs.c",0x98,(void *)info.size,0x40,LOG_BUF_OUT_DATA_TYPE_HEX); + iVar1 = aos_register_fs("/romfs",&romfs_ops,(void *)0x0); + return iVar1; + } + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar3 = 0x92; + format = "[%10u][%s: %s:%4d] romfs magic is NOT correct\r\n"; + } + bl_printk(format,TVar2,&DAT_230a9dd8,"bl_romfs.c",uVar3); + } + else { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [EF] [PART] [XIP] error when get romfs partition %d\r\n",TVar2, + &DAT_230a9dd8,"bl_romfs.c",0x86,iVar1); + } + return -1; +} + + + +void _startup_sntp(void *arg) + +{ + puts("--------------------------------------- Start NTP now\r\n"); + sntp_setoperatingmode('\0'); + sntp_setservername('\0',"0.asia.pool.ntp.org"); + sntp_init(); + puts("--------------------------------------- Start NTP Done\r\n"); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void cmd_sntp_date(char *buf,int len,int argc,char **argv) + +{ + uint32_t uStack44; + uint32_t seconds; + uint32_t frags; + utils_time_date_t date; + + uStack44 = 0; + seconds = 0; + puts("test epoch from 1581863713 --->>>\r\n"); + puts("Should be Sunday, February 16, 2020 2:35:13 PM\r\n"); + utils_time_date_from_epoch(0x5e495321,&frags); + printf("Date & time is: %u-%02u-%02u %02u:%02u:%02u (Day %u of week, Day %u of Year)\r\n", + date._4_4_,(uint)date.ntp_minute,(uint)date.ntp_hour,(uint)(byte)frags,(uint)frags._1_1_, + (uint)frags._2_1_,(uint)frags._3_1_); + puts("SNTP GMT time is\r\n"); + sntp_get_time(&uStack44,&seconds); + utils_time_date_from_epoch(uStack44,&frags); + printf("Date & time is: %u-%02u-%02u %02u:%02u:%02u (Day %u of week, Day %u of Year)\r\n", + date._4_4_,(uint)date.ntp_minute,(uint)date.ntp_hour,(uint)(byte)frags,(uint)frags._1_1_, + (uint)frags._2_1_,(uint)frags._3_1_); + return; +} + + + +void cmd_sntp_time(char *buf,int len,int argc,char **argv) + +{ + uint32_t uStack24; + uint32_t seconds; + uint32_t frags; + + uStack24 = 0; + seconds = 0; + sntp_get_time(&uStack24,&seconds); + printf("[NTP] time is %lu:%lu\r\n",uStack24,seconds); + return; +} + + + +void cmd_sntp_start(char *buf,int len,int argc,char **argv) + +{ + tcpip_callback(_startup_sntp,(void *)0x0); + return; +} + + + +int sntp_cli_init(void) + +{ + return 0; +} + + + +void sntp_retry(void *arg) + +{ + uint uVar1; + + sys_timeout(sntp_retry_timeout,sntp_request,(void *)0x0); + uVar1 = sntp_retry_timeout << 1; + if ((uVar1 < 0x249f1) && (sntp_retry_timeout < uVar1)) { + sntp_retry_timeout = uVar1; + } + return; +} + + + +void sntp_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port) + +{ + int iVar1; + byte bVar2; + u8_t uVar3; + undefined3 extraout_var; + u32_t uVar4; + u32_t uVar5; + uint uVar6; + undefined2 in_register_0000203a; + u32_t uStack40; + sntp_timestamps timestamps; + + printf("SNTP time now\r\n",CONCAT22(in_register_0000203a,port)); + iVar1 = -0x10; + if (p->tot_len == 0x30) { + bVar2 = pbuf_get_at(p,0); + if (sntp_opmode == '\0') { + iVar1 = -3; + if ((bVar2 & 7) != 4) goto LAB_23078f70; + } + else { + iVar1 = -3; + if ((sntp_opmode != '\x01') || ((bVar2 & 7) != 5)) goto LAB_23078f70; + } + uVar3 = pbuf_get_at(p,1); + if (CONCAT31(extraout_var,uVar3) == 0) { + printf("sntp_recv: Received Kiss-of-Death\r\n"); + iVar1 = 1; + } + else { + pbuf_copy_partial(p,&uStack40,8,0x28); + iVar1 = 0; + } + } +LAB_23078f70: + pbuf_free(p); + printf("Try process\r\n"); + if (iVar1 == 0) { + uVar4 = lwip_htonl(uStack40); + uVar5 = lwip_htonl(timestamps.xmit.sec); + printf("Processing...\r\n"); + vTaskEnterCritical(); + ntp_frag = uVar5; + ntp_sec = uVar4 + 0x7c558180; + time_obtained = xTaskGetTickCount(); + uVar6 = ntp_frag / 1000 + ntp_sec * 1000; + bl_sys_time_update(uVar6,(int)((ulonglong)ntp_sec * 1000 >> 0x20) + + (uint)(uVar6 < ntp_sec * 1000)); + vTaskExitCritical(); + printf("sntp_process: %ld, %lu us\r\n",uVar4 + 0x7c558180, + (int)((ulonglong)uVar5 * 1000000 >> 0x20)); + sntp_servers[0].reachability = sntp_servers[0].reachability | 1; + if (sntp_opmode == '\0') { + sys_untimeout(sntp_retry,(void *)0x0); + sys_untimeout(sntp_request,(void *)0x0); + sntp_retry_timeout = 15000; + sys_timeout(3600000,sntp_request,(void *)0x0); + } + } + else { + if ((iVar1 == 1) && (sntp_opmode == '\0')) { + sntp_retry((void *)0x0); + } + } + return; +} + + + +void sntp_send_request(ip_addr_t *server_addr) + +{ + undefined *__s; + pbuf *p; + code *handler; + + p = pbuf_alloc(PBUF_TRANSPORT,0x30,PBUF_RAM); + if (p == (pbuf *)0x0) { + handler = sntp_request; + } + else { + __s = (undefined *)p->payload; + memset(__s,0,0x30); + *__s = 0x23; + udp_sendto(sntp_pcb,p,server_addr,0x7b); + pbuf_free(p); + sntp_servers[0].reachability = sntp_servers[0].reachability << 1; + handler = sntp_retry; + } + sys_timeout(15000,handler,(void *)0x0); + return; +} + + + +void sntp_request(void *arg) + +{ + err_t eVar1; + undefined3 extraout_var; + ip_addr_t iStack20; + ip_addr_t sntp_server_address; + + if (sntp_servers[0].name == (char *)0x0) { + iStack20 = (ip_addr_t)sntp_servers[0].addr; + if (sntp_servers[0].addr == 0) goto LAB_2307917a; + } + else { + sntp_servers[0].addr = 0; + eVar1 = dns_gethostbyname(sntp_servers[0].name,&iStack20,sntp_dns_found,(void *)0x0); + if (CONCAT31(extraout_var,eVar1) == -5) { + return; + } + if (CONCAT31(extraout_var,eVar1) != 0) { +LAB_2307917a: + sys_timeout(15000,sntp_retry,(void *)0x0); + return; + } + } + sntp_servers[0].addr = (u32_t)iStack20; + sntp_send_request(&iStack20); + return; +} + + + +void sntp_dns_found(char *hostname,ip_addr_t *ipaddr,void *arg) + +{ + if (ipaddr != (ip_addr_t *)0x0) { + sntp_servers[0].addr = ipaddr->addr; + sntp_send_request(ipaddr); + return; + } + sntp_retry((void *)0x0); + return; +} + + + +void sntp_init(void) + +{ + udp_pcb *pcb; + uint uVar1; + + if (sntp_pcb == (udp_pcb *)0x0) { + sntp_pcb = udp_new_ip_type(); + printf("[SNTP] pcb isready, %p\r\n"); + if (sntp_pcb != (udp_pcb *)0x0) { + udp_recv(sntp_pcb,sntp_recv,(void *)0x0); + pcb = sntp_pcb; + if (sntp_opmode == '\0') { + sntp_retry_timeout = 15000; + uVar1 = bl_rand(); + sys_timeout(uVar1 % 5000,sntp_request,(void *)0x0); + return; + } + if (sntp_opmode == '\x01') { + sntp_pcb->so_options = sntp_pcb->so_options | 0x20; + udp_bind(pcb,&ip_addr_any,0x7b); + return; + } + } + } + return; +} + + + +void sntp_setoperatingmode(u8_t operating_mode) + +{ + sntp_opmode = operating_mode; + return; +} + + + +int sntp_get_time(uint32_t *seconds,uint32_t *frags) + +{ + TickType_t TVar1; + int iVar2; + uint uVar3; + + vTaskEnterCritical(); + if (ntp_sec == 0) { + *seconds = 0; + *frags = 0; + } + else { + TVar1 = xTaskGetTickCount(); + iVar2 = TVar1 - time_obtained; + uVar3 = ntp_frag / 1000; + *seconds = iVar2 / 1000 + ntp_sec; + *frags = iVar2 % 1000 + uVar3; + } + vTaskExitCritical(); + return 0; +} + + + +void sntp_setservername(u8_t idx,char *server) + +{ + undefined3 in_register_00002029; + + if (CONCAT31(in_register_00002029,idx) == 0) { + sntp_servers[0].name = server; + } + return; +} + + + +void utils_sha256_init(iot_sha256_context *ctx) + +{ + memset(ctx,0,0x6c); + return; +} + + + +void utils_sha256_free(iot_sha256_context *ctx) + +{ + iot_sha256_context *piVar1; + + piVar1 = ctx + 1; + if (ctx != (iot_sha256_context *)0x0) { + while (ctx != piVar1) { + *(undefined *)ctx->total = 0; + ctx = (iot_sha256_context *)((int)ctx->total + 1); + } + } + return; +} + + + +void utils_sha256_starts(iot_sha256_context *ctx) + +{ + ctx->state[0] = 0x6a09e667; + ctx->state[1] = 0xbb67ae85; + ctx->state[2] = 0x3c6ef372; + ctx->state[3] = 0xa54ff53a; + ctx->state[4] = 0x510e527f; + ctx->state[5] = 0x9b05688c; + ctx->state[6] = 0x1f83d9ab; + ctx->total[0] = 0; + ctx->total[1] = 0; + ctx->state[7] = 0x5be0cd19; + ctx->is224 = 0; + return; +} + + + +void utils_sha256_process(iot_sha256_context *ctx,uchar *data) + +{ + uint uVar1; + uint32_t *puVar2; + byte *pbVar3; + byte *pbVar4; + uint uVar5; + uint uVar6; + uint32_t uVar7; + uint uVar8; + uint32_t *puVar9; + uint uVar10; + uint32_t *puVar11; + uint uVar12; + int iVar13; + uint uVar14; + uint uVar15; + uint uVar16; + uint uVar17; + uint32_t *puVar18; + uint uVar19; + uint uVar20; + uint uVar21; + uint32_t *puVar22; + uint uVar23; + uint32_t uVar24; + uint uVar25; + uint32_t *puVar26; + uint32_t uVar27; + uint32_t local_150; + uint32_t A [8]; + uint32_t W [64]; + + puVar18 = &local_150; + puVar9 = &local_150; + puVar11 = ctx->state; + do { + uVar7 = *puVar11; + puVar11 = puVar11 + 1; + *puVar9 = uVar7; + puVar9 = puVar9 + 1; + } while ((uint32_t *)ctx->buffer != puVar11); + puVar11 = A + 7; + pbVar3 = data; + puVar9 = puVar11; + do { + pbVar4 = pbVar3 + 4; + *puVar9 = (uint)*pbVar3 << 0x18 | (uint)pbVar3[1] << 0x10 | (uint)pbVar3[3] | + (uint)pbVar3[2] << 8; + pbVar3 = pbVar4; + puVar9 = puVar9 + 1; + } while (data + 0x40 != pbVar4); + puVar2 = K; + puVar9 = K; + puVar26 = puVar11; + do { + puVar22 = puVar9 + 8; + iVar13 = A[6] + ((A[3] >> 6 | A[3] << 0x1a) ^ (A[3] >> 0xb | A[3] << 0x15) ^ + (A[3] << 7 | A[3] >> 0x19)) + *puVar9 + *puVar26 + ((A[5] ^ A[4]) & A[3] ^ A[5]) + ; + uVar12 = A[2] + iVar13; + uVar14 = iVar13 + ((local_150 >> 2 | local_150 << 0x1e) ^ (local_150 >> 0xd | local_150 << 0x13) + ^ (local_150 << 10 | local_150 >> 0x16)) + + ((local_150 | A[0]) & A[1] | local_150 & A[0]); + iVar13 = ((uVar12 >> 6 | uVar12 * 0x4000000) ^ (uVar12 >> 0xb | uVar12 * 0x200000) ^ + (uVar12 * 0x80 | uVar12 >> 0x19)) + + A[5] + puVar9[1] + puVar26[1] + ((A[3] ^ A[4]) & uVar12 ^ A[4]); + uVar1 = ((uVar14 >> 2 | uVar14 * 0x40000000) ^ (uVar14 >> 0xd | uVar14 * 0x80000) ^ + (uVar14 * 0x400 | uVar14 >> 0x16)) + ((uVar14 | local_150) & A[0] | uVar14 & local_150) + + iVar13; + uVar10 = A[1] + iVar13; + iVar13 = ((uVar10 >> 6 | uVar10 * 0x4000000) ^ (uVar10 >> 0xb | uVar10 * 0x200000) ^ + (uVar10 * 0x80 | uVar10 >> 0x19)) + + A[4] + puVar9[2] + puVar26[2] + ((uVar12 ^ A[3]) & uVar10 ^ A[3]); + uVar5 = ((uVar1 >> 2 | uVar1 * 0x40000000) ^ (uVar1 >> 0xd | uVar1 * 0x80000) ^ + (uVar1 * 0x400 | uVar1 >> 0x16)) + ((uVar14 | uVar1) & local_150 | uVar14 & uVar1) + + iVar13; + uVar8 = A[0] + iVar13; + iVar13 = ((uVar8 >> 6 | uVar8 * 0x4000000) ^ (uVar8 >> 0xb | uVar8 * 0x200000) ^ + (uVar8 * 0x80 | uVar8 >> 0x19)) + + A[3] + puVar9[3] + puVar26[3] + ((uVar12 ^ uVar10) & uVar8 ^ uVar12); + uVar16 = ((uVar5 >> 2 | uVar5 * 0x40000000) ^ (uVar5 >> 0xd | uVar5 * 0x80000) ^ + (uVar5 * 0x400 | uVar5 >> 0x16)) + ((uVar1 | uVar5) & uVar14 | uVar1 & uVar5) + iVar13; + uVar6 = local_150 + iVar13; + iVar13 = ((uVar6 >> 6 | uVar6 * 0x4000000) ^ (uVar6 >> 0xb | uVar6 * 0x200000) ^ + (uVar6 * 0x80 | uVar6 >> 0x19)) + + uVar12 + puVar9[4] + puVar26[4] + ((uVar10 ^ uVar8) & uVar6 ^ uVar10); + A[2] = ((uVar16 >> 2 | uVar16 * 0x40000000) ^ (uVar16 >> 0xd | uVar16 * 0x80000) ^ + (uVar16 * 0x400 | uVar16 >> 0x16)) + ((uVar5 | uVar16) & uVar1 | uVar5 & uVar16) + iVar13 + ; + A[6] = uVar14 + iVar13; + iVar13 = ((A[6] >> 6 | A[6] * 0x4000000) ^ (A[6] >> 0xb | A[6] * 0x200000) ^ + (A[6] * 0x80 | A[6] >> 0x19)) + + uVar10 + puVar9[5] + puVar26[5] + ((uVar8 ^ uVar6) & A[6] ^ uVar8); + A[1] = ((A[2] >> 2 | A[2] * 0x40000000) ^ (A[2] >> 0xd | A[2] * 0x80000) ^ + (A[2] * 0x400 | A[2] >> 0x16)) + ((uVar16 | A[2]) & uVar5 | uVar16 & A[2]) + iVar13; + A[5] = uVar1 + iVar13; + iVar13 = ((A[5] >> 6 | A[5] * 0x4000000) ^ (A[5] >> 0xb | A[5] * 0x200000) ^ + (A[5] * 0x80 | A[5] >> 0x19)) + + uVar8 + puVar9[6] + puVar26[6] + ((uVar6 ^ A[6]) & A[5] ^ uVar6); + A[0] = ((A[1] >> 2 | A[1] * 0x40000000) ^ (A[1] >> 0xd | A[1] * 0x80000) ^ + (A[1] * 0x400 | A[1] >> 0x16)) + ((A[2] | A[1]) & uVar16 | A[2] & A[1]) + iVar13; + A[4] = uVar5 + iVar13; + iVar13 = ((A[4] >> 6 | A[4] * 0x4000000) ^ (A[4] >> 0xb | A[4] * 0x200000) ^ + (A[4] * 0x80 | A[4] >> 0x19)) + + uVar6 + puVar9[7] + puVar26[7] + ((A[6] ^ A[5]) & A[4] ^ A[6]); + A[3] = uVar16 + iVar13; + local_150 = ((A[0] >> 2 | A[0] * 0x40000000) ^ (A[0] >> 0xd | A[0] * 0x80000) ^ + (A[0] * 0x400 | A[0] >> 0x16)) + ((A[1] | A[0]) & A[2] | A[1] & A[0]) + iVar13; + puVar9 = puVar22; + puVar26 = puVar26 + 8; + } while (puVar22 != K + 0x10); + do { + uVar19 = puVar11[0xe]; + uVar1 = puVar11[1]; + uVar20 = puVar11[0xf]; + uVar23 = ((uVar19 << 0xf | uVar19 >> 0x11) ^ (uVar19 << 0xd | uVar19 >> 0x13) ^ uVar19 >> 10) + + puVar11[9] + *puVar11 + + ((uVar1 >> 7 | uVar1 << 0x19) ^ (uVar1 << 0xe | uVar1 >> 0x12) ^ uVar1 >> 3); + uVar10 = puVar11[3]; + iVar13 = A[6] + ((A[3] >> 6 | A[3] << 0x1a) ^ (A[3] >> 0xb | A[3] << 0x15) ^ + (A[3] << 7 | A[3] >> 0x19)) + ((A[5] ^ A[4]) & A[3] ^ A[5]) + puVar2[0x10] + + uVar23; + uVar16 = A[2] + iVar13; + uVar15 = iVar13 + ((local_150 >> 2 | local_150 << 0x1e) ^ (local_150 >> 0xd | local_150 << 0x13) + ^ (local_150 << 10 | local_150 >> 0x16)) + + ((local_150 | A[0]) & A[1] | local_150 & A[0]); + uVar6 = puVar11[2]; + uVar1 = ((uVar20 << 0xf | uVar20 >> 0x11) ^ (uVar20 << 0xd | uVar20 >> 0x13) ^ uVar20 >> 10) + + uVar1 + puVar11[10] + + ((uVar6 >> 7 | uVar6 << 0x19) ^ (uVar6 << 0xe | uVar6 >> 0x12) ^ uVar6 >> 3); + iVar13 = ((A[3] ^ A[4]) & uVar16 ^ A[4]) + A[5] + puVar2[0x11] + uVar1 + + ((uVar16 >> 6 | uVar16 * 0x4000000) ^ (uVar16 >> 0xb | uVar16 * 0x200000) ^ + (uVar16 * 0x80 | uVar16 >> 0x19)); + uVar5 = ((uVar15 >> 2 | uVar15 * 0x40000000) ^ (uVar15 >> 0xd | uVar15 * 0x80000) ^ + (uVar15 * 0x400 | uVar15 >> 0x16)) + ((local_150 | uVar15) & A[0] | local_150 & uVar15) + + iVar13; + uVar14 = A[1] + iVar13; + uVar6 = ((uVar23 * 0x8000 | uVar23 >> 0x11) ^ (uVar23 * 0x2000 | uVar23 >> 0x13) ^ uVar23 >> 10) + + uVar6 + puVar11[0xb] + + ((uVar10 >> 7 | uVar10 << 0x19) ^ (uVar10 << 0xe | uVar10 >> 0x12) ^ uVar10 >> 3); + iVar13 = ((A[3] ^ uVar16) & uVar14 ^ A[3]) + A[4] + puVar2[0x12] + uVar6 + + ((uVar14 >> 6 | uVar14 * 0x4000000) ^ (uVar14 >> 0xb | uVar14 * 0x200000) ^ + (uVar14 * 0x80 | uVar14 >> 0x19)); + puVar11[0x11] = uVar1; + uVar8 = ((uVar5 >> 2 | uVar5 * 0x40000000) ^ (uVar5 >> 0xd | uVar5 * 0x80000) ^ + (uVar5 * 0x400 | uVar5 >> 0x16)) + ((uVar15 | uVar5) & local_150 | uVar15 & uVar5) + + iVar13; + uVar12 = A[0] + iVar13; + uVar25 = puVar11[4]; + uVar1 = ((uVar1 * 0x8000 | uVar1 >> 0x11) ^ (uVar1 * 0x2000 | uVar1 >> 0x13) ^ uVar1 >> 10) + + uVar10 + puVar11[0xc] + + ((uVar25 >> 7 | uVar25 << 0x19) ^ (uVar25 << 0xe | uVar25 >> 0x12) ^ uVar25 >> 3); + iVar13 = ((uVar16 ^ uVar14) & uVar12 ^ uVar16) + A[3] + puVar2[0x13] + uVar1 + + ((uVar12 >> 6 | uVar12 * 0x4000000) ^ (uVar12 >> 0xb | uVar12 * 0x200000) ^ + (uVar12 * 0x80 | uVar12 >> 0x19)); + uVar17 = ((uVar8 >> 2 | uVar8 * 0x40000000) ^ (uVar8 >> 0xd | uVar8 * 0x80000) ^ + (uVar8 * 0x400 | uVar8 >> 0x16)) + ((uVar5 | uVar8) & uVar15 | uVar5 & uVar8) + iVar13; + uVar10 = local_150 + iVar13; + puVar11[0x12] = uVar6; + uVar21 = puVar11[5]; + uVar25 = ((uVar6 * 0x8000 | uVar6 >> 0x11) ^ (uVar6 * 0x2000 | uVar6 >> 0x13) ^ uVar6 >> 10) + + uVar25 + puVar11[0xd] + + ((uVar21 >> 7 | uVar21 << 0x19) ^ (uVar21 << 0xe | uVar21 >> 0x12) ^ uVar21 >> 3); + iVar13 = ((uVar10 >> 6 | uVar10 * 0x4000000) ^ (uVar10 >> 0xb | uVar10 * 0x200000) ^ + (uVar10 * 0x80 | uVar10 >> 0x19)) + + ((uVar14 ^ uVar12) & uVar10 ^ uVar14) + uVar16 + puVar2[0x14] + uVar25; + A[2] = ((uVar17 >> 2 | uVar17 * 0x40000000) ^ (uVar17 >> 0xd | uVar17 * 0x80000) ^ + (uVar17 * 0x400 | uVar17 >> 0x16)) + ((uVar8 | uVar17) & uVar5 | uVar8 & uVar17) + iVar13 + ; + A[6] = uVar15 + iVar13; + uVar6 = puVar11[6]; + puVar11[0x13] = uVar1; + uVar16 = ((uVar1 * 0x8000 | uVar1 >> 0x11) ^ (uVar1 * 0x2000 | uVar1 >> 0x13) ^ uVar1 >> 10) + + uVar19 + uVar21 + + ((uVar6 >> 7 | uVar6 << 0x19) ^ (uVar6 << 0xe | uVar6 >> 0x12) ^ uVar6 >> 3); + iVar13 = ((A[6] >> 6 | A[6] * 0x4000000) ^ (A[6] >> 0xb | A[6] * 0x200000) ^ + (A[6] * 0x80 | A[6] >> 0x19)) + + ((uVar12 ^ uVar10) & A[6] ^ uVar12) + uVar14 + puVar2[0x15] + uVar16; + A[1] = ((A[2] >> 2 | A[2] * 0x40000000) ^ (A[2] >> 0xd | A[2] * 0x80000) ^ + (A[2] * 0x400 | A[2] >> 0x16)) + ((uVar17 | A[2]) & uVar8 | uVar17 & A[2]) + iVar13; + A[5] = uVar5 + iVar13; + uVar1 = puVar11[7]; + puVar11[0x14] = uVar25; + uVar7 = uVar20 + uVar6 + + ((uVar25 * 0x8000 | uVar25 >> 0x11) ^ (uVar25 * 0x2000 | uVar25 >> 0x13) ^ uVar25 >> 10) + + ((uVar1 >> 7 | uVar1 << 0x19) ^ (uVar1 << 0xe | uVar1 >> 0x12) ^ uVar1 >> 3); + iVar13 = ((A[5] >> 6 | A[5] * 0x4000000) ^ (A[5] >> 0xb | A[5] * 0x200000) ^ + (A[5] * 0x80 | A[5] >> 0x19)) + + ((uVar10 ^ A[6]) & A[5] ^ uVar10) + uVar12 + puVar2[0x16] + uVar7; + A[0] = ((A[1] >> 2 | A[1] * 0x40000000) ^ (A[1] >> 0xd | A[1] * 0x80000) ^ + (A[1] * 0x400 | A[1] >> 0x16)) + ((A[2] | A[1]) & uVar17 | A[2] & A[1]) + iVar13; + A[4] = uVar8 + iVar13; + uVar5 = puVar11[8]; + puVar11[0x15] = uVar16; + puVar11[0x10] = uVar23; + uVar27 = puVar2[0x17]; + uVar24 = uVar23 + uVar1 + + ((uVar16 * 0x8000 | uVar16 >> 0x11) ^ (uVar16 * 0x2000 | uVar16 >> 0x13) ^ uVar16 >> 10 + ) + ((uVar5 >> 7 | uVar5 << 0x19) ^ (uVar5 << 0xe | uVar5 >> 0x12) ^ uVar5 >> 3); + puVar11[0x17] = uVar24; + iVar13 = ((A[4] >> 6 | A[4] * 0x4000000) ^ (A[4] >> 0xb | A[4] * 0x200000) ^ + (A[4] * 0x80 | A[4] >> 0x19)) + + uVar10 + uVar27 + uVar24 + ((A[6] ^ A[5]) & A[4] ^ A[6]); + puVar11[0x16] = uVar7; + puVar11 = puVar11 + 8; + A[3] = uVar17 + iVar13; + local_150 = ((A[0] >> 2 | A[0] * 0x40000000) ^ (A[0] >> 0xd | A[0] * 0x80000) ^ + (A[0] * 0x400 | A[0] >> 0x16)) + ((A[1] | A[0]) & A[2] | A[1] & A[0]) + iVar13; + puVar2 = puVar2 + 8; + } while (W + 0x2f != puVar11); + puVar9 = ctx->state; + do { + iVar13 = *puVar18; + puVar11 = puVar9 + 1; + puVar18 = (uint32_t *)((int *)puVar18 + 1); + *puVar9 = *puVar9 + iVar13; + puVar9 = puVar11; + } while ((uint32_t *)ctx->buffer != puVar11); + return; +} + + + +void utils_sha256_update(iot_sha256_context *ctx,uchar *input,uint32_t ilen) + +{ + size_t __n; + uint uVar1; + uint uVar2; + uint __n_00; + + uVar2 = ctx->total[0] & 0x3f; + uVar1 = ctx->total[0] + ilen; + ctx->total[0] = uVar1; + if (uVar1 < ilen) { + ctx->total[1] = ctx->total[1] + 1; + } + uVar1 = ilen; + if ((uVar2 != 0) && (__n_00 = 0x40 - uVar2, __n_00 <= ilen)) { + memcpy(ctx->buffer + uVar2,input,__n_00); + ilen = (ilen - 0x40) + uVar2; + utils_sha256_process(ctx,ctx->buffer); + input = input + __n_00; + uVar2 = 0; + uVar1 = ilen; + } + while (0x3f < ilen) { + utils_sha256_process(ctx,input + (uVar1 - ilen)); + ilen = ilen - 0x40; + } + __n = (uVar1 >> 6) * -0x40 + uVar1; + if (__n == 0) { + return; + } + memcpy(ctx->buffer + uVar2,input + (uVar1 & 0xffffffc0),__n); + return; +} + + + +void utils_sha256_update(iot_sha256_context *ctx,uchar *input,uint32_t ilen) + +{ + if (ilen != 0) { + utils_sha256_update(ctx,input,ilen); + return; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void utils_sha256_finish(iot_sha256_context *ctx,uint8_t *output) + +{ + uint uVar1; + uint uVar2; + int iVar3; + uchar uStack24; + undefined uStack23; + ushort uStack22; + uchar msglen [8]; + + uVar1 = ctx->total[0]; + uVar2 = ctx->total[1] << 3; + uStack24 = (uchar)(uVar2 >> 0x18); + uStack23 = (undefined)(uVar2 >> 0x10); + uStack22 = (ushort)(uVar2 >> 8) & 0xff | (ushort)((uVar2 | uVar1 >> 0x1d) << 8); + msglen[0] = (uchar)((uVar1 << 3) >> 0x18); + msglen[1] = (uchar)((uVar1 << 3) >> 0x10); + msglen._2_2_ = (ushort)((uVar1 << 0x13) >> 0x18) | (ushort)(uVar1 << 0xb); + if ((uVar1 & 0x3f) < 0x38) { + iVar3 = 0x38; + } + else { + iVar3 = 0x78; + } + utils_sha256_update(ctx,sha256_padding,iVar3 - (uVar1 & 0x3f)); + utils_sha256_update(ctx,&uStack24,8); + *output = *(uint8_t *)((int)ctx->state + 3); + output[1] = (uint8_t)*(undefined2 *)((int)ctx->state + 2); + output[2] = (uint8_t)(ctx->state[0] >> 8); + output[3] = (uint8_t)ctx->state[0]; + output[4] = *(uint8_t *)((int)ctx->state + 7); + output[5] = (uint8_t)*(undefined2 *)((int)ctx->state + 6); + output[6] = (uint8_t)(ctx->state[1] >> 8); + output[7] = (uint8_t)ctx->state[1]; + output[8] = *(uint8_t *)((int)ctx->state + 0xb); + output[9] = (uint8_t)*(undefined2 *)((int)ctx->state + 10); + output[10] = (uint8_t)(ctx->state[2] >> 8); + output[0xb] = (uint8_t)ctx->state[2]; + output[0xc] = *(uint8_t *)((int)ctx->state + 0xf); + output[0xd] = (uint8_t)*(undefined2 *)((int)ctx->state + 0xe); + output[0xe] = (uint8_t)(ctx->state[3] >> 8); + output[0xf] = (uint8_t)ctx->state[3]; + output[0x10] = *(uint8_t *)((int)ctx->state + 0x13); + output[0x11] = (uint8_t)*(undefined2 *)((int)ctx->state + 0x12); + output[0x12] = (uint8_t)(ctx->state[4] >> 8); + output[0x13] = (uint8_t)ctx->state[4]; + output[0x14] = *(uint8_t *)((int)ctx->state + 0x17); + output[0x15] = (uint8_t)*(undefined2 *)((int)ctx->state + 0x16); + output[0x16] = (uint8_t)(ctx->state[5] >> 8); + output[0x17] = (uint8_t)ctx->state[5]; + output[0x18] = *(uint8_t *)((int)ctx->state + 0x1b); + output[0x19] = (uint8_t)*(undefined2 *)((int)ctx->state + 0x1a); + output[0x1a] = (uint8_t)(ctx->state[6] >> 8); + output[0x1b] = (uint8_t)ctx->state[6]; + if (ctx->is224 == 0) { + output[0x1c] = *(uint8_t *)((int)ctx->state + 0x1f); + output[0x1d] = (uint8_t)*(undefined2 *)((int)ctx->state + 0x1e); + output[0x1e] = (uint8_t)(ctx->state[7] >> 8); + output[0x1f] = (uint8_t)ctx->state[7]; + } + return; +} + + + +void bl_printk(char *format,...) + +{ + undefined4 in_a1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list args; + undefined4 uStack28; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + if (sys_log_all_enable != false) { + uStack28 = in_a1; + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + vprint(format,&uStack28); + } + return; +} + + + +int log_buf_out(char *file,int line,void *inbuf,int len,LOG_BUF_OUT_DATA_TYPE_T type) + +{ + bool bVar1; + int iVar2; + int iVar3; + TickType_t TVar4; + char *format; + uint uVar5; + undefined3 in_register_00002039; + int iVar6; + int iVar7; + int iVar8; + int iVar9; + void *pvVar10; + + iVar6 = CONCAT31(in_register_00002039,type); + if (len < 1) { + return -1; + } + iVar9 = len / 0x32; + if (len % 0x32 == 0) { + pvVar10 = (void *)(iVar9 * 0x32 + (int)inbuf); + while (pvVar10 != inbuf) { + iVar7 = 0; + iVar9 = 0; + do { + uVar5 = (uint)*(byte *)((int)inbuf + iVar9); + if (iVar6 == 1) { + uVar5 = SEXT14((char)*(byte *)((int)inbuf + iVar9)); + format = "%3d "; + } + else { + format = "%3u "; + if (iVar6 != 2) { + format = "%02x "; + } + } + iVar3 = sprintf(log_buf + iVar7,format,uVar5); + iVar9 = iVar9 + 1; + iVar7 = iVar7 + iVar3; + } while (iVar9 != 0x32); + if (TrapNetCounter == 0) { + TVar4 = xTaskGetTickCount(); + } + else { + TVar4 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %.*s\r\n",TVar4,&UNK_230c444c,file,line,iVar7,log_buf); + inbuf = (void *)((int)inbuf + 0x32); + } + } + else { + iVar7 = 0; + do { + iVar3 = 0; + iVar8 = 0; + if (iVar9 == iVar7) { + do { + uVar5 = (uint)*(byte *)((int)inbuf + iVar8); + if (iVar6 == 1) { + uVar5 = SEXT14((char)*(byte *)((int)inbuf + iVar8)); + format = "%3d "; + } + else { + format = "%3u "; + if (iVar6 != 2) { + format = "%02x "; + } + } + iVar2 = sprintf(log_buf + iVar3,format,uVar5); + iVar8 = iVar8 + 1; + iVar3 = iVar3 + iVar2; + } while (len % 0x32 != iVar8); + } + else { + do { + uVar5 = (uint)*(byte *)((int)inbuf + iVar8); + if (iVar6 == 1) { + uVar5 = SEXT14((char)*(byte *)((int)inbuf + iVar8)); + format = "%3d "; + } + else { + format = "%3u "; + if (iVar6 != 2) { + format = "%02x "; + } + } + iVar2 = sprintf(log_buf + iVar3,format,uVar5); + iVar8 = iVar8 + 1; + iVar3 = iVar3 + iVar2; + } while (iVar8 != 0x32); + } + if (TrapNetCounter == 0) { + TVar4 = xTaskGetTickCount(); + } + else { + TVar4 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %.*s\r\n",TVar4,&UNK_230c444c,file,line,iVar3,log_buf); + inbuf = (void *)((int)inbuf + 0x32); + bVar1 = iVar7 < iVar9; + iVar7 = iVar7 + 1; + } while (bVar1); + } + return 0; +} + + + +int utils_dns_domain_get(uint8_t *records,uint8_t *buf,int *len) + +{ + int iVar1; + int iVar2; + uint uVar3; + int iVar4; + int iVar5; + int iVar6; + + iVar6 = *len; + uVar3 = (uint)*records; + iVar2 = 1; + iVar5 = 0; + while ((iVar4 = iVar5, iVar1 = iVar2, uVar3 != 0 && (0 < iVar6))) { + uVar3 = uVar3 - 1; + buf[iVar4] = records[iVar1]; + iVar2 = iVar1 + 1; + iVar5 = iVar4 + 1; + iVar6 = iVar6 + -1; + if ((uVar3 == 0) && (iVar6 != 0)) { + buf[iVar5] = '.'; + uVar3 = (uint)records[iVar2]; + iVar2 = iVar1 + 2; + iVar5 = iVar4 + 2; + } + } + *len = iVar4; + return 0; +} + + + +void utils_list_init(utils_list *list) + +{ + list->first = (utils_list_hdr *)0x0; + list->last = (utils_list_hdr *)0x0; + return; +} + + + +void utils_list_push_back(utils_list *list,utils_list_hdr *list_hdr) + +{ + if (list->first == (utils_list_hdr *)0x0) { + list->first = list_hdr; + } + else { + list->last->next = list_hdr; + } + list->last = list_hdr; + list_hdr->next = (utils_list_hdr *)0x0; + return; +} + + + +utils_list_hdr * utils_list_pop_front(utils_list *list) + +{ + utils_list_hdr *puVar1; + + puVar1 = list->first; + if (puVar1 != (utils_list_hdr *)0x0) { + list->first = puVar1->next; + } + return puVar1; +} + + + +void utils_hexdump(void *mem,uint len) + +{ + uint uVar1; + int iVar2; + uint c; + int iVar3; + uint uVar4; + uint uVar5; + + iVar2 = 0; + if ((len & 0xf) != 0) { + iVar2 = 0x10 - (len & 0xf); + } + uVar4 = 0; + while (uVar1 = uVar4, iVar2 + len != uVar1) { + if ((uVar1 & 0xf) == 0) { + printf("0x%06x: ",uVar1); + } + if (uVar1 < len) { + printf("%02x ",(uint)*(byte *)((int)mem + uVar1)); + } + else { + printf(" "); + } + uVar4 = uVar1 + 1; + if ((uVar1 & 0xf) == 0xf) { + uVar5 = uVar1 - 0xf; + iVar3 = 0x11; + if (uVar4 < uVar5) { + iVar3 = 1; + } + while (uVar5 != (uVar1 - 0x10) + iVar3) { + c = 0x20; + if ((uVar5 < len) && (c = (uint)*(byte *)((int)mem + uVar5), (_ctype_[c + 1] & 0x97) == 0)) + { + c = 0x2e; + } + bl_putchar(c); + uVar5 = uVar5 + 1; + } + puts("\r\n"); + } + } + return; +} + + + +undefined4 utils_time_date_from_epoch(uint param_1,undefined *param_2) + +{ + byte bVar1; + byte bVar2; + uint uVar3; + uint uVar4; + uint uVar5; + undefined4 uStack20; + undefined2 uStack16; + undefined uStack14; + char cStack13; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack12 = 0x1e1f1c1f; + uStack8 = 0x1f1f1e1f; + uStack4 = 0x1f1e1f1e; + uStack20 = 0x60504; + uStack16 = 0x201; + uStack14 = 3; + *(undefined2 *)(param_2 + 6) = 0; + param_2[2] = (char)(param_1 % 0x3c); + param_2[1] = (char)((param_1 / 0x3c) % 0x3c); + *param_2 = (char)((param_1 / 0xe10) % 0x18); + uVar5 = param_1 / 0x15180; + *(uint *)(param_2 + 0xc) = uVar5; + param_2[3] = *(undefined *)((int)&uStack20 + uVar5 % 7); + uVar4 = 0x7b4; + uVar3 = param_1 / 0x1e13380 + 0x7b2; + *(uint *)(param_2 + 8) = uVar3; + while (uVar4 < uVar3) { + if (((int)uVar4 % 100 != 0) || ((int)uVar4 % 400 == 0)) { + param_2[6] = param_2[6] + '\x01'; + } + uVar4 = uVar4 + 4; + } + uVar3 = (uVar5 - (byte)param_2[6]) / 0x16d + 0x7b2; + *(uint *)(param_2 + 8) = uVar3; + uVar4 = (uVar5 - (byte)param_2[6]) % 0x16d + 1; + *(uint *)(param_2 + 0x10) = uVar4; + if ((((uVar3 & 3) == 0) && (uVar3 % 100 != 0)) || (uVar3 % 400 == 0)) { + uStack12 = 0x1e1f1d1f; + param_2[7] = 1; + } + param_2[5] = 0; + uVar3 = 0; + while( true ) { + bVar1 = param_2[5]; + if ((0xb < bVar1) || (uVar4 <= uVar3)) break; + bVar2 = *(byte *)((int)&uStack12 + (uint)bVar1); + param_2[5] = bVar1 + 1; + uVar3 = uVar3 + bVar2 & 0xffff; + } + param_2[4] = (char)uVar4 - ((char)uVar3 - (&cStack13)[(uint)bVar1]); + return 0; +} + + + +int utils_getopt_init(getopt_env_t *env,int opterr) + +{ + if (env != (getopt_env_t *)0x0) { + env->optarg = (char *)0x0; + env->optind = 1; + env->opterr = opterr; + env->optopt = 0; + env->__optpos = 0; + return 0; + } + return -1; +} + + + +int utils_getopt(getopt_env_t *env,int argc,char **argv,char *optstring) + +{ + byte bVar1; + byte bVar2; + int iVar3; + uint uVar4; + char **ppcVar5; + int iVar6; + byte *pbVar7; + char *pcVar8; + byte *pbVar9; + + if (env == (getopt_env_t *)0x0) { + return -1; + } + iVar6 = env->optind; + if (argc <= iVar6) { + return -1; + } + ppcVar5 = argv + iVar6; + pcVar8 = *ppcVar5; + if (pcVar8 == (char *)0x0) { + return -1; + } + if (*pcVar8 != '-') { + if (*optstring == '-') { + env->optind = iVar6 + 1; + env->optarg = *ppcVar5; + return 1; + } + return -1; + } + if (pcVar8[1] == '\0') { + return -1; + } + if ((pcVar8[1] == '-') && (pcVar8[2] == '\0')) { + env->optind = iVar6 + 1; + return -1; + } + if (env->__optpos == 0) { + env->__optpos = 1; + } + pbVar9 = (byte *)(*ppcVar5 + env->__optpos); + bVar1 = *pbVar9; + uVar4 = (uint)bVar1; + iVar3 = (uint)(bVar1 != 0) + env->__optpos; + env->__optpos = iVar3; + if ((*ppcVar5)[iVar3] == '\0') { + env->optind = iVar6 + 1; + env->__optpos = 0; + } + if ((*optstring - 0x2bU & 0xfd) == 0) { + optstring = optstring + 1; + } + iVar6 = 0; + do { + iVar3 = iVar6 + 1; + pbVar7 = (byte *)(optstring + iVar6); + bVar2 = *pbVar7; + if (bVar2 == 0) { + if (bVar1 == 0) goto LAB_2307a7a4; + goto LAB_2307a786; + } + iVar6 = iVar3; + } while (uVar4 != (uint)bVar2); + if (bVar1 == 0x3a) { +LAB_2307a786: + env->optopt = uVar4; + if (*optstring == ':') { + return 0x3f; + } + if (env->opterr == 0) { + return 0x3f; + } + bVar1 = *pbVar9; + pcVar8 = *argv; + iVar6 = 0x484; + } + else { +LAB_2307a7a4: + if (optstring[iVar3] != ':') { + return uVar4; + } + env->optarg = (char *)0x0; + iVar6 = env->__optpos; + if ((pbVar7[2] != 0x3a) || (iVar6 != 0)) { + iVar3 = env->optind; + env->optind = iVar3 + 1; + pcVar8 = argv[iVar3]; + env->__optpos = 0; + env->optarg = pcVar8 + iVar6; + } + if (env->optind <= argc) { + return uVar4; + } + env->optopt = uVar4; + if (*optstring == ':') { + return 0x3a; + } + if (env->opterr == 0) { + return 0x3f; + } + bVar1 = *pbVar9; + pcVar8 = *argv; + iVar6 = 0x4a4; + } + printf("[%10u][%s: %s:%4d] [EF] [PART] [XIP] error when get romfs partition %d\r\n" + iVar6 + 0x44 + ,pcVar8,(uint)bVar1); + return 0x3f; +} + + + +int params_filter(uint32_t *r) + +{ + int *in_a1; + int iVar1; + uint uVar2; + int iVar3; + + iVar1 = 10; + if ((*(char *)r == '0') && ((*(byte *)((int)r + 1) & 0xdf) == 0x58)) { + r = (uint32_t *)((int)r + 2); + iVar1 = 0x10; + } + iVar3 = 0; + do { + uVar2 = (uint)*(byte *)r; + if (*(byte *)r == 0) { + *in_a1 = iVar3; + return 0; + } + iVar3 = iVar3 * iVar1; + if ((uVar2 - 0x30 & 0xff) < 10) { + iVar3 = iVar3 + -0x30; +LAB_2307a866: + iVar3 = iVar3 + uVar2; + } + else { + if (iVar1 == 10) { + return -1; + } + if (iVar1 == 0x10) { + if ((uVar2 - 0x61 & 0xff) < 6) { + iVar3 = iVar3 + -0x57; + } + else { + if (5 < (uVar2 - 0x41 & 0xff)) goto LAB_2307a868; + uVar2 = uVar2 - 0x37; + } + goto LAB_2307a866; + } + } +LAB_2307a868: + r = (uint32_t *)((int)r + 1); + } while( true ); +} + + + +void get_bytearray_from_string(char **params,uint8_t *result,int array_size) + +{ + int iVar1; + long lVar2; + char acStack36 [2]; + undefined uStack34; + char rand [3]; + + iVar1 = 0; + while (iVar1 < array_size) { + strncpy(acStack36,*params,2); + uStack34 = 0; + lVar2 = strtol(acStack36,(char **)0x0,0x10); + result[iVar1] = (uint8_t)lVar2; + iVar1 = iVar1 + 1; + *params = *params + 2; + } + return; +} + + + +void get_uint8_from_string(char **params,uint8_t *result) + +{ + uint32_t p; + + params_filter((uint32_t *)*params); + *result = '\0'; + return; +} + + + +void get_uint16_from_string(char **params,uint16_t *result) + +{ + uint32_t p; + + params_filter((uint32_t *)*params); + *result = 0; + return; +} + + + +// WARNING: Variable defined which should be unmapped: pTemp + +void Bl_F_fast(uchar *digest,uchar *digest1,char *password,uchar *ssid,int ssidlength,int count, + uchar *output) + +{ + int iVar1; + size_t key_len; + byte *pbVar2; + uchar *puVar3; + byte *pbVar4; + int iVar5; + int iStack40; + int tmpLen; + uchar *pTemp; + + key_len = strlen(password); + iStack40 = ssidlength + 4; + tmpLen = (int)digest; + memcpy(digest,ssid,ssidlength); + puVar3 = digest + ssidlength; + *puVar3 = '\0'; + puVar3[3] = (uchar)count; + puVar3[1] = '\0'; + puVar3[2] = '\0'; + bl_sha_mutex_take(); + utils_hmac_sha1_fast((uchar **)&tmpLen,&iStack40,1,(uchar *)password,key_len,digest1,0x14); + memcpy(output,digest1,0x14); + iVar1 = 0xfff; + tmpLen = (int)digest1; + do { + iStack40 = 0x14; + utils_hmac_sha1_fast((uchar **)&tmpLen,&iStack40,1,(uchar *)password,key_len,digest,0x14); + memcpy(digest1,digest,0x14); + iVar5 = 0; + do { + pbVar2 = output + iVar5; + pbVar4 = digest + iVar5; + iVar5 = iVar5 + 1; + *pbVar2 = *pbVar4 ^ *pbVar2; + } while (iVar5 != 0x14); + iVar1 = iVar1 + -1; + } while (iVar1 != 0); + bl_sha_mutex_give(); + return; +} + + + +int utils_wifi_psk_cal_fast_bin(char *password,uchar *ssid,int ssidlength,uchar *output) + +{ + size_t sVar1; + int iVar2; + uchar auStack88 [4]; + uchar digest1 [20]; + uchar digest [36]; + + sVar1 = strlen(password); + if (sVar1 < 0x40) { + iVar2 = -1; + if (ssidlength < 0x21) { + Bl_F_fast(digest1 + 0x10,auStack88,password,ssid,ssidlength,2,output); + memcpy(output + 0x14,output,0xc); + Bl_F_fast(digest1 + 0x10,auStack88,password,ssid,ssidlength,1,output); + iVar2 = 0; + } + } + else { + iVar2 = -1; + } + return iVar2; +} + + + +int utils_tlv_bl_pack_auto(uint32_t *buf,int buf_sz,uint16_t type,void *arg1) + +{ + undefined2 in_register_00002032; + uint32_t uVar1; + int iVar2; + + if (CONCAT22(in_register_00002032,type) == 1) { + uVar1 = (uint32_t)*(byte *)arg1; + } + else { + if (CONCAT22(in_register_00002032,type) != 7) { + return -2; + } + uVar1 = *(uint32_t *)arg1; + } + iVar2 = -1; + if (3 < buf_sz) { + *buf = uVar1; + iVar2 = 4; + } + return iVar2; +} + + + +int utils_tlv_bl_unpack_auto(uint32_t *buf,int buf_sz,uint16_t type,void *arg1) + +{ + int iVar1; + undefined2 in_register_00002032; + bool bVar2; + uint32_t uVar3; + + if (CONCAT22(in_register_00002032,type) == 1) { + if (buf_sz < 4) { + bVar2 = true; + iVar1 = -1; + } + else { + iVar1 = 4; + bVar2 = *buf != 0; + } + *(bool *)arg1 = bVar2; + return iVar1; + } + if (CONCAT22(in_register_00002032,type) != 7) { + return -2; + } + if (buf_sz < 4) { + uVar3 = 0; + iVar1 = -1; + } + else { + uVar3 = *buf; + iVar1 = 4; + } + *(uint32_t *)arg1 = uVar3; + return iVar1; +} + + + +void utils_hmac_sha1_fast + (uchar **ppText,int *pTextLen,int textNum,uchar *key,int key_len,uchar *output, + int outputLen) + +{ + uint *puVar1; + uint32_t *puVar2; + uint *__src; + uchar **ppuVar3; + int iVar4; + uint *hash; + uint local_120; + uint64_t pBuf [11]; + undefined auStack196 [4]; + bl_sha_ctx_t sha_ctx; + + if (0x40 < key_len) { + bl_sha_init((bl_sha_ctx_t *)auStack196,BL_SHA1); + bl_sha_update((bl_sha_ctx_t *)auStack196,key,key_len); + bl_sha_finish((bl_sha_ctx_t *)auStack196,key); + key_len = 0x14; + } + memset(&local_120,0,0x40); + memcpy(&local_120,key,key_len); + hash = (uint *)((int)pBuf + 0x3c); + puVar1 = &local_120; + do { + __src = puVar1 + 2; + *puVar1 = *puVar1 ^ 0x36363636; + puVar1[1] = puVar1[1] ^ 0x36363636; + puVar1 = __src; + } while (__src != hash); + bl_sha_init((bl_sha_ctx_t *)auStack196,BL_SHA1); + bl_sha_update((bl_sha_ctx_t *)auStack196,(uint8_t *)&local_120,0x40); + iVar4 = 0; + while (iVar4 < textNum) { + puVar2 = (uint32_t *)(pTextLen + iVar4); + ppuVar3 = ppText + iVar4; + iVar4 = iVar4 + 1; + bl_sha_update((bl_sha_ctx_t *)auStack196,*ppuVar3,*puVar2); + } + bl_sha_finish((bl_sha_ctx_t *)auStack196,(uint8_t *)hash); + memset(&local_120,0,0x40); + memcpy(&local_120,key,key_len); + puVar1 = &local_120; + do { + __src = puVar1 + 2; + *puVar1 = *puVar1 ^ 0x5c5c5c5c; + puVar1[1] = puVar1[1] ^ 0x5c5c5c5c; + puVar1 = __src; + } while (__src != hash); + bl_sha_init((bl_sha_ctx_t *)auStack196,BL_SHA1); + bl_sha_update((bl_sha_ctx_t *)auStack196,(uint8_t *)&local_120,0x40); + bl_sha_update((bl_sha_ctx_t *)auStack196,(uint8_t *)__src,0x14); + bl_sha_finish((bl_sha_ctx_t *)auStack196,(uint8_t *)__src); + memcpy(output,__src,outputLen); + return; +} + + + +int vfs_init(void) + +{ + int iVar1; + + iVar1 = 0; + if (g_vfs_init != '\x01') { + g_vfs_mutex = (SemaphoreHandle_t)xQueueCreateMutexStatic('\x01',(StaticQueue_t *)&xMutexBuffer); + iVar1 = -1; + if (g_vfs_mutex != (SemaphoreHandle_t)0x0) { + inode_init(); + iVar1 = 0; + g_vfs_init = '\x01'; + } + } + return iVar1; +} + + + +int aos_open(char *path,int flags) + +{ + size_t sVar1; + BaseType_t BVar2; + inode_t *node; + file_t *file; + int iVar3; + code *pcVar4; + + if (path == (char *)0x0) { + iVar3 = -0x16; + } + else { + sVar1 = strlen(path); + if (0x400 < sVar1) { + return -0x1a; + } + BVar2 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar2 != 1) { + return -1; + } + node = inode_open(path); + if (node == (inode_t *)0x0) { + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + return -2; + } + node->i_flags = flags; + file = new_file(node); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + if (file == (file_t *)0x0) { + return -0x17; + } + pcVar4 = *(code **)node->ops; + if (node->type == '\x03') { + if (pcVar4 == (code *)0x0) goto LAB_2307ad32; + iVar3 = (*pcVar4)(file,path,flags); + } + else { + if (pcVar4 == (code *)0x0) goto LAB_2307ad32; + iVar3 = (*pcVar4)(node,file); + } + if (iVar3 == 0) { +LAB_2307ad32: + iVar3 = get_fd(file); + return iVar3; + } + del_file(file); + } + return iVar3; +} + + + +int aos_close(int fd) + +{ + int iVar1; + file_t *file; + BaseType_t BVar2; + code *pcVar3; + + file = get_file(fd); + iVar1 = -2; + if (file != (file_t *)0x0) { + iVar1 = 0; + pcVar3 = *(code **)(file->node->ops + 4); + if (pcVar3 != (code *)0x0) { + iVar1 = (*pcVar3)(); + } + BVar2 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar2 == 1) { + del_file(file); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + } + else { + iVar1 = -1; + } + } + return iVar1; +} + + + +ssize_t aos_read(int fd,void *buf,size_t nbytes) + +{ + code *UNRECOVERED_JUMPTABLE; + file_t *pfVar1; + ssize_t sVar2; + + pfVar1 = get_file(fd); + if (pfVar1 == (file_t *)0x0) { + sVar2 = -2; + } + else { + UNRECOVERED_JUMPTABLE = *(code **)(pfVar1->node->ops + 8); + if (UNRECOVERED_JUMPTABLE != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x2307adcc. Too many branches + // WARNING: Treating indirect jump as call + sVar2 = (*UNRECOVERED_JUMPTABLE)(buf,nbytes); + return sVar2; + } + sVar2 = -1; + } + return sVar2; +} + + + +ssize_t aos_write(int fd,void *buf,size_t nbytes) + +{ + code *UNRECOVERED_JUMPTABLE; + file_t *pfVar1; + ssize_t sVar2; + + pfVar1 = get_file(fd); + if (pfVar1 == (file_t *)0x0) { + sVar2 = -2; + } + else { + UNRECOVERED_JUMPTABLE = *(code **)(pfVar1->node->ops + 0xc); + if (UNRECOVERED_JUMPTABLE != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x2307adfa. Too many branches + // WARNING: Treating indirect jump as call + sVar2 = (*UNRECOVERED_JUMPTABLE)(buf,nbytes); + return sVar2; + } + sVar2 = -1; + } + return sVar2; +} + + + +int aos_ioctl(int fd,int cmd,ulong arg) + +{ + code *UNRECOVERED_JUMPTABLE; + file_t *pfVar1; + int iVar2; + + if (fd < 0) { + return -0x16; + } + pfVar1 = get_file(fd); + if (pfVar1 == (file_t *)0x0) { + iVar2 = -2; + } + else { + iVar2 = pfVar1->node->ops; + if (pfVar1->node->type == '\x03') { + UNRECOVERED_JUMPTABLE = *(code **)(iVar2 + 0x44); + } + else { + UNRECOVERED_JUMPTABLE = *(code **)(iVar2 + 0x10); + } + if (UNRECOVERED_JUMPTABLE != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x2307ae36. Too many branches + // WARNING: Treating indirect jump as call + iVar2 = (*UNRECOVERED_JUMPTABLE)(cmd,arg); + return iVar2; + } + iVar2 = -0x47; + } + return iVar2; +} + + + +int aos_stat(char *path,stat *st) + +{ + int iVar1; + BaseType_t BVar2; + inode_t *node; + file_t *file; + code *pcVar3; + + if (path == (char *)0x0) { + return -0x16; + } + BVar2 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar2 == 1) { + node = inode_open(path); + if (node == (inode_t *)0x0) { + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + return -0x13; + } + file = new_file(node); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + if (file == (file_t *)0x0) { + return -2; + } + iVar1 = -0x47; + if ((node->type == '\x03') && (pcVar3 = *(code **)(node->ops + 0x18), pcVar3 != (code *)0x0)) { + iVar1 = (*pcVar3)(file,path,st); + } + BVar2 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar2 == 1) { + del_file(file); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + return iVar1; + } + } + return -1; +} + + + +aos_dir_t * aos_opendir(char *path) + +{ + BaseType_t BVar1; + inode_t *node; + file_t *file; + aos_dir_t *paVar2; + int iVar3; + code *pcVar4; + + if ((path != (char *)0x0) && + (BVar1 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff), BVar1 == 1)) { + node = inode_open(path); + if (node == (inode_t *)0x0) { + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + return (aos_dir_t *)0x0; + } + file = new_file(node); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + if (file != (file_t *)0x0) { + if (((node->type == '\x03') && (pcVar4 = *(code **)(node->ops + 0x24), pcVar4 != (code *)0x0)) + && (paVar2 = (aos_dir_t *)(*pcVar4)(file,path), paVar2 != (aos_dir_t *)0x0)) { + iVar3 = get_fd(file); + paVar2->dd_vfs_fd = iVar3; + return paVar2; + } + BVar1 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar1 == 1) { + del_file(file); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + } + } + } + return (aos_dir_t *)0x0; +} + + + +int aos_closedir(aos_dir_t *dir) + +{ + int iVar1; + file_t *file; + BaseType_t BVar2; + code *pcVar3; + + iVar1 = -0x16; + if (dir != (aos_dir_t *)0x0) { + iVar1 = -2; + file = get_file(dir->dd_vfs_fd); + if (file != (file_t *)0x0) { + iVar1 = -0x47; + if ((file->node->type == '\x03') && + (pcVar3 = *(code **)(file->node->ops + 0x2c), pcVar3 != (code *)0x0)) { + iVar1 = (*pcVar3)(dir); + } + BVar2 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar2 == 1) { + del_file(file); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + } + else { + iVar1 = -1; + } + } + } + return iVar1; +} + + + +aos_dirent_t * aos_readdir(aos_dir_t *dir) + +{ + code *UNRECOVERED_JUMPTABLE; + file_t *pfVar1; + aos_dirent_t *paVar2; + + if (dir == (aos_dir_t *)0x0) { + return (aos_dirent_t *)0x0; + } + pfVar1 = get_file(dir->dd_vfs_fd); + if (pfVar1 != (file_t *)0x0) { + if (pfVar1->node->type == '\x03') { + UNRECOVERED_JUMPTABLE = *(code **)(pfVar1->node->ops + 0x28); + if (UNRECOVERED_JUMPTABLE != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x2307b056. Too many branches + // WARNING: Treating indirect jump as call + paVar2 = (aos_dirent_t *)(*UNRECOVERED_JUMPTABLE)(dir); + return paVar2; + } + } + } + return (aos_dirent_t *)0x0; +} + + + +file_t * new_file(inode_t *node) + +{ + file_t *pfVar1; + int iVar2; + + pfVar1 = files; + iVar2 = 0; + do { + if (pfVar1->node == (inode_t *)0x0) { + files[iVar2].node = node; + files[iVar2].f_arg = (void *)0x0; + files[iVar2].offset = 0; + inode_ref(node); + return files + iVar2; + } + iVar2 = iVar2 + 1; + pfVar1 = pfVar1 + 1; + } while (iVar2 != 0x3c); + return (file_t *)0x0; +} + + + +void del_file(file_t *file) + +{ + inode_unref(file->node); + file->node = (inode_t *)0x0; + return; +} + + + +int get_fd(file_t *file) + +{ + return ((int)&file[-0x5802468].f_arg >> 2) * -0x55555555 + 2; +} + + + +file_t * get_file(int fd) + +{ + inode_t *piVar1; + + if (fd - 2U < 0x3c) { + piVar1 = files[fd - 2U].node; + if (piVar1 != (inode_t *)0x0) { + return files + (fd - 2U); + } + } + else { + piVar1 = (inode_t *)0x0; + } + return (file_t *)piVar1; +} + + + +int inode_init(void) + +{ + memset(g_vfs_dev_nodes,0,600); + return 0; +} + + + +int inode_alloc(void) + +{ + int iVar1; + inode_t *piVar2; + + piVar2 = g_vfs_dev_nodes; + iVar1 = 0; + do { + if (piVar2->type == '\0') { + return iVar1; + } + iVar1 = iVar1 + 1; + piVar2 = piVar2 + 1; + } while (iVar1 != 0x1e); + return -0xc; +} + + + +inode_t * inode_open(char *path) + +{ + inode_t *piVar1; + int iVar2; + size_t __n; + char *__s; + + piVar1 = g_vfs_dev_nodes; + do { + __s = (char *)((at_sever_t *)piVar1)->at_serial_fd; + if (__s != (char *)0x0) { + if (*(char *)&((at_sever_t *)piVar1)->xQueue == '\x03') { + __n = strlen(__s); + iVar2 = strncmp(__s,path,__n); + if ((iVar2 == 0) && + (__n = strlen((char *)((at_sever_t *)piVar1)->at_serial_fd), path[__n] == '/')) { + return (inode_t *)(at_sever_t *)piVar1; + } + } + iVar2 = strcmp((char *)((at_sever_t *)piVar1)->at_serial_fd,path); + if (iVar2 == 0) { + return (inode_t *)(at_sever_t *)piVar1; + } + } + piVar1 = (inode_t *)((at_sever_t *)piVar1)->queue_buf; + if ((at_sever_t *)piVar1 == &g_at_server) { + return (inode_t *)0x0; + } + } while( true ); +} + + + +int inode_forearch_name(anon_subr_int_void_ptr_inode_t_ptr *cb,void *arg) + +{ + inode_t *piVar1; + int iVar2; + int iVar3; + + piVar1 = g_vfs_dev_nodes; + iVar2 = 0; + do { + if (((at_sever_t *)piVar1)->at_serial_fd != 0) { + iVar2 = iVar2 + 1; + iVar3 = (*cb)(arg,piVar1); + if (iVar3 != 0) { + return iVar2; + } + } + piVar1 = (inode_t *)((at_sever_t *)piVar1)->queue_buf; + } while ((at_sever_t *)piVar1 != &g_at_server); + return iVar2; +} + + + +void inode_ref(inode_t *node) + +{ + node->refs = node->refs + '\x01'; + return; +} + + + +void inode_unref(inode_t *node) + +{ + if (node->refs != '\0') { + node->refs = node->refs + -1; + } + return; +} + + + +int inode_reserve(char *path,inode_t **inode) + +{ + inode_t *piVar1; + int iVar2; + size_t __n; + char *__dest; + + if (((path != (char *)0x0) && (inode != (inode_t **)0x0)) && + (*inode = (inode_t *)0x0, *path == '/')) { + iVar2 = inode_alloc(); + if (-1 < iVar2) { + piVar1 = (inode_t *)0x0; + if (iVar2 < 0x1e) { + piVar1 = g_vfs_dev_nodes + iVar2; + } + __n = strlen(path); + __dest = (char *)pvPortMalloc(__n + 1); + iVar2 = -0xc; + if (__dest != (char *)0x0) { + memcpy(__dest,path,__n); + piVar1->i_name = __dest; + __dest[__n] = '\0'; + *inode = piVar1; + iVar2 = 0; + } + } + return iVar2; + } + return -0x16; +} + + + +int aos_register_driver(char *path,file_ops_t *ops,void *arg) + +{ + BaseType_t BVar1; + int iVar2; + inode_t *piStack36; + inode_t *node; + + piStack36 = (inode_t *)0x0; + BVar1 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar1 == 1) { + iVar2 = inode_reserve(path,&piStack36); + if (iVar2 == 0) { + *(file_ops_t **)&piStack36->ops = ops; + piStack36->type = '\x01'; + piStack36->i_arg = arg; + } + BVar1 = xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + if (BVar1 == 1) { + return iVar2; + } + if (piStack36->i_name != (char *)0x0) { + vPortFree(piStack36->i_name); + } + memset(piStack36,0,0x14); + } + return -1; +} + + + +int aos_register_fs(char *path,fs_ops_t *ops,void *arg) + +{ + BaseType_t BVar1; + int iVar2; + inode_t *piStack36; + inode_t *node; + + piStack36 = (inode_t *)0x0; + BVar1 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar1 == 1) { + iVar2 = inode_reserve(path,&piStack36); + if (iVar2 == 0) { + *(fs_ops_t **)&piStack36->ops = ops; + piStack36->type = '\x03'; + piStack36->i_arg = arg; + } + BVar1 = xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + if (BVar1 == 1) { + return iVar2; + } + if (piStack36->i_name != (char *)0x0) { + vPortFree(piStack36->i_name); + } + memset(piStack36,0,0x14); + } + return -1; +} + + + +int vfs_uart_open(inode_t *inode,file_t *fp) + +{ + uart_dev_t *uart; + int iVar1; + StreamBufferHandle_t pSVar2; + int32_t iVar3; + inode_t *piVar4; + + if ((fp == (file_t *)0x0) || (piVar4 = fp->node, piVar4 == (inode_t *)0x0)) { + iVar1 = -0x16; + } + else { + iVar1 = 0; + if (piVar4->refs == '\x01') { + uart = (uart_dev_t *)piVar4->i_arg; + aos_mutex_new((aos_mutex_t *)&uart->mutex); + pSVar2 = xStreamBufferGenericCreate(uart->rx_buf_size,1,0); + *(StreamBufferHandle_t *)&uart->rx_ringbuf_handle = pSVar2; + pSVar2 = xStreamBufferGenericCreate(uart->tx_buf_size,1,0); + *(StreamBufferHandle_t *)&uart->tx_ringbuf_handle = pSVar2; + if ((uart->rx_ringbuf_handle != (void *)0x0) && (pSVar2 != (StreamBufferHandle_t)0x0)) { + hal_uart_notify_register(uart,UART_TX_INT,__uart_tx_irq); + hal_uart_notify_register(uart,UART_RX_INT,__uart_rx_irq); + iVar3 = hal_uart_init(uart); + return iVar3; + } + return -0x16; + } + } + return iVar1; +} + + + +void __uart_rx_irq(void *p_arg) + +{ + uint32_t uStack88; + uint32_t length; + BaseType_t xHigherPriorityTaskWoken; + uint8_t tmp_buf [64]; + + uStack88 = 0; + length = 0; + hal_uart_recv_II((uart_dev_t *)p_arg,&xHigherPriorityTaskWoken,0x40,&uStack88,0); + if (uStack88 != 0) { + xStreamBufferSendFromISR + (*(StreamBufferHandle_t *)((int)p_arg + 0x10),&xHigherPriorityTaskWoken,uStack88, + (BaseType_t *)&length); + if (length != 0) { + vTaskSwitchContext(); + } + } + if (*(int *)((int)p_arg + 0x24) != 0) { + *(ushort *)(*(int *)((int)p_arg + 0x28) + 6) = *(ushort *)(*(int *)((int)p_arg + 0x28) + 6) | 1; + (**(code **)((int)p_arg + 0x24)) + (*(undefined4 *)((int)p_arg + 0x28),*(undefined4 *)((int)p_arg + 0x2c), + *(code **)((int)p_arg + 0x24)); + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void __uart_tx_irq(void *p_arg) + +{ + size_t sVar1; + undefined uStack21; + uint8_t ch; + int iStack20; + BaseType_t xHigherPriorityTaskWoken; + + iStack20 = 0; + sVar1 = xStreamBufferReceiveFromISR + (*(StreamBufferHandle_t *)((int)p_arg + 0x14),&uStack21,1, + (BaseType_t *)&stack0xffffffec); + if (iStack20 != 0) { + vTaskSwitchContext(); + } + if (sVar1 == 1) { + hal_uart_send((uart_dev_t *)p_arg,&uStack21,1,0); + } + else { + hal_uart_send_trigger_off((uart_dev_t *)p_arg); + } + return; +} + + + +int vfs_uart_close(file_t *fp) + +{ + uart_dev_t *uart; + int32_t iVar1; + inode_t *piVar2; + + if ((fp == (file_t *)0x0) || (piVar2 = fp->node, piVar2 == (inode_t *)0x0)) { + return -0x16; + } + if (piVar2->refs != '\x01') { + return 0; + } + uart = (uart_dev_t *)piVar2->i_arg; + if (uart != (uart_dev_t *)0x0) { + aos_mutex_free((aos_mutex_t *)&uart->mutex); + vStreamBufferDelete((StreamBufferHandle_t)uart->rx_ringbuf_handle); + vStreamBufferDelete((StreamBufferHandle_t)uart->tx_ringbuf_handle); + iVar1 = hal_uart_finalize(uart); + return iVar1; + } + return -0x16; +} + + + +ssize_t vfs_uart_read(file_t *fp,void *buf,size_t nbytes) + +{ + size_t sVar1; + TickType_t xTicksToWait; + size_t sVar2; + void *pvVar3; + + sVar1 = 0xffffffea; + if (fp != (file_t *)0x0) { + sVar1 = 0xffffffea; + if (((fp->node != (inode_t *)0x0) && (pvVar3 = fp->node->i_arg, nbytes != 0)) && + (pvVar3 != (void *)0x0)) { + aos_mutex_lock((aos_mutex_t *)((int)pvVar3 + 0x20),0xffffffff); + sVar1 = 0; + xTicksToWait = -(uint)(*(char *)((int)pvVar3 + 0x34) == '\x01'); + do { + sVar2 = xStreamBufferReceive + (*(StreamBufferHandle_t *)((int)pvVar3 + 0x10),(void *)((int)buf + sVar1), + nbytes - sVar1,xTicksToWait); + sVar1 = sVar1 + sVar2; + if (sVar1 == nbytes) break; + } while (xTicksToWait != 0); + aos_mutex_unlock((aos_mutex_t *)((int)pvVar3 + 0x20)); + } + } + return sVar1; +} + + + +ssize_t vfs_uart_write(file_t *fp,void *buf,size_t nbytes) + +{ + size_t sVar1; + uart_dev_t *uart; + + sVar1 = 0xffffffea; + if (fp != (file_t *)0x0) { + sVar1 = 0xffffffea; + if (((fp->node != (inode_t *)0x0) && + (uart = (uart_dev_t *)fp->node->i_arg, uart != (uart_dev_t *)0x0)) && + (sVar1 = xStreamBufferSend((StreamBufferHandle_t)uart->tx_ringbuf_handle,buf,nbytes,0), + 0 < (int)sVar1)) { + hal_uart_send_trigger(uart); + } + } + return sVar1; +} + + + +int vfs_uart_poll(file_t *fp,_Bool setup,poll_notify_t *notify,pollfd *fd,void *opa) + +{ + void *pvVar1; + BaseType_t BVar2; + undefined3 in_register_0000202d; + + pvVar1 = fp->node->i_arg; + aos_mutex_lock((aos_mutex_t *)((int)pvVar1 + 0x20),0xffffffff); + if (CONCAT31(in_register_0000202d,setup) == 0) { + vTaskEnterCritical(); + *(undefined4 *)((int)pvVar1 + 0x24) = 0; + *(undefined4 *)((int)pvVar1 + 0x2c) = 0; + vTaskExitCritical(); + } + else { + vTaskEnterCritical(); + *(poll_notify_t **)((int)pvVar1 + 0x24) = notify; + *(pollfd **)((int)pvVar1 + 0x28) = fd; + *(void **)((int)pvVar1 + 0x2c) = opa; + vTaskExitCritical(); + BVar2 = xStreamBufferIsEmpty(*(StreamBufferHandle_t *)((int)pvVar1 + 0x10)); + if (BVar2 != 1) { + *(ushort *)(*(int *)((int)pvVar1 + 0x28) + 6) = + *(ushort *)(*(int *)((int)pvVar1 + 0x28) + 6) | 1; + (*notify)(fd,opa); + } + } + aos_mutex_unlock((aos_mutex_t *)((int)pvVar1 + 0x20)); + return 0; +} + + + +int vfs_uart_sync(file_t *fp) + +{ + uart_dev_t *uart; + int iVar1; + + if (fp == (file_t *)0x0) { + return -0x16; + } + iVar1 = -0x16; + if (fp->node != (inode_t *)0x0) { + uart = (uart_dev_t *)fp->node->i_arg; + if (uart != (uart_dev_t *)0x0) { + aos_mutex_lock((aos_mutex_t *)&uart->mutex,0xffffffff); + hal_uart_send_flush(uart,0); + aos_mutex_unlock((aos_mutex_t *)&uart->mutex); + iVar1 = 0; + } + return iVar1; + } + return iVar1; +} + + + +int uart_ioctl_cmd_waimode(uart_dev_t *uart_dev,int cmd,ulong arg) + +{ + int iVar1; + size_t sVar2; + uint uVar3; + int iVar4; + + iVar1 = -0x16; + if (arg != 0) { + iVar4 = *(int *)(arg + 4); + uVar3 = *(int *)(arg + 8) * 1000; + iVar1 = 0; + do { + sVar2 = xStreamBufferReceive + ((StreamBufferHandle_t)uart_dev->rx_ringbuf_handle, + (void *)(*(int *)arg + iVar1),iVar4 - iVar1,uVar3 / 1000); + iVar1 = iVar1 + sVar2; + if (iVar4 == iVar1) { + return iVar1; + } + if (uVar3 < 1000) { + return iVar1; + } + } while ((cmd != 4) || (iVar1 < 1)); + } + return iVar1; +} + + + +int uart_ioctl_cmd_setconfig(uart_dev_t *uart_dev,ulong arg) + +{ + hal_uart_parity_t parity; + + if (arg != 0) { + parity = *(hal_uart_parity_t *)(arg + 4); + if ((parity != ODD_PARITY) && (parity != EVEN_PARITY)) { + parity = NO_PARITY; + } + hal_uart_setconfig(uart_dev,*(uint32_t *)arg,parity); + return 0; + } + return -0x16; +} + + + +int vfs_uart_ioctl(file_t *fp,int cmd,ulong arg) + +{ + int iVar1; + uart_dev_t *uart_dev; + uint8_t uVar2; + + if (fp == (file_t *)0x0) { + return -0x16; + } + iVar1 = -0x16; + if (fp->node == (inode_t *)0x0) { + return -0x16; + } + uart_dev = (uart_dev_t *)fp->node->i_arg; + if (uart_dev == (uart_dev_t *)0x0) { + return -0x16; + } + aos_mutex_lock((aos_mutex_t *)&uart_dev->mutex,0xffffffff); + switch(cmd) { + case 2: + hal_uart_send_flush(uart_dev,0); + break; + case 3: + hal_uart_setbaud(uart_dev,arg); + break; + case 4: + case 5: + iVar1 = uart_ioctl_cmd_waimode(uart_dev,cmd,arg); + goto switchD_2307b77e_caseD_7; + case 6: + uVar2 = '\x01'; + goto LAB_2307b7c0; + case 7: + uVar2 = '\x02'; +LAB_2307b7c0: + uart_dev->read_block_flag = uVar2; + break; + case 8: + iVar1 = uart_ioctl_cmd_setconfig(uart_dev,arg); + default: + goto switchD_2307b77e_caseD_7; + } + iVar1 = -1; +switchD_2307b77e_caseD_7: + aos_mutex_unlock((aos_mutex_t *)&uart_dev->mutex); + return iVar1; +} + + + +yloop_ctx_t * get_context(void) + +{ + yloop_ctx_t *pyVar1; + + pyVar1 = (yloop_ctx_t *)aos_task_getspecific(g_loop_key); + if (pyVar1 == (yloop_ctx_t *)0x0) { + aos_task_setspecific(g_loop_key,g_main_ctx); + pyVar1 = g_main_ctx; + } + return pyVar1; +} + + + +void aos_loop_set_eventfd(int fd) + +{ + yloop_ctx_t *pyVar1; + + pyVar1 = get_context(); + pyVar1->eventfd = fd; + return; +} + + + +aos_loop_t aos_loop_init(void) + +{ + aos_task_key_t key; + void *pvVar1; + yloop_ctx_t *__s; + + pvVar1 = aos_task_getspecific(g_loop_key); + if (g_main_ctx == (yloop_ctx_t *)0x0) { + aos_task_key_create(&g_loop_key); + } + else { + if (pvVar1 != (void *)0x0) { + printf("yloopyloop already inited"); + return pvVar1; + } + } + __s = (yloop_ctx_t *)pvPortMalloc(0x1c); + if (__s != (yloop_ctx_t *)0x0) { + memset(__s,0,0x1c); + } + if (g_main_ctx == (yloop_ctx_t *)0x0) { + g_main_ctx = __s; + } + *(yloop_ctx_t **)&(__s->timeouts).prev = __s; + key = g_loop_key; + __s->eventfd = -1; + *(yloop_ctx_t **)&(__s->timeouts).next = __s; + aos_task_setspecific(key,__s); + aos_event_service_init(); + return __s; +} + + + +int aos_poll_read_fd(int sock,aos_poll_call_t *cb,void *private_data) + +{ + yloop_sock_t *__dest; + yloop_ctx_t *pyVar1; + pollfd *__dest_00; + uint uVar2; + int iVar3; + uint uVar4; + + pyVar1 = get_context(); + if (sock < 0) { + iVar3 = -0x16; + } + else { + uVar4 = (uint)pyVar1->reader_count; + __dest = (yloop_sock_t *)pvPortMalloc((uVar4 + 1) * 0xc); + __dest_00 = (pollfd *)pvPortMalloc((uVar4 + 1) * 8); + if ((__dest == (yloop_sock_t *)0x0) || (__dest_00 == (pollfd *)0x0)) { + printf("yloopout of memory"); + vPortFree(__dest); + vPortFree(__dest_00); + iVar3 = -0xc; + } + else { + uVar2 = aos_fcntl(sock,3,0); + aos_fcntl(sock,4,uVar2 | 0x4000); + pyVar1->reader_count = pyVar1->reader_count + '\x01'; + memcpy(__dest,pyVar1->readers,uVar4 * 0xc); + vPortFree(pyVar1->readers); + pyVar1->readers = __dest; + memcpy(__dest_00,pyVar1->pollfds,uVar4 << 3); + __dest = __dest + uVar4; + vPortFree(pyVar1->pollfds); + pyVar1->pollfds = __dest_00; + __dest->sock = sock; + __dest->private_data = private_data; + __dest->cb = cb; + iVar3 = 0; + if ((int)(uint)pyVar1->max_sock < sock) { + pyVar1->max_sock = (uint16_t)sock; + iVar3 = 0; + } + } + } + return iVar3; +} + + + +int aos_post_delayed_action(int ms,aos_call_t *action,void *param) + +{ + yloop_ctx_t *pyVar1; + dlist_s *pdVar2; + int iVar3; + pollfd *ppVar4; + aos_call_t *paVar5; + yloop_sock_t *pyVar6; + dlist_s *pdVar7; + yloop_ctx_t *pyVar8; + + if (action != (aos_call_t *)0x0) { + paVar5 = action; + pyVar1 = get_context(); + pdVar2 = (dlist_s *)pvPortMalloc(0x20); + iVar3 = -0xc; + if (pdVar2 != (dlist_s *)0x0) { + aos_now_ms(); + ppVar4 = (pollfd *)(iVar3 + ms); + pyVar6 = (yloop_sock_t *)(paVar5 + (uint)(ppVar4 < (uint)ms) + (ms >> 0x1f)); + *(pollfd **)&pdVar2[1].prev = ppVar4; + *(yloop_sock_t **)&pdVar2[1].next = pyVar6; + pdVar2[2].prev = param; + *(aos_call_t **)&pdVar2[2].next = action; + *(int *)&pdVar2[3].prev = ms; + pyVar8 = (yloop_ctx_t *)(pyVar1->timeouts).next; + while (((pyVar8 != pyVar1 && ((int)pyVar8->readers <= (int)pyVar6)) && + ((pyVar8->readers != pyVar6 || (pyVar8->pollfds <= ppVar4))))) { + pyVar8 = (yloop_ctx_t *)(pyVar8->timeouts).next; + } + pdVar7 = (pyVar8->timeouts).prev; + *(yloop_ctx_t **)&pdVar2->next = pyVar8; + iVar3 = 0; + pdVar2->prev = pdVar7; + pdVar7->next = pdVar2; + (pyVar8->timeouts).prev = pdVar2; + } + return iVar3; + } + return -0x16; +} + + + +void aos_loop_run(yloop_sock_t *param_1) + +{ + yloop_ctx_t *pyVar1; + yloop_sock_t *pyVar2; + yloop_ctx_t *pyVar3; + yloop_ctx_t *pyVar4; + yloop_sock_t *extraout_a1; + yloop_sock_t *extraout_a1_00; + yloop_ctx_t *pv; + dlist_s *pdVar5; + int iVar6; + dlist_s *pdVar7; + yloop_sock_t *pyVar8; + yloop_sock_t *nfds; + undefined4 extraout_fa0; + longlong lVar9; + + pyVar3 = get_context(); + pyVar4 = pyVar3; + while (pyVar3->terminate == false) { + pyVar1 = (yloop_ctx_t *)(pyVar3->timeouts).next; + nfds = (yloop_sock_t *)(uint)pyVar3->reader_count; + if ((pyVar3 == pyVar1) && (pyVar3->reader_count == 0)) break; + pv = (yloop_ctx_t *)0xffffffff; + if (pyVar3 != pyVar1) { + aos_now_ms(); + if (((int)param_1 < (int)pyVar1->readers) || + ((pyVar1->readers == param_1 && (pyVar4 < (yloop_ctx_t *)pyVar1->pollfds)))) { + pv = (yloop_ctx_t *)((int)(yloop_ctx_t *)pyVar1->pollfds - (int)pyVar4); + } + else { + pv = (yloop_ctx_t *)0x0; + } + } + iVar6 = 0; + while (iVar6 < (int)nfds) { + pyVar3->pollfds[iVar6].fd = pyVar3->readers[iVar6].sock; + pyVar3->pollfds[iVar6].events = 1; + iVar6 = iVar6 + 1; + } + param_1 = nfds; + pyVar1 = (yloop_ctx_t *)aos_poll(pyVar3->pollfds,(int)nfds,(int)pv); + pyVar4 = pyVar1; + if ((int)pyVar1 < 0) { + pyVar4 = (yloop_ctx_t *)__errno(); + param_1 = extraout_a1; + if ((pyVar4->timeouts).prev != (dlist_s *)0x4) { + printf("yloopaos_poll",extraout_fa0); + return; + } + } + pv = (yloop_ctx_t *)(pyVar3->timeouts).next; + if (pyVar3 != pv) { + lVar9 = aos_now_ms(); + if (((int)pv->readers <= (int)param_1) && + ((pv->readers != param_1 || ((yloop_ctx_t *)pv->pollfds <= pyVar4)))) { + pdVar7 = (pv->timeouts).next; + pdVar5 = (pv->timeouts).prev; + pdVar5->next = pdVar7; + pdVar7->prev = pdVar5; + param_1 = (yloop_sock_t *) + (**(code **)&pv->max_sock)(pv->eventfd,*(code **)&pv->max_sock,(int)lVar9); + vPortFree(pv); + pyVar4 = pv; + } + } + pyVar2 = (yloop_sock_t *)0x0; + if (0 < (int)pyVar1) { + while (pyVar2 != nfds) { + if ((pyVar3->pollfds[(int)pyVar2].revents & 1U) != 0) { + pyVar8 = pyVar3->readers + (int)pyVar2; + pyVar4 = (yloop_ctx_t *)(*pyVar8->cb)(pyVar8->sock,pyVar8->private_data); + param_1 = extraout_a1_00; + } + pyVar2 = (yloop_sock_t *)((int)&pyVar2->sock + 1); + } + } + } + pyVar3->terminate = false; + return; +} + + + +void vfs_poll_notify(pollfd *fd,void *arg) + +{ + aos_sem_signal((aos_sem_t *)arg); + return; +} + + + +int aos_poll(pollfd *fds,int nfds,int timeout) + +{ + ushort *puVar1; + int iVar2; + uint fd; + file_t *pfVar3; + ushort *puVar4; + int iVar5; + code *pcVar6; + int iVar7; + pollfd *ppVar8; + aos_sem_t aStack60; + poll_arg parg; + _types_fd_set rfds; + + aos_sem_new(&aStack60,0); + iVar5 = 0; + do { + *(undefined *)((int)&parg.sem.hdl + iVar5) = 0; + iVar5 = iVar5 + 1; + } while (iVar5 != 8); + puVar1 = (ushort *)&fds->revents; + iVar5 = 0; + puVar4 = puVar1; + while (iVar5 < nfds) { + *puVar4 = 0; + iVar5 = iVar5 + 1; + puVar4 = puVar4 + 4; + } + iVar5 = 0; + ppVar8 = fds; + do { + if (nfds <= iVar5) { + if (timeout < 0) { + timeout = 0xffffffff; + } + aos_sem_wait(&aStack60,timeout); + iVar5 = 0; + while (iVar5 < nfds) { + if ((1 << (*(uint *)(puVar1 + -3) & 0x1f) & + (uint)(&parg)[*(uint *)(puVar1 + -3) >> 5].sem.hdl) != 0) { + *puVar1 = *puVar1 | 1; + } + iVar5 = iVar5 + 1; + puVar1 = puVar1 + 4; + } + iVar5 = 0; +check_poll: + iVar2 = 0; + iVar7 = 0; + while (iVar7 < nfds) { + if (((1 < fds->fd) && (pfVar3 = get_file(fds->fd), pfVar3 != (file_t *)0x0)) && + (pcVar6 = *(code **)(pfVar3->node->ops + 0x14), (*pcVar6)(0,0,0,0,pcVar6), + fds->revents != 0)) { + iVar2 = iVar2 + 1; + } + iVar7 = iVar7 + 1; + fds = fds + 1; + } + aos_sem_free(&aStack60); + if (iVar5 != 0) { + iVar2 = 0; + } + return iVar2; + } + fd = ppVar8->fd; + if ((int)fd < 2) { + (&parg)[fd >> 5].sem.hdl = (void *)(1 << (fd & 0x1f) | (uint)(&parg)[fd >> 5].sem.hdl); + } + else { + pfVar3 = get_file(fd); + if (pfVar3 == (file_t *)0x0) { + iVar5 = -1; + goto check_poll; + } + pcVar6 = *(code **)(pfVar3->node->ops + 0x14); + (*pcVar6)(1,vfs_poll_notify,ppVar8,&aStack60,pcVar6); + } + iVar5 = iVar5 + 1; + ppVar8 = ppVar8 + 1; + } while( true ); +} + + + +int aos_fcntl(int fd,int cmd,int val) + +{ + int iVar1; + + iVar1 = -0x16; + if ((-1 < fd) && (iVar1 = 0, fd < 2)) { + iVar1 = -2; + } + return iVar1; +} + + + +void dfl_entry(void *arg) + +{ + code *pcVar1; + undefined4 uVar2; + + uVar2 = *(undefined4 *)((int)arg + 8); + pcVar1 = *(code **)((int)arg + 4); + vPortFree(arg); + (*pcVar1)(uVar2); + vTaskDelete((TaskHandle_t)0x0); + return; +} + + + +int aos_task_new(char *name,anon_subr_void_void_ptr *fn,void *arg,int stack_size) + +{ + StaticTask_t *pxTaskBuffer; + StaticTask_t **pvParameters; + StackType_t *puxStackBuffer; + TaskHandle_t ptVar1; + int iVar2; + + pxTaskBuffer = (StaticTask_t *)pvPortMalloc(0x9c); + pvParameters = (StaticTask_t **)pvPortMalloc(0xc); + puxStackBuffer = (StackType_t *)pvPortMalloc(stack_size); + memset(puxStackBuffer,0,stack_size); + memset(pxTaskBuffer,0,0x9c); + pxTaskBuffer[1].pxDummy1 = (void *)0xfffffff0; + *(StackType_t **)(pxTaskBuffer[1].xDummy3[0].pvDummy3 + 3) = puxStackBuffer; + strncpy((char *)(pxTaskBuffer[1].xDummy3 + 1),name,0x1f); + *(undefined4 *)(pxTaskBuffer[1].ucDummy7 + 4) = 0x20171020; + *pvParameters = pxTaskBuffer; + *(anon_subr_void_void_ptr **)(pvParameters + 1) = fn; + pvParameters[2] = arg; + ptVar1 = xTaskCreateStatic(dfl_entry,name,(uint)stack_size >> 2,pvParameters,10,puxStackBuffer, + pxTaskBuffer); + if (ptVar1 == (TaskHandle_t)0x0) { + vPortFree(pxTaskBuffer); + vPortFree(puxStackBuffer); + vPortFree(pvParameters); + iVar2 = -1; + } + else { + iVar2 = 0; + } + return iVar2; +} + + + +void aos_task_exit(int code) + +{ + vTaskDelete((TaskHandle_t)0x0); + return; +} + + + +int aos_task_key_create(aos_task_key_t *key) + +{ + TaskHandle_t ptVar1; + uint uVar2; + aos_task_key_t aVar3; + int iVar4; + StackType_t *pSVar5; + + ptVar1 = xTaskGetCurrentTaskHandle(); + if (*(int *)(ptVar1[1].pcTaskName + 4) == 0x20171020) { + pSVar5 = ptVar1[1].pxTopOfStack; + if (((uint)pSVar5 & 1) == 0) { + aVar3 = 0; + uVar2 = 1; + } + else { + if (((uint)pSVar5 & 2) == 0) { + aVar3 = 1; + uVar2 = 2; + } + else { + if (((uint)pSVar5 & 4) == 0) { + aVar3 = 2; + uVar2 = 4; + } + else { + if (((uint)pSVar5 & 8) != 0) { + return -1; + } + aVar3 = 3; + uVar2 = 8; + } + } + } + ptVar1[1].pxTopOfStack = (StackType_t *)((uint)pSVar5 | uVar2); + *key = aVar3; + iVar4 = 0; + } + else { + iVar4 = -1; + } + return iVar4; +} + + + +int aos_task_setspecific(aos_task_key_t key,void *vp) + +{ + TaskHandle_t ptVar1; + int iVar2; + + ptVar1 = xTaskGetCurrentTaskHandle(); + if (key < 4) { + iVar2 = -1; + if (*(int *)(ptVar1[1].pcTaskName + 4) == 0x20171020) { + *(void **)(&(ptVar1->xStateListItem).xItemValue + key + 0x18) = vp; + iVar2 = 0; + } + } + else { + iVar2 = -1; + } + return iVar2; +} + + + +void * aos_task_getspecific(aos_task_key_t key) + +{ + TaskHandle_t ptVar1; + void *pvVar2; + + ptVar1 = xTaskGetCurrentTaskHandle(); + if (key < 4) { + pvVar2 = (void *)0x0; + if (*(int *)(ptVar1[1].pcTaskName + 4) == 0x20171020) { + pvVar2 = (void *)(&(ptVar1->xStateListItem).xItemValue)[key + 0x18]; + } + } + else { + pvVar2 = (void *)0x0; + } + return pvVar2; +} + + + +int aos_mutex_new(aos_mutex_t *mutex) + +{ + QueueHandle_t pQVar1; + + pQVar1 = xQueueCreateMutex('\x01'); + *(QueueHandle_t *)&mutex->hdl = pQVar1; + return -(uint)(pQVar1 == (QueueHandle_t)0x0); +} + + + +void aos_mutex_free(aos_mutex_t *mutex) + +{ + vQueueDelete((QueueHandle_t)mutex->hdl); + return; +} + + + +int aos_mutex_lock(aos_mutex_t *mutex,uint ms) + +{ + if (mutex != (aos_mutex_t *)0x0) { + xQueueSemaphoreTake((QueueHandle_t)mutex->hdl,ms); + return 0; + } + return 0; +} + + + +int aos_mutex_unlock(aos_mutex_t *mutex) + +{ + if (mutex != (aos_mutex_t *)0x0) { + xQueueGenericSend((QueueHandle_t)mutex->hdl,(void *)0x0,0,0); + return 0; + } + return 0; +} + + + +int aos_sem_new(aos_sem_t *sem,int count) + +{ + QueueHandle_t pQVar1; + + pQVar1 = xQueueCreateCountingSemaphore(0x80,count); + *(QueueHandle_t *)&sem->hdl = pQVar1; + return 0; +} + + + +void aos_sem_free(aos_sem_t *sem) + +{ + if (sem != (aos_sem_t *)0x0) { + vQueueDelete((QueueHandle_t)sem->hdl); + return; + } + return; +} + + + +int aos_sem_wait(aos_sem_t *sem,uint ms) + +{ + BaseType_t BVar1; + + if (sem != (aos_sem_t *)0x0) { + BVar1 = xQueueSemaphoreTake((QueueHandle_t)sem->hdl,ms); + return -(uint)(BVar1 != 1); + } + return -1; +} + + + +void aos_sem_signal(aos_sem_t *sem) + +{ + BaseType_t BStack20; + BaseType_t xHigherPriorityTaskWoken; + + BStack20 = 0; + if (sem != (aos_sem_t *)0x0) { + if (TrapNetCounter == 0) { + xQueueGenericSend((QueueHandle_t)sem->hdl,(void *)0x0,0,0); + } + else { + xQueueGiveFromISR((QueueHandle_t)sem->hdl,&BStack20); + if (BStack20 != 0) { + vTaskSwitchContext(); + } + } + } + return; +} + + + +void * aos_malloc(size_t xWantedSize) + +{ + size_t sVar1; + size_t sVar2; + BlockLink_t *pBVar3; + A_BLOCK_LINK *pAVar4; + BlockLink_t *pxBlockToInsert; + uint uVar5; + uint uVar6; + + if (pxEnd == (BlockLink_t *)0x0) { + vAssertCalled(); + } + vTaskSuspendAll(); + sVar2 = xFreeBytesRemaining; + sVar1 = xBlockAllocatedBit; + if (((xBlockAllocatedBit & xWantedSize) == 0) && (xWantedSize != 0)) { + uVar6 = xWantedSize + 8; + if ((uVar6 & 7) != 0) { + uVar6 = (uVar6 & 0xfffffff8) + 8; + } + if ((uVar6 != 0) && (uVar6 <= xFreeBytesRemaining)) { + pAVar4 = xStart.pxNextFreeBlock; + pBVar3 = &xStart; + do { + pxBlockToInsert = pBVar3; + pBVar3 = (BlockLink_t *)pAVar4; + if (uVar6 <= pBVar3->xBlockSize) break; + pAVar4 = pBVar3->pxNextFreeBlock; + } while (pBVar3->pxNextFreeBlock != (A_BLOCK_LINK *)0x0); + if (pxEnd != pBVar3) { + pAVar4 = pxBlockToInsert->pxNextFreeBlock; + pxBlockToInsert->pxNextFreeBlock = pBVar3->pxNextFreeBlock; + uVar5 = pBVar3->xBlockSize; + pAVar4 = pAVar4 + 1; + if (0x10 < uVar5 - uVar6) { + pxBlockToInsert = (BlockLink_t *)((int)&pBVar3->pxNextFreeBlock + uVar6); + pxBlockToInsert->xBlockSize = uVar5 - uVar6; + pBVar3->xBlockSize = uVar6; + prvInsertBlockIntoFreeList(pxBlockToInsert); + uVar5 = pBVar3->xBlockSize; + } + xFreeBytesRemaining = sVar2 - uVar5; + if (xFreeBytesRemaining < xMinimumEverFreeBytesRemaining) { + xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; + } + pBVar3->xBlockSize = sVar1 | uVar5; + pBVar3->pxNextFreeBlock = (A_BLOCK_LINK *)0x0; + xTaskResumeAll(); + if (pAVar4 != (A_BLOCK_LINK *)0x0) { + return pAVar4; + } + goto LAB_230648be; + } + } + } + xTaskResumeAll(); +LAB_230648be: + vApplicationMallocFailedHook(); + return (void *)0x0; +} + + + +void free(void *pv) + +{ + uint uVar1; + + if (pv == (void *)0x0) { + return; + } + uVar1 = *(uint *)((int)pv + -4); + if ((uVar1 & xBlockAllocatedBit) == 0) { + vAssertCalled(); + if (*(int *)((int)pv + -8) == 0) { + uVar1 = *(uint *)((int)pv + -4); + if ((uVar1 & xBlockAllocatedBit) == 0) { + return; + } + goto LAB_230649ce; + } + } + else { + if (*(int *)((int)pv + -8) == 0) goto LAB_230649ce; + } + vAssertCalled(); + uVar1 = *(uint *)((int)pv + -4); + if (((uVar1 & xBlockAllocatedBit) == 0) || (*(int *)((int)pv + -8) != 0)) { + return; + } +LAB_230649ce: + *(uint *)((int)pv + -4) = ~xBlockAllocatedBit & uVar1; + vTaskSuspendAll(); + xFreeBytesRemaining = *(int *)((int)pv + -4) + xFreeBytesRemaining; + prvInsertBlockIntoFreeList((BlockLink_t *)((int)pv + -8)); + xTaskResumeAll(); + return; +} + + + +void aos_free(void *pv) + +{ + uint uVar1; + + if (pv == (void *)0x0) { + return; + } + uVar1 = *(uint *)((int)pv + -4); + if ((uVar1 & xBlockAllocatedBit) == 0) { + vAssertCalled(); + if (*(int *)((int)pv + -8) == 0) { + uVar1 = *(uint *)((int)pv + -4); + if ((uVar1 & xBlockAllocatedBit) == 0) { + return; + } + goto LAB_230649ce; + } + } + else { + if (*(int *)((int)pv + -8) == 0) goto LAB_230649ce; + } + vAssertCalled(); + uVar1 = *(uint *)((int)pv + -4); + if (((uVar1 & xBlockAllocatedBit) == 0) || (*(int *)((int)pv + -8) != 0)) { + return; + } +LAB_230649ce: + *(uint *)((int)pv + -4) = ~xBlockAllocatedBit & uVar1; + vTaskSuspendAll(); + xFreeBytesRemaining = *(int *)((int)pv + -4) + xFreeBytesRemaining; + prvInsertBlockIntoFreeList((BlockLink_t *)((int)pv + -8)); + xTaskResumeAll(); + return; +} + + + +void * malloc(size_t xWantedSize) + +{ + size_t sVar1; + size_t sVar2; + BlockLink_t *pBVar3; + A_BLOCK_LINK *pAVar4; + BlockLink_t *pxBlockToInsert; + uint uVar5; + uint uVar6; + + if (pxEnd == (BlockLink_t *)0x0) { + vAssertCalled(); + } + vTaskSuspendAll(); + sVar2 = xFreeBytesRemaining; + sVar1 = xBlockAllocatedBit; + if (((xBlockAllocatedBit & xWantedSize) == 0) && (xWantedSize != 0)) { + uVar6 = xWantedSize + 8; + if ((uVar6 & 7) != 0) { + uVar6 = (uVar6 & 0xfffffff8) + 8; + } + if ((uVar6 != 0) && (uVar6 <= xFreeBytesRemaining)) { + pAVar4 = xStart.pxNextFreeBlock; + pBVar3 = &xStart; + do { + pxBlockToInsert = pBVar3; + pBVar3 = (BlockLink_t *)pAVar4; + if (uVar6 <= pBVar3->xBlockSize) break; + pAVar4 = pBVar3->pxNextFreeBlock; + } while (pBVar3->pxNextFreeBlock != (A_BLOCK_LINK *)0x0); + if (pxEnd != pBVar3) { + pAVar4 = pxBlockToInsert->pxNextFreeBlock; + pxBlockToInsert->pxNextFreeBlock = pBVar3->pxNextFreeBlock; + uVar5 = pBVar3->xBlockSize; + pAVar4 = pAVar4 + 1; + if (0x10 < uVar5 - uVar6) { + pxBlockToInsert = (BlockLink_t *)((int)&pBVar3->pxNextFreeBlock + uVar6); + pxBlockToInsert->xBlockSize = uVar5 - uVar6; + pBVar3->xBlockSize = uVar6; + prvInsertBlockIntoFreeList(pxBlockToInsert); + uVar5 = pBVar3->xBlockSize; + } + xFreeBytesRemaining = sVar2 - uVar5; + if (xFreeBytesRemaining < xMinimumEverFreeBytesRemaining) { + xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; + } + pBVar3->xBlockSize = sVar1 | uVar5; + pBVar3->pxNextFreeBlock = (A_BLOCK_LINK *)0x0; + xTaskResumeAll(); + if (pAVar4 != (A_BLOCK_LINK *)0x0) { + return pAVar4; + } + goto LAB_230648be; + } + } + } + xTaskResumeAll(); +LAB_230648be: + vApplicationMallocFailedHook(); + return (void *)0x0; +} + + + +longlong aos_now_ms(void) + +{ + BaseType_t BVar1; + longlong in_fa0; + TickType_t TStack24; + TickType_t ticks; + BaseType_t overflow_count; + + TStack24 = 0; + ticks = 0; + BVar1 = xTaskGetTickCount2(&TStack24,(BaseType_t *)&ticks); + if (BVar1 != 1) { + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + return in_fa0; +} + + + +int event_poll(file_t *f,_Bool setup,poll_notify_t *notify,pollfd *fd,void *opa) + +{ + aos_mutex_t *mutex; + undefined3 in_register_0000202d; + + mutex = (aos_mutex_t *)f->f_arg; + aos_mutex_lock(mutex,0xffffffff); + if (CONCAT31(in_register_0000202d,setup) == 0) { + mutex[1].hdl = (void *)0x0; + mutex[3].hdl = (void *)0x0; + } + else { + *(poll_notify_t **)&mutex[1].hdl = notify; + *(pollfd **)&mutex[2].hdl = fd; + mutex[3].hdl = opa; + if (mutex[4].hdl != (void *)0x0) { + fd->revents = fd->revents | 1; + (*notify)(fd,opa); + } + } + aos_mutex_unlock(mutex); + return 0; +} + + + +int event_open(inode_t *node,file_t *file) + +{ + aos_mutex_t *mutex; + + mutex = (aos_mutex_t *)aos_malloc(0x28); + memset(mutex,0,0x28); + aos_mutex_new(mutex); + *(aos_mutex_t **)&mutex[5].hdl = mutex + 5; + *(aos_mutex_t **)&mutex[6].hdl = mutex + 5; + *(aos_mutex_t **)&mutex[8].hdl = mutex + 8; + *(aos_mutex_t **)&mutex[9].hdl = mutex + 8; + *(aos_mutex_t **)&file->f_arg = mutex; + return 0; +} + + + +ssize_t _event_write(void *buf,size_t len,_Bool urgent) + +{ + int *piVar1; + undefined3 in_register_00002031; + int in_a3; + int iVar2; + int *piVar3; + int **ppiVar4; + size_t __n; + + __n = CONCAT31(in_register_00002031,urgent); + aos_mutex_lock((aos_mutex_t *)buf,0xffffffff); + if ((*(int *)((int)buf + 0x1c) < 1) || (piVar1 = *(int **)((int)buf + 0x24), __n != piVar1[2])) { + piVar1 = (int *)aos_malloc(__n + 0xc); + if (piVar1 == (int *)0x0) { + __n = 0xffffffff; + goto out; + } + } + else { + piVar3 = (int *)piVar1[1]; + iVar2 = *piVar1; + *(int **)(iVar2 + 4) = piVar3; + *piVar3 = iVar2; + *(int *)((int)buf + 0x1c) = *(int *)((int)buf + 0x1c) + -1; + } + *(int *)((int)buf + 0x10) = *(int *)((int)buf + 0x10) + 1; + piVar1[2] = __n; + memcpy(piVar1 + 3,(void *)len,__n); + if (in_a3 == 0) { + iVar2 = *(int *)((int)buf + 0x14); + piVar1[1] = (int)buf + 0x14; + *piVar1 = iVar2; + *(int **)(iVar2 + 4) = piVar1; + *(int **)((int)buf + 0x14) = piVar1; + } + else { + ppiVar4 = *(int ***)((int)buf + 0x18); + *piVar1 = (int)buf + 0x14; + *(int ***)(piVar1 + 1) = ppiVar4; + *(int **)((int)buf + 0x18) = piVar1; + *ppiVar4 = piVar1; + } + if (*(int *)((int)buf + 4) != 0) { + *(ushort *)(*(int *)((int)buf + 8) + 6) = *(ushort *)(*(int *)((int)buf + 8) + 6) | 1; + (**(code **)((int)buf + 4)) + (*(undefined4 *)((int)buf + 8),*(undefined4 *)((int)buf + 0xc), + *(code **)((int)buf + 4)); + } +out: + aos_mutex_unlock((aos_mutex_t *)buf); + return __n; +} + + + +int event_ioctl(file_t *f,int cmd,ulong arg) + +{ + ssize_t sVar1; + + if (((cmd & 0xfU) != 1) && ((cmd & 0xfU) != 2)) { + return -1; + } + sVar1 = _event_write(f->f_arg,arg,SUB41(cmd >> 4,0)); + return sVar1; +} + + + +ssize_t event_write(file_t *f,void *buf,size_t len) + +{ + ssize_t sVar1; + + sVar1 = _event_write(f->f_arg,(size_t)buf,SUB41(len,0)); + return sVar1; +} + + + +int event_close(file_t *file) + +{ + aos_mutex_t *mutex; + aos_mutex_t *pv; + void *pvVar1; + void **ppvVar2; + + mutex = (aos_mutex_t *)file->f_arg; + aos_mutex_free(mutex); + while (pv = (aos_mutex_t *)mutex[6].hdl, pv != mutex + 5) { + pvVar1 = pv->hdl; + ppvVar2 = (void **)pv[1].hdl; + *(void ***)((int)pvVar1 + 4) = ppvVar2; + *ppvVar2 = pvVar1; + aos_free(pv); + } + while (pv = (aos_mutex_t *)mutex[9].hdl, pv != mutex + 8) { + pvVar1 = pv->hdl; + ppvVar2 = (void **)pv[1].hdl; + *(void ***)((int)pvVar1 + 4) = ppvVar2; + *ppvVar2 = pvVar1; + aos_free(pv); + } + aos_free(mutex); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling + +ssize_t event_read(file_t *f,void *buf,size_t len) + +{ + aos_mutex_t *mutex; + void *pv; + int iVar1; + int *piVar2; + void **ppvVar3; + uint __n; + + mutex = (aos_mutex_t *)f->f_arg; + __n = (uint)mutex[4].hdl; + if (__n != 0) { + aos_mutex_lock(mutex,0xffffffff); + pv = mutex[6].hdl; + iVar1 = *(int *)pv; + piVar2 = *(int **)((int)pv + 4); + *(int **)(iVar1 + 4) = piVar2; + *piVar2 = iVar1; + __n = *(uint *)((int)pv + 8); + if (len < *(uint *)((int)pv + 8)) { + __n = len; + } + memcpy(buf,(void *)((int)pv + 0xc),__n); + if ((int)mutex[7].hdl < 4) { + ppvVar3 = (void **)mutex[9].hdl; + *(aos_mutex_t **)pv = mutex + 8; + *(void ***)((int)pv + 4) = ppvVar3; + mutex[9].hdl = pv; + *ppvVar3 = pv; + mutex[7].hdl = (void *)((int)mutex[7].hdl + 1); + } + else { + aos_free(pv); + } + mutex[4].hdl = (void *)((int)mutex[4].hdl + -1); + aos_mutex_unlock(mutex); + } + return __n; +} + + + +int vfs_device_init(void) + +{ + int iVar1; + + iVar1 = 0; + if ((inited != 1) && + (iVar1 = aos_register_driver("/dev/event",(file_ops_t *)&event_fops,(void *)0x0), iVar1 == 0)) + { + inited = 1; + } + return iVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void event_read_cb(int fd,void *param) + +{ + dlist_s *pdVar1; + ssize_t sVar2; + undefined auStack32 [4]; + input_event_t event; + + sVar2 = aos_read(fd,auStack32,0x10); + if (sVar2 == 0x10) { + pdVar1 = g_local_event_list.next; + if ((short)event.time == 0x100) { + (*event._4_4_)(event.value,event._4_4_); + } + else { + while (pdVar1 != (dlist_s *)&g_local_event_list) { + if ((*(short *)&((dlist_t *)pdVar1)[2].prev == 0) || + ((short)event.time == *(short *)&((dlist_t *)pdVar1)[2].prev)) { + (*(code *)((dlist_t *)pdVar1)[1].prev) + (auStack32,((dlist_t *)pdVar1)[1].next,((dlist_t *)pdVar1)[1].prev); + } + pdVar1 = ((dlist_t *)pdVar1)->next; + } + } + } + return; +} + + + +int aos_event_service_init(void) + +{ + int sock; + + sock = aos_open("/dev/event",0); + if (local_event.fd < 0) { + local_event.fd = sock; + } + aos_poll_read_fd(sock,event_read_cb,(void *)0x0); + aos_loop_set_eventfd(sock); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int aos_post_event(uint16_t type,uint16_t code,ulong value) + +{ + undefined2 in_register_0000202a; + int iVar1; + undefined4 local_20; + input_event_t event; + + event.time._0_2_ = (ushort)((CONCAT22(in_register_0000202a,type) << 0x11) >> 0x11); + local_20 = 0; + event.value = 0; + event.time._2_2_ = code; + event._4_4_ = value; + iVar1 = aos_ioctl(local_event.fd,(CONCAT22(in_register_0000202a,type) >> 0xf) + 0x101, + (ulong)&local_20); + return iVar1; +} + + + +int aos_register_event_filter(uint16_t type,aos_event_cb *cb,void *priv) + +{ + dlist_s *pdVar1; + int iVar2; + + if (cb != (aos_event_cb *)0x0) { + pdVar1 = (dlist_s *)aos_malloc(0x14); + iVar2 = -0xc; + if (pdVar1 != (dlist_s *)0x0) { + *(aos_event_cb **)&pdVar1[1].prev = cb; + *(uint16_t *)&pdVar1[2].prev = type; + pdVar1->prev = g_local_event_list.prev; + pdVar1[1].next = priv; + *(dlist_t **)&pdVar1->next = &g_local_event_list; + (g_local_event_list.prev)->next = pdVar1; + iVar2 = 0; + g_local_event_list.prev = pdVar1; + } + return iVar2; + } + return -0x16; +} + + + +int at_serial_write(uchar *buf,int len) + +{ + ssize_t sVar1; + + if (-1 < g_at_server.at_serial_fd) { + sVar1 = aos_write(g_at_server.at_serial_fd,buf,len); + return sVar1; + } + printf("[ERROR][AT] AT serial not init\r\n"); + return 0; +} + + + +int at_serial_read(uchar *buf,int size) + +{ + ssize_t sVar1; + + if (-1 < g_at_server.at_serial_fd) { + sVar1 = aos_read(g_at_server.at_serial_fd,buf,size); + return sVar1; + } + printf("[ERROR][AT] AT serial not init\r\n"); + return 0; +} + + + +void at_cmd_exec(void *param) + +{ + at_parse(); + printf("return form at_parse!\r\n"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +// WARNING: Variable defined which should be unmapped: cfg_tmp +// WARNING: Could not reconcile some variable overlaps + +int at_serial_cfg_set(uint32_t baud,uint8_t data_bit,uint8_t stop_bit,uint8_t parity,uint8_t hwfc) + +{ + undefined3 in_register_00002035; + undefined3 in_register_00002039; + int iVar1; + uint32_t uStack32; + UART_CFG_Type cfg_tmp; + + iVar1 = CONCAT31(in_register_00002039,hwfc); + memcpy(&uStack32,&DAT_230c4590,0x10); + uStack32 = 40000000; + cfg_tmp.baudRate._0_1_ = data_bit + 0xfb; + if ((((UART_DataBits_Type)cfg_tmp.baudRate < 4) && + (cfg_tmp.baudRate._1_1_ = stop_bit + ~UART_STOPBITS_1, + cfg_tmp.baudRate._1_1_ < (UART_STOPBITS_1_5|UART_STOPBITS_2))) && + (CONCAT31(in_register_00002035,parity) < 3)) { + if (iVar1 == 1) { + cfg_tmp.baudRate._3_1_ = ENABLE; + } + else { + if (iVar1 != 0) { + if (iVar1 != 2) { + if (iVar1 != 3) { + return 4; + } + cfg_tmp.baudRate._3_1_ = ENABLE; + } + cfg_tmp.stopBits = UART_STOPBITS_1_5; + } + } + cfg_tmp.uartClk = baud; + cfg_tmp.baudRate._2_1_ = parity; + UART_Disable(UART1_ID,UART_TXRX); + UART_Init(UART1_ID,(UART_CFG_Type *)&uStack32); + UART_TxFreeRun(UART1_ID,ENABLE); + UART_Enable(UART1_ID,UART_TXRX); + return 0; + } + return 4; +} + + + +int at_serial_open(void) + +{ + g_at_server.at_serial_fd = aos_open("/dev/ttyS1",0); + return 0; +} + + + +int at_serial_lock(void) + +{ + BaseType_t BVar1; + int iVar2; + + BVar1 = xQueueTakeMutexRecursive((QueueHandle_t)g_at_server.at_serial_mtx,0xffffffff); + iVar2 = 0; + if (BVar1 != 1) { + printf("get send buf mutex failed!\r\n"); + iVar2 = -1; + } + return iVar2; +} + + + +int at_serial_unlock(void) + +{ + BaseType_t BVar1; + int iVar2; + + BVar1 = xQueueGiveMutexRecursive((QueueHandle_t)g_at_server.at_serial_mtx); + iVar2 = 0; + if (BVar1 != 1) { + printf("give send buf mutex failed!\r\n"); + iVar2 = -1; + } + return iVar2; +} + + + +int at_data_output(char *buf,int size) + +{ + int iVar1; + BaseType_t BVar2; + + BVar2 = xQueueTakeMutexRecursive((QueueHandle_t)g_at_server.at_serial_mtx,0xffffffff); + if (BVar2 == 1) { + iVar1 = (*at_callback.dump_cb)((u8 *)buf,size); + xQueueGiveMutexRecursive((QueueHandle_t)g_at_server.at_serial_mtx); + } + else { + printf("get send buf mutex failed!\r\n"); + iVar1 = -1; + } + return iVar1; +} + + + +int at_key_value_set(char *key,void *p_value) + +{ + int iVar1; + char *format; + char acStack84 [4]; + char buf [65]; + + memset(acStack84,0,0x41); + iVar1 = strcmp(key,"wifi_mode"); + if (iVar1 == 0) { + g_at_server.wifi_mode = ZEXT14(*(byte *)p_value); +LAB_2307c51c: + p_value = (void *)(uint)*(byte *)p_value; + format = "%d"; + } + else { + iVar1 = strcmp(key,"wifi_ssid"); + if ((iVar1 != 0) && (iVar1 = strcmp(key,"wifi_pask"), iVar1 != 0)) { + iVar1 = strcmp(key,"wifi_auto"); + if (iVar1 == 0) { + sprintf(acStack84,"%d",(uint)*(byte *)p_value); + if (*(char *)p_value == '\0') { + wifi_mgmr_sta_autoconnect_disable(); + } + else { + wifi_mgmr_sta_autoconnect_enable(); + } + goto LAB_2307c588; + } + iVar1 = strcmp(key,"uart_baud"); + if (iVar1 == 0) { + sprintf(acStack84,"%d",*(undefined4 *)p_value); + g_at_server.uart_baud = *(uint32_t *)p_value; + aos_ioctl(g_at_server.at_serial_fd,3,*(ulong *)p_value); + goto LAB_2307c588; + } + iVar1 = strcmp(key,"ip"); + if ((((iVar1 != 0) && (iVar1 = strcmp(key,"mask"), iVar1 != 0)) && + (iVar1 = strcmp(key,"gw"), iVar1 != 0)) && + ((iVar1 = strcmp(key,"dns1"), iVar1 != 0 && (iVar1 = strcmp(key,"dns2"), iVar1 != 0)))) + goto LAB_2307c51c; + } + format = "%s"; + } + sprintf(acStack84,format,p_value); +LAB_2307c588: + ef_set_env(key,acStack84); + return 0; +} + + + +int at_key_value_get(char *key,void *p_value) + +{ + char *__nptr; + int iVar1; + uint32_t uVar2; + + if (p_value == (void *)0x0) { + return -1; + } + __nptr = ef_get_env(key); + if (__nptr == (char *)0x0) { + iVar1 = strcmp(key,"wifi_mode"); + if (iVar1 == 0) { + *(char *)p_value = (char)g_at_server.wifi_mode; + return 0; + } + iVar1 = strcmp(key,"wifi_pask"); + if (iVar1 == 0) { + *(undefined *)p_value = 0; + return 0; + } + iVar1 = strcmp(key,"uart_baud"); + uVar2 = g_at_server.uart_baud; + if (iVar1 != 0) { + iVar1 = strcmp(key,"databit"); + uVar2 = 8; + if (iVar1 != 0) { + iVar1 = strcmp(key,"stopbit"); + if (iVar1 != 0) { + iVar1 = strcmp(key,"parity"); + if ((iVar1 != 0) && (iVar1 = strcmp(key,"hwfc"), iVar1 != 0)) { + return -1; + } + *(undefined4 *)p_value = 0; + goto LAB_2307c6d8; + } + uVar2 = 1; + } + } + *(uint32_t *)p_value = uVar2; + } + else { + iVar1 = strcmp(key,"wifi_ssid"); + if (((((iVar1 == 0) || (iVar1 = strcmp(key,"wifi_pask"), iVar1 == 0)) || + (iVar1 = strcmp(key,"ip"), iVar1 == 0)) || + ((iVar1 = strcmp(key,"mask"), iVar1 == 0 || (iVar1 = strcmp(key,"gw"), iVar1 == 0)))) || + ((iVar1 = strcmp(key,"dns1"), iVar1 == 0 || (iVar1 = strcmp(key,"dns2"), iVar1 == 0)))) { + strcpy((char *)p_value,__nptr); + } + else { + iVar1 = atoi(__nptr); + *(int *)p_value = iVar1; + } +LAB_2307c6d8: + iVar1 = 0; + } + return iVar1; +} + + + +s32 at_dump_noend(char *format,...) + +{ + BaseType_t BVar1; + char *fmt; + int iVar2; + u8 *pv; + s32 sVar3; + undefined4 in_a1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list vp; + undefined4 uStack28; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack28 = in_a1; + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + BVar1 = xQueueTakeMutexRecursive((QueueHandle_t)g_at_server.at_serial_mtx,0xffffffff); + if (BVar1 == 1) { + iVar2 = vsnprintf((char *)0x0,0,format,&uStack28); + pv = (u8 *)pvPortMalloc(iVar2 + 10U); + if (pv != (u8 *)0x0) { + iVar2 = vsnprintf((char *)pv,iVar2 + 10U,format,&uStack28); + sVar3 = (*at_callback.dump_cb)(pv,iVar2); + xQueueGiveMutexRecursive((QueueHandle_t)g_at_server.at_serial_mtx); + vPortFree(pv); + return sVar3; + } + fmt = "mem not enought\r\n"; + } + else { + fmt = "get send buf mutex failed!\r\n"; + } + printf(fmt); + return -1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void at_async_event(void *param) + +{ + int iVar1; + char *__src; + ip4_addr_t iStack260; + ip4_addr_t ip; + ip4_addr_t gw; + ip4_addr_t mask; + ip4_addr_t dns1; + ip4_addr_t dns2; + char ip_str [20]; + char gw_str [20]; + char mask_str [20]; + _at_evt ev; + char dns1_str [20]; + char acStack116 [4]; + char dns2_str [20]; + +switchD_2307c880_caseD_9: + xQueueReceive(g_at_server.xQueue,mask_str + 0x10,0xffffffff); + iVar1 = ev.ctx_buf._16_4_; + switch(mask_str._16_4_) { + case 1: + at_dump_noend("\r\n"); + __src = "+EVT:0:wifi connected"; + break; + case 2: + at_dump_noend("\r\n"); + __src = "+EVT:1:data in"; + break; + case 3: + at_dump_noend("\r\n"); + __src = "+EVT:2:wifi psk error"; + break; + case 4: + at_dump_noend("\r\n"); + __src = "+EVT:3:wifi no ap found"; + break; + case 5: + at_dump_noend("\r\n"); + __src = "+EVT:4:wifi disconnect"; + break; + case 6: + memset(&ev.ctx_size,0,0x21); + memset(acStack116,0,0x41); + at_key_value_get("wifi_ssid",&ev.ctx_size); + at_key_value_get("wifi_pask",acStack116); + if (iVar1 == 4) { + at_dump_noend("\r\n"); + at_dump_noend("+BLESYNC:OK,%s,%s,%08x",&ev.ctx_size,acStack116,ev.evt_id); + } + else { + at_dump_noend("\r\n"); + at_dump_noend("+BLESYNC:OK,%s,%s",&ev.ctx_size,acStack116); + } + goto LAB_2307c92e; + case 7: + goto switchD_2307c880_caseD_7; + case 8: + at_dump_noend("\r\n"); + __src = "+BLESYNC:DISCONNECT"; + break; + case 9: + iStack260 = (ip4_addr_t)0x0; + ip = 0; + gw = 0; + mask = 0; + dns1 = 0; + wifi_mgmr_sta_ip_get((uint32_t *)&iStack260,(uint32_t *)&ip,(uint32_t *)&gw); + __src = ip4addr_ntoa(&iStack260); + strcpy((char *)&dns2,__src); + __src = ip4addr_ntoa(&ip); + strcpy(ip_str + 0x10,__src); + __src = ip4addr_ntoa(&gw); + strcpy(gw_str + 0x10,__src); + wifi_mgmr_sta_dns_get((uint32_t *)&mask,(uint32_t *)&dns1); + __src = ip4addr_ntoa(&mask); + strcpy((char *)&ev.ctx_size,__src); + __src = ip4addr_ntoa(&dns1); + strcpy(acStack116,__src); + at_dump_noend("\r\n"); + at_dump_noend("+CIPSTA:%s,%s,%s,%s,%s",&dns2,ip_str + 0x10,gw_str + 0x10,&ev.ctx_size,acStack116 + ); + goto LAB_2307c92e; + } + at_dump_noend(__src); + goto LAB_2307c92e; +switchD_2307c880_caseD_7: + if (ev.ctx_buf._16_4_ == 6) { + at_dump_noend("\r\n"); + at_dump_noend("+BLESYNC:CONNECTED,%02x:%02x:%02x:%02x:%02x,%02x",(uint)ev.ctx_buf[1], + (uint)ev.ctx_buf[0],(uint)ev.evt_id >> 0x18,(uint)ev.evt_id >> 0x10 & 0xff, + (uint)ev.evt_id >> 8 & 0xff,ev.evt_id & 0xff); +LAB_2307c92e: + at_dump_noend("\r\n"); + } + goto switchD_2307c880_caseD_9; +} + + + +void at_cmd_init(void) + +{ + int iVar1; + code *pcStack24; + at_callback_t at_cb; + + at_queue_init(g_at_server.queue_buf,0x400,at_serial_read); + pcStack24 = callback; + at_cb.handle_cb = at_serial_write; + at_init((at_callback_t *)&pcStack24); + iVar1 = at_cmd_impl_init(); + if (iVar1 != 0) { + printf("init cmd impl failed\r\n"); + // WARNING: Subroutine does not return + abort(); + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: echo + +int at_server_init(void) + +{ + char *__nptr; + BaseType_t BVar1; + int iVar2; + uint8_t uStack28; + uint8_t uStack27; + uint8_t uStack26; + uint8_t uStack25; + uint8_t data_bit; + uint8_t stop_bit; + uint8_t parity; + uint8_t hwfc; + TaskHandle_t async_handle; + int echo; + + uStack28 = '\b'; + uStack27 = '\x01'; + async_handle = (TaskHandle_t)0x0; + uStack26 = '\0'; + uStack25 = '\0'; + memset(&g_at_server,0,0x414); + at_serial_open(); + if (g_at_server.at_serial_fd < 0) { + printf("open ttyS1 failed!\r\n"); + } + else { + at_key_value_get("uart_echo",&async_handle); + at_cfg.localecho1 = (at_di_t)async_handle; + __nptr = ef_get_env("wifi_mode"); + iVar2 = 0; + if (__nptr != (char *)0x0) { + iVar2 = atoi(__nptr); + } + g_at_server.wifi_mode = iVar2; + __nptr = ef_get_env("uart_baud"); + if (__nptr == (char *)0x0) { + g_at_server.uart_baud = 0x1c200; + } + else { + g_at_server.uart_baud = atoi(__nptr); + } + at_key_value_get("databit",&uStack28); + at_key_value_get("stopbit",&uStack27); + at_key_value_get("parity",&uStack26); + at_key_value_get("hwfc",&uStack25); + iVar2 = at_serial_cfg_set(g_at_server.uart_baud,uStack28,uStack27,uStack26,uStack25); + if (iVar2 != 0) { + return 4; + } + g_at_server.at_serial_mtx = (SemaphoreHandle_t)xQueueCreateMutex('\x04'); + if (g_at_server.at_serial_mtx == (SemaphoreHandle_t)0x0) { + printf("create send buf mutex failed!\r\n"); + } + else { + g_at_server.xQueue = xQueueGenericCreate(4,0x1c,'\0'); + if (g_at_server.xQueue == (QueueHandle_t)0x0) { + printf("create async notify failed\r\n"); + } + else { + at_cmd_init(); + BVar1 = xTaskCreate(at_async_event,"at async",0x100,(void *)0x0,3,(TaskHandle_t *)&data_bit) + ; + if (BVar1 == 1) { + BVar1 = xTaskCreate(at_cmd_exec,"at_server",0x600,(void *)0x0,0,(TaskHandle_t *)0x0); + if (BVar1 == 1) { + printf("at_server start success!\r\n"); + return 0; + } + printf("create at server task failed!\r\n"); + vTaskDelete(_data_bit); + } + else { + printf("create AT notify thread failed!\r\n"); + } + vQueueDelete(g_at_server.xQueue); + } + vQueueDelete((QueueHandle_t)g_at_server.at_serial_mtx); + } + aos_close(g_at_server.at_serial_fd); + } + return -1; +} + + + +// WARNING: Variable defined which should be unmapped: ev + +int at_server_notify_with_ctx(at_evt_t event,void *p_ctx,uint32_t ctx_size) + +{ + undefined3 in_register_00002029; + int iVar1; + undefined4 uStack44; + _at_evt ev; + + uStack44 = CONCAT31(in_register_00002029,event); + memset(&uStack44,0,0x1c); + iVar1 = -1; + if (ctx_size < 0x15) { + ev.ctx_buf._16_4_ = ctx_size; + memcpy(&ev,p_ctx,ctx_size); + iVar1 = xQueueGenericSend(g_at_server.xQueue,&uStack44,0xffffffff,0); + } + return iVar1; +} + + + +int at_server_notify(at_evt_t event) + +{ + int iVar1; + + iVar1 = at_server_notify_with_ctx(event,(void *)0x0,0); + return iVar1; +} + + + +AT_ERROR_CODE cipsta_ip_get(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + char *__src; + ip4_addr_t iStack136; + ip4_addr_t ip; + ip4_addr_t gw; + ip4_addr_t mask; + ip4_addr_t dns1; + ip4_addr_t dns2; + char ip_str [20]; + char gw_str [20]; + char mask_str [20]; + char dns1_str [20]; + char dns2_str [20]; + + iStack136 = (ip4_addr_t)0x0; + ip = 0; + gw = 0; + mask = 0; + dns1 = 0; + wifi_mgmr_sta_ip_get((uint32_t *)&iStack136,(uint32_t *)&ip,(uint32_t *)&gw); + __src = ip4addr_ntoa(&iStack136); + strcpy((char *)&dns2,__src); + __src = ip4addr_ntoa(&ip); + strcpy(ip_str + 0x10,__src); + __src = ip4addr_ntoa(&gw); + strcpy(gw_str + 0x10,__src); + wifi_mgmr_sta_dns_get((uint32_t *)&mask,(uint32_t *)&dns1); + __src = ip4addr_ntoa(&mask); + strcpy(mask_str + 0x10,__src); + __src = ip4addr_ntoa(&dns1); + strcpy(dns1_str + 0x10,__src); + at_dump_noend("\r\n"); + at_dump_noend("+CIPSTA:%s,%s,%s,%s,%s",&dns2,ip_str + 0x10,gw_str + 0x10,mask_str + 0x10, + dns1_str + 0x10); + at_dump_noend("\r\n"); + return AEC_OK; +} + + + +AT_ERROR_CODE version(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + at_dump_noend("\r\n"); + at_dump_noend("+GMR:fw:\"%s-%s\"","a0_final-44-geb7fadd","f76e39a"); + at_dump_noend("\r\n"); + at_dump_noend("\r\n"); + at_dump_noend("+GMR:sdk:\"release_bl_iot_sdk_1.6.11-1-g66bb28da-dirty\""); + at_dump_noend("\r\n"); + at_dump_noend("\r\n"); + at_dump_noend("+GMR:tm:\"%s %s\"",&UNK_230c4c0c,&UNK_230c4c00); + at_dump_noend("\r\n"); + return AEC_OK; +} + + + +// WARNING: Variable defined which should be unmapped: addr_str + +AT_ERROR_CODE cipsta_ip(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + uint32_t uStack56; + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; + char addr_str [20]; + + uStack56 = 0; + ip = 0; + mask = 0; + gw = 0; + dns1 = 0; + dns2 = 0; + wifi_mgmr_sta_ip_get(&uStack56,&mask,&ip); + wifi_mgmr_sta_dns_get(&gw,&dns1); + sprintf((char *)&dns2,"%d.%d.%d.%d",(uint)para->u[0],(uint)para->u[1],(uint)para->u[2], + (uint)para->u[3]); + uStack56 = ipaddr_addr((char *)&dns2); + puts("IP : "); + puts((char *)&dns2); + puts("\r\n"); + if (*(int *)(para->u + 8) != 0) { + sprintf((char *)&dns2,"%d.%d.%d.%d",(uint)para->u[8],(uint)para->u[9],(uint)para->u[10], + (uint)para->u[0xb]); + ip = ipaddr_addr((char *)&dns2); + puts("MASK: "); + puts((char *)&dns2); + puts("\r\n"); + } + if (*(int *)(para->u + 4) != 0) { + sprintf((char *)&dns2,"%d.%d.%d.%d",(uint)para->u[4],(uint)para->u[5],(uint)para->u[6], + (uint)para->u[7]); + mask = ipaddr_addr((char *)&dns2); + puts("GW : "); + puts((char *)&dns2); + puts("\r\n"); + } + if (*(int *)(para->u + 0xc) != 0) { + sprintf((char *)&dns2,"%d.%d.%d.%d",(uint)para->u[0xc],(uint)para->u[0xd],(uint)para->u[0xe], + (uint)para->u[0xf]); + gw = ipaddr_addr((char *)&dns2); + puts("DNS1 : "); + puts((char *)&dns2); + puts("\r\n"); + } + if (*(int *)(para->u + 0x10) != 0) { + sprintf((char *)&dns2,"%d.%d.%d.%d",(uint)para->u[0x10],(uint)para->u[0x11],(uint)para->u[0x12], + (uint)para->u[0x13]); + dns1 = ipaddr_addr((char *)&dns2); + puts("DNS2 : "); + puts((char *)&dns2); + puts("\r\n"); + } + wifi_mgmr_sta_ip_set(uStack56,ip,mask,gw,dns1); + return AEC_OK; +} + + + +// WARNING: Variable defined which should be unmapped: ip_addr + +AT_ERROR_CODE http_url_req(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + httpc_state_t *req; + httpc_connection_t settings; + u16_t port; + byte *__haystack; + AT_ERROR_CODE AVar1; + char *__dest; + char *uri; + char *pcVar2; + int iVar3; + BaseType_t BVar4; + ip_addr_t iStack36; + in_addr_t ip_addr; + + if (g_http_xSemaphore == (SemaphoreHandle_t)0x0) { + g_http_xSemaphore = (SemaphoreHandle_t)xQueueGenericCreate(1,0,'\x03'); + } + __dest = (char *)pvPortMalloc(0x80); + AVar1 = AEC_CMD_FAIL; + if (__dest != (char *)0x0) { + memset((void *)0x4201bec0,0,0x1c); + settings.req_type = para->u[0x80]; + __haystack = para->u; + settings.content_type = para->u[0x81]; + settings.data = *(u8_t **)(para->u + 0x84); + settings.use_proxy = '\0'; + settings.result_fn = cb_httpc_result; + settings.headers_done_fn = cb_httpc_headers_done_fn; + uri = strstr((char *)__haystack,"/"); + if (uri == (char *)0x0) { + uri = "/"; + } + strcpy(__dest,(char *)__haystack); + (uri + -(int)__haystack)[(int)__dest] = '\0'; + pcVar2 = strstr(__dest,":"); + port = 0x50; + if (pcVar2 != (char *)0x0) { + *pcVar2 = '\0'; + iVar3 = atoi(pcVar2 + 1); + port = (u16_t)iVar3; + } + iStack36 = (ip_addr_t)ipaddr_addr(__dest); + if (iStack36 == (ip_addr_t)0xffffffff) { + httpc_get_file_dns(__dest,port,uri,(httpc_connection_t_conflict *)0x4201bec0,cb_altcp_recv_fn, + rsp,(httpc_state_t **)0x4200f6d8); + } + else { + httpc_get_file(&iStack36,port,uri,(httpc_connection_t_conflict *)0x4201bec0,cb_altcp_recv_fn, + rsp,(httpc_state_t **)&ram0x4200f6d8); + } + BVar4 = xQueueSemaphoreTake((QueueHandle_t)g_http_xSemaphore,10000); + if (BVar4 == 1) { + vPortFree(__dest); + AVar1 = AEC_OK; + } + else { + vQueueDelete((QueueHandle_t)g_http_xSemaphore); + g_http_xSemaphore = (SemaphoreHandle_t)0x0; + vPortFree(__dest); + AVar1 = AEC_NETWORK_ERROR; + } + } + return AVar1; +} + + + +err_t cb_altcp_recv_fn(void *arg,altcp_pcb *conn,pbuf *p,err_t err) + +{ + int count; + size_t sVar1; + int iVar2; + uint uVar3; + + iVar2 = count + 1; + uVar3 = count & 0x3f; + count = iVar2; + if (uVar3 == 0) { + puts("\r\n"); + } + altcp_recved(conn,p->tot_len); + if (arg != (void *)0x0) { + if ((*(int *)((int)arg + 8) == 0) && (p->tot_len != 0)) { + at_data_output((char *)p->payload,(uint)p->tot_len); + } + else { + sVar1 = strlen((char *)p->payload); + if (*(uint *)((int)arg + 0xc) < sVar1) { + printf("rsp buffer size not enought\r\n"); + } + else { + if (*(char **)((int)arg + 8) != (char *)0x0) { + strcpy(*(char **)((int)arg + 8),(char *)p->payload); + } + } + } + } + pbuf_free(p); + return '\0'; +} + + + +void cb_httpc_result(void *arg,httpc_result_t httpc_result,u32_t rx_content_len,u32_t srv_res, + err_t err) + +{ + undefined3 in_register_00002039; + + printf("[HTTPC] Transfer finished err %d. rx_content_len is %lu\r\n", + CONCAT31(in_register_00002039,err)); + if (g_http_xSemaphore != (SemaphoreHandle_t)0x0) { + xQueueGenericSend((QueueHandle_t)g_http_xSemaphore,(void *)0x0,0,0); + return; + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: sta_info +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE ap_sta_get(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + byte idx; + char *pcVar1; + byte bStack61; + uint8_t connected; + ip4_addr_t iStack60; + ip4_addr_t ip; + ip4_addr_t gw; + ip4_addr_t mask; + uint8_t mac [6]; + byte bStack38; + byte bStack37; + wifi_sta_basic_info sta_info; + + bStack61 = 0; + iStack60 = (ip4_addr_t)0x0; + ip = 0; + gw = 0; + wifi_mgmr_ap_sta_cnt_get(&bStack61); + wifi_mgmr_ap_ip_get((uint32_t *)&stack0xffffffc4,(uint32_t *)&ip,(uint32_t *)&gw); + wifi_mgmr_ap_mac_get((uint8_t *)&mask); + at_dump_noend("\r\n"); + pcVar1 = ip4addr_ntoa((ip4_addr_t *)&stack0xffffffc4); + at_dump_noend("+SOFTAP:%s,%s,%02x:%02x:%02x:%02x:%02x:%02x\r\n",g_soft_ap_ssid,pcVar1, + (uint)(byte)mask.addr,(uint)mask.addr._1_1_,(uint)mask.addr._2_1_, + (uint)mask.addr._3_1_,(uint)mac[0]); + at_dump_noend("\r\n"); + idx = 0; + while (idx < bStack61) { + wifi_mgmr_ap_sta_info_get((wifi_sta_basic_info *)(mac + 4),idx); + if (mac[5] != '\0') { + at_dump_noend("\r\n"); + at_dump_noend("+STA:%d,%02x:%02x:%02x:%02x:%02x:%02x,%d",(uint)mac[4],(uint)bStack38, + (uint)bStack37,(uint)sta_info.sta_idx,(uint)sta_info.is_used, + (uint)sta_info.sta_mac[0],(uint)sta_info.sta_mac[1]); + at_dump_noend("\r\n"); + } + idx = idx + 1; + } + return AEC_OK; +} + + + +AT_ERROR_CODE cwmode_cur_get(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + at_key_value_get("wifi_mode",para->u); + return AEC_OK; +} + + + +AT_ERROR_CODE uart_get(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + at_key_value_get("uart_baud",para->u + 4); + at_key_value_get("databit",para->u + 8); + at_key_value_get("stopbit",para->u + 0x10); + at_key_value_get("parity",para->u + 0xc); + at_key_value_get("hwfc",para->u + 0x14); + return AEC_OK; +} + + + +AT_ERROR_CODE cwqap(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + wifi_mgmr_sta_disconnect(); + vTaskDelay(1000); + wifi_mgmr_sta_disable((wifi_interface_t *)0x0); + return AEC_OK; +} + + + +AT_ERROR_CODE cwjap_info(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + int iStack208; + int state; + ip4_addr_t ip; + ip4_addr_t gw; + ip4_addr_t mask; + wifi_mgmr_sta_connect_ind_stat_info_t info; + + memset(&mask,0,0xae); + state = 0; + ip = 0; + gw = 0; + wifi_mgmr_state_get(&iStack208); + if (iStack208 - 3U < 2) { + wifi_mgmr_sta_connect_ind_stat_get((wifi_mgmr_sta_connect_ind_stat_info_t *)&mask); + wifi_mgmr_sta_ip_get((uint32_t *)&state,(uint32_t *)&ip,(uint32_t *)&gw); + } + printf("---------------state %d-------------\r\n",iStack208); + at_dump_noend("\r\n"); + ip4addr_ntoa((ip4_addr_t *)&state); + at_dump_noend("+CWJAP:%s,%02x:%02x:%02x:%02x:%02x:%02x,%s",(int)&mask.addr + 3, + (uint)(byte)info.pmk[60],(uint)(byte)info.pmk[61],(uint)(byte)info.pmk[62], + (uint)(byte)info.pmk[63],(uint)info.bssid[0],(uint)info.bssid[1]); + at_dump_noend("\r\n"); + return AEC_OK; +} + + + +AT_ERROR_CODE deep_sleep(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + int iVar1; + AT_ERROR_CODE AVar2; + byte abStack17 [4]; + uint8_t weakup_pin; + + abStack17[0] = para->u[4]; + iVar1 = *(int *)para->u; + AVar2 = AEC_CMD_FAIL; + if ((byte)(abStack17[0] - 7) < 2) { + hal_hbn_init(abStack17,'\x01'); + at_dump_noend("\r\n"); + at_dump_noend("OK"); + at_dump_noend("\r\n"); + vTaskDelay(100); + hal_hbn_enter(iVar1 * 1000); + at_dump_noend("\r\n"); + at_dump_noend("+GSLP:WEAKUP"); + at_dump_noend("\r\n"); + AVar2 = AEC_NO_RESPONSE; + } + return AVar2; +} + + + +AT_ERROR_CODE restory(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + ef_env_set_default(); + return AEC_OK; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE scan(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + byte bVar1; + uint32_t uVar2; + int *piVar3; + int iVar4; + int *pv; + size_t sVar5; + char *pcVar6; + wifi_mgmr_ap_item_t *pwVar7; + int *piVar8; + int iVar9; + int iVar10; + int iVar11; + byte bStack73; + uint8_t opt; + uint32_t uStack72; + uint32_t cnt; + wifi_mgmr_ap_item_t *ap_ary; + + cnt = 0; + bStack73 = 0; + iVar4 = at_key_value_get("scan_opt",&bStack73); + if (iVar4 != 0) { + bStack73 = 0xff; + } + iVar4 = wifi_mgmr_all_ap_scan((wifi_mgmr_ap_item_t **)&cnt,(uint32_t *)&stack0xffffffb8); + if (iVar4 == 0) { + printf("Scan done: %lu ap info\r\n",uStack72); + uVar2 = cnt; + bVar1 = bStack73; + pv = (int *)malloc(uStack72 << 2); + iVar9 = 0; + if (pv == (int *)0x0) { + printf("mem not enought\r\n"); + } + else { + while (iVar9 < (int)uStack72) { + pv[iVar9] = iVar9; + iVar9 = iVar9 + 1; + } + if ((bVar1 >> 5 & 1) != 0) { + iVar9 = 1; + piVar3 = pv; + while (piVar8 = piVar3 + 1, iVar9 < (int)uStack72) { + iVar11 = *piVar8; + pwVar7 = (wifi_mgmr_ap_item_t *)(iVar11 * 0x34 + uVar2); + if (((wifi_mgmr_ap_item_t *)(*piVar3 * 0x34 + uVar2))->rssi < pwVar7->rssi) { + iVar10 = iVar9 + -1; + piVar3 = piVar8; + do { + if (pwVar7->rssi <= ((wifi_mgmr_ap_item_t *)(piVar3[-1] * 0x34 + uVar2))->rssi) break; + *piVar3 = piVar3[-1]; + iVar10 = iVar10 + -1; + piVar3 = piVar3 + -1; + } while (iVar10 != -1); + pv[iVar10 + 1] = iVar11; + } + iVar9 = iVar9 + 1; + piVar3 = piVar8; + } + } + at_serial_lock(); + at_dump_noend("\r\n"); + at_dump_noend("+CWLAP:"); + at_dump_noend("\r\n"); + piVar3 = pv; + while (iVar4 < (int)uStack72) { + sVar5 = strlen((char *)(*piVar3 * 0x34 + uVar2)); + if (sVar5 != 0) { + at_dump_noend("\r\n%02d",iVar4); + if ((bVar1 >> 1 & 1) != 0) { + at_dump_noend(",%s",(wifi_mgmr_ap_item_t *)(*piVar3 * 0x34 + uVar2)); + } + if ((bVar1 >> 3 & 1) != 0) { + pwVar7 = (wifi_mgmr_ap_item_t *)(*piVar3 * 0x34 + uVar2); + at_dump_noend(",%02x:%02x:%02x:%02x:%02x:%02x",(uint)pwVar7->bssid[0], + (uint)pwVar7->bssid[1],(uint)pwVar7->bssid[2],(uint)pwVar7->bssid[3], + (uint)pwVar7->bssid[4],(uint)pwVar7->bssid[5]); + } + if ((bVar1 >> 4 & 1) != 0) { + at_dump_noend(",%02d",(uint)((wifi_mgmr_ap_item_t *)(*piVar3 * 0x34 + uVar2))->channel); + } + if ((bVar1 >> 2 & 1) != 0) { + at_dump_noend(",%02d",(int)((wifi_mgmr_ap_item_t *)(*piVar3 * 0x34 + uVar2))->rssi); + } + if ((bVar1 & 1) != 0) { + pcVar6 = wifi_mgmr_auth_to_str(((wifi_mgmr_ap_item_t *)(*piVar3 * 0x34 + uVar2))->auth); + at_dump_noend(",%s",pcVar6); + } + at_dump_noend("\r\n"); + vTaskDelay(5); + } + iVar4 = iVar4 + 1; + piVar3 = piVar3 + 1; + } + at_serial_unlock(); + free(pv); + } + if ((wifi_mgmr_ap_item_t *)cnt != (wifi_mgmr_ap_item_t *)0x0) { + vPortFree((void *)cnt); + } + } + else { + printf("wifi all ap scan error %d\r\n",iVar4); + } + return AEC_OK; +} + + + +AT_ERROR_CODE reset(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + at_dump_noend("\r\n"); + at_dump_noend("OK"); + at_dump_noend("\r\n"); + vTaskDelay(2); + hal_reboot(); + return AEC_OK; +} + + + +AT_ERROR_CODE ble_sync(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + uint16_t code; + ulong value; + int iVar1; + + iVar1 = *(int *)para->u; + if (iVar1 == 0) { + value = 0; + code = 2; + } + else { + value = 0; + if (iVar1 != 1) { + if (iVar1 != 2) { + return AEC_OK; + } + value = 1; + } + code = 1; + } + aos_post_event(5,code,value); + return AEC_OK; +} + + + +err_t cb_httpc_headers_done_fn + (httpc_state_t *connection,void *arg,pbuf *hdr,u16_t hdr_len,u32_t content_len) + +{ + undefined2 in_register_00002036; + + printf("[HTTPC] hdr_len is %u, content_len is %lu\r\n",CONCAT22(in_register_00002036,hdr_len), + content_len); + printf((char *)hdr->payload); + if ((arg != (void *)0x0) && (*(int *)((int)arg + 8) == 0)) { + at_dump_noend("\r\n"); + at_dump_noend("+HTTPC:%d,",content_len); + } + return '\0'; +} + + + +AT_ERROR_CODE __wifimode_set(int mode) + +{ + memset(g_soft_ap_ssid,0,0x41); + if (mode == 0) { + wifi_mgmr_sta_disconnect(); + vTaskDelay(1000); + wifi_mgmr_sta_disable((wifi_interface_t *)0x0); + wifi_mgmr_ap_stop((wifi_interface_t *)0x0); + } + else { + if (mode == 1) { + wifi_mgmr_sta_disable((wifi_interface_t *)0x0); + wifi_mgmr_ap_stop((wifi_interface_t *)0x0); + g_wifi_interface = wifi_mgmr_sta_enable(); + } + else { + if (mode != 2) { + printf("The mode is not support \r\n"); + return AEC_CMD_ERROR; + } + wifi_mgmr_sta_disconnect(); + vTaskDelay(1000); + wifi_mgmr_sta_disable((wifi_interface_t *)0x0); + wifi_mgmr_ap_stop((wifi_interface_t *)0x0); + g_wifi_interface = wifi_mgmr_ap_enable(); + } + } + return AEC_OK; +} + + + +// WARNING: Variable defined which should be unmapped: wifiMode + +AT_ERROR_CODE set_apcfg(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + byte *ssid; + AT_ERROR_CODE AVar1; + size_t sVar2; + byte *__s; + int iStack20; + int wifiMode; + + at_key_value_get("wifi_mode",&iStack20); + if (iStack20 - 2U < 2) { + __wifimode_set(iStack20); + __s = para->u + 0x40; + sVar2 = strlen((char *)__s); + ssid = para->u; + printf("para->u.apcfgParam.ssid=%s,para->u.apcfgParam.psk=%s\r\n",ssid,__s); + if ((int)sVar2 < 1) { + __s = (byte *)0x0; + } + wifi_mgmr_ap_start((wifi_interface_t *)g_wifi_interface,(char *)ssid,0,(char *)__s,1); + strcpy(g_soft_ap_ssid,(char *)ssid); + AVar1 = AEC_OK; + } + else { + AVar1 = AEC_CMD_FAIL; + } + return AVar1; +} + + + +AT_ERROR_CODE cwjap_cur(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + byte *__src; + byte *__src_00; + AT_ERROR_CODE AVar1; + size_t __n; + uint uStack40; + int wifiMode; + int auto_conn; + + wifiMode = 0; + at_key_value_get("wifi_mode",&uStack40); + if ((uStack40 & 0xfffffffd) == 1) { + __wifimode_set(uStack40); + memset(cur_ssid,0,0x20); + memset(cur_psk,0,0x41); + __src_00 = para->u; + __n = strlen((char *)__src_00); + memcpy(cur_ssid,__src_00,__n); + __src = para->u + 0x21; + __n = strlen((char *)__src); + memcpy(cur_psk,__src,__n); + if (__src_00 == (byte *)0x0) { + printf("The ssid is NULL"); + AVar1 = AEC_CMD_ERROR; + } + else { + wifi_mgmr_sta_connect + ((wifi_interface_t *)g_wifi_interface,(char *)__src_00,(char *)__src,(char *)0x0, + (uint8_t *)0x0,'\0',0); + at_key_value_get("wifi_auto",&wifiMode); + if (wifiMode == 0) { + wifi_mgmr_sta_autoconnect_disable(); + } + else { + wifi_mgmr_sta_autoconnect_enable(); + } + at_key_value_set("wifi_ssid",__src_00); + at_key_value_set("wifi_pask",__src); + AVar1 = AEC_OK; + } + } + else { + AVar1 = AEC_CMD_FAIL; + } + return AVar1; +} + + + +AT_ERROR_CODE cwmode_cur(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + AT_ERROR_CODE AVar1; + int iStack20; + int now_mode; + + if (*(uint *)para->u < 3) { + at_key_value_get("wifi_mode",&iStack20); + AVar1 = AEC_OK; + if (*(int *)para->u != iStack20) { + at_key_value_set("wifi_mode",para->u); + AVar1 = __wifimode_set(*(int *)para->u); + } + } + else { + printf("The mode is not support \r\n"); + AVar1 = AEC_CMD_ERROR; + } + return AVar1; +} + + + +AT_ERROR_CODE uart_set(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + AT_ERROR_CODE AVar1; + int iVar2; + + printf("at_para.baudrate = %d\r\n",*(undefined4 *)(para->u + 4)); + iVar2 = at_serial_cfg_set(*(uint32_t *)(para->u + 4),para->u[8],para->u[0x10],para->u[0xc], + para->u[0x14]); + if (iVar2 == 0) { + at_key_value_set("uart_baud",para->u + 4); + at_key_value_set("databit",para->u + 8); + at_key_value_set("stopbit",para->u + 0x10); + at_key_value_set("parity",para->u + 0xc); + at_key_value_set("hwfc",para->u + 0x14); + AVar1 = AEC_OK; + } + else { + AVar1 = AEC_PARA_ERROR; + } + return AVar1; +} + + + +u32 at_get_errorcode(void) + +{ + return 0; +} + + + +int at_cmd_impl_init(void) + +{ + g_server_sem = (SemaphoreHandle_t)xQueueCreateMutex('\x01'); + g_network_sem = (SemaphoreHandle_t)xQueueCreateMutex('\x01'); + if (g_server_sem != (SemaphoreHandle_t)0x0) { + if (g_network_sem != (SemaphoreHandle_t)0x0) { + return 0; + } + vQueueDelete((QueueHandle_t)g_server_sem); + } + if (g_network_sem != (SemaphoreHandle_t)0x0) { + vQueueDelete((QueueHandle_t)g_network_sem); + } + return -1; +} + + + +AT_ERROR_CODE callback(AT_CALLBACK_CMD cmd,at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + AT_ERROR_CODE AVar1; + undefined3 in_register_00002029; + callback_handler_t *pcVar2; + int iVar3; + + pcVar2 = callback_tbl; + iVar3 = 0; + while (CONCAT31(in_register_00002029,cmd) != pcVar2->cmd) { + iVar3 = iVar3 + 1; + pcVar2 = pcVar2 + 1; + if (iVar3 == 0x1b) { + return AEC_UNSUPPORTED; + } + } + if (callback_tbl[iVar3].handler != + (anon_subr_AT_ERROR_CODE_at_callback_para_t_ptr_at_callback_rsp_t_ptr_for_handler *)0x0) { + // WARNING: Could not recover jumptable at 0x2307da82. Too many branches + // WARNING: Treating indirect jump as call + AVar1 = (*callback_tbl[iVar3].handler)(para,rsp); + return AVar1; + } + return AEC_UNDEFINED; +} + + + +AT_ERROR_CODE wifi_supports(at_para_t *at_para) + +{ + AT_ERROR_CODE AVar1; + undefined3 extraout_var; + + AVar1 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)0x0,0,(s32 *)0x0); + if (CONCAT31(extraout_var,AVar1) != 0) { + AVar1 = AEC_PARA_ERROR; + } + return AVar1; +} + + + +AT_ERROR_CODE attention_handler(at_para_t *at_para) + +{ + AT_ERROR_CODE AVar1; + + AVar1 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)0x0,0,(s32 *)0x0); + return AVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE wifi_mode_handler(at_para_t *at_para) + +{ + AT_ERROR_CODE AVar1; + undefined3 extraout_var; + char *pcVar2; + at_wifiMode_para_t wifiParam; + s32 paracnt; + at_para_descriptor_t cmd_para_list [1]; + + paracnt._0_1_ = APT_DI; + pcVar2 = at_para->ptr; + if (*pcVar2 == '?') { + at_para->ptr = pcVar2 + 1; + AVar1 = at_wifi_mode_get(); + } + else { + if (*pcVar2 == '=') { + at_para->ptr = pcVar2 + 1; + AVar1 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)¶cnt,1, + (s32 *)&wifiParam); + if ((CONCAT31(extraout_var,AVar1) == 0) && (0 < wifiParam)) { + printf("[atcmd WARN] ------>wifi mode = %d \n",0); + AVar1 = at_wifi_mode(0); + return AVar1; + } + } + AVar1 = AEC_PARA_ERROR; + } + return AVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE http_req(at_para_t *at_para) + +{ + at_callback_rsp_t rsp; + AT_ERROR_CODE AVar1; + char *url; + undefined3 extraout_var; + s32 sStack84; + s32 paracnt; + at_para_descriptor_t cmd_para_list [4]; + + url = (char *)malloc(0x202); + AVar1 = AEC_NOT_ENOUGH_MEMORY; + if (url != (char *)0x0) { + paracnt._0_1_ = APT_DI; + AVar1 = AEC_PARA_ERROR; + if (*at_para->ptr == '=') { + at_para->ptr = at_para->ptr + 1; + AVar1 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)¶cnt,4,&sStack84); + if ((((CONCAT31(extraout_var,AVar1) == 0) && (2 < sStack84)) && ((byte)url[0x100] < 2)) && + ((byte)url[0x101] < 4)) { + rsp.status = '\0'; + rsp.vptr = (void *)0x0; + rsp.vsize = 0; + AVar1 = at_http_request(url,url[0x100],url[0x101],(uint8_t *)(url + 0x102), + (at_callback_rsp_t *)0x4201c2e4); + free(url); + } + else { + free(url); + AVar1 = AEC_PARA_ERROR; + } + } + } + return AVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE domain_name_resolution(at_para_t *at_para) + +{ + char "domain_name_resolution" [23]; + u32 *__s; + AT_ERROR_CODE AVar1; + undefined3 extraout_var; + hostent *phVar2; + char *pcVar3; + int iVar4; + s32 sStack304; + s32 paracnt; + at_para_descriptor_t cmd_para_list [1]; + at_hostname_para_t hostParam; + + __s = &cmd_para_list[0].option; + printf("[atcmd WARN] ------>%s\n","domain_name_resolution"); + memset(__s,0,0x100); + cmd_para_list[0].pvar = (void *)0xd00; + paracnt._0_1_ = APT_TEXT; + if (*at_para->ptr == '=') { + at_para->ptr = at_para->ptr + 1; + cmd_para_list[0]._0_4_ = __s; + AVar1 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)¶cnt,1,&sStack304); + if ((CONCAT31(extraout_var,AVar1) == 0) && (0 < sStack304)) { + printf("[atcmd WARN] ------>hostParam = %s \n",__s); + phVar2 = lwip_gethostbyname((char *)__s); + if (phVar2 != (hostent *)0x0) { + iVar4 = 0; + while (phVar2->h_addr_list[iVar4] != (char *)0x0) { + iVar4 = iVar4 + 1; + } + at_dump_noend("\r\n"); + at_dump_noend("+DNSRES:%d",iVar4); + at_dump_noend("\r\n"); + iVar4 = 0; + while (*(int *)((int)phVar2->h_addr_list + iVar4) != 0) { + at_dump_noend("\r\n"); + pcVar3 = ip4addr_ntoa(*(ip4_addr_t **)(iVar4 + (int)phVar2->h_addr_list)); + at_dump_noend("%s",pcVar3); + at_dump_noend("\r\n"); + iVar4 = iVar4 + 4; + } + return AVar1; + } + return AEC_NETWORK_ERROR; + } + } + return AEC_PARA_ERROR; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE base_station_info(at_para_t *at_para) + +{ + AT_ERROR_CODE AVar1; + AT_ERROR_CODE AVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + cJSON *object; + cJSON *pcVar3; + cJSON *pcVar4; + cJSON *pcVar5; + undefined4 uStack48; + at_callback_rsp_t rsp; + + uStack48 = 0; + rsp._0_4_ = 0; + rsp.type = 0; + rsp.vptr = (void *)0x0; + AVar1 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)0x0,0,(s32 *)0x0); + AVar2 = AEC_PARA_ERROR; + if (CONCAT31(extraout_var,AVar1) == 0) { + rsp.type = (s32)malloc(0x80); + rsp.vptr = (void *)0x80; + AVar2 = at_http_request("napi.bouffalolab.com/mygeoip",'\0','\x01',(uint8_t *)0x0, + (at_callback_rsp_t *)&uStack48); + if (CONCAT31(extraout_var_00,AVar2) == 0) { + object = cJSON_Parse((char *)rsp.type); + if (object == (cJSON *)0x0) { + AVar2 = AEC_NETWORK_ERROR; + } + else { + pcVar3 = cJSON_GetObjectItem(object,"error"); + pcVar4 = cJSON_GetObjectItem(object,"ip"); + pcVar5 = cJSON_GetObjectItem(object,"location"); + at_dump_noend("\r\n"); + if (pcVar3 != (cJSON *)0x0) { + pcVar3 = (cJSON *)pcVar3->valuestring; + } + if (pcVar4 != (cJSON *)0x0) { + pcVar4 = (cJSON *)pcVar4->valuestring; + } + if (pcVar5 != (cJSON *)0x0) { + pcVar5 = (cJSON *)pcVar5->valuestring; + } + at_dump_noend("+BASESTA:%s,%s,%s",pcVar3,pcVar4,pcVar5); + at_dump_noend("\r\n"); + free((void *)rsp.type); + cJSON_Delete(object); + } + } + } + return AVar2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE deep_sleep_handler(at_para_t *at_para) + +{ + AT_ERROR_CODE AVar1; + undefined3 extraout_var; + s32 sStack52; + s32 paracnt; + at_gpiowakeup_para_t wakeupParam; + at_para_descriptor_t cmd_para_list [2]; + + wakeupParam.gpioId._0_1_ = 3; + paracnt = 0; + wakeupParam.sleep_time = 0; + if (*at_para->ptr == '=') { + at_para->ptr = at_para->ptr + 1; + AVar1 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)&wakeupParam.gpioId,2, + &sStack52); + if ((CONCAT31(extraout_var,AVar1) == 0) && (0 < sStack52)) { + printf("[atcmd WARN] ------>deep slee time = %d, weakup_pin %d \n",paracnt, + wakeupParam.sleep_time); + AVar1 = at_deep_sleep_mode(paracnt,wakeupParam.sleep_time); + return AVar1; + } + } + return AEC_PARA_ERROR; +} + + + +// WARNING: Removing unreachable block (ram,0x2307df2a) +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE setautoconnect_handler(at_para_t *at_para) + +{ + char cVar1; + char "setautoconnect_handler" [23]; + AT_ERROR_CODE AVar2; + undefined3 extraout_var; + at_autoconnect_para_t autoParam; + s32 paracnt; + int res; + at_para_descriptor_t cmd_para_list [1]; + + printf("[atcmd WARN] ------>%s\n","setautoconnect_handler"); + res._0_1_ = APT_DI; + paracnt = 0; + cVar1 = *at_para->ptr; + if (cVar1 == '?') { + at_key_value_get("wifi_auto",¶cnt); + at_dump_noend("\r\n"); + at_dump_noend("+CWAUTOCONN:%d",paracnt); + at_dump_noend("\r\n"); +LAB_2307dee0: + AVar2 = AEC_OK; + } + else { + if (cVar1 == '=') { + at_para->ptr = at_para->ptr + 1; + AVar2 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)&res,1,(s32 *)&autoParam); + paracnt = CONCAT31(extraout_var,AVar2); + if (paracnt != 0) { + return AEC_OK; + } + if (0 < autoParam) { + printf("[atcmd WARN] ------>autoParam = %d \n",0); + paracnt = 0; + at_key_value_set("wifi_auto",¶cnt); + goto LAB_2307dee0; + } + } + AVar2 = AEC_PARA_ERROR; + } + return AVar2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE scan_handler_opt(at_para_t *at_para) + +{ + char cVar1; + AT_ERROR_CODE AVar2; + int iVar3; + undefined3 extraout_var; + byte bStack49; + undefined2 uStack48; + uint8_t opt; + at_scan_opt_t cmd_para; + s32 paracnt; + at_para_descriptor_t cmd_para_list [2]; + + paracnt._0_1_ = APT_DI; + bStack49 = 0; + uStack48 = 0; + cVar1 = *at_para->ptr; + if (cVar1 == '?') { + iVar3 = at_key_value_get("scan_opt",&bStack49); + if (iVar3 != 0) { + bStack49 = 0xff; + } + at_dump_noend("\r\n"); + at_dump_noend("+CWLAPOPT:%d,%d",(uint)(bStack49 >> 5) & 1,(uint)bStack49 & 0x1f); + at_dump_noend("\r\n"); + AVar2 = AEC_OK; + } + else { + if (cVar1 == '=') { + at_para->ptr = at_para->ptr + 1; + AVar2 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)¶cnt,2,(s32 *)&cmd_para + ); + if ((CONCAT31(extraout_var,AVar2) == 0) && (1 < _cmd_para)) { + bStack49 = uStack48._1_1_ & 0x1f | (char)uStack48 << 5; + iVar3 = at_key_value_set("scan_opt",&bStack49); + return (AT_ERROR_CODE)iVar3; + } + } + AVar2 = AEC_PARA_ERROR; + } + return AVar2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE scan_handler(at_para_t *at_para) + +{ + AT_ERROR_CODE AVar1; + undefined3 extraout_var; + undefined4 *mode; + undefined3 extraout_var_00; + int iVar2; + char *__s1; + undefined4 local_30; + at_scan_para_t cmd_para; + s32 paracnt; + at_para_descriptor_t cmd_para_list [2]; + + mode = &local_30; + __s1 = (char *)((int)&local_30 + 2); + local_30 = 0; + paracnt._0_1_ = APT_TEXT; + if (*at_para->ptr == '=') { + at_para->ptr = at_para->ptr + 1; + AVar1 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)¶cnt,2,(s32 *)&cmd_para); + if ((((CONCAT31(extraout_var_00,AVar1) == 0) && (1 < (int)cmd_para)) && + ((iVar2 = strcmp((char *)&local_30,"a"), iVar2 == 0 || + (iVar2 = strcmp((char *)&local_30,"p"), iVar2 == 0)))) && + (iVar2 = strcmp(__s1,"r"), iVar2 == 0)) goto LAB_2307e066; + } + else { + AVar1 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)0x0,0,(s32 *)0x0); + mode = (undefined4 *)CONCAT31(extraout_var,AVar1); + if (mode == (undefined4 *)0x0) { + __s1 = (char *)0x0; +LAB_2307e066: + AVar1 = at_scan((char *)mode,__s1); + return AVar1; + } + } + return AEC_PARA_ERROR; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE uart_config_handler(at_para_t *at_para) + +{ + char cVar1; + char "uart_config_handler" [20]; + AT_ERROR_CODE AVar2; + undefined3 extraout_var; + s32 sStack104; + s32 paracnt; + at_uart_para_t uartParam; + at_para_descriptor_t cmd_para_list [5]; + + printf("[atcmd WARN] ------>%s\n","uart_config_handler"); + memset(¶cnt,0,0x18); + uartParam.hwfc._0_1_ = 3; + cVar1 = *at_para->ptr; + if (cVar1 == '?') { + AVar2 = at_uart_config_get(); + } + else { + AVar2 = AEC_UNSUPPORTED; + if (cVar1 == '=') { + at_para->ptr = at_para->ptr + 1; + AVar2 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)&uartParam.hwfc,5, + &sStack104); + if ((CONCAT31(extraout_var,AVar2) == 0) && + ((((4 < sStack104 || (uartParam.parity = 0, sStack104 == 4)) || + (uartParam.stop_bits = 0, sStack104 == 3)) || + ((uartParam.data_bits = 1, sStack104 == 2 || (uartParam.baudrate = 8, sStack104 == 1)))))) + { + printf("[atcmd WARN] ------>baudrate = %d \n",uartParam.uart_id); + printf("[atcmd WARN] ------>data_bits = %d \n",uartParam.baudrate); + printf("[atcmd WARN] ------>parity = %d \n",uartParam.stop_bits); + printf("[atcmd WARN] ------>stop_bits = %d \n",uartParam.data_bits); + printf("[atcmd WARN] ------>hwfc = %d \n",uartParam.parity); + AVar2 = at_uart_config(paracnt,uartParam.uart_id,uartParam.baudrate,uartParam.stop_bits, + uartParam.data_bits,uartParam.parity); + } + else { + AVar2 = AEC_PARA_ERROR; + } + } + } + return AVar2; +} + + + +AT_ERROR_CODE reset_handler(at_para_t *at_para) + +{ + AT_ERROR_CODE AVar1; + undefined3 extraout_var; + + AVar1 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)0x0,0,(s32 *)0x0); + if (CONCAT31(extraout_var,AVar1) == 0) { + AVar1 = at_reset(); + return AVar1; + } + return AEC_PARA_ERROR; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE echo_on_handler(at_para_t *at_para) + +{ + char cVar1; + AT_ERROR_CODE AVar2; + undefined3 extraout_var; + int iStack36; + at_echoswitch_para_t echoswitch; + s32 paracnt; + at_para_descriptor_t cmd_para_list [1]; + + printf("[atcmd WARN] ------>%s\n","echo_on_handler"); + paracnt._0_1_ = APT_DI; + iStack36 = 0; + cVar1 = *at_para->ptr; + if (cVar1 == '?') { + at_key_value_get("uart_echo",&echoswitch); + at_dump_noend("\r\n"); + at_dump_noend("+UARTE:%d",echoswitch); + at_dump_noend("\r\n"); + AVar2 = AEC_OK; + } + else { + if (cVar1 == '=') { + at_para->ptr = at_para->ptr + 1; + AVar2 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)¶cnt,1, + (s32 *)&echoswitch); + if (((CONCAT31(extraout_var,AVar2) == 0) && (0 < echoswitch)) && (iStack36 < 2)) { + at_cfg.localecho1 = iStack36; + at_key_value_set("uart_echo",&iStack36); + return AVar2; + } + } + AVar2 = AEC_PARA_ERROR; + } + return AVar2; +} + + + +AT_ERROR_CODE disconnect_handler(at_para_t *at_para) + +{ + printf("[atcmd WARN] ------>%s\n","disconnect_handler"); + if (*at_para->ptr != '=') { + at_disconnect((char *)0x0); + vTaskDelay(200); + } + return AEC_OK; +} + + + +AT_ERROR_CODE restore_handler(at_para_t *at_para) + +{ + AT_ERROR_CODE AVar1; + undefined3 extraout_var; + + AVar1 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)0x0,0,(s32 *)0x0); + if (CONCAT31(extraout_var,AVar1) == 0) { + AVar1 = at_restore((char *)0x0); + return AVar1; + } + return AEC_PARA_ERROR; +} + + + +AT_ERROR_CODE version_handler(at_para_t *at_para) + +{ + AT_ERROR_CODE AVar1; + undefined3 extraout_var; + + AVar1 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)0x0,0,(s32 *)0x0); + if (CONCAT31(extraout_var,AVar1) == 0) { + AVar1 = at_version((char *)0x0); + return AVar1; + } + return AEC_PARA_ERROR; +} + + + +AT_ERROR_CODE at_help(void) + +{ + char **ppcVar1; + char **ppcVar2; + at_command_handler_t *paVar3; + uint uVar4; + + paVar3 = at_command_table; + do { + at_dump_noend("\r\n"); + ppcVar1 = &paVar3->usage; + ppcVar2 = &paVar3->cmd; + paVar3 = paVar3 + 1; + at_dump_noend("# %s%s",*ppcVar2,*ppcVar1); + at_dump_noend("\r\n"); + vTaskDelay(10); + } while (paVar3 != (at_command_handler_t *)"# %s%s"); + uVar4 = 0; + while (uVar4 < g_at_cmd_usr_cnt) { + at_dump_noend("\r\n"); + at_dump_noend("# %s%s",g_at_cmd_handler_usr[uVar4].cmd,g_at_cmd_handler_usr[uVar4].usage); + at_dump_noend("\r\n"); + vTaskDelay(10); + uVar4 = uVar4 + 1; + } + return AEC_OK; +} + + + +AT_ERROR_CODE help_handler(at_para_t *at_para) + +{ + AT_ERROR_CODE AVar1; + undefined3 extraout_var; + + AVar1 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)0x0,0,(s32 *)0x0); + if (CONCAT31(extraout_var,AVar1) == 0) { + AVar1 = at_help(); + return AVar1; + } + return AEC_PARA_ERROR; +} + + + +AT_ERROR_CODE at_init(at_callback_t *cb) + +{ + AT_ERROR_CODE AVar1; + + memset(&at_callback,0,8); + AVar1 = AEC_UNDEFINED; + if (cb != (at_callback_t *)0x0) { + at_callback.handle_cb = cb->handle_cb; + at_callback.dump_cb = cb->dump_cb; + memset(&cache,0,0x408); + AVar1 = AEC_OK; + } + return AVar1; +} + + + +AT_ERROR_CODE at_command_register(at_command_handler_t *cmd,uint32_t cmd_cnt) + +{ + if (cmd != (at_command_handler_t *)0x0) { + g_at_cmd_handler_usr = cmd; + g_at_cmd_usr_cnt = cmd_cnt; + return AEC_OK; + } + return AEC_NULL_POINTER; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE at_parse(void) + +{ + byte bVar1; + u8 *puVar2; + bool bVar3; + uint32_t uVar4; + u32 uVar5; + AT_QUEUE_ERROR_CODE AVar6; + AT_ERROR_CODE AVar7; + undefined3 extraout_var; + TickType_t TVar8; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + uint uVar9; + int iVar10; + at_command_handler_t *paVar11; + anon_subr_AT_ERROR_CODE_at_para_t_ptr_for_handler *paVar12; + u32 uVar13; + at_para_t aVar14; + TickType_t TVar15; + int iVar16; + u8 uStack105; + u8 tmp; + at_para_t aStack104; + at_para_t at_para; + char at_cmd [33]; + + memset(&send_cache,0,0x518); + memset(&cache,0,0x408); + TVar15 = 0; + bVar3 = false; + uVar13 = 0; +LAB_2307e4c8: + do { + while (AVar6 = at_queue_get(&uStack105), CONCAT31(extraout_var,AVar6) != 0) { +LAB_2307e530: + if ((bVar3) && (TVar8 = xTaskGetTickCount(), 10000 < TVar8 - TVar15)) { + memset(&send_cache,0,0x518); + memset(&cache,0,0x408); + at_response(AEC_SEND_TIMEOUT); + bVar3 = false; + } + uVar4 = g_at_cmd_usr_cnt; + paVar11 = g_at_cmd_handler_usr; + if (uVar13 != 0) { + iVar10 = 0; + aVar14 = (at_para_t)cache.buf; + while ((((iVar10 < (int)cache.cnt && (bVar1 = *(byte *)aVar14, (bVar1 & 0xfd) != 0x3d)) && + (bVar1 != 10)) && (bVar1 != 0xd))) { + if (iVar10 == 0x20) goto LAB_2307e69a; + aVar14 = (at_para_t)((int)aVar14 + 1); + *(byte *)((int)&at_para.ptr + iVar10) = bVar1; + iVar10 = iVar10 + 1; + } + *(undefined *)((int)&at_para.ptr + iVar10) = 0; + iVar16 = 1; + if (iVar10 != 0) { + iVar10 = 0; + if (g_at_cmd_handler_usr != (at_command_handler_t *)0x0) { + while (iVar10 < (int)uVar4) { + iVar16 = strcmp((char *)&at_para,paVar11[iVar10].cmd); + if (iVar16 == 0) { + paVar12 = g_at_cmd_handler_usr[iVar10].handler; + goto LAB_2307e71a; + } + iVar10 = iVar10 + 1; + } + } + paVar11 = at_command_table; + iVar10 = 0; +LAB_2307e5b0: + iVar16 = strcmp((char *)&at_para,paVar11->cmd); + if (iVar16 != 0) goto code_r0x2307e5be; + paVar12 = at_command_table[iVar10].handler; +LAB_2307e71a: + if (paVar12 != (anon_subr_AT_ERROR_CODE_at_para_t_ptr_for_handler *)0x0) { + aStack104 = aVar14; + AVar7 = (*paVar12)((at_para_t *)&stack0xffffff98); + iVar16 = CONCAT31(extraout_var_01,AVar7); + goto LAB_2307e69c; + } +LAB_2307e69a: + iVar16 = 3; + } +LAB_2307e69c: + if ((send_cache.status == 1) && (iVar16 != 0x17)) { + memset(&send_cache,0,0x518); + } + at_response((AT_ERROR_CODE)iVar16); + cache.cnt = 0; + uVar13 = 0; + } + } + if (at_cfg.localecho1 != 0) { + (*at_callback.dump_cb)(&uStack105,1); + } + uVar5 = send_cache.status; + if (send_cache.status == 0) { + uVar9 = cache.cnt; + if (uStack105 != '\n') { + if (uStack105 != '\r') goto LAB_2307e516; + puVar2 = cache.buf + cache.cnt; + cache.cnt = cache.cnt + 1; + *puVar2 = '\r'; + AVar6 = at_queue_peek(&uStack105); + if ((CONCAT31(extraout_var_00,AVar6) == 0) && (uStack105 == '\n')) { + at_queue_get(&uStack105); + uVar9 = cache.cnt; + goto joined_r0x2307e5fe; + } +LAB_2307e514: + uVar13 = 1; + goto LAB_2307e516; + } +joined_r0x2307e5fe: + if (uVar9 < 0x400) { + cache.cnt = uVar9 + 1; + cache.buf[uVar9] = uStack105; + goto LAB_2307e514; + } +LAB_2307e670: + cache.cnt = 0; + printf("[atcmd] command is discarded!\n"); + goto LAB_2307e4c8; + } + if (send_cache.status != 1) { +LAB_2307e516: + if (cache.cnt < 0x400) { + puVar2 = cache.buf + cache.cnt; + cache.cnt = cache.cnt + 1; + *puVar2 = uStack105; + goto LAB_2307e530; + } + goto LAB_2307e670; + } + TVar15 = xTaskGetTickCount(); + uVar9 = send_cache.cnt + 1; + puVar2 = send_cache.buf + send_cache.cnt; + send_cache.cnt = uVar9; + *puVar2 = uStack105; + bVar3 = true; + if (uVar9 < send_cache.length) goto LAB_2307e516; + if (0x3ff < uVar9) { + send_cache.cnt = 0; + } + memset(&cache,0,0x408); + memcpy(cache.buf,"AT+CIPSEND=0,1,u,0,u",0x15); + cache.cnt = 0x15; + bVar3 = false; + uVar13 = uVar5; + } while( true ); +code_r0x2307e5be: + iVar10 = iVar10 + 1; + paVar11 = paVar11 + 1; + if (iVar10 == 0x1c) goto LAB_2307e69a; + goto LAB_2307e5b0; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +AT_ERROR_CODE at_callback_do(AT_CALLBACK_CMD cmd,at_callback_para_t *para) + +{ + AT_ERROR_CODE AVar1; + undefined3 in_register_00002029; + + para->cfg = (at_config_t *)0x42027e64; + if (at_callback.handle_cb != + ( + anon_subr_AT_ERROR_CODE_AT_CALLBACK_CMD_at_callback_para_t_ptr_at_callback_rsp_t_ptr_for_handle_cb + *)0x0) { + // WARNING: Could not recover jumptable at 0x2307e746. Too many branches + // WARNING: Treating indirect jump as call + AVar1 = (*at_callback.handle_cb) + ((AT_CALLBACK_CMD)CONCAT31(in_register_00002029,cmd),(at_callback_para_t *)0x0 + ); + return AVar1; + } + return AEC_CMD_FAIL; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE ble_sync_mode(at_para_t *at_para) + +{ + char cVar1; + int mode; + char **__s; + AT_ERROR_CODE AVar2; + undefined3 extraout_var; + int iVar3; + s32 sStack600; + s32 paracnt; + at_para_descriptor_t cmd_para_list [1]; + char *mode_type [3]; + at_getcfg_t sync_mode; + at_callback_para_t para; + + __s = mode_type + 2; + memset(__s,0,0x100); + cmd_para_list[0].pvar = (void *)0xd00; + cmd_para_list[0].option = 0x230b3c04; + mode_type[0] = "start"; + mode_type[1] = "auto"; + paracnt._0_1_ = APT_TEXT; + cVar1 = *at_para->ptr; + cmd_para_list[0]._0_4_ = __s; + if (cVar1 == '?') { + at_dump_noend("\r\n"); + at_dump_noend("+BLESYNCMODE=%s",(&cmd_para_list[0].option)[mode]); + at_dump_noend("\r\n"); + return AEC_OK; + } + if (cVar1 == '=') { + at_para->ptr = at_para->ptr + 1; + AVar2 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)¶cnt,1,&sStack600); + if ((CONCAT31(extraout_var,AVar2) == 0) && (0 < sStack600)) { + iVar3 = strcmp((char *)__s,"stop"); + if (iVar3 == 0) { + para.sts = (at_status_t *)0x0; + } + else { + iVar3 = strcmp((char *)__s,"start"); + para.sts = (at_status_t *)&DAT_00000001; + if (iVar3 != 0) { + iVar3 = strcmp((char *)__s,"auto"); + if (iVar3 != 0) { + return AEC_PARA_ERROR; + } + para.sts = (at_status_t *)0x2; + } + } + mode = (int)para.sts; + AVar2 = at_callback_do(ACC_BLESYNC,(at_callback_para_t *)(sync_mode.key + 0xfc)); + return AVar2; + } + } + return AEC_PARA_ERROR; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE set_ip_handler(at_para_t *at_para) + +{ + char cVar1; + char "set_ip_handler" [15]; + AT_CALLBACK_CMD cmd; + AT_ERROR_CODE AVar2; + undefined3 extraout_var; + s32 sStack364; + s32 paracnt; + at_para_descriptor_t cmd_para_list [5]; + at_callback_para_t para; + + printf("[atcmd WARN] ------>%s\n","set_ip_handler"); + paracnt._0_1_ = APT_IP; + cmd_para_list[0]._0_4_ = ¶.sts; + cmd_para_list[0].option._0_1_ = 5; + cmd_para_list[1]._0_4_ = para.u; + cmd_para_list[1].option._0_1_ = 5; + cmd_para_list[2].option._0_1_ = 5; + cmd_para_list[3].option._0_1_ = 5; + cmd_para_list[4]._0_4_ = para.u + 0xc; + cmd_para_list[2]._0_4_ = para.u + 4; + cmd_para_list[3]._0_4_ = para.u + 8; + cmd_para_list[0].pvar = (void *)0xc04; + cmd_para_list[1].pvar = (void *)0xc04; + cmd_para_list[2].pvar = (void *)0xc04; + cmd_para_list[3].pvar = (void *)0xc04; + cmd_para_list[4].pvar = (void *)0xc04; + cVar1 = *at_para->ptr; + if (cVar1 == '?') { + cmd = ACC_CIPSTA_IP_GET; + } + else { + if (cVar1 != '=') { + return AEC_CMD_ERROR; + } + at_para->ptr = at_para->ptr + 1; + AVar2 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)¶cnt,5,&sStack364); + if (CONCAT31(extraout_var,AVar2) != 0) { + return AEC_PARA_ERROR; + } + if (sStack364 < 1) { + return AEC_PARA_ERROR; + } + cmd = ACC_CIPSTA_IP; + } + AVar2 = at_callback_do(cmd,(at_callback_para_t *)&cmd_para_list[4].option); + return AVar2; +} + + + +AT_ERROR_CODE at_get_ssid_psk(char **ppara,char *ssid,char *pwd) + +{ + char *pcVar1; + char cVar2; + int iVar3; + char *pcVar4; + + pcVar4 = *ppara; + iVar3 = 0; + do { + cVar2 = *pcVar4; + if (cVar2 == '\\') { + pcVar1 = pcVar4 + 1; + iVar3 = iVar3 + 1; + pcVar4 = pcVar4 + 2; + *ssid = *pcVar1; +LAB_2307e94e: + ssid = ssid + 1; + } + else { + if (cVar2 == '\"') { + pcVar4 = pcVar4 + 1; + iVar3 = iVar3 + 1; + } + else { + if (cVar2 != ',') { + if (cVar2 == '\r') { + return AEC_OK; + } + *ssid = cVar2; + pcVar4 = pcVar4 + 1; + goto LAB_2307e94e; + } + pcVar4 = pcVar4 + 1; + iVar3 = iVar3 + 1; + ssid = pwd; + } + } + iVar3 = iVar3 + 1; + if (0x61 < iVar3) { + return AEC_PARA_ERROR; + } + } while( true ); +} + + + +AT_ERROR_CODE ap_cfg_handler(at_para_t *at_para) + +{ + char cVar1; + AT_ERROR_CODE AVar2; + undefined3 extraout_var; + char acStack528 [4]; + at_joinAp_para_t joinParam; + + printf("[atcmd WARN] ------>\n"); + memset(acStack528,0,0x200); + cVar1 = *at_para->ptr; + if (cVar1 == '?') { + AVar2 = at_ap_sta_get(); + } + else { + if (cVar1 == '=') { + at_para->ptr = at_para->ptr + 1; + AVar2 = at_get_ssid_psk((char **)at_para,acStack528,joinParam.ssid + 0xfc); + if (CONCAT31(extraout_var,AVar2) == 0) { + AVar2 = at_set_ap(acStack528,joinParam.ssid + 0xfc,'\0',0); + return AVar2; + } + } + AVar2 = AEC_PARA_ERROR; + } + return AVar2; +} + + + +AT_ERROR_CODE join_ap_handler(at_para_t *at_para) + +{ + char cVar1; + AT_ERROR_CODE AVar2; + AT_ERROR_CODE AVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + u32 uVar4; + char acStack528 [4]; + at_joinAp_para_t joinParam; + + printf("[atcmd WARN] ------>\n"); + memset(acStack528,0,0x200); + cVar1 = *at_para->ptr; + if (cVar1 == '?') { + AVar2 = at_get_apinfo(); + } + else { + if (cVar1 == '=') { + at_para->ptr = at_para->ptr + 1; + AVar3 = at_get_ssid_psk((char **)at_para,acStack528,joinParam.ssid + 0xfc); + AVar2 = AEC_PARA_ERROR; + if (CONCAT31(extraout_var,AVar3) == 0) { + printf("[atcmd WARN] ------> ssid = %s, pwd = %s \n",acStack528,joinParam.ssid + 0xfc); + AVar2 = at_join_ap(acStack528,joinParam.ssid + 0xfc); + if (CONCAT31(extraout_var_00,AVar2) != 0) { + at_dump_noend("\r\n"); + uVar4 = at_get_errorcode(); + at_dump_noend("+CWJAP_CUR:%d",uVar4); + at_dump_noend("\r\n"); + AVar2 = AEC_CMD_FAIL; + } + } + } + else { + at_key_value_get("wifi_ssid",acStack528); + at_key_value_get("wifi_pask",joinParam.ssid + 0xfc); + AVar2 = at_join_ap(acStack528,joinParam.ssid + 0xfc); + } + } + return AVar2; +} + + + +void at_response(AT_ERROR_CODE aec) + +{ + undefined3 in_register_00002029; + uint uVar1; + char *format; + char *format_00; + err_info_t *peVar2; + int iVar3; + + uVar1 = CONCAT31(in_register_00002029,aec); + if (uVar1 == 0x1b) { + return; + } + if (uVar1 == 0) { + at_dump_noend("\r\n"); + format = "OK"; + } + else { + if (uVar1 != 2) { + peVar2 = err_info; + iVar3 = 0; + while ((uint)peVar2->aec != uVar1) { + iVar3 = iVar3 + 1; + peVar2 = peVar2 + 1; + if (iVar3 == 0x18) { + if (uVar1 != 1) { + printf("[atcmd] \r\nno rsp message!\r\n"); + return; + } + return; + } + } + format = err_info[iVar3].info; + if (uVar1 == 0x17) { + at_dump_noend("\r\n"); + format_00 = "%s"; + } + else { + at_dump_noend("\r\n"); + format_00 = "ERROR: %s"; + } + at_dump_noend(format_00,format); + goto LAB_2307eadc; + } + at_dump_noend("\r\n"); + format = "FAIL"; + } + at_dump_noend(format); +LAB_2307eadc: + at_dump_noend("\r\n"); + return; +} + + + +AT_ERROR_CODE at_reset(void) + +{ + if (at_callback.handle_cb != + ( + anon_subr_AT_ERROR_CODE_AT_CALLBACK_CMD_at_callback_para_t_ptr_at_callback_rsp_t_ptr_for_handle_cb + *)0x0) { + (*at_callback.handle_cb)(ACC_RST,(at_callback_para_t *)0x0,(at_callback_rsp_t *)0x0); + return AEC_OK; + } + return AEC_OK; +} + + + +AT_ERROR_CODE at_version(char *version) + +{ + char "at_version" [11]; + at_config_t *paStack300; + at_callback_para_t para; + + printf("[atcmd WARN] ------>%s\n","at_version"); + paStack300 = &at_cfg; + if (at_callback.handle_cb != + ( + anon_subr_AT_ERROR_CODE_AT_CALLBACK_CMD_at_callback_para_t_ptr_at_callback_rsp_t_ptr_for_handle_cb + *)0x0) { + (*at_callback.handle_cb)(ACC_GMR,(at_callback_para_t *)&paStack300,(at_callback_rsp_t *)0x0); + } + return AEC_OK; +} + + + +AT_ERROR_CODE at_restore(char *address) + +{ + char "at_restore" [11]; + at_config_t *paStack300; + at_callback_para_t para; + + printf("[atcmd WARN] ------>%s\n","at_restore"); + paStack300 = &at_cfg; + if (at_callback.handle_cb != + ( + anon_subr_AT_ERROR_CODE_AT_CALLBACK_CMD_at_callback_para_t_ptr_at_callback_rsp_t_ptr_for_handle_cb + *)0x0) { + (*at_callback.handle_cb)(ACC_RESTORE,(at_callback_para_t *)&paStack300,(at_callback_rsp_t *)0x0) + ; + } + return AEC_OK; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE at_uart_config_get(void) + +{ + char "at_uart_config_get" [19]; + AT_ERROR_CODE AVar1; + undefined3 extraout_var; + at_config_t *paStack300; + at_callback_para_t para; + + printf("[atcmd WARN] ------>%s\n","at_uart_config_get"); + paStack300 = &at_cfg; + AVar1 = AEC_UNSUPPORTED; + if (at_callback.handle_cb != + ( + anon_subr_AT_ERROR_CODE_AT_CALLBACK_CMD_at_callback_para_t_ptr_at_callback_rsp_t_ptr_for_handle_cb + *)0x0) { + AVar1 = (*at_callback.handle_cb) + (ACC_UART_GET,(at_callback_para_t *)&paStack300,(at_callback_rsp_t *)0x0); + if (CONCAT31(extraout_var,AVar1) == 0) { + at_dump_noend("\r\n"); + at_dump_noend("+UART_CUR:%d,%d,%d,%d,%d",para.u._0_4_,para.u._4_4_,para.u._12_4_,para.u._8_4_, + para.u._16_4_); + at_dump_noend("\r\n"); + } + } + return AVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE at_uart_config(int uartId,int uartBaud,int dataBit,int parity,int stopBit,int hwfc) + +{ + char "at_uart_config" [15]; + at_config_t *paStack300; + at_callback_para_t para; + + printf("[atcmd WARN] ------>%s\n","at_uart_config"); + paStack300 = &at_cfg; + if (at_callback.handle_cb != + ( + anon_subr_AT_ERROR_CODE_AT_CALLBACK_CMD_at_callback_para_t_ptr_at_callback_rsp_t_ptr_for_handle_cb + *)0x0) { + para.sts = (at_status_t *)uartId; + para.u._0_4_ = uartBaud; + para.u._4_4_ = dataBit; + para.u._8_4_ = parity; + para.u._12_4_ = stopBit; + para.u._16_4_ = hwfc; + (*at_callback.handle_cb) + (ACC_UART_SET,(at_callback_para_t *)&paStack300,(at_callback_rsp_t *)0x0); + } + return AEC_OK; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE at_deep_sleep_mode(uint32_t sleep_time,int weakup_pin) + +{ + char "at_deep_sleep_mode" [19]; + AT_ERROR_CODE AVar1; + at_config_t *paStack300; + at_callback_para_t para; + + printf("[atcmd WARN] ------>%s\n","at_deep_sleep_mode"); + paStack300 = &at_cfg; + AVar1 = AEC_CMD_ERROR; + if (at_callback.handle_cb != + ( + anon_subr_AT_ERROR_CODE_AT_CALLBACK_CMD_at_callback_para_t_ptr_at_callback_rsp_t_ptr_for_handle_cb + *)0x0) { + para.sts = (at_status_t *)sleep_time; + para.u._0_4_ = weakup_pin; + AVar1 = (*at_callback.handle_cb) + (ACC_DEEP_SLEEP,(at_callback_para_t *)&paStack300,(at_callback_rsp_t *)0x0); + } + return AVar1; +} + + + +AT_ERROR_CODE at_wifi_mode(int wifiMode) + +{ + char "at_wifi_mode" [13]; + AT_ERROR_CODE AVar1; + at_config_t *paStack300; + at_callback_para_t para; + + printf("[atcmd WARN] ------>%s\n","at_wifi_mode"); + paStack300 = &at_cfg; + AVar1 = AEC_OK; + if (at_callback.handle_cb != + ( + anon_subr_AT_ERROR_CODE_AT_CALLBACK_CMD_at_callback_para_t_ptr_at_callback_rsp_t_ptr_for_handle_cb + *)0x0) { + para.sts = (at_status_t *)wifiMode; + AVar1 = (*at_callback.handle_cb) + (ACC_CWMODE_CUR,(at_callback_para_t *)&paStack300,(at_callback_rsp_t *)0x0); + } + return AVar1; +} + + + +AT_ERROR_CODE at_wifi_mode_get(void) + +{ + char "at_wifi_mode_get" [17]; + AT_ERROR_CODE AVar1; + undefined3 extraout_var; + at_config_t *paStack300; + at_callback_para_t para; + + printf("[atcmd WARN] ------>%s\n","at_wifi_mode_get"); + paStack300 = &at_cfg; + AVar1 = AEC_OK; + if (at_callback.handle_cb != + ( + anon_subr_AT_ERROR_CODE_AT_CALLBACK_CMD_at_callback_para_t_ptr_at_callback_rsp_t_ptr_for_handle_cb + *)0x0) { + AVar1 = (*at_callback.handle_cb) + (ACC_CWMODE_GET,(at_callback_para_t *)&paStack300,(at_callback_rsp_t *)0x0); + if (CONCAT31(extraout_var,AVar1) == 0) { + at_dump_noend("\r\n"); + at_dump_noend("+CWMODE:%d",para.sts); + at_dump_noend("\r\n"); + } + } + return AVar1; +} + + + +AT_ERROR_CODE at_get_apinfo(void) + +{ + AT_ERROR_CODE AVar1; + + if (at_callback.handle_cb != + ( + anon_subr_AT_ERROR_CODE_AT_CALLBACK_CMD_at_callback_para_t_ptr_at_callback_rsp_t_ptr_for_handle_cb + *)0x0) { + // WARNING: Could not recover jumptable at 0x2307ee46. Too many branches + // WARNING: Treating indirect jump as call + AVar1 = (*at_callback.handle_cb) + (ACC_CWJAP_INFO,(at_callback_para_t *)0x0,(at_callback_rsp_t *)0x0); + return AVar1; + } + return AEC_CMD_FAIL; +} + + + +AT_ERROR_CODE at_join_ap(char *ssid,char *pwd) + +{ + char "at_join_ap" [11]; + AT_ERROR_CODE AVar1; + size_t sVar2; + undefined3 extraout_var; + at_config_t *paStack300; + at_callback_para_t para; + + printf("[atcmd WARN] ------>%s\n","at_join_ap"); + strcpy((char *)¶.sts,ssid); + strcpy((char *)(para.u + 0x1d),pwd); + paStack300 = &at_cfg; + sVar2 = strlen(ssid); + paStack300->wifi_ssid_len = sVar2; + if (sVar2 < 0x21) { + memset(paStack300->wifi_ssid,0,0x21); + memset(paStack300->wifi_wpa_psk_text,0,0x41); + strcpy((char *)paStack300->wifi_ssid,ssid); + strcpy(paStack300->wifi_wpa_psk_text,pwd); + if ((at_callback.handle_cb != + ( + anon_subr_AT_ERROR_CODE_AT_CALLBACK_CMD_at_callback_para_t_ptr_at_callback_rsp_t_ptr_for_handle_cb + *)0x0) && + (AVar1 = (*at_callback.handle_cb) + (ACC_CWJAP_CUR,(at_callback_para_t *)&paStack300,(at_callback_rsp_t *)0x0) + , CONCAT31(extraout_var,AVar1) == 0)) { + return AVar1; + } + AVar1 = AEC_CMD_FAIL; + } + else { + AVar1 = AEC_LIMITED; + } + return AVar1; +} + + + +AT_ERROR_CODE at_disconnect(char *at_para) + +{ + char "at_disconnect" [14]; + at_config_t *paStack300; + at_callback_para_t para; + + printf("[atcmd WARN] ------>%s\n","at_disconnect"); + paStack300 = &at_cfg; + if (at_callback.handle_cb != + ( + anon_subr_AT_ERROR_CODE_AT_CALLBACK_CMD_at_callback_para_t_ptr_at_callback_rsp_t_ptr_for_handle_cb + *)0x0) { + (*at_callback.handle_cb)(ACC_CWQAP,(at_callback_para_t *)&paStack300,(at_callback_rsp_t *)0x0); + } + return AEC_OK; +} + + + +// WARNING: Variable defined which should be unmapped: para +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE at_set_ap(char *ssid,char *psk,char chl,int max_conn) + +{ + char "at_set_ap" [10]; + AT_ERROR_CODE AVar1; + size_t __n; + undefined3 in_register_00002031; + at_config_t *paStack300; + at_callback_para_t para; + + para.u._124_4_ = CONCAT31(in_register_00002031,chl); + printf("[atcmd WARN] ------>%s\n","at_set_ap"); + memset(¶.sts,0,0x40); + memset(para.u + 0x3c,0,0x40); + __n = strlen(ssid); + memcpy(¶.sts,ssid,__n); + __n = strlen(psk); + memcpy(para.u + 0x3c,psk,__n); + paStack300 = &at_cfg; + AVar1 = AEC_CMD_FAIL; + if (at_callback.handle_cb != + ( + anon_subr_AT_ERROR_CODE_AT_CALLBACK_CMD_at_callback_para_t_ptr_at_callback_rsp_t_ptr_for_handle_cb + *)0x0) { + para.u._132_4_ = max_conn; + AVar1 = (*at_callback.handle_cb) + (ACC_APCFG,(at_callback_para_t *)&paStack300,(at_callback_rsp_t *)0x0); + } + return AVar1; +} + + + +AT_ERROR_CODE at_ap_sta_get(void) + +{ + char "at_ap_sta_get" [14]; + at_config_t *paStack300; + at_callback_para_t para; + + printf("[atcmd WARN] ------>%s\n","at_ap_sta_get"); + paStack300 = &at_cfg; + if (at_callback.handle_cb != + ( + anon_subr_AT_ERROR_CODE_AT_CALLBACK_CMD_at_callback_para_t_ptr_at_callback_rsp_t_ptr_for_handle_cb + *)0x0) { + (*at_callback.handle_cb) + (ACC_AP_STA_GET,(at_callback_para_t *)&paStack300,(at_callback_rsp_t *)0x0); + } + return AEC_OK; +} + + + +// WARNING: Variable defined which should be unmapped: para +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE +at_http_request(char *url,uint8_t type,uint8_t content_type,uint8_t *data,at_callback_rsp_t *req_rsp + ) + +{ + char "at_http_request" [16]; + AT_ERROR_CODE AVar1; + at_config_t *paStack300; + at_callback_para_t para; + + printf("[atcmd WARN] ------>%s\n","at_http_request"); + memcpy(¶.sts,url,0x80); + paStack300 = &at_cfg; + AVar1 = AEC_UNSUPPORTED; + if (at_callback.handle_cb != + ( + anon_subr_AT_ERROR_CODE_AT_CALLBACK_CMD_at_callback_para_t_ptr_at_callback_rsp_t_ptr_for_handle_cb + *)0x0) { + para.u[124] = type; + para.u[125] = content_type; + para.u._128_4_ = data; + AVar1 = (*at_callback.handle_cb)(ACC_HTTP_REQ,(at_callback_para_t *)&paStack300,req_rsp); + } + return AVar1; +} + + + +// WARNING: Variable defined which should be unmapped: strbuf + +u32 get_text_para(char **ppara,void *pvar,u32 opt) + +{ + char cVar1; + uint uVar2; + char *pcVar3; + char *pcVar4; + int iVar5; + int iVar6; + uint uVar7; + char local_110 [4]; + char strbuf [256]; + + local_110[0] = '\0'; + iVar5 = 0; + pcVar4 = *ppara; + do { + if ((int)(opt & 0x1ff) <= iVar5) { + uVar2 = 0; + pcVar3 = pcVar4; +LAB_2307f0dc: + iVar6 = 1; +LAB_2307f142: + *ppara = pcVar3; + return iVar6 << 1 | uVar2; + } + cVar1 = *pcVar4; + pcVar3 = pcVar4 + 1; + if (cVar1 == ',') { + uVar7 = 0x400; + uVar2 = 0; +LAB_2307f124: + if ((uVar7 & opt) == 0) goto LAB_2307f0dc; + iVar6 = 1; + if (iVar5 < (int)(opt & 0x1ff)) { + local_110[iVar5] = '\0'; + memcpy(pvar,local_110,iVar5 + 1); + iVar6 = 0; + } + goto LAB_2307f142; + } + if (cVar1 == '\r') { + if (pcVar4[1] == '\n') { + pcVar3 = pcVar4 + 2; + } +LAB_2307f104: + uVar7 = 0x800; + uVar2 = 1; + goto LAB_2307f124; + } + if (cVar1 == '\n') goto LAB_2307f104; + pcVar4 = pcVar3; + if (cVar1 != '\"') { + local_110[iVar5] = cVar1; + iVar5 = iVar5 + 1; + } + } while( true ); +} + + + +// WARNING: Variable defined which should be unmapped: strbuf + +u32 get_tdata_para(char **ppara,void *pvar,u32 opt) + +{ + char cVar1; + uint uVar2; + uint uVar3; + char *pcVar4; + char *pcVar5; + uint uVar6; + int iVar7; + char local_110 [4]; + char strbuf [256]; + + local_110[0] = '\0'; + uVar6 = 0; + pcVar5 = *ppara; + do { + if ((opt & 0x1ff) == uVar6) { + uVar2 = 0; + pcVar4 = pcVar5; +LAB_2307f198: + iVar7 = 1; + uVar3 = uVar2; +LAB_2307f1de: + *ppara = pcVar4; + return iVar7 << 1 | uVar3; + } + cVar1 = *pcVar5; + pcVar4 = pcVar5 + 1; + if (cVar1 == '\r') { + if (pcVar5[1] == '\n') { + pcVar4 = pcVar5 + 2; + } +LAB_2307f1bc: + uVar2 = 1; + uVar3 = 1; + if ((opt & 0x800) == 0) goto LAB_2307f198; + iVar7 = 1; + if ((uVar6 != 0) && ((int)uVar6 < (int)(opt & 0x1ff))) { + local_110[uVar6] = '\0'; + memcpy(pvar,local_110,uVar6 + 1); + iVar7 = 0; + } + goto LAB_2307f1de; + } + if (cVar1 == '\n') goto LAB_2307f1bc; + local_110[uVar6] = cVar1; + uVar6 = uVar6 + 1; + pcVar5 = pcVar4; + } while( true ); +} + + + +u32 get_di_para(char **ppara,void *pvar,u32 opt) + +{ + char cVar1; + char *pcVar2; + int iVar3; + int iVar4; + uint uVar5; + uint uVar6; + char local_120 [4]; + char strbuf [256]; + + pcVar2 = *ppara; + local_120[0] = '\0'; + iVar4 = 0; + do { + cVar1 = *pcVar2; + if (cVar1 == ',') { + pcVar2 = pcVar2 + 1; + uVar5 = 0x400; + uVar6 = 0; +LAB_2307f258: + iVar3 = 0; + if ((((uVar5 & opt) == 0) || (iVar4 == 0)) || (iVar4 == 0xb)) goto LAB_2307f2e8; + local_120[iVar4] = '\0'; + iVar4 = atoi(local_120); + *(int *)pvar = iVar4; + goto LAB_2307f278; + } + if (cVar1 == '\r') { + if (pcVar2[1] == '\n') { + pcVar2 = pcVar2 + 2; + } + else { + pcVar2 = pcVar2 + 1; + } +LAB_2307f2b2: + uVar5 = 0x800; + uVar6 = 1; + goto LAB_2307f258; + } + if ((cVar1 == '\n') || (cVar1 == ':')) { + pcVar2 = pcVar2 + 1; + goto LAB_2307f2b2; + } + if (9 < (byte)(cVar1 - 0x30U)) break; + local_120[iVar4] = cVar1; + iVar4 = iVar4 + 1; + pcVar2 = pcVar2 + 1; + } while (iVar4 != 0xb); + uVar6 = 0; +LAB_2307f2e8: + iVar3 = 1; +LAB_2307f278: + *ppara = pcVar2; + return iVar3 << 1 | uVar6; +} + + + +u32 get_ip_para(char **ppara,void *pvar,u32 opt) + +{ + char cVar1; + char *pcVar2; + int iVar3; + uint uVar4; + uint uVar5; + int iVar6; + char *pcVar7; + int iVar8; + char acStack324 [4]; + char decbuf [4]; + char strbuf [256]; + + pcVar7 = *ppara; + decbuf[0] = '\0'; + iVar3 = 0; + memset(acStack324,0,4); + iVar6 = 0; + do { + cVar1 = *pcVar7; + if (cVar1 == ',') { + pcVar2 = pcVar7 + 1; + uVar4 = 0x400; + uVar5 = 0; +LAB_2307f36c: + iVar8 = 0; + if (((((uVar4 & opt) == 0) || (2 < iVar3 - 1U)) || (uVar4 = atoi(acStack324), 0xff < uVar4)) + || (decbuf[iVar6] = (char)uVar4, iVar6 != 3)) goto LAB_2307f428; + memset(pvar,0,4); + memcpy(pvar,decbuf,4); + goto LAB_2307f42a; + } + if (cVar1 == '\r') { + if (pcVar7[1] == '\n') { + pcVar2 = pcVar7 + 2; + } + else { + pcVar2 = pcVar7 + 1; + } +LAB_2307f3c4: + uVar4 = 0x800; + uVar5 = 1; + goto LAB_2307f36c; + } + if (cVar1 == '\n') { + pcVar2 = pcVar7 + 1; + goto LAB_2307f3c4; + } + if (cVar1 != '\"') { + if (cVar1 == '.') { + uVar5 = iVar3 - 1; + iVar3 = 1; + if ((uVar5 < 3) && (uVar5 = atoi(acStack324), uVar5 < 0x100)) { + decbuf[iVar6] = (char)uVar5; + iVar6 = iVar6 + 1; + iVar3 = 0; + } + memset(acStack324,0,4); + pcVar2 = pcVar7 + 1; + if (iVar3 != 0) break; + } + else { + pcVar2 = pcVar7; + if ((9 < (byte)(cVar1 - 0x30U)) || (2 < iVar3)) break; + acStack324[iVar3] = cVar1; + iVar3 = iVar3 + 1; + } + } + pcVar2 = pcVar7 + 1; + pcVar7 = pcVar2; + } while (iVar6 != 4); + uVar5 = 0; +LAB_2307f428: + iVar8 = 1; +LAB_2307f42a: + *ppara = pcVar2; + return iVar8 << 1 | uVar5; +} + + + +int hex_to_num(char ch) + +{ + undefined3 in_register_00002029; + int iVar1; + int iVar2; + + iVar1 = CONCAT31(in_register_00002029,ch); + if ((iVar1 - 0x30U & 0xff) < 10) { + return iVar1 - 0x30U; + } + if ((iVar1 - 0x41U & 0xff) < 6) { + return iVar1 + -0x37; + } + iVar2 = -1; + if ((iVar1 - 0x61U & 0xff) < 6) { + iVar2 = iVar1 + -0x57; + } + return iVar2; +} + + + +u32 get_hex_para(char **ppara,void *pvar,u32 opt) + +{ + byte bVar1; + byte *pbVar2; + int iVar3; + int iVar4; + int iVar5; + uint uVar6; + uint uVar7; + int iVar8; + byte abStack324 [4]; + char hexbuf [2]; + char strbuf [256]; + + pbVar2 = (byte *)*ppara; + hexbuf[0] = '\0'; + iVar5 = 0; + iVar8 = 0; + while (iVar8 < (int)(opt & 0x1ff)) { + bVar1 = *pbVar2; + if (bVar1 == 0x2c) { + pbVar2 = pbVar2 + 1; +LAB_2307f546: + uVar6 = 0x400; + uVar7 = 0; +LAB_2307f56a: + iVar3 = 0; + if (((uVar6 & opt) == 0) || (iVar5 != 2)) goto LAB_2307f538; + pbVar2 = pbVar2 + 1; + iVar5 = hex_to_num(abStack324[0]); + iVar4 = hex_to_num(abStack324[1]); + hexbuf[iVar8] = (char)(iVar5 << 4) + (char)iVar4; + memset(pvar,0,opt & 0x1ff); + memcpy(pvar,hexbuf,iVar8 + 1); + goto LAB_2307f5ac; + } + if (bVar1 == 0xd) { + if (pbVar2[1] == 10) { + pbVar2 = pbVar2 + 2; + } + else { + pbVar2 = pbVar2 + 1; + } +LAB_2307f566: + uVar6 = 0x800; + uVar7 = 1; + goto LAB_2307f56a; + } + if (bVar1 == 10) { + pbVar2 = pbVar2 + 1; + goto LAB_2307f566; + } + if (bVar1 == 0x3a) goto LAB_2307f546; + if (bVar1 == 0x22) { + pbVar2 = pbVar2 + 1; + } + else { + if (iVar5 < 2) { + if ((9 < (byte)(bVar1 - 0x30)) && (5 < (byte)((bVar1 & 0xdf) + 0xbf))) break; + pbVar2 = pbVar2 + 1; + abStack324[iVar5] = bVar1; + iVar5 = iVar5 + 1; + } + else { + if (iVar5 != 2) break; + iVar5 = hex_to_num(abStack324[0]); + iVar3 = hex_to_num(abStack324[1]); + hexbuf[iVar8] = (char)iVar3 + (char)(iVar5 << 4); + iVar8 = iVar8 + 1; + iVar5 = 0; + } + } + } + uVar7 = 0; +LAB_2307f538: + iVar3 = 1; +LAB_2307f5ac: + *(byte **)ppara = pbVar2; + return iVar3 << 1 | uVar7; +} + + + +u32 get_hi_para(char **ppara,void *pvar,u32 opt) + +{ + byte bVar1; + byte *pbVar2; + int iVar3; + byte *pbVar4; + int iVar5; + uint uVar6; + uint uVar7; + byte local_120 [4]; + char strbuf [256]; + + local_120[0] = 0; + iVar5 = 0; + pbVar4 = (byte *)*ppara; + do { + pbVar2 = pbVar4; + bVar1 = *pbVar2; + if (bVar1 == 0x2c) { + pbVar2 = pbVar2 + 1; + uVar6 = 0x400; + uVar7 = 0; +LAB_2307f6ba: + iVar3 = 0; + if ((((uVar6 & opt) == 0) || (iVar5 == 0)) || (10 < iVar5)) goto LAB_2307f73e; + local_120[iVar5] = 0; + sscanf((char *)local_120,"%x",pvar); + goto LAB_2307f6de; + } + if (bVar1 == 0xd) { + if (pbVar2[1] == 10) { + pbVar2 = pbVar2 + 2; + } + else { + pbVar2 = pbVar2 + 1; + } +LAB_2307f718: + uVar6 = 0x800; + uVar7 = 1; + goto LAB_2307f6ba; + } + if (bVar1 == 10) { + pbVar2 = pbVar2 + 1; + goto LAB_2307f718; + } + if (bVar1 != 0x22) { + if ((9 < (byte)(bVar1 - 0x30)) && (5 < (byte)((bVar1 & 0xdf) + 0xbf))) break; + local_120[iVar5] = bVar1; + iVar5 = iVar5 + 1; + } + pbVar4 = pbVar2 + 1; + pbVar2 = pbVar2 + 1; + } while (iVar5 != 0xb); + uVar7 = 0; +LAB_2307f73e: + iVar3 = 1; +LAB_2307f6de: + *(byte **)ppara = pbVar2; + return iVar3 << 1 | uVar7; +} + + + +AT_ERROR_CODE at_get_newline(char *para,s32 size) + +{ + if ((*para != '\n') && (*para != '\r')) { + return AEC_CMD_ERROR; + } + return AEC_OK; +} + + + +AT_ERROR_CODE at_get_parameters(char **ppara,at_para_descriptor_t *list,s32 lsize,s32 *pcnt) + +{ + int iVar1; + AT_ERROR_CODE AVar2; + uint uVar3; + uint uVar4; + void *pvar; + u32 opt; + int iVar5; + char *pcStack52; + char *para; + + pcStack52 = *ppara; + if ((list == (at_para_descriptor_t *)0x0) || (lsize == 0)) { + AVar2 = at_get_newline(pcStack52,2); + } + else { + iVar5 = 0; + iVar1 = 0; + while (iVar5 < lsize) { + if (APT_IP < list->pt) { + return AEC_PARA_ERROR; + } + opt = list->option; + pvar = list->pvar; + switch(list->pt) { + case APT_TEXT: + uVar4 = get_text_para(&pcStack52,pvar,opt); + break; + case APT_TDATA: + uVar4 = get_tdata_para(&pcStack52,pvar,opt); + break; + case APT_HEX: + uVar4 = get_hex_para(&pcStack52,pvar,opt); + break; + case APT_DI: + uVar4 = get_di_para(&pcStack52,pvar,opt); + break; + case APT_HI: + uVar4 = get_hi_para(&pcStack52,pvar,opt); + break; + case APT_IP: + uVar4 = get_ip_para(&pcStack52,pvar,opt); + } + uVar3 = uVar4 >> 1 & 1; + if (uVar3 == 0) { + iVar1 = iVar1 + 1; + } + if (((uVar4 & 1) != 0) || (list = list + 1, uVar3 != 0)) goto LAB_2307f7c6; + iVar5 = iVar5 + 1; + } + uVar3 = 0; +LAB_2307f7c6: + AVar2 = (AT_ERROR_CODE)(uVar3 << 2); + *ppara = pcStack52; + *pcnt = iVar1; + } + return AVar2; +} + + + +s32 at_queue_init(void *buf,s32 size,at_queue_callback_t *cb) + +{ + if ((buf != (void *)0x0) && (cb != (at_queue_callback_t *)0x0)) { + memset(&at_queue,0,0x14); + at_queue_callback = cb; + at_queue.qbuf = (u8 *)buf; + at_queue.qsize = size; + return 0; + } + return -1; +} + + + +AT_QUEUE_ERROR_CODE at_queue_get(u8 *element) + +{ + s32 sVar1; + int iVar2; + u8 *puVar3; + u8 local_30 [4]; + u8 winbuf [32]; + + if (at_queue.qcnt < 1) { + if ((at_queue_callback == (at_queue_callback_t *)0x0) || + (sVar1 = (*at_queue_callback)(local_30,0x20), sVar1 < 1)) { + return AQEC_EMPTY; + } + iVar2 = 0; + if (at_queue.qsize - at_queue.qcnt < sVar1) { + printf("[atcmd] queue is overflow\n"); + } + else { + do { + puVar3 = at_queue.qbuf + at_queue.widx; + at_queue.widx = at_queue.widx + 1; + *puVar3 = local_30[iVar2]; + if (at_queue.qsize <= at_queue.widx) { + at_queue.widx = 0; + } + iVar2 = iVar2 + 1; + at_queue.qcnt = at_queue.qcnt + 1; + } while (sVar1 != iVar2); + } + } + puVar3 = at_queue.qbuf + at_queue.ridx; + at_queue.ridx = at_queue.ridx + 1; + *element = *puVar3; + if (at_queue.qsize <= at_queue.ridx) { + at_queue.ridx = 0; + } + at_queue.qcnt = at_queue.qcnt + -1; + return AQEC_OK; +} + + + +AT_QUEUE_ERROR_CODE at_queue_peek(u8 *element) + +{ + s32 sVar1; + u8 *puVar2; + int iVar3; + u8 local_30 [4]; + u8 winbuf [32]; + + if (at_queue.qcnt < 1) { + if ((at_queue_callback == (at_queue_callback_t *)0x0) || + (sVar1 = (*at_queue_callback)(local_30,0x20), sVar1 < 1)) { + return AQEC_EMPTY; + } + iVar3 = 0; + if (at_queue.qsize - at_queue.qcnt < sVar1) { + printf("[atcmd] queue is overflow\n"); + } + else { + do { + puVar2 = at_queue.qbuf + at_queue.widx; + at_queue.widx = at_queue.widx + 1; + *puVar2 = local_30[iVar3]; + if (at_queue.qsize <= at_queue.widx) { + at_queue.widx = 0; + } + iVar3 = iVar3 + 1; + at_queue.qcnt = at_queue.qcnt + 1; + } while (sVar1 != iVar3); + } + } + *element = at_queue.qbuf[at_queue.ridx]; + return AQEC_OK; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE create_tcp_udp_handler(at_para_t *at_para) + +{ + char cVar1; + at_para_descriptor_t *paVar2; + char "create_tcp_udp_handler" [23]; + byte *__s1; + AT_CALLBACK_CMD cmd; + AT_ERROR_CODE AVar3; + undefined3 extraout_var; + int iVar4; + undefined3 extraout_var_00; + s32 sStack400; + s32 paracnt; + at_para_descriptor_t cmd_para_type [2]; + at_para_descriptor_t cmd_para_TCP_list [3]; + at_para_descriptor_t cmd_para_UDP_list [3]; + at_callback_para_t param; + + printf("[atcmd WARN] ------>%s\r\n","create_tcp_udp_handler"); + memset(&cmd_para_UDP_list[2].option,0,0x11c); + param.sts = (at_status_t *)0xffffffff; + cmd_para_type[0]._0_4_ = ¶m.sts; + cmd_para_TCP_list[0]._0_4_ = param.u + 4; + cmd_para_TCP_list[1]._0_4_ = param.u + 0x104; + cmd_para_type[0].pvar = (void *)0xc04; + cmd_para_type[1].pvar = (void *)0xc04; + cmd_para_TCP_list[1].pvar = (void *)0xc04; + cmd_para_TCP_list[2]._0_4_ = param.u + 0x10c; + cmd_para_TCP_list[2].pvar = (void *)0xc04; + cmd_para_UDP_list[1].pvar = (void *)0xc04; + cmd_para_UDP_list[2].pvar = (void *)0xc04; + paracnt._0_1_ = APT_DI; + cmd_para_TCP_list[0].pvar = (void *)0xd00; + cmd_para_TCP_list[0].option._0_1_ = 3; + cmd_para_TCP_list[1].option._0_1_ = 3; + cmd_para_UDP_list[0].pvar = (void *)0xd00; + cmd_para_UDP_list[0].option._0_1_ = 3; + cmd_para_UDP_list[1]._0_4_ = param.u + 0x104; + cmd_para_UDP_list[1].option._0_1_ = 3; + __s1 = param.u; + cmd_para_UDP_list[2]._0_4_ = param.u + 0x108; + cmd_para_UDP_list[0]._0_4_ = param.u + 4; + cmd_para_type[0].option._0_1_ = 0; + cmd_para_type[1].option._0_1_ = 0; + cmd_para_TCP_list[2].option._0_1_ = 0; + cVar1 = *at_para->ptr; + cmd_para_type[1]._0_4_ = __s1; + if (cVar1 == '?') { + cmd = ACC_CIPSTATUS; +LAB_2307fa84: + AVar3 = at_callback_do(cmd,(at_callback_para_t *)&cmd_para_UDP_list[2].option); + } + else { + if (cVar1 == '=') { + at_para->ptr = at_para->ptr + 1; + AVar3 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)¶cnt,2,&sStack400); + if ((CONCAT31(extraout_var,AVar3) == 0) && ((int)param.sts < 5)) { + iVar4 = strcmp((char *)__s1,"TCP"); + if ((iVar4 == 0) || (iVar4 = strcmp((char *)__s1,"SSL"), iVar4 == 0)) { + paVar2 = cmd_para_type + 1; + } + else { + iVar4 = strcmp((char *)__s1,"UDP"); + if (iVar4 != 0) goto LAB_2307fa92; + paVar2 = cmd_para_TCP_list + 2; + } + AVar3 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)&paVar2->option,3, + &sStack400); + if (CONCAT31(extraout_var_00,AVar3) == 0) { + printf("[atcmd WARN] ------>networkPara.linkId = %d, \r\n",param.sts); + printf("[atcmd WARN] ------>networkPara.type = %s, \r\n",__s1); + printf("[atcmd WARN] ------>networkPara.hostname = %s \r\n",param.u + 4); + printf("[atcmd WARN] ------>networkPara.port = %d, \r\n",param.u._260_4_); + printf("[atcmd WARN] ------>networkPara.localport = %d, \r\n",param.u._264_4_); + printf("[atcmd WARN] ------>networkPara.keepAlive = %d \r\n",param.u._268_4_); + cmd = ACC_CIPSTART; + goto LAB_2307fa84; + } + } + } +LAB_2307fa92: + AVar3 = AEC_PARA_ERROR; + } + return AVar3; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE close_network_handler(at_para_t *at_para) + +{ + char "close_network_handler" [22]; + AT_ERROR_CODE AVar1; + undefined3 extraout_var; + s32 sStack316; + s32 paracnt; + at_para_descriptor_t cmd_para_list [1]; + at_callback_para_t param; + + printf("[atcmd WARN] ------>%s\r\n","close_network_handler"); + memset(&cmd_para_list[0].option,0,0x11c); + param.sts = (at_status_t *)0xffffffff; + paracnt._0_1_ = APT_DI; + cmd_para_list[0]._0_4_ = ¶m.sts; + cmd_para_list[0].pvar = (void *)0xc04; + if (*at_para->ptr == '=') { + at_para->ptr = at_para->ptr + 1; + AVar1 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)¶cnt,1,&sStack316); + if ((CONCAT31(extraout_var,AVar1) == 0) && (0 < sStack316)) { + printf("[atcmd WARN] ------>closePara.linkId = %d \r\n",param.sts); + AVar1 = at_callback_do(ACC_CIPCLOSE,(at_callback_para_t *)&cmd_para_list[0].option); + return AVar1; + } + } + return AEC_PARA_ERROR; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE send_data_handler(at_para_t *at_para) + +{ + char "send_data_handler" [18]; + byte *__dest; + AT_ERROR_CODE AVar1; + undefined3 extraout_var; + s32 local_160; + s32 paracnt; + at_para_descriptor_t cmd_para_list_single [4]; + at_callback_para_t param; + + printf("[atcmd WARN] ------>%s \r\n","send_data_handler"); + memset(&cmd_para_list_single[3].option,0,0x11c); + param.sts = (at_status_t *)0xffffffff; + cmd_para_list_single[0]._0_4_ = ¶m.sts; + cmd_para_list_single[2].pvar = (void *)0xd00; + cmd_para_list_single[3]._0_4_ = param.u + 0x108; + cmd_para_list_single[1]._0_4_ = param.u; + __dest = param.u + 8; + paracnt._0_1_ = APT_DI; + cmd_para_list_single[0].pvar = (void *)0xc04; + cmd_para_list_single[0].option._0_1_ = 3; + cmd_para_list_single[1].pvar = (void *)0xc04; + cmd_para_list_single[2].option._0_1_ = 3; + cmd_para_list_single[3].pvar = (void *)0xc04; + cmd_para_list_single[1].option._0_1_ = 0; + cmd_para_list_single[2]._0_4_ = __dest; + printf("[atcmd WARN] at_cfg.CIPMUX== %d\r\n",at_cfg.CIPMUX); + if (*at_para->ptr == '=') { + at_para->ptr = at_para->ptr + 1; + AVar1 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)¶cnt,4,&local_160); + if ((CONCAT31(extraout_var,AVar1) == 0) && (1 < local_160)) { + if (send_cache.status != 0) { + param.sts = (at_status_t *)send_cache.linkID; + param.u._0_4_ = send_cache.length; + param.u._4_4_ = 0x42027a5e; + memcpy(__dest,send_cache.hostname,0x100); + param.u._264_4_ = (uint)send_cache.port; + AVar1 = at_callback_do(ACC_CIPSEND,(at_callback_para_t *)&cmd_para_list_single[3].option); + return AVar1; + } + if (((int)param.sts < 5) && ((int)param.u._0_4_ < 0x405)) { + send_cache.status = 1; + send_cache.linkID = (u32)param.sts; + send_cache.length = param.u._0_4_; + send_cache.port = param.u._264_2_; + memcpy(send_cache.hostname,__dest,0x100); + return AEC_SEND_READY; + } + memset(&send_cache,0,0x518); + } + } + return AEC_PARA_ERROR; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE ap_server_handler(at_para_t *at_para) + +{ + AT_ERROR_CODE AVar1; + undefined3 extraout_var; + s32 local_160; + s32 paracnt; + at_para_descriptor_t cmd_para_list [4]; + at_callback_para_t param; + + cmd_para_list[0]._0_4_ = param.u; + cmd_para_list[1]._0_4_ = ¶m.sts; + cmd_para_list[0].pvar = (void *)0xc04; + cmd_para_list[1].pvar = (void *)0xc04; + cmd_para_list[2]._0_4_ = param.u + 4; + cmd_para_list[2].pvar = (void *)0xc04; + cmd_para_list[3].pvar = (void *)0xc04; + cmd_para_list[3]._0_4_ = param.u + 8; + paracnt._0_1_ = APT_DI; + cmd_para_list[0].option._0_1_ = 3; + cmd_para_list[1].option._0_1_ = 3; + cmd_para_list[2].option._0_1_ = 3; + if (*at_para->ptr != '=') { + return AEC_NO_PARA; + } + at_para->ptr = at_para->ptr + 1; + AVar1 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)¶cnt,4,&local_160); + if (CONCAT31(extraout_var,AVar1) != 0) { + return AEC_PARA_ERROR; + } + if (local_160 < 1) { + return AEC_PARA_ERROR; + } + if (local_160 == 2) { +LAB_2307fdac: + param.u._4_4_ = 0; + } + else { + if (local_160 != 3) { + if (local_160 != 1) goto LAB_2307fdb0; + param.sts = (at_status_t *)0x14d; + goto LAB_2307fdac; + } + } + param.u._8_4_ = 0; +LAB_2307fdb0: + printf("cmd_para.port=%d,cmd_para.enable=%d,tls=%d,ca=%d\r\n",param.sts,param.u._0_4_, + param.u._8_4_,param.u._4_4_); + AVar1 = AEC_OUT_OF_RANGE; + if (param.sts < (at_status_t *)0x10000) { + AVar1 = at_callback_do(ACC_TCPSERVER,(at_callback_para_t *)&cmd_para_list[3].option); + } + return AVar1; +} + + + +// WARNING: Variable defined which should be unmapped: param +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE client_ssl_config_path(at_para_t *at_para) + +{ + AT_ERROR_CODE AVar1; + undefined3 extraout_var; + undefined1 *puVar2; + undefined1 *puVar3; + undefined1 *puVar4; + s32 sStack364; + s32 paracnt; + at_para_descriptor_t cmd_para_list [5]; + at_callback_para_t param; + + memset(&cmd_para_list[4].option,0,0x11c); + param.u._4_4_ = (undefined1 *)pvPortMalloc(0x40); + param.u._8_4_ = (undefined1 *)pvPortMalloc(0x40); + cmd_para_list[3]._0_4_ = (undefined1 *)pvPortMalloc(0x40); + param.u._12_4_ = cmd_para_list[3]._0_4_; + if (param.u._4_4_ == (undefined1 *)0x0) { +LAB_2307fe3a: + if (param.u._12_4_ != (undefined1 *)0x0) { + vPortFree(param.u._12_4_); + } + if (param.u._8_4_ != (undefined1 *)0x0) { + vPortFree(param.u._8_4_); + } + return AEC_NOT_ENOUGH_MEMORY; + } + if ((param.u._8_4_ == (undefined1 *)0x0) || (cmd_para_list[3]._0_4_ == (undefined1 *)0x0)) { + vPortFree(param.u._4_4_); + goto LAB_2307fe3a; + } + cmd_para_list[0]._0_4_ = ¶m.sts; + cmd_para_list[0].pvar = (void *)0x404; + cmd_para_list[1]._0_4_ = param.u; + cmd_para_list[1].pvar = (void *)0xc04; + cmd_para_list[4].pvar = (void *)0x840; + paracnt._0_1_ = APT_DI; + cmd_para_list[0].option._0_1_ = 3; + cmd_para_list[1].option._0_1_ = 0; + cmd_para_list[2]._0_4_ = param.u._4_4_; + cmd_para_list[2].pvar = (void *)0xc40; + cmd_para_list[2].option._0_1_ = 0; + cmd_para_list[3].pvar = (void *)0xc40; + cmd_para_list[3].option._0_1_ = 0; + cmd_para_list[4]._0_4_ = param.u._8_4_; + if (*at_para->ptr != '=') { + return AEC_NO_PARA; + } + at_para->ptr = at_para->ptr + 1; + AVar1 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)¶cnt,5,&sStack364); + if (CONCAT31(extraout_var,AVar1) != 0) { + return AEC_PARA_ERROR; + } + if (sStack364 < 2) { + return AEC_PARA_ERROR; + } + if (param.u._0_4_ == 1) { + if (sStack364 < 5) goto ERR_RET; + vPortFree(param.u._4_4_); + } + else { + if (1 < param.u._0_4_) { + if (param.u._0_4_ == 2) { + if (sStack364 != 2) { + vPortFree(param.u._12_4_); + vPortFree(param.u._8_4_); + param.u._12_4_ = (undefined1 *)0x0; + param.u._8_4_ = (undefined1 *)0x0; + goto LAB_2307ff0a; + } +ERR_RET: + if (param.u._4_4_ != (undefined1 *)0x0) { + vPortFree(param.u._4_4_); + } + if (param.u._12_4_ != (undefined1 *)0x0) { + vPortFree(param.u._12_4_); + } + if (param.u._8_4_ != (undefined1 *)0x0) { + vPortFree(param.u._8_4_); + } + return AEC_PARA_ERROR; + } + if ((param.u._0_4_ != 3) || (sStack364 < 5)) goto ERR_RET; + goto LAB_2307ff0a; + } + if (param.u._0_4_ != 0) goto ERR_RET; + vPortFree(param.u._12_4_); + vPortFree(param.u._8_4_); + vPortFree(param.u._4_4_); + param.u._12_4_ = (undefined1 *)0x0; + param.u._8_4_ = (undefined1 *)0x0; + } + param.u._4_4_ = (undefined1 *)0x0; +LAB_2307ff0a: + puVar2 = param.u._4_4_; + if (param.u._4_4_ == (undefined1 *)0x0) { + puVar2 = &DAT_230c6dbc; + } + puVar3 = param.u._12_4_; + if (param.u._12_4_ == (undefined1 *)0x0) { + puVar3 = &DAT_230c6dbc; + } + puVar4 = param.u._8_4_; + if (param.u._8_4_ == (undefined1 *)0x0) { + puVar4 = &DAT_230c6dbc; + } + printf("auth_mode=%d,ca=%s,cert=%s,key=%s\r\n",param.u._0_4_,puVar2,puVar3,puVar4); + AVar1 = at_callback_do(ACC_CIPSSLCCONF_P,(at_callback_para_t *)&cmd_para_list[4].option); + return AVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE client_ssl_set_sni(at_para_t *at_para) + +{ + byte *__s; + AT_ERROR_CODE AVar1; + AT_ERROR_CODE AVar2; + undefined3 extraout_var; + size_t sVar3; + s32 local_148; + s32 paracnt; + at_para_descriptor_t cmd_para_list [2]; + at_callback_para_t param; + + memset(&cmd_para_list[1].option,0,0x11c); + paracnt._0_1_ = APT_DI; + cmd_para_list[0]._0_4_ = ¶m.sts; + cmd_para_list[0].pvar = (void *)0x404; + cmd_para_list[1].pvar = (void *)0xd00; + __s = param.u; + cmd_para_list[0].option._0_1_ = 0; + if (*at_para->ptr == '=') { + at_para->ptr = at_para->ptr + 1; + cmd_para_list[1]._0_4_ = __s; + AVar1 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)¶cnt,2,&local_148); + AVar2 = AEC_PARA_ERROR; + if ((CONCAT31(extraout_var,AVar1) == 0) && (1 < local_148)) { + sVar3 = strlen((char *)__s); + printf("linkid=%d, sni=%s,%d\r\n",param.sts,__s,sVar3); + AVar2 = at_callback_do(ACC_CIPSSLCSNI,(at_callback_para_t *)&cmd_para_list[1].option); + } + } + else { + AVar2 = AEC_NO_PARA; + } + return AVar2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +AT_ERROR_CODE client_ssl_set_alpn(at_para_t *at_para) + +{ + char cVar1; + undefined4 *puVar2; + int iVar3; + undefined4 *__dest; + AT_ERROR_CODE AVar4; + AT_ERROR_CODE AVar5; + undefined3 extraout_var; + size_t sVar6; + char *__s; + s32 sStack332; + s32 paracnt; + at_para_descriptor_t cmd_para_list [1]; + at_callback_para_t param; + + memset(&cmd_para_list[0].option,0,0x11c); + paracnt._0_1_ = APT_DI; + cmd_para_list[0]._0_4_ = ¶m.sts; + cmd_para_list[0].pvar = (void *)0xc04; + if (*at_para->ptr == '=') { + at_para->ptr = at_para->ptr + 1; + AVar4 = at_get_parameters((char **)at_para,(at_para_descriptor_t *)¶cnt,1,&sStack332); + AVar5 = AEC_PARA_ERROR; + if ((CONCAT31(extraout_var,AVar4) == 0) && (0 < sStack332)) { + __s = at_para->ptr; + if ((*__s == '\r') || (iVar3 = 0, *__s == '\n')) { + param.u._0_4_ = (undefined4 *)0x0; + printf("clear alpn param\r\n"); + } + else { + while ((cVar1 = *__s, cVar1 != '\r' && (cVar1 != '\n'))) { + if (cVar1 == ',') { + iVar3 = iVar3 + 1; + } + __s = __s + 1; + } + *__s = '\0'; + sVar6 = strlen(at_para->ptr); + param.u._0_4_ = (undefined4 *)pvPortMalloc(sVar6 + 1 + (iVar3 + 2) * 4); + if (param.u._0_4_ == (undefined4 *)0x0) { + return AEC_NOT_ENOUGH_MEMORY; + } + param.u._0_4_[iVar3 + 1] = 0; + __s = at_para->ptr; + __dest = param.u._0_4_ + iVar3 + 2; + sVar6 = strlen(__s); + memcpy(__dest,__s,sVar6 + 1); + *(undefined4 **)param.u._0_4_ = __dest; + iVar3 = 1; + while( true ) { + puVar2 = __dest; + __dest = (undefined4 *)((int)puVar2 + 1); + if (*(char *)puVar2 == '\0') break; + if (*(char *)puVar2 == ',') { + *(undefined *)puVar2 = 0; + *(undefined4 **)(param.u._0_4_ + iVar3) = __dest; + iVar3 = iVar3 + 1; + } + } + iVar3 = 0; + while (__s = (char *)param.u._0_4_[iVar3], __s != (char *)0x0) { + printf("alpn %d: %s\r\n",iVar3,__s); + if (*__s == '\0') { + printf("bad alpn parameter!\r\n"); + vPortFree(param.u._0_4_); + return AEC_PARA_ERROR; + } + iVar3 = iVar3 + 1; + } + __s = at_para->ptr; + sVar6 = strlen(__s); + printf("linkid=%d, alpn=%s,%d\r\n",param.sts,__s,sVar6); + } + AVar5 = at_callback_do(ACC_CIPSSLCALPN,(at_callback_para_t *)&cmd_para_list[0].option); + } + } + else { + AVar5 = AEC_NO_PARA; + } + return AVar5; +} + + + +AT_ERROR_CODE at_scan(char *mode,char *repeat) + +{ + int iVar1; + at_config_t *paStack300; + at_callback_para_t para; + + if (mode == (char *)0x0) { + if (repeat == (char *)0x0) { + para.sts = (at_status_t *)0x0; +LAB_230801e8: + paStack300 = &at_cfg; + if (at_callback.handle_cb == + ( + anon_subr_AT_ERROR_CODE_AT_CALLBACK_CMD_at_callback_para_t_ptr_at_callback_rsp_t_ptr_for_handle_cb + *)0x0) { + return AEC_OK; + } + (*at_callback.handle_cb)(ACC_SCAN,(at_callback_para_t *)&paStack300,(at_callback_rsp_t *)0x0); + return AEC_OK; + } + } + else { + if (repeat != (char *)0x0) { + iVar1 = strcmp(mode,"a"); + if (iVar1 == 0) { + iVar1 = strcmp(repeat,"r"); + para.sts = (at_status_t *)&DAT_00000001; + if (iVar1 == 0) goto LAB_230801e8; + } + iVar1 = strcmp(mode,"p"); + if ((iVar1 == 0) && (iVar1 = strcmp(repeat,"r"), iVar1 == 0)) { + para.sts = (at_status_t *)0x2; + goto LAB_230801e8; + } + } + } + return AEC_PARA_ERROR; +} + + + +err_t tcp_sent_callback(void *arg,altcp_pcb *conn,u16_t len) + +{ + char "tcp_sent_callback" [18]; + err_t eVar1; + altcp_pcb *extraout_a1; + undefined2 in_register_00002032; + char *pcVar2; + + pcVar2 = (char *)CONCAT22(in_register_00002032,len); + if (4 < (int)arg) { + pcVar2 = "tcp_sent_callback"; + arg = (void *)__assert_func( + "/home/rjwang/work/bl_iot_sdk.release/components/stage/atcmd/at_bl602/bl_socket.c" + ,0xaa,"linkId < AT_MAX_PEER_NUM"); + conn = extraout_a1; + } + vTaskEnterCritical(conn); + if (networks.connect[(int)arg].status == SOCK_CLIENT_CONNECTED) { + vTaskExitCritical(); + if (networks.connect[(int)arg].protocol == SOCK_TYPE_TLS) { + cipsend_totlen = 0; + at_dump_noend("\r\n"); + at_dump_noend("+IPS:%d,SEND DONE\n",arg); + at_dump_noend("\r\n"); + eVar1 = '\0'; + } + else { + printf("linkId %d peer acknowlege %d\r\n",arg,pcVar2); + cipsend_totlen = cipsend_totlen - (int)pcVar2; + eVar1 = '\0'; + if (cipsend_totlen < 1) { + at_dump_noend("\r\n"); + at_dump_noend("+IPS:%d,SEND DONE\n",arg); + at_dump_noend("\r\n"); + } + } + } + else { + vTaskExitCritical(); + printf("linkId %d connection status error!\r\n",arg); + eVar1 = -0xb; + } + return eVar1; +} + + + +err_t tcp_connected_callback(void *arg,altcp_pcb *conn,err_t err) + +{ + socket_type sVar1; + char "tcp_connected_callback" [23]; + mbedtls_ssl_context *ssl; + char *pcVar2; + altcp_pcb *conn_00; + undefined4 uVar3; + altcp_pcb *extraout_a1; + undefined3 in_register_00002031; + char *pcVar4; + + pcVar2 = (char *)CONCAT31(in_register_00002031,err); + if ((int)arg < 5) goto LAB_23080382; + pcVar4 = "linkId < AT_MAX_PEER_NUM"; + uVar3 = 0xd7; + while( true ) { + pcVar2 = "tcp_connected_callback"; + arg = (void *)__assert_func( + "/home/rjwang/work/bl_iot_sdk.release/components/stage/atcmd/at_bl602/bl_socket.c" + ,uVar3,pcVar4); + conn = extraout_a1; +LAB_23080382: + if (pcVar2 != (char *)0x0) { + at_dump_noend("\r\n"); + at_dump_noend("+IPS:%d,FAILED",arg); + at_dump_noend("\r\n"); + xQueueSemaphoreTake((QueueHandle_t)g_network_sem,0xffffffff); + conn_00 = *(altcp_pcb **)&networks.connect[(int)arg].pcb; + networks.connect[(int)arg].status = SOCK_IDLE_CLOSE; + altcp_close(conn_00); + sVar1 = networks.connect[(int)arg].protocol; + *(undefined4 *)&networks.connect[(int)arg].pcb = 0; + if (sVar1 == SOCK_TYPE_TLS) { + altcp_tls_free_config(*(altcp_tls_config **)((int)&networks.connect[(int)arg].pcb + 4)); + *(undefined4 *)((int)&networks.connect[(int)arg].pcb + 4) = 0; + } + goto LAB_23080422; + } + xQueueSemaphoreTake((QueueHandle_t)g_network_sem,0xffffffff); + sVar1 = networks.connect[(int)arg].protocol; + networks.connect[(int)arg].status = SOCK_CLIENT_CONNECTED; + if (sVar1 != SOCK_TYPE_TLS) goto LAB_23080442; + ssl = (mbedtls_ssl_context *)altcp_tls_context(*(altcp_pcb **)&networks.connect[(int)arg].pcb); + if (ssl != (mbedtls_ssl_context *)0x0) break; + pcVar4 = "ssl_context != NULL"; + uVar3 = 0xe0; + } + pcVar2 = mbedtls_ssl_get_alpn_protocol(ssl); + if (pcVar2 == (char *)0x0) { +LAB_23080442: + at_dump_noend("\r\n"); + at_dump_noend("+IPS:%d,CONNECTED",arg); + } + else { + at_dump_noend("\r\n"); + at_dump_noend("+IPS:%d,CONNECTED,%s",arg,pcVar2); + } + at_dump_noend("\r\n"); + altcp_recv(conn,tcp_receive_callback); + altcp_sent(conn,tcp_sent_callback); +LAB_23080422: + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + return '\0'; +} + + + +err_t tcp_receive_callback(void *arg,altcp_pcb *conn,pbuf *p,err_t err) + +{ + socket_type sVar1; + char "tcp_receive_callback" [21]; + pbuf *ppVar2; + err_t eVar3; + char *pcVar4; + + if (4 < (int)arg) { + pcVar4 = "tcp_receive_callback"; + arg = (void *)__assert_func( + "/home/rjwang/work/bl_iot_sdk.release/components/stage/atcmd/at_bl602/bl_socket.c" + ,0x82,"linkId < AT_MAX_PEER_NUM"); + p = (pbuf *)pcVar4; + } + xQueueSemaphoreTake((QueueHandle_t)g_network_sem,0xffffffff); + if (networks.connect[(int)arg].status == SOCK_CLIENT_CONNECTED) { + if (p == (pbuf *)0x0) { + networks.connect[(int)arg].status = SOCK_IDLE_CLOSE; + at_dump_noend("\r\n"); + at_dump_noend("+IPS:%d,CLOSED",arg); + at_dump_noend("\r\n"); + altcp_close(*(altcp_pcb **)&networks.connect[(int)arg].pcb); + sVar1 = networks.connect[(int)arg].protocol; + *(undefined4 *)&networks.connect[(int)arg].pcb = 0; + if (sVar1 == SOCK_TYPE_TLS) { + altcp_tls_free_config(*(altcp_tls_config **)((int)&networks.connect[(int)arg].pcb + 4)); + *(undefined4 *)((int)&networks.connect[(int)arg].pcb + 4) = 0; + } + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + } + else { + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + at_serial_lock(); + at_dump_noend("\r\n"); + at_dump_noend("+IPD:"); + at_dump_noend("\r\n"); + at_dump_noend("\r\n"); + at_dump_noend("%d,%d\r\n",arg,(uint)p->tot_len); + at_dump_noend("\r\n"); + ppVar2 = p; + do { + at_data_output((char *)ppVar2->payload,(uint)ppVar2->len); + ppVar2 = ppVar2->next; + } while (ppVar2 != (pbuf *)0x0); + at_serial_unlock(); + altcp_recved(*(altcp_pcb **)&networks.connect[(int)arg].pcb,p->tot_len); + pbuf_free(p); + } + eVar3 = '\0'; + } + else { + printf("linkId %d connection status error!\r\n",arg); + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + eVar3 = -0xb; + } + return eVar3; +} + + + +int get_romfs_file_content(char *path,romfs_filebuf_t *buf) + +{ + int fd; + + fd = aos_open(path,0); + if (fd < 0) { + fd = -1; + } + else { + aos_ioctl(fd,1,(ulong)buf); + aos_close(fd); + fd = 0; + } + return fd; +} + + + +void udp_send_data(void *arg) + +{ + char "udp_send_data" [14]; + err_t eVar1; + pbuf *p; + undefined3 extraout_var; + undefined4 uVar2; + char *format; + int iVar3; + + if (arg != (void *)0x0) goto LAB_23080686; + format = "arg != NULL"; + uVar2 = 0x2b6; + while( true ) { + arg = (void *)__assert_func( + "/home/rjwang/work/bl_iot_sdk.release/components/stage/atcmd/at_bl602/bl_socket.c" + ,uVar2,"udp_send_data",format); +LAB_23080686: + if (((int *)arg)[1] != 0) break; + format = "ctx->buf != NULL"; + uVar2 = 0x2ba; + } + vTaskEnterCritical(); + iVar3 = *(int *)arg; + if ((networks.connect[iVar3].protocol == SOCK_TYPE_UDP) && + (networks.connect[iVar3].status != SOCK_IDLE_CLOSE)) { + vTaskExitCritical(); + p = pbuf_alloc(PBUF_TRANSPORT,(u16_t)cipsend_totlen,PBUF_RAM); + if (p != (pbuf *)0x0) { + memcpy(p->payload,(void *)((int *)arg)[1],cipsend_totlen); + eVar1 = udp_send(*(udp_pcb **)&networks.connect[iVar3].pcb,p); + if (CONCAT31(extraout_var,eVar1) == 0) { + at_dump_noend("\r\n"); + iVar3 = *(int *)arg; + format = "+IPS:%d,SEND OK"; + } + else { + at_dump_noend("\r\n"); + iVar3 = *(int *)arg; + format = "+IPS:%d,SEND FAILED"; + } + at_dump_noend(format,iVar3); + at_dump_noend("\r\n"); + pbuf_free(p); + goto LAB_230806f2; + } + } + else { + vTaskExitCritical(); + } + at_dump_noend("\r\n"); + at_dump_noend("+IPS:%d,SEND FAILED",*(int *)arg); + at_dump_noend("\r\n"); +LAB_230806f2: + free(arg); + return; +} + + + +void tcp_err_callback(void *arg,err_t err) + +{ + socket_type sVar1; + undefined3 in_register_0000202d; + undefined4 uVar2; + undefined4 extraout_a1; + + uVar2 = CONCAT31(in_register_0000202d,err); + if (4 < (int)arg) { + arg = (void *)__assert_func( + "/home/rjwang/work/bl_iot_sdk.release/components/stage/atcmd/at_bl602/bl_socket.c" + ,0xc6,"tcp_err_callback","linkId < AT_MAX_PEER_NUM"); + uVar2 = extraout_a1; + } + at_dump_noend("\r\n",uVar2); + at_dump_noend("+IPS:%d,FAILED",arg); + at_dump_noend("\r\n"); + xQueueSemaphoreTake((QueueHandle_t)g_network_sem,0xffffffff); + sVar1 = networks.connect[(int)arg].protocol; + networks.connect[(int)arg].status = SOCK_IDLE_CLOSE; + *(undefined4 *)&networks.connect[(int)arg].pcb = 0; + if (sVar1 == SOCK_TYPE_TLS) { + altcp_tls_free_config(*(altcp_tls_config **)((int)&networks.connect[(int)arg].pcb + 4)); + *(undefined4 *)((int)&networks.connect[(int)arg].pcb + 4) = 0; + } + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + return; +} + + + +void udp_receive_callback(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port) + +{ + pbuf *ppVar1; + undefined2 in_register_0000203a; + + if ((int)arg < 5) { + vTaskEnterCritical(CONCAT22(in_register_0000203a,port)); + if (networks.connect[(int)arg].status == SOCK_IDLE_CLOSE) { + vTaskExitCritical(); + printf("linkId %d connection status error!\r\n",arg); + } + else { + vTaskExitCritical(); + at_serial_lock(); + at_dump_noend("\r\n"); + at_dump_noend("+IPD:"); + at_dump_noend("\r\n"); + at_dump_noend("\r\n"); + at_dump_noend("%d,%d\r\n",arg,(uint)p->tot_len); + at_dump_noend("\r\n"); + ppVar1 = p; + do { + at_data_output((char *)ppVar1->payload,(uint)ppVar1->len); + ppVar1 = ppVar1->next; + } while (ppVar1 != (pbuf *)0x0); + at_serial_unlock(); + } + } + else { + printf("receive callback arg error!!!!\r\n"); + } + pbuf_free(p); + return; +} + + + +err_t tcp_accept_callback(void *arg,altcp_pcb *new_conn,err_t err) + +{ + u16_t uVar1; + char *fmt; + ip_addr_t *addr; + undefined2 extraout_var; + undefined3 in_register_00002031; + network_t *pnVar2; + undefined *arg_00; + + if (CONCAT31(in_register_00002031,err) == 0) { + xQueueSemaphoreTake((QueueHandle_t)g_network_sem,0xffffffff); + pnVar2 = &networks; + arg_00 = (undefined *)0x0; + do { + if (pnVar2->connect[0].status == SOCK_IDLE_CLOSE) { + memset(networks.connect + (int)arg_00,0,0x38); + break; + } + arg_00 = arg_00 + 1; + pnVar2 = (network_t *)&pnVar2->connect[0].status; + } while (arg_00 != &DAT_00000005); + if (networks.connect[(int)arg_00].status == SOCK_IDLE_CLOSE) { + *(altcp_pcb **)&networks.connect[(int)arg_00].pcb = new_conn; + networks.count = networks.count + 1; + networks.connect[(int)arg_00].status = SOCK_CLIENT_CONNECTED; + networks.connect[(int)arg_00].protocol = SOCK_TYPE_TCP; + addr = altcp_get_ip(new_conn,0); + ip4addr_ntoa_r((ip4_addr_t *)addr,(char *)(networks.connect + (int)arg_00),0x10); + uVar1 = altcp_get_port(new_conn,0); + networks.connect[(int)arg_00].port = CONCAT22(extraout_var,uVar1); + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + at_dump_noend("\r\n"); + at_dump_noend("+IPS:%d,CONNECTED",arg_00); + at_dump_noend("\r\n"); + altcp_arg(new_conn,arg_00); + altcp_recv(new_conn,tcp_receive_callback); + altcp_sent(new_conn,tcp_sent_callback); + altcp_err(new_conn,tcp_err_callback); + return err; + } + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + fmt = "no avalible connect slot\r\n"; + } + else { + fmt = "accept error!\r\n"; + } + printf(fmt); + altcp_close(new_conn); + return -0xb; +} + + + +void tcp_send_data(void *arg) + +{ + int iVar1; + undefined4 uVar2; + char *pcVar3; + + if (arg != (void *)0x0) goto LAB_23080a52; + pcVar3 = "arg != NULL"; + uVar2 = 0x2a1; + while( true ) { + arg = (void *)__assert_func( + "/home/rjwang/work/bl_iot_sdk.release/components/stage/atcmd/at_bl602/bl_socket.c" + ,uVar2,"tcp_send_data",pcVar3); +LAB_23080a52: + if (((int *)arg)[1] != 0) break; + pcVar3 = "ctx->buf != NULL"; + uVar2 = 0x2a4; + } + vTaskEnterCritical(); + iVar1 = *(int *)arg; + if ((networks.connect[iVar1].protocol == SOCK_TYPE_UDP) || + (networks.connect[iVar1].status == SOCK_IDLE_CLOSE)) { + vTaskExitCritical(); + at_dump_noend("\r\n"); + at_dump_noend("+IPS:%d,SEND FAILED",*(int *)arg); + at_dump_noend("\r\n"); + } + else { + vTaskExitCritical(); + altcp_write(*(altcp_pcb **)&networks.connect[iVar1].pcb,(void *)((int *)arg)[1], + (u16_t)cipsend_totlen,'\0'); + } + free(arg); + return; +} + + + +AT_ERROR_CODE bl_cipstatus(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + network_t *pnVar1; + int iVar2; + char *pcVar3; + uint uVar4; + + pnVar1 = &networks; + iVar2 = 0; + do { + if (pnVar1->connect[0].status != SOCK_IDLE_CLOSE) { + at_dump_noend("\r\n"); + uVar4 = (uint)pnVar1->connect[0].protocol - 1 & 0xff; + pcVar3 = "UNKNOW"; + if (uVar4 < 3) { + pcVar3 = *(char **)(CSWTCH_67 + uVar4 * 4); + } + at_dump_noend("+CIPSTART:%d,%s,%s,%d",iVar2,pcVar3,pnVar1->connect,pnVar1->connect[0].port); + at_dump_noend("\r\n"); + } + iVar2 = iVar2 + 1; + pnVar1 = (network_t *)&pnVar1->connect[0].status; + } while (iVar2 != 5); + return AEC_OK; +} + + + +// WARNING: Type propagation algorithm not settling + +AT_ERROR_CODE bl_cipstart(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + auth_mode aVar1; + SemaphoreHandle_t xQueue; + char "bl_cipstart" [12]; + byte *__s1; + s32 *psVar2; + err_t eVar3; + int iVar4; + altcp_pcb *conn; + undefined3 extraout_var; + udp_pcb *pcb; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + altcp_tls_config *config; + mbedtls_ssl_context *ssl; + undefined3 extraout_var_02; + char **protos; + socket_type sVar5; + undefined uVar6; + void *arg; + ip_addr_t iStack76; + ip_addr_t ip_addr; + romfs_filebuf_t ca_buf; + romfs_filebuf_t cert_buf; + romfs_filebuf_t filebuf; + + arg = *(void **)para->u; + if (4 < (int)arg) { + return AEC_OUT_OF_RANGE; + } + xQueueSemaphoreTake((QueueHandle_t)g_network_sem,0xffffffff); + if (networks.connect[(int)arg].status != SOCK_IDLE_CLOSE) { + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + at_dump_noend("\r\n"); + at_dump_noend("+IPS:%d,ALREADY CONNECT",arg); + at_dump_noend("\r\n"); + return AEC_SOCKET_EXISTING; + } + strncpy((char *)(networks.connect + (int)arg),(char *)(para->u + 8),0xf); + __s1 = para->u + 4; + networks.connect[(int)arg].port = *(u32 *)(para->u + 0x108); + iVar4 = strcmp((char *)__s1,"TCP"); + if (iVar4 == 0) { +LAB_23080c36: + sVar5 = SOCK_TYPE_TCP; + } + else { + iVar4 = strcmp((char *)__s1,"UDP"); + sVar5 = SOCK_TYPE_UDP; + if (iVar4 != 0) { + iVar4 = strcmp((char *)__s1,"SSL"); + if (iVar4 != 0) goto LAB_23080c96; + if (networks.connect[(int)arg].auth_mode == NO_AUTH) { + printf("warn: use SSL with no auth mode, fallback to tcp mode\r\n"); + goto LAB_23080c36; + } + sVar5 = SOCK_TYPE_TLS; + } + } + networks.connect[(int)arg].protocol = sVar5; + iVar4 = ip4addr_aton((char *)(networks.connect + (int)arg),(ip4_addr_t *)&iStack76); + if (iVar4 == 0) { +LAB_23080c96: + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + return AEC_PARA_ERROR; + } + psVar2 = &networks.count + (int)arg * 0xe; + sVar5 = networks.connect[(int)arg].protocol; + if (sVar5 == SOCK_TYPE_TCP) { + conn = altcp_tcp_new_ip_type('.'); + *(altcp_pcb **)&networks.connect[(int)arg].pcb = conn; + if (conn == (altcp_pcb *)0x0) goto LAB_23080cbe; + altcp_arg(conn,arg); + eVar3 = altcp_connect(*(altcp_pcb **)&networks.connect[(int)arg].pcb,&iStack76, + *(u16_t *)&networks.connect[(int)arg].port,tcp_connected_callback); + conn = *(altcp_pcb **)&networks.connect[(int)arg].pcb; + if (CONCAT31(extraout_var,eVar3) != 0) { + altcp_close(conn); + *(undefined4 *)&networks.connect[(int)arg].pcb = 0; + goto LAB_23080cfa; + } + } + else { + if (sVar5 == SOCK_TYPE_UDP) { + pcb = udp_new_ip_type(); + *(udp_pcb **)&networks.connect[(int)arg].pcb = pcb; + if (pcb == (udp_pcb *)0x0) goto LAB_23080cbe; + eVar3 = udp_bind(pcb,&ip_addr_any,0); + pcb = *(udp_pcb **)&networks.connect[(int)arg].pcb; + if (CONCAT31(extraout_var_00,eVar3) == 0) { + eVar3 = udp_connect(pcb,&iStack76,*(u16_t *)&networks.connect[(int)arg].port); + pcb = *(udp_pcb **)&networks.connect[(int)arg].pcb; + if (CONCAT31(extraout_var_01,eVar3) == 0) { + udp_recv(pcb,udp_receive_callback,arg); + uVar6 = 3; + goto LAB_23080d5c; + } + } + udp_remove(pcb); + *(undefined4 *)&networks.connect[(int)arg].pcb = 0; +LAB_23080cbe: + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + return AEC_SOCKET_FAIL; + } + if (sVar5 != SOCK_TYPE_TLS) { + return AEC_UNDEFINED; + } + aVar1 = networks.connect[(int)arg].auth_mode; + if (aVar1 == CLIENT_AUTH_CA) { + iVar4 = get_romfs_file_content + (networks.connect[(int)arg].ca,(romfs_filebuf_t *)&cert_buf.bufsize); + if (iVar4 != 0) goto LAB_23080cbe; + config = altcp_tls_create_config_client((u8_t *)cert_buf.bufsize,(size_t)filebuf.buf); + } + else { + if (aVar1 == BOTH_AUTH) { + iVar4 = get_romfs_file_content(networks.connect[(int)arg].ca,(romfs_filebuf_t *)&ip_addr); + if (((iVar4 != 0) || + (iVar4 = get_romfs_file_content + (networks.connect[(int)arg].cert,(romfs_filebuf_t *)&ca_buf.bufsize), + iVar4 != 0)) || + (iVar4 = get_romfs_file_content + (networks.connect[(int)arg].key,(romfs_filebuf_t *)&cert_buf.bufsize), + iVar4 != 0)) goto LAB_23080cbe; + } + else { + if (aVar1 != SERVER_AUTH_CERT_KEY) { + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + return AEC_UNSUPPORTED; + } + iVar4 = get_romfs_file_content + (networks.connect[(int)arg].cert,(romfs_filebuf_t *)&ca_buf.bufsize); + if ((iVar4 != 0) || + (ip_addr = get_romfs_file_content + (networks.connect[(int)arg].key,(romfs_filebuf_t *)&cert_buf.bufsize + ), (u8_t *)ip_addr != (u8_t *)0x0)) goto LAB_23080cbe; + ca_buf.buf = (char *)0x0; + } + config = altcp_tls_create_config_client_2wayauth + ((u8_t *)ip_addr,(size_t)ca_buf.buf,(u8_t *)cert_buf.bufsize, + (size_t)filebuf.buf,(u8_t *)0x0,0,(u8_t *)ca_buf.bufsize, + (size_t)cert_buf.buf); + } + *(altcp_tls_config **)((int)&networks.connect[(int)arg].pcb + 4) = config; + config = *(altcp_tls_config **)((int)&networks.connect[(int)arg].pcb + 4); + if (config == (altcp_tls_config *)0x0) goto LAB_23080cbe; + conn = altcp_tls_new(config,'.'); + *(altcp_pcb **)&networks.connect[(int)arg].pcb = conn; + if (conn == (altcp_pcb *)0x0) { + altcp_tls_free_config(*(altcp_tls_config **)((int)&networks.connect[(int)arg].pcb + 4)); + *(undefined4 *)((int)&networks.connect[(int)arg].pcb + 4) = 0; + goto LAB_23080cbe; + } + aVar1 = networks.connect[(int)arg].auth_mode; + if (networks.connect[(int)arg].sni == (char *)0x0) { + if (aVar1 == SERVER_AUTH_CERT_KEY) { +LAB_23080ec2: + mbedtls_ssl_conf_authmode + (*(mbedtls_ssl_config **)((int)&networks.connect[(int)arg].pcb + 4),0); + } + } + else { + if (aVar1 == SERVER_AUTH_CERT_KEY) goto LAB_23080ec2; + ssl = (mbedtls_ssl_context *)altcp_tls_context(conn); + if (ssl == (mbedtls_ssl_context *)0x0) { + __assert_func( + "/home/rjwang/work/bl_iot_sdk.release/components/stage/atcmd/at_bl602/bl_socket.c" + ,0x1cc,"bl_cipstart","ssl_context != NULL"); + } + mbedtls_ssl_conf_authmode + (*(mbedtls_ssl_config **)((int)&networks.connect[(int)arg].pcb + 4),2); + iVar4 = mbedtls_ssl_set_hostname(ssl,networks.connect[(int)arg].sni); + if (iVar4 != 0) { + altcp_close(*(altcp_pcb **)&networks.connect[(int)arg].pcb); + config = *(altcp_tls_config **)((int)&networks.connect[(int)arg].pcb + 4); + *(undefined4 *)&networks.connect[(int)arg].pcb = 0; + altcp_tls_free_config(config); + xQueue = g_network_sem; + *(undefined4 *)((int)&networks.connect[(int)arg].pcb + 4) = 0; + xQueueGenericSend((QueueHandle_t)xQueue,(void *)0x0,0,0); + printf("ssl set sni failed!\r\n"); + return AEC_CONNECT_FAIL; + } + } + protos = networks.connect[(int)arg].alpn; + if (protos != (char **)0x0) { + mbedtls_ssl_conf_alpn_protocols + (*(mbedtls_ssl_config **)((int)&networks.connect[(int)arg].pcb + 4),protos); + } + psVar2 = &networks.count + (int)arg * 0xe; + altcp_arg(*(altcp_pcb **)&networks.connect[(int)arg].pcb,arg); + eVar3 = altcp_connect(*(altcp_pcb **)&networks.connect[(int)arg].pcb,&iStack76, + *(u16_t *)&networks.connect[(int)arg].port,tcp_connected_callback); + conn = *(altcp_pcb **)&networks.connect[(int)arg].pcb; + if (CONCAT31(extraout_var_02,eVar3) != 0) { + altcp_close(conn); + config = *(altcp_tls_config **)((int)&networks.connect[(int)arg].pcb + 4); + *(undefined4 *)&networks.connect[(int)arg].pcb = 0; + altcp_tls_free_config(config); + *(undefined4 *)((int)&networks.connect[(int)arg].pcb + 4) = 0; +LAB_23080cfa: + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + return AEC_CONNECT_FAIL; + } + } + altcp_err(conn,tcp_err_callback); + uVar6 = 2; +LAB_23080d5c: + *(undefined *)(psVar2 + 0xe) = uVar6; + networks.count = networks.count + 1; + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + return AEC_OK; +} + + + +AT_ERROR_CODE bl_cipsendbuf(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + return AEC_OK; +} + + + +AT_ERROR_CODE bl_cipclose(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + socket_type sVar1; + SemaphoreHandle_t xQueue; + int iVar2; + altcp_tls_config *conf; + + iVar2 = *(int *)para->u; + if (4 < iVar2) { + return AEC_PARA_ERROR; + } + if (networks.connect[iVar2].status == SOCK_IDLE_CLOSE) { + return AEC_SOCKET_EXISTING; + } + at_dump_noend("\r\n"); + at_dump_noend("+IPS:%d,-1\r\n",iVar2); + at_dump_noend("\r\n"); + xQueueSemaphoreTake((QueueHandle_t)g_network_sem,0xffffffff); + if (networks.connect[iVar2].status == SOCK_IDLE_CLOSE) { + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + return AEC_DISCONNECT; + } + sVar1 = networks.connect[iVar2].protocol; + networks.connect[iVar2].status = SOCK_IDLE_CLOSE; + if (sVar1 == SOCK_TYPE_UDP) { + udp_remove(*(udp_pcb **)&networks.connect[iVar2].pcb); + } + else { + if (sVar1 != SOCK_TYPE_TCP) { + if (sVar1 == SOCK_TYPE_TLS) { + altcp_close(*(altcp_pcb **)&networks.connect[iVar2].pcb); + conf = *(altcp_tls_config **)((int)&networks.connect[iVar2].pcb + 4); + *(undefined4 *)&networks.connect[iVar2].pcb = 0; + altcp_tls_free_config(conf); + *(undefined4 *)((int)&networks.connect[iVar2].pcb + 4) = 0; + } + goto LAB_23080fcc; + } + altcp_close(*(altcp_pcb **)&networks.connect[iVar2].pcb); + } + *(undefined4 *)&networks.connect[iVar2].pcb = 0; +LAB_23080fcc: + xQueue = g_network_sem; + networks.count = networks.count + -1; + networks.connect[iVar2].protocol = 0; + xQueueGenericSend((QueueHandle_t)xQueue,(void *)0x0,0,0); + return AEC_OK; +} + + + +AT_ERROR_CODE bl_tcpserver(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + err_t eVar1; + undefined3 extraout_var; + u32 uVar2; + + if (*(int *)(para->u + 8) == 0) { + if (*(int *)(para->u + 4) == 0) { + if (g_server_enable == 0) { + return AEC_SOCKET_FAIL; + } + g_server_enable = 0; + if (g_server_arg.protocol != 1) { + g_server_enable = 0; + return AEC_OK; + } + altcp_close((altcp_pcb *)g_server_ctrl.pcb); + g_server_ctrl.pcb._0_4_ = (altcp_pcb *)0x0; + return AEC_OK; + } + uVar2 = 1; + } + else { + uVar2 = 3; + if (*(int *)(para->u + 4) == 0) { + return AEC_UNSUPPORTED; + } + } + if (g_server_enable != 0) { + return AEC_SOCKET_FAIL; + } + g_server_arg.port = (s16)*(undefined4 *)para->u; + g_server_arg.protocol = 1; + memset(&g_server_ctrl,0,0x28); + if (uVar2 == 1) { + g_server_ctrl.pcb._0_4_ = altcp_tcp_new_ip_type('\0'); + if ((altcp_pcb *)g_server_ctrl.pcb == (altcp_pcb *)0x0) { + return AEC_NOT_ENOUGH_MEMORY; + } + eVar1 = altcp_bind((altcp_pcb *)g_server_ctrl.pcb,&ip_addr_any,g_server_arg.port); + if (CONCAT31(extraout_var,eVar1) != 0) { + altcp_close((altcp_pcb *)g_server_ctrl.pcb); + g_server_ctrl.pcb._0_4_ = (altcp_pcb *)0x0; + return AEC_BIND_FAIL; + } + g_server_ctrl.pcb._0_4_ = + altcp_listen_with_backlog_and_err((altcp_pcb *)g_server_ctrl.pcb,'\x05',(err_t *)0x0); + if ((altcp_pcb *)g_server_ctrl.pcb == (altcp_pcb *)0x0) { + return AEC_SOCKET_FAIL; + } + g_server_enable = uVar2; + altcp_accept((altcp_pcb *)g_server_ctrl.pcb,tcp_accept_callback); + } + return AEC_OK; +} + + + +AT_ERROR_CODE bl_cipsend(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + socket_type sVar1; + code *function; + int iVar2; + undefined4 *ctx; + + iVar2 = *(int *)para->u; + if (4 < iVar2) { + return AEC_DISCONNECT; + } + if (networks.connect[iVar2].status != SOCK_CLIENT_CONNECTED) { + printf("linkId %d is not connected!\r\n"); + return AEC_CMD_FAIL; + } + cipsend_totlen = *(int32_t *)(para->u + 4); + sVar1 = networks.connect[iVar2].protocol; + if ((sVar1 & 0xfd) == 1) { + ctx = (undefined4 *)malloc(8); + if (ctx != (undefined4 *)0x0) { + *ctx = *(undefined4 *)para->u; + ctx[1] = *(undefined4 *)(para->u + 8); + function = tcp_send_data; +LAB_230811aa: + tcpip_callback(function,ctx); + return AEC_OK; + } + } + else { + if (sVar1 != SOCK_TYPE_UDP) { + return AEC_UNSUPPORTED; + } + ctx = (undefined4 *)malloc(8); + if (ctx != (undefined4 *)0x0) { + *ctx = *(undefined4 *)para->u; + ctx[1] = *(undefined4 *)(para->u + 8); + function = udp_send_data; + goto LAB_230811aa; + } + } + return AEC_NOT_ENOUGH_MEMORY; +} + + + +AT_ERROR_CODE bl_cipsslcconf_path(at_callback_para_t *para,at_callback_rsp_t *unused) + +{ + int iVar1; + char *pv; + auth_mode aVar2; + int iVar3; + AT_ERROR_CODE AVar4; + + if (4 < *(int *)para->u) { + return AEC_OUT_OF_RANGE; + } + xQueueSemaphoreTake((QueueHandle_t)g_network_sem,0xffffffff); + iVar1 = *(int *)para->u; + AVar4 = networks.connect[iVar1].status; + if (AVar4 != AEC_OK) { + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + return AEC_IMPROPER_OPERATION; + } + iVar3 = *(int *)(para->u + 4); + aVar2 = (auth_mode)iVar3; + if (iVar3 == 1) { + pv = networks.connect[iVar1].ca; + networks.connect[iVar1].auth_mode = aVar2; + if (pv != (char *)0x0) { + vPortFree(pv); + } + pv = networks.connect[iVar1].cert; + if (pv != (char *)0x0) { + vPortFree(pv); + } + pv = networks.connect[iVar1].key; + if (pv != (char *)0x0) { + vPortFree(pv); + } + networks.connect[iVar1].ca = (char *)0x0; +LAB_230812bc: + networks.connect[iVar1].cert = *(char **)(para->u + 0x10); + networks.connect[iVar1].key = *(char **)(para->u + 0xc); +LAB_230812c8: + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + } + else { + if (iVar3 < 2) { + if (iVar3 == 0) { + pv = networks.connect[iVar1].ca; + networks.connect[iVar1].auth_mode = NO_AUTH; + if (pv != (char *)0x0) { + vPortFree(pv); + } + pv = networks.connect[iVar1].cert; + if (pv != (char *)0x0) { + vPortFree(pv); + } + pv = networks.connect[iVar1].key; + if (pv != (char *)0x0) { + vPortFree(pv); + } + networks.connect[iVar1].ca = (char *)0x0; +LAB_23081318: + networks.connect[iVar1].cert = (char *)0x0; + networks.connect[iVar1].key = (char *)0x0; + goto LAB_230812c8; + } + } + else { + if (iVar3 == 2) { + pv = networks.connect[iVar1].ca; + networks.connect[iVar1].auth_mode = aVar2; + if (pv != (char *)0x0) { + vPortFree(pv); + } + pv = networks.connect[iVar1].cert; + if (pv != (char *)0x0) { + vPortFree(pv); + } + pv = networks.connect[iVar1].key; + if (pv != (char *)0x0) { + vPortFree(pv); + } + networks.connect[iVar1].ca = *(char **)(para->u + 8); + goto LAB_23081318; + } + if (iVar3 == 3) { + pv = networks.connect[iVar1].ca; + networks.connect[iVar1].auth_mode = aVar2; + if (pv != (char *)0x0) { + vPortFree(pv); + } + pv = networks.connect[iVar1].cert; + if (pv != (char *)0x0) { + vPortFree(pv); + } + pv = networks.connect[iVar1].key; + if (pv != (char *)0x0) { + vPortFree(pv); + } + networks.connect[iVar1].ca = *(char **)(para->u + 8); + goto LAB_230812bc; + } + } + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + AVar4 = AEC_PARA_ERROR; + } + return AVar4; +} + + + +AT_ERROR_CODE bl_cipsslcsni(at_callback_para_t *para,at_callback_rsp_t *rsp) + +{ + size_t sVar1; + char *__dest; + char *pv; + AT_ERROR_CODE AVar2; + int iVar3; + + AVar2 = AEC_OUT_OF_RANGE; + if (*(int *)para->u < 5) { + xQueueSemaphoreTake((QueueHandle_t)g_network_sem,0xffffffff); + iVar3 = *(int *)para->u; + AVar2 = networks.connect[iVar3].status; + if (AVar2 == AEC_OK) { + sVar1 = strlen((char *)(para->u + 4)); + if (sVar1 == 0) { + __dest = networks.connect[iVar3].sni; + if (__dest != (char *)0x0) { + vPortFree(__dest); + networks.connect[iVar3].sni = (char *)0x0; + } + } + else { + __dest = (char *)pvPortMalloc(sVar1 + 1); + if (__dest == (char *)0x0) { + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + return AEC_NOT_ENOUGH_MEMORY; + } + pv = networks.connect[iVar3].sni; + if (pv != (char *)0x0) { + vPortFree(pv); + networks.connect[iVar3].sni = (char *)0x0; + } + strcpy(__dest,(char *)(para->u + 4)); + __dest[sVar1] = '\0'; + networks.connect[iVar3].sni = __dest; + } + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + } + else { + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + AVar2 = AEC_IMPROPER_OPERATION; + } + } + return AVar2; +} + + + +AT_ERROR_CODE bl_cipsslcalpn(at_callback_para_t *para,at_callback_rsp_t *unused) + +{ + SemaphoreHandle_t xQueue; + void *pv; + char **pv_00; + AT_ERROR_CODE AVar1; + int iVar2; + + if (*(int *)para->u < 5) { + xQueueSemaphoreTake((QueueHandle_t)g_network_sem,0xffffffff); + iVar2 = *(int *)para->u; + if (networks.connect[iVar2].status == SOCK_IDLE_CLOSE) { + pv_00 = networks.connect[iVar2].alpn; + if (pv_00 != (char **)0x0) { + vPortFree(pv_00); + } + xQueue = g_network_sem; + networks.connect[iVar2].alpn = *(char ***)(para->u + 4); + xQueueGenericSend((QueueHandle_t)xQueue,(void *)0x0,0,0); + return AEC_OK; + } + xQueueGenericSend((QueueHandle_t)g_network_sem,(void *)0x0,0,0); + pv = *(void **)(para->u + 4); + AVar1 = AEC_IMPROPER_OPERATION; + } + else { + pv = *(void **)(para->u + 4); + AVar1 = AEC_OUT_OF_RANGE; + } + if (pv != (void *)0x0) { + vPortFree(pv); + *(undefined4 *)(para->u + 4) = 0; + } + return AVar1; +} + + + +size_t format_int(char *q,size_t n,uint flags,int base,int width,int prec) + +{ + char "0123456789abcdef" [17]; + char "0123456789ABCDEF" [17]; + int iVar1; + uint uVar2; + uint uVar3; + char cVar4; + uint uVar5; + uint uVar6; + int in_a6; + int in_a7; + int iVar7; + int iVar8; + uint uVar9; + char *pcVar10; + int iVar11; + char *pcStack84; + + if ((width & 0x80U) == 0) { + pcStack84 = "0123456789abcdef"; + } + else { + pcStack84 = "0123456789ABCDEF"; + } + uVar9 = 0; + if (((width & 0x40U) != 0) && (base < 0)) { + flags = -flags; + base = -(uint)(flags != 0) - base; + uVar9 = 1; + } + iVar7 = 0; + uVar2 = flags; + uVar6 = base; + while ((uVar2 | uVar6) != 0) { + __udivdi3(); + iVar7 = iVar7 + 1; + } + uVar2 = width & 0x20; + if ((uVar2 == 0) || (prec != 8)) { +LAB_230815b6: + if ((in_a7 <= iVar7) && (in_a7 = iVar7, (flags | base) == 0)) { + in_a7 = 1; + } + } + else { + if (in_a7 <= iVar7) { + in_a7 = iVar7 + 1; + goto LAB_230815b6; + } + } + iVar7 = in_a7; + if (((width & 8U) != 0) && (iVar7 = 4, prec != 0x10)) { + iVar7 = 3; + } + iVar8 = (in_a7 + -1) / iVar7 + in_a7; + iVar1 = (uint)((width & 0x14U | uVar9) != 0) + iVar8; + if ((uVar2 != 0) && (prec == 0x10)) { + iVar1 = iVar1 + 2; + } + uVar3 = width & 3; + uVar6 = 0; + if ((uVar3 == 0) && (uVar6 = uVar3, iVar1 < in_a6)) { + uVar6 = in_a6 - iVar1; + uVar5 = 0; + do { + if (uVar5 < n) { + *q = ' '; + q = q + 1; + } + uVar5 = uVar5 + 1; + in_a6 = iVar1; + } while (uVar5 != uVar6); + } + if (uVar9 == 0) { + if ((width & 4U) == 0) { + if ((width & 0x10U) == 0) goto LAB_23081638; + if (uVar6 < n) { + *q = ' '; + q = q + 1; + } + } + else { + if (uVar6 < n) { + *q = '+'; + q = q + 1; + } + } + } + else { + if (uVar6 < n) { + *q = '-'; + q = q + 1; + } + } + uVar6 = uVar6 + 1; +LAB_23081638: + if ((uVar2 != 0) && (prec == 0x10)) { + if (uVar6 < n) { + *q = '0'; + q = q + 1; + } + if (uVar6 + 1 < n) { + cVar4 = 'X'; + if ((width & 0x80U) == 0) { + cVar4 = 'x'; + } + *q = cVar4; + q = q + 1; + } + uVar6 = uVar6 + 2; + } + if ((uVar3 == 1) && (iVar8 < in_a6)) { + while (iVar1 < in_a6) { + if (uVar6 < n) { + *q = '0'; + q = q + 1; + } + uVar6 = uVar6 + 1; + in_a6 = in_a6 + -1; + } + } + uVar6 = iVar8 + uVar6; + q = q + iVar8; + pcVar10 = q; + uVar9 = uVar6; + iVar11 = iVar7; + while (0 < iVar8) { + if (iVar11 == 0) { + uVar9 = uVar9 - 1; + if (uVar9 < n) { + pcVar10[-1] = '_'; + } + pcVar10 = pcVar10 + -1; + iVar8 = iVar8 + -1; + iVar11 = iVar7; + } + iVar11 = iVar11 + -1; + uVar9 = uVar9 - 1; + iVar8 = iVar8 + -1; + if (uVar9 < n) { + uVar2 = flags; + __umoddi3(); + pcVar10[-1] = pcStack84[uVar2]; + } + __udivdi3(); + pcVar10 = pcVar10 + -1; + } + iVar7 = in_a6 + uVar6; + while (((width & 2U) != 0 && (iVar1 < (int)(iVar7 - uVar6)))) { + if (uVar6 < n) { + *q = ' '; + q = q + 1; + } + uVar6 = uVar6 + 1; + } + return uVar6; +} + + + +char * cvt(int ndigits,int *decpt,int *sign,char *buf,int eflag) + +{ + int *piVar1; + byte *pbVar2; + __gcc_CMPtype _Var3; + double *__iptr; + SItype SVar4; + byte *in_a5; + byte *pbVar5; + int in_a6; + byte *pbVar6; + byte *pbVar7; + double in_fa1; + double *pdStack80; + double fi; + double fj; + + piVar1 = (int *)0x4e; + if (((int)sign < 0x4f) && (piVar1 = sign, (int)sign < 0)) { + piVar1 = (int *)0x0; + } + _Var3 = __ledf2(); + if (_Var3 < 0) { + *(undefined4 *)eflag = 1; + } + else { + *(undefined4 *)eflag = 0; + } + modf(in_fa1,(double *)ndigits); + pbVar6 = in_a5 + 0x50; + _Var3 = __eqdf2(); + pbVar2 = pbVar6; + pbVar5 = in_a5; + if (_Var3 == 0) { + _Var3 = __gedf2(); + pbVar7 = (byte *)0x0; + if (0 < _Var3) { + while( true ) { + __iptr = (double *)ndigits; + __muldf3(); + _Var3 = __ledf2(); + if (-1 < _Var3) break; + pbVar7 = pbVar7 + -1; + ndigits = (int)__iptr; + } + } + } + else { + while( true ) { + _Var3 = __eqdf2(); + pbVar7 = pbVar6 + -(int)pbVar2; + if (_Var3 == 0) break; + __iptr = pdStack80; + __divdf3(); + modf(in_fa1,__iptr); + __adddf3(); + __muldf3(); + SVar4 = __fixdfsi(); + pbVar2[-1] = (char)SVar4 + 0x30; + pbVar2 = pbVar2 + -1; + } + while (pbVar2 < pbVar6) { + *pbVar5 = *pbVar2; + pbVar5 = pbVar5 + 1; + pbVar2 = pbVar2 + 1; + } + } + pbVar2 = (byte *)((int)piVar1 + (int)in_a5); + if (in_a6 == 0) { + pbVar2 = pbVar2 + (int)pbVar7; + } + *(byte **)buf = pbVar7; + if (pbVar2 < in_a5) { + *in_a5 = 0; + } + else { + while ((pbVar5 <= pbVar2 && (pbVar5 < pbVar6))) { + __muldf3(); + modf(in_fa1,(double *)ndigits); + SVar4 = __fixdfsi(); + *pbVar5 = (char)SVar4 + 0x30; + pbVar5 = pbVar5 + 1; + } + if (pbVar2 < pbVar6) { + *pbVar2 = *pbVar2 + 5; + pbVar5 = pbVar2; + while (0x39 < *pbVar5) { + *pbVar5 = 0x30; + if (in_a5 < pbVar5) { + pbVar6 = pbVar5 + -1; + pbVar5 = pbVar5 + -1; + *pbVar5 = *pbVar6 + 1; + } + else { + *pbVar5 = 0x31; + *(int *)buf = *(int *)buf + 1; + if (in_a6 == 0) { + if (in_a5 < pbVar2) { + *pbVar2 = 0x30; + } + pbVar2 = pbVar2 + 1; + } + } + } + *pbVar2 = 0; + } + else { + in_a5[0x4f] = 0; + } + } + return (char *)in_a5; +} + + + +char * ecvtbuf(int ndigits,int *decpt,int *sign,char *buf) + +{ + char *pcVar1; + int in_a4; + + pcVar1 = cvt(ndigits,decpt,sign,buf,in_a4); + return pcVar1; +} + + + +char * fcvtbuf(int ndigits,int *decpt,int *sign,char *buf) + +{ + char *pcVar1; + int in_a4; + + pcVar1 = cvt(ndigits,decpt,sign,buf,in_a4); + return pcVar1; +} + + + +char * flt(char *str,int size,int precision,char fmt,int flags) + +{ + bool bVar1; + byte bVar2; + int iVar3; + __gcc_CMPtype _Var4; + char *pcVar5; + undefined *puVar6; + size_t sVar7; + int *sign_00; + undefined3 in_register_00002035; + char *pcVar8; + int *piVar9; + uint uVar10; + int *__string; + char cVar11; + uint in_a5; + uint uVar12; + char *pcVar13; + int iVar14; + uint in_a6; + char cVar15; + char cVar16; + char *pcVar17; + char *pcStack232; + int decpt; + int sign; + char tmp [80]; + char cvtbuf [80]; + + iVar3 = CONCAT31(in_register_00002035,fmt); + uVar12 = in_a6 & 0x10; + if (uVar12 == 0) { + cVar16 = '0'; + if ((in_a6 & 1) == 0) { + cVar16 = ' '; + } + } + else { + in_a6 = in_a6 & 0xfffffffe; + cVar16 = ' '; + } + cVar15 = '\0'; + if ((in_a6 & 2) != 0) { + _Var4 = __ledf2(); + if (_Var4 < 0) { + precision = precision ^ 0x80000000; + iVar3 = iVar3 + -1; + cVar15 = '-'; + } + else { + if ((in_a6 & 4) == 0) { + if ((in_a6 & 8) != 0) { + iVar3 = iVar3 + -1; + cVar15 = ' '; + } + } + else { + iVar3 = iVar3 + -1; + cVar15 = '+'; + } + } + } + if (flags < 0) { + flags = 6; + } + bVar1 = (in_a5 & 0xfd) != 0x45; + uVar10 = in_a5; + if (!bVar1) { + uVar10 = in_a5 + 0x20 & 0xff; + } + if (uVar10 == 0x67) { + ecvtbuf(size,(int *)precision,(int *)flags,(char *)&pcStack232); + if ((-5 < (int)(pcStack232 + -1)) && ((int)(pcStack232 + -1) < flags)) { + sign_00 = (int *)(flags - (int)pcStack232); +LAB_23081b94: + pcVar5 = fcvtbuf(size,(int *)precision,sign_00,(char *)&pcStack232); + __string = &sign; + if (decpt != 0) { + sign._0_1_ = 0x2d; + __string = (int *)((int)&sign + 1); + } + if (*pcVar5 == '\0') { + *(char *)__string = '0'; + if ((int)sign_00 < 1) { + __string = (int *)((int)__string + 1); + } + else { + *(char *)((int)__string + 1) = '.'; + pcVar5 = (char *)((int)__string + 2); + piVar9 = (int *)((int)__string + (int)sign_00); + do { + *(char *)((int)__string + 2) = '0'; + __string = (int *)((int)__string + 1); + } while (piVar9 != __string); + __string = (int *)(pcVar5 + (int)sign_00); + } + } + else { + pcVar17 = pcVar5; + if ((int)pcStack232 < 1) { + *(char *)__string = '0'; + *(char *)((int)__string + 1) = '.'; + sign_00 = __string; + while ((int *)((int)__string - (int)pcStack232) != sign_00) { + *(char *)((int)sign_00 + 2) = '0'; + sign_00 = (int *)((int)sign_00 + 1); + } + __string = (int *)((int)__string + (2 - (int)pcStack232)); + while (cVar11 = *pcVar5, cVar11 != '\0') { + pcVar5 = pcVar5 + 1; + *(char *)__string = cVar11; + __string = (int *)((int)__string + 1); + } + } + else { + do { + sign_00 = __string; + if (pcStack232 == pcVar17 + -(int)pcVar5) { + sign_00 = (int *)((int)__string + 1); + *(char *)__string = '.'; + } + pcVar8 = pcVar17 + 1; + __string = (int *)((int)sign_00 + 1); + *(char *)sign_00 = *pcVar17; + pcVar17 = pcVar8; + } while (*pcVar8 != '\0'); + } + } + goto LAB_23081b3c; + } + __string = (int *)(flags + -1); + } + else { + __string = (int *)flags; + if (uVar10 != 0x65) { + __string = &sign; + sign_00 = (int *)flags; + if (uVar10 != 0x66) goto LAB_23081b3c; + goto LAB_23081b94; + } + } + pcVar5 = ecvtbuf(size,(int *)precision,(int *)((int)__string + 1),(char *)&pcStack232); + sign_00 = &sign; + if (decpt != 0) { + sign._0_1_ = 0x2d; + sign_00 = (int *)((int)&sign + 1); + } + pcVar17 = (char *)((int)sign_00 + 1); + *(char *)sign_00 = *pcVar5; + if (0 < (int)__string) { + pcVar17 = (char *)((int)sign_00 + 2); + *(undefined *)((int)sign_00 + 1) = 0x2e; + } + pcVar8 = pcVar5 + 1; + pcVar13 = pcVar17; + while (pcVar5 + 1 + (int)__string != pcVar8) { + *pcVar13 = *pcVar8; + pcVar8 = pcVar8 + 1; + pcVar13 = pcVar13 + 1; + } + pcVar17 = pcVar17 + (int)__string; + cVar11 = 'E'; + if (bVar1) { + cVar11 = 'e'; + } + *pcVar17 = cVar11; + if (pcStack232 == (char *)0x0) { + _Var4 = __eqdf2(); + if (_Var4 != 0) { + pcStack232 = (char *)0xffffffff; + goto LAB_23081afa; + } +LAB_23081c20: + cVar11 = '+'; + } + else { + pcStack232 = pcStack232 + -1; + if (-1 < (int)pcStack232) goto LAB_23081c20; +LAB_23081afa: + pcStack232 = (char *)-(int)pcStack232; + cVar11 = '-'; + } + pcVar17[1] = cVar11; + pcVar17[4] = (char)((int)pcStack232 % 10) + '0'; + pcVar17[2] = (char)(((int)pcStack232 / 100) % 10) + '0'; + pcVar17[3] = (char)(((int)pcStack232 / 10) % 10) + '0'; + __string = (int *)(pcVar17 + 5); +LAB_23081b3c: + *(char *)__string = '\0'; + if ((in_a6 & 0x20) == 0) { + if (in_a5 == 0x67) { + __string = &sign; + do { + bVar2 = *(byte *)__string; + __string = (int *)((int)__string + 1); + if (bVar2 == 0) goto LAB_23081cd4; + } while (bVar2 != 0x2e); + while ((sign_00 = __string, *(byte *)__string != 0 && ((*(byte *)__string & 0xdf) != 0x45))) { + __string = (int *)((int)__string + 1); + } + do { + piVar9 = sign_00; + sign_00 = (int *)((int)piVar9 + -1); + } while (*(byte *)sign_00 == 0x30); + if (*(byte *)sign_00 == 0x2e) { + sign_00 = (int *)((int)piVar9 + -2); + } + while (__string != sign_00) { + sign_00 = (int *)((int)sign_00 + 1); + *(byte *)sign_00 = 0; + } + } + } + else { + if ((int *)flags == (int *)0x0) { + __string = &sign; + while (bVar2 = *(byte *)__string, bVar2 != 0) { + if (bVar2 == 0x2e) goto LAB_23081cd4; + if ((bVar2 & 0xdf) == 0x45) { + sVar7 = strnlen((char *)__string,0x100); + puVar6 = (undefined *)(sVar7 + (int)__string); + while (0 < (int)(puVar6 + -(int)__string)) { + puVar6[1] = *puVar6; + puVar6 = puVar6 + -1; + } + *(byte *)__string = 0x2e; + goto LAB_23081cd4; + } + __string = (int *)((int)__string + 1); + } + *(byte *)__string = 0x2e; + *(byte *)((int)__string + 1) = 0; + } + } +LAB_23081cd4: + sVar7 = strnlen((char *)&sign,0x100); + iVar3 = iVar3 - sVar7; + pcVar5 = str; + if ((in_a6 & 0x11) == 0) { + while (0 < (int)(str + (iVar3 - (int)pcVar5))) { + *pcVar5 = ' '; + pcVar5 = pcVar5 + 1; + } + iVar14 = iVar3; + if (iVar3 < 0) { + iVar14 = 0; + } + str = str + iVar14; + iVar3 = (iVar3 + -1) - iVar14; + } + if (cVar15 != '\0') { + *str = cVar15; + str = str + 1; + } + pcVar5 = str; + if (uVar12 == 0) { + while (0 < (int)(str + (iVar3 - (int)pcVar5))) { + *pcVar5 = cVar16; + pcVar5 = pcVar5 + 1; + } + iVar14 = iVar3; + if (iVar3 < 0) { + iVar14 = 0; + } + str = str + iVar14; + iVar3 = (iVar3 + -1) - iVar14; + } + iVar14 = 0; + while (iVar14 < (int)sVar7) { + pcVar5 = (char *)((int)&sign + iVar14); + pcVar17 = str + iVar14; + iVar14 = iVar14 + 1; + *pcVar17 = *pcVar5; + } + if ((int)sVar7 < 0) { + sVar7 = 0; + } + str = str + sVar7; + pcVar5 = str; + while (0 < (int)(str + (iVar3 - (int)pcVar5))) { + *pcVar5 = ' '; + pcVar5 = pcVar5 + 1; + } + if (iVar3 < 0) { + iVar3 = 0; + } + return str + iVar3; +} + + + +int vsnprintf(char *buffer,size_t n,char *format,va_list ap) + +{ + char *pcVar1; + size_t n_00; + byte *pbVar2; + int *piVar3; + undefined4 uVar4; + char *pcVar5; + byte bVar6; + uint uVar7; + char **ppcVar8; + int prec; + char *pcVar9; + char *pcVar10; + int iVar11; + uint width; + char *flags; + byte *str; + char *pcVar12; + char *pcStack104; + char *pcStack100; + char *pcStack88; + char acStack65 [4]; + char carg; + + uVar4 = 0; + width = 0; + flags = (char *)0xffffffff; + iVar11 = 0; + pcStack104 = (char *)0x0; + pcStack100 = (char *)0x0; + pcVar5 = (char *)0x0; + str = (byte *)buffer; + pcVar12 = (char *)0x0; +switchD_23081e84_caseD_5: + do { + pbVar2 = (byte *)format; + format = (char *)(pbVar2 + 1); + bVar6 = *pbVar2; + uVar7 = (uint)bVar6; + if (bVar6 == 0) { + if (pcVar5 < n) { + *str = 0; + } + else { + if (n != 0) { + buffer[n - 1] = '\0'; + } + } + return (int)pcVar5; + } + switch(uVar4) { + case 0: + if (bVar6 == 0x25) { + uVar4 = 1; + width = 0; + flags = (char *)0xffffffff; + iVar11 = 0; + pcVar12 = (char *)0x0; + } + else { + if (pcVar5 < n) { + *str = bVar6; + str = str + 1; + } + pcVar5 = pcVar5 + 1; + } + break; + case 1: + switch(uVar7 - 0x20 & 0xff) { + case 0: + width = width | 0x10; + break; + default: + uVar4 = 2; + format = (char *)pbVar2; + break; + case 3: + width = width | 0x20; + break; + case 7: + width = width | 8; + break; + case 0xb: + width = width | 4; + break; + case 0xd: + width = width | 2; + break; + case 0x10: + width = width | 1; + } + break; + case 2: + if ((uVar7 - 0x30 & 0xff) < 10) { + pcVar12 = (char *)((int)pcVar12 * 10 + (uVar7 - 0x30)); + } + else { + if (bVar6 == 0x2a) { + ppcVar8 = (char **)ap + 1; + pcVar12 = *(char **)ap; + ap = ppcVar8; + if ((int)pcVar12 < 0) { + width = width | 2; + pcVar12 = (char *)-(int)pcVar12; + } + } + else { + if (bVar6 == 0x2e) { + uVar4 = 3; + flags = (char *)0x0; + } + else { + uVar4 = 4; + format = (char *)pbVar2; + } + } + } + break; + case 3: + if ((uVar7 - 0x30 & 0xff) < 10) { + flags = (char *)((int)flags * 10 + (uVar7 - 0x30)); + } + else { + if (bVar6 == 0x2a) { + ppcVar8 = (char **)ap + 1; + flags = *(char **)ap; + ap = ppcVar8; + if ((int)flags < 0) { + flags = (char *)0xffffffff; + } + } + else { + uVar4 = 4; + format = (char *)pbVar2; + } + } + break; + case 4: + switch(uVar7 - 0x4c & 0xff) { + case 0: + case 0x25: + iVar11 = iVar11 + 2; + break; + default: + if (2 < iVar11) { + iVar11 = 2; + } + if (iVar11 < -2) { + iVar11 = -2; + } + switch(uVar7 - 0x50 & 0xff) { + case 0: + width = width | 0x80; + goto switchD_23081fe0_caseD_20; + default: + if (pcVar5 < n) { + *str = bVar6; + str = str + 1; + } + uVar4 = 0; + pcVar5 = pcVar5 + 1; + goto switchD_23081e84_caseD_5; + case 8: + width = width | 0x80; + prec = 0x10; + break; + case 0x13: + acStack65[0] = (char)*(char **)ap; + pcVar1 = &DAT_00000001; + pcStack88 = acStack65; + goto is_string; + case 0x14: + case 0x19: + width = width | 0x40; + // WARNING: Could not find normalized switch variable to match jumptable + switch(iVar11) { + case -2: + pcStack104 = (char *)(int)*(char *)ap; + pcStack100 = (char *)((int)pcStack104 >> 0x1f); + ap = (char **)ap + 1; + prec = 10; + break; + case 0: + pcStack104 = *(char **)ap; + pcStack100 = (char *)((int)pcStack104 >> 0x1f); + ap = (char **)ap + 1; + prec = 10; + break; + case 2: + ppcVar8 = (char **)((int)ap + 7U & 0xfffffff8); + ap = ppcVar8 + 2; + pcStack104 = *ppcVar8; + pcStack100 = ppcVar8[1]; + prec = 10; + break; + default: + prec = 10; + } + goto is_integer; + case 0x16: + piVar3 = (int *)((int)ap + 7U & 0xfffffff8); + str = (byte *)flt((char *)str,*piVar3,piVar3[1],(char)pcVar12,(int)flags); + uVar4 = 0; + ap = piVar3 + 2; + goto switchD_23081e84_caseD_5; + case 0x1e: + if (iVar11 + 2U < 5) { + // WARNING: Could not recover jumptable at 0x230821f0. Too many branches + // WARNING: Treating indirect jump as call + iVar11 = (*(code *)(&PTR_LAB_230c60f0)[iVar11 + 2U])((&PTR_LAB_230c60f0)[iVar11 + 2U]); + return iVar11; + } + uVar4 = 0; + goto switchD_23081e84_caseD_5; + case 0x1f: + prec = 8; + break; + case 0x20: +switchD_23081fe0_caseD_20: + width = width | 0x20; + pcStack104 = *(char **)ap; + pcStack100 = (char *)0x0; + ap = (char **)ap + 1; + prec = 0x10; + flags = &DAT_00000008; + goto is_integer; + case 0x23: + pcStack88 = *(char **)ap; + if (pcStack88 == (char *)0x0) { + pcStack88 = "(null)"; + } + pcVar1 = (char *)strlen(pcStack88); +is_string: + ap = (char **)ap + 1; + if ((flags != (char *)0xffffffff) && ((int)flags < (int)pcVar1)) { + pcVar1 = flags; + } + pcVar9 = pcVar5; + if (((int)pcVar1 < (int)pcVar12) && ((width & 2) == 0)) { + if ((width & 1) == 0) { + bVar6 = 0x20; + } + else { + bVar6 = 0x30; + } + pcVar9 = pcVar12 + (int)(pcVar5 + -(int)pcVar1); + do { + if (pcVar5 < n) { + *str = bVar6; + str = str + 1; + } + pcVar5 = pcVar5 + 1; + pcVar12 = pcVar1; + } while (pcVar5 != pcVar9); + } + pcVar5 = pcVar9; + if (pcVar1 != (char *)0x0) { + pcVar10 = pcVar9; + do { + if (pcVar10 < n) { + *str = pcStack88[(int)(pcVar10 + -(int)pcVar9)]; + str = str + 1; + } + pcVar10 = pcVar10 + 1; + pcVar5 = pcVar1 + (int)pcVar9; + } while (pcVar10 != pcVar1 + (int)pcVar9); + } + if ((int)pcVar1 < (int)pcVar12) { + if ((width & 2) == 0) { + uVar4 = 0; + } + else { + pcVar9 = pcVar5 + -(int)pcVar1; + do { + if (pcVar5 < n) { + *str = 0x20; + str = str + 1; + } + pcVar5 = pcVar5 + 1; + } while (pcVar5 != pcVar12 + (int)pcVar9); + uVar4 = 0; + pcVar5 = pcVar12 + (int)pcVar9; + pcVar12 = pcVar1; + } + } + else { + uVar4 = 0; + } + goto switchD_23081e84_caseD_5; + case 0x25: + prec = 10; + break; + case 0x28: + prec = 0x10; + } + // WARNING: Could not find normalized switch variable to match jumptable + switch(iVar11) { + case -2: + pcStack104 = (char *)(uint)*(byte *)ap; + pcStack100 = (char *)0x0; + ap = (char **)ap + 1; + break; + case 0: + pcStack104 = *(char **)ap; + pcStack100 = (char *)0x0; + ap = (char **)ap + 1; + break; + case 2: + ppcVar8 = (char **)((int)ap + 7U & 0xfffffff8); + ap = ppcVar8 + 2; + pcStack104 = *ppcVar8; + pcStack100 = ppcVar8[1]; + } +is_integer: + if (pcVar5 < n) { + n_00 = n - (int)pcVar5; + } + else { + n_00 = 0; + } + n_00 = format_int((char *)str,n_00,(uint)pcStack104,(int)pcStack100,width,prec); + str = str + n_00; + uVar4 = 0; + pcVar5 = pcVar5 + n_00; + break; + case 0x1c: + iVar11 = iVar11 + -1; + break; + case 0x1e: + iVar11 = 2; + break; + case 0x20: + iVar11 = iVar11 + 1; + break; + case 0x28: + case 0x2e: + iVar11 = 1; + } + } + } while( true ); +} + + + +int vsprintf(char *buffer,char *format,va_list ap) + +{ + int iVar1; + + iVar1 = vsnprintf(buffer,0x1e0,format,ap); + return iVar1; +} + + + +void vprint(char *fmt,va_list argp) + +{ + uint8_t *puVar1; + int iVar2; + + if (sys_log_all_enable == false) { + return; + } + iVar2 = vsprintf(string,fmt,argp); + puVar1 = (uint8_t *)string; + if (0 < iVar2) { + while( true ) { + if (*puVar1 == '\0') break; + bl_uart_data_send('\0',*puVar1); + puVar1 = puVar1 + 1; + } + } + return; +} + + + +int bl_putchar(int c) + +{ + bl_uart_data_send('\0',(uint8_t)c); + return 0; +} + + + +int puts(char *s) + +{ + int iVar1; + + iVar1 = 0; + if (sys_log_all_enable != false) { + iVar1 = 0; + while (s[iVar1] != '\0') { + bl_uart_data_send('\0',s[iVar1]); + iVar1 = iVar1 + 1; + } + } + return iVar1; +} + + + +int printf(char *fmt,...) + +{ + undefined4 in_a1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list argp; + undefined4 uStack28; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + if (sys_log_all_enable != false) { + uStack28 = in_a1; + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + vprint(fmt,&uStack28); + } + return 0; +} + + + +int sprintf(char *buffer,char *format,...) + +{ + int iVar1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list ap; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + iVar1 = vsnprintf(buffer,0xffffffff,format,&uStack24); + return iVar1; +} + + + +int snprintf(char *buffer,size_t n,char *format,...) + +{ + int iVar1; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list ap; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + iVar1 = vsnprintf(buffer,n,format,&uStack20); + return iVar1; +} + + + +int sscanf(char *str,char *format,...) + +{ + int iVar1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list ap; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + iVar1 = vsscanf(str,format,&uStack24); + return iVar1; +} + + + +void set_bit(ulong *bitmap,uint bit) + +{ + bitmap[bit >> 5] = bitmap[bit >> 5] | 1 << (bit & 0x1f); + return; +} + + + +int vsscanf(char *buffer,char *format,va_list ap) + +{ + byte bVar1; + bool bVar2; + bool bVar3; + size_t sVar4; + uint uVar5; + uint bit; + byte *pbVar6; + int base; + uint uVar7; + byte **endptr; + byte **ppbVar8; + uint bit_00; + int iVar9; + byte *nptr; + byte *pbVar10; + size_t n; + byte *pbVar11; + int iVar12; + uint uVar13; + uint uStack132; + uint uStack128; + byte *pbStack100; + char *qq; + ulong matchmap [8]; + + uStack128 = 0; + uStack132 = 0; + iVar12 = 0; + pbVar11 = (byte *)0x0; + bVar2 = false; + bVar3 = false; + iVar9 = 0; + uVar5 = 0; + pbVar10 = (byte *)buffer; + n = 0xffffffff; + uVar13 = 0; +switchD_230824b8_caseD_7: + nptr = pbVar10; + pbVar6 = (byte *)format; + uVar7 = uVar5; + bVar1 = *pbVar6; + bit = (uint)bVar1; + format = (char *)(pbVar6 + 1); + if ((bVar1 == 0) || (uVar13 != 0)) { + if ((uVar13 == 1) && (iVar12 == 0)) { + iVar12 = -1; + } + return iVar12; + } + uVar5 = uVar7; + pbVar10 = nptr; + switch(uVar7) { + case 0: + if (bVar1 == 0x25) { + bVar2 = false; + bVar3 = false; + iVar9 = 0; + uVar5 = 1; + n = 0xffffffff; + uVar13 = uVar7; + goto switchD_230824b8_caseD_7; + } + uVar5 = (uint)(byte)_ctype_[bit + 1] & 8; + if ((_ctype_[bit + 1] & 8) == 0) { + uVar13 = 2; + if ((uint)*nptr != bit) goto switchD_230824b8_caseD_7; + nptr = nptr + 1; + } + else { + while (uVar5 = (uint)(byte)_ctype_[(uint)*nptr + 1] & 8, (_ctype_[(uint)*nptr + 1] & 8) != 0) + { + nptr = nptr + 1; + } + } + pbVar10 = nptr; + uVar13 = 0; + goto switchD_230824b8_caseD_7; + case 1: + if (bVar1 == 0x2a) { + bVar3 = true; + goto switchD_230824b8_caseD_7; + } + if ((0x29 < bVar1) && ((bit - 0x30 & 0xff) < 10)) { + bVar2 = true; + uVar5 = 2; + n = bit - 0x30; + goto switchD_230824b8_caseD_7; + } + break; + case 2: + if ((bit - 0x30 & 0xff) < 10) { + n = n * 10 + -0x30 + bit; + goto switchD_230824b8_caseD_7; + } + break; + case 3: + if (bVar1 == 0x6c) { + iVar9 = iVar9 + 1; + } + else { + if (0x6c < bVar1) { + if ((bVar1 == 0x74) || (bVar1 == 0x7a)) { + iVar9 = 1; + goto switchD_230824b8_caseD_7; + } + uVar7 = 0x71; +LAB_23082560: + if (bit == uVar7) goto LAB_23082564; + if (2 < iVar9) { + iVar9 = 2; + } + if (iVar9 < -2) { + iVar9 = -2; + } + if (bVar1 == 0x69) { + base = 0; +LAB_2308261a: + while( true ) { + uVar7 = (uint)*nptr; + if ((_ctype_[uVar7 + 1] & 8) == 0) break; + nptr = nptr + 1; + } + pbVar10 = nptr; + if (*nptr == 0) goto LAB_2308283a; + endptr = &pbStack100; + pbVar6 = nptr; + strntoumax((char *)nptr,(char **)endptr,base,n); + if (pbStack100 == nptr) goto LAB_230825be; + nptr = pbStack100; + if (!bVar3) { + iVar12 = iVar12 + 1; + } +set_integer: + uVar5 = 0; + pbVar10 = nptr; + if (!bVar3) { + if (iVar9 == 0) { + endptr = *(byte ***)ap; + ap = (byte **)ap + 1; + *endptr = pbVar6; +LAB_2308272a: + uVar5 = 0; + pbVar10 = nptr; + goto switchD_230824b8_caseD_7; + } + if (iVar9 < 1) { + if (iVar9 == -2) { + **(byte **)ap = (byte)pbVar6; + } + else { + if (iVar9 != -1) goto switchD_230824b8_caseD_7; + **(undefined2 **)ap = (short)pbVar6; + } + } + else { + if (iVar9 == 2) { + ppbVar8 = *(byte ***)ap; + *ppbVar8 = pbVar6; + *(byte ***)(ppbVar8 + 1) = endptr; + } + else { + if ((1 < iVar9) && (iVar9 != 0x7fffffff)) goto switchD_230824b8_caseD_7; + **(byte ***)ap = pbVar6; + } + } + ap = (byte **)ap + 1; + } + goto switchD_230824b8_caseD_7; + } + if (bVar1 < 0x6a) { + if (bVar1 == 0x58) { +scan_int: + base = 0x10; + goto LAB_2308261a; + } + if (0x58 < bVar1) { + if (bVar1 == 99) { + if (!bVar2) { + n = 1; + } + sVar4 = n - 1; + if (!bVar3) { + pbVar11 = *(byte **)ap; + ap = (byte **)ap + 1; + n = n - 1; + while (n != 0xffffffff) { + bVar1 = *nptr; + uVar7 = (uint)bVar1; + pbVar10 = nptr; + if (bVar1 == 0) goto LAB_2308283a; + nptr = nptr + 1; + *pbVar11 = bVar1; + n = n - 1; + pbVar11 = pbVar11 + 1; + } + iVar12 = iVar12 + 1; + goto LAB_2308272a; + } + do { + n = sVar4; + if (n == 0xffffffff) goto LAB_2308272a; + uVar7 = (uint)*nptr; + sVar4 = n - 1; + } while (*nptr != 0); + goto LAB_2308283a; + } + if (bVar1 == 100) goto LAB_230826ec; + if (bVar1 != 0x5b) goto LAB_230825be; + pbVar11 = (byte *)0x0; + if (!bVar3) { + pbVar11 = *(byte **)ap; + ap = (byte **)ap + 1; + } + memset(&qq,0,0x20); + uStack132 = 0; + uVar5 = 4; + goto switchD_230824b8_caseD_7; + } + if (bVar1 == 0x25) { + if ((uint)*nptr == bit) { + nptr = nptr + 1; + goto LAB_2308272a; + } + } + else { + if (bVar1 == 0x50) goto LAB_230826e0; + } + } + else { + if (bVar1 == 0x70) { +LAB_230826e0: + base = 0; + iVar9 = 0x7fffffff; + goto LAB_2308261a; + } + if (bVar1 < 0x71) { + if (bVar1 == 0x6e) { + pbVar6 = nptr + -(int)buffer; + endptr = (byte **)((int)pbVar6 >> 0x1f); + goto set_integer; + } + base = 8; + if (bVar1 == 0x6f) goto LAB_2308261a; + } + else { + if (bVar1 == 0x75) { +LAB_230826ec: + base = 10; + goto LAB_2308261a; + } + if (bVar1 == 0x78) goto scan_int; + if (bVar1 == 0x73) { + n = n - 1; + if (bVar3) { + while (n != 0xffffffff) { + uVar7 = (uint)*nptr; + pbVar10 = nptr; + if (*nptr == 0) goto LAB_2308283a; + if ((_ctype_[uVar7 + 1] & 8) != 0) break; + nptr = nptr + 1; + n = n - 1; + } + goto LAB_2308272a; + } + pbVar11 = *(byte **)ap; + ap = (byte **)ap + 1; + uVar13 = 1; + pbVar10 = pbVar11; + while (n != 0xffffffff) { + bVar1 = *nptr; + uVar13 = (uint)bVar1; + if ((bVar1 == 0) || ((_ctype_[uVar13 + 1] & 8) != 0)) break; + *pbVar10 = bVar1; + nptr = nptr + 1; + pbVar10 = pbVar10 + 1; + n = n - 1; + } + if (pbVar10 != pbVar11) { + *pbVar10 = 0; + iVar12 = iVar12 + 1; + } + uVar13 = (uint)(uVar13 == 0); + uVar5 = 0; + pbVar10 = nptr; + goto switchD_230824b8_caseD_7; + } + } + } +LAB_230825be: + uVar13 = 2; + uVar5 = 0; + pbVar10 = nptr; + goto switchD_230824b8_caseD_7; + } + if (bVar1 == 0x68) { + iVar9 = iVar9 + -1; + } + else { + if (bVar1 != 0x6a) { + uVar7 = 0x4c; + goto LAB_23082560; + } +LAB_23082564: + iVar9 = 2; + } + } + goto switchD_230824b8_caseD_7; + case 4: + if (bVar1 != 0x5e) { + set_bit((ulong *)&qq,bit); + goto LAB_230827ce; + } + uStack132 = 1; + goto switchD_230824b8_caseD_7; + case 5: + if (bVar1 == 0x5d) { +match_run: + bit = 1; + while (n != 0) { + bVar1 = *pbVar10; + bit = (uint)bVar1; + if ((bVar1 == 0) || (uStack132 == ((uint)(&qq)[bVar1 >> 5] >> (bit & 0x1f) & 1))) break; + if (pbVar11 != (byte *)0x0) { + *pbVar11 = bVar1; + pbVar11 = pbVar11 + 1; + } + pbVar10 = pbVar10 + 1; + } + if ((nptr == pbVar10) || (pbVar11 == (byte *)0x0)) { + uVar13 = 2; + } + else { + *pbVar11 = 0; + iVar12 = iVar12 + 1; + } + pbStack100 = nptr; + if (bit == 0) { +LAB_2308283a: + uVar13 = 1; + uVar5 = uVar7; + } + } + else { + if (bVar1 == 0x2d) { + uStack128 = 0x2d; + uVar5 = 6; + } + else { + set_bit((ulong *)&qq,bit); + } + } + goto switchD_230824b8_caseD_7; + case 6: + bit_00 = uStack128; + if (bVar1 == 0x5d) goto match_run; + while ((int)bit_00 < (int)bit) { + set_bit((ulong *)&qq,bit_00); + bit_00 = bit_00 + 1; + } +LAB_230827ce: + uVar5 = 5; + default: + goto switchD_230824b8_caseD_7; + } + uVar5 = 3; + format = (char *)pbVar6; + goto switchD_230824b8_caseD_7; +} + + + +uintmax_t strntoumax(char *nptr,char **endptr,int base,size_t n) + +{ + byte *pbVar1; + uint uVar2; + uint uVar3; + uintmax_t in_fa0; + + while (n != 0) { + if ((_ctype_[(uint)(byte)*nptr + 1] & 8) == 0) { + if (((uint)(byte)*nptr - 0x2b & 0xfd) == 0) { + nptr = (char *)((byte *)nptr + 1); + n = n - 1; + } + if (base != 0) { + if ((((base == 0x10) && (1 < n)) && (*nptr == 0x30)) && ((((byte *)nptr)[1] & 0xdf) == 0x58) + ) { + n = n - 2; + nptr = (char *)((byte *)nptr + 2); + } + goto LAB_230828ea; + } + if (n < 2) { + if (n == 0) goto joined_r0x23082992; + if (*nptr != 0x30) { + n = 1; + base = 10; + goto LAB_230828ea; + } + } + else { + base = 10; + if (*nptr != 0x30) goto LAB_230828ea; + if ((((byte *)nptr)[1] & 0xdf) == 0x58) { + n = n - 2; + nptr = (char *)((byte *)nptr + 2); + base = 0x10; + goto LAB_230828ea; + } + } + n = n - 1; + nptr = (char *)((byte *)nptr + 1); + base = 8; + goto LAB_230828ea; + } + nptr = (char *)((byte *)nptr + 1); + n = n - 1; + } + if (base != 0) { +LAB_230828ea: + pbVar1 = (byte *)nptr + n; + while ((byte *)nptr != pbVar1) { + uVar3 = (uint)(byte)*nptr; + uVar2 = uVar3 - 0x30; + if (9 < uVar2) { + if (uVar3 - 0x41 < 0x1a) { + uVar2 = uVar3 - 0x37; + } + else { + if (0x19 < uVar3 - 0x61) break; + uVar2 = uVar3 - 0x57; + } + } + if (((int)uVar2 < 0) || (base <= (int)uVar2)) break; + nptr = (char *)((byte *)nptr + 1); + } + } +joined_r0x23082992: + if (endptr != (char **)0x0) { + *endptr = nptr; + } + return in_fa0; +} + + + +BL_Err_Type UART_Init(UART_ID_Type uartId,UART_CFG_Type *uartCfg) + +{ + UART_Parity_Type UVar1; + undefined3 in_register_00002029; + uint *puVar2; + uint uVar3; + uint uVar4; + uint uVar5; + uint uVar6; + + puVar2 = (uint *)uartAddr[CONCAT31(in_register_00002029,uartId)]; + uVar5 = uartCfg->uartClk / uartCfg->baudRate; + if (4 < ((uartCfg->uartClk * 10) / uartCfg->baudRate) % 10) { + uVar5 = uVar5 + 1; + } + puVar2[2] = uVar5 - 1 & 0xffff | (uVar5 - 1) * 0x10000; + UVar1 = uartCfg->parity; + uVar5 = *puVar2; + uVar6 = puVar2[1]; + if (UVar1 == UART_PARITY_ODD) { + uVar5 = uVar5 | 0x30; + uVar6 = uVar6 | 0x30; + } + else { + if (UVar1 == UART_PARITY_NONE) { + uVar5 = uVar5 & 0xffffffef; + uVar6 = uVar6 & 0xffffffef; + } + else { + if (UVar1 == UART_PARITY_EVEN) { + uVar5 = uVar5 & 0xffffffdf | 0x10; + uVar6 = uVar6 & 0xffffffdf | 0x10; + } + } + } + uVar3 = ((uint)uartCfg->dataBits + 4) * 0x100; + uVar4 = uVar5 & 0xfffff8ff | uVar3; + uVar3 = uVar6 & 0xfffff8ff | uVar3; + uVar5 = ((uint)uartCfg->stopBits + 1) * 0x1000; + uVar6 = uVar4 & 0xffffcffd | uVar5; + if (uartCfg->ctsFlowControl == ENABLE) { + uVar6 = uVar4 & 0xffffcfff | uVar5 | 2; + } + if (uartCfg->rxDeglitch == ENABLE) { + uVar3 = uVar3 | 0x800; + } + else { + uVar3 = uVar3 & 0xfffff7ff; + } + uVar5 = uVar3 & 0xfffffffd; + if (uartCfg->rtsSoftwareControl == ENABLE) { + uVar5 = uVar3 | 2; + } + *puVar2 = uVar6; + puVar2[1] = uVar5; + uVar5 = puVar2[3] & 0xfffffffe; + if (uartCfg->byteBitInverse == UART_MSB_FIRST) { + uVar5 = puVar2[3] | 1; + } + puVar2[3] = uVar5; + return SUCCESS; +} + + + +BL_Err_Type UART_FifoConfig(UART_ID_Type uartId,UART_FifoCfg_Type *fifoCfg) + +{ + undefined3 in_register_00002029; + uint32_t uVar1; + uint uVar2; + uint uVar3; + + uVar1 = uartAddr[CONCAT31(in_register_00002029,uartId)]; + *(uint *)(uVar1 + 0x84) = + (((uint)fifoCfg->txFifoDmaThreshold - 1) * 0x10000 | *(uint *)(uVar1 + 0x84) & 0xffe0ffff) & + 0xe0ffffff | ((uint)fifoCfg->rxFifoDmaThreshold - 1) * 0x1000000; + uVar3 = *(uint *)(uVar1 + 0x80) & 0xfffffffe; + if (fifoCfg->txFifoDmaEnable == ENABLE) { + uVar3 = *(uint *)(uVar1 + 0x80) | 1; + } + uVar2 = uVar3 & 0xfffffffd; + if (fifoCfg->rxFifoDmaEnable == ENABLE) { + uVar2 = uVar3 | 2; + } + *(uint *)(uVar1 + 0x80) = uVar2; + return SUCCESS; +} + + + +BL_Err_Type UART_Enable(UART_ID_Type uartId,UART_Direction_Type direct) + +{ + undefined3 in_register_00002029; + uint *puVar1; + + puVar1 = (uint *)uartAddr[CONCAT31(in_register_00002029,uartId)]; + if ((direct & ~UART_TXRX) == UART_TX) { + *puVar1 = *puVar1 | 1; + } + if ((byte)(direct + ~UART_TX) < 2) { + puVar1[1] = puVar1[1] | 1; + } + return SUCCESS; +} + + + +BL_Err_Type UART_Disable(UART_ID_Type uartId,UART_Direction_Type direct) + +{ + undefined3 in_register_00002029; + uint *puVar1; + + puVar1 = (uint *)uartAddr[CONCAT31(in_register_00002029,uartId)]; + if ((direct & ~UART_TXRX) == UART_TX) { + *puVar1 = *puVar1 & 0xfffffffe; + } + if ((byte)(direct + ~UART_TX) < 2) { + puVar1[1] = puVar1[1] & 0xfffffffe; + } + return SUCCESS; +} + + + +BL_Err_Type UART_SetRxTimeoutValue(UART_ID_Type uartId,uint8_t time) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + + *(uint *)(uartAddr[CONCAT31(in_register_00002029,uartId)] + 0x18) = + CONCAT31(in_register_0000202d,time) - 1U | + *(uint *)(uartAddr[CONCAT31(in_register_00002029,uartId)] + 0x18) & 0xffffff00; + return SUCCESS; +} + + + +BL_Err_Type UART_TxFreeRun(UART_ID_Type uartId,BL_Fun_Type txFreeRun) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + uint uVar1; + + uVar1 = *(uint *)uartAddr[CONCAT31(in_register_00002029,uartId)]; + if (CONCAT31(in_register_0000202d,txFreeRun) == 1) { + uVar1 = uVar1 | 4; + } + else { + uVar1 = uVar1 & 0xfffffffb; + } + *(uint *)uartAddr[CONCAT31(in_register_00002029,uartId)] = uVar1; + return SUCCESS; +} + + + +BL_Err_Type UART_IntMask(UART_ID_Type uartId,UART_INT_Type intType,BL_Mask_Type intMask) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + uint uVar1; + undefined3 in_register_00002031; + uint uVar2; + + uVar2 = *(uint *)(uartAddr[CONCAT31(in_register_00002029,uartId)] + 0x24); + if (CONCAT31(in_register_0000202d,intType) == 8) { + uVar1 = 0; + if (CONCAT31(in_register_00002031,intMask) == 1) { + uVar1 = uVar2 | 0xff; + } + } + else { + uVar1 = 1 << ((uint)intType & 0x1f); + if (CONCAT31(in_register_00002031,intMask) == 1) { + uVar1 = uVar1 | uVar2; + } + else { + uVar1 = ~uVar1 & uVar2; + } + } + *(uint *)(uartAddr[CONCAT31(in_register_00002029,uartId)] + 0x24) = uVar1; + return SUCCESS; +} + + + +uint8_t UART_GetTxFifoCount(UART_ID_Type uartId) + +{ + undefined3 in_register_00002029; + + return (uint8_t)((byte)*(undefined4 *)(uartAddr[CONCAT31(in_register_00002029,uartId)] + 0x84) & + 0x3f); +} + + + +BL_Err_Type UART_SendData(UART_ID_Type uartId,uint8_t *data,uint32_t len) + +{ + int iVar1; + uint uVar2; + uint8_t uVar3; + undefined3 in_register_00002029; + undefined3 extraout_var; + uint8_t *puVar4; + uint32_t uVar5; + + uVar5 = uartAddr[CONCAT31(in_register_00002029,uartId)]; + iVar1 = 160000; + uVar2 = 0; + do { + while( true ) { + if (len <= uVar2) { + return SUCCESS; + } + uVar3 = UART_GetTxFifoCount(uartId); + if (CONCAT31(extraout_var,uVar3) == 0) break; + puVar4 = data + uVar2; + uVar2 = uVar2 + 1; + iVar1 = 160000; + *(uint8_t *)(uVar5 + 0x88) = *puVar4; + } + iVar1 = iVar1 + -1; + } while (iVar1 != 0); + return TIMEOUT; +} + + + +uint8_t UART_GetRxFifoCount(UART_ID_Type uartId) + +{ + undefined3 in_register_00002029; + + return (uint8_t)((byte)((uint)*(undefined4 *) + (uartAddr[CONCAT31(in_register_00002029,uartId)] + 0x84) >> 8) & + 0x3f); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Reset(void) + +{ + _DAT_4000f90c = _DAT_4000f90c & 0xfffffffb; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Enable(void) + +{ + _DAT_4000f90c = _DAT_4000f90c | 1; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Disable(void) + +{ + _DAT_4000f90c = _DAT_4000f90c & 0xfffffffe; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Channel_Config(ADC_Chan_Type posCh,ADC_Chan_Type negCh,BL_Fun_Type contEn) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + + _DAT_4000f90c = + CONCAT31(in_register_00002029,posCh) << 8 | _DAT_4000f90c & 0xffffe007 | + CONCAT31(in_register_0000202d,negCh) << 3; + _DAT_4000f910 = + (CONCAT31(in_register_00002031,contEn) << 1 | _DAT_4000f910 & 0xfffffffd) & 0xfdffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Start(void) + +{ + _DAT_4000f90c = _DAT_4000f90c & 0xfffffffd; + BL602_Delay_US(100); + _DAT_4000f90c = _DAT_4000f90c | 2; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_FIFO_Cfg(ADC_FIFO_Cfg_Type *fifoCfg) + +{ + _DAT_40002000 = + (uint)fifoCfg->fifoThreshold << 0x16 | _DAT_40002000 & 0xff3ffffe | (uint)fifoCfg->dmaEn | 2; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t ADC_Get_FIFO_Count(void) + +{ + return (uint8_t)((byte)((uint)_DAT_40002000 >> 0x10) & 0x3f); +} + + + +// WARNING: Control flow encountered bad instruction data + +void ADC_Parse_Result(uint32_t *orgVal,uint32_t len,ADC_Result_Type *result) + +{ + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Tsen_Init(ADC_TSEN_MOD_Type tsenMod) + +{ + undefined3 in_register_00002029; + + _DAT_4000f90c = _DAT_4000f90c & 0x87ffffff | 0xc0000; + _DAT_4000f910 = _DAT_4000f910 | 0x4000000; + _DAT_4000f914 = + (_DAT_4000f914 & 0xfc3ffdf | CONCAT31(in_register_00002029,tsenMod) << 5) & 0xffffa07f | + 0x20000140; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_SET_TSVBE_LOW(void) + +{ + _DAT_4000f914 = _DAT_4000f914 & 0x7fffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_SET_TSVBE_HIGH(void) + +{ + _DAT_4000f914 = _DAT_4000f914 | 0x80000000; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t TSEN_Get_V_Error(void) + +{ + BL_Fun_Type BVar1; + uint8_t uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint uVar3; + uint32_t uStack44; + uint32_t regVal; + ADC_Result_Type result; + + uStack44 = 0; + _DAT_40002000 = _DAT_40002000 | 2; + ADC_SET_TSVBE_LOW(); + ADC_Start(); + do { + uVar2 = ADC_Get_FIFO_Count(); + BVar1 = adcGainCoeffCal.adcGainCoeffEnable; + } while (CONCAT31(extraout_var,uVar2) == 0); + uStack44 = _DAT_40002004; + adcGainCoeffCal.adcGainCoeffEnable = DISABLE; + ADC_Parse_Result(&uStack44,1,(ADC_Result_Type *)®Val); + uVar3 = (uint)regVal._2_2_; + _DAT_40002000 = _DAT_40002000 | 2; + adcGainCoeffCal.adcGainCoeffEnable = BVar1; + ADC_SET_TSVBE_HIGH(); + ADC_Start(); + do { + uVar2 = ADC_Get_FIFO_Count(); + BVar1 = adcGainCoeffCal.adcGainCoeffEnable; + } while (CONCAT31(extraout_var_00,uVar2) == 0); + uStack44 = _DAT_40002004; + adcGainCoeffCal.adcGainCoeffEnable = DISABLE; + ADC_Parse_Result(&uStack44,1,(ADC_Result_Type *)®Val); + adcGainCoeffCal.adcGainCoeffEnable = BVar1; + return uVar3 - regVal._2_2_; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +float TSEN_Get_Temp(uint32_t tsen_offset) + +{ + BL_Fun_Type BVar1; + uint8_t uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint32_t *orgVal; + SFtype SVar3; + undefined4 uVar4; + uint32_t uStack44; + uint32_t regVal; + ADC_Result_Type result; + + uStack44 = 0; + _DAT_40002000 = _DAT_40002000 | 2; + uVar4 = ADC_SET_TSVBE_LOW(); + ADC_Start(uVar4); + do { + uVar2 = ADC_Get_FIFO_Count(); + BVar1 = adcGainCoeffCal.adcGainCoeffEnable; + } while (CONCAT31(extraout_var,uVar2) == 0); + uStack44 = _DAT_40002004; + adcGainCoeffCal.adcGainCoeffEnable = DISABLE; + ADC_Parse_Result(&uStack44,1,(ADC_Result_Type *)®Val); + _DAT_40002000 = _DAT_40002000 | 2; + adcGainCoeffCal.adcGainCoeffEnable = BVar1; + uVar4 = ADC_SET_TSVBE_HIGH(); + ADC_Start(uVar4); + do { + uVar2 = ADC_Get_FIFO_Count(); + BVar1 = adcGainCoeffCal.adcGainCoeffEnable; + } while (CONCAT31(extraout_var_00,uVar2) == 0); + orgVal = &uStack44; + uStack44 = _DAT_40002004; + adcGainCoeffCal.adcGainCoeffEnable = DISABLE; + ADC_Parse_Result(orgVal,1,(ADC_Result_Type *)®Val); + adcGainCoeffCal.adcGainCoeffEnable = BVar1; + __extendsfdf2((SFtype)orgVal); + __divdf3(); + SVar3 = __truncdfsf2(); + return (float)SVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Init(ADC_CFG_Type *cfg) + +{ + uint uVar1; + uint uVar2; + + _DAT_4000f910 = + (uint)cfg->resWidth << 2 | + ((uint)cfg->clkDiv << 0x12 | + (uint)cfg->v11Sel << 0x1b | (uint)cfg->v18Sel << 0x1d | _DAT_4000f910 & 0x8001fffe | + (uint)cfg->offsetCalibEn) & 0xffffffe3; + if ((cfg->gain1 | cfg->gain2) == 0) { + uVar1 = 0xfffe1fff; + uVar2 = 0x8000; + } + else { + uVar1 = 0xfffe3fff; + uVar2 = 0x12000; + } + _DAT_4000f914 = + ((uint)cfg->biasSel << 0x11 | + (uint)cfg->gain2 << 0x16 | (uint)cfg->gain1 << 0x19 | _DAT_4000f914 & 0x803dffff) & uVar1 & + 0xffffe073 | uVar2 | (uint)cfg->vcm << 7 | (uint)cfg->vref << 3 | 0x1000 | + (uint)cfg->inputMode << 2; + _DAT_4000f938 = (int)cfg->offsetCalibVal | _DAT_4000f938 & 0xffff0000; + // WARNING: Treating indirect jump as call + ADC_Gain_Trim(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type Sec_Eng_SHA256_Update(SEC_Eng_SHA256_Ctx *shaCtx,uint8_t *input,uint32_t len) + +{ + byte bVar1; + uint uVar2; + int iVar3; + uint n; + uint32_t *psrc; + uint uVar4; + + uVar2 = _DAT_40004000; + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + bVar1 = shaCtx->shaFeed; + uVar4 = shaCtx->total[0] & 0x3f; + n = shaCtx->total[0] + len; + shaCtx->total[0] = n; + if (n < len) { + shaCtx->total[1] = shaCtx->total[1] + 1; + } + if ((uVar4 != 0) && (n = 0x40 - uVar4, n <= len)) { + BL602_MemCpy_Fast((void *)((int)shaCtx->shaBuf + uVar4),input,n); + _DAT_40004004 = shaCtx->shaBuf; + _DAT_40004000 = (uint)bVar1 << 6 | uVar2 & 0xffbf | 0x10002; + len = (len - 0x40) + uVar4; + shaCtx->shaFeed = '\x01'; + input = input + n; + uVar4 = 0; + } + psrc = (uint32_t *)input; + if (0x3f < len) { + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + _DAT_40004000 = (len >> 6) << 0x10 | (uint)shaCtx->shaFeed << 6 | _DAT_40004000 & 0xffbf | 2; + psrc = (uint32_t *)((int)input + (len & 0xffffffc0)); + _DAT_40004004 = (uint32_t *)input; + shaCtx->shaFeed = '\x01'; + } + if ((len & 0x3f) != 0) { + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + BL602_MemCpy_Fast((void *)((int)shaCtx->shaBuf + uVar4),psrc,len & 0x3f); + } + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_SHA256_Init(SEC_Eng_SHA256_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo, + SEC_ENG_SHA_Type shaType,uint32_t *shaTmpBuf,uint32_t *padding) + +{ + undefined3 in_register_00002031; + + _DAT_40004000 = CONCAT31(in_register_00002031,shaType) << 2 | _DAT_40004000 & 0xffffffe3; + memset(shaCtx,0,0x14); + shaCtx->shaPadding = padding; + shaCtx->shaBuf = shaTmpBuf; + BL602_MemSet(padding,'\0',0x40); + // WARNING: Treating indirect jump as call + BL602_MemSet(shaCtx->shaPadding,-0x80,1); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_SHA_Start(SEC_ENG_SHA_ID_Type shaNo) + +{ + _DAT_40004000 = _DAT_40004000 & 0xffffffbf | 0x20; + return; +} + + + +BL_Err_Type +Sec_Eng_SHA256_Update + (SEC_Eng_SHA256_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,uint8_t *input,uint32_t len) + +{ + BL_Err_Type BVar1; + + if (len != 0) { + BVar1 = Sec_Eng_SHA256_Update(shaCtx,input,len); + return BVar1; + } + return SUCCESS; +} + + + +// WARNING: Could not reconcile some variable overlaps +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +Sec_Eng_SHA256_Finish(SEC_Eng_SHA256_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,uint8_t *hash) + +{ + undefined4 uVar1; + uint uVar2; + int iVar3; + uint uVar4; + undefined uStack24; + undefined uStack23; + ushort uStack22; + uint8_t msgLen [8]; + + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + uVar2 = shaCtx->total[0]; + uVar4 = shaCtx->total[1] << 3; + uStack24 = (undefined)(uVar4 >> 0x18); + uStack23 = (undefined)(uVar4 >> 0x10); + uStack22 = (ushort)((uVar4 | uVar2 >> 0x1d) << 8) | (ushort)(uVar4 >> 8) & 0xff; + msgLen[0] = (uint8_t)((uVar2 << 3) >> 0x18); + msgLen[1] = (uint8_t)((uVar2 << 3) >> 0x10); + msgLen._2_2_ = (ushort)((uVar2 << 0x13) >> 0x18) | (ushort)(uVar2 << 0xb); + if ((uVar2 & 0x3f) < 0x38) { + iVar3 = 0x38; + } + else { + iVar3 = 0x78; + } + Sec_Eng_SHA256_Update(shaCtx,shaNo,(uint8_t *)shaCtx->shaPadding,iVar3 - (uVar2 & 0x3f)); + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + BL602_MemCpy_Fast(shaCtx->shaPadding,&uStack24,8); + Sec_Eng_SHA256_Update(shaCtx,(uint8_t *)shaCtx->shaPadding,8); + uVar1 = _DAT_40004010; + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + uVar2 = _DAT_40004000 >> 2; + *hash = (uint8_t)_DAT_40004010; + hash[1] = (uint8_t)((uint)uVar1 >> 8); + hash[2] = (uint8_t)((uint)uVar1 >> 0x10); + hash[3] = (uint8_t)((uint)uVar1 >> 0x18); + uVar1 = _DAT_40004014; + hash[4] = (uint8_t)_DAT_40004014; + hash[5] = (uint8_t)((uint)uVar1 >> 8); + hash[6] = (uint8_t)((uint)uVar1 >> 0x10); + hash[7] = (uint8_t)((uint)uVar1 >> 0x18); + uVar1 = _DAT_40004018; + hash[8] = (uint8_t)_DAT_40004018; + hash[9] = (uint8_t)((uint)uVar1 >> 8); + hash[10] = (uint8_t)((uint)uVar1 >> 0x10); + hash[0xb] = (uint8_t)((uint)uVar1 >> 0x18); + uVar1 = _DAT_4000401c; + hash[0xc] = (uint8_t)_DAT_4000401c; + hash[0xd] = (uint8_t)((uint)uVar1 >> 8); + hash[0xe] = (uint8_t)((uint)uVar1 >> 0x10); + hash[0xf] = (uint8_t)((uint)uVar1 >> 0x18); + uVar1 = _DAT_40004020; + hash[0x10] = (uint8_t)_DAT_40004020; + hash[0x11] = (uint8_t)((uint)uVar1 >> 8); + hash[0x13] = (uint8_t)((uint)uVar1 >> 0x18); + hash[0x12] = (uint8_t)((uint)uVar1 >> 0x10); + uVar1 = _DAT_40004024; + if ((uVar2 & 6) == 0) { + hash[0x14] = (uint8_t)_DAT_40004024; + hash[0x15] = (uint8_t)((uint)uVar1 >> 8); + hash[0x16] = (uint8_t)((uint)uVar1 >> 0x10); + hash[0x17] = (uint8_t)((uint)uVar1 >> 0x18); + uVar1 = _DAT_40004028; + hash[0x18] = (uint8_t)_DAT_40004028; + hash[0x19] = (uint8_t)((uint)uVar1 >> 8); + hash[0x1a] = (uint8_t)((uint)uVar1 >> 0x10); + hash[0x1b] = (uint8_t)((uint)uVar1 >> 0x18); + uVar1 = _DAT_4000402c; + if ((uVar2 & 7) == 0) { + hash[0x1c] = (uint8_t)_DAT_4000402c; + hash[0x1d] = (uint8_t)((uint)uVar1 >> 8); + hash[0x1e] = (uint8_t)((uint)uVar1 >> 0x10); + hash[0x1f] = (uint8_t)((uint)uVar1 >> 0x18); + } + } + _DAT_40004000 = _DAT_40004000 & 0xffffff9f; + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void DMA_Enable(void) + +{ + _DAT_4000c030 = _DAT_4000c030 | 1; + return; +} + + + +void DMA_Channel_Enable(uint8_t ch) + +{ + undefined3 in_register_00002029; + uint *puVar1; + + puVar1 = (uint *)(CONCAT31(in_register_00002029,ch) * 0x100 + 0x4000c110); + *puVar1 = *puVar1 | 1; + return; +} + + + +void DMA_LLI_Init(uint8_t ch,DMA_LLI_Cfg_Type *lliCfg) + +{ + undefined3 in_register_00002029; + uint *puVar1; + + puVar1 = (uint *)(CONCAT31(in_register_00002029,ch) * 0x100 + 0x4000c110); + *puVar1 = (uint)lliCfg->dir << 0xb | *puVar1 & 0xffffc001 | (uint)lliCfg->dstPeriph << 6 | + (uint)lliCfg->srcPeriph << 1; + return; +} + + + +void DMA_LLI_Update(uint8_t ch,uint32_t LLI) + +{ + undefined3 in_register_00002029; + + // WARNING: Treating indirect jump as call + BL602_MemCpy4((uint32_t *)(CONCAT31(in_register_00002029,ch) * 0x100 + 0x4000c100),(uint32_t *)LLI + ,4); + return; +} + + + +void DMA_IntMask(uint8_t ch,DMA_INT_Type intType,BL_Mask_Type intMask) + +{ + undefined3 in_register_00002029; + int iVar1; + uint *puVar2; + undefined3 in_register_0000202d; + int iVar3; + undefined3 in_register_00002031; + int iVar4; + uint uVar5; + uint uVar6; + + iVar4 = CONCAT31(in_register_00002031,intMask); + iVar3 = CONCAT31(in_register_0000202d,intType); + iVar1 = CONCAT31(in_register_00002029,ch) * 0x100; + if (iVar3 == 1) { + puVar2 = (uint *)(iVar1 + 0x4000c110); + uVar6 = *puVar2; + if (iVar4 == 0) { + uVar6 = uVar6 & 0xffffbfff; + goto LAB_230837d0; + } + uVar5 = 0x4000; + } + else { + if (iVar3 == 0) { + uVar6 = *(uint *)(iVar1 + 0x4000c110); + iVar3 = -0x8000; + if (iVar4 != 0) { + uVar5 = 0x8000; + goto LAB_230837b0; + } + } + else { + if (iVar3 != 2) { + return; + } + uVar6 = *(uint *)(iVar1 + 0x4000c110); + if (iVar4 != 0) { + uVar5 = 0xc000; +LAB_230837b0: + puVar2 = (uint *)(iVar1 + 0x4000c10c); + *(uint *)(iVar1 + 0x4000c110) = uVar6 | uVar5; + uVar6 = *puVar2 & 0x7fffffff; + goto LAB_230837d0; + } + iVar3 = -0xc000; + } + puVar2 = (uint *)(iVar1 + 0x4000c10c); + *(uint *)(iVar1 + 0x4000c110) = uVar6 & iVar3 - 1U; + uVar6 = *puVar2; + uVar5 = 0x80000000; + } + uVar6 = uVar6 | uVar5; +LAB_230837d0: + *puVar2 = uVar6; + return; +} + + + +void Default_Handler(void) + +{ + bflb_platform_printf("Default_Handler\r\n"); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Set_UART_CLK(uint8_t enable,HBN_UART_CLK_Type clkSel,uint8_t div) + +{ + undefined3 in_register_00002029; + undefined3 in_register_00002031; + uint uVar1; + + _DAT_40000008 = CONCAT31(in_register_00002031,div) | _DAT_40000008 & 0xffffffe8; + HBN_Set_UART_CLK_Sel(clkSel); + uVar1 = _DAT_40000008 | 0x10; + if (CONCAT31(in_register_00002029,enable) == 0) { + uVar1 = _DAT_40000008 & 0xffffffef; + } + _DAT_40000008 = uVar1; + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Set_EM_Sel(GLB_EM_Type emType) + +{ + undefined3 in_register_00002029; + + _DAT_4000007c = CONCAT31(in_register_00002029,emType) | _DAT_4000007c & 0xfffffff0; + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Set_ADC_CLK(uint8_t enable,GLB_ADC_CLK_Type clkSel,uint8_t div) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + uint uVar1; + + uVar1 = (CONCAT31(in_register_00002031,div) | _DAT_400000a4 & 0xfffffec0) & 0xffffff7f | + CONCAT31(in_register_0000202d,clkSel) << 7; + _DAT_400000a4 = uVar1 & 0xfffffeff; + if (CONCAT31(in_register_00002029,enable) != 0) { + _DAT_400000a4 = uVar1 | 0x100; + } + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_UART_Fun_Sel(GLB_UART_SIG_Type sig,GLB_UART_SIG_FUN_Type fun) + +{ + undefined3 in_register_0000202d; + + _DAT_400000c0 = + ~(0xf << (((uint)sig & 7) << 2)) & _DAT_400000c0 | + CONCAT31(in_register_0000202d,fun) << (((uint)sig & 7) << 2); + return SUCCESS; +} + + + +BL_Err_Type GLB_GPIO_Write(GLB_GPIO_Type gpioPin,uint32_t val) + +{ + undefined3 in_register_00002029; + uint uVar1; + uint uVar2; + uint *puVar3; + + puVar3 = (uint *)((CONCAT31(in_register_00002029,gpioPin) >> 5) * 4 + 0x40000188); + uVar2 = *puVar3; + uVar1 = 1 << ((uint)gpioPin & 0x1f); + if (val == 0) { + uVar1 = ~uVar1 & uVar2; + } + else { + uVar1 = uVar1 | uVar2; + } + *puVar3 = uVar1; + return SUCCESS; +} + + + +uint32_t GLB_GPIO_Read(GLB_GPIO_Type gpioPin) + +{ + undefined3 in_register_00002029; + + return (uint)((1 << ((uint)gpioPin & 0x1f) & + *(uint *)((CONCAT31(in_register_00002029,gpioPin) >> 5) * 4 + 0x40000180)) != 0); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Set_UART_CLK_Sel(HBN_UART_CLK_Type clkSel) + +{ + undefined3 in_register_00002029; + + _DAT_4000f030 = CONCAT31(in_register_00002029,clkSel) << 2 | _DAT_4000f030 & 0xfffffffb; + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Get_RTC_Timer_Val(uint32_t *valLow,uint32_t *valHigh) + +{ + _DAT_4000f010 = _DAT_4000f010 & 0x7fffffff; + *valLow = _DAT_4000f00c; + *valHigh = _DAT_4000f010 & 0xff; + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Clear_IRQ(HBN_INT_Type irqType) + +{ + uint uVar1; + + uVar1 = 1 << ((uint)irqType & 0x1f); + _DAT_4000f01c = ~uVar1 & (_DAT_4000f01c | uVar1); + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Aon_Pad_IeSmt_Cfg(uint8_t padCfg) + +{ + undefined3 in_register_00002029; + + _DAT_4000f014 = CONCAT31(in_register_00002029,padCfg) << 8 | _DAT_4000f014 & 0xfffffeff; + return SUCCESS; +} + + + +void TIMER_SetCompValue(TIMER_Chan_Type timerCh,TIMER_Comp_ID_Type cmpNo,uint32_t val) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + + *(uint32_t *) + ((CONCAT31(in_register_00002029,timerCh) * 3 + CONCAT31(in_register_0000202d,cmpNo)) * 4 + + 0x4000a510) = val; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void TIMER_SetCountMode(TIMER_Chan_Type timerCh,TIMER_CountMode_Type countMode) + +{ + undefined3 in_register_0000202d; + + _DAT_4000a588 = + ~(1 << ((uint)timerCh + 1 & 0x1f)) & _DAT_4000a588 | + CONCAT31(in_register_0000202d,countMode) << ((uint)timerCh + 1 & 0x1f); + return; +} + + + +void TIMER_ClearIntStatus(TIMER_Chan_Type timerCh,TIMER_Comp_ID_Type cmpNo) + +{ + undefined3 in_register_00002029; + uint *puVar1; + + puVar1 = (uint *)(CONCAT31(in_register_00002029,timerCh) * 4 + 0x4000a578); + *puVar1 = 1 << ((uint)cmpNo & 0x1f) | *puVar1; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type TIMER_Init(TIMER_CFG_Type *timerCfg) + +{ + TIMER_Chan_Type timerCh; + uint uVar1; + uint uVar2; + + timerCh = timerCfg->timerCh; + if (timerCh == TIMER_CH0) { + _DAT_4000a500 = _DAT_4000a500 & 0xfffffff3; + uVar1 = (uint)timerCfg->clkSrc << 2; + } + else { + _DAT_4000a500 = _DAT_4000a500 & 0xffffff9f; + uVar1 = (uint)timerCfg->clkSrc << 5; + } + _DAT_4000a500 = uVar1 | _DAT_4000a500; + if (timerCh == TIMER_CH0) { + uVar1 = 0xffff00ff; + uVar2 = (uint)timerCfg->clockDivision << 8; + } + else { + uVar1 = 0xff00ffff; + uVar2 = (uint)timerCfg->clockDivision << 0x10; + } + _DAT_4000a5bc = uVar2 | uVar1 & _DAT_4000a5bc; + TIMER_SetCountMode(timerCh,timerCfg->countMode); + *(uint *)((uint)timerCh * 4 + 0x4000a55c) = (uint)timerCfg->plTrigSrc; + if (timerCfg->countMode == TIMER_COUNT_PRELOAD) { + *(uint32_t *)((uint)timerCh * 4 + 0x4000a550) = timerCfg->preLoadVal; + } + TIMER_SetCompValue(timerCh,TIMER_COMP_ID_0,timerCfg->matchVal0); + TIMER_SetCompValue(timerCh,TIMER_COMP_ID_1,timerCfg->matchVal1); + TIMER_SetCompValue(timerCh,TIMER_COMP_ID_2,timerCfg->matchVal2); + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void TIMER_Enable(TIMER_Chan_Type timerCh) + +{ + _DAT_4000a584 = 1 << ((uint)timerCh + 1 & 0x1f) | _DAT_4000a584; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void TIMER_Disable(TIMER_Chan_Type timerCh) + +{ + _DAT_4000a584 = ~(1 << ((uint)timerCh + 1 & 0x1f)) & _DAT_4000a584; + return; +} + + + +void TIMER_IntMask(TIMER_Chan_Type timerCh,TIMER_INT_Type intType,BL_Mask_Type intMask) + +{ + undefined3 in_register_00002029; + uint *puVar1; + undefined3 in_register_0000202d; + int iVar2; + undefined3 in_register_00002031; + int iVar3; + uint uVar4; + + iVar3 = CONCAT31(in_register_00002031,intMask); + iVar2 = CONCAT31(in_register_0000202d,intType); + puVar1 = (uint *)(CONCAT31(in_register_00002029,timerCh) * 4 + 0x4000a544); + uVar4 = *puVar1; + if (iVar2 == 1) { + if (iVar3 == 0) { + uVar4 = uVar4 | 2; + } + else { + uVar4 = uVar4 & 0xfffffffd; + } + goto LAB_23083ae8; + } + if (iVar2 == 0) { + if (iVar3 == 0) { + uVar4 = uVar4 | 1; + } + else { + uVar4 = uVar4 & 0xfffffffe; + } + goto LAB_23083ae8; + } + if (iVar2 == 2) { + if (iVar3 != 0) goto LAB_23083b20; + } + else { + if (iVar2 != 3) { + return; + } + if (iVar3 != 0) { + *puVar1 = uVar4 & 0xfffffffe; + *puVar1 = uVar4 & 0xfffffffd; +LAB_23083b20: + uVar4 = uVar4 & 0xfffffffb; + goto LAB_23083ae8; + } + *puVar1 = uVar4 | 1; + *puVar1 = uVar4 | 2; + } + uVar4 = uVar4 | 4; +LAB_23083ae8: + *puVar1 = uVar4; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void WDT_Set_Clock(TIMER_ClkSrc_Type clkSrc,uint8_t div) + +{ + undefined3 in_register_00002029; + + _DAT_4000a500 = CONCAT31(in_register_00002029,clkSrc) << 8 | _DAT_4000a500 & 0xfffffcff; + _DAT_4000a5bc = _DAT_4000a5bc & 0xffffff | (uint)div << 0x18; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void WDT_SetCompValue(uint16_t val) + +{ + undefined2 in_register_0000202a; + + _DAT_4000a568 = CONCAT22(in_register_0000202a,val); + _DAT_4000a59c = _DAT_4000a59c & 0xffff0000 | 0xbaba; + _DAT_4000a5a0 = _DAT_4000a5a0 & 0xffff0000 | 0xeb10; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void WDT_ResetCounterValue(void) + +{ + _DAT_4000a598 = _DAT_4000a598 | 1; + _DAT_4000a59c = _DAT_4000a59c & 0xffff0000 | 0xbaba; + _DAT_4000a5a0 = _DAT_4000a5a0 & 0xffff0000 | 0xeb10; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void WDT_Enable(void) + +{ + _DAT_4000a564 = _DAT_4000a564 | 1; + _DAT_4000a59c = _DAT_4000a59c & 0xffff0000 | 0xbaba; + _DAT_4000a5a0 = _DAT_4000a5a0 & 0xffff0000 | 0xeb10; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void WDT_Disable(void) + +{ + _DAT_4000a564 = _DAT_4000a564 & 0xfffffffe; + _DAT_4000a59c = _DAT_4000a59c & 0xffff0000 | 0xbaba; + _DAT_4000a5a0 = _DAT_4000a5a0 & 0xffff0000 | 0xeb10; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void WDT_IntMask(WDT_INT_Type intType,BL_Mask_Type intMask) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + + if (CONCAT31(in_register_00002029,intType) == 0) { + if (CONCAT31(in_register_0000202d,intMask) == 0) { + _DAT_4000a564 = _DAT_4000a564 & 0xfffffffd; + } + else { + _DAT_4000a564 = _DAT_4000a564 | 2; + } + } + _DAT_4000a59c = _DAT_4000a59c & 0xffff0000 | 0xbaba; + _DAT_4000a5a0 = _DAT_4000a5a0 & 0xffff0000 | 0xeb10; + return; +} + + + +uint32_t EF_Ctrl_Get_Byte_Zero_Cnt(uint8_t val) + +{ + undefined3 in_register_00002029; + uint32_t uVar1; + uint uVar2; + + uVar2 = 0; + uVar1 = 0; + do { + if ((CONCAT31(in_register_00002029,val) >> (uVar2 & 0x1f) & 1U) == 0) { + uVar1 = uVar1 + 1; + } + uVar2 = uVar2 + 1; + } while (uVar2 != 8); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type EF_Ctrl_Read_MAC_Address(uint8_t *mac) + +{ + uint8_t uVar1; + undefined4 uVar2; + uint uVar3; + BL_Err_Type BVar4; + uint32_t uVar5; + uint8_t *puVar6; + uint8_t *puVar7; + uint8_t *puVar8; + int iVar9; + uint uVar10; + + EF_Ctrl_Load_Efuse_R0(); + uVar2 = _DAT_40007014; + uVar10 = 0; + iVar9 = 0; + *mac = (uint8_t)_DAT_40007014; + mac[1] = (uint8_t)((uint)uVar2 >> 8); + mac[3] = (uint8_t)((uint)uVar2 >> 0x18); + mac[2] = (uint8_t)((uint)uVar2 >> 0x10); + uVar3 = _DAT_40007018; + mac[4] = (uint8_t)_DAT_40007018; + mac[5] = (uint8_t)(uVar3 >> 8); + do { + puVar7 = mac + iVar9; + iVar9 = iVar9 + 1; + uVar5 = EF_Ctrl_Get_Byte_Zero_Cnt(*puVar7); + uVar10 = uVar10 + uVar5; + } while (iVar9 != 6); + BVar4 = ERROR; + if (((uVar3 >> 0x10 ^ uVar10) & 0x3f) == 0) { + puVar6 = mac + 2; + puVar7 = mac + 5; + do { + uVar1 = *mac; + puVar8 = puVar7 + -1; + *mac = *puVar7; + *puVar7 = uVar1; + mac = mac + 1; + puVar7 = puVar8; + } while (puVar8 != puVar6); + BVar4 = SUCCESS; + } + return BVar4; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t EF_Ctrl_Is_MAC_Address_Slot_Empty(uint8_t slot,uint8_t reload) + +{ + undefined3 in_register_00002029; + int iVar1; + undefined3 in_register_0000202d; + int iVar2; + uint uVar3; + uint uVar4; + + iVar2 = CONCAT31(in_register_0000202d,reload); + iVar1 = CONCAT31(in_register_00002029,slot); + if (iVar1 == 0) { + EF_Ctrl_Sw_AHB_Clk_0(); + uVar3 = _DAT_40007014; + uVar4 = _DAT_40007018; + if (iVar2 != 0) { + EF_Ctrl_Load_Efuse_R0(); + uVar3 = _DAT_40007014; + uVar4 = _DAT_40007018; + } + } + else { + if (iVar1 == 1) { + EF_Ctrl_Sw_AHB_Clk_0(); + uVar3 = _DAT_4000706c; + uVar4 = _DAT_40007070; + if (iVar2 != 0) { + EF_Ctrl_Load_Efuse_R0(); + uVar3 = _DAT_4000706c; + uVar4 = _DAT_40007070; + } + } + else { + if (iVar1 != 2) { + return '\0'; + } + EF_Ctrl_Sw_AHB_Clk_0(); + uVar3 = _DAT_40007004; + uVar4 = _DAT_40007008; + if (iVar2 != 0) { + EF_Ctrl_Load_Efuse_R0(); + uVar3 = _DAT_40007004; + uVar4 = _DAT_40007008; + } + } + } + if ((uVar4 & 0x3fffff | uVar3) != 0) { + return '\0'; + } + return '\x01'; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type EF_Ctrl_Read_MAC_Address_Opt(uint8_t slot,uint8_t *mac,uint8_t reload) + +{ + uint8_t uVar1; + uint uVar2; + BL_Err_Type BVar3; + undefined3 in_register_00002029; + uint32_t uVar4; + undefined3 in_register_00002031; + uint8_t *puVar5; + undefined4 uVar6; + uint8_t *puVar7; + uint8_t *puVar8; + int iVar9; + uint uVar10; + + uVar10 = CONCAT31(in_register_00002029,slot); + if (2 < uVar10) { + return ERROR; + } + if (CONCAT31(in_register_00002031,reload) == 0) { +LAB_23083dd0: + uVar6 = _DAT_40007014; + if ((uVar10 == 0) || (uVar6 = _DAT_4000706c, uVar10 == 1)) goto LAB_23083dd8; + } + else { + if (uVar10 != 2) { + EF_Ctrl_Load_Efuse_R0(); + goto LAB_23083dd0; + } + EF_Ctrl_Load_Efuse_R0(); + } + uVar6 = _DAT_40007004; +LAB_23083dd8: + *mac = (uint8_t)uVar6; + mac[1] = (uint8_t)((uint)uVar6 >> 8); + mac[2] = (uint8_t)((uint)uVar6 >> 0x10); + mac[3] = (uint8_t)((uint)uVar6 >> 0x18); + uVar2 = _DAT_40007018; + if ((uVar10 != 0) && (uVar2 = _DAT_40007008, uVar10 == 1)) { + uVar2 = _DAT_40007070; + } + mac[4] = (uint8_t)uVar2; + mac[5] = (uint8_t)(uVar2 >> 8); + uVar10 = 0; + iVar9 = 0; + do { + puVar7 = mac + iVar9; + iVar9 = iVar9 + 1; + uVar4 = EF_Ctrl_Get_Byte_Zero_Cnt(*puVar7); + uVar10 = uVar10 + uVar4; + } while (iVar9 != 6); + BVar3 = ERROR; + if (((uVar2 >> 0x10 ^ uVar10) & 0x3f) == 0) { + puVar5 = mac + 2; + puVar7 = mac + 5; + do { + uVar1 = *mac; + puVar8 = puVar7 + -1; + *mac = *puVar7; + *puVar7 = uVar1; + mac = mac + 1; + puVar7 = puVar8; + } while (puVar5 != puVar8); + BVar3 = SUCCESS; + } + return BVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint EF_Ctrl_Is_CapCode_Slot_Empty(int param_1,int param_2) + +{ + uint uVar1; + + EF_Ctrl_Sw_AHB_Clk_0(); + if (param_2 != 0) { + EF_Ctrl_Load_Efuse_R0(); + } + if (param_1 == 0) { + uVar1 = _DAT_4000700c >> 2; + } + else { + uVar1 = _DAT_40007070; + if ((param_1 != 1) && (uVar1 = _DAT_40007008, param_1 != 2)) { + return 0; + } + uVar1 = uVar1 >> 0x16; + } + return (uint)((uVar1 & 0xff) == 0); +} + + + +// WARNING: Variable defined which should be unmapped: tmp +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type EF_Ctrl_Read_CapCode_Opt(uint8_t slot,uint8_t *code,uint8_t reload) + +{ + uint8_t uVar1; + undefined3 in_register_00002029; + uint uVar2; + undefined3 extraout_var; + undefined3 in_register_00002031; + uint uVar3; + uint32_t tmp; + + uVar2 = CONCAT31(in_register_00002029,slot); + if (2 < uVar2) { + return ERROR; + } + EF_Ctrl_Sw_AHB_Clk_0(); + if (CONCAT31(in_register_00002031,reload) != 0) { + EF_Ctrl_Load_Efuse_R0(); + } + if (uVar2 == 0) { + uVar3 = _DAT_4000700c >> 2; + } + else { + uVar3 = _DAT_40007008; + if (uVar2 == 1) { + uVar3 = _DAT_40007070; + } + uVar3 = uVar3 >> 0x16; + } + if ((uVar3 & 0x80) != 0) { + uVar1 = EF_Ctrl_Get_Trim_Parity(uVar3 & 0x3f,'\x06'); + if ((uVar3 >> 6 & 1) == CONCAT31(extraout_var,uVar1)) { + *code = (uint8_t)(uVar3 & 0x3f); + return SUCCESS; + } + } + return ERROR; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t EF_Ctrl_Is_PowerOffset_Slot_Empty(uint8_t slot,uint8_t reload) + +{ + byte bVar1; + undefined3 in_register_00002029; + int iVar2; + undefined3 in_register_0000202d; + byte bVar3; + uint uVar4; + + iVar2 = CONCAT31(in_register_00002029,slot); + EF_Ctrl_Sw_AHB_Clk_0(); + if (CONCAT31(in_register_0000202d,reload) != 0) { + EF_Ctrl_Load_Efuse_R0(); + } + if (iVar2 == 0) { + bVar3 = 1; + uVar4 = _DAT_40007078 >> 0xf; + } + else { + if (iVar2 == 1) { + bVar3 = (byte)_DAT_4000700c; + uVar4 = _DAT_40007074 & 0xffff; + } + else { + if (iVar2 != 2) { + return '\0'; + } + uVar4 = _DAT_40007074 >> 0x10; + bVar3 = (byte)(_DAT_4000700c >> 1); + } + bVar3 = ~bVar3 & 1; + } + bVar1 = 0; + if (uVar4 == 0) { + bVar1 = bVar3; + } + return (uint8_t)bVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type EF_Ctrl_Read_PowerOffset_Opt(uint8_t slot,int8_t *pwrOffset,uint8_t reload) + +{ + uint uVar1; + int iVar2; + uint32_t val; + uint8_t uVar3; + undefined3 in_register_00002029; + undefined3 extraout_var; + uint32_t uVar4; + undefined3 in_register_00002031; + byte bVar5; + uint uVar6; + undefined4 uVar7; + + iVar2 = CONCAT31(in_register_00002029,slot); + uVar7 = EF_Ctrl_Sw_AHB_Clk_0(); + if (CONCAT31(in_register_00002031,reload) != 0) { + EF_Ctrl_Load_Efuse_R0(uVar7); + } + if (iVar2 == 0) { + val = (_DAT_40007078 << 1) >> 0x11; + uVar1 = _DAT_40007078 >> 0x1f; + uVar6 = _DAT_40007078 >> 0xf; + } + else { + if (iVar2 == 1) { + val = _DAT_40007074 & 0x7fff; + uVar1 = _DAT_40007074 >> 0xf & 1; + uVar6 = _DAT_4000700c; + } + else { + if (iVar2 != 2) { + return ERROR; + } + val = (_DAT_40007074 << 1) >> 0x11; + uVar1 = _DAT_40007074 >> 0x1f; + uVar6 = _DAT_4000700c >> 1; + } + } + if (((uVar6 & 1) != 0) && + (uVar3 = EF_Ctrl_Get_Trim_Parity(val,'\x0f'), CONCAT31(extraout_var,uVar3) == uVar1)) { + iVar2 = 0; + do { + uVar4 = val; + __lshrdi3(val); + bVar5 = (byte)uVar4 & 0x1f; + if ((uVar4 & 0x10) != 0) { + bVar5 = bVar5 - 0x20; + } + pwrOffset[iVar2] = bVar5; + iVar2 = iVar2 + 1; + } while (iVar2 != 3); + return SUCCESS; + } + return ERROR; +} + + + +int8_t mfg_media_read_xtal_capcode(uint8_t *capcode,uint8_t reload) + +{ + int8_t iVar1; + + if (rf_para_on_flash != '\0') { + iVar1 = mfg_flash_read_xtal_capcode(capcode,reload); + return iVar1; + } + iVar1 = mfg_efuse_read_xtal_capcode(capcode,reload); + return iVar1; +} + + + +int8_t mfg_media_read_poweroffset(int8_t *pwrOffset,uint8_t reload) + +{ + int8_t iVar1; + + if (rf_para_on_flash != '\0') { + iVar1 = mfg_flash_read_poweroffset(pwrOffset,reload); + return iVar1; + } + iVar1 = mfg_efuse_read_poweroffset(pwrOffset,reload); + return iVar1; +} + + + +int8_t mfg_media_read_macaddr(uint8_t *mac,uint8_t reload) + +{ + int8_t iVar1; + + if (rf_para_on_flash != '\0') { + iVar1 = mfg_flash_read_macaddr(mac,reload); + return iVar1; + } + iVar1 = mfg_efuse_read_macaddr(mac,reload); + return iVar1; +} + + + +void bflb_platform_usart_dbg_send(uint8_t *data,uint32_t len) + +{ + UART_SendData(UART0_ID,data,len); + return; +} + + + +void bflb_platform_printf(char *fmt,...) + +{ + char print_buf [128]; + size_t len; + undefined4 in_a1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list ap; + undefined4 uStack28; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + if (uart_dbg_disable == '\0') { + uStack28 = in_a1; + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + vsnprintf((char *)&ram0x4201c64c,0x7f,fmt,&uStack28); + len = strlen((char *)0x4201c64c); + bflb_platform_usart_dbg_send((uint8_t *)0x4201c64c,len); + } + return; +} + + + +// WARNING: Control flow encountered bad instruction data + +void Default_Handler_Stub(void) + +{ + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +int8_t mfg_efuse_read_xtal_capcode(uint8_t *capcode,uint8_t reload) + +{ + uint8_t bclkDiv; + uint8_t hclkDiv; + BL_Err_Type BVar1; + int iVar2; + undefined3 extraout_var; + undefined3 in_register_0000202d; + undefined4 uVar3; + + uVar3 = CONCAT31(in_register_0000202d,reload); + bclkDiv = GLB_Get_BCLK_Div(); + hclkDiv = GLB_Get_HCLK_Div(); + HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_XTAL); + if ((rf_cal_slots < 3) || (iVar2 = EF_Ctrl_Is_CapCode_Slot_Empty(2,uVar3), iVar2 != 0)) { + if ((rf_cal_slots < 2) || (iVar2 = EF_Ctrl_Is_CapCode_Slot_Empty(1,uVar3), iVar2 != 0)) { + if ((rf_cal_slots == '\0') || (iVar2 = EF_Ctrl_Is_CapCode_Slot_Empty(0,uVar3), iVar2 != 0)) { + printf("No written slot found\r\n"); + iVar2 = 1; + goto LAB_23084268; + } + } + else { + iVar2 = 1; + } + } + else { + iVar2 = 2; + } + printf("Read slot:%d\r\n",iVar2); + BVar1 = EF_Ctrl_Read_CapCode_Opt((uint8_t)iVar2,capcode,reload); + iVar2 = CONCAT31(extraout_var,BVar1); +LAB_23084268: + GLB_Set_System_CLK_Div(hclkDiv,bclkDiv); + HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_PLL); + return (int8_t)-(iVar2 != 0); +} + + + +int8_t mfg_efuse_read_poweroffset(int8_t *pwrOffset,uint8_t reload) + +{ + int iVar1; + uint8_t bclkDiv; + uint8_t hclkDiv; + uint8_t uVar2; + BL_Err_Type BVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + int iVar4; + int iVar5; + int8_t iStack36; + char cStack35; + char cStack34; + int8_t pwrOffsetTmp [3]; + + bclkDiv = GLB_Get_BCLK_Div(); + hclkDiv = GLB_Get_HCLK_Div(); + HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_XTAL); + if ((rf_cal_slots < 3) || + (uVar2 = EF_Ctrl_Is_PowerOffset_Slot_Empty('\x02',reload), CONCAT31(extraout_var_00,uVar2) != 0 + )) { + if ((rf_cal_slots < 2) || + (uVar2 = EF_Ctrl_Is_PowerOffset_Slot_Empty('\x01',reload), CONCAT31(extraout_var,uVar2) != 0) + ) { + if (rf_cal_slots != '\0') { + uVar2 = EF_Ctrl_Is_PowerOffset_Slot_Empty('\0',reload); + iVar1 = CONCAT31(extraout_var_01,uVar2); + if (iVar1 == 0) goto LAB_23084322; + } + printf("No written slot found\r\n"); + iVar1 = 1; + goto LAB_23084444; + } + iVar1 = 1; + } + else { + iVar1 = 2; + } +LAB_23084322: + printf("Read slot:%d\r\n",iVar1); + BVar3 = EF_Ctrl_Read_PowerOffset_Opt((uint8_t)iVar1,&iStack36,reload); + iVar1 = CONCAT31(extraout_var_02,BVar3); + memset(pwrOffset,0,0xe); + *pwrOffset = iStack36; + pwrOffset[6] = cStack35; + pwrOffset[0xc] = cStack34; + iVar4 = (((int)cStack35 - (int)iStack36) * 100) / 6; + pwrOffset[2] = (char)((iVar4 + 0x19) / 0x32) + iStack36; + pwrOffset[3] = (char)((iVar4 * 3 + 0x32) / 100) + iStack36; + pwrOffset[4] = (char)((iVar4 * 4 + 0x32) / 100) + iStack36; + pwrOffset[1] = (char)((iVar4 + 0x32) / 100) + iStack36; + iVar5 = (((int)cStack34 - (int)cStack35) * 100) / 6; + pwrOffset[5] = (char)((iVar4 * 5 + 0x32) / 100) + iStack36; + pwrOffset[8] = (char)((iVar5 + 0x19) / 0x32) + cStack35; + pwrOffset[0xb] = (char)((iVar5 * 5 + 0x32) / 100) + cStack35; + pwrOffset[9] = (char)((iVar5 * 3 + 0x32) / 100) + cStack35; + pwrOffset[7] = (char)((iVar5 + 0x32) / 100) + cStack35; + pwrOffset[10] = (char)((iVar5 * 4 + 0x32) / 100) + cStack35; + pwrOffset[0xd] = (char)((iVar5 * 7 + 0x32) / 100) + cStack35; +LAB_23084444: + GLB_Set_System_CLK_Div(hclkDiv,bclkDiv); + HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_PLL); + return (int8_t)-(iVar1 != 0); +} + + + +int8_t mfg_efuse_read_macaddr(uint8_t *mac,uint8_t reload) + +{ + int iVar1; + uint8_t bclkDiv; + uint8_t hclkDiv; + uint8_t uVar2; + BL_Err_Type BVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + + bclkDiv = GLB_Get_BCLK_Div(); + hclkDiv = GLB_Get_HCLK_Div(); + HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_XTAL); + if ((rf_cal_slots < 3) || + (uVar2 = EF_Ctrl_Is_MAC_Address_Slot_Empty('\x02',reload), CONCAT31(extraout_var_00,uVar2) != 0 + )) { + if ((rf_cal_slots < 2) || + (uVar2 = EF_Ctrl_Is_MAC_Address_Slot_Empty('\x01',reload), CONCAT31(extraout_var,uVar2) != 0) + ) { + if (rf_cal_slots != '\0') { + uVar2 = EF_Ctrl_Is_MAC_Address_Slot_Empty('\0',reload); + iVar1 = CONCAT31(extraout_var_01,uVar2); + if (iVar1 == 0) goto LAB_230844fc; + } + printf("No written slot found\r\n"); + iVar1 = 1; + goto LAB_23084516; + } + iVar1 = 1; + } + else { + iVar1 = 2; + } +LAB_230844fc: + printf("Read slot:%d\r\n",iVar1); + BVar3 = EF_Ctrl_Read_MAC_Address_Opt((uint8_t)iVar1,mac,reload); + iVar1 = CONCAT31(extraout_var_02,BVar3); +LAB_23084516: + GLB_Set_System_CLK_Div(hclkDiv,bclkDiv); + HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_PLL); + return (int8_t)-(iVar1 != 0); +} + + +/* +Unable to decompile 'mfg_flash_read' +Cause: Exception while decompiling 23084548: Decompiler process died + +*/ + + +int8_t mfg_flash_read_xtal_capcode(uint8_t *capcode,uint8_t reload) + +{ + uint32_t uVar1; + int8_t iVar2; + undefined3 extraout_var; + uint32_t uVar3; + undefined3 in_register_0000202d; + + if ((((CONCAT31(in_register_0000202d,reload) == 0) || + (iVar2 = mfg_flash_read(), CONCAT31(extraout_var,iVar2) == 0)) && + (uVar1 = rf_para.crc32, rf_para.magic == 0x41)) && + ((uVar3 = BFLB_Soft_CRC32(&rf_para.capcode_valid,0x10), uVar1 == uVar3 && + (rf_para.capcode_valid == 'Z')))) { + iVar2 = '\0'; + *capcode = rf_para.capcode; + } + else { + iVar2 = -1; + } + return iVar2; +} + + + +int8_t mfg_flash_read_poweroffset(int8_t *pwrOffset,uint8_t reload) + +{ + int8_t iVar1; + int8_t iVar2; + uint32_t uVar3; + int8_t iVar4; + undefined3 extraout_var; + uint32_t uVar5; + undefined3 in_register_0000202d; + int iVar6; + int iVar7; + int iVar8; + + if ((((CONCAT31(in_register_0000202d,reload) == 0) || + (iVar4 = mfg_flash_read(), CONCAT31(extraout_var,iVar4) == 0)) && + (uVar3 = rf_para.crc32, rf_para.magic == 0x41)) && + ((uVar5 = BFLB_Soft_CRC32(&rf_para.capcode_valid,0x10), uVar3 == uVar5 && + (rf_para.poweroffset_valid == 'Z')))) { + memset(pwrOffset,0,0xe); + iVar2 = rf_para.poweroffset[2]; + iVar1 = rf_para.poweroffset[1]; + iVar4 = rf_para.poweroffset[0]; + iVar8 = (int)rf_para.poweroffset[1]; + iVar6 = (int)rf_para.poweroffset[0]; + iVar7 = (int)rf_para.poweroffset[2]; + *pwrOffset = rf_para.poweroffset[0]; + pwrOffset[6] = iVar1; + pwrOffset[0xc] = iVar2; + iVar6 = ((iVar8 - iVar6) * 100) / 6; + pwrOffset[2] = (char)((iVar6 + 0x19) / 0x32) + iVar4; + pwrOffset[3] = (char)((iVar6 * 3 + 0x32) / 100) + iVar4; + pwrOffset[4] = (char)((iVar6 * 4 + 0x32) / 100) + iVar4; + pwrOffset[1] = (char)((iVar6 + 0x32) / 100) + iVar4; + iVar7 = ((iVar7 - iVar8) * 100) / 6; + pwrOffset[5] = iVar4 + (char)((iVar6 * 5 + 0x32) / 100); + pwrOffset[8] = (char)((iVar7 + 0x19) / 0x32) + iVar1; + pwrOffset[10] = (char)((iVar7 * 4 + 0x32) / 100) + iVar1; + pwrOffset[7] = (char)((iVar7 + 0x32) / 100) + iVar1; + pwrOffset[9] = (char)((iVar7 * 3 + 0x32) / 100) + iVar1; + pwrOffset[0xb] = (char)((iVar7 * 5 + 0x32) / 100) + iVar1; + iVar4 = '\0'; + pwrOffset[0xd] = (char)((iVar7 * 7 + 0x32) / 100) + iVar1; + } + else { + iVar4 = -1; + } + return iVar4; +} + + + +int8_t mfg_flash_read_macaddr(uint8_t *mac,uint8_t reload) + +{ + uint32_t uVar1; + int8_t iVar2; + undefined3 extraout_var; + uint32_t uVar3; + undefined3 in_register_0000202d; + + if ((CONCAT31(in_register_0000202d,reload) == 0) || + (iVar2 = mfg_flash_read(), CONCAT31(extraout_var,iVar2) == 0)) { + uVar1 = rf_para.crc32; + if ((rf_para.magic == 0x41) && + ((uVar3 = BFLB_Soft_CRC32(&rf_para.capcode_valid,0x10), uVar1 == uVar3 && + (rf_para.mac_valid == 'Z')))) { + memcpy(mac,rf_para.mac,6); + return '\0'; + } + } + else { + printf("mfg_flash_read fail\r\n"); + } + return -1; +} + + + +int bt_hcionchip_recv(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t uVar1; + + switch((uint)msgid - 0x801 & 0xffff) { + case 0: + uVar1 = '\x02'; + break; + case 1: + uVar1 = '\x03'; + break; + case 2: + uVar1 = '\x05'; + break; + case 3: + uVar1 = '\x04'; + break; + default: + return 0; + case 5: + uVar1 = '\x01'; + } + (*hci_rx_cb)(uVar1,src_id,(uint8_t *)param,*(uint8_t *)((int)param + -2),(void *)0x0); + return 0; +} + + + +uint8_t bt_onchiphci_interface_init(bt_hci_recv_cb *cb) + +{ + uint8_t uVar1; + + hci_rx_cb = cb; + uVar1 = ble_ke_task_create('\x04',&TASK_DESC_HCI_ONCHIP); + return uVar1; +} + + +/* +Unable to decompile 'bt_onchiphci_send' +Cause: Exception while decompiling 23084844: Decompiler process died + +*/ + + +uint bt_onchiphci_hanlde_rx_acl(int param_1,void *param_2) + +{ + uint uVar1; + uint8_t *puVar2; + + puVar2 = hci_build_acl_rx_data((ke_msg *)(param_1 + -0xc)); + uVar1 = (uint)puVar2[2] + 4 & 0xff; + (*ble_memcpy_ptr)(param_2,puVar2,uVar1); + em_buf_rx_free(*(uint8_t *)(param_1 + 6)); + return uVar1; +} + + + +int bl_mtd_open(char *name,bl_mtd_handle_t *handle,uint flags) + +{ + char *__dest; + int iVar1; + uint32_t uStack40; + uint32_t addr; + uint32_t size; + + uStack40 = 0; + addr = 0; + __dest = (char *)pvPortMalloc(0x20); + if (__dest == (char *)0x0) { + iVar1 = -1; + } + else { + memset(__dest,0,0x20); + strncpy(__dest,name,0x10); + if ((flags & 1) == 0) { + if ((flags & 2) == 0) { + *(undefined4 *)(__dest + 0x1c) = 0; + } + else { + iVar1 = hal_boot2_partition_bus_addr_active(name,&uStack40,&addr); + if ((iVar1 != 0) || (uStack40 == 0)) { + printf("[MTD] [PART] [XIP] error when get %s partition %d\r\n",name,iVar1); + printf("[MTD] [PART] [XIP] Dead Loop. Reason: no Valid %s partition found\r\n",name); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + *(uint32_t *)(__dest + 0x1c) = uStack40; + } + iVar1 = hal_boot2_partition_addr_active(name,&uStack40,&addr); + if ((iVar1 != 0) || (uStack40 == 0)) { + printf("[MTD] [PART] [XIP] error when get %s partition %d\r\n",name,iVar1); + printf("[MTD] [PART] [XIP] Dead Loop. Reason: no Valid %s partition found\r\n",name); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + } + else { + if ((flags & 2) == 0) { + *(undefined4 *)(__dest + 0x1c) = 0; + } + else { + iVar1 = hal_boot2_partition_bus_addr_inactive(name,&uStack40,&addr); + if ((iVar1 != 0) || (uStack40 == 0)) { + printf("[MTD] [PART] [XIP] error when get %s partition %d\r\n",name,iVar1); + printf("[MTD] [PART] [XIP] Dead Loop. Reason: no Valid %s partition found\r\n",name); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + *(uint32_t *)(__dest + 0x1c) = uStack40; + } + iVar1 = hal_boot2_partition_addr_inactive(name,&uStack40,&addr); + if ((iVar1 != 0) || (uStack40 == 0)) { + printf("[MTD] [PART] [XIP] error when get %s partition %d\r\n",name,iVar1); + printf("[MTD] [PART] [XIP] Dead Loop. Reason: no Valid %s partition found\r\n",name); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + } + *(uint32_t *)(__dest + 0x14) = uStack40; + *(uint32_t *)(__dest + 0x18) = addr; + puts("[MTD] >>>>>> Hanlde info Dump >>>>>>\r\n"); + printf(" name %s\r\n",__dest); + printf(" id %d\r\n",*(undefined4 *)(__dest + 0x10)); + printf(" offset %p(%u)\r\n",*(undefined4 *)(__dest + 0x14)); + printf(" size %p(%uKbytes)\r\n",*(uint *)(__dest + 0x18),*(uint *)(__dest + 0x18) >> 10); + printf(" xip_addr %p\r\n",*(undefined4 *)(__dest + 0x1c)); + puts("[MTD] <<<<<< Hanlde info End <<<<<<\r\n"); + iVar1 = 0; + *(char **)handle = __dest; + } + return iVar1; +} + + + +int bl_mtd_close(bl_mtd_handle_t handle) + +{ + vPortFree(handle); + return 0; +} + + + +int bl_mtd_info(bl_mtd_handle_t handle,bl_mtd_info_t *info) + +{ + strcpy((char *)info,(char *)handle); + info->offset = *(uint *)((int)handle + 0x14); + info->size = *(uint *)((int)handle + 0x18); + info->xip_addr = *(void **)((int)handle + 0x1c); + return 0; +} + + + +int bl_mtd_erase(bl_mtd_handle_t handle,uint addr,uint size) + +{ + bl_flash_erase(*(int *)((int)handle + 0x14) + addr,size); + return 0; +} + + + +int bl_mtd_erase_all(bl_mtd_handle_t handle) + +{ + bl_flash_erase(*(uint32_t *)((int)handle + 0x14),*(int *)((int)handle + 0x18)); + return 0; +} + + + +int bl_mtd_write(bl_mtd_handle_t handle,uint addr,uint size,uint8_t *data) + +{ + uint32_t addr_00; + int iVar1; + TickType_t TVar2; + uint __n; + uint8_t auStack96 [4]; + uint8_t buf_tmp [64]; + + addr_00 = *(int *)((int)handle + 0x14) + addr; + iVar1 = bl_sys_isxipaddr((uint32_t)data); + if (iVar1 == 0) { + bl_flash_write(addr_00,data,size); + } + else { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] addr@%p is xip flash, size %d\r\n",TVar2,&DAT_230c03d4,"bl_mtd.c", + 0xc9,data,size); + while (size != 0) { + __n = size; + if (0x40 < size) { + __n = 0x40; + } + memcpy(auStack96,data,__n); + bl_flash_write(addr_00,auStack96,__n); + addr_00 = addr_00 + __n; + data = data + __n; + size = size - __n; + } + } + return 0; +} + + + +int bl_mtd_read(bl_mtd_handle_t handle,uint addr,uint size,uint8_t *data) + +{ + bl_flash_read(*(int *)((int)handle + 0x14) + addr,data,size); + return 0; +} + + + +int bloop_init(loop_ctx *loop) + +{ + loop_evt_handler_statistic *list; + loop_evt_handler_statistic *plVar1; + + memset(loop,0,0x4a0); + list = (loop_evt_handler_statistic *)loop->list; + do { + plVar1 = (loop_evt_handler_statistic *)&list->time_accumulated; + utils_list_init((utils_list *)list); + list = plVar1; + } while (plVar1 != loop->statistic); + *(utils_dlist_t **)&(loop->timer_dlist).next = &loop->timer_dlist; + *(utils_dlist_t **)&(loop->timer_dlist).prev = &loop->timer_dlist; + *(utils_dlist_t **)&(loop->timer_dued).next = &loop->timer_dued; + *(utils_dlist_t **)&(loop->timer_dued).prev = &loop->timer_dued; + printf("=== %d task inited\r\n",0x20); + return 0; +} + + + +int bloop_handler_register(loop_ctx *loop,loop_evt_handler *handler,int priority) + +{ + if (((uint)priority < 0x20) && ((&loop->looper + priority)[0x104] == (TaskHandle_t)0x0)) { + *(loop_evt_handler **)(&loop->looper + priority + 0x104) = handler; + return 0; + } + return -1; +} + + + +void bloop_timer_init(loop_timer *timer,int use_auto_free) + +{ + memset(timer,0,0x24); + *(loop_timer **)&(timer->dlist_item).prev = timer; + *(loop_timer **)&(timer->dlist_item).next = timer; + timer->flags = (use_auto_free != 0) << 1; + return; +} + + + +void bloop_timer_configure + (loop_timer *timer,uint delay_ms, + anon_subr_void_loop_ctx_ptr_loop_timer_ptr_void_ptr *cb,void *arg,int idx_task, + uint32_t evt_type_map) + +{ + TickType_t TVar1; + + TVar1 = xTaskGetTickCount(); + timer->time_added = TVar1; + timer->time_target = TVar1 + delay_ms; + *(anon_subr_void_loop_ctx_ptr_loop_timer_ptr_void_ptr **)&timer->cb = cb; + timer->arg = arg; + timer->idx_task = idx_task; + timer->evt_type_map = evt_type_map; + return; +} + + + +void bloop_timer_repeat_enable(loop_timer *timer) + +{ + timer->flags = timer->flags | 1; + return; +} + + + +void bloop_timer_repeat_reconfigure(loop_timer *timer) + +{ + uint uVar1; + uint uVar2; + TickType_t TVar3; + + uVar1 = timer->time_target; + uVar2 = timer->time_added; + TVar3 = xTaskGetTickCount(); + timer->time_target = (uVar1 - uVar2) + TVar3; + timer->time_added = TVar3; + return; +} + + + +void bloop_timer_register(loop_ctx *loop,loop_timer *timer) + +{ + utils_dlist_s *puVar1; + utils_dlist_s *puVar2; + utils_dlist_s *puVar3; + utils_dlist_s *puVar4; + utils_dlist_s *puVar5; + + puVar2 = (loop->timer_dlist).next; + puVar3 = (utils_dlist_s *)&loop->timer_dlist; + if (puVar3 == puVar2) { + (timer->dlist_item).next = puVar3; + (timer->dlist_item).prev = puVar3; + *(loop_timer **)&(loop->timer_dlist).next = timer; + *(loop_timer **)&(loop->timer_dlist).prev = timer; + return; + } + puVar1 = puVar2; + puVar5 = (utils_dlist_s *)0x0; + do { + puVar4 = puVar1; + if (puVar3 == puVar4) { +LAB_23084dce: + puVar2 = puVar5->next; + (timer->dlist_item).prev = puVar5; + (timer->dlist_item).next = puVar2; + *(loop_timer **)&puVar5->next = timer; + *(loop_timer **)&puVar2->prev = timer; + return; + } + if ((int)(timer->time_target - (int)puVar4[2].prev) < 1) { + if (puVar5 == (utils_dlist_s *)0x0) { + (timer->dlist_item).next = puVar2; + (timer->dlist_item).prev = puVar3; + *(loop_timer **)&(loop->timer_dlist).next = timer; + *(loop_timer **)&puVar2->prev = timer; + return; + } + goto LAB_23084dce; + } + puVar1 = puVar4->next; + puVar5 = puVar4; + } while( true ); +} + + + +void bloop_wait_startup(loop_ctx *loop) + +{ + while (loop->looper == (TaskHandle_t)0x0) { + vTaskDelay(1); + } + return; +} + + + +void bloop_evt_set_async(loop_ctx *loop,uint evt,uint32_t evt_map) + +{ + if (0x1f < evt) { + printf("[ASSERT] [ERR] %s:%d\r\n","bloop_base.c",0x15a); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + vTaskEnterCritical(); + loop->bitmap_evt_async = loop->bitmap_evt_async | 1 << (evt & 0x1f); + (&loop->looper + evt)[4] = (TaskHandle_t)((uint)(&loop->looper + evt)[4] | evt_map); + vTaskExitCritical(); + xTaskGenericNotify(loop->looper,0,eIncrement,(uint32_t *)0x0); + return; +} + + + +void bloop_evt_set_sync(loop_ctx *loop,uint evt,uint32_t evt_map) + +{ + if (0x1f < evt) { + printf("[ASSERT] [ERR] %s:%d\r\n","bloop_base.c",0x177); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + loop->bitmap_evt_sync = loop->bitmap_evt_sync | 1 << (evt & 0x1f); + (&loop->looper + evt)[4] = (TaskHandle_t)((uint)(&loop->looper + evt)[4] | evt_map); + return; +} + + + +void bloop_evt_unset_sync(loop_ctx *loop,uint evt) + +{ + if (0x1f < evt) { + printf("[ASSERT] [ERR] %s:%d\r\n","bloop_base.c",0x17f); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + loop->bitmap_evt_sync = ~(1 << (evt & 0x1f)) & loop->bitmap_evt_sync; + return; +} + + + +void bloop_run(loop_ctx *param_1) + +{ + loop_timer *plVar1; + utils_dlist_t *puVar2; + loop_timer *timer; + TaskHandle_t ptVar3; + TickType_t TVar4; + uint32_t uVar5; + uint32_t uVar6; + int iVar7; + int iVar8; + utils_list_hdr *puVar9; + utils_dlist_s *xTicksToWait; + uint evt; + TaskHandle_t ptVar10; + utils_dlist_s *puVar11; + utils_dlist_s *puVar12; + TaskHandle_t *pptVar13; + loop_timer *plVar14; + utils_dlist_t *puVar15; + + ptVar3 = xTaskGetCurrentTaskHandle(); + param_1->looper = ptVar3; +LAB_23084f02: + do { + puVar15 = ¶m_1->timer_dlist; + while( true ) { + vTaskEnterCritical(); + evt = param_1->bitmap_evt_async; + param_1->bitmap_evt_async = 0; + param_1->bitmap_evt_sync = param_1->bitmap_evt_sync | evt; + vTaskExitCritical(); + if (param_1->bitmap_evt_sync != 0) break; + puVar2 = (utils_dlist_t *)(param_1->timer_dlist).next; + xTicksToWait = (utils_dlist_s *)0xffffffff; + if (puVar2 != puVar15) { + xTicksToWait = puVar2[2].prev; + TVar4 = xTaskGetTickCount(); + xTicksToWait = (utils_dlist_s *)((int)xTicksToWait - TVar4); + if ((int)xTicksToWait < 1) break; + } + ulTaskNotifyTake(1,(TickType_t)xTicksToWait); + } + if ((utils_dlist_t *)(param_1->timer_dlist).next != puVar15) { + TVar4 = xTaskGetTickCount(); + puVar2 = (utils_dlist_t *)(param_1->timer_dlist).next; + xTicksToWait = (utils_dlist_s *)0x0; + if (puVar2 != (utils_dlist_t *)0x0) { + xTicksToWait = (&puVar2->prev)[1]; + } + while ((puVar11 = xTicksToWait, puVar2 != puVar15 && (-1 < (int)(TVar4 - (int)puVar2[2].prev)) + )) { + bloop_evt_set_sync(param_1,(uint)puVar2[2].next,(uint32_t)puVar2[3].prev); + if (puVar2[3].next != (utils_dlist_s *)0x0) { + (*(code *)puVar2[3].next)(param_1,puVar2,puVar2[4].prev); + } + puVar12 = (&puVar2->prev)[1]; + xTicksToWait = puVar2->prev; + xTicksToWait->next = puVar12; + puVar12->prev = xTicksToWait; + xTicksToWait = (param_1->timer_dued).next; + *(loop_timer **)&puVar2->prev = (loop_timer *)¶m_1->timer_dued; + (&puVar2->prev)[1] = xTicksToWait; + *(utils_dlist_t **)&(param_1->timer_dued).next = puVar2; + *(utils_dlist_t **)&xTicksToWait->prev = puVar2; + puVar2 = (utils_dlist_t *)puVar11; + xTicksToWait = (utils_dlist_s *)0x0; + if (puVar11 != (utils_dlist_s *)0x0) { + xTicksToWait = (&puVar11->prev)[1]; + } + } + timer = (loop_timer *)(param_1->timer_dued).next; + plVar1 = (loop_timer *)0x0; + if (timer != (loop_timer *)0x0) { + plVar1 = (loop_timer *)(timer->dlist_item).next; + } + while (plVar14 = plVar1, timer != (loop_timer *)¶m_1->timer_dued) { + xTicksToWait = (timer->dlist_item).prev; + puVar11 = (timer->dlist_item).next; + xTicksToWait->next = puVar11; + puVar11->prev = xTicksToWait; + if ((timer->flags & 2) == 0) { + if ((timer->flags & 1) != 0) { + if ((_fsymc_level_bloop < BLOG_LEVEL_INFO) && + (_fsymf_level_bloopbloop_base < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar4 = xTaskGetTickCount(); + } + else { + TVar4 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Repeat timer\r\n",TVar4,"DEBUG ","bloop_base.c",0xbb); + } + bloop_timer_repeat_reconfigure(timer); + bloop_timer_register(param_1,timer); + } + } + else { + if ((_fsymc_level_bloop < BLOG_LEVEL_INFO) && + (_fsymf_level_bloopbloop_base < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar4 = xTaskGetTickCount(); + } + else { + TVar4 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Free now\r\n",TVar4,"DEBUG ","bloop_base.c",0xb8); + } + vPortFree(timer); + } + timer = plVar14; + plVar1 = (loop_timer *)0x0; + if (plVar14 != (loop_timer *)0x0) { + plVar1 = (loop_timer *)(plVar14->dlist_item).next; + } + } + } + iVar7 = __clzsi2(param_1->bitmap_evt_sync); + iVar8 = __clzsi2(param_1->bitmap_msg); + if (iVar7 <= iVar8) { + evt = -iVar7 + 0x1f; + if (evt != 0xffffffff) { + pptVar13 = ¶m_1->looper + evt; + ptVar3 = pptVar13[0x104]; + if (ptVar3 == (TaskHandle_t)0x0) { + printf("[ASSERT] [ERR] %s:%d\r\n","bloop_base.c",0x105); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + vTaskEnterCritical(); + ptVar10 = pptVar13[4]; + pptVar13[4] = (TaskHandle_t)0x0; + pptVar13[0x24] = (TaskHandle_t)((uint)pptVar13[0x24] | (uint)ptVar10); + vTaskExitCritical(); + uVar5 = bl_timer_now_us(); + (*(code *)(ptVar3->xStateListItem).xItemValue) + (param_1,(loop_evt_handler *)ptVar3,¶m_1->bitmap_evt_sync, + (uint32_t *)(¶m_1->looper + -iVar7 + 0x43)); + uVar6 = bl_timer_now_us(); + pptVar13 = ¶m_1->looper + evt * 4; + ptVar3 = (TaskHandle_t)(uVar6 - uVar5); + pptVar13[0x85] = ptVar3; + pptVar13[0x86] = (TaskHandle_t)((int)pptVar13[0x86] + (int)ptVar3); + if (pptVar13[0x84] < ptVar3) { + pptVar13[0x84] = ptVar3; + } + pptVar13[0x87] = (TaskHandle_t)((int)&pptVar13[0x87]->pxTopOfStack + 1); + bloop_evt_unset_sync(param_1,evt); + goto LAB_23084f02; + } + } + if ((-iVar8 != -0x20) && + (puVar9 = utils_list_pop_front((utils_list *)(¶m_1->looper + (-iVar8 + 0x41) * 2)), + puVar9 == (utils_list_hdr *)0x0)) { + printf("[ASSERT] [ERR] %s:%d\r\n","bloop_base.c",0x124); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + } while( true ); +} + + + +int bloop_status_dump(loop_ctx *loop) + +{ + loop_evt_handler_statistic *plVar1; + utils_dlist_s *puVar2; + uint32_t *puVar3; + TickType_t TVar4; + char *pcVar5; + uint32_t uVar6; + int iVar7; + uint32_t uVar8; + uint32_t uVar9; + + puts("====== bloop dump ======\r\n"); + printf(" bitmap_evt %lx\r\n",loop->bitmap_evt_sync); + printf(" bitmap_msg %lx\r\n",loop->bitmap_msg); + TVar4 = xTaskGetTickCount(); + puts("--->>> timer list:\r\n"); + puVar2 = (loop->timer_dlist).next; + iVar7 = 0; + while ((utils_dlist_s *)&loop->timer_dlist != puVar2) { + printf(" timer[%02d]: %u(diff %d)ms, \t\t task idx %02d, evt map %08lx, ptr %p\r\n",iVar7, + puVar2[2].prev,TVar4 - (int)puVar2[2].prev,puVar2[2].next,puVar2[3].prev,puVar2[3].next); + iVar7 = iVar7 + 1; + puVar2 = puVar2->next; + } + puVar3 = loop->evt_type_map_async + 0x1f; + printf(" %d task:\r\n",0x20); + plVar1 = loop->statistic + 0x1f; + iVar7 = 0x1f; + do { + pcVar5 = "empty"; + if ((char **)puVar3[0x100] != (char **)0x0) { + pcVar5 = *(char **)puVar3[0x100]; + } + printf(" task[%02d] : %s\r\n",iVar7,pcVar5); + uVar8 = puVar3[0x100]; + if (uVar8 != 0) { + uVar6 = puVar3[0x20]; + uVar9 = *puVar3; + printf(" evt handler %p,",*(undefined4 *)(uVar8 + 4)); + printf(" msg handler %p,",*(undefined4 *)(uVar8 + 8)); + printf(" trigged cnt %u,",plVar1->count_triggered); + printf(" bitmap async %lx sync %lx,",uVar9,uVar6); + printf(" time consumed %dus acc %dms, max %uus\r\n",plVar1->time_consumed, + plVar1->time_accumulated / 1000,plVar1->time_max); + } + iVar7 = iVar7 + -1; + puVar3 = puVar3 + -1; + plVar1 = plVar1 + -1; + } while (iVar7 != -1); + return 0; +} + + + +int loop_evt_entity_sys_handler(loop_ctx *loop,loop_evt_handler *handler,loop_msg *msg) + +{ + printf( + "[SYS] [MSG] called with msg info\r\n priority %u\r\n dst %u\r\n msgid %u\r\n src %u\r\n arg1 %p\r\n arg2 %p\r\n" + ,(uint)*(byte *)&msg->u,(uint)*(byte *)((int)&msg->u + 1),(uint)*(byte *)((int)&msg->u + 2) + ,(uint)*(byte *)((int)&msg->u + 3),msg->arg1,msg->arg2); + return 0; +} + + + +int loop_evt_entity_sys_evt + (loop_ctx *loop,loop_evt_handler *handler,uint32_t *bitmap_evt,uint32_t *evt_type_map) + +{ + uint uVar1; + + uVar1 = *evt_type_map; + printf("[SYS] [EVT] called with bitmap_evt %08lx, bitmap_task %08lx\r\n",*bitmap_evt,uVar1); + do { + if ((uVar1 & 1) == 0) { + if (uVar1 != 0) { + printf("[ASSERT] [ERR] %s:%d\r\n","bloop_handler_sys.c",0x2e); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + break; + } + uVar1 = uVar1 & 0xfffffffe; + bloop_status_dump(loop); + } while (uVar1 != 0); + *evt_type_map = 0; + return 0; +} + + +/* +Unable to decompile 'misaligned_load_trap' +Cause: Exception while decompiling 23085340: Decompiler process died + +*/ + +/* +Unable to decompile 'misaligned_store_trap' +Cause: Exception while decompiling 23085492: Decompiler process died + +*/ + + +void get_f32_reg(void) + +{ + uint in_t0; + + // WARNING: Could not recover jumptable at 0x230855e2. Too many branches + // WARNING: Treating indirect jump as call + (*(code *)(in_t0 & 0xfffffffe))(); + return; +} + + + +void put_f32_reg(void) + +{ + uint in_t0; + + // WARNING: Could not recover jumptable at 0x230856e2. Too many branches + // WARNING: Treating indirect jump as call + (*(code *)(in_t0 & 0xfffffffe))(); + return; +} + + + +int backtrace_riscv(anon_subr_int_char_ptr *print_func,uintptr_t *regs) + +{ + return -1; +} + + + +int bl_sha_mutex_take(void) + +{ + BaseType_t BVar1; + TickType_t TVar2; + int iVar3; + + BVar1 = xQueueSemaphoreTake((QueueHandle_t)g_bl_sec_sha_mutex,0xffffffff); + iVar3 = 0; + if (((BVar1 != 1) && (iVar3 = -1, _fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvbl_sec_sha < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] sha semphr take failed\r\n",TVar2,&DAT_230a9dd8,"bl_sec_sha.c", + 0x36); + iVar3 = -1; + } + return iVar3; +} + + + +int bl_sha_mutex_give(void) + +{ + BaseType_t BVar1; + TickType_t TVar2; + int iVar3; + + BVar1 = xQueueGenericSend((QueueHandle_t)g_bl_sec_sha_mutex,(void *)0x0,0,0); + iVar3 = 0; + if (((BVar1 != 1) && (iVar3 = -1, _fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvbl_sec_sha < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] sha semphr give failed\\n",TVar2,&DAT_230a9dd8,"bl_sec_sha.c",0x3f + ); + iVar3 = -1; + } + return iVar3; +} + + + +void bl_sha_init(bl_sha_ctx_t *ctx,bl_sha_type_t type) + +{ + Sec_Eng_SHA256_Init((SEC_Eng_SHA256_Ctx *)ctx,SEC_ENG_SHA_ID0,type,ctx->tmp,ctx->pad); + Sec_Eng_SHA_Start(SEC_ENG_SHA_ID0); + return; +} + + + +int bl_sha_update(bl_sha_ctx_t *ctx,uint8_t *input,uint32_t len) + +{ + BL_Err_Type BVar1; + undefined3 extraout_var; + + BVar1 = Sec_Eng_SHA256_Update((SEC_Eng_SHA256_Ctx *)ctx,SEC_ENG_SHA_ID0,input,len); + return CONCAT31(extraout_var,BVar1); +} + + + +int bl_sha_finish(bl_sha_ctx_t *ctx,uint8_t *hash) + +{ + BL_Err_Type BVar1; + undefined3 extraout_var; + + BVar1 = Sec_Eng_SHA256_Finish((SEC_Eng_SHA256_Ctx *)ctx,SEC_ENG_SHA_ID0,hash); + return CONCAT31(extraout_var,BVar1); +} + + + +int hal_hbn_init(uint8_t *pinbuf,uint8_t pinbuf_size) + +{ + TickType_t TVar1; + char *format; + uint8_t *puVar2; + utils_notifier_t *node; + undefined3 in_register_0000202d; + size_t __n; + undefined4 uVar3; + + __n = CONCAT31(in_register_0000202d,pinbuf_size); + if ((int)((__n - 1) * 0x1000000) >> 0x18 < 0) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + uVar3 = 0x51; + format = "[%10u][%s: %s:%4d] arg error.\r\n"; +LAB_23085956: + bl_printk(format,TVar1,&DAT_230a9dd8,"hal_hbn.c",uVar3); + return -1; + } + puVar2 = (uint8_t *)pvPortMalloc(__n + 3); + if (puVar2 == (uint8_t *)0x0) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + uVar3 = 0x56; + format = "[%10u][%s: %s:%4d] mem error"; + goto LAB_23085956; + } + puVar2[1] = '\x01'; + *puVar2 = pinbuf_size; + memcpy(puVar2 + 2,pinbuf,__n); + if (hbn_list == (ntf_list_t *)0x0) { + hbn_list = (ntf_list_t *)pvPortMalloc(8); + if (hbn_list == (ntf_list_t *)0x0) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] malloc error.\r\n",TVar1,&DAT_230a9dd8,"hal_hbn.c",0x30); + } + else { + utils_notifier_chain_init(hbn_list); + } + if (hbn_list == (ntf_list_t *)0x0) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + uVar3 = 0x3c; + format = "[%10u][%s: %s:%4d] ntfgpio not init.\r\n"; + goto LAB_23085a3c; + } + } + node = (utils_notifier_t *)pvPortMalloc(0x10); + if (node != (utils_notifier_t *)0x0) { + node->cb = bl_hbn_enter; + *(uint8_t **)&node->cb_arg = puVar2; + utils_notifier_chain_register(hbn_list,node); + return 0; + } + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + uVar3 = 0x41; + format = "[%10u][%s: %s:%4d] malloc error.\r\n"; +LAB_23085a3c: + bl_printk(format,TVar1,&DAT_230a9dd8,"hal_hbn.c",uVar3); + return 0; +} + + + +int hal_hbn_enter(uint32_t time) + +{ + uint32_t auStack20 [4]; + + auStack20[0] = time; + utils_notifier_chain_call(hbn_list,auStack20); + return -1; +} + + + +// WARNING: Variable defined which should be unmapped: cfg +// WARNING: Could not reconcile some variable overlaps + +int bl_hbn_enter(hbn_type_t *hbn,uint32_t *time) + +{ + char *fmt; + uint8_t uVar1; + uint8_t uVar2; + undefined auStack36 [4]; + HBN_APP_CFG_Type cfg; + + memcpy(auStack36,&DAT_230c67a8,0x14); + if (hbn != (hbn_type_t *)0x0) { + printf("hbn.buflen = %d\r\n",(uint)hbn->buflen); + printf("hbn.active = %d\r\n",(uint)hbn->active); + log_buf_out("bl_hbn.c",0x9c,hbn->buf,(uint)hbn->buflen,LOG_BUF_OUT_DATA_TYPE_HEX); + } + cfg._0_4_ = (*time + 999) / 1000; + if ((hbn->buf == (uint8_t *)0x0) || + (cfg.sleepTime._0_1_ = hbn->buflen, 1 < (byte)((uint8_t)cfg.sleepTime - 1))) { + fmt = "not support arg.\r\n"; + goto LAB_23085b4e; + } + uVar2 = hbn->buf[0]; + if ((uint8_t)cfg.sleepTime == '\x01') { + if ((byte)(uVar2 - 7) < 2) { + if (uVar2 == '\a') { + printf("hbn gpio7.\r\n"); + } + else { + printf("hbn gpio8.\r\n"); + cfg.sleepTime._0_1_ = '\x02'; + } + goto LAB_23085b8a; + } + } + else { + uVar1 = '\a'; + if (uVar2 == '\a') { + uVar1 = hbn[1].buflen; + uVar2 = '\b'; + } + else { + if (uVar2 != '\b') goto LAB_23085be8; + uVar2 = hbn[1].buflen; + } + if (uVar2 == uVar1) { + printf("hbn gpio_all.\r\n"); + cfg.sleepTime._0_1_ = '\x03'; +LAB_23085b8a: + cfg._8_4_ = (SPI_Flash_Cfg_Type *)bl_flash_get_flashCfg(); + HBN_Clear_IRQ(HBN_INT_GPIO7); + HBN_Clear_IRQ(HBN_INT_GPIO8); + HBN_Mode_Enter((HBN_APP_CFG_Type *)auStack36); + return -1; + } + } +LAB_23085be8: + fmt = "invalid arg.\r\n"; +LAB_23085b4e: + printf(fmt); + return -1; +} + + + +err_t httpc_tcp_sent(void *arg,altcp_pcb *pcb,u16_t len) + +{ + return '\0'; +} + + + +err_t httpc_get_internal_addr(httpc_state_t *req,ip_addr_t *ipaddr) + +{ + err_t eVar1; + + if (&req->remote_addr != ipaddr) { + (req->remote_addr).addr = ipaddr->addr; + } + eVar1 = altcp_connect(req->pcb,&req->remote_addr,req->remote_port,httpc_tcp_connected); + return eVar1; +} + + + +err_t httpc_free_state(httpc_state_t *req) + +{ + altcp_pcb *conn; + err_t eVar1; + undefined3 extraout_var; + + if (req->request != (pbuf *)0x0) { + pbuf_free(req->request); + req->request = (pbuf *)0x0; + } + if (req->rx_hdrs != (pbuf *)0x0) { + pbuf_free(req->rx_hdrs); + req->rx_hdrs = (pbuf *)0x0; + } + conn = req->pcb; + mem_free(req); + if (conn != (altcp_pcb *)0x0) { + altcp_arg(conn,(void *)0x0); + altcp_recv(conn,(altcp_recv_fn *)0x0); + altcp_err(conn,(altcp_err_fn *)0x0); + altcp_poll(conn,(altcp_poll_fn *)0x0,'\0'); + altcp_sent(conn,(altcp_sent_fn *)0x0); + eVar1 = altcp_close(conn); + if (CONCAT31(extraout_var,eVar1) != 0) { + altcp_abort(conn); + return -0xd; + } + } + return '\0'; +} + + + +err_t httpc_close(httpc_state_t *req,httpc_result_t result,u32_t server_response,err_t err) + +{ + err_t eVar1; + httpc_result_fn *phVar2; + + if (req != (httpc_state_t *)0x0) { + if ((req->conn_settings != (httpc_connection_t_conflict *)0x0) && + (phVar2 = req->conn_settings->result_fn, phVar2 != (httpc_result_fn *)0x0)) { + (*phVar2)(req->callback_arg,result,req->rx_content_len,server_response,err); + } + eVar1 = httpc_free_state(req); + return eVar1; + } + return '\0'; +} + + + +err_t httpc_tcp_recv(void *arg,altcp_pcb *pcb,pbuf *p,err_t r) + +{ + ushort uVar1; + uint uVar2; + err_t err; + u8_t uVar3; + byte bVar4; + u16_t len; + u16_t start_offset; + undefined2 extraout_var_01; + undefined2 extraout_var_02; + undefined2 extraout_var_03; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined2 extraout_var_04; + undefined2 extraout_var_05; + undefined2 extraout_var_06; + undefined2 extraout_var_07; + undefined2 extraout_var_08; + undefined2 extraout_var_09; + httpc_result_t result; + u16_t start_offset_00; + undefined3 in_register_00002035; + code *pcVar5; + int iVar6; + pbuf *p_00; + char acStack64 [4]; + char status_num [10]; + + *(undefined4 *)((int)arg + 0xc) = 0x1e; + if (p == (pbuf *)0x0) { + result = HTTPC_RESULT_ERR_CLOSED; + if (*(char *)((int)arg + 0x30) == '\x02') { + result = HTTPC_RESULT_OK; + if ((*(int *)((int)arg + 0x2c) != -1) && + (*(int *)((int)arg + 0x2c) != *(int *)((int)arg + 0x28))) { + result = HTTPC_RESULT_ERR_CONTENT_LEN; + } + } + uVar1 = *(ushort *)((int)arg + 0x1a); + err = '\0'; + goto LAB_23085cf8; + } + if (*(char *)((int)arg + 0x30) == '\x02') goto LAB_23085d24; + if (*(pbuf **)((int)arg + 0x14) == (pbuf *)0x0) { + *(pbuf **)((int)arg + 0x14) = p; + } + else { + pbuf_cat(*(pbuf **)((int)arg + 0x14),p); + } + if (*(char *)((int)arg + 0x30) == '\0') { + p_00 = *(pbuf **)((int)arg + 0x14); + len = pbuf_memfind(p_00,"\r\n",2,0); + if (CONCAT22(extraout_var_01,len) == 0xffff) goto LAB_23085efc; + start_offset = pbuf_memfind(p_00," ",1,0); + iVar6 = CONCAT22(extraout_var_02,start_offset); + if (((iVar6 == 0xffff) || + (start_offset = pbuf_memcmp(p_00,0,&DAT_230c69cc,5), + CONCAT22(extraout_var_03,start_offset) != 0)) || + (uVar3 = pbuf_get_at(p_00,6), CONCAT31(extraout_var,uVar3) != 0x2e)) goto LAB_23085efc; + bVar4 = pbuf_get_at(p_00,5); + uVar3 = pbuf_get_at(p_00,7); + *(ushort *)((int)arg + 0x18) = + (short)CONCAT31(extraout_var_00,uVar3) - 0x30U | + (ushort)(((uint)bVar4 - 0x30 & 0xffff) << 8); + start_offset_00 = (u16_t)((uint)((iVar6 + 1) * 0x10000) >> 0x10); + start_offset = pbuf_memfind(p_00," ",1,start_offset_00); + if (CONCAT22(extraout_var_04,start_offset) == 0xffff) { + iVar6 = CONCAT22(extraout_var_01,len) - iVar6; + } + else { + iVar6 = CONCAT22(extraout_var_04,start_offset) - iVar6; + } + memset(acStack64,0,10); + len = pbuf_copy_partial(p_00,acStack64,(u16_t)((uint)((iVar6 + -1) * 0x10000) >> 0x10), + start_offset_00); + if ((iVar6 + -1 != CONCAT22(extraout_var_05,len)) || + (iVar6 = atoi(acStack64), 0xfffe < iVar6 - 1U)) goto LAB_23085efc; + *(undefined2 *)((int)arg + 0x1a) = (short)iVar6; + *(undefined *)((int)arg + 0x30) = 1; +LAB_23085e34: + p_00 = *(pbuf **)((int)arg + 0x14); + len = pbuf_memfind(p_00,&DAT_230adb8c,4,0); + if (CONCAT22(extraout_var_06,len) < 0xfffd) { + *(undefined4 *)((int)arg + 0x2c) = 0xffffffff; + start_offset = pbuf_memfind(p_00,"Content-Length: ",0x10,0); + iVar6 = CONCAT22(extraout_var_07,start_offset); + if (iVar6 != 0xffff) { + start_offset = pbuf_memfind(p_00,"\r\n",2,start_offset); + if (CONCAT22(extraout_var_08,start_offset) != 0xffff) { + memset(acStack64,0,0x10); + uVar2 = (CONCAT22(extraout_var_08,start_offset) - iVar6) - 0x10; + start_offset = pbuf_copy_partial(p_00,acStack64,(u16_t)(uVar2 * 0x10000 >> 0x10), + (u16_t)((uint)((iVar6 + 0x10) * 0x10000) >> 0x10)); + if (((uVar2 & 0xffff) == CONCAT22(extraout_var_09,start_offset)) && + (iVar6 = atoi(acStack64), -1 < iVar6)) { + *(int *)((int)arg + 0x2c) = iVar6; + } + } + } + uVar2 = CONCAT22(extraout_var_06,len) + 4; + len = (u16_t)(uVar2 * 0x10000 >> 0x10); + altcp_recved(pcb,len); + if ((*(int *)((int)arg + 0x20) != 0) && + (pcVar5 = *(code **)(*(int *)((int)arg + 0x20) + 0x18), pcVar5 != (code *)0x0)) { + iVar6 = (*pcVar5)(arg,*(undefined4 *)((int)arg + 0x24),*(undefined4 *)((int)arg + 0x14), + uVar2 & 0xffff,*(undefined4 *)((int)arg + 0x2c)); + err = (err_t)iVar6; + if (iVar6 != 0) { + uVar1 = *(ushort *)((int)arg + 0x1a); + result = HTTPC_RESULT_LOCAL_ABORT; +LAB_23085cf8: + err = httpc_close((httpc_state_t *)arg,result,(uint)uVar1,err); + return err; + } + } + p = pbuf_free_header(*(pbuf **)((int)arg + 0x14),len); + *(undefined4 *)((int)arg + 0x14) = 0; + *(undefined *)((int)arg + 0x30) = 2; + if (p == (pbuf *)0x0) { + return '\0'; + } + goto LAB_23085d24; + } + } + else { +LAB_23085efc: + if (*(char *)((int)arg + 0x30) == '\x01') goto LAB_23085e34; + } + if (*(char *)((int)arg + 0x30) != '\x02') { + return '\0'; + } +LAB_23085d24: + *(int *)((int)arg + 0x28) = *(int *)((int)arg + 0x28) + (uint)p->tot_len; + if (*(code **)((int)arg + 0x1c) == (code *)0x0) { + altcp_recved(pcb,p->tot_len); + pbuf_free(p); + return '\0'; + } + err = (**(code **)((int)arg + 0x1c)) + (*(undefined4 *)((int)arg + 0x24),pcb,p,CONCAT31(in_register_00002035,r)); + return err; +} + + + +void httpc_dns_found(char *hostname,ip_addr_t *ipaddr,void *arg) + +{ + err_t err; + undefined3 extraout_var; + httpc_result_t result; + + if (ipaddr == (ip_addr_t *)0x0) { + result = HTTPC_RESULT_ERR_HOSTNAME; + err = -0x10; + } + else { + err = httpc_get_internal_addr((httpc_state_t *)arg,ipaddr); + result = HTTPC_RESULT_ERR_CONNECT; + if (CONCAT31(extraout_var,err) == 0) { + return; + } + } + httpc_close((httpc_state_t *)arg,result,0,err); + return; +} + + + +err_t httpc_tcp_poll(void *arg,altcp_pcb *pcb) + +{ + err_t eVar1; + int iVar2; + + if ((arg != (void *)0x0) && + ((*(int *)((int)arg + 0xc) == 0 || + (iVar2 = *(int *)((int)arg + 0xc) + -1, *(int *)((int)arg + 0xc) = iVar2, iVar2 == 0)))) { + eVar1 = httpc_close((httpc_state_t *)arg,HTTPC_RESULT_ERR_TIMEOUT,0,'\0'); + return eVar1; + } + return '\0'; +} + + + +void httpc_tcp_err(void *arg,err_t err) + +{ + if (arg != (void *)0x0) { + *(undefined4 *)arg = 0; + httpc_close((httpc_state_t *)arg,HTTPC_RESULT_ERR_CLOSED,0,err); + return; + } + return; +} + + + +err_t httpc_tcp_connected(void *arg,altcp_pcb *pcb,err_t err) + +{ + err_t err_00; + undefined3 extraout_var; + + err_00 = altcp_write(*(altcp_pcb **)arg,*(void **)(*(int *)((int)arg + 0x10) + 4), + (u16_t)(((uint)*(ushort *)(*(int *)((int)arg + 0x10) + 10) - 1) * 0x10000 >> + 0x10),'\x01'); + if (CONCAT31(extraout_var,err_00) != 0) { + err_00 = httpc_close((httpc_state_t *)arg,HTTPC_RESULT_ERR_MEM,0,err_00); + return err_00; + } + pbuf_free(*(pbuf **)((int)arg + 0x10)); + *(undefined4 *)((int)arg + 0x10) = 0; + altcp_output(*(altcp_pcb **)arg); + return '\0'; +} + + + +int httpc_create_request_string + (httpc_connection_t_conflict *settings,char *server_name,int server_port,char *uri, + char *buffer,size_t buffer_size) + +{ + int iVar1; + size_t sVar2; + char *pcVar3; + + if (settings->use_proxy == '\0') { + if (settings->req_type == '\x01') { + pcVar3 = (char *)0x0; + if (settings->content_type < 4) { + pcVar3 = g_cont_type[settings->content_type]; + } + sVar2 = strlen((char *)settings->data); + iVar1 = snprintf(buffer,buffer_size, + + "POST %s HTTP/1.1\r\nContent-Type: %s\r\nContent-Length: %d\r\nUser-Agent: %s\r\nHost: %s\r\nAccept: */*\r\nConnection: Close\r\n\r\n%s" + ,uri,pcVar3,sVar2,&UNK_230c6844,server_name); + return iVar1; + } + iVar1 = snprintf(buffer,buffer_size, + + "GET %s HTTP/1.1\r\nUser-Agent: %s\r\nAccept: */*\r\nHost: %s\r\nConnection: Close\r\n\r\n" + ,&UNK_230c6844,server_name); + return iVar1; + } + if (server_port != 0x50) { + iVar1 = snprintf(buffer,buffer_size, + + "GET http://%s:%d%s HTTP/1.1\r\nUser-Agent: %s\r\nAccept: */*\r\nHost: %s\r\nConnection: Close\r\n\r\n" + ,server_name,server_port,uri,&UNK_230c6844); + return iVar1; + } + iVar1 = snprintf(buffer,buffer_size, + + "GET http://%s%s HTTP/1.1\r\nUser-Agent: %s\r\nAccept: */*\r\nHost: %s\r\nConnection: Close\r\n\r\n" + ,server_name,uri,&UNK_230c6844,server_name); + return iVar1; +} + + + +err_t httpc_init_connection_common + (httpc_state_t **connection,httpc_connection_t_conflict *settings,char *server_name, + u16_t server_port,char *uri,altcp_recv_fn *recv_fn,void *callback_arg) + +{ + uint uVar1; + httpc_state_t *req; + pbuf *ppVar2; + altcp_pcb *conn; + uint uVar3; + undefined2 in_register_00002036; + int server_port_00; + err_t eVar4; + + server_port_00 = CONCAT22(in_register_00002036,server_port); + uVar1 = httpc_create_request_string(settings,server_name,server_port_00,uri,(char *)0x0,0); + if (uVar1 < 0xffff) { + req = (httpc_state_t *)mem_malloc(0x34); + if (req == (httpc_state_t *)0x0) { + return -1; + } + memset(req,0,0x34); + req->timeout_ticks = 0x1e; + ppVar2 = pbuf_alloc(PBUF_RAW,(u16_t)((uVar1 + 1) * 0x10000 >> 0x10),PBUF_RAM); + req->request = ppVar2; + if ((ppVar2 != (pbuf *)0x0) && (ppVar2->next == (pbuf *)0x0)) { + req->hdr_content_len = 0xffffffff; + conn = altcp_new(settings->altcp_allocator); + req->pcb = conn; + if (conn != (altcp_pcb *)0x0) { + if (settings->use_proxy != '\0') { + server_port = settings->proxy_port; + } + req->remote_port = server_port; + altcp_arg(conn,req); + altcp_recv(req->pcb,httpc_tcp_recv); + altcp_err(req->pcb,httpc_tcp_err); + altcp_poll(req->pcb,httpc_tcp_poll,'\x01'); + altcp_sent(req->pcb,httpc_tcp_sent); + uVar3 = httpc_create_request_string + (settings,server_name,server_port_00,uri,(char *)req->request->payload, + uVar1 + 1); + if (uVar1 == uVar3) { + req->recv_fn = recv_fn; + req->conn_settings = settings; + req->callback_arg = callback_arg; + *connection = req; + return '\0'; + } + httpc_free_state(req); + goto LAB_230861dc; + } + } + httpc_free_state(req); + eVar4 = -1; + } + else { +LAB_230861dc: + eVar4 = -6; + } + return eVar4; +} + + + +err_t httpc_get_file(ip_addr_t *server_addr,u16_t port,char *uri, + httpc_connection_t_conflict *settings,altcp_recv_fn *recv_fn,void *callback_arg, + httpc_state_t **connection) + +{ + err_t eVar1; + char *server_name; + undefined3 extraout_var; + undefined3 extraout_var_00; + httpc_state_t *phStack36; + httpc_state_t *req; + + eVar1 = -0x10; + if (((server_addr != (ip_addr_t *)0x0) && (uri != (char *)0x0)) && + (recv_fn != (altcp_recv_fn *)0x0)) { + server_name = ip4addr_ntoa((ip4_addr_t *)server_addr); + eVar1 = -6; + if ((server_name != (char *)0x0) && + (eVar1 = httpc_init_connection_common + (&phStack36,settings,server_name,port,uri,recv_fn,callback_arg), + CONCAT31(extraout_var,eVar1) == 0)) { + if (settings->use_proxy == '\0') { + settings = (httpc_connection_t_conflict *)server_addr; + } + eVar1 = httpc_get_internal_addr(phStack36,(ip_addr_t *)settings); + if (CONCAT31(extraout_var_00,eVar1) == 0) { + if (connection != (httpc_state_t **)0x0) { + *connection = phStack36; + } + } + else { + httpc_free_state(phStack36); + } + } + } + return eVar1; +} + + + +err_t httpc_get_file_dns(char *server_name,u16_t port,char *uri, + httpc_connection_t_conflict *settings,altcp_recv_fn *recv_fn, + void *callback_arg,httpc_state_t **connection) + +{ + httpc_state_t *req_00; + err_t eVar1; + err_t eVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + httpc_state_t *phStack36; + httpc_state_t *req; + + if (server_name == (char *)0x0) { + return -0x10; + } + if (uri == (char *)0x0) { + return -0x10; + } + if (recv_fn == (altcp_recv_fn *)0x0) { + return -0x10; + } + eVar1 = httpc_init_connection_common + (&phStack36,settings,server_name,port,uri,recv_fn,callback_arg); + req_00 = phStack36; + if (CONCAT31(extraout_var,eVar1) != 0) { + return eVar1; + } + if (settings->use_proxy == '\0') { + settings = (httpc_connection_t_conflict *)&phStack36->remote_addr; + eVar2 = dns_gethostbyname(server_name,(ip_addr_t *)settings,httpc_dns_found,phStack36); + if (CONCAT31(extraout_var_01,eVar2) != 0) { + if (CONCAT31(extraout_var_01,eVar2) == -5) goto LAB_230862ec; + goto LAB_230862b2; + } + } + eVar2 = httpc_get_internal_addr(req_00,(ip_addr_t *)settings); + if (CONCAT31(extraout_var_00,eVar2) == 0) { +LAB_230862ec: + if (connection == (httpc_state_t **)0x0) { + return eVar1; + } + *connection = phStack36; + return eVar1; + } +LAB_230862b2: + httpc_free_state(phStack36); + return eVar2; +} + + + +// WARNING: Variable defined which should be unmapped: addr + +void set_if(netif *netif,char *ip_addr,char *gw_addr,char *nm_addr) + +{ + int iVar1; + ip4_addr_t iStack20; + ip4_addr_t addr; + + if ((ip_addr != (char *)0x0) && (iVar1 = ip4addr_aton(ip_addr,&iStack20), iVar1 != 0)) { + netif_set_ipaddr(netif,&iStack20); + } + if ((gw_addr != (char *)0x0) && (iVar1 = ip4addr_aton(gw_addr,&iStack20), iVar1 != 0)) { + netif_set_gw(netif,&iStack20); + } + if ((nm_addr != (char *)0x0) && (iVar1 = ip4addr_aton(nm_addr,&iStack20), iVar1 != 0)) { + netif_set_netmask(netif,&iStack20); + } + return; +} + + + +altcp_pcb * altcp_alloc(void) + +{ + altcp_pcb *__s; + + __s = (altcp_pcb *)memp_malloc(MEMP_ALTCP_PCB); + if (__s != (altcp_pcb *)0x0) { + memset(__s,0,0x2c); + } + return __s; +} + + + +void altcp_free(altcp_pcb *conn) + +{ + altcp_dealloc_fn paVar1; + + if (conn == (altcp_pcb *)0x0) { + return; + } + if ((conn->fns != (altcp_functions *)0x0) && + (paVar1 = conn->fns->dealloc, paVar1 != (altcp_dealloc_fn)0x0)) { + (*paVar1)(conn); + } + memp_free(MEMP_ALTCP_PCB,conn); + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +altcp_pcb * altcp_new_ip_type(altcp_allocator_t *allocator,u8_t ip_type) + +{ + altcp_pcb *paVar1; + + if (allocator == (altcp_allocator_t *)0x0) { + paVar1 = altcp_tcp_new_ip_type(ip_type); + return paVar1; + } + if (allocator->alloc != (altcp_new_fn *)0x0) { + // WARNING: Could not recover jumptable at 0x230863ae. Too many branches + // WARNING: Treating indirect jump as call + paVar1 = (*allocator->alloc)(allocator->arg); + return paVar1; + } + return (altcp_pcb *)0x0; +} + + + +altcp_pcb * altcp_new(altcp_allocator_t *allocator) + +{ + altcp_pcb *paVar1; + + paVar1 = altcp_new_ip_type(allocator,'\0'); + return paVar1; +} + + + +void altcp_arg(altcp_pcb *conn,void *arg) + +{ + if (conn != (altcp_pcb *)0x0) { + conn->arg = arg; + } + return; +} + + + +void altcp_accept(altcp_pcb *conn,altcp_accept_fn accept) + +{ + if (conn != (altcp_pcb *)0x0) { + *(altcp_accept_fn *)&conn->accept = accept; + } + return; +} + + + +void altcp_recv(altcp_pcb *conn,altcp_recv_fn *recv) + +{ + if (conn != (altcp_pcb *)0x0) { + conn->recv = recv; + } + return; +} + + + +void altcp_sent(altcp_pcb *conn,altcp_sent_fn *sent) + +{ + if (conn != (altcp_pcb *)0x0) { + conn->sent = sent; + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void altcp_poll(altcp_pcb *conn,altcp_poll_fn *poll,u8_t interval) + +{ + altcp_set_poll_fn UNRECOVERED_JUMPTABLE; + undefined3 in_register_00002031; + + if (conn != (altcp_pcb *)0x0) { + conn->poll = poll; + conn->pollinterval = interval; + if ((conn->fns != (altcp_functions *)0x0) && + (UNRECOVERED_JUMPTABLE = conn->fns->set_poll, UNRECOVERED_JUMPTABLE != (altcp_set_poll_fn)0x0 + )) { + // WARNING: Could not recover jumptable at 0x230863e8. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)((altcp_pcb *)CONCAT31(in_register_00002031,interval)); + return; + } + } + return; +} + + + +void altcp_err(altcp_pcb *conn,altcp_err_fn *err) + +{ + if (conn != (altcp_pcb *)0x0) { + conn->err = err; + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void altcp_recved(altcp_pcb *conn,u16_t len) + +{ + altcp_recved_fn *UNRECOVERED_JUMPTABLE; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->recved, UNRECOVERED_JUMPTABLE != (altcp_recved_fn *)0x0)) { + // WARNING: Could not recover jumptable at 0x23086400. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(); + return; + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +err_t altcp_bind(altcp_pcb *conn,ip_addr_t *ipaddr,u16_t port) + +{ + altcp_bind_fn *UNRECOVERED_JUMPTABLE; + err_t eVar1; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->bind, UNRECOVERED_JUMPTABLE != (altcp_bind_fn *)0x0)) { + // WARNING: Could not recover jumptable at 0x23086412. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (*UNRECOVERED_JUMPTABLE)(); + return eVar1; + } + return -6; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +err_t altcp_connect(altcp_pcb *conn,ip_addr_t *ipaddr,u16_t port,altcp_connected_fn connected) + +{ + altcp_connect_fn *UNRECOVERED_JUMPTABLE; + err_t eVar1; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->connect, UNRECOVERED_JUMPTABLE != (altcp_connect_fn *)0x0)) + { + // WARNING: Could not recover jumptable at 0x23086426. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (*UNRECOVERED_JUMPTABLE)(); + return eVar1; + } + return -6; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +altcp_pcb * altcp_listen_with_backlog_and_err(altcp_pcb *conn,u8_t backlog,err_t *err) + +{ + altcp_listen_fn *UNRECOVERED_JUMPTABLE; + altcp_pcb *paVar1; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->listen, UNRECOVERED_JUMPTABLE != (altcp_listen_fn *)0x0)) { + // WARNING: Could not recover jumptable at 0x2308643a. Too many branches + // WARNING: Treating indirect jump as call + paVar1 = (*UNRECOVERED_JUMPTABLE)(); + return paVar1; + } + return (altcp_pcb *)0x0; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void altcp_abort(altcp_pcb *conn) + +{ + altcp_abort_fn UNRECOVERED_JUMPTABLE; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->abort, UNRECOVERED_JUMPTABLE != (altcp_abort_fn)0x0)) { + // WARNING: Could not recover jumptable at 0x2308644e. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(); + return; + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +err_t altcp_close(altcp_pcb *conn) + +{ + altcp_close_fn UNRECOVERED_JUMPTABLE; + err_t eVar1; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->close, UNRECOVERED_JUMPTABLE != (altcp_close_fn)0x0)) { + // WARNING: Could not recover jumptable at 0x23086460. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (*UNRECOVERED_JUMPTABLE)(); + return eVar1; + } + return -6; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +err_t altcp_shutdown(altcp_pcb *conn,int shut_rx,int shut_tx) + +{ + altcp_shutdown_fn *UNRECOVERED_JUMPTABLE; + err_t eVar1; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->shutdown, UNRECOVERED_JUMPTABLE != (altcp_shutdown_fn *)0x0 + )) { + // WARNING: Could not recover jumptable at 0x23086474. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (*UNRECOVERED_JUMPTABLE)(); + return eVar1; + } + return -6; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +err_t altcp_write(altcp_pcb *conn,void *dataptr,u16_t len,u8_t apiflags) + +{ + altcp_write_fn *UNRECOVERED_JUMPTABLE; + err_t eVar1; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->write, UNRECOVERED_JUMPTABLE != (altcp_write_fn *)0x0)) { + // WARNING: Could not recover jumptable at 0x23086488. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (*UNRECOVERED_JUMPTABLE)(); + return eVar1; + } + return -6; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +err_t altcp_output(altcp_pcb *conn) + +{ + altcp_output_fn UNRECOVERED_JUMPTABLE; + err_t eVar1; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->output, UNRECOVERED_JUMPTABLE != (altcp_output_fn)0x0)) { + // WARNING: Could not recover jumptable at 0x2308649c. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (*UNRECOVERED_JUMPTABLE)(); + return eVar1; + } + return -6; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +u16_t altcp_mss(altcp_pcb *conn) + +{ + altcp_mss_fn UNRECOVERED_JUMPTABLE; + u16_t uVar1; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->mss, UNRECOVERED_JUMPTABLE != (altcp_mss_fn)0x0)) { + // WARNING: Could not recover jumptable at 0x230864b0. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*UNRECOVERED_JUMPTABLE)(); + return uVar1; + } + return 0; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +u16_t altcp_sndbuf(altcp_pcb *conn) + +{ + altcp_sndbuf_fn UNRECOVERED_JUMPTABLE; + u16_t uVar1; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->sndbuf, UNRECOVERED_JUMPTABLE != (altcp_sndbuf_fn)0x0)) { + // WARNING: Could not recover jumptable at 0x230864c4. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*UNRECOVERED_JUMPTABLE)(); + return uVar1; + } + return 0; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +u16_t altcp_sndqueuelen(altcp_pcb *conn) + +{ + altcp_sndqueuelen_fn UNRECOVERED_JUMPTABLE; + u16_t uVar1; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->sndqueuelen, + UNRECOVERED_JUMPTABLE != (altcp_sndqueuelen_fn)0x0)) { + // WARNING: Could not recover jumptable at 0x230864d8. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*UNRECOVERED_JUMPTABLE)(); + return uVar1; + } + return 0; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void altcp_nagle_disable(altcp_pcb *conn) + +{ + altcp_nagle_disable_fn UNRECOVERED_JUMPTABLE; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->nagle_disable, + UNRECOVERED_JUMPTABLE != (altcp_nagle_disable_fn)0x0)) { + // WARNING: Could not recover jumptable at 0x230864ec. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(); + return; + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void altcp_nagle_enable(altcp_pcb *conn) + +{ + altcp_nagle_enable_fn UNRECOVERED_JUMPTABLE; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->nagle_enable, + UNRECOVERED_JUMPTABLE != (altcp_nagle_enable_fn)0x0)) { + // WARNING: Could not recover jumptable at 0x230864fe. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(); + return; + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +int altcp_nagle_disabled(altcp_pcb *conn) + +{ + altcp_nagle_disabled_fn *UNRECOVERED_JUMPTABLE; + int iVar1; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->nagle_disabled, + UNRECOVERED_JUMPTABLE != (altcp_nagle_disabled_fn *)0x0)) { + // WARNING: Could not recover jumptable at 0x23086510. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*UNRECOVERED_JUMPTABLE)(); + return iVar1; + } + return 0; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void altcp_setprio(altcp_pcb *conn,u8_t prio) + +{ + altcp_setprio_fn UNRECOVERED_JUMPTABLE; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->setprio, UNRECOVERED_JUMPTABLE != (altcp_setprio_fn)0x0)) { + // WARNING: Could not recover jumptable at 0x23086524. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(); + return; + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +err_t altcp_get_tcp_addrinfo(altcp_pcb *conn,int local,ip_addr_t *addr,u16_t *port) + +{ + altcp_get_tcp_addrinfo_fn *UNRECOVERED_JUMPTABLE; + err_t eVar1; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->addrinfo, + UNRECOVERED_JUMPTABLE != (altcp_get_tcp_addrinfo_fn *)0x0)) { + // WARNING: Could not recover jumptable at 0x23086536. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (*UNRECOVERED_JUMPTABLE)(); + return eVar1; + } + return -6; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +ip_addr_t * altcp_get_ip(altcp_pcb *conn,int local) + +{ + altcp_get_ip_fn *UNRECOVERED_JUMPTABLE; + ip_addr_t *piVar1; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->getip, UNRECOVERED_JUMPTABLE != (altcp_get_ip_fn *)0x0)) { + // WARNING: Could not recover jumptable at 0x2308654a. Too many branches + // WARNING: Treating indirect jump as call + piVar1 = (*UNRECOVERED_JUMPTABLE)(); + return piVar1; + } + return (ip_addr_t *)0x0; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +u16_t altcp_get_port(altcp_pcb *conn,int local) + +{ + altcp_get_port_fn *UNRECOVERED_JUMPTABLE; + u16_t uVar1; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->getport, UNRECOVERED_JUMPTABLE != (altcp_get_port_fn *)0x0) + ) { + // WARNING: Could not recover jumptable at 0x2308655e. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*UNRECOVERED_JUMPTABLE)(); + return uVar1; + } + return 0; +} + + + +err_t altcp_default_bind(altcp_pcb *conn,ip_addr_t *ipaddr,u16_t port) + +{ + err_t eVar1; + + if ((conn != (altcp_pcb *)0x0) && (conn->inner_conn != (altcp_pcb *)0x0)) { + eVar1 = altcp_bind(conn->inner_conn,ipaddr,port); + return eVar1; + } + return -6; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +err_t altcp_default_shutdown(altcp_pcb *conn,int shut_rx,int shut_tx) + +{ + altcp_close_fn UNRECOVERED_JUMPTABLE; + err_t eVar1; + + if (conn != (altcp_pcb *)0x0) { + if ((((shut_rx != 0) && (shut_tx != 0)) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->close, UNRECOVERED_JUMPTABLE != (altcp_close_fn)0x0)) { + // WARNING: Could not recover jumptable at 0x23086586. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (*UNRECOVERED_JUMPTABLE)(); + return eVar1; + } + if (conn->inner_conn != (altcp_pcb *)0x0) { + eVar1 = altcp_shutdown(conn->inner_conn,shut_rx,shut_tx); + return eVar1; + } + } + return -6; +} + + + +err_t altcp_default_output(altcp_pcb *conn) + +{ + err_t eVar1; + + if ((conn != (altcp_pcb *)0x0) && (conn->inner_conn != (altcp_pcb *)0x0)) { + eVar1 = altcp_output(conn->inner_conn); + return eVar1; + } + return -6; +} + + + +u16_t altcp_default_sndbuf(altcp_pcb *conn) + +{ + u16_t uVar1; + + if ((conn != (altcp_pcb *)0x0) && (conn->inner_conn != (altcp_pcb *)0x0)) { + uVar1 = altcp_sndbuf(conn->inner_conn); + return uVar1; + } + return 0; +} + + + +u16_t altcp_default_sndqueuelen(altcp_pcb *conn) + +{ + u16_t uVar1; + + if ((conn != (altcp_pcb *)0x0) && (conn->inner_conn != (altcp_pcb *)0x0)) { + uVar1 = altcp_sndqueuelen(conn->inner_conn); + return uVar1; + } + return 0; +} + + + +void altcp_default_nagle_disable(altcp_pcb *conn) + +{ + if ((conn != (altcp_pcb *)0x0) && (conn->inner_conn != (altcp_pcb *)0x0)) { + altcp_nagle_disable(conn->inner_conn); + return; + } + return; +} + + + +void altcp_default_nagle_enable(altcp_pcb *conn) + +{ + if ((conn != (altcp_pcb *)0x0) && (conn->inner_conn != (altcp_pcb *)0x0)) { + altcp_nagle_enable(conn->inner_conn); + return; + } + return; +} + + + +int altcp_default_nagle_disabled(altcp_pcb *conn) + +{ + int iVar1; + + if ((conn != (altcp_pcb *)0x0) && (conn->inner_conn != (altcp_pcb *)0x0)) { + iVar1 = altcp_nagle_disabled(conn->inner_conn); + return iVar1; + } + return 0; +} + + + +void altcp_default_setprio(altcp_pcb *conn,u8_t prio) + +{ + if ((conn != (altcp_pcb *)0x0) && (conn->inner_conn != (altcp_pcb *)0x0)) { + altcp_setprio(conn->inner_conn,prio); + return; + } + return; +} + + + +err_t altcp_default_get_tcp_addrinfo(altcp_pcb *conn,int local,ip_addr_t *addr,u16_t *port) + +{ + err_t eVar1; + + if ((conn != (altcp_pcb *)0x0) && (conn->inner_conn != (altcp_pcb *)0x0)) { + eVar1 = altcp_get_tcp_addrinfo(conn->inner_conn,local,addr,port); + return eVar1; + } + return -6; +} + + + +ip_addr_t * altcp_default_get_ip(altcp_pcb *conn,int local) + +{ + ip_addr_t *piVar1; + + if ((conn != (altcp_pcb *)0x0) && (conn->inner_conn != (altcp_pcb *)0x0)) { + piVar1 = altcp_get_ip(conn->inner_conn,local); + return piVar1; + } + return (ip_addr_t *)0x0; +} + + + +u16_t altcp_default_get_port(altcp_pcb *conn,int local) + +{ + u16_t uVar1; + + if ((conn != (altcp_pcb *)0x0) && (conn->inner_conn != (altcp_pcb *)0x0)) { + uVar1 = altcp_get_port(conn->inner_conn,local); + return uVar1; + } + return 0; +} + + + +altcp_pcb * altcp_tls_new(altcp_tls_config *config,u8_t ip_type) + +{ + altcp_pcb *inner_pcb; + altcp_pcb *paVar1; + + inner_pcb = altcp_tcp_new_ip_type(ip_type); + if (inner_pcb == (altcp_pcb *)0x0) { + paVar1 = (altcp_pcb *)0x0; + } + else { + paVar1 = altcp_tls_wrap(config,inner_pcb); + if (paVar1 == (altcp_pcb *)0x0) { + altcp_close(inner_pcb); + } + } + return paVar1; +} + + + +err_t altcp_tcp_connected(void *arg,tcp_pcb *tpcb,err_t err) + +{ + err_t eVar1; + + if ((arg != (void *)0x0) && (*(code **)((int)arg + 0x14) != (code *)0x0)) { + // WARNING: Could not recover jumptable at 0x2308665c. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (**(code **)((int)arg + 0x14))(*(undefined4 *)((int)arg + 8),arg); + return eVar1; + } + return '\0'; +} + + + +err_t altcp_tcp_sent(void *arg,tcp_pcb *tpcb,u16_t len) + +{ + err_t eVar1; + + if ((arg != (void *)0x0) && (*(code **)((int)arg + 0x1c) != (code *)0x0)) { + // WARNING: Could not recover jumptable at 0x23086670. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (**(code **)((int)arg + 0x1c))(*(undefined4 *)((int)arg + 8),arg); + return eVar1; + } + return '\0'; +} + + + +err_t altcp_tcp_poll(void *arg,tcp_pcb *tpcb) + +{ + err_t eVar1; + + if ((arg != (void *)0x0) && (*(code **)((int)arg + 0x20) != (code *)0x0)) { + // WARNING: Could not recover jumptable at 0x23086684. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (**(code **)((int)arg + 0x20))(*(undefined4 *)((int)arg + 8),arg); + return eVar1; + } + return '\0'; +} + + + +u16_t altcp_tcp_mss(altcp_pcb *conn) + +{ + if (conn != (altcp_pcb *)0x0) { + return *(u16_t *)((int)conn->state + 0x32); + } + return 0; +} + + + +u16_t altcp_tcp_sndbuf(altcp_pcb *conn) + +{ + if (conn != (altcp_pcb *)0x0) { + return *(u16_t *)((int)conn->state + 100); + } + return 0; +} + + + +u16_t altcp_tcp_sndqueuelen(altcp_pcb *conn) + +{ + if (conn != (altcp_pcb *)0x0) { + return *(u16_t *)((int)conn->state + 0x66); + } + return 0; +} + + + +void altcp_tcp_nagle_disable(altcp_pcb *conn) + +{ + void *pvVar1; + + if ((conn != (altcp_pcb *)0x0) && (pvVar1 = conn->state, pvVar1 != (void *)0x0)) { + *(ushort *)((int)pvVar1 + 0x1a) = *(ushort *)((int)pvVar1 + 0x1a) | 0x40; + } + return; +} + + + +void altcp_tcp_nagle_enable(altcp_pcb *conn) + +{ + void *pvVar1; + + if ((conn != (altcp_pcb *)0x0) && (pvVar1 = conn->state, pvVar1 != (void *)0x0)) { + *(ushort *)((int)pvVar1 + 0x1a) = *(ushort *)((int)pvVar1 + 0x1a) & 0xffbf; + } + return; +} + + + +int altcp_tcp_nagle_disabled(altcp_pcb *conn) + +{ + if ((conn != (altcp_pcb *)0x0) && (conn->state != (void *)0x0)) { + return (uint)(*(ushort *)((int)conn->state + 0x1a) >> 6) & 1; + } + return 0; +} + + + +void altcp_tcp_dealloc(altcp_pcb *conn) + +{ + return; +} + + + +ip_addr_t * altcp_tcp_get_ip(altcp_pcb *conn,int local) + +{ + if (((conn != (altcp_pcb *)0x0) && (conn = (altcp_pcb *)conn->state, conn != (altcp_pcb *)0x0)) && + (local == 0)) { + conn = (altcp_pcb *)&conn->inner_conn; + } + return (ip_addr_t *)conn; +} + + + +u16_t altcp_tcp_get_port(altcp_pcb *conn,int local) + +{ + void *pvVar1; + + if ((conn != (altcp_pcb *)0x0) && (pvVar1 = conn->state, pvVar1 != (void *)0x0)) { + if (local == 0) { + return *(u16_t *)((int)pvVar1 + 0x18); + } + return *(u16_t *)((int)pvVar1 + 0x16); + } + return 0; +} + + + +void altcp_tcp_setup_callbacks(altcp_pcb *conn,tcp_pcb *tpcb) + +{ + tcp_arg(tpcb,conn); + tcp_recv(tpcb,altcp_tcp_recv); + tcp_sent(tpcb,altcp_tcp_sent); + tcp_err(tpcb,altcp_tcp_err); + return; +} + + + +void altcp_tcp_err(void *arg,err_t err) + +{ + if (arg != (void *)0x0) { + *(undefined4 *)((int)arg + 0xc) = 0; + if (*(code **)((int)arg + 0x24) != (code *)0x0) { + (**(code **)((int)arg + 0x24))(*(undefined4 *)((int)arg + 8)); + } + altcp_free((altcp_pcb *)arg); + return; + } + return; +} + + + +err_t altcp_tcp_get_tcp_addrinfo(altcp_pcb *conn,int local,ip_addr_t *addr,u16_t *port) + +{ + err_t eVar1; + + if (conn != (altcp_pcb *)0x0) { + eVar1 = tcp_tcp_get_tcp_addrinfo((tcp_pcb *)conn->state,local,addr,port); + return eVar1; + } + return -6; +} + + + +void altcp_tcp_setprio(altcp_pcb *conn,u8_t prio) + +{ + if (conn != (altcp_pcb *)0x0) { + tcp_setprio((tcp_pcb *)conn->state,prio); + return; + } + return; +} + + + +err_t altcp_tcp_output(altcp_pcb *conn) + +{ + err_t eVar1; + + if (conn != (altcp_pcb *)0x0) { + eVar1 = tcp_output((tcp_pcb *)conn->state); + return eVar1; + } + return -6; +} + + + +err_t altcp_tcp_write(altcp_pcb *conn,void *dataptr,u16_t len,u8_t apiflags) + +{ + err_t eVar1; + + if (conn != (altcp_pcb *)0x0) { + eVar1 = tcp_write((tcp_pcb *)conn->state,dataptr,len,apiflags); + return eVar1; + } + return -6; +} + + + +err_t altcp_tcp_shutdown(altcp_pcb *conn,int shut_rx,int shut_tx) + +{ + err_t eVar1; + + if (conn != (altcp_pcb *)0x0) { + eVar1 = tcp_shutdown((tcp_pcb *)conn->state,shut_rx,shut_tx); + return eVar1; + } + return -6; +} + + + +err_t altcp_tcp_close(altcp_pcb *conn) + +{ + tcp_pcb *pcb; + err_t eVar1; + undefined3 extraout_var; + tcp_poll_fn *poll; + + eVar1 = -6; + if (conn != (altcp_pcb *)0x0) { + pcb = (tcp_pcb *)conn->state; + if (pcb != (tcp_pcb *)0x0) { + poll = pcb->poll; + tcp_arg(pcb,(void *)0x0); + tcp_recv(pcb,(tcp_recv_fn *)0x0); + tcp_sent(pcb,(tcp_sent_fn *)0x0); + tcp_err(pcb,(tcp_err_fn *)0x0); + tcp_poll(pcb,(tcp_poll_fn *)0x0,pcb->pollinterval); + eVar1 = tcp_close(pcb); + if (CONCAT31(extraout_var,eVar1) != 0) { + altcp_tcp_setup_callbacks(conn,pcb); + tcp_poll(pcb,poll,pcb->pollinterval); + return eVar1; + } + conn->state = (void *)0x0; + } + altcp_free(conn); + eVar1 = '\0'; + } + return eVar1; +} + + + +void altcp_tcp_abort(altcp_pcb *conn) + +{ + if ((conn != (altcp_pcb *)0x0) && ((tcp_pcb *)conn->state != (tcp_pcb *)0x0)) { + tcp_abort((tcp_pcb *)conn->state); + return; + } + return; +} + + + +altcp_pcb * altcp_tcp_listen(altcp_pcb *conn,u8_t backlog,err_t *err) + +{ + tcp_pcb *pcb; + + if ((conn == (altcp_pcb *)0x0) || + (pcb = tcp_listen_with_backlog_and_err((tcp_pcb *)conn->state,backlog,err), + pcb == (tcp_pcb *)0x0)) { + conn = (altcp_pcb *)0x0; + } + else { + *(tcp_pcb **)&conn->state = pcb; + tcp_accept(pcb,altcp_tcp_accept); + } + return conn; +} + + + +err_t altcp_tcp_connect(altcp_pcb *conn,ip_addr_t *ipaddr,u16_t port,altcp_connected_fn connected) + +{ + err_t eVar1; + + if (conn != (altcp_pcb *)0x0) { + conn->connected = connected; + eVar1 = tcp_connect((tcp_pcb *)conn->state,ipaddr,port,altcp_tcp_connected); + return eVar1; + } + return -6; +} + + + +err_t altcp_tcp_bind(altcp_pcb *conn,ip_addr_t *ipaddr,u16_t port) + +{ + err_t eVar1; + + if (conn != (altcp_pcb *)0x0) { + eVar1 = tcp_bind((tcp_pcb *)conn->state,ipaddr,port); + return eVar1; + } + return -6; +} + + + +void altcp_tcp_recved(altcp_pcb *conn,u16_t len) + +{ + if (conn != (altcp_pcb *)0x0) { + tcp_recved((tcp_pcb *)conn->state,len); + return; + } + return; +} + + + +err_t altcp_tcp_recv(void *arg,tcp_pcb *tpcb,pbuf *p,err_t err) + +{ + err_t eVar1; + + if ((arg != (void *)0x0) && (*(code **)((int)arg + 0x18) != (code *)0x0)) { + // WARNING: Could not recover jumptable at 0x230868b0. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (**(code **)((int)arg + 0x18))(*(undefined4 *)((int)arg + 8)); + return eVar1; + } + if (p != (pbuf *)0x0) { + pbuf_free(p); + return '\0'; + } + return '\0'; +} + + + +void altcp_tcp_set_poll(altcp_pcb *conn,u8_t interval) + +{ + if (conn != (altcp_pcb *)0x0) { + tcp_poll((tcp_pcb *)conn->state,altcp_tcp_poll,interval); + return; + } + return; +} + + + +err_t altcp_tcp_accept(void *arg,tcp_pcb *new_tpcb,err_t err) + +{ + err_t eVar1; + altcp_pcb *conn; + undefined3 in_register_00002031; + + if ((arg != (void *)0x0) && (*(int *)((int)arg + 0x10) != 0)) { + conn = altcp_alloc(); + if (conn != (altcp_pcb *)0x0) { + altcp_tcp_setup_callbacks(conn,new_tpcb); + *(tcp_pcb **)&conn->state = new_tpcb; + conn->fns = (altcp_functions *)0x230c6a40; + // WARNING: Could not recover jumptable at 0x23086926. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (**(code **)((int)arg + 0x10)) + (*(undefined4 *)((int)arg + 8),conn,CONCAT31(in_register_00002031,err)); + return eVar1; + } + return -1; + } + return -0x10; +} + + + +altcp_pcb * altcp_tcp_new_ip_type(u8_t ip_type) + +{ + altcp_pcb *conn; + tcp_pcb *pcb; + + pcb = tcp_new_ip_type(ip_type); + conn = (altcp_pcb *)0x0; + if (pcb != (tcp_pcb *)0x0) { + conn = altcp_alloc(); + if (conn == (altcp_pcb *)0x0) { + tcp_close(pcb); + } + else { + altcp_tcp_setup_callbacks(conn,pcb); + *(tcp_pcb **)&conn->state = pcb; + conn->fns = (altcp_functions *)0x230c6a40; + } + } + return conn; +} + + + +int dummy_rng(void *ctx,uchar *buffer,size_t len) + +{ + size_t ctr; + size_t sVar1; + + sVar1 = 0; + while (sVar1 != len) { + buffer[sVar1] = (char)ctr + '\x01' + (char)sVar1; + sVar1 = sVar1 + 1; + } + return 0; +} + + + +void altcp_mbedtls_lower_err(void *arg,err_t err) + +{ + if (arg != (void *)0x0) { + *(undefined4 *)((int)arg + 4) = 0; + if (*(code **)((int)arg + 0x24) != (code *)0x0) { + (**(code **)((int)arg + 0x24))(*(undefined4 *)((int)arg + 8)); + } + altcp_free((altcp_pcb *)arg); + return; + } + return; +} + + + +int altcp_mbedtls_bio_recv(void *ctx,uchar *buf,size_t len) + +{ + pbuf *buf_00; + u16_t uVar1; + size_t header_size_decrement; + undefined2 extraout_var; + ushort len_00; + int iVar2; + + if (ctx == (void *)0x0) { + return -0x45; + } + iVar2 = *(int *)((int)ctx + 0xc); + if (iVar2 == 0) { + return -0x45; + } + buf_00 = *(pbuf **)(iVar2 + 0xc4); + if (buf_00 == (pbuf *)0x0) { +LAB_23086a04: + *(undefined4 *)(iVar2 + 0xc4) = 0; + header_size_decrement = 0; + if ((*(byte *)(iVar2 + 0xcc) & 0xc) != 4) { + header_size_decrement = 0xffff9700; + } + } + else { + len_00 = buf_00->len; + if (len_00 == 0) { + if (buf_00->next == (pbuf *)0x0) { + pbuf_free(buf_00); + goto LAB_23086a04; + } + } + else { + if (len < len_00) { + len_00 = (ushort)len; + } + } + uVar1 = pbuf_copy_partial(buf_00,buf,len_00,0); + header_size_decrement = CONCAT22(extraout_var,uVar1); + pbuf_remove_header(buf_00,header_size_decrement); + if (buf_00->len == 0) { + *(pbuf **)(iVar2 + 0xc4) = buf_00->next; + buf_00->next = (pbuf *)0x0; + pbuf_free(buf_00); + } + *(int *)(iVar2 + 0xd4) = *(int *)(iVar2 + 0xd4) + header_size_decrement; + } + return header_size_decrement; +} + + + +void altcp_mbedtls_setup_callbacks(altcp_pcb *conn,altcp_pcb *inner_conn) + +{ + altcp_arg(inner_conn,conn); + altcp_recv(inner_conn,altcp_mbedtls_lower_recv); + altcp_sent(inner_conn,altcp_mbedtls_lower_sent); + altcp_err(inner_conn,altcp_mbedtls_lower_err); + return; +} + + + +err_t altcp_mbedtls_setup(void *conf,altcp_pcb *conn,altcp_pcb *inner_conn) + +{ + err_t eVar1; + altcp_mbedtls_state_t_conflict2 *state; + int iVar2; + mbedtls_ssl_context *ssl; + + if (conf != (void *)0x0) { + state = altcp_mbedtls_alloc(conf); + eVar1 = -1; + if (state != (altcp_mbedtls_state_t_conflict2 *)0x0) { + ssl = (mbedtls_ssl_context *)&state->ssl_context; + mbedtls_ssl_init(ssl); + iVar2 = mbedtls_ssl_setup(ssl,(mbedtls_ssl_config *)conf); + if (iVar2 == 0) { + mbedtls_ssl_set_bio(ssl,conn,altcp_mbedtls_bio_send,altcp_mbedtls_bio_recv, + (mbedtls_ssl_recv_timeout_t_conflict1 *)0x0); + altcp_mbedtls_setup_callbacks(conn,inner_conn); + conn->inner_conn = inner_conn; + conn->fns = (altcp_functions *)0x230c6a94; + *(altcp_mbedtls_state_t_conflict2 **)&conn->state = state; + eVar1 = '\0'; + } + else { + altcp_mbedtls_free(conf,state); + eVar1 = -1; + } + } + return eVar1; + } + return -0x10; +} + + + +err_t altcp_mbedtls_lower_accept(void *arg,altcp_pcb *accepted_conn,err_t err) + +{ + void **ppvVar1; + err_t eVar2; + altcp_pcb *conn; + undefined3 extraout_var; + undefined3 in_register_00002031; + + if (((arg == (void *)0x0) || (ppvVar1 = *(void ***)((int)arg + 0xc), ppvVar1 == (void **)0x0)) || + (*(int *)((int)arg + 0x10) == 0)) { + eVar2 = -0x10; + } + else { + conn = altcp_alloc(); + if (conn == (altcp_pcb *)0x0) { + eVar2 = -1; + } + else { + eVar2 = altcp_mbedtls_setup(*ppvVar1,conn,accepted_conn); + if (CONCAT31(extraout_var,eVar2) == 0) { + // WARNING: Could not recover jumptable at 0x23086b98. Too many branches + // WARNING: Treating indirect jump as call + eVar2 = (**(code **)((int)arg + 0x10)) + (*(undefined4 *)((int)arg + 8),conn,CONCAT31(in_register_00002031,err)); + return eVar2; + } + altcp_free(conn); + } + } + return eVar2; +} + + + +void altcp_mbedtls_abort(altcp_pcb *conn) + +{ + if (conn != (altcp_pcb *)0x0) { + altcp_abort(conn->inner_conn); + return; + } + return; +} + + + +void altcp_mbedtls_recved(altcp_pcb *conn,u16_t len) + +{ + undefined2 in_register_0000202e; + uint uVar1; + void *pvVar2; + uint uVar3; + + uVar1 = CONCAT22(in_register_0000202e,len); + if (((conn != (altcp_pcb *)0x0) && (pvVar2 = conn->state, pvVar2 != (void *)0x0)) && + ((*(byte *)((int)pvVar2 + 0xcc) & 1) != 0)) { + uVar3 = *(uint *)((int)pvVar2 + 0xd0); + if ((int)uVar3 < (int)uVar1) { + uVar1 = uVar3 & 0xffff; + } + *(int *)((int)pvVar2 + 0xd0) = uVar3 - uVar1; + altcp_recved(conn->inner_conn,(u16_t)uVar1); + return; + } + return; +} + + + +altcp_tls_config * altcp_tls_create_config(int is_server,int have_cert,int have_pkey,int have_ca) + +{ + altcp_tls_config *item; + mbedtls_ctr_drbg_context_conflict *ctx; + size_t size; + int iVar1; + altcp_tls_config *paVar2; + + altcp_mbedtls_mem_init(); + size = 0x500; + if (have_cert == 0) { + size = 0x3cc; + } + if (have_ca != 0) { + size = size + 0x134; + } + if (have_pkey != 0) { + size = size + 8; + } + item = (altcp_tls_config *)altcp_mbedtls_alloc_config(size); + if (item != (altcp_tls_config *)0x0) { + paVar2 = item + 1; + if (have_cert != 0) { + *(altcp_tls_config **)&item->cert = paVar2; + paVar2 = (altcp_tls_config *)&item[1].entropy.source[3].size; + } + if (have_ca != 0) { + *(altcp_tls_config **)&item->ca = paVar2; + paVar2 = (altcp_tls_config *)&(paVar2->entropy).source[3].size; + } + if (have_pkey != 0) { + *(altcp_tls_config **)&item->pkey = paVar2; + } + mbedtls_ssl_config_init((mbedtls_ssl_config *)item); + ctx = (mbedtls_ctr_drbg_context_conflict *)&item->ctr_drbg; + mbedtls_entropy_init(&item->entropy); + mbedtls_ctr_drbg_init(ctx); + iVar1 = mbedtls_ctr_drbg_seed(ctx,dummy_rng,&item->entropy,(uchar *)0x0,0); + if ((iVar1 == 0) && + (iVar1 = mbedtls_ssl_config_defaults((mbedtls_ssl_config *)item,is_server,0,0), iVar1 == 0)) + { + mbedtls_ssl_conf_authmode((mbedtls_ssl_config *)item,1); + mbedtls_ssl_conf_rng((mbedtls_ssl_config *)item,mbedtls_ctr_drbg_random,ctx); + } + else { + altcp_mbedtls_free_config(item); + item = (altcp_tls_config *)0x0; + } + } + return item; +} + + + +altcp_tls_config * altcp_tls_create_config_client_common(u8_t *ca,size_t ca_len,int is_2wayauth) + +{ + altcp_tls_config *item; + int iVar1; + + item = altcp_tls_create_config(0,is_2wayauth,is_2wayauth,(uint)(ca != (u8_t *)0x0)); + if ((item != (altcp_tls_config *)0x0) && (ca != (u8_t *)0x0)) { + mbedtls_x509_crt_init(item->ca); + iVar1 = mbedtls_x509_crt_parse(item->ca,ca,ca_len); + if (iVar1 == 0) { + mbedtls_ssl_conf_ca_chain((mbedtls_ssl_config *)item,item->ca,(mbedtls_x509_crl *)0x0); + } + else { + altcp_mbedtls_free_config(item); + item = (altcp_tls_config *)0x0; + } + } + return item; +} + + + +void altcp_mbedtls_dealloc(altcp_pcb *conn) + +{ + altcp_mbedtls_state_t_conflict2 *state; + + if (conn != (altcp_pcb *)0x0) { + state = (altcp_mbedtls_state_t_conflict2 *)conn->state; + if (state != (altcp_mbedtls_state_t_conflict2 *)0x0) { + mbedtls_ssl_free((mbedtls_ssl_context *)&state->ssl_context); + state->flags = '\0'; + if (state->rx != (pbuf *)0x0) { + pbuf_free(state->rx); + state->rx = (pbuf *)0x0; + } + altcp_mbedtls_free(state->conf,state); + conn->state = (void *)0x0; + } + return; + } + return; +} + + + +u16_t altcp_mbedtls_sndbuf(altcp_pcb *conn) + +{ + void *pvVar1; + u16_t uVar2; + undefined2 extraout_var; + uint uVar3; + size_t sVar4; + + if (conn != (altcp_pcb *)0x0) { + pvVar1 = conn->state; + if ((pvVar1 == (void *)0x0) || ((*(byte *)((int)pvVar1 + 0xcc) & 1) == 0)) { + return 0; + } + if (conn->inner_conn != (altcp_pcb *)0x0) { + uVar2 = altcp_sndbuf(conn->inner_conn); + uVar3 = mbedtls_ssl_get_record_expansion((mbedtls_ssl_context *)((int)pvVar1 + 4)); + if (0 < (int)uVar3) { + if (0xfffe < (int)uVar3) { + uVar3 = 0xffff; + } + if (uVar3 < CONCAT22(extraout_var,uVar2)) { + sVar4 = mbedtls_ssl_get_max_frag_len((mbedtls_ssl_context *)((int)pvVar1 + 4)); + uVar3 = CONCAT22(extraout_var,uVar2) - uVar3; + if (0xffff < uVar3) { + uVar3 = 0xffff; + } + if (uVar3 <= sVar4) { + return (u16_t)uVar3; + } + return (u16_t)sVar4; + } + } + } + } + uVar2 = altcp_default_sndbuf(conn); + return uVar2; +} + + + +err_t altcp_mbedtls_write(altcp_pcb *conn,void *dataptr,u16_t len,u8_t apiflags) + +{ + void *pvVar1; + size_t sVar2; + undefined2 in_register_00002032; + err_t eVar3; + + if (conn == (altcp_pcb *)0x0) { + return -6; + } + pvVar1 = conn->state; + if (pvVar1 == (void *)0x0) { + return -0xf; + } + if ((*(byte *)((int)pvVar1 + 0xcc) & 1) == 0) { +LAB_23086e1a: + eVar3 = -6; + } + else { + if ((*(int *)((int)pvVar1 + 0xb0) == 0) || + (mbedtls_ssl_flush_output((mbedtls_ssl_context *)((int)pvVar1 + 4)), + *(int *)((int)pvVar1 + 0xb0) == 0)) { + sVar2 = mbedtls_ssl_write((mbedtls_ssl_context *)((int)pvVar1 + 4),(uchar *)dataptr, + CONCAT22(in_register_00002032,len)); + altcp_output(conn->inner_conn); + if ((int)sVar2 < 0) { + if (sVar2 != 0xffff9780) goto LAB_23086e1a; + } + else { + if (CONCAT22(in_register_00002032,len) == sVar2) { + *(byte *)((int)pvVar1 + 0xcc) = *(byte *)((int)pvVar1 + 0xcc) | 0x10; + return '\0'; + } + } + } + eVar3 = -1; + } + return eVar3; +} + + + +err_t altcp_mbedtls_close(altcp_pcb *conn) + +{ + altcp_pcb *conn_00; + err_t eVar1; + undefined3 extraout_var; + altcp_poll_fn *poll; + + eVar1 = -6; + if (conn != (altcp_pcb *)0x0) { + conn_00 = conn->inner_conn; + if (conn_00 != (altcp_pcb *)0x0) { + poll = conn_00->poll; + altcp_arg(conn_00,(void *)0x0); + altcp_recv(conn_00,(altcp_recv_fn *)0x0); + altcp_sent(conn_00,(altcp_sent_fn *)0x0); + altcp_err(conn_00,(altcp_err_fn *)0x0); + altcp_poll(conn_00,(altcp_poll_fn *)0x0,conn_00->pollinterval); + eVar1 = altcp_close(conn->inner_conn); + if (CONCAT31(extraout_var,eVar1) != 0) { + altcp_mbedtls_setup_callbacks(conn,conn_00); + altcp_poll(conn_00,poll,conn_00->pollinterval); + return eVar1; + } + conn->inner_conn = (altcp_pcb *)0x0; + } + altcp_free(conn); + eVar1 = '\0'; + } + return eVar1; +} + + + +altcp_pcb * altcp_mbedtls_listen(altcp_pcb *conn,u8_t backlog,err_t *err) + +{ + altcp_pcb *conn_00; + + if ((conn == (altcp_pcb *)0x0) || + (conn_00 = altcp_listen_with_backlog_and_err(conn->inner_conn,backlog,err), + conn_00 == (altcp_pcb *)0x0)) { + conn = (altcp_pcb *)0x0; + } + else { + conn->inner_conn = conn_00; + altcp_accept(conn_00,altcp_mbedtls_lower_accept); + } + return conn; +} + + + +err_t altcp_mbedtls_connect + (altcp_pcb *conn,ip_addr_t *ipaddr,u16_t port,altcp_connected_fn connected) + +{ + err_t eVar1; + + if (conn != (altcp_pcb *)0x0) { + conn->connected = connected; + eVar1 = altcp_connect(conn->inner_conn,ipaddr,port,altcp_mbedtls_lower_connected); + return eVar1; + } + return -6; +} + + + +int altcp_mbedtls_bio_send(void *ctx,uchar *dataptr,size_t size) + +{ + int iVar1; + err_t eVar2; + undefined3 extraout_var; + uint uVar3; + + iVar1 = -0x45; + if ((ctx != (void *)0x0) && (iVar1 = -0x45, *(int *)((int)ctx + 4) != 0)) { + iVar1 = 0; + while (size != 0) { + uVar3 = size; + if (0xfffe < size) { + uVar3 = 0xffff; + } + eVar2 = altcp_write(*(altcp_pcb **)((int)ctx + 4),dataptr,(u16_t)uVar3,'\x01'); + if (CONCAT31(extraout_var,eVar2) != 0) { + if (CONCAT31(extraout_var,eVar2) == -1) { + return iVar1; + } + return -0x4e; + } + iVar1 = iVar1 + uVar3; + size = size - uVar3; + } + } + return iVar1; +} + + + +err_t altcp_mbedtls_lower_sent(void *arg,altcp_pcb *inner_conn,u16_t len) + +{ + int iVar1; + err_t eVar2; + + if (arg == (void *)0x0) { + return '\0'; + } + iVar1 = *(int *)((int)arg + 0xc); + if ((iVar1 != 0) && ((*(byte *)(iVar1 + 0xcc) & 1) != 0)) { + mbedtls_ssl_flush_output((mbedtls_ssl_context *)(iVar1 + 4)); + if ((*(byte *)(iVar1 + 0xcc) & 0x10) != 0) { + if (*(code **)((int)arg + 0x1c) != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x23086fce. Too many branches + // WARNING: Treating indirect jump as call + eVar2 = (**(code **)((int)arg + 0x1c))(*(undefined4 *)((int)arg + 8),0); + return eVar2; + } + } + } + return '\0'; +} + + + +u16_t altcp_mbedtls_mss(altcp_pcb *conn) + +{ + u16_t uVar1; + + if (conn != (altcp_pcb *)0x0) { + uVar1 = altcp_mss(conn->inner_conn); + return uVar1; + } + return 0; +} + + + +void altcp_mbedtls_set_poll(altcp_pcb *conn,u8_t interval) + +{ + if (conn != (altcp_pcb *)0x0) { + altcp_poll(conn->inner_conn,altcp_mbedtls_lower_poll,interval); + return; + } + return; +} + + + +err_t altcp_mbedtls_handle_rx_appldata(altcp_pcb *conn,altcp_mbedtls_state_t_conflict *state) + +{ + ushort uVar1; + err_t eVar2; + pbuf *p; + int iVar3; + size_t sVar4; + undefined3 extraout_var; + undefined3 extraout_var_00; + int iVar5; + int iVar6; + altcp_pcb *conn_00; + + if ((state->flags & 1) == 0) { + return -6; + } + do { + p = pbuf_alloc(PBUF_RAW,0x2f8,PBUF_RAM); + if (p == (pbuf *)0x0) { + return '\0'; + } + iVar3 = mbedtls_ssl_read((mbedtls_ssl_context *)&state->ssl_context,(uchar *)p->payload,0x2f8); + if (iVar3 < 0) { + if (iVar3 != -0x6780) { + pbuf_free(p); + return '\0'; + } + pbuf_free(p); + altcp_abort(conn); + return -0xd; + } + if (iVar3 == 0) { + pbuf_free(p); + } + else { + pbuf_realloc(p,(u16_t)iVar3); + state->bio_bytes_appl = state->bio_bytes_appl + iVar3; + sVar4 = mbedtls_ssl_get_bytes_avail((mbedtls_ssl_context *)&state->ssl_context); + if (sVar4 == 0) { + conn_00 = conn->inner_conn; + iVar5 = state->bio_bytes_read - state->bio_bytes_appl; + while (0 < iVar5) { + iVar6 = iVar5; + if (0xfffe < iVar5) { + iVar6 = 0xffff; + } + altcp_recved(conn_00,(u16_t)iVar6); + iVar5 = iVar5 - iVar6; + } + state->bio_bytes_read = 0; + state->bio_bytes_appl = 0; + } + if (state->rx_app == (pbuf *)0x0) { + state->rx_app = p; + } + else { + pbuf_cat(state->rx_app,p); + } + } + p = state->rx_app; + if (p == (pbuf *)0x0) { + if ((state->flags & 0xc) != 4) goto LAB_23087164; + state->flags = state->flags | 8; + if (conn->recv == (altcp_recv_fn *)0x0) goto LAB_23087164; + eVar2 = (*conn->recv)(conn->arg,conn,(pbuf *)0x0,'\0'); + if (CONCAT31(extraout_var_00,eVar2) != 0) { + if (CONCAT31(extraout_var_00,eVar2) != -0xd) { + return '\0'; + } + return -0xd; + } + } + else { + state->rx_app = (pbuf *)0x0; + if (conn->recv == (altcp_recv_fn *)0x0) { + pbuf_free(p); + } + else { + uVar1 = p->tot_len; + state->rx_passed_unrecved = state->rx_passed_unrecved + (uint)uVar1; + state->flags = state->flags | 2; + eVar2 = (*conn->recv)(conn->arg,conn,p,'\0'); + if (CONCAT31(extraout_var,eVar2) != 0) { + if (CONCAT31(extraout_var,eVar2) == -0xd) { + return -0xd; + } + state->rx_app = p; + iVar3 = state->rx_passed_unrecved - (uint)uVar1; + if (-1 < iVar3) { + state->rx_passed_unrecved = iVar3; + return '\0'; + } + state->rx_passed_unrecved = 0; + return '\0'; + } + } +LAB_23087164: + if (state != (altcp_mbedtls_state_t_conflict *)conn->state) { + return '\0'; + } + } + if (iVar3 == 0) { + return '\0'; + } + } while( true ); +} + + + +err_t altcp_mbedtls_lower_poll(void *arg,altcp_pcb *inner_conn) + +{ + err_t eVar1; + undefined3 extraout_var; + altcp_mbedtls_state_t_conflict *state; + + if (arg == (void *)0x0) { + return '\0'; + } + state = *(altcp_mbedtls_state_t_conflict **)((int)arg + 0xc); + if (state != (altcp_mbedtls_state_t_conflict *)0x0) { + mbedtls_ssl_flush_output((mbedtls_ssl_context *)&state->ssl_context); + eVar1 = altcp_mbedtls_handle_rx_appldata((altcp_pcb *)arg,state); + if (CONCAT31(extraout_var,eVar1) == -0xd) { + return eVar1; + } + } + if (*(code **)((int)arg + 0x20) == (code *)0x0) { + return '\0'; + } + // WARNING: Could not recover jumptable at 0x230871e8. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (**(code **)((int)arg + 0x20))(*(undefined4 *)((int)arg + 8),arg); + return eVar1; +} + + + +err_t altcp_mbedtls_lower_recv_process(altcp_pcb *conn,altcp_mbedtls_state_t_conflict *state) + +{ + err_t eVar1; + uint uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + int iVar3; + int iVar4; + altcp_pcb *conn_00; + + if ((state->flags & 1) == 0) { + uVar2 = mbedtls_ssl_handshake((mbedtls_ssl_context *)&state->ssl_context); + altcp_output(conn->inner_conn); + iVar3 = state->bio_bytes_read; + if (iVar3 != 0) { + conn_00 = conn->inner_conn; + while (0 < iVar3) { + iVar4 = iVar3; + if (0xfffe < iVar3) { + iVar4 = 0xffff; + } + altcp_recved(conn_00,(u16_t)iVar4); + iVar3 = iVar3 - iVar4; + } + state->bio_bytes_read = 0; + } + if ((uVar2 & 0xffffff7f) != 0xffff9700) { + if (uVar2 == 0) { + state->flags = state->flags | 1; + if ((conn->connected != (altcp_connected_fn)0x0) && + (eVar1 = (*conn->connected)(conn->arg,conn,'\0'), CONCAT31(extraout_var_00,eVar1) != 0)) + { + return eVar1; + } + if (state->rx != (pbuf *)0x0) goto LAB_2308720a; + } + else { + if (conn->err != (altcp_err_fn *)0x0) { + (*conn->err)(conn->arg,-0xf); + } + eVar1 = altcp_close(conn); + if (CONCAT31(extraout_var,eVar1) != 0) { + altcp_abort(conn); + } + } + } + return '\0'; + } +LAB_2308720a: + eVar1 = altcp_mbedtls_handle_rx_appldata(conn,state); + return eVar1; +} + + + +err_t altcp_mbedtls_lower_connected(void *arg,altcp_pcb *inner_conn,err_t err) + +{ + err_t eVar1; + undefined3 in_register_00002031; + + if ((arg == (void *)0x0) || + (*(altcp_mbedtls_state_t_conflict **)((int)arg + 0xc) == (altcp_mbedtls_state_t_conflict *)0x0) + ) { + return -6; + } + if ((CONCAT31(in_register_00002031,err) != 0) && (*(code **)((int)arg + 0x14) != (code *)0x0)) { + // WARNING: Could not recover jumptable at 0x230872ea. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (**(code **)((int)arg + 0x14))(*(undefined4 *)((int)arg + 8),arg); + return eVar1; + } + eVar1 = altcp_mbedtls_lower_recv_process + ((altcp_pcb *)arg,*(altcp_mbedtls_state_t_conflict **)((int)arg + 0xc)); + return eVar1; +} + + + +err_t altcp_mbedtls_lower_recv(void *arg,altcp_pcb *inner_conn,pbuf *p,err_t err) + +{ + byte bVar1; + altcp_mbedtls_state_t_conflict *state; + err_t eVar2; + + if ((arg == (void *)0x0) || + (state = *(altcp_mbedtls_state_t_conflict **)((int)arg + 0xc), + state == (altcp_mbedtls_state_t_conflict *)0x0)) { + if (p != (pbuf *)0x0) { + pbuf_free(p); + } + altcp_close(inner_conn); + eVar2 = -0xf; + } + else { + if (p != (pbuf *)0x0) { + if (state->rx == (pbuf *)0x0) { + state->rx = p; + } + else { + pbuf_cat(state->rx,p); + } + eVar2 = altcp_mbedtls_lower_recv_process((altcp_pcb *)arg,state); + return eVar2; + } + bVar1 = state->flags; + if ((bVar1 & 3) == 3) { + if ((state->rx == (pbuf *)0x0) && (state->rx_app == (pbuf *)0x0)) { + state->flags = bVar1 | 8; + if (*(code **)((int)arg + 0x18) != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x23087372. Too many branches + // WARNING: Treating indirect jump as call + eVar2 = (**(code **)((int)arg + 0x18))(*(undefined4 *)((int)arg + 8),arg,0); + return eVar2; + } + } + else { + state->flags = bVar1 | 4; + altcp_mbedtls_handle_rx_appldata((altcp_pcb *)arg,state); + } + } + else { + if (*(code **)((int)arg + 0x24) != (code *)0x0) { + (**(code **)((int)arg + 0x24))(*(undefined4 *)((int)arg + 8),0xfffffff1); + } + altcp_close((altcp_pcb *)arg); + } + eVar2 = '\0'; + } + return eVar2; +} + + + +altcp_pcb * altcp_tls_wrap(altcp_tls_config *config,altcp_pcb *inner_pcb) + +{ + err_t eVar1; + altcp_pcb *conn; + undefined3 extraout_var; + + if ((inner_pcb != (altcp_pcb *)0x0) && (conn = altcp_alloc(), conn != (altcp_pcb *)0x0)) { + eVar1 = altcp_mbedtls_setup(config,conn,inner_pcb); + if (CONCAT31(extraout_var,eVar1) == 0) { + return conn; + } + altcp_free(conn); + } + return (altcp_pcb *)0x0; +} + + + +void * altcp_tls_context(altcp_pcb *conn) + +{ + if ((conn != (altcp_pcb *)0x0) && (conn = (altcp_pcb *)conn->state, conn != (altcp_pcb *)0x0)) { + conn = (altcp_pcb *)&conn->inner_conn; + } + return conn; +} + + + +altcp_tls_config * altcp_tls_create_config_client(u8_t *ca,size_t ca_len) + +{ + altcp_tls_config *paVar1; + + paVar1 = altcp_tls_create_config_client_common(ca,ca_len,0); + return paVar1; +} + + + +altcp_tls_config * +altcp_tls_create_config_client_2wayauth + (u8_t *ca,size_t ca_len,u8_t *privkey,size_t privkey_len,u8_t *privkey_pass, + size_t privkey_pass_len,u8_t *cert,size_t cert_len) + +{ + altcp_tls_config *item; + int iVar1; + + if (((cert != (u8_t *)0x0) && (privkey != (u8_t *)0x0)) && + (item = altcp_tls_create_config_client_common(ca,ca_len,1), item != (altcp_tls_config *)0x0)) { + mbedtls_x509_crt_init(item->cert); + iVar1 = mbedtls_x509_crt_parse(item->cert,cert,cert_len); + if (iVar1 == 0) { + mbedtls_pk_init(item->pkey); + iVar1 = mbedtls_pk_parse_key(item->pkey,privkey,privkey_len,privkey_pass,privkey_pass_len); + if ((iVar1 == 0) && + (iVar1 = mbedtls_ssl_conf_own_cert((mbedtls_ssl_config *)item,item->cert,item->pkey), + iVar1 == 0)) { + return item; + } + } + else { + item = (altcp_tls_config *)item->cert; + } + altcp_mbedtls_free_config(item); + } + return (altcp_tls_config *)0x0; +} + + + +void altcp_tls_free_config(altcp_tls_config *conf) + +{ + if (conf->pkey != (mbedtls_pk_context *)0x0) { + mbedtls_pk_free(conf->pkey); + } + if (conf->cert != (mbedtls_x509_crt *)0x0) { + mbedtls_x509_crt_free(conf->cert); + } + if (conf->ca != (mbedtls_x509_crt *)0x0) { + mbedtls_x509_crt_free(conf->ca); + } + altcp_mbedtls_free_config(conf); + return; +} + + + +void altcp_mbedtls_mem_init(void) + +{ + return; +} + + + +altcp_mbedtls_state_t_conflict2 * altcp_mbedtls_alloc(void *conf) + +{ + altcp_mbedtls_state_t_conflict2 *paVar1; + + paVar1 = (altcp_mbedtls_state_t_conflict2 *)mem_calloc(1,0xdc); + if (paVar1 != (altcp_mbedtls_state_t_conflict2 *)0x0) { + paVar1->conf = conf; + } + return paVar1; +} + + + +void altcp_mbedtls_free(void *conf,altcp_mbedtls_state_t_conflict2 *state) + +{ + mem_free(state); + return; +} + + + +void * altcp_mbedtls_alloc_config(size_t size) + +{ + void *pvVar1; + + if (size == (size & 0xffff)) { + pvVar1 = mem_calloc(1,(mem_size_t)size); + return pvVar1; + } + return (void *)0x0; +} + + + +void altcp_mbedtls_free_config(void *item) + +{ + mbedtls_ssl_config_free((mbedtls_ssl_config *)item); + mem_free(item); + return; +} + + + +// WARNING: Variable defined which should be unmapped: buf +// WARNING: Could not reconcile some variable overlaps + +int block_cipher_df(uchar *output,uchar *data,size_t data_len) + +{ + uchar *__dest; + uchar *puVar1; + byte *pbVar2; + byte *pbVar3; + int iVar4; + int iVar5; + uint uVar6; + uint uVar7; + uint32_t *puVar8; + byte local_338 [4]; + uchar chain [16]; + uchar key [32]; + uchar tmp [48]; + mbedtls_aes_context aes_ctx; + uchar buf [416]; + + if (data_len < 0x181) { + memset(aes_ctx.buf + 0x43,0,0x1a0); + mbedtls_aes_init((mbedtls_aes_context *)(tmp + 0x2c)); + buf._14_2_ = (ushort)(data_len << 8) | (ushort)(data_len >> 8) & 0xff; + buf[19] = '0'; + buf._12_2_ = 0; + memcpy(buf + 0x14,data,data_len); + buf[data_len + 0x14] = -0x80; + iVar4 = 0; + do { + chain[iVar4 + 0xc] = (uchar)iVar4; + iVar4 = iVar4 + 1; + } while (iVar4 != 0x20); + mbedtls_aes_setkey_enc((mbedtls_aes_context *)(tmp + 0x2c),chain + 0xc,0x100); + iVar4 = 0; + do { + memset(local_338,0,0x10); + puVar8 = aes_ctx.buf + 0x43; + uVar7 = data_len + 0x19; + do { + iVar5 = 0; + pbVar3 = local_338; + do { + pbVar2 = (byte *)((int)puVar8 + iVar5); + iVar5 = iVar5 + 1; + *pbVar3 = *pbVar2 ^ *pbVar3; + pbVar3 = pbVar3 + 1; + } while (iVar5 != 0x10); + puVar8 = puVar8 + 4; + uVar6 = uVar7; + if (0x10 < uVar7) { + uVar6 = 0x10; + } + uVar7 = uVar7 - uVar6; + mbedtls_aes_crypt_ecb((mbedtls_aes_context *)(tmp + 0x2c),1,local_338,local_338); + } while (uVar7 != 0); + memcpy(key + iVar4 + 0x1c,local_338,0x10); + iVar4 = iVar4 + 0x10; + aes_ctx.buf[67]._3_1_ = aes_ctx.buf[67]._3_1_ + '\x01'; + } while (iVar4 != 0x30); + mbedtls_aes_setkey_enc((mbedtls_aes_context *)(tmp + 0x2c),key + 0x1c,0x100); + __dest = output; + do { + mbedtls_aes_crypt_ecb((mbedtls_aes_context *)(tmp + 0x2c),1,tmp + 0x1c,tmp + 0x1c); + puVar1 = __dest + 0x10; + memcpy(__dest,tmp + 0x1c,0x10); + __dest = puVar1; + } while (output + 0x30 != puVar1); + mbedtls_aes_free((mbedtls_aes_context *)(tmp + 0x2c)); + return 0; + } + return -0x38; +} + + + +// WARNING: Variable defined which should be unmapped: tmp + +int ctr_drbg_update_internal(mbedtls_ctr_drbg_context_conflict *ctx,uchar *data) + +{ + bool bVar1; + byte *output; + mbedtls_ctr_drbg_context_conflict *pmVar2; + byte *pbVar3; + uchar uVar4; + int iVar5; + byte local_50 [4]; + uchar tmp [48]; + + iVar5 = 0; + memset(local_50,0,0x30); + do { + output = local_50 + iVar5; + pmVar2 = (mbedtls_ctr_drbg_context_conflict *)(ctx->counter + 0xf); + do { + uVar4 = pmVar2->counter[0] + '\x01'; + pmVar2->counter[0] = uVar4; + if (uVar4 != '\0') break; + bVar1 = ctx != pmVar2; + pmVar2 = (mbedtls_ctr_drbg_context_conflict *)((int)&pmVar2[-1].p_entropy + 3); + } while (bVar1); + iVar5 = iVar5 + 0x10; + mbedtls_aes_crypt_ecb(&ctx->aes_ctx,1,(uchar *)ctx,output); + if (iVar5 == 0x30) { + iVar5 = 0; + output = local_50; + do { + pbVar3 = data + iVar5; + iVar5 = iVar5 + 1; + *output = *pbVar3 ^ *output; + output = output + 1; + } while (iVar5 != 0x30); + mbedtls_aes_setkey_enc(&ctx->aes_ctx,local_50,0x100); + memcpy(ctx,tmp + 0x1c,0x10); + return 0; + } + } while( true ); +} + + + +void mbedtls_ctr_drbg_init(mbedtls_ctr_drbg_context_conflict *ctx) + +{ + memset(ctx,0,0x140); + return; +} + + + +int mbedtls_ctr_drbg_reseed(mbedtls_ctr_drbg_context_conflict *ctx,uchar *additional,size_t len) + +{ + int iVar1; + size_t data_len; + uchar auStack416 [4]; + uchar seed [384]; + + iVar1 = -0x38; + if ((ctx->entropy_len < 0x181) && (iVar1 = -0x38, len <= 0x180 - ctx->entropy_len)) { + memset(auStack416,0,0x180); + iVar1 = (*ctx->f_entropy)(ctx->p_entropy,auStack416,ctx->entropy_len); + if (iVar1 == 0) { + data_len = ctx->entropy_len; + if ((additional != (uchar *)0x0) && (len != 0)) { + memcpy(auStack416 + data_len,additional,len); + data_len = data_len + len; + } + block_cipher_df(auStack416,auStack416,data_len); + ctr_drbg_update_internal(ctx,auStack416); + ctx->reseed_counter = 1; + } + else { + iVar1 = -0x34; + } + } + return iVar1; +} + + + +int mbedtls_ctr_drbg_seed_entropy_len + (mbedtls_ctr_drbg_context_conflict *ctx, + anon_subr_int_void_ptr_uchar_ptr_size_t *f_entropy,void *p_entropy,uchar *custom, + size_t len,size_t entropy_len) + +{ + int iVar1; + uchar auStack64 [4]; + uchar key [32]; + + memset(auStack64,0,0x20); + mbedtls_aes_init(&ctx->aes_ctx); + *(anon_subr_int_void_ptr_uchar_ptr_size_t **)&ctx->f_entropy = f_entropy; + ctx->p_entropy = p_entropy; + ctx->entropy_len = entropy_len; + ctx->reseed_interval = 10000; + mbedtls_aes_setkey_enc(&ctx->aes_ctx,auStack64,0x100); + iVar1 = mbedtls_ctr_drbg_reseed(ctx,custom,len); + return iVar1; +} + + + +int mbedtls_ctr_drbg_seed + (mbedtls_ctr_drbg_context_conflict *ctx, + anon_subr_int_void_ptr_uchar_ptr_size_t *f_entropy,void *p_entropy,uchar *custom, + size_t len) + +{ + int iVar1; + + iVar1 = mbedtls_ctr_drbg_seed_entropy_len(ctx,f_entropy,p_entropy,custom,len,0x20); + return iVar1; +} + + + +// WARNING: Variable defined which should be unmapped: add_input + +int mbedtls_ctr_drbg_random_with_add + (void *p_rng,uchar *output,size_t output_len,uchar *additional,size_t add_len) + +{ + bool bVar1; + char cVar2; + int iVar3; + char *pcVar4; + uint __n; + uchar auStack96 [4]; + uchar tmp [16]; + uchar add_input [48]; + + if (output_len < 0x401) { + iVar3 = -0x38; + if (add_len < 0x101) { + memset(tmp + 0xc,0,0x30); + if ((*(int *)((int)p_rng + 0x1c) < *(int *)((int)p_rng + 0x10)) || + (*(int *)((int)p_rng + 0x14) != 0)) { + iVar3 = mbedtls_ctr_drbg_reseed + ((mbedtls_ctr_drbg_context_conflict *)p_rng,additional,add_len); + if (iVar3 != 0) { + return iVar3; + } + } + else { + if (add_len != 0) { + block_cipher_df(tmp + 0xc,additional,add_len); + ctr_drbg_update_internal((mbedtls_ctr_drbg_context_conflict *)p_rng,tmp + 0xc); + } + } + while (pcVar4 = (char *)((int)p_rng + 0xf), output_len != 0) { + do { + cVar2 = *pcVar4; + *pcVar4 = cVar2 + '\x01'; + if ((char)(cVar2 + '\x01') != '\0') break; + bVar1 = (char *)p_rng != pcVar4; + pcVar4 = pcVar4 + -1; + } while (bVar1); + mbedtls_aes_crypt_ecb((mbedtls_aes_context *)((int)p_rng + 0x20),1,(uchar *)p_rng,auStack96) + ; + __n = output_len; + if (0x10 < output_len) { + __n = 0x10; + } + memcpy(output,auStack96,__n); + output = output + __n; + output_len = output_len - __n; + } + ctr_drbg_update_internal((mbedtls_ctr_drbg_context_conflict *)p_rng,tmp + 0xc); + iVar3 = 0; + *(int *)((int)p_rng + 0x10) = *(int *)((int)p_rng + 0x10) + 1; + } + } + else { + iVar3 = -0x36; + } + return iVar3; +} + + + +int mbedtls_ctr_drbg_random(void *p_rng,uchar *output,size_t output_len) + +{ + int iVar1; + + iVar1 = mbedtls_ctr_drbg_random_with_add(p_rng,output,output_len,(uchar *)0x0,0); + return iVar1; +} + + + +void mbedtls_entropy_init(mbedtls_entropy_context *ctx) + +{ + int iVar1; + uint32_t *puVar2; + + memset(ctx,0,0x208); + mbedtls_sha256_starts((mbedtls_sha256_context *)ctx,0); + iVar1 = ctx->source_count; + if (iVar1 < 0x14) { + puVar2 = (ctx->accumulator).total + iVar1 * 5; + puVar2[0x1e] = 0x23087986; + puVar2[0x21] = 0x20; + puVar2[0x1f] = 0; + puVar2[0x22] = 1; + ctx->source_count = iVar1 + 1; + } + return; +} + + + +int mbedtls_platform_entropy_poll(void *data,uchar *output,size_t len,size_t *olen) + +{ + uint uVar1; + uint uVar2; + + *olen = 0; + uVar2 = 0; + uVar1 = 0; + while (uVar1 != len) { + if ((uVar1 & 3) == 0) { + uVar2 = bl_rand(); + } + output[uVar1] = (uchar)uVar2; + uVar1 = uVar1 + 1; + uVar2 = uVar2 >> 8; + } + *olen = uVar1; + return 0; +} + + + +void mbedtls_pk_init(mbedtls_pk_context *ctx) + +{ + if (ctx != (mbedtls_pk_context *)0x0) { + ctx->pk_info = (mbedtls_pk_info_t *)0x0; + ctx->pk_ctx = (void *)0x0; + } + return; +} + + + +void mbedtls_pk_free(mbedtls_pk_context *ctx) + +{ + mbedtls_pk_context *pmVar1; + + if (ctx != (mbedtls_pk_context *)0x0) { + if (ctx->pk_info != (mbedtls_pk_info_t *)0x0) { + (*ctx->pk_info->ctx_free_func)(ctx->pk_ctx); + pmVar1 = ctx + 1; + while (ctx != pmVar1) { + *(undefined *)&ctx->pk_info = 0; + ctx = (mbedtls_pk_context *)((int)&ctx->pk_info + 1); + } + } + return; + } + return; +} + + + +mbedtls_pk_info_t * mbedtls_pk_info_from_type(mbedtls_pk_type_t pk_type) + +{ + uint uVar1; + + uVar1 = (uint)pk_type - 1 & 0xff; + if (uVar1 < 3) { + return *(mbedtls_pk_info_t **)(&CSWTCH_5 + uVar1 * 4); + } + return (mbedtls_pk_info_t *)0x0; +} + + + +int mbedtls_pk_setup(mbedtls_pk_context *ctx,mbedtls_pk_info_t *info) + +{ + void *pvVar1; + int iVar2; + + if (((ctx != (mbedtls_pk_context *)0x0) && (info != (mbedtls_pk_info_t *)0x0)) && + (ctx->pk_info == (mbedtls_pk_info_t *)0x0)) { + pvVar1 = (*info->ctx_alloc_func)(info->ctx_alloc_func); + ctx->pk_ctx = pvVar1; + if (pvVar1 == (void *)0x0) { + iVar2 = -0x3f80; + } + else { + ctx->pk_info = info; + iVar2 = 0; + } + return iVar2; + } + return -16000; +} + + + +int mbedtls_pk_can_do(mbedtls_pk_context *ctx,mbedtls_pk_type_t type) + +{ + int iVar1; + + if ((ctx != (mbedtls_pk_context *)0x0) && (ctx->pk_info != (mbedtls_pk_info_t *)0x0)) { + // WARNING: Could not recover jumptable at 0x23087a68. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*ctx->pk_info->can_do)(type); + return iVar1; + } + return 0; +} + + + +int mbedtls_pk_verify(mbedtls_pk_context *ctx,mbedtls_md_type_t md_alg,uchar *hash,size_t hash_len, + uchar *sig,size_t sig_len) + +{ + anon_subr_int_void_ptr_mbedtls_md_type_t_uchar_ptr_size_t_uchar_ptr_size_t_for_verify_func + *UNRECOVERED_JUMPTABLE; + uchar uVar1; + mbedtls_md_info_t *md_info; + undefined3 extraout_var; + int iVar2; + + if (ctx == (mbedtls_pk_context *)0x0) { + return -16000; + } + if (ctx->pk_info == (mbedtls_pk_info_t *)0x0) { +LAB_23087a78: + iVar2 = -16000; + } + else { + if (hash_len == 0) { + md_info = mbedtls_md_info_from_type(md_alg); + if (md_info == (mbedtls_md_info_t *)0x0) goto LAB_23087a78; + uVar1 = mbedtls_md_get_size(md_info); + hash_len = CONCAT31(extraout_var,uVar1); + } + UNRECOVERED_JUMPTABLE = ctx->pk_info->verify_func; + if (UNRECOVERED_JUMPTABLE != + (anon_subr_int_void_ptr_mbedtls_md_type_t_uchar_ptr_size_t_uchar_ptr_size_t_for_verify_func + *)0x0) { + // WARNING: Could not recover jumptable at 0x23087ac4. Too many branches + // WARNING: Treating indirect jump as call + iVar2 = (*UNRECOVERED_JUMPTABLE)(ctx->pk_ctx,md_alg,hash,hash_len,sig,sig_len); + return iVar2; + } + iVar2 = -0x3f00; + } + return iVar2; +} + + + +int mbedtls_pk_sign(mbedtls_pk_context *ctx,mbedtls_md_type_t md_alg,uchar *hash,size_t hash_len, + uchar *sig,size_t *sig_len,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng, + void *p_rng) + +{ + + anon_subr_int_void_ptr_mbedtls_md_type_t_uchar_ptr_size_t_uchar_ptr_size_t_ptr_anon_subr_int_void_ptr_uchar_ptr_size_t_ptr_void_ptr_for_sign_func + *UNRECOVERED_JUMPTABLE; + uchar uVar1; + mbedtls_md_info_t *md_info; + undefined3 extraout_var; + int iVar2; + + if (ctx == (mbedtls_pk_context *)0x0) { + return -16000; + } + if (ctx->pk_info == (mbedtls_pk_info_t *)0x0) { +LAB_23087ad8: + iVar2 = -16000; + } + else { + if (hash_len == 0) { + md_info = mbedtls_md_info_from_type(md_alg); + if (md_info == (mbedtls_md_info_t *)0x0) goto LAB_23087ad8; + uVar1 = mbedtls_md_get_size(md_info); + hash_len = CONCAT31(extraout_var,uVar1); + } + UNRECOVERED_JUMPTABLE = ctx->pk_info->sign_func; + if (UNRECOVERED_JUMPTABLE != + ( + anon_subr_int_void_ptr_mbedtls_md_type_t_uchar_ptr_size_t_uchar_ptr_size_t_ptr_anon_subr_int_void_ptr_uchar_ptr_size_t_ptr_void_ptr_for_sign_func + *)0x0) { + // WARNING: Could not recover jumptable at 0x23087b2c. Too many branches + // WARNING: Treating indirect jump as call + iVar2 = (*UNRECOVERED_JUMPTABLE)(ctx->pk_ctx,md_alg,hash,hash_len,sig,sig_len,f_rng,p_rng); + return iVar2; + } + iVar2 = -0x3f00; + } + return iVar2; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +int mbedtls_pk_decrypt(mbedtls_pk_context *ctx,uchar *input,size_t ilen,uchar *output,size_t *olen, + size_t osize,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng) + +{ + + anon_subr_int_void_ptr_uchar_ptr_size_t_uchar_ptr_size_t_ptr_size_t_anon_subr_int_void_ptr_uchar_ptr_size_t_ptr_void_ptr_for_decrypt_func + *UNRECOVERED_JUMPTABLE; + int iVar1; + + if ((ctx != (mbedtls_pk_context *)0x0) && (ctx->pk_info != (mbedtls_pk_info_t *)0x0)) { + UNRECOVERED_JUMPTABLE = ctx->pk_info->decrypt_func; + if (UNRECOVERED_JUMPTABLE != + ( + anon_subr_int_void_ptr_uchar_ptr_size_t_uchar_ptr_size_t_ptr_size_t_anon_subr_int_void_ptr_uchar_ptr_size_t_ptr_void_ptr_for_decrypt_func + *)0x0) { + // WARNING: Could not recover jumptable at 0x23087b4a. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*UNRECOVERED_JUMPTABLE)(ctx->pk_ctx); + return iVar1; + } + return -0x3f00; + } + return -16000; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +int mbedtls_pk_encrypt(mbedtls_pk_context *ctx,uchar *input,size_t ilen,uchar *output,size_t *olen, + size_t osize,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng) + +{ + + anon_subr_int_void_ptr_uchar_ptr_size_t_uchar_ptr_size_t_ptr_size_t_anon_subr_int_void_ptr_uchar_ptr_size_t_ptr_void_ptr_for_encrypt_func + *UNRECOVERED_JUMPTABLE; + int iVar1; + + if ((ctx != (mbedtls_pk_context *)0x0) && (ctx->pk_info != (mbedtls_pk_info_t *)0x0)) { + UNRECOVERED_JUMPTABLE = ctx->pk_info->encrypt_func; + if (UNRECOVERED_JUMPTABLE != + ( + anon_subr_int_void_ptr_uchar_ptr_size_t_uchar_ptr_size_t_ptr_size_t_anon_subr_int_void_ptr_uchar_ptr_size_t_ptr_void_ptr_for_encrypt_func + *)0x0) { + // WARNING: Could not recover jumptable at 0x23087b70. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*UNRECOVERED_JUMPTABLE)(ctx->pk_ctx); + return iVar1; + } + return -0x3f00; + } + return -16000; +} + + + +size_t mbedtls_pk_get_bitlen(mbedtls_pk_context *ctx) + +{ + size_t sVar1; + + if ((ctx != (mbedtls_pk_context *)0x0) && (ctx->pk_info != (mbedtls_pk_info_t *)0x0)) { + // WARNING: Could not recover jumptable at 0x23087b8e. Too many branches + // WARNING: Treating indirect jump as call + sVar1 = (*ctx->pk_info->get_bitlen)(ctx->pk_ctx); + return sVar1; + } + return 0; +} + + + +int mbedtls_pk_verify_ext + (mbedtls_pk_type_t type,void *options,mbedtls_pk_context *ctx,mbedtls_md_type_t md_alg + ,uchar *hash,size_t hash_len,uchar *sig,size_t sig_len) + +{ + undefined3 in_register_00002029; + int iVar1; + size_t sVar2; + int in_fa0; + uchar *in_fa1; + + if ((ctx != (mbedtls_pk_context *)0x0) && (ctx->pk_info != (mbedtls_pk_info_t *)0x0)) { + iVar1 = mbedtls_pk_can_do(ctx,type); + if (iVar1 == 0) { + return -0x3f00; + } + if (CONCAT31(in_register_00002029,type) == 6) { + if (options != (void *)0x0) { + sVar2 = mbedtls_pk_get_bitlen(ctx); + if (sig_len < sVar2 + 7 >> 3) { + return -0x4380; + } + iVar1 = mbedtls_rsa_rsassa_pss_verify_ext + ((mbedtls_rsa_context *)ctx->pk_ctx, + (anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0,(void *)0x0,0,md_alg, + hash_len,hash,*(mbedtls_md_type_t *)options,in_fa0,in_fa1); + if (iVar1 != 0) { + return iVar1; + } + sVar2 = mbedtls_pk_get_bitlen(ctx); + if (sig_len <= sVar2 + 7 >> 3) { + return 0; + } + return -0x3900; + } + } + else { + if (options == (void *)0x0) { + iVar1 = mbedtls_pk_verify(ctx,md_alg,hash,hash_len,sig,sig_len); + return iVar1; + } + } + } + return -16000; +} + + + +int mbedtls_pk_debug(mbedtls_pk_context *ctx,mbedtls_pk_debug_item *items) + +{ + anon_subr_void_void_ptr_mbedtls_pk_debug_item_ptr_for_debug_func *paVar1; + + if ((ctx != (mbedtls_pk_context *)0x0) && (ctx->pk_info != (mbedtls_pk_info_t *)0x0)) { + paVar1 = ctx->pk_info->debug_func; + if (paVar1 != (anon_subr_void_void_ptr_mbedtls_pk_debug_item_ptr_for_debug_func *)0x0) { + (*paVar1)(ctx->pk_ctx,items); + return 0; + } + return -0x3f00; + } + return -16000; +} + + + +char * mbedtls_pk_get_name(mbedtls_pk_context *ctx) + +{ + if ((ctx != (mbedtls_pk_context *)0x0) && (ctx->pk_info != (mbedtls_pk_info_t *)0x0)) { + return ctx->pk_info->name; + } + return "invalid PK"; +} + + + +mbedtls_pk_type_t mbedtls_pk_get_type(mbedtls_pk_context *ctx) + +{ + if ((ctx != (mbedtls_pk_context *)0x0) && (ctx->pk_info != (mbedtls_pk_info_t *)0x0)) { + return ctx->pk_info->type; + } + return MBEDTLS_PK_NONE; +} + + + +int pk_use_ecparams(mbedtls_asn1_buf *params,mbedtls_ecp_group *grp) + +{ + int iVar1; + mbedtls_ecp_group_id local_11 [4]; + mbedtls_ecp_group_id grp_id; + + if (params->tag != 6) { + return -0x3d00; + } + iVar1 = mbedtls_oid_get_ec_grp(params,local_11); + if (iVar1 == 0) { + if ((grp->id == MBEDTLS_ECP_DP_NONE) || (grp->id == local_11[0])) { + iVar1 = mbedtls_ecp_group_load(grp,local_11[0]); + } + else { + iVar1 = -0x3d00; + } + } + else { + iVar1 = -0x3a00; + } + return iVar1; +} + + + +int pk_parse_key_pkcs1_der(mbedtls_rsa_context *rsa,uchar *key,size_t keylen) + +{ + int iVar1; + int iVar2; + size_t sVar3; + uchar *end; + size_t sStack40; + size_t len; + uchar *p; + + len = (size_t)key; + iVar2 = mbedtls_asn1_get_tag((uchar **)&len,key + keylen,&sStack40,0x30); + if (iVar2 == 0) { + end = (uchar *)(len + sStack40); + iVar2 = mbedtls_asn1_get_int((uchar **)&len,end,(int *)rsa); + if (iVar2 == 0) { + if (rsa->ver != 0) { + return -0x3d80; + } + iVar1 = mbedtls_asn1_get_mpi((uchar **)&len,end,&rsa->N); + if (((((iVar1 == 0) && (iVar1 = mbedtls_asn1_get_mpi((uchar **)&len,end,&rsa->E), iVar1 == 0)) + && (iVar1 = mbedtls_asn1_get_mpi((uchar **)&len,end,&rsa->D), iVar1 == 0)) && + ((iVar1 = mbedtls_asn1_get_mpi((uchar **)&len,end,&rsa->P), iVar1 == 0 && + (iVar1 = mbedtls_asn1_get_mpi((uchar **)&len,end,&rsa->Q), iVar1 == 0)))) && + ((iVar1 = mbedtls_asn1_get_mpi((uchar **)&len,end,&rsa->DP), iVar1 == 0 && + ((iVar1 = mbedtls_asn1_get_mpi((uchar **)&len,end,&rsa->DQ), iVar1 == 0 && + (iVar1 = mbedtls_asn1_get_mpi((uchar **)&len,end,&rsa->QP), iVar1 == 0)))))) { + sVar3 = mbedtls_mpi_size(&rsa->N); + rsa->len = sVar3; + if ((uchar *)len != end) { + mbedtls_rsa_free(rsa); + return -0x3d66; + } + iVar2 = mbedtls_rsa_check_privkey(rsa); + if (iVar2 == 0) { + return 0; + } + mbedtls_rsa_free(rsa); + return iVar2; + } + mbedtls_rsa_free(rsa); + iVar2 = -0x3d00; + goto LAB_23087d30; + } + } + iVar1 = -0x3d00; +LAB_23087d30: + return iVar1 + iVar2; +} + + + +int pk_parse_key_sec1_der(mbedtls_ecp_keypair *eck,uchar *key,size_t keylen) + +{ + int iVar1; + uchar *end; + int iVar2; + uchar *end_00; + mbedtls_mpi *X; + int iStack56; + int version; + size_t len; + uchar *p; + mbedtls_asn1_buf params; + + len = (size_t)key; + iVar2 = mbedtls_asn1_get_tag((uchar **)&len,key + keylen,(size_t *)&version,0x30); + if (iVar2 == 0) { + end_00 = (uchar *)(len + version); + iVar2 = mbedtls_asn1_get_int((uchar **)&len,end_00,&iStack56); + if (iVar2 == 0) { + if (iStack56 != 1) { + return -0x3d80; + } + iVar2 = mbedtls_asn1_get_tag((uchar **)&len,end_00,(size_t *)&version,4); + if (iVar2 == 0) { + X = &eck->d; + iVar1 = mbedtls_mpi_read_binary(X,(uchar *)len,version); + if (iVar1 == 0) { + len = len + version; + if ((uchar *)len == end_00) { +LAB_23087f88: + iVar1 = mbedtls_ecp_mul((mbedtls_ecp_group *)eck,&eck->Q,X,&(eck->grp).G, + (anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0,(void *)0x0); + if (iVar1 != 0) goto LAB_23087e80; + } + else { + iVar1 = mbedtls_asn1_get_tag((uchar **)&len,end_00,(size_t *)&version,0xa0); + if (iVar1 == 0) { + end = (uchar *)(version + len); + p = (uchar *)(uint)*(byte *)len; + if (*(byte *)len != 6) { + iVar2 = -0x3d62; + goto LAB_23087ef2; + } + iVar2 = mbedtls_asn1_get_tag((uchar **)&len,end,(size_t *)¶ms,6); + if (iVar2 == 0) { + params.len = len; + len = len + params.tag; + if (end != (uchar *)len) { + iVar2 = -0x3d66; + goto LAB_23087ef2; + } + } + else { + iVar2 = iVar2 + -0x3d00; + if (iVar2 != 0) goto LAB_23087ef2; + } + iVar2 = pk_use_ecparams((mbedtls_asn1_buf *)&p,(mbedtls_ecp_group *)eck); + if (iVar2 != 0) goto LAB_23087ef2; + } + else { + if (iVar1 != -0x62) goto LAB_23087e80; + } + iVar1 = mbedtls_asn1_get_tag((uchar **)&len,end_00,(size_t *)&version,0xa1); + if (iVar1 != 0) { + if (iVar1 != -0x62) goto LAB_23087e80; + goto LAB_23087f88; + } + end_00 = (uchar *)(len + version); + iVar2 = mbedtls_asn1_get_bitstring_null((uchar **)&len,end_00,(size_t *)&version); + if (iVar2 != 0) goto LAB_23087e3e; + if (end_00 != (uchar *)(version + len)) { + return -0x3d66; + } + iVar2 = mbedtls_ecp_point_read_binary + ((mbedtls_ecp_group *)eck,&eck->Q,(uchar *)len,(size_t)(end_00 + -len) + ); + if (iVar2 == 0) { + iVar2 = mbedtls_ecp_check_pubkey((mbedtls_ecp_group *)eck,&eck->Q); + } + len = (size_t)end_00; + if (iVar2 != 0) { + if (iVar2 != -0x4e80) { + return -0x3d00; + } + goto LAB_23087f88; + } + } + iVar2 = mbedtls_ecp_check_privkey((mbedtls_ecp_group *)eck,X); + if (iVar2 == 0) { + return 0; + } +LAB_23087ef2: + mbedtls_ecp_keypair_free(eck); + return iVar2; + } +LAB_23087e80: + mbedtls_ecp_keypair_free(eck); + iVar2 = -0x3d00; + goto LAB_23087e8c; + } + } + } +LAB_23087e3e: + iVar1 = -0x3d00; +LAB_23087e8c: + return iVar1 + iVar2; +} + + + +int pk_get_pk_alg(uchar **p,uchar *end,mbedtls_pk_type_t *pk_alg,mbedtls_asn1_buf *params) + +{ + int iVar1; + undefined auStack44 [4]; + mbedtls_asn1_buf alg_oid; + + memset(params,0,0xc); + iVar1 = mbedtls_asn1_get_alg(p,end,(mbedtls_asn1_buf *)auStack44,params); + if (iVar1 == 0) { + iVar1 = mbedtls_oid_get_pk_alg((mbedtls_asn1_buf *)auStack44,pk_alg); + if (iVar1 == 0) { + if ((*pk_alg == MBEDTLS_PK_RSA) && + (((params->tag != 5 && (params->tag != 0)) || (params->len != 0)))) { + iVar1 = -0x3a80; + } + } + else { + iVar1 = -0x3c80; + } + } + else { + iVar1 = iVar1 + -0x3a80; + } + return iVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int pk_parse_key_pkcs8_unencrypted_der(mbedtls_pk_context *pk,uchar *key,size_t keylen) + +{ + uchar *end; + int iVar1; + mbedtls_pk_info_t *info; + mbedtls_pk_type_t mStack41; + mbedtls_pk_type_t pk_alg; + int iStack40; + int version; + size_t len; + uchar *p; + mbedtls_asn1_buf params; + + mStack41 = MBEDTLS_PK_NONE; + len = (size_t)key; + iVar1 = mbedtls_asn1_get_tag((uchar **)&len,key + keylen,(size_t *)&version,0x30); + if (iVar1 != 0) { +LAB_23088056: + return iVar1 + -0x3d00; + } + end = (uchar *)(len + version); + iVar1 = mbedtls_asn1_get_int((uchar **)&len,end,(int *)&stack0xffffffd8); + if (iVar1 != 0) goto LAB_23088056; + if (iStack40 != 0) { + return -0x3d80; + } + iVar1 = pk_get_pk_alg((uchar **)&len,end,&mStack41,(mbedtls_asn1_buf *)&p); + if ((iVar1 != 0) || + (iVar1 = mbedtls_asn1_get_tag((uchar **)&len,end,(size_t *)&version,4), iVar1 != 0)) + goto LAB_23088056; + if (version == 0) { + return -0x3d60; + } + info = mbedtls_pk_info_from_type(mStack41); + if (info == (mbedtls_pk_info_t *)0x0) { + return -0x3c80; + } + iVar1 = mbedtls_pk_setup(pk,info); + if (iVar1 != 0) { + return iVar1; + } + if (mStack41 == MBEDTLS_PK_RSA) { + iVar1 = pk_parse_key_pkcs1_der((mbedtls_rsa_context *)pk->pk_ctx,(uchar *)len,version); + } + else { + if (1 < (byte)(mStack41 + ~MBEDTLS_PK_RSA)) { + return -0x3c80; + } + iVar1 = pk_use_ecparams((mbedtls_asn1_buf *)&p,(mbedtls_ecp_group *)pk->pk_ctx); + if (iVar1 != 0) goto LAB_230880d8; + iVar1 = pk_parse_key_sec1_der((mbedtls_ecp_keypair *)pk->pk_ctx,(uchar *)len,version); + } + if (iVar1 == 0) { + return 0; + } +LAB_230880d8: + mbedtls_pk_free(pk); + return iVar1; +} + + + +// WARNING: Variable defined which should be unmapped: alg_params +// WARNING: Could not reconcile some variable overlaps + +int mbedtls_pk_parse_subpubkey(uchar **p,uchar *end,mbedtls_pk_context *pk) + +{ + mbedtls_rsa_context *ctx; + int iVar1; + mbedtls_pk_info_t *info; + size_t sVar2; + int iVar3; + uchar *end_00; + mbedtls_ecp_group *grp; + mbedtls_ecp_point *pt; + mbedtls_pk_type_t mStack53; + mbedtls_pk_type_t pk_alg; + size_t sStack52; + size_t len; + size_t len_1; + mbedtls_asn1_buf alg_params; + + mStack53 = MBEDTLS_PK_NONE; + iVar1 = mbedtls_asn1_get_tag(p,end,(size_t *)&stack0xffffffcc,0x30); + if (iVar1 != 0) { + iVar3 = -0x3d00; +LAB_2308813e: + return iVar1 + iVar3; + } + end_00 = *p + sStack52; + iVar1 = pk_get_pk_alg(p,end_00,&mStack53,(mbedtls_asn1_buf *)&len_1); + if (iVar1 != 0) { + return iVar1; + } + iVar1 = mbedtls_asn1_get_bitstring_null(p,end_00,(size_t *)&stack0xffffffcc); + if (iVar1 != 0) { + iVar3 = -0x3b00; + goto LAB_2308813e; + } + if (end_00 != *p + sStack52) { + return -0x3b66; + } + info = mbedtls_pk_info_from_type(mStack53); + if (info == (mbedtls_pk_info_t *)0x0) { + return -0x3c80; + } + iVar1 = mbedtls_pk_setup(pk,info); + if (iVar1 != 0) { + return iVar1; + } + if (mStack53 != MBEDTLS_PK_RSA) { + if ((byte)(mStack53 + ~MBEDTLS_PK_RSA) < 2) { + iVar1 = pk_use_ecparams((mbedtls_asn1_buf *)&len_1,(mbedtls_ecp_group *)pk->pk_ctx); + if (iVar1 == 0) { + grp = (mbedtls_ecp_group *)pk->pk_ctx; + pt = (mbedtls_ecp_point *)&grp[1].P.p; + iVar1 = mbedtls_ecp_point_read_binary(grp,pt,*p,(size_t)(end_00 + -(int)*p)); + if (iVar1 == 0) { + iVar1 = mbedtls_ecp_check_pubkey(grp,pt); + } + *p = end_00; + if (iVar1 == 0) { + return 0; + } + } + } + else { + iVar1 = -0x3c80; + } + goto LAB_230881d2; + } + ctx = (mbedtls_rsa_context *)pk->pk_ctx; + iVar1 = mbedtls_asn1_get_tag(p,end_00,&len,0x30); + if (iVar1 == 0) { + if (end_00 == *p + len) { + iVar1 = mbedtls_asn1_get_mpi(p,end_00,&ctx->N); + if ((iVar1 != 0) || (iVar1 = mbedtls_asn1_get_mpi(p,end_00,&ctx->E), iVar1 != 0)) + goto LAB_230881c8; + if (end_00 != *p) goto LAB_230881e8; + iVar1 = mbedtls_rsa_check_pubkey(ctx); + if (iVar1 != 0) { + iVar1 = -0x3b00; + goto LAB_230881d2; + } + sVar2 = mbedtls_mpi_size(&ctx->N); + ctx->len = sVar2; + goto LAB_23088224; + } + } + else { +LAB_230881c8: + iVar1 = iVar1 + -0x3b00; + if (iVar1 != 0) goto LAB_230881d2; +LAB_23088224: + if (*p == end_00) { + return 0; + } + } +LAB_230881e8: + iVar1 = -0x3b66; +LAB_230881d2: + mbedtls_pk_free(pk); + return iVar1; +} + + + +int mbedtls_pk_parse_key(mbedtls_pk_context *pk,uchar *key,size_t keylen,uchar *pwd,size_t pwdlen) + +{ + int iVar1; + mbedtls_pk_info_t *info; + uchar *puVar2; + size_t sStack64; + size_t len; + mbedtls_pem_context pem; + + mbedtls_pem_init((mbedtls_pem_context *)&len); + if ((keylen == 0) || (puVar2 = key + (keylen - 1), *puVar2 != '\0')) { +LAB_230882c0: + iVar1 = pk_parse_key_pkcs8_unencrypted_der(pk,key,keylen); + if (iVar1 != 0) { + mbedtls_pk_free(pk); + info = mbedtls_pk_info_from_type(MBEDTLS_PK_RSA); + if (info == (mbedtls_pk_info_t *)0x0) goto LAB_23088364; + iVar1 = mbedtls_pk_setup(pk,info); + if ((iVar1 == 0) && + (iVar1 = pk_parse_key_pkcs1_der((mbedtls_rsa_context *)pk->pk_ctx,key,keylen), iVar1 != 0)) + { + mbedtls_pk_free(pk); + info = mbedtls_pk_info_from_type(MBEDTLS_PK_ECKEY); + if (info == (mbedtls_pk_info_t *)0x0) goto LAB_23088364; + iVar1 = mbedtls_pk_setup(pk,info); + if ((iVar1 == 0) && + (iVar1 = pk_parse_key_sec1_der((mbedtls_ecp_keypair *)pk->pk_ctx,key,keylen), iVar1 != 0) + ) { + mbedtls_pk_free(pk); + return -0x3d00; + } + } + } + iVar1 = 0; + } + else { + iVar1 = mbedtls_pem_read_buffer + ((mbedtls_pem_context *)&len,"-----BEGIN RSA PRIVATE KEY-----", + "-----END RSA PRIVATE KEY-----",key,pwd,pwdlen,&sStack64); + if (iVar1 != 0) { + if (iVar1 == -0x1380) { + return -0x3b80; + } + if (iVar1 == -0x1300) { + return -0x3c00; + } + if (iVar1 != -0x1080) { + return iVar1; + } + if (*puVar2 == '\0') { + iVar1 = mbedtls_pem_read_buffer + ((mbedtls_pem_context *)&len,"-----BEGIN EC PRIVATE KEY-----", + "-----END EC PRIVATE KEY-----",key,pwd,pwdlen,&sStack64); + if (iVar1 == 0) { + info = mbedtls_pk_info_from_type(MBEDTLS_PK_ECKEY); + if (info == (mbedtls_pk_info_t *)0x0) goto LAB_23088364; + iVar1 = mbedtls_pk_setup(pk,info); + if (iVar1 != 0) goto LAB_2308839c; + iVar1 = pk_parse_key_sec1_der + ((mbedtls_ecp_keypair *)pk->pk_ctx,(uchar *)len,(size_t)pem.buf); +LAB_23088398: + if (iVar1 == 0) goto LAB_230883a2; + goto LAB_2308839c; + } + if (iVar1 == -0x1380) { + return -0x3b80; + } + if (iVar1 == -0x1300) { + return -0x3c00; + } + if (iVar1 != -0x1080) { + return iVar1; + } + if (*puVar2 == '\0') { + iVar1 = mbedtls_pem_read_buffer + ((mbedtls_pem_context *)&len,"-----BEGIN PRIVATE KEY-----", + "-----END PRIVATE KEY-----",key,(uchar *)0x0,0,&sStack64); + if (iVar1 == 0) { + iVar1 = pk_parse_key_pkcs8_unencrypted_der(pk,(uchar *)len,(size_t)pem.buf); + goto LAB_23088398; + } + if (iVar1 != -0x1080) { + return iVar1; + } + } + } + goto LAB_230882c0; + } + info = mbedtls_pk_info_from_type(MBEDTLS_PK_RSA); + if (info != (mbedtls_pk_info_t *)0x0) { + iVar1 = mbedtls_pk_setup(pk,info); + if (iVar1 == 0) { + iVar1 = pk_parse_key_pkcs1_der + ((mbedtls_rsa_context *)pk->pk_ctx,(uchar *)len,(size_t)pem.buf); + goto LAB_23088398; + } +LAB_2308839c: + mbedtls_pk_free(pk); +LAB_230883a2: + mbedtls_pem_free((mbedtls_pem_context *)&len); + return iVar1; + } +LAB_23088364: + iVar1 = -0x3c80; + } + return iVar1; +} + + + +int rsa_can_do(mbedtls_pk_type_t type) + +{ + undefined3 in_register_00002029; + + if (CONCAT31(in_register_00002029,type) != 1) { + return (uint)(CONCAT31(in_register_00002029,type) == 6); + } + return 1; +} + + + +size_t rsa_get_bitlen(void *ctx) + +{ + return *(int *)((int)ctx + 4) << 3; +} + + + +void rsa_debug(void *ctx,mbedtls_pk_debug_item *items) + +{ + items->name = "rsa.N"; + items->value = (void *)((int)ctx + 8); + items->type = MBEDTLS_PK_DEBUG_MPI; + items[1].type = MBEDTLS_PK_DEBUG_MPI; + items[1].name = "rsa.E"; + items[1].value = (void *)((int)ctx + 0x14); + return; +} + + + +int eckey_can_do(mbedtls_pk_type_t type) + +{ + undefined3 in_register_00002029; + + return (uint)(CONCAT31(in_register_00002029,type) - 2U < 3); +} + + + +size_t eckey_get_bitlen(void *ctx) + +{ + return *(size_t *)((int)ctx + 0x58); +} + + + +void eckey_debug(void *ctx,mbedtls_pk_debug_item *items) + +{ + items->type = MBEDTLS_PK_DEBUG_ECP; + items->name = "eckey.Q"; + items->value = (void *)((int)ctx + 0x88); + return; +} + + + +int eckeydh_can_do(mbedtls_pk_type_t type) + +{ + undefined3 in_register_00002029; + + return (uint)(CONCAT31(in_register_00002029,type) - 2U < 2); +} + + + +void rsa_free_wrap(void *ctx) + +{ + mbedtls_rsa_free((mbedtls_rsa_context *)ctx); + vPortFree(ctx); + return; +} + + + +void * rsa_alloc_wrap(void) + +{ + mbedtls_rsa_context *ctx; + + ctx = (mbedtls_rsa_context *)mycalloc(1,0xac); + if (ctx != (mbedtls_rsa_context *)0x0) { + mbedtls_rsa_init(ctx,0,0); + } + return ctx; +} + + + +int rsa_check_pair_wrap(mbedtls_rsa_context *pub,mbedtls_rsa_context *prv) + +{ + int iVar1; + + iVar1 = mbedtls_rsa_check_pubkey(pub); + if ((((iVar1 != 0) || (iVar1 = mbedtls_rsa_check_privkey(prv), iVar1 != 0)) || + (iVar1 = mbedtls_mpi_cmp_mpi(&pub->N,&prv->N), iVar1 != 0)) || + (iVar1 = mbedtls_mpi_cmp_mpi(&pub->E,&prv->E), iVar1 != 0)) { + iVar1 = -0x4200; + } + return iVar1; +} + + + +int rsa_encrypt_wrap(void *ctx,uchar *input,size_t ilen,uchar *output,size_t *olen,size_t osize, + anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng) + +{ + int iVar1; + uint uVar2; + + uVar2 = *(uint *)((int)ctx + 4); + *olen = uVar2; + if (uVar2 <= osize) { + iVar1 = mbedtls_rsa_pkcs1_encrypt((mbedtls_rsa_context *)ctx,f_rng,p_rng,0,ilen,input,output); + return iVar1; + } + return -0x4400; +} + + + +int rsa_decrypt_wrap(void *ctx,uchar *input,size_t ilen,uchar *output,size_t *olen,size_t osize, + anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng) + +{ + int iVar1; + + if (*(size_t *)((int)ctx + 4) == ilen) { + iVar1 = mbedtls_rsa_pkcs1_decrypt + ((mbedtls_rsa_context *)ctx,f_rng,p_rng,1,olen,input,output,osize); + return iVar1; + } + return -0x4080; +} + + + +int rsa_sign_wrap(void *ctx,mbedtls_md_type_t md_alg,uchar *hash,size_t hash_len,uchar *sig, + size_t *sig_len,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng) + +{ + int iVar1; + + *sig_len = *(size_t *)((int)ctx + 4); + iVar1 = mbedtls_rsa_pkcs1_sign((mbedtls_rsa_context *)ctx,f_rng,p_rng,1,md_alg,hash_len,hash,sig); + return iVar1; +} + + + +int rsa_verify_wrap(void *ctx,mbedtls_md_type_t md_alg,uchar *hash,size_t hash_len,uchar *sig, + size_t sig_len) + +{ + int iVar1; + + if (*(uint *)((int)ctx + 4) <= sig_len) { + iVar1 = mbedtls_rsa_pkcs1_verify + ((mbedtls_rsa_context *)ctx,(anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0, + (void *)0x0,0,md_alg,hash_len,hash,sig); + if ((iVar1 == 0) && (*(uint *)((int)ctx + 4) < sig_len)) { + iVar1 = -0x3900; + } + return iVar1; + } + return -0x4380; +} + + + +void eckey_free_wrap(void *ctx) + +{ + mbedtls_ecp_keypair_free((mbedtls_ecp_keypair *)ctx); + vPortFree(ctx); + return; +} + + + +void * eckey_alloc_wrap(void) + +{ + mbedtls_ecp_keypair *key; + + key = (mbedtls_ecp_keypair *)mycalloc(1,0xac); + if (key != (mbedtls_ecp_keypair *)0x0) { + mbedtls_ecp_keypair_init(key); + } + return key; +} + + + +int eckey_check_pair(mbedtls_ecp_keypair *pub,mbedtls_ecp_keypair *prv) + +{ + mbedtls_ecp_group_id mVar1; + int iVar2; + mbedtls_mpi *Y; + mbedtls_mpi *Y_00; + mbedtls_ecp_point mStack192; + mbedtls_ecp_group mStack156; + + mVar1 = (pub->grp).id; + if ((mVar1 != MBEDTLS_ECP_DP_NONE) && ((prv->grp).id == mVar1)) { + iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&pub->Q,(mbedtls_mpi *)&prv->Q); + if (iVar2 == 0) { + Y_00 = &(prv->Q).Y; + iVar2 = mbedtls_mpi_cmp_mpi(&(pub->Q).Y,Y_00); + if (iVar2 == 0) { + Y = &(prv->Q).Z; + iVar2 = mbedtls_mpi_cmp_mpi(&(pub->Q).Z,Y); + if (iVar2 == 0) { + mbedtls_ecp_point_init(&mStack192); + memset(&mStack156,0,0x7c); + mbedtls_ecp_group_copy(&mStack156,(mbedtls_ecp_group *)prv); + iVar2 = mbedtls_ecp_mul(&mStack156,&mStack192,&prv->d,&(prv->grp).G, + (anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0,(void *)0x0); + if ((iVar2 == 0) && + (((iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&mStack192,(mbedtls_mpi *)&prv->Q), + iVar2 != 0 || (iVar2 = mbedtls_mpi_cmp_mpi(&mStack192.Y,Y_00), iVar2 != 0)) || + (iVar2 = mbedtls_mpi_cmp_mpi(&mStack192.Z,Y), iVar2 != 0)))) { + iVar2 = -0x4f80; + } + mbedtls_ecp_point_free(&mStack192); + mbedtls_ecp_group_free(&mStack156); + return iVar2; + } + } + } + } + return -0x4f80; +} + + + +// WARNING: Variable defined which should be unmapped: mask + +void mgf_mask(uchar *dst,size_t dlen,uchar *src,size_t slen,mbedtls_md_context_t *md_ctx) + +{ + uchar uVar1; + undefined3 extraout_var; + byte *pbVar2; + byte *pbVar3; + uint uVar4; + uint uVar5; + uchar auStack68 [3]; + char cStack65; + uchar counter [4]; + uchar mask [32]; + + memset(counter,0,0x20); + memset(auStack68,0,4); + uVar1 = mbedtls_md_get_size(md_ctx->md_info); + while (dlen != 0) { + uVar5 = dlen; + if (CONCAT31(extraout_var,uVar1) < dlen) { + uVar5 = CONCAT31(extraout_var,uVar1); + } + mbedtls_md_starts(md_ctx); + mbedtls_md_update(md_ctx,src,slen); + mbedtls_md_update(md_ctx,auStack68,4); + mbedtls_md_finish(md_ctx,counter); + uVar4 = 0; + while (pbVar3 = dst + uVar4, uVar4 != uVar5) { + pbVar2 = counter + uVar4; + uVar4 = uVar4 + 1; + *pbVar3 = *pbVar2 ^ *pbVar3; + } + dlen = dlen - uVar4; + cStack65 = cStack65 + '\x01'; + dst = pbVar3; + } + return; +} + + + +void mbedtls_rsa_init(mbedtls_rsa_context *ctx,int padding,int hash_id) + +{ + memset(ctx,0,0xac); + ctx->padding = padding; + ctx->hash_id = hash_id; + return; +} + + + +int mbedtls_rsa_check_pubkey(mbedtls_rsa_context *ctx) + +{ + mbedtls_mpi *X; + size_t sVar1; + int iVar2; + mbedtls_mpi_uint *pmVar3; + mbedtls_mpi_uint *pmVar4; + + pmVar4 = (ctx->N).p; + if ((((pmVar4 != (mbedtls_mpi_uint *)0x0) && + (pmVar3 = (ctx->E).p, pmVar3 != (mbedtls_mpi_uint *)0x0)) && ((*pmVar4 & 1) != 0)) && + ((*pmVar3 & 1) != 0)) { + X = &ctx->N; + sVar1 = mbedtls_mpi_bitlen(X); + if ((0x7f < sVar1) && (sVar1 = mbedtls_mpi_bitlen(X), sVar1 < 0x2001)) { + sVar1 = mbedtls_mpi_bitlen(&ctx->E); + if ((1 < sVar1) && (iVar2 = mbedtls_mpi_cmp_mpi(&ctx->E,X), iVar2 < 0)) { + return 0; + } + } + return -0x4200; + } + return -0x4200; +} + + + +int mbedtls_rsa_check_privkey(mbedtls_rsa_context *ctx) + +{ + int iVar1; + mbedtls_mpi *B; + mbedtls_mpi *A; + mbedtls_mpi *A_00; + undefined auStack188 [4]; + mbedtls_mpi PQ; + mbedtls_mpi DE; + mbedtls_mpi P1; + mbedtls_mpi Q1; + mbedtls_mpi H; + mbedtls_mpi I; + mbedtls_mpi G; + mbedtls_mpi G2; + mbedtls_mpi L1; + mbedtls_mpi L2; + mbedtls_mpi DP; + mbedtls_mpi DQ; + mbedtls_mpi QP; + + iVar1 = mbedtls_rsa_check_pubkey(ctx); + if (iVar1 == 0) { + iVar1 = -0x4200; + if ((((ctx->P).p != (mbedtls_mpi_uint *)0x0) && ((ctx->Q).p != (mbedtls_mpi_uint *)0x0)) && + (iVar1 = -0x4200, (ctx->D).p != (mbedtls_mpi_uint *)0x0)) { + mbedtls_mpi_init((mbedtls_mpi *)auStack188); + mbedtls_mpi_init((mbedtls_mpi *)&PQ.p); + mbedtls_mpi_init((mbedtls_mpi *)&DE.p); + mbedtls_mpi_init((mbedtls_mpi *)&P1.p); + mbedtls_mpi_init((mbedtls_mpi *)&Q1.p); + mbedtls_mpi_init((mbedtls_mpi *)&H.p); + mbedtls_mpi_init((mbedtls_mpi *)&I.p); + mbedtls_mpi_init((mbedtls_mpi *)&G.p); + mbedtls_mpi_init((mbedtls_mpi *)&G2.p); + mbedtls_mpi_init((mbedtls_mpi *)&L1.p); + mbedtls_mpi_init((mbedtls_mpi *)&L2.p); + mbedtls_mpi_init((mbedtls_mpi *)&DP.p); + mbedtls_mpi_init((mbedtls_mpi *)&DQ.p); + A = &ctx->P; + B = &ctx->Q; + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)auStack188,A,B); + if (iVar1 == 0) { + A_00 = &ctx->D; + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&PQ.p,A_00,&ctx->E); + if (((((iVar1 == 0) && (iVar1 = mbedtls_mpi_sub_int((mbedtls_mpi *)&DE.p,A,1), iVar1 == 0)) + && ((iVar1 = mbedtls_mpi_sub_int((mbedtls_mpi *)&P1.p,B,1), iVar1 == 0 && + ((iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&Q1.p,(mbedtls_mpi *)&DE.p, + (mbedtls_mpi *)&P1.p), iVar1 == 0 && + (iVar1 = mbedtls_mpi_gcd((mbedtls_mpi *)&I.p,&ctx->E,(mbedtls_mpi *)&Q1.p), + iVar1 == 0)))))) && + ((iVar1 = mbedtls_mpi_gcd((mbedtls_mpi *)&G.p,(mbedtls_mpi *)&DE.p,(mbedtls_mpi *)&P1.p) + , iVar1 == 0 && + ((((iVar1 = mbedtls_mpi_div_mpi((mbedtls_mpi *)&G2.p,(mbedtls_mpi *)&L1.p, + (mbedtls_mpi *)&Q1.p,(mbedtls_mpi *)&G.p), iVar1 == 0 + && (iVar1 = mbedtls_mpi_mod_mpi((mbedtls_mpi *)&H.p,(mbedtls_mpi *)&PQ.p, + (mbedtls_mpi *)&G2.p), iVar1 == 0)) && + (iVar1 = mbedtls_mpi_mod_mpi((mbedtls_mpi *)&L2.p,A_00,(mbedtls_mpi *)&DE.p), + iVar1 == 0)) && + ((iVar1 = mbedtls_mpi_mod_mpi((mbedtls_mpi *)&DP.p,A_00,(mbedtls_mpi *)&P1.p), + iVar1 == 0 && (iVar1 = mbedtls_mpi_inv_mod((mbedtls_mpi *)&DQ.p,B,A), iVar1 == 0))))) + ))) && ((((iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)auStack188,&ctx->N), iVar1 != 0 + || ((iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&L2.p,&ctx->DP), iVar1 != 0 + || (iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&DP.p,&ctx->DQ), + iVar1 != 0)))) || + (iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&DQ.p,&ctx->QP), iVar1 != 0)) || + (((iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&L1.p,0), iVar1 != 0 || + (iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&H.p,1), iVar1 != 0)) || + (iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&I.p,1), iVar1 != 0)))))) { + iVar1 = -0x4200; + } + } + mbedtls_mpi_free((mbedtls_mpi *)auStack188); + mbedtls_mpi_free((mbedtls_mpi *)&PQ.p); + mbedtls_mpi_free((mbedtls_mpi *)&DE.p); + mbedtls_mpi_free((mbedtls_mpi *)&P1.p); + mbedtls_mpi_free((mbedtls_mpi *)&Q1.p); + mbedtls_mpi_free((mbedtls_mpi *)&H.p); + mbedtls_mpi_free((mbedtls_mpi *)&I.p); + mbedtls_mpi_free((mbedtls_mpi *)&G.p); + mbedtls_mpi_free((mbedtls_mpi *)&G2.p); + mbedtls_mpi_free((mbedtls_mpi *)&L1.p); + mbedtls_mpi_free((mbedtls_mpi *)&L2.p); + mbedtls_mpi_free((mbedtls_mpi *)&DP.p); + mbedtls_mpi_free((mbedtls_mpi *)&DQ.p); + if ((iVar1 != -0x4200) && (iVar1 != 0)) { + iVar1 = iVar1 + -0x4200; + } + } + } + return iVar1; +} + + + +int mbedtls_rsa_check_pub_priv(mbedtls_rsa_context *pub,mbedtls_rsa_context *prv) + +{ + int iVar1; + + iVar1 = mbedtls_rsa_check_pubkey(pub); + if ((((iVar1 != 0) || (iVar1 = mbedtls_rsa_check_privkey(prv), iVar1 != 0)) || + (iVar1 = mbedtls_mpi_cmp_mpi(&pub->N,&prv->N), iVar1 != 0)) || + (iVar1 = mbedtls_mpi_cmp_mpi(&pub->E,&prv->E), iVar1 != 0)) { + iVar1 = -0x4200; + } + return iVar1; +} + + + +int mbedtls_rsa_public(mbedtls_rsa_context *ctx,uchar *input,uchar *output) + +{ + int iVar1; + int iVar2; + size_t buflen; + undefined auStack44 [4]; + mbedtls_mpi T; + + mbedtls_mpi_init((mbedtls_mpi *)auStack44); + iVar1 = mbedtls_mpi_read_binary((mbedtls_mpi *)auStack44,input,ctx->len); + if (iVar1 == 0) { + iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)auStack44,&ctx->N); + iVar1 = -4; + if (iVar2 < 0) { + buflen = ctx->len; + iVar1 = mbedtls_mpi_exp_mod((mbedtls_mpi *)auStack44,(mbedtls_mpi *)auStack44,&ctx->E,&ctx->N, + &ctx->RN); + if (iVar1 == 0) { + iVar1 = mbedtls_mpi_write_binary((mbedtls_mpi *)auStack44,output,buflen); + } + } + } + mbedtls_mpi_free((mbedtls_mpi *)auStack44); + if (iVar1 != 0) { + iVar1 = iVar1 + -0x4280; + } + return iVar1; +} + + + +int mbedtls_rsa_private(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng, + void *p_rng,uchar *input,uchar *output) + +{ + int iVar1; + int iVar2; + mbedtls_mpi *Y; + mbedtls_mpi *G; + mbedtls_mpi *X; + undefined auStack84 [4]; + mbedtls_mpi T; + mbedtls_mpi T1; + mbedtls_mpi T2; + + if ((((ctx->P).p == (mbedtls_mpi_uint *)0x0) || ((ctx->Q).p == (mbedtls_mpi_uint *)0x0)) || + ((ctx->D).p == (mbedtls_mpi_uint *)0x0)) { + return -0x4080; + } + mbedtls_mpi_init((mbedtls_mpi *)auStack84); + mbedtls_mpi_init((mbedtls_mpi *)&T.p); + mbedtls_mpi_init((mbedtls_mpi *)&T1.p); + iVar1 = mbedtls_mpi_read_binary((mbedtls_mpi *)auStack84,input,ctx->len); + if (iVar1 == 0) { + Y = &ctx->N; + iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)auStack84,Y); + iVar1 = -4; + if (iVar2 < 0) { + if (f_rng != (anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0) { + if ((ctx->Vf).p == (mbedtls_mpi_uint *)0x0) { + iVar2 = 0xc; + X = &ctx->Vf; + G = &ctx->Vi; + do { + iVar2 = iVar2 + -1; + if (iVar2 == 0) { + iVar1 = -0x4480; + goto cleanup; + } + iVar1 = mbedtls_mpi_fill_random(X,ctx->len - 1,f_rng,p_rng); + if ((iVar1 != 0) || (iVar1 = mbedtls_mpi_gcd(G,X,Y), iVar1 != 0)) goto cleanup; + iVar1 = mbedtls_mpi_cmp_int(G,1); + } while (iVar1 != 0); + iVar1 = mbedtls_mpi_inv_mod(G,X,Y); + if (iVar1 != 0) goto cleanup; + iVar1 = mbedtls_mpi_exp_mod(G,G,&ctx->E,Y,&ctx->RN); + } + else { + G = &ctx->Vi; + iVar1 = mbedtls_mpi_mul_mpi(G,G,G); + if ((iVar1 != 0) || (iVar1 = mbedtls_mpi_mod_mpi(G,G,Y), iVar1 != 0)) goto cleanup; + G = &ctx->Vf; + iVar1 = mbedtls_mpi_mul_mpi(G,G,G); + if (iVar1 != 0) goto cleanup; + iVar1 = mbedtls_mpi_mod_mpi(G,G,Y); + } + if (((iVar1 != 0) || + (iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)auStack84,(mbedtls_mpi *)auStack84,&ctx->Vi) + , iVar1 != 0)) || + (iVar1 = mbedtls_mpi_mod_mpi((mbedtls_mpi *)auStack84,(mbedtls_mpi *)auStack84,Y), + iVar1 != 0)) goto cleanup; + } + iVar1 = mbedtls_mpi_exp_mod((mbedtls_mpi *)&T.p,(mbedtls_mpi *)auStack84,&ctx->DP,&ctx->P, + &ctx->RP); + if (iVar1 == 0) { + iVar1 = mbedtls_mpi_exp_mod((mbedtls_mpi *)&T1.p,(mbedtls_mpi *)auStack84,&ctx->DQ,&ctx->Q, + &ctx->RQ); + if (((((iVar1 == 0) && + (iVar1 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)auStack84,(mbedtls_mpi *)&T.p, + (mbedtls_mpi *)&T1.p), iVar1 == 0)) && + ((iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T.p,(mbedtls_mpi *)auStack84,&ctx->QP), + iVar1 == 0 && + ((iVar1 = mbedtls_mpi_mod_mpi((mbedtls_mpi *)auStack84,(mbedtls_mpi *)&T.p,&ctx->P), + iVar1 == 0 && + (iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T.p,(mbedtls_mpi *)auStack84,&ctx->Q), + iVar1 == 0)))))) && + (iVar1 = mbedtls_mpi_add_mpi((mbedtls_mpi *)auStack84,(mbedtls_mpi *)&T1.p, + (mbedtls_mpi *)&T.p), iVar1 == 0)) && + ((f_rng == (anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0 || + ((iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)auStack84,(mbedtls_mpi *)auStack84,&ctx->Vf + ), iVar1 == 0 && + (iVar1 = mbedtls_mpi_mod_mpi((mbedtls_mpi *)auStack84,(mbedtls_mpi *)auStack84,Y), + iVar1 == 0)))))) { + iVar1 = mbedtls_mpi_write_binary((mbedtls_mpi *)auStack84,output,ctx->len); + } + } + } + } +cleanup: + mbedtls_mpi_free((mbedtls_mpi *)auStack84); + mbedtls_mpi_free((mbedtls_mpi *)&T.p); + mbedtls_mpi_free((mbedtls_mpi *)&T1.p); + if (iVar1 != 0) { + iVar1 = iVar1 + -0x4300; + } + return iVar1; +} + + + +int mbedtls_rsa_rsaes_oaep_encrypt + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,uchar *label,size_t label_len,size_t ilen,uchar *input,uchar *output) + +{ + uint __n; + size_t dlen; + uchar slen; + mbedtls_md_info_t *md_info; + undefined3 extraout_var; + int iVar1; + uint uVar2; + uchar *output_00; + uchar *src; + uchar *in_stack_00000000; + undefined auStack76 [4]; + mbedtls_md_context_t md_ctx; + + if ((((mode != 1) || (ctx->padding == 1)) && + (f_rng != (anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0)) && + (md_info = mbedtls_md_info_from_type(*(mbedtls_md_type_t *)&ctx->hash_id), + md_info != (mbedtls_md_info_t *)0x0)) { + __n = ctx->len; + slen = mbedtls_md_get_size(md_info); + _slen = CONCAT31(extraout_var,slen); + uVar2 = ilen + 2 + _slen * 2; + if ((ilen <= uVar2) && (uVar2 <= __n)) { + memset(in_stack_00000000,0,__n); + src = in_stack_00000000 + 1; + *in_stack_00000000 = '\0'; + iVar1 = (*f_rng)(p_rng,src,_slen); + if (iVar1 != 0) { + return iVar1 + -0x4480; + } + output_00 = src + _slen; + mbedtls_md(md_info,label,label_len,output_00); + output_00[((__n - ilen) + -2) - _slen] = '\x01'; + memcpy(output_00 + (((__n - ilen) + -2) - _slen) + 1,input,ilen); + mbedtls_md_init((mbedtls_md_context_t *)auStack76); + iVar1 = mbedtls_md_setup((mbedtls_md_context_t *)auStack76,md_info,0); + if (iVar1 != 0) { + mbedtls_md_free((mbedtls_md_context_t *)auStack76); + return iVar1; + } + dlen = (__n - 1) - _slen; + mgf_mask(in_stack_00000000 + _slen + 1,dlen,src,_slen,(mbedtls_md_context_t *)auStack76); + mgf_mask(src,_slen,in_stack_00000000 + _slen + 1,dlen,(mbedtls_md_context_t *)auStack76); + mbedtls_md_free((mbedtls_md_context_t *)auStack76); + if (mode == 0) { + iVar1 = mbedtls_rsa_public(ctx,in_stack_00000000,in_stack_00000000); + return iVar1; + } + iVar1 = mbedtls_rsa_private(ctx,f_rng,p_rng,in_stack_00000000,in_stack_00000000); + return iVar1; + } + } + return -0x4080; +} + + + +int mbedtls_rsa_rsaes_pkcs1_v15_encrypt + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,size_t ilen,uchar *input,uchar *output) + +{ + int iVar1; + int iVar2; + uchar *puVar3; + uchar *puVar4; + + if ((((mode == 1) && (ctx->padding != 0)) || + (f_rng == (anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0)) || + ((input == (uchar *)0x0 || (output == (uchar *)0x0)))) { + return -0x4080; + } + if ((0xfffffff4 < ilen) || (ctx->len < ilen + 0xb)) { + return -0x4080; + } + iVar1 = ctx->len - ilen; + *output = '\0'; + iVar2 = iVar1 + -3; + puVar4 = output + 2; + if (mode == 0) { + output[1] = '\x02'; + puVar3 = output + iVar1 + -1; + while (puVar4 != puVar3) { + iVar1 = 100; + while (iVar2 = (*f_rng)(p_rng,puVar4,1), *puVar4 == '\0') { + iVar1 = iVar1 + -1; + if ((iVar1 == 0) || (iVar2 != 0)) goto LAB_23088e56; + } + if (iVar2 != 0) { +LAB_23088e56: + return iVar2 + -0x4480; + } + puVar4 = puVar4 + 1; + } + } + else { + output[1] = '\x01'; + puVar3 = output; + while (output + iVar2 != puVar3) { + puVar3[2] = -1; + puVar3 = puVar3 + 1; + } + puVar3 = puVar4 + iVar2; + } + *puVar3 = '\0'; + memcpy(puVar3 + 1,input,ilen); + if (mode != 0) { + iVar1 = mbedtls_rsa_private(ctx,f_rng,p_rng,output,output); + return iVar1; + } + iVar1 = mbedtls_rsa_public(ctx,output,output); + return iVar1; +} + + + +int mbedtls_rsa_pkcs1_encrypt + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,size_t ilen,uchar *input,uchar *output) + +{ + int iVar1; + uchar *in_fa0; + + if (ctx->padding == 0) { + iVar1 = mbedtls_rsa_rsaes_pkcs1_v15_encrypt(ctx,f_rng,p_rng,mode,ilen,input,output); + return iVar1; + } + if (ctx->padding != 1) { + return -0x4100; + } + iVar1 = mbedtls_rsa_rsaes_oaep_encrypt(ctx,f_rng,p_rng,mode,(uchar *)0x0,0,ilen,input,in_fa0); + return iVar1; +} + + + +int mbedtls_rsa_rsaes_oaep_decrypt + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,uchar *label,size_t label_len,size_t *olen,uchar *input,uchar *output, + size_t output_max_len) + +{ + uint __n; + uchar dlen; + mbedtls_md_info_t *md_info; + undefined3 extraout_var; + int iVar1; + uchar *puVar2; + uint uVar3; + int iVar4; + byte *pbVar5; + byte *pbVar6; + uchar *output_00; + int iVar7; + size_t slen; + void *in_stack_00000000; + uint in_stack_00000004; + undefined auStack1132 [4]; + mbedtls_md_context_t md_ctx; + uchar lhash [32]; + uchar buf [1024]; + + if ((((mode != 1) || (ctx->padding == 1)) && (__n = ctx->len, __n - 0x10 < 0x3f1)) && + (md_info = mbedtls_md_info_from_type(*(mbedtls_md_type_t *)&ctx->hash_id), + md_info != (mbedtls_md_info_t *)0x0)) { + dlen = mbedtls_md_get_size(md_info); + _dlen = CONCAT31(extraout_var,dlen); + iVar7 = _dlen + 1; + if ((uint)(iVar7 * 2) <= __n) { + output_00 = lhash + 0x1c; + if (mode == 0) { + iVar1 = mbedtls_rsa_public(ctx,input,output_00); + } + else { + iVar1 = mbedtls_rsa_private(ctx,f_rng,p_rng,input,output_00); + } + if (iVar1 != 0) { + return iVar1; + } + mbedtls_md_init((mbedtls_md_context_t *)auStack1132); + iVar1 = mbedtls_md_setup((mbedtls_md_context_t *)auStack1132,md_info,0); + if (iVar1 != 0) { + mbedtls_md_free((mbedtls_md_context_t *)auStack1132); + return iVar1; + } + mbedtls_md(md_info,label,label_len,(uchar *)&md_ctx.hmac_ctx); + slen = (__n - 1) - _dlen; + mgf_mask(lhash + 0x1d,_dlen,output_00 + iVar7,slen,(mbedtls_md_context_t *)auStack1132); + mgf_mask(output_00 + iVar7,slen,lhash + 0x1d,_dlen,(mbedtls_md_context_t *)auStack1132); + mbedtls_md_free((mbedtls_md_context_t *)auStack1132); + uVar3 = 0; + while (uVar3 < _dlen) { + pbVar5 = (byte *)((int)&md_ctx.hmac_ctx + uVar3); + pbVar6 = lhash + _dlen + 0x1d + uVar3; + uVar3 = uVar3 + 1; + lhash[28] = *pbVar5 ^ *pbVar6 | lhash[28]; + } + puVar2 = lhash + _dlen + 0x1d + _dlen; + uVar3 = 0; + iVar4 = 0; + iVar1 = 0; + while (__n + iVar7 * -2 != iVar1) { + pbVar6 = puVar2 + iVar1; + iVar1 = iVar1 + 1; + uVar3 = uVar3 | *pbVar6; + iVar4 = iVar4 + ((-uVar3 & 0xff | uVar3) >> 7 ^ 1); + } + if ((byte)(puVar2[iVar4] ^ 1 | lhash[28]) == 0) { + __n = __n - (int)(puVar2 + iVar4 + 1 + -(int)output_00); + if (__n <= in_stack_00000004) { + *olen = __n; + memcpy(in_stack_00000000,puVar2 + iVar4 + 1,__n); + return 0; + } + return -0x4400; + } + return -0x4100; + } + } + return -0x4080; +} + + + +// WARNING: Variable defined which should be unmapped: buf + +int mbedtls_rsa_rsaes_pkcs1_v15_decrypt + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,size_t *olen,uchar *input,uchar *output,size_t output_max_len) + +{ + char *pcVar1; + int iVar2; + uint __n; + byte *pbVar3; + uint uVar4; + uint uVar5; + byte *pbVar6; + size_t sVar7; + byte local_420; + byte bStack1055; + byte abStack1054 [2]; + uchar buf [1024]; + + pbVar6 = &local_420; + pbVar3 = &local_420; + if (((mode == 1) && (ctx->padding != 0)) || (sVar7 = ctx->len, 0x3f0 < sVar7 - 0x10)) { + iVar2 = -0x4080; + } + else { + if (mode == 0) { + iVar2 = mbedtls_rsa_public(ctx,input,&local_420); + } + else { + iVar2 = mbedtls_rsa_private(ctx,f_rng,p_rng,input,&local_420); + } + if (iVar2 == 0) { + if (mode == 1) { + bStack1055 = bStack1055 ^ 2; + uVar4 = 0; + __n = 0; + uVar5 = 0; + do { + pbVar3 = pbVar6 + 2; + __n = __n + 1; + pbVar6 = pbVar6 + 1; + uVar4 = uVar4 | ((uint)*pbVar3 | -(uint)*pbVar3 & 0xff) >> 7 ^ 1; + uVar5 = uVar5 + ((-uVar4 & 0xff) >> 7 ^ 1); + } while (__n < sVar7 - 3); + } + else { + bStack1055 = bStack1055 ^ 1; + uVar4 = 0; + __n = 0; + uVar5 = 0; + do { + pcVar1 = (char *)(pbVar3 + 2); + __n = __n + 1; + pbVar3 = pbVar3 + 1; + uVar4 = *pcVar1 != -1 | uVar4; + uVar5 = uVar5 + (uVar4 ^ 1); + } while (__n < sVar7 - 3); + } + if ((byte)(uVar5 < 8 | bStack1055 | local_420 | abStack1054[uVar5]) == 0) { + __n = sVar7 - (int)(abStack1054 + uVar5 + 1 + -(int)&local_420); + if (output_max_len < __n) { + iVar2 = -0x4400; + } + else { + *olen = __n; + memcpy(output,abStack1054 + uVar5 + 1,__n); + } + } + else { + iVar2 = -0x4100; + } + } + } + return iVar2; +} + + + +int mbedtls_rsa_pkcs1_decrypt + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,size_t *olen,uchar *input,uchar *output,size_t output_max_len) + +{ + int iVar1; + uchar *in_fa0; + size_t in_fa1; + + if (ctx->padding == 0) { + iVar1 = mbedtls_rsa_rsaes_pkcs1_v15_decrypt + (ctx,f_rng,p_rng,mode,olen,input,output,output_max_len); + return iVar1; + } + if (ctx->padding != 1) { + return -0x4100; + } + iVar1 = mbedtls_rsa_rsaes_oaep_decrypt + (ctx,f_rng,p_rng,mode,(uchar *)0x0,0,olen,input,in_fa0,in_fa1); + return iVar1; +} + + + +int mbedtls_rsa_rsassa_pss_sign + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig) + +{ + uint __n; + uchar uVar1; + mbedtls_md_info_t *md_info; + undefined3 extraout_var; + size_t __n_00; + int iVar2; + size_t sVar3; + uint uVar4; + undefined3 in_register_00002039; + uchar *input; + undefined auStack108 [4]; + mbedtls_md_context_t md_ctx; + uchar salt [32]; + + if (((mode != 1) || (ctx->padding == 1)) && + (f_rng != (anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0)) { + __n = ctx->len; + if (CONCAT31(in_register_00002039,md_alg) != 0) { + md_info = mbedtls_md_info_from_type(md_alg); + if (md_info == (mbedtls_md_info_t *)0x0) { + return -0x4080; + } + uVar1 = mbedtls_md_get_size(md_info); + hashlen = CONCAT31(extraout_var,uVar1); + } + md_info = mbedtls_md_info_from_type(*(mbedtls_md_type_t *)&ctx->hash_id); + if (md_info != (mbedtls_md_info_t *)0x0) { + uVar1 = mbedtls_md_get_size(md_info); + __n_00 = CONCAT31(__n_00._1_3_,uVar1); + if ((__n_00 + 1) * 2 <= __n) { + memset(sig,0,__n); + iVar2 = (*f_rng)(p_rng,(uchar *)&md_ctx.hmac_ctx,__n_00); + if (iVar2 != 0) { + return iVar2 + -0x4480; + } + sVar3 = mbedtls_mpi_bitlen(&ctx->N); + input = sig + __n + (__n_00 + 1) * -2; + *input = '\x01'; + memcpy(input + 1,&md_ctx.hmac_ctx,__n_00); + mbedtls_md_init((mbedtls_md_context_t *)auStack108); + iVar2 = mbedtls_md_setup((mbedtls_md_context_t *)auStack108,md_info,0); + if (iVar2 == 0) { + input = input + 1 + __n_00; + mbedtls_md_starts((mbedtls_md_context_t *)auStack108); + mbedtls_md_update((mbedtls_md_context_t *)auStack108,input,8); + mbedtls_md_update((mbedtls_md_context_t *)auStack108,hash,hashlen); + mbedtls_md_update((mbedtls_md_context_t *)auStack108,(uchar *)&md_ctx.hmac_ctx,__n_00); + mbedtls_md_finish((mbedtls_md_context_t *)auStack108,input); + uVar4 = (uint)((sVar3 - 1 & 7) == 0); + mgf_mask(sig + uVar4,((__n - 1) - __n_00) - uVar4,input,__n_00, + (mbedtls_md_context_t *)auStack108); + mbedtls_md_free((mbedtls_md_context_t *)auStack108); + sVar3 = mbedtls_mpi_bitlen(&ctx->N); + *sig = (byte)(0xff >> ((__n * 8 + 1) - sVar3 & 0x1f)) & *sig; + input[__n_00] = -0x44; + if (mode != 0) { + iVar2 = mbedtls_rsa_private(ctx,f_rng,p_rng,sig,sig); + return iVar2; + } + iVar2 = mbedtls_rsa_public(ctx,sig,sig); + return iVar2; + } + mbedtls_md_free((mbedtls_md_context_t *)auStack108); + return iVar2; + } + } + } + return -0x4080; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int mbedtls_rsa_rsassa_pkcs1_v15_sign + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig) + +{ + uint uVar1; + int iVar2; + uint __n; + uchar uVar3; + mbedtls_md_info_t *md_info; + int iVar4; + undefined3 extraout_var; + uchar *output; + uchar *output_00; + byte *pbVar5; + byte *pbVar6; + byte bVar7; + undefined3 in_register_00002039; + size_t sVar8; + uchar diff_no_optimize; + size_t __n_00; + size_t oid_size; + char *oid; + + __n_00 = 0; + oid_size = 0; + if ((mode != 1) || (ctx->padding == 0)) { + uVar1 = ctx->len; + iVar2 = uVar1 - 3; + if (CONCAT31(in_register_00002039,md_alg) != 0) { + md_info = mbedtls_md_info_from_type(md_alg); + if (md_info == (mbedtls_md_info_t *)0x0) { + return -0x4080; + } + iVar4 = mbedtls_oid_get_oid_by_md(md_alg,(char **)&oid_size,(size_t *)&stack0xffffffc8); + if (iVar4 != 0) { + return -0x4080; + } + iVar2 = iVar2 - __n_00; + uVar3 = mbedtls_md_get_size(md_info); + hashlen = CONCAT31(extraout_var,uVar3); + iVar2 = iVar2 + -10; + } + __n = iVar2 - hashlen; + if ((7 < __n) && (__n <= uVar1)) { + *sig = '\0'; + sig[1] = '\x01'; + memset(sig + 2,0xff,__n); + output = sig + 2 + __n; + *output = '\0'; + if (CONCAT31(in_register_00002039,md_alg) == 0) { + output = output + 1; + } + else { + uVar3 = (uchar)__n_00; + output[2] = uVar3 + '\b' + (uchar)hashlen; + output[4] = uVar3 + '\x04'; + output[6] = uVar3; + output[1] = '0'; + output[3] = '0'; + output[5] = '\x06'; + memcpy(output + 7,(void *)oid_size,__n_00); + output = output + 7 + __n_00; + *output = '\x05'; + output[1] = '\0'; + output[2] = '\x04'; + output[3] = (uchar)hashlen; + output = output + 4; + } + memcpy(output,hash,hashlen); + if (mode != 0) { + iVar2 = -0x10; + output = (uchar *)mycalloc(1,ctx->len); + if (output != (uchar *)0x0) { + output_00 = (uchar *)mycalloc(1,ctx->len); + if (output_00 != (uchar *)0x0) { + iVar2 = mbedtls_rsa_private(ctx,f_rng,p_rng,sig,output); + if ((iVar2 == 0) && (iVar2 = mbedtls_rsa_public(ctx,output,output_00), iVar2 == 0)) { + bVar7 = 0; + sVar8 = 0; + while (ctx->len != sVar8) { + pbVar6 = output_00 + sVar8; + pbVar5 = sig + sVar8; + sVar8 = sVar8 + 1; + bVar7 = bVar7 | *pbVar6 ^ *pbVar5; + } + if (bVar7 == 0) { + memcpy(sig,output,ctx->len); + } + else { + iVar2 = -0x4300; + } + } + vPortFree(output); + output = output_00; + } + vPortFree(output); + return iVar2; + } + return -0x10; + } + iVar2 = mbedtls_rsa_public(ctx,sig,sig); + return iVar2; + } + } + return -0x4080; +} + + + +int mbedtls_rsa_pkcs1_sign + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig) + +{ + int iVar1; + + if (ctx->padding == 0) { + iVar1 = mbedtls_rsa_rsassa_pkcs1_v15_sign(ctx,f_rng,p_rng,mode,md_alg,hashlen,hash,sig); + return iVar1; + } + if (ctx->padding != 1) { + return -0x4100; + } + iVar1 = mbedtls_rsa_rsassa_pss_sign(ctx,f_rng,p_rng,mode,md_alg,hashlen,hash,sig); + return iVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +int mbedtls_rsa_rsassa_pss_verify_ext + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash, + mbedtls_md_type_t mgf1_hash_id,int expected_salt_len,uchar *sig) + +{ + uchar *dst; + uchar *puVar1; + uchar uVar2; + int iVar3; + mbedtls_md_info_t *md_info; + undefined3 extraout_var; + uint slen; + size_t sVar4; + undefined3 in_register_00002039; + size_t ilen; + size_t sVar5; + uchar *output; + size_t in_stack_00000000; + uchar *in_stack_00000004; + uchar auStack1124 [4]; + uchar zeros [8]; + mbedtls_md_context_t md_ctx; + uchar result [32]; + uchar buf [1024]; + + if (((mode != 1) || (ctx->padding == 1)) && (ilen = ctx->len, ilen - 0x10 < 0x3f1)) { + output = result + 0x1c; + if (mode == 0) { + iVar3 = mbedtls_rsa_public(ctx,in_stack_00000004,output); + } + else { + iVar3 = mbedtls_rsa_private(ctx,f_rng,p_rng,in_stack_00000004,output); + } + if (iVar3 != 0) { + return iVar3; + } + if (result[ilen + 0x1b] != -0x44) { + return -0x4100; + } + if (CONCAT31(in_register_00002039,md_alg) != 0) { + md_info = mbedtls_md_info_from_type(md_alg); + if (md_info == (mbedtls_md_info_t *)0x0) { + return -0x4080; + } + uVar2 = mbedtls_md_get_size(md_info); + hashlen = CONCAT31(extraout_var,uVar2); + } + md_info = mbedtls_md_info_from_type(mgf1_hash_id); + if (md_info != (mbedtls_md_info_t *)0x0) { + uVar2 = mbedtls_md_get_size(md_info); + slen = CONCAT31(slen._1_3_,uVar2); + memset(auStack1124,0,8); + sVar4 = mbedtls_mpi_bitlen(&ctx->N); + dst = output; + sVar5 = ilen; + if ((sVar4 - 1 & 7) == 0) { + dst = result + 0x1d; + sVar5 = ilen - 1; + } + if ((int)(uint)result[28] >> (sVar5 * -8 + sVar4 + 7 & 0x1f) == 0) { + mbedtls_md_init((mbedtls_md_context_t *)(zeros + 4)); + iVar3 = mbedtls_md_setup((mbedtls_md_context_t *)(zeros + 4),md_info,0); + if (iVar3 != 0) { + mbedtls_md_free((mbedtls_md_context_t *)(zeros + 4)); + return iVar3; + } + mgf_mask(dst,~slen + sVar5,dst + ~slen + sVar5,slen,(mbedtls_md_context_t *)(zeros + 4)); + result[28] = (byte)(0xff >> (sVar5 * 8 - (sVar4 - 1) & 0x1f)) & result[28]; + do { + puVar1 = dst; + if (output + sVar5 <= puVar1) { + if (output + sVar5 == puVar1) goto LAB_23089810; + break; + } + dst = puVar1 + 1; + } while (*puVar1 == '\0'); + dst = puVar1 + 1; + if ((*puVar1 == '\x01') && + ((ilen = ((ilen - 1) - slen) - (int)(dst + -(int)output), in_stack_00000000 == 0xffffffff + || (in_stack_00000000 == ilen)))) { + mbedtls_md_starts((mbedtls_md_context_t *)(zeros + 4)); + mbedtls_md_update((mbedtls_md_context_t *)(zeros + 4),auStack1124,8); + mbedtls_md_update((mbedtls_md_context_t *)(zeros + 4),hash,hashlen); + mbedtls_md_update((mbedtls_md_context_t *)(zeros + 4),dst,ilen); + mbedtls_md_finish((mbedtls_md_context_t *)(zeros + 4),(uchar *)&md_ctx.hmac_ctx); + mbedtls_md_free((mbedtls_md_context_t *)(zeros + 4)); + iVar3 = memcmp(dst + ilen,&md_ctx.hmac_ctx,slen); + if (iVar3 == 0) { + return 0; + } + return -0x4380; + } +LAB_23089810: + mbedtls_md_free((mbedtls_md_context_t *)(zeros + 4)); + return -0x4100; + } + } + } + return -0x4080; +} + + + +int mbedtls_rsa_rsassa_pss_verify + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig) + +{ + int iVar1; + mbedtls_md_type_t mgf1_hash_id; + int in_fa0; + uchar *in_fa1; + + mgf1_hash_id = (mbedtls_md_type_t)ctx->hash_id; + if (ctx->hash_id == 0) { + mgf1_hash_id = md_alg; + } + iVar1 = mbedtls_rsa_rsassa_pss_verify_ext + (ctx,f_rng,p_rng,mode,md_alg,hashlen,hash,mgf1_hash_id,in_fa0,in_fa1); + return iVar1; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +int mbedtls_rsa_rsassa_pkcs1_v15_verify + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig) + +{ + uchar **output; + uint uVar1; + uchar *end; + uchar __n; + int iVar2; + mbedtls_md_info_t *md_info; + undefined3 extraout_var; + undefined3 in_register_00002039; + size_t sVar3; + mbedtls_md_type_t mStack1077; + mbedtls_md_type_t msg_md_alg; + size_t sStack1076; + size_t asn1_len; + uchar *p; + mbedtls_asn1_buf oid; + uchar buf [1024]; + + if ((mode == 1) && (ctx->padding != 0)) { + return -0x4080; + } + sVar3 = ctx->len; + if (sVar3 - 0x10 < 0x3f1) { + output = &oid.p; + if (mode == 0) { + iVar2 = mbedtls_rsa_public(ctx,sig,(uchar *)output); + } + else { + iVar2 = mbedtls_rsa_private(ctx,f_rng,p_rng,sig,(uchar *)output); + } + if (iVar2 != 0) { + return iVar2; + } + if (((char)oid.p != '\0') || (asn1_len = (int)&oid.p + 2, oid.p._1_1_ != '\x01')) { + return -0x4100; + } + while (*(uchar *)asn1_len != '\0') { + if ((uchar *)((int)output + (sVar3 - 1)) <= asn1_len) { + return -0x4100; + } + if (*(uchar *)asn1_len != -1) { + return -0x4100; + } + asn1_len = asn1_len + 1; + } + asn1_len = asn1_len + 1; + uVar1 = sVar3 - (int)((uchar *)asn1_len + -(int)output); + if ((uVar1 == hashlen) && (CONCAT31(in_register_00002039,md_alg) == 0)) { + iVar2 = memcmp((void *)asn1_len,hash,hashlen); + if (iVar2 == 0) { + return 0; + } + } + else { + md_info = mbedtls_md_info_from_type(md_alg); + if (md_info == (mbedtls_md_info_t *)0x0) goto LAB_23089858; + __n = mbedtls_md_get_size(md_info); + ___n = CONCAT31(extraout_var,__n); + end = (uchar *)(asn1_len + uVar1); + iVar2 = mbedtls_asn1_get_tag((uchar **)&asn1_len,end,(size_t *)&stack0xfffffbcc,0x30); + if ((((iVar2 == 0) && (sStack1076 + 2 == uVar1)) && + (iVar2 = mbedtls_asn1_get_tag((uchar **)&asn1_len,end,(size_t *)&stack0xfffffbcc,0x30), + iVar2 == 0)) && + ((sStack1076 + 6 + ___n == uVar1 && + (iVar2 = mbedtls_asn1_get_tag((uchar **)&asn1_len,end,(size_t *)&oid,6), iVar2 == 0)))) { + oid.len = asn1_len; + asn1_len = asn1_len + oid.tag; + iVar2 = mbedtls_oid_get_md_alg((mbedtls_asn1_buf *)&p,&mStack1077); + if (((iVar2 == 0) && + (((uint)mStack1077 == CONCAT31(in_register_00002039,md_alg) && + (iVar2 = mbedtls_asn1_get_tag((uchar **)&asn1_len,end,(size_t *)&stack0xfffffbcc,5), + iVar2 == 0)))) && + ((iVar2 = mbedtls_asn1_get_tag((uchar **)&asn1_len,end,(size_t *)&stack0xfffffbcc,4), + iVar2 == 0 && + (((sStack1076 == ___n && (iVar2 = memcmp((void *)asn1_len,hash,___n), iVar2 == 0)) && + (end == (uchar *)(___n + asn1_len))))))) { + return 0; + } + } + } + iVar2 = -0x4380; + } + else { +LAB_23089858: + iVar2 = -0x4080; + } + return iVar2; +} + + + +int mbedtls_rsa_pkcs1_verify + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig) + +{ + int iVar1; + + if (ctx->padding == 0) { + iVar1 = mbedtls_rsa_rsassa_pkcs1_v15_verify(ctx,f_rng,p_rng,mode,md_alg,hashlen,hash,sig); + return iVar1; + } + if (ctx->padding != 1) { + return -0x4100; + } + iVar1 = mbedtls_rsa_rsassa_pss_verify(ctx,f_rng,p_rng,mode,md_alg,hashlen,hash,sig); + return iVar1; +} + + + +void mbedtls_rsa_free(mbedtls_rsa_context *ctx) + +{ + mbedtls_mpi_free(&ctx->Vi); + mbedtls_mpi_free(&ctx->Vf); + mbedtls_mpi_free(&ctx->RQ); + mbedtls_mpi_free(&ctx->RP); + mbedtls_mpi_free(&ctx->RN); + mbedtls_mpi_free(&ctx->QP); + mbedtls_mpi_free(&ctx->DQ); + mbedtls_mpi_free(&ctx->DP); + mbedtls_mpi_free(&ctx->Q); + mbedtls_mpi_free(&ctx->P); + mbedtls_mpi_free(&ctx->D); + mbedtls_mpi_free(&ctx->E); + mbedtls_mpi_free(&ctx->N); + return; +} + + + +void mbedtls_sha256_init(mbedtls_sha256_context *ctx) + +{ + memset(ctx,0,0x74); + return; +} + + + +void mbedtls_sha256_free(mbedtls_sha256_context *ctx) + +{ + mbedtls_sha256_context *pmVar1; + + pmVar1 = ctx + 1; + if (ctx != (mbedtls_sha256_context *)0x0) { + while (ctx != pmVar1) { + *(undefined *)ctx->total = 0; + ctx = (mbedtls_sha256_context *)((int)ctx->total + 1); + } + } + return; +} + + + +void mbedtls_sha256_clone(mbedtls_sha256_context *dst,mbedtls_sha256_context *src) + +{ + memcpy(dst,src,0x74); + return; +} + + + +void mbedtls_sha256_starts(mbedtls_sha256_context *ctx,int is224) + +{ + uint32_t uVar1; + + ctx->total[0] = 0; + ctx->total[1] = 0; + if (is224 == 0) { + ctx->state[0] = 0x6a09e667; + ctx->state[1] = 0xbb67ae85; + ctx->state[2] = 0x3c6ef372; + ctx->state[3] = 0xa54ff53a; + ctx->state[4] = 0x510e527f; + ctx->state[5] = 0x9b05688c; + ctx->state[6] = 0x1f83d9ab; + uVar1 = 0x5be0cd19; + } + else { + ctx->state[0] = 0xc1059ed8; + ctx->state[1] = 0x367cd507; + ctx->state[2] = 0x3070dd17; + ctx->state[3] = 0xf70e5939; + ctx->state[4] = 0xffc00b31; + ctx->state[5] = 0x68581511; + ctx->state[6] = 0x64f98fa7; + uVar1 = 0xbefa4fa4; + } + ctx->state[7] = uVar1; + ctx->is224 = is224; + return; +} + + + +void mbedtls_sha256_process(mbedtls_sha256_context *ctx,uchar *data) + +{ + uint uVar1; + uint32_t *puVar2; + byte *pbVar3; + byte *pbVar4; + uint uVar5; + uint uVar6; + uint32_t uVar7; + uint uVar8; + uint32_t *puVar9; + uint uVar10; + uint32_t *puVar11; + uint uVar12; + int iVar13; + uint uVar14; + uint uVar15; + uint uVar16; + uint uVar17; + uint32_t *puVar18; + uint uVar19; + uint uVar20; + uint uVar21; + uint32_t *puVar22; + uint uVar23; + uint32_t uVar24; + uint uVar25; + uint32_t *puVar26; + uint32_t uVar27; + uint32_t local_150; + uint32_t A [8]; + uint32_t W [64]; + + puVar18 = &local_150; + puVar9 = &local_150; + puVar11 = ctx->state; + do { + uVar7 = *puVar11; + puVar11 = puVar11 + 1; + *puVar9 = uVar7; + puVar9 = puVar9 + 1; + } while ((uint32_t *)ctx->buffer != puVar11); + puVar11 = A + 7; + pbVar3 = data; + puVar9 = puVar11; + do { + pbVar4 = pbVar3 + 4; + *puVar9 = (uint)*pbVar3 << 0x18 | (uint)pbVar3[1] << 0x10 | (uint)pbVar3[3] | + (uint)pbVar3[2] << 8; + pbVar3 = pbVar4; + puVar9 = puVar9 + 1; + } while (data + 0x40 != pbVar4); + puVar2 = K; + puVar9 = K; + puVar26 = puVar11; + do { + puVar22 = puVar9 + 8; + iVar13 = A[6] + ((A[3] >> 6 | A[3] << 0x1a) ^ (A[3] >> 0xb | A[3] << 0x15) ^ + (A[3] << 7 | A[3] >> 0x19)) + *puVar9 + *puVar26 + ((A[5] ^ A[4]) & A[3] ^ A[5]) + ; + uVar12 = A[2] + iVar13; + uVar14 = iVar13 + ((local_150 >> 2 | local_150 << 0x1e) ^ (local_150 >> 0xd | local_150 << 0x13) + ^ (local_150 << 10 | local_150 >> 0x16)) + + ((local_150 | A[0]) & A[1] | local_150 & A[0]); + iVar13 = ((uVar12 >> 6 | uVar12 * 0x4000000) ^ (uVar12 >> 0xb | uVar12 * 0x200000) ^ + (uVar12 * 0x80 | uVar12 >> 0x19)) + + A[5] + puVar9[1] + puVar26[1] + ((A[3] ^ A[4]) & uVar12 ^ A[4]); + uVar1 = ((uVar14 >> 2 | uVar14 * 0x40000000) ^ (uVar14 >> 0xd | uVar14 * 0x80000) ^ + (uVar14 * 0x400 | uVar14 >> 0x16)) + ((uVar14 | local_150) & A[0] | uVar14 & local_150) + + iVar13; + uVar10 = A[1] + iVar13; + iVar13 = ((uVar10 >> 6 | uVar10 * 0x4000000) ^ (uVar10 >> 0xb | uVar10 * 0x200000) ^ + (uVar10 * 0x80 | uVar10 >> 0x19)) + + A[4] + puVar9[2] + puVar26[2] + ((uVar12 ^ A[3]) & uVar10 ^ A[3]); + uVar5 = ((uVar1 >> 2 | uVar1 * 0x40000000) ^ (uVar1 >> 0xd | uVar1 * 0x80000) ^ + (uVar1 * 0x400 | uVar1 >> 0x16)) + ((uVar14 | uVar1) & local_150 | uVar14 & uVar1) + + iVar13; + uVar8 = A[0] + iVar13; + iVar13 = ((uVar8 >> 6 | uVar8 * 0x4000000) ^ (uVar8 >> 0xb | uVar8 * 0x200000) ^ + (uVar8 * 0x80 | uVar8 >> 0x19)) + + A[3] + puVar9[3] + puVar26[3] + ((uVar12 ^ uVar10) & uVar8 ^ uVar12); + uVar16 = ((uVar5 >> 2 | uVar5 * 0x40000000) ^ (uVar5 >> 0xd | uVar5 * 0x80000) ^ + (uVar5 * 0x400 | uVar5 >> 0x16)) + ((uVar1 | uVar5) & uVar14 | uVar1 & uVar5) + iVar13; + uVar6 = local_150 + iVar13; + iVar13 = ((uVar6 >> 6 | uVar6 * 0x4000000) ^ (uVar6 >> 0xb | uVar6 * 0x200000) ^ + (uVar6 * 0x80 | uVar6 >> 0x19)) + + uVar12 + puVar9[4] + puVar26[4] + ((uVar10 ^ uVar8) & uVar6 ^ uVar10); + A[2] = ((uVar16 >> 2 | uVar16 * 0x40000000) ^ (uVar16 >> 0xd | uVar16 * 0x80000) ^ + (uVar16 * 0x400 | uVar16 >> 0x16)) + ((uVar5 | uVar16) & uVar1 | uVar5 & uVar16) + iVar13 + ; + A[6] = uVar14 + iVar13; + iVar13 = ((A[6] >> 6 | A[6] * 0x4000000) ^ (A[6] >> 0xb | A[6] * 0x200000) ^ + (A[6] * 0x80 | A[6] >> 0x19)) + + uVar10 + puVar9[5] + puVar26[5] + ((uVar8 ^ uVar6) & A[6] ^ uVar8); + A[1] = ((A[2] >> 2 | A[2] * 0x40000000) ^ (A[2] >> 0xd | A[2] * 0x80000) ^ + (A[2] * 0x400 | A[2] >> 0x16)) + ((uVar16 | A[2]) & uVar5 | uVar16 & A[2]) + iVar13; + A[5] = uVar1 + iVar13; + iVar13 = ((A[5] >> 6 | A[5] * 0x4000000) ^ (A[5] >> 0xb | A[5] * 0x200000) ^ + (A[5] * 0x80 | A[5] >> 0x19)) + + uVar8 + puVar9[6] + puVar26[6] + ((uVar6 ^ A[6]) & A[5] ^ uVar6); + A[0] = ((A[1] >> 2 | A[1] * 0x40000000) ^ (A[1] >> 0xd | A[1] * 0x80000) ^ + (A[1] * 0x400 | A[1] >> 0x16)) + ((A[2] | A[1]) & uVar16 | A[2] & A[1]) + iVar13; + A[4] = uVar5 + iVar13; + iVar13 = ((A[4] >> 6 | A[4] * 0x4000000) ^ (A[4] >> 0xb | A[4] * 0x200000) ^ + (A[4] * 0x80 | A[4] >> 0x19)) + + uVar6 + puVar9[7] + puVar26[7] + ((A[6] ^ A[5]) & A[4] ^ A[6]); + A[3] = uVar16 + iVar13; + local_150 = ((A[0] >> 2 | A[0] * 0x40000000) ^ (A[0] >> 0xd | A[0] * 0x80000) ^ + (A[0] * 0x400 | A[0] >> 0x16)) + ((A[1] | A[0]) & A[2] | A[1] & A[0]) + iVar13; + puVar9 = puVar22; + puVar26 = puVar26 + 8; + } while (puVar22 != K + 0x10); + do { + uVar19 = puVar11[0xe]; + uVar1 = puVar11[1]; + uVar20 = puVar11[0xf]; + uVar23 = ((uVar19 << 0xf | uVar19 >> 0x11) ^ (uVar19 << 0xd | uVar19 >> 0x13) ^ uVar19 >> 10) + + puVar11[9] + *puVar11 + + ((uVar1 >> 7 | uVar1 << 0x19) ^ (uVar1 << 0xe | uVar1 >> 0x12) ^ uVar1 >> 3); + uVar10 = puVar11[3]; + iVar13 = A[6] + ((A[3] >> 6 | A[3] << 0x1a) ^ (A[3] >> 0xb | A[3] << 0x15) ^ + (A[3] << 7 | A[3] >> 0x19)) + ((A[5] ^ A[4]) & A[3] ^ A[5]) + puVar2[0x10] + + uVar23; + uVar16 = A[2] + iVar13; + uVar15 = iVar13 + ((local_150 >> 2 | local_150 << 0x1e) ^ (local_150 >> 0xd | local_150 << 0x13) + ^ (local_150 << 10 | local_150 >> 0x16)) + + ((local_150 | A[0]) & A[1] | local_150 & A[0]); + uVar6 = puVar11[2]; + uVar1 = ((uVar20 << 0xf | uVar20 >> 0x11) ^ (uVar20 << 0xd | uVar20 >> 0x13) ^ uVar20 >> 10) + + uVar1 + puVar11[10] + + ((uVar6 >> 7 | uVar6 << 0x19) ^ (uVar6 << 0xe | uVar6 >> 0x12) ^ uVar6 >> 3); + iVar13 = ((A[3] ^ A[4]) & uVar16 ^ A[4]) + A[5] + puVar2[0x11] + uVar1 + + ((uVar16 >> 6 | uVar16 * 0x4000000) ^ (uVar16 >> 0xb | uVar16 * 0x200000) ^ + (uVar16 * 0x80 | uVar16 >> 0x19)); + uVar5 = ((uVar15 >> 2 | uVar15 * 0x40000000) ^ (uVar15 >> 0xd | uVar15 * 0x80000) ^ + (uVar15 * 0x400 | uVar15 >> 0x16)) + ((local_150 | uVar15) & A[0] | local_150 & uVar15) + + iVar13; + uVar14 = A[1] + iVar13; + uVar6 = ((uVar23 * 0x8000 | uVar23 >> 0x11) ^ (uVar23 * 0x2000 | uVar23 >> 0x13) ^ uVar23 >> 10) + + uVar6 + puVar11[0xb] + + ((uVar10 >> 7 | uVar10 << 0x19) ^ (uVar10 << 0xe | uVar10 >> 0x12) ^ uVar10 >> 3); + iVar13 = ((A[3] ^ uVar16) & uVar14 ^ A[3]) + A[4] + puVar2[0x12] + uVar6 + + ((uVar14 >> 6 | uVar14 * 0x4000000) ^ (uVar14 >> 0xb | uVar14 * 0x200000) ^ + (uVar14 * 0x80 | uVar14 >> 0x19)); + puVar11[0x11] = uVar1; + uVar8 = ((uVar5 >> 2 | uVar5 * 0x40000000) ^ (uVar5 >> 0xd | uVar5 * 0x80000) ^ + (uVar5 * 0x400 | uVar5 >> 0x16)) + ((uVar15 | uVar5) & local_150 | uVar15 & uVar5) + + iVar13; + uVar12 = A[0] + iVar13; + uVar25 = puVar11[4]; + uVar1 = ((uVar1 * 0x8000 | uVar1 >> 0x11) ^ (uVar1 * 0x2000 | uVar1 >> 0x13) ^ uVar1 >> 10) + + uVar10 + puVar11[0xc] + + ((uVar25 >> 7 | uVar25 << 0x19) ^ (uVar25 << 0xe | uVar25 >> 0x12) ^ uVar25 >> 3); + iVar13 = ((uVar16 ^ uVar14) & uVar12 ^ uVar16) + A[3] + puVar2[0x13] + uVar1 + + ((uVar12 >> 6 | uVar12 * 0x4000000) ^ (uVar12 >> 0xb | uVar12 * 0x200000) ^ + (uVar12 * 0x80 | uVar12 >> 0x19)); + uVar17 = ((uVar8 >> 2 | uVar8 * 0x40000000) ^ (uVar8 >> 0xd | uVar8 * 0x80000) ^ + (uVar8 * 0x400 | uVar8 >> 0x16)) + ((uVar5 | uVar8) & uVar15 | uVar5 & uVar8) + iVar13; + uVar10 = local_150 + iVar13; + puVar11[0x12] = uVar6; + uVar21 = puVar11[5]; + uVar25 = ((uVar6 * 0x8000 | uVar6 >> 0x11) ^ (uVar6 * 0x2000 | uVar6 >> 0x13) ^ uVar6 >> 10) + + uVar25 + puVar11[0xd] + + ((uVar21 >> 7 | uVar21 << 0x19) ^ (uVar21 << 0xe | uVar21 >> 0x12) ^ uVar21 >> 3); + iVar13 = ((uVar10 >> 6 | uVar10 * 0x4000000) ^ (uVar10 >> 0xb | uVar10 * 0x200000) ^ + (uVar10 * 0x80 | uVar10 >> 0x19)) + + ((uVar14 ^ uVar12) & uVar10 ^ uVar14) + uVar16 + puVar2[0x14] + uVar25; + A[2] = ((uVar17 >> 2 | uVar17 * 0x40000000) ^ (uVar17 >> 0xd | uVar17 * 0x80000) ^ + (uVar17 * 0x400 | uVar17 >> 0x16)) + ((uVar8 | uVar17) & uVar5 | uVar8 & uVar17) + iVar13 + ; + A[6] = uVar15 + iVar13; + uVar6 = puVar11[6]; + puVar11[0x13] = uVar1; + uVar16 = ((uVar1 * 0x8000 | uVar1 >> 0x11) ^ (uVar1 * 0x2000 | uVar1 >> 0x13) ^ uVar1 >> 10) + + uVar19 + uVar21 + + ((uVar6 >> 7 | uVar6 << 0x19) ^ (uVar6 << 0xe | uVar6 >> 0x12) ^ uVar6 >> 3); + iVar13 = ((A[6] >> 6 | A[6] * 0x4000000) ^ (A[6] >> 0xb | A[6] * 0x200000) ^ + (A[6] * 0x80 | A[6] >> 0x19)) + + ((uVar12 ^ uVar10) & A[6] ^ uVar12) + uVar14 + puVar2[0x15] + uVar16; + A[1] = ((A[2] >> 2 | A[2] * 0x40000000) ^ (A[2] >> 0xd | A[2] * 0x80000) ^ + (A[2] * 0x400 | A[2] >> 0x16)) + ((uVar17 | A[2]) & uVar8 | uVar17 & A[2]) + iVar13; + A[5] = uVar5 + iVar13; + uVar1 = puVar11[7]; + puVar11[0x14] = uVar25; + uVar7 = uVar20 + uVar6 + + ((uVar25 * 0x8000 | uVar25 >> 0x11) ^ (uVar25 * 0x2000 | uVar25 >> 0x13) ^ uVar25 >> 10) + + ((uVar1 >> 7 | uVar1 << 0x19) ^ (uVar1 << 0xe | uVar1 >> 0x12) ^ uVar1 >> 3); + iVar13 = ((A[5] >> 6 | A[5] * 0x4000000) ^ (A[5] >> 0xb | A[5] * 0x200000) ^ + (A[5] * 0x80 | A[5] >> 0x19)) + + ((uVar10 ^ A[6]) & A[5] ^ uVar10) + uVar12 + puVar2[0x16] + uVar7; + A[0] = ((A[1] >> 2 | A[1] * 0x40000000) ^ (A[1] >> 0xd | A[1] * 0x80000) ^ + (A[1] * 0x400 | A[1] >> 0x16)) + ((A[2] | A[1]) & uVar17 | A[2] & A[1]) + iVar13; + A[4] = uVar8 + iVar13; + uVar5 = puVar11[8]; + puVar11[0x15] = uVar16; + puVar11[0x10] = uVar23; + uVar27 = puVar2[0x17]; + uVar24 = uVar23 + uVar1 + + ((uVar16 * 0x8000 | uVar16 >> 0x11) ^ (uVar16 * 0x2000 | uVar16 >> 0x13) ^ uVar16 >> 10 + ) + ((uVar5 >> 7 | uVar5 << 0x19) ^ (uVar5 << 0xe | uVar5 >> 0x12) ^ uVar5 >> 3); + puVar11[0x17] = uVar24; + iVar13 = ((A[4] >> 6 | A[4] * 0x4000000) ^ (A[4] >> 0xb | A[4] * 0x200000) ^ + (A[4] * 0x80 | A[4] >> 0x19)) + + uVar10 + uVar27 + uVar24 + ((A[6] ^ A[5]) & A[4] ^ A[6]); + puVar11[0x16] = uVar7; + puVar11 = puVar11 + 8; + A[3] = uVar17 + iVar13; + local_150 = ((A[0] >> 2 | A[0] * 0x40000000) ^ (A[0] >> 0xd | A[0] * 0x80000) ^ + (A[0] * 0x400 | A[0] >> 0x16)) + ((A[1] | A[0]) & A[2] | A[1] & A[0]) + iVar13; + puVar2 = puVar2 + 8; + } while (W + 0x2f != puVar11); + puVar9 = ctx->state; + do { + iVar13 = *puVar18; + puVar11 = puVar9 + 1; + puVar18 = (uint32_t *)((int *)puVar18 + 1); + *puVar9 = *puVar9 + iVar13; + puVar9 = puVar11; + } while ((uint32_t *)ctx->buffer != puVar11); + return; +} + + + +void mbedtls_sha256_update(mbedtls_sha256_context *ctx,uchar *input,size_t ilen) + +{ + size_t __n; + uint uVar1; + uint uVar2; + uint __n_00; + + uVar2 = ctx->total[0] & 0x3f; + uVar1 = ctx->total[0] + ilen; + ctx->total[0] = uVar1; + if (uVar1 < ilen) { + ctx->total[1] = ctx->total[1] + 1; + } + uVar1 = ilen; + if ((uVar2 != 0) && (__n_00 = 0x40 - uVar2, __n_00 <= ilen)) { + memcpy(ctx->buffer + uVar2,input,__n_00); + ilen = (ilen - 0x40) + uVar2; + mbedtls_sha256_process(ctx,ctx->buffer); + input = input + __n_00; + uVar2 = 0; + uVar1 = ilen; + } + while (0x3f < ilen) { + mbedtls_sha256_process(ctx,input + (uVar1 - ilen)); + ilen = ilen - 0x40; + } + __n = (uVar1 >> 6) * -0x40 + uVar1; + if (__n == 0) { + return; + } + memcpy(ctx->buffer + uVar2,input + (uVar1 & 0xffffffc0),__n); + return; +} + + + +void mbedtls_sha256_update(mbedtls_sha256_context *ctx,uchar *input,size_t ilen) + +{ + if (ilen != 0) { + mbedtls_sha256_update(ctx,input,ilen); + return; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void mbedtls_sha256_finish(mbedtls_sha256_context *ctx,uchar *output) + +{ + uint uVar1; + uint uVar2; + int iVar3; + uchar uStack24; + undefined uStack23; + ushort uStack22; + uchar msglen [8]; + + uVar1 = ctx->total[0]; + uVar2 = ctx->total[1] << 3; + uStack24 = (uchar)(uVar2 >> 0x18); + uStack23 = (undefined)(uVar2 >> 0x10); + uStack22 = (ushort)(uVar2 >> 8) & 0xff | (ushort)((uVar2 | uVar1 >> 0x1d) << 8); + msglen[0] = (uchar)((uVar1 << 3) >> 0x18); + msglen[1] = (uchar)((uVar1 << 3) >> 0x10); + msglen._2_2_ = (ushort)((uVar1 << 0x13) >> 0x18) | (ushort)(uVar1 << 0xb); + if ((uVar1 & 0x3f) < 0x38) { + iVar3 = 0x38; + } + else { + iVar3 = 0x78; + } + mbedtls_sha256_update(ctx,sha256_padding,iVar3 - (uVar1 & 0x3f)); + mbedtls_sha256_update(ctx,&uStack24,8); + *output = *(uchar *)((int)ctx->state + 3); + output[1] = (uchar)*(undefined2 *)((int)ctx->state + 2); + output[2] = (uchar)(ctx->state[0] >> 8); + output[3] = (uchar)ctx->state[0]; + output[4] = *(uchar *)((int)ctx->state + 7); + output[5] = (uchar)*(undefined2 *)((int)ctx->state + 6); + output[6] = (uchar)(ctx->state[1] >> 8); + output[7] = (uchar)ctx->state[1]; + output[8] = *(uchar *)((int)ctx->state + 0xb); + output[9] = (uchar)*(undefined2 *)((int)ctx->state + 10); + output[10] = (uchar)(ctx->state[2] >> 8); + output[0xb] = (uchar)ctx->state[2]; + output[0xc] = *(uchar *)((int)ctx->state + 0xf); + output[0xd] = (uchar)*(undefined2 *)((int)ctx->state + 0xe); + output[0xe] = (uchar)(ctx->state[3] >> 8); + output[0xf] = (uchar)ctx->state[3]; + output[0x10] = *(uchar *)((int)ctx->state + 0x13); + output[0x11] = (uchar)*(undefined2 *)((int)ctx->state + 0x12); + output[0x12] = (uchar)(ctx->state[4] >> 8); + output[0x13] = (uchar)ctx->state[4]; + output[0x14] = *(uchar *)((int)ctx->state + 0x17); + output[0x15] = (uchar)*(undefined2 *)((int)ctx->state + 0x16); + output[0x16] = (uchar)(ctx->state[5] >> 8); + output[0x17] = (uchar)ctx->state[5]; + output[0x18] = *(uchar *)((int)ctx->state + 0x1b); + output[0x19] = (uchar)*(undefined2 *)((int)ctx->state + 0x1a); + output[0x1a] = (uchar)(ctx->state[6] >> 8); + output[0x1b] = (uchar)ctx->state[6]; + if (ctx->is224 == 0) { + output[0x1c] = *(uchar *)((int)ctx->state + 0x1f); + output[0x1d] = (uchar)*(undefined2 *)((int)ctx->state + 0x1e); + output[0x1e] = (uchar)(ctx->state[7] >> 8); + output[0x1f] = (uchar)ctx->state[7]; + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: ctx + +void mbedtls_sha256(uchar *input,size_t ilen,uchar *output,int is224) + +{ + undefined auStack132 [4]; + mbedtls_sha256_context ctx; + + mbedtls_sha256_init((mbedtls_sha256_context *)auStack132); + mbedtls_sha256_starts((mbedtls_sha256_context *)auStack132,is224); + mbedtls_sha256_update((mbedtls_sha256_context *)auStack132,input,ilen); + mbedtls_sha256_finish((mbedtls_sha256_context *)auStack132,output); + mbedtls_sha256_free((mbedtls_sha256_context *)auStack132); + return; +} + + + +mbedtls_x509_crt * mbedtls_ssl_own_cert(mbedtls_ssl_context *ssl) + +{ + mbedtls_x509_crt *pmVar1; + + if (((ssl->handshake != (mbedtls_ssl_handshake_params *)0x0) && + (pmVar1 = (mbedtls_x509_crt *)ssl->handshake->key_cert, pmVar1 != (mbedtls_x509_crt *)0x0)) || + (pmVar1 = (mbedtls_x509_crt *)ssl->conf->key_cert, pmVar1 != (mbedtls_x509_crt *)0x0)) { + pmVar1 = (mbedtls_x509_crt *)(pmVar1->raw).tag; + } + return pmVar1; +} + + + +void mbedtls_zeroize(void *v,size_t n) + +{ + undefined *puVar1; + + puVar1 = (undefined *)(n + (int)v); + while ((undefined *)v != puVar1) { + *(undefined *)v = 0; + v = (undefined *)v + 1; + } + return; +} + + + +void ssl_swap_epochs(mbedtls_ssl_context *ssl) + +{ + mbedtls_ssl_transform *pmVar1; + uchar *puVar2; + undefined auStack24 [4]; + uchar tmp_out_ctr [8]; + + if (ssl->transform_out == ssl->handshake->alt_transform_out) { + mbedtls_debug_print_msg(ssl,3,"file1",0xa0a,"skip swap epochs"); + } + else { + mbedtls_debug_print_msg(ssl,3,"file1",0xa0e,"swap epochs"); + pmVar1 = ssl->transform_out; + ssl->transform_out = ssl->handshake->alt_transform_out; + ssl->handshake->alt_transform_out = pmVar1; + memcpy(auStack24,ssl->out_ctr,8); + memcpy(ssl->out_ctr,ssl->handshake->alt_out_ctr,8); + memcpy(ssl->handshake->alt_out_ctr,auStack24,8); + pmVar1 = ssl->transform_out; + puVar2 = ssl->out_iv; + if ((pmVar1 != (mbedtls_ssl_transform *)0x0) && (1 < ssl->minor_ver)) { + puVar2 = puVar2 + (pmVar1->ivlen - pmVar1->fixed_ivlen); + } + ssl->out_msg = puVar2; + } + return; +} + + + +void ssl_calc_finished_tls_sha256(mbedtls_ssl_context *ssl,uchar *buf,int from) + +{ + mbedtls_ssl_session *pmVar1; + char *pcVar2; + uchar auStack180 [4]; + uchar padbuf [32]; + mbedtls_sha256_context sha256; + + pmVar1 = ssl->session_negotiate; + if (pmVar1 == (mbedtls_ssl_session *)0x0) { + pmVar1 = ssl->session; + } + mbedtls_sha256_init((mbedtls_sha256_context *)(padbuf + 0x1c)); + mbedtls_debug_print_msg(ssl,2,"file1",0x1356,"=> calc finished tls sha256"); + mbedtls_sha256_clone((mbedtls_sha256_context *)(padbuf + 0x1c),&ssl->handshake->fin_sha256); + mbedtls_debug_print_buf + (ssl,4,"file1",0x1362,"finished sha2 state",(uchar *)(sha256.total + 1),0x20); + if (from == 0) { + pcVar2 = "client finished"; + } + else { + pcVar2 = "server finished"; + } + mbedtls_sha256_finish((mbedtls_sha256_context *)(padbuf + 0x1c),auStack180); + (*ssl->handshake->tls_prf)(pmVar1->master,0x30,pcVar2,auStack180,0x20,buf,0xc); + mbedtls_debug_print_buf(ssl,3,"file1",0x136e,"calc finished result",buf,0xc); + mbedtls_sha256_free((mbedtls_sha256_context *)(padbuf + 0x1c)); + mbedtls_zeroize(auStack180,0x20); + mbedtls_debug_print_msg(ssl,2,"file1",0x1374,"<= calc finished"); + return; +} + + + +// WARNING: Variable defined which should be unmapped: sha256 + +void ssl_calc_verify_tls_sha256(mbedtls_ssl_context *ssl,uchar *hash) + +{ + undefined auStack132 [4]; + mbedtls_sha256_context sha256; + + mbedtls_sha256_init((mbedtls_sha256_context *)auStack132); + mbedtls_debug_print_msg(ssl,2,"file1",0x42d,"=> calc verify sha256"); + mbedtls_sha256_clone((mbedtls_sha256_context *)auStack132,&ssl->handshake->fin_sha256); + mbedtls_sha256_finish((mbedtls_sha256_context *)auStack132,hash); + mbedtls_debug_print_buf(ssl,3,"file1",0x432,"calculated verify result",hash,0x20); + mbedtls_debug_print_msg(ssl,2,"file1",0x433,"<= calc verify"); + mbedtls_sha256_free((mbedtls_sha256_context *)auStack132); + return; +} + + + +void ssl_flight_free(mbedtls_ssl_flight_item *flight) + +{ + mbedtls_ssl_flight_item *pmVar1; + + while (flight != (mbedtls_ssl_flight_item *)0x0) { + pmVar1 = flight->next; + vPortFree(flight->p); + vPortFree(flight); + flight = pmVar1; + } + return; +} + + + +int ssl_append_key_cert(mbedtls_ssl_key_cert **head,mbedtls_x509_crt *cert,mbedtls_pk_context *key) + +{ + mbedtls_ssl_key_cert *pmVar1; + int iVar2; + mbedtls_ssl_key_cert *pmVar3; + mbedtls_ssl_key_cert *pmVar4; + + pmVar1 = (mbedtls_ssl_key_cert *)mycalloc(1,0xc); + if (pmVar1 == (mbedtls_ssl_key_cert *)0x0) { + iVar2 = -0x7f00; + } + else { + pmVar1->cert = cert; + pmVar1->next = (mbedtls_ssl_key_cert *)0x0; + pmVar1->key = key; + pmVar3 = *head; + if (*head == (mbedtls_ssl_key_cert *)0x0) { + *head = pmVar1; + } + else { + do { + pmVar4 = pmVar3; + pmVar3 = pmVar4->next; + } while (pmVar3 != (mbedtls_ssl_key_cert *)0x0); + pmVar4->next = pmVar1; + } + iVar2 = 0; + } + return iVar2; +} + + + +void ssl_update_checksum_start(mbedtls_ssl_context *ssl,uchar *buf,size_t len) + +{ + mbedtls_sha256_update(&ssl->handshake->fin_sha256,buf,len); + return; +} + + + +void ssl_update_checksum_sha256(mbedtls_ssl_context *ssl,uchar *buf,size_t len) + +{ + mbedtls_sha256_update(&ssl->handshake->fin_sha256,buf,len); + return; +} + + + +size_t mbedtls_ssl_hdr_len(void) + +{ + int in_a0; + + if ((*(ushort *)(in_a0 + 0x74) & 2) != 0) { + return 0xd; + } + return 5; +} + + + +void ssl_set_timer(mbedtls_ssl_context *ssl,uint32_t millisecs) + +{ + if (ssl->f_set_timer != (mbedtls_ssl_set_timer_t_conflict1 *)0x0) { + mbedtls_debug_print_msg(ssl,3,"file1",0x52,"set_timer to %d ms",millisecs); + // WARNING: Could not recover jumptable at 0x2308ad5e. Too many branches + // WARNING: Treating indirect jump as call + (*ssl->f_set_timer)(ssl->p_timer,millisecs >> 2,millisecs); + return; + } + return; +} + + + +int ssl_check_timer(mbedtls_ssl_context *ssl) + +{ + int iVar1; + + if (ssl->f_get_timer == (mbedtls_ssl_get_timer_t *)0x0) { + return 0; + } + iVar1 = (*ssl->f_get_timer)(ssl->p_timer); + if (iVar1 == 2) { + mbedtls_debug_print_msg(ssl,3,"file1",0x60,"timer expired"); + iVar1 = -1; + } + else { + iVar1 = 0; + } + return iVar1; +} + + + +// WARNING: Variable defined which should be unmapped: tmp + +int tls_prf_sha256(uchar *secret,size_t slen,char *label,uchar *random,size_t rlen,uchar *dstbuf, + size_t dlen) + +{ + int iVar1; + uint uVar2; + uchar ilen; + mbedtls_md_info_t *md_info; + undefined3 extraout_var; + size_t __n; + int iVar3; + uchar *puVar4; + size_t sVar5; + size_t sVar6; + uint uVar7; + undefined auStack220 [4]; + mbedtls_md_context_t md_ctx; + uchar h_i [32]; + uchar tmp [128]; + + mbedtls_md_init((mbedtls_md_context_t *)auStack220); + md_info = mbedtls_md_info_from_type(MBEDTLS_MD_SHA256); + if (md_info == (mbedtls_md_info_t *)0x0) { + iVar3 = -0x6c00; + } + else { + ilen = mbedtls_md_get_size(md_info); + _ilen = CONCAT31(extraout_var,ilen); + __n = strlen(label); + if (__n + rlen + _ilen < 0x81) { + __n = strlen(label); + memcpy(h_i + _ilen + 0x1c,label,__n); + memcpy(h_i + _ilen + __n + 0x1c,random,rlen); + iVar3 = mbedtls_md_setup((mbedtls_md_context_t *)auStack220,md_info,1); + if (iVar3 == 0) { + mbedtls_md_hmac_starts((mbedtls_md_context_t *)auStack220,secret,slen); + mbedtls_md_hmac_update((mbedtls_md_context_t *)auStack220,h_i + _ilen + 0x1c,rlen + __n); + mbedtls_md_hmac_finish((mbedtls_md_context_t *)auStack220,h_i + 0x1c); + uVar2 = 0; + while (uVar7 = uVar2, uVar7 < dlen) { + mbedtls_md_hmac_reset((mbedtls_md_context_t *)auStack220); + mbedtls_md_hmac_update((mbedtls_md_context_t *)auStack220,h_i + 0x1c,rlen + __n + _ilen); + mbedtls_md_hmac_finish((mbedtls_md_context_t *)auStack220,(uchar *)&md_ctx.hmac_ctx); + mbedtls_md_hmac_reset((mbedtls_md_context_t *)auStack220); + mbedtls_md_hmac_update((mbedtls_md_context_t *)auStack220,h_i + 0x1c,_ilen); + mbedtls_md_hmac_finish((mbedtls_md_context_t *)auStack220,h_i + 0x1c); + sVar5 = _ilen; + if (dlen < _ilen + uVar7) { + sVar5 = dlen % _ilen; + } + sVar6 = 0; + while (uVar2 = _ilen + uVar7, sVar6 != sVar5) { + puVar4 = (uchar *)((int)&md_ctx.hmac_ctx + sVar6); + iVar1 = sVar6 + uVar7; + sVar6 = sVar6 + 1; + dstbuf[iVar1] = *puVar4; + } + } + mbedtls_md_free((mbedtls_md_context_t *)auStack220); + mbedtls_zeroize(h_i + 0x1c,0x80); + mbedtls_zeroize(&md_ctx.hmac_ctx,0x20); + } + } + else { + iVar3 = -0x7100; + } + } + return iVar3; +} + + + +int mbedtls_ssl_derive_keys(mbedtls_ssl_context *ssl) + +{ + mbedtls_cipher_type_t mVar1; + size_t __n; + mbedtls_ssl_transform *pmVar2; + mbedtls_cipher_context_t *ctx; + uchar uVar3; + mbedtls_cipher_info_t *cipher_info; + mbedtls_md_info_t *md_info; + undefined3 extraout_var; + size_t sVar4; + uint uVar5; + int line; + int line_00; + char *text; + size_t sVar6; + mbedtls_ssl_handshake_params *pmVar7; + uchar *buf; + uchar *buf_00; + mbedtls_cipher_context_t *ctx_00; + uchar *buf_01; + uchar *key; + mbedtls_ssl_session *pmVar8; + undefined auStack384 [4]; + uchar tmp [64]; + uchar keyblk [256]; + + pmVar2 = ssl->transform_negotiate; + pmVar8 = ssl->session_negotiate; + pmVar7 = ssl->handshake; + mbedtls_debug_print_msg(ssl,2,"file1",0x1f5,"=> derive keys"); + cipher_info = mbedtls_cipher_info_from_type(pmVar2->ciphersuite_info->cipher); + if (cipher_info == (mbedtls_cipher_info_t *)0x0) { + mVar1 = pmVar2->ciphersuite_info->cipher; + text = "cipher info for %d not found"; + line = 0x1fb; +LAB_2308af72: + mbedtls_debug_print_msg(ssl,1,"file1",line,text,(uint)mVar1); + return -0x7100; + } + md_info = mbedtls_md_info_from_type(pmVar2->ciphersuite_info->mac); + if (md_info == (mbedtls_md_info_t *)0x0) { + text = "mbedtls_md info for %d not found"; + mVar1 = pmVar2->ciphersuite_info->mac; + line = 0x203; + goto LAB_2308af72; + } + if (ssl->minor_ver != 3) { + line = 0x232; + goto LAB_2308b048; + } + pmVar7->tls_prf = tls_prf_sha256; + pmVar7->calc_verify = ssl_calc_verify_tls_sha256; + pmVar7->calc_finished = ssl_calc_finished_tls_sha256; + buf_01 = pmVar7->randbytes; + buf = pmVar8->master; + if (pmVar7->resume == 0) { + buf_00 = pmVar7->premaster; + mbedtls_debug_print_buf(ssl,3,"file1",0x243,"premaster secret",buf_00,pmVar7->pmslen); + line = (*pmVar7->tls_prf)(buf_00,pmVar7->pmslen,"master secret",buf_01,0x40,buf,0x30); + if (line != 0) { + text = "prf"; + line_00 = 0x275; + goto LAB_2308b0b0; + } + mbedtls_zeroize(buf_00,0x30); + } + else { + mbedtls_debug_print_msg(ssl,3,"file1",0x27c,"no premaster (session resumed)"); + } + memcpy(auStack384,buf_01,0x40); + memcpy(buf_01,tmp + 0x1c,0x20); + memcpy(pmVar7->randbytes + 0x20,auStack384,0x20); + mbedtls_zeroize(auStack384,0x40); + line = (*pmVar7->tls_prf)(buf,0x30,"key expansion",buf_01,0x40,tmp + 0x3c,0x100); + if (line != 0) { + text = "prf"; + line_00 = 0x296; + goto LAB_2308b0b0; + } + text = mbedtls_ssl_get_ciphersuite_name(pmVar8->ciphersuite); + mbedtls_debug_print_msg(ssl,3,"file1",0x29b,"ciphersuite = %s",text); + mbedtls_debug_print_buf(ssl,3,"file1",0x29c,"master secret",buf,0x30); + mbedtls_debug_print_buf(ssl,4,"file1",0x29d,"random bytes",buf_01,0x40); + mbedtls_debug_print_buf(ssl,4,"file1",0x29e,"key block",tmp + 0x3c,0x100); + mbedtls_zeroize(buf_01,0x40); + pmVar2->keylen = cipher_info->key_bitlen >> 3; + if ((cipher_info->mode + ~MBEDTLS_MODE_CTR & 0xfd) == 0) { + pmVar2->ivlen = 0xc; + pmVar2->fixed_ivlen = 4; + pmVar2->maclen = 0; + line = 8; + if ((pmVar2->ciphersuite_info->flags & 2) == 0) { + line = 0x10; + } + sVar6 = line + 8; +LAB_2308b1e2: + pmVar2->minlen = sVar6; + } + else { + line = mbedtls_md_setup(&pmVar2->md_ctx_enc,md_info,1); + if ((line != 0) || (line = mbedtls_md_setup(&pmVar2->md_ctx_dec,md_info,1), line != 0)) { + text = "mbedtls_md_setup"; + line_00 = 699; + goto LAB_2308b0b0; + } + uVar3 = mbedtls_md_get_size(md_info); + uVar5 = CONCAT31(extraout_var,uVar3); + pmVar2->maclen = uVar5; + sVar6 = cipher_info->iv_size; + pmVar2->ivlen = sVar6; + if (cipher_info->mode != MBEDTLS_MODE_STREAM) { + sVar4 = (uVar5 + cipher_info->block_size) - uVar5 % cipher_info->block_size; + pmVar2->minlen = sVar4; + if (1 < ssl->minor_ver - 2U) { + line = 0x2f7; + goto LAB_2308b048; + } + sVar6 = sVar6 + sVar4; + goto LAB_2308b1e2; + } + pmVar2->minlen = uVar5; + } + mbedtls_debug_print_msg + (ssl,3,"file1",0x2ff,"keylen: %d, minlen: %d, ivlen: %d, maclen: %d",pmVar2->keylen, + pmVar2->minlen,pmVar2->ivlen); + uVar5 = pmVar2->keylen; + __n = pmVar2->fixed_ivlen; + sVar6 = pmVar2->maclen; + line = sVar6 * 2; + if ((*(ushort *)&ssl->conf->field_0x74 & 1) == 0) { + key = tmp + 0x3c; + buf_00 = key + line; + buf = key + line + uVar5; + key = key + sVar6; + if (__n == 0) { + __n = pmVar2->ivlen; + } + memcpy(pmVar2->iv_enc,buf + uVar5,__n); + memcpy(pmVar2->iv_dec,buf + pmVar2->keylen + __n,__n); + buf_01 = tmp + 0x3c; + } + else { + buf_01 = tmp + 0x3c; + buf_00 = buf_01 + line + uVar5; + buf = buf_01 + line; + buf_01 = buf_01 + sVar6; + if (__n == 0) { + __n = pmVar2->ivlen; + } + memcpy(pmVar2->iv_dec,buf_00 + uVar5,__n); + memcpy(pmVar2->iv_enc,buf_00 + pmVar2->keylen + __n,__n); + key = tmp + 0x3c; + } + if (0 < ssl->minor_ver) { + mbedtls_md_hmac_starts(&pmVar2->md_ctx_enc,buf_01,pmVar2->maclen); + mbedtls_md_hmac_starts(&pmVar2->md_ctx_dec,key,pmVar2->maclen); + ctx_00 = &pmVar2->cipher_ctx_enc; + line = mbedtls_cipher_setup(ctx_00,cipher_info); + if (line == 0) { + ctx = &pmVar2->cipher_ctx_dec; + line = mbedtls_cipher_setup(ctx,cipher_info); + if (line == 0) { + line = mbedtls_cipher_setkey(ctx_00,buf_00,cipher_info->key_bitlen,MBEDTLS_ENCRYPT); + if (line == 0) { + line = mbedtls_cipher_setkey(ctx,buf,cipher_info->key_bitlen,MBEDTLS_DECRYPT); + if (line == 0) { + if (cipher_info->mode == MBEDTLS_MODE_CBC) { + line = mbedtls_cipher_set_padding_mode(ctx_00,MBEDTLS_PADDING_NONE); + if (line != 0) { + mbedtls_debug_print_ret(ssl,1,"file1",0x38e,"mbedtls_cipher_set_padding_mode",line); + return line; + } + line = mbedtls_cipher_set_padding_mode(ctx,MBEDTLS_PADDING_NONE); + if (line != 0) { + mbedtls_debug_print_ret(ssl,1,"file1",0x395,"mbedtls_cipher_set_padding_mode",line); + return line; + } + } + mbedtls_zeroize(tmp + 0x3c,0x100); + mbedtls_debug_print_msg(ssl,2,"file1",0x3bd,"<= derive keys"); + return 0; + } + text = "mbedtls_cipher_setkey"; + line_00 = 900; + } + else { + text = "mbedtls_cipher_setkey"; + line_00 = 0x37c; + } + } + else { + text = "mbedtls_cipher_setup"; + line_00 = 0x374; + } + } + else { + text = "mbedtls_cipher_setup"; + line_00 = 0x36d; + } +LAB_2308b0b0: + mbedtls_debug_print_ret(ssl,1,"file1",line_00,text,line); + return line; + } + line = 0x349; +LAB_2308b048: + mbedtls_debug_print_msg(ssl,1,"file1",line,"should never happen"); + return -0x6c00; +} + + + +int mbedtls_ssl_flush_output(mbedtls_ssl_context *ssl) + +{ + int ret; + size_t sVar1; + uint uVar2; + uchar uVar3; + size_t sVar4; + + mbedtls_debug_print_msg(ssl,2,"file1",0x98a,"=> flush output"); + if (ssl->f_send == (mbedtls_ssl_send_t *)0x0) { + mbedtls_debug_print_msg + (ssl,1,"file1",0x98f,"Bad usage of mbedtls_ssl_set_bio() or mbedtls_ssl_set_bio()"); + ret = -0x7100; + } + else { + if (ssl->out_left == 0) { + ret = 0x996; + } + else { + while (sVar4 = ssl->out_left, sVar4 != 0) { + sVar1 = mbedtls_ssl_hdr_len(); + mbedtls_debug_print_msg + (ssl,2,"file1",0x99d,"message length: %d, out_left: %d",ssl->out_msglen + sVar1, + sVar4); + sVar4 = mbedtls_ssl_hdr_len(); + ret = (*ssl->f_send)(ssl->p_bio,ssl->out_hdr + sVar4 + (ssl->out_msglen - ssl->out_left), + ssl->out_left); + mbedtls_debug_print_ret(ssl,2,"file1",0x9a3,"ssl->f_send",ret); + if (ret < 1) { + return ret; + } + ssl->out_left = ssl->out_left - ret; + } + uVar2 = 8; + while (((uint)*(ushort *)&ssl->conf->field_0x74 & 2) < uVar2) { + uVar3 = ssl->out_ctr[uVar2 - 1] + '\x01'; + ssl->out_ctr[uVar2 - 1] = uVar3; + if (uVar3 != '\0') break; + uVar2 = uVar2 - 1 & 0xff; + } + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + sVar4 = 2; + } + if (uVar2 == sVar4) { + mbedtls_debug_print_msg(ssl,1,"file1",0x9b2,"outgoing message counter would wrap"); + return -0x6b80; + } + ret = 0x9b6; + } + mbedtls_debug_print_msg(ssl,2,"file1",ret,"<= flush output"); + ret = 0; + } + return ret; +} + + + +void mbedtls_ssl_recv_flight_completed(mbedtls_ssl_context *ssl) + +{ + ssl_flight_free(ssl->handshake->flight); + ssl->handshake->flight = (mbedtls_ssl_flight_item *)0x0; + ssl->handshake->cur_msg = (mbedtls_ssl_flight_item *)0x0; + ssl->handshake->in_flight_start_seq = ssl->handshake->in_msg_seq; + ssl_set_timer(ssl,0); + if ((ssl->in_msgtype == 0x16) && (*ssl->in_msg == '\x14')) { + ssl->handshake->retransmit_state = '\x03'; + } + else { + ssl->handshake->retransmit_state = '\0'; + } + return; +} + + + +void mbedtls_ssl_send_flight_completed(mbedtls_ssl_context *ssl) + +{ + uchar uVar1; + + ssl->handshake->retransmit_timeout = ssl->conf->hs_timeout_min; + mbedtls_debug_print_msg + (ssl,3,"file1",0x87,"update timeout value to %d millisecs", + ssl->handshake->retransmit_timeout); + ssl_set_timer(ssl,ssl->handshake->retransmit_timeout); + if ((ssl->in_msgtype == 0x16) && (*ssl->in_msg == '\x14')) { + uVar1 = '\x03'; + } + else { + uVar1 = '\x02'; + } + ssl->handshake->retransmit_state = uVar1; + return; +} + + + +void mbedtls_ssl_update_handshake_status(mbedtls_ssl_context *ssl) + +{ + mbedtls_ssl_handshake_params *pmVar1; + + if ((ssl->state != 0x10) && (ssl->handshake != (mbedtls_ssl_handshake_params *)0x0)) { + (*ssl->handshake->update_checksum)(ssl,ssl->in_msg,ssl->in_hslen); + } + if (((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) && + (pmVar1 = ssl->handshake, pmVar1 != (mbedtls_ssl_handshake_params *)0x0)) { + pmVar1->in_msg_seq = pmVar1->in_msg_seq + 1; + } + return; +} + + + +void mbedtls_ssl_optimize_checksum + (mbedtls_ssl_context *ssl,mbedtls_ssl_ciphersuite_t *ciphersuite_info) + +{ + if (ciphersuite_info->mac != MBEDTLS_MD_SHA384) { + ssl->handshake->update_checksum = ssl_update_checksum_sha256; + return; + } + mbedtls_debug_print_msg(ssl,1,"file1",0x122e,"should never happen"); + return; +} + + + +void mbedtls_ssl_reset_checksum(mbedtls_ssl_context *ssl) + +{ + mbedtls_sha256_starts(&ssl->handshake->fin_sha256,0); + return; +} + + + +void mbedtls_ssl_session_init(mbedtls_ssl_session *session) + +{ + memset(session,0,0x74); + return; +} + + + +void mbedtls_ssl_init(mbedtls_ssl_context *ssl) + +{ + memset(ssl,0,0xc0); + return; +} + + + +void mbedtls_ssl_conf_authmode(mbedtls_ssl_config *conf,int authmode) + +{ + *(ushort *)&conf->field_0x74 = + *(ushort *)&conf->field_0x74 & 0xfff3 | (ushort)((authmode & 3U) << 2); + return; +} + + + +void mbedtls_ssl_conf_rng(mbedtls_ssl_config *conf,mbedtls_ssl_recv_t *f_rng,void *p_rng) + +{ + conf->f_rng = f_rng; + conf->p_rng = p_rng; + return; +} + + + +void mbedtls_ssl_set_bio(mbedtls_ssl_context *ssl,void *p_bio,mbedtls_ssl_send_t *f_send, + mbedtls_ssl_recv_t *f_recv, + mbedtls_ssl_recv_timeout_t_conflict1 *f_recv_timeout) + +{ + ssl->p_bio = p_bio; + ssl->f_send = f_send; + ssl->f_recv = f_recv; + ssl->f_recv_timeout = f_recv_timeout; + return; +} + + + +int mbedtls_ssl_conf_own_cert + (mbedtls_ssl_config *conf,mbedtls_x509_crt *own_cert,mbedtls_pk_context *pk_key) + +{ + int iVar1; + + iVar1 = ssl_append_key_cert(&conf->key_cert,own_cert,pk_key); + return iVar1; +} + + + +void mbedtls_ssl_conf_ca_chain + (mbedtls_ssl_config *conf,mbedtls_x509_crt *ca_chain,mbedtls_x509_crl *ca_crl) + +{ + conf->ca_chain = ca_chain; + conf->ca_crl = ca_crl; + return; +} + + + +int mbedtls_ssl_set_hostname(mbedtls_ssl_context *ssl,char *hostname) + +{ + size_t __n; + char *__dest; + int iVar1; + + if (hostname == (char *)0x0) { + return -0x7100; + } + __n = strlen(hostname); + if (__n < 0x100) { + __dest = (char *)mycalloc(1,__n + 1); + ssl->hostname = __dest; + if (__dest == (char *)0x0) { + iVar1 = -0x7f00; + } + else { + memcpy(__dest,hostname,__n); + iVar1 = 0; + ssl->hostname[__n] = '\0'; + } + } + else { + iVar1 = -0x7100; + } + return iVar1; +} + + + +int mbedtls_ssl_conf_alpn_protocols(mbedtls_ssl_config *conf,char **protos) + +{ + char **ppcVar1; + uint uVar2; + size_t sVar3; + + uVar2 = 0; + ppcVar1 = protos; + while( true ) { + if (*ppcVar1 == (char *)0x0) { + conf->alpn_list = protos; + return 0; + } + sVar3 = strlen(*ppcVar1); + uVar2 = uVar2 + sVar3; + if ((0xfe < sVar3 - 1) || (0xffff < uVar2)) break; + ppcVar1 = ppcVar1 + 1; + } + return -0x7100; +} + + + +char * mbedtls_ssl_get_alpn_protocol(mbedtls_ssl_context *ssl) + +{ + return ssl->alpn_chosen; +} + + + +size_t mbedtls_ssl_get_bytes_avail(mbedtls_ssl_context *ssl) + +{ + if (ssl->in_offt != (uchar *)0x0) { + return ssl->in_msglen; + } + return 0; +} + + + +size_t mbedtls_ssl_get_record_expansion(mbedtls_ssl_context *param_1) + +{ + mbedtls_cipher_mode_t mVar1; + size_t sVar2; + size_t sVar3; + int iVar4; + mbedtls_cipher_info_t *pmVar5; + mbedtls_ssl_transform *pmVar6; + + pmVar6 = param_1->transform_out; + if (pmVar6 == (mbedtls_ssl_transform *)0x0) { + sVar2 = mbedtls_ssl_hdr_len(); + return sVar2; + } + pmVar5 = (pmVar6->cipher_ctx_enc).cipher_info; + if (pmVar5 == (mbedtls_cipher_info_t *)0x0) { +LAB_2308b83e: + mbedtls_debug_print_msg(param_1,1,"file1",0x18cf,"should never happen"); + iVar4 = -0x6c00; + } + else { + mVar1 = pmVar5->mode; + if (mVar1 == MBEDTLS_MODE_CBC) { + sVar2 = pmVar6->maclen + pmVar5->block_size; + } + else { + if ((mVar1 < MBEDTLS_MODE_CBC) || (2 < (byte)(mVar1 + ~MBEDTLS_MODE_CTR))) goto LAB_2308b83e; + sVar2 = pmVar6->minlen; + } + sVar3 = mbedtls_ssl_hdr_len(); + iVar4 = sVar3 + sVar2; + } + return iVar4; +} + + + +size_t mbedtls_ssl_get_max_frag_len(mbedtls_ssl_context *ssl) + +{ + uint uVar1; + + uVar1 = *(uint *)((int)mfl_code_to_length + (*(uint *)&ssl->conf->field_0x74 >> 4 & 0x1c)); + if ((ssl->session_out != (mbedtls_ssl_session *)0x0) && + (mfl_code_to_length[ssl->session_out->mfl_code] < uVar1)) { + uVar1 = mfl_code_to_length[ssl->session_out->mfl_code]; + } + return uVar1; +} + + + +int mbedtls_ssl_handshake_step(mbedtls_ssl_context *ssl) + +{ + int iVar1; + + if (ssl == (mbedtls_ssl_context *)0x0) { + return -0x7100; + } + if (ssl->conf == (mbedtls_ssl_config *)0x0) { + iVar1 = -0x7100; + } + else { + if (((*(ushort *)&ssl->conf->field_0x74 & 1) != 0) || + (iVar1 = mbedtls_ssl_handshake_client_step(ssl), (*(ushort *)&ssl->conf->field_0x74 & 1) != 0 + )) { + iVar1 = mbedtls_ssl_handshake_server_step(ssl); + return iVar1; + } + } + return iVar1; +} + + + +int mbedtls_ssl_handshake(mbedtls_ssl_context *ssl) + +{ + int iVar1; + + if ((ssl == (mbedtls_ssl_context *)0x0) || (ssl->conf == (mbedtls_ssl_config *)0x0)) { + iVar1 = -0x7100; + } + else { + mbedtls_debug_print_msg(ssl,2,"file1",0x1926,"=> handshake"); + do { + if (ssl->state == 0x10) { + iVar1 = 0; + break; + } + iVar1 = mbedtls_ssl_handshake_step(ssl); + } while (iVar1 == 0); + mbedtls_debug_print_msg(ssl,2,"file1",0x1930,"<= handshake"); + } + return iVar1; +} + + + +void mbedtls_ssl_transform_free(mbedtls_ssl_transform *transform) + +{ + if (transform != (mbedtls_ssl_transform *)0x0) { + mbedtls_cipher_free(&transform->cipher_ctx_enc); + mbedtls_cipher_free(&transform->cipher_ctx_dec); + mbedtls_md_free(&transform->md_ctx_enc); + mbedtls_md_free(&transform->md_ctx_dec); + mbedtls_zeroize(transform,0xd0); + return; + } + return; +} + + + +void mbedtls_ssl_handshake_free(mbedtls_ssl_handshake_params *handshake) + +{ + mbedtls_ssl_key_cert *pmVar1; + mbedtls_ssl_key_cert *pv; + + if (handshake != (mbedtls_ssl_handshake_params *)0x0) { + mbedtls_sha256_free(&handshake->fin_sha256); + pv = handshake->sni_key_cert; + while (pv != (mbedtls_ssl_key_cert *)0x0) { + pmVar1 = pv->next; + vPortFree(pv); + pv = pmVar1; + } + vPortFree(handshake->verify_cookie); + vPortFree(handshake->hs_msg); + ssl_flight_free(handshake->flight); + mbedtls_zeroize(handshake,0x15c); + return; + } + return; +} + + + +void ssl_handshake_wrapup_free_hs_transform(mbedtls_ssl_context *ssl) + +{ + mbedtls_ssl_transform *pmVar1; + + mbedtls_debug_print_msg(ssl,3,"file1",0x13af,"=> handshake wrapup: final free"); + mbedtls_ssl_handshake_free(ssl->handshake); + vPortFree(ssl->handshake); + ssl->handshake = (mbedtls_ssl_handshake_params *)0x0; + if (ssl->transform != (mbedtls_ssl_transform *)0x0) { + mbedtls_ssl_transform_free(ssl->transform); + vPortFree(ssl->transform); + } + pmVar1 = ssl->transform_negotiate; + ssl->transform_negotiate = (mbedtls_ssl_transform *)0x0; + ssl->transform = pmVar1; + mbedtls_debug_print_msg(ssl,3,"file1",0x13c3,"<= handshake wrapup: final free"); + return; +} + + + +void mbedtls_ssl_session_free(mbedtls_ssl_session *session) + +{ + if (session != (mbedtls_ssl_session *)0x0) { + if (session->peer_cert != (mbedtls_x509_crt *)0x0) { + mbedtls_x509_crt_free(session->peer_cert); + vPortFree(session->peer_cert); + } + vPortFree(session->ticket); + mbedtls_zeroize(session,0x74); + return; + } + return; +} + + + +void mbedtls_ssl_handshake_wrapup(mbedtls_ssl_context *ssl) + +{ + mbedtls_ssl_session *pmVar1; + anon_subr_int_void_ptr_mbedtls_ssl_session_ptr_for_f_set_cache *paVar2; + int iVar3; + + iVar3 = ssl->handshake->resume; + mbedtls_debug_print_msg(ssl,3,"file1",0x13ca,"=> handshake wrapup"); + if (ssl->session != (mbedtls_ssl_session *)0x0) { + mbedtls_ssl_session_free(ssl->session); + vPortFree(ssl->session); + } + pmVar1 = ssl->session_negotiate; + ssl->session_negotiate = (mbedtls_ssl_session *)0x0; + ssl->session = pmVar1; + paVar2 = ssl->conf->f_set_cache; + if ((((paVar2 != (anon_subr_int_void_ptr_mbedtls_ssl_session_ptr_for_f_set_cache *)0x0) && + (pmVar1->id_len != 0)) && (iVar3 == 0)) && + (iVar3 = (*paVar2)(ssl->conf->p_cache,pmVar1), iVar3 != 0)) { + mbedtls_debug_print_msg(ssl,1,"file1",0x13ed,"cache did not store session"); + } + if (((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) || + (ssl->handshake->flight == (mbedtls_ssl_flight_item *)0x0)) { + ssl_handshake_wrapup_free_hs_transform(ssl); + } + else { + ssl_set_timer(ssl,0); + mbedtls_debug_print_msg(ssl,3,"file1",0x13f9,"skip freeing handshake and transform"); + } + ssl->state = ssl->state + 1; + mbedtls_debug_print_msg(ssl,3,"file1",0x1401,"<= handshake wrapup"); + return; +} + + + +int ssl_handshake_init(mbedtls_ssl_context *ssl) + +{ + mbedtls_ssl_transform *__s; + mbedtls_ssl_handshake_params *__s_00; + mbedtls_ssl_session *pmVar1; + + if (ssl->transform_negotiate != (mbedtls_ssl_transform *)0x0) { + mbedtls_ssl_transform_free(ssl->transform_negotiate); + } + if (ssl->session_negotiate != (mbedtls_ssl_session *)0x0) { + mbedtls_ssl_session_free(ssl->session_negotiate); + } + if (ssl->handshake != (mbedtls_ssl_handshake_params *)0x0) { + mbedtls_ssl_handshake_free(ssl->handshake); + } + if (ssl->transform_negotiate == (mbedtls_ssl_transform *)0x0) { + __s = (mbedtls_ssl_transform *)mycalloc(1,0xd0); + ssl->transform_negotiate = __s; + } + if (ssl->session_negotiate == (mbedtls_ssl_session *)0x0) { + pmVar1 = (mbedtls_ssl_session *)mycalloc(1,0x74); + ssl->session_negotiate = pmVar1; + } + if (ssl->handshake == (mbedtls_ssl_handshake_params *)0x0) { + __s_00 = (mbedtls_ssl_handshake_params *)mycalloc(1,0x15c); + ssl->handshake = __s_00; + if (__s_00 == (mbedtls_ssl_handshake_params *)0x0) goto LAB_2308bb98; + } + if ((ssl->transform_negotiate != (mbedtls_ssl_transform *)0x0) && + (ssl->session_negotiate != (mbedtls_ssl_session *)0x0)) { + mbedtls_ssl_session_init(ssl->session_negotiate); + __s = ssl->transform_negotiate; + memset(__s,0,0xd0); + mbedtls_cipher_init(&__s->cipher_ctx_enc); + mbedtls_cipher_init(&__s->cipher_ctx_dec); + mbedtls_md_init(&__s->md_ctx_enc); + mbedtls_md_init(&__s->md_ctx_dec); + __s_00 = ssl->handshake; + memset(__s_00,0,0x15c); + mbedtls_sha256_init(&__s_00->fin_sha256); + mbedtls_sha256_starts(&__s_00->fin_sha256,0); + __s_00->update_checksum = ssl_update_checksum_start; + __s_00->sig_alg = 2; + __s_00->sni_authmode = 3; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + return 0; + } + ssl->handshake->alt_transform_out = ssl->transform_out; + if ((*(ushort *)&ssl->conf->field_0x74 & 1) == 0) { + ssl->handshake->retransmit_state = '\0'; + } + else { + ssl->handshake->retransmit_state = '\x02'; + } + ssl_set_timer(ssl,0); + return 0; + } +LAB_2308bb98: + mbedtls_debug_print_msg(ssl,1,"file1",0x152c,"alloc() of ssl sub-contexts failed"); + vPortFree(ssl->handshake); + vPortFree(ssl->transform_negotiate); + vPortFree(ssl->session_negotiate); + ssl->handshake = (mbedtls_ssl_handshake_params *)0x0; + ssl->transform_negotiate = (mbedtls_ssl_transform *)0x0; + ssl->session_negotiate = (mbedtls_ssl_session *)0x0; + return -0x7f00; +} + + + +int mbedtls_ssl_setup(mbedtls_ssl_context *ssl,mbedtls_ssl_config *conf) + +{ + uchar *puVar1; + int iVar2; + uchar *puVar3; + uchar *puVar4; + + ssl->conf = conf; + puVar1 = (uchar *)mycalloc(1,0x413d); + ssl->in_buf = puVar1; + if (puVar1 != (uchar *)0x0) { + puVar1 = (uchar *)mycalloc(1,0x413d); + ssl->out_buf = puVar1; + if (puVar1 != (uchar *)0x0) { + puVar4 = ssl->in_buf; + puVar3 = puVar1 + 0xd; + if ((*(ushort *)&conf->field_0x74 & 2) == 0) { + ssl->out_ctr = puVar1; + ssl->in_ctr = puVar4; + ssl->out_hdr = puVar1 + 8; + ssl->out_len = puVar1 + 0xb; + ssl->out_iv = puVar3; + ssl->out_msg = puVar3; + ssl->in_hdr = puVar4 + 8; + } + else { + ssl->out_hdr = puVar1; + ssl->in_hdr = puVar4; + ssl->out_ctr = puVar1 + 3; + ssl->out_len = puVar1 + 0xb; + ssl->out_iv = puVar3; + ssl->out_msg = puVar3; + ssl->in_ctr = puVar4 + 3; + } + ssl->in_len = puVar4 + 0xb; + ssl->in_iv = puVar4 + 0xd; + ssl->in_msg = puVar4 + 0xd; + iVar2 = ssl_handshake_init(ssl); + return iVar2; + } + } + mbedtls_debug_print_msg(ssl,1,"file1",0x1585,"alloc(%d bytes) failed",0x413d); + vPortFree(ssl->in_buf); + ssl->in_buf = (uchar *)0x0; + return -0x7f00; +} + + + +void mbedtls_ssl_free(mbedtls_ssl_context *ssl) + +{ + size_t n; + char *__s; + + if (ssl != (mbedtls_ssl_context *)0x0) { + mbedtls_debug_print_msg(ssl,2,"file1",0x1c0a,"=> free"); + if (ssl->out_buf != (uchar *)0x0) { + mbedtls_zeroize(ssl->out_buf,0x413d); + vPortFree(ssl->out_buf); + } + if (ssl->in_buf != (uchar *)0x0) { + mbedtls_zeroize(ssl->in_buf,0x413d); + vPortFree(ssl->in_buf); + } + if (ssl->transform != (mbedtls_ssl_transform *)0x0) { + mbedtls_ssl_transform_free(ssl->transform); + vPortFree(ssl->transform); + } + if (ssl->handshake != (mbedtls_ssl_handshake_params *)0x0) { + mbedtls_ssl_handshake_free(ssl->handshake); + mbedtls_ssl_transform_free(ssl->transform_negotiate); + mbedtls_ssl_session_free(ssl->session_negotiate); + vPortFree(ssl->handshake); + vPortFree(ssl->transform_negotiate); + vPortFree(ssl->session_negotiate); + } + if (ssl->session != (mbedtls_ssl_session *)0x0) { + mbedtls_ssl_session_free(ssl->session); + vPortFree(ssl->session); + } + __s = ssl->hostname; + if (__s != (char *)0x0) { + n = strlen(__s); + mbedtls_zeroize(__s,n); + vPortFree(ssl->hostname); + } + mbedtls_debug_print_msg(ssl,2,"file1",0x1c4b,"<= free"); + mbedtls_zeroize(ssl,0xc0); + return; + } + return; +} + + + +void mbedtls_ssl_config_init(mbedtls_ssl_config *conf) + +{ + memset(conf,0,0x78); + return; +} + + + +int mbedtls_ssl_config_defaults(mbedtls_ssl_config *conf,int endpoint,int transport,int preset) + +{ + ushort uVar1; + ushort uVar2; + ushort uVar3; + int *piVar4; + mbedtls_ecp_group_id *pmVar5; + + uVar1 = *(ushort *)&conf->field_0x74; + uVar3 = (ushort)endpoint & 1; + uVar2 = (ushort)((transport & 1U) << 1); + *(ushort *)&conf->field_0x74 = uVar1 & 0xfffc | uVar3 | uVar2; + if (endpoint == 0) { + *(ushort *)&conf->field_0x74 = uVar1 & 0xfdf0 | uVar3 | uVar2 | 0x208; + } + conf->hs_timeout_min = 1000; + conf->hs_timeout_max = 60000; + if (preset == 2) { + *(undefined4 *)&conf->max_major_ver = 0x3030303; + conf->ciphersuite_list[3] = (int *)0x4200e134; + conf->ciphersuite_list[2] = (int *)0x4200e134; + conf->ciphersuite_list[1] = (int *)0x4200e134; + conf->ciphersuite_list[0] = (int *)0x4200e134; + conf->cert_profile = &mbedtls_x509_crt_profile_suiteb; + conf->sig_hashes = ssl_preset_suiteb_hashes; + conf->curve_list = ssl_preset_suiteb_curves; + return 0; + } + *(undefined4 *)&conf->max_major_ver = 0x3030303; + if (transport == 1) { + conf->min_minor_ver = '\x02'; + } + piVar4 = mbedtls_ssl_list_ciphersuites(); + conf->cert_profile = &mbedtls_x509_crt_profile_default; + conf->ciphersuite_list[3] = piVar4; + conf->ciphersuite_list[2] = piVar4; + conf->ciphersuite_list[1] = piVar4; + conf->ciphersuite_list[0] = piVar4; + conf->sig_hashes = ssl_preset_default_hashes; + pmVar5 = mbedtls_ecp_grp_id_list(); + conf->curve_list = pmVar5; + return 0; +} + + + +void mbedtls_ssl_config_free(mbedtls_ssl_config *conf) + +{ + mbedtls_ssl_key_cert *pmVar1; + mbedtls_ssl_key_cert *pv; + + pv = conf->key_cert; + while (pv != (mbedtls_ssl_key_cert *)0x0) { + pmVar1 = pv->next; + vPortFree(pv); + pv = pmVar1; + } + mbedtls_zeroize(conf,0x78); + return; +} + + + +uchar mbedtls_ssl_sig_from_pk(mbedtls_pk_context *pk) + +{ + int iVar1; + + iVar1 = mbedtls_pk_can_do(pk,MBEDTLS_PK_RSA); + return (uchar)(iVar1 != 0); +} + + + +mbedtls_pk_type_t mbedtls_ssl_pk_alg_from_sig(uchar sig) + +{ + undefined3 in_register_00002029; + + return (mbedtls_pk_type_t)(CONCAT31(in_register_00002029,sig) == 1); +} + + + +mbedtls_md_type_t mbedtls_ssl_md_alg_from_hash(uchar hash) + +{ + uint uVar1; + + uVar1 = (uint)hash - 1 & 0xff; + if (uVar1 < 4) { + return *(mbedtls_md_type_t *)((int)&CSWTCH_35 + uVar1); + } + return MBEDTLS_MD_NONE; +} + + + +uchar mbedtls_ssl_hash_from_md_alg(int md) + +{ + if (md - 3U < 4) { + return *(uchar *)((int)&CSWTCH_35 + md + 1); + } + return '\0'; +} + + + +int mbedtls_ssl_check_curve(mbedtls_ssl_context *ssl,mbedtls_ecp_group_id grp_id) + +{ + undefined3 in_register_0000202d; + mbedtls_ecp_group_id *pmVar1; + + pmVar1 = ssl->conf->curve_list; + if (pmVar1 != (mbedtls_ecp_group_id *)0x0) { + while (*pmVar1 != MBEDTLS_ECP_DP_NONE) { + if ((uint)*pmVar1 == CONCAT31(in_register_0000202d,grp_id)) { + return 0; + } + pmVar1 = pmVar1 + 1; + } + } + return -1; +} + + + +int mbedtls_ssl_check_cert_usage + (mbedtls_x509_crt *cert,mbedtls_ssl_ciphersuite_t *ciphersuite,int cert_endpoint, + uint32_t *flags) + +{ + int iVar1; + int iVar2; + uint usage; + char *usage_oid; + uint uVar3; + + usage = 0x80; + if (cert_endpoint == 1) { + usage = 0; + if (ciphersuite->key_exchange < MBEDTLS_KEY_EXCHANGE_ECJPAKE) { + uVar3 = 1 << ((uint)ciphersuite->key_exchange & 0x1f); + usage = 0x20; + if (((uVar3 & 0x82) == 0) && (usage = 8, (uVar3 & 0x600) == 0)) { + usage = (uint)((uVar3 & 0x1c) != 0) << 7; + } + } + } + iVar1 = mbedtls_x509_crt_check_key_usage(cert,usage); + if (iVar1 != 0) { + *flags = *flags | 0x800; + iVar1 = -1; + } + if (cert_endpoint == 1) { + usage_oid = "+\x06\x01\x05\x05\a\x03\x01"; + } + else { + usage_oid = "+\x06\x01\x05\x05\a\x03\x02"; + } + iVar2 = mbedtls_x509_crt_check_extended_key_usage(cert,usage_oid,8); + if (iVar2 != 0) { + iVar1 = -1; + *flags = *flags | 0x1000; + } + return iVar1; +} + + + +void mbedtls_ssl_write_version(int major,int minor,int transport,uchar *ver) + +{ + uchar uVar1; + + uVar1 = (uchar)minor; + if (transport == 1) { + if (minor == 2) { + uVar1 = '\x01'; + } + *ver = ~((uchar)major - 2); + uVar1 = -uVar1; + } + else { + *ver = (uchar)major; + } + ver[1] = uVar1; + return; +} + + + +// WARNING: Variable defined which should be unmapped: add_data + +int mbedtls_ssl_write_record(mbedtls_ssl_context *ssl) + +{ + uchar uVar1; + mbedtls_cipher_mode_t mVar2; + int ret; + mbedtls_ssl_flight_item *pv; + size_t __n; + char *text; + int line; + mbedtls_ssl_flight_item *pmVar3; + mbedtls_ssl_flight_item *pmVar4; + mbedtls_cipher_info_t *pmVar5; + mbedtls_ssl_transform *pmVar6; + uint uVar7; + byte *pbVar8; + uchar *input; + undefined2 ilen; + uint uVar9; + size_t ilen_00; + size_t *in_fa0; + uchar *in_fa1; + uchar *extraout_fa1; + size_t in_fa2; + size_t sStack52; + size_t olen; + uchar add_data [13]; + + _ilen = ssl->out_msglen; + ilen = (undefined2)_ilen; + mbedtls_debug_print_msg(ssl,2,"file1",0xaa7,"=> write record"); + if (((((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) || + (ssl->handshake == (mbedtls_ssl_handshake_params *)0x0)) || + (ssl->handshake->retransmit_state != '\x01')) && (ssl->out_msgtype == 0x16)) { + uVar1 = *ssl->out_msg; + if ((uVar1 != '\0') && (ssl->handshake == (mbedtls_ssl_handshake_params *)0x0)) { + mbedtls_debug_print_msg(ssl,1,"file1",0xab9,"should never happen"); + return -0x6c00; + } + __n = _ilen - 4; + ssl->out_msg[1] = (uchar)(__n >> 0x10); + ssl->out_msg[2] = (uchar)(__n >> 8); + ssl->out_msg[3] = (uchar)__n; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + _ilen = _ilen + 8; + memmove(ssl->out_msg + 0xc,ssl->out_msg + 4,__n); + ssl->out_msglen = ssl->out_msglen + 8; + if (uVar1 == '\0') { + ssl->out_msg[4] = '\0'; + ssl->out_msg[5] = '\0'; + } + else { + ssl->out_msg[4] = (uchar)(ssl->handshake->out_msg_seq >> 8); + ssl->out_msg[5] = (uchar)ssl->handshake->out_msg_seq; + ssl->handshake->out_msg_seq = ssl->handshake->out_msg_seq + 1; + } + memset(ssl->out_msg + 6,0,3); + memcpy(ssl->out_msg + 9,ssl->out_msg + 1,3); + } + ilen = (undefined2)_ilen; + if (uVar1 != '\0') { + in_fa0 = (size_t *)(*ssl->handshake->update_checksum)(ssl,ssl->out_msg,_ilen); + in_fa1 = extraout_fa1; + } + } + if ((((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) && + (ssl->handshake != (mbedtls_ssl_handshake_params *)0x0)) && + ((ssl->handshake->retransmit_state != '\x01' && ((ssl->out_msgtype & 0xfffffffdU) == 0x14)))) { + pv = (mbedtls_ssl_flight_item *)mycalloc(1,0x10); + if (pv == (mbedtls_ssl_flight_item *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x9ca,"alloc %d bytes failed",0x10); +LAB_2308c1fe: + mbedtls_debug_print_ret(ssl,1,"file1",0xaf1,"ssl_flight_append",-0x7f00); + return -0x7f00; + } + input = (uchar *)mycalloc(1,ssl->out_msglen); + pv->p = input; + if (input == (uchar *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x9d0,"alloc %d bytes failed"); + vPortFree(pv); + goto LAB_2308c1fe; + } + memcpy(input,ssl->out_msg,ssl->out_msglen); + pv->len = ssl->out_msglen; + line = ssl->out_msgtype; + pv->next = (mbedtls_ssl_flight_item *)0x0; + pv->type = (uchar)line; + pmVar3 = ssl->handshake->flight; + if (pmVar3 == (mbedtls_ssl_flight_item *)0x0) { + ssl->handshake->flight = pv; + } + else { + do { + pmVar4 = pmVar3; + pmVar3 = pmVar4->next; + } while (pmVar3 != (mbedtls_ssl_flight_item *)0x0); + pmVar4->next = pv; + } + } + *ssl->out_hdr = (uchar)ssl->out_msgtype; + mbedtls_ssl_write_version + (ssl->major_ver,ssl->minor_ver,*(uint *)&ssl->conf->field_0x74 >> 1 & 1,ssl->out_hdr + 1 + ); + *ssl->out_len = (uchar)((ushort)ilen >> 8); + ssl->out_len[1] = (uchar)ilen; + if (ssl->transform_out == (mbedtls_ssl_transform *)0x0) { +LAB_2308c6d2: + _ilen = mbedtls_ssl_hdr_len(); + ssl->out_left = _ilen + ssl->out_msglen; + pbVar8 = ssl->out_hdr; + mbedtls_debug_print_msg + (ssl,3,"file1",0xb30,"output record: msgtype = %d, version = [%d:%d], msglen = %d", + (uint)*pbVar8,(uint)pbVar8[1],(uint)pbVar8[2]); + _ilen = mbedtls_ssl_hdr_len(); + mbedtls_debug_print_buf + (ssl,4,"file1",0xb33,"output record sent to network",ssl->out_hdr, + ssl->out_msglen + _ilen); + ret = mbedtls_ssl_flush_output(ssl); + if (ret == 0) { + mbedtls_debug_print_msg(ssl,2,"file1",0xb3c,"<= write record"); + return 0; + } + text = "mbedtls_ssl_flush_output"; + line = 0xb38; + goto LAB_2308c548; + } + mbedtls_debug_print_msg(ssl,2,"file1",0x504,"=> encrypt buf"); + if ((ssl->session_out == (mbedtls_ssl_session *)0x0) || + (ssl->transform_out == (mbedtls_ssl_transform *)0x0)) { + line = 0x508; +LAB_2308c2f2: + mbedtls_debug_print_msg(ssl,1,"file1",line,"should never happen"); + ret = -0x6c00; + } + else { + pmVar5 = (ssl->transform_out->cipher_ctx_enc).cipher_info; + mVar2 = MBEDTLS_MODE_NONE; + if (pmVar5 != (mbedtls_cipher_info_t *)0x0) { + mVar2 = pmVar5->mode; + } + mbedtls_debug_print_buf + (ssl,4,"file1",0x50f,"before encrypt: output payload",ssl->out_msg,ssl->out_msglen); + if ((mVar2 == MBEDTLS_MODE_STREAM) || (line = 0, mVar2 == MBEDTLS_MODE_CBC)) { + if (ssl->minor_ver < 1) { + line = 0x536; + goto LAB_2308c2f2; + } + mbedtls_md_hmac_update(&ssl->transform_out->md_ctx_enc,ssl->out_ctr,8); + mbedtls_md_hmac_update(&ssl->transform_out->md_ctx_enc,ssl->out_hdr,3); + mbedtls_md_hmac_update(&ssl->transform_out->md_ctx_enc,ssl->out_len,2); + line = 1; + mbedtls_md_hmac_update(&ssl->transform_out->md_ctx_enc,ssl->out_msg,ssl->out_msglen); + mbedtls_md_hmac_finish(&ssl->transform_out->md_ctx_enc,ssl->out_msg + ssl->out_msglen); + mbedtls_md_hmac_reset(&ssl->transform_out->md_ctx_enc); + mbedtls_debug_print_buf + (ssl,4,"file1",0x53c,"computed mac",ssl->out_msg + ssl->out_msglen, + ssl->transform_out->maclen); + ssl->out_msglen = ssl->out_msglen + ssl->transform_out->maclen; + } + if ((mVar2 + ~MBEDTLS_MODE_CTR & 0xfd) != 0) { + if (mVar2 != MBEDTLS_MODE_CBC) { + line = 0x627; + goto LAB_2308c2f2; + } + olen = 0; + uVar7 = ssl->transform_out->ivlen; + uVar9 = uVar7 - (ssl->out_msglen + 1) % uVar7; + if (uVar7 == uVar9) { + uVar9 = 0; + } + uVar7 = 0; + do { + ssl->out_msg[ssl->out_msglen + uVar7] = (uchar)uVar9; + uVar7 = uVar7 + 1; + } while (uVar7 <= uVar9); + _ilen = ssl->out_msglen + 1 + uVar9; + ssl->out_msglen = _ilen; + if (1 < ssl->minor_ver) { + ret = (*ssl->conf->f_rng)(ssl->conf->p_rng,ssl->transform_out->iv_enc, + ssl->transform_out->ivlen); + if (ret == 0) { + memcpy(ssl->out_iv,ssl->transform_out->iv_enc,ssl->transform_out->ivlen); + _ilen = ssl->out_msglen; + input = ssl->out_msg; + ssl->out_msglen = ssl->transform_out->ivlen + _ilen; + goto LAB_2308c5f6; + } + goto LAB_2308c538; + } + input = ssl->out_msg; +LAB_2308c5f6: + mbedtls_debug_print_msg + (ssl,3,"file1",0x5e3, + "before encrypt: msglen = %d, including %d bytes of IV and %d bytes of padding", + ssl->out_msglen,ssl->transform_out->ivlen,uVar9 + 1); + pmVar6 = ssl->transform_out; + ret = mbedtls_cipher_crypt + (&pmVar6->cipher_ctx_enc,pmVar6->iv_enc,pmVar6->ivlen,input,_ilen,input,&olen) + ; + if (ret != 0) { + text = "mbedtls_cipher_crypt"; + line = 0x5eb; + goto LAB_2308c52c; + } + if (_ilen == olen) goto LAB_2308c592; + line = 0x5f1; + goto LAB_2308c2f2; + } + _ilen = 8; + if ((ssl->transform_out->ciphersuite_info->flags & 2) == 0) { + _ilen = 0x10; + } + memcpy(&olen,ssl->out_ctr,8); + add_data[4] = (uchar)ssl->out_msgtype; + mbedtls_ssl_write_version + (ssl->major_ver,ssl->minor_ver,*(uint *)&ssl->conf->field_0x74 >> 1 & 1,add_data + 5); + add_data[7] = (uchar)(ssl->out_msglen >> 8); + add_data[8] = (uchar)ssl->out_msglen; + mbedtls_debug_print_buf(ssl,4,"file1",0x575,"additional data used for AEAD",(uchar *)&olen,0xd); + pmVar6 = ssl->transform_out; + if (pmVar6->ivlen - 8 != pmVar6->fixed_ivlen) { + line = 0x57d; + goto LAB_2308c2f2; + } + memcpy(pmVar6->iv_enc + pmVar6->fixed_ivlen,ssl->out_ctr,8); + memcpy(ssl->out_iv,ssl->out_ctr,8); + mbedtls_debug_print_buf + (ssl,4,"file1",0x586,"IV used",ssl->out_iv, + ssl->transform_out->ivlen - ssl->transform_out->fixed_ivlen); + ilen_00 = ssl->out_msglen; + input = ssl->out_msg; + ssl->out_msglen = (ssl->transform_out->ivlen + ilen_00) - ssl->transform_out->fixed_ivlen; + mbedtls_debug_print_msg + (ssl,3,"file1",0x592,"before encrypt: msglen = %d, including %d bytes of padding",0); + pmVar6 = ssl->transform_out; + ret = mbedtls_cipher_auth_encrypt + (&pmVar6->cipher_ctx_enc,pmVar6->iv_enc,pmVar6->ivlen,(uchar *)&olen,0xd,input, + ilen_00,input,in_fa0,in_fa1,in_fa2); + if (ret == 0) { + if (ilen_00 != sStack52) { + line = 0x5a5; + goto LAB_2308c2f2; + } + ssl->out_msglen = ssl->out_msglen + _ilen; + line = line + 1; + mbedtls_debug_print_buf(ssl,4,"file1",0x5ac,"after encrypt: tag",input + ilen_00,_ilen); +LAB_2308c592: + if (line == 1) { + mbedtls_debug_print_msg(ssl,2,"file1",0x632,"<= encrypt buf"); + _ilen = ssl->out_msglen; + *ssl->out_len = (uchar)(_ilen >> 8); + ssl->out_len[1] = (uchar)_ilen; + goto LAB_2308c6d2; + } + line = 0x62e; + goto LAB_2308c2f2; + } + text = "mbedtls_cipher_auth_encrypt"; + line = 0x59f; +LAB_2308c52c: + mbedtls_debug_print_ret(ssl,1,"file1",line,text,ret); + } +LAB_2308c538: + text = "ssl_encrypt_buf"; + line = 0xb22; +LAB_2308c548: + mbedtls_debug_print_ret(ssl,1,"file1",line,text,ret); + return ret; +} + + + +int mbedtls_ssl_resend(mbedtls_ssl_context *ssl) + +{ + mbedtls_ssl_flight_item *pmVar1; + int ret; + mbedtls_ssl_handshake_params *pmVar2; + + mbedtls_debug_print_msg(ssl,2,"file1",0xa39,"=> mbedtls_ssl_resend"); + if (ssl->handshake->retransmit_state != '\x01') { + mbedtls_debug_print_msg(ssl,2,"file1",0xa3d,"initialise resending"); + ssl->handshake->cur_msg = ssl->handshake->flight; + ssl_swap_epochs(ssl); + ssl->handshake->retransmit_state = '\x01'; + } + do { + pmVar2 = ssl->handshake; + pmVar1 = pmVar2->cur_msg; + if (pmVar1 == (mbedtls_ssl_flight_item *)0x0) { + if (ssl->state == 0x10) { + pmVar2->retransmit_state = '\x03'; + } + else { + pmVar2->retransmit_state = '\x02'; + ssl_set_timer(ssl,ssl->handshake->retransmit_timeout); + } + mbedtls_debug_print_msg(ssl,2,"file1",0xa6a,"<= mbedtls_ssl_resend"); + return 0; + } + if ((pmVar1->type == '\x16') && (*pmVar1->p == '\x14')) { + ssl_swap_epochs(ssl); + } + memcpy(ssl->out_msg,pmVar1->p,pmVar1->len); + ssl->out_msglen = pmVar1->len; + ssl->out_msgtype = (uint)pmVar1->type; + ssl->handshake->cur_msg = pmVar1->next; + mbedtls_debug_print_buf(ssl,3,"file1",0xa59,"resent handshake message header",ssl->out_msg,0xc); + ret = mbedtls_ssl_write_record(ssl); + } while (ret == 0); + mbedtls_debug_print_ret(ssl,1,"file1",0xa5d,"mbedtls_ssl_write_record",ret); + return ret; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +int mbedtls_ssl_fetch_input(mbedtls_ssl_context *ssl,size_t nb_want) + +{ + void *pvVar1; + int iVar2; + int ret; + uint uVar3; + char *format; + size_t ret_00; + uint uVar4; + uint uVar5; + uint32_t uVar6; + + mbedtls_debug_print_msg(ssl,2,"file1",0x8ba,"=> fetch input"); + if ((ssl->f_recv == (mbedtls_ssl_recv_t *)0x0) && + (ssl->f_recv_timeout == (mbedtls_ssl_recv_timeout_t_conflict1 *)0x0)) { + format = "Bad usage of mbedtls_ssl_set_bio() or mbedtls_ssl_set_bio()"; + ret = 0x8bf; +LAB_2308c91e: + mbedtls_debug_print_msg(ssl,1,"file1",ret,format); + return -0x7100; + } + if (0x413dU - (int)(ssl->in_hdr + -(int)ssl->in_buf) < nb_want) { + format = "requesting more data than fits"; + ret = 0x8c5; + goto LAB_2308c91e; + } + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + mbedtls_debug_print_msg(ssl,2,"file1",0x958,"in_left: %d, nb_want: %d",ssl->in_left,nb_want); + while (uVar5 = ssl->in_left, uVar5 < nb_want) { + iVar2 = ssl_check_timer(ssl); + ret = -0x6800; + if (iVar2 == 0) { + if (ssl->f_recv_timeout == (mbedtls_ssl_recv_timeout_t_conflict1 *)0x0) { + ret = (*ssl->f_recv)(ssl->f_recv); + } + else { + ret = (*ssl->f_recv_timeout) + (ssl->p_bio,ssl->in_hdr + ssl->in_left,nb_want - uVar5, + ssl->conf->read_timeout); + } + } + mbedtls_debug_print_msg(ssl,2,"file1",0x970,"in_left: %d, nb_want: %d",ssl->in_left,nb_want); + mbedtls_debug_print_ret(ssl,2,"file1",0x971,"ssl->f_recv(_timeout)",ret); + if (ret == 0) { + return -0x7280; + } + if (ret < 0) { + return ret; + } + ssl->in_left = ret + ssl->in_left; + } + } + else { + if ((ssl->f_set_timer == (mbedtls_ssl_set_timer_t_conflict1 *)0x0) || + (ssl->f_get_timer == (mbedtls_ssl_get_timer_t *)0x0)) { + format = "You must use mbedtls_ssl_set_timer_cb() for DTLS"; + ret = 0x8d2; + goto LAB_2308c91e; + } + uVar5 = ssl->next_record_offset; + if (uVar5 != 0) { + if (ssl->in_left < uVar5) { + ret = 0x8e4; + goto LAB_2308c9ac; + } + ret_00 = ssl->in_left - uVar5; + ssl->in_left = ret_00; + if (ret_00 != 0) { + mbedtls_debug_print_msg(ssl,2,"file1",0x8ed,"next record in same datagram, offset: %d"); + memmove(ssl->in_hdr,ssl->in_hdr + ssl->next_record_offset,ssl->in_left); + } + ssl->next_record_offset = 0; + } + mbedtls_debug_print_msg(ssl,2,"file1",0x8f7,"in_left: %d, nb_want: %d",ssl->in_left,nb_want); + if (nb_want <= ssl->in_left) { + ret = 0x8fe; + goto LAB_2308ca20; + } + if (ssl->in_left != 0) { + ret = 0x909; +LAB_2308c9ac: + mbedtls_debug_print_msg(ssl,1,"file1",ret,"should never happen"); + return -0x6c00; + } + ret = ssl_check_timer(ssl); + if (ret != 0) { +LAB_2308ca48: + mbedtls_debug_print_msg(ssl,2,"file1",0x92d,"timeout"); + ssl_set_timer(ssl,0); + if (ssl->state != 0x10) { + uVar3 = ssl->handshake->retransmit_timeout; + uVar5 = ssl->conf->hs_timeout_max; + if (uVar3 < uVar5) { + uVar4 = uVar3 << 1; + if ((uVar3 <= uVar4) && (uVar4 < uVar5)) { + uVar5 = uVar4; + } + ssl->handshake->retransmit_timeout = uVar5; + mbedtls_debug_print_msg + (ssl,3,"file1",0x7e,"update timeout value to %d millisecs", + ssl->handshake->retransmit_timeout); + ret = mbedtls_ssl_resend(ssl); + if (ret == 0) { + return -0x6900; + } + mbedtls_debug_print_ret(ssl,1,"file1",0x93a,"mbedtls_ssl_resend",ret); + return ret; + } + mbedtls_debug_print_msg(ssl,1,"file1",0x934,"handshake timeout"); + } + return -0x6800; + } + pvVar1 = (void *)(0x413d - (int)(ssl->in_hdr + -(int)ssl->in_buf)); + if (ssl->state == 0x10) { + uVar6 = ssl->conf->read_timeout; + } + else { + uVar6 = ssl->handshake->retransmit_timeout; + } + mbedtls_debug_print_msg(ssl,3,"file1",0x91d,"f_recv_timeout: %u ms",uVar6); + if (ssl->f_recv_timeout == (mbedtls_ssl_recv_timeout_t_conflict1 *)0x0) { + ret_00 = (*ssl->f_recv)(pvVar1,(uchar *)ssl->f_recv); + } + else { + ret_00 = (*ssl->f_recv_timeout)(ssl->p_bio,ssl->in_hdr,(size_t)pvVar1,uVar6); + } + mbedtls_debug_print_ret(ssl,2,"file1",0x925,"ssl->f_recv(_timeout)",ret_00); + if (ret_00 == 0) { + return -0x7280; + } + if (ret_00 == 0xffff9800) goto LAB_2308ca48; + if ((int)ret_00 < 0) { + return ret_00; + } + ssl->in_left = ret_00; + } + ret = 0x97d; +LAB_2308ca20: + mbedtls_debug_print_msg(ssl,2,"file1",ret,"<= fetch input"); + return 0; +} + + + +int mbedtls_ssl_prepare_handshake_record(mbedtls_ssl_context *ssl) + +{ + byte bVar1; + uint uVar2; + uchar *__s1; + int line; + size_t __n; + uint uVar3; + mbedtls_ssl_handshake_params *pmVar4; + uint __n_00; + int line_00; + uint uVar5; + byte *pbVar6; + char *format; + uint uVar7; + size_t size; + uint uVar8; + uint uVar9; + size_t sVar10; + uchar *puVar11; + uint uVar12; + uchar *puVar13; + + uVar3 = 0xc; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + uVar3 = 4; + } + if (ssl->in_msglen < uVar3) { + mbedtls_debug_print_msg(ssl,1,"file1",0xc20,"handshake message too short: %d"); + return -0x7200; + } + pbVar6 = ssl->in_msg; + ssl->in_hslen = ((uint)pbVar6[1] << 0x10 | (uint)pbVar6[2] << 8 | (uint)pbVar6[3]) + uVar3; + mbedtls_debug_print_msg + (ssl,3,"file1",0xc2b,"handshake message: msglen = %d, type = %d, hslen = %d", + (uint)*pbVar6); + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + if (ssl->in_hslen <= ssl->in_msglen) { + return 0; + } + mbedtls_debug_print_msg(ssl,1,"file1",0xc69,"TLS handshake fragmentation not supported"); + return -0x7080; + } + pmVar4 = ssl->handshake; + __s1 = ssl->in_msg; + if (pmVar4 != (mbedtls_ssl_handshake_params *)0x0) { + uVar3 = (uint)(*(ushort *)(__s1 + 4) >> 8) | ((uint)*(ushort *)(__s1 + 4) & 0xff) << 8; + if (pmVar4->in_msg_seq != uVar3) { + __n_00 = pmVar4->in_flight_start_seq - 1; + if ((__n_00 != uVar3) || (*__s1 == '\x03')) { + mbedtls_debug_print_msg + (ssl,2,"file1",0xc4d, + "dropping out-of-sequence message: message_seq = %d, expected = %d", + pmVar4->in_msg_seq); + return -0x6900; + } + mbedtls_debug_print_msg + (ssl,2,"file1",0xc40, + "received message from last flight, message_seq = %d, start_of_flight = %d",__n_00) + ; + line = mbedtls_ssl_resend(ssl); + if (line == 0) { + return -0x6900; + } + format = "mbedtls_ssl_resend"; + line_00 = 0xc44; + goto LAB_2308cd52; + } + } + if (((ssl->in_hslen <= ssl->in_msglen) && (line = memcmp(__s1 + 6,&DAT_230c6db0,3), line == 0)) && + (line = memcmp(ssl->in_msg + 9,ssl->in_msg + 1,3), line == 0)) { + if (ssl->handshake == (mbedtls_ssl_handshake_params *)0x0) { + return 0; + } + if (ssl->handshake->hs_msg == (uchar *)0x0) { + return 0; + } + } + mbedtls_debug_print_msg(ssl,2,"file1",0xc5b,"found fragmented DTLS handshake message"); + sVar10 = ssl->in_hslen; + uVar3 = sVar10 - 0xc; + if (ssl->handshake == (mbedtls_ssl_handshake_params *)0x0) { + format = "not supported outside handshake (for now)"; + line = 0xb8f; +LAB_2308cdc0: + mbedtls_debug_print_msg(ssl,1,"file1",line,format); + line = -0x7080; + } + else { + __s1 = ssl->handshake->hs_msg; + if (__s1 != (uchar *)0x0) { + line = memcmp(__s1,ssl->in_msg,4); + if (line == 0) goto LAB_2308cebc; + mbedtls_debug_print_msg(ssl,1,"file1",0xbb9,"fragment header mismatch"); + goto LAB_2308cf3e; + } + mbedtls_debug_print_msg(ssl,2,"file1",0xb9b,"initialize reassembly, total length = %d",uVar3); + if (0x4000 < ssl->in_hslen) { + format = "handshake message too large"; + line = 0xb9f; + goto LAB_2308cdc0; + } + size = (uint)((uVar3 & 7) != 0) + (uVar3 >> 3) + sVar10; + pmVar4 = ssl->handshake; + __s1 = (uchar *)mycalloc(1,size); + pmVar4->hs_msg = __s1; + __s1 = ssl->handshake->hs_msg; + if (__s1 == (uchar *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0xba9,"alloc failed (%d bytes)",size); + line = -0x7f00; + goto LAB_2308cdd2; + } + memcpy(__s1,ssl->in_msg,6); + memset(ssl->handshake->hs_msg + 6,0,3); + __s1 = ssl->handshake->hs_msg; + memcpy(__s1 + 9,__s1 + 1,3); +LAB_2308cebc: + puVar13 = ssl->handshake->hs_msg; + __s1 = ssl->in_msg; + puVar11 = puVar13 + sVar10; + bVar1 = __s1[8]; + uVar9 = (uint)__s1[6] << 0x10 | (uint)__s1[7] << 8 | (uint)bVar1; + __n_00 = (uint)__s1[9] << 0x10 | (uint)__s1[10] << 8 | (uint)__s1[0xb]; + if (uVar3 < uVar9 + __n_00) { + mbedtls_debug_print_msg + (ssl,1,"file1",0xbce,"invalid fragment offset/len: %d + %d > %d",uVar9,__n_00,uVar3) + ; + } + else { + uVar12 = __n_00 + 0xc; + if (uVar12 <= ssl->in_msglen) { + mbedtls_debug_print_msg + (ssl,2,"file1",0xbda,"adding fragment, offset = %d, length = %d",uVar9,__n_00); + memcpy(puVar13 + uVar9 + 0xc,ssl->in_msg + 0xc,__n_00); + uVar5 = (uint)bVar1 & 7; + uVar8 = 8 - uVar5; + if (uVar8 == 8) { +LAB_2308d03c: + uVar5 = __n_00 & 7; + if (uVar5 != 0) { + uVar7 = __n_00 + uVar9; + uVar8 = (uint)puVar11[uVar7 >> 3]; + __n_00 = __n_00 - uVar5; + uVar5 = 8 - uVar5; + do { + uVar2 = uVar5 & 0x1f; + uVar5 = uVar5 + 1; + uVar8 = uVar8 | 1 << uVar2 & 0xffU; + } while (uVar5 != 8); + puVar11[uVar7 >> 3] = (byte)uVar8; + } + memset(puVar11 + (uVar9 >> 3),0xff,__n_00 >> 3); + } + else { + uVar7 = uVar9 >> 3; + if (uVar8 < __n_00) { + __n_00 = (__n_00 - 8) + uVar5; + uVar5 = (uint)puVar11[uVar7]; + uVar9 = uVar9 + uVar8; + do { + uVar8 = uVar8 - 1; + uVar5 = uVar5 | 1 << (uVar8 & 0x1f) & 0xffU; + } while (uVar8 != 0); + puVar11[uVar7] = (byte)uVar5; + goto LAB_2308d03c; + } + __n_00 = uVar8 - __n_00; + while (__n_00 != uVar8) { + uVar9 = __n_00 & 0x1f; + __n_00 = __n_00 + 1; + puVar11[uVar7] = (byte)(1 << uVar9) | puVar11[uVar7]; + } + } + __n_00 = 0; + while (__n_00 != uVar3 >> 3) { + if (puVar11[__n_00] != -1) goto LAB_2308d164; + __n_00 = __n_00 + 1; + } + uVar9 = 0; + while (uVar9 < (uVar3 & 7)) { + if (((int)(uint)puVar11[__n_00] >> (7 - uVar9 & 0x1f) & 1U) == 0) goto LAB_2308d164; + uVar9 = uVar9 + 1; + } + mbedtls_debug_print_msg(ssl,2,"file1",0xbe9,"handshake message completed"); + if (ssl->in_msglen <= uVar12) { + uVar3 = ssl->next_record_offset; + if (ssl->in_left <= uVar3) { +LAB_2308d0fc: + memcpy(ssl->in_msg,ssl->handshake->hs_msg,ssl->in_hslen); + vPortFree(ssl->handshake->hs_msg); + ssl->handshake->hs_msg = (uchar *)0x0; + mbedtls_debug_print_buf + (ssl,3,"file1",0xc15,"reassembled handshake message",ssl->in_msg,ssl->in_hslen + ); + return 0; + } + puVar13 = ssl->in_hdr; + __n = ssl->in_left - uVar3; + __s1 = ssl->in_msg + ssl->in_hslen; + puVar11 = __s1 + -(int)puVar13; + *(uchar **)&ssl->next_record_offset = puVar11; + *(uchar **)&ssl->in_left = puVar11 + __n; + if (puVar11 + __n <= (uchar *)(0x413d - (int)(puVar13 + -(int)ssl->in_buf))) { + memmove(__s1,puVar13 + uVar3,__n); + goto LAB_2308d0fc; + } + mbedtls_debug_print_msg(ssl,1,"file1",0xc08,"reassembled message too large for buffer"); + line = -0x6a00; + goto LAB_2308cdd2; + } + format = "last fragment not alone in its record"; + line = 0xbf2; + goto LAB_2308cdc0; + } + mbedtls_debug_print_msg(ssl,1,"file1",0xbd5,"invalid fragment length: %d + 12 > %d",__n_00); + } +LAB_2308cf3e: + line = -0x7200; + } +LAB_2308cdd2: + format = "ssl_reassemble_dtls_handshake"; + line_00 = 0xc5f; +LAB_2308cd52: + mbedtls_debug_print_ret(ssl,1,"file1",line_00,format,line); + return line; +LAB_2308d164: + mbedtls_debug_print_msg(ssl,2,"file1",0xbe5,"message is not complete yet"); + line = -0x6900; + goto LAB_2308cdd2; +} + + + +int mbedtls_ssl_handle_message_type(mbedtls_ssl_context *ssl) + +{ + int iVar1; + uchar *puVar2; + + if ((ssl->in_msgtype == 0x16) && (iVar1 = mbedtls_ssl_prepare_handshake_record(ssl), iVar1 != 0)) + { + return iVar1; + } + if (ssl->in_msgtype == 0x15) { + mbedtls_debug_print_msg + (ssl,2,"file1",0xf93,"got an alert message, type: [%d:%d]",(uint)*ssl->in_msg, + (uint)ssl->in_msg[1]); + puVar2 = ssl->in_msg; + if (*puVar2 == '\x02') { + mbedtls_debug_print_msg + (ssl,1,"file1",0xf9b,"is a fatal alert message (msg %d)",(uint)puVar2[1]); + return -0x7780; + } + if (*puVar2 == '\x01') { + if (puVar2[1] == '\0') { + mbedtls_debug_print_msg(ssl,2,"file1",0xfa2,"is a close notify message"); + return -0x7880; + } + if (puVar2[1] == 'd') { + mbedtls_debug_print_msg(ssl,2,"file1",0xfaa,"is a SSLv3 no_cert"); + goto LAB_2308d1a2; + } + } + iVar1 = -0x6680; + } + else { +LAB_2308d1a2: + iVar1 = 0; + } + return iVar1; +} + + + +int mbedtls_ssl_send_alert_message(mbedtls_ssl_context *ssl,uchar level,uchar message) + +{ + int ret; + + if ((ssl == (mbedtls_ssl_context *)0x0) || (ssl->conf == (mbedtls_ssl_config *)0x0)) { + ret = -0x7100; + } + else { + mbedtls_debug_print_msg(ssl,2,"file1",0xfda,"=> send alert message"); + ssl->out_msgtype = 0x15; + ssl->out_msglen = 2; + *ssl->out_msg = level; + ssl->out_msg[1] = message; + ret = mbedtls_ssl_write_record(ssl); + if (ret == 0) { + mbedtls_debug_print_msg(ssl,2,"file1",0xfe7,"<= send alert message"); + } + else { + mbedtls_debug_print_ret(ssl,1,"file1",0xfe3,"mbedtls_ssl_write_record",ret); + } + } + return ret; +} + + + +int mbedtls_ssl_send_fatal_handshake_failure(mbedtls_ssl_context *ssl) + +{ + int iVar1; + + iVar1 = mbedtls_ssl_send_alert_message(ssl,'\x02','('); + return iVar1; +} + + + +int mbedtls_ssl_write_certificate(mbedtls_ssl_context *ssl) + +{ + int ret; + mbedtls_x509_crt *crt; + size_t sVar1; + uint __n; + mbedtls_ssl_ciphersuite_t *pmVar2; + + pmVar2 = ssl->transform_negotiate->ciphersuite_info; + mbedtls_debug_print_msg(ssl,2,"file1",0x1025,"=> write certificate"); + __n = (uint)pmVar2->key_exchange - 5; + if (((__n & 0xff) < 7) && ((0x4bU >> (__n & 0x1f) & 1) != 0)) { + mbedtls_debug_print_msg(ssl,2,"file1",0x102c,"<= skip write certificate"); + ret = 0; + ssl->state = ssl->state + 1; + } + else { + if ((*(ushort *)&ssl->conf->field_0x74 & 1) == 0) { + if (ssl->client_auth == 0) { + mbedtls_debug_print_msg(ssl,2,"file1",0x1036,"<= skip write certificate"); + ssl->state = ssl->state + 1; + return 0; + } + } + else { + crt = mbedtls_ssl_own_cert(ssl); + if (crt == (mbedtls_x509_crt *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x1053,"got no certificate to send"); + return -0x7580; + } + } + crt = mbedtls_ssl_own_cert(ssl); + mbedtls_debug_print_crt(ssl,3,"file1",0x1059,"own certificate",crt); + crt = mbedtls_ssl_own_cert(ssl); + sVar1 = 7; + while (crt != (mbedtls_x509_crt *)0x0) { + __n = (crt->raw).len; + if (0x3ffd - sVar1 < __n) { + mbedtls_debug_print_msg(ssl,1,"file1",0x106d,"certificate too large, %d > %d",0x4000); + return -0x7500; + } + ssl->out_msg[sVar1] = (uchar)(__n >> 0x10); + ssl->out_msg[sVar1 + 1] = (uchar)(__n >> 8); + ssl->out_msg[sVar1 + 2] = (uchar)__n; + memcpy(ssl->out_msg + sVar1 + 3,(crt->raw).p,__n); + crt = crt->next; + sVar1 = sVar1 + 3 + __n; + } + ret = sVar1 - 7; + ssl->out_msg[4] = (uchar)((uint)ret >> 0x10); + ssl->out_msg[5] = (uchar)((uint)ret >> 8); + ssl->out_msg[6] = (uchar)ret; + ssl->out_msgtype = 0x16; + ssl->out_msglen = sVar1; + *ssl->out_msg = '\v'; + ssl->state = ssl->state + 1; + ret = mbedtls_ssl_write_record(ssl); + if (ret == 0) { + mbedtls_debug_print_msg(ssl,2,"file1",0x108d,"<= write certificate"); + } + else { + mbedtls_debug_print_ret(ssl,1,"file1",0x1089,"mbedtls_ssl_write_record",ret); + } + } + return ret; +} + + + +int mbedtls_ssl_write_change_cipher_spec(mbedtls_ssl_context *ssl) + +{ + int ret; + + mbedtls_debug_print_msg(ssl,2,"file1",0x11b4,"=> write change cipher spec"); + ssl->out_msgtype = 0x14; + ssl->out_msglen = 1; + *ssl->out_msg = '\x01'; + ssl->state = ssl->state + 1; + ret = mbedtls_ssl_write_record(ssl); + if (ret == 0) { + mbedtls_debug_print_msg(ssl,2,"file1",0x11c2,"<= write change cipher spec"); + } + else { + mbedtls_debug_print_ret(ssl,1,"file1",0x11be,"mbedtls_ssl_write_record",ret); + } + return ret; +} + + + +int mbedtls_ssl_write_finished(mbedtls_ssl_context *ssl) + +{ + uchar *puVar1; + uchar uVar2; + int ret; + + mbedtls_debug_print_msg(ssl,2,"file1",0x1408,"=> write finished"); + puVar1 = ssl->out_iv; + if (1 < ssl->minor_ver) { + puVar1 = puVar1 + (ssl->transform_negotiate->ivlen - ssl->transform_negotiate->fixed_ivlen); + } + ssl->out_msg = puVar1; + (*ssl->handshake->calc_finished)(ssl,puVar1 + 4,*(uint *)&ssl->conf->field_0x74 & 1); + ret = 0x24; + if (ssl->minor_ver != 0) { + ret = 0xc; + } + ssl->out_msglen = ret + 4; + ssl->out_msgtype = 0x16; + *ssl->out_msg = '\x14'; + if (ssl->handshake->resume == 0) { + ret = ssl->state + 1; + } + else { + if (((*(ushort *)&ssl->conf->field_0x74 & 1) == 0) && + (ssl->state = 0xf, (*(ushort *)&ssl->conf->field_0x74 & 1) == 0)) goto LAB_2308d646; + ret = 10; + } + ssl->state = ret; +LAB_2308d646: + mbedtls_debug_print_msg(ssl,3,"file1",0x143e,"switching to new transform spec for outbound data"); + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + memset(ssl->out_ctr,0,8); + } + else { + ssl->handshake->alt_transform_out = ssl->transform_out; + memcpy(ssl->handshake->alt_out_ctr,ssl->out_ctr,8); + memset(ssl->out_ctr + 2,0,6); + uVar2 = ssl->out_ctr[1] + '\x01'; + ssl->out_ctr[1] = uVar2; + if ((uVar2 == '\0') && (uVar2 = *ssl->out_ctr + '\x01', *ssl->out_ctr = uVar2, uVar2 == '\0')) { + mbedtls_debug_print_msg(ssl,1,"file1",0x1454,"DTLS epoch would wrap"); + return -0x6b80; + } + } + ssl->transform_out = ssl->transform_negotiate; + ssl->session_out = ssl->session_negotiate; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + mbedtls_ssl_send_flight_completed(ssl); + } + ret = mbedtls_ssl_write_record(ssl); + if (ret == 0) { + mbedtls_debug_print_msg(ssl,2,"file1",0x1475,"<= write finished"); + } + else { + mbedtls_debug_print_ret(ssl,1,"file1",0x1471,"mbedtls_ssl_write_record",ret); + } + return ret; +} + + + +int mbedtls_ssl_write(mbedtls_ssl_context *ssl,uchar *buf,size_t len) + +{ + size_t sVar1; + int line; + size_t sVar2; + uint uVar3; + char *text; + + mbedtls_debug_print_msg(ssl,2,"file1",0x1b3d,"=> write"); + if ((ssl == (mbedtls_ssl_context *)0x0) || (ssl->conf == (mbedtls_ssl_config *)0x0)) { + return -0x7100; + } + if ((ssl->state != 0x10) && (line = mbedtls_ssl_handshake(ssl), line != 0)) { + mbedtls_debug_print_ret(ssl,1,"file1",0x1b4e,"mbedtls_ssl_handshake",line); + return line; + } + sVar2 = mbedtls_ssl_get_max_frag_len(ssl); + sVar1 = len; + if ((sVar2 < len) && (sVar1 = sVar2, (*(ushort *)&ssl->conf->field_0x74 & 2) != 0)) { + text = "fragment larger than the (negotiated) maximum fragment length: %d > %d"; + line = 0x1ae7; +LAB_2308d7f8: + mbedtls_debug_print_msg(ssl,1,"file1",line,text,len,sVar2); + len = 0xffff8f00; + } + else { + len = sVar1; + if (ssl->out_left == 0) { + sVar2 = 0x4130; + if (0x4130 < len) { + text = "input larger than the out msg maximum length: 0x%x > 0x%x"; + line = 0x1afe; + goto LAB_2308d7f8; + } + ssl->out_msgtype = 0x17; + ssl->out_msglen = len; + memcpy(ssl->out_msg,buf,len); + uVar3 = mbedtls_ssl_write_record(ssl); + if (uVar3 == 0) goto LAB_2308d80a; + text = "mbedtls_ssl_write_record"; + line = 0x1b08; + len = uVar3; + } + else { + uVar3 = mbedtls_ssl_flush_output(ssl); + if (uVar3 == 0) goto LAB_2308d80a; + text = "mbedtls_ssl_flush_output"; + line = 0x1af4; + len = uVar3; + } + mbedtls_debug_print_ret(ssl,1,"file1",line,text,len); + } +LAB_2308d80a: + mbedtls_debug_print_msg(ssl,2,"file1",0x1b59,"<= write"); + return len; +} + + + +void mbedtls_ssl_read_version(int *major,int *minor,int transport,uchar *ver) + +{ + uint uVar1; + + if (transport == 1) { + *major = 0x101 - (uint)*ver; + uVar1 = 0x100 - (uint)ver[1]; + if (uVar1 == 1) { + uVar1 = 2; + } + } + else { + *major = (uint)*ver; + uVar1 = (uint)ver[1]; + } + *minor = uVar1; + return; +} + + + +int mbedtls_ssl_read_record_layer(mbedtls_ssl_context *ssl) + +{ + bool bVar1; + size_t nb_want; + size_t len; + uint uVar2; + uint uVar3; + uint uVar4; + size_t __n; + uint uVar5; + int line; + mbedtls_cipher_info_t *pmVar6; + mbedtls_cipher_mode_t mVar7; + byte bVar8; + char *format; + uchar uVar9; + mbedtls_ssl_transform *pmVar10; + byte *pbVar11; + uint uVar12; + uint uVar13; + int line_00; + uint ret; + uchar *input; + uint uVar14; + size_t *in_fa0; + uchar *in_fa1; + size_t in_fa2; + size_t sStack116; + int major_ver; + int minor_ver; + uchar auStack103 [2]; + undefined uStack101; + undefined uStack100; + + uVar4 = ssl->in_hslen; + if ((uVar4 == 0) || (ssl->in_msglen <= uVar4)) { + ssl->in_hslen = 0; + while( true ) { + nb_want = mbedtls_ssl_hdr_len(); + line_00 = mbedtls_ssl_fetch_input(ssl,nb_want); + if (line_00 != 0) break; + nb_want = mbedtls_ssl_hdr_len(); + mbedtls_debug_print_buf(ssl,4,"file1",0xdb1,"input record header",ssl->in_hdr,nb_want); + ssl->in_msgtype = (uint)*ssl->in_hdr; + ssl->in_msglen = + (uint)(*(ushort *)ssl->in_len >> 8) | ((uint)*(ushort *)ssl->in_len & 0xff) << 8; + mbedtls_ssl_read_version + ((int *)&sStack116,&major_ver,*(uint *)&ssl->conf->field_0x74 >> 1 & 1, + ssl->in_hdr + 1); + mbedtls_debug_print_msg + (ssl,3,"file1",0xdba,"input record: msgtype = %d, version = [%d:%d], msglen = %d", + ssl->in_msgtype,sStack116,major_ver); + line_00 = ssl->in_msgtype; + if (line_00 - 0x14U < 4) { + if (ssl->major_ver != sStack116) { + format = "major version mismatch"; + line_00 = 0xdd1; +LAB_2308daaa: + mbedtls_debug_print_msg(ssl,1,"file1",line_00,format); + goto LAB_2308da56; + } + if ((int)(uint)ssl->conf->max_minor_ver < major_ver) { + format = "minor version mismatch"; + line_00 = 0xdd7; + goto LAB_2308daaa; + } + uVar4 = ssl->in_msglen; + if (0x413dU - (int)(ssl->in_msg + -(int)ssl->in_buf) < uVar4) { + format = "bad message length"; + line_00 = 0xddf; + goto LAB_2308daaa; + } + if (ssl->transform_in != (mbedtls_ssl_transform *)0x0) { + ret = ssl->transform_in->minlen; + if (uVar4 < ret) { + format = "bad message length"; + line_00 = 0xdf1; + } + else { + if ((ssl->minor_ver < 1) || (uVar4 <= ret + 0x4100)) goto LAB_2308db3e; + format = "bad message length"; + line_00 = 0xe06; + } + goto LAB_2308daaa; + } + if (0x3fff < uVar4 - 1) { + format = "bad message length"; + line_00 = 0xde9; + goto LAB_2308daaa; + } +LAB_2308db3e: + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + if (line_00 == 0x14) { + if ((ssl->state - 10U & 0xfffffffd) != 0) { + format = "dropping unexpected ChangeCipherSpec"; + line_00 = 0xe1c; + goto LAB_2308db84; + } +LAB_2308dbb4: + if ((((uint)*(ushort *)ssl->in_ctr & 0xff) << 8 | (uint)(*(ushort *)ssl->in_ctr >> 8)) + == (uint)ssl->in_epoch) goto LAB_2308dbd8; + mbedtls_debug_print_msg + (ssl,1,"file1",0xe33,"record from another epoch: expected %d, received %d"); + } + else { + if ((line_00 != 0x17) || (ssl->state == 0x10)) goto LAB_2308dbb4; + format = "dropping unexpected ApplicationData"; + line_00 = 0xe2a; +LAB_2308db84: + mbedtls_debug_print_msg(ssl,1,"file1",line_00,format); + } + line_00 = -0x6700; + goto LAB_2308da5c; + } +LAB_2308dbd8: + nb_want = mbedtls_ssl_hdr_len(); + line_00 = mbedtls_ssl_fetch_input(ssl,nb_want + uVar4); + if (line_00 != 0) { + format = "mbedtls_ssl_fetch_input"; + line = 0xf11; + goto LAB_2308d996; + } + nb_want = ssl->in_msglen; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + ssl->in_left = 0; + } + else { + len = mbedtls_ssl_hdr_len(); + ssl->next_record_offset = len + nb_want; + } + len = mbedtls_ssl_hdr_len(); + mbedtls_debug_print_buf + (ssl,4,"file1",0xe63,"input record from network",ssl->in_hdr,len + nb_want); + if (ssl->transform_in == (mbedtls_ssl_transform *)0x0) { +LAB_2308e274: + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + return 0; + } + if (ssl->handshake == (mbedtls_ssl_handshake_params *)0x0) { + return 0; + } + if (ssl->state != 0x10) { + return 0; + } + if ((ssl->in_msgtype != 0x16) || (*ssl->in_msg != '\x14')) { + ssl_handshake_wrapup_free_hs_transform(ssl); + return 0; + } + mbedtls_debug_print_msg(ssl,2,"file1",0xf6d,"received retransmit of last flight"); + line_00 = mbedtls_ssl_resend(ssl); + if (line_00 == 0) { + return -0x6900; + } + format = "mbedtls_ssl_resend"; + line = 0xf71; + goto LAB_2308d996; + } + mbedtls_debug_print_msg(ssl,2,"file1",0x642,"=> decrypt buf"); + if ((ssl->session_in == (mbedtls_ssl_session *)0x0) || + (pmVar10 = ssl->transform_in, pmVar10 == (mbedtls_ssl_transform *)0x0)) { + line_00 = 0x646; +LAB_2308dc82: + mbedtls_debug_print_msg(ssl,1,"file1",line_00,"should never happen"); + ret = 0xffff9400; +LAB_2308e052: + mbedtls_debug_print_ret(ssl,1,"file1",0xe79,"ssl_decrypt_buf",ret); + } + else { + pmVar6 = (pmVar10->cipher_ctx_dec).cipher_info; + mVar7 = MBEDTLS_MODE_NONE; + if (pmVar6 != (mbedtls_cipher_info_t *)0x0) { + mVar7 = pmVar6->mode; + } + nb_want = ssl->in_msglen; + if (nb_want < pmVar10->minlen) { + format = "in_msglen (%d) < minlen (%d)"; + line_00 = 0x64f; +LAB_2308dcc2: + mbedtls_debug_print_msg(ssl,1,"file1",line_00,format,nb_want); +LAB_2308de20: + ret = 0xffff8e80; + goto LAB_2308e052; + } + if ((mVar7 + ~MBEDTLS_MODE_CTR & 0xfd) != 0) { + if (mVar7 == MBEDTLS_MODE_CBC) { + major_ver = 0; + ret = pmVar10->ivlen; + uVar4 = ret; + if (ssl->minor_ver < 2) { + uVar4 = 0; + } + if ((nb_want < uVar4 + ret) || (nb_want < pmVar10->maclen + 1 + uVar4)) { + format = "msglen (%d) < max( ivlen(%d), maclen (%d) + 1 ) ( + expl IV )"; + line_00 = 0x6d2; + goto LAB_2308dd08; + } + uVar4 = nb_want % ret; + if (uVar4 != 0) { + format = "msglen (%d) %% ivlen (%d) != 0"; + line_00 = 0x70b; + goto LAB_2308dcc2; + } + input = ssl->in_msg; + if (1 < ssl->minor_ver) { + nb_want = nb_want - ret; + ssl->in_msglen = nb_want; + ret = 0; + while (ret < ssl->transform_in->ivlen) { + ssl->transform_in->iv_dec[ret] = ssl->in_iv[ret]; + ret = ret + 1; + } + } + pmVar10 = ssl->transform_in; + ret = mbedtls_cipher_crypt + (&pmVar10->cipher_ctx_dec,pmVar10->iv_dec,pmVar10->ivlen,input,nb_want + ,input,(size_t *)&major_ver); + if (ret != 0) { + mbedtls_debug_print_ret(ssl,1,"file1",0x723,"mbedtls_cipher_crypt",ret); + goto LAB_2308e052; + } + if (nb_want == major_ver) { + uVar5 = ssl->in_msglen; + nb_want = ssl->transform_in->maclen; + uVar13 = (uint)ssl->in_msg[uVar5 - 1] + 1; + bVar1 = uVar13 + nb_want <= uVar5; + if (!bVar1) { + uVar13 = 0; + } + if (0 < ssl->minor_ver) { + uVar2 = (uVar5 - 1) - uVar13; + uVar12 = ((uint)(uVar5 < uVar13 + 1) ^ 1) & (uint)(uVar2 < nb_want + 0x4000) & + (uint)bVar1; + uVar14 = 1; + uVar3 = 1; + do { + uVar14 = uVar14 & ((uint)(uVar13 < uVar3) ^ 1); + line_00 = uVar2 * uVar12 + uVar3; + uVar3 = uVar3 + 1; + uVar4 = uVar4 + ((uint)ssl->in_msg[line_00] == uVar13 - 1) * uVar14; + } while (uVar3 != 0x101); + uVar12 = uVar13 == uVar4 & uVar12; + uVar13 = uVar12 * 0x1ff & uVar13; + ssl->in_msglen = uVar5 - uVar13; + goto LAB_2308de42; + } + line_00 = 0x783; + } + else { + line_00 = 0x729; + } + } + else { + line_00 = 0x78d; + } + goto LAB_2308dc82; + } + len = 8; + if ((pmVar10->ciphersuite_info->flags & 2) == 0) { + len = 0x10; + } + if (nb_want < (pmVar10->ivlen - pmVar10->fixed_ivlen) + len) { + format = "msglen (%d) < explicit_iv_len (%d) + taglen (%d)"; + line_00 = 0x67f; +LAB_2308dd08: + mbedtls_debug_print_msg(ssl,1,"file1",line_00,format,nb_want); + goto LAB_2308de20; + } + nb_want = ((nb_want + pmVar10->fixed_ivlen) - pmVar10->ivlen) - len; + ssl->in_msglen = nb_want; + input = ssl->in_msg; + memcpy(&major_ver,ssl->in_ctr,8); + mbedtls_ssl_write_version + (ssl->major_ver,ssl->minor_ver,*(uint *)&ssl->conf->field_0x74 >> 1 & 1, + auStack103); + uStack101 = (undefined)(ssl->in_msglen >> 8); + uStack100 = (undefined)ssl->in_msglen; + mbedtls_debug_print_buf + (ssl,4,"file1",0x690,"additional data used for AEAD",(uchar *)&major_ver,0xd); + pmVar10 = ssl->transform_in; + memcpy(pmVar10->iv_dec + pmVar10->fixed_ivlen,ssl->in_iv, + pmVar10->ivlen - pmVar10->fixed_ivlen); + mbedtls_debug_print_buf + (ssl,4,"file1",0x697,"IV used",ssl->transform_in->iv_dec, + ssl->transform_in->ivlen); + mbedtls_debug_print_buf(ssl,4,"file1",0x698,"TAG used",input + nb_want,len); + pmVar10 = ssl->transform_in; + ret = mbedtls_cipher_auth_decrypt + (&pmVar10->cipher_ctx_dec,pmVar10->iv_dec,pmVar10->ivlen, + (uchar *)&major_ver,0xd,input,nb_want,input,in_fa0,in_fa1,in_fa2); + if (ret != 0) { + mbedtls_debug_print_ret(ssl,1,"file1",0x6a5,"mbedtls_cipher_auth_decrypt",ret); + if (ret == 0xffff9d00) goto LAB_2308de20; + goto LAB_2308e052; + } + if (nb_want != sStack116) { + line_00 = 0x6b0; + goto LAB_2308dc82; + } + uVar12 = 1; + uVar13 = 0; + ret = 1; +LAB_2308de42: + mbedtls_debug_print_buf + (ssl,4,"file1",0x792,"raw buffer after decryption",ssl->in_msg,ssl->in_msglen); + if (ret == 0) { + nb_want = ssl->in_msglen - ssl->transform_in->maclen; + ssl->in_msglen = nb_want; + *ssl->in_len = (uchar)(nb_want >> 8); + ssl->in_len[1] = (uchar)ssl->in_msglen; + memcpy(&major_ver,ssl->in_msg + ssl->in_msglen,ssl->transform_in->maclen); + if (ssl->minor_ver < 1) { + line_00 = 0x7d6; + goto LAB_2308dc82; + } + uVar4 = ssl->in_msglen + 0x15; + mbedtls_md_hmac_update(&ssl->transform_in->md_ctx_dec,ssl->in_ctr,8); + mbedtls_md_hmac_update(&ssl->transform_in->md_ctx_dec,ssl->in_hdr,3); + mbedtls_md_hmac_update(&ssl->transform_in->md_ctx_dec,ssl->in_len,2); + mbedtls_md_hmac_update(&ssl->transform_in->md_ctx_dec,ssl->in_msg,ssl->in_msglen); + mbedtls_md_hmac_finish(&ssl->transform_in->md_ctx_dec,ssl->in_msg + ssl->in_msglen); + ret = 0; + do { + mbedtls_md_process(&ssl->transform_in->md_ctx_dec,ssl->in_msg); + ret = ret + 1; + } while (ret < (uVar12 * 0xff & (uVar13 + uVar4 >> 6) - (uVar4 >> 6)) + 1); + mbedtls_md_hmac_reset(&ssl->transform_in->md_ctx_dec); + mbedtls_debug_print_buf + (ssl,4,"file1",0x7da,"message mac",(uchar *)&major_ver, + ssl->transform_in->maclen); + mbedtls_debug_print_buf + (ssl,4,"file1",0x7dc,"computed mac",ssl->in_msg + ssl->in_msglen, + ssl->transform_in->maclen); + bVar8 = 0; + nb_want = 0; + while (ssl->transform_in->maclen != nb_want) { + line_00 = ssl->in_msglen + nb_want; + pbVar11 = (byte *)((int)&major_ver + nb_want); + nb_want = nb_want + 1; + bVar8 = bVar8 | ssl->in_msg[line_00] ^ *pbVar11; + } + if ((bVar8 != 0) || (uVar12 == 0)) goto LAB_2308de20; + } + if (ssl->in_msglen == 0) { + line_00 = ssl->nb_zero + 1; + ssl->nb_zero = line_00; + if (3 < line_00) { + mbedtls_debug_print_msg + (ssl,1,"file1",0x802, + "received four consecutive empty messages, possible DoS attack"); + goto LAB_2308de20; + } + } + else { + ssl->nb_zero = 0; + } + uVar4 = 8; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + do { + ret = uVar4; + if (ret <= ((uint)*(ushort *)&ssl->conf->field_0x74 & 2)) break; + uVar9 = ssl->in_ctr[ret - 1] + '\x01'; + ssl->in_ctr[ret - 1] = uVar9; + uVar4 = ret - 1; + } while (uVar9 == '\0'); + if (ret == ((uint)*(ushort *)&ssl->conf->field_0x74 & 2)) { + mbedtls_debug_print_msg(ssl,1,"file1",0x818,"incoming message counter would wrap"); + ret = 0xffff9480; + goto LAB_2308e052; + } + } + mbedtls_debug_print_msg(ssl,2,"file1",0x81d,"<= decrypt buf"); + mbedtls_debug_print_buf + (ssl,4,"file1",0xe7e,"input payload after decrypt",ssl->in_msg,ssl->in_msglen); + if (ssl->in_msglen < 0x4001) goto LAB_2308e274; + mbedtls_debug_print_msg(ssl,1,"file1",0xe82,"bad message length"); + ret = 0xffff8e00; + } + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + return ret; + } + if ((ret & 0xffffff7f) != 0xffff8e00) { + return ret; + } + if ((ssl->state - 0xbU & 0xfffffffd) == 0) { + return ret; + } + format = "discarding invalid record (mac)"; + line_00 = 0xf40; + } + else { + mbedtls_debug_print_msg(ssl,1,"file1",0xdc2,"unknown record type"); + line_00 = mbedtls_ssl_send_alert_message(ssl,'\x02','\n'); + if (line_00 == 0) { +LAB_2308da56: + line_00 = -0x7200; + } +LAB_2308da5c: + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + return line_00; + } + if (line_00 == -0x6780) { + return -0x6780; + } + if (line_00 == -0x6700) { + nb_want = mbedtls_ssl_hdr_len(); + format = "discarding unexpected record (header)"; + ssl->next_record_offset = nb_want + ssl->in_msglen; + line_00 = 0xef8; + } + else { + ssl->next_record_offset = 0; + ssl->in_left = 0; + format = "discarding invalid record (header)"; + line_00 = 0xf01; + } + } + mbedtls_debug_print_msg(ssl,1,"file1",line_00,format); + } + format = "mbedtls_ssl_fetch_input"; + line = 0xee7; +LAB_2308d996: + mbedtls_debug_print_ret(ssl,1,"file1",line,format,line_00); + } + else { + __n = ssl->in_msglen - uVar4; + ssl->in_msglen = __n; + line_00 = 0; + memmove(ssl->in_msg,ssl->in_msg + uVar4,__n); + mbedtls_debug_print_buf + (ssl,4,"file1",0xed7,"remaining content in record",ssl->in_msg,ssl->in_msglen); + } + return line_00; +} + + + +int mbedtls_ssl_read_record(mbedtls_ssl_context *ssl) + +{ + int ret; + int line; + char *text; + + mbedtls_debug_print_msg(ssl,2,"file1",0xeaa,"=> read record"); + do { + ret = mbedtls_ssl_read_record_layer(ssl); + if (ret != 0) { + text = "mbedtls_ssl_read_record_layer"; + line = 0xeb0; + goto LAB_2308e336; + } + ret = mbedtls_ssl_handle_message_type(ssl); + } while (ret == -0x6680); + if (ret == 0) { + if (ssl->in_msgtype == 0x16) { + mbedtls_ssl_update_handshake_status(ssl); + } + mbedtls_debug_print_msg(ssl,2,"file1",0xec3,"<= read record"); + } + else { + text = "mbedtls_ssl_handle_message_type"; + line = 0xeba; +LAB_2308e336: + mbedtls_debug_print_ret(ssl,1,"file1",line,text,ret); + } + return ret; +} + + + +int mbedtls_ssl_parse_certificate(mbedtls_ssl_context *ssl) + +{ + mbedtls_key_exchange_type_t mVar1; + ushort uVar2; + uint uVar3; + mbedtls_ssl_session *pmVar4; + mbedtls_x509_crt *crt; + mbedtls_x509_crl *ca_crl; + int ret; + int line; + mbedtls_ssl_config *pmVar5; + char *text; + uchar *puVar6; + uint uVar7; + mbedtls_ssl_ciphersuite_t *ciphersuite; + + ciphersuite = ssl->transform_negotiate->ciphersuite_info; + uVar3 = *(uint *)&ssl->conf->field_0x74; + mbedtls_debug_print_msg(ssl,2,"file1",0x1099,"=> parse certificate"); + mVar1 = ciphersuite->key_exchange; + uVar7 = (uint)mVar1 - 5; + if (((uVar7 & 0xff) < 7) && ((0x4bU >> (uVar7 & 0x1f) & 1) != 0)) { + ret = 0x10a0; +LAB_2308e40c: + mbedtls_debug_print_msg(ssl,2,"file1",ret,"<= skip parse certificate"); + ssl->state = ssl->state + 1; + return 0; + } + uVar2 = *(ushort *)&ssl->conf->field_0x74; + if (((uVar2 & 1) != 0) && (mVar1 == MBEDTLS_KEY_EXCHANGE_RSA_PSK)) { + ret = 0x10a9; + goto LAB_2308e40c; + } + uVar7 = ssl->handshake->sni_authmode; + if (uVar7 == 3) { + uVar7 = uVar3 >> 2 & 3; + } + if (((uVar2 & 1) != 0) && (uVar7 == 0)) { + ssl->session_negotiate->verify_result = 0x80; + ret = 0x10b7; + goto LAB_2308e40c; + } + ret = mbedtls_ssl_read_record(ssl); + if (ret != 0) { + text = "mbedtls_ssl_read_record"; + line = 0x10bf; + goto LAB_2308e49e; + } + ssl->state = ssl->state + 1; + uVar2 = *(ushort *)&ssl->conf->field_0x74; + if (((uVar2 & 1) == 0) || (ssl->minor_ver == 0)) { +LAB_2308e550: + if (ssl->in_msgtype != 0x16) { +LAB_2308e4de: + mbedtls_debug_print_msg(ssl,1,"file1",0x10f6,"bad certificate message"); + return -0x7700; + } + } + else { + ret = 4; + if ((uVar2 & 2) != 0) { + ret = 0xc; + } + if (ssl->in_hslen != ret + 3U) goto LAB_2308e550; + if (ssl->in_msgtype != 0x16) goto LAB_2308e4de; + if (*ssl->in_msg == '\v') { + ret = memcmp(ssl->in_msg + ret,&DAT_230c6db0,3); + if (ret == 0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x10e7,"TLSv1 client has no certificate"); + ssl->session_negotiate->verify_result = 0x40; + if (uVar7 == 1) { + return 0; + } + return -0x7480; + } + goto LAB_2308e550; + } + } + if (*ssl->in_msg == '\v') { + ret = 4; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + ret = 0xc; + } + if (ret + 6U <= ssl->in_hslen) { + puVar6 = ssl->in_msg + ret; + if ((*puVar6 == '\0') && + (uVar3 = ret + 3, ssl->in_hslen == CONCAT11(puVar6[1],puVar6[2]) + uVar3)) { + crt = ssl->session_negotiate->peer_cert; + if (crt != (mbedtls_x509_crt *)0x0) { + mbedtls_x509_crt_free(crt); + vPortFree(ssl->session_negotiate->peer_cert); + } + pmVar4 = ssl->session_negotiate; + crt = (mbedtls_x509_crt *)mycalloc(1,0x134); + pmVar4->peer_cert = crt; + if (crt == (mbedtls_x509_crt *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x111a,"alloc(%d bytes) failed",0x134); + return -0x7f00; + } + ret = 0; + mbedtls_x509_crt_init(ssl->session_negotiate->peer_cert); + do { + if (ssl->in_hslen <= uVar3) { + mbedtls_debug_print_crt + (ssl,3,"file1",0x113f,"peer certificate",ssl->session_negotiate->peer_cert); + if (uVar7 != 0) { + pmVar5 = ssl->conf; + crt = ssl->handshake->sni_ca_chain; + if (crt == (mbedtls_x509_crt *)0x0) { + crt = pmVar5->ca_chain; + ca_crl = pmVar5->ca_crl; + if (crt == (mbedtls_x509_crt *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x116f,"got no CA chain"); + return -0x7680; + } + } + else { + ca_crl = ssl->handshake->sni_ca_crl; + } + ret = mbedtls_x509_crt_verify_with_profile + (ssl->session_negotiate->peer_cert,crt,ca_crl,pmVar5->cert_profile, + ssl->hostname,&ssl->session_negotiate->verify_result, + (anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *) + pmVar5->f_vrfy,pmVar5->p_vrfy); + if (ret != 0) { + mbedtls_debug_print_ret(ssl,1,"file1",0x1180,"x509_verify_cert",ret); + } + crt = ssl->session_negotiate->peer_cert; + line = mbedtls_pk_can_do(&crt->pk,MBEDTLS_PK_ECKEY); + if (((line != 0) && + (line = mbedtls_ssl_check_curve(ssl,*(mbedtls_ecp_group_id *)(crt->pk).pk_ctx), + line != 0)) && + (mbedtls_debug_print_msg(ssl,1,"file1",0x118f,"bad certificate (EC key curve)"), + ret == 0)) { + ret = -0x7a00; + } + line = mbedtls_ssl_check_cert_usage + (ssl->session_negotiate->peer_cert,ciphersuite, + ~(uint)*(ushort *)&ssl->conf->field_0x74 & 1, + &ssl->session_negotiate->verify_result); + if ((line != 0) && + (mbedtls_debug_print_msg(ssl,1,"file1",0x119b,"bad certificate (usage extensions)") + , ret == 0)) { + ret = -0x7a00; + } + if (uVar7 == 1) { + ret = 0; + } + } + mbedtls_debug_print_msg(ssl,2,"file1",0x11a4,"<= parse certificate"); + return ret; + } + puVar6 = ssl->in_msg + uVar3; + if (*puVar6 != '\0') { + ret = 0x1126; + goto LAB_2308e58c; + } + uVar2 = CONCAT11(puVar6[1],puVar6[2]); + ret = uVar3 + 3; + if ((uVar2 < 0x80) || (uVar3 = (uint)uVar2 + ret, ssl->in_hslen < uVar3)) { + ret = 0x1130; + goto LAB_2308e58c; + } + ret = mbedtls_x509_crt_parse_der + (ssl->session_negotiate->peer_cert,ssl->in_msg + ret,(uint)uVar2); + } while ((ret == 0) || (ret == -0x262e)); + text = " mbedtls_x509_crt_parse_der"; + line = 0x1138; +LAB_2308e49e: + mbedtls_debug_print_ret(ssl,1,"file1",line,text,ret); + return ret; + } + ret = 0x110b; + goto LAB_2308e58c; + } + } + ret = 0x10fd; +LAB_2308e58c: + mbedtls_debug_print_msg(ssl,1,"file1",ret,"bad certificate message"); + return -0x7a00; +} + + + +int mbedtls_ssl_parse_change_cipher_spec(mbedtls_ssl_context *ssl) + +{ + int ret; + uint uVar1; + uchar *puVar2; + + mbedtls_debug_print_msg(ssl,2,"file1",0x11cb,"=> parse change cipher spec"); + ret = mbedtls_ssl_read_record(ssl); + if (ret == 0) { + if (ssl->in_msgtype == 0x14) { + if ((ssl->in_msglen == 1) && (*ssl->in_msg == '\x01')) { + mbedtls_debug_print_msg + (ssl,3,"file1",0x11e3,"switching to new transform spec for inbound data"); + ssl->transform_in = ssl->transform_negotiate; + ssl->session_in = ssl->session_negotiate; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + memset(ssl->in_ctr,0,8); + } + else { + uVar1 = (uint)ssl->in_epoch + 1; + ssl->in_epoch = (uint16_t)(uVar1 * 0x10000 >> 0x10); + if ((uVar1 & 0xffff) == 0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x11f1,"DTLS epoch would wrap"); + return -0x6b80; + } + } + puVar2 = ssl->in_iv; + if (1 < ssl->minor_ver) { + puVar2 = puVar2 + (ssl->transform_negotiate->ivlen - ssl->transform_negotiate->fixed_ivlen + ); + } + ssl->in_msg = puVar2; + ssl->state = ssl->state + 1; + mbedtls_debug_print_msg(ssl,2,"file1",0x1211,"<= parse change cipher spec"); + } + else { + mbedtls_debug_print_msg(ssl,1,"file1",0x11db,"bad change cipher spec message"); + ret = -0x7e00; + } + } + else { + mbedtls_debug_print_msg(ssl,1,"file1",0x11d5,"bad change cipher spec message"); + ret = -0x7700; + } + } + else { + mbedtls_debug_print_ret(ssl,1,"file1",0x11cf,"mbedtls_ssl_read_record",ret); + } + return ret; +} + + + +int mbedtls_ssl_parse_finished(mbedtls_ssl_context *ssl) + +{ + byte *pbVar1; + int line; + int iVar2; + byte bVar3; + mbedtls_ssl_config *pmVar4; + int iVar5; + byte local_2c [4]; + uchar buf [12]; + + mbedtls_debug_print_msg(ssl,2,"file1",0x1486,"=> parse finished"); + (*ssl->handshake->calc_finished)(ssl,local_2c,*(uint *)&ssl->conf->field_0x74 & 1 ^ 1); + line = mbedtls_ssl_read_record(ssl); + if (line != 0) { + mbedtls_debug_print_ret(ssl,1,"file1",0x148c,"mbedtls_ssl_read_record",line); + return line; + } + if (ssl->in_msgtype != 0x16) { + mbedtls_debug_print_msg(ssl,1,"file1",0x1492,"bad finished message"); + return -0x7700; + } + if (*ssl->in_msg == '\x14') { + pmVar4 = ssl->conf; + line = 4; + if ((*(ushort *)&pmVar4->field_0x74 & 2) != 0) { + line = 0xc; + } + bVar3 = 0; + iVar5 = 0; + if (ssl->in_hslen == line + 0xcU) { + do { + iVar2 = line + iVar5; + pbVar1 = local_2c + iVar5; + iVar5 = iVar5 + 1; + bVar3 = bVar3 | ssl->in_msg[iVar2] ^ *pbVar1; + } while (iVar5 != 0xc); + if (bVar3 == 0) { + if (ssl->handshake->resume == 0) { + line = ssl->state + 1; + } + else { + if (((*(ushort *)&pmVar4->field_0x74 & 1) == 0) && + (ssl->state = 10, (*(ushort *)&pmVar4->field_0x74 & 1) == 0)) goto LAB_2308ea74; + line = 0xf; + } + ssl->state = line; +LAB_2308ea74: + if ((*(ushort *)&pmVar4->field_0x74 & 2) != 0) { + mbedtls_ssl_recv_flight_completed(ssl); + } + mbedtls_debug_print_msg(ssl,2,"file1",0x14c4,"<= parse finished"); + return 0; + } + line = 0x14a8; + goto LAB_2308ea10; + } + } + line = 0x14a1; +LAB_2308ea10: + mbedtls_debug_print_msg(ssl,1,"file1",line,"bad finished message"); + return -0x7e80; +} + + + +int mbedtls_ssl_read(mbedtls_ssl_context *ssl,uchar *buf,size_t len) + +{ + bool bVar1; + uint __n; + int ret; + int line; + char *text; + size_t sVar2; + uchar *puVar3; + + if ((ssl == (mbedtls_ssl_context *)0x0) || (ssl->conf == (mbedtls_ssl_config *)0x0)) { + return -0x7100; + } + mbedtls_debug_print_msg(ssl,2,"file1",0x19e0,"=> read"); + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + ret = mbedtls_ssl_flush_output(ssl); + if (ret != 0) { + return ret; + } + if (((ssl->handshake != (mbedtls_ssl_handshake_params *)0x0) && + (ssl->handshake->retransmit_state == '\x01')) && (ret = mbedtls_ssl_resend(ssl), ret != 0)) + { + return ret; + } + } + if (ssl->state == 0x10) { +LAB_2308eb56: + bVar1 = false; + } + else { + ret = mbedtls_ssl_handshake(ssl); + if (ret != -0x6b00) { + if (ret != 0) { + text = "mbedtls_ssl_handshake"; + line = 0x1a02; + goto LAB_2308eb14; + } + goto LAB_2308eb56; + } + bVar1 = true; + } + if (ssl->in_offt != (uchar *)0x0) { +LAB_2308ec3c: + __n = ssl->in_msglen; + if (len < ssl->in_msglen) { + __n = len; + } + memcpy(buf,ssl->in_offt,__n); + puVar3 = (uchar *)0x0; + sVar2 = ssl->in_msglen - __n; + ssl->in_msglen = sVar2; + if (sVar2 != 0) { + puVar3 = ssl->in_offt + __n; + } + ssl->in_offt = puVar3; + mbedtls_debug_print_msg(ssl,2,"file1",0x1ad0,"<= read"); + return __n; + } + if ((ssl->f_get_timer != (mbedtls_ssl_get_timer_t *)0x0) && + (ret = (*ssl->f_get_timer)(ssl->p_timer), ret == -1)) { + ssl_set_timer(ssl,ssl->conf->read_timeout); + } + if ((bVar1) || (ret = mbedtls_ssl_read_record(ssl), ret == 0)) { + if ((ssl->in_msglen != 0) || + ((ssl->in_msgtype != 0x17 || (ret = mbedtls_ssl_read_record(ssl), ret == 0)))) { + if (ssl->in_msgtype == 0x15) { + mbedtls_debug_print_msg(ssl,2,"file1",0x1aa0,"ignoring non-fatal non-closure alert"); + return -0x6900; + } + if (ssl->in_msgtype != 0x17) { + mbedtls_debug_print_msg(ssl,1,"file1",0x1aa6,"bad application data message"); + return -0x7700; + } + ssl->in_offt = ssl->in_msg; + if (ssl->state == 0x10) { + ssl_set_timer(ssl,0); + } + goto LAB_2308ec3c; + } + if (ret == -0x7280) { + return 0; + } + text = "mbedtls_ssl_read_record"; + line = 0x1a27; + } + else { + if (ret == -0x7280) { + return 0; + } + text = "mbedtls_ssl_read_record"; + line = 0x1a17; + } +LAB_2308eb14: + mbedtls_debug_print_ret(ssl,1,"file1",line,text,ret); + return ret; +} + + + +int mbedtls_ssl_set_calc_verify_md(mbedtls_ssl_context *ssl,int md) + +{ + if ((ssl->minor_ver == 3) && (md == 4)) { + ssl->handshake->calc_verify = ssl_calc_verify_tls_sha256; + return 0; + } + return -0x6600; +} + + + +void mbedtls_zeroize(void *v,size_t n) + +{ + undefined *puVar1; + + puVar1 = (undefined *)(n + (int)v); + while ((undefined *)v != puVar1) { + *(undefined *)v = 0; + v = (undefined *)v + 1; + } + return; +} + + + +int x509_memcasecmp(void *s1,void *s2,size_t len) + +{ + byte bVar1; + size_t sVar2; + + sVar2 = 0; + while( true ) { + if (sVar2 == len) { + return 0; + } + bVar1 = *(byte *)((int)s1 + sVar2); + if ((bVar1 != *(byte *)((int)s2 + sVar2)) && + (((bVar1 ^ *(byte *)((int)s2 + sVar2)) != 0x20 || (0x19 < (byte)((bVar1 & 0xdf) + 0xbf))))) + break; + sVar2 = sVar2 + 1; + } + return -1; +} + + + +int x509_name_cmp(mbedtls_x509_name *a,mbedtls_x509_name *b) + +{ + int iVar1; + size_t __n; + size_t len; + + while( true ) { + if (a == (mbedtls_x509_name *)0x0) { + return -(uint)(b != (mbedtls_x509_name *)0x0); + } + if ((((((b == (mbedtls_x509_name *)0x0) || ((a->oid).tag != (b->oid).tag)) || + (__n = (a->oid).len, __n != (b->oid).len)) || + (iVar1 = memcmp((a->oid).p,(b->oid).p,__n), iVar1 != 0)) || + (((((a->val).tag != (b->val).tag || (__n = (a->val).len, __n != (b->val).len)) || + (iVar1 = memcmp((a->val).p,(b->val).p,__n), iVar1 != 0)) && + (((iVar1 = (a->val).tag, iVar1 != 0xc && (iVar1 != 0x13)) || + (((iVar1 = (b->val).tag, iVar1 != 0xc && (iVar1 != 0x13)) || + ((len = (a->val).len, len != (b->val).len || + (iVar1 = x509_memcasecmp((a->val).p,(b->val).p,len), iVar1 != 0)))))))))) || + (a->next_merged != b->next_merged)) break; + a = (mbedtls_x509_name *)a->next; + b = (mbedtls_x509_name *)b->next; + } + return -1; +} + + + +int x509_check_wildcard(char *cn,mbedtls_x509_buf *name) + +{ + size_t sVar1; + size_t sVar2; + uchar *puVar3; + int iVar4; + + sVar1 = strlen(cn); + if (name->len < 3) { + iVar4 = 0; + } + else { + puVar3 = name->p; + iVar4 = 0; + if ((*puVar3 == '*') && (puVar3[1] == '.')) { + sVar2 = 0; + while (sVar2 != sVar1) { + if (cn[sVar2] == '.') { + if (sVar2 == 0) { + return -1; + } + if (sVar1 - sVar2 != name->len - 1) { + return -1; + } + iVar4 = x509_memcasecmp(puVar3 + 1,cn + sVar2,sVar1 - sVar2); + return -(uint)(iVar4 != 0); + } + sVar2 = sVar2 + 1; + } + iVar4 = -1; + } + } + return iVar4; +} + + + +int x509_profile_check_key + (mbedtls_x509_crt_profile *profile,mbedtls_pk_type_t pk_alg,mbedtls_pk_context *pk) + +{ + bool bVar1; + size_t sVar2; + undefined3 in_register_0000202d; + int iVar3; + + iVar3 = CONCAT31(in_register_0000202d,pk_alg); + if ((iVar3 == 1) || (iVar3 == 6)) { + sVar2 = mbedtls_pk_get_bitlen(pk); + bVar1 = sVar2 < profile->rsa_min_bitlen; + } + else { + if (2 < (iVar3 - 2U & 0xff)) { + return -1; + } + bVar1 = (1 << ((uint)*(byte *)pk->pk_ctx - 1 & 0x1f) & profile->allowed_curves) == 0; + } + return -(uint)bVar1; +} + + + +// WARNING: Variable defined which should be unmapped: key_size_str + +int mbedtls_x509_crt_info(char *buf,size_t size,char *prefix,mbedtls_x509_crt *crt) + +{ + byte bVar1; + uint n; + uchar *buffer; + uint uVar2; + char *name; + int iVar3; + size_t sVar4; + uint uVar5; + uchar *puVar6; + undefined *puVar7; + uchar *puVar8; + int iVar9; + mbedtls_x509_sequence *oid; + char *pcStack56; + char *desc; + char key_size_str [18]; + + if (crt == (mbedtls_x509_crt *)0x0) { + uVar2 = snprintf(buf,size,"\nCertificate is uninitialised!\n"); + if ((-1 < (int)uVar2) && (uVar2 < size)) { + return uVar2; + } + } + else { + uVar2 = snprintf(buf,size,"%scert. version : %d\r\n",prefix,crt->version); + if ((-1 < (int)uVar2) && (uVar2 < size)) { + n = size - uVar2; + buf = buf + uVar2; + uVar2 = snprintf(buf,n,"%sserial number : ",prefix); + if ((-1 < (int)uVar2) && (uVar2 < n)) { + n = n - uVar2; + buf = buf + uVar2; + uVar2 = mbedtls_x509_serial_gets(buf,n,&crt->serial); + if ((-1 < (int)uVar2) && (uVar2 < n)) { + n = n - uVar2; + buf = buf + uVar2; + uVar2 = snprintf(buf,n,"\r\n%sissuer name : ",prefix); + if ((-1 < (int)uVar2) && (uVar2 < n)) { + n = n - uVar2; + buf = buf + uVar2; + uVar2 = mbedtls_x509_dn_gets(buf,n,&crt->issuer); + if ((-1 < (int)uVar2) && (uVar2 < n)) { + n = n - uVar2; + buf = buf + uVar2; + uVar2 = snprintf(buf,n,"\r\n%ssubject name : ",prefix); + if ((-1 < (int)uVar2) && (uVar2 < n)) { + n = n - uVar2; + buf = buf + uVar2; + uVar2 = mbedtls_x509_dn_gets(buf,n,&crt->subject); + if ((-1 < (int)uVar2) && (uVar2 < n)) { + n = n - uVar2; + buf = buf + uVar2; + uVar2 = snprintf(buf,n,"\r\n%sissued on : %04d-%02d-%02d %02d:%02d:%02d", + prefix,(crt->valid_from).year,(crt->valid_from).mon, + (crt->valid_from).day,(crt->valid_from).hour); + if ((-1 < (int)uVar2) && (uVar2 < n)) { + n = n - uVar2; + buf = buf + uVar2; + uVar2 = snprintf(buf,n,"\r\n%sexpires on : %04d-%02d-%02d %02d:%02d:%02d" + ,prefix,(crt->valid_to).year,(crt->valid_to).mon, + (crt->valid_to).day,(crt->valid_to).hour); + if ((-1 < (int)uVar2) && (uVar2 < n)) { + n = n - uVar2; + buf = buf + uVar2; + uVar2 = snprintf(buf,n,"\r\n%ssigned using : ",prefix); + if ((-1 < (int)uVar2) && (uVar2 < n)) { + n = n - uVar2; + buf = buf + uVar2; + uVar2 = mbedtls_x509_sig_alg_gets + (buf,n,&crt->sig_oid,crt->sig_pk,crt->sig_md,crt->sig_opts + ); + if ((-1 < (int)uVar2) && (uVar2 < n)) { + name = mbedtls_pk_get_name(&crt->pk); + iVar3 = mbedtls_x509_key_size_helper((char *)&desc,0x12,name); + if (iVar3 != 0) { + return iVar3; + } + sVar4 = mbedtls_pk_get_bitlen(&crt->pk); + n = n - uVar2; + uVar5 = snprintf(buf + uVar2,n,"\r\n%s%-18s: %d bits",prefix,&desc,sVar4); + if ((-1 < (int)uVar5) && (uVar5 < n)) { + n = n - uVar5; + buffer = (uchar *)(buf + uVar2 + uVar5); + if ((crt->ext_types & 0x100U) != 0) { + if (crt->ca_istrue == 0) { + name = "false"; + } + else { + name = "true"; + } + uVar2 = snprintf((char *)buffer,n,"\r\n%sbasic constraints : CA=%s", + prefix,name); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + if (0 < crt->max_pathlen) { + uVar2 = snprintf((char *)buffer,n,", max_pathlen=%d", + crt->max_pathlen + -1); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + } + } + if ((crt->ext_types & 0x20U) != 0) { + uVar2 = snprintf((char *)buffer,n,"\r\n%ssubject alt name : ",prefix) + ; + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + oid = &crt->subject_alt_names; + iVar3 = 0; + puVar7 = &DAT_230c6dbc; + do { + uVar2 = (oid->buf).len + iVar3; + if (n <= uVar2) { + *buffer = '\0'; + return -0x2980; + } + n = n - uVar2; + iVar9 = 0; + while (puVar6 = buffer + iVar9, iVar9 != iVar3) { + puVar8 = puVar7 + iVar9; + iVar9 = iVar9 + 1; + *puVar6 = *puVar8; + } + uVar2 = 0; + while (buffer = puVar6 + uVar2, uVar2 < (oid->buf).len) { + puVar8 = (oid->buf).p + uVar2; + uVar2 = uVar2 + 1; + *buffer = *puVar8; + } + oid = (mbedtls_x509_sequence *)oid->next; + iVar3 = 2; + puVar7 = &DAT_230be808; + } while (oid != (mbedtls_x509_sequence *)0x0); + *buffer = '\0'; + } + if (crt->ext_types << 0xf < 0) { + uVar2 = snprintf((char *)buffer,n,"\r\n%scert. type : ",prefix) + ; + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + bVar1 = crt->ns_cert_type; + n = n - uVar2; + buffer = buffer + uVar2; + puVar7 = &DAT_230c6dbc; + if ((char)bVar1 < '\0') { + uVar2 = snprintf((char *)buffer,n,"%sSSL Client",&DAT_230c6dbc); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + puVar7 = &DAT_230be808; + } + if ((bVar1 & 0x40) != 0) { + uVar2 = snprintf((char *)buffer,n,"%sSSL Server",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + puVar7 = &DAT_230be808; + } + if ((bVar1 & 0x20) != 0) { + uVar2 = snprintf((char *)buffer,n,"%sEmail",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + puVar7 = &DAT_230be808; + } + if ((bVar1 & 0x10) != 0) { + uVar2 = snprintf((char *)buffer,n,"%sObject Signing",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + puVar7 = &DAT_230be808; + } + if ((bVar1 & 8) != 0) { + uVar2 = snprintf((char *)buffer,n,"%sReserved",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + puVar7 = &DAT_230be808; + } + if ((bVar1 & 4) != 0) { + uVar2 = snprintf((char *)buffer,n,"%sSSL CA",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + puVar7 = &DAT_230be808; + } + if ((bVar1 & 2) != 0) { + uVar2 = snprintf((char *)buffer,n,"%sEmail CA",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + puVar7 = &DAT_230be808; + } + if ((bVar1 & 1) != 0) { + uVar2 = snprintf((char *)buffer,n,"%sObject Signing CA",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + } + } + if ((crt->ext_types & 4U) != 0) { + uVar2 = snprintf((char *)buffer,n,"\r\n%skey usage : ",prefix) + ; + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + uVar5 = crt->key_usage; + n = n - uVar2; + buffer = buffer + uVar2; + puVar7 = &DAT_230c6dbc; + if ((uVar5 & 0x80) != 0) { + uVar2 = snprintf((char *)buffer,n,"%sDigital Signature", + &DAT_230c6dbc); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + puVar7 = &DAT_230be808; + } + if ((uVar5 & 0x40) != 0) { + uVar2 = snprintf((char *)buffer,n,"%sNon Repudiation",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + puVar7 = &DAT_230be808; + } + if ((uVar5 & 0x20) != 0) { + uVar2 = snprintf((char *)buffer,n,"%sKey Encipherment",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + puVar7 = &DAT_230be808; + } + if ((uVar5 & 0x10) != 0) { + uVar2 = snprintf((char *)buffer,n,"%sData Encipherment",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + puVar7 = &DAT_230be808; + } + if ((uVar5 & 8) != 0) { + uVar2 = snprintf((char *)buffer,n,"%sKey Agreement",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + puVar7 = &DAT_230be808; + } + if ((uVar5 & 4) != 0) { + uVar2 = snprintf((char *)buffer,n,"%sKey Cert Sign",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + puVar7 = &DAT_230be808; + } + if ((uVar5 & 2) != 0) { + uVar2 = snprintf((char *)buffer,n,"%sCRL Sign",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + puVar7 = &DAT_230be808; + } + if ((uVar5 & 1) != 0) { + uVar2 = snprintf((char *)buffer,n,"%sEncipher Only",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + puVar7 = &DAT_230be808; + } + if ((int)(uVar5 << 0x10) < 0) { + uVar2 = snprintf((char *)buffer,n,"%sDecipher Only",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + } + } + if (crt->ext_types << 0x14 < 0) { + uVar2 = snprintf((char *)buffer,n,"\r\n%sext key usage : ",prefix) + ; + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + n = n - uVar2; + buffer = buffer + uVar2; + oid = &crt->ext_key_usage; + puVar7 = &DAT_230c6dbc; + do { + iVar3 = mbedtls_oid_get_extended_key_usage + ((mbedtls_asn1_buf *)oid,&pcStack56); + if (iVar3 != 0) { + pcStack56 = "???"; + } + uVar2 = snprintf((char *)buffer,n,"%s%s",puVar7,pcStack56); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (n <= uVar2) { + return -0x2980; + } + oid = (mbedtls_x509_sequence *)oid->next; + n = n - uVar2; + buffer = buffer + uVar2; + puVar7 = &DAT_230be808; + } while (oid != (mbedtls_x509_sequence *)0x0); + } + uVar2 = snprintf((char *)buffer,n,"\r\n"); + if ((-1 < (int)uVar2) && (uVar2 < n)) { + return (uVar2 - n) + size; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + return -0x2980; +} + + + +int mbedtls_x509_crt_check_key_usage(mbedtls_x509_crt *crt,uint usage) + +{ + uint uVar1; + + uVar1 = crt->ext_types & 4; + if ((uVar1 != 0) && + (((usage & 0xffff7ffe) != (usage & 0xffff7ffe & crt->key_usage) || + (uVar1 = 0, (usage & 0x8001) != ((usage | crt->key_usage) & 0x8001))))) { + uVar1 = 0xffffd800; + } + return uVar1; +} + + + +int x509_crt_check_parent(mbedtls_x509_crt *child,mbedtls_x509_crt *parent,int top,int bottom) + +{ + int iVar1; + int iVar2; + size_t __n; + + iVar1 = x509_name_cmp(&child->issuer,&parent->subject); + if (iVar1 == 0) { + if (top != 0) { + iVar1 = parent->version; + if (((bottom != 0) && (__n = (child->raw).len, __n == (parent->raw).len)) && + (iVar2 = memcmp((child->raw).p,(parent->raw).p,__n), iVar2 == 0)) { + return 0; + } + if (iVar1 < 3) { + return 0; + } + } + if (parent->ca_istrue != 0) { + iVar1 = mbedtls_x509_crt_check_key_usage(parent,4); + return -(uint)(iVar1 != 0); + } + } + return -1; +} + + + +int x509_crt_verify_top(mbedtls_x509_crt *child,mbedtls_x509_crt *trust_ca, + mbedtls_x509_crt_profile *profile,int path_cnt,int self_cnt,uint32_t *flags, + anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *f_vrfy, + void *p_vrfy) + +{ + mbedtls_pk_type_t type; + mbedtls_md_type_t md_alg; + uchar uVar1; + int iVar2; + mbedtls_md_info_t *md_info; + int iVar3; + undefined3 extraout_var; + void *options; + mbedtls_x509_crt *pmVar4; + uint32_t uStack100; + uint32_t ca_flags; + uchar hash [32]; + + uStack100 = 0; + iVar2 = mbedtls_x509_time_is_past(&child->valid_to); + if (iVar2 != 0) { + *flags = *flags | 1; + } + iVar2 = mbedtls_x509_time_is_future(&child->valid_from); + if (iVar2 != 0) { + *flags = *flags | 0x200; + } + if ((1 << ((uint)child->sig_md - 1 & 0x1f) & profile->allowed_mds) == 0) { + *flags = *flags | 0x4000; + } + if ((1 << ((uint)child->sig_pk - 1 & 0x1f) & profile->allowed_pks) == 0) { + *flags = *flags | 0x8000; + } + *flags = *flags | 8; + md_info = mbedtls_md_info_from_type(child->sig_md); + if (md_info == (mbedtls_md_info_t *)0x0) { +LAB_2308f6a2: + if (f_vrfy == (anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *)0x0) + goto LAB_2308f79c; + } + else { + pmVar4 = (mbedtls_x509_crt *)0x0; + mbedtls_md(md_info,(child->tbs).p,(child->tbs).len,(uchar *)&ca_flags); + while (trust_ca != (mbedtls_x509_crt *)0x0) { + iVar2 = x509_crt_check_parent(child,trust_ca,1,(uint)(path_cnt == 0)); + if (iVar2 == 0) { + iVar2 = path_cnt + 1; + if (((child->subject_raw).len == (trust_ca->subject_raw).len) && + (iVar3 = memcmp((child->subject_raw).p,(trust_ca->subject_raw).p,(child->issuer_raw).len) + , iVar3 == 0)) { + iVar2 = path_cnt; + } + if ((trust_ca->max_pathlen < 1) || (iVar2 - self_cnt <= trust_ca->max_pathlen)) { + type = child->sig_pk; + options = child->sig_opts; + md_alg = child->sig_md; + uVar1 = mbedtls_md_get_size(md_info); + iVar2 = mbedtls_pk_verify_ext + (type,options,&trust_ca->pk,md_alg,(uchar *)&ca_flags, + CONCAT31(extraout_var,uVar1),(child->sig).p,(child->sig).len); + if (iVar2 == 0) { + iVar2 = mbedtls_x509_time_is_past(&trust_ca->valid_to); + if ((iVar2 == 0) && + (iVar2 = mbedtls_x509_time_is_future(&trust_ca->valid_from), iVar2 == 0)) + goto LAB_2308f73e; + if (pmVar4 == (mbedtls_x509_crt *)0x0) { + pmVar4 = trust_ca; + } + } + } + } + trust_ca = trust_ca->next; + } + trust_ca = pmVar4; + if (pmVar4 == (mbedtls_x509_crt *)0x0) goto LAB_2308f6a2; +LAB_2308f73e: + *flags = *flags & 0xfffffff7; + iVar2 = x509_profile_check_key(profile,child->sig_pk,&trust_ca->pk); + if (iVar2 != 0) { + *flags = *flags | 0x10000; + } + if (((child->subject_raw).len == (trust_ca->subject_raw).len) && + (iVar2 = memcmp((child->subject_raw).p,(trust_ca->subject_raw).p,(child->issuer_raw).len), + iVar2 == 0)) goto LAB_2308f6a2; + iVar2 = mbedtls_x509_time_is_past(&trust_ca->valid_to); + if (iVar2 != 0) { + uStack100 = uStack100 | 1; + } + iVar2 = mbedtls_x509_time_is_future(&trust_ca->valid_from); + if (iVar2 != 0) { + uStack100 = uStack100 | 0x200; + } + if (f_vrfy == (anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *)0x0) + goto LAB_2308f79c; + iVar2 = (*f_vrfy)(p_vrfy,trust_ca,path_cnt + 1,&uStack100); + if (iVar2 != 0) { + return iVar2; + } + } + iVar2 = (*f_vrfy)(p_vrfy,child,path_cnt,flags); + if (iVar2 != 0) { + return iVar2; + } +LAB_2308f79c: + *flags = *flags | uStack100; + return 0; +} + + + +int x509_crt_verify_child + (mbedtls_x509_crt *child,mbedtls_x509_crt *parent,mbedtls_x509_crt *trust_ca, + mbedtls_x509_crl *ca_crl,mbedtls_x509_crt_profile *profile,int path_cnt,int self_cnt, + uint32_t *flags,anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *f_vrfy, + void *p_vrfy) + +{ + mbedtls_pk_type_t type; + mbedtls_md_type_t md_alg; + uchar uVar1; + int iVar2; + mbedtls_md_info_t *md_info; + undefined3 extraout_var; + void *options; + mbedtls_x509_crt *parent_00; + mbedtls_x509_crt *parent_01; + anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *extraout_fa0; + anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *f_vrfy_00; + void *extraout_fa1; + void *p_vrfy_00; + anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *in_stack_00000000; + void *in_stack_00000004; + uint32_t uStack100; + uint32_t parent_flags; + uchar hash [32]; + + uStack100 = 0; + if (path_cnt != 0) { + iVar2 = x509_name_cmp(&child->issuer,&child->subject); + if (iVar2 == 0) { + self_cnt = self_cnt + 1; + } + if (path_cnt == 8) { + *flags = *flags | 8; + return -0x2700; + } + } + iVar2 = mbedtls_x509_time_is_past(&child->valid_to); + if (iVar2 != 0) { + *flags = *flags | 1; + } + iVar2 = mbedtls_x509_time_is_future(&child->valid_from); + if (iVar2 != 0) { + *flags = *flags | 0x200; + } + if ((1 << ((uint)child->sig_md - 1 & 0x1f) & profile->allowed_mds) == 0) { + *flags = *flags | 0x4000; + } + if ((1 << ((uint)child->sig_pk - 1 & 0x1f) & profile->allowed_pks) == 0) { + *flags = *flags | 0x8000; + } + f_vrfy_00 = extraout_fa0; + p_vrfy_00 = extraout_fa1; + md_info = mbedtls_md_info_from_type(child->sig_md); + if (md_info != (mbedtls_md_info_t *)0x0) { + mbedtls_md(md_info,(child->tbs).p,(child->tbs).len,(uchar *)&parent_flags); + iVar2 = x509_profile_check_key(profile,child->sig_pk,&parent->pk); + if (iVar2 != 0) { + *flags = *flags | 0x10000; + } + type = child->sig_pk; + options = child->sig_opts; + md_alg = child->sig_md; + uVar1 = mbedtls_md_get_size(md_info); + iVar2 = mbedtls_pk_verify_ext + (type,options,&parent->pk,md_alg,(uchar *)&parent_flags, + CONCAT31(extraout_var,uVar1),(child->sig).p,(child->sig).len); + if (iVar2 == 0) goto LAB_2308f924; + } + *flags = *flags | 8; +LAB_2308f924: + parent_01 = trust_ca; + while (parent_01 != (mbedtls_x509_crt *)0x0) { + iVar2 = x509_crt_check_parent(parent,parent_01,0,(uint)(path_cnt == 0)); + if (iVar2 == 0) goto LAB_2308f978; + parent_01 = parent_01->next; + } + parent_00 = parent->next; + do { + parent_01 = trust_ca; + if (parent_00 == (mbedtls_x509_crt *)0x0) { +LAB_2308f978: + iVar2 = x509_crt_verify_top(parent,parent_01,profile,path_cnt + 1,self_cnt,&uStack100, + in_stack_00000000,in_stack_00000004); +LAB_2308f9ac: + if ((iVar2 == 0) && + ((in_stack_00000000 == (anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *)0x0 + || (iVar2 = (*in_stack_00000000)(in_stack_00000004,child,path_cnt,flags), iVar2 == 0)))) { + iVar2 = 0; + *flags = *flags | uStack100; + } + return iVar2; + } + if (((parent_00->max_pathlen < 1) || ((path_cnt + 2) - self_cnt <= parent_00->max_pathlen)) && + (iVar2 = x509_crt_check_parent(parent,parent_00,0,(uint)(path_cnt == 0)), iVar2 == 0)) { + iVar2 = x509_crt_verify_child + (parent,parent_00,trust_ca,ca_crl,profile,path_cnt + 1,self_cnt,&uStack100, + f_vrfy_00,p_vrfy_00); + goto LAB_2308f9ac; + } + parent_00 = parent_00->next; + } while( true ); +} + + + +int mbedtls_x509_crt_check_extended_key_usage + (mbedtls_x509_crt *crt,char *usage_oid,size_t usage_len) + +{ + mbedtls_x509_sequence *pmVar1; + int iVar2; + + if (-1 < crt->ext_types << 0x14) { + return 0; + } + pmVar1 = &crt->ext_key_usage; + while ((((pmVar1->buf).len != usage_len || + (iVar2 = memcmp((pmVar1->buf).p,usage_oid,usage_len), iVar2 != 0)) && + (((pmVar1->buf).len != 4 || (iVar2 = memcmp(&DAT_230c8268,(pmVar1->buf).p,4), iVar2 != 0))) + )) { + pmVar1 = (mbedtls_x509_sequence *)pmVar1->next; + if (pmVar1 == (mbedtls_x509_sequence *)0x0) { + return -0x2800; + } + } + return 0; +} + + + +int mbedtls_x509_crt_verify_with_profile + (mbedtls_x509_crt *crt,mbedtls_x509_crt *trust_ca,mbedtls_x509_crl *ca_crl, + mbedtls_x509_crt_profile *profile,char *cn,uint32_t *flags, + anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *f_vrfy,void *p_vrfy) + +{ + mbedtls_pk_type_t pk_alg; + size_t len; + int iVar1; + mbedtls_x509_crt *parent; + uint uVar2; + mbedtls_x509_crt *parent_00; + mbedtls_x509_name *pmVar3; + mbedtls_x509_sequence *name; + anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *in_fa0; + void *in_fa1; + + if (profile == (mbedtls_x509_crt_profile *)0x0) { + return -0x2800; + } + *flags = 0; + if (cn != (char *)0x0) { + len = strlen(cn); + if ((crt->ext_types & 0x20U) == 0) { + pmVar3 = &crt->subject; + do { + if ((((pmVar3->oid).len == 3) && + (iVar1 = memcmp(&DAT_230c85ac,(pmVar3->oid).p,3), iVar1 == 0)) && + (((uVar2 = (pmVar3->val).len, uVar2 == len && + (iVar1 = x509_memcasecmp((pmVar3->val).p,cn,len), iVar1 == 0)) || + (((2 < uVar2 && (iVar1 = memcmp((pmVar3->val).p,&DAT_230c85a8,2), iVar1 == 0)) && + (iVar1 = x509_check_wildcard(cn,(mbedtls_x509_buf *)&pmVar3->val), iVar1 == 0)))))) + goto LAB_2308fb0a; + pmVar3 = (mbedtls_x509_name *)pmVar3->next; + } while (pmVar3 != (mbedtls_x509_name *)0x0); + } + else { + name = &crt->subject_alt_names; + do { + uVar2 = (name->buf).len; + if (((uVar2 == len) && (iVar1 = x509_memcasecmp(cn,(name->buf).p,len), iVar1 == 0)) || + ((2 < uVar2 && + ((iVar1 = memcmp((name->buf).p,&DAT_230c85a8,2), iVar1 == 0 && + (iVar1 = x509_check_wildcard(cn,(mbedtls_x509_buf *)name), iVar1 == 0)))))) + goto LAB_2308fb0a; + name = (mbedtls_x509_sequence *)name->next; + } while (name != (mbedtls_x509_sequence *)0x0); + } + *flags = *flags | 4; + } +LAB_2308fb0a: + pk_alg = mbedtls_pk_get_type(&crt->pk); + if ((1 << ((uint)pk_alg - 1 & 0x1f) & profile->allowed_pks) == 0) { + *flags = *flags | 0x8000; + } + iVar1 = x509_profile_check_key(profile,pk_alg,&crt->pk); + parent = trust_ca; + if (iVar1 != 0) { + *flags = *flags | 0x10000; + } + while (parent != (mbedtls_x509_crt *)0x0) { + iVar1 = x509_crt_check_parent(crt,parent,0,1); + if (iVar1 == 0) goto LAB_2308fbd6; + parent = parent->next; + } + parent_00 = crt->next; + do { + parent = trust_ca; + if (parent_00 == (mbedtls_x509_crt *)0x0) { +LAB_2308fbd6: + iVar1 = x509_crt_verify_top(crt,parent,profile,0,0,flags,f_vrfy,p_vrfy); +LAB_2308fbfe: + if ((iVar1 == 0) && (iVar1 = 0, *flags != 0)) { + iVar1 = -0x2700; + } + return iVar1; + } + iVar1 = x509_crt_check_parent(crt,parent_00,0,1); + if (iVar1 == 0) { + iVar1 = x509_crt_verify_child(crt,parent_00,trust_ca,ca_crl,profile,0,0,flags,in_fa0,in_fa1); + goto LAB_2308fbfe; + } + parent_00 = parent_00->next; + } while( true ); +} + + + +void mbedtls_x509_crt_init(mbedtls_x509_crt *crt) + +{ + memset(crt,0,0x134); + return; +} + + + +void mbedtls_x509_crt_free(mbedtls_x509_crt *crt) + +{ + mbedtls_x509_crt **ppmVar1; + mbedtls_x509_crt *v; + uchar *v_00; + mbedtls_asn1_named_data *v_01; + mbedtls_asn1_sequence *v_02; + mbedtls_x509_crt *pmVar2; + mbedtls_asn1_named_data *pmVar3; + mbedtls_asn1_sequence *pmVar4; + + pmVar2 = crt; + if (crt == (mbedtls_x509_crt *)0x0) { + return; + } + do { + mbedtls_pk_free(&pmVar2->pk); + v_01 = (pmVar2->issuer).next; + while (v_01 != (mbedtls_asn1_named_data *)0x0) { + pmVar3 = v_01->next; + mbedtls_zeroize(v_01,0x20); + vPortFree(v_01); + v_01 = pmVar3; + } + v_01 = (pmVar2->subject).next; + while (v_01 != (mbedtls_asn1_named_data *)0x0) { + pmVar3 = v_01->next; + mbedtls_zeroize(v_01,0x20); + vPortFree(v_01); + v_01 = pmVar3; + } + v_02 = (pmVar2->ext_key_usage).next; + while (v_02 != (mbedtls_asn1_sequence *)0x0) { + pmVar4 = v_02->next; + mbedtls_zeroize(v_02,0x10); + vPortFree(v_02); + v_02 = pmVar4; + } + v_02 = (pmVar2->subject_alt_names).next; + while (v_02 != (mbedtls_asn1_sequence *)0x0) { + pmVar4 = v_02->next; + mbedtls_zeroize(v_02,0x10); + vPortFree(v_02); + v_02 = pmVar4; + } + v_00 = (pmVar2->raw).p; + if (v_00 != (uchar *)0x0) { + mbedtls_zeroize(v_00,(pmVar2->raw).len); + vPortFree((pmVar2->raw).p); + } + ppmVar1 = &pmVar2->next; + v = crt; + pmVar2 = *ppmVar1; + } while (*ppmVar1 != (mbedtls_x509_crt *)0x0); + do { + pmVar2 = v->next; + mbedtls_zeroize(v,0x134); + if (crt != v) { + vPortFree(v); + } + v = pmVar2; + } while (pmVar2 != (mbedtls_x509_crt *)0x0); + return; +} + + + +int mbedtls_x509_crt_parse_der(mbedtls_x509_crt *chain,uchar *buf,size_t buflen) + +{ + uchar uVar1; + uchar *end; + mbedtls_x509_crt *crt; + mbedtls_x509_crt *crt_00; + int iVar2; + size_t __n; + size_t sVar3; + byte *pbVar4; + byte *pbVar5; + uchar *end_00; + mbedtls_x509_crt *pmVar6; + uchar *end_01; + uchar *end_02; + mbedtls_x509_sequence *pmVar7; + mbedtls_x509_sequence *pmVar8; + uchar *puStack132; + size_t len; + uchar *p; + size_t len_2; + int is_critical; + int ext_type; + size_t len_3; + mbedtls_x509_buf sig_params1; + mbedtls_x509_buf sig_params2; + mbedtls_x509_buf sig_oid2; + mbedtls_x509_buf extn_oid; + size_t len_1; + + if ((chain == (mbedtls_x509_crt *)0x0) || (buf == (uchar *)0x0)) { + return -0x2800; + } + crt_00 = chain; + pmVar6 = (mbedtls_x509_crt *)0x0; + do { + crt = crt_00; + if (crt->version == 0) goto LAB_2308fd7e; + crt_00 = crt->next; + pmVar6 = crt; + } while (crt->next != (mbedtls_x509_crt *)0x0); + crt_00 = (mbedtls_x509_crt *)mycalloc(1,0x134); + crt->next = crt_00; + if (crt_00 == (mbedtls_x509_crt *)0x0) { + return -0x2880; + } + mbedtls_x509_crt_init(crt_00); + crt = crt->next; +LAB_2308fd7e: + memset(&len_3,0,0xc); + memset(&sig_params1.p,0,0xc); + memset(&sig_params2.p,0,0xc); + if (crt == (mbedtls_x509_crt *)0x0) { + iVar2 = -0x2800; + if (pmVar6 == (mbedtls_x509_crt *)0x0) goto LAB_23090368; +LAB_2308fdc6: + pmVar6->next = (mbedtls_x509_crt *)0x0; + } + else { + puStack132 = (uchar *)buflen; + len = (size_t)buf; + iVar2 = mbedtls_asn1_get_tag((uchar **)&len,buf + buflen,(size_t *)&puStack132,0x30); + if (iVar2 == 0) { + if (buf + buflen + -len < puStack132) goto LAB_2308fdda; + *(uchar **)&(crt->raw).len = puStack132 + (int)(len - (int)buf); + len = (size_t)mycalloc(1,(size_t)(puStack132 + (int)(len - (int)buf))); + *(size_t *)&(crt->raw).p = len; + if ((uchar *)len == (uchar *)0x0) { + iVar2 = -0x2880; + } + else { + memcpy((void *)len,buf,(crt->raw).len); + sVar3 = (crt->raw).len; + end_01 = (uchar *)((sVar3 - (int)puStack132) + len); + end_00 = (uchar *)(len + sVar3); + (crt->tbs).p = end_01; + len = (size_t)end_01; + iVar2 = mbedtls_asn1_get_tag((uchar **)&len,end_00,(size_t *)&puStack132,0x30); + if (iVar2 == 0) { + end_01 = puStack132 + len; + *(uchar **)&(crt->tbs).len = end_01 + -(int)(crt->tbs).p; + iVar2 = mbedtls_asn1_get_tag((uchar **)&len,end_01,(size_t *)&extn_oid.p,0xa0); + if (iVar2 == 0) { + end_02 = extn_oid.p + len; + iVar2 = mbedtls_asn1_get_int((uchar **)&len,end_02,&crt->version); + if (iVar2 == 0) { + if (end_02 == (uchar *)len) goto LAB_2308fe86; + iVar2 = -0x2266; + } + else { + iVar2 = iVar2 + -0x2200; + if (iVar2 == 0) { +LAB_2308fe86: + iVar2 = mbedtls_x509_get_serial((uchar **)&len,end_01,&crt->serial); + if (iVar2 == 0) { + iVar2 = mbedtls_x509_get_alg + ((uchar **)&len,end_01,&crt->sig_oid,(mbedtls_x509_buf *)&len_3) + ; + if (iVar2 == 0) { + iVar2 = crt->version + 1; + crt->version = iVar2; + if (3 < iVar2) { + mbedtls_x509_crt_free(crt); + iVar2 = -0x2580; + goto LAB_2308fdc2; + } + iVar2 = mbedtls_x509_get_sig_alg + (&crt->sig_oid,(mbedtls_x509_buf *)&len_3,&crt->sig_md, + &crt->sig_pk,&crt->sig_opts); + if (iVar2 == 0) { + *(size_t *)&(crt->issuer_raw).p = len; + iVar2 = mbedtls_asn1_get_tag((uchar **)&len,end_01,(size_t *)&puStack132,0x30) + ; + if (iVar2 != 0) goto LAB_2308fe2e; + iVar2 = mbedtls_x509_get_name((uchar **)&len,puStack132 + len,&crt->issuer); + if (iVar2 == 0) { + *(uchar **)&(crt->issuer_raw).len = + (uchar *)(len - (int)(crt->issuer_raw).p); + iVar2 = mbedtls_asn1_get_tag + ((uchar **)&len,end_01,(size_t *)&extn_oid.p,0x30); + if (iVar2 == 0) { + len = (size_t)(extn_oid.p + len); + } + else { + if (iVar2 != -0x62) goto LAB_2308fee2; + } + *(size_t *)&(crt->subject_raw).p = len; + iVar2 = mbedtls_asn1_get_tag + ((uchar **)&len,end_01,(size_t *)&puStack132,0x30); + if (iVar2 != 0) goto LAB_2308fe2e; + if ((puStack132 == (uchar *)0x0) || + (iVar2 = mbedtls_x509_get_name + ((uchar **)&len,puStack132 + len,&crt->subject), + iVar2 == 0)) { + *(uchar **)&(crt->subject_raw).len = + (uchar *)(len - (int)(crt->subject_raw).p); + iVar2 = mbedtls_pk_parse_subpubkey((uchar **)&len,end_01,&crt->pk); + if (iVar2 == 0) { + if (crt->version - 2U < 2) { + if (end_01 != (uchar *)len) { + (crt->issuer_id).tag = (uint)*(byte *)len; + iVar2 = mbedtls_asn1_get_tag + ((uchar **)&len,end_01,&(crt->issuer_id).len,0xa1) + ; + if (iVar2 == 0) { + *(size_t *)&(crt->issuer_id).p = len; + len = len + (crt->issuer_id).len; + } + else { + if (iVar2 != -0x62) goto LAB_2308fee2; + } + if (1 < crt->version - 2U) goto LAB_2308ffba; + } + if (end_01 != (uchar *)len) { + (crt->subject_id).tag = (uint)*(byte *)len; + iVar2 = mbedtls_asn1_get_tag + ((uchar **)&len,end_01,&(crt->subject_id).len,0xa2 + ); + if (iVar2 == 0) { + *(size_t *)&(crt->subject_id).p = len; + len = len + (crt->subject_id).len; + } + else { + if (iVar2 != -0x62) goto LAB_2308fee2; + } + } + } +LAB_2308ffba: + if (crt->version == 3) { + iVar2 = mbedtls_x509_get_ext((uchar **)&len,end_01,&crt->v3_ext,3); + if (iVar2 == 0) { +LAB_2308ffda: + if (end_01 <= len) { + if (end_01 == (uchar *)len) goto LAB_2308ffe4; +LAB_230902b8: + iVar2 = -0x2566; + goto LAB_2308fee2; + } + sig_oid2.p = (uchar *)0x0; + extn_oid.tag = 0; + extn_oid.len = 0; + len_2 = 0; + is_critical = 0; + iVar2 = mbedtls_asn1_get_tag + ((uchar **)&len,end_01,(size_t *)&p,0x30); + if (iVar2 != 0) { +LAB_230900b6: + iVar2 = iVar2 + -0x2500; + if (iVar2 == 0) goto LAB_23090094; + goto LAB_2308fee2; + } + end_02 = p + len; + sig_oid2.p = (uchar *)(uint)*(byte *)len; + iVar2 = mbedtls_asn1_get_tag + ((uchar **)&len,end_01,(size_t *)&extn_oid,6); + if (iVar2 != 0) goto LAB_230900b6; + extn_oid.len = len; + len = len + extn_oid.tag; + if ((int)(end_01 + -len) < 1) { +LAB_23090380: + iVar2 = -0x2560; + goto LAB_2308fee2; + } + iVar2 = mbedtls_asn1_get_bool((uchar **)&len,end_02,(int *)&len_2); + if (((iVar2 != 0) && (iVar2 != -0x62)) || + (iVar2 = mbedtls_asn1_get_tag + ((uchar **)&len,end_02,(size_t *)&p,4), + iVar2 != 0)) goto LAB_230900b6; + end = p + len; + if (end_02 != end) goto LAB_230902b8; + iVar2 = mbedtls_oid_get_x509_ext_type + ((mbedtls_asn1_buf *)&sig_oid2.p,&is_critical); + if (iVar2 != 0) { + len = (size_t)end_02; + if (len_2 != 0) goto LAB_2309012c; + goto LAB_2308ffda; + } + if ((crt->ext_types & is_critical) != 0) { +LAB_23090388: + iVar2 = -0x2500; + goto LAB_2308fee2; + } + crt->ext_types = crt->ext_types | is_critical; + if (is_critical == 0x100) { + crt->ca_istrue = 0; + crt->max_pathlen = 0; + iVar2 = mbedtls_asn1_get_tag + ((uchar **)&len,end_02,(size_t *)&extn_oid.p, + 0x30); + if (iVar2 == 0) { + if (end == (uchar *)len) goto LAB_2308ffda; + iVar2 = mbedtls_asn1_get_bool + ((uchar **)&len,end,&crt->ca_istrue); + if (iVar2 != 0) { + if ((iVar2 != -0x62) || + (iVar2 = mbedtls_asn1_get_int + ((uchar **)&len,end,&crt->ca_istrue), + iVar2 != 0)) goto LAB_230901b8; + if (crt->ca_istrue != 0) { + crt->ca_istrue = 1; + } + } + if (end == (uchar *)len) goto LAB_2308ffda; + iVar2 = mbedtls_asn1_get_int + ((uchar **)&len,end,&crt->max_pathlen); + if (iVar2 == 0) { + if (end != (uchar *)len) goto LAB_230902b8; + crt->max_pathlen = crt->max_pathlen + 1; + goto LAB_2308ffda; + } + } + } + else { + if (is_critical < 0x101) { + if (is_critical == 4) { + extn_oid.p = (uchar *)0x0; + iVar2 = mbedtls_asn1_get_bitstring + ((uchar **)&len,end_02, + (mbedtls_asn1_bitstring *)&extn_oid.p); + if (iVar2 == 0) { + if (extn_oid.p == (uchar *)0x0) goto LAB_23090236; + crt->key_usage = 0; + pbVar4 = (byte *)0x0; + do { + pbVar5 = pbVar4 + 1; + crt->key_usage = + crt->key_usage | + (uint)*pbVar4 << (((uint)pbVar4 & 3) << 3); + if (extn_oid.p == pbVar5) break; + pbVar4 = pbVar5; + } while (pbVar5 != &DAT_00000004); + goto LAB_2308ffda; + } + } + else { + if (is_critical != 0x20) { +LAB_23090162: + iVar2 = -0x2080; + goto LAB_2308fee2; + } + iVar2 = mbedtls_asn1_get_tag + ((uchar **)&len,end_02,(size_t *)&ext_type, + 0x30); + if (iVar2 == 0) { + if (end == (uchar *)(len + ext_type)) { + pmVar7 = &crt->subject_alt_names; + while (len < end) { + if ((int)(end + -len) < 1) goto LAB_23090380; + uVar1 = *(uchar *)len; + len = len + 1; + iVar2 = mbedtls_asn1_get_len + ((uchar **)&len,end, + (size_t *)&extn_oid.p); + if (iVar2 != 0) goto LAB_230901b8; + if (-1 < (char)uVar1) goto LAB_2309012c; + if (uVar1 == -0x7e) { + pmVar8 = pmVar7; + if ((pmVar7->buf).p != (uchar *)0x0) { + if (pmVar7->next != (mbedtls_asn1_sequence *)0x0) + goto LAB_23090388; + pmVar8 = (mbedtls_x509_sequence *)mycalloc(1,0x10); + *(mbedtls_x509_sequence **)&pmVar7->next = pmVar8; + if (pmVar8 == (mbedtls_x509_sequence *)0x0) { + iVar2 = -0x256a; + goto LAB_2308fee2; + } + } + (pmVar8->buf).tag = 0x82; + *(size_t *)&(pmVar8->buf).p = len; + *(uchar **)&(pmVar8->buf).len = extn_oid.p; + pmVar7 = pmVar8; + } + len = (size_t)((uchar *)len + (int)extn_oid.p); + } + pmVar7->next = (mbedtls_asn1_sequence *)0x0; + if (end != (uchar *)len) goto LAB_230902b8; + goto LAB_2308ffda; + } + goto LAB_230902b8; + } + } + } + else { + if (is_critical == 0x800) { + iVar2 = mbedtls_asn1_get_sequence_of + ((uchar **)&len,end_02, + (mbedtls_asn1_sequence *) + &crt->ext_key_usage,6); + if (iVar2 == 0) { + if ((crt->ext_key_usage).buf.p == (uchar *)0x0) { +LAB_23090236: + iVar2 = -0x2564; + goto LAB_2308fee2; + } + goto LAB_2308ffda; + } + } + else { + if (is_critical != 0x10000) goto LAB_23090162; + extn_oid.p = (uchar *)0x0; + iVar2 = mbedtls_asn1_get_bitstring + ((uchar **)&len,end_02, + (mbedtls_asn1_bitstring *)&extn_oid.p); + if (iVar2 == 0) { + if (extn_oid.p != &DAT_00000001) goto LAB_23090236; + crt->ns_cert_type = uRam00000000; + goto LAB_2308ffda; + } + } + } + } +LAB_230901b8: + iVar2 = iVar2 + -0x2500; + if (iVar2 != 0) goto LAB_2308fee2; + goto LAB_2308ffda; + } + if (iVar2 != -0x62) goto LAB_2308fee2; + } +LAB_23090094: + if (end_01 != (uchar *)len) { +LAB_2308fdda: + mbedtls_x509_crt_free(crt); + iVar2 = -0x21e6; + goto LAB_2308fdc2; + } +LAB_2308ffe4: + iVar2 = mbedtls_x509_get_alg + ((uchar **)&len,end_00, + (mbedtls_x509_buf *)&sig_params2.p, + (mbedtls_x509_buf *)&sig_params1.p); + if (iVar2 == 0) { + __n = (crt->sig_oid).len; + if (((__n != sig_oid2.tag) || + (iVar2 = memcmp((crt->sig_oid).p,(void *)sig_oid2.len,__n), + iVar2 != 0)) || + ((sig_params1.tag != sig_params2.tag || + ((sig_params1.tag != 0 && + (iVar2 = memcmp((void *)sig_params1.len,(void *)sig_params2.len, + sig_params1.tag), iVar2 != 0)))))) { + mbedtls_x509_crt_free(crt); + iVar2 = -0x2680; + goto LAB_2308fdc2; + } + iVar2 = mbedtls_x509_get_sig((uchar **)&len,end_00,&crt->sig); + if (iVar2 == 0) { + if (end_00 == (uchar *)len) { + return 0; + } + goto LAB_2308fdda; + } + } + } + } + } + } + } + } + } + } + } + else { + if (iVar2 == -0x62) { + crt->version = 0; + goto LAB_2308fe86; + } + } +LAB_2308fee2: + mbedtls_x509_crt_free(crt); + } + else { +LAB_2308fe2e: + mbedtls_x509_crt_free(crt); + iVar2 = iVar2 + -0x2180; + if (iVar2 == 0) { + return 0; + } + } + } + } + else { + mbedtls_x509_crt_free(crt); + iVar2 = -0x2180; + } +LAB_2308fdc2: + if (pmVar6 != (mbedtls_x509_crt *)0x0) goto LAB_2308fdc6; + } + if (chain == crt) { + return iVar2; + } +LAB_23090368: + vPortFree(crt); + return iVar2; +LAB_2309012c: + iVar2 = -0x2562; + goto LAB_2308fee2; +} + + + +int mbedtls_x509_crt_parse(mbedtls_x509_crt *chain,uchar *buf,size_t buflen) + +{ + bool bVar1; + int iVar2; + char *pcVar3; + int iVar4; + int iVar5; + size_t local_50; + size_t use_len; + mbedtls_pem_context pem; + + if ((chain == (mbedtls_x509_crt *)0x0) || (buf == (uchar *)0x0)) { + iVar4 = -0x2800; + } + else { + if (((buflen != 0) && (buf[buflen - 1] == '\0')) && + (pcVar3 = strstr((char *)buf,"-----BEGIN CERTIFICATE-----"), pcVar3 != (char *)0x0)) { + iVar4 = 0; + iVar2 = 0; + bVar1 = false; + while (1 < buflen) { + mbedtls_pem_init((mbedtls_pem_context *)&use_len); + iVar5 = mbedtls_pem_read_buffer + ((mbedtls_pem_context *)&use_len,"-----BEGIN CERTIFICATE-----", + "-----END CERTIFICATE-----",buf,(uchar *)0x0,0,&local_50); + if (iVar5 == 0) { + buflen = buflen - local_50; + buf = buf + local_50; + iVar5 = mbedtls_x509_crt_parse_der(chain,(uchar *)use_len,(size_t)pem.buf); + mbedtls_pem_free((mbedtls_pem_context *)&use_len); + if (iVar5 != 0) { + if (iVar5 == -0x2880) { + return -0x2880; + } + goto LAB_2309045a; + } + bVar1 = true; + } + else { + if (iVar5 == -0x1480) { + return -0x1480; + } + if (iVar5 == -0x1080) break; + mbedtls_pem_free((mbedtls_pem_context *)&use_len); + buflen = buflen - local_50; + buf = buf + local_50; +LAB_2309045a: + if (iVar2 == 0) { + iVar2 = iVar5; + } + iVar4 = iVar4 + 1; + } + } + if (bVar1) { + return iVar4; + } + if (iVar2 != 0) { + return iVar2; + } + return -0x2780; + } + iVar4 = mbedtls_x509_crt_parse_der(chain,buf,buflen); + } + return iVar4; +} + + + +void * mycalloc(size_t numitems,size_t size) + +{ + void *__s; + + __s = pvPortMalloc(numitems * size); + memset(__s,0,numitems * size); + return __s; +} + + + +void aes_gen_tables(void) + +{ + byte bVar1; + int *piVar2; + uint uVar3; + uchar *puVar4; + uint *puVar5; + uchar *puVar6; + int iVar7; + uint32_t *puVar8; + uint uVar9; + uint uVar10; + uint uVar11; + uint uVar12; + uint uVar13; + uint local_820; + int pow [256]; + int log [256]; + + puVar5 = &local_820; + uVar9 = 1; + iVar7 = 0; + do { + pow[uVar9 + 0xff] = iVar7; + *puVar5 = uVar9; + uVar3 = uVar9 & 0x80; + if (uVar3 != 0) { + uVar3 = 0x1b; + } + iVar7 = iVar7 + 1; + uVar9 = (uVar9 ^ uVar9 << 1 ^ uVar3) & 0xff; + puVar5 = puVar5 + 1; + } while (iVar7 != 0x100); + puVar8 = RCON; + uVar9 = 1; + do { + *puVar8 = uVar9; + uVar3 = uVar9 & 0x80; + if (uVar3 != 0) { + uVar3 = 0x1b; + } + puVar8 = puVar8 + 1; + uVar9 = (uVar3 ^ uVar9 << 1) & 0xff; + } while (puVar8 != (uint32_t *)RSb); + FSb[0] = 'c'; + RSb[99] = '\0'; + piVar2 = pow + 0xff; + iVar7 = 1; + puVar4 = FSb; + puVar6 = RSb; + do { + uVar13 = (&local_820)[0xff - piVar2[1]]; + piVar2 = piVar2 + 1; + uVar9 = uVar13 << 1 | (int)uVar13 >> 7; + uVar12 = uVar9 & 0xff; + uVar10 = (int)uVar12 >> 7; + uVar9 = (uVar9 & 0x7f) << 1; + uVar11 = (int)(uVar9 | uVar10) >> 7; + uVar3 = (uVar9 & 0x7f | uVar10) << 1 | uVar11; + uVar9 = ((int)uVar3 >> 7 | ((uVar9 & 0x3f | uVar10) << 1 | uVar11) << 1) ^ uVar13 ^ uVar12 ^ + (uVar9 | uVar10) ^ uVar3 ^ 99; + FSb[iVar7] = (uchar)uVar9; + RSb[uVar9] = (uchar)iVar7; + iVar7 = iVar7 + 1; + } while (iVar7 != 0x100); + iVar7 = 0; + do { + uVar9 = (uint)*puVar4; + uVar11 = (uVar9 << 1 ^ (int)(char)*puVar4 >> 0x1f & 0x1bU) & 0xff; + uVar3 = uVar9 << 8 ^ uVar9 << 0x10 ^ uVar11; + uVar10 = uVar3 ^ (uVar9 ^ uVar11) << 0x18; + *(uint *)((int)FT0 + iVar7) = uVar10; + *(uint *)((int)FT1 + iVar7) = uVar3 << 8 | uVar9 ^ uVar11; + *(uint *)((int)FT2 + iVar7) = uVar3 << 0x10 | uVar10 >> 0x10; + *(uint *)((int)FT3 + iVar7) = uVar11 << 0x18 | uVar10 >> 8; + bVar1 = *puVar6; + uVar9 = (uint)bVar1; + if (bVar1 == 0) { + uVar3 = 0; + uVar10 = 0; + } + else { + uVar3 = (&local_820)[(log[13] + pow[uVar9 + 0xff]) % 0xff]; + uVar10 = (&local_820)[(pow[uVar9 + 0xff] + log[8]) % 0xff] << 8; + } + uVar11 = 0; + if (bVar1 != 0) { + uVar11 = (&local_820)[(pow[uVar9 + 0xff] + log[12]) % 0xff] << 0x10; + } + uVar11 = uVar10 ^ uVar3 ^ uVar11; + uVar12 = 0; + if (bVar1 != 0) { + uVar12 = (&local_820)[(pow[uVar9 + 0xff] + log[10]) % 0xff] << 0x18; + } + uVar12 = uVar11 ^ uVar12; + *(uint *)((int)RT0 + iVar7) = uVar12; + *(uint *)((int)RT1 + iVar7) = uVar11 << 8 | uVar12 >> 0x18; + *(uint *)((int)RT2 + iVar7) = (uVar10 ^ uVar3) << 0x10 | uVar12 >> 0x10; + *(uint *)((int)RT3 + iVar7) = uVar3 << 0x18 | uVar12 >> 8; + iVar7 = iVar7 + 4; + puVar4 = puVar4 + 1; + puVar6 = puVar6 + 1; + } while (iVar7 != 0x400); + return; +} + + + +void mbedtls_aes_init(mbedtls_aes_context *ctx) + +{ + memset(ctx,0,0x118); + return; +} + + + +void mbedtls_aes_free(mbedtls_aes_context *ctx) + +{ + mbedtls_aes_context *pmVar1; + + pmVar1 = ctx + 1; + if (ctx != (mbedtls_aes_context *)0x0) { + while (ctx != pmVar1) { + *(undefined *)&ctx->nr = 0; + ctx = (mbedtls_aes_context *)((int)&ctx->nr + 1); + } + } + return; +} + + + +int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx,uchar *key,uint keybits) + +{ + byte *pbVar1; + uint32_t *puVar2; + uint uVar3; + int iVar4; + uint32_t *puVar5; + uint32_t *puVar6; + uint uVar7; + + if (aes_init_done == 0) { + aes_gen_tables(); + aes_init_done = 1; + } + if (keybits == 0xc0) { + iVar4 = 0xc; + } + else { + if (keybits == 0x100) { + iVar4 = 0xe; + } + else { + if (keybits != 0x80) { + return -0x20; + } + iVar4 = 10; + } + } + ctx->nr = iVar4; + puVar5 = ctx->buf; + ctx->rk = puVar5; + pbVar1 = key; + puVar2 = puVar5; + while (key + (keybits >> 5) * 4 != pbVar1) { + *puVar2 = (uint)pbVar1[1] << 8 | (uint)pbVar1[2] << 0x10 | (uint)*pbVar1 | + (uint)pbVar1[3] << 0x18; + pbVar1 = pbVar1 + 4; + puVar2 = puVar2 + 1; + } + iVar4 = ctx->nr; + if (iVar4 == 0xc) { + puVar2 = RCON; + do { + uVar3 = puVar5[5]; + uVar7 = *puVar2; + puVar6 = puVar5 + 6; + puVar2 = puVar2 + 1; + uVar7 = (uint)FSb[uVar3 >> 8 & 0xff] ^ *puVar5 ^ uVar7 ^ (uint)FSb[uVar3 >> 0x18] << 0x10 ^ + (uint)FSb[uVar3 & 0xff] << 0x18 ^ (uint)FSb[uVar3 >> 0x10 & 0xff] << 8; + *puVar6 = uVar7; + uVar7 = uVar7 ^ puVar5[1]; + puVar5[7] = uVar7; + uVar7 = uVar7 ^ puVar5[2]; + puVar5[8] = uVar7; + uVar7 = uVar7 ^ puVar5[3]; + puVar5[9] = uVar7; + uVar7 = uVar7 ^ puVar5[4]; + puVar5[10] = uVar7; + puVar5[0xb] = uVar7 ^ uVar3; + puVar5 = puVar6; + } while (puVar6 != ctx->buf + 0x30); + } + else { + if (iVar4 == 0xe) { + puVar2 = RCON; + do { + uVar3 = puVar5[7]; + uVar7 = *puVar2; + puVar6 = puVar5 + 8; + puVar2 = puVar2 + 1; + uVar7 = (uint)FSb[uVar3 >> 8 & 0xff] ^ *puVar5 ^ uVar7 ^ (uint)FSb[uVar3 >> 0x18] << 0x10 ^ + (uint)FSb[uVar3 & 0xff] << 0x18 ^ (uint)FSb[uVar3 >> 0x10 & 0xff] << 8; + *puVar6 = uVar7; + uVar7 = uVar7 ^ puVar5[1]; + puVar5[9] = uVar7; + uVar7 = uVar7 ^ puVar5[2]; + puVar5[10] = uVar7; + uVar7 = uVar7 ^ puVar5[3]; + puVar5[0xb] = uVar7; + uVar7 = (uint)FSb[uVar7 >> 0x10 & 0xff] << 0x10 ^ + (uint)FSb[uVar7 & 0xff] ^ puVar5[4] ^ (uint)FSb[uVar7 >> 0x18] << 0x18 ^ + (uint)FSb[uVar7 >> 8 & 0xff] << 8; + puVar5[0xc] = uVar7; + uVar7 = uVar7 ^ puVar5[5]; + puVar5[0xd] = uVar7; + uVar7 = uVar7 ^ puVar5[6]; + puVar5[0xe] = uVar7; + puVar5[0xf] = uVar7 ^ uVar3; + puVar5 = puVar6; + } while (puVar6 != ctx->buf + 0x38); + } + else { + if (iVar4 != 10) { + return 0; + } + puVar2 = RCON; + do { + uVar3 = puVar5[3]; + uVar7 = *puVar2; + puVar6 = puVar5 + 4; + puVar2 = puVar2 + 1; + uVar7 = (uint)FSb[uVar3 >> 8 & 0xff] ^ *puVar5 ^ uVar7 ^ (uint)FSb[uVar3 >> 0x18] << 0x10 ^ + (uint)FSb[uVar3 & 0xff] << 0x18 ^ (uint)FSb[uVar3 >> 0x10 & 0xff] << 8; + *puVar6 = uVar7; + uVar7 = uVar7 ^ puVar5[1]; + puVar5[5] = uVar7; + uVar7 = uVar7 ^ puVar5[2]; + puVar5[6] = uVar7; + puVar5[7] = uVar7 ^ uVar3; + puVar5 = puVar6; + } while (puVar6 != ctx->buf + 0x28); + } + } + return 0; +} + + + +int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx,uchar *key,uint keybits) + +{ + uint *puVar1; + int iVar2; + uint32_t *puVar3; + uint uVar4; + uint32_t *puVar5; + uint32_t *puVar6; + int iVar7; + int iStack296; + mbedtls_aes_context cty; + + mbedtls_aes_init((mbedtls_aes_context *)&iStack296); + ctx->rk = ctx->buf; + iVar2 = mbedtls_aes_setkey_enc((mbedtls_aes_context *)&iStack296,key,keybits); + if (iVar2 == 0) { + ctx->nr = iStack296; + puVar6 = (uint32_t *)(cty.nr + iStack296 * 0x10); + ctx->buf[0] = *puVar6; + ctx->buf[1] = puVar6[1]; + puVar3 = ctx->buf; + ctx->buf[2] = puVar6[2]; + ctx->buf[3] = puVar6[3]; + while( true ) { + puVar3 = puVar3 + 4; + puVar5 = puVar6 + -4; + iStack296 = iStack296 + -1; + if (iStack296 < 1) break; + iVar7 = 0; + do { + uVar4 = *(uint *)((int)puVar5 + iVar7); + puVar1 = (uint *)((int)puVar3 + iVar7); + iVar7 = iVar7 + 4; + *puVar1 = RT2[FSb[uVar4 >> 0x10 & 0xff]] ^ + RT0[FSb[uVar4 & 0xff]] ^ RT3[FSb[uVar4 >> 0x18]] ^ RT1[FSb[uVar4 >> 8 & 0xff]]; + puVar6 = puVar5; + } while (iVar7 != 0x10); + } + *puVar3 = *puVar5; + puVar3[1] = puVar6[-3]; + puVar3[2] = puVar6[-2]; + puVar3[3] = puVar6[-1]; + } + mbedtls_aes_free((mbedtls_aes_context *)&iStack296); + return iVar2; +} + + + +void mbedtls_aes_encrypt(mbedtls_aes_context *ctx,uchar *input,uchar *output) + +{ + byte bVar1; + byte bVar2; + byte bVar3; + byte bVar4; + byte bVar5; + byte bVar6; + byte bVar7; + byte bVar8; + byte bVar9; + byte bVar10; + byte bVar11; + byte bVar12; + byte bVar13; + byte bVar14; + byte bVar15; + uint uVar16; + uint uVar17; + uint uVar18; + uint uVar19; + uint uVar20; + uint32_t *puVar21; + uint uVar22; + uint uVar23; + uint uVar24; + int iVar25; + uint uVar26; + uint uVar27; + uint uVar28; + uint uVar29; + uint uVar30; + uint uVar31; + uint uVar32; + uint uVar33; + uint32_t *puVar34; + + puVar21 = ctx->rk; + puVar34 = puVar21 + 4; + uVar23 = *(uint *)input ^ *puVar21; + uVar30 = *(uint *)(input + 4) ^ puVar21[1]; + uVar28 = *(uint *)(input + 8) ^ puVar21[2]; + iVar25 = ctx->nr >> 1; + uVar26 = *(uint *)(input + 0xc) ^ puVar21[3]; + while( true ) { + iVar25 = iVar25 + -1; + uVar17 = FT0[uVar23 & 0xff] ^ FT3[uVar26 >> 0x18] ^ *puVar34 ^ + *(uint *)((int)FT1 + (uVar30 >> 6 & 0x3fc)) ^ + *(uint *)((int)FT2 + (uVar28 >> 0xe & 0x3fc)); + uVar31 = puVar34[4]; + uVar19 = FT0[uVar30 & 0xff] ^ FT3[uVar23 >> 0x18] ^ puVar34[1] ^ + *(uint *)((int)FT1 + (uVar28 >> 6 & 0x3fc)) ^ + *(uint *)((int)FT2 + (uVar26 >> 0xe & 0x3fc)); + uVar16 = FT0[uVar28 & 0xff] ^ FT3[uVar30 >> 0x18] ^ puVar34[2] ^ + *(uint *)((int)FT1 + (uVar26 >> 6 & 0x3fc)) ^ + *(uint *)((int)FT2 + (uVar23 >> 0xe & 0x3fc)); + uVar22 = FT0[uVar26 & 0xff] ^ FT3[uVar28 >> 0x18] ^ puVar34[3] ^ + *(uint *)((int)FT1 + (uVar23 >> 6 & 0x3fc)) ^ + *(uint *)((int)FT2 + (uVar30 >> 0xe & 0x3fc)); + uVar33 = uVar19 >> 8 & 0xff; + uVar23 = uVar16 >> 0x10 & 0xff; + uVar30 = puVar34[5]; + uVar32 = uVar16 >> 8 & 0xff; + uVar26 = uVar22 >> 0x10 & 0xff; + uVar29 = puVar34[6]; + uVar24 = uVar22 >> 8 & 0xff; + uVar28 = uVar17 >> 0x10 & 0xff; + uVar27 = puVar34[7]; + uVar18 = uVar17 >> 8 & 0xff; + uVar20 = uVar19 >> 0x10 & 0xff; + if (iVar25 < 1) break; + uVar23 = FT0[uVar17 & 0xff] ^ FT3[uVar22 >> 0x18] ^ uVar31 ^ FT1[uVar33] ^ FT2[uVar23]; + uVar30 = FT0[uVar19 & 0xff] ^ FT3[uVar17 >> 0x18] ^ uVar30 ^ FT1[uVar32] ^ FT2[uVar26]; + uVar28 = FT0[uVar16 & 0xff] ^ FT3[uVar19 >> 0x18] ^ uVar29 ^ FT1[uVar24] ^ FT2[uVar28]; + puVar34 = puVar34 + 8; + uVar26 = FT0[uVar22 & 0xff] ^ FT3[uVar16 >> 0x18] ^ uVar27 ^ FT1[uVar18] ^ FT2[uVar20]; + } + bVar1 = FSb[uVar33]; + bVar2 = FSb[uVar23]; + bVar3 = FSb[uVar22 >> 0x18]; + bVar4 = FSb[uVar32]; + bVar5 = FSb[uVar19 & 0xff]; + bVar6 = FSb[uVar26]; + bVar7 = FSb[uVar17 >> 0x18]; + bVar8 = FSb[uVar24]; + bVar9 = FSb[uVar16 & 0xff]; + bVar10 = FSb[uVar28]; + bVar11 = FSb[uVar19 >> 0x18]; + bVar12 = FSb[uVar22 & 0xff]; + bVar13 = FSb[uVar18]; + bVar14 = FSb[uVar20]; + bVar15 = FSb[uVar16 >> 0x18]; + *output = FSb[uVar17 & 0xff] ^ (byte)uVar31; + output[4] = bVar5 ^ (byte)uVar30; + output[1] = bVar1 ^ (byte)(uVar31 >> 8); + output[2] = (byte)(uVar31 >> 0x10) ^ bVar2; + output[5] = bVar4 ^ (byte)(uVar30 >> 8); + output[6] = (byte)(uVar30 >> 0x10) ^ bVar6; + output[9] = bVar8 ^ (byte)(uVar29 >> 8); + output[10] = (byte)(uVar29 >> 0x10) ^ bVar10; + output[8] = bVar9 ^ (byte)uVar29; + output[0xc] = bVar12 ^ (byte)uVar27; + output[0xd] = (byte)(uVar27 >> 8) ^ bVar13; + output[3] = (byte)(uVar31 >> 0x18) ^ bVar3; + output[7] = (byte)(uVar30 >> 0x18) ^ bVar7; + output[0xb] = (byte)(uVar29 >> 0x18) ^ bVar11; + output[0xf] = (byte)(uVar27 >> 0x18) ^ bVar15; + output[0xe] = (byte)(uVar27 >> 0x10) ^ bVar14; + return; +} + + + +void mbedtls_aes_decrypt(mbedtls_aes_context *ctx,uchar *input,uchar *output) + +{ + byte bVar1; + byte bVar2; + byte bVar3; + byte bVar4; + byte bVar5; + byte bVar6; + byte bVar7; + byte bVar8; + byte bVar9; + byte bVar10; + byte bVar11; + byte bVar12; + byte bVar13; + byte bVar14; + byte bVar15; + uint uVar16; + uint uVar17; + uint uVar18; + uint uVar19; + uint uVar20; + uint32_t *puVar21; + uint uVar22; + uint uVar23; + int iVar24; + uint uVar25; + uint uVar26; + uint uVar27; + uint uVar28; + uint uVar29; + uint uVar30; + uint uVar31; + uint uVar32; + uint uVar33; + uint32_t *puVar34; + + puVar21 = ctx->rk; + uVar29 = *(uint *)(input + 4) ^ puVar21[1]; + puVar34 = puVar21 + 4; + uVar27 = *(uint *)(input + 8) ^ puVar21[2]; + iVar24 = ctx->nr >> 1; + uVar23 = *(uint *)input ^ *puVar21; + uVar25 = *(uint *)(input + 0xc) ^ puVar21[3]; + while( true ) { + iVar24 = iVar24 + -1; + uVar17 = RT0[uVar23 & 0xff] ^ RT3[uVar29 >> 0x18] ^ *puVar34 ^ + *(uint *)((int)RT1 + (uVar25 >> 6 & 0x3fc)) ^ + *(uint *)((int)RT2 + (uVar27 >> 0xe & 0x3fc)); + uVar31 = puVar34[4]; + uVar16 = uVar17 >> 8 & 0xff; + uVar22 = RT0[uVar25 & 0xff] ^ RT3[uVar23 >> 0x18] ^ puVar34[3] ^ + *(uint *)((int)RT1 + (uVar27 >> 6 & 0x3fc)) ^ + *(uint *)((int)RT2 + (uVar29 >> 0xe & 0x3fc)); + uVar18 = RT0[uVar27 & 0xff] ^ RT3[uVar25 >> 0x18] ^ puVar34[2] ^ + *(uint *)((int)RT1 + (uVar29 >> 6 & 0x3fc)) ^ + *(uint *)((int)RT2 + (uVar23 >> 0xe & 0x3fc)); + uVar23 = RT0[uVar29 & 0xff] ^ RT3[uVar27 >> 0x18] ^ puVar34[1] ^ + *(uint *)((int)RT1 + (uVar23 >> 6 & 0x3fc)) ^ + *(uint *)((int)RT2 + (uVar25 >> 0xe & 0x3fc)); + uVar33 = uVar22 >> 8 & 0xff; + uVar32 = uVar18 >> 0x10 & 0xff; + uVar30 = puVar34[5]; + uVar29 = uVar22 >> 0x10 & 0xff; + uVar28 = puVar34[6]; + uVar27 = uVar23 >> 8 & 0xff; + uVar25 = uVar17 >> 0x10 & 0xff; + uVar26 = puVar34[7]; + uVar19 = uVar18 >> 8 & 0xff; + uVar20 = uVar23 >> 0x10 & 0xff; + if (iVar24 < 1) break; + uVar29 = RT0[uVar23 & 0xff] ^ RT3[uVar18 >> 0x18] ^ uVar30 ^ RT1[uVar16] ^ RT2[uVar29]; + uVar23 = RT0[uVar17 & 0xff] ^ RT3[uVar23 >> 0x18] ^ uVar31 ^ RT1[uVar33] ^ RT2[uVar32]; + uVar27 = RT0[uVar18 & 0xff] ^ RT3[uVar22 >> 0x18] ^ uVar28 ^ RT1[uVar27] ^ RT2[uVar25]; + puVar34 = puVar34 + 8; + uVar25 = RT0[uVar22 & 0xff] ^ RT3[uVar17 >> 0x18] ^ uVar26 ^ RT1[uVar19] ^ RT2[uVar20]; + } + bVar1 = RSb[uVar17 & 0xff]; + bVar2 = RSb[uVar32]; + bVar3 = RSb[uVar23 >> 0x18]; + bVar4 = RSb[uVar22 & 0xff]; + bVar5 = RSb[uVar16]; + bVar6 = RSb[uVar23 & 0xff]; + bVar7 = RSb[uVar29]; + bVar8 = RSb[uVar19]; + bVar9 = RSb[uVar18 >> 0x18]; + bVar10 = RSb[uVar20]; + bVar11 = RSb[uVar27]; + bVar12 = RSb[uVar18 & 0xff]; + bVar13 = RSb[uVar25]; + bVar14 = RSb[uVar17 >> 0x18]; + bVar15 = RSb[uVar22 >> 0x18]; + output[1] = RSb[uVar33] ^ (byte)(uVar31 >> 8); + output[2] = (byte)(uVar31 >> 0x10) ^ bVar2; + output[5] = bVar5 ^ (byte)(uVar30 >> 8); + output[6] = (byte)(uVar30 >> 0x10) ^ bVar7; + output[9] = bVar11 ^ (byte)(uVar28 >> 8); + output[10] = (byte)(uVar28 >> 0x10) ^ bVar13; + *output = bVar1 ^ (byte)uVar31; + output[4] = bVar6 ^ (byte)uVar30; + output[8] = bVar12 ^ (byte)uVar28; + output[0xc] = bVar4 ^ (byte)uVar26; + output[0xd] = (byte)(uVar26 >> 8) ^ bVar8; + output[3] = (byte)(uVar31 >> 0x18) ^ bVar3; + output[7] = (byte)(uVar30 >> 0x18) ^ bVar9; + output[0xb] = (byte)(uVar28 >> 0x18) ^ bVar15; + output[0xf] = (byte)(uVar26 >> 0x18) ^ bVar14; + output[0xe] = (byte)(uVar26 >> 0x10) ^ bVar10; + return; +} + + + +int mbedtls_aes_crypt_ecb(mbedtls_aes_context *ctx,int mode,uchar *input,uchar *output) + +{ + if (mode == 1) { + mbedtls_aes_encrypt(ctx,input,output); + } + else { + mbedtls_aes_decrypt(ctx,input,output); + } + return 0; +} + + + +int mbedtls_aes_crypt_cbc + (mbedtls_aes_context *ctx,int mode,size_t length,uchar *iv,uchar *input,uchar *output) + +{ + uint uVar1; + int iVar2; + byte *pbVar3; + byte *pbVar4; + byte *pbVar5; + uchar *input_00; + undefined auStack64 [4]; + uchar temp [16]; + + uVar1 = length & 0xf; + if (uVar1 == 0) { + if (mode == 0) { + while( true ) { + input_00 = output + -uVar1; + if (uVar1 + length == 0) break; + memcpy(auStack64,input + -uVar1,0x10); + mbedtls_aes_decrypt(ctx,input + -uVar1,input_00); + iVar2 = 0; + do { + pbVar3 = input_00 + iVar2; + pbVar4 = iv + iVar2; + iVar2 = iVar2 + 1; + *pbVar3 = *pbVar4 ^ *pbVar3; + } while (iVar2 != 0x10); + memcpy(iv,auStack64,0x10); + uVar1 = uVar1 - 0x10; + } + } + else { + while( true ) { + input_00 = output + -uVar1; + if (length + uVar1 == 0) break; + iVar2 = 0; + do { + pbVar5 = input + -uVar1 + iVar2; + pbVar3 = iv + iVar2; + pbVar4 = input_00 + iVar2; + iVar2 = iVar2 + 1; + *pbVar4 = *pbVar5 ^ *pbVar3; + } while (iVar2 != 0x10); + mbedtls_aes_crypt_ecb(ctx,mode,input_00,input_00); + memcpy(iv,input_00,0x10); + uVar1 = uVar1 - 0x10; + } + } + iVar2 = 0; + } + else { + iVar2 = -0x22; + } + return iVar2; +} + + + +int mbedtls_aes_crypt_cfb128 + (mbedtls_aes_context *ctx,int mode,size_t length,size_t *iv_off,uchar *iv,uchar *input + ,uchar *output) + +{ + uint uVar1; + byte *pbVar2; + byte bVar3; + + uVar1 = *iv_off; + pbVar2 = output; + if (mode == 0) { + while (pbVar2 != output + length) { + if (uVar1 == 0) { + mbedtls_aes_encrypt(ctx,iv,iv); + } + bVar3 = *input; + *pbVar2 = iv[uVar1] ^ bVar3; + iv[uVar1] = bVar3; + uVar1 = uVar1 + 1 & 0xf; + pbVar2 = pbVar2 + 1; + input = input + 1; + } + } + else { + while (pbVar2 != output + length) { + if (uVar1 == 0) { + mbedtls_aes_encrypt(ctx,iv,iv); + } + bVar3 = iv[uVar1] ^ *input; + *pbVar2 = bVar3; + iv[uVar1] = bVar3; + uVar1 = uVar1 + 1 & 0xf; + pbVar2 = pbVar2 + 1; + input = input + 1; + } + } + *iv_off = uVar1; + return 0; +} + + + +int mbedtls_aes_crypt_ctr + (mbedtls_aes_context *ctx,size_t length,size_t *nc_off,uchar *nonce_counter, + uchar *stream_block,uchar *input,uchar *output) + +{ + bool bVar1; + uchar uVar2; + uint uVar3; + uchar *puVar4; + byte *pbVar5; + + uVar3 = *nc_off; + pbVar5 = output; + do { + if (pbVar5 == output + length) { + *nc_off = uVar3; + return 0; + } + if (uVar3 == 0) { + mbedtls_aes_encrypt(ctx,nonce_counter,stream_block); + puVar4 = nonce_counter + 0xf; + do { + uVar2 = *puVar4; + *puVar4 = uVar2 + '\x01'; + if ((uchar)(uVar2 + '\x01') != '\0') break; + bVar1 = nonce_counter != puVar4; + puVar4 = puVar4 + -1; + } while (bVar1); + } + *pbVar5 = stream_block[uVar3] ^ *input; + uVar3 = uVar3 + 1 & 0xf; + input = input + 1; + pbVar5 = pbVar5 + 1; + } while( true ); +} + + + +int mbedtls_asn1_get_len(uchar **p,uchar *end,size_t *len) + +{ + uchar *puVar1; + byte bVar2; + byte *pbVar3; + + pbVar3 = *p; + puVar1 = end + -(int)pbVar3; + if ((int)puVar1 < 1) { + return -0x60; + } + if ((char)*pbVar3 < '\0') { + bVar2 = *pbVar3 & 0x7f; + if (bVar2 == 2) { + if ((int)puVar1 < 3) { + return -0x60; + } + *len = (uint)(*(ushort *)(pbVar3 + 1) >> 8) | ((uint)*(ushort *)(pbVar3 + 1) & 0xff) << 8; + puVar1 = *p + 3; + } + else { + if (bVar2 < 3) { + if (bVar2 != 1) { + return -100; + } + if (puVar1 == &DAT_00000001) { + return -0x60; + } + *len = (uint)pbVar3[1]; + puVar1 = *p + 2; + } + else { + if (bVar2 == 3) { + if ((int)puVar1 < 4) { + return -0x60; + } + *len = (uint)pbVar3[3] | (uint)pbVar3[1] << 0x10 | (uint)pbVar3[2] << 8; + puVar1 = *p + 4; + } + else { + if (bVar2 != 4) { + return -100; + } + if ((int)puVar1 < 5) { + return -0x60; + } + *len = (uint)pbVar3[3] << 8 | + (uint)pbVar3[1] << 0x18 | (uint)pbVar3[2] << 0x10 | (uint)pbVar3[4]; + puVar1 = *p + 5; + } + } + } + *p = puVar1; + } + else { + *p = pbVar3 + 1; + *len = (uint)*pbVar3; + } + if (end + -(int)*p < (uchar *)*len) { + return -0x60; + } + return 0; +} + + + +int mbedtls_asn1_get_tag(uchar **p,uchar *end,size_t *len,int tag) + +{ + int iVar1; + byte *pbVar2; + + pbVar2 = *p; + if ((int)(end + -(int)pbVar2) < 1) { + return -0x60; + } + if ((uint)*pbVar2 == tag) { + *p = pbVar2 + 1; + iVar1 = mbedtls_asn1_get_len(p,end,len); + return iVar1; + } + return -0x62; +} + + + +int mbedtls_asn1_get_bool(uchar **p,uchar *end,int *val) + +{ + int iVar1; + size_t sStack20; + size_t len; + + iVar1 = mbedtls_asn1_get_tag(p,end,&sStack20,1); + if (iVar1 == 0) { + if (sStack20 == 1) { + *val = (uint)(**p != '\0'); + *p = *p + 1; + } + else { + iVar1 = -100; + } + } + return iVar1; +} + + + +int mbedtls_asn1_get_int(uchar **p,uchar *end,int *val) + +{ + int iVar1; + size_t sStack20; + size_t len; + + iVar1 = mbedtls_asn1_get_tag(p,end,&sStack20,2); + if (iVar1 == 0) { + if ((sStack20 - 1 < 4) && (-1 < (char)**p)) { + *val = 0; + while (sStack20 != 0) { + *val = *val << 8 | (uint)**p; + *p = *p + 1; + sStack20 = sStack20 - 1; + } + } + else { + iVar1 = -100; + } + } + return iVar1; +} + + + +int mbedtls_asn1_get_mpi(uchar **p,uchar *end,mbedtls_mpi *X) + +{ + int iVar1; + size_t local_14; + size_t len; + + iVar1 = mbedtls_asn1_get_tag(p,end,&local_14,2); + if (iVar1 == 0) { + iVar1 = mbedtls_mpi_read_binary(X,*p,local_14); + *p = *p + local_14; + } + return iVar1; +} + + + +int mbedtls_asn1_get_bitstring(uchar **p,uchar *end,mbedtls_asn1_bitstring *bs) + +{ + byte bVar1; + int iVar2; + size_t sVar3; + uchar *puVar4; + + iVar2 = mbedtls_asn1_get_tag(p,end,(size_t *)bs,3); + if (iVar2 == 0) { + if (bs->len == 0) { + iVar2 = -0x60; + } + else { + bs->len = bs->len - 1; + bVar1 = **p; + bs->unused_bits = bVar1; + if (bVar1 < 8) { + puVar4 = *p + 1; + *p = puVar4; + sVar3 = bs->len; + bs->p = puVar4; + *p = puVar4 + sVar3; + if (puVar4 + sVar3 != end) { + iVar2 = -0x66; + } + } + else { + iVar2 = -100; + } + } + } + return iVar2; +} + + + +int mbedtls_asn1_get_bitstring_null(uchar **p,uchar *end,size_t *len) + +{ + int iVar1; + uint uVar2; + uchar *puVar3; + + iVar1 = mbedtls_asn1_get_tag(p,end,len,3); + if ((iVar1 == 0) && + ((uVar2 = *len, *len = uVar2 - 1, uVar2 < 2 || (puVar3 = *p, *p = puVar3 + 1, *puVar3 != '\0')) + )) { + iVar1 = -0x68; + } + return iVar1; +} + + + +int mbedtls_asn1_get_sequence_of(uchar **p,uchar *end,mbedtls_asn1_sequence *cur,int tag) + +{ + int iVar1; + mbedtls_asn1_sequence *pmVar2; + uchar *puVar3; + size_t sStack36; + size_t len; + + iVar1 = mbedtls_asn1_get_tag(p,end,&sStack36,0x30); + if (iVar1 == 0) { + if (end == *p + sStack36) { + do { + do { + if (end <= *p) { + cur->next = (mbedtls_asn1_sequence *)0x0; + if (*p == end) { + return 0; + } + goto LAB_230918de; + } + (cur->buf).tag = (uint)**p; + iVar1 = mbedtls_asn1_get_tag(p,end,&(cur->buf).len,tag); + if (iVar1 != 0) { + return iVar1; + } + puVar3 = *p; + (cur->buf).p = puVar3; + puVar3 = puVar3 + (cur->buf).len; + *p = puVar3; + } while (end <= puVar3); + pmVar2 = (mbedtls_asn1_sequence *)mycalloc(1,0x10); + cur->next = pmVar2; + cur = pmVar2; + } while (pmVar2 != (mbedtls_asn1_sequence *)0x0); + iVar1 = -0x6a; + } + else { +LAB_230918de: + iVar1 = -0x66; + } + } + return iVar1; +} + + + +int mbedtls_asn1_get_alg(uchar **p,uchar *end,mbedtls_asn1_buf *alg,mbedtls_asn1_buf *params) + +{ + int iVar1; + int iVar2; + uchar *puVar3; + byte *pbVar4; + mbedtls_asn1_buf *pmVar5; + byte *end_00; + size_t sStack36; + size_t len; + + iVar1 = mbedtls_asn1_get_tag(p,end,&sStack36,0x30); + if (iVar1 == 0) { + iVar1 = -0x60; + if (0 < (int)(end + -(int)*p)) { + alg->tag = (uint)**p; + end_00 = *p + sStack36; + iVar2 = mbedtls_asn1_get_tag(p,end_00,&alg->len,6); + iVar1 = iVar2; + if (iVar2 == 0) { + puVar3 = *p; + alg->p = puVar3; + pbVar4 = puVar3 + alg->len; + *p = pbVar4; + if (pbVar4 == end_00) { + pmVar5 = params + 1; + while (params != pmVar5) { + *(undefined *)¶ms->tag = 0; + params = (mbedtls_asn1_buf *)((int)¶ms->tag + 1); + } + } + else { + params->tag = (uint)*pbVar4; + *p = *p + 1; + iVar1 = mbedtls_asn1_get_len(p,end_00,¶ms->len); + if (iVar1 == 0) { + puVar3 = *p; + params->p = puVar3; + pbVar4 = puVar3 + params->len; + *p = pbVar4; + iVar1 = iVar2; + if (pbVar4 != end_00) { + iVar1 = -0x66; + } + } + } + } + } + } + return iVar1; +} + + + +void mpi_sub_hlp(size_t n,mbedtls_mpi_uint *s,mbedtls_mpi_uint *d) + +{ + mbedtls_mpi_uint *pmVar1; + uint uVar2; + uint uVar3; + uint uVar4; + mbedtls_mpi_uint *pmVar5; + uint uVar6; + size_t sVar7; + + uVar4 = 0; + sVar7 = 0; + pmVar1 = d; + while (sVar7 != n) { + uVar3 = *pmVar1; + pmVar5 = s + sVar7; + sVar7 = sVar7 + 1; + uVar2 = uVar3 - uVar4; + *pmVar1 = uVar2; + uVar6 = *pmVar5; + *pmVar1 = uVar2 - uVar6; + uVar4 = (uint)(uVar2 < uVar6) + (uint)(uVar3 < uVar4); + pmVar1 = pmVar1 + 1; + } + pmVar1 = d + sVar7; + while (uVar4 != 0) { + uVar3 = *pmVar1; + *pmVar1 = uVar3 - uVar4; + uVar4 = (uint)(uVar3 < uVar4); + pmVar1 = pmVar1 + 1; + } + return; +} + + + +void mpi_mul_hlp(size_t i,mbedtls_mpi_uint *s,mbedtls_mpi_uint *d,mbedtls_mpi_uint b) + +{ + size_t sVar1; + uint uVar2; + uint *puVar3; + uint *puVar4; + mbedtls_mpi_uint *pmVar5; + uint uVar6; + uint uVar7; + mbedtls_mpi_uint mVar8; + uint uVar9; + uint uVar10; + uint uVar11; + mbedtls_mpi_uint *pmVar12; + uint uVar13; + + uVar9 = 0; + sVar1 = i; + pmVar5 = d; + pmVar12 = s; + while (uVar11 = *pmVar5, 0xf < sVar1) { + uVar10 = *pmVar12; + sVar1 = sVar1 - 0x10; + uVar6 = b * uVar10 + uVar9; + uVar7 = uVar6 + uVar11; + *pmVar5 = uVar7; + uVar2 = pmVar12[1]; + uVar11 = (uint)(uVar7 < uVar11) + + (int)((ulonglong)b * (ulonglong)uVar10 >> 0x20) + (uint)(uVar6 < uVar9); + uVar6 = b * uVar2 + uVar11; + uVar9 = pmVar5[1]; + uVar7 = uVar6 + uVar9; + pmVar5[1] = uVar7; + uVar9 = (uint)(uVar7 < uVar9) + + (uint)(uVar6 < uVar11) + (int)((ulonglong)b * (ulonglong)uVar2 >> 0x20); + uVar11 = pmVar12[2]; + uVar6 = b * uVar11 + uVar9; + uVar2 = pmVar5[2]; + uVar7 = uVar6 + uVar2; + pmVar5[2] = uVar7; + uVar2 = (uint)(uVar7 < uVar2) + + (uint)(uVar6 < uVar9) + (int)((ulonglong)b * (ulonglong)uVar11 >> 0x20); + uVar9 = pmVar12[3]; + uVar6 = b * uVar9 + uVar2; + uVar11 = pmVar5[3]; + uVar7 = uVar6 + uVar11; + pmVar5[3] = uVar7; + uVar9 = (uint)(uVar7 < uVar11) + + (uint)(uVar6 < uVar2) + (int)((ulonglong)b * (ulonglong)uVar9 >> 0x20); + uVar11 = pmVar12[4]; + uVar6 = b * uVar11 + uVar9; + uVar2 = pmVar5[4]; + uVar7 = uVar6 + uVar2; + pmVar5[4] = uVar7; + uVar2 = (uint)(uVar7 < uVar2) + + (uint)(uVar6 < uVar9) + (int)((ulonglong)b * (ulonglong)uVar11 >> 0x20); + uVar9 = pmVar12[5]; + uVar6 = b * uVar9 + uVar2; + uVar11 = pmVar5[5]; + uVar7 = uVar6 + uVar11; + pmVar5[5] = uVar7; + uVar9 = (uint)(uVar7 < uVar11) + + (uint)(uVar6 < uVar2) + (int)((ulonglong)b * (ulonglong)uVar9 >> 0x20); + uVar11 = pmVar12[6]; + uVar6 = b * uVar11 + uVar9; + uVar2 = pmVar5[6]; + uVar7 = uVar6 + uVar2; + pmVar5[6] = uVar7; + uVar2 = (uint)(uVar7 < uVar2) + + (uint)(uVar6 < uVar9) + (int)((ulonglong)b * (ulonglong)uVar11 >> 0x20); + uVar9 = pmVar12[7]; + uVar6 = b * uVar9 + uVar2; + uVar11 = pmVar5[7]; + uVar7 = uVar6 + uVar11; + pmVar5[7] = uVar7; + uVar9 = (uint)(uVar7 < uVar11) + + (uint)(uVar6 < uVar2) + (int)((ulonglong)b * (ulonglong)uVar9 >> 0x20); + uVar11 = pmVar12[8]; + uVar6 = b * uVar11 + uVar9; + uVar2 = pmVar5[8]; + uVar7 = uVar6 + uVar2; + pmVar5[8] = uVar7; + uVar2 = (uint)(uVar7 < uVar2) + + (uint)(uVar6 < uVar9) + (int)((ulonglong)b * (ulonglong)uVar11 >> 0x20); + uVar9 = pmVar12[9]; + uVar6 = b * uVar9 + uVar2; + uVar11 = pmVar5[9]; + uVar7 = uVar6 + uVar11; + pmVar5[9] = uVar7; + uVar9 = (uint)(uVar7 < uVar11) + + (uint)(uVar6 < uVar2) + (int)((ulonglong)b * (ulonglong)uVar9 >> 0x20); + uVar11 = pmVar12[10]; + uVar6 = b * uVar11 + uVar9; + uVar2 = pmVar5[10]; + uVar7 = uVar6 + uVar2; + pmVar5[10] = uVar7; + uVar2 = (uint)(uVar7 < uVar2) + + (uint)(uVar6 < uVar9) + (int)((ulonglong)b * (ulonglong)uVar11 >> 0x20); + uVar9 = pmVar12[0xb]; + uVar6 = b * uVar9 + uVar2; + uVar11 = pmVar5[0xb]; + uVar7 = uVar6 + uVar11; + pmVar5[0xb] = uVar7; + uVar9 = (uint)(uVar7 < uVar11) + + (uint)(uVar6 < uVar2) + (int)((ulonglong)b * (ulonglong)uVar9 >> 0x20); + uVar11 = pmVar12[0xc]; + uVar6 = b * uVar11 + uVar9; + uVar2 = pmVar5[0xc]; + uVar7 = uVar6 + uVar2; + pmVar5[0xc] = uVar7; + uVar2 = (uint)(uVar7 < uVar2) + + (uint)(uVar6 < uVar9) + (int)((ulonglong)b * (ulonglong)uVar11 >> 0x20); + uVar9 = pmVar12[0xd]; + uVar6 = b * uVar9 + uVar2; + uVar11 = pmVar5[0xd]; + uVar7 = uVar6 + uVar11; + pmVar5[0xd] = uVar7; + uVar9 = (uint)(uVar7 < uVar11) + + (uint)(uVar6 < uVar2) + (int)((ulonglong)b * (ulonglong)uVar9 >> 0x20); + uVar11 = pmVar12[0xe]; + uVar6 = b * uVar11 + uVar9; + uVar2 = pmVar5[0xe]; + uVar7 = uVar6 + uVar2; + pmVar5[0xe] = uVar7; + uVar10 = pmVar12[0xf]; + uVar2 = (uint)(uVar7 < uVar2) + + (uint)(uVar6 < uVar9) + (int)((ulonglong)b * (ulonglong)uVar11 >> 0x20); + uVar9 = b * uVar10 + uVar2; + uVar6 = pmVar5[0xf]; + uVar11 = uVar9 + uVar6; + pmVar5[0xf] = uVar11; + uVar9 = (uint)(uVar11 < uVar6) + + (uint)(uVar9 < uVar2) + (int)((ulonglong)b * (ulonglong)uVar10 >> 0x20); + pmVar5 = pmVar5 + 0x10; + pmVar12 = pmVar12 + 0x10; + } + puVar4 = s + (i & 0xfffffff0); + d = d + (i & 0xfffffff0); + uVar2 = i + (i >> 4) * -0x10; + puVar3 = puVar4; + pmVar5 = d; + if (7 < uVar2) { + uVar13 = *puVar4; + uVar2 = uVar2 - 8; + pmVar5 = d + 8; + puVar3 = puVar4 + 8; + uVar6 = b * uVar13 + uVar9; + uVar7 = uVar6 + uVar11; + *d = uVar7; + uVar10 = puVar4[1]; + uVar13 = (uint)(uVar7 < uVar11) + + (int)((ulonglong)b * (ulonglong)uVar13 >> 0x20) + (uint)(uVar6 < uVar9); + uVar9 = b * uVar10 + uVar13; + uVar7 = d[1]; + uVar11 = uVar9 + uVar7; + d[1] = uVar11; + uVar6 = puVar4[2]; + uVar7 = (uint)(uVar9 < uVar13) + (int)((ulonglong)b * (ulonglong)uVar10 >> 0x20) + + (uint)(uVar11 < uVar7); + uVar9 = b * uVar6 + uVar7; + uVar10 = d[2]; + uVar11 = uVar9 + uVar10; + d[2] = uVar11; + uVar7 = (uint)(uVar11 < uVar10) + + (int)((ulonglong)b * (ulonglong)uVar6 >> 0x20) + (uint)(uVar9 < uVar7); + uVar9 = puVar4[3]; + uVar10 = b * uVar9 + uVar7; + uVar11 = d[3]; + uVar13 = uVar10 + uVar11; + d[3] = uVar13; + uVar6 = puVar4[4]; + uVar9 = (uint)(uVar13 < uVar11) + + (uint)(uVar10 < uVar7) + (int)((ulonglong)b * (ulonglong)uVar9 >> 0x20); + uVar10 = b * uVar6 + uVar9; + uVar11 = d[4]; + uVar13 = uVar10 + uVar11; + d[4] = uVar13; + uVar7 = puVar4[5]; + uVar11 = (uint)(uVar13 < uVar11) + + (uint)(uVar10 < uVar9) + (int)((ulonglong)b * (ulonglong)uVar6 >> 0x20); + uVar10 = b * uVar7 + uVar11; + uVar6 = d[5]; + uVar13 = uVar10 + uVar6; + d[5] = uVar13; + uVar9 = puVar4[6]; + uVar7 = (uint)(uVar13 < uVar6) + + (uint)(uVar10 < uVar11) + (int)((ulonglong)b * (ulonglong)uVar7 >> 0x20); + uVar10 = b * uVar9 + uVar7; + uVar11 = d[6]; + uVar13 = uVar10 + uVar11; + d[6] = uVar13; + uVar6 = puVar4[7]; + uVar9 = (uint)(uVar13 < uVar11) + + (uint)(uVar10 < uVar7) + (int)((ulonglong)b * (ulonglong)uVar9 >> 0x20); + uVar7 = b * uVar6 + uVar9; + uVar11 = d[7]; + uVar10 = uVar7 + uVar11; + d[7] = uVar10; + uVar9 = (uint)(uVar10 < uVar11) + + (uint)(uVar7 < uVar9) + (int)((ulonglong)b * (ulonglong)uVar6 >> 0x20); + } + puVar4 = puVar3; + pmVar12 = pmVar5; + while( true ) { + uVar11 = *pmVar12; + if (puVar4 == puVar3 + uVar2) break; + uVar6 = *puVar4; + uVar7 = b * uVar6 + uVar9; + uVar10 = uVar7 + uVar11; + *pmVar12 = uVar10; + uVar9 = (uint)(uVar10 < uVar11) + + (int)((ulonglong)b * (ulonglong)uVar6 >> 0x20) + (uint)(uVar7 < uVar9); + puVar4 = puVar4 + 1; + pmVar12 = pmVar12 + 1; + } + pmVar5 = pmVar5 + uVar2; + while( true ) { + mVar8 = *pmVar5; + *pmVar5 = mVar8 + uVar9; + if (uVar9 <= mVar8 + uVar9) break; + uVar9 = 1; + pmVar5 = pmVar5 + 1; + } + return; +} + + + +void mbedtls_mpi_init(mbedtls_mpi *X) + +{ + if (X != (mbedtls_mpi *)0x0) { + X->s = 1; + X->n = 0; + X->p = (mbedtls_mpi_uint *)0x0; + } + return; +} + + + +void mbedtls_mpi_free(mbedtls_mpi *X) + +{ + size_t sVar1; + mbedtls_mpi_uint *pmVar2; + + if (X != (mbedtls_mpi *)0x0) { + pmVar2 = X->p; + if (pmVar2 != (mbedtls_mpi_uint *)0x0) { + sVar1 = X->n; + while (sVar1 = sVar1 - 1, sVar1 != 0xffffffff) { + *pmVar2 = 0; + pmVar2 = pmVar2 + 1; + } + vPortFree(X->p); + } + X->s = 1; + X->n = 0; + X->p = (mbedtls_mpi_uint *)0x0; + return; + } + return; +} + + + +int mbedtls_mpi_grow(mbedtls_mpi *X,size_t nblimbs) + +{ + mbedtls_mpi_uint *__dest; + int iVar1; + mbedtls_mpi_uint *pmVar2; + size_t sVar3; + + if (10000 < nblimbs) { + return -0x10; + } + iVar1 = 0; + if (X->n < nblimbs) { + __dest = (mbedtls_mpi_uint *)mycalloc(nblimbs,4); + if (__dest == (mbedtls_mpi_uint *)0x0) { + iVar1 = -0x10; + } + else { + if (X->p != (mbedtls_mpi_uint *)0x0) { + memcpy(__dest,X->p,X->n << 2); + pmVar2 = X->p; + sVar3 = X->n; + while (sVar3 = sVar3 - 1, sVar3 != 0xffffffff) { + *pmVar2 = 0; + pmVar2 = pmVar2 + 1; + } + vPortFree(X->p); + } + X->n = nblimbs; + X->p = __dest; + iVar1 = 0; + } + } + return iVar1; +} + + + +int mbedtls_mpi_shrink(mbedtls_mpi *X,size_t nblimbs) + +{ + uint uVar1; + int iVar2; + mbedtls_mpi_uint *__dest; + mbedtls_mpi_uint *pmVar3; + size_t sVar4; + uint uVar5; + + uVar5 = X->n; + if (X->n <= nblimbs) { + iVar2 = mbedtls_mpi_grow(X,nblimbs); + return iVar2; + } + do { + uVar1 = uVar5; + uVar5 = uVar1 - 1; + if (uVar5 == 0) break; + } while (X->p[uVar5] == 0); + if (nblimbs < uVar1) { + nblimbs = uVar1; + } + __dest = (mbedtls_mpi_uint *)mycalloc(nblimbs,4); + iVar2 = -0x10; + if (__dest != (mbedtls_mpi_uint *)0x0) { + if (X->p != (mbedtls_mpi_uint *)0x0) { + memcpy(__dest,X->p,nblimbs << 2); + pmVar3 = X->p; + sVar4 = X->n; + while (sVar4 = sVar4 - 1, sVar4 != 0xffffffff) { + *pmVar3 = 0; + pmVar3 = pmVar3 + 1; + } + vPortFree(X->p); + } + X->n = nblimbs; + X->p = __dest; + iVar2 = 0; + } + return iVar2; +} + + + +int mbedtls_mpi_copy(mbedtls_mpi *X,mbedtls_mpi *Y) + +{ + int iVar1; + size_t nblimbs; + + if (X != Y) { + if (Y->p != (mbedtls_mpi_uint *)0x0) { + nblimbs = Y->n; + do { + nblimbs = nblimbs; + nblimbs = nblimbs - 1; + if (nblimbs == 0) break; + } while (Y->p[nblimbs] == 0); + X->s = Y->s; + iVar1 = mbedtls_mpi_grow(X,nblimbs); + if (iVar1 != 0) { + return iVar1; + } + memset(X->p,0,X->n << 2); + memcpy(X->p,Y->p,nblimbs << 2); + return 0; + } + mbedtls_mpi_free(X); + } + return 0; +} + + + +int mbedtls_mpi_safe_cond_assign(mbedtls_mpi *X,mbedtls_mpi *Y,uchar assign) + +{ + int iVar1; + mbedtls_mpi_uint *pmVar2; + uint uVar3; + mbedtls_mpi_uint *pmVar4; + int iVar5; + uint uVar6; + + iVar1 = mbedtls_mpi_grow(X,Y->n); + if (iVar1 == 0) { + uVar3 = ((uint)assign | -(uint)assign & 0xff) >> 7; + iVar5 = 1 - uVar3; + X->s = iVar5 * X->s + uVar3 * Y->s; + uVar6 = 0; + while (uVar6 < Y->n) { + pmVar2 = X->p + uVar6; + pmVar4 = Y->p + uVar6; + uVar6 = uVar6 + 1; + *pmVar2 = uVar3 * *pmVar4 + iVar5 * *pmVar2; + } + while (uVar6 < X->n) { + X->p[uVar6] = X->p[uVar6] * iVar5; + uVar6 = uVar6 + 1; + } + } + return iVar1; +} + + + +int mbedtls_mpi_lset(mbedtls_mpi *X,mbedtls_mpi_sint z) + +{ + int iVar1; + int iVar2; + + iVar1 = mbedtls_mpi_grow(X,1); + if (iVar1 == 0) { + memset(X->p,0,X->n << 2); + *X->p = (z >> 0x1f ^ z) - (z >> 0x1f); + iVar2 = -1; + if (-1 < z) { + iVar2 = 1; + } + X->s = iVar2; + } + return iVar1; +} + + + +int mbedtls_mpi_get_bit(mbedtls_mpi *X,size_t pos) + +{ + if (pos < X->n << 5) { + return X->p[pos >> 5] >> (pos & 0x1f) & 1; + } + return 0; +} + + + +size_t mbedtls_mpi_lsb(mbedtls_mpi *X) + +{ + int iVar1; + size_t sVar2; + uint uVar3; + + sVar2 = 0; + iVar1 = 0; + do { + if (X->n == sVar2) { + return 0; + } + uVar3 = 0; + do { + if ((X->p[sVar2] >> (uVar3 & 0x1f) & 1) != 0) { + return iVar1 + uVar3; + } + uVar3 = uVar3 + 1; + } while (uVar3 != 0x20); + sVar2 = sVar2 + 1; + iVar1 = iVar1 + uVar3; + } while( true ); +} + + + +size_t mbedtls_mpi_bitlen(mbedtls_mpi *X) + +{ + int iVar1; + uint uVar2; + size_t sVar3; + size_t sVar4; + + sVar3 = X->n; + if (sVar3 != 0) { + do { + sVar4 = sVar3; + sVar3 = sVar4 - 1; + if (sVar3 == 0) break; + } while (X->p[sVar3] == 0); + iVar1 = 0; + uVar2 = 0x80000000; + do { + if ((X->p[sVar3] & uVar2) != 0) break; + iVar1 = iVar1 + 1; + uVar2 = uVar2 >> 1; + } while (iVar1 != 0x20); + sVar3 = sVar4 * 0x20 - iVar1; + } + return sVar3; +} + + + +size_t mbedtls_mpi_size(mbedtls_mpi *X) + +{ + size_t sVar1; + + sVar1 = mbedtls_mpi_bitlen(X); + return sVar1 + 7 >> 3; +} + + + +int mbedtls_mpi_read_binary(mbedtls_mpi *X,uchar *buf,size_t buflen) + +{ + uint uVar1; + uint uVar2; + int iVar3; + uint *puVar4; + uint uVar5; + + uVar2 = 0; + while ((uVar2 != buflen && (buf[uVar2] == '\0'))) { + uVar2 = uVar2 + 1; + } + iVar3 = mbedtls_mpi_grow(X,(uint)((buflen - uVar2 & 3) != 0) + (buflen - uVar2 >> 2)); + if (iVar3 == 0) { + iVar3 = mbedtls_mpi_lset(X,0); + uVar5 = 0; + if (iVar3 == 0) { + while (uVar2 < buflen) { + buflen = buflen - 1; + puVar4 = (uint *)((int)X->p + (uVar5 & 0xfffffffc)); + uVar1 = uVar5 & 3; + uVar5 = uVar5 + 1; + *puVar4 = *puVar4 | (uint)buf[buflen] << (uVar1 << 3); + } + } + } + return iVar3; +} + + + +int mbedtls_mpi_write_binary(mbedtls_mpi *X,uchar *buf,size_t buflen) + +{ + uint uVar1; + size_t sVar2; + int iVar3; + uint uVar4; + uint uVar5; + + sVar2 = mbedtls_mpi_size(X); + if (buflen < sVar2) { + iVar3 = -8; + } + else { + memset(buf,0,buflen); + buf = buf + buflen; + uVar5 = 0; + while (buf = buf + -1, uVar5 != sVar2) { + uVar4 = uVar5 & 0xfffffffc; + uVar1 = uVar5 & 3; + uVar5 = uVar5 + 1; + *buf = (uchar)(*(uint *)((int)X->p + uVar4) >> (uVar1 << 3)); + } + iVar3 = 0; + } + return iVar3; +} + + + +int mbedtls_mpi_shift_l(mbedtls_mpi *X,size_t count) + +{ + uint uVar1; + size_t sVar2; + uint uVar3; + int iVar4; + uint uVar5; + uint uVar6; + + uVar1 = count >> 5; + uVar6 = count & 0x1f; + sVar2 = mbedtls_mpi_bitlen(X); + uVar3 = sVar2 + count; + if ((uVar3 <= X->n << 5) || + (iVar4 = mbedtls_mpi_grow(X,(uint)((uVar3 & 0x1f) != 0) + (uVar3 >> 5)), iVar4 == 0)) { + if (0x1f < count) { + uVar3 = X->n; + iVar4 = uVar3 << 2; + while (iVar4 = iVar4 + -4, uVar1 < uVar3) { + uVar3 = uVar3 - 1; + *(undefined4 *)((int)X->p + iVar4) = *(undefined4 *)((int)X->p + iVar4 + uVar1 * -4); + } + iVar4 = uVar3 << 2; + while (iVar4 = iVar4 + -4, iVar4 != -4) { + *(undefined4 *)((int)X->p + iVar4) = 0; + } + } + if (uVar6 != 0) { + uVar3 = 0; + while (uVar1 < X->n) { + uVar5 = X->p[uVar1]; + X->p[uVar1] = uVar5 << uVar6; + X->p[uVar1] = X->p[uVar1] | uVar3; + uVar3 = uVar5 >> (0x20 - uVar6 & 0x1f); + uVar1 = uVar1 + 1; + } + } + iVar4 = 0; + } + return iVar4; +} + + + +int mbedtls_mpi_shift_r(mbedtls_mpi *X,size_t count) + +{ + int iVar1; + uint uVar2; + uint uVar3; + uint uVar4; + size_t sVar5; + mbedtls_mpi_uint *pmVar6; + + uVar3 = count >> 5; + uVar4 = count & 0x1f; + if (X->n < uVar3) { +LAB_2309231c: + iVar1 = mbedtls_mpi_lset(X,0); + return iVar1; + } + if (X->n == uVar3) { + if (uVar4 != 0) goto LAB_2309231c; + if (count < 0x20) { + return 0; + } + uVar2 = 0; + } + else { + if (count < 0x20) goto LAB_2309233c; + iVar1 = uVar3 << 2; + uVar2 = 0; + while (uVar2 < X->n - uVar3) { + pmVar6 = (mbedtls_mpi_uint *)((int)X->p + iVar1); + iVar1 = iVar1 + 4; + X->p[uVar2] = *pmVar6; + uVar2 = uVar2 + 1; + } + } + while (uVar2 < X->n) { + X->p[uVar2] = 0; + uVar2 = uVar2 + 1; + } +LAB_2309233c: + if (uVar4 != 0) { + sVar5 = X->n; + uVar3 = 0; + while (sVar5 = sVar5 - 1, sVar5 != 0xffffffff) { + uVar2 = X->p[sVar5]; + X->p[sVar5] = uVar2 >> uVar4; + X->p[sVar5] = X->p[sVar5] | uVar3; + uVar3 = uVar2 << (0x20 - uVar4 & 0x1f); + } + } + return 0; +} + + + +int mbedtls_mpi_cmp_abs(mbedtls_mpi *X,mbedtls_mpi *Y) + +{ + uint uVar1; + uint uVar2; + + uVar2 = X->n; + while ((uVar2 != 0 && (X->p[uVar2 - 1] == 0))) { + uVar2 = uVar2 - 1; + } + uVar1 = Y->n; + while( true ) { + if (uVar1 == 0) { + return (uint)(uVar2 != 0); + } + if (Y->p[uVar1 - 1] != 0) break; + uVar1 = uVar1 - 1; + } + if (uVar2 <= uVar1) { + if (uVar2 < uVar1) { + return -1; + } + while( true ) { + uVar2 = uVar2 - 1; + if (uVar2 == 0xffffffff) { + return 0; + } + uVar1 = Y->p[uVar2]; + if (uVar1 < X->p[uVar2]) break; + if (X->p[uVar2] < uVar1) { + return -1; + } + } + return 1; + } + return 1; +} + + + +int mpi_montmul(mbedtls_mpi *A,mbedtls_mpi *B,mbedtls_mpi *N,mbedtls_mpi_uint mm,mbedtls_mpi *T) + +{ + int iVar1; + mbedtls_mpi_uint *d; + mbedtls_mpi_uint mVar2; + mbedtls_mpi_uint *s; + mbedtls_mpi_uint mVar3; + size_t n; + uint i; + uint i_00; + mbedtls_mpi_uint b; + + if ((N->n + 1 <= T->n) && (T->p != (mbedtls_mpi_uint *)0x0)) { + memset(T->p,0,T->n << 2); + i = N->n; + s = T->p; + i_00 = B->n; + if (i < B->n) { + i_00 = i; + } + n = 0; + d = s; + while (n != i) { + b = A->p[n]; + mVar3 = *B->p; + mVar2 = *d; + n = n + 1; + mpi_mul_hlp(i_00,B->p,d,b); + mpi_mul_hlp(i,N->p,d,(b * mVar3 + mVar2) * mm); + *d = b; + (d + 1)[i + 1] = 0; + d = d + 1; + } + memcpy(A->p,s + i,(i + 1) * 4); + iVar1 = mbedtls_mpi_cmp_abs(A,N); + if (iVar1 < 0) { + d = T->p; + s = A->p; + } + else { + s = N->p; + d = A->p; + } + mpi_sub_hlp(n,s,d); + return 0; + } + return -4; +} + + + +int mbedtls_mpi_cmp_mpi(mbedtls_mpi *X,mbedtls_mpi *Y) + +{ + int iVar1; + uint uVar2; + int iVar3; + uint uVar4; + + uVar4 = X->n; + while ((uVar4 != 0 && (X->p[uVar4 - 1] == 0))) { + uVar4 = uVar4 - 1; + } + uVar2 = Y->n; + do { + if (uVar2 == 0) { + if (uVar4 == 0) { + return 0; + } +LAB_2309255e: + return X->s; + } + if (Y->p[uVar2 - 1] != 0) { + if (uVar4 <= uVar2) { + iVar1 = Y->s; + if (uVar4 < uVar2) { + return -iVar1; + } + iVar3 = X->s; + if (iVar3 < 1) { + if ((0 < iVar1) && (iVar3 != 0)) { + return -1; + } + } + else { + if (iVar1 < 0) { + return 1; + } + } + while( true ) { + uVar4 = uVar4 - 1; + if (uVar4 == 0xffffffff) { + return 0; + } + uVar2 = Y->p[uVar4]; + if (uVar2 < X->p[uVar4]) break; + if (X->p[uVar4] < uVar2) { + return -iVar3; + } + } + return iVar3; + } + goto LAB_2309255e; + } + uVar2 = uVar2 - 1; + } while( true ); +} + + + +int mbedtls_mpi_cmp_int(mbedtls_mpi *X,mbedtls_mpi_sint z) + +{ + int iVar1; + mbedtls_mpi_uint p [1]; + mbedtls_mpi Y; + + p = 1; + if (z < 0) { + p = 0xffffffff; + } + iVar1 = mbedtls_mpi_cmp_mpi(X,(mbedtls_mpi *)p); + return iVar1; +} + + + +int mbedtls_mpi_add_abs(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *B) + +{ + size_t nblimbs; + mbedtls_mpi *pmVar1; + uint uVar2; + int iVar3; + mbedtls_mpi_uint *pmVar4; + int iVar5; + uint uVar6; + mbedtls_mpi_uint *pmVar7; + size_t sVar8; + mbedtls_mpi_uint mVar9; + uint uVar10; + mbedtls_mpi_uint *pmVar11; + + pmVar1 = A; + if (((X == B) || (pmVar1 = B, X == A)) || (iVar3 = mbedtls_mpi_copy(X,A), iVar3 == 0)) { + X->s = 1; + nblimbs = pmVar1->n; + while ((nblimbs != 0 && (pmVar1->p[nblimbs - 1] == 0))) { + nblimbs = nblimbs - 1; + } + iVar3 = mbedtls_mpi_grow(X,nblimbs); + if (iVar3 == 0) { + pmVar11 = X->p; + pmVar4 = pmVar1->p; + sVar8 = 0; + uVar2 = 0; + pmVar7 = pmVar11; + while (nblimbs != sVar8) { + uVar6 = pmVar4[sVar8]; + mVar9 = *pmVar7; + sVar8 = sVar8 + 1; + uVar10 = mVar9 + uVar2 + uVar6; + *pmVar7 = uVar10; + uVar2 = (uint)(mVar9 + uVar2 < uVar2) + (uint)(uVar10 < uVar6); + pmVar7 = pmVar7 + 1; + } + pmVar7 = pmVar11 + nblimbs; + while (uVar2 != 0) { + if (X->n <= nblimbs) { + iVar5 = mbedtls_mpi_grow(X,nblimbs + 1); + if (iVar5 != 0) { + return iVar5; + } + pmVar7 = X->p + nblimbs; + } + mVar9 = *pmVar7; + *pmVar7 = mVar9 + uVar2; + uVar2 = (uint)(mVar9 + uVar2 < uVar2); + nblimbs = nblimbs + 1; + pmVar7 = pmVar7 + 1; + } + } + } + return iVar3; +} + + + +int mbedtls_mpi_sub_abs(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *B) + +{ + int iVar1; + size_t n; + int iStack44; + mbedtls_mpi TB; + + iVar1 = mbedtls_mpi_cmp_abs(A,B); + if (iVar1 < 0) { + return -10; + } + iStack44 = 1; + TB.s = 0; + TB.n = 0; + if (B == X) { + iVar1 = mbedtls_mpi_copy((mbedtls_mpi *)&iStack44,B); + if (iVar1 != 0) goto cleanup; + B = (mbedtls_mpi *)&iStack44; + } + if ((A == X) || (iVar1 = mbedtls_mpi_copy(X,A), iVar1 == 0)) { + X->s = 1; + n = B->n; + while ((n != 0 && (B->p[n - 1] == 0))) { + n = n - 1; + } + iVar1 = 0; + mpi_sub_hlp(n,B->p,X->p); + } +cleanup: + mbedtls_mpi_free((mbedtls_mpi *)&iStack44); + return iVar1; +} + + + +int mbedtls_mpi_add_mpi(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *B) + +{ + int iVar1; + int iVar2; + + iVar1 = A->s; + if (iVar1 * B->s < 0) { + iVar2 = mbedtls_mpi_cmp_abs(A,B); + if (iVar2 < 0) { + iVar2 = mbedtls_mpi_sub_abs(X,B,A); + iVar1 = -iVar1; + } + else { + iVar2 = mbedtls_mpi_sub_abs(X,A,B); + } + } + else { + iVar2 = mbedtls_mpi_add_abs(X,A,B); + } + if (iVar2 == 0) { + X->s = iVar1; + } + return iVar2; +} + + + +int mbedtls_mpi_sub_mpi(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *B) + +{ + int iVar1; + int iVar2; + + iVar1 = A->s; + if (iVar1 * B->s < 1) { + iVar2 = mbedtls_mpi_add_abs(X,A,B); + } + else { + iVar2 = mbedtls_mpi_cmp_abs(A,B); + if (iVar2 < 0) { + iVar2 = mbedtls_mpi_sub_abs(X,B,A); + iVar1 = -iVar1; + } + else { + iVar2 = mbedtls_mpi_sub_abs(X,A,B); + } + } + if (iVar2 == 0) { + X->s = iVar1; + } + return iVar2; +} + + + +int mbedtls_mpi_sub_int(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi_sint b) + +{ + int iVar1; + mbedtls_mpi_uint p [1]; + mbedtls_mpi _B; + + p = 1; + if (b < 0) { + p = 0xffffffff; + } + iVar1 = mbedtls_mpi_sub_mpi(X,A,(mbedtls_mpi *)p); + return iVar1; +} + + + +// WARNING: Variable defined which should be unmapped: TB + +int mbedtls_mpi_mul_mpi(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *B) + +{ + int iVar1; + size_t sVar2; + size_t i; + int local_38; + mbedtls_mpi TA; + mbedtls_mpi TB; + + local_38 = 1; + TA.s = 0; + TA.n = 0; + TA.p = (mbedtls_mpi_uint *)&DAT_00000001; + if (X == A) { + iVar1 = mbedtls_mpi_copy((mbedtls_mpi *)&local_38,A); + A = (mbedtls_mpi *)&local_38; + if (iVar1 != 0) goto cleanup; + } + if (X == B) { + iVar1 = mbedtls_mpi_copy((mbedtls_mpi *)&TA.p,X); + if (iVar1 != 0) goto cleanup; + B = (mbedtls_mpi *)&TA.p; + } + i = A->n; + while ((i != 0 && (A->p[i - 1] == 0))) { + i = i - 1; + } + sVar2 = B->n; + while ((sVar2 != 0 && (B->p[sVar2 - 1] == 0))) { + sVar2 = sVar2 - 1; + } + iVar1 = mbedtls_mpi_grow(X,i + sVar2); + if ((iVar1 == 0) && (iVar1 = mbedtls_mpi_lset(X,0), iVar1 == 0)) { + while (sVar2 = sVar2 - 1, sVar2 != 0xffffffff) { + mpi_mul_hlp(i,A->p,X->p + sVar2,B->p[sVar2]); + } + X->s = A->s * B->s; + } +cleanup: + mbedtls_mpi_free((mbedtls_mpi *)&TA.p); + mbedtls_mpi_free((mbedtls_mpi *)&local_38); + return iVar1; +} + + + +int mbedtls_mpi_mul_int(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi_uint b) + +{ + int iVar1; + mbedtls_mpi_uint p [1]; + mbedtls_mpi _B; + + p = 1; + iVar1 = mbedtls_mpi_mul_mpi(X,A,(mbedtls_mpi *)p); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mbedtls_mpi_div_mpi(mbedtls_mpi *Q,mbedtls_mpi *R,mbedtls_mpi *A,mbedtls_mpi *B) + +{ + int iVar1; + int iVar2; + int iVar3; + size_t count; + int iVar4; + undefined4 uVar5; + uint uVar6; + uint uVar7; + undefined4 uVar8; + int *piVar9; + size_t count_00; + uint uVar10; + int iVar11; + uint uVar12; + undefined4 *puVar13; + int iStack124; + mbedtls_mpi X; + mbedtls_mpi Y; + mbedtls_mpi Z; + mbedtls_mpi T1; + mbedtls_mpi T2; + + iVar3 = mbedtls_mpi_cmp_int(B,0); + if (iVar3 == 0) { + return -0xc; + } + iStack124 = 1; + X.s = 0; + X.n = 0; + X.p = (mbedtls_mpi_uint *)&DAT_00000001; + Y.s = 0; + Y.n = 0; + Y.p = (mbedtls_mpi_uint *)&DAT_00000001; + Z.s = 0; + Z.n = 0; + Z.p = (mbedtls_mpi_uint *)&DAT_00000001; + T1.s = 0; + T1.n = 0; + T1.p = (mbedtls_mpi_uint *)&DAT_00000001; + iVar3 = mbedtls_mpi_cmp_abs(A,B); + if (iVar3 < 0) { + if (((Q == (mbedtls_mpi *)0x0) || (iVar3 = mbedtls_mpi_lset(Q,0), iVar3 == 0)) && + ((R == (mbedtls_mpi *)0x0 || (iVar3 = mbedtls_mpi_copy(R,A), iVar3 == 0)))) { + return 0; + } + } + else { + iVar3 = mbedtls_mpi_copy((mbedtls_mpi *)&iStack124,A); + if ((iVar3 == 0) && (iVar3 = mbedtls_mpi_copy((mbedtls_mpi *)&X.p,B), iVar3 == 0)) { + X.p = (mbedtls_mpi_uint *)&DAT_00000001; + iStack124 = 1; + iVar3 = mbedtls_mpi_grow((mbedtls_mpi *)&Y.p,A->n + 2); + if ((iVar3 == 0) && + (((iVar3 = mbedtls_mpi_lset((mbedtls_mpi *)&Y.p,0), iVar3 == 0 && + (iVar3 = mbedtls_mpi_grow((mbedtls_mpi *)&Z.p,2), iVar3 == 0)) && + (iVar3 = mbedtls_mpi_grow((mbedtls_mpi *)&T1.p,3), iVar3 == 0)))) { + count = mbedtls_mpi_bitlen((mbedtls_mpi *)&X.p); + if ((count & 0x1f) == 0x1f) { + count = 0; + } + else { + count = 0x1f - (count & 0x1f); + iVar3 = mbedtls_mpi_shift_l((mbedtls_mpi *)&iStack124,count); + if ((iVar3 != 0) || (iVar3 = mbedtls_mpi_shift_l((mbedtls_mpi *)&X.p,count), iVar3 != 0)) + goto cleanup; + } + iVar4 = Y.s; + uVar10 = X.s; + iVar1 = X.s - Y.s; + count_00 = iVar1 * 0x20; + iVar3 = mbedtls_mpi_shift_l((mbedtls_mpi *)&X.p,count_00); + while (iVar3 == 0) { + iVar3 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&iStack124,(mbedtls_mpi *)&X.p); + if (iVar3 < 0) { + iVar1 = mbedtls_mpi_shift_r((mbedtls_mpi *)&X.p,count_00); + iVar3 = iVar1; + if (iVar1 == 0) { + uVar12 = iVar4 - 1; + iVar2 = ((uVar10 + 0x3fffffff) - iVar4) * 4; + goto LAB_23092ab2; + } + break; + } + piVar9 = (int *)(Z.n + iVar1 * 4); + *piVar9 = *piVar9 + 1; + iVar3 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&iStack124,(mbedtls_mpi *)&iStack124, + (mbedtls_mpi *)&X.p); + } + } + } + } +cleanup: + mbedtls_mpi_free((mbedtls_mpi *)&iStack124); + mbedtls_mpi_free((mbedtls_mpi *)&X.p); + mbedtls_mpi_free((mbedtls_mpi *)&Y.p); + mbedtls_mpi_free((mbedtls_mpi *)&Z.p); + mbedtls_mpi_free((mbedtls_mpi *)&T1.p); + return iVar3; +LAB_23092ab2: + uVar10 = uVar10 - 1; + if (uVar10 <= uVar12) goto code_r0x23092ab6; + iVar11 = uVar10 * 4; + uVar6 = *(uint *)(X.n + iVar11); + uVar7 = *(uint *)(Y.n + uVar12 * 4); + puVar13 = (undefined4 *)(Z.n + iVar2); + if (uVar6 < uVar7) { + uVar5 = *(undefined4 *)(X.n + iVar11 + -4); + uVar8 = 0xffffffff; + if ((uVar7 != 0) && (__udivdi3(), uVar8 = uVar5, uVar6 != 0)) { + uVar8 = 0xffffffff; + } + *puVar13 = uVar8; + } + else { + *puVar13 = 0xffffffff; + } + *(int *)(Z.n + iVar2) = *(int *)(Z.n + iVar2) + 1; + do { + *(int *)(Z.n + iVar2) = *(int *)(Z.n + iVar2) + -1; + iVar3 = mbedtls_mpi_lset((mbedtls_mpi *)&Z.p,0); + if (iVar3 != 0) goto cleanup; + uVar8 = 0; + if (uVar12 != 0) { + uVar8 = *(undefined4 *)(Y.n + iVar4 * 4 + -8); + } + *(undefined4 *)T1.n = uVar8; + *(undefined4 *)(T1.n + 4) = *(undefined4 *)(Y.n + uVar12 * 4); + iVar3 = mbedtls_mpi_mul_int((mbedtls_mpi *)&Z.p,(mbedtls_mpi *)&Z.p, + *(mbedtls_mpi_uint *)(Z.n + iVar2)); + if ((iVar3 != 0) || (iVar3 = mbedtls_mpi_lset((mbedtls_mpi *)&T1.p,0), iVar3 != 0)) + goto cleanup; + uRam00000000 = 0; + if (uVar10 != 1) { + uRam00000000 = *(undefined4 *)(X.n + iVar11 + -8); + } + _DAT_00000004 = *(undefined4 *)(X.n + iVar11 + -4); + _DAT_00000008 = *(mbedtls_mpi_uint *)(X.n + iVar11); + iVar3 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&Z.p,(mbedtls_mpi *)&T1.p); + } while (0 < iVar3); + iVar3 = mbedtls_mpi_mul_int((mbedtls_mpi *)&Z.p,(mbedtls_mpi *)&X.p, + *(mbedtls_mpi_uint *)(Z.n + iVar2)); + if (iVar3 != 0) goto cleanup; + iVar3 = mbedtls_mpi_shift_l((mbedtls_mpi *)&Z.p,iVar2 << 3); + if ((iVar3 != 0) || + (iVar3 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&iStack124,(mbedtls_mpi *)&iStack124, + (mbedtls_mpi *)&Z.p), iVar3 != 0)) goto cleanup; + iVar3 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&iStack124,0); + if (iVar3 < 0) { + iVar3 = mbedtls_mpi_copy((mbedtls_mpi *)&Z.p,(mbedtls_mpi *)&X.p); + if (((iVar3 != 0) || (iVar3 = mbedtls_mpi_shift_l((mbedtls_mpi *)&Z.p,iVar2 << 3), iVar3 != 0)) + || (iVar3 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&iStack124,(mbedtls_mpi *)&iStack124, + (mbedtls_mpi *)&Z.p), iVar3 != 0)) goto cleanup; + *(int *)(Z.n + iVar2) = *(int *)(Z.n + iVar2) + -1; + } + iVar2 = iVar2 + -4; + goto LAB_23092ab2; +code_r0x23092ab6: + if (Q != (mbedtls_mpi *)0x0) { + iVar3 = mbedtls_mpi_copy(Q,(mbedtls_mpi *)&Y.p); + if (iVar3 != 0) goto cleanup; + Q->s = A->s * B->s; + } + iVar3 = iVar1; + if ((R != (mbedtls_mpi *)0x0) && + (iVar3 = mbedtls_mpi_shift_r((mbedtls_mpi *)&iStack124,count), iVar3 == 0)) { + iStack124 = A->s; + iVar3 = mbedtls_mpi_copy(R,(mbedtls_mpi *)&iStack124); + if ((iVar3 == 0) && (iVar4 = mbedtls_mpi_cmp_int(R,0), iVar3 = iVar1, iVar4 == 0)) { + R->s = 1; + iVar3 = 0; + } + } + goto cleanup; +} + + + +int mbedtls_mpi_mod_mpi(mbedtls_mpi *R,mbedtls_mpi *A,mbedtls_mpi *B) + +{ + int iVar1; + int iVar2; + + iVar1 = mbedtls_mpi_cmp_int(B,0); + if (iVar1 < 0) { + return -10; + } + iVar2 = mbedtls_mpi_div_mpi((mbedtls_mpi *)0x0,R,A,B); + iVar1 = iVar2; + while( true ) { + if (iVar1 != 0) { + return iVar1; + } + iVar1 = mbedtls_mpi_cmp_int(R,0); + if (-1 < iVar1) break; + iVar1 = mbedtls_mpi_add_mpi(R,R,B); + } + do { + iVar1 = mbedtls_mpi_cmp_mpi(R,B); + if (iVar1 < 0) { + return iVar2; + } + iVar1 = mbedtls_mpi_sub_mpi(R,R,B); + } while (iVar1 == 0); + return iVar1; +} + + + +int mbedtls_mpi_exp_mod(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *E,mbedtls_mpi *N,mbedtls_mpi *_RR + ) + +{ + uint uVar1; + mbedtls_mpi_uint mm; + int iVar2; + size_t nblimbs; + mbedtls_mpi *X_00; + mbedtls_mpi *X_01; + uint uVar3; + int iVar4; + int iVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint uVar9; + size_t sVar10; + mbedtls_mpi_uint mStack1652; + mbedtls_mpi_uint z; + mbedtls_mpi RR; + mbedtls_mpi T; + mbedtls_mpi Apos; + mbedtls_mpi U; + mbedtls_mpi W [128]; + + iVar2 = mbedtls_mpi_cmp_int(N,0); + if (iVar2 < 0) { + return -4; + } + uVar6 = *N->p; + uVar9 = uVar6 & 1; + if (uVar9 == 0) { + return -4; + } + iVar2 = mbedtls_mpi_cmp_int(E,0); + if (iVar2 < 0) { + return -4; + } + iVar2 = ((uVar6 + 2) * 2 & 8) + uVar6; + iVar4 = 3; + do { + iVar4 = iVar4 + -1; + iVar2 = iVar2 * (2 - uVar6 * iVar2); + } while (iVar4 != 0); + z = 1; + RR.p = (mbedtls_mpi_uint *)&DAT_00000001; + T.p = (mbedtls_mpi_uint *)&DAT_00000001; + RR.s = 0; + RR.n = 0; + T.s = 0; + T.n = 0; + Apos.s = 0; + Apos.n = 0; + memset(&U.p,0,0x600); + nblimbs = mbedtls_mpi_bitlen(E); + uVar6 = 6; + if ((((nblimbs < 0x2a0) && (uVar6 = 5, nblimbs < 0xf0)) && (uVar6 = 4, nblimbs < 0x50)) && + (uVar6 = 3, nblimbs < 0x18)) { + uVar6 = uVar9; + } + nblimbs = N->n + 1; + iVar4 = mbedtls_mpi_grow(X,nblimbs); + if (((iVar4 != 0) || (iVar4 = mbedtls_mpi_grow((mbedtls_mpi *)&W[0].p,nblimbs), iVar4 != 0)) || + (iVar4 = mbedtls_mpi_grow((mbedtls_mpi *)&RR.p,nblimbs * 2), iVar4 != 0)) goto cleanup; + iVar5 = A->s; + if (iVar5 == -1) { + iVar4 = mbedtls_mpi_copy((mbedtls_mpi *)&T.p,A); + if (iVar4 != 0) goto cleanup; + T.p = (mbedtls_mpi_uint *)&DAT_00000001; + A = (mbedtls_mpi *)&T.p; + } + if ((_RR == (mbedtls_mpi *)0x0) || (_RR->p == (mbedtls_mpi_uint *)0x0)) { + iVar4 = mbedtls_mpi_lset((mbedtls_mpi *)&z,1); + if ((iVar4 != 0) || + ((iVar4 = mbedtls_mpi_shift_l((mbedtls_mpi *)&z,N->n << 6), iVar4 != 0 || + (iVar4 = mbedtls_mpi_mod_mpi((mbedtls_mpi *)&z,(mbedtls_mpi *)&z,N), iVar4 != 0)))) + goto cleanup; + if (_RR != (mbedtls_mpi *)0x0) { + X_00 = _RR; + X_01 = (mbedtls_mpi *)&z; + goto LAB_23092e4a; + } + } + else { + X_00 = (mbedtls_mpi *)&z; + X_01 = _RR; +LAB_23092e4a: + memcpy(X_00,X_01,0xc); + } + iVar4 = mbedtls_mpi_cmp_mpi(A,N); + if (iVar4 < 0) { + iVar4 = mbedtls_mpi_copy((mbedtls_mpi *)&W[0].p,A); + } + else { + iVar4 = mbedtls_mpi_mod_mpi((mbedtls_mpi *)&W[0].p,A,N); + } + if (iVar4 == 0) { + mm = -iVar2; + iVar4 = mpi_montmul((mbedtls_mpi *)&W[0].p,(mbedtls_mpi *)&z,N,mm,(mbedtls_mpi *)&RR.p); + if ((iVar4 == 0) && (iVar4 = mbedtls_mpi_copy(X,(mbedtls_mpi *)&z), iVar4 == 0)) { + U.n = (size_t)&mStack1652; + mStack1652 = 1; + Apos.p = (mbedtls_mpi_uint *)&DAT_00000001; + U.s = 1; + iVar4 = mpi_montmul(X,(mbedtls_mpi *)&Apos.p,N,mm,(mbedtls_mpi *)&RR.p); + if (iVar4 == 0) { + if (uVar6 == 1) { +LAB_23092eb4: + nblimbs = E->n; + uVar7 = 0; + uVar1 = 0; + do { + sVar10 = 0; + uVar8 = 0; +LAB_23092faa: + do { + if (uVar7 == 0) { + if (nblimbs == 0) { + goto LAB_23092fb8; + } + nblimbs = nblimbs - 1; + uVar7 = 0x20; + } + uVar7 = uVar7 - 1; + uVar3 = E->p[nblimbs] >> (uVar7 & 0x1f) & 1; + if (uVar3 == 0) { + if (uVar1 == 0) goto LAB_23092faa; + if (uVar1 == 1) { + iVar4 = mpi_montmul(X,X,N,mm,(mbedtls_mpi *)&RR.p); + if (iVar4 != 0) goto cleanup; + goto LAB_23092faa; + } + } + sVar10 = sVar10 + 1; + uVar8 = uVar8 | uVar3 << (uVar6 - sVar10 & 0x1f); + uVar1 = 2; + } while (uVar6 != sVar10); + uVar1 = 0; + do { + iVar4 = mpi_montmul(X,X,N,mm,(mbedtls_mpi *)&RR.p); + if (iVar4 != 0) goto cleanup; + uVar1 = uVar1 + 1; + } while (uVar1 < sVar10); + iVar4 = mpi_montmul(X,(mbedtls_mpi *)&(&U)[uVar8].p,N,mm,(mbedtls_mpi *)&RR.p); + uVar1 = uVar9; + } while (iVar4 == 0); + } + else { + uVar7 = uVar6 - 1; + X_00 = (mbedtls_mpi *)((int)&U.p + (0xc << (uVar7 & 0x1f))); + iVar4 = mbedtls_mpi_grow(X_00,N->n + 1); + uVar1 = 1 << (uVar7 & 0x1f); + if ((iVar4 == 0) && (iVar4 = mbedtls_mpi_copy(X_00,(mbedtls_mpi *)&W[0].p), iVar4 == 0)) { + uVar8 = 0; + do { + iVar4 = mpi_montmul(X_00,X_00,N,mm,(mbedtls_mpi *)&RR.p); + if (iVar4 != 0) goto cleanup; + uVar8 = uVar8 + 1; + } while (uVar8 < uVar7); + do { + uVar1 = uVar1 + 1; + if ((uint)(1 << uVar6) <= uVar1) goto LAB_23092eb4; + X_01 = X_00 + 1; + iVar4 = mbedtls_mpi_grow(X_01,N->n + 1); + } while (((iVar4 == 0) && (iVar4 = mbedtls_mpi_copy(X_01,X_00), iVar4 == 0)) && + (iVar4 = mpi_montmul(X_01,(mbedtls_mpi *)&W[0].p,N,mm,(mbedtls_mpi *)&RR.p), + X_00 = X_01, iVar4 == 0)); + } + } + } + } + } +cleanup: + uVar9 = 1 << (uVar6 - 1 & 0x1f); + while (uVar9 < (uint)(1 << uVar6)) { + mbedtls_mpi_free((mbedtls_mpi *)&(&U)[uVar9].p); + uVar9 = uVar9 + 1; + } + mbedtls_mpi_free((mbedtls_mpi *)&W[0].p); + mbedtls_mpi_free((mbedtls_mpi *)&RR.p); + mbedtls_mpi_free((mbedtls_mpi *)&T.p); + if ((_RR == (mbedtls_mpi *)0x0) || (_RR->p == (mbedtls_mpi_uint *)0x0)) { + mbedtls_mpi_free((mbedtls_mpi *)&z); + } + return iVar4; +LAB_23092fb8: + if (nblimbs == sVar10) goto code_r0x23092fbc; + iVar4 = mpi_montmul(X,X,N,mm,(mbedtls_mpi *)&RR.p); + if ((iVar4 != 0) || + ((uVar8 = uVar8 << 1, (1 << uVar6 & uVar8) != 0 && + (iVar4 = mpi_montmul(X,(mbedtls_mpi *)&W[0].p,N,mm,(mbedtls_mpi *)&RR.p), iVar4 != 0)))) + goto cleanup; + nblimbs = nblimbs + 1; + goto LAB_23092fb8; +code_r0x23092fbc: + mStack1652 = 1; + Apos.p = (mbedtls_mpi_uint *)&DAT_00000001; + U.s = 1; + U.n = (size_t)&mStack1652; + iVar4 = mpi_montmul(X,(mbedtls_mpi *)&Apos.p,N,mm,(mbedtls_mpi *)&RR.p); + if ((iVar4 == 0) && (iVar5 == -1)) { + X->s = -1; + iVar4 = mbedtls_mpi_add_mpi(X,N,X); + } + goto cleanup; +} + + + +// WARNING: Variable defined which should be unmapped: TB + +int mbedtls_mpi_gcd(mbedtls_mpi *G,mbedtls_mpi *A,mbedtls_mpi *B) + +{ + mbedtls_mpi *pmVar1; + int iVar2; + size_t count; + size_t count_00; + int iStack52; + mbedtls_mpi TG; + mbedtls_mpi TA; + mbedtls_mpi TB; + + iStack52 = 1; + TG.s = 0; + TG.n = 0; + TG.p = (mbedtls_mpi_uint *)&DAT_00000001; + TA.s = 0; + TA.n = 0; + TA.p = (mbedtls_mpi_uint *)&DAT_00000001; + iVar2 = mbedtls_mpi_copy((mbedtls_mpi *)&TG.p,A); + if ((iVar2 == 0) && (iVar2 = mbedtls_mpi_copy((mbedtls_mpi *)&TA.p,B), iVar2 == 0)) { + count = mbedtls_mpi_lsb((mbedtls_mpi *)&TG.p); + count_00 = mbedtls_mpi_lsb((mbedtls_mpi *)&TA.p); + if (count_00 < count) { + count = count_00; + } + iVar2 = mbedtls_mpi_shift_r((mbedtls_mpi *)&TG.p,count); + if ((iVar2 == 0) && (iVar2 = mbedtls_mpi_shift_r((mbedtls_mpi *)&TA.p,count), iVar2 == 0)) { + TA.p = (mbedtls_mpi_uint *)&DAT_00000001; + TG.p = (mbedtls_mpi_uint *)&DAT_00000001; + do { + iVar2 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&TG.p,0); + if (iVar2 == 0) { + iVar2 = mbedtls_mpi_shift_l((mbedtls_mpi *)&TA.p,count); + if (iVar2 == 0) { + iVar2 = mbedtls_mpi_copy(G,(mbedtls_mpi *)&TA.p); + } + break; + } + count_00 = mbedtls_mpi_lsb((mbedtls_mpi *)&TG.p); + iVar2 = mbedtls_mpi_shift_r((mbedtls_mpi *)&TG.p,count_00); + if (iVar2 != 0) break; + count_00 = mbedtls_mpi_lsb((mbedtls_mpi *)&TA.p); + iVar2 = mbedtls_mpi_shift_r((mbedtls_mpi *)&TA.p,count_00); + if (iVar2 != 0) break; + iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&TG.p,(mbedtls_mpi *)&TA.p); + if (iVar2 < 0) { + iVar2 = mbedtls_mpi_sub_abs((mbedtls_mpi *)&TA.p,(mbedtls_mpi *)&TA.p,(mbedtls_mpi *)&TG.p + ); + if (iVar2 != 0) break; + pmVar1 = &TA; + } + else { + iVar2 = mbedtls_mpi_sub_abs((mbedtls_mpi *)&TG.p,(mbedtls_mpi *)&TG.p,(mbedtls_mpi *)&TA.p + ); + if (iVar2 != 0) break; + pmVar1 = &TG; + } + iVar2 = mbedtls_mpi_shift_r((mbedtls_mpi *)&pmVar1->p,1); + } while (iVar2 == 0); + } + } + mbedtls_mpi_free((mbedtls_mpi *)&iStack52); + mbedtls_mpi_free((mbedtls_mpi *)&TG.p); + mbedtls_mpi_free((mbedtls_mpi *)&TA.p); + return iVar2; +} + + + +int mbedtls_mpi_fill_random + (mbedtls_mpi *X,size_t size,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng + ) + +{ + int iVar1; + uchar auStack1040 [4]; + uchar buf [1024]; + + if (size < 0x401) { + iVar1 = (*f_rng)(p_rng,auStack1040,size); + if (iVar1 == 0) { + iVar1 = mbedtls_mpi_read_binary(X,auStack1040,size); + } + return iVar1; + } + return -4; +} + + + +int mbedtls_mpi_inv_mod(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *N) + +{ + mbedtls_mpi *pmVar1; + mbedtls_mpi *pmVar2; + int iVar3; + int iVar4; + int iStack140; + mbedtls_mpi G; + mbedtls_mpi TA; + mbedtls_mpi TU; + mbedtls_mpi U1; + mbedtls_mpi U2; + mbedtls_mpi TB; + mbedtls_mpi TV; + mbedtls_mpi V1; + mbedtls_mpi V2; + + iVar3 = mbedtls_mpi_cmp_int(N,0); + if (iVar3 < 1) { + return -4; + } + G.p = (mbedtls_mpi_uint *)&DAT_00000001; + TA.s = 0; + TA.n = 0; + TA.p = (mbedtls_mpi_uint *)&DAT_00000001; + TU.s = 0; + TU.n = 0; + TU.p = (mbedtls_mpi_uint *)&DAT_00000001; + U1.s = 0; + U1.n = 0; + U1.p = (mbedtls_mpi_uint *)&DAT_00000001; + U2.s = 0; + U2.n = 0; + iStack140 = 1; + G.s = 0; + G.n = 0; + U2.p = (mbedtls_mpi_uint *)&DAT_00000001; + TB.s = 0; + TB.n = 0; + TB.p = (mbedtls_mpi_uint *)&DAT_00000001; + TV.s = 0; + TV.n = 0; + TV.p = (mbedtls_mpi_uint *)&DAT_00000001; + V1.s = 0; + V1.n = 0; + V1.p = (mbedtls_mpi_uint *)&DAT_00000001; + iVar3 = mbedtls_mpi_gcd((mbedtls_mpi *)&iStack140,A,N); + if (iVar3 == 0) { + iVar4 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&iStack140,1); + iVar3 = -0xe; + if (((((iVar4 == 0) && (iVar3 = mbedtls_mpi_mod_mpi((mbedtls_mpi *)&G.p,A,N), iVar3 == 0)) && + (iVar3 = mbedtls_mpi_copy((mbedtls_mpi *)&TA.p,(mbedtls_mpi *)&G.p), iVar3 == 0)) && + ((iVar3 = mbedtls_mpi_copy((mbedtls_mpi *)&U2.p,N), iVar3 == 0 && + (iVar3 = mbedtls_mpi_copy((mbedtls_mpi *)&TB.p,N), iVar3 == 0)))) && + ((iVar3 = mbedtls_mpi_lset((mbedtls_mpi *)&TU.p,1), iVar3 == 0 && + ((iVar3 = mbedtls_mpi_lset((mbedtls_mpi *)&U1.p,0), iVar3 == 0 && + (iVar3 = mbedtls_mpi_lset((mbedtls_mpi *)&TV.p,0), iVar3 == 0)))))) { + iVar3 = mbedtls_mpi_lset((mbedtls_mpi *)&V1.p,1); + while (iVar3 == 0) { + while ((*(uint *)TU.n & 1) != 0) { + while ((*(uint *)TV.n & 1) == 0) { + iVar3 = mbedtls_mpi_shift_r((mbedtls_mpi *)&TB.p,1); + if ((iVar3 != 0) || + (((((*(uint *)V1.n & 1) != 0 || ((uRam00000000 & 1) != 0)) && + ((iVar3 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&TV.p,(mbedtls_mpi *)&TV.p, + (mbedtls_mpi *)&U2.p), iVar3 != 0 || + (iVar3 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&V1.p,(mbedtls_mpi *)&V1.p, + (mbedtls_mpi *)&G.p), iVar3 != 0)))) || + ((iVar3 = mbedtls_mpi_shift_r((mbedtls_mpi *)&TV.p,1), iVar3 != 0 || + (iVar3 = mbedtls_mpi_shift_r((mbedtls_mpi *)&V1.p,1), iVar3 != 0)))))) + goto cleanup; + } + iVar3 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&TA.p,(mbedtls_mpi *)&TB.p); + if (iVar3 < 0) { + iVar3 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&TB.p,(mbedtls_mpi *)&TB.p, + (mbedtls_mpi *)&TA.p); + if ((iVar3 != 0) || + (iVar3 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&TV.p,(mbedtls_mpi *)&TV.p, + (mbedtls_mpi *)&TU.p), iVar3 != 0)) goto cleanup; + pmVar1 = &U1; + pmVar2 = &V1; + } + else { + iVar3 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&TA.p,(mbedtls_mpi *)&TA.p, + (mbedtls_mpi *)&TB.p); + if ((iVar3 != 0) || + (iVar3 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&TU.p,(mbedtls_mpi *)&TU.p, + (mbedtls_mpi *)&TV.p), iVar3 != 0)) goto cleanup; + pmVar1 = &V1; + pmVar2 = &U1; + } + iVar3 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&pmVar2->p,(mbedtls_mpi *)&pmVar2->p, + (mbedtls_mpi *)&pmVar1->p); + if (iVar3 != 0) goto cleanup; + iVar3 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&TA.p,0); + if (iVar3 == 0) goto LAB_2309337e; + } + iVar3 = mbedtls_mpi_shift_r((mbedtls_mpi *)&TA.p,1); + if (((iVar3 != 0) || + ((((*(uint *)U1.n & 1) != 0 || ((*(uint *)U2.n & 1) != 0)) && + ((iVar3 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&TU.p,(mbedtls_mpi *)&TU.p, + (mbedtls_mpi *)&U2.p), iVar3 != 0 || + (iVar3 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&U1.p,(mbedtls_mpi *)&U1.p, + (mbedtls_mpi *)&G.p), iVar3 != 0)))))) || + (iVar3 = mbedtls_mpi_shift_r((mbedtls_mpi *)&TU.p,1), iVar3 != 0)) break; + iVar3 = mbedtls_mpi_shift_r((mbedtls_mpi *)&U1.p,1); + } + } + } + goto cleanup; + while (iVar3 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&TV.p,(mbedtls_mpi *)&TV.p,N), iVar3 == 0) { +LAB_2309337e: + iVar3 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&TV.p,0); + if (-1 < iVar3) goto LAB_2309338a; + } + goto cleanup; + while (iVar3 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&TV.p,(mbedtls_mpi *)&TV.p,N), iVar3 == 0) { +LAB_2309338a: + iVar3 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&TV.p,N); + if (iVar3 < 0) { + iVar3 = mbedtls_mpi_copy(X,(mbedtls_mpi *)&TV.p); + break; + } + } +cleanup: + mbedtls_mpi_free((mbedtls_mpi *)&G.p); + mbedtls_mpi_free((mbedtls_mpi *)&TA.p); + mbedtls_mpi_free((mbedtls_mpi *)&TU.p); + mbedtls_mpi_free((mbedtls_mpi *)&U1.p); + mbedtls_mpi_free((mbedtls_mpi *)&iStack140); + mbedtls_mpi_free((mbedtls_mpi *)&U2.p); + mbedtls_mpi_free((mbedtls_mpi *)&TB.p); + mbedtls_mpi_free((mbedtls_mpi *)&TV.p); + mbedtls_mpi_free((mbedtls_mpi *)&V1.p); + return iVar3; +} + + + +uint mbedtls_cipher_get_block_size(mbedtls_cipher_context_t *ctx) + +{ + if ((ctx != (mbedtls_cipher_context_t *)0x0) && (ctx->cipher_info != (mbedtls_cipher_info_t *)0x0) + ) { + return ctx->cipher_info->block_size; + } + return 0; +} + + + +void add_pkcs_padding(uchar *output,size_t output_len,size_t data_len) + +{ + uint uVar1; + + uVar1 = 0; + while (uVar1 < output_len - data_len) { + output[data_len + uVar1] = (uchar)(output_len - data_len); + uVar1 = uVar1 + 1 & 0xff; + } + return; +} + + + +int get_pkcs_padding(uchar *input,size_t input_len,size_t *data_len) + +{ + byte bVar1; + bool bVar2; + byte *pbVar3; + uint uVar4; + bool bVar5; + uint uVar6; + + if ((input == (uchar *)0x0) || (data_len == (size_t *)0x0)) { + return -0x6100; + } + bVar1 = input[input_len - 1]; + uVar6 = input_len - bVar1; + bVar5 = input_len < bVar1 || bVar1 == 0; + *data_len = uVar6; + uVar4 = 0; + while (uVar4 != input_len) { + pbVar3 = input + uVar4; + bVar2 = uVar6 <= uVar4; + uVar4 = uVar4 + 1; + bVar5 = (bool)(bVar5 | bVar2 * (bVar1 ^ *pbVar3)); + } + if (bVar5 == false) { + return 0; + } + return -0x6200; +} + + + +void add_zeros_padding(uchar *output,size_t output_len,size_t data_len) + +{ + if (output_len <= data_len) { + return; + } + output[data_len] = '\0'; + add_zeros_padding(output,output_len,data_len + 1); + return; +} + + + +int get_no_padding(uchar *input,size_t input_len,size_t *data_len) + +{ + if ((input != (uchar *)0x0) && (data_len != (size_t *)0x0)) { + *data_len = input_len; + return 0; + } + return -0x6100; +} + + + +int get_zeros_padding(uchar *input,size_t input_len,size_t *data_len) + +{ + uint uVar1; + uint uVar2; + + if ((input != (uchar *)0x0) && (data_len != (size_t *)0x0)) { + *data_len = 0; + uVar2 = 0; + while (input_len != 0) { + uVar1 = input[input_len - 1] != '\0' | uVar2; + *data_len = (uVar2 ^ uVar1) * input_len | *data_len; + input_len = input_len - 1; + uVar2 = uVar1; + } + return 0; + } + return -0x6100; +} + + + +mbedtls_cipher_info_t * mbedtls_cipher_info_from_type(mbedtls_cipher_type_t cipher_type) + +{ + undefined3 in_register_00002029; + mbedtls_cipher_definition_t *pmVar1; + + pmVar1 = mbedtls_cipher_definitions; + while ((pmVar1->info != (mbedtls_cipher_info_t *)0x0 && + ((uint)pmVar1->type != CONCAT31(in_register_00002029,cipher_type)))) { + pmVar1 = pmVar1 + 1; + } + return pmVar1->info; +} + + + +mbedtls_cipher_info_t * +mbedtls_cipher_info_from_values + (mbedtls_cipher_id_t cipher_id,int key_bitlen,mbedtls_cipher_mode_t mode) + +{ + undefined3 in_register_00002029; + undefined3 in_register_00002031; + mbedtls_cipher_definition_t *pmVar1; + mbedtls_cipher_info_t *pmVar2; + + pmVar1 = mbedtls_cipher_definitions; + while ((pmVar2 = pmVar1->info, pmVar2 != (mbedtls_cipher_info_t *)0x0 && + ((((uint)pmVar2->base->cipher != CONCAT31(in_register_00002029,cipher_id) || + (pmVar2->key_bitlen != key_bitlen)) || + ((uint)pmVar2->mode != CONCAT31(in_register_00002031,mode)))))) { + pmVar1 = pmVar1 + 1; + } + return pmVar2; +} + + + +void mbedtls_cipher_init(mbedtls_cipher_context_t *ctx) + +{ + memset(ctx,0,0x40); + return; +} + + + +void mbedtls_cipher_free(mbedtls_cipher_context_t *ctx) + +{ + mbedtls_cipher_context_t *pmVar1; + + if (ctx != (mbedtls_cipher_context_t *)0x0) { + if (ctx->cipher_ctx != (void *)0x0) { + (*ctx->cipher_info->base->ctx_free_func)(ctx->cipher_ctx); + } + pmVar1 = ctx + 1; + while (ctx != pmVar1) { + *(undefined *)&ctx->cipher_info = 0; + ctx = (mbedtls_cipher_context_t *)((int)&ctx->cipher_info + 1); + } + return; + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +int mbedtls_cipher_setkey + (mbedtls_cipher_context_t *ctx,uchar *key,int key_bitlen,mbedtls_operation_t operation + ) + +{ + anon_subr_int_void_ptr_uchar_ptr_uint_for_setkey_enc_func *UNRECOVERED_JUMPTABLE; + int iVar1; + undefined3 in_register_00002035; + mbedtls_cipher_info_t *pmVar2; + + if (((ctx != (mbedtls_cipher_context_t *)0x0) && + (pmVar2 = ctx->cipher_info, pmVar2 != (mbedtls_cipher_info_t *)0x0)) && + (((pmVar2->flags & 2U) != 0 || (pmVar2->key_bitlen == key_bitlen)))) { + ctx->key_bitlen = key_bitlen; + ctx->operation = operation; + if ((CONCAT31(in_register_00002035,operation) == 1) || + ((pmVar2->mode + ~MBEDTLS_MODE_CBC & 0xfd) == 0)) { + UNRECOVERED_JUMPTABLE = pmVar2->base->setkey_enc_func; + } + else { + if (CONCAT31(in_register_00002035,operation) != 0) { + return -0x6100; + } + UNRECOVERED_JUMPTABLE = + (anon_subr_int_void_ptr_uchar_ptr_uint_for_setkey_enc_func *) + pmVar2->base->setkey_dec_func; + } + // WARNING: Could not recover jumptable at 0x23093674. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*UNRECOVERED_JUMPTABLE)(ctx->cipher_ctx); + return iVar1; + } + return -0x6100; +} + + + +int mbedtls_cipher_set_iv(mbedtls_cipher_context_t *ctx,uchar *iv,size_t iv_len) + +{ + mbedtls_cipher_info_t *pmVar1; + size_t __n; + + if (ctx == (mbedtls_cipher_context_t *)0x0) { + return -0x6100; + } + pmVar1 = ctx->cipher_info; + if ((pmVar1 != (mbedtls_cipher_info_t *)0x0) && (iv != (uchar *)0x0)) { + if (0x10 < iv_len) { + return -0x6080; + } + __n = iv_len; + if (((pmVar1->flags & 1U) != 0) || (__n = pmVar1->iv_size, __n <= iv_len)) { + memcpy(ctx->iv,iv,__n); + ctx->iv_size = __n; + return 0; + } + } + return -0x6100; +} + + + +int mbedtls_cipher_reset(mbedtls_cipher_context_t *ctx) + +{ + if ((ctx != (mbedtls_cipher_context_t *)0x0) && (ctx->cipher_info != (mbedtls_cipher_info_t *)0x0) + ) { + ctx->unprocessed_len = 0; + return 0; + } + return -0x6100; +} + + + +int mbedtls_cipher_update + (mbedtls_cipher_context_t *ctx,uchar *input,size_t ilen,uchar *output,size_t *olen) + +{ + mbedtls_cipher_mode_t mVar1; + uint uVar2; + int iVar3; + mbedtls_cipher_info_t *pmVar4; + size_t sVar5; + uint __n; + + if (ctx == (mbedtls_cipher_context_t *)0x0) { + return -0x6100; + } + if ((ctx->cipher_info == (mbedtls_cipher_info_t *)0x0) || (olen == (size_t *)0x0)) { + return -0x6100; + } + *olen = 0; + uVar2 = mbedtls_cipher_get_block_size(ctx); + pmVar4 = ctx->cipher_info; + mVar1 = pmVar4->mode; + if (mVar1 == MBEDTLS_MODE_ECB) { + if (uVar2 != ilen) { + return -0x6280; + } + *olen = uVar2; + // WARNING: Could not recover jumptable at 0x23093784. Too many branches + // WARNING: Treating indirect jump as call + iVar3 = (*ctx->cipher_info->base->ecb_func)(ctx->cipher_ctx,ctx->operation,input,output); + return iVar3; + } + if (mVar1 == MBEDTLS_MODE_GCM) { + *olen = ilen; + iVar3 = mbedtls_gcm_update((mbedtls_gcm_context *)ctx->cipher_ctx,ilen,input,output); + return iVar3; + } + if (uVar2 == 0) { + return -0x6380; + } + if (input == output) { + if (ctx->unprocessed_len != 0) { + return -0x6100; + } + if (ilen % uVar2 != 0) { + return -0x6100; + } + } + if (mVar1 == MBEDTLS_MODE_CBC) { + sVar5 = ctx->unprocessed_len; + if (ctx->operation == MBEDTLS_DECRYPT) { + if (ilen <= uVar2 - sVar5) { +LAB_230937da: + memcpy(ctx->unprocessed_data + sVar5,input,ilen); + ctx->unprocessed_len = ilen + ctx->unprocessed_len; + return 0; + } + } + else { + if ((ctx->operation == MBEDTLS_ENCRYPT) && (ilen < uVar2 - sVar5)) goto LAB_230937da; + } + if (sVar5 != 0) { + memcpy(ctx->unprocessed_data + sVar5,input,uVar2 - sVar5); + iVar3 = (*ctx->cipher_info->base->cbc_func) + (ctx->cipher_ctx,ctx->operation,uVar2,ctx->iv,ctx->unprocessed_data,output); + if (iVar3 != 0) { + return iVar3; + } + output = output + uVar2; + *olen = *olen + uVar2; + ctx->unprocessed_len = 0; + input = input + (uVar2 - sVar5); + ilen = (ilen + sVar5) - uVar2; + } + if (ilen != 0) { + __n = ilen % uVar2; + if ((__n == 0) && (ctx->operation == MBEDTLS_DECRYPT)) { + __n = uVar2; + } + ilen = ilen - __n; + memcpy(ctx->unprocessed_data,input + ilen,__n); + ctx->unprocessed_len = __n + ctx->unprocessed_len; + if (ilen != 0) { + iVar3 = (*ctx->cipher_info->base->cbc_func) + (ctx->cipher_ctx,ctx->operation,ilen,ctx->iv,input,output); + if (iVar3 != 0) { + return iVar3; + } + ilen = ilen + *olen; + goto LAB_230938a0; + } + } + return 0; + } + if (mVar1 == MBEDTLS_MODE_CFB) { + iVar3 = (*pmVar4->base->cfb_func) + (ctx->cipher_ctx,ctx->operation,ilen,&ctx->unprocessed_len,ctx->iv,input, + output); + } + else { + if (mVar1 != MBEDTLS_MODE_CTR) { + return -0x6080; + } + iVar3 = (*pmVar4->base->ctr_func) + (ctx->cipher_ctx,ilen,&ctx->unprocessed_len,ctx->iv,ctx->unprocessed_data, + input,output); + } + if (iVar3 != 0) { + return iVar3; + } +LAB_230938a0: + *olen = ilen; + return iVar3; +} + + + +int mbedtls_cipher_finish(mbedtls_cipher_context_t *ctx,uchar *output,size_t *olen) + +{ + mbedtls_cipher_mode_t mVar1; + int iVar2; + uint uVar3; + size_t sVar4; + size_t sVar5; + + if (((ctx == (mbedtls_cipher_context_t *)0x0) || + (ctx->cipher_info == (mbedtls_cipher_info_t *)0x0)) || (olen == (size_t *)0x0)) { + return -0x6100; + } + *olen = 0; + mVar1 = ctx->cipher_info->mode; + if ((mVar1 == MBEDTLS_MODE_CFB) || ((byte)(mVar1 + ~MBEDTLS_MODE_OFB) < 3)) { + return 0; + } + if (mVar1 == MBEDTLS_MODE_ECB) { + sVar5 = ctx->unprocessed_len; +joined_r0x2309396e: + if (sVar5 == 0) { + return 0; + } +LAB_2309394c: + iVar2 = -0x6280; + } + else { + if (mVar1 != MBEDTLS_MODE_CBC) { + return -0x6080; + } + sVar5 = ctx->unprocessed_len; + if (ctx->operation == MBEDTLS_ENCRYPT) { + if (ctx->add_padding == (anon_subr_void_uchar_ptr_size_t_size_t_for_add_padding *)0x0) + goto joined_r0x2309396e; + sVar4 = ctx->iv_size; + if (sVar4 == 0) { + sVar4 = ctx->cipher_info->iv_size; + } + (*ctx->add_padding)(ctx->unprocessed_data,sVar4,sVar5); + } + else { + uVar3 = mbedtls_cipher_get_block_size(ctx); + if (uVar3 != sVar5) { + if ((ctx->add_padding == (anon_subr_void_uchar_ptr_size_t_size_t_for_add_padding *)0x0) && + (sVar5 == 0)) { + return 0; + } + goto LAB_2309394c; + } + } + uVar3 = mbedtls_cipher_get_block_size(ctx); + iVar2 = (*ctx->cipher_info->base->cbc_func) + (ctx->cipher_ctx,ctx->operation,uVar3,ctx->iv,ctx->unprocessed_data,output); + if (iVar2 == 0) { + uVar3 = mbedtls_cipher_get_block_size(ctx); + if (ctx->operation == MBEDTLS_DECRYPT) { + // WARNING: Could not recover jumptable at 0x230939da. Too many branches + // WARNING: Treating indirect jump as call + iVar2 = (*ctx->get_padding)(output,uVar3,olen); + return iVar2; + } + *olen = uVar3; + } + } + return iVar2; +} + + + +int mbedtls_cipher_set_padding_mode(mbedtls_cipher_context_t *ctx,mbedtls_cipher_padding_t mode) + +{ + undefined3 in_register_0000202d; + int iVar1; + code *pcVar2; + + iVar1 = CONCAT31(in_register_0000202d,mode); + if ((ctx != (mbedtls_cipher_context_t *)0x0) && (ctx->cipher_info->mode == MBEDTLS_MODE_CBC)) { + if (iVar1 == 3) { + ctx->add_padding = add_zeros_padding; + pcVar2 = get_zeros_padding; + } + else { + if (iVar1 == 4) { + ctx->add_padding = (anon_subr_void_uchar_ptr_size_t_size_t_for_add_padding *)0x0; + pcVar2 = get_no_padding; + } + else { + if (iVar1 != 0) { + return -0x6080; + } + ctx->add_padding = add_pkcs_padding; + pcVar2 = get_pkcs_padding; + } + } + ctx->get_padding = pcVar2; + return 0; + } + return -0x6100; +} + + + +int mbedtls_cipher_setup(mbedtls_cipher_context_t *ctx,mbedtls_cipher_info_t *cipher_info) + +{ + void *pvVar1; + int iVar2; + anon_subr_void_ptr_for_ctx_alloc_func *paVar3; + + if (cipher_info != (mbedtls_cipher_info_t *)0x0) { + if (ctx == (mbedtls_cipher_context_t *)0x0) { + iVar2 = -0x6100; + } + else { + memset(ctx,0,0x40); + paVar3 = cipher_info->base->ctx_alloc_func; + pvVar1 = (*paVar3)(paVar3); + ctx->cipher_ctx = pvVar1; + if (pvVar1 == (void *)0x0) { + iVar2 = -0x6180; + } + else { + ctx->cipher_info = cipher_info; + mbedtls_cipher_set_padding_mode(ctx,MBEDTLS_PADDING_PKCS7); + iVar2 = 0; + } + } + return iVar2; + } + return -0x6100; +} + + + +int mbedtls_cipher_crypt + (mbedtls_cipher_context_t *ctx,uchar *iv,size_t iv_len,uchar *input,size_t ilen, + uchar *output,size_t *olen) + +{ + int iVar1; + size_t sStack36; + size_t finish_olen; + + iVar1 = mbedtls_cipher_set_iv(ctx,iv,iv_len); + if ((((iVar1 == 0) && (iVar1 = mbedtls_cipher_reset(ctx), iVar1 == 0)) && + (iVar1 = mbedtls_cipher_update(ctx,input,ilen,output,olen), iVar1 == 0)) && + (iVar1 = mbedtls_cipher_finish(ctx,output + *olen,&sStack36), iVar1 == 0)) { + *olen = *olen + sStack36; + } + return iVar1; +} + + + +int mbedtls_cipher_auth_encrypt + (mbedtls_cipher_context_t *ctx,uchar *iv,size_t iv_len,uchar *ad,size_t ad_len, + uchar *input,size_t ilen,uchar *output,size_t *olen,uchar *tag,size_t tag_len) + +{ + int iVar1; + size_t *in_stack_00000000; + + if (ctx->cipher_info->mode == MBEDTLS_MODE_GCM) { + *in_stack_00000000 = ilen; + iVar1 = mbedtls_gcm_crypt_and_tag + ((mbedtls_gcm_context *)ctx->cipher_ctx,1,ilen,iv,iv_len,ad,ad_len,input, + (uchar *)olen,(size_t)tag,(uchar *)tag_len); + return iVar1; + } + return -0x6080; +} + + + +int mbedtls_cipher_auth_decrypt + (mbedtls_cipher_context_t *ctx,uchar *iv,size_t iv_len,uchar *ad,size_t ad_len, + uchar *input,size_t ilen,uchar *output,size_t *olen,uchar *tag,size_t tag_len) + +{ + int iVar1; + size_t *in_stack_00000000; + uchar *in_stack_00000004; + size_t in_stack_00000008; + + if (ctx->cipher_info->mode == MBEDTLS_MODE_GCM) { + *in_stack_00000000 = ilen; + iVar1 = mbedtls_gcm_auth_decrypt + ((mbedtls_gcm_context *)ctx->cipher_ctx,ilen,iv,iv_len,ad,ad_len, + in_stack_00000004,in_stack_00000008,(uchar *)olen,tag); + if (iVar1 == -0x12) { + iVar1 = -0x6300; + } + return iVar1; + } + return -0x6080; +} + + + +void gcm_ctx_free(void *ctx) + +{ + mbedtls_gcm_free((mbedtls_gcm_context *)ctx); + vPortFree(ctx); + return; +} + + + +void * gcm_ctx_alloc(void) + +{ + mbedtls_gcm_context *ctx; + + ctx = (mbedtls_gcm_context *)mycalloc(1,0x188); + if (ctx != (mbedtls_gcm_context *)0x0) { + mbedtls_gcm_init(ctx); + } + return ctx; +} + + + +int gcm_aes_setkey_wrap(void *ctx,uchar *key,uint key_bitlen) + +{ + int iVar1; + + iVar1 = mbedtls_gcm_setkey((mbedtls_gcm_context *)ctx,MBEDTLS_CIPHER_ID_AES,key,key_bitlen); + return iVar1; +} + + + +void aes_ctx_free(void *ctx) + +{ + mbedtls_aes_free((mbedtls_aes_context *)ctx); + vPortFree(ctx); + return; +} + + + +void * aes_ctx_alloc(void) + +{ + mbedtls_aes_context *ctx; + + ctx = (mbedtls_aes_context *)mycalloc(1,0x118); + if (ctx != (mbedtls_aes_context *)0x0) { + mbedtls_aes_init(ctx); + } + return ctx; +} + + + +int aes_setkey_dec_wrap(mbedtls_aes_context *ctx,uchar *key,uint keybits) + +{ + uint *puVar1; + int iVar2; + uint32_t *puVar3; + uint uVar4; + uint32_t *puVar5; + int iVar6; + mbedtls_aes_context mStack296; + + mbedtls_aes_init(&mStack296); + ctx->rk = ctx->buf; + iVar2 = mbedtls_aes_setkey_enc(&mStack296,key,keybits); + if (iVar2 == 0) { + ctx->nr = mStack296.nr; + mStack296.rk = mStack296.rk + mStack296.nr * 4; + ctx->buf[0] = *mStack296.rk; + ctx->buf[1] = mStack296.rk[1]; + puVar3 = ctx->buf; + ctx->buf[2] = mStack296.rk[2]; + ctx->buf[3] = mStack296.rk[3]; + while( true ) { + puVar3 = puVar3 + 4; + puVar5 = mStack296.rk + -4; + mStack296.nr = mStack296.nr + -1; + if (mStack296.nr < 1) break; + iVar6 = 0; + do { + uVar4 = *(uint *)((int)puVar5 + iVar6); + puVar1 = (uint *)((int)puVar3 + iVar6); + iVar6 = iVar6 + 4; + *puVar1 = RT2[FSb[uVar4 >> 0x10 & 0xff]] ^ + RT0[FSb[uVar4 & 0xff]] ^ RT3[FSb[uVar4 >> 0x18]] ^ RT1[FSb[uVar4 >> 8 & 0xff]]; + mStack296.rk = puVar5; + } while (iVar6 != 0x10); + } + *puVar3 = *puVar5; + puVar3[1] = mStack296.rk[-3]; + puVar3[2] = mStack296.rk[-2]; + puVar3[3] = mStack296.rk[-1]; + } + mbedtls_aes_free(&mStack296); + return iVar2; +} + + + +int aes_setkey_enc_wrap(mbedtls_aes_context *ctx,uchar *key,uint keybits) + +{ + byte *pbVar1; + uint32_t *puVar2; + uint uVar3; + int iVar4; + uint32_t *puVar5; + uint32_t *puVar6; + uint uVar7; + + if (aes_init_done == 0) { + aes_gen_tables(); + aes_init_done = 1; + } + if (keybits == 0xc0) { + iVar4 = 0xc; + } + else { + if (keybits == 0x100) { + iVar4 = 0xe; + } + else { + if (keybits != 0x80) { + return -0x20; + } + iVar4 = 10; + } + } + ctx->nr = iVar4; + puVar5 = ctx->buf; + ctx->rk = puVar5; + pbVar1 = key; + puVar2 = puVar5; + while (key + (keybits >> 5) * 4 != pbVar1) { + *puVar2 = (uint)pbVar1[1] << 8 | (uint)pbVar1[2] << 0x10 | (uint)*pbVar1 | + (uint)pbVar1[3] << 0x18; + pbVar1 = pbVar1 + 4; + puVar2 = puVar2 + 1; + } + iVar4 = ctx->nr; + if (iVar4 == 0xc) { + puVar2 = RCON; + do { + uVar3 = puVar5[5]; + uVar7 = *puVar2; + puVar6 = puVar5 + 6; + puVar2 = puVar2 + 1; + uVar7 = (uint)FSb[uVar3 >> 8 & 0xff] ^ *puVar5 ^ uVar7 ^ (uint)FSb[uVar3 >> 0x18] << 0x10 ^ + (uint)FSb[uVar3 & 0xff] << 0x18 ^ (uint)FSb[uVar3 >> 0x10 & 0xff] << 8; + *puVar6 = uVar7; + uVar7 = uVar7 ^ puVar5[1]; + puVar5[7] = uVar7; + uVar7 = uVar7 ^ puVar5[2]; + puVar5[8] = uVar7; + uVar7 = uVar7 ^ puVar5[3]; + puVar5[9] = uVar7; + uVar7 = uVar7 ^ puVar5[4]; + puVar5[10] = uVar7; + puVar5[0xb] = uVar7 ^ uVar3; + puVar5 = puVar6; + } while (puVar6 != ctx->buf + 0x30); + } + else { + if (iVar4 == 0xe) { + puVar2 = RCON; + do { + uVar3 = puVar5[7]; + uVar7 = *puVar2; + puVar6 = puVar5 + 8; + puVar2 = puVar2 + 1; + uVar7 = (uint)FSb[uVar3 >> 8 & 0xff] ^ *puVar5 ^ uVar7 ^ (uint)FSb[uVar3 >> 0x18] << 0x10 ^ + (uint)FSb[uVar3 & 0xff] << 0x18 ^ (uint)FSb[uVar3 >> 0x10 & 0xff] << 8; + *puVar6 = uVar7; + uVar7 = uVar7 ^ puVar5[1]; + puVar5[9] = uVar7; + uVar7 = uVar7 ^ puVar5[2]; + puVar5[10] = uVar7; + uVar7 = uVar7 ^ puVar5[3]; + puVar5[0xb] = uVar7; + uVar7 = (uint)FSb[uVar7 >> 0x10 & 0xff] << 0x10 ^ + (uint)FSb[uVar7 & 0xff] ^ puVar5[4] ^ (uint)FSb[uVar7 >> 0x18] << 0x18 ^ + (uint)FSb[uVar7 >> 8 & 0xff] << 8; + puVar5[0xc] = uVar7; + uVar7 = uVar7 ^ puVar5[5]; + puVar5[0xd] = uVar7; + uVar7 = uVar7 ^ puVar5[6]; + puVar5[0xe] = uVar7; + puVar5[0xf] = uVar7 ^ uVar3; + puVar5 = puVar6; + } while (puVar6 != ctx->buf + 0x38); + } + else { + if (iVar4 != 10) { + return 0; + } + puVar2 = RCON; + do { + uVar3 = puVar5[3]; + uVar7 = *puVar2; + puVar6 = puVar5 + 4; + puVar2 = puVar2 + 1; + uVar7 = (uint)FSb[uVar3 >> 8 & 0xff] ^ *puVar5 ^ uVar7 ^ (uint)FSb[uVar3 >> 0x18] << 0x10 ^ + (uint)FSb[uVar3 & 0xff] << 0x18 ^ (uint)FSb[uVar3 >> 0x10 & 0xff] << 8; + *puVar6 = uVar7; + uVar7 = uVar7 ^ puVar5[1]; + puVar5[5] = uVar7; + uVar7 = uVar7 ^ puVar5[2]; + puVar5[6] = uVar7; + puVar5[7] = uVar7 ^ uVar3; + puVar5 = puVar6; + } while (puVar6 != ctx->buf + 0x28); + } + } + return 0; +} + + + +int aes_crypt_ctr_wrap(mbedtls_aes_context *ctx,size_t length,size_t *nc_off,uchar *nonce_counter, + uchar *stream_block,uchar *input,uchar *output) + +{ + bool bVar1; + uchar uVar2; + uint uVar3; + uchar *puVar4; + byte *pbVar5; + + uVar3 = *nc_off; + pbVar5 = output; + do { + if (pbVar5 == output + length) { + *nc_off = uVar3; + return 0; + } + if (uVar3 == 0) { + mbedtls_aes_encrypt(ctx,nonce_counter,stream_block); + puVar4 = nonce_counter + 0xf; + do { + uVar2 = *puVar4; + *puVar4 = uVar2 + '\x01'; + if ((uchar)(uVar2 + '\x01') != '\0') break; + bVar1 = nonce_counter != puVar4; + puVar4 = puVar4 + -1; + } while (bVar1); + } + *pbVar5 = stream_block[uVar3] ^ *input; + uVar3 = uVar3 + 1 & 0xf; + input = input + 1; + pbVar5 = pbVar5 + 1; + } while( true ); +} + + + +int aes_crypt_cfb128_wrap + (mbedtls_aes_context *ctx,int mode,size_t length,size_t *iv_off,uchar *iv,uchar *input + ,uchar *output) + +{ + uint uVar1; + byte *pbVar2; + byte bVar3; + + uVar1 = *iv_off; + pbVar2 = output; + if (mode == 0) { + while (pbVar2 != output + length) { + if (uVar1 == 0) { + mbedtls_aes_encrypt(ctx,iv,iv); + } + bVar3 = *input; + *pbVar2 = iv[uVar1] ^ bVar3; + iv[uVar1] = bVar3; + uVar1 = uVar1 + 1 & 0xf; + pbVar2 = pbVar2 + 1; + input = input + 1; + } + } + else { + while (pbVar2 != output + length) { + if (uVar1 == 0) { + mbedtls_aes_encrypt(ctx,iv,iv); + } + bVar3 = iv[uVar1] ^ *input; + *pbVar2 = bVar3; + iv[uVar1] = bVar3; + uVar1 = uVar1 + 1 & 0xf; + pbVar2 = pbVar2 + 1; + input = input + 1; + } + } + *iv_off = uVar1; + return 0; +} + + + +int aes_crypt_cbc_wrap(mbedtls_aes_context *ctx,int mode,size_t length,uchar *iv,uchar *input, + uchar *output) + +{ + uint uVar1; + int iVar2; + byte *pbVar3; + byte *pbVar4; + byte *pbVar5; + uchar *input_00; + undefined auStack64 [24]; + + uVar1 = length & 0xf; + if (uVar1 == 0) { + if (mode == 0) { + while( true ) { + input_00 = output + -uVar1; + if (uVar1 + length == 0) break; + memcpy(auStack64,input + -uVar1,0x10); + mbedtls_aes_decrypt(ctx,input + -uVar1,input_00); + iVar2 = 0; + do { + pbVar3 = input_00 + iVar2; + pbVar4 = iv + iVar2; + iVar2 = iVar2 + 1; + *pbVar3 = *pbVar4 ^ *pbVar3; + } while (iVar2 != 0x10); + memcpy(iv,auStack64,0x10); + uVar1 = uVar1 - 0x10; + } + } + else { + while( true ) { + input_00 = output + -uVar1; + if (length + uVar1 == 0) break; + iVar2 = 0; + do { + pbVar5 = input + -uVar1 + iVar2; + pbVar3 = iv + iVar2; + pbVar4 = input_00 + iVar2; + iVar2 = iVar2 + 1; + *pbVar4 = *pbVar5 ^ *pbVar3; + } while (iVar2 != 0x10); + mbedtls_aes_crypt_ecb(ctx,mode,input_00,input_00); + memcpy(iv,input_00,0x10); + uVar1 = uVar1 - 0x10; + } + } + iVar2 = 0; + } + else { + iVar2 = -0x22; + } + return iVar2; +} + + + +int aes_crypt_ecb_wrap(mbedtls_aes_context *ctx,int mode,uchar *input,uchar *output) + +{ + if (mode == 1) { + mbedtls_aes_encrypt(ctx,input,output); + } + else { + mbedtls_aes_decrypt(ctx,input,output); + } + return 0; +} + + + +void debug_send_line(int level,char *file,int line,char *str) + +{ + // WARNING: Could not recover jumptable at 0x23093c40. Too many branches + // WARNING: Treating indirect jump as call + (**(code **)(level + 0x10))(*(undefined4 *)(level + 0x14)); + return; +} + + + +void mbedtls_debug_print_mpi + (mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,mbedtls_mpi *X) + +{ + int iVar1; + size_t sVar2; + int iVar3; + bool bVar4; + uint uVar5; + uint uVar6; + char acStack576 [4]; + char str [512]; + + sVar2 = X->n; + do { + sVar2 = sVar2 - 1; + if (sVar2 == 0) break; + } while (X->p[sVar2] == 0); + uVar5 = 0x1f; + do { + if ((X->p[sVar2] >> (uVar5 & 0x1f) & 1) != 0) break; + uVar5 = uVar5 - 1; + } while (uVar5 != 0xffffffff); + snprintf(acStack576,0x200,"value of \'%s\' (%d bits) is:\n",text,sVar2 * 0x20 + 1 + uVar5); + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + iVar1 = 0; + bVar4 = true; + uVar5 = 0; + while (sVar2 != 0xffffffff) { + if ((!bVar4) || (X->p[sVar2] != 0)) { + uVar6 = 0x18; + do { + if ((!bVar4) || ((X->p[sVar2] >> (uVar6 & 0x1f) & 0xff) != 0)) { + if (((uVar5 & 0xf) == 0) && (uVar5 != 0)) { + snprintf(acStack576 + iVar1,0x200 - iVar1,"\n"); + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + iVar1 = 0; + } + iVar3 = snprintf(acStack576 + iVar1,0x200 - iVar1," %02x", + X->p[sVar2] >> (uVar6 & 0x1f) & 0xff); + iVar1 = iVar1 + iVar3; + uVar5 = uVar5 + 1; + bVar4 = false; + } + uVar6 = uVar6 - 8; + } while (uVar6 != 0xfffffff8); + } + sVar2 = sVar2 - 1; + } + if (bVar4) { + iVar3 = snprintf(acStack576 + iVar1,0x200 - iVar1," 00"); + iVar1 = iVar1 + iVar3; + } + snprintf(acStack576 + iVar1,0x200 - iVar1,"\n"); + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + return; +} + + + +void mbedtls_debug_print_msg + (mbedtls_ssl_context *ssl,int level,char *file,int line,char *format,...) + +{ + uint uVar1; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list argp; + char str [512]; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + if ((((ssl != (mbedtls_ssl_context *)0x0) && (ssl->conf != (mbedtls_ssl_config *)0x0)) && + (ssl->conf->f_dbg != (anon_subr_void_void_ptr_int_char_ptr_int_char_ptr_for_f_dbg *)0x0)) && + (level <= debug_threshold)) { + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + uVar1 = vsnprintf((char *)&argp,0x200,format,&uStack12); + if (uVar1 < 0x1ff) { + *(undefined *)((int)&argp + uVar1) = 10; + *(undefined *)((int)&argp + uVar1 + 1) = 0; + } + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + } + return; +} + + + +void mbedtls_debug_print_ret + (mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,int ret) + +{ + char acStack544 [4]; + char str [512]; + + if ((((ssl->conf != (mbedtls_ssl_config *)0x0) && + (ssl->conf->f_dbg != (anon_subr_void_void_ptr_int_char_ptr_int_char_ptr_for_f_dbg *)0x0)) && + (level <= debug_threshold)) && (ret != -0x6900)) { + snprintf(acStack544,0x200,"%s() returned %d (-0x%04x)\n",text,ret,-ret); + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + } + return; +} + + + +void mbedtls_debug_print_buf + (mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,uchar *buf, + size_t len) + +{ + int iVar1; + byte bVar2; + int iVar3; + uint uVar4; + byte abStack596 [4]; + char txt [17]; + char str [512]; + + if (((ssl->conf != (mbedtls_ssl_config *)0x0) && + (ssl->conf->f_dbg != (anon_subr_void_void_ptr_int_char_ptr_int_char_ptr_for_f_dbg *)0x0)) && + (level <= debug_threshold)) { + snprintf(txt + 0x10,0x200,"dumping \'%s\' (%u bytes)\n",text,len); + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + memset(abStack596,0,0x11); + iVar3 = 0; + uVar4 = 0; + while (uVar4 != len) { + if (uVar4 == 0x1000) goto LAB_23093fc0; + if ((uVar4 & 0xf) == 0) { + if (uVar4 != 0) { + snprintf(txt + iVar3 + 0x10,0x200 - iVar3," %s\n",abStack596); + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + memset(abStack596,0,0x11); + iVar3 = 0; + } + iVar1 = snprintf(txt + iVar3 + 0x10,0x200 - iVar3,"%04x: ",uVar4); + iVar3 = iVar3 + iVar1; + } + iVar1 = snprintf(txt + iVar3 + 0x10,0x200 - iVar3," %02x",(uint)buf[uVar4]); + iVar3 = iVar3 + iVar1; + bVar2 = buf[uVar4]; + if (0x5e < (byte)(bVar2 - 0x20)) { + bVar2 = 0x2e; + } + abStack596[uVar4 & 0xf] = bVar2; + uVar4 = uVar4 + 1; + } + if (len != 0) { + while( true ) { + if ((len & 0xf) == 0) break; + iVar1 = snprintf(txt + iVar3 + 0x10,0x200 - iVar3," "); + iVar3 = iVar3 + iVar1; + len = len + 1; + } +LAB_23093fc0: + snprintf(txt + iVar3 + 0x10,0x200 - iVar3," %s\n",abStack596); + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + } + } + return; +} + + + +void mbedtls_debug_print_mpi + (mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,mbedtls_mpi *X) + +{ + if ((((ssl->conf != (mbedtls_ssl_config *)0x0) && + (ssl->conf->f_dbg != (anon_subr_void_void_ptr_int_char_ptr_int_char_ptr_for_f_dbg *)0x0)) && + (X != (mbedtls_mpi *)0x0)) && (level <= debug_threshold)) { + mbedtls_debug_print_mpi(ssl,level,file,line,text,X); + return; + } + return; +} + + + +void mbedtls_debug_print_ecp + (mbedtls_ssl_context *ssl,int level,char *file,int line,char *text, + mbedtls_ecp_point *X) + +{ + char acStack544 [4]; + char str [512]; + + snprintf(acStack544,0x200,"%s(X)",text); + mbedtls_debug_print_mpi(ssl,level,file,line,acStack544,(mbedtls_mpi *)X); + snprintf(acStack544,0x200,"%s(Y)",text); + mbedtls_debug_print_mpi(ssl,level,file,line,acStack544,&X->Y); + return; +} + + + +void mbedtls_debug_print_ecp + (mbedtls_ssl_context *ssl,int level,char *file,int line,char *text, + mbedtls_ecp_point *X) + +{ + if (((ssl->conf != (mbedtls_ssl_config *)0x0) && + (ssl->conf->f_dbg != (anon_subr_void_void_ptr_int_char_ptr_int_char_ptr_for_f_dbg *)0x0)) && + (level <= debug_threshold)) { + mbedtls_debug_print_ecp(ssl,level,file,line,text,X); + return; + } + return; +} + + + +void mbedtls_debug_print_crt + (mbedtls_ssl_context *ssl,int level,char *file,int line,char *text, + mbedtls_x509_crt *crt) + +{ + int iVar1; + mbedtls_ssl_config *level_00; + char *__src; + int iVar2; + void **ppvVar3; + char *__n; + char *pcVar4; + char *pcStack2132; + char acStack2128 [4]; + char name [16]; + char str [512]; + mbedtls_pk_debug_item items [3]; + char local_440 [4]; + char buf [1024]; + + if ((((ssl->conf != (mbedtls_ssl_config *)0x0) && + (ssl->conf->f_dbg != (anon_subr_void_void_ptr_int_char_ptr_int_char_ptr_for_f_dbg *)0x0)) && + (crt != (mbedtls_x509_crt *)0x0)) && (iVar2 = 0, level <= debug_threshold)) { + pcStack2132 = text; + do { + iVar2 = iVar2 + 1; + snprintf(name + 0xc,0x200,"%s #%d:\n",pcStack2132,iVar2); + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + mbedtls_x509_crt_info(local_440,0x3ff,"",crt); + __src = local_440; + pcVar4 = local_440; + while (__n = pcVar4, *__n != '\0') { + pcVar4 = __n + 1; + if (*__n == '\n') { + __n = __n + (1 - (int)__src); + if ((char *)0x1ff < __n) { + __n = (char *)0x1ff; + } + memcpy(str + 0x1fc,__src,(size_t)__n); + level_00 = ssl->conf; + *(undefined *)((int)__n + (int)register0x00002008 + -0x640) = 0; + debug_send_line((int)level_00,(char *)level,(int)file,(char *)line); + __src = pcVar4; + } + } + memset(str + 0x1fc,0,0x24); + iVar1 = mbedtls_pk_debug(&crt->pk,(mbedtls_pk_debug_item *)(str + 0x1fc)); + if (iVar1 == 0) { + ppvVar3 = (void **)(str + 0x1fc); + do { + if (*(char *)ppvVar3 == '\0') break; + snprintf(acStack2128,0x10,"%s%s",&UNK_230c8928,ppvVar3[1]); + name[11] = '\0'; + if (*(char *)ppvVar3 == '\x01') { + mbedtls_debug_print_mpi(ssl,level,file,line,acStack2128,(mbedtls_mpi *)ppvVar3[2]); + } + else { + if (*(char *)ppvVar3 == '\x02') { + mbedtls_debug_print_ecp + (ssl,level,file,line,acStack2128,(mbedtls_ecp_point *)ppvVar3[2]); + } + else { + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + } + } + ppvVar3 = ppvVar3 + 3; + } while (ppvVar3 != &items[2].value); + } + else { + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + } + crt = crt->next; + } while (crt != (mbedtls_x509_crt *)0x0); + } + return; +} + + + +ecp_curve_type ecp_get_type(mbedtls_ecp_group *grp) + +{ + if ((grp->G).X.p != (mbedtls_mpi_uint *)0x0) { + return ((grp->G).Y.p == (mbedtls_mpi_uint *)0x0) + ECP_TYPE_SHORT_WEIERSTRASS; + } + return ECP_TYPE_NONE; +} + + + +// WARNING: Variable defined which should be unmapped: mQY + +int ecp_safe_invert_jac(mbedtls_ecp_group *grp,mbedtls_ecp_point *Q,uchar inv) + +{ + mbedtls_mpi *B; + int iVar1; + undefined auStack28 [4]; + mbedtls_mpi mQY; + + B = &Q->Y; + mbedtls_mpi_init((mbedtls_mpi *)auStack28); + iVar1 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)auStack28,&grp->P,B); + if (iVar1 == 0) { + iVar1 = mbedtls_mpi_cmp_int(B,0); + iVar1 = mbedtls_mpi_safe_cond_assign(B,(mbedtls_mpi *)auStack28,inv & iVar1 != 0); + } + mbedtls_mpi_free((mbedtls_mpi *)auStack28); + return iVar1; +} + + + +int ecp_select_comb(mbedtls_ecp_group *grp,mbedtls_ecp_point *R,mbedtls_ecp_point *T,uchar t_len, + uchar i) + +{ + bool assign; + uint uVar1; + int iVar2; + undefined3 in_register_00002035; + undefined3 in_register_00002039; + + uVar1 = 0; + while( true ) { + assign = ((uint)i & 0x7e) >> 1 == uVar1; + iVar2 = mbedtls_mpi_safe_cond_assign((mbedtls_mpi *)R,(mbedtls_mpi *)T,assign); + if ((iVar2 != 0) || (iVar2 = mbedtls_mpi_safe_cond_assign(&R->Y,&T->Y,assign), iVar2 != 0)) + break; + uVar1 = uVar1 + 1 & 0xff; + T = T + 1; + if (CONCAT31(in_register_00002035,t_len) == uVar1) { + iVar2 = ecp_safe_invert_jac(grp,R,(uchar)(CONCAT31(in_register_00002039,i) >> 7)); + return iVar2; + } + } + return iVar2; +} + + + +int ecp_modp(mbedtls_mpi *N,mbedtls_ecp_group *grp) + +{ + mbedtls_mpi *B; + int iVar1; + size_t sVar2; + int iVar3; + + if (grp->modp == (anon_subr_int_mbedtls_mpi_ptr_for_modp *)0x0) { + iVar1 = mbedtls_mpi_mod_mpi(N,N,&grp->P); + return iVar1; + } + if (((-1 < N->s) || (iVar1 = mbedtls_mpi_cmp_int(N,0), iVar1 == 0)) && + (sVar2 = mbedtls_mpi_bitlen(N), sVar2 <= grp->pbits << 1)) { + B = &grp->P; + iVar3 = (*grp->modp)(N); + iVar1 = iVar3; + while( true ) { + if (iVar1 != 0) { + return iVar1; + } + if ((-1 < N->s) || (iVar1 = mbedtls_mpi_cmp_int(N,0), iVar1 == 0)) break; + iVar1 = mbedtls_mpi_add_mpi(N,N,B); + } + do { + iVar1 = mbedtls_mpi_cmp_mpi(N,B); + if (iVar1 < 0) { + return iVar3; + } + iVar1 = mbedtls_mpi_sub_abs(N,N,B); + } while (iVar1 == 0); + return iVar1; + } + return -0x4f80; +} + + + +int ecp_double_jac(mbedtls_ecp_group *grp,mbedtls_ecp_point *R,mbedtls_ecp_point *P) + +{ + mbedtls_mpi *X; + int iVar1; + mbedtls_mpi *Y; + mbedtls_mpi *Y_00; + undefined auStack96 [4]; + mbedtls_mpi M; + mbedtls_mpi S; + mbedtls_mpi T; + mbedtls_mpi U; + + X = (mbedtls_mpi *)&M.p; + mbedtls_mpi_init((mbedtls_mpi *)auStack96); + mbedtls_mpi_init(X); + mbedtls_mpi_init((mbedtls_mpi *)&S.p); + mbedtls_mpi_init((mbedtls_mpi *)&T.p); + if ((grp->A).p == (mbedtls_mpi_uint *)0x0) { + iVar1 = mbedtls_mpi_mul_mpi(X,&P->Z,&P->Z); + if ((iVar1 == 0) && (iVar1 = ecp_modp(X,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&S.p,(mbedtls_mpi *)P,X); + Y = &grp->P; + while (iVar1 == 0) { + iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&S.p,Y); + if (iVar1 < 0) { + iVar1 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&T.p,(mbedtls_mpi *)P,X); + goto LAB_230945d2; + } + iVar1 = mbedtls_mpi_sub_abs((mbedtls_mpi *)&S.p,(mbedtls_mpi *)&S.p,Y); + } + } + } + else { + iVar1 = mbedtls_mpi_mul_mpi(X,(mbedtls_mpi *)P,(mbedtls_mpi *)P); + if ((iVar1 == 0) && (iVar1 = ecp_modp(X,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_mul_int((mbedtls_mpi *)auStack96,X,3); + Y = &grp->P; + while (iVar1 == 0) { + iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)auStack96,Y); + if (iVar1 < 0) { + iVar1 = mbedtls_mpi_cmp_int(&grp->A,0); + if (iVar1 == 0) goto LAB_23094610; + iVar1 = mbedtls_mpi_mul_mpi(X,&P->Z,&P->Z); + if (((((iVar1 == 0) && (iVar1 = ecp_modp(X,grp), iVar1 == 0)) && + (iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&S.p,X,X), iVar1 == 0)) && + ((iVar1 = ecp_modp((mbedtls_mpi *)&S.p,grp), iVar1 == 0 && + (iVar1 = mbedtls_mpi_mul_mpi(X,(mbedtls_mpi *)&S.p,&grp->A), iVar1 == 0)))) && + (iVar1 = ecp_modp(X,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_add_mpi((mbedtls_mpi *)auStack96,(mbedtls_mpi *)auStack96,X); + goto LAB_2309488e; + } + break; + } + iVar1 = mbedtls_mpi_sub_abs((mbedtls_mpi *)auStack96,(mbedtls_mpi *)auStack96,Y); + } + } + } + goto cleanup; +LAB_2309488e: + if (iVar1 != 0) goto cleanup; + iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)auStack96,Y); + if (iVar1 < 0) goto LAB_23094610; + iVar1 = mbedtls_mpi_sub_abs((mbedtls_mpi *)auStack96,(mbedtls_mpi *)auStack96,Y); + goto LAB_2309488e; +LAB_230945d2: + if (iVar1 != 0) goto cleanup; + if ((-1 < (int)T.p) || (iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&T.p,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_mul_mpi(X,(mbedtls_mpi *)&S.p,(mbedtls_mpi *)&T.p); + if ((iVar1 == 0) && (iVar1 = ecp_modp(X,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_mul_int((mbedtls_mpi *)auStack96,X,3); + goto LAB_23094600; + } + goto cleanup; + } + iVar1 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&T.p,(mbedtls_mpi *)&T.p,Y); + goto LAB_230945d2; +LAB_23094600: + if (iVar1 != 0) goto cleanup; + iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)auStack96,Y); + if (iVar1 < 0) goto LAB_23094610; + iVar1 = mbedtls_mpi_sub_abs((mbedtls_mpi *)auStack96,(mbedtls_mpi *)auStack96,Y); + goto LAB_23094600; +LAB_23094670: + if (iVar1 != 0) goto cleanup; + iVar1 = mbedtls_mpi_cmp_mpi(X,Y_00); + if (iVar1 < 0) { + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T.p,(mbedtls_mpi *)&S.p,(mbedtls_mpi *)&S.p); + if ((iVar1 == 0) && (iVar1 = ecp_modp((mbedtls_mpi *)&T.p,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_shift_l((mbedtls_mpi *)&T.p,1); + goto LAB_230946a8; + } + goto cleanup; + } + iVar1 = mbedtls_mpi_sub_abs(X,X,Y_00); + goto LAB_23094670; +LAB_230946a8: + if (iVar1 != 0) goto cleanup; + iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&T.p,Y_00); + if (iVar1 < 0) { + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&S.p,(mbedtls_mpi *)auStack96, + (mbedtls_mpi *)auStack96); + if ((iVar1 == 0) && (iVar1 = ecp_modp((mbedtls_mpi *)&S.p,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&S.p,(mbedtls_mpi *)&S.p,X); + goto LAB_230946e2; + } + goto cleanup; + } + iVar1 = mbedtls_mpi_sub_abs((mbedtls_mpi *)&T.p,(mbedtls_mpi *)&T.p,Y_00); + goto LAB_230946a8; +LAB_230946e2: + if (iVar1 != 0) goto cleanup; + if ((-1 < (int)S.p) || (iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&S.p,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&S.p,(mbedtls_mpi *)&S.p,X); + goto LAB_230946f8; + } + iVar1 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&S.p,(mbedtls_mpi *)&S.p,Y_00); + goto LAB_230946e2; +LAB_230946f8: + if (iVar1 != 0) goto cleanup; + if ((-1 < (int)S.p) || (iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&S.p,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_sub_mpi(X,X,(mbedtls_mpi *)&S.p); + goto LAB_2309470e; + } + iVar1 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&S.p,(mbedtls_mpi *)&S.p,Y_00); + goto LAB_230946f8; +LAB_2309470e: + if (iVar1 != 0) goto cleanup; + if ((-1 < (int)M.p) || (iVar1 = mbedtls_mpi_cmp_int(X,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_mul_mpi(X,X,(mbedtls_mpi *)auStack96); + if ((iVar1 == 0) && (iVar1 = ecp_modp(X,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_sub_mpi(X,X,(mbedtls_mpi *)&T.p); + goto joined_r0x23094746; + } + goto cleanup; + } + iVar1 = mbedtls_mpi_add_mpi(X,X,Y_00); + goto LAB_2309470e; +joined_r0x23094746: + if (iVar1 != 0) goto cleanup; + if ((-1 < (int)M.p) || (iVar1 = mbedtls_mpi_cmp_int(X,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T.p,Y,&P->Z); + if ((iVar1 == 0) && (iVar1 = ecp_modp((mbedtls_mpi *)&T.p,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_shift_l((mbedtls_mpi *)&T.p,1); + goto LAB_23094778; + } + goto cleanup; + } + iVar1 = mbedtls_mpi_add_mpi(X,X,Y_00); + goto joined_r0x23094746; +LAB_23094778: + if (iVar1 != 0) goto cleanup; + iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&T.p,Y_00); + if (iVar1 < 0) { + iVar1 = mbedtls_mpi_copy((mbedtls_mpi *)R,(mbedtls_mpi *)&S.p); + if ((iVar1 == 0) && (iVar1 = mbedtls_mpi_copy(&R->Y,(mbedtls_mpi *)&M.p), iVar1 == 0)) { + iVar1 = mbedtls_mpi_copy(&R->Z,(mbedtls_mpi *)&T.p); + } + goto cleanup; + } + iVar1 = mbedtls_mpi_sub_abs((mbedtls_mpi *)&T.p,(mbedtls_mpi *)&T.p,Y_00); + goto LAB_23094778; +LAB_23094610: + Y = &P->Y; + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&S.p,Y,Y); + if ((iVar1 == 0) && (iVar1 = ecp_modp((mbedtls_mpi *)&S.p,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_shift_l((mbedtls_mpi *)&S.p,1); + Y_00 = &grp->P; + while (iVar1 == 0) { + iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&S.p,Y_00); + if (iVar1 < 0) { + iVar1 = mbedtls_mpi_mul_mpi(X,(mbedtls_mpi *)P,(mbedtls_mpi *)&S.p); + if ((iVar1 == 0) && (iVar1 = ecp_modp(X,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_shift_l(X,1); + goto LAB_23094670; + } + break; + } + iVar1 = mbedtls_mpi_sub_abs((mbedtls_mpi *)&S.p,(mbedtls_mpi *)&S.p,Y_00); + } + } +cleanup: + mbedtls_mpi_free((mbedtls_mpi *)auStack96); + mbedtls_mpi_free(X); + mbedtls_mpi_free((mbedtls_mpi *)&S.p); + mbedtls_mpi_free((mbedtls_mpi *)&T.p); + return iVar1; +} + + + +int ecp_normalize_jac(mbedtls_ecp_group *grp,mbedtls_ecp_point *pt) + +{ + mbedtls_mpi *X; + int iVar1; + mbedtls_mpi *X_00; + undefined auStack56 [4]; + mbedtls_mpi Zi; + mbedtls_mpi ZZi; + + X_00 = &pt->Z; + iVar1 = mbedtls_mpi_cmp_int(X_00,0); + if (iVar1 != 0) { + mbedtls_mpi_init((mbedtls_mpi *)auStack56); + mbedtls_mpi_init((mbedtls_mpi *)&Zi.p); + iVar1 = mbedtls_mpi_inv_mod((mbedtls_mpi *)auStack56,X_00,&grp->P); + if ((((iVar1 == 0) && + (iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&Zi.p,(mbedtls_mpi *)auStack56, + (mbedtls_mpi *)auStack56), iVar1 == 0)) && + (iVar1 = ecp_modp((mbedtls_mpi *)&Zi.p,grp), iVar1 == 0)) && + ((iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)pt,(mbedtls_mpi *)pt,(mbedtls_mpi *)&Zi.p), + iVar1 == 0 && (iVar1 = ecp_modp((mbedtls_mpi *)pt,grp), iVar1 == 0)))) { + X = &pt->Y; + iVar1 = mbedtls_mpi_mul_mpi(X,X,(mbedtls_mpi *)&Zi.p); + if (((iVar1 == 0) && + ((iVar1 = ecp_modp(X,grp), iVar1 == 0 && + (iVar1 = mbedtls_mpi_mul_mpi(X,X,(mbedtls_mpi *)auStack56), iVar1 == 0)))) && + (iVar1 = ecp_modp(X,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_lset(X_00,1); + } + } + mbedtls_mpi_free((mbedtls_mpi *)auStack56); + mbedtls_mpi_free((mbedtls_mpi *)&Zi.p); + } + return iVar1; +} + + + +int ecp_normalize_jac_many(mbedtls_ecp_group *grp,mbedtls_ecp_point **T,size_t t_len) + +{ + mbedtls_ecp_point **ppmVar1; + size_t sVar2; + mbedtls_mpi *A; + int iVar3; + mbedtls_mpi *X; + size_t sVar4; + mbedtls_mpi *X_00; + undefined auStack84 [4]; + mbedtls_mpi u; + mbedtls_mpi Zi; + mbedtls_mpi ZZi; + + if (t_len < 2) { + iVar3 = ecp_normalize_jac(grp,*T); + } + else { + X = (mbedtls_mpi *)mycalloc(t_len,0xc); + if (X == (mbedtls_mpi *)0x0) { + iVar3 = -0x4d80; + } + else { + mbedtls_mpi_init((mbedtls_mpi *)auStack84); + mbedtls_mpi_init((mbedtls_mpi *)&u.p); + mbedtls_mpi_init((mbedtls_mpi *)&Zi.p); + iVar3 = mbedtls_mpi_copy(X,&(*T)->Z); + if (iVar3 == 0) { + sVar2 = 1; + A = X; + do { + sVar4 = sVar2; + X_00 = A + 1; + iVar3 = mbedtls_mpi_mul_mpi(X_00,A,&T[sVar4]->Z); + if ((iVar3 != 0) || (iVar3 = ecp_modp(X_00,grp), iVar3 != 0)) goto cleanup; + sVar2 = sVar4 + 1; + A = X_00; + } while (t_len != sVar4 + 1); + iVar3 = mbedtls_mpi_inv_mod((mbedtls_mpi *)auStack84,X + (t_len - 1),&grp->P); + if (iVar3 == 0) { + T = T + t_len; + do { + if (sVar4 == 0) { + iVar3 = mbedtls_mpi_copy((mbedtls_mpi *)&u.p,(mbedtls_mpi *)auStack84); + } + else { + iVar3 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&u.p,(mbedtls_mpi *)auStack84, + X + (sVar4 - 1)); + if (((iVar3 != 0) || (iVar3 = ecp_modp((mbedtls_mpi *)&u.p,grp), iVar3 != 0)) || + (iVar3 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)auStack84,(mbedtls_mpi *)auStack84, + &T[-1]->Z), iVar3 != 0)) break; + iVar3 = ecp_modp((mbedtls_mpi *)auStack84,grp); + } + if (((((iVar3 != 0) || + (iVar3 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&Zi.p,(mbedtls_mpi *)&u.p, + (mbedtls_mpi *)&u.p), iVar3 != 0)) || + ((iVar3 = ecp_modp((mbedtls_mpi *)&Zi.p,grp), iVar3 != 0 || + ((iVar3 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)T[-1],(mbedtls_mpi *)T[-1], + (mbedtls_mpi *)&Zi.p), iVar3 != 0 || + (iVar3 = ecp_modp((mbedtls_mpi *)T[-1],grp), iVar3 != 0)))))) || + (iVar3 = mbedtls_mpi_mul_mpi(&T[-1]->Y,&T[-1]->Y,(mbedtls_mpi *)&Zi.p), iVar3 != 0)) + || ((((iVar3 = ecp_modp(&T[-1]->Y,grp), iVar3 != 0 || + (iVar3 = mbedtls_mpi_mul_mpi(&T[-1]->Y,&T[-1]->Y,(mbedtls_mpi *)&u.p), + iVar3 != 0)) || (iVar3 = ecp_modp(&T[-1]->Y,grp), iVar3 != 0)) || + ((iVar3 = mbedtls_mpi_shrink((mbedtls_mpi *)T[-1],(grp->P).n), iVar3 != 0 || + (iVar3 = mbedtls_mpi_shrink(&T[-1]->Y,(grp->P).n), iVar3 != 0)))))) break; + ppmVar1 = T + -1; + T = T + -1; + mbedtls_mpi_free(&(*ppmVar1)->Z); + if (sVar4 == 0) break; + sVar4 = sVar4 - 1; + } while( true ); + } + } +cleanup: + mbedtls_mpi_free((mbedtls_mpi *)auStack84); + mbedtls_mpi_free((mbedtls_mpi *)&u.p); + mbedtls_mpi_free((mbedtls_mpi *)&Zi.p); + A = X; + do { + X_00 = A + 1; + mbedtls_mpi_free(A); + A = X_00; + } while (X + t_len != X_00); + vPortFree(X); + } + } + return iVar3; +} + + + +void mbedtls_ecp_point_init(mbedtls_ecp_point *pt) + +{ + mbedtls_mpi_init((mbedtls_mpi *)pt); + mbedtls_mpi_init(&pt->Y); + mbedtls_mpi_init(&pt->Z); + return; +} + + + +void mbedtls_ecp_point_free(mbedtls_ecp_point *pt) + +{ + mbedtls_mpi_free((mbedtls_mpi *)pt); + mbedtls_mpi_free(&pt->Y); + mbedtls_mpi_free(&pt->Z); + return; +} + + + +mbedtls_ecp_group_id * mbedtls_ecp_grp_id_list(void) + +{ + int init_done; + int iVar1; + mbedtls_ecp_curve_info *pmVar2; + + if (init_done == 0) { + iVar1 = 0; + pmVar2 = ecp_supported_curves; + while (pmVar2->grp_id != MBEDTLS_ECP_DP_NONE) { + ecp_supported_grp_id[iVar1] = pmVar2->grp_id; + pmVar2 = pmVar2 + 1; + iVar1 = iVar1 + 1; + } + ecp_supported_grp_id[iVar1] = MBEDTLS_ECP_DP_NONE; + } + return ecp_supported_grp_id; +} + + + +void mbedtls_ecp_point_init(mbedtls_ecp_point *pt) + +{ + if (pt != (mbedtls_ecp_point *)0x0) { + mbedtls_ecp_point_init(pt); + return; + } + return; +} + + + +void mbedtls_ecp_group_init(mbedtls_ecp_group *grp) + +{ + if (grp != (mbedtls_ecp_group *)0x0) { + memset(grp,0,0x7c); + return; + } + return; +} + + + +void mbedtls_ecp_keypair_init(mbedtls_ecp_keypair *key) + +{ + if (key != (mbedtls_ecp_keypair *)0x0) { + mbedtls_ecp_group_init((mbedtls_ecp_group *)key); + mbedtls_mpi_init(&key->d); + mbedtls_ecp_point_init(&key->Q); + return; + } + return; +} + + + +void mbedtls_ecp_point_free(mbedtls_ecp_point *pt) + +{ + if (pt != (mbedtls_ecp_point *)0x0) { + mbedtls_ecp_point_free(pt); + return; + } + return; +} + + + +void mbedtls_ecp_group_free(mbedtls_ecp_group *grp) + +{ + uint uVar1; + mbedtls_ecp_group *pmVar2; + + if (grp != (mbedtls_ecp_group *)0x0) { + if (grp->h != 1) { + mbedtls_mpi_free(&grp->P); + mbedtls_mpi_free(&grp->A); + mbedtls_mpi_free(&grp->B); + mbedtls_ecp_point_free(&grp->G); + mbedtls_mpi_free(&grp->N); + } + uVar1 = 0; + if (grp->T != (mbedtls_ecp_point *)0x0) { + while (uVar1 < grp->T_size) { + mbedtls_ecp_point_free(grp->T + uVar1); + uVar1 = uVar1 + 1; + } + vPortFree(grp->T); + } + pmVar2 = grp + 1; + while (grp != pmVar2) { + grp->id = MBEDTLS_ECP_DP_NONE; + grp = (mbedtls_ecp_group *)&grp->field_0x1; + } + return; + } + return; +} + + + +void mbedtls_ecp_keypair_free(mbedtls_ecp_keypair *key) + +{ + if (key != (mbedtls_ecp_keypair *)0x0) { + mbedtls_ecp_group_free((mbedtls_ecp_group *)key); + mbedtls_mpi_free(&key->d); + mbedtls_ecp_point_free(&key->Q); + return; + } + return; +} + + + +int mbedtls_ecp_copy(mbedtls_ecp_point *P,mbedtls_ecp_point *Q) + +{ + int iVar1; + + iVar1 = mbedtls_mpi_copy((mbedtls_mpi *)P,(mbedtls_mpi *)Q); + if ((iVar1 == 0) && (iVar1 = mbedtls_mpi_copy(&P->Y,&Q->Y), iVar1 == 0)) { + iVar1 = mbedtls_mpi_copy(&P->Z,&Q->Z); + return iVar1; + } + return iVar1; +} + + + +int mbedtls_ecp_group_copy(mbedtls_ecp_group *dst,mbedtls_ecp_group *src) + +{ + int iVar1; + + iVar1 = mbedtls_ecp_group_load(dst,src->id); + return iVar1; +} + + + +int mbedtls_ecp_set_zero(mbedtls_ecp_point *pt) + +{ + int iVar1; + + iVar1 = mbedtls_mpi_lset((mbedtls_mpi *)pt,1); + if ((iVar1 == 0) && (iVar1 = mbedtls_mpi_lset(&pt->Y,1), iVar1 == 0)) { + iVar1 = mbedtls_mpi_lset(&pt->Z,0); + return iVar1; + } + return iVar1; +} + + + +int ecp_add_mixed(mbedtls_ecp_group *grp,mbedtls_ecp_point *R,mbedtls_ecp_point *P, + mbedtls_ecp_point *Q) + +{ + int iVar1; + mbedtls_ecp_point *Q_00; + mbedtls_mpi *X_00; + mbedtls_mpi *X_01; + int iStack132; + mbedtls_mpi T1; + mbedtls_mpi T2; + mbedtls_mpi T3; + mbedtls_mpi T4; + mbedtls_mpi X; + mbedtls_mpi Y; + mbedtls_mpi Z; + + X_01 = &P->Z; + iVar1 = mbedtls_mpi_cmp_int(X_01,0); + Q_00 = Q; + if (iVar1 == 0) { +LAB_23094f32: + iVar1 = mbedtls_ecp_copy(R,Q_00); + } + else { + if ((Q->Z).p != (mbedtls_mpi_uint *)0x0) { + iVar1 = mbedtls_mpi_cmp_int(&Q->Z,0); + Q_00 = P; + if (iVar1 == 0) goto LAB_23094f32; + if (((Q->Z).p != (mbedtls_mpi_uint *)0x0) && + (iVar1 = mbedtls_mpi_cmp_int(&Q->Z,1), iVar1 != 0)) { + return -0x4f80; + } + } + mbedtls_mpi_init((mbedtls_mpi *)&iStack132); + mbedtls_mpi_init((mbedtls_mpi *)&T1.p); + mbedtls_mpi_init((mbedtls_mpi *)&T2.p); + mbedtls_mpi_init((mbedtls_mpi *)&T3.p); + X_00 = (mbedtls_mpi *)&T4.p; + mbedtls_mpi_init(X_00); + mbedtls_mpi_init((mbedtls_mpi *)&X.p); + mbedtls_mpi_init((mbedtls_mpi *)&Y.p); + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&iStack132,X_01,X_01); + if ((((iVar1 == 0) && (iVar1 = ecp_modp((mbedtls_mpi *)&iStack132,grp), iVar1 == 0)) && + (iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T1.p,(mbedtls_mpi *)&iStack132,X_01), + iVar1 == 0)) && + (((iVar1 = ecp_modp((mbedtls_mpi *)&T1.p,grp), iVar1 == 0 && + (iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&iStack132,(mbedtls_mpi *)&iStack132, + (mbedtls_mpi *)Q), iVar1 == 0)) && + ((iVar1 = ecp_modp((mbedtls_mpi *)&iStack132,grp), iVar1 == 0 && + ((iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T1.p,(mbedtls_mpi *)&T1.p,&Q->Y), iVar1 == 0 + && (iVar1 = ecp_modp((mbedtls_mpi *)&T1.p,grp), iVar1 == 0)))))))) { + iVar1 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&iStack132,(mbedtls_mpi *)&iStack132, + (mbedtls_mpi *)P); + while (iVar1 == 0) { + if ((-1 < iStack132) || + (iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&iStack132,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&T1.p,(mbedtls_mpi *)&T1.p,&P->Y); + goto joined_r0x23094fa0; + } + iVar1 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&iStack132,(mbedtls_mpi *)&iStack132,&grp->P); + } + } +cleanup: + mbedtls_mpi_free((mbedtls_mpi *)&iStack132); + mbedtls_mpi_free((mbedtls_mpi *)&T1.p); + mbedtls_mpi_free((mbedtls_mpi *)&T2.p); + mbedtls_mpi_free((mbedtls_mpi *)&T3.p); + mbedtls_mpi_free(X_00); + mbedtls_mpi_free((mbedtls_mpi *)&X.p); + mbedtls_mpi_free((mbedtls_mpi *)&Y.p); + } + return iVar1; +joined_r0x23094fa0: + if (iVar1 != 0) goto cleanup; + if ((-1 < (int)T1.p) || (iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&T1.p,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&iStack132,0); + if (iVar1 == 0) { + iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&T1.p,0); + if (iVar1 == 0) { + iVar1 = ecp_double_jac(grp,R,P); + } + else { + iVar1 = mbedtls_ecp_set_zero(R); + } + } + else { + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&Y.p,X_01,(mbedtls_mpi *)&iStack132); + if (((((iVar1 == 0) && (iVar1 = ecp_modp((mbedtls_mpi *)&Y.p,grp), iVar1 == 0)) && + (iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T2.p,(mbedtls_mpi *)&iStack132, + (mbedtls_mpi *)&iStack132), iVar1 == 0)) && + ((iVar1 = ecp_modp((mbedtls_mpi *)&T2.p,grp), iVar1 == 0 && + (iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T3.p,(mbedtls_mpi *)&T2.p, + (mbedtls_mpi *)&iStack132), iVar1 == 0)))) && + ((iVar1 = ecp_modp((mbedtls_mpi *)&T3.p,grp), iVar1 == 0 && + ((iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T2.p,(mbedtls_mpi *)&T2.p,(mbedtls_mpi *)P), + iVar1 == 0 && (iVar1 = ecp_modp((mbedtls_mpi *)&T2.p,grp), iVar1 == 0)))))) { + iVar1 = mbedtls_mpi_mul_int((mbedtls_mpi *)&iStack132,(mbedtls_mpi *)&T2.p,2); + X_01 = &grp->P; + goto joined_r0x2309503c; + } + } + goto cleanup; + } + iVar1 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&T1.p,(mbedtls_mpi *)&T1.p,&grp->P); + goto joined_r0x23094fa0; +joined_r0x2309503c: + if (iVar1 != 0) goto cleanup; + iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&iStack132,X_01); + if (iVar1 < 0) { + iVar1 = mbedtls_mpi_mul_mpi(X_00,(mbedtls_mpi *)&T1.p,(mbedtls_mpi *)&T1.p); + if ((iVar1 == 0) && (iVar1 = ecp_modp(X_00,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_sub_mpi(X_00,X_00,(mbedtls_mpi *)&iStack132); + goto joined_r0x23095078; + } + goto cleanup; + } + iVar1 = mbedtls_mpi_sub_abs((mbedtls_mpi *)&iStack132,(mbedtls_mpi *)&iStack132,X_01); + goto joined_r0x2309503c; +joined_r0x23095078: + if (iVar1 != 0) goto cleanup; + if ((-1 < (int)T4.p) || (iVar1 = mbedtls_mpi_cmp_int(X_00,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_sub_mpi(X_00,X_00,(mbedtls_mpi *)&T3.p); + goto LAB_2309508c; + } + iVar1 = mbedtls_mpi_add_mpi(X_00,X_00,X_01); + goto joined_r0x23095078; +LAB_2309508c: + if (iVar1 != 0) goto cleanup; + if ((-1 < (int)T4.p) || (iVar1 = mbedtls_mpi_cmp_int(X_00,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&T2.p,(mbedtls_mpi *)&T2.p,X_00); + goto LAB_230950a2; + } + iVar1 = mbedtls_mpi_add_mpi(X_00,X_00,X_01); + goto LAB_2309508c; +LAB_230950a2: + if (iVar1 != 0) goto cleanup; + if ((-1 < (int)T2.p) || (iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&T2.p,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T2.p,(mbedtls_mpi *)&T2.p,(mbedtls_mpi *)&T1.p); + if ((iVar1 == 0) && + (((iVar1 = ecp_modp((mbedtls_mpi *)&T2.p,grp), iVar1 == 0 && + (iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T3.p,(mbedtls_mpi *)&T3.p,&P->Y), iVar1 == 0)) + && (iVar1 = ecp_modp((mbedtls_mpi *)&T3.p,grp), iVar1 == 0)))) { + iVar1 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&X.p,(mbedtls_mpi *)&T2.p,(mbedtls_mpi *)&T3.p); + goto LAB_230950f4; + } + goto cleanup; + } + iVar1 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&T2.p,(mbedtls_mpi *)&T2.p,X_01); + goto LAB_230950a2; +LAB_230950f4: + if (iVar1 != 0) goto cleanup; + if ((-1 < (int)X.p) || (iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&X.p,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_copy((mbedtls_mpi *)R,X_00); + if ((iVar1 == 0) && (iVar1 = mbedtls_mpi_copy(&R->Y,(mbedtls_mpi *)&X.p), iVar1 == 0)) { + iVar1 = mbedtls_mpi_copy(&R->Z,(mbedtls_mpi *)&Y.p); + } + goto cleanup; + } + iVar1 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&X.p,(mbedtls_mpi *)&X.p,X_01); + goto LAB_230950f4; +} + + + +int ecp_mul_comb(mbedtls_ecp_group *grp,mbedtls_ecp_point *R,mbedtls_mpi *m,mbedtls_ecp_point *P, + anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng) + +{ + byte bVar1; + byte bVar2; + byte bVar3; + uint uVar4; + mbedtls_mpi_uint **ppmVar5; + int iVar6; + int iVar7; + int iVar8; + int iVar9; + uint uVar10; + uchar t_len; + uint uVar11; + uint uVar12; + mbedtls_ecp_point *P_00; + mbedtls_ecp_point *P_01; + uint uVar13; + uint uVar14; + size_t pos; + mbedtls_mpi *X; + uint numitems; + uint uVar15; + mbedtls_mpi_uint **ppmVar16; + int iVar17; + size_t t_len_00; + undefined auStack412 [4]; + mbedtls_mpi M; + mbedtls_mpi mm; + mbedtls_mpi l; + mbedtls_mpi ll; + mbedtls_ecp_point Txi; + uchar k [262]; + + mbedtls_mpi_init((mbedtls_mpi *)auStack412); + mbedtls_mpi_init((mbedtls_mpi *)&M.p); + iVar6 = mbedtls_mpi_get_bit(&grp->N,0); + if (iVar6 != 1) { + return -0x4f80; + } + uVar13 = (uint)(0x17f < grp->nbits); + iVar6 = mbedtls_mpi_cmp_mpi(&P->Y,&(grp->G).Y); + uVar14 = uVar13 + 4; + if (iVar6 == 0) { + iVar7 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)P,(mbedtls_mpi *)&grp->G); + if (iVar7 == 0) { + uVar14 = uVar13 + 5; + iVar6 = 1; + } + } + else { + iVar6 = 0; + } + if (grp->nbits <= uVar14) { + uVar14 = 2; + } + uVar15 = uVar14 - 1; + numitems = 1 << (uVar15 & 0x1f); + uVar13 = ((grp->nbits - 1) + uVar14) / uVar14; + if ((iVar6 == 0) || (P_01 = grp->T, P_01 == (mbedtls_ecp_point *)0x0)) { + P_01 = (mbedtls_ecp_point *)mycalloc(numitems,0x24); + if (P_01 == (mbedtls_ecp_point *)0x0) { + iVar7 = -0x4d80; + goto LAB_23095342; + } + iVar7 = mbedtls_ecp_copy(P_01,P); + if (iVar7 == 0) { + t_len_00 = 0; + uVar11 = 1; + while (uVar12 = uVar11 >> (uVar15 & 0x1f), uVar12 == 0) { + P_00 = P_01 + uVar11; + iVar7 = mbedtls_ecp_copy(P_00,P_01 + (uVar11 >> 1)); + if (iVar7 != 0) goto LAB_2309531e; + while (uVar13 != uVar12) { + iVar7 = ecp_double_jac(grp,P_00,P_00); + if (iVar7 != 0) goto LAB_2309531e; + uVar12 = uVar12 + 1; + } + *(mbedtls_ecp_point **)(&Txi.Z.p + t_len_00) = P_00; + uVar11 = (uVar11 & 0x7f) << 1; + t_len_00 = t_len_00 + 1 & 0xff; + } + iVar7 = ecp_normalize_jac_many(grp,(mbedtls_ecp_point **)&Txi.Z.p,t_len_00); + if (iVar7 == 0) { + t_len_00 = 0; + uVar11 = 1; + while (uVar11 >> (uVar15 & 0x1f) == 0) { + uVar10 = t_len_00 + uVar11; + P_00 = P_01 + uVar11; + uVar12 = uVar11; + while( true ) { + t_len_00 = (uVar10 & 0xff) - uVar12 & 0xff; + uVar4 = uVar12 - 1; + if (uVar12 == 0) break; + iVar7 = ecp_add_mixed(grp,P_00 + uVar4,P_01 + uVar4,P_00); + if (iVar7 != 0) goto LAB_2309531e; + *(mbedtls_ecp_point **)(&Txi.Z.p + t_len_00) = P_00 + uVar4; + uVar12 = uVar4; + } + uVar11 = (uVar11 & 0x7f) << 1; + } + iVar7 = ecp_normalize_jac_many(grp,(mbedtls_ecp_point **)&Txi.Z.p,t_len_00); + if (iVar7 == 0) { + if (iVar6 != 0) { + grp->T = P_01; + grp->T_size = numitems; + } + goto LAB_23095440; + } + } + } + } + else { +LAB_23095440: + iVar8 = mbedtls_mpi_get_bit(m,0); + iVar7 = mbedtls_mpi_copy((mbedtls_mpi *)auStack412,m); + if ((iVar7 == 0) && (iVar7 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&M.p,&grp->N,m), iVar7 == 0)) { + iVar7 = mbedtls_mpi_safe_cond_assign((mbedtls_mpi *)auStack412,(mbedtls_mpi *)&M.p,iVar8 != 1) + ; + if (iVar7 == 0) { + ppmVar5 = &Txi.Z.p; + memset(&Txi.Z.p,0,uVar13 + 1); + t_len_00 = 0; + ppmVar16 = ppmVar5; + while (uVar13 != t_len_00) { + uVar15 = 0; + pos = t_len_00; + do { + iVar7 = mbedtls_mpi_get_bit((mbedtls_mpi *)auStack412,pos); + *(byte *)ppmVar16 = (byte)(iVar7 << (uVar15 & 0x1f)) | *(byte *)ppmVar16; + uVar15 = uVar15 + 1; + pos = pos + uVar13; + } while (uVar15 < uVar14); + t_len_00 = t_len_00 + 1; + ppmVar16 = (mbedtls_mpi_uint **)((int)ppmVar16 + 1); + } + uVar13 = 0; + while (ppmVar5 != (mbedtls_mpi_uint **)((int)&Txi.Z.p + t_len_00)) { + bVar1 = *(byte *)((int)ppmVar5 + 1); + uVar14 = bVar1 ^ uVar13; + uVar15 = ~uVar14 & 1; + bVar3 = *(byte *)ppmVar5 * (char)uVar15; + *(byte *)ppmVar5 = (byte)(uVar15 << 7) | *(byte *)ppmVar5; + bVar2 = (byte)uVar14; + *(byte *)(mbedtls_mpi_uint **)((int)ppmVar5 + 1) = bVar2 ^ bVar3; + uVar13 = bVar1 & uVar13 | (int)(char)(bVar2 & bVar3) & 0xffU; + ppmVar5 = (mbedtls_mpi_uint **)((int)ppmVar5 + 1); + } + mbedtls_ecp_point_init((mbedtls_ecp_point *)&ll.p); + t_len = (uchar)(numitems & 0xff); + iVar7 = ecp_select_comb(grp,R,P_01,t_len,*(uchar *)((int)&Txi.Z.p + t_len_00)); + if (iVar7 == 0) { + X = &R->Z; + iVar9 = mbedtls_mpi_lset(X,1); + iVar7 = iVar9; + if (iVar9 == 0) { + if (f_rng != (anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0) { + pos = grp->pbits; + mbedtls_mpi_init((mbedtls_mpi *)&mm.p); + mbedtls_mpi_init((mbedtls_mpi *)&l.p); + iVar17 = 0xc; + do { + mbedtls_mpi_fill_random((mbedtls_mpi *)&mm.p,pos + 7 >> 3,f_rng,p_rng); + while (iVar7 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&mm.p,&grp->P), -1 < iVar7) { + iVar7 = mbedtls_mpi_shift_r((mbedtls_mpi *)&mm.p,1); + if (iVar7 != 0) goto cleanup; + } + iVar17 = iVar17 + -1; + if (iVar17 == 0) { + iVar7 = -0x4d00; + goto cleanup; + } + iVar7 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&mm.p,1); + } while (iVar7 < 1); + iVar7 = mbedtls_mpi_mul_mpi(X,X,(mbedtls_mpi *)&mm.p); + if ((((iVar7 == 0) && (iVar7 = ecp_modp(X,grp), iVar7 == 0)) && + (iVar7 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&l.p,(mbedtls_mpi *)&mm.p, + (mbedtls_mpi *)&mm.p), iVar7 == 0)) && + (((iVar7 = ecp_modp((mbedtls_mpi *)&l.p,grp), iVar7 == 0 && + (iVar7 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)R,(mbedtls_mpi *)R, + (mbedtls_mpi *)&l.p), iVar7 == 0)) && + ((iVar7 = ecp_modp((mbedtls_mpi *)R,grp), iVar7 == 0 && + ((iVar7 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&l.p,(mbedtls_mpi *)&l.p, + (mbedtls_mpi *)&mm.p), iVar7 == 0 && + (iVar7 = ecp_modp((mbedtls_mpi *)&l.p,grp), iVar7 == 0)))))))) { + X = &R->Y; + iVar7 = mbedtls_mpi_mul_mpi(X,X,(mbedtls_mpi *)&l.p); + if (iVar7 == 0) { + iVar7 = ecp_modp(X,grp); + } + } +cleanup: + mbedtls_mpi_free((mbedtls_mpi *)&mm.p); + mbedtls_mpi_free((mbedtls_mpi *)&l.p); + if (iVar7 != 0) goto cleanup; + } + do { + iVar7 = iVar9; + if (((t_len_00 - 1 == 0xffffffff) || (iVar7 = ecp_double_jac(grp,R,R), iVar7 != 0)) || + (iVar7 = ecp_select_comb(grp,(mbedtls_ecp_point *)&ll.p,P_01,t_len, + *(uchar *)((int)&Txi.Z.n + t_len_00 + 3)), iVar7 != 0)) + break; + iVar7 = ecp_add_mixed(grp,R,R,(mbedtls_ecp_point *)&ll.p); + t_len_00 = t_len_00 - 1; + } while (iVar7 == 0); + } + } +cleanup: + mbedtls_ecp_point_free((mbedtls_ecp_point *)&ll.p); + if ((iVar7 == 0) && (iVar7 = ecp_safe_invert_jac(grp,R,iVar8 != 1), iVar7 == 0)) { + iVar7 = ecp_normalize_jac(grp,R); + } + } + } + } +LAB_2309531e: + if (iVar6 == 0) { + uVar13 = 0; + do { + uVar14 = uVar13 + 1; + mbedtls_ecp_point_free(P_01 + uVar13); + uVar13 = uVar14; + } while ((uVar14 & 0xff) < (numitems & 0xff)); + vPortFree(P_01); + } +LAB_23095342: + mbedtls_mpi_free((mbedtls_mpi *)auStack412); + mbedtls_mpi_free((mbedtls_mpi *)&M.p); + if (iVar7 != 0) { + mbedtls_ecp_point_free(R); + } + return iVar7; +} + + + +int mbedtls_ecp_point_read_binary + (mbedtls_ecp_group *grp,mbedtls_ecp_point *pt,uchar *buf,size_t ilen) + +{ + int iVar1; + size_t buflen; + + if (ilen != 0) { + if (*buf != '\0') { + buflen = mbedtls_mpi_size(&grp->P); + if (*buf == '\x04') { + if (ilen == buflen * 2 + 1) { + iVar1 = mbedtls_mpi_read_binary((mbedtls_mpi *)pt,buf + 1,buflen); + if ((iVar1 == 0) && + (iVar1 = mbedtls_mpi_read_binary(&pt->Y,buf + buflen + 1,buflen), iVar1 == 0)) { + iVar1 = mbedtls_mpi_lset(&pt->Z,1); + return iVar1; + } + } + else { + iVar1 = -0x4f80; + } + } + else { + iVar1 = -0x4e80; + } + return iVar1; + } + if (ilen == 1) { + iVar1 = mbedtls_ecp_set_zero(pt); + return iVar1; + } + } + return -0x4f80; +} + + + +int mbedtls_ecp_check_pubkey(mbedtls_ecp_group *grp,mbedtls_ecp_point *pt) + +{ + mbedtls_mpi *X; + ecp_curve_type eVar1; + int iVar2; + undefined3 extraout_var; + mbedtls_mpi *Y; + undefined auStack56 [4]; + mbedtls_mpi YY; + mbedtls_mpi RHS; + + iVar2 = mbedtls_mpi_cmp_int(&pt->Z,1); + if (iVar2 == 0) { + eVar1 = ecp_get_type(grp); + if (CONCAT31(extraout_var,eVar1) != 1) { + return -0x4f80; + } + iVar2 = mbedtls_mpi_cmp_int((mbedtls_mpi *)pt,0); + if (-1 < iVar2) { + X = &pt->Y; + iVar2 = mbedtls_mpi_cmp_int(X,0); + if (-1 < iVar2) { + Y = &grp->P; + iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)pt,Y); + if ((iVar2 < 0) && (iVar2 = mbedtls_mpi_cmp_mpi(X,Y), iVar2 < 0)) { + mbedtls_mpi_init((mbedtls_mpi *)auStack56); + mbedtls_mpi_init((mbedtls_mpi *)&YY.p); + iVar2 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)auStack56,X,X); + if ((iVar2 == 0) && + (((iVar2 = ecp_modp((mbedtls_mpi *)auStack56,grp), iVar2 == 0 && + (iVar2 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&YY.p,(mbedtls_mpi *)pt,(mbedtls_mpi *)pt + ), iVar2 == 0)) && + (iVar2 = ecp_modp((mbedtls_mpi *)&YY.p,grp), iVar2 == 0)))) { + if ((grp->A).p == (mbedtls_mpi_uint *)0x0) { + iVar2 = mbedtls_mpi_sub_int((mbedtls_mpi *)&YY.p,(mbedtls_mpi *)&YY.p,3); + while (iVar2 == 0) { + if ((-1 < (int)YY.p) || + (iVar2 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&YY.p,0), iVar2 == 0)) + goto LAB_2309580c; + iVar2 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&YY.p,(mbedtls_mpi *)&YY.p,Y); + } + } + else { + iVar2 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&YY.p,(mbedtls_mpi *)&YY.p,&grp->A); + while (iVar2 == 0) { + iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&YY.p,Y); + if (iVar2 < 0) goto LAB_2309580c; + iVar2 = mbedtls_mpi_sub_abs((mbedtls_mpi *)&YY.p,(mbedtls_mpi *)&YY.p,Y); + } + } + } + goto cleanup; + } + } + } + } + return -0x4c80; +LAB_2309580c: + iVar2 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&YY.p,(mbedtls_mpi *)&YY.p,(mbedtls_mpi *)pt); + if ((iVar2 == 0) && (iVar2 = ecp_modp((mbedtls_mpi *)&YY.p,grp), iVar2 == 0)) { + iVar2 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&YY.p,(mbedtls_mpi *)&YY.p,&grp->B); + while (iVar2 == 0) { + iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&YY.p,Y); + if (iVar2 < 0) { + iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)auStack56,(mbedtls_mpi *)&YY.p); + if (iVar2 != 0) { + iVar2 = -0x4c80; + } + break; + } + iVar2 = mbedtls_mpi_sub_abs((mbedtls_mpi *)&YY.p,(mbedtls_mpi *)&YY.p,Y); + } + } +cleanup: + mbedtls_mpi_free((mbedtls_mpi *)auStack56); + mbedtls_mpi_free((mbedtls_mpi *)&YY.p); + return iVar2; +} + + + +int mbedtls_ecp_check_privkey(mbedtls_ecp_group *grp,mbedtls_mpi *d) + +{ + ecp_curve_type eVar1; + undefined3 extraout_var; + int iVar2; + + eVar1 = ecp_get_type(grp); + if (CONCAT31(extraout_var,eVar1) == 1) { + iVar2 = mbedtls_mpi_cmp_int(d,1); + if ((-1 < iVar2) && (iVar2 = mbedtls_mpi_cmp_mpi(d,&grp->N), iVar2 < 0)) { + return 0; + } + iVar2 = -0x4c80; + } + else { + iVar2 = -0x4f80; + } + return iVar2; +} + + + +int mbedtls_ecp_mul(mbedtls_ecp_group *grp,mbedtls_ecp_point *R,mbedtls_mpi *m,mbedtls_ecp_point *P, + anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng) + +{ + ecp_curve_type eVar1; + int iVar2; + undefined3 extraout_var; + + iVar2 = mbedtls_mpi_cmp_int(&P->Z,1); + if (iVar2 == 0) { + iVar2 = mbedtls_ecp_check_privkey(grp,m); + if (((iVar2 == 0) && (iVar2 = mbedtls_ecp_check_pubkey(grp,P), iVar2 == 0)) && + (eVar1 = ecp_get_type(grp), CONCAT31(extraout_var,eVar1) == 1)) { + iVar2 = ecp_mul_comb(grp,R,m,P,f_rng,p_rng); + return iVar2; + } + } + else { + iVar2 = -0x4f80; + } + return iVar2; +} + + + +int mbedtls_ecp_check_pub_priv(mbedtls_ecp_keypair *pub,mbedtls_ecp_keypair *prv) + +{ + mbedtls_ecp_group_id mVar1; + int iVar2; + mbedtls_mpi *Y; + mbedtls_mpi *Y_00; + undefined auStack192 [4]; + mbedtls_ecp_point Q; + mbedtls_ecp_group grp; + + mVar1 = (pub->grp).id; + if ((mVar1 != MBEDTLS_ECP_DP_NONE) && ((prv->grp).id == mVar1)) { + iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&pub->Q,(mbedtls_mpi *)&prv->Q); + if (iVar2 == 0) { + Y_00 = &(prv->Q).Y; + iVar2 = mbedtls_mpi_cmp_mpi(&(pub->Q).Y,Y_00); + if (iVar2 == 0) { + Y = &(prv->Q).Z; + iVar2 = mbedtls_mpi_cmp_mpi(&(pub->Q).Z,Y); + if (iVar2 == 0) { + mbedtls_ecp_point_init((mbedtls_ecp_point *)auStack192); + memset(&Q.Z.p,0,0x7c); + mbedtls_ecp_group_copy((mbedtls_ecp_group *)&Q.Z.p,(mbedtls_ecp_group *)prv); + iVar2 = mbedtls_ecp_mul((mbedtls_ecp_group *)&Q.Z.p,(mbedtls_ecp_point *)auStack192, + &prv->d,&(prv->grp).G, + (anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0,(void *)0x0); + if ((iVar2 == 0) && + (((iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)auStack192,(mbedtls_mpi *)&prv->Q), + iVar2 != 0 || (iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&Q.X.p,Y_00), iVar2 != 0)) + || (iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&Q.Y.p,Y), iVar2 != 0)))) { + iVar2 = -0x4f80; + } + mbedtls_ecp_point_free((mbedtls_ecp_point *)auStack192); + mbedtls_ecp_group_free((mbedtls_ecp_group *)&Q.Z.p); + return iVar2; + } + } + } + } + return -0x4f80; +} + + + +int ecp_mod_koblitz(mbedtls_mpi *N,mbedtls_mpi_uint *Rp,size_t p_limbs) + +{ + int iVar1; + uint uVar2; + size_t sVar3; + mbedtls_mpi_uint **__s; + int iStack100; + mbedtls_mpi M; + mbedtls_mpi R; + mbedtls_mpi_uint Mp [11]; + + if (N->n < p_limbs) { + return 0; + } + __s = &R.p; + M.p = (mbedtls_mpi_uint *)&DAT_00000001; + R.s = 2; + iStack100 = 1; + uVar2 = N->n - p_limbs; + M.s = p_limbs; + if (uVar2 <= p_limbs) { + M.s = uVar2; + } + M.n = (size_t)__s; + R.n = (size_t)Rp; + memset(__s,0,0x2c); + memcpy(__s,N->p + p_limbs,M.s << 2); + M.s = M.s + R.s; + sVar3 = p_limbs; + while (sVar3 < N->n) { + N->p[sVar3] = 0; + sVar3 = sVar3 + 1; + } + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&iStack100,(mbedtls_mpi *)&iStack100, + (mbedtls_mpi *)&M.p); + if ((iVar1 == 0) && (iVar1 = mbedtls_mpi_add_abs(N,N,(mbedtls_mpi *)&iStack100), iVar1 == 0)) { + uVar2 = N->n - p_limbs; + M.s = p_limbs; + if (uVar2 <= p_limbs) { + M.s = uVar2; + } + memset(__s,0,0x2c); + memcpy(__s,N->p + p_limbs,M.s << 2); + M.s = M.s + R.s; + while (p_limbs < N->n) { + N->p[p_limbs] = 0; + p_limbs = p_limbs + 1; + } + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&iStack100,(mbedtls_mpi *)&iStack100, + (mbedtls_mpi *)&M.p); + if (iVar1 == 0) { + iVar1 = mbedtls_mpi_add_abs(N,N,(mbedtls_mpi *)&iStack100); + } + } + return iVar1; +} + + + +int ecp_mod_p224k1(mbedtls_mpi *N) + +{ + mbedtls_mpi_uint Rp [2]; + int iVar1; + + iVar1 = ecp_mod_koblitz(N,(mbedtls_mpi_uint *)&ram0x4200ece8,7); + return iVar1; +} + + + +int ecp_mod_p256k1(mbedtls_mpi *N) + +{ + mbedtls_mpi_uint Rp [2]; + int iVar1; + + iVar1 = ecp_mod_koblitz(N,(mbedtls_mpi_uint *)&ram0x4200ecf0,8); + return iVar1; +} + + + +int mbedtls_ecp_group_load(mbedtls_ecp_group *grp,mbedtls_ecp_group_id id) + +{ + size_t sVar1; + undefined3 in_register_0000202d; + int iVar2; + mbedtls_mpi_uint *pmVar3; + + iVar2 = CONCAT31(in_register_0000202d,id); + mbedtls_ecp_group_free(grp); + grp->id = id; + if (iVar2 == 0xb) { + (grp->P).p = secp224k1_p; + (grp->A).p = secp224k1_a; + (grp->B).p = secp224k1_b; + (grp->N).n = 8; + grp->modp = ecp_mod_p224k1; + (grp->N).p = secp224k1_n; + (grp->P).n = 7; + (grp->G).X.n = 7; + (grp->G).Y.n = 7; + (grp->P).s = 1; + (grp->A).s = 1; + (grp->A).n = 1; + (grp->B).s = 1; + (grp->B).n = 1; + (grp->N).s = 1; + (grp->G).X.s = 1; + (grp->G).X.p = secp224k1_gx; + (grp->G).Y.s = 1; + pmVar3 = secp224k1_gy; + } + else { + if (iVar2 == 0xc) { + (grp->P).p = secp256k1_p; + (grp->A).p = secp256k1_a; + (grp->B).p = secp256k1_b; + grp->modp = ecp_mod_p256k1; + (grp->N).p = secp256k1_n; + (grp->P).n = 8; + (grp->N).n = 8; + (grp->G).X.n = 8; + (grp->G).Y.n = 8; + (grp->P).s = 1; + (grp->A).s = 1; + (grp->A).n = 1; + (grp->B).s = 1; + (grp->B).n = 1; + (grp->N).s = 1; + (grp->G).X.s = 1; + (grp->G).X.p = secp256k1_gx; + (grp->G).Y.s = 1; + pmVar3 = secp256k1_gy; + } + else { + if (iVar2 != 3) { + mbedtls_ecp_group_free(grp); + return -0x4e80; + } + (grp->P).p = secp256r1_p; + (grp->B).p = secp256r1_b; + (grp->N).p = secp256r1_n; + (grp->P).n = 8; + (grp->B).n = 8; + (grp->N).n = 8; + (grp->G).X.n = 8; + (grp->G).Y.n = 8; + (grp->P).s = 1; + (grp->B).s = 1; + (grp->N).s = 1; + (grp->G).X.s = 1; + (grp->G).X.p = secp256r1_gx; + (grp->G).Y.s = 1; + pmVar3 = secp256r1_gy; + } + } + (grp->G).Y.p = pmVar3; + (grp->G).Z.p = &one_2614; + (grp->G).Z.s = 1; + (grp->G).Z.n = 1; + sVar1 = mbedtls_mpi_bitlen(&grp->P); + grp->pbits = sVar1; + sVar1 = mbedtls_mpi_bitlen(&grp->N); + grp->nbits = sVar1; + grp->h = 1; + return 0; +} + + + +void gcm_mult(mbedtls_gcm_context *ctx,uchar *x,uchar *output) + +{ + mbedtls_cipher_info_t *pmVar1; + mbedtls_cipher_info_t **ppmVar2; + mbedtls_cipher_info_t *pmVar3; + mbedtls_cipher_info_t *pmVar4; + mbedtls_cipher_info_t *pmVar5; + uint uVar6; + int iVar7; + uint uVar8; + uint uVar9; + + iVar7 = 0xf; + ppmVar2 = &(ctx->cipher_ctx).cipher_info + ((uint)x[0xf] & 0xf) * 2; + pmVar1 = ppmVar2[0x30]; + pmVar4 = ppmVar2[0x31]; + pmVar5 = ppmVar2[0x10]; + pmVar3 = ppmVar2[0x11]; + do { + uVar8 = (int)pmVar1 << 0x1c; + uVar6 = (int)pmVar4 << 0x1c; + if (iVar7 != 0xf) { + ppmVar2 = &(ctx->cipher_ctx).cipher_info + ((uint)x[iVar7] & 0xf) * 2; + pmVar4 = (mbedtls_cipher_info_t *) + ((uint)ppmVar2[0x31] ^ + *(int *)(last4 + ((uint)pmVar5 & 0xf)) << 0x10 ^ (uint)pmVar4 >> 4); + pmVar1 = (mbedtls_cipher_info_t *)((uint)ppmVar2[0x30] ^ (uVar6 | (uint)pmVar1 >> 4)); + pmVar5 = (mbedtls_cipher_info_t *) + ((uint)ppmVar2[0x10] ^ ((uint)pmVar5 >> 4 | (int)pmVar3 << 0x1c)); + pmVar3 = (mbedtls_cipher_info_t *)((uint)ppmVar2[0x11] ^ (uVar8 | (uint)pmVar3 >> 4)); + } + ppmVar2 = &(ctx->cipher_ctx).cipher_info + (uint)(x[iVar7] >> 4) * 2; + uVar8 = (int)pmVar1 << 0x1c; + uVar9 = (int)pmVar4 << 0x1c; + uVar6 = (uint)ppmVar2[0x31] ^ (uint)pmVar4 >> 4; + pmVar4 = (mbedtls_cipher_info_t *)(uVar6 ^ *(int *)(last4 + ((uint)pmVar5 & 0xf)) << 0x10); + iVar7 = iVar7 + -1; + pmVar1 = (mbedtls_cipher_info_t *)((uint)ppmVar2[0x30] ^ (uVar9 | (uint)pmVar1 >> 4)); + pmVar5 = (mbedtls_cipher_info_t *) + ((uint)ppmVar2[0x10] ^ ((int)pmVar3 << 0x1c | (uint)pmVar5 >> 4)); + pmVar3 = (mbedtls_cipher_info_t *)((uint)ppmVar2[0x11] ^ (uVar8 | (uint)pmVar3 >> 4)); + } while (iVar7 != -1); + *output = (uchar)((uint)pmVar4 >> 0x18); + output[1] = (uchar)((uint)pmVar4 >> 0x10); + output[3] = (uchar)uVar6; + output[4] = (uchar)((uint)pmVar1 >> 0x18); + output[5] = (uchar)((uint)pmVar1 >> 0x10); + output[6] = (uchar)((uint)pmVar1 >> 8); + output[8] = (uchar)((uint)pmVar3 >> 0x18); + output[9] = (uchar)((uint)pmVar3 >> 0x10); + output[10] = (uchar)((uint)pmVar3 >> 8); + output[0xc] = (uchar)((uint)pmVar5 >> 0x18); + output[0xd] = (uchar)((uint)pmVar5 >> 0x10); + output[2] = (uchar)(uVar6 >> 8); + output[7] = (uchar)pmVar1; + output[0xb] = (uchar)pmVar3; + output[0xe] = (uchar)((uint)pmVar5 >> 8); + output[0xf] = (uchar)pmVar5; + return; +} + + + +void mbedtls_gcm_init(mbedtls_gcm_context *ctx) + +{ + memset(ctx,0,0x188); + return; +} + + + +// WARNING: Variable defined which should be unmapped: h +// WARNING: Could not reconcile some variable overlaps + +int mbedtls_gcm_setkey(mbedtls_gcm_context *ctx,mbedtls_cipher_id_t cipher,uchar *key,uint keybits) + +{ + uint64_t *puVar1; + uint uVar2; + uint64_t *puVar3; + mbedtls_cipher_info_t *cipher_info; + int iVar4; + uint uVar5; + mbedtls_cipher_info_t **ppmVar6; + mbedtls_cipher_info_t *pmVar7; + mbedtls_cipher_info_t *pmVar8; + int iVar9; + mbedtls_cipher_info_t *pmVar10; + uint64_t *puVar11; + int iVar12; + int iVar13; + uint64_t *puVar14; + uint uVar15; + uint *puVar16; + uint uVar17; + size_t sStack36; + size_t olen; + uchar h [16]; + + cipher_info = mbedtls_cipher_info_from_values(cipher,keybits,MBEDTLS_MODE_ECB); + if (cipher_info == (mbedtls_cipher_info_t *)0x0) { + iVar4 = -0x14; + } + else { + iVar4 = -0x14; + if (cipher_info->block_size == 0x10) { + mbedtls_cipher_free((mbedtls_cipher_context_t *)ctx); + iVar4 = mbedtls_cipher_setup((mbedtls_cipher_context_t *)ctx,cipher_info); + if ((iVar4 == 0) && + (iVar4 = mbedtls_cipher_setkey((mbedtls_cipher_context_t *)ctx,key,keybits,MBEDTLS_ENCRYPT) + , iVar4 == 0)) { + sStack36 = 0; + memset(&olen,0,0x10); + iVar4 = mbedtls_cipher_update + ((mbedtls_cipher_context_t *)ctx,(uchar *)&olen,0x10,(uchar *)&olen, + &sStack36); + if (iVar4 == 0) { + cipher_info = (mbedtls_cipher_info_t *) + ((uint)h[0] << 0x18 | (uint)h[1] << 0x10 | (uint)h[3] | (uint)h[2] << 8); + pmVar10 = (mbedtls_cipher_info_t *) + ((uint)(byte)olen << 0x18 | (uint)olen._1_1_ << 0x10 | (uint)olen._3_1_ | + (uint)olen._2_1_ << 8); + pmVar8 = (mbedtls_cipher_info_t *) + ((uint)h[4] << 0x18 | (uint)h[5] << 0x10 | (uint)h[7] | (uint)h[6] << 8); + *(undefined4 *)((int)ctx->HH + 4) = 0; + *(undefined4 *)((int)ctx->HL + 4) = 0; + *(mbedtls_cipher_info_t **)((int)ctx->HL + 0x44) = pmVar8; + *(mbedtls_cipher_info_t **)(ctx->HH + 8) = cipher_info; + *(mbedtls_cipher_info_t **)((int)ctx->HH + 0x44) = pmVar10; + pmVar7 = (mbedtls_cipher_info_t *) + ((uint)h[8] << 0x18 | (uint)h[9] << 0x10 | (uint)h[11] | (uint)h[10] << 8); + *(undefined4 *)ctx->HH = 0; + *(undefined4 *)ctx->HL = 0; + *(mbedtls_cipher_info_t **)(ctx->HL + 8) = pmVar7; + iVar12 = 3; + iVar13 = 4; + do { + uVar5 = (uint)pmVar7 & 1; + uVar15 = (int)pmVar8 << 0x1f; + pmVar8 = (mbedtls_cipher_info_t *)((int)cipher_info << 0x1f | (uint)pmVar8 >> 1); + uVar2 = (int)pmVar10 << 0x1f; + pmVar7 = (mbedtls_cipher_info_t *)(uVar15 | (uint)pmVar7 >> 1); + pmVar10 = (mbedtls_cipher_info_t *)((uint)pmVar10 >> 1 ^ uVar5 * -0x1f000000); + ppmVar6 = &(ctx->cipher_ctx).cipher_info + iVar13 * 2; + cipher_info = (mbedtls_cipher_info_t *)(uVar2 | (uint)cipher_info >> 1); + ppmVar6[0x10] = pmVar7; + ppmVar6[0x11] = pmVar8; + ppmVar6[0x30] = cipher_info; + ppmVar6[0x31] = pmVar10; + iVar12 = iVar12 + -1; + iVar13 = iVar13 >> 1; + } while (iVar12 != 0); + iVar13 = 3; + iVar12 = 2; + do { + puVar14 = ctx->HL + iVar12; + puVar3 = ctx->HH + iVar12; + uVar15 = *(uint *)puVar3; + uVar5 = *(uint *)((int)puVar3 + 4); + uVar2 = *(uint *)puVar14; + uVar17 = *(uint *)((int)puVar14 + 4); + iVar9 = 8; + puVar1 = ctx->HL; + do { + puVar11 = puVar1 + 1; + *(uint *)((int)puVar3 + iVar9) = *(uint *)(puVar11 + 0x10) ^ uVar15; + ((uint *)((int)puVar3 + iVar9))[1] = *(uint *)((int)puVar1 + 0x8c) ^ uVar5; + puVar16 = (uint *)((int)puVar14 + iVar9); + iVar9 = iVar9 + 8; + *puVar16 = *(uint *)puVar11 ^ uVar2; + puVar16[1] = *(uint *)((int)puVar1 + 0xc) ^ uVar17; + puVar1 = puVar11; + } while (iVar12 * 8 != iVar9); + iVar13 = iVar13 + -1; + iVar12 = iVar12 << 1; + } while (iVar13 != 0); + } + } + } + } + return iVar4; +} + + + +int mbedtls_gcm_starts(mbedtls_gcm_context *ctx,int mode,uchar *iv,size_t iv_len,uchar *add, + size_t add_len) + +{ + byte bVar1; + uint uVar2; + int iVar3; + byte *pbVar4; + byte *pbVar5; + byte *x; + size_t *psVar6; + uint uVar7; + byte *x_00; + size_t sStack68; + size_t olen; + uchar work_buf [16]; + + x = ctx->y; + sStack68 = 0; + x_00 = ctx->buf; + memset(x,0,0x10); + memset(x_00,0,0x10); + *(undefined4 *)&ctx->len = 0; + *(undefined4 *)&ctx->add_len = 0; + ctx->mode = mode; + *(undefined4 *)((int)&ctx->len + 4) = 0; + *(undefined4 *)((int)&ctx->add_len + 4) = 0; + if (iv_len == 0xc) { + memcpy(x,iv,0xc); + ctx->y[0xf] = '\x01'; + } + else { + memset(&olen,0,0x10); + while (iv_len != 0) { + uVar2 = iv_len; + if (0x10 < iv_len) { + uVar2 = 0x10; + } + uVar7 = 0; + pbVar4 = x; + do { + pbVar5 = iv + uVar7; + uVar7 = uVar7 + 1; + *pbVar4 = *pbVar5 ^ *pbVar4; + pbVar4 = pbVar4 + 1; + } while (uVar2 != uVar7); + gcm_mult(ctx,x,x); + iv_len = iv_len - uVar2; + iv = iv + uVar2; + } + psVar6 = &olen; + pbVar4 = x; + do { + bVar1 = *(byte *)psVar6; + pbVar5 = pbVar4 + 1; + psVar6 = (size_t *)((int)psVar6 + 1); + *pbVar4 = *pbVar4 ^ bVar1; + pbVar4 = pbVar5; + } while (x_00 != pbVar5); + gcm_mult(ctx,x,x); + } + iVar3 = mbedtls_cipher_update((mbedtls_cipher_context_t *)ctx,x,0x10,ctx->base_ectr,&sStack68); + if (iVar3 == 0) { + *(size_t *)&ctx->add_len = add_len; + *(undefined4 *)((int)&ctx->add_len + 4) = 0; + while (add_len != 0) { + uVar2 = add_len; + if (0x10 < add_len) { + uVar2 = 0x10; + } + uVar7 = 0; + x = x_00; + do { + pbVar4 = add + uVar7; + uVar7 = uVar7 + 1; + *x = *pbVar4 ^ *x; + x = x + 1; + } while (uVar2 != uVar7); + gcm_mult(ctx,x_00,x_00); + add_len = add_len - uVar2; + add = add + uVar2; + } + } + return iVar3; +} + + + +int mbedtls_gcm_update(mbedtls_gcm_context *ctx,size_t length,uchar *input,uchar *output) + +{ + uchar uVar1; + int iVar2; + byte bVar3; + uint uVar4; + uint uVar5; + uchar *puVar6; + uint uVar7; + byte *x; + byte *pbVar8; + size_t sStack68; + size_t olen; + uchar ectr [16]; + + sStack68 = 0; + if ((output <= input) || (iVar2 = -0x14, length <= output + -(int)input)) { + uVar4 = *(uint *)((int)&ctx->len + 4); + uVar5 = length + *(uint *)&ctx->len; + uVar7 = (uVar5 < length) + uVar4; + if (((uVar7 < uVar4) || (((uVar4 == uVar7 && (uVar5 < *(uint *)&ctx->len)) || (0xf < uVar7)))) + || ((uVar7 == 0xf && (0xffffffe0 < uVar5)))) { + iVar2 = -0x14; + } + else { + *(uint *)&ctx->len = uVar5; + *(uint *)((int)&ctx->len + 4) = uVar7; + while (length != 0) { + uVar4 = length; + if (0x10 < length) { + uVar4 = 0x10; + } + puVar6 = ctx->y + 0xf; + do { + uVar1 = *puVar6; + *puVar6 = uVar1 + '\x01'; + if ((uchar)(uVar1 + '\x01') != '\0') break; + puVar6 = puVar6 + -1; + } while (puVar6 != ctx->y + 0xb); + iVar2 = mbedtls_cipher_update + ((mbedtls_cipher_context_t *)ctx,ctx->y,0x10,(uchar *)&olen,&sStack68); + if (iVar2 != 0) { + return iVar2; + } + x = ctx->buf; + uVar5 = 0; + pbVar8 = x; + do { + if (ctx->mode == 0) { + *pbVar8 = input[uVar5] ^ *pbVar8; + } + bVar3 = *(byte *)((int)&olen + uVar5) ^ input[uVar5]; + output[uVar5] = bVar3; + if (ctx->mode == 1) { + *pbVar8 = bVar3 ^ *pbVar8; + } + uVar5 = uVar5 + 1; + pbVar8 = pbVar8 + 1; + } while (uVar4 != uVar5); + gcm_mult(ctx,x,x); + length = length - uVar4; + input = input + uVar4; + output = output + uVar4; + } + iVar2 = 0; + } + } + return iVar2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int mbedtls_gcm_finish(mbedtls_gcm_context *ctx,uchar *tag,size_t tag_len) + +{ + byte bVar1; + uint uVar2; + uint uVar3; + int *x; + int iVar4; + byte *pbVar5; + int *piVar6; + int *piVar7; + byte *pbVar8; + uint uVar9; + uint uVar10; + uint uVar11; + uint uVar12; + byte local_40 [4]; + uchar work_buf [16]; + + pbVar8 = local_40; + uVar11 = *(uint *)&ctx->len; + uVar12 = *(uint *)&ctx->add_len; + uVar2 = *(int *)((int)&ctx->len + 4) << 3; + uVar3 = uVar2 | uVar11 >> 0x1d; + uVar9 = *(int *)((int)&ctx->add_len + 4) << 3; + uVar10 = uVar12 >> 0x1d | uVar9; + if (tag_len - 4 < 0xd) { + memcpy(tag,ctx->base_ectr,tag_len); + if (((uVar11 | uVar12) << 3 | uVar3 | uVar10) != 0) { + memset(local_40,0,0x10); + local_40[0] = (byte)(uVar9 >> 0x18); + local_40[1] = (char)(uVar9 >> 0x10); + local_40[2] = (char)(uVar9 >> 8); + work_buf[0] = (uchar)((uVar12 << 3) >> 0x18); + work_buf[1] = (uchar)((uVar12 << 3) >> 0x10); + work_buf[4] = (uchar)(uVar2 >> 0x18); + work_buf[5] = (uchar)(uVar2 >> 0x10); + work_buf[6] = (uchar)(uVar2 >> 8); + work_buf[8] = (uchar)((uVar11 << 3) >> 0x18); + work_buf[7] = (uchar)uVar3; + x = (int *)ctx->buf; + work_buf[9] = (uchar)((uVar11 << 3) >> 0x10); + local_40[3] = (char)uVar10; + work_buf._2_2_ = (ushort)(uVar12 << 0xb) | (ushort)((uVar12 << 0x13) >> 0x18); + work_buf._10_2_ = (ushort)(uVar11 << 0xb) | (ushort)((uVar11 << 0x13) >> 0x18); + piVar6 = x; + do { + bVar1 = *pbVar8; + piVar7 = (int *)((int)piVar6 + 1); + pbVar8 = pbVar8 + 1; + *(byte *)piVar6 = *(byte *)piVar6 ^ bVar1; + piVar6 = piVar7; + } while (piVar7 != &ctx->mode); + gcm_mult(ctx,(uchar *)x,(uchar *)x); + pbVar8 = tag; + do { + bVar1 = *(byte *)x; + pbVar5 = pbVar8 + 1; + x = (int *)((int)x + 1); + *pbVar8 = *pbVar8 ^ bVar1; + pbVar8 = pbVar5; + } while (tag + tag_len != pbVar5); + } + iVar4 = 0; + } + else { + iVar4 = -0x14; + } + return iVar4; +} + + + +int mbedtls_gcm_crypt_and_tag + (mbedtls_gcm_context *ctx,int mode,size_t length,uchar *iv,size_t iv_len,uchar *add, + size_t add_len,uchar *input,uchar *output,size_t tag_len,uchar *tag) + +{ + int iVar1; + uchar *in_stack_00000000; + size_t in_stack_00000004; + uchar *in_stack_00000008; + + iVar1 = mbedtls_gcm_starts(ctx,mode,iv,iv_len,add,add_len); + if ((iVar1 == 0) && (iVar1 = mbedtls_gcm_update(ctx,length,input,in_stack_00000000), iVar1 == 0)) + { + iVar1 = mbedtls_gcm_finish(ctx,in_stack_00000008,in_stack_00000004); + return iVar1; + } + return iVar1; +} + + + +int mbedtls_gcm_auth_decrypt + (mbedtls_gcm_context *ctx,size_t length,uchar *iv,size_t iv_len,uchar *add, + size_t add_len,uchar *tag,size_t tag_len,uchar *input,uchar *output) + +{ + undefined *puVar1; + uint uVar2; + byte *pbVar3; + byte *pbVar4; + size_t sVar5; + uchar *in_fa2; + uchar *in_stack_00000000; + undefined *in_stack_00000004; + byte local_30 [4]; + uchar check_tag [16]; + + uVar2 = mbedtls_gcm_crypt_and_tag + (ctx,0,length,iv,iv_len,add,add_len,in_stack_00000000,input,(size_t)output, + in_fa2); + sVar5 = 0; + if (uVar2 == 0) { + while (sVar5 != tag_len) { + pbVar4 = tag + sVar5; + pbVar3 = local_30 + sVar5; + sVar5 = sVar5 + 1; + uVar2 = uVar2 | *pbVar4 ^ *pbVar3; + } + puVar1 = in_stack_00000004 + length; + if (uVar2 != 0) { + while (in_stack_00000004 != puVar1) { + *in_stack_00000004 = 0; + in_stack_00000004 = in_stack_00000004 + 1; + } + uVar2 = 0xffffffee; + } + } + return uVar2; +} + + + +void mbedtls_gcm_free(mbedtls_gcm_context *ctx) + +{ + mbedtls_gcm_context *pmVar1; + + mbedtls_cipher_free((mbedtls_cipher_context_t *)ctx); + pmVar1 = ctx + 1; + while (ctx != pmVar1) { + *(undefined *)&(ctx->cipher_ctx).cipher_info = 0; + ctx = (mbedtls_gcm_context *)((int)&(ctx->cipher_ctx).cipher_info + 1); + } + return; +} + + + +mbedtls_md_info_t * mbedtls_md_info_from_type(mbedtls_md_type_t md_type) + +{ + uint uVar1; + + uVar1 = (uint)md_type - 3 & 0xff; + if (uVar1 < 4) { + return *(mbedtls_md_info_t **)(CSWTCH_2 + uVar1 * 4); + } + return (mbedtls_md_info_t *)0x0; +} + + + +void mbedtls_md_init(mbedtls_md_context_t *ctx) + +{ + memset(ctx,0,0xc); + return; +} + + + +void mbedtls_md_free(mbedtls_md_context_t *ctx) + +{ + undefined *puVar1; + mbedtls_md_context_t *pmVar2; + undefined *puVar3; + + if (ctx != (mbedtls_md_context_t *)0x0) { + if (ctx->md_info != (mbedtls_md_info_t *)0x0) { + if (ctx->md_ctx != (void *)0x0) { + (*ctx->md_info->ctx_free_func)(ctx->md_ctx); + } + puVar3 = (undefined *)ctx->hmac_ctx; + if (puVar3 != (undefined *)0x0) { + puVar1 = puVar3 + ctx->md_info->block_size * 2; + while (puVar3 != puVar1) { + *puVar3 = 0; + puVar3 = puVar3 + 1; + } + vPortFree(ctx->hmac_ctx); + } + pmVar2 = ctx + 1; + while (ctx != pmVar2) { + *(undefined *)&ctx->md_info = 0; + ctx = (mbedtls_md_context_t *)((int)&ctx->md_info + 1); + } + } + return; + } + return; +} + + + +int mbedtls_md_setup(mbedtls_md_context_t *ctx,mbedtls_md_info_t *md_info,int hmac) + +{ + void *pvVar1; + int iVar2; + + if ((md_info == (mbedtls_md_info_t *)0x0) || (ctx == (mbedtls_md_context_t *)0x0)) { + return -0x5100; + } + pvVar1 = (*md_info->ctx_alloc_func)(md_info->ctx_alloc_func); + ctx->md_ctx = pvVar1; + if (pvVar1 == (void *)0x0) { +LAB_230965c8: + iVar2 = -0x5180; + } + else { + if (hmac != 0) { + pvVar1 = mycalloc(2,md_info->block_size); + ctx->hmac_ctx = pvVar1; + if (pvVar1 == (void *)0x0) { + (*md_info->ctx_free_func)(ctx->md_ctx); + goto LAB_230965c8; + } + } + ctx->md_info = md_info; + iVar2 = 0; + } + return iVar2; +} + + + +int mbedtls_md_starts(mbedtls_md_context_t *ctx) + +{ + if ((ctx != (mbedtls_md_context_t *)0x0) && (ctx->md_info != (mbedtls_md_info_t *)0x0)) { + (*ctx->md_info->starts_func)(ctx->md_ctx); + return 0; + } + return -0x5100; +} + + + +int mbedtls_md_update(mbedtls_md_context_t *ctx,uchar *input,size_t ilen) + +{ + if ((ctx != (mbedtls_md_context_t *)0x0) && (ctx->md_info != (mbedtls_md_info_t *)0x0)) { + (*ctx->md_info->update_func)(ctx->md_ctx,input,ilen); + return 0; + } + return -0x5100; +} + + + +int mbedtls_md_finish(mbedtls_md_context_t *ctx,uchar *output) + +{ + if ((ctx != (mbedtls_md_context_t *)0x0) && (ctx->md_info != (mbedtls_md_info_t *)0x0)) { + (*ctx->md_info->finish_func)(ctx->md_ctx,output); + return 0; + } + return -0x5100; +} + + + +int mbedtls_md(mbedtls_md_info_t *md_info,uchar *input,size_t ilen,uchar *output) + +{ + if (md_info != (mbedtls_md_info_t *)0x0) { + (*md_info->digest_func)(input,ilen,output); + return 0; + } + return -0x5100; +} + + + +int mbedtls_md_hmac_starts(mbedtls_md_context_t *ctx,uchar *key,size_t keylen) + +{ + int iVar1; + size_t __n; + byte *pbVar2; + byte *pbVar3; + mbedtls_md_info_t *pmVar4; + size_t sVar5; + uchar *puVar6; + uchar *__s; + uchar *__s_00; + uchar local_40 [4]; + uchar sum [32]; + + if (ctx == (mbedtls_md_context_t *)0x0) { + return -0x5100; + } + puVar6 = local_40; + pmVar4 = ctx->md_info; + if ((pmVar4 == (mbedtls_md_info_t *)0x0) || (ctx->hmac_ctx == (void *)0x0)) { + iVar1 = -0x5100; + } + else { + if ((uint)pmVar4->block_size < keylen) { + (*pmVar4->starts_func)(ctx->md_ctx); + (*ctx->md_info->update_func)(ctx->md_ctx,key,keylen); + (*ctx->md_info->finish_func)(ctx->md_ctx,local_40); + keylen = ctx->md_info->size; + key = local_40; + } + __s = (uchar *)ctx->hmac_ctx; + __n = ctx->md_info->block_size; + __s_00 = __s + __n; + memset(__s,0x36,__n); + memset(__s_00,0x5c,ctx->md_info->block_size); + sVar5 = 0; + while (keylen != sVar5) { + pbVar2 = key + sVar5; + __s[sVar5] = __s[sVar5] ^ *pbVar2; + pbVar3 = __s_00 + sVar5; + sVar5 = sVar5 + 1; + *pbVar3 = *pbVar3 ^ *pbVar2; + } + do { + *puVar6 = '\0'; + puVar6 = puVar6 + 1; + } while (puVar6 != sum + 0x1c); + (*ctx->md_info->starts_func)(ctx->md_ctx); + (*ctx->md_info->update_func)(ctx->md_ctx,__s,ctx->md_info->block_size); + iVar1 = 0; + } + return iVar1; +} + + + +int mbedtls_md_hmac_update(mbedtls_md_context_t *ctx,uchar *input,size_t ilen) + +{ + if (((ctx != (mbedtls_md_context_t *)0x0) && (ctx->md_info != (mbedtls_md_info_t *)0x0)) && + (ctx->hmac_ctx != (void *)0x0)) { + (*ctx->md_info->update_func)(ctx->md_ctx,input,ilen); + return 0; + } + return -0x5100; +} + + + +// WARNING: Variable defined which should be unmapped: tmp + +int mbedtls_md_hmac_finish(mbedtls_md_context_t *ctx,uchar *output) + +{ + int iVar1; + mbedtls_md_info_t *pmVar2; + void *pvVar3; + uchar auStack48 [4]; + uchar tmp [32]; + + if (((ctx != (mbedtls_md_context_t *)0x0) && + (pmVar2 = ctx->md_info, pmVar2 != (mbedtls_md_info_t *)0x0)) && + (pvVar3 = ctx->hmac_ctx, pvVar3 != (void *)0x0)) { + iVar1 = pmVar2->block_size; + (*pmVar2->finish_func)(ctx->md_ctx,auStack48); + (*ctx->md_info->starts_func)(ctx->md_ctx); + (*ctx->md_info->update_func) + (ctx->md_ctx,(uchar *)(iVar1 + (int)pvVar3),ctx->md_info->block_size); + (*ctx->md_info->update_func)(ctx->md_ctx,auStack48,ctx->md_info->size); + (*ctx->md_info->finish_func)(ctx->md_ctx,output); + return 0; + } + return -0x5100; +} + + + +int mbedtls_md_hmac_reset(mbedtls_md_context_t *ctx) + +{ + int iVar1; + uchar *puVar2; + + if ((ctx != (mbedtls_md_context_t *)0x0) && (ctx->md_info != (mbedtls_md_info_t *)0x0)) { + puVar2 = (uchar *)ctx->hmac_ctx; + if (puVar2 == (uchar *)0x0) { + iVar1 = -0x5100; + } + else { + (*ctx->md_info->starts_func)(ctx->md_ctx); + (*ctx->md_info->update_func)(ctx->md_ctx,puVar2,ctx->md_info->block_size); + iVar1 = 0; + } + return iVar1; + } + return -0x5100; +} + + + +int mbedtls_md_process(mbedtls_md_context_t *ctx,uchar *data) + +{ + if ((ctx != (mbedtls_md_context_t *)0x0) && (ctx->md_info != (mbedtls_md_info_t *)0x0)) { + (*ctx->md_info->process_func)(ctx->md_ctx,data); + return 0; + } + return -0x5100; +} + + + +uchar mbedtls_md_get_size(mbedtls_md_info_t *md_info) + +{ + if (md_info != (mbedtls_md_info_t *)0x0) { + return *(uchar *)&md_info->size; + } + return '\0'; +} + + + +void md5_process_wrap(mbedtls_md5_context *ctx,uchar *data) + +{ + int iVar1; + int iVar2; + int iVar3; + int iVar4; + int iVar5; + int iVar6; + int iVar7; + int iVar8; + int iVar9; + int iVar10; + int iVar11; + int iVar12; + int iVar13; + int iVar14; + int iVar15; + int iVar16; + uint uVar17; + uint uVar18; + uint uVar19; + uint uVar20; + uint uVar21; + uint uVar22; + uint uVar23; + uint uVar24; + uint uVar25; + + iVar1 = *(int *)data; + iVar2 = *(int *)(data + 4); + iVar3 = *(int *)(data + 0x10); + iVar4 = *(int *)(data + 8); + iVar5 = *(int *)(data + 0xc); + iVar6 = *(int *)(data + 0x14); + iVar7 = *(int *)(data + 0x18); + iVar8 = *(int *)(data + 0x24); + iVar9 = *(int *)(data + 0x1c); + iVar10 = *(int *)(data + 0x20); + iVar11 = *(int *)(data + 0x2c); + iVar12 = *(int *)(data + 0x28); + iVar13 = *(int *)(data + 0x30); + uVar19 = ctx->state[3]; + iVar14 = *(int *)(data + 0x34); + iVar15 = *(int *)(data + 0x38); + iVar16 = *(int *)(data + 0x3c); + uVar17 = ctx->state[2]; + uVar18 = ctx->state[1]; + uVar20 = ((uVar17 ^ uVar19) & uVar18 ^ uVar19) + ctx->state[0] + 0xd76aa478 + iVar1; + uVar21 = (uVar20 >> 0x19 | uVar20 * 0x80) + uVar18; + uVar20 = ((uVar18 ^ uVar17) & uVar21 ^ uVar17) + uVar19 + 0xe8c7b756 + iVar2; + uVar23 = (uVar20 >> 0x14 | uVar20 * 0x1000) + uVar21; + uVar20 = ((uVar18 ^ uVar21) & uVar23 ^ uVar18) + uVar17 + 0x242070db + iVar4; + uVar22 = (uVar20 * 0x20000 | uVar20 >> 0xf) + uVar23; + uVar20 = ((uVar21 ^ uVar23) & uVar22 ^ uVar21) + uVar18 + 0xc1bdceee + iVar5; + uVar20 = (uVar20 * 0x400000 | uVar20 >> 10) + uVar22; + uVar21 = ((uVar23 ^ uVar22) & uVar20 ^ uVar23) + iVar3 + -0xa83f051 + uVar21; + uVar21 = (uVar21 >> 0x19 | uVar21 * 0x80) + uVar20; + uVar23 = ((uVar22 ^ uVar20) & uVar21 ^ uVar22) + iVar6 + 0x4787c62a + uVar23; + uVar23 = (uVar23 >> 0x14 | uVar23 * 0x1000) + uVar21; + uVar22 = ((uVar20 ^ uVar21) & uVar23 ^ uVar20) + iVar7 + -0x57cfb9ed + uVar22; + uVar22 = (uVar22 * 0x20000 | uVar22 >> 0xf) + uVar23; + uVar20 = ((uVar21 ^ uVar23) & uVar22 ^ uVar21) + iVar9 + -0x2b96aff + uVar20; + uVar20 = (uVar20 * 0x400000 | uVar20 >> 10) + uVar22; + uVar21 = ((uVar23 ^ uVar22) & uVar20 ^ uVar23) + iVar10 + 0x698098d8 + uVar21; + uVar21 = (uVar21 >> 0x19 | uVar21 * 0x80) + uVar20; + uVar23 = ((uVar22 ^ uVar20) & uVar21 ^ uVar22) + iVar8 + -0x74bb0851 + uVar23; + uVar23 = (uVar23 >> 0x14 | uVar23 * 0x1000) + uVar21; + uVar22 = ((uVar20 ^ uVar21) & uVar23 ^ uVar20) + iVar12 + -0xa44f + uVar22; + uVar22 = (uVar22 * 0x20000 | uVar22 >> 0xf) + uVar23; + uVar20 = ((uVar21 ^ uVar23) & uVar22 ^ uVar21) + iVar11 + -0x76a32842 + uVar20; + uVar20 = (uVar20 * 0x400000 | uVar20 >> 10) + uVar22; + uVar21 = ((uVar23 ^ uVar22) & uVar20 ^ uVar23) + iVar13 + 0x6b901122 + uVar21; + uVar21 = (uVar21 >> 0x19 | uVar21 * 0x80) + uVar20; + uVar23 = ((uVar22 ^ uVar20) & uVar21 ^ uVar22) + iVar14 + -0x2678e6d + uVar23; + uVar23 = (uVar23 >> 0x14 | uVar23 * 0x1000) + uVar21; + uVar22 = ((uVar20 ^ uVar21) & uVar23 ^ uVar20) + iVar15 + -0x5986bc72 + uVar22; + uVar22 = (uVar22 * 0x20000 | uVar22 >> 0xf) + uVar23; + uVar20 = ((uVar21 ^ uVar23) & uVar22 ^ uVar21) + iVar16 + 0x49b40821 + uVar20; + uVar20 = (uVar20 * 0x400000 | uVar20 >> 10) + uVar22; + uVar21 = ((uVar22 ^ uVar20) & uVar23 ^ uVar22) + iVar2 + -0x9e1da9e + uVar21; + uVar21 = (uVar21 >> 0x1b | uVar21 * 0x20) + uVar20; + uVar23 = ((uVar20 ^ uVar21) & uVar22 ^ uVar20) + iVar7 + -0x3fbf4cc0 + uVar23; + uVar23 = (uVar23 >> 0x17 | uVar23 * 0x200) + uVar21; + uVar22 = ((uVar21 ^ uVar23) & uVar20 ^ uVar21) + iVar11 + 0x265e5a51 + uVar22; + uVar22 = (uVar22 >> 0x12 | uVar22 * 0x4000) + uVar23; + uVar20 = ((uVar23 ^ uVar22) & uVar21 ^ uVar23) + iVar1 + -0x16493856 + uVar20; + uVar20 = (uVar20 * 0x100000 | uVar20 >> 0xc) + uVar22; + uVar21 = ((uVar22 ^ uVar20) & uVar23 ^ uVar22) + iVar6 + -0x29d0efa3 + uVar21; + uVar21 = (uVar21 >> 0x1b | uVar21 * 0x20) + uVar20; + uVar23 = ((uVar20 ^ uVar21) & uVar22 ^ uVar20) + iVar12 + 0x2441453 + uVar23; + uVar23 = (uVar23 >> 0x17 | uVar23 * 0x200) + uVar21; + uVar22 = ((uVar21 ^ uVar23) & uVar20 ^ uVar21) + iVar16 + -0x275e197f + uVar22; + uVar22 = (uVar22 >> 0x12 | uVar22 * 0x4000) + uVar23; + uVar20 = ((uVar23 ^ uVar22) & uVar21 ^ uVar23) + iVar3 + -0x182c0438 + uVar20; + uVar20 = (uVar20 * 0x100000 | uVar20 >> 0xc) + uVar22; + uVar21 = ((uVar22 ^ uVar20) & uVar23 ^ uVar22) + iVar8 + 0x21e1cde6 + uVar21; + uVar21 = (uVar21 >> 0x1b | uVar21 * 0x20) + uVar20; + uVar23 = ((uVar20 ^ uVar21) & uVar22 ^ uVar20) + iVar15 + -0x3cc8f82a + uVar23; + uVar23 = (uVar23 >> 0x17 | uVar23 * 0x200) + uVar21; + uVar22 = ((uVar21 ^ uVar23) & uVar20 ^ uVar21) + iVar5 + -0xb2af279 + uVar22; + uVar22 = (uVar22 >> 0x12 | uVar22 * 0x4000) + uVar23; + uVar20 = ((uVar23 ^ uVar22) & uVar21 ^ uVar23) + iVar10 + 0x455a14ed + uVar20; + uVar20 = (uVar20 * 0x100000 | uVar20 >> 0xc) + uVar22; + uVar21 = ((uVar22 ^ uVar20) & uVar23 ^ uVar22) + iVar14 + -0x561c16fb + uVar21; + uVar21 = (uVar21 >> 0x1b | uVar21 * 0x20) + uVar20; + uVar23 = ((uVar20 ^ uVar21) & uVar22 ^ uVar20) + iVar4 + -0x3105c08 + uVar23; + uVar24 = (uVar23 >> 0x17 | uVar23 * 0x200) + uVar21; + uVar22 = ((uVar21 ^ uVar24) & uVar20 ^ uVar21) + iVar9 + 0x676f02d9 + uVar22; + uVar23 = (uVar22 >> 0x12 | uVar22 * 0x4000) + uVar24; + uVar20 = ((uVar24 ^ uVar23) & uVar21 ^ uVar24) + iVar13 + -0x72d5b376 + uVar20; + uVar20 = (uVar20 * 0x100000 | uVar20 >> 0xc) + uVar23; + uVar21 = (uVar24 ^ uVar23 ^ uVar20) + iVar6 + -0x5c6be + uVar21; + uVar21 = (uVar21 >> 0x1c | uVar21 * 0x10) + uVar20; + uVar22 = (uVar23 ^ uVar20 ^ uVar21) + uVar24 + iVar10 + -0x788e097f; + uVar22 = (uVar22 >> 0x15 | uVar22 * 0x800) + uVar21; + uVar23 = (uVar20 ^ uVar21 ^ uVar22) + uVar23 + iVar11 + 0x6d9d6122; + uVar24 = (uVar23 >> 0x10 | uVar23 * 0x10000) + uVar22; + uVar20 = (uVar21 ^ uVar22 ^ uVar24) + uVar20 + iVar15 + -0x21ac7f4; + uVar23 = (uVar20 * 0x800000 | uVar20 >> 9) + uVar24; + uVar20 = (uVar22 ^ uVar24 ^ uVar23) + iVar2 + -0x5b4115bc + uVar21; + uVar21 = (uVar20 >> 0x1c | uVar20 * 0x10) + uVar23; + uVar20 = (uVar24 ^ uVar23 ^ uVar21) + uVar22 + iVar3 + 0x4bdecfa9; + uVar20 = (uVar20 >> 0x15 | uVar20 * 0x800) + uVar21; + uVar22 = (uVar23 ^ uVar21 ^ uVar20) + iVar9 + -0x944b4a0 + uVar24; + uVar24 = (uVar22 >> 0x10 | uVar22 * 0x10000) + uVar20; + uVar22 = (uVar21 ^ uVar20 ^ uVar24) + uVar23 + iVar12 + -0x41404390; + uVar22 = (uVar22 * 0x800000 | uVar22 >> 9) + uVar24; + uVar21 = (uVar20 ^ uVar24 ^ uVar22) + uVar21 + iVar14 + 0x289b7ec6; + uVar23 = (uVar21 >> 0x1c | uVar21 * 0x10) + uVar22; + uVar20 = (uVar24 ^ uVar22 ^ uVar23) + iVar1 + -0x155ed806 + uVar20; + uVar20 = (uVar20 >> 0x15 | uVar20 * 0x800) + uVar23; + uVar21 = (uVar22 ^ uVar23 ^ uVar20) + iVar5 + -0x2b10cf7b + uVar24; + uVar24 = (uVar21 >> 0x10 | uVar21 * 0x10000) + uVar20; + uVar21 = (uVar23 ^ uVar20 ^ uVar24) + uVar22 + iVar7 + 0x4881d05; + uVar21 = (uVar21 * 0x800000 | uVar21 >> 9) + uVar24; + uVar22 = (uVar20 ^ uVar24 ^ uVar21) + iVar8 + -0x262b2fc7 + uVar23; + uVar23 = (uVar22 >> 0x1c | uVar22 * 0x10) + uVar21; + uVar20 = (uVar24 ^ uVar21 ^ uVar23) + uVar20 + iVar13 + -0x1924661b; + uVar22 = (uVar20 >> 0x15 | uVar20 * 0x800) + uVar23; + uVar20 = (uVar21 ^ uVar23 ^ uVar22) + uVar24 + iVar16 + 0x1fa27cf8; + uVar20 = (uVar20 >> 0x10 | uVar20 * 0x10000) + uVar22; + uVar21 = (uVar23 ^ uVar22 ^ uVar20) + iVar4 + -0x3b53a99b + uVar21; + uVar21 = (uVar21 * 0x800000 | uVar21 >> 9) + uVar20; + uVar23 = ((~uVar22 | uVar21) ^ uVar20) + uVar23 + iVar1 + -0xbd6ddbc; + uVar24 = (uVar23 >> 0x1a | uVar23 * 0x40) + uVar21; + uVar22 = ((~uVar20 | uVar24) ^ uVar21) + uVar22 + iVar9 + 0x432aff97; + uVar23 = (uVar22 >> 0x16 | uVar22 * 0x400) + uVar24; + uVar20 = ((~uVar21 | uVar23) ^ uVar24) + iVar15 + -0x546bdc59 + uVar20; + uVar20 = (uVar20 >> 0x11 | uVar20 * 0x8000) + uVar23; + uVar21 = ((~uVar24 | uVar20) ^ uVar23) + iVar6 + -0x36c5fc7 + uVar21; + uVar22 = (uVar21 * 0x200000 | uVar21 >> 0xb) + uVar20; + uVar21 = ((~uVar23 | uVar22) ^ uVar20) + iVar13 + 0x655b59c3 + uVar24; + uVar24 = (uVar21 >> 0x1a | uVar21 * 0x40) + uVar22; + uVar21 = ((~uVar20 | uVar24) ^ uVar22) + uVar23 + iVar5 + -0x70f3336e; + uVar21 = (uVar21 >> 0x16 | uVar21 * 0x400) + uVar24; + uVar20 = ((~uVar22 | uVar21) ^ uVar24) + iVar12 + -0x100b83 + uVar20; + uVar20 = (uVar20 >> 0x11 | uVar20 * 0x8000) + uVar21; + uVar22 = ((~uVar24 | uVar20) ^ uVar21) + iVar2 + -0x7a7ba22f + uVar22; + uVar22 = (uVar22 * 0x200000 | uVar22 >> 0xb) + uVar20; + uVar23 = ((~uVar21 | uVar22) ^ uVar20) + iVar10 + 0x6fa87e4f + uVar24; + uVar25 = (uVar23 >> 0x1a | uVar23 * 0x40) + uVar22; + uVar21 = ((~uVar20 | uVar25) ^ uVar22) + uVar21 + iVar16 + -0x1d31920; + uVar24 = (uVar21 >> 0x16 | uVar21 * 0x400) + uVar25; + uVar20 = ((~uVar22 | uVar24) ^ uVar25) + iVar7 + -0x5cfebcec + uVar20; + uVar20 = (uVar20 >> 0x11 | uVar20 * 0x8000) + uVar24; + uVar21 = ((~uVar25 | uVar20) ^ uVar24) + iVar14 + 0x4e0811a1 + uVar22; + uVar23 = (uVar21 * 0x200000 | uVar21 >> 0xb) + uVar20; + uVar21 = ((~uVar24 | uVar23) ^ uVar20) + uVar25 + iVar3 + -0x8ac817e; + uVar22 = (uVar21 >> 0x1a | uVar21 * 0x40) + uVar23; + uVar21 = ((~uVar20 | uVar22) ^ uVar23) + uVar24 + iVar11 + -0x42c50dcb; + uVar21 = (uVar21 >> 0x16 | uVar21 * 0x400) + uVar22; + uVar20 = ((~uVar23 | uVar21) ^ uVar22) + uVar20 + iVar4 + 0x2ad7d2bb; + uVar20 = (uVar20 >> 0x11 | uVar20 * 0x8000) + uVar21; + uVar23 = ((~uVar22 | uVar20) ^ uVar21) + uVar23 + iVar8 + -0x14792c6f; + ctx->state[0] = ctx->state[0] + uVar22; + ctx->state[1] = uVar18 + uVar20 + (uVar23 >> 0xb | uVar23 * 0x200000); + ctx->state[2] = uVar20 + uVar17; + ctx->state[3] = uVar21 + uVar19; + return; +} + + + +void md5_clone_wrap(mbedtls_md5_context *dst,mbedtls_md5_context *src) + +{ + memcpy(dst,src,0x58); + return; +} + + + +void md5_ctx_free(void *ctx) + +{ + mbedtls_md5_free((mbedtls_md5_context *)ctx); + vPortFree(ctx); + return; +} + + + +void * md5_ctx_alloc(void) + +{ + mbedtls_md5_context *ctx; + + ctx = (mbedtls_md5_context *)mycalloc(1,0x58); + if (ctx != (mbedtls_md5_context *)0x0) { + mbedtls_md5_init(ctx); + } + return ctx; +} + + + +void md5_finish_wrap(mbedtls_md5_context *ctx,uchar *output) + +{ + uint uVar1; + int iVar2; + int iStack24; + uint uStack20; + + uVar1 = ctx->total[0]; + uStack20 = ctx->total[1] << 3 | uVar1 >> 0x1d; + iStack24 = uVar1 << 3; + if ((uVar1 & 0x3f) < 0x38) { + iVar2 = 0x38; + } + else { + iVar2 = 0x78; + } + mbedtls_md5_update(ctx,md5_padding,iVar2 - (uVar1 & 0x3f)); + mbedtls_md5_update(ctx,(uchar *)&iStack24,8); + *output = (uchar)ctx->state[0]; + output[1] = (uchar)(ctx->state[0] >> 8); + output[2] = (uchar)*(undefined2 *)((int)ctx->state + 2); + output[3] = *(uchar *)((int)ctx->state + 3); + output[4] = (uchar)ctx->state[1]; + output[5] = (uchar)(ctx->state[1] >> 8); + output[6] = (uchar)*(undefined2 *)((int)ctx->state + 6); + output[7] = *(uchar *)((int)ctx->state + 7); + output[8] = (uchar)ctx->state[2]; + output[9] = (uchar)(ctx->state[2] >> 8); + output[10] = (uchar)*(undefined2 *)((int)ctx->state + 10); + output[0xb] = *(uchar *)((int)ctx->state + 0xb); + output[0xc] = (uchar)ctx->state[3]; + output[0xd] = (uchar)(ctx->state[3] >> 8); + output[0xe] = (uchar)*(undefined2 *)((int)ctx->state + 0xe); + output[0xf] = *(uchar *)((int)ctx->state + 0xf); + return; +} + + + +void md5_update_wrap(mbedtls_md5_context *ctx,uchar *input,size_t ilen) + +{ + if (ilen != 0) { + mbedtls_md5_update(ctx,input,ilen); + return; + } + return; +} + + + +void md5_starts_wrap(mbedtls_md5_context *ctx) + +{ + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xefcdab89; + ctx->state[2] = 0x98badcfe; + ctx->total[0] = 0; + ctx->total[1] = 0; + ctx->state[3] = 0x10325476; + return; +} + + + +void sha1_process_wrap(mbedtls_sha1_context *ctx,uchar *data) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + uint uVar4; + uint uVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint uVar9; + uint uVar10; + uint uVar11; + uint32_t uVar12; + uint uVar13; + uint uVar14; + uint uVar15; + uint uVar16; + uint uVar17; + uint uVar18; + uint uVar19; + uint uVar20; + uint uVar21; + uint uVar22; + uint uVar23; + uint uVar24; + uint uVar25; + uint uVar26; + uint uVar27; + uint uVar28; + + uVar8 = (uint)*data << 0x18 | (uint)data[1] << 0x10 | (uint)data[3] | (uint)data[2] << 8; + uVar10 = (uint)data[4] << 0x18 | (uint)data[5] << 0x10 | (uint)data[7] | (uint)data[6] << 8; + uVar9 = (uint)data[8] << 0x18 | (uint)data[9] << 0x10 | (uint)data[0xb] | (uint)data[10] << 8; + uVar1 = (uint)data[0xc] << 0x18 | (uint)data[0xd] << 0x10 | (uint)data[0xf] | (uint)data[0xe] << 8 + ; + uVar27 = (uint)data[0x10] << 0x18 | (uint)data[0x11] << 0x10 | (uint)data[0x13] | + (uint)data[0x12] << 8; + uVar25 = (uint)data[0x14] << 0x18 | (uint)data[0x15] << 0x10 | (uint)data[0x17] | + (uint)data[0x16] << 8; + uVar14 = (uint)data[0x18] << 0x18 | (uint)data[0x19] << 0x10 | (uint)data[0x1b] | + (uint)data[0x1a] << 8; + uVar20 = (uint)data[0x1c] << 0x18 | (uint)data[0x1d] << 0x10 | (uint)data[0x1f] | + (uint)data[0x1e] << 8; + uVar28 = (uint)data[0x20] << 0x18 | (uint)data[0x21] << 0x10 | (uint)data[0x23] | + (uint)data[0x22] << 8; + uVar26 = (uint)data[0x24] << 0x18 | (uint)data[0x25] << 0x10 | (uint)data[0x27] | + (uint)data[0x26] << 8; + uVar2 = (uint)data[0x28] << 0x18 | (uint)data[0x29] << 0x10 | (uint)data[0x2b] | + (uint)data[0x2a] << 8; + uVar13 = (uint)data[0x2c] << 0x18 | (uint)data[0x2d] << 0x10 | (uint)data[0x2f] | + (uint)data[0x2e] << 8; + uVar11 = (uint)data[0x30] << 0x18 | (uint)data[0x31] << 0x10 | (uint)data[0x33] | + (uint)data[0x32] << 8; + uVar16 = ctx->state[2]; + uVar15 = ctx->state[0]; + uVar5 = (uint)data[0x34] << 0x18 | (uint)data[0x35] << 0x10 | (uint)data[0x37] | + (uint)data[0x36] << 8; + uVar4 = (uint)data[0x38] << 0x18 | (uint)data[0x39] << 0x10 | (uint)data[0x3b] | + (uint)data[0x3a] << 8; + uVar3 = (uint)data[0x3c] << 0x18 | (uint)data[0x3d] << 0x10 | (uint)data[0x3f] | + (uint)data[0x3e] << 8; + uVar6 = (uVar15 << 5 | uVar15 >> 0x1b) + ctx->state[4] + 0x5a827999 + + ((uVar16 ^ ctx->state[3]) & ctx->state[1] ^ ctx->state[3]) + uVar8; + uVar17 = ctx->state[1] << 0x1e | ctx->state[1] >> 2; + uVar18 = (uVar6 * 0x20 | uVar6 >> 0x1b) + + ((uVar16 ^ uVar17) & uVar15 ^ uVar16) + ctx->state[3] + 0x5a827999 + uVar10; + uVar23 = uVar15 << 0x1e | uVar15 >> 2; + uVar7 = uVar6 * 0x40000000 | uVar6 >> 2; + uVar6 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar17 ^ uVar23) & uVar6 ^ uVar17) + uVar16 + 0x5a827999 + uVar9; + uVar19 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar18 = (uVar6 * 0x20 | uVar6 >> 0x1b) + + ((uVar23 ^ uVar7) & uVar18 ^ uVar23) + uVar17 + 0x5a827999 + uVar1; + uVar21 = uVar6 * 0x40000000 | uVar6 >> 2; + uVar17 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar7 ^ uVar19) & uVar6 ^ uVar7) + uVar23 + 0x5a827999 + uVar27; + uVar23 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + ((uVar19 ^ uVar21) & uVar18 ^ uVar19) + uVar25 + 0x5a827999 + uVar7; + uVar6 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar7 = (uVar23 * 0x20 | uVar23 >> 0x1b) + + ((uVar21 ^ uVar6) & uVar17 ^ uVar21) + uVar14 + 0x5a827999 + uVar19; + uVar24 = uVar23 * 0x40000000 | uVar23 >> 2; + uVar19 = (uVar7 * 0x20 | uVar7 >> 0x1b) + + ((uVar6 ^ uVar18) & uVar23 ^ uVar6) + uVar21 + uVar20 + 0x5a827999; + uVar17 = uVar7 * 0x40000000 | uVar7 >> 2; + uVar7 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + ((uVar18 ^ uVar24) & uVar7 ^ uVar18) + uVar28 + 0x5a827999 + uVar6; + uVar23 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar6 = (uVar7 * 0x20 | uVar7 >> 0x1b) + + ((uVar24 ^ uVar17) & uVar19 ^ uVar24) + uVar18 + uVar26 + 0x5a827999; + uVar22 = uVar7 * 0x40000000 | uVar7 >> 2; + uVar19 = (uVar6 * 0x20 | uVar6 >> 0x1b) + + ((uVar17 ^ uVar23) & uVar7 ^ uVar17) + uVar2 + 0x5a827999 + uVar24; + uVar18 = uVar6 * 0x40000000 | uVar6 >> 2; + uVar7 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + ((uVar23 ^ uVar22) & uVar6 ^ uVar23) + uVar17 + uVar13 + 0x5a827999; + uVar21 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar6 = (uVar7 * 0x20 | uVar7 >> 0x1b) + + ((uVar22 ^ uVar18) & uVar19 ^ uVar22) + uVar11 + 0x5a827999 + uVar23; + uVar17 = uVar7 * 0x40000000 | uVar7 >> 2; + uVar19 = (uVar6 * 0x20 | uVar6 >> 0x1b) + + ((uVar18 ^ uVar21) & uVar7 ^ uVar18) + uVar22 + uVar5 + 0x5a827999; + uVar7 = uVar6 * 0x40000000 | uVar6 >> 2; + uVar23 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + ((uVar21 ^ uVar17) & uVar6 ^ uVar21) + uVar4 + 0x5a827999 + uVar18; + uVar22 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar6 = uVar8 ^ uVar9 ^ uVar28 ^ uVar5; + uVar18 = (uVar23 * 0x20 | uVar23 >> 0x1b) + + ((uVar17 ^ uVar7) & uVar19 ^ uVar17) + uVar21 + uVar3 + 0x5a827999; + uVar8 = uVar6 >> 0x1f | uVar6 << 1; + uVar6 = uVar10 ^ uVar1 ^ uVar26 ^ uVar4; + uVar19 = uVar23 * 0x40000000 | uVar23 >> 2; + uVar10 = uVar6 >> 0x1f | uVar6 << 1; + uVar17 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar7 ^ uVar22) & uVar23 ^ uVar7) + uVar8 + 0x5a827999 + uVar17; + uVar21 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar9 = uVar9 ^ uVar27 ^ uVar2 ^ uVar3; + uVar6 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + ((uVar22 ^ uVar19) & uVar18 ^ uVar22) + uVar7 + uVar10 + 0x5a827999; + uVar9 = uVar9 >> 0x1f | uVar9 << 1; + uVar1 = uVar1 ^ uVar25 ^ uVar13 ^ uVar8; + uVar23 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar1 = uVar1 >> 0x1f | uVar1 << 1; + uVar18 = (uVar6 * 0x20 | uVar6 >> 0x1b) + + ((uVar19 ^ uVar21) & uVar17 ^ uVar19) + uVar9 + 0x5a827999 + uVar22; + uVar17 = uVar27 ^ uVar14 ^ uVar11 ^ uVar10; + uVar7 = uVar6 * 0x40000000 | uVar6 >> 2; + uVar27 = uVar17 >> 0x1f | uVar17 << 1; + uVar17 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar21 ^ uVar23) & uVar6 ^ uVar21) + uVar1 + 0x5a827999 + uVar19; + uVar6 = uVar25 ^ uVar20 ^ uVar5 ^ uVar9; + uVar19 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar24 = uVar6 >> 0x1f | uVar6 << 1; + uVar21 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar23 ^ uVar7 ^ uVar18) + uVar21 + uVar27 + 0x6ed9eba1; + uVar6 = uVar14 ^ uVar28 ^ uVar4 ^ uVar1; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar17 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar7 ^ uVar19 ^ uVar17) + uVar24 + 0x6ed9eba1 + uVar23; + uVar14 = uVar6 >> 0x1f | uVar6 << 1; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar6 = uVar20 ^ uVar26 ^ uVar3 ^ uVar27; + uVar6 = uVar6 >> 0x1f | uVar6 << 1; + uVar21 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar19 ^ uVar18 ^ uVar21) + uVar14 + 0x6ed9eba1 + uVar7; + uVar7 = uVar28 ^ uVar2 ^ uVar8 ^ uVar24; + uVar20 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar28 = uVar7 >> 0x1f | uVar7 << 1; + uVar7 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar18 ^ uVar23 ^ uVar17) + uVar19 + uVar6 + 0x6ed9eba1; + uVar17 = uVar26 ^ uVar13 ^ uVar10 ^ uVar14; + uVar22 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar26 = uVar17 >> 0x1f | uVar17 << 1; + uVar17 = (uVar7 * 0x20 | uVar7 >> 0x1b) + + (uVar23 ^ uVar20 ^ uVar21) + uVar18 + uVar28 + 0x6ed9eba1; + uVar2 = uVar2 ^ uVar11 ^ uVar9 ^ uVar6; + uVar19 = uVar7 * 0x40000000 | uVar7 >> 2; + uVar21 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar20 ^ uVar22 ^ uVar7) + uVar23 + uVar26 + 0x6ed9eba1; + uVar2 = uVar2 >> 0x1f | uVar2 << 1; + uVar7 = uVar13 ^ uVar5 ^ uVar1 ^ uVar28; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar13 = uVar7 >> 0x1f | uVar7 << 1; + uVar20 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar22 ^ uVar19 ^ uVar17) + uVar2 + 0x6ed9eba1 + uVar20; + uVar7 = uVar11 ^ uVar4 ^ uVar27 ^ uVar26; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar11 = uVar7 >> 0x1f | uVar7 << 1; + uVar17 = (uVar20 * 0x20 | uVar20 >> 0x1b) + + (uVar19 ^ uVar18 ^ uVar21) + uVar13 + 0x6ed9eba1 + uVar22; + uVar5 = uVar5 ^ uVar3 ^ uVar24 ^ uVar2; + uVar22 = uVar20 * 0x40000000 | uVar20 >> 2; + uVar5 = uVar5 >> 0x1f | uVar5 << 1; + uVar7 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar18 ^ uVar23 ^ uVar20) + uVar19 + uVar11 + 0x6ed9eba1; + uVar4 = uVar4 ^ uVar8 ^ uVar14 ^ uVar13; + uVar20 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar4 = uVar4 >> 0x1f | uVar4 << 1; + uVar17 = (uVar7 * 0x20 | uVar7 >> 0x1b) + (uVar23 ^ uVar22 ^ uVar17) + uVar18 + uVar5 + 0x6ed9eba1 + ; + uVar3 = uVar3 ^ uVar10 ^ uVar6 ^ uVar11; + uVar19 = uVar7 * 0x40000000 | uVar7 >> 2; + uVar3 = uVar3 >> 0x1f | uVar3 << 1; + uVar21 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar22 ^ uVar20 ^ uVar7) + uVar23 + uVar4 + 0x6ed9eba1; + uVar7 = uVar8 ^ uVar9 ^ uVar28 ^ uVar5; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar17 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar20 ^ uVar19 ^ uVar17) + uVar3 + 0x6ed9eba1 + uVar22; + uVar7 = uVar7 >> 0x1f | uVar7 << 1; + uVar8 = uVar10 ^ uVar1 ^ uVar26 ^ uVar4; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar10 = uVar8 >> 0x1f | uVar8 << 1; + uVar21 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar19 ^ uVar18 ^ uVar21) + uVar7 + 0x6ed9eba1 + uVar20; + uVar8 = uVar9 ^ uVar27 ^ uVar2 ^ uVar3; + uVar20 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar8 = uVar8 >> 0x1f | uVar8 << 1; + uVar17 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar18 ^ uVar23 ^ uVar17) + uVar19 + uVar10 + 0x6ed9eba1; + uVar1 = uVar1 ^ uVar24 ^ uVar13 ^ uVar7; + uVar22 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar9 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar23 ^ uVar20 ^ uVar21) + uVar18 + uVar8 + 0x6ed9eba1; + uVar1 = uVar1 >> 0x1f | uVar1 << 1; + uVar19 = uVar27 ^ uVar14 ^ uVar11 ^ uVar10; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar21 = (uVar9 * 0x20 | uVar9 >> 0x1b) + (uVar20 ^ uVar22 ^ uVar17) + uVar1 + 0x6ed9eba1 + uVar23 + ; + uVar27 = uVar19 >> 0x1f | uVar19 << 1; + uVar19 = uVar24 ^ uVar6 ^ uVar5 ^ uVar8; + uVar17 = uVar9 * 0x40000000 | uVar9 >> 2; + uVar25 = uVar19 >> 0x1f | uVar19 << 1; + uVar19 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar22 ^ uVar18 ^ uVar9) + uVar27 + 0x6ed9eba1 + uVar20; + uVar9 = uVar14 ^ uVar28 ^ uVar4 ^ uVar1; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar14 = uVar9 >> 0x1f | uVar9 << 1; + uVar20 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar18 ^ uVar17 ^ uVar21) + uVar22 + uVar25 + 0x6ed9eba1; + uVar6 = uVar6 ^ uVar26 ^ uVar3 ^ uVar27; + uVar21 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar6 = uVar6 >> 0x1f | uVar6 << 1; + uVar9 = (uVar20 * 0x20 | uVar20 >> 0x1b) + + (uVar17 ^ uVar23 ^ uVar19) + uVar14 + 0x6ed9eba1 + uVar18; + uVar18 = uVar28 ^ uVar2 ^ uVar7 ^ uVar25; + uVar22 = uVar20 * 0x40000000 | uVar20 >> 2; + uVar28 = uVar18 >> 0x1f | uVar18 << 1; + uVar17 = (uVar9 * 0x20 | uVar9 >> 0x1b) + (uVar23 ^ uVar21 ^ uVar20) + uVar6 + 0x6ed9eba1 + uVar17 + ; + uVar19 = uVar9 * 0x40000000 | uVar9 >> 2; + uVar20 = uVar26 ^ uVar13 ^ uVar10 ^ uVar14; + uVar18 = ((uVar9 | uVar22) & uVar21 | uVar9 & uVar22) + + uVar28 + 0x8f1bbcdc + uVar23 + (uVar17 * 0x20 | uVar17 >> 0x1b); + uVar26 = uVar20 >> 0x1f | uVar20 << 1; + uVar2 = uVar2 ^ uVar11 ^ uVar8 ^ uVar6; + uVar23 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar2 = uVar2 >> 0x1f | uVar2 << 1; + uVar17 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar17 | uVar19) & uVar22 | uVar17 & uVar19) + uVar26 + 0x8f1bbcdc + uVar21; + uVar9 = uVar13 ^ uVar5 ^ uVar1 ^ uVar28; + uVar21 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar13 = uVar9 >> 0x1f | uVar9 << 1; + uVar20 = ((uVar18 | uVar23) & uVar19 | uVar18 & uVar23) + + uVar2 + 0x8f1bbcdc + uVar22 + (uVar17 * 0x20 | uVar17 >> 0x1b); + uVar9 = uVar11 ^ uVar4 ^ uVar27 ^ uVar26; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar11 = uVar9 >> 0x1f | uVar9 << 1; + uVar9 = (uVar20 * 0x20 | uVar20 >> 0x1b) + + ((uVar17 | uVar21) & uVar23 | uVar17 & uVar21) + uVar13 + 0x8f1bbcdc + uVar19; + uVar24 = uVar20 * 0x40000000 | uVar20 >> 2; + uVar5 = uVar5 ^ uVar3 ^ uVar25 ^ uVar2; + uVar19 = ((uVar20 | uVar18) & uVar21 | uVar20 & uVar18) + + uVar11 + 0x8f1bbcdc + uVar23 + (uVar9 * 0x20 | uVar9 >> 0x1b); + uVar5 = uVar5 >> 0x1f | uVar5 << 1; + uVar4 = uVar4 ^ uVar7 ^ uVar14 ^ uVar13; + uVar17 = uVar9 * 0x40000000 | uVar9 >> 2; + uVar4 = uVar4 >> 0x1f | uVar4 << 1; + uVar9 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + ((uVar9 | uVar24) & uVar18 | uVar9 & uVar24) + uVar5 + 0x8f1bbcdc + uVar21; + uVar3 = uVar3 ^ uVar10 ^ uVar6 ^ uVar11; + uVar22 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar3 = uVar3 >> 0x1f | uVar3 << 1; + uVar18 = ((uVar19 | uVar17) & uVar24 | uVar19 & uVar17) + + uVar4 + 0x8f1bbcdc + uVar18 + (uVar9 * 0x20 | uVar9 >> 0x1b); + uVar7 = uVar7 ^ uVar8 ^ uVar28 ^ uVar5; + uVar20 = uVar9 * 0x40000000 | uVar9 >> 2; + uVar7 = uVar7 >> 0x1f | uVar7 << 1; + uVar21 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar9 | uVar22) & uVar17 | uVar9 & uVar22) + uVar3 + 0x8f1bbcdc + uVar24; + uVar9 = uVar10 ^ uVar1 ^ uVar26 ^ uVar4; + uVar19 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar9 = uVar9 >> 0x1f | uVar9 << 1; + uVar10 = ((uVar18 | uVar20) & uVar22 | uVar18 & uVar20) + + uVar7 + 0x8f1bbcdc + uVar17 + (uVar21 * 0x20 | uVar21 >> 0x1b); + uVar8 = uVar8 ^ uVar27 ^ uVar2 ^ uVar3; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar8 = uVar8 >> 0x1f | uVar8 << 1; + uVar18 = (uVar10 * 0x20 | uVar10 >> 0x1b) + + ((uVar21 | uVar19) & uVar20 | uVar21 & uVar19) + uVar9 + 0x8f1bbcdc + uVar22; + uVar1 = uVar1 ^ uVar25 ^ uVar13 ^ uVar7; + uVar17 = uVar10 * 0x40000000 | uVar10 >> 2; + uVar1 = uVar1 >> 0x1f | uVar1 << 1; + uVar10 = ((uVar10 | uVar23) & uVar19 | uVar10 & uVar23) + + uVar8 + 0x8f1bbcdc + uVar20 + (uVar18 * 0x20 | uVar18 >> 0x1b); + uVar21 = uVar27 ^ uVar14 ^ uVar11 ^ uVar9; + uVar22 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar27 = uVar21 >> 0x1f | uVar21 << 1; + uVar18 = (uVar10 * 0x20 | uVar10 >> 0x1b) + + ((uVar18 | uVar17) & uVar23 | uVar18 & uVar17) + uVar19 + uVar1 + 0x8f1bbcdc; + uVar19 = uVar25 ^ uVar6 ^ uVar5 ^ uVar8; + uVar20 = uVar10 * 0x40000000 | uVar10 >> 2; + uVar24 = uVar19 >> 0x1f | uVar19 << 1; + uVar21 = ((uVar10 | uVar22) & uVar17 | uVar10 & uVar22) + + uVar27 + 0x8f1bbcdc + uVar23 + (uVar18 * 0x20 | uVar18 >> 0x1b); + uVar10 = uVar14 ^ uVar28 ^ uVar4 ^ uVar1; + uVar19 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar14 = uVar10 >> 0x1f | uVar10 << 1; + uVar10 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + ((uVar18 | uVar20) & uVar22 | uVar18 & uVar20) + uVar17 + uVar24 + 0x8f1bbcdc; + uVar6 = uVar6 ^ uVar26 ^ uVar3 ^ uVar27; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar6 = uVar6 >> 0x1f | uVar6 << 1; + uVar18 = ((uVar21 | uVar19) & uVar20 | uVar21 & uVar19) + + uVar14 + 0x8f1bbcdc + uVar22 + (uVar10 * 0x20 | uVar10 >> 0x1b); + uVar21 = uVar28 ^ uVar2 ^ uVar7 ^ uVar24; + uVar17 = uVar10 * 0x40000000 | uVar10 >> 2; + uVar28 = uVar21 >> 0x1f | uVar21 << 1; + uVar10 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar10 | uVar23) & uVar19 | uVar10 & uVar23) + uVar20 + uVar6 + 0x8f1bbcdc; + uVar21 = uVar26 ^ uVar13 ^ uVar9 ^ uVar14; + uVar22 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar25 = uVar21 >> 0x1f | uVar21 << 1; + uVar18 = ((uVar18 | uVar17) & uVar23 | uVar18 & uVar17) + + uVar28 + 0x8f1bbcdc + uVar19 + (uVar10 * 0x20 | uVar10 >> 0x1b); + uVar2 = uVar2 ^ uVar11 ^ uVar8 ^ uVar6; + uVar20 = uVar10 * 0x40000000 | uVar10 >> 2; + uVar2 = uVar2 >> 0x1f | uVar2 << 1; + uVar21 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar10 | uVar22) & uVar17 | uVar10 & uVar22) + uVar23 + uVar25 + 0x8f1bbcdc; + uVar10 = uVar13 ^ uVar5 ^ uVar1 ^ uVar28; + uVar19 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar13 = uVar10 >> 0x1f | uVar10 << 1; + uVar17 = ((uVar18 | uVar20) & uVar22 | uVar18 & uVar20) + + uVar2 + 0x8f1bbcdc + uVar17 + (uVar21 * 0x20 | uVar21 >> 0x1b); + uVar10 = uVar11 ^ uVar4 ^ uVar27 ^ uVar25; + uVar18 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar10 = uVar10 >> 0x1f | uVar10 << 1; + uVar23 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + ((uVar21 | uVar19) & uVar20 | uVar21 & uVar19) + uVar22 + uVar13 + 0x8f1bbcdc; + uVar5 = uVar5 ^ uVar3 ^ uVar24 ^ uVar2; + uVar11 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar5 = uVar5 >> 0x1f | uVar5 << 1; + uVar21 = (uVar23 * 0x20 | uVar23 >> 0x1b) + + (uVar19 ^ uVar18 ^ uVar17) + uVar20 + uVar10 + 0xca62c1d6; + uVar4 = uVar4 ^ uVar7 ^ uVar14 ^ uVar13; + uVar20 = uVar23 * 0x40000000 | uVar23 >> 2; + uVar4 = uVar4 >> 0x1f | uVar4 << 1; + uVar17 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar18 ^ uVar11 ^ uVar23) + uVar19 + uVar5 + 0xca62c1d6; + uVar3 = uVar3 ^ uVar9 ^ uVar6 ^ uVar10; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar3 = uVar3 >> 0x1f | uVar3 << 1; + uVar19 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar11 ^ uVar20 ^ uVar21) + uVar18 + uVar4 + 0xca62c1d6; + uVar7 = uVar7 ^ uVar8 ^ uVar28 ^ uVar5; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar7 = uVar7 >> 0x1f | uVar7 << 1; + uVar11 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar20 ^ uVar23 ^ uVar17) + uVar11 + uVar3 + 0xca62c1d6; + uVar9 = uVar9 ^ uVar1 ^ uVar25 ^ uVar4; + uVar21 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar9 = uVar9 >> 0x1f | uVar9 << 1; + uVar20 = (uVar11 * 0x20 | uVar11 >> 0x1b) + + (uVar23 ^ uVar18 ^ uVar19) + uVar20 + uVar7 + 0xca62c1d6; + uVar8 = uVar8 ^ uVar27 ^ uVar2 ^ uVar3; + uVar17 = uVar11 * 0x40000000 | uVar11 >> 2; + uVar8 = uVar8 >> 0x1f | uVar8 << 1; + uVar19 = (uVar20 * 0x20 | uVar20 >> 0x1b) + + (uVar18 ^ uVar21 ^ uVar11) + uVar23 + uVar9 + 0xca62c1d6; + uVar1 = uVar1 ^ uVar24 ^ uVar13 ^ uVar7; + uVar22 = uVar20 * 0x40000000 | uVar20 >> 2; + uVar1 = uVar1 >> 0x1f | uVar1 << 1; + uVar11 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar21 ^ uVar17 ^ uVar20) + uVar18 + uVar8 + 0xca62c1d6; + uVar18 = uVar27 ^ uVar14 ^ uVar10 ^ uVar9; + uVar23 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar26 = uVar18 >> 0x1f | uVar18 << 1; + uVar19 = (uVar11 * 0x20 | uVar11 >> 0x1b) + + (uVar17 ^ uVar22 ^ uVar19) + uVar21 + uVar1 + 0xca62c1d6; + uVar21 = uVar24 ^ uVar6 ^ uVar5 ^ uVar8; + uVar18 = uVar11 * 0x40000000 | uVar11 >> 2; + uVar24 = uVar21 >> 0x1f | uVar21 << 1; + uVar17 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar22 ^ uVar23 ^ uVar11) + uVar17 + uVar26 + 0xca62c1d6; + uVar11 = uVar14 ^ uVar28 ^ uVar4 ^ uVar1; + uVar21 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar11 = uVar11 >> 0x1f | uVar11 << 1; + uVar20 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar23 ^ uVar18 ^ uVar19) + uVar22 + uVar24 + 0xca62c1d6; + uVar6 = uVar6 ^ uVar25 ^ uVar3 ^ uVar26; + uVar14 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar6 = uVar6 >> 0x1f | uVar6 << 1; + uVar19 = (uVar20 * 0x20 | uVar20 >> 0x1b) + + (uVar18 ^ uVar21 ^ uVar17) + uVar23 + uVar11 + 0xca62c1d6; + uVar17 = uVar28 ^ uVar2 ^ uVar7 ^ uVar24; + uVar22 = uVar20 * 0x40000000 | uVar20 >> 2; + uVar27 = uVar17 >> 0x1f | uVar17 << 1; + uVar17 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar21 ^ uVar14 ^ uVar20) + uVar18 + uVar6 + 0xca62c1d6; + uVar18 = uVar25 ^ uVar13 ^ uVar9 ^ uVar11; + uVar23 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar20 = uVar18 >> 0x1f | uVar18 << 1; + uVar19 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar14 ^ uVar22 ^ uVar19) + uVar21 + uVar27 + 0xca62c1d6; + uVar2 = uVar2 ^ uVar10 ^ uVar8 ^ uVar6; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar2 = uVar2 >> 0x1f | uVar2 << 1; + uVar8 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar22 ^ uVar23 ^ uVar17) + uVar14 + uVar20 + 0xca62c1d6; + uVar27 = uVar13 ^ uVar5 ^ uVar1 ^ uVar27; + uVar13 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar21 = uVar27 >> 0x1f | uVar27 << 1; + uVar14 = uVar22 + uVar2 + 0xca62c1d6 + (uVar23 ^ uVar18 ^ uVar19) + (uVar8 * 0x20 | uVar8 >> 0x1b) + ; + uVar20 = uVar10 ^ uVar4 ^ uVar26 ^ uVar20; + uVar10 = (uVar14 * 0x20 | uVar14 >> 0x1b) + + (uVar18 ^ uVar13 ^ uVar8) + uVar23 + uVar21 + 0xca62c1d6; + uVar1 = uVar8 * 0x40000000 | uVar8 >> 2; + uVar17 = uVar20 >> 0x1f | uVar20 << 1; + uVar2 = uVar5 ^ uVar3 ^ uVar24 ^ uVar2; + uVar5 = uVar18 + uVar17 + 0xca62c1d6 + (uVar13 ^ uVar1 ^ uVar14) + + (uVar10 * 0x20 | uVar10 >> 0x1b); + uVar8 = uVar14 * 0x40000000 | uVar14 >> 2; + uVar21 = uVar4 ^ uVar7 ^ uVar11 ^ uVar21; + uVar4 = uVar13 + (uVar2 << 1 | uVar2 >> 0x1f) + 0xca62c1d6 + (uVar1 ^ uVar8 ^ uVar10) + + (uVar5 * 0x20 | uVar5 >> 0x1b); + uVar7 = uVar10 * 0x40000000 | uVar10 >> 2; + uVar17 = uVar3 ^ uVar9 ^ uVar6 ^ uVar17; + uVar1 = uVar1 + (uVar21 << 1 | uVar21 >> 0x1f) + 0xca62c1d6 + (uVar8 ^ uVar7 ^ uVar5) + + (uVar4 * 0x20 | uVar4 >> 0x1b); + uVar2 = uVar5 * 0x40000000 | uVar5 >> 2; + uVar12 = ctx->state[1]; + ctx->state[0] = + uVar8 + (uVar17 << 1 | uVar17 >> 0x1f) + uVar15 + 0xca62c1d6 + (uVar7 ^ uVar2 ^ uVar4) + + (uVar1 * 0x20 | uVar1 >> 0x1b); + ctx->state[1] = uVar1 + uVar12; + ctx->state[2] = uVar16 + (uVar4 >> 2 | uVar4 * 0x40000000); + ctx->state[3] = uVar2 + ctx->state[3]; + ctx->state[4] = uVar7 + ctx->state[4]; + return; +} + + + +void sha1_clone_wrap(mbedtls_sha1_context *dst,mbedtls_sha1_context *src) + +{ + memcpy(dst,src,0x5c); + return; +} + + + +void sha1_ctx_free(void *ctx) + +{ + mbedtls_sha1_free((mbedtls_sha1_context *)ctx); + vPortFree(ctx); + return; +} + + + +void * sha1_ctx_alloc(void) + +{ + mbedtls_sha1_context *ctx; + + ctx = (mbedtls_sha1_context *)mycalloc(1,0x5c); + if (ctx != (mbedtls_sha1_context *)0x0) { + mbedtls_sha1_init(ctx); + } + return ctx; +} + + + +void sha1_finish_wrap(mbedtls_sha1_context *ctx,uchar *output) + +{ + uint uVar1; + uint uVar2; + int iVar3; + uchar uStack24; + undefined uStack23; + ushort uStack22; + undefined uStack20; + undefined uStack19; + ushort uStack18; + + uVar1 = ctx->total[0]; + uVar2 = ctx->total[1] << 3; + uStack24 = (uchar)(uVar2 >> 0x18); + uStack23 = (undefined)(uVar2 >> 0x10); + uStack22 = (ushort)(uVar2 >> 8) & 0xff | (ushort)((uVar2 | uVar1 >> 0x1d) << 8); + uStack20 = (undefined)((uVar1 << 3) >> 0x18); + uStack19 = (undefined)((uVar1 << 3) >> 0x10); + uStack18 = (ushort)((uVar1 << 0x13) >> 0x18) | (ushort)(uVar1 << 0xb); + if ((uVar1 & 0x3f) < 0x38) { + iVar3 = 0x38; + } + else { + iVar3 = 0x78; + } + mbedtls_sha1_update(ctx,sha1_padding,iVar3 - (uVar1 & 0x3f)); + mbedtls_sha1_update(ctx,&uStack24,8); + *output = *(uchar *)((int)ctx->state + 3); + output[1] = (uchar)*(undefined2 *)((int)ctx->state + 2); + output[2] = (uchar)(ctx->state[0] >> 8); + output[3] = (uchar)ctx->state[0]; + output[4] = *(uchar *)((int)ctx->state + 7); + output[5] = (uchar)*(undefined2 *)((int)ctx->state + 6); + output[6] = (uchar)(ctx->state[1] >> 8); + output[7] = (uchar)ctx->state[1]; + output[8] = *(uchar *)((int)ctx->state + 0xb); + output[9] = (uchar)*(undefined2 *)((int)ctx->state + 10); + output[10] = (uchar)(ctx->state[2] >> 8); + output[0xb] = (uchar)ctx->state[2]; + output[0xc] = *(uchar *)((int)ctx->state + 0xf); + output[0xd] = (uchar)*(undefined2 *)((int)ctx->state + 0xe); + output[0xe] = (uchar)(ctx->state[3] >> 8); + output[0xf] = (uchar)ctx->state[3]; + output[0x10] = *(uchar *)((int)ctx->state + 0x13); + output[0x11] = (uchar)*(undefined2 *)((int)ctx->state + 0x12); + output[0x12] = (uchar)(ctx->state[4] >> 8); + output[0x13] = (uchar)ctx->state[4]; + return; +} + + + +void sha1_update_wrap(mbedtls_sha1_context *ctx,uchar *input,size_t ilen) + +{ + if (ilen != 0) { + mbedtls_sha1_update(ctx,input,ilen); + return; + } + return; +} + + + +void sha1_starts_wrap(mbedtls_sha1_context *ctx) + +{ + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xefcdab89; + ctx->state[2] = 0x98badcfe; + ctx->state[3] = 0x10325476; + ctx->total[0] = 0; + ctx->total[1] = 0; + ctx->state[4] = 0xc3d2e1f0; + return; +} + + + +void sha224_process_wrap(mbedtls_sha256_context *ctx,uchar *data) + +{ + uint uVar1; + uint32_t *puVar2; + byte *pbVar3; + byte *pbVar4; + uint uVar5; + uint uVar6; + uint32_t uVar7; + uint uVar8; + uint32_t *puVar9; + uint *puVar10; + uint uVar11; + uint uVar12; + int iVar13; + uint uVar14; + uint uVar15; + uint uVar16; + uint uVar17; + uint32_t *puVar18; + uint uVar19; + uint uVar20; + uint uVar21; + uint *puVar22; + uint32_t *puVar23; + uint uVar24; + uint uVar25; + uint32_t uStack336; + uint uStack332; + uint uStack328; + uint uStack324; + uint uStack320; + uint uStack316; + uint uStack312; + uint uStack308; + uint auStack304 [67]; + + puVar18 = &uStack336; + puVar9 = &uStack336; + puVar2 = ctx->state; + do { + uVar7 = *puVar2; + puVar2 = puVar2 + 1; + *puVar9 = uVar7; + puVar9 = puVar9 + 1; + } while ((uint32_t *)ctx->buffer != puVar2); + puVar22 = auStack304; + pbVar3 = data; + puVar10 = puVar22; + do { + pbVar4 = pbVar3 + 4; + *puVar10 = (uint)*pbVar3 << 0x18 | (uint)pbVar3[1] << 0x10 | (uint)pbVar3[3] | + (uint)pbVar3[2] << 8; + pbVar3 = pbVar4; + puVar10 = puVar10 + 1; + } while (data + 0x40 != pbVar4); + puVar2 = K; + puVar9 = K; + puVar10 = puVar22; + do { + puVar23 = puVar9 + 8; + iVar13 = uStack308 + + ((uStack320 >> 6 | uStack320 << 0x1a) ^ (uStack320 >> 0xb | uStack320 << 0x15) ^ + (uStack320 << 7 | uStack320 >> 0x19)) + *puVar9 + *puVar10 + + ((uStack312 ^ uStack316) & uStack320 ^ uStack312); + uVar12 = uStack324 + iVar13; + uVar14 = iVar13 + ((uStack336 >> 2 | uStack336 << 0x1e) ^ (uStack336 >> 0xd | uStack336 << 0x13) + ^ (uStack336 << 10 | uStack336 >> 0x16)) + + ((uStack336 | uStack332) & uStack328 | uStack336 & uStack332); + iVar13 = ((uVar12 >> 6 | uVar12 * 0x4000000) ^ (uVar12 >> 0xb | uVar12 * 0x200000) ^ + (uVar12 * 0x80 | uVar12 >> 0x19)) + + uStack312 + puVar9[1] + puVar10[1] + ((uStack320 ^ uStack316) & uVar12 ^ uStack316); + uVar1 = ((uVar14 >> 2 | uVar14 * 0x40000000) ^ (uVar14 >> 0xd | uVar14 * 0x80000) ^ + (uVar14 * 0x400 | uVar14 >> 0x16)) + + ((uVar14 | uStack336) & uStack332 | uVar14 & uStack336) + iVar13; + uVar11 = uStack328 + iVar13; + iVar13 = ((uVar11 >> 6 | uVar11 * 0x4000000) ^ (uVar11 >> 0xb | uVar11 * 0x200000) ^ + (uVar11 * 0x80 | uVar11 >> 0x19)) + + uStack316 + puVar9[2] + puVar10[2] + ((uVar12 ^ uStack320) & uVar11 ^ uStack320); + uVar5 = ((uVar1 >> 2 | uVar1 * 0x40000000) ^ (uVar1 >> 0xd | uVar1 * 0x80000) ^ + (uVar1 * 0x400 | uVar1 >> 0x16)) + ((uVar14 | uVar1) & uStack336 | uVar14 & uVar1) + + iVar13; + uVar8 = uStack332 + iVar13; + iVar13 = ((uVar8 >> 6 | uVar8 * 0x4000000) ^ (uVar8 >> 0xb | uVar8 * 0x200000) ^ + (uVar8 * 0x80 | uVar8 >> 0x19)) + + uStack320 + puVar9[3] + puVar10[3] + ((uVar12 ^ uVar11) & uVar8 ^ uVar12); + uVar16 = ((uVar5 >> 2 | uVar5 * 0x40000000) ^ (uVar5 >> 0xd | uVar5 * 0x80000) ^ + (uVar5 * 0x400 | uVar5 >> 0x16)) + ((uVar1 | uVar5) & uVar14 | uVar1 & uVar5) + iVar13; + uVar6 = uStack336 + iVar13; + iVar13 = ((uVar6 >> 6 | uVar6 * 0x4000000) ^ (uVar6 >> 0xb | uVar6 * 0x200000) ^ + (uVar6 * 0x80 | uVar6 >> 0x19)) + + uVar12 + puVar9[4] + puVar10[4] + ((uVar11 ^ uVar8) & uVar6 ^ uVar11); + uStack324 = ((uVar16 >> 2 | uVar16 * 0x40000000) ^ (uVar16 >> 0xd | uVar16 * 0x80000) ^ + (uVar16 * 0x400 | uVar16 >> 0x16)) + ((uVar5 | uVar16) & uVar1 | uVar5 & uVar16) + + iVar13; + uStack308 = uVar14 + iVar13; + iVar13 = ((uStack308 >> 6 | uStack308 * 0x4000000) ^ (uStack308 >> 0xb | uStack308 * 0x200000) ^ + (uStack308 * 0x80 | uStack308 >> 0x19)) + + uVar11 + puVar9[5] + puVar10[5] + ((uVar8 ^ uVar6) & uStack308 ^ uVar8); + uStack328 = ((uStack324 >> 2 | uStack324 * 0x40000000) ^ + (uStack324 >> 0xd | uStack324 * 0x80000) ^ (uStack324 * 0x400 | uStack324 >> 0x16)) + + ((uVar16 | uStack324) & uVar5 | uVar16 & uStack324) + iVar13; + uStack312 = uVar1 + iVar13; + iVar13 = ((uStack312 >> 6 | uStack312 * 0x4000000) ^ (uStack312 >> 0xb | uStack312 * 0x200000) ^ + (uStack312 * 0x80 | uStack312 >> 0x19)) + + uVar8 + puVar9[6] + puVar10[6] + ((uVar6 ^ uStack308) & uStack312 ^ uVar6); + uStack332 = ((uStack328 >> 2 | uStack328 * 0x40000000) ^ + (uStack328 >> 0xd | uStack328 * 0x80000) ^ (uStack328 * 0x400 | uStack328 >> 0x16)) + + ((uStack324 | uStack328) & uVar16 | uStack324 & uStack328) + iVar13; + uStack316 = uVar5 + iVar13; + iVar13 = ((uStack316 >> 6 | uStack316 * 0x4000000) ^ (uStack316 >> 0xb | uStack316 * 0x200000) ^ + (uStack316 * 0x80 | uStack316 >> 0x19)) + + uVar6 + puVar9[7] + puVar10[7] + ((uStack308 ^ uStack312) & uStack316 ^ uStack308); + uStack320 = uVar16 + iVar13; + uStack336 = ((uStack332 >> 2 | uStack332 * 0x40000000) ^ + (uStack332 >> 0xd | uStack332 * 0x80000) ^ (uStack332 * 0x400 | uStack332 >> 0x16)) + + ((uStack328 | uStack332) & uStack324 | uStack328 & uStack332) + iVar13; + puVar9 = puVar23; + puVar10 = puVar10 + 8; + } while (puVar23 != K + 0x10); + do { + uVar19 = puVar22[0xe]; + uVar1 = puVar22[1]; + uVar20 = puVar22[0xf]; + uVar24 = ((uVar19 << 0xf | uVar19 >> 0x11) ^ (uVar19 << 0xd | uVar19 >> 0x13) ^ uVar19 >> 10) + + puVar22[9] + *puVar22 + + ((uVar1 >> 7 | uVar1 << 0x19) ^ (uVar1 << 0xe | uVar1 >> 0x12) ^ uVar1 >> 3); + uVar11 = puVar22[3]; + iVar13 = uStack308 + + ((uStack320 >> 6 | uStack320 << 0x1a) ^ (uStack320 >> 0xb | uStack320 << 0x15) ^ + (uStack320 << 7 | uStack320 >> 0x19)) + + ((uStack312 ^ uStack316) & uStack320 ^ uStack312) + puVar2[0x10] + uVar24; + uVar16 = uStack324 + iVar13; + uVar15 = iVar13 + ((uStack336 >> 2 | uStack336 << 0x1e) ^ (uStack336 >> 0xd | uStack336 << 0x13) + ^ (uStack336 << 10 | uStack336 >> 0x16)) + + ((uStack336 | uStack332) & uStack328 | uStack336 & uStack332); + uVar6 = puVar22[2]; + uVar1 = ((uVar20 << 0xf | uVar20 >> 0x11) ^ (uVar20 << 0xd | uVar20 >> 0x13) ^ uVar20 >> 10) + + uVar1 + puVar22[10] + + ((uVar6 >> 7 | uVar6 << 0x19) ^ (uVar6 << 0xe | uVar6 >> 0x12) ^ uVar6 >> 3); + iVar13 = ((uStack320 ^ uStack316) & uVar16 ^ uStack316) + uStack312 + puVar2[0x11] + uVar1 + + ((uVar16 >> 6 | uVar16 * 0x4000000) ^ (uVar16 >> 0xb | uVar16 * 0x200000) ^ + (uVar16 * 0x80 | uVar16 >> 0x19)); + uVar5 = ((uVar15 >> 2 | uVar15 * 0x40000000) ^ (uVar15 >> 0xd | uVar15 * 0x80000) ^ + (uVar15 * 0x400 | uVar15 >> 0x16)) + + ((uStack336 | uVar15) & uStack332 | uStack336 & uVar15) + iVar13; + uVar14 = uStack328 + iVar13; + uVar6 = ((uVar24 * 0x8000 | uVar24 >> 0x11) ^ (uVar24 * 0x2000 | uVar24 >> 0x13) ^ uVar24 >> 10) + + uVar6 + puVar22[0xb] + + ((uVar11 >> 7 | uVar11 << 0x19) ^ (uVar11 << 0xe | uVar11 >> 0x12) ^ uVar11 >> 3); + iVar13 = ((uStack320 ^ uVar16) & uVar14 ^ uStack320) + uStack316 + puVar2[0x12] + uVar6 + + ((uVar14 >> 6 | uVar14 * 0x4000000) ^ (uVar14 >> 0xb | uVar14 * 0x200000) ^ + (uVar14 * 0x80 | uVar14 >> 0x19)); + puVar22[0x11] = uVar1; + uVar8 = ((uVar5 >> 2 | uVar5 * 0x40000000) ^ (uVar5 >> 0xd | uVar5 * 0x80000) ^ + (uVar5 * 0x400 | uVar5 >> 0x16)) + ((uVar15 | uVar5) & uStack336 | uVar15 & uVar5) + + iVar13; + uVar12 = uStack332 + iVar13; + uVar25 = puVar22[4]; + uVar1 = ((uVar1 * 0x8000 | uVar1 >> 0x11) ^ (uVar1 * 0x2000 | uVar1 >> 0x13) ^ uVar1 >> 10) + + uVar11 + puVar22[0xc] + + ((uVar25 >> 7 | uVar25 << 0x19) ^ (uVar25 << 0xe | uVar25 >> 0x12) ^ uVar25 >> 3); + iVar13 = ((uVar16 ^ uVar14) & uVar12 ^ uVar16) + uStack320 + puVar2[0x13] + uVar1 + + ((uVar12 >> 6 | uVar12 * 0x4000000) ^ (uVar12 >> 0xb | uVar12 * 0x200000) ^ + (uVar12 * 0x80 | uVar12 >> 0x19)); + uVar17 = ((uVar8 >> 2 | uVar8 * 0x40000000) ^ (uVar8 >> 0xd | uVar8 * 0x80000) ^ + (uVar8 * 0x400 | uVar8 >> 0x16)) + ((uVar5 | uVar8) & uVar15 | uVar5 & uVar8) + iVar13; + uVar11 = uStack336 + iVar13; + puVar22[0x12] = uVar6; + uVar21 = puVar22[5]; + uVar25 = ((uVar6 * 0x8000 | uVar6 >> 0x11) ^ (uVar6 * 0x2000 | uVar6 >> 0x13) ^ uVar6 >> 10) + + uVar25 + puVar22[0xd] + + ((uVar21 >> 7 | uVar21 << 0x19) ^ (uVar21 << 0xe | uVar21 >> 0x12) ^ uVar21 >> 3); + iVar13 = ((uVar11 >> 6 | uVar11 * 0x4000000) ^ (uVar11 >> 0xb | uVar11 * 0x200000) ^ + (uVar11 * 0x80 | uVar11 >> 0x19)) + + ((uVar14 ^ uVar12) & uVar11 ^ uVar14) + uVar16 + puVar2[0x14] + uVar25; + uStack324 = ((uVar17 >> 2 | uVar17 * 0x40000000) ^ (uVar17 >> 0xd | uVar17 * 0x80000) ^ + (uVar17 * 0x400 | uVar17 >> 0x16)) + ((uVar8 | uVar17) & uVar5 | uVar8 & uVar17) + + iVar13; + uStack308 = uVar15 + iVar13; + uVar6 = puVar22[6]; + puVar22[0x13] = uVar1; + uVar16 = ((uVar1 * 0x8000 | uVar1 >> 0x11) ^ (uVar1 * 0x2000 | uVar1 >> 0x13) ^ uVar1 >> 10) + + uVar19 + uVar21 + + ((uVar6 >> 7 | uVar6 << 0x19) ^ (uVar6 << 0xe | uVar6 >> 0x12) ^ uVar6 >> 3); + iVar13 = ((uStack308 >> 6 | uStack308 * 0x4000000) ^ (uStack308 >> 0xb | uStack308 * 0x200000) ^ + (uStack308 * 0x80 | uStack308 >> 0x19)) + + ((uVar12 ^ uVar11) & uStack308 ^ uVar12) + uVar14 + puVar2[0x15] + uVar16; + uStack328 = ((uStack324 >> 2 | uStack324 * 0x40000000) ^ + (uStack324 >> 0xd | uStack324 * 0x80000) ^ (uStack324 * 0x400 | uStack324 >> 0x16)) + + ((uVar17 | uStack324) & uVar8 | uVar17 & uStack324) + iVar13; + uStack312 = uVar5 + iVar13; + uVar1 = puVar22[7]; + puVar22[0x14] = uVar25; + uVar6 = uVar20 + uVar6 + + ((uVar25 * 0x8000 | uVar25 >> 0x11) ^ (uVar25 * 0x2000 | uVar25 >> 0x13) ^ uVar25 >> 10) + + ((uVar1 >> 7 | uVar1 << 0x19) ^ (uVar1 << 0xe | uVar1 >> 0x12) ^ uVar1 >> 3); + iVar13 = ((uStack312 >> 6 | uStack312 * 0x4000000) ^ (uStack312 >> 0xb | uStack312 * 0x200000) ^ + (uStack312 * 0x80 | uStack312 >> 0x19)) + + ((uVar11 ^ uStack308) & uStack312 ^ uVar11) + uVar12 + puVar2[0x16] + uVar6; + uStack332 = ((uStack328 >> 2 | uStack328 * 0x40000000) ^ + (uStack328 >> 0xd | uStack328 * 0x80000) ^ (uStack328 * 0x400 | uStack328 >> 0x16)) + + ((uStack324 | uStack328) & uVar17 | uStack324 & uStack328) + iVar13; + uStack316 = uVar8 + iVar13; + uVar5 = puVar22[8]; + puVar22[0x15] = uVar16; + puVar22[0x10] = uVar24; + uVar7 = puVar2[0x17]; + uVar1 = uVar24 + uVar1 + + ((uVar16 * 0x8000 | uVar16 >> 0x11) ^ (uVar16 * 0x2000 | uVar16 >> 0x13) ^ uVar16 >> 10) + + ((uVar5 >> 7 | uVar5 << 0x19) ^ (uVar5 << 0xe | uVar5 >> 0x12) ^ uVar5 >> 3); + puVar22[0x17] = uVar1; + iVar13 = ((uStack316 >> 6 | uStack316 * 0x4000000) ^ (uStack316 >> 0xb | uStack316 * 0x200000) ^ + (uStack316 * 0x80 | uStack316 >> 0x19)) + + uVar11 + uVar7 + uVar1 + ((uStack308 ^ uStack312) & uStack316 ^ uStack308); + puVar22[0x16] = uVar6; + puVar22 = puVar22 + 8; + uStack320 = uVar17 + iVar13; + uStack336 = ((uStack332 >> 2 | uStack332 * 0x40000000) ^ + (uStack332 >> 0xd | uStack332 * 0x80000) ^ (uStack332 * 0x400 | uStack332 >> 0x16)) + + ((uStack328 | uStack332) & uStack324 | uStack328 & uStack332) + iVar13; + puVar2 = puVar2 + 8; + } while (auStack304 + 0x30 != puVar22); + puVar9 = ctx->state; + do { + iVar13 = *puVar18; + puVar2 = puVar9 + 1; + puVar18 = (uint32_t *)((int *)puVar18 + 1); + *puVar9 = *puVar9 + iVar13; + puVar9 = puVar2; + } while ((uint32_t *)ctx->buffer != puVar2); + return; +} + + + +void sha224_clone_wrap(mbedtls_sha256_context *dst,mbedtls_sha256_context *src) + +{ + memcpy(dst,src,0x74); + return; +} + + + +void sha224_ctx_free(void *ctx) + +{ + mbedtls_sha256_free((mbedtls_sha256_context *)ctx); + vPortFree(ctx); + return; +} + + + +void * sha224_ctx_alloc(void) + +{ + mbedtls_sha256_context *ctx; + + ctx = (mbedtls_sha256_context *)mycalloc(1,0x74); + if (ctx != (mbedtls_sha256_context *)0x0) { + mbedtls_sha256_init(ctx); + } + return ctx; +} + + + +void sha224_wrap(uchar *input,size_t ilen,uchar *output) + +{ + mbedtls_sha256(input,ilen,output,1); + return; +} + + + +void sha256_wrap(uchar *input,size_t ilen,uchar *output) + +{ + mbedtls_sha256(input,ilen,output,0); + return; +} + + + +void sha224_finish_wrap(mbedtls_sha256_context *ctx,uchar *output) + +{ + uint uVar1; + uint uVar2; + int iVar3; + uchar uStack24; + undefined uStack23; + ushort uStack22; + undefined uStack20; + undefined uStack19; + ushort uStack18; + + uVar1 = ctx->total[0]; + uVar2 = ctx->total[1] << 3; + uStack24 = (uchar)(uVar2 >> 0x18); + uStack23 = (undefined)(uVar2 >> 0x10); + uStack22 = (ushort)(uVar2 >> 8) & 0xff | (ushort)((uVar2 | uVar1 >> 0x1d) << 8); + uStack20 = (undefined)((uVar1 << 3) >> 0x18); + uStack19 = (undefined)((uVar1 << 3) >> 0x10); + uStack18 = (ushort)((uVar1 << 0x13) >> 0x18) | (ushort)(uVar1 << 0xb); + if ((uVar1 & 0x3f) < 0x38) { + iVar3 = 0x38; + } + else { + iVar3 = 0x78; + } + mbedtls_sha256_update(ctx,sha256_padding,iVar3 - (uVar1 & 0x3f)); + mbedtls_sha256_update(ctx,&uStack24,8); + *output = *(uchar *)((int)ctx->state + 3); + output[1] = (uchar)*(undefined2 *)((int)ctx->state + 2); + output[2] = (uchar)(ctx->state[0] >> 8); + output[3] = (uchar)ctx->state[0]; + output[4] = *(uchar *)((int)ctx->state + 7); + output[5] = (uchar)*(undefined2 *)((int)ctx->state + 6); + output[6] = (uchar)(ctx->state[1] >> 8); + output[7] = (uchar)ctx->state[1]; + output[8] = *(uchar *)((int)ctx->state + 0xb); + output[9] = (uchar)*(undefined2 *)((int)ctx->state + 10); + output[10] = (uchar)(ctx->state[2] >> 8); + output[0xb] = (uchar)ctx->state[2]; + output[0xc] = *(uchar *)((int)ctx->state + 0xf); + output[0xd] = (uchar)*(undefined2 *)((int)ctx->state + 0xe); + output[0xe] = (uchar)(ctx->state[3] >> 8); + output[0xf] = (uchar)ctx->state[3]; + output[0x10] = *(uchar *)((int)ctx->state + 0x13); + output[0x11] = (uchar)*(undefined2 *)((int)ctx->state + 0x12); + output[0x12] = (uchar)(ctx->state[4] >> 8); + output[0x13] = (uchar)ctx->state[4]; + output[0x14] = *(uchar *)((int)ctx->state + 0x17); + output[0x15] = (uchar)*(undefined2 *)((int)ctx->state + 0x16); + output[0x16] = (uchar)(ctx->state[5] >> 8); + output[0x17] = (uchar)ctx->state[5]; + output[0x18] = *(uchar *)((int)ctx->state + 0x1b); + output[0x19] = (uchar)*(undefined2 *)((int)ctx->state + 0x1a); + output[0x1a] = (uchar)(ctx->state[6] >> 8); + output[0x1b] = (uchar)ctx->state[6]; + if (ctx->is224 == 0) { + output[0x1c] = *(uchar *)((int)ctx->state + 0x1f); + output[0x1d] = (uchar)*(undefined2 *)((int)ctx->state + 0x1e); + output[0x1e] = (uchar)(ctx->state[7] >> 8); + output[0x1f] = (uchar)ctx->state[7]; + } + return; +} + + + +void sha224_update_wrap(mbedtls_sha256_context *ctx,uchar *input,size_t ilen) + +{ + if (ilen != 0) { + mbedtls_sha256_update(ctx,input,ilen); + return; + } + return; +} + + + +void sha224_starts_wrap(void *ctx) + +{ + mbedtls_sha256_starts((mbedtls_sha256_context *)ctx,1); + return; +} + + + +void sha256_starts_wrap(void *ctx) + +{ + mbedtls_sha256_starts((mbedtls_sha256_context *)ctx,0); + return; +} + + + +oid_sig_alg_t * oid_sig_alg_from_asn1(mbedtls_asn1_buf *oid) + +{ + oid_sig_alg_t *poVar1; + char *__s1; + int iVar2; + size_t __n; + + poVar1 = oid_sig_alg; + while( true ) { + __s1 = (poVar1->descriptor).asn1; + if (__s1 == (char *)0x0) { + return (oid_sig_alg_t *)0x0; + } + __n = (poVar1->descriptor).asn1_len; + if ((__n == oid->len) && (iVar2 = memcmp(__s1,oid->p,__n), iVar2 == 0)) break; + poVar1 = poVar1 + 1; + } + return poVar1; +} + + + +int mbedtls_oid_get_attr_short_name(mbedtls_asn1_buf *oid,char **short_name) + +{ + oid_x520_attr_t *poVar1; + char *__s1; + int iVar2; + size_t __n; + + if (oid == (mbedtls_asn1_buf *)0x0) { + return -0x2e; + } + poVar1 = oid_x520_attr_type; + while( true ) { + __s1 = (poVar1->descriptor).asn1; + if (__s1 == (char *)0x0) { + return -0x2e; + } + __n = (poVar1->descriptor).asn1_len; + if ((__n == oid->len) && (iVar2 = memcmp(__s1,oid->p,__n), iVar2 == 0)) break; + poVar1 = poVar1 + 1; + } + *short_name = poVar1->short_name; + return 0; +} + + + +int mbedtls_oid_get_x509_ext_type(mbedtls_asn1_buf *oid,int *ext_type) + +{ + oid_x509_ext_t *poVar1; + char *__s1; + int iVar2; + size_t __n; + + if (oid == (mbedtls_asn1_buf *)0x0) { + return -0x2e; + } + poVar1 = oid_x509_ext; + while( true ) { + __s1 = (poVar1->descriptor).asn1; + if (__s1 == (char *)0x0) { + return -0x2e; + } + __n = (poVar1->descriptor).asn1_len; + if ((__n == oid->len) && (iVar2 = memcmp(__s1,oid->p,__n), iVar2 == 0)) break; + poVar1 = poVar1 + 1; + } + *ext_type = poVar1->ext_type; + return 0; +} + + + +int mbedtls_oid_get_extended_key_usage(mbedtls_asn1_buf *oid,char **description) + +{ + mbedtls_oid_descriptor_t *pmVar1; + int iVar2; + + if (oid == (mbedtls_asn1_buf *)0x0) { + return -0x2e; + } + pmVar1 = oid_ext_key_usage; + while( true ) { + if (pmVar1->asn1 == (char *)0x0) { + return -0x2e; + } + if ((pmVar1->asn1_len == oid->len) && + (iVar2 = memcmp(pmVar1->asn1,oid->p,pmVar1->asn1_len), iVar2 == 0)) break; + pmVar1 = pmVar1 + 1; + } + *description = pmVar1->description; + return 0; +} + + + +int mbedtls_oid_get_sig_alg_desc(mbedtls_asn1_buf *oid,char **description) + +{ + int iVar1; + oid_sig_alg_t *poVar2; + + if (oid == (mbedtls_asn1_buf *)0x0) { + return -0x2e; + } + poVar2 = oid_sig_alg_from_asn1(oid); + if (poVar2 == (oid_sig_alg_t *)0x0) { + iVar1 = -0x2e; + } + else { + iVar1 = 0; + *description = (poVar2->descriptor).description; + } + return iVar1; +} + + + +int mbedtls_oid_get_sig_alg + (mbedtls_asn1_buf *oid,mbedtls_md_type_t *md_alg,mbedtls_pk_type_t *pk_alg) + +{ + int iVar1; + oid_sig_alg_t *poVar2; + + if (oid == (mbedtls_asn1_buf *)0x0) { + return -0x2e; + } + poVar2 = oid_sig_alg_from_asn1(oid); + if (poVar2 == (oid_sig_alg_t *)0x0) { + iVar1 = -0x2e; + } + else { + *md_alg = poVar2->md_alg; + iVar1 = 0; + *pk_alg = poVar2->pk_alg; + } + return iVar1; +} + + + +int mbedtls_oid_get_pk_alg(mbedtls_asn1_buf *oid,mbedtls_pk_type_t *pk_alg) + +{ + oid_pk_alg_t *poVar1; + char *__s1; + int iVar2; + size_t __n; + + if (oid == (mbedtls_asn1_buf *)0x0) { + return -0x2e; + } + poVar1 = oid_pk_alg; + while( true ) { + __s1 = (poVar1->descriptor).asn1; + if (__s1 == (char *)0x0) { + return -0x2e; + } + __n = (poVar1->descriptor).asn1_len; + if ((__n == oid->len) && (iVar2 = memcmp(__s1,oid->p,__n), iVar2 == 0)) break; + poVar1 = poVar1 + 1; + } + *pk_alg = poVar1->pk_alg; + return 0; +} + + + +int mbedtls_oid_get_ec_grp(mbedtls_asn1_buf *oid,mbedtls_ecp_group_id *grp_id) + +{ + oid_ecp_grp_t *poVar1; + char *__s1; + int iVar2; + size_t __n; + + if (oid == (mbedtls_asn1_buf *)0x0) { + return -0x2e; + } + poVar1 = oid_ecp_grp; + while( true ) { + __s1 = (poVar1->descriptor).asn1; + if (__s1 == (char *)0x0) { + return -0x2e; + } + __n = (poVar1->descriptor).asn1_len; + if ((__n == oid->len) && (iVar2 = memcmp(__s1,oid->p,__n), iVar2 == 0)) break; + poVar1 = poVar1 + 1; + } + *grp_id = poVar1->grp_id; + return 0; +} + + + +int mbedtls_oid_get_md_alg(mbedtls_asn1_buf *oid,mbedtls_md_type_t *md_alg) + +{ + oid_md_alg_t *poVar1; + char *__s1; + int iVar2; + size_t __n; + + if (oid == (mbedtls_asn1_buf *)0x0) { + return -0x2e; + } + poVar1 = oid_md_alg; + while( true ) { + __s1 = (poVar1->descriptor).asn1; + if (__s1 == (char *)0x0) { + return -0x2e; + } + __n = (poVar1->descriptor).asn1_len; + if ((__n == oid->len) && (iVar2 = memcmp(__s1,oid->p,__n), iVar2 == 0)) break; + poVar1 = poVar1 + 1; + } + *md_alg = poVar1->md_alg; + return 0; +} + + + +int mbedtls_oid_get_oid_by_md(mbedtls_md_type_t md_alg,char **oid,size_t *olen) + +{ + undefined3 in_register_00002029; + char *pcVar1; + oid_md_alg_t *poVar2; + + poVar2 = oid_md_alg; + while( true ) { + pcVar1 = (poVar2->descriptor).asn1; + if (pcVar1 == (char *)0x0) { + return -0x2e; + } + if ((uint)poVar2->md_alg == CONCAT31(in_register_00002029,md_alg)) break; + poVar2 = poVar2 + 1; + } + *oid = pcVar1; + *olen = (poVar2->descriptor).asn1_len; + return 0; +} + + + +// WARNING: Variable defined which should be unmapped: aes_ctx + +void pem_aes_decrypt(uchar *aes_iv,uint keylen,uchar *buf,size_t buflen,uchar *pwd,size_t pwdlen) + +{ + uchar *key; + size_t __n; + uchar *puVar1; + uchar *puVar2; + uchar local_1c0 [4]; + uchar md5sum [16]; + uchar aes_key [32]; + mbedtls_md5_context md5_ctx; + mbedtls_aes_context aes_ctx; + + puVar1 = local_1c0; + puVar2 = local_1c0; + mbedtls_aes_init((mbedtls_aes_context *)(md5_ctx.buffer + 0x3c)); + mbedtls_md5_init((mbedtls_md5_context *)(aes_key + 0x1c)); + mbedtls_md5_starts((mbedtls_md5_context *)(aes_key + 0x1c)); + mbedtls_md5_update((mbedtls_md5_context *)(aes_key + 0x1c),pwd,pwdlen); + mbedtls_md5_update((mbedtls_md5_context *)(aes_key + 0x1c),aes_iv,8); + mbedtls_md5_finish((mbedtls_md5_context *)(aes_key + 0x1c),local_1c0); + key = md5sum + 0xc; + if (keylen == 0x10) { + memcpy(key,local_1c0,0x10); + mbedtls_md5_free((mbedtls_md5_context *)(aes_key + 0x1c)); + do { + *puVar1 = '\0'; + puVar1 = puVar1 + 1; + } while (puVar1 != key); + } + else { + memcpy(key,local_1c0,0x10); + mbedtls_md5_starts((mbedtls_md5_context *)(aes_key + 0x1c)); + mbedtls_md5_update((mbedtls_md5_context *)(aes_key + 0x1c),local_1c0,0x10); + mbedtls_md5_update((mbedtls_md5_context *)(aes_key + 0x1c),pwd,pwdlen); + mbedtls_md5_update((mbedtls_md5_context *)(aes_key + 0x1c),aes_iv,8); + mbedtls_md5_finish((mbedtls_md5_context *)(aes_key + 0x1c),local_1c0); + __n = 0x10; + if (keylen != 0x20) { + __n = keylen - 0x10; + } + memcpy(aes_key + 0xc,local_1c0,__n); + mbedtls_md5_free((mbedtls_md5_context *)(aes_key + 0x1c)); + do { + *puVar2 = '\0'; + puVar2 = puVar2 + 1; + } while (puVar2 != key); + } + mbedtls_aes_setkey_dec((mbedtls_aes_context *)(md5_ctx.buffer + 0x3c),key,keylen << 3); + mbedtls_aes_crypt_cbc((mbedtls_aes_context *)(md5_ctx.buffer + 0x3c),0,buflen,aes_iv,buf,buf); + mbedtls_aes_free((mbedtls_aes_context *)(md5_ctx.buffer + 0x3c)); + while (keylen = keylen - 1, keylen != 0xffffffff) { + *key = '\0'; + key = key + 1; + } + return; +} + + + +void mbedtls_pem_init(mbedtls_pem_context *ctx) + +{ + memset(ctx,0,0xc); + return; +} + + + +int mbedtls_pem_read_buffer + (mbedtls_pem_context *ctx,char *header,char *footer,uchar *data,uchar *pwd, + size_t pwdlen,size_t *use_len) + +{ + uchar uVar1; + bool bVar2; + uchar *dst; + uchar *puVar3; + size_t sVar4; + int iVar5; + int iVar6; + uchar *puVar7; + byte bVar8; + uint uVar9; + uint uVar10; + byte *pbVar11; + uint keylen; + uchar *src; + size_t sStack68; + size_t len; + uchar pem_iv [16]; + + if (ctx == (mbedtls_pem_context *)0x0) { + return -0x1480; + } + dst = (uchar *)strstr((char *)data,header); + if (((dst == (uchar *)0x0) || + (puVar3 = (uchar *)strstr((char *)data,footer), puVar3 == (uchar *)0x0)) || (puVar3 <= dst)) { + return -0x1080; + } + sVar4 = strlen(header); + dst = dst + sVar4; + if (*dst == ' ') { + dst = dst + 1; + } + if (*dst == '\r') { + dst = dst + 1; + } + if (*dst != '\n') { + return -0x1080; + } + sVar4 = strlen(footer); + puVar7 = puVar3 + sVar4; + src = dst + 1; + if (*puVar7 == ' ') { + puVar7 = puVar7 + 1; + } + if (*puVar7 == '\r') { + puVar7 = puVar7 + 1; + } + if (*puVar7 == '\n') { + puVar7 = puVar7 + 1; + } + *(uchar **)use_len = puVar7 + -(int)data; + if (((int)(puVar3 + -(int)src) < 0x16) || + (iVar5 = memcmp(src,"Proc-Type: 4,ENCRYPTED",0x16), iVar5 != 0)) { + iVar5 = 0; + bVar2 = false; + } + else { + uVar1 = dst[0x17]; + puVar7 = dst + 0x17; + if (uVar1 == '\r') { + uVar1 = dst[0x18]; + puVar7 = dst + 0x18; + } + if (uVar1 != '\n') { + return -0x1100; + } + dst = puVar7 + 1; + if ((((int)(puVar3 + -(int)dst) < 0xe) || (iVar5 = memcmp(dst,"DEK-Info: AES-",0xe), iVar5 != 0) + ) || ((int)(puVar3 + -(int)dst) < 0x16)) { + return -0x1280; + } + iVar6 = memcmp(dst,"DEK-Info: AES-128-CBC,",0x16); + iVar5 = 5; + if (iVar6 != 0) { + iVar6 = memcmp(dst,"DEK-Info: AES-192-CBC,",0x16); + iVar5 = 6; + if (iVar6 != 0) { + iVar5 = memcmp(dst,"DEK-Info: AES-256-CBC,",0x16); + if (iVar5 != 0) { + return -0x1280; + } + iVar5 = 7; + } + } + if ((int)(puVar3 + -(int)(puVar7 + 0x17)) < 0x20) { + return -0x1200; + } + memset(&len,0,0x10); + keylen = 0; + do { + uVar10 = (uint)puVar7[keylen + 0x17]; + uVar9 = uVar10 - 0x30; + if (9 < (uVar9 & 0xff)) { + if ((uVar10 - 0x41 & 0xff) < 6) { + uVar9 = uVar10 - 0x37; + } + else { + if (5 < (uVar10 - 0x61 & 0xff)) { + return -0x1200; + } + uVar9 = uVar10 - 0x57; + } + } + bVar8 = (byte)uVar9; + if ((keylen & 1) == 0) { + bVar8 = (byte)(uVar9 << 4); + } + pbVar11 = (byte *)((int)&len + (keylen >> 1)); + keylen = keylen + 1; + *pbVar11 = bVar8 | *pbVar11; + } while (keylen != 0x20); + src = puVar7 + 0x38; + if (puVar7[0x37] != '\r') { + src = puVar7 + 0x37; + } + if (*src != '\n') { + return -0x1100; + } + src = src + 1; + bVar2 = true; + } + if (puVar3 <= src) { + return -0x1100; + } + iVar6 = mbedtls_base64_decode((uchar *)0x0,0,&sStack68,src,(size_t)(puVar3 + -(int)src)); + if (iVar6 == -0x2c) { + return -0x112c; + } + dst = (uchar *)mycalloc(1,sStack68); + if (dst == (uchar *)0x0) { + return -0x1180; + } + iVar6 = mbedtls_base64_decode(dst,sStack68,&sStack68,src,(size_t)(puVar3 + -(int)src)); + if (iVar6 != 0) { + vPortFree(dst); + return iVar6 + -0x1100; + } + if (!bVar2) goto LAB_23096ff2; + if (pwd == (uchar *)0x0) { + vPortFree(dst); + return -0x1300; + } + if (iVar5 == 5) { + keylen = 0x10; +LAB_23096f9c: + pem_aes_decrypt((uchar *)&len,keylen,dst,sStack68,pwd,pwdlen); + } + else { + if (iVar5 == 6) { + keylen = 0x18; + goto LAB_23096f9c; + } + if (iVar5 == 7) { + keylen = 0x20; + goto LAB_23096f9c; + } + } + if (((sStack68 < 3) || (*dst != '0')) || (0x83 < dst[1])) { + vPortFree(dst); + return -0x1380; + } +LAB_23096ff2: + ctx->buf = dst; + ctx->buflen = sStack68; + return 0; +} + + + +void mbedtls_pem_free(mbedtls_pem_context *ctx) + +{ + mbedtls_pem_context *pmVar1; + + vPortFree(ctx->buf); + vPortFree(ctx->info); + pmVar1 = ctx + 1; + while (ctx != pmVar1) { + *(undefined *)&ctx->buf = 0; + ctx = (mbedtls_pem_context *)((int)&ctx->buf + 1); + } + return; +} + + + +void mbedtls_md5_init(mbedtls_md5_context *ctx) + +{ + memset(ctx,0,0x58); + return; +} + + + +void mbedtls_md5_free(mbedtls_md5_context *ctx) + +{ + mbedtls_md5_context *pmVar1; + + pmVar1 = ctx + 1; + if (ctx != (mbedtls_md5_context *)0x0) { + while (ctx != pmVar1) { + *(undefined *)ctx->total = 0; + ctx = (mbedtls_md5_context *)((int)ctx->total + 1); + } + } + return; +} + + + +void mbedtls_md5_clone(mbedtls_md5_context *dst,mbedtls_md5_context *src) + +{ + memcpy(dst,src,0x58); + return; +} + + + +void mbedtls_md5_starts(mbedtls_md5_context *ctx) + +{ + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xefcdab89; + ctx->state[2] = 0x98badcfe; + ctx->total[0] = 0; + ctx->total[1] = 0; + ctx->state[3] = 0x10325476; + return; +} + + + +void mbedtls_md5_process(mbedtls_md5_context *ctx,uchar *data) + +{ + int iVar1; + int iVar2; + int iVar3; + int iVar4; + int iVar5; + int iVar6; + int iVar7; + int iVar8; + int iVar9; + int iVar10; + int iVar11; + int iVar12; + int iVar13; + int iVar14; + int iVar15; + int iVar16; + uint uVar17; + uint uVar18; + uint uVar19; + uint uVar20; + uint uVar21; + uint uVar22; + uint uVar23; + uint uVar24; + uint uVar25; + + iVar1 = *(int *)data; + iVar2 = *(int *)(data + 4); + iVar3 = *(int *)(data + 0x10); + iVar4 = *(int *)(data + 8); + iVar5 = *(int *)(data + 0xc); + iVar6 = *(int *)(data + 0x14); + iVar7 = *(int *)(data + 0x18); + iVar8 = *(int *)(data + 0x24); + iVar9 = *(int *)(data + 0x1c); + iVar10 = *(int *)(data + 0x20); + iVar11 = *(int *)(data + 0x2c); + iVar12 = *(int *)(data + 0x28); + iVar13 = *(int *)(data + 0x30); + uVar19 = ctx->state[3]; + iVar14 = *(int *)(data + 0x34); + iVar15 = *(int *)(data + 0x38); + iVar16 = *(int *)(data + 0x3c); + uVar17 = ctx->state[2]; + uVar18 = ctx->state[1]; + uVar20 = ((uVar17 ^ uVar19) & uVar18 ^ uVar19) + ctx->state[0] + 0xd76aa478 + iVar1; + uVar21 = (uVar20 >> 0x19 | uVar20 * 0x80) + uVar18; + uVar20 = ((uVar18 ^ uVar17) & uVar21 ^ uVar17) + uVar19 + 0xe8c7b756 + iVar2; + uVar23 = (uVar20 >> 0x14 | uVar20 * 0x1000) + uVar21; + uVar20 = ((uVar18 ^ uVar21) & uVar23 ^ uVar18) + uVar17 + 0x242070db + iVar4; + uVar22 = (uVar20 * 0x20000 | uVar20 >> 0xf) + uVar23; + uVar20 = ((uVar21 ^ uVar23) & uVar22 ^ uVar21) + uVar18 + 0xc1bdceee + iVar5; + uVar20 = (uVar20 * 0x400000 | uVar20 >> 10) + uVar22; + uVar21 = ((uVar23 ^ uVar22) & uVar20 ^ uVar23) + iVar3 + -0xa83f051 + uVar21; + uVar21 = (uVar21 >> 0x19 | uVar21 * 0x80) + uVar20; + uVar23 = ((uVar22 ^ uVar20) & uVar21 ^ uVar22) + iVar6 + 0x4787c62a + uVar23; + uVar23 = (uVar23 >> 0x14 | uVar23 * 0x1000) + uVar21; + uVar22 = ((uVar20 ^ uVar21) & uVar23 ^ uVar20) + iVar7 + -0x57cfb9ed + uVar22; + uVar22 = (uVar22 * 0x20000 | uVar22 >> 0xf) + uVar23; + uVar20 = ((uVar21 ^ uVar23) & uVar22 ^ uVar21) + iVar9 + -0x2b96aff + uVar20; + uVar20 = (uVar20 * 0x400000 | uVar20 >> 10) + uVar22; + uVar21 = ((uVar23 ^ uVar22) & uVar20 ^ uVar23) + iVar10 + 0x698098d8 + uVar21; + uVar21 = (uVar21 >> 0x19 | uVar21 * 0x80) + uVar20; + uVar23 = ((uVar22 ^ uVar20) & uVar21 ^ uVar22) + iVar8 + -0x74bb0851 + uVar23; + uVar23 = (uVar23 >> 0x14 | uVar23 * 0x1000) + uVar21; + uVar22 = ((uVar20 ^ uVar21) & uVar23 ^ uVar20) + iVar12 + -0xa44f + uVar22; + uVar22 = (uVar22 * 0x20000 | uVar22 >> 0xf) + uVar23; + uVar20 = ((uVar21 ^ uVar23) & uVar22 ^ uVar21) + iVar11 + -0x76a32842 + uVar20; + uVar20 = (uVar20 * 0x400000 | uVar20 >> 10) + uVar22; + uVar21 = ((uVar23 ^ uVar22) & uVar20 ^ uVar23) + iVar13 + 0x6b901122 + uVar21; + uVar21 = (uVar21 >> 0x19 | uVar21 * 0x80) + uVar20; + uVar23 = ((uVar22 ^ uVar20) & uVar21 ^ uVar22) + iVar14 + -0x2678e6d + uVar23; + uVar23 = (uVar23 >> 0x14 | uVar23 * 0x1000) + uVar21; + uVar22 = ((uVar20 ^ uVar21) & uVar23 ^ uVar20) + iVar15 + -0x5986bc72 + uVar22; + uVar22 = (uVar22 * 0x20000 | uVar22 >> 0xf) + uVar23; + uVar20 = ((uVar21 ^ uVar23) & uVar22 ^ uVar21) + iVar16 + 0x49b40821 + uVar20; + uVar20 = (uVar20 * 0x400000 | uVar20 >> 10) + uVar22; + uVar21 = ((uVar22 ^ uVar20) & uVar23 ^ uVar22) + iVar2 + -0x9e1da9e + uVar21; + uVar21 = (uVar21 >> 0x1b | uVar21 * 0x20) + uVar20; + uVar23 = ((uVar20 ^ uVar21) & uVar22 ^ uVar20) + iVar7 + -0x3fbf4cc0 + uVar23; + uVar23 = (uVar23 >> 0x17 | uVar23 * 0x200) + uVar21; + uVar22 = ((uVar21 ^ uVar23) & uVar20 ^ uVar21) + iVar11 + 0x265e5a51 + uVar22; + uVar22 = (uVar22 >> 0x12 | uVar22 * 0x4000) + uVar23; + uVar20 = ((uVar23 ^ uVar22) & uVar21 ^ uVar23) + iVar1 + -0x16493856 + uVar20; + uVar20 = (uVar20 * 0x100000 | uVar20 >> 0xc) + uVar22; + uVar21 = ((uVar22 ^ uVar20) & uVar23 ^ uVar22) + iVar6 + -0x29d0efa3 + uVar21; + uVar21 = (uVar21 >> 0x1b | uVar21 * 0x20) + uVar20; + uVar23 = ((uVar20 ^ uVar21) & uVar22 ^ uVar20) + iVar12 + 0x2441453 + uVar23; + uVar23 = (uVar23 >> 0x17 | uVar23 * 0x200) + uVar21; + uVar22 = ((uVar21 ^ uVar23) & uVar20 ^ uVar21) + iVar16 + -0x275e197f + uVar22; + uVar22 = (uVar22 >> 0x12 | uVar22 * 0x4000) + uVar23; + uVar20 = ((uVar23 ^ uVar22) & uVar21 ^ uVar23) + iVar3 + -0x182c0438 + uVar20; + uVar20 = (uVar20 * 0x100000 | uVar20 >> 0xc) + uVar22; + uVar21 = ((uVar22 ^ uVar20) & uVar23 ^ uVar22) + iVar8 + 0x21e1cde6 + uVar21; + uVar21 = (uVar21 >> 0x1b | uVar21 * 0x20) + uVar20; + uVar23 = ((uVar20 ^ uVar21) & uVar22 ^ uVar20) + iVar15 + -0x3cc8f82a + uVar23; + uVar23 = (uVar23 >> 0x17 | uVar23 * 0x200) + uVar21; + uVar22 = ((uVar21 ^ uVar23) & uVar20 ^ uVar21) + iVar5 + -0xb2af279 + uVar22; + uVar22 = (uVar22 >> 0x12 | uVar22 * 0x4000) + uVar23; + uVar20 = ((uVar23 ^ uVar22) & uVar21 ^ uVar23) + iVar10 + 0x455a14ed + uVar20; + uVar20 = (uVar20 * 0x100000 | uVar20 >> 0xc) + uVar22; + uVar21 = ((uVar22 ^ uVar20) & uVar23 ^ uVar22) + iVar14 + -0x561c16fb + uVar21; + uVar21 = (uVar21 >> 0x1b | uVar21 * 0x20) + uVar20; + uVar23 = ((uVar20 ^ uVar21) & uVar22 ^ uVar20) + iVar4 + -0x3105c08 + uVar23; + uVar24 = (uVar23 >> 0x17 | uVar23 * 0x200) + uVar21; + uVar22 = ((uVar21 ^ uVar24) & uVar20 ^ uVar21) + iVar9 + 0x676f02d9 + uVar22; + uVar23 = (uVar22 >> 0x12 | uVar22 * 0x4000) + uVar24; + uVar20 = ((uVar24 ^ uVar23) & uVar21 ^ uVar24) + iVar13 + -0x72d5b376 + uVar20; + uVar20 = (uVar20 * 0x100000 | uVar20 >> 0xc) + uVar23; + uVar21 = (uVar24 ^ uVar23 ^ uVar20) + iVar6 + -0x5c6be + uVar21; + uVar21 = (uVar21 >> 0x1c | uVar21 * 0x10) + uVar20; + uVar22 = (uVar23 ^ uVar20 ^ uVar21) + uVar24 + iVar10 + -0x788e097f; + uVar22 = (uVar22 >> 0x15 | uVar22 * 0x800) + uVar21; + uVar23 = (uVar20 ^ uVar21 ^ uVar22) + uVar23 + iVar11 + 0x6d9d6122; + uVar24 = (uVar23 >> 0x10 | uVar23 * 0x10000) + uVar22; + uVar20 = (uVar21 ^ uVar22 ^ uVar24) + uVar20 + iVar15 + -0x21ac7f4; + uVar23 = (uVar20 * 0x800000 | uVar20 >> 9) + uVar24; + uVar20 = (uVar22 ^ uVar24 ^ uVar23) + iVar2 + -0x5b4115bc + uVar21; + uVar21 = (uVar20 >> 0x1c | uVar20 * 0x10) + uVar23; + uVar20 = (uVar24 ^ uVar23 ^ uVar21) + uVar22 + iVar3 + 0x4bdecfa9; + uVar20 = (uVar20 >> 0x15 | uVar20 * 0x800) + uVar21; + uVar22 = (uVar23 ^ uVar21 ^ uVar20) + iVar9 + -0x944b4a0 + uVar24; + uVar24 = (uVar22 >> 0x10 | uVar22 * 0x10000) + uVar20; + uVar22 = (uVar21 ^ uVar20 ^ uVar24) + uVar23 + iVar12 + -0x41404390; + uVar22 = (uVar22 * 0x800000 | uVar22 >> 9) + uVar24; + uVar21 = (uVar20 ^ uVar24 ^ uVar22) + uVar21 + iVar14 + 0x289b7ec6; + uVar23 = (uVar21 >> 0x1c | uVar21 * 0x10) + uVar22; + uVar20 = (uVar24 ^ uVar22 ^ uVar23) + iVar1 + -0x155ed806 + uVar20; + uVar20 = (uVar20 >> 0x15 | uVar20 * 0x800) + uVar23; + uVar21 = (uVar22 ^ uVar23 ^ uVar20) + iVar5 + -0x2b10cf7b + uVar24; + uVar24 = (uVar21 >> 0x10 | uVar21 * 0x10000) + uVar20; + uVar21 = (uVar23 ^ uVar20 ^ uVar24) + uVar22 + iVar7 + 0x4881d05; + uVar21 = (uVar21 * 0x800000 | uVar21 >> 9) + uVar24; + uVar22 = (uVar20 ^ uVar24 ^ uVar21) + iVar8 + -0x262b2fc7 + uVar23; + uVar23 = (uVar22 >> 0x1c | uVar22 * 0x10) + uVar21; + uVar20 = (uVar24 ^ uVar21 ^ uVar23) + uVar20 + iVar13 + -0x1924661b; + uVar22 = (uVar20 >> 0x15 | uVar20 * 0x800) + uVar23; + uVar20 = (uVar21 ^ uVar23 ^ uVar22) + uVar24 + iVar16 + 0x1fa27cf8; + uVar20 = (uVar20 >> 0x10 | uVar20 * 0x10000) + uVar22; + uVar21 = (uVar23 ^ uVar22 ^ uVar20) + iVar4 + -0x3b53a99b + uVar21; + uVar21 = (uVar21 * 0x800000 | uVar21 >> 9) + uVar20; + uVar23 = ((~uVar22 | uVar21) ^ uVar20) + uVar23 + iVar1 + -0xbd6ddbc; + uVar24 = (uVar23 >> 0x1a | uVar23 * 0x40) + uVar21; + uVar22 = ((~uVar20 | uVar24) ^ uVar21) + uVar22 + iVar9 + 0x432aff97; + uVar23 = (uVar22 >> 0x16 | uVar22 * 0x400) + uVar24; + uVar20 = ((~uVar21 | uVar23) ^ uVar24) + iVar15 + -0x546bdc59 + uVar20; + uVar20 = (uVar20 >> 0x11 | uVar20 * 0x8000) + uVar23; + uVar21 = ((~uVar24 | uVar20) ^ uVar23) + iVar6 + -0x36c5fc7 + uVar21; + uVar22 = (uVar21 * 0x200000 | uVar21 >> 0xb) + uVar20; + uVar21 = ((~uVar23 | uVar22) ^ uVar20) + iVar13 + 0x655b59c3 + uVar24; + uVar24 = (uVar21 >> 0x1a | uVar21 * 0x40) + uVar22; + uVar21 = ((~uVar20 | uVar24) ^ uVar22) + uVar23 + iVar5 + -0x70f3336e; + uVar21 = (uVar21 >> 0x16 | uVar21 * 0x400) + uVar24; + uVar20 = ((~uVar22 | uVar21) ^ uVar24) + iVar12 + -0x100b83 + uVar20; + uVar20 = (uVar20 >> 0x11 | uVar20 * 0x8000) + uVar21; + uVar22 = ((~uVar24 | uVar20) ^ uVar21) + iVar2 + -0x7a7ba22f + uVar22; + uVar22 = (uVar22 * 0x200000 | uVar22 >> 0xb) + uVar20; + uVar23 = ((~uVar21 | uVar22) ^ uVar20) + iVar10 + 0x6fa87e4f + uVar24; + uVar25 = (uVar23 >> 0x1a | uVar23 * 0x40) + uVar22; + uVar21 = ((~uVar20 | uVar25) ^ uVar22) + uVar21 + iVar16 + -0x1d31920; + uVar24 = (uVar21 >> 0x16 | uVar21 * 0x400) + uVar25; + uVar20 = ((~uVar22 | uVar24) ^ uVar25) + iVar7 + -0x5cfebcec + uVar20; + uVar20 = (uVar20 >> 0x11 | uVar20 * 0x8000) + uVar24; + uVar21 = ((~uVar25 | uVar20) ^ uVar24) + iVar14 + 0x4e0811a1 + uVar22; + uVar23 = (uVar21 * 0x200000 | uVar21 >> 0xb) + uVar20; + uVar21 = ((~uVar24 | uVar23) ^ uVar20) + uVar25 + iVar3 + -0x8ac817e; + uVar22 = (uVar21 >> 0x1a | uVar21 * 0x40) + uVar23; + uVar21 = ((~uVar20 | uVar22) ^ uVar23) + uVar24 + iVar11 + -0x42c50dcb; + uVar21 = (uVar21 >> 0x16 | uVar21 * 0x400) + uVar22; + uVar20 = ((~uVar23 | uVar21) ^ uVar22) + uVar20 + iVar4 + 0x2ad7d2bb; + uVar20 = (uVar20 >> 0x11 | uVar20 * 0x8000) + uVar21; + uVar23 = ((~uVar22 | uVar20) ^ uVar21) + uVar23 + iVar8 + -0x14792c6f; + ctx->state[0] = ctx->state[0] + uVar22; + ctx->state[1] = uVar18 + uVar20 + (uVar23 >> 0xb | uVar23 * 0x200000); + ctx->state[2] = uVar20 + uVar17; + ctx->state[3] = uVar21 + uVar19; + return; +} + + + +void mbedtls_md5_update(mbedtls_md5_context *ctx,uchar *input,size_t ilen) + +{ + size_t __n; + uint uVar1; + uint uVar2; + uint __n_00; + + uVar2 = ctx->total[0] & 0x3f; + uVar1 = ctx->total[0] + ilen; + ctx->total[0] = uVar1; + if (uVar1 < ilen) { + ctx->total[1] = ctx->total[1] + 1; + } + uVar1 = ilen; + if ((uVar2 != 0) && (__n_00 = 0x40 - uVar2, __n_00 <= ilen)) { + memcpy(ctx->buffer + uVar2,input,__n_00); + ilen = (ilen - 0x40) + uVar2; + mbedtls_md5_process(ctx,ctx->buffer); + input = input + __n_00; + uVar2 = 0; + uVar1 = ilen; + } + while (0x3f < ilen) { + mbedtls_md5_process(ctx,input + (uVar1 - ilen)); + ilen = ilen - 0x40; + } + __n = (uVar1 >> 6) * -0x40 + uVar1; + if (__n == 0) { + return; + } + memcpy(ctx->buffer + uVar2,input + (uVar1 & 0xffffffc0),__n); + return; +} + + + +void mbedtls_md5_update(mbedtls_md5_context *ctx,uchar *input,size_t ilen) + +{ + if (ilen != 0) { + mbedtls_md5_update(ctx,input,ilen); + return; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void mbedtls_md5_finish(mbedtls_md5_context *ctx,uchar *output) + +{ + uint uVar1; + int iVar2; + int iStack24; + uchar msglen [8]; + + uVar1 = ctx->total[0]; + msglen._0_4_ = ctx->total[1] << 3 | uVar1 >> 0x1d; + iStack24 = uVar1 << 3; + if ((uVar1 & 0x3f) < 0x38) { + iVar2 = 0x38; + } + else { + iVar2 = 0x78; + } + mbedtls_md5_update(ctx,md5_padding,iVar2 - (uVar1 & 0x3f)); + mbedtls_md5_update(ctx,(uchar *)&iStack24,8); + *output = (uchar)ctx->state[0]; + output[1] = (uchar)(ctx->state[0] >> 8); + output[2] = (uchar)*(undefined2 *)((int)ctx->state + 2); + output[3] = *(uchar *)((int)ctx->state + 3); + output[4] = (uchar)ctx->state[1]; + output[5] = (uchar)(ctx->state[1] >> 8); + output[6] = (uchar)*(undefined2 *)((int)ctx->state + 6); + output[7] = *(uchar *)((int)ctx->state + 7); + output[8] = (uchar)ctx->state[2]; + output[9] = (uchar)(ctx->state[2] >> 8); + output[10] = (uchar)*(undefined2 *)((int)ctx->state + 10); + output[0xb] = *(uchar *)((int)ctx->state + 0xb); + output[0xc] = (uchar)ctx->state[3]; + output[0xd] = (uchar)(ctx->state[3] >> 8); + output[0xe] = (uchar)*(undefined2 *)((int)ctx->state + 0xe); + output[0xf] = *(uchar *)((int)ctx->state + 0xf); + return; +} + + + +void mbedtls_md5(uchar *input,size_t ilen,uchar *output) + +{ + undefined auStack104 [4]; + mbedtls_md5_context ctx; + + mbedtls_md5_init((mbedtls_md5_context *)auStack104); + mbedtls_md5_starts((mbedtls_md5_context *)auStack104); + mbedtls_md5_update((mbedtls_md5_context *)auStack104,input,ilen); + mbedtls_md5_finish((mbedtls_md5_context *)auStack104,output); + mbedtls_md5_free((mbedtls_md5_context *)auStack104); + return; +} + + + +void mbedtls_sha1_init(mbedtls_sha1_context *ctx) + +{ + memset(ctx,0,0x5c); + return; +} + + + +void mbedtls_sha1_free(mbedtls_sha1_context *ctx) + +{ + mbedtls_sha1_context *pmVar1; + + pmVar1 = ctx + 1; + if (ctx != (mbedtls_sha1_context *)0x0) { + while (ctx != pmVar1) { + *(undefined *)ctx->total = 0; + ctx = (mbedtls_sha1_context *)((int)ctx->total + 1); + } + } + return; +} + + + +void mbedtls_sha1_clone(mbedtls_sha1_context *dst,mbedtls_sha1_context *src) + +{ + memcpy(dst,src,0x5c); + return; +} + + + +void mbedtls_sha1_starts(mbedtls_sha1_context *ctx) + +{ + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xefcdab89; + ctx->state[2] = 0x98badcfe; + ctx->state[3] = 0x10325476; + ctx->total[0] = 0; + ctx->total[1] = 0; + ctx->state[4] = 0xc3d2e1f0; + return; +} + + + +void mbedtls_sha1_process(mbedtls_sha1_context *ctx,uchar *data) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + uint uVar4; + uint uVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint uVar9; + uint uVar10; + uint uVar11; + uint32_t uVar12; + uint uVar13; + uint uVar14; + uint uVar15; + uint uVar16; + uint uVar17; + uint uVar18; + uint uVar19; + uint uVar20; + uint uVar21; + uint uVar22; + uint uVar23; + uint uVar24; + uint uVar25; + uint uVar26; + uint uVar27; + uint uVar28; + + uVar8 = (uint)*data << 0x18 | (uint)data[1] << 0x10 | (uint)data[3] | (uint)data[2] << 8; + uVar10 = (uint)data[4] << 0x18 | (uint)data[5] << 0x10 | (uint)data[7] | (uint)data[6] << 8; + uVar9 = (uint)data[8] << 0x18 | (uint)data[9] << 0x10 | (uint)data[0xb] | (uint)data[10] << 8; + uVar1 = (uint)data[0xc] << 0x18 | (uint)data[0xd] << 0x10 | (uint)data[0xf] | (uint)data[0xe] << 8 + ; + uVar27 = (uint)data[0x10] << 0x18 | (uint)data[0x11] << 0x10 | (uint)data[0x13] | + (uint)data[0x12] << 8; + uVar25 = (uint)data[0x14] << 0x18 | (uint)data[0x15] << 0x10 | (uint)data[0x17] | + (uint)data[0x16] << 8; + uVar14 = (uint)data[0x18] << 0x18 | (uint)data[0x19] << 0x10 | (uint)data[0x1b] | + (uint)data[0x1a] << 8; + uVar20 = (uint)data[0x1c] << 0x18 | (uint)data[0x1d] << 0x10 | (uint)data[0x1f] | + (uint)data[0x1e] << 8; + uVar28 = (uint)data[0x20] << 0x18 | (uint)data[0x21] << 0x10 | (uint)data[0x23] | + (uint)data[0x22] << 8; + uVar26 = (uint)data[0x24] << 0x18 | (uint)data[0x25] << 0x10 | (uint)data[0x27] | + (uint)data[0x26] << 8; + uVar2 = (uint)data[0x28] << 0x18 | (uint)data[0x29] << 0x10 | (uint)data[0x2b] | + (uint)data[0x2a] << 8; + uVar13 = (uint)data[0x2c] << 0x18 | (uint)data[0x2d] << 0x10 | (uint)data[0x2f] | + (uint)data[0x2e] << 8; + uVar11 = (uint)data[0x30] << 0x18 | (uint)data[0x31] << 0x10 | (uint)data[0x33] | + (uint)data[0x32] << 8; + uVar16 = ctx->state[2]; + uVar15 = ctx->state[0]; + uVar5 = (uint)data[0x34] << 0x18 | (uint)data[0x35] << 0x10 | (uint)data[0x37] | + (uint)data[0x36] << 8; + uVar4 = (uint)data[0x38] << 0x18 | (uint)data[0x39] << 0x10 | (uint)data[0x3b] | + (uint)data[0x3a] << 8; + uVar3 = (uint)data[0x3c] << 0x18 | (uint)data[0x3d] << 0x10 | (uint)data[0x3f] | + (uint)data[0x3e] << 8; + uVar6 = (uVar15 << 5 | uVar15 >> 0x1b) + ctx->state[4] + 0x5a827999 + + ((uVar16 ^ ctx->state[3]) & ctx->state[1] ^ ctx->state[3]) + uVar8; + uVar17 = ctx->state[1] << 0x1e | ctx->state[1] >> 2; + uVar18 = (uVar6 * 0x20 | uVar6 >> 0x1b) + + ((uVar16 ^ uVar17) & uVar15 ^ uVar16) + ctx->state[3] + 0x5a827999 + uVar10; + uVar23 = uVar15 << 0x1e | uVar15 >> 2; + uVar7 = uVar6 * 0x40000000 | uVar6 >> 2; + uVar6 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar17 ^ uVar23) & uVar6 ^ uVar17) + uVar16 + 0x5a827999 + uVar9; + uVar19 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar18 = (uVar6 * 0x20 | uVar6 >> 0x1b) + + ((uVar23 ^ uVar7) & uVar18 ^ uVar23) + uVar17 + 0x5a827999 + uVar1; + uVar21 = uVar6 * 0x40000000 | uVar6 >> 2; + uVar17 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar7 ^ uVar19) & uVar6 ^ uVar7) + uVar23 + 0x5a827999 + uVar27; + uVar23 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + ((uVar19 ^ uVar21) & uVar18 ^ uVar19) + uVar25 + 0x5a827999 + uVar7; + uVar6 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar7 = (uVar23 * 0x20 | uVar23 >> 0x1b) + + ((uVar21 ^ uVar6) & uVar17 ^ uVar21) + uVar14 + 0x5a827999 + uVar19; + uVar24 = uVar23 * 0x40000000 | uVar23 >> 2; + uVar19 = (uVar7 * 0x20 | uVar7 >> 0x1b) + + ((uVar6 ^ uVar18) & uVar23 ^ uVar6) + uVar21 + uVar20 + 0x5a827999; + uVar17 = uVar7 * 0x40000000 | uVar7 >> 2; + uVar7 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + ((uVar18 ^ uVar24) & uVar7 ^ uVar18) + uVar28 + 0x5a827999 + uVar6; + uVar23 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar6 = (uVar7 * 0x20 | uVar7 >> 0x1b) + + ((uVar24 ^ uVar17) & uVar19 ^ uVar24) + uVar18 + uVar26 + 0x5a827999; + uVar22 = uVar7 * 0x40000000 | uVar7 >> 2; + uVar19 = (uVar6 * 0x20 | uVar6 >> 0x1b) + + ((uVar17 ^ uVar23) & uVar7 ^ uVar17) + uVar2 + 0x5a827999 + uVar24; + uVar18 = uVar6 * 0x40000000 | uVar6 >> 2; + uVar7 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + ((uVar23 ^ uVar22) & uVar6 ^ uVar23) + uVar17 + uVar13 + 0x5a827999; + uVar21 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar6 = (uVar7 * 0x20 | uVar7 >> 0x1b) + + ((uVar22 ^ uVar18) & uVar19 ^ uVar22) + uVar11 + 0x5a827999 + uVar23; + uVar17 = uVar7 * 0x40000000 | uVar7 >> 2; + uVar19 = (uVar6 * 0x20 | uVar6 >> 0x1b) + + ((uVar18 ^ uVar21) & uVar7 ^ uVar18) + uVar22 + uVar5 + 0x5a827999; + uVar7 = uVar6 * 0x40000000 | uVar6 >> 2; + uVar23 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + ((uVar21 ^ uVar17) & uVar6 ^ uVar21) + uVar4 + 0x5a827999 + uVar18; + uVar22 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar6 = uVar8 ^ uVar9 ^ uVar28 ^ uVar5; + uVar18 = (uVar23 * 0x20 | uVar23 >> 0x1b) + + ((uVar17 ^ uVar7) & uVar19 ^ uVar17) + uVar21 + uVar3 + 0x5a827999; + uVar8 = uVar6 >> 0x1f | uVar6 << 1; + uVar6 = uVar10 ^ uVar1 ^ uVar26 ^ uVar4; + uVar19 = uVar23 * 0x40000000 | uVar23 >> 2; + uVar10 = uVar6 >> 0x1f | uVar6 << 1; + uVar17 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar7 ^ uVar22) & uVar23 ^ uVar7) + uVar8 + 0x5a827999 + uVar17; + uVar21 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar9 = uVar9 ^ uVar27 ^ uVar2 ^ uVar3; + uVar6 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + ((uVar22 ^ uVar19) & uVar18 ^ uVar22) + uVar7 + uVar10 + 0x5a827999; + uVar9 = uVar9 >> 0x1f | uVar9 << 1; + uVar1 = uVar1 ^ uVar25 ^ uVar13 ^ uVar8; + uVar23 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar1 = uVar1 >> 0x1f | uVar1 << 1; + uVar18 = (uVar6 * 0x20 | uVar6 >> 0x1b) + + ((uVar19 ^ uVar21) & uVar17 ^ uVar19) + uVar9 + 0x5a827999 + uVar22; + uVar17 = uVar27 ^ uVar14 ^ uVar11 ^ uVar10; + uVar7 = uVar6 * 0x40000000 | uVar6 >> 2; + uVar27 = uVar17 >> 0x1f | uVar17 << 1; + uVar17 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar21 ^ uVar23) & uVar6 ^ uVar21) + uVar1 + 0x5a827999 + uVar19; + uVar6 = uVar25 ^ uVar20 ^ uVar5 ^ uVar9; + uVar19 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar24 = uVar6 >> 0x1f | uVar6 << 1; + uVar21 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar23 ^ uVar7 ^ uVar18) + uVar21 + uVar27 + 0x6ed9eba1; + uVar6 = uVar14 ^ uVar28 ^ uVar4 ^ uVar1; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar17 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar7 ^ uVar19 ^ uVar17) + uVar24 + 0x6ed9eba1 + uVar23; + uVar14 = uVar6 >> 0x1f | uVar6 << 1; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar6 = uVar20 ^ uVar26 ^ uVar3 ^ uVar27; + uVar6 = uVar6 >> 0x1f | uVar6 << 1; + uVar21 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar19 ^ uVar18 ^ uVar21) + uVar14 + 0x6ed9eba1 + uVar7; + uVar7 = uVar28 ^ uVar2 ^ uVar8 ^ uVar24; + uVar20 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar28 = uVar7 >> 0x1f | uVar7 << 1; + uVar7 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar18 ^ uVar23 ^ uVar17) + uVar19 + uVar6 + 0x6ed9eba1; + uVar17 = uVar26 ^ uVar13 ^ uVar10 ^ uVar14; + uVar22 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar26 = uVar17 >> 0x1f | uVar17 << 1; + uVar17 = (uVar7 * 0x20 | uVar7 >> 0x1b) + + (uVar23 ^ uVar20 ^ uVar21) + uVar18 + uVar28 + 0x6ed9eba1; + uVar2 = uVar2 ^ uVar11 ^ uVar9 ^ uVar6; + uVar19 = uVar7 * 0x40000000 | uVar7 >> 2; + uVar21 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar20 ^ uVar22 ^ uVar7) + uVar23 + uVar26 + 0x6ed9eba1; + uVar2 = uVar2 >> 0x1f | uVar2 << 1; + uVar7 = uVar13 ^ uVar5 ^ uVar1 ^ uVar28; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar13 = uVar7 >> 0x1f | uVar7 << 1; + uVar20 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar22 ^ uVar19 ^ uVar17) + uVar2 + 0x6ed9eba1 + uVar20; + uVar7 = uVar11 ^ uVar4 ^ uVar27 ^ uVar26; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar11 = uVar7 >> 0x1f | uVar7 << 1; + uVar17 = (uVar20 * 0x20 | uVar20 >> 0x1b) + + (uVar19 ^ uVar18 ^ uVar21) + uVar13 + 0x6ed9eba1 + uVar22; + uVar5 = uVar5 ^ uVar3 ^ uVar24 ^ uVar2; + uVar22 = uVar20 * 0x40000000 | uVar20 >> 2; + uVar5 = uVar5 >> 0x1f | uVar5 << 1; + uVar7 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar18 ^ uVar23 ^ uVar20) + uVar19 + uVar11 + 0x6ed9eba1; + uVar4 = uVar4 ^ uVar8 ^ uVar14 ^ uVar13; + uVar20 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar4 = uVar4 >> 0x1f | uVar4 << 1; + uVar17 = (uVar7 * 0x20 | uVar7 >> 0x1b) + (uVar23 ^ uVar22 ^ uVar17) + uVar18 + uVar5 + 0x6ed9eba1 + ; + uVar3 = uVar3 ^ uVar10 ^ uVar6 ^ uVar11; + uVar19 = uVar7 * 0x40000000 | uVar7 >> 2; + uVar3 = uVar3 >> 0x1f | uVar3 << 1; + uVar21 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar22 ^ uVar20 ^ uVar7) + uVar23 + uVar4 + 0x6ed9eba1; + uVar7 = uVar8 ^ uVar9 ^ uVar28 ^ uVar5; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar17 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar20 ^ uVar19 ^ uVar17) + uVar3 + 0x6ed9eba1 + uVar22; + uVar7 = uVar7 >> 0x1f | uVar7 << 1; + uVar8 = uVar10 ^ uVar1 ^ uVar26 ^ uVar4; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar10 = uVar8 >> 0x1f | uVar8 << 1; + uVar21 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar19 ^ uVar18 ^ uVar21) + uVar7 + 0x6ed9eba1 + uVar20; + uVar8 = uVar9 ^ uVar27 ^ uVar2 ^ uVar3; + uVar20 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar8 = uVar8 >> 0x1f | uVar8 << 1; + uVar17 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar18 ^ uVar23 ^ uVar17) + uVar19 + uVar10 + 0x6ed9eba1; + uVar1 = uVar1 ^ uVar24 ^ uVar13 ^ uVar7; + uVar22 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar9 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar23 ^ uVar20 ^ uVar21) + uVar18 + uVar8 + 0x6ed9eba1; + uVar1 = uVar1 >> 0x1f | uVar1 << 1; + uVar19 = uVar27 ^ uVar14 ^ uVar11 ^ uVar10; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar21 = (uVar9 * 0x20 | uVar9 >> 0x1b) + (uVar20 ^ uVar22 ^ uVar17) + uVar1 + 0x6ed9eba1 + uVar23 + ; + uVar27 = uVar19 >> 0x1f | uVar19 << 1; + uVar19 = uVar24 ^ uVar6 ^ uVar5 ^ uVar8; + uVar17 = uVar9 * 0x40000000 | uVar9 >> 2; + uVar25 = uVar19 >> 0x1f | uVar19 << 1; + uVar19 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar22 ^ uVar18 ^ uVar9) + uVar27 + 0x6ed9eba1 + uVar20; + uVar9 = uVar14 ^ uVar28 ^ uVar4 ^ uVar1; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar14 = uVar9 >> 0x1f | uVar9 << 1; + uVar20 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar18 ^ uVar17 ^ uVar21) + uVar22 + uVar25 + 0x6ed9eba1; + uVar6 = uVar6 ^ uVar26 ^ uVar3 ^ uVar27; + uVar21 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar6 = uVar6 >> 0x1f | uVar6 << 1; + uVar9 = (uVar20 * 0x20 | uVar20 >> 0x1b) + + (uVar17 ^ uVar23 ^ uVar19) + uVar14 + 0x6ed9eba1 + uVar18; + uVar18 = uVar28 ^ uVar2 ^ uVar7 ^ uVar25; + uVar22 = uVar20 * 0x40000000 | uVar20 >> 2; + uVar28 = uVar18 >> 0x1f | uVar18 << 1; + uVar17 = (uVar9 * 0x20 | uVar9 >> 0x1b) + (uVar23 ^ uVar21 ^ uVar20) + uVar6 + 0x6ed9eba1 + uVar17 + ; + uVar19 = uVar9 * 0x40000000 | uVar9 >> 2; + uVar20 = uVar26 ^ uVar13 ^ uVar10 ^ uVar14; + uVar18 = ((uVar9 | uVar22) & uVar21 | uVar9 & uVar22) + + uVar28 + 0x8f1bbcdc + uVar23 + (uVar17 * 0x20 | uVar17 >> 0x1b); + uVar26 = uVar20 >> 0x1f | uVar20 << 1; + uVar2 = uVar2 ^ uVar11 ^ uVar8 ^ uVar6; + uVar23 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar2 = uVar2 >> 0x1f | uVar2 << 1; + uVar17 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar17 | uVar19) & uVar22 | uVar17 & uVar19) + uVar26 + 0x8f1bbcdc + uVar21; + uVar9 = uVar13 ^ uVar5 ^ uVar1 ^ uVar28; + uVar21 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar13 = uVar9 >> 0x1f | uVar9 << 1; + uVar20 = ((uVar18 | uVar23) & uVar19 | uVar18 & uVar23) + + uVar2 + 0x8f1bbcdc + uVar22 + (uVar17 * 0x20 | uVar17 >> 0x1b); + uVar9 = uVar11 ^ uVar4 ^ uVar27 ^ uVar26; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar11 = uVar9 >> 0x1f | uVar9 << 1; + uVar9 = (uVar20 * 0x20 | uVar20 >> 0x1b) + + ((uVar17 | uVar21) & uVar23 | uVar17 & uVar21) + uVar13 + 0x8f1bbcdc + uVar19; + uVar24 = uVar20 * 0x40000000 | uVar20 >> 2; + uVar5 = uVar5 ^ uVar3 ^ uVar25 ^ uVar2; + uVar19 = ((uVar20 | uVar18) & uVar21 | uVar20 & uVar18) + + uVar11 + 0x8f1bbcdc + uVar23 + (uVar9 * 0x20 | uVar9 >> 0x1b); + uVar5 = uVar5 >> 0x1f | uVar5 << 1; + uVar4 = uVar4 ^ uVar7 ^ uVar14 ^ uVar13; + uVar17 = uVar9 * 0x40000000 | uVar9 >> 2; + uVar4 = uVar4 >> 0x1f | uVar4 << 1; + uVar9 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + ((uVar9 | uVar24) & uVar18 | uVar9 & uVar24) + uVar5 + 0x8f1bbcdc + uVar21; + uVar3 = uVar3 ^ uVar10 ^ uVar6 ^ uVar11; + uVar22 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar3 = uVar3 >> 0x1f | uVar3 << 1; + uVar18 = ((uVar19 | uVar17) & uVar24 | uVar19 & uVar17) + + uVar4 + 0x8f1bbcdc + uVar18 + (uVar9 * 0x20 | uVar9 >> 0x1b); + uVar7 = uVar7 ^ uVar8 ^ uVar28 ^ uVar5; + uVar20 = uVar9 * 0x40000000 | uVar9 >> 2; + uVar7 = uVar7 >> 0x1f | uVar7 << 1; + uVar21 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar9 | uVar22) & uVar17 | uVar9 & uVar22) + uVar3 + 0x8f1bbcdc + uVar24; + uVar9 = uVar10 ^ uVar1 ^ uVar26 ^ uVar4; + uVar19 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar9 = uVar9 >> 0x1f | uVar9 << 1; + uVar10 = ((uVar18 | uVar20) & uVar22 | uVar18 & uVar20) + + uVar7 + 0x8f1bbcdc + uVar17 + (uVar21 * 0x20 | uVar21 >> 0x1b); + uVar8 = uVar8 ^ uVar27 ^ uVar2 ^ uVar3; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar8 = uVar8 >> 0x1f | uVar8 << 1; + uVar18 = (uVar10 * 0x20 | uVar10 >> 0x1b) + + ((uVar21 | uVar19) & uVar20 | uVar21 & uVar19) + uVar9 + 0x8f1bbcdc + uVar22; + uVar1 = uVar1 ^ uVar25 ^ uVar13 ^ uVar7; + uVar17 = uVar10 * 0x40000000 | uVar10 >> 2; + uVar1 = uVar1 >> 0x1f | uVar1 << 1; + uVar10 = ((uVar10 | uVar23) & uVar19 | uVar10 & uVar23) + + uVar8 + 0x8f1bbcdc + uVar20 + (uVar18 * 0x20 | uVar18 >> 0x1b); + uVar21 = uVar27 ^ uVar14 ^ uVar11 ^ uVar9; + uVar22 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar27 = uVar21 >> 0x1f | uVar21 << 1; + uVar18 = (uVar10 * 0x20 | uVar10 >> 0x1b) + + ((uVar18 | uVar17) & uVar23 | uVar18 & uVar17) + uVar19 + uVar1 + 0x8f1bbcdc; + uVar19 = uVar25 ^ uVar6 ^ uVar5 ^ uVar8; + uVar20 = uVar10 * 0x40000000 | uVar10 >> 2; + uVar24 = uVar19 >> 0x1f | uVar19 << 1; + uVar21 = ((uVar10 | uVar22) & uVar17 | uVar10 & uVar22) + + uVar27 + 0x8f1bbcdc + uVar23 + (uVar18 * 0x20 | uVar18 >> 0x1b); + uVar10 = uVar14 ^ uVar28 ^ uVar4 ^ uVar1; + uVar19 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar14 = uVar10 >> 0x1f | uVar10 << 1; + uVar10 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + ((uVar18 | uVar20) & uVar22 | uVar18 & uVar20) + uVar17 + uVar24 + 0x8f1bbcdc; + uVar6 = uVar6 ^ uVar26 ^ uVar3 ^ uVar27; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar6 = uVar6 >> 0x1f | uVar6 << 1; + uVar18 = ((uVar21 | uVar19) & uVar20 | uVar21 & uVar19) + + uVar14 + 0x8f1bbcdc + uVar22 + (uVar10 * 0x20 | uVar10 >> 0x1b); + uVar21 = uVar28 ^ uVar2 ^ uVar7 ^ uVar24; + uVar17 = uVar10 * 0x40000000 | uVar10 >> 2; + uVar28 = uVar21 >> 0x1f | uVar21 << 1; + uVar10 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar10 | uVar23) & uVar19 | uVar10 & uVar23) + uVar20 + uVar6 + 0x8f1bbcdc; + uVar21 = uVar26 ^ uVar13 ^ uVar9 ^ uVar14; + uVar22 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar25 = uVar21 >> 0x1f | uVar21 << 1; + uVar18 = ((uVar18 | uVar17) & uVar23 | uVar18 & uVar17) + + uVar28 + 0x8f1bbcdc + uVar19 + (uVar10 * 0x20 | uVar10 >> 0x1b); + uVar2 = uVar2 ^ uVar11 ^ uVar8 ^ uVar6; + uVar20 = uVar10 * 0x40000000 | uVar10 >> 2; + uVar2 = uVar2 >> 0x1f | uVar2 << 1; + uVar21 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar10 | uVar22) & uVar17 | uVar10 & uVar22) + uVar23 + uVar25 + 0x8f1bbcdc; + uVar10 = uVar13 ^ uVar5 ^ uVar1 ^ uVar28; + uVar19 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar13 = uVar10 >> 0x1f | uVar10 << 1; + uVar17 = ((uVar18 | uVar20) & uVar22 | uVar18 & uVar20) + + uVar2 + 0x8f1bbcdc + uVar17 + (uVar21 * 0x20 | uVar21 >> 0x1b); + uVar10 = uVar11 ^ uVar4 ^ uVar27 ^ uVar25; + uVar18 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar10 = uVar10 >> 0x1f | uVar10 << 1; + uVar23 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + ((uVar21 | uVar19) & uVar20 | uVar21 & uVar19) + uVar22 + uVar13 + 0x8f1bbcdc; + uVar5 = uVar5 ^ uVar3 ^ uVar24 ^ uVar2; + uVar11 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar5 = uVar5 >> 0x1f | uVar5 << 1; + uVar21 = (uVar23 * 0x20 | uVar23 >> 0x1b) + + (uVar19 ^ uVar18 ^ uVar17) + uVar20 + uVar10 + 0xca62c1d6; + uVar4 = uVar4 ^ uVar7 ^ uVar14 ^ uVar13; + uVar20 = uVar23 * 0x40000000 | uVar23 >> 2; + uVar4 = uVar4 >> 0x1f | uVar4 << 1; + uVar17 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar18 ^ uVar11 ^ uVar23) + uVar19 + uVar5 + 0xca62c1d6; + uVar3 = uVar3 ^ uVar9 ^ uVar6 ^ uVar10; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar3 = uVar3 >> 0x1f | uVar3 << 1; + uVar19 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar11 ^ uVar20 ^ uVar21) + uVar18 + uVar4 + 0xca62c1d6; + uVar7 = uVar7 ^ uVar8 ^ uVar28 ^ uVar5; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar7 = uVar7 >> 0x1f | uVar7 << 1; + uVar11 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar20 ^ uVar23 ^ uVar17) + uVar11 + uVar3 + 0xca62c1d6; + uVar9 = uVar9 ^ uVar1 ^ uVar25 ^ uVar4; + uVar21 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar9 = uVar9 >> 0x1f | uVar9 << 1; + uVar20 = (uVar11 * 0x20 | uVar11 >> 0x1b) + + (uVar23 ^ uVar18 ^ uVar19) + uVar20 + uVar7 + 0xca62c1d6; + uVar8 = uVar8 ^ uVar27 ^ uVar2 ^ uVar3; + uVar17 = uVar11 * 0x40000000 | uVar11 >> 2; + uVar8 = uVar8 >> 0x1f | uVar8 << 1; + uVar19 = (uVar20 * 0x20 | uVar20 >> 0x1b) + + (uVar18 ^ uVar21 ^ uVar11) + uVar23 + uVar9 + 0xca62c1d6; + uVar1 = uVar1 ^ uVar24 ^ uVar13 ^ uVar7; + uVar22 = uVar20 * 0x40000000 | uVar20 >> 2; + uVar1 = uVar1 >> 0x1f | uVar1 << 1; + uVar11 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar21 ^ uVar17 ^ uVar20) + uVar18 + uVar8 + 0xca62c1d6; + uVar18 = uVar27 ^ uVar14 ^ uVar10 ^ uVar9; + uVar23 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar26 = uVar18 >> 0x1f | uVar18 << 1; + uVar19 = (uVar11 * 0x20 | uVar11 >> 0x1b) + + (uVar17 ^ uVar22 ^ uVar19) + uVar21 + uVar1 + 0xca62c1d6; + uVar21 = uVar24 ^ uVar6 ^ uVar5 ^ uVar8; + uVar18 = uVar11 * 0x40000000 | uVar11 >> 2; + uVar24 = uVar21 >> 0x1f | uVar21 << 1; + uVar17 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar22 ^ uVar23 ^ uVar11) + uVar17 + uVar26 + 0xca62c1d6; + uVar11 = uVar14 ^ uVar28 ^ uVar4 ^ uVar1; + uVar21 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar11 = uVar11 >> 0x1f | uVar11 << 1; + uVar20 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar23 ^ uVar18 ^ uVar19) + uVar22 + uVar24 + 0xca62c1d6; + uVar6 = uVar6 ^ uVar25 ^ uVar3 ^ uVar26; + uVar14 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar6 = uVar6 >> 0x1f | uVar6 << 1; + uVar19 = (uVar20 * 0x20 | uVar20 >> 0x1b) + + (uVar18 ^ uVar21 ^ uVar17) + uVar23 + uVar11 + 0xca62c1d6; + uVar17 = uVar28 ^ uVar2 ^ uVar7 ^ uVar24; + uVar22 = uVar20 * 0x40000000 | uVar20 >> 2; + uVar27 = uVar17 >> 0x1f | uVar17 << 1; + uVar17 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar21 ^ uVar14 ^ uVar20) + uVar18 + uVar6 + 0xca62c1d6; + uVar18 = uVar25 ^ uVar13 ^ uVar9 ^ uVar11; + uVar23 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar20 = uVar18 >> 0x1f | uVar18 << 1; + uVar19 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar14 ^ uVar22 ^ uVar19) + uVar21 + uVar27 + 0xca62c1d6; + uVar2 = uVar2 ^ uVar10 ^ uVar8 ^ uVar6; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar2 = uVar2 >> 0x1f | uVar2 << 1; + uVar8 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar22 ^ uVar23 ^ uVar17) + uVar14 + uVar20 + 0xca62c1d6; + uVar27 = uVar13 ^ uVar5 ^ uVar1 ^ uVar27; + uVar13 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar21 = uVar27 >> 0x1f | uVar27 << 1; + uVar14 = uVar22 + uVar2 + 0xca62c1d6 + (uVar23 ^ uVar18 ^ uVar19) + (uVar8 * 0x20 | uVar8 >> 0x1b) + ; + uVar20 = uVar10 ^ uVar4 ^ uVar26 ^ uVar20; + uVar10 = (uVar14 * 0x20 | uVar14 >> 0x1b) + + (uVar18 ^ uVar13 ^ uVar8) + uVar23 + uVar21 + 0xca62c1d6; + uVar1 = uVar8 * 0x40000000 | uVar8 >> 2; + uVar17 = uVar20 >> 0x1f | uVar20 << 1; + uVar2 = uVar5 ^ uVar3 ^ uVar24 ^ uVar2; + uVar5 = uVar18 + uVar17 + 0xca62c1d6 + (uVar13 ^ uVar1 ^ uVar14) + + (uVar10 * 0x20 | uVar10 >> 0x1b); + uVar8 = uVar14 * 0x40000000 | uVar14 >> 2; + uVar21 = uVar4 ^ uVar7 ^ uVar11 ^ uVar21; + uVar4 = uVar13 + (uVar2 << 1 | uVar2 >> 0x1f) + 0xca62c1d6 + (uVar1 ^ uVar8 ^ uVar10) + + (uVar5 * 0x20 | uVar5 >> 0x1b); + uVar7 = uVar10 * 0x40000000 | uVar10 >> 2; + uVar17 = uVar3 ^ uVar9 ^ uVar6 ^ uVar17; + uVar1 = uVar1 + (uVar21 << 1 | uVar21 >> 0x1f) + 0xca62c1d6 + (uVar8 ^ uVar7 ^ uVar5) + + (uVar4 * 0x20 | uVar4 >> 0x1b); + uVar2 = uVar5 * 0x40000000 | uVar5 >> 2; + uVar12 = ctx->state[1]; + ctx->state[0] = + uVar8 + (uVar17 << 1 | uVar17 >> 0x1f) + uVar15 + 0xca62c1d6 + (uVar7 ^ uVar2 ^ uVar4) + + (uVar1 * 0x20 | uVar1 >> 0x1b); + ctx->state[1] = uVar1 + uVar12; + ctx->state[2] = uVar16 + (uVar4 >> 2 | uVar4 * 0x40000000); + ctx->state[3] = uVar2 + ctx->state[3]; + ctx->state[4] = uVar7 + ctx->state[4]; + return; +} + + + +void mbedtls_sha1_update(mbedtls_sha1_context *ctx,uchar *input,size_t ilen) + +{ + size_t __n; + uint uVar1; + uint uVar2; + uint __n_00; + + uVar2 = ctx->total[0] & 0x3f; + uVar1 = ctx->total[0] + ilen; + ctx->total[0] = uVar1; + if (uVar1 < ilen) { + ctx->total[1] = ctx->total[1] + 1; + } + uVar1 = ilen; + if ((uVar2 != 0) && (__n_00 = 0x40 - uVar2, __n_00 <= ilen)) { + memcpy(ctx->buffer + uVar2,input,__n_00); + ilen = (ilen - 0x40) + uVar2; + mbedtls_sha1_process(ctx,ctx->buffer); + input = input + __n_00; + uVar2 = 0; + uVar1 = ilen; + } + while (0x3f < ilen) { + mbedtls_sha1_process(ctx,input + (uVar1 - ilen)); + ilen = ilen - 0x40; + } + __n = (uVar1 >> 6) * -0x40 + uVar1; + if (__n == 0) { + return; + } + memcpy(ctx->buffer + uVar2,input + (uVar1 & 0xffffffc0),__n); + return; +} + + + +void mbedtls_sha1_update(mbedtls_sha1_context *ctx,uchar *input,size_t ilen) + +{ + if (ilen != 0) { + mbedtls_sha1_update(ctx,input,ilen); + return; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void mbedtls_sha1_finish(mbedtls_sha1_context *ctx,uchar *output) + +{ + uint uVar1; + uint uVar2; + int iVar3; + uchar uStack24; + undefined uStack23; + ushort uStack22; + uchar msglen [8]; + + uVar1 = ctx->total[0]; + uVar2 = ctx->total[1] << 3; + uStack24 = (uchar)(uVar2 >> 0x18); + uStack23 = (undefined)(uVar2 >> 0x10); + uStack22 = (ushort)(uVar2 >> 8) & 0xff | (ushort)((uVar2 | uVar1 >> 0x1d) << 8); + msglen[0] = (uchar)((uVar1 << 3) >> 0x18); + msglen[1] = (uchar)((uVar1 << 3) >> 0x10); + msglen._2_2_ = (ushort)((uVar1 << 0x13) >> 0x18) | (ushort)(uVar1 << 0xb); + if ((uVar1 & 0x3f) < 0x38) { + iVar3 = 0x38; + } + else { + iVar3 = 0x78; + } + mbedtls_sha1_update(ctx,sha1_padding,iVar3 - (uVar1 & 0x3f)); + mbedtls_sha1_update(ctx,&uStack24,8); + *output = *(uchar *)((int)ctx->state + 3); + output[1] = (uchar)*(undefined2 *)((int)ctx->state + 2); + output[2] = (uchar)(ctx->state[0] >> 8); + output[3] = (uchar)ctx->state[0]; + output[4] = *(uchar *)((int)ctx->state + 7); + output[5] = (uchar)*(undefined2 *)((int)ctx->state + 6); + output[6] = (uchar)(ctx->state[1] >> 8); + output[7] = (uchar)ctx->state[1]; + output[8] = *(uchar *)((int)ctx->state + 0xb); + output[9] = (uchar)*(undefined2 *)((int)ctx->state + 10); + output[10] = (uchar)(ctx->state[2] >> 8); + output[0xb] = (uchar)ctx->state[2]; + output[0xc] = *(uchar *)((int)ctx->state + 0xf); + output[0xd] = (uchar)*(undefined2 *)((int)ctx->state + 0xe); + output[0xe] = (uchar)(ctx->state[3] >> 8); + output[0xf] = (uchar)ctx->state[3]; + output[0x10] = *(uchar *)((int)ctx->state + 0x13); + output[0x11] = (uchar)*(undefined2 *)((int)ctx->state + 0x12); + output[0x12] = (uchar)(ctx->state[4] >> 8); + output[0x13] = (uchar)ctx->state[4]; + return; +} + + + +void mbedtls_sha1(uchar *input,size_t ilen,uchar *output) + +{ + undefined auStack108 [4]; + mbedtls_sha1_context ctx; + + mbedtls_sha1_init((mbedtls_sha1_context *)auStack108); + mbedtls_sha1_starts((mbedtls_sha1_context *)auStack108); + mbedtls_sha1_update((mbedtls_sha1_context *)auStack108,input,ilen); + mbedtls_sha1_finish((mbedtls_sha1_context *)auStack108,output); + mbedtls_sha1_free((mbedtls_sha1_context *)auStack108); + return; +} + + + +mbedtls_ssl_ciphersuite_t * mbedtls_ssl_ciphersuite_from_id(int ciphersuite) + +{ + mbedtls_ssl_ciphersuite_t *pmVar1; + + pmVar1 = ciphersuite_definitions; + while( true ) { + if (pmVar1->id == 0) { + return (mbedtls_ssl_ciphersuite_t *)0x0; + } + if (pmVar1->id == ciphersuite) break; + pmVar1 = pmVar1 + 1; + } + return pmVar1; +} + + + +int * mbedtls_ssl_list_ciphersuites(void) + +{ + int *piVar1; + int *piVar2; + mbedtls_ssl_ciphersuite_t *pmVar3; + int ciphersuite; + + if (supported_init == 0) { + piVar1 = supported_ciphersuites; + piVar2 = ciphersuite_preference; + while ((ciphersuite = *piVar2, ciphersuite != 0 && (piVar1 < supported_ciphersuites + 5))) { + pmVar3 = mbedtls_ssl_ciphersuite_from_id(ciphersuite); + if (pmVar3 != (mbedtls_ssl_ciphersuite_t *)0x0) { + *piVar1 = ciphersuite; + piVar1 = piVar1 + 1; + } + piVar2 = piVar2 + 1; + } + *piVar1 = 0; + supported_init = 1; + } + return supported_ciphersuites; +} + + + +char * mbedtls_ssl_get_ciphersuite_name(int ciphersuite_id) + +{ + mbedtls_ssl_ciphersuite_t *pmVar1; + char *pcVar2; + + pmVar1 = mbedtls_ssl_ciphersuite_from_id(ciphersuite_id); + if (pmVar1 == (mbedtls_ssl_ciphersuite_t *)0x0) { + pcVar2 = "unknown"; + } + else { + pcVar2 = pmVar1->name; + } + return pcVar2; +} + + + +mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_pk_alg(mbedtls_ssl_ciphersuite_t *info) + +{ + mbedtls_pk_type_t mVar1; + uint uVar2; + + if (info->key_exchange < MBEDTLS_KEY_EXCHANGE_ECJPAKE) { + uVar2 = 1 << ((uint)info->key_exchange & 0x1f); + mVar1 = MBEDTLS_PK_RSA; + if (((uVar2 & 0x8e) == 0) && (mVar1 = MBEDTLS_PK_ECKEY, (uVar2 & 0x600) == 0)) { + return (mbedtls_pk_type_t)(((uVar2 & 0x10) != 0) << 2); + } + } + else { + mVar1 = MBEDTLS_PK_NONE; + } + return mVar1; +} + + + +mbedtls_pk_context * mbedtls_ssl_own_key(mbedtls_ssl_context *ssl) + +{ + mbedtls_ssl_key_cert *pmVar1; + + if (((ssl->handshake != (mbedtls_ssl_handshake_params *)0x0) && + (pmVar1 = ssl->handshake->key_cert, pmVar1 != (mbedtls_ssl_key_cert *)0x0)) || + (pmVar1 = ssl->conf->key_cert, pmVar1 != (mbedtls_ssl_key_cert *)0x0)) { + pmVar1 = (mbedtls_ssl_key_cert *)pmVar1->key; + } + return (mbedtls_pk_context *)pmVar1; +} + + + +size_t mbedtls_ssl_hs_hdr_len(void) + +{ + int in_a0; + + if ((*(ushort *)(in_a0 + 0x74) & 2) != 0) { + return 0xc; + } + return 4; +} + + + +// WARNING: Type propagation algorithm not settling + +int mbedtls_ssl_handshake_client_step(mbedtls_ssl_context *ssl) + +{ + uchar uVar1; + mbedtls_key_exchange_type_t mVar2; + byte bVar3; + byte bVar4; + byte bVar5; + byte bVar6; + bool bVar7; + uchar *puVar8; + uchar *puVar9; + uchar uVar10; + uint ret; + mbedtls_ssl_session *pmVar11; + size_t __n; + mbedtls_x509_crt *pmVar12; + mbedtls_pk_context *pk; + size_t len; + mbedtls_md_type_t md_alg; + int line; + int line_00; + char *format; + uint __n_00; + size_t sVar13; + uchar *buf; + int *piVar14; + undefined *puVar15; + mbedtls_ssl_config *pmVar16; + mbedtls_ssl_key_cert *pmVar17; + uchar *buf_00; + ushort *puVar18; + byte *buf_01; + mbedtls_ssl_handshake_params *pmVar19; + uint size; + mbedtls_ssl_ciphersuite_t *ciphersuite_info; + uchar *puVar20; + uint uVar21; + byte *pbVar22; + uchar *puVar23; + mbedtls_ssl_transform *pmVar24; + char **ppcVar25; + uchar *ver; + byte *buf_02; + uchar *puVar26; + size_t local_74; + int major_ver; + int minor_ver; + + if (ssl->state == 0x10) { + return -0x7100; + } + if (ssl->handshake == (mbedtls_ssl_handshake_params *)0x0) { + return -0x7100; + } + mbedtls_debug_print_msg(ssl,2,"file1",0xccf,"client state: %d"); + ret = mbedtls_ssl_flush_output(ssl); + if (ret != 0) { + return ret; + } + if ((((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) && + (ssl->handshake->retransmit_state == '\x01')) && + (line_00 = mbedtls_ssl_resend(ssl), line_00 != 0)) { + return line_00; + } + if ((ssl->state == 0xc) && (ssl->handshake->new_session_ticket != 0)) { + ssl->state = 0x11; + } + __n_00 = ssl->state; + switch(__n_00) { + case 0: + ssl->state = 1; + break; + case 1: + mbedtls_debug_print_msg(ssl,2,"file1",0x2cd,"=> write client hello"); + pmVar16 = ssl->conf; + if (pmVar16->f_rng == (mbedtls_ssl_recv_t *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x2d1,"no RNG provided"); + return -0x7400; + } + ssl->major_ver = (uint)pmVar16->min_major_ver; + ssl->minor_ver = (uint)pmVar16->min_minor_ver; + if (pmVar16->max_major_ver == 0) { + mbedtls_debug_print_msg + (ssl,1,"file1",0x2e0, + + "configured max major version is invalid, consider using mbedtls_ssl_config_defaults()" + ); + return -0x7100; + } + ver = ssl->out_msg; + mbedtls_ssl_write_version + ((uint)pmVar16->max_major_ver,(uint)pmVar16->max_minor_ver, + *(uint *)&pmVar16->field_0x74 >> 1 & 1,ver + 4); + mbedtls_debug_print_msg + (ssl,3,"file1",0x2f3,"client hello, max version: [%d:%d]",(uint)ver[4],(uint)ver[5]); + pmVar16 = ssl->conf; + pmVar19 = ssl->handshake; + if ((((*(ushort *)&pmVar16->field_0x74 & 2) == 0) || (pmVar19->verify_cookie == (uchar *)0x0)) + && ((ret = (*pmVar16->f_rng)(pmVar16->p_rng,pmVar19->randbytes,4), ret != 0 || + (ret = (*ssl->conf->f_rng)(ssl->conf->p_rng,pmVar19->randbytes + 4,0x1c), ret != 0)))) { + format = "ssl_generate_random"; + line_00 = 0x2f7; + } + else { + memcpy(ver + 6,ssl->handshake->randbytes,0x20); + mbedtls_debug_print_buf(ssl,3,"file1",0x2fc,"client hello, random bytes",ver + 6,0x20); + pmVar11 = ssl->session_negotiate; + len = pmVar11->id_len; + if ((0x10 < len - 0x10) || (ssl->handshake->resume == 0)) { + len = 0; + } + if ((pmVar11->ticket != (uchar *)0x0) && (pmVar11->ticket_len != 0)) { + line_00 = (*ssl->conf->f_rng)(ssl->conf->p_rng,pmVar11->id,0x20); + if (line_00 != 0) { + return line_00; + } + len = 0x20; + ssl->session_negotiate->id_len = 0x20; + } + ver[0x26] = (uchar)len; + sVar13 = 0; + while (len != sVar13) { + ver[sVar13 + 0x27] = ssl->session_negotiate->id[sVar13]; + sVar13 = sVar13 + 1; + } + puVar20 = ver + 0x27 + len; + mbedtls_debug_print_msg(ssl,3,"file1",0x331,"client hello, session id len.: %d",len); + mbedtls_debug_print_buf(ssl,3,"file1",0x332,"client hello, session id",ver + 0x27,len); + buf_00 = puVar20; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + buf_00 = puVar20 + 1; + buf = ssl->handshake->verify_cookie; + if (buf == (uchar *)0x0) { + mbedtls_debug_print_msg(ssl,3,"file1",0x33c,"no verify cookie to send"); + *puVar20 = '\0'; + } + else { + mbedtls_debug_print_buf + (ssl,3,"file1",0x343,"client hello, cookie",buf, + (uint)ssl->handshake->verify_cookie_len); + *puVar20 = ssl->handshake->verify_cookie_len; + memcpy(buf_00,ssl->handshake->verify_cookie,(uint)ssl->handshake->verify_cookie_len); + buf_00 = buf_00 + ssl->handshake->verify_cookie_len; + } + } + piVar14 = ssl->conf->ciphersuite_list[ssl->minor_ver]; + line_00 = 0; + puVar20 = buf_00 + 2; + while (*piVar14 != 0) { + ciphersuite_info = mbedtls_ssl_ciphersuite_from_id(*piVar14); + buf = puVar20; + if ((((ciphersuite_info != (mbedtls_ssl_ciphersuite_t *)0x0) && + (pmVar16 = ssl->conf, + ciphersuite_info->min_minor_ver <= (int)(uint)pmVar16->max_minor_ver)) && + ((int)(uint)pmVar16->min_minor_ver <= ciphersuite_info->max_minor_ver)) && + (((*(ushort *)&pmVar16->field_0x74 & 2) == 0 || ((ciphersuite_info->flags & 4) == 0)))) { + mbedtls_debug_print_msg + (ssl,3,"file1",0x375,"client hello, add ciphersuite: %04x",*piVar14); + line_00 = line_00 + 1; + buf = puVar20 + 2; + *puVar20 = (uchar)((uint)*piVar14 >> 8); + puVar20[1] = (uchar)*piVar14; + } + piVar14 = piVar14 + 1; + puVar20 = buf; + } + puVar20[1] = -1; + *puVar20 = '\0'; + *buf_00 = (uchar)(line_00 + 1U >> 7); + buf_00[1] = (char)(line_00 + 1U) * '\x02'; + mbedtls_debug_print_msg(ssl,3,"file1",0x396,"client hello, got %d ciphersuites"); + mbedtls_debug_print_msg(ssl,3,"file1",0x3b5,"client hello, compress len.: %d",1); + mbedtls_debug_print_msg(ssl,3,"file1",0x3b7,"client hello, compress alg.: %d",0); + puVar20[2] = '\x01'; + puVar20[3] = '\0'; + buf_00 = puVar20 + 4; + buf = puVar20 + 6; + puVar23 = (uchar *)0x0; + if (ssl->hostname != (char *)0x0) { + puVar8 = ssl->out_msg; + mbedtls_debug_print_msg(ssl,3,"file1",0x48,"client hello, adding server name extension: %s") + ; + __n = strlen(ssl->hostname); + if ((puVar8 + 0x4000 < buf) || + (puVar23 = (uchar *)(__n + 9), puVar8 + 0x4000 + -(int)buf < puVar23)) { + mbedtls_debug_print_msg(ssl,1,"file1",0x4e,"buffer too small"); + puVar23 = (uchar *)0x0; + } + else { + puVar20[8] = (uchar)(__n + 5 >> 8); + uVar10 = (uchar)__n; + puVar20[9] = uVar10 + '\x05'; + puVar20[10] = (uchar)(__n + 3 >> 8); + puVar20[0xb] = uVar10 + '\x03'; + puVar20[6] = '\0'; + puVar20[7] = '\0'; + puVar20[0xc] = '\0'; + puVar20[0xd] = (uchar)(__n >> 8); + puVar20[0xe] = uVar10; + memcpy(puVar20 + 0xf,ssl->hostname,__n); + } + } + line_00 = 0; + if (ssl->conf->max_minor_ver == '\x03') { + puVar8 = ssl->out_msg; + mbedtls_debug_print_msg + (ssl,3,"file1",0xb2,"client hello, adding signature_algorithms extension"); + piVar14 = ssl->conf->sig_hashes; + line_00 = 0; + while (*(int *)(line_00 * 2 + (int)piVar14) != 0) { + line_00 = line_00 + 2; + } + puVar9 = puVar23 + 2 + (int)buf_00; + if ((puVar8 + 0x4000 < puVar9) || (puVar8 + 0x4000 + -(int)puVar9 < (uchar *)(line_00 + 6))) + { + mbedtls_debug_print_msg(ssl,1,"file1",0xc0,"buffer too small"); + line_00 = 0; + } + else { + puVar8 = puVar9 + 6; + line_00 = 0; + while( true ) { + line = *(int *)(line_00 * 2 + (int)piVar14); + if (line == 0) break; + uVar10 = mbedtls_ssl_hash_from_md_alg(line); + *puVar8 = uVar10; + puVar8[1] = '\x01'; + puVar8 = puVar8 + 2; + line_00 = line_00 + 2; + } + puVar9[1] = '\r'; + puVar9[3] = (uchar)line_00 + '\x02'; + *puVar9 = '\0'; + puVar9[2] = (uchar)((uint)(line_00 + 2) >> 8); + puVar9[4] = (uchar)((uint)line_00 >> 8); + puVar9[5] = (uchar)line_00; + line_00 = line_00 + 6; + } + } + puVar23 = puVar23 + line_00; + line_00 = 0; + if ((*(ushort *)&ssl->conf->field_0x74 & 0x1c0) != 0) { + puVar9 = ssl->out_msg; + puVar8 = buf_00 + (int)(puVar23 + 2); + mbedtls_debug_print_msg + (ssl,3,"file1",0x1b8,"client hello, adding max_fragment_length extension"); + if ((puVar9 + 0x4000 < puVar8) || (puVar9 + 0x4000 + -(int)puVar8 < &DAT_00000005)) { + mbedtls_debug_print_msg(ssl,1,"file1",0x1bc,"buffer too small"); + line_00 = 0; + } + else { + *puVar8 = '\0'; + puVar8[1] = '\x01'; + puVar8[2] = '\0'; + puVar8[3] = '\x01'; + puVar8[4] = (byte)(*(uint *)&ssl->conf->field_0x74 >> 6) & 7; + line_00 = 5; + } + } + puVar23 = puVar23 + line_00; + buf_02 = (byte *)0x0; + if (ssl->conf->alpn_list != (char **)0x0) { + puVar8 = ssl->out_msg; + mbedtls_debug_print_msg(ssl,3,"file1",0x26c,"client hello, adding alpn extension"); + ppcVar25 = ssl->conf->alpn_list; + while (*ppcVar25 != (char *)0x0) { + __n = strlen(*ppcVar25); + buf_02 = buf_02 + (__n & 0xff) + 1; + ppcVar25 = ppcVar25 + 1; + } + puVar9 = buf_00 + (int)(puVar23 + 2); + if ((puVar8 + 0x4000 < puVar9) || (puVar8 + 0x4000 + -(int)puVar9 < buf_02 + 6)) { + mbedtls_debug_print_msg(ssl,1,"file1",0x273,"buffer too small"); + buf_02 = (byte *)0x0; + } + else { + *puVar9 = '\0'; + puVar9[1] = '\x10'; + buf_02 = puVar9 + 6; + ppcVar25 = ssl->conf->alpn_list; + while (*ppcVar25 != (char *)0x0) { + __n = strlen(*ppcVar25); + *buf_02 = (byte)__n; + memcpy(buf_02 + 1,*ppcVar25,__n & 0xff); + ppcVar25 = ppcVar25 + 1; + buf_02 = buf_02 + (uint)*buf_02 + 1; + } + buf_02 = buf_02 + -(int)puVar9; + puVar9[4] = (uchar)((uint)(buf_02 + -6) >> 8); + puVar9[5] = (char)buf_02 + -6; + puVar9[2] = (uchar)((uint)(buf_02 + -4) >> 8); + puVar9[3] = (char)buf_02 + -4; + } + } + puVar8 = (uchar *)0x0; + if ((*(ushort *)&ssl->conf->field_0x74 & 0x200) != 0) { + puVar26 = ssl->out_msg; + puVar9 = buf_00 + (int)(buf_02 + (int)puVar23 + 2); + __n = ssl->session_negotiate->ticket_len; + mbedtls_debug_print_msg(ssl,3,"file1",0x23f,"client hello, adding session ticket extension") + ; + if ((puVar26 + 0x4000 < puVar9) || + (puVar8 = (uchar *)(__n + 4), puVar26 + 0x4000 + -(int)puVar9 < puVar8)) { + mbedtls_debug_print_msg(ssl,1,"file1",0x243,"buffer too small"); + puVar8 = (uchar *)0x0; + } + else { + puVar9[1] = '#'; + *puVar9 = '\0'; + puVar9[2] = (uchar)(__n >> 8); + puVar9[3] = (uchar)__n; + if ((ssl->session_negotiate->ticket == (uchar *)0x0) || (__n == 0)) { + puVar8 = &DAT_00000004; + } + else { + mbedtls_debug_print_msg(ssl,3,"file1",0x254,"sending session ticket of length %d",__n); + memcpy(puVar9 + 4,ssl->session_negotiate->ticket,__n); + } + } + } + puVar8 = puVar8 + (int)(buf_02 + (int)puVar23); + mbedtls_debug_print_msg(ssl,3,"file1",0x3ff,"client hello, total extension length: %d",puVar8) + ; + if (puVar8 != (uchar *)0x0) { + puVar20[4] = (uchar)((uint)puVar8 >> 8); + puVar20[5] = (uchar)puVar8; + buf_00 = buf + (int)puVar8; + } + ssl->out_msgtype = 0x16; + *(uchar **)&ssl->out_msglen = buf_00 + -(int)ver; + *ssl->out_msg = '\x01'; + ssl->state = ssl->state + 1; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + mbedtls_ssl_send_flight_completed(ssl); + } + ret = mbedtls_ssl_write_record(ssl); + if (ret == 0) { + format = "<= write client hello"; + line_00 = 0x419; + goto LAB_2309a036; + } + format = "mbedtls_ssl_write_record"; + line_00 = 0x415; + } + goto LAB_23099f16; + case 2: + mbedtls_debug_print_msg(ssl,2,"file1",0x582,"=> parse server hello"); + buf_02 = ssl->in_msg; + ret = mbedtls_ssl_read_record(ssl); + if (ret == 0) { + if (ssl->in_msgtype == 0x16) { + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + if (*buf_02 == 3) { + mbedtls_debug_print_msg(ssl,2,"file1",0x5a9,"received hello verify request"); + mbedtls_debug_print_msg(ssl,2,"file1",0x5aa,"<= parse server hello"); + len = mbedtls_ssl_hs_hdr_len(); + ver = ssl->in_msg + len; + mbedtls_debug_print_msg(ssl,2,"file1",0x52e,"=> parse hello verify request"); + mbedtls_debug_print_buf(ssl,3,"file1",0x536,"server version",ver,2); + mbedtls_ssl_read_version + ((int *)&local_74,&major_ver,*(uint *)&ssl->conf->field_0x74 >> 1 & 1,ver); + if (((((int)local_74 < 3) || (major_ver < 2)) || + ((int)(uint)ssl->conf->max_major_ver < (int)local_74)) || + ((int)(uint)ssl->conf->max_minor_ver < major_ver)) { + mbedtls_debug_print_msg(ssl,1,"file1",0x543,"bad server version"); + goto LAB_2309a182; + } + buf_00 = ver + 3; + bVar3 = ver[2]; + __n_00 = (uint)bVar3; + mbedtls_debug_print_buf(ssl,3,"file1",0x54c,"cookie",buf_00,__n_00); + if ((int)(ssl->in_msg + (ssl->in_msglen - (int)buf_00)) < (int)__n_00) { + mbedtls_debug_print_msg + (ssl,1,"file1",0x551,"cookie length does not match incoming message size"); + mbedtls_ssl_send_alert_message(ssl,'\x02','2'); + return -0x7980; + } + vPortFree(ssl->handshake->verify_cookie); + pmVar19 = ssl->handshake; + ver = (uchar *)mycalloc(1,__n_00); + pmVar19->verify_cookie = ver; + ver = ssl->handshake->verify_cookie; + if (ver == (uchar *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x55c,"alloc failed (%d bytes)",__n_00); + return -0x7f00; + } + memcpy(ver,buf_00,__n_00); + ssl->handshake->verify_cookie_len = bVar3; + ssl->state = 1; + mbedtls_ssl_reset_checksum(ssl); + mbedtls_ssl_recv_flight_completed(ssl); + format = "<= parse hello verify request"; + line_00 = 0x569; + goto LAB_2309a036; + } + vPortFree(ssl->handshake->verify_cookie); + ssl->handshake->verify_cookie = (uchar *)0x0; + ssl->handshake->verify_cookie_len = '\0'; + } + len = mbedtls_ssl_hs_hdr_len(); + if ((ssl->in_hslen < len + 0x26) || (bVar3 = *buf_02, bVar3 != 2)) { + line_00 = 0x5ba; + } + else { + buf_02 = buf_02 + len; + mbedtls_debug_print_buf(ssl,3,"file1",0x5cb,"server hello, version",buf_02,2); + mbedtls_ssl_read_version + (&ssl->major_ver,&ssl->minor_ver,*(uint *)&ssl->conf->field_0x74 >> 1 & 1,buf_02 + ); + pmVar16 = ssl->conf; + if (((ssl->major_ver < (int)(uint)pmVar16->min_major_ver) || + (ssl->minor_ver < (int)(uint)pmVar16->min_minor_ver)) || + (((int)(uint)pmVar16->max_major_ver < ssl->major_ver || + ((int)(uint)pmVar16->max_minor_ver < ssl->minor_ver)))) { + mbedtls_debug_print_msg + (ssl,1,"file1",0x5d8, + "server version out of bounds - min: [%d:%d], server: [%d:%d], max: [%d:%d]" + ); +LAB_2309a182: + mbedtls_ssl_send_alert_message(ssl,'\x02','F'); + return -0x6e80; + } + mbedtls_debug_print_msg + (ssl,3,"file1",0x5e5,"server hello, current time: %lu", + (uint)buf_02[4] << 8 | + (uint)buf_02[2] << 0x18 | (uint)buf_02[3] << 0x10 | (uint)buf_02[5]); + memcpy(ssl->handshake->randbytes + 0x20,buf_02 + 2,0x20); + bVar4 = buf_02[0x22]; + size = (uint)bVar4; + mbedtls_debug_print_buf(ssl,3,"file1",0x5ec,"server hello, random bytes",buf_02 + 2,0x20); + if (bVar4 < 0x21) { + __n_00 = ssl->in_hslen; + len = mbedtls_ssl_hs_hdr_len(); + line_00 = len + size; + if (line_00 + 0x27U < __n_00) { + uVar21 = (uint)CONCAT11((buf_02 + size)[0x26],(buf_02 + size)[0x27]); + if ((uVar21 - 1 <= (uint)bVar3) || (__n_00 != line_00 + uVar21 + 0x28)) { + line_00 = 0x5fc; + goto LAB_2309a2b6; + } + } + else { + uVar21 = 0; + if (__n_00 != line_00 + 0x26U) { + line_00 = 0x606; + goto LAB_2309a2b6; + } + } + __n_00 = (uint)CONCAT11((buf_02 + size)[0x23],(buf_02 + size)[0x24]); + if (buf_02[size + 0x25] != 0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x621,"server hello, bad compression: %d"); + return -0x7080; + } + pmVar24 = ssl->transform_negotiate; + ciphersuite_info = mbedtls_ssl_ciphersuite_from_id(__n_00); + pmVar24->ciphersuite_info = ciphersuite_info; + ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + if (ciphersuite_info == (mbedtls_ssl_ciphersuite_t *)0x0) { + format = "ciphersuite info for %04x not found"; + line_00 = 0x62c; +LAB_2309a492: + mbedtls_debug_print_msg(ssl,1,"file1",line_00,format,__n_00); + return -0x7100; + } + mbedtls_ssl_optimize_checksum(ssl,ciphersuite_info); + mbedtls_debug_print_msg(ssl,3,"file1",0x632,"server hello, session id len.: %d",size); + buf_01 = buf_02 + 0x23; + mbedtls_debug_print_buf(ssl,3,"file1",0x633,"server hello, session id",buf_01,size); + if ((((ssl->handshake->resume == 0) || (bVar4 == 0)) || + (pmVar11 = ssl->session_negotiate, __n_00 != pmVar11->ciphersuite)) || + (((pmVar11->compression != 0 || (size != pmVar11->id_len)) || + (line_00 = memcmp(pmVar11->id,buf_01,size), line_00 != 0)))) { + ssl->state = ssl->state + 1; + ssl->handshake->resume = 0; + ssl->session_negotiate->ciphersuite = __n_00; + ssl->session_negotiate->compression = 0; + ssl->session_negotiate->id_len = size; + memcpy(ssl->session_negotiate->id,buf_01,size); + } + else { + ssl->state = 0xc; + line_00 = mbedtls_ssl_derive_keys(ssl); + if (line_00 != 0) { + mbedtls_debug_print_ret(ssl,1,"file1",0x651,"mbedtls_ssl_derive_keys",line_00); + return line_00; + } + } + if (ssl->handshake->resume == 0) { + puVar15 = &UNK_230c9dcc; + } + else { + puVar15 = (undefined *)0x230c3fb8; + } + mbedtls_debug_print_msg(ssl,3,"file1",0x657,"%s session has been resumed",puVar15); + mbedtls_debug_print_msg + (ssl,3,"file1",0x659,"server hello, chosen ciphersuite: %04x",__n_00); + mbedtls_debug_print_msg + (ssl,3,"file1",0x65a,"server hello, compress alg.: %d", + (uint)buf_02[size + 0x25]); + ciphersuite_info = mbedtls_ssl_ciphersuite_from_id(ssl->session_negotiate->ciphersuite); + if (ciphersuite_info == (mbedtls_ssl_ciphersuite_t *)0x0) { + line_00 = 0x664; + } + else { + mbedtls_debug_print_msg + (ssl,3,"file1",0x668,"server hello, chosen ciphersuite: %s", + ciphersuite_info->name); + piVar14 = ssl->conf->ciphersuite_list[ssl->minor_ver]; + do { + line_00 = *piVar14; + if (line_00 == 0) { + line_00 = 0x66f; + goto LAB_2309a2b6; + } + piVar14 = piVar14 + 1; + } while (line_00 != ssl->session_negotiate->ciphersuite); + ssl->session_negotiate->compression = 0; + puVar18 = (ushort *)(buf_02 + size + 0x28); + mbedtls_debug_print_msg + (ssl,2,"file1",0x687,"server hello, total extension length: %d",uVar21); + do { + if (uVar21 == 0) { + if ((ssl->secure_renegotiation == 0) && + ((*(ushort *)&ssl->conf->field_0x74 & 0x30) == 0x20)) { + line_00 = 0x4c4; + line = 0x720; +LAB_2309a75c: + mbedtls_debug_print_msg + (ssl,1,"file1",line, + "client hello, adding signature_algorithms extension" + + line_00 + 0x1c); + line_00 = mbedtls_ssl_send_fatal_handshake_failure(ssl); + if (line_00 == 0) { + return -0x7980; + } + return line_00; + } + format = "<= parse server hello"; + line_00 = 0x743; + goto LAB_2309a036; + } + __n_00 = (uint)(*puVar18 >> 8) | ((uint)*puVar18 & 0xff) << 8; + size = ((uint)puVar18[1] & 0xff) << 8 | (uint)(puVar18[1] >> 8); + if (uVar21 < size + 4) { + line_00 = 0x692; + goto LAB_2309a2b6; + } + if (__n_00 == 0x10) { + mbedtls_debug_print_msg(ssl,3,"file1",0x703,"found alpn extension"); + ppcVar25 = ssl->conf->alpn_list; + if (ppcVar25 == (char **)0x0) { + return -0x7980; + } + if (size < 4) { + return -0x7980; + } + if (((uint)(puVar18[2] >> 8) | ((uint)puVar18[2] & 0xff) << 8) != size - 2) { + return -0x7980; + } + __n_00 = (uint)*(byte *)(puVar18 + 3); + if (__n_00 != size - 3) { + return -0x7980; + } + while( true ) { + if (*ppcVar25 == (char *)0x0) { + return -0x7980; + } + __n = strlen(*ppcVar25); + if ((__n_00 == __n) && + (line_00 = memcmp((byte *)((int)puVar18 + 7),*ppcVar25,__n_00), line_00 == 0) + ) break; + ppcVar25 = ppcVar25 + 1; + } + ssl->alpn_chosen = *ppcVar25; + } + else { + if (__n_00 < 0x11) { + if (__n_00 == 1) { + mbedtls_debug_print_msg + (ssl,3,"file1",0x6a6,"found max_fragment_length extension"); + if ((*(ushort *)&ssl->conf->field_0x74 & 0x1c0) == 0) { + return -0x7980; + } + if (size != 1) { + return -0x7980; + } + if ((uint)*(byte *)(puVar18 + 2) != (*(uint *)&ssl->conf->field_0x74 >> 6 & 7) + ) { + return -0x7980; + } + } + else { +LAB_2309a706: + mbedtls_debug_print_msg + (ssl,3,"file1",0x70d,"unknown extension found: %d (ignoring)"); + } + } + else { + if (__n_00 == 0x23) { + mbedtls_debug_print_msg(ssl,3,"file1",0x6da,"found session_ticket extension"); + if ((*(ushort *)&ssl->conf->field_0x74 & 0x200) == 0) { + return -0x7980; + } + if (size != 0) { + return -0x7980; + } + ssl->handshake->new_session_ticket = 1; + } + else { + if (__n_00 != 0xff01) goto LAB_2309a706; + mbedtls_debug_print_msg(ssl,3,"file1",0x699,"found renegotiation extension"); + if ((size != 1) || (*(byte *)(puVar18 + 2) != 0)) { + line_00 = 0x41c; + line = 0x43c; + goto LAB_2309a75c; + } + ssl->secure_renegotiation = 1; + } + } + } + line_00 = uVar21 - size; + uVar21 = line_00 - 4; + puVar18 = (ushort *)((int)puVar18 + size + 4); + } while (2 < line_00 - 5U); + line_00 = 0x715; + } + } + else { + line_00 = 0x5f0; + } + } +LAB_2309a2b6: + mbedtls_debug_print_msg(ssl,1,"file1",line_00,"bad server hello message"); + return -0x7980; + } + format = "bad server hello message"; + line_00 = 0x5a0; +LAB_2309a092: + line = 1; +LAB_2309a098: + mbedtls_debug_print_msg(ssl,line,"file1",line_00,format); + return -0x7700; + } + format = "mbedtls_ssl_read_record"; + line_00 = 0x588; + goto LAB_23099f16; + case 3: + __n_00 = mbedtls_ssl_parse_certificate(ssl); + break; + case 4: + ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + mbedtls_debug_print_msg(ssl,2,"file1",0x896,"=> parse server key exchange"); + if (ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA) { + format = "<= skip parse server key exchange"; + line_00 = 0x89b; +LAB_2309a8ea: + mbedtls_debug_print_msg(ssl,2,"file1",line_00,format); + line_00 = ssl->state + 1; + __n_00 = ret; + goto LAB_2309a8fc; + } + ret = mbedtls_ssl_read_record(ssl); + if (ret == 0) { + if (ssl->in_msgtype == 0x16) { + ver = ssl->in_msg; + if (*ver == '\f') { + len = mbedtls_ssl_hs_hdr_len(); + mbedtls_debug_print_buf + (ssl,3,"file1",0x8d6,"server key exchange",ver + len,ssl->in_hslen - len); + line_00 = 0x91b; + goto LAB_2309a9bc; + } + if ((ciphersuite_info->key_exchange & 0xfd) == 5) { + ssl->record_read = 1; + ssl->state = ssl->state + 1; + format = "<= parse server key exchange"; + line_00 = 0x9d4; + goto LAB_2309a036; + } + format = "bad server key exchange message"; + line_00 = 0x8d0; + } + else { + format = "bad server key exchange message"; + line_00 = 0x8bf; + } + goto LAB_2309a092; + } + format = "mbedtls_ssl_read_record"; + line_00 = 0x8b9; + goto LAB_23099f16; + case 5: + ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + mbedtls_debug_print_msg(ssl,2,"file1",0x9fc,"=> parse certificate request"); + mVar2 = ciphersuite_info->key_exchange; + if (((byte)(mVar2 + ~MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA) < 4) || + (mVar2 == MBEDTLS_KEY_EXCHANGE_ECJPAKE)) { + format = "<= skip parse certificate request"; + line_00 = 0xa04; + goto LAB_2309a8ea; + } + if (ssl->record_read == 0) { + line_00 = mbedtls_ssl_read_record(ssl); + if (line_00 != 0) { + line = 0xa0d; + goto LAB_2309aa3a; + } + if (ssl->in_msgtype != 0x16) { + format = "bad certificate request message"; + line_00 = 0xa13; + goto LAB_2309a092; + } + ssl->record_read = 1; + } + ssl->client_auth = 0; + ssl->state = ssl->state + 1; + if (*ssl->in_msg == '\r') { + ssl->client_auth = 1; + puVar15 = (undefined *)0x230c3fb8; + } + else { + puVar15 = &UNK_230c9dcc; + } + mbedtls_debug_print_msg(ssl,3,"file1",0xa21,"got %s certificate request",puVar15); + if (ssl->client_auth != 0) { + ver = ssl->in_msg; + ssl->record_read = 0; + len = mbedtls_ssl_hs_hdr_len(); + buf_01 = (byte *)(uint)ver[len]; + buf_02 = buf_01 + len; + if ((byte *)ssl->in_hslen < buf_02 + 2) { + line_00 = 0xa48; +LAB_2309aaea: + mbedtls_debug_print_msg(ssl,1,"file1",line_00,"bad certificate request message"); + return -0x7a80; + } + if (ssl->minor_ver == 3) { + uVar10 = ver[(int)(buf_02 + 1)]; + uVar1 = ver[(int)(buf_02 + 2)]; + pbVar22 = ver + (int)(buf_02 + 3); + while (pbVar22 + -(int)(ver + (int)(buf_02 + 3)) < (byte *)(uint)CONCAT11(uVar10,uVar1)) { + mbedtls_debug_print_msg + (ssl,3,"file1",0xa58,"Supported Signature Algorithm found: %d,%d",(uint)*pbVar22 + ,(uint)pbVar22[1]); + pbVar22 = pbVar22 + 2; + } + buf_01 = (byte *)(uint)CONCAT11(uVar10,uVar1) + (int)(buf_01 + 2); + len = mbedtls_ssl_hs_hdr_len(); + if ((byte *)ssl->in_hslen < buf_01 + len + 2) { + line_00 = 0xa60; + goto LAB_2309aaea; + } + } + len = mbedtls_ssl_hs_hdr_len(); + buf_01 = buf_01 + len; + if ((byte *)ssl->in_hslen != + buf_01 + (uint)CONCAT11((ver + (int)buf_01)[1],(ver + (int)buf_01)[2]) + 3) { + line_00 = 0xa6d; + goto LAB_2309aaea; + } + } + format = "<= parse certificate request"; + line_00 = 0xa72; + goto LAB_2309a036; + case 6: + mbedtls_debug_print_msg(ssl,2,"file1",0xa81,"=> parse server hello done"); + if (ssl->record_read == 0) { + line_00 = mbedtls_ssl_read_record(ssl); + if (line_00 != 0) { + line = 0xa87; +LAB_2309aa3a: + mbedtls_debug_print_ret(ssl,1,"file1",line,"mbedtls_ssl_read_record",line_00); + return line_00; + } + if (ssl->in_msgtype != 0x16) { + format = "bad server hello done message"; + line_00 = 0xa8d; + goto LAB_2309a092; + } + } + pmVar16 = ssl->conf; + ssl->record_read = 0; + len = mbedtls_ssl_hs_hdr_len(); + if ((ssl->in_hslen != len) || (*ssl->in_msg != '\x0e')) { + mbedtls_debug_print_msg(ssl,1,"file1",0xa96,"bad server hello done message"); + return -0x7b80; + } + ssl->state = ssl->state + 1; + if ((*(ushort *)&pmVar16->field_0x74 & 2) != 0) { + mbedtls_ssl_recv_flight_completed(ssl); + } + format = "<= parse server hello done"; + line_00 = 0xaa1; +LAB_2309a036: + mbedtls_debug_print_msg(ssl,2,"file1",line_00,format); + __n_00 = ret; + break; + case 7: + __n_00 = mbedtls_ssl_write_certificate(ssl); + break; + case 8: + ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + mbedtls_debug_print_msg(ssl,2,"file1",0xaac,"=> write client key exchange"); + if (ciphersuite_info->key_exchange != MBEDTLS_KEY_EXCHANGE_RSA) { + line_00 = 0xb91; +LAB_2309a9bc: + mbedtls_debug_print_msg(ssl,1,"file1",line_00,"should never happen"); + return -0x6c00; + } + pmVar16 = ssl->conf; + pmVar19 = ssl->handshake; + line_00 = ssl->minor_ver; + ver = pmVar19->premaster; + mbedtls_ssl_write_version + ((uint)pmVar16->max_major_ver,(uint)pmVar16->max_minor_ver, + *(uint *)&pmVar16->field_0x74 >> 1 & 1,ver); + bVar7 = line_00 != 0; + ret = (*ssl->conf->f_rng)(ssl->conf->p_rng,pmVar19->premaster + 2,0x2e); + line_00 = (uint)bVar7 * 2 + 4; + if (ret == 0) { + ssl->handshake->pmslen = 0x30; + pmVar12 = ssl->session_negotiate->peer_cert; + if (pmVar12 == (mbedtls_x509_crt *)0x0) { + format = "certificate required"; + line_00 = 0x801; + line = 2; + goto LAB_2309a098; + } + line = mbedtls_pk_can_do(&pmVar12->pk,MBEDTLS_PK_RSA); + if (line == 0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x80b,"certificate key type mismatch"); + return -0x6d00; + } + ret = mbedtls_pk_encrypt(&ssl->session_negotiate->peer_cert->pk,ver,ssl->handshake->pmslen, + ssl->out_msg + line_00,(size_t *)&major_ver,0x4000 - line_00, + (anon_subr_int_void_ptr_uchar_ptr_size_t *)ssl->conf->f_rng, + ssl->conf->p_rng); + if (ret == 0) { + if (bVar7) { + ssl->out_msg[4] = (uchar)((uint)major_ver >> 8); + ssl->out_msg[5] = (uchar)major_ver; + major_ver = major_ver + 2; + } + ssl->out_msglen = major_ver + 4; + ssl->out_msgtype = 0x16; + *ssl->out_msg = '\x10'; + ssl->state = ssl->state + 1; + ret = mbedtls_ssl_write_record(ssl); + if (ret == 0) { + format = "<= write client key exchange"; + line_00 = 0xba1; + goto LAB_2309a036; + } + format = "mbedtls_ssl_write_record"; + line_00 = 0xb9d; + } + else { + format = "mbedtls_rsa_pkcs1_encrypt"; + line_00 = 0x815; + } + } + else { + format = "f_rng"; + line_00 = 0x7f9; + } + goto LAB_23099f16; + case 9: + ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + local_74 = 0; + mbedtls_debug_print_msg(ssl,2,"file1",0xbd2,"=> write certificate verify"); + ret = mbedtls_ssl_derive_keys(ssl); + if (ret == 0) { + mVar2 = ciphersuite_info->key_exchange; + if (((byte)(mVar2 + ~MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA) < 4) || + (mVar2 == MBEDTLS_KEY_EXCHANGE_ECJPAKE)) { + format = "<= skip write certificate verify"; + line_00 = 0xbe0; + } + else { + if ((ssl->client_auth != 0) && + ((((pmVar19 = ssl->handshake, pmVar19 != (mbedtls_ssl_handshake_params *)0x0 && + (pmVar17 = pmVar19->key_cert, pmVar17 != (mbedtls_ssl_key_cert *)0x0)) || + (pmVar17 = ssl->conf->key_cert, pmVar17 != (mbedtls_ssl_key_cert *)0x0)) && + (pmVar17->cert != (mbedtls_x509_crt *)0x0)))) { + pk = mbedtls_ssl_own_key(ssl); + if (pk == (mbedtls_pk_context *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0xbee,"got no private key for certificate"); + return -0x7600; + } + (*pmVar19->calc_verify)(ssl,(uchar *)&major_ver); + if (ssl->minor_ver != 3) { + line_00 = 0xc3d; + goto LAB_2309a9bc; + } + md_alg = ssl->transform_negotiate->ciphersuite_info->mac; + if (md_alg == MBEDTLS_MD_SHA384) { + ssl->out_msg[4] = '\x05'; + } + else { + ssl->out_msg[4] = '\x04'; + md_alg = MBEDTLS_MD_SHA256; + } + pk = mbedtls_ssl_own_key(ssl); + ver = ssl->out_msg; + uVar10 = mbedtls_ssl_sig_from_pk(pk); + ver[5] = uVar10; + pk = mbedtls_ssl_own_key(ssl); + ret = mbedtls_pk_sign(pk,md_alg,(uchar *)&major_ver,0,ssl->out_msg + 8,&local_74, + (anon_subr_int_void_ptr_uchar_ptr_size_t *)ssl->conf->f_rng, + ssl->conf->p_rng); + if (ret == 0) { + ssl->out_msg[6] = (uchar)(local_74 >> 8); + ssl->out_msg[7] = (uchar)local_74; + ssl->out_msglen = local_74 + 8; + ssl->out_msgtype = 0x16; + *ssl->out_msg = '\x0f'; + ssl->state = ssl->state + 1; + ret = mbedtls_ssl_write_record(ssl); + if (ret == 0) { + format = "<= write certificate verify"; + line_00 = 0xc58; + goto LAB_2309a036; + } + format = "mbedtls_ssl_write_record"; + line_00 = 0xc54; + } + else { + format = "mbedtls_pk_sign"; + line_00 = 0xc45; + } + goto LAB_23099f16; + } + format = "<= skip write certificate verify"; + line_00 = 0xbe7; + } + goto LAB_2309a8ea; + } + format = "mbedtls_ssl_derive_keys"; + line_00 = 0xbd6; + goto LAB_23099f16; + case 10: + __n_00 = mbedtls_ssl_write_change_cipher_spec(ssl); + break; + case 0xb: + __n_00 = mbedtls_ssl_write_finished(ssl); + break; + case 0xc: + __n_00 = mbedtls_ssl_parse_change_cipher_spec(ssl); + break; + case 0xd: + __n_00 = mbedtls_ssl_parse_finished(ssl); + break; + case 0xe: + mbedtls_debug_print_msg(ssl,2,"file1",0xd3e,"handshake: done"); + line_00 = 0xf; + __n_00 = ret; +LAB_2309a8fc: + ssl->state = line_00; + break; + case 0xf: + mbedtls_ssl_handshake_wrapup(ssl); + __n_00 = ret; + break; + default: + format = "invalid state %d"; + line_00 = 0xd47; + goto LAB_2309a492; + case 0x11: + mbedtls_debug_print_msg(ssl,2,"file1",0xc6c,"=> parse new session ticket"); + ret = mbedtls_ssl_read_record(ssl); + if (ret == 0) { + if (ssl->in_msgtype == 0x16) { + ver = ssl->in_msg; + if (*ver == '\x04') { + __n_00 = ssl->in_hslen; + len = mbedtls_ssl_hs_hdr_len(); + if (len + 6 <= __n_00) { + buf_02 = ver + len; + bVar3 = *buf_02; + size = ((uint)*(ushort *)(buf_02 + 4) & 0xff) << 8 | + (uint)(*(ushort *)(buf_02 + 4) >> 8); + bVar4 = buf_02[1]; + bVar5 = buf_02[2]; + bVar6 = buf_02[3]; + if (__n_00 != len + 6 + size) { + line_00 = 0xc94; + goto LAB_2309b098; + } + mbedtls_debug_print_msg(ssl,3,"file1",0xc98,"ticket length: %d",size); + ssl->handshake->new_session_ticket = 0; + ssl->state = 0xc; + if (size == 0) { + return 0; + } + buf_00 = ssl->session_negotiate->ticket; + ver = buf_00 + ssl->session_negotiate->ticket_len; + while (buf_00 != ver) { + *buf_00 = '\0'; + buf_00 = buf_00 + 1; + } + vPortFree(ssl->session_negotiate->ticket); + ssl->session_negotiate->ticket = (uchar *)0x0; + ssl->session_negotiate->ticket_len = 0; + ver = (uchar *)mycalloc(1,size); + if (ver == (uchar *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0xcad,"ticket alloc failed"); + return -0x7f00; + } + memcpy(ver,buf_02 + 6,size); + ssl->session_negotiate->ticket = ver; + ssl->session_negotiate->ticket_len = size; + ssl->session_negotiate->ticket_lifetime = + (uint)bVar3 << 0x18 | (uint)bVar4 << 0x10 | (uint)bVar6 | (uint)bVar5 << 8; + mbedtls_debug_print_msg(ssl,3,"file1",0xcbc,"ticket in use, discarding session id"); + format = "<= parse new session ticket"; + ssl->session_negotiate->id_len = 0; + line_00 = 0xcbf; + goto LAB_2309a036; + } + } + line_00 = 0xc87; +LAB_2309b098: + mbedtls_debug_print_msg(ssl,1,"file1",line_00,"bad new session ticket message"); + return -0x6e00; + } + format = "bad new session ticket message"; + line_00 = 0xc76; + goto LAB_2309a092; + } + format = "mbedtls_ssl_read_record"; + line_00 = 0xc70; +LAB_23099f16: + mbedtls_debug_print_ret(ssl,1,"file1",line_00,format,ret); + __n_00 = ret; + } + return __n_00; +} + + + +mbedtls_pk_context * mbedtls_ssl_own_key(mbedtls_ssl_context *ssl) + +{ + mbedtls_ssl_key_cert *pmVar1; + + if (((ssl->handshake != (mbedtls_ssl_handshake_params *)0x0) && + (pmVar1 = ssl->handshake->key_cert, pmVar1 != (mbedtls_ssl_key_cert *)0x0)) || + (pmVar1 = ssl->conf->key_cert, pmVar1 != (mbedtls_ssl_key_cert *)0x0)) { + pmVar1 = (mbedtls_ssl_key_cert *)pmVar1->key; + } + return (mbedtls_pk_context *)pmVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int mbedtls_ssl_handshake_server_step(mbedtls_ssl_context *ssl) + +{ + byte bVar1; + mbedtls_key_exchange_type_t mVar2; + ushort uVar3; + char cVar4; + mbedtls_x509_crt *pmVar5; + ushort *buf; + uchar *__n; + uchar *puVar6; + mbedtls_ssl_handshake_params *pmVar7; + mbedtls_ssl_ciphersuite_t *info; + uchar message; + mbedtls_md_type_t md_alg; + mbedtls_pk_type_t type; + int ret; + int iVar8; + undefined3 extraout_var; + undefined3 extraout_var_00; + size_t __n_00; + undefined3 extraout_var_01; + mbedtls_pk_context *ctx; + size_t sVar9; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + ushort *puVar10; + uint uVar11; + int line; + mbedtls_ssl_config *pmVar12; + char *format; + anon_subr_int_void_ptr_mbedtls_ssl_session_ptr_for_f_get_cache *paVar13; + mbedtls_ssl_session *pmVar14; + undefined *puVar15; + uchar *buf_00; + uchar *hash; + uint sig_len; + byte *pbVar16; + byte *input; + uint ilen; + byte *buf_01; + uint uVar17; + byte *len; + uint *puVar18; + uchar *puVar19; + size_t len_00; + int *piVar20; + int line_00; + byte *pbVar21; + uint uVar22; + mbedtls_ssl_key_cert *pmVar23; + uchar *puVar24; + byte *pbVar25; + byte *pbVar26; + char **ppcVar27; + mbedtls_ssl_key_cert *pmVar28; + byte bStack236; + byte bStack235; + uchar ver [2]; + int major; + int minor; + undefined4 local_b4; + mbedtls_ssl_session session; + + if ((ssl->state == 0x10) || (ssl->handshake == (mbedtls_ssl_handshake_params *)0x0)) { + return -0x7100; + } + mbedtls_debug_print_msg(ssl,2,"file1",0xede,"server state: %d"); + ret = mbedtls_ssl_flush_output(ssl); + if (ret != 0) { + return ret; + } + if ((((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) && + (ssl->handshake->retransmit_state == '\x01')) && + (line_00 = mbedtls_ssl_resend(ssl), line_00 != 0)) { + return line_00; + } + line_00 = ssl->state; + switch(line_00) { + case 0: + ssl->state = 1; + break; + case 1: + mbedtls_debug_print_msg(ssl,2,"file1",0x440,"=> parse client hello"); + line = mbedtls_ssl_fetch_input(ssl,5); + if (line == 0) { + input = ssl->in_hdr; + len_00 = 5; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + len_00 = 0xd; + } + mbedtls_debug_print_buf(ssl,4,"file1",0x45f,"record header",input,len_00); + mbedtls_debug_print_msg(ssl,3,"file1",0x46b,"client hello v3, message type: %d",(uint)*input); + if (*input != 0x16) { + ret = 0x46f; + goto LAB_2309b3c2; + } + mbedtls_debug_print_msg + (ssl,3,"file1",0x474,"client hello v3, message len.: %d", + ((uint)*(ushort *)ssl->in_len & 0xff) << 8 | (uint)(*(ushort *)ssl->in_len >> 8)); + mbedtls_debug_print_msg + (ssl,3,"file1",0x477,"client hello v3, protocol version: [%d:%d]",(uint)input[1], + (uint)input[2]); + mbedtls_ssl_read_version((int *)ver,&major,*(uint *)&ssl->conf->field_0x74 >> 1 & 1,input + 1) + ; + if ((int)_ver < 3) { + ret = 0x481; + goto LAB_2309b3c2; + } + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + hash = ssl->in_ctr; + if ((*hash != '\0') || (hash[1] != '\0')) { + ret = 0x491; + goto LAB_2309b3c2; + } + memcpy(ssl->out_ctr + 2,hash + 2,6); + } + ilen = ((uint)*(ushort *)ssl->in_len & 0xff) << 8 | (uint)(*(ushort *)ssl->in_len >> 8); + if (0x4000 < ilen) { + ret = 0x4b3; + goto LAB_2309b3c2; + } + ret = 5; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + ret = 0xd; + } + iVar8 = mbedtls_ssl_fetch_input(ssl,ret + ilen); + if (iVar8 != 0) { + format = "mbedtls_ssl_fetch_input"; + ret = 0x4b9; + line_00 = iVar8; + goto LAB_2309b350; + } + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + ssl->in_left = 0; + } + else { + ssl->next_record_offset = ilen + 0xd; + } + input = ssl->in_msg; + mbedtls_debug_print_buf(ssl,4,"file1",0x4c8,"record contents",input,ilen); + (*ssl->handshake->update_checksum)(ssl,input,ilen); + sig_len = 4; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + sig_len = 0xc; + } + if (ilen < sig_len) { + ret = 0x4d6; + goto LAB_2309b3c2; + } + mbedtls_debug_print_msg + (ssl,3,"file1",0x4da,"client hello v3, handshake type: %d",(uint)*input); + if (*input != 1) { + ret = 0x4de; + goto LAB_2309b3c2; + } + mbedtls_debug_print_msg + (ssl,3,"file1",0x4e3,"client hello v3, handshake len.: %d", + (uint)input[1] << 0x10 | (uint)input[2] << 8 | (uint)input[3]); + if (input[1] == 0) { + ret = 4; + uVar3 = *(ushort *)&ssl->conf->field_0x74; + if ((uVar3 & 2) != 0) { + ret = 0xc; + } + if (ilen == ((uint)(*(ushort *)(input + 2) >> 8) | + ((uint)*(ushort *)(input + 2) & 0xff) << 8) + ret) { + if ((uVar3 & 2) == 0) { +LAB_2309b678: + ret = 4; + } + else { + sig_len = ((uint)*(ushort *)(ssl->in_msg + 4) & 0xff) << 8 | + (uint)(*(ushort *)(ssl->in_msg + 4) >> 8); + ssl->handshake->out_msg_seq = sig_len; + ssl->handshake->in_msg_seq = sig_len + 1; + hash = ssl->in_msg; + if ((((hash[6] != '\0') || (hash[7] != '\0')) || (hash[8] != '\0')) || + (ret = memcmp(hash + 1,hash + 9,3), ret != 0)) { + mbedtls_debug_print_msg(ssl,1,"file1",0x515,"ClientHello fragmentation not supported") + ; + return -0x7080; + } + ret = 0xc; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) goto LAB_2309b678; + } + input = input + ret; + pbVar21 = (byte *)(ilen - ret); + if (pbVar21 < (byte *)0x26) { + ret = 0x535; + goto LAB_2309b3c2; + } + mbedtls_debug_print_buf(ssl,3,"file1",0x53c,"client hello, version",input,2); + mbedtls_ssl_read_version + (&ssl->major_ver,&ssl->minor_ver,*(uint *)&ssl->conf->field_0x74 >> 1 & 1,input) + ; + ssl->handshake->max_major_ver = ssl->major_ver; + ret = ssl->minor_ver; + ssl->handshake->max_minor_ver = ret; + pmVar12 = ssl->conf; + if ((ssl->major_ver < (int)(uint)pmVar12->min_major_ver) || + (ret < (int)(uint)pmVar12->min_minor_ver)) { + mbedtls_debug_print_msg + (ssl,1,"file1",0x54a, + "client only supports ssl smaller than minimum [%d:%d] < [%d:%d]"); + mbedtls_ssl_send_alert_message(ssl,'\x02','F'); + return -0x6e80; + } + if ((int)(uint)pmVar12->max_major_ver < ssl->major_ver) { + ssl->major_ver = (uint)pmVar12->max_major_ver; + ilen = (uint)pmVar12->max_minor_ver; +LAB_2309b738: + ssl->minor_ver = ilen; + } + else { + ilen = (uint)pmVar12->max_minor_ver; + if ((int)ilen < ret) goto LAB_2309b738; + } + mbedtls_debug_print_buf(ssl,3,"file1",0x55d,"client hello, random bytes",input + 2,0x20); + memcpy(ssl->handshake->randbytes,input + 2,0x20); + ilen = (uint)input[0x22]; + if ((0x20 < input[0x22]) || (len = (byte *)(ilen + 0x24), pbVar21 < len)) { + ret = 0x569; + goto LAB_2309b3c2; + } + mbedtls_debug_print_buf(ssl,3,"file1",0x56d,"client hello, session id",input + 0x23,ilen); + ssl->session_negotiate->id_len = ilen; + buf_01 = (byte *)(ilen + 0x23); + memset(ssl->session_negotiate->id,0,0x20); + memcpy(ssl->session_negotiate->id,input + 0x23,ssl->session_negotiate->id_len); + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + bVar1 = input[(int)buf_01]; + if (pbVar21 < buf_01 + (uint)bVar1 + 3) { + ret = 0x580; + goto LAB_2309b3c2; + } + mbedtls_debug_print_buf + (ssl,3,"file1",0x585,"client hello, cookie",input + (int)len,(uint)bVar1); + if (bVar1 != 0) { + ret = 0x5a1; + goto LAB_2309b3c2; + } + mbedtls_debug_print_msg(ssl,2,"file1",0x5a5,"cookie verification skipped"); + buf_01 = len; + } + bVar1 = (input + (int)buf_01)[1]; + uVar3 = CONCAT11(input[(int)buf_01],bVar1); + len = (byte *)(uint)uVar3; + if (1 < uVar3) { + pbVar25 = len + (int)buf_01; + if ((pbVar25 + 3 <= pbVar21) && (ilen = (uint)len & 1, (bVar1 & 1) == 0)) { + buf_01 = input + (int)(buf_01 + 2); + mbedtls_debug_print_buf + (ssl,3,"file1",0x5bd,"client hello, ciphersuitelist",buf_01,(size_t)len); + sig_len = (uint)input[(int)(pbVar25 + 2)]; + if (sig_len - 1 < 0x10) { + pbVar26 = pbVar25 + 2 + sig_len; + pbVar16 = pbVar26 + 1; + if (pbVar16 <= pbVar21) { + mbedtls_debug_print_buf + (ssl,3,"file1",0x5cf,"client hello, compression", + input + (int)(pbVar25 + 3),sig_len); + ssl->session_negotiate->compression = 0; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + ssl->session_negotiate->compression = 0; + } + pbVar25 = pbVar26 + 3; + if (pbVar16 < pbVar21) { + if (pbVar21 < pbVar25) { + ret = 0x5f0; + goto LAB_2309b3c2; + } + ilen = (uint)CONCAT11(input[(int)pbVar16],input[(int)(pbVar26 + 2)]); + if ((ilen - 1 < 3) || (pbVar21 != pbVar25 + ilen)) { + ret = 0x5fa; + goto LAB_2309b3c2; + } + } + buf = (ushort *)(input + (int)pbVar25); + mbedtls_debug_print_buf + (ssl,3,"file1",0x602,"client hello extensions",(uchar *)buf,ilen); + do { + input = buf_01; + if (ilen == 0) goto LAB_2309b99a; + sig_len = (uint)(*buf >> 8) | ((uint)*buf & 0xff) << 8; + uVar17 = ((uint)buf[1] & 0xff) << 8 | (uint)(buf[1] >> 8); + uVar22 = uVar17 + 4; + if (ilen < uVar22) { + ret = 0x60d; + goto LAB_2309b3c2; + } + if (sig_len == 0xd) { + mbedtls_debug_print_msg + (ssl,3,"file1",0x62c,"found signature_algorithms extension"); + uVar3 = buf[2] >> 8; + if ((uVar17 == (((uint)buf[2] & 0xff) << 8 | (uint)uVar3) + 2) && + ((uVar3 & 1) == 0)) { + piVar20 = ssl->conf->sig_hashes; + while (*piVar20 != 0) { + puVar10 = buf + 3; + while (puVar10 < (ushort *)((int)buf + uVar22)) { + ret = *piVar20; + md_alg = mbedtls_ssl_md_alg_from_hash(*(byte *)puVar10); + if (ret == CONCAT31(extraout_var,md_alg)) { + ret = 0xe4; + ssl->handshake->sig_alg = (uint)*(byte *)puVar10; + format = "client hello v3, signature_algorithm ext: %d"; + sig_len = ssl->handshake->sig_alg; + goto LAB_2309bd02; + } + puVar10 = puVar10 + 1; + } + piVar20 = piVar20 + 1; + } + format = "no signature_algorithm in common"; + ret = 0xdf; + goto LAB_2309bcb4; + } + ret = 0xcb; + goto LAB_2309b3c2; + } + if (sig_len < 0xe) { + if (sig_len == 0) { + mbedtls_debug_print_msg(ssl,3,"file1",0x614,"found ServerName extension"); + if (ssl->conf->f_sni != + ( + anon_subr_int_void_ptr_mbedtls_ssl_context_ptr_uchar_ptr_size_t_for_f_sni + *)0x0) { + mbedtls_debug_print_msg(ssl,3,"file1",0x62,"parse ServerName extension"); + sig_len = ((uint)buf[2] & 0xff) << 8 | (uint)(buf[2] >> 8); + if (uVar17 != sig_len + 2) { + ret = 0x67; + goto LAB_2309b3c2; + } + puVar10 = buf + 3; + while (sig_len != 0) { + uVar11 = ((uint)*(ushort *)((int)puVar10 + 1) & 0xff) << 8 | + (uint)(*(ushort *)((int)puVar10 + 1) >> 8); + if (sig_len < uVar11 + 3) { + ret = 0x71; + goto LAB_2309b3c2; + } + if (*(byte *)puVar10 == 0) { + ret = (*ssl->conf->f_sni)(ssl->conf->p_sni,ssl, + (byte *)((int)puVar10 + 3),uVar11); + if (ret != 0) { + mbedtls_debug_print_ret(ssl,1,"file1",0x7b,"ssl_sni_wrapper",ret); + message = 'p'; + goto LAB_2309bbe4; + } + break; + } + sig_len = sig_len + (-3 - uVar11); + puVar10 = (ushort *)((int)puVar10 + uVar11 + 3); + } + } + } + else { + if (sig_len == 1) { + mbedtls_debug_print_msg + (ssl,3,"file1",0x65a,"found max fragment length extension"); + if ((uVar17 != 1) || (4 < *(byte *)(buf + 2))) { + ret = 0x16a; + goto LAB_2309b3c2; + } + ssl->session_negotiate->mfl_code = *(byte *)(buf + 2); + } + else { +LAB_2309ba6c: + format = "unknown extension found: %d (ignoring)"; + ret = 0x696; +LAB_2309bd02: + mbedtls_debug_print_msg(ssl,3,"file1",ret,format,sig_len); + } + } + } + else { + if (sig_len == 0x23) { + mbedtls_debug_print_msg + (ssl,3,"file1",0x682,"found session ticket extension"); + mbedtls_ssl_session_init((mbedtls_ssl_session *)&local_b4); + if ((ssl->conf->f_ticket_parse != + ( + anon_subr_int_void_ptr_mbedtls_ssl_session_ptr_uchar_ptr_size_t_for_f_ticket_parse + *)0x0) && + (ssl->conf->f_ticket_write != + ( + anon_subr_int_void_ptr_mbedtls_ssl_session_ptr_uchar_ptr_uchar_ptr_size_t_ptr_uint32_t_ptr_for_f_ticket_write + *)0x0)) { + ssl->handshake->new_session_ticket = 1; + mbedtls_debug_print_msg(ssl,3,"file1",0x1c9,"ticket length: %d",uVar17); + if (uVar17 != 0) { + ret = (*ssl->conf->f_ticket_parse) + (ssl->conf->p_ticket,(mbedtls_ssl_session *)&local_b4, + (uchar *)(buf + 2),uVar17); + if (ret == 0) { + session.compression = ssl->session_negotiate->id_len; + memcpy(&session.id_len,ssl->session_negotiate->id,session.compression) + ; + mbedtls_ssl_session_free(ssl->session_negotiate); + memcpy(ssl->session_negotiate,&local_b4,0x74); + hash = &local_b4; + do { + *hash = '\0'; + hash = hash + 1; + } while (hash != &session.mfl_code); + mbedtls_debug_print_msg + (ssl,3,"file1",0x1f5, + "session successfully restored from ticket"); + ssl->handshake->resume = 1; + ssl->handshake->new_session_ticket = 0; + } + else { + mbedtls_ssl_session_free((mbedtls_ssl_session *)&local_b4); + if (ret == -0x7180) { + format = "ticket is not authentic"; + ret = 0x1df; + } + else { + if (ret != -0x6d80) { + mbedtls_debug_print_ret + (ssl,1,"file1",0x1e3,"mbedtls_ssl_ticket_parse",ret); + goto LAB_2309bb62; + } + format = "ticket is expired"; + ret = 0x1e1; + } +LAB_2309bcb4: + mbedtls_debug_print_msg(ssl,3,"file1",ret,format); + } + } + } + } + else { + if (sig_len == 0xff01) { + mbedtls_debug_print_msg + (ssl,3,"file1",0x61f,"found renegotiation extension"); + if ((uVar17 != 1) || (*(byte *)(buf + 2) != 0)) { + format = "non-zero length renegotiation info"; + ret = 0xad; + goto LAB_2309bc2a; + } + ssl->secure_renegotiation = 1; + } + else { + if (sig_len != 0x10) goto LAB_2309ba6c; + mbedtls_debug_print_msg(ssl,3,"file1",0x68c,"found alpn extension"); + ppcVar27 = ssl->conf->alpn_list; + if (ppcVar27 != (char **)0x0) { + if (uVar17 < 4) { + return -0x7900; + } + if (((uint)(buf[2] >> 8) | ((uint)buf[2] & 0xff) << 8) != uVar17 - 2) { + return -0x7900; + } + while (*ppcVar27 != (char *)0x0) { + __n_00 = strlen(*ppcVar27); + puVar10 = buf + 3; + while ((ushort *)((int)buf + uVar22) != puVar10) { + if ((ushort *)((int)buf + uVar22) < puVar10) { + return -0x7900; + } + bVar1 = *(byte *)puVar10; + if (bVar1 == 0) { + return -0x7900; + } + if ((__n_00 == (uint)bVar1) && + (ret = memcmp((byte *)((int)puVar10 + 1),*ppcVar27,__n_00), + ret == 0)) { + ssl->alpn_chosen = *ppcVar27; + goto LAB_2309bb62; + } + puVar10 = (ushort *)((byte *)((int)puVar10 + 1) + (uint)bVar1); + } + ppcVar27 = ppcVar27 + 1; + } + message = 'x'; +LAB_2309bbe4: + mbedtls_ssl_send_alert_message(ssl,'\x02',message); + return -0x7900; + } + } + } + } +LAB_2309bb62: + ret = ilen - uVar17; + ilen = ret - 4; + buf = (ushort *)((int)buf + uVar22); + } while (2 < ret - 5U); + ret = 0x69e; + goto LAB_2309b3c2; + } + } + ret = 0x5ca; + goto LAB_2309b3c2; + } + } + ret = 0x5b8; + goto LAB_2309b3c2; + } + } + ret = 0x4e9; +LAB_2309b3c2: + mbedtls_debug_print_msg(ssl,1,"file1",ret,"bad client hello message"); + return -0x7900; + } + format = "mbedtls_ssl_fetch_input"; + ret = 0x450; + line_00 = line; + goto LAB_2309b350; + case 2: + mbedtls_debug_print_msg(ssl,2,"file1",0x8b1,"=> write server hello"); + if (ssl->conf->f_rng == (mbedtls_ssl_recv_t *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x8c0,"no RNG provided"); + return -0x7400; + } + puVar24 = ssl->out_msg; + mbedtls_ssl_write_version + (ssl->major_ver,ssl->minor_ver,*(uint *)&ssl->conf->field_0x74 >> 1 & 1,puVar24 + 4); + mbedtls_debug_print_msg + (ssl,3,"file1",0x8d3,"server hello, chosen version: [%d:%d]",(uint)puVar24[4], + (uint)puVar24[5]); + hash = puVar24 + 6; + ret = (*ssl->conf->f_rng)(ssl->conf->p_rng,hash,4); + if (ret != 0) { + return ret; + } + ret = (*ssl->conf->f_rng)(ssl->conf->p_rng,puVar24 + 10,0x1c); + if (ret != 0) { + return ret; + } + memcpy(ssl->handshake->randbytes + 0x20,hash,0x20); + mbedtls_debug_print_buf(ssl,3,"file1",0x8eb,"server hello, random bytes",hash,0x20); + if ((ssl->handshake->resume == 0) && (ssl->session_negotiate->id_len != 0)) { + paVar13 = ssl->conf->f_get_cache; + if ((paVar13 != (anon_subr_int_void_ptr_mbedtls_ssl_session_ptr_for_f_get_cache *)0x0) && + (ret = (*paVar13)(ssl->conf->p_cache,ssl->session_negotiate), ret == 0)) { + mbedtls_debug_print_msg(ssl,3,"file1",0x8fa,"session successfully restored from cache"); + ssl->handshake->resume = 1; + } + } + pmVar14 = ssl->session_negotiate; + if (ssl->handshake->resume == 0) { + ssl->state = ssl->state + 1; + if (ssl->handshake->new_session_ticket == 0) { + pmVar14->id_len = 0x20; + len_00 = 0x20; + ret = (*ssl->conf->f_rng)(ssl->conf->p_rng,ssl->session_negotiate->id,0x20); + if (ret != 0) { + return ret; + } + } + else { + pmVar14->id_len = 0; + memset(ssl->session_negotiate->id,0,0x20); + len_00 = 0; + } + } + else { + len_00 = pmVar14->id_len; + ssl->state = 0xc; + line_00 = mbedtls_ssl_derive_keys(ssl); + if (line_00 != 0) { + format = "mbedtls_ssl_derive_keys"; + ret = 0x923; + goto LAB_2309b350; + } + } + hash = puVar24 + 0x27; + puVar24[0x26] = (uchar)ssl->session_negotiate->id_len; + memcpy(hash,ssl->session_negotiate->id,ssl->session_negotiate->id_len); + sVar9 = ssl->session_negotiate->id_len; + mbedtls_debug_print_msg(ssl,3,"file1",0x934,"server hello, session id len.: %d",len_00); + mbedtls_debug_print_buf(ssl,3,"file1",0x935,"server hello, session id",hash,len_00); + hash = hash + sVar9; + if (ssl->handshake->resume == 0) { + puVar15 = &UNK_230c9dcc; + } + else { + puVar15 = (undefined *)0x230c3fb8; + } + mbedtls_debug_print_msg(ssl,3,"file1",0x937,"%s session has been resumed",puVar15); + puVar19 = hash + 3; + *hash = (uchar)((uint)ssl->session_negotiate->ciphersuite >> 8); + hash[1] = (uchar)ssl->session_negotiate->ciphersuite; + hash[2] = (uchar)ssl->session_negotiate->compression; + format = mbedtls_ssl_get_ciphersuite_name(ssl->session_negotiate->ciphersuite); + mbedtls_debug_print_msg(ssl,3,"file1",0x93e,"server hello, chosen ciphersuite: %s",format); + mbedtls_debug_print_msg + (ssl,3,"file1",0x940,"server hello, compress alg.: 0x%02X", + ssl->session_negotiate->compression); + puVar6 = (uchar *)0x0; + if (ssl->secure_renegotiation == 1) { + mbedtls_debug_print_msg(ssl,3,"file1",0x7c3,"server hello, secure renegotiation extension"); + hash[5] = -1; + hash[6] = '\x01'; + hash[7] = '\0'; + hash[8] = '\x01'; + hash[9] = '\0'; + puVar6 = hash + (10 - (int)(hash + 5)); + } + ret = 0; + if (ssl->session_negotiate->mfl_code != '\0') { + mbedtls_debug_print_msg(ssl,3,"file1",0x7ec,"server hello, max_fragment_length extension"); + __n = puVar6 + 2 + (int)puVar19; + *__n = '\0'; + __n[1] = '\x01'; + __n[2] = '\0'; + __n[3] = '\x01'; + __n[4] = ssl->session_negotiate->mfl_code; + ret = 5; + } + puVar6 = puVar6 + ret; + ret = 0; + if (ssl->handshake->new_session_ticket != 0) { + mbedtls_debug_print_msg(ssl,3,"file1",0x7ab,"server hello, adding session ticket extension"); + __n = puVar19 + (int)(puVar6 + 2); + *__n = '\0'; + __n[1] = '#'; + __n[2] = '\0'; + __n[3] = '\0'; + ret = 4; + } + line_00 = 0; + if (ssl->alpn_chosen != (char *)0x0) { + mbedtls_debug_print_msg(ssl,3,"file1",0x84f,"server hello, adding alpn extension"); + __n = puVar19 + (int)(puVar6 + ret + 2); + __n[1] = '\x10'; + *__n = '\0'; + __n_00 = strlen(ssl->alpn_chosen); + line_00 = __n_00 + 7; + __n[2] = (uchar)(__n_00 + 3 >> 8); + cVar4 = (char)line_00; + __n[3] = cVar4 + -4; + __n[4] = (uchar)(__n_00 + 1 >> 8); + __n[5] = cVar4 + -6; + __n[6] = cVar4 + -7; + memcpy(__n + 7,ssl->alpn_chosen,__n_00); + } + puVar6 = puVar6 + ret + line_00; + mbedtls_debug_print_msg(ssl,3,"file1",0x977,"server hello, total extension length: %d",puVar6); + if (puVar6 != (uchar *)0x0) { + hash[3] = (uchar)((uint)puVar6 >> 8); + hash[4] = (uchar)puVar6; + puVar19 = hash + 5 + (int)puVar6; + } + ssl->out_msgtype = 0x16; + *(uchar **)&ssl->out_msglen = puVar19 + -(int)puVar24; + *ssl->out_msg = '\x02'; + line_00 = mbedtls_ssl_write_record(ssl); + format = "<= write server hello"; + line = 0x98a; + goto LAB_2309c0d4; + case 3: + line_00 = mbedtls_ssl_write_certificate(ssl); + break; + case 4: + info = ssl->transform_negotiate->ciphersuite_info; + mbedtls_debug_print_msg(ssl,2,"file1",0xa7f,"=> write server key exchange"); + mVar2 = info->key_exchange; + if (((mVar2 & 0xfb) == 1) || (mVar2 == MBEDTLS_KEY_EXCHANGE_RSA_PSK)) { + format = "<= skip write server key exchange"; + line_00 = 0xa88; +LAB_2309c5f8: + mbedtls_debug_print_msg(ssl,2,"file1",line_00,format); + line_00 = ssl->state + 1; + goto LAB_2309c60a; + } + ssl->out_msglen = 4; + ssl->out_msgtype = 0x16; + *ssl->out_msg = '\f'; + ssl->state = ssl->state + 1; + line_00 = mbedtls_ssl_write_record(ssl); + if (line_00 != 0) { + format = "mbedtls_ssl_write_record"; + ret = 0xbd4; + goto LAB_2309b350; + } + format = "<= write server key exchange"; + line = 0xbd8; + goto LAB_2309c0d4; + case 5: + info = ssl->transform_negotiate->ciphersuite_info; + hash = ssl->out_msg; + mbedtls_debug_print_msg(ssl,2,"file1",0x9b5,"=> write certificate request"); + ssl->state = ssl->state + 1; + ilen = ssl->handshake->sni_authmode; + if (ilen == 3) { + ilen = *(uint *)&ssl->conf->field_0x74 >> 2 & 3; + } + mVar2 = info->key_exchange; + if ((((byte)(mVar2 + ~MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA) < 4) || + (mVar2 == MBEDTLS_KEY_EXCHANGE_ECJPAKE)) || (ilen == 0)) { + format = "<= skip write certificate request"; + line = 0x9c7; + line_00 = ret; + } + else { + puVar19 = ssl->out_msg; + ret = 0; + puVar19[5] = '\x01'; + puVar19[4] = '\x01'; + puVar6 = puVar19 + 6; + puVar24 = puVar6; + if (ssl->minor_ver == 3) { + line_00 = 0; + piVar20 = ssl->conf->sig_hashes; + while( true ) { + ret = line_00 + 2; + puVar24 = puVar6 + ret; + if (*piVar20 == 0) break; + message = mbedtls_ssl_hash_from_md_alg(*piVar20); + if ((CONCAT31(extraout_var_01,message) != 0) && + (line = mbedtls_ssl_set_calc_verify_md(ssl,CONCAT31(extraout_var_01,message)), + line == 0)) { + *puVar24 = message; + puVar6[line_00 + 3] = '\x01'; + line_00 = ret; + } + piVar20 = piVar20 + 1; + } + puVar19[6] = (uchar)((uint)line_00 >> 8); + puVar19[7] = (uchar)line_00; + } + puVar24 = puVar24 + 2; + pmVar5 = ssl->handshake->sni_ca_chain; + if (pmVar5 == (mbedtls_x509_crt *)0x0) { + pmVar5 = ssl->conf->ca_chain; + } + hash = hash + 0x4000; + puVar6 = (uchar *)0x0; + while( true ) { + if ((pmVar5 == (mbedtls_x509_crt *)0x0) || (pmVar5->version == 0)) goto LAB_2309c766; + __n = (uchar *)(pmVar5->subject_raw).len; + if ((hash < puVar24) || ((hash + -(int)puVar24 < __n || (hash + -(int)puVar24 < __n + 2)))) + break; + *puVar24 = (uchar)((uint)__n >> 8); + puVar24[1] = (uchar)__n; + buf_00 = puVar24 + 2; + memcpy(buf_00,(pmVar5->subject_raw).p,(size_t)__n); + puVar24 = buf_00 + (int)__n; + puVar6 = __n + 2 + (int)puVar6; + mbedtls_debug_print_buf(ssl,3,"file1",0xa38,"requested DN",buf_00,(size_t)__n); + pmVar5 = pmVar5->next; + } + mbedtls_debug_print_msg(ssl,1,"file1",0xa2f,"skipping CAs: buffer too short"); +LAB_2309c766: + *(uchar **)&ssl->out_msglen = puVar24 + -(int)puVar19; + ssl->out_msgtype = 0x16; + *ssl->out_msg = '\r'; + ssl->out_msg[ret + 6] = (uchar)((uint)puVar6 >> 8); + ssl->out_msg[ret + 7] = (uchar)puVar6; + line_00 = mbedtls_ssl_write_record(ssl); + format = "<= write certificate request"; + line = 0xa46; + } +LAB_2309c0d4: + mbedtls_debug_print_msg(ssl,2,"file1",line,format); + break; + case 6: + mbedtls_debug_print_msg(ssl,2,"file1",0xbe1,"=> write server hello done"); + ssl->out_msglen = 4; + ssl->out_msgtype = 0x16; + *ssl->out_msg = '\x0e'; + ssl->state = ssl->state + 1; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + mbedtls_ssl_send_flight_completed(ssl); + } + line_00 = mbedtls_ssl_write_record(ssl); + if (line_00 == 0) { + format = "<= write server hello done"; + line = 0xbf4; + goto LAB_2309c0d4; + } + format = "mbedtls_ssl_write_record"; + ret = 0xbf0; + goto LAB_2309b350; + case 7: + line_00 = mbedtls_ssl_parse_certificate(ssl); + break; + case 8: + info = ssl->transform_negotiate->ciphersuite_info; + mbedtls_debug_print_msg(ssl,2,"file1",0xcd4,"=> parse client key exchange"); + line_00 = mbedtls_ssl_read_record(ssl); + if (line_00 == 0) { + hash = ssl->in_msg; + ret = 4; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + ret = 0xc; + } + len_00 = ssl->in_hslen; + input = hash + ret; + if (ssl->in_msgtype == 0x16) { + if (*hash == '\x10') { + if (info->key_exchange != MBEDTLS_KEY_EXCHANGE_RSA) { + ret = 0xdb5; +LAB_2309bf30: + mbedtls_debug_print_msg(ssl,1,"file1",ret,"should never happen"); + ret = -0x7000; + goto LAB_2309c914; + } + ctx = mbedtls_ssl_own_key(ssl); + sVar9 = mbedtls_pk_get_bitlen(ctx); + ctx = mbedtls_ssl_own_key(ssl); + ilen = sVar9 + 7 >> 3; + pmVar7 = ssl->handshake; + ret = mbedtls_pk_can_do(ctx,MBEDTLS_PK_RSA); + if (ret == 0) { + mbedtls_debug_print_msg(ssl,1,"file1",0xc34,"got no RSA private key"); + line_00 = -0x7600; + } + else { + if ((ssl->minor_ver == 0) || + (((uint)*input == (sVar9 + 7 >> 0xb & 0xff) && + (pbVar21 = input + 1, input = input + 2, (uint)*pbVar21 == (ilen & 0xff))))) { + if (hash + len_00 == input + ilen) { + mbedtls_ssl_write_version + (ssl->handshake->max_major_ver,ssl->handshake->max_minor_ver, + *(uint *)&ssl->conf->field_0x74 >> 1 & 1,&bStack236); + line_00 = (*ssl->conf->f_rng)(ssl->conf->p_rng,(uchar *)&major,0x30); + if (line_00 == 0) { + ctx = mbedtls_ssl_own_key(ssl); + ilen = mbedtls_pk_decrypt(ctx,input,ilen,&local_b4,(size_t *)ver,0x30, + (anon_subr_int_void_ptr_uchar_ptr_size_t *) + ssl->conf->f_rng,ssl->conf->p_rng); + ilen = ilen | (uint)(byte)((byte)local_b4 ^ bStack236 | local_b4._1_1_ ^ bStack235 + ) | _ver ^ 0x30; + ssl->handshake->pmslen = 0x30; + bVar1 = (char)((byte)(ilen >> 0x18) | (byte)(-ilen >> 0x18)) >> 7; + ilen = 0; + while (ilen < ssl->handshake->pmslen) { + pmVar7->premaster[ilen] = + (&local_b4)[ilen] & ~bVar1 | *(byte *)((int)&major + ilen) & bVar1; + ilen = ilen + 1; + } + line_00 = mbedtls_ssl_derive_keys(ssl); + if (line_00 == 0) { + ssl->state = ssl->state + 1; + format = "<= parse client key exchange"; + line = 0xdc1; + goto LAB_2309c0d4; + } + format = "mbedtls_ssl_derive_keys"; + ret = 0xdbb; + goto LAB_2309b350; + } + goto LAB_2309c984; + } + ret = 0xc4a; + } + else { + ret = 0xc42; + } + mbedtls_debug_print_msg(ssl,1,"file1",ret,"bad client key exchange message"); + line_00 = -0x7c00; + } +LAB_2309c984: + format = "ssl_parse_parse_encrypted_pms_secret"; + ret = 0xd98; + goto LAB_2309b350; + } + ret = 0xce7; + } + else { + ret = 0xce1; + } + mbedtls_debug_print_msg(ssl,1,"file1",ret,"bad client key exchange message"); + ret = -0x8000; +LAB_2309c914: + return ret + 0x400; + } + format = "mbedtls_ssl_read_record"; + ret = 0xcd8; + goto LAB_2309b350; + case 9: + info = ssl->transform_negotiate->ciphersuite_info; + mbedtls_debug_print_msg(ssl,2,"file1",0xdee,"=> parse certificate verify"); + mVar2 = info->key_exchange; + if ((((byte)(mVar2 + ~MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA) < 4) || + (mVar2 == MBEDTLS_KEY_EXCHANGE_ECJPAKE)) || + (ssl->session_negotiate->peer_cert == (mbedtls_x509_crt *)0x0)) { + format = "<= skip parse certificate verify"; + line_00 = 0xdf7; + goto LAB_2309c5f8; + } + do { + line_00 = mbedtls_ssl_read_record_layer(ssl); + if (line_00 != 0) { + format = "mbedtls_ssl_read_record_layer"; + ret = 0xe01; + goto LAB_2309b350; + } + line_00 = mbedtls_ssl_handle_message_type(ssl); + } while (line_00 == -0x6680); + if (line_00 == 0) { + ssl->state = ssl->state + 1; + if ((ssl->in_msgtype != 0x16) || (*ssl->in_msg != '\x0f')) { + format = "bad certificate verify message"; + ret = 0xe15; + goto LAB_2309cbc6; + } + ret = 4; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + ret = 0xc; + } + if (ssl->minor_ver != 3) { + ret = 0xe6c; + goto LAB_2309bf30; + } + if (ssl->in_hslen < ret + 2U) { + format = "bad certificate verify message"; + ret = 0xe39; +LAB_2309cbc6: + mbedtls_debug_print_msg(ssl,1,"file1",ret,format); + return -0x7d80; + } + md_alg = mbedtls_ssl_md_alg_from_hash(ssl->in_msg[ret]); + if ((CONCAT31(extraout_var_02,md_alg) == 0) || + (line_00 = mbedtls_ssl_set_calc_verify_md(ssl,(uint)ssl->in_msg[ret]), line_00 != 0)) { + format = "peer not adhering to requested sig_alg for verify message"; + ret = 0xe45; + goto LAB_2309cbc6; + } + hash = &local_b4; + if (CONCAT31(extraout_var_02,md_alg) == 4) { + hash = session.id; + } + type = mbedtls_ssl_pk_alg_from_sig(ssl->in_msg[ret + 1]); + if (CONCAT31(extraout_var_03,type) == 0) { + format = "peer not adhering to requested sig_alg for verify message"; + ret = 0xe5a; + goto LAB_2309cbc6; + } + line_00 = mbedtls_pk_can_do(&ssl->session_negotiate->peer_cert->pk,type); + if (line_00 == 0) { + format = "sig_alg doesn\'t match cert key"; + ret = 0xe63; + goto LAB_2309cbc6; + } + ilen = ret + 4; + if (ssl->in_hslen < ilen) { + format = "bad certificate verify message"; + ret = 0xe72; + goto LAB_2309cbc6; + } + sig_len = (uint)CONCAT11(ssl->in_msg[ret + 2U],ssl->in_msg[ret + 3]); + if (ssl->in_hslen != ilen + sig_len) { + format = "bad certificate verify message"; + ret = 0xe7b; + goto LAB_2309cbc6; + } + (*ssl->handshake->calc_verify)(ssl,&local_b4); + line_00 = mbedtls_pk_verify(&ssl->session_negotiate->peer_cert->pk,md_alg,hash,0, + ssl->in_msg + ilen,sig_len); + if (line_00 == 0) { + mbedtls_ssl_update_handshake_status(ssl); + format = "<= parse certificate verify"; + line = 0xe8c; + goto LAB_2309c0d4; + } + format = "mbedtls_pk_verify"; + ret = 0xe86; + } + else { + format = "mbedtls_ssl_handle_message_type"; + ret = 0xe0b; + } + goto LAB_2309b350; + case 10: + line_00 = mbedtls_ssl_parse_change_cipher_spec(ssl); + break; + case 0xb: + line_00 = mbedtls_ssl_parse_finished(ssl); + break; + case 0xc: + if (ssl->handshake->new_session_ticket == 0) { + ret = mbedtls_ssl_write_change_cipher_spec(ssl); + return ret; + } + mbedtls_debug_print_msg(ssl,2,"file1",0xe9e,"=> write new session ticket"); + ssl->out_msgtype = 0x16; + *ssl->out_msg = '\x04'; + ret = (*ssl->conf->f_ticket_write) + (ssl->conf->p_ticket,ssl->session_negotiate,ssl->out_msg + 10, + ssl->out_msg + 0x4000,(size_t *)&major,(uint32_t *)&local_b4); + if (ret != 0) { + mbedtls_debug_print_ret(ssl,1,"file1",0xeb4,"mbedtls_ssl_ticket_write",ret); + major = 0; + } + ssl->out_msg[4] = (uchar)(local_b4 >> 0x18); + ssl->out_msg[5] = (uchar)(local_b4 >> 0x10); + ssl->out_msg[6] = (uchar)(local_b4 >> 8); + ssl->out_msg[7] = (uchar)local_b4; + ssl->out_msg[8] = (uchar)((uint)major >> 8); + ssl->out_msg[9] = (uchar)major; + ssl->out_msglen = major + 10; + ssl->handshake->new_session_ticket = 0; + line_00 = mbedtls_ssl_write_record(ssl); + if (line_00 == 0) { + format = "<= write new session ticket"; + line = 0xece; + goto LAB_2309c0d4; + } + format = "mbedtls_ssl_write_record"; + ret = 0xeca; +LAB_2309b350: + mbedtls_debug_print_ret(ssl,1,"file1",ret,format,line_00); + break; + case 0xd: + line_00 = mbedtls_ssl_write_finished(ssl); + break; + case 0xe: + mbedtls_debug_print_msg(ssl,2,"file1",0xf47,"handshake: done"); + line_00 = 0xf; +LAB_2309c60a: + ssl->state = line_00; + line_00 = ret; + break; + case 0xf: + mbedtls_ssl_handshake_wrapup(ssl); + line_00 = ret; + break; + default: + mbedtls_debug_print_msg(ssl,1,"file1",0xf50,"invalid state %d",line_00); + return -0x7100; + case 0x12: + line_00 = -0x6a80; + } + return line_00; +LAB_2309b99a: + if ((*input == 0) && (input[1] == 0xff)) { + mbedtls_debug_print_msg(ssl,3,"file1",0x6c4,"received TLS_EMPTY_RENEGOTIATION_INFO "); + ssl->secure_renegotiation = 1; + goto LAB_2309b9c8; + } + input = input + 2; + if (len <= input + -(int)buf_01) { + if ((ssl->secure_renegotiation != 1) && ((*(ushort *)&ssl->conf->field_0x74 & 0x30) == 0x20)) { + format = "legacy renegotiation, breaking off handshake"; + ret = 0x6db; +LAB_2309bc2a: + mbedtls_debug_print_msg(ssl,1,"file1",ret,format); + ret = mbedtls_ssl_send_fatal_handshake_failure(ssl); + if (ret == 0) { + return -0x7900; + } + return ret; + } +LAB_2309b9c8: + puVar18 = (uint *)ssl->conf->ciphersuite_list[ssl->minor_ver]; + ret = 0; + do { + input = buf_01; + if (*puVar18 == 0) { + if (ret == 0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x728,"got no ciphersuites in common"); + mbedtls_ssl_send_fatal_handshake_failure(ssl); + return -0x7380; + } + mbedtls_debug_print_msg + (ssl,1,"file1",0x722,"got ciphersuites in common, but none of them usable"); + mbedtls_ssl_send_fatal_handshake_failure(ssl); + return -0x6980; + } + do { + ilen = *puVar18; + if (((uint)*input == ((int)ilen >> 8 & 0xffU)) && ((uint)input[1] == (ilen & 0xff))) { + info = mbedtls_ssl_ciphersuite_from_id(ilen); + if (info == (mbedtls_ssl_ciphersuite_t *)0x0) { + ret = 0x2cc; + goto LAB_2309bf30; + } + mbedtls_debug_print_msg(ssl,3,"file1",0x2d0,"trying ciphersuite: %s",info->name); + ret = line_00; + if ((ssl->minor_ver < info->min_minor_ver) || (info->max_minor_ver < ssl->minor_ver)) { + format = "ciphersuite mismatch: version"; + line = 0x2d5; + } + else { + if (((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) && ((info->flags & 4) != 0)) + goto LAB_2309bf82; + type = mbedtls_ssl_get_ciphersuite_sig_pk_alg(info); + pmVar28 = ssl->handshake->sni_key_cert; + if (pmVar28 == (mbedtls_ssl_key_cert *)0x0) { + pmVar28 = ssl->conf->key_cert; + } + if (CONCAT31(extraout_var_00,type) == 0) { +have_ciphersuite: + mbedtls_debug_print_msg(ssl,2,"file1",0x72e,"selected ciphersuite: %s",info->name); + ssl->session_negotiate->ciphersuite = *puVar18; + ssl->transform_negotiate->ciphersuite_info = info; + ssl->state = ssl->state + 1; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + mbedtls_ssl_recv_flight_completed(ssl); + } + format = "<= parse client hello"; + line = 0x73a; + line_00 = iVar8; + goto LAB_2309c0d4; + } + mbedtls_debug_print_msg(ssl,3,"file1",0x26f,"ciphersuite requires certificate"); + pmVar23 = (mbedtls_ssl_key_cert *)0x0; + if (pmVar28 == (mbedtls_ssl_key_cert *)0x0) { + mbedtls_debug_print_msg(ssl,3,"file1",0x273,"server has no certificate"); + } + else { + do { + mbedtls_debug_print_crt + (ssl,3,"file1",0x27a,"candidate certificate chain, certificate", + pmVar28->cert); + line = mbedtls_pk_can_do(pmVar28->key,type); + if (line == 0) { + format = "certificate mismatch: key type"; + line = 0x27e; + } + else { + line = mbedtls_ssl_check_cert_usage(pmVar28->cert,info,1,(uint32_t *)&local_b4); + if (line == 0) { + if ((2 < ssl->minor_ver) || (pmVar28->cert->sig_md == MBEDTLS_MD_SHA1)) + goto LAB_2309c056; + if (pmVar23 == (mbedtls_ssl_key_cert *)0x0) { + pmVar23 = pmVar28; + } + format = "certificate not preferred: sha-2 with pre-TLS 1.2 client"; + line = 0x2a7; + } + else { + format = "certificate mismatch: (extended) key usage extension"; + line = 0x28e; + } + } + mbedtls_debug_print_msg(ssl,3,"file1",line,format); + pmVar28 = pmVar28->next; + } while (pmVar28 != (mbedtls_ssl_key_cert *)0x0); + pmVar28 = pmVar23; + if (pmVar23 != (mbedtls_ssl_key_cert *)0x0) { +LAB_2309c056: + ssl->handshake->key_cert = pmVar28; + mbedtls_debug_print_crt + (ssl,3,"file1",0x2b8,"selected certificate chain, certificate", + ssl->handshake->key_cert->cert); + goto have_ciphersuite; + } + } + format = "ciphersuite mismatch: no suitable certificate"; + line = 0x316; + } + mbedtls_debug_print_msg(ssl,3,"file1",line,format); + } +LAB_2309bf82: + input = input + 2; + } while (input + -(int)buf_01 < len); + puVar18 = puVar18 + 1; + } while( true ); + } + goto LAB_2309b99a; +} + + + +int mbedtls_x509_get_serial(uchar **p,uchar *end,mbedtls_x509_buf *serial) + +{ + int iVar1; + byte *pbVar2; + uchar *puVar3; + + pbVar2 = *p; + if ((int)(end + -(int)pbVar2) < 1) { + return -0x22e0; + } + if ((*pbVar2 & 0x7f) == 2) { + *p = pbVar2 + 1; + serial->tag = (uint)*pbVar2; + iVar1 = mbedtls_asn1_get_len(p,end,&serial->len); + if (iVar1 == 0) { + puVar3 = *p; + serial->p = puVar3; + *p = puVar3 + serial->len; + } + else { + iVar1 = iVar1 + -0x2280; + } + return iVar1; + } + return -0x22e2; +} + + + +int mbedtls_x509_get_alg(uchar **p,uchar *end,mbedtls_x509_buf *alg,mbedtls_x509_buf *params) + +{ + int iVar1; + + iVar1 = mbedtls_asn1_get_alg(p,end,(mbedtls_asn1_buf *)alg,(mbedtls_asn1_buf *)params); + if (iVar1 != 0) { + iVar1 = iVar1 + -0x2300; + } + return iVar1; +} + + + +int mbedtls_x509_get_name(uchar **p,uchar *end,mbedtls_x509_name *cur) + +{ + mbedtls_x509_name *pmVar1; + int iVar2; + mbedtls_asn1_named_data *pmVar3; + uchar *puVar4; + byte *pbVar5; + uchar *end_00; + size_t sStack56; + size_t set_len; + size_t len; + +LAB_2309cf62: + iVar2 = mbedtls_asn1_get_tag(p,end,&sStack56,0x31); + if (iVar2 != 0) { + return iVar2 + -0x2380; + } + end_00 = *p + sStack56; + pmVar1 = cur; + do { + iVar2 = mbedtls_asn1_get_tag(p,end_00,&set_len,0x30); + if (iVar2 == 0) { + if ((int)(end_00 + -(int)*p) < 1) { + return -0x23e0; + } + (pmVar1->oid).tag = (uint)**p; + iVar2 = mbedtls_asn1_get_tag(p,end_00,&(pmVar1->oid).len,6); + if (iVar2 != 0) goto LAB_2309cfae; + puVar4 = *p; + (pmVar1->oid).p = puVar4; + pbVar5 = puVar4 + (pmVar1->oid).len; + *p = pbVar5; + if ((int)(end_00 + -(int)pbVar5) < 1) { + return -0x23e0; + } + if ((0x1e < *pbVar5) || ((0x50581008U >> ((uint)*pbVar5 & 0x1f) & 1) == 0)) { + return -0x23e2; + } + *p = pbVar5 + 1; + (pmVar1->val).tag = (uint)*pbVar5; + iVar2 = mbedtls_asn1_get_len(p,end_00,&(pmVar1->val).len); + if (iVar2 != 0) goto LAB_2309cfae; + puVar4 = *p; + (pmVar1->val).p = puVar4; + *p = puVar4 + (pmVar1->val).len; + pmVar1->next = (mbedtls_asn1_named_data *)0x0; + } + else { +LAB_2309cfae: + if (iVar2 + -0x2380 != 0) { + return iVar2 + -0x2380; + } + } + if (*p == end_00) break; + pmVar1->next_merged = '\x01'; + pmVar3 = (mbedtls_asn1_named_data *)mycalloc(1,0x20); + pmVar1->next = pmVar3; + pmVar1 = (mbedtls_x509_name *)pmVar3; + if (pmVar3 == (mbedtls_asn1_named_data *)0x0) { + return -0x2880; + } + } while( true ); + if (end == end_00) { + return 0; + } + cur = (mbedtls_x509_name *)mycalloc(1,0x20); + *(mbedtls_x509_name **)&pmVar1->next = cur; + if (cur == (mbedtls_x509_name *)0x0) { + return -0x2880; + } + goto LAB_2309cf62; +} + + + +// WARNING: Variable defined which should be unmapped: len + +int mbedtls_x509_get_sig(uchar **p,uchar *end,mbedtls_x509_buf *sig) + +{ + byte bVar1; + int iVar2; + uchar *puVar3; + size_t sStack20; + size_t len; + + if (0 < (int)(end + -(int)*p)) { + bVar1 = **p; + iVar2 = mbedtls_asn1_get_bitstring_null(p,end,&sStack20); + if (iVar2 == 0) { + sig->tag = (uint)bVar1; + sig->len = sStack20; + puVar3 = *p; + sig->p = puVar3; + *p = puVar3 + sStack20; + } + else { + iVar2 = iVar2 + -0x2480; + } + return iVar2; + } + return -0x24e0; +} + + + +int mbedtls_x509_get_sig_alg + (mbedtls_x509_buf *sig_oid,mbedtls_x509_buf *sig_params,mbedtls_md_type_t *md_alg, + mbedtls_pk_type_t *pk_alg,void **sig_opts) + +{ + int iVar1; + + if (*sig_opts == (void *)0x0) { + iVar1 = mbedtls_oid_get_sig_alg((mbedtls_asn1_buf *)sig_oid,md_alg,pk_alg); + if (iVar1 == 0) { + if (((sig_params->tag != 5) && (sig_params->tag != 0)) || (sig_params->len != 0)) { + iVar1 = -0x2300; + } + } + else { + iVar1 = iVar1 + -0x2600; + } + return iVar1; + } + return -0x2800; +} + + + +int mbedtls_x509_get_ext(uchar **p,uchar *end,mbedtls_x509_buf *ext,int tag) + +{ + int iVar1; + uchar *end_00; + size_t sStack20; + size_t len; + + if (*p == end) { + return 0; + } + ext->tag = (uint)**p; + iVar1 = mbedtls_asn1_get_tag(p,end,&ext->len,tag | 0xa0); + if (iVar1 == 0) { + end_00 = *p; + ext->p = end_00; + end_00 = end_00 + ext->len; + iVar1 = mbedtls_asn1_get_tag(p,end_00,&sStack20,0x30); + if (iVar1 == 0) { + iVar1 = 0; + if (end_00 != *p + sStack20) { + iVar1 = -0x2566; + } + } + else { + iVar1 = iVar1 + -0x2500; + } + } + return iVar1; +} + + + +int mbedtls_x509_dn_gets(char *buf,size_t size,mbedtls_x509_name *dn) + +{ + size_t n; + uint n_00; + uint uVar1; + int iVar2; + char *format; + byte bVar3; + uchar uVar4; + uint uVar5; + mbedtls_x509_name *oid; + char *pcStack308; + char *short_name; + char s [256]; + + pcStack308 = (char *)0x0; + memset(&short_name,0,0x100); + uVar4 = '\0'; + n = size; + oid = dn; + do { + if (oid == (mbedtls_x509_name *)0x0) { + return size - n; + } + if ((oid->oid).p != (uchar *)0x0) { + if (oid != dn) { + format = " + "; + if (uVar4 == '\0') { + format = ", "; + } + uVar1 = snprintf(buf,n,format); + if ((int)uVar1 < 0) { + return -0x2980; + } + if (n <= uVar1) { + return -0x2980; + } + n = n - uVar1; + buf = buf + uVar1; + } + iVar2 = mbedtls_oid_get_attr_short_name((mbedtls_asn1_buf *)oid,&pcStack308); + if (iVar2 == 0) { + uVar1 = snprintf(buf,n,"%s=",pcStack308); + } + else { + uVar1 = snprintf(buf,n,"??="); + } + if (((int)uVar1 < 0) || (n <= uVar1)) { + return -0x2980; + } + n_00 = n - uVar1; + uVar5 = 0; + while ((uVar5 < (oid->val).len && (uVar5 != 0xff))) { + bVar3 = (oid->val).p[uVar5]; + if ((bVar3 < 0x20) || ((bVar3 == 0x7f || ((byte)(bVar3 + 0x7f) < 0x1f)))) { + bVar3 = 0x3f; + } + *(byte *)((int)&short_name + uVar5) = bVar3; + uVar5 = uVar5 + 1; + } + *(undefined *)((int)&short_name + uVar5) = 0; + uVar5 = snprintf(buf + uVar1,n_00,"%s",&short_name); + if ((int)uVar5 < 0) { + return -0x2980; + } + if (n_00 <= uVar5) { + return -0x2980; + } + n = n_00 - uVar5; + buf = buf + uVar1 + uVar5; + uVar4 = oid->next_merged; + } + oid = (mbedtls_x509_name *)oid->next; + } while( true ); +} + + + +int mbedtls_x509_serial_gets(char *buf,size_t size,mbedtls_x509_buf *serial) + +{ + size_t n; + uint uVar1; + undefined1 *puVar2; + uint uVar3; + uint uVar4; + + uVar4 = serial->len; + if (0x20 < uVar4) { + uVar4 = 0x1c; + } + uVar3 = 0; + n = size; + do { + if (uVar3 == uVar4) { + if (serial->len != uVar3) { + uVar4 = snprintf(buf,n,"...."); + if (((int)uVar4 < 0) || (n <= uVar4)) { + return -0x2980; + } + n = n - uVar4; + } + return size - n; + } + if (((uVar3 != 0) || (uVar4 == 1)) || (*serial->p != '\0')) { + puVar2 = (undefined1 *)0x230b8d1c; + if (uVar4 - 1 <= uVar3) { + puVar2 = &DAT_230c6dbc; + } + uVar1 = snprintf(buf,n,"%02X%s",(uint)serial->p[uVar3],puVar2); + if ((int)uVar1 < 0) { + return -0x2980; + } + if (n <= uVar1) { + return -0x2980; + } + n = n - uVar1; + buf = buf + uVar1; + } + uVar3 = uVar3 + 1; + } while( true ); +} + + + +int mbedtls_x509_sig_alg_gets + (char *buf,size_t size,mbedtls_x509_buf *sig_oid,mbedtls_pk_type_t pk_alg, + mbedtls_md_type_t md_alg,void *sig_opts) + +{ + int iVar1; + uint uVar2; + char *pcStack20; + char *desc; + + pcStack20 = (char *)0x0; + iVar1 = mbedtls_oid_get_sig_alg_desc((mbedtls_asn1_buf *)sig_oid,&pcStack20); + if (iVar1 == 0) { + uVar2 = snprintf(buf,size,"%s",pcStack20); + } + else { + uVar2 = snprintf(buf,size,"???"); + } + if (((int)uVar2 < 0) || (size <= uVar2)) { + uVar2 = 0xffffd680; + } + return uVar2; +} + + + +int mbedtls_x509_key_size_helper(char *buf,size_t buf_size,char *name) + +{ + uint uVar1; + int iVar2; + + uVar1 = snprintf(buf,buf_size,"%s key size",name); + if (((int)uVar1 < 0) || (buf_size <= uVar1)) { + iVar2 = -0x2980; + } + else { + iVar2 = 0; + } + return iVar2; +} + + + +int mbedtls_x509_time_is_past(mbedtls_x509_time *to) + +{ + return 0; +} + + + +undefined4 mbedtls_x509_time_is_future(void) + +{ + return 0; +} + + + +int mbedtls_base64_decode(uchar *dst,size_t dlen,size_t *olen,uchar *src,size_t slen) + +{ + byte bVar1; + byte bVar2; + int iVar3; + byte *pbVar4; + uint uVar5; + uchar *puVar6; + uint uVar7; + size_t sVar8; + uint uVar9; + int iVar10; + + uVar5 = 0; + uVar7 = 0; + sVar8 = 0; + while (sVar8 < slen) { + iVar3 = 0; + uVar9 = sVar8; + while( true ) { + bVar1 = src[uVar9]; + sVar8 = slen; + if (bVar1 != 0x20) break; + uVar9 = uVar9 + 1; + iVar3 = iVar3 + 1; + if (slen == uVar9) goto LAB_2309d47e; + } + if (slen == uVar9) break; + bVar2 = bVar1; + if ((1 < slen - uVar9) && (bVar1 == 0xd)) { + bVar2 = (src + uVar9)[1]; + } + if (bVar2 != 10) { + if (iVar3 != 0) { + return -0x2c; + } + if (bVar1 == 0x3d) { + uVar5 = uVar5 + 1; + if (2 < uVar5) { + return -0x2c; + } + } + else { + if ((char)bVar1 < '\0') { + return -0x2c; + } + } + if ( + "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f>\x7f\x7f\x7f?456789:;<=\x7f\x7f\x7f@\x7f\x7f\x7f" + [bVar1] == 0x7f) { + return -0x2c; + } + if (( + "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f>\x7f\x7f\x7f?456789:;<=\x7f\x7f\x7f@\x7f\x7f\x7f" + [bVar1] < 0x40) && (uVar5 != 0)) { + return -0x2c; + } + uVar7 = uVar7 + 1; + } + sVar8 = uVar9 + 1; + } +LAB_2309d47e: + if (uVar7 == 0) { + *olen = 0; + } + else { + uVar5 = ((uVar7 >> 3) * 6 - uVar5) + ((uVar7 & 7) * 6 + 7 >> 3); + if ((dst == (uchar *)0x0) || (dlen < uVar5)) { + *olen = uVar5; + return -0x2a; + } + pbVar4 = src + sVar8; + uVar5 = 0; + iVar10 = 3; + iVar3 = 0; + puVar6 = dst; + while (pbVar4 != src) { + uVar7 = (uint)*src - 10; + if ((0x16 < (uVar7 & 0xff)) || ((0x400009U >> (uVar7 & 0x1f) & 1) == 0)) { + uVar7 = uVar5 << 6; + iVar3 = iVar3 + 1; + iVar10 = iVar10 - (uint)( + "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f>\x7f\x7f\x7f?456789:;<=\x7f\x7f\x7f@\x7f\x7f\x7f" + [(uint)*src] == 0x40); + uVar5 = (uint) + "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f>\x7f\x7f\x7f?456789:;<=\x7f\x7f\x7f@\x7f\x7f\x7f" + [(uint)*src] & 0x3f | uVar7; + if ((iVar3 == 4) && (iVar3 = 0, iVar10 != 0)) { + *puVar6 = (uchar)(uVar7 >> 0x10); + if (iVar10 == 1) { + puVar6 = puVar6 + 1; + } + else { + puVar6[1] = (uchar)(uVar7 >> 8); + if (iVar10 == 2) { + puVar6 = puVar6 + 2; + } + else { + puVar6[2] = (uchar)uVar5; + puVar6 = puVar6 + 3; + } + } + } + } + src = src + 1; + } + *(uchar **)olen = puVar6 + -(int)dst; + } + return 0; +} + + + +int utils_notifier_chain_init(ntf_list_t *nl) + +{ + utils_list_init((utils_list *)nl); + return 0; +} + + + +int utils_notifier_chain_register(ntf_list_t *nl,utils_notifier_t *node) + +{ + if ((nl != (ntf_list_t *)0x0) && (node != (utils_notifier_t *)0x0)) { + utils_list_push_back((utils_list *)nl,(utils_list_hdr *)node); + return 0; + } + return -1; +} + + + +// WARNING: Type propagation algorithm not settling + +int utils_notifier_chain_call(ntf_list_t *nl,void *env) + +{ + int *piVar1; + + if (nl != (ntf_list_t *)0x0) { + piVar1 = (int *)nl->first; + while (piVar1 != (int *)0x0) { + if ((code *)piVar1[1] != (code *)0x0) { + (*(code *)piVar1[1])(piVar1[2],env); + } + piVar1 = (int *)*piVar1; + } + return 0; + } + return 0; +} + + + +double fabs(double __x) + +{ + double in_fa0; + + return in_fa0; +} + + + +double floor(double __x) + +{ + uint uVar1; + uint in_a0; + uint in_a1; + uint uVar2; + double in_fa0; + + uVar2 = (int)in_a1 >> 0x14 & 0x7ff; + uVar1 = uVar2 - 0x3ff; + if ((int)uVar1 < 0x14) { + if ((int)uVar1 < 0) { + in_fa0 = (double)__adddf3(); + __gedf2(); + } + else { + if ((0xfffff >> (uVar1 & 0x1f) & in_a1 | in_a0) != 0) { + in_fa0 = (double)__adddf3(); + __gedf2(); + } + } + } + else { + if ((int)uVar1 < 0x34) { + if ((0xffffffffU >> (uVar2 - 0x413 & 0x1f) & in_a0) != 0) { + in_fa0 = (double)__adddf3(); + __gedf2(); + } + } + else { + if (uVar1 == 0x400) { + in_fa0 = (double)__adddf3(); + } + } + } + return in_fa0; +} + + + +double modf(double __x,double *__iptr) + +{ + double *in_a1; + double **in_a2; + uint uVar1; + uint uVar2; + double in_fa0; + DFtype DVar3; + + uVar1 = (int)in_a1 >> 0x14 & 0x7ff; + uVar2 = uVar1 - 0x3ff; + if ((int)uVar2 < 0x14) { + if ((int)uVar2 < 0) { + *in_a2 = (double *)0x0; + in_a2[1] = (double *)((uint)in_a1 & 0x80000000); + return in_fa0; + } + uVar1 = 0xfffff >> (uVar2 & 0x1f); + if ((uVar1 & (uint)in_a1 | (uint)__iptr) != 0) { + in_a1 = (double *)(~uVar1 & (uint)in_a1); + __iptr = (double *)0x0; +LAB_2309d8bc: + *in_a2 = __iptr; + in_a2[1] = in_a1; + DVar3 = __subdf3(); + return (double)DVar3; + } + } + else { + if (((int)uVar2 < 0x34) && + (uVar1 = 0xffffffff >> (uVar1 - 0x413 & 0x1f), (uVar1 & (uint)__iptr) != 0)) { + __iptr = (double *)(~uVar1 & (uint)__iptr); + goto LAB_2309d8bc; + } + } + in_a2[1] = in_a1; + *in_a2 = __iptr; + return in_fa0; +} + + + +double pow(double __x,double __y) + +{ + __gcc_CMPtype _Var1; + int iVar2; + undefined4 *extraout_a0; + undefined4 *extraout_a0_00; + undefined4 *extraout_a0_01; + undefined4 *puVar3; + double dVar4; + double extraout_fa1; + double __value; + double extraout_fa1_00; + + dVar4 = (double)__ieee754_pow(); + if ((__fdlib_version != -1) && (__value = extraout_fa1, _Var1 = __unorddf2(), _Var1 == 0)) { + _Var1 = __unorddf2(); + if (_Var1 == 0) { + _Var1 = __eqdf2(); + if (_Var1 == 0) { + _Var1 = __eqdf2(); + if (((_Var1 != 0) && (iVar2 = finite(__value), iVar2 != 0)) && + (_Var1 = __ledf2(), _Var1 < 0)) { + dVar4 = (double)__errno(); + *extraout_a0_01 = 0x21; + } + } + else { + iVar2 = finite(__value); + if (((iVar2 == 0) && (iVar2 = finite(__value), iVar2 != 0)) && + (iVar2 = finite(__value), iVar2 != 0)) { + _Var1 = __unorddf2(); + if (_Var1 == 0) { + dVar4 = (double)__errno(); + *extraout_a0_00 = 0x22; + __value = extraout_fa1_00; + _Var1 = __ledf2(); + if (_Var1 < 0) { + dVar4 = rint(__value); + __eqdf2(); + } + } + else { + puVar3 = (undefined4 *)__errno(); + *puVar3 = 0x21; + dVar4 = (double)__divdf3(); + } + } + else { + _Var1 = __eqdf2(); + if (((_Var1 == 0) && (iVar2 = finite(__value), iVar2 != 0)) && + (iVar2 = finite(__value), iVar2 != 0)) { + dVar4 = (double)__errno(); + *extraout_a0 = 0x22; + } + } + } + } + else { + __eqdf2(); + } + } + return dVar4; +} + + + +void __ieee754_pow(uint param_1,uint param_2,uint param_3,uint param_4,double param_5) + +{ + uint uVar1; + __gcc_CMPtype _Var2; + int __n; + uint uVar3; + int iVar4; + uint uVar5; + uint uVar6; + int iVar7; + uint uVar8; + SItype i; + + uVar6 = param_4 & 0x7fffffff; + if ((uVar6 | param_3) == 0) { + return; + } + uVar1 = param_2 & 0x7fffffff; + if (uVar1 < 0x7ff00001) { + if (uVar1 == 0x7ff00000) { + if ((param_1 != 0) || (0x7ff00000 < uVar6)) goto LAB_2309dcd4; + } + else { + if (0x7ff00000 < uVar6) goto LAB_2309dbd8; + } + if ((uVar6 != 0x7ff00000) || (param_3 == 0)) { + uVar8 = 0; + uVar3 = param_2; + if ((int)param_2 < 0) { + if (0x433fffff < uVar6) { + uVar8 = 2; + goto LAB_2309dc54; + } + if (uVar6 < 0x3ff00000) { +LAB_2309dd58: + if (param_3 == 0) goto LAB_2309dc60; + goto LAB_2309dd5c; + } + iVar7 = ((int)uVar6 >> 0x14) + -0x3ff; + if (0x14 < iVar7) { + uVar5 = param_3 >> (0x34U - iVar7 & 0x1f); + if (uVar5 << (0x34U - iVar7 & 0x1f) == param_3) { + uVar8 = 2 - (uVar5 & 1); + } + goto LAB_2309dd58; + } + if (param_3 == 0) { + uVar5 = (int)uVar6 >> (0x14U - iVar7 & 0x1f); + uVar8 = param_3; + if (uVar5 << (0x14U - iVar7 & 0x1f) == uVar6) { + uVar8 = 2 - (uVar5 & 1); + } + goto LAB_2309dc60; + } + fabs(param_5); + if (param_1 != 0) goto LAB_2309dea4; +LAB_2309ddc0: + if ((uVar1 == 0) || ((param_2 & 0x3fffffff) == 0x3ff00000)) { + if ((int)param_4 < 0) { + __divdf3(); + } + if (-1 < (int)param_2) { + return; + } + if ((uVar1 + 0xc0100000 | uVar8) != 0) { + return; + } + __subdf3(); + __divdf3(); + return; + } + } + else { +LAB_2309dc54: + if (param_3 == 0) { + if (uVar6 == 0x7ff00000) { + return; + } +LAB_2309dc60: + if (uVar6 == 0x3ff00000) { + if (-1 < (int)param_4) { + return; + } + __divdf3(); + return; + } + if (param_4 == 0x40000000) { + __muldf3(); + return; + } + if ((param_4 == 0x3fe00000) && (-1 < (int)param_2)) { + __ieee754_sqrt(param_1,param_2); + return; + } + } +LAB_2309dd5c: + fabs(param_5); + if (param_1 == 0) goto LAB_2309ddc0; + } + if ((uVar8 | 0xffffffffU - ((int)param_2 >> 0x1f)) == 0) { +LAB_2309dea4: + __subdf3(); + __divdf3(); + return; + } + if (0x41e00000 < uVar6) { + if (uVar6 < 0x43f00001) { + if (0x3feffffe < uVar1) { + if (0x3ff00000 < uVar1) goto LAB_2309de64; + __subdf3(); + __muldf3(); + __muldf3(); + __muldf3(); + __subdf3(); + __muldf3(); + __subdf3(); + __muldf3(); + __muldf3(); + __muldf3(); + __subdf3(); + __adddf3(); + __subdf3(); + __subdf3(); + goto LAB_2309e414; + } + } + else { + if (0x3fefffff < uVar1) { +LAB_2309de64: + if ((int)param_4 < 1) { + return; + } + goto LAB_2309dd98; + } + } + if (-1 < (int)param_4) { + return; + } +LAB_2309dd98: + __muldf3(); + return; + } + iVar7 = 0; + if ((param_2 & 0x7ff00000) == 0) { + uVar1 = uVar3; + __muldf3(); + iVar7 = -0x35; + } + i = ((int)uVar1 >> 0x14) + -0x3ff + iVar7; + if ((0x3988e < (uVar1 & 0xfffff)) && (0xbb679 < (uVar1 & 0xfffff))) { + i = i + 1; + } + __subdf3(); + __adddf3(); + __divdf3(); + __muldf3(); + __muldf3(); + __subdf3(); + __subdf3(); + __subdf3(); + __muldf3(); + __subdf3(); + __muldf3(); + __muldf3(); + __muldf3(); + __adddf3(); + __muldf3(); + __adddf3(); + __muldf3(); + __adddf3(); + __muldf3(); + __adddf3(); + __muldf3(); + __adddf3(); + __muldf3(); + __muldf3(); + __adddf3(); + __muldf3(); + __adddf3(); + __muldf3(); + __adddf3(); + __adddf3(); + __muldf3(); + __subdf3(); + __subdf3(); + __subdf3(); + __muldf3(); + __muldf3(); + __adddf3(); + __adddf3(); + __muldf3(); + __subdf3(); + __subdf3(); + __muldf3(); + __muldf3(); + __adddf3(); + __adddf3(); + __floatsidf(i); + __adddf3(); + __adddf3(); + __adddf3(); + __subdf3(); + __subdf3(); + __subdf3(); + __subdf3(); +LAB_2309e414: + __subdf3(); + __muldf3(); + __muldf3(); + __adddf3(); + __muldf3(); + __adddf3(); + if ((int)param_4 < 0x40900000) { + uVar6 = param_4 & 0x7fffffff; + if (0x4090cbff < uVar6) { + if ((param_4 + 0x3f6f3400 | param_3) != 0) goto LAB_2309e888; + __subdf3(); + _Var2 = __gedf2(); + if (-1 < _Var2) goto LAB_2309e888; + goto LAB_2309e534; + } + iVar7 = 0; + if (uVar6 < 0x3fe00001) goto LAB_2309e5bc; + uVar6 = (int)uVar6 >> 0x14; + } + else { + if ((param_4 + 0xbf700000 | param_3) != 0) { +LAB_2309e888: + __muldf3(); + __muldf3(); + return; + } + __adddf3(); + __subdf3(); + _Var2 = __gedf2(); + if (0 < _Var2) goto LAB_2309e888; +LAB_2309e534: + uVar6 = (int)param_4 >> 0x14 & 0x7ff; + } + uVar6 = (0x100000 >> (uVar6 - 0x3fe & 0x1f)) + param_4; + iVar7 = (int)(uVar6 & 0xfffff | 0x100000) >> + (0x14 - (((int)uVar6 >> 0x14 & 0x7ffU) - 0x3ff) & 0x1f); + if ((int)param_4 < 0) { + iVar7 = -iVar7; + } + __subdf3(); + __adddf3(); + iVar7 = iVar7 << 0x14; +LAB_2309e5bc: + __muldf3(); + __subdf3(); + __subdf3(); + __muldf3(); + __muldf3(); + __adddf3(); + __adddf3(); + __subdf3(); + __subdf3(); + __muldf3(); + __muldf3(); + __subdf3(); + __muldf3(); + __adddf3(); + __muldf3(); + __subdf3(); + __muldf3(); + __adddf3(); + __muldf3(); + __subdf3(); + __muldf3(); + __subdf3(); + __divdf3(); + __muldf3(); + __adddf3(); + __subdf3(); + __subdf3(); + __n = DAT_4200ed20; + iVar4 = DAT_4200ed24; + __subdf3(); + if (iVar7 + iVar4 >> 0x14 < 1) { + scalbn(param_5,__n); + } + __muldf3(); + return; + } + } +LAB_2309dbd8: + if ((uVar1 + 0xc0100000 | param_1) == 0) { + return; + } +LAB_2309dcd4: + nan(""); + return; +} + + + +uint __ieee754_sqrt(uint param_1,uint param_2) + +{ + int iVar1; + uint uVar2; + uint uVar3; + uint uVar4; + uint uVar5; + uint uVar6; + uint uVar7; + int iVar8; + uint uVar9; + int iVar10; + uint uVar11; + + if ((param_2 & 0x7ff00000) == 0x7ff00000) { + __muldf3(); + __adddf3(); + return param_1; + } + if ((int)param_2 < 1) { + if ((param_2 & 0x7fffffff | param_1) == 0) { + return param_1; + } + uVar6 = param_2; + if (param_2 != 0) { + __subdf3(); + __divdf3(); + return param_1; + } + do { + uVar7 = param_1; + param_2 = uVar7 >> 0xb; + uVar6 = uVar6 - 0x15; + param_1 = uVar7 << 0x15; + } while (param_2 == 0); + uVar5 = param_1; + if (-1 < (int)uVar7) goto LAB_2309ed04; + uVar3 = 0; + uVar7 = 0xffffffff; + } + else { + iVar10 = (int)param_2 >> 0x14; + if (iVar10 != 0) goto LAB_2309eb88; + uVar6 = 0; + uVar5 = param_1; +LAB_2309ed04: + uVar11 = 0; + uVar3 = param_2; + do { + uVar7 = uVar11; + param_2 = uVar3 << 1; + iVar10 = uVar3 << 0xc; + uVar11 = uVar7 + 1; + uVar3 = param_2; + } while (-1 < iVar10); + uVar3 = 0x20 - uVar11; + param_1 = uVar5 << (uVar11 & 0x1f); + } + iVar10 = uVar6 - uVar7; + param_2 = uVar5 >> (uVar3 & 0x1f) | param_2; +LAB_2309eb88: + uVar7 = (param_2 & 0xfffff | 0x100000) * 2 - ((int)param_1 >> 0x1f); + uVar6 = param_1 << 1; + if ((iVar10 - 0x3ffU & 1) != 0) { + uVar7 = uVar7 * 2 - ((int)uVar6 >> 0x1f); + uVar6 = param_1 << 2; + } + iVar10 = 0x16; + uVar11 = 0; + uVar5 = 0; + uVar3 = 0x200000; + do { + iVar1 = uVar5 + uVar3; + iVar10 = iVar10 + -1; + if (iVar1 <= (int)uVar7) { + uVar7 = uVar7 - iVar1; + uVar5 = iVar1 + uVar3; + uVar11 = uVar11 + uVar3; + } + uVar7 = uVar7 * 2 - ((int)uVar6 >> 0x1f); + uVar6 = uVar6 << 1; + uVar3 = uVar3 >> 1; + } while (iVar10 != 0); + uVar3 = 0; + uVar4 = 0x80000000; + iVar1 = 0x20; + do { + while (iVar8 = iVar1, uVar2 = uVar4 + iVar10, (int)uVar5 < (int)uVar7) { + uVar9 = uVar5; + if ((int)uVar2 < 0) { +LAB_2309ed44: + uVar9 = uVar5 - ((int)~(uVar2 + uVar4) >> 0x1f); + } + iVar1 = (uVar7 - uVar5) - (uint)(uVar6 < uVar2); + uVar5 = uVar9; +LAB_2309ec58: + iVar10 = uVar2 + uVar4; + uVar3 = uVar3 + uVar4; + uVar7 = iVar1 * 2 - ((int)(uVar6 - uVar2) >> 0x1f); + uVar6 = (uVar6 - uVar2) * 2; + uVar4 = uVar4 >> 1; + iVar1 = iVar8 + -1; + if (iVar8 + -1 == 0) goto LAB_2309ec80; + } + if ((uVar7 == uVar5) && (uVar2 <= uVar6)) { + if ((int)uVar2 < 0) goto LAB_2309ed44; + iVar1 = 0; + uVar5 = uVar7; + goto LAB_2309ec58; + } + uVar7 = uVar7 * 2 - ((int)uVar6 >> 0x1f); + uVar6 = uVar6 << 1; + uVar4 = uVar4 >> 1; + iVar1 = iVar8 + -1; + } while (iVar8 + -1 != 0); +LAB_2309ec80: + uVar5 = iVar8 - 1; + if ((uVar7 | uVar6) == 0) { + uVar5 = uVar3 >> 1; + } + else { + if (uVar3 == 0xffffffff) { + uVar11 = uVar11 + 1; + } + else { + uVar5 = uVar3 + 1 >> 1; + } + } + if ((uVar11 & 1) != 0) { + uVar5 = uVar5 | 0x80000000; + } + return uVar5; +} + + + +int finite(double __value) + +{ + uint in_a1; + + return (in_a1 & 0x7fffffff) + 0x80100000 >> 0x1f; +} + + + +double nan(char *__tagb) + +{ + double in_fa0; + + return in_fa0; +} + + + +double rint(double __x) + +{ + uint in_a0; + uint in_a1; + uint uVar1; + uint uVar2; + double in_fa0; + DFtype DVar3; + + uVar2 = (int)in_a1 >> 0x14 & 0x7ff; + uVar1 = uVar2 - 0x3ff; + if ((int)uVar1 < 0x14) { + if ((int)uVar1 < 0) { + if ((in_a1 & 0x7fffffff | in_a0) == 0) { + return in_fa0; + } + __adddf3(); + DVar3 = __subdf3(); + return (double)DVar3; + } + uVar1 = 0xfffff >> (uVar1 & 0x1f) & in_a1 | in_a0; + } + else { + if (0x33 < (int)uVar1) { + if (uVar1 != 0x400) { + return in_fa0; + } + DVar3 = __adddf3(); + return (double)DVar3; + } + uVar1 = 0xffffffffU >> (uVar2 - 0x413 & 0x1f) & in_a0; + } + if (uVar1 != 0) { + __adddf3(); + in_fa0 = (double)__subdf3(); + } + return in_fa0; +} + + + +double scalbn(double __x,int __n) + +{ + uint in_a1; + int in_a2; + uint uVar1; + int iVar2; + double in_fa0; + DFtype DVar3; + + uVar1 = (int)in_a1 >> 0x14 & 0x7ff; + if (uVar1 == 0) { + if ((in_a1 & 0x7fffffff | __n) == 0) { + return in_fa0; + } + in_fa0 = (double)__muldf3(); + if (in_a2 < -50000) { + DVar3 = __muldf3(); + return (double)DVar3; + } + uVar1 = ((int)in_a1 >> 0x14 & 0x7ffU) - 0x36; + } + else { + if (uVar1 == 0x7ff) { + DVar3 = __adddf3(); + return (double)DVar3; + } + } + iVar2 = in_a2 + uVar1; + if (iVar2 < 0x7ff) { + if (0 < iVar2) { + return in_fa0; + } + if (-0x36 < iVar2) { + DVar3 = __muldf3(); + return (double)DVar3; + } + if (in_a2 < 0xc351) goto LAB_2309f0e8; + } + if ((int)in_a1 < 0) { + DVar3 = __muldf3(); + return (double)DVar3; + } +LAB_2309f0e8: + DVar3 = __muldf3(); + return (double)DVar3; +} + + + +DItype __lshrdi3(shift_count_type b) + +{ + DItype in_fa0; + + return in_fa0; +} + + + +DItype __ashldi3(shift_count_type b) + +{ + DItype in_fa0; + + return in_fa0; +} + + + +int __clzsi2(USItype x) + +{ + int iVar1; + + if (x < 0x10000) { + iVar1 = (uint)(0xff < x) << 3; + } + else { + iVar1 = 0x10; + if (0xffffff < x) { + iVar1 = 0x18; + } + } + return (0x20 - iVar1) - (uint)""[x >> iVar1]; +} + + + +int __popcountsi2(USItype x) + +{ + uint uVar1; + + uVar1 = x - (x >> 1 & 0x55555555); + uVar1 = (uVar1 & 0x33333333) + (uVar1 >> 2 & 0x33333333); + return ((uVar1 >> 4) + uVar1 & 0xf0f0f0f) * 0x1010101 >> 0x18; +} + + + +SFtype __floatundisf(void) + +{ + USItype in_a0; + SFtype SVar1; + uint in_a1; + + if ((0x1fffff < in_a1) && ((in_a0 & 0x7ff) != 0)) { + in_a0 = in_a0 & 0xfffff800 | 0x800; + } + __floatunsidf(in_a1); + __muldf3(); + __floatunsidf(in_a0); + __adddf3(); + SVar1 = __truncdfsf2(); + return SVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +DItype __divdi3(void) + +{ + DItype in_fa0; + + return in_fa0; +} + + + +// WARNING: Type propagation algorithm not settling + +DItype __moddi3(void) + +{ + DItype in_fa0; + + return in_fa0; +} + + + +// WARNING: Type propagation algorithm not settling + +UDItype __udivdi3(void) + +{ + UDItype in_fa0; + + return in_fa0; +} + + + +// WARNING: Type propagation algorithm not settling + +UDItype __umoddi3(void) + +{ + UDItype in_fa0; + + return in_fa0; +} + + +/* +Unable to decompile '__adddf3' +Cause: Exception while decompiling 230a04b4: Decompiler process died + +*/ + +/* +Unable to decompile '__divdf3' +Cause: +Low-level Error: Assignment to constant at r0x230a1638 +*/ + + +__gcc_CMPtype __eqdf2(void) + +{ + uint in_a0; + uint in_a1; + uint in_a2; + uint in_a3; + uint uVar1; + uint uVar2; + uint uVar3; + + uVar1 = in_a1 >> 0x14 & 0x7ff; + uVar2 = in_a1 & 0xfffff; + uVar3 = in_a3 >> 0x14 & 0x7ff; + if (uVar1 == 0x7ff) { + if ((uVar2 | in_a0) != 0) { + return 1; + } + if (uVar3 != 0x7ff) { + return 1; + } + } + else { + if (uVar3 != 0x7ff) goto LAB_230a1908; + } + if ((in_a3 & 0xfffff | in_a2) != 0) { + return 1; + } +LAB_230a1908: + if (((uVar1 == uVar3) && (uVar2 == (in_a3 & 0xfffff))) && (in_a2 == in_a0)) { + if (in_a1 >> 0x1f == in_a3 >> 0x1f) { + return 0; + } + if (uVar1 == 0) { + return (uint)((uVar2 | in_a2) != 0); + } + } + return 1; +} + + + +__gcc_CMPtype __gedf2(void) + +{ + bool bVar1; + uint in_a0; + uint in_a1; + int iVar2; + uint in_a2; + uint in_a3; + int iVar3; + uint uVar4; + uint uVar5; + uint uVar6; + uint uVar7; + + uVar6 = in_a1 >> 0x14 & 0x7ff; + uVar7 = in_a1 & 0xfffff; + uVar5 = in_a3 & 0xfffff; + iVar2 = -((int)in_a1 >> 0x1f); + uVar4 = in_a3 >> 0x14 & 0x7ff; + iVar3 = -((int)in_a3 >> 0x1f); + if (uVar6 == 0x7ff) { + if ((uVar7 | in_a0) != 0) { + return -2; + } + if (uVar4 == 0x7ff) { +LAB_230a19cc: + if ((uVar5 | in_a2) != 0) { + return -2; + } + goto LAB_230a19d4; + } +LAB_230a1a58: + if (uVar4 == 0) { + bVar1 = false; +LAB_230a19e4: + if ((uVar5 | in_a2) == 0) { + if (bVar1) { + return 0; + } + goto LAB_230a19f8; + } + goto LAB_230a19ec; + } + } + else { + if (uVar4 == 0x7ff) goto LAB_230a19cc; +LAB_230a19d4: + if (uVar6 != 0) goto LAB_230a1a58; + bVar1 = (uVar7 | in_a0) == 0; + if (uVar4 == 0) goto LAB_230a19e4; +LAB_230a19ec: + if (bVar1) { + if (iVar3 != 0) { + return iVar3; + } + return -1; + } + } + if ((iVar2 == iVar3) && (uVar6 <= uVar4)) { + if (uVar4 <= uVar6) { + if (uVar5 < uVar7) goto LAB_230a19f8; + if (uVar7 == uVar5) { + if (in_a2 < in_a0) goto LAB_230a19f8; + if (in_a2 <= in_a0) { + return 0; + } + } + else { + if (uVar5 <= uVar7) { + return 0; + } + } + } + if (iVar2 == 0) { + return -1; + } + return iVar2; + } +LAB_230a19f8: + if (iVar2 != 0) { + return -1; + } + return 1; +} + + + +__gcc_CMPtype __ledf2(void) + +{ + bool bVar1; + uint in_a0; + uint in_a1; + int iVar2; + uint in_a2; + uint in_a3; + int iVar3; + uint uVar4; + uint uVar5; + uint uVar6; + uint uVar7; + + uVar6 = in_a1 >> 0x14 & 0x7ff; + uVar7 = in_a1 & 0xfffff; + uVar5 = in_a3 & 0xfffff; + iVar2 = -((int)in_a1 >> 0x1f); + uVar4 = in_a3 >> 0x14 & 0x7ff; + iVar3 = -((int)in_a3 >> 0x1f); + if (uVar6 == 0x7ff) { + if ((uVar7 | in_a0) != 0) { + return 2; + } + if (uVar4 == 0x7ff) { +LAB_230a1ab8: + if ((uVar5 | in_a2) != 0) { + return 2; + } + goto LAB_230a1ac0; + } +LAB_230a1b44: + if (uVar4 == 0) { + bVar1 = false; +LAB_230a1ad0: + if ((uVar5 | in_a2) == 0) { + if (bVar1) { + return 0; + } + goto LAB_230a1ae4; + } + goto LAB_230a1ad8; + } + } + else { + if (uVar4 == 0x7ff) goto LAB_230a1ab8; +LAB_230a1ac0: + if (uVar6 != 0) goto LAB_230a1b44; + bVar1 = (uVar7 | in_a0) == 0; + if (uVar4 == 0) goto LAB_230a1ad0; +LAB_230a1ad8: + if (bVar1) { + if (iVar3 != 0) { + return iVar3; + } + return -1; + } + } + if ((iVar2 == iVar3) && (uVar6 <= uVar4)) { + if (uVar4 <= uVar6) { + if (uVar5 < uVar7) goto LAB_230a1ae4; + if (uVar7 == uVar5) { + if (in_a2 < in_a0) goto LAB_230a1ae4; + if (in_a2 <= in_a0) { + return 0; + } + } + else { + if (uVar5 <= uVar7) { + return 0; + } + } + } + if (iVar2 == 0) { + return -1; + } + return iVar2; + } +LAB_230a1ae4: + if (iVar2 != 0) { + return -1; + } + return 1; +} + + +/* +Unable to decompile '__muldf3' +Cause: +Low-level Error: Assignment to constant at r0x230a1df8 +*/ + +/* +Unable to decompile '__subdf3' +Cause: Exception while decompiling 230a22ec: Decompiler process died + +*/ + + +__gcc_CMPtype __unorddf2(void) + +{ + uint in_a0; + uint in_a1; + uint uVar1; + uint in_a2; + uint in_a3; + uint uVar2; + uint uVar3; + uint uVar4; + + uVar4 = in_a1 & 0xfffff; + uVar3 = in_a3 & 0xfffff; + uVar1 = in_a1 >> 0x14 & 0x7ff; + uVar2 = in_a3 >> 0x14 & 0x7ff; + if ((uVar1 == 0x7ff) && ((uVar4 | in_a0) != 0)) { +LAB_230a2e80: + if (-1 < (int)(uVar4 << 0xc)) { + return 1; + } + if (uVar2 != 0x7ff) { + return 1; + } + } + else { + if (uVar2 != 0x7ff) { + return 0; + } + if ((uVar3 | in_a2) == 0) { + return 0; + } + if (uVar1 != 0x7ff) goto LAB_230a2ea0; + if ((uVar4 | in_a0) != 0) goto LAB_230a2e80; + } + if ((uVar3 | in_a2) == 0) { + return 1; + } +LAB_230a2ea0: + if (-1 < (int)(uVar3 << 0xc)) { + return 1; + } + return 1; +} + + + +SItype __fixdfsi(void) + +{ + uint in_a0; + uint in_a1; + uint uVar1; + uint uVar2; + + uVar1 = in_a1 >> 0x14 & 0x7ff; + if (uVar1 < 0x3ff) { + if ((uVar1 != 0) || (uVar2 = in_a1 & 0xfffff | in_a0, uVar2 != 0)) { + uVar2 = 0; + } + } + else { + if (uVar1 < 0x41e) { + uVar2 = in_a1 & 0xfffff | 0x100000; + if ((int)(0x433 - uVar1) < 0x20) { + uVar2 = uVar2 << (uVar1 - 0x413 & 0x1f) | in_a0 >> (0x433 - uVar1 & 0x1f); + } + else { + uVar2 = uVar2 >> (0x413 - uVar1 & 0x1f); + } + if (-((int)in_a1 >> 0x1f) != 0) { + uVar2 = -uVar2; + } + } + else { + uVar2 = -((int)in_a1 >> 0x1f) + 0x7fffffff; + } + } + return uVar2; +} + + + +USItype __fixunsdfsi(void) + +{ + uint in_a0; + USItype UVar1; + uint in_a1; + uint uVar2; + uint uVar3; + uint uVar4; + uint uVar5; + + uVar3 = in_a1 >> 0x14 & 0x7ff; + if (uVar3 < 0x3ff) { + if ((uVar3 == 0) && ((in_a1 & 0xfffff | in_a0) == 0)) { + return 0; + } + UVar1 = 0; + } + else { + if ((int)in_a1 < 0) { + UVar1 = 0; + } + else { + if (uVar3 < 0x41f) { + uVar5 = in_a1 & 0xfffff | 0x100000; + uVar2 = 0x433 - uVar3; + if ((int)uVar2 < 0x20) { + uVar4 = in_a0 << (uVar3 - 0x413 & 0x1f); + UVar1 = uVar5 << (uVar3 - 0x413 & 0x1f) | in_a0 >> (uVar2 & 0x1f); + } + else { + uVar4 = 0; + if (uVar2 != 0x20) { + uVar4 = uVar5 << (uVar3 - 0x3f3 & 0x1f); + } + uVar4 = uVar4 | in_a0; + UVar1 = uVar5 >> (0x413 - uVar3 & 0x1f); + } + if (uVar4 == 0) { + return UVar1; + } + } + else { + UVar1 = 0xffffffff; + } + } + } + return UVar1; +} + + + +DFtype __floatsidf(SItype i) + +{ + DFtype in_fa0; + + if (i != 0) { + __clzsi2((i >> 0x1f ^ i) - (i >> 0x1f)); + } + return in_fa0; +} + + + +DFtype __floatunsidf(USItype i) + +{ + DFtype in_fa0; + + if (i != 0) { + __clzsi2(i); + } + return in_fa0; +} + + +/* +Unable to decompile '__extendsfdf2' +Cause: Exception while decompiling 230a31ac: Decompiler process died + +*/ + + +SFtype __truncdfsf2(void) + +{ + uint uVar1; + SFtype in_a0; + uint in_a1; + uint uVar2; + uint uVar3; + uint uVar4; + uint uVar5; + int iVar6; + int in_frm; + + uVar1 = in_a1 >> 0x14 & 0x7ff; + uVar3 = (uint)in_a0 >> 0x1d | (in_a1 & 0xfffff) << 3; + uVar5 = (int)in_a0 << 3; + if ((uVar1 + 1 & 0x7fe) == 0) { + uVar3 = uVar3 | uVar5; + if (uVar1 == 0) { + uVar1 = (uint)(uVar3 != 0); +LAB_230a340c: + if (uVar1 == 0) { + return in_a0; + } +LAB_230a3410: + if (((((uVar1 * 2 & 7) != 0) && (in_frm != 2)) && (in_frm != 3)) && (in_frm == 0)) { + in_a0 = 0.00000000; + } + } + else { + if (uVar3 == 0) { + return in_a0; + } + uVar1 = 0; + } + } + else { + iVar6 = uVar1 - 0x380; + if (0xfe < iVar6) { + if (in_frm == 0) { + return in_a0; + } + if (in_frm == 3) { + if (-1 < (int)in_a1) { + return in_a0; + } + } + else { + if ((in_frm == 2) && ((int)in_a1 < 0)) { + return in_a0; + } + } + goto LAB_230a331c; + } + if (iVar6 < 1) { + if (-0x18 < iVar6) { + uVar3 = uVar3 | 0x800000; + uVar2 = 0x1e - iVar6; + if ((int)uVar2 < 0x20) { + uVar1 = uVar5 >> (uVar2 & 0x1f) | + (uint)(uVar5 << (uVar1 - 0x37e & 0x1f) != 0) | uVar3 << (uVar1 - 0x37e & 0x1f); + } + else { + in_a0 = 0.00000000; + uVar4 = 0; + if (uVar2 != 0x20) { + uVar4 = uVar3 << (uVar1 - 0x35e & 0x1f); + } + uVar1 = uVar3 >> (-iVar6 - 2U & 0x1f) | (uint)((uVar4 | uVar5) != 0); + } + goto LAB_230a340c; + } + uVar1 = 1; + goto LAB_230a3410; + } + in_a0 = (SFtype)(uint)(((uint)in_a0 & 0x3ffffff) != 0); + uVar1 = (uint)in_a0 | uVar5 >> 0x1d; + } + if ((uVar1 & 7) == 0) { + return in_a0; + } +LAB_230a331c: + if (((in_frm != 2) && (in_frm != 3)) && (in_frm == 0)) { + in_a0 = 0.00000000; + } + return in_a0; +} + + + +// WARNING: Unknown calling convention yet parameter storage is locked + +void abort(void) + +{ + raise(6); + // WARNING: Subroutine does not return + _exit(1); +} + + + +void __assert_func(undefined4 param_1,undefined4 param_2,char *param_3,undefined4 param_4) + +{ + char *pcVar1; + + pcVar1 = ", function: "; + if (param_3 == (char *)0x0) { + pcVar1 = ""; + param_3 = pcVar1; + } + fiprintf(*(undefined4 *)(_impure_ptr + 0xc),"assertion \"%s\" failed: file \"%s\", line %d%s%s\n", + param_4,param_1,param_2,pcVar1,param_3); + // WARNING: Subroutine does not return + abort(); +} + + + +void __assert(char *__assertion,char *__file,int __line) + +{ + char *__nptr; + + __nptr = (char *)__assert_func(0,__line); + strtol(__nptr,(char **)0x0,10); + return; +} + + + +int atoi(char *__nptr) + +{ + long lVar1; + + lVar1 = strtol(__nptr,(char **)0x0,10); + return lVar1; +} + + + +void _atoi_r(void) + +{ + _strtol_r(0,10); + return; +} + + + +undefined * __errno(void) + +{ + return _impure_ptr; +} + + + +void _fiprintf_r(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4, + undefined4 param_5) + +{ + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack20 = param_1; + uStack16 = param_2; + uStack12 = param_3; + uStack8 = param_4; + uStack4 = param_5; + _vfiprintf_r(&uStack20); + return; +} + + + +void fiprintf(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4, + undefined4 param_5,undefined4 param_6,undefined4 param_7,undefined4 param_8) + +{ + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack24 = param_3; + uStack20 = param_4; + uStack16 = param_5; + uStack12 = param_6; + uStack8 = param_7; + uStack4 = param_8; + _vfiprintf_r(_impure_ptr,param_1,param_2,&uStack24); + return; +} + + + +void * memchr(void *__s,int __c,size_t __n) + +{ + byte bVar1; + uint uVar2; + uint uVar3; + uint *puVar4; + uint uVar5; + + uVar5 = __c & 0xff; + if (((uint)__s & 3) != 0) { + if (__n == 0) { + return (void *)0x0; + } + bVar1 = *(byte *)__s; + __n = __n - 1; + while( true ) { + if ((uint)bVar1 == uVar5) { + return (uint *)__s; + } + __s = (void *)((int)__s + 1); + if (((uint)__s & 3) == 0) break; + __n = __n - 1; + if (__n == 0xffffffff) { + return (void *)0x0; + } + bVar1 = *(byte *)__s; + } + } + if (3 < __n) { + uVar2 = (__c & 0xffU) << 8 | __c & 0xffU; + do { + uVar3 = (uVar2 << 0x10 | uVar2) ^ *(uint *)__s; + if ((uVar3 + 0xfefefeff & ~uVar3 & 0x80808080) != 0) goto LAB_230a3714; + __n = __n - 4; + __s = (uint *)__s + 1; + } while (3 < __n); + } + if (__n != 0) { +LAB_230a3714: + if ((uint)*(byte *)__s == uVar5) { + return (uint *)__s; + } + puVar4 = (uint *)((int)__s + __n); + while (__s = (void *)((int)__s + 1), puVar4 != (uint *)__s) { + if ((uint)*(byte *)__s == uVar5) { + return (uint *)__s; + } + } + } + return (void *)0x0; +} + + + +int memcmp(void *__s1,void *__s2,size_t __n) + +{ + int *piVar1; + uint uVar2; + uint uVar3; + + if (3 < __n) { + if ((((uint)__s1 | (uint)__s2) & 3) != 0) goto LAB_230a37e0; + do { + if (*(int *)__s1 != *(int *)__s2) goto LAB_230a37e0; + __n = __n - 4; + __s1 = (int *)__s1 + 1; + __s2 = (int *)__s2 + 1; + } while (3 < __n); + } + if (__n == 0) { + return 0; + } +LAB_230a37e0: + uVar3 = (uint)*(byte *)__s1; + uVar2 = (uint)*(byte *)__s2; + if (uVar3 == uVar2) { + piVar1 = (int *)((int)__s1 + __n); + do { + __s1 = (void *)((int)__s1 + 1); + __s2 = (void *)((int)__s2 + 1); + if ((int *)__s1 == piVar1) { + return 0; + } + uVar3 = (uint)*(byte *)__s1; + uVar2 = (uint)*(byte *)__s2; + } while (uVar3 == uVar2); + } + return uVar3 - uVar2; +} + + + +void * memcpy(void *__dest,void *__src,size_t __n) + +{ + undefined uVar1; + undefined4 uVar2; + undefined4 uVar3; + undefined4 *puVar4; + undefined4 *puVar5; + undefined4 uVar6; + undefined4 *puVar7; + uint uVar8; + undefined4 *puVar9; + undefined4 *puVar10; + int iVar11; + undefined4 uVar12; + undefined4 *puVar13; + undefined4 uVar14; + undefined4 uVar15; + undefined4 uVar16; + undefined4 uVar17; + + puVar13 = (undefined4 *)((int)__dest + __n); + if (((((uint)__src ^ (uint)__dest) & 3) == 0) && (3 < __n)) { + uVar8 = (uint)__dest & 3; + puVar5 = (undefined4 *)__dest; + while (puVar4 = (undefined4 *)__src, puVar7 = puVar5, uVar8 != 0) { + puVar7 = (undefined4 *)((int)puVar5 + 1); + *(undefined *)puVar5 = *(undefined *)__src; + puVar4 = (undefined4 *)((int)__src + 1); + if (((uint)puVar7 & 3) == 0) break; + uVar8 = (uint)(undefined4 *)((int)puVar5 + 2) & 3; + *(undefined *)((int)puVar5 + 1) = *(undefined *)puVar4; + __src = (void *)((int)__src + 2); + puVar5 = (undefined4 *)((int)puVar5 + 2); + } + puVar5 = (undefined4 *)((uint)puVar13 & 0xfffffffc); + __src = puVar4; + while (puVar7 < puVar5 + -8) { + uVar2 = ((undefined4 *)__src)[1]; + uVar17 = ((undefined4 *)__src)[2]; + uVar16 = ((undefined4 *)__src)[3]; + uVar15 = ((undefined4 *)__src)[4]; + uVar14 = ((undefined4 *)__src)[5]; + uVar3 = ((undefined4 *)__src)[6]; + uVar12 = ((undefined4 *)__src)[7]; + *puVar7 = *(undefined4 *)__src; + uVar6 = ((undefined4 *)__src)[8]; + puVar7[1] = uVar2; + puVar7[2] = uVar17; + puVar7[3] = uVar16; + puVar7[4] = uVar15; + puVar7[5] = uVar14; + puVar7[6] = uVar3; + puVar7[7] = uVar12; + puVar7[8] = uVar6; + __src = (undefined4 *)__src + 9; + puVar7 = puVar7 + 9; + } + puVar4 = (undefined4 *)__src; + puVar9 = puVar7; + if (puVar7 < puVar5) { + do { + puVar10 = puVar9 + 1; + *puVar9 = *puVar4; + puVar4 = puVar4 + 1; + puVar9 = puVar10; + } while (puVar10 < puVar5); + iVar11 = ((int)puVar5 + (-1 - (int)puVar7) & 0xfffffffcU) + 4; + puVar7 = (undefined4 *)((int)puVar7 + iVar11); + __src = (void *)((int)__src + iVar11); + } + if (puVar7 < puVar13) { +LAB_230a38a4: + do { + uVar1 = *(undefined *)__src; + puVar5 = (undefined4 *)((int)puVar7 + 1); + __src = (void *)((int)__src + 1); + *(undefined *)puVar7 = uVar1; + puVar7 = puVar5; + } while (puVar5 < puVar13); + return __dest; + } + } + else { + puVar7 = (undefined4 *)__dest; + if (__dest < puVar13) goto LAB_230a38a4; + } + return __dest; +} + + + +void * memmove(void *__dest,void *__src,size_t __n) + +{ + int iVar1; + undefined *puVar2; + undefined4 *puVar3; + undefined *puVar4; + undefined4 *puVar5; + undefined4 *puVar6; + uint uVar7; + + if ((__src < __dest) && (puVar4 = (undefined *)((int)__src + __n), __dest < puVar4)) { + puVar2 = (undefined *)((int)__dest + __n); + if (__n == 0) { + return __dest; + } + do { + puVar4 = puVar4 + -1; + puVar2 = puVar2 + -1; + *puVar2 = *puVar4; + } while ((undefined *)__src != puVar4); + return __dest; + } + uVar7 = __n; + puVar5 = (undefined4 *)__dest; + if (0xf < __n) { + if ((((uint)__src | (uint)__dest) & 3) != 0) { + iVar1 = __n - 1; + goto LAB_230a3988; + } + iVar1 = (__n - 0x10 & 0xfffffff0) + 0x10; + puVar3 = (undefined4 *)__src; + puVar6 = (undefined4 *)__dest; + do { + puVar5 = puVar6 + 4; + *puVar6 = *puVar3; + puVar6[1] = puVar3[1]; + puVar6[2] = puVar3[2]; + puVar6[3] = puVar3[3]; + puVar3 = puVar3 + 4; + puVar6 = puVar5; + } while ((undefined4 *)((int)__dest + iVar1) != puVar5); + __src = (void *)((int)__src + iVar1); + uVar7 = __n & 0xf; + puVar3 = (undefined4 *)__src; + if ((__n & 0xc) != 0) { + do { + puVar3 = puVar3 + 1; + *puVar6 = *puVar3; + puVar3 = puVar3; + puVar6 = puVar6 + 1; + } while (3 < (int)__src + (uVar7 - (int)puVar3)); + iVar1 = (uVar7 - 4 & 0xfffffffc) + 4; + __src = (void *)((int)__src + iVar1); + uVar7 = __n & 3; + puVar5 = (undefined4 *)((int)puVar5 + iVar1); + } + } + iVar1 = uVar7 - 1; + if (uVar7 == 0) { + return __dest; + } +LAB_230a3988: + puVar3 = puVar5; + do { + puVar6 = (undefined4 *)((int)puVar3 + 1); + *(undefined *)puVar3 = *(undefined *)__src; + __src = (undefined4 *)((int)__src + 1); + puVar3 = puVar6; + } while (puVar6 != (undefined4 *)((int)puVar5 + iVar1 + 1)); + return __dest; +} + + + +void * memset(void *__s,int __c,size_t __n) + +{ + uint uVar1; + uint extraout_a1; + uint *puVar2; + uint *puVar3; + void *pvVar4; + uint uVar5; + + uVar1 = 0xf; + if (0xf < __n) { + uVar5 = (uint)__s & 0xf; + puVar3 = (uint *)__s; + if (uVar5 != 0) { + pvVar4 = __s; + __s = (void *)(*(code *)(uVar5 * 4 + 0x230a3abc))(); + puVar3 = (uint *)((int)pvVar4 - (uVar5 - 0x10)); + __n = __n + (uVar5 - 0x10); + __c = extraout_a1; + if (__n <= uVar1) goto LAB_230a3aac; + } + if (__c != 0) { + uVar5 = __c & 0xffU | (__c & 0xffU) << 8; + __c = uVar5 | uVar5 << 0x10; + } + uVar5 = __n & 0xfffffff0; + __n = __n & 0xf; + puVar2 = (uint *)(uVar5 + (int)puVar3); + do { + *puVar3 = __c; + puVar3[1] = __c; + puVar3[2] = __c; + puVar3[3] = __c; + puVar3 = puVar3 + 4; + } while (puVar3 < puVar2); + if (__n == 0) { + return __s; + } + } +LAB_230a3aac: + // WARNING: Could not recover jumptable at 0x230a3abc. Too many branches + // WARNING: Treating indirect jump as call + pvVar4 = (void *)(*(code *)(&UNK_230a3ac0 + (uVar1 - __n) * 4))(); + return pvVar4; +} + + + +undefined4 _init_signal_r_part_0(int param_1) + +{ + undefined4 *puVar1; + undefined4 uVar2; + undefined4 *puVar3; + + puVar1 = (undefined4 *)_malloc_r(0x80); + *(undefined4 **)(param_1 + 0x2dc) = puVar1; + if (puVar1 == (undefined4 *)0x0) { + uVar2 = 0xffffffff; + } + else { + puVar3 = puVar1 + 0x20; + do { + *puVar1 = 0; + puVar1 = puVar1 + 1; + } while (puVar1 != puVar3); + uVar2 = 0; + } + return uVar2; +} + + + +undefined4 _init_signal_r(int param_1) + +{ + undefined4 uVar1; + + if (*(int *)(param_1 + 0x2dc) != 0) { + return 0; + } + uVar1 = _init_signal_r_part_0(); + return uVar1; +} + + + +undefined4 _signal_r(undefined4 *param_1,uint param_2,undefined4 param_3) + +{ + undefined4 *puVar1; + int iVar2; + undefined4 uVar3; + + if (0x1f < param_2) { + *param_1 = 0x16; + return 0xffffffff; + } + iVar2 = param_1[0xb7]; + if (iVar2 == 0) { + iVar2 = _init_signal_r_part_0(); + if (iVar2 != 0) { + return 0xffffffff; + } + iVar2 = param_1[0xb7]; + } + puVar1 = (undefined4 *)(iVar2 + param_2 * 4); + uVar3 = *puVar1; + *puVar1 = param_3; + return uVar3; +} + + + +undefined4 _raise_r(undefined4 *param_1,uint param_2) + +{ + __pid_t _Var1; + undefined4 uVar2; + uint uVar3; + uint *puVar4; + + if (0x1f < param_2) { + *param_1 = 0x16; + return 0xffffffff; + } + if (param_1[0xb7] != 0) { + puVar4 = (uint *)(param_1[0xb7] + param_2 * 4); + uVar3 = *puVar4; + if (uVar3 != 0) { + if (uVar3 == 1) { + return 0; + } + if (uVar3 != 0xffffffff) { + *puVar4 = 0; + (*(code *)(uVar3 & 0xfffffffe))(param_2); + return 0; + } + *param_1 = 0x16; + return 1; + } + } + _Var1 = _getpid_r(); + uVar2 = _kill_r(param_1,_Var1,param_2); + return uVar2; +} + + + +undefined4 __sigtramp_r(int param_1,uint param_2) + +{ + undefined4 uVar1; + uint uVar2; + int iVar3; + uint *puVar4; + + if (0x1f < param_2) { + return 0xffffffff; + } + iVar3 = *(int *)(param_1 + 0x2dc); + if (iVar3 == 0) { + iVar3 = _init_signal_r_part_0(); + if (iVar3 != 0) { + return 0xffffffff; + } + iVar3 = *(int *)(param_1 + 0x2dc); + } + puVar4 = (uint *)(iVar3 + param_2 * 4); + uVar2 = *puVar4; + if (uVar2 != 0) { + if (uVar2 == 0xffffffff) { + uVar1 = 2; + } + else { + if (uVar2 == 1) { + return 3; + } + *puVar4 = 0; + (*(code *)(uVar2 & 0xfffffffe))(param_2); + uVar1 = 0; + } + return uVar1; + } + return 1; +} + + + +int raise(int __sig) + +{ + int iVar1; + + iVar1 = _raise_r(_impure_ptr,__sig); + return iVar1; +} + + + +__sighandler_t signal(int __sig,__sighandler_t __handler) + +{ + __sighandler_t p_Var1; + + p_Var1 = (__sighandler_t)_signal_r(_impure_ptr,__sig,__handler); + return p_Var1; +} + + + +undefined4 _init_signal(void) + +{ + undefined4 uVar1; + + if (*(int *)(_impure_ptr + 0x2dc) != 0) { + return 0; + } + uVar1 = _init_signal_r_part_0(); + return uVar1; +} + + + +void __sigtramp(undefined4 param_1) + +{ + __sigtramp_r(_impure_ptr,param_1); + return; +} + + + +void _kill_r(int *param_1,__pid_t param_2,int param_3) + +{ + int iVar1; + + errno = 0; + iVar1 = _kill(param_2,param_3); + if ((iVar1 == -1) && (errno != 0)) { + *param_1 = errno; + return; + } + return; +} + + + +// WARNING: Unknown calling convention yet parameter storage is locked + +__pid_t _getpid_r(void) + +{ + return 1; +} + + + +char * strchr(char *__s,int __c) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + uint uVar4; + + uVar3 = __c & 0xff; + if (uVar3 == 0) { + if (((uint)__s & 3) != 0) { + if (*__s == '\0') { + return __s; + } + while (__s = (char *)((int)__s + 1), ((uint)__s & 3) != 0) { + if (*__s == '\0') { + return (char *)(uint *)__s; + } + } + } + uVar3 = *(uint *)__s + 0xfefefeff & ~*(uint *)__s; + while ((uVar3 & 0x80808080) == 0) { + __s = (char *)((uint *)__s + 1); + uVar3 = *(uint *)__s + 0xfefefeff & ~*(uint *)__s; + } + if (*__s != '\0') { + do { + __s = (char *)((int)__s + 1); + } while (*__s != '\0'); + return __s; + } + return (char *)(uint *)__s; + } + if (((uint)__s & 3) != 0) { + if (*__s == 0) { + return (char *)0x0; + } + if (uVar3 == (uint)(byte)*__s) { + return __s; + } + while (__s = (char *)((int)__s + 1), ((uint)__s & 3) != 0) { + if (*__s == 0) { + return (char *)0x0; + } + if ((uint)(byte)*__s == uVar3) { + return (char *)(uint *)__s; + } + } + } + uVar1 = __c & 0xffU | (__c & 0xffU) << 8; + uVar4 = *(uint *)__s; + uVar1 = uVar1 << 0x10 | uVar1; + uVar2 = uVar1 ^ uVar4; + uVar2 = ~uVar4 & uVar4 + 0xfefefeff | ~uVar2 & uVar2 + 0xfefefeff; + while ((uVar2 & 0x80808080) == 0) { + __s = (char *)((uint *)__s + 1); + uVar4 = *(uint *)__s; + uVar2 = uVar4 ^ uVar1; + uVar2 = uVar4 + 0xfefefeff & ~uVar4 | uVar2 + 0xfefefeff & ~uVar2; + } + if (*__s != 0) { + if (uVar3 == (uint)(byte)*__s) { + return (char *)(uint *)__s; + } + while( true ) { + __s = (char *)((int)__s + 1); + if (*__s == 0) break; + if ((uint)(byte)*__s == uVar3) { + return __s; + } + } + } + return (char *)0x0; +} + + + +int strcmp(char *__s1,char *__s2) + +{ + byte bVar1; + byte bVar2; + uint uVar3; + uint uVar4; + + if ((((uint)__s1 | (uint)__s2) & 3) == 0) { + do { + uVar3 = *(uint *)__s1; + uVar4 = *(uint *)__s2; + if (((uVar3 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar3 | 0x7f7f7f7f) != 0xffffffff) { +LAB_230a4128: + if (uVar3 == uVar4) { + return 0; + } + goto LAB_230a4100; + } + if (uVar3 != uVar4) break; + uVar3 = ((uint *)__s1)[1]; + uVar4 = ((uint *)__s2)[1]; + if (((uVar3 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar3 | 0x7f7f7f7f) != 0xffffffff) { + __s1 = (char *)((uint *)__s1 + 1); + __s2 = (char *)((uint *)__s2 + 1); + goto LAB_230a4128; + } + if (uVar3 != uVar4) break; + uVar3 = ((uint *)__s1)[2]; + uVar4 = ((uint *)__s2)[2]; + if (((uVar3 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar3 | 0x7f7f7f7f) != 0xffffffff) { + __s1 = (char *)((uint *)__s1 + 2); + __s2 = (char *)((uint *)__s2 + 2); + if (uVar3 == uVar4) { + return 0; + } + goto LAB_230a4100; + } + if (uVar3 != uVar4) break; + uVar3 = ((uint *)__s1)[3]; + uVar4 = ((uint *)__s2)[3]; + if (((uVar3 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar3 | 0x7f7f7f7f) != 0xffffffff) { + __s1 = (char *)((uint *)__s1 + 3); + __s2 = (char *)((uint *)__s2 + 3); + if (uVar3 == uVar4) { + return 0; + } + goto LAB_230a4100; + } + if (uVar3 != uVar4) break; + uVar3 = ((uint *)__s1)[4]; + uVar4 = ((uint *)__s2)[4]; + if (((uVar3 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar3 | 0x7f7f7f7f) != 0xffffffff) { + __s1 = (char *)((uint *)__s1 + 4); + __s2 = (char *)((uint *)__s2 + 4); + if (uVar3 == uVar4) { + return 0; + } + goto LAB_230a4100; + } + __s1 = (char *)((uint *)__s1 + 5); + __s2 = (char *)((uint *)__s2 + 5); + } while (uVar3 == uVar4); + if (uVar3 << 0x10 == uVar4 << 0x10) { + uVar3 = uVar3 >> 0x10; + uVar4 = uVar4 >> 0x10; + if ((uVar3 - uVar4 & 0xff) == 0) { + return uVar3 - uVar4; + } + } + else { + uVar3 = uVar3 & 0xffff; + uVar4 = uVar4 & 0xffff; + if ((uVar3 - uVar4 & 0xff) == 0) { + return uVar3 - uVar4; + } + } + return (uVar3 & 0xff) - (uVar4 & 0xff); + } +LAB_230a4100: + do { + bVar1 = *__s1; + bVar2 = *__s2; + __s1 = (char *)((int)__s1 + 1); + __s2 = (char *)((int)__s2 + 1); + if ((uint)bVar1 != (uint)bVar2) break; + } while (bVar1 != 0); + return (uint)bVar1 - (uint)bVar2; +} + + + +char * strcpy(char *__dest,char *__src) + +{ + char cVar1; + char cVar2; + char cVar3; + uint *puVar4; + uint uVar5; + uint uVar6; + char *pcVar7; + + pcVar7 = __dest; + if ((((uint)__dest | (uint)__src) & 3) != 0) { + do { + cVar1 = *__src; + __src = __src + 1; + *pcVar7 = cVar1; + pcVar7 = pcVar7 + 1; + } while (cVar1 != '\0'); + return __dest; + } + uVar5 = *(uint *)__src; + uVar6 = (uVar5 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar5; + puVar4 = (uint *)__dest; + while ((uVar6 | 0x7f7f7f7f) == 0xffffffff) { + __src = (char *)((uint *)__src + 1); + *puVar4 = uVar5; + uVar5 = *(uint *)__src; + uVar6 = (uVar5 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar5; + puVar4 = puVar4 + 1; + } + cVar1 = *__src; + cVar2 = *(char *)((int)__src + 1); + cVar3 = *(char *)((int)__src + 2); + *(char *)puVar4 = cVar1; + if (((cVar1 != '\0') && (*(char *)((int)puVar4 + 1) = cVar2, cVar2 != '\0')) && + (*(char *)((int)puVar4 + 2) = cVar3, cVar3 != '\0')) { + *(char *)((int)puVar4 + 3) = '\0'; + return __dest; + } + return __dest; +} + + + +size_t strlen(char *__s) + +{ + char cVar1; + uint *puVar2; + uint *puVar3; + uint uVar4; + + uVar4 = (uint)__s & 3; + puVar3 = (uint *)__s; + while (uVar4 != 0) { + cVar1 = *(char *)puVar3; + puVar3 = (uint *)((int)puVar3 + 1); + uVar4 = (uint)puVar3 & 3; + if (cVar1 == '\0') { + return (int)puVar3 + (-1 - (int)__s); + } + } + do { + puVar2 = puVar3; + puVar3 = puVar2 + 1; + } while (((*puVar2 & 0x7f7f7f7f) + 0x7f7f7f7f | *puVar2 | 0x7f7f7f7f) == 0xffffffff); + puVar3 = (uint *)((int)(puVar2 + 1) - (int)__s); + if (*(char *)puVar2 != '\0') { + if (*(char *)((int)puVar2 + 1) != '\0') { + return (int)puVar3 + ((uint)(*(char *)((int)puVar2 + 2) != '\0') - 2); + } + return (size_t)((int)puVar3 + -3); + } + return (size_t)(puVar3 + -1); +} + + + +int strncmp(char *__s1,char *__s2,size_t __n) + +{ + int iVar1; + uint *puVar2; + uint uVar3; + uint uVar4; + + if (__n == 0) { + return 0; + } + if (((((uint)__s1 | (uint)__s2) & 3) == 0) && (3 < __n)) { + uVar4 = *(uint *)__s1; + if (uVar4 != *(uint *)__s2) { +LAB_230a4388: + uVar3 = (uint)(byte)*__s1; + uVar4 = (uint)(byte)*__s2; + iVar1 = __n - 1; + if (uVar4 == uVar3) goto LAB_230a434c; + goto LAB_230a4378; + } + __n = __n - 4; + if (__n == 0) { + return 0; + } + uVar4 = uVar4 + 0xfefefeff & ~uVar4; + while( true ) { + if ((uVar4 & 0x80808080) != 0) { + return 0; + } + __s1 = (char *)((uint *)__s1 + 1); + __s2 = (char *)((uint *)__s2 + 1); + if (__n < 4) break; + uVar3 = *(uint *)__s1; + uVar4 = uVar3 + 0xfefefeff & ~uVar3; + if (uVar3 != *(uint *)__s2) goto LAB_230a4388; + __n = __n - 4; + if (__n == 0) { + return 0; + } + } + } + uVar3 = (uint)(byte)*__s1; + uVar4 = (uint)(byte)*__s2; + iVar1 = __n - 1; + if (uVar4 == uVar3) { + if (iVar1 == 0) { + return 0; + } +LAB_230a434c: + if (uVar3 != 0) { + puVar2 = (uint *)((int)__s1 + iVar1); + do { + __s1 = (char *)((int)__s1 + 1); + __s2 = (char *)((int)__s2 + 1); + uVar3 = (uint)(byte)*__s1; + uVar4 = (uint)(byte)*__s2; + if (uVar3 != uVar4) goto LAB_230a4378; + } while ((puVar2 != (uint *)__s1) && (*__s1 != 0)); + } + return 0; + } +LAB_230a4378: + return uVar3 - uVar4; +} + + + +char * strncpy(char *__dest,char *__src,size_t __n) + +{ + char cVar1; + uint uVar2; + uint *puVar3; + uint *puVar4; + char *pcVar5; + char *pcVar6; + char *pcVar7; + int iVar8; + + puVar3 = (uint *)__dest; + if (((((uint)__src | (uint)__dest) & 3) == 0) && (puVar4 = (uint *)__dest, 3 < __n)) { + do { + uVar2 = *(uint *)__src; + if ((uVar2 + 0xfefefeff & ~uVar2 & 0x80808080) != 0) goto LAB_230a43b8; + puVar3 = puVar4 + 1; + __n = __n - 4; + *puVar4 = uVar2; + __src = (char *)((uint *)__src + 1); + puVar4 = puVar3; + } while (3 < __n); + } + puVar4 = puVar3; + if (__n != 0) { +LAB_230a43b8: + cVar1 = *__src; + *(char *)puVar4 = cVar1; + pcVar5 = (char *)((int)puVar4 + 1); + iVar8 = __n - 1; + if (cVar1 != '\0') { + pcVar6 = pcVar5; + do { + __src = (char *)((int)__src + 1); + iVar8 = (__n - 1) - (int)pcVar6; + if (pcVar6 == (char *)((int)puVar4 + __n)) { + return __dest; + } + cVar1 = *__src; + pcVar5 = pcVar6 + 1; + *pcVar6 = cVar1; + pcVar6 = pcVar5; + iVar8 = (int)puVar4 + iVar8; + } while (cVar1 != '\0'); + } + pcVar6 = pcVar5; + if (iVar8 == 0) { + return __dest; + } + do { + pcVar7 = pcVar6 + 1; + *pcVar6 = '\0'; + pcVar6 = pcVar7; + } while (pcVar7 != pcVar5 + iVar8); + } + return __dest; +} + + + +size_t strnlen(char *__string,size_t __maxlen) + +{ + char *pcVar1; + + if (__maxlen != 0) { + if (*__string == '\0') { + __maxlen = 0; + } + else { + pcVar1 = __string; + while (pcVar1 = pcVar1 + 1, pcVar1 != __string + __maxlen) { + if (*pcVar1 == '\0') { + return (size_t)(pcVar1 + -(int)__string); + } + } + } + } + return __maxlen; +} + + + +char * strrchr(char *__s,int __c) + +{ + char *pcVar1; + char *pcVar2; + + if (__c != 0) { + pcVar2 = (char *)0x0; + while (pcVar1 = strchr(__s,__c), pcVar1 != (char *)0x0) { + __s = pcVar1 + 1; + pcVar2 = pcVar1; + } + return pcVar2; + } + pcVar2 = strchr(__s,0); + return pcVar2; +} + + + +byte * two_way_long_needle(int param_1,int param_2,byte *param_3,byte *param_4) + +{ + byte bVar1; + byte bVar2; + int iVar3; + size_t sVar4; + byte *pbVar5; + byte *pbVar6; + byte *__n; + byte *pbVar7; + byte *pbVar8; + byte **ppbVar9; + byte *pbVar10; + byte *pbVar11; + byte *pbVar12; + byte *pbVar13; + byte *pbVar14; + byte *local_440 [256]; + byte *apbStack64 [3]; + + pbVar13 = (byte *)0x1; + pbVar6 = (byte *)0x1; + __n = (byte *)0x0; + pbVar11 = (byte *)0xffffffff; + do { + pbVar14 = pbVar6 + (int)pbVar11; + pbVar10 = pbVar6 + (int)__n; + pbVar12 = __n; + while( true ) { + __n = pbVar10; + if (param_4 <= __n) { + pbVar6 = (byte *)0x1; + __n = (byte *)0x1; + pbVar14 = (byte *)0xffffffff; + pbVar12 = (byte *)0x0; + goto LAB_230a45ac; + } + if (param_3[(int)pbVar14] <= param_3[(int)__n]) break; + pbVar6 = (byte *)0x1; + pbVar13 = __n + -(int)pbVar11; + pbVar14 = pbVar11 + 1; + pbVar10 = __n + 1; + pbVar12 = __n; + } + if (param_3[(int)__n] == param_3[(int)pbVar14]) { + if (pbVar6 == pbVar13) { + pbVar6 = (byte *)0x1; + } + else { + pbVar6 = pbVar6 + 1; + __n = pbVar12; + } + } + else { + pbVar13 = (byte *)0x1; + pbVar6 = (byte *)0x1; + __n = pbVar12 + 1; + pbVar11 = pbVar12; + } + } while( true ); +LAB_230a45ac: + pbVar5 = __n + (int)pbVar14; + pbVar7 = __n + (int)pbVar12; + pbVar10 = pbVar12; + while (pbVar12 = pbVar7, pbVar12 < param_4) { + if (param_3[(int)pbVar12] <= param_3[(int)pbVar5]) goto LAB_230a4780; + __n = (byte *)0x1; + pbVar6 = pbVar12 + -(int)pbVar14; + pbVar5 = pbVar14 + 1; + pbVar7 = pbVar12 + 1; + pbVar10 = pbVar12; + } + __n = pbVar11 + 1; + if (pbVar11 + 1 <= pbVar14 + 1) { + pbVar13 = pbVar6; + __n = pbVar14 + 1; + } + ppbVar9 = local_440; + do { + *ppbVar9 = param_4; + ppbVar9 = ppbVar9 + 1; + } while (apbStack64 != ppbVar9); + pbVar11 = param_4 + -1; + pbVar6 = param_3; + if (param_4 != (byte *)0x0) { + do { + bVar1 = *pbVar6; + iVar3 = -(int)pbVar6; + pbVar6 = pbVar6 + 1; + local_440[bVar1] = param_3 + (int)(pbVar11 + iVar3); + } while (pbVar6 != param_3 + (int)param_4); + } + iVar3 = memcmp(param_3,param_3 + (int)pbVar13,(size_t)__n); + if (iVar3 != 0) { + pbVar13 = param_4 + -(int)__n; + if (param_4 + -(int)__n < __n) { + pbVar13 = __n; + } + pbVar6 = __n + -1; + pbVar12 = (byte *)0x0; +LAB_230a4840: + pbVar14 = pbVar12 + param_1; + pbVar10 = local_440[pbVar11[(int)pbVar14]]; + if (pbVar10 == (byte *)0x0) goto LAB_230a48a4; + do { + pbVar12 = pbVar10 + (int)pbVar12; + while( true ) { + if (pbVar12 <= (byte *)(param_2 - (int)param_4)) goto LAB_230a4840; + sVar4 = strnlen((char *)(param_1 + param_2),(uint)param_4 | 0x800); + param_2 = param_2 + sVar4; + if ((byte *)(param_2 - (int)param_4) < pbVar12) { + return (byte *)0; + } + pbVar14 = pbVar12 + param_1; + pbVar10 = local_440[pbVar11[(int)pbVar14]]; + if (pbVar10 != (byte *)0x0) break; +LAB_230a48a4: + if (__n < pbVar11) { + pbVar10 = __n; + if (__n[(int)pbVar14] == param_3[(int)__n]) { + do { + pbVar10 = pbVar10 + 1; + if (pbVar11 <= pbVar10) goto LAB_230a48e4; + } while (param_3[(int)pbVar10] == pbVar10[(int)(pbVar12 + param_1)]); + } + pbVar12 = pbVar10 + (int)(pbVar12 + (1 - (int)__n)); + } + else { +LAB_230a48e4: + if (pbVar6 == (byte *)0xffffffff) { + return pbVar14; + } + if (pbVar6[(int)pbVar14] == param_3[(int)pbVar6]) { + pbVar5 = param_3 + (int)(__n + -2); + pbVar10 = __n + -2 + (int)(pbVar12 + param_1); + do { + if (pbVar5 == param_3 + -1) { + return pbVar14; + } + bVar1 = *pbVar5; + bVar2 = *pbVar10; + pbVar5 = pbVar5 + -1; + pbVar10 = pbVar10 + -1; + } while (bVar1 == bVar2); + } + pbVar12 = pbVar13 + (int)(pbVar12 + 1); + } + } + } while( true ); + } + pbVar6 = __n + -1; + pbVar12 = (byte *)0x0; + pbVar14 = (byte *)0x0; + do { + pbVar5 = pbVar14 + param_1; + pbVar10 = local_440[pbVar11[(int)pbVar5]]; + if (pbVar10 == (byte *)0x0) { + pbVar10 = pbVar12; + if (pbVar12 < __n) { + pbVar10 = __n; + } + if (pbVar10 < pbVar11) { + pbVar7 = pbVar10 + (int)(pbVar14 + param_1); + pbVar8 = param_3 + (int)pbVar10; + do { + if (*pbVar7 != *pbVar8) { + pbVar14 = pbVar14 + (1 - (int)__n); + goto LAB_230a46b8; + } + pbVar10 = pbVar10 + 1; + pbVar7 = param_3 + (int)pbVar10; + pbVar8 = pbVar10 + (int)(pbVar14 + param_1); + } while (pbVar10 < pbVar11); + } + if ((pbVar12 < __n) && + (pbVar10 = pbVar6, pbVar6[(int)(pbVar14 + param_1)] == param_3[(int)pbVar6])) { + do { + pbVar7 = pbVar10; + pbVar10 = pbVar7 + -1; + if (pbVar12 == pbVar7) break; + } while (param_3[(int)pbVar10] == pbVar10[(int)(pbVar14 + param_1)]); + if (pbVar7 < pbVar12 + 1) { + return pbVar5; + } + } + else { + if (__n < pbVar12 + 1) { + return pbVar5; + } + } + pbVar14 = pbVar13 + (int)pbVar14; + pbVar12 = param_4 + -(int)pbVar13; + } + else { + if ((pbVar12 != (byte *)0x0) && (pbVar10 < pbVar13)) { + pbVar10 = param_4 + -(int)pbVar13; + } +LAB_230a46b8: + pbVar14 = pbVar10 + (int)pbVar14; + pbVar12 = (byte *)0x0; + } + if ((byte *)(param_2 - (int)param_4) < pbVar14) { + sVar4 = strnlen((char *)(param_1 + param_2),(uint)param_4 | 0x800); + param_2 = param_2 + sVar4; + if ((byte *)(param_2 - (int)param_4) < pbVar14) { + return (byte *)0; + } + } + } while( true ); +LAB_230a4780: + if (param_3[(int)pbVar12] == param_3[(int)pbVar5]) { + if (__n == pbVar6) { + __n = (byte *)0x1; + } + else { + __n = __n + 1; + pbVar12 = pbVar10; + } + } + else { + pbVar6 = (byte *)0x1; + __n = (byte *)0x1; + pbVar14 = pbVar10; + pbVar12 = pbVar10 + 1; + } + goto LAB_230a45ac; +} + + + +char * strstr(char *__haystack,char *__needle) + +{ + byte bVar1; + byte bVar2; + char cVar3; + size_t __n; + size_t sVar4; + int iVar5; + uint __c; + char *pcVar6; + uint uVar7; + byte *pbVar8; + uint uVar9; + char *pcVar10; + byte abStack96 [68]; + + __c = (uint)(byte)*__needle; + if (*__needle != 0) { + uVar7 = (uint)(byte)__needle[1]; + if (__needle[1] == 0) { + __haystack = strchr(__haystack,__c); + } + else { + bVar1 = __needle[2]; + if (bVar1 == 0) { + uVar9 = (uint)(byte)*__haystack; + if (*__haystack != 0) { + bVar1 = __haystack[1]; + pcVar10 = __haystack + 1; + while (pcVar6 = pcVar10, uVar9 = (uint)bVar1 | uVar9 << 0x10, bVar1 != 0) { + bVar1 = pcVar6[1]; + pcVar10 = pcVar6 + 1; + if ((__c << 0x10 | uVar7) == uVar9) { + return pcVar6 + -1; + } + } + } + } + else { + if (__needle[3] == 0) { + if (*__haystack != 0) { + uVar9 = (uint)(byte)*__haystack << 8; + bVar2 = __haystack[1]; + pcVar10 = __haystack + 1; + while (pcVar6 = pcVar10, uVar9 = (bVar2 | uVar9) << 8, bVar2 != 0) { + bVar2 = pcVar6[1]; + pcVar10 = pcVar6 + 1; + if ((__c << 0x18 | uVar7 << 0x10 | (uint)bVar1 << 8) == uVar9) { + return pcVar6 + -2; + } + } + } + } + else { + if (__needle[4] == '\0') { + bVar2 = *__haystack; + __c = __c << 0x18 | uVar7 << 0x10 | (uint)(byte)__needle[3] | (uint)bVar1 << 8; + if (bVar2 != 0) { + uVar7 = 0; + do { + pcVar10 = __haystack; + uVar7 = (uint)bVar2 | uVar7 << 8; + bVar2 = pcVar10[1]; + if (bVar2 == 0) { + if (__c != uVar7) goto LAB_230a4b4c; + break; + } + __haystack = pcVar10 + 1; + } while (__c != uVar7); + return pcVar10 + -3; + } + } + else { + __n = strlen(__needle); + sVar4 = strnlen(__haystack,__n | 0x200); + if (__n <= sVar4) { + if (0xfe < __n) { + pcVar10 = (char *)two_way_long_needle(__haystack,sVar4,__needle,__n); + return pcVar10; + } + pcVar10 = __haystack + (sVar4 - __n); + memset(abStack96,__n + 1,0x40); + if (__n != 0) { + pbVar8 = (byte *)__needle; + do { + bVar1 = *pbVar8; + cVar3 = (char)pbVar8; + pbVar8 = pbVar8 + 1; + abStack96[(uint)bVar1 & 0x3f] = ((char)__needle + (char)__n) - cVar3; + } while ((byte *)(__needle + __n) != pbVar8); + } + while( true ) { + __haystack = __haystack + -1 + abStack96[(uint)(byte)(__haystack + -1)[__n] & 0x3f]; + while (__haystack <= pcVar10) { + bVar1 = abStack96[(uint)(byte)__haystack[__n] & 0x3f]; + iVar5 = memcmp(__haystack,__needle,__n); + if (iVar5 == 0) { + return __haystack; + } + __haystack = __haystack + bVar1; + } + if (pcVar10[__n] == '\0') break; + sVar4 = strnlen(pcVar10 + __n,0x800); + pcVar10 = pcVar10 + sVar4; + if (pcVar10 < __haystack) { + return (char *)0x0; + } + } + } + } + } + } +LAB_230a4b4c: + __haystack = (char *)0x0; + } + } + return __haystack; +} + + + +uint _strtol_l_isra_0(undefined4 *param_1,byte *param_2,byte **param_3,uint param_4) + +{ + byte bVar1; + bool bVar2; + uint uVar3; + byte *pbVar4; + uint uVar5; + byte *pbVar6; + uint uVar7; + uint uVar8; + int iVar9; + uint uVar10; + + pbVar6 = param_2; + do { + pbVar4 = pbVar6; + pbVar6 = pbVar4 + 1; + bVar1 = *pbVar4; + uVar7 = (uint)bVar1; + } while ((_ctype_[uVar7 + 1] & 8) != 0); + if (bVar1 == 0x2d) { + uVar7 = (uint)*pbVar6; + bVar2 = true; + pbVar6 = pbVar4 + 2; +LAB_230a4c4c: + if (param_4 != 0) goto LAB_230a4c50; +LAB_230a4cd4: + if (uVar7 != 0x30) { + uVar10 = 10; + param_4 = 10; + goto LAB_230a4c5c; + } + if ((*pbVar6 & 0xdf) != 0x58) { + uVar10 = 8; + param_4 = 8; + goto LAB_230a4c5c; + } + } + else { + if (bVar1 != 0x2b) { + bVar2 = false; + goto LAB_230a4c4c; + } + uVar7 = (uint)*pbVar6; + bVar2 = false; + pbVar6 = pbVar4 + 2; + if (param_4 == 0) goto LAB_230a4cd4; +LAB_230a4c50: + uVar10 = param_4; + if (param_4 != 0x10) goto LAB_230a4c5c; + if ((uVar7 != 0x30) || ((*pbVar6 & 0xdf) != 0x58)) { + uVar10 = 0x10; + goto LAB_230a4c5c; + } + } + uVar7 = (uint)pbVar6[1]; + uVar10 = 0x10; + pbVar6 = pbVar6 + 2; + param_4 = 0x10; +LAB_230a4c5c: + uVar3 = 0x80000000; + if (!bVar2) { + uVar3 = 0x7fffffff; + } + iVar9 = 0; + uVar5 = 0; + do { + uVar8 = uVar7 - 0x30; + if (9 < uVar8) { + if (uVar7 - 0x41 < 0x1a) { + uVar8 = uVar7 - 0x37; + } + else { + if (0x19 < uVar7 - 0x61) break; + uVar8 = uVar7 - 0x57; + } + } + if ((int)param_4 <= (int)uVar8) break; + if (((iVar9 != -1) && (iVar9 = -1, uVar5 <= uVar3 / uVar10)) && + ((uVar3 / uVar10 != uVar5 || ((int)uVar8 <= (int)(uVar3 % uVar10))))) { + iVar9 = 1; + uVar5 = uVar8 + uVar10 * uVar5; + } + uVar7 = (uint)*pbVar6; + pbVar6 = pbVar6 + 1; + } while( true ); + if (iVar9 == -1) { + *param_1 = 0x22; + if (param_3 == (byte **)0x0) { + return uVar3; + } + } + else { + uVar3 = uVar5; + if (bVar2) { + uVar3 = -uVar5; + } + if (param_3 == (byte **)0x0) { + return uVar3; + } + if (iVar9 == 0) goto LAB_230a4d10; + } + param_2 = pbVar6 + -1; +LAB_230a4d10: + *param_3 = param_2; + return uVar3; +} + + + +uint _strtol_r(undefined4 *param_1,byte *param_2,byte **param_3,uint param_4) + +{ + byte bVar1; + bool bVar2; + uint uVar3; + byte *pbVar4; + uint uVar5; + byte *pbVar6; + uint uVar7; + uint uVar8; + int iVar9; + uint uVar10; + + pbVar6 = param_2; + do { + pbVar4 = pbVar6; + pbVar6 = pbVar4 + 1; + bVar1 = *pbVar4; + uVar7 = (uint)bVar1; + } while ((_ctype_[uVar7 + 1] & 8) != 0); + if (bVar1 == 0x2d) { + uVar7 = (uint)*pbVar6; + bVar2 = true; + pbVar6 = pbVar4 + 2; +LAB_230a4c4c: + if (param_4 != 0) goto LAB_230a4c50; +LAB_230a4cd4: + if (uVar7 != 0x30) { + uVar10 = 10; + param_4 = 10; + goto LAB_230a4c5c; + } + if ((*pbVar6 & 0xdf) != 0x58) { + uVar10 = 8; + param_4 = 8; + goto LAB_230a4c5c; + } + } + else { + if (bVar1 != 0x2b) { + bVar2 = false; + goto LAB_230a4c4c; + } + uVar7 = (uint)*pbVar6; + bVar2 = false; + pbVar6 = pbVar4 + 2; + if (param_4 == 0) goto LAB_230a4cd4; +LAB_230a4c50: + uVar10 = param_4; + if (param_4 != 0x10) goto LAB_230a4c5c; + if ((uVar7 != 0x30) || ((*pbVar6 & 0xdf) != 0x58)) { + uVar10 = 0x10; + goto LAB_230a4c5c; + } + } + uVar7 = (uint)pbVar6[1]; + uVar10 = 0x10; + pbVar6 = pbVar6 + 2; + param_4 = 0x10; +LAB_230a4c5c: + uVar3 = 0x80000000; + if (!bVar2) { + uVar3 = 0x7fffffff; + } + iVar9 = 0; + uVar5 = 0; + do { + uVar8 = uVar7 - 0x30; + if (9 < uVar8) { + if (uVar7 - 0x41 < 0x1a) { + uVar8 = uVar7 - 0x37; + } + else { + if (0x19 < uVar7 - 0x61) break; + uVar8 = uVar7 - 0x57; + } + } + if ((int)param_4 <= (int)uVar8) break; + if (((iVar9 != -1) && (iVar9 = -1, uVar5 <= uVar3 / uVar10)) && + ((uVar3 / uVar10 != uVar5 || ((int)uVar8 <= (int)(uVar3 % uVar10))))) { + iVar9 = 1; + uVar5 = uVar8 + uVar10 * uVar5; + } + uVar7 = (uint)*pbVar6; + pbVar6 = pbVar6 + 1; + } while( true ); + if (iVar9 == -1) { + *param_1 = 0x22; + if (param_3 == (byte **)0x0) { + return uVar3; + } + } + else { + uVar3 = uVar5; + if (bVar2) { + uVar3 = -uVar5; + } + if (param_3 == (byte **)0x0) { + return uVar3; + } + if (iVar9 == 0) goto LAB_230a4d10; + } + param_2 = pbVar6 + -1; +LAB_230a4d10: + *param_3 = param_2; + return uVar3; +} + + + +long strtol_l(char *__nptr,char **__endptr,int __base,__locale_t __loc) + +{ + long lVar1; + + lVar1 = _strtol_l_isra_0(_impure_ptr,__nptr,__endptr,__base); + return lVar1; +} + + + +long strtol(char *__nptr,char **__endptr,int __base) + +{ + long lVar1; + + lVar1 = _strtol_l_isra_0(_impure_ptr,__nptr,__endptr,__base); + return lVar1; +} + + + +uint _strtoul_l_isra_0(undefined4 *param_1,byte *param_2,byte **param_3,uint param_4) + +{ + byte bVar1; + bool bVar2; + uint uVar3; + byte *pbVar4; + uint uVar5; + byte *pbVar6; + uint uVar7; + uint uVar8; + int iVar9; + uint uVar10; + uint uVar11; + + pbVar6 = param_2; + do { + pbVar4 = pbVar6; + pbVar6 = pbVar4 + 1; + bVar1 = *pbVar4; + uVar7 = (uint)bVar1; + } while ((_ctype_[uVar7 + 1] & 8) != 0); + if (bVar1 == 0x2d) { + uVar7 = (uint)*pbVar6; + bVar2 = true; + pbVar6 = pbVar4 + 2; +LAB_230a4e34: + if (param_4 != 0) goto LAB_230a4e38; +LAB_230a4eb0: + if (uVar7 != 0x30) { + uVar3 = 5; + uVar10 = 0x19999999; + uVar11 = 10; + param_4 = 10; + goto LAB_230a4e50; + } + if ((*pbVar6 & 0xdf) != 0x58) { + uVar3 = 7; + uVar10 = 0x1fffffff; + uVar11 = 8; + param_4 = 8; + goto LAB_230a4e50; + } + } + else { + if (bVar1 != 0x2b) { + bVar2 = false; + goto LAB_230a4e34; + } + uVar7 = (uint)*pbVar6; + bVar2 = false; + pbVar6 = pbVar4 + 2; + if (param_4 == 0) goto LAB_230a4eb0; +LAB_230a4e38: + if (param_4 != 0x10) { + uVar10 = 0xffffffff / param_4; + uVar3 = 0xffffffff % param_4; + uVar11 = param_4; + goto LAB_230a4e50; + } + if (uVar7 != 0x30) { + uVar3 = 0xf; + uVar10 = 0xfffffff; + uVar11 = 0x10; + goto LAB_230a4e50; + } + if ((*pbVar6 & 0xdf) != 0x58) { + uVar11 = 0x10; + uVar10 = 0xfffffff; + uVar3 = 0xf; + goto LAB_230a4e50; + } + } + uVar7 = (uint)pbVar6[1]; + uVar3 = 0xf; + pbVar6 = pbVar6 + 2; + uVar10 = 0xfffffff; + uVar11 = 0x10; + param_4 = 0x10; +LAB_230a4e50: + iVar9 = 0; + uVar5 = 0; + do { + uVar8 = uVar7 - 0x30; + if (9 < uVar8) { + if (uVar7 - 0x41 < 0x1a) { + uVar8 = uVar7 - 0x37; + } + else { + if (0x19 < uVar7 - 0x61) { +LAB_230a4ee8: + if (iVar9 < 0) { + *param_1 = 0x22; + uVar5 = 0xffffffff; + if (param_3 == (byte **)0x0) { + return uVar5; + } + } + else { + if (bVar2) { + uVar5 = -uVar5; + } + if (param_3 == (byte **)0x0) { + return uVar5; + } + if (iVar9 == 0) { + *param_3 = param_2; + return uVar5; + } + } + *param_3 = pbVar6 + -1; + return uVar5; + } + uVar8 = uVar7 - 0x57; + } + } + if ((int)param_4 <= (int)uVar8) goto LAB_230a4ee8; + if (iVar9 < 0) { + iVar9 = -1; + } + else { + iVar9 = -1; + if ((uVar5 <= uVar10) && ((uVar5 != uVar10 || ((int)uVar8 <= (int)uVar3)))) { + iVar9 = 1; + uVar5 = uVar8 + uVar11 * uVar5; + } + } + uVar7 = (uint)*pbVar6; + pbVar6 = pbVar6 + 1; + } while( true ); +} + + + +uint _strtoul_r(undefined4 *param_1,byte *param_2,byte **param_3,uint param_4) + +{ + byte bVar1; + bool bVar2; + uint uVar3; + byte *pbVar4; + uint uVar5; + byte *pbVar6; + uint uVar7; + uint uVar8; + int iVar9; + uint uVar10; + uint uVar11; + + pbVar6 = param_2; + do { + pbVar4 = pbVar6; + pbVar6 = pbVar4 + 1; + bVar1 = *pbVar4; + uVar7 = (uint)bVar1; + } while ((_ctype_[uVar7 + 1] & 8) != 0); + if (bVar1 == 0x2d) { + uVar7 = (uint)*pbVar6; + bVar2 = true; + pbVar6 = pbVar4 + 2; +LAB_230a4e34: + if (param_4 != 0) goto LAB_230a4e38; +LAB_230a4eb0: + if (uVar7 != 0x30) { + uVar3 = 5; + uVar10 = 0x19999999; + uVar11 = 10; + param_4 = 10; + goto LAB_230a4e50; + } + if ((*pbVar6 & 0xdf) != 0x58) { + uVar3 = 7; + uVar10 = 0x1fffffff; + uVar11 = 8; + param_4 = 8; + goto LAB_230a4e50; + } + } + else { + if (bVar1 != 0x2b) { + bVar2 = false; + goto LAB_230a4e34; + } + uVar7 = (uint)*pbVar6; + bVar2 = false; + pbVar6 = pbVar4 + 2; + if (param_4 == 0) goto LAB_230a4eb0; +LAB_230a4e38: + if (param_4 != 0x10) { + uVar10 = 0xffffffff / param_4; + uVar3 = 0xffffffff % param_4; + uVar11 = param_4; + goto LAB_230a4e50; + } + if (uVar7 != 0x30) { + uVar3 = 0xf; + uVar10 = 0xfffffff; + uVar11 = 0x10; + goto LAB_230a4e50; + } + if ((*pbVar6 & 0xdf) != 0x58) { + uVar11 = 0x10; + uVar10 = 0xfffffff; + uVar3 = 0xf; + goto LAB_230a4e50; + } + } + uVar7 = (uint)pbVar6[1]; + uVar3 = 0xf; + pbVar6 = pbVar6 + 2; + uVar10 = 0xfffffff; + uVar11 = 0x10; + param_4 = 0x10; +LAB_230a4e50: + iVar9 = 0; + uVar5 = 0; + do { + uVar8 = uVar7 - 0x30; + if (9 < uVar8) { + if (uVar7 - 0x41 < 0x1a) { + uVar8 = uVar7 - 0x37; + } + else { + if (0x19 < uVar7 - 0x61) { +LAB_230a4ee8: + if (iVar9 < 0) { + *param_1 = 0x22; + uVar5 = 0xffffffff; + if (param_3 == (byte **)0x0) { + return uVar5; + } + } + else { + if (bVar2) { + uVar5 = -uVar5; + } + if (param_3 == (byte **)0x0) { + return uVar5; + } + if (iVar9 == 0) { + *param_3 = param_2; + return uVar5; + } + } + *param_3 = pbVar6 + -1; + return uVar5; + } + uVar8 = uVar7 - 0x57; + } + } + if ((int)param_4 <= (int)uVar8) goto LAB_230a4ee8; + if (iVar9 < 0) { + iVar9 = -1; + } + else { + iVar9 = -1; + if ((uVar5 <= uVar10) && ((uVar5 != uVar10 || ((int)uVar8 <= (int)uVar3)))) { + iVar9 = 1; + uVar5 = uVar8 + uVar11 * uVar5; + } + } + uVar7 = (uint)*pbVar6; + pbVar6 = pbVar6 + 1; + } while( true ); +} + + + +ulong strtoul_l(char *__nptr,char **__endptr,int __base,__locale_t __loc) + +{ + ulong uVar1; + + uVar1 = _strtoul_l_isra_0(_impure_ptr,__nptr,__endptr,__base); + return uVar1; +} + + + +ulong strtoul(char *__nptr,char **__endptr,int __base) + +{ + ulong uVar1; + + uVar1 = _strtoul_l_isra_0(_impure_ptr,__nptr,__endptr,__base); + return uVar1; +} + + + +int stat(char *__file,stat *__buf) + +{ + int iVar1; + + iVar1 = _stat_r(_impure_ptr,__file,__buf); + return iVar1; +} + + + +undefined4 __sprint_r_part_0(undefined4 param_1,int param_2,int **param_3) + +{ + undefined4 *puVar1; + uint uVar2; + int iVar3; + undefined4 uVar4; + int *piVar5; + uint uVar6; + int *piVar7; + uint uVar8; + + if (*(int *)(param_2 + 100) << 0x12 < 0) { + piVar5 = param_3[2]; + piVar7 = *param_3; + while (piVar5 != (int *)0x0) { + uVar8 = piVar7[1]; + puVar1 = (undefined4 *)*piVar7; + uVar6 = uVar8 >> 2; + if (uVar6 != 0) { + uVar2 = 0; + do { + iVar3 = _fputwc_r(param_1,*puVar1,param_2); + uVar2 = uVar2 + 1; + if (iVar3 == -1) { + uVar4 = 0xffffffff; + goto LAB_230a50ac; + } + puVar1 = puVar1 + 1; + } while (uVar6 != uVar2); + piVar5 = param_3[2]; + } + piVar5 = (int *)((int)piVar5 - (uVar8 & 0xfffffffc)); + param_3[2] = piVar5; + piVar7 = piVar7 + 2; + } + uVar4 = 0; + } + else { + uVar4 = __sfvwrite_r(); + } +LAB_230a50ac: + param_3[2] = (int *)0x0; + param_3[1] = (int *)0x0; + return uVar4; +} + + + +undefined4 __sprint_r(int param_1) + +{ + undefined4 uVar1; + + if (*(int *)(param_1 + 8) != 0) { + uVar1 = __sprint_r_part_0(); + return uVar1; + } + *(undefined4 *)(param_1 + 4) = 0; + return 0; +} + + + +// WARNING: Type propagation algorithm not settling + +int _vfiprintf_r(int param_1,int param_2,int *param_3,int **param_4) + +{ + bool bVar1; + byte bVar2; + ushort uVar3; + bool bVar4; + bool bVar5; + bool bVar6; + bool bVar7; + bool bVar8; + bool bVar9; + int *piVar10; + int iVar11; + undefined4 uVar12; + void *pvVar13; + int **ppiVar14; + int **ppiVar15; + int **ppiVar16; + int *piVar17; + uint uVar18; + int iVar19; + uint uVar20; + uint uVar21; + int *piVar22; + char cVar23; + int *__n; + int *piVar24; + char *__s; + int *piVar25; + int iStack300; + int **ppiStack292; + char *pcStack288; + byte *pbStack272; + char *pcStack268; + size_t sStack264; + char cStack245; + undefined2 auStack244 [2]; + int **ppiStack240; + int iStack236; + int *piStack232; + int *local_e4 [16]; + undefined uStack164; + byte abStack66 [14]; + + if ((param_1 != 0) && (*(int *)(param_1 + 0x38) == 0)) { + __sinit(); + } + uVar3 = *(ushort *)(param_2 + 0xc); + uVar20 = (int)(short)uVar3 & 0xffff; + if (-1 < (int)(uVar20 << 0x12)) { + *(ushort *)(param_2 + 0xc) = uVar3 | 0x2000; + *(uint *)(param_2 + 100) = *(uint *)(param_2 + 100) & 0xffffdfff; + uVar20 = (int)(short)uVar3 & 0xffffU | 0x2000; + } + if (((uVar20 & 8) == 0) || (*(int *)(param_2 + 0x10) == 0)) { + iVar11 = __swsetup_r(param_1,param_2); + if (iVar11 != 0) { + return 0xffffffff; + } + if ((*(ushort *)(param_2 + 0xc) & 0x1a) != 10) goto LAB_230a51d0; + } + else { + if ((uVar20 & 0x1a) != 10) goto LAB_230a51d0; + } + if (-1 < *(short *)(param_2 + 0xe)) { + uVar12 = __sbprintf(param_1,param_2,param_3,param_4); + return uVar12; + } +LAB_230a51d0: + piStack232 = (int *)0x0; + iStack236 = 0; + pcStack288 = (char *)0x0; + pbStack272 = (byte *)0x0; + sStack264 = 0; + pcStack268 = (char *)0x0; + iStack300 = 0; + ppiVar16 = local_e4; + ppiStack292 = param_4; + ppiStack240 = local_e4; +LAB_230a520c: + if (*(byte *)param_3 == 0) { +LAB_230a5378: + if (piStack232 != (int *)0x0) { + __sprint_r_part_0(param_1,param_2,&ppiStack240); + } +LAB_230a5390: + if ((*(ushort *)(param_2 + 0xc) & 0x40) != 0) { + return 0xffffffff; + } + return iStack300; + } + piVar24 = param_3; + if (*(byte *)param_3 != 0x25) { + do { + __n = piVar24; + piVar24 = (int *)((int)__n + 1); + if (*(byte *)((int)__n + 1) == 0) { + piVar10 = (int *)((int)piVar24 - (int)param_3); + if (piVar10 == (int *)0x0) goto LAB_230a5378; + goto LAB_230a5240; + } + } while (*(byte *)((int)__n + 1) != 0x25); + piVar10 = (int *)((int)piVar24 - (int)param_3); + if (piVar10 != (int *)0x0) { +LAB_230a5240: + *ppiVar16 = param_3; + piStack232 = (int *)((int)piVar10 + (int)piStack232); + iStack236 = iStack236 + 1; + ppiVar16[1] = piVar10; + ppiVar16 = ppiVar16 + 2; + if (7 < iStack236) { + if (piStack232 == (int *)0x0) { + iStack236 = 0; + ppiVar16 = local_e4; + } + else { + iVar11 = __sprint_r_part_0(param_1,param_2,&ppiStack240); + ppiVar16 = local_e4; + if (iVar11 != 0) goto LAB_230a5390; + } + } + iStack300 = iStack300 + (int)piVar10; + if (*(byte *)((int)__n + 1) == 0) goto LAB_230a5378; + } + } + uVar18 = (uint)*(byte *)((int)piVar24 + 1); + cStack245 = '\0'; + __n = (int *)0xffffffff; + piVar10 = (int *)0x0; + uVar20 = 0; + bVar9 = false; + bVar8 = false; + bVar6 = false; + bVar5 = false; + bVar1 = false; + bVar4 = false; + bVar7 = false; + param_3 = (int *)((int)piVar24 + 1); +LAB_230a52b8: + param_3 = (int *)((int)param_3 + 1); +LAB_230a52c0: + uVar21 = uVar18 - 0x20; + if (uVar21 < 0x5b) { +LAB_230a52c8: + piVar24 = __n; + switch((int)&switchdataD_230cb6b4 + (&switchdataD_230cb6b4)[uVar21] & 0xfffffffe) { + case 0x230a52dc: + iVar11 = _localeconv_r(param_1); + pcStack268 = *(char **)(iVar11 + 4); + sStack264 = strlen(pcStack268); + iVar11 = _localeconv_r(param_1); + pbStack272 = *(byte **)(iVar11 + 8); + if (sStack264 == 0) goto switchD_230a52d8_caseD_230a5310; + uVar18 = (uint)*(byte *)param_3; + if ((pbStack272 != (byte *)0x0) && (*pbStack272 != 0)) { + uVar20 = uVar20 | 0x400; + bVar9 = true; + } + goto LAB_230a52b8; + case 0x230a5310: +switchD_230a52d8_caseD_230a5310: + uVar18 = (uint)*(byte *)param_3; + goto LAB_230a52b8; + case 0x230a5318: + uVar20 = uVar20 | 0x20; + bVar4 = true; + uVar18 = (uint)*(byte *)param_3; + goto LAB_230a52b8; + case 0x230a53e0: + pcStack288 = "0123456789ABCDEF"; + if (!bVar4) goto LAB_230a591c; +LAB_230a53f4: + ppiStack292 = (int **)((int)ppiStack292 + 7U & 0xfffffff8); + piVar22 = *ppiStack292; + piVar25 = ppiStack292[1]; + ppiStack292 = ppiStack292 + 2; + goto LAB_230a5410; + case 0x230a5470: + goto switchD_230a52d8_caseD_230a5470; + case 0x230a54a4: + goto switchD_230a52d8_caseD_230a54a4; + case 0x230a5608: + uVar20 = uVar20 | 0x10; + if (bVar4) { +LAB_230a5b58: + iVar11 = 1; + ppiVar15 = (int **)((int)ppiStack292 + 7U & 0xfffffff8); + ppiStack292 = ppiVar15 + 2; + piVar22 = *ppiVar15; + piVar25 = ppiVar15[1]; + } + else { +LAB_230a561c: + piVar25 = (int *)0x0; + piVar22 = *ppiStack292; + iVar11 = 1; + ppiStack292 = ppiStack292 + 1; + } + break; + case 0x230a5634: + uVar20 = uVar20 | 0x80; + uVar18 = (uint)*(byte *)param_3; + goto LAB_230a52b8; + case 0x230a5640: + cStack245 = '\0'; + __s = (char *)*ppiStack292; + ppiStack292 = ppiStack292 + 1; + if ((int *)__s != (int *)0x0) { + if (__n == (int *)0xffffffff) { + piVar22 = (int *)strlen(__s); + piVar24 = (int *)0x0; + } + else { + pvVar13 = memchr(__s,0,(size_t)__n); + if (pvVar13 == (void *)0x0) { + piVar24 = (int *)0x0; + piVar22 = __n; + } + else { + piVar24 = (int *)0x0; + piVar22 = (int *)((int)pvVar13 - (int)__s); + } + } + goto LAB_230a5454; + } + if ((int *)0x6 < __n) { + __n = (int *)0x6; + } + __s = "(null)"; + goto LAB_230a54bc; + case 0x230a5688: + uVar20 = uVar20 | 0x10; + if (bVar4) { +LAB_230a5b04: + ppiStack292 = (int **)((int)ppiStack292 + 7U & 0xfffffff8); + piVar22 = *ppiStack292; + piVar25 = ppiStack292[1]; + ppiStack292 = ppiStack292 + 2; + } + else { +LAB_230a569c: + piVar25 = (int *)0x0; + piVar22 = *ppiStack292; + ppiStack292 = ppiStack292 + 1; + } + goto LAB_230a5b20; + case 0x230a56b0: + uVar20 = uVar20 | 0x10; + if (bVar4) { +LAB_230a5b30: + ppiVar15 = (int **)((int)ppiStack292 + 7U & 0xfffffff8); + piVar25 = ppiVar15[1]; + ppiStack292 = ppiVar15 + 2; + piVar22 = *ppiVar15; + } + else { +LAB_230a56c4: + piVar22 = *ppiStack292; + piVar25 = (int *)((int)piVar22 >> 0x1f); + ppiStack292 = ppiStack292 + 1; + } +LAB_230a56d8: + if ((int)piVar25 < 0) goto LAB_230a5a60; +LAB_230a56dc: + cVar23 = (char)piVar22; + if (__n == (int *)0xffffffff) goto LAB_230a56f4; + uVar20 = uVar20 & 0xffffff7f; + bVar8 = false; + if (((uint)piVar22 | (uint)piVar25) != 0) goto LAB_230a56f4; + if (__n == (int *)0x0) goto LAB_230a5f84; + goto LAB_230a5700; + case 0x230a5718: + piVar24 = *ppiStack292; + ppiStack292 = ppiStack292 + 1; + uStack164 = SUB41(piVar24,0); + __n = (int *)&DAT_00000001; + __s = &uStack164; + goto LAB_230a54bc; + case 0x230a581c: + uVar18 = (uint)*(byte *)param_3; + if (cStack245 == '\0') { + cStack245 = ' '; + } + goto LAB_230a52b8; + case 0x230a5834: + cStack245 = '+'; + uVar18 = (uint)*(byte *)param_3; + goto LAB_230a52b8; + case 0x230a5844: + uVar18 = (uint)*(byte *)param_3; + piVar10 = *ppiStack292; + ppiStack292 = ppiStack292 + 1; + if ((int)piVar10 < 0) { + piVar10 = (int *)-(int)piVar10; + uVar20 = uVar20 | 4; + } + goto LAB_230a52b8; + case 0x230a5868: + uVar20 = uVar20 | 1; + bVar1 = true; + uVar18 = (uint)*(byte *)param_3; + goto LAB_230a52b8; + case 0x230a5874: + goto switchD_230a52d8_caseD_230a5874; + case 0x230a58bc: + uVar18 = (uint)*(byte *)param_3; + uVar20 = uVar20 | 4; + goto LAB_230a52b8; + case 0x230a58c8: + if (bVar4) goto LAB_230a5b58; + ppiVar15 = ppiStack292 + 1; + piVar22 = *ppiStack292; + if (bVar5) goto LAB_230a561c; + ppiStack292 = ppiVar15; + if (bVar6) { + piVar22 = (int *)((uint)piVar22 & 0xffff); + piVar25 = (int *)0x0; + iVar11 = 1; + } + else { + if (bVar7) { + piVar22 = (int *)((uint)piVar22 & 0xff); + piVar25 = (int *)0x0; + iVar11 = 1; + } + else { + piVar25 = (int *)0x0; + iVar11 = 1; + } + } + break; + case 0x230a5908: + pcStack288 = "0123456789abcdef"; + if (bVar4) goto LAB_230a53f4; +LAB_230a591c: + piVar22 = *ppiStack292; + ppiStack292 = ppiStack292 + 1; + if (bVar5) { +LAB_230a5f9c: + piVar25 = (int *)0x0; + } + else { + if (bVar6) { + piVar22 = (int *)((uint)piVar22 & 0xffff); + piVar25 = (int *)0x0; + } + else { + if (!bVar7) goto LAB_230a5f9c; + piVar22 = (int *)((uint)piVar22 & 0xff); + piVar25 = (int *)0x0; + } + } +LAB_230a5410: + if ((bVar1) && (((uint)piVar22 | (uint)piVar25) != 0)) { + auStack244[0] = CONCAT11((char)uVar18,0x30); + uVar20 = uVar20 & 0xfffffbff | 2; + bVar9 = false; + bVar8 = true; + iVar11 = 2; + } + else { + uVar20 = uVar20 & 0xfffffbff; + bVar9 = false; + bVar8 = false; + iVar11 = 2; + } + break; + case 0x230a594c: + piVar25 = (int *)0x0; + piVar22 = *ppiStack292; + ppiStack292 = ppiStack292 + 1; + uVar20 = uVar20 | 2; + bVar8 = true; + auStack244[0] = 0x7830; + pcStack288 = "0123456789abcdef"; + iVar11 = 2; + break; + case 0x230a5980: + if (bVar4) goto LAB_230a5b04; + ppiVar15 = ppiStack292 + 1; + piVar22 = *ppiStack292; + if (bVar5) goto LAB_230a569c; + ppiStack292 = ppiVar15; + if (bVar6) { + piVar22 = (int *)((uint)piVar22 & 0xffff); + piVar25 = (int *)0x0; + } + else { + if (bVar7) { + piVar22 = (int *)((uint)piVar22 & 0xff); + piVar25 = (int *)0x0; + } + else { + piVar25 = (int *)0x0; + } + } +LAB_230a5b20: + uVar20 = uVar20 & 0xfffffbff; + bVar9 = false; + bVar8 = false; + iVar11 = 0; + break; + case 0x230a59bc: + ppiVar15 = ppiStack292 + 1; + if (bVar4) { + piVar24 = *ppiStack292; + *piVar24 = iStack300; + piVar24[1] = iStack300 >> 0x1f; + ppiStack292 = ppiVar15; + goto LAB_230a520c; + } + if (!bVar5) { + if (bVar6) { + *(short *)*ppiStack292 = (short)iStack300; + ppiStack292 = ppiVar15; + goto LAB_230a520c; + } + if (bVar7) { + *(byte *)*ppiStack292 = (byte)iStack300; + ppiStack292 = ppiVar15; + goto LAB_230a520c; + } + } + **ppiStack292 = iStack300; + ppiStack292 = ppiVar15; + goto LAB_230a520c; + case 0x230a59fc: + uVar18 = (uint)*(byte *)param_3; + if (*(byte *)param_3 == 0x6c) { + uVar18 = (uint)*(byte *)((int)param_3 + 1); + uVar20 = uVar20 | 0x20; + bVar4 = true; + param_3 = (int *)((int)param_3 + 1); + } + else { + uVar20 = uVar20 | 0x10; + bVar5 = true; + } + goto LAB_230a52b8; + case 0x230a5a10: + uVar18 = (uint)*(byte *)param_3; + if (*(byte *)param_3 == 0x68) { + uVar18 = (uint)*(byte *)((int)param_3 + 1); + uVar20 = uVar20 | 0x200; + bVar7 = true; + param_3 = (int *)((int)param_3 + 1); + } + else { + uVar20 = uVar20 | 0x40; + bVar6 = true; + } + goto LAB_230a52b8; + case 0x230a5a24: + if (bVar4) goto LAB_230a5b30; + ppiVar15 = ppiStack292 + 1; + if (bVar5) goto LAB_230a56c4; + if (!bVar6) { + if (bVar7) { + piVar22 = (int *)(int)*(char *)ppiStack292; + piVar25 = (int *)((int)piVar22 >> 0x1f); + ppiStack292 = ppiVar15; + } + else { + piVar22 = *ppiStack292; + piVar25 = (int *)((int)piVar22 >> 0x1f); + ppiStack292 = ppiVar15; + } + goto LAB_230a56d8; + } + piVar22 = (int *)(int)*(short *)ppiStack292; + piVar25 = (int *)((int)piVar22 >> 0x1f); + ppiStack292 = ppiVar15; + if (-1 < (int)piVar25) goto LAB_230a56dc; +LAB_230a5a60: + piVar22 = (int *)-(int)piVar22; + piVar25 = (int *)(-(uint)(piVar22 != (int *)0x0) - (int)piVar25); + cStack245 = '-'; + iVar11 = 1; + goto joined_r0x230a5430; + } + cStack245 = '\0'; +joined_r0x230a5430: + if (__n != (int *)0xffffffff) { + cVar23 = (char)piVar22; + uVar20 = uVar20 & 0xffffff7f; + if (((uint)piVar22 | (uint)piVar25) != 0) goto LAB_230a5a88; + if (__n == (int *)0x0) { + if (iVar11 == 0) { + __s = (char *)(abStack66 + 2); + piVar22 = (int *)(uint)bVar1; + if (bVar1 != false) { + abStack66[1] = '0'; + __s = (char *)(abStack66 + 1); + } + } + else { +LAB_230a5f84: + __s = (char *)(abStack66 + 2); + piVar22 = (int *)0x0; + piVar24 = (int *)0x0; + } + } + else { + if (iVar11 != 1) goto joined_r0x230a5b8c; +LAB_230a5700: + abStack66[1] = cVar23 + '0'; + __s = (char *)(abStack66 + 1); + piVar22 = (int *)&DAT_00000001; + } + goto LAB_230a5454; + } +LAB_230a5a88: + if (iVar11 != 1) { +joined_r0x230a5b8c: + if (iVar11 == 2) { + __s = (char *)(abStack66 + 2); + do { + uVar18 = (uint)piVar22 & 0xf; + __s = (char *)((int)__s + -1); + piVar22 = (int *)((int)piVar25 << 0x1c | (uint)piVar22 >> 4); + piVar25 = (int *)((uint)piVar25 >> 4); + *__s = pcStack288[uVar18]; + } while (((uint)piVar22 | (uint)piVar25) != 0); + goto LAB_230a5bc4; + } + __s = (char *)(abStack66 + 2); + do { + __n = (int *)__s; + iVar11 = ((uint)piVar22 & 7) + 0x30; + piVar22 = (int *)((int)piVar25 << 0x1d | (uint)piVar22 >> 3); + piVar25 = (int *)((uint)piVar25 >> 3); + *(undefined *)((int)__n + -1) = (char)iVar11; + __s = (char *)((int)__n + -1); + } while (((uint)piVar22 | (uint)piVar25) != 0); + if ((bVar1 == false) || (iVar11 == 0x30)) goto LAB_230a5bc4; + __s = (char *)((int)__n + -2); + *(byte *)((int)__n + -2) = 0x30; + piVar22 = (int *)(abStack66 + (2 - (int)__s)); + goto LAB_230a5454; + } +LAB_230a56f4: + cVar23 = (char)piVar22; + if ((piVar25 == (int *)0x0) && (piVar22 < &DAT_0000000a)) goto LAB_230a5700; + uVar18 = 0; + __s = (char *)(abStack66 + 2); + goto LAB_230a6100; + } +switchD_230a52d8_caseD_230a54a4: + if (uVar18 == 0) goto LAB_230a5378; + uStack164 = (undefined)uVar18; + __n = (int *)&DAT_00000001; + __s = &uStack164; +LAB_230a54bc: + cStack245 = '\0'; + piVar24 = (int *)0x0; + piVar22 = __n; + goto LAB_230a54c0; + while ((piVar22 = __n, piVar17 = piVar25, __udivdi3(), bVar1 = piVar25 != (int *)0x0, + piVar25 = piVar17, bVar1 || (&DAT_0000000a <= __n))) { +LAB_230a6100: + __n = piVar22; + cVar23 = (char)__n; + __umoddi3(); + *(char *)((int)__s + -1) = cVar23 + '0'; + uVar18 = uVar18 + 1; + __s = (char *)((int)__s + -1); + if (((bVar9) && ((uint)*pbStack272 == uVar18)) && (uVar18 != 0xff)) { + if ((piVar25 == (int *)0x0) && (__n < &DAT_0000000a)) break; + __s = (char *)((int)__s - sStack264); + strncpy(__s,pcStack268,sStack264); + pbStack272 = pbStack272 + (pbStack272[1] != 0); + uVar18 = 0; + __udivdi3(); + piVar22 = __n; + goto LAB_230a6100; + } + } +LAB_230a5bc4: + piVar22 = (int *)(abStack66 + (2 - (int)__s)); +LAB_230a5454: + __n = piVar24; + if ((int)piVar24 < (int)piVar22) { + __n = piVar22; + } + __n = (int *)((int)__n + (uint)(cStack245 != '\0')); +LAB_230a54c0: + if (bVar8) { + __n = (int *)((int)__n + 2); + } + iVar11 = iStack236 + 1; + if (((uVar20 & 0x84) == 0) && (piVar25 = (int *)((int)piVar10 - (int)__n), 0 < (int)piVar25)) { + piVar17 = piVar25; + if (0x10 < (int)piVar25) { + while( true ) { + piStack232 = piStack232 + 4; + *(char **)ppiVar16 = " 00000000000000000123456789ABCDEF"; + *(undefined **)(ppiVar16 + 1) = &DAT_00000010; + if (iVar11 < 8) { + ppiVar16 = ppiVar16 + 2; + iVar19 = iStack236 + 2; + iStack236 = iVar11; + } + else { + if (piStack232 == (int *)0x0) { + iVar19 = 1; + iStack236 = 0; + ppiVar16 = local_e4; + } + else { + iStack236 = iVar11; + iVar11 = __sprint_r_part_0(param_1,param_2,&ppiStack240); + if (iVar11 != 0) goto LAB_230a5390; + iVar19 = iStack236 + 1; + ppiVar16 = local_e4; + } + } + iVar11 = iVar19; + piVar25 = piVar17 + -4; + if ((int)piVar25 < 0x11) break; + iVar11 = iStack236 + 1; + piVar17 = piVar17 + -4; + } + } + piStack232 = (int *)((int)piStack232 + (int)piVar25); + *(char **)ppiVar16 = " 00000000000000000123456789ABCDEF"; + ppiVar16[1] = piVar25; + iStack236 = iVar11; + if (iVar11 < 8) { + iVar11 = iVar11 + 1; + ppiVar16 = ppiVar16 + 2; + goto LAB_230a54ec; + } + if (piStack232 != (int *)0x0) { + iVar11 = __sprint_r_part_0(param_1,param_2,&ppiStack240); + if (iVar11 != 0) goto LAB_230a5390; + iVar11 = iStack236 + 1; + ppiVar16 = local_e4; + goto LAB_230a54ec; + } + if (cStack245 != '\0') { + local_e4[0] = (int *)&cStack245; + piStack232 = (int *)&DAT_00000001; + local_e4[1] = (int *)&DAT_00000001; + iStack236 = 1; + ppiVar14 = local_e4 + 2; + goto LAB_230a551c; + } +LAB_230a5dd4: + if (bVar8) { + local_e4[0] = (int *)auStack244; + piStack232 = (int *)0x2; + local_e4[1] = (int *)0x2; + iStack236 = 1; + ppiVar16 = local_e4 + 2; + goto LAB_230a5df0; + } + iStack236 = 0; + ppiVar15 = local_e4 + 2; + iVar11 = 1; + ppiVar16 = local_e4; + } + else { +LAB_230a54ec: + ppiVar14 = ppiVar16 + 2; + ppiVar15 = ppiVar14; + if (cStack245 != '\0') { + piStack232 = (int *)((int)piStack232 + 1); + *(char **)ppiVar16 = &cStack245; + *(undefined **)(ppiVar16 + 1) = &DAT_00000001; + iStack236 = iVar11; + if (iVar11 < 8) { +LAB_230a551c: + iVar11 = iStack236 + 1; + ppiVar15 = ppiVar14 + 2; + ppiVar16 = ppiVar14; + } + else { + if (piStack232 == (int *)0x0) goto LAB_230a5dd4; + iVar11 = __sprint_r_part_0(param_1,param_2,&ppiStack240); + if (iVar11 != 0) goto LAB_230a5390; + ppiVar15 = local_e4 + 2; + iVar11 = iStack236 + 1; + ppiVar16 = local_e4; + } + } + if (bVar8) { + piStack232 = (int *)((int)piStack232 + 2); + *(undefined2 **)ppiVar16 = auStack244; + ppiVar16[1] = (int *)0x2; + ppiVar16 = ppiVar15; + iStack236 = iVar11; + if (iVar11 < 8) { +LAB_230a5df0: + iVar11 = iStack236 + 1; + ppiVar15 = ppiVar16 + 2; + } + else { + if (piStack232 == (int *)0x0) { + ppiVar15 = local_e4 + 2; + iVar11 = 1; + iStack236 = 0; + ppiVar16 = local_e4; + } + else { + iVar11 = __sprint_r_part_0(param_1,param_2,&ppiStack240); + if (iVar11 != 0) goto LAB_230a5390; + ppiVar15 = local_e4 + 2; + iVar11 = iStack236 + 1; + ppiVar16 = local_e4; + } + } + } + } + ppiVar14 = ppiVar16; + if (((uVar20 & 0x84) == 0x80) && (piVar25 = (int *)((int)piVar10 - (int)__n), 0 < (int)piVar25)) { + ppiVar14 = ppiVar15; + if (0x10 < (int)piVar25) { + do { + while( true ) { + piVar17 = piVar25; + piStack232 = piStack232 + 4; + iVar19 = iStack236 + 1; + *ppiVar16 = (int *)0x230cb830; + *(undefined **)(ppiVar16 + 1) = &DAT_00000010; + if (7 < iVar19) break; + iVar11 = iStack236 + 2; + ppiVar16 = ppiVar16 + 2; + iStack236 = iVar19; +LAB_230a5c14: + piVar25 = piVar17 + -4; + if ((int)(piVar17 + -4) < 0x11) goto LAB_230a5c80; + } + if (piStack232 == (int *)0x0) { + iVar11 = 1; + iStack236 = 0; + ppiVar16 = local_e4; + goto LAB_230a5c14; + } + iStack236 = iVar19; + iVar11 = __sprint_r_part_0(param_1,param_2,&ppiStack240); + if (iVar11 != 0) goto LAB_230a5390; + iVar11 = iStack236 + 1; + ppiVar16 = local_e4; + piVar25 = piVar17 + -4; + } while (0x10 < (int)(piVar17 + -4)); +LAB_230a5c80: + piVar25 = piVar17 + -4; + ppiVar14 = ppiVar16 + 2; + } + piStack232 = (int *)((int)piStack232 + (int)piVar25); + *ppiVar16 = (int *)0x230cb830; + ppiVar16[1] = piVar25; + iStack236 = iVar11; + if (iVar11 < 8) { + iVar11 = iVar11 + 1; + ppiVar15 = ppiVar14 + 2; + goto LAB_230a5590; + } + if (piStack232 == (int *)0x0) { + ppiVar15 = local_e4 + 2; + iVar11 = 1; + iStack236 = 0; + ppiVar14 = local_e4; + goto LAB_230a5590; + } + iVar11 = __sprint_r_part_0(param_1,param_2,&ppiStack240); + if (iVar11 != 0) goto LAB_230a5390; + piVar24 = (int *)((int)piVar24 - (int)piVar22); + ppiVar15 = local_e4 + 2; + iVar11 = iStack236 + 1; + ppiVar14 = local_e4; + if (0 < (int)piVar24) goto LAB_230a5cd4; +LAB_230a5598: + piStack232 = (int *)((int)piVar22 + (int)piStack232); + *(char **)ppiVar14 = __s; + ppiVar14[1] = piVar22; + iStack236 = iVar11; + if (iVar11 < 8) goto LAB_230a55d4; + if (piStack232 != (int *)0x0) { + iVar11 = __sprint_r_part_0(param_1,param_2,&ppiStack240); + ppiVar15 = local_e4; + if (iVar11 != 0) goto LAB_230a5390; + goto LAB_230a55d4; + } + iStack236 = 0; + if (((uVar20 & 4) != 0) && + (piVar24 = (int *)((int)piVar10 - (int)__n), ppiVar15 = local_e4, 0 < (int)piVar24)) + goto LAB_230a5758; +LAB_230a5f2c: + if ((int)piVar10 < (int)__n) { + piVar10 = __n; + } + iStack300 = iStack300 + (int)piVar10; + } + else { +LAB_230a5590: + piVar24 = (int *)((int)piVar24 - (int)piVar22); + if ((int)piVar24 < 1) goto LAB_230a5598; +LAB_230a5cd4: + ppiVar16 = ppiVar15; + if (0x10 < (int)piVar24) { + do { + while( true ) { + piVar25 = piVar24; + piStack232 = piStack232 + 4; + iVar19 = iStack236 + 1; + *ppiVar14 = (int *)0x230cb830; + *(undefined **)(ppiVar14 + 1) = &DAT_00000010; + if (7 < iVar19) break; + iVar11 = iStack236 + 2; + ppiVar14 = ppiVar14 + 2; + iStack236 = iVar19; +LAB_230a5cfc: + piVar24 = piVar25 + -4; + if ((int)(piVar25 + -4) < 0x11) goto LAB_230a5d60; + } + if (piStack232 == (int *)0x0) { + iVar11 = 1; + iStack236 = 0; + ppiVar14 = local_e4; + goto LAB_230a5cfc; + } + iStack236 = iVar19; + iVar11 = __sprint_r_part_0(param_1,param_2,&ppiStack240); + if (iVar11 != 0) goto LAB_230a5390; + iVar11 = iStack236 + 1; + piVar24 = piVar25 + -4; + ppiVar14 = local_e4; + } while (0x10 < (int)(piVar25 + -4)); +LAB_230a5d60: + piVar24 = piVar25 + -4; + ppiVar16 = ppiVar14 + 2; + } + piStack232 = (int *)((int)piStack232 + (int)piVar24); + *ppiVar14 = (int *)0x230cb830; + ppiVar14[1] = piVar24; + if (iVar11 < 8) { + iVar11 = iVar11 + 1; + ppiVar15 = ppiVar16 + 2; + ppiVar14 = ppiVar16; + goto LAB_230a5598; + } + if (piStack232 != (int *)0x0) { + iStack236 = iVar11; + iVar11 = __sprint_r_part_0(param_1,param_2,&ppiStack240); + if (iVar11 != 0) goto LAB_230a5390; + ppiVar15 = local_e4 + 2; + iVar11 = iStack236 + 1; + ppiVar14 = local_e4; + goto LAB_230a5598; + } + iStack236 = 1; + ppiVar15 = local_e4 + 2; + piStack232 = piVar22; + local_e4[0] = (int *)__s; + local_e4[1] = piVar22; +LAB_230a55d4: + if (((uVar20 & 4) != 0) && (piVar24 = (int *)((int)piVar10 - (int)__n), 0 < (int)piVar24)) { +LAB_230a5758: + if ((int)piVar24 < 0x11) { + iVar11 = iStack236 + 1; + } + else { + do { + while( true ) { + piStack232 = piStack232 + 4; + iVar19 = iStack236 + 1; + *(char **)ppiVar15 = " 00000000000000000123456789ABCDEF"; + *(undefined **)(ppiVar15 + 1) = &DAT_00000010; + if (7 < iVar19) break; + iVar11 = iStack236 + 2; + ppiVar15 = ppiVar15 + 2; + iStack236 = iVar19; +LAB_230a5784: + piVar24 = piVar24 + -4; + if ((int)piVar24 < 0x11) goto LAB_230a57e0; + } + if (piStack232 == (int *)0x0) { + iVar11 = 1; + ppiVar15 = local_e4; + iStack236 = 0; + goto LAB_230a5784; + } + iStack236 = iVar19; + iVar11 = __sprint_r_part_0(param_1,param_2,&ppiStack240); + if (iVar11 != 0) goto LAB_230a5390; + piVar24 = piVar24 + -4; + iVar11 = iStack236 + 1; + ppiVar15 = local_e4; + } while (0x10 < (int)piVar24); + } +LAB_230a57e0: + piStack232 = (int *)((int)piStack232 + (int)piVar24); + *(char **)ppiVar15 = " 00000000000000000123456789ABCDEF"; + ppiVar15[1] = piVar24; + iStack236 = iVar11; + if (7 < iVar11) { + if (piStack232 == (int *)0x0) goto LAB_230a5f2c; + iVar11 = __sprint_r_part_0(param_1,param_2,&ppiStack240); + if (iVar11 != 0) goto LAB_230a5390; + } + } + if ((int)piVar10 < (int)__n) { + piVar10 = __n; + } + iStack300 = iStack300 + (int)piVar10; + if ((piStack232 != (int *)0x0) && + (iVar11 = __sprint_r_part_0(param_1,param_2,&ppiStack240), iVar11 != 0)) goto LAB_230a5390; + } + iStack236 = 0; + ppiVar16 = local_e4; + goto LAB_230a520c; +switchD_230a52d8_caseD_230a5470: + piVar10 = (int *)0x0; + uVar21 = uVar18 - 0x30; + piVar24 = param_3; + do { + param_3 = (int *)((int)piVar24 + 1); + uVar18 = (uint)*(byte *)piVar24; + piVar10 = (int *)(uVar21 + (int)piVar10 * 10); + uVar21 = uVar18 - 0x30; + piVar24 = param_3; + } while (uVar21 < 10); + uVar21 = uVar18 - 0x20; + if (0x5a < uVar21) goto switchD_230a52d8_caseD_230a54a4; + goto LAB_230a52c8; +switchD_230a52d8_caseD_230a5874: + bVar2 = *(byte *)param_3; + if (bVar2 == 0x2a) goto LAB_230a6374; + __n = (int *)0x0; + param_3 = (int *)((int)param_3 + 1); + while( true ) { + uVar18 = (uint)bVar2; + if (9 < uVar18 - 0x30) break; + bVar2 = *(byte *)param_3; + __n = (int *)((int)__n * 10 + (uVar18 - 0x30)); + param_3 = (int *)((int)param_3 + 1); + } + goto LAB_230a52c0; +LAB_230a6374: + __n = *ppiStack292; + ppiStack292 = ppiStack292 + 1; + if ((int)__n < 0) { + __n = (int *)0xffffffff; + } + uVar18 = (uint)*(byte *)((int)param_3 + 1); + param_3 = (int *)((int)param_3 + 1); + goto LAB_230a52b8; +} + + + +void vfiprintf(undefined4 param_1,undefined4 param_2,undefined4 param_3) + +{ + _vfiprintf_r(_impure_ptr,param_1,param_2,param_3); + return; +} + + + +int __sbprintf(undefined4 param_1,int param_2) + +{ + int iVar1; + int iVar2; + undefined *apuStack1144 [2]; + undefined4 uStack1136; + ushort uStack1132; + undefined2 uStack1130; + undefined *puStack1128; + undefined4 uStack1124; + undefined4 uStack1120; + undefined4 uStack1116; + undefined4 uStack1108; + undefined4 uStack1044; + undefined auStack1040 [1024]; + + uStack1044 = *(undefined4 *)(param_2 + 100); + uStack1130 = *(undefined2 *)(param_2 + 0xe); + uStack1116 = *(undefined4 *)(param_2 + 0x1c); + uStack1108 = *(undefined4 *)(param_2 + 0x24); + uStack1132 = *(ushort *)(param_2 + 0xc) & 0xfffd; + apuStack1144[0] = auStack1040; + uStack1136 = 0x400; + uStack1124 = 0x400; + uStack1120 = 0; + puStack1128 = apuStack1144[0]; + iVar1 = _vfiprintf_r(apuStack1144); + if ((-1 < iVar1) && (iVar2 = _fflush_r(param_1,apuStack1144), iVar2 != 0)) { + iVar1 = -1; + } + if ((uStack1132 & 0x40) != 0) { + *(ushort *)(param_2 + 0xc) = *(ushort *)(param_2 + 0xc) | 0x40; + } + return iVar1; +} + + + +undefined4 __swsetup_r(undefined4 *param_1,int *param_2) + +{ + undefined4 uVar1; + int iVar2; + ushort uVar3; + int iVar4; + + if ((_impure_ptr == (undefined *)0x0) || (*(int *)(_impure_ptr + 0x38) != 0)) { + uVar3 = *(ushort *)(param_2 + 3); + } + else { + __sinit(_impure_ptr); + uVar3 = *(ushort *)(param_2 + 3); + } + if ((uVar3 & 8) == 0) { + if ((uVar3 & 0x10) == 0) { + *param_1 = 9; + *(ushort *)(param_2 + 3) = uVar3 | 0x40; + return 0xffffffff; + } + if ((uVar3 & 4) == 0) { + iVar2 = param_2[4]; + } + else { + if ((int *)param_2[0xc] != (int *)0x0) { + if ((int *)param_2[0xc] != param_2 + 0x10) { + _free_r(param_1); + uVar3 = *(ushort *)(param_2 + 3); + } + param_2[0xc] = 0; + } + iVar2 = param_2[4]; + uVar3 = uVar3 & 0xffdb; + param_2[1] = 0; + *param_2 = iVar2; + } + *(ushort *)(param_2 + 3) = uVar3 | 8; + uVar3 = uVar3 | 8; + } + else { + iVar2 = param_2[4]; + } + if ((iVar2 == 0) && ((uVar3 & 0x280) != 0x200)) { + __smakebuf_r(param_1,param_2); + uVar3 = *(ushort *)(param_2 + 3); + iVar2 = param_2[4]; + } + if ((uVar3 & 1) == 0) { + iVar4 = 0; + if ((uVar3 & 2) == 0) { + iVar4 = param_2[5]; + } + param_2[2] = iVar4; + } + else { + param_2[2] = 0; + param_2[6] = -param_2[5]; + } + uVar1 = 0; + if (iVar2 == 0) { + uVar1 = 0; + if ((*(ushort *)(param_2 + 3) & 0x80) != 0) { + *(ushort *)(param_2 + 3) = *(ushort *)(param_2 + 3) | 0x40; + uVar1 = 0xffffffff; + } + } + return uVar1; +} + + + +int __sflush_r(int *param_1,int *param_2) + +{ + int iVar1; + int iVar2; + int iVar3; + int *piVar4; + uint uVar5; + ushort uVar6; + uint uVar7; + + uVar7 = SEXT24((short)*(ushort *)(param_2 + 3)); + if ((uVar7 & 8) != 0) { + iVar3 = param_2[4]; + if (iVar3 == 0) { + return 0; + } + iVar1 = *param_2; + *param_2 = iVar3; + iVar1 = iVar1 - iVar3; + iVar2 = 0; + if ((uVar7 & 3) == 0) { + iVar2 = param_2[5]; + } + param_2[2] = iVar2; + while( true ) { + if (iVar1 < 1) { + return 0; + } + iVar2 = (*(code *)(param_2[9] & 0xfffffffe))(param_1,param_2[7],iVar3,iVar1); + iVar1 = iVar1 - iVar2; + if (iVar2 < 1) break; + iVar3 = iVar3 + iVar2; + } + uVar6 = *(ushort *)(param_2 + 3); + iVar3 = -1; +LAB_230a679c: + *(ushort *)(param_2 + 3) = uVar6 | 0x40; + return iVar3; + } + *(ushort *)(param_2 + 3) = *(ushort *)(param_2 + 3) | 0x800; + if ((param_2[1] < 1) && (param_2[0xf] < 1)) { + return 0; + } + uVar5 = param_2[10]; + if (uVar5 == 0) { + return 0; + } + uVar7 = uVar7 & 0xffff | 0x800; + iVar1 = *param_1; + *param_1 = 0; + iVar3 = param_2[7]; + if ((int)(uVar7 << 0x13) < 0) { + iVar2 = param_2[0x14]; + } + else { + iVar2 = (*(code *)(uVar5 & 0xfffffffe))(param_1,iVar3,0,1); + if ((iVar2 == -1) && (iVar3 = *param_1, iVar3 != 0)) { + if ((iVar3 != 0x1d) && (iVar3 != 0x16)) { + *(ushort *)(param_2 + 3) = *(ushort *)(param_2 + 3) | 0x40; + return 0xffffffff; + } + *param_1 = iVar1; + return 0; + } + uVar7 = (uint)*(ushort *)(param_2 + 3); + uVar5 = param_2[10]; + iVar3 = param_2[7]; + } + if (((uVar7 & 4) != 0) && (iVar2 = iVar2 - param_2[1], param_2[0xc] != 0)) { + iVar2 = iVar2 - param_2[0xf]; + } + iVar3 = (*(code *)(uVar5 & 0xfffffffe))(param_1,iVar3,iVar2,0); + if (iVar3 == -1) { + iVar2 = *param_1; + uVar6 = *(ushort *)(param_2 + 3); + if (iVar2 != 0) { + if ((iVar2 != 0x1d) && (iVar2 != 0x16)) goto LAB_230a679c; + *(ushort *)(param_2 + 3) = uVar6 & 0xf7ff; + param_2[1] = 0; + *param_2 = param_2[4]; + goto LAB_230a66fc; + } + iVar2 = param_2[4]; + uVar7 = (int)(short)uVar6 & 0xfffff7ff; + } + else { + iVar2 = param_2[4]; + uVar7 = SEXT24((short)(*(ushort *)(param_2 + 3) & 0xf7ff)); + } + *(short *)(param_2 + 3) = (short)uVar7; + param_2[1] = 0; + *param_2 = iVar2; + if ((int)(uVar7 << 0x13) < 0) { + param_2[0x14] = iVar3; + } +LAB_230a66fc: + piVar4 = (int *)param_2[0xc]; + *param_1 = iVar1; + if (piVar4 != (int *)0x0) { + if (piVar4 != param_2 + 0x10) { + _free_r(param_1); + } + param_2[0xc] = 0; + } + return 0; +} + + + +undefined4 _fflush_r(int param_1,int param_2) + +{ + short sVar1; + undefined4 uVar2; + + if ((param_1 == 0) || (*(int *)(param_1 + 0x38) != 0)) { + sVar1 = *(short *)(param_2 + 0xc); + } + else { + __sinit(); + sVar1 = *(short *)(param_2 + 0xc); + } + if (sVar1 == 0) { + return 0; + } + uVar2 = __sflush_r(param_1); + return uVar2; +} + + + +int fflush(FILE *__stream) + +{ + int iVar1; + + if (__stream != (FILE *)0x0) { + iVar1 = _fflush_r(_impure_ptr,__stream); + return iVar1; + } + iVar1 = _fwalk_reent(_global_impure_ptr,_fflush_r); + return iVar1; +} + + + +undefined4 __fp_lock(void) + +{ + return 0; +} + + + +void _cleanup_r(void) + +{ + _fwalk_reent(_fclose_r); + return; +} + + + +void __sinit_part_0(int param_1) + +{ + undefined4 *puVar1; + undefined4 *puVar2; + + puVar1 = *(undefined4 **)(param_1 + 4); + *(undefined4 *)(param_1 + 0x3c) = 0x230a68ec; + *(undefined4 *)(param_1 + 0x2e4) = 3; + *(int *)(param_1 + 0x2e8) = param_1 + 0x2ec; + *(undefined4 *)(param_1 + 0x2e0) = 0; + puVar1[3] = 4; + puVar1[0x19] = 0; + *puVar1 = 0; + puVar1[1] = 0; + puVar1[2] = 0; + puVar1[4] = 0; + puVar1[5] = 0; + puVar1[6] = 0; + memset(puVar1 + 0x17,0,8); + puVar2 = *(undefined4 **)(param_1 + 8); + puVar1[8] = 0x230a8ac4; + puVar1[9] = 0x230a8b28; + puVar1[10] = 0x230a8bb0; + puVar1[0xb] = 0x230a8c18; + *(undefined4 **)(puVar1 + 7) = puVar1; + puVar2[3] = 0x10009; + puVar2[0x19] = 0; + *puVar2 = 0; + puVar2[1] = 0; + puVar2[2] = 0; + puVar2[4] = 0; + puVar2[5] = 0; + puVar2[6] = 0; + memset(puVar2 + 0x17,0,8); + puVar1 = *(undefined4 **)(param_1 + 0xc); + puVar2[8] = 0x230a8ac4; + puVar2[9] = 0x230a8b28; + puVar2[10] = 0x230a8bb0; + puVar2[0xb] = 0x230a8c18; + *(undefined4 **)(puVar2 + 7) = puVar2; + puVar1[3] = 0x20012; + puVar1[0x19] = 0; + *puVar1 = 0; + puVar1[1] = 0; + puVar1[2] = 0; + puVar1[4] = 0; + puVar1[5] = 0; + puVar1[6] = 0; + memset(puVar1 + 0x17,0,8); + puVar1[8] = 0x230a8ac4; + puVar1[9] = 0x230a8b28; + puVar1[10] = 0x230a8bb0; + puVar1[0xb] = 0x230a8c18; + *(undefined4 **)(puVar1 + 7) = puVar1; + *(undefined4 *)(param_1 + 0x38) = 1; + return; +} + + + +undefined4 __fp_unlock(void) + +{ + return 0; +} + + + +undefined4 * __sfmoreglue(int param_1) + +{ + int iVar1; + undefined4 *puVar2; + + iVar1 = (param_1 + -1) * 0x68; + puVar2 = (undefined4 *)_malloc_r(iVar1 + 0x74); + if (puVar2 != (undefined4 *)0x0) { + *puVar2 = 0; + puVar2[1] = param_1; + *(undefined4 **)(puVar2 + 2) = puVar2 + 3; + memset(puVar2 + 3,0,iVar1 + 0x68); + } + return puVar2; +} + + + +undefined4 * __sfp(undefined4 *param_1) + +{ + undefined *puVar1; + undefined4 *puVar2; + int iVar3; + undefined4 *puVar4; + + puVar1 = _global_impure_ptr; + if (*(int *)(_global_impure_ptr + 0x38) == 0) { + __sinit_part_0(_global_impure_ptr); + } + puVar2 = (undefined4 *)(puVar1 + 0x2e0); + do { + do { + puVar4 = puVar2; + puVar2 = (undefined4 *)puVar4[2]; + iVar3 = puVar4[1] + -1; + if (-1 < iVar3) { + do { + if (*(short *)(puVar2 + 3) == 0) { + puVar2[0x19] = 0; + *puVar2 = 0; + puVar2[1] = 0; + puVar2[2] = 0; + puVar2[3] = 0xffff0001; + puVar2[4] = 0; + puVar2[5] = 0; + puVar2[6] = 0; + memset(puVar2 + 0x17,0,8); + puVar2[0xc] = 0; + puVar2[0xd] = 0; + puVar2[0x11] = 0; + puVar2[0x12] = 0; + return puVar2; + } + iVar3 = iVar3 + -1; + puVar2 = puVar2 + 0x1a; + } while (iVar3 != -1); + } + puVar2 = (undefined4 *)*puVar4; + } while ((undefined4 *)*puVar4 != (undefined4 *)0x0); + puVar2 = (undefined4 *)__sfmoreglue(param_1,4); + *(undefined4 **)puVar4 = puVar2; + } while (puVar2 != (undefined4 *)0x0); + *param_1 = 0xc; + return (undefined4 *)0; +} + + + +void _cleanup(void) + +{ + _fwalk_reent(_global_impure_ptr,_fclose_r); + return; +} + + + +void __sinit(int param_1) + +{ + if (*(int *)(param_1 + 0x38) != 0) { + return; + } + __sinit_part_0(); + return; +} + + + +void __sfp_lock_acquire(void) + +{ + return; +} + + + +void __sfp_lock_release(void) + +{ + return; +} + + + +void __sinit_lock_acquire(void) + +{ + return; +} + + + +void __sinit_lock_release(void) + +{ + return; +} + + + +void __fp_lock_all(void) + +{ + _fwalk(_impure_ptr,__fp_lock); + return; +} + + + +void __fp_unlock_all(void) + +{ + _fwalk(_impure_ptr,__fp_unlock); + return; +} + + + +uint __fputwc(undefined4 param_1,uint param_2,int *param_3) + +{ + uint uVar1; + int iVar2; + uint uVar3; + undefined *puVar4; + uint uVar5; + byte bStack36; + byte local_23 [3]; + + iVar2 = __locale_mb_cur_max(); + if ((iVar2 == 1) && (param_2 - 1 < 0xff)) { + uVar3 = param_2 & 0xff; + bStack36 = (byte)uVar3; + uVar5 = 1; +LAB_230a6ce0: + uVar1 = 0; + while( true ) { + iVar2 = param_3[2] + -1; + param_3[2] = iVar2; + if ((iVar2 < 0) && ((iVar2 < param_3[6] || (uVar3 == 10)))) { + iVar2 = __swbuf_r(param_1,param_3); + if (iVar2 == -1) { + return 0xffffffff; + } + } + else { + puVar4 = (undefined *)*param_3; + *(undefined **)param_3 = puVar4 + 1; + *puVar4 = (char)uVar3; + } + if (uVar5 <= uVar1 + 1) break; + uVar3 = (uint)local_23[uVar1]; + uVar1 = uVar1 + 1; + } + return param_2; + } + uVar5 = _wcrtomb_r(param_1,&bStack36,param_2,param_3 + 0x17); + if (uVar5 == 0xffffffff) { + *(ushort *)(param_3 + 3) = *(ushort *)(param_3 + 3) | 0x40; + param_2 = uVar5; + } + else { + if (uVar5 != 0) { + uVar3 = (uint)bStack36; + goto LAB_230a6ce0; + } + } + return param_2; +} + + + +void _fputwc_r(int param_1) + +{ + if (-1 < (int)(short)*(ushort *)(param_1 + 0xc) << 0x12) { + *(ushort *)(param_1 + 0xc) = *(ushort *)(param_1 + 0xc) | 0x2000; + *(uint *)(param_1 + 100) = *(uint *)(param_1 + 100) | 0x2000; + } + __fputwc(); + return; +} + + + +wint_t fputwc(wchar_t __wc,__FILE *__stream) + +{ + undefined *puVar1; + undefined2 in_register_0000202a; + wint_t wVar2; + + puVar1 = _impure_ptr; + if ((_impure_ptr != (undefined *)0x0) && (*(int *)(_impure_ptr + 0x38) == 0)) { + __sinit(_impure_ptr); + } + if (-1 < (int)(short)*(ushort *)&__stream->_IO_read_base << 0x12) { + *(ushort *)&__stream->_IO_read_base = *(ushort *)&__stream->_IO_read_base | 0x2000; + __stream->__pad5 = __stream->__pad5 | 0x2000; + } + wVar2 = __fputwc(puVar1,CONCAT22(in_register_0000202a,__wc)); + return wVar2; +} + + + +undefined4 _malloc_trim_r(undefined4 param_1,int param_2) + +{ + int iVar1; + uint uVar2; + int iVar3; + + __malloc_lock(); + uVar2 = *(uint *)(__malloc_av_._8_4_ + 4) & 0xfffffffc; + iVar1 = ((0xfef - param_2) + uVar2 >> 0xc) - 1; + if (0xfff < iVar1 * 0x1000) { + iVar3 = _sbrk_r(param_1,0); + if (iVar3 == __malloc_av_._8_4_ + uVar2) { + iVar3 = _sbrk_r(param_1,iVar1 * -0x1000); + if (iVar3 != -1) { + __malloc_current_mallinfo._0_4_ = __malloc_current_mallinfo._0_4_ + iVar1 * -0x1000; + *(uint *)(__malloc_av_._8_4_ + 4) = uVar2 + iVar1 * -0x1000 | 1; + __malloc_unlock(param_1); + return 1; + } + iVar3 = _sbrk_r(param_1,0); + iVar1 = __malloc_sbrk_base; + if (0xf < iVar3 - __malloc_av_._8_4_) { + *(uint *)(__malloc_av_._8_4_ + 4) = iVar3 - __malloc_av_._8_4_ | 1; + __malloc_current_mallinfo._0_4_ = iVar3 - iVar1; + } + } + } + __malloc_unlock(param_1); + return 0; +} + + + +void _free_r(undefined4 param_1,int param_2) + +{ + uint uVar1; + uint uVar2; + uint *puVar3; + int iVar4; + uint uVar5; + int iVar6; + uint *puVar7; + uint uVar8; + uint uVar9; + + if (param_2 == 0) { + return; + } + __malloc_lock(); + uVar2 = *(uint *)(param_2 + -4); + puVar7 = (uint *)(param_2 + -8); + uVar8 = uVar2 & 0xfffffffe; + puVar3 = (uint *)((int)puVar7 + uVar8); + uVar5 = puVar3[1] & 0xfffffffc; + if (__malloc_av_._8_4_ == puVar3) { + uVar8 = uVar8 + uVar5; + if ((uVar2 & 1) == 0) { + puVar7 = (uint *)((int)puVar7 - *(int *)(param_2 + -8)); + uVar5 = puVar7[3]; + uVar2 = puVar7[2]; + uVar8 = uVar8 + *(int *)(param_2 + -8); + *(uint *)(uVar2 + 0xc) = uVar5; + *(uint *)(uVar5 + 8) = uVar2; + } + uVar2 = __malloc_trim_threshold; + puVar7[1] = uVar8 | 1; + __malloc_av_._8_4_ = puVar7; + if (uVar2 <= uVar8) { + _malloc_trim_r(param_1,__malloc_top_pad); + } + goto LAB_230a7060; + } + puVar3[1] = uVar5; + if ((uVar2 & 1) == 0) { + puVar7 = (uint *)((int)puVar7 - *(int *)(param_2 + -8)); + uVar9 = puVar7[2]; + uVar8 = uVar8 + *(int *)(param_2 + -8); + uVar2 = *(uint *)((int)puVar3 + uVar5 + 4) & 1; + if (uVar9 == 0x4200e6ec) { + if (uVar2 == 0) { + uVar2 = puVar3[2]; + uVar9 = puVar3[3]; + uVar5 = uVar5 + uVar8; + *(uint *)(uVar2 + 0xc) = uVar9; + *(uint *)(uVar9 + 8) = uVar2; + puVar7[1] = uVar5 | 1; + *(uint *)((int)puVar7 + uVar5) = uVar5; + } + else { + puVar7[1] = uVar8 | 1; + *puVar3 = uVar8; + } + goto LAB_230a7060; + } + uVar1 = puVar7[3]; + *(uint *)(uVar9 + 0xc) = uVar1; + *(uint *)(uVar1 + 8) = uVar9; + if (uVar2 == 0) goto LAB_230a7090; + puVar7[1] = uVar8 | 1; + *puVar3 = uVar8; + } + else { + if ((*(uint *)((int)puVar3 + uVar5 + 4) & 1) == 0) { +LAB_230a7090: + uVar8 = uVar8 + uVar5; + uVar2 = puVar3[2]; + if (uVar2 == 0x4200e6ec) { + __malloc_av_._16_4_ = puVar7; + __malloc_av_._20_4_ = puVar7; + puVar7[3] = 0x4200e6ec; + puVar7[2] = 0x4200e6ec; + puVar7[1] = uVar8 | 1; + *(uint *)((int)puVar7 + uVar8) = uVar8; + goto LAB_230a7060; + } + uVar5 = puVar3[3]; + *(uint *)(uVar2 + 0xc) = uVar5; + *(uint *)(uVar5 + 8) = uVar2; + puVar7[1] = uVar8 | 1; + *(uint *)((int)puVar7 + uVar8) = uVar8; + } + else { + *(uint *)(param_2 + -4) = uVar8 | 1; + *puVar3 = uVar8; + } + } + if (0x1ff < uVar8) { + uVar2 = uVar8 >> 9; + if (uVar2 < 5) { + iVar4 = (uVar8 >> 6) + 0x38; + iVar6 = ((uVar8 >> 6) + 0x39) * 8; + } + else { + if (uVar2 < 0x15) { + iVar4 = uVar2 + 0x5b; + iVar6 = (uVar2 + 0x5c) * 8; + } + else { + if (uVar2 < 0x55) { + iVar4 = (uVar8 >> 0xc) + 0x6e; + iVar6 = ((uVar8 >> 0xc) + 0x6f) * 8; + } + else { + if (uVar2 < 0x155) { + iVar4 = (uVar8 >> 0xf) + 0x77; + iVar6 = ((uVar8 >> 0xf) + 0x78) * 8; + } + else { + if (uVar2 < 0x555) { + iVar4 = (uVar8 >> 0x12) + 0x7c; + iVar6 = ((uVar8 >> 0x12) + 0x7d) * 8; + } + else { + iVar6 = 0x3f8; + iVar4 = 0x7e; + } + } + } + } + } + uVar5 = *(uint *)(__malloc_av_ + iVar6); + uVar2 = iVar6 + 0x4200e6dc; + if (uVar2 == uVar5) { + __malloc_av_._4_4_ = 1 << (iVar4 >> 2 & 0x1fU) | __malloc_av_._4_4_; + } + else { + do { + if ((*(uint *)(uVar5 + 4) & 0xfffffffc) <= uVar8) break; + uVar5 = *(uint *)(uVar5 + 8); + } while (uVar2 != uVar5); + uVar2 = *(uint *)(uVar5 + 0xc); + } + puVar7[3] = uVar2; + puVar7[2] = uVar5; + *(uint **)(uVar2 + 8) = puVar7; + *(uint **)(uVar5 + 0xc) = puVar7; + __malloc_unlock(param_1); + return; + } + iVar6 = ((uVar8 >> 3) + 1) * 8; + puVar3 = *(uint **)(__malloc_av_ + iVar6); + __malloc_av_._4_4_ = 1 << ((int)(uVar8 >> 3) >> 2 & 0x1fU) | __malloc_av_._4_4_; + puVar7[3] = iVar6 + 0x4200e6dc; + *(uint **)(puVar7 + 2) = puVar3; + *(uint **)(__malloc_av_ + iVar6) = puVar7; + *(uint **)(puVar3 + 3) = puVar7; +LAB_230a7060: + __malloc_unlock(param_1); + return; +} + + + +undefined4 __sfvwrite_r(undefined4 *param_1,void **param_2,int **param_3) + +{ + void **ppvVar1; + int iVar2; + void *__dest; + ushort uVar3; + void *__s; + int *piVar4; + void *__src; + void *__dest_00; + void *__dest_01; + void *__n; + + if (param_3[2] == (int *)0x0) { + return 0; + } + uVar3 = *(ushort *)(param_2 + 3); + if (((uVar3 & 8) == 0) || (param_2[4] == (void *)0x0)) { + iVar2 = __swsetup_r(param_1,param_2); + if (iVar2 != 0) { + return 0xffffffff; + } + uVar3 = *(ushort *)(param_2 + 3); + ppvVar1 = (void **)*param_3; + } + else { + ppvVar1 = (void **)*param_3; + } + if ((uVar3 & 2) == 0) { + if ((uVar3 & 1) == 0) { + __n = param_2[2]; + __dest = *param_2; + __src = (void *)0x0; + __s = (void *)0x0; +joined_r0x230a73c4: + while (__s == (void *)0x0) { + __src = *ppvVar1; + __s = ppvVar1[1]; + ppvVar1 = ppvVar1 + 2; + } + if ((uVar3 & 0x200) == 0) { + if ((param_2[4] < __dest) || (__dest_00 = param_2[5], __s < __dest_00)) { + if (__s < __n) { + __n = __s; + } + memmove(__dest,__src,(size_t)__n); + __dest = param_2[2]; + param_2[2] = (void *)((int)__dest - (int)__n); + *param_2 = (void *)((int)*param_2 + (int)__n); + if ((void *)((int)__dest - (int)__n) == (void *)0x0) { + iVar2 = _fflush_r(param_1,param_2); + if (iVar2 == 0) { + __dest_00 = (void *)((int)__s - (int)__n); + goto LAB_230a749c; + } + goto LAB_230a75d0; + } + } + else { + __dest = __s; + if ((void *)0x7ffffffe < __s) { + __dest = (void *)0x7fffffff; + } + __n = (void *)(*(code *)((uint)param_2[9] & 0xfffffffe)) + (param_1,param_2[7],__src, + ((int)__dest / (int)__dest_00) * (int)__dest_00); + if ((int)__n < 1) goto LAB_230a75d0; + } + __dest_00 = (void *)((int)__s - (int)__n); + } + else { + __dest_00 = __s; + if ((__n <= __s) && (__dest_00 = __n, (uVar3 & 0x480) != 0)) { + __dest_00 = (void *)((int)__dest - (int)param_2[4]); + __n = (void *)(((int)param_2[5] * 3) / 2); + __dest = (void *)((int)__s + 1 + (int)__dest_00); + if (__n < __dest) { + __n = __dest; + } + if ((uVar3 & 0x400) == 0) { + __dest_01 = (void *)_realloc_r(param_1,__n); + if (__dest_01 == (void *)0x0) { + _free_r(param_1,param_2[4]); + uVar3 = *(ushort *)(param_2 + 3); + *param_1 = 0xc; + uVar3 = uVar3 & 0xff7f; + goto LAB_230a75d4; + } + } + else { + __dest_01 = (void *)_malloc_r(param_1,__n); + if (__dest_01 == (void *)0x0) { + *param_1 = 0xc; + uVar3 = *(ushort *)(param_2 + 3); + goto LAB_230a75d4; + } + memcpy(__dest_01,param_2[4],(size_t)__dest_00); + *(ushort *)(param_2 + 3) = *(ushort *)(param_2 + 3) & 0xfb7f | 0x80; + } + __dest = (void *)((int)__dest_01 + (int)__dest_00); + param_2[4] = __dest_01; + *param_2 = __dest; + param_2[5] = __n; + param_2[2] = (void *)((int)__n - (int)__dest_00); + __dest_00 = __s; + } + memmove(__dest,__src,(size_t)__dest_00); + param_2[2] = (void *)((int)param_2[2] - (int)__dest_00); + *param_2 = (void *)((int)*param_2 + (int)__dest_00); + __dest_00 = (void *)0x0; + __n = __s; + } +LAB_230a749c: + piVar4 = param_3[2]; + __src = (void *)((int)__src + (int)__n); + param_3[2] = (int *)((int)piVar4 - (int)__n); + if ((int *)((int)piVar4 - (int)__n) != (int *)0x0) { + __n = param_2[2]; + __dest = *param_2; + uVar3 = *(ushort *)(param_2 + 3); + __s = __dest_00; + goto joined_r0x230a73c4; + } + } + else { + __src = (void *)0x0; + iVar2 = 0; + __s = (void *)0x0; + __dest = (void *)0x0; + do { + if (__dest == (void *)0x0) { + do { + __dest = ppvVar1[1]; + __s = *ppvVar1; + ppvVar1 = ppvVar1 + 2; + } while (__dest == (void *)0x0); + __src = memchr(__s,10,(size_t)__dest); +joined_r0x230a74f0: + if (__src == (void *)0x0) { + __src = (void *)((int)__dest + 1); + } + else { + __src = (void *)((int)__src + (1 - (int)__s)); + } + } + else { + if (iVar2 == 0) { + __src = memchr(__s,10,(size_t)__dest); + goto joined_r0x230a74f0; + } + } + __n = __dest; + if (__src < __dest) { + __n = __src; + } + __dest_00 = *param_2; + if ((param_2[4] < __dest_00) && + (__dest_01 = (void *)((int)param_2[5] + (int)param_2[2]), (int)__dest_01 < (int)__n)) { + memmove(__dest_00,__s,(size_t)__dest_01); + *param_2 = (void *)((int)*param_2 + (int)__dest_01); + iVar2 = _fflush_r(param_1,param_2); + if (iVar2 != 0) { +LAB_230a75d0: + uVar3 = *(ushort *)(param_2 + 3); +LAB_230a75d4: + *(ushort *)(param_2 + 3) = uVar3 | 0x40; + return 0xffffffff; + } + } + else { + if ((int)__n < (int)param_2[5]) { + memmove(__dest_00,__s,(size_t)__n); + param_2[2] = (void *)((int)param_2[2] - (int)__n); + *param_2 = (void *)((int)*param_2 + (int)__n); + __dest_01 = __n; + } + else { + __dest_01 = (void *)(*(code *)((uint)param_2[9] & 0xfffffffe))(param_1,param_2[7],__s); + if ((int)__dest_01 < 1) goto LAB_230a75d0; + } + } + __src = (void *)((int)__src - (int)__dest_01); + iVar2 = 1; + if ((__src == (void *)0x0) && (iVar2 = _fflush_r(param_1,param_2), iVar2 != 0)) + goto LAB_230a75d0; + piVar4 = param_3[2]; + __s = (void *)((int)__s + (int)__dest_01); + __dest = (void *)((int)__dest - (int)__dest_01); + param_3[2] = (int *)((int)piVar4 - (int)__dest_01); + } while ((int *)((int)piVar4 - (int)__dest_01) != (int *)0x0); + } + } + else { + __dest = param_2[9]; + __s = param_2[7]; + __n = (void *)0x0; + __src = (void *)0x0; + while( true ) { + while (__src == (void *)0x0) { + __n = *ppvVar1; + __src = ppvVar1[1]; + ppvVar1 = ppvVar1 + 2; + } + __dest_00 = __src; + if ((void *)0x7ffffc00 < __src) { + __dest_00 = (void *)0x7ffffc00; + } + iVar2 = (*(code *)((uint)__dest & 0xfffffffe))(param_1,__s,__n,__dest_00); + if (iVar2 < 1) goto LAB_230a75d0; + piVar4 = param_3[2]; + __n = (void *)((int)__n + iVar2); + __src = (void *)((int)__src - iVar2); + param_3[2] = (int *)((int)piVar4 - iVar2); + if ((int *)((int)piVar4 - iVar2) == (int *)0x0) break; + __s = param_2[7]; + __dest = param_2[9]; + } + } + return 0; +} + + + +uint _fwalk(int param_1,uint param_2) + +{ + int iVar1; + int iVar2; + uint uVar3; + uint uVar4; + int *piVar5; + + piVar5 = (int *)(param_1 + 0x2e0); + if (piVar5 == (int *)0x0) { + uVar4 = 0; + } + else { + uVar4 = 0; + do { + iVar1 = piVar5[2]; + iVar2 = piVar5[1] + -1; + if (-1 < iVar2) { + do { + iVar2 = iVar2 + -1; + if ((1 < *(ushort *)(iVar1 + 0xc)) && (*(short *)(iVar1 + 0xe) != -1)) { + uVar3 = (*(code *)(param_2 & 0xfffffffe))(iVar1); + uVar4 = uVar4 | uVar3; + } + iVar1 = iVar1 + 0x68; + } while (iVar2 != -1); + } + piVar5 = (int *)*piVar5; + } while (piVar5 != (int *)0x0); + } + return uVar4; +} + + + +uint _fwalk_reent(int param_1,uint param_2) + +{ + int iVar1; + int iVar2; + uint uVar3; + uint uVar4; + int *piVar5; + + piVar5 = (int *)(param_1 + 0x2e0); + if (piVar5 == (int *)0x0) { + uVar4 = 0; + } + else { + uVar4 = 0; + do { + iVar1 = piVar5[2]; + iVar2 = piVar5[1] + -1; + if (-1 < iVar2) { + do { + iVar2 = iVar2 + -1; + if ((1 < *(ushort *)(iVar1 + 0xc)) && (*(short *)(iVar1 + 0xe) != -1)) { + uVar3 = (*(code *)(param_2 & 0xfffffffe))(param_1); + uVar4 = uVar4 | uVar3; + } + iVar1 = iVar1 + 0x68; + } while (iVar2 != -1); + } + piVar5 = (int *)*piVar5; + } while (piVar5 != (int *)0x0); + } + return uVar4; +} + + + +int __localeconv_l(int param_1) + +{ + return param_1 + 0xf0; +} + + + +undefined4 _localeconv_r(void) + +{ + return 0x4200e668; +} + + + +// WARNING: Unknown calling convention yet parameter storage is locked + +lconv * localeconv(void) + +{ + return (lconv *)(__global_locale + 0xf0); +} + + + +undefined * _setlocale_r(char *param_1) + +{ + int iVar1; + undefined *puVar2; + + if (param_1 != (char *)0x0) { + iVar1 = strcmp(param_1,"POSIX"); + if (((iVar1 == 0) || (iVar1 = strcmp(param_1,"C"), iVar1 == 0)) || + (iVar1 = strcmp(param_1,""), iVar1 == 0)) { + puVar2 = &DAT_230c9578; + } + else { + puVar2 = (undefined *)0x0; + } + return puVar2; + } + return &DAT_230c9578; +} + + + +uint __locale_mb_cur_max(void) + +{ + return (uint)__global_locale[296]; +} + + + +char * setlocale(int __category,char *__locale) + +{ + char *pcVar1; + + pcVar1 = (char *)_setlocale_r(_impure_ptr,__category,__locale); + return pcVar1; +} + + + +undefined4 __swhatbuf_r(int param_1,undefined4 *param_2,uint *param_3) + +{ + ushort uVar1; + int iVar2; + undefined auStack104 [4]; + uint uStack100; + + if ((-1 < *(short *)(param_1 + 0xe)) && (iVar2 = _fstat_r(auStack104), -1 < iVar2)) { + *param_3 = (uint)((uStack100 & 0xf000) == 0x2000); + *param_2 = 0x400; + return 0x800; + } + uVar1 = *(ushort *)(param_1 + 0xc); + *param_3 = 0; + if ((uVar1 & 0x80) != 0) { + *param_2 = 0x40; + return 0; + } + *param_2 = 0x400; + return 0; +} + + + +void __smakebuf_r(int param_1,int *param_2) + +{ + ushort uVar1; + int iVar2; + ushort uVar3; + int iStack24; + int iStack20; + + if ((*(ushort *)(param_2 + 3) & 2) == 0) { + uVar1 = __swhatbuf_r(&iStack24,&iStack20); + iVar2 = _malloc_r(param_1,iStack24); + uVar3 = *(ushort *)(param_2 + 3); + if (iVar2 != 0) { + *(undefined4 *)(param_1 + 0x3c) = 0x230a68ec; + uVar3 = uVar3 | 0x80; + *(ushort *)(param_2 + 3) = uVar3; + *param_2 = iVar2; + param_2[4] = iVar2; + param_2[5] = iStack24; + if (iStack20 != 0) { + iVar2 = _isatty_r(param_1,(int)*(short *)((int)param_2 + 0xe)); + if (iVar2 == 0) { + uVar3 = *(ushort *)(param_2 + 3); + } + else { + uVar3 = *(ushort *)(param_2 + 3) & 0xfffc | 1; + } + } + *(ushort *)(param_2 + 3) = uVar3 | uVar1; + return; + } + if ((uVar3 & 0x200) == 0) { + *(ushort *)(param_2 + 3) = uVar3 & 0xfffc | 2; + *param_2 = (int)param_2 + 0x43; + param_2[4] = (int)param_2 + 0x43; + param_2[5] = 1; + } + } + else { + *param_2 = (int)param_2 + 0x43; + param_2[4] = (int)param_2 + 0x43; + param_2[5] = 1; + } + return; +} + + + +undefined4 * _malloc_r(undefined4 *param_1,uint param_2) + +{ + undefined1 *puVar1; + undefined4 *puVar2; + undefined1 *puVar3; + uint uVar4; + uint uVar5; + undefined4 *puVar6; + int iVar7; + uint uVar8; + int iVar9; + uint uVar10; + int iVar11; + uint uVar12; + uint uVar13; + undefined1 *puVar14; + int iVar15; + undefined4 *puVar16; + undefined1 *puVar17; + undefined1 *puVar18; + undefined1 *puVar19; + + uVar4 = param_2 + 0xb; + if (uVar4 < 0x17) { + if (0x10 < param_2) { +LAB_230a7de8: + *param_1 = 0xc; + return (undefined4 *)0; + } + __malloc_lock(); + uVar5 = 0x10; + iVar9 = 0x18; + uVar4 = 2; +LAB_230a7bc4: + puVar1 = *(undefined1 **)(__malloc_av_ + iVar9 + 4); + if (puVar1 != (undefined1 *)(iVar9 + 0x4200e6dc)) { +LAB_230a7bdc: + iVar7 = *(int *)(puVar1 + 0xc); + iVar9 = *(int *)(puVar1 + 8); + uVar10 = *(uint *)(puVar1 + 4) & 0xfffffffc; +LAB_230a7bec: + uVar4 = *(uint *)(puVar1 + uVar10 + 4); + *(int *)(iVar9 + 0xc) = iVar7; + *(int *)(iVar7 + 8) = iVar9; + *(uint *)(puVar1 + uVar10 + 4) = uVar4 | 1; + __malloc_unlock(param_1); + return (undefined4 *)(puVar1 + 8); + } + puVar1 = *(undefined1 **)(__malloc_av_ + iVar9 + 0xc); + uVar4 = uVar4 + 2; + if (__malloc_av_ + iVar9 != puVar1) goto LAB_230a7bdc; + iVar9 = __malloc_av_._16_4_; + if (__malloc_av_._16_4_ == 0x4200e6ec) goto LAB_230a7e54; +LAB_230a7ca8: + uVar13 = *(uint *)(iVar9 + 4); + uVar8 = uVar13 & 0xfffffffc; + uVar10 = uVar8 - uVar5; + if (0xf < (int)uVar10) { + *(uint *)(iVar9 + 4) = uVar5 | 1; + iVar7 = iVar9 + uVar5; + __malloc_av_._16_4_ = iVar7; + __malloc_av_._20_4_ = iVar7; + *(undefined4 *)(iVar7 + 0xc) = 0x4200e6ec; + *(undefined4 *)(iVar7 + 8) = 0x4200e6ec; + *(uint *)(iVar7 + 4) = uVar10 | 1; + *(uint *)(iVar9 + uVar8) = uVar10; + __malloc_unlock(param_1); + return (undefined4 *)(iVar9 + 8); + } + __malloc_av_._20_4_ = 0x4200e6ec; + __malloc_av_._16_4_ = 0x4200e6ec; + if (-1 < (int)uVar10) { + *(uint *)(iVar9 + uVar8 + 4) = *(uint *)(iVar9 + uVar8 + 4) | 1; + __malloc_unlock(param_1); + return (undefined4 *)(iVar9 + 8); + } + if (uVar8 < 0x200) { + iVar11 = ((uVar13 >> 3) + 1) * 8; + iVar7 = *(int *)(__malloc_av_ + iVar11); + uVar13 = 1 << ((int)(uVar13 >> 3) >> 2 & 0x1fU) | __malloc_av_._4_4_; + *(int *)(iVar9 + 0xc) = iVar11 + 0x4200e6dc; + *(int *)(iVar9 + 8) = iVar7; + __malloc_av_._4_4_ = uVar13; + *(int *)(__malloc_av_ + iVar11) = iVar9; + *(int *)(iVar7 + 0xc) = iVar9; + } + else { + uVar10 = uVar13 >> 9; + if (uVar10 < 5) { + iVar11 = (uVar13 >> 6) + 0x38; + iVar7 = ((uVar13 >> 6) + 0x39) * 8; + } + else { + if (uVar10 < 0x15) { + iVar11 = uVar10 + 0x5b; + iVar7 = (uVar10 + 0x5c) * 8; + } + else { + if (uVar10 < 0x55) { + iVar11 = (uVar13 >> 0xc) + 0x6e; + iVar7 = ((uVar13 >> 0xc) + 0x6f) * 8; + } + else { + if (uVar10 < 0x155) { + iVar11 = (uVar13 >> 0xf) + 0x77; + iVar7 = ((uVar13 >> 0xf) + 0x78) * 8; + } + else { + if (uVar10 < 0x555) { + iVar11 = (uVar13 >> 0x12) + 0x7c; + iVar7 = ((uVar13 >> 0x12) + 0x7d) * 8; + } + else { + iVar7 = 0x3f8; + iVar11 = 0x7e; + } + } + } + } + } + iVar15 = *(int *)(__malloc_av_ + iVar7); + iVar7 = iVar7 + 0x4200e6dc; + if (iVar7 == iVar15) { + __malloc_av_._4_4_ = 1 << (iVar11 >> 2 & 0x1fU) | __malloc_av_._4_4_; + } + else { + do { + if ((*(uint *)(iVar15 + 4) & 0xfffffffc) <= uVar8) break; + iVar15 = *(int *)(iVar15 + 8); + } while (iVar7 != iVar15); + iVar7 = *(int *)(iVar15 + 0xc); + } + uVar13 = __malloc_av_._4_4_; + *(int *)(iVar9 + 0xc) = iVar7; + *(int *)(iVar9 + 8) = iVar15; + *(int *)(iVar7 + 8) = iVar9; + *(int *)(iVar15 + 0xc) = iVar9; + } + uVar8 = 1 << ((int)uVar4 >> 2 & 0x1fU); + if (uVar8 <= uVar13) goto LAB_230a7d2c; + } + else { + uVar5 = uVar4 & 0xfffffff8; + if (((int)uVar5 < 0) || (uVar5 < param_2)) goto LAB_230a7de8; + __malloc_lock(); + if (uVar5 < 0x1f8) { + uVar4 = uVar4 >> 3; + iVar9 = uVar5 + 8; + goto LAB_230a7bc4; + } + uVar13 = uVar4 >> 9; + if (uVar13 == 0) { + iVar9 = 0x200; + uVar8 = 0x40; + uVar13 = 0x3f; + } + else { + if (uVar13 < 5) { + uVar8 = (uVar4 >> 6) + 0x39; + uVar13 = (uVar4 >> 6) + 0x38; + iVar9 = uVar8 * 8; + } + else { + if (uVar13 < 0x15) { + uVar8 = uVar13 + 0x5c; + uVar13 = uVar13 + 0x5b; + iVar9 = uVar8 * 8; + } + else { + if (uVar13 < 0x55) { + uVar8 = (uVar4 >> 0xc) + 0x6f; + uVar13 = (uVar4 >> 0xc) + 0x6e; + iVar9 = uVar8 * 8; + } + else { + if (uVar13 < 0x155) { + uVar8 = (uVar4 >> 0xf) + 0x78; + uVar13 = (uVar4 >> 0xf) + 0x77; + iVar9 = uVar8 * 8; + } + else { + if (uVar13 < 0x555) { + uVar8 = (uVar4 >> 0x12) + 0x7d; + uVar13 = (uVar4 >> 0x12) + 0x7c; + iVar9 = uVar8 * 8; + } + else { + iVar9 = 0x3f8; + uVar8 = 0x7f; + uVar13 = 0x7e; + } + } + } + } + } + } + puVar1 = *(undefined1 **)(__malloc_av_ + iVar9 + 4); + uVar4 = uVar8; + if ((undefined1 *)(iVar9 + 0x4200e6dc) != puVar1) { + uVar10 = *(uint *)(puVar1 + 4) & 0xfffffffc; + iVar7 = uVar10 - uVar5; + while (uVar4 = uVar13, iVar7 < 0x10) { + if (-1 < iVar7) { + iVar7 = *(int *)(puVar1 + 0xc); + iVar9 = *(int *)(puVar1 + 8); + goto LAB_230a7bec; + } + puVar1 = *(undefined1 **)(puVar1 + 0xc); + uVar4 = uVar8; + if ((undefined1 *)(iVar9 + 0x4200e6dc) == puVar1) break; + uVar10 = *(uint *)(puVar1 + 4) & 0xfffffffc; + iVar7 = uVar10 - uVar5; + } + } + iVar9 = __malloc_av_._16_4_; + if (__malloc_av_._16_4_ != 0x4200e6ec) goto LAB_230a7ca8; +LAB_230a7e54: + uVar8 = 1 << ((int)uVar4 >> 2 & 0x1fU); + uVar13 = __malloc_av_._4_4_; + if (uVar8 <= __malloc_av_._4_4_) { +LAB_230a7d2c: + if ((uVar8 & uVar13) == 0) { + uVar4 = uVar4 & 0xfffffffc; + do { + uVar8 = uVar8 << 1; + uVar4 = uVar4 + 4; + } while ((uVar8 & uVar13) == 0); + } + do { + puVar16 = (undefined4 *)(__malloc_av_ + uVar4 * 8); + uVar13 = uVar4; + puVar6 = puVar16; + do { + puVar2 = (undefined4 *)puVar6[3]; + while (puVar6 != puVar2) { + uVar12 = puVar2[1] & 0xfffffffc; + uVar10 = uVar12 - uVar5; + if (0xf < (int)uVar10) { + iVar7 = puVar2[3]; + iVar9 = puVar2[2]; + puVar2[1] = uVar5 | 1; + *(int *)(iVar9 + 0xc) = iVar7; + *(int *)(iVar7 + 8) = iVar9; + iVar9 = (int)puVar2 + uVar5; + __malloc_av_._16_4_ = iVar9; + __malloc_av_._20_4_ = iVar9; + *(undefined4 *)(iVar9 + 0xc) = 0x4200e6ec; + *(undefined4 *)(iVar9 + 8) = 0x4200e6ec; + *(uint *)(iVar9 + 4) = uVar10 | 1; + *(uint *)((int)puVar2 + uVar12) = uVar10; + __malloc_unlock(param_1); + return puVar2 + 2; + } + if (-1 < (int)uVar10) { + iVar7 = puVar2[3]; + iVar9 = puVar2[2]; + *(uint *)((int)puVar2 + uVar12 + 4) = *(uint *)((int)puVar2 + uVar12 + 4) | 1; + *(int *)(iVar9 + 0xc) = iVar7; + *(int *)(iVar7 + 8) = iVar9; + __malloc_unlock(param_1); + return puVar2 + 2; + } + puVar2 = (undefined4 *)puVar2[3]; + } + uVar13 = uVar13 + 1; + puVar6 = puVar6 + 2; + } while ((uVar13 & 3) != 0); + do { + puVar6 = puVar16 + -2; + if ((uVar4 & 3) == 0) { + __malloc_av_._4_4_ = ~uVar8 & __malloc_av_._4_4_; + break; + } + puVar2 = (undefined4 *)*puVar16; + uVar4 = uVar4 - 1; + puVar16 = puVar6; + } while (puVar2 == puVar6); + uVar8 = uVar8 << 1; + if ((__malloc_av_._4_4_ < uVar8) || (uVar4 = uVar13, uVar8 == 0)) break; + while ((uVar8 & __malloc_av_._4_4_) == 0) { + uVar8 = uVar8 << 1; + uVar4 = uVar4 + 4; + } + } while( true ); + } + } + puVar1 = __malloc_av_._8_4_; + uVar4 = *(uint *)(__malloc_av_._8_4_ + 4) & 0xfffffffc; + if ((uVar5 <= uVar4) && (uVar13 = uVar4 - uVar5, puVar3 = __malloc_av_._8_4_, 0xf < (int)uVar13)) + goto LAB_230a7ff8; + puVar17 = __malloc_av_._8_4_ + uVar4; + if (__malloc_sbrk_base == (undefined1 *)0xffffffff) { + puVar18 = (undefined1 *)(uVar5 + __malloc_top_pad + 0x10); + } + else { + puVar18 = (undefined1 *)(uVar5 + __malloc_top_pad + 0x100f & 0xfffff000); + } + puVar19 = (undefined1 *)_sbrk_r(param_1,puVar18); + puVar3 = __malloc_av_._8_4_; + if (puVar19 == (undefined1 *)0xffffffff) { +LAB_230a8180: + uVar8 = *(uint *)(__malloc_av_._8_4_ + 4); + } + else { + if (puVar19 < puVar17) { + if (puVar1 != __malloc_av_) goto LAB_230a8180; +LAB_230a7efc: + __malloc_current_mallinfo._0_4_ = puVar18 + (int)__malloc_current_mallinfo._0_4_; + puVar3 = puVar19; + if (__malloc_sbrk_base != (undefined1 *)0xffffffff) { + __malloc_current_mallinfo._0_4_ = + puVar19 + (int)(__malloc_current_mallinfo._0_4_ + -(int)puVar17); + puVar3 = __malloc_sbrk_base; + } + __malloc_sbrk_base = puVar3; + uVar13 = (uint)puVar19 & 7; + if (uVar13 == 0) { + uVar10 = 0x1000 - ((uint)(puVar19 + (int)puVar18) & 0xfff) & 0xfff; + iVar9 = _sbrk_r(param_1,uVar10); + if (iVar9 != -1) goto LAB_230a7f5c; + uVar10 = 0; + puVar3 = puVar19; + } + else { + puVar19 = puVar19 + (8 - uVar13); + uVar10 = (0x1008 - uVar13) - ((uint)(puVar19 + (int)puVar18) & 0xfff) & 0xfff; + iVar9 = _sbrk_r(param_1,uVar10); + if (iVar9 == -1) { + puVar18 = puVar19 + (int)puVar18 + ((uVar13 - 8) - (int)puVar19); + uVar10 = 0; + puVar3 = puVar19; + } + else { +LAB_230a7f5c: + puVar18 = (undefined1 *)((iVar9 - (int)puVar19) + uVar10); + puVar3 = puVar19; + } + } + uVar8 = (uint)puVar18 | 1; + puVar14 = __malloc_current_mallinfo._0_4_ + uVar10; + __malloc_av_._8_4_ = puVar3; + __malloc_current_mallinfo._0_4_ = puVar14; + *(uint *)(puVar3 + 4) = uVar8; + if (puVar1 != __malloc_av_) { + if (uVar4 < 0x10) { + *(undefined4 *)(puVar3 + 4) = 1; + goto LAB_230a819c; + } + uVar4 = uVar4 - 0xc & 0xfffffff8; + *(uint *)(puVar1 + 4) = *(uint *)(puVar1 + 4) & 1 | uVar4; + *(undefined4 *)(puVar1 + uVar4 + 4) = 5; + *(undefined4 *)(puVar1 + uVar4 + 8) = 5; + if (uVar4 < 0x10) { + uVar8 = *(uint *)(puVar3 + 4); + } + else { + _free_r(param_1,puVar1 + 8); + uVar8 = *(uint *)(__malloc_av_._8_4_ + 4); + puVar3 = __malloc_av_._8_4_; + puVar14 = __malloc_current_mallinfo._0_4_; + } + } + } + else { + puVar14 = puVar18 + (int)__malloc_current_mallinfo._0_4_; + if ((puVar17 != puVar19) || (((uint)puVar17 & 0xfff) != 0)) goto LAB_230a7efc; + uVar8 = (uint)(puVar18 + uVar4) | 1; + __malloc_current_mallinfo._0_4_ = puVar14; + *(uint *)(__malloc_av_._8_4_ + 4) = uVar8; + } + if (__malloc_max_sbrked_mem < puVar14) { + __malloc_max_sbrked_mem = puVar14; + } + if (__malloc_max_total_mem < puVar14) { + __malloc_max_total_mem = puVar14; + } + } + uVar13 = (uVar8 & 0xfffffffc) - uVar5; + if ((uVar5 <= (uVar8 & 0xfffffffc)) && (0xf < (int)uVar13)) { +LAB_230a7ff8: + *(uint *)(puVar3 + 4) = uVar5 | 1; + __malloc_av_._8_4_ = puVar3 + uVar5; + *(uint *)(__malloc_av_._8_4_ + 4) = uVar13 | 1; + __malloc_unlock(param_1); + return (undefined4 *)(puVar3 + 8); + } +LAB_230a819c: + __malloc_unlock(param_1); + return (undefined4 *)0; +} + + + +void _mbtowc_r(void) + +{ + (*(code *)(__global_locale._228_4_ & 0xfffffffe))(); + return; +} + + + +uint __ascii_mbtowc(uint *param_1,byte *param_2,int param_3) + +{ + uint uVar1; + + if (param_1 == (uint *)0x0) { + if (param_2 == (byte *)0x0) { + uVar1 = 0; + } + else { + if (param_3 == 0) { + uVar1 = 0xfffffffe; + } + else { + uVar1 = (uint)(*param_2 != 0); + } + } + return uVar1; + } + if (param_2 != (byte *)0x0) { + if (param_3 != 0) { + *param_1 = (uint)*param_2; + return (uint)(*param_2 != 0); + } + return 0xfffffffe; + } + return 0; +} + + + +void __malloc_lock(void) + +{ + return; +} + + + +void __malloc_unlock(void) + +{ + return; +} + + + +undefined4 * _realloc_r(undefined4 *param_1,undefined4 *param_2,uint param_3) + +{ + uint uVar1; + uint __n; + uint uVar2; + uint uVar3; + undefined4 uVar4; + undefined4 *__dest; + int iVar5; + uint uVar6; + undefined4 *puVar7; + int iVar8; + undefined4 *__dest_00; + int iVar9; + undefined4 *puVar10; + + if (param_2 == (undefined4 *)0x0) { + uVar4 = _malloc_r(param_3); + return (undefined4 *)uVar4; + } + __malloc_lock(); + if (param_3 + 0xb < 0x17) { + uVar1 = 0x10; + if (0x10 < param_3) goto LAB_230a8578; + } + else { + uVar1 = param_3 + 0xb & 0xfffffff8; + if (((int)uVar1 < 0) || (uVar1 < param_3)) { +LAB_230a8578: + *param_1 = 0xc; + return (undefined4 *)0; + } + } + uVar6 = param_2[-1]; + __dest = param_2 + -2; + __n = uVar6 & 0xfffffffc; + iVar9 = (int)__dest + __n; + uVar2 = __n; + __dest_00 = param_2; + if ((int)__n < (int)uVar1) { + uVar3 = *(uint *)(iVar9 + 4); + if (__malloc_av_._8_4_ == iVar9) { + iVar9 = __n + (uVar3 & 0xfffffffc); + if ((int)(uVar1 + 0x10) <= iVar9) { + __malloc_av_._8_4_ = (int)__dest + uVar1; + *(uint *)(__malloc_av_._8_4_ + 4) = iVar9 - uVar1 | 1; + param_2[-1] = param_2[-1] & 1 | uVar1; + __malloc_unlock(param_1); + return param_2; + } + if ((uVar6 & 1) == 0) { + puVar7 = (undefined4 *)((int)__dest - param_2[-2]); + uVar6 = puVar7[1] & 0xfffffffc; + iVar9 = uVar6 + (uVar3 & 0xfffffffc) + __n; + if ((int)(uVar1 + 0x10) <= iVar9) { + iVar8 = puVar7[3]; + iVar5 = puVar7[2]; + __n = __n - 4; + *(int *)(iVar5 + 0xc) = iVar8; + *(int *)(iVar8 + 8) = iVar5; + __dest = puVar7 + 2; + if (__n < 0x25) { + uVar4 = *param_2; + __dest_00 = __dest; + if (0x13 < __n) { + puVar7[2] = uVar4; + puVar7[3] = param_2[1]; + if (__n < 0x1c) { + uVar4 = param_2[2]; + __dest_00 = puVar7 + 4; + param_2 = param_2 + 2; + } + else { + puVar7[4] = param_2[2]; + puVar7[5] = param_2[3]; + uVar4 = param_2[4]; + if (__n == 0x24) { + puVar7[6] = uVar4; + puVar10 = param_2 + 5; + __dest_00 = puVar7 + 8; + param_2 = param_2 + 6; + puVar7[7] = *puVar10; + uVar4 = *param_2; + } + else { + __dest_00 = puVar7 + 6; + param_2 = param_2 + 4; + } + } + } + *__dest_00 = uVar4; + __dest_00[1] = param_2[1]; + __dest_00[2] = param_2[2]; + } + else { + memmove(__dest,param_2,__n); + } + __malloc_av_._8_4_ = (int)puVar7 + uVar1; + *(uint *)(__malloc_av_._8_4_ + 4) = iVar9 - uVar1 | 1; + puVar7[1] = puVar7[1] & 1 | uVar1; + __malloc_unlock(param_1); + return __dest; + } +LAB_230a84f0: + uVar2 = __n + uVar6; + if ((int)uVar1 <= (int)uVar2) { + iVar5 = puVar7[3]; + iVar9 = puVar7[2]; + uVar6 = __n - 4; + *(int *)(iVar9 + 0xc) = iVar5; + *(int *)(iVar5 + 8) = iVar9; + __dest_00 = puVar7 + 2; + iVar9 = (int)puVar7 + uVar2; + if (0x24 < uVar6) goto LAB_230a88d0; + uVar4 = *param_2; + __dest = __dest_00; + puVar10 = param_2; + if (0x13 < uVar6) { + puVar7[2] = uVar4; + puVar7[3] = param_2[1]; + if (uVar6 < 0x1c) { + uVar4 = param_2[2]; + __dest = puVar7 + 4; + puVar10 = param_2 + 2; + } + else { + puVar7[4] = param_2[2]; + puVar7[5] = param_2[3]; + if (uVar6 == 0x24) { + __dest = puVar7 + 8; + puVar10 = param_2 + 6; + puVar7[6] = param_2[4]; + puVar7[7] = param_2[5]; + uVar4 = *puVar10; + } + else { + uVar4 = param_2[4]; + __dest = puVar7 + 6; + puVar10 = param_2 + 4; + } + } + } + *__dest = uVar4; + __dest[1] = puVar10[1]; + __dest[2] = puVar10[2]; + __dest = puVar7; + goto LAB_230a863c; + } + } + } + else { + if ((*(uint *)(iVar9 + (uVar3 & 0xfffffffe) + 4) & 1) == 0) { + uVar2 = __n + (uVar3 & 0xfffffffc); + if ((int)uVar2 < (int)uVar1) { + if ((uVar6 & 1) != 0) goto LAB_230a84f8; + puVar7 = (undefined4 *)((int)__dest - param_2[-2]); + uVar6 = puVar7[1] & 0xfffffffc; + uVar2 = uVar6 + (uVar3 & 0xfffffffc) + __n; + if ((int)uVar2 < (int)uVar1) goto LAB_230a84f0; + iVar5 = *(int *)(iVar9 + 0xc); + iVar9 = *(int *)(iVar9 + 8); + uVar6 = __n - 4; + *(int *)(iVar9 + 0xc) = iVar5; + *(int *)(iVar5 + 8) = iVar9; + iVar5 = puVar7[2]; + iVar8 = puVar7[3]; + __dest_00 = puVar7 + 2; + iVar9 = (int)puVar7 + uVar2; + *(int *)(iVar5 + 0xc) = iVar8; + *(int *)(iVar8 + 8) = iVar5; + if (uVar6 < 0x25) { + uVar4 = *param_2; + __dest = __dest_00; + if (0x13 < uVar6) { + puVar7[2] = uVar4; + puVar7[3] = param_2[1]; + uVar4 = param_2[2]; + if (uVar6 < 0x1c) { + __dest = puVar7 + 4; + param_2 = param_2 + 2; + } + else { + puVar7[4] = uVar4; + puVar7[5] = param_2[3]; + uVar4 = param_2[4]; + if (uVar6 == 0x24) { + puVar7[6] = uVar4; + puVar10 = param_2 + 5; + __dest = puVar7 + 8; + param_2 = param_2 + 6; + puVar7[7] = *puVar10; + uVar4 = *param_2; + } + else { + __dest = puVar7 + 6; + param_2 = param_2 + 4; + } + } + } + *__dest = uVar4; + __dest[1] = param_2[1]; + __dest[2] = param_2[2]; + __dest = puVar7; + goto LAB_230a863c; + } +LAB_230a88d0: + memmove(__dest_00,param_2,__n - 4); + __dest = puVar7; + } + else { + iVar8 = *(int *)(iVar9 + 0xc); + iVar5 = *(int *)(iVar9 + 8); + iVar9 = (int)__dest + uVar2; + *(int *)(iVar5 + 0xc) = iVar8; + *(int *)(iVar8 + 8) = iVar5; + } + goto LAB_230a863c; + } + if ((uVar6 & 1) == 0) { + puVar7 = (undefined4 *)((int)__dest - param_2[-2]); + uVar6 = puVar7[1] & 0xfffffffc; + goto LAB_230a84f0; + } + } +LAB_230a84f8: + __dest_00 = (undefined4 *)_malloc_r(param_1,param_3); + if (__dest_00 != (undefined4 *)0x0) { + if ((undefined4 *)((int)__dest + (param_2[-1] & 0xfffffffe)) == __dest_00 + -2) { + uVar2 = __n + (__dest_00[-1] & 0xfffffffc); + iVar9 = (int)__dest + uVar2; + __dest_00 = param_2; + goto LAB_230a863c; + } + __n = __n - 4; + if (__n < 0x25) { + uVar4 = *param_2; + __dest = param_2; + puVar7 = __dest_00; + if (0x13 < __n) { + *__dest_00 = uVar4; + __dest_00[1] = param_2[1]; + if (__n < 0x1c) { + uVar4 = param_2[2]; + __dest = param_2 + 2; + puVar7 = __dest_00 + 2; + } + else { + __dest_00[2] = param_2[2]; + __dest_00[3] = param_2[3]; + if (__n == 0x24) { + __dest_00[4] = param_2[4]; + __dest_00[5] = param_2[5]; + uVar4 = param_2[6]; + __dest = param_2 + 6; + puVar7 = __dest_00 + 6; + } + else { + uVar4 = param_2[4]; + __dest = param_2 + 4; + puVar7 = __dest_00 + 4; + } + } + } + *puVar7 = uVar4; + puVar7[1] = __dest[1]; + puVar7[2] = __dest[2]; + } + else { + memmove(__dest_00,param_2,__n); + } + _free_r(param_1,param_2); + } + __malloc_unlock(param_1); + } + else { +LAB_230a863c: + if (uVar2 - uVar1 < 0x10) { + __dest[1] = uVar2 | __dest[1] & 1; + *(uint *)(iVar9 + 4) = *(uint *)(iVar9 + 4) | 1; + } + else { + __dest[1] = __dest[1] & 1 | uVar1; + *(uint *)((int)__dest + uVar1 + 4) = uVar2 - uVar1 | 1; + *(uint *)(iVar9 + 4) = *(uint *)(iVar9 + 4) | 1; + _free_r(param_1,(int)__dest + uVar1 + 8); + } + __malloc_unlock(param_1); + } + return __dest_00; +} + + + +void _sbrk_r(int *param_1,intptr_t param_2) + +{ + void *pvVar1; + + errno = 0; + pvVar1 = _sbrk(param_2); + if ((pvVar1 == (void *)0xffffffff) && (errno != 0)) { + *param_1 = errno; + return; + } + return; +} + + + +void _stat_r(int *param_1,undefined4 param_2,undefined4 param_3) + +{ + int iVar1; + + errno = 0; + iVar1 = _stat(param_2,param_3); + if ((iVar1 == -1) && (errno != 0)) { + *param_1 = errno; + return; + } + return; +} + + + +void __sread(int param_1) + +{ + int iVar1; + + iVar1 = _read_r((int)*(short *)(param_1 + 0xe)); + if (-1 < iVar1) { + *(int *)(param_1 + 0x50) = *(int *)(param_1 + 0x50) + iVar1; + return; + } + *(ushort *)(param_1 + 0xc) = *(ushort *)(param_1 + 0xc) & 0xefff; + return; +} + + + +undefined4 __seofread(void) + +{ + return 0; +} + + + +void __swrite(undefined4 param_1,int param_2,undefined4 param_3,undefined4 param_4) + +{ + ushort uVar1; + int iVar2; + + uVar1 = *(ushort *)(param_2 + 0xc); + iVar2 = (int)*(short *)(param_2 + 0xe); + if ((uVar1 & 0x100) != 0) { + _lseek_r(iVar2,0,2); + uVar1 = *(ushort *)(param_2 + 0xc); + iVar2 = (int)*(short *)(param_2 + 0xe); + } + *(ushort *)(param_2 + 0xc) = uVar1 & 0xefff; + _write_r(param_1,iVar2,param_3,param_4); + return; +} + + + +void __sseek(int param_1) + +{ + int iVar1; + + iVar1 = _lseek_r((int)*(short *)(param_1 + 0xe)); + if (iVar1 != -1) { + *(int *)(param_1 + 0x50) = iVar1; + *(ushort *)(param_1 + 0xc) = *(ushort *)(param_1 + 0xc) | 0x1000; + return; + } + *(ushort *)(param_1 + 0xc) = *(ushort *)(param_1 + 0xc) & 0xefff; + return; +} + + + +void __sclose(int param_1) + +{ + _close_r((int)*(short *)(param_1 + 0xe)); + return; +} + + + +uint __swbuf_r(int param_1,byte param_2,byte **param_3) + +{ + ushort uVar1; + int iVar2; + uint uVar3; + byte *pbVar4; + byte *pbVar5; + + if ((param_1 != 0) && (*(int *)(param_1 + 0x38) == 0)) { + __sinit(); + } + uVar1 = *(ushort *)(param_3 + 3); + uVar3 = (int)(short)uVar1 & 0xffff; + param_3[2] = param_3[6]; + if ((((int)(short)uVar1 & 8U) == 0) || (pbVar5 = param_3[4], pbVar5 == (byte *)0x0)) { + iVar2 = __swsetup_r(param_1,param_3); + if (iVar2 != 0) { + return 0xffffffff; + } + uVar1 = *(ushort *)(param_3 + 3); + uVar3 = SEXT24((short)uVar1); + pbVar5 = param_3[4]; + } + if ((int)(uVar3 << 0x12) < 0) { + pbVar4 = *param_3; + pbVar5 = pbVar4 + -(int)pbVar5; + if ((int)pbVar5 < (int)param_3[5]) goto LAB_230a8c94; +LAB_230a8d4c: + iVar2 = _fflush_r(param_1,param_3); + if (iVar2 != 0) { + return 0xffffffff; + } + pbVar5 = *param_3; + *param_3 = pbVar5 + 1; + param_3[2] = param_3[2] + -1; + *pbVar5 = param_2; + if (param_3[5] == &DAT_00000001) goto LAB_230a8d84; + } + else { + *(ushort *)(param_3 + 3) = uVar1 | 0x2000; + pbVar4 = *param_3; + param_3[0x19] = (byte *)((uint)param_3[0x19] & 0xffffdfff); + pbVar5 = pbVar4 + -(int)pbVar5; + if ((int)param_3[5] <= (int)pbVar5) goto LAB_230a8d4c; +LAB_230a8c94: + *param_3 = pbVar4 + 1; + param_3[2] = param_3[2] + -1; + *pbVar4 = param_2; + if (param_3[5] == pbVar5 + 1) goto LAB_230a8d84; + } + if ((*(ushort *)(param_3 + 3) & 1) == 0) { + return (uint)param_2; + } + if (param_2 != 10) { + return (uint)param_2; + } +LAB_230a8d84: + iVar2 = _fflush_r(param_1,param_3); + if (iVar2 != 0) { + return 0xffffffff; + } + return (uint)param_2; +} + + + +void __swbuf(undefined4 param_1,undefined4 param_2) + +{ + __swbuf_r(_impure_ptr,param_1,param_2); + return; +} + + + +void _wcrtomb_r(undefined4 *param_1,int param_2,undefined4 *param_3) + +{ + int iVar1; + undefined auStack28 [16]; + + if (param_2 == 0) { + iVar1 = (*(code *)(__global_locale._224_4_ & 0xfffffffe))(auStack28,0); + } + else { + iVar1 = (*(code *)(__global_locale._224_4_ & 0xfffffffe))(); + } + if (iVar1 != -1) { + return; + } + *param_3 = 0; + *param_1 = 0x8a; + return; +} + + + +size_t wcrtomb(char *__s,wchar_t __wc,mbstate_t *__ps) + +{ + undefined *puVar1; + size_t sVar2; + undefined2 in_register_0000202e; + undefined auStack28 [16]; + + puVar1 = _impure_ptr; + if (__s == (char *)0x0) { + sVar2 = (*(code *)(__global_locale._224_4_ & 0xfffffffe))(_impure_ptr,auStack28,0,__ps); + } + else { + sVar2 = (*(code *)(__global_locale._224_4_ & 0xfffffffe)) + (_impure_ptr,__s,CONCAT22(in_register_0000202e,__wc)); + } + if (sVar2 != 0xffffffff) { + return sVar2; + } + __ps->__count = 0; + *(undefined4 *)puVar1 = 0x8a; + return 0xffffffff; +} + + + +void _wctomb_r(void) + +{ + (*(code *)(__global_locale._224_4_ & 0xfffffffe))(); + return; +} + + + +undefined4 __ascii_wctomb(undefined4 *param_1,undefined *param_2,uint param_3) + +{ + if (param_2 == (undefined *)0x0) { + return 0; + } + if (param_3 < 0x100) { + *param_2 = (char)param_3; + return 1; + } + *param_1 = 0x8a; + return 0xffffffff; +} + + + +void _write_r(int *param_1,int param_2,void *param_3,size_t param_4) + +{ + ssize_t sVar1; + + errno = 0; + sVar1 = _write(param_2,param_3,param_4); + if ((sVar1 == -1) && (errno != 0)) { + *param_1 = errno; + return; + } + return; +} + + + +void _close_r(int *param_1,int param_2) + +{ + int iVar1; + + errno = 0; + iVar1 = _close(param_2); + if ((iVar1 == -1) && (errno != 0)) { + *param_1 = errno; + return; + } + return; +} + + + +undefined4 _fclose_r(int param_1,int param_2) + +{ + short sVar1; + ushort uVar2; + undefined4 uVar3; + int iVar4; + + if (param_2 != 0) { + if ((param_1 == 0) || (*(int *)(param_1 + 0x38) != 0)) { + sVar1 = *(short *)(param_2 + 0xc); + } + else { + __sinit(); + sVar1 = *(short *)(param_2 + 0xc); + } + if (sVar1 != 0) { + uVar3 = __sflush_r(param_1,param_2); + if ((*(uint *)(param_2 + 0x2c) == 0) || + (iVar4 = (*(code *)(*(uint *)(param_2 + 0x2c) & 0xfffffffe)) + (param_1,*(undefined4 *)(param_2 + 0x1c)), -1 < iVar4)) { + uVar2 = *(ushort *)(param_2 + 0xc); + } + else { + uVar2 = *(ushort *)(param_2 + 0xc); + uVar3 = 0xffffffff; + } + if ((uVar2 & 0x80) != 0) { + _free_r(param_1,*(undefined4 *)(param_2 + 0x10)); + } + if (*(int *)(param_2 + 0x30) != 0) { + if (*(int *)(param_2 + 0x30) != param_2 + 0x40) { + _free_r(param_1); + } + *(undefined4 *)(param_2 + 0x30) = 0; + } + if (*(int *)(param_2 + 0x44) != 0) { + _free_r(param_1); + *(undefined4 *)(param_2 + 0x44) = 0; + } + __sfp_lock_acquire(); + *(undefined2 *)(param_2 + 0xc) = 0; + __sfp_lock_release(); + return uVar3; + } + } + return 0; +} + + + +int fclose(FILE *__stream) + +{ + int iVar1; + + iVar1 = _fclose_r(_impure_ptr,__stream); + return iVar1; +} + + + +void _fstat_r(int *param_1,int param_2,stat *param_3) + +{ + int iVar1; + + errno = 0; + iVar1 = _fstat(param_2,param_3); + if ((iVar1 == -1) && (errno != 0)) { + *param_1 = errno; + return; + } + return; +} + + + +void _isatty_r(int *param_1,int param_2) + +{ + int iVar1; + + errno = 0; + iVar1 = _isatty(param_2); + if ((iVar1 == -1) && (errno != 0)) { + *param_1 = errno; + return; + } + return; +} + + + +void _lseek_r(int *param_1,int param_2,__off_t param_3,int param_4) + +{ + __off_t _Var1; + + errno = 0; + _Var1 = _lseek(param_2,param_3,param_4); + if ((_Var1 == -1) && (errno != 0)) { + *param_1 = errno; + return; + } + return; +} + + + +void _read_r(int *param_1,int param_2,void *param_3,size_t param_4) + +{ + ssize_t sVar1; + + errno = 0; + sVar1 = _read(param_2,param_3,param_4); + if ((sVar1 == -1) && (errno != 0)) { + *param_1 = errno; + return; + } + return; +} + + + +int _close(int __fd) + +{ + int *piVar1; + + ecall(); + if (__fd < 0) { + piVar1 = (int *)__errno(0,0,0,0,0,0x39); + *piVar1 = -__fd; + __fd = -1; + } + return __fd; +} + + + +void _exit(int __status) + +{ + int *piVar1; + + ecall(); + if (-1 < __status) { + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + piVar1 = (int *)__errno(0,0,0,0,0,0x5d); + *piVar1 = -__status; + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +int _fstat(int __fd,stat *__buf) + +{ + int *piVar1; + undefined auStack144 [132]; + + ecall(); + if (__fd < 0) { + piVar1 = (int *)__errno(auStack144,0,0,0,0,0x50); + *piVar1 = -__fd; + __fd = -1; + } + _conv_stat(__buf,auStack144); + return __fd; +} + + + +// WARNING: Unknown calling convention yet parameter storage is locked + +__pid_t _getpid(void) + +{ + return 1; +} + + + +int _isatty(int __fd) + +{ + int iVar1; + undefined auStack104 [4]; + uint uStack100; + + iVar1 = _fstat(__fd,(stat *)auStack104); + if (iVar1 != -1) { + return uStack100 >> 0xd & 1; + } + return 0; +} + + + +int _kill(__pid_t __pid,int __sig) + +{ + undefined4 *puVar1; + + puVar1 = (undefined4 *)__errno(); + *puVar1 = 0x16; + return -1; +} + + + +__off_t _lseek(int __fd,__off_t __offset,int __whence) + +{ + int *piVar1; + + ecall(); + if (__fd < 0) { + piVar1 = (int *)__errno(0,0,0,0x3e); + *piVar1 = -__fd; + __fd = -1; + } + return __fd; +} + + + +ssize_t _read(int __fd,void *__buf,size_t __nbytes) + +{ + int *piVar1; + + ecall(); + if (__fd < 0) { + piVar1 = (int *)__errno(0,0,0,0x3f); + *piVar1 = -__fd; + __fd = -1; + } + return __fd; +} + + + +// WARNING: Removing unreachable block (ram,0x230a9530) + +void * _sbrk(intptr_t __delta) + +{ + void *pvVar1; + + if (heap_end_1866 == (void *)0x0) { + ecall(); + heap_end_1866 = (void *)0x0; + } + ecall(); + pvVar1 = heap_end_1866; + heap_end_1866 = (void *)(__delta + (int)heap_end_1866); + return pvVar1; +} + + + +int _stat(int param_1,undefined4 param_2) + +{ + int *piVar1; + undefined auStack144 [132]; + + ecall(); + if (param_1 < 0) { + piVar1 = (int *)__errno(auStack144,0,0,0,0,0x40e); + *piVar1 = -param_1; + param_1 = -1; + } + _conv_stat(param_2,auStack144); + return param_1; +} + + + +ssize_t _write(int __fd,void *__buf,size_t __n) + +{ + int *piVar1; + + ecall(); + if (__fd < 0) { + piVar1 = (int *)__errno(0,0,0,0x40); + *piVar1 = -__fd; + __fd = -1; + } + return __fd; +} + + + +void _conv_stat(undefined2 *param_1,undefined4 *param_2) + +{ + undefined4 uVar1; + undefined4 uVar2; + undefined4 uVar3; + undefined4 uVar4; + undefined4 uVar5; + undefined4 uVar6; + undefined4 uVar7; + undefined4 uVar8; + undefined4 uVar9; + undefined4 uVar10; + undefined4 uVar11; + undefined4 uVar12; + undefined4 uVar13; + undefined4 uVar14; + undefined4 uVar15; + + uVar3 = param_2[5]; + uVar1 = param_2[6]; + uVar15 = param_2[7]; + uVar14 = param_2[8]; + uVar13 = param_2[0xc]; + uVar12 = param_2[0x10]; + uVar2 = param_2[0xe]; + uVar10 = param_2[0x12]; + uVar11 = param_2[0x13]; + uVar6 = param_2[0x16]; + uVar4 = param_2[4]; + uVar5 = param_2[2]; + uVar7 = param_2[0x17]; + uVar8 = param_2[0x1a]; + uVar9 = param_2[0x1b]; + *param_1 = (short)*param_2; + param_1[1] = (short)uVar5; + *(undefined4 *)(param_1 + 2) = uVar4; + param_1[4] = (short)uVar3; + param_1[5] = (short)uVar1; + param_1[6] = (short)uVar15; + param_1[7] = (short)uVar14; + *(undefined4 *)(param_1 + 8) = uVar13; + *(undefined4 *)(param_1 + 0x24) = uVar12; + *(undefined4 *)(param_1 + 0x22) = uVar2; + *(undefined4 *)(param_1 + 0xc) = uVar10; + *(undefined4 *)(param_1 + 0xe) = uVar11; + *(undefined4 *)(param_1 + 0x14) = uVar6; + *(undefined4 *)(param_1 + 0x16) = uVar7; + *(undefined4 *)(param_1 + 0x1c) = uVar8; + *(undefined4 *)(param_1 + 0x1e) = uVar9; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_On_BG(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4a0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010828)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_Off_BG(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4aa. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101082c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_On_LDO11_SOC(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4b4. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010830)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_Off_LDO11_SOC(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4be. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010834)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_On_LDO15_RF(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4c8. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010838)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_Off_LDO15_RF(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4d2. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101083c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_On_SFReg(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4dc. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010840)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_Off_SFReg(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4e6. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010844)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_LowPower_Enter_PDS0(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4f0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010848)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_LowPower_Exit_PDS0(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4fa. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101084c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ASM_Delay_Us(uint32_t core,uint32_t cnt) + +{ + // WARNING: Could not recover jumptable at 0x4200c504. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010850)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void BL602_Delay_US(uint32_t cnt) + +{ + // WARNING: Could not recover jumptable at 0x4200c50e. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010854)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void BL602_Delay_MS(uint32_t cnt) + +{ + // WARNING: Could not recover jumptable at 0x4200c518. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010858)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void * BL602_MemCpy(void *dst,void *src,uint32_t n) + +{ + void *pvVar1; + + // WARNING: Could not recover jumptable at 0x4200c522. Too many branches + // WARNING: Treating indirect jump as call + pvVar1 = (void *)(*_DAT_2101085c)(); + return pvVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t * BL602_MemCpy4(uint32_t *dst,uint32_t *src,uint32_t n) + +{ + uint32_t *puVar1; + + // WARNING: Could not recover jumptable at 0x4200c52c. Too many branches + // WARNING: Treating indirect jump as call + puVar1 = (uint32_t *)(*_DAT_21010860)(); + return puVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void * BL602_MemCpy_Fast(void *pdst,void *psrc,uint32_t n) + +{ + void *pvVar1; + + // WARNING: Could not recover jumptable at 0x4200c536. Too many branches + // WARNING: Treating indirect jump as call + pvVar1 = (void *)(*_DAT_21010864)(); + return pvVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void * BL602_MemSet(void *s,uint8_t c,uint32_t n) + +{ + void *pvVar1; + + // WARNING: Could not recover jumptable at 0x4200c540. Too many branches + // WARNING: Treating indirect jump as call + pvVar1 = (void *)(*_DAT_21010868)(); + return pvVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t * BL602_MemSet4(uint32_t *dst,uint32_t val,uint32_t n) + +{ + uint32_t *puVar1; + + // WARNING: Could not recover jumptable at 0x4200c54a. Too many branches + // WARNING: Treating indirect jump as call + puVar1 = (uint32_t *)(*_DAT_2101086c)(); + return puVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int BL602_MemCmp(void *s1,void *s2,uint32_t n) + +{ + int iVar1; + + // WARNING: Could not recover jumptable at 0x4200c554. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*_DAT_21010870)(); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Sw_AHB_Clk_0(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c55e. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010874)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Program_Efuse_0(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c568. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010878)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Load_Efuse_R0(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c572. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_2101087c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Sts_Type EF_Ctrl_Busy(void) + +{ + BL_Sts_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c57c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010880)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Sts_Type EF_Ctrl_AutoLoad_Done(void) + +{ + BL_Sts_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c586. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010884)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Clear(uint32_t index,uint32_t len) + +{ + // WARNING: Could not recover jumptable at 0x4200c590. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010894)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_SW_System_Reset(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c59a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108bc)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_SW_CPU_Reset(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5a4. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108c0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_SW_POR_Reset(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5ae. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108c4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Select_Internal_Flash(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5b8. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108c8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Select_External_Flash(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5c2. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108cc)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Deswap_Flash_Pin(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5cc. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108d0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Swap_Flash_Pin(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5d6. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108d4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_GPIO_Init(GLB_GPIO_Cfg_Type *cfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5e0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108d8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_GPIO_OUTPUT_Enable(GLB_GPIO_Type gpioPin) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5ea. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108dc)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_GPIO_OUTPUT_Disable(GLB_GPIO_Type gpioPin) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5f4. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108e0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_GPIO_Set_HZ(GLB_GPIO_Type gpioPin) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5fe. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108e4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t GLB_GPIO_Get_Fun(GLB_GPIO_Type gpioPin) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c608. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_210108e8)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void HBN_Mode_Enter(HBN_APP_CFG_Type *cfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c612. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210108ec)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void HBN_Power_Down_Flash(SPI_Flash_Cfg_Type *flashCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c61c. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210108f0)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void HBN_Enable(uint8_t aGPIOIeCfg,HBN_LDO_LEVEL_Type ldoLevel,HBN_LEVEL_Type hbnLevel) + +{ + // WARNING: Could not recover jumptable at 0x4200c626. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210108f4)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Reset(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c630. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108f8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Set_Ldo11_Aon_Vout(HBN_LDO_LEVEL_Type ldoLevel) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c63a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108fc)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Set_Ldo11_Rt_Vout(HBN_LDO_LEVEL_Type ldoLevel) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c644. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010900)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Set_Ldo11_Soc_Vout(HBN_LDO_LEVEL_Type ldoLevel) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c64e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010904)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Hw_Pu_Pd_Cfg(uint8_t enable) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c658. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010924)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Pin_WakeUp_Mask(uint8_t maskVal) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c662. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010928)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +HBN_GPIO7_Dbg_Pull_Cfg(BL_Fun_Type pupdEn,BL_Fun_Type iesmtEn,BL_Fun_Type dlyEn,uint8_t dlySec) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c66c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101092c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Set_Embedded_Flash_Pullup(uint8_t enable) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c676. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010930)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type L1C_Set_Wrap(BL_Fun_Type wrap) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c680. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010934)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type L1C_Set_Way_Disable(uint8_t disableVal) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c68a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010938)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type L1C_IROM_2T_Access_Set(uint8_t enable) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c694. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101093c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Reset(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c69e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010940)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Force_Config(PDS_CTL2_Type *cfg2,PDS_CTL3_Type *cfg3) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c6a8. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010948)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_RAM_Config(PDS_RAM_CFG_Type *ramCfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c6b2. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101094c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +PDS_Default_Level_Config + (PDS_DEFAULT_LV_CFG_Type *defaultLvCfg,PDS_RAM_CFG_Type *ramCfg,uint32_t pdsSleepCnt) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c6bc. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010950)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SEC_Eng_Turn_On_Sec_Ring(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c6c6. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010978)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SEC_Eng_Turn_Off_Sec_Ring(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c6d0. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_2101097c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Init(SF_Ctrl_Cfg_Type *pSfCtrlCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c6da. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010980)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_SetSPIMode(SF_Ctrl_Mode_Type mode) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c6e4. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010984)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Read_Reg(SPI_Flash_Cfg_Type *flashCfg,uint8_t regIndex,uint8_t *regValue,uint8_t regLen) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c6ee. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010988)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Write_Reg(SPI_Flash_Cfg_Type *flashCfg,uint8_t regIndex,uint8_t *regValue,uint8_t regLen) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c6f8. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101098c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Sts_Type SFlash_Busy(SPI_Flash_Cfg_Type *flashCfg) + +{ + BL_Sts_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c702. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010990)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Write_Enable(SPI_Flash_Cfg_Type *flashCfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c70c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010994)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Qspi_Enable(SPI_Flash_Cfg_Type *flashCfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c716. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010998)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Volatile_Reg_Write_Enable(SPI_Flash_Cfg_Type *flashCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c720. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_2101099c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Chip_Erase(SPI_Flash_Cfg_Type *flashCfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c72a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109a0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Sector_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t secNum) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c734. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109a4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Blk32_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t blkNum) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c73e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109a8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Blk64_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t blkNum) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c748. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109ac)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t startaddr,uint32_t endaddr) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c752. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109b0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Program(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint32_t addr,uint8_t *data, + uint32_t len) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c75c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109b4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_GetUniqueId(uint8_t *data,uint8_t idLen) + +{ + // WARNING: Could not recover jumptable at 0x4200c766. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109b8)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_GetJedecId(SPI_Flash_Cfg_Type *flashCfg,uint8_t *data) + +{ + // WARNING: Could not recover jumptable at 0x4200c770. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109bc)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_GetDeviceId(uint8_t *data) + +{ + // WARNING: Could not recover jumptable at 0x4200c77a. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109c0)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Powerdown(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c784. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109c4)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Releae_Powerdown(SPI_Flash_Cfg_Type *flashCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c78e. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109c8)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_SetBurstWrap(SPI_Flash_Cfg_Type *flashCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c798. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109cc)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_DisableBurstWrap(SPI_Flash_Cfg_Type *flashCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c7a2. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109d0)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Software_Reset(SPI_Flash_Cfg_Type *flashCfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c7ac. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109d4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Reset_Continue_Read(SPI_Flash_Cfg_Type *flashCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c7b6. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109d8)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Set_IDbus_Cfg + (SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead,uint32_t addr, + uint32_t len) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c7c0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109dc)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_IDbus_Read_Enable(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c7ca. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109e0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Cache_Enable_Set(uint8_t wayDisable) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c7d4. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109e4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Cache_Flush(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c7de. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109e8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Cache_Read_Enable + (SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead,uint8_t wayDisable) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c7e8. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109ec)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Cache_Hit_Count_Get(uint32_t *hitCountLow,uint32_t *hitCountHigh) + +{ + // WARNING: Could not recover jumptable at 0x4200c7f2. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109f0)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t SFlash_Cache_Miss_Count_Get(void) + +{ + uint32_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c7fc. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_210109f4)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Cache_Read_Disable(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c806. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109f8)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Read(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead,uint32_t addr, + uint8_t *data,uint32_t len) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c810. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109fc)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Read_Reg_With_Cmd + (SPI_Flash_Cfg_Type *flashCfg,uint8_t readRegCmd,uint8_t *regValue,uint8_t regLen) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c81a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a00)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Write_Reg_With_Cmd + (SPI_Flash_Cfg_Type *flashCfg,uint8_t writeRegCmd,uint8_t *regValue,uint8_t regLen) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c824. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a04)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Cfg_Init_Ext_Flash_Gpio(uint8_t extFlashPin) + +{ + // WARNING: Could not recover jumptable at 0x4200c82e. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a0c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Cfg_Init_Internal_Flash_Gpio(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c838. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a10)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Cfg_Deinit_Ext_Flash_Gpio(uint8_t extFlashPin) + +{ + // WARNING: Could not recover jumptable at 0x4200c842. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a14)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Cfg_Restore_GPIO17_Fun(uint8_t fun) + +{ + // WARNING: Could not recover jumptable at 0x4200c84c. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a18)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SF_Cfg_Get_Flash_Cfg_Need_Lock(uint32_t flashID,SPI_Flash_Cfg_Type *pFlashCfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c856. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a1c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Cfg_Init_Flash_Gpio(uint8_t flashPinCfg,uint8_t restoreDefault) + +{ + // WARNING: Could not recover jumptable at 0x4200c860. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a20)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t SF_Cfg_Flash_Identify + (uint8_t callFromFlash,uint32_t autoScan,uint32_t flashPinCfg, + uint8_t restoreDefault,SPI_Flash_Cfg_Type *pFlashCfg) + +{ + undefined3 in_register_00002029; + uint32_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c86a. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010a24)(CONCAT31(in_register_00002029,callFromFlash)); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Enable(SF_Ctrl_Cfg_Type *cfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c874. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a28)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Select_Pad(SF_Ctrl_Pad_Sel sel) + +{ + // WARNING: Could not recover jumptable at 0x4200c87e. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a2c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Set_Owner(SF_Ctrl_Owner_Type owner) + +{ + // WARNING: Could not recover jumptable at 0x4200c888. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a30)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Disable(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c892. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a34)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Enable_BE(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c89c. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a38)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Enable_LE(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c8a6. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a3c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Set_Region + (uint8_t region,uint8_t enable,uint8_t hwKey,uint32_t startAddr,uint32_t endAddr, + uint8_t locked) + +{ + // WARNING: Could not recover jumptable at 0x4200c8b0. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a40)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Set_Key(uint8_t region,uint8_t *key,SF_Ctrl_AES_Key_Type keyType) + +{ + // WARNING: Could not recover jumptable at 0x4200c8ba. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a44)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Set_Key_BE(uint8_t region,uint8_t *key,SF_Ctrl_AES_Key_Type keyType) + +{ + // WARNING: Could not recover jumptable at 0x4200c8c4. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a48)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Set_IV(uint8_t region,uint8_t *iv,uint32_t addrOffset) + +{ + // WARNING: Could not recover jumptable at 0x4200c8ce. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a4c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Set_IV_BE(uint8_t region,uint8_t *iv,uint32_t addrOffset) + +{ + // WARNING: Could not recover jumptable at 0x4200c8d8. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a50)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Enable(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c8e2. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a54)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Disable(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c8ec. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a58)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Set_Flash_Image_Offset(uint32_t addrOffset) + +{ + // WARNING: Could not recover jumptable at 0x4200c8f6. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a5c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t SF_Ctrl_Get_Flash_Image_Offset(void) + +{ + uint32_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c900. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010a60)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Select_Clock(SF_Ctrl_Sahb_Type sahbType) + +{ + // WARNING: Could not recover jumptable at 0x4200c90a. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a64)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_SendCmd(SF_Ctrl_Cmd_Cfg_Type *cfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c914. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a68)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Icache_Set(SF_Ctrl_Cmd_Cfg_Type *cfg,uint8_t cmdValid) + +{ + // WARNING: Could not recover jumptable at 0x4200c91e. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a6c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Icache2_Set(SF_Ctrl_Cmd_Cfg_Type *cfg,uint8_t cmdValid) + +{ + // WARNING: Could not recover jumptable at 0x4200c928. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a70)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Sts_Type SF_Ctrl_GetBusyState(void) + +{ + BL_Sts_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c932. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a74)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t SF_Ctrl_Is_AES_Enable(void) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c93c. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010a78)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t SF_Ctrl_Get_Clock_Delay(void) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c946. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010a7c)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Set_Clock_Delay(uint8_t delay) + +{ + // WARNING: Could not recover jumptable at 0x4200c950. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a80)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type XIP_SFlash_State_Save(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t *offset) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c95a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a84)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type XIP_SFlash_State_Restore(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t offset) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c964. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a88)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +XIP_SFlash_Erase_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t startaddr,uint32_t endaddr) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c96e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a8c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +XIP_SFlash_Write_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *data,uint32_t len) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c978. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a90)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +XIP_SFlash_Read_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *data,uint32_t len) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c982. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a94)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type XIP_SFlash_GetJedecId_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint8_t *data) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c98c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a98)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type XIP_SFlash_GetDeviceId_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint8_t *data) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c996. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a9c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +XIP_SFlash_GetUniqueId_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint8_t *data,uint8_t idLen) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c9a0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010aa0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type XIP_SFlash_Read_Via_Cache_Need_Lock(uint32_t addr,uint8_t *data,uint32_t len) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c9aa. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010aa4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int XIP_SFlash_Read_With_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *dst,int len) + +{ + int iVar1; + + // WARNING: Could not recover jumptable at 0x4200c9b4. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*_DAT_21010aa8)(); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int XIP_SFlash_Write_With_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *src,int len) + +{ + int iVar1; + + // WARNING: Could not recover jumptable at 0x4200c9be. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*_DAT_21010aac)(); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int XIP_SFlash_Erase_With_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,int len) + +{ + int iVar1; + + // WARNING: Could not recover jumptable at 0x4200c9c8. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*_DAT_21010ab0)(); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void XIP_SFlash_Opt_Enter(uint8_t *aesEnable) + +{ + // WARNING: Could not recover jumptable at 0x4200c9d2. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010ab4)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void XIP_SFlash_Opt_Exit(uint8_t aesEnable) + +{ + // WARNING: Could not recover jumptable at 0x4200c9dc. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010ab8)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t BFLB_Soft_CRC32(void *dataIn,uint32_t len) + +{ + uint32_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c9e6. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010abc)(); + return uVar1; +} + + + +// WARNING: Control flow encountered bad instruction data + +BL_Err_Type ADC_Trim_TSEN(uint16_t *tsen_offset) + +{ + Efuse_TSEN_Refcode_Corner_Type trim; + + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +// WARNING: Control flow encountered bad instruction data + +BL_Err_Type ADC_Gain_Trim(void) + +{ + uint uVar1; + uint8_t a; + undefined3 extraout_var; + Efuse_ADC_Gain_Coeff_Type EStack36; + Efuse_ADC_Gain_Coeff_Type trim; + + EF_Ctrl_Read_ADC_Gain_Trim(&EStack36); + if ((int)EStack36 << 0x12 < 0) { + uVar1 = (uint)EStack36 >> 0xc; + a = EF_Ctrl_Get_Trim_Parity((uint)EStack36 & 0xfff,'\f'); + _a = (SFtype)CONCAT31(extraout_var,a); + if ((SFtype)(uVar1 & 1) == _a) { + adcGainCoeffCal.adcGainCoeffEnable = ENABLE; + adcGainCoeffCal.adcgainCoeffVal = SUB42(EStack36,0) & 0xfff; + if (((uint)EStack36 & 0x800) == 0) { + __extendsfdf2(_a); + __muldf3(); + __subdf3(); + } + else { + __extendsfdf2(_a); + __muldf3(); + __adddf3(); + } + __truncdfsf2(); + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); + } + } + return ERROR; +} + + + +uint8_t EF_Ctrl_Get_Trim_Parity(uint32_t val,uint8_t len) + +{ + undefined3 in_register_0000202d; + uint uVar1; + byte bVar2; + + uVar1 = 0; + bVar2 = 0; + while ((uVar1 & 0xff) < CONCAT31(in_register_0000202d,len)) { + if ((1 << (uVar1 & 0x1f) & val) != 0) { + bVar2 = bVar2 + 1; + } + uVar1 = uVar1 + 1; + } + return (uint8_t)(bVar2 & 1); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Read_RC32M_Trim(Efuse_Ana_RC32M_Trim_Type *trim) + +{ + uint uVar1; + uint uVar2; + + EF_Ctrl_Sw_AHB_Clk_0(); + EF_Ctrl_Load_Efuse_R0(); + uVar1 = _DAT_4000700c; + uVar2 = _DAT_4000700c >> 10; + *(char *)trim = (char)uVar2; + *(uint *)trim = (uint)*trim & 0xfffffcff | uVar2 & 0x100 | uVar1 >> 10 & 0x200; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Read_RC32K_Trim(Efuse_Ana_RC32K_Trim_Type *trim) + +{ + EF_Ctrl_Sw_AHB_Clk_0(); + EF_Ctrl_Load_Efuse_R0(); + *(uint *)trim = + (uint)*trim & 0xfffff000 | _DAT_4000700c >> 0x14 & 0x3ff | _DAT_4000700c >> 0x14 & 0x400 | + (_DAT_4000700c >> 0x1f) << 0xb; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Read_TSEN_Trim(Efuse_TSEN_Refcode_Corner_Type *trim) + +{ + uint uVar1; + Efuse_TSEN_Refcode_Corner_Type EVar2; + uint uVar3; + uint uVar4; + + EF_Ctrl_Sw_AHB_Clk_0(); + EF_Ctrl_Load_Efuse_R0(); + uVar3 = (_DAT_40007078 & 1) << 0xd; + EVar2 = *trim; + *(uint *)trim = (uint)EVar2 & 0xffffdfff | uVar3; + uVar4 = _DAT_4000707c & 0xfff; + uVar1 = _DAT_4000707c & 0x1000; + *(uint *)trim = (uint)EVar2 & 0xffffc000 | uVar3 | uVar4 | uVar1; + *(uint *)trim = + (uint)EVar2 & 0xffff8000 | uVar3 | uVar4 | uVar1 | (_DAT_40007070 >> 0x1e & 1) << 0xe; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Read_ADC_Gain_Trim(Efuse_ADC_Gain_Coeff_Type *trim) + +{ + EF_Ctrl_Sw_AHB_Clk_0(); + EF_Ctrl_Load_Efuse_R0(); + *(uint *)trim = + (uint)*trim & 0xffffc000 | (_DAT_40007078 << 0x13) >> 0x14 | + (_DAT_40007078 >> 0xd & 1) << 0xc | (_DAT_40007078 >> 0xe & 1) << 0xd; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_On_MBG(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cd8e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010810)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_Off_MBG(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cd98. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010814)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_On_XTAL(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cda2. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010818)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Set_Xtal_CapCode(uint8_t capIn,uint8_t capOut) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cdac. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101081c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t AON_Get_Xtal_CapCode(void) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200cdb6. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010820)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_Off_XTAL(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cdc0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010824)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t EF_Ctrl_Get_Trim_Parity(uint32_t val,uint8_t len) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200cdca. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010888)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Read_RC32M_Trim(Efuse_Ana_RC32M_Trim_Type *trim) + +{ + // WARNING: Could not recover jumptable at 0x4200cdd4. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_2101088c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Read_RC32K_Trim(Efuse_Ana_RC32K_Trim_Type *trim) + +{ + // WARNING: Could not recover jumptable at 0x4200cdde. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010890)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +GLB_ROOT_CLK_Type GLB_Get_Root_CLK_Sel(void) + +{ + GLB_ROOT_CLK_Type GVar1; + + // WARNING: Could not recover jumptable at 0x4200cde8. Too many branches + // WARNING: Treating indirect jump as call + GVar1 = (*_DAT_21010898)(); + return GVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Set_System_CLK_Div(uint8_t hclkDiv,uint8_t bclkDiv) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cdf2. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101089c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t GLB_Get_BCLK_Div(void) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200cdfc. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_210108a0)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t GLB_Get_HCLK_Div(void) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200ce06. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_210108a4)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type Update_SystemCoreClockWith_XTAL(GLB_PLL_XTAL_Type xtalType) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce10. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108a8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Set_System_CLK(GLB_PLL_XTAL_Type xtalType,GLB_SYS_CLK_Type clkFreq) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce1a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108ac)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type System_Core_Clock_Update_From_RC32M(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce24. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108b0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Set_SF_CLK(uint8_t enable,GLB_SFLASH_CLK_Type clkSel,uint8_t div) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce2e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108b4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Set_PKA_CLK_Sel(GLB_PKA_CLK_Type clkSel) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce38. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108b8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_32K_Sel(HBN_32K_CLK_Type clkType) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce42. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010908)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_Type rootClk) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce4c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101090c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Power_On_Xtal_32K(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce56. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010910)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Power_Off_Xtal_32K(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce60. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010914)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Power_On_RC32K(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce6a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010918)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Power_Off_RC32K(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce74. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101091c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Trim_RC32K(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce7e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010920)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Trim_RC32M(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce88. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010954)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Select_RC32M_As_PLL_Ref(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce92. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010958)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Select_XTAL_As_PLL_Ref(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce9c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101095c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Power_On_PLL(PDS_PLL_XTAL_Type xtalType) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cea6. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010960)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Enable_PLL_All_Clks(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ceb0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010964)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Disable_PLL_All_Clks(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ceba. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010968)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Enable_PLL_Clk(PDS_PLL_CLK_Type pllClk) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cec4. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101096c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Disable_PLL_Clk(PDS_PLL_CLK_Type pllClk) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cece. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010970)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Power_Off_PLL(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ced8. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010974)(); + return BVar1; +} + + diff --git a/blobs/bl602_demo_at.ghidra.h b/blobs/bl602_demo_at.ghidra.h new file mode 100755 index 0000000..91e1bfe --- /dev/null +++ b/blobs/bl602_demo_at.ghidra.h @@ -0,0 +1,69201 @@ +typedef unsigned char undefined; + +typedef unsigned char bool; +typedef unsigned char byte; +typedef unsigned int dword; +typedef long long longlong; +typedef unsigned long long qword; +typedef unsigned char uchar; +typedef unsigned int uint; +typedef unsigned long ulong; +typedef unsigned long long ulonglong; +typedef unsigned char undefined1; +typedef unsigned short undefined2; +typedef unsigned int undefined3; +typedef unsigned int undefined4; +typedef unsigned long long undefined5; +typedef unsigned long long undefined6; +typedef unsigned long long undefined7; +typedef unsigned long long undefined8; +typedef unsigned short ushort; +typedef short wchar_t; +typedef unsigned short word; +#define unkbyte9 unsigned long long +#define unkbyte10 unsigned long long +#define unkbyte11 unsigned long long +#define unkbyte12 unsigned long long +#define unkbyte13 unsigned long long +#define unkbyte14 unsigned long long +#define unkbyte15 unsigned long long +#define unkbyte16 unsigned long long + +#define unkuint9 unsigned long long +#define unkuint10 unsigned long long +#define unkuint11 unsigned long long +#define unkuint12 unsigned long long +#define unkuint13 unsigned long long +#define unkuint14 unsigned long long +#define unkuint15 unsigned long long +#define unkuint16 unsigned long long + +#define unkint9 long long +#define unkint10 long long +#define unkint11 long long +#define unkint12 long long +#define unkint13 long long +#define unkint14 long long +#define unkint15 long long +#define unkint16 long long + +#define unkfloat1 float +#define unkfloat2 float +#define unkfloat3 float +#define unkfloat5 double +#define unkfloat6 double +#define unkfloat7 double +#define unkfloat9 long double +#define unkfloat11 long double +#define unkfloat12 long double +#define unkfloat13 long double +#define unkfloat14 long double +#define unkfloat15 long double +#define unkfloat16 long double + +#define BADSPACEBASE void +#define code void + +typedef void _IO_lock_t; + +typedef struct _IO_marker _IO_marker, *P_IO_marker; + +typedef struct _IO_FILE _IO_FILE, *P_IO_FILE; + +typedef long __off_t; + +typedef longlong __quad_t; + +typedef __quad_t __off64_t; + +typedef ulong size_t; + +struct _IO_FILE { + int _flags; + char * _IO_read_ptr; + char * _IO_read_end; + char * _IO_read_base; + char * _IO_write_base; + char * _IO_write_ptr; + char * _IO_write_end; + char * _IO_buf_base; + char * _IO_buf_end; + char * _IO_save_base; + char * _IO_backup_base; + char * _IO_save_end; + struct _IO_marker * _markers; + struct _IO_FILE * _chain; + int _fileno; + int _flags2; + __off_t _old_offset; + ushort _cur_column; + char _vtable_offset; + char _shortbuf[1]; + _IO_lock_t * _lock; + __off64_t _offset; + void * __pad1; + void * __pad2; + void * __pad3; + void * __pad4; + size_t __pad5; + int _mode; + char _unused2[15]; +}; + +struct _IO_marker { + struct _IO_marker * _next; + struct _IO_FILE * _sbuf; + int _pos; +}; + +typedef struct stat stat, *Pstat; + +typedef ulonglong __u_quad_t; + +typedef __u_quad_t __dev_t; + +typedef ulong __ino_t; + +typedef uint __mode_t; + +typedef uint __nlink_t; + +typedef uint __uid_t; + +typedef uint __gid_t; + +typedef long __blksize_t; + +typedef long __blkcnt_t; + +typedef struct timespec timespec, *Ptimespec; + +typedef long __time_t; + +struct timespec { + __time_t tv_sec; + long tv_nsec; +}; + +struct stat { + __dev_t st_dev; + ushort __pad1; + __ino_t st_ino; + __mode_t st_mode; + __nlink_t st_nlink; + __uid_t st_uid; + __gid_t st_gid; + __dev_t st_rdev; + ushort __pad2; + __off_t st_size; + __blksize_t st_blksize; + __blkcnt_t st_blocks; + struct timespec st_atim; + struct timespec st_mtim; + struct timespec st_ctim; + ulong __unused4; + ulong __unused5; +}; + +typedef struct _IO_FILE __FILE; + +typedef struct _IO_FILE FILE; + +typedef struct __locale_data __locale_data, *P__locale_data; + +struct __locale_data { +}; + +typedef struct __locale_struct __locale_struct, *P__locale_struct; + +struct __locale_struct { + struct __locale_data * __locales[13]; + ushort * __ctype_b; + int * __ctype_tolower; + int * __ctype_toupper; + char * __names[13]; +}; + +typedef struct __locale_struct * __locale_t; + +typedef int __ssize_t; + +typedef __ssize_t ssize_t; + +typedef int __pid_t; + +typedef struct __mbstate_t __mbstate_t, *P__mbstate_t; + +typedef union _union_27 _union_27, *P_union_27; + +union _union_27 { + uint __wch; + char __wchb[4]; +}; + +struct __mbstate_t { + int __count; + union _union_27 __value; +}; + +typedef struct __mbstate_t mbstate_t; + +typedef struct lconv lconv, *Plconv; + +struct lconv { + char * decimal_point; + char * thousands_sep; + char * grouping; + char * int_curr_symbol; + char * currency_symbol; + char * mon_decimal_point; + char * mon_thousands_sep; + char * mon_grouping; + char * positive_sign; + char * negative_sign; + char int_frac_digits; + char frac_digits; + char p_cs_precedes; + char p_sep_by_space; + char n_cs_precedes; + char n_sep_by_space; + char p_sign_posn; + char n_sign_posn; + char int_p_cs_precedes; + char int_p_sep_by_space; + char int_n_cs_precedes; + char int_n_sep_by_space; + char int_p_sign_posn; + char int_n_sign_posn; +}; + +typedef undefined complex long double[32]; + +typedef qword complex float; + +typedef undefined complex double[16]; + +typedef bool _Bool; + +typedef struct at_peer_t at_peer_t, *Pat_peer_t; + +typedef int at_di_t; + +typedef uchar at_hex_t; + +typedef uint at_hi_t; + +struct at_peer_t { + at_di_t link_id; + at_di_t state; + at_hex_t addr[6]; + undefined field_0xe; + undefined field_0xf; + at_di_t last_rx; + at_di_t last_tx; + at_di_t rx_drops; + at_di_t tx_drops; + at_di_t rx_pkts; + at_di_t tx_pkts; + at_di_t tx_errs; + at_di_t rate_mask; + at_di_t cur_rate_idx; + at_di_t cur_rate_ok; + at_di_t cur_rate_fail; + at_di_t tx_consec_fail; + at_hi_t rx_seqnum; + at_hi_t rx_seqnum_mc; + at_di_t rx_rssi; + at_di_t rx_rateidx; + at_di_t setprot; + at_di_t listen_interval; + at_hi_t capinfo; +}; + +typedef struct at_status_t at_status_t, *Pat_status_t; + +typedef char at_text_t; + +typedef uchar at_ip_t[4]; + +struct at_status_t { + at_text_t version[32]; + at_di_t reset_reason; + at_di_t conf_flag; + at_di_t system_uptime; + at_di_t system_sleeptime; + at_di_t gpio_enable; + at_di_t captiveportal; + at_di_t wifi_state; + at_hex_t wifi_bssid[6]; + undefined field_0x42; + undefined field_0x43; + at_di_t wifi_aid; + at_di_t wifi_channelnum; + at_hi_t wifi_sup_rate_mask; + at_hi_t wifi_bas_rate_mask; + at_hi_t wifi_chan_activity2; + at_di_t wifi_max_tx_power; + at_di_t wifi_reg_country; + at_di_t wifi_dtim_period; + at_di_t wifi_sleeping; + at_di_t wifi_num_assoc; + at_ip_t ip_ipaddr; + at_ip_t ip_netmask; + at_ip_t ip_gw; + at_ip_t ip_dns; + at_di_t ip_sock_open; + at_di_t ip_sockd_port; + at_di_t free_heap; + at_di_t min_heap; + at_di_t current_time; +}; + +typedef struct send_data_ctx send_data_ctx, *Psend_data_ctx; + +typedef uchar uint8_t; + +struct send_data_ctx { + int linkId; + uint8_t * buf; +}; + +typedef enum KE_EVENT_STATUS { + KE_EVENT_ALREADY_EXISTS=4, + KE_EVENT_CAPA_EXCEEDED=3, + KE_EVENT_FAIL=1, + KE_EVENT_OK=0, + KE_EVENT_UNKNOWN=2 +} KE_EVENT_STATUS; + +typedef struct rx_msg_struct rx_msg_struct, *Prx_msg_struct; + +typedef ushort uint16_t; + +struct rx_msg_struct { + uint8_t pkt_type; + uint16_t src_id; + uint8_t * param; + uint8_t param_len; +}; + +typedef struct ble_ke_event_env_tag ble_ke_event_env_tag, *Pble_ke_event_env_tag; + +typedef ulong uint32_t; + +typedef void (* p_callback_t)(void); + +struct ble_ke_event_env_tag { + uint32_t event_field; + p_callback_t callback[10]; + uint8_t state; + undefined field_0x2d; + undefined field_0x2e; + undefined field_0x2f; +}; + +typedef struct ke_evt_tag ke_evt_tag, *Pke_evt_tag; + +struct ke_evt_tag { + void (* func)(int); + int param; +}; + +typedef struct cipher_key_buf cipher_key_buf, *Pcipher_key_buf; + +typedef struct cipher_key_buf cipher_key_buf_t; + +typedef struct cipher_key_t cipher_key_t, *Pcipher_key_t; + +typedef union ckd ckd, *Pckd; + +typedef struct eapolHskData_t eapolHskData_t, *PeapolHskData_t; + +typedef uchar UINT8; + +typedef struct KeyData_t KeyData_t, *PKeyData_t; + +typedef ulong UINT32; + +typedef ushort UINT16; + +struct KeyData_t { + UINT8 Key[16]; + UINT8 RxMICKey[8]; + UINT8 TxMICKey[8]; + UINT32 TxIV32; + UINT16 TxIV16; + UINT16 KeyIndex; +}; + +struct eapolHskData_t { + UINT8 ANonce[32]; + struct KeyData_t pwsKeyData; +}; + +union ckd { + struct eapolHskData_t hskData; +}; + +struct cipher_key_t { + union ckd ckd; +}; + +struct cipher_key_buf { + struct cipher_key_t cipher_key; +}; + +typedef void * __gnuc_va_list; + +typedef __gnuc_va_list va_list; + +typedef struct bt_dev bt_dev, *Pbt_dev; + +typedef struct bt_addr_le_t bt_addr_le_t, *Pbt_addr_le_t; + +typedef uint8_t u8_t; + +typedef uint16_t u16_t; + +typedef struct k_work k_work, *Pk_work; + +typedef int atomic_t; + +typedef struct bt_dev_le bt_dev_le, *Pbt_dev_le; + +typedef struct k_sem k_sem, *Pk_sem; + +typedef struct net_buf net_buf, *Pnet_buf; + +typedef struct k_fifo k_fifo, *Pk_fifo; + +typedef struct bt_hci_driver bt_hci_driver, *Pbt_hci_driver; + +typedef struct bt_addr_t bt_addr_t, *Pbt_addr_t; + +typedef ulonglong u64_t; + +typedef struct bl_hdl_t bl_hdl_t, *Pbl_hdl_t; + +typedef struct bl_hdl_t _sem_t; + +typedef struct _dnode _dnode, *P_dnode; + +typedef struct _dnode sys_dlist_t; + +typedef union anon_union_for_field_0 anon_union_for_field_0, *Panon_union_for_field_0; + +typedef union anon_union_for_field_4 anon_union_for_field_4, *Panon_union_for_field_4; + +typedef struct k_queue k_queue, *Pk_queue; + +typedef enum bt_hci_driver_bus { + BT_HCI_DRIVER_BUS_I2C=8, + BT_HCI_DRIVER_BUS_IPM=9, + BT_HCI_DRIVER_BUS_PCCARD=2, + BT_HCI_DRIVER_BUS_PCI=5, + BT_HCI_DRIVER_BUS_RS232=4, + BT_HCI_DRIVER_BUS_SDIO=6, + BT_HCI_DRIVER_BUS_SPI=7, + BT_HCI_DRIVER_BUS_UART=3, + BT_HCI_DRIVER_BUS_USB=1, + BT_HCI_DRIVER_BUS_VIRTUAL=0 +} bt_hci_driver_bus; + +typedef uint u32_t.conflict; + + +// WARNING! conflicting data type names: /DWARF/dlist.h/_dnode/anon_union_for_field_0 - /DWARF/buf.h/net_buf/anon_union_for_field_0 + +typedef union anon_union_for_field_1 anon_union_for_field_1, *Panon_union_for_field_1; + +typedef struct _snode _snode, *P_snode; + +typedef struct _snode sys_snode_t; + +typedef struct anon_struct.conflict24 anon_struct.conflict24, *Panon_struct.conflict24; + +typedef struct net_buf_simple net_buf_simple, *Pnet_buf_simple; + +union anon_union_for_field_1 { + struct _dnode * tail; + struct _dnode * prev; +}; + +struct _dnode { + union anon_union_for_field_0 field_0; + union anon_union_for_field_1 field_1; +}; + +struct k_queue { + void * hdl; + sys_dlist_t poll_events; +}; + +struct k_fifo { + struct k_queue _queue; +}; + +struct k_work { + void * _reserved; + void (* handler)(struct k_work *); + atomic_t flags[1]; +}; + +struct bl_hdl_t { + void * hdl; +}; + +struct k_sem { + _sem_t sem; + sys_dlist_t poll_events; +}; + +struct bt_dev_le { + u8_t features[8]; + u64_t states; + u16_t mtu; + undefined field_0x12; + undefined field_0x13; + struct k_sem pkts; + u8_t rl_size; + u8_t rl_entries; + u8_t wl_size; + u8_t wl_entries; + undefined field_0x24; + undefined field_0x25; + undefined field_0x26; + undefined field_0x27; +}; + +struct bt_addr_t { + u8_t val[6]; +}; + +struct bt_addr_le_t { + u8_t type; + struct bt_addr_t a; +}; + +struct bt_dev { + struct bt_addr_le_t id_addr[1]; + u8_t id_count; + u8_t adv_id; + struct bt_addr_le_t random_addr; + u8_t hci_version; + u8_t lmp_version; + u16_t hci_revision; + u16_t lmp_subversion; + u16_t manufacturer; + u8_t features[1][8]; + u8_t supported_commands[64]; + struct k_work init; + atomic_t flags[1]; + struct bt_dev_le le; + struct k_sem ncmd_sem; + struct net_buf * sent_cmd; + struct k_fifo cmd_tx_queue; + struct bt_hci_driver * drv; + char name[30]; + undefined field_0xd6; + undefined field_0xd7; +}; + +struct _snode { + struct _snode * next; +}; + +union anon_union_for_field_0 { + sys_snode_t node; +}; + +struct anon_struct.conflict24 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +struct net_buf_simple { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +union anon_union_for_field_4 { + struct anon_struct.conflict24 field_0; + struct net_buf_simple b; +}; + +struct net_buf { + union anon_union_for_field_0 field_0; + u8_t ref; + u8_t flags; + u8_t pool_id; + undefined field_0x7; + union anon_union_for_field_4 field_4; + u8_t user_data[10]; + undefined field_0x1e; + undefined field_0x1f; +}; + +struct bt_hci_driver { + char * name; + enum bt_hci_driver_bus bus; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + u32_t.conflict quirks; + int (* open)(void); + int (* send)(struct net_buf *); +}; + +typedef struct stats_mem stats_mem, *Pstats_mem; + +typedef u16_t mem_size_t; + +struct stats_mem { + u16_t err; + mem_size_t avail; + mem_size_t used; + mem_size_t max; + u16_t illegal; +}; + +typedef struct stats_proto stats_proto, *Pstats_proto; + +struct stats_proto { + u16_t xmit; + u16_t recv; + u16_t fw; + u16_t drop; + u16_t chkerr; + u16_t lenerr; + u16_t memerr; + u16_t rterr; + u16_t proterr; + u16_t opterr; + u16_t err; + u16_t cachehit; +}; + +typedef struct stats_ stats_, *Pstats_; + +typedef struct stats_igmp stats_igmp, *Pstats_igmp; + +typedef struct stats_sys stats_sys, *Pstats_sys; + +typedef struct stats_syselem stats_syselem, *Pstats_syselem; + +struct stats_igmp { + u16_t xmit; + u16_t recv; + u16_t drop; + u16_t chkerr; + u16_t lenerr; + u16_t memerr; + u16_t proterr; + u16_t rx_v1; + u16_t rx_group; + u16_t rx_general; + u16_t rx_report; + u16_t tx_join; + u16_t tx_leave; + u16_t tx_report; +}; + +struct stats_syselem { + u16_t used; + u16_t max; + u16_t err; +}; + +struct stats_sys { + struct stats_syselem sem; + struct stats_syselem mutex; + struct stats_syselem mbox; +}; + +struct stats_ { + struct stats_proto link; + struct stats_proto etharp; + struct stats_proto ip; + struct stats_proto icmp; + struct stats_igmp igmp; + struct stats_proto udp; + struct stats_proto tcp; + struct stats_mem mem; + undefined field_0xb6; + undefined field_0xb7; + struct stats_mem * memp[15]; + struct stats_sys sys; + undefined field_0x106; + undefined field_0x107; +}; + +typedef struct event_handler event_handler, *Pevent_handler; + +struct event_handler { + u8_t event; + u8_t min_len; + undefined field_0x2; + undefined field_0x3; + void (* handler)(struct net_buf *); +}; + +typedef struct bt_ad bt_ad, *Pbt_ad; + +typedef struct bt_data bt_data, *Pbt_data; + + +// WARNING! conflicting data type names: /DWARF/stddef.h/size_t - /stddef.h/size_t + +struct bt_data { + u8_t type; + u8_t data_len; + undefined field_0x2; + undefined field_0x3; + u8_t * data; +}; + +struct bt_ad { + struct bt_data * data; + size_t len; +}; + +typedef struct cmd_data cmd_data, *Pcmd_data; + +typedef struct cmd_state_set cmd_state_set, *Pcmd_state_set; + +struct cmd_data { + u8_t status; + undefined field_0x1; + u16_t opcode; + struct cmd_state_set * state; + struct k_sem * sync; +}; + +struct cmd_state_set { + atomic_t * target; + int bit; + _Bool val; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct acl_data acl_data, *Pacl_data; + +struct acl_data { + u8_t type; + u8_t id; + u16_t handle; +}; + +typedef uchar uint8; + +typedef short SINT16; + +typedef enum Status_e { + FAIL=1, + FW_SUCCESS=0 +} Status_e; + +typedef long SINT32; + +typedef enum wlan_security_type { + WLAN_SECURITY_EAP_TLS=6, + WLAN_SECURITY_NONE=0, + WLAN_SECURITY_WEP_OPEN=1, + WLAN_SECURITY_WEP_SHARED=2, + WLAN_SECURITY_WILDCARD=7, + WLAN_SECURITY_WPA=3, + WLAN_SECURITY_WPA2=4, + WLAN_SECURITY_WPA_WPA2_MIXED=5 +} wlan_security_type; + +typedef char CHAR; + +typedef ushort uint16; + +typedef char SINT8; + +typedef void mdev_t; + +typedef ulong uint32; + +typedef ulonglong UINT64; + +typedef int BOOLEAN; + +typedef enum lld_util_instant_action { + LLD_UTIL_CHMAP_UPDATE=2, + LLD_UTIL_NO_ACTION=0, + LLD_UTIL_PARAM_UPDATE=1 +} lld_util_instant_action; + +typedef struct sha256_state sha256_state, *Psha256_state; + +struct sha256_state { + UINT64 length; + UINT32 state[8]; + UINT32 curlen; + UINT8 buf[64]; + undefined field_0x6c; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef enum nl80211_auth_type { + NL80211_AUTHTYPE_AUTOMATIC=8, + NL80211_AUTHTYPE_FILS_PK=7, + NL80211_AUTHTYPE_FILS_SK=5, + NL80211_AUTHTYPE_FILS_SK_PFS=6, + NL80211_AUTHTYPE_FT=2, + NL80211_AUTHTYPE_MAX=7, + NL80211_AUTHTYPE_NETWORK_EAP=3, + NL80211_AUTHTYPE_OPEN_SYSTEM=0, + NL80211_AUTHTYPE_SAE=4, + NL80211_AUTHTYPE_SHARED_KEY=1, + __NL80211_AUTHTYPE_NUM=8 +} nl80211_auth_type; + +typedef enum nl80211_dfs_state { + NL80211_DFS_AVAILABLE=2, + NL80211_DFS_UNAVAILABLE=1, + NL80211_DFS_USABLE=0 +} nl80211_dfs_state; + +typedef enum nl80211_bss_select_attr { + NL80211_BSS_SELECT_ATTR_BAND_PREF=2, + NL80211_BSS_SELECT_ATTR_MAX=3, + NL80211_BSS_SELECT_ATTR_RSSI=1, + NL80211_BSS_SELECT_ATTR_RSSI_ADJUST=3, + __NL80211_BSS_SELECT_ATTR_AFTER_LAST=4, + __NL80211_BSS_SELECT_ATTR_INVALID=0 +} nl80211_bss_select_attr; + +typedef enum nl80211_band { + NL80211_BAND_2GHZ=0, + NL80211_BAND_5GHZ=1, + NL80211_BAND_60GHZ=2, + NUM_NL80211_BANDS=3 +} nl80211_band; + +typedef enum nl80211_mfp { + NL80211_MFP_NO=0, + NL80211_MFP_REQUIRED=1 +} nl80211_mfp; + +typedef enum nl80211_iftype { + NL80211_IFTYPE_ADHOC=1, + NL80211_IFTYPE_AP=3, + NL80211_IFTYPE_AP_VLAN=4, + NL80211_IFTYPE_MAX=12, + NL80211_IFTYPE_MESH_POINT=7, + NL80211_IFTYPE_MONITOR=6, + NL80211_IFTYPE_NAN=12, + NL80211_IFTYPE_OCB=11, + NL80211_IFTYPE_P2P_CLIENT=8, + NL80211_IFTYPE_P2P_DEVICE=10, + NL80211_IFTYPE_P2P_GO=9, + NL80211_IFTYPE_STATION=2, + NL80211_IFTYPE_UNSPECIFIED=0, + NL80211_IFTYPE_WDS=5, + NUM_NL80211_IFTYPES=13 +} nl80211_iftype; + +typedef struct rw_task_msg_t rw_task_msg_t, *Prw_task_msg_t; + +struct rw_task_msg_t { + uint8_t msg_type; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + void * params; +}; + +typedef struct rwip_eif_api rwip_eif_api, *Prwip_eif_api; + +struct rwip_eif_api { + void (* read)(uint8_t *, uint32_t, void (* )(void *, uint8_t), void *); + void (* write)(uint8_t *, uint32_t, void (* )(void *, uint8_t), void *); + void (* flow_on)(void); + _Bool (* flow_off)(void); +}; + +typedef struct rwip_rf_api.conflict1 rwip_rf_api.conflict1, *Prwip_rf_api.conflict1; + +typedef char int8_t; + +struct rwip_rf_api.conflict1 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef enum prevent_sleep { + RW_AHI_TIMEOUT=8, + RW_CRYPT_ONGOING=16, + RW_CSB_NOT_LPO_ALLOWED=64, + RW_DELETE_ELT_ONGOING=32, + RW_MWS_WLAN_EVENT_GENERATOR_ACTIVE=-128, + RW_TL_RX_ONGOING=4, + RW_TL_TX_ONGOING=2, + RW_WAKE_UP_ONGOING=1 +} prevent_sleep; + +typedef struct rwip_prio rwip_prio, *Prwip_prio; + +struct rwip_prio { + uint8_t value; + uint8_t increment; +}; + +typedef struct rwip_rf_api.conflict rwip_rf_api.conflict, *Prwip_rf_api.conflict; + +struct rwip_rf_api.conflict { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef enum rwip_eif_types { + RWIP_EIF_AHI=2, + RWIP_EIF_HCIC=0, + RWIP_EIF_HCIH=1 +} rwip_eif_types; + +typedef struct rwip_rf_api rwip_rf_api, *Prwip_rf_api; + +struct rwip_rf_api { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict2 rwip_rf_api.conflict2, *Prwip_rf_api.conflict2; + +struct rwip_rf_api.conflict2 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef enum rw_task_msg_type { + FW_TO_FW_MSG=2, + HOST_TO_FW_MSG=1 +} rw_task_msg_type; + +typedef struct rwip_time_t rwip_time_t, *Prwip_time_t; + +struct rwip_time_t { + uint32_t time; + uint32_t next_tick; +}; + +typedef struct rwip_env_tag rwip_env_tag, *Prwip_env_tag; + +struct rwip_env_tag { + uint32_t lp_cycle_wakeup_delay; + uint32_t sleep_acc_error; + uint16_t sleep_algo_dur; + uint16_t prevent_sleep; + _Bool sleep_enable; + _Bool ext_wakeup_enable; + undefined field_0xe; + undefined field_0xf; +}; + +typedef enum HBN_PIR_HPF_Type { + HBN_PIR_HPF_METHOD0=0, + HBN_PIR_HPF_METHOD1=1, + HBN_PIR_HPF_METHOD2=2 +} HBN_PIR_HPF_Type; + +typedef enum HBN_OUT0_INT_Type { + HBN_OUT0_INT_GPIO7=0, + HBN_OUT0_INT_GPIO8=1, + HBN_OUT0_INT_RTC=2 +} HBN_OUT0_INT_Type; + +typedef enum HBN_XCLK_CLK_Type { + HBN_XCLK_CLK_RC32M=0, + HBN_XCLK_CLK_XTAL=1 +} HBN_XCLK_CLK_Type; + +typedef enum HBN_BOR_THRES_Type { + HBN_BOR_THRES_2P0V=0, + HBN_BOR_THRES_2P4V=1 +} HBN_BOR_THRES_Type; + +typedef struct HBN_APP_CFG_Type HBN_APP_CFG_Type, *PHBN_APP_CFG_Type; + +typedef enum HBN_GPIO_INT_Trigger_Type { + HBN_GPIO_INT_TRIGGER_ASYNC_FALLING_EDGE=4, + HBN_GPIO_INT_TRIGGER_ASYNC_HIGH_LEVEL=7, + HBN_GPIO_INT_TRIGGER_ASYNC_LOW_LEVEL=6, + HBN_GPIO_INT_TRIGGER_ASYNC_RISING_EDGE=5, + HBN_GPIO_INT_TRIGGER_SYNC_FALLING_EDGE=0, + HBN_GPIO_INT_TRIGGER_SYNC_HIGH_LEVEL=3, + HBN_GPIO_INT_TRIGGER_SYNC_LOW_LEVEL=2, + HBN_GPIO_INT_TRIGGER_SYNC_RISING_EDGE=1 +} HBN_GPIO_INT_Trigger_Type; + +typedef struct SPI_Flash_Cfg_Type SPI_Flash_Cfg_Type, *PSPI_Flash_Cfg_Type; + +typedef enum HBN_LEVEL_Type { + HBN_LEVEL_0=0, + HBN_LEVEL_1=1, + HBN_LEVEL_2=2, + HBN_LEVEL_3=3 +} HBN_LEVEL_Type; + +typedef enum HBN_LDO_LEVEL_Type { + HBN_LDO_LEVEL_0P60V=0, + HBN_LDO_LEVEL_0P65V=1, + HBN_LDO_LEVEL_0P70V=2, + HBN_LDO_LEVEL_0P75V=3, + HBN_LDO_LEVEL_0P80V=4, + HBN_LDO_LEVEL_0P85V=5, + HBN_LDO_LEVEL_0P90V=6, + HBN_LDO_LEVEL_0P95V=7, + HBN_LDO_LEVEL_1P00V=8, + HBN_LDO_LEVEL_1P05V=9, + HBN_LDO_LEVEL_1P10V=10, + HBN_LDO_LEVEL_1P15V=11, + HBN_LDO_LEVEL_1P20V=12, + HBN_LDO_LEVEL_1P25V=13, + HBN_LDO_LEVEL_1P30V=14, + HBN_LDO_LEVEL_1P35V=15 +} HBN_LDO_LEVEL_Type; + +struct HBN_APP_CFG_Type { + uint8_t useXtal32k; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + uint32_t sleepTime; + uint8_t gpioWakeupSrc; + enum HBN_GPIO_INT_Trigger_Type gpioTrigType; + undefined field_0xa; + undefined field_0xb; + struct SPI_Flash_Cfg_Type * flashCfg; + enum HBN_LEVEL_Type hbnLevel; + enum HBN_LDO_LEVEL_Type ldoLevel; + undefined field_0x12; + undefined field_0x13; +}; + +struct SPI_Flash_Cfg_Type { + uint8_t ioMode; + uint8_t cReadSupport; + uint8_t clkDelay; + uint8_t clkInvert; + uint8_t resetEnCmd; + uint8_t resetCmd; + uint8_t resetCreadCmd; + uint8_t resetCreadCmdSize; + uint8_t jedecIdCmd; + uint8_t jedecIdCmdDmyClk; + uint8_t qpiJedecIdCmd; + uint8_t qpiJedecIdCmdDmyClk; + uint8_t sectorSize; + uint8_t mid; + uint16_t pageSize; + uint8_t chipEraseCmd; + uint8_t sectorEraseCmd; + uint8_t blk32EraseCmd; + uint8_t blk64EraseCmd; + uint8_t writeEnableCmd; + uint8_t pageProgramCmd; + uint8_t qpageProgramCmd; + uint8_t qppAddrMode; + uint8_t fastReadCmd; + uint8_t frDmyClk; + uint8_t qpiFastReadCmd; + uint8_t qpiFrDmyClk; + uint8_t fastReadDoCmd; + uint8_t frDoDmyClk; + uint8_t fastReadDioCmd; + uint8_t frDioDmyClk; + uint8_t fastReadQoCmd; + uint8_t frQoDmyClk; + uint8_t fastReadQioCmd; + uint8_t frQioDmyClk; + uint8_t qpiFastReadQioCmd; + uint8_t qpiFrQioDmyClk; + uint8_t qpiPageProgramCmd; + uint8_t writeVregEnableCmd; + uint8_t wrEnableIndex; + uint8_t qeIndex; + uint8_t busyIndex; + uint8_t wrEnableBit; + uint8_t qeBit; + uint8_t busyBit; + uint8_t wrEnableWriteRegLen; + uint8_t wrEnableReadRegLen; + uint8_t qeWriteRegLen; + uint8_t qeReadRegLen; + uint8_t releasePowerDown; + uint8_t busyReadRegLen; + uint8_t readRegCmd[4]; + uint8_t writeRegCmd[4]; + uint8_t enterQpi; + uint8_t exitQpi; + uint8_t cReadMode; + uint8_t cRExit; + uint8_t burstWrapCmd; + uint8_t burstWrapCmdDmyClk; + uint8_t burstWrapDataMode; + uint8_t burstWrapData; + uint8_t deBurstWrapCmd; + uint8_t deBurstWrapCmdDmyClk; + uint8_t deBurstWrapDataMode; + uint8_t deBurstWrapData; + uint16_t timeEsector; + uint16_t timeE32k; + uint16_t timeE64k; + uint16_t timePagePgm; + uint16_t timeCe; + uint8_t pdDelay; + uint8_t qeData; +}; + +typedef struct HBN_BOR_CFG_Type HBN_BOR_CFG_Type, *PHBN_BOR_CFG_Type; + +struct HBN_BOR_CFG_Type { + uint8_t enableBor; + uint8_t enableBorInt; + uint8_t borThreshold; + uint8_t enablePorInBor; +}; + +typedef enum HBN_PIR_LPF_Type { + HBN_PIR_LPF_DIV1=0, + HBN_PIR_LPF_DIV2=1 +} HBN_PIR_LPF_Type; + +typedef struct HBN_PIR_INT_CFG_Type HBN_PIR_INT_CFG_Type, *PHBN_PIR_INT_CFG_Type; + +typedef enum BL_Fun_Type { + DISABLE=0, + ENABLE=1 +} BL_Fun_Type; + +struct HBN_PIR_INT_CFG_Type { + enum BL_Fun_Type lowIntEn; + enum BL_Fun_Type highIntEn; +}; + +typedef enum HBN_32K_CLK_Type { + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1 +} HBN_32K_CLK_Type; + +typedef enum HBN_ROOT_CLK_Type { + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1 +} HBN_ROOT_CLK_Type; + +typedef enum HBN_UART_CLK_Type { + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0 +} HBN_UART_CLK_Type; + +typedef enum HBN_INT_Type { + HBN_INT_ACOMP0=20, + HBN_INT_ACOMP1=22, + HBN_INT_BOR=18, + HBN_INT_GPIO7=0, + HBN_INT_GPIO8=1, + HBN_INT_PIR=17, + HBN_INT_RTC=16 +} HBN_INT_Type; + +typedef enum HBN_OUT1_INT_Type { + HBN_OUT1_INT_ACOMP0=2, + HBN_OUT1_INT_ACOMP1=3, + HBN_OUT1_INT_BOR=1, + HBN_OUT1_INT_PIR=0 +} HBN_OUT1_INT_Type; + +typedef enum HBN_BOR_MODE_Type { + HBN_BOR_MODE_POR_INDEPENDENT=0, + HBN_BOR_MODE_POR_RELEVANT=1 +} HBN_BOR_MODE_Type; + +typedef enum HBN_RTC_INT_Delay_Type { + HBN_RTC_INT_DELAY_0T=1, + HBN_RTC_INT_DELAY_32T=0 +} HBN_RTC_INT_Delay_Type; + +typedef enum llm_msg_id { + LLM_ECC_RESULT_IND=6, + LLM_ENC_IND=5, + LLM_ENC_REQ=4, + LLM_GEN_CHNL_CLS_CMD=8, + LLM_LE_CHNL_ASSESS_TIMER=7, + LLM_LE_ENH_PRIV_ADDR_RENEW_TIMER=9, + LLM_LE_SET_HOST_CH_CLASS_CMD_STO=0, + LLM_LE_SET_HOST_CH_CLASS_REQ=2, + LLM_LE_SET_HOST_CH_CLASS_REQ_IND=3, + LLM_STOP_IND=1 +} llm_msg_id; + +typedef struct llm_enc_req llm_enc_req, *Pllm_enc_req; + +typedef struct ltk ltk, *Pltk; + +struct ltk { + uint8_t ltk[16]; +}; + +struct llm_enc_req { + struct ltk key; + uint8_t plain_data[16]; +}; + +typedef struct llm_enc_ind llm_enc_ind, *Pllm_enc_ind; + +struct llm_enc_ind { + uint8_t status; + uint8_t encrypted_data[16]; +}; + +typedef enum llm_state_id { + LLM_ADV_STATE_MASK=-16, + LLM_COEXT_ADVERTISING_IDLE=16, + LLM_COEXT_ADVERTISING_INITIATING=18, + LLM_COEXT_ADVERTISING_SCANNING=17, + LLM_COEXT_ADVERTISING_STOPPING=19, + LLM_COEXT_IDLE_IDLE=0, + LLM_COEXT_IDLE_INITIATING=2, + LLM_COEXT_IDLE_SCANNING=1, + LLM_COEXT_IDLE_STOPPING=3, + LLM_COEXT_STOPPING_IDLE=32, + LLM_COEXT_STOPPING_INITIATING=34, + LLM_COEXT_STOPPING_SCANNING=33, + LLM_COEXT_STOPPING_STOPPING=35, + LLM_SCAN_INIT_STATE_MASK=15, + LLM_STATE_MAX=37, + LLM_TEST=36 +} llm_state_id; + +typedef enum flag.conflict { + FL_INV=2, + FL_MINUS=8, + FL_SPLAT=1, + FL_WIDTH=4 +} flag.conflict; + +typedef enum bail { + bail_eof=1, + bail_err=2, + bail_none=0 +} bail; + +typedef enum ranks.conflict { + rank_char=-2, + rank_int=0, + rank_long=1, + rank_longlong=2, + rank_ptr=2147483647, + rank_short=-1 +} ranks.conflict; + +typedef enum anon_enum_8 { + st_flags=1, + st_match=5, + st_match_init=4, + st_match_range=6, + st_modifiers=3, + st_normal=0, + st_width=2 +} anon_enum_8; + +typedef struct anon_struct.conflict579 anon_struct.conflict579, *Panon_struct.conflict579; + +struct anon_struct.conflict579 { + uint frac0:32; + uint frac1:20; + uint exp:11; + uint sign:1; +}; + +typedef union _FP_UNION_D _FP_UNION_D, *P_FP_UNION_D; + +typedef double DFtype; + +union _FP_UNION_D { + DFtype flt; + struct anon_struct.conflict579 bits; +}; + +typedef struct _romfs_file_buf _romfs_file_buf, *P_romfs_file_buf; + +struct _romfs_file_buf { + char * buf; + uint32_t bufsize; +}; + +typedef struct _romfs_file_buf romfs_filebuf_t; + +typedef struct bt_hci_cp_le_set_scan_param bt_hci_cp_le_set_scan_param, *Pbt_hci_cp_le_set_scan_param; + +struct bt_hci_cp_le_set_scan_param { + u8_t scan_type; + u16_t interval; + u16_t window; + u8_t addr_type; + u8_t filter_policy; +}; + +typedef struct bt_hci_evt_num_completed_packets bt_hci_evt_num_completed_packets, *Pbt_hci_evt_num_completed_packets; + +typedef struct bt_hci_handle_count bt_hci_handle_count, *Pbt_hci_handle_count; + +struct bt_hci_evt_num_completed_packets { + u8_t num_handles; + struct bt_hci_handle_count[0] h; +}; + +struct bt_hci_handle_count { + u16_t handle; + u16_t count; +}; + +typedef struct bt_hci_cp_le_rem_dev_from_wl bt_hci_cp_le_rem_dev_from_wl, *Pbt_hci_cp_le_rem_dev_from_wl; + +struct bt_hci_cp_le_rem_dev_from_wl { + struct bt_addr_le_t addr; +}; + +typedef struct bt_hci_cp_le_write_default_data_len bt_hci_cp_le_write_default_data_len, *Pbt_hci_cp_le_write_default_data_len; + +struct bt_hci_cp_le_write_default_data_len { + u16_t max_tx_octets; + u16_t max_tx_time; +}; + +typedef struct bt_hci_cp_le_start_encryption bt_hci_cp_le_start_encryption, *Pbt_hci_cp_le_start_encryption; + +struct bt_hci_cp_le_start_encryption { + u16_t handle; + u64_t rand; + u16_t ediv; + u8_t ltk[16]; +}; + +typedef struct bt_hci_evt_encrypt_change bt_hci_evt_encrypt_change, *Pbt_hci_evt_encrypt_change; + +struct bt_hci_evt_encrypt_change { + u8_t status; + u16_t handle; + u8_t encrypt; +}; + +typedef struct bt_hci_rp_le_read_wl_size bt_hci_rp_le_read_wl_size, *Pbt_hci_rp_le_read_wl_size; + +struct bt_hci_rp_le_read_wl_size { + u8_t status; + u8_t wl_size; +}; + +typedef struct bt_hci_rp_read_encryption_key_size bt_hci_rp_read_encryption_key_size, *Pbt_hci_rp_read_encryption_key_size; + +struct bt_hci_rp_read_encryption_key_size { + u8_t status; + u16_t handle; + u8_t key_size; +}; + +typedef struct hci_cp_le_conn_update hci_cp_le_conn_update, *Phci_cp_le_conn_update; + +struct hci_cp_le_conn_update { + u16_t handle; + u16_t conn_interval_min; + u16_t conn_interval_max; + u16_t conn_latency; + u16_t supervision_timeout; + u16_t min_ce_len; + u16_t max_ce_len; +}; + +typedef struct bt_hci_evt_disconn_complete bt_hci_evt_disconn_complete, *Pbt_hci_evt_disconn_complete; + +struct bt_hci_evt_disconn_complete { + u8_t status; + u16_t handle; + u8_t reason; +}; + +typedef struct bt_hci_evt_le_conn_update_complete bt_hci_evt_le_conn_update_complete, *Pbt_hci_evt_le_conn_update_complete; + +struct bt_hci_evt_le_conn_update_complete { + u8_t status; + u16_t handle; + u16_t interval; + u16_t latency; + u16_t supv_timeout; +}; + +typedef struct bt_hci_evt_le_remote_feat_complete bt_hci_evt_le_remote_feat_complete, *Pbt_hci_evt_le_remote_feat_complete; + +struct bt_hci_evt_le_remote_feat_complete { + u8_t status; + u16_t handle; + u8_t features[8]; +}; + +typedef struct bt_hci_cp_read_encryption_key_size bt_hci_cp_read_encryption_key_size, *Pbt_hci_cp_read_encryption_key_size; + +struct bt_hci_cp_read_encryption_key_size { + u16_t handle; +}; + +typedef struct bt_hci_cmd_hdr bt_hci_cmd_hdr, *Pbt_hci_cmd_hdr; + +struct bt_hci_cmd_hdr { + u16_t opcode; + u8_t param_len; +}; + +typedef struct bt_hci_rp_le_read_local_features bt_hci_rp_le_read_local_features, *Pbt_hci_rp_le_read_local_features; + +struct bt_hci_rp_le_read_local_features { + u8_t status; + u8_t features[8]; +}; + +typedef struct bt_hci_rp_le_read_max_data_len bt_hci_rp_le_read_max_data_len, *Pbt_hci_rp_le_read_max_data_len; + +struct bt_hci_rp_le_read_max_data_len { + u8_t status; + u16_t max_tx_octets; + u16_t max_tx_time; + u16_t max_rx_octets; + u16_t max_rx_time; +}; + +typedef struct bt_hci_rp_read_supported_commands bt_hci_rp_read_supported_commands, *Pbt_hci_rp_read_supported_commands; + +struct bt_hci_rp_read_supported_commands { + u8_t status; + u8_t commands[64]; +}; + +typedef struct bt_hci_evt_le_conn_complete bt_hci_evt_le_conn_complete, *Pbt_hci_evt_le_conn_complete; + +struct bt_hci_evt_le_conn_complete { + u8_t status; + u16_t handle; + u8_t role; + struct bt_addr_le_t peer_addr; + u16_t interval; + u16_t latency; + u16_t supv_timeout; + u8_t clock_accuracy; +}; + +typedef struct bt_hci_evt_le_generate_dhkey_complete bt_hci_evt_le_generate_dhkey_complete, *Pbt_hci_evt_le_generate_dhkey_complete; + +struct bt_hci_evt_le_generate_dhkey_complete { + u8_t status; + u8_t dhkey[32]; +}; + +typedef struct bt_hci_evt_hdr bt_hci_evt_hdr, *Pbt_hci_evt_hdr; + +struct bt_hci_evt_hdr { + u8_t evt; + u8_t len; +}; + +typedef struct bt_hci_evt_data_buf_overflow bt_hci_evt_data_buf_overflow, *Pbt_hci_evt_data_buf_overflow; + +struct bt_hci_evt_data_buf_overflow { + u8_t link_type; +}; + +typedef struct bt_hci_rp_le_read_rl_size bt_hci_rp_le_read_rl_size, *Pbt_hci_rp_le_read_rl_size; + +struct bt_hci_rp_le_read_rl_size { + u8_t status; + u8_t rl_size; +}; + +typedef struct bt_hci_evt_encrypt_key_refresh_complete bt_hci_evt_encrypt_key_refresh_complete, *Pbt_hci_evt_encrypt_key_refresh_complete; + +struct bt_hci_evt_encrypt_key_refresh_complete { + u8_t status; + u16_t handle; +}; + +typedef struct bt_hci_cp_le_set_event_mask bt_hci_cp_le_set_event_mask, *Pbt_hci_cp_le_set_event_mask; + +struct bt_hci_cp_le_set_event_mask { + u8_t events[8]; +}; + +typedef struct bt_hci_cp_le_conn_param_req_reply bt_hci_cp_le_conn_param_req_reply, *Pbt_hci_cp_le_conn_param_req_reply; + +struct bt_hci_cp_le_conn_param_req_reply { + u16_t handle; + u16_t interval_min; + u16_t interval_max; + u16_t latency; + u16_t timeout; + u16_t min_ce_len; + u16_t max_ce_len; +}; + +typedef struct bt_hci_rp_le_read_buffer_size bt_hci_rp_le_read_buffer_size, *Pbt_hci_rp_le_read_buffer_size; + +struct bt_hci_rp_le_read_buffer_size { + u8_t status; + u16_t le_max_len; + u8_t le_max_num; +}; + +typedef struct bt_hci_cp_disconnect bt_hci_cp_disconnect, *Pbt_hci_cp_disconnect; + +struct bt_hci_cp_disconnect { + u16_t handle; + u8_t reason; +}; + +typedef struct bt_hci_cp_le_set_host_chan_classif bt_hci_cp_le_set_host_chan_classif, *Pbt_hci_cp_le_set_host_chan_classif; + +struct bt_hci_cp_le_set_host_chan_classif { + u8_t ch_map[5]; +}; + +typedef struct bt_hci_cp_le_ltk_req_reply bt_hci_cp_le_ltk_req_reply, *Pbt_hci_cp_le_ltk_req_reply; + +struct bt_hci_cp_le_ltk_req_reply { + u16_t handle; + u8_t ltk[16]; +}; + +typedef struct bt_hci_rp_read_local_version_info bt_hci_rp_read_local_version_info, *Pbt_hci_rp_read_local_version_info; + +struct bt_hci_rp_read_local_version_info { + u8_t status; + u8_t hci_version; + u16_t hci_revision; + u8_t lmp_version; + u16_t manufacturer; + u16_t lmp_subversion; +}; + +typedef struct bt_hci_evt_cmd_complete bt_hci_evt_cmd_complete, *Pbt_hci_evt_cmd_complete; + +struct bt_hci_evt_cmd_complete { + u8_t ncmd; + u16_t opcode; +}; + +typedef struct bt_hci_evt_le_conn_param_req bt_hci_evt_le_conn_param_req, *Pbt_hci_evt_le_conn_param_req; + +struct bt_hci_evt_le_conn_param_req { + u16_t handle; + u16_t interval_min; + u16_t interval_max; + u16_t latency; + u16_t timeout; +}; + +typedef struct bt_hci_cp_le_create_conn bt_hci_cp_le_create_conn, *Pbt_hci_cp_le_create_conn; + +struct bt_hci_cp_le_create_conn { + u16_t scan_interval; + u16_t scan_window; + u8_t filter_policy; + struct bt_addr_le_t peer_addr; + u8_t own_addr_type; + u16_t conn_interval_min; + u16_t conn_interval_max; + u16_t conn_latency; + u16_t supervision_timeout; + u16_t min_ce_len; + u16_t max_ce_len; +}; + +typedef struct bt_hci_cp_le_set_data_len bt_hci_cp_le_set_data_len, *Pbt_hci_cp_le_set_data_len; + +struct bt_hci_cp_le_set_data_len { + u16_t handle; + u16_t tx_octets; + u16_t tx_time; +}; + +typedef struct bt_hci_cp_read_rssi bt_hci_cp_read_rssi, *Pbt_hci_cp_read_rssi; + +struct bt_hci_cp_read_rssi { + u16_t handle; +}; + +typedef struct bt_hci_cp_le_read_remote_features bt_hci_cp_le_read_remote_features, *Pbt_hci_cp_le_read_remote_features; + +struct bt_hci_cp_le_read_remote_features { + u16_t handle; +}; + +typedef struct bt_hci_evt_le_ltk_request bt_hci_evt_le_ltk_request, *Pbt_hci_evt_le_ltk_request; + +struct bt_hci_evt_le_ltk_request { + u16_t handle; + u64_t rand; + u16_t ediv; +}; + +typedef struct bt_hci_rp_read_rssi bt_hci_rp_read_rssi, *Pbt_hci_rp_read_rssi; + +typedef int8_t s8_t; + +struct bt_hci_rp_read_rssi { + u8_t status; + u16_t handle; + s8_t rssi; +}; + +typedef struct bt_hci_evt_le_enh_conn_complete bt_hci_evt_le_enh_conn_complete, *Pbt_hci_evt_le_enh_conn_complete; + +struct bt_hci_evt_le_enh_conn_complete { + u8_t status; + u16_t handle; + u8_t role; + struct bt_addr_le_t peer_addr; + struct bt_addr_t local_rpa; + struct bt_addr_t peer_rpa; + u16_t interval; + u16_t latency; + u16_t supv_timeout; + u8_t clock_accuracy; +}; + +typedef struct bt_hci_cp_write_le_host_supp bt_hci_cp_write_le_host_supp, *Pbt_hci_cp_write_le_host_supp; + +struct bt_hci_cp_write_le_host_supp { + u8_t le; + u8_t simul; +}; + +typedef struct bt_hci_evt_cmd_status bt_hci_evt_cmd_status, *Pbt_hci_evt_cmd_status; + +struct bt_hci_evt_cmd_status { + u8_t status; + u8_t ncmd; + u16_t opcode; +}; + +typedef struct bt_hci_evt_le_meta_event bt_hci_evt_le_meta_event, *Pbt_hci_evt_le_meta_event; + +struct bt_hci_evt_le_meta_event { + u8_t subevent; +}; + +typedef struct bt_hci_cp_le_set_privacy_mode bt_hci_cp_le_set_privacy_mode, *Pbt_hci_cp_le_set_privacy_mode; + +struct bt_hci_cp_le_set_privacy_mode { + struct bt_addr_le_t id_addr; + u8_t mode; +}; + +typedef struct bt_hci_evt_le_p256_public_key_complete bt_hci_evt_le_p256_public_key_complete, *Pbt_hci_evt_le_p256_public_key_complete; + +struct bt_hci_evt_le_p256_public_key_complete { + u8_t status; + u8_t key[64]; +}; + +typedef struct bt_hci_rp_read_bd_addr bt_hci_rp_read_bd_addr, *Pbt_hci_rp_read_bd_addr; + +struct bt_hci_rp_read_bd_addr { + u8_t status; + struct bt_addr_t bdaddr; +}; + +typedef struct bt_hci_cp_le_add_dev_to_rl bt_hci_cp_le_add_dev_to_rl, *Pbt_hci_cp_le_add_dev_to_rl; + +struct bt_hci_cp_le_add_dev_to_rl { + struct bt_addr_le_t peer_id_addr; + u8_t peer_irk[16]; + u8_t local_irk[16]; +}; + +typedef struct bt_hci_rp_le_rand bt_hci_rp_le_rand, *Pbt_hci_rp_le_rand; + +struct bt_hci_rp_le_rand { + u8_t status; + u8_t rand[8]; +}; + +typedef struct bt_hci_cp_le_rem_dev_from_rl bt_hci_cp_le_rem_dev_from_rl, *Pbt_hci_cp_le_rem_dev_from_rl; + +struct bt_hci_cp_le_rem_dev_from_rl { + struct bt_addr_le_t peer_id_addr; +}; + +typedef struct bt_hci_evt_le_advertising_info bt_hci_evt_le_advertising_info, *Pbt_hci_evt_le_advertising_info; + +struct bt_hci_evt_le_advertising_info { + u8_t evt_type; + struct bt_addr_le_t addr; + u8_t length; + u8_t[0] data; +}; + +typedef struct bt_hci_cp_le_add_dev_to_wl bt_hci_cp_le_add_dev_to_wl, *Pbt_hci_cp_le_add_dev_to_wl; + +struct bt_hci_cp_le_add_dev_to_wl { + struct bt_addr_le_t addr; +}; + +typedef struct bt_hci_cp_le_ltk_req_neg_reply bt_hci_cp_le_ltk_req_neg_reply, *Pbt_hci_cp_le_ltk_req_neg_reply; + +struct bt_hci_cp_le_ltk_req_neg_reply { + u16_t handle; +}; + +typedef struct bt_hci_cp_le_conn_param_req_neg_reply bt_hci_cp_le_conn_param_req_neg_reply, *Pbt_hci_cp_le_conn_param_req_neg_reply; + +struct bt_hci_cp_le_conn_param_req_neg_reply { + u16_t handle; + u8_t reason; +}; + +typedef struct bt_hci_rp_read_local_features bt_hci_rp_read_local_features, *Pbt_hci_rp_read_local_features; + +struct bt_hci_rp_read_local_features { + u8_t status; + u8_t features[8]; +}; + +typedef struct bt_hci_cp_le_set_adv_param bt_hci_cp_le_set_adv_param, *Pbt_hci_cp_le_set_adv_param; + +struct bt_hci_cp_le_set_adv_param { + u16_t min_interval; + u16_t max_interval; + u8_t type; + u8_t own_addr_type; + struct bt_addr_le_t direct_addr; + u8_t channel_map; + u8_t filter_policy; +}; + +typedef struct bt_hci_cp_le_set_scan_rsp_data bt_hci_cp_le_set_scan_rsp_data, *Pbt_hci_cp_le_set_scan_rsp_data; + +struct bt_hci_cp_le_set_scan_rsp_data { + u8_t len; + u8_t data[31]; +}; + +typedef struct bt_hci_cp_le_set_adv_data bt_hci_cp_le_set_adv_data, *Pbt_hci_cp_le_set_adv_data; + +struct bt_hci_cp_le_set_adv_data { + u8_t len; + u8_t data[31]; +}; + +typedef struct bt_hci_cp_le_generate_dhkey bt_hci_cp_le_generate_dhkey, *Pbt_hci_cp_le_generate_dhkey; + +struct bt_hci_cp_le_generate_dhkey { + u8_t key[64]; +}; + +typedef struct bt_hci_cp_le_set_scan_enable bt_hci_cp_le_set_scan_enable, *Pbt_hci_cp_le_set_scan_enable; + +struct bt_hci_cp_le_set_scan_enable { + u8_t enable; + u8_t filter_dup; +}; + +typedef struct bt_hci_cp_set_event_mask bt_hci_cp_set_event_mask, *Pbt_hci_cp_set_event_mask; + +struct bt_hci_cp_set_event_mask { + u8_t events[8]; +}; + +typedef struct bt_hci_acl_hdr bt_hci_acl_hdr, *Pbt_hci_acl_hdr; + +struct bt_hci_acl_hdr { + u16_t handle; + u16_t len; +}; + +typedef struct bt_hci_rp_le_read_supp_states bt_hci_rp_le_read_supp_states, *Pbt_hci_rp_le_read_supp_states; + +struct bt_hci_rp_le_read_supp_states { + u8_t status; + u8_t le_states[8]; +}; + +typedef struct bt_hci_rp_read_buffer_size bt_hci_rp_read_buffer_size, *Pbt_hci_rp_read_buffer_size; + +struct bt_hci_rp_read_buffer_size { + u8_t status; + u16_t acl_max_len; + u8_t sco_max_len; + u16_t acl_max_num; + u16_t sco_max_num; +}; + +typedef struct machw_mib_tag machw_mib_tag, *Pmachw_mib_tag; + +struct machw_mib_tag { + uint32_t dot11_wep_excluded_count; + uint32_t dot11_fcs_error_count; + uint32_t nx_rx_phy_error_count; + uint32_t nx_rd_fifo_overflow_count; + uint32_t nx_tx_underun_count; + uint32_t reserved_1[7]; + uint32_t nx_qos_utransmitted_mpdu_count[8]; + uint32_t nx_qos_gtransmitted_mpdu_count[8]; + uint32_t dot11_qos_failed_count[8]; + uint32_t dot11_qos_retry_count[8]; + uint32_t dot11_qos_rts_success_count[8]; + uint32_t dot11_qos_rts_failure_count[8]; + uint32_t nx_qos_ack_failure_count[8]; + uint32_t nx_qos_ureceived_mpdu_count[8]; + uint32_t nx_qos_greceived_mpdu_count[8]; + uint32_t nx_qos_ureceived_other_mpdu[8]; + uint32_t dot11_qos_retries_received_count[8]; + uint32_t nx_utransmitted_amsdu_count[8]; + uint32_t nx_gtransmitted_amsdu_count[8]; + uint32_t dot11_failed_amsdu_count[8]; + uint32_t dot11_retry_amsdu_count[8]; + uint32_t dot11_transmitted_octets_in_amsdu[8]; + uint32_t dot11_amsdu_ack_failure_count[8]; + uint32_t nx_ureceived_amsdu_count[8]; + uint32_t nx_greceived_amsdu_count[8]; + uint32_t nx_ureceived_other_amsdu[8]; + uint32_t dot11_received_octets_in_amsdu_count[8]; + uint32_t reserved_2[24]; + uint32_t dot11_transmitted_ampdu_count; + uint32_t dot11_transmitted_mpdus_in_ampdu_count; + uint32_t dot11_transmitted_octets_in_ampdu_count; + uint32_t wnlu_ampdu_received_count; + uint32_t nx_gampdu_received_count; + uint32_t nx_other_ampdu_received_count; + uint32_t dot11_mpdu_in_received_ampdu_count; + uint32_t dot11_received_octets_in_ampdu_count; + uint32_t dot11_ampdu_delimiter_crc_error_count; + uint32_t dot11_implicit_bar_failure_count; + uint32_t dot11_explicit_bar_failure_count; + uint32_t reserved_3[5]; + uint32_t dot11_20mhz_frame_transmitted_count; + uint32_t dot11_40mhz_frame_transmitted_count; + uint32_t dot11_20mhz_frame_received_count; + uint32_t dot11_40mhz_frame_received_count; + uint32_t nx_failed_40mhz_txop; + uint32_t nx_successful_txops; + uint32_t reserved_4[4]; + uint32_t dot11_dualcts_success_count; + uint32_t dot11_stbc_cts_success_count; + uint32_t dot11_stbc_cts_failure_count; + uint32_t dot11_non_stbc_cts_success_count; + uint32_t dot11_non_stbc_cts_failure_count; +}; + +typedef enum SEC_ENG_AES_ID_Type { + SEC_ENG_AES_ID0=0 +} SEC_ENG_AES_ID_Type; + +typedef struct SEC_Eng_SHA256_Link_Ctx SEC_Eng_SHA256_Link_Ctx, *PSEC_Eng_SHA256_Link_Ctx; + +struct SEC_Eng_SHA256_Link_Ctx { + uint32_t total[2]; + uint32_t * shaBuf; + uint32_t * shaPadding; + uint32_t linkAddr; +}; + +typedef enum SEC_ENG_AES_Key_Type { + SEC_ENG_AES_DOUBLE_KEY_128BITS=3, + SEC_ENG_AES_KEY_128BITS=0, + SEC_ENG_AES_KEY_192BITS=2, + SEC_ENG_AES_KEY_256BITS=1 +} SEC_ENG_AES_Key_Type; + +typedef struct SEC_Eng_SHA_Link_Config_Type SEC_Eng_SHA_Link_Config_Type, *PSEC_Eng_SHA_Link_Config_Type; + +struct SEC_Eng_SHA_Link_Config_Type { + uint32_t shaMode:3; + uint32_t shaHashSel:1; + uint32_t shaIntClr:1; + uint32_t shaIntSet:1; + uint32_t shaMsgLen:16; + uint32_t shaSrcAddr; + uint32_t result[8]; +}; + +typedef struct SEC_Eng_SHA256_Ctx SEC_Eng_SHA256_Ctx, *PSEC_Eng_SHA256_Ctx; + +struct SEC_Eng_SHA256_Ctx { + uint32_t total[2]; + uint32_t * shaBuf; + uint32_t * shaPadding; + uint8_t shaFeed; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct SEC_Eng_SHA_Link_Config_Type.conflict SEC_Eng_SHA_Link_Config_Type.conflict, *PSEC_Eng_SHA_Link_Config_Type.conflict; + +struct SEC_Eng_SHA_Link_Config_Type.conflict { + uint32_t shaMode:3; + uint32_t shaHashSel:1; + uint32_t shaIntClr:1; + uint32_t shaIntSet:1; + uint32_t shaMsgLen:16; + uint32_t shaSrcAddr; + uint32_t result[8]; +}; + +typedef enum SEC_ENG_SHA_Type { + SEC_ENG_SHA1=2, + SEC_ENG_SHA1_RSVD=3, + SEC_ENG_SHA224=1, + SEC_ENG_SHA256=0 +} SEC_ENG_SHA_Type; + +typedef enum SEC_ENG_PKA_OP_Type { + SEC_ENG_PKA_OP_CFLIRI_BUFFER=54, + SEC_ENG_PKA_OP_CFLIR_BUFFER=56, + SEC_ENG_PKA_OP_CLIR=53, + SEC_ENG_PKA_OP_CTLIRI_PLD=55, + SEC_ENG_PKA_OP_CTLIR_PLD=57, + SEC_ENG_PKA_OP_LADD=24, + SEC_ENG_PKA_OP_LCMP=25, + SEC_ENG_PKA_OP_LDIV=20, + SEC_ENG_PKA_OP_LDIV2N=18, + SEC_ENG_PKA_OP_LMUL=22, + SEC_ENG_PKA_OP_LMUL2N=19, + SEC_ENG_PKA_OP_LSQR=21, + SEC_ENG_PKA_OP_LSUB=23, + SEC_ENG_PKA_OP_MADD=40, + SEC_ENG_PKA_OP_MDIV2=33, + SEC_ENG_PKA_OP_MEXP=35, + SEC_ENG_PKA_OP_MINV=34, + SEC_ENG_PKA_OP_MMUL=37, + SEC_ENG_PKA_OP_MOD2N=17, + SEC_ENG_PKA_OP_MOVDAT=50, + SEC_ENG_PKA_OP_MREM=38, + SEC_ENG_PKA_OP_MSQR=36, + SEC_ENG_PKA_OP_MSUB=39, + SEC_ENG_PKA_OP_NLIR=51, + SEC_ENG_PKA_OP_PPSEL=0, + SEC_ENG_PKA_OP_RESIZE=49, + SEC_ENG_PKA_OP_SLIR=52 +} SEC_ENG_PKA_OP_Type; + +typedef enum SEC_ENG_AES_Key_Src_Type { + SEC_ENG_AES_KEY_HW=1, + SEC_ENG_AES_KEY_SW=0 +} SEC_ENG_AES_Key_Src_Type; + +typedef struct SEC_Eng_AES_Ctx SEC_Eng_AES_Ctx, *PSEC_Eng_AES_Ctx; + +typedef enum SEC_ENG_AES_Type { + SEC_ENG_AES_CBC=2, + SEC_ENG_AES_CTR=1, + SEC_ENG_AES_ECB=0 +} SEC_ENG_AES_Type; + +struct SEC_Eng_AES_Ctx { + uint8_t aesFeed; + enum SEC_ENG_AES_Type mode; +}; + +typedef enum SEC_ENG_AES_EnDec_Type { + SEC_ENG_AES_DECRYPTION=1, + SEC_ENG_AES_ENCRYPTION=0 +} SEC_ENG_AES_EnDec_Type; + +typedef struct SEC_Eng_SHA_Link_Config_Type.conflict2 SEC_Eng_SHA_Link_Config_Type.conflict2, *PSEC_Eng_SHA_Link_Config_Type.conflict2; + +struct SEC_Eng_SHA_Link_Config_Type.conflict2 { + uint32_t shaMode:3; + uint32_t shaHashSel:1; + uint32_t shaIntClr:1; + uint32_t shaIntSet:1; + uint32_t shaMsgLen:16; + uint32_t shaSrcAddr; + uint32_t result[8]; +}; + +typedef enum SEC_ENG_SHA_ID_Type { + SEC_ENG_SHA_ID0=0 +} SEC_ENG_SHA_ID_Type; + +typedef struct SEC_Eng_SHA_Link_Config_Type.conflict1 SEC_Eng_SHA_Link_Config_Type.conflict1, *PSEC_Eng_SHA_Link_Config_Type.conflict1; + +struct SEC_Eng_SHA_Link_Config_Type.conflict1 { + uint32_t shaMode:3; + uint32_t shaHashSel:1; + uint32_t shaIntClr:1; + uint32_t shaIntSet:1; + uint32_t shaMsgLen:16; + uint32_t shaSrcAddr; + uint32_t result[8]; +}; + +typedef enum SEC_ENG_AES_Counter_Type { + SEC_ENG_AES_COUNTER_BYTE_1=1, + SEC_ENG_AES_COUNTER_BYTE_2=2, + SEC_ENG_AES_COUNTER_BYTE_3=3, + SEC_ENG_AES_COUNTER_BYTE_4=0 +} SEC_ENG_AES_Counter_Type; + +typedef enum SEC_ENG_PKA_REG_SIZE_Type { + SEC_ENG_PKA_REG_SIZE_128=6, + SEC_ENG_PKA_REG_SIZE_16=2, + SEC_ENG_PKA_REG_SIZE_192=7, + SEC_ENG_PKA_REG_SIZE_256=8, + SEC_ENG_PKA_REG_SIZE_32=3, + SEC_ENG_PKA_REG_SIZE_384=9, + SEC_ENG_PKA_REG_SIZE_512=10, + SEC_ENG_PKA_REG_SIZE_64=4, + SEC_ENG_PKA_REG_SIZE_8=1, + SEC_ENG_PKA_REG_SIZE_96=5 +} SEC_ENG_PKA_REG_SIZE_Type; + +typedef enum SEC_ENG_INT_Type { + SEC_ENG_INT_AES=1, + SEC_ENG_INT_ALL=6, + SEC_ENG_INT_CDET=4, + SEC_ENG_INT_GMAC=5, + SEC_ENG_INT_PKA=3, + SEC_ENG_INT_SHA=2, + SEC_ENG_INT_TRNG=0 +} SEC_ENG_INT_Type; + +typedef struct ip4_addr ip4_addr, *Pip4_addr; + +typedef struct ip4_addr ip4_addr_t; + +typedef ip4_addr_t ip_addr_t; + +typedef uint32_t u32_t; + +struct ip4_addr { + u32_t addr; +}; + +typedef enum lwip_ip_addr_type { + IPADDR_TYPE_ANY=46, + IPADDR_TYPE_V4=0, + IPADDR_TYPE_V6=6 +} lwip_ip_addr_type; + +typedef struct pka0_pldi_cfg pka0_pldi_cfg, *Ppka0_pldi_cfg; + +typedef union anon_union_for_value anon_union_for_value, *Panon_union_for_value; + +typedef struct anon_struct.conflict576 anon_struct.conflict576, *Panon_struct.conflict576; + +struct anon_struct.conflict576 { + uint32_t rsvd:12; + uint32_t d_reg_index:8; + uint32_t d_reg_type:4; + uint32_t op:7; + uint32_t last_op:1; +}; + +union anon_union_for_value { + struct anon_struct.conflict576 BF; + uint32_t WORD; +}; + +struct pka0_pldi_cfg { + union anon_union_for_value value; +}; + +typedef struct dbg_mem_write_req dbg_mem_write_req, *Pdbg_mem_write_req; + +struct dbg_mem_write_req { + uint32_t memaddr; + uint32_t memdata; +}; + +typedef struct dbg_set_sev_filter_req dbg_set_sev_filter_req, *Pdbg_set_sev_filter_req; + +struct dbg_set_sev_filter_req { + uint32_t sev_filter; +}; + +typedef struct dbg_mem_read_req dbg_mem_read_req, *Pdbg_mem_read_req; + +struct dbg_mem_read_req { + uint32_t memaddr; +}; + +typedef struct dbg_mem_write_cfm dbg_mem_write_cfm, *Pdbg_mem_write_cfm; + +struct dbg_mem_write_cfm { + uint32_t memaddr; + uint32_t memdata; +}; + +typedef struct dbg_get_sys_stat_cfm dbg_get_sys_stat_cfm, *Pdbg_get_sys_stat_cfm; + +struct dbg_get_sys_stat_cfm { + uint32_t cpu_sleep_time; + uint32_t doze_time; + uint32_t stats_time; +}; + +typedef struct dbg_mem_read_cfm dbg_mem_read_cfm, *Pdbg_mem_read_cfm; + +struct dbg_mem_read_cfm { + uint32_t memaddr; + uint32_t memdata; +}; + +typedef struct dbg_set_mod_filter_req dbg_set_mod_filter_req, *Pdbg_set_mod_filter_req; + +struct dbg_set_mod_filter_req { + uint32_t mod_filter; +}; + +typedef enum dbg_msg_tag { + DBG_ERROR_IND=1032, + DBG_GET_SYS_STAT_CFM=1034, + DBG_GET_SYS_STAT_REQ=1033, + DBG_MAX=1035, + DBG_MEM_READ_CFM=1025, + DBG_MEM_READ_REQ=1024, + DBG_MEM_WRITE_CFM=1027, + DBG_MEM_WRITE_REQ=1026, + DBG_SET_MOD_FILTER_CFM=1029, + DBG_SET_MOD_FILTER_REQ=1028, + DBG_SET_SEV_FILTER_CFM=1031, + DBG_SET_SEV_FILTER_REQ=1030, + DBG_SYS_STAT_TIMER=1035 +} dbg_msg_tag; + +typedef enum mbedtls_pk_type_t { + MBEDTLS_PK_ECDSA=4, + MBEDTLS_PK_ECKEY=2, + MBEDTLS_PK_ECKEY_DH=3, + MBEDTLS_PK_NONE=0, + MBEDTLS_PK_RSA=1, + MBEDTLS_PK_RSASSA_PSS=6, + MBEDTLS_PK_RSA_ALT=5 +} mbedtls_pk_type_t; + +typedef struct mbedtls_pk_info_t mbedtls_pk_info_t, *Pmbedtls_pk_info_t; + +typedef enum mbedtls_md_type_t { + MBEDTLS_MD_MD2=1, + MBEDTLS_MD_MD4=2, + MBEDTLS_MD_MD5=3, + MBEDTLS_MD_NONE=0, + MBEDTLS_MD_RIPEMD160=9, + MBEDTLS_MD_SHA1=4, + MBEDTLS_MD_SHA224=5, + MBEDTLS_MD_SHA256=6, + MBEDTLS_MD_SHA384=7, + MBEDTLS_MD_SHA512=8 +} mbedtls_md_type_t; + +typedef struct mbedtls_pk_debug_item mbedtls_pk_debug_item, *Pmbedtls_pk_debug_item; + +typedef enum mbedtls_pk_debug_type { + MBEDTLS_PK_DEBUG_ECP=2, + MBEDTLS_PK_DEBUG_MPI=1, + MBEDTLS_PK_DEBUG_NONE=0 +} mbedtls_pk_debug_type; + +struct mbedtls_pk_debug_item { + enum mbedtls_pk_debug_type type; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + char * name; + void * value; +}; + +struct mbedtls_pk_info_t { + enum mbedtls_pk_type_t type; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + char * name; + size_t (* get_bitlen)(void *); + int (* can_do)(enum mbedtls_pk_type_t); + int (* verify_func)(void *, enum mbedtls_md_type_t, uchar *, size_t, uchar *, size_t); + int (* sign_func)(void *, enum mbedtls_md_type_t, uchar *, size_t, uchar *, size_t *, int (* )(void *, uchar *, size_t), void *); + int (* decrypt_func)(void *, uchar *, size_t, uchar *, size_t *, size_t, int (* )(void *, uchar *, size_t), void *); + int (* encrypt_func)(void *, uchar *, size_t, uchar *, size_t *, size_t, int (* )(void *, uchar *, size_t), void *); + int (* check_pair_func)(void *, void *); + void * (* ctx_alloc_func)(void); + void (* ctx_free_func)(void *); + void (* debug_func)(void *, struct mbedtls_pk_debug_item *); +}; + +typedef struct mbedtls_pk_context mbedtls_pk_context, *Pmbedtls_pk_context; + +struct mbedtls_pk_context { + struct mbedtls_pk_info_t * pk_info; + void * pk_ctx; +}; + +typedef struct mbedtls_pk_rsassa_pss_options mbedtls_pk_rsassa_pss_options, *Pmbedtls_pk_rsassa_pss_options; + +struct mbedtls_pk_rsassa_pss_options { + enum mbedtls_md_type_t mgf1_hash_id; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + int expected_salt_len; +}; + +typedef struct bt_gatt_discover_params.conflict bt_gatt_discover_params.conflict, *Pbt_gatt_discover_params.conflict; + +typedef struct bt_conn bt_conn, *Pbt_conn; + +typedef struct bt_gatt_attr bt_gatt_attr, *Pbt_gatt_attr; + + +// WARNING! conflicting data type names: /DWARF/types.h/ssize_t - /types.h/ssize_t + +typedef struct bt_gatt_discover_params bt_gatt_discover_params, *Pbt_gatt_discover_params; + +typedef struct bt_att_req.conflict3 bt_att_req.conflict3, *Pbt_att_req.conflict3; + +typedef struct bt_uuid bt_uuid, *Pbt_uuid; + +typedef enum bt_security_t { + BT_SECURITY_FIPS=4, + BT_SECURITY_FORCE_PAIR=-128, + BT_SECURITY_HIGH=3, + BT_SECURITY_L0=0, + BT_SECURITY_L1=1, + BT_SECURITY_L2=2, + BT_SECURITY_L3=3, + BT_SECURITY_L4=4, + BT_SECURITY_LOW=1, + BT_SECURITY_MEDIUM=2, + BT_SECURITY_NONE=0 +} bt_security_t; + +typedef enum bt_conn_state_t { + BT_CONN_CONNECT=3, + BT_CONN_CONNECTED=4, + BT_CONN_CONNECT_DIR_ADV=2, + BT_CONN_CONNECT_SCAN=1, + BT_CONN_DISCONNECT=5, + BT_CONN_DISCONNECTED=0 +} bt_conn_state_t; + +typedef struct _slist _slist, *P_slist; + +typedef struct _slist sys_slist_t; + +typedef struct k_delayed_work k_delayed_work, *Pk_delayed_work; + +typedef union anon_union_for_field_20 anon_union_for_field_20, *Panon_union_for_field_20; + +typedef struct bt_att_req.conflict2 bt_att_req.conflict2, *Pbt_att_req.conflict2; + +typedef union anon_union_for_field_3 anon_union_for_field_3, *Panon_union_for_field_3; + +typedef void (* bt_att_destroy_t)(void *); + +typedef struct net_buf_simple_state net_buf_simple_state, *Pnet_buf_simple_state; + +typedef struct k_work_q k_work_q, *Pk_work_q; + +typedef struct k_timer k_timer, *Pk_timer; + +typedef struct k_timer k_timer_t; + +typedef struct bt_conn_le bt_conn_le, *Pbt_conn_le; + +typedef struct anon_struct.conflict496 anon_struct.conflict496, *Panon_struct.conflict496; + +typedef struct bl_hdl_t bl_timer_t; + +typedef struct bt_keys bt_keys, *Pbt_keys; + +typedef struct bt_ltk bt_ltk, *Pbt_ltk; + +typedef struct bt_irk bt_irk, *Pbt_irk; + +typedef struct bt_csrk bt_csrk, *Pbt_csrk; + +struct bt_irk { + u8_t val[16]; + struct bt_addr_t rpa; +}; + +struct bt_ltk { + u8_t rand[8]; + u8_t ediv[2]; + u8_t val[16]; +}; + +struct bt_csrk { + u8_t val[16]; + u32_t.conflict cnt; +}; + +struct bt_keys { + u8_t id; + struct bt_addr_le_t addr; + u8_t enc_size; + u8_t flags; + u16_t keys; + struct bt_ltk ltk; + struct bt_irk irk; + struct bt_csrk local_csrk; + struct bt_csrk remote_csrk; + struct bt_ltk slave_ltk; + undefined field_0x7e; + undefined field_0x7f; + u32_t.conflict aging_counter; +}; + +struct net_buf_simple_state { + u16_t offset; + u16_t len; +}; + +struct bt_att_req.conflict3 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_attr { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +struct bt_att_req.conflict2 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct anon_struct.conflict496 { + u16_t attr_handle; + u16_t start_handle; + u16_t end_handle; +}; + +union anon_union_for_field_3 { + struct anon_struct.conflict496 _included; + u16_t start_handle; +}; + +struct bt_gatt_discover_params.conflict { + struct bt_att_req.conflict3 _req; + struct bt_uuid * uuid; + u8_t (* func)(struct bt_conn *, struct bt_gatt_attr *, struct bt_gatt_discover_params *); + union anon_union_for_field_3 field_3; + u16_t end_handle; + u8_t type; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +struct k_timer { + bl_timer_t timer; + void (* handler)(void *); + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +struct k_delayed_work { + struct k_work work; + struct k_work_q * work_q; + k_timer_t timer; +}; + +struct _slist { + sys_snode_t * head; + sys_snode_t * tail; +}; + +struct bt_conn_le { + struct bt_addr_le_t dst; + struct bt_addr_le_t init_addr; + struct bt_addr_le_t resp_addr; + undefined field_0x15; + u16_t interval; + u16_t interval_min; + u16_t interval_max; + u16_t latency; + u16_t timeout; + u16_t pending_latency; + u16_t pending_timeout; + u8_t features[8]; + struct bt_keys * keys; +}; + +union anon_union_for_field_20 { + struct bt_conn_le le; +}; + +struct bt_conn { + u16_t handle; + u8_t type; + u8_t role; + atomic_t flags[1]; + u8_t id; + enum bt_security_t sec_level; + enum bt_security_t required_sec_level; + u8_t encrypt; + u8_t err; + enum bt_conn_state_t state; + u16_t rx_len; + struct net_buf * rx; + sys_slist_t tx_pending; + u32_t.conflict pending_no_cb; + sys_slist_t tx_complete; + struct k_work tx_complete_work; + struct k_fifo tx_queue; + sys_slist_t channels; + atomic_t ref; + struct k_delayed_work update_work; + union anon_union_for_field_20 field_20; +}; + +struct k_work_q { + struct k_fifo fifo; +}; + +struct bt_uuid { + u8_t type; +}; + +struct bt_gatt_discover_params { + struct bt_att_req.conflict2 _req; + struct bt_uuid * uuid; + u8_t (* func)(struct bt_conn *, struct bt_gatt_attr *, struct bt_gatt_discover_params *); + union anon_union_for_field_3 field_3; + u16_t end_handle; + u8_t type; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct _bt_gatt_ccc.conflict1 _bt_gatt_ccc.conflict1, *P_bt_gatt_ccc.conflict1; + +typedef struct bt_gatt_ccc_cfg bt_gatt_ccc_cfg, *Pbt_gatt_ccc_cfg; + +struct bt_gatt_ccc_cfg { + u8_t id; + struct bt_addr_le_t peer; + u16_t value; +}; + +struct _bt_gatt_ccc.conflict1 { + struct bt_gatt_ccc_cfg cfg[2]; + u16_t value; + undefined field_0x16; + undefined field_0x17; + void (* cfg_changed)(struct bt_gatt_attr *, u16_t); + _Bool (* cfg_write)(struct bt_conn *, struct bt_gatt_attr *, u16_t); + _Bool (* cfg_match)(struct bt_conn *, struct bt_gatt_attr *); +}; + +typedef struct _bt_gatt_ccc.conflict3 _bt_gatt_ccc.conflict3, *P_bt_gatt_ccc.conflict3; + +struct _bt_gatt_ccc.conflict3 { + struct bt_gatt_ccc_cfg cfg[2]; + u16_t value; + undefined field_0x16; + undefined field_0x17; + void (* cfg_changed)(struct bt_gatt_attr *, u16_t); + _Bool (* cfg_write)(struct bt_conn *, struct bt_gatt_attr *, u16_t); + _Bool (* cfg_match)(struct bt_conn *, struct bt_gatt_attr *); +}; + +typedef struct _bt_gatt_ccc.conflict2 _bt_gatt_ccc.conflict2, *P_bt_gatt_ccc.conflict2; + +struct _bt_gatt_ccc.conflict2 { + struct bt_gatt_ccc_cfg cfg[2]; + u16_t value; + undefined field_0x16; + undefined field_0x17; + void (* cfg_changed)(struct bt_gatt_attr *, u16_t); + _Bool (* cfg_write)(struct bt_conn *, struct bt_gatt_attr *, u16_t); + _Bool (* cfg_match)(struct bt_conn *, struct bt_gatt_attr *); +}; + +typedef struct bt_gatt_attr.conflict7 bt_gatt_attr.conflict7, *Pbt_gatt_attr.conflict7; + +struct bt_gatt_attr.conflict7 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_attr.conflict1 bt_gatt_attr.conflict1, *Pbt_gatt_attr.conflict1; + +struct bt_gatt_attr.conflict1 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_indicate_params.conflict3 bt_gatt_indicate_params.conflict3, *Pbt_gatt_indicate_params.conflict3; + +typedef struct bt_att_req.conflict13 bt_att_req.conflict13, *Pbt_att_req.conflict13; + +struct bt_att_req.conflict13 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_indicate_params.conflict3 { + struct bt_att_req.conflict13 _req; + struct bt_uuid * uuid; + struct bt_gatt_attr * attr; + void (* func)(struct bt_conn *, struct bt_gatt_attr *, u8_t); + void * data; + u16_t len; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct bt_gatt_chrc bt_gatt_chrc, *Pbt_gatt_chrc; + +struct bt_gatt_chrc { + struct bt_uuid * uuid; + u16_t value_handle; + u8_t properties; + undefined field_0x7; +}; + +typedef struct bt_gatt_service_val bt_gatt_service_val, *Pbt_gatt_service_val; + +struct bt_gatt_service_val { + struct bt_uuid * uuid; + u16_t end_handle; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct bt_gatt_attr.conflict17 bt_gatt_attr.conflict17, *Pbt_gatt_attr.conflict17; + +struct bt_gatt_attr.conflict17 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct _bt_gatt_ccc.conflict4 _bt_gatt_ccc.conflict4, *P_bt_gatt_ccc.conflict4; + +struct _bt_gatt_ccc.conflict4 { + struct bt_gatt_ccc_cfg cfg[2]; + u16_t value; + undefined field_0x16; + undefined field_0x17; + void (* cfg_changed)(struct bt_gatt_attr *, u16_t); + _Bool (* cfg_write)(struct bt_conn *, struct bt_gatt_attr *, u16_t); + _Bool (* cfg_match)(struct bt_conn *, struct bt_gatt_attr *); +}; + +typedef struct bt_gatt_read_params.conflict bt_gatt_read_params.conflict, *Pbt_gatt_read_params.conflict; + +typedef struct bt_gatt_read_params bt_gatt_read_params, *Pbt_gatt_read_params; + +typedef struct bt_att_req.conflict5 bt_att_req.conflict5, *Pbt_att_req.conflict5; + +typedef struct bt_att_req.conflict4 bt_att_req.conflict4, *Pbt_att_req.conflict4; + + +// WARNING! conflicting data type names: /DWARF/gatt.h/bt_gatt_read_params/anon_union_for_field_3 - /DWARF/gatt.h/bt_gatt_discover_params/anon_union_for_field_3 + +struct bt_att_req.conflict4 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_att_req.conflict5 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_read_params { + struct bt_att_req.conflict4 _req; + u8_t (* func)(struct bt_conn *, u8_t, struct bt_gatt_read_params *, void *, u16_t); + size_t handle_count; + union anon_union_for_field_3 field_3; +}; + +struct bt_gatt_read_params.conflict { + struct bt_att_req.conflict5 _req; + u8_t (* func)(struct bt_conn *, u8_t, struct bt_gatt_read_params *, void *, u16_t); + size_t handle_count; + union anon_union_for_field_3 field_3; +}; + +typedef struct bt_gatt_service bt_gatt_service, *Pbt_gatt_service; + +struct bt_gatt_service { + struct bt_gatt_attr * attrs; + size_t attr_count; + sys_snode_t node; +}; + +typedef struct bt_gatt_discover_params.conflict1 bt_gatt_discover_params.conflict1, *Pbt_gatt_discover_params.conflict1; + +typedef struct bt_att_req.conflict18 bt_att_req.conflict18, *Pbt_att_req.conflict18; + +struct bt_att_req.conflict18 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + void (* destroy)(void *); + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_discover_params.conflict1 { + struct bt_att_req.conflict18 _req; + struct bt_uuid * uuid; + u8_t (* func)(struct bt_conn *, struct bt_gatt_attr *, struct bt_gatt_discover_params *); + union anon_union_for_field_3 field_3; + u16_t end_handle; + u8_t type; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct bt_gatt_cep bt_gatt_cep, *Pbt_gatt_cep; + +struct bt_gatt_cep { + u16_t properties; +}; + +typedef struct bt_gatt_indicate_params.conflict1 bt_gatt_indicate_params.conflict1, *Pbt_gatt_indicate_params.conflict1; + +typedef struct bt_att_req.conflict11 bt_att_req.conflict11, *Pbt_att_req.conflict11; + +struct bt_att_req.conflict11 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_indicate_params.conflict1 { + struct bt_att_req.conflict11 _req; + struct bt_uuid * uuid; + struct bt_gatt_attr * attr; + void (* func)(struct bt_conn *, struct bt_gatt_attr *, u8_t); + void * data; + u16_t len; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct anon_struct.conflict499 anon_struct.conflict499, *Panon_struct.conflict499; + +struct anon_struct.conflict499 { + u16_t start_handle; + u16_t end_handle; + struct bt_uuid * uuid; +}; + +typedef struct anon_struct.conflict497 anon_struct.conflict497, *Panon_struct.conflict497; + +struct anon_struct.conflict497 { + u16_t attr_handle; + u16_t start_handle; + u16_t end_handle; +}; + +typedef struct anon_struct.conflict498 anon_struct.conflict498, *Panon_struct.conflict498; + +struct anon_struct.conflict498 { + u16_t handle; + u16_t offset; +}; + +typedef struct bt_gatt_exchange_params bt_gatt_exchange_params, *Pbt_gatt_exchange_params; + +typedef struct bt_att_req.conflict1 bt_att_req.conflict1, *Pbt_att_req.conflict1; + +struct bt_att_req.conflict1 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_exchange_params { + struct bt_att_req.conflict1 _req; + void (* func)(struct bt_conn *, u8_t, struct bt_gatt_exchange_params *); +}; + +typedef struct bt_gatt_write_params bt_gatt_write_params, *Pbt_gatt_write_params; + +typedef struct bt_att_req.conflict6 bt_att_req.conflict6, *Pbt_att_req.conflict6; + +struct bt_att_req.conflict6 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_write_params { + struct bt_att_req.conflict6 _req; + void (* func)(struct bt_conn *, u8_t, struct bt_gatt_write_params *); + u16_t handle; + u16_t offset; + void * data; + u16_t length; + undefined field_0x26; + undefined field_0x27; +}; + +typedef struct bt_gatt_include bt_gatt_include, *Pbt_gatt_include; + +struct bt_gatt_include { + struct bt_uuid * uuid; + u16_t start_handle; + u16_t end_handle; +}; + +typedef struct bt_gatt_attr.conflict5 bt_gatt_attr.conflict5, *Pbt_gatt_attr.conflict5; + +struct bt_gatt_attr.conflict5 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_indicate_params.conflict4 bt_gatt_indicate_params.conflict4, *Pbt_gatt_indicate_params.conflict4; + +typedef struct bt_att_req.conflict15 bt_att_req.conflict15, *Pbt_att_req.conflict15; + +struct bt_att_req.conflict15 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_indicate_params.conflict4 { + struct bt_att_req.conflict15 _req; + struct bt_uuid * uuid; + struct bt_gatt_attr * attr; + void (* func)(struct bt_conn *, struct bt_gatt_attr *, u8_t); + void * data; + u16_t len; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct bt_gatt_attr.conflict6 bt_gatt_attr.conflict6, *Pbt_gatt_attr.conflict6; + +struct bt_gatt_attr.conflict6 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_subscribe_params.conflict bt_gatt_subscribe_params.conflict, *Pbt_gatt_subscribe_params.conflict; + +typedef struct bt_gatt_subscribe_params bt_gatt_subscribe_params, *Pbt_gatt_subscribe_params; + +typedef struct bt_att_req.conflict9 bt_att_req.conflict9, *Pbt_att_req.conflict9; + +typedef struct bt_att_req.conflict8 bt_att_req.conflict8, *Pbt_att_req.conflict8; + +struct bt_att_req.conflict9 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_subscribe_params.conflict { + struct bt_att_req.conflict9 _req; + struct bt_addr_le_t _peer; + undefined field_0x1f; + u8_t (* notify)(struct bt_conn *, struct bt_gatt_subscribe_params *, void *, u16_t); + u16_t value_handle; + u16_t ccc_handle; + u16_t value; + undefined field_0x2a; + undefined field_0x2b; + atomic_t flags[1]; + sys_snode_t node; +}; + +struct bt_att_req.conflict8 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_subscribe_params { + struct bt_att_req.conflict8 _req; + struct bt_addr_le_t _peer; + undefined field_0x1f; + u8_t (* notify)(struct bt_conn *, struct bt_gatt_subscribe_params *, void *, u16_t); + u16_t value_handle; + u16_t ccc_handle; + u16_t value; + undefined field_0x2a; + undefined field_0x2b; + atomic_t flags[1]; + sys_snode_t node; +}; + +typedef struct bt_gatt_indicate_params.conflict2 bt_gatt_indicate_params.conflict2, *Pbt_gatt_indicate_params.conflict2; + +typedef struct bt_att_req.conflict12 bt_att_req.conflict12, *Pbt_att_req.conflict12; + +struct bt_att_req.conflict12 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_indicate_params.conflict2 { + struct bt_att_req.conflict12 _req; + struct bt_uuid * uuid; + struct bt_gatt_attr * attr; + void (* func)(struct bt_conn *, struct bt_gatt_attr *, u8_t); + void * data; + u16_t len; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct bt_gatt_service_static bt_gatt_service_static, *Pbt_gatt_service_static; + +struct bt_gatt_service_static { + struct bt_gatt_attr * attrs; + size_t attr_count; +}; + +typedef struct bt_gatt_attr.conflict16 bt_gatt_attr.conflict16, *Pbt_gatt_attr.conflict16; + +struct bt_gatt_attr.conflict16 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_attr.conflict12 bt_gatt_attr.conflict12, *Pbt_gatt_attr.conflict12; + +struct bt_gatt_attr.conflict12 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_attr.conflict15 bt_gatt_attr.conflict15, *Pbt_gatt_attr.conflict15; + +struct bt_gatt_attr.conflict15 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_attr.conflict14 bt_gatt_attr.conflict14, *Pbt_gatt_attr.conflict14; + +struct bt_gatt_attr.conflict14 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_attr.conflict13 bt_gatt_attr.conflict13, *Pbt_gatt_attr.conflict13; + +struct bt_gatt_attr.conflict13 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_attr.conflict4 bt_gatt_attr.conflict4, *Pbt_gatt_attr.conflict4; + +struct bt_gatt_attr.conflict4 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_attr.conflict11 bt_gatt_attr.conflict11, *Pbt_gatt_attr.conflict11; + +struct bt_gatt_attr.conflict11 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_attr.conflict10 bt_gatt_attr.conflict10, *Pbt_gatt_attr.conflict10; + +struct bt_gatt_attr.conflict10 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct _bt_gatt_ccc _bt_gatt_ccc, *P_bt_gatt_ccc; + +struct _bt_gatt_ccc { + struct bt_gatt_ccc_cfg cfg[2]; + u16_t value; + undefined field_0x16; + undefined field_0x17; + void (* cfg_changed)(struct bt_gatt_attr *, u16_t); + _Bool (* cfg_write)(struct bt_conn *, struct bt_gatt_attr *, u16_t); + _Bool (* cfg_match)(struct bt_conn *, struct bt_gatt_attr *); +}; + +typedef struct bt_gatt_cpf bt_gatt_cpf, *Pbt_gatt_cpf; + +struct bt_gatt_cpf { + u8_t format; + s8_t exponent; + u16_t unit; + u8_t name_space; + u16_t description; +}; + +typedef struct bt_gatt_exchange_params.conflict bt_gatt_exchange_params.conflict, *Pbt_gatt_exchange_params.conflict; + +typedef struct bt_att_req.conflict17 bt_att_req.conflict17, *Pbt_att_req.conflict17; + +struct bt_att_req.conflict17 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + void (* destroy)(void *); + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_exchange_params.conflict { + struct bt_att_req.conflict17 _req; + void (* func)(struct bt_conn *, u8_t, struct bt_gatt_exchange_params *); +}; + +typedef struct bt_gatt_indicate_params bt_gatt_indicate_params, *Pbt_gatt_indicate_params; + +typedef struct bt_att_req.conflict bt_att_req.conflict, *Pbt_att_req.conflict; + +struct bt_att_req.conflict { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_indicate_params { + struct bt_att_req.conflict _req; + struct bt_uuid * uuid; + struct bt_gatt_attr * attr; + void (* func)(struct bt_conn *, struct bt_gatt_attr *, u8_t); + void * data; + u16_t len; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct bt_gatt_notify_params.conflict2 bt_gatt_notify_params.conflict2, *Pbt_gatt_notify_params.conflict2; + +struct bt_gatt_notify_params.conflict2 { + struct bt_uuid * uuid; + struct bt_gatt_attr * attr; + void * data; + u16_t len; + undefined field_0xe; + undefined field_0xf; + void (* func)(struct bt_conn *, void *); + void * user_data; +}; + +typedef struct bt_gatt_notify_params.conflict3 bt_gatt_notify_params.conflict3, *Pbt_gatt_notify_params.conflict3; + +struct bt_gatt_notify_params.conflict3 { + struct bt_uuid * uuid; + struct bt_gatt_attr * attr; + void * data; + u16_t len; + undefined field_0xe; + undefined field_0xf; + void (* func)(struct bt_conn *, void *); + void * user_data; +}; + +typedef struct bt_gatt_notify_params.conflict1 bt_gatt_notify_params.conflict1, *Pbt_gatt_notify_params.conflict1; + +struct bt_gatt_notify_params.conflict1 { + struct bt_uuid * uuid; + struct bt_gatt_attr * attr; + void * data; + u16_t len; + undefined field_0xe; + undefined field_0xf; + void (* func)(struct bt_conn *, void *); + void * user_data; +}; + +typedef struct anon_struct.conflict500 anon_struct.conflict500, *Panon_struct.conflict500; + +struct anon_struct.conflict500 { + u16_t handle; + u16_t offset; +}; + +typedef struct anon_struct.conflict501 anon_struct.conflict501, *Panon_struct.conflict501; + +struct anon_struct.conflict501 { + u16_t start_handle; + u16_t end_handle; + struct bt_uuid * uuid; +}; + +typedef struct anon_struct.conflict518 anon_struct.conflict518, *Panon_struct.conflict518; + +struct anon_struct.conflict518 { + u16_t start_handle; + u16_t end_handle; + struct bt_uuid * uuid; +}; + +typedef struct bt_gatt_write_params.conflict bt_gatt_write_params.conflict, *Pbt_gatt_write_params.conflict; + +typedef struct bt_att_req.conflict7 bt_att_req.conflict7, *Pbt_att_req.conflict7; + +struct bt_att_req.conflict7 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_write_params.conflict { + struct bt_att_req.conflict7 _req; + void (* func)(struct bt_conn *, u8_t, struct bt_gatt_write_params *); + u16_t handle; + u16_t offset; + void * data; + u16_t length; + undefined field_0x26; + undefined field_0x27; +}; + +typedef struct bt_gatt_notify_params bt_gatt_notify_params, *Pbt_gatt_notify_params; + +struct bt_gatt_notify_params { + struct bt_uuid * uuid; + struct bt_gatt_attr * attr; + void * data; + u16_t len; + undefined field_0xe; + undefined field_0xf; + void (* func)(struct bt_conn *, void *); + void * user_data; +}; + +typedef struct anon_struct.conflict516 anon_struct.conflict516, *Panon_struct.conflict516; + +struct anon_struct.conflict516 { + u16_t attr_handle; + u16_t start_handle; + u16_t end_handle; +}; + +typedef struct anon_struct.conflict517 anon_struct.conflict517, *Panon_struct.conflict517; + +struct anon_struct.conflict517 { + u16_t handle; + u16_t offset; +}; + +typedef struct bt_gatt_write_params.conflict1 bt_gatt_write_params.conflict1, *Pbt_gatt_write_params.conflict1; + +typedef struct bt_att_req.conflict20 bt_att_req.conflict20, *Pbt_att_req.conflict20; + +struct bt_att_req.conflict20 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + void (* destroy)(void *); + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_write_params.conflict1 { + struct bt_att_req.conflict20 _req; + void (* func)(struct bt_conn *, u8_t, struct bt_gatt_write_params *); + u16_t handle; + u16_t offset; + void * data; + u16_t length; + undefined field_0x26; + undefined field_0x27; +}; + +typedef struct bt_gatt_attr.conflict2 bt_gatt_attr.conflict2, *Pbt_gatt_attr.conflict2; + +struct bt_gatt_attr.conflict2 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_attr.conflict3 bt_gatt_attr.conflict3, *Pbt_gatt_attr.conflict3; + +struct bt_gatt_attr.conflict3 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_attr.conflict9 bt_gatt_attr.conflict9, *Pbt_gatt_attr.conflict9; + +struct bt_gatt_attr.conflict9 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_read_params.conflict1 bt_gatt_read_params.conflict1, *Pbt_gatt_read_params.conflict1; + +typedef struct bt_att_req.conflict19 bt_att_req.conflict19, *Pbt_att_req.conflict19; + +struct bt_att_req.conflict19 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + void (* destroy)(void *); + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_read_params.conflict1 { + struct bt_att_req.conflict19 _req; + u8_t (* func)(struct bt_conn *, u8_t, struct bt_gatt_read_params *, void *, u16_t); + size_t handle_count; + union anon_union_for_field_3 field_3; +}; + +typedef struct bt_gatt_attr.conflict8 bt_gatt_attr.conflict8, *Pbt_gatt_attr.conflict8; + +struct bt_gatt_attr.conflict8 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_subscribe_params.conflict1 bt_gatt_subscribe_params.conflict1, *Pbt_gatt_subscribe_params.conflict1; + +typedef struct bt_att_req.conflict21 bt_att_req.conflict21, *Pbt_att_req.conflict21; + +struct bt_att_req.conflict21 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + void (* destroy)(void *); + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_subscribe_params.conflict1 { + struct bt_att_req.conflict21 _req; + struct bt_addr_le_t _peer; + undefined field_0x1f; + u8_t (* notify)(struct bt_conn *, struct bt_gatt_subscribe_params *, void *, u16_t); + u16_t value_handle; + u16_t ccc_handle; + u16_t value; + undefined field_0x2a; + undefined field_0x2b; + atomic_t flags[1]; + sys_snode_t node; +}; + +typedef struct bt_gatt_attr.conflict bt_gatt_attr.conflict, *Pbt_gatt_attr.conflict; + +struct bt_gatt_attr.conflict { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct _bt_gatt_ccc.conflict _bt_gatt_ccc.conflict, *P_bt_gatt_ccc.conflict; + +struct _bt_gatt_ccc.conflict { + struct bt_gatt_ccc_cfg cfg[2]; + u16_t value; + undefined field_0x16; + undefined field_0x17; + void (* cfg_changed)(struct bt_gatt_attr *, u16_t); + _Bool (* cfg_write)(struct bt_conn *, struct bt_gatt_attr *, u16_t); + _Bool (* cfg_match)(struct bt_conn *, struct bt_gatt_attr *); +}; + +typedef struct bt_gatt_indicate_params.conflict bt_gatt_indicate_params.conflict, *Pbt_gatt_indicate_params.conflict; + +typedef struct bt_att_req.conflict10 bt_att_req.conflict10, *Pbt_att_req.conflict10; + +struct bt_att_req.conflict10 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_indicate_params.conflict { + struct bt_att_req.conflict10 _req; + struct bt_uuid * uuid; + struct bt_gatt_attr * attr; + void (* func)(struct bt_conn *, struct bt_gatt_attr *, u8_t); + void * data; + u16_t len; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct bt_gatt_exchange_params.conflict2 bt_gatt_exchange_params.conflict2, *Pbt_gatt_exchange_params.conflict2; + +typedef struct bt_att_req.conflict30 bt_att_req.conflict30, *Pbt_att_req.conflict30; + +struct bt_att_req.conflict30 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_exchange_params.conflict2 { + struct bt_att_req.conflict30 _req; + void (* func)(struct bt_conn *, u8_t, struct bt_gatt_exchange_params *); +}; + +typedef struct bt_gatt_notify_params.conflict bt_gatt_notify_params.conflict, *Pbt_gatt_notify_params.conflict; + +struct bt_gatt_notify_params.conflict { + struct bt_uuid * uuid; + struct bt_gatt_attr * attr; + void * data; + u16_t len; + undefined field_0xe; + undefined field_0xf; + void (* func)(struct bt_conn *, void *); + void * user_data; +}; + +typedef struct bt_gatt_exchange_params.conflict1 bt_gatt_exchange_params.conflict1, *Pbt_gatt_exchange_params.conflict1; + +typedef struct bt_att_req.conflict23 bt_att_req.conflict23, *Pbt_att_req.conflict23; + +struct bt_att_req.conflict23 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + void (* destroy)(void *); + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_exchange_params.conflict1 { + struct bt_att_req.conflict23 _req; + void (* func)(struct bt_conn *, u8_t, struct bt_gatt_exchange_params *); +}; + +typedef uint32_t u32.conflict18; + +typedef uint32_t u32.conflict17; + +typedef uint32_t u32_l; + +typedef uint16_t __be16; + +typedef uint32_t u32.conflict23; + +typedef uint32_t u32.conflict10; + +typedef uint32_t u32.conflict6; + +typedef uint32_t u32.conflict22; + +typedef uint32_t u32.conflict13; + +typedef uint32_t u32.conflict12; + +typedef uint32_t u32.conflict26; + +typedef int8_t s8; + +typedef uint32_t u32.conflict270; + +typedef uint32_t u32.conflict21; + +typedef uint32_t u32.conflict20; + +typedef uint32_t u32.conflict173; + +typedef uint32_t u32.conflict25; + +typedef uint32_t u32.conflict; + +typedef uint32_t u32.conflict24; + +typedef uint32_t u32.conflict177; + +typedef uint16_t u16; + +typedef uint16_t u16_l; + +typedef long int32_t; + +typedef int32_t s32.conflict; + +typedef uint32_t u32.conflict54; + +typedef uint8_t u8_l; + +typedef uint32_t u32.conflict268; + +typedef uint32_t u32.conflict269; + +typedef uint32_t u32.conflict263; + +typedef uint32_t u32.conflict36; + +typedef uint32_t u32.conflict35; + +typedef ulonglong __uint64_t; + +typedef __uint64_t uint64_t; + +typedef uint64_t __le64; + +typedef uint32_t u32.conflict267; + +typedef uint32_t u32.conflict41; + +typedef uint32_t u32.conflict46; + +typedef uint32_t u32.conflict7; + +typedef uint32_t u32.conflict5; + +typedef uint32_t u32.conflict53; + +typedef uint32_t u32.conflict52; + +typedef uint32_t u32.conflict51; + +typedef uint32_t u32.conflict3; + +typedef uint32_t u32.conflict2; + +typedef uint16_t __le16; + +typedef uint32_t u32.conflict191; + +typedef uint32_t u32.conflict186; + +typedef _Bool bool_l; + +typedef int8_t s8_l; + +typedef uint32_t __le32; + +typedef uint32_t u32.conflict196; + +typedef struct work work, *Pwork; + +struct work { + void (* fn)(void *); + void * arg; + int dly; +}; + +typedef struct targ targ, *Ptarg; + +typedef struct AosStaticTask_t AosStaticTask_t, *PAosStaticTask_t; + +typedef struct xSTATIC_TCB xSTATIC_TCB, *PxSTATIC_TCB; + +typedef struct xSTATIC_TCB StaticTask_t; + +typedef struct xSTATIC_LIST_ITEM xSTATIC_LIST_ITEM, *PxSTATIC_LIST_ITEM; + +typedef struct xSTATIC_LIST_ITEM StaticListItem_t; + +typedef uint32_t UBaseType_t; + +typedef uint32_t TickType_t; + +struct xSTATIC_LIST_ITEM { + TickType_t xDummy2; + void * pvDummy3[4]; +}; + +struct xSTATIC_TCB { + void * pxDummy1; + StaticListItem_t xDummy3[2]; + UBaseType_t uxDummy5; + void * pxDummy6; + uint8_t ucDummy7[16]; + UBaseType_t uxDummy9; + UBaseType_t uxDummy10[2]; + UBaseType_t uxDummy12[2]; + uint32_t ulDummy18; + uint8_t ucDummy19; + uint8_t uxDummy20; + undefined field_0x5e; + undefined field_0x5f; +}; + +struct targ { + struct AosStaticTask_t * task; + void (* fn)(void *); + void * arg; +}; + +struct AosStaticTask_t { + StaticTask_t fTask; + uint32_t key_bitmap; + void * keys[4]; + void * stack; + char name[32]; + uint32_t magic; +}; + +typedef struct mbedtls_gcm_context mbedtls_gcm_context, *Pmbedtls_gcm_context; + +typedef struct mbedtls_cipher_context_t mbedtls_cipher_context_t, *Pmbedtls_cipher_context_t; + +typedef struct mbedtls_cipher_info_t mbedtls_cipher_info_t, *Pmbedtls_cipher_info_t; + +typedef enum mbedtls_operation_t { + MBEDTLS_DECRYPT=0, + MBEDTLS_ENCRYPT=1, + MBEDTLS_OPERATION_NONE=-1 +} mbedtls_operation_t; + +typedef enum mbedtls_cipher_type_t { + MBEDTLS_CIPHER_AES_128_CBC=5, + MBEDTLS_CIPHER_AES_128_CCM=43, + MBEDTLS_CIPHER_AES_128_CFB128=8, + MBEDTLS_CIPHER_AES_128_CTR=11, + MBEDTLS_CIPHER_AES_128_ECB=2, + MBEDTLS_CIPHER_AES_128_GCM=14, + MBEDTLS_CIPHER_AES_192_CBC=6, + MBEDTLS_CIPHER_AES_192_CCM=44, + MBEDTLS_CIPHER_AES_192_CFB128=9, + MBEDTLS_CIPHER_AES_192_CTR=12, + MBEDTLS_CIPHER_AES_192_ECB=3, + MBEDTLS_CIPHER_AES_192_GCM=15, + MBEDTLS_CIPHER_AES_256_CBC=7, + MBEDTLS_CIPHER_AES_256_CCM=45, + MBEDTLS_CIPHER_AES_256_CFB128=10, + MBEDTLS_CIPHER_AES_256_CTR=13, + MBEDTLS_CIPHER_AES_256_ECB=4, + MBEDTLS_CIPHER_AES_256_GCM=16, + MBEDTLS_CIPHER_ARC4_128=42, + MBEDTLS_CIPHER_BLOWFISH_CBC=39, + MBEDTLS_CIPHER_BLOWFISH_CFB64=40, + MBEDTLS_CIPHER_BLOWFISH_CTR=41, + MBEDTLS_CIPHER_BLOWFISH_ECB=38, + MBEDTLS_CIPHER_CAMELLIA_128_CBC=20, + MBEDTLS_CIPHER_CAMELLIA_128_CCM=46, + MBEDTLS_CIPHER_CAMELLIA_128_CFB128=23, + MBEDTLS_CIPHER_CAMELLIA_128_CTR=26, + MBEDTLS_CIPHER_CAMELLIA_128_ECB=17, + MBEDTLS_CIPHER_CAMELLIA_128_GCM=29, + MBEDTLS_CIPHER_CAMELLIA_192_CBC=21, + MBEDTLS_CIPHER_CAMELLIA_192_CCM=47, + MBEDTLS_CIPHER_CAMELLIA_192_CFB128=24, + MBEDTLS_CIPHER_CAMELLIA_192_CTR=27, + MBEDTLS_CIPHER_CAMELLIA_192_ECB=18, + MBEDTLS_CIPHER_CAMELLIA_192_GCM=30, + MBEDTLS_CIPHER_CAMELLIA_256_CBC=22, + MBEDTLS_CIPHER_CAMELLIA_256_CCM=48, + MBEDTLS_CIPHER_CAMELLIA_256_CFB128=25, + MBEDTLS_CIPHER_CAMELLIA_256_CTR=28, + MBEDTLS_CIPHER_CAMELLIA_256_ECB=19, + MBEDTLS_CIPHER_CAMELLIA_256_GCM=31, + MBEDTLS_CIPHER_DES_CBC=33, + MBEDTLS_CIPHER_DES_ECB=32, + MBEDTLS_CIPHER_DES_EDE3_CBC=37, + MBEDTLS_CIPHER_DES_EDE3_ECB=36, + MBEDTLS_CIPHER_DES_EDE_CBC=35, + MBEDTLS_CIPHER_DES_EDE_ECB=34, + MBEDTLS_CIPHER_NONE=0, + MBEDTLS_CIPHER_NULL=1 +} mbedtls_cipher_type_t; + +typedef enum mbedtls_cipher_mode_t { + MBEDTLS_MODE_CBC=2, + MBEDTLS_MODE_CCM=8, + MBEDTLS_MODE_CFB=3, + MBEDTLS_MODE_CTR=5, + MBEDTLS_MODE_ECB=1, + MBEDTLS_MODE_GCM=6, + MBEDTLS_MODE_NONE=0, + MBEDTLS_MODE_OFB=4, + MBEDTLS_MODE_STREAM=7 +} mbedtls_cipher_mode_t; + +typedef struct mbedtls_cipher_base_t mbedtls_cipher_base_t, *Pmbedtls_cipher_base_t; + +typedef enum mbedtls_cipher_id_t { + MBEDTLS_CIPHER_ID_3DES=4, + MBEDTLS_CIPHER_ID_AES=2, + MBEDTLS_CIPHER_ID_ARC4=7, + MBEDTLS_CIPHER_ID_BLOWFISH=6, + MBEDTLS_CIPHER_ID_CAMELLIA=5, + MBEDTLS_CIPHER_ID_DES=3, + MBEDTLS_CIPHER_ID_NONE=0, + MBEDTLS_CIPHER_ID_NULL=1 +} mbedtls_cipher_id_t; + +struct mbedtls_cipher_context_t { + struct mbedtls_cipher_info_t * cipher_info; + int key_bitlen; + enum mbedtls_operation_t operation; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + void (* add_padding)(uchar *, size_t, size_t); + int (* get_padding)(uchar *, size_t, size_t *); + uchar unprocessed_data[16]; + size_t unprocessed_len; + uchar iv[16]; + size_t iv_size; + void * cipher_ctx; +}; + +struct mbedtls_cipher_info_t { + enum mbedtls_cipher_type_t type; + enum mbedtls_cipher_mode_t mode; + undefined field_0x2; + undefined field_0x3; + uint key_bitlen; + char * name; + uint iv_size; + int flags; + uint block_size; + struct mbedtls_cipher_base_t * base; +}; + +struct mbedtls_gcm_context { + struct mbedtls_cipher_context_t cipher_ctx; + uint64_t HL[16]; + uint64_t HH[16]; + uint64_t len; + uint64_t add_len; + uchar base_ectr[16]; + uchar y[16]; + uchar buf[16]; + int mode; + undefined field_0x184; + undefined field_0x185; + undefined field_0x186; + undefined field_0x187; +}; + +struct mbedtls_cipher_base_t { + enum mbedtls_cipher_id_t cipher; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + int (* ecb_func)(void *, enum mbedtls_operation_t, uchar *, uchar *); + int (* cbc_func)(void *, enum mbedtls_operation_t, size_t, uchar *, uchar *, uchar *); + int (* cfb_func)(void *, enum mbedtls_operation_t, size_t, size_t *, uchar *, uchar *, uchar *); + int (* ctr_func)(void *, size_t, size_t *, uchar *, uchar *, uchar *, uchar *); + int (* setkey_enc_func)(void *, uchar *, uint); + int (* setkey_dec_func)(void *, uchar *, uint); + void * (* ctx_alloc_func)(void); + void (* ctx_free_func)(void *); +}; + +typedef struct gatt_chrc gatt_chrc, *Pgatt_chrc; + +typedef union anon_union_for_field_2 anon_union_for_field_2, *Panon_union_for_field_2; + +union anon_union_for_field_2 { + u16_t uuid16; + u8_t uuid[16]; +}; + +struct gatt_chrc { + u8_t properties; + u16_t value_handle; + union anon_union_for_field_2 field_2; +}; + +typedef struct gatt_incl gatt_incl, *Pgatt_incl; + +struct gatt_incl { + u16_t start_handle; + u16_t end_handle; + u16_t uuid16; +}; + +typedef struct sc_data sc_data, *Psc_data; + +struct sc_data { + u16_t start; + u16_t end; +}; + +typedef struct notify_data notify_data, *Pnotify_data; + + +// WARNING! conflicting data type names: /DWARF/gatt.c/notify_data/anon_union_for_field_2 - /DWARF/gatt.c/gatt_chrc/anon_union_for_field_2 + +struct notify_data { + int err; + u16_t type; + undefined field_0x6; + undefined field_0x7; + union anon_union_for_field_2 field_2; +}; + +typedef struct gatt_sc.conflict gatt_sc.conflict, *Pgatt_sc.conflict; + +typedef struct k_delayed_work.conflict k_delayed_work.conflict, *Pk_delayed_work.conflict; + +typedef struct k_timer.conflict k_timer.conflict, *Pk_timer.conflict; + +typedef struct k_timer.conflict k_timer_t.conflict; + +typedef void (* k_timer_handler_t.conflict)(void *); + +struct k_timer.conflict { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +struct k_delayed_work.conflict { + struct k_work work; + struct k_work_q * work_q; + k_timer_t.conflict timer; +}; + +struct gatt_sc.conflict { + struct bt_gatt_indicate_params.conflict4 params; + u16_t start; + u16_t end; + struct k_delayed_work.conflict work; + atomic_t flags[1]; +}; + +typedef struct gatt_sc_cfg gatt_sc_cfg, *Pgatt_sc_cfg; + +typedef struct anon_struct_for_data anon_struct_for_data, *Panon_struct_for_data; + +struct anon_struct_for_data { + u16_t start; + u16_t end; +}; + +struct gatt_sc_cfg { + u8_t id; + struct bt_addr_le_t peer; + struct anon_struct_for_data data; +}; + +typedef struct addr_with_id addr_with_id, *Paddr_with_id; + +struct addr_with_id { + struct bt_addr_le_t * addr; + u8_t id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct ccc_load ccc_load, *Pccc_load; + +typedef struct ccc_store ccc_store, *Pccc_store; + +struct ccc_load { + struct addr_with_id addr_with_id; + struct ccc_store * entry; + size_t count; +}; + +struct ccc_store { + u16_t handle; + u16_t value; +}; + +typedef struct gatt_sc gatt_sc, *Pgatt_sc; + +struct gatt_sc { + struct bt_gatt_indicate_params.conflict params; + u16_t start; + u16_t end; + struct k_delayed_work.conflict work; + atomic_t flags[1]; +}; + +typedef struct anon_struct.conflict502 anon_struct.conflict502, *Panon_struct.conflict502; + +struct anon_struct.conflict502 { + u16_t start; + u16_t end; +}; + +typedef struct conn_data conn_data, *Pconn_data; + +struct conn_data { + struct bt_conn * conn; + enum bt_security_t sec; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef union anon_union anon_union, *Panon_union; + +typedef struct bt_uuid_16 bt_uuid_16, *Pbt_uuid_16; + +typedef struct bt_uuid_128 bt_uuid_128, *Pbt_uuid_128; + +struct bt_uuid_16 { + struct bt_uuid uuid; + undefined field_0x1; + u16_t val; +}; + +struct bt_uuid_128 { + struct bt_uuid uuid; + u8_t val[16]; +}; + +union anon_union { + struct bt_uuid uuid; + struct bt_uuid_16 u16; + struct bt_uuid_128 u128; + undefined1 field3[18]; // Automatically generated padding to match DWARF declared size +}; + +typedef union anon_union_for_info anon_union_for_info, *Panon_union_for_info; + +typedef struct bt_att_info_16 bt_att_info_16, *Pbt_att_info_16; + +typedef struct bt_att_info_128 bt_att_info_128, *Pbt_att_info_128; + +struct bt_att_info_16 { + u16_t handle; + u16_t uuid; +}; + +union anon_union_for_info { + struct bt_att_info_16 * i16; + struct bt_att_info_128 * i128; +}; + +struct bt_att_info_128 { + u16_t handle; + u8_t uuid[16]; +}; + +typedef union anon_union_for_u anon_union_for_u, *Panon_union_for_u; + +union anon_union_for_u { + struct bt_uuid uuid; + struct bt_uuid_16 u16; + struct bt_uuid_128 u128; + undefined1 field3[18]; // Automatically generated padding to match DWARF declared size +}; + +typedef struct anon_struct_for_ppcp anon_struct_for_ppcp, *Panon_struct_for_ppcp; + +struct anon_struct_for_ppcp { + u16_t min_int; + u16_t max_int; + u16_t latency; + u16_t timeout; +}; + + +// WARNING! conflicting data type names: /DWARF/gatt.c/read_included_uuid_cb/anon_union_for_u - /DWARF/gatt.c/gatt_find_info_rsp/anon_union_for_u + +typedef struct ipc_emb_env_tag ipc_emb_env_tag, *Pipc_emb_env_tag; + +typedef struct co_list co_list, *Pco_list; + +typedef struct txdesc_host txdesc_host, *Ptxdesc_host; + +typedef struct co_list_hdr co_list_hdr, *Pco_list_hdr; + +typedef struct hostdesc hostdesc, *Phostdesc; + +typedef struct mac_addr mac_addr, *Pmac_addr; + +struct co_list_hdr { + struct co_list_hdr * next; +}; + +struct mac_addr { + uint16_t array[3]; +}; + +struct hostdesc { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr eth_dest_addr; + struct mac_addr eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct co_list { + struct co_list_hdr * first; + struct co_list_hdr * last; +}; + +struct ipc_emb_env_tag { + struct co_list rx_queue; + struct co_list cfm_queue; + uint8_t ipc_rxdesc_idx; + uint8_t ipc_rxbuf_idx; + uint8_t ipc_radar_buf_idx; + uint8_t ipc_msge2a_buf_idx; + uint8_t ipc_dbg_buf_idx; + uint8_t ipc_msgacke2a_cnt; + undefined field_0x16; + undefined field_0x17; + uint32_t txdesc_idx; + struct txdesc_host * txdesc; +}; + +struct txdesc_host { + uint32_t ready; + struct hostdesc host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct romapi_freertos_map romapi_freertos_map, *Promapi_freertos_map; + +struct romapi_freertos_map { + void * vApplicationIdleHook; + void * interrupt_entry_ptr; + void * vApplicationGetIdleTaskMemory; + void * vApplicationStackOverflowHook; + void * vApplicationGetTimerTaskMemory; + void * rtos_sprintf; + void * vApplicationMallocFailedHook; + void * rtos_memcpy_ptr; + void * vAssertCalled; + void * rtos_strlen_ptr; + void * rtos_memset_ptr; + void * rtos_clz; + void * exception_entry_ptr; + void * rtos_strcpy_ptr; + void * xISRStackTop; +}; + +typedef struct mac_hdr_qos mac_hdr_qos, *Pmac_hdr_qos; + +struct mac_hdr_qos { + uint16_t fctl; + uint16_t durid; + struct mac_addr addr1; + struct mac_addr addr2; + struct mac_addr addr3; + uint16_t seq; + uint16_t qos; +}; + +typedef struct eth_hdr eth_hdr, *Peth_hdr; + +struct eth_hdr { + struct mac_addr da; + struct mac_addr sa; + uint16_t len; +}; + +typedef struct mac_hdr_long_qos mac_hdr_long_qos, *Pmac_hdr_long_qos; + +struct mac_hdr_long_qos { + uint16_t fctl; + uint16_t durid; + struct mac_addr addr1; + struct mac_addr addr2; + struct mac_addr addr3; + uint16_t seq; + struct mac_addr addr4; + uint16_t qos; +}; + +typedef struct mac_hdr mac_hdr, *Pmac_hdr; + +struct mac_hdr { + uint16_t fctl; + uint16_t durid; + struct mac_addr addr1; + struct mac_addr addr2; + struct mac_addr addr3; + uint16_t seq; +}; + +typedef struct bcn_frame bcn_frame, *Pbcn_frame; + +struct bcn_frame { + struct mac_hdr h; + uint64_t tsf; + uint16_t bcnint; + uint16_t capa; + uint8_t[0] variable; +}; + +typedef struct mac_hdr_long mac_hdr_long, *Pmac_hdr_long; + +struct mac_hdr_long { + uint16_t fctl; + uint16_t durid; + struct mac_addr addr1; + struct mac_addr addr2; + struct mac_addr addr3; + uint16_t seq; + struct mac_addr addr4; +}; + +typedef struct preq_frame preq_frame, *Ppreq_frame; + +struct preq_frame { + struct mac_hdr h; + uint8_t[0] payload; +}; + +typedef struct mac_hdr_ctrl mac_hdr_ctrl, *Pmac_hdr_ctrl; + +struct mac_hdr_ctrl { + uint16_t fctl; + uint16_t durid; + struct mac_addr addr1; + struct mac_addr addr2; +}; + +typedef struct sm_disconnect_req sm_disconnect_req, *Psm_disconnect_req; + +struct sm_disconnect_req { + uint16_t reason_code; + uint8_t vif_idx; + undefined field_0x3; +}; + +typedef struct sm_disconnect_ind sm_disconnect_ind, *Psm_disconnect_ind; + +struct sm_disconnect_ind { + uint16_t reason_code; + uint8_t vif_idx; + _Bool ft_over_ds; +}; + +typedef struct sm_connect_req sm_connect_req, *Psm_connect_req; + +typedef struct mac_ssid mac_ssid, *Pmac_ssid; + +typedef struct scan_chan_tag scan_chan_tag, *Pscan_chan_tag; + +struct scan_chan_tag { + uint16_t freq; + uint8_t band; + uint8_t flags; + int8_t tx_power; + undefined field_0x5; +}; + +struct mac_ssid { + uint8_t length; + uint8_t array[32]; + uint8_t array_tail[1]; +}; + +struct sm_connect_req { + struct mac_ssid ssid; + struct mac_addr bssid; + struct scan_chan_tag chan; + undefined field_0x2e; + undefined field_0x2f; + uint32_t flags; + uint16_t ctrl_port_ethertype; + uint16_t ie_len; + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t auth_type; + uint8_t uapsd_queues; + uint8_t vif_idx; + undefined field_0x3e; + undefined field_0x3f; + uint32_t ie_buf[64]; + _Bool is_supplicant_enabled; + uint8_t phrase[64]; + uint8_t phrase_pmk[64]; + undefined field_0x1c1; + undefined field_0x1c2; + undefined field_0x1c3; +}; + +typedef struct sm_connect_cfm sm_connect_cfm, *Psm_connect_cfm; + +struct sm_connect_cfm { + uint8_t status; +}; + +typedef enum sm_state_tag { + SM_ACTIVATING=7, + SM_ASSOCIATING=6, + SM_AUTHENTICATING=5, + SM_BSS_PARAM_SETTING=4, + SM_DISCONNECTING=8, + SM_IDLE=0, + SM_JOINING=2, + SM_SCANNING=1, + SM_STATE_MAX=9, + SM_STA_ADDING=3 +} sm_state_tag; + +typedef struct sm_connect_ind sm_connect_ind, *Psm_connect_ind; + +struct sm_connect_ind { + uint16_t status_code; + struct mac_addr bssid; + _Bool roamed; + uint8_t vif_idx; + uint8_t ap_idx; + uint8_t ch_idx; + _Bool qos; + uint8_t acm; + uint16_t assoc_req_ie_len; + uint16_t assoc_rsp_ie_len; + undefined field_0x12; + undefined field_0x13; + uint32_t assoc_ie_buf[200]; + uint16_t aid; + uint8_t band; + undefined field_0x337; + uint16_t center_freq; + uint8_t width; + undefined field_0x33b; + uint32_t center_freq1; + uint32_t center_freq2; + uint32_t ac_param[4]; +}; + +typedef enum sm_msg_tag { + SM_CONNECT_CFM=6145, + SM_CONNECT_IND=6146, + SM_CONNECT_REQ=6144, + SM_DISCONNECT_CFM=6148, + SM_DISCONNECT_IND=6149, + SM_DISCONNECT_REQ=6147, + SM_MAX=6151, + SM_RSP_TIMEOUT_IND=6150 +} sm_msg_tag; + +typedef struct mm_csa_counter_ind mm_csa_counter_ind, *Pmm_csa_counter_ind; + +struct mm_csa_counter_ind { + uint8_t vif_index; + uint8_t csa_count; +}; + +typedef struct mm_force_idle_req mm_force_idle_req, *Pmm_force_idle_req; + +struct mm_force_idle_req { + void (* cb)(void); +}; + +typedef struct mm_set_bssid_req mm_set_bssid_req, *Pmm_set_bssid_req; + +struct mm_set_bssid_req { + struct mac_addr bssid; + uint8_t inst_nbr; +}; + +typedef struct mm_monitor_channel_cfm mm_monitor_channel_cfm, *Pmm_monitor_channel_cfm; + +struct mm_monitor_channel_cfm { + uint32_t status; + uint32_t freq; + uint32_t data[8]; +}; + +typedef struct mm_rssi_status_ind mm_rssi_status_ind, *Pmm_rssi_status_ind; + +struct mm_rssi_status_ind { + uint8_t vif_index; + _Bool rssi_status; + int8_t rssi; +}; + +typedef struct mm_sta_del_req mm_sta_del_req, *Pmm_sta_del_req; + +struct mm_sta_del_req { + uint8_t sta_idx; +}; + +typedef struct mm_set_channel_req mm_set_channel_req, *Pmm_set_channel_req; + +struct mm_set_channel_req { + uint8_t band; + uint8_t type; + uint16_t prim20_freq; + uint16_t center1_freq; + uint16_t center2_freq; + uint8_t index; + int8_t tx_power; +}; + +typedef struct mm_sta_add_req mm_sta_add_req, *Pmm_sta_add_req; + +struct mm_sta_add_req { + uint32_t ampdu_size_max_vht; + uint32_t paid_gid; + uint16_t ampdu_size_max_ht; + struct mac_addr mac_addr; + uint8_t ampdu_spacing_min; + uint8_t inst_nbr; + _Bool tdls_sta; + int8_t rssi; + uint32_t tsflo; + uint32_t tsfhi; + uint8_t data_rate; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +typedef struct mm_set_power_cfm mm_set_power_cfm, *Pmm_set_power_cfm; + +struct mm_set_power_cfm { + uint8_t radio_idx; + int8_t power; +}; + +typedef struct mm_set_mode_req mm_set_mode_req, *Pmm_set_mode_req; + +struct mm_set_mode_req { + uint8_t abgnmode; +}; + +typedef struct mm_chan_ctxt_update_req mm_chan_ctxt_update_req, *Pmm_chan_ctxt_update_req; + +struct mm_chan_ctxt_update_req { + uint8_t chan_index; + uint8_t band; + uint8_t type; + undefined field_0x3; + uint16_t prim20_freq; + uint16_t center1_freq; + uint16_t center2_freq; + int8_t tx_power; + undefined field_0xb; +}; + +typedef struct mm_monitor_req mm_monitor_req, *Pmm_monitor_req; + +struct mm_monitor_req { + uint32_t enable; +}; + +typedef struct mm_cfg_rssi_req mm_cfg_rssi_req, *Pmm_cfg_rssi_req; + +struct mm_cfg_rssi_req { + uint8_t vif_index; + int8_t rssi_thold; + uint8_t rssi_hyst; +}; + +typedef struct mm_set_beacon_int_req mm_set_beacon_int_req, *Pmm_set_beacon_int_req; + +struct mm_set_beacon_int_req { + uint16_t beacon_int; + uint8_t inst_nbr; + undefined field_0x3; +}; + +typedef struct mm_traffic_req_ind mm_traffic_req_ind, *Pmm_traffic_req_ind; + +struct mm_traffic_req_ind { + uint8_t sta_idx; + uint8_t pkt_cnt; + _Bool uapsd; +}; + +typedef struct mm_set_power_req mm_set_power_req, *Pmm_set_power_req; + +struct mm_set_power_req { + uint8_t inst_nbr; + int8_t power; +}; + +typedef struct mm_set_dtim_req mm_set_dtim_req, *Pmm_set_dtim_req; + +struct mm_set_dtim_req { + uint8_t dtim_period; +}; + +typedef struct mm_bcn_change_req mm_bcn_change_req, *Pmm_bcn_change_req; + +struct mm_bcn_change_req { + uint32_t bcn_ptr; + uint16_t bcn_len; + uint16_t tim_oft; + uint8_t tim_len; + uint8_t inst_nbr; + uint8_t csa_oft[2]; + uint8_t[0] bcn_buf; +}; + +typedef struct mm_key_del_req mm_key_del_req, *Pmm_key_del_req; + +struct mm_key_del_req { + uint8_t hw_key_idx; +}; + +typedef struct mm_set_edca_req mm_set_edca_req, *Pmm_set_edca_req; + +struct mm_set_edca_req { + uint32_t ac_param; + _Bool uapsd; + uint8_t hw_queue; + uint8_t inst_nbr; + undefined field_0x7; +}; + +typedef struct mm_set_filter_req mm_set_filter_req, *Pmm_set_filter_req; + +struct mm_set_filter_req { + uint32_t filter; +}; + +typedef struct mm_set_channel_cfm mm_set_channel_cfm, *Pmm_set_channel_cfm; + +struct mm_set_channel_cfm { + uint8_t radio_idx; + int8_t power; +}; + +typedef struct mm_add_if_req mm_add_if_req, *Pmm_add_if_req; + +struct mm_add_if_req { + uint8_t type; + struct mac_addr addr; + _Bool p2p; +}; + +typedef struct mm_ba_add_req mm_ba_add_req, *Pmm_ba_add_req; + +struct mm_ba_add_req { + uint8_t type; + uint8_t sta_idx; + uint8_t tid; + uint8_t bufsz; + uint16_t ssn; +}; + +typedef struct mm_monitor_cfm mm_monitor_cfm, *Pmm_monitor_cfm; + +struct mm_monitor_cfm { + uint32_t status; + uint32_t enable; + uint32_t data[8]; +}; + +typedef struct mm_csa_finish_ind mm_csa_finish_ind, *Pmm_csa_finish_ind; + +struct mm_csa_finish_ind { + uint8_t vif_index; + uint8_t status; + uint8_t chan_idx; +}; + +typedef struct mm_chan_ctxt_add_req mm_chan_ctxt_add_req, *Pmm_chan_ctxt_add_req; + +struct mm_chan_ctxt_add_req { + uint8_t band; + uint8_t type; + uint16_t prim20_freq; + uint16_t center1_freq; + uint16_t center2_freq; + int8_t tx_power; + undefined field_0x9; +}; + +typedef struct mm_set_idle_req mm_set_idle_req, *Pmm_set_idle_req; + +struct mm_set_idle_req { + uint8_t hw_idle; +}; + +typedef struct mm_sta_add_cfm mm_sta_add_cfm, *Pmm_sta_add_cfm; + +struct mm_sta_add_cfm { + uint8_t status; + uint8_t sta_idx; + uint8_t hw_sta_idx; +}; + +typedef struct mm_set_ps_mode_req mm_set_ps_mode_req, *Pmm_set_ps_mode_req; + +struct mm_set_ps_mode_req { + uint8_t new_state; +}; + +typedef struct mm_ba_add_cfm mm_ba_add_cfm, *Pmm_ba_add_cfm; + +struct mm_ba_add_cfm { + uint8_t sta_idx; + uint8_t tid; + uint8_t status; +}; + +typedef struct mm_key_add_cfm mm_key_add_cfm, *Pmm_key_add_cfm; + +struct mm_key_add_cfm { + uint8_t status; + uint8_t hw_key_idx; +}; + +typedef struct mm_ps_change_ind mm_ps_change_ind, *Pmm_ps_change_ind; + +struct mm_ps_change_ind { + uint8_t sta_idx; + uint8_t ps_state; +}; + +typedef struct mm_remain_on_channel_req mm_remain_on_channel_req, *Pmm_remain_on_channel_req; + +struct mm_remain_on_channel_req { + uint8_t op_code; + uint8_t vif_index; + uint8_t band; + uint8_t type; + uint16_t prim20_freq; + uint16_t center1_freq; + uint16_t center2_freq; + undefined field_0xa; + undefined field_0xb; + uint32_t duration_ms; + int8_t tx_power; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct mm_remain_on_channel_cfm mm_remain_on_channel_cfm, *Pmm_remain_on_channel_cfm; + +struct mm_remain_on_channel_cfm { + uint8_t op_code; + uint8_t status; + uint8_t chan_ctxt_index; +}; + +typedef struct mm_tim_update_req mm_tim_update_req, *Pmm_tim_update_req; + +struct mm_tim_update_req { + uint16_t aid; + uint8_t tx_avail; + uint8_t inst_nbr; +}; + +typedef enum mm_msg_tag { + MM_ADD_IF_CFM=7, + MM_ADD_IF_REQ=6, + MM_BA_ADD_CFM=41, + MM_BA_ADD_REQ=40, + MM_BA_DEL_CFM=43, + MM_BA_DEL_REQ=42, + MM_BCN_CHANGE_CFM=64, + MM_BCN_CHANGE_REQ=63, + MM_BFMER_ENABLE_REQ=80, + MM_CFG_RSSI_REQ=86, + MM_CHANNEL_PRE_SWITCH_IND=69, + MM_CHANNEL_SURVEY_IND=79, + MM_CHANNEL_SWITCH_IND=68, + MM_CHAN_CTXT_ADD_CFM=52, + MM_CHAN_CTXT_ADD_REQ=51, + MM_CHAN_CTXT_DEL_CFM=54, + MM_CHAN_CTXT_DEL_REQ=53, + MM_CHAN_CTXT_LINK_CFM=56, + MM_CHAN_CTXT_LINK_REQ=55, + MM_CHAN_CTXT_SCHED_CFM=62, + MM_CHAN_CTXT_SCHED_REQ=61, + MM_CHAN_CTXT_UNLINK_CFM=58, + MM_CHAN_CTXT_UNLINK_REQ=57, + MM_CHAN_CTXT_UPDATE_CFM=60, + MM_CHAN_CTXT_UPDATE_REQ=59, + MM_CONNECTION_LOSS_IND=67, + MM_CSA_COUNTER_IND=78, + MM_CSA_FINISH_IND=88, + MM_CSA_TRAFFIC_IND=89, + MM_DENOISE_REQ=48, + MM_FORCE_IDLE_REQ=96, + MM_KEY_ADD_CFM=37, + MM_KEY_ADD_REQ=36, + MM_KEY_DEL_CFM=39, + MM_KEY_DEL_REQ=38, + MM_MAX=99, + MM_MONITOR_CFM=93, + MM_MONITOR_CHANNEL_CFM=95, + MM_MONITOR_CHANNEL_REQ=94, + MM_MONITOR_REQ=92, + MM_MU_GROUP_UPDATE_CFM=91, + MM_MU_GROUP_UPDATE_REQ=90, + MM_P2P_NOA_UPD_IND=85, + MM_P2P_VIF_PS_CHANGE_IND=77, + MM_PRIMARY_TBTT_IND=44, + MM_PS_CHANGE_IND=73, + MM_REMAIN_ON_CHANNEL_CFM=71, + MM_REMAIN_ON_CHANNEL_EXP_IND=72, + MM_REMAIN_ON_CHANNEL_REQ=70, + MM_REMOVE_IF_CFM=9, + MM_REMOVE_IF_REQ=8, + MM_RESET_CFM=1, + MM_RESET_REQ=0, + MM_RSSI_STATUS_IND=87, + MM_SCAN_CHANNEL_END_IND=98, + MM_SCAN_CHANNEL_START_IND=97, + MM_SECONDARY_TBTT_IND=45, + MM_SET_BASIC_RATES_CFM=23, + MM_SET_BASIC_RATES_REQ=22, + MM_SET_BEACON_INT_CFM=21, + MM_SET_BEACON_INT_REQ=20, + MM_SET_BSSID_CFM=25, + MM_SET_BSSID_REQ=24, + MM_SET_CHANNEL_CFM=17, + MM_SET_CHANNEL_REQ=16, + MM_SET_DTIM_CFM=19, + MM_SET_DTIM_REQ=18, + MM_SET_EDCA_CFM=27, + MM_SET_EDCA_REQ=26, + MM_SET_FILTER_CFM=15, + MM_SET_FILTER_REQ=14, + MM_SET_IDLE_CFM=35, + MM_SET_IDLE_REQ=34, + MM_SET_MODE_CFM=29, + MM_SET_MODE_REQ=28, + MM_SET_P2P_NOA_CFM=83, + MM_SET_P2P_NOA_REQ=81, + MM_SET_P2P_OPPPS_CFM=84, + MM_SET_P2P_OPPPS_REQ=82, + MM_SET_POWER_CFM=47, + MM_SET_POWER_REQ=46, + MM_SET_PS_MODE_CFM=50, + MM_SET_PS_MODE_REQ=49, + MM_SET_PS_OPTIONS_CFM=76, + MM_SET_PS_OPTIONS_REQ=75, + MM_SET_SLOTTIME_CFM=33, + MM_SET_SLOTTIME_REQ=32, + MM_SET_VIF_STATE_CFM=31, + MM_SET_VIF_STATE_REQ=30, + MM_START_CFM=3, + MM_START_REQ=2, + MM_STA_ADD_CFM=11, + MM_STA_ADD_REQ=10, + MM_STA_DEL_CFM=13, + MM_STA_DEL_REQ=12, + MM_TIM_UPDATE_CFM=66, + MM_TIM_UPDATE_REQ=65, + MM_TRAFFIC_REQ_IND=74, + MM_VERSION_CFM=5, + MM_VERSION_REQ=4 +} mm_msg_tag; + +typedef struct mm_monitor_channel_req mm_monitor_channel_req, *Pmm_monitor_channel_req; + +struct mm_monitor_channel_req { + uint32_t freq; + uint32_t use_40Mhz; + uint32_t higher_band; +}; + +typedef struct mm_key_add_req mm_key_add_req, *Pmm_key_add_req; + +typedef struct mac_sec_key mac_sec_key, *Pmac_sec_key; + +struct mac_sec_key { + uint8_t length; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + uint32_t array[8]; +}; + +struct mm_key_add_req { + uint8_t key_idx; + uint8_t sta_idx; + undefined field_0x2; + undefined field_0x3; + struct mac_sec_key key; + uint8_t cipher_suite; + uint8_t inst_nbr; + uint8_t spp; + _Bool pairwise; +}; + +typedef struct mm_set_vif_state_req mm_set_vif_state_req, *Pmm_set_vif_state_req; + +struct mm_set_vif_state_req { + uint16_t aid; + _Bool active; + uint8_t inst_nbr; +}; + +typedef struct mm_start_req mm_start_req, *Pmm_start_req; + +typedef struct phy_cfg_tag phy_cfg_tag, *Pphy_cfg_tag; + +struct phy_cfg_tag { + uint32_t parameters[16]; +}; + +struct mm_start_req { + struct phy_cfg_tag phy_cfg; + uint32_t uapsd_timeout; + uint16_t lp_clk_accuracy; + undefined field_0x46; + undefined field_0x47; +}; + +typedef enum mm_remain_on_channel_op { + MM_ROC_OP_CANCEL=1, + MM_ROC_OP_MAX=2, + MM_ROC_OP_START=0 +} mm_remain_on_channel_op; + +typedef struct mm_remove_if_req mm_remove_if_req, *Pmm_remove_if_req; + +struct mm_remove_if_req { + uint8_t inst_nbr; +}; + +typedef struct mm_version_cfm mm_version_cfm, *Pmm_version_cfm; + +struct mm_version_cfm { + uint32_t version_lmac; + uint32_t version_machw_1; + uint32_t version_machw_2; + uint32_t version_phy_1; + uint32_t version_phy_2; + uint32_t features; +}; + +typedef struct mm_add_if_cfm mm_add_if_cfm, *Pmm_add_if_cfm; + +struct mm_add_if_cfm { + uint8_t status; + uint8_t inst_nbr; +}; + +typedef struct mm_set_ps_options_req mm_set_ps_options_req, *Pmm_set_ps_options_req; + +struct mm_set_ps_options_req { + uint8_t vif_index; + undefined field_0x1; + uint16_t listen_interval; + _Bool dont_listen_bc_mc; + undefined field_0x5; +}; + +typedef struct mm_connection_loss_ind mm_connection_loss_ind, *Pmm_connection_loss_ind; + +struct mm_connection_loss_ind { + uint8_t inst_nbr; +}; + +typedef struct mm_csa_traffic_ind mm_csa_traffic_ind, *Pmm_csa_traffic_ind; + +struct mm_csa_traffic_ind { + uint8_t vif_index; + _Bool enable; +}; + +typedef struct mm_set_basic_rates_req mm_set_basic_rates_req, *Pmm_set_basic_rates_req; + +struct mm_set_basic_rates_req { + uint32_t rates; + uint8_t inst_nbr; + uint8_t band; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct mm_set_slottime_req mm_set_slottime_req, *Pmm_set_slottime_req; + +struct mm_set_slottime_req { + uint8_t slottime; +}; + +typedef enum mm_state_tag { + MM_ACTIVE=1, + MM_GOING_TO_IDLE=2, + MM_HOST_BYPASSED=3, + MM_IDLE=0, + MM_STATE_MAX=4 +} mm_state_tag; + +typedef struct dns_hdr dns_hdr, *Pdns_hdr; + +struct dns_hdr { + u16_t id; + u8_t flags1; + u8_t flags2; + u16_t numquestions; + u16_t numanswers; + u16_t numauthrr; + u16_t numextrarr; +}; + +typedef enum lwip_ieee_eth_type { + ETHTYPE_ARP=2054, + ETHTYPE_ETHERCAT=-30556, + ETHTYPE_IP=2048, + ETHTYPE_IPV6=-31011, + ETHTYPE_JUMBO=-30608, + ETHTYPE_LLDP=-30516, + ETHTYPE_MRP=-30493, + ETHTYPE_PPPOE=-30620, + ETHTYPE_PPPOEDISC=-30621, + ETHTYPE_PROFINET=-30574, + ETHTYPE_PTP=-30473, + ETHTYPE_QINQ=-28416, + ETHTYPE_RARP=-32715, + ETHTYPE_SERCOS=-30515, + ETHTYPE_VLAN=-32512, + ETHTYPE_WOL=2114 +} lwip_ieee_eth_type; + +typedef struct dns_table_entry.conflict dns_table_entry.conflict, *Pdns_table_entry.conflict; + +struct dns_table_entry.conflict { + u32_t ttl; + ip_addr_t ipaddr; + u16_t txid; + u8_t state; + u8_t server_idx; + u8_t tmr; + u8_t retries; + u8_t seqno; + char name[256]; + undefined field_0x10f; +}; + +typedef struct dns_req_entry dns_req_entry, *Pdns_req_entry; + +struct dns_req_entry { + void (* found)(char *, ip_addr_t *, void *); + void * arg; +}; + +typedef struct dns_table_entry.conflict1 dns_table_entry.conflict1, *Pdns_table_entry.conflict1; + +struct dns_table_entry.conflict1 { + u32_t ttl; + ip_addr_t ipaddr; + u16_t txid; + u8_t state; + u8_t server_idx; + u8_t tmr; + u8_t retries; + u8_t seqno; + char name[256]; + undefined field_0x10f; +}; + +typedef struct dns_query dns_query, *Pdns_query; + +struct dns_query { + u16_t type; + u16_t cls; +}; + +typedef struct dns_answer dns_answer, *Pdns_answer; + +struct dns_answer { + u16_t type; + u16_t cls; + u32_t ttl; + u16_t len; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct bt_hci_cp_vs_set_tx_pwr bt_hci_cp_vs_set_tx_pwr, *Pbt_hci_cp_vs_set_tx_pwr; + +struct bt_hci_cp_vs_set_tx_pwr { + int8_t power; +}; + +typedef struct bt_mesh_proxy_client.conflict bt_mesh_proxy_client.conflict, *Pbt_mesh_proxy_client.conflict; + +typedef enum anon_enum_8_for_filter_type.conflict { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLACKLIST=2, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_GATT_PERM_NONE=0, + BT_GATT_PERM_PREPARE_WRITE=64, + BT_GATT_PERM_READ=1, + BT_GATT_PERM_READ_AUTHEN=16, + BT_GATT_PERM_READ_ENCRYPT=4, + BT_GATT_PERM_WRITE=2, + BT_GATT_PERM_WRITE_AUTHEN=32, + BT_GATT_PERM_WRITE_ENCRYPT=8, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_ACTIVE=1, + LINK_INVALID=5, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_GATT_NONE=0, + MESH_GATT_PROV=1, + MESH_GATT_PROXY=2, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + NONE=0, + NOTIFY_INPUT_COMPLETE=4, + NUM_FLAGS=6, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PROV=3, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + REMOTE_PUB_KEY=0, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WAIT_NUMBER=2, + WAIT_STRING=3, + WHITELIST=1, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_filter_type.conflict; + +struct bt_mesh_proxy_client.conflict { + struct bt_conn * conn; + u16_t filter[1]; + enum anon_enum_8_for_filter_type.conflict filter_type; + u8_t msg_type; + struct k_work send_beacons; + struct k_delayed_work sar_timer; + struct net_buf_simple buf; +}; + +typedef struct bt_mesh_proxy_client bt_mesh_proxy_client, *Pbt_mesh_proxy_client; + +typedef enum anon_enum_8_for_filter_type { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLACKLIST=2, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_GATT_PERM_NONE=0, + BT_GATT_PERM_PREPARE_WRITE=64, + BT_GATT_PERM_READ=1, + BT_GATT_PERM_READ_AUTHEN=16, + BT_GATT_PERM_READ_ENCRYPT=4, + BT_GATT_PERM_WRITE=2, + BT_GATT_PERM_WRITE_AUTHEN=32, + BT_GATT_PERM_WRITE_ENCRYPT=8, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_ACTIVE=1, + LINK_INVALID=5, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + NONE=0, + NOTIFY_INPUT_COMPLETE=4, + NUM_FLAGS=6, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PROV=3, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + REMOTE_PUB_KEY=0, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WAIT_NUMBER=2, + WAIT_STRING=3, + WHITELIST=1, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_filter_type; + +struct bt_mesh_proxy_client { + struct bt_conn * conn; + u16_t filter[1]; + enum anon_enum_8_for_filter_type filter_type; + u8_t msg_type; + struct k_work send_beacons; + struct k_delayed_work sar_timer; + struct net_buf_simple buf; +}; + +typedef struct bl_dma_item bl_dma_item, *Pbl_dma_item; + +typedef struct utils_list_hdr utils_list_hdr, *Putils_list_hdr; + +struct utils_list_hdr { + struct utils_list_hdr * next; +}; + +struct bl_dma_item { + struct utils_list_hdr item; + void (* cb)(void *); + void * arg; + uint32_t src; + uint32_t dst; + uint32_t next; + uint32_t ctrl; +}; + +typedef struct dma_ctx dma_ctx, *Pdma_ctx; + +typedef struct utils_dlist_s utils_dlist_s, *Putils_dlist_s; + +typedef struct utils_dlist_s utils_dlist_t; + +struct utils_dlist_s { + struct utils_dlist_s * prev; + struct utils_dlist_s * next; +}; + +struct dma_ctx { + utils_dlist_t * pstqueue; +}; + +typedef struct dma_node dma_node, *Pdma_node; + +struct dma_node { + utils_dlist_t dlist_item; + int channel; + void * tc_handler; + void * interr_handler; + void * ctx; +}; + +typedef struct aos_dir_t aos_dir_t, *Paos_dir_t; + +struct aos_dir_t { + int dd_vfs_fd; + int dd_rsv; +}; + +typedef struct aos_dirent_t aos_dirent_t, *Paos_dirent_t; + +struct aos_dirent_t { // Missing member d_name : char[1] at offset 0x5 [Unsupported interior flex array: char[1]] + int d_ino; + uint8_t d_type; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct statfs statfs, *Pstatfs; + +struct statfs { + long f_type; + long f_bsize; + long f_blocks; + long f_bfree; + long f_bavail; + long f_files; + long f_ffree; + long f_fsid; + long f_namelen; +}; + +typedef ushort UHWtype; + +typedef struct bl_custom_pbuf bl_custom_pbuf, *Pbl_custom_pbuf; + +typedef struct bl_custom_pbuf bl_custom_pbuf_t; + +typedef struct pbuf_custom pbuf_custom, *Ppbuf_custom; + +typedef struct pbuf pbuf, *Ppbuf; + +struct pbuf { + struct pbuf * next; + void * payload; + u16_t tot_len; + u16_t len; + u8_t type_internal; + u8_t flags; + u8_t ref; + u8_t if_idx; +}; + +struct pbuf_custom { + struct pbuf pbuf; + void (* custom_free_function)(struct pbuf *); +}; + +struct bl_custom_pbuf { + struct pbuf_custom p; + void * swdesc; +}; + +typedef struct bt_mesh_health_srv_cb bt_mesh_health_srv_cb, *Pbt_mesh_health_srv_cb; + +typedef struct bt_mesh_model bt_mesh_model, *Pbt_mesh_model; + + +// WARNING! conflicting data type names: /DWARF/access.h/bt_mesh_model/anon_union_for_field_0 - /DWARF/buf.h/net_buf/anon_union_for_field_0 + +typedef struct bt_mesh_model_pub bt_mesh_model_pub, *Pbt_mesh_model_pub; + +typedef struct bt_mesh_model_op bt_mesh_model_op, *Pbt_mesh_model_op; + +typedef struct bt_mesh_msg_ctx bt_mesh_msg_ctx, *Pbt_mesh_msg_ctx; + +struct bt_mesh_model { + union anon_union_for_field_0 field_0; + u8_t elem_idx; + u8_t mod_idx; + u16_t flags; + struct bt_mesh_model_pub * pub; + u16_t keys[2]; + u16_t groups[2]; + struct bt_mesh_model_op * op; + void * user_data; +}; + +struct bt_mesh_model_pub { + struct bt_mesh_model * mod; + u16_t addr; + u16_t key; + u8_t ttl; + u8_t retransmit; + u8_t period; + u8_t period_div:4; + u8_t cred:1; + u8_t fast_period:1; + u8_t count:3; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u32_t.conflict period_start; + struct net_buf_simple * msg; + int (* update)(struct bt_mesh_model *); + struct k_delayed_work timer; + uint8_t dev_role; + undefined field_0x41; + undefined field_0x42; + undefined field_0x43; +}; + +struct bt_mesh_msg_ctx { + u16_t net_idx; + u16_t app_idx; + u16_t addr; + u16_t recv_dst; + s8_t recv_rssi; + u8_t recv_ttl; + _Bool send_rel; + u8_t send_ttl; + u32_t.conflict recv_op; + struct bt_mesh_model * model; + _Bool srv_send; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_mesh_health_srv_cb { + int (* fault_get_cur)(struct bt_mesh_model *, u8_t *, u16_t *, u8_t *, u8_t *); + int (* fault_get_reg)(struct bt_mesh_model *, u16_t, u8_t *, u8_t *, u8_t *); + int (* fault_clear)(struct bt_mesh_model *, u16_t); + int (* fault_test)(struct bt_mesh_model *, u8_t, u16_t); + void (* attn_on)(struct bt_mesh_model *); + void (* attn_off)(struct bt_mesh_model *); +}; + +struct bt_mesh_model_op { + u32_t.conflict opcode; + size_t min_len; + void (* func)(struct bt_mesh_model *, struct bt_mesh_msg_ctx *, struct net_buf_simple *); +}; + +typedef struct bt_mesh_health_srv bt_mesh_health_srv, *Pbt_mesh_health_srv; + +struct bt_mesh_health_srv { + struct bt_mesh_model * model; + struct bt_mesh_health_srv_cb * cb; + struct k_delayed_work attn_timer; +}; + +typedef enum bl_dev_flag { + RWNX_DEV_RESTARTING=0, + RWNX_DEV_STACK_RESTARTING=1, + RWNX_DEV_STARTED=2 +} bl_dev_flag; + +typedef uchar UQItype; + +typedef int shift_count_type; + +typedef struct DWstruct DWstruct, *PDWstruct; + +typedef int SItype; + +struct DWstruct { + SItype low; + SItype high; +}; + +typedef union DWunion DWunion, *PDWunion; + +typedef longlong DItype; + +union DWunion { + struct DWstruct s; + DItype ll; +}; + +typedef ulonglong UDItype; + +typedef uint USItype; + +typedef float SFtype; + +typedef struct _httpc_state.conflict _httpc_state.conflict, *P_httpc_state.conflict; + +typedef s8_t err_t; + +typedef struct altcp_pcb altcp_pcb, *Paltcp_pcb; + +typedef struct altcp_functions altcp_functions, *Paltcp_functions; + +typedef err_t (* altcp_connected_fn)(void *, struct altcp_pcb *, err_t); + +typedef err_t (* altcp_accept_fn)(void *, struct altcp_pcb *, err_t); + +typedef struct _httpc_connection.conflict1 _httpc_connection.conflict1, *P_httpc_connection.conflict1; + +typedef enum ehttpc_result { + HTTPC_RESULT_ERR_CLOSED=4, + HTTPC_RESULT_ERR_CONNECT=2, + HTTPC_RESULT_ERR_CONTENT_LEN=9, + HTTPC_RESULT_ERR_HOSTNAME=3, + HTTPC_RESULT_ERR_MEM=7, + HTTPC_RESULT_ERR_SVR_RESP=6, + HTTPC_RESULT_ERR_TIMEOUT=5, + HTTPC_RESULT_ERR_UNKNOWN=1, + HTTPC_RESULT_LOCAL_ABORT=8, + HTTPC_RESULT_OK=0 +} ehttpc_result; + +typedef enum ehttpc_result httpc_result_t; + +typedef struct _httpc_state _httpc_state, *P_httpc_state; + +typedef struct _httpc_state httpc_state_t; + +typedef struct _httpc_connection.conflict1 httpc_connection_t.conflict1; + +typedef enum ehttpc_parse_state { + HTTPC_PARSE_RX_DATA=2, + HTTPC_PARSE_WAIT_FIRST_LINE=0, + HTTPC_PARSE_WAIT_HEADERS=1 +} ehttpc_parse_state; + +typedef enum ehttpc_parse_state httpc_parse_state_t; + +typedef void (* altcp_set_poll_fn)(struct altcp_pcb *, u8_t); + +typedef void (* altcp_abort_fn)(struct altcp_pcb *); + +typedef err_t (* altcp_close_fn)(struct altcp_pcb *); + +typedef err_t (* altcp_output_fn)(struct altcp_pcb *); + +typedef u16_t (* altcp_mss_fn)(struct altcp_pcb *); + +typedef u16_t (* altcp_sndbuf_fn)(struct altcp_pcb *); + +typedef u16_t (* altcp_sndqueuelen_fn)(struct altcp_pcb *); + +typedef void (* altcp_nagle_disable_fn)(struct altcp_pcb *); + +typedef void (* altcp_nagle_enable_fn)(struct altcp_pcb *); + +typedef void (* altcp_setprio_fn)(struct altcp_pcb *, u8_t); + +typedef void (* altcp_dealloc_fn)(struct altcp_pcb *); + +typedef struct altcp_allocator_s altcp_allocator_s, *Paltcp_allocator_s; + +typedef struct altcp_allocator_s altcp_allocator_t; + +typedef struct _httpc_connection.conflict _httpc_connection.conflict, *P_httpc_connection.conflict; + +typedef struct _httpc_connection.conflict httpc_connection_t.conflict; + +struct altcp_pcb { + struct altcp_functions * fns; + struct altcp_pcb * inner_conn; + void * arg; + void * state; + altcp_accept_fn accept; + altcp_connected_fn connected; + err_t (* recv)(void *, struct altcp_pcb *, struct pbuf *, err_t); + err_t (* sent)(void *, struct altcp_pcb *, u16_t); + err_t (* poll)(void *, struct altcp_pcb *); + void (* err)(void *, err_t); + u8_t pollinterval; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +struct _httpc_connection.conflict { + ip_addr_t proxy_addr; + u16_t proxy_port; + u8_t use_proxy; + u8_t req_type; + u8_t * data; + u8_t content_type; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + altcp_allocator_t * altcp_allocator; + void (* result_fn)(void *, httpc_result_t, u32_t, u32_t, err_t); + err_t (* headers_done_fn)(httpc_state_t *, void *, struct pbuf *, u16_t, u32_t); +}; + +struct altcp_functions { + altcp_set_poll_fn set_poll; + void (* recved)(struct altcp_pcb *, u16_t); + err_t (* bind)(struct altcp_pcb *, ip_addr_t *, u16_t); + err_t (* connect)(struct altcp_pcb *, ip_addr_t *, u16_t, altcp_connected_fn); + altcp_pcb * (* listen)(struct altcp_pcb *, u8_t, err_t *); + altcp_abort_fn abort; + altcp_close_fn close; + err_t (* shutdown)(struct altcp_pcb *, int, int); + err_t (* write)(struct altcp_pcb *, void *, u16_t, u8_t); + altcp_output_fn output; + altcp_mss_fn mss; + altcp_sndbuf_fn sndbuf; + altcp_sndqueuelen_fn sndqueuelen; + altcp_nagle_disable_fn nagle_disable; + altcp_nagle_enable_fn nagle_enable; + int (* nagle_disabled)(struct altcp_pcb *); + altcp_setprio_fn setprio; + altcp_dealloc_fn dealloc; + err_t (* addrinfo)(struct altcp_pcb *, int, ip_addr_t *, u16_t *); + ip_addr_t * (* getip)(struct altcp_pcb *, int); + u16_t (* getport)(struct altcp_pcb *, int); +}; + +struct _httpc_state.conflict { + struct altcp_pcb * pcb; + ip_addr_t remote_addr; + u16_t remote_port; + undefined field_0xa; + undefined field_0xb; + int timeout_ticks; + struct pbuf * request; + struct pbuf * rx_hdrs; + u16_t rx_http_version; + u16_t rx_status; + err_t (* recv_fn)(void *, struct altcp_pcb *, struct pbuf *, err_t); + httpc_connection_t.conflict1 * conn_settings; + void * callback_arg; + u32_t rx_content_len; + u32_t hdr_content_len; + httpc_parse_state_t parse_state; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +struct _httpc_connection.conflict1 { + ip_addr_t proxy_addr; + u16_t proxy_port; + u8_t use_proxy; + u8_t req_type; + u8_t * data; + u8_t content_type; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + altcp_allocator_t * altcp_allocator; + void (* result_fn)(void *, httpc_result_t, u32_t, u32_t, err_t); + err_t (* headers_done_fn)(httpc_state_t *, void *, struct pbuf *, u16_t, u32_t); +}; + +struct altcp_allocator_s { + altcp_pcb * (* alloc)(void *, u8_t); + void * arg; +}; + +struct _httpc_state { + struct altcp_pcb * pcb; + ip_addr_t remote_addr; + u16_t remote_port; + undefined field_0xa; + undefined field_0xb; + int timeout_ticks; + struct pbuf * request; + struct pbuf * rx_hdrs; + u16_t rx_http_version; + u16_t rx_status; + err_t (* recv_fn)(void *, struct altcp_pcb *, struct pbuf *, err_t); + httpc_connection_t.conflict * conn_settings; + void * callback_arg; + u32_t rx_content_len; + u32_t hdr_content_len; + httpc_parse_state_t parse_state; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef enum BL_AHB_Slave1_Type { + BL_AHB_SLAVE1_CCI=8, + BL_AHB_SLAVE1_CKS=23, + BL_AHB_SLAVE1_DBG=3, + BL_AHB_SLAVE1_DMA=12, + BL_AHB_SLAVE1_EFUSE=7, + BL_AHB_SLAVE1_GLB=0, + BL_AHB_SLAVE1_GPIP=2, + BL_AHB_SLAVE1_I2C=19, + BL_AHB_SLAVE1_IRR=22, + BL_AHB_SLAVE1_L1C=9, + BL_AHB_SLAVE1_MAX=24, + BL_AHB_SLAVE1_PDSHBN=14, + BL_AHB_SLAVE1_PWM=20, + BL_AHB_SLAVE1_RF=1, + BL_AHB_SLAVE1_SDU=13, + BL_AHB_SLAVE1_SEC=4, + BL_AHB_SLAVE1_SFC=11, + BL_AHB_SLAVE1_SPI=18, + BL_AHB_SLAVE1_TMR=21, + BL_AHB_SLAVE1_TZ1=5, + BL_AHB_SLAVE1_TZ2=6, + BL_AHB_SLAVE1_UART0=16, + BL_AHB_SLAVE1_UART1=17, + BL_AHB_SLAVE1_WRAM=15 +} BL_AHB_Slave1_Type; + +typedef struct _httpc_connection.conflict2 _httpc_connection.conflict2, *P_httpc_connection.conflict2; + +struct _httpc_connection.conflict2 { + ip_addr_t proxy_addr; + u16_t proxy_port; + u8_t use_proxy; + u8_t req_type; + u8_t * data; + u8_t content_type; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + altcp_allocator_t * altcp_allocator; + void (* result_fn)(void *, httpc_result_t, u32_t, u32_t, err_t); + err_t (* headers_done_fn)(httpc_state_t *, void *, struct pbuf *, u16_t, u32_t); +}; + +typedef struct _httpc_connection.conflict3 _httpc_connection.conflict3, *P_httpc_connection.conflict3; + +struct _httpc_connection.conflict3 { + ip_addr_t proxy_addr; + u16_t proxy_port; + u8_t use_proxy; + u8_t req_type; + u8_t * data; + u8_t content_type; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + altcp_allocator_t * altcp_allocator; + void (* result_fn)(void *, httpc_result_t, u32_t, u32_t, err_t); + err_t (* headers_done_fn)(httpc_state_t *, void *, struct pbuf *, u16_t, u32_t); +}; + +typedef struct _httpc_connection.conflict4 _httpc_connection.conflict4, *P_httpc_connection.conflict4; + +struct _httpc_connection.conflict4 { + ip_addr_t proxy_addr; + u16_t proxy_port; + u8_t use_proxy; + u8_t req_type; + u8_t * data; + u8_t content_type; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + altcp_allocator_t * altcp_allocator; + void (* result_fn)(void *, httpc_result_t, u32_t, u32_t, err_t); + err_t (* headers_done_fn)(httpc_state_t *, void *, struct pbuf *, u16_t, u32_t); +}; + +typedef struct _httpc_connection.conflict5 _httpc_connection.conflict5, *P_httpc_connection.conflict5; + +struct _httpc_connection.conflict5 { + ip_addr_t proxy_addr; + u16_t proxy_port; + u8_t use_proxy; + u8_t req_type; + u8_t * data; + u8_t content_type; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + altcp_allocator_t * altcp_allocator; + void (* result_fn)(void *, httpc_result_t, u32_t, u32_t, err_t); + err_t (* headers_done_fn)(httpc_state_t *, void *, struct pbuf *, u16_t, u32_t); +}; + +typedef struct _httpc_connection.conflict5 httpc_connection_t.conflict4; + +typedef struct _httpc_connection _httpc_connection, *P_httpc_connection; + +typedef struct _httpc_connection httpc_connection_t; + +struct _httpc_connection { + ip_addr_t proxy_addr; + u16_t proxy_port; + u8_t use_proxy; + u8_t req_type; + u8_t * data; + u8_t content_type; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + altcp_allocator_t * altcp_allocator; + void (* result_fn)(void *, httpc_result_t, u32_t, u32_t, err_t); + err_t (* headers_done_fn)(httpc_state_t *, void *, struct pbuf *, u16_t, u32_t); +}; + +typedef struct _httpc_connection.conflict4 httpc_connection_t.conflict3; + +typedef struct _httpc_connection.conflict3 httpc_connection_t.conflict2; + +typedef struct bt_mesh_hb_sub.conflict5 bt_mesh_hb_sub.conflict5, *Pbt_mesh_hb_sub.conflict5; + +typedef longlong s64_t; + +struct bt_mesh_hb_sub.conflict5 { + s64_t expiry; + u16_t src; + u16_t dst; + u16_t count; + u8_t min_hops; + u8_t max_hops; + void (* func)(u16_t, u16_t, u8_t, u16_t); + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_mesh_hb_sub.conflict4 bt_mesh_hb_sub.conflict4, *Pbt_mesh_hb_sub.conflict4; + +struct bt_mesh_hb_sub.conflict4 { + s64_t expiry; + u16_t src; + u16_t dst; + u16_t count; + u8_t min_hops; + u8_t max_hops; + void (* func)(u16_t, u16_t, u8_t, u16_t); + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_mesh_hb_sub.conflict7 bt_mesh_hb_sub.conflict7, *Pbt_mesh_hb_sub.conflict7; + +struct bt_mesh_hb_sub.conflict7 { + s64_t expiry; + u16_t src; + u16_t dst; + u16_t count; + u8_t min_hops; + u8_t max_hops; + void (* func)(u16_t, u16_t, u8_t, u16_t); + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_mesh_hb_sub.conflict6 bt_mesh_hb_sub.conflict6, *Pbt_mesh_hb_sub.conflict6; + +struct bt_mesh_hb_sub.conflict6 { + s64_t expiry; + u16_t src; + u16_t dst; + u16_t count; + u8_t min_hops; + u8_t max_hops; + void (* func)(u16_t, u16_t, u8_t, u16_t); + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_mesh_hb_sub.conflict1 bt_mesh_hb_sub.conflict1, *Pbt_mesh_hb_sub.conflict1; + +struct bt_mesh_hb_sub.conflict1 { + s64_t expiry; + u16_t src; + u16_t dst; + u16_t count; + u8_t min_hops; + u8_t max_hops; + void (* func)(u16_t, u16_t, u8_t, u16_t); + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_mesh_hb_sub.conflict3 bt_mesh_hb_sub.conflict3, *Pbt_mesh_hb_sub.conflict3; + +struct bt_mesh_hb_sub.conflict3 { + s64_t expiry; + u16_t src; + u16_t dst; + u16_t count; + u8_t min_hops; + u8_t max_hops; + void (* func)(u16_t, u16_t, u8_t, u16_t); + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_mesh_hb_sub.conflict2 bt_mesh_hb_sub.conflict2, *Pbt_mesh_hb_sub.conflict2; + +struct bt_mesh_hb_sub.conflict2 { + s64_t expiry; + u16_t src; + u16_t dst; + u16_t count; + u8_t min_hops; + u8_t max_hops; + void (* func)(u16_t, u16_t, u8_t, u16_t); + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_mesh_cfg_srv bt_mesh_cfg_srv, *Pbt_mesh_cfg_srv; + +typedef struct bt_mesh_hb_pub bt_mesh_hb_pub, *Pbt_mesh_hb_pub; + +struct bt_mesh_hb_pub { + struct k_delayed_work timer; + u16_t dst; + u16_t count; + u8_t period; + u8_t ttl; + u16_t feat; + u16_t net_idx; + undefined field_0x2e; + undefined field_0x2f; +}; + +struct bt_mesh_cfg_srv { + struct bt_mesh_model * model; + u8_t net_transmit; + u8_t relay; + u8_t relay_retransmit; + u8_t beacon; + u8_t gatt_proxy; + u8_t frnd; + u8_t default_ttl; + undefined field_0xb; + struct bt_mesh_hb_pub hb_pub; + undefined field_0x3c; + undefined field_0x3d; + undefined field_0x3e; + undefined field_0x3f; + struct bt_mesh_hb_sub.conflict7 hb_sub; +}; + +typedef struct bt_mesh_hb_sub.conflict bt_mesh_hb_sub.conflict, *Pbt_mesh_hb_sub.conflict; + +struct bt_mesh_hb_sub.conflict { + s64_t expiry; + u16_t src; + u16_t dst; + u16_t count; + u8_t min_hops; + u8_t max_hops; + void (* func)(u16_t, u16_t, u8_t, u16_t); + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_mesh_hb_sub bt_mesh_hb_sub, *Pbt_mesh_hb_sub; + +struct bt_mesh_hb_sub { + s64_t expiry; + u16_t src; + u16_t dst; + u16_t count; + u8_t min_hops; + u8_t max_hops; + void (* func)(u16_t, u16_t, u8_t, u16_t); + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct timer_rec_d timer_rec_d, *Ptimer_rec_d; + +struct timer_rec_d { + bl_timer_t timer; + struct k_delayed_work * delay_work; +}; + +typedef struct label label, *Plabel; + +struct label { + u16_t ref; + u16_t addr; + u8_t uuid[16]; +}; + +typedef struct unbind_data unbind_data, *Punbind_data; + +struct unbind_data { + u16_t app_idx; + _Bool store; + undefined field_0x3; +}; + +typedef struct hb_pub_param.conflict hb_pub_param.conflict, *Phb_pub_param.conflict; + +struct hb_pub_param.conflict { + u16_t dst; + u8_t count_log; + u8_t period_log; + u8_t ttl; + u16_t feat; + u16_t net_idx; +}; + +typedef struct connect_t connect_t, *Pconnect_t; + +typedef uint u32; + +typedef enum socket_type { + SOCK_TYPE_TCP=1, + SOCK_TYPE_TLS=3, + SOCK_TYPE_UDP=2 +} socket_type; + +typedef enum auth_mode { + BOTH_AUTH=3, + CLIENT_AUTH_CA=2, + NO_AUTH=0, + SERVER_AUTH_CERT_KEY=1 +} auth_mode; + +typedef union anon_union_for_pcb anon_union_for_pcb, *Panon_union_for_pcb; + +typedef enum socket_state { + SOCK_CLIENT_CONNECTED=3, + SOCK_CLIENT_CONNECTING=2, + SOCK_IDLE_CLOSE=0, + SOCK_SERVER_LISTENING=1 +} socket_state; + +typedef struct udp_pcb udp_pcb, *Pudp_pcb; + +typedef struct anon_struct.conflict575 anon_struct.conflict575, *Panon_struct.conflict575; + +typedef struct altcp_tls_config altcp_tls_config, *Paltcp_tls_config; + +typedef struct mbedtls_ssl_config.conflict3 mbedtls_ssl_config.conflict3, *Pmbedtls_ssl_config.conflict3; + +typedef struct mbedtls_ssl_session mbedtls_ssl_session, *Pmbedtls_ssl_session; + +typedef struct mbedtls_ssl_context mbedtls_ssl_context, *Pmbedtls_ssl_context; + +typedef struct mbedtls_x509_crt mbedtls_x509_crt, *Pmbedtls_x509_crt; + +typedef struct mbedtls_entropy_context mbedtls_entropy_context, *Pmbedtls_entropy_context; + +typedef struct mbedtls_ctr_drbg_context mbedtls_ctr_drbg_context, *Pmbedtls_ctr_drbg_context; + +typedef struct mbedtls_ssl_config mbedtls_ssl_config, *Pmbedtls_ssl_config; + +typedef struct mbedtls_ssl_handshake_params mbedtls_ssl_handshake_params, *Pmbedtls_ssl_handshake_params; + +typedef struct mbedtls_ssl_transform mbedtls_ssl_transform, *Pmbedtls_ssl_transform; + +typedef struct mbedtls_asn1_buf mbedtls_asn1_buf, *Pmbedtls_asn1_buf; + +typedef struct mbedtls_asn1_buf mbedtls_x509_buf; + +typedef struct mbedtls_asn1_named_data mbedtls_asn1_named_data, *Pmbedtls_asn1_named_data; + +typedef struct mbedtls_asn1_named_data mbedtls_x509_name; + +typedef struct mbedtls_x509_time mbedtls_x509_time, *Pmbedtls_x509_time; + +typedef struct mbedtls_asn1_sequence mbedtls_asn1_sequence, *Pmbedtls_asn1_sequence; + +typedef struct mbedtls_asn1_sequence mbedtls_x509_sequence; + +typedef struct mbedtls_x509_crt_profile mbedtls_x509_crt_profile, *Pmbedtls_x509_crt_profile; + +typedef struct mbedtls_ssl_key_cert mbedtls_ssl_key_cert, *Pmbedtls_ssl_key_cert; + +typedef struct mbedtls_x509_crl mbedtls_x509_crl, *Pmbedtls_x509_crl; + +typedef enum mbedtls_ecp_group_id { + MBEDTLS_ECP_DP_BP256R1=6, + MBEDTLS_ECP_DP_BP384R1=7, + MBEDTLS_ECP_DP_BP512R1=8, + MBEDTLS_ECP_DP_CURVE25519=9, + MBEDTLS_ECP_DP_NONE=0, + MBEDTLS_ECP_DP_SECP192K1=10, + MBEDTLS_ECP_DP_SECP192R1=1, + MBEDTLS_ECP_DP_SECP224K1=11, + MBEDTLS_ECP_DP_SECP224R1=2, + MBEDTLS_ECP_DP_SECP256K1=12, + MBEDTLS_ECP_DP_SECP256R1=3, + MBEDTLS_ECP_DP_SECP384R1=4, + MBEDTLS_ECP_DP_SECP521R1=5 +} mbedtls_ecp_group_id; + +typedef struct mbedtls_sha256_context mbedtls_sha256_context, *Pmbedtls_sha256_context; + +typedef struct mbedtls_entropy_source_state mbedtls_entropy_source_state, *Pmbedtls_entropy_source_state; + +typedef struct mbedtls_aes_context mbedtls_aes_context, *Pmbedtls_aes_context; + +typedef struct mbedtls_ssl_flight_item mbedtls_ssl_flight_item, *Pmbedtls_ssl_flight_item; + +typedef struct mbedtls_ssl_ciphersuite_t mbedtls_ssl_ciphersuite_t, *Pmbedtls_ssl_ciphersuite_t; + +typedef struct mbedtls_md_context_t mbedtls_md_context_t, *Pmbedtls_md_context_t; + +typedef struct mbedtls_x509_crl_entry mbedtls_x509_crl_entry, *Pmbedtls_x509_crl_entry; + +typedef enum mbedtls_key_exchange_type_t { + MBEDTLS_KEY_EXCHANGE_DHE_PSK=6, + MBEDTLS_KEY_EXCHANGE_DHE_RSA=2, + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=4, + MBEDTLS_KEY_EXCHANGE_ECDHE_PSK=8, + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=3, + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=10, + MBEDTLS_KEY_EXCHANGE_ECDH_RSA=9, + MBEDTLS_KEY_EXCHANGE_ECJPAKE=11, + MBEDTLS_KEY_EXCHANGE_NONE=0, + MBEDTLS_KEY_EXCHANGE_PSK=5, + MBEDTLS_KEY_EXCHANGE_RSA=1, + MBEDTLS_KEY_EXCHANGE_RSA_PSK=7 +} mbedtls_key_exchange_type_t; + +typedef struct mbedtls_md_info_t mbedtls_md_info_t, *Pmbedtls_md_info_t; + +struct mbedtls_asn1_buf { + int tag; + size_t len; + uchar * p; +}; + +struct mbedtls_asn1_named_data { + struct mbedtls_asn1_buf oid; + struct mbedtls_asn1_buf val; + struct mbedtls_asn1_named_data * next; + uchar next_merged; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +struct mbedtls_ssl_config.conflict3 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_aes_context { + int nr; + uint32_t * rk; + uint32_t buf[68]; +}; + +struct mbedtls_ssl_session { + int ciphersuite; + int compression; + size_t id_len; + uchar id[32]; + uchar master[48]; + struct mbedtls_x509_crt * peer_cert; + uint32_t verify_result; + uchar * ticket; + size_t ticket_len; + uint32_t ticket_lifetime; + uchar mfl_code; + undefined field_0x71; + undefined field_0x72; + undefined field_0x73; +}; + +struct mbedtls_x509_time { + int year; + int mon; + int day; + int hour; + int min; + int sec; +}; + +struct mbedtls_x509_crl_entry { + mbedtls_x509_buf raw; + mbedtls_x509_buf serial; + struct mbedtls_x509_time revocation_date; + mbedtls_x509_buf entry_ext; + struct mbedtls_x509_crl_entry * next; +}; + +struct mbedtls_x509_crl { + mbedtls_x509_buf raw; + mbedtls_x509_buf tbs; + int version; + mbedtls_x509_buf sig_oid; + mbedtls_x509_buf issuer_raw; + mbedtls_x509_name issuer; + struct mbedtls_x509_time this_update; + struct mbedtls_x509_time next_update; + struct mbedtls_x509_crl_entry entry; + mbedtls_x509_buf crl_ext; + mbedtls_x509_buf sig_oid2; + mbedtls_x509_buf sig; + enum mbedtls_md_type_t sig_md; + enum mbedtls_pk_type_t sig_pk; + undefined field_0xea; + undefined field_0xeb; + void * sig_opts; + struct mbedtls_x509_crl * next; +}; + +struct mbedtls_ctr_drbg_context { + uchar counter[16]; + int reseed_counter; + int prediction_resistance; + size_t entropy_len; + int reseed_interval; + struct mbedtls_aes_context aes_ctx; + int (* f_entropy)(void *, uchar *, size_t); + void * p_entropy; +}; + +struct mbedtls_ssl_context { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct mbedtls_md_info_t { + enum mbedtls_md_type_t type; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + char * name; + int size; + int block_size; + void (* starts_func)(void *); + void (* update_func)(void *, uchar *, size_t); + void (* finish_func)(void *, uchar *); + void (* digest_func)(uchar *, size_t, uchar *); + void * (* ctx_alloc_func)(void); + void (* ctx_free_func)(void *); + void (* clone_func)(void *, void *); + void (* process_func)(void *, uchar *); +}; + +struct mbedtls_ssl_config { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_md_context_t { + struct mbedtls_md_info_t * md_info; + void * md_ctx; + void * hmac_ctx; +}; + +struct mbedtls_ssl_transform { + struct mbedtls_ssl_ciphersuite_t * ciphersuite_info; + uint keylen; + size_t minlen; + size_t ivlen; + size_t fixed_ivlen; + size_t maclen; + uchar iv_enc[16]; + uchar iv_dec[16]; + struct mbedtls_md_context_t md_ctx_enc; + struct mbedtls_md_context_t md_ctx_dec; + struct mbedtls_cipher_context_t cipher_ctx_enc; + struct mbedtls_cipher_context_t cipher_ctx_dec; +}; + +struct mbedtls_sha256_context { + uint32_t total[2]; + uint32_t state[8]; + uchar buffer[64]; + int is224; + size_t size; + void * ali_ctx; +}; + +struct mbedtls_asn1_sequence { + struct mbedtls_asn1_buf buf; + struct mbedtls_asn1_sequence * next; +}; + +struct mbedtls_entropy_source_state { + int (* f_source)(void *, uchar *, size_t, size_t *); + void * p_source; + size_t size; + size_t threshold; + int strong; +}; + +struct mbedtls_entropy_context { + struct mbedtls_sha256_context accumulator; + int source_count; + struct mbedtls_entropy_source_state source[20]; +}; + +struct altcp_tls_config { + struct mbedtls_ssl_config.conflict3 conf; + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_x509_crt * cert; + struct mbedtls_pk_context * pkey; + struct mbedtls_x509_crt * ca; +}; + +struct udp_pcb { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct udp_pcb * next; + u8_t flags; + undefined field_0x11; + u16_t local_port; + u16_t remote_port; + undefined field_0x16; + undefined field_0x17; + ip4_addr_t mcast_ip4; + u8_t mcast_ifindex; + u8_t mcast_ttl; + undefined field_0x1e; + undefined field_0x1f; + void (* recv)(void *, struct udp_pcb *, struct pbuf *, ip_addr_t *, u16_t); + void * recv_arg; +}; + +struct mbedtls_ssl_ciphersuite_t { + int id; + char * name; + enum mbedtls_cipher_type_t cipher; + enum mbedtls_md_type_t mac; + enum mbedtls_key_exchange_type_t key_exchange; + undefined field_0xb; + int min_major_ver; + int min_minor_ver; + int max_major_ver; + int max_minor_ver; + uchar flags; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +struct anon_struct.conflict575 { + struct altcp_pcb * pcb; + struct altcp_tls_config * config; +}; + +union anon_union_for_pcb { + struct udp_pcb * udp; + struct altcp_pcb * tcp; + struct anon_struct.conflict575 tls; +}; + +struct connect_t { + char ip[16]; + u32 port; + enum socket_type protocol; + enum auth_mode auth_mode; + undefined field_0x16; + undefined field_0x17; + char * sni; + char * ca; + char * cert; + char * key; + char * * alpn; + union anon_union_for_pcb pcb; + enum socket_state status; + undefined field_0x35; + undefined field_0x36; + undefined field_0x37; +}; + +struct mbedtls_x509_crt { + mbedtls_x509_buf raw; + mbedtls_x509_buf tbs; + int version; + mbedtls_x509_buf serial; + mbedtls_x509_buf sig_oid; + mbedtls_x509_buf issuer_raw; + mbedtls_x509_buf subject_raw; + mbedtls_x509_name issuer; + mbedtls_x509_name subject; + struct mbedtls_x509_time valid_from; + struct mbedtls_x509_time valid_to; + struct mbedtls_pk_context pk; + mbedtls_x509_buf issuer_id; + mbedtls_x509_buf subject_id; + mbedtls_x509_buf v3_ext; + mbedtls_x509_sequence subject_alt_names; + int ext_types; + int ca_istrue; + int max_pathlen; + uint key_usage; + mbedtls_x509_sequence ext_key_usage; + uchar ns_cert_type; + undefined field_0x119; + undefined field_0x11a; + undefined field_0x11b; + mbedtls_x509_buf sig; + enum mbedtls_md_type_t sig_md; + enum mbedtls_pk_type_t sig_pk; + undefined field_0x12a; + undefined field_0x12b; + void * sig_opts; + struct mbedtls_x509_crt * next; +}; + +struct mbedtls_ssl_flight_item { + uchar * p; + size_t len; + uchar type; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + struct mbedtls_ssl_flight_item * next; +}; + +struct mbedtls_ssl_key_cert { + struct mbedtls_x509_crt * cert; + struct mbedtls_pk_context * key; + struct mbedtls_ssl_key_cert * next; +}; + +struct mbedtls_x509_crt_profile { + uint32_t allowed_mds; + uint32_t allowed_pks; + uint32_t allowed_curves; + uint32_t rsa_min_bitlen; +}; + +struct mbedtls_ssl_handshake_params { + int sig_alg; + int verify_sig_alg; + struct mbedtls_ssl_key_cert * key_cert; + int sni_authmode; + struct mbedtls_ssl_key_cert * sni_key_cert; + struct mbedtls_x509_crt * sni_ca_chain; + struct mbedtls_x509_crl * sni_ca_crl; + uint out_msg_seq; + uint in_msg_seq; + uchar * verify_cookie; + uchar verify_cookie_len; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; + uchar * hs_msg; + uint32_t retransmit_timeout; + uchar retransmit_state; + undefined field_0x35; + undefined field_0x36; + undefined field_0x37; + struct mbedtls_ssl_flight_item * flight; + struct mbedtls_ssl_flight_item * cur_msg; + uint in_flight_start_seq; + struct mbedtls_ssl_transform * alt_transform_out; + uchar alt_out_ctr[8]; + struct mbedtls_sha256_context fin_sha256; + void (* update_checksum)(struct mbedtls_ssl_context *, uchar *, size_t); + void (* calc_verify)(struct mbedtls_ssl_context *, uchar *); + void (* calc_finished)(struct mbedtls_ssl_context *, uchar *, int); + int (* tls_prf)(uchar *, size_t, char *, uchar *, size_t, uchar *, size_t); + size_t pmslen; + uchar randbytes[64]; + uchar premaster[48]; + int resume; + int max_major_ver; + int max_minor_ver; + int cli_exts; + int new_session_ticket; +}; + +typedef struct network_t network_t, *Pnetwork_t; + +typedef int s32; + +struct network_t { + s32 count; + struct connect_t connect[5]; +}; + +typedef struct server_arg server_arg, *Pserver_arg; + +typedef short s16; + +struct server_arg { + s16 port; + undefined field_0x2; + undefined field_0x3; + s32 protocol; +}; + +typedef struct server_ctrl_t server_ctrl_t, *Pserver_ctrl_t; + +struct server_ctrl_t { + u32 flag; + s16 port; + undefined field_0x6; + undefined field_0x7; + s32 protocol; + u32 auth_mode; + char * cert; + char * key; + char * ca; + char * * alpn; + union anon_union_for_pcb pcb; +}; + +typedef struct _rom_dir_t _rom_dir_t, *P_rom_dir_t; + +struct _rom_dir_t { + struct aos_dir_t dir; + char * dir_start_addr; + char * dir_end_addr; + char * dir_cur_addr; + struct aos_dirent_t cur_dirent; +}; + +typedef struct _rom_dir_t romfs_dir_t; + +typedef struct romfh romfh, *Promfh; + +struct romfh { + int32_t nextfh; + int32_t spec; + int32_t size; + int32_t checksum; +}; + +typedef struct at_config_t at_config_t, *Pat_config_t; + +struct at_config_t { + at_di_t CIPMUX; + at_di_t apDhcp; + at_di_t staDhcp; + at_di_t link_type[5]; + at_text_t nv_manuf[32]; + at_text_t nv_model[32]; + at_text_t nv_serial[32]; + at_hex_t nv_wifi_macaddr[6]; + undefined field_0x86; + undefined field_0x87; + at_di_t blink_led; + at_hi_t wind_off_low; + at_hi_t wind_off_medium; + at_hi_t wind_off_high; + at_text_t user_desc[64]; + at_text_t escape_seq[8]; + at_di_t localecho1; + at_di_t console1_speed; + at_di_t console1_hwfc; + at_di_t console1_enabled; + at_di_t sleep_enabled; + at_di_t standby_enabled; + at_di_t standby_time; + at_di_t wifi_tx_msdu_lifetime; + at_di_t wifi_rx_msdu_lifetime; + at_hi_t wifi_operational_mode; + at_di_t wifi_beacon_wakeup; + at_di_t wifi_beacon_interval; + at_di_t wifi_listen_interval; + at_di_t wifi_rts_threshold; + at_hex_t wifi_ssid[33]; + undefined field_0x139; + undefined field_0x13a; + undefined field_0x13b; + at_di_t wifi_ssid_len; + at_di_t wifi_channelnum; + at_hi_t wifi_opr_rate_mask; + at_hi_t wifi_bas_rate_mask; + at_di_t wifi_mode; + at_di_t wifi_auth_type; + at_di_t wifi_powersave; + at_di_t wifi_tx_power; + at_di_t wifi_rssi_thresh; + at_di_t wifi_rssi_hyst; + at_di_t wifi_ap_idle_timeout; + at_di_t wifi_beacon_loss_thresh; + at_di_t wifi_priv_mode; + at_hex_t wifi_wep_keys[4][16]; + at_hex_t wifi_wep_key_lens[4]; + at_di_t wifi_wep_default_key; + at_hex_t wifi_wpa_psk_raw[32]; + at_text_t wifi_wpa_psk_text[65]; + undefined field_0x219; + undefined field_0x21a; + undefined field_0x21b; + at_di_t ip_use_dhcp; + at_di_t ip_use_httpd; + at_di_t ip_mtu; + at_text_t ip_hostname[32]; + at_text_t ip_apdomainname[32]; + at_ip_t ip_ipaddr; + at_ip_t ip_netmask; + at_ip_t ip_gw; + at_ip_t ip_dns; + at_di_t ip_http_get_recv_timeout; + at_di_t ip_dhcp_timeout; + at_di_t ip_sockd_timeout; +}; + +typedef struct StreamBufferDef_t StreamBufferDef_t, *PStreamBufferDef_t; + +typedef struct StreamBufferDef_t * StreamBufferHandle_t; + +typedef struct tskTaskControlBlock tskTaskControlBlock, *PtskTaskControlBlock; + +typedef struct tskTaskControlBlock * TaskHandle_t; + +typedef uint32_t StackType_t; + +typedef struct xLIST_ITEM xLIST_ITEM, *PxLIST_ITEM; + +typedef struct xLIST_ITEM ListItem_t; + +typedef struct xLIST xLIST, *PxLIST; + +typedef struct xMINI_LIST_ITEM xMINI_LIST_ITEM, *PxMINI_LIST_ITEM; + +typedef struct xMINI_LIST_ITEM MiniListItem_t; + +struct xMINI_LIST_ITEM { + TickType_t xItemValue; + struct xLIST_ITEM * pxNext; + struct xLIST_ITEM * pxPrevious; +}; + +struct xLIST_ITEM { + TickType_t xItemValue; + struct xLIST_ITEM * pxNext; + struct xLIST_ITEM * pxPrevious; + void * pvOwner; + struct xLIST * pvContainer; +}; + +struct tskTaskControlBlock { + StackType_t * pxTopOfStack; + ListItem_t xStateListItem; + ListItem_t xEventListItem; + UBaseType_t uxPriority; + StackType_t * pxStack; + char pcTaskName[16]; + UBaseType_t uxCriticalNesting; + UBaseType_t uxTCBNumber; + UBaseType_t uxTaskNumber; + UBaseType_t uxBasePriority; + UBaseType_t uxMutexesHeld; + uint32_t ulNotifiedValue; + uint8_t ucNotifyState; + uint8_t ucStaticallyAllocated; + undefined field_0x5e; + undefined field_0x5f; +}; + +struct StreamBufferDef_t { + size_t xTail; + size_t xHead; + size_t xLength; + size_t xTriggerLevelBytes; + TaskHandle_t xTaskWaitingToReceive; + TaskHandle_t xTaskWaitingToSend; + uint8_t * pucBuffer; + uint8_t ucFlags; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; + UBaseType_t uxStreamBufferNumber; +}; + +struct xLIST { + UBaseType_t uxNumberOfItems; + ListItem_t * pxIndex; + MiniListItem_t xListEnd; +}; + +typedef long __suseconds_t; + +typedef __suseconds_t suseconds_t; + +typedef struct timeval timeval, *Ptimeval; + +typedef longlong __int_least64_t; + +typedef __int_least64_t time_t; + +struct timeval { + time_t tv_sec; + suseconds_t tv_usec; + undefined field_0xc; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; +}; + +typedef struct StreamBufferDef_t StreamBuffer_t; + +typedef struct chan_env_tag chan_env_tag, *Pchan_env_tag; + +typedef struct chan_ctxt_tag chan_ctxt_tag, *Pchan_ctxt_tag; + +typedef struct mm_timer_tag mm_timer_tag, *Pmm_timer_tag; + +typedef uint16_t ke_task_id_t; + +struct mm_timer_tag { + struct co_list_hdr list_hdr; + void (* cb)(void *); + void * env; + uint32_t time; +}; + +struct chan_env_tag { + struct co_list list_free_ctxt; + struct co_list list_sched_ctxt; + struct co_list list_tbtt; + struct co_list list_tbtt_delay; + struct chan_ctxt_tag * current_channel; + struct chan_ctxt_tag * chan_switch; + struct mm_timer_tag tmr_tbtt_switch; + struct mm_timer_tag tmr_cde; + struct mm_timer_tag tmr_ctxt_op; + struct mm_timer_tag tmr_conn_less; + uint32_t cde_dur_us; + uint32_t cde_time; + uint8_t status; + uint8_t cfm_cnt; + uint8_t nb_sched_ctxt; + uint8_t pm; +}; + +struct chan_ctxt_tag { + struct co_list_hdr list_hdr; + struct mm_chan_ctxt_add_req channel; + ke_task_id_t taskid; + uint16_t nb_slots; + uint16_t nb_rem_slots; + uint16_t nb_res_slots; + uint8_t status; + uint8_t idx; + uint8_t nb_linked_vif; + uint8_t vif_index; + undefined field_0x1a; + undefined field_0x1b; +}; + +typedef struct chan_tbtt_tag chan_tbtt_tag, *Pchan_tbtt_tag; + +struct chan_tbtt_tag { + struct co_list_hdr list_hdr; + uint32_t time; + uint8_t vif_index; + uint8_t priority; + uint8_t status; + undefined field_0xb; +}; + +typedef enum chan_tbtt_status { + CHAN_TBTT_NOT_PROG=0, + CHAN_TBTT_PRESENCE=2, + CHAN_TBTT_PROG=1, + CHAN_TBTT_STATUS_MAX=3 +} chan_tbtt_status; + +typedef enum chan_env_status_bit { + CHAN_ENV_BCN_DETECT_BIT=6, + CHAN_ENV_BIT_MAX=7, + CHAN_ENV_DELAY_PROG_BIT=4, + CHAN_ENV_ROC_BIT=2, + CHAN_ENV_ROC_WAIT_BIT=0, + CHAN_ENV_SCAN_BIT=3, + CHAN_ENV_SCAN_WAIT_BIT=1, + CHAN_ENV_TIMEOUT_BIT=5 +} chan_env_status_bit; + +typedef enum chan_ctxt_status { + CHAN_CTXT_STATUS_MAX=7, + CHAN_GOTO_IDLE=2, + CHAN_NOT_PROG=1, + CHAN_NOT_SCHEDULED=0, + CHAN_PRESENT=5, + CHAN_SENDING_NOA=6, + CHAN_WAITING_END=4, + CHAN_WAIT_NOA_CFM=3 +} chan_ctxt_status; + +typedef struct txl_cfm_env_tag txl_cfm_env_tag, *Ptxl_cfm_env_tag; + +struct txl_cfm_env_tag { + struct co_list cfmlist[5]; +}; + +typedef struct wifi_pkt wifi_pkt, *Pwifi_pkt; + +struct wifi_pkt { + uint32_t pkt[4]; + void * pbuf[4]; + uint16_t len[4]; +}; + +typedef struct wifi_mgmr_ap_item wifi_mgmr_ap_item, *Pwifi_mgmr_ap_item; + +typedef struct wifi_mgmr_ap_item wifi_mgmr_ap_item_t; + +struct wifi_mgmr_ap_item { + char ssid[32]; + char ssid_tail[1]; + undefined field_0x21; + undefined field_0x22; + undefined field_0x23; + uint32_t ssid_len; + uint8_t bssid[6]; + uint8_t channel; + uint8_t auth; + int8_t rssi; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef enum WIFI_STATE_ENUM_LIST { + WIFI_STATE_CONNECTED_IP_GETTING=3, + WIFI_STATE_CONNECTED_IP_GOT=4, + WIFI_STATE_CONNECTING=2, + WIFI_STATE_DISCONNECT=5, + WIFI_STATE_IDLE=1, + WIFI_STATE_IFDOWN=6, + WIFI_STATE_NO_AP_FOUND=9, + WIFI_STATE_PSK_ERROR=8, + WIFI_STATE_SNIFFER=7, + WIFI_STATE_UNKNOWN=0, + WIFI_STATE_WITH_AP_CONNECTED_IP_GETTING=19, + WIFI_STATE_WITH_AP_CONNECTED_IP_GOT=20, + WIFI_STATE_WITH_AP_CONNECTING=18, + WIFI_STATE_WITH_AP_DISCONNECT=21, + WIFI_STATE_WITH_AP_IDLE=17 +} WIFI_STATE_ENUM_LIST; + +typedef struct wifi_conf wifi_conf, *Pwifi_conf; + +typedef struct wifi_conf wifi_conf_t; + +struct wifi_conf { + char country_code[3]; + undefined field_0x3; + int channel_nums; +}; + +typedef struct wifi_sta_basic_info wifi_sta_basic_info, *Pwifi_sta_basic_info; + +struct wifi_sta_basic_info { + uint8_t sta_idx; + uint8_t is_used; + uint8_t sta_mac[6]; + uint32_t tsfhi; + uint32_t tsflo; + int rssi; + uint8_t data_rate; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct wifi_mgmr_sta_connect_ind_stat_info wifi_mgmr_sta_connect_ind_stat_info, *Pwifi_mgmr_sta_connect_ind_stat_info; + +typedef struct wifi_mgmr_sta_connect_ind_stat_info wifi_mgmr_sta_connect_ind_stat_info_t; + +struct wifi_mgmr_sta_connect_ind_stat_info { + uint16_t status_code; + uint8_t type_ind; + char ssid[32]; + char psk[65]; + char pmk[64]; + uint8_t bssid[6]; + uint16_t chan_freq; + uint8_t chan_band; + undefined field_0xad; +}; + +typedef void * wifi_interface_t; + +typedef enum WIFI_SCAN_DONE_EVENT_TYPE { + WIFI_SCAN_DONE_EVENT_BUSY=1, + WIFI_SCAN_DONE_EVENT_OK=0 +} WIFI_SCAN_DONE_EVENT_TYPE; + +typedef struct rx_cntrl_pm_mon rx_cntrl_pm_mon, *Prx_cntrl_pm_mon; + +struct rx_cntrl_pm_mon { + struct mac_addr addr; + uint8_t pm_state; + _Bool mon; +}; + +typedef struct rx_cntrl_ipcdesc rx_cntrl_ipcdesc, *Prx_cntrl_ipcdesc; + +struct rx_cntrl_ipcdesc { + uint32_t host_id; +}; + +typedef struct rxu_cntrl_env_tag rxu_cntrl_env_tag, *Prxu_cntrl_env_tag; + +typedef struct rx_cntrl_rx_status rx_cntrl_rx_status, *Prx_cntrl_rx_status; + +typedef struct rx_cntrl_dupli rx_cntrl_dupli, *Prx_cntrl_dupli; + +typedef struct key_info_tag key_info_tag, *Pkey_info_tag; + + +// WARNING! conflicting data type names: /DWARF/mac.h/key_info_tag/anon_union_for_u - /DWARF/gatt.c/gatt_find_info_rsp/anon_union_for_u + +struct rx_cntrl_dupli { + struct mac_addr last_src_addr; + uint16_t last_seq_cntl; +}; + +struct rx_cntrl_rx_status { + uint16_t frame_cntl; + uint16_t seq_cntl; + uint16_t sn; + uint8_t fn; + uint8_t tid; + uint8_t machdr_len; + uint8_t sta_idx; + uint8_t vif_idx; + uint8_t dst_idx; + undefined field_0xc; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint64_t pn; + uint32_t statinfo; + uint32_t host_buf_addr; + struct key_info_tag * key; + struct mac_addr da; + struct mac_addr sa; + uint8_t frame_info; + _Bool eth_len_present; + uint8_t payl_offset; + undefined field_0x33; + undefined field_0x34; + undefined field_0x35; + undefined field_0x36; + undefined field_0x37; +}; + +struct rxu_cntrl_env_tag { + struct rx_cntrl_rx_status rx_status; + struct co_list rxdesc_pending; + struct co_list rxdesc_ready; + struct rx_cntrl_ipcdesc rx_ipcdesc_stat; + struct co_list rxu_defrag_free; + struct co_list rxu_defrag_used; + struct rx_cntrl_dupli rxu_dupli; + struct mac_addr * mac_addr_ptr; + struct rx_cntrl_pm_mon pm_mon; + uint32_t ttr; + undefined field_0x74; + undefined field_0x75; + undefined field_0x76; + undefined field_0x77; +}; + +struct key_info_tag { + uint64_t rx_pn[9]; + uint64_t tx_pn; + union anon_union_for_u u; + uint8_t cipher; + uint8_t key_idx; + uint8_t hw_key_idx; + _Bool valid; + undefined field_0x64; + undefined field_0x65; + undefined field_0x66; + undefined field_0x67; +}; + +typedef enum rx_status_bits { + RX_STAT_ALLOC=2, + RX_STAT_COPY=32, + RX_STAT_DELETE=4, + RX_STAT_ETH_LEN_UPDATE=16, + RX_STAT_FORWARD=1, + RX_STAT_LEN_UPDATE=8 +} rx_status_bits; + +typedef struct rxu_mic_calc rxu_mic_calc, *Prxu_mic_calc; + +typedef struct mic_calc mic_calc, *Pmic_calc; + +struct mic_calc { + uint32_t mic_key_least; + uint32_t mic_key_most; + uint32_t last_m_i; + uint8_t last_m_i_len; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; +}; + +struct rxu_mic_calc { + struct mic_calc mic_calc; + uint32_t last_bytes[2]; +}; + +typedef enum rxu_cntrl_frame_info_pos { + RXU_CNTRL_MIC_CHECK_NEEDED=1, + RXU_CNTRL_NEW_MESH_PEER=4, + RXU_CNTRL_PN_CHECK_NEEDED=2 +} rxu_cntrl_frame_info_pos; + +typedef void (* altcp_err_fn.conflict)(void *, err_t); + +typedef struct altcp_pcb.conflict altcp_pcb.conflict, *Paltcp_pcb.conflict; + +struct altcp_pcb.conflict { + struct altcp_functions * fns; + struct altcp_pcb * inner_conn; + void * arg; + void * state; + altcp_accept_fn accept; + altcp_connected_fn connected; + err_t (* recv)(void *, struct altcp_pcb *, struct pbuf *, err_t); + err_t (* sent)(void *, struct altcp_pcb *, u16_t); + err_t (* poll)(void *, struct altcp_pcb *); + void (* err)(void *, err_t); + u8_t pollinterval; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct altcp_pcb.conflict1 altcp_pcb.conflict1, *Paltcp_pcb.conflict1; + +struct altcp_pcb.conflict1 { + struct altcp_functions * fns; + struct altcp_pcb * inner_conn; + void * arg; + void * state; + altcp_accept_fn accept; + altcp_connected_fn connected; + err_t (* recv)(void *, struct altcp_pcb *, struct pbuf *, err_t); + err_t (* sent)(void *, struct altcp_pcb *, u16_t); + err_t (* poll)(void *, struct altcp_pcb *); + void (* err)(void *, err_t); + u8_t pollinterval; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct altcp_pcb.conflict2 altcp_pcb.conflict2, *Paltcp_pcb.conflict2; + +struct altcp_pcb.conflict2 { + struct altcp_functions * fns; + struct altcp_pcb * inner_conn; + void * arg; + void * state; + altcp_accept_fn accept; + altcp_connected_fn connected; + err_t (* recv)(void *, struct altcp_pcb *, struct pbuf *, err_t); + err_t (* sent)(void *, struct altcp_pcb *, u16_t); + err_t (* poll)(void *, struct altcp_pcb *); + void (* err)(void *, err_t); + u8_t pollinterval; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct altcp_pcb.conflict3 altcp_pcb.conflict3, *Paltcp_pcb.conflict3; + +struct altcp_pcb.conflict3 { + struct altcp_functions * fns; + struct altcp_pcb * inner_conn; + void * arg; + void * state; + altcp_accept_fn accept; + altcp_connected_fn connected; + err_t (* recv)(void *, struct altcp_pcb *, struct pbuf *, err_t); + err_t (* sent)(void *, struct altcp_pcb *, u16_t); + err_t (* poll)(void *, struct altcp_pcb *); + altcp_err_fn.conflict err; + u8_t pollinterval; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct altcp_pcb.conflict4 altcp_pcb.conflict4, *Paltcp_pcb.conflict4; + +struct altcp_pcb.conflict4 { + struct altcp_functions * fns; + struct altcp_pcb * inner_conn; + void * arg; + void * state; + altcp_accept_fn accept; + altcp_connected_fn connected; + err_t (* recv)(void *, struct altcp_pcb *, struct pbuf *, err_t); + err_t (* sent)(void *, struct altcp_pcb *, u16_t); + err_t (* poll)(void *, struct altcp_pcb *); + void (* err)(void *, err_t); + u8_t pollinterval; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct co_read16_struct co_read16_struct, *Pco_read16_struct; + +struct co_read16_struct { + uint16_t val; +}; + +typedef struct co_read32_struct co_read32_struct, *Pco_read32_struct; + +struct co_read32_struct { + uint32_t val; +}; + +typedef struct bt_mesh_comp bt_mesh_comp, *Pbt_mesh_comp; + +typedef struct bt_mesh_elem bt_mesh_elem, *Pbt_mesh_elem; + +struct bt_mesh_elem { + u16_t addr; + u16_t loc; + u8_t model_count; + u8_t vnd_model_count; + undefined field_0x6; + undefined field_0x7; + struct bt_mesh_model * models; + struct bt_mesh_model * vnd_models; +}; + +struct bt_mesh_comp { + u16_t cid; + u16_t pid; + u16_t vid; + undefined field_0x6; + undefined field_0x7; + size_t elem_count; + struct bt_mesh_elem * elem; +}; + +typedef struct anon_struct.conflict461 anon_struct.conflict461, *Panon_struct.conflict461; + +struct anon_struct.conflict461 { + u16_t company; + u16_t id; +}; + +typedef struct anon_struct.conflict478 anon_struct.conflict478, *Panon_struct.conflict478; + +struct anon_struct.conflict478 { + u16_t company; + u16_t id; +}; + +typedef struct anon_struct.conflict475 anon_struct.conflict475, *Panon_struct.conflict475; + +struct anon_struct.conflict475 { + u16_t company; + u16_t id; +}; + +typedef struct bt_mesh_model_pub.conflict bt_mesh_model_pub.conflict, *Pbt_mesh_model_pub.conflict; + +struct bt_mesh_model_pub.conflict { + struct bt_mesh_model * mod; + u16_t addr; + u16_t key; + u8_t ttl; + u8_t retransmit; + u8_t period; + u8_t period_div:4; + u8_t cred:1; + u8_t fast_period:1; + u8_t count:3; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u32_t.conflict period_start; + struct net_buf_simple * msg; + int (* update)(struct bt_mesh_model *); + struct k_delayed_work timer; + uint8_t dev_role; + undefined field_0x41; + undefined field_0x42; + undefined field_0x43; +}; + +typedef struct anon_struct.conflict482 anon_struct.conflict482, *Panon_struct.conflict482; + +struct anon_struct.conflict482 { + u16_t company; + u16_t id; +}; + +typedef struct anon_struct.conflict411 anon_struct.conflict411, *Panon_struct.conflict411; + +struct anon_struct.conflict411 { + u16_t company; + u16_t id; +}; + +typedef struct anon_struct.conflict410 anon_struct.conflict410, *Panon_struct.conflict410; + +struct anon_struct.conflict410 { + u16_t company; + u16_t id; +}; + +typedef struct anon_struct.conflict415 anon_struct.conflict415, *Panon_struct.conflict415; + +struct anon_struct.conflict415 { + u16_t company; + u16_t id; +}; + +typedef struct bt_mesh_send_cb bt_mesh_send_cb, *Pbt_mesh_send_cb; + +struct bt_mesh_send_cb { + void (* start)(u16_t, int, void *); + void (* end)(int, void *); +}; + +typedef struct anon_struct.conflict423 anon_struct.conflict423, *Panon_struct.conflict423; + +struct anon_struct.conflict423 { + u16_t company; + u16_t id; +}; + +typedef struct anon_struct.conflict421 anon_struct.conflict421, *Panon_struct.conflict421; + +struct anon_struct.conflict421 { + u16_t company; + u16_t id; +}; + +typedef struct bt_mesh_model_pub.conflict6 bt_mesh_model_pub.conflict6, *Pbt_mesh_model_pub.conflict6; + +struct bt_mesh_model_pub.conflict6 { + struct bt_mesh_model * mod; + u16_t addr; + u16_t key; + u8_t ttl; + u8_t retransmit; + u8_t period; + u8_t period_div:4; + u8_t cred:1; + u8_t fast_period:1; + u8_t count:3; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u32_t.conflict period_start; + struct net_buf_simple * msg; + int (* update)(struct bt_mesh_model *); + struct k_delayed_work timer; + uint8_t dev_role; + undefined field_0x41; + undefined field_0x42; + undefined field_0x43; +}; + +typedef struct bt_mesh_model_pub.conflict7 bt_mesh_model_pub.conflict7, *Pbt_mesh_model_pub.conflict7; + +struct bt_mesh_model_pub.conflict7 { + struct bt_mesh_model * mod; + u16_t addr; + u16_t key; + u8_t ttl; + u8_t retransmit; + u8_t period; + u8_t period_div:4; + u8_t cred:1; + u8_t fast_period:1; + u8_t count:3; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u32_t.conflict period_start; + struct net_buf_simple * msg; + int (* update)(struct bt_mesh_model *); + struct k_delayed_work timer; + uint8_t dev_role; + undefined field_0x41; + undefined field_0x42; + undefined field_0x43; +}; + +typedef struct bt_mesh_model_pub.conflict8 bt_mesh_model_pub.conflict8, *Pbt_mesh_model_pub.conflict8; + +struct bt_mesh_model_pub.conflict8 { + struct bt_mesh_model * mod; + u16_t addr; + u16_t key; + u8_t ttl; + u8_t retransmit; + u8_t period; + u8_t period_div:4; + u8_t cred:1; + u8_t fast_period:1; + u8_t count:3; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u32_t.conflict period_start; + struct net_buf_simple * msg; + int (* update)(struct bt_mesh_model *); + struct k_delayed_work timer; + uint8_t dev_role; + undefined field_0x41; + undefined field_0x42; + undefined field_0x43; +}; + +typedef struct bt_mesh_model_pub.conflict9 bt_mesh_model_pub.conflict9, *Pbt_mesh_model_pub.conflict9; + +struct bt_mesh_model_pub.conflict9 { + struct bt_mesh_model * mod; + u16_t addr; + u16_t key; + u8_t ttl; + u8_t retransmit; + u8_t period; + u8_t period_div:4; + u8_t cred:1; + u8_t fast_period:1; + u8_t count:3; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u32_t.conflict period_start; + struct net_buf_simple * msg; + int (* update)(struct bt_mesh_model *); + struct k_delayed_work timer; + uint8_t dev_role; + undefined field_0x41; + undefined field_0x42; + undefined field_0x43; +}; + +typedef struct bt_mesh_model_pub.conflict2 bt_mesh_model_pub.conflict2, *Pbt_mesh_model_pub.conflict2; + +struct bt_mesh_model_pub.conflict2 { + struct bt_mesh_model * mod; + u16_t addr; + u16_t key; + u8_t ttl; + u8_t retransmit; + u8_t period; + u8_t period_div:4; + u8_t cred:1; + u8_t fast_period:1; + u8_t count:3; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u32_t.conflict period_start; + struct net_buf_simple * msg; + int (* update)(struct bt_mesh_model *); + struct k_delayed_work timer; + uint8_t dev_role; + undefined field_0x41; + undefined field_0x42; + undefined field_0x43; +}; + +typedef struct bt_mesh_model_pub.conflict3 bt_mesh_model_pub.conflict3, *Pbt_mesh_model_pub.conflict3; + +struct bt_mesh_model_pub.conflict3 { + struct bt_mesh_model * mod; + u16_t addr; + u16_t key; + u8_t ttl; + u8_t retransmit; + u8_t period; + u8_t period_div:4; + u8_t cred:1; + u8_t fast_period:1; + u8_t count:3; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u32_t.conflict period_start; + struct net_buf_simple * msg; + int (* update)(struct bt_mesh_model *); + struct k_delayed_work timer; + uint8_t dev_role; + undefined field_0x41; + undefined field_0x42; + undefined field_0x43; +}; + +typedef struct bt_mesh_model_pub.conflict4 bt_mesh_model_pub.conflict4, *Pbt_mesh_model_pub.conflict4; + +struct bt_mesh_model_pub.conflict4 { + struct bt_mesh_model * mod; + u16_t addr; + u16_t key; + u8_t ttl; + u8_t retransmit; + u8_t period; + u8_t period_div:4; + u8_t cred:1; + u8_t fast_period:1; + u8_t count:3; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u32_t.conflict period_start; + struct net_buf_simple * msg; + int (* update)(struct bt_mesh_model *); + struct k_delayed_work timer; + uint8_t dev_role; + undefined field_0x41; + undefined field_0x42; + undefined field_0x43; +}; + +typedef struct bt_mesh_model_pub.conflict5 bt_mesh_model_pub.conflict5, *Pbt_mesh_model_pub.conflict5; + +struct bt_mesh_model_pub.conflict5 { + struct bt_mesh_model * mod; + u16_t addr; + u16_t key; + u8_t ttl; + u8_t retransmit; + u8_t period; + u8_t period_div:4; + u8_t cred:1; + u8_t fast_period:1; + u8_t count:3; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u32_t.conflict period_start; + struct net_buf_simple * msg; + int (* update)(struct bt_mesh_model *); + struct k_delayed_work timer; + uint8_t dev_role; + undefined field_0x41; + undefined field_0x42; + undefined field_0x43; +}; + +typedef struct bt_mesh_model_pub.conflict1 bt_mesh_model_pub.conflict1, *Pbt_mesh_model_pub.conflict1; + +struct bt_mesh_model_pub.conflict1 { + struct bt_mesh_model * mod; + u16_t addr; + u16_t key; + u8_t ttl; + u8_t retransmit; + u8_t period; + u8_t period_div:4; + u8_t cred:1; + u8_t fast_period:1; + u8_t count:3; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u32_t.conflict period_start; + struct net_buf_simple * msg; + int (* update)(struct bt_mesh_model *); + struct k_delayed_work timer; + uint8_t dev_role; + undefined field_0x41; + undefined field_0x42; + undefined field_0x43; +}; + +typedef struct bt_mesh_model_pub.conflict12 bt_mesh_model_pub.conflict12, *Pbt_mesh_model_pub.conflict12; + +struct bt_mesh_model_pub.conflict12 { + struct bt_mesh_model * mod; + u16_t addr; + u16_t key; + u8_t ttl; + u8_t retransmit; + u8_t period; + u8_t period_div:4; + u8_t cred:1; + u8_t fast_period:1; + u8_t count:3; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u32_t.conflict period_start; + struct net_buf_simple * msg; + int (* update)(struct bt_mesh_model *); + struct k_delayed_work timer; + uint8_t dev_role; + undefined field_0x41; + undefined field_0x42; + undefined field_0x43; +}; + +typedef struct bt_mesh_model_pub.conflict11 bt_mesh_model_pub.conflict11, *Pbt_mesh_model_pub.conflict11; + +struct bt_mesh_model_pub.conflict11 { + struct bt_mesh_model * mod; + u16_t addr; + u16_t key; + u8_t ttl; + u8_t retransmit; + u8_t period; + u8_t period_div:4; + u8_t cred:1; + u8_t fast_period:1; + u8_t count:3; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u32_t.conflict period_start; + struct net_buf_simple * msg; + int (* update)(struct bt_mesh_model *); + struct k_delayed_work timer; + uint8_t dev_role; + undefined field_0x41; + undefined field_0x42; + undefined field_0x43; +}; + +typedef struct bt_mesh_model_pub.conflict10 bt_mesh_model_pub.conflict10, *Pbt_mesh_model_pub.conflict10; + +struct bt_mesh_model_pub.conflict10 { + struct bt_mesh_model * mod; + u16_t addr; + u16_t key; + u8_t ttl; + u8_t retransmit; + u8_t period; + u8_t period_div:4; + u8_t cred:1; + u8_t fast_period:1; + u8_t count:3; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u32_t.conflict period_start; + struct net_buf_simple * msg; + int (* update)(struct bt_mesh_model *); + struct k_delayed_work timer; + uint8_t dev_role; + undefined field_0x41; + undefined field_0x42; + undefined field_0x43; +}; + +typedef struct anon_struct.conflict436 anon_struct.conflict436, *Panon_struct.conflict436; + +struct anon_struct.conflict436 { + u16_t company; + u16_t id; +}; + +typedef struct anon_struct.conflict431 anon_struct.conflict431, *Panon_struct.conflict431; + +struct anon_struct.conflict431 { + u16_t company; + u16_t id; +}; + +typedef struct bt_mesh_model_pub.conflict16 bt_mesh_model_pub.conflict16, *Pbt_mesh_model_pub.conflict16; + +struct bt_mesh_model_pub.conflict16 { + struct bt_mesh_model * mod; + u16_t addr; + u16_t key; + u8_t ttl; + u8_t retransmit; + u8_t period; + u8_t period_div:4; + u8_t cred:1; + u8_t fast_period:1; + u8_t count:3; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u32_t.conflict period_start; + struct net_buf_simple * msg; + int (* update)(struct bt_mesh_model *); + struct k_delayed_work timer; + uint8_t dev_role; + undefined field_0x41; + undefined field_0x42; + undefined field_0x43; +}; + +typedef struct bt_mesh_model_pub.conflict15 bt_mesh_model_pub.conflict15, *Pbt_mesh_model_pub.conflict15; + +struct bt_mesh_model_pub.conflict15 { + struct bt_mesh_model * mod; + u16_t addr; + u16_t key; + u8_t ttl; + u8_t retransmit; + u8_t period; + u8_t period_div:4; + u8_t cred:1; + u8_t fast_period:1; + u8_t count:3; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u32_t.conflict period_start; + struct net_buf_simple * msg; + int (* update)(struct bt_mesh_model *); + struct k_delayed_work timer; + uint8_t dev_role; + undefined field_0x41; + undefined field_0x42; + undefined field_0x43; +}; + +typedef struct anon_struct.conflict439 anon_struct.conflict439, *Panon_struct.conflict439; + +struct anon_struct.conflict439 { + u16_t company; + u16_t id; +}; + +typedef struct bt_mesh_model_pub.conflict14 bt_mesh_model_pub.conflict14, *Pbt_mesh_model_pub.conflict14; + +struct bt_mesh_model_pub.conflict14 { + struct bt_mesh_model * mod; + u16_t addr; + u16_t key; + u8_t ttl; + u8_t retransmit; + u8_t period; + u8_t period_div:4; + u8_t cred:1; + u8_t fast_period:1; + u8_t count:3; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u32_t.conflict period_start; + struct net_buf_simple * msg; + int (* update)(struct bt_mesh_model *); + struct k_delayed_work timer; + uint8_t dev_role; + undefined field_0x41; + undefined field_0x42; + undefined field_0x43; +}; + +typedef struct bt_mesh_model_pub.conflict13 bt_mesh_model_pub.conflict13, *Pbt_mesh_model_pub.conflict13; + +struct bt_mesh_model_pub.conflict13 { + struct bt_mesh_model * mod; + u16_t addr; + u16_t key; + u8_t ttl; + u8_t retransmit; + u8_t period; + u8_t period_div:4; + u8_t cred:1; + u8_t fast_period:1; + u8_t count:3; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u32_t.conflict period_start; + struct net_buf_simple * msg; + int (* update)(struct bt_mesh_model *); + struct k_delayed_work timer; + uint8_t dev_role; + undefined field_0x41; + undefined field_0x42; + undefined field_0x43; +}; + +typedef struct anon_struct.conflict445 anon_struct.conflict445, *Panon_struct.conflict445; + +struct anon_struct.conflict445 { + u16_t company; + u16_t id; +}; + +typedef struct anon_struct.conflict447 anon_struct.conflict447, *Panon_struct.conflict447; + +struct anon_struct.conflict447 { + u16_t company; + u16_t id; +}; + +typedef struct anon_struct.conflict442 anon_struct.conflict442, *Panon_struct.conflict442; + +struct anon_struct.conflict442 { + u16_t company; + u16_t id; +}; + +typedef struct anon_struct.conflict450 anon_struct.conflict450, *Panon_struct.conflict450; + +struct anon_struct.conflict450 { + u16_t company; + u16_t id; +}; + +typedef struct anon_struct.conflict456 anon_struct.conflict456, *Panon_struct.conflict456; + +struct anon_struct.conflict456 { + u16_t company; + u16_t id; +}; + +typedef struct anon_struct.conflict453 anon_struct.conflict453, *Panon_struct.conflict453; + +struct anon_struct.conflict453 { + u16_t company; + u16_t id; +}; + +typedef struct mbedtls_ctr_drbg_context.conflict mbedtls_ctr_drbg_context.conflict, *Pmbedtls_ctr_drbg_context.conflict; + +struct mbedtls_ctr_drbg_context.conflict { + uchar counter[16]; + int reseed_counter; + int prediction_resistance; + size_t entropy_len; + int reseed_interval; + struct mbedtls_aes_context aes_ctx; + int (* f_entropy)(void *, uchar *, size_t); + void * p_entropy; +}; + +typedef struct anon_struct.conflict425 anon_struct.conflict425, *Panon_struct.conflict425; + +struct anon_struct.conflict425 { + u16_t id; + undefined field_0x2; + undefined field_0x3; + int (* init)(struct bt_mesh_model *, _Bool); +}; + +typedef struct anon_struct.conflict426 anon_struct.conflict426, *Panon_struct.conflict426; + +struct anon_struct.conflict426 { + u16_t id; + undefined field_0x2; + undefined field_0x3; + int (* init)(struct bt_mesh_model *, _Bool); +}; + +typedef struct anon_struct.conflict427 anon_struct.conflict427, *Panon_struct.conflict427; + +struct anon_struct.conflict427 { + u16_t id; + undefined field_0x2; + undefined field_0x3; + int (* init)(struct bt_mesh_model *, _Bool); +}; + +typedef struct anon_struct.conflict428 anon_struct.conflict428, *Panon_struct.conflict428; + +struct anon_struct.conflict428 { + u16_t id; + undefined field_0x2; + undefined field_0x3; + int (* init)(struct bt_mesh_model *, _Bool); +}; + +typedef struct raw_pcb raw_pcb, *Praw_pcb; + +struct raw_pcb { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct raw_pcb * next; + u8_t protocol; + u8_t flags; + u8_t mcast_ifindex; + u8_t mcast_ttl; + u8_t (* recv)(void *, struct raw_pcb *, struct pbuf *, ip_addr_t *); + void * recv_arg; +}; + +typedef struct tskTaskControlBlock tskTCB; + +typedef tskTCB TCB_t; + +typedef struct k_poll_event k_poll_event, *Pk_poll_event; + +typedef struct _dnode sys_dnode_t; + +typedef struct _poller _poller, *P_poller; + +typedef union anon_union_for_field_7 anon_union_for_field_7, *Panon_union_for_field_7; + +typedef struct k_poll_signal k_poll_signal, *Pk_poll_signal; + +union anon_union_for_field_7 { + void * obj; + struct k_poll_signal * signal; + struct k_sem * sem; + struct k_fifo * fifo; + struct k_queue * queue; +}; + +struct k_poll_event { + sys_dnode_t _node; + struct _poller * poller; + u32_t.conflict tag:8; + u32_t.conflict type:4; + u32_t.conflict state:4; + u32_t.conflict mode:1; + u32_t.conflict unused:15; + union anon_union_for_field_7 field_7; +}; + +struct k_poll_signal { + sys_dlist_t poll_events; + uint signaled; + int result; +}; + +struct _poller { +}; + +typedef enum _poll_types_bits { + _POLL_NUM_TYPES=4, + _POLL_TYPE_DATA_AVAILABLE=3, + _POLL_TYPE_IGNORE=0, + _POLL_TYPE_SEM_AVAILABLE=2, + _POLL_TYPE_SIGNAL=1 +} _poll_types_bits; + +typedef enum _poll_states_bits { + _POLL_NUM_STATES=4, + _POLL_STATE_DATA_AVAILABLE=3, + _POLL_STATE_NOT_READY=0, + _POLL_STATE_SEM_AVAILABLE=2, + _POLL_STATE_SIGNALED=1 +} _poll_states_bits; + +typedef enum k_poll_modes { + K_POLL_MODE_NOTIFY_ONLY=0, + K_POLL_NUM_MODES=1 +} k_poll_modes; + +typedef struct tc_aes_key_sched_struct tc_aes_key_sched_struct, *Ptc_aes_key_sched_struct; + +struct tc_aes_key_sched_struct { + uint words[44]; +}; + +typedef struct tc_aes_key_sched_struct * TCAesKeySched_t; + +typedef struct sm_connect_req.conflict sm_connect_req.conflict, *Psm_connect_req.conflict; + +typedef struct mac_addr.conflict57 mac_addr.conflict57, *Pmac_addr.conflict57; + +struct mac_addr.conflict57 { + u8_l array[6]; +}; + +struct sm_connect_req.conflict { + struct mac_ssid ssid; + struct mac_addr.conflict57 bssid; + struct scan_chan_tag chan; + undefined field_0x2e; + undefined field_0x2f; + u32_l flags; + u16_l ctrl_port_ethertype; + u16_l ie_len; + u16_l listen_interval; + bool_l dont_wait_bcmc; + u8_l auth_type; + u8_l uapsd_queues; + u8_l vif_idx; + undefined field_0x3e; + undefined field_0x3f; + u32_l ie_buf[64]; + _Bool is_supplicant_enabled; + uint8_t phrase[64]; + uint8_t phrase_pmk[64]; + undefined field_0x1c1; + undefined field_0x1c2; + undefined field_0x1c3; +}; + +typedef struct anon_struct.conflict273 anon_struct.conflict273, *Panon_struct.conflict273; + +struct anon_struct.conflict273 { + uint32_t task; + uint32_t element; +}; + +typedef struct mm_set_denoise_req mm_set_denoise_req, *Pmm_set_denoise_req; + +struct mm_set_denoise_req { + u8_l denoise_mode; +}; + +typedef struct scanu_result_ind scanu_result_ind, *Pscanu_result_ind; + +struct scanu_result_ind { + uint16_t length; + uint16_t framectrl; + uint16_t center_freq; + uint8_t band; + uint8_t sta_idx; + uint8_t inst_nbr; + uint8_t sa[6]; + undefined field_0xf; + uint32_t tsflo; + uint32_t tsfhi; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t data_rate; + uint32_t[0] payload; +}; + +typedef struct lmac_msg lmac_msg, *Plmac_msg; + +typedef u16 lmac_msg_id_t; + +typedef u16 lmac_task_id_t; + +typedef uint32_t u32.conflict1; + +struct lmac_msg { + lmac_msg_id_t id; + lmac_task_id_t dest_id; + lmac_task_id_t src_id; + u16 param_len; + u32.conflict1[0] param; +}; + +typedef struct Cipher_t.conflict1 Cipher_t.conflict1, *PCipher_t.conflict1; + +struct Cipher_t.conflict1 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct anon_struct.conflict260 anon_struct.conflict260, *Panon_struct.conflict260; + +struct anon_struct.conflict260 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct anon_struct.conflict261 anon_struct.conflict261, *Panon_struct.conflict261; + +struct anon_struct.conflict261 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct anon_struct.conflict269 anon_struct.conflict269, *Panon_struct.conflict269; + +struct anon_struct.conflict269 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct anon_struct.conflict347 anon_struct.conflict347, *Panon_struct.conflict347; + +struct anon_struct.conflict347 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct mm_channel_switch_ind mm_channel_switch_ind, *Pmm_channel_switch_ind; + +struct mm_channel_switch_ind { + u8_l chan_index; + bool_l roc; + u8_l vif_index; + bool_l roc_tdls; +}; + +typedef struct anon_struct.conflict388 anon_struct.conflict388, *Panon_struct.conflict388; + +struct anon_struct.conflict388 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct anon_struct.conflict274 anon_struct.conflict274, *Panon_struct.conflict274; + +struct anon_struct.conflict274 { + uint32_t task; + uint32_t element; +}; + +typedef struct Cipher_t.conflict Cipher_t.conflict, *PCipher_t.conflict; + +struct Cipher_t.conflict { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef enum tdls_msg_tag { + TDLS_CANCEL_CHAN_SWITCH_CFM=3077, + TDLS_CANCEL_CHAN_SWITCH_REQ=3076, + TDLS_CHAN_SWITCH_BASE_IND=3075, + TDLS_CHAN_SWITCH_CFM=3073, + TDLS_CHAN_SWITCH_IND=3074, + TDLS_CHAN_SWITCH_REQ=3072, + TDLS_MAX=3081, + TDLS_PEER_PS_IND=3078, + TDLS_PEER_TRAFFIC_IND_CFM=3080, + TDLS_PEER_TRAFFIC_IND_REQ=3079 +} tdls_msg_tag; + +typedef struct anon_struct.conflict271 anon_struct.conflict271, *Panon_struct.conflict271; + +struct anon_struct.conflict271 { + uint32_t task; + uint32_t element; +}; + +typedef struct anon_struct.conflict272 anon_struct.conflict272, *Panon_struct.conflict272; + +struct anon_struct.conflict272 { + uint32_t task; + uint32_t element; + uint32_t type; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct anon_struct.conflict395 anon_struct.conflict395, *Panon_struct.conflict395; + +struct anon_struct.conflict395 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct anon_struct.conflict270 anon_struct.conflict270, *Panon_struct.conflict270; + +struct anon_struct.conflict270 { + uint32_t task; + uint32_t element; +}; + +typedef struct anon_struct.conflict275 anon_struct.conflict275, *Panon_struct.conflict275; + +struct anon_struct.conflict275 { + uint32_t task; + uint32_t element; + uint32_t type; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct anon_struct.conflict352 anon_struct.conflict352, *Panon_struct.conflict352; + +struct anon_struct.conflict352 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct anon_struct.conflict398 anon_struct.conflict398, *Panon_struct.conflict398; + +struct anon_struct.conflict398 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef enum mm_msg_tag.conflict { + MM_ADD_IF_CFM=7, + MM_ADD_IF_REQ=6, + MM_BA_ADD_CFM=41, + MM_BA_ADD_REQ=40, + MM_BA_DEL_CFM=43, + MM_BA_DEL_REQ=42, + MM_BCN_CHANGE_CFM=64, + MM_BCN_CHANGE_REQ=63, + MM_BFMER_ENABLE_REQ=80, + MM_CFG_RSSI_REQ=86, + MM_CHANNEL_PRE_SWITCH_IND=69, + MM_CHANNEL_SURVEY_IND=79, + MM_CHANNEL_SWITCH_IND=68, + MM_CHAN_CTXT_ADD_CFM=52, + MM_CHAN_CTXT_ADD_REQ=51, + MM_CHAN_CTXT_DEL_CFM=54, + MM_CHAN_CTXT_DEL_REQ=53, + MM_CHAN_CTXT_LINK_CFM=56, + MM_CHAN_CTXT_LINK_REQ=55, + MM_CHAN_CTXT_SCHED_CFM=62, + MM_CHAN_CTXT_SCHED_REQ=61, + MM_CHAN_CTXT_UNLINK_CFM=58, + MM_CHAN_CTXT_UNLINK_REQ=57, + MM_CHAN_CTXT_UPDATE_CFM=60, + MM_CHAN_CTXT_UPDATE_REQ=59, + MM_CONNECTION_LOSS_IND=67, + MM_CSA_COUNTER_IND=78, + MM_CSA_FINISH_IND=88, + MM_CSA_TRAFFIC_IND=89, + MM_DENOISE_REQ=48, + MM_KEY_ADD_CFM=37, + MM_KEY_ADD_REQ=36, + MM_KEY_DEL_CFM=39, + MM_KEY_DEL_REQ=38, + MM_MAX=96, + MM_MONITOR_CFM=93, + MM_MONITOR_CHANNEL_CFM=95, + MM_MONITOR_CHANNEL_REQ=94, + MM_MONITOR_REQ=92, + MM_MU_GROUP_UPDATE_CFM=91, + MM_MU_GROUP_UPDATE_REQ=90, + MM_P2P_NOA_UPD_IND=85, + MM_P2P_VIF_PS_CHANGE_IND=77, + MM_PRIMARY_TBTT_IND=44, + MM_PS_CHANGE_IND=73, + MM_REMAIN_ON_CHANNEL_CFM=71, + MM_REMAIN_ON_CHANNEL_EXP_IND=72, + MM_REMAIN_ON_CHANNEL_REQ=70, + MM_REMOVE_IF_CFM=9, + MM_REMOVE_IF_REQ=8, + MM_RESET_CFM=1, + MM_RESET_REQ=0, + MM_RSSI_STATUS_IND=87, + MM_SECONDARY_TBTT_IND=45, + MM_SET_BASIC_RATES_CFM=23, + MM_SET_BASIC_RATES_REQ=22, + MM_SET_BEACON_INT_CFM=21, + MM_SET_BEACON_INT_REQ=20, + MM_SET_BSSID_CFM=25, + MM_SET_BSSID_REQ=24, + MM_SET_CHANNEL_CFM=17, + MM_SET_CHANNEL_REQ=16, + MM_SET_DTIM_CFM=19, + MM_SET_DTIM_REQ=18, + MM_SET_EDCA_CFM=27, + MM_SET_EDCA_REQ=26, + MM_SET_FILTER_CFM=15, + MM_SET_FILTER_REQ=14, + MM_SET_IDLE_CFM=35, + MM_SET_IDLE_REQ=34, + MM_SET_MODE_CFM=29, + MM_SET_MODE_REQ=28, + MM_SET_P2P_NOA_CFM=83, + MM_SET_P2P_NOA_REQ=81, + MM_SET_P2P_OPPPS_CFM=84, + MM_SET_P2P_OPPPS_REQ=82, + MM_SET_POWER_CFM=47, + MM_SET_POWER_REQ=46, + MM_SET_PS_MODE_CFM=50, + MM_SET_PS_MODE_REQ=49, + MM_SET_PS_OPTIONS_CFM=76, + MM_SET_PS_OPTIONS_REQ=75, + MM_SET_SLOTTIME_CFM=33, + MM_SET_SLOTTIME_REQ=32, + MM_SET_VIF_STATE_CFM=31, + MM_SET_VIF_STATE_REQ=30, + MM_START_CFM=3, + MM_START_REQ=2, + MM_STA_ADD_CFM=11, + MM_STA_ADD_REQ=10, + MM_STA_DEL_CFM=13, + MM_STA_DEL_REQ=12, + MM_TIM_UPDATE_CFM=66, + MM_TIM_UPDATE_REQ=65, + MM_TRAFFIC_REQ_IND=74, + MM_VERSION_CFM=5, + MM_VERSION_REQ=4 +} mm_msg_tag.conflict; + +typedef struct sm_connect_ind.conflict sm_connect_ind.conflict, *Psm_connect_ind.conflict; + +typedef struct mac_addr.conflict75 mac_addr.conflict75, *Pmac_addr.conflict75; + +struct mac_addr.conflict75 { + u8_l array[6]; +}; + +struct sm_connect_ind.conflict { + u16_l status_code; + struct mac_addr.conflict75 bssid; + bool_l roamed; + u8_l vif_idx; + u8_l ap_idx; + u8_l ch_idx; + bool_l qos; + u8_l acm; + u16_l assoc_req_ie_len; + u16_l assoc_rsp_ie_len; + undefined field_0x12; + undefined field_0x13; + u32_l assoc_ie_buf[200]; + u16_l aid; + u8_l band; + undefined field_0x337; + u16_l center_freq; + u8_l width; + undefined field_0x33b; + u32_l center_freq1; + u32_l center_freq2; + u32_l ac_param[4]; +}; + +typedef struct anon_struct.conflict280 anon_struct.conflict280, *Panon_struct.conflict280; + +struct anon_struct.conflict280 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct mm_add_if_req.conflict mm_add_if_req.conflict, *Pmm_add_if_req.conflict; + +typedef struct mac_addr.conflict55 mac_addr.conflict55, *Pmac_addr.conflict55; + +struct mac_addr.conflict55 { + u8_l array[6]; +}; + +struct mm_add_if_req.conflict { + u8_l type; + struct mac_addr.conflict55 addr; + bool_l p2p; +}; + +typedef enum mesh_msg_tag { + MESH_MAX=9232, + MESH_PATH_CREATE_CFM=9225, + MESH_PATH_CREATE_REQ=9224, + MESH_PATH_UPDATE_CFM=9227, + MESH_PATH_UPDATE_IND=9230, + MESH_PATH_UPDATE_REQ=9226, + MESH_PEER_INFO_REQ=9222, + MESH_PEER_INFO_RSP=9223, + MESH_PEER_UPDATE_IND=9229, + MESH_PEER_UPDATE_NTF=9229, + MESH_PROXY_ADD_REQ=9228, + MESH_PROXY_UPDATE_IND=9231, + MESH_START_CFM=9217, + MESH_START_REQ=9216, + MESH_STOP_CFM=9219, + MESH_STOP_REQ=9218, + MESH_UPDATE_CFM=9221, + MESH_UPDATE_REQ=9220 +} mesh_msg_tag; + +typedef struct apm_sta_add_ind.conflict apm_sta_add_ind.conflict, *Papm_sta_add_ind.conflict; + +typedef struct mac_addr.conflict76 mac_addr.conflict76, *Pmac_addr.conflict76; + +struct mac_addr.conflict76 { + u8_l array[6]; +}; + +struct apm_sta_add_ind.conflict { + uint32_t flags; + struct mac_addr.conflict76 sta_addr; + uint8_t vif_idx; + uint8_t sta_idx; + int8_t rssi; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t tsflo; + uint32_t tsfhi; + uint8_t data_rate; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; +}; + +typedef struct scanu_start_req.conflict scanu_start_req.conflict, *Pscanu_start_req.conflict; + +typedef struct mac_addr.conflict56 mac_addr.conflict56, *Pmac_addr.conflict56; + +struct mac_addr.conflict56 { + u8_l array[6]; +}; + +struct scanu_start_req.conflict { + struct scan_chan_tag chan[42]; + struct mac_ssid ssid[2]; + struct mac_addr.conflict56 bssid; + undefined field_0x146; + undefined field_0x147; + u32_l add_ies; + u16_l add_ie_len; + u8_l vif_idx; + u8_l chan_cnt; + u8_l ssid_cnt; + _Bool no_cck; + undefined field_0x152; + undefined field_0x153; +}; + +typedef struct net_device net_device, *Pnet_device; + +typedef struct bl_hw bl_hw, *Pbl_hw; + +typedef struct bl_cmd_mgr bl_cmd_mgr, *Pbl_cmd_mgr; + +typedef struct bl_cmd bl_cmd, *Pbl_cmd; + +typedef struct ipc_e2a_msg ipc_e2a_msg, *Pipc_e2a_msg; + +typedef struct ipc_host_env_tag ipc_host_env_tag, *Pipc_host_env_tag; + +typedef struct bl_stats bl_stats, *Pbl_stats; + +typedef struct list_head list_head, *Plist_head; + +typedef struct bl_vif bl_vif, *Pbl_vif; + +typedef struct bl_sta bl_sta, *Pbl_sta; + +typedef struct bl_mod_params bl_mod_params, *Pbl_mod_params; + +typedef enum wiphy_flags { + WIPHY_FLAG_4ADDR_AP=32, + WIPHY_FLAG_4ADDR_STATION=64, + WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD=524288, + WIPHY_FLAG_AP_UAPSD=16384, + WIPHY_FLAG_CONTROL_PORT_PROTOCOL=-128, + WIPHY_FLAG_HAS_CHANNEL_SWITCH=8388608, + WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL=2097152, + WIPHY_FLAG_HAS_STATIC_WEP=16777216, + WIPHY_FLAG_HAVE_AP_SME=131072, + WIPHY_FLAG_IBSS_RSN=256, + WIPHY_FLAG_MESH_AUTH=1024, + WIPHY_FLAG_NETNS_OK=8, + WIPHY_FLAG_OFFCHAN_TX=1048576, + WIPHY_FLAG_PS_ON_BY_DEFAULT=16, + WIPHY_FLAG_REPORTS_OBSS=262144, + WIPHY_FLAG_SUPPORTS_5_10_MHZ=4194304, + WIPHY_FLAG_SUPPORTS_FW_ROAM=8192, + WIPHY_FLAG_SUPPORTS_SCHED_SCAN=2048, + WIPHY_FLAG_SUPPORTS_TDLS=-32768, + WIPHY_FLAG_TDLS_EXTERNAL_SETUP=65536 +} wiphy_flags; + +typedef struct ieee80211_sta_ht_cap ieee80211_sta_ht_cap, *Pieee80211_sta_ht_cap; + +typedef uchar u8; + +typedef enum RWNX_INTERFACE_STATUS { + RWNX_INTERFACE_STATUS_DOWN=0, + RWNX_INTERFACE_STATUS_UP=1 +} RWNX_INTERFACE_STATUS; + +typedef enum bl_cmd_mgr_state { + RWNX_CMD_MGR_STATE_CRASHED=2, + RWNX_CMD_MGR_STATE_DEINIT=0, + RWNX_CMD_MGR_STATE_INITED=1 +} bl_cmd_mgr_state; + +typedef uint32_t u32.conflict8; + +typedef uint32_t u32.conflict9; + +typedef struct QueueDefinition QueueDefinition, *PQueueDefinition; + +typedef struct QueueDefinition * QueueHandle_t; + +typedef QueueHandle_t SemaphoreHandle_t; + +typedef SemaphoreHandle_t os_mutex_t; + +typedef struct xSTATIC_EVENT_GROUP xSTATIC_EVENT_GROUP, *PxSTATIC_EVENT_GROUP; + +typedef struct xSTATIC_EVENT_GROUP StaticEventGroup_t; + +typedef StaticEventGroup_t os_event_t; + +typedef uint32_t u32.conflict4; + +typedef struct ipc_host_cb_tag ipc_host_cb_tag, *Pipc_host_cb_tag; + +typedef struct ipc_shared_env_tag.conflict30 ipc_shared_env_tag.conflict30, *Pipc_shared_env_tag.conflict30; + +typedef struct ipc_hostbuf ipc_hostbuf, *Pipc_hostbuf; + +typedef struct netif netif, *Pnetif; + +typedef enum netif_mac_filter_action { + NETIF_ADD_MAC_FILTER=1, + NETIF_DEL_MAC_FILTER=0 +} netif_mac_filter_action; + +typedef struct net_device_stats net_device_stats, *Pnet_device_stats; + +typedef union anon_union_for_field_13 anon_union_for_field_13, *Panon_union_for_field_13; + +typedef struct mac_addr.conflict36 mac_addr.conflict36, *Pmac_addr.conflict36; + +typedef struct ieee80211_mcs_info ieee80211_mcs_info, *Pieee80211_mcs_info; + + +// WARNING! conflicting data type names: /DWARF/queue.c/QueueDefinition/anon_union_for_u - /DWARF/gatt.c/gatt_find_info_rsp/anon_union_for_u + +typedef struct xLIST List_t; + +typedef struct xSTATIC_LIST xSTATIC_LIST, *PxSTATIC_LIST; + +typedef struct xSTATIC_LIST StaticList_t; + +typedef struct ipc_a2e_msg ipc_a2e_msg, *Pipc_a2e_msg; + +typedef struct txdesc_host.conflict60 txdesc_host.conflict60, *Ptxdesc_host.conflict60; + +typedef struct anon_struct.conflict262 anon_struct.conflict262, *Panon_struct.conflict262; + +typedef struct anon_struct.conflict263 anon_struct.conflict263, *Panon_struct.conflict263; + +typedef struct anon_struct.conflict264 anon_struct.conflict264, *Panon_struct.conflict264; + +typedef struct xSTATIC_MINI_LIST_ITEM xSTATIC_MINI_LIST_ITEM, *PxSTATIC_MINI_LIST_ITEM; + +typedef struct xSTATIC_MINI_LIST_ITEM StaticMiniListItem_t; + +typedef struct hostdesc.conflict75 hostdesc.conflict75, *Phostdesc.conflict75; + +typedef struct bl_bcn bl_bcn, *Pbl_bcn; + +typedef struct mac_addr.conflict166 mac_addr.conflict166, *Pmac_addr.conflict166; + +typedef struct mac_addr.conflict167 mac_addr.conflict167, *Pmac_addr.conflict167; + +struct mac_addr.conflict167 { + u8_l array[6]; +}; + +struct mac_addr.conflict166 { + u8_l array[6]; +}; + +struct hostdesc.conflict75 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict166 eth_dest_addr; + struct mac_addr.conflict167 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict60 { + u32_l ready; + struct hostdesc.conflict75 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct bl_bcn { + u8 * head; + u8 * tail; + u8 * ies; + size_t head_len; + size_t tail_len; + size_t ies_len; + size_t tim_len; + size_t len; + u8 dtim; + undefined field_0x21; + undefined field_0x22; + undefined field_0x23; +}; + +struct bl_mod_params { + _Bool ht_on; + _Bool vht_on; + undefined field_0x2; + undefined field_0x3; + int mcs_map; + _Bool ldpc_on; + _Bool vht_stbc; + undefined field_0xa; + undefined field_0xb; + int phy_cfg; + int uapsd_timeout; + _Bool ap_uapsd_on; + _Bool sgi; + _Bool sgi80; + _Bool use_2040; + _Bool use_80; + _Bool custregd; + undefined field_0x1a; + undefined field_0x1b; + int nss; + _Bool bfmee; + _Bool bfmer; + _Bool mesh; + _Bool murx; + _Bool mutx; + _Bool mutx_on; + undefined field_0x26; + undefined field_0x27; + uint roc_dur_max; + int listen_itv; + _Bool listen_bcmc; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + int lp_clk_ppm; + _Bool ps_on; + undefined field_0x39; + undefined field_0x3a; + undefined field_0x3b; + int tx_lft; + int amsdu_maxnb; + int uapsd_queues; + _Bool tdls; + undefined field_0x49; + undefined field_0x4a; + undefined field_0x4b; +}; + +struct list_head { + struct list_head * next; + struct list_head * prev; +}; + +struct net_device_stats { + ulong rx_packets; + ulong tx_packets; + ulong rx_bytes; + ulong tx_bytes; + ulong rx_errors; + ulong tx_errors; + ulong rx_dropped; + ulong tx_dropped; + ulong multicast; + ulong collisions; + ulong rx_length_errors; + ulong rx_over_errors; + ulong rx_crc_errors; + ulong rx_frame_errors; + ulong rx_fifo_errors; + ulong rx_missed_errors; + ulong tx_aborted_errors; + ulong tx_carrier_errors; + ulong tx_fifo_errors; + ulong tx_heartbeat_errors; + ulong tx_window_errors; + ulong rx_compressed; + ulong tx_compressed; +}; + +struct anon_struct.conflict263 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +struct anon_struct.conflict264 { + struct bl_vif * master; + struct bl_sta * sta_4a; +}; + +struct anon_struct.conflict262 { + struct bl_sta * ap; + struct bl_sta * tdls_sta; +}; + +union anon_union_for_field_13 { + struct anon_struct.conflict262 sta; + struct anon_struct.conflict263 ap; + struct anon_struct.conflict264 ap_vlan; +}; + +struct bl_vif { + struct list_head list; + struct netif * dev; + struct bl_hw * bl_hw; + struct net_device_stats net_stats; + u8 drv_vif_index; + u8 vif_index; + u8 ch_index; + _Bool up; + _Bool use_4addr; + _Bool is_resending; + _Bool user_mpm; + _Bool roc_tdls; + u8 tdls_status; + undefined field_0x75; + undefined field_0x76; + undefined field_0x77; + union anon_union_for_field_13 field_13; +}; + +struct netif { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct net_device { + struct bl_hw * bl_hw; +}; + +struct bl_stats { + int cfm_balance; + ulong last_rx; + ulong last_tx; + int ampdus_tx[64]; + int ampdus_rx[64]; + int ampdus_rx_map[4]; + int ampdus_rx_miss; + int amsdus_rx[64]; +}; + +struct ipc_e2a_msg { + u16_l id; + u16_l dummy_dest_id; + u16_l dummy_src_id; + u16_l param_len; + u32_l param[245]; + u32_l pattern; +}; + +struct ieee80211_mcs_info { + u8 rx_mask[10]; + __le16 rx_highest; + u8 tx_params; + u8 reserved[3]; +}; + +struct ieee80211_sta_ht_cap { + u16 cap; + _Bool ht_supported; + u8 ampdu_factor; + u8 ampdu_density; + undefined field_0x5; + struct ieee80211_mcs_info mcs; +}; + +struct ipc_host_cb_tag { + int (* send_data_cfm)(void *, void *); + uint8_t (* recv_data_ind)(void *, void *); + uint8_t (* recv_radar_ind)(void *, void *); + uint8_t (* recv_msg_ind)(void *, void *); + uint8_t (* recv_msgack_ind)(void *, void *); + uint8_t (* recv_dbg_ind)(void *, void *); + void (* prim_tbtt_ind)(void *); + void (* sec_tbtt_ind)(void *); +}; + +struct ipc_hostbuf { + void * hostid; + uint32_t dma_addr; +}; + +struct xSTATIC_MINI_LIST_ITEM { + TickType_t xDummy2; + void * pvDummy3[2]; +}; + +struct xSTATIC_LIST { + UBaseType_t uxDummy2; + void * pvDummy3; + StaticMiniListItem_t xDummy4; +}; + +struct xSTATIC_EVENT_GROUP { + TickType_t xDummy1; + StaticList_t xDummy2; + UBaseType_t uxDummy3; + uint8_t ucDummy4; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +struct bl_cmd { + struct list_head list; + lmac_msg_id_t id; + lmac_msg_id_t reqid; + struct lmac_msg * a2e_msg; + char * e2a_msg; + u32.conflict3 tkn; + u16 flags; + undefined field_0x1a; + undefined field_0x1b; + os_event_t complete; + u32.conflict4 result; +}; + +struct bl_cmd_mgr { + enum bl_cmd_mgr_state state; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + u32.conflict7 next_tkn; + u32.conflict8 queue_sz; + u32.conflict9 max_queue_sz; + struct list_head cmds; + os_mutex_t lock; + int (* queue)(struct bl_cmd_mgr *, struct bl_cmd *); + int (* llind)(struct bl_cmd_mgr *, struct bl_cmd *); + int (* msgind)(struct bl_cmd_mgr *, struct ipc_e2a_msg *, int (* )(struct bl_hw *, struct bl_cmd *, struct ipc_e2a_msg *)); + void (* print)(struct bl_cmd_mgr *); + void (* drain)(struct bl_cmd_mgr *); +}; + +struct ipc_host_env_tag { + struct ipc_host_cb_tag cb; + struct ipc_shared_env_tag.conflict30 * shared; + struct ipc_hostbuf ipc_host_rxdesc_array[2]; + uint8_t ipc_host_rxdesc_idx; + uint8_t rxdesc_nb; + uint8_t ipc_host_rxbuf_idx; + undefined field_0x37; + uint32_t rx_bufnb; + uint32_t rx_bufsz; + uint32_t txdesc_free_idx; + uint32_t txdesc_used_idx; + void * tx_host_id0[4]; + void * * tx_host_id; + struct txdesc_host * txdesc; + struct ipc_hostbuf ipc_host_msgbuf_array[8]; + uint8_t ipc_host_msge2a_idx; + undefined field_0xa1; + undefined field_0xa2; + undefined field_0xa3; + uint32_t ipc_e2amsg_bufnb; + uint32_t ipc_e2amsg_bufsz; + uint8_t msga2e_cnt; + undefined field_0xad; + undefined field_0xae; + undefined field_0xaf; + void * msga2e_hostid; + struct ipc_hostbuf ipc_host_dbgbuf_array[4]; + uint8_t ipc_host_dbg_idx; + undefined field_0xd5; + undefined field_0xd6; + undefined field_0xd7; + uint32_t ipc_dbg_bufnb; + uint32_t ipc_dbg_bufsz; + void * pthis; +}; + +struct QueueDefinition { + int8_t * pcHead; + int8_t * pcWriteTo; + union anon_union_for_u u; + List_t xTasksWaitingToSend; + List_t xTasksWaitingToReceive; + UBaseType_t uxMessagesWaiting; + UBaseType_t uxLength; + UBaseType_t uxItemSize; + int8_t cRxLock; + int8_t cTxLock; + uint8_t ucStaticallyAllocated; + undefined field_0x47; + UBaseType_t uxQueueNumber; + uint8_t ucQueueType; + undefined field_0x4d; + undefined field_0x4e; + undefined field_0x4f; +}; + +struct ipc_a2e_msg { + uint32_t dummy_word; + uint32_t msg[127]; +}; + +struct ipc_shared_env_tag.conflict30 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict60 txdesc0[4]; +}; + +struct mac_addr.conflict36 { + u8_l array[6]; +}; + +struct bl_sta { + struct mac_addr.conflict36 sta_addr; + u16 aid; + u8 is_used; + u8 sta_idx; + u8 vif_idx; + u8 vlan_idx; + int8_t rssi; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t tsflo; + uint32_t tsfhi; + uint8_t data_rate; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; +}; + +struct bl_hw { + int is_up; + struct bl_cmd_mgr cmd_mgr; + struct ipc_host_env_tag * ipc_env; + struct bl_stats stats; + struct list_head vifs; + struct bl_vif vif_table[12]; + struct bl_sta sta_table[12]; + ulong drv_flags; + struct mm_version_cfm version_cfm; + struct bl_mod_params * mod_params; + enum wiphy_flags flags; + struct ieee80211_sta_ht_cap ht_cap; + u8 vif_started; + undefined field_0xe1b; + int vif_index_sta; + int vif_index_ap; + int sta_idx; + int ap_bcmc_idx; + struct phy_cfg_tag phy_config; + enum RWNX_INTERFACE_STATUS status; + undefined field_0xe6d; + undefined field_0xe6e; + undefined field_0xe6f; +}; + +typedef struct err_info_t err_info_t, *Perr_info_t; + +typedef enum AT_ERROR_CODE { + AEC_BIND_FAIL=15, + AEC_BLANK_LINE=1, + AEC_CMD_ERROR=3, + AEC_CMD_FAIL=2, + AEC_CONNECT_FAIL=14, + AEC_DISCONNECT=18, + AEC_IMPROPER_OPERATION=21, + AEC_LIMITED=17, + AEC_NETWORK_ERROR=19, + AEC_NOT_ENOUGH_MEMORY=20, + AEC_NOT_FOUND=7, + AEC_NO_PARA=5, + AEC_NO_RESPONSE=27, + AEC_NULL_POINTER=8, + AEC_OK=0, + AEC_OUT_OF_RANGE=9, + AEC_PARA_ERROR=4, + AEC_READ_ONLY=11, + AEC_SCAN_FAIL=10, + AEC_SEND_FAIL=12, + AEC_SEND_READY=23, + AEC_SEND_TIMEOUT=24, + AEC_SOCKET_EXISTING=22, + AEC_SOCKET_FAIL=16, + AEC_SWITCH_MODE=13, + AEC_UNDEFINED=26, + AEC_UNSUPPORTED=6, + AEC_UPGRADE_FAILED=25 +} AT_ERROR_CODE; + +struct err_info_t { + enum AT_ERROR_CODE aec; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + char * info; +}; + +typedef UINT8 IEEEtypes_Addr_t; + +typedef IEEEtypes_Addr_t IEEEtypes_MacAddr_t[6]; + +typedef enum ChanBand_e { + Band_2_4_GHz=0, + Band_4_GHz=2, + Band_5_GHz=1 +} ChanBand_e; + +typedef enum IEEEtypes_ElementId_e { + ELEM_ID_2040_BSS_COEXISTENCE=72, + ELEM_ID_2040_BSS_INTOL_CHRPT=73, + ELEM_ID_AID=-59, + ELEM_ID_ANTENNA_INFO=64, + ELEM_ID_AP_CHANNEL_REPORT=51, + ELEM_ID_BSS_ACCESS_DELAY=63, + ELEM_ID_BSS_AC_ACCESS_DELAY=68, + ELEM_ID_BSS_AVAIL_ADM_CAP=67, + ELEM_ID_BSS_LOAD=11, + ELEM_ID_BSS_MAX_IDLE_PERIOD=90, + ELEM_ID_CF_PARAM_SET=4, + ELEM_ID_CHALLENGE_TEXT=16, + ELEM_ID_CHANNEL_SWITCH_ANN=37, + ELEM_ID_CHANNEL_USAGE=97, + ELEM_ID_COLLOC_INTF_REPORT=96, + ELEM_ID_COUNTRY=7, + ELEM_ID_DIAG_REPORT=81, + ELEM_ID_DIAG_REQUEST=80, + ELEM_ID_DMS_REQUEST=99, + ELEM_ID_DMS_RESPONSE=100, + ELEM_ID_DSE_REGISTERED_LOC=58, + ELEM_ID_DS_PARAM_SET=3, + ELEM_ID_EDCA_PARAM_SET=12, + ELEM_ID_ERP_INFO=42, + ELEM_ID_EVENT_REPORT=79, + ELEM_ID_EVENT_REQUEST=78, + ELEM_ID_EXTENSION=-1, + ELEM_ID_EXT_ASSOC_DELAY_INFO=1, + ELEM_ID_EXT_CAPABILITIES=127, + ELEM_ID_EXT_CHAN_SWITCH_ANN=60, + ELEM_ID_EXT_ESTIMATED_SERVICE_PARAMS=11, + ELEM_ID_EXT_EXTENDED_REQUEST=10, + ELEM_ID_EXT_FILS_HLP_CONTAINER=5, + ELEM_ID_EXT_FILS_IP_ADDR_ASSIGN=6, + ELEM_ID_EXT_FILS_KEY_CONFIRM=3, + ELEM_ID_EXT_FILS_NONCE=13, + ELEM_ID_EXT_FILS_PUBLIC_KEY=12, + ELEM_ID_EXT_FILS_REQ_PARAMS=2, + ELEM_ID_EXT_FILS_SESSION=4, + ELEM_ID_EXT_FILS_WRAPPED_DATA=8, + ELEM_ID_EXT_FTM_SYNC_INFO=9, + ELEM_ID_EXT_FUTURE_CHANNEL_GUIDANCE=14, + ELEM_ID_EXT_HE_CAPABILITIES=35, + ELEM_ID_EXT_HE_OPERATION=36, + ELEM_ID_EXT_KEY_DELIVERY=7, + ELEM_ID_EXT_OWE_DH_PARAM=32, + ELEM_ID_EXT_PASSWORD_IDENTIFIER=33, + ELEM_ID_EXT_SUPPORTED_RATES=50, + ELEM_ID_FAST_BSS_TRANS=55, + ELEM_ID_FH_PARAM_SET=2, + ELEM_ID_FMS_DESCRIPTOR=86, + ELEM_ID_FMS_REQUEST=87, + ELEM_ID_FMS_RESPONSE=88, + ELEM_ID_HOP_PARAM=8, + ELEM_ID_HOP_TABLE=9, + ELEM_ID_HT_CAPABILITY=45, + ELEM_ID_HT_INFORMATION=61, + ELEM_ID_IBSS_DFS=41, + ELEM_ID_IBSS_PARAM_SET=6, + ELEM_ID_LINK_ID=101, + ELEM_ID_LOCATION_PARAM=82, + ELEM_ID_MANAGEMENT_MIC=76, + ELEM_ID_MBSSID_INDEX=85, + ELEM_ID_MEASUREMENT_REQ=38, + ELEM_ID_MEASUREMENT_RPT=39, + ELEM_ID_MEAS_PILOT_TX_INFO=66, + ELEM_ID_MOBILITY_DOMAIN=54, + ELEM_ID_MULTI_BSSID=71, + ELEM_ID_NEIGHBOR_REPORT=52, + ELEM_ID_NONTRANS_BSSID_CAP=83, + ELEM_ID_OBSS_SCAN_PARAM=74, + ELEM_ID_POWER_CAPABILITY=33, + ELEM_ID_POWER_CONSTRAINT=32, + ELEM_ID_PTI_CONTROL=105, + ELEM_ID_PU_BUFFER_STATUS=106, + ELEM_ID_QOS_CAPABILITY=46, + ELEM_ID_QOS_TRAFFIC_CAP=89, + ELEM_ID_QUIET=40, + ELEM_ID_RCPI=53, + ELEM_ID_REQUEST=10, + ELEM_ID_RIC_DATA=57, + ELEM_ID_RIC_DESCRIPTOR=75, + ELEM_ID_RRM_ENABLED_CAP=70, + ELEM_ID_RSN=48, + ELEM_ID_RSNI=65, + ELEM_ID_SCHEDULE=15, + ELEM_ID_SECONDARY_CHAN_OFFSET=62, + ELEM_ID_SSID=0, + ELEM_ID_SSID_LIST=84, + ELEM_ID_SUPPORTED_CHANNELS=36, + ELEM_ID_SUPPORTED_RATES=1, + ELEM_ID_SUPPORTED_REGCLASS=59, + ELEM_ID_TCLAS=14, + ELEM_ID_TCLAS_PROCESS=44, + ELEM_ID_TDLS_CS_TIMING=104, + ELEM_ID_TFS_REQUEST=91, + ELEM_ID_TFS_RESPONSE=92, + ELEM_ID_TIM=5, + ELEM_ID_TIMEOUT_INTERVAL=56, + ELEM_ID_TIME_ZONE=98, + ELEM_ID_TIM_BCAST_REQUEST=94, + ELEM_ID_TIM_BCAST_RESPONSE=95, + ELEM_ID_TPC_REPORT=35, + ELEM_ID_TPC_REQUEST=34, + ELEM_ID_TSPEC=13, + ELEM_ID_TS_DELAY=43, + ELEM_ID_VENDOR_SPECIFIC=-35, + ELEM_ID_VHT_CAPABILITIES=-65, + ELEM_ID_VHT_OPERATION=-64, + ELEM_ID_VHT_OP_MODE_NOTIFICATION=-57, + ELEM_ID_WAKEUP_SCHEDULE=102, + ELEM_ID_WAPI=68, + ELEM_ID_WIDE_BAND_CHAN_SW=-63, + ELEM_ID_WNM_SLEEP_MODE=93, + SUBELEM_ID_GTK=2, + SUBELEM_ID_IGTK=4, + SUBELEM_ID_PMK_R0_KEY_HOLDER_ID=3, + SUBELEM_ID_PMK_R1_KEY_HOLDER_ID=1, + SUBELEM_ID_REPORTED_FRAME_BODY=1, + SUBELEM_ID_REPORTING_DETAIL=2 +} IEEEtypes_ElementId_e; + +typedef enum Chan2Offset_e { + SECONDARY_CHAN_ABOVE=1, + SECONDARY_CHAN_BELOW=3, + SECONDARY_CHAN_NONE=0 +} Chan2Offset_e; + +typedef UINT8 IEEEtypes_SsId_t[32]; + +typedef enum IEEEtypes_8021x_CodeType_e { + IEEE_8021X_CODE_TYPE_FAILURE=4, + IEEE_8021X_CODE_TYPE_REQUEST=1, + IEEE_8021X_CODE_TYPE_RESPONSE=2, + IEEE_8021X_CODE_TYPE_SUCCESS=3 +} IEEEtypes_8021x_CodeType_e; + +typedef UINT8 IEEEtypes_DtimPeriod_t; + +typedef struct IEEEtypes_WPAElement_t IEEEtypes_WPAElement_t, *PIEEEtypes_WPAElement_t; + +typedef UINT8 IEEEtypes_Len_t; + +struct IEEEtypes_WPAElement_t { + enum IEEEtypes_ElementId_e ElementId; + IEEEtypes_Len_t Len; + UINT8 OuiType[4]; + UINT16 Ver; + UINT8 GrpKeyCipher[4]; + UINT16 PwsKeyCnt; + UINT8 PwsKeyCipherList[4]; + UINT16 AuthKeyCnt; + UINT8 AuthKeyList[4]; +}; + +typedef enum IEEEtypes_KDEDataType_e { + KDE_DATA_TYPE_ERROR=8, + KDE_DATA_TYPE_GTK=1, + KDE_DATA_TYPE_IGTK=9, + KDE_DATA_TYPE_LIFETIME=7, + KDE_DATA_TYPE_MACADDR=3, + KDE_DATA_TYPE_NONCE=6, + KDE_DATA_TYPE_PMKID=4, + KDE_DATA_TYPE_RESERVED=0, + KDE_DATA_TYPE_RESERVED2=2, + KDE_DATA_TYPE_SMK=5 +} IEEEtypes_KDEDataType_e; + +typedef UINT16 IEEEtypes_BcnInterval_t; + +typedef struct IEEEtypes_RSNCapability_t IEEEtypes_RSNCapability_t, *PIEEEtypes_RSNCapability_t; + +struct IEEEtypes_RSNCapability_t { + UINT8 PreAuth:1; + UINT8 NoPairwise:1; + UINT8 PtksaReplayCtr:2; + UINT8 GtksaReplayCtr:2; + UINT8 MFPR:1; + UINT8 MFPC:1; + UINT8 Reserved_8:1; + UINT8 PeerkeyEnabled:1; + UINT8 SppAmsduCap:1; + UINT8 SppAmsduReq:1; + UINT8 PBAC:1; + UINT8 Reserved_13_15:3; +}; + +typedef struct BandConfig_t BandConfig_t, *PBandConfig_t; + +typedef enum ChanWidth_e { + ChanWidth_10_MHz=1, + ChanWidth_20_MHz=0, + ChanWidth_40_MHz=2, + ChanWidth_80_MHz=3 +} ChanWidth_e; + +typedef enum ScanMode_e { + ACS_MODE=1, + MANUAL_MODE=0 +} ScanMode_e; + +struct BandConfig_t { + enum ChanBand_e chanBand:2; + enum ChanWidth_e chanWidth:2; + enum Chan2Offset_e chan2Offset:2; + enum ScanMode_e scanMode:2; +}; + +typedef enum IEEEtypes_PwrMgmtMode_e { + PWR_MODE_ACTIVE=0, + PWR_MODE_PWR_SAVE=1 +} IEEEtypes_PwrMgmtMode_e; + +typedef struct ether_hdr_t ether_hdr_t, *Pether_hdr_t; + +struct ether_hdr_t { + IEEEtypes_MacAddr_t da; + IEEEtypes_MacAddr_t sa; + UINT16 type; +}; + +typedef struct IEEEtypes_SsIdElement_t IEEEtypes_SsIdElement_t, *PIEEEtypes_SsIdElement_t; + +struct IEEEtypes_SsIdElement_t { + enum IEEEtypes_ElementId_e ElementId; + IEEEtypes_Len_t Len; + IEEEtypes_SsId_t SsId; +}; + +typedef enum IEEEtypes_8021x_PacketType_e { + IEEE_8021X_PACKET_TYPE_ASF_ALERT=4, + IEEE_8021X_PACKET_TYPE_EAPOL_KEY=3, + IEEE_8021X_PACKET_TYPE_EAPOL_LOGOFF=2, + IEEE_8021X_PACKET_TYPE_EAPOL_START=1, + IEEE_8021X_PACKET_TYPE_EAP_PACKET=0 +} IEEEtypes_8021x_PacketType_e; + +typedef struct IEEEtypes_InfoElementHdr_t IEEEtypes_InfoElementHdr_t, *PIEEEtypes_InfoElementHdr_t; + +struct IEEEtypes_InfoElementHdr_t { + enum IEEEtypes_ElementId_e ElementId; + IEEEtypes_Len_t Len; +}; + +typedef struct IEEEtypes_RSNElement_t IEEEtypes_RSNElement_t, *PIEEEtypes_RSNElement_t; + +struct IEEEtypes_RSNElement_t { + enum IEEEtypes_ElementId_e ElementId; + IEEEtypes_Len_t Len; + UINT16 Ver; + UINT8 GrpKeyCipher[4]; + UINT16 PwsKeyCnt; + UINT8 PwsKeyCipherList[4]; + UINT16 AuthKeyCnt; + UINT8 AuthKeyList[4]; + struct IEEEtypes_RSNCapability_t RsnCap; + UINT16 PMKIDCnt; + UINT8 PMKIDList[16]; + UINT8 GrpMgmtCipher[4]; +}; + +typedef struct ChanBandInfo_t ChanBandInfo_t, *PChanBandInfo_t; + +struct ChanBandInfo_t { + struct BandConfig_t bandConfig; + UINT8 chanNum; +}; + +typedef int _LOCK_RECURSIVE_T; + +typedef enum keyMgmtState_e { + GRPMSG1_PENDING=5, + GRP_REKEY_MSG1_PENDING=7, + HSK_DUMMY_STATE=9, + HSK_END=10, + HSK_NOT_STARTED=0, + MSG1_PENDING=1, + MSG3_PENDING=3, + WAITING_4_GRPMSG2=6, + WAITING_4_GRP_REKEY_MSG2=8, + WAITING_4_MSG2=2, + WAITING_4_MSG4=4 +} keyMgmtState_e; + +typedef struct apKeyMgmtInfoStaRom_t apKeyMgmtInfoStaRom_t, *PapKeyMgmtInfoStaRom_t; + +typedef struct SecurityMode_t SecurityMode_t, *PSecurityMode_t; + +typedef struct Cipher_t Cipher_t, *PCipher_t; + +struct Cipher_t { + UINT8 wep40:1; + UINT8 wep104:1; + UINT8 tkip:1; + UINT8 ccmp:1; + UINT8 rsvd:4; +}; + +struct SecurityMode_t { + UINT16 noRsn:1; + UINT16 wepStatic:1; + UINT16 wepDynamic:1; + UINT16 wpa:1; + UINT16 wpaNone:1; + UINT16 wpa2:1; + UINT16 cckm:1; + UINT16 wapi:1; + UINT16 wpa3:1; + UINT16 rsvd:7; +}; + +struct apKeyMgmtInfoStaRom_t { + UINT16 staRsnCap; + struct SecurityMode_t staSecType; + struct Cipher_t staUcstCipher; + UINT8 staAkmType; + enum keyMgmtState_e keyMgmtState; + undefined field_0x7; +}; + +typedef struct tsen_reload_data tsen_reload_data, *Ptsen_reload_data; + +typedef struct tsen_reload_data tsen_reload_data_t; + +typedef struct xSTATIC_TIMER xSTATIC_TIMER, *PxSTATIC_TIMER; + +typedef struct xSTATIC_TIMER StaticTimer_t; + +typedef StaticTimer_t os_timer_t; + +struct xSTATIC_TIMER { + void * pvDummy1; + StaticListItem_t xDummy2; + TickType_t xDummy3; + void * pvDummy5; + void (* pvDummy6)(void *); + UBaseType_t uxDummy7; + uint8_t ucDummy8; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +struct tsen_reload_data { + char name[32]; + os_timer_t timer; +}; + +typedef struct connectedIPNoData connectedIPNoData, *PconnectedIPNoData; + +typedef struct connectedIPNoData connectedIPNoData_t; + +struct connectedIPNoData { + char name[32]; + os_timer_t timer; +}; + +typedef struct disconnectData disconnectData, *PdisconnectData; + +typedef struct wifi_mgmr_profile_msg wifi_mgmr_profile_msg, *Pwifi_mgmr_profile_msg; + +typedef struct wifi_mgmr_profile_msg wifi_mgmr_profile_msg_t; + +struct wifi_mgmr_profile_msg { + char ssid[32]; + char ssid_tail[1]; + uint32_t ssid_len; + char psk[64]; + char psk_tail[1]; + char pmk[64]; + char pmk_tail[1]; + uint32_t psk_len; + uint32_t pmk_len; + uint8_t mac[6]; + uint8_t band; + uint16_t freq; + uint8_t dhcp_use; +}; + +struct disconnectData { + char name[32]; + os_timer_t timer; + uint8_t timer_started; + wifi_mgmr_profile_msg_t profile_msg; + undefined field_0x106; + undefined field_0x107; +}; + +typedef struct disconnectData disconnectData_t; + +typedef struct cJSON_Hooks cJSON_Hooks, *PcJSON_Hooks; + +struct cJSON_Hooks { + void * (* malloc_fn)(size_t); + void (* free_fn)(void *); +}; + +typedef struct cJSON cJSON, *PcJSON; + +struct cJSON { + struct cJSON * next; + struct cJSON * prev; + struct cJSON * child; + int type; + char * valuestring; + int valueint; + double valuedouble; + char * string; + undefined field_0x24; + undefined field_0x25; + undefined field_0x26; + undefined field_0x27; +}; + +typedef struct printbuffer printbuffer, *Pprintbuffer; + +struct printbuffer { + char * buffer; + int length; + int offset; +}; + +typedef enum AT_MODE { + AM_CMD=0, + AM_DATA=1 +} AT_MODE; + +typedef struct at_para_descriptor_t at_para_descriptor_t, *Pat_para_descriptor_t; + +typedef enum AT_PARA_TYPE { + APT_DI=3, + APT_HEX=2, + APT_HI=4, + APT_IP=5, + APT_TDATA=1, + APT_TEXT=0 +} AT_PARA_TYPE; + +struct at_para_descriptor_t { + enum AT_PARA_TYPE pt; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + void * pvar; + u32 option; +}; + +typedef enum AT_PARA_OPTION { + APO_RO=0, + APO_RW=1 +} AT_PARA_OPTION; + +typedef enum anon_enum_16 { + AET_LINE=2048, + AET_PARA=1024, + HAL_AC0_TIMER_BIT=1, + HAL_AC1_TIMER_BIT=2, + HAL_AC2_TIMER_BIT=4, + HAL_AC3_TIMER_BIT=8, + HAL_BCN_TIMER_BIT=16, + HAL_IDLE_TIMER_BIT=32, + HAL_KE_TIMER_BIT=256, + HAL_MM_TIMER_BIT=-128, + HAL_RX_TIMER_BIT=64, + LLD_EXT_ADV_STOP_IND=513, + LLD_STOP_IND=512, + ME_CHAN_CONFIG_CFM=5123, + ME_CHAN_CONFIG_REQ=5122, + ME_CONFIG_CFM=5121, + ME_CONFIG_REQ=5120, + ME_MAX=5137, + ME_RC_SET_RATE_REQ=5136, + ME_RC_STATS_CFM=5135, + ME_RC_STATS_REQ=5134, + ME_SET_ACTIVE_CFM=5138, + ME_SET_ACTIVE_REQ=5137, + ME_SET_CONTROL_PORT_CFM=5125, + ME_SET_CONTROL_PORT_REQ=5124, + ME_SET_PS_DISABLE_CFM=5140, + ME_SET_PS_DISABLE_REQ=5139, + ME_STA_ADD_CFM=5128, + ME_STA_ADD_REQ=5127, + ME_STA_DEL_CFM=5130, + ME_STA_DEL_REQ=5129, + ME_TKIP_MIC_FAILURE_IND=5126, + ME_TRAFFIC_IND_CFM=5133, + ME_TRAFFIC_IND_REQ=5132, + ME_TX_CREDITS_UPDATE_IND=5131, + PBUF_POOL=386, + PBUF_RAM=640, + PBUF_REF=65, + PBUF_ROM=1, + ROM_API_INDEX_AON_Get_Xtal_CapCode=8, + ROM_API_INDEX_AON_LowPower_Enter_PDS0=18, + ROM_API_INDEX_AON_LowPower_Exit_PDS0=19, + ROM_API_INDEX_AON_Power_Off_BG=11, + ROM_API_INDEX_AON_Power_Off_LDO11_SOC=13, + ROM_API_INDEX_AON_Power_Off_LDO15_RF=15, + ROM_API_INDEX_AON_Power_Off_MBG=5, + ROM_API_INDEX_AON_Power_Off_SFReg=17, + ROM_API_INDEX_AON_Power_Off_XTAL=9, + ROM_API_INDEX_AON_Power_On_BG=10, + ROM_API_INDEX_AON_Power_On_LDO11_SOC=12, + ROM_API_INDEX_AON_Power_On_LDO15_RF=14, + ROM_API_INDEX_AON_Power_On_MBG=4, + ROM_API_INDEX_AON_Power_On_SFReg=16, + ROM_API_INDEX_AON_Power_On_XTAL=6, + ROM_API_INDEX_AON_Set_Xtal_CapCode=7, + ROM_API_INDEX_ASM_Delay_Us=20, + ROM_API_INDEX_BFLB_Soft_CRC32=-81, + ROM_API_INDEX_BL602_Delay_MS=22, + ROM_API_INDEX_BL602_Delay_US=21, + ROM_API_INDEX_BL602_MemCmp=28, + ROM_API_INDEX_BL602_MemCpy=23, + ROM_API_INDEX_BL602_MemCpy4=24, + ROM_API_INDEX_BL602_MemCpy_Fast=25, + ROM_API_INDEX_BL602_MemSet=26, + ROM_API_INDEX_BL602_MemSet4=27, + ROM_API_INDEX_EF_Ctrl_AutoLoad_Done=33, + ROM_API_INDEX_EF_Ctrl_Busy=32, + ROM_API_INDEX_EF_Ctrl_Clear=37, + ROM_API_INDEX_EF_Ctrl_Get_Trim_Parity=34, + ROM_API_INDEX_EF_Ctrl_Load_Efuse_R0=31, + ROM_API_INDEX_EF_Ctrl_Program_Efuse_0=30, + ROM_API_INDEX_EF_Ctrl_Read_RC32K_Trim=36, + ROM_API_INDEX_EF_Ctrl_Read_RC32M_Trim=35, + ROM_API_INDEX_EF_Ctrl_Sw_AHB_Clk_0=29, + ROM_API_INDEX_FUNC_EMPTY_END=511, + ROM_API_INDEX_FUNC_EMPTY_START=-80, + ROM_API_INDEX_GLB_Deswap_Flash_Pin=52, + ROM_API_INDEX_GLB_GPIO_Get_Fun=58, + ROM_API_INDEX_GLB_GPIO_Init=54, + ROM_API_INDEX_GLB_GPIO_OUTPUT_Disable=56, + ROM_API_INDEX_GLB_GPIO_OUTPUT_Enable=55, + ROM_API_INDEX_GLB_GPIO_Set_HZ=57, + ROM_API_INDEX_GLB_Get_BCLK_Div=40, + ROM_API_INDEX_GLB_Get_HCLK_Div=41, + ROM_API_INDEX_GLB_Get_Root_CLK_Sel=38, + ROM_API_INDEX_GLB_SW_CPU_Reset=48, + ROM_API_INDEX_GLB_SW_POR_Reset=49, + ROM_API_INDEX_GLB_SW_System_Reset=47, + ROM_API_INDEX_GLB_Select_External_Flash=51, + ROM_API_INDEX_GLB_Select_Internal_Flash=50, + ROM_API_INDEX_GLB_Set_PKA_CLK_Sel=46, + ROM_API_INDEX_GLB_Set_SF_CLK=45, + ROM_API_INDEX_GLB_Set_System_CLK=43, + ROM_API_INDEX_GLB_Set_System_CLK_Div=39, + ROM_API_INDEX_GLB_Swap_Flash_Pin=53, + ROM_API_INDEX_HBN_32K_Sel=66, + ROM_API_INDEX_HBN_Enable=61, + ROM_API_INDEX_HBN_GPIO7_Dbg_Pull_Cfg=75, + ROM_API_INDEX_HBN_Hw_Pu_Pd_Cfg=73, + ROM_API_INDEX_HBN_Mode_Enter=59, + ROM_API_INDEX_HBN_Pin_WakeUp_Mask=74, + ROM_API_INDEX_HBN_Power_Down_Flash=60, + ROM_API_INDEX_HBN_Power_Off_RC32K=71, + ROM_API_INDEX_HBN_Power_Off_Xtal_32K=69, + ROM_API_INDEX_HBN_Power_On_RC32K=70, + ROM_API_INDEX_HBN_Power_On_Xtal_32K=68, + ROM_API_INDEX_HBN_Reset=62, + ROM_API_INDEX_HBN_Set_Embedded_Flash_Pullup=76, + ROM_API_INDEX_HBN_Set_Ldo11_Aon_Vout=63, + ROM_API_INDEX_HBN_Set_Ldo11_Rt_Vout=64, + ROM_API_INDEX_HBN_Set_Ldo11_Soc_Vout=65, + ROM_API_INDEX_HBN_Set_ROOT_CLK_Sel=67, + ROM_API_INDEX_HBN_Trim_RC32K=72, + ROM_API_INDEX_L1C_IROM_2T_Access_Set=79, + ROM_API_INDEX_L1C_Set_Way_Disable=78, + ROM_API_INDEX_L1C_Set_Wrap=77, + ROM_API_INDEX_PDS_Default_Level_Config=84, + ROM_API_INDEX_PDS_Disable_PLL_All_Clks=90, + ROM_API_INDEX_PDS_Disable_PLL_Clk=92, + ROM_API_INDEX_PDS_Enable=81, + ROM_API_INDEX_PDS_Enable_PLL_All_Clks=89, + ROM_API_INDEX_PDS_Enable_PLL_Clk=91, + ROM_API_INDEX_PDS_Force_Config=82, + ROM_API_INDEX_PDS_Power_Off_PLL=93, + ROM_API_INDEX_PDS_Power_On_PLL=88, + ROM_API_INDEX_PDS_RAM_Config=83, + ROM_API_INDEX_PDS_Reset=80, + ROM_API_INDEX_PDS_Select_RC32M_As_PLL_Ref=86, + ROM_API_INDEX_PDS_Select_XTAL_As_PLL_Ref=87, + ROM_API_INDEX_PDS_Trim_RC32M=85, + ROM_API_INDEX_RSVD_0=1, + ROM_API_INDEX_RSVD_1=2, + ROM_API_INDEX_RSVD_LAST=3, + ROM_API_INDEX_SEC_Eng_Turn_Off_Sec_Ring=95, + ROM_API_INDEX_SEC_Eng_Turn_On_Sec_Ring=94, + ROM_API_INDEX_SF_Cfg_Deinit_Ext_Flash_Gpio=-123, + ROM_API_INDEX_SF_Cfg_Flash_Identify=-119, + ROM_API_INDEX_SF_Cfg_Get_Flash_Cfg_Need_Lock=-121, + ROM_API_INDEX_SF_Cfg_Init_Ext_Flash_Gpio=-125, + ROM_API_INDEX_SF_Cfg_Init_Flash_Gpio=-120, + ROM_API_INDEX_SF_Cfg_Init_Internal_Flash_Gpio=-124, + ROM_API_INDEX_SF_Cfg_Restore_GPIO17_Fun=-122, + ROM_API_INDEX_SF_Ctrl_AES_Disable=-106, + ROM_API_INDEX_SF_Ctrl_AES_Enable=-107, + ROM_API_INDEX_SF_Ctrl_AES_Enable_BE=-114, + ROM_API_INDEX_SF_Ctrl_AES_Enable_LE=-113, + ROM_API_INDEX_SF_Ctrl_AES_Set_IV=-109, + ROM_API_INDEX_SF_Ctrl_AES_Set_IV_BE=-108, + ROM_API_INDEX_SF_Ctrl_AES_Set_Key=-111, + ROM_API_INDEX_SF_Ctrl_AES_Set_Key_BE=-110, + ROM_API_INDEX_SF_Ctrl_AES_Set_Region=-112, + ROM_API_INDEX_SF_Ctrl_Disable=-115, + ROM_API_INDEX_SF_Ctrl_Enable=-118, + ROM_API_INDEX_SF_Ctrl_GetBusyState=-99, + ROM_API_INDEX_SF_Ctrl_Get_Clock_Delay=-97, + ROM_API_INDEX_SF_Ctrl_Get_Flash_Image_Offset=-104, + ROM_API_INDEX_SF_Ctrl_Icache2_Set=-100, + ROM_API_INDEX_SF_Ctrl_Icache_Set=-101, + ROM_API_INDEX_SF_Ctrl_Is_AES_Enable=-98, + ROM_API_INDEX_SF_Ctrl_Select_Clock=-103, + ROM_API_INDEX_SF_Ctrl_Select_Pad=-117, + ROM_API_INDEX_SF_Ctrl_SendCmd=-102, + ROM_API_INDEX_SF_Ctrl_Set_Clock_Delay=-96, + ROM_API_INDEX_SF_Ctrl_Set_Flash_Image_Offset=-105, + ROM_API_INDEX_SF_Ctrl_Set_Owner=-116, + ROM_API_INDEX_SFlash_Blk32_Erase=106, + ROM_API_INDEX_SFlash_Blk64_Erase=107, + ROM_API_INDEX_SFlash_Busy=100, + ROM_API_INDEX_SFlash_Cache_Enable_Set=121, + ROM_API_INDEX_SFlash_Cache_Flush=122, + ROM_API_INDEX_SFlash_Cache_Hit_Count_Get=124, + ROM_API_INDEX_SFlash_Cache_Miss_Count_Get=125, + ROM_API_INDEX_SFlash_Cache_Read_Disable=126, + ROM_API_INDEX_SFlash_Cache_Read_Enable=123, + ROM_API_INDEX_SFlash_Chip_Erase=104, + ROM_API_INDEX_SFlash_DisableBurstWrap=116, + ROM_API_INDEX_SFlash_Erase=108, + ROM_API_INDEX_SFlash_GetDeviceId=112, + ROM_API_INDEX_SFlash_GetJedecId=111, + ROM_API_INDEX_SFlash_GetUniqueId=110, + ROM_API_INDEX_SFlash_IDbus_Read_Enable=120, + ROM_API_INDEX_SFlash_Init=96, + ROM_API_INDEX_SFlash_Powerdown=113, + ROM_API_INDEX_SFlash_Program=109, + ROM_API_INDEX_SFlash_Qspi_Enable=102, + ROM_API_INDEX_SFlash_Read=127, + ROM_API_INDEX_SFlash_Read_Reg=98, + ROM_API_INDEX_SFlash_Read_Reg_With_Cmd=-128, + ROM_API_INDEX_SFlash_Releae_Powerdown=114, + ROM_API_INDEX_SFlash_Reset_Continue_Read=118, + ROM_API_INDEX_SFlash_Restore_From_Powerdown=-126, + ROM_API_INDEX_SFlash_Sector_Erase=105, + ROM_API_INDEX_SFlash_SetBurstWrap=115, + ROM_API_INDEX_SFlash_SetSPIMode=97, + ROM_API_INDEX_SFlash_Set_IDbus_Cfg=119, + ROM_API_INDEX_SFlash_Software_Reset=117, + ROM_API_INDEX_SFlash_Volatile_Reg_Write_Enable=103, + ROM_API_INDEX_SFlash_Write_Enable=101, + ROM_API_INDEX_SFlash_Write_Reg=99, + ROM_API_INDEX_SFlash_Write_Reg_With_Cmd=-127, + ROM_API_INDEX_System_Core_Clock_Update_From_RC32M=44, + ROM_API_INDEX_Update_SystemCoreClockWith_XTAL=42, + ROM_API_INDEX_VERSION=0, + ROM_API_INDEX_XIP_SFlash_Erase_Need_Lock=-93, + ROM_API_INDEX_XIP_SFlash_Erase_With_Lock=-84, + ROM_API_INDEX_XIP_SFlash_GetDeviceId_Need_Lock=-89, + ROM_API_INDEX_XIP_SFlash_GetJedecId_Need_Lock=-90, + ROM_API_INDEX_XIP_SFlash_GetUniqueId_Need_Lock=-88, + ROM_API_INDEX_XIP_SFlash_Opt_Enter=-83, + ROM_API_INDEX_XIP_SFlash_Opt_Exit=-82, + ROM_API_INDEX_XIP_SFlash_Read_Need_Lock=-91, + ROM_API_INDEX_XIP_SFlash_Read_Via_Cache_Need_Lock=-87, + ROM_API_INDEX_XIP_SFlash_Read_With_Lock=-86, + ROM_API_INDEX_XIP_SFlash_State_Restore=-94, + ROM_API_INDEX_XIP_SFlash_State_Save=-95, + ROM_API_INDEX_XIP_SFlash_Write_Need_Lock=-92, + ROM_API_INDEX_XIP_SFlash_Write_With_Lock=-85, + SCANU_JOIN_CFM=4099, + SCANU_JOIN_REQ=4098, + SCANU_MAX=4103, + SCANU_RAW_SEND_CFM=4102, + SCANU_RAW_SEND_REQ=4101, + SCANU_RESULT_IND=4100, + SCANU_START_CFM=4097, + SCANU_START_REQ=4096 +} anon_enum_16; + +typedef union at_value_t at_value_t, *Pat_value_t; + +union at_value_t { + at_text_t text[256]; + at_hex_t hex[256]; + at_di_t di; + at_hi_t hi; + at_ip_t ip; +}; + +typedef struct at_var_descriptor_t at_var_descriptor_t, *Pat_var_descriptor_t; + +struct at_var_descriptor_t { + char * key; + enum AT_PARA_TYPE pt; + enum AT_PARA_OPTION po; + undefined field_0x6; + undefined field_0x7; + void * pvar; + s32 vsize; + s32 (* verify)(union at_value_t *); +}; + +typedef struct bam_env_tag bam_env_tag, *Pbam_env_tag; + +typedef struct bam_baw bam_baw, *Pbam_baw; + +struct bam_baw { + uint (* idx_compute)(struct bam_baw *, uint); + uint16_t fsn; + uint8_t states[64]; + uint8_t fsn_idx; + uint8_t buf_size; + uint8_t mask; + undefined field_0x49; + undefined field_0x4a; + undefined field_0x4b; +}; + +struct bam_env_tag { + uint32_t pkt_cnt; + uint32_t last_activity_time; + uint16_t ssn; + uint16_t ba_timeout; + uint8_t sta_idx; + uint8_t dev_type; + uint8_t ba_policy; + uint8_t buffer_size; + uint8_t tid; + uint8_t dialog_token; + uint8_t amsdu; + uint8_t delba_count; + struct bam_baw baw; +}; + +typedef enum HCI_MSG_DEST_LL { + BLE_CTRL=3, + BLE_MNG=2, + BT_BCST=7, + BT_CTRL_BD_ADDR=6, + BT_CTRL_CONHDL=5, + BT_MNG=4, + CTRL=1, + DBG=8, + LL_UNDEF=9, + MNG=0 +} HCI_MSG_DEST_LL; + +typedef struct hci_evt_desc_tag hci_evt_desc_tag, *Phci_evt_desc_tag; + +struct hci_evt_desc_tag { + uint8_t code; + uint8_t dest_field; + uint8_t special_pack; + undefined field_0x3; + void * par_fmt; +}; + +typedef struct hci_cmd_desc_tab_ref hci_cmd_desc_tab_ref, *Phci_cmd_desc_tab_ref; + +typedef struct hci_cmd_desc_tag hci_cmd_desc_tag, *Phci_cmd_desc_tag; + +struct hci_cmd_desc_tab_ref { + uint8_t ogf; + undefined field_0x1; + uint16_t nb_cmds; + struct hci_cmd_desc_tag * cmd_desc_tab; +}; + +struct hci_cmd_desc_tag { + uint16_t opcode; + uint8_t dest_field; + uint8_t par_size_max; + void * par_fmt; + void * ret_par_fmt; +}; + +typedef enum HCI_MSG_DEST_HL { + HL_AM0=3, + HL_CTRL=1, + HL_DATA=2, + HL_MNG=0, + HL_UNDEF=4 +} HCI_MSG_DEST_HL; + +typedef enum HCI_PACK_STATUS { + HCI_PACK_ERROR=4, + HCI_PACK_IN_BUF_OVFLW=1, + HCI_PACK_OK=0, + HCI_PACK_OUT_BUF_OVFLW=2, + HCI_PACK_WRONG_FORMAT=3 +} HCI_PACK_STATUS; + +typedef struct hci_env_tag hci_env_tag, *Phci_env_tag; + +typedef struct evt_mask evt_mask, *Pevt_mask; + +struct evt_mask { + uint8_t mask[8]; +}; + +struct hci_env_tag { + struct evt_mask evt_msk; + struct evt_mask evt_msk_page_2; +}; + +typedef uint uintptr_t; + +typedef uintptr_t mem_ptr_t; + +typedef int32_t s32_t.conflict; + +typedef int32_t s32_t.conflict9; + +typedef int32_t s32_t.conflict8; + +typedef int32_t s32_t.conflict7; + +typedef int32_t s32_t.conflict6; + +typedef int32_t s32_t.conflict5; + +typedef int32_t s32_t.conflict4; + +typedef int32_t s32_t.conflict3; + +typedef int32_t s32_t.conflict2; + +typedef int32_t s32_t.conflict1; + +typedef enum tcp_state { + CLOSED=0, + CLOSE_WAIT=7, + CLOSING=8, + ESTABLISHED=4, + FIN_WAIT_1=5, + FIN_WAIT_2=6, + LAST_ACK=9, + LISTEN=1, + SYN_RCVD=3, + SYN_SENT=2, + TIME_WAIT=10 +} tcp_state; + +typedef u16_t tcpwnd_size_t; + +typedef struct wifi_mgmr wifi_mgmr, *Pwifi_mgmr; + +typedef struct wifi_mgmr wifi_mgmr_t; + +typedef struct wlan_netif.conflict25 wlan_netif.conflict25, *Pwlan_netif.conflict25; + +typedef struct wlan_netif.conflict26 wlan_netif.conflict26, *Pwlan_netif.conflict26; + +typedef enum WIFI_MGMR_CONNECTION_STATUS { + WIFI_MGMR_CONNECTION_STATUS_CONNECTED_IP_NO=3, + WIFI_MGMR_CONNECTION_STATUS_CONNECTED_IP_YES=2, + WIFI_MGMR_CONNECTION_STATUS_CONNECTING=1, + WIFI_MGMR_CONNECTION_STATUS_DISCONNECTED=4, + WIFI_MGMR_CONNECTION_STATUS_IDLE=0 +} WIFI_MGMR_CONNECTION_STATUS; + +typedef enum WIFI_MGMR_CONNECTION_STATUS WIFI_MGMR_CONNECTION_STATUS_T; + +typedef struct wifi_mgmr_profile wifi_mgmr_profile, *Pwifi_mgmr_profile; + +typedef struct wifi_mgmr_profile wifi_mgmr_profile_t; + +typedef struct wifi_mgmr_scan_item wifi_mgmr_scan_item, *Pwifi_mgmr_scan_item; + +typedef struct wifi_mgmr_scan_item wifi_mgmr_scan_item_t; + +typedef struct xSTATIC_STREAM_BUFFER xSTATIC_STREAM_BUFFER, *PxSTATIC_STREAM_BUFFER; + +typedef struct xSTATIC_STREAM_BUFFER StaticStreamBuffer_t; + +typedef StaticStreamBuffer_t StaticMessageBuffer_t; + +typedef StaticMessageBuffer_t os_messagequeue_t; + +typedef struct stateMachine stateMachine, *PstateMachine; + +typedef struct wifi_mgmr_connect_ind_stat_info wifi_mgmr_connect_ind_stat_info, *Pwifi_mgmr_connect_ind_stat_info; + +typedef struct wifi_mgmr_connect_ind_stat_info wifi_mgmr_connect_ind_stat_info_t; + +typedef struct anon_struct_for_ipv4 anon_struct_for_ipv4, *Panon_struct_for_ipv4; + +typedef struct netif.conflict34 netif.conflict34, *Pnetif.conflict34; + +typedef union anon_union_for_field_5 anon_union_for_field_5, *Panon_union_for_field_5; + +typedef struct netif.conflict35 netif.conflict35, *Pnetif.conflict35; + +typedef struct state state, *Pstate; + +typedef struct event event, *Pevent; + +typedef struct anon_struct.conflict385 anon_struct.conflict385, *Panon_struct.conflict385; + +typedef struct transition transition, *Ptransition; + +struct wifi_mgmr_connect_ind_stat_info { + uint16_t status_code; + uint8_t type_ind; + char ssid[32]; + char psk[65]; + uint8_t bssid[6]; + uint16_t chan_freq; + uint8_t chan_band; + undefined field_0x6d; +}; + +struct wifi_mgmr_profile { + char ssid[33]; + uint8_t no_autoconnect; + undefined field_0x22; + undefined field_0x23; + uint32_t ssid_len; + char psk[65]; + undefined field_0x69; + undefined field_0x6a; + undefined field_0x6b; + uint32_t psk_len; + char pmk[65]; + undefined field_0xb1; + undefined field_0xb2; + undefined field_0xb3; + uint32_t pmk_len; + uint8_t mac[6]; + uint8_t dhcp_use; + uint8_t priority; + uint8_t isActive; + uint8_t isUsed; + undefined field_0xc2; + undefined field_0xc3; +}; + +struct netif.conflict35 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct netif.conflict34 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct anon_struct_for_ipv4 { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +struct anon_struct.conflict385 { + int8_t rssi; +}; + +union anon_union_for_field_5 { + struct anon_struct.conflict385 sta; +}; + +struct state { + struct state * parentState; + struct state * entryState; + struct transition * transitions; + size_t numTransitions; + void * data; + void (* entryAction)(void *, struct event *); + void (* exitAction)(void *, struct event *); +}; + +struct event { + int type; + void * data; +}; + +struct xSTATIC_STREAM_BUFFER { + size_t uxDummy1[4]; + void * pvDummy2[3]; + uint8_t ucDummy3; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; + UBaseType_t uxDummy4; +}; + +struct stateMachine { + struct state * currentState; + struct state * previousState; + struct state * errorState; +}; + +struct wlan_netif.conflict25 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict34 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +struct wifi_mgmr_scan_item { + char ssid[32]; + char ssid_tail[1]; + undefined field_0x21; + undefined field_0x22; + undefined field_0x23; + uint32_t ssid_len; + uint8_t bssid[6]; + uint8_t channel; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t auth; + uint8_t cipher; + uint8_t is_used; + undefined field_0x35; + undefined field_0x36; + undefined field_0x37; + uint32_t timestamp_lastseen; +}; + +struct wlan_netif.conflict26 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict35 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +struct wifi_mgmr { + uint8_t ready; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + int channel; + int inf_ap_enabled; + struct wlan_netif.conflict25 wlan_sta; + struct wlan_netif.conflict26 wlan_ap; + WIFI_MGMR_CONNECTION_STATUS_T status; + undefined field_0xed; + undefined field_0xee; + undefined field_0xef; + wifi_mgmr_profile_t profiles[2]; + int profile_active_index; + wifi_mgmr_scan_item_t scan_items[50]; + os_messagequeue_t mq; + uint8_t mq_pool[2240]; + struct stateMachine m; + os_timer_t timer; + wifi_mgmr_connect_ind_stat_info_t wifi_mgmr_stat_info; + char country_code[3]; + uint8_t disable_autoreconnect; + undefined field_0x17c2; + undefined field_0x17c3; + int channel_nums; + uint32_t pending_task; + uint32_t features; + int scan_item_timeout; +}; + +struct transition { + int eventType; + void * condition; + _Bool (* guard)(void *, struct event *); + void (* action)(void *, struct event *, void *); + struct state * nextState; +}; + +typedef struct wifi_mgmr_cfg_element_msg wifi_mgmr_cfg_element_msg, *Pwifi_mgmr_cfg_element_msg; + +struct wifi_mgmr_cfg_element_msg { + uint32_t ops; + uint32_t task; + uint32_t element; + uint32_t type; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct wlan_netif.conflict27 wlan_netif.conflict27, *Pwlan_netif.conflict27; + +typedef struct netif.conflict36 netif.conflict36, *Pnetif.conflict36; + +struct netif.conflict36 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict27 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict36 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif wlan_netif, *Pwlan_netif; + +struct wlan_netif { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wifi_mgmr_sta_basic_info wifi_mgmr_sta_basic_info, *Pwifi_mgmr_sta_basic_info; + +typedef struct wifi_mgmr_sta_basic_info wifi_mgmr_sta_basic_info_t; + +struct wifi_mgmr_sta_basic_info { + uint8_t sta_idx; + uint8_t is_used; + uint8_t sta_mac[6]; + uint32_t tsfhi; + uint32_t tsflo; + int rssi; + uint8_t data_rate; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct wifi_mgmr_ipgot_msg wifi_mgmr_ipgot_msg, *Pwifi_mgmr_ipgot_msg; + +struct wifi_mgmr_ipgot_msg { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +typedef struct wifi_mgmr_msg wifi_mgmr_msg, *Pwifi_mgmr_msg; + +typedef struct wifi_mgmr_msg wifi_mgmr_msg_t; + +typedef enum WIFI_MGMR_EVENT { + WIFI_MGMR_EVENT_APP_AP_START=8, + WIFI_MGMR_EVENT_APP_AP_STOP=9, + WIFI_MGMR_EVENT_APP_CONF_MAX_STA=10, + WIFI_MGMR_EVENT_APP_CONNECT=1, + WIFI_MGMR_EVENT_APP_CONNECTED=3, + WIFI_MGMR_EVENT_APP_DENOISE=12, + WIFI_MGMR_EVENT_APP_DISCONNECT=5, + WIFI_MGMR_EVENT_APP_IDLE=0, + WIFI_MGMR_EVENT_APP_IP_GOT=4, + WIFI_MGMR_EVENT_APP_PHY_UP=7, + WIFI_MGMR_EVENT_APP_RC_CONFIG=11, + WIFI_MGMR_EVENT_APP_RECONNECT=6, + WIFI_MGMR_EVENT_APP_RELOAD_TSEN=13, + WIFI_MGMR_EVENT_APP_SNIFFER=2, + WIFI_MGMR_EVENT_FW_CFG_REQ=22, + WIFI_MGMR_EVENT_FW_CHANNEL_SET=17, + WIFI_MGMR_EVENT_FW_DATA_RAW_SEND=21, + WIFI_MGMR_EVENT_FW_DISCONNECT=15, + WIFI_MGMR_EVENT_FW_IND_CONNECTED=20, + WIFI_MGMR_EVENT_FW_IND_DISCONNECT=19, + WIFI_MGMR_EVENT_FW_POWERSAVING=16, + WIFI_MGMR_EVENT_FW_SCAN=18, + WIFI_MGMR_EVENT_GLB_AP_IND_STA_DEL=27, + WIFI_MGMR_EVENT_GLB_AP_IND_STA_NEW=26, + WIFI_MGMR_EVENT_GLB_DISABLE_AUTORECONNECT=28, + WIFI_MGMR_EVENT_GLB_ENABLE_AUTORECONNECT=29, + WIFI_MGMR_EVENT_GLB_IP_UPDATE=30, + WIFI_MGMR_EVENT_GLB_SCAN_IND_BEACON=24, + WIFI_MGMR_EVENT_GLB_SCAN_IND_PROBE_RESP=25, + WIFI_MGMR_EVENT_MAXAPP_MINIFW=14, + WIFI_MGMR_EVENT_MAXFW_MINI_GLOBAL=23 +} WIFI_MGMR_EVENT; + +typedef enum WIFI_MGMR_EVENT WIFI_MGMR_EVENT_T; + +struct wifi_mgmr_msg { + WIFI_MGMR_EVENT_T ev; + void * data1; + void * data2; + uint32_t len; + uint8_t[0] data; +}; + +typedef struct anon_struct.conflict400 anon_struct.conflict400, *Panon_struct.conflict400; + +struct anon_struct.conflict400 { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +typedef struct anon_struct.conflict401 anon_struct.conflict401, *Panon_struct.conflict401; + +struct anon_struct.conflict401 { + int8_t rssi; +}; + +typedef struct wifi_mgmr_cfg_element_msg wifi_mgmr_cfg_element_msg_t; + +typedef struct wifi_mgmr_ipgot_msg wifi_mgmr_ipgot_msg_t; + +typedef enum EVENT_TYPE { + EVENT_TYPE_APP=1, + EVENT_TYPE_FW=0, + EVENT_TYPE_GLB=2 +} EVENT_TYPE; + +typedef struct wlan_netif.conflict12 wlan_netif.conflict12, *Pwlan_netif.conflict12; + +typedef struct netif.conflict19 netif.conflict19, *Pnetif.conflict19; + +struct netif.conflict19 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict12 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict19 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict13 wlan_netif.conflict13, *Pwlan_netif.conflict13; + +typedef struct netif.conflict20 netif.conflict20, *Pnetif.conflict20; + +struct netif.conflict20 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict13 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict20 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct anon_struct.conflict384 anon_struct.conflict384, *Panon_struct.conflict384; + +struct anon_struct.conflict384 { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +typedef struct wlan_netif.conflict15 wlan_netif.conflict15, *Pwlan_netif.conflict15; + +typedef struct netif.conflict22 netif.conflict22, *Pnetif.conflict22; + +struct netif.conflict22 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict15 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict22 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict10 wlan_netif.conflict10, *Pwlan_netif.conflict10; + +typedef struct netif.conflict16 netif.conflict16, *Pnetif.conflict16; + +struct netif.conflict16 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict10 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict16 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct anon_struct.conflict389 anon_struct.conflict389, *Panon_struct.conflict389; + +struct anon_struct.conflict389 { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +typedef struct anon_struct.conflict386 anon_struct.conflict386, *Panon_struct.conflict386; + +struct anon_struct.conflict386 { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +typedef struct wlan_netif.conflict17 wlan_netif.conflict17, *Pwlan_netif.conflict17; + +typedef struct netif.conflict25 netif.conflict25, *Pnetif.conflict25; + +struct netif.conflict25 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict17 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict25 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct anon_struct.conflict387 anon_struct.conflict387, *Panon_struct.conflict387; + +struct anon_struct.conflict387 { + int8_t rssi; +}; + +typedef struct wlan_netif.conflict18 wlan_netif.conflict18, *Pwlan_netif.conflict18; + +typedef struct netif.conflict26 netif.conflict26, *Pnetif.conflict26; + +struct netif.conflict26 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict18 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict26 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict wlan_netif.conflict, *Pwlan_netif.conflict; + +typedef struct netif.conflict5 netif.conflict5, *Pnetif.conflict5; + +struct netif.conflict5 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict5 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict1 wlan_netif.conflict1, *Pwlan_netif.conflict1; + +typedef struct netif.conflict6 netif.conflict6, *Pnetif.conflict6; + +struct netif.conflict6 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict1 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict6 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct anon_struct.conflict392 anon_struct.conflict392, *Panon_struct.conflict392; + +struct anon_struct.conflict392 { + int8_t rssi; +}; + +typedef struct wlan_netif.conflict23 wlan_netif.conflict23, *Pwlan_netif.conflict23; + +typedef struct netif.conflict32 netif.conflict32, *Pnetif.conflict32; + +struct netif.conflict32 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict23 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict32 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct anon_struct.conflict393 anon_struct.conflict393, *Panon_struct.conflict393; + +struct anon_struct.conflict393 { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +typedef struct anon_struct.conflict394 anon_struct.conflict394, *Panon_struct.conflict394; + +struct anon_struct.conflict394 { + int8_t rssi; +}; + +typedef struct wlan_netif.conflict20 wlan_netif.conflict20, *Pwlan_netif.conflict20; + +typedef struct netif.conflict28 netif.conflict28, *Pnetif.conflict28; + +struct netif.conflict28 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict20 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict28 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct anon_struct.conflict390 anon_struct.conflict390, *Panon_struct.conflict390; + +struct anon_struct.conflict390 { + int8_t rssi; +}; + +typedef struct anon_struct.conflict391 anon_struct.conflict391, *Panon_struct.conflict391; + +struct anon_struct.conflict391 { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +typedef struct wlan_netif.conflict22 wlan_netif.conflict22, *Pwlan_netif.conflict22; + +typedef struct netif.conflict31 netif.conflict31, *Pnetif.conflict31; + +struct netif.conflict31 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict22 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict31 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict8 wlan_netif.conflict8, *Pwlan_netif.conflict8; + +typedef struct netif.conflict14 netif.conflict14, *Pnetif.conflict14; + +struct netif.conflict14 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict8 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict14 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict6 wlan_netif.conflict6, *Pwlan_netif.conflict6; + +typedef struct netif.conflict12 netif.conflict12, *Pnetif.conflict12; + +struct netif.conflict12 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict6 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict12 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict5 wlan_netif.conflict5, *Pwlan_netif.conflict5; + +typedef struct netif.conflict11 netif.conflict11, *Pnetif.conflict11; + +struct netif.conflict11 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict5 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict11 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wifi_mgmr_ap_msg wifi_mgmr_ap_msg, *Pwifi_mgmr_ap_msg; + +struct wifi_mgmr_ap_msg { + int32_t channel; + char ssid[32]; + char ssid_tail[1]; + uint8_t hidden_ssid; + uint32_t ssid_len; + char psk[64]; + char psk_tail[1]; + uint32_t psk_len; +}; + +typedef struct wlan_netif.conflict3 wlan_netif.conflict3, *Pwlan_netif.conflict3; + +typedef struct netif.conflict8 netif.conflict8, *Pnetif.conflict8; + +struct netif.conflict8 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict3 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict8 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wifi_mgmr_ap_msg wifi_mgmr_ap_msg_t; + +typedef struct mm_bcn_env_tag mm_bcn_env_tag, *Pmm_bcn_env_tag; + +typedef struct hal_dma_desc_tag hal_dma_desc_tag, *Phal_dma_desc_tag; + +typedef struct dma_desc dma_desc, *Pdma_desc; + +struct hal_dma_desc_tag { + struct co_list_hdr hdr; + struct dma_desc * dma_desc; + void (* cb)(void *, int); + void * env; +}; + +struct dma_desc { + uint32_t src; + uint32_t dest; + uint16_t length; + uint16_t ctrl; + uint32_t next; +}; + +struct mm_bcn_env_tag { + struct mm_bcn_change_req * param; + int tx_cfm; + _Bool tx_pending; + _Bool update_ongoing; + _Bool update_pending; + undefined field_0xb; + struct hal_dma_desc_tag dma; + struct co_list tim_list; +}; + + +// WARNING! conflicting data type names: /DWARF/_types.h/__uid_t - /types.h/__uid_t + +typedef long _off_t; + +typedef int _ssize_t; + + +// WARNING! conflicting data type names: /DWARF/_types.h/anon_union - /DWARF/gatt.c/parse_service/anon_union + +typedef struct _mbstate_t _mbstate_t, *P_mbstate_t; + +typedef union anon_union_for___value anon_union_for___value, *Panon_union_for___value; + +typedef uint wint_t; + +union anon_union_for___value { + wint_t __wch; + uchar __wchb[4]; +}; + +struct _mbstate_t { + int __count; + union anon_union_for___value __value; +}; + + +// WARNING! conflicting data type names: /DWARF/_types.h/__nlink_t - /types.h/__nlink_t + + +// WARNING! conflicting data type names: /DWARF/_types.h/__dev_t - /types.h/__dev_t + + +// WARNING! conflicting data type names: /DWARF/_types.h/__off_t - /types.h/__off_t + +typedef long _fpos_t; + + +// WARNING! conflicting data type names: /DWARF/_types.h/__mode_t - /types.h/__mode_t + + +// WARNING! conflicting data type names: /DWARF/_types.h/__ino_t - /types.h/__ino_t + + +// WARNING! conflicting data type names: /DWARF/_types.h/__gid_t - /types.h/__gid_t + +typedef struct rf_para_flash_tag rf_para_flash_tag, *Prf_para_flash_tag; + +struct rf_para_flash_tag { + uint32_t magic; + uint8_t capcode_valid; + uint8_t capcode; + uint8_t poweroffset_valid; + int8_t poweroffset[3]; + uint8_t mac_valid; + uint8_t mac[6]; + uint8_t rsvd[3]; + uint32_t crc32; +}; + +typedef struct rf_para_flash_tag rf_para_flash_t; + +typedef struct rf_calib3_tag.conflict9 rf_calib3_tag.conflict9, *Prf_calib3_tag.conflict9; + +struct rf_calib3_tag.conflict9 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib2_tag.conflict9 rf_calib2_tag.conflict9, *Prf_calib2_tag.conflict9; + +struct rf_calib2_tag.conflict9 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib1_tag.conflict9 rf_calib1_tag.conflict9, *Prf_calib1_tag.conflict9; + +struct rf_calib1_tag.conflict9 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib4_tag.conflict1 rf_calib4_tag.conflict1, *Prf_calib4_tag.conflict1; + +struct rf_calib4_tag.conflict1 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib1_tag.conflict8 rf_calib1_tag.conflict8, *Prf_calib1_tag.conflict8; + +struct rf_calib1_tag.conflict8 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib2_tag rf_calib2_tag, *Prf_calib2_tag; + +struct rf_calib2_tag { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib1_tag.conflict7 rf_calib1_tag.conflict7, *Prf_calib1_tag.conflict7; + +struct rf_calib1_tag.conflict7 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib1_tag.conflict6 rf_calib1_tag.conflict6, *Prf_calib1_tag.conflict6; + +struct rf_calib1_tag.conflict6 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib1_tag.conflict5 rf_calib1_tag.conflict5, *Prf_calib1_tag.conflict5; + +struct rf_calib1_tag.conflict5 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib4_tag.conflict9 rf_calib4_tag.conflict9, *Prf_calib4_tag.conflict9; + +struct rf_calib4_tag.conflict9 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib1_tag.conflict4 rf_calib1_tag.conflict4, *Prf_calib1_tag.conflict4; + +struct rf_calib1_tag.conflict4 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib1_tag.conflict3 rf_calib1_tag.conflict3, *Prf_calib1_tag.conflict3; + +struct rf_calib1_tag.conflict3 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib1_tag.conflict2 rf_calib1_tag.conflict2, *Prf_calib1_tag.conflict2; + +struct rf_calib1_tag.conflict2 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib1_tag.conflict1 rf_calib1_tag.conflict1, *Prf_calib1_tag.conflict1; + +struct rf_calib1_tag.conflict1 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib4_tag.conflict rf_calib4_tag.conflict, *Prf_calib4_tag.conflict; + +struct rf_calib4_tag.conflict { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib3_tag.conflict11 rf_calib3_tag.conflict11, *Prf_calib3_tag.conflict11; + +struct rf_calib3_tag.conflict11 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib3_tag.conflict10 rf_calib3_tag.conflict10, *Prf_calib3_tag.conflict10; + +struct rf_calib3_tag.conflict10 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib1_tag.conflict rf_calib1_tag.conflict, *Prf_calib1_tag.conflict; + +struct rf_calib1_tag.conflict { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib4_tag.conflict11 rf_calib4_tag.conflict11, *Prf_calib4_tag.conflict11; + +struct rf_calib4_tag.conflict11 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib2_tag.conflict11 rf_calib2_tag.conflict11, *Prf_calib2_tag.conflict11; + +struct rf_calib2_tag.conflict11 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib4_tag.conflict4 rf_calib4_tag.conflict4, *Prf_calib4_tag.conflict4; + +struct rf_calib4_tag.conflict4 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib2_tag.conflict10 rf_calib2_tag.conflict10, *Prf_calib2_tag.conflict10; + +struct rf_calib2_tag.conflict10 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib4_tag.conflict2 rf_calib4_tag.conflict2, *Prf_calib4_tag.conflict2; + +struct rf_calib4_tag.conflict2 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib4_tag.conflict3 rf_calib4_tag.conflict3, *Prf_calib4_tag.conflict3; + +struct rf_calib4_tag.conflict3 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib4_tag.conflict6 rf_calib4_tag.conflict6, *Prf_calib4_tag.conflict6; + +struct rf_calib4_tag.conflict6 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib4_tag.conflict5 rf_calib4_tag.conflict5, *Prf_calib4_tag.conflict5; + +struct rf_calib4_tag.conflict5 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib4_tag.conflict8 rf_calib4_tag.conflict8, *Prf_calib4_tag.conflict8; + +struct rf_calib4_tag.conflict8 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib4_tag.conflict7 rf_calib4_tag.conflict7, *Prf_calib4_tag.conflict7; + +struct rf_calib4_tag.conflict7 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib_data_tag rf_calib_data_tag, *Prf_calib_data_tag; + +typedef struct rf_calib2_tag.conflict4 rf_calib2_tag.conflict4, *Prf_calib2_tag.conflict4; + +typedef struct rf_calib3_tag.conflict4 rf_calib3_tag.conflict4, *Prf_calib3_tag.conflict4; + +struct rf_calib2_tag.conflict4 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +struct rf_calib3_tag.conflict4 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +struct rf_calib_data_tag { + uint32_t inited; + struct rf_calib1_tag.conflict3 cal; + struct rf_calib2_tag.conflict4 lo[21]; + undefined field_0x46; + undefined field_0x47; + struct rf_calib3_tag.conflict4 rxcal[4]; + struct rf_calib4_tag.conflict4 txcal[8]; +}; + +typedef struct rf_calib3_tag.conflict5 rf_calib3_tag.conflict5, *Prf_calib3_tag.conflict5; + +struct rf_calib3_tag.conflict5 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib3_tag.conflict2 rf_calib3_tag.conflict2, *Prf_calib3_tag.conflict2; + +struct rf_calib3_tag.conflict2 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib3_tag.conflict3 rf_calib3_tag.conflict3, *Prf_calib3_tag.conflict3; + +struct rf_calib3_tag.conflict3 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib3_tag.conflict1 rf_calib3_tag.conflict1, *Prf_calib3_tag.conflict1; + +struct rf_calib3_tag.conflict1 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict121 anon_struct.conflict121, *Panon_struct.conflict121; + +typedef struct rf_calib2_tag.conflict8 rf_calib2_tag.conflict8, *Prf_calib2_tag.conflict8; + +typedef struct rf_calib3_tag.conflict8 rf_calib3_tag.conflict8, *Prf_calib3_tag.conflict8; + +struct rf_calib2_tag.conflict8 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +struct rf_calib3_tag.conflict8 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +struct anon_struct.conflict121 { + uint32_t inited; + struct rf_calib1_tag.conflict7 cal; + struct rf_calib2_tag.conflict8 lo[21]; + undefined field_0x46; + undefined field_0x47; + struct rf_calib3_tag.conflict8 rxcal[4]; + struct rf_calib4_tag.conflict8 txcal[8]; +}; + +typedef struct anon_struct.conflict122 anon_struct.conflict122, *Panon_struct.conflict122; + +struct anon_struct.conflict122 { + uint32_t inited; + struct rf_calib1_tag.conflict8 cal; + struct rf_calib2_tag.conflict9 lo[21]; + undefined field_0x46; + undefined field_0x47; + struct rf_calib3_tag.conflict9 rxcal[4]; + struct rf_calib4_tag.conflict9 txcal[8]; +}; + +typedef struct rf_calib3_tag.conflict6 rf_calib3_tag.conflict6, *Prf_calib3_tag.conflict6; + +struct rf_calib3_tag.conflict6 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib3_tag.conflict7 rf_calib3_tag.conflict7, *Prf_calib3_tag.conflict7; + +struct rf_calib3_tag.conflict7 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib2_tag.conflict2 rf_calib2_tag.conflict2, *Prf_calib2_tag.conflict2; + +struct rf_calib2_tag.conflict2 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib2_tag.conflict7 rf_calib2_tag.conflict7, *Prf_calib2_tag.conflict7; + +struct rf_calib2_tag.conflict7 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib2_tag.conflict1 rf_calib2_tag.conflict1, *Prf_calib2_tag.conflict1; + +struct rf_calib2_tag.conflict1 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib2_tag.conflict5 rf_calib2_tag.conflict5, *Prf_calib2_tag.conflict5; + +struct rf_calib2_tag.conflict5 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib2_tag.conflict6 rf_calib2_tag.conflict6, *Prf_calib2_tag.conflict6; + +struct rf_calib2_tag.conflict6 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib2_tag.conflict3 rf_calib2_tag.conflict3, *Prf_calib2_tag.conflict3; + +struct rf_calib2_tag.conflict3 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib4_tag.conflict10 rf_calib4_tag.conflict10, *Prf_calib4_tag.conflict10; + +struct rf_calib4_tag.conflict10 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib3_tag rf_calib3_tag, *Prf_calib3_tag; + +struct rf_calib3_tag { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict57 anon_struct.conflict57, *Panon_struct.conflict57; + +struct anon_struct.conflict57 { + uint32_t inited; + struct rf_calib1_tag.conflict2 cal; + struct rf_calib2_tag.conflict2 lo[21]; + undefined field_0x46; + undefined field_0x47; + struct rf_calib3_tag.conflict2 rxcal[4]; + struct rf_calib4_tag.conflict2 txcal[8]; +}; + +typedef struct anon_struct.conflict56 anon_struct.conflict56, *Panon_struct.conflict56; + +struct anon_struct.conflict56 { + uint32_t inited; + struct rf_calib1_tag.conflict1 cal; + struct rf_calib2_tag.conflict1 lo[21]; + undefined field_0x46; + undefined field_0x47; + struct rf_calib3_tag.conflict1 rxcal[4]; + struct rf_calib4_tag.conflict1 txcal[8]; +}; + +typedef struct rf_calib3_tag.conflict rf_calib3_tag.conflict, *Prf_calib3_tag.conflict; + +struct rf_calib3_tag.conflict { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib_data_tag.conflict1 rf_calib_data_tag.conflict1, *Prf_calib_data_tag.conflict1; + +struct rf_calib_data_tag.conflict1 { + uint32_t inited; + struct rf_calib1_tag.conflict9 cal; + struct rf_calib2_tag.conflict11 lo[21]; + undefined field_0x46; + undefined field_0x47; + struct rf_calib3_tag.conflict11 rxcal[4]; + struct rf_calib4_tag.conflict11 txcal[8]; +}; + +typedef struct rf_calib1_tag rf_calib1_tag, *Prf_calib1_tag; + +struct rf_calib1_tag { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib2_tag.conflict rf_calib2_tag.conflict, *Prf_calib2_tag.conflict; + +struct rf_calib2_tag.conflict { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib_data_tag.conflict rf_calib_data_tag.conflict, *Prf_calib_data_tag.conflict; + +struct rf_calib_data_tag.conflict { + uint32_t inited; + struct rf_calib1_tag.conflict4 cal; + struct rf_calib2_tag.conflict5 lo[21]; + undefined field_0x46; + undefined field_0x47; + struct rf_calib3_tag.conflict5 rxcal[4]; + struct rf_calib4_tag.conflict5 txcal[8]; +}; + +typedef struct rf_calib4_tag rf_calib4_tag, *Prf_calib4_tag; + +struct rf_calib4_tag { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct bt_smp bt_smp, *Pbt_smp; + +typedef struct bt_l2cap_le_chan bt_l2cap_le_chan, *Pbt_l2cap_le_chan; + +typedef struct bt_le_oob_sc_data bt_le_oob_sc_data, *Pbt_le_oob_sc_data; + +typedef struct bt_l2cap_chan bt_l2cap_chan, *Pbt_l2cap_chan; + +typedef struct bt_l2cap_le_endpoint bt_l2cap_le_endpoint, *Pbt_l2cap_le_endpoint; + +typedef struct bt_l2cap_chan_ops bt_l2cap_chan_ops, *Pbt_l2cap_chan_ops; + +typedef enum bt_l2cap_chan_state { + BT_L2CAP_CONFIG=2, + BT_L2CAP_CONNECT=1, + BT_L2CAP_CONNECTED=3, + BT_L2CAP_DISCONNECT=4, + BT_L2CAP_DISCONNECTED=0 +} bt_l2cap_chan_state; + +typedef enum bt_l2cap_chan_state bt_l2cap_chan_state_t; + +struct bt_le_oob_sc_data { + u8_t r[16]; + u8_t c[16]; +}; + +struct bt_l2cap_le_endpoint { + u16_t cid; + u16_t mtu; + u16_t mps; + u16_t init_credits; + struct k_sem credits; +}; + +struct bt_l2cap_chan { + struct bt_conn * conn; + struct bt_l2cap_chan_ops * ops; + sys_snode_t node; + void (* destroy)(struct bt_l2cap_chan *); + struct k_delayed_work rtx_work; + atomic_t status[1]; + bt_l2cap_chan_state_t state; + undefined field_0x39; + u16_t psm; + u8_t ident; + enum bt_security_t required_sec_level; + undefined field_0x3e; + undefined field_0x3f; +}; + +struct bt_l2cap_le_chan { + struct bt_l2cap_chan chan; + struct bt_l2cap_le_endpoint rx; + struct bt_l2cap_le_endpoint tx; + struct k_fifo tx_queue; + struct net_buf * tx_buf; + struct net_buf * _sdu; + u16_t _sdu_len; + undefined field_0x7e; + undefined field_0x7f; + struct k_work rx_work; + struct k_fifo rx_queue; +}; + +struct bt_l2cap_chan_ops { + void (* connected)(struct bt_l2cap_chan *); + void (* disconnected)(struct bt_l2cap_chan *); + void (* encrypt_change)(struct bt_l2cap_chan *, u8_t); + net_buf * (* alloc_buf)(struct bt_l2cap_chan *); + int (* recv)(struct bt_l2cap_chan *, struct net_buf *); + void (* sent)(struct bt_l2cap_chan *); + void (* status)(struct bt_l2cap_chan *, atomic_t *); +}; + +struct bt_smp { + struct bt_l2cap_le_chan chan; + atomic_t allowed_cmds; + atomic_t flags[1]; + u8_t method; + u8_t preq[7]; + u8_t prsp[7]; + u8_t pcnf[16]; + u8_t prnd[16]; + u8_t rrnd[16]; + u8_t tk[16]; + u8_t pkey[64]; + u8_t dhkey[32]; + u8_t e[16]; + u8_t mackey[16]; + undefined field_0x16f; + u32_t.conflict passkey; + u8_t passkey_round; + undefined field_0x175; + undefined field_0x176; + undefined field_0x177; + struct bt_le_oob_sc_data * oobd_local; + struct bt_le_oob_sc_data * oobd_remote; + u8_t local_dist; + u8_t remote_dist; + undefined field_0x182; + undefined field_0x183; + struct k_delayed_work work; +}; + +typedef struct anon_struct.conflict510 anon_struct.conflict510, *Panon_struct.conflict510; + +struct anon_struct.conflict510 { + u8_t (* func)(struct bt_smp *, struct net_buf *); + u8_t expect_len; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef enum pairing_method { + JUST_WORKS=0, + LE_SC_OOB=5, + PASSKEY_CONFIRM=3, + PASSKEY_DISPLAY=2, + PASSKEY_INPUT=1, + PASSKEY_ROLE=4 +} pairing_method; + +typedef struct anon_struct.conflict508 anon_struct.conflict508, *Panon_struct.conflict508; + +struct anon_struct.conflict508 { + u8_t (* func)(struct bt_smp *, struct net_buf *); + u8_t expect_len; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict509 anon_struct.conflict509, *Panon_struct.conflict509; + +struct anon_struct.conflict509 { + u8_t (* func)(struct bt_smp *, struct net_buf *); + u8_t expect_len; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict511 anon_struct.conflict511, *Panon_struct.conflict511; + +struct anon_struct.conflict511 { + u8_t (* func)(struct bt_smp *, struct net_buf *); + u8_t expect_len; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct anon_struct_0 anon_struct_0, *Panon_struct_0; + +struct anon_struct_0 { + u32_t.conflict __v; +}; + +typedef struct anon_struct_for_rand anon_struct_for_rand, *Panon_struct_for_rand; + +struct anon_struct_for_rand { + u8_t key[16]; + u8_t rand[8]; + u8_t ediv[2]; +}; + +typedef struct bt_smp_pairing_random bt_smp_pairing_random, *Pbt_smp_pairing_random; + +struct bt_smp_pairing_random { + u8_t val[16]; +}; + +typedef struct bt_smp_pairing bt_smp_pairing, *Pbt_smp_pairing; + +struct bt_smp_pairing { + u8_t io_capability; + u8_t oob_flag; + u8_t auth_req; + u8_t max_key_size; + u8_t init_key_dist; + u8_t resp_key_dist; +}; + +typedef struct bt_smp_signing_info bt_smp_signing_info, *Pbt_smp_signing_info; + +struct bt_smp_signing_info { + u8_t csrk[16]; +}; + +typedef struct bt_smp_public_key bt_smp_public_key, *Pbt_smp_public_key; + +struct bt_smp_public_key { + u8_t x[32]; + u8_t y[32]; +}; + +typedef struct bt_smp_ident_info bt_smp_ident_info, *Pbt_smp_ident_info; + +struct bt_smp_ident_info { + u8_t irk[16]; +}; + +typedef struct bt_smp_master_ident bt_smp_master_ident, *Pbt_smp_master_ident; + +struct bt_smp_master_ident { + u8_t ediv[2]; + u8_t rand[8]; +}; + +typedef struct bt_smp_ident_addr_info bt_smp_ident_addr_info, *Pbt_smp_ident_addr_info; + +struct bt_smp_ident_addr_info { + struct bt_addr_le_t addr; +}; + +typedef struct bt_smp_pairing_fail bt_smp_pairing_fail, *Pbt_smp_pairing_fail; + +struct bt_smp_pairing_fail { + u8_t reason; +}; + +typedef struct bt_smp_dhkey_check bt_smp_dhkey_check, *Pbt_smp_dhkey_check; + +struct bt_smp_dhkey_check { + u8_t e[16]; +}; + +typedef struct bt_smp_security_request bt_smp_security_request, *Pbt_smp_security_request; + +struct bt_smp_security_request { + u8_t auth_req; +}; + +typedef struct bt_smp_hdr bt_smp_hdr, *Pbt_smp_hdr; + +struct bt_smp_hdr { + u8_t code; +}; + +typedef struct bt_smp_pairing_confirm bt_smp_pairing_confirm, *Pbt_smp_pairing_confirm; + +struct bt_smp_pairing_confirm { + u8_t val[16]; +}; + +typedef struct bt_smp_encrypt_info bt_smp_encrypt_info, *Pbt_smp_encrypt_info; + +struct bt_smp_encrypt_info { + u8_t ltk[16]; +}; + +typedef struct ip4_addr_packed ip4_addr_packed, *Pip4_addr_packed; + +struct ip4_addr_packed { + u32_t addr; +}; + +typedef struct ip_hdr ip_hdr, *Pip_hdr; + +typedef struct ip4_addr_packed ip4_addr_p_t; + +struct ip_hdr { + u8_t _v_hl; + u8_t _tos; + u16_t _len; + u16_t _id; + u16_t _offset; + u8_t _ttl; + u8_t _proto; + u16_t _chksum; + ip4_addr_p_t src; + ip4_addr_p_t dest; +}; + +typedef struct cfg_element_entry cfg_element_entry, *Pcfg_element_entry; + +typedef enum CFG_ELEMENT_TYPE_OPS { + CFG_ELEMENT_TYPE_OPS_DUMP_DEBUG=3, + CFG_ELEMENT_TYPE_OPS_GET=1, + CFG_ELEMENT_TYPE_OPS_RESET=2, + CFG_ELEMENT_TYPE_OPS_SET=0, + CFG_ELEMENT_TYPE_OPS_UNKNOWN=4 +} CFG_ELEMENT_TYPE_OPS; + +struct cfg_element_entry { + uint32_t task; + uint16_t element; + uint16_t type; + char * name; + void * val; + int (* set)(struct cfg_element_entry *, void *, void *); + int (* get)(struct cfg_element_entry *, void *, void *); + int (* notify)(struct cfg_element_entry *, void *, void *, enum CFG_ELEMENT_TYPE_OPS); +}; + +typedef struct tc_hmac_state_struct tc_hmac_state_struct, *Ptc_hmac_state_struct; + +typedef struct tc_sha256_state_struct tc_sha256_state_struct, *Ptc_sha256_state_struct; + +struct tc_sha256_state_struct { + uint iv[8]; + uint64_t bits_hashed; + uint8_t leftover[64]; + size_t leftover_offset; + undefined field_0x6c; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +struct tc_hmac_state_struct { + struct tc_sha256_state_struct hash_state; + uint8_t key[128]; +}; + +typedef struct bl_txhdr.conflict3 bl_txhdr.conflict3, *Pbl_txhdr.conflict3; + +typedef union bl_hw_txstatus.conflict5 bl_hw_txstatus.conflict5, *Pbl_hw_txstatus.conflict5; + +typedef struct hostdesc.conflict54 hostdesc.conflict54, *Phostdesc.conflict54; + +typedef struct anon_struct.conflict383 anon_struct.conflict383, *Panon_struct.conflict383; + +typedef struct mac_addr.conflict121 mac_addr.conflict121, *Pmac_addr.conflict121; + +typedef struct mac_addr.conflict122 mac_addr.conflict122, *Pmac_addr.conflict122; + +typedef uint32_t u32.conflict192; + +typedef uint32_t u32.conflict193; + +typedef uint32_t u32.conflict194; + +typedef uint32_t u32.conflict195; + +struct mac_addr.conflict122 { + u8_l array[6]; +}; + +struct mac_addr.conflict121 { + u8_l array[6]; +}; + +struct hostdesc.conflict54 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict121 eth_dest_addr; + struct mac_addr.conflict122 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct anon_struct.conflict383 { + u32.conflict192 tx_done:1; + u32.conflict193 retry_required:1; + u32.conflict194 sw_retry_required:1; + u32.conflict195 reserved:29; +}; + +union bl_hw_txstatus.conflict5 { + struct anon_struct.conflict383 field_0; + u32.conflict196 value; +}; + +struct bl_txhdr.conflict3 { + struct utils_list_hdr item; + union bl_hw_txstatus.conflict5 status; + uint32_t * p; + struct hostdesc.conflict54 host; +}; + +typedef struct bl_txhdr.conflict1 bl_txhdr.conflict1, *Pbl_txhdr.conflict1; + +typedef union bl_hw_txstatus.conflict2 bl_hw_txstatus.conflict2, *Pbl_hw_txstatus.conflict2; + +typedef struct hostdesc.conflict44 hostdesc.conflict44, *Phostdesc.conflict44; + +typedef struct anon_struct.conflict351 anon_struct.conflict351, *Panon_struct.conflict351; + +typedef struct mac_addr.conflict100 mac_addr.conflict100, *Pmac_addr.conflict100; + +typedef struct mac_addr.conflict101 mac_addr.conflict101, *Pmac_addr.conflict101; + +typedef uint32_t u32.conflict47; + +typedef uint32_t u32.conflict48; + +typedef uint32_t u32.conflict49; + +typedef uint32_t u32.conflict50; + +struct anon_struct.conflict351 { + u32.conflict47 tx_done:1; + u32.conflict48 retry_required:1; + u32.conflict49 sw_retry_required:1; + u32.conflict50 reserved:29; +}; + +union bl_hw_txstatus.conflict2 { + struct anon_struct.conflict351 field_0; + u32.conflict51 value; +}; + +struct mac_addr.conflict101 { + u8_l array[6]; +}; + +struct mac_addr.conflict100 { + u8_l array[6]; +}; + +struct hostdesc.conflict44 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict100 eth_dest_addr; + struct mac_addr.conflict101 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct bl_txhdr.conflict1 { + struct utils_list_hdr item; + union bl_hw_txstatus.conflict2 status; + uint32_t * p; + struct hostdesc.conflict44 host; +}; + +typedef struct bl_txhdr.conflict bl_txhdr.conflict, *Pbl_txhdr.conflict; + +typedef union bl_hw_txstatus.conflict1 bl_hw_txstatus.conflict1, *Pbl_hw_txstatus.conflict1; + +typedef struct hostdesc.conflict43 hostdesc.conflict43, *Phostdesc.conflict43; + +typedef struct anon_struct.conflict350 anon_struct.conflict350, *Panon_struct.conflict350; + +typedef struct mac_addr.conflict98 mac_addr.conflict98, *Pmac_addr.conflict98; + +typedef struct mac_addr.conflict99 mac_addr.conflict99, *Pmac_addr.conflict99; + +typedef uint32_t u32.conflict42; + +typedef uint32_t u32.conflict43; + +typedef uint32_t u32.conflict44; + +typedef uint32_t u32.conflict45; + +struct mac_addr.conflict98 { + u8_l array[6]; +}; + +struct mac_addr.conflict99 { + u8_l array[6]; +}; + +struct anon_struct.conflict350 { + u32.conflict42 tx_done:1; + u32.conflict43 retry_required:1; + u32.conflict44 sw_retry_required:1; + u32.conflict45 reserved:29; +}; + +union bl_hw_txstatus.conflict1 { + struct anon_struct.conflict350 field_0; + u32.conflict46 value; +}; + +struct hostdesc.conflict43 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict98 eth_dest_addr; + struct mac_addr.conflict99 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct bl_txhdr.conflict { + struct utils_list_hdr item; + union bl_hw_txstatus.conflict1 status; + uint32_t * p; + struct hostdesc.conflict43 host; +}; + +typedef struct bl_txhdr.conflict2 bl_txhdr.conflict2, *Pbl_txhdr.conflict2; + +typedef union bl_hw_txstatus.conflict4 bl_hw_txstatus.conflict4, *Pbl_hw_txstatus.conflict4; + +typedef struct hostdesc.conflict53 hostdesc.conflict53, *Phostdesc.conflict53; + +typedef struct anon_struct.conflict382 anon_struct.conflict382, *Panon_struct.conflict382; + +typedef struct mac_addr.conflict119 mac_addr.conflict119, *Pmac_addr.conflict119; + +typedef struct mac_addr.conflict120 mac_addr.conflict120, *Pmac_addr.conflict120; + +typedef uint32_t u32.conflict187; + +typedef uint32_t u32.conflict188; + +typedef uint32_t u32.conflict189; + +typedef uint32_t u32.conflict190; + +struct mac_addr.conflict119 { + u8_l array[6]; +}; + +struct mac_addr.conflict120 { + u8_l array[6]; +}; + +struct hostdesc.conflict53 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict119 eth_dest_addr; + struct mac_addr.conflict120 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct anon_struct.conflict382 { + u32.conflict187 tx_done:1; + u32.conflict188 retry_required:1; + u32.conflict189 sw_retry_required:1; + u32.conflict190 reserved:29; +}; + +union bl_hw_txstatus.conflict4 { + struct anon_struct.conflict382 field_0; + u32.conflict191 value; +}; + +struct bl_txhdr.conflict2 { + struct utils_list_hdr item; + union bl_hw_txstatus.conflict4 status; + uint32_t * p; + struct hostdesc.conflict53 host; +}; + +typedef struct bl_txhdr bl_txhdr, *Pbl_txhdr; + +typedef union bl_hw_txstatus.conflict bl_hw_txstatus.conflict, *Pbl_hw_txstatus.conflict; + +typedef struct hostdesc.conflict42 hostdesc.conflict42, *Phostdesc.conflict42; + +typedef struct anon_struct.conflict349 anon_struct.conflict349, *Panon_struct.conflict349; + +typedef struct mac_addr.conflict96 mac_addr.conflict96, *Pmac_addr.conflict96; + +typedef struct mac_addr.conflict97 mac_addr.conflict97, *Pmac_addr.conflict97; + +typedef uint32_t u32.conflict37; + +typedef uint32_t u32.conflict38; + +typedef uint32_t u32.conflict39; + +typedef uint32_t u32.conflict40; + +struct mac_addr.conflict96 { + u8_l array[6]; +}; + +struct mac_addr.conflict97 { + u8_l array[6]; +}; + +struct anon_struct.conflict349 { + u32.conflict37 tx_done:1; + u32.conflict38 retry_required:1; + u32.conflict39 sw_retry_required:1; + u32.conflict40 reserved:29; +}; + +union bl_hw_txstatus.conflict { + struct anon_struct.conflict349 field_0; + u32.conflict41 value; +}; + +struct hostdesc.conflict42 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict96 eth_dest_addr; + struct mac_addr.conflict97 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct bl_txhdr { + struct utils_list_hdr item; + union bl_hw_txstatus.conflict status; + uint32_t * p; + struct hostdesc.conflict42 host; +}; + +typedef struct scanu_raw_send_cfm scanu_raw_send_cfm, *Pscanu_raw_send_cfm; + +struct scanu_raw_send_cfm { + uint32_t status; +}; + +typedef struct scanu_raw_send_req scanu_raw_send_req, *Pscanu_raw_send_req; + +struct scanu_raw_send_req { + void * pkt; + uint32_t len; +}; + +typedef struct scanu_start_req scanu_start_req, *Pscanu_start_req; + +struct scanu_start_req { + struct scan_chan_tag chan[42]; + struct mac_ssid ssid[2]; + struct mac_addr bssid; + undefined field_0x146; + undefined field_0x147; + uint32_t add_ies; + uint16_t add_ie_len; + uint8_t vif_idx; + uint8_t chan_cnt; + uint8_t ssid_cnt; + _Bool no_cck; + undefined field_0x152; + undefined field_0x153; +}; + +typedef struct scanu_start_cfm scanu_start_cfm, *Pscanu_start_cfm; + +struct scanu_start_cfm { + uint8_t status; +}; + +typedef struct tcp_pcb_listen tcp_pcb_listen, *Ptcp_pcb_listen; + +typedef struct tcp_pcb tcp_pcb, *Ptcp_pcb; + +typedef err_t (* tcp_accept_fn)(void *, struct tcp_pcb *, err_t); + +typedef u16_t tcpflags_t; + +typedef short s16_t; + +typedef struct tcp_seg tcp_seg, *Ptcp_seg; + +typedef err_t (* tcp_connected_fn)(void *, struct tcp_pcb *, err_t); + +typedef struct tcp_hdr tcp_hdr, *Ptcp_hdr; + +struct tcp_hdr { + u16_t src; + u16_t dest; + u32_t seqno; + u32_t ackno; + u16_t _hdrlen_rsvd_flags; + u16_t wnd; + u16_t chksum; + u16_t urgp; +}; + +struct tcp_pcb_listen { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb_listen * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + tcp_accept_fn accept; +}; + +struct tcp_pcb { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +struct tcp_seg { + struct tcp_seg * next; + struct pbuf * p; + u16_t len; + u16_t chksum; + u8_t chksum_swapped; + u8_t flags; + undefined field_0xe; + undefined field_0xf; + struct tcp_hdr * tcphdr; +}; + +typedef uint32_t u32.conflict265; + +typedef struct netconn netconn, *Pnetconn; + +typedef enum netconn_evt { + NETCONN_EVT_ERROR=4, + NETCONN_EVT_RCVMINUS=1, + NETCONN_EVT_RCVPLUS=0, + NETCONN_EVT_SENDMINUS=3, + NETCONN_EVT_SENDPLUS=2 +} netconn_evt; + +typedef enum netconn_type { + NETCONN_INVALID=0, + NETCONN_RAW=64, + NETCONN_TCP=16, + NETCONN_UDP=32, + NETCONN_UDPLITE=33, + NETCONN_UDPNOCHKSUM=34 +} netconn_type; + +typedef enum netconn_state { + NETCONN_CLOSE=4, + NETCONN_CONNECT=3, + NETCONN_LISTEN=2, + NETCONN_NONE=0, + NETCONN_WRITE=1 +} netconn_state; + + +// WARNING! conflicting data type names: /DWARF/api.h/netconn/anon_union_for_pcb - /DWARF/bl_socket.h/connect_t/anon_union_for_pcb + +typedef SemaphoreHandle_t sys_sem_t; + +typedef QueueHandle_t sys_mbox_t; + +typedef struct api_msg api_msg, *Papi_msg; + +typedef union anon_union_for_msg anon_union_for_msg, *Panon_union_for_msg; + +typedef struct netbuf netbuf, *Pnetbuf; + +typedef struct anon_struct.conflict541 anon_struct.conflict541, *Panon_struct.conflict541; + +typedef struct anon_struct.conflict542 anon_struct.conflict542, *Panon_struct.conflict542; + +typedef struct anon_struct.conflict543 anon_struct.conflict543, *Panon_struct.conflict543; + +typedef struct anon_struct.conflict544 anon_struct.conflict544, *Panon_struct.conflict544; + +typedef struct anon_struct.conflict545 anon_struct.conflict545, *Panon_struct.conflict545; + +typedef struct anon_struct.conflict546 anon_struct.conflict546, *Panon_struct.conflict546; + +typedef struct anon_struct.conflict547 anon_struct.conflict547, *Panon_struct.conflict547; + +typedef struct netvector netvector, *Pnetvector; + +typedef enum netconn_igmp { + NETCONN_JOIN=0, + NETCONN_LEAVE=1 +} netconn_igmp; + +struct netvector { + void * ptr; + size_t len; +}; + +struct netbuf { + struct pbuf * p; + struct pbuf * ptr; + ip_addr_t addr; + u16_t port; + u8_t flags; + undefined field_0xf; + u16_t toport_chksum; + undefined field_0x12; + undefined field_0x13; +}; + +struct netconn { + enum netconn_type type; + enum netconn_state state; + undefined field_0x2; + undefined field_0x3; + union anon_union_for_pcb pcb; + err_t pending_err; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + sys_sem_t op_completed; + sys_mbox_t recvmbox; + sys_mbox_t acceptmbox; + int socket; + s32_t.conflict9 send_timeout; + u32_t recv_timeout; + u8_t flags; + undefined field_0x25; + undefined field_0x26; + undefined field_0x27; + struct api_msg * current_msg; + void (* callback)(struct netconn *, enum netconn_evt, u16_t); +}; + +struct anon_struct.conflict542 { + ip_addr_t * ipaddr; + u16_t port; + u8_t if_idx; + undefined field_0x7; +}; + +struct anon_struct.conflict546 { + u8_t shut; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + u32_t time_started; +}; + +struct anon_struct.conflict544 { + struct netvector * vector; + u16_t vector_cnt; + undefined field_0x6; + undefined field_0x7; + size_t vector_off; + size_t len; + size_t offset; + u8_t apiflags; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + u32_t time_started; +}; + +struct anon_struct.conflict547 { + ip_addr_t * multiaddr; + ip_addr_t * netif_addr; + u8_t if_idx; + enum netconn_igmp join_or_leave; + undefined field_0xa; + undefined field_0xb; +}; + +struct anon_struct.conflict545 { + size_t len; +}; + +struct anon_struct.conflict541 { + u8_t proto; +}; + +struct anon_struct.conflict543 { + ip_addr_t * ipaddr; + u16_t * port; + u8_t local; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +union anon_union_for_msg { + struct netbuf * b; + struct anon_struct.conflict541 n; + struct anon_struct.conflict542 bc; + struct anon_struct.conflict543 ad; + struct anon_struct.conflict544 w; + struct anon_struct.conflict545 r; + struct anon_struct.conflict546 sd; + struct anon_struct.conflict547 jl; +}; + +struct api_msg { + struct netconn * conn; + err_t err; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + union anon_union_for_msg msg; +}; + +typedef struct wifi_cipher_t.conflict26 wifi_cipher_t.conflict26, *Pwifi_cipher_t.conflict26; + +struct wifi_cipher_t.conflict26 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict24 wifi_cipher_t.conflict24, *Pwifi_cipher_t.conflict24; + +struct wifi_cipher_t.conflict24 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict25 wifi_cipher_t.conflict25, *Pwifi_cipher_t.conflict25; + +struct wifi_cipher_t.conflict25 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict22 wifi_cipher_t.conflict22, *Pwifi_cipher_t.conflict22; + +struct wifi_cipher_t.conflict22 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict20 wifi_cipher_t.conflict20, *Pwifi_cipher_t.conflict20; + +struct wifi_cipher_t.conflict20 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict21 wifi_cipher_t.conflict21, *Pwifi_cipher_t.conflict21; + +struct wifi_cipher_t.conflict21 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict15 wifi_cipher_t.conflict15, *Pwifi_cipher_t.conflict15; + +struct wifi_cipher_t.conflict15 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict16 wifi_cipher_t.conflict16, *Pwifi_cipher_t.conflict16; + +struct wifi_cipher_t.conflict16 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict14 wifi_cipher_t.conflict14, *Pwifi_cipher_t.conflict14; + +struct wifi_cipher_t.conflict14 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict11 wifi_cipher_t.conflict11, *Pwifi_cipher_t.conflict11; + +struct wifi_cipher_t.conflict11 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict12 wifi_cipher_t.conflict12, *Pwifi_cipher_t.conflict12; + +struct wifi_cipher_t.conflict12 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict10 wifi_cipher_t.conflict10, *Pwifi_cipher_t.conflict10; + +struct wifi_cipher_t.conflict10 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + + +// WARNING! conflicting data type names: /DWARF/_UNCATEGORIZED_/__locale_t - /xlocale.h/__locale_t + +typedef struct tcpip_callback_msg tcpip_callback_msg, *Ptcpip_callback_msg; + +struct tcpip_callback_msg { +}; + +typedef struct lwip_cyclic_timer.conflict17 lwip_cyclic_timer.conflict17, *Plwip_cyclic_timer.conflict17; + +struct lwip_cyclic_timer.conflict17 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct netif.conflict17 netif.conflict17, *Pnetif.conflict17; + +struct netif.conflict17 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict13 netif.conflict13, *Pnetif.conflict13; + +struct netif.conflict13 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict15 netif.conflict15, *Pnetif.conflict15; + +struct netif.conflict15 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict33 netif.conflict33, *Pnetif.conflict33; + +struct netif.conflict33 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict29 netif.conflict29, *Pnetif.conflict29; + +struct netif.conflict29 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict27 netif.conflict27, *Pnetif.conflict27; + +struct netif.conflict27 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict21 netif.conflict21, *Pnetif.conflict21; + +struct netif.conflict21 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict23 netif.conflict23, *Pnetif.conflict23; + +struct netif.conflict23 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct wlan_netif.conflict2 wlan_netif.conflict2, *Pwlan_netif.conflict2; + +typedef struct netif.conflict7 netif.conflict7, *Pnetif.conflict7; + +struct netif.conflict7 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict2 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict7 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict9 wlan_netif.conflict9, *Pwlan_netif.conflict9; + +struct wlan_netif.conflict9 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict15 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict7 wlan_netif.conflict7, *Pwlan_netif.conflict7; + +struct wlan_netif.conflict7 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict13 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict4 wlan_netif.conflict4, *Pwlan_netif.conflict4; + +typedef struct netif.conflict9 netif.conflict9, *Pnetif.conflict9; + +struct netif.conflict9 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict4 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict9 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct cm_ConnectionInfo cm_ConnectionInfo, *Pcm_ConnectionInfo; + +typedef struct supplicantData supplicantData, *PsupplicantData; + +typedef struct CommonMlmeData_t CommonMlmeData_t, *PCommonMlmeData_t; + +typedef union anon_union_for_specDat anon_union_for_specDat, *Panon_union_for_specDat; + +typedef struct customMIB_RSNStats_t customMIB_RSNStats_t, *PcustomMIB_RSNStats_t; + +typedef struct RSNConfig_t RSNConfig_t, *PRSNConfig_t; + +typedef struct keyMgmtInfoSta_t keyMgmtInfoSta_t, *PkeyMgmtInfoSta_t; + +typedef struct SecurityParams_t SecurityParams_t, *PSecurityParams_t; + +typedef struct apSpecificData_t apSpecificData_t, *PapSpecificData_t; + +typedef struct AkmSuite_t AkmSuite_t, *PAkmSuite_t; + +typedef struct MIC_Error_t MIC_Error_t, *PMIC_Error_t; + +typedef struct apInfo_t apInfo_t, *PapInfo_t; + +typedef struct BufferDesc BufferDesc, *PBufferDesc; + +typedef struct BufferDesc BufferDesc_t; + +typedef struct staData_t staData_t, *PstaData_t; + +typedef enum AkmType_e { + AKM_1X=1, + AKM_CCKM=99, + AKM_FT_1X=3, + AKM_FT_PSK=4, + AKM_NONE=0, + AKM_PSK=2, + AKM_RSN_MAX=6, + AKM_SHA256_1X=5, + AKM_SHA256_PSK=6, + AKM_SUITE_MAX=5, + AKM_TDLS=7, + AKM_WPA_MAX=2 +} AkmType_e; + +typedef enum AkmType_e AkmTypePacked_e; + +typedef enum MIC_Fail_State_e { + FIRST_MIC_FAIL_IN_60_SEC=1, + NO_MIC_FAILURE=0, + SECOND_MIC_FAIL_IN_60_SEC=2 +} MIC_Fail_State_e; + +typedef struct BssConfig_t BssConfig_t, *PBssConfig_t; + +typedef struct BssData_t BssData_t, *PBssData_t; + +typedef union anon_union_for_intf anon_union_for_intf, *Panon_union_for_intf; + +typedef struct _txQingInfo_t _txQingInfo_t, *P_txQingInfo_t; + +typedef struct _txQingInfo_t txQingInfo_t; + +typedef struct apKeyMgmtInfoSta_t apKeyMgmtInfoSta_t, *PapKeyMgmtInfoSta_t; + +typedef struct apRsnConfig_t apRsnConfig_t, *PapRsnConfig_t; + +typedef struct Operation_t Operation_t, *POperation_t; + +struct MIC_Error_t { + enum MIC_Fail_State_e status; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + BOOLEAN MICCounterMeasureEnabled; + UINT32 disableStaAsso; +}; + +struct SecurityParams_t { + struct SecurityMode_t wpaType; + struct Cipher_t mcstCipher; + struct Cipher_t ucstCipher; +}; + +struct apKeyMgmtInfoSta_t { + struct apKeyMgmtInfoStaRom_t rom; + UINT8 numHskTries; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + UINT32 counterLo; + UINT32 counterHi; + struct mm_timer_tag HskTimer; + UINT8 EAPOL_MIC_Key[16]; + UINT8 EAPOL_Encr_Key[16]; + UINT8 EAPOLProtoVersion; + UINT8 rsvd[3]; +}; + +struct customMIB_RSNStats_t { + UINT8 TKIPICVErrors; + UINT8 TKIPLocalMICFailures; + UINT8 TKIPCounterMeasuresInvoked; +}; + +struct _txQingInfo_t { + enum IEEEtypes_PwrMgmtMode_e mode; +}; + +struct staData_t { + txQingInfo_t pwrSaveInfo; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + struct apKeyMgmtInfoSta_t keyMgmtInfo; +}; + +struct Operation_t { + UINT16 keyExchange:1; + UINT16 authenticate:1; + UINT16 reserved:14; +}; + +struct apRsnConfig_t { + struct Cipher_t mcstCipher; + UINT8 mcstCipherCount; + struct Cipher_t wpaUcstCipher; + UINT8 wpaUcstCipherCount; + struct Cipher_t wpa2UcstCipher; + UINT8 wpa2UcstCipherCount; + UINT16 AuthKey; + UINT16 AuthKeyCount; + struct Operation_t Akmp; + UINT32 GrpReKeyTime; + UINT8 PSKPassPhrase[64]; + UINT8 PSKPassPhraseLen; + UINT8 PSKValue[32]; + UINT8 MaxPwsHskRetries; + UINT8 MaxGrpHskRetries; + undefined field_0x73; + UINT32 PwsHskTimeOut; + UINT32 GrpHskTimeOut; +}; + +struct CommonMlmeData_t { + IEEEtypes_SsId_t SsId; + IEEEtypes_Len_t SsIdLen; + IEEEtypes_DtimPeriod_t DtimPeriod; + IEEEtypes_BcnInterval_t BcnPeriod; + IEEEtypes_MacAddr_t BssId; + UINT16 RtsThresh; + UINT16 FragThresh; + UINT8 ShortRetryLim; + UINT8 LongRetryLim; + UINT8 MbssBcnIntFac; + UINT8 MbssCurBcnIntCnt; + UINT16 Reserved; +}; + +struct BssConfig_t { + UINT32 StaAgeOutTime; + UINT32 PsStaAgeOutTime; + struct apRsnConfig_t RsnConfig; + struct CommonMlmeData_t comData; +}; + +struct AkmSuite_t { + UINT8 akmOui[3]; + AkmTypePacked_e akmType; +}; + +struct apSpecificData_t { + struct apInfo_t * apInfo; + BufferDesc_t * apInfoBuffDesc; + struct ChanBandInfo_t chanBandInfo; + undefined field_0xa; + undefined field_0xb; + struct staData_t staData; +}; + +union anon_union_for_specDat { + struct apSpecificData_t apData; +}; + +struct BssData_t { + BOOLEAN updatePassPhrase; + struct mm_timer_tag apMicTimer; + struct KeyData_t grpKeyData; + UINT8 GNonce[32]; + UINT32 grpRekeyBcnCntConfigured; + UINT32 grpRekeyBcnCntRemaining; +}; + +struct apInfo_t { + struct BssConfig_t bssConfig; + struct BssData_t bssData; + UINT8 ApStop_Req_Pending; + undefined field_0x11d; + undefined field_0x11e; + undefined field_0x11f; +}; + +struct keyMgmtInfoSta_t { + UINT8 ANonce[32]; + UINT8 SNonce[32]; + UINT8 EAPOL_MIC_Key[16]; + UINT8 EAPOL_Encr_Key[16]; + UINT32 apCounterLo; + UINT32 apCounterHi; + UINT32 apCounterZeroDone; + UINT32 staCounterLo; + UINT32 staCounterHi; + BOOLEAN RSNDataTrafficEnabled; + BOOLEAN RSNSecured; + BOOLEAN pwkHandshakeComplete; + struct cipher_key_t * pRxDecryptKey; + struct KeyData_t PWKey; + struct KeyData_t GRKey; + struct KeyData_t newPWKey; + struct MIC_Error_t sta_MIC_Error; + struct mm_timer_tag rsnTimer; + struct cm_ConnectionInfo * connPtr; + struct KeyData_t IGtk; +}; + +struct RSNConfig_t { + UINT8 RSNEnabled:1; + UINT8 pmkidValid:1; + UINT8 rsnCapValid:1; + UINT8 grpMgmtCipherValid:1; + UINT8 rsvd:4; + struct SecurityMode_t wpaType; + struct Cipher_t mcstCipher; + struct Cipher_t ucstCipher; + struct AkmSuite_t AKM; + UINT8 PMKID[16]; + struct IEEEtypes_RSNCapability_t rsnCap; + struct Cipher_t grpMgmtCipher; +}; + +struct supplicantData { + BOOLEAN inUse; + struct IEEEtypes_SsIdElement_t hashSsId; + IEEEtypes_MacAddr_t localBssid; + IEEEtypes_MacAddr_t localStaAddr; + struct customMIB_RSNStats_t customMIB_RSNStats; + struct RSNConfig_t customMIB_RSNConfig; + undefined field_0x51; + undefined field_0x52; + undefined field_0x53; + struct keyMgmtInfoSta_t keyMgmtInfoSta; + struct SecurityParams_t currParams; +}; + +struct cm_ConnectionInfo { + UINT8 conType; + UINT8 staId; + UINT8 instNbr; + UINT8 gtkHwKeyId; + UINT8 ptkHwKeyId; + UINT8 mfpHwKeyId; + undefined field_0x6; + undefined field_0x7; + struct supplicantData * suppData; + struct CommonMlmeData_t comData; + IEEEtypes_MacAddr_t peerMacAddr; + IEEEtypes_MacAddr_t localMacAddr; + union anon_union_for_specDat specDat; + cipher_key_buf_t TxRxCipherKeyBuf; +}; + +union anon_union_for_intf { + uint32 Interface; +}; + +struct BufferDesc { + union anon_union_for_intf intf; + uint16 DataLen; + undefined field_0x6; + undefined field_0x7; + void * Buffer; +}; + +typedef uint32_t u32.conflict175; + +typedef struct txl_buffer_tag txl_buffer_tag, *Ptxl_buffer_tag; + +typedef struct txdesc txdesc, *Ptxdesc; + +typedef struct tx_pbd tx_pbd, *Ptx_pbd; + +typedef struct txl_buffer_control txl_buffer_control, *Ptxl_buffer_control; + +typedef struct umacdesc umacdesc, *Pumacdesc; + +typedef struct lmacdesc lmacdesc, *Plmacdesc; + +typedef struct tx_hw_desc tx_hw_desc, *Ptx_hw_desc; + +typedef struct tx_cfm_tag tx_cfm_tag, *Ptx_cfm_tag; + + +// WARNING! conflicting data type names: /DWARF/txl_buffer.h/txl_buffer_control/anon_union_for_field_0 - /DWARF/buf.h/net_buf/anon_union_for_field_0 + +typedef struct tx_agg_desc tx_agg_desc, *Ptx_agg_desc; + +typedef struct tx_hd tx_hd, *Ptx_hd; + + +// WARNING! conflicting data type names: /DWARF/hal_desc.h/tx_hd/anon_union_for_field_3 - /DWARF/gatt.h/bt_gatt_discover_params/anon_union_for_field_3 + + +// WARNING! conflicting data type names: /DWARF/hal_desc.h/tx_hd/anon_union_for_field_4 - /DWARF/buf.h/net_buf/anon_union_for_field_4 + + +// WARNING! conflicting data type names: /DWARF/hal_desc.h/tx_hd/anon_union_for_field_5 - /DWARF/wifi_mgmr.h/wlan_netif/anon_union_for_field_5 + +struct txl_buffer_control { + union anon_union_for_field_0 field_0; + uint32_t mac_control_info; + uint32_t phy_control_info; +}; + +struct tx_pbd { + uint32_t upatterntx; + uint32_t next; + uint32_t datastartptr; + uint32_t dataendptr; + uint32_t bufctrlinfo; +}; + +struct txl_buffer_tag { + uint32_t length; + uint32_t lenheader; + uint32_t lenpad; + uint32_t flags; + struct txl_buffer_tag * next; + struct txdesc * txdesc; + struct dma_desc dma_desc[1]; + struct dma_desc dma_desc_pat; + struct tx_pbd tbd; + struct tx_pbd tbd_body[8]; + uint8_t user_idx; + undefined field_0xed; + undefined field_0xee; + undefined field_0xef; + struct txl_buffer_control buffer_control; + struct tx_pbd tkip_mic_icv_pbd; + uint8_t tkip_mic_icv[12]; + uint32_t[0] payload; +}; + +struct tx_hd { + uint32_t upatterntx; + uint32_t nextfrmexseq_ptr; + uint32_t nextmpdudesc_ptr; + union anon_union_for_field_3 field_3; + union anon_union_for_field_4 field_4; + union anon_union_for_field_5 field_5; + uint32_t frmlen; + uint32_t frmlifetime; + uint32_t phyctrlinfo; + uint32_t policyentryaddr; + uint32_t optlen[3]; + uint32_t macctrlinfo1; + uint32_t macctrlinfo2; + uint32_t statinfo; + uint32_t mediumtimeused; +}; + +struct umacdesc { + struct txl_buffer_control * buf_control; + uint32_t buff_offset; + uint16_t payl_len; + uint8_t head_len; + uint8_t hdr_len_802_2; + uint8_t tail_len; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; +}; + +struct lmacdesc { + struct tx_agg_desc * agg_desc; + struct txl_buffer_tag * buffer; + struct tx_hw_desc * hw_desc; +}; + +struct tx_cfm_tag { + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + int8_t credits; + uint8_t ampdu_size; + uint8_t pad[2]; + uint32_t status; +}; + +struct tx_hw_desc { + struct tx_cfm_tag * cfm_ptr; + struct tx_hd thd; +}; + +struct txdesc { + struct co_list_hdr list_hdr; + struct hostdesc host; + struct umacdesc umac; + struct lmacdesc lmac; + struct tx_hw_desc hw_desc; + struct tx_cfm_tag hw_cfm; + uint32_t buf[128]; +}; + +struct tx_agg_desc { + uint8_t reserved; +}; + +typedef uint32_t u32.conflict202; + +typedef uint32_t u32.conflict203; + +typedef uint32_t u32.conflict204; + +typedef uint32_t u32.conflict205; + +typedef uint32_t u32.conflict206; + +typedef uint32_t u32.conflict207; + +typedef uint32_t u32.conflict208; + +typedef uint32_t u32.conflict209; + +typedef uint32_t u32.conflict200; + +typedef uint32_t u32.conflict201; + +typedef uint32_t u32.conflict213; + +typedef uint32_t u32.conflict214; + +typedef uint32_t u32.conflict215; + +typedef uint32_t u32.conflict216; + +typedef uint32_t u32.conflict217; + +typedef uint32_t u32.conflict218; + +typedef uint32_t u32.conflict219; + +typedef uint32_t u32.conflict210; + +typedef uint32_t u32.conflict211; + +typedef uint32_t u32.conflict212; + +typedef uint32_t u32.conflict246; + +typedef uint32_t u32.conflict247; + +typedef uint32_t u32.conflict248; + +typedef uint32_t u32.conflict249; + +typedef uint32_t u32.conflict240; + +typedef uint32_t u32.conflict241; + +typedef uint32_t u32.conflict242; + +typedef uint32_t u32.conflict243; + +typedef uint32_t u32.conflict244; + +typedef uint32_t u32.conflict245; + +typedef uint32_t u32.conflict257; + +typedef uint32_t u32.conflict258; + +typedef uint32_t u32.conflict259; + +typedef uint32_t u32.conflict250; + +typedef uint32_t u32.conflict251; + +typedef uint32_t u32.conflict252; + +typedef uint32_t u32.conflict253; + +typedef uint32_t u32.conflict254; + +typedef uint32_t u32.conflict255; + +typedef uint32_t u32.conflict256; + +typedef uint32_t u32.conflict224; + +typedef uint32_t u32.conflict225; + +typedef uint32_t u32.conflict226; + +typedef uint32_t u32.conflict227; + +typedef uint32_t u32.conflict228; + +typedef uint32_t u32.conflict229; + +typedef uint32_t u32.conflict220; + +typedef uint32_t u32.conflict221; + +typedef uint32_t u32.conflict222; + +typedef uint32_t u32.conflict223; + +typedef uint32_t u32.conflict235; + +typedef uint32_t u32.conflict236; + +typedef uint32_t u32.conflict237; + +typedef uint32_t u32.conflict238; + +typedef uint32_t u32.conflict239; + +typedef uint32_t u32.conflict230; + +typedef uint32_t u32.conflict231; + +typedef uint32_t u32.conflict232; + +typedef uint32_t u32.conflict233; + +typedef uint32_t u32.conflict234; + +typedef struct mac_addr.conflict161 mac_addr.conflict161, *Pmac_addr.conflict161; + +struct mac_addr.conflict161 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict163 mac_addr.conflict163, *Pmac_addr.conflict163; + +struct mac_addr.conflict163 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict169 mac_addr.conflict169, *Pmac_addr.conflict169; + +struct mac_addr.conflict169 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict165 mac_addr.conflict165, *Pmac_addr.conflict165; + +struct mac_addr.conflict165 { + u8_l array[6]; +}; + +typedef uint32_t u32.conflict176; + +typedef uint32_t u32.conflict170; + +typedef uint32_t u32.conflict171; + +typedef uint32_t u32.conflict169; + +typedef uint32_t u32.conflict161; + +typedef uint32_t u32.conflict162; + +typedef uint32_t u32.conflict163; + +typedef uint32_t u32.conflict164; + +typedef uint32_t u32.conflict165; + +typedef uint32_t u32.conflict166; + +typedef uint32_t u32.conflict167; + +typedef uint32_t u32.conflict168; + +typedef uint32_t u32.conflict180; + +typedef uint32_t u32.conflict181; + +typedef uint32_t u32.conflict182; + +typedef uint32_t u32.conflict172; + +typedef uint32_t u32.conflict174; + +typedef uint32_t u32.conflict178; + +typedef uint32_t u32.conflict179; + +typedef uint32_t u32.conflict147; + +typedef uint32_t u32.conflict148; + +typedef uint32_t u32.conflict149; + +typedef uint32_t u32.conflict140; + +typedef uint32_t u32.conflict141; + +typedef uint32_t u32.conflict142; + +typedef uint32_t u32.conflict143; + +typedef uint32_t u32.conflict144; + +typedef uint32_t u32.conflict145; + +typedef uint32_t u32.conflict146; + +typedef uint32_t u32.conflict160; + +typedef uint32_t u32.conflict158; + +typedef uint32_t u32.conflict159; + +typedef uint32_t u32.conflict150; + +typedef uint32_t u32.conflict151; + +typedef uint32_t u32.conflict152; + +typedef uint32_t u32.conflict153; + +typedef uint32_t u32.conflict154; + +typedef uint32_t u32.conflict155; + +typedef uint32_t u32.conflict156; + +typedef uint32_t u32.conflict157; + +typedef uint32_t u32.conflict183; + +typedef uint32_t u32.conflict184; + +typedef uint32_t u32.conflict185; + +typedef uint32_t u32.conflict197; + +typedef uint32_t u32.conflict198; + +typedef uint32_t u32.conflict199; + +typedef uint32_t u32.conflict16; + +typedef struct wlan_netif.conflict14 wlan_netif.conflict14, *Pwlan_netif.conflict14; + +struct wlan_netif.conflict14 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict21 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict11 wlan_netif.conflict11, *Pwlan_netif.conflict11; + +struct wlan_netif.conflict11 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict17 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict16 wlan_netif.conflict16, *Pwlan_netif.conflict16; + +struct wlan_netif.conflict16 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict23 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict19 wlan_netif.conflict19, *Pwlan_netif.conflict19; + +struct wlan_netif.conflict19 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict27 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict24 wlan_netif.conflict24, *Pwlan_netif.conflict24; + +struct wlan_netif.conflict24 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict33 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict21 wlan_netif.conflict21, *Pwlan_netif.conflict21; + +struct wlan_netif.conflict21 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict29 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef uint32_t u32.conflict260; + +typedef uint32_t u32.conflict261; + +typedef uint32_t u32.conflict262; + +typedef uint32_t u32.conflict264; + +typedef uint32_t u32.conflict266; + +typedef struct txdesc_host.conflict8 txdesc_host.conflict8, *Ptxdesc_host.conflict8; + +typedef struct hostdesc.conflict10 hostdesc.conflict10, *Phostdesc.conflict10; + +typedef struct mac_addr.conflict22 mac_addr.conflict22, *Pmac_addr.conflict22; + +typedef struct mac_addr.conflict23 mac_addr.conflict23, *Pmac_addr.conflict23; + +struct mac_addr.conflict22 { + u8_l array[6]; +}; + +struct mac_addr.conflict23 { + u8_l array[6]; +}; + +struct hostdesc.conflict10 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict22 eth_dest_addr; + struct mac_addr.conflict23 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict8 { + u32_l ready; + struct hostdesc.conflict10 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct wifi_cipher_t.conflict2 wifi_cipher_t.conflict2, *Pwifi_cipher_t.conflict2; + +struct wifi_cipher_t.conflict2 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict3 wifi_cipher_t.conflict3, *Pwifi_cipher_t.conflict3; + +struct wifi_cipher_t.conflict3 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict4 wifi_cipher_t.conflict4, *Pwifi_cipher_t.conflict4; + +struct wifi_cipher_t.conflict4 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict6 wifi_cipher_t.conflict6, *Pwifi_cipher_t.conflict6; + +struct wifi_cipher_t.conflict6 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict7 wifi_cipher_t.conflict7, *Pwifi_cipher_t.conflict7; + +struct wifi_cipher_t.conflict7 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict8 wifi_cipher_t.conflict8, *Pwifi_cipher_t.conflict8; + +struct wifi_cipher_t.conflict8 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct _reent _reent, *P_reent; + + +// WARNING! conflicting data type names: /DWARF/reent.h/__FILE - /stdio.h/__FILE + +typedef struct _Bigint _Bigint, *P_Bigint; + +typedef union anon_union_for__new anon_union_for__new, *Panon_union_for__new; + +typedef struct _atexit _atexit, *P_atexit; + +typedef struct _glue _glue, *P_glue; + +typedef ulong __ULong; + +typedef struct anon_struct anon_struct, *Panon_struct; + +typedef struct anon_struct.conflict anon_struct.conflict, *Panon_struct.conflict; + +typedef struct _on_exit_args _on_exit_args, *P_on_exit_args; + +typedef struct __tm __tm, *P__tm; + +typedef struct _rand48 _rand48, *P_rand48; + +struct __tm { + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + +struct _rand48 { + ushort _seed[3]; + ushort _mult[3]; + ushort _add; +}; + +struct anon_struct { + uint _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + undefined field_0x22; + undefined field_0x23; + struct __tm _localtime_buf; + int _gamma_signgam; + undefined field_0x4c; + undefined field_0x4d; + undefined field_0x4e; + undefined field_0x4f; + ulonglong _rand_next; + struct _rand48 _r48; + undefined field_0x66; + undefined field_0x67; + struct _mbstate_t _mblen_state; + struct _mbstate_t _mbtowc_state; + struct _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + struct _mbstate_t _mbrlen_state; + struct _mbstate_t _mbrtowc_state; + struct _mbstate_t _mbsrtowcs_state; + struct _mbstate_t _wcrtomb_state; + struct _mbstate_t _wcsrtombs_state; + int _h_errno; +}; + +struct anon_struct.conflict { + uchar * _nextf[30]; + uint _nmalloc[30]; +}; + +union anon_union_for__new { + struct anon_struct _reent; + struct anon_struct.conflict _unused; +}; + +struct _glue { + struct _glue * _next; + int _niobs; + __FILE * _iobs; +}; + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + __ULong _fntypes; + __ULong _is_cxa; +}; + +struct _atexit { + struct _atexit * _next; + int _ind; + void (* _fns[32])(void); + struct _on_exit_args _on_exit_args; +}; + +struct _reent { + int _errno; + __FILE * _stdin; + __FILE * _stdout; + __FILE * _stderr; + int _inc; + char _emergency[25]; + undefined field_0x2d; + undefined field_0x2e; + undefined field_0x2f; + int _unspecified_locale_info; + struct __locale_t * _locale; + int __sdidinit; + void (* __cleanup)(struct _reent *); + struct _Bigint * _result; + int _result_k; + struct _Bigint * _p5s; + struct _Bigint * * _freelist; + int _cvtlen; + char * _cvtbuf; + union anon_union_for__new _new; + struct _atexit * _atexit; + struct _atexit _atexit0; + void (** _sig_func)(int); + struct _glue __sglue; + __FILE __sf[3]; + undefined field_0x424; + undefined field_0x425; + undefined field_0x426; + undefined field_0x427; +}; + +struct _Bigint { + struct _Bigint * _next; + int _k; + int _maxwds; + int _sign; + int _wds; + __ULong _x[1]; +}; + +typedef uint32_t u32.conflict90; + +typedef uint32_t u32.conflict94; + +typedef uint32_t u32.conflict93; + +typedef uint32_t u32.conflict92; + +typedef uint32_t u32.conflict91; + +typedef uint32_t u32.conflict98; + +typedef uint32_t u32.conflict97; + +typedef uint32_t u32.conflict96; + +typedef uint32_t u32.conflict95; + +typedef uint32_t u32.conflict99; + +typedef uint32_t u32.conflict125; + +typedef uint32_t u32.conflict126; + +typedef uint32_t u32.conflict127; + +typedef uint32_t u32.conflict128; + +typedef uint32_t u32.conflict129; + +typedef uint32_t u32.conflict120; + +typedef uint32_t u32.conflict121; + +typedef uint32_t u32.conflict122; + +typedef uint32_t u32.conflict123; + +typedef uint32_t u32.conflict124; + +typedef uint32_t u32.conflict136; + +typedef uint32_t u32.conflict137; + +typedef uint32_t u32.conflict138; + +typedef uint32_t u32.conflict139; + +typedef uint32_t u32.conflict130; + +typedef uint32_t u32.conflict131; + +typedef uint32_t u32.conflict132; + +typedef uint32_t u32.conflict133; + +typedef uint32_t u32.conflict134; + +typedef uint32_t u32.conflict135; + +typedef uint32_t u32.conflict103; + +typedef uint32_t u32.conflict104; + +typedef uint32_t u32.conflict105; + +typedef uint32_t u32.conflict106; + +typedef uint32_t u32.conflict107; + +typedef uint32_t u32.conflict108; + +typedef uint32_t u32.conflict109; + +typedef uint32_t u32.conflict100; + +typedef uint32_t u32.conflict101; + +typedef uint32_t u32.conflict102; + +typedef uint32_t u32.conflict114; + +typedef uint32_t u32.conflict115; + +typedef uint32_t u32.conflict116; + +typedef uint32_t u32.conflict117; + +typedef uint32_t u32.conflict118; + +typedef uint32_t u32.conflict119; + +typedef uint32_t u32.conflict110; + +typedef uint32_t u32.conflict111; + +typedef uint32_t u32.conflict112; + +typedef uint32_t u32.conflict113; + +typedef uint32_t u32.conflict15; + +typedef uint32_t u32.conflict19; + +typedef uint32_t u32.conflict14; + +typedef uint32_t u32.conflict11; + +typedef uint32_t u32.conflict29; + +typedef uint32_t u32.conflict28; + +typedef uint32_t u32.conflict27; + +typedef uint32_t u32.conflict32; + +typedef uint32_t u32.conflict31; + +typedef uint32_t u32.conflict30; + +typedef uint32_t u32.conflict34; + +typedef uint32_t u32.conflict33; + +typedef uint32_t u32.conflict59; + +typedef uint32_t u32.conflict58; + +typedef uint32_t u32.conflict57; + +typedef uint32_t u32.conflict56; + +typedef uint32_t u32.conflict55; + +typedef uint32_t u32.conflict61; + +typedef uint32_t u32.conflict60; + +typedef uint32_t u32.conflict65; + +typedef uint32_t u32.conflict64; + +typedef uint32_t u32.conflict63; + +typedef uint32_t u32.conflict62; + +typedef uint32_t u32.conflict69; + +typedef uint32_t u32.conflict68; + +typedef uint32_t u32.conflict67; + +typedef uint32_t u32.conflict66; + +typedef uint32_t u32.conflict72; + +typedef uint32_t u32.conflict71; + +typedef uint32_t u32.conflict70; + +typedef uint32_t u32.conflict76; + +typedef uint32_t u32.conflict75; + +typedef uint32_t u32.conflict74; + +typedef uint32_t u32.conflict73; + +typedef uint32_t u32.conflict79; + +typedef uint32_t u32.conflict78; + +typedef uint32_t u32.conflict77; + +typedef uint32_t u32.conflict83; + +typedef uint32_t u32.conflict82; + +typedef uint32_t u32.conflict81; + +typedef uint32_t u32.conflict80; + +typedef uint32_t u32.conflict87; + +typedef uint32_t u32.conflict86; + +typedef uint32_t u32.conflict85; + +typedef uint32_t u32.conflict84; + +typedef uint32_t u32.conflict89; + +typedef uint32_t u32.conflict88; + +typedef struct mac_addr.conflict118 mac_addr.conflict118, *Pmac_addr.conflict118; + +struct mac_addr.conflict118 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict114 mac_addr.conflict114, *Pmac_addr.conflict114; + +struct mac_addr.conflict114 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict116 mac_addr.conflict116, *Pmac_addr.conflict116; + +struct mac_addr.conflict116 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict110 mac_addr.conflict110, *Pmac_addr.conflict110; + +struct mac_addr.conflict110 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict112 mac_addr.conflict112, *Pmac_addr.conflict112; + +struct mac_addr.conflict112 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict106 mac_addr.conflict106, *Pmac_addr.conflict106; + +struct mac_addr.conflict106 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict108 mac_addr.conflict108, *Pmac_addr.conflict108; + +struct mac_addr.conflict108 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict104 mac_addr.conflict104, *Pmac_addr.conflict104; + +struct mac_addr.conflict104 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict135 mac_addr.conflict135, *Pmac_addr.conflict135; + +struct mac_addr.conflict135 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict138 mac_addr.conflict138, *Pmac_addr.conflict138; + +struct mac_addr.conflict138 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict131 mac_addr.conflict131, *Pmac_addr.conflict131; + +struct mac_addr.conflict131 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict133 mac_addr.conflict133, *Pmac_addr.conflict133; + +struct mac_addr.conflict133 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict129 mac_addr.conflict129, *Pmac_addr.conflict129; + +struct mac_addr.conflict129 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict125 mac_addr.conflict125, *Pmac_addr.conflict125; + +struct mac_addr.conflict125 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict127 mac_addr.conflict127, *Pmac_addr.conflict127; + +struct mac_addr.conflict127 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict150 mac_addr.conflict150, *Pmac_addr.conflict150; + +struct mac_addr.conflict150 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict152 mac_addr.conflict152, *Pmac_addr.conflict152; + +struct mac_addr.conflict152 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict157 mac_addr.conflict157, *Pmac_addr.conflict157; + +struct mac_addr.conflict157 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict159 mac_addr.conflict159, *Pmac_addr.conflict159; + +struct mac_addr.conflict159 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict155 mac_addr.conflict155, *Pmac_addr.conflict155; + +struct mac_addr.conflict155 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict140 mac_addr.conflict140, *Pmac_addr.conflict140; + +struct mac_addr.conflict140 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict146 mac_addr.conflict146, *Pmac_addr.conflict146; + +struct mac_addr.conflict146 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict148 mac_addr.conflict148, *Pmac_addr.conflict148; + +struct mac_addr.conflict148 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict142 mac_addr.conflict142, *Pmac_addr.conflict142; + +struct mac_addr.conflict142 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict144 mac_addr.conflict144, *Pmac_addr.conflict144; + +struct mac_addr.conflict144 { + u8_l array[6]; +}; + +typedef struct mblock_free mblock_free, *Pmblock_free; + +struct mblock_free { + struct mblock_free * next; + uint32_t size; +}; + +typedef struct inode_t inode_t, *Pinode_t; + +typedef union inode_ops_t inode_ops_t, *Pinode_ops_t; + +typedef struct file_ops file_ops, *Pfile_ops; + +typedef struct file_t file_t, *Pfile_t; + +typedef struct pollfd pollfd, *Ppollfd; + +typedef struct file_ops file_ops_t; + +typedef struct fs_ops fs_ops, *Pfs_ops; + +typedef __off_t off_t; + + +// WARNING! conflicting data type names: /DWARF/stat.h/stat - /stat.h/stat + +typedef struct fs_ops fs_ops_t; + +struct file_ops { + int (* open)(struct inode_t *, struct file_t *); + int (* close)(struct file_t *); + ssize_t (* read)(struct file_t *, void *, size_t); + ssize_t (* write)(struct file_t *, void *, size_t); + int (* ioctl)(struct file_t *, int, ulong); + int (* poll)(struct file_t *, _Bool, void (* )(struct pollfd *, void *), struct pollfd *, void *); + int (* sync)(struct file_t *); +}; + +union inode_ops_t { + file_ops_t * i_ops; + fs_ops_t * i_fops; +}; + +struct inode_t { + union inode_ops_t ops; + void * i_arg; + char * i_name; + int i_flags; + uint8_t type; + uint8_t refs; + undefined field_0x12; + undefined field_0x13; +}; + +struct fs_ops { + int (* open)(struct file_t *, char *, int); + int (* close)(struct file_t *); + ssize_t (* read)(struct file_t *, char *, size_t); + ssize_t (* write)(struct file_t *, char *, size_t); + off_t (* lseek)(struct file_t *, off_t, int); + int (* sync)(struct file_t *); + int (* stat)(struct file_t *, char *, struct stat *); + int (* unlink)(struct file_t *, char *); + int (* rename)(struct file_t *, char *, char *); + aos_dir_t * (* opendir)(struct file_t *, char *); + aos_dirent_t * (* readdir)(struct file_t *, struct aos_dir_t *); + int (* closedir)(struct file_t *, struct aos_dir_t *); + int (* mkdir)(struct file_t *, char *); + int (* rmdir)(struct file_t *, char *); + void (* rewinddir)(struct file_t *, struct aos_dir_t *); + long (* telldir)(struct file_t *, struct aos_dir_t *); + void (* seekdir)(struct file_t *, struct aos_dir_t *, long); + int (* ioctl)(struct file_t *, int, ulong); + int (* statfs)(struct file_t *, char *, struct statfs *); + int (* access)(struct file_t *, char *, int); +}; + +struct pollfd { + int fd; + short events; + short revents; +}; + +struct file_t { + struct inode_t * node; + void * f_arg; + size_t offset; +}; + +typedef struct anon_struct.conflict139 anon_struct.conflict139, *Panon_struct.conflict139; + +struct anon_struct.conflict139 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct lwip_cyclic_timer.conflict3 lwip_cyclic_timer.conflict3, *Plwip_cyclic_timer.conflict3; + +struct lwip_cyclic_timer.conflict3 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef int32_t s32.conflict12; + +typedef int32_t s32.conflict11; + +typedef int32_t s32.conflict10; + +typedef struct mac_addr.conflict10 mac_addr.conflict10, *Pmac_addr.conflict10; + +struct mac_addr.conflict10 { + u8_l array[6]; +}; + +typedef struct anon_struct.conflict338 anon_struct.conflict338, *Panon_struct.conflict338; + +struct anon_struct.conflict338 { + __le16 capab_info; + __le16 status_code; + __le16 aid; + u8[0] variable; +}; + +typedef struct anon_struct.conflict339 anon_struct.conflict339, *Panon_struct.conflict339; + +struct anon_struct.conflict339 { + __le16 capab_info; + __le16 listen_interval; + u8 current_ap[6]; + u8[0] variable; +}; + +typedef uint8_t ke_state_t.conflict; + +typedef struct anon_struct.conflict340 anon_struct.conflict340, *Panon_struct.conflict340; + +struct anon_struct.conflict340 { + __le16 reason_code; +}; + +typedef struct anon_struct.conflict341 anon_struct.conflict341, *Panon_struct.conflict341; + +struct anon_struct.conflict341 { + __le64 timestamp; + __le16 beacon_int; + __le16 capab_info; + u8[0] variable; +}; + +typedef struct anon_struct.conflict342 anon_struct.conflict342, *Panon_struct.conflict342; + +struct anon_struct.conflict342 { + __le64 timestamp; + __le16 beacon_int; + __le16 capab_info; + u8[0] variable; +}; + +typedef struct anon_struct.conflict343 anon_struct.conflict343, *Panon_struct.conflict343; + +struct anon_struct.conflict343 { + u8 category; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + undefined field_0x4; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + undefined field_0x8; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + undefined field_0xc; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + undefined field_0x10; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + undefined field_0x18; + undefined field_0x19; +}; + +typedef struct mac_addr.conflict21 mac_addr.conflict21, *Pmac_addr.conflict21; + +struct mac_addr.conflict21 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict18 mac_addr.conflict18, *Pmac_addr.conflict18; + +struct mac_addr.conflict18 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict16 mac_addr.conflict16, *Pmac_addr.conflict16; + +struct mac_addr.conflict16 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict14 mac_addr.conflict14, *Pmac_addr.conflict14; + +struct mac_addr.conflict14 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict12 mac_addr.conflict12, *Pmac_addr.conflict12; + +struct mac_addr.conflict12 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict33 mac_addr.conflict33, *Pmac_addr.conflict33; + +struct mac_addr.conflict33 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict31 mac_addr.conflict31, *Pmac_addr.conflict31; + +struct mac_addr.conflict31 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict29 mac_addr.conflict29, *Pmac_addr.conflict29; + +struct mac_addr.conflict29 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict27 mac_addr.conflict27, *Pmac_addr.conflict27; + +struct mac_addr.conflict27 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict25 mac_addr.conflict25, *Pmac_addr.conflict25; + +struct mac_addr.conflict25 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict44 mac_addr.conflict44, *Pmac_addr.conflict44; + +struct mac_addr.conflict44 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict42 mac_addr.conflict42, *Pmac_addr.conflict42; + +struct mac_addr.conflict42 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict40 mac_addr.conflict40, *Pmac_addr.conflict40; + +struct mac_addr.conflict40 { + u8_l array[6]; +}; + +typedef struct anon_struct.conflict378 anon_struct.conflict378, *Panon_struct.conflict378; + +struct anon_struct.conflict378 { + u8 category; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + undefined field_0x4; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + undefined field_0x8; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + undefined field_0xc; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + undefined field_0x10; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + undefined field_0x18; + undefined field_0x19; +}; + +typedef struct mac_addr.conflict35 mac_addr.conflict35, *Pmac_addr.conflict35; + +struct mac_addr.conflict35 { + u8_l array[6]; +}; + +typedef struct ke_state_handler ke_state_handler, *Pke_state_handler; + +typedef struct ke_msg_handler ke_msg_handler, *Pke_msg_handler; + +typedef uint16_t ke_msg_id_t; + +struct ke_state_handler { + struct ke_msg_handler * msg_table; + uint16_t msg_cnt; + undefined field_0x6; + undefined field_0x7; +}; + +struct ke_msg_handler { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef int32_t s32.conflict3; + +typedef int32_t s32.conflict2; + +typedef int32_t s32.conflict5; + +typedef int32_t s32.conflict4; + +typedef int32_t s32.conflict1; + +typedef int32_t s32.conflict7; + +typedef int32_t s32.conflict6; + +typedef int32_t s32.conflict9; + +typedef int32_t s32.conflict8; + +typedef struct anon_struct.conflict323 anon_struct.conflict323, *Panon_struct.conflict323; + +struct anon_struct.conflict323 { + u8 category; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + undefined field_0x4; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + undefined field_0x8; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + undefined field_0xc; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + undefined field_0x10; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + undefined field_0x18; + undefined field_0x19; +}; + +typedef struct anon_struct.conflict328 anon_struct.conflict328, *Panon_struct.conflict328; + +struct anon_struct.conflict328 { + __le16 capab_info; + __le16 status_code; + __le16 aid; + u8[0] variable; +}; + +typedef struct mac_addr.conflict8 mac_addr.conflict8, *Pmac_addr.conflict8; + +struct mac_addr.conflict8 { + u8_l array[6]; +}; + +typedef struct anon_struct.conflict334 anon_struct.conflict334, *Panon_struct.conflict334; + +struct anon_struct.conflict334 { + __le16 auth_alg; + __le16 auth_transaction; + __le16 status_code; + u8[0] variable; +}; + +typedef struct mac_addr.conflict6 mac_addr.conflict6, *Pmac_addr.conflict6; + +struct mac_addr.conflict6 { + u8_l array[6]; +}; + +typedef struct anon_struct.conflict335 anon_struct.conflict335, *Panon_struct.conflict335; + +struct anon_struct.conflict335 { + __le16 reason_code; +}; + +typedef struct anon_struct.conflict336 anon_struct.conflict336, *Panon_struct.conflict336; + +struct anon_struct.conflict336 { + __le16 capab_info; + __le16 listen_interval; + u8[0] variable; +}; + +typedef struct mac_addr.conflict4 mac_addr.conflict4, *Pmac_addr.conflict4; + +struct mac_addr.conflict4 { + u8_l array[6]; +}; + +typedef struct anon_struct.conflict337 anon_struct.conflict337, *Panon_struct.conflict337; + +struct anon_struct.conflict337 { + __le16 capab_info; + __le16 status_code; + __le16 aid; + u8[0] variable; +}; + +typedef struct mac_addr.conflict2 mac_addr.conflict2, *Pmac_addr.conflict2; + +struct mac_addr.conflict2 { + u8_l array[6]; +}; + +typedef struct anon_struct.conflict333 anon_struct.conflict333, *Panon_struct.conflict333; + +struct anon_struct.conflict333 { + u8 category; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + undefined field_0x4; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + undefined field_0x8; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + undefined field_0xc; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + undefined field_0x10; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + undefined field_0x18; + undefined field_0x19; +}; + +typedef struct mac_addr.conflict95 mac_addr.conflict95, *Pmac_addr.conflict95; + +struct mac_addr.conflict95 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict93 mac_addr.conflict93, *Pmac_addr.conflict93; + +struct mac_addr.conflict93 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict91 mac_addr.conflict91, *Pmac_addr.conflict91; + +struct mac_addr.conflict91 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict89 mac_addr.conflict89, *Pmac_addr.conflict89; + +struct mac_addr.conflict89 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict54 mac_addr.conflict54, *Pmac_addr.conflict54; + +struct mac_addr.conflict54 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict52 mac_addr.conflict52, *Pmac_addr.conflict52; + +struct mac_addr.conflict52 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict50 mac_addr.conflict50, *Pmac_addr.conflict50; + +struct mac_addr.conflict50 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict48 mac_addr.conflict48, *Pmac_addr.conflict48; + +struct mac_addr.conflict48 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict46 mac_addr.conflict46, *Pmac_addr.conflict46; + +struct mac_addr.conflict46 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict66 mac_addr.conflict66, *Pmac_addr.conflict66; + +struct mac_addr.conflict66 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict64 mac_addr.conflict64, *Pmac_addr.conflict64; + +struct mac_addr.conflict64 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict62 mac_addr.conflict62, *Pmac_addr.conflict62; + +struct mac_addr.conflict62 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict60 mac_addr.conflict60, *Pmac_addr.conflict60; + +struct mac_addr.conflict60 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict74 mac_addr.conflict74, *Pmac_addr.conflict74; + +struct mac_addr.conflict74 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict72 mac_addr.conflict72, *Pmac_addr.conflict72; + +struct mac_addr.conflict72 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict70 mac_addr.conflict70, *Pmac_addr.conflict70; + +struct mac_addr.conflict70 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict68 mac_addr.conflict68, *Pmac_addr.conflict68; + +struct mac_addr.conflict68 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict87 mac_addr.conflict87, *Pmac_addr.conflict87; + +struct mac_addr.conflict87 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict85 mac_addr.conflict85, *Pmac_addr.conflict85; + +struct mac_addr.conflict85 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict83 mac_addr.conflict83, *Pmac_addr.conflict83; + +struct mac_addr.conflict83 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict81 mac_addr.conflict81, *Pmac_addr.conflict81; + +struct mac_addr.conflict81 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict79 mac_addr.conflict79, *Pmac_addr.conflict79; + +struct mac_addr.conflict79 { + u8_l array[6]; +}; + +typedef enum anon_enum_8_for_oob_config.conflict { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_oob_config.conflict; + +typedef enum anon_enum_8_for_oob_config { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_oob_config; + +typedef union anon_union_for_u.conflict anon_union_for_u.conflict, *Panon_union_for_u.conflict; + +union anon_union_for_u.conflict { + struct anon_struct.conflict333 wme_action; + struct anon_struct.conflict333 chan_switch; + struct anon_struct.conflict333 ext_chan_switch; + struct anon_struct.conflict333 measurement; + struct anon_struct.conflict333 addba_req; + struct anon_struct.conflict333 addba_resp; + struct anon_struct.conflict333 delba; + struct anon_struct.conflict333 self_prot; + struct anon_struct.conflict333 mesh_action; + struct anon_struct.conflict333 sa_query; + struct anon_struct.conflict333 ht_smps; + struct anon_struct.conflict333 ht_notify_cw; + struct anon_struct.conflict333 tdls_discover_resp; + struct anon_struct.conflict333 vht_opmode_notif; + struct anon_struct.conflict333 vht_group_notif; + struct anon_struct.conflict333 tpc_report; + struct anon_struct.conflict333 ftm; +}; + + +// WARNING! conflicting data type names: /DWARF/_UNCATEGORIZED_/anon_struct/anon_union_for_u - /DWARF/gatt.c/gatt_find_info_rsp/anon_union_for_u + +typedef union anon_union_for_u.conflict2 anon_union_for_u.conflict2, *Panon_union_for_u.conflict2; + +union anon_union_for_u.conflict2 { + struct anon_struct.conflict378 wme_action; + struct anon_struct.conflict378 chan_switch; + struct anon_struct.conflict378 ext_chan_switch; + struct anon_struct.conflict378 measurement; + struct anon_struct.conflict378 addba_req; + struct anon_struct.conflict378 addba_resp; + struct anon_struct.conflict378 delba; + struct anon_struct.conflict378 self_prot; + struct anon_struct.conflict378 mesh_action; + struct anon_struct.conflict378 sa_query; + struct anon_struct.conflict378 ht_smps; + struct anon_struct.conflict378 ht_notify_cw; + struct anon_struct.conflict378 tdls_discover_resp; + struct anon_struct.conflict378 vht_opmode_notif; + struct anon_struct.conflict378 vht_group_notif; + struct anon_struct.conflict378 tpc_report; + struct anon_struct.conflict378 ftm; +}; + +typedef union anon_union_for_u.conflict1 anon_union_for_u.conflict1, *Panon_union_for_u.conflict1; + +union anon_union_for_u.conflict1 { + struct anon_struct.conflict343 wme_action; + struct anon_struct.conflict343 chan_switch; + struct anon_struct.conflict343 ext_chan_switch; + struct anon_struct.conflict343 measurement; + struct anon_struct.conflict343 addba_req; + struct anon_struct.conflict343 addba_resp; + struct anon_struct.conflict343 delba; + struct anon_struct.conflict343 self_prot; + struct anon_struct.conflict343 mesh_action; + struct anon_struct.conflict343 sa_query; + struct anon_struct.conflict343 ht_smps; + struct anon_struct.conflict343 ht_notify_cw; + struct anon_struct.conflict343 tdls_discover_resp; + struct anon_struct.conflict343 vht_opmode_notif; + struct anon_struct.conflict343 vht_group_notif; + struct anon_struct.conflict343 tpc_report; + struct anon_struct.conflict343 ftm; +}; + +typedef enum anon_enum_8_for_oob_config.conflict5 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLACKLIST=2, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_AUTO_CONNECT=0, + BT_CONN_AUTO_FEATURE_EXCH=13, + BT_CONN_AUTO_PHY_COMPLETE=12, + BT_CONN_AUTO_PHY_UPDATE=7, + BT_CONN_AUTO_VERSION_INFO=14, + BT_CONN_BR_LEGACY_SECURE=1, + BT_CONN_BR_NOBOND=4, + BT_CONN_BR_PAIRING=3, + BT_CONN_BR_PAIRING_INITIATOR=5, + BT_CONN_CLEANUP=6, + BT_CONN_FORCE_PAIR=11, + BT_CONN_NUM_FLAGS=15, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_SLAVE_PARAM_L2CAP=10, + BT_CONN_SLAVE_PARAM_SET=9, + BT_CONN_SLAVE_PARAM_UPDATE=8, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_CONN_USER=2, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_EVENT_CMD_TX=0, + BT_EVENT_CONN_TX_QUEUE=1, + BT_GATT_DISCOVER_ATTRIBUTE=5, + BT_GATT_DISCOVER_CHARACTERISTIC=3, + BT_GATT_DISCOVER_DESCRIPTOR=4, + BT_GATT_DISCOVER_INCLUDE=2, + BT_GATT_DISCOVER_PRIMARY=0, + BT_GATT_DISCOVER_SECONDARY=1, + BT_GATT_ITER_CONTINUE=1, + BT_GATT_ITER_STOP=0, + BT_GATT_PERM_NONE=0, + BT_GATT_PERM_PREPARE_WRITE=64, + BT_GATT_PERM_READ=1, + BT_GATT_PERM_READ_AUTHEN=16, + BT_GATT_PERM_READ_ENCRYPT=4, + BT_GATT_PERM_WRITE=2, + BT_GATT_PERM_WRITE_AUTHEN=32, + BT_GATT_PERM_WRITE_ENCRYPT=8, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_HCI_ACL_DATA=1, + BT_HCI_CMD=0, + BT_HCI_CMD_CMP_EVT=2, + BT_HCI_CMD_STAT_EVT=3, + BT_HCI_EVT=5, + BT_HCI_LE_EVT=4, + BT_KEYS_ALL=63, + BT_KEYS_AUTHENTICATED=1, + BT_KEYS_DEBUG=2, + BT_KEYS_ID_PENDING_ADD=4, + BT_KEYS_ID_PENDING_DEL=8, + BT_KEYS_IRK=2, + BT_KEYS_LOCAL_CSRK=8, + BT_KEYS_LTK=4, + BT_KEYS_LTK_P256=32, + BT_KEYS_REMOTE_CSRK=16, + BT_KEYS_SC=16, + BT_KEYS_SLAVE_LTK=1, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_LE_SCAN_FILTER_DUPLICATE=1, + BT_LE_SCAN_FILTER_EXTENDED=4, + BT_LE_SCAN_FILTER_WHITELIST=2, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BT_QUIRK_NO_RESET=1, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + K_WORK_STATE_PENDING=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_ACTIVE=1, + LINK_INVALID=5, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_GATT_NONE=0, + MESH_GATT_PROV=1, + MESH_GATT_PROXY=2, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + NONE=0, + NOTIFY_INPUT_COMPLETE=4, + NUM_FLAGS=6, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PROV=3, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + REMOTE_PUB_KEY=0, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SC_INDICATE_PENDING=1, + SC_NUM_FLAGS=2, + SC_RANGE_CHANGED=0, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SMP_FLAG_BOND=12, + SMP_FLAG_BR_CONNECTED=17, + SMP_FLAG_BR_PAIR=18, + SMP_FLAG_CFM_DELAYED=0, + SMP_FLAG_CT2=19, + SMP_FLAG_DERIVE_LK=16, + SMP_FLAG_DHCHECK_WAIT=15, + SMP_FLAG_DHKEY_PENDING=7, + SMP_FLAG_DHKEY_SEND=8, + SMP_FLAG_DISPLAY=10, + SMP_FLAG_ENC_PENDING=1, + SMP_FLAG_KEYS_DISTR=2, + SMP_FLAG_OOB_PENDING=11, + SMP_FLAG_PAIRING=3, + SMP_FLAG_PKEY_SEND=6, + SMP_FLAG_SC=5, + SMP_FLAG_SC_DEBUG_KEY=13, + SMP_FLAG_SEC_REQ=14, + SMP_FLAG_TIMEOUT=4, + SMP_FLAG_USER=9, + SMP_NUM_FLAGS=20, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WAIT_NUMBER=2, + WAIT_STRING=3, + WHITELIST=1, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_oob_config.conflict5; + +typedef enum anon_enum_8_for_oob_config.conflict6 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + ATT_DISCONNECTED=2, + ATT_NUM_FLAGS=3, + ATT_PENDING_CFM=1, + ATT_PENDING_RSP=0, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLACKLIST=2, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_AUTO_CONNECT=0, + BT_CONN_AUTO_FEATURE_EXCH=13, + BT_CONN_AUTO_PHY_COMPLETE=12, + BT_CONN_AUTO_PHY_UPDATE=7, + BT_CONN_AUTO_VERSION_INFO=14, + BT_CONN_BR_LEGACY_SECURE=1, + BT_CONN_BR_NOBOND=4, + BT_CONN_BR_PAIRING=3, + BT_CONN_BR_PAIRING_INITIATOR=5, + BT_CONN_CLEANUP=6, + BT_CONN_FORCE_PAIR=11, + BT_CONN_NUM_FLAGS=15, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_SLAVE_PARAM_L2CAP=10, + BT_CONN_SLAVE_PARAM_SET=9, + BT_CONN_SLAVE_PARAM_UPDATE=8, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_CONN_USER=2, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_EVENT_CMD_TX=0, + BT_EVENT_CONN_TX_QUEUE=1, + BT_GATT_DISCOVER_ATTRIBUTE=5, + BT_GATT_DISCOVER_CHARACTERISTIC=3, + BT_GATT_DISCOVER_DESCRIPTOR=4, + BT_GATT_DISCOVER_INCLUDE=2, + BT_GATT_DISCOVER_PRIMARY=0, + BT_GATT_DISCOVER_SECONDARY=1, + BT_GATT_ITER_CONTINUE=1, + BT_GATT_ITER_STOP=0, + BT_GATT_PERM_NONE=0, + BT_GATT_PERM_PREPARE_WRITE=64, + BT_GATT_PERM_READ=1, + BT_GATT_PERM_READ_AUTHEN=16, + BT_GATT_PERM_READ_ENCRYPT=4, + BT_GATT_PERM_WRITE=2, + BT_GATT_PERM_WRITE_AUTHEN=32, + BT_GATT_PERM_WRITE_ENCRYPT=8, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_GATT_WRITE_FLAG_CMD=2, + BT_GATT_WRITE_FLAG_PREPARE=1, + BT_HCI_ACL_DATA=1, + BT_HCI_CMD=0, + BT_HCI_CMD_CMP_EVT=2, + BT_HCI_CMD_STAT_EVT=3, + BT_HCI_EVT=5, + BT_HCI_LE_EVT=4, + BT_KEYS_ALL=63, + BT_KEYS_AUTHENTICATED=1, + BT_KEYS_DEBUG=2, + BT_KEYS_ID_PENDING_ADD=4, + BT_KEYS_ID_PENDING_DEL=8, + BT_KEYS_IRK=2, + BT_KEYS_LOCAL_CSRK=8, + BT_KEYS_LTK=4, + BT_KEYS_LTK_P256=32, + BT_KEYS_REMOTE_CSRK=16, + BT_KEYS_SC=16, + BT_KEYS_SLAVE_LTK=1, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_LE_SCAN_FILTER_DUPLICATE=1, + BT_LE_SCAN_FILTER_EXTENDED=4, + BT_LE_SCAN_FILTER_WHITELIST=2, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BT_QUIRK_NO_RESET=1, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + K_WORK_STATE_PENDING=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_ACTIVE=1, + LINK_INVALID=5, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_GATT_NONE=0, + MESH_GATT_PROV=1, + MESH_GATT_PROXY=2, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + NONE=0, + NOTIFY_INPUT_COMPLETE=4, + NUM_FLAGS=6, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PROV=3, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + REMOTE_PUB_KEY=0, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SC_INDICATE_PENDING=1, + SC_NUM_FLAGS=2, + SC_RANGE_CHANGED=0, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SMP_FLAG_BOND=12, + SMP_FLAG_BR_CONNECTED=17, + SMP_FLAG_BR_PAIR=18, + SMP_FLAG_CFM_DELAYED=0, + SMP_FLAG_CT2=19, + SMP_FLAG_DERIVE_LK=16, + SMP_FLAG_DHCHECK_WAIT=15, + SMP_FLAG_DHKEY_PENDING=7, + SMP_FLAG_DHKEY_SEND=8, + SMP_FLAG_DISPLAY=10, + SMP_FLAG_ENC_PENDING=1, + SMP_FLAG_KEYS_DISTR=2, + SMP_FLAG_OOB_PENDING=11, + SMP_FLAG_PAIRING=3, + SMP_FLAG_PKEY_SEND=6, + SMP_FLAG_SC=5, + SMP_FLAG_SC_DEBUG_KEY=13, + SMP_FLAG_SEC_REQ=14, + SMP_FLAG_TIMEOUT=4, + SMP_FLAG_USER=9, + SMP_NUM_FLAGS=20, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WAIT_NUMBER=2, + WAIT_STRING=3, + WHITELIST=1, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_oob_config.conflict6; + +typedef enum anon_enum_8_for_oob_config.conflict3 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLACKLIST=2, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_AUTO_CONNECT=0, + BT_CONN_AUTO_FEATURE_EXCH=13, + BT_CONN_AUTO_PHY_COMPLETE=12, + BT_CONN_AUTO_PHY_UPDATE=7, + BT_CONN_AUTO_VERSION_INFO=14, + BT_CONN_BR_LEGACY_SECURE=1, + BT_CONN_BR_NOBOND=4, + BT_CONN_BR_PAIRING=3, + BT_CONN_BR_PAIRING_INITIATOR=5, + BT_CONN_CLEANUP=6, + BT_CONN_FORCE_PAIR=11, + BT_CONN_NUM_FLAGS=15, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_SLAVE_PARAM_L2CAP=10, + BT_CONN_SLAVE_PARAM_SET=9, + BT_CONN_SLAVE_PARAM_UPDATE=8, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_CONN_USER=2, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_EVENT_CMD_TX=0, + BT_EVENT_CONN_TX_QUEUE=1, + BT_GATT_DISCOVER_ATTRIBUTE=5, + BT_GATT_DISCOVER_CHARACTERISTIC=3, + BT_GATT_DISCOVER_DESCRIPTOR=4, + BT_GATT_DISCOVER_INCLUDE=2, + BT_GATT_DISCOVER_PRIMARY=0, + BT_GATT_DISCOVER_SECONDARY=1, + BT_GATT_ITER_CONTINUE=1, + BT_GATT_ITER_STOP=0, + BT_GATT_PERM_NONE=0, + BT_GATT_PERM_PREPARE_WRITE=64, + BT_GATT_PERM_READ=1, + BT_GATT_PERM_READ_AUTHEN=16, + BT_GATT_PERM_READ_ENCRYPT=4, + BT_GATT_PERM_WRITE=2, + BT_GATT_PERM_WRITE_AUTHEN=32, + BT_GATT_PERM_WRITE_ENCRYPT=8, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_HCI_ACL_DATA=1, + BT_HCI_CMD=0, + BT_HCI_CMD_CMP_EVT=2, + BT_HCI_CMD_STAT_EVT=3, + BT_HCI_EVT=5, + BT_HCI_LE_EVT=4, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_LE_SCAN_FILTER_DUPLICATE=1, + BT_LE_SCAN_FILTER_EXTENDED=4, + BT_LE_SCAN_FILTER_WHITELIST=2, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + K_WORK_STATE_PENDING=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_ACTIVE=1, + LINK_INVALID=5, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_GATT_NONE=0, + MESH_GATT_PROV=1, + MESH_GATT_PROXY=2, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + NONE=0, + NOTIFY_INPUT_COMPLETE=4, + NUM_FLAGS=6, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PROV=3, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + REMOTE_PUB_KEY=0, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SC_INDICATE_PENDING=1, + SC_NUM_FLAGS=2, + SC_RANGE_CHANGED=0, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WAIT_NUMBER=2, + WAIT_STRING=3, + WHITELIST=1, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_oob_config.conflict3; + +typedef enum anon_enum_8_for_oob_config.conflict4 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLACKLIST=2, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_AUTO_CONNECT=0, + BT_CONN_AUTO_FEATURE_EXCH=13, + BT_CONN_AUTO_PHY_COMPLETE=12, + BT_CONN_AUTO_PHY_UPDATE=7, + BT_CONN_AUTO_VERSION_INFO=14, + BT_CONN_BR_LEGACY_SECURE=1, + BT_CONN_BR_NOBOND=4, + BT_CONN_BR_PAIRING=3, + BT_CONN_BR_PAIRING_INITIATOR=5, + BT_CONN_CLEANUP=6, + BT_CONN_FORCE_PAIR=11, + BT_CONN_NUM_FLAGS=15, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_SLAVE_PARAM_L2CAP=10, + BT_CONN_SLAVE_PARAM_SET=9, + BT_CONN_SLAVE_PARAM_UPDATE=8, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_CONN_USER=2, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_EVENT_CMD_TX=0, + BT_EVENT_CONN_TX_QUEUE=1, + BT_GATT_DISCOVER_ATTRIBUTE=5, + BT_GATT_DISCOVER_CHARACTERISTIC=3, + BT_GATT_DISCOVER_DESCRIPTOR=4, + BT_GATT_DISCOVER_INCLUDE=2, + BT_GATT_DISCOVER_PRIMARY=0, + BT_GATT_DISCOVER_SECONDARY=1, + BT_GATT_ITER_CONTINUE=1, + BT_GATT_ITER_STOP=0, + BT_GATT_PERM_NONE=0, + BT_GATT_PERM_PREPARE_WRITE=64, + BT_GATT_PERM_READ=1, + BT_GATT_PERM_READ_AUTHEN=16, + BT_GATT_PERM_READ_ENCRYPT=4, + BT_GATT_PERM_WRITE=2, + BT_GATT_PERM_WRITE_AUTHEN=32, + BT_GATT_PERM_WRITE_ENCRYPT=8, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_HCI_ACL_DATA=1, + BT_HCI_CMD=0, + BT_HCI_CMD_CMP_EVT=2, + BT_HCI_CMD_STAT_EVT=3, + BT_HCI_EVT=5, + BT_HCI_LE_EVT=4, + BT_KEYS_ALL=63, + BT_KEYS_AUTHENTICATED=1, + BT_KEYS_DEBUG=2, + BT_KEYS_ID_PENDING_ADD=4, + BT_KEYS_ID_PENDING_DEL=8, + BT_KEYS_IRK=2, + BT_KEYS_LOCAL_CSRK=8, + BT_KEYS_LTK=4, + BT_KEYS_LTK_P256=32, + BT_KEYS_REMOTE_CSRK=16, + BT_KEYS_SC=16, + BT_KEYS_SLAVE_LTK=1, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_LE_SCAN_FILTER_DUPLICATE=1, + BT_LE_SCAN_FILTER_EXTENDED=4, + BT_LE_SCAN_FILTER_WHITELIST=2, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BT_QUIRK_NO_RESET=1, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + K_WORK_STATE_PENDING=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_ACTIVE=1, + LINK_INVALID=5, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_GATT_NONE=0, + MESH_GATT_PROV=1, + MESH_GATT_PROXY=2, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + NONE=0, + NOTIFY_INPUT_COMPLETE=4, + NUM_FLAGS=6, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PROV=3, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + REMOTE_PUB_KEY=0, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SC_INDICATE_PENDING=1, + SC_NUM_FLAGS=2, + SC_RANGE_CHANGED=0, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WAIT_NUMBER=2, + WAIT_STRING=3, + WHITELIST=1, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_oob_config.conflict4; + +typedef enum anon_enum_8_for_oob_config.conflict1 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLACKLIST=2, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_GATT_PERM_NONE=0, + BT_GATT_PERM_PREPARE_WRITE=64, + BT_GATT_PERM_READ=1, + BT_GATT_PERM_READ_AUTHEN=16, + BT_GATT_PERM_READ_ENCRYPT=4, + BT_GATT_PERM_WRITE=2, + BT_GATT_PERM_WRITE_AUTHEN=32, + BT_GATT_PERM_WRITE_ENCRYPT=8, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_HCI_ACL_DATA=1, + BT_HCI_CMD=0, + BT_HCI_CMD_CMP_EVT=2, + BT_HCI_CMD_STAT_EVT=3, + BT_HCI_EVT=5, + BT_HCI_LE_EVT=4, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + K_WORK_STATE_PENDING=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_ACTIVE=1, + LINK_INVALID=5, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_GATT_NONE=0, + MESH_GATT_PROV=1, + MESH_GATT_PROXY=2, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + NONE=0, + NOTIFY_INPUT_COMPLETE=4, + NUM_FLAGS=6, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PROV=3, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + REMOTE_PUB_KEY=0, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WAIT_NUMBER=2, + WAIT_STRING=3, + WHITELIST=1, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_oob_config.conflict1; + +typedef enum anon_enum_8_for_oob_config.conflict2 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLACKLIST=2, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_AUTO_CONNECT=0, + BT_CONN_AUTO_FEATURE_EXCH=13, + BT_CONN_AUTO_PHY_COMPLETE=12, + BT_CONN_AUTO_PHY_UPDATE=7, + BT_CONN_AUTO_VERSION_INFO=14, + BT_CONN_BR_LEGACY_SECURE=1, + BT_CONN_BR_NOBOND=4, + BT_CONN_BR_PAIRING=3, + BT_CONN_BR_PAIRING_INITIATOR=5, + BT_CONN_CLEANUP=6, + BT_CONN_FORCE_PAIR=11, + BT_CONN_NUM_FLAGS=15, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_SLAVE_PARAM_L2CAP=10, + BT_CONN_SLAVE_PARAM_SET=9, + BT_CONN_SLAVE_PARAM_UPDATE=8, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_CONN_USER=2, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_EVENT_CMD_TX=0, + BT_EVENT_CONN_TX_QUEUE=1, + BT_GATT_PERM_NONE=0, + BT_GATT_PERM_PREPARE_WRITE=64, + BT_GATT_PERM_READ=1, + BT_GATT_PERM_READ_AUTHEN=16, + BT_GATT_PERM_READ_ENCRYPT=4, + BT_GATT_PERM_WRITE=2, + BT_GATT_PERM_WRITE_AUTHEN=32, + BT_GATT_PERM_WRITE_ENCRYPT=8, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_HCI_ACL_DATA=1, + BT_HCI_CMD=0, + BT_HCI_CMD_CMP_EVT=2, + BT_HCI_CMD_STAT_EVT=3, + BT_HCI_EVT=5, + BT_HCI_LE_EVT=4, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + K_WORK_STATE_PENDING=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_ACTIVE=1, + LINK_INVALID=5, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_GATT_NONE=0, + MESH_GATT_PROV=1, + MESH_GATT_PROXY=2, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + NONE=0, + NOTIFY_INPUT_COMPLETE=4, + NUM_FLAGS=6, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PROV=3, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + REMOTE_PUB_KEY=0, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WAIT_NUMBER=2, + WAIT_STRING=3, + WHITELIST=1, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_oob_config.conflict2; + +typedef enum anon_enum_8_for_type.conflict6 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + ATT_DISCONNECTED=2, + ATT_NUM_FLAGS=3, + ATT_PENDING_CFM=1, + ATT_PENDING_RSP=0, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLACKLIST=2, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_AUTO_CONNECT=0, + BT_CONN_AUTO_FEATURE_EXCH=13, + BT_CONN_AUTO_PHY_COMPLETE=12, + BT_CONN_AUTO_PHY_UPDATE=7, + BT_CONN_AUTO_VERSION_INFO=14, + BT_CONN_BR_LEGACY_SECURE=1, + BT_CONN_BR_NOBOND=4, + BT_CONN_BR_PAIRING=3, + BT_CONN_BR_PAIRING_INITIATOR=5, + BT_CONN_CLEANUP=6, + BT_CONN_FORCE_PAIR=11, + BT_CONN_NUM_FLAGS=15, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_SLAVE_PARAM_L2CAP=10, + BT_CONN_SLAVE_PARAM_SET=9, + BT_CONN_SLAVE_PARAM_UPDATE=8, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_CONN_USER=2, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_EVENT_CMD_TX=0, + BT_EVENT_CONN_TX_QUEUE=1, + BT_GATT_DISCOVER_ATTRIBUTE=5, + BT_GATT_DISCOVER_CHARACTERISTIC=3, + BT_GATT_DISCOVER_DESCRIPTOR=4, + BT_GATT_DISCOVER_INCLUDE=2, + BT_GATT_DISCOVER_PRIMARY=0, + BT_GATT_DISCOVER_SECONDARY=1, + BT_GATT_ITER_CONTINUE=1, + BT_GATT_ITER_STOP=0, + BT_GATT_PERM_NONE=0, + BT_GATT_PERM_PREPARE_WRITE=64, + BT_GATT_PERM_READ=1, + BT_GATT_PERM_READ_AUTHEN=16, + BT_GATT_PERM_READ_ENCRYPT=4, + BT_GATT_PERM_WRITE=2, + BT_GATT_PERM_WRITE_AUTHEN=32, + BT_GATT_PERM_WRITE_ENCRYPT=8, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_GATT_WRITE_FLAG_CMD=2, + BT_GATT_WRITE_FLAG_PREPARE=1, + BT_HCI_ACL_DATA=1, + BT_HCI_CMD=0, + BT_HCI_CMD_CMP_EVT=2, + BT_HCI_CMD_STAT_EVT=3, + BT_HCI_EVT=5, + BT_HCI_LE_EVT=4, + BT_KEYS_ALL=63, + BT_KEYS_AUTHENTICATED=1, + BT_KEYS_DEBUG=2, + BT_KEYS_ID_PENDING_ADD=4, + BT_KEYS_ID_PENDING_DEL=8, + BT_KEYS_IRK=2, + BT_KEYS_LOCAL_CSRK=8, + BT_KEYS_LTK=4, + BT_KEYS_LTK_P256=32, + BT_KEYS_REMOTE_CSRK=16, + BT_KEYS_SC=16, + BT_KEYS_SLAVE_LTK=1, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_LE_SCAN_FILTER_DUPLICATE=1, + BT_LE_SCAN_FILTER_EXTENDED=4, + BT_LE_SCAN_FILTER_WHITELIST=2, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BT_QUIRK_NO_RESET=1, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + K_WORK_STATE_PENDING=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_ACTIVE=1, + LINK_INVALID=5, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_GATT_NONE=0, + MESH_GATT_PROV=1, + MESH_GATT_PROXY=2, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + NONE=0, + NOTIFY_INPUT_COMPLETE=4, + NUM_FLAGS=6, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PROV=3, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + REMOTE_PUB_KEY=0, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SC_INDICATE_PENDING=1, + SC_NUM_FLAGS=2, + SC_RANGE_CHANGED=0, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SMP_FLAG_BOND=12, + SMP_FLAG_BR_CONNECTED=17, + SMP_FLAG_BR_PAIR=18, + SMP_FLAG_CFM_DELAYED=0, + SMP_FLAG_CT2=19, + SMP_FLAG_DERIVE_LK=16, + SMP_FLAG_DHCHECK_WAIT=15, + SMP_FLAG_DHKEY_PENDING=7, + SMP_FLAG_DHKEY_SEND=8, + SMP_FLAG_DISPLAY=10, + SMP_FLAG_ENC_PENDING=1, + SMP_FLAG_KEYS_DISTR=2, + SMP_FLAG_OOB_PENDING=11, + SMP_FLAG_PAIRING=3, + SMP_FLAG_PKEY_SEND=6, + SMP_FLAG_SC=5, + SMP_FLAG_SC_DEBUG_KEY=13, + SMP_FLAG_SEC_REQ=14, + SMP_FLAG_TIMEOUT=4, + SMP_FLAG_USER=9, + SMP_NUM_FLAGS=20, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WAIT_NUMBER=2, + WAIT_STRING=3, + WHITELIST=1, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_type.conflict6; + +typedef enum anon_enum_8_for_type.conflict1 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLACKLIST=2, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_GATT_PERM_NONE=0, + BT_GATT_PERM_PREPARE_WRITE=64, + BT_GATT_PERM_READ=1, + BT_GATT_PERM_READ_AUTHEN=16, + BT_GATT_PERM_READ_ENCRYPT=4, + BT_GATT_PERM_WRITE=2, + BT_GATT_PERM_WRITE_AUTHEN=32, + BT_GATT_PERM_WRITE_ENCRYPT=8, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_HCI_ACL_DATA=1, + BT_HCI_CMD=0, + BT_HCI_CMD_CMP_EVT=2, + BT_HCI_CMD_STAT_EVT=3, + BT_HCI_EVT=5, + BT_HCI_LE_EVT=4, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + K_WORK_STATE_PENDING=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_ACTIVE=1, + LINK_INVALID=5, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_GATT_NONE=0, + MESH_GATT_PROV=1, + MESH_GATT_PROXY=2, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + NONE=0, + NOTIFY_INPUT_COMPLETE=4, + NUM_FLAGS=6, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PROV=3, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + REMOTE_PUB_KEY=0, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WAIT_NUMBER=2, + WAIT_STRING=3, + WHITELIST=1, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_type.conflict1; + +typedef enum anon_enum_8_for_type.conflict5 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLACKLIST=2, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_AUTO_CONNECT=0, + BT_CONN_AUTO_FEATURE_EXCH=13, + BT_CONN_AUTO_PHY_COMPLETE=12, + BT_CONN_AUTO_PHY_UPDATE=7, + BT_CONN_AUTO_VERSION_INFO=14, + BT_CONN_BR_LEGACY_SECURE=1, + BT_CONN_BR_NOBOND=4, + BT_CONN_BR_PAIRING=3, + BT_CONN_BR_PAIRING_INITIATOR=5, + BT_CONN_CLEANUP=6, + BT_CONN_FORCE_PAIR=11, + BT_CONN_NUM_FLAGS=15, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_SLAVE_PARAM_L2CAP=10, + BT_CONN_SLAVE_PARAM_SET=9, + BT_CONN_SLAVE_PARAM_UPDATE=8, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_CONN_USER=2, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_EVENT_CMD_TX=0, + BT_EVENT_CONN_TX_QUEUE=1, + BT_GATT_DISCOVER_ATTRIBUTE=5, + BT_GATT_DISCOVER_CHARACTERISTIC=3, + BT_GATT_DISCOVER_DESCRIPTOR=4, + BT_GATT_DISCOVER_INCLUDE=2, + BT_GATT_DISCOVER_PRIMARY=0, + BT_GATT_DISCOVER_SECONDARY=1, + BT_GATT_ITER_CONTINUE=1, + BT_GATT_ITER_STOP=0, + BT_GATT_PERM_NONE=0, + BT_GATT_PERM_PREPARE_WRITE=64, + BT_GATT_PERM_READ=1, + BT_GATT_PERM_READ_AUTHEN=16, + BT_GATT_PERM_READ_ENCRYPT=4, + BT_GATT_PERM_WRITE=2, + BT_GATT_PERM_WRITE_AUTHEN=32, + BT_GATT_PERM_WRITE_ENCRYPT=8, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_HCI_ACL_DATA=1, + BT_HCI_CMD=0, + BT_HCI_CMD_CMP_EVT=2, + BT_HCI_CMD_STAT_EVT=3, + BT_HCI_EVT=5, + BT_HCI_LE_EVT=4, + BT_KEYS_ALL=63, + BT_KEYS_AUTHENTICATED=1, + BT_KEYS_DEBUG=2, + BT_KEYS_ID_PENDING_ADD=4, + BT_KEYS_ID_PENDING_DEL=8, + BT_KEYS_IRK=2, + BT_KEYS_LOCAL_CSRK=8, + BT_KEYS_LTK=4, + BT_KEYS_LTK_P256=32, + BT_KEYS_REMOTE_CSRK=16, + BT_KEYS_SC=16, + BT_KEYS_SLAVE_LTK=1, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_LE_SCAN_FILTER_DUPLICATE=1, + BT_LE_SCAN_FILTER_EXTENDED=4, + BT_LE_SCAN_FILTER_WHITELIST=2, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BT_QUIRK_NO_RESET=1, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + K_WORK_STATE_PENDING=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_ACTIVE=1, + LINK_INVALID=5, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_GATT_NONE=0, + MESH_GATT_PROV=1, + MESH_GATT_PROXY=2, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + NONE=0, + NOTIFY_INPUT_COMPLETE=4, + NUM_FLAGS=6, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PROV=3, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + REMOTE_PUB_KEY=0, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SC_INDICATE_PENDING=1, + SC_NUM_FLAGS=2, + SC_RANGE_CHANGED=0, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SMP_FLAG_BOND=12, + SMP_FLAG_BR_CONNECTED=17, + SMP_FLAG_BR_PAIR=18, + SMP_FLAG_CFM_DELAYED=0, + SMP_FLAG_CT2=19, + SMP_FLAG_DERIVE_LK=16, + SMP_FLAG_DHCHECK_WAIT=15, + SMP_FLAG_DHKEY_PENDING=7, + SMP_FLAG_DHKEY_SEND=8, + SMP_FLAG_DISPLAY=10, + SMP_FLAG_ENC_PENDING=1, + SMP_FLAG_KEYS_DISTR=2, + SMP_FLAG_OOB_PENDING=11, + SMP_FLAG_PAIRING=3, + SMP_FLAG_PKEY_SEND=6, + SMP_FLAG_SC=5, + SMP_FLAG_SC_DEBUG_KEY=13, + SMP_FLAG_SEC_REQ=14, + SMP_FLAG_TIMEOUT=4, + SMP_FLAG_USER=9, + SMP_NUM_FLAGS=20, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WAIT_NUMBER=2, + WAIT_STRING=3, + WHITELIST=1, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_type.conflict5; + +typedef enum anon_enum_8_for_type.conflict4 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLACKLIST=2, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_AUTO_CONNECT=0, + BT_CONN_AUTO_FEATURE_EXCH=13, + BT_CONN_AUTO_PHY_COMPLETE=12, + BT_CONN_AUTO_PHY_UPDATE=7, + BT_CONN_AUTO_VERSION_INFO=14, + BT_CONN_BR_LEGACY_SECURE=1, + BT_CONN_BR_NOBOND=4, + BT_CONN_BR_PAIRING=3, + BT_CONN_BR_PAIRING_INITIATOR=5, + BT_CONN_CLEANUP=6, + BT_CONN_FORCE_PAIR=11, + BT_CONN_NUM_FLAGS=15, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_SLAVE_PARAM_L2CAP=10, + BT_CONN_SLAVE_PARAM_SET=9, + BT_CONN_SLAVE_PARAM_UPDATE=8, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_CONN_USER=2, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_EVENT_CMD_TX=0, + BT_EVENT_CONN_TX_QUEUE=1, + BT_GATT_DISCOVER_ATTRIBUTE=5, + BT_GATT_DISCOVER_CHARACTERISTIC=3, + BT_GATT_DISCOVER_DESCRIPTOR=4, + BT_GATT_DISCOVER_INCLUDE=2, + BT_GATT_DISCOVER_PRIMARY=0, + BT_GATT_DISCOVER_SECONDARY=1, + BT_GATT_ITER_CONTINUE=1, + BT_GATT_ITER_STOP=0, + BT_GATT_PERM_NONE=0, + BT_GATT_PERM_PREPARE_WRITE=64, + BT_GATT_PERM_READ=1, + BT_GATT_PERM_READ_AUTHEN=16, + BT_GATT_PERM_READ_ENCRYPT=4, + BT_GATT_PERM_WRITE=2, + BT_GATT_PERM_WRITE_AUTHEN=32, + BT_GATT_PERM_WRITE_ENCRYPT=8, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_HCI_ACL_DATA=1, + BT_HCI_CMD=0, + BT_HCI_CMD_CMP_EVT=2, + BT_HCI_CMD_STAT_EVT=3, + BT_HCI_EVT=5, + BT_HCI_LE_EVT=4, + BT_KEYS_ALL=63, + BT_KEYS_AUTHENTICATED=1, + BT_KEYS_DEBUG=2, + BT_KEYS_ID_PENDING_ADD=4, + BT_KEYS_ID_PENDING_DEL=8, + BT_KEYS_IRK=2, + BT_KEYS_LOCAL_CSRK=8, + BT_KEYS_LTK=4, + BT_KEYS_LTK_P256=32, + BT_KEYS_REMOTE_CSRK=16, + BT_KEYS_SC=16, + BT_KEYS_SLAVE_LTK=1, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_LE_SCAN_FILTER_DUPLICATE=1, + BT_LE_SCAN_FILTER_EXTENDED=4, + BT_LE_SCAN_FILTER_WHITELIST=2, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BT_QUIRK_NO_RESET=1, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + K_WORK_STATE_PENDING=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_ACTIVE=1, + LINK_INVALID=5, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_GATT_NONE=0, + MESH_GATT_PROV=1, + MESH_GATT_PROXY=2, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + NONE=0, + NOTIFY_INPUT_COMPLETE=4, + NUM_FLAGS=6, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PROV=3, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + REMOTE_PUB_KEY=0, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SC_INDICATE_PENDING=1, + SC_NUM_FLAGS=2, + SC_RANGE_CHANGED=0, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WAIT_NUMBER=2, + WAIT_STRING=3, + WHITELIST=1, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_type.conflict4; + +typedef enum anon_enum_8_for_type.conflict3 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLACKLIST=2, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_AUTO_CONNECT=0, + BT_CONN_AUTO_FEATURE_EXCH=13, + BT_CONN_AUTO_PHY_COMPLETE=12, + BT_CONN_AUTO_PHY_UPDATE=7, + BT_CONN_AUTO_VERSION_INFO=14, + BT_CONN_BR_LEGACY_SECURE=1, + BT_CONN_BR_NOBOND=4, + BT_CONN_BR_PAIRING=3, + BT_CONN_BR_PAIRING_INITIATOR=5, + BT_CONN_CLEANUP=6, + BT_CONN_FORCE_PAIR=11, + BT_CONN_NUM_FLAGS=15, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_SLAVE_PARAM_L2CAP=10, + BT_CONN_SLAVE_PARAM_SET=9, + BT_CONN_SLAVE_PARAM_UPDATE=8, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_CONN_USER=2, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_EVENT_CMD_TX=0, + BT_EVENT_CONN_TX_QUEUE=1, + BT_GATT_DISCOVER_ATTRIBUTE=5, + BT_GATT_DISCOVER_CHARACTERISTIC=3, + BT_GATT_DISCOVER_DESCRIPTOR=4, + BT_GATT_DISCOVER_INCLUDE=2, + BT_GATT_DISCOVER_PRIMARY=0, + BT_GATT_DISCOVER_SECONDARY=1, + BT_GATT_ITER_CONTINUE=1, + BT_GATT_ITER_STOP=0, + BT_GATT_PERM_NONE=0, + BT_GATT_PERM_PREPARE_WRITE=64, + BT_GATT_PERM_READ=1, + BT_GATT_PERM_READ_AUTHEN=16, + BT_GATT_PERM_READ_ENCRYPT=4, + BT_GATT_PERM_WRITE=2, + BT_GATT_PERM_WRITE_AUTHEN=32, + BT_GATT_PERM_WRITE_ENCRYPT=8, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_HCI_ACL_DATA=1, + BT_HCI_CMD=0, + BT_HCI_CMD_CMP_EVT=2, + BT_HCI_CMD_STAT_EVT=3, + BT_HCI_EVT=5, + BT_HCI_LE_EVT=4, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_LE_SCAN_FILTER_DUPLICATE=1, + BT_LE_SCAN_FILTER_EXTENDED=4, + BT_LE_SCAN_FILTER_WHITELIST=2, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + K_WORK_STATE_PENDING=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_ACTIVE=1, + LINK_INVALID=5, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_GATT_NONE=0, + MESH_GATT_PROV=1, + MESH_GATT_PROXY=2, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + NONE=0, + NOTIFY_INPUT_COMPLETE=4, + NUM_FLAGS=6, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PROV=3, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + REMOTE_PUB_KEY=0, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SC_INDICATE_PENDING=1, + SC_NUM_FLAGS=2, + SC_RANGE_CHANGED=0, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WAIT_NUMBER=2, + WAIT_STRING=3, + WHITELIST=1, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_type.conflict3; + +typedef enum anon_enum_8_for_type.conflict2 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLACKLIST=2, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_AUTO_CONNECT=0, + BT_CONN_AUTO_FEATURE_EXCH=13, + BT_CONN_AUTO_PHY_COMPLETE=12, + BT_CONN_AUTO_PHY_UPDATE=7, + BT_CONN_AUTO_VERSION_INFO=14, + BT_CONN_BR_LEGACY_SECURE=1, + BT_CONN_BR_NOBOND=4, + BT_CONN_BR_PAIRING=3, + BT_CONN_BR_PAIRING_INITIATOR=5, + BT_CONN_CLEANUP=6, + BT_CONN_FORCE_PAIR=11, + BT_CONN_NUM_FLAGS=15, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_SLAVE_PARAM_L2CAP=10, + BT_CONN_SLAVE_PARAM_SET=9, + BT_CONN_SLAVE_PARAM_UPDATE=8, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_CONN_USER=2, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_EVENT_CMD_TX=0, + BT_EVENT_CONN_TX_QUEUE=1, + BT_GATT_PERM_NONE=0, + BT_GATT_PERM_PREPARE_WRITE=64, + BT_GATT_PERM_READ=1, + BT_GATT_PERM_READ_AUTHEN=16, + BT_GATT_PERM_READ_ENCRYPT=4, + BT_GATT_PERM_WRITE=2, + BT_GATT_PERM_WRITE_AUTHEN=32, + BT_GATT_PERM_WRITE_ENCRYPT=8, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_HCI_ACL_DATA=1, + BT_HCI_CMD=0, + BT_HCI_CMD_CMP_EVT=2, + BT_HCI_CMD_STAT_EVT=3, + BT_HCI_EVT=5, + BT_HCI_LE_EVT=4, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + K_WORK_STATE_PENDING=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_ACTIVE=1, + LINK_INVALID=5, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_GATT_NONE=0, + MESH_GATT_PROV=1, + MESH_GATT_PROXY=2, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + NONE=0, + NOTIFY_INPUT_COMPLETE=4, + NUM_FLAGS=6, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PROV=3, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + REMOTE_PUB_KEY=0, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WAIT_NUMBER=2, + WAIT_STRING=3, + WHITELIST=1, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_type.conflict2; + +typedef union anon_union_for_field_1.conflict anon_union_for_field_1.conflict, *Panon_union_for_field_1.conflict; + +typedef struct anon_struct.conflict430 anon_struct.conflict430, *Panon_struct.conflict430; + +struct anon_struct.conflict430 { + enum anon_enum_8_for_oob_config.conflict oob_config; +}; + +union anon_union_for_field_1.conflict { + struct anon_struct.conflict430 lesc; +}; + +typedef enum anon_enum_8_for_type.conflict { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_type.conflict; + +typedef union anon_union_for_field_1.conflict6 anon_union_for_field_1.conflict6, *Panon_union_for_field_1.conflict6; + +typedef struct anon_struct.conflict525 anon_struct.conflict525, *Panon_struct.conflict525; + +struct anon_struct.conflict525 { + enum anon_enum_8_for_oob_config.conflict6 oob_config; +}; + +union anon_union_for_field_1.conflict6 { + struct anon_struct.conflict525 lesc; +}; + +typedef union anon_union_for_field_1.conflict5 anon_union_for_field_1.conflict5, *Panon_union_for_field_1.conflict5; + +typedef struct anon_struct.conflict513 anon_struct.conflict513, *Panon_struct.conflict513; + +struct anon_struct.conflict513 { + enum anon_enum_8_for_oob_config.conflict5 oob_config; +}; + +union anon_union_for_field_1.conflict5 { + struct anon_struct.conflict513 lesc; +}; + +typedef union anon_union_for_field_1.conflict2 anon_union_for_field_1.conflict2, *Panon_union_for_field_1.conflict2; + +typedef struct anon_struct.conflict494 anon_struct.conflict494, *Panon_struct.conflict494; + +struct anon_struct.conflict494 { + enum anon_enum_8_for_oob_config.conflict2 oob_config; +}; + +union anon_union_for_field_1.conflict2 { + struct anon_struct.conflict494 lesc; +}; + +typedef union anon_union_for_field_1.conflict1 anon_union_for_field_1.conflict1, *Panon_union_for_field_1.conflict1; + +typedef struct anon_struct.conflict492 anon_struct.conflict492, *Panon_struct.conflict492; + +struct anon_struct.conflict492 { + enum anon_enum_8_for_oob_config.conflict1 oob_config; +}; + +union anon_union_for_field_1.conflict1 { + struct anon_struct.conflict492 lesc; +}; + +typedef union anon_union_for_field_1.conflict4 anon_union_for_field_1.conflict4, *Panon_union_for_field_1.conflict4; + +typedef struct anon_struct.conflict506 anon_struct.conflict506, *Panon_struct.conflict506; + +struct anon_struct.conflict506 { + enum anon_enum_8_for_oob_config.conflict4 oob_config; +}; + +union anon_union_for_field_1.conflict4 { + struct anon_struct.conflict506 lesc; +}; + +typedef union anon_union_for_field_1.conflict3 anon_union_for_field_1.conflict3, *Panon_union_for_field_1.conflict3; + +typedef struct anon_struct.conflict504 anon_struct.conflict504, *Panon_struct.conflict504; + +struct anon_struct.conflict504 { + enum anon_enum_8_for_oob_config.conflict3 oob_config; +}; + +union anon_union_for_field_1.conflict3 { + struct anon_struct.conflict504 lesc; +}; + + +// WARNING! conflicting data type names: /DWARF/_UNCATEGORIZED_/ieee80211_mgmt/anon_union_for_u - /DWARF/gatt.c/gatt_find_info_rsp/anon_union_for_u + +typedef enum anon_enum_8_for_state.conflict2 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_state.conflict2; + +typedef enum anon_enum_8_for_state.conflict1 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_state.conflict1; + +typedef enum anon_enum_8_for_state.conflict { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_state.conflict; + +typedef enum anon_enum_8_for_state.conflict6 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLACKLIST=2, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_GATT_PERM_NONE=0, + BT_GATT_PERM_PREPARE_WRITE=64, + BT_GATT_PERM_READ=1, + BT_GATT_PERM_READ_AUTHEN=16, + BT_GATT_PERM_READ_ENCRYPT=4, + BT_GATT_PERM_WRITE=2, + BT_GATT_PERM_WRITE_AUTHEN=32, + BT_GATT_PERM_WRITE_ENCRYPT=8, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_ACTIVE=1, + LINK_INVALID=5, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_GATT_NONE=0, + MESH_GATT_PROV=1, + MESH_GATT_PROXY=2, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + NONE=0, + NOTIFY_INPUT_COMPLETE=4, + NUM_FLAGS=6, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PROV=3, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + REMOTE_PUB_KEY=0, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WAIT_NUMBER=2, + WAIT_STRING=3, + WHITELIST=1, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_state.conflict6; + +typedef enum anon_enum_8_for_state.conflict5 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_GATT_PERM_NONE=0, + BT_GATT_PERM_PREPARE_WRITE=64, + BT_GATT_PERM_READ=1, + BT_GATT_PERM_READ_AUTHEN=16, + BT_GATT_PERM_READ_ENCRYPT=4, + BT_GATT_PERM_WRITE=2, + BT_GATT_PERM_WRITE_AUTHEN=32, + BT_GATT_PERM_WRITE_ENCRYPT=8, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_ACTIVE=1, + LINK_INVALID=5, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + NOTIFY_INPUT_COMPLETE=4, + NUM_FLAGS=6, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + REMOTE_PUB_KEY=0, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WAIT_NUMBER=2, + WAIT_STRING=3, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_state.conflict5; + +typedef enum anon_enum_8_for_state.conflict4 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_state.conflict4; + +typedef enum anon_enum_8_for_state.conflict3 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_MESH_CFG_PENDING=12, + BT_MESH_FLAG_COUNT=14, + BT_MESH_HB_PUB_PENDING=11, + BT_MESH_IVU_INITIATOR=3, + BT_MESH_IVU_IN_PROGRESS=2, + BT_MESH_IVU_PENDING=5, + BT_MESH_IVU_TEST=4, + BT_MESH_IV_PENDING=9, + BT_MESH_KEYS_PENDING=7, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BT_MESH_MOD_PENDING=13, + BT_MESH_NET_PENDING=8, + BT_MESH_RPL_PENDING=6, + BT_MESH_SEQ_PENDING=10, + BT_MESH_SUSPENDED=1, + BT_MESH_VALID=0, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MESH_STATE_OFF=0, + MESH_STATE_ON=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_state.conflict3; + +typedef struct tmrTimerControl tmrTimerControl, *PtmrTimerControl; + +typedef struct tmrTimerControl * TimerHandle_t; + +typedef TimerHandle_t timer_cb_arg_t; + +struct tmrTimerControl { + char * pcTimerName; + ListItem_t xTimerListItem; + TickType_t xTimerPeriodInTicks; + void * pvTimerID; + void (* pxCallbackFunction)(TimerHandle_t); + UBaseType_t uxTimerNumber; + uint8_t ucStatus; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef TickType_t EventBits_t; + +typedef struct EventGroupDef_t EventGroupDef_t, *PEventGroupDef_t; + +typedef struct EventGroupDef_t * EventGroupHandle_t; + +struct EventGroupDef_t { + EventBits_t uxEventBits; + List_t xTasksWaitingForBits; + UBaseType_t uxEventGroupNumber; + uint8_t ucStaticallyAllocated; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +typedef ulonglong uintmax_t; + +typedef longlong intmax_t; + +typedef struct gethostbyname_r_helper gethostbyname_r_helper, *Pgethostbyname_r_helper; + +struct gethostbyname_r_helper { + ip_addr_t * addr_list[2]; + ip_addr_t addr; + char * aliases; +}; + +typedef struct addrinfo addrinfo, *Paddrinfo; + +typedef u32_t socklen_t; + +typedef struct sockaddr sockaddr, *Psockaddr; + +typedef u8_t sa_family_t; + +struct addrinfo { + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + socklen_t ai_addrlen; + struct sockaddr * ai_addr; + char * ai_canonname; + struct addrinfo * ai_next; +}; + +struct sockaddr { + u8_t sa_len; + sa_family_t sa_family; + char sa_data[14]; +}; + +typedef struct hostent hostent, *Phostent; + +struct hostent { + char * h_name; + char * * h_aliases; + int h_addrtype; + int h_length; + char * * h_addr_list; +}; + +typedef struct EventGroupDef_t EventGroup_t; + +typedef union anon_union.conflict11 anon_union.conflict11, *Panon_union.conflict11; + +union anon_union.conflict11 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict12 anon_union.conflict12, *Panon_union.conflict12; + +union anon_union.conflict12 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict13 anon_union.conflict13, *Panon_union.conflict13; + +union anon_union.conflict13 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict15 anon_union.conflict15, *Panon_union.conflict15; + +union anon_union.conflict15 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef struct anon_struct.conflict345 anon_struct.conflict345, *Panon_struct.conflict345; + +struct anon_struct.conflict345 { + u32.conflict27 tx_done:1; + u32.conflict28 retry_required:1; + u32.conflict29 sw_retry_required:1; + u32.conflict30 reserved:29; +}; + +typedef union anon_union.conflict16 anon_union.conflict16, *Panon_union.conflict16; + +union anon_union.conflict16 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef struct anon_struct.conflict346 anon_struct.conflict346, *Panon_struct.conflict346; + +struct anon_struct.conflict346 { + u32.conflict31 tx_done:1; + u32.conflict32 retry_required:1; + u32.conflict33 sw_retry_required:1; + u32.conflict34 reserved:29; +}; + +typedef union anon_union.conflict17 anon_union.conflict17, *Panon_union.conflict17; + +union anon_union.conflict17 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict19 anon_union.conflict19, *Panon_union.conflict19; + +union anon_union.conflict19 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict20 anon_union.conflict20, *Panon_union.conflict20; + +union anon_union.conflict20 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict21 anon_union.conflict21, *Panon_union.conflict21; + +union anon_union.conflict21 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict23 anon_union.conflict23, *Panon_union.conflict23; + +union anon_union.conflict23 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict24 anon_union.conflict24, *Panon_union.conflict24; + +union anon_union.conflict24 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict25 anon_union.conflict25, *Panon_union.conflict25; + +union anon_union.conflict25 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef struct rx_dmadesc rx_dmadesc, *Prx_dmadesc; + +typedef struct rx_hd rx_hd, *Prx_hd; + +typedef struct phy_channel_info phy_channel_info, *Pphy_channel_info; + +typedef struct rx_swdesc rx_swdesc, *Prx_swdesc; + +typedef struct rx_payloaddesc rx_payloaddesc, *Prx_payloaddesc; + +typedef struct rx_pbd rx_pbd, *Prx_pbd; + +struct rx_hd { + uint32_t upatternrx; + uint32_t next; + uint32_t first_pbd_ptr; + struct rx_swdesc * swdesc; + uint32_t datastartptr; + uint32_t dataendptr; + uint32_t headerctrlinfo; + uint16_t frmlen; + uint16_t ampdu_stat_info; + uint32_t tsflo; + uint32_t tsfhi; + uint32_t recvec1a; + uint32_t recvec1b; + uint32_t recvec1c; + uint32_t recvec1d; + uint32_t recvec2a; + uint32_t recvec2b; + uint32_t statinfo; +}; + +struct phy_channel_info { + uint32_t info1; + uint32_t info2; +}; + +struct rx_dmadesc { + struct rx_hd hd; + struct phy_channel_info phy_info; + uint32_t flags; + uint32_t pattern; + uint32_t payl_offset; + uint32_t reserved_pad[2]; + uint32_t use_in_tcpip; +}; + +struct rx_swdesc { + struct co_list_hdr list_hdr; + struct rx_dmadesc * dma_hdrdesc; + struct rx_payloaddesc * pd; + struct rx_pbd * last_pbd; + struct rx_pbd * spare_pbd; + uint32_t host_id; + uint32_t frame_len; + uint8_t status; + uint8_t pbd_count; + uint8_t use_in_tcpip; + undefined field_0x1f; +}; + +struct rx_pbd { + uint32_t upattern; + uint32_t next; + uint32_t datastartptr; + uint32_t dataendptr; + uint16_t bufstatinfo; + uint16_t reserved; +}; + +struct rx_payloaddesc { + struct rx_pbd pbd; + uint32_t pd_status; + uint32_t * buffer_rx; + void * pbuf_holder[6]; +}; + +typedef union anon_union.conflict30 anon_union.conflict30, *Panon_union.conflict30; + +union anon_union.conflict30 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict31 anon_union.conflict31, *Panon_union.conflict31; + +union anon_union.conflict31 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict32 anon_union.conflict32, *Panon_union.conflict32; + +union anon_union.conflict32 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict50 anon_union.conflict50, *Panon_union.conflict50; + +union anon_union.conflict50 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict40 anon_union.conflict40, *Panon_union.conflict40; + +union anon_union.conflict40 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict185 anon_union.conflict185, *Panon_union.conflict185; + +union anon_union.conflict185 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict41 anon_union.conflict41, *Panon_union.conflict41; + +union anon_union.conflict41 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict186 anon_union.conflict186, *Panon_union.conflict186; + +union anon_union.conflict186 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict42 anon_union.conflict42, *Panon_union.conflict42; + +union anon_union.conflict42 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict44 anon_union.conflict44, *Panon_union.conflict44; + +union anon_union.conflict44 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict45 anon_union.conflict45, *Panon_union.conflict45; + +union anon_union.conflict45 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict46 anon_union.conflict46, *Panon_union.conflict46; + +union anon_union.conflict46 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict187 anon_union.conflict187, *Panon_union.conflict187; + +union anon_union.conflict187 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union bl_hw_txstatus bl_hw_txstatus, *Pbl_hw_txstatus; + +union bl_hw_txstatus { + struct anon_struct.conflict346 field_0; + u32.conflict35 value; +}; + +typedef union anon_union.conflict180 anon_union.conflict180, *Panon_union.conflict180; + +union anon_union.conflict180 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict61 anon_union.conflict61, *Panon_union.conflict61; + +union anon_union.conflict61 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict51 anon_union.conflict51, *Panon_union.conflict51; + +union anon_union.conflict51 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict52 anon_union.conflict52, *Panon_union.conflict52; + +union anon_union.conflict52 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict172 anon_union.conflict172, *Panon_union.conflict172; + +union anon_union.conflict172 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict54 anon_union.conflict54, *Panon_union.conflict54; + +union anon_union.conflict54 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict173 anon_union.conflict173, *Panon_union.conflict173; + +union anon_union.conflict173 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict55 anon_union.conflict55, *Panon_union.conflict55; + +union anon_union.conflict55 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict178 anon_union.conflict178, *Panon_union.conflict178; + +union anon_union.conflict178 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict56 anon_union.conflict56, *Panon_union.conflict56; + +union anon_union.conflict56 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict179 anon_union.conflict179, *Panon_union.conflict179; + +union anon_union.conflict179 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict171 anon_union.conflict171, *Panon_union.conflict171; + +union anon_union.conflict171 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict70 anon_union.conflict70, *Panon_union.conflict70; + +union anon_union.conflict70 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict62 anon_union.conflict62, *Panon_union.conflict62; + +union anon_union.conflict62 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict63 anon_union.conflict63, *Panon_union.conflict63; + +union anon_union.conflict63 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict164 anon_union.conflict164, *Panon_union.conflict164; + +union anon_union.conflict164 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict68 anon_union.conflict68, *Panon_union.conflict68; + +union anon_union.conflict68 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict165 anon_union.conflict165, *Panon_union.conflict165; + +union anon_union.conflict165 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict69 anon_union.conflict69, *Panon_union.conflict69; + +union anon_union.conflict69 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict166 anon_union.conflict166, *Panon_union.conflict166; + +union anon_union.conflict166 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict158 anon_union.conflict158, *Panon_union.conflict158; + +union anon_union.conflict158 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict159 anon_union.conflict159, *Panon_union.conflict159; + +union anon_union.conflict159 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict82 anon_union.conflict82, *Panon_union.conflict82; + +union anon_union.conflict82 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict83 anon_union.conflict83, *Panon_union.conflict83; + +union anon_union.conflict83 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict152 anon_union.conflict152, *Panon_union.conflict152; + +union anon_union.conflict152 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict153 anon_union.conflict153, *Panon_union.conflict153; + +union anon_union.conflict153 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict75 anon_union.conflict75, *Panon_union.conflict75; + +union anon_union.conflict75 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict76 anon_union.conflict76, *Panon_union.conflict76; + +union anon_union.conflict76 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict77 anon_union.conflict77, *Panon_union.conflict77; + +union anon_union.conflict77 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict157 anon_union.conflict157, *Panon_union.conflict157; + +union anon_union.conflict157 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict154 anon_union.conflict154, *Panon_union.conflict154; + +union anon_union.conflict154 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict147 anon_union.conflict147, *Panon_union.conflict147; + +union anon_union.conflict147 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict90 anon_union.conflict90, *Panon_union.conflict90; + +union anon_union.conflict90 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict91 anon_union.conflict91, *Panon_union.conflict91; + +union anon_union.conflict91 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict84 anon_union.conflict84, *Panon_union.conflict84; + +union anon_union.conflict84 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict141 anon_union.conflict141, *Panon_union.conflict141; + +union anon_union.conflict141 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict142 anon_union.conflict142, *Panon_union.conflict142; + +union anon_union.conflict142 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict140 anon_union.conflict140, *Panon_union.conflict140; + +union anon_union.conflict140 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict145 anon_union.conflict145, *Panon_union.conflict145; + +union anon_union.conflict145 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict89 anon_union.conflict89, *Panon_union.conflict89; + +union anon_union.conflict89 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict146 anon_union.conflict146, *Panon_union.conflict146; + +union anon_union.conflict146 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict136 anon_union.conflict136, *Panon_union.conflict136; + +union anon_union.conflict136 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict137 anon_union.conflict137, *Panon_union.conflict137; + +union anon_union.conflict137 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union bl_hw_txstatus.conflict3 bl_hw_txstatus.conflict3, *Pbl_hw_txstatus.conflict3; + +typedef struct anon_struct.conflict381 anon_struct.conflict381, *Panon_struct.conflict381; + +struct anon_struct.conflict381 { + u32.conflict182 tx_done:1; + u32.conflict183 retry_required:1; + u32.conflict184 sw_retry_required:1; + u32.conflict185 reserved:29; +}; + +union bl_hw_txstatus.conflict3 { + struct anon_struct.conflict381 field_0; + u32.conflict186 value; +}; + +typedef union anon_union.conflict130 anon_union.conflict130, *Panon_union.conflict130; + +union anon_union.conflict130 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict96 anon_union.conflict96, *Panon_union.conflict96; + +union anon_union.conflict96 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict131 anon_union.conflict131, *Panon_union.conflict131; + +union anon_union.conflict131 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict97 anon_union.conflict97, *Panon_union.conflict97; + +union anon_union.conflict97 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict98 anon_union.conflict98, *Panon_union.conflict98; + +union anon_union.conflict98 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict135 anon_union.conflict135, *Panon_union.conflict135; + +union anon_union.conflict135 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict132 anon_union.conflict132, *Panon_union.conflict132; + +union anon_union.conflict132 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict127 anon_union.conflict127, *Panon_union.conflict127; + +union anon_union.conflict127 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict125 anon_union.conflict125, *Panon_union.conflict125; + +union anon_union.conflict125 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict126 anon_union.conflict126, *Panon_union.conflict126; + +union anon_union.conflict126 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict120 anon_union.conflict120, *Panon_union.conflict120; + +union anon_union.conflict120 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict118 anon_union.conflict118, *Panon_union.conflict118; + +union anon_union.conflict118 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef struct tx_policy_tbl tx_policy_tbl, *Ptx_policy_tbl; + +struct tx_policy_tbl { + uint32_t upatterntx; + uint32_t phycntrlinfo1; + uint32_t phycntrlinfo2; + uint32_t maccntrlinfo1; + uint32_t maccntrlinfo2; + uint32_t ratecntrlinfo[4]; + uint32_t powercntrlinfo[4]; +}; + +typedef union anon_union.conflict119 anon_union.conflict119, *Panon_union.conflict119; + +union anon_union.conflict119 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict112 anon_union.conflict112, *Panon_union.conflict112; + +union anon_union.conflict112 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict113 anon_union.conflict113, *Panon_union.conflict113; + +union anon_union.conflict113 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict111 anon_union.conflict111, *Panon_union.conflict111; + +union anon_union.conflict111 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict105 anon_union.conflict105, *Panon_union.conflict105; + +union anon_union.conflict105 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict103 anon_union.conflict103, *Panon_union.conflict103; + +union anon_union.conflict103 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict104 anon_union.conflict104, *Panon_union.conflict104; + +union anon_union.conflict104 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef struct anon_struct.conflict380 anon_struct.conflict380, *Panon_struct.conflict380; + +struct anon_struct.conflict380 { + u32.conflict178 tx_done:1; + u32.conflict179 retry_required:1; + u32.conflict180 sw_retry_required:1; + u32.conflict181 reserved:29; +}; + +typedef struct tx_compressed_policy_tbl tx_compressed_policy_tbl, *Ptx_compressed_policy_tbl; + +struct tx_compressed_policy_tbl { + uint32_t upatterntx; + uint32_t sec_user_control; +}; + +typedef enum PtTable_ID_Type { + PT_TABLE_ID_0=0, + PT_TABLE_ID_1=1, + PT_TABLE_ID_INVALID=2 +} PtTable_ID_Type; + +typedef struct PtTable_Entry_Config PtTable_Entry_Config, *PPtTable_Entry_Config; + +struct PtTable_Entry_Config { + uint8_t type; + uint8_t device; + uint8_t activeIndex; + uint8_t name[9]; + uint32_t Address[2]; + uint32_t maxLen[2]; + uint32_t len; + uint32_t age; +}; + +typedef struct PtTable_Stuff_Config PtTable_Stuff_Config, *PPtTable_Stuff_Config; + +typedef struct PtTable_Config PtTable_Config, *PPtTable_Config; + +struct PtTable_Config { + uint32_t magicCode; + uint16_t version; + uint16_t entryCnt; + uint32_t age; + uint32_t crc32; +}; + +struct PtTable_Stuff_Config { + struct PtTable_Config ptTable; + struct PtTable_Entry_Config ptEntries[16]; + uint32_t crc32; +}; + +typedef enum PtTable_Error_Type { + PT_ERROR_CRC32=4, + PT_ERROR_ENTRY_NOT_FOUND=2, + PT_ERROR_ENTRY_UPDATE_FAIL=3, + PT_ERROR_FALSH_ERASE=8, + PT_ERROR_FALSH_READ=6, + PT_ERROR_FALSH_WRITE=7, + PT_ERROR_PARAMETER=5, + PT_ERROR_SUCCESS=0, + PT_ERROR_TABLE_NOT_VALID=1 +} PtTable_Error_Type; + +typedef enum PtTable_Entry_Type { + PT_ENTRY_FW_CPU0=0, + PT_ENTRY_FW_CPU1=1, + PT_ENTRY_MAX=16 +} PtTable_Entry_Type; + +typedef enum _blog_leve { + BLOG_LEVEL_ALL=0, + BLOG_LEVEL_ASSERT=5, + BLOG_LEVEL_DEBUG=1, + BLOG_LEVEL_ERROR=4, + BLOG_LEVEL_INFO=2, + BLOG_LEVEL_NEVER=6, + BLOG_LEVEL_WARN=3 +} _blog_leve; + +typedef enum _blog_leve blog_level_t; + +typedef struct _blog_info _blog_info, *P_blog_info; + +typedef struct _blog_info blog_info_t; + +struct _blog_info { + blog_level_t * level; + char * name; +}; + +typedef struct netconn.conflict netconn.conflict, *Pnetconn.conflict; + +struct netconn.conflict { + enum netconn_type type; + enum netconn_state state; + undefined field_0x2; + undefined field_0x3; + union anon_union_for_pcb pcb; + err_t pending_err; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + sys_sem_t op_completed; + sys_mbox_t recvmbox; + sys_mbox_t acceptmbox; + int socket; + s32_t.conflict2 send_timeout; + u32_t recv_timeout; + u8_t flags; + undefined field_0x25; + undefined field_0x26; + undefined field_0x27; + struct api_msg * current_msg; + void (* callback)(struct netconn *, enum netconn_evt, u16_t); +}; + +typedef struct netconn.conflict1 netconn.conflict1, *Pnetconn.conflict1; + +struct netconn.conflict1 { + enum netconn_type type; + enum netconn_state state; + undefined field_0x2; + undefined field_0x3; + union anon_union_for_pcb pcb; + err_t pending_err; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + sys_sem_t op_completed; + sys_mbox_t recvmbox; + sys_mbox_t acceptmbox; + int socket; + s32_t.conflict7 send_timeout; + u32_t recv_timeout; + u8_t flags; + undefined field_0x25; + undefined field_0x26; + undefined field_0x27; + struct api_msg * current_msg; + void (* callback)(struct netconn *, enum netconn_evt, u16_t); +}; + +typedef struct Efuse_Ana_RC32M_Trim_Type Efuse_Ana_RC32M_Trim_Type, *PEfuse_Ana_RC32M_Trim_Type; + +struct Efuse_Ana_RC32M_Trim_Type { + uint32_t trimRc32mCodeFrExt:8; + uint32_t trimRc32mCodeFrExtParity:1; + uint32_t trimRc32mExtCodeEn:1; + uint32_t reserved:22; +}; + +typedef struct Efuse_Ana_RC32K_Trim_Type Efuse_Ana_RC32K_Trim_Type, *PEfuse_Ana_RC32K_Trim_Type; + +struct Efuse_Ana_RC32K_Trim_Type { + uint32_t trimRc32kCodeFrExt:10; + uint32_t trimRc32kCodeFrExtParity:1; + uint32_t trimRc32kExtCodeEn:1; + uint32_t reserved:20; +}; + +typedef struct Efuse_Capcode_Info_Type Efuse_Capcode_Info_Type, *PEfuse_Capcode_Info_Type; + +struct Efuse_Capcode_Info_Type { + uint32_t capCode:6; + uint32_t parity:1; + uint32_t en:1; + uint32_t rsvd:24; +}; + +typedef enum EF_Ctrl_Sign_Type { + EF_CTRL_SIGN_ECC=2, + EF_CTRL_SIGN_NONE=0, + EF_CTRL_SIGN_RSA=1 +} EF_Ctrl_Sign_Type; + +typedef struct Efuse_Device_Info_Type Efuse_Device_Info_Type, *PEfuse_Device_Info_Type; + +struct Efuse_Device_Info_Type { + uint32_t rsvd:22; + uint32_t customerID:2; + uint32_t rsvd_info:3; + uint32_t memoryInfo:2; + uint32_t coreInfo:1; + uint32_t mcuInfo:1; + uint32_t pinInfo:1; +}; + +typedef struct Efuse_TSEN_Refcode_Corner_Type Efuse_TSEN_Refcode_Corner_Type, *PEfuse_TSEN_Refcode_Corner_Type; + +struct Efuse_TSEN_Refcode_Corner_Type { + uint32_t tsenRefcodeCorner:12; + uint32_t tsenRefcodeCornerParity:1; + uint32_t tsenRefcodeCornerEn:1; + uint32_t tsenRefcodeCornerVersion:1; + uint32_t reserved:17; +}; + +typedef enum EF_Ctrl_SF_AES_Type { + EF_CTRL_SF_AES_128=1, + EF_CTRL_SF_AES_192=2, + EF_CTRL_SF_AES_256=3, + EF_CTRL_SF_AES_NONE=0 +} EF_Ctrl_SF_AES_Type; + +typedef struct Efuse_ADC_Gain_Coeff_Type Efuse_ADC_Gain_Coeff_Type, *PEfuse_ADC_Gain_Coeff_Type; + +struct Efuse_ADC_Gain_Coeff_Type { + uint32_t adcGainCoeff:12; + uint32_t adcGainCoeffParity:1; + uint32_t adcGainCoeffEn:1; + uint32_t reserved:18; +}; + +typedef struct EF_Ctrl_Sec_Param_Type EF_Ctrl_Sec_Param_Type, *PEF_Ctrl_Sec_Param_Type; + +typedef enum EF_Ctrl_Dbg_Mode_Type { + EF_CTRL_DBG_CLOSE=4, + EF_CTRL_DBG_OPEN=0, + EF_CTRL_DBG_PASSWORD=1 +} EF_Ctrl_Dbg_Mode_Type; + +struct EF_Ctrl_Sec_Param_Type { + enum EF_Ctrl_Dbg_Mode_Type ef_dbg_mode; + uint8_t ef_dbg_jtag_0_dis; + uint8_t ef_sboot_en; + uint8_t ef_no_hd_boot_en; +}; + +typedef struct bt_l2cap_cmd_reject bt_l2cap_cmd_reject, *Pbt_l2cap_cmd_reject; + +struct bt_l2cap_cmd_reject { + u16_t reason; + u8_t[0] data; +}; + +typedef struct bt_l2cap_disconn_rsp bt_l2cap_disconn_rsp, *Pbt_l2cap_disconn_rsp; + +struct bt_l2cap_disconn_rsp { + u16_t dcid; + u16_t scid; +}; + +typedef struct bt_l2cap_disconn_req bt_l2cap_disconn_req, *Pbt_l2cap_disconn_req; + +struct bt_l2cap_disconn_req { + u16_t dcid; + u16_t scid; +}; + +typedef struct bt_l2cap_cmd_reject_cid_data bt_l2cap_cmd_reject_cid_data, *Pbt_l2cap_cmd_reject_cid_data; + +struct bt_l2cap_cmd_reject_cid_data { + u16_t scid; + u16_t dcid; +}; + +typedef struct bt_l2cap_sig_hdr bt_l2cap_sig_hdr, *Pbt_l2cap_sig_hdr; + +struct bt_l2cap_sig_hdr { + u8_t code; + u8_t ident; + u16_t len; +}; + +typedef struct bt_l2cap_fixed_chan bt_l2cap_fixed_chan, *Pbt_l2cap_fixed_chan; + +struct bt_l2cap_fixed_chan { + u16_t cid; + undefined field_0x2; + undefined field_0x3; + int (* accept)(struct bt_conn *, struct bt_l2cap_chan * *); + sys_snode_t node; +}; + +typedef struct bt_l2cap_conn_param_rsp bt_l2cap_conn_param_rsp, *Pbt_l2cap_conn_param_rsp; + +struct bt_l2cap_conn_param_rsp { + u16_t result; +}; + +typedef struct bt_l2cap_le_conn_req bt_l2cap_le_conn_req, *Pbt_l2cap_le_conn_req; + +struct bt_l2cap_le_conn_req { + u16_t psm; + u16_t scid; + u16_t mtu; + u16_t mps; + u16_t credits; +}; + +typedef struct bt_l2cap_conn_param_req bt_l2cap_conn_param_req, *Pbt_l2cap_conn_param_req; + +struct bt_l2cap_conn_param_req { + u16_t min_interval; + u16_t max_interval; + u16_t latency; + u16_t timeout; +}; + +typedef struct bt_l2cap_le_credits bt_l2cap_le_credits, *Pbt_l2cap_le_credits; + +struct bt_l2cap_le_credits { + u16_t cid; + u16_t credits; +}; + +typedef struct bt_l2cap_le_conn_rsp bt_l2cap_le_conn_rsp, *Pbt_l2cap_le_conn_rsp; + +struct bt_l2cap_le_conn_rsp { + u16_t dcid; + u16_t mtu; + u16_t mps; + u16_t credits; + u16_t result; +}; + +typedef struct bt_l2cap_hdr bt_l2cap_hdr, *Pbt_l2cap_hdr; + +struct bt_l2cap_hdr { + u16_t len; + u16_t cid; +}; + +typedef struct aos_hdl_t aos_hdl_t, *Paos_hdl_t; + +typedef struct aos_hdl_t aos_timer_t; + +struct aos_hdl_t { + void * hdl; +}; + +typedef struct aos_hdl_t aos_queue_t; + +typedef uint aos_task_key_t; + +typedef struct aos_hdl_t aos_sem_t; + +typedef struct aos_hdl_t aos_task_t; + +typedef struct aos_hdl_t aos_mutex_t; + +typedef struct aos_hdl_t aos_work_t; + +typedef struct aos_workqueue_t aos_workqueue_t, *Paos_workqueue_t; + +struct aos_workqueue_t { + void * hdl; + void * stk; +}; + +typedef struct ke_msg.conflict ke_msg.conflict, *Pke_msg.conflict; + +struct ke_msg.conflict { + struct co_list_hdr hdr; + ke_msg_id_t id; + ke_task_id_t dest_id; + ke_task_id_t src_id; + uint16_t param_len; + uint32_t param[1]; +}; + +typedef enum ke_msg_status_tag { + KE_MSG_CONSUMED=0, + KE_MSG_NO_FREE=1, + KE_MSG_SAVED=2 +} ke_msg_status_tag; + +typedef uint16_t ke_state_t; + +typedef struct ke_msg ke_msg, *Pke_msg; + +struct ke_msg { + struct co_list_hdr hdr; + ke_msg_id_t id; + ke_task_id_t dest_id; + ke_task_id_t src_id; + uint16_t param_len; + uint32_t[0] param; +}; + +typedef struct mac_addr.conflict11 mac_addr.conflict11, *Pmac_addr.conflict11; + +struct mac_addr.conflict11 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict94 mac_addr.conflict94, *Pmac_addr.conflict94; + +struct mac_addr.conflict94 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict92 mac_addr.conflict92, *Pmac_addr.conflict92; + +struct mac_addr.conflict92 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict90 mac_addr.conflict90, *Pmac_addr.conflict90; + +struct mac_addr.conflict90 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict160 mac_addr.conflict160, *Pmac_addr.conflict160; + +struct mac_addr.conflict160 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict162 mac_addr.conflict162, *Pmac_addr.conflict162; + +struct mac_addr.conflict162 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict20 mac_addr.conflict20, *Pmac_addr.conflict20; + +struct mac_addr.conflict20 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict168 mac_addr.conflict168, *Pmac_addr.conflict168; + +struct mac_addr.conflict168 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict19 mac_addr.conflict19, *Pmac_addr.conflict19; + +struct mac_addr.conflict19 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict17 mac_addr.conflict17, *Pmac_addr.conflict17; + +struct mac_addr.conflict17 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict164 mac_addr.conflict164, *Pmac_addr.conflict164; + +struct mac_addr.conflict164 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict15 mac_addr.conflict15, *Pmac_addr.conflict15; + +struct mac_addr.conflict15 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict13 mac_addr.conflict13, *Pmac_addr.conflict13; + +struct mac_addr.conflict13 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict32 mac_addr.conflict32, *Pmac_addr.conflict32; + +struct mac_addr.conflict32 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict30 mac_addr.conflict30, *Pmac_addr.conflict30; + +struct mac_addr.conflict30 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict117 mac_addr.conflict117, *Pmac_addr.conflict117; + +struct mac_addr.conflict117 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict113 mac_addr.conflict113, *Pmac_addr.conflict113; + +struct mac_addr.conflict113 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict115 mac_addr.conflict115, *Pmac_addr.conflict115; + +struct mac_addr.conflict115 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict28 mac_addr.conflict28, *Pmac_addr.conflict28; + +struct mac_addr.conflict28 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict26 mac_addr.conflict26, *Pmac_addr.conflict26; + +struct mac_addr.conflict26 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict111 mac_addr.conflict111, *Pmac_addr.conflict111; + +struct mac_addr.conflict111 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict24 mac_addr.conflict24, *Pmac_addr.conflict24; + +struct mac_addr.conflict24 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict43 mac_addr.conflict43, *Pmac_addr.conflict43; + +struct mac_addr.conflict43 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict41 mac_addr.conflict41, *Pmac_addr.conflict41; + +struct mac_addr.conflict41 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict107 mac_addr.conflict107, *Pmac_addr.conflict107; + +struct mac_addr.conflict107 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict109 mac_addr.conflict109, *Pmac_addr.conflict109; + +struct mac_addr.conflict109 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict102 mac_addr.conflict102, *Pmac_addr.conflict102; + +struct mac_addr.conflict102 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict103 mac_addr.conflict103, *Pmac_addr.conflict103; + +struct mac_addr.conflict103 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict38 mac_addr.conflict38, *Pmac_addr.conflict38; + +struct mac_addr.conflict38 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict39 mac_addr.conflict39, *Pmac_addr.conflict39; + +struct mac_addr.conflict39 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict105 mac_addr.conflict105, *Pmac_addr.conflict105; + +struct mac_addr.conflict105 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict37 mac_addr.conflict37, *Pmac_addr.conflict37; + +struct mac_addr.conflict37 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict34 mac_addr.conflict34, *Pmac_addr.conflict34; + +struct mac_addr.conflict34 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict53 mac_addr.conflict53, *Pmac_addr.conflict53; + +struct mac_addr.conflict53 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict130 mac_addr.conflict130, *Pmac_addr.conflict130; + +struct mac_addr.conflict130 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict51 mac_addr.conflict51, *Pmac_addr.conflict51; + +struct mac_addr.conflict51 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict139 mac_addr.conflict139, *Pmac_addr.conflict139; + +struct mac_addr.conflict139 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict136 mac_addr.conflict136, *Pmac_addr.conflict136; + +struct mac_addr.conflict136 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict49 mac_addr.conflict49, *Pmac_addr.conflict49; + +struct mac_addr.conflict49 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict137 mac_addr.conflict137, *Pmac_addr.conflict137; + +struct mac_addr.conflict137 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict47 mac_addr.conflict47, *Pmac_addr.conflict47; + +struct mac_addr.conflict47 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict132 mac_addr.conflict132, *Pmac_addr.conflict132; + +struct mac_addr.conflict132 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict45 mac_addr.conflict45, *Pmac_addr.conflict45; + +struct mac_addr.conflict45 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict134 mac_addr.conflict134, *Pmac_addr.conflict134; + +struct mac_addr.conflict134 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict65 mac_addr.conflict65, *Pmac_addr.conflict65; + +struct mac_addr.conflict65 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict63 mac_addr.conflict63, *Pmac_addr.conflict63; + +struct mac_addr.conflict63 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict61 mac_addr.conflict61, *Pmac_addr.conflict61; + +struct mac_addr.conflict61 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict mac_addr.conflict, *Pmac_addr.conflict; + +struct mac_addr.conflict { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict128 mac_addr.conflict128, *Pmac_addr.conflict128; + +struct mac_addr.conflict128 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict124 mac_addr.conflict124, *Pmac_addr.conflict124; + +struct mac_addr.conflict124 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict126 mac_addr.conflict126, *Pmac_addr.conflict126; + +struct mac_addr.conflict126 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict58 mac_addr.conflict58, *Pmac_addr.conflict58; + +struct mac_addr.conflict58 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict59 mac_addr.conflict59, *Pmac_addr.conflict59; + +struct mac_addr.conflict59 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict123 mac_addr.conflict123, *Pmac_addr.conflict123; + +struct mac_addr.conflict123 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict77 mac_addr.conflict77, *Pmac_addr.conflict77; + +struct mac_addr.conflict77 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict151 mac_addr.conflict151, *Pmac_addr.conflict151; + +struct mac_addr.conflict151 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict73 mac_addr.conflict73, *Pmac_addr.conflict73; + +struct mac_addr.conflict73 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict71 mac_addr.conflict71, *Pmac_addr.conflict71; + +struct mac_addr.conflict71 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict158 mac_addr.conflict158, *Pmac_addr.conflict158; + +struct mac_addr.conflict158 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict69 mac_addr.conflict69, *Pmac_addr.conflict69; + +struct mac_addr.conflict69 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict153 mac_addr.conflict153, *Pmac_addr.conflict153; + +struct mac_addr.conflict153 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict154 mac_addr.conflict154, *Pmac_addr.conflict154; + +struct mac_addr.conflict154 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict67 mac_addr.conflict67, *Pmac_addr.conflict67; + +struct mac_addr.conflict67 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict156 mac_addr.conflict156, *Pmac_addr.conflict156; + +struct mac_addr.conflict156 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict88 mac_addr.conflict88, *Pmac_addr.conflict88; + +struct mac_addr.conflict88 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict86 mac_addr.conflict86, *Pmac_addr.conflict86; + +struct mac_addr.conflict86 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict141 mac_addr.conflict141, *Pmac_addr.conflict141; + +struct mac_addr.conflict141 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict84 mac_addr.conflict84, *Pmac_addr.conflict84; + +struct mac_addr.conflict84 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict82 mac_addr.conflict82, *Pmac_addr.conflict82; + +struct mac_addr.conflict82 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict80 mac_addr.conflict80, *Pmac_addr.conflict80; + +struct mac_addr.conflict80 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict9 mac_addr.conflict9, *Pmac_addr.conflict9; + +struct mac_addr.conflict9 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict7 mac_addr.conflict7, *Pmac_addr.conflict7; + +struct mac_addr.conflict7 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict5 mac_addr.conflict5, *Pmac_addr.conflict5; + +struct mac_addr.conflict5 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict147 mac_addr.conflict147, *Pmac_addr.conflict147; + +struct mac_addr.conflict147 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict3 mac_addr.conflict3, *Pmac_addr.conflict3; + +struct mac_addr.conflict3 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict149 mac_addr.conflict149, *Pmac_addr.conflict149; + +struct mac_addr.conflict149 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict1 mac_addr.conflict1, *Pmac_addr.conflict1; + +struct mac_addr.conflict1 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict143 mac_addr.conflict143, *Pmac_addr.conflict143; + +struct mac_addr.conflict143 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict78 mac_addr.conflict78, *Pmac_addr.conflict78; + +struct mac_addr.conflict78 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict145 mac_addr.conflict145, *Pmac_addr.conflict145; + +struct mac_addr.conflict145 { + u8_l array[6]; +}; + +typedef struct anon_struct.conflict54 anon_struct.conflict54, *Panon_struct.conflict54; + +struct anon_struct.conflict54 { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct anon_struct.conflict53 anon_struct.conflict53, *Panon_struct.conflict53; + +struct anon_struct.conflict53 { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct anon_struct.conflict52 anon_struct.conflict52, *Panon_struct.conflict52; + +struct anon_struct.conflict52 { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct anon_struct.conflict51 anon_struct.conflict51, *Panon_struct.conflict51; + +struct anon_struct.conflict51 { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict50 anon_struct.conflict50, *Panon_struct.conflict50; + +struct anon_struct.conflict50 { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict55 anon_struct.conflict55, *Panon_struct.conflict55; + +struct anon_struct.conflict55 { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct anon_struct.conflict43 anon_struct.conflict43, *Panon_struct.conflict43; + +struct anon_struct.conflict43 { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct anon_struct.conflict42 anon_struct.conflict42, *Panon_struct.conflict42; + +struct anon_struct.conflict42 { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct regs_to_opti regs_to_opti, *Pregs_to_opti; + +struct regs_to_opti { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct anon_struct.conflict41 anon_struct.conflict41, *Panon_struct.conflict41; + +struct anon_struct.conflict41 { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict49 anon_struct.conflict49, *Panon_struct.conflict49; + +struct anon_struct.conflict49 { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct anon_struct.conflict48 anon_struct.conflict48, *Panon_struct.conflict48; + +struct anon_struct.conflict48 { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct anon_struct.conflict47 anon_struct.conflict47, *Panon_struct.conflict47; + +struct anon_struct.conflict47 { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct anon_struct.conflict46 anon_struct.conflict46, *Panon_struct.conflict46; + +struct anon_struct.conflict46 { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct anon_struct.conflict45 anon_struct.conflict45, *Panon_struct.conflict45; + +struct anon_struct.conflict45 { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict44 anon_struct.conflict44, *Panon_struct.conflict44; + +struct anon_struct.conflict44 { + uint32_t index; + int32_t dvga; +}; + +typedef struct notch_param notch_param, *Pnotch_param; + +struct notch_param { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct anon_struct.conflict115 anon_struct.conflict115, *Panon_struct.conflict115; + +struct anon_struct.conflict115 { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict116 anon_struct.conflict116, *Panon_struct.conflict116; + +struct anon_struct.conflict116 { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict117 anon_struct.conflict117, *Panon_struct.conflict117; + +struct anon_struct.conflict117 { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct anon_struct.conflict118 anon_struct.conflict118, *Panon_struct.conflict118; + +struct anon_struct.conflict118 { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct anon_struct.conflict119 anon_struct.conflict119, *Panon_struct.conflict119; + +struct anon_struct.conflict119 { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct tx_pwr_index tx_pwr_index, *Ptx_pwr_index; + +struct tx_pwr_index { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict120 anon_struct.conflict120, *Panon_struct.conflict120; + +struct anon_struct.conflict120 { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef enum __fdlibm_version { + __fdlibm_ieee=-1, + __fdlibm_posix=0 +} __fdlibm_version; + +typedef struct HWStateMachineReg HWStateMachineReg, *PHWStateMachineReg; + +struct HWStateMachineReg { + uint32_t rxControl:6; + uint32_t reserved_7_6:2; + uint32_t txControl:9; + uint32_t reserved_23_17:7; + uint32_t macControl:8; +}; + +typedef struct dump_data_t dump_data_t, *Pdump_data_t; + +struct dump_data_t { + uint32_t time; + char * func_name; + uint32_t rc_state; + uint32_t rf_state; + uint32_t mac_debugRegHWSM1; + uint32_t mac_debugRegHWSM2; + uint16_t mac_debugPortCoex; + uint16_t mac_debugPortBackoff; + uint16_t mac_debugPortMacPhyIf; + uint16_t mac_debugPortMacPhyIf2; + uint16_t phy_debugPortMainFSM; + uint16_t phy_debugPortTDTX; + uint16_t phy_debugPortDSSSCCK1; + uint16_t phy_debugPortDSSSCCKTx; +}; + +typedef struct mbedtls_ecp_keypair mbedtls_ecp_keypair, *Pmbedtls_ecp_keypair; + +typedef struct mbedtls_ecp_group mbedtls_ecp_group, *Pmbedtls_ecp_group; + +typedef struct mbedtls_mpi mbedtls_mpi, *Pmbedtls_mpi; + +typedef struct mbedtls_ecp_point mbedtls_ecp_point, *Pmbedtls_ecp_point; + +typedef uint32_t mbedtls_mpi_uint; + +struct mbedtls_mpi { + int s; + size_t n; + mbedtls_mpi_uint * p; +}; + +struct mbedtls_ecp_point { + struct mbedtls_mpi X; + struct mbedtls_mpi Y; + struct mbedtls_mpi Z; +}; + +struct mbedtls_ecp_group { + enum mbedtls_ecp_group_id id; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + struct mbedtls_mpi P; + struct mbedtls_mpi A; + struct mbedtls_mpi B; + struct mbedtls_ecp_point G; + struct mbedtls_mpi N; + size_t pbits; + size_t nbits; + uint h; + int (* modp)(struct mbedtls_mpi *); + int (* t_pre)(struct mbedtls_ecp_point *, void *); + int (* t_post)(struct mbedtls_ecp_point *, void *); + void * t_data; + struct mbedtls_ecp_point * T; + size_t T_size; +}; + +struct mbedtls_ecp_keypair { + struct mbedtls_ecp_group grp; + struct mbedtls_mpi d; + struct mbedtls_ecp_point Q; +}; + +typedef struct mbedtls_ecp_curve_info mbedtls_ecp_curve_info, *Pmbedtls_ecp_curve_info; + +struct mbedtls_ecp_curve_info { + enum mbedtls_ecp_group_id grp_id; + undefined field_0x1; + uint16_t tls_id; + uint16_t bit_size; + undefined field_0x6; + undefined field_0x7; + char * name; +}; + +typedef enum ecp_curve_type { + ECP_TYPE_MONTGOMERY=2, + ECP_TYPE_NONE=0, + ECP_TYPE_SHORT_WEIERSTRASS=1 +} ecp_curve_type; + +typedef enum netifapi_arp_entry { + NETIFAPI_ARP_PERM=0 +} netifapi_arp_entry; + +typedef struct rxl_hwdesc_env_tag rxl_hwdesc_env_tag, *Prxl_hwdesc_env_tag; + +struct rxl_hwdesc_env_tag { + struct rx_pbd * last; + struct rx_pbd * free; +}; + +typedef struct sntp_msg sntp_msg, *Psntp_msg; + +struct sntp_msg { + u8_t li_vn_mode; + u8_t stratum; + u8_t poll; + u8_t precision; + u32_t root_delay; + u32_t root_dispersion; + u32_t reference_identifier; + u32_t reference_timestamp[2]; + u32_t originate_timestamp[2]; + u32_t receive_timestamp[2]; + u32_t transmit_timestamp[2]; +}; + +typedef struct sntp_time sntp_time, *Psntp_time; + +struct sntp_time { + u32_t sec; + u32_t frac; +}; + +typedef struct sntp_server sntp_server, *Psntp_server; + +struct sntp_server { + char * name; + ip_addr_t addr; + u8_t reachability; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct sntp_timestamps sntp_timestamps, *Psntp_timestamps; + +struct sntp_timestamps { + struct sntp_time xmit; +}; + +typedef struct event_dev_t event_dev_t, *Pevent_dev_t; + +typedef struct dlist_s dlist_s, *Pdlist_s; + +typedef struct dlist_s dlist_t; + +struct dlist_s { + struct dlist_s * prev; + struct dlist_s * next; +}; + +struct event_dev_t { + aos_mutex_t mutex; + void (* poll_cb)(struct pollfd *, void *); + struct pollfd * fd; + void * poll_data; + int counter; + dlist_t bufs; + int cache_count; + dlist_t buf_cache; +}; + +typedef struct dev_event_t dev_event_t, *Pdev_event_t; + +struct dev_event_t { + dlist_t node; + size_t len; + char[0] buf; +}; + +typedef uint64_t fdt64_t; + +typedef uint32_t fdt32_t; + +typedef struct tc_hmac_prng_struct tc_hmac_prng_struct, *Ptc_hmac_prng_struct; + +struct tc_hmac_prng_struct { + struct tc_hmac_state_struct h; + uint8_t key[32]; + uint8_t v[32]; + uint countdown; + undefined field_0x134; + undefined field_0x135; + undefined field_0x136; + undefined field_0x137; +}; + +typedef struct TkipPtk_t TkipPtk_t, *PTkipPtk_t; + +struct TkipPtk_t { + UINT8 kck[16]; + UINT8 kek[16]; + UINT8 tk[16]; + UINT8 rxMicKey[8]; + UINT8 txMicKey[8]; +}; + +typedef struct bt_mesh_sg bt_mesh_sg, *Pbt_mesh_sg; + +struct bt_mesh_sg { + void * data; + size_t len; +}; + +typedef struct anon_struct.conflict98 anon_struct.conflict98, *Panon_struct.conflict98; + +struct anon_struct.conflict98 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict97 anon_struct.conflict97, *Panon_struct.conflict97; + +struct anon_struct.conflict97 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict78 anon_struct.conflict78, *Panon_struct.conflict78; + +struct anon_struct.conflict78 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict140 anon_struct.conflict140, *Panon_struct.conflict140; + +struct anon_struct.conflict140 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict77 anon_struct.conflict77, *Panon_struct.conflict77; + +struct anon_struct.conflict77 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct apm apm, *Papm; + +typedef struct apm_start_req apm_start_req, *Papm_start_req; + +typedef struct mac_rateset mac_rateset, *Pmac_rateset; + +struct mac_rateset { + uint8_t length; + uint8_t array[12]; +}; + +struct apm { + struct apm_start_req * param; + struct co_list bss_config; + uint8_t aging_sta_idx; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint8_t * bcn_buf; + _Bool apm_emb_enabled; + uint8_t hidden_ssid; + uint8_t assoc_sta_count; + uint8_t max_sta_supported; + struct anon_struct.conflict77 aid_list[10]; + undefined field_0x5e; + undefined field_0x5f; +}; + +struct apm_start_req { // Missing member bcn_buf : uint8_t[1] at offset 0xa7 [Unsupported interior flex array: uint8_t[1]] + struct mac_rateset basic_rates; + undefined field_0xd; + struct scan_chan_tag chan; + uint32_t center_freq1; + uint32_t center_freq2; + uint8_t ch_width; + uint8_t hidden_ssid; + undefined field_0x1e; + undefined field_0x1f; + uint32_t bcn_addr; + uint16_t bcn_len; + uint16_t tim_oft; + uint16_t bcn_int; + undefined field_0x2a; + undefined field_0x2b; + uint32_t flags; + uint16_t ctrl_port_ethertype; + uint8_t tim_len; + uint8_t vif_idx; + _Bool apm_emb_enabled; + struct mac_rateset rate_set; + uint8_t beacon_period; + uint8_t qos_supported; + struct mac_ssid ssid; + uint8_t ap_sec_type; + uint8_t phrase[64]; + undefined field_0xa7; +}; + +typedef struct anon_struct.conflict87 anon_struct.conflict87, *Panon_struct.conflict87; + +struct anon_struct.conflict87 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict166 anon_struct.conflict166, *Panon_struct.conflict166; + +struct anon_struct.conflict166 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict88 anon_struct.conflict88, *Panon_struct.conflict88; + +struct anon_struct.conflict88 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict76 anon_struct.conflict76, *Panon_struct.conflict76; + +struct anon_struct.conflict76 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict247 anon_struct.conflict247, *Panon_struct.conflict247; + +struct anon_struct.conflict247 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict248 anon_struct.conflict248, *Panon_struct.conflict248; + +struct anon_struct.conflict248 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict165 anon_struct.conflict165, *Panon_struct.conflict165; + +struct anon_struct.conflict165 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct bt_conn_cb bt_conn_cb, *Pbt_conn_cb; + +typedef struct bt_le_conn_param bt_le_conn_param, *Pbt_le_conn_param; + +struct bt_conn_cb { + void (* connected)(struct bt_conn *, u8_t); + void (* disconnected)(struct bt_conn *, u8_t); + _Bool (* le_param_req)(struct bt_conn *, struct bt_le_conn_param *); + void (* le_param_updated)(struct bt_conn *, u16_t, u16_t, u16_t); + struct bt_conn_cb * _next; +}; + +struct bt_le_conn_param { + u16_t interval_min; + u16_t interval_max; + u16_t latency; + u16_t timeout; +}; + +typedef struct bt_conn_le_info bt_conn_le_info, *Pbt_conn_le_info; + +struct bt_conn_le_info { + struct bt_addr_le_t * src; + struct bt_addr_le_t * dst; + struct bt_addr_le_t * local; + struct bt_addr_le_t * remote; + u16_t interval; + u16_t latency; + u16_t timeout; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_conn_auth_cb bt_conn_auth_cb, *Pbt_conn_auth_cb; + +typedef struct bt_conn_oob_info bt_conn_oob_info, *Pbt_conn_oob_info; + +typedef enum bt_security_err { + BT_SECURITY_ERR_AUTH_FAIL=1, + BT_SECURITY_ERR_AUTH_REQUIREMENT=4, + BT_SECURITY_ERR_INVALID_PARAM=7, + BT_SECURITY_ERR_OOB_NOT_AVAILABLE=3, + BT_SECURITY_ERR_PAIR_NOT_ALLOWED=6, + BT_SECURITY_ERR_PAIR_NOT_SUPPORTED=5, + BT_SECURITY_ERR_PIN_OR_KEY_MISSING=2, + BT_SECURITY_ERR_SUCCESS=0, + BT_SECURITY_ERR_UNSPECIFIED=8 +} bt_security_err; + +typedef enum anon_enum_8_for_type { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_type; + + +// WARNING! conflicting data type names: /DWARF/conn.h/bt_conn_oob_info/anon_union_for_field_1 - /DWARF/dlist.h/_dnode/anon_union_for_field_1 + +struct bt_conn_oob_info { + enum anon_enum_8_for_type type; + union anon_union_for_field_1 field_1; +}; + +struct bt_conn_auth_cb { + void (* passkey_display)(struct bt_conn *, uint); + void (* passkey_entry)(struct bt_conn *); + void (* passkey_confirm)(struct bt_conn *, uint); + void (* oob_data_request)(struct bt_conn *, struct bt_conn_oob_info *); + void (* cancel)(struct bt_conn *); + void (* pairing_confirm)(struct bt_conn *); + void (* pairing_complete)(struct bt_conn *, _Bool); + void (* pairing_failed)(struct bt_conn *, enum bt_security_err); +}; + +typedef struct bt_conn_info bt_conn_info, *Pbt_conn_info; + + +// WARNING! conflicting data type names: /DWARF/conn.h/bt_conn_info/anon_union_for_field_3 - /DWARF/gatt.h/bt_gatt_discover_params/anon_union_for_field_3 + +struct bt_conn_info { + u8_t type; + u8_t role; + u8_t id; + undefined field_0x3; + union anon_union_for_field_3 field_3; +}; + +typedef struct bt_conn_oob_info.conflict bt_conn_oob_info.conflict, *Pbt_conn_oob_info.conflict; + +struct bt_conn_oob_info.conflict { + enum anon_enum_8_for_type.conflict type; + union anon_union_for_field_1.conflict field_1; +}; + +typedef struct bt_conn_br_info bt_conn_br_info, *Pbt_conn_br_info; + +struct bt_conn_br_info { + struct bt_addr_t * dst; +}; + +typedef struct anon_struct.conflict409 anon_struct.conflict409, *Panon_struct.conflict409; + +struct anon_struct.conflict409 { + enum anon_enum_8_for_oob_config oob_config; +}; + +typedef struct bt_conn_cb.conflict bt_conn_cb.conflict, *Pbt_conn_cb.conflict; + +struct bt_conn_cb.conflict { + void (* connected)(struct bt_conn *, u8_t); + void (* disconnected)(struct bt_conn *, u8_t); + _Bool (* le_param_req)(struct bt_conn *, struct bt_le_conn_param *); + void (* le_param_updated)(struct bt_conn *, u16_t, u16_t, u16_t); + void (* identity_resolved)(struct bt_conn *, struct bt_addr_le_t *, struct bt_addr_le_t *); + void (* security_changed)(struct bt_conn *, enum bt_security_t, enum bt_security_err); + struct bt_conn_cb * _next; +}; + +typedef struct bt_conn_oob_info.conflict3 bt_conn_oob_info.conflict3, *Pbt_conn_oob_info.conflict3; + +struct bt_conn_oob_info.conflict3 { + enum anon_enum_8_for_type.conflict3 type; + union anon_union_for_field_1.conflict3 field_1; +}; + +typedef struct bt_conn_oob_info.conflict4 bt_conn_oob_info.conflict4, *Pbt_conn_oob_info.conflict4; + +struct bt_conn_oob_info.conflict4 { + enum anon_enum_8_for_type.conflict4 type; + union anon_union_for_field_1.conflict4 field_1; +}; + +typedef struct bt_conn_oob_info.conflict5 bt_conn_oob_info.conflict5, *Pbt_conn_oob_info.conflict5; + +struct bt_conn_oob_info.conflict5 { + enum anon_enum_8_for_type.conflict5 type; + union anon_union_for_field_1.conflict5 field_1; +}; + +typedef struct bt_conn_oob_info.conflict6 bt_conn_oob_info.conflict6, *Pbt_conn_oob_info.conflict6; + +struct bt_conn_oob_info.conflict6 { + enum anon_enum_8_for_type.conflict6 type; + union anon_union_for_field_1.conflict6 field_1; +}; + +typedef struct bt_conn_oob_info.conflict1 bt_conn_oob_info.conflict1, *Pbt_conn_oob_info.conflict1; + +struct bt_conn_oob_info.conflict1 { + enum anon_enum_8_for_type.conflict1 type; + union anon_union_for_field_1.conflict1 field_1; +}; + +typedef struct bt_conn_oob_info.conflict2 bt_conn_oob_info.conflict2, *Pbt_conn_oob_info.conflict2; + +struct bt_conn_oob_info.conflict2 { + enum anon_enum_8_for_type.conflict2 type; + union anon_union_for_field_1.conflict2 field_1; +}; + +typedef struct tx_meta tx_meta, *Ptx_meta; + +typedef struct bt_conn_tx bt_conn_tx, *Pbt_conn_tx; + +struct tx_meta { + struct bt_conn_tx * tx; +}; + +struct bt_conn_tx { + sys_snode_t node; + void (* cb)(struct bt_conn *, void *); + void * user_data; + u32_t.conflict pending_no_cb; +}; + +typedef struct dhcp_msg dhcp_msg, *Pdhcp_msg; + +struct dhcp_msg { + u8_t op; + u8_t htype; + u8_t hlen; + u8_t hops; + u32_t xid; + u16_t secs; + u16_t flags; + ip4_addr_p_t ciaddr; + ip4_addr_p_t yiaddr; + ip4_addr_p_t siaddr; + ip4_addr_p_t giaddr; + u8_t chaddr[16]; + u8_t sname[64]; + u8_t file[128]; + u32_t cookie; + u8_t options[68]; +}; + +typedef struct dhcp dhcp, *Pdhcp; + +struct dhcp { + u32_t xid; + u8_t pcb_allocated; + u8_t state; + u8_t tries; + u8_t subnet_mask_given; + u16_t request_timeout; + u16_t t1_timeout; + u16_t t2_timeout; + u16_t t1_renew_time; + u16_t t2_rebind_time; + u16_t lease_used; + u16_t t0_timeout; + undefined field_0x16; + undefined field_0x17; + ip_addr_t server_ip_addr; + ip4_addr_t offered_ip_addr; + ip4_addr_t offered_sn_mask; + ip4_addr_t offered_gw_addr; + u32_t offered_t0_lease; + u32_t offered_t1_renew; + u32_t offered_t2_rebind; +}; + +typedef enum dhcp_option_idx { + DHCP_OPTION_IDX_DNS_SERVER=8, + DHCP_OPTION_IDX_DNS_SERVER_LAST=9, + DHCP_OPTION_IDX_LEASE_TIME=3, + DHCP_OPTION_IDX_MAX=10, + DHCP_OPTION_IDX_MSG_TYPE=1, + DHCP_OPTION_IDX_OVERLOAD=0, + DHCP_OPTION_IDX_ROUTER=7, + DHCP_OPTION_IDX_SERVER_ID=2, + DHCP_OPTION_IDX_SUBNET_MASK=6, + DHCP_OPTION_IDX_T1=4, + DHCP_OPTION_IDX_T2=5 +} dhcp_option_idx; + +typedef struct xTIME_OUT xTIME_OUT, *PxTIME_OUT; + +typedef struct xTIME_OUT TimeOut_t; + +typedef int32_t BaseType_t; + +struct xTIME_OUT { + BaseType_t xOverflowCount; + TickType_t xTimeOnEntering; +}; + +typedef struct xMEMORY_REGION xMEMORY_REGION, *PxMEMORY_REGION; + +struct xMEMORY_REGION { + void * pvBaseAddress; + uint32_t ulLengthInBytes; + uint32_t ulParameters; +}; + +typedef struct xTASK_STATUS xTASK_STATUS, *PxTASK_STATUS; + +typedef struct xTASK_STATUS TaskStatus_t; + +typedef enum eTaskState { + eBlocked=2, + eDeleted=4, + eInvalid=5, + eReady=1, + eRunning=0, + eSuspended=3 +} eTaskState; + +struct xTASK_STATUS { + TaskHandle_t xHandle; + char * pcTaskName; + UBaseType_t xTaskNumber; + enum eTaskState eCurrentState; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + UBaseType_t uxCurrentPriority; + UBaseType_t uxBasePriority; + uint32_t ulRunTimeCounter; + StackType_t * pxStackBase; + uint16_t usStackHighWaterMark; + undefined field_0x22; + undefined field_0x23; +}; + +typedef enum eNotifyAction { + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4 +} eNotifyAction; + +typedef struct xMEMORY_REGION MemoryRegion_t; + +typedef struct ip_pcb ip_pcb, *Pip_pcb; + +struct ip_pcb { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; +}; + +typedef struct ip_globals ip_globals, *Pip_globals; + +struct ip_globals { + struct netif * current_netif; + struct netif * current_input_netif; + struct ip_hdr * current_ip4_header; + u16_t current_ip_header_tot_len; + undefined field_0xe; + undefined field_0xf; + ip_addr_t current_iphdr_src; + ip_addr_t current_iphdr_dest; +}; + +typedef atomic_t atomic_val_t; + +typedef struct access_addr access_addr, *Paccess_addr; + +struct access_addr { + uint8_t addr[4]; +}; + +typedef struct adv_report adv_report, *Padv_report; + +typedef struct bd_addr bd_addr, *Pbd_addr; + +struct bd_addr { + uint8_t addr[6]; +}; + +struct adv_report { + uint8_t evt_type; + uint8_t adv_addr_type; + struct bd_addr adv_addr; + uint8_t data_len; + uint8_t data[31]; + uint8_t rssi; +}; + +typedef struct init_vect init_vect, *Pinit_vect; + +struct init_vect { + uint8_t iv[4]; +}; + +typedef struct le_chnl_map le_chnl_map, *Ple_chnl_map; + +struct le_chnl_map { + uint8_t map[5]; +}; + +typedef enum adv_filter_policy { + ADV_ALLOW_SCAN_ANY_CON_ANY=0, + ADV_ALLOW_SCAN_ANY_CON_WLST=2, + ADV_ALLOW_SCAN_END=4, + ADV_ALLOW_SCAN_WLST_CON_ANY=1, + ADV_ALLOW_SCAN_WLST_CON_WLST=3 +} adv_filter_policy; + +typedef struct features features, *Pfeatures; + +struct features { + uint8_t feats[8]; +}; + +typedef enum scan_filter_policy { + SCAN_ALLOW_ADV_ALL=0, + SCAN_ALLOW_ADV_ALL_AND_INIT_RPA=2, + SCAN_ALLOW_ADV_END=4, + SCAN_ALLOW_ADV_WLST=1, + SCAN_ALLOW_ADV_WLST_AND_INIT_RPA=3 +} scan_filter_policy; + +typedef struct dir_adv_report dir_adv_report, *Pdir_adv_report; + +struct dir_adv_report { + uint8_t evt_type; + uint8_t addr_type; + struct bd_addr addr; + uint8_t dir_addr_type; + struct bd_addr dir_addr; + uint8_t rssi; +}; + +typedef struct adv_data adv_data, *Padv_data; + +struct adv_data { + uint8_t data[31]; +}; + +typedef struct back_packet_info back_packet_info, *Pback_packet_info; + +struct back_packet_info { + uint8_t used; + uint8_t advmode_headlen; + uint8_t head_flags; + struct bd_addr adva_addr; + struct bd_addr targeta_addr; + undefined field_0xf; + uint16_t adi; + uint8_t auxptr[3]; + uint8_t syncinfo[18]; + uint8_t txpwr; + uint8_t datalen; + uint8_t data[255]; +}; + +typedef struct sess_k_div_x sess_k_div_x, *Psess_k_div_x; + +struct sess_k_div_x { + uint8_t skdiv[8]; +}; + +typedef struct le_features le_features, *Ple_features; + +struct le_features { + uint8_t feats[8]; +}; + +typedef struct rand_nb rand_nb, *Prand_nb; + +struct rand_nb { + uint8_t nb[8]; +}; + +typedef struct sess_k_div sess_k_div, *Psess_k_div; + +struct sess_k_div { + uint8_t skd[16]; +}; + +typedef struct t_public_key t_public_key, *Pt_public_key; + +struct t_public_key { + uint8_t x[32]; + uint8_t y[32]; +}; + +typedef struct supp_cmds supp_cmds, *Psupp_cmds; + +struct supp_cmds { + uint8_t cmds[64]; +}; + +typedef enum rnd_addr_type { + RND_NON_RSLV_ADDR=0, + RND_RSLV_ADDR=64, + RND_STATIC_ADDR=-64 +} rnd_addr_type; + +typedef enum adv_channel_map { + ADV_ALL_CHNLS_EN=7, + ADV_CHNL_37_EN=1, + ADV_CHNL_38_EN=2, + ADV_CHNL_39_EN=4, + ADV_CHNL_END=8 +} adv_channel_map; + +typedef struct crc_init crc_init, *Pcrc_init; + +struct crc_init { + uint8_t crc[3]; +}; + +typedef struct scan_rsp_data scan_rsp_data, *Pscan_rsp_data; + +struct scan_rsp_data { + uint8_t data[31]; +}; + +typedef enum scan_dup_filter_policy { + SCAN_FILT_DUPLIC_DIS=0, + SCAN_FILT_DUPLIC_EN=1, + SCAN_FILT_DUPLIC_END=2 +} scan_dup_filter_policy; + +typedef struct le_states le_states, *Ple_states; + +struct le_states { + uint8_t supp_states[8]; +}; + +typedef enum le_evt_mask { + LE_ADV_REP_EVT_BIT=1, + LE_ADV_REP_EVT_MSK=2, + LE_CH_SEL_ALGO_EVT_BIT=19, + LE_CH_SEL_ALGO_EVT_MSK=524288, + LE_CON_CMP_EVT_BIT=0, + LE_CON_CMP_EVT_MSK=1, + LE_CON_RD_REM_FEAT_EVT_BIT=3, + LE_CON_RD_REM_FEAT_EVT_MSK=8, + LE_CON_UPD_EVT_BIT=2, + LE_CON_UPD_EVT_MSK=4, + LE_DATA_LEN_CHG_EVT_BIT=6, + LE_DATA_LEN_CHG_EVT_MSK=64, + LE_DFT_EVT_MSK=31, + LE_DIR_ADV_REP_EVT_BIT=10, + LE_DIR_ADV_REP_EVT_MSK=1024, + LE_ENH_CON_CMP_EVT_BIT=9, + LE_ENH_CON_CMP_EVT_MSK=512, + LE_EXT_ADV_REP_EVT_BIT=12, + LE_EXT_ADV_REP_EVT_MSK=4096, + LE_EXT_ADV_SET_TER_EVT_BIT=17, + LE_EXT_ADV_SET_TER_EVT_MSK=131072, + LE_EXT_SCAN_TO_EVT_BIT=16, + LE_EXT_SCAN_TO_EVT_MSK=65536, + LE_GEN_DHKEY_CMP_EVT_BIT=8, + LE_GEN_DHKEY_CMP_EVT_MSK=256, + LE_LG_TR_KEY_REQ_EVT_BIT=4, + LE_LG_TR_KEY_REQ_EVT_MSK=16, + LE_PER_ADV_REP_EVT_BIT=14, + LE_PER_ADV_REP_EVT_MSK=16384, + LE_PER_ADV_SYNC_EST_EVT_BIT=13, + LE_PER_ADV_SYNC_EST_EVT_MSK=8192, + LE_PER_ADV_SYNC_LOST_EVT_BIT=15, + LE_PER_ADV_SYNC_LOST_EVT_MSK=-32768, + LE_PHY_UPD_CMP_EVT_BIT=11, + LE_PHY_UPD_CMP_EVT_MSK=2048, + LE_RD_LOC_P256_PUB_KEY_CMP_EVT_BIT=7, + LE_RD_LOC_P256_PUB_KEY_CMP_EVT_MSK=-128, + LE_REM_CON_PARA_REQ_EVT_BIT=5, + LE_REM_CON_PARA_REQ_EVT_MSK=32, + LE_SCAN_REQ_REC_EVT_BIT=18, + LE_SCAN_REQ_REC_EVT_MSK=262144 +} le_evt_mask; + +typedef enum bl_flag_wl { + LLM_UTIL_BL_CLEAR_WL=1, + LLM_UTIL_BL_NO_ACTION_WL=0, + LLM_UTIL_BL_SET_WL=2 +} bl_flag_wl; + +typedef struct llm_util_cnx_bd_addr_tag llm_util_cnx_bd_addr_tag, *Pllm_util_cnx_bd_addr_tag; + +struct llm_util_cnx_bd_addr_tag { + struct co_list_hdr hdr; + struct bd_addr dev_addr; + uint16_t conhdl; + uint8_t dev_addr_type; + _Bool in_wl; + undefined field_0xe; + undefined field_0xf; +}; + +typedef struct sha256_link_item.conflict sha256_link_item.conflict, *Psha256_link_item.conflict; + +struct sha256_link_item.conflict { + struct SEC_Eng_SHA256_Link_Ctx ctx; + struct SEC_Eng_SHA_Link_Config_Type.conflict2 linkCfg; + uint32_t tmp[16]; + uint32_t pad[16]; +}; + +typedef struct sha256_link_item sha256_link_item, *Psha256_link_item; + +struct sha256_link_item { + struct SEC_Eng_SHA256_Link_Ctx ctx; + struct SEC_Eng_SHA_Link_Config_Type.conflict1 linkCfg; + uint32_t tmp[16]; + uint32_t pad[16]; +}; + +typedef struct sha256_link_item.conflict sha256_link_item_t; + +typedef struct bt_pub_key_cb bt_pub_key_cb, *Pbt_pub_key_cb; + +struct bt_pub_key_cb { + void (* func)(u8_t *); + struct bt_pub_key_cb * _next; +}; + +typedef struct payload payload, *Ppayload; + +typedef struct payload * pyld_handle_t; + +typedef struct pro_pyld_func pro_pyld_func, *Ppro_pyld_func; + +typedef short __int16_t; + +typedef __int16_t int16_t; + +struct payload { + struct pro_pyld_func * pfnc; + void * p_drv; + uint8_t pyld_type; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +struct pro_pyld_func { + int (* pfn_pyld_read)(void *, uint8_t *, uint8_t *, uint8_t *, uint8_t *, uint8_t); + int (* pfn_pyld_write)(void *, uint8_t *, uint8_t *, uint8_t, uint8_t *, uint8_t, int16_t); +}; + +typedef struct ieee80211_mgmt ieee80211_mgmt, *Pieee80211_mgmt; + +struct ieee80211_mgmt { + __le16 frame_control; + __le16 duration; + u8 da[6]; + u8 sa[6]; + u8 bssid[6]; + __le16 seq_ctrl; + undefined field_0x18; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; + undefined field_0x1c; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; + undefined field_0x20; + undefined field_0x21; + undefined field_0x22; + undefined field_0x23; + undefined field_0x24; + undefined field_0x25; + undefined field_0x26; + undefined field_0x27; + undefined field_0x28; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; + undefined field_0x2c; + undefined field_0x2d; + undefined field_0x2e; + undefined field_0x2f; + undefined field_0x30; + undefined field_0x31; +}; + +typedef struct anon_struct.conflict356 anon_struct.conflict356, *Panon_struct.conflict356; + +struct anon_struct.conflict356 { + __le16 capab_info; + __le16 status_code; + __le16 aid; + u8[0] variable; +}; + +typedef struct anon_struct.conflict357 anon_struct.conflict357, *Panon_struct.conflict357; + +struct anon_struct.conflict357 { + __le16 capab_info; + __le16 listen_interval; + u8 current_ap[6]; + u8[0] variable; +}; + +typedef struct anon_struct.conflict358 anon_struct.conflict358, *Panon_struct.conflict358; + +struct anon_struct.conflict358 { + __le16 reason_code; +}; + +typedef struct anon_struct.conflict359 anon_struct.conflict359, *Panon_struct.conflict359; + +struct anon_struct.conflict359 { + __le64 timestamp; + __le16 beacon_int; + __le16 capab_info; + u8[0] variable; +}; + +typedef struct anon_struct.conflict353 anon_struct.conflict353, *Panon_struct.conflict353; + +struct anon_struct.conflict353 { + __le16 auth_alg; + __le16 auth_transaction; + __le16 status_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict354 anon_struct.conflict354, *Panon_struct.conflict354; + +struct anon_struct.conflict354 { + __le16 reason_code; +}; + +typedef struct anon_struct.conflict355 anon_struct.conflict355, *Panon_struct.conflict355; + +struct anon_struct.conflict355 { + __le16 capab_info; + __le16 listen_interval; + u8[0] variable; +}; + +typedef struct anon_struct.conflict360 anon_struct.conflict360, *Panon_struct.conflict360; + +struct anon_struct.conflict360 { + __le64 timestamp; + __le16 beacon_int; + __le16 capab_info; + u8[0] variable; +}; + +typedef struct anon_struct.conflict361 anon_struct.conflict361, *Panon_struct.conflict361; + +struct anon_struct.conflict361 { + u8 action_code; + u8 dialog_token; + u8 status_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict362 anon_struct.conflict362, *Panon_struct.conflict362; + +struct anon_struct.conflict362 { + u8 action_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict367 anon_struct.conflict367, *Panon_struct.conflict367; + +struct anon_struct.conflict367 { + u8 action_code; + __le16 params; + __le16 reason_code; +}; + +typedef struct anon_struct.conflict368 anon_struct.conflict368, *Panon_struct.conflict368; + +struct anon_struct.conflict368 { + u8 action_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict369 anon_struct.conflict369, *Panon_struct.conflict369; + +struct anon_struct.conflict369 { + u8 action_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict363 anon_struct.conflict363, *Panon_struct.conflict363; + +struct anon_struct.conflict363 { + u8 action_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict364 anon_struct.conflict364, *Panon_struct.conflict364; + +struct anon_struct.conflict364 { + u8 action_code; + u8 dialog_token; + u8 element_id; + u8 length; +}; + +typedef struct anon_struct.conflict365 anon_struct.conflict365, *Panon_struct.conflict365; + +struct anon_struct.conflict365 { + u8 action_code; + u8 dialog_token; + __le16 capab; + __le16 timeout; + __le16 start_seq_num; +}; + +typedef struct anon_struct.conflict366 anon_struct.conflict366, *Panon_struct.conflict366; + +struct anon_struct.conflict366 { + u8 action_code; + u8 dialog_token; + __le16 status; + __le16 capab; + __le16 timeout; +}; + +typedef struct anon_struct.conflict370 anon_struct.conflict370, *Panon_struct.conflict370; + +struct anon_struct.conflict370 { + u8 action; + u8 trans_id[2]; +}; + +typedef struct anon_struct.conflict371 anon_struct.conflict371, *Panon_struct.conflict371; + +struct anon_struct.conflict371 { + u8 action; + u8 smps_control; +}; + +typedef struct anon_struct.conflict372 anon_struct.conflict372, *Panon_struct.conflict372; + +struct anon_struct.conflict372 { + u8 action_code; + u8 chanwidth; +}; + +typedef struct anon_struct.conflict373 anon_struct.conflict373, *Panon_struct.conflict373; + +struct anon_struct.conflict373 { + u8 action_code; + u8 dialog_token; + __le16 capability; + u8[0] variable; +}; + +typedef struct anon_struct.conflict374 anon_struct.conflict374, *Panon_struct.conflict374; + +struct anon_struct.conflict374 { + u8 action_code; + u8 operating_mode; +}; + +typedef struct anon_struct.conflict375 anon_struct.conflict375, *Panon_struct.conflict375; + +struct anon_struct.conflict375 { + u8 action_code; + u8 membership[8]; + u8 position[16]; +}; + +typedef struct anon_struct.conflict376 anon_struct.conflict376, *Panon_struct.conflict376; + +struct anon_struct.conflict376 { + u8 action_code; + u8 dialog_token; + u8 tpc_elem_id; + u8 tpc_elem_length; +}; + +typedef struct anon_struct.conflict377 anon_struct.conflict377, *Panon_struct.conflict377; + +struct anon_struct.conflict377 { + u8 action_code; + u8 dialog_token; + u8 follow_up; + u8 tod[6]; + u8 toa[6]; + __le16 tod_error; + __le16 toa_error; + u8[0] variable; +}; + +typedef struct anon_struct.conflict301 anon_struct.conflict301, *Panon_struct.conflict301; + +struct anon_struct.conflict301 { + u8 action_code; + u8 dialog_token; + __le16 capability; + u8[0] variable; +}; + +typedef struct anon_struct.conflict302 anon_struct.conflict302, *Panon_struct.conflict302; + +struct anon_struct.conflict302 { + u8 action_code; + u8 operating_mode; +}; + +typedef struct anon_struct.conflict303 anon_struct.conflict303, *Panon_struct.conflict303; + +struct anon_struct.conflict303 { + u8 action_code; + u8 membership[8]; + u8 position[16]; +}; + +typedef struct anon_struct.conflict304 anon_struct.conflict304, *Panon_struct.conflict304; + +struct anon_struct.conflict304 { + u8 action_code; + u8 dialog_token; + u8 tpc_elem_id; + u8 tpc_elem_length; +}; + +typedef struct anon_struct.conflict300 anon_struct.conflict300, *Panon_struct.conflict300; + +struct anon_struct.conflict300 { + u8 action_code; + u8 chanwidth; +}; + +typedef struct anon_struct.conflict309 anon_struct.conflict309, *Panon_struct.conflict309; + +struct anon_struct.conflict309 { + u8 action_code; + u8 dialog_token; + u8 element_id; + u8 length; +}; + +typedef struct anon_struct.conflict305 anon_struct.conflict305, *Panon_struct.conflict305; + +struct anon_struct.conflict305 { + u8 action_code; + u8 dialog_token; + u8 follow_up; + u8 tod[6]; + u8 toa[6]; + __le16 tod_error; + __le16 toa_error; + u8[0] variable; +}; + +typedef struct anon_struct.conflict306 anon_struct.conflict306, *Panon_struct.conflict306; + +struct anon_struct.conflict306 { + u8 action_code; + u8 dialog_token; + u8 status_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict307 anon_struct.conflict307, *Panon_struct.conflict307; + +struct anon_struct.conflict307 { + u8 action_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict308 anon_struct.conflict308, *Panon_struct.conflict308; + +struct anon_struct.conflict308 { + u8 action_code; + u8[0] variable; +}; + +typedef union anon_union.conflict200 anon_union.conflict200, *Panon_union.conflict200; + +typedef struct anon_struct.conflict310 anon_struct.conflict310, *Panon_struct.conflict310; + +typedef struct anon_struct.conflict311 anon_struct.conflict311, *Panon_struct.conflict311; + +typedef struct anon_struct.conflict312 anon_struct.conflict312, *Panon_struct.conflict312; + +typedef struct anon_struct.conflict313 anon_struct.conflict313, *Panon_struct.conflict313; + +typedef struct anon_struct.conflict314 anon_struct.conflict314, *Panon_struct.conflict314; + +typedef struct anon_struct.conflict315 anon_struct.conflict315, *Panon_struct.conflict315; + +typedef struct anon_struct.conflict316 anon_struct.conflict316, *Panon_struct.conflict316; + +typedef struct anon_struct.conflict317 anon_struct.conflict317, *Panon_struct.conflict317; + +typedef struct anon_struct.conflict318 anon_struct.conflict318, *Panon_struct.conflict318; + +typedef struct anon_struct.conflict319 anon_struct.conflict319, *Panon_struct.conflict319; + +typedef struct anon_struct.conflict320 anon_struct.conflict320, *Panon_struct.conflict320; + +typedef struct anon_struct.conflict321 anon_struct.conflict321, *Panon_struct.conflict321; + +typedef struct anon_struct.conflict322 anon_struct.conflict322, *Panon_struct.conflict322; + +struct anon_struct.conflict316 { + u8 action; + u8 smps_control; +}; + +struct anon_struct.conflict317 { + u8 action_code; + u8 chanwidth; +}; + +struct anon_struct.conflict318 { + u8 action_code; + u8 dialog_token; + __le16 capability; + u8[0] variable; +}; + +struct anon_struct.conflict319 { + u8 action_code; + u8 operating_mode; +}; + +struct anon_struct.conflict320 { + u8 action_code; + u8 membership[8]; + u8 position[16]; +}; + +struct anon_struct.conflict321 { + u8 action_code; + u8 dialog_token; + u8 tpc_elem_id; + u8 tpc_elem_length; +}; + +struct anon_struct.conflict322 { + u8 action_code; + u8 dialog_token; + u8 follow_up; + u8 tod[6]; + u8 toa[6]; + __le16 tod_error; + __le16 toa_error; + u8[0] variable; +}; + +struct anon_struct.conflict311 { + u8 action_code; + u8 dialog_token; + __le16 status; + __le16 capab; + __le16 timeout; +}; + +struct anon_struct.conflict315 { + u8 action; + u8 trans_id[2]; +}; + +struct anon_struct.conflict313 { + u8 action_code; + u8[0] variable; +}; + +struct anon_struct.conflict310 { + u8 action_code; + u8 dialog_token; + __le16 capab; + __le16 timeout; + __le16 start_seq_num; +}; + +struct anon_struct.conflict312 { + u8 action_code; + __le16 params; + __le16 reason_code; +}; + +struct anon_struct.conflict314 { + u8 action_code; + u8[0] variable; +}; + +union anon_union.conflict200 { + struct anon_struct.conflict306 wme_action; + struct anon_struct.conflict307 chan_switch; + struct anon_struct.conflict308 ext_chan_switch; + struct anon_struct.conflict309 measurement; + struct anon_struct.conflict310 addba_req; + struct anon_struct.conflict311 addba_resp; + struct anon_struct.conflict312 delba; + struct anon_struct.conflict313 self_prot; + struct anon_struct.conflict314 mesh_action; + struct anon_struct.conflict315 sa_query; + struct anon_struct.conflict316 ht_smps; + struct anon_struct.conflict317 ht_notify_cw; + struct anon_struct.conflict318 tdls_discover_resp; + struct anon_struct.conflict319 vht_opmode_notif; + struct anon_struct.conflict320 vht_group_notif; + struct anon_struct.conflict321 tpc_report; + struct anon_struct.conflict322 ftm; +}; + +typedef struct ieee80211_ht_cap ieee80211_ht_cap, *Pieee80211_ht_cap; + +struct ieee80211_ht_cap { + __le16 cap_info; + u8 ampdu_params_info; + undefined field_0x3; + struct ieee80211_mcs_info mcs; + __le16 extended_ht_cap_info; + undefined field_0x16; + undefined field_0x17; + __le32 tx_BF_cap_info; + u8 antenna_selection_info; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict282 anon_struct.conflict282, *Panon_struct.conflict282; + +struct anon_struct.conflict282 { + __le16 reason_code; +}; + +typedef struct anon_struct.conflict283 anon_struct.conflict283, *Panon_struct.conflict283; + +struct anon_struct.conflict283 { + __le16 capab_info; + __le16 listen_interval; + u8[0] variable; +}; + +typedef struct anon_struct.conflict284 anon_struct.conflict284, *Panon_struct.conflict284; + +struct anon_struct.conflict284 { + __le16 capab_info; + __le16 status_code; + __le16 aid; + u8[0] variable; +}; + +typedef struct anon_struct.conflict285 anon_struct.conflict285, *Panon_struct.conflict285; + +struct anon_struct.conflict285 { + __le16 capab_info; + __le16 listen_interval; + u8 current_ap[6]; + u8[0] variable; +}; + +typedef struct anon_struct.conflict281 anon_struct.conflict281, *Panon_struct.conflict281; + +struct anon_struct.conflict281 { + __le16 auth_alg; + __le16 auth_transaction; + __le16 status_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict324 anon_struct.conflict324, *Panon_struct.conflict324; + +struct anon_struct.conflict324 { + __le16 auth_alg; + __le16 auth_transaction; + __le16 status_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict325 anon_struct.conflict325, *Panon_struct.conflict325; + +struct anon_struct.conflict325 { + __le16 reason_code; +}; + +typedef struct anon_struct.conflict326 anon_struct.conflict326, *Panon_struct.conflict326; + +struct anon_struct.conflict326 { + __le16 capab_info; + __le16 listen_interval; + u8[0] variable; +}; + +typedef struct anon_struct.conflict286 anon_struct.conflict286, *Panon_struct.conflict286; + +struct anon_struct.conflict286 { + __le16 reason_code; +}; + +typedef struct anon_struct.conflict287 anon_struct.conflict287, *Panon_struct.conflict287; + +struct anon_struct.conflict287 { + __le64 timestamp; + __le16 beacon_int; + __le16 capab_info; + u8[0] variable; +}; + +typedef struct anon_struct.conflict288 anon_struct.conflict288, *Panon_struct.conflict288; + +struct anon_struct.conflict288 { + __le64 timestamp; + __le16 beacon_int; + __le16 capab_info; + u8[0] variable; +}; + +typedef struct anon_struct.conflict289 anon_struct.conflict289, *Panon_struct.conflict289; + +struct anon_struct.conflict289 { + u8 action_code; + u8 dialog_token; + u8 status_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict327 anon_struct.conflict327, *Panon_struct.conflict327; + +struct anon_struct.conflict327 { + __le16 capab_info; + __le16 status_code; + __le16 aid; + u8[0] variable; +}; + +typedef enum ieee80211_reasoncode { + WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT=15, + WLAN_REASON_CIPHER_SUITE_REJECTED=24, + WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA=6, + WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA=7, + WLAN_REASON_DEAUTH_LEAVING=3, + WLAN_REASON_DISASSOC_AP_BUSY=5, + WLAN_REASON_DISASSOC_BAD_POWER=10, + WLAN_REASON_DISASSOC_BAD_SUPP_CHAN=11, + WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY=4, + WLAN_REASON_DISASSOC_LOW_ACK=34, + WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP=35, + WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH=33, + WLAN_REASON_DISASSOC_STA_HAS_LEFT=8, + WLAN_REASON_DISASSOC_UNSPECIFIED_QOS=32, + WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT=16, + WLAN_REASON_IEEE8021X_FAILED=23, + WLAN_REASON_IE_DIFFERENT=17, + WLAN_REASON_INVALID_AKMP=20, + WLAN_REASON_INVALID_GROUP_CIPHER=18, + WLAN_REASON_INVALID_IE=13, + WLAN_REASON_INVALID_PAIRWISE_CIPHER=19, + WLAN_REASON_INVALID_RSN_IE_CAP=22, + WLAN_REASON_MAC_EXISTS_IN_MBSS=64, + WLAN_REASON_MESH_CHAN=66, + WLAN_REASON_MESH_CHAN_REGULATORY=65, + WLAN_REASON_MESH_CLOSE=55, + WLAN_REASON_MESH_CONFIG=54, + WLAN_REASON_MESH_CONFIRM_TIMEOUT=57, + WLAN_REASON_MESH_INCONSISTENT_PARAM=59, + WLAN_REASON_MESH_INVALID_GTK=58, + WLAN_REASON_MESH_INVALID_SECURITY=60, + WLAN_REASON_MESH_MAX_PEERS=53, + WLAN_REASON_MESH_MAX_RETRIES=56, + WLAN_REASON_MESH_PATH_DEST_UNREACHABLE=63, + WLAN_REASON_MESH_PATH_ERROR=61, + WLAN_REASON_MESH_PATH_NOFORWARD=62, + WLAN_REASON_MESH_PEER_CANCELED=52, + WLAN_REASON_MIC_FAILURE=14, + WLAN_REASON_PREV_AUTH_NOT_VALID=2, + WLAN_REASON_QSTA_CIPHER_NOT_SUPP=45, + WLAN_REASON_QSTA_LEAVE_QBSS=36, + WLAN_REASON_QSTA_NOT_USE=37, + WLAN_REASON_QSTA_REQUIRE_SETUP=38, + WLAN_REASON_QSTA_TIMEOUT=39, + WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH=9, + WLAN_REASON_TDLS_TEARDOWN_UNREACHABLE=25, + WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED=26, + WLAN_REASON_UNSPECIFIED=1, + WLAN_REASON_UNSUPP_RSN_VERSION=21 +} ieee80211_reasoncode; + +typedef struct anon_struct.conflict329 anon_struct.conflict329, *Panon_struct.conflict329; + +struct anon_struct.conflict329 { + __le16 capab_info; + __le16 listen_interval; + u8 current_ap[6]; + u8[0] variable; +}; + +typedef struct anon_struct.conflict293 anon_struct.conflict293, *Panon_struct.conflict293; + +struct anon_struct.conflict293 { + u8 action_code; + u8 dialog_token; + __le16 capab; + __le16 timeout; + __le16 start_seq_num; +}; + +typedef struct anon_struct.conflict294 anon_struct.conflict294, *Panon_struct.conflict294; + +struct anon_struct.conflict294 { + u8 action_code; + u8 dialog_token; + __le16 status; + __le16 capab; + __le16 timeout; +}; + +typedef struct anon_struct.conflict295 anon_struct.conflict295, *Panon_struct.conflict295; + +struct anon_struct.conflict295 { + u8 action_code; + __le16 params; + __le16 reason_code; +}; + +typedef struct anon_struct.conflict296 anon_struct.conflict296, *Panon_struct.conflict296; + +struct anon_struct.conflict296 { + u8 action_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict290 anon_struct.conflict290, *Panon_struct.conflict290; + +struct anon_struct.conflict290 { + u8 action_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict291 anon_struct.conflict291, *Panon_struct.conflict291; + +struct anon_struct.conflict291 { + u8 action_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict292 anon_struct.conflict292, *Panon_struct.conflict292; + +struct anon_struct.conflict292 { + u8 action_code; + u8 dialog_token; + u8 element_id; + u8 length; +}; + +typedef struct anon_struct.conflict297 anon_struct.conflict297, *Panon_struct.conflict297; + +struct anon_struct.conflict297 { + u8 action_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict330 anon_struct.conflict330, *Panon_struct.conflict330; + +struct anon_struct.conflict330 { + __le16 reason_code; +}; + +typedef struct anon_struct.conflict298 anon_struct.conflict298, *Panon_struct.conflict298; + +struct anon_struct.conflict298 { + u8 action; + u8 trans_id[2]; +}; + +typedef struct anon_struct.conflict331 anon_struct.conflict331, *Panon_struct.conflict331; + +struct anon_struct.conflict331 { + __le64 timestamp; + __le16 beacon_int; + __le16 capab_info; + u8[0] variable; +}; + +typedef struct anon_struct.conflict299 anon_struct.conflict299, *Panon_struct.conflict299; + +struct anon_struct.conflict299 { + u8 action; + u8 smps_control; +}; + +typedef struct anon_struct.conflict332 anon_struct.conflict332, *Panon_struct.conflict332; + +struct anon_struct.conflict332 { + __le64 timestamp; + __le16 beacon_int; + __le16 capab_info; + u8[0] variable; +}; + +typedef struct mac_htcapability mac_htcapability, *Pmac_htcapability; + +struct mac_htcapability { + uint16_t ht_capa_info; + uint8_t a_mpdu_param; + uint8_t mcs_rate[16]; + undefined field_0x13; + uint16_t ht_extended_capa; + undefined field_0x16; + undefined field_0x17; + uint32_t tx_beamforming_capa; + uint8_t asel_capa; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict219 anon_struct.conflict219, *Panon_struct.conflict219; + +struct anon_struct.conflict219 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct mac_edca_param_set mac_edca_param_set, *Pmac_edca_param_set; + +struct mac_edca_param_set { + uint8_t qos_info; + uint8_t acm; + undefined field_0x2; + undefined field_0x3; + uint32_t ac_param[4]; +}; + +typedef struct mac_scan_result mac_scan_result, *Pmac_scan_result; + +struct mac_scan_result { + struct mac_addr bssid; + struct mac_ssid ssid; + uint16_t bsstype; + undefined field_0x2a; + undefined field_0x2b; + struct scan_chan_tag * chan; + uint16_t beacon_period; + uint16_t cap_info; + _Bool valid_flag; + int8_t rssi; + int8_t ppm_rel; + int8_t ppm_abs; +}; + +typedef union anon_union.conflict14 anon_union.conflict14, *Panon_union.conflict14; + +typedef struct anon_struct.conflict37 anon_struct.conflict37, *Panon_struct.conflict37; + +typedef struct anon_struct.conflict38 anon_struct.conflict38, *Panon_struct.conflict38; + +struct anon_struct.conflict38 { + uint32_t key[4]; +}; + +struct anon_struct.conflict37 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict14 { + struct anon_struct.conflict37 mic; + struct anon_struct.conflict38 mfp; +}; + +typedef struct anon_struct.conflict227 anon_struct.conflict227, *Panon_struct.conflict227; + +struct anon_struct.conflict227 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict220 anon_struct.conflict220, *Panon_struct.conflict220; + +struct anon_struct.conflict220 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict100 anon_struct.conflict100, *Panon_struct.conflict100; + +struct anon_struct.conflict100 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict221 anon_struct.conflict221, *Panon_struct.conflict221; + +struct anon_struct.conflict221 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict101 anon_struct.conflict101, *Panon_struct.conflict101; + +struct anon_struct.conflict101 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict222 anon_struct.conflict222, *Panon_struct.conflict222; + +struct anon_struct.conflict222 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict102 anon_struct.conflict102, *Panon_struct.conflict102; + +struct anon_struct.conflict102 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict107 anon_struct.conflict107, *Panon_struct.conflict107; + +struct anon_struct.conflict107 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict228 anon_struct.conflict228, *Panon_struct.conflict228; + +struct anon_struct.conflict228 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict108 anon_struct.conflict108, *Panon_struct.conflict108; + +struct anon_struct.conflict108 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict229 anon_struct.conflict229, *Panon_struct.conflict229; + +struct anon_struct.conflict229 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict109 anon_struct.conflict109, *Panon_struct.conflict109; + +struct anon_struct.conflict109 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict230 anon_struct.conflict230, *Panon_struct.conflict230; + +struct anon_struct.conflict230 { + uint32_t key[4]; +}; + +typedef union anon_union.conflict22 anon_union.conflict22, *Panon_union.conflict22; + +typedef struct anon_struct.conflict60 anon_struct.conflict60, *Panon_struct.conflict60; + +typedef struct anon_struct.conflict61 anon_struct.conflict61, *Panon_struct.conflict61; + +struct anon_struct.conflict61 { + uint32_t key[4]; +}; + +struct anon_struct.conflict60 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict22 { + struct anon_struct.conflict60 mic; + struct anon_struct.conflict61 mfp; +}; + +typedef struct anon_struct.conflict235 anon_struct.conflict235, *Panon_struct.conflict235; + +struct anon_struct.conflict235 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict236 anon_struct.conflict236, *Panon_struct.conflict236; + +struct anon_struct.conflict236 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict237 anon_struct.conflict237, *Panon_struct.conflict237; + +struct anon_struct.conflict237 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict29 anon_union.conflict29, *Panon_union.conflict29; + +typedef struct anon_struct.conflict70 anon_struct.conflict70, *Panon_struct.conflict70; + +typedef struct anon_struct.conflict71 anon_struct.conflict71, *Panon_struct.conflict71; + +struct anon_struct.conflict71 { + uint32_t key[4]; +}; + +struct anon_struct.conflict70 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict29 { + struct anon_struct.conflict70 mic; + struct anon_struct.conflict71 mfp; +}; + +typedef struct anon_struct.conflict238 anon_struct.conflict238, *Panon_struct.conflict238; + +struct anon_struct.conflict238 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict110 anon_struct.conflict110, *Panon_struct.conflict110; + +struct anon_struct.conflict110 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict125 anon_struct.conflict125, *Panon_struct.conflict125; + +struct anon_struct.conflict125 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict246 anon_struct.conflict246, *Panon_struct.conflict246; + +struct anon_struct.conflict246 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict126 anon_struct.conflict126, *Panon_struct.conflict126; + +struct anon_struct.conflict126 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict243 anon_struct.conflict243, *Panon_struct.conflict243; + +struct anon_struct.conflict243 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict123 anon_struct.conflict123, *Panon_struct.conflict123; + +struct anon_struct.conflict123 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict244 anon_struct.conflict244, *Panon_struct.conflict244; + +struct anon_struct.conflict244 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict124 anon_struct.conflict124, *Panon_struct.conflict124; + +struct anon_struct.conflict124 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict245 anon_struct.conflict245, *Panon_struct.conflict245; + +struct anon_struct.conflict245 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict43 anon_union.conflict43, *Panon_union.conflict43; + +typedef struct anon_struct.conflict81 anon_struct.conflict81, *Panon_struct.conflict81; + +typedef struct anon_struct.conflict82 anon_struct.conflict82, *Panon_struct.conflict82; + +struct anon_struct.conflict82 { + uint32_t key[4]; +}; + +struct anon_struct.conflict81 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict43 { + struct anon_struct.conflict81 mic; + struct anon_struct.conflict82 mfp; +}; + +typedef struct anon_struct.conflict131 anon_struct.conflict131, *Panon_struct.conflict131; + +struct anon_struct.conflict131 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict184 anon_union.conflict184, *Panon_union.conflict184; + +union anon_union.conflict184 { + struct anon_struct.conflict245 mic; + struct anon_struct.conflict246 mfp; +}; + +typedef struct anon_struct.conflict132 anon_struct.conflict132, *Panon_struct.conflict132; + +struct anon_struct.conflict132 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict133 anon_struct.conflict133, *Panon_struct.conflict133; + +struct anon_struct.conflict133 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict134 anon_struct.conflict134, *Panon_struct.conflict134; + +struct anon_struct.conflict134 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict59 anon_struct.conflict59, *Panon_struct.conflict59; + +struct anon_struct.conflict59 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict58 anon_struct.conflict58, *Panon_struct.conflict58; + +struct anon_struct.conflict58 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict60 anon_union.conflict60, *Panon_union.conflict60; + +union anon_union.conflict60 { + struct anon_struct.conflict101 mic; + struct anon_struct.conflict102 mfp; +}; + +typedef struct mac_vhtcapability mac_vhtcapability, *Pmac_vhtcapability; + +struct mac_vhtcapability { + uint32_t vht_capa_info; + uint16_t rx_mcs_map; + uint16_t rx_highest; + uint16_t tx_mcs_map; + uint16_t tx_highest; +}; + +typedef union anon_union.conflict53 anon_union.conflict53, *Panon_union.conflict53; + +typedef struct anon_struct.conflict91 anon_struct.conflict91, *Panon_struct.conflict91; + +typedef struct anon_struct.conflict92 anon_struct.conflict92, *Panon_struct.conflict92; + +struct anon_struct.conflict92 { + uint32_t key[4]; +}; + +struct anon_struct.conflict91 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict53 { + struct anon_struct.conflict91 mic; + struct anon_struct.conflict92 mfp; +}; + +typedef union anon_union.conflict177 anon_union.conflict177, *Panon_union.conflict177; + +union anon_union.conflict177 { + struct anon_struct.conflict237 mic; + struct anon_struct.conflict238 mfp; +}; + +typedef union anon_union.conflict170 anon_union.conflict170, *Panon_union.conflict170; + +union anon_union.conflict170 { + struct anon_struct.conflict229 mic; + struct anon_struct.conflict230 mfp; +}; + +typedef struct anon_struct.conflict40 anon_struct.conflict40, *Panon_struct.conflict40; + +struct anon_struct.conflict40 { + uint32_t key[4]; +}; + +typedef union anon_union.conflict163 anon_union.conflict163, *Panon_union.conflict163; + +union anon_union.conflict163 { + struct anon_struct.conflict221 mic; + struct anon_struct.conflict222 mfp; +}; + +typedef union anon_union.conflict67 anon_union.conflict67, *Panon_union.conflict67; + +union anon_union.conflict67 { + struct anon_struct.conflict109 mic; + struct anon_struct.conflict110 mfp; +}; + +typedef struct anon_struct.conflict39 anon_struct.conflict39, *Panon_struct.conflict39; + +struct anon_struct.conflict39 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict36 anon_struct.conflict36, *Panon_struct.conflict36; + +struct anon_struct.conflict36 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict35 anon_struct.conflict35, *Panon_struct.conflict35; + +struct anon_struct.conflict35 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict81 anon_union.conflict81, *Panon_union.conflict81; + +union anon_union.conflict81 { + struct anon_struct.conflict133 mic; + struct anon_struct.conflict134 mfp; +}; + +typedef union anon_union.conflict74 anon_union.conflict74, *Panon_union.conflict74; + +union anon_union.conflict74 { + struct anon_struct.conflict125 mic; + struct anon_struct.conflict126 mfp; +}; + +typedef union anon_union.conflict151 anon_union.conflict151, *Panon_union.conflict151; + +typedef struct anon_struct.conflict209 anon_struct.conflict209, *Panon_struct.conflict209; + +typedef struct anon_struct.conflict210 anon_struct.conflict210, *Panon_struct.conflict210; + +struct anon_struct.conflict210 { + uint32_t key[4]; +}; + +struct anon_struct.conflict209 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict151 { + struct anon_struct.conflict209 mic; + struct anon_struct.conflict210 mfp; +}; + +typedef union anon_union.conflict156 anon_union.conflict156, *Panon_union.conflict156; + +typedef struct anon_struct.conflict213 anon_struct.conflict213, *Panon_struct.conflict213; + +typedef struct anon_struct.conflict214 anon_struct.conflict214, *Panon_struct.conflict214; + +struct anon_struct.conflict214 { + uint32_t key[4]; +}; + +struct anon_struct.conflict213 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict156 { + struct anon_struct.conflict213 mic; + struct anon_struct.conflict214 mfp; +}; + +typedef struct anon_struct.conflict202 anon_struct.conflict202, *Panon_struct.conflict202; + +struct anon_struct.conflict202 { + uint32_t key[4]; +}; + +typedef struct mac_sta_info mac_sta_info, *Pmac_sta_info; + +struct mac_sta_info { + struct mac_rateset rate_set; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + struct mac_htcapability ht_cap; + struct mac_vhtcapability vht_cap; + uint32_t capa_flags; + uint8_t phy_bw_max; + uint8_t bw_cur; + uint8_t uapsd_queues; + uint8_t max_sp_len; + uint8_t stbc_nss; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; +}; + +typedef struct anon_struct.conflict200 anon_struct.conflict200, *Panon_struct.conflict200; + +struct anon_struct.conflict200 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict201 anon_struct.conflict201, *Panon_struct.conflict201; + +struct anon_struct.conflict201 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict207 anon_struct.conflict207, *Panon_struct.conflict207; + +struct anon_struct.conflict207 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict208 anon_struct.conflict208, *Panon_struct.conflict208; + +struct anon_struct.conflict208 { + uint32_t key[4]; +}; + +typedef union anon_union.conflict88 anon_union.conflict88, *Panon_union.conflict88; + +typedef struct anon_struct.conflict143 anon_struct.conflict143, *Panon_struct.conflict143; + +typedef struct anon_struct.conflict144 anon_struct.conflict144, *Panon_struct.conflict144; + +struct anon_struct.conflict143 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +struct anon_struct.conflict144 { + uint32_t key[4]; +}; + +union anon_union.conflict88 { + struct anon_struct.conflict143 mic; + struct anon_struct.conflict144 mfp; +}; + +typedef union anon_union.conflict144 anon_union.conflict144, *Panon_union.conflict144; + +union anon_union.conflict144 { + struct anon_struct.conflict201 mic; + struct anon_struct.conflict202 mfp; +}; + +typedef struct anon_struct.conflict211 anon_struct.conflict211, *Panon_struct.conflict211; + +struct anon_struct.conflict211 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict212 anon_struct.conflict212, *Panon_struct.conflict212; + +struct anon_struct.conflict212 { + uint32_t key[4]; +}; + +typedef union anon_union.conflict139 anon_union.conflict139, *Panon_union.conflict139; + +typedef struct anon_struct.conflict197 anon_struct.conflict197, *Panon_struct.conflict197; + +typedef struct anon_struct.conflict198 anon_struct.conflict198, *Panon_struct.conflict198; + +struct anon_struct.conflict198 { + uint32_t key[4]; +}; + +struct anon_struct.conflict197 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict139 { + struct anon_struct.conflict197 mic; + struct anon_struct.conflict198 mfp; +}; + +typedef struct anon_struct.conflict99 anon_struct.conflict99, *Panon_struct.conflict99; + +struct anon_struct.conflict99 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict95 anon_union.conflict95, *Panon_union.conflict95; + +typedef struct anon_struct.conflict151 anon_struct.conflict151, *Panon_struct.conflict151; + +typedef struct anon_struct.conflict152 anon_struct.conflict152, *Panon_struct.conflict152; + +struct anon_struct.conflict152 { + uint32_t key[4]; +}; + +struct anon_struct.conflict151 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict95 { + struct anon_struct.conflict151 mic; + struct anon_struct.conflict152 mfp; +}; + +typedef struct anon_struct.conflict183 anon_struct.conflict183, *Panon_struct.conflict183; + +struct anon_struct.conflict183 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict184 anon_struct.conflict184, *Panon_struct.conflict184; + +struct anon_struct.conflict184 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict185 anon_struct.conflict185, *Panon_struct.conflict185; + +struct anon_struct.conflict185 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict186 anon_struct.conflict186, *Panon_struct.conflict186; + +struct anon_struct.conflict186 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict90 anon_struct.conflict90, *Panon_struct.conflict90; + +struct anon_struct.conflict90 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict188 anon_struct.conflict188, *Panon_struct.conflict188; + +struct anon_struct.conflict188 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict189 anon_struct.conflict189, *Panon_struct.conflict189; + +struct anon_struct.conflict189 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict80 anon_struct.conflict80, *Panon_struct.conflict80; + +struct anon_struct.conflict80 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict89 anon_struct.conflict89, *Panon_struct.conflict89; + +struct anon_struct.conflict89 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict129 anon_union.conflict129, *Panon_union.conflict129; + +typedef struct anon_struct.conflict190 anon_struct.conflict190, *Panon_struct.conflict190; + +typedef struct anon_struct.conflict191 anon_struct.conflict191, *Panon_struct.conflict191; + +struct anon_struct.conflict191 { + uint32_t key[4]; +}; + +struct anon_struct.conflict190 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict129 { + struct anon_struct.conflict190 mic; + struct anon_struct.conflict191 mfp; +}; + +typedef struct anon_struct.conflict195 anon_struct.conflict195, *Panon_struct.conflict195; + +struct anon_struct.conflict195 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict196 anon_struct.conflict196, *Panon_struct.conflict196; + +struct anon_struct.conflict196 { + uint32_t key[4]; +}; + +typedef union anon_union.conflict124 anon_union.conflict124, *Panon_union.conflict124; + +union anon_union.conflict124 { + struct anon_struct.conflict185 mic; + struct anon_struct.conflict186 mfp; +}; + +typedef struct anon_struct.conflict199 anon_struct.conflict199, *Panon_struct.conflict199; + +struct anon_struct.conflict199 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict117 anon_union.conflict117, *Panon_union.conflict117; + +typedef struct anon_struct.conflict177 anon_struct.conflict177, *Panon_struct.conflict177; + +typedef struct anon_struct.conflict178 anon_struct.conflict178, *Panon_struct.conflict178; + +struct anon_struct.conflict178 { + uint32_t key[4]; +}; + +struct anon_struct.conflict177 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict117 { + struct anon_struct.conflict177 mic; + struct anon_struct.conflict178 mfp; +}; + +typedef struct anon_struct.conflict79 anon_struct.conflict79, *Panon_struct.conflict79; + +struct anon_struct.conflict79 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict110 anon_union.conflict110, *Panon_union.conflict110; + +typedef struct anon_struct.conflict169 anon_struct.conflict169, *Panon_struct.conflict169; + +typedef struct anon_struct.conflict170 anon_struct.conflict170, *Panon_struct.conflict170; + +struct anon_struct.conflict170 { + uint32_t key[4]; +}; + +struct anon_struct.conflict169 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict110 { + struct anon_struct.conflict169 mic; + struct anon_struct.conflict170 mfp; +}; + +typedef struct anon_struct.conflict69 anon_struct.conflict69, *Panon_struct.conflict69; + +struct anon_struct.conflict69 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict68 anon_struct.conflict68, *Panon_struct.conflict68; + +struct anon_struct.conflict68 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict102 anon_union.conflict102, *Panon_union.conflict102; + +typedef struct anon_struct.conflict159 anon_struct.conflict159, *Panon_struct.conflict159; + +typedef struct anon_struct.conflict160 anon_struct.conflict160, *Panon_struct.conflict160; + +struct anon_struct.conflict160 { + uint32_t key[4]; +}; + +struct anon_struct.conflict159 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict102 { + struct anon_struct.conflict159 mic; + struct anon_struct.conflict160 mfp; +}; + +typedef struct anon_struct.conflict141 anon_struct.conflict141, *Panon_struct.conflict141; + +struct anon_struct.conflict141 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict142 anon_struct.conflict142, *Panon_struct.conflict142; + +struct anon_struct.conflict142 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict149 anon_struct.conflict149, *Panon_struct.conflict149; + +struct anon_struct.conflict149 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict150 anon_struct.conflict150, *Panon_struct.conflict150; + +struct anon_struct.conflict150 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict158 anon_struct.conflict158, *Panon_struct.conflict158; + +struct anon_struct.conflict158 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict157 anon_struct.conflict157, *Panon_struct.conflict157; + +struct anon_struct.conflict157 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict167 anon_struct.conflict167, *Panon_struct.conflict167; + +struct anon_struct.conflict167 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict168 anon_struct.conflict168, *Panon_struct.conflict168; + +struct anon_struct.conflict168 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict175 anon_struct.conflict175, *Panon_struct.conflict175; + +struct anon_struct.conflict175 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict176 anon_struct.conflict176, *Panon_struct.conflict176; + +struct anon_struct.conflict176 { + uint32_t key[4]; +}; + +typedef struct ke_msg_handler.conflict2 ke_msg_handler.conflict2, *Pke_msg_handler.conflict2; + +struct ke_msg_handler.conflict2 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict53 ke_msg_handler.conflict53, *Pke_msg_handler.conflict53; + +struct ke_msg_handler.conflict53 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict41 ke_msg_handler.conflict41, *Pke_msg_handler.conflict41; + +struct ke_msg_handler.conflict41 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_task_desc ke_task_desc, *Pke_task_desc; + +struct ke_task_desc { + struct ke_state_handler * state_handler; + struct ke_state_handler * default_handler; + ke_state_t * state; + uint16_t state_max; + uint16_t idx_max; +}; + +typedef struct ke_msg_handler.conflict65 ke_msg_handler.conflict65, *Pke_msg_handler.conflict65; + +struct ke_msg_handler.conflict65 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict64 ke_msg_handler.conflict64, *Pke_msg_handler.conflict64; + +struct ke_msg_handler.conflict64 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict63 ke_msg_handler.conflict63, *Pke_msg_handler.conflict63; + +struct ke_msg_handler.conflict63 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict62 ke_msg_handler.conflict62, *Pke_msg_handler.conflict62; + +struct ke_msg_handler.conflict62 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict3 ke_msg_handler.conflict3, *Pke_msg_handler.conflict3; + +struct ke_msg_handler.conflict3 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict61 ke_msg_handler.conflict61, *Pke_msg_handler.conflict61; + +struct ke_msg_handler.conflict61 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict60 ke_msg_handler.conflict60, *Pke_msg_handler.conflict60; + +struct ke_msg_handler.conflict60 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict ke_msg_handler.conflict, *Pke_msg_handler.conflict; + +struct ke_msg_handler.conflict { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict59 ke_msg_handler.conflict59, *Pke_msg_handler.conflict59; + +struct ke_msg_handler.conflict59 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict58 ke_msg_handler.conflict58, *Pke_msg_handler.conflict58; + +struct ke_msg_handler.conflict58 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict57 ke_msg_handler.conflict57, *Pke_msg_handler.conflict57; + +struct ke_msg_handler.conflict57 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict56 ke_msg_handler.conflict56, *Pke_msg_handler.conflict56; + +struct ke_msg_handler.conflict56 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict55 ke_msg_handler.conflict55, *Pke_msg_handler.conflict55; + +struct ke_msg_handler.conflict55 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict54 ke_msg_handler.conflict54, *Pke_msg_handler.conflict54; + +struct ke_msg_handler.conflict54 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef enum KE_TASK_STATUS { + KE_TASK_ALREADY_EXISTS=4, + KE_TASK_CAPA_EXCEEDED=3, + KE_TASK_FAIL=1, + KE_TASK_OK=0, + KE_TASK_UNKNOWN=2 +} KE_TASK_STATUS; + +typedef struct ke_msg_handler.conflict52 ke_msg_handler.conflict52, *Pke_msg_handler.conflict52; + +struct ke_msg_handler.conflict52 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict51 ke_msg_handler.conflict51, *Pke_msg_handler.conflict51; + +struct ke_msg_handler.conflict51 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict50 ke_msg_handler.conflict50, *Pke_msg_handler.conflict50; + +struct ke_msg_handler.conflict50 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict9 ke_msg_handler.conflict9, *Pke_msg_handler.conflict9; + +struct ke_msg_handler.conflict9 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict46 ke_msg_handler.conflict46, *Pke_msg_handler.conflict46; + +struct ke_msg_handler.conflict46 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict6 ke_msg_handler.conflict6, *Pke_msg_handler.conflict6; + +struct ke_msg_handler.conflict6 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict5 ke_msg_handler.conflict5, *Pke_msg_handler.conflict5; + +struct ke_msg_handler.conflict5 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict8 ke_msg_handler.conflict8, *Pke_msg_handler.conflict8; + +struct ke_msg_handler.conflict8 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict7 ke_msg_handler.conflict7, *Pke_msg_handler.conflict7; + +struct ke_msg_handler.conflict7 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict1 ke_msg_handler.conflict1, *Pke_msg_handler.conflict1; + +struct ke_msg_handler.conflict1 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict4 ke_msg_handler.conflict4, *Pke_msg_handler.conflict4; + +struct ke_msg_handler.conflict4 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict47 ke_msg_handler.conflict47, *Pke_msg_handler.conflict47; + +struct ke_msg_handler.conflict47 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict49 ke_msg_handler.conflict49, *Pke_msg_handler.conflict49; + +struct ke_msg_handler.conflict49 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict48 ke_msg_handler.conflict48, *Pke_msg_handler.conflict48; + +struct ke_msg_handler.conflict48 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict45 ke_msg_handler.conflict45, *Pke_msg_handler.conflict45; + +struct ke_msg_handler.conflict45 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict44 ke_msg_handler.conflict44, *Pke_msg_handler.conflict44; + +struct ke_msg_handler.conflict44 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict43 ke_msg_handler.conflict43, *Pke_msg_handler.conflict43; + +struct ke_msg_handler.conflict43 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict42 ke_msg_handler.conflict42, *Pke_msg_handler.conflict42; + +struct ke_msg_handler.conflict42 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict40 ke_msg_handler.conflict40, *Pke_msg_handler.conflict40; + +struct ke_msg_handler.conflict40 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict39 ke_msg_handler.conflict39, *Pke_msg_handler.conflict39; + +struct ke_msg_handler.conflict39 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict38 ke_msg_handler.conflict38, *Pke_msg_handler.conflict38; + +struct ke_msg_handler.conflict38 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict37 ke_msg_handler.conflict37, *Pke_msg_handler.conflict37; + +struct ke_msg_handler.conflict37 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict36 ke_msg_handler.conflict36, *Pke_msg_handler.conflict36; + +struct ke_msg_handler.conflict36 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict35 ke_msg_handler.conflict35, *Pke_msg_handler.conflict35; + +struct ke_msg_handler.conflict35 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict34 ke_msg_handler.conflict34, *Pke_msg_handler.conflict34; + +struct ke_msg_handler.conflict34 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict33 ke_msg_handler.conflict33, *Pke_msg_handler.conflict33; + +struct ke_msg_handler.conflict33 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict32 ke_msg_handler.conflict32, *Pke_msg_handler.conflict32; + +struct ke_msg_handler.conflict32 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict31 ke_msg_handler.conflict31, *Pke_msg_handler.conflict31; + +struct ke_msg_handler.conflict31 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict30 ke_msg_handler.conflict30, *Pke_msg_handler.conflict30; + +struct ke_msg_handler.conflict30 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict29 ke_msg_handler.conflict29, *Pke_msg_handler.conflict29; + +struct ke_msg_handler.conflict29 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict28 ke_msg_handler.conflict28, *Pke_msg_handler.conflict28; + +struct ke_msg_handler.conflict28 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict27 ke_msg_handler.conflict27, *Pke_msg_handler.conflict27; + +struct ke_msg_handler.conflict27 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict26 ke_msg_handler.conflict26, *Pke_msg_handler.conflict26; + +struct ke_msg_handler.conflict26 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict25 ke_msg_handler.conflict25, *Pke_msg_handler.conflict25; + +struct ke_msg_handler.conflict25 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict24 ke_msg_handler.conflict24, *Pke_msg_handler.conflict24; + +struct ke_msg_handler.conflict24 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict23 ke_msg_handler.conflict23, *Pke_msg_handler.conflict23; + +struct ke_msg_handler.conflict23 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict22 ke_msg_handler.conflict22, *Pke_msg_handler.conflict22; + +struct ke_msg_handler.conflict22 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict21 ke_msg_handler.conflict21, *Pke_msg_handler.conflict21; + +struct ke_msg_handler.conflict21 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict20 ke_msg_handler.conflict20, *Pke_msg_handler.conflict20; + +struct ke_msg_handler.conflict20 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict19 ke_msg_handler.conflict19, *Pke_msg_handler.conflict19; + +struct ke_msg_handler.conflict19 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict18 ke_msg_handler.conflict18, *Pke_msg_handler.conflict18; + +struct ke_msg_handler.conflict18 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict17 ke_msg_handler.conflict17, *Pke_msg_handler.conflict17; + +struct ke_msg_handler.conflict17 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict16 ke_msg_handler.conflict16, *Pke_msg_handler.conflict16; + +struct ke_msg_handler.conflict16 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict15 ke_msg_handler.conflict15, *Pke_msg_handler.conflict15; + +struct ke_msg_handler.conflict15 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict14 ke_msg_handler.conflict14, *Pke_msg_handler.conflict14; + +struct ke_msg_handler.conflict14 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict13 ke_msg_handler.conflict13, *Pke_msg_handler.conflict13; + +struct ke_msg_handler.conflict13 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict12 ke_msg_handler.conflict12, *Pke_msg_handler.conflict12; + +struct ke_msg_handler.conflict12 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict11 ke_msg_handler.conflict11, *Pke_msg_handler.conflict11; + +struct ke_msg_handler.conflict11 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict10 ke_msg_handler.conflict10, *Pke_msg_handler.conflict10; + +struct ke_msg_handler.conflict10 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct vendor_data_t vendor_data_t, *Pvendor_data_t; + +struct vendor_data_t { + uint8_t data[65]; +}; + +typedef struct anon_struct.conflict413 anon_struct.conflict413, *Panon_struct.conflict413; + +struct anon_struct.conflict413 { + u16_t local; + u16_t dst; + u16_t net_idx; + u16_t app_idx; +}; + +typedef struct anon_struct.conflict529 anon_struct.conflict529, *Panon_struct.conflict529; + +struct anon_struct.conflict529 { + uint8_t partition_active_idx; + uint8_t pad[3]; + struct PtTable_Stuff_Config table; +}; + +typedef enum llc_util_enc_state { + LLC_ENC_DISABLED=0, + LLC_ENC_ENABLE=3, + LLC_ENC_FLOW_OFF=12, + LLC_ENC_PAUSE_PENDING=32, + LLC_ENC_REFRESH_PENDING=16, + LLC_ENC_RX=2, + LLC_ENC_RX_FLOW_OFF=8, + LLC_ENC_TX=1, + LLC_ENC_TX_FLOW_OFF=4 +} llc_util_enc_state; + +typedef struct HALPartition_Entry_Config HALPartition_Entry_Config, *PHALPartition_Entry_Config; + +struct HALPartition_Entry_Config { + uint8_t type; + uint8_t device; + uint8_t activeIndex; + uint8_t name[9]; + uint32_t Address[2]; + uint32_t maxLen[2]; + uint32_t len; + uint32_t age; +}; + +typedef enum HAL_Err_Type { + HAL_ERROR=1, + HAL_SUCCESS=0 +} HAL_Err_Type; + +typedef struct phy_hal_tag phy_hal_tag, *Pphy_hal_tag; + +struct phy_hal_tag { + int16_t temperature; + uint8_t capcode; + undefined field_0x3; +}; + +typedef struct anon_struct.conflict560 anon_struct.conflict560, *Panon_struct.conflict560; + +struct anon_struct.conflict560 { + void * handle; + int fd; +}; + +typedef struct event_list_node_t event_list_node_t, *Pevent_list_node_t; + +typedef struct input_event_t input_event_t, *Pinput_event_t; + +struct event_list_node_t { + dlist_t node; + void (* cb)(struct input_event_t *, void *); + void * priv; + uint16_t type_filter; + undefined field_0x12; + undefined field_0x13; +}; + +struct input_event_t { + uint32_t time; + uint16_t type; + uint16_t code; + ulong value; + ulong extra; +}; + +typedef struct Bl_MD5_CTX Bl_MD5_CTX, *PBl_MD5_CTX; + +struct Bl_MD5_CTX { + ulong state[4]; + ulong count[2]; + ulong scratch[16]; + uchar buffer[64]; +}; + +typedef struct mbedtls_md5_context mbedtls_md5_context, *Pmbedtls_md5_context; + +struct mbedtls_md5_context { + uint32_t total[2]; + uint32_t state[4]; + uchar buffer[64]; +}; + +typedef struct ke_task_elem ke_task_elem, *Pke_task_elem; + +struct ke_task_elem { + struct ke_task_desc * p_desc; +}; + +typedef struct ble_ke_task_env_tag ble_ke_task_env_tag, *Pble_ke_task_env_tag; + +struct ble_ke_task_env_tag { + struct ke_task_elem task_list[5]; +}; + +typedef struct sm_env_tag sm_env_tag, *Psm_env_tag; + +struct sm_env_tag { + struct sm_connect_req * connect_param; + struct sm_connect_ind * connect_ind; + struct co_list bss_config; + _Bool join_passive; + _Bool ft_over_ds; + undefined field_0x12; + undefined field_0x13; + int exist_ssid_idx; + struct mac_addr ft_old_bssid; + undefined field_0x1e; + undefined field_0x1f; +}; + +typedef struct apm_start_cac_req apm_start_cac_req, *Papm_start_cac_req; + +struct apm_start_cac_req { + struct scan_chan_tag chan; + undefined field_0x6; + undefined field_0x7; + uint32_t center_freq1; + uint32_t center_freq2; + uint8_t ch_width; + uint8_t vif_idx; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct apm_start_cfm apm_start_cfm, *Papm_start_cfm; + +struct apm_start_cfm { + uint8_t status; + uint8_t vif_idx; + uint8_t ch_idx; + uint8_t bcmc_idx; +}; + +typedef struct apm_sta_del_cfm apm_sta_del_cfm, *Papm_sta_del_cfm; + +struct apm_sta_del_cfm { + uint8_t status; + uint8_t vif_idx; + uint8_t sta_idx; +}; + +typedef struct apm_stop_req apm_stop_req, *Papm_stop_req; + +struct apm_stop_req { + uint8_t vif_idx; +}; + +typedef struct apm_sta_del_ind apm_sta_del_ind, *Papm_sta_del_ind; + +struct apm_sta_del_ind { + uint8_t sta_idx; +}; + +typedef enum apm_msg_tag { + APM_CONF_MAX_STA_CFM=7182, + APM_CONF_MAX_STA_REQ=7181, + APM_MAX=7183, + APM_START_CAC_CFM=7173, + APM_START_CAC_REQ=7172, + APM_START_CFM=7169, + APM_START_REQ=7168, + APM_STA_ADD_IND=7176, + APM_STA_CONNECT_TIMEOUT_IND=7178, + APM_STA_DEL_CFM=7180, + APM_STA_DEL_IND=7177, + APM_STA_DEL_REQ=7179, + APM_STOP_CAC_CFM=7175, + APM_STOP_CAC_REQ=7174, + APM_STOP_CFM=7171, + APM_STOP_REQ=7170 +} apm_msg_tag; + +typedef enum apm_state_tag { + APM_BCN_SETTING=2, + APM_BSS_PARAM_SETTING=1, + APM_IDLE=0, + APM_STATE_MAX=3 +} apm_state_tag; + +typedef struct apm_start_cac_cfm apm_start_cac_cfm, *Papm_start_cac_cfm; + +struct apm_start_cac_cfm { + uint8_t status; + uint8_t ch_idx; +}; + +typedef struct apm_stop_cac_req apm_stop_cac_req, *Papm_stop_cac_req; + +struct apm_stop_cac_req { + uint8_t vif_idx; +}; + +typedef struct apm_conf_max_sta_req apm_conf_max_sta_req, *Papm_conf_max_sta_req; + +struct apm_conf_max_sta_req { + uint8_t max_sta_supported; +}; + +typedef struct apm_sta_del_req apm_sta_del_req, *Papm_sta_del_req; + +struct apm_sta_del_req { + uint8_t vif_idx; + uint8_t sta_idx; +}; + +typedef struct apm_sta_add_ind apm_sta_add_ind, *Papm_sta_add_ind; + +struct apm_sta_add_ind { + uint32_t flags; + struct mac_addr sta_addr; + uint8_t vif_idx; + uint8_t sta_idx; + int8_t rssi; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t tsflo; + uint32_t tsfhi; + uint8_t data_rate; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; +}; + +typedef struct UART_CFG_Type UART_CFG_Type, *PUART_CFG_Type; + +typedef enum UART_DataBits_Type { + UART_DATABITS_5=0, + UART_DATABITS_6=1, + UART_DATABITS_7=2, + UART_DATABITS_8=3 +} UART_DataBits_Type; + +typedef enum UART_StopBits_Type { + UART_STOPBITS_1=0, + UART_STOPBITS_1_5=1, + UART_STOPBITS_2=2 +} UART_StopBits_Type; + +typedef enum UART_Parity_Type { + UART_PARITY_EVEN=2, + UART_PARITY_NONE=0, + UART_PARITY_ODD=1 +} UART_Parity_Type; + +typedef enum UART_ByteBitInverse_Type { + UART_LSB_FIRST=0, + UART_MSB_FIRST=1 +} UART_ByteBitInverse_Type; + +struct UART_CFG_Type { + uint32_t uartClk; + uint32_t baudRate; + enum UART_DataBits_Type dataBits; + enum UART_StopBits_Type stopBits; + enum UART_Parity_Type parity; + enum BL_Fun_Type ctsFlowControl; + enum BL_Fun_Type rxDeglitch; + enum BL_Fun_Type rtsSoftwareControl; + enum UART_ByteBitInverse_Type byteBitInverse; + undefined field_0xf; +}; + +typedef struct UART_FifoCfg_Type UART_FifoCfg_Type, *PUART_FifoCfg_Type; + +struct UART_FifoCfg_Type { + uint8_t txFifoDmaThreshold; + uint8_t rxFifoDmaThreshold; + enum BL_Fun_Type txFifoDmaEnable; + enum BL_Fun_Type rxFifoDmaEnable; +}; + +typedef enum UART_ID_Type { + UART0_ID=0, + UART1_ID=1, + UART_ID_MAX=2 +} UART_ID_Type; + +typedef enum UART_AutoBaudDetection_Type { + UART_AUTOBAUD_0X55=0, + UART_AUTOBAUD_STARTBIT=1 +} UART_AutoBaudDetection_Type; + +typedef enum UART_Direction_Type { + UART_RX=1, + UART_TX=0, + UART_TXRX=2 +} UART_Direction_Type; + +typedef enum UART_Overflow_Type { + UART_RX_OVERFLOW=2, + UART_RX_UNDERFLOW=3, + UART_TX_OVERFLOW=0, + UART_TX_UNDERFLOW=1 +} UART_Overflow_Type; + +typedef struct UART_IrCfg_Type UART_IrCfg_Type, *PUART_IrCfg_Type; + +struct UART_IrCfg_Type { + enum BL_Fun_Type txIrEnable; + enum BL_Fun_Type rxIrEnable; + enum BL_Fun_Type txIrInverse; + enum BL_Fun_Type rxIrInverse; + uint16_t txIrPulseStart; + uint16_t txIrPulseStop; + uint16_t rxIrPulseStart; +}; + +typedef enum UART_INT_Type { + UART_INT_ALL=8, + UART_INT_PCE=5, + UART_INT_RTO=4, + UART_INT_RX_END=1, + UART_INT_RX_FER=7, + UART_INT_RX_FIFO_REQ=3, + UART_INT_TX_END=0, + UART_INT_TX_FER=6, + UART_INT_TX_FIFO_REQ=2 +} UART_INT_Type; + +typedef struct ethhdr ethhdr, *Pethhdr; + +struct ethhdr { + uchar h_dest[6]; + uchar h_source[6]; + __be16 h_proto; +}; + +typedef struct anon_struct.conflict268 anon_struct.conflict268, *Panon_struct.conflict268; + +struct anon_struct.conflict268 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict348 anon_struct.conflict348, *Panon_struct.conflict348; + +struct anon_struct.conflict348 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict265 anon_struct.conflict265, *Panon_struct.conflict265; + +struct anon_struct.conflict265 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict266 anon_struct.conflict266, *Panon_struct.conflict266; + +struct anon_struct.conflict266 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict267 anon_struct.conflict267, *Panon_struct.conflict267; + +struct anon_struct.conflict267 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict344 anon_struct.conflict344, *Panon_struct.conflict344; + +struct anon_struct.conflict344 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef union anon_union.conflict201 anon_union.conflict201, *Panon_union.conflict201; + +union anon_union.conflict201 { + struct anon_struct.conflict324 auth; + struct anon_struct.conflict325 deauth; + struct anon_struct.conflict326 assoc_req; + struct anon_struct.conflict327 assoc_resp; + struct anon_struct.conflict328 reassoc_resp; + struct anon_struct.conflict329 reassoc_req; + struct anon_struct.conflict330 disassoc; + struct anon_struct.conflict331 beacon; + struct anon_struct probe_req; + struct anon_struct.conflict332 probe_resp; +}; + +typedef struct anon_struct.conflict279 anon_struct.conflict279, *Panon_struct.conflict279; + +struct anon_struct.conflict279 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef enum ieee80211_vht_mcs_support { + IEEE80211_VHT_MCS_NOT_SUPPORTED=3, + IEEE80211_VHT_MCS_SUPPORT_0_7=0, + IEEE80211_VHT_MCS_SUPPORT_0_8=1, + IEEE80211_VHT_MCS_SUPPORT_0_9=2 +} ieee80211_vht_mcs_support; + +typedef struct anon_struct.conflict396 anon_struct.conflict396, *Panon_struct.conflict396; + +struct anon_struct.conflict396 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict276 anon_struct.conflict276, *Panon_struct.conflict276; + +struct anon_struct.conflict276 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict397 anon_struct.conflict397, *Panon_struct.conflict397; + +struct anon_struct.conflict397 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict277 anon_struct.conflict277, *Panon_struct.conflict277; + +struct anon_struct.conflict277 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict278 anon_struct.conflict278, *Panon_struct.conflict278; + +struct anon_struct.conflict278 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict399 anon_struct.conflict399, *Panon_struct.conflict399; + +struct anon_struct.conflict399 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef union anon_union.conflict197 anon_union.conflict197, *Panon_union.conflict197; + +union anon_union.conflict197 { + struct anon_struct.conflict262 sta; + struct anon_struct.conflict277 ap; + struct anon_struct.conflict264 ap_vlan; +}; + +typedef union anon_union.conflict194 anon_union.conflict194, *Panon_union.conflict194; + +union anon_union.conflict194 { + struct anon_struct.conflict262 sta; + struct anon_struct.conflict266 ap; + struct anon_struct.conflict264 ap_vlan; +}; + +typedef union anon_union.conflict195 anon_union.conflict195, *Panon_union.conflict195; + +union anon_union.conflict195 { + struct anon_struct.conflict262 sta; + struct anon_struct.conflict268 ap; + struct anon_struct.conflict264 ap_vlan; +}; + +typedef union anon_union.conflict198 anon_union.conflict198, *Panon_union.conflict198; + +union anon_union.conflict198 { + struct anon_struct.conflict262 sta; + struct anon_struct.conflict279 ap; + struct anon_struct.conflict264 ap_vlan; +}; + +typedef struct anon_struct.conflict379 anon_struct.conflict379, *Panon_struct.conflict379; + +struct anon_struct.conflict379 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct txl_frame_desc_tag txl_frame_desc_tag, *Ptxl_frame_desc_tag; + +typedef struct txl_frame_cfm_tag txl_frame_cfm_tag, *Ptxl_frame_cfm_tag; + +struct txl_frame_cfm_tag { + void (* cfm_func)(void *, uint32_t); + void * env; +}; + +struct txl_frame_desc_tag { + struct txdesc txdesc; + struct txl_frame_cfm_tag cfm; + uint8_t type; + _Bool postponed; + _Bool keep_desc; + undefined field_0x2d7; +}; + +typedef struct txl_frame_env_tag txl_frame_env_tag, *Ptxl_frame_env_tag; + +struct txl_frame_env_tag { + struct co_list desc_free; + struct co_list desc_done; +}; + +typedef struct _hbn_type _hbn_type, *P_hbn_type; + +typedef struct _hbn_type hbn_type_t; + +struct _hbn_type { + uint8_t buflen; + uint8_t active; + uint8_t buf[1]; +}; + +typedef struct pro_dev pro_dev, *Ppro_dev; + +typedef struct pro_dev * pro_handle_t; + +typedef struct encrypt encrypt, *Pencrypt; + +typedef struct encrypt * enc_handle_t; + +typedef struct pro_event pro_event, *Ppro_event; + +typedef struct xSTATIC_QUEUE xSTATIC_QUEUE, *PxSTATIC_QUEUE; + +typedef struct xSTATIC_QUEUE StaticQueue_t; + +typedef StaticQueue_t StaticSemaphore_t; + +typedef struct pro_func pro_func, *Ppro_func; + +typedef struct pro_enc_func pro_enc_func, *Ppro_enc_func; + +typedef enum event_type_t { + PROTOCOL_EVENT_CMD=0, + PROTOCOL_EVENT_DATA=1 +} event_type_t; + + +// WARNING! conflicting data type names: /DWARF/FreeRTOS.h/xSTATIC_QUEUE/anon_union_for_u - /DWARF/gatt.c/gatt_find_info_rsp/anon_union_for_u + +struct xSTATIC_QUEUE { + void * pvDummy1[3]; + union anon_union_for_u u; + StaticList_t xDummy3[2]; + UBaseType_t uxDummy4[3]; + uint8_t ucDummy5[2]; + uint8_t ucDummy6; + undefined field_0x47; + UBaseType_t uxDummy8; + uint8_t ucDummy9; + undefined field_0x4d; + undefined field_0x4e; + undefined field_0x4f; +}; + +struct pro_event { + enum event_type_t type; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + int event_id; + void * p_buf; + uint32_t length; +}; + +struct encrypt { + pyld_handle_t pyld_handle; + struct payload pyld; + uint8_t is_head; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; + struct pro_enc_func * pfnc; + void * p_drv; +}; + +struct pro_dev { + enc_handle_t enc_handle; + struct encrypt enc; + uint8_t old_seq; + undefined field_0x21; + undefined field_0x22; + undefined field_0x23; + uint8_t * pyld_buf; + struct pro_event ev; + uint16_t tol_len_now; + uint16_t total_length; + uint16_t mtu; + uint16_t ack_len; + uint8_t * ack_buf; + undefined field_0x44; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + longlong seq_start_ms; + SemaphoreHandle_t xSemaphore; + StaticSemaphore_t xSemaphoreBuffer; + struct pro_func * p_func; + void * p_drv; + undefined field_0xac; + undefined field_0xad; + undefined field_0xae; + undefined field_0xaf; +}; + +struct pro_func { + int (* pfu_bytes_send)(void *, void *, size_t); + int (* pfn_recv_event)(void *, struct pro_event *); +}; + +struct pro_enc_func { + int (* pfn_enc_read)(void *, uint8_t, uint8_t *, uint8_t *, uint8_t *, uint8_t *, size_t); + int (* pfn_enc_write)(void *, uint8_t, uint8_t, uint8_t *, uint8_t *, uint8_t *, uint8_t, int16_t); +}; + +typedef struct general_head general_head, *Pgeneral_head; + +struct general_head { + uint8_t ctrl; + uint8_t seq; + uint16_t frag_ctrl; +}; + + +// WARNING! conflicting data type names: /DWARF/buf.c/net_buf_simple_pull_le16/lexical_block_0/anon_struct_0 - /DWARF/smp.c/smp_sign_buf/lexical_block_0/anon_struct_0 + + +// WARNING! conflicting data type names: /DWARF/buf.c/net_buf_simple_pull_be16/lexical_block_0/anon_struct_0 - /DWARF/smp.c/smp_sign_buf/lexical_block_0/anon_struct_0 + +typedef struct net_buf_pool net_buf_pool, *Pnet_buf_pool; + +typedef struct k_lifo k_lifo, *Pk_lifo; + +typedef struct net_buf_data_alloc net_buf_data_alloc, *Pnet_buf_data_alloc; + +typedef struct net_buf_data_cb net_buf_data_cb, *Pnet_buf_data_cb; + +typedef int s32_t; + +struct k_lifo { + struct k_queue _queue; +}; + +struct net_buf_pool { + struct k_lifo free; + u16_t buf_count; + u16_t uninit_count; + void (* destroy)(struct net_buf *); + struct net_buf_data_alloc * alloc; + struct net_buf * __bufs; +}; + +struct net_buf_data_cb { + u8_t * (* alloc)(struct net_buf *, size_t *, s32_t); + u8_t * (* ref)(struct net_buf *, u8_t *); + void (* unref)(struct net_buf *, u8_t *); +}; + +struct net_buf_data_alloc { + struct net_buf_data_cb * cb; + void * alloc_data; +}; + +typedef struct anon_struct.conflict460 anon_struct.conflict460, *Panon_struct.conflict460; + +struct anon_struct.conflict460 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef union anon_union.conflict10 anon_union.conflict10, *Panon_union.conflict10; + +typedef struct anon_struct.conflict34 anon_struct.conflict34, *Panon_struct.conflict34; + +struct anon_struct.conflict34 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +union anon_union.conflict10 { + struct anon_struct.conflict34 field_0; + struct net_buf_simple b; +}; + +typedef union anon_union.conflict5 anon_union.conflict5, *Panon_union.conflict5; + +union anon_union.conflict5 { + sys_snode_t node; + struct net_buf * frags; +}; + +typedef union anon_union.conflict6 anon_union.conflict6, *Panon_union.conflict6; + +typedef struct anon_struct.conflict26 anon_struct.conflict26, *Panon_struct.conflict26; + +struct anon_struct.conflict26 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +union anon_union.conflict6 { + struct anon_struct.conflict26 field_0; + struct net_buf_simple b; +}; + +typedef union anon_union.conflict7 anon_union.conflict7, *Panon_union.conflict7; + +typedef struct anon_struct.conflict28 anon_struct.conflict28, *Panon_struct.conflict28; + +struct anon_struct.conflict28 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +union anon_union.conflict7 { + struct anon_struct.conflict28 field_0; + struct net_buf_simple b; +}; + +typedef struct anon_struct.conflict477 anon_struct.conflict477, *Panon_struct.conflict477; + +struct anon_struct.conflict477 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict474 anon_struct.conflict474, *Panon_struct.conflict474; + +struct anon_struct.conflict474 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict481 anon_struct.conflict481, *Panon_struct.conflict481; + +struct anon_struct.conflict481 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict488 anon_struct.conflict488, *Panon_struct.conflict488; + +struct anon_struct.conflict488 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict489 anon_struct.conflict489, *Panon_struct.conflict489; + +struct anon_struct.conflict489 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict485 anon_struct.conflict485, *Panon_struct.conflict485; + +struct anon_struct.conflict485 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict486 anon_struct.conflict486, *Panon_struct.conflict486; + +struct anon_struct.conflict486 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict487 anon_struct.conflict487, *Panon_struct.conflict487; + +struct anon_struct.conflict487 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict491 anon_struct.conflict491, *Panon_struct.conflict491; + +struct anon_struct.conflict491 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict493 anon_struct.conflict493, *Panon_struct.conflict493; + +struct anon_struct.conflict493 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict490 anon_struct.conflict490, *Panon_struct.conflict490; + +struct anon_struct.conflict490 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict495 anon_struct.conflict495, *Panon_struct.conflict495; + +struct anon_struct.conflict495 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict422 anon_struct.conflict422, *Panon_struct.conflict422; + +struct anon_struct.conflict422 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict420 anon_struct.conflict420, *Panon_struct.conflict420; + +struct anon_struct.conflict420 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict429 anon_struct.conflict429, *Panon_struct.conflict429; + +struct anon_struct.conflict429 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict435 anon_struct.conflict435, *Panon_struct.conflict435; + +struct anon_struct.conflict435 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict438 anon_struct.conflict438, *Panon_struct.conflict438; + +struct anon_struct.conflict438 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict33 anon_struct.conflict33, *Panon_struct.conflict33; + +struct anon_struct.conflict33 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct net_buf_pool_fixed net_buf_pool_fixed, *Pnet_buf_pool_fixed; + +struct net_buf_pool_fixed { + size_t data_size; + u8_t * data_pool; +}; + +typedef struct anon_struct.conflict444 anon_struct.conflict444, *Panon_struct.conflict444; + +struct anon_struct.conflict444 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict446 anon_struct.conflict446, *Panon_struct.conflict446; + +struct anon_struct.conflict446 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict441 anon_struct.conflict441, *Panon_struct.conflict441; + +struct anon_struct.conflict441 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict449 anon_struct.conflict449, *Panon_struct.conflict449; + +struct anon_struct.conflict449 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict27 anon_struct.conflict27, *Panon_struct.conflict27; + +struct anon_struct.conflict27 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict25 anon_struct.conflict25, *Panon_struct.conflict25; + +struct anon_struct.conflict25 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict455 anon_struct.conflict455, *Panon_struct.conflict455; + +struct anon_struct.conflict455 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict452 anon_struct.conflict452, *Panon_struct.conflict452; + +struct anon_struct.conflict452 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict507 anon_struct.conflict507, *Panon_struct.conflict507; + +struct anon_struct.conflict507 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict503 anon_struct.conflict503, *Panon_struct.conflict503; + +struct anon_struct.conflict503 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict505 anon_struct.conflict505, *Panon_struct.conflict505; + +struct anon_struct.conflict505 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict512 anon_struct.conflict512, *Panon_struct.conflict512; + +struct anon_struct.conflict512 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict519 anon_struct.conflict519, *Panon_struct.conflict519; + +struct anon_struct.conflict519 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict514 anon_struct.conflict514, *Panon_struct.conflict514; + +struct anon_struct.conflict514 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict515 anon_struct.conflict515, *Panon_struct.conflict515; + +struct anon_struct.conflict515 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict521 anon_struct.conflict521, *Panon_struct.conflict521; + +struct anon_struct.conflict521 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict524 anon_struct.conflict524, *Panon_struct.conflict524; + +struct anon_struct.conflict524 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict520 anon_struct.conflict520, *Panon_struct.conflict520; + +struct anon_struct.conflict520 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict408 anon_struct.conflict408, *Panon_struct.conflict408; + +struct anon_struct.conflict408 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict414 anon_struct.conflict414, *Panon_struct.conflict414; + +struct anon_struct.conflict414 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef enum bt_buf_type { + BT_BUF_ACL_IN=3, + BT_BUF_ACL_OUT=2, + BT_BUF_CMD=0, + BT_BUF_EVT=1 +} bt_buf_type; + +typedef struct mbedtls_rsa_context mbedtls_rsa_context, *Pmbedtls_rsa_context; + +struct mbedtls_rsa_context { + int ver; + size_t len; + struct mbedtls_mpi N; + struct mbedtls_mpi E; + struct mbedtls_mpi D; + struct mbedtls_mpi P; + struct mbedtls_mpi Q; + struct mbedtls_mpi DP; + struct mbedtls_mpi DQ; + struct mbedtls_mpi QP; + struct mbedtls_mpi RN; + struct mbedtls_mpi RP; + struct mbedtls_mpi RQ; + struct mbedtls_mpi Vi; + struct mbedtls_mpi Vf; + int padding; + int hash_id; +}; + +typedef struct cfg_start_req cfg_start_req, *Pcfg_start_req; + +struct cfg_start_req { // Missing member u : anon_union_for_u at offset 0x4 [exceeds parent struct len] + uint32_t ops; +}; + +typedef struct anon_struct.conflict258 anon_struct.conflict258, *Panon_struct.conflict258; + +struct anon_struct.conflict258 { + uint32_t task; + uint32_t element; +}; + +typedef struct cfg_start_cfm cfg_start_cfm, *Pcfg_start_cfm; + +struct cfg_start_cfm { + uint8_t status; +}; + +typedef struct anon_struct.conflict187 anon_struct.conflict187, *Panon_struct.conflict187; + +struct anon_struct.conflict187 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef union anon_union.conflict192 anon_union.conflict192, *Panon_union.conflict192; + +union anon_union.conflict192 { + undefined1 get; // Data type larger than union's declared size: anon_struct[1] + undefined1 reset; // Data type larger than union's declared size: anon_struct[1] + undefined1 set; // Data type larger than union's declared size: anon_struct[1] +}; + +typedef enum cfg_msg_tag { + CFG_MAX=12290, + CFG_START_CFM=12289, + CFG_START_REQ=12288 +} cfg_msg_tag; + +typedef struct anon_struct.conflict257 anon_struct.conflict257, *Panon_struct.conflict257; + +struct anon_struct.conflict257 { + uint32_t task; + uint32_t element; +}; + +typedef struct anon_struct.conflict259 anon_struct.conflict259, *Panon_struct.conflict259; + +struct anon_struct.conflict259 { + uint32_t task; + uint32_t element; + uint32_t type; + uint32_t length; + uint32_t[0] buf; +}; + +typedef enum cfg_state_tag { + CFG_IDLE=0, + CFG_STATE_MAX=1 +} cfg_state_tag; + +typedef struct anon_struct.conflict253 anon_struct.conflict253, *Panon_struct.conflict253; + +struct anon_struct.conflict253 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct anon_struct.conflict254 anon_struct.conflict254, *Panon_struct.conflict254; + +struct anon_struct.conflict254 { + uint32_t task; + uint32_t element; +}; + +typedef struct anon_struct.conflict255 anon_struct.conflict255, *Panon_struct.conflict255; + +struct anon_struct.conflict255 { + uint32_t task; + uint32_t element; +}; + +typedef struct anon_struct.conflict256 anon_struct.conflict256, *Panon_struct.conflict256; + +struct anon_struct.conflict256 { + uint32_t task; + uint32_t element; + uint32_t type; + uint32_t length; + uint32_t[0] buf; +}; + +typedef union tcp_listen_pcbs_t tcp_listen_pcbs_t, *Ptcp_listen_pcbs_t; + +union tcp_listen_pcbs_t { + struct tcp_pcb_listen * listen_pcbs; + struct tcp_pcb * pcbs; +}; + +typedef union anon_union.conflict36 anon_union.conflict36, *Panon_union.conflict36; + +union anon_union.conflict36 { + uint32 Interface; + struct cm_ConnectionInfo * connPtr; +}; + +typedef struct TIMER_CFG_Type TIMER_CFG_Type, *PTIMER_CFG_Type; + +typedef enum TIMER_Chan_Type { + TIMER_CH0=0, + TIMER_CH1=1, + TIMER_CH_MAX=2 +} TIMER_Chan_Type; + +typedef enum TIMER_ClkSrc_Type { + TIMER_CLKSRC_1K=2, + TIMER_CLKSRC_32K=1, + TIMER_CLKSRC_FCLK=0, + TIMER_CLKSRC_XTAL=3 +} TIMER_ClkSrc_Type; + +typedef enum TIMER_PreLoad_Trig_Type { + TIMER_PRELOAD_TRIG_COMP0=1, + TIMER_PRELOAD_TRIG_COMP1=2, + TIMER_PRELOAD_TRIG_COMP2=3, + TIMER_PRELOAD_TRIG_NONE=0 +} TIMER_PreLoad_Trig_Type; + +typedef enum TIMER_CountMode_Type { + TIMER_COUNT_FREERUN=1, + TIMER_COUNT_PRELOAD=0 +} TIMER_CountMode_Type; + +struct TIMER_CFG_Type { + enum TIMER_Chan_Type timerCh; + enum TIMER_ClkSrc_Type clkSrc; + enum TIMER_PreLoad_Trig_Type plTrigSrc; + enum TIMER_CountMode_Type countMode; + uint8_t clockDivision; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t matchVal0; + uint32_t matchVal1; + uint32_t matchVal2; + uint32_t preLoadVal; +}; + +typedef enum WDT_INT_Type { + WDT_INT=0, + WDT_INT_ALL=1 +} WDT_INT_Type; + +typedef enum TIMER_INT_Type { + TIMER_INT_ALL=3, + TIMER_INT_COMP_0=0, + TIMER_INT_COMP_1=1, + TIMER_INT_COMP_2=2 +} TIMER_INT_Type; + +typedef enum TIMER_Comp_ID_Type { + TIMER_COMP_ID_0=0, + TIMER_COMP_ID_1=1, + TIMER_COMP_ID_2=2 +} TIMER_Comp_ID_Type; + +typedef struct DMA_LLI_Ctrl_Type DMA_LLI_Ctrl_Type, *PDMA_LLI_Ctrl_Type; + +typedef struct DMA_Control_Reg.conflict DMA_Control_Reg.conflict, *PDMA_Control_Reg.conflict; + +struct DMA_Control_Reg.conflict { + uint32_t TransferSize:12; + uint32_t SBSize:3; + uint32_t DBSize:3; + uint32_t SWidth:3; + uint32_t DWidth:3; + uint32_t SLargerD:1; + uint32_t reserved_25:1; + uint32_t SI:1; + uint32_t DI:1; + uint32_t Prot:3; + uint32_t I:1; +}; + +struct DMA_LLI_Ctrl_Type { + uint32_t srcDmaAddr; + uint32_t destDmaAddr; + uint32_t nextLLI; + struct DMA_Control_Reg.conflict dmaCtrl; +}; + +typedef enum DMA_Trans_Dir_Type { + DMA_TRNS_M2M=0, + DMA_TRNS_M2P=1, + DMA_TRNS_P2M=2, + DMA_TRNS_P2P=3 +} DMA_Trans_Dir_Type; + +typedef enum DMA_Burst_Size_Type { + DMA_BURST_SIZE_1=0, + DMA_BURST_SIZE_16=3, + DMA_BURST_SIZE_4=1, + DMA_BURST_SIZE_8=2 +} DMA_Burst_Size_Type; + +typedef struct DMA_LLI_Ctrl_Type.conflict DMA_LLI_Ctrl_Type.conflict, *PDMA_LLI_Ctrl_Type.conflict; + +typedef struct DMA_Control_Reg.conflict1 DMA_Control_Reg.conflict1, *PDMA_Control_Reg.conflict1; + +struct DMA_Control_Reg.conflict1 { + uint32_t TransferSize:12; + uint32_t SBSize:3; + uint32_t DBSize:3; + uint32_t SWidth:3; + uint32_t DWidth:3; + uint32_t SLargerD:1; + uint32_t reserved_25:1; + uint32_t SI:1; + uint32_t DI:1; + uint32_t Prot:3; + uint32_t I:1; +}; + +struct DMA_LLI_Ctrl_Type.conflict { + uint32_t srcDmaAddr; + uint32_t destDmaAddr; + uint32_t nextLLI; + struct DMA_Control_Reg.conflict1 dmaCtrl; +}; + +typedef struct DMA_LLI_Ctrl_Type.conflict1 DMA_LLI_Ctrl_Type.conflict1, *PDMA_LLI_Ctrl_Type.conflict1; + +typedef struct DMA_Control_Reg.conflict2 DMA_Control_Reg.conflict2, *PDMA_Control_Reg.conflict2; + +struct DMA_Control_Reg.conflict2 { + uint32_t TransferSize:12; + uint32_t SBSize:3; + uint32_t DBSize:3; + uint32_t SWidth:3; + uint32_t DWidth:3; + uint32_t SLargerD:1; + uint32_t reserved_25:1; + uint32_t SI:1; + uint32_t DI:1; + uint32_t Prot:3; + uint32_t I:1; +}; + +struct DMA_LLI_Ctrl_Type.conflict1 { + uint32_t srcDmaAddr; + uint32_t destDmaAddr; + uint32_t nextLLI; + struct DMA_Control_Reg.conflict2 dmaCtrl; +}; + +typedef enum DMA_Chan_Type { + DMA_CH0=0, + DMA_CH1=1, + DMA_CH2=2, + DMA_CH3=3, + DMA_CH_MAX=4 +} DMA_Chan_Type; + +typedef struct DMA_LLI_PP_Buf DMA_LLI_PP_Buf, *PDMA_LLI_PP_Buf; + +struct DMA_LLI_PP_Buf { + uint8_t idleIndex; + uint8_t dmaChan; + undefined field_0x2; + undefined field_0x3; + struct DMA_LLI_Ctrl_Type * lliListHeader[2]; + void (* onTransCompleted)(struct DMA_LLI_Ctrl_Type *); +}; + +typedef struct DMA_LLI_PP_Struct DMA_LLI_PP_Struct, *PDMA_LLI_PP_Struct; + +typedef struct DMA_Control_Reg DMA_Control_Reg, *PDMA_Control_Reg; + +typedef struct DMA_LLI_Cfg_Type DMA_LLI_Cfg_Type, *PDMA_LLI_Cfg_Type; + +typedef enum DMA_Periph_Req_Type { + DMA_REQ_GPADC0=22, + DMA_REQ_GPADC1=23, + DMA_REQ_I2C_RX=6, + DMA_REQ_I2C_TX=7, + DMA_REQ_NONE=0, + DMA_REQ_SPI_RX=10, + DMA_REQ_SPI_TX=11, + DMA_REQ_UART0_RX=0, + DMA_REQ_UART0_TX=1, + DMA_REQ_UART1_RX=2, + DMA_REQ_UART1_TX=3 +} DMA_Periph_Req_Type; + +struct DMA_LLI_Cfg_Type { + enum DMA_Trans_Dir_Type dir; + enum DMA_Periph_Req_Type srcPeriph; + enum DMA_Periph_Req_Type dstPeriph; +}; + +struct DMA_Control_Reg { + uint32_t TransferSize:12; + uint32_t SBSize:3; + uint32_t DBSize:3; + uint32_t SWidth:3; + uint32_t DWidth:3; + uint32_t SLargerD:1; + uint32_t reserved_25:1; + uint32_t SI:1; + uint32_t DI:1; + uint32_t Prot:3; + uint32_t I:1; +}; + +struct DMA_LLI_PP_Struct { + uint8_t trans_index; + uint8_t dmaChan; + undefined field_0x2; + undefined field_0x3; + struct DMA_Control_Reg dmaCtrlRegVal; + struct DMA_LLI_Cfg_Type * DMA_LLI_Cfg; + uint32_t operatePeriphAddr; + uint32_t chache_buf_addr[2]; + enum BL_Fun_Type is_single_mode; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; +}; + +typedef enum DMA_INT_Type { + DMA_INT_ALL=2, + DMA_INT_ERR=1, + DMA_INT_TCOMPLETED=0 +} DMA_INT_Type; + +typedef struct DMA_Channel_Cfg_Type DMA_Channel_Cfg_Type, *PDMA_Channel_Cfg_Type; + +typedef enum DMA_Trans_Width_Type { + DMA_TRNS_WIDTH_16BITS=1, + DMA_TRNS_WIDTH_32BITS=2, + DMA_TRNS_WIDTH_8BITS=0 +} DMA_Trans_Width_Type; + +struct DMA_Channel_Cfg_Type { + uint32_t srcDmaAddr; + uint32_t destDmaAddr; + uint32_t transfLength; + enum DMA_Trans_Dir_Type dir; + enum DMA_Chan_Type ch; + enum DMA_Trans_Width_Type srcTransfWidth; + enum DMA_Trans_Width_Type dstTransfWidth; + enum DMA_Burst_Size_Type srcBurstSzie; + enum DMA_Burst_Size_Type dstBurstSzie; + uint8_t srcAddrInc; + uint8_t destAddrInc; + enum DMA_Periph_Req_Type srcPeriph; + enum DMA_Periph_Req_Type dstPeriph; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct anon_struct.conflict580 anon_struct.conflict580, *Panon_struct.conflict580; + +struct anon_struct.conflict580 { + uint frac:23; + uint exp:8; + uint sign:1; +}; + +typedef union _FP_UNION_S _FP_UNION_S, *P_FP_UNION_S; + +union _FP_UNION_S { + SFtype flt; + struct anon_struct.conflict580 bits; +}; + +typedef enum BL_Sts_Type { + RESET=0, + SET=1 +} BL_Sts_Type; + +typedef enum BL_Err_Type { + ERROR=1, + SUCCESS=0, + TIMEOUT=2 +} BL_Err_Type; + +typedef enum BL_Mask_Type { + MASK=1, + UNMASK=0 +} BL_Mask_Type; + +typedef struct scan_start_req scan_start_req, *Pscan_start_req; + +struct scan_start_req { + struct scan_chan_tag chan[42]; + struct mac_ssid ssid[2]; + struct mac_addr bssid; + undefined field_0x146; + undefined field_0x147; + uint32_t add_ies; + uint16_t add_ie_len; + uint8_t vif_idx; + uint8_t chan_cnt; + uint8_t ssid_cnt; + _Bool no_cck; + undefined field_0x152; + undefined field_0x153; +}; + +typedef struct scan_cancel_cfm scan_cancel_cfm, *Pscan_cancel_cfm; + +struct scan_cancel_cfm { + uint8_t status; +}; + +typedef struct scan_start_cfm scan_start_cfm, *Pscan_start_cfm; + +struct scan_start_cfm { + uint8_t status; +}; + +typedef enum scan_state_tag { + SCAN_IDLE=0, + SCAN_STATE_MAX=4, + SCAN_WAIT_BEACON_PROBE_RSP=3, + SCAN_WAIT_CHANNEL=2, + SCAN_WAIT_IE_DWNLD=1 +} scan_state_tag; + +typedef enum scan_msg_tag { + SCAN_CANCEL_CFM=2052, + SCAN_CANCEL_REQ=2051, + SCAN_DONE_IND=2050, + SCAN_MAX=2054, + SCAN_START_CFM=2049, + SCAN_START_REQ=2048, + SCAN_TIMER=2053 +} scan_msg_tag; + +typedef struct anon_struct.conflict466 anon_struct.conflict466, *Panon_struct.conflict466; + +struct anon_struct.conflict466 { + void (* func)(u8_t *); + u16_t len; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict467 anon_struct.conflict467, *Panon_struct.conflict467; + +struct anon_struct.conflict467 { + void (* func)(u8_t *); + u16_t len; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict468 anon_struct.conflict468, *Panon_struct.conflict468; + +struct anon_struct.conflict468 { + void (* func)(u8_t *); + u16_t len; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict469 anon_struct.conflict469, *Panon_struct.conflict469; + +struct anon_struct.conflict469 { + void (* func)(u8_t *); + u16_t len; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict464 anon_struct.conflict464, *Panon_struct.conflict464; + +struct anon_struct.conflict464 { + u8_t id; + u8_t prev_id; + u8_t seg; + u8_t last_seg; + u8_t fcs; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + struct net_buf_simple * buf; +}; + +typedef struct anon_struct.conflict465 anon_struct.conflict465, *Panon_struct.conflict465; + +struct anon_struct.conflict465 { + s64_t start; + u8_t id; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + struct net_buf * buf[3]; + struct k_delayed_work retransmit; + undefined field_0x3c; + undefined field_0x3d; + undefined field_0x3e; + undefined field_0x3f; +}; + +typedef struct prov_rx prov_rx, *Pprov_rx; + +struct prov_rx { + u32_t.conflict link_id; + u8_t xact_id; + u8_t gpc; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict470 anon_struct.conflict470, *Panon_struct.conflict470; + +struct anon_struct.conflict470 { + void (* func)(struct prov_rx *, struct net_buf_simple *); + _Bool require_link; + u8_t min_len; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict471 anon_struct.conflict471, *Panon_struct.conflict471; + +struct anon_struct.conflict471 { + void (* func)(struct prov_rx *, struct net_buf_simple *); + _Bool require_link; + u8_t min_len; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict472 anon_struct.conflict472, *Panon_struct.conflict472; + +struct anon_struct.conflict472 { + void (* func)(struct prov_rx *, struct net_buf_simple *); + _Bool require_link; + u8_t min_len; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict473 anon_struct.conflict473, *Panon_struct.conflict473; + +struct anon_struct.conflict473 { + void (* func)(struct prov_rx *, struct net_buf_simple *); + _Bool require_link; + u8_t min_len; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct prov_link prov_link, *Pprov_link; + +typedef struct anon_struct_for_rx anon_struct_for_rx, *Panon_struct_for_rx; + +typedef struct anon_struct_for_tx anon_struct_for_tx, *Panon_struct_for_tx; + +struct anon_struct_for_tx { + s64_t start; + u8_t id; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + struct net_buf * buf[3]; + struct k_delayed_work retransmit; + undefined field_0x3c; + undefined field_0x3d; + undefined field_0x3e; + undefined field_0x3f; +}; + +struct anon_struct_for_rx { + u8_t id; + u8_t prev_id; + u8_t seg; + u8_t last_seg; + u8_t fcs; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + struct net_buf_simple * buf; +}; + +struct prov_link { + atomic_t flags[1]; + struct bt_conn * conn; + u8_t dhkey[32]; + u8_t expect; + u8_t oob_method; + u8_t oob_action; + u8_t oob_size; + u8_t conf[16]; + u8_t rand[16]; + u8_t auth[16]; + u8_t conf_salt[16]; + u8_t conf_key[16]; + u8_t conf_inputs[145]; + u8_t prov_salt[16]; + undefined field_0x11d; + undefined field_0x11e; + undefined field_0x11f; + u32_t.conflict id; + struct anon_struct_for_rx rx; + struct anon_struct_for_tx tx; + struct k_delayed_work prot_timer; + undefined field_0x194; + undefined field_0x195; + undefined field_0x196; + undefined field_0x197; +}; + +typedef enum task_mm_cfg { + TASK_MM_CFG_KEEP_ALIVE_PACKET_COUNTER=2, + TASK_MM_CFG_KEEP_ALIVE_STATUS_ENABLED=0, + TASK_MM_CFG_KEEP_ALIVE_TIME_LAST_RECEIVED=1 +} task_mm_cfg; + +typedef struct mm_timer_env_tag mm_timer_env_tag, *Pmm_timer_env_tag; + +struct mm_timer_env_tag { + struct co_list prog; +}; + +typedef enum dbg_sev_tag { + DBG_SEV_ALL=7, + DBG_SEV_IDX_CRT=1, + DBG_SEV_IDX_ERR=2, + DBG_SEV_IDX_INF=4, + DBG_SEV_IDX_MAX=6, + DBG_SEV_IDX_NONE=0, + DBG_SEV_IDX_VRB=5, + DBG_SEV_IDX_WRN=3 +} dbg_sev_tag; + +typedef struct debug_env_tag debug_env_tag, *Pdebug_env_tag; + +struct debug_env_tag { + uint32_t filter_module; + uint32_t filter_severity; +}; + +typedef enum dbg_mod_tag { + DBG_MOD_IDX_DBG=1, + DBG_MOD_IDX_DMA=3, + DBG_MOD_IDX_IPC=2, + DBG_MOD_IDX_KE=0, + DBG_MOD_IDX_MAX=8, + DBG_MOD_IDX_MM=4, + DBG_MOD_IDX_PHY=7, + DBG_MOD_IDX_RX=6, + DBG_MOD_IDX_TX=5 +} dbg_mod_tag; + +typedef enum mbedtls_cipher_padding_t { + MBEDTLS_PADDING_NONE=4, + MBEDTLS_PADDING_ONE_AND_ZEROS=1, + MBEDTLS_PADDING_PKCS7=0, + MBEDTLS_PADDING_ZEROS=3, + MBEDTLS_PADDING_ZEROS_AND_LEN=2 +} mbedtls_cipher_padding_t; + +typedef struct anon_struct.conflict537 anon_struct.conflict537, *Panon_struct.conflict537; + +typedef void (* tcpip_callback_fn)(void *); + +struct anon_struct.conflict537 { + tcpip_callback_fn function; + void * msg; +}; + +typedef struct anon_struct.conflict538 anon_struct.conflict538, *Panon_struct.conflict538; + +typedef struct tcpip_api_call_data tcpip_api_call_data, *Ptcpip_api_call_data; + +struct anon_struct.conflict538 { + err_t (* function)(struct tcpip_api_call_data *); + struct tcpip_api_call_data * arg; + sys_sem_t * sem; +}; + +struct tcpip_api_call_data { + err_t err; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + sys_sem_t sem; +}; + +typedef struct anon_struct.conflict539 anon_struct.conflict539, *Panon_struct.conflict539; + +struct anon_struct.conflict539 { + struct pbuf * p; + struct netif * netif; + err_t (* input_fn)(struct pbuf *, struct netif *); +}; + +typedef struct tcpip_msg tcpip_msg, *Ptcpip_msg; + +typedef enum tcpip_msg_type { + TCPIP_MSG_API=0, + TCPIP_MSG_API_CALL=1, + TCPIP_MSG_CALLBACK=3, + TCPIP_MSG_CALLBACK_STATIC=4, + TCPIP_MSG_INPKT=2 +} tcpip_msg_type; + + +// WARNING! conflicting data type names: /DWARF/tcpip_priv.h/tcpip_msg/anon_union_for_msg - /DWARF/api_msg.h/api_msg/anon_union_for_msg + +struct tcpip_msg { + enum tcpip_msg_type type; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + union anon_union_for_msg msg; +}; + +typedef struct anon_struct.conflict540 anon_struct.conflict540, *Panon_struct.conflict540; + +struct anon_struct.conflict540 { + tcpip_callback_fn function; + void * ctx; +}; + +typedef struct dhcp_server dhcp_server, *Pdhcp_server; + +typedef struct dhcp_client_node dhcp_client_node, *Pdhcp_client_node; + +struct dhcp_server { + struct dhcp_server * next; + struct netif * netif; + struct udp_pcb * pcb; + struct dhcp_client_node * node_list; + ip4_addr_t start; + ip4_addr_t end; + ip4_addr_t current; +}; + +struct dhcp_client_node { + struct dhcp_client_node * next; + u8_t chaddr[6]; + undefined field_0xa; + undefined field_0xb; + ip4_addr_t ipaddr; + u32_t lease_end; +}; + +typedef struct eth_addr eth_addr, *Peth_addr; + +struct eth_addr { + u8_t addr[6]; +}; + +typedef struct eth_hdr.conflict eth_hdr.conflict, *Peth_hdr.conflict; + +struct eth_hdr.conflict { + struct eth_addr dest; + struct eth_addr src; + u16_t type; +}; + +typedef struct at_test_para_t at_test_para_t, *Pat_test_para_t; + +struct at_test_para_t { + int arg1; + at_text_t arg2[64]; +}; + +typedef struct tc_cmac_struct tc_cmac_struct, *Ptc_cmac_struct; + +struct tc_cmac_struct { + uint8_t iv[16]; + uint8_t K1[16]; + uint8_t K2[16]; + uint8_t leftover[16]; + uint keyid; + uint leftover_offset; + TCAesKeySched_t sched; + undefined field_0x4c; + undefined field_0x4d; + undefined field_0x4e; + undefined field_0x4f; + uint64_t countdown; +}; + +typedef struct tc_cmac_struct * TCCmacState_t; + +typedef void (* tcp_err_fn.conflict)(void *, err_t); + +typedef struct tcp_pcb.conflict tcp_pcb.conflict, *Ptcp_pcb.conflict; + +struct tcp_pcb.conflict { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict11 tcp_pcb.conflict11, *Ptcp_pcb.conflict11; + +struct tcp_pcb.conflict11 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict10 tcp_pcb.conflict10, *Ptcp_pcb.conflict10; + +struct tcp_pcb.conflict10 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict14 tcp_pcb.conflict14, *Ptcp_pcb.conflict14; + +struct tcp_pcb.conflict14 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + tcp_err_fn.conflict errf; + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict13 tcp_pcb.conflict13, *Ptcp_pcb.conflict13; + +struct tcp_pcb.conflict13 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict12 tcp_pcb.conflict12, *Ptcp_pcb.conflict12; + +struct tcp_pcb.conflict12 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict9 tcp_pcb.conflict9, *Ptcp_pcb.conflict9; + +struct tcp_pcb.conflict9 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict7 tcp_pcb.conflict7, *Ptcp_pcb.conflict7; + +struct tcp_pcb.conflict7 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict8 tcp_pcb.conflict8, *Ptcp_pcb.conflict8; + +struct tcp_pcb.conflict8 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict1 tcp_pcb.conflict1, *Ptcp_pcb.conflict1; + +struct tcp_pcb.conflict1 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict2 tcp_pcb.conflict2, *Ptcp_pcb.conflict2; + +struct tcp_pcb.conflict2 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict5 tcp_pcb.conflict5, *Ptcp_pcb.conflict5; + +struct tcp_pcb.conflict5 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict6 tcp_pcb.conflict6, *Ptcp_pcb.conflict6; + +struct tcp_pcb.conflict6 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict3 tcp_pcb.conflict3, *Ptcp_pcb.conflict3; + +struct tcp_pcb.conflict3 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict4 tcp_pcb.conflict4, *Ptcp_pcb.conflict4; + +struct tcp_pcb.conflict4 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct iperf_server_udp_ctx iperf_server_udp_ctx, *Piperf_server_udp_ctx; + +struct iperf_server_udp_ctx { + int exit_flag; + uint32_t datagram_cnt; + int32_t packet_id; + uint32_t out_of_order_cnt; + uint32_t error_cnt; + uint32_t out_of_order_curr; + uint32_t receive_start; + uint32_t period_start; + uint32_t current; + undefined field_0x24; + undefined field_0x25; + undefined field_0x26; + undefined field_0x27; + uint64_t recv_total_len; + uint64_t recv_now; + float f_min; + float f_max; +}; + +typedef struct UDP_datagram UDP_datagram, *PUDP_datagram; + +struct UDP_datagram { + uint32_t id; + uint32_t tv_sec; + uint32_t tv_usec; +}; + +typedef struct server_hdr_v1 server_hdr_v1, *Pserver_hdr_v1; + +typedef struct server_hdr_v1 server_hdr; + +struct server_hdr_v1 { + int32_t flags; + int32_t total_len1; + int32_t total_len2; + int32_t stop_sec; + int32_t stop_usec; + int32_t error_cnt; + int32_t outorder_cnt; + int32_t datagrams; + int32_t jitter1; + int32_t jitter2; +}; + +typedef struct cm_ConnectionInfo cm_ConnectionInfo_t; + +typedef union anon_union.conflict138 anon_union.conflict138, *Panon_union.conflict138; + +union anon_union.conflict138 { + struct apSpecificData_t apData; +}; + +typedef union anon_union.conflict134 anon_union.conflict134, *Panon_union.conflict134; + +union anon_union.conflict134 { + struct apSpecificData_t apData; +}; + +typedef union anon_union.conflict39 anon_union.conflict39, *Panon_union.conflict39; + +union anon_union.conflict39 { + struct apSpecificData_t apData; +}; + +typedef union anon_union.conflict191 anon_union.conflict191, *Panon_union.conflict191; + +union anon_union.conflict191 { + struct apSpecificData_t apData; +}; + +typedef union anon_union.conflict109 anon_union.conflict109, *Panon_union.conflict109; + +union anon_union.conflict109 { + struct apSpecificData_t apData; +}; + +typedef union anon_union.conflict143 anon_union.conflict143, *Panon_union.conflict143; + +union anon_union.conflict143 { + struct apSpecificData_t apData; +}; + +typedef struct rc4_key rc4_key, *Prc4_key; + +struct rc4_key { + uchar state[256]; + uchar x; + uchar y; +}; + +typedef struct llcp_start_enc_req llcp_start_enc_req, *Pllcp_start_enc_req; + +struct llcp_start_enc_req { + uint8_t opcode; +}; + +typedef struct llcp_con_param_req llcp_con_param_req, *Pllcp_con_param_req; + +struct llcp_con_param_req { + uint8_t opcode; + undefined field_0x1; + uint16_t interval_min; + uint16_t interval_max; + uint16_t latency; + uint16_t timeout; + uint8_t pref_period; + undefined field_0xb; + uint16_t ref_con_event_count; + uint16_t offset0; + uint16_t offset1; + uint16_t offset2; + uint16_t offset3; + uint16_t offset4; + uint16_t offset5; +}; + +typedef struct llcp_pause_enc_rsp llcp_pause_enc_rsp, *Pllcp_pause_enc_rsp; + +struct llcp_pause_enc_rsp { + uint8_t opcode; +}; + +typedef struct llcp_channel_map_ind llcp_channel_map_ind, *Pllcp_channel_map_ind; + +struct llcp_channel_map_ind { + uint8_t opcode; + struct le_chnl_map ch_map; + uint16_t instant; +}; + +typedef struct llcp_enc_req llcp_enc_req, *Pllcp_enc_req; + +struct llcp_enc_req { + uint8_t opcode; + struct rand_nb rand; + uint8_t ediv[2]; + struct sess_k_div_x skdm; + struct init_vect ivm; +}; + +typedef struct llcp_slave_feature_req llcp_slave_feature_req, *Pllcp_slave_feature_req; + +struct llcp_slave_feature_req { + uint8_t opcode; + struct le_features feats; +}; + +typedef struct llcp_length_rsp llcp_length_rsp, *Pllcp_length_rsp; + +struct llcp_length_rsp { + uint8_t opcode; + undefined field_0x1; + uint16_t max_rx_octets; + uint16_t max_rx_time; + uint16_t max_tx_octets; + uint16_t max_tx_time; +}; + +typedef struct llcp_terminate_ind llcp_terminate_ind, *Pllcp_terminate_ind; + +struct llcp_terminate_ind { + uint8_t opcode; + uint8_t err_code; +}; + +typedef struct llcp_feats_rsp llcp_feats_rsp, *Pllcp_feats_rsp; + +struct llcp_feats_rsp { + uint8_t opcode; + struct le_features feats; +}; + +typedef struct llcp_enc_rsp llcp_enc_rsp, *Pllcp_enc_rsp; + +struct llcp_enc_rsp { + uint8_t opcode; + struct sess_k_div_x skds; + struct init_vect ivs; +}; + +typedef struct llcp_start_enc_rsp llcp_start_enc_rsp, *Pllcp_start_enc_rsp; + +struct llcp_start_enc_rsp { + uint8_t opcode; +}; + +typedef struct llcp_unknown_rsp llcp_unknown_rsp, *Pllcp_unknown_rsp; + +struct llcp_unknown_rsp { + uint8_t opcode; + uint8_t unk_type; +}; + +typedef enum co_llcp_opcode { + LLCP_CHANNEL_MAP_IND_OPCODE=1, + LLCP_CONNECTION_PARAM_REQ_OPCODE=15, + LLCP_CONNECTION_PARAM_RSP_OPCODE=16, + LLCP_CONNECTION_UPDATE_IND_OPCODE=0, + LLCP_ENC_REQ_OPCODE=3, + LLCP_ENC_RSP_OPCODE=4, + LLCP_FEATURE_REQ_OPCODE=8, + LLCP_FEATURE_RSP_OPCODE=9, + LLCP_LENGTH_REQ_OPCODE=20, + LLCP_LENGTH_RSP_OPCODE=21, + LLCP_OPCODE_MAX_OPCODE=22, + LLCP_PAUSE_ENC_REQ_OPCODE=10, + LLCP_PAUSE_ENC_RSP_OPCODE=11, + LLCP_PING_REQ_OPCODE=18, + LLCP_PING_RSP_OPCODE=19, + LLCP_REJECT_IND_EXT_OPCODE=17, + LLCP_REJECT_IND_OPCODE=13, + LLCP_SLAVE_FEATURE_REQ_OPCODE=14, + LLCP_START_ENC_REQ_OPCODE=5, + LLCP_START_ENC_RSP_OPCODE=6, + LLCP_TERMINATE_IND_OPCODE=2, + LLCP_UNKNOWN_RSP_OPCODE=7, + LLCP_VERSION_IND_OPCODE=12 +} co_llcp_opcode; + +typedef struct llcp_reject_ind_ext llcp_reject_ind_ext, *Pllcp_reject_ind_ext; + +struct llcp_reject_ind_ext { + uint8_t opcode; + uint8_t rej_opcode; + uint8_t err_code; +}; + +typedef struct llcp_feats_req llcp_feats_req, *Pllcp_feats_req; + +struct llcp_feats_req { + uint8_t opcode; + struct le_features feats; +}; + +typedef struct llcp_con_upd_ind llcp_con_upd_ind, *Pllcp_con_upd_ind; + +struct llcp_con_upd_ind { + uint8_t opcode; + uint8_t win_size; + uint16_t win_off; + uint16_t interv; + uint16_t latency; + uint16_t timeout; + uint16_t instant; +}; + +typedef struct llcp_vers_ind llcp_vers_ind, *Pllcp_vers_ind; + +struct llcp_vers_ind { + uint8_t opcode; + uint8_t vers; + uint16_t compid; + uint16_t subvers; +}; + +typedef struct llcp_length_req llcp_length_req, *Pllcp_length_req; + +struct llcp_length_req { + uint8_t opcode; + undefined field_0x1; + uint16_t max_rx_octets; + uint16_t max_rx_time; + uint16_t max_tx_octets; + uint16_t max_tx_time; +}; + +typedef struct llcp_ping_rsp llcp_ping_rsp, *Pllcp_ping_rsp; + +struct llcp_ping_rsp { + uint8_t opcode; +}; + +typedef struct llcp_pause_enc_req llcp_pause_enc_req, *Pllcp_pause_enc_req; + +struct llcp_pause_enc_req { + uint8_t opcode; +}; + +typedef union llcp_pdu llcp_pdu, *Pllcp_pdu; + +typedef struct llcp_reject_ind llcp_reject_ind, *Pllcp_reject_ind; + +typedef struct llcp_con_param_rsp llcp_con_param_rsp, *Pllcp_con_param_rsp; + +typedef struct llcp_ping_req llcp_ping_req, *Pllcp_ping_req; + +struct llcp_reject_ind { + uint8_t opcode; + uint8_t err_code; +}; + +struct llcp_ping_req { + uint8_t opcode; +}; + +struct llcp_con_param_rsp { + uint8_t opcode; + undefined field_0x1; + uint16_t interval_min; + uint16_t interval_max; + uint16_t latency; + uint16_t timeout; + uint8_t pref_period; + undefined field_0xb; + uint16_t ref_con_event_count; + uint16_t offset0; + uint16_t offset1; + uint16_t offset2; + uint16_t offset3; + uint16_t offset4; + uint16_t offset5; +}; + +union llcp_pdu { + uint8_t opcode; + struct llcp_con_upd_ind con_up_req; + struct llcp_channel_map_ind channel_map_req; + struct llcp_terminate_ind terminate_ind; + struct llcp_enc_req enc_req; + struct llcp_enc_rsp enc_rsp; + struct llcp_start_enc_req start_enc_req; + struct llcp_start_enc_rsp start_enc_rsp; + struct llcp_unknown_rsp unknown_rsp; + struct llcp_feats_req feats_req; + struct llcp_feats_rsp feats_rsp; + struct llcp_pause_enc_req pause_enc_req; + struct llcp_pause_enc_rsp pause_enc_rsp; + struct llcp_vers_ind vers_ind; + struct llcp_reject_ind reject_ind; + struct llcp_slave_feature_req slave_feature_req; + struct llcp_con_param_req con_param_req; + struct llcp_con_param_rsp con_param_rsp; + struct llcp_reject_ind_ext reject_ind_ext; + struct llcp_ping_req ping_req; + struct llcp_ping_rsp ping_rsp; + struct llcp_length_req length_req; + struct llcp_length_rsp length_rsp; +}; + +typedef enum co_llcp_length { + LLCP_CH_MAP_REQ_LEN=8, + LLCP_CON_PARAM_REQ_LEN=24, + LLCP_CON_PARAM_RSP_LEN=24, + LLCP_CON_REQ_LEN=34, + LLCP_CON_UPD_IND_LEN=12, + LLCP_ENC_REQ_LEN=23, + LLCP_ENC_RSP_LEN=13, + LLCP_FEAT_REQ_LEN=9, + LLCP_FEAT_RSP_LEN=9, + LLCP_LENGTH_REQ_LEN=9, + LLCP_LENGTH_RSP_LEN=9, + LLCP_PA_ENC_REQ_LEN=1, + LLCP_PA_ENC_RSP_LEN=1, + LLCP_PDU_LENGTH_MAX=34, + LLCP_PING_REQ_LEN=1, + LLCP_PING_RSP_LEN=1, + LLCP_REJECT_IND_EXT_LEN=3, + LLCP_REJ_IND_LEN=2, + LLCP_SLAVE_FEATURE_REQ_LEN=9, + LLCP_ST_ENC_REQ_LEN=1, + LLCP_ST_ENC_RSP_LEN=1, + LLCP_TERM_IND_LEN=2, + LLCP_UNKN_RSP_LEN=2, + LLCP_VERS_IND_LEN=6 +} co_llcp_length; + +typedef int __intptr_t; + +typedef __intptr_t intptr_t; + +typedef longlong __int64_t; + +typedef __int64_t int64_t; + +typedef struct mbedtls_pem_context mbedtls_pem_context, *Pmbedtls_pem_context; + +struct mbedtls_pem_context { + uchar * buf; + size_t buflen; + uchar * info; +}; + +typedef struct _gpio_ctx_desc _gpio_ctx_desc, *P_gpio_ctx_desc; + +struct _gpio_ctx_desc { + struct _gpio_ctx_desc * next; + void (* gpio_handler)(void *); + void * arg; + uint8_t gpioPin; + uint8_t intCtrlMod; + uint8_t intTrgMod; + undefined field_0xf; +}; + +typedef struct _gpio_ctx_desc gpio_ctx_t; + +typedef struct gpio_feature_config gpio_feature_config, *Pgpio_feature_config; + +struct gpio_feature_config { + int pin; + uint8_t valid; + uint8_t feature; + uint8_t active; + uint8_t mode; + uint time; +}; + +typedef enum riscv_abi_type { + ABI_ILP32=0, + ABI_ILP32D=3, + ABI_ILP32E=1, + ABI_ILP32F=2, + ABI_LP64=4, + ABI_LP64D=6, + ABI_LP64F=5 +} riscv_abi_type; + +typedef enum riscv_microarchitecture_type { + generic=0, + sifive_7=1 +} riscv_microarchitecture_type; + +typedef enum riscv_code_model { + CM_MEDANY=1, + CM_MEDLOW=0, + CM_PIC=2 +} riscv_code_model; + +typedef struct llm_pdu_adv llm_pdu_adv, *Pllm_pdu_adv; + +struct llm_pdu_adv { + struct bd_addr adva; + undefined field_0x6; + undefined field_0x7; + uint8_t * adva_data; +}; + +typedef struct scanning_pdu_params scanning_pdu_params, *Pscanning_pdu_params; + +typedef struct em_buf_node em_buf_node, *Pem_buf_node; + +struct em_buf_node { + struct co_list_hdr hdr; + uint16_t idx; + uint16_t buf_ptr; +}; + +struct scanning_pdu_params { + struct em_buf_node * conn_req_desc_node; + uint16_t interval; + uint16_t window; + uint8_t filterpolicy; + uint8_t type; + uint8_t filter_duplicate; + uint8_t own_addr_type; +}; + +typedef struct llm_le_env_tag llm_le_env_tag, *Pllm_le_env_tag; + +typedef struct advertising_pdu_params advertising_pdu_params, *Padvertising_pdu_params; + +typedef struct data_len_ext data_len_ext, *Pdata_len_ext; + +typedef struct channel_map_assess channel_map_assess, *Pchannel_map_assess; + +typedef struct access_addr_gen access_addr_gen, *Paccess_addr_gen; + +typedef struct ea_elt_tag ea_elt_tag, *Pea_elt_tag; + +typedef struct llm_test_mode llm_test_mode, *Pllm_test_mode; + +typedef struct t_public_key256 t_public_key256, *Pt_public_key256; + +typedef enum t_key_multiplication_type { + LLM_DHKEY_GENERATION=2, + LLM_ECC_IDLE=0, + LLM_PUBLIC_KEY_GENERATION=1 +} t_key_multiplication_type; + +typedef enum t_key_multiplication_type t_key_multi_type; + +struct ea_elt_tag { + struct co_list_hdr hdr; + struct ea_elt_tag * linked_element; + uint32_t timestamp; + uint32_t asap_limit; + uint16_t asap_settings; + uint16_t duration_min; + uint16_t delay; + uint8_t current_prio; + uint8_t stop_latency1; + uint8_t stop_latency2; + uint8_t start_latency; + undefined field_0x1a; + undefined field_0x1b; + void (* ea_cb_start)(struct ea_elt_tag *); + void (* ea_cb_stop)(struct ea_elt_tag *); + void (* ea_cb_cancel)(struct ea_elt_tag *); + void * env; +}; + +struct t_public_key256 { + uint8_t x[32]; + uint8_t y[32]; +}; + +struct llm_test_mode { + _Bool end_of_tst; + uint8_t directtesttype; +}; + +struct channel_map_assess { + uint16_t assess_timer; + int8_t lower_limit; + int8_t upper_limit; + int8_t rssi_noise_limit; + uint8_t reassess_count; + struct le_chnl_map ch_map; + _Bool llm_le_set_host_ch_class_cmd_sto; +}; + +struct data_len_ext { + uint16_t conn_initial_max_tx_octets; + uint16_t conn_initial_max_tx_time; + uint16_t suppted_max_tx_octets; + uint16_t suppted_max_tx_time; + uint16_t suppted_max_rx_octets; + uint16_t suppted_max_rx_time; +}; + +struct access_addr_gen { + uint8_t intrand; + uint8_t ct1_idx; + uint8_t ct2_idx; +}; + +struct llm_le_env_tag { + struct co_list enc_req; + struct co_list adv_list; + struct scanning_pdu_params * scanning_params; + struct advertising_pdu_params * advertising_params; + struct co_list cnx_list; + struct data_len_ext data_len_val; + struct channel_map_assess ch_map_assess; + struct evt_mask eventmask; + struct access_addr_gen aa; + undefined field_0x43; + uint16_t conhdl_alloc; + undefined field_0x46; + undefined field_0x47; + struct ea_elt_tag * elt; + _Bool last_opcode; + undefined field_0x4d; + uint16_t opcode2; + uint8_t state2; + undefined field_0x51; + undefined field_0x52; + undefined field_0x53; + struct ea_elt_tag * elt_coext_scan; + _Bool enc_pend; + struct llm_test_mode test_mode; + struct bd_addr rand_add; + struct bd_addr public_add; + undefined field_0x67; + uint16_t enh_priv_rpa_timeout; + uint16_t p256_byte_process_timeout; + uint16_t opcode; + uint8_t state; + uint8_t enh_priv_info; + uint8_t curr_addr_type; + uint8_t nb_dev_in_wl; + uint8_t nb_dev_in_hw_wl; + struct t_public_key256 public_key256; + uint8_t secret_key256[32]; + t_key_multi_type cur_ecc_multiplication; +}; + +struct advertising_pdu_params { + struct ke_msg * adv_data_req; + struct ke_msg * scan_rsp_req; + struct em_buf_node * adv_desc_node; + struct em_buf_node * scan_rsp_desc_node; + struct bd_addr peer_addr; + uint16_t intervalmin; + uint16_t intervalmax; + uint8_t channelmap; + uint8_t filterpolicy; + uint8_t type; + uint8_t datalen; + uint8_t scanrsplen; + uint8_t own_addr_type; + uint8_t peer_addr_type; + _Bool adv_ldc_flag; + undefined field_0x22; + undefined field_0x23; +}; + +typedef struct llm_pdu_con_req_tx llm_pdu_con_req_tx, *Pllm_pdu_con_req_tx; + +struct llm_pdu_con_req_tx { + struct access_addr aa; + struct crc_init crcinit; + uint8_t winsize; + uint16_t winoffset; + uint16_t interval; + uint16_t latency; + uint16_t timeout; + struct le_chnl_map chm; + uint8_t hop_sca; +}; + +typedef struct adv_device_list adv_device_list, *Padv_device_list; + +struct adv_device_list { + struct co_list_hdr hdr; + uint8_t adv_type; + struct bd_addr adv_addr; + undefined field_0xb; +}; + +typedef enum llm_enh_priv { + LLM_PRIV_ENABLE_LSB=0, + LLM_PRIV_ENABLE_MASK=1, + LLM_PRIV_RFU_LSB=2, + LLM_PRIV_RFU_MASK=-116, + LLM_RPA_RENEW_TIMER_EN_LSB=1, + LLM_RPA_RENEW_TIMER_EN_MASK=2 +} llm_enh_priv; + +typedef struct llm_pdu_con_req_rx llm_pdu_con_req_rx, *Pllm_pdu_con_req_rx; + +struct llm_pdu_con_req_rx { + struct bd_addr inita; + struct bd_addr adva; + struct access_addr aa; + struct crc_init crcinit; + uint8_t winsize; + uint16_t winoffset; + uint16_t interval; + uint16_t latency; + uint16_t timeout; + struct le_chnl_map chm; + uint8_t hop_sca; +}; + +typedef struct bl_mtd_info_t bl_mtd_info_t, *Pbl_mtd_info_t; + +struct bl_mtd_info_t { + char name[16]; + uint offset; + uint size; + void * xip_addr; +}; + +typedef void * bl_mtd_handle_t; + +typedef struct mbedtls_ssl_config.conflict mbedtls_ssl_config.conflict, *Pmbedtls_ssl_config.conflict; + +struct mbedtls_ssl_config.conflict { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict1 mbedtls_ssl_config.conflict1, *Pmbedtls_ssl_config.conflict1; + +struct mbedtls_ssl_config.conflict1 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict2 mbedtls_ssl_config.conflict2, *Pmbedtls_ssl_config.conflict2; + +struct mbedtls_ssl_config.conflict2 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_context.conflict3 mbedtls_ssl_context.conflict3, *Pmbedtls_ssl_context.conflict3; + +struct mbedtls_ssl_context.conflict3 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict2 mbedtls_ssl_context.conflict2, *Pmbedtls_ssl_context.conflict2; + +struct mbedtls_ssl_context.conflict2 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict1 mbedtls_ssl_context.conflict1, *Pmbedtls_ssl_context.conflict1; + +struct mbedtls_ssl_context.conflict1 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict7 mbedtls_ssl_context.conflict7, *Pmbedtls_ssl_context.conflict7; + +struct mbedtls_ssl_context.conflict7 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict6 mbedtls_ssl_context.conflict6, *Pmbedtls_ssl_context.conflict6; + +struct mbedtls_ssl_context.conflict6 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict5 mbedtls_ssl_context.conflict5, *Pmbedtls_ssl_context.conflict5; + +struct mbedtls_ssl_context.conflict5 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict4 mbedtls_ssl_context.conflict4, *Pmbedtls_ssl_context.conflict4; + +struct mbedtls_ssl_context.conflict4 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict9 mbedtls_ssl_context.conflict9, *Pmbedtls_ssl_context.conflict9; + +struct mbedtls_ssl_context.conflict9 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict8 mbedtls_ssl_context.conflict8, *Pmbedtls_ssl_context.conflict8; + +struct mbedtls_ssl_context.conflict8 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_config.conflict9 mbedtls_ssl_config.conflict9, *Pmbedtls_ssl_config.conflict9; + +struct mbedtls_ssl_config.conflict9 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict7 mbedtls_ssl_config.conflict7, *Pmbedtls_ssl_config.conflict7; + +struct mbedtls_ssl_config.conflict7 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict8 mbedtls_ssl_config.conflict8, *Pmbedtls_ssl_config.conflict8; + +struct mbedtls_ssl_config.conflict8 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict5 mbedtls_ssl_config.conflict5, *Pmbedtls_ssl_config.conflict5; + +struct mbedtls_ssl_config.conflict5 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict6 mbedtls_ssl_config.conflict6, *Pmbedtls_ssl_config.conflict6; + +struct mbedtls_ssl_config.conflict6 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict4 mbedtls_ssl_config.conflict4, *Pmbedtls_ssl_config.conflict4; + +struct mbedtls_ssl_config.conflict4 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_context.conflict20 mbedtls_ssl_context.conflict20, *Pmbedtls_ssl_context.conflict20; + +struct mbedtls_ssl_context.conflict20 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict18 mbedtls_ssl_context.conflict18, *Pmbedtls_ssl_context.conflict18; + +struct mbedtls_ssl_context.conflict18 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict17 mbedtls_ssl_context.conflict17, *Pmbedtls_ssl_context.conflict17; + +struct mbedtls_ssl_context.conflict17 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict16 mbedtls_ssl_context.conflict16, *Pmbedtls_ssl_context.conflict16; + +struct mbedtls_ssl_context.conflict16 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict15 mbedtls_ssl_context.conflict15, *Pmbedtls_ssl_context.conflict15; + +struct mbedtls_ssl_context.conflict15 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict19 mbedtls_ssl_context.conflict19, *Pmbedtls_ssl_context.conflict19; + +struct mbedtls_ssl_context.conflict19 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict10 mbedtls_ssl_context.conflict10, *Pmbedtls_ssl_context.conflict10; + +struct mbedtls_ssl_context.conflict10 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict14 mbedtls_ssl_context.conflict14, *Pmbedtls_ssl_context.conflict14; + +struct mbedtls_ssl_context.conflict14 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict13 mbedtls_ssl_context.conflict13, *Pmbedtls_ssl_context.conflict13; + +struct mbedtls_ssl_context.conflict13 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict12 mbedtls_ssl_context.conflict12, *Pmbedtls_ssl_context.conflict12; + +struct mbedtls_ssl_context.conflict12 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict11 mbedtls_ssl_context.conflict11, *Pmbedtls_ssl_context.conflict11; + +struct mbedtls_ssl_context.conflict11 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict mbedtls_ssl_context.conflict, *Pmbedtls_ssl_context.conflict; + +struct mbedtls_ssl_context.conflict { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_config.conflict11 mbedtls_ssl_config.conflict11, *Pmbedtls_ssl_config.conflict11; + +struct mbedtls_ssl_config.conflict11 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict10 mbedtls_ssl_config.conflict10, *Pmbedtls_ssl_config.conflict10; + +struct mbedtls_ssl_config.conflict10 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict13 mbedtls_ssl_config.conflict13, *Pmbedtls_ssl_config.conflict13; + +struct mbedtls_ssl_config.conflict13 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict12 mbedtls_ssl_config.conflict12, *Pmbedtls_ssl_config.conflict12; + +struct mbedtls_ssl_config.conflict12 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict15 mbedtls_ssl_config.conflict15, *Pmbedtls_ssl_config.conflict15; + +struct mbedtls_ssl_config.conflict15 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict14 mbedtls_ssl_config.conflict14, *Pmbedtls_ssl_config.conflict14; + +struct mbedtls_ssl_config.conflict14 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict17 mbedtls_ssl_config.conflict17, *Pmbedtls_ssl_config.conflict17; + +struct mbedtls_ssl_config.conflict17 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict16 mbedtls_ssl_config.conflict16, *Pmbedtls_ssl_config.conflict16; + +struct mbedtls_ssl_config.conflict16 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict18 mbedtls_ssl_config.conflict18, *Pmbedtls_ssl_config.conflict18; + +struct mbedtls_ssl_config.conflict18 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct notifier_block notifier_block, *Pnotifier_block; + +struct notifier_block { + int (* cb)(struct notifier_block *, int, void *); + struct notifier_block * next; + int priority; +}; + +typedef int32_t mbedtls_mpi_sint; + +typedef uint64_t mbedtls_t_udbl; + +typedef enum raw_input_state { + RAW_INPUT_DELIVERED=2, + RAW_INPUT_EATEN=1, + RAW_INPUT_NONE=0 +} raw_input_state; + +typedef enum raw_input_state raw_input_state_t; + +typedef enum memp_t { + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1 +} memp_t; + + +// WARNING! conflicting data type names: /DWARF/memp.h/anon_enum_8 - /DWARF/vsscanf.c/vsscanf/anon_enum_8 + +typedef struct bl_mtd_handle_priv bl_mtd_handle_priv, *Pbl_mtd_handle_priv; + +struct bl_mtd_handle_priv { + char name[16]; + int id; + uint offset; + uint size; + void * xip_addr; +}; + +typedef struct bl_mtd_handle_priv * bl_mtd_handle_priv_t; + +typedef struct k_thread k_thread, *Pk_thread; + +typedef uint32_t _task_t; + +struct k_thread { + _task_t task; +}; + +typedef struct k_mutex k_mutex, *Pk_mutex; + +typedef struct bl_hdl_t _mutex_t; + +struct k_mutex { + _mutex_t mutex; + sys_dlist_t poll_events; +}; + +typedef void (* k_thread_entry_t)(void *); + +typedef enum LLC_MSG { + LLC_AUTH_PAYL_NEARLY_TO=259, + LLC_AUTH_PAYL_REAL_TO=260, + LLC_CHMAP_UPDATE_REQ_IND=264, + LLC_CHNL_ASSESS_TO=261, + LLC_CON_UPD_REQ_IND=265, + LLC_DATA_IND=256, + LLC_ENC_MGT_IND=262, + LLC_LENGTH_REQ_IND=263, + LLC_LE_LINK_SUP_TO=257, + LLC_LLCP_RECV_IND=266, + LLC_LLCP_RSP_TO=258 +} LLC_MSG; + +typedef struct llc_create_con_req_ind llc_create_con_req_ind, *Pllc_create_con_req_ind; + +struct llc_create_con_req_ind { + uint16_t con_int; + uint16_t con_lat; + uint16_t sup_to; + uint16_t ral_ptr; + struct bd_addr peer_addr; + uint8_t peer_addr_type; + uint8_t hop_inc; + uint8_t sleep_clk_acc; + uint8_t filter_policy; +}; + +typedef struct llc_data_ind llc_data_ind, *Pllc_data_ind; + +struct llc_data_ind { + uint16_t conhdl; + uint8_t pb_bc_flag; + undefined field_0x3; + uint16_t length; + uint8_t rx_hdl; + undefined field_0x7; +}; + +typedef enum llc_loc_proc_state { + LLC_LOC_IDLE=0, + LLC_LOC_SEND_START_ENC_RSP=17, + LLC_LOC_WAIT_CON_PARAM_RSP=7, + LLC_LOC_WAIT_CON_UPD_INSTANT=9, + LLC_LOC_WAIT_CON_UPD_REQ=8, + LLC_LOC_WAIT_ENC_RSP=13, + LLC_LOC_WAIT_FEAT_RSP=1, + LLC_LOC_WAIT_LENGTH_RSP=4, + LLC_LOC_WAIT_MAP_UPD_INSTANT=6, + LLC_LOC_WAIT_PAUSE_ENC_RSP=11, + LLC_LOC_WAIT_PAUSE_ENC_RSP_SENT=12, + LLC_LOC_WAIT_PING_RSP=5, + LLC_LOC_WAIT_RANDN_GEN_IND=19, + LLC_LOC_WAIT_SK=15, + LLC_LOC_WAIT_SK_AND_START_ENC_REQ=14, + LLC_LOC_WAIT_START_ENC_REQ=16, + LLC_LOC_WAIT_START_ENC_RSP=18, + LLC_LOC_WAIT_TERM_ACK=3, + LLC_LOC_WAIT_TRAFFIC_PAUSED=10, + LLC_LOC_WAIT_VERS_IND=2 +} llc_loc_proc_state; + +typedef struct llc_con_upd_req_ind llc_con_upd_req_ind, *Pllc_con_upd_req_ind; + +struct llc_con_upd_req_ind { + uint8_t operation; + undefined field_0x1; + uint16_t con_intv_min; + uint16_t con_intv_max; + uint16_t con_latency; + uint16_t superv_to; + uint16_t ce_len_min; + uint16_t ce_len_max; + uint16_t interval_min; + uint16_t interval_max; + uint8_t pref_period; + undefined field_0x13; + uint16_t ref_con_event_count; + uint16_t offset0; + uint16_t offset1; + uint16_t offset2; + uint16_t offset3; + uint16_t offset4; + uint16_t offset5; +}; + +typedef enum llc_op_type { + LLC_OP_DLE_UPD=3, + LLC_OP_ENCRYPT=2, + LLC_OP_LOC_PARAM_UPD=0, + LLC_OP_MAX=4, + LLC_OP_REM_PARAM_UPD=1 +} llc_op_type; + +typedef enum llc_con_up_op { + LLC_CON_UP_FORCE=2, + LLC_CON_UP_HCI_REQ=0, + LLC_CON_UP_LOC_REQ=4, + LLC_CON_UP_MOVE_ANCHOR=1, + LLC_CON_UP_PEER_REQ=3 +} llc_con_up_op; + +typedef struct llc_llcp_recv_ind llc_llcp_recv_ind, *Pllc_llcp_recv_ind; + +struct llc_llcp_recv_ind { + uint8_t status; + uint8_t dummy; + union llcp_pdu pdu; +}; + +typedef enum llc_rem_proc_state { + LLC_REM_IDLE=0, + LLC_REM_WAIT_CON_PARAM_HOST_RSP=2, + LLC_REM_WAIT_CON_UPD_INSTANT=4, + LLC_REM_WAIT_CON_UPD_REQ=3, + LLC_REM_WAIT_ENC_REJECT_ACK=13, + LLC_REM_WAIT_ENC_REQ=7, + LLC_REM_WAIT_LTK=9, + LLC_REM_WAIT_MAP_UPD_INSTANT=1, + LLC_REM_WAIT_PAUSE_ENC_RSP=6, + LLC_REM_WAIT_RANDN_GEN_IND=14, + LLC_REM_WAIT_SK=10, + LLC_REM_WAIT_START_ENC_RSP=11, + LLC_REM_WAIT_START_ENC_RSP_ACK=12, + LLC_REM_WAIT_TP_FOR_ENC_REQ=8, + LLC_REM_WAIT_TP_FOR_PAUSE_ENC_REQ=5 +} llc_rem_proc_state; + +typedef enum llc_state_id { + LLC_CONNECTED=0, + LLC_DISC_BUSY=15, + LLC_FREE=127, + LLC_LOC_PROC_BUSY=1, + LLC_REM_PROC_BUSY=2, + LLC_STATE_MAX=-128, + LLC_TRAFFIC_PAUSED_BUSY=4 +} llc_state_id; + +typedef enum llc_proc_field { + LLC_DISC=3, + LLC_LOC_PROC=0, + LLC_REM_PROC=1, + LLC_TRAFFIC_PAUSED=2 +} llc_proc_field; + +typedef struct lld_pdu_pack_desc lld_pdu_pack_desc, *Plld_pdu_pack_desc; + +struct lld_pdu_pack_desc { + uint8_t pdu_len; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + void * pack_fmt; + void (* unpack_func)(uint16_t, uint8_t, uint8_t *); +}; + +typedef enum lld_pdu_pack_status { + LLC_PDU_PACK_OK=0, + LLC_PDU_PACK_UNKNOWN=2, + LLC_PDU_PACK_WRONG_FORMAT=1 +} lld_pdu_pack_status; + +typedef struct lld_pdu_rx_info lld_pdu_rx_info, *Plld_pdu_rx_info; + +struct lld_pdu_rx_info { + struct co_list_hdr hdr; + uint8_t rx_hdl; + _Bool free; + uint16_t conhdl; + uint16_t status; + uint8_t length; + uint8_t channel; + uint8_t rssi; + uint8_t audio; + undefined field_0xe; + undefined field_0xf; +}; + +typedef ulong __uint32_t; + +typedef uint __uintptr_t; + +typedef uchar __uint8_t; + +typedef char __int8_t; + +typedef long __int32_t; + +typedef ushort __uint16_t; + +typedef struct lld_pdu_data_tx_tag lld_pdu_data_tx_tag, *Plld_pdu_data_tx_tag; + +struct lld_pdu_data_tx_tag { + struct co_list_hdr hdr; + uint16_t idx; + uint16_t conhdl; + uint16_t length; + uint8_t pb_bc_flag; + undefined field_0xb; + struct em_buf_node * buf; +}; + +typedef struct bl_env_tag bl_env_tag, *Pbl_env_tag; + +struct bl_env_tag { + uint8_t prev_hw_state; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + int hw_in_doze; +}; + +typedef struct trpc_env_tag trpc_env_tag, *Ptrpc_env_tag; + +struct trpc_env_tag { + int8_t power_dbm_max_rf; + int8_t power_dbm_min_rf; + int8_t power_dbm_lim_reg; + undefined field_0x3; + int16_t channel_freq; + int8_t temperature; + int8_t temperature_compensate; +}; + +typedef struct cfg80211_bss_select_adjust cfg80211_bss_select_adjust, *Pcfg80211_bss_select_adjust; + +struct cfg80211_bss_select_adjust { + enum nl80211_band band; + s8 delta; +}; + +typedef enum ieee80211_channel_flags { + IEEE80211_CHAN_DISABLED=1, + IEEE80211_CHAN_INDOOR_ONLY=512, + IEEE80211_CHAN_IR_CONCURRENT=1024, + IEEE80211_CHAN_NO_10MHZ=4096, + IEEE80211_CHAN_NO_160MHZ=256, + IEEE80211_CHAN_NO_20MHZ=2048, + IEEE80211_CHAN_NO_80MHZ=-128, + IEEE80211_CHAN_NO_HT40MINUS=32, + IEEE80211_CHAN_NO_HT40PLUS=16, + IEEE80211_CHAN_NO_IR=2, + IEEE80211_CHAN_NO_OFDM=64, + IEEE80211_CHAN_RADAR=8 +} ieee80211_channel_flags; + +typedef struct ieee80211_channel ieee80211_channel, *Pieee80211_channel; + +struct ieee80211_channel { + enum nl80211_band band; + undefined field_0x1; + u16 center_freq; + u16 hw_value; + undefined field_0x6; + undefined field_0x7; + u32.conflict10 flags; + int max_antenna_gain; + int max_power; + int max_reg_power; + _Bool beacon_found; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; + u32.conflict11 orig_flags; + int orig_mag; + int orig_mpwr; + enum nl80211_dfs_state dfs_state; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; + ulong dfs_state_entered; + uint dfs_cac_ms; +}; + +typedef struct ieee80211_dot_d ieee80211_dot_d, *Pieee80211_dot_d; + +struct ieee80211_dot_d { + char * code; + int channel_num; + struct ieee80211_channel * channels; +}; + +typedef union anon_union.conflict196 anon_union.conflict196, *Panon_union.conflict196; + +union anon_union.conflict196 { + enum nl80211_band band_pref; + struct cfg80211_bss_select_adjust adjust; +}; + +typedef struct cfg80211_connect_params cfg80211_connect_params, *Pcfg80211_connect_params; + +typedef struct cfg80211_crypto_settings cfg80211_crypto_settings, *Pcfg80211_crypto_settings; + +typedef struct cfg80211_bss_selection cfg80211_bss_selection, *Pcfg80211_bss_selection; + +typedef struct key_params key_params, *Pkey_params; + +typedef union anon_union_for_param anon_union_for_param, *Panon_union_for_param; + +union anon_union_for_param { + enum nl80211_band band_pref; + struct cfg80211_bss_select_adjust adjust; +}; + +struct cfg80211_bss_selection { + enum nl80211_bss_select_attr behaviour; + union anon_union_for_param param; +}; + +struct cfg80211_crypto_settings { + u32.conflict13 wpa_versions; + u32.conflict14 cipher_group; + int n_ciphers_pairwise; + u32.conflict15 ciphers_pairwise[5]; + int n_akm_suites; + u32.conflict16 akm_suites[2]; + _Bool control_port; + undefined field_0x2d; + __be16 control_port_ethertype; + _Bool control_port_no_encrypt; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct key_params * wep_keys; + int wep_tx_key; +}; + +struct cfg80211_connect_params { + struct ieee80211_channel channel; + struct ieee80211_channel * channel_hint; + u8 * bssid; + u8 * bssid_hint; + u8 * ssid; + size_t ssid_len; + enum nl80211_auth_type auth_type; + undefined field_0x49; + undefined field_0x4a; + undefined field_0x4b; + u8 * ie; + size_t ie_len; + _Bool privacy; + enum nl80211_mfp mfp; + undefined field_0x56; + undefined field_0x57; + struct cfg80211_crypto_settings crypto; + u8 * key; + u8 * pmk; + u8 key_len; + u8 pmk_len; + u8 key_idx; + undefined field_0x9f; + u32.conflict19 flags; + int bg_scan_period; + struct ieee80211_ht_cap ht_capa; + struct ieee80211_ht_cap ht_capa_mask; + _Bool pbss; + struct cfg80211_bss_selection bss_select; + u8 * prev_bssid; +}; + +struct key_params { + u8 * key; + u8 * seq; + int key_len; + int seq_len; + u32.conflict12 cipher; +}; + +typedef union anon_union.conflict193 anon_union.conflict193, *Panon_union.conflict193; + +union anon_union.conflict193 { + enum nl80211_band band_pref; + struct cfg80211_bss_select_adjust adjust; +}; + +typedef struct hw_vect.conflict1 hw_vect.conflict1, *Phw_vect.conflict1; + +struct hw_vect.conflict1 { + u32.conflict197 len:16; + u32.conflict198 reserved:8; + u32.conflict199 mpdu_cnt:6; + u32.conflict200 ampdu_cnt:2; + __le32 tsf_lo; + __le32 tsf_hi; + u32.conflict201 leg_length:12; + u32.conflict202 leg_rate:4; + u32.conflict203 ht_length:16; + u32.conflict204 _ht_length:4; + u32.conflict205 short_gi:1; + u32.conflict206 stbc:2; + u32.conflict207 smoothing:1; + u32.conflict208 mcs:7; + u32.conflict209 pre_type:1; + u32.conflict210 format_mod:3; + u32.conflict211 ch_bw:2; + u32.conflict212 n_sts:3; + u32.conflict213 lsig_valid:1; + u32.conflict214 sounding:1; + u32.conflict215 num_extn_ss:2; + u32.conflict216 aggregation:1; + u32.conflict217 fec_coding:1; + u32.conflict218 dyn_bw:1; + u32.conflict219 doze_not_allowed:1; + u32.conflict220 antenna_set:8; + u32.conflict221 partial_aid:9; + u32.conflict222 group_id:6; + u32.conflict223 reserved_1c:1; + s32.conflict9 rssi1:8; + s32.conflict10 rssi2:8; + s32.conflict11 rssi3:8; + s32.conflict12 rssi4:8; + u32.conflict224 reserved_1d:8; + u32.conflict225 rcpi:8; + u32.conflict226 evm1:8; + u32.conflict227 evm2:8; + u32.conflict228 evm3:8; + u32.conflict229 evm4:8; + u32.conflict230 reserved2b_1:8; + u32.conflict231 reserved2b_2:8; + u32.conflict232 reserved2b_3:8; + u32.conflict233 rx_vect2_valid:1; + u32.conflict234 resp_frame:1; + u32.conflict235 decr_status:3; + u32.conflict236 rx_fifo_oflow:1; + u32.conflict237 undef_err:1; + u32.conflict238 phy_err:1; + u32.conflict239 fcs_err:1; + u32.conflict240 addr_mismatch:1; + u32.conflict241 ga_frame:1; + u32.conflict242 current_ac:2; + u32.conflict243 frm_successful_rx:1; + u32.conflict244 desc_done_rx:1; + u32.conflict245 key_sram_index:10; + u32.conflict246 key_sram_v:1; + u32.conflict247 type:2; + u32.conflict248 subtype:4; +}; + +typedef struct hw_rxhdr.conflict hw_rxhdr.conflict, *Phw_rxhdr.conflict; + +struct hw_rxhdr.conflict { + struct hw_vect.conflict1 hwvect; + u32.conflict249 phy_band:8; + u32.conflict250 phy_channel_type:8; + u32.conflict251 phy_prim20_freq:16; + u32.conflict252 phy_center1_freq:16; + u32.conflict253 phy_center2_freq:16; + u32.conflict254 flags_is_amsdu:1; + u32.conflict255 flags_is_80211_mpdu:1; + u32.conflict256 flags_is_4addr:1; + u32.conflict257 flags_new_peer:1; + u32.conflict258 flags_user_prio:3; + u32.conflict259 flags_rsvd0:1; + u32.conflict260 flags_vif_idx:8; + u32.conflict261 flags_sta_idx:8; + u32.conflict262 flags_dst_idx:8; + u32.conflict263 pattern; + u32.conflict264 payl_offset; + u32.conflict265 reserved_pad[2]; + u32.conflict266 wild[8]; +}; + +typedef struct sm_reason_code sm_reason_code, *Psm_reason_code; + +struct sm_reason_code { + uint16_t reason_code; + undefined field_0x2; + undefined field_0x3; + char * action; +}; + +typedef struct hw_vect.conflict hw_vect.conflict, *Phw_vect.conflict; + +struct hw_vect.conflict { + u32.conflict107 len:16; + u32.conflict108 reserved:8; + u32.conflict109 mpdu_cnt:6; + u32.conflict110 ampdu_cnt:2; + __le32 tsf_lo; + __le32 tsf_hi; + u32.conflict111 leg_length:12; + u32.conflict112 leg_rate:4; + u32.conflict113 ht_length:16; + u32.conflict114 _ht_length:4; + u32.conflict115 short_gi:1; + u32.conflict116 stbc:2; + u32.conflict117 smoothing:1; + u32.conflict118 mcs:7; + u32.conflict119 pre_type:1; + u32.conflict120 format_mod:3; + u32.conflict121 ch_bw:2; + u32.conflict122 n_sts:3; + u32.conflict123 lsig_valid:1; + u32.conflict124 sounding:1; + u32.conflict125 num_extn_ss:2; + u32.conflict126 aggregation:1; + u32.conflict127 fec_coding:1; + u32.conflict128 dyn_bw:1; + u32.conflict129 doze_not_allowed:1; + u32.conflict130 antenna_set:8; + u32.conflict131 partial_aid:9; + u32.conflict132 group_id:6; + u32.conflict133 reserved_1c:1; + s32.conflict5 rssi1:8; + s32.conflict6 rssi2:8; + s32.conflict7 rssi3:8; + s32.conflict8 rssi4:8; + u32.conflict134 reserved_1d:8; + u32.conflict135 rcpi:8; + u32.conflict136 evm1:8; + u32.conflict137 evm2:8; + u32.conflict138 evm3:8; + u32.conflict139 evm4:8; + u32.conflict140 reserved2b_1:8; + u32.conflict141 reserved2b_2:8; + u32.conflict142 reserved2b_3:8; + u32.conflict143 rx_vect2_valid:1; + u32.conflict144 resp_frame:1; + u32.conflict145 decr_status:3; + u32.conflict146 rx_fifo_oflow:1; + u32.conflict147 undef_err:1; + u32.conflict148 phy_err:1; + u32.conflict149 fcs_err:1; + u32.conflict150 addr_mismatch:1; + u32.conflict151 ga_frame:1; + u32.conflict152 current_ac:2; + u32.conflict153 frm_successful_rx:1; + u32.conflict154 desc_done_rx:1; + u32.conflict155 key_sram_index:10; + u32.conflict156 key_sram_v:1; + u32.conflict157 type:2; + u32.conflict158 subtype:4; +}; + +typedef struct hw_vect hw_vect, *Phw_vect; + +struct hw_vect { + u32.conflict55 len:16; + u32.conflict56 reserved:8; + u32.conflict57 mpdu_cnt:6; + u32.conflict58 ampdu_cnt:2; + __le32 tsf_lo; + __le32 tsf_hi; + u32.conflict59 leg_length:12; + u32.conflict60 leg_rate:4; + u32.conflict61 ht_length:16; + u32.conflict62 _ht_length:4; + u32.conflict63 short_gi:1; + u32.conflict64 stbc:2; + u32.conflict65 smoothing:1; + u32.conflict66 mcs:7; + u32.conflict67 pre_type:1; + u32.conflict68 format_mod:3; + u32.conflict69 ch_bw:2; + u32.conflict70 n_sts:3; + u32.conflict71 lsig_valid:1; + u32.conflict72 sounding:1; + u32.conflict73 num_extn_ss:2; + u32.conflict74 aggregation:1; + u32.conflict75 fec_coding:1; + u32.conflict76 dyn_bw:1; + u32.conflict77 doze_not_allowed:1; + u32.conflict78 antenna_set:8; + u32.conflict79 partial_aid:9; + u32.conflict80 group_id:6; + u32.conflict81 reserved_1c:1; + s32.conflict1 rssi1:8; + s32.conflict2 rssi2:8; + s32.conflict3 rssi3:8; + s32.conflict4 rssi4:8; + u32.conflict82 reserved_1d:8; + u32.conflict83 rcpi:8; + u32.conflict84 evm1:8; + u32.conflict85 evm2:8; + u32.conflict86 evm3:8; + u32.conflict87 evm4:8; + u32.conflict88 reserved2b_1:8; + u32.conflict89 reserved2b_2:8; + u32.conflict90 reserved2b_3:8; + u32.conflict91 rx_vect2_valid:1; + u32.conflict92 resp_frame:1; + u32.conflict93 decr_status:3; + u32.conflict94 rx_fifo_oflow:1; + u32.conflict95 undef_err:1; + u32.conflict96 phy_err:1; + u32.conflict97 fcs_err:1; + u32.conflict98 addr_mismatch:1; + u32.conflict99 ga_frame:1; + u32.conflict100 current_ac:2; + u32.conflict101 frm_successful_rx:1; + u32.conflict102 desc_done_rx:1; + u32.conflict103 key_sram_index:10; + u32.conflict104 key_sram_v:1; + u32.conflict105 type:2; + u32.conflict106 subtype:4; +}; + +typedef struct hw_rxhdr hw_rxhdr, *Phw_rxhdr; + +struct hw_rxhdr { + struct hw_vect.conflict hwvect; + u32.conflict159 phy_band:8; + u32.conflict160 phy_channel_type:8; + u32.conflict161 phy_prim20_freq:16; + u32.conflict162 phy_center1_freq:16; + u32.conflict163 phy_center2_freq:16; + u32.conflict164 flags_is_amsdu:1; + u32.conflict165 flags_is_80211_mpdu:1; + u32.conflict166 flags_is_4addr:1; + u32.conflict167 flags_new_peer:1; + u32.conflict168 flags_user_prio:3; + u32.conflict169 flags_rsvd0:1; + u32.conflict170 flags_vif_idx:8; + u32.conflict171 flags_sta_idx:8; + u32.conflict172 flags_dst_idx:8; + u32.conflict173 pattern; + u32.conflict174 payl_offset; + u32.conflict175 reserved_pad[2]; + u32.conflict176 wild[8]; +}; + +typedef struct hci_le_rx_test_cmd hci_le_rx_test_cmd, *Phci_le_rx_test_cmd; + +struct hci_le_rx_test_cmd { + uint8_t rx_freq; +}; + +typedef struct hci_host_buf_size_cmd hci_host_buf_size_cmd, *Phci_host_buf_size_cmd; + +struct hci_host_buf_size_cmd { + uint16_t acl_pkt_len; + uint8_t sync_pkt_len; + undefined field_0x3; + uint16_t nb_acl_pkts; + uint16_t nb_sync_pkts; +}; + +typedef struct hci_rd_auth_payl_to_cmd hci_rd_auth_payl_to_cmd, *Phci_rd_auth_payl_to_cmd; + +struct hci_rd_auth_payl_to_cmd { + uint16_t conhdl; +}; + +typedef struct hci_le_rd_suggted_dft_data_len_cmd_cmp_evt hci_le_rd_suggted_dft_data_len_cmd_cmp_evt, *Phci_le_rd_suggted_dft_data_len_cmd_cmp_evt; + +struct hci_le_rd_suggted_dft_data_len_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t suggted_max_tx_octets; + uint16_t suggted_max_tx_time; +}; + +typedef struct hci_le_rd_rem_used_feats_cmd_cmp_evt hci_le_rd_rem_used_feats_cmd_cmp_evt, *Phci_le_rd_rem_used_feats_cmd_cmp_evt; + +struct hci_le_rd_rem_used_feats_cmd_cmp_evt { + uint8_t subcode; + uint8_t status; + uint16_t conhdl; + struct le_features feats_used; +}; + +typedef struct hci_rd_wlst_size_cmd_cmp_evt hci_rd_wlst_size_cmd_cmp_evt, *Phci_rd_wlst_size_cmd_cmp_evt; + +struct hci_rd_wlst_size_cmd_cmp_evt { + uint8_t status; + uint8_t wlst_size; +}; + +typedef struct hci_set_evt_mask_cmd hci_set_evt_mask_cmd, *Phci_set_evt_mask_cmd; + +struct hci_set_evt_mask_cmd { + struct evt_mask event_mask; +}; + +typedef struct hci_le_generate_dh_key_cmd hci_le_generate_dh_key_cmd, *Phci_le_generate_dh_key_cmd; + +struct hci_le_generate_dh_key_cmd { + uint8_t public_key[64]; +}; + +typedef struct hci_set_ctrl_to_host_flow_ctrl_cmd hci_set_ctrl_to_host_flow_ctrl_cmd, *Phci_set_ctrl_to_host_flow_ctrl_cmd; + +struct hci_set_ctrl_to_host_flow_ctrl_cmd { + uint8_t flow_cntl; +}; + +typedef struct hci_le_rem_con_param_req_neg_reply_cmd hci_le_rem_con_param_req_neg_reply_cmd, *Phci_le_rem_con_param_req_neg_reply_cmd; + +struct hci_le_rem_con_param_req_neg_reply_cmd { + uint16_t conhdl; + uint8_t reason; + undefined field_0x3; +}; + +typedef struct hci_basic_conhdl_cmd hci_basic_conhdl_cmd, *Phci_basic_conhdl_cmd; + +struct hci_basic_conhdl_cmd { + uint16_t conhdl; +}; + +typedef struct hci_rd_tx_pwr_lvl_cmd_cmp_evt hci_rd_tx_pwr_lvl_cmd_cmp_evt, *Phci_rd_tx_pwr_lvl_cmd_cmp_evt; + +struct hci_rd_tx_pwr_lvl_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; + uint8_t tx_pow_lvl; + undefined field_0x5; +}; + +typedef struct hci_rd_tx_pwr_lvl_cmd hci_rd_tx_pwr_lvl_cmd, *Phci_rd_tx_pwr_lvl_cmd; + +struct hci_rd_tx_pwr_lvl_cmd { + uint16_t conhdl; + uint8_t type; + undefined field_0x3; +}; + +typedef struct hci_basic_cmd_cmp_evt hci_basic_cmd_cmp_evt, *Phci_basic_cmd_cmp_evt; + +struct hci_basic_cmd_cmp_evt { + uint8_t status; +}; + +typedef struct hci_host_nb_cmp_pkts_cmd hci_host_nb_cmp_pkts_cmd, *Phci_host_nb_cmp_pkts_cmd; + +struct hci_host_nb_cmp_pkts_cmd { + uint8_t nb_of_hdl; + undefined field_0x1; + uint16_t con_hdl[3]; + uint16_t nb_comp_pkt[3]; +}; + +typedef struct hci_le_ltk_request_evt hci_le_ltk_request_evt, *Phci_le_ltk_request_evt; + +struct hci_le_ltk_request_evt { + uint8_t subcode; + undefined field_0x1; + uint16_t conhdl; + struct rand_nb rand; + uint16_t ediv; +}; + +typedef struct hci_le_generate_dhkey_cmp_evt hci_le_generate_dhkey_cmp_evt, *Phci_le_generate_dhkey_cmp_evt; + +struct hci_le_generate_dhkey_cmp_evt { + uint8_t subcode; + uint8_t status; + uint8_t dh_key[32]; +}; + +typedef struct hci_le_ltk_req_reply_cmd hci_le_ltk_req_reply_cmd, *Phci_le_ltk_req_reply_cmd; + +struct hci_le_ltk_req_reply_cmd { + uint16_t conhdl; + struct ltk ltk; +}; + +typedef struct hci_rd_local_supp_cmds_cmd_cmp_evt hci_rd_local_supp_cmds_cmd_cmp_evt, *Phci_rd_local_supp_cmds_cmd_cmp_evt; + +struct hci_rd_local_supp_cmds_cmd_cmp_evt { + uint8_t status; + struct supp_cmds local_cmds; +}; + +typedef struct hci_le_enc_cmd_cmp_evt hci_le_enc_cmd_cmp_evt, *Phci_le_enc_cmd_cmp_evt; + +struct hci_le_enc_cmd_cmp_evt { + uint8_t status; + uint8_t encrypted_data[16]; +}; + +typedef struct hci_le_set_scan_param_cmd hci_le_set_scan_param_cmd, *Phci_le_set_scan_param_cmd; + +struct hci_le_set_scan_param_cmd { + uint8_t scan_type; + undefined field_0x1; + uint16_t scan_intv; + uint16_t scan_window; + uint8_t own_addr_type; + uint8_t scan_filt_policy; +}; + +typedef struct hci_rd_local_supp_feats_cmd_cmp_evt hci_rd_local_supp_feats_cmd_cmp_evt, *Phci_rd_local_supp_feats_cmd_cmp_evt; + +struct hci_rd_local_supp_feats_cmd_cmp_evt { + uint8_t status; + struct features feats; +}; + +typedef struct hci_le_rd_buff_size_cmd_cmp_evt hci_le_rd_buff_size_cmd_cmp_evt, *Phci_le_rd_buff_size_cmd_cmp_evt; + +struct hci_le_rd_buff_size_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t hc_data_pk_len; + uint8_t hc_tot_nb_data_pkts; + undefined field_0x5; +}; + +typedef struct hci_le_set_adv_param_cmd hci_le_set_adv_param_cmd, *Phci_le_set_adv_param_cmd; + +struct hci_le_set_adv_param_cmd { + uint16_t adv_intv_min; + uint16_t adv_intv_max; + uint8_t adv_type; + uint8_t own_addr_type; + uint8_t peer_addr_type; + struct bd_addr peer_addr; + uint8_t adv_chnl_map; + uint8_t adv_filt_policy; + undefined field_0xf; +}; + +typedef struct hci_le_rand_cmd_cmp_evt hci_le_rand_cmd_cmp_evt, *Phci_le_rand_cmd_cmp_evt; + +struct hci_le_rand_cmd_cmp_evt { + uint8_t status; + struct rand_nb nb; +}; + +typedef struct hci_rd_supp_states_cmd_cmp_evt hci_rd_supp_states_cmd_cmp_evt, *Phci_rd_supp_states_cmd_cmp_evt; + +struct hci_rd_supp_states_cmd_cmp_evt { + uint8_t status; + struct le_states states; +}; + +typedef struct hci_rd_rem_ver_info_cmp_evt hci_rd_rem_ver_info_cmp_evt, *Phci_rd_rem_ver_info_cmp_evt; + +struct hci_rd_rem_ver_info_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; + uint8_t vers; + undefined field_0x5; + uint16_t compid; + uint16_t subvers; +}; + +typedef struct hci_le_ch_sel_algo_evt hci_le_ch_sel_algo_evt, *Phci_le_ch_sel_algo_evt; + +struct hci_le_ch_sel_algo_evt { + uint8_t subcode; + undefined field_0x1; + uint16_t conhdl; + uint8_t chSel; + undefined field_0x5; +}; + +typedef struct hci_rd_auth_payl_to_cmd_cmp_evt hci_rd_auth_payl_to_cmd_cmp_evt, *Phci_rd_auth_payl_to_cmd_cmp_evt; + +struct hci_rd_auth_payl_to_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; + uint16_t auth_payl_to; +}; + +typedef enum hci_evt_code { + HCI_AUTH_CMP_EVT_CODE=6, + HCI_AUTH_PAYL_TO_EXP_EVT_CODE=87, + HCI_CHG_CON_LK_CMP_EVT_CODE=9, + HCI_CMD_CMP_EVT_CODE=14, + HCI_CMD_STATUS_EVT_CODE=15, + HCI_CON_CMP_EVT_CODE=3, + HCI_CON_PKT_TYPE_CHG_EVT_CODE=29, + HCI_CON_REQ_EVT_CODE=4, + HCI_CON_SLV_BCST_CH_MAP_CHG_EVT_CODE=85, + HCI_CON_SLV_BCST_REC_EVT_CODE=81, + HCI_CON_SLV_BCST_TO_EVT_CODE=82, + HCI_DATA_BUF_OVFLW_EVT_CODE=26, + HCI_DBG_META_EVT_CODE=-1, + HCI_DISC_CMP_EVT_CODE=5, + HCI_ENC_CHG_EVT_CODE=8, + HCI_ENC_KEY_REFRESH_CMP_EVT_CODE=48, + HCI_ENH_FLUSH_CMP_EVT_CODE=57, + HCI_EXT_INQ_RES_EVT_CODE=47, + HCI_FLOW_SPEC_CMP_EVT_CODE=33, + HCI_FLUSH_OCCURRED_EVT_CODE=17, + HCI_HW_ERR_EVT_CODE=16, + HCI_INQ_CMP_EVT_CODE=1, + HCI_INQ_RES_EVT_CODE=2, + HCI_INQ_RES_WITH_RSSI_EVT_CODE=34, + HCI_IO_CAP_REQ_EVT_CODE=49, + HCI_IO_CAP_RSP_EVT_CODE=50, + HCI_KEYPRESS_NOTIF_EVT_CODE=60, + HCI_LE_ADV_REPORT_EVT_SUBCODE=2, + HCI_LE_CH_SEL_ALGO_EVT_SUBCODE=20, + HCI_LE_CON_CMP_EVT_SUBCODE=1, + HCI_LE_CON_UPDATE_CMP_EVT_SUBCODE=3, + HCI_LE_DATA_LEN_CHG_EVT_SUBCODE=7, + HCI_LE_DIR_ADV_REP_EVT_SUBCODE=11, + HCI_LE_ENH_CON_CMP_EVT_SUBCODE=10, + HCI_LE_GEN_DHKEY_CMP_EVT_SUBCODE=9, + HCI_LE_LTK_REQUEST_EVT_SUBCODE=5, + HCI_LE_META_EVT_CODE=62, + HCI_LE_RD_LOC_P256_PUB_KEY_CMP_EVT_SUBCODE=8, + HCI_LE_RD_REM_USED_FEATS_CMP_EVT_SUBCODE=4, + HCI_LE_REM_CON_PARAM_REQ_EVT_SUBCODE=6, + HCI_LINK_SUPV_TO_CHG_EVT_CODE=56, + HCI_LK_NOTIF_EVT_CODE=24, + HCI_LK_REQ_EVT_CODE=23, + HCI_MASTER_LK_CMP_EVT_CODE=10, + HCI_MAX_EVT_MSK_PAGE_1_CODE=64, + HCI_MAX_EVT_MSK_PAGE_2_CODE=88, + HCI_MAX_SLOT_CHG_EVT_CODE=27, + HCI_MODE_CHG_EVT_CODE=20, + HCI_NB_CMP_PKTS_EVT_CODE=19, + HCI_PAGE_SCAN_REPET_MODE_CHG_EVT_CODE=32, + HCI_PIN_CODE_REQ_EVT_CODE=22, + HCI_QOS_SETUP_CMP_EVT_CODE=13, + HCI_QOS_VIOL_EVT_CODE=30, + HCI_RD_CLK_OFF_CMP_EVT_CODE=28, + HCI_RD_REM_EXT_FEATS_CMP_EVT_CODE=35, + HCI_RD_REM_SUPP_FEATS_CMP_EVT_CODE=11, + HCI_RD_REM_VER_INFO_CMP_EVT_CODE=12, + HCI_REM_HOST_SUPP_FEATS_NOTIF_EVT_CODE=61, + HCI_REM_NAME_REQ_CMP_EVT_CODE=7, + HCI_REM_OOB_DATA_REQ_EVT_CODE=53, + HCI_RETURN_LINK_KEYS_EVT_CODE=21, + HCI_ROLE_CHG_EVT_CODE=18, + HCI_SLV_PAGE_RSP_TO_EVT_CODE=84, + HCI_SNIFF_SUB_EVT_CODE=46, + HCI_SP_CMP_EVT_CODE=54, + HCI_SYNC_CON_CHG_EVT_CODE=45, + HCI_SYNC_CON_CMP_EVT_CODE=44, + HCI_SYNC_TRAIN_CMP_EVT_CODE=79, + HCI_SYNC_TRAIN_REC_EVT_CODE=80, + HCI_TRUNC_PAGE_CMP_EVT_CODE=83, + HCI_USER_CFM_REQ_EVT_CODE=51, + HCI_USER_PASSKEY_NOTIF_EVT_CODE=59, + HCI_USER_PASSKEY_REQ_EVT_CODE=52 +} hci_evt_code; + +typedef struct hci_enc_change_evt hci_enc_change_evt, *Phci_enc_change_evt; + +struct hci_enc_change_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; + uint8_t enc_stat; + undefined field_0x5; +}; + +typedef struct hci_le_set_host_ch_class_cmd hci_le_set_host_ch_class_cmd, *Phci_le_set_host_ch_class_cmd; + +struct hci_le_set_host_ch_class_cmd { + struct le_chnl_map chmap; +}; + +typedef struct hci_le_set_scan_en_cmd hci_le_set_scan_en_cmd, *Phci_le_set_scan_en_cmd; + +struct hci_le_set_scan_en_cmd { + uint8_t scan_en; + uint8_t filter_duplic_en; +}; + +typedef struct hci_le_con_update_cmp_evt hci_le_con_update_cmp_evt, *Phci_le_con_update_cmp_evt; + +struct hci_le_con_update_cmp_evt { + uint8_t subcode; + uint8_t status; + uint16_t conhdl; + uint16_t con_interval; + uint16_t con_latency; + uint16_t sup_to; +}; + +typedef struct hci_le_create_con_cmd hci_le_create_con_cmd, *Phci_le_create_con_cmd; + +struct hci_le_create_con_cmd { + uint16_t scan_intv; + uint16_t scan_window; + uint8_t init_filt_policy; + uint8_t peer_addr_type; + struct bd_addr peer_addr; + uint8_t own_addr_type; + undefined field_0xd; + uint16_t con_intv_min; + uint16_t con_intv_max; + uint16_t con_latency; + uint16_t superv_to; + uint16_t ce_len_min; + uint16_t ce_len_max; +}; + +typedef struct hci_disconnect_cmd hci_disconnect_cmd, *Phci_disconnect_cmd; + +struct hci_disconnect_cmd { + uint16_t conhdl; + uint8_t reason; + undefined field_0x3; +}; + +typedef struct hci_nb_cmp_pkts_evt hci_nb_cmp_pkts_evt, *Phci_nb_cmp_pkts_evt; + +struct hci_nb_cmp_pkts_evt { + uint8_t nb_of_hdl; + undefined field_0x1; + uint16_t conhdl[1]; + uint16_t nb_comp_pkt[1]; +}; + +typedef struct hci_auth_payl_to_exp_evt hci_auth_payl_to_exp_evt, *Phci_auth_payl_to_exp_evt; + +struct hci_auth_payl_to_exp_evt { + uint16_t conhdl; +}; + +typedef struct hci_rd_local_ver_info_cmd_cmp_evt hci_rd_local_ver_info_cmd_cmp_evt, *Phci_rd_local_ver_info_cmd_cmp_evt; + +struct hci_rd_local_ver_info_cmd_cmp_evt { + uint8_t status; + uint8_t hci_ver; + uint16_t hci_rev; + uint8_t lmp_ver; + undefined field_0x5; + uint16_t manuf_name; + uint16_t lmp_subver; +}; + +typedef struct hci_le_rd_rem_used_feats_cmd hci_le_rd_rem_used_feats_cmd, *Phci_le_rd_rem_used_feats_cmd; + +struct hci_le_rd_rem_used_feats_cmd { + uint16_t conhdl; +}; + +typedef struct hci_le_data_len_chg_evt hci_le_data_len_chg_evt, *Phci_le_data_len_chg_evt; + +struct hci_le_data_len_chg_evt { + uint8_t subcode; + undefined field_0x1; + uint16_t conhdl; + uint16_t max_tx_octets; + uint16_t max_tx_time; + uint16_t max_rx_octets; + uint16_t max_rx_time; +}; + +typedef struct hci_le_set_data_len_cmd hci_le_set_data_len_cmd, *Phci_le_set_data_len_cmd; + +struct hci_le_set_data_len_cmd { + uint16_t conhdl; + uint16_t tx_octets; + uint16_t tx_time; +}; + +typedef struct hci_rd_bd_addr_cmd_cmp_evt hci_rd_bd_addr_cmd_cmp_evt, *Phci_rd_bd_addr_cmd_cmp_evt; + +struct hci_rd_bd_addr_cmd_cmp_evt { + uint8_t status; + struct bd_addr local_addr; +}; + +typedef struct hci_rd_adv_chnl_tx_pw_cmd_cmp_evt hci_rd_adv_chnl_tx_pw_cmd_cmp_evt, *Phci_rd_adv_chnl_tx_pw_cmd_cmp_evt; + +struct hci_rd_adv_chnl_tx_pw_cmd_cmp_evt { + uint8_t status; + int8_t adv_tx_pw_lvl; +}; + +typedef struct hci_le_wr_rfpath_cps_cmd hci_le_wr_rfpath_cps_cmd, *Phci_le_wr_rfpath_cps_cmd; + +struct hci_le_wr_rfpath_cps_cmd { + uint16_t rf_txpath_compensation_value; + uint16_t rf_rxpath_compensation_value; +}; + +typedef struct hci_le_set_evt_mask_cmd hci_le_set_evt_mask_cmd, *Phci_le_set_evt_mask_cmd; + +struct hci_le_set_evt_mask_cmd { + struct evt_mask le_mask; +}; + +typedef struct hci_basic_conhdl_cmd_cmp_evt hci_basic_conhdl_cmd_cmp_evt, *Phci_basic_conhdl_cmd_cmp_evt; + +struct hci_basic_conhdl_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; +}; + +typedef struct hci_rd_buff_size_cmd_cmp_evt hci_rd_buff_size_cmd_cmp_evt, *Phci_rd_buff_size_cmd_cmp_evt; + +struct hci_rd_buff_size_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t hc_data_pk_len; + uint8_t hc_sync_pk_len; + undefined field_0x5; + uint16_t hc_tot_nb_data_pkts; + uint16_t hc_tot_nb_sync_pkts; +}; + +typedef struct hci_wr_auth_payl_to_cmd_cmp_evt hci_wr_auth_payl_to_cmd_cmp_evt, *Phci_wr_auth_payl_to_cmd_cmp_evt; + +struct hci_wr_auth_payl_to_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; +}; + +typedef struct hci_le_tx_test_cmd hci_le_tx_test_cmd, *Phci_le_tx_test_cmd; + +struct hci_le_tx_test_cmd { + uint8_t tx_freq; + uint8_t test_data_len; + uint8_t pk_payload_type; +}; + +typedef struct hci_le_rd_local_supp_feats_cmd_cmp_evt hci_le_rd_local_supp_feats_cmd_cmp_evt, *Phci_le_rd_local_supp_feats_cmd_cmp_evt; + +struct hci_le_rd_local_supp_feats_cmd_cmp_evt { + uint8_t status; + struct le_features feats; +}; + +typedef struct hci_rd_rem_ver_info_cmd hci_rd_rem_ver_info_cmd, *Phci_rd_rem_ver_info_cmd; + +struct hci_rd_rem_ver_info_cmd { + uint16_t conhdl; +}; + +typedef struct hci_le_adv_report_evt hci_le_adv_report_evt, *Phci_le_adv_report_evt; + +struct hci_le_adv_report_evt { + uint8_t subcode; + uint8_t nb_reports; + struct adv_report adv_rep[1]; +}; + +typedef struct hci_flush_cmd_cmp_evt hci_flush_cmd_cmp_evt, *Phci_flush_cmd_cmp_evt; + +struct hci_flush_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; +}; + +typedef struct hci_le_set_rand_addr_cmd hci_le_set_rand_addr_cmd, *Phci_le_set_rand_addr_cmd; + +struct hci_le_set_rand_addr_cmd { + struct bd_addr rand_addr; +}; + +typedef struct hci_le_start_enc_cmd hci_le_start_enc_cmd, *Phci_le_start_enc_cmd; + +struct hci_le_start_enc_cmd { + uint16_t conhdl; + struct rand_nb nb; + uint16_t enc_div; + struct ltk ltk; +}; + +typedef struct hci_test_end_cmd_cmp_evt hci_test_end_cmd_cmp_evt, *Phci_test_end_cmd_cmp_evt; + +struct hci_test_end_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t nb_packet_received; +}; + +typedef struct hci_disc_cmp_evt hci_disc_cmp_evt, *Phci_disc_cmp_evt; + +struct hci_disc_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; + uint8_t reason; + undefined field_0x5; +}; + +typedef enum hci_evt_mask_page { + HCI_PAGE_0=0, + HCI_PAGE_1=1, + HCI_PAGE_2=2, + HCI_PAGE_DFT=3 +} hci_evt_mask_page; + +typedef struct hci_vsc_set_tx_pwr_cmd hci_vsc_set_tx_pwr_cmd, *Phci_vsc_set_tx_pwr_cmd; + +struct hci_vsc_set_tx_pwr_cmd { + int8_t power; +}; + +typedef struct hci_le_set_scan_rsp_data_cmd hci_le_set_scan_rsp_data_cmd, *Phci_le_set_scan_rsp_data_cmd; + +struct hci_le_set_scan_rsp_data_cmd { + uint8_t scan_rsp_data_len; + struct scan_rsp_data data; +}; + +typedef struct hci_enc_key_ref_cmp_evt hci_enc_key_ref_cmp_evt, *Phci_enc_key_ref_cmp_evt; + +struct hci_enc_key_ref_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; +}; + +typedef struct hci_le_rd_chnl_map_cmd_cmp_evt hci_le_rd_chnl_map_cmd_cmp_evt, *Phci_le_rd_chnl_map_cmd_cmp_evt; + +struct hci_le_rd_chnl_map_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; + struct le_chnl_map ch_map; + undefined field_0x9; +}; + +typedef struct hci_le_enh_con_cmp_evt hci_le_enh_con_cmp_evt, *Phci_le_enh_con_cmp_evt; + +struct hci_le_enh_con_cmp_evt { + uint8_t subcode; + uint8_t status; + uint16_t conhdl; + uint8_t role; + uint8_t peer_addr_type; + struct bd_addr peer_addr; + struct bd_addr loc_rslv_priv_addr; + struct bd_addr peer_rslv_priv_addr; + uint16_t con_interval; + uint16_t con_latency; + uint16_t sup_to; + uint8_t clk_accuracy; + undefined field_0x1f; +}; + +typedef struct hci_rd_rfpath_cps_cmd_cmp_evt hci_rd_rfpath_cps_cmd_cmp_evt, *Phci_rd_rfpath_cps_cmd_cmp_evt; + +struct hci_rd_rfpath_cps_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t rf_txpath_compensation_value; + uint16_t rf_rxpath_compensation_value; +}; + +typedef enum hci_opcode { + HCI_ACCEPT_CON_REQ_CMD_OPCODE=1033, + HCI_ACCEPT_SYNC_CON_REQ_CMD_OPCODE=1065, + HCI_AUTH_REQ_CMD_OPCODE=1041, + HCI_CHG_CON_LK_CMD_OPCODE=1045, + HCI_CHG_CON_PKT_TYPE_CMD_OPCODE=1039, + HCI_CREATE_CON_CANCEL_CMD_OPCODE=1032, + HCI_CREATE_CON_CMD_OPCODE=1029, + HCI_CREATE_NEW_UNIT_KEY_CMD_OPCODE=3083, + HCI_DBG_BLE_TST_LLCP_PT_EN_CMD_OPCODE=-958, + HCI_DBG_BLE_TST_SEND_LLCP_CMD_OPCODE=-957, + HCI_DBG_BT_SEND_LMP_CMD_OPCODE=-1010, + HCI_DBG_DEL_PAR_CMD_OPCODE=-1021, + HCI_DBG_ER_FLASH_CMD_OPCODE=-1018, + HCI_DBG_HW_REG_RD_CMD_OPCODE=-976, + HCI_DBG_HW_REG_WR_CMD_OPCODE=-975, + HCI_DBG_ID_FLASH_CMD_OPCODE=-1019, + HCI_DBG_LLCP_DISCARD_CMD_OPCODE=-970, + HCI_DBG_MWS_COEXTST_SCEN_CMD_OPCODE=-954, + HCI_DBG_MWS_COEX_CMD_OPCODE=-955, + HCI_DBG_PLF_RESET_CMD_OPCODE=-1007, + HCI_DBG_RD_FLASH_CMD_OPCODE=-1016, + HCI_DBG_RD_KE_STATS_CMD_OPCODE=-1008, + HCI_DBG_RD_MEM_CMD_OPCODE=-1023, + HCI_DBG_RD_MEM_INFO_CMD_OPCODE=-1006, + HCI_DBG_RD_PAR_CMD_OPCODE=-1015, + HCI_DBG_RESET_RX_CNT_CMD_OPCODE=-969, + HCI_DBG_RESET_TX_CNT_CMD_OPCODE=-968, + HCI_DBG_RF_CNTL_TX_CMD_OPCODE=-961, + HCI_DBG_RF_RD_DATA_RX_CMD_OPCODE=-962, + HCI_DBG_RF_REG_RD_CMD_OPCODE=-967, + HCI_DBG_RF_REG_WR_CMD_OPCODE=-966, + HCI_DBG_RF_SWITCH_CLK_CMD_OPCODE=-964, + HCI_DBG_RF_SYNC_P_CNTL_CMD_OPCODE=-960, + HCI_DBG_RF_WR_DATA_TX_CMD_OPCODE=-963, + HCI_DBG_SET_BD_ADDR_CMD_OPCODE=-974, + HCI_DBG_SET_CRC_CMD_OPCODE=-971, + HCI_DBG_SET_LOCAL_CLOCK_CMD_OPCODE=-1009, + HCI_DBG_SET_TX_PW_CMD_OPCODE=-965, + HCI_DBG_SET_TYPE_PUB_CMD_OPCODE=-973, + HCI_DBG_SET_TYPE_RAND_CMD_OPCODE=-972, + HCI_DBG_WLAN_COEXTST_SCEN_CMD_OPCODE=-1011, + HCI_DBG_WLAN_COEX_CMD_OPCODE=-1013, + HCI_DBG_WR_DLE_DFT_VALUE_CMD_OPCODE=-959, + HCI_DBG_WR_FLASH_CMD_OPCODE=-1017, + HCI_DBG_WR_MEM_CMD_OPCODE=-1022, + HCI_DBG_WR_PAR_CMD_OPCODE=-1014, + HCI_DEL_RES_LT_ADDR_CMD_OPCODE=3189, + HCI_DEL_STORED_LK_CMD_OPCODE=3090, + HCI_DISCONNECT_CMD_OPCODE=1030, + HCI_ENH_ACCEPT_SYNC_CON_CMD_OPCODE=1086, + HCI_ENH_FLUSH_CMD_OPCODE=3167, + HCI_ENH_SETUP_SYNC_CON_CMD_OPCODE=1085, + HCI_EN_DUT_MODE_CMD_OPCODE=6147, + HCI_EXIT_PARK_STATE_CMD_OPCODE=2054, + HCI_EXIT_PER_INQ_MODE_CMD_OPCODE=1028, + HCI_EXIT_SNIFF_MODE_CMD_OPCODE=2052, + HCI_FLOW_SPEC_CMD_OPCODE=2064, + HCI_FLUSH_CMD_OPCODE=3080, + HCI_GET_MWS_TRANSPORT_LAYER_CONFIG_CMD_OPCODE=5132, + HCI_HOLD_MODE_CMD_OPCODE=2049, + HCI_HOST_BUF_SIZE_CMD_OPCODE=3123, + HCI_HOST_NB_CMP_PKTS_CMD_OPCODE=3125, + HCI_INQ_CANCEL_CMD_OPCODE=1026, + HCI_INQ_CMD_OPCODE=1025, + HCI_IO_CAP_REQ_NEG_REPLY_CMD_OPCODE=1076, + HCI_IO_CAP_REQ_REPLY_CMD_OPCODE=1067, + HCI_LE_ADD_DEV_TO_RSLV_LIST_CMD_OPCODE=8231, + HCI_LE_ADD_DEV_TO_WLST_CMD_OPCODE=8209, + HCI_LE_CLEAR_RSLV_LIST_CMD_OPCODE=8233, + HCI_LE_CLEAR_WLST_CMD_OPCODE=8208, + HCI_LE_CON_UPDATE_CMD_OPCODE=8211, + HCI_LE_CREATE_CON_CANCEL_CMD_OPCODE=8206, + HCI_LE_CREATE_CON_CMD_OPCODE=8205, + HCI_LE_ENC_CMD_OPCODE=8215, + HCI_LE_GEN_DHKEY_CMD_OPCODE=8230, + HCI_LE_LTK_REQ_NEG_REPLY_CMD_OPCODE=8219, + HCI_LE_LTK_REQ_REPLY_CMD_OPCODE=8218, + HCI_LE_RAND_CMD_OPCODE=8216, + HCI_LE_RD_ADV_CHNL_TX_PW_CMD_OPCODE=8199, + HCI_LE_RD_BUFF_SIZE_CMD_OPCODE=8194, + HCI_LE_RD_CHNL_MAP_CMD_OPCODE=8213, + HCI_LE_RD_LOCAL_SUPP_FEATS_CMD_OPCODE=8195, + HCI_LE_RD_LOC_P256_PUB_KEY_CMD_OPCODE=8229, + HCI_LE_RD_LOC_RSLV_ADDR_CMD_OPCODE=8236, + HCI_LE_RD_MAX_DATA_LEN_CMD_OPCODE=8239, + HCI_LE_RD_PEER_RSLV_ADDR_CMD_OPCODE=8235, + HCI_LE_RD_REM_USED_FEATS_CMD_OPCODE=8214, + HCI_LE_RD_RFPATH_CPS_CMD_OPCODE=8268, + HCI_LE_RD_RSLV_LIST_SIZE_CMD_OPCODE=8234, + HCI_LE_RD_SUGGTED_DFT_DATA_LEN_CMD_OPCODE=8227, + HCI_LE_RD_SUPP_STATES_CMD_OPCODE=8220, + HCI_LE_RD_TRANS_PWR_CMD_OPCODE=8267, + HCI_LE_RD_WLST_SIZE_CMD_OPCODE=8207, + HCI_LE_REM_CON_PARAM_REQ_NEG_REPLY_CMD_OPCODE=8225, + HCI_LE_REM_CON_PARAM_REQ_REPLY_CMD_OPCODE=8224, + HCI_LE_RMV_DEV_FROM_RSLV_LIST_CMD_OPCODE=8232, + HCI_LE_RMV_DEV_FROM_WLST_CMD_OPCODE=8210, + HCI_LE_RX_TEST_CMD_OPCODE=8221, + HCI_LE_SET_ADDR_RESOL_EN_CMD_OPCODE=8237, + HCI_LE_SET_ADV_DATA_CMD_OPCODE=8200, + HCI_LE_SET_ADV_EN_CMD_OPCODE=8202, + HCI_LE_SET_ADV_PARAM_CMD_OPCODE=8198, + HCI_LE_SET_DATA_LEN_CMD_OPCODE=8226, + HCI_LE_SET_EVT_MASK_CMD_OPCODE=8193, + HCI_LE_SET_HOST_CH_CLASS_CMD_OPCODE=8212, + HCI_LE_SET_RAND_ADDR_CMD_OPCODE=8197, + HCI_LE_SET_RSLV_PRIV_ADDR_TO_CMD_OPCODE=8238, + HCI_LE_SET_SCAN_EN_CMD_OPCODE=8204, + HCI_LE_SET_SCAN_PARAM_CMD_OPCODE=8203, + HCI_LE_SET_SCAN_RSP_DATA_CMD_OPCODE=8201, + HCI_LE_START_ENC_CMD_OPCODE=8217, + HCI_LE_TEST_END_CMD_OPCODE=8223, + HCI_LE_TX_TEST_CMD_OPCODE=8222, + HCI_LE_WR_RFPATH_CPS_CMD_OPCODE=8269, + HCI_LE_WR_SUGGTED_DFT_DATA_LEN_CMD_OPCODE=8228, + HCI_LK_REQ_NEG_REPLY_CMD_OPCODE=1036, + HCI_LK_REQ_REPLY_CMD_OPCODE=1035, + HCI_MASTER_LK_CMD_OPCODE=1047, + HCI_NO_OPERATION_CMD_OPCODE=0, + HCI_PARK_STATE_CMD_OPCODE=2053, + HCI_PER_INQ_MODE_CMD_OPCODE=1027, + HCI_PIN_CODE_REQ_NEG_REPLY_CMD_OPCODE=1038, + HCI_PIN_CODE_REQ_REPLY_CMD_OPCODE=1037, + HCI_QOS_SETUP_CMD_OPCODE=2055, + HCI_RD_AFH_CH_ASSESS_MODE_CMD_OPCODE=3144, + HCI_RD_AFH_CH_MAP_CMD_OPCODE=5126, + HCI_RD_AUTH_EN_CMD_OPCODE=3103, + HCI_RD_AUTH_PAYL_TO_CMD_OPCODE=3195, + HCI_RD_AUTO_FLUSH_TO_CMD_OPCODE=3111, + HCI_RD_BD_ADDR_CMD_OPCODE=4105, + HCI_RD_BUFF_SIZE_CMD_OPCODE=4101, + HCI_RD_CLASS_OF_DEV_CMD_OPCODE=3107, + HCI_RD_CLK_CMD_OPCODE=5127, + HCI_RD_CLK_OFF_CMD_OPCODE=1055, + HCI_RD_CON_ACCEPT_TO_CMD_OPCODE=3093, + HCI_RD_CURR_IAC_LAP_CMD_OPCODE=3129, + HCI_RD_DFT_ERR_DATA_REP_CMD_OPCODE=3162, + HCI_RD_DFT_LINK_POL_STG_CMD_OPCODE=2062, + HCI_RD_ENC_KEY_SIZE_CMD_OPCODE=5128, + HCI_RD_ENH_TX_PWR_LVL_CMD_OPCODE=3176, + HCI_RD_EXT_INQ_LEN_CMD_OPCODE=3200, + HCI_RD_EXT_INQ_RSP_CMD_OPCODE=3153, + HCI_RD_EXT_PAGE_TO_CMD_OPCODE=3198, + HCI_RD_FAIL_CONTACT_CNT_CMD_OPCODE=5121, + HCI_RD_FLOW_CNTL_MODE_CMD_OPCODE=3174, + HCI_RD_HOLD_MODE_ACTIVITY_CMD_OPCODE=3115, + HCI_RD_INQ_MODE_CMD_OPCODE=3140, + HCI_RD_INQ_RSP_TX_PWR_LVL_CMD_OPCODE=3160, + HCI_RD_INQ_SCAN_ACT_CMD_OPCODE=3101, + HCI_RD_INQ_SCAN_TYPE_CMD_OPCODE=3138, + HCI_RD_LE_HOST_SUPP_CMD_OPCODE=3180, + HCI_RD_LINK_POL_STG_CMD_OPCODE=2060, + HCI_RD_LINK_QUAL_CMD_OPCODE=5123, + HCI_RD_LINK_SUPV_TO_CMD_OPCODE=3126, + HCI_RD_LMP_HDL_CMD_OPCODE=1056, + HCI_RD_LOCAL_EXT_FEATS_CMD_OPCODE=4100, + HCI_RD_LOCAL_NAME_CMD_OPCODE=3092, + HCI_RD_LOCAL_SUPP_CMDS_CMD_OPCODE=4098, + HCI_RD_LOCAL_SUPP_CODECS_CMD_OPCODE=4107, + HCI_RD_LOCAL_SUPP_FEATS_CMD_OPCODE=4099, + HCI_RD_LOCAL_VER_INFO_CMD_OPCODE=4097, + HCI_RD_LOC_OOB_DATA_CMD_OPCODE=3159, + HCI_RD_LOC_OOB_EXT_DATA_CMD_OPCODE=3197, + HCI_RD_LOOPBACK_MODE_CMD_OPCODE=6145, + HCI_RD_NB_BDCST_RETX_CMD_OPCODE=3113, + HCI_RD_NB_SUPP_IAC_CMD_OPCODE=3128, + HCI_RD_PAGE_SCAN_ACT_CMD_OPCODE=3099, + HCI_RD_PAGE_SCAN_TYPE_CMD_OPCODE=3142, + HCI_RD_PAGE_TO_CMD_OPCODE=3095, + HCI_RD_PIN_TYPE_CMD_OPCODE=3081, + HCI_RD_REM_EXT_FEATS_CMD_OPCODE=1052, + HCI_RD_REM_SUPP_FEATS_CMD_OPCODE=1051, + HCI_RD_REM_VER_INFO_CMD_OPCODE=1053, + HCI_RD_RSSI_CMD_OPCODE=5125, + HCI_RD_SCAN_EN_CMD_OPCODE=3097, + HCI_RD_SEC_CON_HOST_SUPP_CMD_OPCODE=3193, + HCI_RD_SP_MODE_CMD_OPCODE=3157, + HCI_RD_STORED_LK_CMD_OPCODE=3085, + HCI_RD_SYNC_FLOW_CTRL_EN_CMD_OPCODE=3118, + HCI_RD_SYNC_TRAIN_PARAM_CMD_OPCODE=3191, + HCI_RD_TX_PWR_LVL_CMD_OPCODE=3117, + HCI_RD_VOICE_STG_CMD_OPCODE=3109, + HCI_REC_SYNC_TRAIN_CMD_OPCODE=1092, + HCI_REFRESH_ENC_KEY_CMD_OPCODE=3155, + HCI_REJECT_CON_REQ_CMD_OPCODE=1034, + HCI_REJECT_SYNC_CON_REQ_CMD_OPCODE=1066, + HCI_REM_NAME_REQ_CANCEL_CMD_OPCODE=1050, + HCI_REM_NAME_REQ_CMD_OPCODE=1049, + HCI_REM_OOB_DATA_REQ_NEG_REPLY_CMD_OPCODE=1075, + HCI_REM_OOB_DATA_REQ_REPLY_CMD_OPCODE=1072, + HCI_REM_OOB_EXT_DATA_REQ_REPLY_CMD_OPCODE=1093, + HCI_RESET_CMD_OPCODE=3075, + HCI_ROLE_DISCOVERY_CMD_OPCODE=2057, + HCI_RST_FAIL_CONTACT_CNT_CMD_OPCODE=5122, + HCI_SEND_KEYPRESS_NOTIF_CMD_OPCODE=3168, + HCI_SETUP_SYNC_CON_CMD_OPCODE=1064, + HCI_SET_AFH_HOST_CH_CLASS_CMD_OPCODE=3135, + HCI_SET_CON_ENC_CMD_OPCODE=1043, + HCI_SET_CON_SLV_BCST_CMD_OPCODE=1089, + HCI_SET_CON_SLV_BCST_DATA_CMD_OPCODE=3190, + HCI_SET_CON_SLV_BCST_REC_CMD_OPCODE=1090, + HCI_SET_CTRL_TO_HOST_FLOW_CTRL_CMD_OPCODE=3121, + HCI_SET_EVT_FILTER_CMD_OPCODE=3077, + HCI_SET_EVT_MASK_CMD_OPCODE=3073, + HCI_SET_EVT_MASK_PAGE_2_CMD_OPCODE=3171, + HCI_SET_EXTERNAL_FRAME_CONFIG_CMD_OPCODE=3183, + HCI_SET_MWS_CHANNEL_PARAMS_CMD_OPCODE=3182, + HCI_SET_MWS_PATTERN_CONFIG_CMD_OPCODE=3187, + HCI_SET_MWS_SCAN_FREQ_TABLE_CMD_OPCODE=3186, + HCI_SET_MWS_SIGNALING_CMD_OPCODE=3184, + HCI_SET_MWS_TRANSPORT_LAYER_CMD_OPCODE=3185, + HCI_SET_RES_LT_ADDR_CMD_OPCODE=3188, + HCI_SET_TX_PWR_CMD_OPCODE=-927, + HCI_SNIFF_MODE_CMD_OPCODE=2051, + HCI_SNIFF_SUB_CMD_OPCODE=2065, + HCI_START_SYNC_TRAIN_CMD_OPCODE=1091, + HCI_SWITCH_ROLE_CMD_OPCODE=2059, + HCI_TESTER_SET_LE_PARAMS_CMD_OPCODE=-960, + HCI_TRUNC_PAGE_CAN_CMD_OPCODE=1088, + HCI_TRUNC_PAGE_CMD_OPCODE=1087, + HCI_USER_CFM_REQ_NEG_REPLY_CMD_OPCODE=1069, + HCI_USER_CFM_REQ_REPLY_CMD_OPCODE=1068, + HCI_USER_PASSKEY_REQ_NEG_REPLY_CMD_OPCODE=1071, + HCI_USER_PASSKEY_REQ_REPLY_CMD_OPCODE=1070, + HCI_VS_AUDIO_ALLOCATE_CMD_OPCODE=-944, + HCI_VS_AUDIO_CONFIGURE_CMD_OPCODE=-943, + HCI_VS_AUDIO_GET_BUFFER_RANGE_CMD_OPCODE=-939, + HCI_VS_AUDIO_RESET_CMD_OPCODE=-941, + HCI_VS_AUDIO_SET_MODE_CMD_OPCODE=-942, + HCI_VS_AUDIO_SET_POINTER_CMD_OPCODE=-940, + HCI_WR_AFH_CH_ASSESS_MODE_CMD_OPCODE=3145, + HCI_WR_AUTH_EN_CMD_OPCODE=3104, + HCI_WR_AUTH_PAYL_TO_CMD_OPCODE=3196, + HCI_WR_AUTO_FLUSH_TO_CMD_OPCODE=3112, + HCI_WR_CLASS_OF_DEV_CMD_OPCODE=3108, + HCI_WR_CON_ACCEPT_TO_CMD_OPCODE=3094, + HCI_WR_CURR_IAC_LAP_CMD_OPCODE=3130, + HCI_WR_DFT_ERR_DATA_REP_CMD_OPCODE=3163, + HCI_WR_DFT_LINK_POL_STG_CMD_OPCODE=2063, + HCI_WR_EXT_INQ_LEN_CMD_OPCODE=3201, + HCI_WR_EXT_INQ_RSP_CMD_OPCODE=3154, + HCI_WR_EXT_PAGE_TO_CMD_OPCODE=3199, + HCI_WR_FLOW_CNTL_MODE_CMD_OPCODE=3175, + HCI_WR_HOLD_MODE_ACTIVITY_CMD_OPCODE=3116, + HCI_WR_INQ_MODE_CMD_OPCODE=3141, + HCI_WR_INQ_SCAN_ACT_CMD_OPCODE=3102, + HCI_WR_INQ_SCAN_TYPE_CMD_OPCODE=3139, + HCI_WR_INQ_TX_PWR_LVL_CMD_OPCODE=3161, + HCI_WR_LE_HOST_SUPP_CMD_OPCODE=3181, + HCI_WR_LINK_POL_STG_CMD_OPCODE=2061, + HCI_WR_LINK_SUPV_TO_CMD_OPCODE=3127, + HCI_WR_LOCAL_NAME_CMD_OPCODE=3091, + HCI_WR_LOOPBACK_MODE_CMD_OPCODE=6146, + HCI_WR_NB_BDCST_RETX_CMD_OPCODE=3114, + HCI_WR_PAGE_SCAN_ACT_CMD_OPCODE=3100, + HCI_WR_PAGE_SCAN_TYPE_CMD_OPCODE=3143, + HCI_WR_PAGE_TO_CMD_OPCODE=3096, + HCI_WR_PIN_TYPE_CMD_OPCODE=3082, + HCI_WR_SCAN_EN_CMD_OPCODE=3098, + HCI_WR_SEC_CON_HOST_SUPP_CMD_OPCODE=3194, + HCI_WR_SEC_CON_TEST_MODE_CMD_OPCODE=6154, + HCI_WR_SP_DBG_MODE_CMD_OPCODE=6148, + HCI_WR_SP_MODE_CMD_OPCODE=3158, + HCI_WR_STORED_LK_CMD_OPCODE=3089, + HCI_WR_SYNC_FLOW_CTRL_EN_CMD_OPCODE=3119, + HCI_WR_SYNC_TRAIN_PARAM_CMD_OPCODE=3192, + HCI_WR_VOICE_STG_CMD_OPCODE=3110 +} hci_opcode; + +typedef struct hci_le_enc_cmd hci_le_enc_cmd, *Phci_le_enc_cmd; + +struct hci_le_enc_cmd { + struct ltk key; + uint8_t plain_data[16]; +}; + +typedef struct hci_rd_trans_pwr_cmd_cmp_evt hci_rd_trans_pwr_cmd_cmp_evt, *Phci_rd_trans_pwr_cmd_cmp_evt; + +struct hci_rd_trans_pwr_cmd_cmp_evt { + uint8_t status; + char min_tx_pwr; + char max_tx_pwr; +}; + +typedef struct hci_cmd_stat_event hci_cmd_stat_event, *Phci_cmd_stat_event; + +struct hci_cmd_stat_event { + uint8_t status; +}; + +typedef struct hci_le_rem_con_param_req_reply_cmd hci_le_rem_con_param_req_reply_cmd, *Phci_le_rem_con_param_req_reply_cmd; + +struct hci_le_rem_con_param_req_reply_cmd { + uint16_t conhdl; + uint16_t interval_min; + uint16_t interval_max; + uint16_t latency; + uint16_t timeout; + uint16_t min_ce_len; + uint16_t max_ce_len; +}; + +typedef struct hci_le_rem_con_param_req_evt hci_le_rem_con_param_req_evt, *Phci_le_rem_con_param_req_evt; + +struct hci_le_rem_con_param_req_evt { + uint8_t subcode; + undefined field_0x1; + uint16_t conhdl; + uint16_t interval_min; + uint16_t interval_max; + uint16_t latency; + uint16_t timeout; +}; + +typedef struct hci_le_add_dev_to_wlst_cmd hci_le_add_dev_to_wlst_cmd, *Phci_le_add_dev_to_wlst_cmd; + +struct hci_le_add_dev_to_wlst_cmd { + uint8_t dev_addr_type; + struct bd_addr dev_addr; +}; + +typedef struct hci_le_dir_adv_rep_evt hci_le_dir_adv_rep_evt, *Phci_le_dir_adv_rep_evt; + +struct hci_le_dir_adv_rep_evt { + uint8_t subcode; + uint8_t nb_reports; + struct dir_adv_report adv_rep[1]; +}; + +typedef struct hci_le_set_adv_data_cmd hci_le_set_adv_data_cmd, *Phci_le_set_adv_data_cmd; + +struct hci_le_set_adv_data_cmd { + uint8_t adv_data_len; + struct adv_data data; +}; + +typedef struct hci_data_buf_ovflw_evt hci_data_buf_ovflw_evt, *Phci_data_buf_ovflw_evt; + +struct hci_data_buf_ovflw_evt { + uint8_t link_type; +}; + +typedef struct hci_wr_auth_payl_to_cmd hci_wr_auth_payl_to_cmd, *Phci_wr_auth_payl_to_cmd; + +struct hci_wr_auth_payl_to_cmd { + uint16_t conhdl; + uint16_t auth_payl_to; +}; + +typedef struct hci_rd_rssi_cmd_cmp_evt hci_rd_rssi_cmd_cmp_evt, *Phci_rd_rssi_cmd_cmp_evt; + +struct hci_rd_rssi_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; + int8_t rssi; + undefined field_0x5; +}; + +typedef struct hci_acl_data_rx hci_acl_data_rx, *Phci_acl_data_rx; + +struct hci_acl_data_rx { + uint16_t conhdl; + uint8_t pb_bc_flag; + undefined field_0x3; + uint16_t length; + uint8_t rx_hdl; + undefined field_0x7; +}; + +typedef struct hci_le_set_adv_en_cmd hci_le_set_adv_en_cmd, *Phci_le_set_adv_en_cmd; + +struct hci_le_set_adv_en_cmd { + uint8_t adv_en; +}; + +typedef struct hci_le_wr_suggted_dft_data_len_cmd hci_le_wr_suggted_dft_data_len_cmd, *Phci_le_wr_suggted_dft_data_len_cmd; + +struct hci_le_wr_suggted_dft_data_len_cmd { + uint16_t suggted_max_tx_octets; + uint16_t suggted_max_tx_time; +}; + +typedef struct hci_le_generate_p256_public_key_cmp_evt hci_le_generate_p256_public_key_cmp_evt, *Phci_le_generate_p256_public_key_cmp_evt; + +struct hci_le_generate_p256_public_key_cmp_evt { + uint8_t subcode; + uint8_t status; + struct t_public_key public_key; +}; + +typedef struct hci_le_con_cmp_evt hci_le_con_cmp_evt, *Phci_le_con_cmp_evt; + +struct hci_le_con_cmp_evt { + uint8_t subcode; + uint8_t status; + uint16_t conhdl; + uint8_t role; + uint8_t peer_addr_type; + struct bd_addr peer_addr; + uint16_t con_interval; + uint16_t con_latency; + uint16_t sup_to; + uint8_t clk_accuracy; + undefined field_0x13; +}; + +typedef struct hci_le_con_update_cmd hci_le_con_update_cmd, *Phci_le_con_update_cmd; + +struct hci_le_con_update_cmd { + uint16_t conhdl; + uint16_t con_intv_min; + uint16_t con_intv_max; + uint16_t con_latency; + uint16_t superv_to; + uint16_t ce_len_min; + uint16_t ce_len_max; +}; + +typedef struct hci_acl_data_tx hci_acl_data_tx, *Phci_acl_data_tx; + +struct hci_acl_data_tx { + uint16_t conhdl; + uint8_t pb_bc_flag; + undefined field_0x3; + uint16_t length; + undefined field_0x6; + undefined field_0x7; + struct em_buf_node * buf; +}; + +typedef struct hci_le_rd_max_data_len_cmd_cmp_evt hci_le_rd_max_data_len_cmd_cmp_evt, *Phci_le_rd_max_data_len_cmd_cmp_evt; + +struct hci_le_rd_max_data_len_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t suppted_max_tx_octets; + uint16_t suppted_max_tx_time; + uint16_t suppted_max_rx_octets; + uint16_t suppted_max_rx_time; +}; + +typedef struct hci_flush_occurred_evt hci_flush_occurred_evt, *Phci_flush_occurred_evt; + +struct hci_flush_occurred_evt { + uint16_t conhdl; +}; + +typedef enum td_status_bit { + TD_STATUS_RX=1, + TD_STATUS_RX_PS=3, + TD_STATUS_TX=0, + TD_STATUS_TX_PS=2 +} td_status_bit; + +typedef struct td_env_tag td_env_tag, *Ptd_env_tag; + +struct td_env_tag { + struct mm_timer_tag td_timer; + uint32_t pck_cnt_tx; + uint32_t pck_cnt_rx; + uint32_t pck_cnt_tx_ps; + uint32_t pck_cnt_rx_ps; + uint8_t vif_index; + uint8_t status; + _Bool is_on; + _Bool has_active_chan; +}; + +typedef struct bt_mesh_adv.conflict10 bt_mesh_adv.conflict10, *Pbt_mesh_adv.conflict10; + + +// WARNING! conflicting data type names: /DWARF/adv.h/bt_mesh_adv/anon_union_for_field_5 - /DWARF/wifi_mgmr.h/wlan_netif/anon_union_for_field_5 + +struct bt_mesh_adv.conflict10 { + struct bt_mesh_send_cb * cb; + void * cb_data; + u8_t type:2; + u8_t busy:1; + u8_t xmit; + union anon_union_for_field_5 field_5; +}; + +typedef struct anon_struct.conflict462 anon_struct.conflict462, *Panon_struct.conflict462; + +struct anon_struct.conflict462 { + u8_t attempts; +}; + +typedef struct bt_mesh_adv.conflict3 bt_mesh_adv.conflict3, *Pbt_mesh_adv.conflict3; + +struct bt_mesh_adv.conflict3 { + struct bt_mesh_send_cb * cb; + void * cb_data; + u8_t type:2; + u8_t busy:1; + u8_t xmit; + union anon_union_for_field_5 field_5; +}; + +typedef struct bt_mesh_adv.conflict1 bt_mesh_adv.conflict1, *Pbt_mesh_adv.conflict1; + +struct bt_mesh_adv.conflict1 { + struct bt_mesh_send_cb * cb; + void * cb_data; + u8_t type:2; + u8_t busy:1; + u8_t xmit; + union anon_union_for_field_5 field_5; +}; + +typedef struct bt_mesh_adv.conflict7 bt_mesh_adv.conflict7, *Pbt_mesh_adv.conflict7; + +struct bt_mesh_adv.conflict7 { + struct bt_mesh_send_cb * cb; + void * cb_data; + u8_t type:2; + u8_t busy:1; + u8_t xmit; + union anon_union_for_field_5 field_5; +}; + +typedef struct bt_mesh_adv.conflict bt_mesh_adv.conflict, *Pbt_mesh_adv.conflict; + +struct bt_mesh_adv.conflict { + struct bt_mesh_send_cb * cb; + void * cb_data; + u8_t type:2; + u8_t busy:1; + u8_t xmit; + union anon_union_for_field_5 field_5; +}; + +typedef struct anon_struct.conflict433 anon_struct.conflict433, *Panon_struct.conflict433; + +struct anon_struct.conflict433 { + u8_t attempts; +}; + +typedef struct anon_struct.conflict479 anon_struct.conflict479, *Panon_struct.conflict479; + +struct anon_struct.conflict479 { + u8_t attempts; +}; + +typedef struct anon_struct.conflict432 anon_struct.conflict432, *Panon_struct.conflict432; + +struct anon_struct.conflict432 { + u8_t attempts; +}; + +typedef struct bt_mesh_adv bt_mesh_adv, *Pbt_mesh_adv; + +struct bt_mesh_adv { + struct bt_mesh_send_cb * cb; + void * cb_data; + u8_t type:2; + u8_t busy:1; + u8_t xmit; + union anon_union_for_field_5 field_5; +}; + +typedef struct anon_struct.conflict483 anon_struct.conflict483, *Panon_struct.conflict483; + +struct anon_struct.conflict483 { + u8_t attempts; +}; + +typedef enum bt_mesh_adv_type { + BT_MESH_ADV_BEACON=2, + BT_MESH_ADV_DATA=1, + BT_MESH_ADV_PROV=0, + BT_MESH_ADV_URI=3 +} bt_mesh_adv_type; + +typedef struct bt_mesh_adv.conflict8 bt_mesh_adv.conflict8, *Pbt_mesh_adv.conflict8; + +struct bt_mesh_adv.conflict8 { + struct bt_mesh_send_cb * cb; + void * cb_data; + u8_t type:2; + u8_t busy:1; + u8_t xmit; + union anon_union_for_field_5 field_5; +}; + +typedef struct bt_mesh_adv.conflict9 bt_mesh_adv.conflict9, *Pbt_mesh_adv.conflict9; + +struct bt_mesh_adv.conflict9 { + struct bt_mesh_send_cb * cb; + void * cb_data; + u8_t type:2; + u8_t busy:1; + u8_t xmit; + union anon_union_for_field_5 field_5; +}; + +typedef struct bt_mesh_adv.conflict2 bt_mesh_adv.conflict2, *Pbt_mesh_adv.conflict2; + +struct bt_mesh_adv.conflict2 { + struct bt_mesh_send_cb * cb; + void * cb_data; + u8_t type:2; + u8_t busy:1; + u8_t xmit; + union anon_union_for_field_5 field_5; +}; + +typedef struct bt_mesh_adv.conflict6 bt_mesh_adv.conflict6, *Pbt_mesh_adv.conflict6; + +struct bt_mesh_adv.conflict6 { + struct bt_mesh_send_cb * cb; + void * cb_data; + u8_t type:2; + u8_t busy:1; + u8_t xmit; + union anon_union_for_field_5 field_5; +}; + +typedef struct bt_mesh_adv.conflict4 bt_mesh_adv.conflict4, *Pbt_mesh_adv.conflict4; + +struct bt_mesh_adv.conflict4 { + struct bt_mesh_send_cb * cb; + void * cb_data; + u8_t type:2; + u8_t busy:1; + u8_t xmit; + union anon_union_for_field_5 field_5; +}; + +typedef struct bt_mesh_adv.conflict5 bt_mesh_adv.conflict5, *Pbt_mesh_adv.conflict5; + +struct bt_mesh_adv.conflict5 { + struct bt_mesh_send_cb * cb; + void * cb_data; + u8_t type:2; + u8_t busy:1; + u8_t xmit; + union anon_union_for_field_5 field_5; +}; + +typedef enum ranks { + rank_char=-2, + rank_int=0, + rank_long=1, + rank_longlong=2, + rank_short=-1 +} ranks; + +typedef enum flag { + FL_HASH=32, + FL_MINUS=2, + FL_PLUS=4, + FL_SIGNED=64, + FL_SPACE=16, + FL_TICK=8, + FL_UPPER=-128, + FL_ZERO=1 +} flag; + + +// WARNING! conflicting data type names: /DWARF/debug.c/vsnprintf/anon_enum_8 - /DWARF/vsscanf.c/vsscanf/anon_enum_8 + +typedef struct scanu_env_tag scanu_env_tag, *Pscanu_env_tag; + +struct scanu_env_tag { + struct scanu_start_req * param; + struct hal_dma_desc_tag dma_desc; + uint16_t result_cnt; + undefined field_0x16; + undefined field_0x17; + struct mac_scan_result scan_result[6]; + ke_task_id_t src_id; + _Bool joining; + uint8_t band; + struct mac_addr bssid; + struct mac_ssid ssid; +}; + +typedef struct scanu_add_ie_tag scanu_add_ie_tag, *Pscanu_add_ie_tag; + +struct scanu_add_ie_tag { + struct dma_desc dma_desc; + uint32_t buf[50]; +}; + +typedef struct tmrTimerQueueMessage tmrTimerQueueMessage, *PtmrTimerQueueMessage; + +typedef struct tmrTimerQueueMessage DaemonTaskMessage_t; + + +// WARNING! conflicting data type names: /DWARF/timers.c/tmrTimerQueueMessage/anon_union_for_u - /DWARF/gatt.c/gatt_find_info_rsp/anon_union_for_u + +struct tmrTimerQueueMessage { + BaseType_t xMessageID; + union anon_union_for_u u; +}; + +typedef struct tmrTimerParameters tmrTimerParameters, *PtmrTimerParameters; + +typedef struct tmrTimerControl xTIMER; + +typedef xTIMER Timer_t; + +struct tmrTimerParameters { + TickType_t xMessageValue; + Timer_t * pxTimer; +}; + +typedef struct tmrCallbackParameters tmrCallbackParameters, *PtmrCallbackParameters; + +struct tmrCallbackParameters { + void (* pxCallbackFunction)(void *, uint32_t); + void * pvParameter1; + uint32_t ulParameter2; +}; + +typedef struct tmrCallbackParameters CallbackParameters_t; + +typedef struct tmrTimerParameters TimerParameter_t; + +typedef struct txdesc_host.conflict5 txdesc_host.conflict5, *Ptxdesc_host.conflict5; + +typedef struct hostdesc.conflict6 hostdesc.conflict6, *Phostdesc.conflict6; + +struct hostdesc.conflict6 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict13 eth_dest_addr; + struct mac_addr.conflict14 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict5 { + u32_l ready; + struct hostdesc.conflict6 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict31 ipc_shared_env_tag.conflict31, *Pipc_shared_env_tag.conflict31; + +typedef struct txdesc_host.conflict61 txdesc_host.conflict61, *Ptxdesc_host.conflict61; + +typedef struct hostdesc.conflict76 hostdesc.conflict76, *Phostdesc.conflict76; + +struct hostdesc.conflict76 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict168 eth_dest_addr; + struct mac_addr.conflict169 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict61 { + u32_l ready; + struct hostdesc.conflict76 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag.conflict31 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict61 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict59 txdesc_host.conflict59, *Ptxdesc_host.conflict59; + +typedef struct hostdesc.conflict74 hostdesc.conflict74, *Phostdesc.conflict74; + +struct hostdesc.conflict74 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict164 eth_dest_addr; + struct mac_addr.conflict165 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict59 { + u32_l ready; + struct hostdesc.conflict74 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict8 ipc_shared_env_tag.conflict8, *Pipc_shared_env_tag.conflict8; + +struct ipc_shared_env_tag.conflict8 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict8 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict6 txdesc_host.conflict6, *Ptxdesc_host.conflict6; + +typedef struct hostdesc.conflict7 hostdesc.conflict7, *Phostdesc.conflict7; + +struct hostdesc.conflict7 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict15 eth_dest_addr; + struct mac_addr.conflict16 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict6 { + u32_l ready; + struct hostdesc.conflict7 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict9 txdesc_host.conflict9, *Ptxdesc_host.conflict9; + +typedef struct hostdesc.conflict11 hostdesc.conflict11, *Phostdesc.conflict11; + +struct hostdesc.conflict11 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict24 eth_dest_addr; + struct mac_addr.conflict25 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict9 { + u32_l ready; + struct hostdesc.conflict11 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict7 txdesc_host.conflict7, *Ptxdesc_host.conflict7; + +typedef struct hostdesc.conflict8 hostdesc.conflict8, *Phostdesc.conflict8; + +struct hostdesc.conflict8 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict17 eth_dest_addr; + struct mac_addr.conflict18 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict7 { + u32_l ready; + struct hostdesc.conflict8 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict4 txdesc_host.conflict4, *Ptxdesc_host.conflict4; + +typedef struct hostdesc.conflict5 hostdesc.conflict5, *Phostdesc.conflict5; + +struct hostdesc.conflict5 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict11 eth_dest_addr; + struct mac_addr.conflict12 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict4 { + u32_l ready; + struct hostdesc.conflict5 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict2 txdesc_host.conflict2, *Ptxdesc_host.conflict2; + +typedef struct hostdesc.conflict3 hostdesc.conflict3, *Phostdesc.conflict3; + +struct hostdesc.conflict3 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict7 eth_dest_addr; + struct mac_addr.conflict8 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict2 { + u32_l ready; + struct hostdesc.conflict3 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict14 txdesc_host.conflict14, *Ptxdesc_host.conflict14; + +typedef struct hostdesc.conflict16 hostdesc.conflict16, *Phostdesc.conflict16; + +struct hostdesc.conflict16 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict34 eth_dest_addr; + struct mac_addr.conflict35 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict14 { + u32_l ready; + struct hostdesc.conflict16 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict3 txdesc_host.conflict3, *Ptxdesc_host.conflict3; + +typedef struct hostdesc.conflict4 hostdesc.conflict4, *Phostdesc.conflict4; + +struct hostdesc.conflict4 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict9 eth_dest_addr; + struct mac_addr.conflict10 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict3 { + u32_l ready; + struct hostdesc.conflict4 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict1 txdesc_host.conflict1, *Ptxdesc_host.conflict1; + +typedef struct hostdesc.conflict2 hostdesc.conflict2, *Phostdesc.conflict2; + +struct hostdesc.conflict2 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict5 eth_dest_addr; + struct mac_addr.conflict6 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict1 { + u32_l ready; + struct hostdesc.conflict2 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict7 ipc_shared_env_tag.conflict7, *Pipc_shared_env_tag.conflict7; + +struct ipc_shared_env_tag.conflict7 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict8 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict9 ipc_shared_env_tag.conflict9, *Pipc_shared_env_tag.conflict9; + +typedef struct txdesc_host.conflict17 txdesc_host.conflict17, *Ptxdesc_host.conflict17; + +typedef struct hostdesc.conflict20 hostdesc.conflict20, *Phostdesc.conflict20; + +struct hostdesc.conflict20 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict45 eth_dest_addr; + struct mac_addr.conflict46 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict17 { + u32_l ready; + struct hostdesc.conflict20 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag.conflict9 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict17 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict1 ipc_shared_env_tag.conflict1, *Pipc_shared_env_tag.conflict1; + +struct ipc_shared_env_tag.conflict1 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict5 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict2 ipc_shared_env_tag.conflict2, *Pipc_shared_env_tag.conflict2; + +struct ipc_shared_env_tag.conflict2 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict6 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict25 txdesc_host.conflict25, *Ptxdesc_host.conflict25; + +typedef struct hostdesc.conflict29 hostdesc.conflict29, *Phostdesc.conflict29; + +struct hostdesc.conflict29 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict67 eth_dest_addr; + struct mac_addr.conflict68 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict25 { + u32_l ready; + struct hostdesc.conflict29 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict3 ipc_shared_env_tag.conflict3, *Pipc_shared_env_tag.conflict3; + +struct ipc_shared_env_tag.conflict3 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict7 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict4 ipc_shared_env_tag.conflict4, *Pipc_shared_env_tag.conflict4; + +typedef struct txdesc_host.conflict10 txdesc_host.conflict10, *Ptxdesc_host.conflict10; + +typedef struct hostdesc.conflict12 hostdesc.conflict12, *Phostdesc.conflict12; + +struct hostdesc.conflict12 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict26 eth_dest_addr; + struct mac_addr.conflict27 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict10 { + u32_l ready; + struct hostdesc.conflict12 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag.conflict4 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict10 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict5 ipc_shared_env_tag.conflict5, *Pipc_shared_env_tag.conflict5; + +typedef struct txdesc_host.conflict13 txdesc_host.conflict13, *Ptxdesc_host.conflict13; + +typedef struct hostdesc.conflict15 hostdesc.conflict15, *Phostdesc.conflict15; + +struct hostdesc.conflict15 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict32 eth_dest_addr; + struct mac_addr.conflict33 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict13 { + u32_l ready; + struct hostdesc.conflict15 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag.conflict5 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict13 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict6 ipc_shared_env_tag.conflict6, *Pipc_shared_env_tag.conflict6; + +struct ipc_shared_env_tag.conflict6 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict14 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict38 txdesc_host.conflict38, *Ptxdesc_host.conflict38; + +typedef struct hostdesc.conflict48 hostdesc.conflict48, *Phostdesc.conflict48; + +struct hostdesc.conflict48 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict109 eth_dest_addr; + struct mac_addr.conflict110 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict38 { + u32_l ready; + struct hostdesc.conflict48 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict72 hostdesc.conflict72, *Phostdesc.conflict72; + +struct hostdesc.conflict72 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict160 eth_dest_addr; + struct mac_addr.conflict161 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict73 hostdesc.conflict73, *Phostdesc.conflict73; + +struct hostdesc.conflict73 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict162 eth_dest_addr; + struct mac_addr.conflict163 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict70 hostdesc.conflict70, *Phostdesc.conflict70; + +struct hostdesc.conflict70 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict156 eth_dest_addr; + struct mac_addr.conflict157 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict71 hostdesc.conflict71, *Phostdesc.conflict71; + +struct hostdesc.conflict71 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict158 eth_dest_addr; + struct mac_addr.conflict159 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct ipc_shared_env_tag.conflict21 ipc_shared_env_tag.conflict21, *Pipc_shared_env_tag.conflict21; + +typedef struct txdesc_host.conflict41 txdesc_host.conflict41, *Ptxdesc_host.conflict41; + +typedef struct hostdesc.conflict51 hostdesc.conflict51, *Phostdesc.conflict51; + +struct hostdesc.conflict51 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict115 eth_dest_addr; + struct mac_addr.conflict116 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict41 { + u32_l ready; + struct hostdesc.conflict51 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag.conflict21 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict41 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict50 txdesc_host.conflict50, *Ptxdesc_host.conflict50; + +typedef struct hostdesc.conflict64 hostdesc.conflict64, *Phostdesc.conflict64; + +struct hostdesc.conflict64 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict143 eth_dest_addr; + struct mac_addr.conflict144 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict50 { + u32_l ready; + struct hostdesc.conflict64 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict27 txdesc_host.conflict27, *Ptxdesc_host.conflict27; + +typedef struct hostdesc.conflict31 hostdesc.conflict31, *Phostdesc.conflict31; + +struct hostdesc.conflict31 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict71 eth_dest_addr; + struct mac_addr.conflict72 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict27 { + u32_l ready; + struct hostdesc.conflict31 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict10 ipc_shared_env_tag.conflict10, *Pipc_shared_env_tag.conflict10; + +typedef struct txdesc_host.conflict20 txdesc_host.conflict20, *Ptxdesc_host.conflict20; + +typedef struct hostdesc.conflict23 hostdesc.conflict23, *Phostdesc.conflict23; + +struct hostdesc.conflict23 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict51 eth_dest_addr; + struct mac_addr.conflict52 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict20 { + u32_l ready; + struct hostdesc.conflict23 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag.conflict10 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict20 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict ipc_shared_env_tag.conflict, *Pipc_shared_env_tag.conflict; + +struct ipc_shared_env_tag.conflict { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict2 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict26 txdesc_host.conflict26, *Ptxdesc_host.conflict26; + +typedef struct hostdesc.conflict30 hostdesc.conflict30, *Phostdesc.conflict30; + +struct hostdesc.conflict30 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict69 eth_dest_addr; + struct mac_addr.conflict70 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict26 { + u32_l ready; + struct hostdesc.conflict30 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict9 hostdesc.conflict9, *Phostdesc.conflict9; + +struct hostdesc.conflict9 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict20 eth_dest_addr; + struct mac_addr.conflict21 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict1 hostdesc.conflict1, *Phostdesc.conflict1; + +struct hostdesc.conflict1 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict3 eth_dest_addr; + struct mac_addr.conflict4 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict38 hostdesc.conflict38, *Phostdesc.conflict38; + +struct hostdesc.conflict38 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict88 eth_dest_addr; + struct mac_addr.conflict89 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict40 txdesc_host.conflict40, *Ptxdesc_host.conflict40; + +typedef struct hostdesc.conflict50 hostdesc.conflict50, *Phostdesc.conflict50; + +struct hostdesc.conflict50 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict113 eth_dest_addr; + struct mac_addr.conflict114 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict40 { + u32_l ready; + struct hostdesc.conflict50 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict39 hostdesc.conflict39, *Phostdesc.conflict39; + +struct hostdesc.conflict39 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict90 eth_dest_addr; + struct mac_addr.conflict91 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict36 hostdesc.conflict36, *Phostdesc.conflict36; + +struct hostdesc.conflict36 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict84 eth_dest_addr; + struct mac_addr.conflict85 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict42 txdesc_host.conflict42, *Ptxdesc_host.conflict42; + +typedef struct hostdesc.conflict52 hostdesc.conflict52, *Phostdesc.conflict52; + +struct hostdesc.conflict52 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict117 eth_dest_addr; + struct mac_addr.conflict118 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict42 { + u32_l ready; + struct hostdesc.conflict52 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict37 hostdesc.conflict37, *Phostdesc.conflict37; + +struct hostdesc.conflict37 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict86 eth_dest_addr; + struct mac_addr.conflict87 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict43 txdesc_host.conflict43, *Ptxdesc_host.conflict43; + +typedef struct hostdesc.conflict56 hostdesc.conflict56, *Phostdesc.conflict56; + +struct hostdesc.conflict56 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict126 eth_dest_addr; + struct mac_addr.conflict127 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict43 { + u32_l ready; + struct hostdesc.conflict56 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict34 hostdesc.conflict34, *Phostdesc.conflict34; + +struct hostdesc.conflict34 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict80 eth_dest_addr; + struct mac_addr.conflict81 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict44 txdesc_host.conflict44, *Ptxdesc_host.conflict44; + +typedef struct hostdesc.conflict57 hostdesc.conflict57, *Phostdesc.conflict57; + +struct hostdesc.conflict57 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict128 eth_dest_addr; + struct mac_addr.conflict129 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict44 { + u32_l ready; + struct hostdesc.conflict57 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict35 hostdesc.conflict35, *Phostdesc.conflict35; + +struct hostdesc.conflict35 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict82 eth_dest_addr; + struct mac_addr.conflict83 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict45 txdesc_host.conflict45, *Ptxdesc_host.conflict45; + +typedef struct hostdesc.conflict58 hostdesc.conflict58, *Phostdesc.conflict58; + +struct hostdesc.conflict58 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict130 eth_dest_addr; + struct mac_addr.conflict131 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict45 { + u32_l ready; + struct hostdesc.conflict58 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict32 hostdesc.conflict32, *Phostdesc.conflict32; + +struct hostdesc.conflict32 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict73 eth_dest_addr; + struct mac_addr.conflict74 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict33 hostdesc.conflict33, *Phostdesc.conflict33; + +struct hostdesc.conflict33 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict78 eth_dest_addr; + struct mac_addr.conflict79 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict46 txdesc_host.conflict46, *Ptxdesc_host.conflict46; + +typedef struct hostdesc.conflict59 hostdesc.conflict59, *Phostdesc.conflict59; + +struct hostdesc.conflict59 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict132 eth_dest_addr; + struct mac_addr.conflict133 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict46 { + u32_l ready; + struct hostdesc.conflict59 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict47 txdesc_host.conflict47, *Ptxdesc_host.conflict47; + +typedef struct hostdesc.conflict60 hostdesc.conflict60, *Phostdesc.conflict60; + +struct hostdesc.conflict60 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict134 eth_dest_addr; + struct mac_addr.conflict135 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict47 { + u32_l ready; + struct hostdesc.conflict60 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict28 txdesc_host.conflict28, *Ptxdesc_host.conflict28; + +struct txdesc_host.conflict28 { + u32_l ready; + struct hostdesc.conflict32 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict48 txdesc_host.conflict48, *Ptxdesc_host.conflict48; + +typedef struct hostdesc.conflict62 hostdesc.conflict62, *Phostdesc.conflict62; + +struct hostdesc.conflict62 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict139 eth_dest_addr; + struct mac_addr.conflict140 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict48 { + u32_l ready; + struct hostdesc.conflict62 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict49 txdesc_host.conflict49, *Ptxdesc_host.conflict49; + +typedef struct hostdesc.conflict63 hostdesc.conflict63, *Phostdesc.conflict63; + +struct hostdesc.conflict63 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict141 eth_dest_addr; + struct mac_addr.conflict142 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict49 { + u32_l ready; + struct hostdesc.conflict63 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict49 hostdesc.conflict49, *Phostdesc.conflict49; + +struct hostdesc.conflict49 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict111 eth_dest_addr; + struct mac_addr.conflict112 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict30 txdesc_host.conflict30, *Ptxdesc_host.conflict30; + +struct txdesc_host.conflict30 { + u32_l ready; + struct hostdesc.conflict36 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict31 txdesc_host.conflict31, *Ptxdesc_host.conflict31; + +struct txdesc_host.conflict31 { + u32_l ready; + struct hostdesc.conflict37 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict47 hostdesc.conflict47, *Phostdesc.conflict47; + +struct hostdesc.conflict47 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict107 eth_dest_addr; + struct mac_addr.conflict108 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict32 txdesc_host.conflict32, *Ptxdesc_host.conflict32; + +struct txdesc_host.conflict32 { + u32_l ready; + struct hostdesc.conflict38 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict33 txdesc_host.conflict33, *Ptxdesc_host.conflict33; + +struct txdesc_host.conflict33 { + u32_l ready; + struct hostdesc.conflict39 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict45 hostdesc.conflict45, *Phostdesc.conflict45; + +struct hostdesc.conflict45 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict103 eth_dest_addr; + struct mac_addr.conflict104 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict34 txdesc_host.conflict34, *Ptxdesc_host.conflict34; + +typedef struct hostdesc.conflict40 hostdesc.conflict40, *Phostdesc.conflict40; + +struct hostdesc.conflict40 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict92 eth_dest_addr; + struct mac_addr.conflict93 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict34 { + u32_l ready; + struct hostdesc.conflict40 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict46 hostdesc.conflict46, *Phostdesc.conflict46; + +struct hostdesc.conflict46 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict105 eth_dest_addr; + struct mac_addr.conflict106 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict41 hostdesc.conflict41, *Phostdesc.conflict41; + +struct hostdesc.conflict41 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict94 eth_dest_addr; + struct mac_addr.conflict95 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict35 txdesc_host.conflict35, *Ptxdesc_host.conflict35; + +struct txdesc_host.conflict35 { + u32_l ready; + struct hostdesc.conflict41 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict36 txdesc_host.conflict36, *Ptxdesc_host.conflict36; + +struct txdesc_host.conflict36 { + u32_l ready; + struct hostdesc.conflict46 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict37 txdesc_host.conflict37, *Ptxdesc_host.conflict37; + +struct txdesc_host.conflict37 { + u32_l ready; + struct hostdesc.conflict47 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict39 txdesc_host.conflict39, *Ptxdesc_host.conflict39; + +struct txdesc_host.conflict39 { + u32_l ready; + struct hostdesc.conflict49 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict19 ipc_shared_env_tag.conflict19, *Pipc_shared_env_tag.conflict19; + +struct ipc_shared_env_tag.conflict19 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict35 txdesc0[4]; +}; + +typedef struct hostdesc.conflict55 hostdesc.conflict55, *Phostdesc.conflict55; + +struct hostdesc.conflict55 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict124 eth_dest_addr; + struct mac_addr.conflict125 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict51 txdesc_host.conflict51, *Ptxdesc_host.conflict51; + +typedef struct hostdesc.conflict65 hostdesc.conflict65, *Phostdesc.conflict65; + +struct hostdesc.conflict65 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict145 eth_dest_addr; + struct mac_addr.conflict146 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict51 { + u32_l ready; + struct hostdesc.conflict65 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict52 txdesc_host.conflict52, *Ptxdesc_host.conflict52; + +typedef struct hostdesc.conflict66 hostdesc.conflict66, *Phostdesc.conflict66; + +struct hostdesc.conflict66 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict147 eth_dest_addr; + struct mac_addr.conflict148 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict52 { + u32_l ready; + struct hostdesc.conflict66 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict53 txdesc_host.conflict53, *Ptxdesc_host.conflict53; + +typedef struct hostdesc.conflict67 hostdesc.conflict67, *Phostdesc.conflict67; + +struct hostdesc.conflict67 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict149 eth_dest_addr; + struct mac_addr.conflict150 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict53 { + u32_l ready; + struct hostdesc.conflict67 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict69 hostdesc.conflict69, *Phostdesc.conflict69; + +struct hostdesc.conflict69 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict154 eth_dest_addr; + struct mac_addr.conflict155 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict54 txdesc_host.conflict54, *Ptxdesc_host.conflict54; + +typedef struct hostdesc.conflict68 hostdesc.conflict68, *Phostdesc.conflict68; + +struct hostdesc.conflict68 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict151 eth_dest_addr; + struct mac_addr.conflict152 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict54 { + u32_l ready; + struct hostdesc.conflict68 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict55 txdesc_host.conflict55, *Ptxdesc_host.conflict55; + +struct txdesc_host.conflict55 { + u32_l ready; + struct hostdesc.conflict70 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict56 txdesc_host.conflict56, *Ptxdesc_host.conflict56; + +struct txdesc_host.conflict56 { + u32_l ready; + struct hostdesc.conflict71 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict61 hostdesc.conflict61, *Phostdesc.conflict61; + +struct hostdesc.conflict61 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict137 eth_dest_addr; + struct mac_addr.conflict138 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict57 txdesc_host.conflict57, *Ptxdesc_host.conflict57; + +struct txdesc_host.conflict57 { + u32_l ready; + struct hostdesc.conflict72 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict58 txdesc_host.conflict58, *Ptxdesc_host.conflict58; + +struct txdesc_host.conflict58 { + u32_l ready; + struct hostdesc.conflict73 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict18 hostdesc.conflict18, *Phostdesc.conflict18; + +struct hostdesc.conflict18 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict41 eth_dest_addr; + struct mac_addr.conflict42 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict19 hostdesc.conflict19, *Phostdesc.conflict19; + +struct hostdesc.conflict19 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict43 eth_dest_addr; + struct mac_addr.conflict44 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict17 hostdesc.conflict17, *Phostdesc.conflict17; + +struct hostdesc.conflict17 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict39 eth_dest_addr; + struct mac_addr.conflict40 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict14 hostdesc.conflict14, *Phostdesc.conflict14; + +struct hostdesc.conflict14 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict30 eth_dest_addr; + struct mac_addr.conflict31 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct ipc_shared_env_tag.conflict22 ipc_shared_env_tag.conflict22, *Pipc_shared_env_tag.conflict22; + +struct ipc_shared_env_tag.conflict22 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict42 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict21 txdesc_host.conflict21, *Ptxdesc_host.conflict21; + +typedef struct hostdesc.conflict24 hostdesc.conflict24, *Phostdesc.conflict24; + +struct hostdesc.conflict24 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict53 eth_dest_addr; + struct mac_addr.conflict54 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict21 { + u32_l ready; + struct hostdesc.conflict24 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict22 txdesc_host.conflict22, *Ptxdesc_host.conflict22; + +typedef struct hostdesc.conflict26 hostdesc.conflict26, *Phostdesc.conflict26; + +struct hostdesc.conflict26 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict61 eth_dest_addr; + struct mac_addr.conflict62 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict22 { + u32_l ready; + struct hostdesc.conflict26 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict20 ipc_shared_env_tag.conflict20, *Pipc_shared_env_tag.conflict20; + +struct ipc_shared_env_tag.conflict20 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict38 txdesc0[4]; +}; + +typedef struct hostdesc.conflict13 hostdesc.conflict13, *Phostdesc.conflict13; + +struct hostdesc.conflict13 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict28 eth_dest_addr; + struct mac_addr.conflict29 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict23 txdesc_host.conflict23, *Ptxdesc_host.conflict23; + +typedef struct hostdesc.conflict27 hostdesc.conflict27, *Phostdesc.conflict27; + +struct hostdesc.conflict27 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict63 eth_dest_addr; + struct mac_addr.conflict64 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict23 { + u32_l ready; + struct hostdesc.conflict27 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict24 txdesc_host.conflict24, *Ptxdesc_host.conflict24; + +typedef struct hostdesc.conflict28 hostdesc.conflict28, *Phostdesc.conflict28; + +struct hostdesc.conflict28 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict65 eth_dest_addr; + struct mac_addr.conflict66 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict24 { + u32_l ready; + struct hostdesc.conflict28 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict26 ipc_shared_env_tag.conflict26, *Pipc_shared_env_tag.conflict26; + +struct ipc_shared_env_tag.conflict26 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict54 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict25 ipc_shared_env_tag.conflict25, *Pipc_shared_env_tag.conflict25; + +struct ipc_shared_env_tag.conflict25 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict53 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict24 ipc_shared_env_tag.conflict24, *Pipc_shared_env_tag.conflict24; + +struct ipc_shared_env_tag.conflict24 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict50 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict23 ipc_shared_env_tag.conflict23, *Pipc_shared_env_tag.conflict23; + +struct ipc_shared_env_tag.conflict23 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict45 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict29 txdesc_host.conflict29, *Ptxdesc_host.conflict29; + +struct txdesc_host.conflict29 { + u32_l ready; + struct hostdesc.conflict35 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict29 ipc_shared_env_tag.conflict29, *Pipc_shared_env_tag.conflict29; + +struct ipc_shared_env_tag.conflict29 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict57 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict28 ipc_shared_env_tag.conflict28, *Pipc_shared_env_tag.conflict28; + +struct ipc_shared_env_tag.conflict28 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict8 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict27 ipc_shared_env_tag.conflict27, *Pipc_shared_env_tag.conflict27; + +struct ipc_shared_env_tag.conflict27 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict8 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict11 ipc_shared_env_tag.conflict11, *Pipc_shared_env_tag.conflict11; + +struct ipc_shared_env_tag.conflict11 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict21 txdesc0[4]; +}; + +typedef struct hostdesc.conflict25 hostdesc.conflict25, *Phostdesc.conflict25; + +struct hostdesc.conflict25 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict59 eth_dest_addr; + struct mac_addr.conflict60 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict11 txdesc_host.conflict11, *Ptxdesc_host.conflict11; + +struct txdesc_host.conflict11 { + u32_l ready; + struct hostdesc.conflict13 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict12 txdesc_host.conflict12, *Ptxdesc_host.conflict12; + +struct txdesc_host.conflict12 { + u32_l ready; + struct hostdesc.conflict14 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict21 hostdesc.conflict21, *Phostdesc.conflict21; + +struct hostdesc.conflict21 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict47 eth_dest_addr; + struct mac_addr.conflict48 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict22 hostdesc.conflict22, *Phostdesc.conflict22; + +struct hostdesc.conflict22 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict49 eth_dest_addr; + struct mac_addr.conflict50 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict18 txdesc_host.conflict18, *Ptxdesc_host.conflict18; + +struct txdesc_host.conflict18 { + u32_l ready; + struct hostdesc.conflict21 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict15 ipc_shared_env_tag.conflict15, *Pipc_shared_env_tag.conflict15; + +struct ipc_shared_env_tag.conflict15 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict27 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict14 ipc_shared_env_tag.conflict14, *Pipc_shared_env_tag.conflict14; + +struct ipc_shared_env_tag.conflict14 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict24 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict15 txdesc_host.conflict15, *Ptxdesc_host.conflict15; + +struct txdesc_host.conflict15 { + u32_l ready; + struct hostdesc.conflict18 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict13 ipc_shared_env_tag.conflict13, *Pipc_shared_env_tag.conflict13; + +struct ipc_shared_env_tag.conflict13 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict8 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict16 txdesc_host.conflict16, *Ptxdesc_host.conflict16; + +struct txdesc_host.conflict16 { + u32_l ready; + struct hostdesc.conflict19 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict12 ipc_shared_env_tag.conflict12, *Pipc_shared_env_tag.conflict12; + +struct ipc_shared_env_tag.conflict12 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict8 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict18 ipc_shared_env_tag.conflict18, *Pipc_shared_env_tag.conflict18; + +struct ipc_shared_env_tag.conflict18 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict34 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict19 txdesc_host.conflict19, *Ptxdesc_host.conflict19; + +struct txdesc_host.conflict19 { + u32_l ready; + struct hostdesc.conflict22 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict17 ipc_shared_env_tag.conflict17, *Pipc_shared_env_tag.conflict17; + +struct ipc_shared_env_tag.conflict17 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict31 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict16 ipc_shared_env_tag.conflict16, *Pipc_shared_env_tag.conflict16; + +struct ipc_shared_env_tag.conflict16 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict28 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict txdesc_host.conflict, *Ptxdesc_host.conflict; + +struct txdesc_host.conflict { + u32_l ready; + struct hostdesc.conflict1 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag ipc_shared_env_tag, *Pipc_shared_env_tag; + +struct ipc_shared_env_tag { + struct ipc_a2e_msg msg_a2e_buf; + uint32_t pattern_addr; + struct txdesc_host txdesc0[4]; +}; + +typedef struct hostdesc.conflict hostdesc.conflict, *Phostdesc.conflict; + +struct hostdesc.conflict { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict1 eth_dest_addr; + struct mac_addr.conflict2 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct lld_sleep_env_tag lld_sleep_env_tag, *Plld_sleep_env_tag; + +struct lld_sleep_env_tag { + uint32_t irq_mask; + int32_t last_sleep_dur; + _Bool sw_wakeup; + _Bool pds_reset; + undefined field_0xa; + undefined field_0xb; + uint32_t basetimecnt; + uint32_t finetimecnt; +}; + +typedef struct tcal_tag tcal_tag, *Ptcal_tag; + +struct tcal_tag { + int16_t prev_temperature; + undefined field_0x2; + undefined field_0x3; + uint32_t last_action_time[4]; + uint32_t last_action_temperature[4]; + int32_t last_action_out[4]; + _Bool enabled; + undefined field_0x35; + undefined field_0x36; + undefined field_0x37; +}; + +typedef enum HCI_MSG { + HCI_ACL_DATA_RX=2054, + HCI_ACL_DATA_TX=2055, + HCI_CMD_CMP_EVENT=2049, + HCI_CMD_STAT_EVENT=2050, + HCI_COMMAND=2053, + HCI_DBG_EVT=2057, + HCI_EVENT=2051, + HCI_LE_EVENT=2052, + HCI_MSG_ID_FIRST=2048, + HCI_MSG_ID_LAST=2058, + HCI_TCI_LMP=2056 +} HCI_MSG; + +typedef union _reg_t _reg_t, *P_reg_t; + +union _reg_t { + uint8_t byte[4]; + uint32_t word; +}; + +typedef struct bt_uuid_32 bt_uuid_32, *Pbt_uuid_32; + +struct bt_uuid_32 { + struct bt_uuid uuid; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + u32_t.conflict val; +}; + +typedef struct bl_hci_cmd_struct bl_hci_cmd_struct, *Pbl_hci_cmd_struct; + +struct bl_hci_cmd_struct { + uint16_t opcode; + undefined field_0x2; + undefined field_0x3; + uint8_t * params; + uint8_t param_len; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct bl_hci_acl_data_tx bl_hci_acl_data_tx, *Pbl_hci_acl_data_tx; + +struct bl_hci_acl_data_tx { + uint16_t conhdl; + uint8_t pb_bc_flag; + undefined field_0x3; + uint16_t len; + undefined field_0x6; + undefined field_0x7; + uint8_t * buffer; +}; + +typedef struct hci_pkt_struct hci_pkt_struct, *Phci_pkt_struct; + +typedef union anon_union_for_p anon_union_for_p, *Panon_union_for_p; + +union anon_union_for_p { + struct bl_hci_cmd_struct hci_cmd; + struct bl_hci_acl_data_tx acl_data; +}; + +struct hci_pkt_struct { + union anon_union_for_p p; +}; + +typedef enum TASK_API_ID { + TASK_ID_AHI=16, + TASK_ID_AM0=-16, + TASK_ID_AM0_HAS=-15, + TASK_ID_ANPC=48, + TASK_ID_ANPS=47, + TASK_ID_APP=15, + TASK_ID_BASC=37, + TASK_ID_BASS=36, + TASK_ID_BCSC=64, + TASK_ID_BCSS=63, + TASK_ID_BLPC=29, + TASK_ID_BLPS=28, + TASK_ID_CPPC=52, + TASK_ID_CPPS=51, + TASK_ID_CSCPC=46, + TASK_ID_CSCPS=45, + TASK_ID_DBG=3, + TASK_ID_DISC=21, + TASK_ID_DISPLAY=9, + TASK_ID_DISS=20, + TASK_ID_ENVC=58, + TASK_ID_ENVS=57, + TASK_ID_FINDL=24, + TASK_ID_FINDT=25, + TASK_ID_GAPC=14, + TASK_ID_GAPM=13, + TASK_ID_GATTC=12, + TASK_ID_GATTM=11, + TASK_ID_GLPC=42, + TASK_ID_GLPS=41, + TASK_ID_HCI=8, + TASK_ID_HOGPBH=39, + TASK_ID_HOGPD=38, + TASK_ID_HOGPRH=40, + TASK_ID_HRPC=31, + TASK_ID_HRPS=30, + TASK_ID_HTPC=26, + TASK_ID_HTPT=27, + TASK_ID_INVALID=-1, + TASK_ID_IPSC=56, + TASK_ID_IPSS=55, + TASK_ID_L2CC=10, + TASK_ID_LANC=54, + TASK_ID_LANS=53, + TASK_ID_LB=6, + TASK_ID_LC=5, + TASK_ID_LD=7, + TASK_ID_LLC=1, + TASK_ID_LLD=2, + TASK_ID_LLM=0, + TASK_ID_LM=4, + TASK_ID_PASPC=50, + TASK_ID_PASPS=49, + TASK_ID_PLXC=68, + TASK_ID_PLXS=67, + TASK_ID_PROXM=22, + TASK_ID_PROXR=23, + TASK_ID_RSCPC=44, + TASK_ID_RSCPS=43, + TASK_ID_SCPPC=35, + TASK_ID_SCPPS=34, + TASK_ID_TIPC=33, + TASK_ID_TIPS=32, + TASK_ID_UDSC=62, + TASK_ID_UDSS=61, + TASK_ID_WPTC=66, + TASK_ID_WPTS=65, + TASK_ID_WSCC=60, + TASK_ID_WSCS=59 +} TASK_API_ID; + +typedef struct sta_info_tag sta_info_tag, *Psta_info_tag; + +typedef enum sta_ps_traffic { + PS_TRAFFIC=3, + PS_TRAFFIC_HOST=1, + PS_TRAFFIC_INT=2, + UAPSD_TRAFFIC=12, + UAPSD_TRAFFIC_HOST=4, + UAPSD_TRAFFIC_INT=8 +} sta_ps_traffic; + +typedef int sta_ps_sp_t; + +typedef struct sta_mgmt_sec_info sta_mgmt_sec_info, *Psta_mgmt_sec_info; + +typedef struct sta_pol_tbl_cntl sta_pol_tbl_cntl, *Psta_pol_tbl_cntl; + +typedef struct sta_mgmt_ba_info sta_mgmt_ba_info, *Psta_mgmt_ba_info; + +typedef struct rc_sta_stats rc_sta_stats, *Prc_sta_stats; + +typedef struct rc_rate_stats rc_rate_stats, *Prc_rate_stats; + +typedef struct step step, *Pstep; + +typedef union anon_union_for_rate_map anon_union_for_rate_map, *Panon_union_for_rate_map; + +struct sta_mgmt_ba_info { + uint32_t last_tx_time; + uint32_t last_ba_add_time; + uint8_t bam_idx_rx; + uint8_t bam_idx_tx; + int8_t credit_oft; + undefined field_0xb; +}; + +struct rc_rate_stats { + uint16_t attempts; + uint16_t success; + uint16_t probability; + uint16_t rate_config; + uint8_t sample_skipped; + _Bool old_prob_available; + uint8_t n_retry; + _Bool rate_allowed; +}; + +struct step { + uint32_t tp; + uint16_t idx; + undefined field_0x6; + undefined field_0x7; +}; + +union anon_union_for_rate_map { + uint8_t ht[4]; +}; + +struct rc_sta_stats { + uint32_t last_rc_time; + struct rc_rate_stats rate_stats[10]; + struct step retry[4]; + struct step max_tp_2_trial; + uint16_t ampdu_len; + uint16_t ampdu_packets; + uint32_t avg_ampdu_len; + uint8_t sample_wait; + uint8_t sample_slow; + uint8_t trial_status; + uint8_t info; + uint8_t sw_retry_step; + uint8_t format_mod; + union anon_union_for_rate_map rate_map; + uint16_t rate_map_l; + uint8_t mcs_max; + uint8_t r_idx_min; + uint8_t r_idx_max; + uint8_t bw_max; + uint8_t no_ss; + uint8_t short_gi; + uint8_t p_type; + undefined field_0xbf; + uint16_t no_samples; + uint16_t max_amsdu_len; + uint16_t curr_amsdu_len; + uint16_t fixed_rate_cfg; +}; + +struct sta_pol_tbl_cntl { + struct txl_buffer_control * buf_ctrl; + struct rc_sta_stats * sta_stats; + uint32_t prot_cfg; + uint16_t ppdu_tx_cfg; + uint8_t upd_field; + undefined field_0xf; +}; + +struct sta_mgmt_sec_info { + struct key_info_tag key_info; + struct key_info_tag * pairwise_key; + struct key_info_tag * * cur_key; +}; + +struct sta_info_tag { + struct co_list_hdr list_hdr; + uint32_t bcn_int; + uint32_t ampdu_size_max_vht; + uint16_t ampdu_size_max_ht; + undefined field_0xe; + undefined field_0xf; + uint32_t paid_gid; + uint8_t ampdu_spacing_min; + undefined field_0x15; + uint16_t drift; + uint16_t aid; + uint8_t inst_nbr; + uint8_t staid; + uint8_t ps_state; + _Bool valid; + struct mac_addr mac_addr; + int8_t rssi; + undefined field_0x25; + undefined field_0x26; + undefined field_0x27; + uint32_t tsflo; + uint32_t tsfhi; + uint8_t data_rate; + uint8_t ctrl_port_state; + enum sta_ps_traffic traffic_avail; + undefined field_0x33; + sta_ps_sp_t ps_service_period; + uint16_t ctrl_port_ethertype; + undefined field_0x3a; + undefined field_0x3b; + undefined field_0x3c; + undefined field_0x3d; + undefined field_0x3e; + undefined field_0x3f; + struct sta_mgmt_sec_info sta_sec_info; + struct mac_sta_info info; + uint16_t seq_nbr[9]; + undefined field_0x10a; + undefined field_0x10b; + struct sta_pol_tbl_cntl pol_tbl; + struct sta_mgmt_ba_info ba_info[9]; + uint16_t rx_nqos_last_seqcntl; + uint16_t rx_qos_last_seqcntl[9]; + struct co_list tx_desc_post; + void * suppData; + uint32_t time_last_seen; + undefined field_0x1ac; + undefined field_0x1ad; + undefined field_0x1ae; + undefined field_0x1af; +}; + +typedef struct sta_info_env_tag sta_info_env_tag, *Psta_info_env_tag; + +struct sta_info_env_tag { + struct co_list free_sta_list; +}; + +typedef enum sta_mgmt_pol_upd { + STA_MGMT_POL_UPD_BW=3, + STA_MGMT_POL_UPD_MAX=5, + STA_MGMT_POL_UPD_PPDU_TX=2, + STA_MGMT_POL_UPD_PROT=1, + STA_MGMT_POL_UPD_RATE=0, + STA_MGMT_POL_UPD_TX_POWER=4 +} sta_mgmt_pol_upd; + +typedef enum sta_ps_sp { + ANY_SERVICE_PERIOD_INT=3, + BCN_SERVICE_PERIOD=8, + NO_SERVICE_PERIOD=0, + PS_SERVICE_PERIOD=1, + UAPSD_SERVICE_PERIOD=6, + UAPSD_SERVICE_PERIOD_HOST=4, + UAPSD_SERVICE_PERIOD_INT=2 +} sta_ps_sp; + +typedef struct BL_ENDECRYPT_t BL_ENDECRYPT_t, *PBL_ENDECRYPT_t; + +struct BL_ENDECRYPT_t { + UINT8 enDeAction; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + UINT8 * pData; +}; + +typedef struct scan_probe_req_ie_tag scan_probe_req_ie_tag, *Pscan_probe_req_ie_tag; + +struct scan_probe_req_ie_tag { + struct dma_desc dma_desc; + struct tx_pbd pbd; + uint32_t buf[50]; +}; + +typedef struct scan_env_tag scan_env_tag, *Pscan_env_tag; + +struct scan_env_tag { + struct hal_dma_desc_tag dma_desc; + struct scan_start_req * param; + uint32_t ds_ie; + ke_task_id_t req_id; + uint8_t chan_idx; + _Bool abort; +}; + +typedef struct _ef_env _ef_env, *P_ef_env; + +typedef struct _ef_env ef_env; + +struct _ef_env { + char * key; + void * value; + size_t value_len; +}; + +typedef enum env_status { + ENV_DELETED=4, + ENV_ERR_HDR=5, + ENV_PRE_DELETE=3, + ENV_PRE_WRITE=1, + ENV_STATUS_NUM=6, + ENV_UNUSED=0, + ENV_WRITE=2 +} env_status; + +typedef enum env_status env_status_t; + +typedef enum EfErrCode { + EF_ENV_ARG_ERR=8, + EF_ENV_FULL=6, + EF_ENV_INIT_FAILED=7, + EF_ENV_NAME_ERR=4, + EF_ENV_NAME_EXIST=5, + EF_ERASE_ERR=1, + EF_NO_ERR=0, + EF_READ_ERR=2, + EF_WRITE_ERR=3 +} EfErrCode; + +typedef struct env_node_obj env_node_obj, *Penv_node_obj; + +typedef struct anon_struct_for_addr anon_struct_for_addr, *Panon_struct_for_addr; + +struct anon_struct_for_addr { + uint32_t start; + uint32_t value; +}; + +struct env_node_obj { + env_status_t status; + _Bool crc_is_ok; + uint8_t name_len; + undefined field_0x3; + uint32_t magic; + uint32_t len; + uint32_t value_len; + char name[64]; + struct anon_struct_for_addr addr; +}; + +typedef struct anon_struct.conflict526 anon_struct.conflict526, *Panon_struct.conflict526; + +struct anon_struct.conflict526 { + uint32_t start; + uint32_t value; +}; + +typedef struct env_node_obj * env_node_obj_t; + +typedef __blkcnt_t blkcnt_t; + +typedef __mode_t mode_t; + +typedef __uint16_t in_port_t; + +typedef __ino_t ino_t; + +typedef __uid_t uid_t; + +typedef __nlink_t nlink_t; + +typedef __gid_t gid_t; + +typedef __uint32_t in_addr_t; + +typedef __dev_t dev_t; + +typedef __blksize_t blksize_t; + +typedef struct txl_list txl_list, *Ptxl_list; + +struct txl_list { + struct tx_hd * last_frame_exch; + struct co_list transmitting; + uint16_t bridgedmacnt; + uint8_t chk_state; + undefined field_0xf; +}; + +typedef struct txl_cntrl_env_tag txl_cntrl_env_tag, *Ptxl_cntrl_env_tag; + +struct txl_cntrl_env_tag { + struct txl_list txlist[5]; + uint32_t pck_cnt; + uint16_t seqnbr; + _Bool reset; + undefined field_0x57; +}; + +typedef struct callback_handler_t callback_handler_t, *Pcallback_handler_t; + +typedef struct at_callback_para_t at_callback_para_t, *Pat_callback_para_t; + +typedef struct at_callback_rsp_t at_callback_rsp_t, *Pat_callback_rsp_t; + + +// WARNING! conflicting data type names: /DWARF/at_command.h/at_callback_para_t/anon_union_for_u - /DWARF/gatt.c/gatt_find_info_rsp/anon_union_for_u + +struct callback_handler_t { + s32 cmd; + AT_ERROR_CODE (* handler)(struct at_callback_para_t *, struct at_callback_rsp_t *); +}; + +struct at_callback_para_t { + struct at_config_t * cfg; + struct at_status_t * sts; + union anon_union_for_u u; +}; + +struct at_callback_rsp_t { + u8 status; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + s32 type; + void * vptr; + s32 vsize; +}; + +typedef enum wlan_mode { + WIFI_AP_STA_MODE=3, + WIFI_DISABLE=0, + WIFI_SOFTAP_MODE=2, + WIFI_STATION_MODE=1 +} wlan_mode; + +typedef union byte_array byte_array, *Pbyte_array; + +union byte_array { + uint8_t bytes[8]; + uintptr_t intx; + uint64_t int64; +}; + +typedef enum BL_IRQ_EXCEPTION_TYPE_T { + BL_IRQ_EXCEPTION_TYPE_ACCESS_ILLEGAL=2, + BL_IRQ_EXCEPTION_TYPE_ILLEGAL_INSTRUCTION=3, + BL_IRQ_EXCEPTION_TYPE_LOAD_MISALIGN=0, + BL_IRQ_EXCEPTION_TYPE_STORE_MISALIGN=1 +} BL_IRQ_EXCEPTION_TYPE_T; + +typedef struct dma_env_tag dma_env_tag, *Pdma_env_tag; + +struct dma_env_tag { + struct dma_desc * last_dma[4]; +}; + +typedef struct hal_dma_env_tag hal_dma_env_tag, *Phal_dma_env_tag; + +struct hal_dma_env_tag { + struct co_list prog[2]; + struct co_list free_gp_dma_descs; + uint16_t lli_cnt[2]; +}; + +typedef struct memp memp, *Pmemp; + +struct memp { + struct memp * next; +}; + +typedef struct memp_desc memp_desc, *Pmemp_desc; + +struct memp_desc { + struct stats_mem * stats; + u16_t size; + u16_t num; + u8_t * base; + struct memp * * tab; +}; + +typedef struct __sbuf __sbuf, *P__sbuf; + +struct __sbuf { + uchar * _base; + int _size; +}; + +typedef struct __sFILE __sFILE, *P__sFILE; + +typedef _LOCK_RECURSIVE_T _flock_t; + +struct __sFILE { + uchar * _p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + void * _cookie; + _ssize_t (* _read)(struct _reent *, void *, char *, int); + _ssize_t (* _write)(struct _reent *, void *, char *, int); + _fpos_t (* _seek)(struct _reent *, void *, _fpos_t, int); + int (* _close)(struct _reent *, void *); + struct __sbuf _ub; + uchar * _up; + int _ur; + uchar _ubuf[3]; + uchar _nbuf[1]; + struct __sbuf _lb; + int _blksize; + _off_t _offset; + struct _reent * _data; + _flock_t _lock; + struct _mbstate_t _mbstate; + int _flags2; +}; + +typedef union anon_union.conflict anon_union.conflict, *Panon_union.conflict; + +union anon_union.conflict { + struct anon_struct _reent; + struct anon_struct.conflict _unused; +}; + +typedef struct _atexit.conflict _atexit.conflict, *P_atexit.conflict; + +struct _atexit.conflict { + struct _atexit * _next; + int _ind; + void (* _fns[32])(void); + struct _on_exit_args _on_exit_args; +}; + +typedef struct _reent.conflict _reent.conflict, *P_reent.conflict; + +struct _reent.conflict { + int _errno; + __FILE * _stdin; + __FILE * _stdout; + __FILE * _stderr; + int _inc; + char _emergency[25]; + undefined field_0x2d; + undefined field_0x2e; + undefined field_0x2f; + int _unspecified_locale_info; + struct __locale_t * _locale; + int __sdidinit; + void (* __cleanup)(struct _reent *); + struct _Bigint * _result; + int _result_k; + struct _Bigint * _p5s; + struct _Bigint * * _freelist; + int _cvtlen; + char * _cvtbuf; + union anon_union_for__new _new; + struct _atexit * _atexit; + struct _atexit.conflict _atexit0; + void (** _sig_func)(int); + struct _glue __sglue; + __FILE __sf[3]; + undefined field_0x424; + undefined field_0x425; + undefined field_0x426; + undefined field_0x427; +}; + +typedef enum hal_uart_flow_control_t { + FLOW_CONTROL_CTS=1, + FLOW_CONTROL_CTS_RTS=3, + FLOW_CONTROL_DISABLED=0, + FLOW_CONTROL_RTS=2 +} hal_uart_flow_control_t; + +typedef enum hal_uart_mode_t { + MODE_RX=1, + MODE_TX=0, + MODE_TX_RX=2 +} hal_uart_mode_t; + +typedef enum hal_uart_stop_bits_t { + STOP_BITS_1=0, + STOP_BITS_2=1 +} hal_uart_stop_bits_t; + +typedef struct uart_dev_t uart_dev_t, *Puart_dev_t; + +typedef struct uart_config_t uart_config_t, *Puart_config_t; + +typedef enum hal_uart_data_width_t { + DATA_WIDTH_5BIT=0, + DATA_WIDTH_6BIT=1, + DATA_WIDTH_7BIT=2, + DATA_WIDTH_8BIT=3, + DATA_WIDTH_9BIT=4 +} hal_uart_data_width_t; + +typedef enum hal_uart_parity_t { + EVEN_PARITY=2, + NO_PARITY=0, + ODD_PARITY=1 +} hal_uart_parity_t; + +struct uart_config_t { + uint32_t baud_rate; + enum hal_uart_data_width_t data_width; + enum hal_uart_parity_t parity; + enum hal_uart_stop_bits_t stop_bits; + enum hal_uart_flow_control_t flow_control; + enum hal_uart_mode_t mode; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +struct uart_dev_t { + uint8_t port; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + struct uart_config_t config; + void * rx_ringbuf_handle; + void * tx_ringbuf_handle; + uint32_t rx_buf_size; + uint32_t tx_buf_size; + void * mutex; + void * poll_cb; + void * fd; + void * poll_data; + void * taskhdl; + uint8_t read_block_flag; + undefined field_0x35; + undefined field_0x36; + undefined field_0x37; + void * priv; +}; + +typedef enum hal_uart_int_t { + UART_RX_INT=1, + UART_TX_INT=0 +} hal_uart_int_t; + +typedef struct etharp_hdr etharp_hdr, *Petharp_hdr; + +typedef struct ip4_addr_wordaligned ip4_addr_wordaligned, *Pip4_addr_wordaligned; + +struct ip4_addr_wordaligned { + u16_t addrw[2]; +}; + +struct etharp_hdr { + u16_t hwtype; + u16_t proto; + u8_t hwlen; + u8_t protolen; + u16_t opcode; + struct eth_addr shwaddr; + struct ip4_addr_wordaligned sipaddr; + struct eth_addr dhwaddr; + struct ip4_addr_wordaligned dipaddr; +}; + +typedef enum etharp_opcode { + ARP_REPLY=2, + ARP_REQUEST=1 +} etharp_opcode; + +typedef struct bt_mesh_state_transition bt_mesh_state_transition, *Pbt_mesh_state_transition; + +struct bt_mesh_state_transition { + u8_t trans_time; + u8_t delay; +}; + +typedef struct bt_mesh_last_rcvd_msg bt_mesh_last_rcvd_msg, *Pbt_mesh_last_rcvd_msg; + +struct bt_mesh_last_rcvd_msg { + u8_t tid; + undefined field_0x1; + u16_t src_addr; + u16_t dst_addr; + undefined field_0x6; + undefined field_0x7; + int64_t rcvd_time; +}; + +typedef struct etharp_entry etharp_entry, *Petharp_entry; + +struct etharp_entry { + struct pbuf * q; + ip4_addr_t ipaddr; + struct netif * netif; + struct eth_addr ethaddr; + u16_t ctime; + u8_t state; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef enum etharp_state { + ETHARP_STATE_EMPTY=0, + ETHARP_STATE_PENDING=1, + ETHARP_STATE_STABLE=2, + ETHARP_STATE_STABLE_REREQUESTING_1=3, + ETHARP_STATE_STABLE_REREQUESTING_2=4 +} etharp_state; + +typedef struct la_mem_format la_mem_format, *Pla_mem_format; + +struct la_mem_format { + uint32_t word[4]; +}; + +typedef struct mbedtls_asn1_bitstring mbedtls_asn1_bitstring, *Pmbedtls_asn1_bitstring; + +typedef struct mbedtls_asn1_bitstring mbedtls_x509_bitstring; + +struct mbedtls_asn1_bitstring { + size_t len; + uchar unused_bits; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uchar * p; +}; + +typedef struct QueueDefinition xQUEUE; + +typedef struct QUEUE_REGISTRY_ITEM QUEUE_REGISTRY_ITEM, *PQUEUE_REGISTRY_ITEM; + +typedef struct QUEUE_REGISTRY_ITEM xQueueRegistryItem; + +typedef xQueueRegistryItem QueueRegistryItem_t; + +struct QUEUE_REGISTRY_ITEM { + char * pcQueueName; + QueueHandle_t xHandle; +}; + +typedef struct QueuePointers QueuePointers, *PQueuePointers; + +typedef struct QueuePointers QueuePointers_t; + +struct QueuePointers { + int8_t * pcTail; + int8_t * pcReadFrom; +}; + +typedef struct SemaphoreData SemaphoreData, *PSemaphoreData; + +typedef struct SemaphoreData SemaphoreData_t; + +struct SemaphoreData { + TaskHandle_t xMutexHolder; + UBaseType_t uxRecursiveCallCount; +}; + +typedef xQUEUE Queue_t; + +typedef struct bt_att_req.conflict16 bt_att_req.conflict16, *Pbt_att_req.conflict16; + +struct bt_att_req.conflict16 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + void (* destroy)(void *); + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_att_req.conflict14 bt_att_req.conflict14, *Pbt_att_req.conflict14; + +struct bt_att_req.conflict14 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_att_req.conflict26 bt_att_req.conflict26, *Pbt_att_req.conflict26; + +struct bt_att_req.conflict26 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_att_req.conflict28 bt_att_req.conflict28, *Pbt_att_req.conflict28; + +struct bt_att_req.conflict28 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_att_req.conflict25 bt_att_req.conflict25, *Pbt_att_req.conflict25; + +struct bt_att_req.conflict25 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_att_req.conflict27 bt_att_req.conflict27, *Pbt_att_req.conflict27; + +struct bt_att_req.conflict27 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_att_req.conflict24 bt_att_req.conflict24, *Pbt_att_req.conflict24; + +struct bt_att_req.conflict24 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_att_req.conflict22 bt_att_req.conflict22, *Pbt_att_req.conflict22; + +struct bt_att_req.conflict22 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + void (* destroy)(void *); + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_att_req bt_att_req, *Pbt_att_req; + +struct bt_att_req { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_att_req.conflict29 bt_att_req.conflict29, *Pbt_att_req.conflict29; + +struct bt_att_req.conflict29 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct write_data write_data, *Pwrite_data; + +struct write_data { + struct bt_conn * conn; + struct net_buf * buf; + u8_t req; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + void * value; + u16_t len; + u16_t offset; + u8_t err; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_att bt_att, *Pbt_att; + +typedef struct bt_l2cap_le_chan.conflict3 bt_l2cap_le_chan.conflict3, *Pbt_l2cap_le_chan.conflict3; + +typedef struct bt_l2cap_chan.conflict4 bt_l2cap_chan.conflict4, *Pbt_l2cap_chan.conflict4; + +struct bt_l2cap_chan.conflict4 { + struct bt_conn * conn; + struct bt_l2cap_chan_ops * ops; + sys_snode_t node; + void (* destroy)(struct bt_l2cap_chan *); + struct k_delayed_work.conflict rtx_work; + atomic_t status[1]; + bt_l2cap_chan_state_t state; + undefined field_0x39; + u16_t psm; + u8_t ident; + enum bt_security_t required_sec_level; + undefined field_0x3e; + undefined field_0x3f; +}; + +struct bt_l2cap_le_chan.conflict3 { + struct bt_l2cap_chan.conflict4 chan; + struct bt_l2cap_le_endpoint rx; + struct bt_l2cap_le_endpoint tx; + struct k_fifo tx_queue; + struct net_buf * tx_buf; + struct net_buf * _sdu; + u16_t _sdu_len; + undefined field_0x7e; + undefined field_0x7f; + struct k_work rx_work; + struct k_fifo rx_queue; +}; + +struct bt_att { + struct bt_l2cap_le_chan.conflict3 chan; + atomic_t flags[1]; + struct bt_att_req.conflict28 * req; + sys_slist_t reqs; + struct k_delayed_work.conflict timeout_work; + struct k_sem tx_sem; + struct k_fifo tx_queue; +}; + +typedef struct find_type_data find_type_data, *Pfind_type_data; + +typedef struct bt_att_handle_group bt_att_handle_group, *Pbt_att_handle_group; + +struct bt_att_handle_group { + u16_t start_handle; + u16_t end_handle; +}; + +struct find_type_data { + struct bt_att * att; + struct net_buf * buf; + struct bt_att_handle_group * group; + void * value; + u8_t value_len; + u8_t err; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct read_type_data read_type_data, *Pread_type_data; + +typedef struct bt_att_read_type_rsp bt_att_read_type_rsp, *Pbt_att_read_type_rsp; + +typedef struct bt_att_data bt_att_data, *Pbt_att_data; + +struct bt_att_read_type_rsp { + u8_t len; + struct bt_att_data[0] data; +}; + +struct bt_att_data { + u16_t handle; + u8_t[0] value; +}; + +struct read_type_data { + struct bt_att * att; + struct bt_uuid * uuid; + struct net_buf * buf; + struct bt_att_read_type_rsp * rsp; + struct bt_att_data * item; + u8_t err; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct att_handler.conflict2 att_handler.conflict2, *Patt_handler.conflict2; + +typedef enum att_type_t { + ATT_COMMAND=0, + ATT_CONFIRMATION=4, + ATT_INDICATION=5, + ATT_NOTIFICATION=3, + ATT_REQUEST=1, + ATT_RESPONSE=2, + ATT_UNKNOWN=6 +} att_type_t; + +struct att_handler.conflict2 { + u8_t op; + u8_t expect_len; + enum att_type_t type; + undefined field_0x3; + u8_t (* func)(struct bt_att *, struct net_buf *); +}; + +typedef struct att_handler.conflict3 att_handler.conflict3, *Patt_handler.conflict3; + +struct att_handler.conflict3 { + u8_t op; + u8_t expect_len; + enum att_type_t type; + undefined field_0x3; + u8_t (* func)(struct bt_att *, struct net_buf *); +}; + +typedef struct att_handler.conflict1 att_handler.conflict1, *Patt_handler.conflict1; + +struct att_handler.conflict1 { + u8_t op; + u8_t expect_len; + enum att_type_t type; + undefined field_0x3; + u8_t (* func)(struct bt_att *, struct net_buf *); +}; + +typedef struct read_data read_data, *Pread_data; + +typedef struct bt_att_read_rsp bt_att_read_rsp, *Pbt_att_read_rsp; + +struct bt_att_read_rsp { // Missing member value : u8_t[1] at offset 0x0 [Unsupported interior flex array: u8_t[1]] +}; + +struct read_data { + struct bt_att * att; + u16_t offset; + undefined field_0x6; + undefined field_0x7; + struct net_buf * buf; + struct bt_att_read_rsp * rsp; + u8_t err; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct find_info_data find_info_data, *Pfind_info_data; + +typedef struct bt_att_find_info_rsp bt_att_find_info_rsp, *Pbt_att_find_info_rsp; + + +// WARNING! conflicting data type names: /DWARF/att.c/find_info_data/anon_union_for_field_3 - /DWARF/gatt.h/bt_gatt_discover_params/anon_union_for_field_3 + +struct find_info_data { + struct bt_att * att; + struct net_buf * buf; + struct bt_att_find_info_rsp * rsp; + union anon_union_for_field_3 field_3; +}; + +struct bt_att_find_info_rsp { + u8_t format; + u8_t[0] info; +}; + +typedef struct read_group_data read_group_data, *Pread_group_data; + +typedef struct bt_att_read_group_rsp bt_att_read_group_rsp, *Pbt_att_read_group_rsp; + +typedef struct bt_att_group_data bt_att_group_data, *Pbt_att_group_data; + +struct bt_att_read_group_rsp { + u8_t len; + struct bt_att_group_data[0] data; +}; + +struct bt_att_group_data { + u16_t start_handle; + u16_t end_handle; + u8_t[0] value; +}; + +struct read_group_data { + struct bt_att * att; + struct bt_uuid * uuid; + struct net_buf * buf; + struct bt_att_read_group_rsp * rsp; + struct bt_att_group_data * group; +}; + +typedef struct write_data.conflict write_data.conflict, *Pwrite_data.conflict; + +struct write_data.conflict { + struct bt_conn * conn; + struct net_buf * buf; + u8_t req; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + void * value; + u16_t len; + u16_t offset; + u8_t err; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct att_handler att_handler, *Patt_handler; + +struct att_handler { + u8_t op; + u8_t expect_len; + enum att_type_t type; + undefined field_0x3; + u8_t (* func)(struct bt_att *, struct net_buf *); +}; + +typedef struct att_handler.conflict att_handler.conflict, *Patt_handler.conflict; + +struct att_handler.conflict { + u8_t op; + u8_t expect_len; + enum att_type_t type; + undefined field_0x3; + u8_t (* func)(struct bt_att *, struct net_buf *); +}; + +typedef struct anon_struct.conflict536 anon_struct.conflict536, *Panon_struct.conflict536; + +struct anon_struct.conflict536 { + char * name; + u8_t index; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct netifapi_msg netifapi_msg, *Pnetifapi_msg; + + +// WARNING! conflicting data type names: /DWARF/api_msg.h/netifapi_msg/anon_union_for_msg - /DWARF/api_msg.h/api_msg/anon_union_for_msg + +struct netifapi_msg { + struct tcpip_api_call_data call; + struct netif * netif; + union anon_union_for_msg msg; +}; + +typedef struct anon_struct.conflict548 anon_struct.conflict548, *Panon_struct.conflict548; + +struct anon_struct.conflict548 { + u8_t proto; +}; + +typedef struct anon_struct.conflict549 anon_struct.conflict549, *Panon_struct.conflict549; + +struct anon_struct.conflict549 { + ip_addr_t * ipaddr; + u16_t port; + u8_t if_idx; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict554 anon_struct.conflict554, *Panon_struct.conflict554; + +struct anon_struct.conflict554 { + u8_t proto; +}; + +typedef struct anon_struct.conflict555 anon_struct.conflict555, *Panon_struct.conflict555; + +struct anon_struct.conflict555 { + ip_addr_t * ipaddr; + u16_t port; + u8_t if_idx; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict556 anon_struct.conflict556, *Panon_struct.conflict556; + +struct anon_struct.conflict556 { + ip_addr_t * ipaddr; + u16_t * port; + u8_t local; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct anon_struct.conflict557 anon_struct.conflict557, *Panon_struct.conflict557; + +struct anon_struct.conflict557 { + struct netvector * vector; + u16_t vector_cnt; + undefined field_0x6; + undefined field_0x7; + size_t vector_off; + size_t len; + size_t offset; + u8_t apiflags; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + u32_t time_started; +}; + +typedef struct anon_struct.conflict550 anon_struct.conflict550, *Panon_struct.conflict550; + +struct anon_struct.conflict550 { + ip_addr_t * ipaddr; + u16_t * port; + u8_t local; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct anon_struct.conflict551 anon_struct.conflict551, *Panon_struct.conflict551; + +struct anon_struct.conflict551 { + struct netvector * vector; + u16_t vector_cnt; + undefined field_0x6; + undefined field_0x7; + size_t vector_off; + size_t len; + size_t offset; + u8_t apiflags; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + u32_t time_started; +}; + +typedef struct anon_struct.conflict552 anon_struct.conflict552, *Panon_struct.conflict552; + +struct anon_struct.conflict552 { + u8_t shut; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + u32_t time_started; +}; + +typedef struct anon_struct.conflict553 anon_struct.conflict553, *Panon_struct.conflict553; + +struct anon_struct.conflict553 { + ip_addr_t * multiaddr; + ip_addr_t * netif_addr; + u8_t if_idx; + enum netconn_igmp join_or_leave; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct anon_struct.conflict558 anon_struct.conflict558, *Panon_struct.conflict558; + +struct anon_struct.conflict558 { + u8_t shut; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + u32_t time_started; +}; + +typedef struct anon_struct.conflict559 anon_struct.conflict559, *Panon_struct.conflict559; + +struct anon_struct.conflict559 { + ip_addr_t * multiaddr; + ip_addr_t * netif_addr; + u8_t if_idx; + enum netconn_igmp join_or_leave; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct dns_api_msg dns_api_msg, *Pdns_api_msg; + +struct dns_api_msg { + char * name; + ip_addr_t * addr; + sys_sem_t * sem; + err_t * err; +}; + +typedef void (* netifapi_void_fn)(struct netif *); + +typedef err_t (* netifapi_errt_fn)(struct netif *); + +typedef struct anon_struct.conflict533 anon_struct.conflict533, *Panon_struct.conflict533; + +typedef err_t (* netif_init_fn)(struct netif *); + +struct anon_struct.conflict533 { + ip4_addr_t * ipaddr; + ip4_addr_t * netmask; + ip4_addr_t * gw; + void * state; + netif_init_fn init; + err_t (* input)(struct pbuf *, struct netif *); +}; + +typedef struct anon_struct.conflict534 anon_struct.conflict534, *Panon_struct.conflict534; + +struct anon_struct.conflict534 { + netifapi_void_fn voidfunc; + netifapi_errt_fn errtfunc; +}; + +typedef struct anon_struct.conflict535 anon_struct.conflict535, *Panon_struct.conflict535; + +struct anon_struct.conflict535 { + char * name; + u8_t index; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef enum rxu_msg_tag { + RXU_MGT_IND=11264, + RXU_NULL_DATA=11265 +} rxu_msg_tag; + +typedef struct rxu_mgt_ind rxu_mgt_ind, *Prxu_mgt_ind; + +struct rxu_mgt_ind { + uint16_t length; + uint16_t framectrl; + uint16_t center_freq; + uint8_t band; + uint8_t sta_idx; + uint8_t inst_nbr; + uint8_t sa[6]; + undefined field_0xf; + uint32_t tsflo; + uint32_t tsfhi; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t data_rate; + uint32_t[0] payload; +}; + +typedef struct ota_header ota_header, *Pota_header; + + +// WARNING! conflicting data type names: /DWARF/bl_sys_ota_cli.c/ota_header/anon_union_for_u - /DWARF/gatt.c/gatt_find_info_rsp/anon_union_for_u + +struct ota_header { + union anon_union_for_u u; +}; + +typedef struct ota_header ota_header_t; + +typedef struct anon_struct.conflict522 anon_struct.conflict522, *Panon_struct.conflict522; + +struct anon_struct.conflict522 { + uint8_t header[16]; + uint8_t type[4]; + uint32_t len; + uint8_t pad0[8]; + uint8_t ver_hardware[16]; + uint8_t ver_software[16]; + uint8_t sha256[32]; +}; + +typedef struct anon_struct.conflict523 anon_struct.conflict523, *Panon_struct.conflict523; + +struct anon_struct.conflict523 { + uint8_t header[16]; + uint8_t type[4]; + uint32_t len; + uint8_t pad0[8]; + uint8_t ver_hardware[16]; + uint8_t ver_software[16]; + uint8_t sha256[32]; +}; + +typedef enum bt_mesh_friend_pdu_type { + BT_MESH_FRIEND_PDU_COMPLETE=2, + BT_MESH_FRIEND_PDU_PARTIAL=1, + BT_MESH_FRIEND_PDU_SINGLE=0 +} bt_mesh_friend_pdu_type; + +typedef struct llc_env_tag llc_env_tag, *Pllc_env_tag; + +typedef struct llc_ch_asses_tag llc_ch_asses_tag, *Pllc_ch_asses_tag; + +typedef struct rem_version rem_version, *Prem_version; + +typedef struct data_len_ext_tag data_len_ext_tag, *Pdata_len_ext_tag; + +typedef struct encrypt.conflict encrypt.conflict, *Pencrypt.conflict; + +struct rem_version { + uint8_t vers; + undefined field_0x1; + uint16_t compid; + uint16_t subvers; +}; + +struct encrypt.conflict { + struct sess_k_div skd; + struct ltk ltk; + uint8_t randn[16]; +}; + +struct data_len_ext_tag { + uint16_t conn_max_tx_octets; + uint16_t conn_max_rx_octets; + uint16_t conn_eff_max_tx_octets; + uint16_t conn_eff_max_rx_octets; + uint16_t conn_max_tx_time; + uint16_t conn_max_rx_time; + uint16_t conn_eff_max_tx_time; + uint16_t conn_eff_max_rx_time; + _Bool send_req_not_allowed; + uint8_t data_len_ext_flag; +}; + +struct llc_ch_asses_tag { + int8_t rcvd_quality[37]; + _Bool latency_en; + uint8_t reassess_count; + uint8_t reassess_cursor; +}; + +struct llc_env_tag { + void * operation[4]; + struct ea_elt_tag * elt; + struct llc_ch_asses_tag chnl_assess; + struct rem_version peer_version; + struct data_len_ext_tag data_len_ext_info; + uint16_t sup_to; + uint16_t n_sup_to; + uint16_t auth_payl_to; + uint16_t auth_payl_to_margin; + uint16_t llc_status; + struct le_chnl_map ch_map; + struct le_chnl_map n_ch_map; + int8_t rssi; + struct le_features feats_used; + struct encrypt.conflict encrypt; + uint8_t disc_reason; + _Bool disc_event_sent; + uint8_t loc_proc_state; + uint8_t rem_proc_state; + uint8_t encryption_state; + _Bool peer_sup_conn_param_req; + undefined field_0xa7; +}; + +typedef struct llc_snap llc_snap, *Pllc_snap; + +struct llc_snap { + uint16_t dsap_ssap; + uint16_t control_oui0; + uint16_t oui1_2; + uint16_t proto_id; +}; + +typedef enum llc_status_flag { + LLC_STAT_DISC_REM_REQ_LSB=9, + LLC_STAT_DISC_REM_REQ_MASK=512, + LLC_STAT_FEAT_EXCH_LSB=0, + LLC_STAT_FEAT_EXCH_MASK=1, + LLC_STAT_INSTANT_PROCEED_LSB=11, + LLC_STAT_INSTANT_PROCEED_MASK=2048, + LLC_STAT_LLCP_DISCARD_LSB=3, + LLC_STAT_LLCP_DISCARD_MASK=8, + LLC_STAT_LLCP_INSTANT_EXTRACTED_LSB=10, + LLC_STAT_LLCP_INSTANT_EXTRACTED_MASK=1024, + LLC_STAT_PEER_VERS_KNOWN_LSB=1, + LLC_STAT_PEER_VERS_KNOWN_MASK=2, + LLC_STAT_SYNC_FOUND_LSB=8, + LLC_STAT_SYNC_FOUND_MASK=256, + LLC_STAT_TO_PENDING_LSB=4, + LLC_STAT_TO_PENDING_MASK=16, + LLC_STAT_UPDATE_EVT_SENT_LSB=7, + LLC_STAT_UPDATE_EVT_SENT_MASK=-128, + LLC_STAT_UPDATE_HOST_REQ_LSB=6, + LLC_STAT_UPDATE_HOST_REQ_MASK=64, + LLC_STAT_UPDATE_PENDING_LSB=5, + LLC_STAT_UPDATE_PENDING_MASK=32, + LLC_STAT_WAIT_TRAFFIC_PAUSED_LSB=2, + LLC_STAT_WAIT_TRAFFIC_PAUSED_MASK=4 +} llc_status_flag; + +typedef struct llc_snap_short llc_snap_short, *Pllc_snap_short; + +struct llc_snap_short { + uint16_t dsap_ssap; + uint16_t control_oui0; + uint16_t oui1_2; +}; + +typedef enum llc_dle_flag { + LLC_DLE_EVT_SENT_LSB=1, + LLC_DLE_EVT_SENT_MASK=2, + LLC_DLE_REQ_RCVD_LSB=0, + LLC_DLE_REQ_RCVD_MASK=1 +} llc_dle_flag; + +typedef void * aos_loop_t; + +typedef struct yloop_sock_t yloop_sock_t, *Pyloop_sock_t; + +struct yloop_sock_t { + int sock; + void * private_data; + void (* cb)(int, void *); +}; + +typedef struct yloop_ctx_t yloop_ctx_t, *Pyloop_ctx_t; + +struct yloop_ctx_t { + dlist_t timeouts; + struct pollfd * pollfds; + struct yloop_sock_t * readers; + int eventfd; + uint16_t max_sock; + uint8_t reader_count; + _Bool pending_terminate; + _Bool terminate; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; +}; + +typedef struct A_BLOCK_LINK A_BLOCK_LINK, *PA_BLOCK_LINK; + +struct A_BLOCK_LINK { + struct A_BLOCK_LINK * pxNextFreeBlock; + size_t xBlockSize; +}; + +typedef struct A_BLOCK_LINK BlockLink_t; + +typedef struct friend_adv.conflict1 friend_adv.conflict1, *Pfriend_adv.conflict1; + +struct friend_adv.conflict1 { + struct bt_mesh_adv.conflict10 adv; + undefined field_0xc; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u64_t seq_auth; +}; + +typedef struct friend_pdu_info.conflict friend_pdu_info.conflict, *Pfriend_pdu_info.conflict; + +struct friend_pdu_info.conflict { + u16_t src; + u16_t dst; + u8_t seq[3]; + u8_t ttl:7; + u8_t ctl:1; + u32_t.conflict iv_index; +}; + +typedef struct friend_pdu_info friend_pdu_info, *Pfriend_pdu_info; + +struct friend_pdu_info { + u16_t src; + u16_t dst; + u8_t seq[3]; + u8_t ttl:7; + u8_t ctl:1; + u32_t.conflict iv_index; +}; + +typedef struct friend_adv.conflict friend_adv.conflict, *Pfriend_adv.conflict; + +struct friend_adv.conflict { + struct bt_mesh_adv.conflict9 adv; + undefined field_0xc; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u64_t seq_auth; +}; + +typedef struct friend_adv friend_adv, *Pfriend_adv; + +struct friend_adv { + struct bt_mesh_adv.conflict8 adv; + undefined field_0xc; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + u64_t seq_auth; +}; + +typedef struct yloop_timeout_s yloop_timeout_s, *Pyloop_timeout_s; + +typedef struct yloop_timeout_s yloop_timeout_t; + +struct yloop_timeout_s { + dlist_t next; + longlong timeout_ms; + void * private_data; + void (* cb)(void *); + int ms; + undefined field_0x1c; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +typedef struct llcp_pdu_tag llcp_pdu_tag, *Pllcp_pdu_tag; + +struct llcp_pdu_tag { + struct co_list_hdr hdr; + uint16_t idx; + undefined field_0x6; + undefined field_0x7; + void * ptr; + uint8_t opcode; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; +}; + +typedef enum llc_llcp_authorize { + LLC_LLCP_NO_AUTHZED=0, + LLC_LLCP_PAUSE_ENC_AUTHZED=2, + LLC_LLCP_START_ENC_AUTHZED=1 +} llc_llcp_authorize; + +typedef enum bam_state_tag { + BAM_ACTIVE=1, + BAM_CHECK_ADMISSION=3, + BAM_IDLE=0, + BAM_RESET=4, + BAM_STATE_MAX=5, + BAM_WAIT_RSP=2 +} bam_state_tag; + +typedef struct bt_mesh_rpl bt_mesh_rpl, *Pbt_mesh_rpl; + +struct bt_mesh_rpl { + u16_t src; + _Bool old_iv; + undefined field_0x3; + u32_t.conflict seq; +}; + +typedef struct anon_struct.conflict419 anon_struct.conflict419, *Panon_struct.conflict419; + +struct anon_struct.conflict419 { + u8_t nid; + u8_t enc[16]; + u8_t privacy[16]; +}; + +typedef struct bt_mesh_friend.conflict29 bt_mesh_friend.conflict29, *Pbt_mesh_friend.conflict29; + +typedef struct bt_mesh_friend_seg bt_mesh_friend_seg, *Pbt_mesh_friend_seg; + +typedef struct anon_struct_for_clear anon_struct_for_clear, *Panon_struct_for_clear; + +struct anon_struct_for_clear { + u32_t.conflict start; + u16_t frnd; + u16_t repeat_sec; + struct k_delayed_work timer; +}; + +struct bt_mesh_friend_seg { + sys_slist_t queue; + u8_t seg_count; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +struct bt_mesh_friend.conflict29 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict27 bt_mesh_friend.conflict27, *Pbt_mesh_friend.conflict27; + +struct bt_mesh_friend.conflict27 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict28 bt_mesh_friend.conflict28, *Pbt_mesh_friend.conflict28; + +struct bt_mesh_friend.conflict28 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict25 bt_mesh_friend.conflict25, *Pbt_mesh_friend.conflict25; + +struct bt_mesh_friend.conflict25 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict26 bt_mesh_friend.conflict26, *Pbt_mesh_friend.conflict26; + +struct bt_mesh_friend.conflict26 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict34 bt_mesh_friend.conflict34, *Pbt_mesh_friend.conflict34; + +struct bt_mesh_friend.conflict34 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_app_key bt_mesh_app_key, *Pbt_mesh_app_key; + +typedef struct bt_mesh_app_keys bt_mesh_app_keys, *Pbt_mesh_app_keys; + +struct bt_mesh_app_keys { + u8_t id; + u8_t val[16]; +}; + +struct bt_mesh_app_key { + u16_t net_idx; + u16_t app_idx; + _Bool updated; + struct bt_mesh_app_keys keys[2]; + undefined field_0x27; +}; + +typedef struct bt_mesh_friend.conflict35 bt_mesh_friend.conflict35, *Pbt_mesh_friend.conflict35; + +struct bt_mesh_friend.conflict35 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict32 bt_mesh_friend.conflict32, *Pbt_mesh_friend.conflict32; + +struct bt_mesh_friend.conflict32 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict33 bt_mesh_friend.conflict33, *Pbt_mesh_friend.conflict33; + +struct bt_mesh_friend.conflict33 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict30 bt_mesh_friend.conflict30, *Pbt_mesh_friend.conflict30; + +struct bt_mesh_friend.conflict30 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict31 bt_mesh_friend.conflict31, *Pbt_mesh_friend.conflict31; + +struct bt_mesh_friend.conflict31 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict37 bt_mesh_friend.conflict37, *Pbt_mesh_friend.conflict37; + +struct bt_mesh_friend.conflict37 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict3 bt_mesh_friend.conflict3, *Pbt_mesh_friend.conflict3; + +struct bt_mesh_friend.conflict3 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_net_rx.conflict bt_mesh_net_rx.conflict, *Pbt_mesh_net_rx.conflict; + +typedef struct bt_mesh_subnet bt_mesh_subnet, *Pbt_mesh_subnet; + +typedef struct bt_mesh_subnet_keys bt_mesh_subnet_keys, *Pbt_mesh_subnet_keys; + +struct bt_mesh_subnet_keys { + u8_t net[16]; + u8_t nid; + u8_t enc[16]; + u8_t net_id[8]; + u8_t identity[16]; + u8_t privacy[16]; + u8_t beacon[16]; +}; + +struct bt_mesh_subnet { + u32_t.conflict beacon_sent; + u8_t beacons_last; + u8_t beacons_cur; + u8_t beacon_cache[21]; + undefined field_0x1b; + u16_t net_idx; + _Bool kr_flag; + u8_t kr_phase; + u8_t node_id; + undefined field_0x21; + undefined field_0x22; + undefined field_0x23; + u32_t.conflict node_id_start; + u8_t auth[8]; + struct bt_mesh_subnet_keys keys[2]; + undefined field_0xe2; + undefined field_0xe3; +}; + +struct bt_mesh_net_rx.conflict { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx ctx; + u32_t.conflict seq; + u8_t old_iv:1; + u8_t new_key:1; + u8_t friend_cred:1; + u8_t ctl:1; + u8_t net_if:2; + u8_t local_match:1; + u8_t friend_match:1; + undefined field_0x21; + u16_t msg_cache_idx; +}; + +typedef struct bt_mesh_friend.conflict4 bt_mesh_friend.conflict4, *Pbt_mesh_friend.conflict4; + +struct bt_mesh_friend.conflict4 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict1 bt_mesh_friend.conflict1, *Pbt_mesh_friend.conflict1; + +struct bt_mesh_friend.conflict1 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict2 bt_mesh_friend.conflict2, *Pbt_mesh_friend.conflict2; + +struct bt_mesh_friend.conflict2 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict9 bt_mesh_friend.conflict9, *Pbt_mesh_friend.conflict9; + +struct bt_mesh_friend.conflict9 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict18 bt_mesh_friend.conflict18, *Pbt_mesh_friend.conflict18; + +struct bt_mesh_friend.conflict18 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict19 bt_mesh_friend.conflict19, *Pbt_mesh_friend.conflict19; + +struct bt_mesh_friend.conflict19 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict7 bt_mesh_friend.conflict7, *Pbt_mesh_friend.conflict7; + +struct bt_mesh_friend.conflict7 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict16 bt_mesh_friend.conflict16, *Pbt_mesh_friend.conflict16; + +struct bt_mesh_friend.conflict16 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict8 bt_mesh_friend.conflict8, *Pbt_mesh_friend.conflict8; + +struct bt_mesh_friend.conflict8 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict17 bt_mesh_friend.conflict17, *Pbt_mesh_friend.conflict17; + +struct bt_mesh_friend.conflict17 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict5 bt_mesh_friend.conflict5, *Pbt_mesh_friend.conflict5; + +struct bt_mesh_friend.conflict5 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict14 bt_mesh_friend.conflict14, *Pbt_mesh_friend.conflict14; + +struct bt_mesh_friend.conflict14 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict6 bt_mesh_friend.conflict6, *Pbt_mesh_friend.conflict6; + +struct bt_mesh_friend.conflict6 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict15 bt_mesh_friend.conflict15, *Pbt_mesh_friend.conflict15; + +struct bt_mesh_friend.conflict15 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict23 bt_mesh_friend.conflict23, *Pbt_mesh_friend.conflict23; + +struct bt_mesh_friend.conflict23 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict24 bt_mesh_friend.conflict24, *Pbt_mesh_friend.conflict24; + +struct bt_mesh_friend.conflict24 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict21 bt_mesh_friend.conflict21, *Pbt_mesh_friend.conflict21; + +struct bt_mesh_friend.conflict21 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict22 bt_mesh_friend.conflict22, *Pbt_mesh_friend.conflict22; + +struct bt_mesh_friend.conflict22 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict20 bt_mesh_friend.conflict20, *Pbt_mesh_friend.conflict20; + +struct bt_mesh_friend.conflict20 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict bt_mesh_friend.conflict, *Pbt_mesh_friend.conflict; + +struct bt_mesh_friend.conflict { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict38 bt_mesh_friend.conflict38, *Pbt_mesh_friend.conflict38; + +struct bt_mesh_friend.conflict38 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict39 bt_mesh_friend.conflict39, *Pbt_mesh_friend.conflict39; + +struct bt_mesh_friend.conflict39 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict36 bt_mesh_friend.conflict36, *Pbt_mesh_friend.conflict36; + +struct bt_mesh_friend.conflict36 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict45 bt_mesh_friend.conflict45, *Pbt_mesh_friend.conflict45; + +struct bt_mesh_friend.conflict45 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict43 bt_mesh_friend.conflict43, *Pbt_mesh_friend.conflict43; + +struct bt_mesh_friend.conflict43 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict44 bt_mesh_friend.conflict44, *Pbt_mesh_friend.conflict44; + +struct bt_mesh_friend.conflict44 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict41 bt_mesh_friend.conflict41, *Pbt_mesh_friend.conflict41; + +struct bt_mesh_friend.conflict41 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict42 bt_mesh_friend.conflict42, *Pbt_mesh_friend.conflict42; + +struct bt_mesh_friend.conflict42 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict40 bt_mesh_friend.conflict40, *Pbt_mesh_friend.conflict40; + +struct bt_mesh_friend.conflict40 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_lpn.conflict bt_mesh_lpn.conflict, *Pbt_mesh_lpn.conflict; + +struct bt_mesh_lpn.conflict { + enum anon_enum_8_for_state.conflict state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct anon_struct.conflict418 anon_struct.conflict418, *Panon_struct.conflict418; + +struct anon_struct.conflict418 { + u8_t nid; + u8_t enc[16]; + u8_t privacy[16]; +}; + +typedef struct bt_mesh_net_rx.conflict10 bt_mesh_net_rx.conflict10, *Pbt_mesh_net_rx.conflict10; + +struct bt_mesh_net_rx.conflict10 { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx ctx; + u32_t.conflict seq; + u8_t old_iv:1; + u8_t new_key:1; + u8_t friend_cred:1; + u8_t ctl:1; + u8_t net_if:2; + u8_t local_match:1; + u8_t friend_match:1; + undefined field_0x21; + u16_t msg_cache_idx; +}; + +typedef struct bt_mesh_friend.conflict13 bt_mesh_friend.conflict13, *Pbt_mesh_friend.conflict13; + +struct bt_mesh_friend.conflict13 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict12 bt_mesh_friend.conflict12, *Pbt_mesh_friend.conflict12; + +struct bt_mesh_friend.conflict12 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict10 bt_mesh_friend.conflict10, *Pbt_mesh_friend.conflict10; + +struct bt_mesh_friend.conflict10 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_friend.conflict11 bt_mesh_friend.conflict11, *Pbt_mesh_friend.conflict11; + +struct bt_mesh_friend.conflict11 { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct friend_cred friend_cred, *Pfriend_cred; + +struct friend_cred { + u16_t net_idx; + u16_t addr; + u16_t lpn_counter; + u16_t frnd_counter; + struct anon_struct.conflict418 cred[2]; +}; + +typedef struct bt_mesh_net_tx.conflict bt_mesh_net_tx.conflict, *Pbt_mesh_net_tx.conflict; + +struct bt_mesh_net_tx.conflict { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx * ctx; + u16_t src; + u8_t xmit; + u8_t friend_cred:1; + u8_t aszmic:1; + u8_t aid:6; +}; + +typedef struct bt_mesh_net_rx.conflict2 bt_mesh_net_rx.conflict2, *Pbt_mesh_net_rx.conflict2; + +struct bt_mesh_net_rx.conflict2 { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx ctx; + u32_t.conflict seq; + u8_t old_iv:1; + u8_t new_key:1; + u8_t friend_cred:1; + u8_t ctl:1; + u8_t net_if:2; + u8_t local_match:1; + u8_t friend_match:1; + undefined field_0x21; + u16_t msg_cache_idx; +}; + +typedef struct bt_mesh_net.conflict5 bt_mesh_net.conflict5, *Pbt_mesh_net.conflict5; + +typedef struct bt_mesh_lpn.conflict13 bt_mesh_lpn.conflict13, *Pbt_mesh_lpn.conflict13; + +struct bt_mesh_lpn.conflict13 { + enum anon_enum_8_for_state.conflict3 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +struct bt_mesh_net.conflict5 { + u32_t.conflict iv_index; + u32_t.conflict seq; + atomic_t flags[1]; + struct k_work local_work; + sys_slist_t local_queue; + struct bt_mesh_friend.conflict18 frnd[2]; + struct bt_mesh_lpn.conflict13 lpn; + u8_t ivu_duration; + undefined field_0x17d; + undefined field_0x17e; + undefined field_0x17f; + struct k_delayed_work ivu_timer; + u8_t dev_key[16]; + struct bt_mesh_app_key app_keys[2]; + struct bt_mesh_subnet sub[2]; + struct bt_mesh_rpl rpl[5]; +}; + +typedef struct bt_mesh_net.conflict4 bt_mesh_net.conflict4, *Pbt_mesh_net.conflict4; + +typedef struct bt_mesh_lpn.conflict11 bt_mesh_lpn.conflict11, *Pbt_mesh_lpn.conflict11; + +struct bt_mesh_lpn.conflict11 { + enum anon_enum_8_for_state.conflict3 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +struct bt_mesh_net.conflict4 { + u32_t.conflict iv_index; + u32_t.conflict seq; + atomic_t flags[1]; + struct k_work local_work; + sys_slist_t local_queue; + struct bt_mesh_friend.conflict15 frnd[2]; + struct bt_mesh_lpn.conflict11 lpn; + u8_t ivu_duration; + undefined field_0x17d; + undefined field_0x17e; + undefined field_0x17f; + struct k_delayed_work ivu_timer; + u8_t dev_key[16]; + struct bt_mesh_app_key app_keys[2]; + struct bt_mesh_subnet sub[2]; + struct bt_mesh_rpl rpl[5]; +}; + +typedef struct bt_mesh_net.conflict7 bt_mesh_net.conflict7, *Pbt_mesh_net.conflict7; + +typedef struct bt_mesh_lpn.conflict17 bt_mesh_lpn.conflict17, *Pbt_mesh_lpn.conflict17; + +struct bt_mesh_lpn.conflict17 { + enum anon_enum_8_for_state.conflict3 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +struct bt_mesh_net.conflict7 { + u32_t.conflict iv_index; + u32_t.conflict seq; + atomic_t flags[1]; + struct k_work local_work; + sys_slist_t local_queue; + struct bt_mesh_friend.conflict25 frnd[2]; + struct bt_mesh_lpn.conflict17 lpn; + u8_t ivu_duration; + undefined field_0x17d; + undefined field_0x17e; + undefined field_0x17f; + struct k_delayed_work ivu_timer; + u8_t dev_key[16]; + struct bt_mesh_app_key app_keys[2]; + struct bt_mesh_subnet sub[2]; + struct bt_mesh_rpl rpl[5]; +}; + +typedef struct bt_mesh_net.conflict6 bt_mesh_net.conflict6, *Pbt_mesh_net.conflict6; + +typedef struct bt_mesh_lpn.conflict15 bt_mesh_lpn.conflict15, *Pbt_mesh_lpn.conflict15; + +struct bt_mesh_lpn.conflict15 { + enum anon_enum_8_for_state.conflict3 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +struct bt_mesh_net.conflict6 { + u32_t.conflict iv_index; + u32_t.conflict seq; + atomic_t flags[1]; + struct k_work local_work; + sys_slist_t local_queue; + struct bt_mesh_friend.conflict22 frnd[2]; + struct bt_mesh_lpn.conflict15 lpn; + u8_t ivu_duration; + undefined field_0x17d; + undefined field_0x17e; + undefined field_0x17f; + struct k_delayed_work ivu_timer; + u8_t dev_key[16]; + struct bt_mesh_app_key app_keys[2]; + struct bt_mesh_subnet sub[2]; + struct bt_mesh_rpl rpl[5]; +}; + +typedef struct bt_mesh_net.conflict1 bt_mesh_net.conflict1, *Pbt_mesh_net.conflict1; + +typedef struct bt_mesh_lpn.conflict5 bt_mesh_lpn.conflict5, *Pbt_mesh_lpn.conflict5; + +struct bt_mesh_lpn.conflict5 { + enum anon_enum_8_for_state.conflict2 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +struct bt_mesh_net.conflict1 { + u32_t.conflict iv_index; + u32_t.conflict seq; + atomic_t flags[1]; + struct k_work local_work; + sys_slist_t local_queue; + struct bt_mesh_friend.conflict6 frnd[2]; + struct bt_mesh_lpn.conflict5 lpn; + u8_t ivu_duration; + undefined field_0x17d; + undefined field_0x17e; + undefined field_0x17f; + struct k_delayed_work ivu_timer; + u8_t dev_key[16]; + struct bt_mesh_app_key app_keys[2]; + struct bt_mesh_subnet sub[2]; + struct bt_mesh_rpl rpl[5]; +}; + +typedef struct bt_mesh_net.conflict3 bt_mesh_net.conflict3, *Pbt_mesh_net.conflict3; + +typedef struct bt_mesh_lpn.conflict9 bt_mesh_lpn.conflict9, *Pbt_mesh_lpn.conflict9; + +struct bt_mesh_lpn.conflict9 { + enum anon_enum_8_for_state.conflict3 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +struct bt_mesh_net.conflict3 { + u32_t.conflict iv_index; + u32_t.conflict seq; + atomic_t flags[1]; + struct k_work local_work; + sys_slist_t local_queue; + struct bt_mesh_friend.conflict12 frnd[2]; + struct bt_mesh_lpn.conflict9 lpn; + u8_t ivu_duration; + undefined field_0x17d; + undefined field_0x17e; + undefined field_0x17f; + struct k_delayed_work ivu_timer; + u8_t dev_key[16]; + struct bt_mesh_app_key app_keys[2]; + struct bt_mesh_subnet sub[2]; + struct bt_mesh_rpl rpl[5]; +}; + +typedef struct bt_mesh_net.conflict2 bt_mesh_net.conflict2, *Pbt_mesh_net.conflict2; + +typedef struct bt_mesh_lpn.conflict7 bt_mesh_lpn.conflict7, *Pbt_mesh_lpn.conflict7; + +struct bt_mesh_lpn.conflict7 { + enum anon_enum_8_for_state.conflict3 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +struct bt_mesh_net.conflict2 { + u32_t.conflict iv_index; + u32_t.conflict seq; + atomic_t flags[1]; + struct k_work local_work; + sys_slist_t local_queue; + struct bt_mesh_friend.conflict9 frnd[2]; + struct bt_mesh_lpn.conflict7 lpn; + u8_t ivu_duration; + undefined field_0x17d; + undefined field_0x17e; + undefined field_0x17f; + struct k_delayed_work ivu_timer; + u8_t dev_key[16]; + struct bt_mesh_app_key app_keys[2]; + struct bt_mesh_subnet sub[2]; + struct bt_mesh_rpl rpl[5]; +}; + +typedef struct bt_mesh_net.conflict9 bt_mesh_net.conflict9, *Pbt_mesh_net.conflict9; + +typedef struct bt_mesh_lpn.conflict21 bt_mesh_lpn.conflict21, *Pbt_mesh_lpn.conflict21; + +struct bt_mesh_lpn.conflict21 { + enum anon_enum_8_for_state.conflict4 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +struct bt_mesh_net.conflict9 { + u32_t.conflict iv_index; + u32_t.conflict seq; + atomic_t flags[1]; + struct k_work local_work; + sys_slist_t local_queue; + struct bt_mesh_friend.conflict31 frnd[2]; + struct bt_mesh_lpn.conflict21 lpn; + u8_t ivu_duration; + undefined field_0x17d; + undefined field_0x17e; + undefined field_0x17f; + struct k_delayed_work ivu_timer; + u8_t dev_key[16]; + struct bt_mesh_app_key app_keys[2]; + struct bt_mesh_subnet sub[2]; + struct bt_mesh_rpl rpl[5]; +}; + +typedef struct bt_mesh_net.conflict8 bt_mesh_net.conflict8, *Pbt_mesh_net.conflict8; + +typedef struct bt_mesh_lpn.conflict19 bt_mesh_lpn.conflict19, *Pbt_mesh_lpn.conflict19; + +struct bt_mesh_lpn.conflict19 { + enum anon_enum_8_for_state.conflict4 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +struct bt_mesh_net.conflict8 { + u32_t.conflict iv_index; + u32_t.conflict seq; + atomic_t flags[1]; + struct k_work local_work; + sys_slist_t local_queue; + struct bt_mesh_friend.conflict28 frnd[2]; + struct bt_mesh_lpn.conflict19 lpn; + u8_t ivu_duration; + undefined field_0x17d; + undefined field_0x17e; + undefined field_0x17f; + struct k_delayed_work ivu_timer; + u8_t dev_key[16]; + struct bt_mesh_app_key app_keys[2]; + struct bt_mesh_subnet sub[2]; + struct bt_mesh_rpl rpl[5]; +}; + +typedef struct bt_mesh_lpn bt_mesh_lpn, *Pbt_mesh_lpn; + +typedef enum anon_enum_8_for_state { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_MAX_TYPES=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + ANY_BSS_MODE=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + AP_ENC_OPEN=0, + AP_ENC_WPA2=1, + AP_ENC_WPA2_WPA=2, + ATHD_CHK_STATE=1, + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6, + BA_AGMT_ALREADY_EXISTS=1, + BA_AGMT_DELETED=2, + BA_AGMT_DOESNT_EXIST=3, + BA_AGMT_ESTABLISHED=0, + BA_AGMT_NOT_SUPPORTED=5, + BA_AGMT_NO_MORE_BA_AGMT=4, + BA_AGMT_RX=1, + BA_AGMT_TX=0, + BA_DEV_NONE=2, + BA_ORIGINATOR=1, + BA_RESPONDER=0, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BROADCAST_STA_IDX_MAX=11, + BROADCAST_STA_IDX_MIN=10, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_MESH_LPN_CLEAR=1, + BT_MESH_LPN_DISABLED=0, + BT_MESH_LPN_ENABLED=3, + BT_MESH_LPN_ESTABLISHED=6, + BT_MESH_LPN_RECV_DELAY=7, + BT_MESH_LPN_REQ_WAIT=4, + BT_MESH_LPN_TIMER=2, + BT_MESH_LPN_WAIT_OFFER=5, + BT_MESH_LPN_WAIT_UPDATE=8, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONNECTION_TYPE_ADHOC=1, + CONNECTION_TYPE_AP=2, + CONNECTION_TYPE_BTAMP=4, + CONNECTION_TYPE_INFRA=0, + CONNECTION_TYPE_MAX=7, + CONNECTION_TYPE_PSEUDO=5, + CONNECTION_TYPE_TDLS=6, + CONNECTION_TYPE_WFD=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + C_DIGIT=4, + C_DOT=2, + C_FLAG=5, + C_MAX=8, + C_OTHER=0, + C_PERCENT=1, + C_SIZE=6, + C_TYPE=7, + C_ZERO=3, + DBG_PROF_MAX=0, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + DMA_DL=0, + DMA_MAX=2, + DMA_UL=1, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + E_RF_BRANCH_I=0, + E_RF_BRANCH_Q=1, + E_RF_CHANNEL_2404M=0, + E_RF_CHANNEL_2408M=1, + E_RF_CHANNEL_2412M=2, + E_RF_CHANNEL_2416M=3, + E_RF_CHANNEL_2420M=4, + E_RF_CHANNEL_2424M=5, + E_RF_CHANNEL_2428M=6, + E_RF_CHANNEL_2432M=7, + E_RF_CHANNEL_2436M=8, + E_RF_CHANNEL_2440M=9, + E_RF_CHANNEL_2444M=10, + E_RF_CHANNEL_2448M=11, + E_RF_CHANNEL_2452M=12, + E_RF_CHANNEL_2456M=13, + E_RF_CHANNEL_2460M=14, + E_RF_CHANNEL_2464M=15, + E_RF_CHANNEL_2468M=16, + E_RF_CHANNEL_2472M=17, + E_RF_CHANNEL_2476M=18, + E_RF_CHANNEL_2480M=19, + E_RF_CHANNEL_2484M=20, + E_RF_CHANNEL_NUM=21, + E_RF_GAIN=2, + E_RF_MODE_11B=0, + E_RF_MODE_11G=1, + E_RF_MODE_11N=2, + E_RF_MODE_IDLE=0, + E_RF_MODE_LO_ACAL=6, + E_RF_MODE_LO_FCAL=7, + E_RF_MODE_RCCAL=4, + E_RF_MODE_ROSCAL=3, + E_RF_MODE_RX=2, + E_RF_MODE_TX=1, + E_RF_MODE_TXCAL=5, + E_RF_PHASE=3, + E_RF_RXCAL_GAIN_CNT=4, + E_RF_TXCAL_GAIN_CNT=8, + E_RF_TXPWR_TBL_CNT=16, + E_RF_XTAL_24M=0, + E_RF_XTAL_26M=1, + E_RF_XTAL_32M=2, + E_RF_XTAL_38M4=3, + E_RF_XTAL_40M=4, + E_RF_XTAL_52M=5, + FAIL=1, + FLAG_LEAD_ZERO=64, + FLAG_LEFT=32, + FLAG_LONG=2, + FLAG_NEGATIVE=-128, + FLAG_SHORT=1, + FLAG_SIGN=8, + FLAG_SIGNED=4, + FLAG_SIGN_SPACE=16, + FW_SUCCESS=0, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HAL_AC0_TIMER=0, + HAL_AC1_TIMER=1, + HAL_AC2_TIMER=2, + HAL_AC3_TIMER=3, + HAL_BCN_TIMER=4, + HAL_IDLE_TIMER=5, + HAL_KE_TIMER=8, + HAL_MM_TIMER=7, + HAL_RX_TIMER=6, + HAL_TIMER_MAX=9, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + HW_ACTIVE=3, + HW_DOZE=2, + HW_IDLE=0, + HW_RATE_11MBPS=3, + HW_RATE_12MBPS=6, + HW_RATE_18MBPS=7, + HW_RATE_1MBPS=0, + HW_RATE_24MBPS=8, + HW_RATE_2MBPS=1, + HW_RATE_36MBPS=9, + HW_RATE_48MBPS=10, + HW_RATE_54MBPS=11, + HW_RATE_5_5MBPS=2, + HW_RATE_6MBPS=4, + HW_RATE_9MBPS=5, + HW_RESERVED=1, + I2C_IRQn=48, + INDEPENDENT_BSS_MODE=2, + INFO_PAR_OGF=4, + INFRASTRUCTURE_MODE=1, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + INVALID_STA_IDX=-1, + IPC_DMA_CHANNEL_CTRL_RX=0, + IPC_DMA_CHANNEL_CTRL_TX=2, + IPC_DMA_CHANNEL_DATA_RX=1, + IPC_DMA_CHANNEL_DATA_TX=3, + IPC_DMA_CHANNEL_MAX=4, + IPC_DMA_LLI_CFM_TX=8, + IPC_DMA_LLI_DATA_AC0_TX=0, + IPC_DMA_LLI_DATA_AC1_TX=1, + IPC_DMA_LLI_DATA_AC2_TX=2, + IPC_DMA_LLI_DATA_AC3_TX=3, + IPC_DMA_LLI_DATA_BCN_TX=4, + IPC_DMA_LLI_DATA_RX0=5, + IPC_DMA_LLI_DBG=7, + IPC_DMA_LLI_DBG_DUMP=10, + IPC_DMA_LLI_GP_DL=9, + IPC_DMA_LLI_GP_UL=11, + IPC_DMA_LLI_MAX=12, + IPC_DMA_LLI_MSG=6, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_DUMP_STATISTIC=26, + KE_EVT_GP_DMA_DL=25, + KE_EVT_GP_DMA_UL=3, + KE_EVT_HW_IDLE=8, + KE_EVT_IDLE=0, + KE_EVT_IPC_EMB_MSG=6, + KE_EVT_IPC_EMB_TXDESC_AC0=24, + KE_EVT_IPC_EMB_TXDESC_AC1=23, + KE_EVT_IPC_EMB_TXDESC_AC2=22, + KE_EVT_IPC_EMB_TXDESC_AC3=21, + KE_EVT_IPC_EMB_TXDESC_BCN=20, + KE_EVT_IRQ_UP_BH=1, + KE_EVT_IRQ_USR=2, + KE_EVT_KE_MESSAGE=7, + KE_EVT_KE_TIMER=5, + KE_EVT_MAX=27, + KE_EVT_MM_TIMER=4, + KE_EVT_PRIMARY_TBTT=9, + KE_EVT_RESET=0, + KE_EVT_RUNNING=1, + KE_EVT_RXREADY=13, + KE_EVT_RXUPLOADED=11, + KE_EVT_RXUREADY=12, + KE_EVT_SECONDARY_TBTT=10, + KE_EVT_TXCFM_AC0=19, + KE_EVT_TXCFM_AC1=18, + KE_EVT_TXCFM_AC2=17, + KE_EVT_TXCFM_AC3=16, + KE_EVT_TXCFM_BCN=15, + KE_EVT_TXFRAME_CFM=14, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MACBYP_IDLE=0, + MACBYP_OFF=0, + MACBYP_ON=1, + MACBYP_RX=1, + MACBYP_TX_BURST=3, + MACBYP_TX_CONT=4, + MACBYP_TX_SINGLE=2, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RATE_11MBPS=22, + MAC_RATE_12MBPS=24, + MAC_RATE_18MBPS=36, + MAC_RATE_1MBPS=2, + MAC_RATE_24MBPS=48, + MAC_RATE_2MBPS=4, + MAC_RATE_36MBPS=72, + MAC_RATE_48MBPS=96, + MAC_RATE_54MBPS=108, + MAC_RATE_5_5MBPS=11, + MAC_RATE_6MBPS=12, + MAC_RATE_9MBPS=18, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MEXT_IRQn=11, + ME_BUSY=1, + ME_IDLE=0, + ME_STATE_MAX=2, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MODE_802_11A=1, + MODE_802_11AC_5=6, + MODE_802_11B=0, + MODE_802_11G=2, + MODE_802_11N_2_4=3, + MODE_802_11N_5=4, + MODE_RESERVED=5, + MOD_CLASS_DSSS_OFDM=5, + MOD_CLASS_ERP_OFDM=6, + MOD_CLASS_ERP_PBCC=4, + MOD_CLASS_FHSS=2, + MOD_CLASS_HR_DSSS=3, + MOD_CLASS_HT=8, + MOD_CLASS_INFRA=1, + MOD_CLASS_OFDM=7, + MOD_CLASS_VHT=9, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + PHY_FORMATMOD_11B=0, + PHY_FORMATMOD_11G=1, + PHY_FORMATMOD_11N=2, + PHY_PRIM=0, + PHY_SEC=1, + POOL_LINKED_LIST=0, + PORT_CLOSED=0, + PORT_CONTROLED=1, + PORT_OPEN=2, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RFC_BBMODE_BLE=1, + RFC_BBMODE_WLAN=0, + RFC_BW_10M=1, + RFC_BW_20M=0, + RFC_FORMATMOD_11B=0, + RFC_FORMATMOD_11G=1, + RFC_FORMATMOD_11N=2, + RFC_FSM_FORCE_OFF=15, + RFC_FSM_LO=2, + RFC_FSM_PD=0, + RFC_FSM_RX=3, + RFC_FSM_SB=1, + RFC_FSM_TX=4, + RFC_PC_AUTO=0, + RFC_PC_BT_BLE=4, + RFC_PC_WLAN_11B=1, + RFC_PC_WLAN_11G=2, + RFC_PC_WLAN_11N=3, + RFC_RC_FORCE_OFF=15, + RFC_RC_IDLE=0, + RFC_RC_RX2ON=1, + RFC_RC_RXON=3, + RFC_RC_TX2ON=2, + RFC_RC_TX2PAON=4, + RFC_RC_TXPAON=7, + RFC_SG_RAMP=2, + RFC_SG_SINGLE_TONE=0, + RFC_SG_TWO_TONE=1, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCANU_IDLE=0, + SCANU_SCANNING=1, + SCANU_STATE_MAX=2, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + STA_HT_CAPA=2, + STA_MAX=12, + STA_MFP_CAPA=8, + STA_OPMOD_NOTIF=16, + STA_QOS_CAPA=1, + STA_VHT_CAPA=4, + S_COPY=0, + S_DOT=4, + S_FLAGS=2, + S_MAX=8, + S_PERCENT=1, + S_PRECIS=5, + S_SIZE=6, + S_TYPE=7, + S_WIDTH=3, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TCAL_NUM_CALS=4, + TCAL_RXGAIN=2, + TCAL_RXIQ=3, + TCAL_TXGAIN=0, + TCAL_TXIQ=1, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + THD_CHK_STATE=0, + TID_0=0, + TID_1=1, + TID_2=2, + TID_3=3, + TID_4=4, + TID_5=5, + TID_6=6, + TID_7=7, + TID_MAX=9, + TID_MGT=8, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_CUSTOM=4, + TX_DEFAULT_24G=0, + TX_DEFAULT_5G=1, + TX_DEFAULT_NDP=3, + TX_DEFAULT_NDPA_BRP=2, + TX_EXT=1, + TX_INT=0, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VIF_AP=2, + VIF_IBSS=1, + VIF_MESH_POINT=3, + VIF_STA=0, + VIF_UNKNOWN=4, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WMM_AC_BE=0, + WMM_AC_BK=1, + WMM_AC_VI=2, + WMM_AC_VO=3, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4, + shaInputTooLong=2, + shaNull=1, + shaStateError=3, + shaSuccess=0 +} anon_enum_8_for_state; + +struct bt_mesh_lpn { + enum anon_enum_8_for_state state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct anon_struct.conflict412 anon_struct.conflict412, *Panon_struct.conflict412; + +struct anon_struct.conflict412 { + u32_t.conflict start; + u16_t frnd; + u16_t repeat_sec; + struct k_delayed_work timer; +}; + +typedef enum bt_mesh_net_if { + BT_MESH_NET_IF_ADV=0, + BT_MESH_NET_IF_LOCAL=1, + BT_MESH_NET_IF_PROXY=2, + BT_MESH_NET_IF_PROXY_CFG=3 +} bt_mesh_net_if; + +typedef struct bt_mesh_net_rx.conflict1 bt_mesh_net_rx.conflict1, *Pbt_mesh_net_rx.conflict1; + +struct bt_mesh_net_rx.conflict1 { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx ctx; + u32_t.conflict seq; + u8_t old_iv:1; + u8_t new_key:1; + u8_t friend_cred:1; + u8_t ctl:1; + u8_t net_if:2; + u8_t local_match:1; + u8_t friend_match:1; + undefined field_0x21; + u16_t msg_cache_idx; +}; + +typedef struct bt_mesh_lpn.conflict2 bt_mesh_lpn.conflict2, *Pbt_mesh_lpn.conflict2; + +struct bt_mesh_lpn.conflict2 { + enum anon_enum_8_for_state.conflict1 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct bt_mesh_lpn.conflict1 bt_mesh_lpn.conflict1, *Pbt_mesh_lpn.conflict1; + +struct bt_mesh_lpn.conflict1 { + enum anon_enum_8_for_state.conflict1 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct bt_mesh_lpn.conflict8 bt_mesh_lpn.conflict8, *Pbt_mesh_lpn.conflict8; + +struct bt_mesh_lpn.conflict8 { + enum anon_enum_8_for_state.conflict3 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct bt_mesh_lpn.conflict4 bt_mesh_lpn.conflict4, *Pbt_mesh_lpn.conflict4; + +struct bt_mesh_lpn.conflict4 { + enum anon_enum_8_for_state.conflict2 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct bt_mesh_lpn.conflict3 bt_mesh_lpn.conflict3, *Pbt_mesh_lpn.conflict3; + +struct bt_mesh_lpn.conflict3 { + enum anon_enum_8_for_state.conflict1 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct bt_mesh_lpn.conflict6 bt_mesh_lpn.conflict6, *Pbt_mesh_lpn.conflict6; + +struct bt_mesh_lpn.conflict6 { + enum anon_enum_8_for_state.conflict3 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct bt_mesh_net_rx.conflict5 bt_mesh_net_rx.conflict5, *Pbt_mesh_net_rx.conflict5; + +struct bt_mesh_net_rx.conflict5 { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx ctx; + u32_t.conflict seq; + u8_t old_iv:1; + u8_t new_key:1; + u8_t friend_cred:1; + u8_t ctl:1; + u8_t net_if:2; + u8_t local_match:1; + u8_t friend_match:1; + undefined field_0x21; + u16_t msg_cache_idx; +}; + +typedef struct bt_mesh_net_rx.conflict6 bt_mesh_net_rx.conflict6, *Pbt_mesh_net_rx.conflict6; + +struct bt_mesh_net_rx.conflict6 { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx ctx; + u32_t.conflict seq; + u8_t old_iv:1; + u8_t new_key:1; + u8_t friend_cred:1; + u8_t ctl:1; + u8_t net_if:2; + u8_t local_match:1; + u8_t friend_match:1; + undefined field_0x21; + u16_t msg_cache_idx; +}; + +typedef struct bt_mesh_net_rx.conflict3 bt_mesh_net_rx.conflict3, *Pbt_mesh_net_rx.conflict3; + +struct bt_mesh_net_rx.conflict3 { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx ctx; + u32_t.conflict seq; + u8_t old_iv:1; + u8_t new_key:1; + u8_t friend_cred:1; + u8_t ctl:1; + u8_t net_if:2; + u8_t local_match:1; + u8_t friend_match:1; + undefined field_0x21; + u16_t msg_cache_idx; +}; + +typedef struct bt_mesh_net_rx.conflict4 bt_mesh_net_rx.conflict4, *Pbt_mesh_net_rx.conflict4; + +struct bt_mesh_net_rx.conflict4 { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx ctx; + u32_t.conflict seq; + u8_t old_iv:1; + u8_t new_key:1; + u8_t friend_cred:1; + u8_t ctl:1; + u8_t net_if:2; + u8_t local_match:1; + u8_t friend_match:1; + undefined field_0x21; + u16_t msg_cache_idx; +}; + +typedef struct bt_mesh_net_rx.conflict9 bt_mesh_net_rx.conflict9, *Pbt_mesh_net_rx.conflict9; + +struct bt_mesh_net_rx.conflict9 { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx ctx; + u32_t.conflict seq; + u8_t old_iv:1; + u8_t new_key:1; + u8_t friend_cred:1; + u8_t ctl:1; + u8_t net_if:2; + u8_t local_match:1; + u8_t friend_match:1; + undefined field_0x21; + u16_t msg_cache_idx; +}; + +typedef struct bt_mesh_net_rx.conflict7 bt_mesh_net_rx.conflict7, *Pbt_mesh_net_rx.conflict7; + +struct bt_mesh_net_rx.conflict7 { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx ctx; + u32_t.conflict seq; + u8_t old_iv:1; + u8_t new_key:1; + u8_t friend_cred:1; + u8_t ctl:1; + u8_t net_if:2; + u8_t local_match:1; + u8_t friend_match:1; + undefined field_0x21; + u16_t msg_cache_idx; +}; + +typedef struct bt_mesh_net_rx.conflict8 bt_mesh_net_rx.conflict8, *Pbt_mesh_net_rx.conflict8; + +struct bt_mesh_net_rx.conflict8 { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx ctx; + u32_t.conflict seq; + u8_t old_iv:1; + u8_t new_key:1; + u8_t friend_cred:1; + u8_t ctl:1; + u8_t net_if:2; + u8_t local_match:1; + u8_t friend_match:1; + undefined field_0x21; + u16_t msg_cache_idx; +}; + +typedef struct bt_mesh_net_tx.conflict3 bt_mesh_net_tx.conflict3, *Pbt_mesh_net_tx.conflict3; + +struct bt_mesh_net_tx.conflict3 { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx * ctx; + u16_t src; + u8_t xmit; + u8_t friend_cred:1; + u8_t aszmic:1; + u8_t aid:6; +}; + +typedef struct bt_mesh_net_tx.conflict4 bt_mesh_net_tx.conflict4, *Pbt_mesh_net_tx.conflict4; + +struct bt_mesh_net_tx.conflict4 { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx * ctx; + u16_t src; + u8_t xmit; + u8_t friend_cred:1; + u8_t aszmic:1; + u8_t aid:6; +}; + +typedef struct bt_mesh_net_tx.conflict1 bt_mesh_net_tx.conflict1, *Pbt_mesh_net_tx.conflict1; + +struct bt_mesh_net_tx.conflict1 { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx * ctx; + u16_t src; + u8_t xmit; + u8_t friend_cred:1; + u8_t aszmic:1; + u8_t aid:6; +}; + +typedef struct bt_mesh_net_tx.conflict2 bt_mesh_net_tx.conflict2, *Pbt_mesh_net_tx.conflict2; + +struct bt_mesh_net_tx.conflict2 { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx * ctx; + u16_t src; + u8_t xmit; + u8_t friend_cred:1; + u8_t aszmic:1; + u8_t aid:6; +}; + +typedef struct anon_struct.conflict459 anon_struct.conflict459, *Panon_struct.conflict459; + +struct anon_struct.conflict459 { + u8_t nid; + u8_t enc[16]; + u8_t privacy[16]; +}; + +typedef struct bt_mesh_lpn.conflict27 bt_mesh_lpn.conflict27, *Pbt_mesh_lpn.conflict27; + +struct bt_mesh_lpn.conflict27 { + enum anon_enum_8_for_state.conflict6 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct bt_mesh_lpn.conflict28 bt_mesh_lpn.conflict28, *Pbt_mesh_lpn.conflict28; + +struct bt_mesh_lpn.conflict28 { + enum anon_enum_8_for_state.conflict6 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct bt_mesh_lpn.conflict29 bt_mesh_lpn.conflict29, *Pbt_mesh_lpn.conflict29; + +struct bt_mesh_lpn.conflict29 { + enum anon_enum_8_for_state.conflict6 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct anon_struct.conflict463 anon_struct.conflict463, *Panon_struct.conflict463; + +struct anon_struct.conflict463 { + u32_t.conflict start; + u16_t frnd; + u16_t repeat_sec; + struct k_delayed_work timer; +}; + +typedef struct bt_mesh_net_tx bt_mesh_net_tx, *Pbt_mesh_net_tx; + +struct bt_mesh_net_tx { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx * ctx; + u16_t src; + u8_t xmit; + u8_t friend_cred:1; + u8_t aszmic:1; + u8_t aid:6; +}; + +typedef struct anon_struct.conflict476 anon_struct.conflict476, *Panon_struct.conflict476; + +struct anon_struct.conflict476 { + u32_t.conflict start; + u16_t frnd; + u16_t repeat_sec; + struct k_delayed_work timer; +}; + +typedef struct anon_struct.conflict480 anon_struct.conflict480, *Panon_struct.conflict480; + +struct anon_struct.conflict480 { + u32_t.conflict start; + u16_t frnd; + u16_t repeat_sec; + struct k_delayed_work timer; +}; + +typedef struct bt_mesh_lpn.conflict10 bt_mesh_lpn.conflict10, *Pbt_mesh_lpn.conflict10; + +struct bt_mesh_lpn.conflict10 { + enum anon_enum_8_for_state.conflict3 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct bt_mesh_lpn.conflict12 bt_mesh_lpn.conflict12, *Pbt_mesh_lpn.conflict12; + +struct bt_mesh_lpn.conflict12 { + enum anon_enum_8_for_state.conflict3 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct bt_mesh_lpn.conflict14 bt_mesh_lpn.conflict14, *Pbt_mesh_lpn.conflict14; + +struct bt_mesh_lpn.conflict14 { + enum anon_enum_8_for_state.conflict3 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct anon_struct.conflict484 anon_struct.conflict484, *Panon_struct.conflict484; + +struct anon_struct.conflict484 { + u32_t.conflict start; + u16_t frnd; + u16_t repeat_sec; + struct k_delayed_work timer; +}; + +typedef struct bt_mesh_lpn.conflict16 bt_mesh_lpn.conflict16, *Pbt_mesh_lpn.conflict16; + +struct bt_mesh_lpn.conflict16 { + enum anon_enum_8_for_state.conflict3 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct bt_mesh_lpn.conflict18 bt_mesh_lpn.conflict18, *Pbt_mesh_lpn.conflict18; + +struct bt_mesh_lpn.conflict18 { + enum anon_enum_8_for_state.conflict4 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct bt_mesh_lpn.conflict20 bt_mesh_lpn.conflict20, *Pbt_mesh_lpn.conflict20; + +struct bt_mesh_lpn.conflict20 { + enum anon_enum_8_for_state.conflict4 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct bt_mesh_lpn.conflict22 bt_mesh_lpn.conflict22, *Pbt_mesh_lpn.conflict22; + +struct bt_mesh_lpn.conflict22 { + enum anon_enum_8_for_state.conflict4 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct bt_mesh_lpn.conflict23 bt_mesh_lpn.conflict23, *Pbt_mesh_lpn.conflict23; + +struct bt_mesh_lpn.conflict23 { + enum anon_enum_8_for_state.conflict4 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct bt_mesh_lpn.conflict24 bt_mesh_lpn.conflict24, *Pbt_mesh_lpn.conflict24; + +struct bt_mesh_lpn.conflict24 { + enum anon_enum_8_for_state.conflict5 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct bt_mesh_lpn.conflict25 bt_mesh_lpn.conflict25, *Pbt_mesh_lpn.conflict25; + +struct bt_mesh_lpn.conflict25 { + enum anon_enum_8_for_state.conflict5 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct bt_mesh_lpn.conflict26 bt_mesh_lpn.conflict26, *Pbt_mesh_lpn.conflict26; + +struct bt_mesh_lpn.conflict26 { + enum anon_enum_8_for_state.conflict6 state; + u8_t xact_next; + u8_t xact_pending; + u8_t sent_req; + u16_t frnd; + u8_t recv_win; + u8_t req_attempts; + s32_t poll_timeout; + u8_t groups_changed:1; + u8_t pending_poll:1; + u8_t disable:1; + u8_t fsn:1; + u8_t established:1; + u8_t clear_success:1; + u8_t queue_size; + u16_t counter; + u16_t old_friend; + u16_t adv_duration; + struct k_delayed_work timer; + u16_t groups[8]; + atomic_t added[1]; + atomic_t pending[1]; + atomic_t to_remove[1]; +}; + +typedef struct anon_struct.conflict416 anon_struct.conflict416, *Panon_struct.conflict416; + +struct anon_struct.conflict416 { + u32_t.conflict start; + u16_t frnd; + u16_t repeat_sec; + struct k_delayed_work timer; +}; + +typedef struct anon_struct.conflict417 anon_struct.conflict417, *Panon_struct.conflict417; + +struct anon_struct.conflict417 { + u8_t nid; + u8_t enc[16]; + u8_t privacy[16]; +}; + +typedef struct anon_struct.conflict424 anon_struct.conflict424, *Panon_struct.conflict424; + +struct anon_struct.conflict424 { + u32_t.conflict start; + u16_t frnd; + u16_t repeat_sec; + struct k_delayed_work timer; +}; + +typedef struct anon_struct.conflict434 anon_struct.conflict434, *Panon_struct.conflict434; + +struct anon_struct.conflict434 { + u32_t.conflict start; + u16_t frnd; + u16_t repeat_sec; + struct k_delayed_work timer; +}; + +typedef struct anon_struct.conflict437 anon_struct.conflict437, *Panon_struct.conflict437; + +struct anon_struct.conflict437 { + u32_t.conflict start; + u16_t frnd; + u16_t repeat_sec; + struct k_delayed_work timer; +}; + +typedef struct anon_struct.conflict440 anon_struct.conflict440, *Panon_struct.conflict440; + +struct anon_struct.conflict440 { + u32_t.conflict start; + u16_t frnd; + u16_t repeat_sec; + struct k_delayed_work timer; +}; + +typedef struct anon_struct.conflict443 anon_struct.conflict443, *Panon_struct.conflict443; + +struct anon_struct.conflict443 { + u32_t.conflict start; + u16_t frnd; + u16_t repeat_sec; + struct k_delayed_work timer; +}; + +typedef struct bt_mesh_net_rx bt_mesh_net_rx, *Pbt_mesh_net_rx; + +struct bt_mesh_net_rx { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx ctx; + u32_t.conflict seq; + u8_t old_iv:1; + u8_t new_key:1; + u8_t friend_cred:1; + u8_t ctl:1; + u8_t net_if:2; + u8_t local_match:1; + u8_t friend_match:1; + undefined field_0x21; + u16_t msg_cache_idx; +}; + +typedef struct anon_struct.conflict448 anon_struct.conflict448, *Panon_struct.conflict448; + +struct anon_struct.conflict448 { + u32_t.conflict start; + u16_t frnd; + u16_t repeat_sec; + struct k_delayed_work timer; +}; + +typedef struct anon_struct.conflict457 anon_struct.conflict457, *Panon_struct.conflict457; + +struct anon_struct.conflict457 { + u32_t.conflict start; + u16_t frnd; + u16_t repeat_sec; + struct k_delayed_work timer; +}; + +typedef struct anon_struct.conflict458 anon_struct.conflict458, *Panon_struct.conflict458; + +struct anon_struct.conflict458 { + u8_t nid; + u8_t enc[16]; + u8_t privacy[16]; +}; + +typedef struct anon_struct.conflict451 anon_struct.conflict451, *Panon_struct.conflict451; + +struct anon_struct.conflict451 { + u32_t.conflict start; + u16_t frnd; + u16_t repeat_sec; + struct k_delayed_work timer; +}; + +typedef struct anon_struct.conflict454 anon_struct.conflict454, *Panon_struct.conflict454; + +struct anon_struct.conflict454 { + u32_t.conflict start; + u16_t frnd; + u16_t repeat_sec; + struct k_delayed_work timer; +}; + +typedef struct bt_mesh_net_tx.conflict7 bt_mesh_net_tx.conflict7, *Pbt_mesh_net_tx.conflict7; + +struct bt_mesh_net_tx.conflict7 { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx * ctx; + u16_t src; + u8_t xmit; + u8_t friend_cred:1; + u8_t aszmic:1; + u8_t aid:6; +}; + +typedef struct bt_mesh_net.conflict bt_mesh_net.conflict, *Pbt_mesh_net.conflict; + +struct bt_mesh_net.conflict { + u32_t.conflict iv_index; + u32_t.conflict seq; + atomic_t flags[1]; + struct k_work local_work; + sys_slist_t local_queue; + struct bt_mesh_friend.conflict3 frnd[2]; + struct bt_mesh_lpn.conflict2 lpn; + u8_t ivu_duration; + undefined field_0x17d; + undefined field_0x17e; + undefined field_0x17f; + struct k_delayed_work ivu_timer; + u8_t dev_key[16]; + struct bt_mesh_app_key app_keys[2]; + struct bt_mesh_subnet sub[2]; + struct bt_mesh_rpl rpl[5]; +}; + +typedef struct bt_mesh_friend bt_mesh_friend, *Pbt_mesh_friend; + +struct bt_mesh_friend { + u16_t lpn; + u8_t recv_delay; + u8_t fsn:1; + u8_t send_last:1; + u8_t pending_req:1; + u8_t sec_update:1; + u8_t pending_buf:1; + u8_t valid:1; + u8_t established:1; + s32_t poll_to; + u8_t num_elem; + undefined field_0x9; + u16_t lpn_counter; + u16_t counter; + u16_t net_idx; + u16_t sub_list[3]; + undefined field_0x16; + undefined field_0x17; + struct k_delayed_work timer; + struct bt_mesh_friend_seg seg[1]; + struct net_buf * last; + sys_slist_t queue; + u32_t.conflict queue_size; + struct anon_struct_for_clear clear; +}; + +typedef struct bt_mesh_net.conflict12 bt_mesh_net.conflict12, *Pbt_mesh_net.conflict12; + +struct bt_mesh_net.conflict12 { + u32_t.conflict iv_index; + u32_t.conflict seq; + atomic_t flags[1]; + struct k_work local_work; + sys_slist_t local_queue; + struct bt_mesh_friend.conflict40 frnd[2]; + struct bt_mesh_lpn.conflict27 lpn; + u8_t ivu_duration; + undefined field_0x17d; + undefined field_0x17e; + undefined field_0x17f; + struct k_delayed_work ivu_timer; + u8_t dev_key[16]; + struct bt_mesh_app_key app_keys[2]; + struct bt_mesh_subnet sub[2]; + struct bt_mesh_rpl rpl[5]; +}; + +typedef struct bt_mesh_net.conflict11 bt_mesh_net.conflict11, *Pbt_mesh_net.conflict11; + +struct bt_mesh_net.conflict11 { + u32_t.conflict iv_index; + u32_t.conflict seq; + atomic_t flags[1]; + struct k_work local_work; + sys_slist_t local_queue; + struct bt_mesh_friend.conflict37 frnd[2]; + struct bt_mesh_lpn.conflict25 lpn; + u8_t ivu_duration; + undefined field_0x17d; + undefined field_0x17e; + undefined field_0x17f; + struct k_delayed_work ivu_timer; + u8_t dev_key[16]; + struct bt_mesh_app_key app_keys[2]; + struct bt_mesh_subnet sub[2]; + struct bt_mesh_rpl rpl[5]; +}; + +typedef struct bt_mesh_net.conflict13 bt_mesh_net.conflict13, *Pbt_mesh_net.conflict13; + +struct bt_mesh_net.conflict13 { + u32_t.conflict iv_index; + u32_t.conflict seq; + atomic_t flags[1]; + struct k_work local_work; + sys_slist_t local_queue; + struct bt_mesh_friend.conflict43 frnd[2]; + struct bt_mesh_lpn.conflict29 lpn; + u8_t ivu_duration; + undefined field_0x17d; + undefined field_0x17e; + undefined field_0x17f; + struct k_delayed_work ivu_timer; + u8_t dev_key[16]; + struct bt_mesh_app_key app_keys[2]; + struct bt_mesh_subnet sub[2]; + struct bt_mesh_rpl rpl[5]; +}; + +typedef struct bt_mesh_net bt_mesh_net, *Pbt_mesh_net; + +struct bt_mesh_net { + u32_t.conflict iv_index; + u32_t.conflict seq; + atomic_t flags[1]; + struct k_work local_work; + sys_slist_t local_queue; + struct bt_mesh_friend.conflict frnd[2]; + struct bt_mesh_lpn.conflict lpn; + u8_t ivu_duration; + undefined field_0x17d; + undefined field_0x17e; + undefined field_0x17f; + struct k_delayed_work ivu_timer; + u8_t dev_key[16]; + struct bt_mesh_app_key app_keys[2]; + struct bt_mesh_subnet sub[2]; + struct bt_mesh_rpl rpl[5]; +}; + +typedef struct bt_mesh_net.conflict10 bt_mesh_net.conflict10, *Pbt_mesh_net.conflict10; + +struct bt_mesh_net.conflict10 { + u32_t.conflict iv_index; + u32_t.conflict seq; + atomic_t flags[1]; + struct k_work local_work; + sys_slist_t local_queue; + struct bt_mesh_friend.conflict34 frnd[2]; + struct bt_mesh_lpn.conflict23 lpn; + u8_t ivu_duration; + undefined field_0x17d; + undefined field_0x17e; + undefined field_0x17f; + struct k_delayed_work ivu_timer; + u8_t dev_key[16]; + struct bt_mesh_app_key app_keys[2]; + struct bt_mesh_subnet sub[2]; + struct bt_mesh_rpl rpl[5]; +}; + +typedef struct bt_mesh_net_tx.conflict9 bt_mesh_net_tx.conflict9, *Pbt_mesh_net_tx.conflict9; + +struct bt_mesh_net_tx.conflict9 { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx * ctx; + u16_t src; + u8_t xmit; + u8_t friend_cred:1; + u8_t aszmic:1; + u8_t aid:6; +}; + +typedef struct bt_mesh_net_tx.conflict8 bt_mesh_net_tx.conflict8, *Pbt_mesh_net_tx.conflict8; + +struct bt_mesh_net_tx.conflict8 { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx * ctx; + u16_t src; + u8_t xmit; + u8_t friend_cred:1; + u8_t aszmic:1; + u8_t aid:6; +}; + +typedef struct bt_mesh_net_tx.conflict5 bt_mesh_net_tx.conflict5, *Pbt_mesh_net_tx.conflict5; + +struct bt_mesh_net_tx.conflict5 { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx * ctx; + u16_t src; + u8_t xmit; + u8_t friend_cred:1; + u8_t aszmic:1; + u8_t aid:6; +}; + +typedef struct bt_mesh_net_tx.conflict6 bt_mesh_net_tx.conflict6, *Pbt_mesh_net_tx.conflict6; + +struct bt_mesh_net_tx.conflict6 { + struct bt_mesh_subnet * sub; + struct bt_mesh_msg_ctx * ctx; + u16_t src; + u8_t xmit; + u8_t friend_cred:1; + u8_t aszmic:1; + u8_t aid:6; +}; + +typedef int sys_prot_t; + +typedef struct rfc_status_tag.conflict rfc_status_tag.conflict, *Prfc_status_tag.conflict; + +struct rfc_status_tag.conflict { + uint32_t pkdet_out_raw:1; + uint32_t dig_xtal_clk_dbg:1; + uint32_t clk_ble_16m_dbg:1; + uint32_t clk_rc_dbg0:1; + uint32_t clk_adcpow_dbg:1; + uint32_t clk_fetx_dbg:1; + uint32_t clk_ferx_dbg:1; + uint32_t clkpll_postdiv_outclk_dbg:1; + uint32_t clk_soc_480m_dbg:1; + uint32_t clk_soc_240m_dbg:1; + uint32_t clk_soc_192m_dbg:1; + uint32_t clk_soc_160m_dbg:1; + uint32_t clk_soc_120m_dbg:1; + uint32_t clk_soc_96m_dbg:1; + uint32_t clk_soc_80m_dbg:1; + uint32_t clk_soc_48m_dbg:1; + uint32_t clk_soc_32m_dbg:1; + uint32_t pad_pkdet_out:1; + uint32_t pad_agc_ctrl:10; + uint32_t rf_pkdet_rst_hw:1; + uint32_t rf_cbw_wifi:2; + uint32_t lo_unlocked:1; + uint32_t fsm_pu_txbuf:1; + uint32_t fsm_pu_rxbuf:1; + uint32_t fsm_pu_tosdac:1; + uint32_t fsm_pu_dac:1; + uint32_t fsm_trsw_en:1; + uint32_t fsm_pu_adc:1; + uint32_t fsm_pu_pkdet:1; + uint32_t fsm_pu_rbb:1; + uint32_t fsm_pu_rmx:1; + uint32_t fsm_pu_rmxgm:1; + uint32_t fsm_pu_lna:1; + uint32_t clk_rc_dbg2:1; + uint32_t rf_lna_ind_hw:4; + uint32_t rf_rbb_ind_hw:4; + uint32_t rf_tx_pow_lvl_hw:4; + uint32_t rf_rc_lo_rdy:1; + uint32_t rf_fsm_state:3; + uint32_t rf_rc_state:3; + uint32_t clk_rc_dbg:1; +}; + +typedef struct rfc_status_tag rfc_status_tag, *Prfc_status_tag; + +struct rfc_status_tag { + uint32_t pkdet_out_raw:1; + uint32_t dig_xtal_clk_dbg:1; + uint32_t clk_ble_16m_dbg:1; + uint32_t clk_rc_dbg0:1; + uint32_t clk_adcpow_dbg:1; + uint32_t clk_fetx_dbg:1; + uint32_t clk_ferx_dbg:1; + uint32_t clkpll_postdiv_outclk_dbg:1; + uint32_t clk_soc_480m_dbg:1; + uint32_t clk_soc_240m_dbg:1; + uint32_t clk_soc_192m_dbg:1; + uint32_t clk_soc_160m_dbg:1; + uint32_t clk_soc_120m_dbg:1; + uint32_t clk_soc_96m_dbg:1; + uint32_t clk_soc_80m_dbg:1; + uint32_t clk_soc_48m_dbg:1; + uint32_t clk_soc_32m_dbg:1; + uint32_t pad_pkdet_out:1; + uint32_t pad_agc_ctrl:10; + uint32_t rf_pkdet_rst_hw:1; + uint32_t rf_cbw_wifi:2; + uint32_t lo_unlocked:1; + uint32_t fsm_pu_txbuf:1; + uint32_t fsm_pu_rxbuf:1; + uint32_t fsm_pu_tosdac:1; + uint32_t fsm_pu_dac:1; + uint32_t fsm_trsw_en:1; + uint32_t fsm_pu_adc:1; + uint32_t fsm_pu_pkdet:1; + uint32_t fsm_pu_rbb:1; + uint32_t fsm_pu_rmx:1; + uint32_t fsm_pu_rmxgm:1; + uint32_t fsm_pu_lna:1; + uint32_t clk_rc_dbg2:1; + uint32_t rf_lna_ind_hw:4; + uint32_t rf_rbb_ind_hw:4; + uint32_t rf_tx_pow_lvl_hw:4; + uint32_t rf_rc_lo_rdy:1; + uint32_t rf_fsm_state:3; + uint32_t rf_rc_state:3; + uint32_t clk_rc_dbg:1; +}; + +typedef struct adc_ctx.conflict adc_ctx.conflict, *Padc_ctx.conflict; + +struct adc_ctx.conflict { + int mode; + uint32_t * channel_data; + void * adc_lli; + int lli_flag; + uint32_t chan_init_table; + uint32_t data_size; + void (* cb)(int, uint32_t *, uint32_t); +}; + +typedef struct adc_ctx adc_ctx, *Padc_ctx; + +struct adc_ctx { + int mode; + uint32_t * channel_data; + void * adc_lli; + int lli_flag; + uint32_t chan_init_table; + uint32_t data_size; + void (* cb)(int, uint32_t *, uint32_t); +}; + +typedef struct adc_ctx.conflict1 adc_ctx.conflict1, *Padc_ctx.conflict1; + +typedef struct adc_ctx.conflict1 adc_ctx_t.conflict; + +struct adc_ctx.conflict1 { + int mode; + uint32_t * channel_data; + void * adc_lli; + int lli_flag; + uint32_t chan_init_table; + uint32_t data_size; + void (* cb)(int, uint32_t *, uint32_t); +}; + +typedef struct adc_ctx.conflict adc_ctx_t; + + +// WARNING! conflicting data type names: /DWARF/cli.c/handle_input/anon_struct - /DWARF/reent.h/anon_struct + +typedef struct llcp_pdu_handler_info llcp_pdu_handler_info, *Pllcp_pdu_handler_info; + +struct llcp_pdu_handler_info { + int (* handler)(uint16_t, ke_task_id_t, _Bool, union llcp_pdu *); + _Bool int_ctx_allowed; + uint8_t enc_auth; + undefined field_0x6; + undefined field_0x7; +}; + +typedef enum llc_instant_state { + LLC_INSTANT_ACCEPTED=1, + LLC_INSTANT_COLLISION=2, + LLC_INSTANT_IGNORED=0, + LLC_INSTANT_MIC_FAILURE=4, + LLC_INSTANT_PASSED=3, + LLC_INSTANT_REJECT=5 +} llc_instant_state; + +typedef struct cli_command cli_command, *Pcli_command; + +struct cli_command { + char * name; + char * help; + void (* function)(char *, int, int, char * *); +}; + +typedef struct cli_st cli_st, *Pcli_st; + +struct cli_st { + int initialized; + int echo_disabled; + struct cli_command * static_cmds; + struct cli_command * dynamic_cmds[8]; + uint num_static_cmds; + uint num_commands; + uint bp; + char inbuf[256]; + char * outbuf; + int his_idx; + int his_cur; + char history[256]; +}; + +typedef struct pmkElement_t pmkElement_t, *PpmkElement_t; + +typedef union anon_union_for_key anon_union_for_key, *Panon_union_for_key; + +union anon_union_for_key { + IEEEtypes_MacAddr_t Bssid; + char Ssid[32]; +}; + +struct pmkElement_t { + union anon_union_for_key key; + UINT8 PMK[32]; + UINT8 length; + UINT8 psk_length; + SINT8 replacementRank; +}; + +typedef union anon_union.conflict38 anon_union.conflict38, *Panon_union.conflict38; + +union anon_union.conflict38 { + IEEEtypes_MacAddr_t Bssid; + char Ssid[32]; +}; + +typedef struct bl_wifi_ap_info bl_wifi_ap_info, *Pbl_wifi_ap_info; + +typedef struct bl_wifi_ap_info bl_wifi_ap_info_t; + +struct bl_wifi_ap_info { + uint8_t ssid[33]; + uint8_t psk[65]; + uint8_t chan; +}; + +typedef struct dns_ans_hdr dns_ans_hdr, *Pdns_ans_hdr; + +struct dns_ans_hdr { + uint16_t id; + uint16_t flag; + uint16_t numquestions; + uint16_t numanswers; + uint16_t numauthrr; + uint16_t numextrarr; +}; + +typedef struct dns_server_ctx dns_server_ctx, *Pdns_server_ctx; + +struct dns_server_ctx { + uint8_t name[256]; + uint16_t txid; + uint16_t nquestions; + uint16_t nanswers; + undefined field_0x106; + undefined field_0x107; + struct udp_pcb * upcb1; + ip_addr_t * addr1; + u16_t port1; + undefined field_0x112; + undefined field_0x113; +}; + +typedef struct dns_table_entry dns_table_entry, *Pdns_table_entry; + +struct dns_table_entry { + uint16_t txid; + uint16_t flags; + uint16_t numque; + uint16_t ansrrs; + uint16_t autrrs; + uint16_t addrrs; + uint16_t type; + uint16_t class; + uint16_t poiname; + uint16_t anstype; + uint16_t anstypee; + uint16_t datalen; + uint32_t anstime; + uint32_t adress; +}; + +typedef struct dns_ans_ans dns_ans_ans, *Pdns_ans_ans; + +struct dns_ans_ans { + uint16_t typ; + uint16_t cls; + uint16_t point; + uint16_t antyp; + uint16_t antypp; + uint16_t len; + uint32_t time; + uint32_t addr; +}; + +typedef struct _bl_wifi_env _bl_wifi_env, *P_bl_wifi_env; + +struct _bl_wifi_env { + uint8_t sta_mac_addr_board[6]; + uint8_t sta_mac_addr_usr[6]; + uint8_t ap_mac_addr_board[6]; + uint8_t ap_mac_addr_usr[6]; + uint8_t country_code; + bl_wifi_ap_info_t ap_info; + uint8_t ap_info_en; + bl_wifi_ap_info_t sta_info; + uint8_t sta_info_en; +}; + +typedef struct _bl_wifi_env bl_wifi_env_t; + +typedef struct me_rc_stats_cfm me_rc_stats_cfm, *Pme_rc_stats_cfm; + +struct me_rc_stats_cfm { + uint8_t sta_idx; + undefined field_0x1; + uint16_t no_samples; + uint16_t ampdu_len; + uint16_t ampdu_packets; + uint32_t avg_ampdu_len; + uint8_t sw_retry_step; + uint8_t sample_wait; + undefined field_0xe; + undefined field_0xf; + struct step retry[4]; + struct rc_rate_stats rate_stats[10]; + uint32_t tp[10]; +}; + +typedef struct me_set_control_port_req me_set_control_port_req, *Pme_set_control_port_req; + +struct me_set_control_port_req { + uint8_t sta_idx; + _Bool control_port_open; +}; + +typedef struct me_set_active_req me_set_active_req, *Pme_set_active_req; + +struct me_set_active_req { + _Bool active; + uint8_t vif_idx; +}; + +typedef struct me_sta_add_cfm me_sta_add_cfm, *Pme_sta_add_cfm; + +struct me_sta_add_cfm { + uint8_t sta_idx; + uint8_t status; + uint8_t pm_state; +}; + +typedef struct me_rc_stats_req me_rc_stats_req, *Pme_rc_stats_req; + +struct me_rc_stats_req { + uint8_t sta_idx; +}; + +typedef struct me_chan_config_req me_chan_config_req, *Pme_chan_config_req; + +struct me_chan_config_req { + struct scan_chan_tag chan2G4[14]; + struct scan_chan_tag chan5G[28]; + uint8_t chan2G4_cnt; + uint8_t chan5G_cnt; +}; + +typedef struct me_traffic_ind_req me_traffic_ind_req, *Pme_traffic_ind_req; + +struct me_traffic_ind_req { + uint8_t sta_idx; + uint8_t tx_avail; + _Bool uapsd; +}; + +typedef struct me_sta_add_req me_sta_add_req, *Pme_sta_add_req; + +struct me_sta_add_req { + struct mac_addr mac_addr; + struct mac_rateset rate_set; + undefined field_0x13; + struct mac_htcapability ht_cap; + struct mac_vhtcapability vht_cap; + uint32_t flags; + uint16_t aid; + uint8_t uapsd_queues; + uint8_t max_sp_len; + uint8_t opmode; + uint8_t vif_idx; + _Bool tdls_sta; + undefined field_0x4b; + uint32_t tsflo; + uint32_t tsfhi; + int8_t rssi; + uint8_t data_rate; + undefined field_0x56; + undefined field_0x57; +}; + +typedef struct me_sta_del_req me_sta_del_req, *Pme_sta_del_req; + +struct me_sta_del_req { + uint8_t sta_idx; + _Bool tdls_sta; +}; + +typedef struct me_set_ps_disable_req me_set_ps_disable_req, *Pme_set_ps_disable_req; + +struct me_set_ps_disable_req { + _Bool ps_disable; + uint8_t vif_idx; +}; + +typedef struct me_tkip_mic_failure_ind me_tkip_mic_failure_ind, *Pme_tkip_mic_failure_ind; + +struct me_tkip_mic_failure_ind { + struct mac_addr addr; + undefined field_0x6; + undefined field_0x7; + uint64_t tsc; + _Bool ga; + uint8_t keyid; + uint8_t vif_idx; + undefined field_0x13; + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct me_rc_set_rate_req me_rc_set_rate_req, *Pme_rc_set_rate_req; + +struct me_rc_set_rate_req { + uint8_t sta_idx; + undefined field_0x1; + uint16_t fixed_rate_cfg; +}; + +typedef struct me_config_req me_config_req, *Pme_config_req; + +struct me_config_req { + struct mac_htcapability ht_cap; + struct mac_vhtcapability vht_cap; + uint16_t tx_lft; + _Bool ht_supp; + _Bool vht_supp; + _Bool ps_on; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct bt_att_hdr bt_att_hdr, *Pbt_att_hdr; + +struct bt_att_hdr { + u8_t code; +}; + +typedef struct bt_att_exchange_mtu_req bt_att_exchange_mtu_req, *Pbt_att_exchange_mtu_req; + +struct bt_att_exchange_mtu_req { + u16_t mtu; +}; + +typedef struct bt_att_error_rsp bt_att_error_rsp, *Pbt_att_error_rsp; + +struct bt_att_error_rsp { + u8_t request; + u16_t handle; + u8_t error; +}; + +typedef struct bt_att_signed_write_cmd bt_att_signed_write_cmd, *Pbt_att_signed_write_cmd; + +struct bt_att_signed_write_cmd { + u16_t handle; + u8_t[0] value; +}; + +typedef struct bt_att_find_info_req bt_att_find_info_req, *Pbt_att_find_info_req; + +struct bt_att_find_info_req { + u16_t start_handle; + u16_t end_handle; +}; + +typedef struct bt_att_prepare_write_req bt_att_prepare_write_req, *Pbt_att_prepare_write_req; + +struct bt_att_prepare_write_req { + u16_t handle; + u16_t offset; + u8_t[0] value; +}; + +typedef struct bt_att_read_req bt_att_read_req, *Pbt_att_read_req; + +struct bt_att_read_req { + u16_t handle; +}; + +typedef struct bt_att_write_req bt_att_write_req, *Pbt_att_write_req; + +struct bt_att_write_req { + u16_t handle; + u8_t[0] value; +}; + +typedef struct bt_att_read_group_req bt_att_read_group_req, *Pbt_att_read_group_req; + +struct bt_att_read_group_req { + u16_t start_handle; + u16_t end_handle; + u8_t[0] uuid; +}; + +typedef struct bt_att_write_cmd bt_att_write_cmd, *Pbt_att_write_cmd; + +struct bt_att_write_cmd { + u16_t handle; + u8_t[0] value; +}; + +typedef struct bt_att_read_blob_req bt_att_read_blob_req, *Pbt_att_read_blob_req; + +struct bt_att_read_blob_req { + u16_t handle; + u16_t offset; +}; + +typedef struct bt_att_find_type_rsp bt_att_find_type_rsp, *Pbt_att_find_type_rsp; + +struct bt_att_find_type_rsp { // Missing member list : bt_att_handle_group[1] at offset 0x0 [Unsupported interior flex array: bt_att_handle_group[1]] +}; + +typedef struct bt_att_notify bt_att_notify, *Pbt_att_notify; + +struct bt_att_notify { + u16_t handle; + u8_t[0] value; +}; + +typedef struct bt_att_exchange_mtu_rsp bt_att_exchange_mtu_rsp, *Pbt_att_exchange_mtu_rsp; + +struct bt_att_exchange_mtu_rsp { + u16_t mtu; +}; + +typedef struct bt_att_read_type_req bt_att_read_type_req, *Pbt_att_read_type_req; + +struct bt_att_read_type_req { + u16_t start_handle; + u16_t end_handle; + u8_t[0] uuid; +}; + +typedef struct bt_att_find_type_req bt_att_find_type_req, *Pbt_att_find_type_req; + +struct bt_att_find_type_req { + u16_t start_handle; + u16_t end_handle; + u16_t type; + u8_t[0] value; +}; + +typedef struct bt_att_exec_write_req bt_att_exec_write_req, *Pbt_att_exec_write_req; + +struct bt_att_exec_write_req { + u8_t flags; +}; + +typedef struct bt_att_indicate bt_att_indicate, *Pbt_att_indicate; + +struct bt_att_indicate { + u16_t handle; + u8_t[0] value; +}; + +typedef struct led_trigger_item led_trigger_item, *Pled_trigger_item; + +typedef struct loop_timer loop_timer, *Ploop_timer; + +typedef struct loop_ctx loop_ctx, *Ploop_ctx; + +typedef struct utils_list utils_list, *Putils_list; + +typedef struct loop_evt_handler_statistic loop_evt_handler_statistic, *Ploop_evt_handler_statistic; + +typedef struct loop_evt_handler loop_evt_handler, *Ploop_evt_handler; + +typedef struct loop_msg loop_msg, *Ploop_msg; + + +// WARNING! conflicting data type names: /DWARF/bloop.h/loop_msg/anon_union_for_u - /DWARF/gatt.c/gatt_find_info_rsp/anon_union_for_u + +struct loop_timer { + utils_dlist_t dlist_item; + uint8_t flags; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + uint time_added; + uint time_target; + int idx_task; + uint32_t evt_type_map; + void (* cb)(struct loop_ctx *, struct loop_timer *, void *); + void * arg; +}; + +struct led_trigger_item { + utils_dlist_t dlist_item; + struct loop_timer timer; + int type; + int pin; + int active; + int current_val; +}; + +struct utils_list { + struct utils_list_hdr * first; + struct utils_list_hdr * last; +}; + +struct loop_evt_handler { + char * name; + int (* evt)(struct loop_ctx *, struct loop_evt_handler *, uint32_t *, uint32_t *); + int (* handle)(struct loop_ctx *, struct loop_evt_handler *, struct loop_msg *); +}; + +struct loop_evt_handler_statistic { + uint time_max; + uint time_consumed; + uint time_accumulated; + uint count_triggered; +}; + +struct loop_ctx { + TaskHandle_t looper; + uint32_t bitmap_evt_async; + uint32_t bitmap_evt_sync; + uint32_t bitmap_msg; + uint32_t evt_type_map_async[32]; + uint32_t evt_type_map_sync[32]; + struct utils_list list[32]; + struct loop_evt_handler_statistic statistic[32]; + struct loop_evt_handler * handlers[32]; + utils_dlist_t timer_dlist; + utils_dlist_t timer_dued; +}; + +struct loop_msg { + struct utils_list_hdr item; + union anon_union_for_u u; + void * arg1; + void * arg2; + uint time_added; + uint time_consumed; +}; + +typedef struct led_trigger_ctx led_trigger_ctx, *Pled_trigger_ctx; + +struct led_trigger_ctx { + utils_dlist_t trigger_queue; + utils_dlist_t waiting_queue; +}; + +typedef struct loop_evt_handler_holder loop_evt_handler_holder, *Ploop_evt_handler_holder; + +struct loop_evt_handler_holder { + struct loop_evt_handler handler; + struct led_trigger_ctx * ctx; +}; + +typedef struct rijndael_ctx rijndael_ctx, *Prijndael_ctx; + +struct rijndael_ctx { + int decrypt; + int Nr; + u32 key[60]; +}; + +typedef void * MessageBufferHandle_t; + +typedef enum hostapd_state_tag { + HOSTAPD_STATE_IDLE=0, + HOSTAPD_STATE_MAX=1 +} hostapd_state_tag; + +typedef enum co_error { + CO_ERROR_ACL_CON_EXISTS=11, + CO_ERROR_AUTH_FAILURE=5, + CO_ERROR_CCA_REJ_USE_CLOCK_DRAG=64, + CO_ERROR_CHANNEL_CLASS_NOT_SUP=46, + CO_ERROR_COMMAND_DISALLOWED=12, + CO_ERROR_CONN_ACCEPT_TIMEOUT_EXCEED=16, + CO_ERROR_CONN_FAILED_TO_BE_EST=62, + CO_ERROR_CONN_REJ_LIMITED_RESOURCES=13, + CO_ERROR_CONN_REJ_SECURITY_REASONS=14, + CO_ERROR_CONN_REJ_UNACCEPTABLE_BDADDR=15, + CO_ERROR_CONTROLLER_BUSY=58, + CO_ERROR_CON_LIMIT_EXCEED=9, + CO_ERROR_CON_TERM_BY_LOCAL_HOST=22, + CO_ERROR_CON_TIMEOUT=8, + CO_ERROR_DIFF_TRANSACTION_COLLISION=42, + CO_ERROR_DIRECT_ADV_TO=60, + CO_ERROR_EIR_TOO_LARGE=54, + CO_ERROR_ENC_MODE_NOT_ACCEPT=37, + CO_ERROR_HARDWARE_FAILURE=3, + CO_ERROR_HOST_BUSY_PAIRING=56, + CO_ERROR_HW_MEM_ALLOC_FAIL=1, + CO_ERROR_HW_UART_OUT_OF_SYNC=0, + CO_ERROR_INSTANT_PASSED=40, + CO_ERROR_INSUFFICIENT_SECURITY=47, + CO_ERROR_INVALID_HCI_PARAM=18, + CO_ERROR_INVALID_LMP_PARAM=30, + CO_ERROR_LIMIT_REACHED=67, + CO_ERROR_LINK_KEY_CANT_CHANGE=38, + CO_ERROR_LMP_COLLISION=35, + CO_ERROR_LMP_PDU_NOT_ALLOWED=36, + CO_ERROR_LMP_RSP_TIMEOUT=34, + CO_ERROR_MEMORY_CAPA_EXCEED=7, + CO_ERROR_NO_ERROR=0, + CO_ERROR_OP_CANCELL_BY_HOST=68, + CO_ERROR_PAGE_TIMEOUT=4, + CO_ERROR_PAIRING_NOT_ALLOWED=24, + CO_ERROR_PAIRING_WITH_UNIT_KEY_NOT_SUP=41, + CO_ERROR_PARAM_OUT_OF_MAND_RANGE=48, + CO_ERROR_PIN_MISSING=6, + CO_ERROR_QOS_NOT_SUPPORTED=39, + CO_ERROR_QOS_REJECTED=45, + CO_ERROR_QOS_UNACCEPTABLE_PARAM=44, + CO_ERROR_REMOTE_DEV_POWER_OFF=21, + CO_ERROR_REMOTE_DEV_TERM_LOW_RESOURCES=20, + CO_ERROR_REMOTE_USER_TERM_CON=19, + CO_ERROR_REPEATED_ATTEMPTS=23, + CO_ERROR_RESERVED_SLOT_VIOLATION=52, + CO_ERROR_ROLE_CHANGE_NOT_ALLOWED=33, + CO_ERROR_ROLE_SWITCH_FAIL=53, + CO_ERROR_ROLE_SWITCH_PEND=50, + CO_ERROR_SCO_AIR_MODE_REJECTED=29, + CO_ERROR_SCO_INTERVAL_REJECTED=28, + CO_ERROR_SCO_OFFSET_REJECTED=27, + CO_ERROR_SP_NOT_SUPPORTED_HOST=55, + CO_ERROR_SYNC_CON_LIMIT_DEV_EXCEED=10, + CO_ERROR_TERMINATED_MIC_FAILURE=61, + CO_ERROR_UNACCEPTABLE_CONN_INT=59, + CO_ERROR_UNDEFINED=-1, + CO_ERROR_UNKNOWN_CONNECTION_ID=2, + CO_ERROR_UNKNOWN_HCI_COMMAND=1, + CO_ERROR_UNKNOWN_LMP_PDU=25, + CO_ERROR_UNKNOW_ADV_ID=66, + CO_ERROR_UNSPECIFIED_ERROR=31, + CO_ERROR_UNSUPPORTED=17, + CO_ERROR_UNSUPPORTED_LMP_PARAM_VALUE=32, + CO_ERROR_UNSUPPORTED_REMOTE_FEATURE=26 +} co_error; + +typedef void (* tcpip_init_done_fn)(void *); + +typedef struct lwip_socket_multicast_pair lwip_socket_multicast_pair, *Plwip_socket_multicast_pair; + +typedef struct lwip_sock lwip_sock, *Plwip_sock; + +typedef union lwip_sock_lastdata lwip_sock_lastdata, *Plwip_sock_lastdata; + +union lwip_sock_lastdata { + struct netbuf * netbuf; + struct pbuf * pbuf; +}; + +struct lwip_sock { + struct netconn * conn; + union lwip_sock_lastdata lastdata; + s16_t rcvevent; + u16_t sendevent; + u16_t errevent; + u8_t select_waiting; + undefined field_0xf; +}; + +struct lwip_socket_multicast_pair { + struct lwip_sock * sock; + ip4_addr_t if_addr; + ip4_addr_t multi_addr; +}; + +typedef enum lwip_pollscan_opts { + LWIP_POLLSCAN_CLEAR=1, + LWIP_POLLSCAN_DEC_WAIT=4, + LWIP_POLLSCAN_INC_WAIT=2 +} lwip_pollscan_opts; + +typedef union sockaddr_aligned sockaddr_aligned, *Psockaddr_aligned; + +typedef struct sockaddr_in sockaddr_in, *Psockaddr_in; + +typedef struct in_addr in_addr, *Pin_addr; + +struct in_addr { + in_addr_t s_addr; +}; + +struct sockaddr_in { + u8_t sin_len; + sa_family_t sin_family; + in_port_t sin_port; + struct in_addr sin_addr; + char sin_zero[8]; +}; + +union sockaddr_aligned { + struct sockaddr sa; + struct sockaddr_in sin; +}; + +typedef struct Bl_SHA1_CTX Bl_SHA1_CTX, *PBl_SHA1_CTX; + +struct Bl_SHA1_CTX { + UINT32 Intermediate_Hash[5]; + UINT32 Length_Low; + UINT32 Length_High; + UINT32 Scratch[16]; + UINT8 Message_Block[64]; + SINT16 Message_Block_Index; + UINT8 Computed; + UINT8 Corrupted; +}; + +typedef struct mbedtls_sha1_context mbedtls_sha1_context, *Pmbedtls_sha1_context; + +struct mbedtls_sha1_context { + uint32_t total[2]; + uint32_t state[5]; + uchar buffer[64]; +}; + +typedef struct ip_mreq ip_mreq, *Pip_mreq; + +struct ip_mreq { + struct in_addr imr_multiaddr; + struct in_addr imr_interface; +}; + +typedef struct ifreq ifreq, *Pifreq; + +struct ifreq { + char ifr_name[6]; +}; + +typedef struct sockaddr_storage sockaddr_storage, *Psockaddr_storage; + +struct sockaddr_storage { + u8_t s2_len; + sa_family_t ss_family; + char s2_data1[2]; + u32_t s2_data2[3]; +}; + +typedef struct iovec iovec, *Piovec; + +struct iovec { + void * iov_base; + size_t iov_len; +}; + +typedef struct msghdr msghdr, *Pmsghdr; + +struct msghdr { + void * msg_name; + socklen_t msg_namelen; + struct iovec * msg_iov; + int msg_iovlen; + void * msg_control; + socklen_t msg_controllen; + int msg_flags; +}; + +typedef uint nfds_t; + +typedef struct mm_env_tag mm_env_tag, *Pmm_env_tag; + +struct mm_env_tag { + uint32_t rx_filter_umac; + uint32_t rx_filter_lmac_enable; + uint16_t ampdu_max_dur[5]; + uint8_t prev_mm_state; + uint8_t prev_hw_state; + uint32_t basic_rates[2]; + uint32_t uapsd_timeout; + uint16_t lp_clk_accuracy; + uint8_t host_idle; + _Bool keep_alive_status_enabled; + uint32_t keep_alive_packet_counter; + uint32_t keep_alive_time_last_received; +}; + +typedef enum mm_features { + MM_FEAT_AMPDU_BIT=9, + MM_FEAT_AMSDU_BIT=10, + MM_FEAT_AUTOBCN_BIT=1, + MM_FEAT_BCN_BIT=0, + MM_FEAT_BFMEE_BIT=17, + MM_FEAT_BFMER_BIT=18, + MM_FEAT_CHNL_CTXT_BIT=11, + MM_FEAT_CMON_BIT=3, + MM_FEAT_DPSM_BIT=8, + MM_FEAT_HWSCAN_BIT=2, + MM_FEAT_MESH_BIT=23, + MM_FEAT_MFP_BIT=20, + MM_FEAT_MROLE_BIT=4, + MM_FEAT_MU_MIMO_RX_BIT=21, + MM_FEAT_MU_MIMO_TX_BIT=22, + MM_FEAT_P2P_BIT=13, + MM_FEAT_P2P_GO_BIT=14, + MM_FEAT_PS_BIT=6, + MM_FEAT_RADAR_BIT=5, + MM_FEAT_REORD_BIT=12, + MM_FEAT_TDLS_BIT=24, + MM_FEAT_UAPSD_BIT=7, + MM_FEAT_UMAC_BIT=15, + MM_FEAT_VHT_BIT=16, + MM_FEAT_WAPI_BIT=19 +} mm_features; + +typedef enum ea_elt_asap_type { + EA_FLAG_ASAP_LIMIT=2, + EA_FLAG_ASAP_NO_LIMIT=1, + EA_FLAG_MAX=3, + EA_FLAG_NO_ASAP=0 +} ea_elt_asap_type; + +typedef enum ea_param_req_action { + EA_PARAM_REQ_CHECK=1, + EA_PARAM_REQ_GET=0 +} ea_param_req_action; + +typedef struct ea_param_input ea_param_input, *Pea_param_input; + +struct ea_param_input { + uint16_t interval_min; + uint16_t interval_max; + uint32_t duration_min; + uint16_t duration_max; + uint8_t pref_period; + undefined field_0xb; + uint16_t offset; + uint8_t action; + undefined field_0xf; + uint16_t conhdl; + uint16_t role; + _Bool odd_offset; + undefined field_0x15; + uint16_t linkid; +}; + +typedef struct ea_param_output ea_param_output, *Pea_param_output; + +struct ea_param_output { + uint16_t interval; + undefined field_0x2; + undefined field_0x3; + uint32_t duration; + uint16_t offset; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct ea_interval_tag ea_interval_tag, *Pea_interval_tag; + +struct ea_interval_tag { + struct co_list_hdr hdr; + uint16_t interval_used; + uint16_t offset_used; + uint16_t bandwidth_used; + uint16_t conhdl_used; + uint16_t role_used; + uint16_t linkid; +}; + +typedef enum ea_error { + EA_ERROR_BW_FULL=3, + EA_ERROR_NOT_FOUND=2, + EA_ERROR_OK=0, + EA_ERROR_REJECTED=1 +} ea_error; + +typedef enum ea_elt_asap_parity { + EA_EVEN_SLOT=0, + EA_NO_PARITY=2, + EA_ODD_SLOT=1 +} ea_elt_asap_parity; + +typedef struct ea_env_tag ea_env_tag, *Pea_env_tag; + +struct ea_env_tag { + struct co_list elt_wait; + struct ea_elt_tag * elt_prog; + struct co_list elt_canceled; + struct co_list interval_list; + uint32_t finetarget_time; +}; + +typedef enum ea_conflict { + START_AFTER_END_AFTER=5, + START_BEFORE_END_AFTER=2, + START_BEFORE_END_BEFORE=0, + START_BEFORE_END_DURING=1, + START_DURING_END_AFTER=4, + START_DURING_END_DURING=3 +} ea_conflict; + +typedef enum rwip_prio_dft { + RWIP_PRIO_ADV_DFT=5, + RWIP_PRIO_ADV_HDC_DFT=10, + RWIP_PRIO_INIT_DFT=5, + RWIP_PRIO_LE_CON_ACT_DFT=15, + RWIP_PRIO_LE_CON_IDLE_DFT=10, + RWIP_PRIO_LE_ESTAB_DFT=20, + RWIP_PRIO_MAX=31, + RWIP_PRIO_SCAN_DFT=5 +} rwip_prio_dft; + +typedef enum rwip_coex_config_idx { + RWIP_COEX_ADV_IDX=2, + RWIP_COEX_CFG_MAX=5, + RWIP_COEX_CON_DATA_IDX=1, + RWIP_COEX_CON_IDX=0, + RWIP_COEX_INIT_IDX=4, + RWIP_COEX_SCAN_IDX=3 +} rwip_coex_config_idx; + +typedef enum rwip_incr_dft { + RWIP_INCR_ADV_DFT=1, + RWIP_INCR_ADV_HDC_PRIO_DFT=1, + RWIP_INCR_INIT_DFT=1, + RWIP_INCR_LE_CON_ACT_DFT=11, + RWIP_INCR_LE_CON_IDLE_DFT=1, + RWIP_INCR_LE_ESTAB_DFT=1, + RWIP_INCR_SCAN_DFT=1 +} rwip_incr_dft; + +typedef enum KE_EVENT_TYPE { + KE_EVENT_BLE_CRYPT=1, + KE_EVENT_BLE_EVT_DEFER=8, + KE_EVENT_BLE_EVT_DELETE=9, + KE_EVENT_BT_PSCAN_PROC=7, + KE_EVENT_ECC_MULTIPLICATION=0, + KE_EVENT_H4TL_CMD_HDR_RX=5, + KE_EVENT_H4TL_CMD_PLD_RX=6, + KE_EVENT_H4TL_TX=4, + KE_EVENT_KE_MESSAGE=2, + KE_EVENT_KE_TIMER=3, + KE_EVENT_MAX=10 +} KE_EVENT_TYPE; + +typedef enum rwip_prio_idx { + RWIP_PRIO_ADV_HDC_IDX=6, + RWIP_PRIO_ADV_IDX=5, + RWIP_PRIO_IDX_MAX=7, + RWIP_PRIO_INIT_IDX=1, + RWIP_PRIO_LE_CON_ACT_IDX=4, + RWIP_PRIO_LE_CON_IDLE_IDX=3, + RWIP_PRIO_LE_ESTAB_IDX=2, + RWIP_PRIO_SCAN_IDX=0 +} rwip_prio_idx; + +typedef enum KE_TASK_TYPE { + TASK_DBG=3, + TASK_HCI_ONCHIP=4, + TASK_LLC=1, + TASK_LLD=2, + TASK_LLM=0, + TASK_MAX=5, + TASK_NONE=-1 +} KE_TASK_TYPE; + +typedef struct bt_l2cap_le_chan.conflict1 bt_l2cap_le_chan.conflict1, *Pbt_l2cap_le_chan.conflict1; + +typedef struct bt_l2cap_chan.conflict2 bt_l2cap_chan.conflict2, *Pbt_l2cap_chan.conflict2; + +struct bt_l2cap_chan.conflict2 { + struct bt_conn * conn; + struct bt_l2cap_chan_ops * ops; + sys_snode_t node; + void (* destroy)(struct bt_l2cap_chan *); + struct k_delayed_work.conflict rtx_work; + atomic_t status[1]; + bt_l2cap_chan_state_t state; + undefined field_0x39; + u16_t psm; + u8_t ident; + enum bt_security_t required_sec_level; + undefined field_0x3e; + undefined field_0x3f; +}; + +struct bt_l2cap_le_chan.conflict1 { + struct bt_l2cap_chan.conflict2 chan; + struct bt_l2cap_le_endpoint rx; + struct bt_l2cap_le_endpoint tx; + struct k_fifo tx_queue; + struct net_buf * tx_buf; + struct net_buf * _sdu; + u16_t _sdu_len; + undefined field_0x7e; + undefined field_0x7f; + struct k_work rx_work; + struct k_fifo rx_queue; +}; + +typedef struct bt_l2cap_le_chan.conflict2 bt_l2cap_le_chan.conflict2, *Pbt_l2cap_le_chan.conflict2; + +typedef struct bt_l2cap_chan.conflict3 bt_l2cap_chan.conflict3, *Pbt_l2cap_chan.conflict3; + +struct bt_l2cap_chan.conflict3 { + struct bt_conn * conn; + struct bt_l2cap_chan_ops * ops; + sys_snode_t node; + void (* destroy)(struct bt_l2cap_chan *); + struct k_delayed_work.conflict rtx_work; + atomic_t status[1]; + bt_l2cap_chan_state_t state; + undefined field_0x39; + u16_t psm; + u8_t ident; + enum bt_security_t required_sec_level; + undefined field_0x3e; + undefined field_0x3f; +}; + +struct bt_l2cap_le_chan.conflict2 { + struct bt_l2cap_chan.conflict3 chan; + struct bt_l2cap_le_endpoint rx; + struct bt_l2cap_le_endpoint tx; + struct k_fifo tx_queue; + struct net_buf * tx_buf; + struct net_buf * _sdu; + u16_t _sdu_len; + undefined field_0x7e; + undefined field_0x7f; + struct k_work rx_work; + struct k_fifo rx_queue; +}; + +typedef enum bt_l2cap_chan_status { + BT_L2CAP_NUM_STATUS=1, + BT_L2CAP_STATUS_OUT=0 +} bt_l2cap_chan_status; + +typedef struct bt_l2cap_chan.conflict bt_l2cap_chan.conflict, *Pbt_l2cap_chan.conflict; + +struct bt_l2cap_chan.conflict { + struct bt_conn * conn; + struct bt_l2cap_chan_ops * ops; + sys_snode_t node; + void (* destroy)(struct bt_l2cap_chan *); + struct k_delayed_work.conflict rtx_work; + atomic_t status[1]; + bt_l2cap_chan_state_t state; + undefined field_0x39; + u16_t psm; + u8_t ident; + enum bt_security_t required_sec_level; + undefined field_0x3e; + undefined field_0x3f; +}; + +typedef struct bt_l2cap_chan.conflict1 bt_l2cap_chan.conflict1, *Pbt_l2cap_chan.conflict1; + +struct bt_l2cap_chan.conflict1 { + struct bt_conn * conn; + struct bt_l2cap_chan_ops * ops; + sys_snode_t node; + void (* destroy)(struct bt_l2cap_chan *); + struct k_delayed_work.conflict rtx_work; + atomic_t status[1]; + bt_l2cap_chan_state_t state; + undefined field_0x39; + u16_t psm; + u8_t ident; + enum bt_security_t required_sec_level; + undefined field_0x3e; + undefined field_0x3f; +}; + +typedef struct bt_l2cap_le_chan.conflict bt_l2cap_le_chan.conflict, *Pbt_l2cap_le_chan.conflict; + +struct bt_l2cap_le_chan.conflict { + struct bt_l2cap_chan.conflict1 chan; + struct bt_l2cap_le_endpoint rx; + struct bt_l2cap_le_endpoint tx; + struct k_fifo tx_queue; + struct net_buf * tx_buf; + struct net_buf * _sdu; + u16_t _sdu_len; + undefined field_0x7e; + undefined field_0x7f; + struct k_work rx_work; + struct k_fifo rx_queue; +}; + +typedef struct bt_l2cap_server bt_l2cap_server, *Pbt_l2cap_server; + +struct bt_l2cap_server { + u16_t psm; + enum bt_security_t sec_level; + undefined field_0x3; + int (* accept)(struct bt_conn *, struct bt_l2cap_chan * *); + sys_snode_t node; +}; + +typedef struct bt_l2cap bt_l2cap, *Pbt_l2cap; + +struct bt_l2cap { + struct bt_l2cap_le_chan chan; +}; + +typedef struct utils_notifier utils_notifier, *Putils_notifier; + +struct utils_notifier { + struct utils_list_hdr node; + int (* cb)(void *, void *); + void * cb_arg; + int priority; +}; + +typedef struct utils_list ntf_list_t; + +typedef struct utils_notifier utils_notifier_t; + +typedef struct Ring_Buffer_Type Ring_Buffer_Type, *PRing_Buffer_Type; + +struct Ring_Buffer_Type { + uint8_t * pointer; + uint8_t readMirror; + undefined field_0x5; + uint16_t readIndex; + uint8_t writeMirror; + undefined field_0x9; + uint16_t writeIndex; + uint16_t size; + undefined field_0xe; + undefined field_0xf; + void (* lock)(void); + void (* unlock)(void); +}; + +typedef union anon_union.conflict175 anon_union.conflict175, *Panon_union.conflict175; + +union anon_union.conflict175 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict58 anon_union.conflict58, *Panon_union.conflict58; + +union anon_union.conflict58 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict72 anon_union.conflict72, *Panon_union.conflict72; + +union anon_union.conflict72 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict161 anon_union.conflict161, *Panon_union.conflict161; + +union anon_union.conflict161 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict65 anon_union.conflict65, *Panon_union.conflict65; + +union anon_union.conflict65 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict168 anon_union.conflict168, *Panon_union.conflict168; + +union anon_union.conflict168 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict122 anon_union.conflict122, *Panon_union.conflict122; + +union anon_union.conflict122 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict27 anon_union.conflict27, *Panon_union.conflict27; + +union anon_union.conflict27 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict115 anon_union.conflict115, *Panon_union.conflict115; + +union anon_union.conflict115 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict34 anon_union.conflict34, *Panon_union.conflict34; + +union anon_union.conflict34 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict79 anon_union.conflict79, *Panon_union.conflict79; + +union anon_union.conflict79 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict149 anon_union.conflict149, *Panon_union.conflict149; + +union anon_union.conflict149 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict106 anon_union.conflict106, *Panon_union.conflict106; + +union anon_union.conflict106 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict93 anon_union.conflict93, *Panon_union.conflict93; + +union anon_union.conflict93 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict86 anon_union.conflict86, *Panon_union.conflict86; + +union anon_union.conflict86 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict189 anon_union.conflict189, *Panon_union.conflict189; + +union anon_union.conflict189 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict100 anon_union.conflict100, *Panon_union.conflict100; + +union anon_union.conflict100 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict48 anon_union.conflict48, *Panon_union.conflict48; + +union anon_union.conflict48 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict181 anon_union.conflict181, *Panon_union.conflict181; + +union anon_union.conflict181 { + uint8_t ht[4]; +}; + +typedef struct udp_hdr udp_hdr, *Pudp_hdr; + +struct udp_hdr { + u16_t src; + u16_t dest; + u16_t len; + u16_t chksum; +}; + +typedef enum lld_ch_asses_ponderation { + LLD_CH_ASSES_CRC_ERR=-3, + LLD_CH_ASSES_SYNC_ERR_HIGH_RSSI=-3, + LLD_CH_ASSES_SYNC_ERR_LOW_RSSI_LATENCY=0, + LLD_CH_ASSES_SYNC_ERR_LOW_RSSI_NO_LATENCY=-1, + LLD_CH_ASSES_SYNC_FOUND_NO_CRC_ERR=3 +} lld_ch_asses_ponderation; + +typedef enum HCI_TX_STATE { + HCI_STATE_TX_IDLE=1, + HCI_STATE_TX_ONGOING=0 +} HCI_TX_STATE; + +typedef struct hci_tl_env_tag hci_tl_env_tag, *Phci_tl_env_tag; + +struct hci_tl_env_tag { + struct co_list tx_queue; + struct co_list acl_queue; + struct ke_msg * curr_tx_msg; + struct em_buf_node * txtag; + uint8_t tx_state; + int8_t nb_h2c_cmd_pkts; + undefined field_0x1a; + undefined field_0x1b; +}; + +typedef struct _bl_sha_SEC_Eng_SHA256_Ctx_t _bl_sha_SEC_Eng_SHA256_Ctx_t, *P_bl_sha_SEC_Eng_SHA256_Ctx_t; + +struct _bl_sha_SEC_Eng_SHA256_Ctx_t { + uint32_t total[2]; + uint32_t * shaBuf; + uint32_t * shaPadding; + uint8_t shaFeed; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; +}; + +typedef enum bl_sha_type_t { + BL_SHA1=2, + BL_SHA224=1, + BL_SHA256=0 +} bl_sha_type_t; + +typedef struct bl_sha_ctx bl_sha_ctx, *Pbl_sha_ctx; + +struct bl_sha_ctx { + struct _bl_sha_SEC_Eng_SHA256_Ctx_t sha_ctx; + uint32_t tmp[16]; + uint32_t pad[16]; +}; + +typedef struct bl_sha_ctx bl_sha_ctx_t; + +typedef struct anon_struct.conflict1 anon_struct.conflict1, *Panon_struct.conflict1; + +struct anon_struct.conflict1 { + uint8_t priority; + uint8_t id_dst; + uint8_t id_msg; + uint8_t id_src; +}; + +typedef union anon_union.conflict2 anon_union.conflict2, *Panon_union.conflict2; + +union anon_union.conflict2 { + void * container; + struct anon_struct.conflict1 header; +}; + +typedef struct anon_struct.conflict532 anon_struct.conflict532, *Panon_struct.conflict532; + +struct anon_struct.conflict532 { + uint8_t priority; + uint8_t id_dst; + uint8_t id_msg; + uint8_t id_src; +}; + +typedef struct anon_struct.conflict577 anon_struct.conflict577, *Panon_struct.conflict577; + +struct anon_struct.conflict577 { + uint8_t priority; + uint8_t id_dst; + uint8_t id_msg; + uint8_t id_src; +}; + +typedef struct anon_struct.conflict578 anon_struct.conflict578, *Panon_struct.conflict578; + +struct anon_struct.conflict578 { + uint8_t priority; + uint8_t id_dst; + uint8_t id_msg; + uint8_t id_src; +}; + +typedef struct anon_struct.conflict531 anon_struct.conflict531, *Panon_struct.conflict531; + +struct anon_struct.conflict531 { + uint8_t priority; + uint8_t id_dst; + uint8_t id_msg; + uint8_t id_src; +}; + +typedef union anon_union.conflict8 anon_union.conflict8, *Panon_union.conflict8; + +union anon_union.conflict8 { + void * pvDummy2; + UBaseType_t uxDummy2; +}; + +typedef enum lld_evt_defer_type { + LLD_DEFER_CON_UP_INSTANT=3, + LLD_DEFER_END=1, + LLD_DEFER_MAP_UP_INSTANT=4, + LLD_DEFER_MAX=5, + LLD_DEFER_RX=0, + LLD_DEFER_TEST_END=2 +} lld_evt_defer_type; + +typedef enum CFG_ELEMENT_TYPE { + CFG_ELEMENT_TYPE_BOOLEAN=1, + CFG_ELEMENT_TYPE_SINT16=4, + CFG_ELEMENT_TYPE_SINT32=6, + CFG_ELEMENT_TYPE_SINT8=2, + CFG_ELEMENT_TYPE_STRING=8, + CFG_ELEMENT_TYPE_UINT16=5, + CFG_ELEMENT_TYPE_UINT32=7, + CFG_ELEMENT_TYPE_UINT8=3, + CFG_ELEMENT_TYPE_UNKNOWN=0 +} CFG_ELEMENT_TYPE; + +typedef enum ADC_Data_Width_Type { + ADC_DATA_WIDTH_12=0, + ADC_DATA_WIDTH_14_WITH_16_AVERAGE=1, + ADC_DATA_WIDTH_16_WITH_128_AVERAGE=3, + ADC_DATA_WIDTH_16_WITH_256_AVERAGE=4, + ADC_DATA_WIDTH_16_WITH_64_AVERAGE=2 +} ADC_Data_Width_Type; + +typedef enum ADC_Chan_Type { + ADC_CHAN0=0, + ADC_CHAN1=1, + ADC_CHAN10=10, + ADC_CHAN11=11, + ADC_CHAN2=2, + ADC_CHAN3=3, + ADC_CHAN4=4, + ADC_CHAN5=5, + ADC_CHAN6=6, + ADC_CHAN7=7, + ADC_CHAN8=8, + ADC_CHAN9=9, + ADC_CHAN_DAC_OUTA=12, + ADC_CHAN_DAC_OUTB=13, + ADC_CHAN_DCTEST=17, + ADC_CHAN_GND=23, + ADC_CHAN_SENP0=22, + ADC_CHAN_SENP1=21, + ADC_CHAN_SENP2=20, + ADC_CHAN_SENP3=19, + ADC_CHAN_TSEN_N=15, + ADC_CHAN_TSEN_P=14, + ADC_CHAN_VABT_HALF=18, + ADC_CHAN_VREF=16 +} ADC_Chan_Type; + +typedef enum ADC_INT_Type { + ADC_INT_ADC_READY=4, + ADC_INT_ALL=5, + ADC_INT_FIFO_OVERRUN=3, + ADC_INT_FIFO_UNDERRUN=2, + ADC_INT_NEG_SATURATION=1, + ADC_INT_POS_SATURATION=0 +} ADC_INT_Type; + +typedef struct ADC_Result_Type ADC_Result_Type, *PADC_Result_Type; + +struct ADC_Result_Type { + int8_t posChan; + int8_t negChan; + uint16_t value; + float volt; +}; + +typedef enum ADC_V18_SEL_Type { + ADC_V18_SEL_1P62V=0, + ADC_V18_SEL_1P72V=1, + ADC_V18_SEL_1P82V=2, + ADC_V18_SEL_1P92V=3 +} ADC_V18_SEL_Type; + +typedef enum ADC_PGA_GAIN_Type { + ADC_PGA_GAIN_1=1, + ADC_PGA_GAIN_16=5, + ADC_PGA_GAIN_2=2, + ADC_PGA_GAIN_32=6, + ADC_PGA_GAIN_4=3, + ADC_PGA_GAIN_8=4, + ADC_PGA_GAIN_NONE=0 +} ADC_PGA_GAIN_Type; + +typedef struct ADC_CFG_Type ADC_CFG_Type, *PADC_CFG_Type; + +typedef enum ADC_V11_SEL_Type { + ADC_V11_SEL_1P0V=0, + ADC_V11_SEL_1P18V=2, + ADC_V11_SEL_1P1V=1, + ADC_V11_SEL_1P26V=3 +} ADC_V11_SEL_Type; + +typedef enum ADC_CLK_Type { + ADC_CLK_DIV_1=0, + ADC_CLK_DIV_12=3, + ADC_CLK_DIV_16=4, + ADC_CLK_DIV_20=5, + ADC_CLK_DIV_24=6, + ADC_CLK_DIV_32=7, + ADC_CLK_DIV_4=1, + ADC_CLK_DIV_8=2 +} ADC_CLK_Type; + +typedef enum ADC_CHOP_MOD_Type { + ADC_CHOP_MOD_ALL_OFF=0, + ADC_CHOP_MOD_AZ_ON=1, + ADC_CHOP_MOD_AZ_PGA_ON=2, + ADC_CHOP_MOD_AZ_PGA_RPC_ON=3 +} ADC_CHOP_MOD_Type; + +typedef enum ADC_BIAS_SEL_Type { + ADC_BIAS_SEL_AON_BANDGAP=1, + ADC_BIAS_SEL_MAIN_BANDGAP=0 +} ADC_BIAS_SEL_Type; + +typedef enum ADC_PGA_VCM_Type { + ADC_PGA_VCM_1P2V=1, + ADC_PGA_VCM_1P4V=2, + ADC_PGA_VCM_1P6V=3, + ADC_PGA_VCM_1V=0 +} ADC_PGA_VCM_Type; + +typedef enum ADC_VREF_Type { + ADC_VREF_2V=1, + ADC_VREF_3P2V=0 +} ADC_VREF_Type; + +typedef enum ADC_SIG_INPUT_Type { + ADC_INPUT_DIFF=1, + ADC_INPUT_SINGLE_END=0 +} ADC_SIG_INPUT_Type; + +struct ADC_CFG_Type { + enum ADC_V18_SEL_Type v18Sel; + enum ADC_V11_SEL_Type v11Sel; + enum ADC_CLK_Type clkDiv; + enum ADC_PGA_GAIN_Type gain1; + enum ADC_PGA_GAIN_Type gain2; + enum ADC_CHOP_MOD_Type chopMode; + enum ADC_BIAS_SEL_Type biasSel; + enum ADC_PGA_VCM_Type vcm; + enum ADC_VREF_Type vref; + enum ADC_SIG_INPUT_Type inputMode; + enum ADC_Data_Width_Type resWidth; + enum BL_Fun_Type offsetCalibEn; + int16_t offsetCalibVal; +}; + +typedef struct ADC_MIC_Type ADC_MIC_Type, *PADC_MIC_Type; + +typedef enum ADC_MICBOOST_DB_Type { + ADC_MICBOOST_DB_16DB=0, + ADC_MICBOOST_DB_32DB=1 +} ADC_MICBOOST_DB_Type; + +typedef enum ADC_PGA2_GAIN_Type { + ADC_PGA2_GAIN_0DB=0, + ADC_PGA2_GAIN_12DB=3, + ADC_PGA2_GAIN_6DB=1, + ADC_PGA2_GAIN_N6DB=2 +} ADC_PGA2_GAIN_Type; + +typedef enum ADC_MIC_MODE_Type { + ADC_MIC_MODE_DIFF=1, + ADC_MIC_MODE_SINGLE=0 +} ADC_MIC_MODE_Type; + +struct ADC_MIC_Type { + enum ADC_MICBOOST_DB_Type micboostDb; + enum ADC_PGA2_GAIN_Type micPga2Gain; + enum ADC_MIC_MODE_Type mic1Mode; + enum ADC_MIC_MODE_Type mic2Mode; + enum BL_Fun_Type dwaEn; + enum BL_Fun_Type micboostBypassEn; + enum BL_Fun_Type micPgaEn; + enum BL_Fun_Type micBiasEn; +}; + +typedef struct ADC_Gain_Coeff_Type ADC_Gain_Coeff_Type, *PADC_Gain_Coeff_Type; + +struct ADC_Gain_Coeff_Type { + enum BL_Fun_Type adcGainCoeffEnable; + undefined field_0x1; + uint16_t adcgainCoeffVal; + float coe; +}; + +typedef enum ADC_TSEN_MOD_Type { + ADC_TSEN_MOD_EXTERNAL_DIODE=1, + ADC_TSEN_MOD_INTERNAL_DIODE=0 +} ADC_TSEN_MOD_Type; + +typedef struct ADC_FIFO_Cfg_Type ADC_FIFO_Cfg_Type, *PADC_FIFO_Cfg_Type; + +typedef enum ADC_FIFO_Threshold_Type { + ADC_FIFO_THRESHOLD_1=0, + ADC_FIFO_THRESHOLD_16=3, + ADC_FIFO_THRESHOLD_4=1, + ADC_FIFO_THRESHOLD_8=2 +} ADC_FIFO_Threshold_Type; + +struct ADC_FIFO_Cfg_Type { + enum ADC_FIFO_Threshold_Type fifoThreshold; + enum BL_Fun_Type dmaEn; +}; + +typedef struct _at_evt _at_evt, *P_at_evt; + +struct _at_evt { + int evt_id; + uint8_t ctx_buf[20]; + uint32_t ctx_size; +}; + +typedef struct at_sever at_sever, *Pat_sever; + +typedef struct at_sever at_sever_t; + +struct at_sever { + int wifi_mode; + uint32_t uart_baud; + int at_serial_fd; + SemaphoreHandle_t at_serial_mtx; + QueueHandle_t xQueue; + uint8_t queue_buf[1024]; +}; + +typedef enum at_evt_t { + AT_ASYNC_DATA_IN=2, + AT_ASYNC_NO_AP_FOUND=4, + AT_ASYNC_PSK_ERROR=3, + AT_ASYNC_WIFI_CONNECTED=1, + AT_BLE_CONNECTED=7, + AT_BLE_DISCONNECTED=8, + AT_WIFI_DISCONNECT=5, + AT_WIFI_IP_GET=9, + AT_WIFI_PRVO_DUMP=6 +} at_evt_t; + +typedef struct bt_bond_info bt_bond_info, *Pbt_bond_info; + +struct bt_bond_info { + struct bt_addr_le_t addr; +}; + +typedef struct bt_le_adv_param bt_le_adv_param, *Pbt_le_adv_param; + +struct bt_le_adv_param { + u8_t id; + u8_t options; + u16_t interval_min; + u16_t interval_max; +}; + +typedef struct bt_le_scan_param bt_le_scan_param, *Pbt_le_scan_param; + +struct bt_le_scan_param { + u8_t type; + u8_t filter_dup; + u16_t interval; + u16_t window; +}; + +typedef struct bt_le_oob bt_le_oob, *Pbt_le_oob; + +struct bt_le_oob { + struct bt_addr_le_t addr; + struct bt_le_oob_sc_data le_sc_data; +}; + +typedef struct mem mem, *Pmem; + +struct mem { + mem_size_t next; + mem_size_t prev; + u8_t used; + undefined field_0x5; +}; + +typedef enum lwip_iana_hwtype { + LWIP_IANA_HWTYPE_ETHERNET=1 +} lwip_iana_hwtype; + +typedef enum lwip_iana_port_number { + LWIP_IANA_PORT_DHCP_CLIENT=68, + LWIP_IANA_PORT_DHCP_SERVER=67, + LWIP_IANA_PORT_HTTP=80, + LWIP_IANA_PORT_HTTPS=443, + LWIP_IANA_PORT_MDNS=5353, + LWIP_IANA_PORT_MQTT=1883, + LWIP_IANA_PORT_NETBIOS=-119, + LWIP_IANA_PORT_SECURE_MQTT=8883, + LWIP_IANA_PORT_SMTP=25, + LWIP_IANA_PORT_SMTPS=465, + LWIP_IANA_PORT_SNMP=-95, + LWIP_IANA_PORT_SNMP_TRAP=-94, + LWIP_IANA_PORT_SNTP=123, + LWIP_IANA_PORT_TFTP=69 +} lwip_iana_port_number; + +typedef enum stateM_handleEventRetVals { + stateM_errArg=-2, + stateM_errorStateReached=-1, + stateM_finalStateReached=3, + stateM_noStateChange=2, + stateM_stateChanged=0, + stateM_stateLoopSelf=1 +} stateM_handleEventRetVals; + +typedef struct em_desc_node em_desc_node, *Pem_desc_node; + +struct em_desc_node { + struct co_list_hdr hdr; + uint16_t idx; + uint16_t buffer_idx; + uint16_t buffer_ptr; + uint8_t llid; + uint8_t length; +}; + +typedef struct em_buf_tx_desc em_buf_tx_desc, *Pem_buf_tx_desc; + +struct em_buf_tx_desc { + uint16_t txptr; + uint16_t txheader; + uint16_t txdataptr; + uint16_t txdle; +}; + +typedef struct em_buf_env_tag em_buf_env_tag, *Pem_buf_env_tag; + +struct em_buf_env_tag { + struct co_list tx_desc_free; + struct co_list tx_buff_free; + struct em_desc_node tx_desc_node[26]; + struct em_buf_node tx_buff_node[2]; + struct em_buf_tx_desc * tx_desc; + uint8_t rx_current; + undefined field_0x15d; + undefined field_0x15e; + undefined field_0x15f; +}; + +typedef enum AT_QUEUE_ERROR_CODE { + AQEC_EMPTY=2, + AQEC_FAIL=1, + AQEC_FULL=3, + AQEC_OK=0 +} AT_QUEUE_ERROR_CODE; + +typedef struct at_queue_t at_queue_t, *Pat_queue_t; + +struct at_queue_t { + u8 * qbuf; + s32 qsize; + s32 qcnt; + s32 ridx; + s32 widx; +}; + +typedef struct KDE_t KDE_t, *PKDE_t; + +struct KDE_t { + UINT8 type; + UINT8 length; + UINT8 OUI[3]; + UINT8 dataType; + UINT8 data[1]; +}; + +typedef struct Hdr_8021x_t Hdr_8021x_t, *PHdr_8021x_t; + +struct Hdr_8021x_t { + UINT8 protocol_ver; + enum IEEEtypes_8021x_PacketType_e pckt_type; + UINT16 pckt_body_len; +}; + +typedef struct EAPOL_KeyMsg_t EAPOL_KeyMsg_t, *PEAPOL_KeyMsg_t; + +typedef struct key_info_t key_info_t, *Pkey_info_t; + +struct key_info_t { + UINT16 KeyMIC:1; + UINT16 Secure:1; + UINT16 Error:1; + UINT16 Request:1; + UINT16 EncryptedKeyData:1; + UINT16 Reserved:3; + UINT16 KeyDescriptorVersion:3; + UINT16 KeyType:1; + UINT16 KeyIndex:2; + UINT16 Install:1; + UINT16 KeyAck:1; +}; + +struct EAPOL_KeyMsg_t { + struct Hdr_8021x_t hdr_8021x; + UINT8 desc_type; + struct key_info_t key_info; + UINT16 key_length; + UINT32 replay_cnt[2]; + UINT8 key_nonce[32]; + UINT8 EAPOL_key_IV[16]; + UINT8 key_RSC[8]; + UINT8 key_ID[8]; + UINT8 key_MIC[16]; + UINT16 key_material_len; + UINT8 key_data[1]; +}; + +typedef struct EAPOL_KeyMsg_Tx_t EAPOL_KeyMsg_Tx_t, *PEAPOL_KeyMsg_Tx_t; + +struct EAPOL_KeyMsg_Tx_t { + struct ether_hdr_t ethHdr; + struct EAPOL_KeyMsg_t keyMsg; +}; + +typedef struct EAP_PacketMsg_t EAP_PacketMsg_t, *PEAP_PacketMsg_t; + +struct EAP_PacketMsg_t { + struct Hdr_8021x_t hdr_8021x; + enum IEEEtypes_8021x_CodeType_e code; + UINT8 identifier; + UINT16 length; + UINT8 data[1]; +}; + +typedef struct GTK_KDE_t GTK_KDE_t, *PGTK_KDE_t; + +struct GTK_KDE_t { + UINT8 KeyID:2; + UINT8 Tx:1; + UINT8 rsvd:5; + UINT8 rsvd1; + UINT8 GTK[1]; +}; + +typedef union anon_union.conflict199 anon_union.conflict199, *Panon_union.conflict199; + +union anon_union.conflict199 { + u32_t u32_addr[4]; + u8_t u8_addr[16]; +}; + +typedef struct in6_addr in6_addr, *Pin6_addr; + +typedef union anon_union_for_un anon_union_for_un, *Panon_union_for_un; + +union anon_union_for_un { + u32_t u32_addr[4]; + u8_t u8_addr[16]; +}; + +struct in6_addr { + union anon_union_for_un un; +}; + +typedef union anon_union.conflict1 anon_union.conflict1, *Panon_union.conflict1; + +union anon_union.conflict1 { + u32_t u32_addr[4]; + u8_t u8_addr[16]; +}; + +typedef ulong fd_mask; + +typedef struct _types_fd_set _types_fd_set, *P_types_fd_set; + +struct _types_fd_set { + fd_mask fds_bits[2]; +}; + +typedef struct poll_arg poll_arg, *Ppoll_arg; + +struct poll_arg { + aos_sem_t sem; +}; + +typedef struct getopt_env getopt_env, *Pgetopt_env; + +typedef struct getopt_env getopt_env_t; + +struct getopt_env { + char * optarg; + int optind; + int opterr; + int optopt; + int __optpos; +}; + +typedef struct health_period_param health_period_param, *Phealth_period_param; + +struct health_period_param { + u8_t * divisor; +}; + +typedef struct health_attention_param health_attention_param, *Phealth_attention_param; + +struct health_attention_param { + u8_t * attention; +}; + +typedef struct health_fault_param health_fault_param, *Phealth_fault_param; + +struct health_fault_param { + u16_t cid; + undefined field_0x2; + undefined field_0x3; + u8_t * expect_test_id; + u8_t * test_id; + u8_t * faults; + size_t * fault_count; +}; + +typedef struct supplicantData supplicantData_t; + +typedef struct bt_mesh_health_cli bt_mesh_health_cli, *Pbt_mesh_health_cli; + +struct bt_mesh_health_cli { + struct bt_mesh_model * model; + void (* current_status)(struct bt_mesh_health_cli *, u16_t, u8_t, u16_t, u8_t *, size_t); + struct k_sem op_sync; + u32_t.conflict op_pending; + void * op_param; +}; + +typedef struct wifi_secmode_t.conflict wifi_secmode_t.conflict, *Pwifi_secmode_t.conflict; + +struct wifi_secmode_t.conflict { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +typedef struct wifi_event_data_ind_scan_done wifi_event_data_ind_scan_done, *Pwifi_event_data_ind_scan_done; + +struct wifi_event_data_ind_scan_done { + uint32_t nothing; +}; + +typedef struct wifi_event_sm_connect_ind wifi_event_sm_connect_ind, *Pwifi_event_sm_connect_ind; + +struct wifi_event_sm_connect_ind { + uint16_t status_code; + uint8_t bssid[6]; + uint8_t vif_idx; + uint8_t ap_idx; + uint8_t ch_idx; + undefined field_0xb; + int qos; + uint16_t aid; + uint8_t band; + undefined field_0x13; + uint16_t center_freq; + uint8_t width; + undefined field_0x17; + uint32_t center_freq1; + uint32_t center_freq2; +}; + +typedef struct wifi_cipher_t.conflict23 wifi_cipher_t.conflict23, *Pwifi_cipher_t.conflict23; + +struct wifi_cipher_t.conflict23 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_apm_sta_info wifi_apm_sta_info, *Pwifi_apm_sta_info; + +struct wifi_apm_sta_info { + uint8_t sta_idx; + uint8_t is_used; + uint8_t sta_mac[6]; + uint32_t tsfhi; + uint32_t tsflo; + int rssi; + uint8_t data_rate; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct wifi_event_beacon_ind wifi_event_beacon_ind, *Pwifi_event_beacon_ind; + +typedef struct wifi_cipher_t.conflict1 wifi_cipher_t.conflict1, *Pwifi_cipher_t.conflict1; + +typedef struct wifi_secmode_t.conflict1 wifi_secmode_t.conflict1, *Pwifi_secmode_t.conflict1; + +struct wifi_secmode_t.conflict1 { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +struct wifi_cipher_t.conflict1 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +struct wifi_event_beacon_ind { + uint8_t bssid[6]; + uint8_t ssid[33]; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t channel; + uint8_t auth; + uint8_t cipher; + struct wifi_cipher_t.conflict1 wpa_mcstCipher; + struct wifi_cipher_t.conflict2 wpa_ucstCipher; + struct wifi_cipher_t.conflict3 rsn_mcstCipher; + struct wifi_cipher_t.conflict4 rsn_ucstCipher; + struct wifi_secmode_t.conflict1 sec_mode; + undefined field_0x33; + int ssid_len; +}; + +typedef struct wifi_secmode_t wifi_secmode_t, *Pwifi_secmode_t; + +struct wifi_secmode_t { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +typedef struct wifi_event_sm_disconnect_ind wifi_event_sm_disconnect_ind, *Pwifi_event_sm_disconnect_ind; + +struct wifi_event_sm_disconnect_ind { + uint16_t reason_code; + uint8_t vif_idx; + undefined field_0x3; + int ft_over_ds; +}; + +typedef struct wifi_event_beacon_ind.conflict1 wifi_event_beacon_ind.conflict1, *Pwifi_event_beacon_ind.conflict1; + +typedef struct wifi_cipher_t.conflict9 wifi_cipher_t.conflict9, *Pwifi_cipher_t.conflict9; + +typedef struct wifi_secmode_t.conflict3 wifi_secmode_t.conflict3, *Pwifi_secmode_t.conflict3; + +struct wifi_cipher_t.conflict9 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +struct wifi_secmode_t.conflict3 { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +struct wifi_event_beacon_ind.conflict1 { + uint8_t bssid[6]; + uint8_t ssid[33]; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t channel; + uint8_t auth; + uint8_t cipher; + struct wifi_cipher_t.conflict9 wpa_mcstCipher; + struct wifi_cipher_t.conflict10 wpa_ucstCipher; + struct wifi_cipher_t.conflict11 rsn_mcstCipher; + struct wifi_cipher_t.conflict12 rsn_ucstCipher; + struct wifi_secmode_t.conflict3 sec_mode; + undefined field_0x33; + int ssid_len; +}; + +typedef struct wifi_event_beacon_ind.conflict4 wifi_event_beacon_ind.conflict4, *Pwifi_event_beacon_ind.conflict4; + +typedef struct wifi_secmode_t.conflict8 wifi_secmode_t.conflict8, *Pwifi_secmode_t.conflict8; + +struct wifi_secmode_t.conflict8 { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +struct wifi_event_beacon_ind.conflict4 { + uint8_t bssid[6]; + uint8_t ssid[33]; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t channel; + uint8_t auth; + uint8_t cipher; + struct wifi_cipher_t.conflict23 wpa_mcstCipher; + struct wifi_cipher_t.conflict24 wpa_ucstCipher; + struct wifi_cipher_t.conflict25 rsn_mcstCipher; + struct wifi_cipher_t.conflict26 rsn_ucstCipher; + struct wifi_secmode_t.conflict8 sec_mode; + undefined field_0x33; + int ssid_len; +}; + +typedef struct wifi_event_beacon_ind.conflict3 wifi_event_beacon_ind.conflict3, *Pwifi_event_beacon_ind.conflict3; + +typedef struct wifi_cipher_t.conflict19 wifi_cipher_t.conflict19, *Pwifi_cipher_t.conflict19; + +typedef struct wifi_secmode_t.conflict7 wifi_secmode_t.conflict7, *Pwifi_secmode_t.conflict7; + +struct wifi_cipher_t.conflict19 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +struct wifi_secmode_t.conflict7 { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +struct wifi_event_beacon_ind.conflict3 { + uint8_t bssid[6]; + uint8_t ssid[33]; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t channel; + uint8_t auth; + uint8_t cipher; + struct wifi_cipher_t.conflict19 wpa_mcstCipher; + struct wifi_cipher_t.conflict20 wpa_ucstCipher; + struct wifi_cipher_t.conflict21 rsn_mcstCipher; + struct wifi_cipher_t.conflict22 rsn_ucstCipher; + struct wifi_secmode_t.conflict7 sec_mode; + undefined field_0x33; + int ssid_len; +}; + +typedef struct wifi_event_beacon_ind.conflict2 wifi_event_beacon_ind.conflict2, *Pwifi_event_beacon_ind.conflict2; + +typedef struct wifi_cipher_t.conflict13 wifi_cipher_t.conflict13, *Pwifi_cipher_t.conflict13; + +typedef struct wifi_secmode_t.conflict4 wifi_secmode_t.conflict4, *Pwifi_secmode_t.conflict4; + +struct wifi_cipher_t.conflict13 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +struct wifi_secmode_t.conflict4 { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +struct wifi_event_beacon_ind.conflict2 { + uint8_t bssid[6]; + uint8_t ssid[33]; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t channel; + uint8_t auth; + uint8_t cipher; + struct wifi_cipher_t.conflict13 wpa_mcstCipher; + struct wifi_cipher_t.conflict14 wpa_ucstCipher; + struct wifi_cipher_t.conflict15 rsn_mcstCipher; + struct wifi_cipher_t.conflict16 rsn_ucstCipher; + struct wifi_secmode_t.conflict4 sec_mode; + undefined field_0x33; + int ssid_len; +}; + +typedef struct wifi_secmode_t.conflict2 wifi_secmode_t.conflict2, *Pwifi_secmode_t.conflict2; + +struct wifi_secmode_t.conflict2 { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +typedef struct wifi_secmode_t.conflict5 wifi_secmode_t.conflict5, *Pwifi_secmode_t.conflict5; + +struct wifi_secmode_t.conflict5 { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +typedef struct wifi_secmode_t.conflict6 wifi_secmode_t.conflict6, *Pwifi_secmode_t.conflict6; + +struct wifi_secmode_t.conflict6 { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +typedef struct wifi_cipher_t.conflict17 wifi_cipher_t.conflict17, *Pwifi_cipher_t.conflict17; + +struct wifi_cipher_t.conflict17 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict18 wifi_cipher_t.conflict18, *Pwifi_cipher_t.conflict18; + +struct wifi_cipher_t.conflict18 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_event_data_ind_channel_switch wifi_event_data_ind_channel_switch, *Pwifi_event_data_ind_channel_switch; + +struct wifi_event_data_ind_channel_switch { + int channel; +}; + +typedef struct wifi_cipher_t.conflict5 wifi_cipher_t.conflict5, *Pwifi_cipher_t.conflict5; + +struct wifi_cipher_t.conflict5 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict wifi_cipher_t.conflict, *Pwifi_cipher_t.conflict; + +struct wifi_cipher_t.conflict { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_event_beacon_ind.conflict wifi_event_beacon_ind.conflict, *Pwifi_event_beacon_ind.conflict; + +struct wifi_event_beacon_ind.conflict { + uint8_t bssid[6]; + uint8_t ssid[33]; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t channel; + uint8_t auth; + uint8_t cipher; + struct wifi_cipher_t.conflict5 wpa_mcstCipher; + struct wifi_cipher_t.conflict6 wpa_ucstCipher; + struct wifi_cipher_t.conflict7 rsn_mcstCipher; + struct wifi_cipher_t.conflict8 rsn_ucstCipher; + struct wifi_secmode_t.conflict2 sec_mode; + undefined field_0x33; + int ssid_len; +}; + +typedef struct wifi_event wifi_event, *Pwifi_event; + +struct wifi_event { + uint32_t id; + uint8_t[0] data; +}; + +typedef struct wifi_cipher_t wifi_cipher_t, *Pwifi_cipher_t; + +struct wifi_cipher_t { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct phyif_utils_recvtable_t phyif_utils_recvtable_t, *Pphyif_utils_recvtable_t; + +struct phyif_utils_recvtable_t { + uint32_t recvtable1; + uint32_t recvtable2; + uint32_t recvtable3; + uint32_t recvtable4; + uint32_t recvtable5; + uint32_t recvtable6; +}; + +typedef struct phyif_utils_recvtable_priv_t.conflict phyif_utils_recvtable_priv_t.conflict, *Pphyif_utils_recvtable_priv_t.conflict; + +struct phyif_utils_recvtable_priv_t.conflict { + uint32_t leg_length:12; + uint32_t leg_rate:4; + uint32_t ht_length:16; + uint32_t _ht_length:4; + uint32_t short_gi:1; + uint32_t stbc:2; + uint32_t smoothing:1; + uint32_t mcs:7; + uint32_t pre_type:1; + uint32_t format_mod:3; + uint32_t ch_bw:2; + uint32_t n_sts:3; + uint32_t lsig_valid:1; + uint32_t sounding:1; + uint32_t num_extn_ss:2; + uint32_t aggregation:1; + uint32_t fec_coding:1; + uint32_t dyn_bw:1; + uint32_t doze_not_allowed:1; + uint32_t antenna_set:8; + uint32_t partial_aid:9; + uint32_t group_id:6; + uint32_t reserved_1c:1; + int32_t rssi1:8; + int32_t rssi2:8; + int32_t rssi3:8; + int32_t rssi4:8; + uint32_t reserved_1d:8; + uint32_t rcpi:8; + uint32_t evm1:8; + uint32_t evm2:8; + uint32_t evm3:8; + uint32_t evm4:8; + uint32_t reserved2b_1:8; + uint32_t reserved2b_2:8; + uint32_t reserved2b_3:8; +}; + +typedef struct phyif_utils_recvtable_priv_t.conflict1 phyif_utils_recvtable_priv_t.conflict1, *Pphyif_utils_recvtable_priv_t.conflict1; + +struct phyif_utils_recvtable_priv_t.conflict1 { + uint32_t leg_length:12; + uint32_t leg_rate:4; + uint32_t ht_length:16; + uint32_t _ht_length:4; + uint32_t short_gi:1; + uint32_t stbc:2; + uint32_t smoothing:1; + uint32_t mcs:7; + uint32_t pre_type:1; + uint32_t format_mod:3; + uint32_t ch_bw:2; + uint32_t n_sts:3; + uint32_t lsig_valid:1; + uint32_t sounding:1; + uint32_t num_extn_ss:2; + uint32_t aggregation:1; + uint32_t fec_coding:1; + uint32_t dyn_bw:1; + uint32_t doze_not_allowed:1; + uint32_t antenna_set:8; + uint32_t partial_aid:9; + uint32_t group_id:6; + uint32_t reserved_1c:1; + int32_t rssi1:8; + int32_t rssi2:8; + int32_t rssi3:8; + int32_t rssi4:8; + uint32_t reserved_1d:8; + uint32_t rcpi:8; + uint32_t evm1:8; + uint32_t evm2:8; + uint32_t evm3:8; + uint32_t evm4:8; + uint32_t reserved2b_1:8; + uint32_t reserved2b_2:8; + uint32_t reserved2b_3:8; +}; + +typedef struct phyif_utils_recvtable_priv_t phyif_utils_recvtable_priv_t, *Pphyif_utils_recvtable_priv_t; + +struct phyif_utils_recvtable_priv_t { + uint32_t leg_length:12; + uint32_t leg_rate:4; + uint32_t ht_length:16; + uint32_t _ht_length:4; + uint32_t short_gi:1; + uint32_t stbc:2; + uint32_t smoothing:1; + uint32_t mcs:7; + uint32_t pre_type:1; + uint32_t format_mod:3; + uint32_t ch_bw:2; + uint32_t n_sts:3; + uint32_t lsig_valid:1; + uint32_t sounding:1; + uint32_t num_extn_ss:2; + uint32_t aggregation:1; + uint32_t fec_coding:1; + uint32_t dyn_bw:1; + uint32_t doze_not_allowed:1; + uint32_t antenna_set:8; + uint32_t partial_aid:9; + uint32_t group_id:6; + uint32_t reserved_1c:1; + int32_t rssi1:8; + int32_t rssi2:8; + int32_t rssi3:8; + int32_t rssi4:8; + uint32_t reserved_1d:8; + uint32_t rcpi:8; + uint32_t evm1:8; + uint32_t evm2:8; + uint32_t evm3:8; + uint32_t evm4:8; + uint32_t reserved2b_1:8; + uint32_t reserved2b_2:8; + uint32_t reserved2b_3:8; +}; + +typedef struct lwip_setgetsockopt_data lwip_setgetsockopt_data, *Plwip_setgetsockopt_data; + +typedef union anon_union_for_optval anon_union_for_optval, *Panon_union_for_optval; + +union anon_union_for_optval { + void * p; + void * pc; +}; + +struct lwip_setgetsockopt_data { + int s; + int level; + int optname; + union anon_union_for_optval optval; + socklen_t optlen; + int err; + void * completed_sem; +}; + +typedef struct lwip_select_cb lwip_select_cb, *Plwip_select_cb; + +struct lwip_select_cb { + struct lwip_select_cb * next; + struct lwip_select_cb * prev; + struct _types_fd_set * readset; + struct _types_fd_set * writeset; + struct _types_fd_set * exceptset; + struct pollfd * poll_fds; + nfds_t poll_nfds; + int sem_signalled; + sys_sem_t sem; +}; + +typedef uint32_t evt_field_t; + +typedef struct ke_env_tag ke_env_tag, *Pke_env_tag; + +struct ke_env_tag { + evt_field_t evt_field; + struct co_list queue_sent; + struct co_list queue_saved; + struct co_list queue_timer; + struct mblock_free * mblock_first; +}; + +typedef struct ble_ke_env_tag ble_ke_env_tag, *Pble_ke_env_tag; + +struct ble_ke_env_tag { + struct co_list queue_sent; + struct co_list queue_saved; + struct co_list queue_timer; + struct mblock_free * heap[2]; + uint16_t heap_size[2]; +}; + +typedef struct mblock_used mblock_used, *Pmblock_used; + +struct mblock_used { + uint32_t size; +}; + +typedef struct mblock_free.conflict mblock_free.conflict, *Pmblock_free.conflict; + +struct mblock_free.conflict { + uint16_t corrupt_check; + uint16_t free_size; + struct mblock_free * next; + struct mblock_free * previous; +}; + +typedef struct mblock_used.conflict mblock_used.conflict, *Pmblock_used.conflict; + +struct mblock_used.conflict { + uint16_t corrupt_check; + uint16_t size; +}; + +typedef struct mbedtls_cipher_definition_t mbedtls_cipher_definition_t, *Pmbedtls_cipher_definition_t; + +struct mbedtls_cipher_definition_t { + enum mbedtls_cipher_type_t type; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + struct mbedtls_cipher_info_t * info; +}; + +typedef struct pbuf_rom pbuf_rom, *Ppbuf_rom; + +struct pbuf_rom { + struct pbuf * next; + void * payload; +}; + +typedef enum pbuf_layer { + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74 +} pbuf_layer; + +typedef enum pbuf_type { + PBUF_POOL=386, + PBUF_RAM=640, + PBUF_REF=65, + PBUF_ROM=1 +} pbuf_type; + +typedef enum SF_Ctrl_Sahb_Type { + SF_CTRL_FLASH_CLOCK=1, + SF_CTRL_SAHB_CLOCK=0 +} SF_Ctrl_Sahb_Type; + +typedef enum SF_Ctrl_Dmy_Mode_Type { + SF_CTRL_DUMMY_1_LINE=0, + SF_CTRL_DUMMY_2_LINES=1, + SF_CTRL_DUMMY_4_LINES=2 +} SF_Ctrl_Dmy_Mode_Type; + +typedef enum SF_Ctrl_Mode_Type { + SF_CTRL_QPI_MODE=1, + SF_CTRL_SPI_MODE=0 +} SF_Ctrl_Mode_Type; + +typedef enum SF_Ctrl_IO_Type { + SF_CTRL_DIO_MODE=3, + SF_CTRL_DO_MODE=1, + SF_CTRL_NIO_MODE=0, + SF_CTRL_QIO_MODE=4, + SF_CTRL_QO_MODE=2 +} SF_Ctrl_IO_Type; + +typedef enum SF_Ctrl_Data_Mode_Type { + SF_CTRL_DATA_1_LINE=0, + SF_CTRL_DATA_2_LINES=1, + SF_CTRL_DATA_4_LINES=2 +} SF_Ctrl_Data_Mode_Type; + +typedef struct SF_Ctrl_Cmd_Cfg_Type SF_Ctrl_Cmd_Cfg_Type, *PSF_Ctrl_Cmd_Cfg_Type; + +typedef enum SF_Ctrl_Cmd_Mode_Type { + SF_CTRL_CMD_1_LINE=0, + SF_CTRL_CMD_4_LINES=1 +} SF_Ctrl_Cmd_Mode_Type; + +typedef enum SF_Ctrl_Addr_Mode_Type { + SF_CTRL_ADDR_1_LINE=0, + SF_CTRL_ADDR_2_LINES=1, + SF_CTRL_ADDR_4_LINES=2 +} SF_Ctrl_Addr_Mode_Type; + +struct SF_Ctrl_Cmd_Cfg_Type { + uint8_t rwFlag; + enum SF_Ctrl_Cmd_Mode_Type cmdMode; + enum SF_Ctrl_Addr_Mode_Type addrMode; + uint8_t addrSize; + uint8_t dummyClks; + enum SF_Ctrl_Dmy_Mode_Type dummyMode; + enum SF_Ctrl_Data_Mode_Type dataMode; + uint8_t rsv[1]; + uint32_t nbData; + uint32_t cmdBuf[2]; +}; + +typedef struct SF_Ctrl_Cfg_Type SF_Ctrl_Cfg_Type, *PSF_Ctrl_Cfg_Type; + +typedef enum SF_Ctrl_Owner_Type { + SF_CTRL_OWNER_IAHB=1, + SF_CTRL_OWNER_SAHB=0 +} SF_Ctrl_Owner_Type; + +typedef enum SF_Ctrl_Ahb2sif_Type { + HIGH_SPEED_MODE_CLOCK=0, + REMOVE_CLOCK_CONSTRAIN=1 +} SF_Ctrl_Ahb2sif_Type; + +struct SF_Ctrl_Cfg_Type { + enum SF_Ctrl_Owner_Type owner; + enum SF_Ctrl_Sahb_Type sahbClock; + enum SF_Ctrl_Ahb2sif_Type ahb2sifMode; + uint8_t clkDelay; + uint8_t clkInvert; + uint8_t rxClkInvert; + uint8_t doDelay; + uint8_t diDelay; + uint8_t oeDelay; +}; + +typedef enum SF_Ctrl_Pad_Sel { + SF_CTRL_EMBEDDED_SEL=0, + SF_CTRL_EXTERNAL_0TO2_20TO22_SEL=2, + SF_CTRL_EXTERNAL_17TO22_SEL=1 +} SF_Ctrl_Pad_Sel; + +typedef enum SF_Ctrl_AES_Key_Type { + SF_CTRL_AES_128BITS=0, + SF_CTRL_AES_128BITS_DOUBLE_KEY=3, + SF_CTRL_AES_192BITS=2, + SF_CTRL_AES_256BITS=1 +} SF_Ctrl_AES_Key_Type; + +typedef struct mac_bss_info mac_bss_info, *Pmac_bss_info; + +typedef struct mobility_domain mobility_domain, *Pmobility_domain; + +struct mobility_domain { + uint16_t mdid; + uint8_t ft_capability_policy; + undefined field_0x3; +}; + +struct mac_bss_info { + struct mac_htcapability ht_cap; + struct mac_addr bssid; + struct mac_ssid ssid; + uint16_t bsstype; + undefined field_0x4a; + undefined field_0x4b; + struct scan_chan_tag * chan; + uint16_t center_freq1; + uint16_t center_freq2; + uint16_t beacon_period; + uint16_t cap_info; + struct mac_rateset rate_set; + undefined field_0x65; + undefined field_0x66; + undefined field_0x67; + struct mac_edca_param_set edca_param; + int8_t rssi; + int8_t ppm_rel; + int8_t ppm_abs; + uint8_t high_11b_rate; + uint16_t prot_status; + uint8_t bw; + uint8_t phy_bw; + uint8_t power_constraint; + undefined field_0x85; + undefined field_0x86; + undefined field_0x87; + uint32_t valid_flags; + struct mobility_domain mde; + _Bool is_supplicant_enabled; + struct SecurityMode_t wpa_wpa2_wep; + struct Cipher_t wpa_mcstCipher; + struct Cipher_t wpa_ucstCipher; + struct Cipher_t rsn_mcstCipher; + struct Cipher_t rsn_ucstCipher; + _Bool is_pmf_required; + _Bool is_wpa2_prefered; + uint8_t rsn_wpa_ie[32]; + uint8_t rsn_wpa_ie_len; + uint16_t beacon_interval; + uint16_t aid_bitmap; + uint16_t max_listen_interval; + uint8_t sec_type; + undefined field_0xc1; + undefined field_0xc2; + undefined field_0xc3; +}; + +typedef struct me_env_tag me_env_tag, *Pme_env_tag; + +struct me_env_tag { + uint32_t active_vifs; + uint32_t ps_disable_vifs; + ke_task_id_t requester_id; + undefined field_0xa; + undefined field_0xb; + struct mac_htcapability ht_cap; + uint16_t tx_lft; + _Bool ht_supported; + undefined field_0x2f; + struct me_chan_config_req chan; + uint8_t stbc_nss; + uint8_t phy_bw_max; + _Bool ps_on; + undefined field_0x131; + undefined field_0x132; + undefined field_0x133; +}; + +typedef struct _uart_ioctrl_wait_read _uart_ioctrl_wait_read, *P_uart_ioctrl_wait_read; + +struct _uart_ioctrl_wait_read { + char * buf; + int read_size; + uint32_t timeout; +}; + +typedef struct _uart_ioctrl_config _uart_ioctrl_config, *P_uart_ioctrl_config; + +typedef struct _uart_ioctrl_config uart_ioc_config_t; + +typedef enum ioc_uart_parity_t { + IO_UART_PARITY_EVEN=2, + IO_UART_PARITY_NONE=0, + IO_UART_PARITY_ODD=1 +} ioc_uart_parity_t; + +struct _uart_ioctrl_config { + uint32_t baud; + enum ioc_uart_parity_t parity; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct _uart_ioctrl_wait_read uart_ioc_waitread_t; + +typedef struct NoHostSecurityParams_t NoHostSecurityParams_t, *PNoHostSecurityParams_t; + +struct NoHostSecurityParams_t { + UINT8 CipherType; + UINT8 MulticastCipher; + UINT8 UnicastCipher; + char PSKPassPhrase[64]; +}; + +typedef struct input_t input_t, *Pinput_t; + +struct input_t { + int8_t rssi; + int8_t lna; + undefined field_0x2; + undefined field_0x3; + float ppm; + uint8_t new; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct pa_state_t pa_state_t, *Ppa_state_t; + +struct pa_state_t { + uint8_t used; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + uint32_t vif_tag; + struct input_t input_buffer[8]; + int8_t input_buffer_ptr; + undefined field_0x69; + undefined field_0x6a; + undefined field_0x6b; + uint32_t last_update; + int8_t rss; + int8_t rss_acq; + int8_t rss_trk; + int8_t rss_state; + uint8_t rss_hit_count; + undefined field_0x75; + undefined field_0x76; + undefined field_0x77; + uint32_t rss_count; + int8_t ris; + undefined field_0x7d; + undefined field_0x7e; + undefined field_0x7f; + float ce; + int8_t ce_in; + int8_t ce_acq; + int8_t ce_trk; + int8_t ce_state; + int8_t ce_num_up_cmds; + int8_t ce_num_dn_cmds; + undefined field_0x8a; + undefined field_0x8b; +}; + +typedef struct rvec_t rvec_t, *Prvec_t; + +struct rvec_t { + uint32_t leg_length:12; + uint32_t leg_rate:4; + uint32_t ht_length:16; + uint32_t _ht_length:4; + uint32_t short_gi:1; + uint32_t stbc:2; + uint32_t smoothing:1; + uint32_t mcs:7; + uint32_t pre_type:1; + uint32_t format_mod:3; + uint32_t ch_bw:2; + uint32_t n_sts:3; + uint32_t lsig_valid:1; + uint32_t sounding:1; + uint32_t num_extn_ss:2; + uint32_t aggregation:1; + uint32_t fec_coding:1; + uint32_t dyn_bw:1; + uint32_t doze_not_allowed:1; + uint32_t antenna_set:8; + uint32_t partial_aid:9; + uint32_t group_id:6; + uint32_t reserved_1c:1; + int32_t rssi1:8; + int32_t rssi2:8; + int32_t agc_lna:4; + int32_t agc_rbb1:5; + int32_t agc_dg:7; + uint32_t reserved_1d:8; + uint32_t rcpi:8; + uint32_t evm1:8; + uint32_t evm2:8; + uint32_t freqoff_lo:8; + uint32_t freqoff_hi:8; + uint32_t reserved2b_1:8; + uint32_t reserved2b_2:8; + uint32_t reserved2b_3:8; +}; + +typedef struct hb_pub_param hb_pub_param, *Phb_pub_param; + +typedef struct bt_mesh_cfg_hb_pub bt_mesh_cfg_hb_pub, *Pbt_mesh_cfg_hb_pub; + +struct bt_mesh_cfg_hb_pub { + u16_t dst; + u8_t count; + u8_t period; + u8_t ttl; + undefined field_0x5; + u16_t feat; + u16_t net_idx; +}; + +struct hb_pub_param { + u8_t * status; + struct bt_mesh_cfg_hb_pub * pub; +}; + +typedef struct mod_pub_param mod_pub_param, *Pmod_pub_param; + +typedef struct bt_mesh_cfg_mod_pub bt_mesh_cfg_mod_pub, *Pbt_mesh_cfg_mod_pub; + +struct mod_pub_param { + u16_t mod_id; + u16_t cid; + u16_t elem_addr; + undefined field_0x6; + undefined field_0x7; + u8_t * status; + struct bt_mesh_cfg_mod_pub * pub; +}; + +struct bt_mesh_cfg_mod_pub { + u16_t addr; + u16_t app_idx; + _Bool cred_flag; + u8_t ttl; + u8_t period; + u8_t transmit; +}; + +typedef struct relay_param relay_param, *Prelay_param; + +struct relay_param { + u8_t * status; + u8_t * transmit; +}; + +typedef struct hb_sub_param hb_sub_param, *Phb_sub_param; + +typedef struct bt_mesh_cfg_hb_sub bt_mesh_cfg_hb_sub, *Pbt_mesh_cfg_hb_sub; + +struct bt_mesh_cfg_hb_sub { + u16_t src; + u16_t dst; + u8_t period; + u8_t count; + u8_t min; + u8_t max; +}; + +struct hb_sub_param { + u8_t * status; + struct bt_mesh_cfg_hb_sub * sub; +}; + +typedef struct app_key_param app_key_param, *Papp_key_param; + +struct app_key_param { + u8_t * status; + u16_t net_idx; + u16_t app_idx; +}; + +typedef struct comp_data comp_data, *Pcomp_data; + +struct comp_data { + u8_t * status; + struct net_buf_simple * comp; +}; + +typedef struct mod_sub_param mod_sub_param, *Pmod_sub_param; + +struct mod_sub_param { + u8_t * status; + u16_t elem_addr; + undefined field_0x6; + undefined field_0x7; + u16_t * sub_addr; + u16_t * expect_sub; + u16_t mod_id; + u16_t cid; +}; + +typedef struct net_key_param net_key_param, *Pnet_key_param; + +struct net_key_param { + u8_t * status; + u16_t net_idx; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct mod_app_param mod_app_param, *Pmod_app_param; + +struct mod_app_param { + u8_t * status; + u16_t elem_addr; + u16_t mod_app_idx; + u16_t mod_id; + u16_t cid; +}; + +typedef struct ke_timer ke_timer, *Pke_timer; + +struct ke_timer { + struct ke_timer * next; + ke_msg_id_t id; + ke_task_id_t task; + uint32_t time; +}; + +typedef struct bt_mesh_cfg_cli bt_mesh_cfg_cli, *Pbt_mesh_cfg_cli; + +struct bt_mesh_cfg_cli { + struct bt_mesh_model * model; + struct k_sem op_sync; + u32_t.conflict op_pending; + void * op_param; +}; + +typedef struct anon_struct.conflict530 anon_struct.conflict530, *Panon_struct.conflict530; + +struct anon_struct.conflict530 { + uint32_t magic; + struct SPI_Flash_Cfg_Type flashCfg; +}; + +typedef struct igmp_msg igmp_msg, *Pigmp_msg; + +struct igmp_msg { + u8_t igmp_msgtype; + u8_t igmp_maxresp; + u16_t igmp_checksum; + ip4_addr_p_t igmp_group_address; +}; + +typedef struct igmp_group igmp_group, *Pigmp_group; + +struct igmp_group { + struct igmp_group * next; + ip4_addr_t group_address; + u8_t last_reporter_flag; + u8_t group_state; + u16_t timer; + u8_t use; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; +}; + +typedef struct env_hdr_data env_hdr_data, *Penv_hdr_data; + +typedef struct env_hdr_data * env_hdr_data_t; + +struct env_hdr_data { + uint8_t status_table[5]; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t magic; + uint32_t len; + uint32_t crc32; + uint8_t name_len; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + uint32_t value_len; +}; + +typedef enum sector_dirty_status { + SECTOR_DIRTY_FALSE=1, + SECTOR_DIRTY_GC=3, + SECTOR_DIRTY_STATUS_NUM=4, + SECTOR_DIRTY_TRUE=2, + SECTOR_DIRTY_UNUSED=0 +} sector_dirty_status; + +typedef enum sector_dirty_status sector_dirty_status_t; + +typedef struct sector_cache_node sector_cache_node, *Psector_cache_node; + +struct sector_cache_node { + uint32_t addr; + uint32_t empty_addr; +}; + +typedef struct sector_meta_data sector_meta_data, *Psector_meta_data; + +typedef struct sector_meta_data * sector_meta_data_t; + +typedef struct anon_struct_for_status anon_struct_for_status, *Panon_struct_for_status; + +typedef enum sector_store_status { + SECTOR_STORE_EMPTY=1, + SECTOR_STORE_FULL=3, + SECTOR_STORE_STATUS_NUM=4, + SECTOR_STORE_UNUSED=0, + SECTOR_STORE_USING=2 +} sector_store_status; + +typedef enum sector_store_status sector_store_status_t; + +struct anon_struct_for_status { + sector_store_status_t store; + sector_dirty_status_t dirty; +}; + +struct sector_meta_data { + _Bool check_ok; + struct anon_struct_for_status status; + undefined field_0x3; + uint32_t addr; + uint32_t magic; + uint32_t combined; + size_t remain; + uint32_t empty_env; +}; + +typedef struct anon_struct.conflict527 anon_struct.conflict527, *Panon_struct.conflict527; + +struct anon_struct.conflict527 { + uint8_t store[3]; + uint8_t dirty[3]; +}; + +typedef struct anon_struct.conflict528 anon_struct.conflict528, *Panon_struct.conflict528; + +struct anon_struct.conflict528 { + sector_store_status_t store; + sector_dirty_status_t dirty; +}; + +typedef struct env_cache_node env_cache_node, *Penv_cache_node; + +struct env_cache_node { + uint16_t name_crc; + uint16_t active; + uint32_t addr; +}; + +typedef struct sector_hdr_data sector_hdr_data, *Psector_hdr_data; + +typedef struct anon_struct_for_status_table anon_struct_for_status_table, *Panon_struct_for_status_table; + +struct anon_struct_for_status_table { + uint8_t store[3]; + uint8_t dirty[3]; +}; + +struct sector_hdr_data { + struct anon_struct_for_status_table status_table; + undefined field_0x6; + undefined field_0x7; + uint32_t magic; + uint32_t combined; + uint32_t reserved; +}; + +typedef struct ecc_result_ind ecc_result_ind, *Pecc_result_ind; + +struct ecc_result_ind { + uint8_t key_res_x[32]; + uint8_t key_res_y[32]; +}; + +typedef uint32_t u_int32; + +typedef struct ecc_elt_tag ecc_elt_tag, *Pecc_elt_tag; + +typedef struct ECC_Jacobian_Point256 ECC_Jacobian_Point256, *PECC_Jacobian_Point256; + +typedef struct bigHex256 bigHex256, *PbigHex256; + +struct bigHex256 { + u_int32 num[8]; + u_int32 len; + u_int32 sign; +}; + +struct ECC_Jacobian_Point256 { + struct bigHex256 x; + struct bigHex256 y; + struct bigHex256 z; +}; + +struct ecc_elt_tag { + struct co_list_hdr hdr; + u_int32 Point_Mul_Word256; + struct ECC_Jacobian_Point256 Jacobian_PointQ256; + struct ECC_Jacobian_Point256 Jacobian_PointR256; + struct bigHex256 Pk256; + ke_msg_id_t msg_id; + ke_task_id_t client_id; + uint32_t current_val; + uint32_t bit_cursor; + uint8_t key_type; + undefined field_0x12d; + undefined field_0x12e; + undefined field_0x12f; + struct ECC_Jacobian_Point256 * win_4_table; +}; + +typedef uint8_t u_int8; + +typedef struct ecc_env_tag ecc_env_tag, *Pecc_env_tag; + +struct ecc_env_tag { + struct co_list ongoing_mul; +}; + +typedef struct ECC_Point256 ECC_Point256, *PECC_Point256; + +struct ECC_Point256 { + struct bigHex256 x; + struct bigHex256 y; +}; + +typedef ulonglong u64; + +typedef struct uart_priv_data uart_priv_data, *Puart_priv_data; + +typedef struct uart_priv_data uart_priv_data_t; + +struct uart_priv_data { + aos_mutex_t mutex; +}; + +typedef struct _feature_pin _feature_pin, *P_feature_pin; + +struct _feature_pin { + char * featue_name; + char * pin_name; + uint8_t value; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct bl_uart_notify bl_uart_notify, *Pbl_uart_notify; + +struct bl_uart_notify { + void (* rx_cb)(void *); + void * rx_cb_arg; + void (* tx_cb)(void *); + void * tx_cb_arg; +}; + +typedef struct bl_uart_notify bl_uart_notify_t; + +typedef enum icmp_dur_type { + ICMP_DUR_FRAG=4, + ICMP_DUR_HOST=1, + ICMP_DUR_NET=0, + ICMP_DUR_PORT=3, + ICMP_DUR_PROTO=2, + ICMP_DUR_SR=5 +} icmp_dur_type; + +typedef struct icmp_echo_hdr icmp_echo_hdr, *Picmp_echo_hdr; + +struct icmp_echo_hdr { + u8_t type; + u8_t code; + u16_t chksum; + u16_t id; + u16_t seqno; +}; + +typedef struct fdt_property fdt_property, *Pfdt_property; + +struct fdt_property { + fdt32_t tag; + fdt32_t len; + fdt32_t nameoff; + char[0] data; +}; + +typedef struct fdt_reserve_entry fdt_reserve_entry, *Pfdt_reserve_entry; + +struct fdt_reserve_entry { + fdt64_t address; + fdt64_t size; +}; + +typedef struct fdt_node_header fdt_node_header, *Pfdt_node_header; + +struct fdt_node_header { + fdt32_t tag; + char[0] name; +}; + +typedef struct fdt_header fdt_header, *Pfdt_header; + +struct fdt_header { + fdt32_t magic; + fdt32_t totalsize; + fdt32_t off_dt_struct; + fdt32_t off_dt_strings; + fdt32_t off_mem_rsvmap; + fdt32_t version; + fdt32_t last_comp_version; + fdt32_t boot_cpuid_phys; + fdt32_t size_dt_strings; + fdt32_t size_dt_struct; +}; + +typedef SemaphoreHandle_t sys_mutex_t; + +typedef TaskHandle_t sys_thread_t; + +typedef struct bt_mesh_gen_onoff_srv bt_mesh_gen_onoff_srv, *Pbt_mesh_gen_onoff_srv; + +typedef struct bt_mesh_gen_onoff_state bt_mesh_gen_onoff_state, *Pbt_mesh_gen_onoff_state; + +struct bt_mesh_gen_onoff_state { + u8_t prest_onoff; + u8_t target_onoff; +}; + +struct bt_mesh_gen_onoff_srv { + struct bt_mesh_model * model; + struct bt_mesh_gen_onoff_state onoff_state; + struct bt_mesh_state_transition transition; + struct bt_mesh_last_rcvd_msg last_msg; +}; + +typedef struct utils_time_date_t utils_time_date_t, *Putils_time_date_t; + +struct utils_time_date_t { + uchar ntp_hour; + uchar ntp_minute; + uchar ntp_second; + uchar ntp_week_day; + uchar ntp_date; + uchar ntp_month; + uchar leap_days; + uchar leap_year_ind; + uint ntp_year; + uint days_since_epoch; + uint day_of_year; +}; + +typedef struct pka0_bit_shift_op_cfg pka0_bit_shift_op_cfg, *Ppka0_bit_shift_op_cfg; + + +// WARNING! conflicting data type names: /DWARF/sec_eng.c/pka0_bit_shift_op_cfg/anon_union_for_value - /DWARF/bl602_sec_eng.c/pka0_pldi_cfg/anon_union_for_value + +struct pka0_bit_shift_op_cfg { + union anon_union_for_value value; +}; + +typedef struct pka0_common_op_first_cfg pka0_common_op_first_cfg, *Ppka0_common_op_first_cfg; + + +// WARNING! conflicting data type names: /DWARF/sec_eng.c/pka0_common_op_first_cfg/anon_union_for_value - /DWARF/bl602_sec_eng.c/pka0_pldi_cfg/anon_union_for_value + +struct pka0_common_op_first_cfg { + union anon_union_for_value value; +}; + +typedef struct pka0_pld_cfg pka0_pld_cfg, *Ppka0_pld_cfg; + + +// WARNING! conflicting data type names: /DWARF/sec_eng.c/pka0_pld_cfg/anon_union_for_value - /DWARF/bl602_sec_eng.c/pka0_pldi_cfg/anon_union_for_value + +struct pka0_pld_cfg { + union anon_union_for_value value; +}; + +typedef struct pka0_common_op_snd_cfg_S2_only pka0_common_op_snd_cfg_S2_only, *Ppka0_common_op_snd_cfg_S2_only; + + +// WARNING! conflicting data type names: /DWARF/sec_eng.c/pka0_common_op_snd_cfg_S2_only/anon_union_for_value - /DWARF/bl602_sec_eng.c/pka0_pldi_cfg/anon_union_for_value + +struct pka0_common_op_snd_cfg_S2_only { + union anon_union_for_value value; +}; + +typedef struct pka0_common_op_snd_cfg_S1_S2 pka0_common_op_snd_cfg_S1_S2, *Ppka0_common_op_snd_cfg_S1_S2; + + +// WARNING! conflicting data type names: /DWARF/sec_eng.c/pka0_common_op_snd_cfg_S1_S2/anon_union_for_value - /DWARF/bl602_sec_eng.c/pka0_pldi_cfg/anon_union_for_value + +struct pka0_common_op_snd_cfg_S1_S2 { + union anon_union_for_value value; +}; + +typedef struct anon_struct.conflict402 anon_struct.conflict402, *Panon_struct.conflict402; + +struct anon_struct.conflict402 { + uint32_t size:12; + uint32_t d_reg_index:8; + uint32_t d_reg_type:4; + uint32_t op:7; + uint32_t last_op:1; +}; + +typedef struct anon_struct.conflict403 anon_struct.conflict403, *Panon_struct.conflict403; + +struct anon_struct.conflict403 { + uint32_t s0_reg_idx:8; + uint32_t s0_reg_type:4; + uint32_t d_reg_idx:8; + uint32_t d_reg_type:4; + uint32_t op:7; + uint32_t last_op:1; +}; + +typedef struct pka0_common_op_snd_cfg_S1_only pka0_common_op_snd_cfg_S1_only, *Ppka0_common_op_snd_cfg_S1_only; + + +// WARNING! conflicting data type names: /DWARF/sec_eng.c/pka0_common_op_snd_cfg_S1_only/anon_union_for_value - /DWARF/bl602_sec_eng.c/pka0_pldi_cfg/anon_union_for_value + +struct pka0_common_op_snd_cfg_S1_only { + union anon_union_for_value value; +}; + +typedef struct anon_struct.conflict404 anon_struct.conflict404, *Panon_struct.conflict404; + +struct anon_struct.conflict404 { + uint32_t reserved_0_11:12; + uint32_t s1_reg_idx:8; + uint32_t s1_reg_type:4; + uint32_t reserved_24_31:8; +}; + +typedef struct anon_struct.conflict405 anon_struct.conflict405, *Panon_struct.conflict405; + +struct anon_struct.conflict405 { + uint32_t s2_reg_idx:8; + uint32_t s2_reg_type:4; + uint32_t reserved_12_31:20; +}; + +typedef struct anon_struct.conflict406 anon_struct.conflict406, *Panon_struct.conflict406; + +struct anon_struct.conflict406 { + uint32_t s2_reg_idx:8; + uint32_t s2_reg_type:4; + uint32_t s1_reg_idx:8; + uint32_t s1_reg_type:4; + uint32_t reserved_24_31:8; +}; + +typedef struct anon_struct.conflict407 anon_struct.conflict407, *Panon_struct.conflict407; + +struct anon_struct.conflict407 { + uint32_t bit_shift:15; + uint32_t reserved_24_31:17; +}; + +typedef struct anon_struct.conflict10 anon_struct.conflict10, *Panon_struct.conflict10; + +struct anon_struct.conflict10 { + char ssid[64]; + char psk[64]; + int chl; + int ecn; + int max_conn; + int hidden; +}; + +typedef struct at_serial_para_t at_serial_para_t, *Pat_serial_para_t; + +struct at_serial_para_t { + u32 baudrate; + u32 dataBit; + u32 parity; + u32 stopBit; + u32 hwfc; +}; + +typedef struct at_network_para_t at_network_para_t, *Pat_network_para_t; + +struct at_network_para_t { + at_di_t linkId; + at_text_t type[4]; + at_text_t hostname[256]; + at_di_t port; + at_di_t localport; + at_di_t keepAlive; +}; + +typedef struct anon_struct.conflict18 anon_struct.conflict18, *Panon_struct.conflict18; + +struct anon_struct.conflict18 { + int ID; +}; + +typedef struct anon_struct.conflict17 anon_struct.conflict17, *Panon_struct.conflict17; + +struct anon_struct.conflict17 { + int ID; + int data; +}; + +typedef struct anon_struct.conflict16 anon_struct.conflict16, *Panon_struct.conflict16; + +struct anon_struct.conflict16 { + int ID; + int mode; +}; + +typedef struct anon_struct.conflict15 anon_struct.conflict15, *Panon_struct.conflict15; + +struct anon_struct.conflict15 { + int ID; + int mode; + int pull; +}; + +typedef struct at_para_t at_para_t, *Pat_para_t; + +struct at_para_t { + char * ptr; +}; + +typedef struct anon_struct.conflict14 anon_struct.conflict14, *Panon_struct.conflict14; + +struct anon_struct.conflict14 { + at_ip_t setdnsip; +}; + +typedef struct anon_struct.conflict13 anon_struct.conflict13, *Panon_struct.conflict13; + +struct anon_struct.conflict13 { + char hostname[128]; + uint8_t type; + uint8_t content_type; + undefined field_0x82; + undefined field_0x83; + uint8_t * data; +}; + +typedef struct anon_struct.conflict12 anon_struct.conflict12, *Panon_struct.conflict12; + +struct anon_struct.conflict12 { + char hostname[128]; +}; + +typedef struct anon_struct.conflict11 anon_struct.conflict11, *Panon_struct.conflict11; + +struct anon_struct.conflict11 { + char hostname[33]; +}; + +typedef struct at_command_handler_t at_command_handler_t, *Pat_command_handler_t; + +struct at_command_handler_t { + char * cmd; + AT_ERROR_CODE (* handler)(struct at_para_t *); + char * usage; +}; + +typedef union anon_union.conflict4 anon_union.conflict4, *Panon_union.conflict4; + +typedef struct anon_struct.conflict2 anon_struct.conflict2, *Panon_struct.conflict2; + +typedef struct anon_struct.conflict3 anon_struct.conflict3, *Panon_struct.conflict3; + +typedef struct anon_struct.conflict4 anon_struct.conflict4, *Panon_struct.conflict4; + +typedef struct at_tcpserver_para_t at_tcpserver_para_t, *Pat_tcpserver_para_t; + +typedef struct anon_struct.conflict5 anon_struct.conflict5, *Panon_struct.conflict5; + +typedef struct anon_struct.conflict6 anon_struct.conflict6, *Panon_struct.conflict6; + +typedef struct anon_struct.conflict22 anon_struct.conflict22, *Panon_struct.conflict22; + +typedef struct anon_struct.conflict8 anon_struct.conflict8, *Panon_struct.conflict8; + +typedef struct anon_struct.conflict9 anon_struct.conflict9, *Panon_struct.conflict9; + +typedef struct at_ip_para_t at_ip_para_t, *Pat_ip_para_t; + +typedef struct anon_struct.conflict23 anon_struct.conflict23, *Panon_struct.conflict23; + +typedef struct at_sendData_para_t at_sendData_para_t, *Pat_sendData_para_t; + +typedef struct at_close_para_t at_close_para_t, *Pat_close_para_t; + +typedef struct at_client_ssl_path_para_t at_client_ssl_path_para_t, *Pat_client_ssl_path_para_t; + +typedef struct at_client_ssl_sni_t at_client_ssl_sni_t, *Pat_client_ssl_sni_t; + +typedef struct at_client_ssl_alpn_t at_client_ssl_alpn_t, *Pat_client_ssl_alpn_t; + +typedef struct at_ble_sync_mode_t at_ble_sync_mode_t, *Pat_ble_sync_mode_t; + +typedef struct anon_struct.conflict19 anon_struct.conflict19, *Panon_struct.conflict19; + +struct at_ip_para_t { + at_ip_t ip; + at_ip_t getway; + at_ip_t netmask; + at_ip_t dns1; + at_ip_t dns2; +}; + +struct anon_struct.conflict9 { + char ssid[33]; + char pwd[33]; +}; + +struct anon_struct.conflict8 { + int mode; +}; + +struct at_client_ssl_sni_t { + at_di_t linkId; + at_text_t sni[256]; +}; + +struct at_client_ssl_path_para_t { + at_di_t linkId; + at_di_t auth_mode; + at_text_t * ca; + at_text_t * key; + at_text_t * cert; +}; + +struct anon_struct.conflict19 { + int apnum; +}; + +struct at_ble_sync_mode_t { + int mode; +}; + +struct at_sendData_para_t { + at_di_t linkId; + at_di_t bufferlen; + at_text_t * buffer; + at_text_t hostname[256]; + at_di_t port; +}; + +struct anon_struct.conflict5 { + s32 len; + u8 * buf; +}; + +struct anon_struct.conflict22 { + uint32_t sleep_time; + int weakup_pin; +}; + +struct at_tcpserver_para_t { + at_di_t port; + at_di_t enable; + at_di_t tls; + at_di_t ca; +}; + +struct at_close_para_t { + at_di_t linkId; +}; + +struct anon_struct.conflict2 { + char hostname[256]; +}; + +struct anon_struct.conflict4 { + s32 method; +}; + +struct anon_struct.conflict23 { + char hostname[128]; + uint8_t type; + uint8_t content_type; + undefined field_0x82; + undefined field_0x83; + uint8_t * data; +}; + +struct at_client_ssl_alpn_t { + at_di_t linkId; + at_text_t * * alpn; +}; + +struct anon_struct.conflict6 { + int uartId; + int uartBaud; + int dataBit; + int parity; + int stopBit; + int hwfc; +}; + +struct anon_struct.conflict3 { + s32 value; +}; + +union anon_union.conflict4 { + struct anon_struct.conflict2 ping; + struct anon_struct.conflict3 wifi; + struct anon_struct.conflict4 scan; + struct at_tcpserver_para_t tcp_server; + struct anon_struct.conflict5 mode; + struct anon_struct.conflict6 uart; + struct anon_struct.conflict22 sleep; + struct anon_struct.conflict8 wifiMode; + struct anon_struct.conflict9 joinParam; + struct at_ip_para_t at_ip_para; + struct anon_struct.conflict10 apcfgParam; + struct anon_struct.conflict11 iphostname; + struct anon_struct.conflict12 dns_parse; + struct anon_struct.conflict23 http_req; + struct anon_struct.conflict14 set_dns; + struct at_network_para_t net_param; + struct at_sendData_para_t send_param; + struct at_close_para_t close_id; + struct at_client_ssl_path_para_t client_ssl_path_cfg; + struct at_client_ssl_sni_t client_ssl_sni_cfg; + struct at_client_ssl_alpn_t client_ssl_alpn_cfg; + struct at_ble_sync_mode_t ble_sync_mode; + struct anon_struct.conflict15 setgpio_para; + struct anon_struct.conflict16 setiodir_para; + struct anon_struct.conflict17 writeiodata_para; + struct anon_struct.conflict18 readiodata_para; + struct anon_struct.conflict19 deleteap_para; +}; + +typedef union anon_union.conflict9 anon_union.conflict9, *Panon_union.conflict9; + +typedef struct anon_struct.conflict31 anon_struct.conflict31, *Panon_struct.conflict31; + +typedef struct anon_struct.conflict32 anon_struct.conflict32, *Panon_struct.conflict32; + +struct anon_struct.conflict32 { + char hostname[128]; + uint8_t type; + uint8_t content_type; + undefined field_0x82; + undefined field_0x83; + uint8_t * data; +}; + +struct anon_struct.conflict31 { + uint32_t sleep_time; + int weakup_pin; +}; + +union anon_union.conflict9 { + struct anon_struct.conflict2 ping; + struct anon_struct.conflict3 wifi; + struct anon_struct.conflict4 scan; + struct at_tcpserver_para_t tcp_server; + struct anon_struct.conflict5 mode; + struct anon_struct.conflict6 uart; + struct anon_struct.conflict31 sleep; + struct anon_struct.conflict8 wifiMode; + struct anon_struct.conflict9 joinParam; + struct at_ip_para_t at_ip_para; + struct anon_struct.conflict10 apcfgParam; + struct anon_struct.conflict11 iphostname; + struct anon_struct.conflict12 dns_parse; + struct anon_struct.conflict32 http_req; + struct anon_struct.conflict14 set_dns; + struct at_network_para_t net_param; + struct at_sendData_para_t send_param; + struct at_close_para_t close_id; + struct at_client_ssl_path_para_t client_ssl_path_cfg; + struct at_client_ssl_sni_t client_ssl_sni_cfg; + struct at_client_ssl_alpn_t client_ssl_alpn_cfg; + struct at_ble_sync_mode_t ble_sync_mode; + struct anon_struct.conflict15 setgpio_para; + struct anon_struct.conflict16 setiodir_para; + struct anon_struct.conflict17 writeiodata_para; + struct anon_struct.conflict18 readiodata_para; + struct anon_struct.conflict19 deleteap_para; +}; + +typedef struct at_wifiMode_para_t at_wifiMode_para_t, *Pat_wifiMode_para_t; + +struct at_wifiMode_para_t { + at_di_t wifi_mode; +}; + +typedef union anon_union.conflict3 anon_union.conflict3, *Panon_union.conflict3; + +typedef struct anon_struct.conflict7 anon_struct.conflict7, *Panon_struct.conflict7; + +struct anon_struct.conflict7 { + uint32_t sleep_time; + int weakup_pin; +}; + +union anon_union.conflict3 { + struct anon_struct.conflict2 ping; + struct anon_struct.conflict3 wifi; + struct anon_struct.conflict4 scan; + struct at_tcpserver_para_t tcp_server; + struct anon_struct.conflict5 mode; + struct anon_struct.conflict6 uart; + struct anon_struct.conflict7 sleep; + struct anon_struct.conflict8 wifiMode; + struct anon_struct.conflict9 joinParam; + struct at_ip_para_t at_ip_para; + struct anon_struct.conflict10 apcfgParam; + struct anon_struct.conflict11 iphostname; + struct anon_struct.conflict12 dns_parse; + struct anon_struct.conflict13 http_req; + struct anon_struct.conflict14 set_dns; + struct at_network_para_t net_param; + struct at_sendData_para_t send_param; + struct at_close_para_t close_id; + struct at_client_ssl_path_para_t client_ssl_path_cfg; + struct at_client_ssl_sni_t client_ssl_sni_cfg; + struct at_client_ssl_alpn_t client_ssl_alpn_cfg; + struct at_ble_sync_mode_t ble_sync_mode; + struct anon_struct.conflict15 setgpio_para; + struct anon_struct.conflict16 setiodir_para; + struct anon_struct.conflict17 writeiodata_para; + struct anon_struct.conflict18 readiodata_para; + struct anon_struct.conflict19 deleteap_para; +}; + +typedef enum AT_CALLBACK_CMD { + ACC_ACT=0, + ACC_APCFG=39, + ACC_AP_STA_GET=40, + ACC_BLESYNC=65, + ACC_CIPCLOSE=45, + ACC_CIPDNS_CUR=54, + ACC_CIPDOMAIN=42, + ACC_CIPMODE=52, + ACC_CIPMUX=51, + ACC_CIPRECVDATA=55, + ACC_CIPRECVMODE=56, + ACC_CIPSEND=57, + ACC_CIPSENDBUF=44, + ACC_CIPSSLCALPN=48, + ACC_CIPSSLCCONF_P=46, + ACC_CIPSSLCSNI=47, + ACC_CIPSTAMAC_CUR=36, + ACC_CIPSTART=43, + ACC_CIPSTATUS=41, + ACC_CIPSTA_CUR=37, + ACC_CIPSTA_IP=66, + ACC_CIPSTA_IP_GET=67, + ACC_CWDHCP_CUR=35, + ACC_CWHOSTNAME=38, + ACC_CWJAP_CUR=30, + ACC_CWJAP_INFO=31, + ACC_CWLAP=33, + ACC_CWLAPOPT=32, + ACC_CWMODE_CUR=28, + ACC_CWMODE_GET=29, + ACC_CWQAP=34, + ACC_DEEP_SLEEP=26, + ACC_DELETEAP=63, + ACC_FACTORY=6, + ACC_GMR=21, + ACC_GPIOC=17, + ACC_GPIOR=18, + ACC_GPIOW=19, + ACC_HTTP_REQ=53, + ACC_LOAD=4, + ACC_MODE=2, + ACC_OTA=64, + ACC_PEER=7, + ACC_PING=8, + ACC_REASSOCIATE=16, + ACC_RESTORE=22, + ACC_RST=1, + ACC_SAVE=3, + ACC_SCAN=20, + ACC_SLEEP=25, + ACC_SOCKC=13, + ACC_SOCKD=14, + ACC_SOCKON=9, + ACC_SOCKQ=11, + ACC_SOCKR=12, + ACC_SOCKW=10, + ACC_STATUS=5, + ACC_SYSGPIODIR=60, + ACC_SYSGPIOREAD=62, + ACC_SYSGPIOWRITE=61, + ACC_SYSIOGETCFG=59, + ACC_SYSIOSETCFG=58, + ACC_TCPSERVER=49, + ACC_TCPSERVERMAXCONN=50, + ACC_UART_GET=24, + ACC_UART_SET=23, + ACC_WAKEUPGPIO=27, + ACC_WIFI=15 +} AT_CALLBACK_CMD; + +typedef struct at_http_para_t at_http_para_t, *Pat_http_para_t; + +struct at_http_para_t { + at_text_t hostname[256]; + uint8_t type; + uint8_t content_type; + at_text_t data[256]; +}; + +typedef struct at_joinAp_para_t at_joinAp_para_t, *Pat_joinAp_para_t; + +struct at_joinAp_para_t { + at_text_t ssid[256]; + at_text_t pwd[256]; +}; + +typedef struct at_scan_para_t at_scan_para_t, *Pat_scan_para_t; + +struct at_scan_para_t { + at_text_t mode[2]; + at_text_t repeat[2]; +}; + +typedef struct at_callback_t at_callback_t, *Pat_callback_t; + +struct at_callback_t { + AT_ERROR_CODE (* handle_cb)(enum AT_CALLBACK_CMD, struct at_callback_para_t *, struct at_callback_rsp_t *); + s32 (* dump_cb)(u8 *, s32); +}; + +typedef struct anon_struct.conflict30 anon_struct.conflict30, *Panon_struct.conflict30; + +struct anon_struct.conflict30 { + char hostname[128]; + uint8_t type; + uint8_t content_type; + undefined field_0x82; + undefined field_0x83; + uint8_t * data; +}; + +typedef struct anon_struct.conflict565 anon_struct.conflict565, *Panon_struct.conflict565; + +struct anon_struct.conflict565 { + uint32_t sleep_time; + int weakup_pin; +}; + +typedef struct anon_struct.conflict566 anon_struct.conflict566, *Panon_struct.conflict566; + +struct anon_struct.conflict566 { + char hostname[128]; + uint8_t type; + uint8_t content_type; + undefined field_0x82; + undefined field_0x83; + uint8_t * data; +}; + +typedef struct anon_struct.conflict567 anon_struct.conflict567, *Panon_struct.conflict567; + +struct anon_struct.conflict567 { + uint32_t sleep_time; + int weakup_pin; +}; + +typedef struct anon_struct.conflict568 anon_struct.conflict568, *Panon_struct.conflict568; + +struct anon_struct.conflict568 { + char hostname[128]; + uint8_t type; + uint8_t content_type; + undefined field_0x82; + undefined field_0x83; + uint8_t * data; +}; + +typedef struct anon_struct.conflict561 anon_struct.conflict561, *Panon_struct.conflict561; + +struct anon_struct.conflict561 { + uint32_t sleep_time; + int weakup_pin; +}; + +typedef struct anon_struct.conflict562 anon_struct.conflict562, *Panon_struct.conflict562; + +struct anon_struct.conflict562 { + char hostname[128]; + uint8_t type; + uint8_t content_type; + undefined field_0x82; + undefined field_0x83; + uint8_t * data; +}; + +typedef struct anon_struct.conflict563 anon_struct.conflict563, *Panon_struct.conflict563; + +struct anon_struct.conflict563 { + uint32_t sleep_time; + int weakup_pin; +}; + +typedef struct anon_struct.conflict564 anon_struct.conflict564, *Panon_struct.conflict564; + +struct anon_struct.conflict564 { + char hostname[128]; + uint8_t type; + uint8_t content_type; + undefined field_0x82; + undefined field_0x83; + uint8_t * data; +}; + +typedef struct anon_struct.conflict21 anon_struct.conflict21, *Panon_struct.conflict21; + +struct anon_struct.conflict21 { + char hostname[128]; + uint8_t type; + uint8_t content_type; + undefined field_0x82; + undefined field_0x83; + uint8_t * data; +}; + +typedef struct anon_struct.conflict20 anon_struct.conflict20, *Panon_struct.conflict20; + +struct anon_struct.conflict20 { + uint32_t sleep_time; + int weakup_pin; +}; + +typedef struct anon_struct.conflict569 anon_struct.conflict569, *Panon_struct.conflict569; + +struct anon_struct.conflict569 { + uint32_t sleep_time; + int weakup_pin; +}; + +typedef struct anon_struct.conflict29 anon_struct.conflict29, *Panon_struct.conflict29; + +struct anon_struct.conflict29 { + uint32_t sleep_time; + int weakup_pin; +}; + +typedef struct anon_struct.conflict570 anon_struct.conflict570, *Panon_struct.conflict570; + +struct anon_struct.conflict570 { + char hostname[128]; + uint8_t type; + uint8_t content_type; + undefined field_0x82; + undefined field_0x83; + uint8_t * data; +}; + +typedef struct anon_struct.conflict571 anon_struct.conflict571, *Panon_struct.conflict571; + +struct anon_struct.conflict571 { + uint32_t sleep_time; + int weakup_pin; +}; + +typedef struct anon_struct.conflict572 anon_struct.conflict572, *Panon_struct.conflict572; + +struct anon_struct.conflict572 { + char hostname[128]; + uint8_t type; + uint8_t content_type; + undefined field_0x82; + undefined field_0x83; + uint8_t * data; +}; + +typedef struct anon_struct.conflict573 anon_struct.conflict573, *Panon_struct.conflict573; + +struct anon_struct.conflict573 { + uint32_t sleep_time; + int weakup_pin; +}; + +typedef struct anon_struct.conflict574 anon_struct.conflict574, *Panon_struct.conflict574; + +struct anon_struct.conflict574 { + char hostname[128]; + uint8_t type; + uint8_t content_type; + undefined field_0x82; + undefined field_0x83; + uint8_t * data; +}; + +typedef struct cmd_send_cache cmd_send_cache, *Pcmd_send_cache; + +struct cmd_send_cache { + u32 status; + u32 cnt; + u32 linkID; + u32 length; + u8 hostname[256]; + u16 port; + u8 buf[1028]; + undefined field_0x516; + undefined field_0x517; +}; + +typedef struct cmd_send_cache cmd_send_cache_t; + +typedef struct at_uart_para_t at_uart_para_t, *Pat_uart_para_t; + +struct at_uart_para_t { + at_di_t uart_id; + at_di_t baudrate; + at_di_t data_bits; + at_di_t stop_bits; + at_di_t parity; + at_di_t hwfc; +}; + +typedef struct at_scan_opt_t at_scan_opt_t, *Pat_scan_opt_t; + +struct at_scan_opt_t { + uint8_t sort_enable; + uint8_t mask; +}; + +typedef struct at_getcfg_t at_getcfg_t, *Pat_getcfg_t; + +struct at_getcfg_t { + at_text_t key[256]; +}; + +typedef struct cmd_cache cmd_cache, *Pcmd_cache; + +struct cmd_cache { + u32 cnt; + u8 buf[1028]; +}; + +typedef struct at_hostname_para_t at_hostname_para_t, *Pat_hostname_para_t; + +struct at_hostname_para_t { + at_text_t hostname[256]; +}; + +typedef struct at_autoconnect_para_t at_autoconnect_para_t, *Pat_autoconnect_para_t; + +struct at_autoconnect_para_t { + int autoconnectSwitch; +}; + +typedef struct cmd_cache cmd_cache_t; + +typedef struct at_echoswitch_para_t at_echoswitch_para_t, *Pat_echoswitch_para_t; + +struct at_echoswitch_para_t { + int echoSwitch; +}; + +typedef struct at_gpiowakeup_para_t at_gpiowakeup_para_t, *Pat_gpiowakeup_para_t; + +struct at_gpiowakeup_para_t { + at_di_t sleep_time; + at_di_t gpioId; +}; + +typedef struct iot_sha256_context iot_sha256_context, *Piot_sha256_context; + +struct iot_sha256_context { + uint32_t total[2]; + uint32_t state[8]; + uchar buffer[64]; + int is224; +}; + +typedef int ptrdiff_t; + +typedef struct altcp_mbedtls_state_s.conflict1 altcp_mbedtls_state_s.conflict1, *Paltcp_mbedtls_state_s.conflict1; + +typedef struct altcp_mbedtls_state_s.conflict1 altcp_mbedtls_state_t.conflict; + +struct altcp_mbedtls_state_s.conflict1 { + void * conf; + struct mbedtls_ssl_context.conflict3 ssl_context; + struct pbuf * rx; + struct pbuf * rx_app; + u8_t flags; + undefined field_0xcd; + undefined field_0xce; + undefined field_0xcf; + int rx_passed_unrecved; + int bio_bytes_read; + int bio_bytes_appl; +}; + +typedef struct altcp_mbedtls_state_s.conflict4 altcp_mbedtls_state_s.conflict4, *Paltcp_mbedtls_state_s.conflict4; + +struct altcp_mbedtls_state_s.conflict4 { + void * conf; + struct mbedtls_ssl_context.conflict8 ssl_context; + struct pbuf * rx; + struct pbuf * rx_app; + u8_t flags; + undefined field_0xcd; + undefined field_0xce; + undefined field_0xcf; + int rx_passed_unrecved; + int bio_bytes_read; + int bio_bytes_appl; +}; + +typedef struct altcp_mbedtls_state_s altcp_mbedtls_state_s, *Paltcp_mbedtls_state_s; + +struct altcp_mbedtls_state_s { + void * conf; + struct mbedtls_ssl_context.conflict1 ssl_context; + struct pbuf * rx; + struct pbuf * rx_app; + u8_t flags; + undefined field_0xcd; + undefined field_0xce; + undefined field_0xcf; + int rx_passed_unrecved; + int bio_bytes_read; + int bio_bytes_appl; +}; + +typedef struct altcp_mbedtls_state_s.conflict altcp_mbedtls_state_s.conflict, *Paltcp_mbedtls_state_s.conflict; + +typedef struct altcp_mbedtls_state_s.conflict altcp_mbedtls_state_t; + +struct altcp_mbedtls_state_s.conflict { + void * conf; + struct mbedtls_ssl_context.conflict2 ssl_context; + struct pbuf * rx; + struct pbuf * rx_app; + u8_t flags; + undefined field_0xcd; + undefined field_0xce; + undefined field_0xcf; + int rx_passed_unrecved; + int bio_bytes_read; + int bio_bytes_appl; +}; + +typedef struct altcp_mbedtls_state_s.conflict4 altcp_mbedtls_state_t.conflict2; + +typedef struct altcp_mbedtls_state_s.conflict3 altcp_mbedtls_state_s.conflict3, *Paltcp_mbedtls_state_s.conflict3; + +struct altcp_mbedtls_state_s.conflict3 { + void * conf; + struct mbedtls_ssl_context.conflict7 ssl_context; + struct pbuf * rx; + struct pbuf * rx_app; + u8_t flags; + undefined field_0xcd; + undefined field_0xce; + undefined field_0xcf; + int rx_passed_unrecved; + int bio_bytes_read; + int bio_bytes_appl; +}; + +typedef struct altcp_mbedtls_state_s.conflict2 altcp_mbedtls_state_s.conflict2, *Paltcp_mbedtls_state_s.conflict2; + +struct altcp_mbedtls_state_s.conflict2 { + void * conf; + struct mbedtls_ssl_context.conflict6 ssl_context; + struct pbuf * rx; + struct pbuf * rx_app; + u8_t flags; + undefined field_0xcd; + undefined field_0xce; + undefined field_0xcf; + int rx_passed_unrecved; + int bio_bytes_read; + int bio_bytes_appl; +}; + +typedef struct altcp_mbedtls_state_s.conflict3 altcp_mbedtls_state_t.conflict1; + +typedef struct anon_struct.conflict217 anon_struct.conflict217, *Panon_struct.conflict217; + +struct anon_struct.conflict217 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict218 anon_struct.conflict218, *Panon_struct.conflict218; + +struct anon_struct.conflict218 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict103 anon_struct.conflict103, *Panon_struct.conflict103; + +struct anon_struct.conflict103 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict224 anon_struct.conflict224, *Panon_struct.conflict224; + +struct anon_struct.conflict224 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict104 anon_struct.conflict104, *Panon_struct.conflict104; + +struct anon_struct.conflict104 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict225 anon_struct.conflict225, *Panon_struct.conflict225; + +struct anon_struct.conflict225 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict105 anon_struct.conflict105, *Panon_struct.conflict105; + +struct anon_struct.conflict105 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict226 anon_struct.conflict226, *Panon_struct.conflict226; + +struct anon_struct.conflict226 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict106 anon_struct.conflict106, *Panon_struct.conflict106; + +struct anon_struct.conflict106 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict223 anon_struct.conflict223, *Panon_struct.conflict223; + +struct anon_struct.conflict223 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef enum VIF_AP_BCMC_STATUS { + VIF_AP_BCMC_BUFFERED=1, + VIF_AP_BCMC_MOREDATA=2 +} VIF_AP_BCMC_STATUS; + +typedef struct anon_struct.conflict114 anon_struct.conflict114, *Panon_struct.conflict114; + +struct anon_struct.conflict114 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef union anon_union.conflict28 anon_union.conflict28, *Panon_union.conflict28; + +typedef struct anon_struct.conflict64 anon_struct.conflict64, *Panon_struct.conflict64; + +typedef struct anon_struct.conflict65 anon_struct.conflict65, *Panon_struct.conflict65; + +struct anon_struct.conflict65 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +struct anon_struct.conflict64 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +union anon_union.conflict28 { + struct anon_struct.conflict64 sta; + struct anon_struct.conflict65 ap; +}; + +typedef struct anon_struct.conflict231 anon_struct.conflict231, *Panon_struct.conflict231; + +struct anon_struct.conflict231 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict111 anon_struct.conflict111, *Panon_struct.conflict111; + +struct anon_struct.conflict111 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict232 anon_struct.conflict232, *Panon_struct.conflict232; + +struct anon_struct.conflict232 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict112 anon_struct.conflict112, *Panon_struct.conflict112; + +struct anon_struct.conflict112 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict233 anon_struct.conflict233, *Panon_struct.conflict233; + +struct anon_struct.conflict233 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict113 anon_struct.conflict113, *Panon_struct.conflict113; + +struct anon_struct.conflict113 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict234 anon_struct.conflict234, *Panon_struct.conflict234; + +struct anon_struct.conflict234 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict239 anon_struct.conflict239, *Panon_struct.conflict239; + +struct anon_struct.conflict239 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict240 anon_struct.conflict240, *Panon_struct.conflict240; + +struct anon_struct.conflict240 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict241 anon_struct.conflict241, *Panon_struct.conflict241; + +struct anon_struct.conflict241 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef union anon_union.conflict35 anon_union.conflict35, *Panon_union.conflict35; + +typedef struct anon_struct.conflict74 anon_struct.conflict74, *Panon_struct.conflict74; + +typedef struct anon_struct.conflict75 anon_struct.conflict75, *Panon_struct.conflict75; + +struct anon_struct.conflict75 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +struct anon_struct.conflict74 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +union anon_union.conflict35 { + struct anon_struct.conflict74 sta; + struct anon_struct.conflict75 ap; +}; + +typedef struct anon_struct.conflict127 anon_struct.conflict127, *Panon_struct.conflict127; + +struct anon_struct.conflict127 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict128 anon_struct.conflict128, *Panon_struct.conflict128; + +struct anon_struct.conflict128 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict249 anon_struct.conflict249, *Panon_struct.conflict249; + +struct anon_struct.conflict249 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict242 anon_struct.conflict242, *Panon_struct.conflict242; + +struct anon_struct.conflict242 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef union anon_union.conflict190 anon_union.conflict190, *Panon_union.conflict190; + +typedef struct anon_struct.conflict251 anon_struct.conflict251, *Panon_struct.conflict251; + +typedef struct anon_struct.conflict252 anon_struct.conflict252, *Panon_struct.conflict252; + +struct anon_struct.conflict252 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +struct anon_struct.conflict251 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +union anon_union.conflict190 { + struct anon_struct.conflict251 sta; + struct anon_struct.conflict252 ap; +}; + +typedef struct anon_struct.conflict129 anon_struct.conflict129, *Panon_struct.conflict129; + +struct anon_struct.conflict129 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict250 anon_struct.conflict250, *Panon_struct.conflict250; + +struct anon_struct.conflict250 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict130 anon_struct.conflict130, *Panon_struct.conflict130; + +struct anon_struct.conflict130 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef union anon_union.conflict183 anon_union.conflict183, *Panon_union.conflict183; + +union anon_union.conflict183 { + struct anon_struct.conflict241 sta; + struct anon_struct.conflict242 ap; +}; + +typedef struct anon_struct.conflict136 anon_struct.conflict136, *Panon_struct.conflict136; + +struct anon_struct.conflict136 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef union anon_union.conflict49 anon_union.conflict49, *Panon_union.conflict49; + +typedef struct anon_struct.conflict85 anon_struct.conflict85, *Panon_struct.conflict85; + +typedef struct anon_struct.conflict86 anon_struct.conflict86, *Panon_struct.conflict86; + +struct anon_struct.conflict86 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +struct anon_struct.conflict85 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +union anon_union.conflict49 { + struct anon_struct.conflict85 sta; + struct anon_struct.conflict86 ap; +}; + +typedef struct anon_struct.conflict137 anon_struct.conflict137, *Panon_struct.conflict137; + +struct anon_struct.conflict137 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict138 anon_struct.conflict138, *Panon_struct.conflict138; + +struct anon_struct.conflict138 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict135 anon_struct.conflict135, *Panon_struct.conflict135; + +struct anon_struct.conflict135 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef union anon_union.conflict176 anon_union.conflict176, *Panon_union.conflict176; + +union anon_union.conflict176 { + struct anon_struct.conflict233 sta; + struct anon_struct.conflict234 ap; +}; + +typedef union anon_union.conflict59 anon_union.conflict59, *Panon_union.conflict59; + +typedef struct anon_struct.conflict95 anon_struct.conflict95, *Panon_struct.conflict95; + +typedef struct anon_struct.conflict96 anon_struct.conflict96, *Panon_struct.conflict96; + +struct anon_struct.conflict96 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +struct anon_struct.conflict95 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +union anon_union.conflict59 { + struct anon_struct.conflict95 sta; + struct anon_struct.conflict96 ap; +}; + +typedef struct vif_info_tag vif_info_tag, *Pvif_info_tag; + + +// WARNING! conflicting data type names: /DWARF/vif_mgmt.h/vif_info_tag/anon_union_for_u - /DWARF/gatt.c/gatt_find_info_rsp/anon_union_for_u + +struct vif_info_tag { + struct co_list_hdr list_hdr; + uint32_t prevent_sleep; + uint32_t txq_params[4]; + struct mm_timer_tag tbtt_timer; + struct mm_timer_tag tmr_bcn_to; + struct mac_addr bssid; + undefined field_0x3e; + undefined field_0x3f; + struct chan_ctxt_tag * chan_ctxt; + struct chan_tbtt_tag tbtt_switch; + struct mac_addr mac_addr; + uint8_t type; + uint8_t index; + _Bool active; + int8_t tx_power; + int8_t user_tx_power; + undefined field_0x5b; + union anon_union_for_u u; + struct co_list sta_list; + struct mac_bss_info bss_info; + undefined field_0x41c; + undefined field_0x41d; + undefined field_0x41e; + undefined field_0x41f; + struct key_info_tag key_info[4]; + struct key_info_tag * default_key; + uint32_t flags; + struct mm_chan_ctxt_add_req csa_channel; + undefined field_0x5d2; + undefined field_0x5d3; + undefined field_0x5d4; + undefined field_0x5d5; + undefined field_0x5d6; + undefined field_0x5d7; +}; + +typedef union anon_union.conflict169 anon_union.conflict169, *Panon_union.conflict169; + +union anon_union.conflict169 { + struct anon_struct.conflict225 sta; + struct anon_struct.conflict226 ap; +}; + +typedef union anon_union.conflict162 anon_union.conflict162, *Panon_union.conflict162; + +union anon_union.conflict162 { + struct anon_struct.conflict217 sta; + struct anon_struct.conflict218 ap; +}; + +typedef union anon_union.conflict66 anon_union.conflict66, *Panon_union.conflict66; + +union anon_union.conflict66 { + struct anon_struct.conflict105 sta; + struct anon_struct.conflict106 ap; +}; + +typedef union anon_union.conflict80 anon_union.conflict80, *Panon_union.conflict80; + +union anon_union.conflict80 { + struct anon_struct.conflict129 sta; + struct anon_struct.conflict130 ap; +}; + +typedef union anon_union.conflict73 anon_union.conflict73, *Panon_union.conflict73; + +union anon_union.conflict73 { + struct anon_struct.conflict113 sta; + struct anon_struct.conflict114 ap; +}; + +typedef union anon_union.conflict150 anon_union.conflict150, *Panon_union.conflict150; + +typedef struct anon_struct.conflict205 anon_struct.conflict205, *Panon_struct.conflict205; + +typedef struct anon_struct.conflict206 anon_struct.conflict206, *Panon_struct.conflict206; + +struct anon_struct.conflict206 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +struct anon_struct.conflict205 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +union anon_union.conflict150 { + struct anon_struct.conflict205 sta; + struct anon_struct.conflict206 ap; +}; + +typedef struct anon_struct.conflict203 anon_struct.conflict203, *Panon_struct.conflict203; + +struct anon_struct.conflict203 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict204 anon_struct.conflict204, *Panon_struct.conflict204; + +struct anon_struct.conflict204 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef union anon_union.conflict94 anon_union.conflict94, *Panon_union.conflict94; + +typedef struct anon_struct.conflict147 anon_struct.conflict147, *Panon_struct.conflict147; + +typedef struct anon_struct.conflict148 anon_struct.conflict148, *Panon_struct.conflict148; + +struct anon_struct.conflict147 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +struct anon_struct.conflict148 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +union anon_union.conflict94 { + struct anon_struct.conflict147 sta; + struct anon_struct.conflict148 ap; +}; + +typedef union anon_union.conflict87 anon_union.conflict87, *Panon_union.conflict87; + +union anon_union.conflict87 { + struct anon_struct.conflict137 sta; + struct anon_struct.conflict138 ap; +}; + +typedef struct anon_struct.conflict215 anon_struct.conflict215, *Panon_struct.conflict215; + +struct anon_struct.conflict215 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict216 anon_struct.conflict216, *Panon_struct.conflict216; + +struct anon_struct.conflict216 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict94 anon_struct.conflict94, *Panon_struct.conflict94; + +struct anon_struct.conflict94 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict93 anon_struct.conflict93, *Panon_struct.conflict93; + +struct anon_struct.conflict93 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict180 anon_struct.conflict180, *Panon_struct.conflict180; + +struct anon_struct.conflict180 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict181 anon_struct.conflict181, *Panon_struct.conflict181; + +struct anon_struct.conflict181 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict182 anon_struct.conflict182, *Panon_struct.conflict182; + +struct anon_struct.conflict182 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict84 anon_struct.conflict84, *Panon_struct.conflict84; + +struct anon_struct.conflict84 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict83 anon_struct.conflict83, *Panon_struct.conflict83; + +struct anon_struct.conflict83 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef union anon_union.conflict123 anon_union.conflict123, *Panon_union.conflict123; + +union anon_union.conflict123 { + struct anon_struct.conflict181 sta; + struct anon_struct.conflict182 ap; +}; + +typedef struct anon_struct.conflict73 anon_struct.conflict73, *Panon_struct.conflict73; + +struct anon_struct.conflict73 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict72 anon_struct.conflict72, *Panon_struct.conflict72; + +struct anon_struct.conflict72 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef union anon_union.conflict116 anon_union.conflict116, *Panon_union.conflict116; + +typedef struct anon_struct.conflict173 anon_struct.conflict173, *Panon_struct.conflict173; + +typedef struct anon_struct.conflict174 anon_struct.conflict174, *Panon_struct.conflict174; + +struct anon_struct.conflict174 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +struct anon_struct.conflict173 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +union anon_union.conflict116 { + struct anon_struct.conflict173 sta; + struct anon_struct.conflict174 ap; +}; + +typedef struct anon_struct.conflict63 anon_struct.conflict63, *Panon_struct.conflict63; + +struct anon_struct.conflict63 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict62 anon_struct.conflict62, *Panon_struct.conflict62; + +struct anon_struct.conflict62 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict67 anon_struct.conflict67, *Panon_struct.conflict67; + +struct anon_struct.conflict67 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict66 anon_struct.conflict66, *Panon_struct.conflict66; + +struct anon_struct.conflict66 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef union anon_union.conflict108 anon_union.conflict108, *Panon_union.conflict108; + +typedef struct anon_struct.conflict163 anon_struct.conflict163, *Panon_struct.conflict163; + +typedef struct anon_struct.conflict164 anon_struct.conflict164, *Panon_struct.conflict164; + +struct anon_struct.conflict163 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +struct anon_struct.conflict164 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +union anon_union.conflict108 { + struct anon_struct.conflict163 sta; + struct anon_struct.conflict164 ap; +}; + +typedef union anon_union.conflict101 anon_union.conflict101, *Panon_union.conflict101; + +typedef struct anon_struct.conflict155 anon_struct.conflict155, *Panon_struct.conflict155; + +typedef struct anon_struct.conflict156 anon_struct.conflict156, *Panon_struct.conflict156; + +struct anon_struct.conflict156 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +struct anon_struct.conflict155 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +union anon_union.conflict101 { + struct anon_struct.conflict155 sta; + struct anon_struct.conflict156 ap; +}; + +typedef struct vif_mgmt_env_tag vif_mgmt_env_tag, *Pvif_mgmt_env_tag; + +struct vif_mgmt_env_tag { + struct co_list free_list; + struct co_list used_list; + uint8_t vif_sta_cnt; + uint8_t vif_ap_cnt; + uint8_t low_bcn_int_idx; + undefined field_0x13; +}; + +typedef struct anon_struct.conflict145 anon_struct.conflict145, *Panon_struct.conflict145; + +struct anon_struct.conflict145 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict146 anon_struct.conflict146, *Panon_struct.conflict146; + +struct anon_struct.conflict146 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict153 anon_struct.conflict153, *Panon_struct.conflict153; + +struct anon_struct.conflict153 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict154 anon_struct.conflict154, *Panon_struct.conflict154; + +struct anon_struct.conflict154 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict161 anon_struct.conflict161, *Panon_struct.conflict161; + +struct anon_struct.conflict161 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict162 anon_struct.conflict162, *Panon_struct.conflict162; + +struct anon_struct.conflict162 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict172 anon_struct.conflict172, *Panon_struct.conflict172; + +struct anon_struct.conflict172 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict171 anon_struct.conflict171, *Panon_struct.conflict171; + +struct anon_struct.conflict171 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict179 anon_struct.conflict179, *Panon_struct.conflict179; + +struct anon_struct.conflict179 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct _wifi_conn _wifi_conn, *P_wifi_conn; + +struct _wifi_conn { + char ssid[32]; + char ssid_tail[1]; + char pask[64]; +}; + +typedef struct _wifi_item _wifi_item, *P_wifi_item; + +struct _wifi_item { + char ssid[32]; + uint32_t ssid_len; + uint8_t bssid[6]; + uint8_t channel; + uint8_t auth; + int8_t rssi; + undefined field_0x2d; + undefined field_0x2e; + undefined field_0x2f; +}; + +typedef struct _wifi_item _wifi_item_t; + +typedef struct _wifi_state _wifi_state, *P_wifi_state; + +struct _wifi_state { + char ip[16]; + char gw[16]; + char mask[16]; + char ssid[32]; + char ssid_tail[1]; + uint8_t bssid[6]; + uint8_t state; +}; + +typedef struct wifi_state wifi_state, *Pwifi_state; + +struct wifi_state { + char ip[16]; + char gw[16]; + char mask[16]; + char ssid[32]; + char ssid_tail[1]; + uint8_t bssid[6]; + uint8_t state; +}; + +typedef struct blesync_wifi_item blesync_wifi_item, *Pblesync_wifi_item; + +struct blesync_wifi_item { + char ssid[32]; + uint32_t ssid_len; + uint8_t bssid[6]; + uint8_t channel; + uint8_t auth; + int8_t rssi; + undefined field_0x2d; + undefined field_0x2e; + undefined field_0x2f; +}; + +typedef struct bl_ble_sync bl_ble_sync, *Pbl_ble_sync; + +typedef struct bl_ble_sync bl_ble_sync_t; + +typedef struct queue_buf queue_buf, *Pqueue_buf; + +typedef struct blesync_wifi_func blesync_wifi_func, *Pblesync_wifi_func; + +typedef struct wifi_conn wifi_conn, *Pwifi_conn; + +typedef struct blesync_wifi_item blesync_wifi_item_t; + +struct queue_buf { + uint8_t buf[256]; + uint32_t len; +}; + +struct blesync_wifi_func { + void (* local_connect_remote_ap)(struct wifi_conn *); + void (* local_disconnect_remote_ap)(void); + void (* local_wifi_scan)(void (* )(void *)); + void (* local_wifi_state_get)(void (* )(void *)); +}; + +struct wifi_conn { + uint8_t ssid[32]; + uint8_t ssid_tail[1]; + uint8_t pask[64]; +}; + +struct bl_ble_sync { + SemaphoreHandle_t xSemaphore; + StaticSemaphore_t xSemaphoreBuffer; + struct wifi_state state; + QueueHandle_t xQueue1; + StaticQueue_t xQueueBuffer; + struct queue_buf buf[2]; + struct queue_buf send_buf; + pro_handle_t pro_handle; + void (* complete_cb)(void *); + void * p_arg; + struct blesync_wifi_func * wifi_func; + uint8_t attr_read_buf[256]; + uint8_t attr_write_buf[256]; + uint16_t rbuf_len; + uint8_t task_runing; + uint8_t scaning; + uint8_t stop_flag; + struct wifi_conn conn_info; + undefined field_0x682; + undefined field_0x683; + struct bt_conn * p_cur_conn; + StackType_t stack[512]; + StaticTask_t task; + TaskHandle_t task_handle; + undefined field_0xeec; + undefined field_0xeed; + undefined field_0xeee; + undefined field_0xeef; + struct pro_dev pro_dev; + blesync_wifi_item_t ap_item[50]; + uint8_t w_ap_item; + uint8_t r_ap_item; + undefined field_0x1902; + undefined field_0x1903; + undefined field_0x1904; + undefined field_0x1905; + undefined field_0x1906; + undefined field_0x1907; +}; + +typedef struct bl_ble_sync.conflict1 bl_ble_sync.conflict1, *Pbl_ble_sync.conflict1; + +typedef void (* pfn_complete_cb_t.conflict)(void *); + +struct bl_ble_sync.conflict1 { + SemaphoreHandle_t xSemaphore; + StaticSemaphore_t xSemaphoreBuffer; + struct wifi_state state; + QueueHandle_t xQueue1; + StaticQueue_t xQueueBuffer; + struct queue_buf buf[2]; + struct queue_buf send_buf; + pro_handle_t pro_handle; + pfn_complete_cb_t.conflict complete_cb; + void * p_arg; + struct blesync_wifi_func * wifi_func; + uint8_t attr_read_buf[256]; + uint8_t attr_write_buf[256]; + uint16_t rbuf_len; + uint8_t task_runing; + uint8_t scaning; + uint8_t stop_flag; + struct wifi_conn conn_info; + undefined field_0x682; + undefined field_0x683; + struct bt_conn * p_cur_conn; + StackType_t stack[512]; + StaticTask_t task; + TaskHandle_t task_handle; + undefined field_0xeec; + undefined field_0xeed; + undefined field_0xeee; + undefined field_0xeef; + struct pro_dev pro_dev; + blesync_wifi_item_t ap_item[50]; + uint8_t w_ap_item; + uint8_t r_ap_item; + undefined field_0x1902; + undefined field_0x1903; + undefined field_0x1904; + undefined field_0x1905; + undefined field_0x1906; + undefined field_0x1907; +}; + +typedef struct bl_ble_sync.conflict1 bl_ble_sync_t.conflict; + +typedef struct bl_ble_sync.conflict bl_ble_sync.conflict, *Pbl_ble_sync.conflict; + +struct bl_ble_sync.conflict { + SemaphoreHandle_t xSemaphore; + StaticSemaphore_t xSemaphoreBuffer; + struct wifi_state state; + QueueHandle_t xQueue1; + StaticQueue_t xQueueBuffer; + struct queue_buf buf[2]; + struct queue_buf send_buf; + pro_handle_t pro_handle; + pfn_complete_cb_t.conflict complete_cb; + void * p_arg; + struct blesync_wifi_func * wifi_func; + uint8_t attr_read_buf[256]; + uint8_t attr_write_buf[256]; + uint16_t rbuf_len; + uint8_t task_runing; + uint8_t scaning; + uint8_t stop_flag; + struct wifi_conn conn_info; + undefined field_0x682; + undefined field_0x683; + struct bt_conn * p_cur_conn; + StackType_t stack[512]; + StaticTask_t task; + TaskHandle_t task_handle; + undefined field_0xeec; + undefined field_0xeed; + undefined field_0xeee; + undefined field_0xeef; + struct pro_dev pro_dev; + blesync_wifi_item_t ap_item[50]; + uint8_t w_ap_item; + uint8_t r_ap_item; + undefined field_0x1902; + undefined field_0x1903; + undefined field_0x1904; + undefined field_0x1905; + undefined field_0x1906; + undefined field_0x1907; +}; + +typedef struct bt_mesh_prov.conflict bt_mesh_prov.conflict, *Pbt_mesh_prov.conflict; + +typedef enum bt_mesh_output_action_t { + BT_MESH_BEEP=2, + BT_MESH_BLINK=1, + BT_MESH_DISPLAY_NUMBER=8, + BT_MESH_DISPLAY_STRING=16, + BT_MESH_NO_OUTPUT=0, + BT_MESH_VIBRATE=4 +} bt_mesh_output_action_t; + +typedef enum bt_mesh_input_action_t { + BT_MESH_ENTER_NUMBER=4, + BT_MESH_ENTER_STRING=8, + BT_MESH_NO_INPUT=0, + BT_MESH_PUSH=1, + BT_MESH_TWIST=2 +} bt_mesh_input_action_t; + +typedef enum bt_mesh_prov_bearer_t { + BT_MESH_PROV_ADV=1, + BT_MESH_PROV_GATT=2 +} bt_mesh_prov_bearer_t; + +typedef enum bt_mesh_prov_oob_info_t { + BT_MESH_PROV_OOB_2D_CODE=4, + BT_MESH_PROV_OOB_BAR_CODE=8, + BT_MESH_PROV_OOB_IN_BOX=4096, + BT_MESH_PROV_OOB_IN_MANUAL=16384, + BT_MESH_PROV_OOB_NFC=16, + BT_MESH_PROV_OOB_NUMBER=32, + BT_MESH_PROV_OOB_ON_BOX=2048, + BT_MESH_PROV_OOB_ON_DEV=-32768, + BT_MESH_PROV_OOB_ON_PAPER=8192, + BT_MESH_PROV_OOB_OTHER=1, + BT_MESH_PROV_OOB_STRING=64, + BT_MESH_PROV_OOB_URI=2 +} bt_mesh_prov_oob_info_t; + +struct bt_mesh_prov.conflict { + u8_t * uuid; + char * uri; + enum bt_mesh_prov_oob_info_t oob_info; + undefined field_0xa; + undefined field_0xb; + u8_t * static_val; + u8_t static_val_len; + u8_t output_size; + u16_t output_actions; + u8_t input_size; + undefined field_0x15; + u16_t input_actions; + int (* output_number)(enum bt_mesh_output_action_t, u32_t.conflict); + int (* output_string)(char *); + int (* input)(enum bt_mesh_input_action_t, u8_t); + void (* input_complete)(void); + void (* link_open)(enum bt_mesh_prov_bearer_t); + void (* link_close)(enum bt_mesh_prov_bearer_t); + void (* complete)(u16_t, u16_t); + void (* reset)(void); +}; + +typedef struct bt_mesh_prov.conflict11 bt_mesh_prov.conflict11, *Pbt_mesh_prov.conflict11; + +struct bt_mesh_prov.conflict11 { + u8_t * uuid; + char * uri; + enum bt_mesh_prov_oob_info_t oob_info; + undefined field_0xa; + undefined field_0xb; + u8_t * static_val; + u8_t static_val_len; + u8_t output_size; + u16_t output_actions; + u8_t input_size; + undefined field_0x15; + u16_t input_actions; + int (* output_number)(enum bt_mesh_output_action_t, u32_t.conflict); + int (* output_string)(char *); + int (* input)(enum bt_mesh_input_action_t, u8_t); + void (* input_complete)(void); + void (* link_open)(enum bt_mesh_prov_bearer_t); + void (* link_close)(enum bt_mesh_prov_bearer_t); + void (* complete)(u16_t, u16_t); + void (* reset)(void); +}; + +typedef struct bt_mesh_prov.conflict10 bt_mesh_prov.conflict10, *Pbt_mesh_prov.conflict10; + +struct bt_mesh_prov.conflict10 { + u8_t * uuid; + char * uri; + enum bt_mesh_prov_oob_info_t oob_info; + undefined field_0xa; + undefined field_0xb; + u8_t * static_val; + u8_t static_val_len; + u8_t output_size; + u16_t output_actions; + u8_t input_size; + undefined field_0x15; + u16_t input_actions; + int (* output_number)(enum bt_mesh_output_action_t, u32_t.conflict); + int (* output_string)(char *); + int (* input)(enum bt_mesh_input_action_t, u8_t); + void (* input_complete)(void); + void (* link_open)(enum bt_mesh_prov_bearer_t); + void (* link_close)(enum bt_mesh_prov_bearer_t); + void (* complete)(u16_t, u16_t); + void (* reset)(void); +}; + +typedef struct bt_mesh_prov.conflict1 bt_mesh_prov.conflict1, *Pbt_mesh_prov.conflict1; + +struct bt_mesh_prov.conflict1 { + u8_t * uuid; + char * uri; + enum bt_mesh_prov_oob_info_t oob_info; + undefined field_0xa; + undefined field_0xb; + u8_t * static_val; + u8_t static_val_len; + u8_t output_size; + u16_t output_actions; + u8_t input_size; + undefined field_0x15; + u16_t input_actions; + int (* output_number)(enum bt_mesh_output_action_t, u32_t.conflict); + int (* output_string)(char *); + int (* input)(enum bt_mesh_input_action_t, u8_t); + void (* input_complete)(void); + void (* link_open)(enum bt_mesh_prov_bearer_t); + void (* link_close)(enum bt_mesh_prov_bearer_t); + void (* complete)(u16_t, u16_t); + void (* reset)(void); +}; + +typedef struct bt_mesh_prov.conflict5 bt_mesh_prov.conflict5, *Pbt_mesh_prov.conflict5; + +struct bt_mesh_prov.conflict5 { + u8_t * uuid; + char * uri; + enum bt_mesh_prov_oob_info_t oob_info; + undefined field_0xa; + undefined field_0xb; + u8_t * static_val; + u8_t static_val_len; + u8_t output_size; + u16_t output_actions; + u8_t input_size; + undefined field_0x15; + u16_t input_actions; + int (* output_number)(enum bt_mesh_output_action_t, u32_t.conflict); + int (* output_string)(char *); + int (* input)(enum bt_mesh_input_action_t, u8_t); + void (* input_complete)(void); + void (* link_open)(enum bt_mesh_prov_bearer_t); + void (* link_close)(enum bt_mesh_prov_bearer_t); + void (* complete)(u16_t, u16_t); + void (* reset)(void); +}; + +typedef struct bt_mesh_prov.conflict4 bt_mesh_prov.conflict4, *Pbt_mesh_prov.conflict4; + +struct bt_mesh_prov.conflict4 { + u8_t * uuid; + char * uri; + enum bt_mesh_prov_oob_info_t oob_info; + undefined field_0xa; + undefined field_0xb; + u8_t * static_val; + u8_t static_val_len; + u8_t output_size; + u16_t output_actions; + u8_t input_size; + undefined field_0x15; + u16_t input_actions; + int (* output_number)(enum bt_mesh_output_action_t, u32_t.conflict); + int (* output_string)(char *); + int (* input)(enum bt_mesh_input_action_t, u8_t); + void (* input_complete)(void); + void (* link_open)(enum bt_mesh_prov_bearer_t); + void (* link_close)(enum bt_mesh_prov_bearer_t); + void (* complete)(u16_t, u16_t); + void (* reset)(void); +}; + +typedef struct bt_mesh_prov.conflict3 bt_mesh_prov.conflict3, *Pbt_mesh_prov.conflict3; + +struct bt_mesh_prov.conflict3 { + u8_t * uuid; + char * uri; + enum bt_mesh_prov_oob_info_t oob_info; + undefined field_0xa; + undefined field_0xb; + u8_t * static_val; + u8_t static_val_len; + u8_t output_size; + u16_t output_actions; + u8_t input_size; + undefined field_0x15; + u16_t input_actions; + int (* output_number)(enum bt_mesh_output_action_t, u32_t.conflict); + int (* output_string)(char *); + int (* input)(enum bt_mesh_input_action_t, u8_t); + void (* input_complete)(void); + void (* link_open)(enum bt_mesh_prov_bearer_t); + void (* link_close)(enum bt_mesh_prov_bearer_t); + void (* complete)(u16_t, u16_t); + void (* reset)(void); +}; + +typedef struct bt_mesh_prov.conflict2 bt_mesh_prov.conflict2, *Pbt_mesh_prov.conflict2; + +struct bt_mesh_prov.conflict2 { + u8_t * uuid; + char * uri; + enum bt_mesh_prov_oob_info_t oob_info; + undefined field_0xa; + undefined field_0xb; + u8_t * static_val; + u8_t static_val_len; + u8_t output_size; + u16_t output_actions; + u8_t input_size; + undefined field_0x15; + u16_t input_actions; + int (* output_number)(enum bt_mesh_output_action_t, u32_t.conflict); + int (* output_string)(char *); + int (* input)(enum bt_mesh_input_action_t, u8_t); + void (* input_complete)(void); + void (* link_open)(enum bt_mesh_prov_bearer_t); + void (* link_close)(enum bt_mesh_prov_bearer_t); + void (* complete)(u16_t, u16_t); + void (* reset)(void); +}; + +typedef struct bt_mesh_prov.conflict9 bt_mesh_prov.conflict9, *Pbt_mesh_prov.conflict9; + +struct bt_mesh_prov.conflict9 { + u8_t * uuid; + char * uri; + enum bt_mesh_prov_oob_info_t oob_info; + undefined field_0xa; + undefined field_0xb; + u8_t * static_val; + u8_t static_val_len; + u8_t output_size; + u16_t output_actions; + u8_t input_size; + undefined field_0x15; + u16_t input_actions; + int (* output_number)(enum bt_mesh_output_action_t, u32_t.conflict); + int (* output_string)(char *); + int (* input)(enum bt_mesh_input_action_t, u8_t); + void (* input_complete)(void); + void (* link_open)(enum bt_mesh_prov_bearer_t); + void (* link_close)(enum bt_mesh_prov_bearer_t); + void (* complete)(u16_t, u16_t); + void (* reset)(void); +}; + +typedef struct bt_mesh_prov.conflict8 bt_mesh_prov.conflict8, *Pbt_mesh_prov.conflict8; + +struct bt_mesh_prov.conflict8 { + u8_t * uuid; + char * uri; + enum bt_mesh_prov_oob_info_t oob_info; + undefined field_0xa; + undefined field_0xb; + u8_t * static_val; + u8_t static_val_len; + u8_t output_size; + u16_t output_actions; + u8_t input_size; + undefined field_0x15; + u16_t input_actions; + int (* output_number)(enum bt_mesh_output_action_t, u32_t.conflict); + int (* output_string)(char *); + int (* input)(enum bt_mesh_input_action_t, u8_t); + void (* input_complete)(void); + void (* link_open)(enum bt_mesh_prov_bearer_t); + void (* link_close)(enum bt_mesh_prov_bearer_t); + void (* complete)(u16_t, u16_t); + void (* reset)(void); +}; + +typedef struct bt_mesh_prov.conflict7 bt_mesh_prov.conflict7, *Pbt_mesh_prov.conflict7; + +struct bt_mesh_prov.conflict7 { + u8_t * uuid; + char * uri; + enum bt_mesh_prov_oob_info_t oob_info; + undefined field_0xa; + undefined field_0xb; + u8_t * static_val; + u8_t static_val_len; + u8_t output_size; + u16_t output_actions; + u8_t input_size; + undefined field_0x15; + u16_t input_actions; + int (* output_number)(enum bt_mesh_output_action_t, u32_t.conflict); + int (* output_string)(char *); + int (* input)(enum bt_mesh_input_action_t, u8_t); + void (* input_complete)(void); + void (* link_open)(enum bt_mesh_prov_bearer_t); + void (* link_close)(enum bt_mesh_prov_bearer_t); + void (* complete)(u16_t, u16_t); + void (* reset)(void); +}; + +typedef struct bt_mesh_prov.conflict6 bt_mesh_prov.conflict6, *Pbt_mesh_prov.conflict6; + +struct bt_mesh_prov.conflict6 { + u8_t * uuid; + char * uri; + enum bt_mesh_prov_oob_info_t oob_info; + undefined field_0xa; + undefined field_0xb; + u8_t * static_val; + u8_t static_val_len; + u8_t output_size; + u16_t output_actions; + u8_t input_size; + undefined field_0x15; + u16_t input_actions; + int (* output_number)(enum bt_mesh_output_action_t, u32_t.conflict); + int (* output_string)(char *); + int (* input)(enum bt_mesh_input_action_t, u8_t); + void (* input_complete)(void); + void (* link_open)(enum bt_mesh_prov_bearer_t); + void (* link_close)(enum bt_mesh_prov_bearer_t); + void (* complete)(u16_t, u16_t); + void (* reset)(void); +}; + +typedef struct bt_mesh_prov bt_mesh_prov, *Pbt_mesh_prov; + +struct bt_mesh_prov { + u8_t * uuid; + char * uri; + enum bt_mesh_prov_oob_info_t oob_info; + undefined field_0xa; + undefined field_0xb; + u8_t * static_val; + u8_t static_val_len; + u8_t output_size; + u16_t output_actions; + u8_t input_size; + undefined field_0x15; + u16_t input_actions; + int (* output_number)(enum bt_mesh_output_action_t, u32_t.conflict); + int (* output_string)(char *); + int (* input)(enum bt_mesh_input_action_t, u8_t); + void (* input_complete)(void); + void (* link_open)(enum bt_mesh_prov_bearer_t); + void (* link_close)(enum bt_mesh_prov_bearer_t); + void (* complete)(u16_t, u16_t); + void (* reset)(void); +}; + +typedef struct bt_mesh_ctl_friend_update bt_mesh_ctl_friend_update, *Pbt_mesh_ctl_friend_update; + +struct bt_mesh_ctl_friend_update { + u8_t flags; + u32_t.conflict iv_index; + u8_t md; +}; + +typedef struct bt_mesh_ctl_friend_sub bt_mesh_ctl_friend_sub, *Pbt_mesh_ctl_friend_sub; + +struct bt_mesh_ctl_friend_sub { + u8_t xact; + u16_t addr_list[5]; +}; + +typedef struct bt_mesh_ctl_friend_sub_confirm bt_mesh_ctl_friend_sub_confirm, *Pbt_mesh_ctl_friend_sub_confirm; + +struct bt_mesh_ctl_friend_sub_confirm { + u8_t xact; +}; + +typedef struct bt_mesh_ctl_friend_poll bt_mesh_ctl_friend_poll, *Pbt_mesh_ctl_friend_poll; + +struct bt_mesh_ctl_friend_poll { + u8_t fsn; +}; + +typedef struct bt_mesh_ctl_friend_req bt_mesh_ctl_friend_req, *Pbt_mesh_ctl_friend_req; + +struct bt_mesh_ctl_friend_req { + u8_t criteria; + u8_t recv_delay; + u8_t poll_to[3]; + u16_t prev_addr; + u8_t num_elem; + u16_t lpn_counter; +}; + +typedef struct bt_mesh_ctl_friend_clear_confirm bt_mesh_ctl_friend_clear_confirm, *Pbt_mesh_ctl_friend_clear_confirm; + +struct bt_mesh_ctl_friend_clear_confirm { + u16_t lpn_addr; + u16_t lpn_counter; +}; + +typedef struct bt_mesh_ctl_friend_clear bt_mesh_ctl_friend_clear, *Pbt_mesh_ctl_friend_clear; + +struct bt_mesh_ctl_friend_clear { + u16_t lpn_addr; + u16_t lpn_counter; +}; + +typedef struct bt_mesh_ctl_friend_offer bt_mesh_ctl_friend_offer, *Pbt_mesh_ctl_friend_offer; + +struct bt_mesh_ctl_friend_offer { + u8_t recv_win; + u8_t queue_size; + u8_t sub_list_size; + s8_t rssi; + u16_t frnd_counter; +}; + +typedef enum ps_dpsm_state_bit_pos { + PS_DPSM_STATE_ON=0, + PS_DPSM_STATE_PAUSE=3, + PS_DPSM_STATE_PAUSING=1, + PS_DPSM_STATE_RESUMING=2, + PS_DPSM_STATE_SET_MODE_REQ=4 +} ps_dpsm_state_bit_pos; + +typedef struct ps_env_tag ps_env_tag, *Pps_env_tag; + +struct ps_env_tag { + _Bool ps_on; + undefined field_0x1; + ke_task_id_t taskid; + uint32_t prevent_sleep; + uint8_t cfm_cnt; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + struct mm_timer_tag uapsd_timer; + _Bool uapsd_tmr_on; + _Bool uapsd_on; + undefined field_0x1e; + undefined field_0x1f; + uint32_t uapsd_timeout; + uint8_t dpsm_state; + uint8_t next_mode; + undefined field_0x26; + undefined field_0x27; +}; + +typedef struct mbedtls_oid_descriptor_t mbedtls_oid_descriptor_t, *Pmbedtls_oid_descriptor_t; + +struct mbedtls_oid_descriptor_t { + char * asn1; + size_t asn1_len; + char * name; + char * description; +}; + +typedef struct HeapRegion HeapRegion, *PHeapRegion; + +struct HeapRegion { + uint8_t * pucStartAddress; + size_t xSizeInBytes; +}; + +typedef struct HeapRegion HeapRegion_t; + +typedef struct anon_struct.conflict193 anon_struct.conflict193, *Panon_struct.conflict193; + +typedef struct anon_struct.conflict193 wpa_suite_ucast_t; + +typedef struct _wpa_suite_t _wpa_suite_t, *P_wpa_suite_t; + +typedef struct _wpa_suite_t wpa_suite; + +struct _wpa_suite_t { + uint8_t oui[3]; + uint8_t type; +}; + +struct anon_struct.conflict193 { + uint16_t count; + wpa_suite list[2]; +}; + +typedef struct anon_struct.conflict194 anon_struct.conflict194, *Panon_struct.conflict194; + +typedef struct anon_struct.conflict194 wpa_suite_auth_key_mgmt_t; + +struct anon_struct.conflict194 { + uint16_t count; + wpa_suite list[2]; +}; + +typedef struct _IEEEtypes_Rsn_t _IEEEtypes_Rsn_t, *P_IEEEtypes_Rsn_t; + +typedef struct _wpa_suite_t wpa_suite_mcast_t; + +struct _IEEEtypes_Rsn_t { + uint8_t element_id; + uint8_t len; + uint16_t version; + wpa_suite_mcast_t group_cipher; + wpa_suite_ucast_t pairwise_cipher; + wpa_suite_auth_key_mgmt_t auth_key_mgmt; +}; + +typedef struct anon_struct.conflict192 anon_struct.conflict192, *Panon_struct.conflict192; + +struct anon_struct.conflict192 { + uint16_t count; + wpa_suite list[2]; +}; + +typedef struct _IEEEtypes_Wpa_t _IEEEtypes_Wpa_t, *P_IEEEtypes_Wpa_t; + +typedef struct _IEEEtypes_Wpa_t IEEEtypes_Wpa_t; + +struct _IEEEtypes_Wpa_t { + uint8_t element_id; + uint8_t len; + uint8_t oui[4]; + uint16_t version; + wpa_suite_mcast_t group_cipher; + wpa_suite_ucast_t pairwise_cipher; + wpa_suite_auth_key_mgmt_t auth_key_mgmt; +}; + +typedef struct _IEEEtypes_Rsn_t IEEEtypes_Rsn_t; + +typedef struct wifi_ap_data_rate wifi_ap_data_rate, *Pwifi_ap_data_rate; + +struct wifi_ap_data_rate { + uint8_t data_rate; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + char * val; +}; + +typedef struct netif.conflict71 netif.conflict71, *Pnetif.conflict71; + +struct netif.conflict71 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict72 netif.conflict72, *Pnetif.conflict72; + +struct netif.conflict72 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict73 netif.conflict73, *Pnetif.conflict73; + +struct netif.conflict73 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict74 netif.conflict74, *Pnetif.conflict74; + +struct netif.conflict74 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict68 netif.conflict68, *Pnetif.conflict68; + +struct netif.conflict68 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict69 netif.conflict69, *Pnetif.conflict69; + +struct netif.conflict69 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict64 netif.conflict64, *Pnetif.conflict64; + +struct netif.conflict64 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict65 netif.conflict65, *Pnetif.conflict65; + +struct netif.conflict65 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict66 netif.conflict66, *Pnetif.conflict66; + +struct netif.conflict66 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict67 netif.conflict67, *Pnetif.conflict67; + +struct netif.conflict67 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict60 netif.conflict60, *Pnetif.conflict60; + +struct netif.conflict60 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict61 netif.conflict61, *Pnetif.conflict61; + +struct netif.conflict61 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict62 netif.conflict62, *Pnetif.conflict62; + +struct netif.conflict62 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict63 netif.conflict63, *Pnetif.conflict63; + +struct netif.conflict63 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict70 netif.conflict70, *Pnetif.conflict70; + +struct netif.conflict70 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef u8_t netif_addr_idx_t; + +typedef void (* netif_status_callback_fn.conflict)(struct netif *); + +typedef struct netif.conflict18 netif.conflict18, *Pnetif.conflict18; + +struct netif.conflict18 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict10 netif.conflict10, *Pnetif.conflict10; + +struct netif.conflict10 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef enum lwip_internal_netif_client_data_index { + LWIP_NETIF_CLIENT_DATA_INDEX_DHCP=0, + LWIP_NETIF_CLIENT_DATA_INDEX_IGMP=1, + LWIP_NETIF_CLIENT_DATA_INDEX_MAX=2 +} lwip_internal_netif_client_data_index; + +typedef struct netif.conflict netif.conflict, *Pnetif.conflict; + +struct netif.conflict { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict39 netif.conflict39, *Pnetif.conflict39; + +struct netif.conflict39 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict37 netif.conflict37, *Pnetif.conflict37; + +struct netif.conflict37 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict38 netif.conflict38, *Pnetif.conflict38; + +struct netif.conflict38 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict30 netif.conflict30, *Pnetif.conflict30; + +struct netif.conflict30 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict3 netif.conflict3, *Pnetif.conflict3; + +struct netif.conflict3 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict2 netif.conflict2, *Pnetif.conflict2; + +struct netif.conflict2 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict4 netif.conflict4, *Pnetif.conflict4; + +struct netif.conflict4 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict24 netif.conflict24, *Pnetif.conflict24; + +struct netif.conflict24 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict1 netif.conflict1, *Pnetif.conflict1; + +struct netif.conflict1 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict57 netif.conflict57, *Pnetif.conflict57; + +struct netif.conflict57 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict58 netif.conflict58, *Pnetif.conflict58; + +struct netif.conflict58 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict59 netif.conflict59, *Pnetif.conflict59; + +struct netif.conflict59 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict53 netif.conflict53, *Pnetif.conflict53; + +struct netif.conflict53 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict54 netif.conflict54, *Pnetif.conflict54; + +struct netif.conflict54 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict55 netif.conflict55, *Pnetif.conflict55; + +struct netif.conflict55 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict56 netif.conflict56, *Pnetif.conflict56; + +struct netif.conflict56 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict50 netif.conflict50, *Pnetif.conflict50; + +struct netif.conflict50 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict51 netif.conflict51, *Pnetif.conflict51; + +struct netif.conflict51 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict52 netif.conflict52, *Pnetif.conflict52; + +struct netif.conflict52 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict46 netif.conflict46, *Pnetif.conflict46; + +struct netif.conflict46 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict47 netif.conflict47, *Pnetif.conflict47; + +struct netif.conflict47 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict48 netif.conflict48, *Pnetif.conflict48; + +struct netif.conflict48 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict49 netif.conflict49, *Pnetif.conflict49; + +struct netif.conflict49 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict42 netif.conflict42, *Pnetif.conflict42; + +struct netif.conflict42 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict43 netif.conflict43, *Pnetif.conflict43; + +struct netif.conflict43 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict44 netif.conflict44, *Pnetif.conflict44; + +struct netif.conflict44 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict45 netif.conflict45, *Pnetif.conflict45; + +struct netif.conflict45 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict40 netif.conflict40, *Pnetif.conflict40; + +struct netif.conflict40 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + netif_status_callback_fn.conflict status_callback; + netif_status_callback_fn.conflict link_callback; + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict41 netif.conflict41, *Pnetif.conflict41; + +struct netif.conflict41 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct seg_rx seg_rx, *Pseg_rx; + +struct seg_rx { + struct bt_mesh_subnet * sub; + undefined field_0x4; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + u64_t seq_auth; + u8_t seg_n:5; + u8_t ctl:1; + u8_t in_use:1; + u8_t obo:1; + u8_t hdr; + u8_t ttl; + undefined field_0x13; + u16_t src; + u16_t dst; + u32_t.conflict block; + u32_t.conflict last; + struct k_delayed_work ack; + struct net_buf_simple buf; +}; + +typedef struct seg_rx.conflict1 seg_rx.conflict1, *Pseg_rx.conflict1; + +struct seg_rx.conflict1 { + struct bt_mesh_subnet * sub; + undefined field_0x4; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + u64_t seq_auth; + u8_t seg_n:5; + u8_t ctl:1; + u8_t in_use:1; + u8_t obo:1; + u8_t hdr; + u8_t ttl; + undefined field_0x13; + u16_t src; + u16_t dst; + u32_t.conflict block; + u32_t.conflict last; + struct k_delayed_work ack; + struct net_buf_simple buf; +}; + +typedef struct seg_rx.conflict seg_rx.conflict, *Pseg_rx.conflict; + +struct seg_rx.conflict { + struct bt_mesh_subnet * sub; + undefined field_0x4; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + u64_t seq_auth; + u8_t seg_n:5; + u8_t ctl:1; + u8_t in_use:1; + u8_t obo:1; + u8_t hdr; + u8_t ttl; + undefined field_0x13; + u16_t src; + u16_t dst; + u32_t.conflict block; + u32_t.conflict last; + struct k_delayed_work ack; + struct net_buf_simple buf; +}; + +typedef struct seg_tx.conflict1 seg_tx.conflict1, *Pseg_tx.conflict1; + +struct seg_tx.conflict1 { + struct bt_mesh_subnet * sub; + struct net_buf * seg[6]; + undefined field_0x1c; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; + u64_t seq_auth; + u16_t dst; + u8_t seg_n:5; + u8_t new_key:1; + u8_t nack_count; + u8_t ttl; + undefined field_0x2d; + undefined field_0x2e; + undefined field_0x2f; + struct bt_mesh_send_cb * cb; + void * cb_data; + struct k_delayed_work retransmit; + undefined field_0x5c; + undefined field_0x5d; + undefined field_0x5e; + undefined field_0x5f; +}; + +typedef struct seg_tx seg_tx, *Pseg_tx; + +struct seg_tx { + struct bt_mesh_subnet * sub; + struct net_buf * seg[6]; + undefined field_0x1c; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; + u64_t seq_auth; + u16_t dst; + u8_t seg_n:5; + u8_t new_key:1; + u8_t nack_count; + u8_t ttl; + undefined field_0x2d; + undefined field_0x2e; + undefined field_0x2f; + struct bt_mesh_send_cb * cb; + void * cb_data; + struct k_delayed_work retransmit; + undefined field_0x5c; + undefined field_0x5d; + undefined field_0x5e; + undefined field_0x5f; +}; + +typedef struct seg_tx.conflict seg_tx.conflict, *Pseg_tx.conflict; + +struct seg_tx.conflict { + struct bt_mesh_subnet * sub; + struct net_buf * seg[6]; + undefined field_0x1c; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; + u64_t seq_auth; + u16_t dst; + u8_t seg_n:5; + u8_t new_key:1; + u8_t nack_count; + u8_t ttl; + undefined field_0x2d; + undefined field_0x2e; + undefined field_0x2f; + struct bt_mesh_send_cb * cb; + void * cb_data; + struct k_delayed_work retransmit; + undefined field_0x5c; + undefined field_0x5d; + undefined field_0x5e; + undefined field_0x5f; +}; + +typedef struct anon_struct_for_hb anon_struct_for_hb, *Panon_struct_for_hb; + +struct anon_struct_for_hb { + u8_t init_ttl; + u16_t feat; +}; + +typedef struct rxl_cntrl_env_tag rxl_cntrl_env_tag, *Prxl_cntrl_env_tag; + +struct rxl_cntrl_env_tag { + struct co_list ready; + struct rx_dmadesc * first; + struct rx_dmadesc * last; + struct rx_dmadesc * free; + uint32_t packet_stack_cnt; +}; + +typedef struct counter_fc counter_fc, *Pcounter_fc; + +struct counter_fc { + uint16_t acl_pkt_sent; +}; + +typedef struct host_set_fc host_set_fc, *Phost_set_fc; + +struct host_set_fc { + _Bool acl_flow_cntl_en; + undefined field_0x1; + uint16_t acl_pkt_len; + uint16_t acl_pkt_nb; + uint16_t curr_pkt_nb; +}; + +typedef struct hci_fc_tag hci_fc_tag, *Phci_fc_tag; + +struct hci_fc_tag { + struct host_set_fc host_set; + struct counter_fc cntr; +}; + +typedef struct GLB_GPIO_Cfg_Type GLB_GPIO_Cfg_Type, *PGLB_GPIO_Cfg_Type; + +struct GLB_GPIO_Cfg_Type { + uint8_t gpioPin; + uint8_t gpioFun; + uint8_t gpioMode; + uint8_t pullType; + uint8_t drive; + uint8_t smtCtrl; +}; + +typedef enum GLB_GPIO_FUNC_Type { + GPIO_FUN_ANALOG=10, + GPIO_FUN_EXT_PA=9, + GPIO_FUN_FLASH=2, + GPIO_FUN_I2C=6, + GPIO_FUN_JTAG=14, + GPIO_FUN_PWM=8, + GPIO_FUN_SDIO=1, + GPIO_FUN_SPI=4, + GPIO_FUN_SWGPIO=11, + GPIO_FUN_UART=7 +} GLB_GPIO_FUNC_Type; + +typedef enum GLB_GPIO_Type { + GLB_GPIO_PIN_0=0, + GLB_GPIO_PIN_1=1, + GLB_GPIO_PIN_10=10, + GLB_GPIO_PIN_11=11, + GLB_GPIO_PIN_12=12, + GLB_GPIO_PIN_13=13, + GLB_GPIO_PIN_14=14, + GLB_GPIO_PIN_15=15, + GLB_GPIO_PIN_16=16, + GLB_GPIO_PIN_17=17, + GLB_GPIO_PIN_18=18, + GLB_GPIO_PIN_19=19, + GLB_GPIO_PIN_2=2, + GLB_GPIO_PIN_20=20, + GLB_GPIO_PIN_21=21, + GLB_GPIO_PIN_22=22, + GLB_GPIO_PIN_3=3, + GLB_GPIO_PIN_4=4, + GLB_GPIO_PIN_5=5, + GLB_GPIO_PIN_6=6, + GLB_GPIO_PIN_7=7, + GLB_GPIO_PIN_8=8, + GLB_GPIO_PIN_9=9, + GLB_GPIO_PIN_MAX=23 +} GLB_GPIO_Type; + +typedef struct txl_buffer_list_tag txl_buffer_list_tag, *Ptxl_buffer_list_tag; + +struct txl_buffer_list_tag { + struct txl_buffer_tag * first; + struct txl_buffer_tag * last; +}; + +typedef union anon_union.conflict99 anon_union.conflict99, *Panon_union.conflict99; + +union anon_union.conflict99 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict133 anon_union.conflict133, *Panon_union.conflict133; + +union anon_union.conflict133 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict18 anon_union.conflict18, *Panon_union.conflict18; + +union anon_union.conflict18 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict128 anon_union.conflict128, *Panon_union.conflict128; + +union anon_union.conflict128 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef struct txl_buffer_idx_tag txl_buffer_idx_tag, *Ptxl_buffer_idx_tag; + +typedef struct txl_buffer_hw_desc_tag txl_buffer_hw_desc_tag, *Ptxl_buffer_hw_desc_tag; + +struct txl_buffer_hw_desc_tag { + struct dma_desc dma_desc; + struct tx_pbd pbd; +}; + +struct txl_buffer_idx_tag { + uint32_t used_area; + uint32_t free; + uint32_t free_size; + uint32_t last; + uint32_t next_needed; + uint32_t buf_size; + uint32_t * pool; + struct txl_buffer_hw_desc_tag * desc; + uint8_t count; + undefined field_0x21; + undefined field_0x22; + undefined field_0x23; +}; + +typedef union anon_union.conflict121 anon_union.conflict121, *Panon_union.conflict121; + +union anon_union.conflict121 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict26 anon_union.conflict26, *Panon_union.conflict26; + +union anon_union.conflict26 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict114 anon_union.conflict114, *Panon_union.conflict114; + +union anon_union.conflict114 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict33 anon_union.conflict33, *Panon_union.conflict33; + +union anon_union.conflict33 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict107 anon_union.conflict107, *Panon_union.conflict107; + +union anon_union.conflict107 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict47 anon_union.conflict47, *Panon_union.conflict47; + +union anon_union.conflict47 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict188 anon_union.conflict188, *Panon_union.conflict188; + +union anon_union.conflict188 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict182 anon_union.conflict182, *Panon_union.conflict182; + +union anon_union.conflict182 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict174 anon_union.conflict174, *Panon_union.conflict174; + +union anon_union.conflict174 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict57 anon_union.conflict57, *Panon_union.conflict57; + +union anon_union.conflict57 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef struct txl_buffer_env_tag txl_buffer_env_tag, *Ptxl_buffer_env_tag; + +struct txl_buffer_env_tag { + struct txl_buffer_idx_tag buf_idx[5][1]; + struct txl_buffer_list_tag list[5]; +}; + +typedef union anon_union.conflict71 anon_union.conflict71, *Panon_union.conflict71; + +union anon_union.conflict71 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict64 anon_union.conflict64, *Panon_union.conflict64; + +union anon_union.conflict64 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict167 anon_union.conflict167, *Panon_union.conflict167; + +union anon_union.conflict167 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict160 anon_union.conflict160, *Panon_union.conflict160; + +union anon_union.conflict160 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict78 anon_union.conflict78, *Panon_union.conflict78; + +union anon_union.conflict78 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict155 anon_union.conflict155, *Panon_union.conflict155; + +union anon_union.conflict155 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict148 anon_union.conflict148, *Panon_union.conflict148; + +union anon_union.conflict148 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict92 anon_union.conflict92, *Panon_union.conflict92; + +union anon_union.conflict92 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict85 anon_union.conflict85, *Panon_union.conflict85; + +union anon_union.conflict85 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef struct oid_x520_attr_t oid_x520_attr_t, *Poid_x520_attr_t; + +struct oid_x520_attr_t { + struct mbedtls_oid_descriptor_t descriptor; + char * short_name; +}; + +typedef struct oid_x509_ext_t oid_x509_ext_t, *Poid_x509_ext_t; + +struct oid_x509_ext_t { + struct mbedtls_oid_descriptor_t descriptor; + int ext_type; +}; + +typedef struct oid_md_alg_t oid_md_alg_t, *Poid_md_alg_t; + +struct oid_md_alg_t { + struct mbedtls_oid_descriptor_t descriptor; + enum mbedtls_md_type_t md_alg; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct oid_sig_alg_t oid_sig_alg_t, *Poid_sig_alg_t; + +struct oid_sig_alg_t { + struct mbedtls_oid_descriptor_t descriptor; + enum mbedtls_md_type_t md_alg; + enum mbedtls_pk_type_t pk_alg; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct oid_cipher_alg_t oid_cipher_alg_t, *Poid_cipher_alg_t; + +struct oid_cipher_alg_t { + struct mbedtls_oid_descriptor_t descriptor; + enum mbedtls_cipher_type_t cipher_alg; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct oid_ecp_grp_t oid_ecp_grp_t, *Poid_ecp_grp_t; + +struct oid_ecp_grp_t { + struct mbedtls_oid_descriptor_t descriptor; + enum mbedtls_ecp_group_id grp_id; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct oid_pk_alg_t oid_pk_alg_t, *Poid_pk_alg_t; + +struct oid_pk_alg_t { + struct mbedtls_oid_descriptor_t descriptor; + enum mbedtls_pk_type_t pk_alg; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct PDS_CTL2_Type PDS_CTL2_Type, *PPDS_CTL2_Type; + +struct PDS_CTL2_Type { + uint32_t forceCpuPwrOff:1; + uint32_t rsv1:1; + uint32_t forceWbPwrOff:1; + uint32_t rsv3:1; + uint32_t forceCpuIsoPwrOff:1; + uint32_t rsv5:1; + uint32_t forceWbIsoPwrOff:1; + uint32_t rsv7:1; + uint32_t forceCpuPdsRst:1; + uint32_t rsv9:1; + uint32_t forceWbPdsRst:1; + uint32_t rsv11:1; + uint32_t forceCpuMemStby:1; + uint32_t rsv13:1; + uint32_t forceWbMemStby:1; + uint32_t rsv15:1; + uint32_t forceCpuGateClk:1; + uint32_t rsv17:1; + uint32_t forceWbGateClk:1; + uint32_t rsv19_31:12; +}; + +typedef enum PDS_PLL_CLK_Type { + PDS_PLL_CLK_120M=4, + PDS_PLL_CLK_160M=3, + PDS_PLL_CLK_192M=2, + PDS_PLL_CLK_240M=1, + PDS_PLL_CLK_32M=8, + PDS_PLL_CLK_480M=0, + PDS_PLL_CLK_48M=7, + PDS_PLL_CLK_80M=6, + PDS_PLL_CLK_96M=5 +} PDS_PLL_CLK_Type; + +typedef struct PDS_DEFAULT_LV_CFG_Type PDS_DEFAULT_LV_CFG_Type, *PPDS_DEFAULT_LV_CFG_Type; + +typedef struct PDS_CTL_Type PDS_CTL_Type, *PPDS_CTL_Type; + +typedef struct PDS_CTL3_Type PDS_CTL3_Type, *PPDS_CTL3_Type; + +typedef struct PDS_CTL4_Type PDS_CTL4_Type, *PPDS_CTL4_Type; + +struct PDS_CTL3_Type { + uint32_t rsv0:1; + uint32_t forceMiscPwrOff:1; + uint32_t rsv2_3:2; + uint32_t forceMiscIsoEn:1; + uint32_t rsv5_6:2; + uint32_t forceMiscPdsRst:1; + uint32_t rsv8_9:2; + uint32_t forceMiscMemStby:1; + uint32_t rsv11_12:2; + uint32_t forceMiscGateClk:1; + uint32_t rsv14_23:10; + uint32_t CpuIsoEn:1; + uint32_t rsv25_26:2; + uint32_t WbIsoEn:1; + uint32_t rsv28_29:2; + uint32_t MiscIsoEn:1; + uint32_t rsv31:1; +}; + +struct PDS_CTL4_Type { + uint32_t cpuPwrOff:1; + uint32_t cpuRst:1; + uint32_t cpuMemStby:1; + uint32_t cpuGateClk:1; + uint32_t rsv4_11:8; + uint32_t WbPwrOff:1; + uint32_t WbRst:1; + uint32_t WbMemStby:1; + uint32_t WbGateClk:1; + uint32_t rsv16_23:8; + uint32_t MiscPwrOff:1; + uint32_t MiscRst:1; + uint32_t MiscMemStby:1; + uint32_t MiscGateClk:1; + uint32_t rsv28_31:4; +}; + +struct PDS_CTL_Type { + uint32_t pdsStart:1; + uint32_t sleepForever:1; + uint32_t xtalForceOff:1; + uint32_t saveWiFiState:1; + uint32_t dcdc18Off:1; + uint32_t bgSysOff:1; + uint32_t rsv6_7:2; + uint32_t clkOff:1; + uint32_t memStby:1; + uint32_t rsv10:1; + uint32_t isolation:1; + uint32_t waitXtalRdy:1; + uint32_t pdsPwrOff:1; + uint32_t xtalOff:1; + uint32_t socEnbForceOn:1; + uint32_t pdsRstSocEn:1; + uint32_t pdsRC32mOn:1; + uint32_t pdsLdoVselEn:1; + uint32_t rsv19_20:2; + uint32_t wfiMask:1; + uint32_t ldo11Off:1; + uint32_t rsv23:1; + uint32_t pdsLdoVol:4; + uint32_t pdsCtlRfSel:2; + uint32_t pdsCtlPllSel:2; +}; + +struct PDS_DEFAULT_LV_CFG_Type { + struct PDS_CTL_Type pdsCtl; + struct PDS_CTL2_Type pdsCtl2; + struct PDS_CTL3_Type pdsCtl3; + struct PDS_CTL4_Type pdsCtl4; +}; + +typedef struct PDS_RAM_CFG_Type PDS_RAM_CFG_Type, *PPDS_RAM_CFG_Type; + +struct PDS_RAM_CFG_Type { + uint32_t PDS_RAM_CFG_0KB_16KB_CPU_RAM_RET:1; + uint32_t PDS_RAM_CFG_16KB_32KB_CPU_RAM_RET:1; + uint32_t PDS_RAM_CFG_32KB_48KB_CPU_RAM_RET:1; + uint32_t PDS_RAM_CFG_48KB_64KB_CPU_RAM_RET:1; + uint32_t PDS_RAM_CFG_0KB_16KB_CPU_RAM_SLP:1; + uint32_t PDS_RAM_CFG_16KB_32KB_CPU_RAM_SLP:1; + uint32_t PDS_RAM_CFG_32KB_48KB_CPU_RAM_SLP:1; + uint32_t PDS_RAM_CFG_48KB_64KB_CPU_RAM_SLP:1; + uint32_t PDS_RAM_CFG_RSV:24; +}; + +typedef enum PDS_PLL_XTAL_Type { + PDS_PLL_XTAL_24M=1, + PDS_PLL_XTAL_26M=5, + PDS_PLL_XTAL_32M=2, + PDS_PLL_XTAL_38P4M=3, + PDS_PLL_XTAL_40M=4, + PDS_PLL_XTAL_NONE=0, + PDS_PLL_XTAL_RC32M=6 +} PDS_PLL_XTAL_Type; + +typedef struct x509_crt_verify_string x509_crt_verify_string, *Px509_crt_verify_string; + +struct x509_crt_verify_string { + int code; + char * string; +}; + +typedef uintptr_t insn_t; + +typedef struct key_MgtMaterial_t key_MgtMaterial_t, *Pkey_MgtMaterial_t; + +typedef union anon_union_for_keyEncypt anon_union_for_keyEncypt, *Panon_union_for_keyEncypt; + +typedef struct key_Type_TKIP_t key_Type_TKIP_t, *Pkey_Type_TKIP_t; + +typedef struct key_Type_AES_t key_Type_AES_t, *Pkey_Type_AES_t; + +typedef struct key_Type_WEP_t key_Type_WEP_t, *Pkey_Type_WEP_t; + +typedef struct key_Type_WAPI_t key_Type_WAPI_t, *Pkey_Type_WAPI_t; + +typedef struct key_Type_AES_CMAC_t key_Type_AES_CMAC_t, *Pkey_Type_AES_CMAC_t; + +struct key_Type_WEP_t { + UINT8 keyIndex; + UINT8 isDefaultTx; + UINT8 key[13]; +}; + +struct key_Type_WAPI_t { + UINT8 keyIndex; + UINT8 isDefKey; + UINT8 key[16]; + UINT8 mickey[16]; + UINT8 rxPN[16]; +}; + +struct key_Type_TKIP_t { + UINT8 key[16]; + UINT8 txMicKey[8]; + UINT8 rxMicKey[8]; +}; + +struct key_Type_AES_CMAC_t { + UINT8 ipn[6]; + UINT8 reserved[2]; + UINT8 key[16]; +}; + +struct key_Type_AES_t { + UINT8 key[16]; +}; + +union anon_union_for_keyEncypt { + struct key_Type_TKIP_t TKIP; + struct key_Type_AES_t AES1; + struct key_Type_WEP_t WEP; + struct key_Type_WAPI_t WAPI; + struct key_Type_AES_CMAC_t iGTK; +}; + +struct key_MgtMaterial_t { + UINT16 keyType; + UINT16 keyInfo; + UINT16 keyLen; + union anon_union_for_keyEncypt keyEncypt; +}; + +typedef union anon_union.conflict37 anon_union.conflict37, *Panon_union.conflict37; + +union anon_union.conflict37 { + struct key_Type_TKIP_t TKIP; + struct key_Type_AES_t AES1; + struct key_Type_WEP_t WEP; + struct key_Type_WAPI_t WAPI; + struct key_Type_AES_CMAC_t iGTK; +}; + +typedef uint hashval_t; + +typedef struct rd_env_tag rd_env_tag, *Prd_env_tag; + +struct rd_env_tag { + struct co_list event_free_list; +}; + +typedef enum GLB_DIG_CLK_Type { + GLB_DIG_CLK_PLL_32M=0, + GLB_DIG_CLK_XCLK=1 +} GLB_DIG_CLK_Type; + +typedef enum BMX_BUS_ERR_Type { + BMX_BUS_ERR_ADDR_DECODE=1, + BMX_BUS_ERR_TRUSTZONE_DECODE=0 +} BMX_BUS_ERR_Type; + +typedef enum GLB_SPI_PAD_ACT_AS_Type { + GLB_SPI_PAD_ACT_AS_MASTER=1, + GLB_SPI_PAD_ACT_AS_SLAVE=0 +} GLB_SPI_PAD_ACT_AS_Type; + +typedef enum GLB_EM_Type { + GLB_EM_0KB=0, + GLB_EM_16KB=15, + GLB_EM_8KB=3 +} GLB_EM_Type; + +typedef enum BMX_ERR_INT_Type { + BMX_ERR_INT_ALL=1, + BMX_ERR_INT_ERR=0 +} BMX_ERR_INT_Type; + +typedef struct BMX_Cfg_Type BMX_Cfg_Type, *PBMX_Cfg_Type; + +typedef enum BMX_ARB_Type { + BMX_ARB_FIX=0, + BMX_ARB_RANDOM=2, + BMX_ARB_ROUND_ROBIN=1 +} BMX_ARB_Type; + +struct BMX_Cfg_Type { + uint8_t timeoutEn; + enum BL_Fun_Type errEn; + enum BMX_ARB_Type arbMod; +}; + +typedef enum GLB_PLL_XTAL_Type { + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6 +} GLB_PLL_XTAL_Type; + +typedef enum GLB_SYS_CLK_Type { + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1 +} GLB_SYS_CLK_Type; + +typedef enum GLB_BT_BANDWIDTH_Type { + GLB_BT_BANDWIDTH_1M=0, + GLB_BT_BANDWIDTH_2M=1 +} GLB_BT_BANDWIDTH_Type; + +typedef enum GLB_GPIO_INT_TRIG_Type { + GLB_GPIO_INT_TRIG_NEG_LEVEL=2, + GLB_GPIO_INT_TRIG_NEG_PULSE=0, + GLB_GPIO_INT_TRIG_POS_LEVEL=3, + GLB_GPIO_INT_TRIG_POS_PULSE=1 +} GLB_GPIO_INT_TRIG_Type; + +typedef enum GLB_DMA_CLK_ID_Type { + GLB_DMA_CLK_DMA0_CH0=0, + GLB_DMA_CLK_DMA0_CH1=1, + GLB_DMA_CLK_DMA0_CH2=2, + GLB_DMA_CLK_DMA0_CH3=3 +} GLB_DMA_CLK_ID_Type; + +typedef enum GLB_UART_SIG_FUN_Type { + GLB_UART_SIG_FUN_UART0_CTS=1, + GLB_UART_SIG_FUN_UART0_RTS=0, + GLB_UART_SIG_FUN_UART0_RXD=3, + GLB_UART_SIG_FUN_UART0_TXD=2, + GLB_UART_SIG_FUN_UART1_CTS=5, + GLB_UART_SIG_FUN_UART1_RTS=4, + GLB_UART_SIG_FUN_UART1_RXD=7, + GLB_UART_SIG_FUN_UART1_TXD=6 +} GLB_UART_SIG_FUN_Type; + +typedef enum GLB_PLL_CLK_Type { + GLB_PLL_CLK_120M=4, + GLB_PLL_CLK_160M=3, + GLB_PLL_CLK_192M=2, + GLB_PLL_CLK_240M=1, + GLB_PLL_CLK_32M=8, + GLB_PLL_CLK_480M=0, + GLB_PLL_CLK_48M=7, + GLB_PLL_CLK_80M=6, + GLB_PLL_CLK_96M=5 +} GLB_PLL_CLK_Type; + +typedef enum GLB_ROOT_CLK_Type { + GLB_ROOT_CLK_PLL=2, + GLB_ROOT_CLK_RC32M=0, + GLB_ROOT_CLK_XTAL=1 +} GLB_ROOT_CLK_Type; + +typedef enum GLB_SFLASH_CLK_Type { + GLB_SFLASH_CLK_120M=0, + GLB_SFLASH_CLK_48M=2, + GLB_SFLASH_CLK_80M=3, + GLB_SFLASH_CLK_96M=5, + GLB_SFLASH_CLK_BCLK=4, + GLB_SFLASH_CLK_XTAL=1 +} GLB_SFLASH_CLK_Type; + +typedef enum BMX_TO_INT_Type { + BMX_TO_INT_ALL=1, + BMX_TO_INT_TIMEOUT=0 +} BMX_TO_INT_Type; + +typedef enum GLB_DAC_CLK_Type { + GLB_DAC_CLK_32M=0, + GLB_DAC_CLK_XCLK=1 +} GLB_DAC_CLK_Type; + +typedef enum GLB_IR_CLK_SRC_Type { + GLB_IR_CLK_SRC_XCLK=0 +} GLB_IR_CLK_SRC_Type; + +typedef enum GLB_ADC_CLK_Type { + GLB_ADC_CLK_96M=0, + GLB_ADC_CLK_XCLK=1 +} GLB_ADC_CLK_Type; + +typedef enum GLB_GPIO_INT_CONTROL_Type { + GLB_GPIO_INT_CONTROL_ASYNC=1, + GLB_GPIO_INT_CONTROL_SYNC=0 +} GLB_GPIO_INT_CONTROL_Type; + +typedef enum GLB_MTIMER_CLK_Type { + GLB_MTIMER_CLK_32K=1, + GLB_MTIMER_CLK_BCLK=0 +} GLB_MTIMER_CLK_Type; + +typedef enum GLB_GPIO_REAL_MODE_Type { + GLB_GPIO_REAL_MODE_CCI=15, + GLB_GPIO_REAL_MODE_JTAG=14, + GLB_GPIO_REAL_MODE_REG=0, + GLB_GPIO_REAL_MODE_RF=12, + GLB_GPIO_REAL_MODE_SDIO=1 +} GLB_GPIO_REAL_MODE_Type; + +typedef enum GLB_PKA_CLK_Type { + GLB_PKA_CLK_HCLK=0, + GLB_PKA_CLK_PLL120M=1 +} GLB_PKA_CLK_Type; + +typedef enum GLB_UART_SIG_Type { + GLB_UART_SIG_0=0, + GLB_UART_SIG_1=1, + GLB_UART_SIG_2=2, + GLB_UART_SIG_3=3, + GLB_UART_SIG_4=4, + GLB_UART_SIG_5=5, + GLB_UART_SIG_6=6, + GLB_UART_SIG_7=7 +} GLB_UART_SIG_Type; + +typedef struct phy_env_tag phy_env_tag, *Pphy_env_tag; + +typedef struct phy_bl602_cfg_tag phy_bl602_cfg_tag, *Pphy_bl602_cfg_tag; + +struct phy_bl602_cfg_tag { + uint32_t reserved; +}; + +struct phy_env_tag { + struct phy_bl602_cfg_tag cfg; + uint16_t chnl_prim20_freq; + uint16_t chnl_center1_freq; + uint16_t chnl_center2_freq; + uint8_t band; + uint8_t chnl_type; +}; + +typedef struct lld_evt_env_tag lld_evt_env_tag, *Plld_evt_env_tag; + +struct lld_evt_env_tag { + struct co_list elt_prog; + struct co_list elt_wait; + struct co_list elt_deferred; + struct co_list rx_pkt_deferred; + struct co_list elt_to_be_deleted; + uint8_t sca; + _Bool renew; + uint8_t hw_wa_sleep_compensation; + undefined field_0x2b; +}; + +typedef struct lld_evt_wait_tag lld_evt_wait_tag, *Plld_evt_wait_tag; + +struct lld_evt_wait_tag { + struct co_list_hdr hdr; + struct ea_elt_tag * elt_ptr; +}; + +typedef struct lld_conn lld_conn, *Plld_conn; + +struct lld_conn { + uint32_t sync_win_size; + uint32_t sca_drift; + uint16_t instant; + uint16_t latency; + uint16_t counter; + uint16_t missed_cnt; + uint16_t duration_dft; + uint16_t update_offset; + uint16_t eff_max_tx_time; + uint16_t eff_max_tx_size; + uint8_t update_size; + uint8_t instant_action; + uint8_t mst_sca; + uint8_t last_md_rx; + uint8_t tx_prog_pkt_cnt; + _Bool wait_con_up_sync; + undefined field_0x1e; + undefined field_0x1f; +}; + +typedef struct lld_evt_delete_tag lld_evt_delete_tag, *Plld_evt_delete_tag; + +struct lld_evt_delete_tag { + struct co_list_hdr hdr; + struct ea_elt_tag * elt_ptr; + _Bool flush; + _Bool send_ind; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct lld_evt_anchor lld_evt_anchor, *Plld_evt_anchor; + +struct lld_evt_anchor { + uint32_t basetime_cnt; + uint16_t finetime_cnt; + uint16_t evt_cnt; +}; + +typedef enum lld_evt_flag { + LLD_EVT_FLAG_APFM=64, + LLD_EVT_FLAG_LATENCY_ACTIVE=-128, + LLD_EVT_FLAG_NO_RESTART=32, + LLD_EVT_FLAG_WAITING_ACK=1, + LLD_EVT_FLAG_WAITING_EOEVT_TO_DELETE=16, + LLD_EVT_FLAG_WAITING_INSTANT=8, + LLD_EVT_FLAG_WAITING_SYNC=2, + LLD_EVT_FLAG_WAITING_TXPROG=4 +} lld_evt_flag; + +typedef struct lld_evt_deferred_tag lld_evt_deferred_tag, *Plld_evt_deferred_tag; + +struct lld_evt_deferred_tag { + struct co_list_hdr hdr; + struct ea_elt_tag * elt_ptr; + uint8_t type; + uint8_t rx_desc_cnt; + undefined field_0xa; + undefined field_0xb; +}; + +typedef enum lld_evt_mode { + LLD_EVT_ADV_MODE=0, + LLD_EVT_EXT_ADV_MODE=5, + LLD_EVT_EXT_SCAN_MODE=7, + LLD_EVT_MODE_MAX=8, + LLD_EVT_MST_MODE=3, + LLD_EVT_PER_ADV_MODE=6, + LLD_EVT_SCAN_MODE=1, + LLD_EVT_SLV_MODE=4, + LLD_EVT_TEST_MODE=2 +} lld_evt_mode; + +typedef struct lld_evt_tag lld_evt_tag, *Plld_evt_tag; + +typedef union lld_evt_info lld_evt_info, *Plld_evt_info; + +typedef struct lld_non_conn lld_non_conn, *Plld_non_conn; + +struct lld_non_conn { + uint32_t window; + uint32_t anchor; + uint32_t end_ts; + _Bool initiate; + _Bool connect_req_sent; + undefined field_0xe; + undefined field_0xf; +}; + +union lld_evt_info { + struct lld_non_conn non_conn; + struct lld_conn conn; +}; + +struct lld_evt_tag { + struct lld_evt_anchor anchor_point; + struct co_list tx_acl_rdy; + struct co_list tx_acl_tofree; + struct co_list tx_llcp_pdu_rdy; + struct co_list tx_prog; + struct ea_interval_tag * interval_elt; + union lld_evt_info evt; + uint16_t conhdl; + uint16_t cs_ptr; + uint16_t interval; + uint8_t rx_cnt; + uint8_t mode; + uint8_t tx_pwr; + uint8_t default_prio; + uint8_t evt_flag; + _Bool delete_ongoing; +}; + +typedef enum lld_evt_cs_format { + LLD_ACTIVE_SCANNING=9, + LLD_HD_ADVERTISER=5, + LLD_INITIATING=15, + LLD_LD_ADVERTISER=4, + LLD_MASTER_CONNECTED=2, + LLD_PASSIVE_SCANNING=8, + LLD_RXTEST_MODE=29, + LLD_SLAVE_CONNECTED=3, + LLD_TXRXTEST_MODE=30, + LLD_TXTEST_MODE=28 +} lld_evt_cs_format; + +typedef struct lld_evt_update_tag lld_evt_update_tag, *Plld_evt_update_tag; + +struct lld_evt_update_tag { + uint16_t win_offset; + uint16_t instant; + uint8_t win_size; + undefined field_0x5; +}; + +typedef struct lwip_cyclic_timer.conflict27 lwip_cyclic_timer.conflict27, *Plwip_cyclic_timer.conflict27; + +struct lwip_cyclic_timer.conflict27 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict51 lwip_cyclic_timer.conflict51, *Plwip_cyclic_timer.conflict51; + +struct lwip_cyclic_timer.conflict51 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct sys_timeo sys_timeo, *Psys_timeo; + +struct sys_timeo { + struct sys_timeo * next; + u32_t time; + void (* h)(void *); + void * arg; +}; + +typedef struct lwip_cyclic_timer lwip_cyclic_timer, *Plwip_cyclic_timer; + +typedef void (* lwip_cyclic_timer_handler)(void); + +struct lwip_cyclic_timer { + u32_t interval_ms; + lwip_cyclic_timer_handler handler; +}; + +typedef struct lwip_cyclic_timer.conflict39 lwip_cyclic_timer.conflict39, *Plwip_cyclic_timer.conflict39; + +struct lwip_cyclic_timer.conflict39 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict18 lwip_cyclic_timer.conflict18, *Plwip_cyclic_timer.conflict18; + +struct lwip_cyclic_timer.conflict18 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict15 lwip_cyclic_timer.conflict15, *Plwip_cyclic_timer.conflict15; + +struct lwip_cyclic_timer.conflict15 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict lwip_cyclic_timer.conflict, *Plwip_cyclic_timer.conflict; + +struct lwip_cyclic_timer.conflict { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict16 lwip_cyclic_timer.conflict16, *Plwip_cyclic_timer.conflict16; + +struct lwip_cyclic_timer.conflict16 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict2 lwip_cyclic_timer.conflict2, *Plwip_cyclic_timer.conflict2; + +struct lwip_cyclic_timer.conflict2 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict19 lwip_cyclic_timer.conflict19, *Plwip_cyclic_timer.conflict19; + +struct lwip_cyclic_timer.conflict19 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict10 lwip_cyclic_timer.conflict10, *Plwip_cyclic_timer.conflict10; + +struct lwip_cyclic_timer.conflict10 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict13 lwip_cyclic_timer.conflict13, *Plwip_cyclic_timer.conflict13; + +struct lwip_cyclic_timer.conflict13 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict14 lwip_cyclic_timer.conflict14, *Plwip_cyclic_timer.conflict14; + +struct lwip_cyclic_timer.conflict14 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict11 lwip_cyclic_timer.conflict11, *Plwip_cyclic_timer.conflict11; + +struct lwip_cyclic_timer.conflict11 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict12 lwip_cyclic_timer.conflict12, *Plwip_cyclic_timer.conflict12; + +struct lwip_cyclic_timer.conflict12 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict40 lwip_cyclic_timer.conflict40, *Plwip_cyclic_timer.conflict40; + +struct lwip_cyclic_timer.conflict40 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict31 lwip_cyclic_timer.conflict31, *Plwip_cyclic_timer.conflict31; + +struct lwip_cyclic_timer.conflict31 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict28 lwip_cyclic_timer.conflict28, *Plwip_cyclic_timer.conflict28; + +struct lwip_cyclic_timer.conflict28 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict29 lwip_cyclic_timer.conflict29, *Plwip_cyclic_timer.conflict29; + +struct lwip_cyclic_timer.conflict29 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict26 lwip_cyclic_timer.conflict26, *Plwip_cyclic_timer.conflict26; + +struct lwip_cyclic_timer.conflict26 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict20 lwip_cyclic_timer.conflict20, *Plwip_cyclic_timer.conflict20; + +struct lwip_cyclic_timer.conflict20 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict21 lwip_cyclic_timer.conflict21, *Plwip_cyclic_timer.conflict21; + +struct lwip_cyclic_timer.conflict21 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict24 lwip_cyclic_timer.conflict24, *Plwip_cyclic_timer.conflict24; + +struct lwip_cyclic_timer.conflict24 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict25 lwip_cyclic_timer.conflict25, *Plwip_cyclic_timer.conflict25; + +struct lwip_cyclic_timer.conflict25 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict22 lwip_cyclic_timer.conflict22, *Plwip_cyclic_timer.conflict22; + +struct lwip_cyclic_timer.conflict22 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict23 lwip_cyclic_timer.conflict23, *Plwip_cyclic_timer.conflict23; + +struct lwip_cyclic_timer.conflict23 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict48 lwip_cyclic_timer.conflict48, *Plwip_cyclic_timer.conflict48; + +struct lwip_cyclic_timer.conflict48 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict34 lwip_cyclic_timer.conflict34, *Plwip_cyclic_timer.conflict34; + +struct lwip_cyclic_timer.conflict34 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict1 lwip_cyclic_timer.conflict1, *Plwip_cyclic_timer.conflict1; + +struct lwip_cyclic_timer.conflict1 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict9 lwip_cyclic_timer.conflict9, *Plwip_cyclic_timer.conflict9; + +struct lwip_cyclic_timer.conflict9 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict37 lwip_cyclic_timer.conflict37, *Plwip_cyclic_timer.conflict37; + +struct lwip_cyclic_timer.conflict37 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict8 lwip_cyclic_timer.conflict8, *Plwip_cyclic_timer.conflict8; + +struct lwip_cyclic_timer.conflict8 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict38 lwip_cyclic_timer.conflict38, *Plwip_cyclic_timer.conflict38; + +struct lwip_cyclic_timer.conflict38 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict7 lwip_cyclic_timer.conflict7, *Plwip_cyclic_timer.conflict7; + +struct lwip_cyclic_timer.conflict7 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict6 lwip_cyclic_timer.conflict6, *Plwip_cyclic_timer.conflict6; + +struct lwip_cyclic_timer.conflict6 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict5 lwip_cyclic_timer.conflict5, *Plwip_cyclic_timer.conflict5; + +struct lwip_cyclic_timer.conflict5 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict4 lwip_cyclic_timer.conflict4, *Plwip_cyclic_timer.conflict4; + +struct lwip_cyclic_timer.conflict4 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict32 lwip_cyclic_timer.conflict32, *Plwip_cyclic_timer.conflict32; + +struct lwip_cyclic_timer.conflict32 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict30 lwip_cyclic_timer.conflict30, *Plwip_cyclic_timer.conflict30; + +struct lwip_cyclic_timer.conflict30 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict35 lwip_cyclic_timer.conflict35, *Plwip_cyclic_timer.conflict35; + +struct lwip_cyclic_timer.conflict35 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict36 lwip_cyclic_timer.conflict36, *Plwip_cyclic_timer.conflict36; + +struct lwip_cyclic_timer.conflict36 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict43 lwip_cyclic_timer.conflict43, *Plwip_cyclic_timer.conflict43; + +struct lwip_cyclic_timer.conflict43 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict33 lwip_cyclic_timer.conflict33, *Plwip_cyclic_timer.conflict33; + +struct lwip_cyclic_timer.conflict33 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict49 lwip_cyclic_timer.conflict49, *Plwip_cyclic_timer.conflict49; + +struct lwip_cyclic_timer.conflict49 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict42 lwip_cyclic_timer.conflict42, *Plwip_cyclic_timer.conflict42; + +struct lwip_cyclic_timer.conflict42 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict41 lwip_cyclic_timer.conflict41, *Plwip_cyclic_timer.conflict41; + +struct lwip_cyclic_timer.conflict41 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict46 lwip_cyclic_timer.conflict46, *Plwip_cyclic_timer.conflict46; + +struct lwip_cyclic_timer.conflict46 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict47 lwip_cyclic_timer.conflict47, *Plwip_cyclic_timer.conflict47; + +struct lwip_cyclic_timer.conflict47 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict44 lwip_cyclic_timer.conflict44, *Plwip_cyclic_timer.conflict44; + +struct lwip_cyclic_timer.conflict44 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict45 lwip_cyclic_timer.conflict45, *Plwip_cyclic_timer.conflict45; + +struct lwip_cyclic_timer.conflict45 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict52 lwip_cyclic_timer.conflict52, *Plwip_cyclic_timer.conflict52; + +struct lwip_cyclic_timer.conflict52 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict50 lwip_cyclic_timer.conflict50, *Plwip_cyclic_timer.conflict50; + +struct lwip_cyclic_timer.conflict50 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef enum LOG_BUF_OUT_DATA_TYPE { + LOG_BUF_OUT_DATA_TYPE_HEX=0, + LOG_BUF_OUT_DATA_TYPE_INT8=1, + LOG_BUF_OUT_DATA_TYPE_UNT8=2 +} LOG_BUF_OUT_DATA_TYPE; + +typedef enum LOG_BUF_OUT_DATA_TYPE LOG_BUF_OUT_DATA_TYPE_T; + +typedef int __gcc_CMPtype; + +typedef struct bt_conn.conflict2 bt_conn.conflict2, *Pbt_conn.conflict2; + +struct bt_conn.conflict2 { + u16_t handle; + u8_t type; + u8_t role; + atomic_t flags[1]; + u8_t id; + enum bt_security_t sec_level; + enum bt_security_t required_sec_level; + u8_t encrypt; + u8_t err; + enum bt_conn_state_t state; + u16_t rx_len; + struct net_buf * rx; + sys_slist_t tx_pending; + u32_t.conflict pending_no_cb; + sys_slist_t tx_complete; + struct k_work tx_complete_work; + struct k_fifo tx_queue; + sys_slist_t channels; + atomic_t ref; + struct k_delayed_work.conflict update_work; + union anon_union_for_field_20 field_20; +}; + +typedef struct bt_conn.conflict1 bt_conn.conflict1, *Pbt_conn.conflict1; + +struct bt_conn.conflict1 { + u16_t handle; + u8_t type; + u8_t role; + atomic_t flags[1]; + u8_t id; + enum bt_security_t sec_level; + enum bt_security_t required_sec_level; + u8_t encrypt; + u8_t err; + enum bt_conn_state_t state; + u16_t rx_len; + struct net_buf * rx; + sys_slist_t tx_pending; + u32_t.conflict pending_no_cb; + sys_slist_t tx_complete; + struct k_work tx_complete_work; + struct k_fifo tx_queue; + sys_slist_t channels; + atomic_t ref; + struct k_delayed_work.conflict update_work; + union anon_union_for_field_20 field_20; +}; + +typedef struct bt_conn.conflict bt_conn.conflict, *Pbt_conn.conflict; + +struct bt_conn.conflict { + u16_t handle; + u8_t type; + u8_t role; + atomic_t flags[1]; + u8_t id; + enum bt_security_t sec_level; + enum bt_security_t required_sec_level; + u8_t encrypt; + u8_t err; + enum bt_conn_state_t state; + u16_t rx_len; + struct net_buf * rx; + sys_slist_t tx_pending; + u32_t.conflict pending_no_cb; + sys_slist_t tx_complete; + struct k_work tx_complete_work; + struct k_fifo tx_queue; + sys_slist_t channels; + atomic_t ref; + struct k_delayed_work.conflict update_work; + union anon_union_for_field_20 field_20; +}; + +typedef void (* __sighandler_t)(int); + +typedef enum Elf_ProgramHeaderType { + PT_DYNAMIC=2, + PT_GNU_EH_FRAME=1685382480, + PT_GNU_RELRO=1685382482, + PT_GNU_STACK=1685382481, + PT_INTERP=3, + PT_LOAD=1, + PT_NOTE=4, + PT_NULL=0, + PT_PHDR=6, + PT_SHLIB=5, + PT_TLS=7 +} Elf_ProgramHeaderType; + +typedef struct Elf32_Shdr Elf32_Shdr, *PElf32_Shdr; + +typedef enum Elf_SectionHeaderType { + SHT_CHECKSUM=1879048184, + SHT_DYNAMIC=6, + SHT_DYNSYM=11, + SHT_FINI_ARRAY=15, + SHT_GNU_ATTRIBUTES=1879048181, + SHT_GNU_HASH=1879048182, + SHT_GNU_LIBLIST=1879048183, + SHT_GNU_verdef=1879048189, + SHT_GNU_verneed=1879048190, + SHT_GNU_versym=1879048191, + SHT_GROUP=17, + SHT_HASH=5, + SHT_INIT_ARRAY=14, + SHT_NOBITS=8, + SHT_NOTE=7, + SHT_NULL=0, + SHT_PREINIT_ARRAY=16, + SHT_PROGBITS=1, + SHT_REL=9, + SHT_RELA=4, + SHT_SHLIB=10, + SHT_STRTAB=3, + SHT_SUNW_COMDAT=1879048187, + SHT_SUNW_move=1879048186, + SHT_SUNW_syminfo=1879048188, + SHT_SYMTAB=2, + SHT_SYMTAB_SHNDX=18 +} Elf_SectionHeaderType; + +struct Elf32_Shdr { + dword sh_name; + enum Elf_SectionHeaderType sh_type; + dword sh_flags; + dword sh_addr; + dword sh_offset; + dword sh_size; + dword sh_link; + dword sh_info; + dword sh_addralign; + dword sh_entsize; +}; + +typedef struct Elf32_Sym Elf32_Sym, *PElf32_Sym; + +struct Elf32_Sym { + dword st_name; + dword st_value; + dword st_size; + byte st_info; + byte st_other; + word st_shndx; +}; + +typedef struct Elf32_Phdr Elf32_Phdr, *PElf32_Phdr; + +struct Elf32_Phdr { + enum Elf_ProgramHeaderType p_type; + dword p_offset; + dword p_vaddr; + dword p_paddr; + dword p_filesz; + dword p_memsz; + dword p_flags; + dword p_align; +}; + +typedef struct Elf32_Ehdr Elf32_Ehdr, *PElf32_Ehdr; + +struct Elf32_Ehdr { + byte e_ident_magic_num; + char e_ident_magic_str[3]; + byte e_ident_class; + byte e_ident_data; + byte e_ident_version; + byte e_ident_pad[9]; + word e_type; + word e_machine; + dword e_version; + dword e_entry; + dword e_phoff; + dword e_shoff; + dword e_flags; + word e_ehsize; + word e_phentsize; + word e_phnum; + word e_shentsize; + word e_shnum; + word e_shstrndx; +}; + + +// WARNING! conflicting data type names: /stdint.h/intptr_t - /DWARF/_stdint.h/intptr_t + + + + +void bl602_start(void); +void cmd_free_mem(char *buf,int len,int argc,char **argv); +void cmd_stack_ble(void); +void cmd_stack_wifi(char *buf,int len,int argc,char **argv); +void scan_complete_cb(void *p_arg,void *param); +void scan_item_cb(wifi_mgmr_ap_item_t *env,uint32_t *param1,wifi_mgmr_ap_item_t *item); +void wifiprov_wifi_state_get(void *p_arg); +uchar char_to_hex(char asccode); +void event_cb_wifi_event(input_event_t *event,void *private_data); +void event_cb_cli(input_event_t *event,void *p_arg); +int get_dts_addr(char *name); +void aos_loop_proc(void *pvParameters); +void vApplicationStackOverflowHook(TaskHandle_t xTask,char *pcTaskName); +void vApplicationMallocFailedHook(void); +void vApplicationIdleHook(void); +void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,StackType_t **ppxIdleTaskStackBuffer,uint32_t *pulIdleTaskStackSize); +void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer,StackType_t **ppxTimerTaskStackBuffer,uint32_t *pulTimerTaskStackSize); +void vAssertCalled(void); +void bfl_main(void); +AT_ERROR_CODE __usr_at_cmd_demo(at_para_t *at_para); +void usr_at_cmd_register(void); +void bt_enable_cb(int err); +void ble_stack_start(void); +void blesync_complete_cb(void *p_arg); +void app_delayed_action_bleadv(void *arg); +void wifiprov_api_state_get(anon_subr_void_void_ptr *state_get); +void wifiprov_wifi_scan(anon_subr_void_void_ptr *complete); +void wifiprov_disc_from_ap_ind(void); +void wifiprov_connect_ap_ind(wifi_conn *info); +void blsync_disconnected(bt_conn *conn,u8_t reason); +void blsync_connected(bt_conn *conn,u8_t err); +void app_delayed_action_bleadvstop(void *arg); +void blsync_ble_start(void); +void blsync_ble_stop(void); +void cmd_coex_dump(char *buf,int len,int argc,char **argv); +int codex_debug_cli_init(void); +int wifi_prov_api_event_trigger_connect(wifi_conn *info); +int wifi_prov_api_event_trigger_disconnect(void); +int wifi_prov_api_event_trigger_scan(anon_subr_void_void_ptr *complete); +int wifi_prov_api_event_state_get(anon_subr_void_void_ptr *state_get); +void assert_err(char *condition,char *file,int line); +void assert_warn(char *condition,char *file,int line); +void coex_dump_pta(void); +void coex_dump_wifi(void); +void coex_wifi_rf_forece_enable(int enable); +void coex_wifi_pti_forece_enable(int enable); +void wifi_main(void); +void ipc_emb_notify(void); +void ipc_emb_wait(void); +void ipc_emb_init(void); +void ipc_emb_tx_irq(void); +void ipc_emb_tx_evt(int queue_idx); +void ipc_emb_cfmback_irq(void); +void ipc_emb_txcfm_ind(uint32_t queue_bits); +void ipc_emb_msg_irq(void); +void ipc_emb_msg_evt(void); +void ipc_emb_msg_dma_int_handler(void); +void ipc_emb_dbg_dma_int_handler(void); +void ipc_emb_dump(void); +void mdm_txcbwmax_setf(uint8_t txcbwmax); +void phy_config_rxgain(int offset); +void agc_config(void); +void mdm_reset(void); +void phy_powroffset_set(int8_t *power_offset); +void phy_hw_set_channel(uint8_t band,uint16_t freq,uint16_t freq1,uint8_t chantype); +void phy_get_channel(phy_channel_info *info,uint8_t index); +void phy_set_channel(uint8_t band,uint8_t type,uint16_t prim20_freq,uint16_t center1_freq,uint16_t center2_freq,uint8_t index); +void phy_get_version(uint32_t *version_1,uint32_t *version_2); +_Bool phy_vht_supported(void); +void phy_init(phy_cfg_tag *config); +uint8_t phy_get_nss(void); +uint8_t phy_get_ntx(void); +void phy_stop(void); +_Bool phy_ldpc_tx_supported(void); +uint8_t phy_get_mac_freq(void); +void phy_get_rf_gain_idx(int8_t *power,uint8_t *idx); +void phy_get_rf_gain_capab(int8_t *max,int8_t *min); +void bz_phy_reset(void); +void mpif_clk_init(void); +void phy_mdm_isr(void); +void phy_rc_isr(void); +void pa_init(void); +void pa_input(uint8_t id,rx_hd *rhd); +uint8_t hal_get_capcode(void); +void hal_set_capcode(uint32_t capcode); +_Bool hal_get_temperature(int16_t *temperature); +void hal_set_temperature(int16_t temperature); +void trpc_update_power(int8_t (*power_rate_table) [8]); +void trpc_power_get(int8_t *power_rate_table); +void trpc_update_power_11b(int8_t *power_rate_table); +void trpc_update_power_11g(int8_t *power_rate_table); +void trpc_update_power_11n(int8_t *power_rate_table); +void trpc_init(void); +int8_t trpc_get_rf_max_power(void); +int8_t trpc_get_rf_min_power(void); +uint8_t trpc_get_power_idx(uint8_t formatmod,uint8_t mcs,int8_t pwr_dbm); +uint8_t trpc_get_default_power_idx(uint8_t formatmod,uint8_t mcs); +void trpc_update_vs_channel(int8_t channel_MHz); +void trpc_update_vs_temperature(int8_t temperature); +void phy_tcal_reset(void); +void phy_tcal_start(void); +void phy_tcal_txpwr(int16_t curr_temperature); +void phy_tcal_callback(int16_t temperature); +void rf_fsm_ctrl_en_setf(uint32_t x); +void rf_gc_tbb_setf(uint32_t x); +void rf_gc_tmx_setf(uint32_t x); +void rf_pa_ib_fix_setf(uint32_t x); +void rf_pa_vbcas_setf(uint32_t x); +void rf_pa_vbcore_setf(uint32_t x); +void rf_tmx_cs_setf(uint32_t x); +void rf_fsm_st_dbg_en_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc3_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc2_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc1_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc0_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc7_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc6_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc5_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc4_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc11_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc10_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc9_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc8_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc15_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc14_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc13_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc12_setf(uint32_t x); +void wait_us(uint32_t us); +void rf_pa_etb_en_setf(void); +void rf_pa_half_on_setf(void); +void _print_channel_info(void); +void rfc_init(uint32_t xtalfreq_hz); +void rfc_rxdfe_set_notch0(uint8_t en,uint8_t alpha,int8_t nrmfc); +void rfc_config_channel(uint32_t channel_freq); +void rfc_coex_force_to(uint32_t force_enable,uint32_t bbmode); +_Bool rfc_config_power_ble(int32_t pwr_dbm); +uint32_t rfc_get_power_level(uint32_t formatmod,int32_t power); +void rfc_apply_tx_dvga(int8_t *dvga_qdb); +void rfc_apply_tx_power_offset(uint8_t channel,int8_t *power_offset); +void rf_pri_set_gain_table_regs(void); +void rf_pri_manu_pu(uint32_t mode); +void rf_pri_save_state_for_cal(void); +void rf_pri_restore_state_for_cal(void); +void rf_pri_singen_start(void); +uint32_t rf_pri_pm_pwr(void); +void rf_pri_start_txdfe(void); +int32_t rf_pri_pm_pwr_avg(uint32_t iq,uint32_t acc_len); +void rf_pri_txcal_config_hw(void); +uint16_t rf_pri_fcal_meas(uint32_t cw); +void rf_pri_rccal_config(uint32_t rbb_fc); +void rf_pri_rccal_config(uint32_t iq,uint32_t rbb_fc); +void rf_pri_txcal_config(uint32_t param_ind,int32_t val); +int32_t rf_pri_txcal_search_core(uint32_t param_ind,uint32_t center,uint32_t delta,uint32_t meas_freq); +void rf_pri_singen_config(uint32_t fcw); +uint32_t rf_pri_rccal_iq(uint32_t iq); +void rf_pri_config_channel(void); +uint32_t rf_pri_roscal_iq(uint32_t iq); +void rf_pri_chipv(uint8_t chipv); +void rf_pri_update_tx_power_offset(uint8_t channel,int8_t *power_offset); +void rf_pri_get_notch_param(uint32_t chanfreq_MHz,uint8_t *ncf_on,int32_t *ncf_freq_Hz); +void rf_pri_update_param(uint32_t chanfreq_MHz); +void rf_pri_xtalfreq(uint32_t xtalfreq); +uint32_t rf_pri_get_vco_freq_cw(uint32_t chanfreq_MHz); +uint32_t rf_pri_get_vco_idac_cw(uint32_t chanfreq_MHz); +int32_t rf_pri_get_txgain_max(void); +int32_t rf_pri_get_txgain_min(void); +uint32_t rf_pri_get_txgain_index(int32_t pwr,uint32_t mode); +void rf_pri_query_txgain_table(uint32_t index,uint32_t *rfg_index,uint32_t *dg); +void rf_pri_update_dvga_os(int8_t dvga_os); +void rf_pri_tx_gain_comp(int32_t Tsens); +void rf_pri_txcal(void); +void rf_pri_roscal(void); +void rf_pri_rccal(void); +void rf_pri_lo_acal(void); +void rf_pri_fcal(void); +void rf_pri_full_cal(void); +void rf_pri_restore_cal_reg(void); +void rf_pri_init(uint8_t reset,uint8_t chipv); +void rf_pri_update_power_offset(int32_t *power_offset); +void sysctrl_init(void); +void intc_spurious(void); +void intc_enable_irq(int index); +void intc_init(void); +void mac_irq(void); +void bl_irq_handler(void); +uint8_t blmac_soft_reset_getf(void); +void blmac_wt_2_crypt_clk_ratio_setf(uint8_t wt2cryptclkratio); +void blmac_rx_flow_cntrl_en_setf(void); +void blmac_key_sto_ram_reset_setf(void); +void hal_machw_stop(void); +void hal_machw_init(void); +void hal_machw_disable_int(void); +void hal_machw_reset(void); +uint8_t hal_machw_search_addr(mac_addr *addr); +void hal_machw_monitor_mode(void); +_Bool hal_machw_sleep_check(void); +void hal_machw_gen_handler(void); +void mm_rx_filter_set(void); +int element_notify_status_enabled(cfg_element_entry *entry,void *arg1,void *arg2,CFG_ELEMENT_TYPE_OPS ops); +void blmac_ap_setf(uint8_t ap); +uchar ascii_to_hex(char asccode); +undefined4 element_notify_time_last_received_set(void); +void blmac_encr_cntrl_pack(uint8_t newread,uint8_t newwrite,uint16_t keyindexram,uint8_t ctyperam,uint8_t vlanidram,uint8_t sppram,uint8_t usedefkeyram,uint8_t clenram); +undefined4 element_notify_keepalive_received(void); +uint32_t hal_machw_rx_duration(rx_hd *rhd,uint16_t len); +void mm_env_max_ampdu_duration_set(void); +void mm_env_init(void); +void mm_init(void); +void mm_active(void); +void mm_reset(void); +uint8_t mm_sec_machwaddr_wr(uint8_t sta_idx,uint8_t inst_nbr); +uint8_t mm_sec_machwkey_wr(mm_key_add_req *param); +void mm_sec_machwkey_del(uint8_t hw_key_idx); +void mm_sec_machwaddr_del(uint8_t sta_idx); +void mm_hw_idle_evt(int dummy); +void mm_hw_info_set(mac_addr *mac_addr); +void mm_hw_ap_info_set(void); +void mm_hw_ap_info_reset(void); +void mm_back_to_host_idle(void); +uint8_t mm_sta_add(mm_sta_add_req *param,uint8_t *sta_idx,uint8_t *hw_sta_idx); +void mm_sta_del(uint8_t sta_idx); +void mm_cfg_element_keepalive_timestamp_update(void); +void mm_send_connection_loss_ind(vif_info_tag *p_vif_entry); +void mm_ap_probe_cfm(void *env,uint32_t status); +void mm_check_rssi(vif_info_tag *vif_entry,int8_t rssi); +void mm_send_csa_traffic_ind(uint8_t vif_index,_Bool enable); +uint mm_check_beacon(rx_hd *param_1,vif_info_tag *param_2,int param_3,char **param_4); +void mm_sta_tbtt(void *env); +uint16_t mm_get_rsn_wpa_ie(uint8_t sta_id,uint8_t *wpa_ie); +void mm_tim_update_proceed(ushort *param_1); +void mm_bcn_init(void); +void mm_bcn_init_vif(vif_info_tag *vif_entry); +void mm_tim_update(mm_tim_update_req *param); +void mm_bcn_transmit(void); +void mm_bcn_updated(void *env,int dma_queue); +void mm_bcn_update(mm_bcn_change_req *param); +void mm_bcn_transmitted(vif_info_tag *param_1); +void mm_bcn_change(mm_bcn_change_req *param); +_Bool cmp_abs_time(co_list_hdr *timerA,co_list_hdr *timerB); +void mm_timer_init(void); +void mm_timer_set(mm_timer_tag *timer,uint32_t value); +void mm_timer_clear(mm_timer_tag *timer); +void mm_timer_schedule(int dummy); +void ps_uapsd_timer_handle(void *env); +void blmac_pwr_mgt_setf(uint8_t pwrmgt); +void ps_dpsm_update(_Bool pause); +uint8_t ps_send_pspoll(vif_info_tag *vif_entry); +void ps_init(void); +void ps_set_mode(uint8_t mode,ke_task_id_t taskid); +void ps_enable_cfm(void *env,uint32_t status); +void ps_disable_cfm(void *env,uint32_t status); +uint8_t ps_polling_frame(vif_info_tag *vif_entry); +void ps_check_beacon(int param_1,vif_info_tag *param_2); +void ps_check_frame(uint8_t *frame,uint32_t statinfo,vif_info_tag *vif_entry); +void ps_check_tx_frame(uint8_t staid,uint8_t tid); +void ps_uapsd_set(vif_info_tag *vif_entry,uint8_t hw_queue,_Bool uapsd); +void ps_traffic_status_update(uint8_t vif_index,uint8_t new_status); +void bl_init(void); +int bl_sleep(void); +uint32_t bl_nap_calculate(void); +void mm_ps_change_ind(uint8_t sta_idx,uint8_t ps_state); +void rxl_mpdu_transfer(rx_swdesc *swdesc); +void rxl_init(void); +void rxl_cntrl_dump(void); +void rxl_timer_int_handler(void); +void rxl_timeout_int_handler(void); +void rxl_dma_int_handler(void); +void rxl_dma_evt(int dummy); +void rxl_frame_release(rx_swdesc *swdesc); +void rxl_mpdu_free(rx_swdesc *swdesc); +void bl60x_firmwre_mpdu_free(void *swdesc_ptr); +void rxl_reset(void); +void rxl_hwdesc_dump(void); +void rxl_hwdesc_init(int init); +void rxl_hd_append(rx_dmadesc *desc); +void rxl_pd_append(rx_pbd *first,rx_pbd *last,rx_pbd *spare); +void scan_search_ds(void); +void scan_init(void); +void scan_set_channel_request(void); +void dma_cb(void *env,int dma_queue); +void scan_ie_download(scan_start_req *param); +void scan_probe_req_tx(void); +void scan_send_cancel_cfm(uint8_t status,ke_task_id_t dest_id); +void sta_mgmt_entry_init(sta_info_tag *sta_entry); +void sta_mgmt_init(void); +uint8_t sta_mgmt_register(mm_sta_add_req *param,uint8_t *sta_idx); +void sta_mgmt_unregister(uint8_t sta_idx); +void sta_mgmt_add_key(mm_key_add_req *param,uint8_t hw_key_idx); +void sta_mgmt_del_key(sta_info_tag *sta); +int sta_mgmt_send_postponed_frame(vif_info_tag *p_vif_entry,sta_info_tag *p_sta_entry,int limit); +void td_timer_end(void *env); +void td_reset(uint8_t vif_index); +void td_init(void); +void td_start(uint8_t vif_index); +void td_pck_ind(uint8_t vif_index,uint8_t sta_index,_Bool rx); +void td_pck_ps_ind(uint8_t vif_index,_Bool rx); +void bl_tpc_update_power_table(int8_t *power_table); +void bl_tpc_power_table_get(int8_t *power_table_config); +void bl_tpc_update_power_rate_11b(int8_t *power_rate_table); +void bl_tpc_update_power_rate_11g(int8_t *power_rate_table); +void bl_tpc_update_power_rate_11n(int8_t *power_rate_table); +void tpc_update_tx_power(int8_t pwr); +void tpc_update_vif_tx_power(vif_info_tag *vif,int8_t *pwr,uint8_t *idx); +uint8_t tpc_get_vif_tx_power_vs_rate(uint32_t rate_config); +void tpc_update_frame_tx_power(vif_info_tag *vif,txl_frame_desc_tag *frame); +void txl_cfm_init(void); +void txl_cfm_push(txdesc *txdesc,uint32_t status,uint8_t access_category); +void txl_cfm_flush(uint8_t access_category,co_list *list,uint32_t status); +void txl_cfm_dma_int_handler(void); +void txl_cfm_dump(void); +void txl_int_fake_transfer(txdesc *txdesc,uint8_t access_category); +void blmac_abs_timer_set(int reg_idx,uint32_t value); +void txl_machdr_format(uint32_t machdrptr); +void txl_cntrl_init(void); +_Bool txl_cntrl_tx_check(vif_info_tag *p_vif_entry); +void txl_cntrl_halt_ac(uint8_t access_category); +void txl_cntrl_flush_ac(uint8_t access_category,uint32_t status); +void txl_cntrl_inc_pck_cnt(void); +void txl_payload_handle(void); +void txl_payload_handle_backup(void); +void txl_transmit_trigger(void); +void txl_reset(void); +void txl_cntrl_env_dump(void); +void txl_frame_init_desc(txl_frame_desc_tag *frame,txl_buffer_tag *buffer,tx_hw_desc *hwdesc,txl_buffer_control *bufctrl); +void txl_frame_init(_Bool reset); +txl_frame_desc_tag * txl_frame_get(int type,int len); +_Bool txl_frame_push(txl_frame_desc_tag *frame,uint8_t ac); +_Bool txl_frame_push_force(txl_frame_desc_tag *frame,uint8_t ac); +void txl_frame_cfm(txdesc *txdesc); +void txl_frame_release(txdesc *txdesc,_Bool postponed); +uint8_t txl_frame_send_null_frame(uint8_t sta_idx,cfm_func_ptr *cfm,void *env); +uint8_t txl_frame_send_qosnull_frame(uint8_t sta_idx,uint16_t qos,cfm_func_ptr *cfm,void *env); +uint8_t txl_frame_send_eapol_frame(uint8_t sta_idx,cfm_func_ptr *cfm,void *cfm_env,uint8_t *pBuf,uint32_t pBuf_len); +void txl_frame_dump(void); +void txl_hwdesc_init(void); +void txl_hwdesc_reset(void); +void vif_mgmt_bcn_to_evt(void *env); +void vif_mgmt_init(void); +uint8_t vif_mgmt_register(mac_addr *mac_addr,uint8_t vif_type,_Bool p2p,uint8_t *vif_idx); +void vif_mgmt_unregister(uint8_t vif_idx); +void vif_mgmt_add_key(mm_key_add_req *param,uint8_t hw_key_idx); +void vif_mgmt_del_key(vif_info_tag *vif,uint8_t keyid); +void vif_mgmt_send_postponed_frame(vif_info_tag *p_vif_entry); +void vif_mgmt_reset(void); +void vif_mgmt_bcn_to_prog(vif_info_tag *p_vif_entry); +void vif_mgmt_bcn_recv(vif_info_tag *p_vif_entry); +void vif_mgmt_switch_channel(vif_info_tag *p_vif_entry); +vif_info_tag * vif_mgmt_get_first_ap_inf(void); +void me_init(void); +scan_chan_tag * me_freq_to_chan_ptr(uint8_t band,uint16_t freq); +void michael_block(mic_calc *mic_calc_ptr,uint32_t block); +void me_mic_init(mic_calc *mic_calc_ptr,uint32_t *mic_key_ptr,mac_addr *da,mac_addr *sa,uint8_t tid); +void me_mic_calc(mic_calc *mic_calc_ptr,uint32_t start_ptr,uint32_t data_len); +void me_mic_end(mic_calc *mic_calc_ptr); +_Bool me_set_sta_ht_vht_param(sta_info_tag *sta,mac_bss_info *bss); +uint8_t me_11n_nss_max(uint8_t *mcs_set); +uint8_t me_legacy_ridx_min(uint16_t rate_map); +uint8_t me_legacy_ridx_max(uint16_t rate_map); +uint8_t me_rate_translate(uint8_t rate); +void me_get_basic_rates(mac_rateset *rateset,mac_rateset *basic_ratest); +uint16_t me_legacy_rate_bitfield_build(mac_rateset *rateset,_Bool basic_only); +uint16_t me_build_capability(uint8_t vif_idx); +void me_init_bcmc_rate(sta_info_tag *sta_entry); +void me_tx_cfm_singleton(txdesc *txdesc); +void me_check_rc(uint8_t sta_idx,_Bool *tx_ampdu); +void me_init_rate(sta_info_tag *sta_entry); +void me_bw_check(int param_1,int param_2); +void me_beacon_check(uint8_t vif_idx,uint16_t length,uint32_t bcn_addr); +void me_sta_bw_nss_max_upd(uint8_t sta_idx,uint8_t bw,uint8_t nss); +uint8_t me_add_chan_ctx(uint8_t *p_chan_idx,scan_chan_tag *p_chan,uint32_t center_freq1,uint32_t center_freq2,uint8_t ch_width); +uint8_t rc_get_nss(uint16_t rate_config); +uint8_t rc_get_mcs_index(uint16_t rate_config); +uint16_t rc_set_previous_mcs_index(rc_sta_stats *rc_ss,uint16_t rate_config); +uint16_t rc_set_next_mcs_index(rc_sta_stats *rc_ss,uint16_t rate_config); +_Bool is_cck_group(uint16_t rate_config); +void rc_update_retry_chain(rc_sta_stats *rc_ss,uint32_t *cur_tp); +uint16_t rc_get_lowest_rate_config(rc_sta_stats *rc_ss); +void rc_sort_samples_tp(rc_sta_stats *rc_ss,uint32_t *cur_tp); +uint16_t rc_get_initial_rate_config(rc_sta_stats *rc_ss); +void rc_calc_prob_ewma(rc_rate_stats *rc_rs); +_Bool rc_check_valid_rate(rc_sta_stats *rc_ss,uint16_t rate_config); +uint16_t rc_new_random_rate(rc_sta_stats *rc_ss); +void rc_update_counters(uint8_t sta_idx,uint32_t attempts,uint32_t failures,_Bool tx_ampdu,_Bool retry_required); +uint32_t rc_get_duration(uint param_1); +void rc_update_bw_nss_max(uint8_t sta_idx,uint8_t bw_max,uint8_t nss_max); +void rc_init_bcmc_rate(sta_info_tag *sta_entry,uint8_t basic_rate_idx); +_Bool rc_check_fixed_rate_config(rc_sta_stats *rc_ss,uint16_t fixed_rate_config); +uint32_t rc_calc_tp(rc_sta_stats *rc_ss,uint8_t sample_idx); +_Bool rc_update_stats(rc_sta_stats *rc_ss,_Bool init); +void rc_init(sta_info_tag *sta_entry); +void rc_check(uint8_t sta_idx,_Bool *tx_ampdu); +uint8_t rxu_cntrl_machdr_len_get(uint16_t frame_cntl); +_Bool rxu_cntrl_protected_handle(uint8_t *frame,uint32_t statinfo); +undefined4 rxu_mgt_frame_check(rx_swdesc *param_1,uint param_2); +void rxu_cntrl_init(void); +void rxu_cntrl_monitor_pm(mac_addr *addr); +uint8_t rxu_cntrl_get_pm(void); +void rxu_cntrl_evt(int dummy); +void rxu_swdesc_upload_evt(int arg); +void scanu_confirm(uint8_t status); +void scanu_raw_send_cfm(uint8_t status,ke_task_id_t dst_id); +void scanu_init(void); +mac_scan_result * scanu_find_result(mac_addr *bssid_ptr,_Bool allocate); +undefined4 scanu_frame_handler(ushort *param_1); +mac_scan_result * scanu_search_by_bssid(mac_addr *bssid); +mac_scan_result * scanu_search_by_ssid(mac_ssid *ssid,int *idx); +void scanu_rm_exist_ssid(mac_ssid *ssid,int index); +void scanu_scan_next(void); +void scanu_dma_cb(void); +void scanu_start(void); +uint16_t txl_get_seq_ctrl(void); +void sm_delete_resources(vif_info_tag *vif); +void sm_frame_tx_cfm_handler(void *env,uint32_t status); +void sm_init(void); +void sm_get_bss_params(mac_addr **bssid,scan_chan_tag **chan); +void sm_scan_bss(mac_addr *bssid,scan_chan_tag *chan_1); +void sm_join_bss(mac_addr *bssid,scan_chan_tag *chan,_Bool passive); +uint8_t sm_add_chan_ctx(uint8_t *p_chan_idx); +void sm_send_next_bss_param(void); +void sm_set_bss_param(void); +void sm_disconnect_process(vif_info_tag *vif,uint16_t reason); +void sm_deauth_cfm(void *env,uint32_t status); +void sm_disconnect(uint8_t vif_index,uint16_t reason_code); +void sm_connect_ind(uint16_t status); +void sm_supplicant_deauth_cfm(void *env,uint32_t status); +void sm_auth_send(uint16_t auth_seq,uint32_t *challenge); +void sm_assoc_req_send(void); +void sm_assoc_done(uint16_t aid); +void sm_auth_handler(rxu_mgt_ind *param); +void sm_assoc_rsp_handler(rxu_mgt_ind *param); +int sm_deauth_handler(rxu_mgt_ind *param); +void sm_handle_supplicant_result(uint8_t sta_id,uint16_t reason_code); +undefined2 * txu_cntrl_sec_hdr_append(int param_1,undefined2 *param_2,int param_3); +int txu_cntrl_sechdr_len_compute(txdesc *txdesc,int *tail_len); +void txu_cntrl_frame_build(txdesc *txdesc,uint32_t buf); +void txu_cntrl_tkip_mic_append(txdesc *txdesc,uint8_t ac); +void txu_cntrl_cfm(txdesc *txdesc); +void txu_cntrl_protect_mgmt_frame(txdesc *txdesc,uint32_t frame,uint16_t hdr_len); +int _aid_list_delete(uint8_t *mac); +void apm_sta_delete(uint8_t sta_idx,uint8_t *mac); +void apm_tx_cfm_handler(uint8_t *param_1,int param_2); +void apm_init(void); +void apm_start_cfm(int param_1); +void apm_send_next_bss_param(void); +void apm_set_bss_param(void); +void apm_stop(vif_info_tag *vif); +_Bool apm_tx_int_ps_check(txdesc *txdesc); +void apm_tx_int_ps_postpone(txdesc *txdesc,sta_info_tag *sta); +txdesc * apm_tx_int_ps_get_postpone(vif_info_tag *vif,sta_info_tag *sta,int *stop); +void apm_tx_int_ps_clear(vif_info_tag *vif,uint8_t sta_idx); +void apm_sta_fw_delete(uint8_t sta_idx); +void apm_sta_add(uint8_t sta_idx); +void apm_send_mlme(vif_info_tag *vif,uint16_t fctl,mac_addr *ra,cfm_func_ptr *cfm_func,void *env,uint16_t status_code); +_Bool apm_embedded_enabled(vif_info_tag *vif); +void apm_bcn_set(void); +void apm_probe_req_handler(ushort *param_1); +void apm_auth_handler(rxu_mgt_ind *param); +void apm_assoc_req_handler(ushort *param_1,int param_2); +void apm_deauth_handler(rxu_mgt_ind *param); +void apm_disassoc_handler(rxu_mgt_ind *param); +void apm_beacon_handler(rxu_mgt_ind *param); +void apm_sta_remove(uint8_t vif_idx,uint8_t sta_idx); +char * cfg_api_element_dump(void *val,CFG_ELEMENT_TYPE type,char *strs); +int cfg_api_element_general_set(cfg_element_entry *entry,void *arg1,void *arg2); +int cfg_api_element_general_get(cfg_element_entry *entry,void *arg1,void *arg2); +int cfg_api_element_set(uint32_t task,uint32_t element,uint32_t type,void *arg1,void *arg2); +void co_list_init(co_list *list); +void co_list_push_back(co_list *list,co_list_hdr *list_hdr); +void co_list_push_front(co_list *list,co_list_hdr *list_hdr); +co_list_hdr * co_list_pop_front(co_list *list); +void co_list_extract(co_list *list,co_list_hdr *list_hdr); +uint32_t co_list_cnt(co_list *list); +void co_list_insert(co_list *list,co_list_hdr *element,anon_subr__Bool_co_list_hdr_ptr_co_list_hdr_ptr *cmp); +void co_list_insert_after(co_list *list,co_list_hdr *prev_element,co_list_hdr *element); +void co_list_remove(co_list *list,co_list_hdr *prev_element,co_list_hdr *element); +uint32_t co_crc32(uint32_t addr,uint32_t len,uint32_t crc); +void dbg_init(void); +void bl_event_handle(int param); +void bl60x_fw_dump_statistic(int forced); +void ke_evt_schedule(void); +void ke_init(void); +void * ke_msg_alloc(ke_msg_id_t id,ke_task_id_t dest_id,ke_task_id_t src_id,uint16_t param_len); +void ke_msg_send(int param_1); +void ke_msg_send_basic(ke_msg_id_t id,ke_task_id_t dest_id,ke_task_id_t src_id); +void ke_msg_forward_and_change_id(void *param_ptr,ke_msg_id_t msg_id,ke_task_id_t dest_id,ke_task_id_t src_id); +_Bool cmp_dest_id(co_list_hdr *msg,uint32_t dest_id); +_Bool ke_task_local(ke_task_id_t id); +ke_msg_func_t * ke_handler_search(ke_msg_id_t msg_id,ke_state_handler *state_handler); +ke_state_t ke_state_get(ke_task_id_t id); +int ke_msg_discard(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int ke_msg_save(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +_Bool cmp_abs_time(co_list_hdr *timerA,co_list_hdr *timerB); +_Bool cmp_timer_id(co_list_hdr *timer,uint32_t timer_task); +void ke_timer_set(ke_msg_id_t timer_id,ke_task_id_t task_id,uint32_t delay); +void ke_timer_clear(ke_msg_id_t timer_id,ke_task_id_t task_id); +void ke_timer_schedule(int dummy); +void bl60x_current_time_us(longlong *time_now); +byte * mac_ie_find(byte *param_1,int param_2,uint param_3); +char * mac_vsie_find(char *param_1,int param_2,int param_3,int param_4); +BufferDesc_t *GetTxEAPOLBuffer(cm_ConnectionInfo_t *connPtr,EAPOL_KeyMsg_Tx_t **ppTxEapol,BufferDesc_t *pBufDesc); +void UpdateEAPOLWcbLenAndTransmit(BufferDesc_t *pBufDesc,UINT16 frameLen); +BOOLEAN keyMgmtProcessMsgExt(keyMgmtInfoSta_t *pKeyMgmtInfoSta,EAPOL_KeyMsg_t *pKeyMsg); +void KeyMgmtInitSta(cm_ConnectionInfo_t *connPtr); +void keyMgmtSta_StartSession(cm_ConnectionInfo_t *connPtr,CHAR *pBssid,UINT8 *pStaAddr); +void init_customApp_mibs(supplicantData_t *suppData); +UINT8 supplicantIsEnabled(void *connectionPtr); +void supplicantInitSession(cm_ConnectionInfo_t *connPtr,CHAR *pSsid,UINT16 len,CHAR *pBssid,UINT8 *pStaAddr); +void supplicantDisable(cm_ConnectionInfo_t *connPtr); +void supplicantEnable(void *connectionPtr,int security_mode,void *mcstCipher,void *ucstCipher,_Bool is_pmf_required); +UINT16 keyMgmtFormatWpaRsnIe(cm_ConnectionInfo_t *connPtr,UINT8 *pos,IEEEtypes_MacAddr_t *pBssid,IEEEtypes_MacAddr_t *pStaAddr,UINT8 *pPmkid,BOOLEAN addPmkid); +Status_e GeneratePWKMsg2(BufferDesc_t *pEAPoLBufDesc,UINT8 *pSNonce,UINT8 *pEAPOLMICKey,UINT8 forceKeyDescVersion); +BOOLEAN KeyMgmtStaHsk_Recvd_PWKMsg1(BufferDesc_t *pEAPoLBufDesc,IEEEtypes_MacAddr_t *sa,IEEEtypes_MacAddr_t *da); +void supplicantInit(supplicantData_t *suppData); +void allocSupplicantData(void *connectionPtr); +UINT16 keyMgmtGetKeySize(cm_ConnectionInfo_t *connPtr,UINT8 isPairwise); +uint8_t add_key_to_mac(cm_ConnectionInfo_t *connPtr,UINT8 pairwise); +BufferReturnNotify_t * keyMgmtKeyGroupTxDone(void); +Status_e GenerateGrpMsg2(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta); +EAPOL_KeyMsg_t * KeyMgmtStaHsk_Recvd_GrpMsg1(BufferDesc_t *pEAPoLBufDesc); +uint8_t add_mfp_key_to_mac(cm_ConnectionInfo_t *connPtr,UINT8 pairwise); +void keyMgmtPlumbPairwiseKey(cm_ConnectionInfo_t *connPtr); +BufferReturnNotify_t * keyMgmtKeyPairwiseTxDone(void); +Status_e GeneratePWKMsg4(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta,BOOLEAN groupKeyReceived); +EAPOL_KeyMsg_t * KeyMgmtStaHsk_Recvd_PWKMsg3(BufferDesc_t *pEAPoLBufDesc); +void ProcessKeyMgmtDataSta(BufferDesc_t *pBufDesc,IEEEtypes_MacAddr_t *sa,IEEEtypes_MacAddr_t *da); +UINT8 ProcessEAPoLPkt(BufferDesc_t *bufDesc,IEEEtypes_MacAddr_t *sa,IEEEtypes_MacAddr_t *da); +uchar process_rsn_ie(uint8_t *rsn_ie,Cipher_t *mcstCipher,Cipher_t *ucstCipher,_Bool *is_pmf_required,SecurityMode_t *security_mode,_Bool wpa2_prefered); +uchar process_wpa_ie(uint8_t *wpa_ie,Cipher_t *mcstCipher,Cipher_t *ucstCipher); +void keyMgmtStaRsnSecuredTimeoutHandler(void *env); +void supplicantGenerateRand(UINT8 *dataOut,UINT32 length); +void ComputeEAPOL_MIC(EAPOL_KeyMsg_t *pKeyMsg,UINT16 data_length,UINT8 *MIC_Key,UINT8 MIC_Key_length,UINT8 micKeyDescVersion); +UINT16 keyMgmtGetKeySize_internal(RSNConfig_t *pRsnConfig,UINT8 isPairwise); +int isApReplayCounterFresh(keyMgmtInfoSta_t *pKeyMgmtInfoSta,UINT8 *pRxReplayCount); +void updateApReplayCounter(keyMgmtInfoSta_t *pKeyMgmtStaInfo,UINT8 *pRxReplayCount); +void formEAPOLEthHdr(EAPOL_KeyMsg_Tx_t *pTxEapol,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa); +BOOLEAN IsEAPOL_MICValid(EAPOL_KeyMsg_t *pKeyMsg,UINT8 *pMICKey); +UINT16 KeyMgmtSta_PopulateEAPOLLengthMic(EAPOL_KeyMsg_Tx_t *pTxEapol,UINT8 *pEAPOLMICKey,UINT8 eapolProtocolVersion,UINT8 forceKeyDescVersion); +KDE_t * parseKeyKDE(IEEEtypes_InfoElementHdr_t *pIe); +KDE_t * parseKeyKDE_DataType(UINT8 *pData,SINT32 dataLen,IEEEtypes_KDEDataType_e KDEDataType); +KDE_t * parseKeyDataGTK(UINT8 *pKey,UINT16 len,KeyData_t *pGRKey); +void KeyMgmtSta_ApplyKEK(EAPOL_KeyMsg_t *pKeyMsg,KeyData_t *pGRKey,UINT8 *EAPOL_Encr_Key); +BOOLEAN KeyMgmtSta_IsRxEAPOLValid(keyMgmtInfoSta_t *pKeyMgmtInfoSta,EAPOL_KeyMsg_t *pKeyMsg); +void KeyMgmtSta_PrepareEAPOLFrame(EAPOL_KeyMsg_Tx_t *pTxEapol,EAPOL_KeyMsg_t *pRxEapol,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa,UINT8 *pSNonce); +BOOLEAN supplicantAkmIsWpaWpa2(AkmSuite_t *pAkm); +BOOLEAN supplicantAkmIsWpa2(AkmSuite_t *pAkm); +BOOLEAN supplicantAkmIsWpaWpa2Psk(AkmSuite_t *pAkm); +BOOLEAN supplicantAkmUsesKdf(AkmSuite_t *pAkm); +void supplicantConstructContext(IEEEtypes_MacAddr_t *pAddr1,IEEEtypes_MacAddr_t *pAddr2,UINT8 *pNonce1,UINT8 *pNonce2,UINT8 *pContext); +void KeyMgmt_DerivePTK(IEEEtypes_MacAddr_t *pAddr1,IEEEtypes_MacAddr_t *pAddr2,UINT8 *pNonce1,UINT8 *pNonce2,UINT8 *pPTK,UINT8 *pPMK,BOOLEAN use_kdf); +void KeyMgmtSta_DeriveKeys(UINT8 *pPMK,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa,UINT8 *ANonce,UINT8 *SNonce,UINT8 *EAPOL_MIC_Key,UINT8 *EAPOL_Encr_Key,KeyData_t *newPWKey,BOOLEAN use_kdf); +void SetEAPOLKeyDescTypeVersion(EAPOL_KeyMsg_Tx_t *pTxEapol,BOOLEAN isWPA2,BOOLEAN isKDF,BOOLEAN nonTKIP); +EAPOL_KeyMsg_t *GetKeyMsgNonceFromEAPOL(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta); +EAPOL_KeyMsg_t *ProcessRxEAPOL_PwkMsg3(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta); +EAPOL_KeyMsg_t *ProcessRxEAPOL_GrpMsg1(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta); +void KeyMgmtResetCounter(keyMgmtInfoSta_t *pKeyMgmtInfo); +void keyMgmtSta_StartSession_internal(keyMgmtInfoSta_t *pKeyMgmtInfoSta,UINT32 expiry); +void KeyMgmtSta_InitSession(keyMgmtInfoSta_t *pKeyMgmtInfoSta); +void set_psk(char *pSsid,UINT8 ssidLen,char *phrase); +void remove_psk(char *pSsid,UINT8 ssidLen); +void bl_sha256_crypto_kdf(UINT8 *pKey,UINT8 key_len,char *label,UINT8 label_len,UINT8 *pContext,UINT16 context_len,UINT8 *pOutput,UINT16 output_len); +UINT8 * pmkCacheFindPSK(UINT8 *pSsid,UINT8 ssidLen); +void pmkCacheSetPassphrase(UINT8 *pSsid,UINT8 ssidLen,UINT8 *pPassphrase,UINT8 PassphraseLen); +void pmkCacheInit(void); +void pmkCacheRomInit(void); +pmkElement_t * pmkCacheNewElement(void); +void pmkCacheUpdateReplacementRank(pmkElement_t *pPMKElement); +pmkElement_t * pmkCacheFindPSKElement(UINT8 *pSsid,UINT8 ssidLen); +void pmkCacheAddPSK(UINT8 *pSsid,UINT8 ssidLen,UINT8 *pPSK,UINT8 pPSKLen); +void pmkCacheDeletePSK(UINT8 *pSsid,UINT8 ssidLen); +UINT8 pmkCacheGetHexNibble(UINT8 nibble); +void pmkCacheGeneratePSK(UINT8 *pSsid,UINT8 ssidLen,UINT8 *pPassphrase,UINT8 PassphraseLen,UINT8 *pPSK); +void prepare_key(uchar *key_data_ptr,int key_data_len,rc4_key *key); +void rc4(uchar *buffer_ptr,int buffer_len,int skip,rc4_key *key); +void RC4_Encrypt(uchar *Encr_Key,uchar *IV,ushort iv_length,uchar *Data,ushort data_length,ushort skipBytes); +int sha256_compress(sha256_state *md,UINT8 *msgBuf,UINT8 *pScratchMem); +void sha256_init(sha256_state *md); +void sha256_vector(size_t num_elem,UINT8 **addr,size_t *len,UINT8 *mac,UINT8 *pScratchMem); +void hmac_sha256_vector(UINT8 *key,size_t key_len,size_t num_elem,UINT8 **addr,size_t *len,UINT8 *mac); +Status_e supplicantRestoreDefaults(void); +void supplicantFuncInit(void); +void KeyMgmtInit(cm_ConnectionInfo_t *connPtr); +BufferDesc_t *PrepDefaultEapolMsg(cm_ConnectionInfo_t *connPtr,EAPOL_KeyMsg_Tx_t **pTxEapolPtr,BufferDesc_t *pBufDesc); +Status_e GeneratePWKMsg1(cm_ConnectionInfo_t *connPtr,BufferDesc_t *pBufDesc); +Status_e GeneratePWKMsg3(cm_ConnectionInfo_t *connPtr,BufferDesc_t *pBufDesc); +Status_e ProcessPWKMsg4(BufferDesc_t *pBufDesc); +Status_e GenerateApEapolMsg(cm_ConnectionInfo_t *connPtr,keyMgmtState_e msgState,BufferDesc_t *pBufDesc); +Status_e ProcessPWKMsg2(BufferDesc_t *pBufDesc); +BOOLEAN SendEAPOLMsgUsingBufDesc(cm_ConnectionInfo_t *connPtr,BufferDesc_t *pBufDesc); +Status_e ProcessKeyMgmtDataAp(BufferDesc_t *pBufDesc); +void InitStaKeyInfo(void *pConn,SecurityMode_t *secType,Cipher_t *pwCipher,UINT16 staRsnCap,UINT8 akmType); +void RemoveAPKeyInfo(void *pConn); +void InitGroupKey(cm_ConnectionInfo_t *connPtr); +void GenerateGTK_internal(KeyData_t *grpKeyData,UINT8 *nonce,IEEEtypes_Addr_t *StaMacAddr); +void PopulateKeyMsg(EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,Cipher_t *Cipher,UINT16 Type,UINT32 *replay_cnt,UINT8 *Nonce); +void prepareKDE(EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,KeyData_t *grKey,Cipher_t *cipher); +BOOLEAN Encrypt_keyData(EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,UINT8 *EAPOL_Encr_Key,Cipher_t *cipher); +void KeyMgmtAp_DerivePTK(UINT8 *pPMK,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa,UINT8 *ANonce,UINT8 *SNonce,UINT8 *EAPOL_MIC_Key,UINT8 *EAPOL_Encr_Key,KeyData_t *newPWKey,BOOLEAN use_kdf); +BOOLEAN KeyData_CopyWPAWP2(EAPOL_KeyMsg_Tx_t *pTxEAPOL,void *pIe); +BOOLEAN KeyData_UpdateKeyMaterial(EAPOL_KeyMsg_Tx_t *pTxEAPOL,SecurityMode_t *pSecType,void *pWPA,void *pWPA2); +void ROM_InitGTK(KeyData_t *grpKeyData,UINT8 *nonce,IEEEtypes_Addr_t *StaMacAddr); +void InitKeyMgmtInfo(apKeyMgmtInfoStaRom_t *pKeyMgmtInfo,SecurityMode_t *secType,Cipher_t *pwCipher,UINT16 staRsnCap,UINT8 akmType); +apInfo_t * cm_GetApInfo(cm_ConnectionInfo_t *connPtr); +apSpecificData_t * cm_GetApData(cm_ConnectionInfo_t *connPtr); +Status_e cm_AllocAPResources(cm_ConnectionInfo_t *connPtr); +Status_e cm_AllocResources(cm_ConnectionInfo_t *connPtr); +cm_ConnectionInfo_t *cm_InitConnection(UINT8 conType,UINT8 bssType,UINT8 bssNum,IEEEtypes_MacAddr_t *bssId,IEEEtypes_MacAddr_t *peerMacAddr,UINT8 channel,unkbyte0 *hostMdev); +void cm_DeleteConnection(cm_ConnectionInfo_t *connPtr); +void cm_SetPeerAddr(cm_ConnectionInfo_t *connPtr,IEEEtypes_MacAddr_t *bssId,IEEEtypes_MacAddr_t *peerMacAddr); +void cm_SetComData(cm_ConnectionInfo_t *connPtr,char *ssid); +void rf_set_channel(uint8_t bandwidth,uint16_t channel_freq); +void rf_dump_status(void); +int bl60x_check_mac_status(int *is_ok); +void helper_record_dump(void); +void helper_record_rc_rf_states(uint *param_1,uint *param_2); +void helper_record_all_states(char *func_name); +int phyif_utils_decode(phyif_utils_recvtable_t *vec,int8_t *ppm); +void blmac_pwr_mgt_setf(uint8_t pwrmgt); +chan_ctxt_tag * chan_get_next_chan(void); +void chan_conn_less_delay_prog(void); +void chan_upd_nb_rem_slots(uint32_t current_time); +_Bool chan_tbtt_detect_conflict(void); +void chan_tbtt_insert(chan_tbtt_tag *p_tbtt_entry); +void chan_upd_ctxt_status(chan_ctxt_tag *p_chan_entry,uint8_t next_status); +void chan_switch_start(chan_ctxt_tag *p_chan_entry); +void chan_conn_less_delay_evt(void *env); +void chan_tbtt_switch_evt(void *env); +void chan_tbtt_schedule(chan_tbtt_tag *p_tbtt_entry); +void chan_cde_evt(void *env); +void chan_goto_idle_cb(void); +void chan_tx_cfm(void *dummy,uint32_t status); +void chan_init(void); +void chan_scan_req(uint8_t band,uint16_t freq,int8_t pwr,uint32_t duration_us,uint8_t vif_index); +uint8_t chan_roc_req(mm_remain_on_channel_req *req,ke_task_id_t taskid); +uint8_t chan_ctxt_add(mm_chan_ctxt_add_req *p_add_req,uint8_t *idx); +void chan_ctxt_del(uint8_t chan_idx); +void chan_tbtt_switch_update(vif_info_tag *p_vif_entry,uint32_t tbtt_time); +void chan_bcn_to_evt(vif_info_tag *p_vif_entry); +void chan_bcn_detect_start(vif_info_tag *p_vif_entry); +_Bool chan_is_on_channel(vif_info_tag *p_vif_entry); +_Bool chan_is_tx_allowed(vif_info_tag *p_vif_entry); +_Bool chan_is_on_operational_channel(vif_info_tag *p_vif_entry); +void chan_update_tx_power(chan_ctxt_tag *p_chan_entry); +void chan_ctxt_link(uint8_t vif_idx,uint8_t chan_idx); +void chan_ctxt_unlink(uint8_t vif_idx); +void hal_dma_init(void); +void hal_mib_dump(void); +int mm_monitor_channel_req_handler(ke_msg_id_t msgid,mm_monitor_channel_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_monitor_enable_req_handler(ke_msg_id_t msgid,mm_monitor_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_cfg_rssi_req_handler(ke_msg_id_t msgid,mm_cfg_rssi_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_ps_options_req_handler(ke_msg_id_t msgid,mm_set_ps_options_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_tim_update_req_handler(ke_msg_id_t msgid,mm_tim_update_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_bcn_change_req_handler(ke_msg_id_t msgid,mm_bcn_change_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_remain_on_channel_req_handler(ke_msg_id_t msgid,mm_remain_on_channel_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_sta_del_req_handler(ke_msg_id_t msgid,mm_sta_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_sta_add_req_handler(ke_msg_id_t msgid,mm_sta_add_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_key_del_req_handler(ke_msg_id_t msgid,mm_key_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_key_add_req_handler(ke_msg_id_t msgid,mm_key_add_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_power_req_handler(ke_msg_id_t msgid,mm_set_power_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_idle_req_handler(ke_msg_id_t msgid,mm_set_idle_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_version_req_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_start_req_handler(ke_msg_id_t msgid,mm_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_ps_mode_req_handler(ke_msg_id_t msgid,mm_set_ps_mode_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_force_idle_req_handler(ke_msg_id_t msgid,mm_force_idle_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_hw_config_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int bl60x_edca_get(int ac,uint8_t *aifs,uint8_t *cwmin,uint8_t *cwmax,uint16_t *txop); +void rx_swdesc_init(void); +int scan_cancel_req_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scan_start_req_handler(ke_msg_id_t msgid,scan_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +undefined4 mm_scan_channel_end_ind_handler(void); +int mm_scan_channel_start_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +void txl_buffer_reinit(void); +void txl_buffer_init(void); +void txl_buffer_reset(void); +txl_buffer_tag * txl_buffer_alloc(txdesc *txdesc,uint8_t access_category,uint8_t user_idx); +void txl_buffer_update_thd(txdesc *txdesc); +void bam_init(void); +void bam_send_air_action_frame(int param_1,bam_env_tag *param_2,int param_3,uint8_t param_4,int param_5,uint16_t param_6,cfm_func_ptr *param_7); +undefined4 rxu_mgt_ind_handler(int param_1); +void co_pack8p(uint32_t dst,uint8_t *src,uint32_t len); +int phy_freq_to_channel(uint8_t band,uint16_t freq); +uint16_t phy_channel_to_freq(uint8_t band,int channel); +uint32_t me_add_ie_ssid(uint32_t *frame_addr,uint8_t ssid_len,uint8_t *p_ssid); +uint32_t me_add_ie_supp_rates(uint32_t *frame_addr,mac_rateset *p_rateset); +uint32_t me_add_ie_ext_supp_rates(uint32_t *frame_addr,mac_rateset *p_rateset); +uint32_t me_add_ie_ds(uint32_t *frame_addr,uint8_t channel); +uint32_t me_add_ie_erp(uint32_t *frame_addr,uint8_t erp_info); +uint32_t me_add_ie_rsn(uint32_t *frame_addr,uint8_t enc_type); +uint32_t me_add_ie_wpa(uint32_t *frame_addr,uint8_t enc_type); +uint32_t me_add_ie_tim(uint32_t *frame_addr,uint8_t dtim_period); +uint32_t me_add_ie_ht_capa(uint32_t *frame_addr); +uint32_t me_add_ie_ht_oper(uint32_t *frame_addr,vif_info_tag *p_vif_entry); +uint16_t me_build_authenticate(uint32_t frame,uint16_t algo_type,uint16_t seq_nbr,uint16_t status_code,uint32_t *challenge_array_ptr); +uint16_t me_build_deauthenticate(uint32_t frame,uint16_t reason_code); +uint16_t me_build_associate_req(uint32_t frame,mac_bss_info *bss,mac_addr *old_ap_addr_ptr,uint8_t vif_idx,uint32_t *ie_addr,uint16_t *ie_len,sm_connect_req *con_par); +uint16_t me_build_add_ba_req(uint32_t frame,bam_env_tag *bam_env); +uint16_t me_build_add_ba_rsp(uint32_t frame,bam_env_tag *bam_env,uint16_t param,uint8_t dialog_token,uint16_t status_code); +uint16_t me_build_del_ba(uint32_t frame,bam_env_tag *bam_env,uint16_t reason_code); +void me_extract_rate_set(uint32_t buffer,uint16_t buflen,mac_rateset *mac_rate_set_ptr); +void me_extract_power_constraint(uint32_t buffer,uint16_t buflen,mac_bss_info *bss); +void me_extract_country_reg(int param_1); +void me_extract_mobility_domain(uint32_t buffer,uint16_t buflen,mac_bss_info *bss); +uint me_extract_csa(undefined4 param_1,undefined4 param_2,undefined *param_3,int param_4); +uint16_t me_build_beacon(uint32_t frame,uint8_t vif_idx,uint16_t *tim_oft,uint8_t *tim_len,uint8_t hidden_ssid); +uint16_t me_build_probe_rsp(uint32_t frame,uint8_t vif_idx); +uint16_t me_build_associate_rsp(uint32_t frame,uint8_t vif_idx,uint16_t status_code,me_sta_add_req *req); +int me_rc_set_rate_req_handler(ke_msg_id_t msgid,me_rc_set_rate_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_rc_stats_req_handler(ke_msg_id_t msgid,me_rc_stats_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_traffic_ind_req_handler(ke_msg_id_t msgid,me_traffic_ind_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_sta_del_req_handler(ke_msg_id_t msgid,me_sta_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_control_port_req_handler(ke_msg_id_t msgid,me_set_control_port_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_chan_config_req_handler(ke_msg_id_t msgid,me_chan_config_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_ps_mode_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_idle_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_config_req_handler(ke_msg_id_t msgid,me_config_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_ps_disable_req_handler(ke_msg_id_t msgid,me_set_ps_disable_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_active_req_handler(ke_msg_id_t msgid,me_set_active_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_sta_add_req_handler(ke_msg_id_t msgid,me_sta_add_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +void cfm_raw_send(void *env,uint32_t status); +int scanu_raw_send_req_handler(ke_msg_id_t msgid,scanu_raw_send_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scanu_join_req_handler(ke_msg_id_t msgid,scanu_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scanu_start_req_handler(ke_msg_id_t msgid,scanu_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int rxu_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scan_done_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scan_start_cfm_handler(ke_msg_id_t msgid,scan_start_cfm *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_ps_disable_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_bss_param_setting_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int sm_rsp_timeout_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scanu_start_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_connection_loss_ind_handler(ke_msg_id_t msgid,mm_connection_loss_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scanu_join_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int sm_connect_req_handler(ke_msg_id_t msgid,sm_connect_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int rxu_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_vif_state_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_active_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_sta_add_cfm_handler(ke_msg_id_t msgid,mm_sta_add_cfm *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int sm_disconnect_req_handler(ke_msg_id_t msgid,sm_disconnect_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int apm_sta_connect_timeout_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int rxu_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int apm_sta_add_cfm_handler(ke_msg_id_t msgid,me_sta_add_cfm *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int apm_sta_del_req_handler(ke_msg_id_t msgid,apm_sta_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int apm_conf_max_sta_req_handler(ke_msg_id_t msgid,apm_conf_max_sta_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_ps_disable_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_bss_param_setting_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_bcn_change_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int apm_stop_req_handler(ke_msg_id_t msgid,apm_stop_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int apm_start_req_handler(ke_msg_id_t msgid,apm_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_active_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hostapd_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id); +void dump_cfg_entries(void); +int cfg_start_req_handler(ke_msg_id_t msgid,cfg_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +void dbg_test_print(char *fmt,...); +int dbg_get_sys_stat_req_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int dbg_mem_write_req_handler(ke_msg_id_t msgid,dbg_mem_write_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int dbg_mem_read_req_handler(ke_msg_id_t msgid,dbg_mem_read_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int dbg_set_sev_filter_req_handler(ke_msg_id_t msgid,dbg_set_sev_filter_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int dbg_set_mod_filter_req_handler(ke_msg_id_t msgid,dbg_set_mod_filter_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +co_list_hdr *ke_queue_extract(co_list *queue,anon_subr__Bool_co_list_hdr_ptr_uint32_t *func,uint32_t arg); +void bl_aes_128(UINT8 *key,UINT8 *input,UINT8 *output); +void xor_128(UINT8 *a,UINT8 *b,UINT8 *out); +void leftshift_onebit(UINT8 *input,UINT8 *output); +void generate_subkey(UINT8 *key,UINT8 *K1,UINT8 *K2); +void padding(UINT8 *lastb,UINT8 *pad,int length); +void bl_aes_cmac(UINT8 *key,UINT8 *input,int length,UINT8 *mac); +int BL_AES_MEMCMP(UINT8 *dst,UINT8 *src,int len); +void BL_AES_MEMSET(UINT8 *dst,UINT8 val,int size); +void BL_AES_MEMCPY(UINT8 *dst,UINT8 *src,int size); +int BL_AesEncrypt(UINT8 *kek,UINT8 kekLen,UINT8 *data,UINT8 *ret); +int BL_AesWrap(UINT8 *kek,UINT8 kekLen,UINT32 n,UINT8 *plain,UINT8 *keyIv,UINT8 *cipher); +int BL_AesUnWrap(UINT8 *kek,UINT8 kekLen,UINT32 n,UINT8 *cipher,UINT8 *keyIv,UINT8 *plain); +void Bl_hmac_md5(UINT8 *text_data,int text_len,UINT8 *key,int key_len,void *digest); +void Bl_hmac_sha1(uchar **ppText,int *pTextLen,int textNum,uchar *key,int key_len,uchar *output,int outputLen); +void Bl_PRF(uchar *key,int key_len,uchar *prefix,int prefix_len,uchar *data,int data_len,uchar *output,int len); +void wpa_MD5Transform(UINT32 *state,ulong *block); +void wpa_MD5Init(Bl_MD5_CTX *context); +void wpa_MD5Update(Bl_MD5_CTX *context,UINT8 *input,UINT32 inputLen); +void wpa_MD5Final(uchar *digest,Bl_MD5_CTX *context); +int rijndaelKeySetupEnc(u32 *rk,u8 *cipherKey,int keyBits); +void rijndael_set_key(rijndael_ctx *ctx,u8 *key,int bits,int encrypt); +void rijndael_decrypt(rijndael_ctx *ctx,u8 *src,u8 *dst); +void rijndael_encrypt(rijndael_ctx *ctx,u8 *src,u8 *dst); +void Bl_SHA1ProcessMessageBlock(Bl_SHA1_CTX *context); +int Bl_SHA1Init(Bl_SHA1_CTX *context); +int Bl_SHA1Final(Bl_SHA1_CTX *context,UINT8 *Message_Digest); +int Bl_SHA1Update(Bl_SHA1_CTX *context,UINT8 *message_array,uint length); +void ap_setpsk(cm_ConnectionInfo_t *connPtr,CHAR *ssid,CHAR *passphrase); +void ap_resetConfiguration(cm_ConnectionInfo_t *connPtr); +void InitializeAp(cm_ConnectionInfo_t *connPtr); +u32.conflict3 ipc_emb2app_rawstatus_get(void); +void ipc_host_init(ipc_host_env_tag *env,ipc_host_cb_tag *cb,ipc_shared_env_tag.conflict3 *shared_env_ptr,void *pthis); +int ipc_host_msg_push(ipc_host_env_tag *env,void *msg_buf,uint16_t len); +uint32_t ipc_host_get_rawstatus(ipc_host_env_tag *env); +txdesc_host * ipc_host_txdesc_get(ipc_host_env_tag *env); +void ipc_host_txdesc_push(ipc_host_env_tag *env,void *host_id); +void ipc_host_irq(ipc_host_env_tag *env,uint32_t status); +void ipc_host_enable_irq(ipc_host_env_tag *env,uint32_t value); +void ipc_host_disable_irq_e2a(void); +int bl_main_disconnect(void); +int bl_main_powersaving(int mode); +int bl_main_denoise(int mode); +int bl_main_monitor(void); +int bl_main_phy_up(void); +int bl_main_monitor_channel_set(int channel,int use_40MHZ); +int bl_main_if_remove(uint8_t vif_index); +int bl_main_raw_send(uint8_t *pkt,int len); +int bl_main_rate_config(uint8_t sta_idx,uint16_t fixed_rate_cfg); +int bl_main_set_country_code(char *country_code); +int bl_main_get_channel_nums(void); +int bl_main_if_add(int is_sta,netif *netif,uint8_t *vif_index); +int bl_main_apm_start(char *ssid,char *password,int channel,uint8_t vif_index,uint8_t hidden_ssid); +int bl_main_apm_stop(uint8_t vif_index); +int bl_main_apm_sta_cnt_get(uint8_t *sta_cnt); +int bl_main_apm_sta_info_get(wifi_apm_sta_info *apm_sta_info,uint8_t idx); +int bl_main_apm_sta_delete(uint8_t sta_idx); +int bl_main_apm_remove_all_sta(void); +int bl_main_conf_max_sta(uint8_t max_sta_supported); +int bl_main_cfg_task_req(uint32_t ops,uint32_t task,uint32_t element,uint32_t type,void *arg1,void *arg2); +int bl_main_scan(void); +int bl_cfg80211_connect(bl_hw *bl_hw,cfg80211_connect_params *sme); +int bl_main_connect(uint8_t *ssid,int ssid_len,uint8_t *psk,int psk_len,uint8_t *pmk,int pmk_len,uint8_t *mac,uint8_t band,uint16_t freq); +void bl_main_event_handle(void); +void bl_main_lowlevel_init(void); +int bl_main_rtthread_start(bl_hw **bl_hw); +int bl_handle_dynparams(bl_hw *bl_hw); +int bl_send_msg(bl_hw *bl_hw,void *msg_params,int reqcfm,lmac_msg_id_t reqid,void *cfm); +void * bl_msg_zalloc(lmac_msg_id_t id,lmac_task_id_t dest_id,uint16_t param_len); +void bl_msg_update_channel_cfg(char *code); +int bl_msg_get_channel_nums(void); +int bl_send_reset(bl_hw *bl_hw); +int bl_send_monitor_enable(bl_hw *bl_hw,mm_monitor_cfm *cfm); +int bl_send_monitor_channel_set(bl_hw *bl_hw,mm_monitor_channel_cfm *cfm,int channel,int use_40Mhz); +int bl_send_version_req(bl_hw *bl_hw,mm_version_cfm *cfm); +int bl_send_me_config_req(bl_hw *bl_hw); +int bl_send_me_chan_config_req(bl_hw *bl_hw); +int bl_send_me_rate_config_req(bl_hw *bl_hw,uchar sta_idx,uint16_t fixed_rate_cfg); +int bl_send_start(bl_hw *bl_hw); +int bl_send_add_if(bl_hw *bl_hw,uchar *mac,nl80211_iftype iftype,_Bool p2p,mm_add_if_cfm *cfm); +int bl_send_remove_if(bl_hw *bl_hw,uchar inst_nbr); +int bl_send_scanu_req(bl_hw *bl_hw); +int bl_send_scanu_raw_send(bl_hw *bl_hw,uint8_t *pkt,int len); +int bl_send_sm_connect_req(bl_hw *bl_hw,cfg80211_connect_params *sme,sm_connect_cfm *cfm); +int bl_send_sm_disconnect_req(bl_hw *bl_hw,u16 reason); +int bl_send_mm_powersaving_req(bl_hw *bl_hw,int mode); +int bl_send_mm_denoise_req(bl_hw *bl_hw,int mode); +int bl_send_apm_start_req(bl_hw *bl_hw,apm_start_cfm *cfm,char *ssid,char *password,int channel,uchar vif_index,uchar hidden_ssid); +int bl_send_apm_stop_req(bl_hw *bl_hw,uchar vif_idx); +int bl_send_apm_sta_del_req(bl_hw *bl_hw,apm_sta_del_cfm *cfm,uchar sta_idx,uchar vif_idx); +int bl_send_apm_conf_max_sta_req(bl_hw *bl_hw,uchar max_sta_supported); +int bl_send_cfg_task_req(bl_hw *bl_hw,uint32_t ops,uint32_t task,uint32_t element,uint32_t type,void *arg1,void *arg2); +int bl_platform_on(bl_hw *bl_hw); +int bl_rx_chan_pre_switch_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_rssi_status_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_apm_sta_del_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_apm_sta_add_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +void notify_event_scan_done(int join_scan); +int bl_rx_scanu_join_cfm(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_scanu_start_cfm(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_chan_switch_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_sm_connect_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_sm_disconnect_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +undefined4 bl_rx_scanu_result_ind(int param_1,longlong param_2); +undefined4 bl_rx_mesh_path_update_ind(void); +undefined4 bl_rx_mesh_proxy_update_ind(void); +undefined4 bl_rx_remain_on_channel_exp_ind(void); +undefined4 bl_rx_ps_change_ind(void); +undefined4 bl_rx_traffic_req_ind(void); +undefined4 bl_rx_csa_counter_ind(void); +undefined4 bl_rx_csa_finish_ind(void); +undefined4 bl_rx_csa_traffic_ind(void); +undefined4 bl_rx_channel_survey_ind(void); +undefined4 bl_rx_dbg_error_ind(void); +undefined4 bl_rx_tdls_chan_switch_cfm(void); +undefined4 bl_rx_tdls_chan_switch_ind(void); +undefined4 bl_rx_tdls_chan_switch_base_ind(void); +undefined4 bl_rx_tdls_peer_ps_ind(void); +undefined4 bl_rx_me_tkip_mic_failure_ind(void); +undefined4 bl_rx_me_tx_credits_update_ind(void); +undefined4 bl_rx_mesh_path_create_cfm(void); +undefined4 bl_rx_mesh_peer_update_ind(void); +int bl_rx_sm_connect_ind_cb_register(void *env,wifi_event_sm_connect_ind_cb_t *cb); +int bl_rx_sm_disconnect_ind_cb_register(void *env,wifi_event_sm_disconnect_ind_cb_t *cb); +int bl_rx_beacon_ind_cb_register(void *env,wifi_event_beacon_ind_cb_t *cb); +int bl_rx_probe_resp_ind_cb_register(void *env,wifi_event_probe_resp_ind_cb_t *cb); +int bl_rx_pkt_cb_register(void *env,wifi_event_pkt_cb_t *cb); +int bl_rx_pkt_cb_unregister(void *env); +int bl_rx_rssi_cb_register(void *env,wifi_event_rssi_cb_t *cb); +int bl_rx_event_register(void *env,wifi_event_cb_t *cb); +void bl_rx_e2a_handler(void *arg); +void bl_rx_pkt_cb(uint8_t *pkt,int len); +void bl_tx_push(bl_hw *bl_hw,bl_txhdr.conflict1 *txhdr); +void bl_tx_resend(void); +void bl_tx_try_flush(void); +int bl_txdatacfm(void *pthis,void *host_id); +void bl_tx_notify(void); +err_t bl_output(bl_hw *bl_hw,netif *netif,pbuf *p,int is_sta); +u8 bl_radarind(void *pthis,void *hostid); +u8 bl_msgackind(void *pthis,void *hostid); +void bl_prim_tbtt_ind(void *pthis); +void my_pbuf_free_custom(pbuf *p); +undefined4 bl_dbgind(void); +void bl_sec_tbtt_ind(void); +void my_pbuf_free_custom_fake(void); +int tcpip_stack_input(void *swdesc,uchar status,void *hwhdr,uint msdu_offset,wifi_pkt *pkt); +int bl_utils_idx_lookup(bl_hw *bl_hw,uint8_t *mac); +int bl_ipc_init(bl_hw *bl_hw,ipc_shared_env_tag.conflict21 *ipc_shared_mem); +void bl_utils_dump(void); +_Bool stateSnifferGuard(void *ch,event *event); +_Bool stateConnectedIPYesGuard_ip_update(void *ch,event *event); +void printErrMsg(void *stateData,event *event); +void stateSnifferExit(void *stateData,event *event); +void stateSnifferAction(void *oldStateData,event *event,void *newStateData); +void stateConnectedIPNoAction_ipgot(void *oldStateData,event *event,void *newStateData); +void stateGlobalEnter(void *stateData,event *event); +void stateGlobalAction(void *oldStateData,event *event,void *newStateData); +void stateConnectingEnter(void *stateData,event *event); +_Bool stateSnifferGuard_ChannelSet(void *ch,event *event); +_Bool stateIdleGuard_sniffer(void *ev,event *event); +void stateConnectedIPNoExit(void *stateData,event *event); +void stateDisconnect_action_idle(void *oldStateData,event *event,void *newStateData); +void stateDisconnect_action_reconnect(void *oldStateData,event *event,void *newStateData); +void ip_obtaining_timeout(timer_cb_arg_t data); +void stateConnectedIPNoEnter(void *stateData,event *event); +_Bool stateConnectedIPNoGuard_disconnect(void *ch,event *event); +_Bool stateConnectedIPYesGuard_disconnect(void *ch,event *event); +_Bool stateConnectedIPYesGuard_rcconfig(void *ch,event *event); +void stateIdleAction_connect(void *oldStateData,event *event,void *newStateData); +_Bool stateGlobal_cfg_req(void *ch,event *event); +_Bool stateGlobalGuard_fw_powersaving(void *ch,event *event); +_Bool stateGlobalGuard_conf_max_sta(void *ev,event *event); +_Bool stateGlobalGuard_AP(void *ev,event *event); +_Bool stateGlobalGuard_scan_beacon(void *ch,event *event); +void __reload_tsen(timer_cb_arg_t data); +void event_cb_wifi_event_mgmr(input_event_t *event,void *private_data); +void trigger_auto_denoise(void *arg); +void stateDisconnect_exit(void *stateData,event *event); +void disconnect_retry(timer_cb_arg_t data); +_Bool stateGlobalGuard_fw_disconnect(void *ch,event *event); +void stateConnectedIPYes_exit(void *stateData,event *event); +_Bool stateGlobalGuard_denoise(void *ev,event *event); +_Bool stateIdleGuard_connect(void *ev,event *event); +_Bool stateIfaceDownGuard_phyup(void *ev,event *event); +_Bool stateSnifferGuard_raw_send(void *ch,event *event); +_Bool stateGlobalGuard_stop(void *ev,event *event); +_Bool stateGlobalGuard_enable_autoreconnect(void *ch,event *event); +_Bool stateGlobalGuard_disable_autoreconnect(void *ch,event *event); +void stateDisconnect_enter(void *stateData,event *event); +_Bool stateGlobalGuard_fw_scan(void *ch,event *event); +uint stateDisconnect_guard(uint param_1,int param_2); +void stateGlobalExit(void); +void stateSnifferEnter(void); +uint stateConnectingGuard(uint param_1,int param_2); +void stateConnectingAction_connected(void); +void stateConnectingAction_disconnect(void); +void stateConnectingExit(void); +void stateIdleAction_sniffer(void); +void stateIdleEnter(void); +void stateIdleExit(void); +void stateIfaceDownAction_phyup(void); +void stateIfaceDownEnter(void); +void stateIfaceDownExit(void); +uint stateConnectedIPNoGuard(uint param_1,int param_2); +void stateConnectedIPNoAction_disconnect(void); +uint stateConnectedIPYesGuard(uint param_1,int param_2); +void stateConnectedIPYes_action(void); +void stateConnectedIPYes_enter(void *stateData,event *event); +char * wifi_mgmr_auth_to_str(uint8_t auth); +char * wifi_mgmr_cipher_to_str(uint8_t cipher); +int wifi_mgmr_event_notify(wifi_mgmr_msg_t *msg); +void wifi_mgmr_start(void); +void _wifi_mgmr_entry(void *pvParameters); +void wifi_mgmr_start_background(wifi_conf_t *conf); +int wifi_mgmr_init(void); +int wifi_mgmr_status_code_clean_internal(void); +int wifi_mgmr_state_get_internal(int *state); +void wifi_mgmr_set_connect_stat_info(wifi_event_sm_connect_ind *ind,uint8_t type_ind); +int wifi_mgmr_set_country_code_internal(char *country_code); +int wifi_mgmr_ap_sta_cnt_get_internal(uint8_t *sta_cnt); +int wifi_mgmr_ap_sta_info_get_internal(wifi_mgmr_sta_basic_info_t *sta_info_internal,uint8_t idx); +int wifi_mgmr_ap_sta_delete_internal(uint8_t sta_idx); +int wifi_mgmr_scan_complete_notify(void); +int wifi_mgmr_api_connect(char *ssid,char *psk,char *pmk,uint8_t *mac,uint8_t band,uint16_t freq); +int wifi_mgmr_api_cfg_req(uint32_t ops,uint32_t task,uint32_t element,uint32_t type,uint32_t length,uint32_t *buf); +int wifi_mgmr_api_ip_got(uint32_t ip,uint32_t mask,uint32_t gw,uint32_t dns1,uint32_t dns2); +int wifi_mgmr_api_ip_update(void); +int wifi_mgmr_api_reconnect(void); +int wifi_mgmr_api_disable_autoreconnect(void); +int wifi_mgmr_api_enable_autoreconnect(void); +int wifi_mgmr_api_disconnect(void); +int wifi_mgmr_api_rate_config(uint16_t config); +int wifi_mgmr_api_conf_max_sta(uint8_t max_sta_supported); +int wifi_mgmr_api_ifaceup(void); +int wifi_mgmr_api_sniffer_enable(void); +int wifi_mgmr_api_scan_item_beacon(uint8_t channel,int8_t rssi,uint8_t auth,uint8_t *mac,uint8_t *ssid,int len,int8_t ppm_abs,int8_t ppm_rel,uint8_t cipher); +int wifi_mgmr_api_fw_disconnect(void); +int wifi_mgmr_api_fw_tsen_reload(void); +int wifi_mgmr_api_fw_scan(void); +int wifi_mgmr_api_fw_powersaving(int mode); +int wifi_mgmr_api_ap_start(char *ssid,char *passwd,int channel,uint8_t hidden_ssid); +int wifi_mgmr_api_ap_stop(void); +int wifi_mgmr_api_idle(void); +int wifi_mgmr_api_denoise_enable(void); +int wifi_mgmr_api_denoise_disable(void); +int wifi_mgmr_api_raw_send(uint8_t *pkt,int len); +int wifi_mgmr_api_set_country_code(char *country_code); +void cmd_rf_dump(char *buf,int len,int argc,char **argv); +void cmd_dump_reset(char *buf,int len,int argc,char **argv); +void cmd_wifi_power_table_update(char *buf,int len,int argc,char **argv); +void cmd_wifi_state_get(char *buf,int len,int argc,char **argv); +void wifi_sta_get_state_cmd(char *buf,int len,int argc,char **argv); +void wifi_edca_dump_cmd(char *buf,int len,int argc,char **argv); +void wifi_ap_sta_list_get_cmd(char *buf,int len,int argc,char **argv); +void wifi_ap_sta_delete_cmd(char *buf,int len,int argc,char **argv); +void cmd_wifi_coex_pta_force_off(char *buf,int len,int argc,char **argv); +void cmd_wifi_coex_pta_force_on(char *buf,int len,int argc,char **argv); +void cmd_wifi_coex_pti_force_off(char *buf,int len,int argc,char **argv); +void cmd_wifi_coex_pti_force_on(char *buf,int len,int argc,char **argv); +void cmd_wifi_coex_rf_force_off(char *buf,int len,int argc,char **argv); +void cmd_wifi_coex_rf_force_on(char *buf,int len,int argc,char **argv); +void cmd_wifi_mib(char *buf,int len,int argc,char **argv); +void cmd_wifi_cfg(char *buf,int len,int argc,char **argv); +void cmd_wifi_ap_stop(char *buf,int len,int argc,char **argv); +void cmd_wifi_ap_start(char *buf,int len,int argc,char **argv); +void wifi_sniffer_off_cmd(char *buf,int len,int argc,char **argv); +void wifi_sniffer_on_cmd(char *buf,int len,int argc,char **argv); +int wifi_denoise_disable_cmd(void); +int wifi_denoise_enable_cmd(void); +void wifi_power_saving_off_cmd(char *buf,int len,int argc,char **argv); +void wifi_power_saving_on_cmd(char *buf,int len,int argc,char **argv); +void wifi_rc_fixed_disable(char *buf,int len,int argc,char **argv); +int wifi_disable_autoreconnect_cmd(void); +int wifi_enable_autoreconnect_cmd(void); +void wifi_disconnect_cmd(char *buf,int len,int argc,char **argv); +int wifi_sta_ip_unset_cmd(void); +void wifi_sta_ip_info(char *buf,int len,int argc,char **argv); +void cmd_wifi_raw_send(char *buf,int len,int argc,char **argv); +void wifi_scan_cmd(char *buf,int len,int argc,char **argv); +void sniffer_cb(void *env,uint8_t *pkt,int len); +void cmd_wifi_dump(char *buf,int len,int argc,char **argv); +void cmd_wifi_ap_conf_max_sta(char *buf,int len,int argc,char **argv); +void wifi_mon_cmd(char *buf,int len,int argc,char **argv); +void wifi_rc_fixed_enable(char *buf,int len,int argc,char **argv); +void wifi_connect_cmd(char *buf,int len,int argc,char **argv); +void wifi_sta_ip_set_cmd(char *buf,int len,int argc,char **argv); +void wifi_scan_filter_cmd(char *buf,int len,int argc,char **argv); +void wifi_capcode_cmd(char *buf,int len,int argc,char **argv); +int wifi_mgmr_cli_scanlist(void); +int wifi_mgmr_ext_dump_needed(void); +int wifi_mgmr_cli_init(void); +int mac_is_unvalid(uint8_t *mac); +void cb_scan_item_parse(wifi_mgmr_ap_item_t *env,uint32_t *param1,wifi_mgmr_ap_item_t *item); +void cb_scan_complete(void *data,void *param); +int wifi_mgmr_drv_init(wifi_conf_t *conf); +wifi_interface_t wifi_mgmr_sta_enable(void); +int wifi_mgmr_sta_disable(wifi_interface_t *interface); +int wifi_mgmr_sta_ip_get(uint32_t *ip,uint32_t *gw,uint32_t *mask); +int wifi_mgmr_sta_dns_get(uint32_t *dns1,uint32_t *dns2); +int wifi_mgmr_sta_ip_set(uint32_t ip,uint32_t mask,uint32_t gw,uint32_t dns1,uint32_t dns2); +int wifi_mgmr_sta_ip_unset(void); +int wifi_mgmr_sta_disconnect(void); +int wifi_mgmr_sta_powersaving(int ps); +int wifi_mgmr_sta_autoconnect_enable(void); +int wifi_mgmr_sta_autoconnect_disable(void); +void wifi_mgmr_sta_connect_ind_stat_get(wifi_mgmr_sta_connect_ind_stat_info_t *wifi_mgmr_ind_stat); +void wifi_mgmr_sta_ssid_set(char *ssid); +void wifi_mgmr_sta_psk_set(char *psk); +int wifi_mgmr_sta_connect(wifi_interface_t *wifi_interface,char *ssid,char *psk,char *pmk,uint8_t *mac,uint8_t band,uint16_t freq); +wifi_interface_t wifi_mgmr_ap_enable(void); +int wifi_mgmr_ap_mac_get(uint8_t *mac); +int wifi_mgmr_ap_ip_get(uint32_t *ip,uint32_t *gw,uint32_t *mask); +int wifi_mgmr_ap_start(wifi_interface_t *interface,char *ssid,int hidden_ssid,char *passwd,int channel); +int wifi_mgmr_ap_stop(wifi_interface_t *interface); +int wifi_mgmr_ap_sta_cnt_get(uint8_t *sta_cnt); +int wifi_mgmr_ap_sta_info_get(wifi_sta_basic_info *sta_info,uint8_t idx); +int wifi_mgmr_ap_sta_delete(uint8_t sta_idx); +int wifi_mgmr_sniffer_register(void *env,sniffer_cb_t *cb); +int wifi_mgmr_sniffer_unregister(void *env); +int wifi_mgmr_sniffer_enable(void); +int wifi_mgmr_sniffer_disable(void); +int wifi_mgmr_rate_config(uint16_t config); +int wifi_mgmr_conf_max_sta(uint8_t max_sta_supported); +int wifi_mgmr_state_get(int *state); +int wifi_mgmr_rssi_get(int *rssi); +int wifi_mgmr_raw_80211_send(uint8_t *pkt,int len); +int wifi_mgmr_scan(void *data,scan_complete_cb_t *cb); +int wifi_mgmr_cfg_req(uint32_t ops,uint32_t task,uint32_t element,uint32_t type,uint32_t length,uint32_t *buf); +int wifi_mgmr_scan_filter_hidden_ssid(int filter); +int wifi_mgmr_scan_complete_callback(void); +int wifi_mgmr_scan_ap_all(wifi_mgmr_ap_item_t *env,uint32_t *param1,scan_item_cb_t *cb); +int wifi_mgmr_all_ap_scan(wifi_mgmr_ap_item_t **ap_ary,uint32_t *num); +char * wifi_mgmr_status_code_str(uint16_t status_code); +int wifi_mgmr_profile_add(wifi_mgmr_t *mgmr,wifi_mgmr_profile_msg_t *profile_msg,int index); +int wifi_mgmr_profile_get(wifi_mgmr_t *mgmr,wifi_mgmr_profile_msg_t *profile_msg); +int wifi_mgmr_profile_autoreconnect_is_enabled(wifi_mgmr_t *mgmr,int index); +int wifi_mgmr_profile_autoreconnect_disable(wifi_mgmr_t *mgmr,int index); +int wifi_mgmr_profile_autoreconnect_enable(wifi_mgmr_t *mgmr,int index); +int wifi_netif_dhcp_start(netif *netif); +void cb_rssi_ind(void *env,int8_t rssi); +void cb_probe_resp_ind(void *env); +void cb_beacon_ind(void *env,wifi_event_beacon_ind.conflict4 *ind); +void cb_disconnect_ind(void *env,wifi_event_sm_disconnect_ind *ind); +void cb_connect_ind(void *env,wifi_event_sm_connect_ind *ind); +void cb_event_ind(void *env,wifi_event *event); +int wifi_mgmr_event_init(void); +void cmd_mgr_print(bl_cmd_mgr *cmd_mgr); +void cmd_complete(bl_cmd *cmd); +int cmd_mgr_msgind(bl_cmd_mgr *cmd_mgr,ipc_e2a_msg *msg,msg_cb_fct *cb); +int cmd_mgr_llind(bl_cmd_mgr *cmd_mgr,bl_cmd *cmd); +undefined4 cmd_mgr_queue(char *param_1,char **param_2); +void cmd_mgr_drain(bl_cmd_mgr *cmd_mgr); +void bl_cmd_mgr_init(bl_cmd_mgr *cmd_mgr); +int bl_irqs_init(bl_hw *bl_hw); +void bl_irq_bottomhalf(bl_hw *bl_hw); +void goToErrorState(stateMachine *fsm,event *event); +void stateM_init(stateMachine *fsm,state *initialState,state *errorState); +int stateM_handleEvent(stateMachine *fsm,event *event); +void netif_status_callback(netif *netif); +err_t wifi_tx(netif *netif,pbuf *p); +err_t bl606a0_wifi_netif_init(netif *netif); +int bl606a0_wifi_init(wifi_conf_t *conf); +void lld_wlcoex_set(int param_1); +void coex_dump_ble(void); +uint32_t BLE_ROM_patch(void *pRet,...); +void blecontroller_main(void *pvParameters); +void BLE_ROM_hook_init(void); +_Bool rw_main_task_post(void *msg,uint32_t timeout); +void rw_main_task_post_from_fw(void); +void bdaddr_init(void); +void ble_controller_init(uint8_t task_priority); +void ble_controller_deinit(void); +void rwble_init(void); +void rwble_isr_clear(void); +void rwble_isr(void); +uint8_t ea_conflict_check(ea_elt_tag *evt_a,ea_elt_tag *evt_b); +void ea_elt_cancel(ea_elt_tag *param_1); +void ea_init(_Bool reset); +ea_elt_tag * ea_elt_create(uint16_t size_of_env); +ea_interval_tag * ea_interval_create(void); +void ea_interval_insert(ea_interval_tag *interval_to_add); +void ea_interval_remove(ea_interval_tag *interval_to_remove); +void ea_sw_isr(void); +uint8_t ea_offset_req(ea_param_input *input_param,ea_param_output *output_param); +uint32_t ea_time_get_halfslot_rounded(void); +uint32_t ea_time_get_slot_rounded(void); +void ea_prog_timer(void); +void ea_finetimer_isr(void); +void ea_interval_duration_req(ea_param_input *input_param,ea_param_output *output_param); +void hci_send_2_host(void *param); +void hci_send_2_controller(int param_1); +uint8_t hci_evt_mask_set(evt_mask *evt_msk,uint8_t page); +void hci_init(void); +void hci_reset(void); +void rwip_init(uint32_t error); +void rwip_schedule(void); +void rwip_wakeup_delay_set(uint16_t wakeup_delay); +void rwip_wakeup(void); +void rwip_wakeup_end(void); +uint32_t rwip_sleep_lpcycles_2_us(uint32_t lpcycles); +uint32_t rwip_us_2_lpcycles(uint32_t us); +void ble_co_list_init(co_list *list); +void ble_co_list_push_back(int *param_1,undefined4 *param_2); +void ble_co_list_push_front(co_list *list,co_list_hdr *list_hdr); +co_list_hdr * ble_co_list_pop_front(co_list *list); +_Bool ble_co_list_extract(co_list *list,co_list_hdr *list_hdr,uint8_t nb_following); +void ble_co_list_extract_after(co_list *list,co_list_hdr *elt_ref_hdr,co_list_hdr *elt_to_rem_hdr); +_Bool ble_co_list_find(co_list *list,co_list_hdr *list_hdr); +void ble_co_list_merge(int *param_1,int *param_2); +void ble_co_list_insert_after(co_list *list,co_list_hdr *elt_ref_hdr,co_list_hdr *elt_to_add_hdr); +uint16_t ble_co_list_size(co_list *list); +void co_bdaddr_set(uint8_t *bdaddr); +_Bool co_bdaddr_compare(bd_addr *bd_address1,bd_addr *bd_address2); +void Mont2GF(uint8_t reg_idx); +void getFinalPoint(uint8_t reg_idx); +void pka_point_addition(uint8_t x1_idx,uint8_t x2_idx,uint8_t ret_idx); +void pka_read_result(ECC_Jacobian_Point256 *point,uint8_t idx); +void pka_cp_x2_to_x1(uint8_t x1_idx,uint8_t x2_idx); +void pka_point_inf_check(uint8_t x1_idx,uint8_t *p1_eq_inf); +void GF2Mont(u_int32 *numA,u_int32 *result); +void pka_point_double(uint8_t x_idx); +void pka_addition_win(ECC_Jacobian_Point256 *src1,ECC_Jacobian_Point256 *src2,ECC_Jacobian_Point256 *ret); +void ecc_multiplication_event_handler(uint8_t param_1); +void ecc_init(int param_1); +uint8_t ecc_generate_key256(u_int8 key_type,u_int8 *secret_key,u_int8 *public_key_x,u_int8 *public_key_y,ke_msg_id_t msg_id,ke_task_id_t task_id); +void ecc_gen_new_public_key(u_int8 *secret_key,ke_msg_id_t msg_id,ke_task_id_t task_id); +void ecc_gen_new_secret_key(uint8_t *secret_key256,_Bool forced); +void ble_ke_event_init(void); +uint8_t ble_ke_event_callback_set(uint8_t event_type,intCallback_Type *p_callback); +void ble_ke_event_flush(void); +void ble_ke_event_schedule(void); +_Bool ble_ke_mem_is_in_heap(uint8_t type,void *mem_ptr); +_Bool ble_ke_is_free(void *mem_ptr); +void * ble_ke_msg_alloc(ke_msg_id_t id,ke_task_id_t dest_id,ke_task_id_t src_id,uint16_t param_len); +void ble_ke_msg_send_basic(ke_msg_id_t id,ke_task_id_t dest_id,ke_task_id_t src_id); +void ble_ke_msg_free(ke_msg *msg); +_Bool ble_cmp_abs_time(co_list_hdr *timerA,co_list_hdr *timerB); +_Bool ble_cmp_timer_id(co_list_hdr *timer,uint32_t timer_task); +uint32_t ble_ke_time(void); +_Bool ble_ke_time_cmp(uint32_t newer,uint32_t older); +_Bool ble_ke_time_past(uint32_t time); +void ble_ke_timer_hw_set(ke_timer *timer); +void ble_ke_timer_schedule(void); +void ble_ke_timer_init(void); +void ble_ke_timer_set(ke_msg_id_t timer_id,ke_task_id_t task_id,uint32_t delay); +void ble_ke_timer_clear(ke_msg_id_t timer_id,ke_task_id_t task_id); +_Bool ble_ke_timer_active(ke_msg_id_t timer_id,ke_task_id_t task_id); +void ble_ke_init(void); +void ble_ke_flush(void); +void rf_force_agc_enable(_Bool en); +uint8_t rf_txpwr_dbm_get(uint8_t txpwr_idx,uint8_t modulation); +int8_t rf_rssi_convert(uint8_t rssi_reg); +uint32_t rf_reg_rd(uint16_t addr); +void rf_reg_wr(uint16_t addr,uint32_t value); +void rf_sleep(void); +_Bool rf_txpwr_dec(uint8_t dec); +_Bool rf_txpwr_inc(uint8_t inc); +void rf_txpwr_max_set(int8_t txpwr_dbm); +void rf_reset(void); +void ble_rf_set_pwr_offset(int8_t offset); +void ble_controller_set_tx_pwr(int ble_tx_power); +void ble_rf_init(rwip_rf_api.conflict1 *api); +void pka0_write_common_op_first_cfg(uint8_t s0_reg_index,uint8_t s0_reg_type,uint8_t d_reg_index,uint8_t d_reg_type,uint8_t op,_Bool last_op); +void pka0_write_common_op_snd_cfg_S1(uint8_t s1_reg_index,uint8_t s1_reg_type); +void pka0_write_common_op_snd_cfg_S1_S2(uint8_t s1_reg_index,uint8_t s1_reg_type,uint8_t s2_reg_index,uint8_t s2_reg_type); +void sec_eng_pka0_reset(void); +void sec_eng_pka0_clear_int(void); +void sec_eng_pka0_pld(uint16_t size,uint32_t *data,uint8_t reg_index,uint8_t reg_type,uint8_t op,_Bool last_op); +void sec_eng_pka0_wait_4_isr(void); +void sec_eng_pka0_read_data(uint8_t reg_ype,uint8_t reg_idx,uint32_t *result,uint8_t ret_size); +void sec_eng_pka0_clir(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t size); +void sec_eng_pka0_movdat(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type,uint8_t s0_reg_idx); +void sec_eng_pka0_msub(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type,uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx,uint8_t s2_reg_type,uint8_t s2_reg_idx); +void sec_eng_pka0_mrem(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type,uint8_t s0_reg_idx,uint8_t s2_reg_type,uint8_t s2_reg_idx); +void sec_eng_pka0_mmul(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type,uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx,uint8_t s2_reg_type,uint8_t s2_reg_idx); +void sec_eng_pka0_mexp(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type,uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx,uint8_t s2_reg_type,uint8_t s2_reg_idx); +void sec_eng_pka0_lcmp(uint8_t *cout,uint8_t s0_reg_type,uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx); +void sec_eng_pka0_lsub(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type,uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx); +void sec_eng_pka0_lmul(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type,uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx); +void sec_eng_pka0_lmul2n(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type,uint8_t s0_reg_idx,uint16_t bit_shift); +void em_buf_init(void); +void em_buf_rx_free(uint8_t hdl); +uint8_t * em_buf_rx_buff_addr_get(uint16_t rx_hdl); +void llc_init(void); +void llc_stop(int param_1); +void llc_reset(void); +void llc_discon_event_complete_send(ke_task_id_t src_id,uint8_t status,uint8_t conhdl,uint8_t reason); +void llc_le_con_cmp_evt_send(uint8_t status,uint16_t conhdl,llc_create_con_req_ind *param); +void llc_le_ch_sel_algo_evt_send(uint8_t chSel,uint16_t conhdl,llc_create_con_req_ind *param); +void llc_start(llc_create_con_req_ind *param_1,ea_elt_tag *param_2); +void llc_con_update_complete_send(uint8_t status,uint16_t conhdl,lld_evt_tag *evt); +void llc_ltk_req_send(uint16_t conhdl,llcp_enc_req *param); +void llc_feats_rd_event_send(uint8_t status,uint16_t conhdl,le_features *feats); +void llc_version_rd_event_send(uint8_t status,uint16_t conhdl); +void llc_common_cmd_complete_send(uint16_t opcode,uint8_t status,uint16_t conhdl); +void llc_common_cmd_status_send(uint16_t opcode,uint8_t status,uint16_t conhdl); +void llc_common_flush_occurred_send(uint16_t conhdl); +void llc_common_enc_key_ref_comp_evt_send(uint16_t conhdl,uint8_t status); +void llc_common_enc_change_evt_send(uint16_t conhdl,uint8_t enc_status,uint8_t status); +void llc_common_nb_of_pkt_comp_evt_send(uint16_t conhdl,uint8_t nb_of_pkt); +void llc_con_update_ind(uint16_t conhdl,ea_elt_tag *elt_new); +void llc_lsto_con_update(uint16_t conhdl); +void llc_map_update_ind(uint16_t conhdl); +void llc_con_update_finished(int param_1); +void llc_map_update_finished(int param_1); +void lld_evt_winsize_change(lld_evt_tag *evt,_Bool instant); +void lld_evt_slave_time_compute(ea_elt_tag *elt,uint16_t slot_offset); +void lld_evt_prevent_stop(ea_elt_tag *elt); +void lld_evt_deferred_elt_push(ea_elt_tag *elt,uint8_t type,uint8_t rx_desc_cnt); +void lld_evt_elt_wait_insert(ea_elt_tag *elt); +uint32_t lld_evt_get_next_free_slot(void); +lld_evt_wait_tag * lld_evt_elt_wait_get(ea_elt_tag *elt); +void lld_evt_schedule(ea_elt_tag *elt); +void lld_evt_channel_next(uint16_t conhdl,int16_t nb_inc); +uint16_t lld_evt_drift_compute(uint16_t delay,uint8_t master_sca); +void lld_evt_rxwin_compute(ea_elt_tag *elt); +void lld_evt_canceled(ea_elt_tag *elt); +ea_elt_tag * lld_evt_scan_create(uint16_t handle,uint16_t latency); +ea_elt_tag *lld_evt_move_to_master(ea_elt_tag *elt_scan,uint16_t conhdl,llc_create_con_req_ind *pdu_tx,uint8_t rx_hdl); +ea_elt_tag *lld_evt_update_create(ea_elt_tag *elt_old,uint16_t ce_len,uint16_t mininterval,uint16_t maxinterval,uint16_t latency,uint8_t pref_period,lld_evt_update_tag *upd_par); +ea_elt_tag *lld_evt_move_to_slave(llc_create_con_req_ind *con_par,llm_pdu_con_req_rx *con_req_pdu,ea_elt_tag *elt_adv,uint16_t conhdl); +void lld_evt_slave_update(llcp_con_upd_ind *param_pdu,ea_elt_tag *elt_old); +ea_elt_tag *lld_evt_adv_create(uint16_t handle,uint16_t mininterval,uint16_t maxinterval,_Bool restart_pol); +void lld_evt_end(ea_elt_tag *elt); +void lld_evt_rx(ea_elt_tag *elt); +void lld_evt_rx_afs(ea_elt_tag *elt,uint8_t num); +void lld_evt_timer_isr(void); +void lld_evt_end_isr(_Bool apfm); +void lld_evt_rx_isr(void); +void lld_evt_afs_isr(uint8_t num); +void lld_pdu_llcp_con_param_req_unpk(uint16_t pdu_ptr,uint8_t parlen,uint8_t *param); +void lld_pdu_llcp_con_param_rsp_unpk(uint16_t pdu_ptr,uint8_t parlen,uint8_t *param); +void lld_pdu_llcp_length_req_unpk(uint16_t pdu_ptr,uint8_t parlen,uint8_t *param); +void lld_pdu_llcp_length_rsp_unpk(uint16_t pdu_ptr,uint8_t parlen,uint8_t *param); +uint8_t lld_pdu_pack(uint8_t *p_data,uint8_t *p_length,char *format); +void lld_pdu_cntl_aligned_unpk(uint16_t pdu_ptr,uint8_t parlen,uint8_t *param); +void lld_pdu_data_tx_push(lld_evt_tag *evt,em_desc_node *txnode,_Bool can_be_freed,_Bool encrypted); +void lld_pdu_tx_prog(lld_evt_tag *param_1); +uint8_t lld_pdu_adv_pack(uint8_t code,uint8_t *buf,uint8_t *p_len); +void lld_pdu_rx_handler(lld_evt_tag *evt,uint8_t nb_rx_desc); +void lld_sleep_init(void); +void lld_sleep_wakeup(void); +void lld_sleep_wakeup_end(void); +uint16_t lld_util_instant_get(void *event,uint8_t action); +void lld_util_set_bd_address(bd_addr *bd_addr,uint8_t type); +uint8_t lld_util_freq2chnl(uint8_t freq); +uint16_t lld_util_get_local_offset(uint16_t PeerOffset,uint16_t Interval,uint32_t AnchorPoint); +uint16_t lld_util_get_peer_offset(uint16_t LocalOffset,uint16_t Interval,uint32_t AnchorPoint); +void lld_util_connection_param_set(ea_elt_tag *elt,ea_param_output *param); +void lld_util_dle_set_cs_fields(uint16_t conhdl); +void lld_util_anchor_point_move(ea_elt_tag *elt_connect); +void lld_util_flush_list(co_list *list); +_Bool lld_util_instant_ongoing(ea_elt_tag *elt); +void lld_util_compute_ce_max(ea_elt_tag *elt,uint16_t tx_time,uint16_t rx_time); +void lld_util_priority_set(ea_elt_tag *elt,uint8_t priority_index); +uint8_t lld_util_get_tx_pkt_cnt(ea_elt_tag *elt); +void lld_util_eff_tx_time_set(ea_elt_tag *elt,uint16_t max_tx_time,uint16_t max_tx_size); +void lld_init(_Bool reset); +void lld_core_reset(void); +void lld_adv_stop(ea_elt_tag *elt); +void lld_scan_stop(ea_elt_tag *elt); +ea_elt_tag *lld_move_to_master(ea_elt_tag *elt,uint16_t conhdl,llc_create_con_req_ind *param,uint8_t rx_hdl); +void lld_con_update_req(ea_elt_tag *elt_old,llc_con_upd_req_ind *param,llcp_con_upd_ind *param_pdu); +uint8_t lld_con_update_after_param_req(uint16_t conhdl,ea_elt_tag *elt_old,llc_con_upd_req_ind *param,llcp_con_upd_ind *param_pdu,_Bool bypass_offchk); +uint8_t lld_con_param_rsp(uint16_t conhdl,ea_elt_tag *elt,llc_con_upd_req_ind *param); +void lld_con_param_req(uint16_t conhdl,ea_elt_tag *elt,llc_con_upd_req_ind *param); +void lld_con_stop(ea_elt_tag *elt); +uint8_t lld_get_mode(uint16_t conhdl); +ea_elt_tag *lld_move_to_slave(llc_create_con_req_ind *con_par,llm_pdu_con_req_rx *con_req_pdu,ea_elt_tag *elt_adv,uint16_t conhdl,uint8_t rx_hdl); +void lld_ch_map_ind(ea_elt_tag *elt,uint16_t instant); +void lld_con_update_ind(ea_elt_tag *elt_old,llcp_con_upd_ind *param_pdu); +void lld_crypt_isr(void); +ea_elt_tag * lld_test_mode_tx(em_desc_node *txdesc,uint8_t tx_freq,uint8_t tx_phy); +ea_elt_tag * lld_test_mode_rx(uint8_t rx_freq); +void lld_test_stop(ea_elt_tag *elt); +uint16_t llm_util_bd_addr_wl_position(bd_addr *bd_address,uint8_t bd_addr_type); +uint8_t llm_util_check_address_validity(bd_addr *bd_address,uint8_t addr_type); +uint8_t llm_util_check_map_validity(uint8_t *channel_map,uint8_t nb_octet); +void llm_util_apply_bd_addr(uint8_t addr_type); +_Bool llm_util_check_evt_mask(uint8_t event_id); +void llm_util_get_channel_map(le_chnl_map *map); +void llm_util_get_supp_features(le_features *feats); +void llm_util_adv_data_update(void); +uint8_t llm_util_bl_check(bd_addr *bd_addr_to_add,uint8_t bd_addr_type,uint16_t *conhdl,uint8_t wl_flag_action,_Bool *in_wl); +_Bool llm_util_bd_addr_in_wl(bd_addr *bd_address,uint8_t bd_addr_type,_Bool *in_black_list); +uint8_t llm_util_bl_add(bd_addr *bd_addr_to_add,uint8_t bd_addr_type,uint16_t conhdl); +uint8_t llm_util_bl_rem(uint16_t conhdl); +void llm_end_evt_defer(void); +_Bool llm_pdu_defer(uint16_t status,uint8_t rx_hdl,uint8_t tx_cnt); +void llm_wlpub_addr_set(uint16_t elem_index,bd_addr *bdaddr); +void llm_wlpriv_addr_set(uint16_t elem_index,bd_addr *bdaddr); +void llm_con_req_ind(uint8_t rx_hdl,uint16_t status); +void llm_le_adv_report_ind(uint8_t rx_hdl); +void llm_con_req_tx_cfm(uint8_t rx_hdl); +void llm_common_cmd_complete_send(uint16_t opcode,uint8_t status); +void llm_common_cmd_status_send(uint16_t opcode,uint8_t status); +uint8_t llm_test_mode_start_rx(hci_le_rx_test_cmd *param); +uint8_t llm_set_adv_param(hci_le_set_adv_param_cmd *param); +uint8_t llm_set_adv_en(hci_le_set_adv_en_cmd *param); +uint8_t llm_set_adv_data(hci_le_set_adv_data_cmd *param); +uint8_t llm_set_scan_rsp_data(hci_le_set_scan_rsp_data_cmd *param); +uint8_t llm_set_scan_param(hci_le_set_scan_param_cmd *param); +uint8_t llm_set_scan_en(hci_le_set_scan_en_cmd *param); +void llm_wl_clr(void); +void llm_init(_Bool reset); +void llm_wl_dev_add(bd_addr *bd_addr,uint8_t bd_addr_type); +void llm_wl_dev_rem(bd_addr *bd_addr,uint8_t bd_addr_type); +uint8_t llm_wl_dev_add_hdl(bd_addr *bd_addr,uint8_t bd_addr_type); +uint8_t llm_wl_dev_rem_hdl(bd_addr *bd_addr,uint8_t bd_addr_type); +uint8_t llm_create_con(hci_le_create_con_cmd *param); +void llm_encryption_start(llm_enc_req *param); +void llm_encryption_done(void); +void hci_fc_init(void); +uint8_t hci_fc_acl_buf_size_set(uint16_t acl_pkt_len,uint16_t nb_acl_pkts); +uint8_t hci_fc_acl_en(_Bool flow_enable); +void hci_fc_host_nb_acl_pkts_complete(uint16_t acl_pkt_nb); +uint8_t hci_pack_bytes(uint8_t **pp_in,uint8_t **pp_out,uint8_t *p_in_end,uint8_t *p_out_end,uint8_t len); +uint8_t hci_host_nb_cmp_pkts_cmd_pkupk(uint8_t *out,uint8_t *in,uint16_t *out_len,uint16_t in_len); +uint8_t hci_le_adv_report_evt_pkupk(uint8_t *out,uint8_t *in,uint16_t *out_len,uint16_t in_len); +uint8_t hci_le_dir_adv_report_evt_pkupk(uint8_t *out,uint8_t *in,uint16_t *out_len,uint16_t in_len); +hci_cmd_desc_tag * hci_look_for_cmd_desc(uint16_t opcode); +hci_evt_desc_tag * hci_look_for_evt_desc(uint8_t code); +hci_evt_desc_tag * hci_look_for_le_evt_desc(uint8_t subcode); +void hci_tl_init(_Bool reset); +uint16_t hci_util_read_array_size(char **fmt_cursor); +HCI_PACK_STATUS hci_util_pack(uint8_t *inout,uint16_t *inout_len,char *format); +HCI_PACK_STATUS hci_util_unpack(uint8_t *out,uint8_t *in,uint16_t *out_len,uint16_t in_len,char *format); +uint8_t * hci_build_cc_evt(ke_msg *msg,int8_t nb_h2c_cmd_pkts); +uint8_t * hci_build_evt(ke_msg *msg); +uint8_t * hci_build_le_evt(ke_msg *msg); +uint8_t * hci_build_acl_rx_data(ke_msg *msg); +co_list_hdr *ble_ke_queue_extract(co_list *queue,anon_subr__Bool_co_list_hdr_ptr_uint32_t *func,uint32_t arg); +void ble_ke_queue_insert(co_list *queue,co_list_hdr *element,anon_subr__Bool_co_list_hdr_ptr_co_list_hdr_ptr *cmp); +_Bool ble_cmp_dest_id(co_list_hdr *msg,uint32_t dest_id); +ke_msg_func_t * ble_ke_handler_search(ke_msg_id_t msg_id,ke_state_handler *state_handler); +ke_msg_func_t * ble_ke_task_handler_get(ke_msg_id_t msg_id,ke_task_id_t task_id); +void ble_ke_task_init(void); +void ble_ke_state_set(ke_task_id_t id,ke_state_t.conflict state_id); +undefined4 llcp_ping_rsp_handler(int param_1,ke_task_id_t param_2); +int llcp_terminate_ind_handler(uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_terminate_ind *param); +void llc_llcp_reject_ind(int param_1,ke_task_id_t param_2,int param_3,int param_4); +int llcp_reject_ind_ext_handler(uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_reject_ind_ext *param); +int llcp_reject_ind_handler(uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_reject_ind *param); +undefined4 llcp_start_enc_req_handler(int param_1,ke_task_id_t param_2); +undefined4 llcp_unknown_rsp_handler(int param_1,ke_task_id_t param_2,int param_3); +void llc_llcp_version_ind_pdu_send(uint16_t conhdl); +undefined4 llcp_vers_ind_handler(int param_1,ke_task_id_t param_2,int param_3); +void llc_llcp_ch_map_update_pdu_send(uint16_t conhdl); +void llc_llcp_pause_enc_req_pdu_send(uint16_t conhdl); +void llc_llcp_pause_enc_rsp_pdu_send(uint16_t conhdl); +void llc_llcp_enc_req_pdu_send(uint16_t conhdl,hci_le_start_enc_cmd *param); +void llc_llcp_enc_rsp_pdu_send(uint16_t conhdl,llcp_enc_req *param); +void llc_llcp_start_enc_rsp_pdu_send(uint16_t conhdl); +void llc_llcp_reject_ind_pdu_send(uint16_t conhdl,uint8_t rej_opcode,uint8_t reason); +int llcp_con_param_rsp_handler(uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_con_param_rsp *param); +undefined4 llcp_feats_rsp_handler(int param_1,ke_task_id_t param_2,uint8_t *param_3); +int llcp_channel_map_ind_handler(int param_1,ke_task_id_t param_2,int param_3,uint8_t *param_4); +int llcp_con_upd_ind_handler(int param_1,ke_task_id_t param_2,int param_3,llcp_con_upd_ind *param_4); +void llc_llcp_con_update_pdu_send(uint16_t conhdl,llcp_con_upd_ind *param); +void llc_llcp_con_param_req_pdu_send(uint16_t conhdl,llc_con_upd_req_ind *param); +void llc_llcp_con_param_rsp_pdu_send(uint16_t conhdl,llc_con_upd_req_ind *param); +undefined4 llcp_con_param_req_handler(int param_1,ke_task_id_t param_2,uint8_t *param_3); +void llc_llcp_feats_req_pdu_send(uint16_t conhdl); +void llc_llcp_feats_rsp_pdu_send(uint16_t conhdl); +void llc_llcp_start_enc_req_pdu_send(uint16_t conhdl); +void llc_llcp_terminate_ind_pdu_send(uint16_t conhdl,uint8_t err_code); +void llc_llcp_unknown_rsp_send_pdu(uint16_t conhdl,uint8_t unk_type); +int llc_llcp_unknown_ind_handler(uint16_t conhdl,uint8_t opcode); +int llcp_feats_req_handler(uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_feats_req *param); +int llcp_slave_feature_req_handler(uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_slave_feature_req *param); +void llc_llcp_ping_req_pdu_send(uint16_t conhdl); +void llc_llcp_ping_rsp_pdu_send(uint16_t conhdl); +int llcp_ping_req_handler(uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,void *param); +void llc_llcp_length_req_pdu_send(uint16_t conhdl); +void llc_llcp_length_rsp_pdu_send(uint16_t conhdl); +int llc_llcp_recv_handler(uint param_1,int param_2,byte *param_3,int param_4); +uint8_t llc_llcp_get_autorize(uint8_t opcode); +int llc_dft_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +undefined4 llm_enc_ind_handler(int param_1,uint param_2); +int llc_llcp_recv_ind_handler(ke_msg_id_t msgid,llc_llcp_recv_ind *ind,ke_task_id_t dest_id,ke_task_id_t src_id); +undefined4 llc_chmap_update_req_ind_handler(uint param_1); +undefined4 llc_auth_payl_real_to_ind_handler(uint param_1); +undefined4 llc_con_upd_req_ind_handler(llc_con_upd_req_ind *param_1,uint param_2); +undefined4 llc_length_req_ind_handler(uint param_1); +void llc_task_random_gen_request(ke_task_id_t dest_id); +undefined4 llc_enc_mgt_ind_handler(uint param_1); +undefined4 llc_chnl_assess_timer_handler(uint param_1); +int llc_llcp_rsp_to_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +undefined4 llc_link_sup_to_ind_handler(uint param_1); +undefined4 llc_auth_payl_nearly_to_ind_handler(uint param_1); +undefined4 llc_data_ind_handler(void *param_1,uint param_2); +undefined4 lld_stop_ind_handler(uint param_1); +uint8_t llc_util_get_free_conhdl(uint16_t *conhdl); +uint8_t llc_util_get_nb_active_link(void); +void llc_util_update_channel_map(uint16_t conhdl,le_chnl_map *map); +void llc_util_set_auth_payl_to_margin(lld_evt_tag *evt); +void llc_util_clear_operation_ptr(int param_1,int param_2); +void llc_util_bw_mgt(uint16_t conhdl); +void llc_end_evt_defer(int param_1); +void llc_pdu_acl_tx_ack_defer(uint16_t conhdl,uint8_t tx_cnt); +void llc_pdu_defer(uint16_t conhdl,uint16_t status,uint8_t rssi,uint8_t channel,uint8_t length); +int llm_dft_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int llm_le_set_host_ch_class_cmd_sto_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int llm_ecc_result_ind_handler(ke_msg_id_t msgid,ecc_result_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int llm_enc_req_handler(ke_msg_id_t msgid,llm_enc_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int lld_stop_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +void llc_ch_assess_local(int param_1,uint param_2,int param_3,int param_4); +uint8_t llc_ch_assess_get_local_ch_map(uint16_t conhdl,le_chnl_map *map,le_chnl_map *hostmap); +le_chnl_map * llc_ch_assess_get_current_ch_map(uint16_t conhdl); +void llc_ch_assess_reass_ch(uint16_t conhdl,le_chnl_map *map,le_chnl_map *hostmap,uint8_t nb_chgood); +undefined4 hci_le_set_data_len_cmd_handler(ushort *param_1,ke_task_id_t param_2,uint16_t param_3); +undefined4 hci_le_rem_con_param_req_neg_reply_cmd_handler(ushort *param_1,ke_task_id_t param_2,uint16_t param_3); +undefined4 hci_le_rem_con_param_req_reply_cmd_handler(ushort *param_1,ke_task_id_t param_2,uint16_t param_3); +undefined4 hci_le_ltk_req_reply_cmd_handler(ushort *param_1,ke_task_id_t param_2,uint16_t param_3); +undefined4 hci_disconnect_cmd_handler(uint16_t *param_1,ke_task_id_t param_2,uint16_t param_3); +int hci_le_rd_rem_used_feats_cmd_handler(ke_msg_id_t msgid,hci_le_rd_rem_used_feats_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +undefined4 hci_le_rd_chnl_map_cmd_handler(ke_task_id_t *param_1,ke_task_id_t param_2); +undefined4 hci_rd_auth_payl_to_cmd_handler(ke_task_id_t *param_1,uint param_2); +undefined4 hci_rd_rssi_cmd_handler(ke_task_id_t *param_1,ke_task_id_t param_2); +undefined4 hci_rd_tx_pwr_lvl_cmd_handler(ke_task_id_t *param_1,ke_task_id_t param_2); +undefined4 hci_le_con_update_cmd_handler(ushort *param_1,ke_task_id_t param_2,uint16_t param_3); +undefined4 hci_wr_auth_payl_to_cmd_handler(ke_task_id_t *param_1,uint param_2); +int hci_flush_cmd_handler(ke_msg_id_t msgid,hci_basic_conhdl_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +undefined4 hci_rd_rem_ver_info_cmd_handler(uint16_t *param_1,uint param_2,uint16_t param_3); +int llc_hci_command_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_vsc_set_tx_pwr(ke_msg_id_t msgid,hci_vsc_set_tx_pwr_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_wr_rfpath_compensation_cmd_handler(ke_msg_id_t msgid,hci_le_wr_rfpath_cps_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_wr_le_host_supp_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_wr_suggted_dft_data_len_cmd_handler(ke_msg_id_t msgid,hci_le_wr_suggted_dft_data_len_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_set_evt_mask_cmd_handler(ke_msg_id_t msgid,hci_le_set_evt_mask_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rd_rfpath_compensation_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rd_trans_pwr_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_rd_buff_size_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_rd_local_supp_feats_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_rd_local_supp_cmds_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_rd_local_ver_info_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_rd_bd_addr_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rd_max_data_len_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rd_suggted_dft_data_len_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rd_supp_states_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rd_wl_size_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rd_adv_ch_tx_pw_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rd_local_supp_feats_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rd_buff_size_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_generate_dhkey_cmd_handler(ke_msg_id_t msgid,hci_le_generate_dh_key_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_host_nb_cmp_pkts_cmd_handler(ke_msg_id_t msgid,hci_host_nb_cmp_pkts_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_host_buf_size_cmd_handler(ke_msg_id_t msgid,hci_host_buf_size_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_set_evt_mask_page_2_cmd_handler(ke_msg_id_t msgid,hci_set_evt_mask_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_set_evt_mask_cmd_handler(ke_msg_id_t msgid,hci_set_evt_mask_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_set_ctrl_to_host_flow_ctrl_cmd_handler(ke_msg_id_t msgid,hci_set_ctrl_to_host_flow_ctrl_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_reset_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_tx_test_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rx_test_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rand_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_enc_cmd_handler(ke_msg_id_t msgid,hci_le_enc_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_wl_mngt_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_set_host_ch_class_cmd_handler(ke_msg_id_t msgid,hci_le_set_host_ch_class_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_create_con_cmd_handler(ke_msg_id_t msgid,hci_le_create_con_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_set_scan_en_cmd_handler(ke_msg_id_t msgid,hci_le_set_scan_en_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_set_scan_param_cmd_handler(ke_msg_id_t msgid,hci_le_set_scan_param_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_set_adv_en_cmd_handler(ke_msg_id_t msgid,hci_le_set_adv_en_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_set_adv_param_cmd_handler(ke_msg_id_t msgid,hci_le_set_adv_param_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_set_rand_add_cmd_handler(ke_msg_id_t msgid,hci_le_set_rand_addr_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rd_local_p256_public_key_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_test_end_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_create_con_cancel_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_command_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +char * bearer2str(bt_mesh_prov_bearer_t bearer); +int fault_test(bt_mesh_model *model,uint8_t test_id,uint16_t cid); +void attn_on(bt_mesh_model *model); +void lpn_cb(u16_t friend_addr,_Bool established); +int fault_get_reg(bt_mesh_model *model,u16_t cid,u8_t *test_id,u8_t *faults,u8_t *fault_count); +void prov_reset(void); +void prov_complete(u16_t net_idx,u16_t addr); +void link_close(bt_mesh_prov_bearer_t bearer); +void link_open(bt_mesh_prov_bearer_t bearer); +void prov_input_complete(void); +int input(bt_mesh_input_action_t act,u8_t size); +int output_string(char *str); +int output_number(bt_mesh_output_action_t action,u32_t.conflict number); +void vendor_data_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void blemesh_lpn_set(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void blemesh_rpl_clr(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +int fault_clear(bt_mesh_model *model,uint16_t cid); +void blemesh_seg_send(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void blemesh_net_send(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void blemesh_reset(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void blemesh_input_str(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void blemesh_input_num(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void blemesh_ivu_test(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void blemesh_set_dev_uuid(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void blemesh_fault_set(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void blemesh_pb(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void blemesh_init(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void attn_off(void); +void blemesh_iv_update(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +int fault_get_cur(bt_mesh_model *model,u8_t *test_id,u16_t *company_id,u8_t *faults,u8_t *fault_count); +void show_faults(u8_t test_id,u16_t cid,u8_t *faults,size_t fault_count); +void health_current_status(bt_mesh_health_cli *cli,u16_t addr,u8_t test_id,u16_t cid,u8_t *faults,size_t fault_count); +int blemesh_cli_register(void); +int send_friend_poll(void); +void group_zero(atomic_t *target); +void clear_friendship(_Bool force,_Bool disable); +int atomic_test_and_clear_bit(atomic_t *target,int bit); +int atomic_test_bit(atomic_t *target,int bit); +void friend_req_sent(u16_t duration,int err,void *user_data); +void friend_clear_sent(int err,void *user_data); +void req_sent(u16_t duration,int err,void *user_data); +_Bool sub_update(u8_t op); +void friend_response_received(void); +int send_friend_req(void); +void lpn_timeout(k_work *work); +s32_t poll_timeout(void); +void bt_mesh_lpn_disable(_Bool force); +int bt_mesh_lpn_set(_Bool enable); +void bt_mesh_lpn_msg_received(bt_mesh_net_rx.conflict *rx); +int bt_mesh_lpn_friend_offer(bt_mesh_net_rx.conflict *rx,net_buf_simple *buf); +int bt_mesh_lpn_friend_clear_cfm(bt_mesh_net_rx.conflict *rx,net_buf_simple *buf); +void bt_mesh_lpn_group_add(u16_t group); +void bt_mesh_lpn_group_del(u16_t *groups,size_t group_count); +int bt_mesh_lpn_friend_sub_cfm(bt_mesh_net_rx.conflict *rx,net_buf_simple *buf); +int bt_mesh_lpn_friend_update(bt_mesh_net_rx.conflict *rx,net_buf_simple *buf); +int bt_mesh_lpn_poll(void); +void bt_mesh_lpn_set_cb(anon_subr_void_u16_t__Bool.conflict *cb); +int bt_mesh_lpn_init(void); +void gen_onoff_set(bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void gen_onoff_set_unack(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void send_onoff_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx); +void gen_onoff_set_with_ack(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void gen_onoff_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void publish_start(u16_t duration,int err,void *user_data); +int model_send(bt_mesh_model *model,bt_mesh_net_tx.conflict2 *tx,_Bool implicit_bind,net_buf_simple *msg,bt_mesh_send_cb *cb,void *cb_data); +void mod_init(bt_mesh_model *mod,bt_mesh_elem *elem,_Bool vnd,_Bool primary,void *user_data); +void bt_mesh_model_foreach(anon_subr_void_bt_mesh_model_ptr_bt_mesh_elem_ptr__Bool__Bool_void_ptr *func,void *user_data); +s32_t bt_mesh_model_pub_period_get(bt_mesh_model *mod); +void publish_sent(int err,void *user_data); +bt_mesh_elem * bt_mesh_model_elem(bt_mesh_model *mod); +int bt_mesh_comp_register(bt_mesh_comp *comp); +void bt_mesh_comp_provision(u16_t addr); +void bt_mesh_comp_unprovision(void); +u16_t bt_mesh_primary_addr(void); +u16_t * bt_mesh_model_find_group(bt_mesh_model *mod,u16_t addr); +bt_mesh_elem * bt_mesh_elem_find(u16_t addr); +u8_t bt_mesh_elem_count(void); +_Bool bt_mesh_fixed_group_match(u16_t addr); +void bt_mesh_model_recv(bt_mesh_net_rx.conflict2 *rx,net_buf_simple *buf); +void bt_mesh_model_msg_init(net_buf_simple *msg,u32_t.conflict opcode); +int bt_mesh_model_send(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *msg,bt_mesh_send_cb *cb,void *cb_data); +int bt_mesh_model_publish(bt_mesh_model *model); +void mod_publish(k_work *work); +bt_mesh_model * bt_mesh_model_find_vnd(bt_mesh_elem *elem,u16_t company,u16_t id); +bt_mesh_model * bt_mesh_model_find(bt_mesh_elem *elem,u16_t id); +bt_mesh_comp * bt_mesh_comp_get(void); +bt_mesh_adv.conflict2 * adv_alloc(int id); +void adv_thread(void *p1); +void bt_mesh_scan_cb(bt_addr_le_t *addr,s8_t rssi,u8_t adv_type,net_buf_simple *buf); +net_buf * bt_mesh_adv_create_from_pool(net_buf_pool *pool,bt_mesh_adv_alloc_t *get_id,bt_mesh_adv_type type,u8_t xmit,s32_t timeout); +net_buf * bt_mesh_adv_create(bt_mesh_adv_type type,u8_t xmit,s32_t timeout); +void bt_mesh_adv_update(void); +void bt_mesh_adv_send(net_buf *buf,bt_mesh_send_cb *cb,void *cb_data); +void bt_mesh_adv_init(void); +int bt_mesh_scan_enable(void); +int bt_mesh_scan_disable(void); +void beacon_complete(int err,void *user_data); +void bt_mesh_beacon_create(bt_mesh_subnet *sub,net_buf_simple *buf); +void beacon_send(k_work *work); +void bt_mesh_beacon_init(void); +void bt_mesh_beacon_ivu_initiator(_Bool enable); +void bt_mesh_beacon_recv(net_buf_simple *buf); +void bt_mesh_beacon_enable(void); +void bt_mesh_beacon_disable(void); +void hb_pub_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void hb_sub_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void mod_pub_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void relay_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void key_idx_unpack(net_buf_simple *buf,u16_t *idx1,u16_t *idx2); +void app_key_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void net_key_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void comp_data_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void mod_sub_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void mod_app_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void state_status_u8(net_buf_simple *buf,u32_t.conflict expect_status); +void gatt_proxy_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void friend_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void ttl_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void beacon_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +_Bool app_key_is_valid(u16_t app_idx); +void key_idx_pack(net_buf_simple *buf,u16_t idx1,u16_t idx2); +void send_krp_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,u16_t idx,u8_t phase,u8_t status); +void send_friend_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx); +void friend_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx); +void net_key_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void send_net_key_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,u16_t idx,u8_t status); +void krp_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void node_identity_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void app_key_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void hb_pub_send_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,u8_t status,hb_pub_param *orig_msg); +void heartbeat_pub_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void send_mod_sub_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,u8_t status,u16_t elem_addr,u16_t sub_addr,u8_t *mod_id,_Bool vnd); +void krp_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void lpn_timeout_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void friend_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void node_reset(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void mod_sub_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void mod_sub_get_vnd(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void net_key_update(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void net_key_add(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void key_idx_unpack(net_buf_simple *buf,u16_t *idx1,u16_t *idx2); +u8_t _mod_pub_set(bt_mesh_model *model,u16_t pub_addr,u16_t app_idx,u8_t cred_flag,u8_t ttl,u8_t period,u8_t retransmit); +u8_t mod_unbind(bt_mesh_model *model,u16_t key_idx); +void create_mod_app_status(net_buf_simple *msg,_Bool vnd,u16_t elem_addr,u16_t app_idx,u8_t status,u8_t *mod_id); +void send_mod_pub_status(bt_mesh_model *cfg_mod,bt_mesh_msg_ctx *ctx,u16_t elem_addr,u16_t pub_addr,_Bool vnd,u8_t status,u8_t *mod_id); +bt_mesh_model * get_model(bt_mesh_elem *elem,net_buf_simple *buf,_Bool *vnd); +void mod_app_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void mod_app_unbind(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void mod_app_bind(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void mod_pub_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void mod_pub_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void mod_sub_del(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void mod_sub_add(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void mod_sub_va_del(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +u8_t va_add(u8_t *label_uuid,u16_t *addr); +void mod_pub_va_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void mod_sub_va_add(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void dev_comp_data_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +u8_t app_key_set(u16_t net_idx,u16_t app_idx,u8_t *val,_Bool update); +void app_key_update(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void app_key_add(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +u16_t hb_pwr2(u8_t val); +void hb_publish(k_work *work); +void heartbeat_pub_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void _mod_unbind(bt_mesh_model *mod,bt_mesh_elem *elem,_Bool vnd,_Bool primary,void *user_data); +void hb_sub_send_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx); +void heartbeat_sub_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void heartbeat_sub_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void bt_mesh_app_key_del(bt_mesh_app_key *key,_Bool store); +void app_key_del(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +int bt_mesh_cfg_srv_init(bt_mesh_model *model,_Bool primary); +void bt_mesh_heartbeat(u16_t src,u16_t dst,u8_t hops,u16_t feat); +u8_t bt_mesh_net_transmit_get(void); +void net_transmit_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void net_transmit_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +u8_t bt_mesh_relay_get(void); +u8_t bt_mesh_friend_get(void); +u8_t bt_mesh_relay_retransmit_get(void); +void relay_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void relay_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +u8_t bt_mesh_beacon_get(void); +void beacon_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void beacon_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +u8_t bt_mesh_gatt_proxy_get(void); +void node_identity_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void send_gatt_proxy_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx); +void gatt_proxy_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx); +void gatt_proxy_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +u8_t bt_mesh_default_ttl_get(void); +void default_ttl_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void default_ttl_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +u8_t * bt_mesh_label_uuid_get(u16_t addr); +size_t mod_sub_list_clear(bt_mesh_model *mod); +void mod_sub_del_all(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void mod_sub_va_overwrite(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void mod_sub_overwrite(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +size_t mod_reset(bt_mesh_model *mod); +bt_mesh_cfg_srv * bt_mesh_cfg_get(void); +void bt_mesh_subnet_del(bt_mesh_subnet *sub,_Bool store); +void net_key_del(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void bt_mesh_cfg_reset(void); +void sys_put_be32(u32_t.conflict val,u8_t *dst); +int bt_mesh_ccm_encrypt(u8_t *param_1,void *param_2,int param_3,uint param_4,int param_5,int param_6,int param_7,size_t param_8); +int bt_mesh_ccm_decrypt(u8_t *param_1,void *param_2,int param_3,uint param_4,int param_5,int param_6,void *param_7,size_t param_8); +int bt_mesh_aes_cmac(u8_t *key,bt_mesh_sg *sg,size_t sg_len,u8_t *mac); +int bt_mesh_aes_cmac_one(u8_t *key,void *m,size_t len,u8_t *mac); +_Bool bt_mesh_s1(char *m,u8_t *salt); +int bt_mesh_k1(u8_t *ikm,size_t ikm_len,u8_t *salt,char *info,u8_t *okm); +int bt_mesh_k2(u8_t *n,u8_t *p,size_t p_len,u8_t *net_id,u8_t *enc_key,u8_t *priv_key); +int bt_mesh_k3(u8_t *n,u8_t *out); +int bt_mesh_k4(u8_t *n,u8_t *out); +int bt_mesh_id128(u8_t *n,char *s,u8_t *out); +int bt_mesh_net_obfuscate(u8_t *pdu,u32_t.conflict iv_index,u8_t *privacy_key); +int bt_mesh_net_encrypt(u8_t *key,net_buf_simple *buf,u32_t.conflict iv_index,_Bool proxy); +int bt_mesh_net_decrypt(u8_t *key,net_buf_simple *buf,u32_t.conflict iv_index,_Bool proxy); +int bt_mesh_app_encrypt(u8_t *key,_Bool dev_key,u8_t aszmic,net_buf_simple *buf,u8_t *ad,u16_t src,u16_t dst,u32_t.conflict seq_num,u32_t.conflict iv_index); +int bt_mesh_app_decrypt(u8_t *key,_Bool dev_key,u8_t aszmic,net_buf_simple *buf,net_buf_simple *out,u8_t *ad,u16_t src,u16_t dst,u32_t.conflict seq_num,u32_t.conflict iv_index); +u8_t bt_mesh_fcs_calc(u8_t *data,u8_t data_len); +_Bool bt_mesh_fcs_check(net_buf_simple *buf,u8_t received_fcs); +int bt_mesh_virtual_addr(u8_t *virtual_label,u16_t *addr); +int bt_mesh_prov_conf_salt(u8_t *conf_inputs,u8_t *salt); +int bt_mesh_prov_conf_key(u8_t *dhkey,u8_t *conf_salt,u8_t *conf_key); +int bt_mesh_prov_conf(u8_t *conf_key,u8_t *rand,u8_t *auth,u8_t *conf); +int bt_mesh_prov_decrypt(u8_t *key,u8_t *nonce,u8_t *data,u8_t *out); +int bt_mesh_beacon_auth(u8_t *beacon_key,u8_t flags,u8_t *net_id,u32_t.conflict iv_index,u8_t *auth); +void health_period_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void health_current_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void health_fault_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void health_attention_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void attention_off(k_work *work); +void send_attention_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx); +void attention_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx); +void health_period_set_unrel(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void send_health_period_status(bt_mesh_model *model,bt_mesh_msg_ctx *ctx); +void health_period_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void health_period_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx); +void health_fault_test_unrel(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void health_fault_clear_unrel(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void health_get_registered(bt_mesh_model *mod,u16_t company_id,net_buf_simple *msg); +void health_fault_test(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void health_fault_clear(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void health_fault_get(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +int health_pub_update(bt_mesh_model *mod); +int bt_mesh_health_srv_init(bt_mesh_model *model,_Bool primary); +void bt_mesh_attention(bt_mesh_model *model,u8_t time); +void attention_set_unrel(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +void attention_set(bt_mesh_model *model,bt_mesh_msg_ctx *ctx,net_buf_simple *buf); +int bt_mesh_provision(u8_t *net_key,u16_t net_idx,u8_t flags,u32_t.conflict iv_index,u16_t addr,u8_t *dev_key); +void bt_mesh_reset(void); +_Bool bt_mesh_is_provisioned(void); +int bt_mesh_prov_enable(bt_mesh_prov_bearer_t bearers); +int bt_mesh_prov_disable(bt_mesh_prov_bearer_t bearers); +int bt_mesh_init(bt_mesh_prov.conflict5 *prov,bt_mesh_comp *comp); +void send_cb_finalize(bt_mesh_send_cb *cb,void *cb_data); +_Bool auth_match(bt_mesh_subnet_keys *keys,u8_t *net_id,u8_t flags,u32_t.conflict iv_index,u8_t *auth); +int net_decrypt(u8_t *enc,u8_t *priv,u8_t *data,size_t data_len,bt_mesh_net_rx.conflict4 *rx,net_buf_simple *buf); +int atomic_test_bit(void); +bt_mesh_subnet * bt_mesh_subnet_get(u16_t net_idx); +int bt_mesh_net_keys_create(bt_mesh_subnet_keys *keys,u8_t *key); +int friend_cred_set(friend_cred *cred,u8_t idx,u8_t *net_key); +void friend_cred_refresh(u16_t net_idx); +int friend_cred_update(bt_mesh_subnet *sub); +void friend_cred_clear(friend_cred *cred); +friend_cred *friend_cred_create(bt_mesh_subnet *sub,u16_t addr,u16_t lpn_counter,u16_t frnd_counter); +int friend_cred_del(u16_t net_idx,u16_t addr); +int friend_cred_get(bt_mesh_subnet *sub,u16_t addr,u8_t *nid,u8_t **enc,u8_t **priv); +u8_t bt_mesh_net_flags(bt_mesh_subnet *sub); +int bt_mesh_net_beacon_update(bt_mesh_subnet *sub); +int bt_mesh_net_create(u16_t idx,u8_t flags,u8_t *key,u32_t.conflict iv_index); +void bt_mesh_net_revoke_keys(bt_mesh_subnet *sub); +_Bool bt_mesh_kr_update(bt_mesh_subnet *sub,u8_t new_kr,_Bool new_key); +void bt_mesh_rpl_reset(void); +void bt_mesh_net_sec_update(bt_mesh_subnet *sub); +_Bool bt_mesh_net_iv_update(u32_t.conflict iv_index,_Bool iv_update); +void ivu_refresh(k_work *work); +u32_t.conflict bt_mesh_next_seq(void); +int bt_mesh_net_resend(bt_mesh_subnet *sub,net_buf *buf,_Bool new_key,bt_mesh_send_cb *cb,void *cb_data); +int bt_mesh_net_encode(bt_mesh_net_tx.conflict4 *tx,net_buf_simple *buf,_Bool proxy); +int bt_mesh_net_send(bt_mesh_net_tx.conflict4 *tx,net_buf *buf,bt_mesh_send_cb *cb,void *cb_data); +bt_mesh_subnet *bt_mesh_subnet_find(u8_t *net_id,u8_t flags,u32_t.conflict iv_index,u8_t *auth,_Bool *new_key); +int bt_mesh_net_decode(net_buf_simple *data,bt_mesh_net_if net_if,bt_mesh_net_rx.conflict4 *rx,net_buf_simple *buf); +void bt_mesh_net_recv(net_buf_simple *data,s8_t rssi,bt_mesh_net_if net_if); +void bt_mesh_net_local(k_work *work); +void bt_mesh_net_start(void); +void bt_mesh_net_init(void); +void ack_complete(u16_t duration,int err,void *user_data); +void prov_capabilities(u8_t *data); +void prov_failed(u8_t *data); +void prov_buf_init(net_buf_simple *buf,u8_t type); +net_buf * adv_buf_create(void); +void free_segments(void); +void prov_clear_tx(void); +void gen_prov_ack(prov_rx *rx,net_buf_simple *buf); +void send_reliable(undefined4 param_1,undefined4 param_2); +int prov_send(net_buf_simple *buf); +void send_input_complete(void); +int bearer_ctl_send(u8_t op,void *data,u8_t data_len); +void prov_send_fail_msg(u8_t err); +int reset_state(void); +void reset_adv_link(void); +void prov_confirm(u8_t *data); +void prov_invite(u8_t *data); +void buf_sent(int err,void *user_data); +void gen_prov_ack_send(u8_t xact_id); +void prov_random(u8_t *data); +void prov_data(u8_t *data); +void sys_memcpy_swap(void *dst,void *src); +void prov_dh_key_gen(void); +void prov_pub_key(u8_t *data); +void prov_start(u8_t *data); +void pub_key_ready(u8_t *pkey); +void prov_complete(void); +void prov_retransmit(k_work *work); +void prov_input_complete(u8_t *data); +void prov_msg_recv(void); +void gen_prov_cont(prov_rx *rx,net_buf_simple *buf); +void gen_prov_start(prov_rx *rx,net_buf_simple *buf); +void send_pub_key(u8_t *dhkey); +void gen_prov_ctl(prov_rx *rx,net_buf_simple *buf); +int bt_mesh_input_number(u32_t.conflict num); +int bt_mesh_input_string(char *str); +int bt_mesh_pb_gatt_recv(bt_conn *conn,net_buf_simple *buf); +int bt_mesh_pb_gatt_open(bt_conn *conn); +int bt_mesh_pb_gatt_close(bt_conn *conn); +void protocol_timeout(k_work *work); +bt_mesh_prov.conflict8 * bt_mesh_prov_get(void); +_Bool bt_prov_active(void); +void bt_mesh_pb_adv_recv(net_buf_simple *buf); +int bt_mesh_prov_init(bt_mesh_prov.conflict8 *prov_info); +void bt_mesh_prov_complete(u16_t net_idx,u16_t addr); +void bt_mesh_prov_reset(void); +ssize_t prov_ccc_read(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset); +ssize_t proxy_ccc_read(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset); +void proxy_sar_timeout(k_work *work); +bt_mesh_proxy_client.conflict * find_client(bt_conn *conn); +ssize_t prov_ccc_write(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset,u8_t flags); +ssize_t proxy_ccc_write(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset,u8_t flags); +void filter_add(u16_t addr); +bt_mesh_subnet * next_sub(void); +void proxy_disconnected(bt_conn *conn,u8_t reason); +void proxy_connected(bt_conn *conn,u8_t err); +int proxy_send(bt_conn *conn,void *data,u16_t len); +int proxy_segment_and_send(bt_conn *conn,u8_t type,net_buf_simple *msg); +int beacon_send(bt_conn *conn,bt_mesh_subnet *sub); +void proxy_send_beacons(k_work *work); +void send_filter_status(bt_mesh_proxy_client.conflict *client,bt_mesh_net_rx.conflict6 *rx,net_buf_simple *buf); +void proxy_complete_pdu(bt_mesh_proxy_client.conflict *client); +ssize_t proxy_recv(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset,u8_t flags); +void bt_mesh_proxy_beacon_send(bt_mesh_subnet *sub); +void bt_mesh_proxy_identity_start(bt_mesh_subnet *sub); +void bt_mesh_proxy_identity_stop(bt_mesh_subnet *sub); +int bt_mesh_proxy_identity_enable(void); +net_buf_simple * bt_mesh_proxy_get_buf(void); +int bt_mesh_proxy_prov_enable(void); +int bt_mesh_proxy_prov_disable(_Bool disconnect); +int bt_mesh_proxy_gatt_enable(void); +void bt_mesh_proxy_gatt_disconnect(void); +int bt_mesh_proxy_gatt_disable(void); +void bt_mesh_proxy_addr_add(net_buf_simple *buf,u16_t addr); +int bt_mesh_proxy_send(bt_conn *conn,u8_t type,net_buf_simple *msg); +_Bool bt_mesh_proxy_relay(net_buf_simple *buf,u16_t dst); +s32_t bt_mesh_proxy_adv_start(void); +int bt_mesh_proxy_adv_stop(int param_1); +int bt_mesh_proxy_init(void); +void send_cb_finalize(bt_mesh_send_cb *cb,void *cb_data); +void seg_first_send_start(u16_t duration,int err,void *user_data); +_Bool is_replay(bt_mesh_net_rx.conflict8 *rx,bt_mesh_rpl **match); +void seg_sent(int err,void *user_data); +s32_t ack_timeout(seg_rx.conflict1 *rx); +int sdu_recv(bt_mesh_net_rx.conflict8 *rx,u32_t.conflict seq,u8_t hdr,u8_t aszmic,net_buf_simple *buf); +void seg_send_start(u16_t duration,int err,void *user_data); +void seg_rx_reset(seg_rx.conflict1 *rx,_Bool full_reset); +void seg_tx_reset(seg_tx.conflict1 *tx); +void seg_tx_complete(seg_tx.conflict1 *tx,int err); +void seg_tx_send_unacked(seg_tx.conflict1 *tx); +void seg_retransmit(k_work *work); +int ctl_recv(bt_mesh_net_rx.conflict8 *rx,u8_t hdr,net_buf_simple *buf,u64_t *seq_auth); +void bt_mesh_set_hb_sub_dst(u16_t addr); +_Bool bt_mesh_tx_in_progress(void); +bt_mesh_app_key * bt_mesh_app_key_find(u16_t app_idx); +int bt_mesh_trans_send(bt_mesh_net_tx.conflict7 *tx,net_buf_simple *msg,bt_mesh_send_cb *cb,void *cb_data); +int bt_mesh_ctl_send(bt_mesh_net_tx.conflict7 *tx,u8_t ctl_op,void *data,size_t data_len,u64_t *seq_auth,bt_mesh_send_cb *cb,void *cb_data); +int send_ack(bt_mesh_subnet *sub,u16_t src,u16_t dst,u8_t ttl,u64_t *seq_auth,u32_t.conflict block,u8_t obo); +void seg_ack(k_work *work); +int bt_mesh_trans_recv(net_buf_simple *param_1,bt_mesh_net_rx.conflict8 *param_2); +void bt_mesh_rx_reset(void); +void bt_mesh_tx_reset(void); +void bt_mesh_trans_init(void); +void bt_mesh_heartbeat_send(void); +bt_mesh_adv.conflict7 * adv_alloc(int id); +void friend_purge_old_ack(int param_1,int *param_2,uint param_3); +void send_friend_clear(bt_mesh_friend.conflict45 *frnd); +void friend_clear_sent(int err,void *user_data); +net_buf * create_friend_pdu(bt_mesh_friend.conflict45 *frnd,friend_pdu_info.conflict *info,net_buf_simple *sdu); +void clear_timeout(k_work *work); +_Bool friend_lpn_matches(bt_mesh_friend.conflict45 *frnd,u16_t net_idx,u16_t addr); +_Bool friend_queue_has_space(bt_mesh_friend.conflict45 *frnd,u16_t addr,u64_t *seq_auth,u8_t seg_count); +void buf_send_start(u16_t duration,int err,void *user_data); +void buf_send_end(int err,void *user_data); +void purge_buffers(sys_slist_t *list); +void friend_clear(bt_mesh_friend.conflict45 *frnd); +void friend_timeout(k_work *work); +net_buf * encode_friend_ctl(bt_mesh_friend.conflict45 *frnd,u8_t ctl_op,net_buf_simple *sdu); +void enqueue_sub_cfm(bt_mesh_friend.conflict45 *frnd,u8_t xact); +_Bool friend_queue_prepare_space(bt_mesh_friend.conflict45 *frnd,u16_t addr,u64_t *seq_auth,u8_t seg_count); +void enqueue_update(bt_mesh_friend.conflict45 *frnd,u8_t md); +void enqueue_friend_pdu(bt_mesh_friend.conflict45 *frnd,bt_mesh_friend_pdu_type type,u8_t seg_count,net_buf *buf); +bt_mesh_friend.conflict45 *bt_mesh_friend_find(u16_t net_idx,u16_t lpn_addr,_Bool valid,_Bool established); +void bt_mesh_friend_clear_net_idx(u16_t net_idx); +void bt_mesh_friend_sec_update(u16_t net_idx); +int bt_mesh_friend_clear(bt_mesh_net_rx.conflict10 *rx,net_buf_simple *buf); +int bt_mesh_friend_sub_add(bt_mesh_net_rx.conflict10 *rx,net_buf_simple *buf); +int bt_mesh_friend_sub_rem(bt_mesh_net_rx.conflict10 *rx,net_buf_simple *buf); +int bt_mesh_friend_poll(bt_mesh_net_rx.conflict10 *rx,net_buf_simple *buf); +int bt_mesh_friend_clear_cfm(bt_mesh_net_rx.conflict10 *rx,net_buf_simple *buf); +int bt_mesh_friend_req(bt_mesh_net_rx.conflict10 *rx,net_buf_simple *buf); +int bt_mesh_friend_init(void); +_Bool bt_mesh_friend_match(u16_t net_idx,u16_t addr); +_Bool bt_mesh_friend_queue_has_space(u16_t net_idx,u16_t src,u16_t dst,u64_t *seq_auth,u8_t seg_count); +void bt_mesh_friend_enqueue_rx(bt_mesh_net_rx.conflict10 *rx,bt_mesh_friend_pdu_type type,u64_t *seq_auth,u8_t seg_count,net_buf_simple *sbuf); +_Bool bt_mesh_friend_enqueue_tx(bt_mesh_net_tx.conflict9 *tx,bt_mesh_friend_pdu_type type,u64_t *seq_auth,u8_t seg_count,net_buf_simple *sbuf); +void bt_mesh_friend_clear_incomplete(bt_mesh_subnet *sub,u16_t src,u16_t dst,u64_t *seq_auth); +void bt_mesh_srv_update_last_rcvd_msg(bt_mesh_last_rcvd_msg *last_msg,u8_t tid,u16_t src_addr,u16_t dst_addr); +_Bool bt_mesh_srv_check_rcvd_msg_with_last(u8_t tid,u16_t src_addr,u16_t dst_addr,int64_t *rcvd_time,bt_mesh_last_rcvd_msg *last_msg); +void k_queue_init(k_queue *queue,int size); +void k_queue_insert(k_queue *queue,void *prev,void *data); +void k_queue_append(k_queue *queue,void *data); +void k_queue_free(k_queue *queue); +void k_queue_prepend(k_queue *queue,void *data); +void k_queue_append_list(k_queue *queue,void *head,void *tail); +void * k_queue_get(k_queue *queue,s32_t timeout); +int k_queue_is_empty(k_queue *queue); +int k_queue_get_cnt(k_queue *queue); +int k_sem_init(k_sem *sem,uint initial_count,uint limit); +int k_sem_take(k_sem *sem,uint32_t timeout); +int k_sem_give(k_sem *sem); +int k_sem_delete(k_sem *sem); +uint k_sem_count_get(k_sem *sem); +int k_thread_create(k_thread *new_thread,char *name,size_t stack_size,k_thread_entry_t entry,int prio); +void k_thread_delete(k_thread *new_thread); +int k_yield(void); +void k_sleep(s32_t dur_ms); +uint irq_lock(void); +void irq_unlock(void); +void k_timer_init(k_timer_t.conflict *timer,k_timer_handler_t.conflict handle,void *args); +void k_timer_stop(k_timer_t.conflict *timer); +void k_timer_delete(k_timer_t.conflict *timer); +longlong k_now_ms(void); +longlong k_uptime_get(void); +u32_t.conflict k_uptime_get_32(void); +void k_timer_start(k_timer_t.conflict *timer,uint32_t timeout); +void k_get_random_byte_array(uint8_t *buf,size_t len); +void * k_malloc(size_t xWantedSize); +void k_free(void *pv); +int atomic_cas(atomic_t *target,atomic_val_t old_value,atomic_val_t new_value); +atomic_val_t atomic_inc(atomic_t *target); +atomic_val_t atomic_dec(atomic_t *target); +atomic_val_t atomic_get(atomic_t *target); +atomic_val_t atomic_set(atomic_t *target,atomic_val_t value); +atomic_val_t atomic_clear(atomic_t *target); +atomic_val_t atomic_or(atomic_t *target,atomic_val_t value); +atomic_val_t atomic_and(atomic_t *target,atomic_val_t value); +void fixed_data_unref(net_buf *buf,u8_t *data); +net_buf_pool * net_buf_pool_get(int id); +int net_buf_id(net_buf *buf); +u8_t * fixed_data_alloc(net_buf *buf,size_t *size,s32_t timeout); +net_buf * net_buf_alloc_len(net_buf_pool *pool,size_t size,s32_t timeout); +net_buf * net_buf_alloc_fixed(net_buf_pool *pool,s32_t timeout); +net_buf * net_buf_get(k_fifo *fifo,s32_t timeout); +void net_buf_simple_reserve(net_buf_simple *buf,size_t reserve); +void net_buf_slist_put(sys_slist_t *list,net_buf *buf); +net_buf * net_buf_slist_get(sys_slist_t *list); +void net_buf_put(k_fifo *fifo,net_buf *buf); +void net_buf_unref(net_buf *buf); +net_buf * net_buf_ref(net_buf *buf); +void net_buf_frag_insert(net_buf *parent,net_buf *frag); +net_buf * net_buf_frag_add(net_buf *head,net_buf *frag); +net_buf * net_buf_frag_del(net_buf *parent,net_buf *frag); +void * net_buf_simple_add(net_buf_simple *buf,size_t len); +void * net_buf_simple_add_mem(net_buf_simple *buf,void *mem,size_t len); +u8_t * net_buf_simple_add_u8(net_buf_simple *buf,u8_t val); +void net_buf_simple_add_le16(net_buf_simple *buf,u16_t val); +void net_buf_simple_add_be16(net_buf_simple *buf,u16_t val); +void net_buf_simple_add_be32(net_buf_simple *buf,u32_t.conflict val); +void * net_buf_simple_push(net_buf_simple *buf,size_t len); +void net_buf_simple_push_le16(net_buf_simple *buf,u16_t val); +void net_buf_simple_push_be16(net_buf_simple *buf,u16_t val); +void net_buf_simple_push_u8(net_buf_simple *buf,u8_t val); +void * net_buf_simple_pull(net_buf_simple *buf,size_t len); +void * net_buf_simple_pull_mem(net_buf_simple *buf,size_t len); +u8_t net_buf_simple_pull_u8(net_buf_simple *buf); +u16_t net_buf_simple_pull_le16(net_buf_simple *buf); +u16_t net_buf_simple_pull_be16(net_buf_simple *buf); +u32_t.conflict net_buf_simple_pull_be32(net_buf_simple *buf); +size_t net_buf_simple_headroom(net_buf_simple *buf); +size_t net_buf_simple_tailroom(net_buf_simple *buf); +size_t net_buf_append_bytes(net_buf *buf,size_t len,void *value,s32_t timeout,net_buf_allocator_cb *allocate_cb,void *user_data); +char * bt_hex_real(void *buf,size_t len); +char * bt_addr_le_str_real(bt_addr_le_t *addr); +void k_work_submit_to_queue(k_work_q *work_q,k_work *work); +void work_queue_main(void *p1); +int k_work_q_start(void); +int k_work_init(k_work *work,k_work_handler_t *handler); +void k_work_submit(k_work *work); +void k_delayed_work_init(k_delayed_work *work,k_work_handler_t *handler); +s32_t k_delayed_work_remaining_get(k_delayed_work *work); +void k_delayed_work_del_timer(k_delayed_work *work); +int add_timer_record(k_delayed_work *delay_work); +int remv_timer_record(k_delayed_work *delay_work); +int k_delayed_work_cancel(k_delayed_work *work); +int k_delayed_work_submit(k_delayed_work *work,uint32_t delay); +timer_rec_d * get_timer_record(void *hdl); +void work_timeout(void *timer); +void reverse_bytearray(uint8_t *src,uint8_t *result,int array_size); +uint find_msb_set(uint32_t data); +uint find_lsb_set(uint32_t data); +void gf_double(uint8_t *out,uint8_t *in); +int tc_cmac_erase(TCCmacState_t s); +int tc_cmac_init(TCCmacState_t s); +int tc_cmac_setup(TCCmacState_t s,uint8_t *key,TCAesKeySched_t sched); +int tc_cmac_update(TCCmacState_t s,uint8_t *data,size_t data_length); +int tc_cmac_final(uint8_t *tag,TCCmacState_t s); +uint _copy(uint8_t *to,uint to_len,uint8_t *from,uint from_len); +void * _set(void *__s,int __c,size_t __n); +uint8_t _double_byte(uint8_t a); +rx_msg_struct * bl_find_valid_queued_entry(void); +void bl_onchiphci_rx_packet_handler(uint8_t pkt_type,uint16_t src_id,uint8_t *param,uint8_t param_len,void *rx_buf); +void bl_handle_queued_msg(void); +void bl_onchiphci_interface_deinit(void); +uint8_t bl_onchiphci_interface_init(void); +int bl_onchiphci_send_2_controller(net_buf *buf); +int hci_driver_send(net_buf *buf); +int hci_driver_open(void); +void recv_thread(void *p1); +void hci_driver_enque_recvq(net_buf *buf); +int hci_driver_init(void); +int atomic_test_bit(atomic_t *target,int bit); +void tx_free(bt_conn_tx *tx); +int send_frag(ushort *param_1,net_buf *param_2,int param_3,int param_4); +void notify_connected(bt_conn *conn); +void bt_conn_reset_rx_state(bt_conn *conn); +void conn_cleanup(bt_conn *conn); +void tx_notify(bt_conn *conn); +void tx_complete_work(k_work *work); +k_sem * bt_conn_get_pkts(bt_conn *conn); +void notify_le_param_updated(bt_conn *conn); +_Bool le_param_req(bt_conn *conn,bt_le_conn_param *param); +_Bool le_check_valid_conn(void); +void bt_conn_identity_resolved(bt_conn *conn); +int bt_conn_le_start_encryption(bt_conn *conn,u8_t *rand,u8_t *ediv,u8_t *ltk,size_t len); +void bt_conn_security_changed(bt_conn *param_1,int param_2); +int bt_conn_set_security(bt_conn *conn,bt_security_t sec); +bt_security_t bt_conn_get_security(bt_conn *conn); +void bt_conn_cb_register(bt_conn_cb *cb); +void bt_conn_recv(bt_conn *conn,net_buf *buf,u8_t flags); +int bt_conn_send_cb(bt_conn *conn,net_buf *buf,bt_conn_tx_cb_t *cb,void *user_data); +int bt_conn_prepare_events(k_poll_event *events); +bt_conn * bt_conn_add_le(u8_t id,bt_addr_le_t *peer); +void bt_conn_set_state(bt_conn *conn,bt_conn_state_t state); +bt_conn * bt_conn_lookup_handle(u16_t handle); +int bt_conn_addr_le_cmp(bt_conn *conn,bt_addr_le_t *peer); +bt_conn * bt_conn_lookup_state_le(bt_addr_le_t *peer,bt_conn_state_t state); +bt_conn * bt_conn_lookup_addr_le(u8_t id,bt_addr_le_t *peer); +bt_conn * bt_conn_lookup_state_le(bt_addr_le_t *peer,bt_conn_state_t state); +void bt_conn_foreach(int type,anon_subr_void_bt_conn_ptr_void_ptr *func,void *data); +void bt_conn_disconnect_all(u8_t id); +bt_conn * bt_conn_ref(bt_conn *conn); +void bt_conn_unref(bt_conn *conn); +bt_addr_le_t * bt_conn_get_dst(bt_conn *conn); +int bt_conn_get_info(bt_conn *conn,bt_conn_info *info); +int bt_conn_get_remote_dev_info(bt_conn_info *info); +int bt_conn_disconnect(bt_conn *conn,u8_t reason); +void disconnect_all(bt_conn *conn,void *data); +bt_conn * bt_conn_create_le(bt_addr_le_t *peer,bt_le_conn_param *param); +int bt_conn_le_conn_update(bt_conn *conn,bt_le_conn_param *param); +int send_conn_le_param_update(bt_conn *conn,bt_le_conn_param *param); +void conn_update_timeout(k_work *work); +int bt_conn_le_param_update(bt_conn *conn,bt_le_conn_param *param); +net_buf * bt_conn_create_pdu_timeout(net_buf_pool *pool,size_t reserve,s32_t timeout); +net_buf * create_frag(net_buf *buf); +void bt_conn_process_tx(bt_conn *param_1); +int bt_conn_auth_cb_register(bt_conn_auth_cb *cb); +int bt_conn_auth_passkey_entry(bt_conn *conn,uint passkey); +int bt_conn_auth_passkey_confirm(bt_conn *conn); +int bt_conn_auth_cancel(bt_conn *conn); +int bt_conn_auth_pairing_confirm(bt_conn *conn); +u8_t bt_conn_index(bt_conn *conn); +int bt_conn_init(void); +int bt_rand(void *buf,size_t len); +int bt_encrypt_le(u8_t *key,u8_t *plaintext,u8_t *enc_data); +int bt_encrypt_be(u8_t *key,u8_t *plaintext,u8_t *enc_data); +void sys_slist_remove(sys_slist_t *list,sys_snode_t *prev_node,sys_snode_t *node); +u8_t found_attr(bt_gatt_attr *attr,void *user_data); +u16_t find_static_attr(bt_gatt_attr *attr); +void gatt_ccc_changed(bt_gatt_attr *attr,_bt_gatt_ccc.conflict2 *ccc); +void gatt_indicate_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +void sc_restore_rsp(bt_conn *conn,bt_gatt_attr *attr,u8_t err); +void gatt_subscription_remove(bt_conn *conn,sys_snode_t *prev,bt_gatt_subscribe_params *params); +void gatt_mtu_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +void gatt_write_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +bt_gatt_ccc_cfg * find_ccc_cfg(bt_conn *conn,_bt_gatt_ccc.conflict2 *ccc); +int gatt_notify(bt_conn *conn,u16_t handle,bt_gatt_notify_params.conflict2 *params); +void gatt_read_multiple_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +void gatt_write_ccc_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +int gatt_send(bt_conn *conn,net_buf *buf,bt_att_func_t *func,void *params); +int gatt_indicate(bt_conn *conn,u16_t handle,bt_gatt_indicate_params.conflict2 *params); +undefined4 match_uuid(undefined4 param_1,undefined4 *param_2); +void sc_indicate_rsp(bt_conn *conn,bt_gatt_attr *attr,u8_t err); +u8_t disconnected_cb(bt_gatt_attr *attr,void *user_data); +gatt_sc_cfg * find_sc_cfg(u8_t id,bt_addr_le_t *addr); +int gatt_write_ccc(bt_conn *conn,u16_t handle,u16_t value,bt_gatt_subscribe_params *params); +ssize_t read_appearance(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset); +ssize_t read_ppcp(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset); +ssize_t read_name(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset); +ssize_t bt_gatt_attr_read_ccc(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset); +ssize_t bt_gatt_attr_read_service(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset); +void sc_save(u8_t id,bt_addr_le_t *peer,u16_t start,u16_t end); +_Bool sc_ccc_cfg_write(bt_conn *conn,bt_gatt_attr *attr,u16_t value); +u8_t notify_cb(bt_gatt_attr *attr,void *user_data); +void sc_indicate(u16_t start,u16_t end); +ssize_t bt_gatt_attr_write_ccc(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset,u8_t flags); +void bt_gatt_init(void); +void bt_gatt_deinit(void); +undefined4 bt_gatt_service_unregister(int *param_1); +ssize_t bt_gatt_attr_read(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t buf_len,u16_t offset,void *value,u16_t value_len); +uint16_t bt_gatt_attr_value_handle(bt_gatt_attr *attr); +uint lexical_block_0(bt_gatt_attr *param_1); +ssize_t bt_gatt_attr_read_chrc(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset); +void bt_gatt_foreach_attr_type(u16_t start_handle,u16_t end_handle,bt_uuid *uuid,void *attr_data,uint16_t num_matches,bt_gatt_attr_func_t *func,void *user_data); +void bt_gatt_foreach_attr(u16_t start_handle,u16_t end_handle,bt_gatt_attr_func_t *func,void *user_data); +int bt_gatt_service_register(bt_uuid **param_1); +int bt_gatt_notify_cb(bt_conn *conn,bt_gatt_notify_params.conflict2 *params); +int bt_gatt_indicate(bt_conn *conn,bt_gatt_indicate_params.conflict2 *params); +void sc_process(k_work *work); +u16_t bt_gatt_get_mtu(bt_conn *conn); +u8_t bt_gatt_check_perm(bt_conn *conn,bt_gatt_attr *attr,u8_t mask); +u8_t update_ccc(bt_gatt_attr *attr,void *user_data); +int bt_gatt_exchange_mtu(bt_conn *conn,bt_gatt_exchange_params *params); +int bt_gatt_discover(bt_conn *conn,bt_gatt_discover_params *params); +void gatt_discover_next(bt_conn *conn,u16_t last_handle,bt_gatt_discover_params *params); +void gatt_find_type_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +void gatt_read_group_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +void gatt_read_type_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +void read_included_uuid_cb(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +void gatt_find_info_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +int bt_gatt_read(bt_conn *conn,bt_gatt_read_params *params); +void gatt_read_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +int bt_gatt_write_without_response_cb(bt_conn *conn,u16_t handle,void *data,u16_t length,_Bool sign,bt_gatt_complete_func_t *func,void *user_data); +int bt_gatt_write(bt_conn *conn,bt_gatt_write_params *params); +void gatt_prepare_write_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +int bt_gatt_subscribe(bt_conn *conn,bt_gatt_subscribe_params *params); +int bt_gatt_unsubscribe(bt_conn *conn,bt_gatt_subscribe_params *params); +void bt_gatt_notification(bt_conn *conn,u16_t handle,void *data,u16_t length); +void bt_gatt_connected(bt_conn *conn); +void bt_gatt_encrypt_change(bt_conn *conn); +_Bool bt_gatt_change_aware(bt_conn *conn,_Bool req); +void bt_gatt_disconnected(bt_conn *conn); +void le_dhkey_complete(net_buf *buf); +void hci_data_buf_overflow(net_buf *buf); +int atomic_test_bit(atomic_t *target,int bit); +void bt_addr_le_copy(bt_addr_le_t *dst,bt_addr_le_t *src); +void le_pkey_complete(net_buf *buf); +void atomic_set_bit_to(atomic_t *target,int bit,_Bool val); +void slave_update_conn_param(bt_conn *conn); +void le_remote_feat_complete(net_buf *buf); +void le_conn_update_complete(net_buf *buf); +void hci_num_completed_packets(net_buf *buf); +void update_sec_level(bt_conn *conn); +void hci_encrypt_key_refresh_complete(net_buf *buf); +void hci_encrypt_change(net_buf *buf); +bt_conn * find_pending_connect(bt_addr_le_t *peer_addr); +void hci_vendor_event(net_buf *buf); +void handle_event(u8_t event,net_buf *buf,event_handler *handlers,size_t num_handlers); +void hci_le_meta_event(net_buf *buf); +void hci_cmd_done(u16_t opcode,u8_t status,net_buf *buf); +void hci_cmd_status(net_buf *buf); +void hci_cmd_complete(net_buf *buf); +int id_find(bt_addr_le_t *addr); +void sys_put_le64(u8_t *dst); +net_buf * bt_hci_cmd_create(u16_t opcode,u8_t param_len); +int bt_hci_cmd_send_sync(u16_t opcode,net_buf *buf,net_buf **rsp); +int set_le_scan_enable(u8_t enable); +int set_random_address(bt_addr_t *addr); +int le_set_private_addr(void); +int hci_id_add(bt_addr_le_t *addr,u8_t *val); +void keys_add_id(bt_keys *keys,void *data); +int addr_res_enable(u8_t enable); +int set_advertise_enable(_Bool enable); +void hci_disconn_complete(net_buf *buf); +int set_ad(u16_t hci_op,bt_ad *ad,size_t ad_len); +int le_adv_update(bt_data *ad,size_t ad_len,bt_data *sd,size_t sd_len,_Bool connectable,_Bool use_name); +bt_addr_le_t * bt_lookup_id_addr(u8_t id,bt_addr_le_t *addr); +_Bool bt_le_conn_params_valid(bt_le_conn_param *param); +int bt_unpair(u8_t id,bt_addr_le_t *addr); +void bt_id_add(bt_keys *keys); +void bt_id_del(bt_keys *keys); +void update_pending_id(bt_keys *keys,void *data); +void bt_data_parse(net_buf_simple *ad,anon_subr__Bool_bt_data_ptr_void_ptr *func,void *user_data); +int bt_addr_le_create_static(bt_addr_le_t *addr); +void id_create(u8_t id,bt_addr_le_t *addr); +int bt_send(net_buf *buf); +int bt_hci_cmd_send(u16_t opcode,net_buf *buf); +int bt_le_set_data_len(bt_conn *conn,u16_t tx_octets,u16_t tx_time); +int start_le_scan(u8_t scan_type,u16_t interval,u16_t window); +int bt_le_scan_update(_Bool fast_scan); +void le_adv_report(net_buf *buf); +void le_ltk_request(net_buf *buf); +void le_conn_param_neg_reply(u16_t handle,u8_t reason); +void le_conn_param_req(net_buf *buf); +void enh_conn_complete(bt_hci_evt_le_enh_conn_complete *evt); +void le_enh_conn_complete(net_buf *buf); +void le_legacy_conn_complete(net_buf *buf); +void hci_tx_thread(void *p1); +int bt_recv(net_buf *buf); +undefined4 bt_recv_prio(net_buf *param_1); +int bt_hci_driver_register(bt_hci_driver *drv); +void bt_finalize_init(void); +void bt_delete_queue(k_fifo *queue_to_del); +int bt_disable_action(void); +int bt_disable(void); +int bt_set_name(char *name); +int bt_enable(bt_ready_cb_t *cb); +char * bt_get_name(void); +int bt_id_create(bt_addr_le_t *addr,u8_t *irk); +int bt_setup_id_addr(void); +void init_work(k_work *work); +_Bool bt_addr_le_is_bonded(u8_t id,bt_addr_le_t *addr); +int bt_le_adv_start_internal(byte *param_1,bt_data *param_2,size_t param_3,bt_data *param_4,size_t param_5,bt_addr_le_t *param_6); +int set_adv_channel_map(u8_t channel); +int bt_get_local_public_address(bt_addr_le_t *adv_addr); +int bt_get_local_ramdon_address(bt_addr_le_t *adv_addr); +int bt_le_adv_start(bt_le_adv_param *param,bt_data *ad,size_t ad_len,bt_data *sd,size_t sd_len); +int bt_le_adv_stop(void); +int bt_le_scan_start(byte *param_1,bt_le_scan_cb_t.conflict1 *param_2); +int bt_le_scan_stop(void); +int bt_set_tx_pwr(int8_t power); +int bt_buf_get_rx_avail_cnt(void); +net_buf * bt_buf_get_rx(bt_buf_type type,s32_t timeout); +net_buf * bt_buf_get_cmd_complete(s32_t timeout); +int bt_pub_key_gen(bt_pub_key_cb *new_cb); +u8_t * bt_pub_key_get(void); +int bt_dh_key_gen(u8_t *remote_pk,bt_dh_key_cb_t *cb); +void sys_slist_remove(sys_slist_t *list,sys_snode_t *prev_node,sys_snode_t *node); +size_t net_buf_frags_len(net_buf *buf); +u8_t get_ident(void); +bt_l2cap_le_chan * __l2cap_lookup_ident(bt_conn *conn,u16_t ident,_Bool remove); +bt_l2cap_server * l2cap_server_lookup_psm(u16_t psm); +bt_l2cap_le_chan * l2cap_remove_rx_cid(bt_conn *conn,u16_t cid); +void l2cap_chan_sdu_sent(bt_conn *conn,void *user_data); +net_buf * l2cap_alloc_frag(s32_t timeout,void *user_data); +void l2cap_connected(bt_l2cap_chan *chan); +void l2cap_chan_destroy(bt_l2cap_chan *chan); +void l2cap_chan_tx_init(bt_l2cap_le_chan *chan); +void l2cap_chan_rx_init(bt_l2cap_le_chan *chan); +int l2cap_accept(bt_conn *conn,bt_l2cap_chan **chan); +net_buf * l2cap_create_le_sig_pdu(u8_t code,u8_t ident,u16_t len); +void l2cap_chan_tx_give_credits(bt_l2cap_le_chan *chan,u16_t credits); +void l2cap_disconnected(void); +void bt_l2cap_chan_remove(bt_conn *conn,bt_l2cap_chan *ch); +void bt_l2cap_chan_del(bt_l2cap_chan *chan); +void l2cap_rtx_timeout(k_work *work); +void bt_l2cap_disconnected(bt_conn *conn); +net_buf * bt_l2cap_create_pdu_timeout(net_buf_pool *pool,size_t reserve,s32_t timeout); +int bt_l2cap_send_cb(bt_conn *conn,u16_t cid,net_buf *buf,bt_conn_tx_cb_t *cb,void *user_data); +void bt_l2cap_send(bt_conn *conn,u16_t cid,net_buf *buf); +void l2cap_chan_send_credits(bt_l2cap_le_chan *chan,u16_t credits); +int l2cap_le_conn_req(bt_l2cap_le_chan *ch); +void bt_l2cap_encrypt_change(bt_conn *conn,u8_t hci_status); +void l2cap_send_reject(bt_conn *conn,u8_t ident,u16_t reason,void *data,u8_t data_len); +int l2cap_chan_le_send(bt_l2cap_le_chan *ch,net_buf *buf,u16_t sdu_hdr_len); +int l2cap_chan_le_send_sdu(bt_l2cap_le_chan *param_1,net_buf **param_2,ushort param_3); +bt_l2cap_chan * bt_l2cap_le_lookup_tx_cid(bt_conn *conn,u16_t cid); +bt_l2cap_chan * bt_l2cap_le_lookup_rx_cid(bt_conn *conn,u16_t cid); +_Bool l2cap_chan_add(bt_conn *conn,bt_l2cap_chan *chan,bt_l2cap_chan_destroy_t *destroy); +void bt_l2cap_connected(bt_conn *conn); +void bt_l2cap_recv(bt_conn *conn,net_buf *buf); +int bt_l2cap_update_conn_param(bt_conn *conn,bt_le_conn_param *param); +void bt_l2cap_init(void); +int bt_l2cap_chan_disconnect(bt_l2cap_chan *chan); +void l2cap_chan_le_recv_seg(bt_l2cap_le_chan *param_1,net_buf *param_2); +void l2cap_rx_process(k_work *work); +int l2cap_recv(bt_l2cap_chan *chan_1,net_buf *buf); +void uuid_to_uuid128(bt_uuid *src,bt_uuid_128 *dst); +int bt_uuid_cmp(bt_uuid *u1,bt_uuid *u2); +_Bool bt_uuid_create(bt_uuid *uuid,u8_t *data,u8_t data_len); +void bt_uuid_to_str(bt_uuid *uuid,char *str,size_t len); +void sys_memcpy_swap(void *dst,void *src,size_t length); +void sys_mem_swap(void *buf,size_t length); +u8_t get_io_capa(void); +bt_smp * smp_chan_get(bt_conn *conn); +void atomic_set_bit(atomic_t *target,int bit); +int atomic_test_bit(atomic_t *target,int bit); +void smp_reset(bt_smp *smp); +void smp_pairing_complete(bt_smp *smp,u8_t status); +int bt_smp_aes_cmac(u8_t *key,u8_t *in,size_t len,u8_t *out); +int smp_sign_buf(u8_t *key,u8_t *msg,u16_t len); +int smp_f4(u8_t *u,u8_t *v,u8_t *x,u8_t z,u8_t *res); +u8_t sc_smp_check_confirm(bt_smp *smp); +int smp_f5(u8_t *w,u8_t *n1,u8_t *n2,bt_addr_le_t *a1,bt_addr_le_t *a2,u8_t *mackey,u8_t *ltk); +int smp_f6(u8_t *w,u8_t *n1,u8_t *n2,u8_t *r,u8_t *iocap,bt_addr_le_t *a1,bt_addr_le_t *a2,u8_t *check); +int smp_g2(u8_t *u,u8_t *v,u8_t *x,u8_t *y,u32_t.conflict *passkey); +int atomic_test_and_clear_bit(atomic_t *target,int bit); +u8_t display_passkey(bt_smp *smp); +_Bool update_keys_check(bt_smp *smp); +u8_t smp_pairing_failed(bt_smp *smp,net_buf *buf); +void smp_timeout(k_work *work); +u8_t smp_ident_info(bt_smp *smp,net_buf *buf); +u8_t smp_encrypt_info(bt_smp *smp,net_buf *buf); +u8_t legacy_request_tk(bt_smp *smp); +void bt_smp_disconnected(bt_l2cap_chan *chan); +void bt_smp_connected(bt_l2cap_chan *chan); +u8_t get_auth(u8_t auth); +_Bool sec_level_reachable(void); +int bt_smp_accept(bt_conn *conn,bt_l2cap_chan **chan); +_Bool smp_keys_check(bt_conn *conn); +u8_t get_pair_method(bt_smp *smp,u8_t remote_io); +net_buf * smp_create_pdu(bt_smp *smp,u8_t op); +void smp_send(bt_smp *smp,net_buf *buf,bt_conn_tx_cb_t *cb); +u8_t sc_smp_send_dhkey_check(bt_smp *smp,u8_t *e); +u8_t compute_and_send_master_dhcheck(bt_smp *smp); +u8_t compute_and_check_and_send_slave_dhcheck(bt_smp *smp); +u8_t smp_dhkey_check(bt_smp *smp,net_buf *buf); +u8_t smp_send_pairing_random(bt_smp *smp); +u8_t sc_send_public_key(bt_smp *smp); +u8_t send_pairing_rsp(bt_smp *smp); +u8_t bt_smp_distribute_keys(bt_smp *smp); +u8_t smp_signing_info(bt_smp *smp,net_buf *buf); +u8_t smp_master_ident(bt_smp *smp,net_buf *buf); +int smp_init(bt_smp *smp); +int smp_send_pairing_req(bt_conn *conn); +u8_t smp_security_request(bt_smp *smp,net_buf *buf); +u8_t smp_pairing_req(bt_smp *smp,net_buf *buf); +void smp_check_complete(bt_conn *conn,u8_t dist_complete); +void smp_sign_info_sent(bt_conn *conn,void *user_data); +void le_sc_oob_config_set.isra.3.constprop.19(int *param_1,char *param_2); +int smp_error(bt_smp *smp,u8_t reason); +void bt_smp_dhkey_ready(u8_t *dhkey); +int bt_smp_recv(bt_l2cap_chan *chan,net_buf *buf); +void bt_smp_encrypt_change(bt_l2cap_chan *chan,u8_t hci_status); +u8_t smp_send_pairing_confirm(bt_smp *smp); +void smp_ident_sent(bt_conn *conn,void *user_data); +int smp_c1(u8_t *k,u8_t *r,u8_t *preq,u8_t *pres,bt_addr_le_t *ia,bt_addr_le_t *ra,u8_t *enc_data); +u8_t legacy_send_pairing_confirm(bt_smp *smp); +u8_t legacy_pairing_confirm(bt_smp *smp); +u8_t smp_pairing_confirm(bt_smp *smp,net_buf *buf); +u8_t smp_pairing_rsp(bt_smp *smp,net_buf *buf); +u8_t smp_ident_addr_info(bt_smp *smp,net_buf *buf); +u8_t smp_public_key_slave(bt_smp *smp); +u8_t smp_public_key(bt_smp *smp,net_buf *buf); +void bt_smp_pkey_ready(u8_t *pkey); +u8_t smp_pairing_random(bt_smp *smp,net_buf *buf); +_Bool bt_smp_request_ltk(bt_conn *conn,u16_t ediv,u8_t *ltk); +int bt_smp_sign_verify(bt_conn *conn,net_buf *buf); +int bt_smp_sign(bt_conn *conn,net_buf *buf); +int bt_smp_auth_passkey_entry(bt_conn *conn,uint passkey); +int bt_smp_auth_passkey_confirm(bt_conn *conn); +int bt_smp_auth_cancel(bt_conn *conn); +int bt_smp_auth_pairing_confirm(bt_conn *conn); +int bt_smp_start_security(bt_conn *conn); +void bt_smp_update_keys(bt_conn *conn); +int bt_smp_init(void); +bt_keys * bt_keys_find_addr(u8_t id,bt_addr_le_t *addr); +bt_keys * bt_keys_find(int type,u8_t id,bt_addr_le_t *addr); +bt_keys * bt_keys_get_addr(u8_t id,bt_addr_le_t *addr); +void bt_keys_foreach(int type,anon_subr_void_bt_keys_ptr_void_ptr *func,void *data); +bt_keys * bt_keys_find(int type,u8_t id,bt_addr_le_t *addr); +bt_keys * bt_keys_get_type(int type,u8_t id,bt_addr_le_t *addr); +bt_keys * bt_keys_find_irk(u8_t id,bt_addr_le_t *addr); +bt_keys * bt_keys_find_addr(u8_t id,bt_addr_le_t *addr); +void bt_keys_add_type(bt_keys *keys,int type); +void bt_keys_clear(bt_keys *keys); +void keys_clear_id(bt_keys *keys,void *data); +void bt_keys_clear_all(u8_t id); +void bt_keys_update_usage(u8_t id,bt_addr_le_t *addr); +void bt_settings_encode_key(char *path,size_t path_size,char *subsys,bt_addr_le_t *addr,char *key); +u8_t notify_func(bt_conn *conn,bt_gatt_subscribe_params *params,void *data,u16_t length); +void le_param_updated(bt_conn *conn,u16_t interval,u16_t latency,u16_t timeout); +void ble_set_tx_pwr(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_unsubscribe(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void write_func(bt_conn *conn,u8_t err,bt_gatt_write_params *params); +void ble_exchange_mtu(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void exchange_func(bt_conn *conn,u8_t err,bt_gatt_exchange_params *params); +void ble_auth_pairing_confirm(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_auth_passkey_confirm(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_auth_cancel(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_auth(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_security(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_select_conn(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_disconnect(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_connect(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_stop_advertise(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_get_device_name(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_start_advertise(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_set_adv_channel(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_stop_scan(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_disable(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +u8_t discover_func(bt_conn *conn,bt_gatt_attr *attr,bt_gatt_discover_params *params); +void ble_set_data_len(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_subscribe(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_write(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_read(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +u8_t read_func(bt_conn *conn,u8_t err,bt_gatt_read_params *params,void *data,u16_t length); +_Bool data_cb(bt_data *data,void *user_data); +void ble_discover(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_auth_passkey(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_conn_update(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_unpair(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_start_scan(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_set_device_name(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_init(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +int bt_addr_le_to_str(bt_addr_le_t *addr,char *str); +void device_found(bt_addr_le_t *addr,s8_t rssi,u8_t evtype,net_buf_simple *buf); +void ble_read_local_address(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void connected(bt_conn *conn,u8_t err); +void disconnected(bt_conn *conn,u8_t reason); +void security_changed(bt_conn *conn,bt_security_t level,bt_security_err err); +void auth_passkey_display(bt_conn *conn,uint passkey); +void auth_passkey_entry(bt_conn *conn); +void auth_passkey_confirm(bt_conn *conn,uint passkey); +void auth_cancel(bt_conn *conn); +void auth_pairing_confirm(bt_conn *conn); +void auth_pairing_complete(bt_conn *conn,_Bool bonded); +void auth_pairing_failed(bt_conn *conn,bt_security_err reason); +void identity_resolved(bt_conn *conn,bt_addr_le_t *rpa,bt_addr_le_t *identity); +void ble_get_all_conn_info(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_write_without_rsp(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +int ble_cli_register(void); +int ble_tp_recv(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset,u8_t flags); +void ble_tp_disconnected(bt_conn *conn,u8_t reason); +void ble_tp_connected(bt_conn *conn,u8_t err); +void ble_tp_ccc_cfg_changed(bt_gatt_attr *attr,u16_t value); +void ble_tp_tx_mtu_size(bt_conn *conn,u8_t err,bt_gatt_exchange_params *params); +void ble_tp_notify_task(void *pvParameters); +void ble_tp_init(void); +_Bool polling_events(k_poll_event *events,int num_events,s32_t timeout,int *last_registered); +void k_poll_event_init(k_poll_event *event,u32_t.conflict type,int mode,void *obj); +int k_poll(k_poll_event *events,int num_events,s32_t timeout); +int k_poll_signal_raise(k_poll_signal *signal,int result); +_Bool bt_rpa_irk_matches(u8_t *irk,bt_addr_t *addr); +u8_t u8_to_dec(char *buf,u8_t buflen,u8_t value); +void add_round_key(uint8_t *s,uint *k); +void shift_rows(uint8_t *s); +void mult_row_column(uint8_t *out,uint8_t *in); +int tc_aes128_set_encrypt_key(TCAesKeySched_t s,uint8_t *k); +int tc_aes_encrypt(uint8_t *out,uint8_t *in,TCAesKeySched_t s); +u8_t att_prepare_write_req(bt_att *att,net_buf *buf); +att_type_t att_op_get_type(u8_t op); +void att_req_destroy(bt_att_req.conflict28 *req); +u8_t att_notify(bt_att *att,net_buf *buf); +void bt_gatt_foreach_attr(u16_t start_handle,u16_t end_handle,bt_gatt_attr_func_t *func,void *user_data); +u8_t read_group_cb(bt_gatt_attr *attr,void *user_data); +u8_t read_type_cb(bt_gatt_attr *attr,void *user_data); +u8_t find_type_cb(bt_gatt_attr *attr,void *user_data); +u8_t find_info_cb(bt_gatt_attr *attr,void *user_data); +void bt_att_connected(bt_l2cap_chan *chan); +bt_conn_tx_cb_t * att_cb(void); +int att_send(bt_conn *conn,net_buf *buf,bt_conn_tx_cb_t *cb,void *user_data); +int att_send_req(bt_att *att,bt_att_req.conflict28 *req); +u8_t att_handle_rsp(bt_att *att,void *pdu,u16_t len,u8_t err); +u8_t att_handle_find_info_rsp(bt_att *att,net_buf *buf); +u8_t att_handle_find_type_rsp(bt_att *att,net_buf *buf); +u8_t att_handle_read_type_rsp(bt_att *att,net_buf *buf); +u8_t att_handle_read_rsp(bt_att *att,net_buf *buf); +u8_t att_handle_read_blob_rsp(bt_att *att,net_buf *buf); +u8_t att_handle_read_mult_rsp(bt_att *att,net_buf *buf); +u8_t att_handle_read_group_rsp(bt_att *att,net_buf *buf); +u8_t att_handle_write_rsp(bt_att *att,net_buf *buf); +u8_t att_handle_prepare_write_rsp(bt_att *att,net_buf *buf); +u8_t att_handle_exec_write_rsp(bt_att *att,net_buf *buf); +u8_t att_confirm(bt_att *att,net_buf *buf); +u8_t att_error_rsp(bt_att *att,net_buf *buf); +int bt_att_accept(bt_conn *conn,bt_l2cap_chan **chan); +u8_t att_mtu_rsp(bt_att *att,net_buf *buf); +void att_reset(bt_att *att); +void bt_att_disconnected(bt_l2cap_chan *chan); +void att_timeout(k_work *work); +void bt_att_encrypt_change(bt_l2cap_chan *chan,u8_t hci_status); +undefined4 att_exec_write_req(void); +void att_pdu_sent(bt_conn *conn,void *user_data); +bt_att * att_chan_get(bt_conn *conn); +void att_req_sent(bt_conn *conn,void *user_data); +void att_cfm_sent(bt_conn *conn,void *user_data); +void att_rsp_sent(bt_conn *conn,void *user_data); +u8_t write_cb(bt_gatt_attr *attr,void *user_data); +u8_t read_cb(bt_gatt_attr *attr,void *user_data); +net_buf * bt_att_create_pdu(bt_conn *conn,u8_t op,size_t len); +u8_t att_indicate(bt_att *att,net_buf *buf); +u8_t att_mtu_req(bt_att *att,net_buf *buf); +void send_err_rsp(bt_conn *conn,u8_t req,u16_t handle,u8_t err); +int bt_att_recv(bt_l2cap_chan *chan,net_buf *buf); +u8_t att_read_group_req(bt_att *att,net_buf *buf); +u8_t att_read_mult_req(bt_att *att,net_buf *buf); +u8_t att_read_rsp(bt_att *att,u8_t op,u8_t rsp,u16_t handle,u16_t offset); +u8_t att_read_blob_req(bt_att *att,net_buf *buf); +u8_t att_read_req(bt_att *att,net_buf *buf); +u8_t att_read_type_req(bt_att *att,net_buf *buf); +u8_t att_find_type_req(bt_att *att,net_buf *buf); +u8_t att_find_info_req(bt_att *att,net_buf *buf); +u8_t att_write_rsp(bt_conn *conn,u8_t req,u8_t rsp,u16_t handle,void *value,u16_t len); +u8_t att_write_req(bt_att *att,net_buf *buf); +u8_t att_write_cmd(bt_att *att,net_buf *buf); +u8_t att_signed_write_cmd(bt_att *att,net_buf *buf); +void bt_att_init(void); +u16_t bt_att_get_mtu(bt_conn *conn); +int bt_att_send(bt_conn *conn,net_buf *buf,bt_conn_tx_cb_t *cb,void *user_data); +int bt_att_req_send(bt_conn *conn,bt_att_req.conflict28 *req); +void bt_att_req_cancel(bt_conn *param_1,sys_snode_t param_2); +uint32_t fdt32_ld(fdt32_t *p); +int nextprop_(void *fdt,int offset); +fdt_property * fdt_get_property_by_offset_(void *fdt,int offset,int *lenp); +char * fdt_get_string(void *fdt,int stroffset,int *lenp); +char * fdt_get_name(void *fdt,int nodeoffset,int *len); +int fdt_subnode_offset_namelen(void *fdt,int offset,char *name,int namelen); +int fdt_subnode_offset(void *fdt,int parentoffset,char *name); +int fdt_first_property_offset(void *fdt,int nodeoffset); +int fdt_next_property_offset(void *fdt,int offset); +fdt_property *fdt_get_property_namelen_(void *fdt,int offset,char *name,int namelen,int *lenp,int *poffset); +void * fdt_getprop_namelen(void *fdt,int nodeoffset,char *name,int namelen,int *lenp); +void * fdt_getprop(void *fdt,int nodeoffset,char *name,int *lenp); +int fdt_stringlist_count(void *fdt,int nodeoffset,char *property); +char * fdt_stringlist_get(void *fdt,int nodeoffset,char *property,int idx,int *lenp); +void blfdt(char *buf,int len,int argc,char **argv); +int blfdt_cli_init(void); +uint32_t fdt32_ld(fdt32_t *p); +int fdt_ro_probe_(void *fdt); +void * fdt_offset_ptr(void *fdt,int offset,uint len); +uint32_t fdt_next_tag(void *fdt,int startoffset,int *nextoffset); +int fdt_check_node_offset_(void *fdt,int offset); +int fdt_check_prop_offset_(void *fdt,int offset); +int fdt_next_node(void *fdt,int offset,int *depth); +uint32_t fdt32_to_cpu(fdt32_t x); +uint64_t fdt64_to_cpu(void); +uint32_t fdt32_ld(fdt32_t *p); +_Bool util_is_printable_string(void *data,int len); +void utilfdt_print_data(char *data,int len); +undefined4 tc_blfdtdump(void); +undefined4 tc_fdt_wifi_module(void); +int tc_fdt_wifi(void); +void cmd_blog_info_dump(char *buf,int len,int argc,char **argv); +size_t blog_strcpy(size_t cur_len,char *dst,char *src); +void cmd_blog_set_level(char *buf,int len,int argc,char **argv); +void blog_port_output(char *log,size_t size); +void blog_hexdump_out(char *name,uint8_t width,uint8_t *buf,uint16_t size); +void blog_init(void); +int ota_dump_cmd(void); +void ota_tcp_cmd(char **argv); +void ota_tcp_cmd(char *buf,int len,int argc,char **argv); +int bl_sys_ota_cli_init(void); +void wifiprov_ccc_cfg_changed(bt_gatt_attr *attr,u16_t value); +void __bl_ble_sync_task(void *p_arg); +void scan_complete_cb(void *param); +int __recv_event(void *p_drv,pro_event *p_event); +void wifi_state_get_cb(void *p_arg); +size_t write_data(bt_conn *param_1,uint8_t *param_2,size_t param_3); +undefined4 __ble_bytes_send(uint8_t *param_1,uint param_2); +void blsync_disconnected(bt_conn *conn,u8_t reason); +void blsync_exchange_func(bt_conn *conn,u8_t err,bt_gatt_exchange_params *params); +ssize_t read_data(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset); +void blsync_connected(bt_conn *conn,u8_t err); +int bl_ble_sync_start(bl_ble_sync_t *index,blesync_wifi_func *func,pfn_complete_cb_t *cb,void *cb_arg); +int bl_ble_sync_stop(bl_ble_sync_t *index); +void * __malloc(size_t size); +void __free(void *ptr); +void __clear_dev(pro_handle_t handle); +int __protocol_send(pro_handle_t handle,uint8_t seq,uint8_t ack,uint8_t type,void *p_data,uint16_t length); +int pro_trans_read(pro_handle_t handle,void *buf,size_t bytes,uint16_t mtu); +int pro_trans_ack(pro_handle_t handle); +int pro_trans_layer_ack_read(pro_handle_t handle,void *ack_buf,size_t bytes); +pro_handle_t pro_trans_init(pro_dev *p_dev,pro_func *p_func,void *p_drv); +void pro_trans_reset(pro_handle_t handle); +int __pack_encrypt_read(void *p_drv,uint8_t pack_type,uint8_t *dst_id,uint8_t *dst_buf,uint8_t *dst_len,uint8_t *src_buf,size_t src_lenght); +int __pack_encrypt_write(void *p_drv,uint8_t pack_type,uint8_t src_id,uint8_t *dst_buf,uint8_t *dst_len,uint8_t *src_buf,uint8_t src_len,int16_t remain_len); +enc_handle_t pro_encrypt_init(encrypt *p_enc,void *p_drv); +int __payload_write(void *p_arg,uint8_t *dst_buf,uint8_t *dst_len,uint8_t src_id,uint8_t *src_buf,uint8_t src_len,int16_t remain_len); +int __payload_read(void *p_arg,uint8_t *dst_buf,uint8_t *dst_type,uint8_t *dst_len,uint8_t *src_buf,uint8_t src_len); +pyld_handle_t pro_payload_init(payload *p_pyld,void *p_drv); +void cmd_sys_time_now(char *buf,int len,int argc,char **argv); +int bl_sys_time_cli_init(void); +void bl_sys_time_update(undefined4 param_1,undefined4 param_2); +int bl_sys_time_get(uint64_t *epoch); +int bl_sys_time_sync_state(uint32_t *xTicksToJump); +uint parse_hex4(char *str); +char * parse_string(cJSON *item,char *str); +char * skip(char *in); +cJSON * cJSON_New_Item(void); +char * ensure(printbuffer *p,int needed); +char * cJSON_strdup(char *str); +int update(printbuffer *p); +char * print_number(cJSON *item,printbuffer *p); +char * print_string_ptr(char *str,printbuffer *p); +int cJSON_strcasecmp(char *s1,char *s2); +char * parse_value(cJSON *item,char *value); +char * print_array(int depth,int fmt,printbuffer *p); +char * print_value(cJSON *item,int depth,int fmt,printbuffer *p); +char * print_object(int depth,int fmt,printbuffer *p); +void cJSON_InitHooks(cJSON_Hooks *hooks); +void cJSON_Delete(cJSON *c); +cJSON * cJSON_ParseWithOpts(char *value,char **return_parse_end,int require_null_terminated); +cJSON * cJSON_Parse(char *value); +char * cJSON_Print(cJSON *item); +cJSON * cJSON_GetObjectItem(cJSON *object,char *string); +void cJSON_AddItemToArray(cJSON *array,cJSON *item); +void cJSON_AddItemToObject(cJSON *object,char *string,cJSON *item); +cJSON * cJSON_CreateNumber(void); +cJSON * cJSON_CreateString(char *string); +cJSON * cJSON_CreateObject(void); +cli_command * cli_command_get(int idx,int *is_static_cmd); +void exit_cmd(char *buf,int len,int argc,char **argv); +int cb_idnoe(void *arg,inode_t *node); +void ota_cmd(char *buf,int len,int argc,char **argv); +void tftp_ota_thread(void *arg); +void cat_cmd(char *buf,int len,int argc,char **argv); +void hexdump_cmd(char *buf,int len,int argc,char **argv); +int aos_cli_init(int use_thread); +void * aos_cli_event_cb_read_get(void); +int cli_putstr(char *msg); +void ps_cmd(char *buf,int len,int argc,char **argv); +int aos_cli_printf(char *msg,...); +int proc_onecmd(int argc,char **argv); +void ls_cmd(char *buf,int len,int argc,char **argv); +void uptime_cmd(char *buf,int len,int argc,char **argv); +void reset_cmd(char *buf,int len,int argc,char **argv); +void poweroff_cmd(char *buf,int len,int argc,char **argv); +void reboot_cmd(char *buf,int len,int argc,char **argv); +void version_cmd(char *buf,int len,int argc,char **argv); +void devname_cmd(char *buf,int len,int argc,char **argv); +void echo_cmd(char *buf,int len,int argc,char **argv); +void mmem_cmd(char *buf,int len,int argc,char **argv); +void pmem_cmd(char *buf,int len,int argc,char **argv); +void help_cmd(char *buf,int len,int argc,char **argv); +int cli_getchar(char *inbuf); +void cli_main_input(char *buffer,int count); +void console_cb_read(int fd,void *param); +void aos_cli_input_direct(char *buffer,int count); +void get_dns_request(void *arg,udp_pcb *upcb,pbuf *p,ip_addr_t *addr,u16_t port); +void dns_server_init(void); +EfErrCode easyflash_init(void); +size_t get_status(uint8_t *status_table,size_t status_num); +void update_sector_cache(uint32_t sec_addr,uint32_t empty_addr); +uint32_t get_next_sector_addr(sector_meta_data_t pre_sec); +_Bool gc_check_cb(sector_meta_data_t sector,void *arg1,void *arg2); +void update_env_cache(char *name,size_t name_len,uint32_t addr); +_Bool find_env_cb(env_node_obj_t env,void *arg1,void *arg2); +_Bool sector_statistics_cb(sector_meta_data_t sector,void *arg1,void *arg2); +_Bool alloc_env_cb(sector_meta_data_t sector,void *arg1,void *arg2); +EfErrCode write_status(uint32_t addr,uint8_t *status_table,size_t status_num,size_t status_index); +EfErrCode read_env(env_node_obj_t env); +EfErrCode update_sec_status(sector_meta_data_t sector,size_t new_env_len,_Bool *is_full); +EfErrCode format_sector(uint32_t addr); +_Bool check_sec_hdr_cb(sector_meta_data_t sector,void *arg1,void *arg2); +_Bool print_env_cb(env_node_obj_t env,void *arg1,void *arg2); +uint32_t get_next_env_addr(sector_meta_data_t sector,env_node_obj_t pre_env); +EfErrCode read_sector_meta_data(uint32_t addr,sector_meta_data_t sector,_Bool traversal); +void sector_iterator(sector_meta_data_t sector,sector_store_status_t status,void *arg1,void *arg2,anon_subr__Bool_sector_meta_data_t_void_ptr_void_ptr *callback,_Bool traversal_env); +uint32_t alloc_env(sector_meta_data_t sector,size_t env_size); +void gc_collect(void); +uint32_t new_env(sector_meta_data_t sector,size_t env_size); +_Bool check_and_recovery_gc_cb(sector_meta_data_t sector,void *arg1,void *arg2); +void env_iterator(env_node_obj_t env,void *arg1,void *arg2,anon_subr__Bool_env_node_obj_t_void_ptr_void_ptr *callback); +_Bool find_env(char *key,env_node_obj_t env); +EfErrCode del_env(char *key,env_node_obj_t old_env,_Bool complete_del); +EfErrCode move_env(env_node_obj_t env); +_Bool check_and_recovery_env_cb(env_node_obj_t env,void *arg1,void *arg2); +_Bool do_gc(sector_meta_data_t sector,void *arg1,void *arg2); +EfErrCode create_env_blob(sector_meta_data_t sector,char *key,void *value,size_t len); +size_t ef_get_env_blob(char *key,void *value_buf,size_t buf_len,size_t *saved_value_len); +char * ef_get_env(char *key); +EfErrCode ef_del_env(char *key); +EfErrCode ef_set_env_blob(char *key,void *value_buf,size_t buf_len); +EfErrCode ef_set_env(char *key,char *value); +EfErrCode ef_save_env(void); +EfErrCode ef_env_set_default(void); +void ef_print_env(void); +EfErrCode ef_load_env(void); +EfErrCode ef_env_init(ef_env *default_env,size_t default_env_size); +EfErrCode ef_port_read(uint32_t addr,uint32_t *buf,size_t size); +EfErrCode ef_port_write(uint32_t addr,uint32_t *buf,size_t size); +void ef_port_env_lock(void); +void ef_port_env_unlock(void); +void ef_log_debug(char *file,long line,char *format,...); +EfErrCode ef_port_erase(uint32_t addr,size_t size); +void ef_log_info(char *format,...); +EfErrCode ef_port_init(ef_env **default_env,size_t *default_env_size); +void ef_print(char *format,...); +uint32_t ef_calc_crc32(uint32_t crc,void *buf,size_t size); +void psm_get_cmd(char *buf,int len,int argc,char **argv); +void psm_test_cmd(void); +EfErrCode psm_erase_cmd(void); +void psm_dump_cmd(void); +void psm_unset_cmd(char *buf,int len,int argc,char **argv); +void psm_set_cmd(char *buf,int len,int argc,char **argv); +int easyflash_cli_init(void); +EventGroupHandle_t xEventGroupCreateStatic(StaticEventGroup_t *pxEventGroupBuffer); +EventBits_t xEventGroupWaitBits(EventGroupHandle_t xEventGroup,EventBits_t uxBitsToWaitFor,BaseType_t xClearOnExit,BaseType_t xWaitForAllBits,TickType_t xTicksToWait); +EventBits_t xEventGroupSetBits(EventGroupHandle_t xEventGroup,EventBits_t uxBitsToSet); +void vEventGroupDelete(EventGroupHandle_t xEventGroup); +void vListInitialise(List_t *pxList); +void vListInitialiseItem(ListItem_t *pxItem); +void vListInsertEnd(List_t *pxList,ListItem_t *pxNewListItem); +void vListInsert(List_t *pxList,ListItem_t *pxNewListItem); +UBaseType_t uxListRemove(ListItem_t *pxItemToRemove); +BaseType_t prvCopyDataToQueue(Queue_t *pxQueue,void *pvItemToQueue,BaseType_t xPosition); +void prvCopyDataFromQueue(Queue_t *pxQueue,void *pvBuffer); +void prvUnlockQueue(Queue_t *pxQueue); +BaseType_t xQueueGenericReset(QueueHandle_t xQueue,BaseType_t xNewQueue); +QueueHandle_t xQueueGenericCreateStatic(UBaseType_t uxQueueLength,UBaseType_t uxItemSize,uint8_t *pucQueueStorage,StaticQueue_t *pxStaticQueue,uint8_t ucQueueType); +QueueHandle_t xQueueGenericCreate(UBaseType_t uxQueueLength,UBaseType_t uxItemSize,uint8_t ucQueueType); +QueueHandle_t xQueueCreateCountingSemaphore(UBaseType_t uxMaxCount,UBaseType_t uxInitialCount); +BaseType_t xQueueGenericSend(QueueHandle_t xQueue,void *pvItemToQueue,TickType_t xTicksToWait,BaseType_t xCopyPosition); +QueueHandle_t xQueueCreateMutexStatic(uint8_t ucQueueType,StaticQueue_t *pxStaticQueue); +BaseType_t xQueueGiveMutexRecursive(QueueHandle_t xMutex); +QueueHandle_t xQueueCreateMutex(uint8_t ucQueueType); +BaseType_t xQueueGenericSendFromISR(QueueHandle_t xQueue,void *pvItemToQueue,BaseType_t *pxHigherPriorityTaskWoken,BaseType_t xCopyPosition); +BaseType_t xQueueGiveFromISR(QueueHandle_t xQueue,BaseType_t *pxHigherPriorityTaskWoken); +BaseType_t xQueueReceive(QueueHandle_t xQueue,void *pvBuffer,TickType_t xTicksToWait); +BaseType_t xQueueSemaphoreTake(QueueHandle_t xQueue,TickType_t xTicksToWait); +BaseType_t xQueueTakeMutexRecursive(QueueHandle_t xMutex,TickType_t xTicksToWait); +UBaseType_t uxQueueMessagesWaiting(QueueHandle_t xQueue); +void vQueueDelete(QueueHandle_t xQueue); +void vQueueAddToRegistry(QueueHandle_t xQueue,char *pcQueueName); +void vQueueWaitForMessageRestricted(QueueHandle_t xQueue,TickType_t xTicksToWait,BaseType_t xWaitIndefinitely); +void prvInitialiseNewStreamBuffer(StreamBuffer_t *pxStreamBuffer,uint8_t *pucBuffer,size_t xBufferSizeBytes,size_t xTriggerLevelBytes,uint8_t ucFlags); +size_t prvWriteBytesToBuffer(StreamBuffer_t *pxStreamBuffer,uint8_t *pucData,size_t xCount); +size_t prvReadBytesFromBuffer(StreamBuffer_t *pxStreamBuffer,uint8_t *pucData,size_t xMaxCount,size_t xBytesAvailable); +StreamBufferHandle_t xStreamBufferGenericCreate(size_t xBufferSizeBytes,size_t xTriggerLevelBytes,BaseType_t xIsMessageBuffer); +StreamBufferHandle_t xStreamBufferGenericCreateStatic(size_t xBufferSizeBytes,size_t xTriggerLevelBytes,BaseType_t xIsMessageBuffer,uint8_t *pucStreamBufferStorageArea,StaticStreamBuffer_t *pxStaticStreamBuffer); +void vStreamBufferDelete(StreamBufferHandle_t xStreamBuffer); +size_t xStreamBufferSpacesAvailable(StreamBufferHandle_t xStreamBuffer); +size_t xStreamBufferSend(StreamBufferHandle_t xStreamBuffer,void *pvTxData,size_t xDataLengthBytes,TickType_t xTicksToWait); +size_t xStreamBufferSendFromISR(StreamBufferHandle_t xStreamBuffer,void *pvTxData,size_t xDataLengthBytes,BaseType_t *pxHigherPriorityTaskWoken); +size_t xStreamBufferReceive(StreamBufferHandle_t xStreamBuffer,void *pvRxData,size_t xBufferLengthBytes,TickType_t xTicksToWait); +size_t xStreamBufferReceiveFromISR(StreamBufferHandle_t xStreamBuffer,void *pvRxData,size_t xBufferLengthBytes,BaseType_t *pxHigherPriorityTaskWoken); +BaseType_t xStreamBufferIsEmpty(StreamBufferHandle_t xStreamBuffer); +void prvResetNextTaskUnblockTime(void); +void prvInitialiseNewTask(TaskFunction_t *pxTaskCode,char *pcName,uint32_t ulStackDepth,void *pvParameters,UBaseType_t uxPriority,TaskHandle_t *pxCreatedTask,TCB_t *pxNewTCB); +void prvDeleteTCB(TCB_t *pxTCB); +void prvAddCurrentTaskToDelayedList(TickType_t xTicksToWait,BaseType_t xCanBlockIndefinitely); +void vTaskEnterCritical(void); +void vTaskExitCritical(void); +void prvAddNewTaskToReadyList(TCB_t *pxNewTCB); +TaskHandle_t xTaskCreateStatic(TaskFunction_t *pxTaskCode,char *pcName,uint32_t ulStackDepth,void *pvParameters,UBaseType_t uxPriority,StackType_t *puxStackBuffer,StaticTask_t *pxTaskBuffer); +BaseType_t xTaskCreate(TaskFunction_t *pxTaskCode,char *pcName,uint16_t usStackDepth,void *pvParameters,UBaseType_t uxPriority,TaskHandle_t *pxCreatedTask); +void vTaskDelete(TaskHandle_t xTaskToDelete); +void vTaskSuspendAll(void); +TickType_t xTaskGetTickCount(void); +BaseType_t xTaskGetTickCount2(TickType_t *ticks,BaseType_t *overflow); +TickType_t xTaskGetTickCountFromISR(void); +BaseType_t xTaskIncrementTick(void); +void vTaskDelay(TickType_t xTicksToDelay); +void vTaskSwitchContext(void); +void vTaskPlaceOnEventList(List_t *pxEventList,TickType_t xTicksToWait); +void vTaskPlaceOnUnorderedEventList(List_t *pxEventList,TickType_t xItemValue,TickType_t xTicksToWait); +void vTaskPlaceOnEventListRestricted(List_t *pxEventList,TickType_t xTicksToWait,BaseType_t xWaitIndefinitely); +BaseType_t xTaskRemoveFromEventList(List_t *pxEventList); +void vTaskRemoveFromUnorderedEventList(ListItem_t *pxEventListItem,TickType_t xItemValue); +void vTaskInternalSetTimeOutState(TimeOut_t *pxTimeOut); +void vTaskMissedYield(void); +void vTaskGetInfo(TaskHandle_t xTask,TaskStatus_t *pxTaskStatus,BaseType_t xGetFreeStackSpace,eTaskState eState); +UBaseType_t prvListTasksWithinSingleList(TaskStatus_t *pxTaskStatusArray,List_t *pxList,eTaskState eState); +UBaseType_t uxTaskGetSystemState(TaskStatus_t *pxTaskStatusArray,UBaseType_t uxArraySize,uint32_t *pulTotalRunTime); +TaskHandle_t xTaskGetCurrentTaskHandle(void); +BaseType_t xTaskGetSchedulerState(void); +BaseType_t xTaskPriorityInherit(TaskHandle_t pxMutexHolder); +BaseType_t xTaskPriorityDisinherit(TaskHandle_t pxMutexHolder); +void vTaskPriorityDisinheritAfterTimeout(TaskHandle_t pxMutexHolder,UBaseType_t uxHighestPriorityWaitingTask); +void vTaskEnterCritical(void); +void vTaskExitCritical(void); +void vTaskList(char *pcWriteBuffer); +TickType_t uxTaskResetEventItemValue(void); +TaskHandle_t pvTaskIncrementMutexHeldCount(void); +BaseType_t xTaskGenericNotifyFromISR(TaskHandle_t xTaskToNotify,uint32_t ulValue,eNotifyAction eAction,uint32_t *pulPreviousNotificationValue,BaseType_t *pxHigherPriorityTaskWoken); +void vTaskNotifyGiveFromISR(TaskHandle_t xTaskToNotify,BaseType_t *pxHigherPriorityTaskWoken); +BaseType_t xTaskNotifyStateClear(TaskHandle_t xTask); +void prvCheckForValidListAndQueue(void); +BaseType_t prvInsertTimerInActiveList(Timer_t *pxTimer,TickType_t xNextExpiryTime,TickType_t xTimeNow,TickType_t xCommandTime); +BaseType_t xTimerCreateTimerTask(void); +TimerHandle_t xTimerCreate(char *pcTimerName,TickType_t xTimerPeriodInTicks,UBaseType_t uxAutoReload,void *pvTimerID,TimerCallbackFunction_t *pxCallbackFunction); +TimerHandle_t xTimerCreateStatic(char *pcTimerName,TickType_t xTimerPeriodInTicks,UBaseType_t uxAutoReload,void *pvTimerID,TimerCallbackFunction_t *pxCallbackFunction,StaticTimer_t *pxTimerBuffer); +BaseType_t xTimerGenericCommand(TimerHandle_t xTimer,BaseType_t xCommandID,TickType_t xOptionalValue,BaseType_t *pxHigherPriorityTaskWoken,TickType_t xTicksToWait); +void prvSwitchTimerLists(void); +void prvTimerTask(void *pvParameters); +void * pvTimerGetTimerID(TimerHandle_t xTimer); +void vPortSetupTimerInterrupt(void); +void pxPortInitialiseStack(int param_1,undefined4 param_2,undefined4 param_3); +void prvInsertBlockIntoFreeList(BlockLink_t *pxBlockToInsert); +void * pvPortMalloc(size_t xWantedSize); +void vPortFree(void *pv); +size_t xPortGetFreeHeapSize(void); +void vPortDefineHeapRegions(HeapRegion_t *pxHeapRegions); +void uart_generic_notify_handler(uint8_t id); +void UART0_IRQHandler(void); +void UART1_IRQHandler(void); +int bl_uart_init(uint8_t id,uint8_t tx_pin,uint8_t rx_pin,uint8_t cts_pin,uint8_t rts_pin,uint32_t baudrate); +int bl_uart_data_send(uint8_t id,uint8_t data); +int bl_uart_data_recv(uint8_t id); +int bl_uart_int_rx_enable(uint8_t id); +int bl_uart_int_rx_disable(uint8_t id); +int bl_uart_int_tx_enable(uint8_t id); +int bl_uart_int_tx_disable(uint8_t id); +int bl_uart_flush(uint8_t id); +void bl_uart_getdefconfig(uint8_t id,uint8_t *parity); +void bl_uart_setconfig(uint8_t id,uint32_t baudrate,UART_Parity_Type parity); +void bl_uart_setbaud(uint8_t id,uint32_t baud); +int bl_uart_int_enable(uint8_t id); +int bl_uart_int_disable(uint8_t id); +int bl_uart_int_rx_notify_register(uint8_t id,cb_uart_notify_t *cb,void *arg); +int bl_uart_int_tx_notify_register(uint8_t id,cb_uart_notify_t *cb,void *arg); +int bl_chip_info(char *info); +int bl_chip_banner(char **banner); +int bl_chip_memory_ram(int *num,uint *addr,uint *size,char (*desc) [6]); +int bl_sys_reset_por(void); +void bl_sys_reset_system(void); +int bl_sys_isxipaddr(uint32_t addr); +int bl_sys_em_config(void); +int bl_sys_init(void); +void bl_dma_int_process(void); +int bl_dma_int_clear(int ch); +void bl_dma_IRQHandler(void); +int bl_dma_irq_register(int channel,void *tc_handler,void *interr_handler,void *ctx); +void bl_dma_init(void); +void _irq_num_check(int irqnum); +void bl_irq_enable(uint source); +void bl_irq_disable(uint source); +void bl_irq_pending_clear(uint source); +void bl_irq_register_with_ctx(int irqnum,void *handler,void *ctx); +void bl_irq_ctx_get(int irqnum,void **ctx); +void bl_irq_register(int irqnum,void *handler); +void bl_irq_unregister(int irqnum,void *handler); +void interrupt_entry(uint32_t mcause); +void exception_entry(uint32_t mcause,uint32_t mepc,uint32_t mtval,uintptr_t *regs); +void bl_irq_init(void); +void _trng_trigger(void); +void wait_trng4feed(void); +void sec_trng_IRQHandler(uint param_1,int param_2); +uint32_t bl_sec_get_random_word(void); +void bl_rand_stream(uint8_t *buf,int len); +int bl_rand(void); +int bl_sec_init(void); +int bl_sec_test(void); +void cmd_gpio_get(char *buf,int len,int argc,char **argv); +void cmd_gpio_set(char *buf,int len,int argc,char **argv); +void cmd_gpio_func(char *buf,int len,int argc,char **argv); +int bl_gpio_cli_init(void); +int bl_efuse_read_mac(uint8_t *mac); +int bl_efuse_read_mac_factory(uint8_t *mac); +int bl_efuse_read_capcode(uint8_t *capcode); +int bl_efuse_read_pwroft(int8_t *poweroffset); +int bl_wifi_clock_enable(void); +int bl_wifi_enable_irq(void); +int bl_wifi_sta_mac_addr_set(uint8_t *mac); +int bl_wifi_ap_mac_addr_set(uint8_t *mac); +int bl_wifi_mac_addr_get(uint8_t *mac); +int bl_wifi_country_code_set(uint8_t country_code); +int bl_wifi_ap_info_set(uint8_t *ssid,uint8_t ssid_len,uint8_t *psk,uint8_t psk_len,uint8_t chan); +int bl_wifi_sta_info_set(uint8_t *ssid,uint8_t ssid_len,uint8_t *psk,uint8_t psk_len,int autoconnect); +int cmd_timer_start(void); +void cmd_wdt_disable(void); +void cmd_wdt_feed(void); +void cmd_wdt_init(int param_1,undefined4 *param_2); +int bl_wdt_cli_init(void); +uint32_t fdt32_to_cpu(fdt32_t x); +int dev_uart_init(uint8_t id,char *path,uint32_t rx_buf_size,uint32_t tx_buf_size); +int32_t hal_uart_send_trigger(uart_dev_t *uart); +int32_t hal_uart_send_trigger_off(uart_dev_t *uart); +int32_t hal_uart_init(uart_dev_t *uart); +int32_t hal_uart_recv_II(uart_dev_t *uart,void *data,uint32_t expect_size,uint32_t *recv_size,uint32_t timeout); +int32_t hal_uart_send(uart_dev_t *uart,void *data,uint32_t size,uint32_t timeout); +int32_t hal_uart_finalize(uart_dev_t *uart); +int32_t hal_uart_notify_register(uart_dev_t *uart,hal_uart_int_t type,anon_subr_void_void_ptr *cb); +undefined4 vfs_uart_init(void *param_1,int param_2); +int32_t hal_uart_send_flush(uart_dev_t *uart,uint32_t timeout); +void hal_uart_setbaud(uart_dev_t *uart,uint32_t baud); +void hal_uart_setconfig(uart_dev_t *uart,uint32_t baud,hal_uart_parity_t parity); +undefined4 hal_gpio_init_from_dts(void *param_1,int param_2); +void _dump_partition(void); +int hal_boot2_update_ptable(HALPartition_Entry_Config *ptEntry_hal); +uint32_t hal_boot2_get_flash_addr(void); +int hal_boot2_partition_bus_addr(char *name,uint32_t *addr0,uint32_t *addr1,uint32_t *size0,uint32_t *size1,int *active); +int hal_boot2_partition_bus_addr_active(char *name,uint32_t *addr,uint32_t *size); +int hal_boot2_partition_bus_addr_inactive(char *name,uint32_t *addr,uint32_t *size); +int hal_boot2_partition_addr(char *name,uint32_t *addr0,uint32_t *addr1,uint32_t *size0,uint32_t *size1,int *active); +int hal_boot2_partition_addr_active(char *name,uint32_t *addr,uint32_t *size); +int hal_boot2_partition_addr_inactive(char *name,uint32_t *addr,uint32_t *size); +uint8_t hal_boot2_get_active_partition(void); +int hal_boot2_get_active_entries(int type,HALPartition_Entry_Config *ptEntry_hal); +int hal_boot2_dump(void); +int hal_boot2_init(void); +int hal_reboot(void); +void hal_sys_reset(void); +void hal_poweroff(void); +void hal_sys_capcode_update(uint8_t capin,uint8_t capout); +uint8_t hal_sys_capcode_get(void); +uint32_t fdt32_to_cpu(fdt32_t x); +uint32_t hal_board_get_factory_addr(void); +undefined4 hal_board_cfg(void); +void bl_tsen_adc_get(void); +uint64_t bl_rtc_get_counter(void); +uint64_t bl_rtc_get_timestamp_ms(void); +int hal_wifi_start_firmware_task(void); +PtTable_Error_Type PtTable_Update_Entry(SPI_Flash_Cfg_Type *pFlashCfg,PtTable_ID_Type targetTableID,PtTable_Stuff_Config *ptStuff,PtTable_Entry_Config *ptEntry); +PtTable_Error_Type PtTable_Get_Active_Entries(PtTable_Stuff_Config *ptStuff,PtTable_Entry_Type type,PtTable_Entry_Config *ptEntry); +void int_timer_cb(void); +uint32_t bl_timer_now_us(void); +int bl_timer_tick_enable(void); +int bl_gpio_enable_output(uint8_t pin,uint8_t pullup,uint8_t pulldown); +int bl_gpio_enable_input(uint8_t pin,uint8_t pullup,uint8_t pulldown); +int bl_gpio_output_set(uint8_t pin,uint8_t value); +int bl_gpio_input_get(uint8_t pin,uint8_t *value); +int bl_flash_erase(uint32_t addr,int len); +int bl_flash_write(uint32_t addr,uint8_t *src,int len); +int bl_flash_read(uint32_t addr,uint8_t *dst,int len); +undefined4 bl_flash_config_update(void); +void * bl_flash_get_flashCfg(void); +void bl_wdt_feed(void); +void bl_wdt_disable(void); +int bl_wdt_init(int ms); +void proc_entry_looprt(void *pvParameters); +void looprt_evt_notify_async(uint task,uint32_t evt_map); +void looprt_evt_status_dump(void); +void looprt_evt_schedule(int task,uint32_t evt_map,int delay_ms); +int looprt_start(StackType_t *proc_stack_looprt,int stack_count,StaticTask_t *proc_task_looprt); +int looprt_start_auto(void); +int looprt_handler_register(loop_evt_handler *handler,int priority); +int looprt_timer_register(loop_timer *timer); +void cmd_looprt_test(char *buf,int len,int argc,char **argv); +void cmd_looprt_test_status(char *buf,int len,int argc,char **argv); +void cmd_looprt_test_evt(char *buf,int len,int argc,char **argv); +void cmd_looprt_test_evt_dump(char *buf,int len,int argc,char **argv); +void cmd_looprt_test_schedule_evt1(char *buf,int len,int argc,char **argv); +void cmd_looprt_test_schedule_evt2(char *buf,int len,int argc,char **argv); +int looprt_test_cli_init(void); +void _cb_led_trigger(loop_ctx *loop,loop_timer *timer,void *arg); +int _led_bloop_msg(loop_ctx *loop,loop_evt_handler *handler,loop_msg *msg); +int _led_bloop_evt(loop_ctx *loop,loop_evt_handler *handler,uint32_t *bitmap_evt,uint32_t *evt_type_map); +int loopset_led_hook_on_looprt(void); +void loopset_led_trigger(int pin,uint timeon_ms); +err_t sys_mbox_new(sys_mbox_t *mbox,int size); +void sys_mbox_free(sys_mbox_t *mbox); +void sys_mbox_post(sys_mbox_t *mbox,void *data); +err_t sys_mbox_trypost(sys_mbox_t *mbox,void *msg); +u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox,void **msg,u32_t timeout); +u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox,void **msg); +uint sys_mbox_valid(int *param_1); +void sys_mbox_set_invalid(undefined4 *param_1); +err_t sys_sem_new(sys_sem_t *sem,u8_t count); +u32_t sys_arch_sem_wait(sys_sem_t *sem,u32_t timeout); +void sys_sem_free(sys_sem_t *sem); +int sys_sem_valid(sys_sem_t *sem); +void sys_sem_set_invalid(sys_sem_t *sem); +void sys_init(void); +err_t sys_mutex_new(sys_mutex_t *mutex); +void sys_mutex_lock(sys_mutex_t *mutex); +void sys_mutex_unlock(sys_mutex_t *mutex); +void sys_sem_signal(sys_mutex_t *mutex); +sys_thread_t sys_thread_new(char *name,lwip_thread_fn *thread,void *arg,int stacksize,int prio); +sys_prot_t sys_arch_protect(void); +void sys_arch_unprotect(void); +TickType_t sys_now(void); +hostent * lwip_gethostbyname(char *name); +err_t netifapi_do_netif_add(tcpip_api_call_data *m); +err_t netifapi_do_netif_set_addr(tcpip_api_call_data *m); +err_t netifapi_do_netif_common(tcpip_api_call_data *m); +err_t netifapi_netif_add(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw,void *state,netif_init_fn init,netif_input_fn *input); +err_t netifapi_netif_set_addr(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw); +err_t netifapi_netif_common(netif *netif,netifapi_void_fn voidfunc,netifapi_errt_fn errtfunc); +int alloc_socket(netconn *newconn,int accepted); +ssize_t lwip_recv_tcp(lwip_sock *sock,void *mem,size_t len,int flags); +int lwip_sock_make_addr(u16_t port,sockaddr *from,socklen_t *fromlen); +void free_socket(lwip_sock *sock,int is_tcp); +err_t lwip_recvfrom_udp_raw(lwip_sock *sock,int flags,msghdr *msg,u16_t *datagram_len); +lwip_sock * get_socket(int fd); +void lwip_setsockopt_callback(void *arg); +void event_callback(netconn *conn,netconn_evt evt,u16_t len); +int lwip_accept(int s,sockaddr *addr,socklen_t *addrlen); +int lwip_bind(int s,sockaddr *name,socklen_t namelen); +int lwip_close(int s); +int lwip_connect(int s,sockaddr *name,socklen_t namelen); +int lwip_listen(int s,int backlog); +ssize_t lwip_recvfrom(int s,void *mem,size_t len,int flags,sockaddr *from,socklen_t *fromlen); +ssize_t lwip_read(int s,void *mem,size_t len); +ssize_t lwip_recv(int s,void *mem,size_t len,int flags); +ssize_t lwip_sendto(int s,void *data,size_t size,int flags,sockaddr *to,socklen_t tolen); +ssize_t lwip_send(int s,void *data,size_t size,int flags); +int lwip_socket(int domain,int type,int protocol); +int lwip_setsockopt(int s,int level,int optname,void *optval,socklen_t optlen); +void tcpip_thread(void *arg); +err_t tcpip_inpkt(pbuf *p,netif *inp,netif_input_fn *input_fn); +err_t tcpip_input(pbuf *p,netif *inp); +err_t tcpip_callback(tcpip_callback_fn function,void *ctx); +err_t tcpip_try_callback(tcpip_callback_fn function,void *ctx); +err_t tcpip_send_msg_wait_sem(tcpip_callback_fn fn,void *apimsg,sys_sem_t *sem); +err_t tcpip_api_call(tcpip_api_call_fn *fn,tcpip_api_call_data *call); +void tcpip_init(tcpip_init_done_fn initfunc,void *arg); +u16_t lwip_htons(u16_t n); +u32_t lwip_htonl(u32_t n); +int lwip_strnicmp(char *str1,char *str2,size_t len); +void dns_call_found(u8_t idx,ip_addr_t *addr); +err_t dns_send(u8_t idx); +void dns_check_entry(u8_t i); +void dns_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port); +void dns_init(void); +void dns_setserver(u8_t numdns,ip_addr_t *dnsserver); +ip_addr_t * dns_getserver(u8_t numdns); +void dns_tmr(void); +err_t dns_gethostbyname_addrtype(char *hostname,ip_addr_t *addr,dns_found_callback *found,void *callback_arg,u8_t dns_addrtype); +err_t dns_gethostbyname(char *hostname,ip_addr_t *addr,dns_found_callback *found,void *callback_arg); +u16_t lwip_standard_chksum(void *dataptr,int len); +u16_t inet_chksum_pseudo(pbuf *p,u8_t proto,u16_t proto_len,ip4_addr_t *src,ip4_addr_t *dest); +u16_t ip_chksum_pseudo(pbuf *p,u8_t proto,u16_t proto_len,ip4_addr_t *src,ip4_addr_t *dest); +u16_t inet_chksum_pseudo_partial(pbuf *p,u8_t proto,u16_t proto_len,u16_t chksum_len,ip4_addr_t *src,ip4_addr_t *dest); +u16_t ip_chksum_pseudo_partial(pbuf *p,u8_t proto,u16_t proto_len,u16_t chksum_len,ip4_addr_t *src,ip4_addr_t *dest); +u16_t inet_chksum(void *dataptr,u16_t len); +u16_t inet_chksum_pbuf(pbuf *p); +u16_t lwip_chksum_copy(void *dst,void *src,u16_t len); +void lwip_init(void); +void dhcp_set_state(dhcp *dhcp,u8_t new_state); +u16_t dhcp_option_short(u16_t options_out_len,u8_t *options,u16_t value); +u16_t dhcp_option_long(u16_t options_out_len,u8_t *options,u32_t value); +pbuf * dhcp_create_msg(netif *netif,dhcp *dhcp,u8_t message_type,u16_t *options_out_len); +void dhcp_option_trailer(u16_t options_out_len,u8_t *options,pbuf *p_out); +err_t dhcp_discover(netif *netif); +void dhcp_check(netif *netif); +void dhcp_bind(netif *netif); +err_t dhcp_inc_pcb_refcount(void); +u16_t dhcp_option_hostname(u16_t options_out_len,u8_t *options); +err_t dhcp_reboot(netif *netif); +err_t dhcp_select(netif *netif); +void dhcp_dec_pcb_refcount(void); +void dhcp_handle_ack(dhcp_msg *msg_in); +void dhcp_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port); +void dhcp_network_changed(netif *netif); +void dhcp_arp_reply(netif *netif,ip4_addr_t *addr); +err_t dhcp_renew(netif *netif); +u8_t dhcp_supplied_address(netif *netif); +void dhcp_release_and_stop(netif *netif); +err_t dhcp_start(netif *netif); +void dhcp_coarse_tmr(void); +void dhcp_fine_tmr(void); +void dhcp_stop(netif *netif); +void etharp_free_entry(int i); +s16_t etharp_find_entry(ip4_addr_t *ipaddr,u8_t flags,netif *netif); +err_t etharp_raw(netif *netif,eth_addr *ethsrc_addr,eth_addr *ethdst_addr,eth_addr *hwsrc_addr,ip4_addr_t *ipsrc_addr,eth_addr *hwdst_addr,ip4_addr_t *ipdst_addr,u16_t opcode); +void etharp_cleanup_netif(netif *netif); +void etharp_input(pbuf *p,netif *netif); +err_t etharp_request(netif *netif,ip4_addr_t *ipaddr); +void etharp_tmr(void); +err_t etharp_output_to_arp_index(netif *netif,pbuf *q,netif_addr_idx_t arp_idx); +err_t etharp_query(netif *netif,ip4_addr_t *ipaddr,pbuf *q); +err_t etharp_output(netif *netif,pbuf *q,ip4_addr_t *ipaddr); +void igmp_send(netif *netif,igmp_group *group,u8_t type); +void igmp_delaying_member(igmp_group *group,u8_t maxresp); +void igmp_init(void); +err_t igmp_stop(netif *netif); +void igmp_report_groups(netif *netif); +igmp_group * igmp_lookfor_group(netif *ifp,ip4_addr_t *addr); +igmp_group * igmp_lookup_group(netif *ifp,ip4_addr_t *addr); +err_t igmp_start(netif *netif); +void igmp_input(pbuf *p,netif *inp,ip4_addr_t *dest); +err_t igmp_joingroup_netif(netif *netif,ip4_addr_t *groupaddr); +err_t igmp_joingroup(ip4_addr_t *ifaddr,ip4_addr_t *groupaddr); +err_t igmp_leavegroup_netif(netif *netif,ip4_addr_t *groupaddr); +err_t igmp_leavegroup(ip4_addr_t *ifaddr,ip4_addr_t *groupaddr); +void igmp_tmr(void); +int ip4_input_accept(netif *netif); +netif * ip4_route(ip4_addr_t *dest); +err_t ip4_input(pbuf *p,netif *inp); +err_t ip4_output_if_opt_src(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto,netif *netif,void *ip_options,u16_t optlen); +err_t ip4_output_if_opt(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto,netif *netif,void *ip_options,u16_t optlen); +err_t ip4_output_if(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto,netif *netif); +err_t ip4_output_if_src(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto,netif *netif); +u8_t ip4_addr_isbroadcast_u32(u32_t addr,netif *netif); +int ip4addr_aton(char *cp,ip4_addr_t *addr); +u32_t ipaddr_addr(char *cp); +char * ip4addr_ntoa_r(ip4_addr_t *addr,char *buf,int buflen); +char * ip4addr_ntoa(ip4_addr_t *addr); +void mem_init(void); +void mem_free(uint param_1); +mem * mem_trim(mem *param_1,uint param_2); +mem_size_t * mem_malloc(uint param_1); +void * mem_calloc(mem_size_t count,mem_size_t size); +void * do_memp_malloc_pool(memp_desc *desc); +void memp_init_pool(memp_desc *desc); +void memp_init(void); +void * memp_malloc(memp_t type); +void memp_free(memp_t type,void *mem); +err_t netif_null_output_ip4(netif *netif,pbuf *p,ip4_addr_t *ipaddr); +void netif_issue_reports(netif *netif,u8_t report_type); +int netif_do_set_ipaddr(netif *netif,ip4_addr_t *ipaddr,ip_addr_t *old_addr); +void netif_init(void); +void netif_set_ipaddr(netif *netif,ip4_addr_t *ipaddr); +void netif_set_netmask(netif *netif,ip4_addr_t *netmask); +void netif_set_gw(netif *netif,ip4_addr_t *gw); +void netif_set_addr(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw); +netif * netif_add(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw,void *state,netif_init_fn.conflict *init,netif_input_fn *input); +void netif_set_default(netif *netif); +void netif_set_up(netif *netif); +void netif_set_down(netif *netif); +void netif_remove(netif *netif); +void netif_set_status_callback(netif *netif,netif_status_callback_fn *status_callback); +void netif_set_link_up(netif *netif); +void netif_set_link_down(netif *netif); +netif * netif_get_by_index(u8_t idx); +netif * netif_find(char *name); +pbuf * pbuf_skip_const(pbuf *in,u16_t in_offset,u16_t *out_offset); +void pbuf_free_ooseq_callback(void *arg); +u8_t pbuf_add_header_impl(pbuf *p,size_t header_size_increment,u8_t force); +pbuf * pbuf_alloc_reference(void *payload,u16_t length,pbuf_type type); +pbuf * pbuf_alloced_custom(pbuf_layer l,u16_t length,pbuf_type type,pbuf_custom *p,void *payload_mem,u16_t payload_mem_len); +u8_t pbuf_add_header(pbuf *p,size_t header_size_increment); +u8_t pbuf_remove_header(pbuf *p,size_t header_size_decrement); +u8_t pbuf_header(pbuf *p,s16_t header_size_increment); +u8_t pbuf_header_force(pbuf *p,s16_t header_size_increment); +u8_t pbuf_free(pbuf *p); +pbuf * pbuf_alloc(pbuf_layer layer,u16_t length,pbuf_type type); +void pbuf_realloc(pbuf *p,u16_t new_len); +pbuf * pbuf_free_header(pbuf *q,u16_t size); +u16_t pbuf_clen(pbuf *p); +void pbuf_ref(pbuf *p); +void pbuf_cat(pbuf *h,pbuf *t); +void pbuf_chain(pbuf *h,pbuf *t); +err_t pbuf_copy(pbuf *p_to,pbuf *p_from); +u16_t pbuf_copy_partial(pbuf *buf,void *dataptr,u16_t len,u16_t offset); +err_t pbuf_take(pbuf *buf,void *dataptr,u16_t len); +err_t pbuf_take_at(pbuf *buf,void *dataptr,u16_t len,u16_t offset); +pbuf * pbuf_clone(pbuf_layer layer,pbuf_type type,pbuf *p); +int pbuf_try_get_at(pbuf *p,u16_t offset); +u8_t pbuf_get_at(pbuf *p,u16_t offset); +void pbuf_put_at(pbuf *p,u16_t offset,u8_t data); +u16_t pbuf_memcmp(pbuf *p,u16_t offset,void *s2,u16_t n); +u16_t pbuf_memfind(pbuf *p,void *mem,u16_t mem_len,u16_t start_offset); +raw_input_state_t raw_input(pbuf *p,netif *inp); +err_t raw_bind(raw_pcb *pcb,ip_addr_t *ipaddr); +void raw_bind_netif(raw_pcb *pcb,netif *netif); +err_t raw_connect(raw_pcb *pcb,ip_addr_t *ipaddr); +void raw_recv(raw_pcb *pcb,raw_recv_fn *recv,void *recv_arg); +err_t raw_sendto_if_src(raw_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,netif *netif,ip_addr_t *src_ip); +err_t raw_sendto(raw_pcb *pcb,pbuf *p,ip_addr_t *ipaddr); +err_t raw_send(raw_pcb *pcb,pbuf *p); +void raw_remove(raw_pcb *pcb); +raw_pcb * raw_new(u8_t proto); +raw_pcb * raw_new_ip_type(u8_t type,u8_t proto); +void raw_netif_ip_addr_changed(ip_addr_t *old_addr,ip_addr_t *new_addr); +void stats_init(void); +u16_t tcp_new_port(void); +err_t tcp_close_shutdown_fin(tcp_pcb *pcb); +void tcp_init(void); +void tcp_free(tcp_pcb *pcb); +err_t tcp_bind(tcp_pcb *pcb,ip_addr_t *ipaddr,u16_t port); +void tcp_bind_netif(tcp_pcb *pcb,netif *netif); +tcp_pcb * tcp_listen_with_backlog_and_err(tcp_pcb *pcb,u8_t backlog,err_t *err); +u32_t tcp_update_rcv_ann_wnd(tcp_pcb *pcb); +void tcp_recved(tcp_pcb *pcb,u16_t len); +void tcp_seg_free(tcp_seg *seg); +void tcp_segs_free(tcp_seg *seg); +void tcp_setprio(tcp_pcb *pcb,u8_t prio); +tcp_seg * tcp_seg_copy(tcp_seg *seg); +void tcp_arg(tcp_pcb *pcb,void *arg); +void tcp_recv(tcp_pcb *pcb,tcp_recv_fn *recv); +void tcp_sent(tcp_pcb *pcb,tcp_sent_fn *sent); +void tcp_err(tcp_pcb *pcb,tcp_err_fn *err); +void tcp_accept(tcp_pcb *pcb,tcp_accept_fn accept); +void tcp_poll(tcp_pcb *pcb,tcp_poll_fn *poll,u8_t interval); +u32_t tcp_next_iss(tcp_pcb *pcb); +u16_t tcp_eff_send_mss_netif(u16_t sendmss,netif *outif,ip_addr_t *dest); +err_t tcp_connect(tcp_pcb *pcb,ip_addr_t *ipaddr,u16_t port,tcp_connected_fn connected); +err_t tcp_tcp_get_tcp_addrinfo(tcp_pcb *pcb,int local,ip_addr_t *addr,u16_t *port); +void tcp_free_ooseq(tcp_pcb *pcb); +void tcp_pcb_purge(tcp_pcb *pcb); +void tcp_pcb_remove(tcp_pcb **pcblist,tcp_pcb *pcb); +void tcp_abandon(tcp_pcb *pcb,int reset); +void tcp_abort(tcp_pcb *pcb); +err_t tcp_accept_null(void *arg,tcp_pcb *pcb,err_t err); +void tcp_netif_ip_addr_changed_pcblist(tcp_pcb *pcb_list); +void tcp_netif_ip_addr_changed(ip_addr_t *old_addr,ip_addr_t *new_addr); +void tcp_kill_state(tcp_state state); +tcp_pcb * tcp_alloc(u8_t prio); +tcp_pcb * tcp_new_ip_type(u8_t type); +err_t tcp_close_shutdown(tcp_pcb *pcb,u8_t rst_on_unacked_data); +err_t tcp_close(tcp_pcb *pcb); +err_t tcp_recv_null(void *arg,tcp_pcb *pcb,pbuf *p,err_t err); +err_t tcp_process_refused_data(tcp_pcb *pcb); +void tcp_fasttmr(void); +err_t tcp_shutdown(tcp_pcb *pcb,int shut_rx,int shut_tx); +void tcp_slowtmr(void); +void tcp_tmr(void); +u8_t tcp_get_next_optbyte(void); +void tcp_oos_insert_segment(tcp_seg *cseg,tcp_seg *next); +void tcp_parseopt(undefined2 *param_1); +int tcp_input_delayed_close(tcp_pcb *pcb); +tcp_seg * tcp_free_acked_segments(tcp_seg *seg_list); +void tcp_receive(tcp_pcb *pcb); +void tcp_input(pbuf *p,netif *inp); +void tcp_trigger_input_pcb_close(void); +void tcp_seg_add_chksum(u16_t chksum,u16_t len,u16_t *seg_chksum,u8_t *seg_chksum_swapped); +tcp_seg * tcp_create_segment(tcp_pcb *pcb,pbuf *p,u8_t hdrflags,u32_t seqno,u8_t optflags); +pbuf * tcp_output_alloc_header_common(u32_t ackno,u16_t datalen,u32_t seqno_be,u16_t src_port,u16_t dst_port,u8_t flags,u16_t wnd); +pbuf * tcp_output_alloc_header(tcp_pcb *pcb,u16_t datalen,u32_t seqno_be); +err_t tcp_output_control_segment(tcp_pcb *pcb,pbuf *p,ip_addr_t *src,ip_addr_t *dst); +err_t tcp_write(tcp_pcb *pcb,void *arg,u16_t len,u8_t apiflags); +err_t tcp_split_unsent_seg(tcp_pcb *pcb,u16_t split); +err_t tcp_enqueue_flags(tcp_pcb *pcb,u8_t flags); +err_t tcp_send_fin(tcp_pcb *pcb); +err_t tcp_rexmit_rto_prepare(tcp_pcb *pcb); +err_t tcp_rexmit(tcp_pcb *pcb); +void tcp_rexmit_fast(tcp_pcb *pcb); +void tcp_rst(tcp_pcb *pcb,u32_t seqno,u32_t ackno,ip_addr_t *param_4,ip_addr_t *remote_ip,u16_t param_6,u16_t remote_port); +err_t tcp_send_empty_ack(tcp_pcb *pcb); +err_t tcp_output(tcp_pcb *pcb); +void tcp_rexmit_rto_commit(tcp_pcb *pcb); +void tcp_rexmit_rto(tcp_pcb *pcb); +err_t tcp_keepalive(tcp_pcb *pcb); +err_t tcp_zero_window_probe(tcp_pcb *pcb); +void sys_timeout_abs(u32_t abs_time,sys_timeout_handler *handler,void *arg); +void lwip_cyclic_timer(void *arg); +void sys_timeout(u32_t msecs,sys_timeout_handler *handler,void *arg); +void tcp_timer_needed(void); +void tcpip_tcp_timer(void *arg); +void sys_timeouts_init(void); +void sys_untimeout(sys_timeout_handler *handler,void *arg); +void sys_check_timeouts(void); +u32_t sys_timeouts_sleeptime(void); +void udp_init(void); +void udp_input(pbuf *p,netif *inp); +err_t udp_bind(udp_pcb *pcb,ip_addr_t *ipaddr,u16_t port); +err_t udp_sendto_if_src_chksum(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif,u8_t have_chksum,u16_t chksum,ip_addr_t *src_ip); +err_t udp_sendto_if_chksum(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif,u8_t have_chksum,u16_t chksum); +err_t udp_sendto_chksum(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,u8_t have_chksum,u16_t chksum); +err_t udp_send_chksum(udp_pcb *pcb,pbuf *p,u8_t have_chksum,u16_t chksum); +err_t udp_sendto(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port); +err_t udp_send(udp_pcb *pcb,pbuf *p); +err_t udp_sendto_if(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif); +err_t udp_sendto_if_src(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif,ip_addr_t *src_ip); +void udp_bind_netif(udp_pcb *pcb,netif *netif); +err_t udp_connect(udp_pcb *pcb,ip_addr_t *ipaddr,u16_t port); +void udp_disconnect(udp_pcb *pcb); +void udp_recv(udp_pcb *pcb,udp_recv_fn *recv,void *recv_arg); +void udp_remove(udp_pcb *pcb); +udp_pcb * udp_new(void); +udp_pcb * udp_new_ip_type(void); +void udp_netif_ip_addr_changed(ip_addr_t *old_addr,ip_addr_t *new_addr); +err_t ethernet_input(pbuf *p,netif *netif); +err_t ethernet_output(netif *netif,pbuf *p,eth_addr *src,eth_addr *dst,u16_t eth_type); +err_t netconn_apimsg(tcpip_callback_fn.conflict *fn,api_msg *apimsg); +err_t netconn_close_shutdown(netconn *conn,u8_t how); +netconn * netconn_new_with_proto_and_callback(netconn_type t,u8_t proto,netconn_callback *callback); +err_t netconn_prepare_delete(netconn *conn); +err_t netconn_delete(netconn *conn); +err_t netconn_getaddr(netconn *conn,ip_addr_t *addr,u16_t *port,u8_t local); +err_t netconn_bind(netconn *conn,ip_addr_t *addr,u16_t port); +err_t netconn_connect(netconn *conn,ip_addr_t *addr,u16_t port); +err_t netconn_disconnect(netconn *conn); +err_t netconn_listen_with_backlog(netconn *conn,u8_t backlog); +err_t netconn_tcp_recvd(netconn *conn,size_t len); +err_t netconn_send(netconn *conn,netbuf *buf); +err_t netconn_write_vectors_partly(netconn *conn,netvector *vectors,u16_t vectorcnt,u8_t apiflags,size_t *bytes_written); +err_t netconn_write_partly(netconn *conn,void *dataptr,size_t size,u8_t apiflags,size_t *bytes_written); +err_t netconn_err(netconn *conn); +err_t netconn_accept(netconn *conn,netconn **new_conn); +err_t netconn_recv_data(netconn *conn,void **new_buf,u8_t apiflags); +err_t netconn_recv_udp_raw_netbuf_flags(netconn *conn,netbuf **new_buf,u8_t apiflags); +err_t netconn_recv_data_tcp(netconn *conn,pbuf **new_buf,u8_t apiflags); +err_t netconn_recv_tcp_pbuf_flags(netconn *conn,pbuf **new_buf,u8_t apiflags); +err_t netconn_join_leave_group(netconn *conn,ip_addr_t *multiaddr,ip_addr_t *netif_addr,netconn_igmp join_or_leave); +err_t netconn_gethostbyname(char *name,ip_addr_t *addr); +void lwip_netconn_do_dns_found(char *name,ip_addr_t *ipaddr,void *arg); +void recv_udp(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port); +void setup_tcp(netconn *conn); +err_t lwip_netconn_do_connected(void *arg,tcp_pcb *pcb,err_t err); +void err_tcp(void *arg,err_t err); +err_t lwip_netconn_do_writemore(netconn *conn); +err_t lwip_netconn_do_close_internal(netconn *conn); +err_t poll_tcp(void *arg,tcp_pcb *pcb); +u8_t recv_raw(void *arg,raw_pcb *pcb,pbuf *p,ip_addr_t *addr); +err_t sent_tcp(void *arg,tcp_pcb *pcb,u16_t len); +err_t recv_tcp(void *arg,tcp_pcb *pcb,pbuf *p,err_t err); +int lwip_netconn_is_err_msg(void *msg,err_t *err); +void lwip_netconn_do_newconn(void *m); +netconn * netconn_alloc(netconn_type t,netconn_callback *callback); +void netconn_free(netconn *conn); +void netconn_drain(netconn *conn); +err_t accept_function(void *arg,tcp_pcb *newpcb,err_t err); +void lwip_netconn_do_delconn(void *m); +void lwip_netconn_do_bind(void *m); +void lwip_netconn_do_connect(void *m); +void lwip_netconn_do_disconnect(void *m); +void lwip_netconn_do_listen(void *m); +void lwip_netconn_do_send(void *m); +void lwip_netconn_do_recv(void *m); +void lwip_netconn_do_write(void *m); +void lwip_netconn_do_getaddr(void *m); +void lwip_netconn_do_close(void *m); +void lwip_netconn_do_join_leave_group(void *m); +void lwip_netconn_do_gethostbyname(void *arg); +int err_to_errno(err_t err); +void netbuf_delete(netbuf *buf); +void * netbuf_alloc(netbuf *buf,u16_t size); +void netbuf_free(netbuf *buf); +void icmp_input(pbuf *p,netif *inp); +void icmp_dest_unreach(pbuf *p,icmp_dur_type t); +u8_t * dhcp_server_option_find(u8_t *buf,u16_t len,u8_t option); +dhcp_client_node * dhcp_client_find_by_ip(uint8_t *ip); +void dhcp_server_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *recv_addr,u16_t port); +err_t dhcp_server_start(netif *netif,ip4_addr_t *start,ip4_addr_t *end); +err_t dhcp_server_stop(netif *netif); +void dhcpd_start(netif *netif); +void iperf_server_udp_entry(char *name); +void iperf_client_udp_entry(char *name); +void iperf_server_entry(char *name); +void iperf_client_tcp_entry(char *name); +void iperf_server_udp(void *arg); +void iperf_server_udp_recv_fn(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port); +void iperf_client_udp(void *arg); +void iperf_server(void *arg); +void iperf_client_tcp(void *arg); +void ipus_test_cmd(char *buf,int len,int argc,char **argv); +void ipu_test_cmd(char *buf,int len,int argc,char **argv); +void ipc_test_cmd(char *buf,int len,int argc,char **argv); +void ips_test_cmd(char *buf,int len,int argc,char **argv); +int network_netutils_iperf_cli_register(void); +int dirent_type(void *addr); +uint32_t dirent_hardfh(void *addr); +uint32_t dirent_childaddr(void *addr); +uint32_t dirent_size(void *addr); +int romfs_close(file_t *fp); +int romfs_ioctl(file_t *fp,int cmd,ulong arg); +ssize_t romfs_read(file_t *fp,char *buf,size_t length); +undefined4 file_info(char *param_1,char **param_2,char **param_3); +int romfs_closedir(file_t *fp,aos_dir_t *dir); +off_t romfs_lseek(file_t *fp,off_t off,int whence); +aos_dirent_t * romfs_readdir(file_t *fp,aos_dir_t *dir); +uint32_t dirent_file(char *path,void **p_addr_start_input,void **p_addr_end_input); +aos_dir_t * romfs_opendir(file_t *fp,char *path); +int romfs_stat(file_t *fp,char *path,stat *st); +int romfs_open(file_t *fp,char *path,int flags); +int romfs_register(void); +void _startup_sntp(void *arg); +void cmd_sntp_date(char *buf,int len,int argc,char **argv); +void cmd_sntp_time(char *buf,int len,int argc,char **argv); +void cmd_sntp_start(char *buf,int len,int argc,char **argv); +int sntp_cli_init(void); +void sntp_retry(void *arg); +void sntp_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port); +void sntp_send_request(ip_addr_t *server_addr); +void sntp_request(void *arg); +void sntp_dns_found(char *hostname,ip_addr_t *ipaddr,void *arg); +void sntp_init(void); +void sntp_setoperatingmode(u8_t operating_mode); +int sntp_get_time(uint32_t *seconds,uint32_t *frags); +void sntp_setservername(u8_t idx,char *server); +void utils_sha256_init(iot_sha256_context *ctx); +void utils_sha256_free(iot_sha256_context *ctx); +void utils_sha256_starts(iot_sha256_context *ctx); +void utils_sha256_process(iot_sha256_context *ctx,uchar *data); +void utils_sha256_update(iot_sha256_context *ctx,uchar *input,uint32_t ilen); +void utils_sha256_update(iot_sha256_context *ctx,uchar *input,uint32_t ilen); +void utils_sha256_finish(iot_sha256_context *ctx,uint8_t *output); +void bl_printk(char *format,...); +int log_buf_out(char *file,int line,void *inbuf,int len,LOG_BUF_OUT_DATA_TYPE_T type); +int utils_dns_domain_get(uint8_t *records,uint8_t *buf,int *len); +void utils_list_init(utils_list *list); +void utils_list_push_back(utils_list *list,utils_list_hdr *list_hdr); +utils_list_hdr * utils_list_pop_front(utils_list *list); +void utils_hexdump(void *mem,uint len); +undefined4 utils_time_date_from_epoch(uint param_1,undefined *param_2); +int utils_getopt_init(getopt_env_t *env,int opterr); +int utils_getopt(getopt_env_t *env,int argc,char **argv,char *optstring); +int params_filter(uint32_t *r); +void get_bytearray_from_string(char **params,uint8_t *result,int array_size); +void get_uint8_from_string(char **params,uint8_t *result); +void get_uint16_from_string(char **params,uint16_t *result); +void Bl_F_fast(uchar *digest,uchar *digest1,char *password,uchar *ssid,int ssidlength,int count,uchar *output); +int utils_wifi_psk_cal_fast_bin(char *password,uchar *ssid,int ssidlength,uchar *output); +int utils_tlv_bl_pack_auto(uint32_t *buf,int buf_sz,uint16_t type,void *arg1); +int utils_tlv_bl_unpack_auto(uint32_t *buf,int buf_sz,uint16_t type,void *arg1); +void utils_hmac_sha1_fast(uchar **ppText,int *pTextLen,int textNum,uchar *key,int key_len,uchar *output,int outputLen); +int vfs_init(void); +int aos_open(char *path,int flags); +int aos_close(int fd); +ssize_t aos_read(int fd,void *buf,size_t nbytes); +ssize_t aos_write(int fd,void *buf,size_t nbytes); +int aos_ioctl(int fd,int cmd,ulong arg); +int aos_stat(char *path,stat *st); +aos_dir_t * aos_opendir(char *path); +int aos_closedir(aos_dir_t *dir); +aos_dirent_t * aos_readdir(aos_dir_t *dir); +file_t * new_file(inode_t *node); +void del_file(file_t *file); +int get_fd(file_t *file); +file_t * get_file(int fd); +int inode_init(void); +int inode_alloc(void); +inode_t * inode_open(char *path); +int inode_forearch_name(anon_subr_int_void_ptr_inode_t_ptr *cb,void *arg); +void inode_ref(inode_t *node); +void inode_unref(inode_t *node); +int inode_reserve(char *path,inode_t **inode); +int aos_register_driver(char *path,file_ops_t *ops,void *arg); +int aos_register_fs(char *path,fs_ops_t *ops,void *arg); +int vfs_uart_open(inode_t *inode,file_t *fp); +void __uart_rx_irq(void *p_arg); +void __uart_tx_irq(void *p_arg); +int vfs_uart_close(file_t *fp); +ssize_t vfs_uart_read(file_t *fp,void *buf,size_t nbytes); +ssize_t vfs_uart_write(file_t *fp,void *buf,size_t nbytes); +int vfs_uart_poll(file_t *fp,_Bool setup,poll_notify_t *notify,pollfd *fd,void *opa); +int vfs_uart_sync(file_t *fp); +int uart_ioctl_cmd_waimode(uart_dev_t *uart_dev,int cmd,ulong arg); +int uart_ioctl_cmd_setconfig(uart_dev_t *uart_dev,ulong arg); +int vfs_uart_ioctl(file_t *fp,int cmd,ulong arg); +yloop_ctx_t * get_context(void); +void aos_loop_set_eventfd(int fd); +aos_loop_t aos_loop_init(void); +int aos_poll_read_fd(int sock,aos_poll_call_t *cb,void *private_data); +int aos_post_delayed_action(int ms,aos_call_t *action,void *param); +void aos_loop_run(yloop_sock_t *param_1); +void vfs_poll_notify(pollfd *fd,void *arg); +int aos_poll(pollfd *fds,int nfds,int timeout); +int aos_fcntl(int fd,int cmd,int val); +void dfl_entry(void *arg); +int aos_task_new(char *name,anon_subr_void_void_ptr *fn,void *arg,int stack_size); +void aos_task_exit(int code); +int aos_task_key_create(aos_task_key_t *key); +int aos_task_setspecific(aos_task_key_t key,void *vp); +void * aos_task_getspecific(aos_task_key_t key); +int aos_mutex_new(aos_mutex_t *mutex); +void aos_mutex_free(aos_mutex_t *mutex); +int aos_mutex_lock(aos_mutex_t *mutex,uint ms); +int aos_mutex_unlock(aos_mutex_t *mutex); +int aos_sem_new(aos_sem_t *sem,int count); +void aos_sem_free(aos_sem_t *sem); +int aos_sem_wait(aos_sem_t *sem,uint ms); +void aos_sem_signal(aos_sem_t *sem); +void * aos_malloc(size_t xWantedSize); +void free(void *pv); +void aos_free(void *pv); +void * malloc(size_t xWantedSize); +longlong aos_now_ms(void); +int event_poll(file_t *f,_Bool setup,poll_notify_t *notify,pollfd *fd,void *opa); +int event_open(inode_t *node,file_t *file); +ssize_t _event_write(void *buf,size_t len,_Bool urgent); +int event_ioctl(file_t *f,int cmd,ulong arg); +ssize_t event_write(file_t *f,void *buf,size_t len); +int event_close(file_t *file); +ssize_t event_read(file_t *f,void *buf,size_t len); +int vfs_device_init(void); +void event_read_cb(int fd,void *param); +int aos_event_service_init(void); +int aos_post_event(uint16_t type,uint16_t code,ulong value); +int aos_register_event_filter(uint16_t type,aos_event_cb *cb,void *priv); +int at_serial_write(uchar *buf,int len); +int at_serial_read(uchar *buf,int size); +void at_cmd_exec(void *param); +int at_serial_cfg_set(uint32_t baud,uint8_t data_bit,uint8_t stop_bit,uint8_t parity,uint8_t hwfc); +int at_serial_open(void); +int at_serial_lock(void); +int at_serial_unlock(void); +int at_data_output(char *buf,int size); +int at_key_value_set(char *key,void *p_value); +int at_key_value_get(char *key,void *p_value); +s32 at_dump_noend(char *format,...); +void at_async_event(void *param); +void at_cmd_init(void); +int at_server_init(void); +int at_server_notify_with_ctx(at_evt_t event,void *p_ctx,uint32_t ctx_size); +int at_server_notify(at_evt_t event); +AT_ERROR_CODE cipsta_ip_get(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE version(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE cipsta_ip(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE http_url_req(at_callback_para_t *para,at_callback_rsp_t *rsp); +err_t cb_altcp_recv_fn(void *arg,altcp_pcb *conn,pbuf *p,err_t err); +void cb_httpc_result(void *arg,httpc_result_t httpc_result,u32_t rx_content_len,u32_t srv_res,err_t err); +AT_ERROR_CODE ap_sta_get(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE cwmode_cur_get(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE uart_get(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE cwqap(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE cwjap_info(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE deep_sleep(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE restory(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE scan(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE reset(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE ble_sync(at_callback_para_t *para,at_callback_rsp_t *rsp); +err_t cb_httpc_headers_done_fn(httpc_state_t *connection,void *arg,pbuf *hdr,u16_t hdr_len,u32_t content_len); +AT_ERROR_CODE __wifimode_set(int mode); +AT_ERROR_CODE set_apcfg(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE cwjap_cur(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE cwmode_cur(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE uart_set(at_callback_para_t *para,at_callback_rsp_t *rsp); +u32 at_get_errorcode(void); +int at_cmd_impl_init(void); +AT_ERROR_CODE callback(AT_CALLBACK_CMD cmd,at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE wifi_supports(at_para_t *at_para); +AT_ERROR_CODE attention_handler(at_para_t *at_para); +AT_ERROR_CODE wifi_mode_handler(at_para_t *at_para); +AT_ERROR_CODE http_req(at_para_t *at_para); +AT_ERROR_CODE domain_name_resolution(at_para_t *at_para); +AT_ERROR_CODE base_station_info(at_para_t *at_para); +AT_ERROR_CODE deep_sleep_handler(at_para_t *at_para); +AT_ERROR_CODE setautoconnect_handler(at_para_t *at_para); +AT_ERROR_CODE scan_handler_opt(at_para_t *at_para); +AT_ERROR_CODE scan_handler(at_para_t *at_para); +AT_ERROR_CODE uart_config_handler(at_para_t *at_para); +AT_ERROR_CODE reset_handler(at_para_t *at_para); +AT_ERROR_CODE echo_on_handler(at_para_t *at_para); +AT_ERROR_CODE disconnect_handler(at_para_t *at_para); +AT_ERROR_CODE restore_handler(at_para_t *at_para); +AT_ERROR_CODE version_handler(at_para_t *at_para); +AT_ERROR_CODE at_help(void); +AT_ERROR_CODE help_handler(at_para_t *at_para); +AT_ERROR_CODE at_init(at_callback_t *cb); +AT_ERROR_CODE at_command_register(at_command_handler_t *cmd,uint32_t cmd_cnt); +AT_ERROR_CODE at_parse(void); +AT_ERROR_CODE at_callback_do(AT_CALLBACK_CMD cmd,at_callback_para_t *para); +AT_ERROR_CODE ble_sync_mode(at_para_t *at_para); +AT_ERROR_CODE set_ip_handler(at_para_t *at_para); +AT_ERROR_CODE at_get_ssid_psk(char **ppara,char *ssid,char *pwd); +AT_ERROR_CODE ap_cfg_handler(at_para_t *at_para); +AT_ERROR_CODE join_ap_handler(at_para_t *at_para); +void at_response(AT_ERROR_CODE aec); +AT_ERROR_CODE at_reset(void); +AT_ERROR_CODE at_version(char *version); +AT_ERROR_CODE at_restore(char *address); +AT_ERROR_CODE at_uart_config_get(void); +AT_ERROR_CODE at_uart_config(int uartId,int uartBaud,int dataBit,int parity,int stopBit,int hwfc); +AT_ERROR_CODE at_deep_sleep_mode(uint32_t sleep_time,int weakup_pin); +AT_ERROR_CODE at_wifi_mode(int wifiMode); +AT_ERROR_CODE at_wifi_mode_get(void); +AT_ERROR_CODE at_get_apinfo(void); +AT_ERROR_CODE at_join_ap(char *ssid,char *pwd); +AT_ERROR_CODE at_disconnect(char *at_para); +AT_ERROR_CODE at_set_ap(char *ssid,char *psk,char chl,int max_conn); +AT_ERROR_CODE at_ap_sta_get(void); +AT_ERROR_CODE at_http_request(char *url,uint8_t type,uint8_t content_type,uint8_t *data,at_callback_rsp_t *req_rsp); +u32 get_text_para(char **ppara,void *pvar,u32 opt); +u32 get_tdata_para(char **ppara,void *pvar,u32 opt); +u32 get_di_para(char **ppara,void *pvar,u32 opt); +u32 get_ip_para(char **ppara,void *pvar,u32 opt); +int hex_to_num(char ch); +u32 get_hex_para(char **ppara,void *pvar,u32 opt); +u32 get_hi_para(char **ppara,void *pvar,u32 opt); +AT_ERROR_CODE at_get_newline(char *para,s32 size); +AT_ERROR_CODE at_get_parameters(char **ppara,at_para_descriptor_t *list,s32 lsize,s32 *pcnt); +s32 at_queue_init(void *buf,s32 size,at_queue_callback_t *cb); +AT_QUEUE_ERROR_CODE at_queue_get(u8 *element); +AT_QUEUE_ERROR_CODE at_queue_peek(u8 *element); +AT_ERROR_CODE create_tcp_udp_handler(at_para_t *at_para); +AT_ERROR_CODE close_network_handler(at_para_t *at_para); +AT_ERROR_CODE send_data_handler(at_para_t *at_para); +AT_ERROR_CODE ap_server_handler(at_para_t *at_para); +AT_ERROR_CODE client_ssl_config_path(at_para_t *at_para); +AT_ERROR_CODE client_ssl_set_sni(at_para_t *at_para); +AT_ERROR_CODE client_ssl_set_alpn(at_para_t *at_para); +AT_ERROR_CODE at_scan(char *mode,char *repeat); +err_t tcp_sent_callback(void *arg,altcp_pcb *conn,u16_t len); +err_t tcp_connected_callback(void *arg,altcp_pcb *conn,err_t err); +err_t tcp_receive_callback(void *arg,altcp_pcb *conn,pbuf *p,err_t err); +int get_romfs_file_content(char *path,romfs_filebuf_t *buf); +void udp_send_data(void *arg); +void tcp_err_callback(void *arg,err_t err); +void udp_receive_callback(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port); +err_t tcp_accept_callback(void *arg,altcp_pcb *new_conn,err_t err); +void tcp_send_data(void *arg); +AT_ERROR_CODE bl_cipstatus(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE bl_cipstart(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE bl_cipsendbuf(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE bl_cipclose(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE bl_tcpserver(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE bl_cipsend(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE bl_cipsslcconf_path(at_callback_para_t *para,at_callback_rsp_t *unused); +AT_ERROR_CODE bl_cipsslcsni(at_callback_para_t *para,at_callback_rsp_t *rsp); +AT_ERROR_CODE bl_cipsslcalpn(at_callback_para_t *para,at_callback_rsp_t *unused); +size_t format_int(char *q,size_t n,uint flags,int base,int width,int prec); +char * cvt(int ndigits,int *decpt,int *sign,char *buf,int eflag); +char * ecvtbuf(int ndigits,int *decpt,int *sign,char *buf); +char * fcvtbuf(int ndigits,int *decpt,int *sign,char *buf); +char * flt(char *str,int size,int precision,char fmt,int flags); +int vsnprintf(char *buffer,size_t n,char *format,va_list ap); +int vsprintf(char *buffer,char *format,va_list ap); +void vprint(char *fmt,va_list argp); +int bl_putchar(int c); +int puts(char *s); +int printf(char *fmt,...); +int sprintf(char *buffer,char *format,...); +int snprintf(char *buffer,size_t n,char *format,...); +int sscanf(char *str,char *format,...); +void set_bit(ulong *bitmap,uint bit); +int vsscanf(char *buffer,char *format,va_list ap); +uintmax_t strntoumax(char *nptr,char **endptr,int base,size_t n); +BL_Err_Type UART_Init(UART_ID_Type uartId,UART_CFG_Type *uartCfg); +BL_Err_Type UART_FifoConfig(UART_ID_Type uartId,UART_FifoCfg_Type *fifoCfg); +BL_Err_Type UART_Enable(UART_ID_Type uartId,UART_Direction_Type direct); +BL_Err_Type UART_Disable(UART_ID_Type uartId,UART_Direction_Type direct); +BL_Err_Type UART_SetRxTimeoutValue(UART_ID_Type uartId,uint8_t time); +BL_Err_Type UART_TxFreeRun(UART_ID_Type uartId,BL_Fun_Type txFreeRun); +BL_Err_Type UART_IntMask(UART_ID_Type uartId,UART_INT_Type intType,BL_Mask_Type intMask); +uint8_t UART_GetTxFifoCount(UART_ID_Type uartId); +BL_Err_Type UART_SendData(UART_ID_Type uartId,uint8_t *data,uint32_t len); +uint8_t UART_GetRxFifoCount(UART_ID_Type uartId); +void ADC_Reset(void); +void ADC_Enable(void); +void ADC_Disable(void); +void ADC_Channel_Config(ADC_Chan_Type posCh,ADC_Chan_Type negCh,BL_Fun_Type contEn); +void ADC_Start(void); +void ADC_FIFO_Cfg(ADC_FIFO_Cfg_Type *fifoCfg); +uint8_t ADC_Get_FIFO_Count(void); +void ADC_Parse_Result(uint32_t *orgVal,uint32_t len,ADC_Result_Type *result); +void ADC_Tsen_Init(ADC_TSEN_MOD_Type tsenMod); +void ADC_SET_TSVBE_LOW(void); +void ADC_SET_TSVBE_HIGH(void); +uint32_t TSEN_Get_V_Error(void); +float TSEN_Get_Temp(uint32_t tsen_offset); +void ADC_Init(ADC_CFG_Type *cfg); +BL_Err_Type Sec_Eng_SHA256_Update(SEC_Eng_SHA256_Ctx *shaCtx,uint8_t *input,uint32_t len); +void Sec_Eng_SHA256_Init(SEC_Eng_SHA256_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,SEC_ENG_SHA_Type shaType,uint32_t *shaTmpBuf,uint32_t *padding); +void Sec_Eng_SHA_Start(SEC_ENG_SHA_ID_Type shaNo); +BL_Err_Type Sec_Eng_SHA256_Update(SEC_Eng_SHA256_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,uint8_t *input,uint32_t len); +BL_Err_Type Sec_Eng_SHA256_Finish(SEC_Eng_SHA256_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,uint8_t *hash); +void DMA_Enable(void); +void DMA_Channel_Enable(uint8_t ch); +void DMA_LLI_Init(uint8_t ch,DMA_LLI_Cfg_Type *lliCfg); +void DMA_LLI_Update(uint8_t ch,uint32_t LLI); +void DMA_IntMask(uint8_t ch,DMA_INT_Type intType,BL_Mask_Type intMask); +void Default_Handler(void); +BL_Err_Type GLB_Set_UART_CLK(uint8_t enable,HBN_UART_CLK_Type clkSel,uint8_t div); +BL_Err_Type GLB_Set_EM_Sel(GLB_EM_Type emType); +BL_Err_Type GLB_Set_ADC_CLK(uint8_t enable,GLB_ADC_CLK_Type clkSel,uint8_t div); +BL_Err_Type GLB_UART_Fun_Sel(GLB_UART_SIG_Type sig,GLB_UART_SIG_FUN_Type fun); +BL_Err_Type GLB_GPIO_Write(GLB_GPIO_Type gpioPin,uint32_t val); +uint32_t GLB_GPIO_Read(GLB_GPIO_Type gpioPin); +BL_Err_Type HBN_Set_UART_CLK_Sel(HBN_UART_CLK_Type clkSel); +BL_Err_Type HBN_Get_RTC_Timer_Val(uint32_t *valLow,uint32_t *valHigh); +BL_Err_Type HBN_Clear_IRQ(HBN_INT_Type irqType); +BL_Err_Type HBN_Aon_Pad_IeSmt_Cfg(uint8_t padCfg); +void TIMER_SetCompValue(TIMER_Chan_Type timerCh,TIMER_Comp_ID_Type cmpNo,uint32_t val); +void TIMER_SetCountMode(TIMER_Chan_Type timerCh,TIMER_CountMode_Type countMode); +void TIMER_ClearIntStatus(TIMER_Chan_Type timerCh,TIMER_Comp_ID_Type cmpNo); +BL_Err_Type TIMER_Init(TIMER_CFG_Type *timerCfg); +void TIMER_Enable(TIMER_Chan_Type timerCh); +void TIMER_Disable(TIMER_Chan_Type timerCh); +void TIMER_IntMask(TIMER_Chan_Type timerCh,TIMER_INT_Type intType,BL_Mask_Type intMask); +void WDT_Set_Clock(TIMER_ClkSrc_Type clkSrc,uint8_t div); +void WDT_SetCompValue(uint16_t val); +void WDT_ResetCounterValue(void); +void WDT_Enable(void); +void WDT_Disable(void); +void WDT_IntMask(WDT_INT_Type intType,BL_Mask_Type intMask); +uint32_t EF_Ctrl_Get_Byte_Zero_Cnt(uint8_t val); +BL_Err_Type EF_Ctrl_Read_MAC_Address(uint8_t *mac); +uint8_t EF_Ctrl_Is_MAC_Address_Slot_Empty(uint8_t slot,uint8_t reload); +BL_Err_Type EF_Ctrl_Read_MAC_Address_Opt(uint8_t slot,uint8_t *mac,uint8_t reload); +uint EF_Ctrl_Is_CapCode_Slot_Empty(int param_1,int param_2); +BL_Err_Type EF_Ctrl_Read_CapCode_Opt(uint8_t slot,uint8_t *code,uint8_t reload); +uint8_t EF_Ctrl_Is_PowerOffset_Slot_Empty(uint8_t slot,uint8_t reload); +BL_Err_Type EF_Ctrl_Read_PowerOffset_Opt(uint8_t slot,int8_t *pwrOffset,uint8_t reload); +int8_t mfg_media_read_xtal_capcode(uint8_t *capcode,uint8_t reload); +int8_t mfg_media_read_poweroffset(int8_t *pwrOffset,uint8_t reload); +int8_t mfg_media_read_macaddr(uint8_t *mac,uint8_t reload); +void bflb_platform_usart_dbg_send(uint8_t *data,uint32_t len); +void bflb_platform_printf(char *fmt,...); +void Default_Handler_Stub(void); +int8_t mfg_efuse_read_xtal_capcode(uint8_t *capcode,uint8_t reload); +int8_t mfg_efuse_read_poweroffset(int8_t *pwrOffset,uint8_t reload); +int8_t mfg_efuse_read_macaddr(uint8_t *mac,uint8_t reload); +int8_t mfg_flash_read_xtal_capcode(uint8_t *capcode,uint8_t reload); +int8_t mfg_flash_read_poweroffset(int8_t *pwrOffset,uint8_t reload); +int8_t mfg_flash_read_macaddr(uint8_t *mac,uint8_t reload); +int bt_hcionchip_recv(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +uint8_t bt_onchiphci_interface_init(bt_hci_recv_cb *cb); +uint bt_onchiphci_hanlde_rx_acl(int param_1,void *param_2); +int bl_mtd_open(char *name,bl_mtd_handle_t *handle,uint flags); +int bl_mtd_close(bl_mtd_handle_t handle); +int bl_mtd_info(bl_mtd_handle_t handle,bl_mtd_info_t *info); +int bl_mtd_erase(bl_mtd_handle_t handle,uint addr,uint size); +int bl_mtd_erase_all(bl_mtd_handle_t handle); +int bl_mtd_write(bl_mtd_handle_t handle,uint addr,uint size,uint8_t *data); +int bl_mtd_read(bl_mtd_handle_t handle,uint addr,uint size,uint8_t *data); +int bloop_init(loop_ctx *loop); +int bloop_handler_register(loop_ctx *loop,loop_evt_handler *handler,int priority); +void bloop_timer_init(loop_timer *timer,int use_auto_free); +void bloop_timer_configure(loop_timer *timer,uint delay_ms,anon_subr_void_loop_ctx_ptr_loop_timer_ptr_void_ptr *cb,void *arg,int idx_task,uint32_t evt_type_map); +void bloop_timer_repeat_enable(loop_timer *timer); +void bloop_timer_repeat_reconfigure(loop_timer *timer); +void bloop_timer_register(loop_ctx *loop,loop_timer *timer); +void bloop_wait_startup(loop_ctx *loop); +void bloop_evt_set_async(loop_ctx *loop,uint evt,uint32_t evt_map); +void bloop_evt_set_sync(loop_ctx *loop,uint evt,uint32_t evt_map); +void bloop_evt_unset_sync(loop_ctx *loop,uint evt); +void bloop_run(loop_ctx *param_1); +int bloop_status_dump(loop_ctx *loop); +int loop_evt_entity_sys_handler(loop_ctx *loop,loop_evt_handler *handler,loop_msg *msg); +int loop_evt_entity_sys_evt(loop_ctx *loop,loop_evt_handler *handler,uint32_t *bitmap_evt,uint32_t *evt_type_map); +void get_f32_reg(void); +void put_f32_reg(void); +int backtrace_riscv(anon_subr_int_char_ptr *print_func,uintptr_t *regs); +int bl_sha_mutex_take(void); +int bl_sha_mutex_give(void); +void bl_sha_init(bl_sha_ctx_t *ctx,bl_sha_type_t type); +int bl_sha_update(bl_sha_ctx_t *ctx,uint8_t *input,uint32_t len); +int bl_sha_finish(bl_sha_ctx_t *ctx,uint8_t *hash); +int hal_hbn_init(uint8_t *pinbuf,uint8_t pinbuf_size); +int hal_hbn_enter(uint32_t time); +int bl_hbn_enter(hbn_type_t *hbn,uint32_t *time); +err_t httpc_tcp_sent(void *arg,altcp_pcb *pcb,u16_t len); +err_t httpc_get_internal_addr(httpc_state_t *req,ip_addr_t *ipaddr); +err_t httpc_free_state(httpc_state_t *req); +err_t httpc_close(httpc_state_t *req,httpc_result_t result,u32_t server_response,err_t err); +err_t httpc_tcp_recv(void *arg,altcp_pcb *pcb,pbuf *p,err_t r); +void httpc_dns_found(char *hostname,ip_addr_t *ipaddr,void *arg); +err_t httpc_tcp_poll(void *arg,altcp_pcb *pcb); +void httpc_tcp_err(void *arg,err_t err); +err_t httpc_tcp_connected(void *arg,altcp_pcb *pcb,err_t err); +int httpc_create_request_string(httpc_connection_t.conflict *settings,char *server_name,int server_port,char *uri,char *buffer,size_t buffer_size); +err_t httpc_init_connection_common(httpc_state_t **connection,httpc_connection_t.conflict *settings,char *server_name,u16_t server_port,char *uri,altcp_recv_fn *recv_fn,void *callback_arg); +err_t httpc_get_file(ip_addr_t *server_addr,u16_t port,char *uri,httpc_connection_t.conflict *settings,altcp_recv_fn *recv_fn,void *callback_arg,httpc_state_t **connection); +err_t httpc_get_file_dns(char *server_name,u16_t port,char *uri,httpc_connection_t.conflict *settings,altcp_recv_fn *recv_fn,void *callback_arg,httpc_state_t **connection); +void set_if(netif *netif,char *ip_addr,char *gw_addr,char *nm_addr); +altcp_pcb * altcp_alloc(void); +void altcp_free(altcp_pcb *conn); +altcp_pcb * altcp_new_ip_type(altcp_allocator_t *allocator,u8_t ip_type); +altcp_pcb * altcp_new(altcp_allocator_t *allocator); +void altcp_arg(altcp_pcb *conn,void *arg); +void altcp_accept(altcp_pcb *conn,altcp_accept_fn accept); +void altcp_recv(altcp_pcb *conn,altcp_recv_fn *recv); +void altcp_sent(altcp_pcb *conn,altcp_sent_fn *sent); +void altcp_poll(altcp_pcb *conn,altcp_poll_fn *poll,u8_t interval); +void altcp_err(altcp_pcb *conn,altcp_err_fn *err); +void altcp_recved(altcp_pcb *conn,u16_t len); +err_t altcp_bind(altcp_pcb *conn,ip_addr_t *ipaddr,u16_t port); +err_t altcp_connect(altcp_pcb *conn,ip_addr_t *ipaddr,u16_t port,altcp_connected_fn connected); +altcp_pcb * altcp_listen_with_backlog_and_err(altcp_pcb *conn,u8_t backlog,err_t *err); +void altcp_abort(altcp_pcb *conn); +err_t altcp_close(altcp_pcb *conn); +err_t altcp_shutdown(altcp_pcb *conn,int shut_rx,int shut_tx); +err_t altcp_write(altcp_pcb *conn,void *dataptr,u16_t len,u8_t apiflags); +err_t altcp_output(altcp_pcb *conn); +u16_t altcp_mss(altcp_pcb *conn); +u16_t altcp_sndbuf(altcp_pcb *conn); +u16_t altcp_sndqueuelen(altcp_pcb *conn); +void altcp_nagle_disable(altcp_pcb *conn); +void altcp_nagle_enable(altcp_pcb *conn); +int altcp_nagle_disabled(altcp_pcb *conn); +void altcp_setprio(altcp_pcb *conn,u8_t prio); +err_t altcp_get_tcp_addrinfo(altcp_pcb *conn,int local,ip_addr_t *addr,u16_t *port); +ip_addr_t * altcp_get_ip(altcp_pcb *conn,int local); +u16_t altcp_get_port(altcp_pcb *conn,int local); +err_t altcp_default_bind(altcp_pcb *conn,ip_addr_t *ipaddr,u16_t port); +err_t altcp_default_shutdown(altcp_pcb *conn,int shut_rx,int shut_tx); +err_t altcp_default_output(altcp_pcb *conn); +u16_t altcp_default_sndbuf(altcp_pcb *conn); +u16_t altcp_default_sndqueuelen(altcp_pcb *conn); +void altcp_default_nagle_disable(altcp_pcb *conn); +void altcp_default_nagle_enable(altcp_pcb *conn); +int altcp_default_nagle_disabled(altcp_pcb *conn); +void altcp_default_setprio(altcp_pcb *conn,u8_t prio); +err_t altcp_default_get_tcp_addrinfo(altcp_pcb *conn,int local,ip_addr_t *addr,u16_t *port); +ip_addr_t * altcp_default_get_ip(altcp_pcb *conn,int local); +u16_t altcp_default_get_port(altcp_pcb *conn,int local); +altcp_pcb * altcp_tls_new(altcp_tls_config *config,u8_t ip_type); +err_t altcp_tcp_connected(void *arg,tcp_pcb *tpcb,err_t err); +err_t altcp_tcp_sent(void *arg,tcp_pcb *tpcb,u16_t len); +err_t altcp_tcp_poll(void *arg,tcp_pcb *tpcb); +u16_t altcp_tcp_mss(altcp_pcb *conn); +u16_t altcp_tcp_sndbuf(altcp_pcb *conn); +u16_t altcp_tcp_sndqueuelen(altcp_pcb *conn); +void altcp_tcp_nagle_disable(altcp_pcb *conn); +void altcp_tcp_nagle_enable(altcp_pcb *conn); +int altcp_tcp_nagle_disabled(altcp_pcb *conn); +void altcp_tcp_dealloc(altcp_pcb *conn); +ip_addr_t * altcp_tcp_get_ip(altcp_pcb *conn,int local); +u16_t altcp_tcp_get_port(altcp_pcb *conn,int local); +void altcp_tcp_setup_callbacks(altcp_pcb *conn,tcp_pcb *tpcb); +void altcp_tcp_err(void *arg,err_t err); +err_t altcp_tcp_get_tcp_addrinfo(altcp_pcb *conn,int local,ip_addr_t *addr,u16_t *port); +void altcp_tcp_setprio(altcp_pcb *conn,u8_t prio); +err_t altcp_tcp_output(altcp_pcb *conn); +err_t altcp_tcp_write(altcp_pcb *conn,void *dataptr,u16_t len,u8_t apiflags); +err_t altcp_tcp_shutdown(altcp_pcb *conn,int shut_rx,int shut_tx); +err_t altcp_tcp_close(altcp_pcb *conn); +void altcp_tcp_abort(altcp_pcb *conn); +altcp_pcb * altcp_tcp_listen(altcp_pcb *conn,u8_t backlog,err_t *err); +err_t altcp_tcp_connect(altcp_pcb *conn,ip_addr_t *ipaddr,u16_t port,altcp_connected_fn connected); +err_t altcp_tcp_bind(altcp_pcb *conn,ip_addr_t *ipaddr,u16_t port); +void altcp_tcp_recved(altcp_pcb *conn,u16_t len); +err_t altcp_tcp_recv(void *arg,tcp_pcb *tpcb,pbuf *p,err_t err); +void altcp_tcp_set_poll(altcp_pcb *conn,u8_t interval); +err_t altcp_tcp_accept(void *arg,tcp_pcb *new_tpcb,err_t err); +altcp_pcb * altcp_tcp_new_ip_type(u8_t ip_type); +int dummy_rng(void *ctx,uchar *buffer,size_t len); +void altcp_mbedtls_lower_err(void *arg,err_t err); +int altcp_mbedtls_bio_recv(void *ctx,uchar *buf,size_t len); +void altcp_mbedtls_setup_callbacks(altcp_pcb *conn,altcp_pcb *inner_conn); +err_t altcp_mbedtls_setup(void *conf,altcp_pcb *conn,altcp_pcb *inner_conn); +err_t altcp_mbedtls_lower_accept(void *arg,altcp_pcb *accepted_conn,err_t err); +void altcp_mbedtls_abort(altcp_pcb *conn); +void altcp_mbedtls_recved(altcp_pcb *conn,u16_t len); +altcp_tls_config * altcp_tls_create_config(int is_server,int have_cert,int have_pkey,int have_ca); +altcp_tls_config * altcp_tls_create_config_client_common(u8_t *ca,size_t ca_len,int is_2wayauth); +void altcp_mbedtls_dealloc(altcp_pcb *conn); +u16_t altcp_mbedtls_sndbuf(altcp_pcb *conn); +err_t altcp_mbedtls_write(altcp_pcb *conn,void *dataptr,u16_t len,u8_t apiflags); +err_t altcp_mbedtls_close(altcp_pcb *conn); +altcp_pcb * altcp_mbedtls_listen(altcp_pcb *conn,u8_t backlog,err_t *err); +err_t altcp_mbedtls_connect(altcp_pcb *conn,ip_addr_t *ipaddr,u16_t port,altcp_connected_fn connected); +int altcp_mbedtls_bio_send(void *ctx,uchar *dataptr,size_t size); +err_t altcp_mbedtls_lower_sent(void *arg,altcp_pcb *inner_conn,u16_t len); +u16_t altcp_mbedtls_mss(altcp_pcb *conn); +void altcp_mbedtls_set_poll(altcp_pcb *conn,u8_t interval); +err_t altcp_mbedtls_handle_rx_appldata(altcp_pcb *conn,altcp_mbedtls_state_t.conflict *state); +err_t altcp_mbedtls_lower_poll(void *arg,altcp_pcb *inner_conn); +err_t altcp_mbedtls_lower_recv_process(altcp_pcb *conn,altcp_mbedtls_state_t.conflict *state); +err_t altcp_mbedtls_lower_connected(void *arg,altcp_pcb *inner_conn,err_t err); +err_t altcp_mbedtls_lower_recv(void *arg,altcp_pcb *inner_conn,pbuf *p,err_t err); +altcp_pcb * altcp_tls_wrap(altcp_tls_config *config,altcp_pcb *inner_pcb); +void * altcp_tls_context(altcp_pcb *conn); +altcp_tls_config * altcp_tls_create_config_client(u8_t *ca,size_t ca_len); +altcp_tls_config *altcp_tls_create_config_client_2wayauth(u8_t *ca,size_t ca_len,u8_t *privkey,size_t privkey_len,u8_t *privkey_pass,size_t privkey_pass_len,u8_t *cert,size_t cert_len); +void altcp_tls_free_config(altcp_tls_config *conf); +void altcp_mbedtls_mem_init(void); +altcp_mbedtls_state_t.conflict2 * altcp_mbedtls_alloc(void *conf); +void altcp_mbedtls_free(void *conf,altcp_mbedtls_state_t.conflict2 *state); +void * altcp_mbedtls_alloc_config(size_t size); +void altcp_mbedtls_free_config(void *item); +int block_cipher_df(uchar *output,uchar *data,size_t data_len); +int ctr_drbg_update_internal(mbedtls_ctr_drbg_context.conflict *ctx,uchar *data); +void mbedtls_ctr_drbg_init(mbedtls_ctr_drbg_context.conflict *ctx); +int mbedtls_ctr_drbg_reseed(mbedtls_ctr_drbg_context.conflict *ctx,uchar *additional,size_t len); +int mbedtls_ctr_drbg_seed_entropy_len(mbedtls_ctr_drbg_context.conflict *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_entropy,void *p_entropy,uchar *custom,size_t len,size_t entropy_len); +int mbedtls_ctr_drbg_seed(mbedtls_ctr_drbg_context.conflict *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_entropy,void *p_entropy,uchar *custom,size_t len); +int mbedtls_ctr_drbg_random_with_add(void *p_rng,uchar *output,size_t output_len,uchar *additional,size_t add_len); +int mbedtls_ctr_drbg_random(void *p_rng,uchar *output,size_t output_len); +void mbedtls_entropy_init(mbedtls_entropy_context *ctx); +int mbedtls_platform_entropy_poll(void *data,uchar *output,size_t len,size_t *olen); +void mbedtls_pk_init(mbedtls_pk_context *ctx); +void mbedtls_pk_free(mbedtls_pk_context *ctx); +mbedtls_pk_info_t * mbedtls_pk_info_from_type(mbedtls_pk_type_t pk_type); +int mbedtls_pk_setup(mbedtls_pk_context *ctx,mbedtls_pk_info_t *info); +int mbedtls_pk_can_do(mbedtls_pk_context *ctx,mbedtls_pk_type_t type); +int mbedtls_pk_verify(mbedtls_pk_context *ctx,mbedtls_md_type_t md_alg,uchar *hash,size_t hash_len,uchar *sig,size_t sig_len); +int mbedtls_pk_sign(mbedtls_pk_context *ctx,mbedtls_md_type_t md_alg,uchar *hash,size_t hash_len,uchar *sig,size_t *sig_len,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng); +int mbedtls_pk_decrypt(mbedtls_pk_context *ctx,uchar *input,size_t ilen,uchar *output,size_t *olen,size_t osize,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng); +int mbedtls_pk_encrypt(mbedtls_pk_context *ctx,uchar *input,size_t ilen,uchar *output,size_t *olen,size_t osize,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng); +size_t mbedtls_pk_get_bitlen(mbedtls_pk_context *ctx); +int mbedtls_pk_verify_ext(mbedtls_pk_type_t type,void *options,mbedtls_pk_context *ctx,mbedtls_md_type_t md_alg,uchar *hash,size_t hash_len,uchar *sig,size_t sig_len); +int mbedtls_pk_debug(mbedtls_pk_context *ctx,mbedtls_pk_debug_item *items); +char * mbedtls_pk_get_name(mbedtls_pk_context *ctx); +mbedtls_pk_type_t mbedtls_pk_get_type(mbedtls_pk_context *ctx); +int pk_use_ecparams(mbedtls_asn1_buf *params,mbedtls_ecp_group *grp); +int pk_parse_key_pkcs1_der(mbedtls_rsa_context *rsa,uchar *key,size_t keylen); +int pk_parse_key_sec1_der(mbedtls_ecp_keypair *eck,uchar *key,size_t keylen); +int pk_get_pk_alg(uchar **p,uchar *end,mbedtls_pk_type_t *pk_alg,mbedtls_asn1_buf *params); +int pk_parse_key_pkcs8_unencrypted_der(mbedtls_pk_context *pk,uchar *key,size_t keylen); +int mbedtls_pk_parse_subpubkey(uchar **p,uchar *end,mbedtls_pk_context *pk); +int mbedtls_pk_parse_key(mbedtls_pk_context *pk,uchar *key,size_t keylen,uchar *pwd,size_t pwdlen); +int rsa_can_do(mbedtls_pk_type_t type); +size_t rsa_get_bitlen(void *ctx); +void rsa_debug(void *ctx,mbedtls_pk_debug_item *items); +int eckey_can_do(mbedtls_pk_type_t type); +size_t eckey_get_bitlen(void *ctx); +void eckey_debug(void *ctx,mbedtls_pk_debug_item *items); +int eckeydh_can_do(mbedtls_pk_type_t type); +void rsa_free_wrap(void *ctx); +void * rsa_alloc_wrap(void); +int rsa_check_pair_wrap(mbedtls_rsa_context *pub,mbedtls_rsa_context *prv); +int rsa_encrypt_wrap(void *ctx,uchar *input,size_t ilen,uchar *output,size_t *olen,size_t osize,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng); +int rsa_decrypt_wrap(void *ctx,uchar *input,size_t ilen,uchar *output,size_t *olen,size_t osize,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng); +int rsa_sign_wrap(void *ctx,mbedtls_md_type_t md_alg,uchar *hash,size_t hash_len,uchar *sig,size_t *sig_len,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng); +int rsa_verify_wrap(void *ctx,mbedtls_md_type_t md_alg,uchar *hash,size_t hash_len,uchar *sig,size_t sig_len); +void eckey_free_wrap(void *ctx); +void * eckey_alloc_wrap(void); +int eckey_check_pair(mbedtls_ecp_keypair *pub,mbedtls_ecp_keypair *prv); +void mgf_mask(uchar *dst,size_t dlen,uchar *src,size_t slen,mbedtls_md_context_t *md_ctx); +void mbedtls_rsa_init(mbedtls_rsa_context *ctx,int padding,int hash_id); +int mbedtls_rsa_check_pubkey(mbedtls_rsa_context *ctx); +int mbedtls_rsa_check_privkey(mbedtls_rsa_context *ctx); +int mbedtls_rsa_check_pub_priv(mbedtls_rsa_context *pub,mbedtls_rsa_context *prv); +int mbedtls_rsa_public(mbedtls_rsa_context *ctx,uchar *input,uchar *output); +int mbedtls_rsa_private(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,uchar *input,uchar *output); +int mbedtls_rsa_rsaes_oaep_encrypt(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,uchar *label,size_t label_len,size_t ilen,uchar *input,uchar *output); +int mbedtls_rsa_rsaes_pkcs1_v15_encrypt(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,size_t ilen,uchar *input,uchar *output); +int mbedtls_rsa_pkcs1_encrypt(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,size_t ilen,uchar *input,uchar *output); +int mbedtls_rsa_rsaes_oaep_decrypt(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,uchar *label,size_t label_len,size_t *olen,uchar *input,uchar *output,size_t output_max_len); +int mbedtls_rsa_rsaes_pkcs1_v15_decrypt(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,size_t *olen,uchar *input,uchar *output,size_t output_max_len); +int mbedtls_rsa_pkcs1_decrypt(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,size_t *olen,uchar *input,uchar *output,size_t output_max_len); +int mbedtls_rsa_rsassa_pss_sign(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig); +int mbedtls_rsa_rsassa_pkcs1_v15_sign(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig); +int mbedtls_rsa_pkcs1_sign(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig); +int mbedtls_rsa_rsassa_pss_verify_ext(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,mbedtls_md_type_t mgf1_hash_id,int expected_salt_len,uchar *sig); +int mbedtls_rsa_rsassa_pss_verify(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig); +int mbedtls_rsa_rsassa_pkcs1_v15_verify(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig); +int mbedtls_rsa_pkcs1_verify(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig); +void mbedtls_rsa_free(mbedtls_rsa_context *ctx); +void mbedtls_sha256_init(mbedtls_sha256_context *ctx); +void mbedtls_sha256_free(mbedtls_sha256_context *ctx); +void mbedtls_sha256_clone(mbedtls_sha256_context *dst,mbedtls_sha256_context *src); +void mbedtls_sha256_starts(mbedtls_sha256_context *ctx,int is224); +void mbedtls_sha256_process(mbedtls_sha256_context *ctx,uchar *data); +void mbedtls_sha256_update(mbedtls_sha256_context *ctx,uchar *input,size_t ilen); +void mbedtls_sha256_update(mbedtls_sha256_context *ctx,uchar *input,size_t ilen); +void mbedtls_sha256_finish(mbedtls_sha256_context *ctx,uchar *output); +void mbedtls_sha256(uchar *input,size_t ilen,uchar *output,int is224); +mbedtls_x509_crt * mbedtls_ssl_own_cert(mbedtls_ssl_context *ssl); +void mbedtls_zeroize(void *v,size_t n); +void ssl_swap_epochs(mbedtls_ssl_context *ssl); +void ssl_calc_finished_tls_sha256(mbedtls_ssl_context *ssl,uchar *buf,int from); +void ssl_calc_verify_tls_sha256(mbedtls_ssl_context *ssl,uchar *hash); +void ssl_flight_free(mbedtls_ssl_flight_item *flight); +int ssl_append_key_cert(mbedtls_ssl_key_cert **head,mbedtls_x509_crt *cert,mbedtls_pk_context *key); +void ssl_update_checksum_start(mbedtls_ssl_context *ssl,uchar *buf,size_t len); +void ssl_update_checksum_sha256(mbedtls_ssl_context *ssl,uchar *buf,size_t len); +size_t mbedtls_ssl_hdr_len(void); +void ssl_set_timer(mbedtls_ssl_context *ssl,uint32_t millisecs); +int ssl_check_timer(mbedtls_ssl_context *ssl); +int tls_prf_sha256(uchar *secret,size_t slen,char *label,uchar *random,size_t rlen,uchar *dstbuf,size_t dlen); +int mbedtls_ssl_derive_keys(mbedtls_ssl_context *ssl); +int mbedtls_ssl_flush_output(mbedtls_ssl_context *ssl); +void mbedtls_ssl_recv_flight_completed(mbedtls_ssl_context *ssl); +void mbedtls_ssl_send_flight_completed(mbedtls_ssl_context *ssl); +void mbedtls_ssl_update_handshake_status(mbedtls_ssl_context *ssl); +void mbedtls_ssl_optimize_checksum(mbedtls_ssl_context *ssl,mbedtls_ssl_ciphersuite_t *ciphersuite_info); +void mbedtls_ssl_reset_checksum(mbedtls_ssl_context *ssl); +void mbedtls_ssl_session_init(mbedtls_ssl_session *session); +void mbedtls_ssl_init(mbedtls_ssl_context *ssl); +void mbedtls_ssl_conf_authmode(mbedtls_ssl_config *conf,int authmode); +void mbedtls_ssl_conf_rng(mbedtls_ssl_config *conf,mbedtls_ssl_recv_t *f_rng,void *p_rng); +void mbedtls_ssl_set_bio(mbedtls_ssl_context *ssl,void *p_bio,mbedtls_ssl_send_t *f_send,mbedtls_ssl_recv_t *f_recv,mbedtls_ssl_recv_timeout_t.conflict1 *f_recv_timeout); +int mbedtls_ssl_conf_own_cert(mbedtls_ssl_config *conf,mbedtls_x509_crt *own_cert,mbedtls_pk_context *pk_key); +void mbedtls_ssl_conf_ca_chain(mbedtls_ssl_config *conf,mbedtls_x509_crt *ca_chain,mbedtls_x509_crl *ca_crl); +int mbedtls_ssl_set_hostname(mbedtls_ssl_context *ssl,char *hostname); +int mbedtls_ssl_conf_alpn_protocols(mbedtls_ssl_config *conf,char **protos); +char * mbedtls_ssl_get_alpn_protocol(mbedtls_ssl_context *ssl); +size_t mbedtls_ssl_get_bytes_avail(mbedtls_ssl_context *ssl); +size_t mbedtls_ssl_get_record_expansion(mbedtls_ssl_context *param_1); +size_t mbedtls_ssl_get_max_frag_len(mbedtls_ssl_context *ssl); +int mbedtls_ssl_handshake_step(mbedtls_ssl_context *ssl); +int mbedtls_ssl_handshake(mbedtls_ssl_context *ssl); +void mbedtls_ssl_transform_free(mbedtls_ssl_transform *transform); +void mbedtls_ssl_handshake_free(mbedtls_ssl_handshake_params *handshake); +void ssl_handshake_wrapup_free_hs_transform(mbedtls_ssl_context *ssl); +void mbedtls_ssl_session_free(mbedtls_ssl_session *session); +void mbedtls_ssl_handshake_wrapup(mbedtls_ssl_context *ssl); +int ssl_handshake_init(mbedtls_ssl_context *ssl); +int mbedtls_ssl_setup(mbedtls_ssl_context *ssl,mbedtls_ssl_config *conf); +void mbedtls_ssl_free(mbedtls_ssl_context *ssl); +void mbedtls_ssl_config_init(mbedtls_ssl_config *conf); +int mbedtls_ssl_config_defaults(mbedtls_ssl_config *conf,int endpoint,int transport,int preset); +void mbedtls_ssl_config_free(mbedtls_ssl_config *conf); +uchar mbedtls_ssl_sig_from_pk(mbedtls_pk_context *pk); +mbedtls_pk_type_t mbedtls_ssl_pk_alg_from_sig(uchar sig); +mbedtls_md_type_t mbedtls_ssl_md_alg_from_hash(uchar hash); +uchar mbedtls_ssl_hash_from_md_alg(int md); +int mbedtls_ssl_check_curve(mbedtls_ssl_context *ssl,mbedtls_ecp_group_id grp_id); +int mbedtls_ssl_check_cert_usage(mbedtls_x509_crt *cert,mbedtls_ssl_ciphersuite_t *ciphersuite,int cert_endpoint,uint32_t *flags); +void mbedtls_ssl_write_version(int major,int minor,int transport,uchar *ver); +int mbedtls_ssl_write_record(mbedtls_ssl_context *ssl); +int mbedtls_ssl_resend(mbedtls_ssl_context *ssl); +int mbedtls_ssl_fetch_input(mbedtls_ssl_context *ssl,size_t nb_want); +int mbedtls_ssl_prepare_handshake_record(mbedtls_ssl_context *ssl); +int mbedtls_ssl_handle_message_type(mbedtls_ssl_context *ssl); +int mbedtls_ssl_send_alert_message(mbedtls_ssl_context *ssl,uchar level,uchar message); +int mbedtls_ssl_send_fatal_handshake_failure(mbedtls_ssl_context *ssl); +int mbedtls_ssl_write_certificate(mbedtls_ssl_context *ssl); +int mbedtls_ssl_write_change_cipher_spec(mbedtls_ssl_context *ssl); +int mbedtls_ssl_write_finished(mbedtls_ssl_context *ssl); +int mbedtls_ssl_write(mbedtls_ssl_context *ssl,uchar *buf,size_t len); +void mbedtls_ssl_read_version(int *major,int *minor,int transport,uchar *ver); +int mbedtls_ssl_read_record_layer(mbedtls_ssl_context *ssl); +int mbedtls_ssl_read_record(mbedtls_ssl_context *ssl); +int mbedtls_ssl_parse_certificate(mbedtls_ssl_context *ssl); +int mbedtls_ssl_parse_change_cipher_spec(mbedtls_ssl_context *ssl); +int mbedtls_ssl_parse_finished(mbedtls_ssl_context *ssl); +int mbedtls_ssl_read(mbedtls_ssl_context *ssl,uchar *buf,size_t len); +int mbedtls_ssl_set_calc_verify_md(mbedtls_ssl_context *ssl,int md); +void mbedtls_zeroize(void *v,size_t n); +int x509_memcasecmp(void *s1,void *s2,size_t len); +int x509_name_cmp(mbedtls_x509_name *a,mbedtls_x509_name *b); +int x509_check_wildcard(char *cn,mbedtls_x509_buf *name); +int x509_profile_check_key(mbedtls_x509_crt_profile *profile,mbedtls_pk_type_t pk_alg,mbedtls_pk_context *pk); +int mbedtls_x509_crt_info(char *buf,size_t size,char *prefix,mbedtls_x509_crt *crt); +int mbedtls_x509_crt_check_key_usage(mbedtls_x509_crt *crt,uint usage); +int x509_crt_check_parent(mbedtls_x509_crt *child,mbedtls_x509_crt *parent,int top,int bottom); +int x509_crt_verify_top(mbedtls_x509_crt *child,mbedtls_x509_crt *trust_ca,mbedtls_x509_crt_profile *profile,int path_cnt,int self_cnt,uint32_t *flags,anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *f_vrfy,void *p_vrfy); +int x509_crt_verify_child(mbedtls_x509_crt *child,mbedtls_x509_crt *parent,mbedtls_x509_crt *trust_ca,mbedtls_x509_crl *ca_crl,mbedtls_x509_crt_profile *profile,int path_cnt,int self_cnt,uint32_t *flags,anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *f_vrfy,void *p_vrfy); +int mbedtls_x509_crt_check_extended_key_usage(mbedtls_x509_crt *crt,char *usage_oid,size_t usage_len); +int mbedtls_x509_crt_verify_with_profile(mbedtls_x509_crt *crt,mbedtls_x509_crt *trust_ca,mbedtls_x509_crl *ca_crl,mbedtls_x509_crt_profile *profile,char *cn,uint32_t *flags,anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *f_vrfy,void *p_vrfy); +void mbedtls_x509_crt_init(mbedtls_x509_crt *crt); +void mbedtls_x509_crt_free(mbedtls_x509_crt *crt); +int mbedtls_x509_crt_parse_der(mbedtls_x509_crt *chain,uchar *buf,size_t buflen); +int mbedtls_x509_crt_parse(mbedtls_x509_crt *chain,uchar *buf,size_t buflen); +void * mycalloc(size_t numitems,size_t size); +void aes_gen_tables(void); +void mbedtls_aes_init(mbedtls_aes_context *ctx); +void mbedtls_aes_free(mbedtls_aes_context *ctx); +int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx,uchar *key,uint keybits); +int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx,uchar *key,uint keybits); +void mbedtls_aes_encrypt(mbedtls_aes_context *ctx,uchar *input,uchar *output); +void mbedtls_aes_decrypt(mbedtls_aes_context *ctx,uchar *input,uchar *output); +int mbedtls_aes_crypt_ecb(mbedtls_aes_context *ctx,int mode,uchar *input,uchar *output); +int mbedtls_aes_crypt_cbc(mbedtls_aes_context *ctx,int mode,size_t length,uchar *iv,uchar *input,uchar *output); +int mbedtls_aes_crypt_cfb128(mbedtls_aes_context *ctx,int mode,size_t length,size_t *iv_off,uchar *iv,uchar *input,uchar *output); +int mbedtls_aes_crypt_ctr(mbedtls_aes_context *ctx,size_t length,size_t *nc_off,uchar *nonce_counter,uchar *stream_block,uchar *input,uchar *output); +int mbedtls_asn1_get_len(uchar **p,uchar *end,size_t *len); +int mbedtls_asn1_get_tag(uchar **p,uchar *end,size_t *len,int tag); +int mbedtls_asn1_get_bool(uchar **p,uchar *end,int *val); +int mbedtls_asn1_get_int(uchar **p,uchar *end,int *val); +int mbedtls_asn1_get_mpi(uchar **p,uchar *end,mbedtls_mpi *X); +int mbedtls_asn1_get_bitstring(uchar **p,uchar *end,mbedtls_asn1_bitstring *bs); +int mbedtls_asn1_get_bitstring_null(uchar **p,uchar *end,size_t *len); +int mbedtls_asn1_get_sequence_of(uchar **p,uchar *end,mbedtls_asn1_sequence *cur,int tag); +int mbedtls_asn1_get_alg(uchar **p,uchar *end,mbedtls_asn1_buf *alg,mbedtls_asn1_buf *params); +void mpi_sub_hlp(size_t n,mbedtls_mpi_uint *s,mbedtls_mpi_uint *d); +void mpi_mul_hlp(size_t i,mbedtls_mpi_uint *s,mbedtls_mpi_uint *d,mbedtls_mpi_uint b); +void mbedtls_mpi_init(mbedtls_mpi *X); +void mbedtls_mpi_free(mbedtls_mpi *X); +int mbedtls_mpi_grow(mbedtls_mpi *X,size_t nblimbs); +int mbedtls_mpi_shrink(mbedtls_mpi *X,size_t nblimbs); +int mbedtls_mpi_copy(mbedtls_mpi *X,mbedtls_mpi *Y); +int mbedtls_mpi_safe_cond_assign(mbedtls_mpi *X,mbedtls_mpi *Y,uchar assign); +int mbedtls_mpi_lset(mbedtls_mpi *X,mbedtls_mpi_sint z); +int mbedtls_mpi_get_bit(mbedtls_mpi *X,size_t pos); +size_t mbedtls_mpi_lsb(mbedtls_mpi *X); +size_t mbedtls_mpi_bitlen(mbedtls_mpi *X); +size_t mbedtls_mpi_size(mbedtls_mpi *X); +int mbedtls_mpi_read_binary(mbedtls_mpi *X,uchar *buf,size_t buflen); +int mbedtls_mpi_write_binary(mbedtls_mpi *X,uchar *buf,size_t buflen); +int mbedtls_mpi_shift_l(mbedtls_mpi *X,size_t count); +int mbedtls_mpi_shift_r(mbedtls_mpi *X,size_t count); +int mbedtls_mpi_cmp_abs(mbedtls_mpi *X,mbedtls_mpi *Y); +int mpi_montmul(mbedtls_mpi *A,mbedtls_mpi *B,mbedtls_mpi *N,mbedtls_mpi_uint mm,mbedtls_mpi *T); +int mbedtls_mpi_cmp_mpi(mbedtls_mpi *X,mbedtls_mpi *Y); +int mbedtls_mpi_cmp_int(mbedtls_mpi *X,mbedtls_mpi_sint z); +int mbedtls_mpi_add_abs(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *B); +int mbedtls_mpi_sub_abs(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *B); +int mbedtls_mpi_add_mpi(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *B); +int mbedtls_mpi_sub_mpi(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *B); +int mbedtls_mpi_sub_int(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi_sint b); +int mbedtls_mpi_mul_mpi(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *B); +int mbedtls_mpi_mul_int(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi_uint b); +int mbedtls_mpi_div_mpi(mbedtls_mpi *Q,mbedtls_mpi *R,mbedtls_mpi *A,mbedtls_mpi *B); +int mbedtls_mpi_mod_mpi(mbedtls_mpi *R,mbedtls_mpi *A,mbedtls_mpi *B); +int mbedtls_mpi_exp_mod(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *E,mbedtls_mpi *N,mbedtls_mpi *_RR); +int mbedtls_mpi_gcd(mbedtls_mpi *G,mbedtls_mpi *A,mbedtls_mpi *B); +int mbedtls_mpi_fill_random(mbedtls_mpi *X,size_t size,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng); +int mbedtls_mpi_inv_mod(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *N); +uint mbedtls_cipher_get_block_size(mbedtls_cipher_context_t *ctx); +void add_pkcs_padding(uchar *output,size_t output_len,size_t data_len); +int get_pkcs_padding(uchar *input,size_t input_len,size_t *data_len); +void add_zeros_padding(uchar *output,size_t output_len,size_t data_len); +int get_no_padding(uchar *input,size_t input_len,size_t *data_len); +int get_zeros_padding(uchar *input,size_t input_len,size_t *data_len); +mbedtls_cipher_info_t * mbedtls_cipher_info_from_type(mbedtls_cipher_type_t cipher_type); +mbedtls_cipher_info_t *mbedtls_cipher_info_from_values(mbedtls_cipher_id_t cipher_id,int key_bitlen,mbedtls_cipher_mode_t mode); +void mbedtls_cipher_init(mbedtls_cipher_context_t *ctx); +void mbedtls_cipher_free(mbedtls_cipher_context_t *ctx); +int mbedtls_cipher_setkey(mbedtls_cipher_context_t *ctx,uchar *key,int key_bitlen,mbedtls_operation_t operation); +int mbedtls_cipher_set_iv(mbedtls_cipher_context_t *ctx,uchar *iv,size_t iv_len); +int mbedtls_cipher_reset(mbedtls_cipher_context_t *ctx); +int mbedtls_cipher_update(mbedtls_cipher_context_t *ctx,uchar *input,size_t ilen,uchar *output,size_t *olen); +int mbedtls_cipher_finish(mbedtls_cipher_context_t *ctx,uchar *output,size_t *olen); +int mbedtls_cipher_set_padding_mode(mbedtls_cipher_context_t *ctx,mbedtls_cipher_padding_t mode); +int mbedtls_cipher_setup(mbedtls_cipher_context_t *ctx,mbedtls_cipher_info_t *cipher_info); +int mbedtls_cipher_crypt(mbedtls_cipher_context_t *ctx,uchar *iv,size_t iv_len,uchar *input,size_t ilen,uchar *output,size_t *olen); +int mbedtls_cipher_auth_encrypt(mbedtls_cipher_context_t *ctx,uchar *iv,size_t iv_len,uchar *ad,size_t ad_len,uchar *input,size_t ilen,uchar *output,size_t *olen,uchar *tag,size_t tag_len); +int mbedtls_cipher_auth_decrypt(mbedtls_cipher_context_t *ctx,uchar *iv,size_t iv_len,uchar *ad,size_t ad_len,uchar *input,size_t ilen,uchar *output,size_t *olen,uchar *tag,size_t tag_len); +void gcm_ctx_free(void *ctx); +void * gcm_ctx_alloc(void); +int gcm_aes_setkey_wrap(void *ctx,uchar *key,uint key_bitlen); +void aes_ctx_free(void *ctx); +void * aes_ctx_alloc(void); +int aes_setkey_dec_wrap(mbedtls_aes_context *ctx,uchar *key,uint keybits); +int aes_setkey_enc_wrap(mbedtls_aes_context *ctx,uchar *key,uint keybits); +int aes_crypt_ctr_wrap(mbedtls_aes_context *ctx,size_t length,size_t *nc_off,uchar *nonce_counter,uchar *stream_block,uchar *input,uchar *output); +int aes_crypt_cfb128_wrap(mbedtls_aes_context *ctx,int mode,size_t length,size_t *iv_off,uchar *iv,uchar *input,uchar *output); +int aes_crypt_cbc_wrap(mbedtls_aes_context *ctx,int mode,size_t length,uchar *iv,uchar *input,uchar *output); +int aes_crypt_ecb_wrap(mbedtls_aes_context *ctx,int mode,uchar *input,uchar *output); +void debug_send_line(int level,char *file,int line,char *str); +void mbedtls_debug_print_mpi(mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,mbedtls_mpi *X); +void mbedtls_debug_print_msg(mbedtls_ssl_context *ssl,int level,char *file,int line,char *format,...); +void mbedtls_debug_print_ret(mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,int ret); +void mbedtls_debug_print_buf(mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,uchar *buf,size_t len); +void mbedtls_debug_print_mpi(mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,mbedtls_mpi *X); +void mbedtls_debug_print_ecp(mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,mbedtls_ecp_point *X); +void mbedtls_debug_print_ecp(mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,mbedtls_ecp_point *X); +void mbedtls_debug_print_crt(mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,mbedtls_x509_crt *crt); +ecp_curve_type ecp_get_type(mbedtls_ecp_group *grp); +int ecp_safe_invert_jac(mbedtls_ecp_group *grp,mbedtls_ecp_point *Q,uchar inv); +int ecp_select_comb(mbedtls_ecp_group *grp,mbedtls_ecp_point *R,mbedtls_ecp_point *T,uchar t_len,uchar i); +int ecp_modp(mbedtls_mpi *N,mbedtls_ecp_group *grp); +int ecp_double_jac(mbedtls_ecp_group *grp,mbedtls_ecp_point *R,mbedtls_ecp_point *P); +int ecp_normalize_jac(mbedtls_ecp_group *grp,mbedtls_ecp_point *pt); +int ecp_normalize_jac_many(mbedtls_ecp_group *grp,mbedtls_ecp_point **T,size_t t_len); +void mbedtls_ecp_point_init(mbedtls_ecp_point *pt); +void mbedtls_ecp_point_free(mbedtls_ecp_point *pt); +mbedtls_ecp_group_id * mbedtls_ecp_grp_id_list(void); +void mbedtls_ecp_point_init(mbedtls_ecp_point *pt); +void mbedtls_ecp_group_init(mbedtls_ecp_group *grp); +void mbedtls_ecp_keypair_init(mbedtls_ecp_keypair *key); +void mbedtls_ecp_point_free(mbedtls_ecp_point *pt); +void mbedtls_ecp_group_free(mbedtls_ecp_group *grp); +void mbedtls_ecp_keypair_free(mbedtls_ecp_keypair *key); +int mbedtls_ecp_copy(mbedtls_ecp_point *P,mbedtls_ecp_point *Q); +int mbedtls_ecp_group_copy(mbedtls_ecp_group *dst,mbedtls_ecp_group *src); +int mbedtls_ecp_set_zero(mbedtls_ecp_point *pt); +int ecp_add_mixed(mbedtls_ecp_group *grp,mbedtls_ecp_point *R,mbedtls_ecp_point *P,mbedtls_ecp_point *Q); +int ecp_mul_comb(mbedtls_ecp_group *grp,mbedtls_ecp_point *R,mbedtls_mpi *m,mbedtls_ecp_point *P,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng); +int mbedtls_ecp_point_read_binary(mbedtls_ecp_group *grp,mbedtls_ecp_point *pt,uchar *buf,size_t ilen); +int mbedtls_ecp_check_pubkey(mbedtls_ecp_group *grp,mbedtls_ecp_point *pt); +int mbedtls_ecp_check_privkey(mbedtls_ecp_group *grp,mbedtls_mpi *d); +int mbedtls_ecp_mul(mbedtls_ecp_group *grp,mbedtls_ecp_point *R,mbedtls_mpi *m,mbedtls_ecp_point *P,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng); +int mbedtls_ecp_check_pub_priv(mbedtls_ecp_keypair *pub,mbedtls_ecp_keypair *prv); +int ecp_mod_koblitz(mbedtls_mpi *N,mbedtls_mpi_uint *Rp,size_t p_limbs); +int ecp_mod_p224k1(mbedtls_mpi *N); +int ecp_mod_p256k1(mbedtls_mpi *N); +int mbedtls_ecp_group_load(mbedtls_ecp_group *grp,mbedtls_ecp_group_id id); +void gcm_mult(mbedtls_gcm_context *ctx,uchar *x,uchar *output); +void mbedtls_gcm_init(mbedtls_gcm_context *ctx); +int mbedtls_gcm_setkey(mbedtls_gcm_context *ctx,mbedtls_cipher_id_t cipher,uchar *key,uint keybits); +int mbedtls_gcm_starts(mbedtls_gcm_context *ctx,int mode,uchar *iv,size_t iv_len,uchar *add,size_t add_len); +int mbedtls_gcm_update(mbedtls_gcm_context *ctx,size_t length,uchar *input,uchar *output); +int mbedtls_gcm_finish(mbedtls_gcm_context *ctx,uchar *tag,size_t tag_len); +int mbedtls_gcm_crypt_and_tag(mbedtls_gcm_context *ctx,int mode,size_t length,uchar *iv,size_t iv_len,uchar *add,size_t add_len,uchar *input,uchar *output,size_t tag_len,uchar *tag); +int mbedtls_gcm_auth_decrypt(mbedtls_gcm_context *ctx,size_t length,uchar *iv,size_t iv_len,uchar *add,size_t add_len,uchar *tag,size_t tag_len,uchar *input,uchar *output); +void mbedtls_gcm_free(mbedtls_gcm_context *ctx); +mbedtls_md_info_t * mbedtls_md_info_from_type(mbedtls_md_type_t md_type); +void mbedtls_md_init(mbedtls_md_context_t *ctx); +void mbedtls_md_free(mbedtls_md_context_t *ctx); +int mbedtls_md_setup(mbedtls_md_context_t *ctx,mbedtls_md_info_t *md_info,int hmac); +int mbedtls_md_starts(mbedtls_md_context_t *ctx); +int mbedtls_md_update(mbedtls_md_context_t *ctx,uchar *input,size_t ilen); +int mbedtls_md_finish(mbedtls_md_context_t *ctx,uchar *output); +int mbedtls_md(mbedtls_md_info_t *md_info,uchar *input,size_t ilen,uchar *output); +int mbedtls_md_hmac_starts(mbedtls_md_context_t *ctx,uchar *key,size_t keylen); +int mbedtls_md_hmac_update(mbedtls_md_context_t *ctx,uchar *input,size_t ilen); +int mbedtls_md_hmac_finish(mbedtls_md_context_t *ctx,uchar *output); +int mbedtls_md_hmac_reset(mbedtls_md_context_t *ctx); +int mbedtls_md_process(mbedtls_md_context_t *ctx,uchar *data); +uchar mbedtls_md_get_size(mbedtls_md_info_t *md_info); +void md5_process_wrap(mbedtls_md5_context *ctx,uchar *data); +void md5_clone_wrap(mbedtls_md5_context *dst,mbedtls_md5_context *src); +void md5_ctx_free(void *ctx); +void * md5_ctx_alloc(void); +void md5_finish_wrap(mbedtls_md5_context *ctx,uchar *output); +void md5_update_wrap(mbedtls_md5_context *ctx,uchar *input,size_t ilen); +void md5_starts_wrap(mbedtls_md5_context *ctx); +void sha1_process_wrap(mbedtls_sha1_context *ctx,uchar *data); +void sha1_clone_wrap(mbedtls_sha1_context *dst,mbedtls_sha1_context *src); +void sha1_ctx_free(void *ctx); +void * sha1_ctx_alloc(void); +void sha1_finish_wrap(mbedtls_sha1_context *ctx,uchar *output); +void sha1_update_wrap(mbedtls_sha1_context *ctx,uchar *input,size_t ilen); +void sha1_starts_wrap(mbedtls_sha1_context *ctx); +void sha224_process_wrap(mbedtls_sha256_context *ctx,uchar *data); +void sha224_clone_wrap(mbedtls_sha256_context *dst,mbedtls_sha256_context *src); +void sha224_ctx_free(void *ctx); +void * sha224_ctx_alloc(void); +void sha224_wrap(uchar *input,size_t ilen,uchar *output); +void sha256_wrap(uchar *input,size_t ilen,uchar *output); +void sha224_finish_wrap(mbedtls_sha256_context *ctx,uchar *output); +void sha224_update_wrap(mbedtls_sha256_context *ctx,uchar *input,size_t ilen); +void sha224_starts_wrap(void *ctx); +void sha256_starts_wrap(void *ctx); +oid_sig_alg_t * oid_sig_alg_from_asn1(mbedtls_asn1_buf *oid); +int mbedtls_oid_get_attr_short_name(mbedtls_asn1_buf *oid,char **short_name); +int mbedtls_oid_get_x509_ext_type(mbedtls_asn1_buf *oid,int *ext_type); +int mbedtls_oid_get_extended_key_usage(mbedtls_asn1_buf *oid,char **description); +int mbedtls_oid_get_sig_alg_desc(mbedtls_asn1_buf *oid,char **description); +int mbedtls_oid_get_sig_alg(mbedtls_asn1_buf *oid,mbedtls_md_type_t *md_alg,mbedtls_pk_type_t *pk_alg); +int mbedtls_oid_get_pk_alg(mbedtls_asn1_buf *oid,mbedtls_pk_type_t *pk_alg); +int mbedtls_oid_get_ec_grp(mbedtls_asn1_buf *oid,mbedtls_ecp_group_id *grp_id); +int mbedtls_oid_get_md_alg(mbedtls_asn1_buf *oid,mbedtls_md_type_t *md_alg); +int mbedtls_oid_get_oid_by_md(mbedtls_md_type_t md_alg,char **oid,size_t *olen); +void pem_aes_decrypt(uchar *aes_iv,uint keylen,uchar *buf,size_t buflen,uchar *pwd,size_t pwdlen); +void mbedtls_pem_init(mbedtls_pem_context *ctx); +int mbedtls_pem_read_buffer(mbedtls_pem_context *ctx,char *header,char *footer,uchar *data,uchar *pwd,size_t pwdlen,size_t *use_len); +void mbedtls_pem_free(mbedtls_pem_context *ctx); +void mbedtls_md5_init(mbedtls_md5_context *ctx); +void mbedtls_md5_free(mbedtls_md5_context *ctx); +void mbedtls_md5_clone(mbedtls_md5_context *dst,mbedtls_md5_context *src); +void mbedtls_md5_starts(mbedtls_md5_context *ctx); +void mbedtls_md5_process(mbedtls_md5_context *ctx,uchar *data); +void mbedtls_md5_update(mbedtls_md5_context *ctx,uchar *input,size_t ilen); +void mbedtls_md5_update(mbedtls_md5_context *ctx,uchar *input,size_t ilen); +void mbedtls_md5_finish(mbedtls_md5_context *ctx,uchar *output); +void mbedtls_md5(uchar *input,size_t ilen,uchar *output); +void mbedtls_sha1_init(mbedtls_sha1_context *ctx); +void mbedtls_sha1_free(mbedtls_sha1_context *ctx); +void mbedtls_sha1_clone(mbedtls_sha1_context *dst,mbedtls_sha1_context *src); +void mbedtls_sha1_starts(mbedtls_sha1_context *ctx); +void mbedtls_sha1_process(mbedtls_sha1_context *ctx,uchar *data); +void mbedtls_sha1_update(mbedtls_sha1_context *ctx,uchar *input,size_t ilen); +void mbedtls_sha1_update(mbedtls_sha1_context *ctx,uchar *input,size_t ilen); +void mbedtls_sha1_finish(mbedtls_sha1_context *ctx,uchar *output); +void mbedtls_sha1(uchar *input,size_t ilen,uchar *output); +mbedtls_ssl_ciphersuite_t * mbedtls_ssl_ciphersuite_from_id(int ciphersuite); +int * mbedtls_ssl_list_ciphersuites(void); +char * mbedtls_ssl_get_ciphersuite_name(int ciphersuite_id); +mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_pk_alg(mbedtls_ssl_ciphersuite_t *info); +mbedtls_pk_context * mbedtls_ssl_own_key(mbedtls_ssl_context *ssl); +size_t mbedtls_ssl_hs_hdr_len(void); +int mbedtls_ssl_handshake_client_step(mbedtls_ssl_context *ssl); +mbedtls_pk_context * mbedtls_ssl_own_key(mbedtls_ssl_context *ssl); +int mbedtls_ssl_handshake_server_step(mbedtls_ssl_context *ssl); +int mbedtls_x509_get_serial(uchar **p,uchar *end,mbedtls_x509_buf *serial); +int mbedtls_x509_get_alg(uchar **p,uchar *end,mbedtls_x509_buf *alg,mbedtls_x509_buf *params); +int mbedtls_x509_get_name(uchar **p,uchar *end,mbedtls_x509_name *cur); +int mbedtls_x509_get_sig(uchar **p,uchar *end,mbedtls_x509_buf *sig); +int mbedtls_x509_get_sig_alg(mbedtls_x509_buf *sig_oid,mbedtls_x509_buf *sig_params,mbedtls_md_type_t *md_alg,mbedtls_pk_type_t *pk_alg,void **sig_opts); +int mbedtls_x509_get_ext(uchar **p,uchar *end,mbedtls_x509_buf *ext,int tag); +int mbedtls_x509_dn_gets(char *buf,size_t size,mbedtls_x509_name *dn); +int mbedtls_x509_serial_gets(char *buf,size_t size,mbedtls_x509_buf *serial); +int mbedtls_x509_sig_alg_gets(char *buf,size_t size,mbedtls_x509_buf *sig_oid,mbedtls_pk_type_t pk_alg,mbedtls_md_type_t md_alg,void *sig_opts); +int mbedtls_x509_key_size_helper(char *buf,size_t buf_size,char *name); +int mbedtls_x509_time_is_past(mbedtls_x509_time *to); +undefined4 mbedtls_x509_time_is_future(void); +int mbedtls_base64_decode(uchar *dst,size_t dlen,size_t *olen,uchar *src,size_t slen); +int utils_notifier_chain_init(ntf_list_t *nl); +int utils_notifier_chain_register(ntf_list_t *nl,utils_notifier_t *node); +int utils_notifier_chain_call(ntf_list_t *nl,void *env); +double fabs(double __x); +double floor(double __x); +double modf(double __x,double *__iptr); +double pow(double __x,double __y); +void __ieee754_pow(uint param_1,uint param_2,uint param_3,uint param_4,double param_5); +uint __ieee754_sqrt(uint param_1,uint param_2); +int finite(double __value); +double nan(char *__tagb); +double rint(double __x); +double scalbn(double __x,int __n); +DItype __lshrdi3(shift_count_type b); +DItype __ashldi3(shift_count_type b); +int __clzsi2(USItype x); +int __popcountsi2(USItype x); +SFtype __floatundisf(void); +DItype __divdi3(void); +DItype __moddi3(void); +UDItype __udivdi3(void); +UDItype __umoddi3(void); +__gcc_CMPtype __eqdf2(void); +__gcc_CMPtype __gedf2(void); +__gcc_CMPtype __ledf2(void); +__gcc_CMPtype __unorddf2(void); +SItype __fixdfsi(void); +USItype __fixunsdfsi(void); +DFtype __floatsidf(SItype i); +DFtype __floatunsidf(USItype i); +SFtype __truncdfsf2(void); +void abort(void); +void __assert_func(undefined4 param_1,undefined4 param_2,char *param_3,undefined4 param_4); +void __assert(char *__assertion,char *__file,int __line); +int atoi(char *__nptr); +void _atoi_r(void); +undefined * __errno(void); +void _fiprintf_r(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,undefined4 param_5); +void fiprintf(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,undefined4 param_5,undefined4 param_6,undefined4 param_7,undefined4 param_8); +void * memchr(void *__s,int __c,size_t __n); +int memcmp(void *__s1,void *__s2,size_t __n); +void * memcpy(void *__dest,void *__src,size_t __n); +void * memmove(void *__dest,void *__src,size_t __n); +void * memset(void *__s,int __c,size_t __n); +undefined4 _init_signal_r.part.0(int param_1); +undefined4 _init_signal_r(int param_1); +undefined4 _signal_r(undefined4 *param_1,uint param_2,undefined4 param_3); +undefined4 _raise_r(undefined4 *param_1,uint param_2); +undefined4 __sigtramp_r(int param_1,uint param_2); +int raise(int __sig); +__sighandler_t signal(int __sig,__sighandler_t __handler); +undefined4 _init_signal(void); +void __sigtramp(undefined4 param_1); +void _kill_r(int *param_1,__pid_t param_2,int param_3); +__pid_t _getpid_r(void); +char * strchr(char *__s,int __c); +int strcmp(char *__s1,char *__s2); +char * strcpy(char *__dest,char *__src); +size_t strlen(char *__s); +int strncmp(char *__s1,char *__s2,size_t __n); +char * strncpy(char *__dest,char *__src,size_t __n); +size_t strnlen(char *__string,size_t __maxlen); +char * strrchr(char *__s,int __c); +byte * two_way_long_needle(int param_1,int param_2,byte *param_3,byte *param_4); +char * strstr(char *__haystack,char *__needle); +uint _strtol_l.isra.0(undefined4 *param_1,byte *param_2,byte **param_3,uint param_4); +uint _strtol_r(undefined4 *param_1,byte *param_2,byte **param_3,uint param_4); +long strtol_l(char *__nptr,char **__endptr,int __base,__locale_t __loc); +long strtol(char *__nptr,char **__endptr,int __base); +uint _strtoul_l.isra.0(undefined4 *param_1,byte *param_2,byte **param_3,uint param_4); +uint _strtoul_r(undefined4 *param_1,byte *param_2,byte **param_3,uint param_4); +ulong strtoul_l(char *__nptr,char **__endptr,int __base,__locale_t __loc); +ulong strtoul(char *__nptr,char **__endptr,int __base); +int stat(char *__file,stat *__buf); +undefined4 __sprint_r.part.0(undefined4 param_1,int param_2,int **param_3); +undefined4 __sprint_r(int param_1); +int _vfiprintf_r(int param_1,int param_2,int *param_3,int **param_4); +void vfiprintf(undefined4 param_1,undefined4 param_2,undefined4 param_3); +int __sbprintf(undefined4 param_1,int param_2); +undefined4 __swsetup_r(undefined4 *param_1,int *param_2); +int __sflush_r(int *param_1,int *param_2); +undefined4 _fflush_r(int param_1,int param_2); +int fflush(FILE *__stream); +undefined4 __fp_lock(void); +void _cleanup_r(void); +void __sinit.part.0(int param_1); +undefined4 __fp_unlock(void); +undefined4 * __sfmoreglue(int param_1); +undefined4 * __sfp(undefined4 *param_1); +void _cleanup(void); +void __sinit(int param_1); +void __sfp_lock_acquire(void); +void __sfp_lock_release(void); +void __sinit_lock_acquire(void); +void __sinit_lock_release(void); +void __fp_lock_all(void); +void __fp_unlock_all(void); +uint __fputwc(undefined4 param_1,uint param_2,int *param_3); +void _fputwc_r(int param_1); +wint_t fputwc(wchar_t __wc,__FILE *__stream); +undefined4 _malloc_trim_r(undefined4 param_1,int param_2); +void _free_r(undefined4 param_1,int param_2); +undefined4 __sfvwrite_r(undefined4 *param_1,void **param_2,int **param_3); +uint _fwalk(int param_1,uint param_2); +uint _fwalk_reent(int param_1,uint param_2); +int __localeconv_l(int param_1); +undefined4 _localeconv_r(void); +lconv * localeconv(void); +undefined * _setlocale_r(char *param_1); +uint __locale_mb_cur_max(void); +char * setlocale(int __category,char *__locale); +undefined4 __swhatbuf_r(int param_1,undefined4 *param_2,uint *param_3); +void __smakebuf_r(int param_1,int *param_2); +undefined4 * _malloc_r(undefined4 *param_1,uint param_2); +void _mbtowc_r(void); +uint __ascii_mbtowc(uint *param_1,byte *param_2,int param_3); +void __malloc_lock(void); +void __malloc_unlock(void); +undefined4 * _realloc_r(undefined4 *param_1,undefined4 *param_2,uint param_3); +void _sbrk_r(int *param_1,intptr_t param_2); +void _stat_r(int *param_1,undefined4 param_2,undefined4 param_3); +void __sread(int param_1); +undefined4 __seofread(void); +void __swrite(undefined4 param_1,int param_2,undefined4 param_3,undefined4 param_4); +void __sseek(int param_1); +void __sclose(int param_1); +uint __swbuf_r(int param_1,byte param_2,byte **param_3); +void __swbuf(undefined4 param_1,undefined4 param_2); +void _wcrtomb_r(undefined4 *param_1,int param_2,undefined4 *param_3); +size_t wcrtomb(char *__s,wchar_t __wc,mbstate_t *__ps); +void _wctomb_r(void); +undefined4 __ascii_wctomb(undefined4 *param_1,undefined *param_2,uint param_3); +void _write_r(int *param_1,int param_2,void *param_3,size_t param_4); +void _close_r(int *param_1,int param_2); +undefined4 _fclose_r(int param_1,int param_2); +int fclose(FILE *__stream); +void _fstat_r(int *param_1,int param_2,stat *param_3); +void _isatty_r(int *param_1,int param_2); +void _lseek_r(int *param_1,int param_2,__off_t param_3,int param_4); +void _read_r(int *param_1,int param_2,void *param_3,size_t param_4); +int _close(int __fd); +void _exit(int __status); +int _fstat(int __fd,stat *__buf); +__pid_t _getpid(void); +int _isatty(int __fd); +int _kill(__pid_t __pid,int __sig); +__off_t _lseek(int __fd,__off_t __offset,int __whence); +ssize_t _read(int __fd,void *__buf,size_t __nbytes); +void * _sbrk(intptr_t __delta); +int _stat(int param_1,undefined4 param_2); +ssize_t _write(int __fd,void *__buf,size_t __n); +void _conv_stat(undefined2 *param_1,undefined4 *param_2); +BL_Err_Type AON_Power_On_BG(void); +BL_Err_Type AON_Power_Off_BG(void); +BL_Err_Type AON_Power_On_LDO11_SOC(void); +BL_Err_Type AON_Power_Off_LDO11_SOC(void); +BL_Err_Type AON_Power_On_LDO15_RF(void); +BL_Err_Type AON_Power_Off_LDO15_RF(void); +BL_Err_Type AON_Power_On_SFReg(void); +BL_Err_Type AON_Power_Off_SFReg(void); +BL_Err_Type AON_LowPower_Enter_PDS0(void); +BL_Err_Type AON_LowPower_Exit_PDS0(void); +void ASM_Delay_Us(uint32_t core,uint32_t cnt); +void BL602_Delay_US(uint32_t cnt); +void BL602_Delay_MS(uint32_t cnt); +void * BL602_MemCpy(void *dst,void *src,uint32_t n); +uint32_t * BL602_MemCpy4(uint32_t *dst,uint32_t *src,uint32_t n); +void * BL602_MemCpy_Fast(void *pdst,void *psrc,uint32_t n); +void * BL602_MemSet(void *s,uint8_t c,uint32_t n); +uint32_t * BL602_MemSet4(uint32_t *dst,uint32_t val,uint32_t n); +int BL602_MemCmp(void *s1,void *s2,uint32_t n); +void EF_Ctrl_Sw_AHB_Clk_0(void); +void EF_Ctrl_Program_Efuse_0(void); +void EF_Ctrl_Load_Efuse_R0(void); +BL_Sts_Type EF_Ctrl_Busy(void); +BL_Sts_Type EF_Ctrl_AutoLoad_Done(void); +void EF_Ctrl_Clear(uint32_t index,uint32_t len); +BL_Err_Type GLB_SW_System_Reset(void); +BL_Err_Type GLB_SW_CPU_Reset(void); +BL_Err_Type GLB_SW_POR_Reset(void); +BL_Err_Type GLB_Select_Internal_Flash(void); +BL_Err_Type GLB_Select_External_Flash(void); +BL_Err_Type GLB_Deswap_Flash_Pin(void); +BL_Err_Type GLB_Swap_Flash_Pin(void); +BL_Err_Type GLB_GPIO_Init(GLB_GPIO_Cfg_Type *cfg); +BL_Err_Type GLB_GPIO_OUTPUT_Enable(GLB_GPIO_Type gpioPin); +BL_Err_Type GLB_GPIO_OUTPUT_Disable(GLB_GPIO_Type gpioPin); +BL_Err_Type GLB_GPIO_Set_HZ(GLB_GPIO_Type gpioPin); +uint8_t GLB_GPIO_Get_Fun(GLB_GPIO_Type gpioPin); +void HBN_Mode_Enter(HBN_APP_CFG_Type *cfg); +void HBN_Power_Down_Flash(SPI_Flash_Cfg_Type *flashCfg); +void HBN_Enable(uint8_t aGPIOIeCfg,HBN_LDO_LEVEL_Type ldoLevel,HBN_LEVEL_Type hbnLevel); +BL_Err_Type HBN_Reset(void); +BL_Err_Type HBN_Set_Ldo11_Aon_Vout(HBN_LDO_LEVEL_Type ldoLevel); +BL_Err_Type HBN_Set_Ldo11_Rt_Vout(HBN_LDO_LEVEL_Type ldoLevel); +BL_Err_Type HBN_Set_Ldo11_Soc_Vout(HBN_LDO_LEVEL_Type ldoLevel); +BL_Err_Type HBN_Hw_Pu_Pd_Cfg(uint8_t enable); +BL_Err_Type HBN_Pin_WakeUp_Mask(uint8_t maskVal); +BL_Err_Type HBN_GPIO7_Dbg_Pull_Cfg(BL_Fun_Type pupdEn,BL_Fun_Type iesmtEn,BL_Fun_Type dlyEn,uint8_t dlySec); +BL_Err_Type HBN_Set_Embedded_Flash_Pullup(uint8_t enable); +BL_Err_Type L1C_Set_Wrap(BL_Fun_Type wrap); +BL_Err_Type L1C_Set_Way_Disable(uint8_t disableVal); +BL_Err_Type L1C_IROM_2T_Access_Set(uint8_t enable); +BL_Err_Type PDS_Reset(void); +BL_Err_Type PDS_Force_Config(PDS_CTL2_Type *cfg2,PDS_CTL3_Type *cfg3); +BL_Err_Type PDS_RAM_Config(PDS_RAM_CFG_Type *ramCfg); +BL_Err_Type PDS_Default_Level_Config(PDS_DEFAULT_LV_CFG_Type *defaultLvCfg,PDS_RAM_CFG_Type *ramCfg,uint32_t pdsSleepCnt); +void SEC_Eng_Turn_On_Sec_Ring(void); +void SEC_Eng_Turn_Off_Sec_Ring(void); +void SFlash_Init(SF_Ctrl_Cfg_Type *pSfCtrlCfg); +BL_Err_Type SFlash_SetSPIMode(SF_Ctrl_Mode_Type mode); +BL_Err_Type SFlash_Read_Reg(SPI_Flash_Cfg_Type *flashCfg,uint8_t regIndex,uint8_t *regValue,uint8_t regLen); +BL_Err_Type SFlash_Write_Reg(SPI_Flash_Cfg_Type *flashCfg,uint8_t regIndex,uint8_t *regValue,uint8_t regLen); +BL_Sts_Type SFlash_Busy(SPI_Flash_Cfg_Type *flashCfg); +BL_Err_Type SFlash_Write_Enable(SPI_Flash_Cfg_Type *flashCfg); +BL_Err_Type SFlash_Qspi_Enable(SPI_Flash_Cfg_Type *flashCfg); +void SFlash_Volatile_Reg_Write_Enable(SPI_Flash_Cfg_Type *flashCfg); +BL_Err_Type SFlash_Chip_Erase(SPI_Flash_Cfg_Type *flashCfg); +BL_Err_Type SFlash_Sector_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t secNum); +BL_Err_Type SFlash_Blk32_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t blkNum); +BL_Err_Type SFlash_Blk64_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t blkNum); +BL_Err_Type SFlash_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t startaddr,uint32_t endaddr); +BL_Err_Type SFlash_Program(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint32_t addr,uint8_t *data,uint32_t len); +void SFlash_GetUniqueId(uint8_t *data,uint8_t idLen); +void SFlash_GetJedecId(SPI_Flash_Cfg_Type *flashCfg,uint8_t *data); +void SFlash_GetDeviceId(uint8_t *data); +void SFlash_Powerdown(void); +void SFlash_Releae_Powerdown(SPI_Flash_Cfg_Type *flashCfg); +void SFlash_SetBurstWrap(SPI_Flash_Cfg_Type *flashCfg); +void SFlash_DisableBurstWrap(SPI_Flash_Cfg_Type *flashCfg); +BL_Err_Type SFlash_Software_Reset(SPI_Flash_Cfg_Type *flashCfg); +void SFlash_Reset_Continue_Read(SPI_Flash_Cfg_Type *flashCfg); +BL_Err_Type SFlash_Set_IDbus_Cfg(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead,uint32_t addr,uint32_t len); +BL_Err_Type SFlash_IDbus_Read_Enable(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead); +BL_Err_Type SFlash_Cache_Enable_Set(uint8_t wayDisable); +BL_Err_Type SFlash_Cache_Flush(void); +BL_Err_Type SFlash_Cache_Read_Enable(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead,uint8_t wayDisable); +void SFlash_Cache_Hit_Count_Get(uint32_t *hitCountLow,uint32_t *hitCountHigh); +uint32_t SFlash_Cache_Miss_Count_Get(void); +void SFlash_Cache_Read_Disable(void); +BL_Err_Type SFlash_Read(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead,uint32_t addr,uint8_t *data,uint32_t len); +BL_Err_Type SFlash_Read_Reg_With_Cmd(SPI_Flash_Cfg_Type *flashCfg,uint8_t readRegCmd,uint8_t *regValue,uint8_t regLen); +BL_Err_Type SFlash_Write_Reg_With_Cmd(SPI_Flash_Cfg_Type *flashCfg,uint8_t writeRegCmd,uint8_t *regValue,uint8_t regLen); +void SF_Cfg_Init_Ext_Flash_Gpio(uint8_t extFlashPin); +void SF_Cfg_Init_Internal_Flash_Gpio(void); +void SF_Cfg_Deinit_Ext_Flash_Gpio(uint8_t extFlashPin); +void SF_Cfg_Restore_GPIO17_Fun(uint8_t fun); +BL_Err_Type SF_Cfg_Get_Flash_Cfg_Need_Lock(uint32_t flashID,SPI_Flash_Cfg_Type *pFlashCfg); +void SF_Cfg_Init_Flash_Gpio(uint8_t flashPinCfg,uint8_t restoreDefault); +uint32_t SF_Cfg_Flash_Identify(uint8_t callFromFlash,uint32_t autoScan,uint32_t flashPinCfg,uint8_t restoreDefault,SPI_Flash_Cfg_Type *pFlashCfg); +void SF_Ctrl_Enable(SF_Ctrl_Cfg_Type *cfg); +void SF_Ctrl_Select_Pad(SF_Ctrl_Pad_Sel sel); +void SF_Ctrl_Set_Owner(SF_Ctrl_Owner_Type owner); +void SF_Ctrl_Disable(void); +void SF_Ctrl_AES_Enable_BE(void); +void SF_Ctrl_AES_Enable_LE(void); +void SF_Ctrl_AES_Set_Region(uint8_t region,uint8_t enable,uint8_t hwKey,uint32_t startAddr,uint32_t endAddr,uint8_t locked); +void SF_Ctrl_AES_Set_Key(uint8_t region,uint8_t *key,SF_Ctrl_AES_Key_Type keyType); +void SF_Ctrl_AES_Set_Key_BE(uint8_t region,uint8_t *key,SF_Ctrl_AES_Key_Type keyType); +void SF_Ctrl_AES_Set_IV(uint8_t region,uint8_t *iv,uint32_t addrOffset); +void SF_Ctrl_AES_Set_IV_BE(uint8_t region,uint8_t *iv,uint32_t addrOffset); +void SF_Ctrl_AES_Enable(void); +void SF_Ctrl_AES_Disable(void); +void SF_Ctrl_Set_Flash_Image_Offset(uint32_t addrOffset); +uint32_t SF_Ctrl_Get_Flash_Image_Offset(void); +void SF_Ctrl_Select_Clock(SF_Ctrl_Sahb_Type sahbType); +void SF_Ctrl_SendCmd(SF_Ctrl_Cmd_Cfg_Type *cfg); +void SF_Ctrl_Icache_Set(SF_Ctrl_Cmd_Cfg_Type *cfg,uint8_t cmdValid); +void SF_Ctrl_Icache2_Set(SF_Ctrl_Cmd_Cfg_Type *cfg,uint8_t cmdValid); +BL_Sts_Type SF_Ctrl_GetBusyState(void); +uint8_t SF_Ctrl_Is_AES_Enable(void); +uint8_t SF_Ctrl_Get_Clock_Delay(void); +void SF_Ctrl_Set_Clock_Delay(uint8_t delay); +BL_Err_Type XIP_SFlash_State_Save(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t *offset); +BL_Err_Type XIP_SFlash_State_Restore(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t offset); +BL_Err_Type XIP_SFlash_Erase_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t startaddr,uint32_t endaddr); +BL_Err_Type XIP_SFlash_Write_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *data,uint32_t len); +BL_Err_Type XIP_SFlash_Read_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *data,uint32_t len); +BL_Err_Type XIP_SFlash_GetJedecId_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint8_t *data); +BL_Err_Type XIP_SFlash_GetDeviceId_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint8_t *data); +BL_Err_Type XIP_SFlash_GetUniqueId_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint8_t *data,uint8_t idLen); +BL_Err_Type XIP_SFlash_Read_Via_Cache_Need_Lock(uint32_t addr,uint8_t *data,uint32_t len); +int XIP_SFlash_Read_With_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *dst,int len); +int XIP_SFlash_Write_With_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *src,int len); +int XIP_SFlash_Erase_With_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,int len); +void XIP_SFlash_Opt_Enter(uint8_t *aesEnable); +void XIP_SFlash_Opt_Exit(uint8_t aesEnable); +uint32_t BFLB_Soft_CRC32(void *dataIn,uint32_t len); +BL_Err_Type ADC_Trim_TSEN(uint16_t *tsen_offset); +BL_Err_Type ADC_Gain_Trim(void); +uint8_t EF_Ctrl_Get_Trim_Parity(uint32_t val,uint8_t len); +void EF_Ctrl_Read_RC32M_Trim(Efuse_Ana_RC32M_Trim_Type *trim); +void EF_Ctrl_Read_RC32K_Trim(Efuse_Ana_RC32K_Trim_Type *trim); +void EF_Ctrl_Read_TSEN_Trim(Efuse_TSEN_Refcode_Corner_Type *trim); +void EF_Ctrl_Read_ADC_Gain_Trim(Efuse_ADC_Gain_Coeff_Type *trim); +BL_Err_Type AON_Power_On_MBG(void); +BL_Err_Type AON_Power_Off_MBG(void); +BL_Err_Type AON_Power_On_XTAL(void); +BL_Err_Type AON_Set_Xtal_CapCode(uint8_t capIn,uint8_t capOut); +uint8_t AON_Get_Xtal_CapCode(void); +BL_Err_Type AON_Power_Off_XTAL(void); +uint8_t EF_Ctrl_Get_Trim_Parity(uint32_t val,uint8_t len); +void EF_Ctrl_Read_RC32M_Trim(Efuse_Ana_RC32M_Trim_Type *trim); +void EF_Ctrl_Read_RC32K_Trim(Efuse_Ana_RC32K_Trim_Type *trim); +GLB_ROOT_CLK_Type GLB_Get_Root_CLK_Sel(void); +BL_Err_Type GLB_Set_System_CLK_Div(uint8_t hclkDiv,uint8_t bclkDiv); +uint8_t GLB_Get_BCLK_Div(void); +uint8_t GLB_Get_HCLK_Div(void); +BL_Err_Type Update_SystemCoreClockWith_XTAL(GLB_PLL_XTAL_Type xtalType); +BL_Err_Type GLB_Set_System_CLK(GLB_PLL_XTAL_Type xtalType,GLB_SYS_CLK_Type clkFreq); +BL_Err_Type System_Core_Clock_Update_From_RC32M(void); +BL_Err_Type GLB_Set_SF_CLK(uint8_t enable,GLB_SFLASH_CLK_Type clkSel,uint8_t div); +BL_Err_Type GLB_Set_PKA_CLK_Sel(GLB_PKA_CLK_Type clkSel); +BL_Err_Type HBN_32K_Sel(HBN_32K_CLK_Type clkType); +BL_Err_Type HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_Type rootClk); +BL_Err_Type HBN_Power_On_Xtal_32K(void); +BL_Err_Type HBN_Power_Off_Xtal_32K(void); +BL_Err_Type HBN_Power_On_RC32K(void); +BL_Err_Type HBN_Power_Off_RC32K(void); +BL_Err_Type HBN_Trim_RC32K(void); +BL_Err_Type PDS_Trim_RC32M(void); +BL_Err_Type PDS_Select_RC32M_As_PLL_Ref(void); +BL_Err_Type PDS_Select_XTAL_As_PLL_Ref(void); +BL_Err_Type PDS_Power_On_PLL(PDS_PLL_XTAL_Type xtalType); +BL_Err_Type PDS_Enable_PLL_All_Clks(void); +BL_Err_Type PDS_Disable_PLL_All_Clks(void); +BL_Err_Type PDS_Enable_PLL_Clk(PDS_PLL_CLK_Type pllClk); +BL_Err_Type PDS_Disable_PLL_Clk(PDS_PLL_CLK_Type pllClk); +BL_Err_Type PDS_Power_Off_PLL(void); + diff --git a/blobs/bl602_demo_wifi.ghidra.c b/blobs/bl602_demo_wifi.ghidra.c new file mode 100755 index 0000000..da67aa1 --- /dev/null +++ b/blobs/bl602_demo_wifi.ghidra.c @@ -0,0 +1,104853 @@ +#include "bl602_demo_wifi.h" + + + +// WARNING: Removing unreachable block (ram,0x230000d8) + +void bl602_start(void) + +{ + uint32_t *puVar1; + undefined4 *puVar2; + int *piVar3; + ipc_shared_env_tag *piVar4; + anon_struct_conflict371 *paVar5; + anon_struct_conflict372 *paVar6; + code *pcVar7; + + puVar2 = (undefined4 *)(ram_heap + 0x1c40); + paVar5 = &boot2_partition_table; + do { + *(undefined4 *)paVar5 = *puVar2; + puVar2 = puVar2 + 1; + paVar5 = (anon_struct_conflict371 *)&paVar5->table; + } while (paVar5 < &boot2_flashCfg); + puVar1 = (uint32_t *)hal_boot2_get_flash_addr(); + paVar6 = &boot2_flashCfg; + do { + paVar6->magic = *puVar1; + puVar1 = puVar1 + 1; + paVar6 = (anon_struct_conflict372 *)&paVar6->flashCfg; + } while (paVar6 < &count); + puVar2 = (undefined4 *)&_bl_static_blogfile_code_end; + pcVar7 = AON_Power_On_BG; + do { + *(undefined4 *)pcVar7 = *puVar2; + puVar2 = puVar2 + 1; + pcVar7 = (code *)&((anon_struct_conflict371 *)pcVar7)->table; + } while (pcVar7 < &boot2_partition_table); + piVar3 = &count; + do { + *piVar3 = 0; + piVar3 = piVar3 + 1; + } while (piVar3 < &__bss_end); + piVar4 = &ipc_shared_env; + do { + (piVar4->msg_a2e_buf).dummy_word = 0; + piVar4 = (ipc_shared_env_tag *)(piVar4->msg_a2e_buf).msg; + } while (piVar4 < (ipc_shared_env_tag *)&_heap_wifi_start); + DAT_42041ff8 = 0x230000e8; + bfl_main(0,0); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +err_t cb_httpc_headers_done_fn + (httpc_state_t *connection,void *arg,pbuf *hdr,u16_t hdr_len,u32_t content_len) + +{ + undefined2 in_register_00002036; + + printf("[HTTPC] hdr_len is %u, content_len is %lu\r\n",CONCAT22(in_register_00002036,hdr_len), + content_len); + return '\0'; +} + + + +void cb_httpc_result(void *arg,httpc_result_t httpc_result,u32_t rx_content_len,u32_t srv_res, + err_t err) + +{ + printf("[HTTPC] Transfer finished. rx_content_len is %lu\r\n",rx_content_len); + *(undefined4 *)arg = 0; + return; +} + + + +err_t cb_altcp_recv_fn(void *arg,altcp_pcb *conn,pbuf *p,err_t err) + +{ + int count; + int iVar1; + uint uVar2; + + puts("."); + iVar1 = count + 1; + uVar2 = count & 0x3f; + count = iVar1; + if (uVar2 == 0) { + puts("\r\n"); + } + altcp_recved(conn,p->tot_len); + pbuf_free(p); + return '\0'; +} + + + +void cmd_stack_wifi(char *buf,int len,int argc,char **argv) + +{ + uint8_t stack_wifi_init; + uint32_t uVar1; + + if (stack_wifi_init == '\x01') { + puts("Wi-Fi Stack Started already!!!\r\n"); + return; + } + stack_wifi_init = '\x01'; + uVar1 = bl_timer_now_us(); + printf("Start Wi-Fi fw @%lums\r\n",uVar1 / 1000); + hal_wifi_start_firmware_task(); + uVar1 = bl_timer_now_us(); + printf("Start Wi-Fi fw is Done @%lums\r\n",uVar1 / 1000); + aos_post_event(2,1,0); + return; +} + + + +void cmd_exception_illegal_ins(char *buf,int len,int argc,char **argv) + +{ + bl_irq_exception_trigger(BL_IRQ_EXCEPTION_TYPE_ILLEGAL_INSTRUCTION,(void *)0x22008001); + return; +} + + + +void cmd_exception_store(char *buf,int len,int argc,char **argv) + +{ + bl_irq_exception_trigger(BL_IRQ_EXCEPTION_TYPE_STORE_MISALIGN,(void *)0x22008001); + return; +} + + + +void cmd_exception_l_illegal(char *buf,int len,int argc,char **argv) + +{ + bl_irq_exception_trigger(BL_IRQ_EXCEPTION_TYPE_ACCESS_ILLEGAL,(void *)0x200000); + return; +} + + + +void cmd_exception_load(char *buf,int len,int argc,char **argv) + +{ + bl_irq_exception_trigger(BL_IRQ_EXCEPTION_TYPE_LOAD_MISALIGN,(void *)0x22008001); + return; +} + + + +void cmd_dma(void) + +{ + bl_dma_item *first; + void *__s; + void *__s_00; + TickType_t TVar1; + + first = (bl_dma_item *)pvPortMalloc(0x1c); + __s = pvPortMalloc(0x44); + __s_00 = pvPortMalloc(0x44); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_dma < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [TEST] [DMA] first %p, src %p, dst %p\r\n",TVar1,&DAT_2307f16c, + "bl_dma.c",0x1af,first,__s,__s_00); + } + memset(first,0,0x1c); + memset(__s,1,0x44); + memset(__s_00,0xff,0x44); + first->ctrl = 0x8c49b011; + *(void **)&first->src = __s; + *(void **)&first->dst = __s_00; + first->next = 0; + first->cb = _cb_cmd; + *(bl_dma_item **)&first->arg = first; + bl_dma_copy(first); + while (first->arg != (void *)0x0) { + vTaskDelay(2); + } + vPortFree((void *)first->src); + vPortFree((void *)first->dst); + vPortFree(first); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +undefined4 cmd_cks(void) + +{ + ushort uVar1; + TickType_t TVar2; + char *format; + undefined *puVar3; + undefined4 uVar4; + int iVar5; + uint uVar6; + uint uVar7; + undefined2 uStack128; + ushort uStack126; + undefined4 uStack124; + undefined4 uStack120; + bl_dma_item bStack116; + undefined auStack88 [4]; + undefined4 uStack84; + undefined4 uStack80; + undefined2 *puStack76; + undefined *puStack72; + undefined **ppuStack68; + undefined4 uStack64; + undefined auStack60 [4]; + undefined4 uStack56; + undefined4 uStack52; + undefined *puStack48; + ushort *puStack44; + undefined4 uStack40; + undefined4 uStack36; + + puStack76 = &uStack128; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] --->>> case1 test\r\n",TVar2,&DAT_2307f16c,"bl_cks.c",0x137); + } + DAT_4000a700 = 1; + iVar5 = 0; + do { + DAT_4000a704 = data_src1_2802[iVar5]; + iVar5 = iVar5 + 1; + } while (iVar5 != 0x14); + uVar6 = (uint)_DAT_4000a708; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] CKS result with LE is %04x, should be %02x%02x\r\n",TVar2, + &DAT_2307f16c,"bl_cks.c",0x40,uVar6,0x61,0xb8); + } + DAT_4000a700 = 2; + iVar5 = 0; + do { + DAT_4000a704 = data_src1_2802[iVar5]; + iVar5 = iVar5 + 1; + } while (iVar5 != 0x14); + uVar6 = (uint)_DAT_4000a708; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] CKS result with BE is %04x, should be %02x%02x\r\n",TVar2, + &DAT_2307f16c,"bl_cks.c",0x48,uVar6,0x61,0xb8); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] --->>> case2 test\r\n",TVar2,&DAT_2307f16c,"bl_cks.c",0x139); + } + } + DAT_4000a700 = 1; + DAT_4000a704 = 0x3f; + uVar6 = (uint)_DAT_4000a708; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] CKS LE result is %04x, %04x\r\n",TVar2,&DAT_2307f16c,"bl_cks.c", + 0x61,uVar6,0xc0e0); + } + uVar1 = _DAT_4000a708; + DAT_4000a700 = 2; + DAT_4000a704 = 0x3f; + uVar6 = (uint)_DAT_4000a708; + if (_fsymc_level_hal_drv < BLOG_LEVEL_WARN) { + if (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] CKS BE result is %04x, %04x\r\n",TVar2,&DAT_2307f16c,"bl_cks.c", + 0x73,uVar6,0xc0e0); + if (uVar1 != 0xc0e0) goto LAB_2303332e; + if ((BLOG_LEVEL_INFO < _fsymc_level_hal_drv) || (BLOG_LEVEL_INFO < _fsymf_level_hal_drvbl_cks) + ) goto LAB_23032c88; + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar6 = 0xc0e0; + uVar4 = 0x75; + format = "[%10u][%s: %s:%4d] ====== Success %04X Checksum=====\r\n"; +LAB_23032c7a: + bl_printk(format,TVar2,&DAT_2307f16c,"bl_cks.c",uVar4,uVar6); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN) + ) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] --->>> case3 test\r\n",TVar2,&DAT_2307f16c,"bl_cks.c",0x13b); + } + } + else { + if (_DAT_4000a708 != 0xc0e0) goto LAB_23033338; + } + } + else { + if (_DAT_4000a708 != 0xc0e0) { +LAB_2303332e: + if (_fsymc_level_hal_drv < BLOG_LEVEL_WARN) { +LAB_23033338: + if (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar4 = 0x77; + format = "[%10u][%s: %s:%4d] ====== Failed %04X Checksum======\r\n"; + goto LAB_23032c7a; + } + } + } + } +LAB_23032c88: + DAT_4000a700 = 1; + iVar5 = 1000; + do { + DAT_4000a704 = 0x3f; + iVar5 = iVar5 + -1; + } while (iVar5 != 0); + uVar6 = 0xf69118; + while (uVar6 >> 0x10 != 0) { + uVar6 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + } + uVar7 = (uint)_DAT_4000a708; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] CKS LE result is %04x, %04x\r\n",TVar2,&DAT_2307f16c,"bl_cks.c", + 0x91,uVar7,~uVar6 & 0xffff); + } + DAT_4000a700 = 2; + iVar5 = 1000; + do { + DAT_4000a704 = 0x3f; + iVar5 = iVar5 + -1; + } while (iVar5 != 0); + uVar6 = 0xf69118; + while (uVar6 >> 0x10 != 0) { + uVar6 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + } + uVar7 = (uint)_DAT_4000a708; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] CKS BE result is %04x, %04x\r\n",TVar2,&DAT_2307f16c,"bl_cks.c", + 0xa3,uVar7,~uVar6 & 0xffff); + } + if (uVar7 == (~uVar6 & 0xffff)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar4 = 0xa5; + puVar3 = &DAT_2307f16c; + format = "[%10u][%s: %s:%4d] ====== Success %04X Checksum=====\r\n"; +LAB_230330f0: + bl_printk(format,TVar2,puVar3,"bl_cks.c",uVar4,uVar7); + goto LAB_230330f4; + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar4 = 0xa7; + puVar3 = &DAT_23072bcc; + format = "[%10u][%s: %s:%4d] ====== Failed %04X Checksum======\r\n"; + goto LAB_230330f0; + } +LAB_230330f4: + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] --->>> case4 test\r\n",TVar2,&DAT_2307f16c,"bl_cks.c",0x13d); + } + } + DAT_4000a700 = 1; + DAT_4000a704 = 0xa1; + uVar6 = (uint)_DAT_4000a708; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] CKS LE result is %04x, %04x\r\n",TVar2,&DAT_2307f16c,"bl_cks.c", + 0xc4,uVar6,0xc03f); + } + uVar1 = _DAT_4000a708; + DAT_4000a700 = 2; + DAT_4000a704 = 0xa1; + uVar6 = (uint)_DAT_4000a708; + if (_fsymc_level_hal_drv < BLOG_LEVEL_WARN) { + if (BLOG_LEVEL_INFO < _fsymf_level_hal_drvbl_cks) { + if (_DAT_4000a708 == 0xc03f) goto LAB_23032ef6; + goto LAB_230332e4; + } + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] CKS BE result is %04x, %04x\r\n",TVar2,&DAT_2307f16c,"bl_cks.c", + 0xd8,uVar6,0xc03f); + if (uVar1 != 0xc03f) goto LAB_230332da; + if ((BLOG_LEVEL_INFO < _fsymc_level_hal_drv) || (BLOG_LEVEL_INFO < _fsymf_level_hal_drvbl_cks)) + goto LAB_23032ef6; + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar6 = 0xc03f; + uVar4 = 0xda; + puVar3 = &DAT_2307f16c; + format = "[%10u][%s: %s:%4d] ====== Success %04X Checksum=====\r\n"; +LAB_230331c2: + bl_printk(format,TVar2,puVar3,"bl_cks.c",uVar4,uVar6); + } + else { + if (_DAT_4000a708 == 0xc03f) goto LAB_23032ef6; +LAB_230332da: + if (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) { +LAB_230332e4: + if (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_ASSERT) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar4 = 0xdc; + puVar3 = &DAT_23072bcc; + format = "[%10u][%s: %s:%4d] ====== Failed %04X Checksum======\r\n"; + goto LAB_230331c2; + } + } + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] --->>> case5 test\r\n",TVar2,&DAT_2307f16c,"bl_cks.c",0x13f); + } +LAB_23032ef6: + bStack116.arg = &bStack116; + uStack128 = 0x3f1f; + uStack124 = 1; + uStack120 = 2; + uStack126 = 0; + memset(bStack116.arg,0,0x1c); + memset(auStack88,0,0x1c); + memset(auStack60,0,0x1c); + bStack116.src = &uStack124; + bStack116.dst = &DAT_4000a700; + bStack116.next = &puStack76; + bStack116.ctrl = 0x4480002; + bStack116.cb = _cb_cmd; + puStack72 = &DAT_4000a704; + puStack48 = &DAT_4000a708; + ppuStack68 = &puStack48; + puStack44 = &uStack126; + uStack64 = 0x403e8; + uStack84 = 0; + uStack80 = 0; + uStack40 = 0; + uStack36 = 0x80240001; + uStack56 = 0; + uStack52 = 0; + bl_dma_copy(bStack116.arg); + while (bStack116.arg != (bl_dma_item *)0x0) { + vTaskDelay(2); + } + if (uStack126 == 0x6df1) { + if (BLOG_LEVEL_INFO < _fsymc_level_hal_drv) { + return 0; + } + if (BLOG_LEVEL_INFO < _fsymf_level_hal_drvbl_cks) { + return 0; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0x12f; + puVar3 = &DAT_2307f16c; + format = "[%10u][%s: %s:%4d] ====== Success %04X Checksum=====\r\n"; + } + else { + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return 0; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvbl_cks) { + return 0; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0x131; + puVar3 = &DAT_23072bcc; + format = "[%10u][%s: %s:%4d] ====== Failed %04X Checksum======\r\n"; + } + bl_printk(format,puVar3,"bl_cks.c",uVar4,(uint)uStack126); + return 0; +} + + + +int cmd_aes(void) + +{ + bl_irq_register(0x1d,bl_sec_aes_IRQHandler); + bl_irq_enable(0x1d); + bl_printk( + "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n" + ); + Sec_Eng_AES_Link_Case_CBC_128(SEC_ENG_AES_ID0); + bl_printk( + "####################################################################################\r\n" + ); + Sec_Eng_AES_Link_Case_CTR_128(SEC_ENG_AES_ID0); + bl_printk( + "####################################################################################\r\n" + ); + Sec_Eng_AES_Link_Case_ECB_128(SEC_ENG_AES_ID0); + bl_printk( + "------------------------------------------------------------------------------------\r\n" + ); + return 0; +} + + + +int cmd_trng(void) + +{ + int iVar1; + + bl_printk("------------------TRNG TEST---------------------------------\r\n"); + iVar1 = bl_rand(); + bl_printk("**********TRNG TEST rand[%08x]**************\r\n",iVar1); + iVar1 = bl_rand(); + bl_printk("**********TRNG TEST rand[%08x]**************\r\n",iVar1); + bl_printk("------------------------------------------------------------\r\n"); + return 0; +} + + + +int cmd_sha(void) + +{ + puts("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n"); + puts("^^^^^^^^^^^^^^^^^^^^^^^SHA256 TEST CASE^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n"); + sha256_test_case0(); + puts("------------------------------------------------------------------------------------\r\n"); + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void cmd_wifi(void) + +{ + uint uVar1; + undefined *puVar2; + int iVar3; + + uVar1 = _DAT_44b000d8; + puts("========================== Keyram Config ========================\r\n"); + printf(" start %02u -->> end %02u; nVAP %02u; max %02u\r\n",uVar1 & 0xff,uVar1 >> 8 & 0xff, + uVar1 >> 0x10 & 0xff,uVar1 >> 0x18); + puts("========================== Keyram Dump =========================\r\n"); + uVar1 = _DAT_44b000d8 >> 8; + puts("[id] MAC Address Key Len VLan ID Default \tKey Hexdump(16Bytes MAX)\r\n"); + iVar3 = 0; + while (iVar3 < (int)(uVar1 & 0xff)) { + blmac_encr_cntrl_pack('\x01','\0',(uint16_t)iVar3,'\0','\0','\0','\0','\0'); + do { + } while ((int)_DAT_44b000c4 < 0); + printf("[%02d] %02X:%02X:%02X:%02X:%02X:%02X",iVar3,_DAT_44b000bc & 0xff, + _DAT_44b000bc >> 8 & 0xff,_DAT_44b000bc >> 0x10 & 0xff,_DAT_44b000bc >> 0x18, + _DAT_44b000c0 & 0xff,_DAT_44b000c0 >> 8 & 0xff); + puVar2 = &UNK_230743ec; + if ((_DAT_44b000c4 & 1) == 0) { + puVar2 = &UNK_230743f4; + } + printf(" %s",puVar2); + iVar3 = iVar3 + 1; + printf(" %02u",_DAT_44b000c4 >> 4 & 0xf); + printf(" %u",_DAT_44b000c4 >> 1 & 1); + printf(" %02X%02X%02X%02X %02X%02X%02X%02X %02X%02X%02X%02X %02X%02X%02X%02X", + _DAT_44b000ac & 0xff,_DAT_44b000ac >> 8 & 0xff,_DAT_44b000ac >> 0x10 & 0xff, + _DAT_44b000ac >> 0x18,_DAT_44b000b0 & 0xff,_DAT_44b000b0 >> 8 & 0xff, + _DAT_44b000b0 >> 0x10 & 0xff); + puts("\r\n"); + } + puts("========================== MAC Address =========================\r\n"); + printf(" MAC %02X:%02X:%02X:%02X:%02X:%02X",_DAT_44b00010 & 0xff,_DAT_44b00010 >> 8 & 0xff, + _DAT_44b00010 >> 0x10 & 0xff,_DAT_44b00010 >> 0x18,_DAT_44b00014 & 0xff, + _DAT_44b00014 >> 8 & 0xff); + printf(" Mask %02X:%02X:%02X:%02X:%02X:%02X",_DAT_44b00018 & 0xff,_DAT_44b00018 >> 8 & 0xff, + _DAT_44b00018 >> 0x10 & 0xff,_DAT_44b00018 >> 0x18,_DAT_44b0001c & 0xff, + _DAT_44b0001c >> 8 & 0xff); + puts("\r\n"); + printf(" BSSID %02X:%02X:%02X:%02X:%02X:%02X",_DAT_44b00020 & 0xff,_DAT_44b00020 >> 8 & 0xff, + _DAT_44b00020 >> 0x10 & 0xff,_DAT_44b00020 >> 0x18,_DAT_44b00024 & 0xff, + _DAT_44b00024 >> 8 & 0xff); + printf(" Mask %02X:%02X:%02X:%02X:%02X:%02X",_DAT_44b00028 >> 8 & 0xff, + _DAT_44b00028 >> 0x10 & 0xff,_DAT_44b00028 >> 0x18,_DAT_44b0002c & 0xff, + _DAT_44b0002c >> 8 & 0xff); + puts("\r\n"); + return; +} + + + +int cmd_pka(void) + +{ + bl_irq_register(0x1b,bl_sec_pka_IRQHandler); + bl_irq_enable(0x1b); + _pka_test_case2(); + _pka_test_case_xgcd(); + _pka_test_case2(); + return 0; +} + + + +void cmd_aws(char *buf,int len,int argc,char **argv) + +{ + xTaskCreate(aws_main_entry,"aws_iot",0x1000,(void *)0x0,10,(TaskHandle_t *)0x0); + return; +} + + + +void proc_hellow_entry(void *pvParameters) + +{ + char "proc_hellow_entry" [18]; + + vTaskDelay(500); + do { + printf("%s: RISC-V rv32imafc\r\n","proc_hellow_entry"); + vTaskDelay(10000); + } while( true ); +} + + + +uchar char_to_hex(char asccode) + +{ + char cVar1; + byte bVar2; + + bVar2 = asccode - 0x30; + if (9 < bVar2) { + if ((byte)(asccode + 0x9fU) < 6) { + cVar1 = -0x57; + } + else { + if (5 < (byte)(asccode + 0xbfU)) { + return '\0'; + } + cVar1 = -0x37; + } + bVar2 = asccode + cVar1; + } + return (uchar)bVar2; +} + + + +void cmd_httpc_test(char *buf,int len,int argc,char **argv) + +{ + if (req_12703 != 0) { + printf("[CLI] req is on-going...\r\n"); + return; + } + memset(settings_12702,0,0x1c); + settings_12702._20_4_ = cb_httpc_result; + settings_12702._24_4_ = cb_httpc_headers_done_fn; + settings_12702[6] = 0; + httpc_get_file_dns("nf.cr.dandanman.com",0x50,"/ddm/ContentResource/music/204.mp3", + (httpc_connection_t_conflict *)settings_12702,cb_altcp_recv_fn,&req_12703, + (httpc_state_t **)&req_12703); + return; +} + + + +int get_dts_addr(char *name) + +{ + TickType_t TVar1; + + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %s NULL.\r\n",TVar1,&DAT_23072bcc,&UNK_23072bc4,0x322,name); + return -1; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +int client_demo(void) + +{ + uint uVar1; + hostent *phVar2; + char *__format; + int s; + int iVar3; + TickType_t TVar4; + void *mem; + uint uVar5; + TickType_t TVar6; + char cVar7; + ip4_addr_t iStack308; + uint32_t address; + sockaddr_in dest; + char wbuf [111]; + char buffer [128]; + + phVar2 = lwip_gethostbyname("nf.cr.dandanman.com"); + if (phVar2 == (hostent *)0x0) { + __format = "gethostbyname Failed\r\n"; + } + else { + s = lwip_socket(2,1,0); + if (s < 0) { + __format = "Error in socket\r\n"; + } + else { + memset(&address,0,0x10); + address._1_1_ = '\x02'; + address._2_2_ = lwip_htons(0x50); + iStack308 = (ip4_addr_t)((ip4_addr_t *)((ip4_addr_t *)phVar2->h_addr_list)->addr)->addr; + dest._0_4_ = iStack308; + __format = ip4addr_ntoa(&iStack308); + printf("Server ip Address : %s\r\n",__format); + iVar3 = lwip_connect(s,(sockaddr *)&address,0x10); + if (iVar3 == 0) { + memset(wbuf + 0x6c,0,0x80); + memcpy(dest.sin_zero + 4, + + "GET /ddm/ContentResource/music/204.mp3 HTTP/1.1\r\nHost: nf.cr.dandanman.com\r\nUser-Agent: wmsdk\r\nAccept: */*\r\n\r\n" + ,0x6f); + lwip_write(s,dest.sin_zero + 4,0x6e); + TVar4 = xTaskGetTickCount(); + mem = pvPortMalloc(0x3000); + if (mem != (void *)0x0) { + uVar1 = 0; + cVar7 = '\0'; + do { + uVar5 = lwip_read(s,mem,0x3000); + if (uVar5 == 0) { + printf("eof\n\r",0); + goto LAB_230006f2; + } + if ((int)uVar5 < 0) { + __format = "ret = %d, err = %d\n\r"; + uVar1 = errno; + goto LAB_23000718; + } + uVar1 = uVar1 + uVar5; + if (cVar7 == '\0') { + printf("total = %d, ret = %d\n\r",uVar1,uVar5); + } + cVar7 = cVar7 + '\x01'; + } while ((int)uVar1 < 0x4e3fbd1); + TVar6 = xTaskGetTickCount(); + uVar5 = (TVar6 - TVar4) / 1000; + __format = "Download comlete, total time %u s, speed %u Kbps\r\n"; + uVar1 = (uVar1 / uVar5 << 3) / 1000; +LAB_23000718: + printf(__format,uVar5,uVar1); +LAB_230006f2: + vPortFree(mem); + } + lwip_close(s); + return 0; + } + __format = "Error in connect\r\n"; + } + } + printf(__format); + return -1; +} + + + +// WARNING: Type propagation algorithm not settling + +int http_test_cmd(void) + +{ + uint uVar1; + hostent *phVar2; + char *__format; + int s; + int iVar3; + TickType_t TVar4; + void *mem; + uint uVar5; + TickType_t TVar6; + char cVar7; + ip4_addr_t iStack308; + undefined uStack304; + sa_family_t sStack303; + u16_t uStack302; + ip4_addr_t iStack300; + undefined auStack288 [112]; + undefined auStack176 [136]; + + phVar2 = lwip_gethostbyname("nf.cr.dandanman.com"); + if (phVar2 == (hostent *)0x0) { + __format = "gethostbyname Failed\r\n"; + } + else { + s = lwip_socket(2,1,0); + if (s < 0) { + __format = "Error in socket\r\n"; + } + else { + memset(&uStack304,0,0x10); + sStack303 = '\x02'; + uStack302 = lwip_htons(0x50); + iStack308 = (ip4_addr_t)((ip4_addr_t *)((ip4_addr_t *)phVar2->h_addr_list)->addr)->addr; + iStack300 = iStack308; + __format = ip4addr_ntoa(&iStack308); + printf("Server ip Address : %s\r\n",__format); + iVar3 = lwip_connect(s,(sockaddr *)&uStack304,0x10); + if (iVar3 == 0) { + memset(auStack176,0,0x80); + memcpy(auStack288, + + "GET /ddm/ContentResource/music/204.mp3 HTTP/1.1\r\nHost: nf.cr.dandanman.com\r\nUser-Agent: wmsdk\r\nAccept: */*\r\n\r\n" + ,0x6f); + lwip_write(s,auStack288,0x6e); + TVar4 = xTaskGetTickCount(); + mem = pvPortMalloc(0x3000); + if (mem != (void *)0x0) { + uVar1 = 0; + cVar7 = '\0'; + do { + uVar5 = lwip_read(s,mem,0x3000); + if (uVar5 == 0) { + printf("eof\n\r",0); + goto LAB_230006f2; + } + if ((int)uVar5 < 0) { + __format = "ret = %d, err = %d\n\r"; + uVar1 = errno; + goto LAB_23000718; + } + uVar1 = uVar1 + uVar5; + if (cVar7 == '\0') { + printf("total = %d, ret = %d\n\r",uVar1,uVar5); + } + cVar7 = cVar7 + '\x01'; + } while ((int)uVar1 < 0x4e3fbd1); + TVar6 = xTaskGetTickCount(); + uVar5 = (TVar6 - TVar4) / 1000; + __format = "Download comlete, total time %u s, speed %u Kbps\r\n"; + uVar1 = (uVar1 / uVar5 << 3) / 1000; +LAB_23000718: + printf(__format,uVar5,uVar1); +LAB_230006f2: + vPortFree(mem); + } + lwip_close(s); + return 0; + } + __format = "Error in connect\r\n"; + } + } + printf(__format); + return -1; +} + + + +void aos_loop_proc(void *pvParameters) + +{ + StackType_t proc_stack_looprt [512]; + StaticTask_t proc_task_looprt; + void *fdt; + void *fdt_00; + int sock; + aos_poll_call_t *cb; + void *pvVar1; + void *pvVar2; + + looprt_start((StackType_t *)&ram0x4200f8e0,0x200,(StaticTask_t *)&ram0x420100e0); + loopset_led_hook_on_looprt(); + easyflash_init(); + vfs_init(); + vfs_device_init(); + fdt = (void *)hal_board_get_factory_addr(); + fdt_00 = (void *)fdt_subnode_offset(fdt,0,"uart"); + if (fdt_00 == (void *)0x0) { + sock = get_dts_addr("uart"); + fdt = fdt_00; + pvVar2 = (void *)0x0; + if (sock != 0) goto LAB_230007c6; + fdt = (void *)0x0; + } + vfs_uart_init(fdt,fdt_00); + pvVar2 = fdt_00; +LAB_230007c6: + fdt_00 = (void *)hal_board_get_factory_addr(); + pvVar1 = (void *)fdt_subnode_offset(fdt_00,0,"gpio"); + if ((pvVar1 != (void *)0x0) || + (sock = get_dts_addr("gpio"), fdt_00 = fdt, pvVar1 = pvVar2, sock == 0)) { + hal_gpio_init_from_dts(fdt_00,pvVar1); + } + romfs_register(); + aos_loop_init(); + sock = aos_open("/dev/ttyS0",0); + if (-1 < sock) { + printf("Init CLI with event Driven\r\n"); + aos_cli_init(0); + cb = (aos_poll_call_t *)aos_cli_event_cb_read_get(); + aos_poll_read_fd(sock,cb,(void *)0x12345678); + codex_debug_cli_init(); + easyflash_cli_init(); + network_netutils_iperf_cli_register(); + network_netutils_tcpserver_cli_register(); + network_netutils_tcpclinet_cli_register(); + network_netutils_netstat_cli_register(); + network_netutils_ping_cli_register(); + sntp_cli_init(); + bl_sys_time_cli_init(); + bl_sys_ota_cli_init(); + blfdt_cli_init(); + wifi_mgmr_cli_init(); + bl_wdt_cli_init(); + bl_gpio_cli_init(); + looprt_test_cli_init(); + } + aos_register_event_filter(2,event_cb_wifi_event,(void *)0x0); + cmd_stack_wifi((char *)0x0,0,0,(char **)0x0); + aos_loop_run(); + puts("------------------------------------------\r\n"); + puts("+++++++++Critical Exit From Loop++++++++++\r\n"); + puts("******************************************\r\n"); + vTaskDelete((TaskHandle_t)0x0); + return; +} + + + +void vApplicationStackOverflowHook(TaskHandle_t xTask,char *pcTaskName) + +{ + puts("Stack Overflow checked\r\n"); + printf("Task Name %s\r\n",pcTaskName); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void vApplicationMallocFailedHook(void) + +{ + size_t sVar1; + + sVar1 = xPortGetFreeHeapSize(); + printf("Memory Allocate Failed. Current left size is %d bytes\r\n",sVar1); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void vApplicationIdleHook(void) + +{ + return; +} + + + +// WARNING: Variable defined which should be unmapped: sta_info + +int check_dts_config(char *ssid,char *password) + +{ + int iVar1; + int iVar2; + undefined auStack116 [4]; + bl_wifi_ap_info_t sta_info; + + iVar2 = bl_wifi_sta_info_get((bl_wifi_ap_info_t *)auStack116); + iVar1 = -1; + if (iVar2 == 0) { + strncpy(ssid,auStack116,0x20); + ssid[0x1f] = '\0'; + strncpy(password,(char *)(sta_info.ssid + 0x1d),0x40); + password[0x3f] = '\0'; + iVar1 = iVar2; + } + return iVar1; +} + + + +void _connect_wifi(undefined4 param_1) + +{ + bool bVar1; + int iVar2; + uint8_t *puVar3; + char *__dest; + uchar uVar4; + uchar uVar5; + wifi_interface_t pvVar6; + char *password_00; + size_t ssid_len; + size_t sVar7; + size_t sVar8; + undefined3 extraout_var; + char *__src; + uint16_t freq; + int iVar9; + uint uVar10; + int iVar11; + char *__dest_00; + longlong lVar12; + byte abStack340 [4]; + uint8_t mac [6]; + char chan [10]; + char bssid [32]; + char ssid [33]; + char pmk [66]; + char password [66]; + char val_buf [66]; + + pvVar6 = wifi_mgmr_sta_enable(); + wifi_interface = pvVar6; + lVar12 = aos_now_ms(); + __dest = ssid + 0x20; + printf( + "[APP] [WIFI] [T] %lld\r\n[APP] Get STA %p from Wi-Fi Mgmr, pmk ptr %p, ssid ptr %p, password %p\r\n" + ,pvVar6,param_1,wifi_interface,__dest,bssid + 0x1c,pmk + 0x40,(int)lVar12); + memset(__dest,0,0x42); + memset(bssid + 0x1c,0,0x21); + memset(pmk + 0x40,0,0x42); + __dest_00 = chan + 8; + memset(__dest_00,0,0x20); + memset(abStack340,0,6); + memset(mac + 4,0,10); + memset(password + 0x40,0,0x42); + ef_get_env_blob("conf_ap_ssid",password + 0x40,0x41,(size_t *)0x0); + if (password[64] == '\0') { + password_00 = pmk + 0x40; + sVar7 = check_dts_config(bssid + 0x1c,password_00); + freq = 0; + if (sVar7 != 0) { + puts("[APP] Empty Config\r\n"); + puts("[APP] Try to set the following ENV with psm_set command, then reboot\r\n"); + puts("[APP] NOTE: conf_ap_pmk MUST be psm_unset when conf is changed\r\n"); + puts("[APP] env: conf_ap_ssid\r\n"); + puts("[APP] env: conf_ap_psk\r\n"); + puts("[APP] env(optinal): conf_ap_pmk\r\n"); + return; + } + goto LAB_23000b88; + } + strncpy(bssid + 0x1c,password + 0x40,0x20); + memset(password + 0x40,0,0x42); + ef_get_env_blob("conf_ap_psk",password + 0x40,0x41,(size_t *)0x0); + if (password[64] != '\0') { + strncpy(pmk + 0x40,password + 0x40,0x41); + } + memset(password + 0x40,0,0x42); + __src = password + 0x40; + password_00 = (char *)ef_get_env_blob("conf_ap_pmk",__src,0x41,(size_t *)0x0); + if (password[64] != '\0') { + __src = password + 0x40; + password_00 = strncpy(__dest,__src,0x41); + } + if (ssid[32] == '\0') { + lVar12 = aos_now_ms(); + printf("[APP] [WIFI] [T] %lld\r\n",password_00,__src,(int)lVar12); + puts("[APP] Re-cal pmk\r\n"); + ssid_len = strlen(bssid + 0x1c); + wifi_mgmr_psk_cal(pmk + 0x40,bssid + 0x1c,ssid_len,__dest); + ef_set_env("conf_ap_pmk",__dest); + ef_save_env(); + } + memset(password + 0x40,0,0x42); + ef_get_env_blob("conf_ap_channel",password + 0x40,0x41,(size_t *)0x0); + if (password[64] == '\0') { +LAB_23000b00: + freq = 0; + uVar4 = '\0'; + } + else { + strncpy((char *)(mac + 4),password + 0x40,9); + printf("connect wifi channel = %s\r\n",mac + 4); + password_00 = strchr((char *)(mac + 4),0x7c); + if (password_00 + 1 == (char *)0x0) goto LAB_23000b00; + iVar11 = 1; + iVar9 = 0; + uVar4 = char_to_hex(password_00[1]); + ssid_len = strlen((char *)(mac + 4)); + sVar8 = strlen(password_00 + 1); + iVar2 = ssid_len - sVar8; + mac[iVar2 + 3] = '\0'; + uVar10 = 0; + puVar3 = mac + iVar2 + 4; + while( true ) { + freq = (uint16_t)uVar10; + if (iVar2 + -1 <= iVar9) break; + iVar9 = iVar9 + 1; + uVar5 = char_to_hex(puVar3[-2]); + uVar10 = uVar10 + CONCAT31(extraout_var,uVar5) * iVar11 & 0xffff; + iVar11 = iVar11 * 10; + puVar3 = puVar3 + -1; + } + } + memset(password + 0x40,0,0x42); + password_00 = password + 0x40; + sVar7 = ef_get_env_blob("conf_ap_bssid",password_00,0x41,(size_t *)0x0); + bVar1 = password[64] != '\0'; + password[64] = uVar4; + if (bVar1) { + strncpy(__dest_00,password + 0x40,0x1f); + printf("connect wifi bssid = %s\r\n",__dest_00); + ssid_len = strlen(__dest_00); + if ((ssid_len & 1) != 0) { + ssid_len = ssid_len - (int)ssid_len % 2; + } + if (ssid_len != 0) { + uVar10 = 0; + while ((int)uVar10 < (int)ssid_len) { + uVar4 = char_to_hex(*__dest_00); + uVar5 = char_to_hex(__dest_00[1]); + abStack340[uVar10 >> 1] = uVar4 * '\x10' + uVar5; + uVar10 = uVar10 + 2; + __dest_00 = __dest_00 + 2; + } + } + password_00 = (char *)(uint)abStack340[0]; + sVar7 = printf("mac = %02X:%02X:%02X:%02X:%02X:%02X\r\n",(uint)abStack340[1],(uint)abStack340[2] + ,(uint)abStack340[3],(uint)mac[0],(uint)mac[1]); + } +LAB_23000b88: + aos_now_ms(); + ssid_len = strlen(bssid + 0x1c); + sVar8 = strlen(pmk + 0x40); + printf( + "[APP] [WIFI] [T] %lld\r\n[APP] SSID %s\r\n[APP] SSID len %d\r\n[APP] password %s\r\n[APP] password len %d\r\n[APP] pmk %s\r\n[APP] bssid %s\r\n[APP] channel band %d\r\n[APP] channel freq %d\r\n" + ,sVar7,password_00,bssid + 0x1c,ssid_len,pmk + 0x40,sVar8); + wifi_mgmr_sta_connect + ((wifi_interface_t *)wifi_interface,bssid + 0x1c,pmk + 0x40,__dest,abStack340, + password[64],freq); + return; +} + + + +void event_cb_wifi_event(input_event_t *event,void *private_data) + +{ + ushort uVar1; + char *password; + char *ssid; + ulong *puVar2; + uint32_t uVar3; + char *__format; + size_t sVar4; + wifi_interface_t *wifi_interface; + input_event_t *piVar5; + char *__format_00; + undefined4 uVar6; + longlong lVar7; + + uVar1 = event->code; + piVar5 = event; + switch((uint)uVar1 - 1 & 0xffff) { + case 0: + lVar7 = aos_now_ms(); + printf("[APP] [EVT] INIT DONE %lld\r\n",event,private_data,(int)lVar7); + wifi_mgmr_start_background(&conf); + return; + case 1: + aos_now_ms(); + uVar3 = bl_timer_now_us(); + printf("[APP] [EVT] MGMR DONE %lld, now %lums\r\n",event,private_data,uVar3 / 1000); + _connect_wifi(); + return; + case 2: + lVar7 = aos_now_ms(); + uVar6 = (undefined4)lVar7; + __format = "[APP] [EVT] Reconnect %lld\r\n"; + break; + case 3: + case 5: + lVar7 = aos_now_ms(); + uVar6 = (undefined4)lVar7; + __format = "[APP] [EVT] connected %lld\r\n"; + break; + case 4: + aos_now_ms(); + __format = wifi_mgmr_status_code_str(*(uint16_t *)&event->value); + __format_00 = "[APP] [EVT] disconnect %lld, Reason: %s\r\n"; + goto LAB_23000dee; + case 6: + lVar7 = aos_now_ms(); + printf("[APP] [EVT] GOT IP %lld\r\n",event,private_data,(int)lVar7); + sVar4 = xPortGetFreeHeapSize(); + printf("[SYS] Memory left is %d Bytes\r\n",sVar4); + return; + case 7: + lVar7 = aos_now_ms(); + uVar6 = (undefined4)lVar7; + __format = "[APP] [EVT] Connecting %lld\r\n"; + break; + case 8: + lVar7 = aos_now_ms(); + printf("[APP] [EVT] SCAN Done %lld\r\n",event,private_data,(int)lVar7); + wifi_mgmr_cli_scanlist(); + return; + case 9: + lVar7 = aos_now_ms(); + uVar6 = (undefined4)lVar7; + __format = "[APP] [EVT] SCAN On Join %lld\r\n"; + break; + default: + lVar7 = aos_now_ms(); + printf("[APP] [EVT] Unknown code %u, %lld\r\n",(uint)uVar1,event,private_data,(int)lVar7); + return; + case 0xc: + lVar7 = aos_now_ms(); + __format = (char *)event->value; + if (__format == (char *)0x0) { + __format = "UNKNOWN"; + } + printf("[APP] [EVT] [PROV] [SSID] %lld: %s\r\n",piVar5,private_data,__format,(int)lVar7); + puVar2 = (ulong *)0x4200dc84; + password = ssid; + goto LAB_23000eaa; + case 0xd: + lVar7 = aos_now_ms(); + __format = (char *)event->value; + if (__format == (char *)0x0) { + __format = "UNKNOWN"; + } + printf("[APP] [EVT] [PROV] [BSSID] %lld: %s\r\n",piVar5,private_data,__format,(int)lVar7); + if ((void *)event->value == (void *)0x0) { + return; + } + vPortFree((void *)event->value); + return; + case 0xe: + lVar7 = aos_now_ms(); + __format = (char *)event->value; + if (__format == (char *)0x0) { + __format = "UNKNOWN"; + } + printf("[APP] [EVT] [PROV] [PASSWD] %lld: %s\r\n",piVar5,private_data,__format,(int)lVar7); + puVar2 = (ulong *)0x4200dc7c; +LAB_23000eaa: + if (password != (char *)0x0) { + vPortFree(password); + } + *puVar2 = event->value; + return; + case 0xf: + lVar7 = aos_now_ms(); + printf("[APP] [EVT] [PROV] [CONNECT] %lld\r\n",event,private_data,(int)lVar7); + printf("connecting to %s:%s...\r\n",ssid,password); + wifi_interface = (wifi_interface_t *)wifi_mgmr_sta_enable(); + wifi_mgmr_sta_connect(wifi_interface,ssid,password,(char *)0x0,(uint8_t *)0x0,'\0',0); + return; + case 0x10: + lVar7 = aos_now_ms(); + uVar6 = (undefined4)lVar7; + __format = "[APP] [EVT] [PROV] [DISCONNECT] %lld\r\n"; + break; + case 0x13: + lVar7 = aos_now_ms(); + uVar6 = (undefined4)lVar7; + __format = "[APP] [EVT] Microwave Denoise is ON %lld\r\n"; + break; + case 0x14: + aos_now_ms(); + __format = (char *)event->value; + __format_00 = "[APP] [EVT] [AP] [ADD] %lld, sta idx is %lu\r\n"; + goto LAB_23000dee; + case 0x15: + aos_now_ms(); + __format = (char *)event->value; + __format_00 = "[APP] [EVT] [AP] [DEL] %lld, sta idx is %lu\r\n"; +LAB_23000dee: + printf(__format_00,piVar5,private_data,__format); + return; + case 0x16: + lVar7 = aos_now_ms(); + printf("[APP] [EVT] EMERGENCY MAC %lld\r\n",event,private_data,(int)lVar7); + hal_reboot(); + return; + } + printf(__format,event,private_data,uVar6); + return; +} + + + +void vApplicationGetIdleTaskMemory + (StaticTask_t **ppxIdleTaskTCBBuffer,StackType_t **ppxIdleTaskStackBuffer, + uint32_t *pulIdleTaskStackSize) + +{ + StackType_t uxIdleTaskStack [96]; + StaticTask_t xIdleTaskTCB; + + *ppxIdleTaskTCBBuffer = (StaticTask_t *)&ram0x4201091c; + *ppxIdleTaskStackBuffer = (StackType_t *)&ram0x4201015c; + *pulIdleTaskStackSize = 0x60; + return; +} + + + +void vApplicationGetTimerTaskMemory + (StaticTask_t **ppxTimerTaskTCBBuffer,StackType_t **ppxTimerTaskStackBuffer, + uint32_t *pulTimerTaskStackSize) + +{ + StackType_t uxTimerTaskStack [400]; + StaticTask_t xTimerTaskTCB; + + *ppxTimerTaskTCBBuffer = (StaticTask_t *)&ram0x4201097c; + *ppxTimerTaskStackBuffer = (StackType_t *)&ram0x420102dc; + *pulTimerTaskStackSize = 400; + return; +} + + + +// WARNING: Removing unreachable block (ram,0x23001014) + +void vAssertCalled(void) + +{ + uint32_t ulSetTo1ToExitFunction; + + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +// WARNING: Variable defined which should be unmapped: chip_feature + +void bfl_main(void) + +{ + StackType_t aos_loop_proc_stack [1024]; + StaticTask_t aos_loop_proc_task; + StackType_t proc_hellow_stack [512]; + StaticTask_t proc_hellow_task; + int iVar1; + char *pcStack60; + char *banner; + char chip_feature [40]; + + time_main = bl_timer_now_us(); + bl_uart_init('\0','\x10','\a',-1,-1,(uint32_t)&DAT_001e8480); + puts("Starting bl602 now....\r\n"); + puts("Booting BL602 Chip...\r\n"); + iVar1 = bl_chip_banner(&pcStack60); + if (iVar1 == 0) { + puts(pcStack60); + } + puts("\r\n"); + puts("\r\n"); + puts("------------------------------------------------------------\r\n"); + puts("RISC-V Core Feature:"); + bl_chip_info((char *)&banner); + puts((char *)&banner); + puts("\r\n"); + puts("Build Version: "); + puts("release_bl_iot_sdk_1.6.11-1-g66bb28da-dirty"); + puts("\r\n"); + puts("PHY Version: "); + puts("a0_final-44-geb7fadd"); + puts("\r\n"); + puts("RF Version: "); + puts("f76e39a"); + puts("\r\n"); + puts("Build Date: "); + puts("Oct 30 2020"); + puts("\r\n"); + puts("Build Time: "); + puts("00:08:24"); + puts("\r\n"); + puts("------------------------------------------------------------\r\n"); + vPortDefineHeapRegions(xHeapRegions); + printf("Heap %u@%p, %u@%p\r\n",&_heap_size,&__bss_end,0x860,&_heap_wifi_start); + printf("Boot2 consumed %lums\r\n",time_main / 1000); + blog_init(); + bl_irq_init(); + bl_sec_init(); + bl_sec_test(); + bl_dma_init(); + hal_boot2_init(); + hal_board_cfg(0); + puts("[OS] Starting proc_hellow_entry task...\r\n"); + xTaskCreateStatic(proc_hellow_entry,"hellow",0x200,(void *)0x0,0xf,(StackType_t *)&ram0x4200f080, + (StaticTask_t *)&ram0x4200f880); + puts("[OS] Starting aos_loop_proc task...\r\n"); + xTaskCreateStatic(aos_loop_proc,"event_loop",0x400,(void *)0x0,0xf,(StackType_t *)&ram0x4200e020, + (StaticTask_t *)&ram0x4200f020); + puts("[OS] Starting TCP/IP Stack...\r\n"); + tcpip_init((tcpip_init_done_fn)0x0,(void *)0x0); + puts("[OS] Starting OS Scheduler...\r\n"); + vTaskStartScheduler(); + return; +} + + + +void ShadowUpdateStatusCallback + (char *pThingName,ShadowActions_t action,Shadow_Ack_Status_t status, + char *pReceivedJsonDocument,void *pContextData) + +{ + char *__format; + undefined3 in_register_00002031; + int iVar1; + + iVar1 = CONCAT31(in_register_00002031,status); + shadowUpdateInProgress = false; + if (iVar1 == 0) { + __format = "Update timed out\r\n"; + } + else { + if (iVar1 == 1) { + __format = "Update rejected\r\n"; + } + else { + if (iVar1 != 2) { + shadowUpdateInProgress = false; + return; + } + __format = "Update accepted\r\n"; + } + } + printf(__format); + return; +} + + + +void windowActuate_Callback(char *pJsonString,uint32_t JsonStringDataLen,jsonStruct_t *pContext) + +{ + if (pContext != (jsonStruct_t *)0x0) { + printf("Delta - Window state changed to %d\r\n",(uint)*(byte *)pContext->pData); + return; + } + return; +} + + +/* +Unable to decompile 'aws_main_entry' +Cause: Pcode: XML comms: Invalid storage: Unsupported varnode size: -1 +*/ + + +void cmd_coex_dump(char *buf,int len,int argc,char **argv) + +{ + coex_dump_pta(); + coex_dump_wifi(); + return; +} + + + +int codex_debug_cli_init(void) + +{ + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_rx_filter_set(void) + +{ + _DAT_44b00060 = mm_env.rx_filter_lmac_enable | mm_env.rx_filter_umac; + return; +} + + + +int element_notify_status_enabled + (cfg_element_entry *entry,void *arg1,void *arg2,CFG_ELEMENT_TYPE_OPS ops) + +{ + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_ap_setf(uint8_t ap) + +{ + undefined3 in_register_00002029; + + _DAT_44b0004c = CONCAT31(in_register_00002029,ap) << 1 | _DAT_44b0004c & 0xfffffffd; + return; +} + + + +uchar ascii_to_hex(char asccode) + +{ + char cVar1; + byte bVar2; + + bVar2 = asccode - 0x30; + if (9 < bVar2) { + if ((byte)(asccode + 0x9fU) < 6) { + cVar1 = -0x57; + } + else { + if (5 < (byte)(asccode + 0xbfU)) { + return '\0'; + } + cVar1 = -0x37; + } + bVar2 = asccode + cVar1; + } + return (uchar)bVar2; +} + + + +undefined4 element_notify_time_last_received_set(void) + +{ + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_encr_cntrl_pack + (uint8_t newread,uint8_t newwrite,uint16_t keyindexram,uint8_t ctyperam, + uint8_t vlanidram,uint8_t sppram,uint8_t usedefkeyram,uint8_t clenram) + +{ + uint uVar1; + undefined3 in_register_00002035; + undefined3 in_register_00002039; + undefined3 in_register_0000203d; + undefined3 in_register_00002041; + undefined3 in_register_00002045; + uint uVar2; + + uVar2 = CONCAT31(in_register_00002039,vlanidram) << 4; + if ((uVar2 & 0xffffff0f) != 0) { + assert_err("(((uint32_t)vlanidram << 4) & ~((uint32_t)0x000000F0)) == 0","module",0x1873); + } + uVar1 = CONCAT31(in_register_0000203d,sppram) << 2; + if ((uVar1 & 0xfffffff3) != 0) { + assert_err("(((uint32_t)sppram << 2) & ~((uint32_t)0x0000000C)) == 0","module",0x1874); + } + _DAT_44b000c4 = + (uint)newread << 0x1f | CONCAT31(in_register_00002045,clenram) | + CONCAT31(in_register_00002041,usedefkeyram) << 1 | uVar1 | uVar2 | + CONCAT31(in_register_00002035,ctyperam) << 8 | (uint)keyindexram << 0x10 | + (uint)newwrite << 0x1e; + return; +} + + + +undefined4 element_notify_keepalive_received(void) + +{ + return 0; +} + + + +// WARNING: Removing unreachable block (ram,0x23001bd8) +// WARNING: Removing unreachable block (ram,0x23001be2) +// WARNING: Removing unreachable block (ram,0x23001c0a) +// WARNING: Removing unreachable block (ram,0x23001bfe) +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t hal_machw_rx_duration(rx_hd *rhd,uint16_t len) + +{ + if ((""[rhd->recvec1a >> 0xc & 0xf] & 0x80) != 0) { + assert_err("(((uint32_t)ppdumcsindex << 0) & ~((uint32_t)0x0000007F)) == 0","module",0x1a99); + } + do { + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_env_max_ampdu_duration_set(void) + +{ + mm_env.ampdu_max_dur[0] = 0x96; + if (((_DAT_44b00200 >> 0xc & 0xffff) != 0) && ((_DAT_44b00200 >> 0xc & 0xffff) < 0x97)) { + mm_env.ampdu_max_dur[0] = (uint16_t)(_DAT_44b00200 >> 0xc); + } + mm_env.ampdu_max_dur[1] = 0x96; + if (((_DAT_44b00204 >> 0xc & 0xffff) != 0) && ((_DAT_44b00204 >> 0xc & 0xffff) < 0x97)) { + mm_env.ampdu_max_dur[1] = (uint16_t)(_DAT_44b00204 >> 0xc); + } + mm_env.ampdu_max_dur[2] = 0x96; + if (((_DAT_44b00208 >> 0xc & 0xffff) != 0) && ((_DAT_44b00208 >> 0xc & 0xffff) < 0x97)) { + mm_env.ampdu_max_dur[2] = (uint16_t)(_DAT_44b00208 >> 0xc); + } + mm_env.ampdu_max_dur[3] = 0x96; + if (((_DAT_44b0020c >> 0xc & 0xffff) != 0) && ((_DAT_44b0020c >> 0xc & 0xffff) < 0x97)) { + mm_env.ampdu_max_dur[3] = (uint16_t)(_DAT_44b0020c >> 0xc); + } + mm_env.ampdu_max_dur[4] = mm_env.ampdu_max_dur[3]; + return; +} + + + +void mm_env_init(void) + +{ + memset(&mm_env,0,0x2c); + mm_env._34_2_ = 0x101; + mm_env._18_2_ = 0; + mm_env.rx_filter_lmac_enable = 0; + mm_env.rx_filter_umac = 0x7fffffde; + mm_rx_filter_set(); + mm_env_max_ampdu_duration_set(); + return; +} + + + +void mm_init(void) + +{ + hal_machw_init(); + mm_env_init(); + vif_mgmt_init(); + sta_mgmt_init(); + td_init(); + ps_init(); + txl_cntrl_init(); + rxl_init(); + mm_timer_init(); + scan_init(); + chan_init(); + hal_dma_init(); + mm_bcn_init(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_active(void) + +{ + _DAT_44b00038 = 0x30; + ke_state_set(0,1); + return; +} + + + +void mm_reset(void) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(0); + if (CONCAT22(extraout_var,kVar1) == 1) { + mm_active(); + return; + } + ke_state_set(0,0); + return; +} + + +/* +Unable to decompile 'mm_tbtt_evt' +Cause: Exception while decompiling 23001d94: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t mm_sec_machwaddr_wr(uint8_t sta_idx,uint8_t inst_nbr) + +{ + uint uVar1; + undefined3 in_register_00002029; + int iVar2; + + iVar2 = CONCAT31(in_register_00002029,sta_idx); + uVar1 = iVar2 + 8U & 0xff; + _DAT_44b000bc = *(undefined4 *)sta_info_tab[iVar2].mac_addr.array; + _DAT_44b000c0 = (uint)sta_info_tab[iVar2].mac_addr.array[2]; + _DAT_44b000ac = 0; + _DAT_44b000b0 = 0; + _DAT_44b000b4 = 0; + _DAT_44b000b8 = 0; + blmac_encr_cntrl_pack('\0','\x01',(uint16_t)uVar1,'\0',inst_nbr,'\0','\x01','\0'); + do { + } while (_DAT_44b000c4 << 1 < 0); + return (uint8_t)uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_sec_keydump(void) + +{ + uint uVar1; + undefined *puVar2; + int iVar3; + + uVar1 = _DAT_44b000d8; + puts("========================== Keyram Config ========================\r\n"); + printf(" start %02u -->> end %02u; nVAP %02u; max %02u\r\n",uVar1 & 0xff,uVar1 >> 8 & 0xff, + uVar1 >> 0x10 & 0xff,uVar1 >> 0x18); + puts("========================== Keyram Dump =========================\r\n"); + uVar1 = _DAT_44b000d8 >> 8; + puts("[id] MAC Address Key Len VLan ID Default \tKey Hexdump(16Bytes MAX)\r\n"); + iVar3 = 0; + while (iVar3 < (int)(uVar1 & 0xff)) { + blmac_encr_cntrl_pack('\x01','\0',(uint16_t)iVar3,'\0','\0','\0','\0','\0'); + do { + } while ((int)_DAT_44b000c4 < 0); + printf("[%02d] %02X:%02X:%02X:%02X:%02X:%02X",iVar3,_DAT_44b000bc & 0xff, + _DAT_44b000bc >> 8 & 0xff,_DAT_44b000bc >> 0x10 & 0xff,_DAT_44b000bc >> 0x18, + _DAT_44b000c0 & 0xff,_DAT_44b000c0 >> 8 & 0xff); + puVar2 = &UNK_230743ec; + if ((_DAT_44b000c4 & 1) == 0) { + puVar2 = &UNK_230743f4; + } + printf(" %s",puVar2); + iVar3 = iVar3 + 1; + printf(" %02u",_DAT_44b000c4 >> 4 & 0xf); + printf(" %u",_DAT_44b000c4 >> 1 & 1); + printf(" %02X%02X%02X%02X %02X%02X%02X%02X %02X%02X%02X%02X %02X%02X%02X%02X", + _DAT_44b000ac & 0xff,_DAT_44b000ac >> 8 & 0xff,_DAT_44b000ac >> 0x10 & 0xff, + _DAT_44b000ac >> 0x18,_DAT_44b000b0 & 0xff,_DAT_44b000b0 >> 8 & 0xff, + _DAT_44b000b0 >> 0x10 & 0xff); + puts("\r\n"); + } + puts("========================== MAC Address =========================\r\n"); + printf(" MAC %02X:%02X:%02X:%02X:%02X:%02X",_DAT_44b00010 & 0xff,_DAT_44b00010 >> 8 & 0xff, + _DAT_44b00010 >> 0x10 & 0xff,_DAT_44b00010 >> 0x18,_DAT_44b00014 & 0xff, + _DAT_44b00014 >> 8 & 0xff); + printf(" Mask %02X:%02X:%02X:%02X:%02X:%02X",_DAT_44b00018 & 0xff,_DAT_44b00018 >> 8 & 0xff, + _DAT_44b00018 >> 0x10 & 0xff,_DAT_44b00018 >> 0x18,_DAT_44b0001c & 0xff, + _DAT_44b0001c >> 8 & 0xff); + puts("\r\n"); + printf(" BSSID %02X:%02X:%02X:%02X:%02X:%02X",_DAT_44b00020 & 0xff,_DAT_44b00020 >> 8 & 0xff, + _DAT_44b00020 >> 0x10 & 0xff,_DAT_44b00020 >> 0x18,_DAT_44b00024 & 0xff, + _DAT_44b00024 >> 8 & 0xff); + printf(" Mask %02X:%02X:%02X:%02X:%02X:%02X",_DAT_44b00028 >> 8 & 0xff, + _DAT_44b00028 >> 0x10 & 0xff,_DAT_44b00028 >> 0x18,_DAT_44b0002c & 0xff, + _DAT_44b0002c >> 8 & 0xff); + puts("\r\n"); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t mm_sec_machwkey_wr(mm_key_add_req *param) + +{ + byte bVar1; + byte vlanidram; + uint16_t keyindexram; + uint uVar2; + uint8_t ctyperam; + uint8_t clenram; + uint uVar3; + + bVar1 = param->sta_idx; + uVar3 = (uint)bVar1; + vlanidram = param->inst_nbr; + if (bVar1 == 0xff) { + uVar3 = (uint)vlanidram * 4 + (uint)param->key_idx & 0xff; + keyindexram = (uint16_t)uVar3; + _DAT_44b000bc = 0xffffffff; + _DAT_44b000c0 = 0xffffffff; + vif_mgmt_add_key(param,(uint8_t)uVar3); + } + else { + if (0xb < bVar1) { + assert_err("sta_idx < STA_MAX","module",0x3e4); + } + uVar2 = uVar3 + 8 & 0xff; + keyindexram = (uint16_t)uVar2; + sta_mgmt_add_key(param,(uint8_t)uVar2); + _DAT_44b000bc = *(undefined4 *)sta_info_tab[uVar3].mac_addr.array; + _DAT_44b000c0 = (uint)sta_info_tab[uVar3].mac_addr.array[2]; + } + bVar1 = param->cipher_suite; + if (bVar1 < 4) { + clenram = *(uint8_t *)((int)&CSWTCH_22 + (uint)bVar1); + ctyperam = *(uint8_t *)((int)&CSWTCH_23 + (uint)bVar1); + } + else { + assert_err("0","module",0x429); + ctyperam = '\0'; + clenram = '\x01'; + } + _DAT_44b000ac = (param->key).array[0]; + _DAT_44b000b0 = (param->key).array[1]; + _DAT_44b000b4 = (param->key).array[2]; + _DAT_44b000b8 = (param->key).array[3]; + blmac_encr_cntrl_pack('\0','\x01',keyindexram,ctyperam,vlanidram,param->spp,'\0',clenram); + do { + } while (_DAT_44b000c4 << 1 < 0); + return (uint8_t)keyindexram; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_sec_machwkey_del(uint8_t hw_key_idx) + +{ + undefined3 in_register_00002029; + uint uVar1; + uint uVar2; + + uVar1 = CONCAT31(in_register_00002029,hw_key_idx); + if (uVar1 < 8) { + _DAT_44b000bc = 0xffffffff; + _DAT_44b000c0 = 0xffffffff; + vif_mgmt_del_key(vif_info_tab + ((int)uVar1 >> 2),hw_key_idx & 3); + } + else { + uVar2 = uVar1 - 8 & 0xff; + _DAT_44b000bc = *(undefined4 *)sta_info_tab[uVar2].mac_addr.array; + _DAT_44b000c0 = (uint)sta_info_tab[uVar2].mac_addr.array[2]; + sta_mgmt_del_key(sta_info_tab + uVar2); + } + _DAT_44b000ac = 0; + _DAT_44b000b0 = 0; + _DAT_44b000b4 = 0; + _DAT_44b000b8 = 0; + blmac_encr_cntrl_pack('\0','\x01',(uint16_t)uVar1,'\0','\0','\0','\0','\0'); + do { + } while (_DAT_44b000c4 << 1 < 0); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_sec_machwaddr_del(uint8_t sta_idx) + +{ + _DAT_44b000bc = 0xffffffff; + _DAT_44b000c0 = 0xffffffff; + _DAT_44b000ac = 0; + _DAT_44b000b0 = 0; + _DAT_44b000b4 = 0; + _DAT_44b000b8 = 0; + blmac_encr_cntrl_pack('\0','\x01',(ushort)sta_idx + 8 & 0xff,'\0','\0','\0','\0','\0'); + do { + } while (_DAT_44b000c4 << 1 < 0); + return; +} + + + +void mm_hw_idle_evt(int dummy) + +{ + ke_evt_clear(0x800000); + ke_state_set(0,0); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_hw_info_set(mac_addr *mac_addr) + +{ + blmac_ap_setf('\0'); + _DAT_44b0001c = 0x100; + _DAT_44b080a4 = 0; + _DAT_44b080a8 = 0; + _DAT_44b00010 = *(undefined4 *)mac_addr->array; + _DAT_44b00014 = (uint)mac_addr->array[2]; + _DAT_44b0004c = _DAT_44b0004c & 0xfffff8ff | 1; + mm_env.rx_filter_umac = 0x3503858c; + mm_rx_filter_set(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_hw_ap_info_set(void) + +{ + blmac_ap_setf('\x01'); + mm_env.rx_filter_umac = 0x3507a58c; + mm_rx_filter_set(); + _DAT_44b08070 = 0x40001; + _DAT_44b08074 = _DAT_44b08074 | 0x40001; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_hw_ap_info_reset(void) + +{ + blmac_ap_setf('\0'); + mm_env.rx_filter_umac = 0x3503858c; + mm_rx_filter_set(); + _DAT_44b08070 = 0x40001; + _DAT_44b08074 = _DAT_44b08074 & 0xfffbfffe; + return; +} + + + +void mm_back_to_host_idle(void) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(0); + if (CONCAT22(extraout_var,kVar1) != 3) { + assert_err("ke_state_get(TASK_MM) == MM_HOST_BYPASSED","module",0x52a); + } + if (mm_env.host_idle == '\0') { + mm_active(); + return; + } + ke_state_set(0,0); + return; +} + + +/* +Unable to decompile 'mm_force_idle_req' +Cause: Exception while decompiling 2300251e: Decompiler process died + +*/ + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +uint8_t mm_sta_add(mm_sta_add_req *param,uint8_t *sta_idx,uint8_t *hw_sta_idx) + +{ + uint uVar1; + uint8_t uVar2; + uint8_t uVar3; + uchar uVar4; + uchar uVar5; + undefined3 extraout_var; + size_t sVar6; + int security_mode; + uint8_t *phrase; + int iVar7; + int iVar8; + _Bool is_pmf_required; + uint uVar9; + undefined2 uStack92; + mm_key_add_req key_add_req; + + uVar2 = sta_mgmt_register(param,sta_idx); + if (CONCAT31(extraout_var,uVar2) != 0) { + return uVar2; + } + uVar1 = (uint)param->inst_nbr; + uVar3 = mm_sec_machwaddr_wr(*sta_idx,param->inst_nbr); + *hw_sta_idx = uVar3; + if (vif_info_tab[uVar1].type != '\0') { + return uVar2; + } + if (vif_info_tab[uVar1].bss_info.is_supplicant_enabled == false) goto LAB_230025a4; + sta_conn_info.staId = *sta_idx; + if ((*(uint *)&vif_info_tab[uVar1].bss_info.is_supplicant_enabled & 0x12800) == 0) { + if ((*(byte *)&vif_info_tab[uVar1].bss_info.wpa_wpa2_wep & 2) != 0) { + sVar6 = strlen((char *)(sm_env.connect_param)->phrase); + printf("wep:len:%d,password:%s\n",sVar6,(sm_env.connect_param)->phrase); + memset(&uStack92,0,0x2c); + key_add_req.key.array[7]._1_1_ = param->inst_nbr; + uStack92 = 0xff00; + sVar6 = strlen((char *)(sm_env.connect_param)->phrase); + uVar9 = sVar6 & 0xff; + key_add_req.key_idx = (uint8_t)uVar9; + if (uVar9 == 5) { + key_add_req.key.array[7]._0_1_ = '\0'; +LAB_230026d8: + memcpy(&key_add_req.key,(sm_env.connect_param)->phrase,sVar6 & 0xff); + } + else { + if (uVar9 == 0xd) { + key_add_req.key.array[7]._0_1_ = '\x03'; + goto LAB_230026d8; + } + if (uVar9 == 10) { + key_add_req.key.array[7]._0_1_ = '\0'; + } + else { + if (uVar9 != 0x1a) { + printf("password length is not correct for wep\n"); + sta_mgmt_unregister(*sta_idx); + return '\x01'; + } + key_add_req.key.array[7]._0_1_ = '\x03'; + } + uVar9 = sVar6 & 0xff; + if ((sVar6 & 1) != 0) { + uVar9 = sVar6 & 0xfe; + } + if (uVar9 != 0) { + iVar7 = 0; + phrase = (sm_env.connect_param)->phrase; + do { + uVar4 = ascii_to_hex(*phrase); + uVar5 = ascii_to_hex(phrase[1]); + (&key_add_req.key.length)[iVar7 >> 1] = uVar4 * '\x10' + uVar5; + iVar7 = iVar7 + 2; + phrase = phrase + 2; + } while (iVar7 < (int)uVar9); + } + key_add_req.key_idx = key_add_req.key_idx >> 1; + } + wep_hw_keyid = mm_sec_machwkey_wr((mm_key_add_req *)&uStack92); + } + } + else { + if ((sm_env.connect_param)->phrase_pmk[0] == '\0') { + phrase = (sm_env.connect_param)->phrase; + } + else { + phrase = (sm_env.connect_param)->phrase_pmk; + } + set_psk((char *)vif_info_tab[uVar1].bss_info.ssid.array,vif_info_tab[uVar1].bss_info.ssid.length + ,(char *)phrase); + } + iVar7 = uVar1 * 0x5d8; + if ((*(uint *)&vif_info_tab[uVar1].bss_info.is_supplicant_enabled & 0x12000) == 0) { + if ((*(byte *)&vif_info_tab[uVar1].bss_info.wpa_wpa2_wep & 8) != 0) { + iVar8 = iVar7 + 0x3ec; + iVar7 = iVar7 + 0x3eb; + is_pmf_required = vif_info_tab[uVar1].bss_info.is_pmf_required; + security_mode = 3; + goto LAB_2300263a; + } + } + else { + is_pmf_required = vif_info_tab[uVar1].bss_info.is_pmf_required; + iVar8 = iVar7 + 0x3ee; + iVar7 = iVar7 + 0x3ed; + security_mode = 4; +LAB_2300263a: + supplicantEnable(&sta_conn_info,security_mode, + (void *)((int)&vif_info_tab[0].list_hdr.next + iVar7), + (void *)((int)&vif_info_tab[0].list_hdr.next + iVar8),is_pmf_required); + } + if (vif_info_tab[uVar1].type != '\0') { + return uVar2; + } +LAB_230025a4: + vif_info_tab[uVar1].u[4] = *sta_idx; + return '\0'; +} + + + +void mm_sta_del(uint8_t sta_idx) + +{ + uint uVar1; + undefined3 in_register_00002029; + undefined *puVar2; + byte bVar3; + uint uVar4; + + uVar4 = (uint)sta_info_tab[CONCAT31(in_register_00002029,sta_idx)].inst_nbr; + if (vif_info_tab[uVar4].type == '\0') { + vif_info_tab[uVar4].u[4] = 0xff; + if (vif_info_tab[uVar4].bss_info.is_supplicant_enabled != false) { + if ((*(uint *)&vif_info_tab[uVar4].bss_info.is_supplicant_enabled & 0x12800) == 0) { + if (((*(byte *)&vif_info_tab[uVar4].bss_info.wpa_wpa2_wep & 2) != 0) && (wep_hw_keyid != -1) + ) { + mm_sec_machwkey_del(wep_hw_keyid); + } + } + else { + mm_sec_machwkey_del(sta_conn_info.ptkHwKeyId); + mm_sec_machwkey_del(sta_conn_info.gtkHwKeyId); + mm_sec_machwkey_del(sta_conn_info.mfpHwKeyId); + supplicantDisable(&sta_conn_info); + memset(&(sta_conn_info.suppData)->hashSsId,0,0x22); + remove_psk((char *)vif_info_tab[uVar4].bss_info.ssid.array, + vif_info_tab[uVar4].bss_info.ssid.length); + } + vif_info_tab[uVar4].bss_info.is_supplicant_enabled = false; + } + } + else { + if ((sta_info_tab[CONCAT31(in_register_00002029,sta_idx)].ps_state == '\x01') && + (bVar3 = vif_info_tab[uVar4].u[0x2ee] - 1, vif_info_tab[uVar4].u[0x2ee] = bVar3, bVar3 == 0)) + { + uVar1 = (uint)vif_info_tab[uVar4].index + 10 & 0xff; + puVar2 = (undefined *)ke_msg_alloc(0x49,0xd,0,2); + sta_info_tab[uVar1].ps_state = '\0'; + *puVar2 = (char)uVar1; + puVar2[1] = 0; + ke_msg_send(); + apm_tx_int_ps_clear(vif_info_tab + uVar4,vif_info_tab[uVar4].index + '\n'); + } + } + mm_sec_machwaddr_del(sta_idx); + sta_mgmt_unregister(sta_idx); + return; +} + + + +void mm_cfg_element_keepalive_timestamp_update(void) + +{ + mm_env.keep_alive_time_last_received = xTaskGetTickCount(); + mm_env.keep_alive_packet_counter = mm_env.keep_alive_packet_counter + 1; + return; +} + + + +void mm_send_connection_loss_ind(vif_info_tag *p_vif_entry) + +{ + uint8_t *puVar1; + + puVar1 = (uint8_t *)ke_msg_alloc(0x43,6,0,1); + *puVar1 = p_vif_entry->index; + ke_msg_send(); + return; +} + + + +void mm_ap_probe_cfm(void *env,uint32_t status) + +{ + if ((int)(status << 8) < 0) { + *(undefined *)((int)env + 0x74) = 0; + return; + } + mm_send_connection_loss_ind((vif_info_tag *)env); + return; +} + + + +// WARNING: Variable defined which should be unmapped: cur_us +// WARNING: Could not reconcile some variable overlaps + +void mm_check_rssi(vif_info_tag *vif_entry,int8_t rssi) + +{ + byte bVar1; + uint8_t uVar2; + int iVar3; + uint8_t *puVar4; + undefined3 in_register_0000202d; + int iVar5; + uint uVar6; + bool bVar7; + int iVar8; + uint uStack40; + longlong cur_us; + + iVar5 = CONCAT31(in_register_0000202d,rssi); + iVar8 = (int)(char)vif_entry->u[0x19]; + iVar3 = (int)(char)vif_entry->u[0x1a]; + bVar1 = vif_entry->u[0x1b]; + bVar7 = (bool)vif_entry->u[0x1c]; + vif_entry->u[0x19] = rssi; + uStack40 = 0; + cur_us._0_4_ = 0; + bl60x_current_time_us((longlong *)&uStack40); + if (iVar8 != 0) { + uVar6 = (uint)(uStack40 < uStack40 - (uint)last_us); + if (((int)(((int)cur_us - last_us._4_4_) - uVar6) < 1) && + (((int)cur_us - last_us._4_4_ != uVar6 || (uStack40 - (uint)last_us < 0x1e8481)))) + goto LAB_230029d6; + } + puVar4 = (uint8_t *)ke_msg_alloc(0x57,0xd,0,3); + uVar2 = vif_entry->index; + *(bool *)(puVar4 + 1) = bVar7; + puVar4[2] = rssi; + *puVar4 = uVar2; + last_us._0_4_ = uStack40; + last_us._4_4_ = (int)cur_us; + ke_msg_send(); +LAB_230029d6: + if (iVar3 != 0) { + if (bVar7 == false) { + if (iVar5 < iVar8) { + bVar7 = iVar5 < iVar3 - (char)bVar1; + } + } + else { + if (iVar8 < iVar5) { + bVar7 = iVar5 <= iVar3 + (char)bVar1; + } + } + if ((bool)vif_entry->u[0x1c] != bVar7) { + puVar4 = (uint8_t *)ke_msg_alloc(0x57,0xd,0,3); + uVar2 = vif_entry->index; + *(bool *)(puVar4 + 1) = bVar7; + puVar4[2] = rssi; + *puVar4 = uVar2; + ke_msg_send(); + } + *(bool *)(vif_entry->u + 0x1c) = bVar7; + } + return; +} + + + +void mm_send_csa_traffic_ind(uint8_t vif_index,_Bool enable) + +{ + uint8_t *puVar1; + + puVar1 = (uint8_t *)ke_msg_alloc(0x59,0xd,0,2); + *puVar1 = vif_index; + *(_Bool *)(puVar1 + 1) = enable; + ke_msg_send(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint mm_check_beacon(rx_hd *param_1,vif_info_tag *param_2,int param_3,char **param_4) + +{ + ushort len; + ushort uVar1; + ushort uVar2; + uint uVar3; + int iVar4; + uint8_t uVar5; + undefined3 extraout_var; + uint32_t crc; + uint32_t uVar6; + uint32_t uVar7; + uint uVar8; + uint uVar9; + char *pcVar10; + uint uVar11; + int iVar12; + int iVar13; + uint len_00; + int iVar14; + uint uVar15; + + len = param_1->frmlen; + iVar13 = *(int *)(param_1->first_pbd_ptr + 8); + param_2->u[0x18] = 0; + beacon_rx_count = beacon_rx_count + 1; + iVar14 = *(int *)(param_2->u + 0x14); + if (param_2->u[0x1e] != 0) { + mm_send_csa_traffic_ind(param_2->index,true); + param_2->u[0x1e] = 0; + } + if ((((30000000 - _DAT_44b00120) + *(int *)(param_2->u + 0x10) < 0) && + (mm_env.keep_alive_status_enabled != false)) && + (uVar5 = txl_frame_send_null_frame(param_2->u[4],(cfm_func_ptr *)0x0,(void *)0x0), + CONCAT31(extraout_var,uVar5) == 0)) { + *(int *)(param_2->u + 0x10) = _DAT_44b00120; + } + uVar3 = (uint)len - 0x24; + mm_check_rssi(param_2,*(int8_t *)((int)¶m_1->recvec1c + 3)); + crc = co_crc32(iVar13 + 0x20,4,0); + pcVar10 = (char *)(iVar13 + 0x24); + *param_4 = (char *)0x0; + while (uVar3 = uVar3 & 0xffff, 1 < uVar3) { + len_00 = (uint)(byte)pcVar10[1]; + if (uVar3 <= len_00 + 1) break; + if (*pcVar10 == '\x05') { + *param_4 = pcVar10; + } + else { + crc = co_crc32((uint32_t)(pcVar10 + 2),len_00,crc); + } + uVar3 = uVar3 + (-2 - len_00); + pcVar10 = pcVar10 + 2 + len_00; + } + *(uint32_t *)(param_2->u + 0x14) = crc; + uVar1 = *(ushort *)(param_3 + 0x16); + uVar2 = *(ushort *)(iVar13 + 0x20); + uVar3 = *(uint *)(iVar13 + 0x18); + crc = param_1->tsflo; + iVar4 = (uint)uVar2 * 0x400; + iVar13 = *(int *)(iVar13 + 0x1c); + len_00 = (uint)*(ushort *)param_2->u; + if (*(ushort *)param_2->u == 0) { + pcVar10 = *param_4; + len_00 = 1; + if ((pcVar10 != (char *)0x0) && (len_00 = (uint)(byte)pcVar10[2], pcVar10[2] == 0)) { + len_00 = (uint)(byte)pcVar10[3]; + } + } + uVar6 = hal_machw_rx_duration(param_1,len); + uVar7 = hal_machw_rx_duration(param_1,0x18); + uVar8 = uVar3; + iVar12 = iVar13; + __udivdi3(); + uVar11 = uVar3 - uVar7; + uVar15 = iVar13 - (uint)(uVar3 < uVar11); + uVar9 = iVar12 * iVar4 + (int)((ulonglong)uVar8 * (ulonglong)uVar2 * 0x400 >> 0x20); + if ((uVar9 < uVar15) || ((uVar15 == uVar9 && (uVar8 * iVar4 < uVar11)))) { + uVar11 = uVar8 * iVar4; + } + iVar12 = ((uVar11 + len_00 * iVar4) - ((uVar3 - crc) + (uVar6 - uVar7))) - uVar1 * len_00; + iVar13 = iVar12 + -400; + if (iVar12 + (-0xc80 - _DAT_44b00120) < 0) { + iVar13 = iVar13 + iVar4; + } + crc = (_DAT_44b00120 - _DAT_44b080a4) + iVar13; + if (crc != (param_2->tbtt_timer).time) { + mm_timer_set(¶m_2->tbtt_timer,crc); + } + return (uint)(*(int *)(param_2->u + 0x14) != iVar14); +} + + + +void mm_sta_tbtt(void *env) + +{ + uint32_t value; + _Bool _Var1; + undefined3 extraout_var; + byte bVar2; + + if (*(char *)((int)env + 0x58) == '\0') { + return; + } + if (*(char *)((int)env + 0x79) != '\0') { + bVar2 = *(char *)((int)env + 0x79) - 1; + *(byte *)((int)env + 0x79) = bVar2; + if (bVar2 < 2) { + vif_mgmt_switch_channel((vif_info_tag *)env); + return; + } + if (bVar2 == 2) { + mm_send_csa_traffic_ind(*(uint8_t *)((int)env + 0x57),false); + } + } + value = sta_info_tab[*(byte *)((int)env + 0x60)].bcn_int + *(int *)((int)env + 0x24); + mm_timer_set((mm_timer_tag *)((int)env + 0x18),value); + vif_mgmt_bcn_to_prog((vif_info_tag *)env); + chan_tbtt_switch_update((vif_info_tag *)env,value); + _Var1 = chan_is_on_channel((vif_info_tag *)env); + if (CONCAT31(extraout_var,_Var1) != 0) { + *(uint *)((int)env + 4) = *(uint *)((int)env + 4) | 1; + bVar2 = *(char *)((int)env + 0x74) + 1; + *(byte *)((int)env + 0x74) = bVar2; + if (100 < bVar2) { + txl_frame_send_null_frame(*(uint8_t *)((int)env + 0x60),mm_ap_probe_cfm,env); + return; + } + if (bVar2 == 100) { + chan_bcn_detect_start((vif_info_tag *)env); + return; + } + } + return; +} + + + +uint16_t mm_get_rsn_wpa_ie(uint8_t sta_id,uint8_t *wpa_ie) + +{ + undefined3 in_register_00002029; + uint uVar1; + + uVar1 = (uint)sta_info_tab[CONCAT31(in_register_00002029,sta_id)].inst_nbr; + memcpy(wpa_ie,vif_info_tab[uVar1].bss_info.rsn_wpa_ie, + (uint)vif_info_tab[uVar1].bss_info.rsn_wpa_ie_len); + return (uint16_t)(ushort)vif_info_tab[uVar1].bss_info.rsn_wpa_ie_len; +} + + + +void mm_tim_update_proceed(ushort *param_1) + +{ + byte bVar1; + ushort uVar2; + uint uVar3; + uint8_t *puVar4; + uint uVar5; + int iVar6; + uint uVar7; + int iVar8; + uint uVar9; + uint uVar10; + uint uVar11; + byte *pbVar12; + + uVar2 = *param_1; + uVar9 = (uint)*(byte *)((int)param_1 + 3); + if (uVar2 == 0) { + if (*(char *)(param_1 + 1) == '\0') { + vif_info_tab[uVar9].u[0x2ea] = 0; + } + else { + vif_info_tab[uVar9].u[0x2ea] = 1; + } + } + else { + iVar8 = uVar9 * 8; + uVar10 = (uint)(uVar2 >> 3); + uVar11 = uVar10 & 0xff; + puVar4 = txl_tim_bitmap_pool + uVar9 * 0xfc; + pbVar12 = puVar4 + uVar11; + bVar1 = *pbVar12; + uVar7 = 1 << ((uint)uVar2 & 7); + uVar5 = uVar7 & 0xff; + uVar3 = uVar5 & bVar1; + if (*(char *)(param_1 + 1) == '\0') { + if (uVar3 != 0) { + *pbVar12 = ~(byte)uVar7 & bVar1; + uVar3 = (uint)*(ushort *)(vif_info_tab[uVar9].u + 0x2e0) - 1; + *(short *)(vif_info_tab[uVar9].u + 0x2e0) = (short)(uVar3 * 0x10000 >> 0x10); + if ((uVar3 & 0xffff) == 0) { + *(undefined2 *)(vif_info_tab[uVar9].u + 0x2de) = 6; + *(undefined2 *)(vif_info_tab[uVar9].u + 0x2e8) = 0xff; + bVar1 = vif_info_tab[uVar9].u[0x2de]; + txl_tim_ie_pool[iVar8 + 4] = '\0'; + txl_tim_ie_pool[iVar8 + 1] = bVar1 - 2; + txl_tim_desc[uVar9 * 2].dataendptr = iVar8 + 0x42047365; + *(tx_pbd **)&txl_tim_desc[uVar9 * 2].next = txl_bcn_end_desc + *(byte *)((int)param_1 + 3) + ; + *(uint8_t **)&txl_tim_desc[uVar9 * 2 + 1].dataendptr = + puVar4 + vif_info_tab[uVar9].u[0x2e9]; + } + else { + if ((uint)vif_info_tab[uVar9].u[0x2e8] == (uVar10 & 0xfe)) { + while( true ) { + bVar1 = vif_info_tab[uVar9].u[0x2e8]; + if ((bVar1 == 0xfb) || (puVar4[(uint)bVar1] != '\0')) break; + vif_info_tab[uVar9].u[0x2e8] = bVar1 + 1; + } + uVar3 = (uint)bVar1 & 0xfe; + vif_info_tab[uVar9].u[0x2e8] = (byte)uVar3; + *(uint8_t **)&txl_tim_desc[uVar9 * 2 + 1].datastartptr = puVar4 + uVar3; + } + if ((uint)vif_info_tab[uVar9].u[0x2e9] == uVar11) { + while( true ) { + bVar1 = vif_info_tab[uVar9].u[0x2e9]; + if ((bVar1 == 0) || (puVar4[bVar1] != '\0')) break; + vif_info_tab[uVar9].u[0x2e9] = bVar1 - 1; + } + *(uint8_t **)&txl_tim_desc[uVar9 * 2 + 1].dataendptr = puVar4 + bVar1; + } + iVar6 = (((uint)vif_info_tab[uVar9].u[0x2e9] + 6) - (uint)vif_info_tab[uVar9].u[0x2e8]) * + 0x10000; + *(short *)(vif_info_tab[uVar9].u + 0x2de) = (short)((uint)iVar6 >> 0x10); + txl_tim_ie_pool[iVar8 + 1] = (char)((uint)iVar6 >> 0x10) + -2; + txl_tim_ie_pool[iVar8 + 4] = vif_info_tab[uVar9].u[0x2e8]; + } + } + } + else { + if (uVar3 == 0) { + *pbVar12 = (byte)uVar5 | bVar1; + bVar1 = vif_info_tab[uVar9].u[0x2e8]; + *(short *)(vif_info_tab[uVar9].u + 0x2e0) = *(short *)(vif_info_tab[uVar9].u + 0x2e0) + 1; + if (uVar11 < bVar1) { + vif_info_tab[uVar9].u[0x2e8] = (byte)(uVar10 & 0xfe); + *(uint8_t **)&txl_tim_desc[uVar9 * 2 + 1].datastartptr = puVar4 + (uVar10 & 0xfe); + } + if (vif_info_tab[uVar9].u[0x2e9] < uVar11) { + vif_info_tab[uVar9].u[0x2e9] = (byte)uVar11; + *(byte **)&txl_tim_desc[uVar9 * 2 + 1].dataendptr = pbVar12; + } + iVar6 = (((uint)vif_info_tab[uVar9].u[0x2e9] + 6) - (uint)vif_info_tab[uVar9].u[0x2e8]) * + 0x10000; + *(short *)(vif_info_tab[uVar9].u + 0x2de) = (short)((uint)iVar6 >> 0x10); + txl_tim_ie_pool[iVar8 + 1] = (char)((uint)iVar6 >> 0x10) + -2; + txl_tim_ie_pool[iVar8 + 4] = vif_info_tab[uVar9].u[0x2e8]; + txl_tim_desc[uVar9 * 2].dataendptr = iVar8 + 0x42047364; + txl_tim_desc[uVar9 * 2].next = uVar9 * 0x28 + 0x42047aa4; + } + } + } + ke_msg_send_basic(0x42,param_1[-2],0); + ke_msg_free(param_1 + -6); + return; +} + + + +void mm_bcn_init(void) + +{ + memset(&mm_bcn_env,0,0x24); + mm_bcn_env.dma.dma_desc = &bcn_dwnld_desc; + mm_bcn_env.dma.cb = mm_bcn_updated; + co_list_init(&mm_bcn_env.tim_list); + return; +} + + + +void mm_bcn_init_vif(vif_info_tag *vif_entry) + +{ + byte bVar1; + tx_pbd *ptVar2; + uint uVar3; + int iVar4; + + uVar3 = (uint)vif_entry->index; + txl_frame_init_desc((txl_frame_desc_tag *)(vif_entry->u + 4), + (txl_buffer_tag *)(txl_bcn_pool + uVar3 * 0xd3),txl_bcn_hwdesc_pool + uVar3, + txl_bcn_buf_ctrl + uVar3); + txl_bcn_hwdesc_pool[uVar3].cfm_ptr = txl_bcn_hwdesc_cfms + vif_entry->index; + uVar3 = (uint)vif_entry->index; + iVar4 = uVar3 * 8; + vif_entry->u[0x2e7] = 0; + *(undefined2 *)(vif_entry->u + 0x2e0) = 0; + vif_entry->u[0x2ea] = 0; + *(undefined2 *)(vif_entry->u + 0x2de) = 6; + *(undefined2 *)(vif_entry->u + 0x2e8) = 0xff; + txl_tim_desc[uVar3 * 2].dataendptr = iVar4 + 0x42047365; + txl_tim_desc[uVar3 * 2].upatterntx = 0xcafefade; + *(uint8_t **)&txl_tim_desc[uVar3 * 2].datastartptr = txl_tim_ie_pool + iVar4; + txl_tim_desc[uVar3 * 2].bufctrlinfo = 0; + ptVar2 = txl_bcn_end_desc + uVar3; + *(tx_pbd **)&txl_tim_desc[uVar3 * 2].next = ptVar2; + txl_tim_ie_pool[iVar4] = '\x05'; + txl_tim_ie_pool[iVar4 + 1] = '\x04'; + bVar1 = vif_entry->u[0x2e7]; + txl_tim_ie_pool[iVar4 + 4] = '\0'; + txl_tim_ie_pool[iVar4 + 2] = bVar1; + txl_tim_ie_pool[iVar4 + 3] = '\x01'; + txl_tim_ie_pool[iVar4 + 5] = -1; + txl_tim_desc[uVar3 * 2 + 1].upatterntx = 0xcafefade; + bVar1 = vif_entry->u[0x2e9]; + *(tx_pbd **)&txl_tim_desc[uVar3 * 2 + 1].next = ptVar2; + *(uint8_t **)&txl_tim_desc[uVar3 * 2 + 1].dataendptr = txl_tim_bitmap_pool + uVar3 * 0xfc + bVar1; + memset(txl_tim_bitmap_pool + uVar3 * 0xfc,0,0xfc); + ptVar2->upatterntx = 0xcafefade; + txl_bcn_end_desc[uVar3].next = 0; + txl_bcn_end_desc[uVar3].bufctrlinfo = 0; + iVar4 = *(int *)(vif_entry->u + 0x70); + *(undefined4 *)(iVar4 + 0x24) = 0; + *(undefined4 *)(iVar4 + 0x3c) = 0; + *(undefined4 *)(iVar4 + 0x10) = 0; + *(undefined4 *)(vif_entry->u + 0x2d0) = 0x2300362e; + *(vif_info_tag **)(vif_entry->u + 0x2d4) = vif_entry; + return; +} + + + +void mm_tim_update(mm_tim_update_req *param) + +{ + if (mm_bcn_env.tx_cfm != 0) { + co_list_push_back(&mm_bcn_env.tim_list,(co_list_hdr *)(param + -3)); + return; + } + mm_tim_update_proceed(); + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void mm_bcn_transmit(void) + +{ + byte bVar1; + uint8_t uVar2; + uint8_t uVar3; + vif_info_tag *vif; + txl_frame_desc_tag *frame; + _Bool _Var4; + undefined3 extraout_var; + char *pcVar5; + undefined3 extraout_var_00; + uint8_t *puVar6; + int iVar7; + byte bVar8; + uint uVar9; + char cVar10; + int iVar11; + + vif = (vif_info_tag *)vif_mgmt_env.used_list.first; + if (mm_bcn_env.tx_cfm != 0) { + assert_err("!mm_bcn_env.tx_cfm","module",0x339); + } + if (mm_bcn_env.update_ongoing == false) { + mm_bcn_env.tx_pending = false; + while (vif != (vif_info_tag *)0x0) { + if (((vif->type == '\x02') && (*(char *)((int)vif->u + 0x2e6) != '\0')) && + (*(char *)((int)vif->u + 0x2e5) == *(char *)((int)vif->u + 0x2e4))) { + iVar7 = *(int *)((int)vif->u + 0x70); + iVar11 = (uint)vif->index * 8; + bVar1 = txl_tim_ie_pool[iVar11 + 4]; + *(int *)(iVar7 + 0x1c) = + (uint)*(ushort *)((int)vif->u + 0x2dc) + (uint)*(ushort *)((int)vif->u + 0x2de) + 4; + uVar9 = (uint)txl_cntrl_env.seqnbr; + frame = (txl_frame_desc_tag *)((int)vif->u + 4); + txl_cntrl_env.seqnbr = (uint16_t)((uVar9 + 1) * 0x10000 >> 0x10); + *(undefined2 *)(*(int *)(iVar7 + 0x14) + 0x16) = (short)((uVar9 + 1 & 0xffff) << 4); + uVar2 = *(uint8_t *)((int)vif->u + 0x2e7); + txl_tim_ie_pool[iVar11 + 2] = uVar2; + if (uVar2 == '\0') { + if ((*(char *)((int)vif->u + 0x2ea) != '\0') || + (bVar8 = bVar1 & 0xfe, ipc_emb_env.txdesc[ipc_emb_env.txdesc_idx & 3].ready != 0)) { + bVar8 = bVar1 | 1; + } + *(uint8_t *)((int)vif->u + 0x2e7) = txl_tim_ie_pool[iVar11 + 3]; + } + else { + bVar8 = bVar1 & 0xfe; + if ((*(byte *)((int)vif->u + 0x2ea) & 2) != 0) { + bVar8 = bVar1 | 1; + } + } + txl_tim_ie_pool[iVar11 + 4] = bVar8 | 1; + *(char *)((int)vif->u + 0x2e7) = *(char *)((int)vif->u + 0x2e7) + -1; + cVar10 = *(char *)((int)vif->u + 0x2eb); + if (cVar10 != '\0') { + bVar1 = *(byte *)((int)vif->u + 0x2ec); + cVar10 = cVar10 + -1; + *(char *)((int)vif->u + 0x2eb) = cVar10; + if (bVar1 != 0) { + *(char *)(*(int *)(iVar7 + 0x14) + (uint)bVar1) = cVar10; + bVar1 = *(byte *)((int)vif->u + 0x2ed); + if (bVar1 != 0) { + *(undefined *)(*(int *)(iVar7 + 0x14) + (uint)bVar1) = + *(undefined *)((int)vif->u + 0x2eb); + } + } + uVar2 = *(uint8_t *)((int)vif->u + 0x2eb); + if (uVar2 != '\0') { + uVar3 = vif->index; + puVar6 = (uint8_t *)ke_msg_alloc(0x4e,0xd,0,2); + *puVar6 = uVar3; + puVar6[1] = uVar2; + ke_msg_send(); + if (*(char *)((int)vif->u + 0x2eb) != '\0') goto LAB_230033a6; + } + *(undefined *)((int)vif->u + 0x2eb) = 1; + } +LAB_230033a6: + tpc_update_frame_tx_power(vif,frame); + _Var4 = chan_is_on_operational_channel(vif); + if (CONCAT31(extraout_var,_Var4) != 0) { + uVar2 = vif->index; + pcVar5 = (char *)ke_msg_alloc(0x4a,0xd,0,3); + *pcVar5 = uVar2 + '\n'; + pcVar5[1] = '\0'; + pcVar5[2] = '\0'; + ke_msg_send(); + *(uint8_t *)((int)vif->u + 0x33) = vif->index; + *(undefined *)((int)vif->u + 0x34) = 0xff; + _Var4 = txl_frame_push(frame,'\x04'); + if (CONCAT31(extraout_var_00,_Var4) != 0) { + mm_bcn_env.tx_cfm = mm_bcn_env.tx_cfm + 1; + } + iVar7 = (uint)vif->index + 10; + if ((sta_info_tab[iVar7].traffic_avail & PS_TRAFFIC_INT) != 0) { + sta_info_tab[iVar7].ps_service_period = 9; + sta_mgmt_send_postponed_frame(vif,sta_info_tab + iVar7,0); + sta_info_tab[iVar7].ps_service_period = 0; + } + } + } + vif = *(vif_info_tag **)&vif->list_hdr; + } + } + else { + mm_bcn_env.tx_pending = true; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_bcn_updated(void *env,int dma_queue) + +{ + ushort uVar1; + ushort uVar2; + mm_bcn_change_req *pmVar3; + int iVar4; + uint32_t uVar5; + int iVar6; + txl_buffer_control *ptVar7; + mm_bcn_change_req *mem_ptr; + int iVar8; + uint uVar9; + int iVar10; + + mem_ptr = mm_bcn_env.param + -1; + ke_msg_send_basic(0x40,*(ke_task_id_t *)&mm_bcn_env.param[-1].tim_len,0); + pmVar3 = mm_bcn_env.param; + uVar9 = (uint)*(byte *)((int)env + 0x57); + iVar4 = *(int *)((int)env + 0xcc); + uVar1 = (mm_bcn_env.param)->tim_oft; + iVar10 = (uint)(mm_bcn_env.param)->bcn_len - (uint)(mm_bcn_env.param)->tim_len; + iVar8 = *(int *)(iVar4 + 0x14); + *(undefined2 *)((int)env + 0x338) = (short)iVar10; + me_beacon_check(*(byte *)((int)env + 0x57),pmVar3->bcn_len,*(uint32_t *)(iVar4 + 0x14)); + iVar6 = *(int *)(iVar4 + 0x14) + ((uint)pmVar3->tim_oft - 1); + *(int *)(iVar4 + 0x18) = iVar6; + uVar5 = (uint)pmVar3->tim_len + 1 + iVar6; + txl_bcn_end_desc[uVar9].datastartptr = uVar5; + uVar2 = pmVar3->tim_oft; + txl_bcn_end_desc[uVar9].bufctrlinfo = 0; + txl_bcn_end_desc[uVar9].dataendptr = ~(uint)uVar2 + iVar10 + uVar5; + if (*(char *)(*(int *)((int)env + 0x40) + 4) == '\0') { + ptVar7 = &txl_buffer_control_24G; + } + else { + ptVar7 = &txl_buffer_control_5G; + } + *(uint *)(ptVar7->field_0 + 0x24) = _DAT_44b000a0 & 0xff; + *(txl_buffer_control **)(iVar4 + 0x28) = ptVar7; + *(undefined4 *)(iVar4 + 0x24) = 0; + *(undefined4 *)(iVar4 + 0x3c) = 0; + *(tx_pbd **)(iVar4 + 0x10) = txl_tim_desc + (uint)*(byte *)((int)env + 0x57) * 2; + *(undefined *)((int)env + 0x342) = 1; + txl_tim_ie_pool[uVar9 * 8 + 3] = *(uint8_t *)(iVar8 + (uint)uVar1 + 3); + pmVar3 = mm_bcn_env.param; + *(undefined *)((int)env + 0x347) = 0; + *(uint8_t *)((int)env + 0x348) = pmVar3->csa_oft[0]; + *(uint8_t *)((int)env + 0x349) = pmVar3->csa_oft[1]; + if (pmVar3->csa_oft[0] != 0) { + *(char *)((int)env + 0x347) = + *(char *)(*(int *)(*(int *)((int)env + 0xcc) + 0x14) + (uint)pmVar3->csa_oft[0]) + '\x01'; + } + mm_bcn_env.update_ongoing = false; + if (mm_bcn_env.tx_pending != false) { + mm_bcn_transmit(); + } + mm_bcn_env.param = (mm_bcn_change_req *)0x0; + ke_msg_free(mem_ptr); + return; +} + + + +void mm_bcn_update(mm_bcn_change_req *param) + +{ + byte bVar1; + + bVar1 = param->inst_nbr; + memcpy(txl_bcn_pool + (uint)bVar1 * 0xd3 + 0x53,param + 1,(uint)param->bcn_len); + mm_bcn_env.update_pending = false; + mm_bcn_env.update_ongoing = true; + mm_bcn_updated(vif_info_tab + (uint)bVar1,0); + return; +} + + + +void mm_bcn_transmitted(vif_info_tag *param_1) + +{ + co_list_hdr *pcVar1; + + if (mm_bcn_env.tx_cfm == 0) { + assert_err("mm_bcn_env.tx_cfm","module",0x244); + } + mm_bcn_env.tx_cfm = mm_bcn_env.tx_cfm + -1; + if (mm_bcn_env.tx_cfm == 0) { + if (mm_bcn_env.update_pending != false) { + mm_bcn_update(mm_bcn_env.param); + } + while (mm_bcn_env.tim_list.first != (co_list_hdr *)0x0) { + pcVar1 = co_list_pop_front(&mm_bcn_env.tim_list); + mm_tim_update_proceed(pcVar1 + 3); + } + if (param_1->u[0x2eb] == 1) { + vif_mgmt_switch_channel(param_1); + return; + } + } + return; +} + + + +void mm_bcn_change(mm_bcn_change_req *param) + +{ + if (mm_bcn_env.tx_cfm != 0) { + mm_bcn_env.param = param; + mm_bcn_env.update_pending = true; + return; + } + mm_bcn_env.param = param; + mm_bcn_update(param); + return; +} + + +/* +Unable to decompile 'mm_timer_hw_set' +Cause: Exception while decompiling 230036ce: Decompiler process died + +*/ + + +_Bool cmp_abs_time(co_list_hdr *timerA,co_list_hdr *timerB) + +{ + return SUB41((uint)((int)timerA[3].next - (int)timerB[3].next) >> 0x1f,0); +} + + + +void mm_timer_init(void) + +{ + co_list_init((co_list *)&mm_timer_env); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_timer_set(mm_timer_tag *timer,uint32_t value) + +{ + bool bVar1; + + if ((int)(value - _DAT_44b00120) < 0) { + puts("\r\n-------------------[FW] Timer is past due to flash operation. Try to fix\r\n"); + value = _DAT_44b00120 + 3000; + } + bVar1 = timer != (mm_timer_tag *)mm_timer_env.prog.first; + if (bVar1) { + co_list_extract((co_list *)&mm_timer_env,(co_list_hdr *)timer); + } + else { + co_list_pop_front((co_list *)&mm_timer_env); + } + timer->time = value; + co_list_insert((co_list *)&mm_timer_env,(co_list_hdr *)timer,cmp_abs_time); + if ((!bVar1) || (timer == (mm_timer_tag *)mm_timer_env.prog.first)) { + mm_timer_hw_set(mm_timer_env.prog.first); + } + if ((int)(value - _DAT_44b00120) < 0) { + ke_evt_set(0x8000000); + return; + } + return; +} + + + +void mm_timer_clear(mm_timer_tag *timer) + +{ + if (timer == (mm_timer_tag *)mm_timer_env.prog.first) { + co_list_pop_front((co_list *)&mm_timer_env); + mm_timer_hw_set(mm_timer_env.prog.first); + return; + } + co_list_extract((co_list *)&mm_timer_env,(co_list_hdr *)timer); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_timer_schedule(int dummy) + +{ + co_list_hdr *pcVar1; + + while( true ) { + ke_evt_clear(0x8000000); + pcVar1 = mm_timer_env.prog.first; + if (mm_timer_env.prog.first == (co_list_hdr *)0x0) { + mm_timer_hw_set(0); + return; + } + if ((-1 < (int)mm_timer_env.prog.first[3].next + (-0x32 - _DAT_44b00120)) && + (mm_timer_hw_set(mm_timer_env.prog.first), -1 < (int)((int)pcVar1[3].next - _DAT_44b00120))) + break; + co_list_pop_front((co_list *)&mm_timer_env); + if (pcVar1[1].next == (co_list_hdr *)0x0) { + assert_err("timer->cb","module",0xde); + } + (*(code *)pcVar1[1].next)(pcVar1[2].next,pcVar1[1].next); + } + return; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ps_uapsd_timer_handle(void *env) + +{ + vif_info_tag *p_vif_entry; + _Bool _Var1; + undefined3 extraout_var; + int iVar2; + + iVar2 = 0; + p_vif_entry = (vif_info_tag *)vif_mgmt_env.used_list.first; + while (p_vif_entry != (vif_info_tag *)0x0) { + if (((p_vif_entry->type == '\0') && (p_vif_entry->active != false)) && + (*(char *)((int)p_vif_entry->u + 0xc) != '\0')) { + _Var1 = chan_is_on_channel(p_vif_entry); + __Var1 = CONCAT31(extraout_var,_Var1); + if ((__Var1 != 0) && + (iVar2 = __Var1, + (int)(((ps_env.uapsd_timeout >> 1) - _DAT_44b00120) + *(int *)((int)p_vif_entry->u + 8)) < + 0)) { + p_vif_entry->prevent_sleep = p_vif_entry->prevent_sleep | 8; + txl_frame_send_qosnull_frame + (*(uint8_t *)((int)p_vif_entry->u + 4),7,(cfm_func_ptr *)0x0,(void *)0x0); + *(int *)((int)p_vif_entry->u + 8) = _DAT_44b00120; + } + } + p_vif_entry = *(vif_info_tag **)&p_vif_entry->list_hdr; + } + if (iVar2 != 0) { + mm_timer_set(&ps_env.uapsd_timer,_DAT_44b00120 + ps_env.uapsd_timeout); + return; + } + ps_env.uapsd_tmr_on = false; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_pwr_mgt_setf(uint8_t pwrmgt) + +{ + undefined3 in_register_00002029; + + _DAT_44b0004c = CONCAT31(in_register_00002029,pwrmgt) << 2 | _DAT_44b0004c & 0xfffffffb; + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void ps_dpsm_update(_Bool pause) + +{ + vif_info_tag *p_vif_entry; + _Bool _Var1; + undefined3 in_register_00002029; + undefined3 extraout_var; + code *UNRECOVERED_JUMPTABLE; + + if (CONCAT31(in_register_00002029,pause) == 0) { + ps_env.dpsm_state = ps_env.dpsm_state | 4; + ps_env.prevent_sleep = ps_env.prevent_sleep & 0xfffffff7; + UNRECOVERED_JUMPTABLE = ps_enable_cfm; + } + else { + ps_env.dpsm_state = ps_env.dpsm_state | 2; + ps_env.prevent_sleep = ps_env.prevent_sleep | 8; + UNRECOVERED_JUMPTABLE = ps_disable_cfm; + } + blmac_pwr_mgt_setf(pause ^ 1); + ps_env.cfm_cnt = '\0'; + p_vif_entry = (vif_info_tag *)vif_mgmt_env.used_list.first; + while (p_vif_entry != (vif_info_tag *)0x0) { + if (((p_vif_entry->type == '\0') && (p_vif_entry->active != false)) && + (_Var1 = chan_is_on_channel(p_vif_entry), CONCAT31(extraout_var,_Var1) != 0)) { + *(undefined *)((int)p_vif_entry->u + 3) = 0; + ps_env.cfm_cnt = ps_env.cfm_cnt + '\x01'; + txl_frame_send_null_frame + (*(uint8_t *)((int)p_vif_entry->u + 4),UNRECOVERED_JUMPTABLE,p_vif_entry); + } + p_vif_entry = *(vif_info_tag **)&p_vif_entry->list_hdr; + } + if (ps_env.cfm_cnt == '\0') { + // WARNING: Could not recover jumptable at 0x230039d8. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)((void *)0x0,0x800000); + return; + } + return; +} + + + +uint8_t ps_send_pspoll(vif_info_tag *vif_entry) + +{ + ushort uVar1; + txl_frame_desc_tag *frame; + tx_hw_desc *ptVar2; + txl_buffer_tag *ptVar3; + uint uVar4; + char acStack40 [4]; + phy_channel_info phy_info; + + uVar4 = (uint)vif_entry->u[4]; + phy_get_channel((phy_channel_info *)acStack40,'\0'); + frame = txl_frame_get((uint)(acStack40[0] != '\0'),0x10); + if (frame != (txl_frame_desc_tag *)0x0) { + tpc_update_frame_tx_power(vif_entry,frame); + ptVar3 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar3[1].length = 0xa4; + *(undefined *)((int)&ptVar3[1].length + 1) = 0; + uVar1 = sta_info_tab[uVar4].aid; + *(undefined *)((int)&ptVar3[1].length + 2) = (char)uVar1; + *(byte *)((int)&ptVar3[1].length + 3) = (byte)((uint)uVar1 >> 8) | 0xc0; + memcpy(&ptVar3[1].lenheader,&sta_info_tab[uVar4].mac_addr,6); + memcpy((void *)((int)&ptVar3[1].lenpad + 2),&vif_entry->mac_addr,6); + ptVar2 = (frame->txdesc).lmac.hw_desc; + (ptVar2->thd).macctrlinfo2 = (ptVar2->thd).macctrlinfo2 | 0x10000053; + (frame->txdesc).host.vif_idx = sta_info_tab[uVar4].inst_nbr; + (frame->txdesc).host.staid = sta_info_tab[uVar4].staid; + txl_frame_push(frame,'\x03'); + } + return (uint8_t)(frame == (txl_frame_desc_tag *)0x0); +} + + + +void ps_init(void) + +{ + memset(&ps_env,0,0x28); + ps_env.uapsd_timer.cb = ps_uapsd_timer_handle; + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void ps_set_mode(uint8_t mode,ke_task_id_t taskid) + +{ + vif_info_tag *p_vif_entry; + _Bool _Var1; + undefined3 in_register_00002029; + undefined3 extraout_var; + code *UNRECOVERED_JUMPTABLE; + + ps_env.taskid = taskid; + if (((ps_env.dpsm_state & 1) == 0) || ((ps_env.dpsm_state & 6) == 0)) { + if (CONCAT31(in_register_00002029,mode) == 0) { + ps_env.dpsm_state = '\0'; + UNRECOVERED_JUMPTABLE = ps_disable_cfm; + blmac_pwr_mgt_setf(mode); + } + else { + if (CONCAT31(in_register_00002029,mode) == 2) { + ps_env.dpsm_state = ps_env.dpsm_state | 1; + } + blmac_pwr_mgt_setf('\x01'); + UNRECOVERED_JUMPTABLE = ps_enable_cfm; + } + ps_env.cfm_cnt = '\0'; + ps_env.uapsd_on = false; + p_vif_entry = (vif_info_tag *)vif_mgmt_env.used_list.first; + while (p_vif_entry != (vif_info_tag *)0x0) { + if (((p_vif_entry->type == '\0') && (p_vif_entry->active != false)) && + (_Var1 = chan_is_on_channel(p_vif_entry), CONCAT31(extraout_var,_Var1) != 0)) { + *(undefined *)((int)p_vif_entry->u + 3) = 0; + ps_env.cfm_cnt = ps_env.cfm_cnt + '\x01'; + if (*(char *)((int)p_vif_entry->u + 0xc) != '\0') { + ps_env.uapsd_on = true; + } + txl_frame_send_null_frame + (*(uint8_t *)((int)p_vif_entry->u + 4),UNRECOVERED_JUMPTABLE,p_vif_entry); + } + p_vif_entry = *(vif_info_tag **)&p_vif_entry->list_hdr; + } + if (ps_env.cfm_cnt == '\0') { + // WARNING: Could not recover jumptable at 0x23003ba6. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)((void *)0x0,0x800000); + return; + } + } + else { + ps_env.dpsm_state = ps_env.dpsm_state | 0x10; + ps_env.next_mode = mode; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ps_enable_cfm(void *env,uint32_t status) + +{ + co_list_hdr cVar1; + char cVar2; + + if (-1 < (int)(status << 8)) { + cVar2 = *(char *)((int)env + 0x5f) + '\x01'; + *(char *)((int)env + 0x5f) = cVar2; + if (cVar2 != '\x03') { + txl_frame_send_null_frame(*(uint8_t *)((int)env + 0x60),ps_enable_cfm,env); + return; + } + mm_send_connection_loss_ind((vif_info_tag *)env); + } + cVar1 = (co_list_hdr)vif_mgmt_env.used_list.first; + if ((ps_env.cfm_cnt == '\0') || (ps_env.cfm_cnt = ps_env.cfm_cnt + -1, ps_env.cfm_cnt == '\0')) { + if (ps_env.uapsd_on != false) { + mm_timer_set(&ps_env.uapsd_timer,_DAT_44b00120 + ps_env.uapsd_timeout); + ps_env.uapsd_tmr_on = true; + while (cVar1 != (co_list_hdr)0x0) { + if (((*(char *)((int)cVar1 + 0x56) == '\0') && + (*(char *)&((co_list_hdr *)((int)cVar1 + 0x58))->next != '\0')) && + (*(char *)&((co_list_hdr *)((int)cVar1 + 0x68))->next != '\0')) { + ((co_list_hdr *)((int)cVar1 + 4))->next = + (co_list_hdr *)((uint)((co_list_hdr *)((int)cVar1 + 4))->next & 0xfffffff7); + } + cVar1 = *(co_list_hdr *)cVar1; + } + } + if ((ps_env.dpsm_state & 5) == 5) { + ps_env.dpsm_state = ps_env.dpsm_state & 0xf3; + } + else { + ps_env.ps_on = true; + ke_msg_send_basic(0x32,ps_env.taskid,0); + } + if ((ps_env.dpsm_state & 0x10) != 0) { + ps_env.dpsm_state = ps_env.dpsm_state & 0xef; + ps_set_mode(ps_env.next_mode,ps_env.taskid); + return; + } + } + return; +} + + + +void ps_disable_cfm(void *env,uint32_t status) + +{ + char cVar1; + + if (-1 < (int)(status << 8)) { + cVar1 = *(char *)((int)env + 0x5f) + '\x01'; + *(char *)((int)env + 0x5f) = cVar1; + if (cVar1 != '\x03') { + txl_frame_send_null_frame(*(uint8_t *)((int)env + 0x60),ps_disable_cfm,env); + return; + } + mm_send_connection_loss_ind((vif_info_tag *)env); + } + if ((ps_env.cfm_cnt == '\0') || (ps_env.cfm_cnt = ps_env.cfm_cnt + -1, ps_env.cfm_cnt == '\0')) { + mm_timer_clear(&ps_env.uapsd_timer); + ps_env.uapsd_tmr_on = false; + if ((ps_env.dpsm_state & 3) == 3) { + ps_env.dpsm_state = ps_env.dpsm_state & 0xfd | 8; + } + else { + ps_env.ps_on = false; + ke_msg_send_basic(0x32,ps_env.taskid,0); + } + if ((ps_env.dpsm_state & 0x10) != 0) { + ps_env.dpsm_state = ps_env.dpsm_state & 0xef; + ps_set_mode(ps_env.next_mode,ps_env.taskid); + return; + } + } + return; +} + + + +uint8_t ps_polling_frame(vif_info_tag *vif_entry) + +{ + ushort uVar1; + txl_frame_desc_tag *frame; + tx_hw_desc *ptVar2; + txl_buffer_tag *ptVar3; + uint uVar4; + char acStack40 [16]; + + uVar4 = (uint)vif_entry->u[4]; + phy_get_channel((phy_channel_info *)acStack40,'\0'); + frame = txl_frame_get((uint)(acStack40[0] != '\0'),0x10); + if (frame != (txl_frame_desc_tag *)0x0) { + tpc_update_frame_tx_power(vif_entry,frame); + ptVar3 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar3[1].length = 0xa4; + *(undefined *)((int)&ptVar3[1].length + 1) = 0; + uVar1 = sta_info_tab[uVar4].aid; + *(undefined *)((int)&ptVar3[1].length + 2) = (char)uVar1; + *(byte *)((int)&ptVar3[1].length + 3) = (byte)((uint)uVar1 >> 8) | 0xc0; + memcpy(&ptVar3[1].lenheader,&sta_info_tab[uVar4].mac_addr,6); + memcpy((void *)((int)&ptVar3[1].lenpad + 2),&vif_entry->mac_addr,6); + ptVar2 = (frame->txdesc).lmac.hw_desc; + (ptVar2->thd).macctrlinfo2 = (ptVar2->thd).macctrlinfo2 | 0x10000053; + (frame->txdesc).host.vif_idx = sta_info_tab[uVar4].inst_nbr; + (frame->txdesc).host.staid = sta_info_tab[uVar4].staid; + txl_frame_push(frame,'\x03'); + } + return (uint8_t)(frame == (txl_frame_desc_tag *)0x0); +} + + + +void ps_check_beacon(int param_1,vif_info_tag *param_2) + +{ + ushort uVar1; + _Bool _Var2; + uint8_t uVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint uVar4; + uint uVar5; + uint32_t uVar6; + byte bVar7; + + _Var2 = ps_env.ps_on; + uVar1 = sta_info_tab[param_2->u[4]].aid; + uVar5 = param_2->prevent_sleep; + uVar4 = uVar5 & 0xfffffffe; + param_2->prevent_sleep = uVar4; + if (((_Var2 == false) || ((ps_env.dpsm_state & 8) != 0)) || (param_1 == 0)) { + return; + } + if (param_2->u[2] == 0) { + if ((*(byte *)(param_1 + 4) & 1) == 0) { + param_2->prevent_sleep = uVar5 & 0xfffffffc; + } + else { + param_2->prevent_sleep = uVar4 | 2; + } + } + uVar5 = (uint)(uVar1 >> 3); + uVar4 = (uint)*(byte *)(param_1 + 4) & 0xfe; + bVar7 = param_2->u[0xc] & 0xf; + if (((uVar4 <= uVar5) && (uVar5 <= ((uint)*(byte *)(param_1 + 1) - 4) + uVar4)) && + (((uint)*(byte *)(((uVar5 + param_1) - uVar4) + 5) & 1 << ((uint)uVar1 & 7)) != 0)) { + if (bVar7 == 0xf) { + uVar3 = txl_frame_send_qosnull_frame(param_2->u[4],7,(cfm_func_ptr *)0x0,(void *)0x0); + if (CONCAT31(extraout_var,uVar3) != 0) { + return; + } + uVar6 = param_2->prevent_sleep | 8; + } + else { + uVar3 = ps_send_pspoll(param_2); + if (CONCAT31(extraout_var_00,uVar3) != 0) { + return; + } + uVar6 = param_2->prevent_sleep | 4; + } + param_2->prevent_sleep = uVar6; + return; + } + if (bVar7 == 0xf) { + uVar6 = param_2->prevent_sleep & 0xfffffff7; + } + else { + uVar6 = param_2->prevent_sleep & 0xfffffffb; + } + param_2->prevent_sleep = uVar6; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ps_check_frame(uint8_t *frame,uint32_t statinfo,vif_info_tag *vif_entry) + +{ + byte bVar1; + uint uVar2; + uint8_t uVar3; + undefined3 extraout_var; + uint32_t uVar4; + _Bool _Var5; + + _Var5 = ps_env.uapsd_on; + if (ps_env.ps_on == false) { + return; + } + uVar2 = (uint)*(ushort *)frame; + if ((frame[4] & 1) != 0) { + if (((int)(uVar2 << 0x12) < 0) && (vif_entry->u[2] == 0)) { + return; + } + uVar4 = vif_entry->prevent_sleep & 0xfffffffd; +LAB_23003ee6: + vif_entry->prevent_sleep = uVar4; + return; + } + if ((statinfo & 0x200) != 0) { + return; + } + if (ps_env.uapsd_on != false) { + if ((uVar2 & 0x88) == 0x88) { + if ((uVar2 & 0x300) == 0x300) { + bVar1 = frame[0x1e]; + } + else { + bVar1 = frame[0x18]; + } + if ((vif_entry->u[0xc] >> ((uint)"\x01"[(uint)bVar1 & 7] & 0x1f) & 1) != 0) { + *(undefined4 *)(vif_entry->u + 8) = _DAT_44b00120; + if ((bVar1 & 0x10) == 0) { + return; + } + uVar4 = vif_entry->prevent_sleep & 0xfffffff7; + goto LAB_23003ee6; + } + } + else { + if (((*(ushort *)frame & 0xc) == 0) && ((vif_entry->u[0xc] & 8) != 0)) { + *(undefined4 *)(vif_entry->u + 8) = _DAT_44b00120; + goto LAB_23003f80; + } + } + _Var5 = false; + } +LAB_23003f80: + td_pck_ps_ind(vif_entry->index,true); + if ((_Var5 == false) && + ((-1 < (int)(uVar2 << 0x12) || + (((ps_env.dpsm_state & 8) == 0 && + (uVar3 = ps_send_pspoll(vif_entry), CONCAT31(extraout_var,uVar3) != 0)))))) { + vif_entry->prevent_sleep = vif_entry->prevent_sleep & 0xfffffffb; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ps_check_tx_frame(uint8_t staid,uint8_t tid) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + uint uVar1; + + if ((((ps_env.ps_on != false) && (CONCAT31(in_register_00002029,staid) != 0xff)) && + (CONCAT31(in_register_0000202d,tid) != 0xff)) && + ((uVar1 = (uint)sta_info_tab[CONCAT31(in_register_00002029,staid)].inst_nbr, + vif_info_tab[uVar1].type == '\0' && (vif_info_tab[uVar1].active != false)))) { + if ((vif_info_tab[uVar1].u[0xc] >> ((uint)"\x01"[CONCAT31(in_register_0000202d,tid)] & 0x1f) & 1 + ) != 0) { + vif_info_tab[uVar1].prevent_sleep = vif_info_tab[uVar1].prevent_sleep | 8; + *(undefined4 *)(vif_info_tab[uVar1].u + 8) = _DAT_44b00120; + return; + } + td_pck_ps_ind(vif_info_tab[uVar1].index,false); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ps_uapsd_set(vif_info_tag *vif_entry,uint8_t hw_queue,_Bool uapsd) + +{ + byte bVar1; + undefined3 in_register_00002031; + + bVar1 = (byte)(1 << ((uint)hw_queue & 0x1f)); + if (CONCAT31(in_register_00002031,uapsd) == 0) { + vif_entry->u[0xc] = vif_entry->u[0xc] & ~bVar1; + } + else { + vif_entry->u[0xc] = vif_entry->u[0xc] | bVar1; + if ((ps_env.ps_on != false) && (ps_env.uapsd_tmr_on == false)) { + ps_env.uapsd_on = true; + mm_timer_set(&ps_env.uapsd_timer,_DAT_44b00120 + ps_env.uapsd_timeout); + ps_env.uapsd_tmr_on = true; + } + } + return; +} + + + +void ps_traffic_status_update(uint8_t vif_index,uint8_t new_status) + +{ + _Bool pause; + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + char cVar1; + co_list_hdr cVar2; + + if (((ps_env.ps_on != false) && ((ps_env.dpsm_state & 1) != 0)) && ((ps_env.dpsm_state & 6) == 0)) + { + cVar2 = (co_list_hdr)vif_mgmt_env.used_list.first; + if (CONCAT31(in_register_0000202d,new_status) == 0) { + while (cVar2 != (co_list_hdr)0x0) { + if ((((uint)*(byte *)((int)cVar2 + 0x57) != CONCAT31(in_register_00002029,vif_index)) && + (cVar1 = *(char *)&((co_list_hdr *)((int)cVar2 + 0x58))->next, cVar1 != '\0')) && + ((*(char *)((int)cVar2 + 0x56) == '\0' && + ((td_env[(uint)*(byte *)((int)cVar2 + 0x57)].status & 0xc) != 0)))) goto LAB_230040e0; + cVar2 = *(co_list_hdr *)cVar2; + } + cVar1 = '\0'; +LAB_230040e0: + if (cVar1 == '\0') { + if ((ps_env.dpsm_state & 8) == 0) { + return; + } + pause = false; + goto LAB_230040e8; + } + } + pause = true; + if ((ps_env.dpsm_state & 8) == 0) { +LAB_230040e8: + ps_dpsm_update(pause); + return; + } + } + return; +} + + + +void mm_ps_change_ind(uint8_t sta_idx,uint8_t ps_state) + +{ + undefined3 in_register_00002029; + uint8_t *puVar1; + + puVar1 = (uint8_t *)ke_msg_alloc(0x49,0xd,0,2); + sta_info_tab[CONCAT31(in_register_00002029,sta_idx)].ps_state = ps_state; + *puVar1 = sta_idx; + puVar1[1] = ps_state; + ke_msg_send(); + return; +} + + + +void rxl_mpdu_transfer(rx_swdesc *swdesc) + +{ + rx_pbd *prVar1; + rx_pbd *prVar2; + rx_pbd *prVar3; + rx_dmadesc *prVar4; + + prVar4 = swdesc->dma_hdrdesc; + prVar1 = (rx_pbd *)(prVar4->hd).first_pbd_ptr; + phy_get_channel(&prVar4->phy_info,'\0'); + prVar4->payl_offset = mac_payload_offset; + swdesc->pbd_count = '\0'; + prVar3 = (rx_pbd *)0x0; + do { + prVar2 = prVar1; + if ((prVar2->bufstatinfo & 1) != 0) { + swdesc->spare_pbd = prVar2; + swdesc->last_pbd = prVar3; + return; + } + prVar1 = (rx_pbd *)prVar2->next; + swdesc->pbd_count = swdesc->pbd_count + '\x01'; + prVar3 = prVar2; + } while (prVar1 != (rx_pbd *)0x0); + assert_rec("pd != NULL","module",0xb4); + return; +} + + + +void rxl_init(void) + +{ + rxl_hwdesc_init(1); + rx_swdesc_init(); + co_list_init((co_list *)&rxl_cntrl_env); + rxu_cntrl_init(); + return; +} + + + +void rxl_cntrl_dump(void) + +{ + uint32_t uVar1; + co_list_hdr cVar2; + + uVar1 = co_list_cnt((co_list *)&rxl_cntrl_env); + cVar2 = (co_list_hdr)rxl_cntrl_env.ready.first; + if (uVar1 != 0) { + while (cVar2 != (co_list_hdr)0x0) { + cVar2 = *(co_list_hdr *)cVar2; + } + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxl_timer_int_handler(void) + +{ + rx_hd *prVar1; + rx_dmadesc *desc; + char *condition; + rx_swdesc *list_hdr; + int line; + uint32_t uVar2; + + _DAT_44b0807c = 0xa0000; + do { + while( true ) { + if ((rxl_cntrl_env.first == (rx_dmadesc *)0x0) || + (-1 < (int)(((rxl_cntrl_env.first)->hd).statinfo << 0x11))) { + if (rxl_cntrl_env.ready.first != (co_list_hdr *)0x0) { + ke_evt_set(0x40000); + return; + } + return; + } + list_hdr = ((rxl_cntrl_env.first)->hd).swdesc; + prVar1 = &(rxl_cntrl_env.first)->hd; + desc = list_hdr->dma_hdrdesc; + rxl_cntrl_env.first = (rx_dmadesc *)((rxl_cntrl_env.first)->hd).next; + list_hdr->pd = (rx_payloaddesc *)prVar1->first_pbd_ptr; + uVar2 = (desc->hd).first_pbd_ptr; + if ((desc->hd).frmlen == 0) break; + if (uVar2 == 0) { + line = 0xd8; + condition = "pd != NULL"; +LAB_23004280: + assert_rec(condition,"module",line); + } + else { + co_list_push_back((co_list *)&rxl_cntrl_env,(co_list_hdr *)list_hdr); + } + } + if (uVar2 != 0) { + line = 0xfa; + condition = "dma_hdrdesc->hd.first_pbd_ptr == 0"; + goto LAB_23004280; + } + list_hdr->spare_pbd = (rx_pbd *)0x0; + list_hdr->last_pbd = (rx_pbd *)0x0; + rxl_hd_append(desc); + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxl_timeout_int_handler(void) + +{ + _DAT_44b0808c = _DAT_44b0808c & 0xffffffbf; + return; +} + + + +void rxl_dma_int_handler(void) + +{ + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxl_dma_evt(int dummy) + +{ + ke_evt_clear(0x100000); + _DAT_44a00020 = 0x20; + return; +} + + + +void rxl_frame_release(rx_swdesc *swdesc) + +{ + rxl_pd_append((rx_pbd *)(swdesc->dma_hdrdesc->hd).first_pbd_ptr,swdesc->last_pbd,swdesc->spare_pbd + ); + rxl_hd_append(swdesc->dma_hdrdesc); + return; +} + + + +void rxl_mpdu_free(rx_swdesc *swdesc) + +{ + ushort uVar1; + rx_pbd *prVar2; + rx_pbd *prVar3; + rx_pbd *prVar4; + + prVar2 = (rx_pbd *)(swdesc->dma_hdrdesc->hd).first_pbd_ptr; + vTaskEnterCritical(); + swdesc->use_in_tcpip = '\0'; + swdesc->dma_hdrdesc->use_in_tcpip = 0; + prVar4 = (rx_pbd *)0x0; + do { + prVar3 = prVar2; + uVar1 = prVar3->bufstatinfo; + prVar3[1].upattern = 0; + if ((uVar1 & 1) != 0) { + swdesc->spare_pbd = prVar3; + swdesc->last_pbd = prVar4; + rxl_frame_release(swdesc); + vTaskExitCritical(); + return; + } + prVar2 = (rx_pbd *)prVar3->next; + prVar4 = prVar3; + } while ((rx_pbd *)prVar3->next != (rx_pbd *)0x0); + assert_rec("pd != NULL","module",0x397); + return; +} + + +/* +Unable to decompile 'rxl_cntrl_evt' +Cause: Exception while decompiling 23004384: Decompiler process died + +*/ + + +void bl60x_firmwre_mpdu_free(void *swdesc_ptr) + +{ + rx_swdesc *swdesc; + + vTaskEnterCritical(); + rxl_cntrl_env.packet_stack_cnt = + rxl_cntrl_env.packet_stack_cnt - *(byte *)((int)swdesc_ptr + 0x1d); + vTaskExitCritical(); + rxl_mpdu_free((rx_swdesc *)swdesc_ptr); + return; +} + + + +void rxl_reset(void) + +{ + rxl_hwdesc_init(0); + co_list_init((co_list *)&rxl_cntrl_env); + co_list_init((co_list *)&swdesc); + return; +} + + + +void rxl_hwdesc_dump(void) + +{ + rx_dmadesc *prVar1; + rx_payloaddesc *prVar2; + int iVar3; + int iVar4; + uint32_t uVar5; + + puts("---------- rxl_hwdesc_dump -------\r\n"); + printf("rx_dma_hdrdesc: %d\r\n",0xd); + iVar3 = 0; + prVar1 = rx_dma_hdrdesc; + do { + printf(" [%2d]@%08lx: upatternrx %08lx next %08lx first_pbd_ptr %08lx, swdesc %p\r\n",iVar3, + prVar1,(prVar1->hd).upatternrx,(prVar1->hd).next,(prVar1->hd).first_pbd_ptr, + (prVar1->hd).swdesc); + iVar3 = iVar3 + 1; + printf( + " datastartptr %08lx dataendptr %08lx, headerctrlinfo %08lx frmlen %4u ampdu_stat_info %04x\r\n" + ,(prVar1->hd).datastartptr,(prVar1->hd).dataendptr,(prVar1->hd).headerctrlinfo, + (uint)(prVar1->hd).frmlen,(uint)(prVar1->hd).ampdu_stat_info); + printf( + " tsflo %08lx tsfhi %08lx recvec1b %08lx recvec1c %08lx recvec1d %08lx recvec2a %08lx recvec2b %08lx statinfo %08lx\r\n" + ,(prVar1->hd).tsflo,(prVar1->hd).tsfhi,(prVar1->hd).recvec1b,(prVar1->hd).recvec1c, + (prVar1->hd).recvec1d,(prVar1->hd).recvec2a,(prVar1->hd).recvec2b); + prVar1 = prVar1 + 1; + } while (iVar3 != 0xd); + printf("rx_payload_desc: %d\r\n",0xd); + iVar3 = 0; + prVar2 = rx_payload_desc; + do { + uVar5 = (prVar2->pbd).dataendptr; + iVar4 = 0; + if (uVar5 != 0) { + iVar4 = (uVar5 + 1) - (prVar2->pbd).datastartptr; + } + iVar3 = iVar3 + 1; + printf( + " [%2d]@%08lx %3lu Bytes: upatternrx %08lx next %08lx datastartptr %08lx dataendptr %08lx bufstatinfo %04x reserved %04X\r\n" + ,prVar2,iVar4,(prVar2->pbd).upattern,(prVar2->pbd).next); + prVar2 = prVar2 + 1; + } while (iVar3 != 0xd); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxl_hwdesc_init(int init) + +{ + rx_dmadesc *prVar1; + rx_dmadesc *prVar2; + txl_buffer_control *ptVar3; + txl_buffer_control *ptVar4; + txl_buffer_control *ptVar5; + int iVar6; + uint32_t *puVar7; + int iVar8; + txl_buffer_control *ptVar9; + rx_dmadesc *prVar10; + rx_dmadesc *prVar11; + rx_dmadesc *prVar12; + rx_dmadesc *prVar13; + txl_buffer_control *ptVar14; + txl_buffer_control *ptVar15; + + vTaskEnterCritical(); + prVar13 = (rx_dmadesc *)0x0; + iVar6 = 0; + iVar8 = 0; + prVar1 = (rx_dmadesc *)0x0; + prVar10 = rx_dma_hdrdesc; + prVar11 = (rx_dmadesc *)0x0; + do { + prVar2 = prVar10; + prVar10 = prVar2 + 1; + prVar12 = prVar11; + if ((init == 0) && (prVar2->use_in_tcpip == 1)) { + prVar2 = prVar1; + if (prVar1 != (rx_dmadesc *)0x0) { + (prVar1->hd).next = 0; + } + } + else { + if (prVar1 != (rx_dmadesc *)0x0) { + *(rx_dmadesc **)&(prVar1->hd).next = prVar2; + } + (prVar2->hd).datastartptr = 0; + (prVar2->hd).dataendptr = 0; + (prVar2->hd).upatternrx = 0xbaadf00d; + (prVar2->hd).statinfo = 0; + (prVar2->hd).headerctrlinfo = 0; + *(rx_dmadesc **)&(prVar2->hd).next = prVar10; + (prVar2->hd).first_pbd_ptr = 0; + (prVar2->hd).swdesc = rx_swdesc_tab + iVar8; + (prVar2->hd).frmlen = 0; + prVar12 = prVar2; + if ((iVar6 != 0) && (prVar12 = prVar11, iVar6 == 1)) { + prVar13 = prVar2; + } + iVar6 = iVar6 + 1; + } + iVar8 = iVar8 + 1; + prVar1 = prVar2; + prVar11 = prVar12; + } while (iVar8 != 0xd); + if (iVar6 < 4) { + printf("No enough DESC %d(%d)\r\n",0xd); + } + if (prVar2 != (rx_dmadesc *)0x0) { + (prVar2->hd).next = 0; + } + _DAT_44b08180 = 0x4000000; + puVar7 = rx_payload_desc_buffer; + ptVar9 = (txl_buffer_control *)0x0; + iVar6 = 0; + ptVar3 = (txl_buffer_control *)0x0; + ptVar5 = (txl_buffer_control *)rx_payload_desc; + ptVar14 = (txl_buffer_control *)0x0; + _DAT_44b081b8 = prVar13; + do { + ptVar4 = ptVar5; + ptVar5 = (txl_buffer_control *)&ptVar4->mac_control_info; + ptVar15 = ptVar14; + if ((init == 0) && (*(int *)(ptVar4->field_0 + 0x14) == 1)) { + ptVar4 = ptVar3; + if (ptVar3 != (txl_buffer_control *)0x0) { + *(undefined4 *)ptVar3->field_0 = 0; + } + } + else { + if (ptVar3 != (txl_buffer_control *)0x0) { + *(txl_buffer_control **)ptVar3->field_0 = ptVar4; + } + *(txl_buffer_control **)ptVar4->field_0 = ptVar5; + *(undefined4 *)ptVar4->field_0 = 0xc0dedbad; + *(undefined2 *)ptVar4->field_0 = 0; + *(uint32_t **)ptVar4->field_0 = puVar7; + *(int *)ptVar4->field_0 = (int)puVar7 + 0x34f; + *(uint32_t **)(ptVar4->field_0 + 0x18) = puVar7; + ptVar15 = ptVar4; + if ((iVar6 != 0) && (ptVar15 = ptVar14, iVar6 == 1)) { + ptVar9 = ptVar4; + } + iVar6 = iVar6 + 1; + } + puVar7 = puVar7 + 0xd4; + ptVar3 = ptVar4; + ptVar14 = ptVar15; + } while (ptVar5 != txl_buffer_control_desc_bcmc); + if (iVar6 < 4) { + printf("No enough PBD DESC, %d(%d)\r\n",0xd); + } + *(undefined4 *)ptVar4->field_0 = 0; + _DAT_44b08180 = 0x8000000; + _DAT_44b081bc = ptVar9; + if ((((prVar12 == (rx_dmadesc *)0x0) || (prVar13 == (rx_dmadesc *)0x0)) || + (prVar2 == (rx_dmadesc *)0x0)) || + ((ptVar15 == (txl_buffer_control *)0x0 || (ptVar9 == (txl_buffer_control *)0x0)))) { + printf("%p:%p%p vs %p:%p:%p\r\n",prVar12,prVar13,prVar2,ptVar15,ptVar4); + } + rxl_cntrl_env.first = prVar13; + rxl_cntrl_env.last = prVar2; + rxl_cntrl_env.free = prVar12; + rx_hwdesc_env.last = (rx_pbd *)ptVar4; + rx_hwdesc_env.free = (rx_pbd *)ptVar15; + vTaskExitCritical(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxl_hd_append(rx_dmadesc *desc) + +{ + rx_dmadesc *prVar1; + + if (desc == (rx_dmadesc *)0x0) { + assert_err("desc != NULL","module",0xf9); + } + prVar1 = desc; + if (rxl_cntrl_env.free != _DAT_44b08548) { + prVar1 = rxl_cntrl_env.free; + rxl_cntrl_env.free = desc; + } + (prVar1->hd).next = 0; + (prVar1->hd).first_pbd_ptr = 0; + (prVar1->hd).statinfo = 0; + (prVar1->hd).frmlen = 0; + *(rx_dmadesc **)&((rxl_cntrl_env.last)->hd).next = prVar1; + if (rxl_cntrl_env.first == (rx_dmadesc *)0x0) { + rxl_cntrl_env.first = prVar1; + } + rxl_cntrl_env.last = prVar1; + _DAT_44b08180 = 0x1000000; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxl_pd_append(rx_pbd *first,rx_pbd *last,rx_pbd *spare) + +{ + rx_pbd **pprVar1; + rx_pbd *prVar2; + rx_pbd *prVar3; + rx_pbd *prVar4; + + if (spare == (rx_pbd *)0x0) { + assert_err("spare != NULL","module",0x128); + } + prVar4 = rx_hwdesc_env.free; + if (rx_hwdesc_env.free == _DAT_44b0854c) { + prVar4 = first; + if (last == (rx_pbd *)0x0) { + prVar4 = spare; + } + spare->bufstatinfo = 0; + } + else { + prVar2 = rx_hwdesc_env.free; + prVar3 = spare; + if (last != (rx_pbd *)0x0) { + pprVar1 = (rx_pbd **)&(rx_hwdesc_env.free)->next; + rx_hwdesc_env.free = spare; + *pprVar1 = first; + prVar2 = last; + prVar3 = rx_hwdesc_env.free; + } + rx_hwdesc_env.free = prVar3; + spare = prVar2; + prVar4->bufstatinfo = 0; + } + spare->next = 0; + *(rx_pbd **)&(rx_hwdesc_env.last)->next = prVar4; + rx_hwdesc_env.last = spare; + _DAT_44b08180 = 0x2000000; + return; +} + + + +void scan_search_ds(void) + +{ + scan_start_req *param; + + DAT_42018f0c = mac_ie_find(0x42047d04,(uint)param->add_ie_len,3); + return; +} + + + +void scan_init(void) + +{ + memset(&scan_env,0,0x1c); + ke_state_set(2,0); + DAT_42018efc = &scan_probe_req_ie; + DAT_42018f00 = dma_cb; + DAT_42018f04 = 0; + scan_probe_req_ie.dma_desc.dest = 0x42047d04; + scan_probe_req_ie.pbd.upatterntx = 0xcafefade; + scan_probe_req_ie.pbd.next = 0; + scan_probe_req_ie.pbd.datastartptr = 0x42047d04; + scan_probe_req_ie.pbd.bufctrlinfo = 0; + return; +} + + + +void scan_set_channel_request(void) + +{ + scan_chan_tag *psVar1; + uint uVar2; + undefined uVar3; + int iVar4; + + psVar1 = param->chan + DAT_42018f12; + chan_scan_req(*(uint8_t *)(&psVar1->freq + 1),psVar1->freq,*(int8_t *)(&psVar1->freq + 2),110000, + param->vif_idx); + if (DAT_42018f0c == 0) goto LAB_23004c56; + uVar2 = (uint)psVar1->freq; + if (*(char *)(&psVar1->freq + 1) == '\0') { + uVar3 = 0; + if (((uVar2 - 0x96c & 0xffff) < 0x49) && (uVar3 = 0xe, psVar1->freq != 0x9b4)) { + iVar4 = -0x967; +LAB_23004c4a: + uVar3 = (undefined)((int)(uVar2 + iVar4) / 5); + } + } + else { + uVar3 = 0; + if ((*(char *)(&psVar1->freq + 1) == '\x01') && ((uVar2 - 0x138d & 0xffff) < 0x335)) { + iVar4 = -5000; + goto LAB_23004c4a; + } + } + *(undefined *)(DAT_42018f0c + 2) = uVar3; +LAB_23004c56: + ke_state_set(2,2); + return; +} + + + +void dma_cb(void *env,int dma_queue) + +{ + scan_search_ds(); + scan_set_channel_request(); + return; +} + + + +void scan_ie_download(scan_start_req *param) + +{ + scan_search_ds(); + scan_set_channel_request(); + scan_probe_req_ie.pbd.dataendptr = + (scan_probe_req_ie.pbd.datastartptr - 1) + (uint)param->add_ie_len; + scan_probe_req_ie.pbd.bufctrlinfo = 0; + return; +} + + + +void scan_probe_req_tx(void) + +{ + byte bVar1; + byte bVar2; + scan_start_req *psVar3; + txl_buffer_tag *ptVar4; + uint type; + txl_frame_desc_tag *frame; + int iVar5; + int iVar6; + uint uVar7; + uint8_t *puVar8; + tx_hw_desc *ptVar9; + + psVar3 = param; + uVar7 = (uint)DAT_42018f12; + bVar1 = param->vif_idx; + puVar8 = param->ssid[0].array; + iVar6 = 0; + while( true ) { + if ((int)(uint)psVar3->ssid_cnt <= iVar6) { + return; + } + type = 1; + if (psVar3->chan[uVar7].band == '\0') { + type = (uint)psVar3->no_cck; + } + frame = txl_frame_get(type,(uint)psVar3->add_ie_len + (uint)puVar8[-1] + 0x1a); + if (frame == (txl_frame_desc_tag *)0x0) break; + ptVar4 = (frame->txdesc).lmac.buffer; + ptVar9 = (frame->txdesc).lmac.hw_desc; + *(undefined *)&ptVar4[1].length = 0x40; + *(undefined *)((int)&ptVar4[1].length + 1) = 0; + *(undefined *)((int)&ptVar4[1].length + 2) = 0; + *(undefined *)((int)&ptVar4[1].length + 3) = 0; + memcpy(&ptVar4[1].lenheader,&mac_addr_bcst,6); + memcpy((void *)((int)&ptVar4[1].lenpad + 2),&vif_info_tab[bVar1].mac_addr,6); + memcpy(&ptVar4[1].next,&psVar3->bssid,6); + type = (uint)txl_cntrl_env.seqnbr; + *(undefined *)&ptVar4[1].dma_desc[0].src = 0; + txl_cntrl_env.seqnbr = (uint16_t)((type + 1) * 0x10000 >> 0x10); + iVar5 = (type + 1) * 0x100000; + *(undefined *)((int)&ptVar4[1].txdesc + 2) = (char)((uint)iVar5 >> 0x10); + *(undefined *)((int)&ptVar4[1].txdesc + 3) = (char)((uint)iVar5 >> 0x18); + bVar2 = puVar8[-1]; + *(byte *)((int)&ptVar4[1].dma_desc[0].src + 1) = bVar2; + type = 0; + while ((uint)bVar2 != type) { + *(uint8_t *)((int)&ptVar4[1].dma_desc[0].src + type + 2) = puVar8[type]; + type = type + 1; + } + (ptVar9->thd).field_3 = 0x42047cf0; + (ptVar9->thd).field_5 = (ptVar9->thd).field_5 - (uint)psVar3->add_ie_len; + (frame->cfm).cfm_func = (cfm_func_ptr *)0x0; + (frame->cfm).env = (void *)0x0; + iVar6 = iVar6 + 1; + puVar8 = puVar8 + 0x22; + (frame->txdesc).host.vif_idx = psVar3->vif_idx; + (frame->txdesc).host.staid = -1; + txl_frame_push(frame,'\x03'); + } + return; +} + + + +void scan_send_cancel_cfm(uint8_t status,ke_task_id_t dest_id) + +{ + uint8_t *puVar1; + + puVar1 = (uint8_t *)ke_msg_alloc(0x804,dest_id,2,1); + *puVar1 = status; + ke_msg_send(); + return; +} + + + +void sta_mgmt_entry_init(sta_info_tag *sta_entry) + +{ + txdesc *txdesc; + uint16_t *puVar1; + + while ((sta_entry->tx_desc_post).first != (co_list_hdr *)0x0) { + txdesc = (txdesc *)co_list_pop_front(&sta_entry->tx_desc_post); + txl_frame_release(txdesc,true); + } + memset(sta_entry,0,0x1b0); + puVar1 = (uint16_t *)&sta_entry->ba_info[0].bam_idx_rx; + do { + *(uint8_t *)puVar1 = '\x02'; + *(uint8_t *)((int)puVar1 + 1) = '\x02'; + puVar1 = puVar1 + 6; + } while (puVar1 != sta_entry->rx_qos_last_seqcntl + 3); + sta_entry->inst_nbr = -1; + return; +} + + + +void sta_mgmt_init(void) + +{ + sta_info_tag *sta_entry; + sta_info_tag *psVar1; + + co_list_init((co_list *)&sta_info_env); + sta_entry = sta_info_tab; + do { + sta_mgmt_entry_init(sta_entry); + psVar1 = sta_entry + 1; + co_list_push_back((co_list *)&sta_info_env,(co_list_hdr *)sta_entry); + sta_entry = psVar1; + } while (psVar1 != sta_info_tab + 10); + sta_mgmt_entry_init(sta_info_tab + 10); + sta_info_tab[10].pol_tbl.buf_ctrl = txl_buffer_control_desc_bcmc; + sta_info_tab[10].sta_sec_info.cur_key = &vif_info_tab[0].default_key; + sta_info_tab[10].inst_nbr = '\0'; + sta_info_tab[10].ctrl_port_state = '\0'; + printf("------ set default key %p, key ptr %p\r\n",0x4201a9d0,vif_info_tab[0].default_key); + sta_mgmt_entry_init(sta_info_tab + 0xb); + sta_info_tab[11].inst_nbr = '\x01'; + sta_info_tab[11].pol_tbl.buf_ctrl = txl_buffer_control_desc_bcmc + 1; + sta_info_tab[11].ctrl_port_state = '\0'; + sta_info_tab[11].sta_sec_info.cur_key = &vif_info_tab[1].default_key; + printf("------ set default key %p, key ptr %p\r\n",vif_info_tab[1].default_key); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t sta_mgmt_register(mm_sta_add_req *param,uint8_t *sta_idx) + +{ + uint8_t uVar1; + co_list_hdr *list_hdr; + char *__format; + undefined4 uVar2; + key_info_tag *pkVar3; + co_list_hdr *pcVar4; + byte bVar5; + co_list_hdr *pcVar6; + co_list_hdr *pcVar7; + uint uVar8; + + uVar8 = (uint)param->inst_nbr; + list_hdr = co_list_pop_front((co_list *)&sta_info_env); + if (list_hdr == (co_list_hdr *)0x0) { + uVar1 = '\x01'; + } + else { + memcpy((void *)((int)&list_hdr[7].next + 2),¶m->mac_addr,6); + bVar5 = param->ampdu_spacing_min; + if (bVar5 < 0x10) { + bVar5 = 0x10; + } + *(byte *)&list_hdr[5].next = bVar5; + *(uint16_t *)&list_hdr[3].next = param->ampdu_size_max_ht; + list_hdr[2].next = (co_list_hdr *)param->ampdu_size_max_vht; + list_hdr[4].next = (co_list_hdr *)param->paid_gid; + *(uint8_t *)((int)&list_hdr[6].next + 2) = param->inst_nbr; + *(int8_t *)&list_hdr[9].next = param->rssi; + list_hdr[10].next = (co_list_hdr *)param->tsflo; + list_hdr[0xb].next = (co_list_hdr *)param->tsfhi; + *(uint8_t *)&list_hdr[0xc].next = param->data_rate; + uVar1 = (char)((int)(list_hdr + -0x108063c8) >> 4) * '\x13'; + *sta_idx = uVar1; + *(uint8_t *)((int)&list_hdr[6].next + 3) = uVar1; + list_hdr[1].next = (co_list_hdr *)0x19000; + *(undefined2 *)&list_hdr[0x62].next = 0xffff; + pcVar6 = (co_list_hdr *)((int)&list_hdr[0x62].next + 2); + do { + *(undefined2 *)&pcVar6->next = 0xffff; + pcVar6 = (co_list_hdr *)((int)&pcVar6->next + 2); + } while (pcVar6 != list_hdr + 0x67); + bVar5 = *sta_idx; + *(undefined *)((int)&list_hdr[0xc].next + 1) = 0; + *(txl_buffer_control **)&list_hdr[0x43].next = txl_buffer_control_desc + bVar5; + if ((vif_info_tab[uVar8].flags & 8) == 0) { + list_hdr[0x2b].next = (co_list_hdr *)(uVar8 * 0x5d8 + 0x4201a9d0); + pkVar3 = vif_info_tab[uVar8].default_key; + uVar2 = 0x10d; + __format = "------ %d set default key %p, ptr %p\r\n"; + } + else { + pkVar3 = (key_info_tag *)list_hdr[0x2a].next; + list_hdr[0x2b].next = list_hdr + 0x2a; + uVar2 = 0x102; + __format = "------ %d set default key %p, key ptr %p\r\n"; + } + printf(__format,uVar2,pkVar3); + pcVar6 = _DAT_44b00120; + pcVar7 = list_hdr + 0x47; + pcVar4 = _DAT_44b00120 + -250000; + do { + pcVar7->next = pcVar6; + pcVar7[1].next = pcVar4; + pcVar7 = pcVar7 + 3; + } while (pcVar7 != list_hdr + 0x62); + co_list_push_back(&vif_info_tab[uVar8].sta_list,list_hdr); + *(undefined *)((int)&list_hdr[7].next + 1) = 1; + uVar1 = '\0'; + } + return uVar1; +} + + + +void sta_mgmt_unregister(uint8_t sta_idx) + +{ + sta_info_tag *sta_entry; + undefined3 in_register_00002029; + + sta_entry = sta_info_tab + CONCAT31(in_register_00002029,sta_idx); + co_list_extract(&vif_info_tab[sta_info_tab[CONCAT31(in_register_00002029,sta_idx)].inst_nbr]. + sta_list,(co_list_hdr *)sta_entry); + sta_mgmt_entry_init(sta_entry); + co_list_push_back((co_list *)&sta_info_env,(co_list_hdr *)sta_entry); + return; +} + + + +void sta_mgmt_add_key(mm_key_add_req *param,uint8_t hw_key_idx) + +{ + uint8_t uVar1; + uint uVar2; + + uVar2 = (uint)param->sta_idx; + sta_info_tab[uVar2].sta_sec_info.key_info.hw_key_idx = hw_key_idx; + sta_info_tab[uVar2].sta_sec_info.key_info.cipher = param->cipher_suite; + sta_info_tab[uVar2].sta_sec_info.key_info.key_idx = param->key_idx; + memset(&sta_info_tab[uVar2].sta_sec_info,0,0x48); + uVar1 = sta_info_tab[uVar2].sta_sec_info.key_info.cipher; + if (uVar1 == '\x01') { + *(undefined4 *)&sta_info_tab[uVar2].sta_sec_info.key_info.tx_pn = 0; + *(undefined4 *)((int)&sta_info_tab[uVar2].sta_sec_info.key_info.tx_pn + 4) = 0; + *(uint32_t *)sta_info_tab[uVar2].sta_sec_info.key_info.u = (param->key).array[4]; + *(uint32_t *)(sta_info_tab[uVar2].sta_sec_info.key_info.u + 4) = (param->key).array[5]; + *(uint32_t *)(sta_info_tab[uVar2].sta_sec_info.key_info.u + 8) = (param->key).array[6]; + *(uint32_t *)(sta_info_tab[uVar2].sta_sec_info.key_info.u + 0xc) = (param->key).array[7]; + } + else { + if ((uVar1 == '\0') || (uVar1 == '\x03')) { + next = next * 0x41c64e6d + 0x3039; + *(ulong *)&sta_info_tab[uVar2].sta_sec_info.key_info.tx_pn = next >> 0x10; + *(undefined4 *)((int)&sta_info_tab[uVar2].sta_sec_info.key_info.tx_pn + 4) = 0; + } + else { + *(undefined4 *)&sta_info_tab[uVar2].sta_sec_info.key_info.tx_pn = 0; + *(undefined4 *)((int)&sta_info_tab[uVar2].sta_sec_info.key_info.tx_pn + 4) = 0; + } + } + sta_info_tab[uVar2].sta_sec_info.key_info.valid = true; + *(sta_mgmt_sec_info **)&sta_info_tab[uVar2].sta_sec_info.pairwise_key = + &sta_info_tab[uVar2].sta_sec_info; + return; +} + + + +void sta_mgmt_del_key(sta_info_tag *sta) + +{ + (sta->sta_sec_info).key_info.valid = false; + (sta->sta_sec_info).pairwise_key = (key_info_tag *)0x0; + sta->ctrl_port_state = '\x01'; + return; +} + + + +int sta_mgmt_send_postponed_frame(vif_info_tag *p_vif_entry,sta_info_tag *p_sta_entry,int limit) + +{ + uint8_t access_category; + int iVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 extraout_var_00; + txdesc *txdesc; + int iStack36; + int stop; + + iVar1 = 0; + while( true ) { + txdesc = (txdesc *)(p_sta_entry->tx_desc_post).first; + if (txdesc == (txdesc *)0x0) { + return iVar1; + } + iStack36 = 0; + _Var2 = txl_cntrl_tx_check(p_vif_entry); + if (CONCAT31(extraout_var,_Var2) == 0) { + return iVar1; + } + _Var2 = apm_tx_int_ps_check(txdesc); + if (CONCAT31(extraout_var_00,_Var2) == 0) { + return iVar1; + } + txdesc = apm_tx_int_ps_get_postpone(p_vif_entry,p_sta_entry,&iStack36); + if (iStack36 != 0) break; + if (txdesc == (txdesc *)0x0) { + txdesc = (txdesc *)co_list_pop_front(&p_sta_entry->tx_desc_post); + } + access_category = (txdesc->host).tid; + *(undefined *)((int)&txdesc[1].host.packet_addr + 1) = 0; + iVar1 = iVar1 + 1; + txl_cntrl_push_int(txdesc,access_category); + if ((limit != 0) && (iVar1 == limit)) { + return iVar1; + } + } + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void td_timer_end(void *env) + +{ + int iVar1; + bool bVar2; + undefined *puVar3; + undefined *puVar4; + + iVar1 = _DAT_44b00120; + if (*(char *)((int)env + 0x23) != '\0') { + bVar2 = *(int *)((int)env + 0x10) != 0; + if (*(int *)((int)env + 0x14) != 0) { + bVar2 = (bool)(bVar2 | 2); + } + if (*(int *)((int)env + 0x18) != 0) { + bVar2 = (bool)(bVar2 | 4); + } + if (*(int *)((int)env + 0x1c) != 0) { + bVar2 = (bool)(bVar2 | 8); + } + if (((*(byte *)((int)env + 0x21) ^ bVar2) & 0xc) != 0) { + if ((bVar2 & 4U) == 0) { + puVar3 = &UNK_23074b2c; + } + else { + puVar3 = &UNK_23074b28; + } + if ((bVar2 & 8U) == 0) { + puVar4 = &UNK_23074b2c; + } + else { + puVar4 = &UNK_23074b30; + } + printf(&DAT_23074b34,puVar3,puVar4); + ps_traffic_status_update(*(uint8_t *)((int)env + 0x20),bVar2 & 0xc); + } + *(bool *)((int)env + 0x21) = bVar2; + } + *(undefined4 *)((int)env + 0x10) = 0; + *(undefined4 *)((int)env + 0x14) = 0; + *(undefined4 *)((int)env + 0x18) = 0; + *(undefined4 *)((int)env + 0x1c) = 0; + *(bool *)((int)env + 0x23) = vif_info_tab[*(byte *)((int)env + 0x20)].chan_ctxt == DAT_4201d1f8; + mm_timer_set((mm_timer_tag *)env,iVar1 + 1000000); + return; +} + + + +void td_reset(uint8_t vif_index) + +{ + td_env_tag *__s; + undefined3 in_register_00002029; + int iVar1; + + iVar1 = CONCAT31(in_register_00002029,vif_index); + __s = td_env + iVar1; + printf(&DAT_23074b00,iVar1); + if (td_env[iVar1].is_on != false) { + mm_timer_clear((mm_timer_tag *)__s); + } + memset(__s,0,0x24); + td_env[iVar1].td_timer.cb = td_timer_end; + *(td_env_tag **)&td_env[iVar1].td_timer.env = __s; + td_env[iVar1].vif_index = vif_index; + return; +} + + + +void td_init(void) + +{ + printf(&DAT_23074af4); + td_reset('\0'); + td_reset('\x01'); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void td_start(uint8_t vif_index) + +{ + int iVar1; + undefined3 in_register_00002029; + int iVar2; + + iVar1 = _DAT_44b00120; + iVar2 = CONCAT31(in_register_00002029,vif_index); + if (td_env[iVar2].is_on == false) { + printf(&DAT_23074b14,iVar2); + td_env[iVar2].is_on = true; + mm_timer_set((mm_timer_tag *)(td_env + iVar2),iVar1 + 1000000); + return; + } + return; +} + + + +void td_pck_ind(uint8_t vif_index,uint8_t sta_index,_Bool rx) + +{ + undefined3 in_register_00002029; + int iVar1; + undefined3 in_register_00002031; + + iVar1 = CONCAT31(in_register_00002029,vif_index); + if (CONCAT31(in_register_00002031,rx) != 0) { + td_env[iVar1].pck_cnt_rx = td_env[iVar1].pck_cnt_rx + 1; + return; + } + td_env[iVar1].pck_cnt_tx = td_env[iVar1].pck_cnt_tx + 1; + return; +} + + + +void td_pck_ps_ind(uint8_t vif_index,_Bool rx) + +{ + undefined3 in_register_00002029; + int iVar1; + undefined3 in_register_0000202d; + + iVar1 = CONCAT31(in_register_00002029,vif_index); + if (CONCAT31(in_register_0000202d,rx) != 0) { + td_env[iVar1].pck_cnt_rx_ps = td_env[iVar1].pck_cnt_rx_ps + 1; + return; + } + td_env[iVar1].pck_cnt_tx_ps = td_env[iVar1].pck_cnt_tx_ps + 1; + return; +} + + + +void bl_tpc_update_power_table(int8_t *power_table) + +{ + char cVar1; + int32_t *piVar2; + char *pcVar3; + int iStack72; + int32_t power_os [14]; + + trpc_update_power((int8_t (*) [8])power_table); + pcVar3 = power_table + 0x18; + piVar2 = &iStack72; + while (pcVar3 != power_table + 0x26) { + cVar1 = *pcVar3; + pcVar3 = pcVar3 + 1; + *piVar2 = (int)cVar1; + piVar2 = piVar2 + 1; + } + rf_pri_update_power_offset(&iStack72); + return; +} + + + +void bl_tpc_power_table_get(int8_t *power_table_config) + +{ + int iVar1; + + trpc_power_get(power_table_config); + iVar1 = 0x18; + do { + power_table_config[iVar1] = '\0'; + iVar1 = iVar1 + 1; + } while (iVar1 != 0x26); + return; +} + + + +void bl_tpc_update_power_rate_11b(int8_t *power_rate_table) + +{ + int8_t *piVar1; + int8_t *piVar2; + int iVar3; + + iVar3 = 0; + do { + piVar1 = power_rate_table + iVar3; + piVar2 = txpwr_vs_rate_table + iVar3; + iVar3 = iVar3 + 1; + *piVar2 = *piVar1; + } while (iVar3 != 4); + return; +} + + + +void bl_tpc_update_power_rate_11g(int8_t *power_rate_table) + +{ + int8_t *piVar1; + int iVar2; + int8_t *piVar3; + + iVar2 = 0; + piVar3 = txpwr_vs_rate_table; + do { + piVar1 = power_rate_table + iVar2; + iVar2 = iVar2 + 1; + piVar3[8] = *piVar1; + piVar3 = piVar3 + 1; + } while (iVar2 != 8); + return; +} + + + +void bl_tpc_update_power_rate_11n(int8_t *power_rate_table) + +{ + int8_t *piVar1; + int iVar2; + int8_t *piVar3; + + iVar2 = 0; + piVar3 = txpwr_vs_rate_table; + do { + piVar1 = power_rate_table + iVar2; + iVar2 = iVar2 + 1; + piVar3[0x10] = *piVar1; + piVar3 = piVar3 + 1; + } while (iVar2 != 8); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void tpc_update_tx_power(int8_t pwr) + +{ + uint8_t uVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + + uVar1 = trpc_get_default_power_idx('\x02','\0'); + _DAT_44b000a0 = CONCAT31(extraout_var,uVar1) | _DAT_44b000a0 & 0xffffff00; + uVar1 = trpc_get_default_power_idx('\0','\0'); + _DAT_44b000a0 = CONCAT31(extraout_var_00,uVar1) << 8 | _DAT_44b000a0 & 0xffff00ff; + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void tpc_update_vif_tx_power(vif_info_tag *vif,int8_t *pwr,uint8_t *idx) + +{ + char cVar1; + char cVar2; + _Bool _Var3; + undefined3 extraout_var; + int *piVar4; + + if (*pwr == '\x7f') { + return; + } + cVar1 = vif->tx_power; + phy_get_rf_gain_idx(pwr,idx); + cVar2 = *pwr; + vif->tx_power = cVar2; + if (vif->user_tx_power < cVar2) { + *pwr = vif->user_tx_power; + phy_get_rf_gain_idx(pwr,idx); + } + if (*pwr != cVar1) { + piVar4 = (int *)(vif->sta_list).first; + while (piVar4 != (int *)0x0) { + *(byte *)((int)piVar4 + 0x11a) = *(byte *)((int)piVar4 + 0x11a) | 0x10; + piVar4 = (int *)*piVar4; + } + if (vif->chan_ctxt != (chan_ctxt_tag *)0x0) { + chan_update_tx_power(vif->chan_ctxt); + _Var3 = chan_is_on_channel(vif); + if (CONCAT31(extraout_var,_Var3) != 0) { + tpc_update_tx_power((vif->chan_ctxt->channel).tx_power); + return; + } + } + } + return; +} + + + +uint8_t tpc_get_vif_tx_power_vs_rate(uint32_t rate_config) + +{ + uint8_t formatmod; + byte mcs; + + mcs = (byte)rate_config & 0x7f; + if ((rate_config >> 0xb & 7) == 0) { + formatmod = (uint8_t)(rate_config & 0x7c); + if ((rate_config & 0x7c) != 0) { + mcs = mcs - 4; + formatmod = '\x01'; + } + } + else { + formatmod = '\x02'; + } + formatmod = trpc_get_default_power_idx(formatmod,mcs); + return formatmod; +} + + + +void tpc_update_frame_tx_power(vif_info_tag *vif,txl_frame_desc_tag *frame) + +{ + uint32_t uVar1; + uint8_t uVar2; + undefined3 extraout_var; + + uVar1 = (((frame->txdesc).lmac.hw_desc)->thd).policyentryaddr; + uVar2 = tpc_get_vif_tx_power_vs_rate(*(uint32_t *)(uVar1 + 0x14)); + *(undefined4 *)(uVar1 + 0x24) = CONCAT31(extraout_var,uVar2); + return; +} + + + +void txl_int_fake_transfer(txdesc *txdesc,uint8_t access_category) + +{ + undefined3 in_register_0000202d; + int iVar1; + txl_buffer_tag *ptVar2; + + ptVar2 = (txdesc->lmac).buffer; + (ptVar2->tbd).upatterntx = 0xcafefade; + iVar1 = CONCAT31(in_register_0000202d,access_category) + 0x16; + ptVar2->txdesc = txdesc; + if ((&txl_buffer_env.buf_idx[0].free)[iVar1 * 2] == 0) { + *(txl_buffer_tag **)(&txl_buffer_env.buf_idx[0].free + iVar1 * 2) = ptVar2; + } + else { + *(txl_buffer_tag **)((&txl_buffer_env.buf_idx[0].free_size)[iVar1 * 2] + 0x10) = ptVar2; + } + *(txl_buffer_tag **)(&txl_buffer_env.buf_idx[0].free_size + iVar1 * 2) = ptVar2; + ptVar2->next = (txl_buffer_tag *)0x0; + return; +} + + + +void blmac_abs_timer_set(int reg_idx,uint32_t value) + +{ + if (9 < reg_idx) { + assert_err("reg_idx <= 9","module",0x26a0); + } + *(uint32_t *)((reg_idx + 0x112c004a) * 4) = value; + return; +} + + + +void txl_machdr_format(uint32_t machdrptr) + +{ + uint uVar1; + + if ((*(byte *)(machdrptr + 0x16) & 0xf) == 0) { + txl_cntrl_env.seqnbr = txl_cntrl_env.seqnbr + 1; + } + uVar1 = (uint)txl_cntrl_env.seqnbr; + *(byte *)(machdrptr + 0x16) = (byte)(uVar1 << 4) | *(byte *)(machdrptr + 0x16) & 0xf; + *(undefined *)(machdrptr + 0x17) = (char)((uVar1 << 4) >> 8); + return; +} + + + +void txl_cntrl_init(void) + +{ + txl_cntrl_env_tag *ptVar1; + undefined4 uVar2; + undefined4 *puVar3; + + txl_hwdesc_init(); + txl_buffer_init(); + txl_cfm_init(); + txl_frame_init(false); + memset(&txl_cntrl_env,0,0x58); + ptVar1 = &txl_cntrl_env; + puVar3 = (undefined4 *)&DAT_44a00080; + do { + co_list_init(&ptVar1->txlist[0].transmitting); + ptVar1->txlist[0].last_frame_exch = (tx_hd *)0x0; + uVar2 = *puVar3; + ptVar1->txlist[0].chk_state = '\0'; + puVar3 = puVar3 + 1; + ptVar1->txlist[0].bridgedmacnt = (uint16_t)uVar2; + ptVar1 = (txl_cntrl_env_tag *)(ptVar1->txlist + 1); + } while (puVar3 != (undefined4 *)0x44a00094); + txl_cntrl_env.seqnbr = 0; + return; +} + + + +_Bool txl_cntrl_tx_check(vif_info_tag *p_vif_entry) + +{ + _Bool _Var1; + + if (txl_cntrl_env.reset == false) { + _Var1 = chan_is_tx_allowed(p_vif_entry); + return _Var1; + } + return false; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_cntrl_halt_ac(uint8_t access_category) + +{ + undefined3 in_register_00002029; + + switch(CONCAT31(in_register_00002029,access_category)) { + case 0: + _DAT_44b08180 = 0x10000; + do { + } while ((_DAT_44b08188 >> 4 & 3) != 0); + _DAT_44b08184 = 0x10000; + break; + case 1: + _DAT_44b08180 = 0x20000; + do { + } while ((_DAT_44b08188 >> 8 & 3) != 0); + _DAT_44b08184 = 0x20000; + break; + case 2: + _DAT_44b08180 = 0x40000; + do { + } while ((_DAT_44b08188 >> 0xc & 3) != 0); + _DAT_44b08184 = 0x40000; + break; + case 3: + _DAT_44b08180 = 0x80000; + do { + } while ((_DAT_44b08188 >> 0x10 & 3) != 0); + _DAT_44b08184 = 0x80000; + break; + case 4: + _DAT_44b08180 = 0x8000; + do { + } while ((_DAT_44b08188 & 3) != 0); + _DAT_44b08184 = 0x8000; + break; + default: + assert_err("0","module",0x779); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_cntrl_flush_ac(uint8_t access_category,uint32_t status) + +{ + uint uVar1; + undefined3 in_register_00002029; + int iVar2; + uint uVar3; + + uVar1 = _DAT_44b0808c; + iVar2 = CONCAT31(in_register_00002029,access_category); + uVar3 = 1 << ((uint)access_category & 0x1f); + txl_cfm_flush(access_category,txl_cfm_env.cfmlist + iVar2,status); + txl_cfm_flush(access_category,&txl_cntrl_env.txlist[iVar2].transmitting,status); + txl_cntrl_env.txlist[iVar2].last_frame_exch = (tx_hd *)0x0; + txl_buffer_reset(iVar2); + _DAT_44b08088 = uVar3; + _DAT_44b0808c = ~uVar3 & uVar1; + return; +} + + +/* +Unable to decompile 'txl_cntrl_clear_bcn_ac' +Cause: Exception while decompiling 230058de: Decompiler process died + +*/ + +/* +Unable to decompile 'txl_cntrl_clear_all_ac' +Cause: Exception while decompiling 23005900: Decompiler process died + +*/ + + +void txl_cntrl_inc_pck_cnt(void) + +{ + txl_cntrl_env.pck_cnt = txl_cntrl_env.pck_cnt + 1; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_payload_handle(void) + +{ + int iVar1; + + while ((_DAT_44a00024 & 0x1f) != 0) { + iVar1 = __clzsi2(_DAT_44a00024 & 0x1f); + _DAT_44a00020 = 1 << (0x1fU - iVar1 & 0x1f); + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_payload_handle_backup(void) + +{ + ushort uVar1; + uint uVar2; + uint uVar3; + txl_buffer_tag *ptVar4; + char *condition; + int line; + byte bVar5; + uint reg_idx; + tx_hd *ptVar6; + undefined *puVar7; + txdesc *txdesc; + tx_hd *ptVar8; + txl_buffer_env_tag *ptVar9; + txl_cntrl_env_tag *ptVar10; + uint uVar11; + tx_hw_desc *ptVar12; + + ptVar9 = &txl_buffer_env; + ptVar10 = &txl_cntrl_env; + uVar3 = 0; + while (ptVar4 = ptVar9->list[0].first, ptVar4 == (txl_buffer_tag *)0x0) { +LAB_230059f6: + uVar3 = uVar3 + 1; + ptVar9 = (txl_buffer_env_tag *)&ptVar9->buf_idx[0].free_size; + ptVar10 = (txl_cntrl_env_tag *)(ptVar10->txlist + 1); + if (uVar3 == 5) { + return; + } + } + uVar2 = uVar3 & 0xff; + ptVar9->list[0].first = ptVar4->next; + uVar11 = 1 << (uVar3 & 0x1f); + do { + txdesc = ptVar4->txdesc; + if ((txdesc->host).packet_addr != 0) { + if (uVar3 == 4) { + reg_idx = (uint)(txdesc->host).vif_idx; + if ((*(byte *)((int)&ptVar4[1].length + 1) >> 5 & 1) == 0) { + bVar5 = vif_info_tab[reg_idx].u[0x2ea] & 0xfd; + } + else { + bVar5 = vif_info_tab[reg_idx].u[0x2ea] | 2; + } + vif_info_tab[reg_idx].u[0x2ea] = bVar5; + } + if ((txdesc->host).tid == -1) { + uVar1 = (txdesc->host).flags; + if ((((uVar1 & 8) != 0) && ((*(byte *)&ptVar4[1].length & 0xdc) == 0x10)) && + (*(short *)((int)&ptVar4[1].dma_desc[0].src + 2) == 0)) { + (txdesc->host).flags = uVar1 | 0x20; + rxu_cntrl_monitor_pm((mac_addr *)&ptVar4[1].lenheader); + } + txl_machdr_format((uint32_t)(ptVar4 + 1)); + } + ptVar4 = (txdesc->lmac).buffer; + ptVar12 = (txdesc->lmac).hw_desc; + if (((txdesc->host).flags & 8) == 0) { + txu_cntrl_tkip_mic_append(txdesc,(uint8_t)uVar2); + (ptVar12->thd).macctrlinfo1 = (ptVar4->buffer_control).mac_control_info; + } + else { + (ptVar12->thd).macctrlinfo2 = (ptVar12->thd).macctrlinfo2 & 0xff87ffff; + bVar5 = *(byte *)&ptVar4[1].lenheader; + (ptVar12->thd).statinfo = 0; + (ptVar12->thd).macctrlinfo1 = (uint)((bVar5 & 1) == 0) << 9; + } + *(txl_buffer_control **)&(ptVar12->thd).policyentryaddr = &ptVar4->buffer_control; + (ptVar12->thd).phyctrlinfo = (ptVar4->buffer_control).phy_control_info; + } + ptVar10->txlist[0].bridgedmacnt = ptVar10->txlist[0].bridgedmacnt + 1; + ptVar6 = ptVar10->txlist[0].last_frame_exch; + ptVar8 = &((txdesc->lmac).hw_desc)->thd; + if (ptVar6 == (tx_hd *)0x0) { + reg_idx = uVar3; + if (uVar2 == 2) { + if ((_DAT_44b08188 >> 0xc & 3) == 2) { + line = 0x23c; + condition = "blmac_tx_ac_2_state_getf() != 2"; + goto LAB_23005bec; + } + _DAT_44b08180 = 0x800; + puVar7 = (undefined *)0x61a80; + _DAT_44b081a4 = ptVar8; + } + else { + if (2 < uVar2) { + if (uVar2 == 3) { + if ((_DAT_44b08188 >> 0x10 & 3) != 2) { + _DAT_44b08180 = 0x1000; + _DAT_44b081a8 = ptVar8; + goto LAB_23005c4c; + } + line = 0x236; + condition = "blmac_tx_ac_3_state_getf() != 2"; + } + else { + if (uVar2 != 4) goto LAB_23005b9a; + if ((_DAT_44b08188 & 3) != 2) { + _DAT_44b08180 = 0x100; + reg_idx = 4; + puVar7 = (undefined *)0xc350; + _DAT_44b08198 = ptVar8; + goto LAB_23005c08; + } + line = 0x22f; + condition = "blmac_tx_bcn_state_getf() != 2"; + } +LAB_23005bec: + assert_rec(condition,"module",line); + goto LAB_23005b5e; + } + if (uVar2 == 1) { + if ((_DAT_44b08188 >> 8 & 3) == 2) { + line = 0x242; + condition = "blmac_tx_ac_1_state_getf() != 2"; + goto LAB_23005bec; + } + _DAT_44b08180 = 0x400; + puVar7 = &DAT_001e8480; + _DAT_44b081a0 = ptVar8; + } + else { +LAB_23005b9a: + if ((_DAT_44b08188 >> 4 & 3) == 2) { + line = 0x248; + condition = "blmac_tx_ac_0_state_getf() != 2"; + goto LAB_23005bec; + } + _DAT_44b08180 = 0x200; + _DAT_44b0819c = ptVar8; +LAB_23005c4c: + puVar7 = (undefined *)0x30d40; + } + } +LAB_23005c08: + blmac_abs_timer_set(reg_idx,(uint32_t)(puVar7 + _DAT_44b00120)); + _DAT_44b0808c = uVar11 | _DAT_44b0808c; + _DAT_44b08088 = uVar11; + } + else { + *(tx_hd **)&ptVar6->nextfrmexseq_ptr = ptVar8; + if (uVar2 == 2) { + _DAT_44b08180 = 8; + } + else { + if (uVar2 < 3) { + if (uVar2 == 1) { + _DAT_44b08180 = 4; + } + else { +LAB_23005b26: + _DAT_44b08180 = 2; + } + } + else { + if (uVar2 == 3) { + _DAT_44b08180 = 0x10; + } + else { + if (uVar2 != 4) goto LAB_23005b26; + _DAT_44b08180 = 1; + } + } + } + } +LAB_23005b5e: + ptVar4 = ptVar9->list[0].first; + ptVar10->txlist[0].last_frame_exch = ptVar8; + if (ptVar4 == (txl_buffer_tag *)0x0) goto LAB_230059f6; + ptVar9->list[0].first = ptVar4->next; + } while( true ); +} + + +/* +Unable to decompile 'txl_cntrl_push_int' +Cause: Exception while decompiling 23005cd2: Decompiler process died + +*/ + +/* +Unable to decompile 'txl_cntrl_push_int_force' +Cause: Exception while decompiling 23005da4: Decompiler process died + +*/ + +/* +Unable to decompile 'txl_cntrl_push' +Cause: Exception while decompiling 23005df2: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_transmit_trigger(void) + +{ + uint reg_idx; + uint uVar1; + int iVar2; + uint32_t status; + tx_hw_desc *ptVar3; + uint32_t uVar4; + txdesc *txdesc; + co_list *list; + + if ((_DAT_44b08078 & 0x7c0) == 0) { + return; + } + iVar2 = __clzsi2(_DAT_44b08078 & 0x7c0); + reg_idx = 0x19U - iVar2 & 0xff; + if (4 < reg_idx) { + assert_err("access_category < NX_TXQ_CNT","module",0x90b); + } + _DAT_44b0807c = 1 << (reg_idx + 6 & 0x1f); + list = &txl_cntrl_env.txlist[reg_idx].transmitting; + uVar1 = ~(1 << (0x19U - iVar2 & 0x1f)); + while( true ) { + txdesc = (txdesc *)list->first; + if (txdesc == (txdesc *)0x0) { + txl_cntrl_env.txlist[reg_idx].last_frame_exch = (tx_hd *)0x0; + _DAT_44b0808c = uVar1 & _DAT_44b0808c; + return; + } + ptVar3 = (txdesc->lmac).hw_desc; + status = (ptVar3->thd).statinfo; + if (-1 < (int)status) break; + if (((txdesc->host).packet_addr != 0) && ((txdesc->lmac).buffer != (txl_buffer_tag *)0x0)) { + (txdesc->lmac).buffer = (txl_buffer_tag *)0x0; + } + ptVar3->cfm_ptr->status = status; + uVar4 = (ptVar3->thd).nextfrmexseq_ptr; + if (uVar4 == 0) { + txl_cntrl_env.txlist[reg_idx].last_frame_exch = (tx_hd *)0x0; + _DAT_44b0808c = _DAT_44b0808c & uVar1; + } + else { + if (-1 < *(int *)(uVar4 + 0x3c)) { + blmac_abs_timer_set(reg_idx,_DAT_44b00120 + TX_TIMEOUT[reg_idx]); + return; + } + } + co_list_pop_front(list); + if ((txdesc->host).packet_addr == 0) { + txl_frame_cfm(txdesc); + } + else { + txl_cfm_push(txdesc,status,(uint8_t)reg_idx); + } + blmac_abs_timer_set(reg_idx,_DAT_44b00120 + TX_TIMEOUT[reg_idx]); + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_reset(void) + +{ + uint8_t access_category; + uint16_t uVar1; + txl_cntrl_env_tag *ptVar2; + undefined4 *puVar3; + undefined4 uVar4; + uint uVar5; + co_list *list; + txl_cfm_env_tag *list_00; + + uVar1 = txl_cntrl_env.seqnbr; + ke_evt_clear(0x1f000); + do { + } while ((_DAT_44a00010 & 0xffff) != 0xffff); + txl_cntrl_env.reset = true; + list_00 = &txl_cfm_env; + list = &txl_cntrl_env.txlist[0].transmitting; + uVar5 = 0; + do { + _DAT_44a00020 = 1 << (uVar5 & 0x1f); + access_category = (uint8_t)uVar5; + txl_cfm_flush(access_category,(co_list *)list_00,0x40000000); + uVar5 = uVar5 + 1; + txl_cfm_flush(access_category,list,0x40000000); + list_00 = (txl_cfm_env_tag *)(list_00->cfmlist + 1); + list = list + 2; + } while (uVar5 != 5); + txl_hwdesc_reset(); + txl_buffer_reinit(); + txl_cfm_init(); + memset(&txl_cntrl_env,0,0x58); + ptVar2 = &txl_cntrl_env; + puVar3 = (undefined4 *)&DAT_44a00080; + txl_cntrl_env.seqnbr = uVar1; + do { + co_list_init(&ptVar2->txlist[0].transmitting); + ptVar2->txlist[0].last_frame_exch = (tx_hd *)0x0; + uVar4 = *puVar3; + ptVar2->txlist[0].chk_state = '\0'; + puVar3 = puVar3 + 1; + ptVar2->txlist[0].bridgedmacnt = (uint16_t)uVar4; + ptVar2 = (txl_cntrl_env_tag *)(ptVar2->txlist + 1); + } while (puVar3 != (undefined4 *)0x44a00094); + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void txl_cntrl_env_dump(void) + +{ + int iVar1; + uint32_t uVar2; + int *piVar3; + int iVar4; + int *piVar5; + co_list *list; + + iVar1 = 4; + do { + list = (co_list *)((int)&txl_cntrl_env.txlist[0].last_frame_exch + iVar1); + uVar2 = co_list_cnt(list); + if (uVar2 != 0) { + piVar5 = (int *)list->first; + piVar3 = piVar5; + while (piVar3 != (int *)0x0) { + piVar3 = (int *)*piVar3; + } + while (piVar5 != (int *)0x0) { + iVar4 = *(int *)(piVar5[0x1b] + 0x10); + while (iVar4 != 0) { + iVar4 = *(int *)(iVar4 + 4); + } + piVar5 = (int *)*piVar5; + } + } + iVar1 = iVar1 + 0x10; + } while (iVar1 != 0x54); + return; +} + + + +void txl_frame_init_desc(txl_frame_desc_tag *frame,txl_buffer_tag *buffer,tx_hw_desc *hwdesc, + txl_buffer_control *bufctrl) + +{ + memset(frame,0,0x2d8); + (hwdesc->thd).upatterntx = 0xcafebabe; + *(txl_buffer_tag **)&(hwdesc->thd).field_4 = buffer + 1; + (hwdesc->thd).frmlifetime = 0; + (hwdesc->thd).optlen[0] = 0; + (hwdesc->thd).optlen[1] = 0; + (hwdesc->thd).optlen[2] = 0; + *(undefined4 *)bufctrl->field_0 = 0xbadcab1e; + (frame->txdesc).lmac.hw_desc = hwdesc; + (frame->txdesc).lmac.buffer = buffer; + (frame->txdesc).umac.buf_control = bufctrl; + frame->type = '\x01'; + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void txl_frame_init(_Bool reset) + +{ + tx_hw_desc *ptVar1; + txl_frame_desc_tag *__s; + uint8_t uVar2; + byte bVar3; + undefined3 in_register_00002029; + undefined3 extraout_var; + undefined3 extraout_var_00; + txl_buffer_control *ptVar4; + uint32_t *puVar5; + int iVar6; + + co_list_init((co_list *)&txl_frame_env); + co_list_init(&txl_frame_env.desc_done); + __s = txl_frame_desc; + ptVar1 = txl_frame_hwdesc_pool; + puVar5 = txl_frame_pool; + ptVar4 = txl_frame_buf_ctrl; + iVar6 = 0; + do { + if ((CONCAT31(in_register_00002029,reset) == 0) || ((&__s->type)[1] == '\0')) { + memset(__s,0,0x2d8); + (ptVar1->thd).upatterntx = 0xcafebabe; + (ptVar1->thd).frmlifetime = 0; + (ptVar1->thd).optlen[0] = 0; + (ptVar1->thd).optlen[1] = 0; + (ptVar1->thd).optlen[2] = 0; + *(undefined4 *)ptVar4->field_0 = 0xbadcab1e; + *(uint32_t **)&(__s->txdesc).lmac.buffer = puVar5; + (__s->txdesc).umac.buf_control = ptVar4; + (__s->txdesc).lmac.hw_desc = ptVar1; + ptVar1->cfm_ptr = txl_frame_hwdesc_cfms + iVar6; + *(txl_buffer_tag **)&(ptVar1->thd).field_4 = (txl_buffer_tag *)puVar5 + 1; + __s->type = '\0'; + co_list_push_back((co_list *)&txl_frame_env,(co_list_hdr *)__s); + } + iVar6 = iVar6 + 1; + __s = __s + 1; + ptVar1 = ptVar1 + 1; + puVar5 = (uint32_t *)(((txl_buffer_tag *)puVar5)[1].buffer_control.field_0 + 0x10); + ptVar4 = ptVar4 + 1; + } while (iVar6 != 4); + txl_buffer_control_24G.field_0._0_4_ = 0xbadcab1e; + txl_buffer_control_24G.mac_control_info = 0; + txl_buffer_control_24G.phy_control_info = 0; + uVar2 = phy_get_ntx(); + txl_buffer_control_24G.field_0._4_4_ = CONCAT31(extraout_var,uVar2) << 0xe; + bVar3 = phy_get_ntx(); + txl_buffer_control_24G.field_0._8_4_ = (1 << ((uint)bVar3 + 1 & 0x1f)) + -1; + txl_buffer_control_24G.field_0._16_4_ = 0xffff0704; + txl_buffer_control_24G.field_0._20_4_ = 0x400; + txl_buffer_control_24G.field_0._12_4_ = 0; + txl_buffer_control_24G.field_0._24_4_ = 0; + txl_buffer_control_24G.field_0._28_4_ = 0; + txl_buffer_control_24G.field_0._32_4_ = 0; + txl_buffer_control_24G.field_0._40_4_ = 0; + txl_buffer_control_24G.field_0._44_4_ = 0; + txl_buffer_control_24G.field_0._48_4_ = 0; + txl_buffer_control_5G.field_0._0_4_ = 0xbadcab1e; + txl_buffer_control_5G.mac_control_info = 0; + txl_buffer_control_5G.phy_control_info = 0; + uVar2 = phy_get_ntx(); + txl_buffer_control_5G.field_0._4_4_ = CONCAT31(extraout_var_00,uVar2) << 0xe; + bVar3 = phy_get_ntx(); + txl_buffer_control_5G.field_0._8_4_ = (1 << ((uint)bVar3 + 1 & 0x1f)) + -1; + txl_buffer_control_5G.field_0._12_4_ = 0; + txl_buffer_control_5G.field_0._16_4_ = 0xffff0704; + txl_buffer_control_5G.field_0._20_4_ = iVar6; + txl_buffer_control_5G.field_0._24_4_ = 0; + txl_buffer_control_5G.field_0._28_4_ = 0; + txl_buffer_control_5G.field_0._32_4_ = 0; + txl_buffer_control_5G.field_0._40_4_ = 0; + txl_buffer_control_5G.field_0._44_4_ = 0; + txl_buffer_control_5G.field_0._48_4_ = 0; + return; +} + + + +// WARNING: Type propagation algorithm not settling + +txl_frame_desc_tag * txl_frame_get(int type,int len) + +{ + txl_frame_desc_tag *ptVar1; + tx_hw_desc *ptVar2; + uint8_t uVar3; + undefined3 extraout_var; + uint32_t uVar4; + uint32_t uVar5; + txl_buffer_control *__src; + txl_buffer_control *__dest; + txl_buffer_tag *ptVar6; + + ptVar1 = (txl_frame_desc_tag *)co_list_pop_front((co_list *)&txl_frame_env); + if (ptVar1 == (txl_frame_desc_tag *)0x0) { + tx_count = tx_count + 1; + if (tx_count == 10) { + tx_count = 0; + rx_count = 2; + uVar4 = co_list_cnt((co_list *)&txl_frame_env); + uVar5 = co_list_cnt(&txl_frame_env.desc_done); + if ((uVar5 | uVar4) == 0) { + txl_cntrl_clear_all_ac(); + } + } + } + else { + if (rx_count == 1) { + rx_count = 0; + mac_hw_reset = '\x01'; + vTaskEnterCritical(); + assert_rec("MAC HW RESET include tx and rx","tx rx",0x10b); + vTaskDelay(200); + ptVar1 = (txl_frame_desc_tag *)0x0; + vTaskExitCritical(); + } + else { + if (rx_count != 0) { + rx_count = rx_count - 1; + } + ptVar2 = (ptVar1->txdesc).lmac.hw_desc; + ptVar6 = (ptVar1->txdesc).lmac.buffer; + (ptVar2->thd).frmlen = len + 4; + (ptVar2->thd).field_5 = (ptVar2->thd).field_4 + len + -1; + __dest = &ptVar6->buffer_control; + if (type == 0) { + __src = &txl_buffer_control_24G; + } + else { + __src = __dest; + if (type == 1) { + __src = &txl_buffer_control_5G; + } + } + memcpy(__dest,__src,0x34); + uVar3 = tpc_get_vif_tx_power_vs_rate(*(uint32_t *)((ptVar6->buffer_control).field_0 + 0x14)); + *(uint *)((ptVar6->buffer_control).field_0 + 0x24) = CONCAT31(extraout_var,uVar3); + *(txl_buffer_control **)&(ptVar2->thd).policyentryaddr = __dest; + (ptVar2->thd).phyctrlinfo = 0; + (ptVar2->thd).macctrlinfo2 = 0; + (ptVar2->thd).field_3 = 0; + (ptVar1->cfm).cfm_func = (cfm_func_ptr *)0x0; + (ptVar1->cfm).env = (void *)0x0; + } + } + return ptVar1; +} + + + +_Bool txl_frame_push(txl_frame_desc_tag *frame,uint8_t ac) + +{ + byte bVar1; + tx_hw_desc *ptVar2; + _Bool _Var3; + + ptVar2 = (frame->txdesc).lmac.hw_desc; + if (((ptVar2->thd).field_4 & 1) != 0) { + assert_err("(thd->datastartptr & 0x01) == 0","module",0x182); + } + (ptVar2->thd).nextfrmexseq_ptr = 0; + (ptVar2->thd).nextmpdudesc_ptr = 0; + (ptVar2->thd).macctrlinfo2 = (ptVar2->thd).macctrlinfo2 & 0xff87ffff; + bVar1 = *(byte *)((ptVar2->thd).field_4 + 4); + (ptVar2->thd).statinfo = 0; + (ptVar2->thd).macctrlinfo1 = (uint)((bVar1 & 1) == 0) << 9; + _Var3 = txl_cntrl_push_int((txdesc *)frame,ac); + return _Var3; +} + + + +_Bool txl_frame_push_force(txl_frame_desc_tag *frame,uint8_t ac) + +{ + byte bVar1; + tx_hw_desc *ptVar2; + _Bool _Var3; + + ptVar2 = (frame->txdesc).lmac.hw_desc; + if (((ptVar2->thd).field_4 & 1) != 0) { + assert_err("(thd->datastartptr & 0x01) == 0","module",0x1ad); + } + (ptVar2->thd).nextfrmexseq_ptr = 0; + (ptVar2->thd).nextmpdudesc_ptr = 0; + (ptVar2->thd).macctrlinfo2 = (ptVar2->thd).macctrlinfo2 & 0xff87ffff; + bVar1 = *(byte *)((ptVar2->thd).field_4 + 4); + (ptVar2->thd).statinfo = 0; + (ptVar2->thd).macctrlinfo1 = (uint)((bVar1 & 1) == 0) << 9; + _Var3 = txl_cntrl_push_int_force((txdesc *)frame,ac); + return _Var3; +} + + + +void txl_frame_cfm(txdesc *txdesc) + +{ + co_list_push_back(&txl_frame_env.desc_done,(co_list_hdr *)txdesc); + ke_evt_set(0x20000); + return; +} + + + +void txl_frame_release(txdesc *txdesc,_Bool postponed) + +{ + co_list_hdr *UNRECOVERED_JUMPTABLE; + undefined3 in_register_0000202d; + + if (*(char *)&txdesc[1].host.packet_addr == '\0') { + co_list_push_back((co_list *)&txl_frame_env,(co_list_hdr *)txdesc); + } + if ((CONCAT31(in_register_0000202d,postponed) != 0) && + (UNRECOVERED_JUMPTABLE = txdesc[1].list_hdr.next, UNRECOVERED_JUMPTABLE != (co_list_hdr *)0x0)) + { + // WARNING: Could not recover jumptable at 0x230065c4. Too many branches + // WARNING: Treating indirect jump as call + (*(code *)UNRECOVERED_JUMPTABLE)(txdesc[1].host.pbuf_addr,0); + return; + } + return; +} + + +/* +Unable to decompile 'txl_frame_evt' +Cause: Exception while decompiling 230065d0: Decompiler process died + +*/ + + +uint8_t txl_frame_send_null_frame(uint8_t sta_idx,cfm_func_ptr *cfm,void *env) + +{ + byte bVar1; + uint8_t uVar2; + txl_buffer_tag *ptVar3; + undefined3 in_register_00002029; + int iVar4; + txl_frame_desc_tag *frame; + uint uVar5; + int iVar6; + char acStack56 [4]; + phy_channel_info phy_info; + + iVar4 = CONCAT31(in_register_00002029,sta_idx); + bVar1 = sta_info_tab[iVar4].inst_nbr; + phy_get_channel((phy_channel_info *)acStack56,'\0'); + frame = txl_frame_get((uint)(acStack56[0] != '\0'),0x18); + if (frame != (txl_frame_desc_tag *)0x0) { + tpc_update_frame_tx_power(vif_info_tab + bVar1,frame); + ptVar3 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar3[1].length = 0x48; + *(undefined *)((int)&ptVar3[1].length + 1) = 1; + *(undefined *)((int)&ptVar3[1].length + 2) = 0; + *(undefined *)((int)&ptVar3[1].length + 3) = 0; + memcpy(&ptVar3[1].lenheader,&sta_info_tab[iVar4].mac_addr,6); + memcpy((void *)((int)&ptVar3[1].lenpad + 2),&vif_info_tab[bVar1].mac_addr,6); + memcpy(&ptVar3[1].next,&sta_info_tab[iVar4].mac_addr,6); + uVar5 = (uint)txl_cntrl_env.seqnbr; + txl_cntrl_env.seqnbr = (uint16_t)((uVar5 + 1) * 0x10000 >> 0x10); + iVar6 = (uVar5 + 1) * 0x100000; + *(undefined *)((int)&ptVar3[1].txdesc + 2) = (char)((uint)iVar6 >> 0x10); + *(undefined *)((int)&ptVar3[1].txdesc + 3) = (char)((uint)iVar6 >> 0x18); + (frame->cfm).cfm_func = cfm; + (frame->cfm).env = env; + uVar2 = sta_info_tab[iVar4].inst_nbr; + (frame->txdesc).host.staid = sta_idx; + (frame->txdesc).host.vif_idx = uVar2; + txl_frame_push(frame,'\x03'); + } + return (uint8_t)(frame == (txl_frame_desc_tag *)0x0); +} + + + +// WARNING: Variable defined which should be unmapped: phy_info + +uint8_t txl_frame_send_qosnull_frame(uint8_t sta_idx,uint16_t qos,cfm_func_ptr *cfm,void *env) + +{ + txl_buffer_tag *ptVar1; + uint8_t uVar2; + undefined3 in_register_00002029; + int iVar3; + txl_frame_desc_tag *frame; + mac_addr *__src; + uint uVar4; + char acStack56 [4]; + phy_channel_info phy_info; + + iVar3 = CONCAT31(in_register_00002029,sta_idx); + uVar4 = (uint)sta_info_tab[iVar3].inst_nbr; + phy_get_channel((phy_channel_info *)acStack56,'\0'); + frame = txl_frame_get((uint)(acStack56[0] != '\0'),0x1a); + if (frame == (txl_frame_desc_tag *)0x0) { + uVar2 = '\x01'; + } + else { + tpc_update_frame_tx_power(vif_info_tab + uVar4,frame); + ptVar1 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar1[1].length = 200; + *(undefined *)((int)&ptVar1[1].length + 1) = 0; + *(undefined *)((int)&ptVar1[1].length + 2) = 0; + *(undefined *)((int)&ptVar1[1].length + 3) = 0; + memcpy(&ptVar1[1].lenheader,&sta_info_tab[iVar3].mac_addr,6); + __src = &vif_info_tab[uVar4].mac_addr; + memcpy((void *)((int)&ptVar1[1].lenpad + 2),__src,6); + uVar2 = vif_info_tab[uVar4].type; + *(undefined *)&ptVar1[1].length = 200; + if (uVar2 == '\0') { + *(undefined *)((int)&ptVar1[1].length + 1) = 1; + __src = &sta_info_tab[iVar3].mac_addr; + } + else { + *(undefined *)((int)&ptVar1[1].length + 1) = 2; + } + memcpy(&ptVar1[1].next,__src,6); + *(char *)&ptVar1[1].dma_desc[0].src = (char)qos; + *(undefined *)((int)&ptVar1[1].txdesc + 2) = 0; + *(undefined *)((int)&ptVar1[1].txdesc + 3) = 0; + *(undefined *)((int)&ptVar1[1].dma_desc[0].src + 1) = (char)(qos >> 8); + (frame->cfm).cfm_func = cfm; + (frame->cfm).env = env; + uVar2 = sta_info_tab[iVar3].inst_nbr; + (frame->txdesc).host.staid = sta_idx; + (frame->txdesc).host.vif_idx = uVar2; + txl_frame_push(frame,'\x03'); + uVar2 = '\0'; + } + return uVar2; +} + + + +uint8_t txl_frame_send_eapol_frame + (uint8_t sta_idx,cfm_func_ptr *cfm,void *cfm_env,uint8_t *pBuf,uint32_t pBuf_len) + +{ + byte bVar1; + uint8_t uVar2; + ushort uVar3; + undefined2 uVar4; + txl_buffer_tag *ptVar5; + undefined3 in_register_00002029; + txl_frame_desc_tag *frame; + key_info_tag *pkVar6; + uint32_t uVar7; + undefined *puVar8; + int iVar9; + tx_hw_desc *ptVar10; + uint16_t uVar11; + uint uVar12; + dma_desc *pdVar13; + uint uVar14; + dma_desc *unaff_s8; + mac_addr *pmVar15; + mac_addr *pmVar16; + uint uVar17; + int iVar18; + char acStack88 [4]; + phy_channel_info phy_info; + mic_calc mic; + + iVar18 = CONCAT31(in_register_00002029,sta_idx); + bVar1 = sta_info_tab[iVar18].inst_nbr; + uVar17 = (uint)bVar1; + phy_get_channel((phy_channel_info *)acStack88,'\0'); + frame = txl_frame_get((uint)(acStack88[0] != '\0'),0x100); + if (frame == (txl_frame_desc_tag *)0x0) { + return '\0'; + } + (frame->txdesc).host.vif_idx = bVar1; + (frame->txdesc).host.staid = sta_idx; + (frame->txdesc).host.tid = '\0'; + uVar3 = sta_info_tab[iVar18].seq_nbr[0]; + sta_info_tab[iVar18].seq_nbr[0] = (ushort)(((uint)uVar3 + 1) * 0x100000 >> 0x14); + (frame->txdesc).host.ethertype = 0x8e88; + (frame->txdesc).host.sn = uVar3; + pmVar15 = &sta_info_tab[iVar18].mac_addr; + (frame->txdesc).host.eth_dest_addr.array[0] = pmVar15->array[0]; + (frame->txdesc).host.eth_dest_addr.array[1] = sta_info_tab[iVar18].mac_addr.array[1]; + (frame->txdesc).host.eth_dest_addr.array[2] = sta_info_tab[iVar18].mac_addr.array[2]; + pmVar16 = &vif_info_tab[uVar17].mac_addr; + (frame->txdesc).host.eth_src_addr.array[0] = pmVar16->array[0]; + (frame->txdesc).host.eth_src_addr.array[1] = vif_info_tab[uVar17].mac_addr.array[1]; + (frame->txdesc).host.eth_src_addr.array[2] = vif_info_tab[uVar17].mac_addr.array[2]; + tpc_update_frame_tx_power(vif_info_tab + uVar17,frame); + ptVar5 = (frame->txdesc).lmac.buffer; + if ((vif_info_tab[uVar17].bss_info.valid_flags & 1) == 0) { + *(undefined *)&ptVar5[1].length = 8; + uVar14 = (uint)txl_cntrl_env.seqnbr; + *(undefined *)((int)&ptVar5[1].length + 1) = 0; + pdVar13 = ptVar5[1].dma_desc; + txl_cntrl_env.seqnbr = (uint16_t)((uVar14 + 1) * 0x10000 >> 0x10); + iVar9 = (uVar14 + 1) * 0x100000; + *(undefined *)((int)&ptVar5[1].txdesc + 2) = (char)((uint)iVar9 >> 0x10); + *(undefined *)((int)&ptVar5[1].txdesc + 3) = (char)((uint)iVar9 >> 0x18); + uVar14 = pBuf_len + 0x20; + } + else { + *(undefined *)&ptVar5[1].length = 0x88; + *(undefined *)((int)&ptVar5[1].length + 1) = 0; + pdVar13 = (dma_desc *)((int)&ptVar5[1].dma_desc[0].src + 2); + uVar14 = pBuf_len + 0x22; + iVar9 = (uint)(frame->txdesc).host.sn << 0x14; + *(undefined *)((int)&ptVar5[1].txdesc + 2) = (char)((uint)iVar9 >> 0x10); + *(undefined *)((int)&ptVar5[1].txdesc + 3) = (char)((uint)iVar9 >> 0x18); + uVar2 = (frame->txdesc).host.tid; + *(undefined *)((int)&ptVar5[1].dma_desc[0].src + 1) = 0; + *(uint8_t *)&ptVar5[1].dma_desc[0].src = uVar2; + } + if (0x100 < uVar14) { + assert_err("length<=NX_TXFRAME_LEN","module",0x591); + } + uVar4 = *(undefined2 *)&ptVar5[1].length; + bVar1 = 1; + if (vif_info_tab[uVar17].type == '\x02') { + bVar1 = 2; + } + *(char *)&ptVar5[1].length = (char)uVar4; + *(byte *)((int)&ptVar5[1].length + 1) = (byte)((ushort)uVar4 >> 8) | bVar1; + *(undefined *)((int)&ptVar5[1].length + 2) = 0; + *(undefined *)((int)&ptVar5[1].length + 3) = 0; + *(uint16_t *)&ptVar5[1].lenheader = pmVar15->array[0]; + *(uint16_t *)((int)&ptVar5[1].lenheader + 2) = sta_info_tab[iVar18].mac_addr.array[1]; + *(uint16_t *)&ptVar5[1].lenpad = sta_info_tab[iVar18].mac_addr.array[2]; + *(uint16_t *)((int)&ptVar5[1].lenpad + 2) = pmVar16->array[0]; + *(uint16_t *)&ptVar5[1].flags = vif_info_tab[uVar17].mac_addr.array[1]; + *(uint16_t *)((int)&ptVar5[1].flags + 2) = vif_info_tab[uVar17].mac_addr.array[2]; + if (vif_info_tab[uVar17].type == '\x02') { + *(uint16_t *)&ptVar5[1].next = pmVar16->array[0]; + *(uint16_t *)((int)&ptVar5[1].next + 2) = vif_info_tab[uVar17].mac_addr.array[1]; + uVar11 = vif_info_tab[uVar17].mac_addr.array[2]; + } + else { + *(uint16_t *)&ptVar5[1].next = pmVar15->array[0]; + *(uint16_t *)((int)&ptVar5[1].next + 2) = sta_info_tab[iVar18].mac_addr.array[1]; + uVar11 = sta_info_tab[iVar18].mac_addr.array[2]; + } + *(uint16_t *)&ptVar5[1].txdesc = uVar11; + iVar18 = 0; + if ((vif_info_tab[(frame->txdesc).host.vif_idx].type != '\0') || + (uVar17 = (uint)(frame->txdesc).host.staid, sta_info_tab[uVar17].ctrl_port_state != '\x02')) + goto LAB_23006b64; + pkVar6 = *sta_info_tab[uVar17].sta_sec_info.cur_key; + uVar2 = pkVar6->cipher; + if (uVar2 == '\x01') { + uVar17 = *(uint *)&pkVar6->tx_pn + 1; + *(int *)((int)&pkVar6->tx_pn + 4) = + (uint)(uVar17 < *(uint *)&pkVar6->tx_pn) + *(int *)((int)&pkVar6->tx_pn + 4); + *(uint *)&pkVar6->tx_pn = uVar17; + memcpy((frame->txdesc).host.pn,&pkVar6->tx_pn,6); + iVar9 = 0xc; +LAB_23006cbc: + iVar18 = 8; + } + else { + if (uVar2 == '\0') { +LAB_23006a9e: + uVar17 = *(uint *)&pkVar6->tx_pn + 1; + *(int *)((int)&pkVar6->tx_pn + 4) = + (uint)(uVar17 < *(uint *)&pkVar6->tx_pn) + *(int *)((int)&pkVar6->tx_pn + 4); + *(uint *)&pkVar6->tx_pn = uVar17; + memcpy((frame->txdesc).host.pn,&pkVar6->tx_pn,4); + iVar9 = 4; + iVar18 = 4; + } + else { + if (uVar2 == '\x02') { + uVar17 = *(uint *)&pkVar6->tx_pn + 1; + *(int *)((int)&pkVar6->tx_pn + 4) = + (uint)(uVar17 < *(uint *)&pkVar6->tx_pn) + *(int *)((int)&pkVar6->tx_pn + 4); + *(uint *)&pkVar6->tx_pn = uVar17; + memcpy((frame->txdesc).host.pn,&pkVar6->tx_pn,6); + iVar9 = 8; + goto LAB_23006cbc; + } + if (uVar2 == '\x03') goto LAB_23006a9e; + iVar9 = 0; + iVar18 = 0; + } + } + iVar18 = iVar18 + iVar9; + if (iVar18 == 0) goto LAB_23006b64; + uVar3 = *(ushort *)&ptVar5[1].length; + uVar14 = uVar14 + iVar18; + *(char *)&ptVar5[1].length = (char)uVar3; + *(byte *)((int)&ptVar5[1].length + 1) = (byte)((uint)uVar3 >> 8) | 0x40; + uVar17 = (uint)vif_info_tab[(frame->txdesc).host.vif_idx].type; + if (vif_info_tab[(frame->txdesc).host.vif_idx].type == 0) { + uVar12 = (uint)(frame->txdesc).host.staid; + if (sta_info_tab[uVar12].ctrl_port_state == '\x02') { + pkVar6 = *sta_info_tab[uVar12].sta_sec_info.cur_key; + uVar7 = (((frame->txdesc).lmac.hw_desc)->thd).policyentryaddr; + uVar2 = pkVar6->cipher; + if (uVar2 == '\x01') { + uVar3 = (frame->txdesc).host.pn[0]; + *(ushort *)&pdVar13->src = uVar3 & 0x7f00 | 0x2000 | uVar3 >> 8; + uVar3 = (ushort)*(byte *)(frame->txdesc).host.pn | (ushort)pkVar6->key_idx << 0xe; +LAB_23006d14: + *(ushort *)((int)&pdVar13->src + 2) = uVar3 | 0x2000; + uVar17 = 8; + *(uint16_t *)&pdVar13->dest = (frame->txdesc).host.pn[1]; + *(uint16_t *)((int)&pdVar13->dest + 2) = (frame->txdesc).host.pn[2]; + } + else { + if (uVar2 == '\0') { +LAB_23006b32: + *(uint16_t *)&pdVar13->src = (frame->txdesc).host.pn[0]; + *(ushort *)((int)&pdVar13->src + 2) = + (ushort)pkVar6->key_idx << 0xe | (frame->txdesc).host.pn[1]; + uVar17 = 4; + } + else { + if (uVar2 == '\x02') { + *(uint16_t *)&pdVar13->src = (frame->txdesc).host.pn[0]; + uVar3 = (ushort)pkVar6->key_idx << 0xe; + goto LAB_23006d14; + } + if (uVar2 == '\x03') goto LAB_23006b32; + } + } + *(uint *)(uVar7 + 0xc) = *(uint *)(uVar7 + 0xc) & 0xffc00 | (uint)pkVar6->hw_key_idx; + } + } + else { + uVar17 = 0; + } + pdVar13 = (dma_desc *)((int)&pdVar13->src + uVar17); + unaff_s8 = pdVar13; +LAB_23006b64: + *(undefined2 *)&pdVar13->src = 0xaaaa; + *(undefined2 *)((int)&pdVar13->src + 2) = 3; + *(undefined2 *)&pdVar13->dest = 0; + *(uint16_t *)((int)&pdVar13->dest + 2) = (frame->txdesc).host.ethertype; + memcpy(&pdVar13->length,pBuf,pBuf_len); + if ((iVar18 != 0) && + (pkVar6 = *sta_info_tab[(frame->txdesc).host.staid].sta_sec_info.cur_key, + pkVar6->cipher == '\x01')) { + me_mic_init((mic_calc *)&phy_info.info2,(uint32_t *)pkVar6->u, + &(frame->txdesc).host.eth_dest_addr,&(frame->txdesc).host.eth_src_addr, + (frame->txdesc).host.tid); + me_mic_calc((mic_calc *)&phy_info.info2,(uint32_t)unaff_s8,pBuf_len + 8); + me_mic_end((mic_calc *)&phy_info.info2); + iVar18 = 0; + do { + puVar8 = (undefined *)((int)&phy_info.info2 + iVar18); + iVar9 = iVar18 + pBuf_len + 8; + iVar18 = iVar18 + 1; + *(undefined *)((int)&unaff_s8->length + iVar9 + -8) = *puVar8; + } while (iVar18 != 8); + } + ptVar10 = (frame->txdesc).lmac.hw_desc; + (ptVar10->thd).field_5 = (ptVar10->thd).field_4 + -1 + uVar14; + (ptVar10->thd).frmlen = uVar14 + 4; + if (cfm != (cfm_func_ptr *)0x0) { + (frame->cfm).cfm_func = cfm; + (frame->cfm).env = cfm_env; + } + txl_frame_push(frame,"\x01"[(frame->txdesc).host.tid]); + return '\0'; +} + + + +void txl_frame_dump(void) + +{ + uint32_t uVar1; + co_list_hdr cVar2; + co_list_hdr cVar3; + + uVar1 = co_list_cnt((co_list *)&txl_frame_env); + cVar2 = (co_list_hdr)txl_frame_env.desc_free.first; + if (uVar1 != 0) { + while (cVar3 = (co_list_hdr)txl_frame_env.desc_done.first, cVar2 != (co_list_hdr)0x0) { + cVar2 = *(co_list_hdr *)cVar2; + } + while (cVar3 != (co_list_hdr)0x0) { + cVar3 = *(co_list_hdr *)cVar3; + } + } + return; +} + + + +void txl_hwdesc_init(void) + +{ + return; +} + + + +void txl_hwdesc_reset(void) + +{ + return; +} + + + +void vif_mgmt_bcn_to_evt(void *env) + +{ + if (*(int *)((int)env + 0x40) != 0) { + chan_bcn_to_evt((vif_info_tag *)env); + return; + } + return; +} + + + +void vif_mgmt_init(void) + +{ + memset(&vif_mgmt_env,0,0x14); + co_list_init((co_list *)&vif_mgmt_env); + co_list_init(&vif_mgmt_env.used_list); + memset(vif_info_tab,0,0x5d8); + vif_info_tab[0].type = '\x04'; + vif_info_tab[0].tx_power = '\x7f'; + vif_info_tab[0].user_tx_power = '\x7f'; + vif_info_tab[0].tmr_bcn_to.cb = vif_mgmt_bcn_to_evt; + vif_info_tab[0].tmr_bcn_to.env = vif_info_tab; + co_list_push_back((co_list *)&vif_mgmt_env,(co_list_hdr *)vif_info_tab); + memset(vif_info_tab + 1,0,0x5d8); + vif_info_tab[1].type = '\x04'; + vif_info_tab[1].tx_power = '\x7f'; + vif_info_tab[1].user_tx_power = '\x7f'; + vif_info_tab[1].tmr_bcn_to.cb = vif_mgmt_bcn_to_evt; + vif_info_tab[1].tmr_bcn_to.env = vif_info_tab + 1; + co_list_push_back((co_list *)&vif_mgmt_env,(co_list_hdr *)(vif_info_tab + 1)); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t vif_mgmt_register(mac_addr *mac_addr,uint8_t vif_type,_Bool p2p,uint8_t *vif_idx) + +{ + uint8_t uVar1; + vif_info_tag *vif_entry; + undefined3 in_register_0000202d; + + if (vif_mgmt_env.free_list.first == (co_list_hdr *)0x0) { + uVar1 = '\x01'; + } + else { + if (vif_mgmt_env.used_list.first == (co_list_hdr *)0x0) { + mm_hw_info_set(mac_addr); + } + else { + if (*(int *)mac_addr->array != _DAT_44b00010) { + return '\x01'; + } + if (((mac_addr->array[2] ^ _DAT_44b00014) & ~_DAT_44b0001c) != 0) { + return '\x01'; + } + mm_env.rx_filter_lmac_enable = mm_env.rx_filter_lmac_enable | 0x10; + _DAT_44b00060 = mm_env.rx_filter_lmac_enable | mm_env.rx_filter_umac; + } + vif_entry = (vif_info_tag *)co_list_pop_front((co_list *)&vif_mgmt_env); + vif_entry->type = vif_type; + memcpy(&vif_entry->mac_addr,mac_addr,6); + uVar1 = (char)((int)&vif_entry[-0xb4b94].key_info[1].tx_pn >> 3) * 's'; + vif_entry->txq_params[1] = 0xa43; + vif_entry->txq_params[2] = 0x5e432; + vif_entry->index = uVar1; + vif_entry->txq_params[0] = 0xa47; + vif_entry->txq_params[3] = 0x2f322; + vif_entry->chan_ctxt = (chan_ctxt_tag *)0x0; + (vif_entry->tbtt_switch).vif_index = uVar1; + if (CONCAT31(in_register_0000202d,vif_type) == 0) { + *(vif_info_tag **)&(vif_entry->tbtt_timer).env = vif_entry; + vif_entry->u[0x1d] = 0; + vif_mgmt_env.vif_sta_cnt = vif_mgmt_env.vif_sta_cnt + '\x01'; + (vif_entry->tbtt_timer).cb = mm_sta_tbtt; + vif_entry->u[4] = 0xff; + vif_entry->u[0x1e] = 0; + } + else { + if (CONCAT31(in_register_0000202d,vif_type) == 2) { + if (vif_mgmt_env.vif_ap_cnt == '\0') { + mm_hw_ap_info_set(); + } + vif_mgmt_env.vif_ap_cnt = vif_mgmt_env.vif_ap_cnt + '\x01'; + mm_bcn_init_vif(vif_entry); + } + } + td_start(vif_entry->index); + *vif_idx = vif_entry->index; + co_list_push_back(&vif_mgmt_env.used_list,(co_list_hdr *)vif_entry); + uVar1 = '\0'; + } + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void vif_mgmt_unregister(uint8_t vif_idx) + +{ + vif_info_tag *__s; + undefined3 in_register_00002029; + int iVar1; + + iVar1 = CONCAT31(in_register_00002029,vif_idx); + __s = vif_info_tab + iVar1; + co_list_extract(&vif_mgmt_env.used_list,(co_list_hdr *)__s); + if (vif_info_tab[iVar1].type == '\0') { + vif_mgmt_env.vif_sta_cnt = vif_mgmt_env.vif_sta_cnt + -1; + } + else { + if (vif_info_tab[iVar1].type == '\x02') { + vif_mgmt_env.vif_ap_cnt = vif_mgmt_env.vif_ap_cnt + -1; + if (vif_mgmt_env.vif_ap_cnt == '\0') { + mm_hw_ap_info_reset(); + } + } + } + if ((uint)vif_mgmt_env.vif_ap_cnt + (uint)vif_mgmt_env.vif_sta_cnt == 1) { + mm_env.rx_filter_lmac_enable = mm_env.rx_filter_lmac_enable & 0xffffffef; + _DAT_44b00060 = mm_env.rx_filter_lmac_enable | mm_env.rx_filter_umac; + _DAT_44b00020 = vif_mgmt_env.used_list.first[0xe].next; + _DAT_44b00024 = (uint)*(ushort *)&vif_mgmt_env.used_list.first[0xf].next; + } + if (vif_info_tab[iVar1].type == '\x02') { + txl_cntrl_clear_bcn_ac(); + } + mm_timer_clear(&vif_info_tab[iVar1].tbtt_timer); + mm_timer_clear(&vif_info_tab[iVar1].tmr_bcn_to); + td_reset(vif_info_tab[iVar1].index); + memset(__s,0,0x5d8); + vif_info_tab[iVar1].type = '\x04'; + vif_info_tab[iVar1].tx_power = '\x7f'; + vif_info_tab[iVar1].user_tx_power = '\x7f'; + vif_info_tab[iVar1].tmr_bcn_to.cb = vif_mgmt_bcn_to_evt; + *(vif_info_tag **)&vif_info_tab[iVar1].tmr_bcn_to.env = __s; + co_list_push_back((co_list *)&vif_mgmt_env,(co_list_hdr *)__s); + return; +} + + + +void vif_mgmt_add_key(mm_key_add_req *param,uint8_t hw_key_idx) + +{ + uint8_t uVar1; + uint uVar2; + uint uVar3; + + uVar3 = (uint)param->inst_nbr; + uVar2 = (uint)param->key_idx; + vif_info_tab[uVar3].key_info[uVar2].hw_key_idx = hw_key_idx; + vif_info_tab[uVar3].key_info[uVar2].cipher = param->cipher_suite; + vif_info_tab[uVar3].key_info[uVar2].key_idx = param->key_idx; + memset(vif_info_tab[uVar3].key_info + uVar2,0,0x48); + uVar1 = vif_info_tab[uVar3].key_info[uVar2].cipher; + if (uVar1 == '\x01') { + *(undefined4 *)&vif_info_tab[uVar3].key_info[uVar2].tx_pn = 0; + *(undefined4 *)((int)&vif_info_tab[uVar3].key_info[uVar2].tx_pn + 4) = 0; + *(uint32_t *)vif_info_tab[uVar3].key_info[uVar2].u = (param->key).array[4]; + *(uint32_t *)(vif_info_tab[uVar3].key_info[uVar2].u + 4) = (param->key).array[5]; + *(uint32_t *)(vif_info_tab[uVar3].key_info[uVar2].u + 8) = (param->key).array[6]; + *(uint32_t *)(vif_info_tab[uVar3].key_info[uVar2].u + 0xc) = (param->key).array[7]; + } + else { + if ((uVar1 == '\0') || (uVar1 == '\x03')) { + next = next * 0x41c64e6d + 0x3039; + *(ulong *)&vif_info_tab[uVar3].key_info[uVar2].tx_pn = next >> 0x10; + *(undefined4 *)((int)&vif_info_tab[uVar3].key_info[uVar2].tx_pn + 4) = 0; + } + else { + *(undefined4 *)&vif_info_tab[uVar3].key_info[uVar2].tx_pn = 0; + *(undefined4 *)((int)&vif_info_tab[uVar3].key_info[uVar2].tx_pn + 4) = 0; + } + } + vif_info_tab[uVar3].key_info[uVar2].valid = true; + vif_info_tab[uVar3].default_key = vif_info_tab[uVar3].key_info + uVar2; + return; +} + + + +void vif_mgmt_del_key(vif_info_tag *vif,uint8_t keyid) + +{ + undefined3 in_register_0000202d; + _Bool *p_Var1; + int iVar2; + + vif->key_info[CONCAT31(in_register_0000202d,keyid)].valid = false; + if (vif->default_key == vif->key_info + CONCAT31(in_register_0000202d,keyid)) { + vif->default_key = (key_info_tag *)0x0; + p_Var1 = &vif->key_info[0].valid; + iVar2 = 0; + do { + if (*p_Var1 != false) { + vif->default_key = vif->key_info + iVar2; + return; + } + iVar2 = iVar2 + 1; + p_Var1 = p_Var1 + 0x68; + } while (iVar2 != 4); + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void vif_mgmt_send_postponed_frame(vif_info_tag *p_vif_entry) + +{ + sta_info_tag *p_sta_entry; + + p_sta_entry = (sta_info_tag *)(p_vif_entry->sta_list).first; + while (p_sta_entry != (sta_info_tag *)0x0) { + sta_mgmt_send_postponed_frame(p_vif_entry,p_sta_entry,0); + p_sta_entry = *(sta_info_tag **)&p_sta_entry->list_hdr; + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void vif_mgmt_reset(void) + +{ + vif_info_tag *p_vif_entry; + + p_vif_entry = (vif_info_tag *)vif_mgmt_env.used_list.first; + while (p_vif_entry != (vif_info_tag *)0x0) { + vif_mgmt_send_postponed_frame(p_vif_entry); + p_vif_entry = *(vif_info_tag **)&p_vif_entry->list_hdr; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void vif_mgmt_bcn_to_prog(vif_info_tag *p_vif_entry) + +{ + mm_timer_set(&p_vif_entry->tmr_bcn_to,_DAT_44b00120 + 10000); + return; +} + + + +void vif_mgmt_bcn_recv(vif_info_tag *p_vif_entry) + +{ + if (((ps_env.ps_on != false) && ((ps_env.prevent_sleep & 8) == 0)) && + (p_vif_entry->prevent_sleep == 0)) { + mm_timer_clear(&p_vif_entry->tmr_bcn_to); + vif_mgmt_bcn_to_evt(p_vif_entry); + return; + } + return; +} + + +/* +Unable to decompile 'vif_mgmt_set_ap_bcn_int' +Cause: Exception while decompiling 230072dc: Decompiler process died + +*/ + + +// WARNING: Variable defined which should be unmapped: chan_idx +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void vif_mgmt_switch_channel(vif_info_tag *p_vif_entry) + +{ + byte bVar1; + uint16_t freq; + uint8_t uVar2; + void *pvVar3; + scan_chan_tag *psVar4; + undefined3 extraout_var; + uint8_t chan_idx_00; + uint8_t local_11 [4]; + uint8_t chan_idx; + + pvVar3 = ke_msg_alloc(0x58,0xd,0,3); + local_11[0] = -1; + chan_ctxt_unlink(p_vif_entry->index); + freq = (p_vif_entry->csa_channel).prim20_freq; + chan_idx_00 = (uint8_t)freq; + psVar4 = me_freq_to_chan_ptr((p_vif_entry->csa_channel).band,freq); + freq = (p_vif_entry->csa_channel).center1_freq; + (p_vif_entry->bss_info).chan = psVar4; + (p_vif_entry->bss_info).center_freq1 = freq; + (p_vif_entry->bss_info).center_freq2 = (p_vif_entry->csa_channel).center2_freq; + uVar2 = (p_vif_entry->csa_channel).type; + (p_vif_entry->bss_info).phy_bw = uVar2; + if (uVar2 == '\x04') { + uVar2 = '\x03'; + } + (p_vif_entry->bss_info).bw = uVar2; + if (psVar4 == (scan_chan_tag *)0x0) { + ebreak(); + } + else { + (p_vif_entry->csa_channel).tx_power = psVar4->tx_power; + uVar2 = chan_ctxt_add(&p_vif_entry->csa_channel,local_11); + psVar4 = (scan_chan_tag *)CONCAT31(extraout_var,uVar2); + *(uint8_t *)((int)pvVar3 + 1) = uVar2; + *(uint8_t *)((int)pvVar3 + 2) = local_11[0]; + chan_idx_00 = local_11[0]; + if (p_vif_entry->type != '\0') { + if ((p_vif_entry->type == '\x02') && + (p_vif_entry->u[0x2eb] = 0, psVar4 == (scan_chan_tag *)0x0)) { + chan_ctxt_link(p_vif_entry->index,local_11[0]); + mm_bcn_env.update_ongoing = true; + } + goto LAB_2300745a; + } + } + p_vif_entry->u[0x1d] = 0; + if (psVar4 == (scan_chan_tag *)0x0) { + bVar1 = p_vif_entry->u[4]; + chan_ctxt_link(p_vif_entry->index,chan_idx_00); + mm_timer_clear(&p_vif_entry->tmr_bcn_to); + mm_timer_set(&p_vif_entry->tbtt_timer,_DAT_44b00120 + sta_info_tab[bVar1].bcn_int); + p_vif_entry->u[0x18] = 0; + p_vif_entry->u[0x1e] = 1; + } + else { + mm_send_connection_loss_ind(p_vif_entry); + } +LAB_2300745a: + ke_msg_send(pvVar3); + return; +} + + + +vif_info_tag * vif_mgmt_get_first_ap_inf(void) + +{ + co_list_hdr cVar1; + co_list_hdr cVar2; + + cVar1 = (co_list_hdr)vif_mgmt_env.used_list.first; + cVar2 = (co_list_hdr)0x0; + if (vif_mgmt_env.vif_ap_cnt != '\0') { + while ((cVar2 = cVar1, cVar1 != (co_list_hdr)0x0 && (*(char *)((int)cVar1 + 0x56) != '\x02'))) { + cVar1 = *(co_list_hdr *)cVar1; + } + } + return (vif_info_tag *)cVar2; +} + + + +void me_init(void) + +{ + memset(&me_env,0,0x134); + ke_state_set(5,0); + scanu_init(); + apm_init(); + sm_init(); + bam_init(); + return; +} + + + +scan_chan_tag * me_freq_to_chan_ptr(uint8_t band,uint16_t freq) + +{ + int iVar1; + byte bVar2; + ushort *puVar3; + undefined3 in_register_00002029; + scan_chan_tag *psVar4; + undefined2 in_register_0000202e; + scan_chan_tag *psVar5; + scan_chan_tag *psVar6; + + if (CONCAT31(in_register_00002029,band) == 0) { + iVar1 = 4; + bVar2 = me_env.chan.chan2G4_cnt; + } + else { + iVar1 = 0x58; + bVar2 = me_env.chan.chan5G_cnt; + } + psVar5 = (scan_chan_tag *)((int)&me_env.tx_lft + iVar1); + psVar6 = psVar5; + do { + if (psVar6 == psVar5 + bVar2) { + return (scan_chan_tag *)0x0; + } + psVar4 = psVar6; + puVar3 = &psVar6->freq; + psVar6 = psVar6 + 1; + } while ((uint)*puVar3 != CONCAT22(in_register_0000202e,freq)); + return psVar4; +} + + + +void michael_block(mic_calc *mic_calc_ptr,uint32_t block) + +{ + uint uVar1; + uint uVar2; + + uVar1 = block ^ mic_calc_ptr->mic_key_least; + uVar2 = mic_calc_ptr->mic_key_most ^ (uVar1 >> 0xf | uVar1 << 0x11); + uVar1 = uVar1 + uVar2; + uVar2 = (uVar1 >> 8 & 0xff00ff | uVar1 * 0x100 & 0xff00ff00) ^ uVar2; + uVar1 = uVar1 + uVar2; + uVar2 = (uVar1 * 8 | uVar1 >> 0x1d) ^ uVar2; + uVar1 = uVar1 + uVar2; + uVar2 = (uVar1 >> 2 | uVar1 * 0x40000000) ^ uVar2; + mic_calc_ptr->mic_key_most = uVar2; + mic_calc_ptr->mic_key_least = uVar1 + uVar2; + return; +} + + + +void me_mic_init(mic_calc *mic_calc_ptr,uint32_t *mic_key_ptr,mac_addr *da,mac_addr *sa,uint8_t tid) + +{ + uint32_t block; + uint16_t uVar1; + uint16_t uVar2; + uint32_t block_00; + undefined3 in_register_00002039; + uint32_t uVar3; + uint32_t block_01; + + block = *(uint32_t *)da->array; + block_01 = (uint)tid & 7; + uVar1 = sa->array[0]; + uVar2 = da->array[2]; + block_00 = *(uint32_t *)(sa->array + 1); + if (CONCAT31(in_register_00002039,tid) == 0xff) { + block_01 = 0; + } + mic_calc_ptr->mic_key_least = *mic_key_ptr; + uVar3 = mic_key_ptr[1]; + mic_calc_ptr->last_m_i = 0; + mic_calc_ptr->mic_key_most = uVar3; + mic_calc_ptr->last_m_i_len = '\0'; + michael_block(mic_calc_ptr,block); + michael_block(mic_calc_ptr,CONCAT22(uVar1,uVar2)); + michael_block(mic_calc_ptr,block_00); + michael_block(mic_calc_ptr,block_01); + return; +} + + + +void me_mic_calc(mic_calc *mic_calc_ptr,uint32_t start_ptr,uint32_t data_len) + +{ + uint8_t uVar1; + uint block; + uint block_00; + uint uVar2; + uint uVar3; + uint *puVar4; + uint uVar5; + uint uVar6; + uint *puVar7; + uint uVar8; + + puVar7 = (uint *)(start_ptr & 0xfffffffc) + 1; + block = 4 - (start_ptr & 3) & 0xff; + uVar3 = (uint)mic_calc_ptr->last_m_i_len; + uVar2 = *(uint *)(start_ptr & 0xfffffffc) >> ((start_ptr & 3) << 3); + uVar8 = data_len - block; + if (data_len < block) { + uVar2 = uVar2 & 0xffffffffU >> ((4 - data_len) * 8 & 0x1f); + block = data_len & 0xff; + uVar8 = 0; + } + block = block + uVar3; + block_00 = uVar2 << ((uVar3 & 3) << 3) | mic_calc_ptr->last_m_i; + uVar6 = block_00; + if (3 < block) { + uVar3 = (4 - uVar3) * 8; + uVar6 = 0; + if (uVar3 != 0x20) { + uVar6 = uVar2 >> (uVar3 & 0x1f); + } + block = block - 4; + michael_block(mic_calc_ptr,block_00); + } + uVar1 = (uint8_t)block; + uVar2 = (4 - block) * 8; + uVar3 = 0; + puVar4 = puVar7; + while (uVar8 >> 2 != uVar3) { + uVar5 = *puVar4; + puVar4 = puVar4 + 1; + block_00 = uVar5 << (block << 3 & 0x1f) | uVar6; + uVar6 = 0; + if (uVar2 != 0x20) { + uVar6 = uVar5 >> (uVar2 & 0x1f); + } + michael_block(mic_calc_ptr,block_00); + uVar3 = uVar3 + 1; + } + if ((uVar8 & 0xfffffffc) < uVar8) { + block_00 = (4 - (uVar8 & 3)) * 8; + uVar3 = 0; + if (block_00 != 0x20) { + uVar3 = 0xffffffff >> (block_00 & 0x1f); + } + uVar3 = *(uint *)((int)puVar7 + (uVar8 & 0xfffffffc)) & uVar3; + uVar8 = block + (uVar8 & 3); + uVar1 = (uint8_t)uVar8; + block = uVar6 | uVar3 << (block << 3 & 0x1f); + uVar6 = block; + if (3 < uVar8) { + uVar6 = 0; + if (uVar2 != 0x20) { + uVar6 = uVar3 >> (uVar2 & 0x1f); + } + uVar1 = uVar1 + -4; + michael_block(mic_calc_ptr,block); + } + } + mic_calc_ptr->last_m_i_len = uVar1; + mic_calc_ptr->last_m_i = uVar6; + return; +} + + + +void me_mic_end(mic_calc *mic_calc_ptr) + +{ + uint uVar1; + + uVar1 = mic_calc_ptr->last_m_i; + if (3 < mic_calc_ptr->last_m_i_len) { + assert_err("mic_calc_ptr->last_m_i_len < 4","module",0x13e); + } + michael_block(mic_calc_ptr,0x5a << (((uint)mic_calc_ptr->last_m_i_len & 3) << 3) | uVar1); + michael_block(mic_calc_ptr,0); + return; +} + + + +_Bool me_set_sta_ht_vht_param(sta_info_tag *sta,mac_bss_info *bss) + +{ + ushort uVar1; + uint uVar2; + uint uVar3; + uint8_t uVar4; + uint uVar5; + + uVar1 = (sta->info).ht_cap.ht_capa_info; + uVar3 = (uint)(uVar1 >> 1) & 1; + uVar2 = (int)(uint)uVar1 >> 8 & 3; + if ((uint)me_env.phy_bw_max < uVar3) { + uVar3 = (uint)me_env.phy_bw_max; + } + (sta->info).phy_bw_max = (uint8_t)uVar3; + uVar5 = (uint)bss->phy_bw; + if (bss->phy_bw == 4) { + uVar5 = 2; + } + uVar4 = (uint8_t)uVar5; + if (uVar3 < uVar5) { + uVar4 = (uint8_t)uVar3; + } + (sta->info).bw_cur = uVar4; + uVar4 = me_env.stbc_nss; + if (uVar2 < me_env.stbc_nss) { + uVar4 = (uint8_t)uVar2; + } + (sta->info).stbc_nss = uVar4; + return (_Bool)(((uint)uVar1 & 0xc) != 0xc); +} + + + +uint8_t me_11n_nss_max(uint8_t *mcs_set) + +{ + uint8_t uVar1; + + if (mcs_set[3] == '\0') { + uVar1 = '\x02'; + if ((mcs_set[2] == '\0') && (uVar1 = mcs_set[1], uVar1 != '\0')) { + uVar1 = '\x01'; + } + } + else { + uVar1 = '\x03'; + } + return uVar1; +} + + + +uint8_t me_legacy_ridx_min(uint16_t rate_map) + +{ + undefined2 in_register_0000202a; + uint uVar1; + + uVar1 = 0; + do { + if ((CONCAT22(in_register_0000202a,rate_map) >> (uVar1 & 0x1f) & 1U) != 0) { + return (uint8_t)uVar1; + } + uVar1 = uVar1 + 1; + } while (uVar1 != 0xc); + return '\f'; +} + + + +uint8_t me_legacy_ridx_max(uint16_t rate_map) + +{ + undefined2 in_register_0000202a; + char cVar1; + uint uVar2; + + if (CONCAT22(in_register_0000202a,rate_map) == 0) { + return '\f'; + } + uVar2 = 0xb; + do { + cVar1 = '\v' - (char)uVar2; + if ((CONCAT22(in_register_0000202a,rate_map) >> (uVar2 & 0x1f) & 1U) != 0) goto LAB_23007860; + uVar2 = uVar2 - 1; + } while (uVar2 != 0xffffffff); + cVar1 = '\f'; +LAB_23007860: + return '\v' - cVar1; +} + + + +uint8_t me_rate_translate(uint8_t rate) + +{ + uint8_t uVar1; + byte bVar2; + byte bVar3; + + bVar3 = rate & 0x7f; + if (bVar3 == 0x16) { + uVar1 = '\x03'; + } + else { + if (bVar3 < 0x17) { + if (bVar3 == 0xb) { + return '\x02'; + } + if (bVar3 < 0xc) { + if (bVar3 == 2) { + return '\0'; + } + bVar2 = 4; + uVar1 = '\x01'; + } + else { + if (bVar3 == 0xc) { + return '\x04'; + } + bVar2 = 0x12; + uVar1 = '\x05'; + } + } + else { + if (bVar3 == 0x30) { + return '\b'; + } + if (bVar3 < 0x31) { + if (bVar3 == 0x18) { + return '\x06'; + } + bVar2 = 0x24; + uVar1 = '\a'; + } + else { + if (bVar3 == 0x60) { + return '\n'; + } + if (bVar3 == 0x6c) { + return '\v'; + } + bVar2 = 0x48; + uVar1 = '\t'; + } + } + if (bVar3 != bVar2) { + return -1; + } + } + return uVar1; +} + + + +void me_get_basic_rates(mac_rateset *rateset,mac_rateset *basic_ratest) + +{ + byte bVar1; + int iVar2; + + basic_ratest->length = '\0'; + iVar2 = 0; + while (iVar2 < (int)(uint)rateset->length) { + if ((char)rateset->array[iVar2] < '\0') { + bVar1 = basic_ratest->length; + basic_ratest->array[bVar1] = rateset->array[iVar2]; + basic_ratest->length = bVar1 + 1; + } + iVar2 = iVar2 + 1; + } + return; +} + + + +uint16_t me_legacy_rate_bitfield_build(mac_rateset *rateset,_Bool basic_only) + +{ + uint uVar1; + int iVar2; + byte bVar3; + undefined3 extraout_var; + undefined3 in_register_0000202d; + + uVar1 = 0; + iVar2 = 0; + while (iVar2 < (int)(uint)rateset->length) { + if ((CONCAT31(in_register_0000202d,basic_only) == 0) || ((char)rateset->array[iVar2] < '\0')) { + bVar3 = me_rate_translate(rateset->array[iVar2]); + if (CONCAT31(extraout_var,bVar3) < 0xc) { + uVar1 = uVar1 | 1 << ((uint)bVar3 & 0x1f) & 0xffffU; + } + else { + assert_warn("bit_pos < MAC_RATESET_LEN","module",0x1c6); + } + } + iVar2 = iVar2 + 1; + } + return (uint16_t)uVar1; +} + + + +uint16_t me_build_capability(uint8_t vif_idx) + +{ + ushort uVar1; + undefined3 in_register_00002029; + int iVar2; + ushort uVar3; + + iVar2 = CONCAT31(in_register_00002029,vif_idx); + uVar3 = 0x11; + if (((vif_info_tab[iVar2].type != '\0') && (uVar3 = 1, vif_info_tab[iVar2].type == '\x02')) && + ((*(uint *)&vif_info_tab[iVar2].bss_info.is_supplicant_enabled & 0x12a00) != 0)) { + uVar3 = 0x11; + } + uVar1 = uVar3 | 0x520; + if ((vif_info_tab[iVar2].bss_info.chan)->band != '\x01') { + uVar1 = uVar3 | 0x420; + } + return (uint16_t)uVar1; +} + + + +void me_init_bcmc_rate(sta_info_tag *sta_entry) + +{ + byte bVar1; + byte rate; + uint8_t basic_rate_idx; + int iVar2; + + if ((sta_entry->info).rate_set.length == '\0') { + assert_err("rates->length != 0","module",0x229); + } + iVar2 = 0; + rate = 0; + while (iVar2 < (int)(uint)(sta_entry->info).rate_set.length) { + bVar1 = (sta_entry->info).rate_set.array[iVar2]; + if (rate < (bVar1 & 0x7f)) { + rate = bVar1 & 0x7f; + } + iVar2 = iVar2 + 1; + } + basic_rate_idx = me_rate_translate(rate); + rc_init_bcmc_rate(sta_entry,basic_rate_idx); + (sta_entry->pol_tbl).upd_field = '\0'; + return; +} + + + +void me_tx_cfm_singleton(txdesc *txdesc) + +{ + uint8_t sta_idx; + uint uVar1; + uint uVar2; + + uVar1 = ((txdesc->lmac).hw_desc)->cfm_ptr->status; + uVar2 = uVar1 & 0x10000; + uVar1 = uVar1 >> 8 & 0xff; + if (uVar2 == 0) { + sta_idx = (txdesc->host).staid; + } + else { + rf_dump_status(); + sta_idx = (txdesc->host).staid; + } + rc_update_counters(sta_idx,uVar1 + 1,uVar1 + (uVar2 != 0),false,false); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void me_check_rc(uint8_t sta_idx,_Bool *tx_ampdu) + +{ + ushort uVar1; + ushort uVar2; + ushort rate_config; + ushort rate_config_00; + uint16_t uVar3; + bool bVar4; + rc_sta_stats *rc_ss; + uint uVar5; + _Bool _Var6; + uint8_t uVar7; + uint8_t uVar8; + undefined3 in_register_00002029; + uint uVar9; + undefined3 extraout_var; + uint uVar10; + uint32_t uVar11; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + uint32_t uVar12; + byte bVar13; + uint32_t *puVar14; + uint uVar15; + int iVar16; + uint uVar17; + uint uVar18; + + uVar9 = CONCAT31(in_register_00002029,sta_idx); + if (9 < uVar9) { + return; + } + rc_ss = sta_info_tab[uVar9].pol_tbl.sta_stats; + if (rc_ss == (rc_sta_stats *)0x0) { + assert_err("rc_ss != NULL","module",0x826); + } + iVar16 = 0; + if ((int)((100000 - _DAT_44b00120) + rc_ss->last_rc_time) < 0) { + _Var6 = rc_update_stats(rc_ss,false); + iVar16 = CONCAT31(extraout_var,_Var6); + rc_ss->trial_status = '\0'; + rc_ss->sw_retry_step = '\0'; + rc_ss->info = rc_ss->info & 0xef; + rc_ss->last_rc_time = _DAT_44b00120; + } + if (rc_ss->trial_status == '\x01') { + if ((rc_ss->info & 0x40) == 0) { + bVar13 = rc_ss->format_mod; + uVar1 = rc_ss->retry[0].idx; + uVar15 = (uint)uVar1; + if (bVar13 < 2) { + if ((ushort)(rc_ss->rate_stats[uVar15].probability + 0xe667) < 0xd99b) { + uVar7 = '\n'; + } + else { + uVar7 = '\x05'; + } + } + else { + uVar7 = ((char)*(undefined2 *)((int)&rc_ss->avg_ampdu_len + 2) + '\b') * '\x02'; + } + rc_ss->sample_wait = uVar7; + next = next * 0x41c64e6d + 0x3039; + uVar5 = (next >> 0x10) % (uint)rc_ss->no_samples; + if (uVar5 != uVar15) { + uVar2 = rc_ss->retry[1].idx; + if (((uVar5 != (uint)uVar2) && (uVar18 = (uint)rc_ss->retry[2].idx, uVar5 != uVar18)) && + (puVar14 = &rc_ss->last_rc_time + uVar5 * 3, *(ushort *)(puVar14 + 2) < 0xf334)) { + rate_config = *(ushort *)((int)puVar14 + 10); + uVar10 = rc_get_duration((uint)rate_config); + rate_config_00 = rc_ss->rate_stats[uVar15].rate_config; + if (bVar13 < 2) { + uVar15 = rc_get_duration((uint)rate_config_00); + if (uVar15 < uVar10) { + uVar11 = 0; + bVar4 = 0x13 < *(byte *)(puVar14 + 3); + } + else { + uVar11 = 0; + bVar4 = true; + } + } + else { + uVar17 = 0x20; + uVar15 = rc_get_duration((uint)rc_ss->rate_stats[(uint)uVar2].rate_config); + if (*(char *)((int)puVar14 + 0xd) == '\0') { + uVar17 = (uint)*(ushort *)((int)&rc_ss->avg_ampdu_len + 2); + } + if (uVar15 <= uVar10) { + uVar7 = rc_get_nss(rate_config_00); + uVar8 = rc_get_nss(rate_config); + if ((CONCAT31(extraout_var_00,uVar7) - 1U < CONCAT31(extraout_var_01,uVar8)) || + (uVar15 = rc_get_duration((uint)rc_ss->rate_stats[uVar18].rate_config), + uVar15 <= uVar10)) { + if (uVar17 <= *(byte *)(puVar14 + 3)) { + bVar13 = rc_ss->sample_slow + 1; + rc_ss->sample_slow = bVar13; + if (bVar13 < 3) goto LAB_2300964c; + if (0xf < bVar13) { + rc_ss->sample_slow = '\x0f'; + } + } + goto LAB_23009626; + } + } +LAB_2300964c: + uVar11 = rc_calc_tp(rc_ss,(uint8_t)uVar5); + bVar4 = true; + if ((*(byte *)((int)puVar14 + 0xe) & 0xf) < 10) { + bVar4 = uVar17 <= *(byte *)(puVar14 + 3); + } + } + uVar12 = rc_ss->retry[1].tp; + (rc_ss->max_tp_2_trial).idx = uVar2; + (rc_ss->max_tp_2_trial).tp = uVar12; + if (bVar4) { + uVar12 = rc_ss->retry[0].tp; + rc_ss->info = rc_ss->info & 0xfd; + rc_ss->retry[1].tp = uVar12; + rc_ss->retry[1].idx = uVar1; + rc_ss->retry[0].tp = uVar11; + rc_ss->retry[0].idx = (uint16_t)uVar5; + } + else { + rc_ss->info = rc_ss->info | 2; + rc_ss->retry[1].tp = uVar11; + rc_ss->retry[1].idx = (uint16_t)uVar5; + } + rc_ss->trial_status = '\x02'; + goto LAB_2300958c; + } + } + } +LAB_23009626: + rc_ss->trial_status = '\0'; + } + else { + if (rc_ss->trial_status == '\x03') { + if ((rc_ss->info & 2) == 0) { + rc_ss->retry[0].idx = rc_ss->retry[1].idx; + rc_ss->retry[0].tp = rc_ss->retry[1].tp; + } + uVar3 = (rc_ss->max_tp_2_trial).idx; + rc_ss->trial_status = '\0'; + rc_ss->retry[1].idx = uVar3; + uVar11 = (rc_ss->max_tp_2_trial).tp; + (rc_ss->max_tp_2_trial).tp = 0; + rc_ss->retry[1].tp = uVar11; + (rc_ss->max_tp_2_trial).idx = 0xff; + goto LAB_2300958c; + } + } + if (iVar16 == 0) { + return; + } +LAB_2300958c: + sta_info_tab[uVar9].pol_tbl.upd_field = sta_info_tab[uVar9].pol_tbl.upd_field | 1; + return; +} + + +/* +Unable to decompile 'me_update_buffer_control' +Cause: Exception while decompiling 23007ab2: Decompiler process died + +*/ + + +void me_init_rate(sta_info_tag *sta_entry) + +{ + rc_init(sta_entry); + me_update_buffer_control(sta_entry); + return; +} + + + +void me_bw_check(int param_1,int param_2) + +{ + short sVar1; + short sVar2; + byte bVar3; + + sVar2 = **(short **)(param_2 + 0x4c); + bVar3 = 0; + if ((param_1 != 0) && (bVar3 = me_env.phy_bw_max, me_env.phy_bw_max != '\0')) { + bVar3 = *(byte *)(param_1 + 3) & 3; + if ((*(byte *)(param_1 + 3) & 3) != 0) { + sVar1 = 10; + if (bVar3 != 1) { + sVar1 = -10; + } + sVar2 = sVar2 + sVar1; + bVar3 = 1; + } + } + *(byte *)(param_2 + 0x82) = bVar3; + *(byte *)(param_2 + 0x83) = bVar3; + *(short *)(param_2 + 0x50) = sVar2; + *(undefined2 *)(param_2 + 0x52) = 0; + return; +} + + + +void me_beacon_check(uint8_t vif_idx,uint16_t length,uint32_t bcn_addr) + +{ + byte bVar1; + uint8_t uVar2; + uint8_t uVar3; + undefined3 in_register_00002029; + int iVar4; + int iVar5; + undefined4 uVar6; + uint8_t *puVar7; + undefined2 in_register_0000202e; + uint uVar8; + uint16_t uVar9; + scan_chan_tag *psVar10; + uint uVar11; + byte bVar12; + char cStack51; + int8_t iStack50; + uint8_t auStack49 [2]; + uint8_t csa_mode; + int8_t pwr; + uint8_t idx; + + iVar4 = CONCAT31(in_register_00002029,vif_idx); + psVar10 = vif_info_tab[iVar4].bss_info.chan; + vif_info_tab[iVar4].bss_info.prot_status = 0; + uVar8 = CONCAT22(in_register_0000202e,length) - 0x24; + bVar1 = vif_info_tab[iVar4].bss_info.phy_bw; + uVar2 = vif_info_tab[iVar4].bss_info.power_constraint; + bcn_addr = bcn_addr + 0x24; + uVar11 = uVar8 & 0xffff; + if ((psVar10->band == '\0') && (iVar5 = mac_ie_find(bcn_addr,uVar11,0x2a), iVar5 != 0)) { + bVar12 = *(byte *)(iVar5 + 2); + uVar9 = vif_info_tab[iVar4].bss_info.prot_status & 0xfff8; + if ((bVar12 & 1) != 0) { + uVar9 = uVar9 | 1; + } + vif_info_tab[iVar4].bss_info.prot_status = uVar9; + if ((bVar12 & 2) != 0) { + vif_info_tab[iVar4].bss_info.prot_status = vif_info_tab[iVar4].bss_info.prot_status | 2; + } + if ((bVar12 & 4) != 0) { + vif_info_tab[iVar4].bss_info.prot_status = vif_info_tab[iVar4].bss_info.prot_status | 4; + } + } + uVar6 = 0; + if (me_env.ht_supported != false) { + uVar6 = mac_ie_find(bcn_addr,uVar11,0x3d); + } + me_bw_check(uVar6,0,&vif_info_tab[iVar4].bss_info); + uVar11 = me_extract_csa(bcn_addr,uVar11,&cStack51,iVar4 * 0x5d8 + 0x4201a9d8); + if ((uVar11 & 0xff) != 0) { + bVar12 = (byte)(uVar11 & 0xff); + if (vif_info_tab[iVar4].type == '\0') { + if ((vif_info_tab[iVar4].u[0x1d] == 0) && (cStack51 == '\x01')) { + mm_send_csa_traffic_ind(vif_info_tab[iVar4].index,false); + } + vif_info_tab[iVar4].u[0x1d] = bVar12; + } + else { + if (vif_info_tab[iVar4].type == '\x02') { + vif_info_tab[iVar4].u[0x2eb] = bVar12; + } + } + } + me_extract_power_constraint + (bcn_addr,(uint16_t)(uVar8 * 0x10000 >> 0x10),&vif_info_tab[iVar4].bss_info); + uVar3 = vif_info_tab[iVar4].bss_info.power_constraint; + if (uVar3 != uVar2) { + iStack50 = (vif_info_tab[iVar4].bss_info.chan)->tx_power - uVar3; + tpc_update_vif_tx_power(vif_info_tab + iVar4,&iStack50,auStack49); + } + if (bVar1 < vif_info_tab[iVar4].bss_info.phy_bw) { + puVar7 = (uint8_t *)ke_msg_alloc(0x3b,0,5,0xc); + if (vif_info_tab[iVar4].chan_ctxt == (chan_ctxt_tag *)0x0) { + assert_err("vif->chan_ctxt != NULL","module",0x39); + } + *puVar7 = (vif_info_tab[iVar4].chan_ctxt)->idx; + puVar7[1] = (vif_info_tab[iVar4].bss_info.chan)->band; + puVar7[2] = vif_info_tab[iVar4].bss_info.phy_bw; + *(uint16_t *)(puVar7 + 4) = (vif_info_tab[iVar4].bss_info.chan)->freq; + *(uint16_t *)(puVar7 + 6) = vif_info_tab[iVar4].bss_info.center_freq1; + *(uint16_t *)(puVar7 + 8) = vif_info_tab[iVar4].bss_info.center_freq2; + puVar7[10] = ((vif_info_tab[iVar4].chan_ctxt)->channel).tx_power; + ke_msg_send(puVar7); + } + return; +} + + + +void me_sta_bw_nss_max_upd(uint8_t sta_idx,uint8_t bw,uint8_t nss) + +{ + byte bVar1; + byte bVar2; + uint8_t sta_idx_00; + uint8_t nss_max; + uint8_t bw_max; + undefined3 in_register_00002029; + int iVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 in_register_0000202d; + uint uVar4; + undefined3 in_register_00002031; + uint uVar5; + + iVar3 = CONCAT31(in_register_00002029,sta_idx); + bVar1 = sta_info_tab[iVar3].inst_nbr; + if (me_env.ht_supported == false) { + assert_err("me_env.ht_supported","module",0x429); + } + nss_max = me_11n_nss_max(sta_info_tab[iVar3].info.ht_cap.mcs_rate); + bw_max = me_11n_nss_max(me_env.ht_cap.mcs_rate); + uVar5 = CONCAT31(extraout_var_00,bw_max); + if (CONCAT31(extraout_var,nss_max) < CONCAT31(extraout_var_00,bw_max)) { + uVar5 = CONCAT31(extraout_var,nss_max); + } + nss_max = (uint8_t)uVar5; + if (CONCAT31(in_register_00002031,nss) < uVar5) { + nss_max = nss; + } + bVar2 = sta_info_tab[iVar3].info.phy_bw_max; + uVar5 = (uint)bVar2; + if (bVar2 == 4) { + uVar5 = 3; + } + uVar4 = (uint)vif_info_tab[bVar1].bss_info.bw; + if (CONCAT31(in_register_0000202d,bw) < uVar4) { + uVar4 = CONCAT31(in_register_0000202d,bw); + } + bw_max = (uint8_t)uVar4; + if (uVar5 < uVar4) { + bw_max = (uint8_t)uVar5; + } + sta_idx_00 = sta_info_tab[iVar3].staid; + sta_info_tab[iVar3].info.bw_cur = bw_max; + rc_update_bw_nss_max(sta_idx_00,bw_max,nss_max); + sta_info_tab[iVar3].pol_tbl.upd_field = sta_info_tab[iVar3].pol_tbl.upd_field | 8; + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +uint8_t me_add_chan_ctx(uint8_t *p_chan_idx,scan_chan_tag *p_chan,uint32_t center_freq1, + uint32_t center_freq2,uint8_t ch_width) + +{ + uint8_t uVar1; + uint8_t uStack28; + uint8_t uStack27; + uint16_t uStack26; + mm_chan_ctxt_add_req req; + + uStack28 = p_chan->band; + req._0_2_ = (uint16_t)center_freq1; + uStack26 = p_chan->freq; + req.prim20_freq = (uint16_t)center_freq2; + req.center1_freq._0_1_ = p_chan->tx_power; + uStack27 = ch_width; + uVar1 = chan_ctxt_add((mm_chan_ctxt_add_req *)&uStack28,p_chan_idx); + return uVar1; +} + + + +uint8_t rc_get_nss(uint16_t rate_config) + +{ + undefined2 in_register_0000202a; + + if ((CONCAT22(in_register_0000202a,rate_config) >> 0xb & 7U) - 2 < 2) { + return (uint8_t)((byte)(CONCAT22(in_register_0000202a,rate_config) >> 3) & 3); + } + return '\0'; +} + + + +uint8_t rc_get_mcs_index(uint16_t rate_config) + +{ + undefined2 in_register_0000202a; + byte bVar1; + uint uVar2; + + uVar2 = CONCAT22(in_register_0000202a,rate_config) >> 0xb & 7; + if (uVar2 < 2) { + bVar1 = (byte)rate_config & 0x7f; + } + else { + bVar1 = 0; + if (uVar2 < 4) { + bVar1 = (byte)rate_config & 7; + } + } + return (uint8_t)bVar1; +} + + + +uint16_t rc_set_previous_mcs_index(rc_sta_stats *rc_ss,uint16_t rate_config) + +{ + uint uVar1; + uint8_t uVar2; + undefined3 extraout_var; + undefined2 in_register_0000202e; + + uVar2 = rc_get_mcs_index(rate_config); + _uVar2 = CONCAT31(extraout_var,uVar2); + uVar1 = CONCAT22(in_register_0000202e,rate_config) >> 0xb & 7; + if (uVar1 < 2) { + if (rc_ss->r_idx_min < _uVar2) { + rate_config = rate_config & 0xff80 | (short)_uVar2 - 1U; + } + } + else { + if ((uVar1 < 4) && (_uVar2 != 0)) { + rate_config = rate_config & 0xfff8 | (short)_uVar2 - 1U; + if (rc_ss->short_gi != '\0') { + rate_config = rate_config | 0x200; + } + } + } + return rate_config; +} + + + +uint16_t rc_set_next_mcs_index(rc_sta_stats *rc_ss,uint16_t rate_config) + +{ + uint8_t uVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined2 in_register_0000202e; + uint uVar2; + + uVar1 = rc_get_mcs_index(rate_config); + _uVar1 = CONCAT31(extraout_var,uVar1); + uVar2 = CONCAT22(in_register_0000202e,rate_config) >> 0xb & 7; + if (uVar2 < 2) { + if ((_uVar1 < rc_ss->r_idx_max) && ((rc_ss->rate_map_l >> (_uVar1 + 1 & 0x1f) & 1) != 0)) { + rate_config = rate_config & 0xff80 | (ushort)(_uVar1 + 1); + } + } + else { + if ((uVar2 < 4) && (_uVar1 < rc_ss->mcs_max)) { + uVar1 = rc_get_nss(rate_config); + if ((*(byte *)((int)&rc_ss->rate_map + CONCAT31(extraout_var_00,uVar1)) >> (_uVar1 + 1 & 0x1f) + & 1) != 0) { + rate_config = rate_config & 0xfff8 | (ushort)(_uVar1 + 1); + if (rc_ss->short_gi != '\0') { + rate_config = rate_config | 0x200; + } + } + } + } + return rate_config; +} + + + +_Bool is_cck_group(uint16_t rate_config) + +{ + uint8_t uVar1; + undefined3 extraout_var; + + if ((rate_config & 0x3000) == 0) { + uVar1 = rc_get_mcs_index(rate_config); + return (_Bool)(CONCAT31(extraout_var,uVar1) < 4); + } + return false; +} + + + +void rc_update_retry_chain(rc_sta_stats *rc_ss,uint32_t *cur_tp) + +{ + ushort uVar1; + ushort uVar2; + int iVar3; + uint uVar4; + _Bool _Var5; + ushort uVar6; + undefined3 extraout_var; + undefined3 extraout_var_00; + ushort *puVar7; + int iVar8; + uint32_t uVar9; + uint uVar10; + uint uVar11; + uint uVar12; + uint uVar13; + + uVar6 = rc_ss->no_samples; + uVar13 = (uint)uVar6; + if (((rc_ss->info & 4) == 0) && (cur_tp[uVar13 - 1] < *cur_tp)) { + rc_ss->retry[0].idx = 0; + rc_ss->retry[0].tp = 0; + uVar4 = 1; + } + else { + rc_ss->retry[0].idx = uVar6 - 1; + uVar4 = 2; + rc_ss->retry[0].tp = cur_tp[uVar13 - 1]; + } + uVar1 = rc_ss->retry[0].idx; + _Var5 = is_cck_group(*(uint16_t *)((int)(&rc_ss->last_rc_time + (uint)uVar1 * 3) + 10)); + if (CONCAT31(extraout_var,_Var5) == 0) { + uVar12 = 0; + while ((int)uVar12 < (int)(uVar13 - 1)) { + _Var5 = is_cck_group(*(uint16_t *)((int)(&rc_ss->last_rc_time + uVar12 * 3) + 10)); + if (CONCAT31(extraout_var_00,_Var5) != 0) { + *(undefined *)((int)(&rc_ss->last_rc_time + uVar12 * 3) + 0xf) = 0; + } + uVar12 = uVar12 + 1 & 0xffff; + } + *(undefined *)((int)(&rc_ss->last_rc_time + (uint)uVar1 * 3) + 0xf) = 1; + } + uVar9 = rc_ss->retry[0].tp; + rc_ss->retry[1].idx = uVar1; + rc_ss->retry[1].tp = uVar9; + iVar3 = uVar13 - uVar4; + do { + iVar8 = iVar3; + uVar12 = uVar4; + uVar4 = uVar12 + 1 & 0xffff; + if (uVar13 <= uVar12) goto LAB_230081c4; + iVar3 = iVar8 + -1; + } while (rc_ss->rate_stats[iVar8].rate_allowed == false); + rc_ss->retry[1].idx = uVar6 - (short)uVar12; + rc_ss->retry[1].tp = cur_tp[iVar8]; +LAB_230081c4: + uVar12 = (uint)rc_ss->retry[1].idx; + uVar4 = uVar13 - uVar4; + do { + uVar10 = uVar4; + uVar11 = uVar12; + if (uVar13 <= (uVar13 - uVar10 & 0xffff)) break; + uVar4 = uVar10 - 1; + uVar11 = uVar10; + } while (rc_ss->rate_stats[uVar10].rate_allowed == false); + uVar13 = cur_tp[uVar11]; + puVar7 = &rc_ss->rate_stats[0].probability; + uVar6 = rc_ss->rate_stats[uVar11].probability; + uVar4 = 0; + do { + if (uVar12 <= (uVar4 & 0xffff)) { + rc_ss->retry[2].idx = (uint16_t)uVar11; + uVar9 = cur_tp[uVar11]; + rc_ss->retry[3].idx = 0; + rc_ss->retry[2].tp = uVar9; + rc_ss->retry[3].tp = *cur_tp; + return; + } + if ((*(char *)((int)puVar7 + 7) != '\0') && ((uVar4 & 0xffff) != (uint)uVar1)) { + uVar2 = *puVar7; + if (uVar2 < 0xf333) { + if (uVar6 <= uVar2) { + uVar9 = cur_tp[uVar4]; + goto LAB_230082a8; + } + } + else { + uVar9 = cur_tp[uVar4]; + if (uVar13 <= uVar9) { +LAB_230082a8: + uVar13 = uVar9; + uVar11 = uVar4; + uVar6 = uVar2; + } + } + } + uVar4 = uVar4 + 1; + puVar7 = puVar7 + 6; + } while( true ); +} + + + +uint16_t rc_get_lowest_rate_config(rc_sta_stats *rc_ss) + +{ + byte bVar1; + uint16_t uVar2; + + bVar1 = rc_ss->format_mod; + if (bVar1 < 2) { + uVar2 = (uint16_t)rc_ss->r_idx_min; + if (rc_ss->r_idx_min == 0) { + return 0x400; + } + } + else { + if (3 < bVar1) { + return 0; + } + if (rc_ss->r_idx_min == '\0') { + return 0x400; + } + uVar2 = (ushort)bVar1 << 0xb; + } + return uVar2; +} + + + +// WARNING: Variable defined which should be unmapped: rc_ss_tmp + +void rc_sort_samples_tp(rc_sta_stats *rc_ss,uint32_t *cur_tp) + +{ + ushort uVar1; + uint32_t *puVar2; + ushort uVar3; + uint32_t uVar4; + ushort uVar5; + rc_rate_stats *__src; + ushort uVar6; + rc_rate_stats *__src_00; + undefined auStack44 [4]; + rc_rate_stats rc_ss_tmp; + + uVar5 = rc_ss->no_samples; + uVar1 = uVar5 - 1; + while (uVar6 = uVar1, uVar5 != 0) { + puVar2 = cur_tp + 1; + uVar5 = 0; + uVar3 = 1; + __src = rc_ss->rate_stats + 1; + while (uVar1 = uVar5, uVar3 < uVar6) { + __src_00 = __src + 1; + if (puVar2[1] < *puVar2) { + memmove(auStack44,__src,0xc); + memmove(__src,__src_00,0xc); + memmove(__src_00,auStack44,0xc); + uVar4 = puVar2[1]; + puVar2[1] = *puVar2; + *puVar2 = uVar4; + uVar5 = uVar3; + } + uVar3 = uVar3 + 1; + puVar2 = puVar2 + 1; + __src = __src_00; + } + } + return; +} + + + +uint16_t rc_get_initial_rate_config(rc_sta_stats *rc_ss) + +{ + byte bVar1; + byte bVar2; + ushort uVar3; + int iVar4; + ushort uVar5; + + bVar1 = rc_ss->format_mod; + if (bVar1 < 2) { + uVar3 = (ushort)rc_ss->r_idx_max; + uVar5 = (ushort)bVar1 << 0xb | (ushort)rc_ss->p_type << 10; + } + else { + if (3 < bVar1) { + return 0; + } + bVar2 = rc_ss->no_ss; + iVar4 = __clzsi2((uint)*(byte *)((int)&rc_ss->rate_map + (uint)bVar2)); + uVar5 = (ushort)rc_ss->short_gi << 9 | (ushort)bVar1 << 0xb | (ushort)rc_ss->bw_max << 7 | + (ushort)bVar2 << 3; + uVar3 = 0x1fU - (short)iVar4 & 0xff; + } + return (uint16_t)(uVar5 | uVar3); +} + + + +void rc_calc_prob_ewma(rc_rate_stats *rc_rs) + +{ + ushort uVar1; + uint uVar2; + uint uVar3; + + uVar1 = rc_rs->attempts; + if (uVar1 != 0) { + rc_rs->sample_skipped = '\0'; + uVar3 = (uint)rc_rs->success << 0x10; + uVar2 = uVar3 / uVar1; + if (rc_rs->old_prob_available == false) { + if (uVar3 < uVar1) { + rc_rs->probability = 0; + } + else { + rc_rs->probability = (short)uVar2 - 1; + } + } + else { + rc_rs->probability = (uint16_t)((uint)rc_rs->probability * 0x60 + uVar2 * 0x20 >> 7); + } + rc_rs->old_prob_available = true; + return; + } + if (rc_rs->sample_skipped != -1) { + rc_rs->sample_skipped = rc_rs->sample_skipped + '\x01'; + } + return; +} + + + +_Bool rc_check_valid_rate(rc_sta_stats *rc_ss,uint16_t rate_config) + +{ + uint8_t uVar1; + byte bVar2; + undefined3 extraout_var; + undefined2 in_register_0000202e; + uint uVar3; + + uVar3 = CONCAT22(in_register_0000202e,rate_config) >> 0xb & 7; + if (uVar3 < 2) { + bVar2 = rc_get_mcs_index(rate_config); + uVar3 = (uint)rc_ss->rate_map_l; + } + else { + if (3 < uVar3) { + return true; + } + uVar1 = rc_get_nss(rate_config); + bVar2 = rc_get_mcs_index(rate_config); + uVar3 = (uint)*(byte *)((int)&rc_ss->rate_map + CONCAT31(extraout_var,uVar1)); + } + return (_Bool)((byte)(uVar3 >> ((uint)bVar2 & 0x1f)) & 1); +} + + + +uint16_t rc_new_random_rate(rc_sta_stats *rc_ss) + +{ + byte bVar1; + byte bVar2; + uint uVar3; + int iVar4; + uint16_t uVar5; + uint uVar6; + ushort uVar7; + uint uVar8; + + bVar1 = rc_ss->bw_max; + uVar8 = 0; + next = next * 0x41c64e6d + 0x3039; + bVar2 = rc_ss->format_mod; + uVar6 = next >> 0x10; + uVar5 = (uint16_t)(((uint)bVar2 << 0x1b) >> 0x10); + if (bVar1 != 0) { + uVar8 = (uint)bVar1 - 1 & 0xff; + } + uVar7 = (ushort)(next >> 0x10); + if (bVar2 < 2) { + uVar8 = (int)(uVar6 & 0x7f) % (((uint)rc_ss->r_idx_max - (uint)rc_ss->r_idx_min) + 1) + + (uint)rc_ss->r_idx_min; + uVar6 = uVar8 & 0xff; + if ((rc_ss->rate_map_l >> (uVar8 & 0x1f) & 1) == 0) { + uVar6 = (uint)rc_ss->r_idx_max; + } + uVar5 = uVar5 | (ushort)uVar6; + if (uVar6 == 0) { + uVar5 = uVar5 | 0x400; + } + else { + if ((uVar6 - 1 & 0xff) < 3) { + uVar5 = uVar5 | uVar7 & 0x400 | (ushort)rc_ss->p_type << 10; + } + } + } + else { + if (bVar2 < 4) { + bVar2 = rc_ss->r_idx_min; + if ((bVar2 < 4) && ((int)(uVar6 << 0x14) < 0)) { + uVar8 = (int)(uVar6 & 0x7f) % (((uint)rc_ss->r_idx_max - (uint)bVar2) + 1) + (uint)bVar2; + uVar6 = uVar8 & 0xff; + if ((rc_ss->rate_map_l >> (uVar8 & 0x1f) & 1) == 0) { + uVar6 = (uint)rc_ss->r_idx_max; + } + uVar5 = 0x400; + if (uVar6 != 0) { + uVar5 = (ushort)rc_ss->p_type << 10 | uVar7 & 0x400 | (ushort)uVar6; + } + } + else { + uVar7 = (ushort)rc_ss->mcs_max; + iVar4 = (int)((int)uVar6 >> 3 & 3U) % ((uint)rc_ss->no_ss + 1); + uVar3 = (int)(uVar6 & 7) % ((uint)rc_ss->mcs_max + 1); + if ((*(byte *)((int)&rc_ss->rate_map + iVar4) >> (uVar3 & 0x1f) & 1) != 0) { + uVar7 = (ushort)uVar3 & 0xff; + } + uVar5 = uVar5 | (ushort)((int)((int)uVar6 >> 9 & 1U) % ((uint)rc_ss->short_gi + 1) << 9) | + (ushort)(iVar4 << 3) | + ((short)((int)((int)uVar6 >> 7 & 3U) % (((uint)bVar1 - uVar8) + 1)) + (short)uVar8) + * 0x80 | uVar7; + } + } + } + return uVar5; +} + + + +void rc_update_counters(uint8_t sta_idx,uint32_t attempts,uint32_t failures,_Bool tx_ampdu, + _Bool retry_required) + +{ + short sVar1; + rc_sta_stats *prVar2; + undefined3 in_register_00002029; + uint uVar3; + uint8_t uVar4; + uint32_t *puVar5; + ushort *puVar6; + + uVar3 = CONCAT31(in_register_00002029,sta_idx); + if (9 < uVar3) { + return; + } + if (sta_info_tab[uVar3].inst_nbr != -1) { + prVar2 = sta_info_tab[uVar3].pol_tbl.sta_stats; + if (prVar2 == (rc_sta_stats *)0x0) { + assert_err("rc_ss != NULL","module",0x7ce); + } + puVar6 = &prVar2->retry[0].idx; + prVar2->ampdu_packets = prVar2->ampdu_packets + 1; + prVar2->ampdu_len = prVar2->ampdu_len + 1; + do { + if (attempts == 0) break; + puVar5 = &prVar2->last_rc_time + (uint)*puVar6 * 3; + if (failures < 4) { + *(short *)(puVar5 + 1) = *(short *)(puVar5 + 1) + (short)attempts; + sVar1 = (short)failures; + failures = 0; + *(short *)((int)puVar5 + 6) = ((short)attempts - sVar1) + *(short *)((int)puVar5 + 6); + attempts = 0; + } + else { + *(short *)(puVar5 + 1) = *(short *)(puVar5 + 1) + 4; + attempts = attempts - 4; + failures = failures - 4; + } + if (*(ushort *)(puVar5 + 1) < *(ushort *)((int)puVar5 + 6)) { + assert_err("rc_rs->attempts >= rc_rs->success","module",0x7fa); + } + puVar6 = puVar6 + 4; + } while (puVar6 != &(prVar2->max_tp_2_trial).idx); + if (prVar2->trial_status == '\0') { + if (prVar2->sample_wait != '\0') { + prVar2->sample_wait = prVar2->sample_wait + -1; + return; + } + uVar4 = '\x01'; + } + else { + if (prVar2->trial_status != '\x02') { + return; + } + if ((sta_info_tab[uVar3].pol_tbl.upd_field & 1) != 0) { + return; + } + uVar4 = '\x03'; + } + prVar2->trial_status = uVar4; + } + return; +} + + + +uint32_t rc_get_duration(uint param_1) + +{ + uint8_t uVar1; + undefined3 extraout_var; + uint32_t uVar2; + undefined3 extraout_var_00; + uint uVar3; + + uVar1 = rc_get_mcs_index((uint16_t)param_1); + _uVar1 = CONCAT31(extraout_var,uVar1); + uVar3 = (int)param_1 >> 0xb & 7; + if (uVar3 < 2) { + if (_uVar1 < 4) { + uVar2 = rc_duration_cck[(int)param_1 >> 10 & 1U | _uVar1 << 1]; + } + else { + uVar2 = rc_duration_non_ht[_uVar1 - 4]; + } + } + else { + uVar2 = 0; + if (uVar3 < 4) { + uVar1 = rc_get_nss((uint16_t)param_1); + uVar2 = rc_duration_ht_ampdu[_uVar1 << 3 | param_1 >> 9 & 1 | param_1 >> 6 & 6] / + (CONCAT31(extraout_var_00,uVar1) + 1U); + } + } + return uVar2; +} + + + +void rc_update_bw_nss_max(uint8_t sta_idx,uint8_t bw_max,uint8_t nss_max) + +{ + ushort uVar1; + rc_sta_stats *rc_ss; + uint16_t uVar2; + undefined3 in_register_00002029; + int iVar3; + undefined2 extraout_var; + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + uint32_t *puVar4; + uint uVar5; + ushort *puVar6; + uint16_t *puVar7; + uint uVar8; + uint32_t local_48; + uint32_t cur_tp [10]; + + iVar3 = CONCAT31(in_register_00002029,sta_idx); + rc_ss = sta_info_tab[iVar3].pol_tbl.sta_stats; + if (rc_ss == (rc_sta_stats *)0x0) { + assert_err("rc_ss != NULL","module",0x969); + } + if (((uint)rc_ss->bw_max != CONCAT31(in_register_0000202d,bw_max)) || + ((uint)rc_ss->no_ss != CONCAT31(in_register_00002031,nss_max))) { + rc_ss->bw_max = bw_max; + if (3 < CONCAT31(in_register_0000202d,bw_max)) { + assert_err("rc_ss->bw_max <= BW_160MHZ","module",0x96f); + } + rc_ss->no_ss = nss_max; + if (7 < CONCAT31(in_register_00002031,nss_max)) { + assert_err("rc_ss->no_ss < 8","module",0x971); + } + if (rc_ss->fixed_rate_cfg == 0xffff) { + uVar2 = rc_get_lowest_rate_config(rc_ss); + rc_ss->rate_stats[0].rate_config = uVar2; + uVar2 = rc_get_initial_rate_config(rc_ss); + rc_ss->rate_stats[(uint)rc_ss->no_samples - 1].rate_config = uVar2; + uVar5 = 1; +LAB_230088ac: + uVar1 = rc_ss->no_samples; + if ((int)uVar5 < (int)((uint)uVar1 - 1)) { + do { + uVar2 = rc_new_random_rate(rc_ss); + uVar8 = 0; + puVar6 = &rc_ss->rate_stats[0].rate_config; + while( true ) { + if (rc_ss->no_samples <= uVar8) { + rc_ss->rate_stats[uVar5].rate_config = uVar2; + uVar5 = uVar5 + 1 & 0xffff; + goto LAB_230088ac; + } + if ((uint)*puVar6 == CONCAT22(extraout_var,uVar2)) break; + uVar8 = uVar8 + 1; + puVar6 = puVar6 + 6; + } + } while( true ); + } + puVar7 = &rc_ss->rate_stats[0].probability; + uVar5 = 0; + puVar4 = &local_48; + while ((uint)uVar1 != uVar5) { + *(undefined *)(puVar7 + 3) = 0; + *(undefined *)((int)puVar7 + 7) = 1; + *puVar7 = 0; + *(undefined *)((int)puVar7 + 5) = 0; + *puVar4 = 0; + uVar5 = uVar5 + 1 & 0xffff; + puVar7 = puVar7 + 6; + puVar4 = puVar4 + 1; + } + rc_sort_samples_tp(rc_ss,&local_48); + rc_update_retry_chain(rc_ss,&local_48); + sta_info_tab[iVar3].pol_tbl.upd_field = sta_info_tab[iVar3].pol_tbl.upd_field | 1; + } + } + return; +} + + + +void rc_init_bcmc_rate(sta_info_tag *sta_entry,uint8_t basic_rate_idx) + +{ + undefined3 in_register_0000202d; + txl_buffer_control *ptVar1; + uint uVar2; + + ptVar1 = (sta_entry->pol_tbl).buf_ctrl; + uVar2 = 0; + if (CONCAT31(in_register_0000202d,basic_rate_idx) < 4) { + uVar2 = SEXT24((short)((sta_entry->pol_tbl).ppdu_tx_cfg & 0x400)); + } + uVar2 = CONCAT31(in_register_0000202d,basic_rate_idx) | uVar2 | 0x20000000; + *(uint *)(ptVar1->field_0 + 0x14) = uVar2; + *(uint *)(ptVar1->field_0 + 0x18) = uVar2; + *(uint *)(ptVar1->field_0 + 0x1c) = uVar2; + *(uint *)(ptVar1->field_0 + 0x20) = uVar2; + return; +} + + + +_Bool rc_check_fixed_rate_config(rc_sta_stats *rc_ss,uint16_t fixed_rate_config) + +{ + uint8_t uVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined2 in_register_0000202e; + uint uVar3; + uint uVar4; + + uVar4 = (uint)rc_ss->format_mod; + uVar3 = ((uint)fixed_rate_config & 0x3800) >> 0xb; + if (uVar4 < uVar3) { + return false; + } + if (rc_ss->format_mod == 4) { + if (uVar3 != uVar4) { + return false; + } +LAB_2300899e: + if ((fixed_rate_config & 0x3000) == 0) { +LAB_230089f6: + if (((CONCAT22(in_register_0000202e,fixed_rate_config) >> 10 & 1U) == 0) && + (rc_ss->p_type == '\x01')) { + return false; + } + goto LAB_230089d0; + } + } + else { + if (1 < (uVar4 - 2 & 0xff)) goto LAB_2300899e; + if ((fixed_rate_config & 0x3000) == 0) { + if (3 < rc_ss->r_idx_min) { + return false; + } + goto LAB_230089f6; + } + } + if (((((fixed_rate_config & 0x200) != 0) && (rc_ss->short_gi == '\0')) || + ((uint)rc_ss->bw_max < (CONCAT22(in_register_0000202e,fixed_rate_config) >> 7 & 3U))) || + (uVar1 = rc_get_nss(fixed_rate_config), (uint)rc_ss->no_ss < CONCAT31(extraout_var,uVar1))) { + return false; + } +LAB_230089d0: + _Var2 = rc_check_valid_rate(rc_ss,fixed_rate_config); + return _Var2; +} + + + +uint32_t rc_calc_tp(rc_sta_stats *rc_ss,uint8_t sample_idx) + +{ + ushort uVar1; + ushort rate_config; + uint uVar2; + _Bool _Var3; + undefined3 extraout_var; + int iVar4; + uint32_t uVar5; + undefined3 in_register_0000202d; + + uVar1 = *(ushort *)(&rc_ss->last_rc_time + CONCAT31(in_register_0000202d,sample_idx) * 3 + 2); + if (uVar1 < 0x1999) { + uVar5 = 0; + } + else { + rate_config = *(ushort *) + ((int)(&rc_ss->last_rc_time + CONCAT31(in_register_0000202d,sample_idx) * 3) + 10 + ); + uVar2 = 0; + _Var3 = is_cck_group(rate_config); + if (CONCAT31(extraout_var,_Var3) == 0) { + uVar2 = 0x35390 / (uint)*(ushort *)((int)&rc_ss->avg_ampdu_len + 2); + } + iVar4 = rc_get_duration((uint)rate_config); + uVar5 = (((uint)uVar1 * 1000) / (iVar4 + uVar2)) * 1000000 >> 0x10; + } + return uVar5; +} + + + +_Bool rc_update_stats(rc_sta_stats *rc_ss,_Bool init) + +{ + byte bVar1; + ushort rate_config; + _Bool _Var2; + uint16_t rate_config_00; + uint32_t uVar3; + undefined2 extraout_var_03; + undefined3 extraout_var; + undefined2 extraout_var_04; + undefined3 extraout_var_00; + undefined2 extraout_var_05; + undefined3 extraout_var_01; + undefined2 extraout_var_06; + undefined3 extraout_var_02; + uint uVar4; + undefined3 in_register_0000202d; + rc_rate_stats *prVar5; + uint32_t *cur_tp_00; + uint32_t *puVar6; + uint uVar7; + ushort rate_config_01; + uint16_t uVar8; + uint8_t *puVar9; + uint16_t *puVar10; + uint16_t *puVar11; + uint uVar12; + char cVar13; + uint16_t uStack148; + ushort uStack146; + uint16_t new_rate_cfg_array [6]; + step old_retry [4]; + uint32_t cur_tp [10]; + + memcpy(new_rate_cfg_array + 4,rc_ss->retry,0x20); + if (rc_ss->ampdu_packets != 0) { + rate_config = rc_ss->ampdu_len; + *(undefined4 *)&rc_ss->ampdu_len = 0; + rc_ss->avg_ampdu_len = + ((int)((uint)rate_config << 0x10) / (int)(uint)rc_ss->ampdu_packets) * 0x20 + + rc_ss->avg_ampdu_len * 0x60 >> 7; + } + rate_config = rc_ss->no_samples; + cur_tp_00 = (uint32_t *)&old_retry[3].idx; + rc_ss->sample_slow = '\0'; + puVar9 = &rc_ss->rate_stats[0].n_retry; + uVar7 = 0; + puVar6 = cur_tp_00; + while ((uint)rate_config != uVar7) { + *puVar6 = 0; + *puVar9 = '\0'; + puVar9[1] = '\x01'; + uVar7 = uVar7 + 1 & 0xffff; + puVar6 = puVar6 + 1; + puVar9 = puVar9 + 0xc; + } + rate_config_00 = rc_ss->fixed_rate_cfg; + uVar12 = 0; + if (rate_config_00 == 0xffff) { + while (uVar12 < rc_ss->no_samples) { + rc_calc_prob_ewma(rc_ss->rate_stats + uVar12); + uVar3 = rc_calc_tp(rc_ss,(uint8_t)uVar12); + *(uint32_t *)(&old_retry[3].idx + uVar12 * 2) = uVar3; + uVar12 = uVar12 + 1 & 0xffff; + } + rc_sort_samples_tp(rc_ss,cur_tp_00); + rc_update_retry_chain(rc_ss,cur_tp_00); + if (CONCAT31(in_register_0000202d,init) == 0) { + rate_config = rc_ss->no_samples; + if (9 < rate_config) { + cVar13 = '\0'; + rate_config = rc_ss->rate_stats[rc_ss->retry[0].idx].rate_config; + uVar7 = (uint)rate_config; + rate_config_01 = rc_ss->rate_stats[rc_ss->retry[1].idx].rate_config; + memset(&uStack148,-1,0xc); + do { + switch(cVar13) { + case '\x01': + if ((((int)uVar7 >> 0xb & 6U) != 0) && (rc_ss->short_gi == '\x01')) { + if ((rate_config & 0x200) == 0) { + uStack146 = rate_config | 0x200; + } + else { + uStack146 = rate_config & 0xfdff; + } + } + break; + case '\x02': + rate_config_00 = rc_set_next_mcs_index(rc_ss,rate_config); + if ((uVar7 != CONCAT22(extraout_var_03,rate_config_00)) && + (_Var2 = rc_check_valid_rate(rc_ss,rate_config_00), CONCAT31(extraout_var,_Var2) != 0 + )) { + new_rate_cfg_array[0] = rate_config_00; + } + break; + case '\x03': + rate_config_00 = rc_set_previous_mcs_index(rc_ss,rate_config); + if ((uVar7 != CONCAT22(extraout_var_04,rate_config_00)) && + (_Var2 = rc_check_valid_rate(rc_ss,rate_config_00), + CONCAT31(extraout_var_00,_Var2) != 0)) { + new_rate_cfg_array[1] = rate_config_00; + } + break; + case '\x04': + rate_config_00 = rc_set_next_mcs_index(rc_ss,rate_config_01); + if (((uint)rate_config_01 != CONCAT22(extraout_var_05,rate_config_00)) && + (_Var2 = rc_check_valid_rate(rc_ss,rate_config_00), + CONCAT31(extraout_var_01,_Var2) != 0)) { + new_rate_cfg_array[2] = rate_config_00; + } + break; + case '\x05': + rate_config_00 = rc_set_previous_mcs_index(rc_ss,rate_config_01); + if (((uint)rate_config_01 != CONCAT22(extraout_var_06,rate_config_00)) && + (_Var2 = rc_check_valid_rate(rc_ss,rate_config_00), + CONCAT31(extraout_var_02,_Var2) != 0)) { + new_rate_cfg_array[3] = rate_config_00; + } + break; + default: + uStack148 = rc_new_random_rate(rc_ss); + } + cVar13 = cVar13 + '\x01'; + } while (cVar13 != '\x06'); + rate_config = rc_ss->no_samples; + uVar12 = 1; + uVar7 = 0; + while (uVar12 < rate_config) { + puVar6 = &rc_ss->last_rc_time + uVar12 * 3; + if ((((*(short *)(puVar6 + 2) < 0) && (*(byte *)(puVar6 + 3) < 0xb)) || + ((uint)rc_ss->retry[0].idx == uVar12)) || + ((((uint)rc_ss->retry[1].idx == uVar12 || ((uint)rc_ss->retry[2].idx == uVar12)) || + (5 < uVar7)))) { + uVar12 = uVar12 + 1 & 0xffff; + } + else { + rate_config_00 = (&uStack148)[uVar7]; + if (rate_config_00 != 0xffff) { + uVar4 = 0; + puVar11 = &rc_ss->rate_stats[0].rate_config; + while (uVar4 < rate_config) { + if (*puVar11 == rate_config_00) goto LAB_23008d8e; + uVar4 = uVar4 + 1; + puVar11 = puVar11 + 6; + } + *(uint16_t *)((int)puVar6 + 10) = rate_config_00; + *(undefined2 *)(puVar6 + 2) = 0; + *(undefined *)((int)puVar6 + 0xd) = 0; + uVar12 = uVar12 + 1 & 0xffff; + } +LAB_23008d8e: + uVar7 = uVar7 + 1; + } + *(undefined2 *)(puVar6 + 1) = 0; + *(undefined2 *)((int)puVar6 + 6) = 0; + } + *(undefined4 *)rc_ss->rate_stats = 0; + goto LAB_23008c54; + } + prVar5 = rc_ss->rate_stats; + rate_config_01 = 0; + while (rate_config != rate_config_01) { + rate_config_01 = rate_config_01 + 1; + prVar5->attempts = 0; + prVar5->success = 0; + prVar5 = prVar5 + 1; + } + } + } + else { + bVar1 = rc_ss->info; + uVar12 = 0; + if ((bVar1 & 0x20) != 0) { + while (uVar8 = (uint16_t)uVar12, uVar12 < uVar7) { + if (rc_ss->rate_stats[uVar12].rate_config == rate_config_00) goto LAB_23008de8; + uVar12 = uVar12 + 1 & 0xff; + } + if (uVar7 == uVar12) { + uVar12 = uVar12 - 1 & 0xff; + uVar8 = (uint16_t)uVar12; + *(uint16_t *)((int)(&rc_ss->last_rc_time + uVar12 * 3) + 10) = rate_config_00; + *(undefined2 *)(&rc_ss->last_rc_time + uVar12 * 3 + 2) = 0; + } +LAB_23008de8: + rc_ss->retry[0].idx = uVar8; + rc_ss->retry[1].idx = uVar8; + rc_ss->retry[2].idx = uVar8; + rc_ss->retry[0].tp = 0; + rc_ss->retry[1].tp = 0; + rc_ss->retry[2].tp = 0; + prVar5 = rc_ss->rate_stats; + uVar12 = 0; + while (uVar7 != uVar12) { + prVar5->attempts = 0; + prVar5->success = 0; + uVar12 = uVar12 + 1 & 0xffff; + prVar5 = prVar5 + 1; + } + rc_ss->info = bVar1 & 0x9f | 0x40; + init = true; + goto LAB_23008c54; + } + uVar7 = (uint)*(byte *)&rc_ss->retry[0].idx; + rc_calc_prob_ewma(rc_ss->rate_stats + uVar7); + *(undefined2 *)(&rc_ss->last_rc_time + uVar7 * 3 + 1) = 0; + *(undefined2 *)((int)(&rc_ss->last_rc_time + uVar7 * 3) + 6) = 0; + *(undefined4 *)rc_ss->rate_stats = 0; + } + init = false; +LAB_23008c54: + puVar10 = &rc_ss->retry[0].idx; + puVar11 = new_rate_cfg_array; + do { + if (puVar11[6] != *puVar10) { + return true; + } + puVar10 = puVar10 + 4; + puVar11 = puVar11 + 4; + } while (puVar10 != &(rc_ss->max_tp_2_trial).idx); + return init; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rc_init(sta_info_tag *sta_entry) + +{ + byte bVar1; + ushort uVar2; + uint uVar3; + step *psVar4; + uint8_t uVar5; + uint8_t uVar6; + _Bool _Var7; + byte bVar8; + uint16_t rate_map; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + undefined3 extraout_var_05; + undefined3 extraout_var_06; + undefined2 extraout_var_07; + int iVar9; + short sVar10; + uint *puVar11; + uint *puVar12; + uint uVar13; + ushort *puVar14; + uint uVar15; + uint uVar16; + rc_sta_stats *__s; + txl_buffer_control *ptVar17; + uint uVar18; + rc_sta_stats *rc_ss; + uint uVar19; + uint8_t *mcs_set; + ushort *puVar20; + + bVar8 = sta_entry->staid; + ptVar17 = (sta_entry->pol_tbl).buf_ctrl; + if (9 < bVar8) { + assert_err("sta_entry->staid < NX_REMOTE_STA_MAX","module",0x85f); + } + uVar16 = (uint)sta_entry->staid; + __s = sta_stats + uVar16; + (sta_entry->pol_tbl).sta_stats = __s; + uVar5 = phy_get_ntx(); + uVar18 = CONCAT31(extraout_var,uVar5) << 0xe; + memset(__s,0,200); + if (((sta_entry->info).capa_flags & 2) == 0) { + rate_map = me_legacy_rate_bitfield_build((mac_rateset *)&sta_entry->info,false); + sta_stats[uVar16].rate_map_l = rate_map; + uVar5 = me_legacy_ridx_min(rate_map); + sta_stats[uVar16].r_idx_min = uVar5; + if (0xb < CONCAT31(extraout_var_05,uVar5)) { + assert_err("rc_ss->r_idx_min < MAC_RATESET_LEN","module",0x8f4); + } + uVar5 = me_legacy_ridx_max(sta_stats[uVar16].rate_map_l); + sta_stats[uVar16].r_idx_max = uVar5; + if (0xb < CONCAT31(extraout_var_06,uVar5)) { + assert_err("rc_ss->r_idx_max < MAC_RATESET_LEN","module",0x8f6); + } + sta_stats[uVar16].mcs_max = -1; + uVar5 = (sta_entry->info).bw_cur; + sta_stats[uVar16].bw_max = uVar5; + if (uVar5 != '\0') { + assert_err("rc_ss->bw_max == BW_20MHZ","module",0x8f9); + } + sta_stats[uVar16].p_type = (byte)((int)(uint)(sta_entry->pol_tbl).ppdu_tx_cfg >> 10) & 1; + } + else { + rate_map = me_legacy_rate_bitfield_build((mac_rateset *)&sta_entry->info,false); + mcs_set = (sta_entry->info).ht_cap.mcs_rate; + sta_stats[uVar16].format_mod = '\x02'; + sta_stats[uVar16].rate_map_l = rate_map; + uVar5 = me_11n_nss_max(mcs_set); + uVar6 = me_11n_nss_max(me_env.ht_cap.mcs_rate); + uVar19 = CONCAT31(extraout_var_00,uVar5); + if (CONCAT31(extraout_var_01,uVar6) < CONCAT31(extraout_var_00,uVar5)) { + uVar19 = CONCAT31(extraout_var_01,uVar6); + } + sta_stats[uVar16].no_ss = (uint8_t)uVar19; + if (3 < uVar19) { + assert_err("rc_ss->no_ss <= 3","module",0x8a6); + } + memcpy(&sta_stats[uVar16].rate_map,mcs_set,4); + rate_map = sta_stats[uVar16].rate_map_l; + *(undefined *)&sta_stats[uVar16].rate_map = 0xff; + sta_stats[uVar16].mcs_max = '\a'; + uVar5 = me_legacy_ridx_min(rate_map); + sta_stats[uVar16].r_idx_min = uVar5; + if (0xc < CONCAT31(extraout_var_02,uVar5)) { + assert_err("(rc_ss->r_idx_min <= HW_RATE_54MBPS) || (rc_ss->r_idx_min == MAC_RATESET_LEN)", + "module",0x8b8); + } + uVar5 = me_legacy_ridx_max(sta_stats[uVar16].rate_map_l); + sta_stats[uVar16].r_idx_max = uVar5; + if (0xc < CONCAT31(extraout_var_03,uVar5)) { + assert_err("(rc_ss->r_idx_max <= HW_RATE_54MBPS) || (rc_ss->r_idx_max == MAC_RATESET_LEN)", + "module",0x8be); + } + sta_stats[uVar16].p_type = (byte)((int)(uint)(sta_entry->pol_tbl).ppdu_tx_cfg >> 10) & 1; + _Var7 = phy_ldpc_tx_supported(); + uVar2 = (sta_entry->info).ht_cap.ht_capa_info; + if ((CONCAT31(extraout_var_04,_Var7) != 0) && ((uVar2 & 1) != 0)) { + uVar18 = uVar18 | 0x40; + } + if ((int)((uint)uVar2 << 0x14) < 0) { + sVar10 = 0x2000; + } + else { + sVar10 = 0x1000; + } + sta_stats[uVar16].max_amsdu_len = sVar10 - 0x101; + bVar1 = (sta_entry->info).bw_cur; + sta_stats[uVar16].bw_max = bVar1; + if (3 < bVar1) { + assert_err("rc_ss->bw_max <= BW_160MHZ","module",0x8d5); + } + uVar5 = (sta_entry->info).bw_cur; + if (uVar5 == '\0') { + if (((sta_entry->info).ht_cap.ht_capa_info & 0x20) != 0) { + uVar5 = '\x01'; + goto LAB_2300909a; + } + } + else { + if ((uVar5 == '\x01') && (((sta_entry->info).ht_cap.ht_capa_info & 0x40) != 0)) { +LAB_2300909a: + sta_stats[uVar16].short_gi = uVar5; + } + } + } + if (sta_stats[uVar16].format_mod < 2) { + uVar19 = (uint)sta_stats[uVar16].rate_map_l; + uVar15 = 1 - (uint)sta_stats[uVar16].p_type; + uVar13 = (((int)uVar19 >> 1 & 1U) + ((int)uVar19 >> 2 & 1U) << (uVar15 & 0x1f)) + (uVar19 & 1) + + (((int)uVar19 >> 3 & 1U) << (uVar15 & 0x1f)) & 0xffff; + uVar15 = 4; + do { + uVar3 = uVar15 & 0x1f; + uVar15 = uVar15 + 1; + uVar13 = uVar13 + ((int)uVar19 >> uVar3 & 1U) & 0xffff; + } while (uVar15 != 0xc); +LAB_230091b4: + if (10 < uVar13) { + sta_stats[uVar16].no_samples = 10; + goto LAB_230091c8; + } + sta_stats[uVar16].no_samples = (uint16_t)uVar13; + if (uVar13 != 0) goto LAB_230091c8; + } + else { + if (sta_stats[uVar16].format_mod < 4) { + uVar19 = (uint)*(byte *)&sta_stats[uVar16].rate_map; + iVar9 = 8; + uVar15 = 0; + do { + uVar13 = uVar19 & 1; + iVar9 = iVar9 + -1; + uVar19 = uVar19 >> 1; + uVar15 = uVar15 + (1 << ((uint)sta_stats[uVar16].short_gi & 0x1f)) * uVar13 & 0xffff; + } while (iVar9 != 0); + uVar13 = (uint)sta_stats[uVar16].rate_map_l; + uVar19 = 1 - (uint)sta_stats[uVar16].p_type; + uVar13 = uVar15 + (((int)uVar13 >> 1 & 1U) + ((int)uVar13 >> 2 & 1U) << (uVar19 & 0x1f)) + + (uVar13 & 1) + (((int)uVar13 >> 3 & 1U) << (uVar19 & 0x1f)) & 0xffff; + goto LAB_230091b4; + } + sta_stats[uVar16].no_samples = 0; + } + assert_err("rc_ss->no_samples >= 1","module",0x8ff); + if (10 < sta_stats[uVar16].no_samples) { + assert_err("rc_ss->no_samples <= RC_MAX_N_SAMPLE","module",0x900); + } +LAB_230091c8: + rc_ss = sta_info_tab[sta_entry->staid].pol_tbl.sta_stats; + if (rc_ss == (rc_sta_stats *)0x0) { + assert_err("rc_ss != NULL","module",0x6e4); + } + uVar2 = rc_ss->no_samples; + puVar20 = &rc_ss->rate_stats[0].rate_config; + uVar19 = 0; + puVar14 = puVar20; + while (uVar19 != (uint)uVar2) { + *puVar14 = 0xffff; + uVar19 = uVar19 + 1 & 0xffff; + puVar14 = puVar14 + 6; + } + rate_map = rc_get_lowest_rate_config(rc_ss); + rc_ss->rate_stats[0].rate_config = rate_map; + rate_map = rc_get_initial_rate_config(rc_ss); + rc_ss->rate_stats[uVar19 - 1].rate_config = rate_map; + uVar19 = 1; +LAB_23009232: + do { + uVar2 = rc_ss->no_samples; + if ((int)((uint)uVar2 - 1) <= (int)uVar19) { + rc_ss->retry[0].idx = (uint16_t)((uint)uVar2 - 1); + rc_ss->retry[2].idx = uVar2 - 3; + rc_ss->avg_ampdu_len = 0x10000; + rc_ss->retry[1].idx = uVar2 - 2; + rc_ss->fixed_rate_cfg = 0xffff; + rc_ss->retry[0].tp = 0; + rc_ss->retry[1].tp = 0; + rc_ss->retry[2].tp = 0; + rc_ss->retry[3].idx = 0; + rc_ss->retry[3].tp = 0; + rc_ss->info = '\0'; + rc_update_stats(rc_ss,true); + rc_ss->sample_wait = '\x05'; + puVar11 = (uint *)(ptVar17->field_0 + 0x14); + do { + psVar4 = __s->retry; + puVar12 = puVar11 + 1; + __s = (rc_sta_stats *)&__s->rate_stats[0].probability; + *puVar11 = (uint)sta_stats[uVar16].rate_stats[*(byte *)&psVar4->idx].rate_config | + 0x80000000; + puVar11 = puVar12; + } while (puVar12 != (uint *)(ptVar17->field_0 + 0x24)); + sta_stats[uVar16].last_rc_time = _DAT_44b00120; + *(undefined4 *)ptVar17->field_0 = 0xbadcab1e; + *(uint *)(ptVar17->field_0 + 0xc) = ((uint)bVar8 + 8 & 0xff) << 10; + *(undefined4 *)(ptVar17->field_0 + 0x10) = 0xffff0704; + *(uint *)(ptVar17->field_0 + 4) = uVar18; + bVar8 = phy_get_ntx(); + *(int *)(ptVar17->field_0 + 8) = (1 << ((uint)bVar8 + 1 & 0x1f)) + -1; + ((sta_entry->pol_tbl).buf_ctrl)->mac_control_info = 0x2200; + ((sta_entry->pol_tbl).buf_ctrl)->phy_control_info = sta_entry->paid_gid; + (sta_entry->pol_tbl).upd_field = (sta_entry->pol_tbl).upd_field | 0x11; + return; + } + rate_map = rc_new_random_rate(rc_ss); + uVar15 = 0; + puVar14 = puVar20; + while (uVar15 < rc_ss->no_samples) { + if ((uint)*puVar14 == CONCAT22(extraout_var_07,rate_map)) goto LAB_23009232; + uVar15 = uVar15 + 1; + puVar14 = puVar14 + 6; + } + rc_ss->rate_stats[uVar19].rate_config = rate_map; + uVar19 = uVar19 + 1 & 0xffff; + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rc_check(uint8_t sta_idx,_Bool *tx_ampdu) + +{ + ushort uVar1; + ushort uVar2; + ushort rate_config; + ushort rate_config_00; + uint16_t uVar3; + bool bVar4; + rc_sta_stats *rc_ss; + uint uVar5; + _Bool _Var6; + uint8_t uVar7; + uint8_t uVar8; + undefined3 in_register_00002029; + uint uVar9; + undefined3 extraout_var; + uint uVar10; + uint32_t uVar11; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + uint32_t uVar12; + byte bVar13; + uint32_t *puVar14; + uint uVar15; + int iVar16; + uint uVar17; + uint uVar18; + + uVar9 = CONCAT31(in_register_00002029,sta_idx); + if (9 < uVar9) { + return; + } + rc_ss = sta_info_tab[uVar9].pol_tbl.sta_stats; + if (rc_ss == (rc_sta_stats *)0x0) { + assert_err("rc_ss != NULL","module",0x826); + } + iVar16 = 0; + if ((int)((100000 - _DAT_44b00120) + rc_ss->last_rc_time) < 0) { + _Var6 = rc_update_stats(rc_ss,false); + iVar16 = CONCAT31(extraout_var,_Var6); + rc_ss->trial_status = '\0'; + rc_ss->sw_retry_step = '\0'; + rc_ss->info = rc_ss->info & 0xef; + rc_ss->last_rc_time = _DAT_44b00120; + } + if (rc_ss->trial_status == '\x01') { + if ((rc_ss->info & 0x40) == 0) { + bVar13 = rc_ss->format_mod; + uVar1 = rc_ss->retry[0].idx; + uVar15 = (uint)uVar1; + if (bVar13 < 2) { + if ((ushort)(rc_ss->rate_stats[uVar15].probability + 0xe667) < 0xd99b) { + uVar7 = '\n'; + } + else { + uVar7 = '\x05'; + } + } + else { + uVar7 = ((char)*(undefined2 *)((int)&rc_ss->avg_ampdu_len + 2) + '\b') * '\x02'; + } + rc_ss->sample_wait = uVar7; + next = next * 0x41c64e6d + 0x3039; + uVar5 = (next >> 0x10) % (uint)rc_ss->no_samples; + if (uVar5 != uVar15) { + uVar2 = rc_ss->retry[1].idx; + if (((uVar5 != (uint)uVar2) && (uVar18 = (uint)rc_ss->retry[2].idx, uVar5 != uVar18)) && + (puVar14 = &rc_ss->last_rc_time + uVar5 * 3, *(ushort *)(puVar14 + 2) < 0xf334)) { + rate_config = *(ushort *)((int)puVar14 + 10); + uVar10 = rc_get_duration((uint)rate_config); + rate_config_00 = rc_ss->rate_stats[uVar15].rate_config; + if (bVar13 < 2) { + uVar15 = rc_get_duration((uint)rate_config_00); + if (uVar15 < uVar10) { + uVar11 = 0; + bVar4 = 0x13 < *(byte *)(puVar14 + 3); + } + else { + uVar11 = 0; + bVar4 = true; + } + } + else { + uVar17 = 0x20; + uVar15 = rc_get_duration((uint)rc_ss->rate_stats[(uint)uVar2].rate_config); + if (*(char *)((int)puVar14 + 0xd) == '\0') { + uVar17 = (uint)*(ushort *)((int)&rc_ss->avg_ampdu_len + 2); + } + if (uVar15 <= uVar10) { + uVar7 = rc_get_nss(rate_config_00); + uVar8 = rc_get_nss(rate_config); + if ((CONCAT31(extraout_var_00,uVar7) - 1U < CONCAT31(extraout_var_01,uVar8)) || + (uVar15 = rc_get_duration((uint)rc_ss->rate_stats[uVar18].rate_config), + uVar15 <= uVar10)) { + if (uVar17 <= *(byte *)(puVar14 + 3)) { + bVar13 = rc_ss->sample_slow + 1; + rc_ss->sample_slow = bVar13; + if (bVar13 < 3) goto LAB_2300964c; + if (0xf < bVar13) { + rc_ss->sample_slow = '\x0f'; + } + } + goto LAB_23009626; + } + } +LAB_2300964c: + uVar11 = rc_calc_tp(rc_ss,(uint8_t)uVar5); + bVar4 = true; + if ((*(byte *)((int)puVar14 + 0xe) & 0xf) < 10) { + bVar4 = uVar17 <= *(byte *)(puVar14 + 3); + } + } + uVar12 = rc_ss->retry[1].tp; + (rc_ss->max_tp_2_trial).idx = uVar2; + (rc_ss->max_tp_2_trial).tp = uVar12; + if (bVar4) { + uVar12 = rc_ss->retry[0].tp; + rc_ss->info = rc_ss->info & 0xfd; + rc_ss->retry[1].tp = uVar12; + rc_ss->retry[1].idx = uVar1; + rc_ss->retry[0].tp = uVar11; + rc_ss->retry[0].idx = (uint16_t)uVar5; + } + else { + rc_ss->info = rc_ss->info | 2; + rc_ss->retry[1].tp = uVar11; + rc_ss->retry[1].idx = (uint16_t)uVar5; + } + rc_ss->trial_status = '\x02'; + goto LAB_2300958c; + } + } + } +LAB_23009626: + rc_ss->trial_status = '\0'; + } + else { + if (rc_ss->trial_status == '\x03') { + if ((rc_ss->info & 2) == 0) { + rc_ss->retry[0].idx = rc_ss->retry[1].idx; + rc_ss->retry[0].tp = rc_ss->retry[1].tp; + } + uVar3 = (rc_ss->max_tp_2_trial).idx; + rc_ss->trial_status = '\0'; + rc_ss->retry[1].idx = uVar3; + uVar11 = (rc_ss->max_tp_2_trial).tp; + (rc_ss->max_tp_2_trial).tp = 0; + rc_ss->retry[1].tp = uVar11; + (rc_ss->max_tp_2_trial).idx = 0xff; + goto LAB_2300958c; + } + } + if (iVar16 == 0) { + return; + } +LAB_2300958c: + sta_info_tab[uVar9].pol_tbl.upd_field = sta_info_tab[uVar9].pol_tbl.upd_field | 1; + return; +} + + + +uint8_t rxu_cntrl_machdr_len_get(uint16_t frame_cntl) + +{ + uint8_t uVar1; + + uVar1 = '\x18'; + if ((frame_cntl & 0x300) == 0x300) { + uVar1 = '\x1e'; + } + if ((frame_cntl & 0xfc) == 0x88) { + uVar1 = uVar1 + '\x02'; + } + if ((short)frame_cntl < 0) { + uVar1 = uVar1 + '\x04'; + } + return uVar1; +} + + + +_Bool rxu_cntrl_protected_handle(uint8_t *frame,uint32_t statinfo) + +{ + ushort *puVar1; + uint uVar2; + vif_info_tag *pvVar3; + int iVar4; + + uVar2 = statinfo & 0x1c; + puVar1 = (ushort *)(frame + DAT_4201b9d0); + if (uVar2 == 0x18) { + DAT_4201b9d0 = DAT_4201b9d0 + 8; + DAT_4201b9dc = (uint)puVar1[3]; + DAT_4201b9d8 = (uint)puVar1[2] << 0x10 | (uint)*(byte *)(puVar1 + 1) | + ((uint)*puVar1 & 0xff) << 8; + DAT_4201b9f8 = DAT_4201b9f8 | 3; + if ((statinfo & 0x400) == 0) { + iVar4 = (uint)DAT_4201b9d1 * 0x1b0 + 0x40; + pvVar3 = (vif_info_tag *)sta_info_tab; + } + else { + iVar4 = (uint)(puVar1[1] >> 0xe) * 0x68 + (uint)DAT_4201b9d2 * 0x5d8 + 0x420; + pvVar3 = vif_info_tab; + } + key = (key_info_tag *)((int)&(pvVar3->list_hdr).next + iVar4); + } + else { + if (uVar2 == 0x1c) { + if ((statinfo & 0x400) == 0) { + iVar4 = (uint)DAT_4201b9d1 * 0x1b0 + 0x40; + pvVar3 = (vif_info_tag *)sta_info_tab; + } + else { + iVar4 = (uint)(puVar1[1] >> 0xe) * 0x68 + (uint)DAT_4201b9d2 * 0x5d8 + 0x420; + pvVar3 = vif_info_tab; + } + key = (key_info_tag *)((int)&(pvVar3->list_hdr).next + iVar4); + DAT_4201b9d0 = DAT_4201b9d0 + 8; + DAT_4201b9dc = (uint)puVar1[3]; + DAT_4201b9d8 = CONCAT22(puVar1[2],*puVar1); + DAT_4201b9f8 = DAT_4201b9f8 | 2; + } + else { + if (uVar2 != 0x14) { + return false; + } + DAT_4201b9d0 = DAT_4201b9d0 + 4; + } + } + return true; +} + + +/* +Unable to decompile 'rxu_mpdu_upload_and_indicate' +Cause: Exception while decompiling 23009828: Decompiler process died + +*/ + + +undefined4 rxu_mgt_frame_check(rx_swdesc *param_1,uint param_2) + +{ + char cVar1; + ushort length; + bool bVar2; + ushort uVar3; + int8_t iVar4; + ushort *bcn_addr; + ushort uVar5; + _Bool _Var6; + ke_state_t kVar7; + undefined3 extraout_var; + undefined2 extraout_var_01; + undefined2 extraout_var_02; + undefined3 extraout_var_00; + undefined2 *puVar8; + byte sta_idx; + byte bw; + uint8_t nss; + co_list_hdr cVar9; + char *pcVar10; + uint uVar11; + uint uVar12; + ke_task_id_t dest_id; + rx_dmadesc *prVar13; + uint uVar14; + vif_info_tag *vif; + int8_t iStack73; + phy_channel_info apStack72 [2]; + + sta_idx = (byte)param_2; + prVar13 = param_1->dma_hdrdesc; + iStack73 = '\0'; + bcn_addr = *(ushort **)((prVar13->hd).first_pbd_ptr + 0x18); + length = *bcn_addr; + if ((length & 0x400) != 0) { + return 1; + } + if ((*(byte *)(bcn_addr + 0xb) & 0xf) != 0) { + return 1; + } + if ((param_2 == 0xff) && (DAT_4201b9d2 = 0xff, ((prVar13->hd).statinfo & 0x600) == 0)) { + cVar9 = (co_list_hdr)vif_mgmt_env.used_list.first; + if (((length == 0xb0) || (bVar2 = true, length == 0)) && + ((((bVar2 = true, *(char *)(bcn_addr + 2) == *(char *)(bcn_addr + 8) && + (*(char *)((int)bcn_addr + 5) == *(char *)((int)bcn_addr + 0x11))) && + (*(char *)(bcn_addr + 3) == *(char *)(bcn_addr + 9))) && + ((*(char *)((int)bcn_addr + 7) == *(char *)((int)bcn_addr + 0x13) && + (*(char *)(bcn_addr + 4) == *(char *)(bcn_addr + 10))))))) { + bVar2 = *(char *)((int)bcn_addr + 9) != *(char *)((int)bcn_addr + 0x15); + } + while (DAT_4201b9d2 = sta_idx, cVar9 != (co_list_hdr)0x0) { + if (((*(char *)&((co_list_hdr *)((int)cVar9 + 0x50))->next == *(char *)(bcn_addr + 2)) && + (*(char *)((int)cVar9 + 0x51) == *(char *)((int)bcn_addr + 5))) && + ((*(char *)((int)cVar9 + 0x52) == *(char *)(bcn_addr + 3) && + (((*(char *)((int)cVar9 + 0x53) == *(char *)((int)bcn_addr + 7) && + (*(char *)&((co_list_hdr *)((int)cVar9 + 0x54))->next == *(char *)(bcn_addr + 4))) && + (*(char *)((int)cVar9 + 0x55) == *(char *)((int)bcn_addr + 9))))))) { + if (*(char *)((int)cVar9 + 0x56) == '\0') { + if (bVar2) { +LAB_23009a66: + DAT_4201b9d2 = *(byte *)((int)cVar9 + 0x57); + break; + } + } + else { + if ((*(char *)((int)cVar9 + 0x56) == '\x02') && (!bVar2)) goto LAB_23009a66; + } + } + cVar9 = *(co_list_hdr *)cVar9; + } + } + phyif_utils_decode((phyif_utils_recvtable_t *)&(prVar13->hd).recvec1a,&iStack73); + iVar4 = iStack73; + bw = DAT_4201b9d0; + uVar3 = *bcn_addr; + uVar14 = (uint)DAT_4201b9d0; + uVar11 = (uint)DAT_4201b9d2; + length = (prVar13->hd).frmlen; + uVar12 = (uint)length; + if (DAT_4201b9d2 == 0xff) { + if (param_2 != uVar11) { + DAT_4201b9d2 = sta_info_tab[param_2].inst_nbr; + uVar11 = (uint)DAT_4201b9d2; + goto LAB_23009ab4; + } + nss = '\x04'; + vif = (vif_info_tag *)0x0; + } + else { +LAB_23009ab4: + vif = vif_info_tab + uVar11; + nss = vif_info_tab[uVar11].type; + } + uVar5 = uVar3 & 0xfc; + if (uVar5 == 0x50) { + if (vif == (vif_info_tag *)0x0) goto LAB_23009af0; + bVar2 = true; + dest_id = 4; + goto LAB_23009c10; + } + if (uVar5 < 0x51) { + if (uVar5 == 0x20) { +LAB_23009b3e: + _Var6 = apm_embedded_enabled(vif); + if (CONCAT31(extraout_var,_Var6) == 0) { +LAB_23009af0: + rxu_mpdu_upload_and_indicate(param_1); + return 1; + } +LAB_23009c0c: + bVar2 = true; + dest_id = 7; + goto LAB_23009c10; + } + if (uVar5 < 0x21) { + if ((uVar3 & 0xfc) == 0) goto LAB_23009b3e; + if (uVar5 != 0x10) goto LAB_23009af0; + } + else { + if (uVar5 != 0x30) { + if (uVar5 != 0x40) goto LAB_23009af0; + goto LAB_23009b3e; + } + } + if (nss != '\0') goto LAB_23009af0; + } + else { + if (uVar5 != 0xb0) { + if (0xb0 < uVar5) { + if (uVar5 != 0xc0) { + if ((uVar5 != 0xd0) || (pcVar10 = (char *)((int)bcn_addr + uVar14), param_2 == 0xff)) + goto LAB_23009af0; + cVar1 = *pcVar10; + if (cVar1 == '\a') { + if (pcVar10[1] == '\0') { + if ((sta_info_tab[param_2].info.capa_flags & 2) == 0) { + return 0; + } + bw = pcVar10[2]; + nss = -1; + if (1 < bw) { + return 0; + } + } + else { + if (pcVar10[1] != '\x01') goto LAB_23009af0; + if ((sta_info_tab[param_2].info.capa_flags & 2) == 0) { + return 0; + } + nss = -1; + if ((pcVar10[2] & 1U) != 0) { + nss = '\0'; + } + bw = 0xff; + } + me_sta_bw_nss_max_upd(sta_idx,bw,nss); + return 0; + } + if (cVar1 == '\b') { + if ((int)(uVar12 - uVar14) < 4) { + return 0; + } + if ((DAT_4201b9d2 == 0xff) || + ((byte)(vif_info_tab[DAT_4201b9d2].type | pcVar10[1]) != 0)) goto LAB_23009af0; + dest_id = 6; + } + else { + if (cVar1 != '\x03') goto LAB_23009af0; + dest_id = 8; + } + bVar2 = false; + goto LAB_23009c10; + } +LAB_23009b64: + if (param_2 == 0xff) { + return 0; + } + goto LAB_23009b6e; + } + if (uVar5 != 0x80) { + if (uVar5 != 0xa0) goto LAB_23009af0; + goto LAB_23009b64; + } + kVar7 = ke_state_get(4); + bVar2 = CONCAT22(extraout_var_01,kVar7) != 1; + if (bVar2) { + dest_id = 0xff; + } + else { + dest_id = 4; + } + bVar2 = !bVar2; + if (param_2 != 0xff) { + if (vif->active != false) { + me_beacon_check(DAT_4201b9d2,length,(uint32_t)bcn_addr); + } +LAB_23009be6: + if (dest_id != 0xff) goto LAB_23009c10; + goto LAB_23009af0; + } + kVar7 = ke_state_get(4); + if ((CONCAT22(extraout_var_02,kVar7) == 1) || + (_Var6 = apm_embedded_enabled(vif), CONCAT31(extraout_var_00,_Var6) == 0)) + goto LAB_23009be6; + goto LAB_23009c0c; + } +LAB_23009b6e: + if (nss != '\0') goto LAB_23009b3e; + } + bVar2 = false; + dest_id = 6; +LAB_23009c10: + puVar8 = (undefined2 *) + ke_msg_alloc(0x2c00,dest_id,0xb,(uint16_t)((uVar12 + 0x1c) * 0x10000 >> 0x10)); + if (puVar8 != (undefined2 *)0x0) { + phy_get_channel(apStack72,'\0'); + if (!bVar2) { + if ((bw & 1) != 0) { + assert_warn("(machdr_length & 0x1) == 0","module",0x64d); + } + uVar12 = uVar12 - uVar14 & 0xffff; + bcn_addr = (ushort *)((int)bcn_addr + uVar14); + } + *puVar8 = (short)uVar12; + uVar11 = 0; + while (bw = DAT_4201b9d2, (uVar12 + 3 & 0xfffffffc) != uVar11) { + *(undefined4 *)((int)puVar8 + uVar11 + 0x1c) = *(undefined4 *)((int)bcn_addr + uVar11); + uVar11 = uVar11 + 4; + } + puVar8[1] = uVar3; + *(byte *)((int)puVar8 + 7) = sta_idx; + *(byte *)(puVar8 + 4) = bw; + *(int8_t *)(puVar8 + 0xd) = iVar4; + *(int8_t *)((int)puVar8 + 0x19) = iVar4; + puVar8[2] = (short)(apStack72[0].info1 >> 0x10); + *(char *)(puVar8 + 3) = (char)apStack72[0].info1; + *(undefined *)(puVar8 + 0xc) = *(undefined *)((int)&(prVar13->hd).recvec1c + 3); + if ((dest_id == 7) && ((uVar3 & 0xfc) == 0)) { + *(uint32_t *)(puVar8 + 8) = (prVar13->hd).tsflo; + *(uint32_t *)(puVar8 + 10) = (prVar13->hd).tsfhi; + *(byte *)((int)puVar8 + 0x1b) = (byte)((prVar13->hd).recvec1a >> 0xc) & 0xf; + } + ke_msg_send(puVar8); + } + return 0; +} + + + +void rxu_cntrl_init(void) + +{ + co_list_init((co_list *)&swdesc); + co_list_init((co_list *)&DAT_4201ba00); + co_list_init((co_list *)&DAT_4201ba14); + co_list_init((co_list *)&DAT_4201ba1c); + DAT_4201ba2a = 0xffff; + return; +} + + +/* +Unable to decompile 'rxu_cntrl_frame_handle' +Cause: Exception while decompiling 23009dea: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxu_cntrl_monitor_pm(mac_addr *addr) + +{ + if (DAT_4201ba37 == '\0') { + _DAT_4201ba30 = addr->array[0]; + _DAT_4201ba32 = addr->array[1]; + _DAT_4201ba34 = addr->array[2]; + _DAT_4201ba36 = 0x100; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t rxu_cntrl_get_pm(void) + +{ + _DAT_4201ba36 = 0; + return DAT_4201ba36; +} + + + +void rxu_cntrl_evt(int dummy) + +{ + ke_evt_clear(0x80000); + if (swdesc != (rx_swdesc *)0x0) { + ke_evt_set(0x20000000); + return; + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: pkt + +void rxu_swdesc_upload_evt(int arg) + +{ + rx_swdesc *swdesc; + uint uVar1; + int iVar2; + uint32_t uVar3; + uint32_t *puVar4; + uint32_t *puVar5; + uint32_t uVar6; + uint32_t local_48; + wifi_pkt pkt; + + ke_evt_clear(0x20000000); + swdesc = (rx_swdesc *)co_list_pop_front((co_list *)&swdesc); + while (swdesc != (rx_swdesc *)0x0) { + uVar1 = (uint)(swdesc->dma_hdrdesc->hd).frmlen; + memset(&local_48,0,0x28); + puVar4 = (uint32_t *)&local_48; + uVar6 = (swdesc->dma_hdrdesc->hd).first_pbd_ptr; + puVar5 = puVar4; + while ((uVar1 != 0 && (puVar5 != pkt.pkt + 3))) { + swdesc->pbd_count = swdesc->pbd_count + '\x01'; + uVar3 = *(uint32_t *)(uVar6 + 8); + *puVar5 = uVar3; + *(short *)(puVar4 + 8) = ((short)*(undefined4 *)(uVar6 + 0xc) + 1) - (short)uVar3; + puVar5[4] = uVar6 + 0x1c; + *(undefined4 *)(uVar6 + 0x14) = 1; + if (uVar1 < 0x350) { + uVar1 = 0; + } + else { + uVar1 = uVar1 - 0x350; + } + uVar6 = *(uint32_t *)(uVar6 + 4); + puVar5 = puVar5 + 1; + puVar4 = (uint32_t *)((int)puVar4 + 2); + } + swdesc->use_in_tcpip = '\x01'; + swdesc->dma_hdrdesc->use_in_tcpip = 1; + iVar2 = tcpip_stack_input(swdesc,swdesc->status,&(swdesc->dma_hdrdesc->hd).frmlen, + swdesc->dma_hdrdesc->payl_offset,(wifi_pkt *)&local_48); + if (iVar2 == 0) { + vTaskEnterCritical(); + rxl_cntrl_env.packet_stack_cnt = rxl_cntrl_env.packet_stack_cnt + swdesc->pbd_count; + vTaskExitCritical(); + } + else { + rxl_mpdu_free(swdesc); + } + swdesc = (rx_swdesc *)co_list_pop_front((co_list *)&swdesc); + } + return; +} + + + +void scanu_confirm(uint8_t status) + +{ + uint8_t *puVar1; + uint8_t *puVar2; + + if (scanu_env.joining == false) { + puVar2 = (uint8_t *)ke_msg_alloc(0x1001,scanu_env.src_id,4,1); + puVar1 = (uint8_t *)0x0; + } + else { + puVar2 = (uint8_t *)ke_msg_alloc(0x1003,scanu_env.src_id,4,1); + puVar1 = (uint8_t *)ke_msg_alloc(0x1003,0xd,4,1); + } + *puVar2 = status; + ke_msg_free(&scanu_env.param[-1].add_ies); + scanu_env.param = (scanu_start_req *)0x0; + ke_msg_send(puVar2); + if (puVar1 != (uint8_t *)0x0) { + *puVar1 = status; + ke_msg_send(puVar1); + } + ke_state_set(4,0); + return; +} + + + +void scanu_raw_send_cfm(uint8_t status,ke_task_id_t dst_id) + +{ + undefined3 in_register_00002029; + undefined4 *puVar1; + + puVar1 = (undefined4 *)ke_msg_alloc(0x1006,dst_id,4,4); + *puVar1 = CONCAT31(in_register_00002029,status); + ke_msg_send(); + return; +} + + + +void scanu_init(void) + +{ + ke_state_set(4,0); + memset(&scanu_env,0,0x194); + scanu_env.dma_desc.dma_desc = &scanu_add_ie; + scanu_env.dma_desc.cb = scanu_dma_cb; + scanu_env.dma_desc.env = (void *)0x0; + scanu_add_ie.dma_desc.dest = 0x42047ddc; + return; +} + + + +mac_scan_result * scanu_find_result(mac_addr *bssid_ptr,_Bool allocate) + +{ + undefined3 in_register_0000202d; + mac_scan_result *pmVar1; + + pmVar1 = scanu_env.scan_result; + do { + if (pmVar1->valid_flag == false) { + if (CONCAT31(in_register_0000202d,allocate) != 0) { + return pmVar1; + } + } + else { + if ((((*(char *)(pmVar1->bssid).array == *(char *)bssid_ptr->array) && + (*(char *)((int)(pmVar1->bssid).array + 1) == *(char *)((int)bssid_ptr->array + 1))) && + (*(char *)((pmVar1->bssid).array + 1) == *(char *)(bssid_ptr->array + 1))) && + (((*(char *)((int)(pmVar1->bssid).array + 3) == *(char *)((int)bssid_ptr->array + 3) && + (*(char *)((pmVar1->bssid).array + 2) == *(char *)(bssid_ptr->array + 2))) && + (*(char *)((int)(pmVar1->bssid).array + 5) == *(char *)((int)bssid_ptr->array + 5))))) { + return pmVar1; + } + } + pmVar1 = pmVar1 + 1; + if (pmVar1 == (mac_scan_result *)&scanu_env.src_id) { + return (mac_scan_result *)0x0; + } + } while( true ); +} + + + +// WARNING: Restarted to delay deadcode elimination for space: ram + +undefined4 scanu_frame_handler(ushort *param_1) + +{ + undefined uVar1; + uint8_t band; + _Bool _Var2; + ushort uVar3; + scanu_start_req *psVar4; + sm_connect_req *psVar5; + uchar uVar6; + ke_state_t kVar7; + uint16_t uVar8; + int iVar9; + undefined2 extraout_var; + mac_scan_result *pmVar10; + scan_chan_tag *psVar11; + void *__src; + byte bVar12; + uint16_t freq; + uint __n; + undefined *puVar13; + uint8_t *puVar14; + undefined *puVar15; + uint8_t *rsn_ie; + SecurityMode_t *security_mode; + char cVar16; + uint uVar17; + uint uVar18; + mac_bss_info *bss; + int iVar19; + Cipher_t *mcstCipher; + Cipher_t *mcstCipher_00; + Cipher_t *ucstCipher; + uint32_t uVar20; + mac_ssid *pmVar21; + uint uVar22; + ushort *buffer; + mac_rateset *mac_rate_set_ptr; + Cipher_t *ucstCipher_00; + undefined uStack100; + undefined local_63 [47]; + + psVar4 = scanu_env.param; + buffer = param_1 + 0x20; + uVar22 = (uint)(scanu_env.param)->vif_idx; + iVar9 = mac_ie_find(buffer,(uint)*param_1 - 0x24 & 0xffff,0); + if (iVar9 != 0) { + bVar12 = *(byte *)(iVar9 + 1); + uVar17 = (uint)bVar12; + if (bVar12 < 0x21) { + if (bVar12 == 0) goto LAB_2300a9ca; + } + else { + uVar17 = 0x20; + } + puVar13 = (undefined *)(iVar9 + 2); + if (*(char *)(iVar9 + 2) != '\0') { + uStack100 = (undefined)uVar17; + puVar15 = &uStack100; + uVar18 = uVar17; + while( true ) { + uVar18 = uVar18 - 1; + puVar15 = puVar15 + 1; + if (uVar18 == 0xffffffff) break; + uVar1 = *puVar13; + puVar13 = puVar13 + 1; + *puVar15 = uVar1; + } + local_63[uVar17] = 0; + } + } +LAB_2300a9ca: + kVar7 = ke_state_get(4); + if (((CONCAT22(extraout_var,kVar7) != 1) || + (pmVar10 = scanu_find_result((mac_addr *)(param_1 + 0x16),true), + pmVar10 == (mac_scan_result *)0x0)) || + ((((byte)scanu_env.bssid.array[0] & 1) == 0 && + (((((*(byte *)(param_1 + 0x16) != (byte)scanu_env.bssid.array[0] || + (*(char *)((int)param_1 + 0x2d) != scanu_env.bssid.array[0]._1_1_)) || + (*(char *)(param_1 + 0x17) != (char)scanu_env.bssid.array[1])) || + ((*(char *)((int)param_1 + 0x2f) != scanu_env.bssid.array[1]._1_1_ || + (*(char *)(param_1 + 0x18) != (char)scanu_env.bssid.array[2])))) || + (*(char *)((int)param_1 + 0x31) != scanu_env.bssid.array[2]._1_1_)))))) goto LAB_2300b100; + (pmVar10->bssid).array[0] = param_1[0x16]; + (pmVar10->bssid).array[1] = param_1[0x17]; + (pmVar10->bssid).array[2] = param_1[0x18]; + pmVar10->beacon_period = param_1[0x1e]; + uVar3 = param_1[0x1f]; + pmVar10->cap_info = uVar3; + freq = uVar3 & 1; + if ((uVar3 & 1) == 0) { + freq = 2; + } + pmVar10->bsstype = freq; + uVar3 = *param_1; + uVar17 = (uint)uVar3 - 0x24 & 0xffff; + iVar9 = mac_ie_find(buffer,uVar17,0); + if (iVar9 == 0) { + (pmVar10->ssid).length = '\0'; + } + else { + bVar12 = *(byte *)(iVar9 + 1); + uVar18 = (uint)bVar12; + if (bVar12 < 0x21) { + if (bVar12 == 0) goto LAB_2300aa9e; + } + else { + uVar18 = 0x20; + } + rsn_ie = (uint8_t *)(iVar9 + 2); + if (*(char *)(iVar9 + 2) != '\0') { + (pmVar10->ssid).length = (uint8_t)uVar18; + puVar14 = (pmVar10->ssid).array; + while (uVar18 = uVar18 - 1, uVar18 != 0xffffffff) { + band = *rsn_ie; + rsn_ie = rsn_ie + 1; + *puVar14 = band; + puVar14 = puVar14 + 1; + } + } + } +LAB_2300aa9e: + pmVar10->ppm_rel = *(int8_t *)(param_1 + 0xd); + pmVar10->ppm_abs = *(int8_t *)((int)param_1 + 0x19); + if (psVar4->ssid_cnt != '\0') { + uVar18 = 0; + pmVar21 = psVar4->ssid; + while ((int)uVar18 < (int)(uint)psVar4->ssid_cnt) { + if (pmVar21->length == 0) goto LAB_2300ab3c; + __n = (uint)(pmVar10->ssid).length; + if ((__n == (uint)pmVar21->length) && + (iVar9 = memcmp(pmVar21->array,(pmVar10->ssid).array,__n), iVar9 == 0)) break; + uVar18 = uVar18 + 1; + pmVar21 = pmVar21 + 1; + } + if ((uint)psVar4->ssid_cnt == uVar18) goto LAB_2300b100; + } +LAB_2300ab3c: + iVar9 = mac_ie_find(buffer,uVar17,3); + if (iVar9 == 0) { + if (pmVar10->rssi < *(char *)(param_1 + 0xc)) { + psVar11 = me_freq_to_chan_ptr(*(uint8_t *)(param_1 + 3),param_1[2]); + pmVar10->chan = psVar11; + cVar16 = *(char *)(param_1 + 0xc); + goto LAB_2300ab8c; + } + } + else { + bVar12 = *(byte *)(iVar9 + 2); + band = *(uint8_t *)(param_1 + 3); + if (band == '\0') { + if ((uint)bVar12 - 1 < 0xe) { + if (bVar12 == 0xe) { + freq = 0x9b4; + } + else { + freq = (ushort)bVar12 * 5 + 0x967; + } + } + else { +LAB_2300afea: + freq = 0xffff; + } + } + else { + if ((band != '\x01') || (0xa4 < (uint)bVar12 - 1)) goto LAB_2300afea; + freq = (ushort)bVar12 * 5 + 5000; + } + psVar11 = me_freq_to_chan_ptr(band,freq); + pmVar10->chan = psVar11; + cVar16 = *(char *)(param_1 + 0xc); + if (pmVar10->rssi < cVar16) { +LAB_2300ab8c: + pmVar10->rssi = cVar16; + } + } + if (scanu_env.joining != false) { + bss = &vif_info_tab[uVar22].bss_info; + vif_info_tab[uVar22].bss_info.bsstype = pmVar10->bsstype; + mac_rate_set_ptr = &vif_info_tab[uVar22].bss_info.rate_set; + *(undefined4 *)vif_info_tab[uVar22].bss_info.bssid.array = *(undefined4 *)(pmVar10->bssid).array + ; + vif_info_tab[uVar22].bss_info.bssid.array[2] = (pmVar10->bssid).array[2]; + vif_info_tab[uVar22].bss_info.cap_info = pmVar10->cap_info; + vif_info_tab[uVar22].bss_info.beacon_period = pmVar10->beacon_period; + memcpy(&vif_info_tab[uVar22].bss_info.ssid,&pmVar10->ssid,0x22); + psVar11 = pmVar10->chan; + vif_info_tab[uVar22].bss_info.valid_flags = 0; + vif_info_tab[uVar22].bss_info.chan = psVar11; + vif_info_tab[uVar22].bss_info.ppm_rel = pmVar10->ppm_rel; + vif_info_tab[uVar22].bss_info.ppm_abs = pmVar10->ppm_abs; + freq = (uint16_t)(((uint)uVar3 - 0x24) * 0x10000 >> 0x10); + me_extract_rate_set((uint32_t)buffer,freq,mac_rate_set_ptr); + if (pmVar10->chan->band == '\0') { + uVar8 = me_legacy_rate_bitfield_build(mac_rate_set_ptr,true); + if ((uVar8 & 0xf) == 0) { + vif_info_tab[uVar22].bss_info.high_11b_rate = '\x01'; + } + else { + iVar9 = __clzsi2((uint)uVar8 & 0xf); + vif_info_tab[uVar22].bss_info.high_11b_rate = '\x1f' - (char)iVar9; + } + } + iVar9 = mac_vsie_find(buffer,uVar17,&DAT_230750d0,5); + if (iVar9 == 0) { + vif_info_tab[uVar22].bss_info.edca_param.ac_param[0] = 0xa43; + vif_info_tab[uVar22].bss_info.edca_param.ac_param[1] = 0xa43; + vif_info_tab[uVar22].bss_info.edca_param.ac_param[2] = 0xa43; + vif_info_tab[uVar22].bss_info.edca_param.ac_param[3] = 0xa43; + } + else { + vif_info_tab[uVar22].bss_info.edca_param.qos_info = *(uint8_t *)(iVar9 + 8); + vif_info_tab[uVar22].bss_info.cap_info = vif_info_tab[uVar22].bss_info.cap_info | 0x200; + uVar18 = *(uint *)(iVar9 + 10); + bVar12 = (byte)(uVar18 >> 3) & 2; + vif_info_tab[uVar22].bss_info.edca_param.acm = bVar12; + vif_info_tab[uVar22].bss_info.edca_param.ac_param[1] = uVar18 & 0xf | (uVar18 >> 8) << 4; + uVar18 = *(uint *)(iVar9 + 0xe); + bVar12 = (byte)(uVar18 >> 4) & 1 | bVar12; + vif_info_tab[uVar22].bss_info.edca_param.acm = bVar12; + vif_info_tab[uVar22].bss_info.edca_param.ac_param[0] = uVar18 & 0xf | (uVar18 >> 8) << 4; + uVar18 = *(uint *)(iVar9 + 0x12); + bVar12 = bVar12 | (byte)(uVar18 >> 2) & 4; + vif_info_tab[uVar22].bss_info.edca_param.acm = bVar12; + vif_info_tab[uVar22].bss_info.edca_param.ac_param[2] = uVar18 & 0xf | (uVar18 >> 8) << 4; + uVar18 = *(uint *)(iVar9 + 0x16); + vif_info_tab[uVar22].bss_info.edca_param.acm = bVar12 | (byte)(uVar18 >> 1) & 8; + __n = vif_info_tab[uVar22].bss_info.valid_flags; + vif_info_tab[uVar22].bss_info.edca_param.ac_param[3] = uVar18 & 0xf | (uVar18 >> 8) << 4; + vif_info_tab[uVar22].bss_info.valid_flags = __n | 1; + } + uVar18 = 0; + if (me_env.ht_supported != false) { + uVar18 = vif_info_tab[uVar22].bss_info.valid_flags & 1; + if (uVar18 != 0) { + iVar9 = mac_ie_find(buffer,uVar17,0x2d); + if (iVar9 != 0) { + vif_info_tab[uVar22].bss_info.ht_cap.ht_capa_info = *(uint16_t *)(iVar9 + 2); + vif_info_tab[uVar22].bss_info.ht_cap.a_mpdu_param = *(uint8_t *)(iVar9 + 4); + iVar19 = 0; + do { + vif_info_tab[uVar22].bss_info.ht_cap.mcs_rate[iVar19] = *(uint8_t *)(iVar9 + 5 + iVar19) + ; + iVar19 = iVar19 + 1; + } while (iVar19 != 0x10); + vif_info_tab[uVar22].bss_info.ht_cap.ht_extended_capa = *(uint16_t *)(iVar9 + 0x15); + vif_info_tab[uVar22].bss_info.ht_cap.tx_beamforming_capa = (uint)*(ushort *)(iVar9 + 0x17) + ; + vif_info_tab[uVar22].bss_info.ht_cap.asel_capa = *(uint8_t *)(iVar9 + 0x1b); + vif_info_tab[uVar22].bss_info.valid_flags = vif_info_tab[uVar22].bss_info.valid_flags | 2; + } + uVar18 = mac_ie_find(buffer,uVar17,0x3d); + } + } + _Var2 = (sm_env.connect_param)->is_supplicant_enabled; + vif_info_tab[uVar22].bss_info.is_supplicant_enabled = _Var2; + if ((_Var2 != false) && (-1 < (int)vif_info_tab[uVar22].bss_info.valid_flags)) { + security_mode = &vif_info_tab[uVar22].bss_info.wpa_wpa2_wep; + memset(security_mode,0,2); + mcstCipher = &vif_info_tab[uVar22].bss_info.rsn_mcstCipher; + ucstCipher_00 = &vif_info_tab[uVar22].bss_info.rsn_ucstCipher; + memset(mcstCipher,0,1); + memset(ucstCipher_00,0,1); + mcstCipher_00 = &vif_info_tab[uVar22].bss_info.wpa_mcstCipher; + memset(mcstCipher_00,0,1); + ucstCipher = &vif_info_tab[uVar22].bss_info.wpa_ucstCipher; + memset(ucstCipher,0,1); + vif_info_tab[uVar22].bss_info.rsn_wpa_ie_len = '\0'; + vif_info_tab[uVar22].bss_info.is_pmf_required = false; + vif_info_tab[uVar22].bss_info.is_wpa2_prefered = false; + __src = (void *)mac_ie_find(buffer,uVar17,0x30); + rsn_ie = vif_info_tab[uVar22].bss_info.rsn_wpa_ie; + if (__src != (void *)0x0) { + __n = (uint)*(byte *)((int)__src + 1) + 2 & 0xff; + vif_info_tab[uVar22].bss_info.rsn_wpa_ie_len = (uint8_t)__n; + memcpy(rsn_ie,__src,__n); + uVar6 = process_rsn_ie(rsn_ie,mcstCipher,ucstCipher_00, + &vif_info_tab[uVar22].bss_info.is_pmf_required,security_mode, + *(_Bool *)(uVar22 * 0x5d8 + 0x4201a800)); + __n = *(uint *)&vif_info_tab[uVar22].bss_info.wpa_ucstCipher; + vif_info_tab[uVar22].bss_info.rsn_wpa_ie_len = uVar6; + printf("wpa2/wpa3 pairwise ccmp:%d,tkip:%d,wep104:%d,wep:40:%d\r\n",__n >> 0x13 & 1, + __n >> 0x12 & 1,__n >> 0x11 & 1,__n >> 0x10 & 1); + __n = *(uint *)&vif_info_tab[uVar22].bss_info.wpa_ucstCipher; + printf("wpa2/wpa3 group ccmp:%d,tkip:%d,wep104:%d,wep:40:%d\r\n",__n >> 0xb & 1, + __n >> 10 & 1,__n >> 9 & 1,__n >> 8 & 1); + printf("wpa2/wpa3 is_pmf_required:%d\r\n", + (uint)vif_info_tab[uVar22].bss_info.is_pmf_required); + } + __src = (void *)mac_vsie_find(buffer,uVar17,&DAT_230750d8,4); + if (__src != (void *)0x0) { + *(byte *)&vif_info_tab[uVar22].bss_info.wpa_wpa2_wep = + *(byte *)&vif_info_tab[uVar22].bss_info.wpa_wpa2_wep | 8; + if (vif_info_tab[uVar22].bss_info.rsn_wpa_ie_len == '\0') { + __n = (uint)*(byte *)((int)__src + 1) + 2 & 0xff; + vif_info_tab[uVar22].bss_info.rsn_wpa_ie_len = (uint8_t)__n; + memcpy(rsn_ie,__src,__n); + uVar6 = process_wpa_ie(rsn_ie,mcstCipher_00,ucstCipher); + vif_info_tab[uVar22].bss_info.rsn_wpa_ie_len = uVar6; + } + } + psVar5 = sm_env.connect_param; + (sm_env.connect_param)->flags = 0; + if ((*(uint *)&vif_info_tab[uVar22].bss_info.is_supplicant_enabled & 0x12800) == 0) { + if ((vif_info_tab[uVar22].bss_info.cap_info & 0x10) == 0) { + uVar20 = 2; + goto LAB_2300afbc; + } + *(byte *)&vif_info_tab[uVar22].bss_info.wpa_wpa2_wep = + *(byte *)&vif_info_tab[uVar22].bss_info.wpa_wpa2_wep | 2; + psVar5->auth_type = '\x01'; + } + else { + uVar20 = 9; +LAB_2300afbc: + psVar5->flags = uVar20; + } + memcpy(psVar5->ie_buf,rsn_ie,(uint)vif_info_tab[uVar22].bss_info.rsn_wpa_ie_len); + (sm_env.connect_param)->ie_len = (ushort)vif_info_tab[uVar22].bss_info.rsn_wpa_ie_len; + __n = *(uint *)&vif_info_tab[uVar22].bss_info.is_supplicant_enabled; + printf("AP Security mode: wep:%d,wpa:%d,wpa2:%d,wpa3:%d\r\n",__n >> 9 & 1,__n >> 0xb & 1, + __n >> 0xd & 1,__n >> 0x10 & 1); + } + me_bw_check(uVar18,0,bss); + me_extract_power_constraint((uint32_t)buffer,freq,bss); + me_extract_country_reg(buffer,uVar17,bss); + me_extract_mobility_domain((uint32_t)buffer,freq,bss); + vif_info_tab[uVar22].bss_info.valid_flags = + vif_info_tab[uVar22].bss_info.valid_flags | 0x80000000; + } + if (pmVar10->valid_flag == false) { + scanu_env.result_cnt = scanu_env.result_cnt + 1; + } + if (psVar4->ssid_cnt != '\0') { + pmVar10->valid_flag = true; + } +LAB_2300b100: + ke_msg_forward_and_change_id(param_1,0x1004,0xd,4); + return 1; +} + + + +mac_scan_result * scanu_search_by_bssid(mac_addr *bssid) + +{ + mac_scan_result *pmVar1; + + pmVar1 = scanu_find_result(bssid,false); + return pmVar1; +} + + + +mac_scan_result * scanu_search_by_ssid(mac_ssid *ssid,int *idx) + +{ + scanu_env_tag *psVar1; + int iVar2; + int iVar3; + mac_scan_result *pmVar4; + int8_t iVar5; + + pmVar4 = (mac_scan_result *)0x0; + if (ssid->length != '\0') { + psVar1 = &scanu_env; + iVar3 = 0; + pmVar4 = (mac_scan_result *)0x0; + iVar5 = -0x80; + do { + if (psVar1->scan_result[0].valid_flag == false) { + return pmVar4; + } + if (((iVar5 < psVar1->scan_result[0].rssi) && + ((uint)ssid->length == (uint)psVar1->scan_result[0].ssid.length)) && + (iVar2 = memcmp(psVar1->scan_result[0].ssid.array,ssid->array,(uint)ssid->length), + iVar2 == 0)) { + iVar5 = psVar1->scan_result[0].rssi; + pmVar4 = psVar1->scan_result; + *idx = iVar3; + } + iVar3 = iVar3 + 1; + psVar1 = (scanu_env_tag *)(psVar1->scan_result[0].ssid.array + 0x19); + } while (iVar3 != 6); + } + return pmVar4; +} + + + +void scanu_rm_exist_ssid(mac_ssid *ssid,int index) + +{ + int iVar1; + + if ((index < 0) || (ssid == (mac_ssid *)0x0)) { + return; + } + if (((scanu_env.scan_result[index].valid_flag != false) && + ((uint)ssid->length == (uint)scanu_env.scan_result[index].ssid.length)) && + (iVar1 = memcmp(scanu_env.scan_result[index].ssid.array,ssid->array,(uint)ssid->length), + iVar1 == 0)) { + memset(scanu_env.scan_result + index,0,0x38); + return; + } + return; +} + + + +void scanu_scan_next(void) + +{ + byte bVar1; + int iVar2; + scanu_start_req *psVar3; + uint uVar4; + void *pvVar5; + uint uVar6; + uint8_t *puVar7; + undefined *puVar8; + undefined *puVar9; + uint32_t *puVar10; + me_env_tag *pmVar11; + short sVar12; + int iVar13; + undefined *puVar14; + int iVar15; + scanu_add_ie_tag *psVar16; + uint8_t *puVar17; + uint uVar18; + int iVar19; + int iVar20; + + psVar3 = scanu_env.param; + while( true ) { + if (1 < scanu_env.band) { + scanu_confirm('\0'); + return; + } + uVar18 = 0; + puVar7 = &(scanu_env.param)->chan[0].band; + while ((int)uVar18 < (int)(uint)(scanu_env.param)->chan_cnt) { + if (*puVar7 == scanu_env.band) goto LAB_2300b27a; + uVar18 = uVar18 + 1; + puVar7 = puVar7 + 6; + } + if ((uint)(scanu_env.param)->chan_cnt != uVar18) break; + scanu_env.band = scanu_env.band + '\x01'; + } +LAB_2300b27a: + pvVar5 = ke_msg_alloc(0x800,2,4,0x154); + *(uint8_t *)((int)pvVar5 + 0x14e) = psVar3->vif_idx; + *(undefined4 *)((int)pvVar5 + 0x140) = *(undefined4 *)(psVar3->bssid).array; + *(uint16_t *)((int)pvVar5 + 0x144) = (psVar3->bssid).array[2]; + *(uint8_t *)((int)pvVar5 + 0x150) = psVar3->ssid_cnt; + *(_Bool *)((int)pvVar5 + 0x151) = psVar3->no_cck; + while ((int)uVar18 < (int)(uint)psVar3->chan_cnt) { + if (*(uint8_t *)(&psVar3->chan[uVar18].freq + 1) == scanu_env.band) { + bVar1 = *(byte *)((int)pvVar5 + 0x14f); + memcpy((void *)((uint)bVar1 * 6 + (int)pvVar5),psVar3->chan + uVar18,6); + *(char *)((int)pvVar5 + 0x14f) = bVar1 + 1; + } + uVar18 = uVar18 + 1; + } + iVar19 = 0xfc; + iVar20 = 0; + while (iVar20 < (int)(uint)psVar3->ssid_cnt) { + memcpy((void *)((int)pvVar5 + iVar19),(void *)((int)&psVar3->chan[0].freq + iVar19),0x22); + iVar20 = iVar20 + 1; + iVar19 = iVar19 + 0x22; + } + uVar18 = (uint)(scanu_env.param)->add_ie_len; + puVar10 = scanu_add_ie.buf; + if (200 < (scanu_env.param)->add_ie_len) { + uVar18 = 0; + } + if ((scanu_env.band == '\x01') || ((scanu_env.param)->no_cck != false)) { + iVar19 = 4; + iVar20 = 8; + } + else { + iVar19 = 0; + iVar20 = 0xc; + } + scan_probe_req_ie.buf[0]._0_1_ = 1; + scan_probe_req_ie.buf[0]._1_1_ = 8; + iVar13 = 0; + do { + iVar15 = iVar19 + iVar13; + iVar2 = iVar13 + 2; + iVar13 = iVar13 + 1; + *(uint8_t *)((int)scan_probe_req_ie.buf + iVar2) = mac_id2rate[iVar15]; + } while (iVar13 != 8); + puVar14 = (undefined *)((int)scan_probe_req_ie.buf + 10); + if ((uVar18 != 0) && ((char)scanu_add_ie.buf[0] == '\n')) { + uVar6 = (uint)scanu_add_ie.buf[0]._1_1_ + 2 & 0xff; + uVar4 = uVar6; + psVar16 = &scanu_add_ie; + while( true ) { + uVar4 = uVar4 - 1; + if (uVar4 == 0xffffffff) break; + *puVar14 = *(undefined *)psVar16->buf; + psVar16 = (scanu_add_ie_tag *)((int)&(psVar16->dma_desc).src + 1); + puVar14 = puVar14 + 1; + } + puVar14 = (undefined *)((int)scan_probe_req_ie.buf + uVar6 + 10); + puVar10 = (uint32_t *)((int)scanu_add_ie.buf + uVar6); + uVar18 = uVar18 - uVar6 & 0xffff; + } + if (iVar20 != 8) { + uVar4 = iVar20 - 8U & 0xff; + *puVar14 = 0x32; + puVar14[1] = (char)uVar4; + iVar19 = uVar4 + 2; + puVar7 = mac_id2rate; + puVar17 = puVar14 + 2; + while( true ) { + uVar4 = uVar4 - 1; + if (uVar4 == 0xffffffff) break; + *puVar17 = puVar7[8]; + puVar7 = puVar7 + 1; + puVar17 = puVar17 + 1; + } + puVar14 = puVar14 + iVar19; + } + if (scanu_env.band == '\0') { + *puVar14 = 3; + puVar14[1] = 1; + puVar14 = puVar14 + 3; + } + if ((uVar18 != 0) && (*(char *)puVar10 == ';')) { + uVar4 = 0; + uVar6 = (uint)*(byte *)((int)puVar10 + 1) + 2 & 0xff; + while (uVar6 != uVar4) { + puVar8 = (undefined *)((int)puVar10 + uVar4); + puVar9 = puVar14 + uVar4; + uVar4 = uVar4 + 1; + *puVar9 = *puVar8; + } + puVar14 = puVar14 + uVar6; + puVar10 = (uint32_t *)((int)puVar10 + uVar6); + uVar18 = uVar18 - uVar6 & 0xffff; + } + if (me_env.ht_supported != false) { + *puVar14 = 0x2d; + puVar14[1] = 0x1a; + puVar8 = puVar14 + 0x1c; + pmVar11 = &me_env; + puVar14 = puVar14 + 2; + while (puVar8 != puVar14) { + *puVar14 = *(undefined *)&(pmVar11->ht_cap).ht_capa_info; + pmVar11 = (me_env_tag *)((int)&pmVar11->active_vifs + 1); + puVar14 = puVar14 + 1; + } + } + sVar12 = (short)puVar14; + if (uVar18 != 0) { + uVar4 = 0; + do { + puVar8 = (undefined *)((int)puVar10 + uVar4); + puVar9 = puVar14 + uVar4; + uVar4 = uVar4 + 1; + *puVar9 = *puVar8; + } while (uVar18 != uVar4); + sVar12 = sVar12 + (short)uVar18; + } + *(short *)((int)pvVar5 + 0x14c) = sVar12 + -0x7d04; + *(undefined4 *)((int)pvVar5 + 0x148) = 0; + ke_msg_send(pvVar5); + return; +} + + + +void scanu_dma_cb(void) + +{ + byte bVar1; + int iVar2; + scanu_start_req *psVar3; + uint uVar4; + void *pvVar5; + uint uVar6; + uint8_t *puVar7; + undefined *puVar8; + undefined *puVar9; + uint32_t *puVar10; + me_env_tag *pmVar11; + short sVar12; + int iVar13; + undefined *puVar14; + int iVar15; + scanu_add_ie_tag *psVar16; + uint8_t *puVar17; + uint uVar18; + int iVar19; + int iVar20; + + psVar3 = scanu_env.param; + while( true ) { + if (1 < scanu_env.band) { + scanu_confirm('\0'); + return; + } + uVar18 = 0; + puVar7 = &(scanu_env.param)->chan[0].band; + while ((int)uVar18 < (int)(uint)(scanu_env.param)->chan_cnt) { + if (*puVar7 == scanu_env.band) goto LAB_2300b27a; + uVar18 = uVar18 + 1; + puVar7 = puVar7 + 6; + } + if ((uint)(scanu_env.param)->chan_cnt != uVar18) break; + scanu_env.band = scanu_env.band + '\x01'; + } +LAB_2300b27a: + pvVar5 = ke_msg_alloc(0x800,2,4,0x154); + *(uint8_t *)((int)pvVar5 + 0x14e) = psVar3->vif_idx; + *(undefined4 *)((int)pvVar5 + 0x140) = *(undefined4 *)(psVar3->bssid).array; + *(uint16_t *)((int)pvVar5 + 0x144) = (psVar3->bssid).array[2]; + *(uint8_t *)((int)pvVar5 + 0x150) = psVar3->ssid_cnt; + *(_Bool *)((int)pvVar5 + 0x151) = psVar3->no_cck; + while ((int)uVar18 < (int)(uint)psVar3->chan_cnt) { + if (*(uint8_t *)(&psVar3->chan[uVar18].freq + 1) == scanu_env.band) { + bVar1 = *(byte *)((int)pvVar5 + 0x14f); + memcpy((void *)((uint)bVar1 * 6 + (int)pvVar5),psVar3->chan + uVar18,6); + *(char *)((int)pvVar5 + 0x14f) = bVar1 + 1; + } + uVar18 = uVar18 + 1; + } + iVar19 = 0xfc; + iVar20 = 0; + while (iVar20 < (int)(uint)psVar3->ssid_cnt) { + memcpy((void *)((int)pvVar5 + iVar19),(void *)((int)&psVar3->chan[0].freq + iVar19),0x22); + iVar20 = iVar20 + 1; + iVar19 = iVar19 + 0x22; + } + uVar18 = (uint)(scanu_env.param)->add_ie_len; + puVar10 = scanu_add_ie.buf; + if (200 < (scanu_env.param)->add_ie_len) { + uVar18 = 0; + } + if ((scanu_env.band == '\x01') || ((scanu_env.param)->no_cck != false)) { + iVar19 = 4; + iVar20 = 8; + } + else { + iVar19 = 0; + iVar20 = 0xc; + } + scan_probe_req_ie.buf[0]._0_1_ = 1; + scan_probe_req_ie.buf[0]._1_1_ = 8; + iVar13 = 0; + do { + iVar15 = iVar19 + iVar13; + iVar2 = iVar13 + 2; + iVar13 = iVar13 + 1; + *(uint8_t *)((int)scan_probe_req_ie.buf + iVar2) = mac_id2rate[iVar15]; + } while (iVar13 != 8); + puVar14 = (undefined *)((int)scan_probe_req_ie.buf + 10); + if ((uVar18 != 0) && ((char)scanu_add_ie.buf[0] == '\n')) { + uVar6 = (uint)scanu_add_ie.buf[0]._1_1_ + 2 & 0xff; + uVar4 = uVar6; + psVar16 = &scanu_add_ie; + while( true ) { + uVar4 = uVar4 - 1; + if (uVar4 == 0xffffffff) break; + *puVar14 = *(undefined *)psVar16->buf; + psVar16 = (scanu_add_ie_tag *)((int)&(psVar16->dma_desc).src + 1); + puVar14 = puVar14 + 1; + } + puVar14 = (undefined *)((int)scan_probe_req_ie.buf + uVar6 + 10); + puVar10 = (uint32_t *)((int)scanu_add_ie.buf + uVar6); + uVar18 = uVar18 - uVar6 & 0xffff; + } + if (iVar20 != 8) { + uVar4 = iVar20 - 8U & 0xff; + *puVar14 = 0x32; + puVar14[1] = (char)uVar4; + iVar19 = uVar4 + 2; + puVar7 = mac_id2rate; + puVar17 = puVar14 + 2; + while( true ) { + uVar4 = uVar4 - 1; + if (uVar4 == 0xffffffff) break; + *puVar17 = puVar7[8]; + puVar7 = puVar7 + 1; + puVar17 = puVar17 + 1; + } + puVar14 = puVar14 + iVar19; + } + if (scanu_env.band == '\0') { + *puVar14 = 3; + puVar14[1] = 1; + puVar14 = puVar14 + 3; + } + if ((uVar18 != 0) && (*(char *)puVar10 == ';')) { + uVar4 = 0; + uVar6 = (uint)*(byte *)((int)puVar10 + 1) + 2 & 0xff; + while (uVar6 != uVar4) { + puVar8 = (undefined *)((int)puVar10 + uVar4); + puVar9 = puVar14 + uVar4; + uVar4 = uVar4 + 1; + *puVar9 = *puVar8; + } + puVar14 = puVar14 + uVar6; + puVar10 = (uint32_t *)((int)puVar10 + uVar6); + uVar18 = uVar18 - uVar6 & 0xffff; + } + if (me_env.ht_supported != false) { + *puVar14 = 0x2d; + puVar14[1] = 0x1a; + puVar8 = puVar14 + 0x1c; + pmVar11 = &me_env; + puVar14 = puVar14 + 2; + while (puVar8 != puVar14) { + *puVar14 = *(undefined *)&(pmVar11->ht_cap).ht_capa_info; + pmVar11 = (me_env_tag *)((int)&pmVar11->active_vifs + 1); + puVar14 = puVar14 + 1; + } + } + sVar12 = (short)puVar14; + if (uVar18 != 0) { + uVar4 = 0; + do { + puVar8 = (undefined *)((int)puVar10 + uVar4); + puVar9 = puVar14 + uVar4; + uVar4 = uVar4 + 1; + *puVar9 = *puVar8; + } while (uVar18 != uVar4); + sVar12 = sVar12 + (short)uVar18; + } + *(short *)((int)pvVar5 + 0x14c) = sVar12 + -0x7d04; + *(undefined4 *)((int)pvVar5 + 0x148) = 0; + ke_msg_send(pvVar5); + return; +} + + + +void scanu_start(void) + +{ + scanu_env_tag *psVar1; + + if (scanu_env.joining == false) { + psVar1 = &scanu_env; + do { + psVar1->scan_result[0].valid_flag = false; + psVar1->scan_result[0].rssi = -0x80; + psVar1 = (scanu_env_tag *)(psVar1->scan_result[0].ssid.array + 0x19); + } while (psVar1 != (scanu_env_tag *)0x4201bb94); + scanu_env.result_cnt = 0; + } + ke_state_set(4,1); + if ((scanu_env.param)->add_ies != 0) { + if ((scanu_env.param)->add_ie_len < 0xc9) { + scanu_add_ie.dma_desc.src = (scanu_env.param)->add_ies; + scanu_add_ie.dma_desc.length = (scanu_env.param)->add_ie_len; + hal_dma_push(&scanu_env.dma_desc,0); + return; + } + } + scanu_scan_next(); + return; +} + + + +uint16_t txl_get_seq_ctrl(void) + +{ + uint uVar1; + + uVar1 = (uint)txl_cntrl_env.seqnbr; + txl_cntrl_env.seqnbr = (uint16_t)((uVar1 + 1) * 0x10000 >> 0x10); + return (uint16_t)((uVar1 + 1) * 0x100000 >> 0x10); +} + + + +void sm_delete_resources(vif_info_tag *vif) + +{ + undefined *puVar1; + undefined *puVar2; + void *pvVar3; + byte *pbVar4; + + puVar1 = (undefined *)ke_msg_alloc(0x1413,5,6,2); + puVar2 = (undefined *)ke_msg_alloc(0x1411,5,6,2); + *puVar1 = 0; + puVar1[1] = vif->index; + ke_msg_send(puVar1); + if (vif->active != false) { + pvVar3 = ke_msg_alloc(0x1e,0,6,4); + *(undefined *)((int)pvVar3 + 2) = 0; + *(uint8_t *)((int)pvVar3 + 3) = vif->index; + ke_msg_send(); + } + if (vif->u[4] != 0xff) { + pbVar4 = (byte *)ke_msg_alloc(0xc,0,6,1); + *pbVar4 = vif->u[4]; + ke_msg_send(); + } + if (vif->chan_ctxt != (chan_ctxt_tag *)0x0) { + chan_ctxt_unlink(vif->index); + } + *puVar2 = 0; + puVar2[1] = vif->index; + ke_msg_send(puVar2); + (vif->bss_info).valid_flags = 0; + return; +} + + + +void sm_frame_tx_cfm_handler(void *env,uint32_t status) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(6); + if (((status & 0x40030000) != 0) && (CONCAT22(extraout_var,kVar1) - 5U < 2)) { + txl_frame_push((txl_frame_desc_tag *)env,'\x03'); + *(undefined *)((int)env + 0x2d6) = 1; + } + return; +} + + + +void sm_init(void) + +{ + sm_env.connect_param = (sm_connect_req *)0x0; + ke_state_set(6,0); + return; +} + + + +void sm_get_bss_params(mac_addr **bssid,scan_chan_tag **chan) + +{ + byte bVar1; + sm_connect_req *ssid; + int iVar2; + int iVar3; + mac_scan_result *pmVar4; + mac_addr *bssid_00; + mac_addr *pmVar5; + int local_34; + int index; + + ssid = sm_env.connect_param; + *bssid = (mac_addr *)0x0; + *chan = (scan_chan_tag *)0x0; + bssid_00 = &ssid->bssid; + local_34 = -1; + printf("===start sm_get_bss_params===\r\n"); + iVar2 = 0; + pmVar5 = bssid_00; + do { + iVar3 = iVar2 + 1; + printf("bssid[%d] = 0x%x\r\n",iVar2,(uint)pmVar5->array[0]); + pmVar5 = (mac_addr *)(pmVar5->array + 1); + iVar2 = iVar3; + } while (iVar3 != 3); + bVar1 = *(byte *)(ssid->bssid).array; + if (((bVar1 & 1) == 0) && + ((((bVar1 != 0 || (*(char *)((int)(ssid->bssid).array + 1) != '\0')) || + (*(char *)((ssid->bssid).array + 1) != '\0')) || + (((*(char *)((int)(ssid->bssid).array + 3) != '\0' || + (*(char *)((ssid->bssid).array + 2) != '\0')) || + (*(char *)((int)(ssid->bssid).array + 5) != '\0')))))) { + printf("search bssid \r\n "); + *bssid = bssid_00; + pmVar4 = scanu_search_by_bssid(bssid_00); + if (pmVar4 == (mac_scan_result *)0x0) goto LAB_2300b794; + } + else { + printf("search ssid = %s\r\n",(ssid->ssid).array); + pmVar4 = scanu_search_by_ssid((mac_ssid *)ssid,&local_34); + printf("result ssid index = %d\r\n",local_34); + if (pmVar4 == (mac_scan_result *)0x0) { +LAB_2300b794: + if ((ssid->chan).freq != 0xffff) { + *chan = &ssid->chan; + } + goto LAB_2300b756; + } + if (-1 < local_34) { + *(mac_scan_result **)bssid = pmVar4; + sm_env.exist_ssid_idx = local_34; + } + } + *chan = pmVar4->chan; +LAB_2300b756: + printf("===end sm_get_bss_params===\r\n"); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void sm_scan_bss(mac_addr *bssid,scan_chan_tag *chan_1) + +{ + uint8_t uVar1; + byte bVar2; + undefined2 uVar3; + sm_connect_req *__src; + int iVar4; + void *__dest; + void *__src_00; + undefined2 *puVar5; + int *piVar6; + undefined2 local_2c; + undefined2 uStack42; + uint8_t chan_cnt [2]; + scan_chan_tag *chan [2]; + + __src = sm_env.connect_param; + __dest = ke_msg_alloc(0x1000,4,6,0x154); + uVar1 = __src->vif_idx; + *(undefined4 *)((int)__dest + 0x148) = 0; + *(uint8_t *)((int)__dest + 0x14e) = uVar1; + *(undefined2 *)((int)__dest + 0x14c) = 0; + memcpy((void *)((int)__dest + 0xfc),__src,0x22); + *(undefined *)((int)__dest + 0x150) = 1; + if (bssid == (mac_addr *)0x0) { + bssid = &mac_addr_bcst; + } + memcpy((void *)((int)__dest + 0x140),bssid,6); + uVar3 = me_env.chan._252_2_; + if (chan_1 == (scan_chan_tag *)0x0) { + _chan_cnt = 0x4201b004; + *(undefined *)((int)__dest + 0x14f) = 0; + puVar5 = &local_2c; + local_2c = uVar3; + piVar6 = (int *)chan_cnt; + do { + iVar4 = 0; + while (iVar4 < (int)(uint)*(byte *)puVar5) { + __src_00 = (void *)(iVar4 * 6 + *piVar6); + if ((*(byte *)((int)__src_00 + 3) & 2) == 0) { + bVar2 = *(byte *)((int)__dest + 0x14f); + *(char *)((int)__dest + 0x14f) = bVar2 + 1; + memcpy((void *)((uint)bVar2 * 6 + (int)__dest),__src_00,6); + } + iVar4 = iVar4 + 1; + } + puVar5 = (undefined2 *)((int)puVar5 + 1); + piVar6 = piVar6 + 1; + } while (puVar5 != &uStack42); + } + else { + memcpy(__dest,chan_1,6); + *(undefined *)((int)__dest + 0x14f) = 1; + } + ke_msg_send(__dest); + ke_state_set(6,1); + return; +} + + + +void sm_join_bss(mac_addr *bssid,scan_chan_tag *chan,_Bool passive) + +{ + sm_connect_req *__src; + void *__dest; + undefined3 in_register_00002031; + + __src = sm_env.connect_param; + __dest = ke_msg_alloc(0x1002,4,6,0x154); + memcpy(__dest,chan,6); + *(undefined *)((int)__dest + 0x14f) = 1; + memcpy((void *)((int)__dest + 0xfc),__src,0x22); + *(undefined *)((int)__dest + 0x150) = 1; + *(undefined2 *)((int)__dest + 0x14c) = 0; + *(undefined4 *)((int)__dest + 0x148) = 0; + *(uint8_t *)((int)__dest + 0x14e) = __src->vif_idx; + memcpy((void *)((int)__dest + 0x140),bssid,6); + if (CONCAT31(in_register_00002031,passive) != 0) { + *(byte *)((int)__dest + 3) = *(byte *)((int)__dest + 3) | 1; + } + sm_env.join_passive = passive; + ke_msg_send(__dest); + ke_state_set(6,2); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +uint8_t sm_add_chan_ctx(uint8_t *p_chan_idx) + +{ + uint8_t uVar1; + scan_chan_tag *psVar2; + uint uVar3; + uint8_t uStack28; + uint8_t uStack27; + uint16_t uStack26; + mm_chan_ctxt_add_req req; + + uVar3 = (uint)(sm_env.connect_param)->vif_idx; + psVar2 = vif_info_tab[uVar3].bss_info.chan; + uStack27 = vif_info_tab[uVar3].bss_info.phy_bw; + uStack28 = psVar2->band; + uStack26 = psVar2->freq; + req._0_4_ = *(undefined4 *)&vif_info_tab[uVar3].bss_info.center_freq1; + req.center1_freq._0_1_ = psVar2->tx_power; + uVar1 = chan_ctxt_add((mm_chan_ctxt_add_req *)&uStack28,p_chan_idx); + return uVar1; +} + + + +void sm_send_next_bss_param(void) + +{ + co_list_hdr *pcVar1; + + pcVar1 = co_list_pop_front(&sm_env.bss_config); + if (pcVar1 == (co_list_hdr *)0x0) { + assert_err("msg != NULL","module",0x1a0); + } + ke_msg_send(pcVar1 + 3); + return; +} + + + +void sm_set_bss_param(void) + +{ + sm_connect_req *psVar1; + vif_info_tag *pvVar2; + uint16_t uVar3; + undefined *puVar4; + void *__dest; + undefined4 *puVar5; + uint16_t *puVar6; + undefined *puVar7; + undefined2 extraout_var; + uint32_t *puVar8; + bool bVar9; + uint32_t uVar10; + uint uVar11; + int iVar12; + + psVar1 = sm_env.connect_param; + uVar11 = (uint)(sm_env.connect_param)->vif_idx; + puVar4 = (undefined *)ke_msg_alloc(0x1413,5,6,2); + __dest = ke_msg_alloc(0x18,0,6,7); + puVar5 = (undefined4 *)ke_msg_alloc(0x16,0,6,8); + puVar6 = (uint16_t *)ke_msg_alloc(0x14,0,6,4); + puVar7 = (undefined *)ke_msg_alloc(0x1411,5,6,2); + co_list_init(&sm_env.bss_config); + *puVar4 = 1; + puVar4[1] = psVar1->vif_idx; + co_list_push_back(&sm_env.bss_config,(co_list_hdr *)(puVar4 + -0xc)); + pvVar2 = vif_info_tab + uVar11; + memcpy(__dest,&vif_info_tab[uVar11].bss_info.bssid,6); + *(uint8_t *)((int)__dest + 6) = psVar1->vif_idx; + co_list_push_back(&sm_env.bss_config,(co_list_hdr *)((int)__dest + -0xc)); + *(uint8_t *)((int)puVar5 + 5) = (vif_info_tab[uVar11].bss_info.chan)->band; + uVar3 = me_legacy_rate_bitfield_build(&vif_info_tab[uVar11].bss_info.rate_set,true); + *puVar5 = CONCAT22(extraout_var,uVar3); + *(uint8_t *)(puVar5 + 1) = psVar1->vif_idx; + co_list_push_back(&sm_env.bss_config,(co_list_hdr *)(puVar5 + -3)); + *puVar6 = vif_info_tab[uVar11].bss_info.beacon_period; + iVar12 = 0; + *(uint8_t *)(puVar6 + 1) = psVar1->vif_idx; + co_list_push_back(&sm_env.bss_config,(co_list_hdr *)(puVar6 + -6)); + do { + puVar8 = (uint32_t *)ke_msg_alloc(0x1a,0,6,8); + uVar10 = (pvVar2->bss_info).edca_param.ac_param[0]; + *(undefined *)((int)puVar8 + 5) = (char)iVar12; + *puVar8 = uVar10; + *(uint8_t *)((int)puVar8 + 6) = psVar1->vif_idx; + bVar9 = false; + if ((ps_env.uapsd_timeout != 0) && + ((char)vif_info_tab[uVar11].bss_info.edca_param.qos_info < '\0')) { + bVar9 = (mac_ac2uapsd[iVar12] & psVar1->uapsd_queues) != 0; + } + *(bool *)(puVar8 + 1) = bVar9; + iVar12 = iVar12 + 1; + co_list_push_back(&sm_env.bss_config,(co_list_hdr *)(puVar8 + -3)); + pvVar2 = (vif_info_tag *)&pvVar2->prevent_sleep; + } while (iVar12 != 4); + *puVar7 = 1; + puVar7[1] = psVar1->vif_idx; + co_list_push_back(&sm_env.bss_config,(co_list_hdr *)(puVar7 + -0xc)); + sm_send_next_bss_param(); + ke_state_set(6,4); + return; +} + + + +void sm_disconnect_process(vif_info_tag *vif,uint16_t reason) + +{ + uint16_t *puVar1; + + puVar1 = (uint16_t *)ke_msg_alloc(0x1805,0xd,6,4); + sm_delete_resources(vif); + *puVar1 = reason; + *(uint8_t *)(puVar1 + 1) = vif->index; + if (sm_env.ft_over_ds != false) { + *(undefined *)((int)puVar1 + 3) = 1; + } + ke_msg_send(puVar1); + return; +} + + + +void sm_deauth_cfm(void *env,uint32_t status) + +{ + sm_disconnect_process((vif_info_tag *)env,0); + return; +} + + + +void sm_disconnect(uint8_t vif_index,uint16_t reason_code) + +{ + byte bVar1; + _Bool _Var2; + uint16_t uVar3; + undefined3 in_register_00002029; + int iVar4; + txl_frame_desc_tag *frame; + undefined2 extraout_var_00; + undefined3 extraout_var; + vif_info_tag *vif; + tx_hw_desc *ptVar5; + txl_buffer_tag *ptVar6; + + iVar4 = CONCAT31(in_register_00002029,vif_index); + vif = vif_info_tab + iVar4; + if ((vif_info_tab[iVar4].type == '\0') && (vif_info_tab[iVar4].active != false)) { + bVar1 = vif_info_tab[iVar4].u[4]; + ke_state_set(6,8); + frame = txl_frame_get((uint)((vif_info_tab[iVar4].bss_info.chan)->band != '\0'),0x100); + if (frame != (txl_frame_desc_tag *)0x0) { + tpc_update_frame_tx_power(vif,frame); + ptVar6 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar6[1].length = 0xc0; + *(undefined *)((int)&ptVar6[1].length + 1) = 0; + *(undefined *)((int)&ptVar6[1].length + 2) = 0; + *(undefined *)((int)&ptVar6[1].length + 3) = 0; + memcpy(&ptVar6[1].lenheader,&sta_info_tab[bVar1].mac_addr,6); + memcpy((void *)((int)&ptVar6[1].lenpad + 2),&vif_info_tab[iVar4].mac_addr,6); + memcpy(&ptVar6[1].next,&sta_info_tab[bVar1].mac_addr,6); + uVar3 = txl_get_seq_ctrl(); + *(undefined *)((int)&ptVar6[1].txdesc + 2) = (char)uVar3; + *(undefined *)((int)&ptVar6[1].txdesc + 3) = (char)(uVar3 >> 8); + (frame->cfm).cfm_func = sm_deauth_cfm; + *(vif_info_tag **)&(frame->cfm).env = vif; + (frame->txdesc).host.vif_idx = vif_index; + (frame->txdesc).host.staid = vif_info_tab[iVar4].u[4]; + uVar3 = me_build_deauthenticate((uint32_t)ptVar6[1].dma_desc,reason_code); + ptVar5 = (frame->txdesc).lmac.hw_desc; + (ptVar5->thd).frmlen = CONCAT22(extraout_var_00,uVar3) + 0x1c; + (ptVar5->thd).field_5 = (ptVar5->thd).field_4 + 0x17 + CONCAT22(extraout_var_00,uVar3); + _Var2 = txl_frame_push(frame,'\x03'); + if (CONCAT31(extraout_var,_Var2) != 0) { + return; + } + vif = (vif_info_tag *)(frame->cfm).env; + } + sm_disconnect_process(vif,0); + return; + } + return; +} + + + +void sm_connect_ind(uint16_t status) + +{ + sm_connect_req *ssid; + sm_connect_ind *psVar1; + int index; + undefined2 in_register_0000202a; + uint8_t uVar2; + uint uVar3; + chan_ctxt_tag *pcVar4; + uint uVar5; + + index = sm_env.exist_ssid_idx; + psVar1 = sm_env.connect_ind; + ssid = sm_env.connect_param; + uVar5 = (uint)(sm_env.connect_param)->vif_idx; + (sm_env.connect_ind)->vif_idx = (sm_env.connect_param)->vif_idx; + memcpy(&psVar1->bssid,&vif_info_tab[uVar5].bss_info.bssid,6); + psVar1->ap_idx = vif_info_tab[uVar5].u[4]; + printf("ind ix %p, chan_ctxt is %p\r\n",psVar1,vif_info_tab[uVar5].chan_ctxt); + pcVar4 = vif_info_tab[uVar5].chan_ctxt; + psVar1->ch_idx = '\0'; + if (pcVar4 == (chan_ctxt_tag *)0x0) { + psVar1->band = '\0'; + psVar1->center_freq = 0; + psVar1->center_freq1 = 0; + psVar1->center_freq2 = 0; + psVar1->width = '\0'; + } + else { + psVar1->band = ((vif_info_tab[uVar5].chan_ctxt)->channel).band; + psVar1->center_freq = ((vif_info_tab[uVar5].chan_ctxt)->channel).prim20_freq; + psVar1->center_freq1 = (uint)((vif_info_tab[uVar5].chan_ctxt)->channel).center1_freq; + psVar1->center_freq2 = (uint)((vif_info_tab[uVar5].chan_ctxt)->channel).center2_freq; + psVar1->width = ((vif_info_tab[uVar5].chan_ctxt)->channel).type; + } + uVar2 = '\0'; + uVar3 = vif_info_tab[uVar5].bss_info.valid_flags & 1; + psVar1->qos = SUB41(uVar3,0); + if (uVar3 != 0) { + uVar2 = vif_info_tab[uVar5].bss_info.edca_param.acm; + } + psVar1->acm = uVar2; + psVar1->roamed = false; + if (CONCAT22(in_register_0000202a,status) == 0) { + ke_state_set(6,0); + } + else { + ke_state_set(6,8); + printf("connect failure, ssid = %s, index = %d\r\n",(ssid->ssid).array,index); + if (-1 < index) { + printf("from sm_connect_ind to scanu_rm_exist_ssid\r\n"); + scanu_rm_exist_ssid((mac_ssid *)ssid,index); + sm_env.exist_ssid_idx = -1; + } + sm_delete_resources(vif_info_tab + uVar5); + } + ke_msg_free(sm_env.connect_param[-1].phrase_pmk + 0x37); + sm_env.connect_param = (sm_connect_req *)0x0; + sm_env.ft_over_ds = false; + psVar1->status_code = status; + ke_msg_send(psVar1); + sm_env.connect_ind = (sm_connect_ind *)0x0; + return; +} + + + +void sm_supplicant_deauth_cfm(void *env,uint32_t status) + +{ + if (-1 < (int)(status << 8)) { + printf("sm deauth frame transmit failure\r\n"); + } + sm_connect_ind(8); + return; +} + + + +void sm_auth_send(uint16_t auth_seq,uint32_t *challenge) + +{ + byte bVar1; + sm_connect_req *psVar2; + txl_buffer_tag *ptVar3; + uint16_t uVar4; + undefined2 in_register_0000202a; + txl_frame_desc_tag *frame; + undefined2 extraout_var; + tx_hw_desc *ptVar5; + uint uVar6; + int iVar7; + + psVar2 = sm_env.connect_param; + uVar6 = (uint)(sm_env.connect_param)->vif_idx; + bVar1 = vif_info_tab[uVar6].u[4]; + frame = txl_frame_get((uint)((vif_info_tab[uVar6].bss_info.chan)->band != '\0'),0x100); + if (frame != (txl_frame_desc_tag *)0x0) { + tpc_update_frame_tx_power(vif_info_tab + uVar6,frame); + ptVar3 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar3[1].length = 0xb0; + *(undefined *)((int)&ptVar3[1].length + 1) = 0; + *(undefined *)((int)&ptVar3[1].length + 2) = 0; + *(undefined *)((int)&ptVar3[1].length + 3) = 0; + memcpy(&ptVar3[1].lenheader,&sta_info_tab[bVar1].mac_addr,6); + memcpy((void *)((int)&ptVar3[1].lenpad + 2),&vif_info_tab[uVar6].mac_addr,6); + memcpy(&ptVar3[1].next,&sta_info_tab[bVar1].mac_addr,6); + uVar4 = txl_get_seq_ctrl(); + *(undefined *)((int)&ptVar3[1].txdesc + 2) = (char)uVar4; + *(undefined *)((int)&ptVar3[1].txdesc + 3) = (char)(uVar4 >> 8); + (frame->txdesc).host.vif_idx = vif_info_tab[uVar6].index; + bVar1 = vif_info_tab[uVar6].u[4]; + (frame->txdesc).umac.head_len = '\0'; + (frame->txdesc).umac.tail_len = '\0'; + (frame->txdesc).host.staid = bVar1; + iVar7 = 0x18; + if ((psVar2->auth_type == '\x01') && (CONCAT22(in_register_0000202a,auth_seq) == 3)) { + txu_cntrl_protect_mgmt_frame((txdesc *)frame,(uint32_t)(ptVar3 + 1),0x18); + iVar7 = (uint)(frame->txdesc).umac.head_len + 0x18; + } + uVar4 = me_build_authenticate + ((int)&ptVar3[1].length + iVar7,(ushort)psVar2->auth_type,auth_seq,0,challenge + ); + bVar1 = (frame->txdesc).umac.tail_len; + ptVar5 = (frame->txdesc).lmac.hw_desc; + *(txl_frame_desc_tag **)&(frame->cfm).env = frame; + iVar7 = CONCAT22(extraout_var,uVar4) + (uint)bVar1 + iVar7; + (frame->cfm).cfm_func = sm_frame_tx_cfm_handler; + (ptVar5->thd).frmlen = iVar7 + 4; + (ptVar5->thd).field_5 = (ptVar5->thd).field_4 + -1 + iVar7; + txl_frame_push(frame,'\x03'); + ke_timer_set(0x1806,6,0x32000); + ke_state_set(6,5); + return; + } + sm_connect_ind(1); + return; +} + + + +// WARNING: Variable defined which should be unmapped: ie_addr +// WARNING: Could not reconcile some variable overlaps + +void sm_assoc_req_send(void) + +{ + byte bVar1; + sm_connect_req *con_par; + sm_connect_ind *psVar2; + txl_buffer_tag *ptVar3; + uint16_t uVar4; + txl_frame_desc_tag *frame; + undefined2 extraout_var; + tx_hw_desc *ptVar5; + _Bool _Var6; + sm_connect_ind *psVar7; + uint uVar8; + mac_addr *old_ap_addr_ptr; + uint16_t uStack54; + uint16_t ie_len; + uint32_t uStack52; + uint32_t ie_addr; + + con_par = sm_env.connect_param; + uVar8 = (uint)(sm_env.connect_param)->vif_idx; + bVar1 = vif_info_tab[uVar8].u[4]; + frame = txl_frame_get((uint)((vif_info_tab[uVar8].bss_info.chan)->band != '\0'),0x100); + psVar2 = sm_env.connect_ind; + if (frame == (txl_frame_desc_tag *)0x0) { + sm_connect_ind(4); + } + else { + tpc_update_frame_tx_power(vif_info_tab + uVar8,frame); + ptVar3 = (frame->txdesc).lmac.buffer; + old_ap_addr_ptr = (mac_addr *)0x0; + _Var6 = sm_env.ft_over_ds; + if (sm_env.ft_over_ds != false) { + _Var6 = true; + old_ap_addr_ptr = &sm_env.ft_old_bssid; + } + *(_Bool *)&ptVar3[1].length = _Var6; + *(undefined *)((int)&ptVar3[1].length + 1) = 0; + *(undefined *)((int)&ptVar3[1].length + 2) = 0; + *(undefined *)((int)&ptVar3[1].length + 3) = 0; + memcpy(&ptVar3[1].lenheader,&sta_info_tab[bVar1].mac_addr,6); + memcpy((void *)((int)&ptVar3[1].lenpad + 2),&vif_info_tab[uVar8].mac_addr,6); + memcpy(&ptVar3[1].next,&sta_info_tab[bVar1].mac_addr,6); + uVar4 = txl_get_seq_ctrl(); + *(undefined *)((int)&ptVar3[1].txdesc + 2) = (char)uVar4; + *(undefined *)((int)&ptVar3[1].txdesc + 3) = (char)(uVar4 >> 8); + uVar4 = me_build_associate_req + ((uint32_t)ptVar3[1].dma_desc,&vif_info_tab[uVar8].bss_info,old_ap_addr_ptr, + vif_info_tab[uVar8].index,(uint32_t *)&stack0xffffffcc,&uStack54,con_par); + ptVar5 = (frame->txdesc).lmac.hw_desc; + (frame->txdesc).host.vif_idx = vif_info_tab[uVar8].index; + bVar1 = vif_info_tab[uVar8].u[4]; + *(txl_frame_desc_tag **)&(frame->cfm).env = frame; + (frame->txdesc).host.staid = bVar1; + (frame->cfm).cfm_func = sm_frame_tx_cfm_handler; + (ptVar5->thd).field_5 = (ptVar5->thd).field_4 + 0x17 + CONCAT22(extraout_var,uVar4); + (ptVar5->thd).frmlen = CONCAT22(extraout_var,uVar4) + 0x1c; + psVar7 = psVar2; + while (psVar7 != (sm_connect_ind *)((int)&psVar2->status_code + (uint)uStack54)) { + *(undefined *)psVar7->assoc_ie_buf = *(undefined *)((uStack52 - (int)psVar2) + (int)psVar7); + psVar7 = (sm_connect_ind *)((int)&psVar7->status_code + 1); + } + psVar2->assoc_req_ie_len = uStack54; + txl_frame_push(frame,'\x03'); + ke_timer_set(0x1806,6,0x32000); + ke_state_set(6,6); + } + return; +} + + + +void sm_assoc_done(uint16_t aid) + +{ + sm_connect_req *psVar1; + uint16_t *puVar2; + + psVar1 = sm_env.connect_param; + puVar2 = (uint16_t *)ke_msg_alloc(0x1e,0,6,4); + *puVar2 = aid; + *(undefined *)(puVar2 + 1) = 1; + *(uint8_t *)((int)puVar2 + 3) = psVar1->vif_idx; + ke_msg_send(); + ke_state_set(6,7); + return; +} + + + +void sm_auth_handler(rxu_mgt_ind *param) + +{ + uint16_t auth_seq; + uint32_t *challenge; + + ke_timer_clear(0x1806,6); + if (param[1].center_freq != 0) { + if (((sm_env.connect_param)->auth_type != '\x01') || + ((sm_env.connect_param)->is_supplicant_enabled == false)) { + printf("Authentication failure, Wlan802.11 status code = %d\r\n"); + sm_connect_ind(2); + return; + } + (sm_env.connect_param)->auth_type = '\0'; + challenge = (uint32_t *)0x0; + auth_seq = 1; +LAB_2300c2aa: + sm_auth_send(auth_seq,challenge); + return; + } + if (param[1].length != 0) { + if (param[1].length != 1) { + return; + } + if (param[1].framectrl != 4) { + if (param[1].framectrl != 2) { + sm_connect_ind(3); + assert_warn("0","module",0x374); + return; + } + if (param->length < 0x88) { + printf("Drop illegal auth packet length %u\r\n"); + return; + } + challenge = (uint32_t *)¶m[1].inst_nbr; + auth_seq = 3; + goto LAB_2300c2aa; + } + } + sm_assoc_req_send(); + return; +} + + + +void sm_assoc_rsp_handler(rxu_mgt_ind *param) + +{ + uint8_t *puVar1; + byte bVar2; + ushort uVar3; + int iVar4; + sm_connect_ind *psVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint8_t uStack50; + int8_t aiStack49 [3]; + uint8_t idx; + int8_t pwr; + + psVar5 = sm_env.connect_ind; + uVar8 = (uint)(sm_env.connect_param)->vif_idx; + uStack50 = '\0'; + bVar2 = vif_info_tab[uVar8].u[4]; + ke_timer_clear(0x1806,6); + uVar6 = (uint)param[1].framectrl; + if (param[1].framectrl == 0) { + if (5 < param->length) { + uVar6 = (uint)param->length - 6 & 0xffff; + } + sm_assoc_done((ushort)(((uint)param[1].center_freq << 0x12) >> 0x12)); + me_init_rate(sta_info_tab + bVar2); + aiStack49[0] = (vif_info_tab[uVar8].bss_info.chan)->tx_power - + vif_info_tab[uVar8].bss_info.power_constraint; + tpc_update_vif_tx_power(vif_info_tab + uVar8,aiStack49,&uStack50); + uVar3 = psVar5->assoc_req_ie_len; + uVar7 = 0; + while (uVar6 != uVar7) { + puVar1 = ¶m[1].band + uVar7; + iVar4 = uVar7 + uVar3; + uVar7 = uVar7 + 1; + *(uint8_t *)((int)psVar5->assoc_ie_buf + iVar4) = *puVar1; + } + psVar5->assoc_rsp_ie_len = (uint16_t)uVar6; + if ((*(uint *)&vif_info_tab[uVar8].bss_info.is_supplicant_enabled & 0x12a00) != 0) { + supplicantInitSession + (&sta_conn_info,(CHAR *)vif_info_tab[uVar8].bss_info.ssid.array, + (ushort)vif_info_tab[uVar8].bss_info.ssid.length, + (CHAR *)&vif_info_tab[uVar8].bss_info.bssid,(UINT8 *)&vif_info_tab[uVar8].mac_addr) + ; + } + } + else { + printf("Association failure, Wlan802.11 status code = %d\r\n",uVar6); + sm_connect_ind(5); + } + return; +} + + + +int sm_deauth_handler(rxu_mgt_ind *param) + +{ + byte bVar1; + ushort reason; + sm_connect_req *psVar2; + ke_state_t kVar3; + undefined2 extraout_var; + undefined2 extraout_var_00; + + psVar2 = sm_env.connect_param; + bVar1 = param->inst_nbr; + kVar3 = ke_state_get(6); + if (CONCAT22(extraout_var,kVar3) != 8) { + kVar3 = ke_state_get(6); + if (CONCAT22(extraout_var_00,kVar3) == 0) { + if (vif_info_tab[bVar1].active == false) { + return 0; + } + reason = param[1].length; + ke_state_set(6,8); + printf("Deauth by AP, Wlan802.11 reason code = %d\r\n",(uint)reason); + sm_disconnect_process(vif_info_tab + bVar1,reason); + return 0; + } + if (psVar2->vif_idx == param->inst_nbr) { + sm_connect_ind(6); + return 0; + } + } + return 2; +} + + + +void sm_handle_supplicant_result(uint8_t sta_id,uint16_t reason_code) + +{ + byte bVar1; + txl_buffer_tag *ptVar2; + _Bool _Var3; + uint16_t status; + undefined3 in_register_00002029; + int iVar4; + txl_frame_desc_tag *frame; + undefined2 extraout_var_00; + undefined3 extraout_var; + undefined2 in_register_0000202e; + tx_hw_desc *ptVar5; + uint uVar6; + + iVar4 = CONCAT31(in_register_00002029,sta_id); + bVar1 = sta_info_tab[iVar4].inst_nbr; + uVar6 = (uint)bVar1; + if (CONCAT22(in_register_0000202e,reason_code) == 0) { + sta_info_tab[iVar4].ctrl_port_state = '\x02'; + status = 0; + } + else { + if (CONCAT22(in_register_0000202e,reason_code) == 0xf) { + printf( + "4-way handshake timeout failure, wlan 802.11 reason code = %u, try to transmit deauth frame\r\n" + ); + } + frame = txl_frame_get((uint)((vif_info_tab[uVar6].bss_info.chan)->band != '\0'),0x100); + if (frame == (txl_frame_desc_tag *)0x0) { + status = 10; + } + else { + tpc_update_frame_tx_power(vif_info_tab + uVar6,frame); + ptVar2 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar2[1].length = 0xc0; + *(undefined *)((int)&ptVar2[1].length + 1) = 0; + *(undefined *)((int)&ptVar2[1].length + 2) = 0; + *(undefined *)((int)&ptVar2[1].length + 3) = 0; + memcpy(&ptVar2[1].lenheader,&sta_info_tab[iVar4].mac_addr,6); + memcpy((void *)((int)&ptVar2[1].lenpad + 2),&vif_info_tab[uVar6].mac_addr,6); + memcpy(&ptVar2[1].next,&sta_info_tab[iVar4].mac_addr,6); + status = txl_get_seq_ctrl(); + *(undefined *)((int)&ptVar2[1].txdesc + 2) = (char)status; + *(undefined *)((int)&ptVar2[1].txdesc + 3) = (char)(status >> 8); + (frame->cfm).cfm_func = sm_supplicant_deauth_cfm; + *(vif_info_tag **)&(frame->cfm).env = vif_info_tab + uVar6; + (frame->txdesc).host.vif_idx = bVar1; + (frame->txdesc).host.staid = sta_id; + status = me_build_deauthenticate((uint32_t)ptVar2[1].dma_desc,reason_code); + ptVar5 = (frame->txdesc).lmac.hw_desc; + (ptVar5->thd).frmlen = CONCAT22(extraout_var_00,status) + 0x1c; + (ptVar5->thd).field_5 = (ptVar5->thd).field_4 + 0x17 + CONCAT22(extraout_var_00,status); + _Var3 = txl_frame_push(frame,'\x03'); + if (CONCAT31(extraout_var,_Var3) != 0) { + return; + } + status = 9; + } + } + sm_connect_ind(status); + return; +} + + + +undefined2 * txu_cntrl_sec_hdr_append(int param_1,undefined2 *param_2,int param_3) + +{ + uint8_t uVar1; + ushort uVar2; + undefined2 *puVar3; + int iVar4; + key_info_tag *pkVar5; + + pkVar5 = *sta_info_tab[*(byte *)(param_1 + 0x30)].sta_sec_info.cur_key; + if (pkVar5 == (key_info_tag *)0x0) { + return param_2; + } + if (((vif_info_tab[*(byte *)(param_1 + 0x2f)].flags & 2) != 0) && + ((uint)sta_info_tab[*(byte *)(param_1 + 0x30)].ctrl_port_ethertype == + (((uint)*(ushort *)(param_1 + 0x20) & 0xff) << 8 | (uint)(*(ushort *)(param_1 + 0x20) >> 8)))) + { + return param_2; + } + uVar1 = pkVar5->cipher; + if (uVar1 == '\x01') { + param_2[-4] = *(ushort *)(param_1 + 0x22) & 0x7f00 | 0x2000 | *(ushort *)(param_1 + 0x22) >> 8; + uVar2 = (ushort)*(byte *)(param_1 + 0x22) | (ushort)pkVar5->key_idx << 0xe; +LAB_2300c744: + puVar3 = param_2 + -4; + param_2[-3] = uVar2 | 0x2000; + param_2[-2] = *(undefined2 *)(param_1 + 0x24); + param_2[-1] = *(undefined2 *)(param_1 + 0x26); + } + else { + if (uVar1 != '\0') { + if (uVar1 == '\x02') { + param_2[-4] = *(undefined2 *)(param_1 + 0x22); + uVar2 = (ushort)pkVar5->key_idx << 0xe; + goto LAB_2300c744; + } + puVar3 = param_2; + if (uVar1 != '\x03') goto LAB_2300c6f6; + } + puVar3 = param_2 + -2; + *puVar3 = *(undefined2 *)(param_1 + 0x22); + param_2[-1] = (ushort)pkVar5->key_idx << 0xe | *(ushort *)(param_1 + 0x24); + } +LAB_2300c6f6: + if (param_3 == 0) { + iVar4 = *(int *)(param_1 + 0x68) + 0xf0; + } + else { + iVar4 = *(int *)(param_1 + 0x54); + } + *(uint *)(iVar4 + 0xc) = (uint)pkVar5->hw_key_idx | *(uint *)(iVar4 + 0xc) & 0xffc00; + return puVar3; +} + + + +int txu_cntrl_sechdr_len_compute(txdesc *txdesc,int *tail_len) + +{ + byte bVar1; + uint8_t uVar2; + ushort uVar3; + int iVar4; + int iVar5; + uint uVar6; + uint uVar7; + key_info_tag *pkVar8; + + bVar1 = (txdesc->host).vif_idx; + pkVar8 = *sta_info_tab[(txdesc->host).staid].sta_sec_info.cur_key; + *tail_len = 0; + if (pkVar8 == (key_info_tag *)0x0) { + return 0; + } + if (((vif_info_tab[bVar1].flags & 2) != 0) && + (uVar3 = (txdesc->host).ethertype, + (uint)sta_info_tab[(txdesc->host).staid].ctrl_port_ethertype == + (((uint)uVar3 & 0xff) << 8 | (uint)(uVar3 >> 8)))) { + return 0; + } + uVar2 = pkVar8->cipher; + if (uVar2 == '\x01') { + iVar4 = 0xc; +LAB_2300c83a: + *tail_len = iVar4; + if (((txdesc->host).flags & 1) == 0) { + uVar7 = *(uint *)&pkVar8->tx_pn; + iVar4 = *(int *)((int)&pkVar8->tx_pn + 4); + uVar6 = uVar7 + 1; + *(uint *)&pkVar8->tx_pn = uVar6; + *(int *)((int)&pkVar8->tx_pn + 4) = (uint)(uVar6 < uVar7) + iVar4; + memcpy((txdesc->host).pn,&pkVar8->tx_pn,6); + } + iVar4 = 8; + } + else { + if (uVar2 != '\0') { + if (uVar2 == '\x02') { + iVar4 = 8; + goto LAB_2300c83a; + } + if (uVar2 != '\x03') { + return 0; + } + } + *tail_len = 4; + iVar4 = 4; + if (((txdesc->host).flags & 1) == 0) { + uVar7 = *(uint *)&pkVar8->tx_pn; + iVar5 = *(int *)((int)&pkVar8->tx_pn + 4); + uVar6 = uVar7 + 1; + *(uint *)&pkVar8->tx_pn = uVar6; + *(int *)((int)&pkVar8->tx_pn + 4) = (uint)(uVar6 < uVar7) + iVar5; + memcpy((txdesc->host).pn,&pkVar8->tx_pn,4); + } + } + return iVar4; +} + + + +void txu_cntrl_frame_build(txdesc *txdesc,uint32_t buf) + +{ + uint8_t uVar1; + byte bVar2; + int iVar3; + ushort *puVar4; + ushort *puVar5; + uint uVar6; + ushort uVar7; + ushort uVar8; + ushort *puVar9; + uint uVar10; + key_info_tag *pkVar11; + + uVar8 = (txdesc->host).ethertype; + if (0x5ff < (((uint)uVar8 & 0xff) << 8 | (uint)(uVar8 >> 8))) { + *(undefined2 *)(buf - 8) = 0xaaaa; + *(undefined2 *)(buf - 6) = 3; + *(undefined2 *)(buf - 4) = 0; + *(uint16_t *)(buf - 2) = (txdesc->host).ethertype; + } + iVar3 = txu_cntrl_sec_hdr_append(txdesc,1); + uVar6 = (uint)(txdesc->host).staid; + uVar1 = (txdesc->host).tid; + uVar10 = (uint)(txdesc->host).vif_idx; + pkVar11 = *sta_info_tab[uVar6].sta_sec_info.cur_key; + puVar9 = (ushort *)(iVar3 + -0x1a); + if (uVar1 == -1) { + puVar9 = (ushort *)(iVar3 + -0x18); + } + puVar4 = puVar9 + 0xc; + puVar5 = (ushort *)0x0; + if (((txdesc->host).flags & 0x100) != 0) { + puVar5 = puVar9 + -3; + puVar9 = puVar5; + } + if (uVar1 == -1) { + *(undefined *)puVar9 = 0; + *(undefined *)((int)puVar9 + 1) = 0; + *(undefined *)(puVar9 + 0xb) = 0; + *(undefined *)((int)puVar9 + 0x17) = 0; + } + else { + *(undefined *)puVar9 = 0x80; + *(undefined *)((int)puVar9 + 1) = 0; + *puVar4 = (ushort)(txdesc->host).tid; + iVar3 = (uint)(txdesc->host).sn << 0x14; + *(char *)(puVar9 + 0xb) = (char)((uint)iVar3 >> 0x10); + *(undefined *)((int)puVar9 + 0x17) = (char)((uint)iVar3 >> 0x18); + if (((txdesc->host).flags & 0x200) != 0) { + *puVar4 = *puVar4 | 0x10; + } + } + uVar7 = *puVar9; + *(byte *)puVar9 = (byte)uVar7 | 8; + *(undefined *)((int)puVar9 + 1) = (char)((uint)uVar7 >> 8); + uVar8 = (txdesc->host).flags; + if ((int)((uint)uVar8 << 0x14) < 0) { + uVar7 = uVar7 & 0xfcff | 8; +LAB_2300c97c: + *(char *)puVar9 = (char)uVar7; + *(undefined *)((int)puVar9 + 1) = (char)(uVar7 >> 8); + } + else { + if ((uVar8 & 0x100) != 0) { + uVar7 = uVar7 | 0x308; + goto LAB_2300c97c; + } + if (vif_info_tab[uVar10].type == '\0') { + uVar7 = uVar7 | 0x108; + goto LAB_2300c97c; + } + if (vif_info_tab[uVar10].type == '\x02') { + uVar7 = uVar7 | 0x208; + goto LAB_2300c97c; + } + } + if (((txdesc->host).flags & 4) != 0) { + uVar8 = *puVar9; + *(char *)puVar9 = (char)uVar8; + *(byte *)((int)puVar9 + 1) = (byte)((uint)uVar8 >> 8) | 0x20; + } + puVar9[5] = vif_info_tab[uVar10].mac_addr.array[0]; + puVar9[6] = vif_info_tab[uVar10].mac_addr.array[1]; + puVar9[7] = vif_info_tab[uVar10].mac_addr.array[2]; + bVar2 = *(byte *)((int)puVar9 + 1) & 3; + if (bVar2 == 1) { + puVar9[2] = sta_info_tab[uVar6].mac_addr.array[0]; + puVar9[3] = sta_info_tab[uVar6].mac_addr.array[1]; + puVar9[4] = sta_info_tab[uVar6].mac_addr.array[2]; + puVar9[8] = (txdesc->host).eth_dest_addr.array[0]; + puVar9[9] = (txdesc->host).eth_dest_addr.array[1]; + uVar8 = (txdesc->host).eth_dest_addr.array[2]; + } + else { + if (bVar2 == 2) { + puVar9[2] = (txdesc->host).eth_dest_addr.array[0]; + puVar9[3] = (txdesc->host).eth_dest_addr.array[1]; + puVar9[4] = (txdesc->host).eth_dest_addr.array[2]; + puVar9[8] = (txdesc->host).eth_src_addr.array[0]; + puVar9[9] = (txdesc->host).eth_src_addr.array[1]; + uVar8 = (txdesc->host).eth_src_addr.array[2]; + } + else { + if (bVar2 != 0) { + puVar5[2] = sta_info_tab[uVar6].mac_addr.array[0]; + puVar5[3] = sta_info_tab[uVar6].mac_addr.array[1]; + puVar5[4] = sta_info_tab[uVar6].mac_addr.array[2]; + puVar5[8] = (txdesc->host).eth_dest_addr.array[0]; + puVar5[9] = (txdesc->host).eth_dest_addr.array[1]; + puVar5[10] = (txdesc->host).eth_dest_addr.array[2]; + puVar5[0xc] = (txdesc->host).eth_src_addr.array[0]; + puVar5[0xd] = (txdesc->host).eth_src_addr.array[1]; + puVar5[0xe] = (txdesc->host).eth_src_addr.array[2]; + goto LAB_2300ca20; + } + puVar9[2] = (txdesc->host).eth_dest_addr.array[0]; + puVar9[3] = (txdesc->host).eth_dest_addr.array[1]; + puVar9[4] = (txdesc->host).eth_dest_addr.array[2]; + puVar9[8] = vif_info_tab[uVar10].bss_info.bssid.array[0]; + puVar9[9] = vif_info_tab[uVar10].bss_info.bssid.array[1]; + uVar8 = vif_info_tab[uVar10].bss_info.bssid.array[2]; + } + } + puVar9[10] = uVar8; +LAB_2300ca20: + if ((pkVar11 != (key_info_tag *)0x0) && + (((vif_info_tab[uVar10].flags & 2) == 0 || + (uVar8 = (txdesc->host).ethertype, + (uint)sta_info_tab[(txdesc->host).staid].ctrl_port_ethertype != + (((uint)uVar8 & 0xff) << 8 | (uint)(uVar8 >> 8)))))) { + uVar8 = *puVar9; + *(char *)puVar9 = (char)uVar8; + *(byte *)((int)puVar9 + 1) = (byte)((uint)uVar8 >> 8) | 0x40; + } + return; +} + + +/* +Unable to decompile 'txu_cntrl_push' +Cause: Exception while decompiling 2300cb86: Decompiler process died + +*/ + + +void txu_cntrl_tkip_mic_append(txdesc *txdesc,uint8_t ac) + +{ + uint8_t uVar1; + byte bVar2; + byte bVar3; + txl_buffer_tag *ptVar4; + uint32_t uVar5; + int iVar6; + key_info_tag *pkVar7; + int iVar8; + tx_pbd *ptVar9; + undefined *puVar10; + undefined *puVar11; + tx_pbd *ptVar12; + txl_buffer_tag *ptVar13; + undefined auStack48 [4]; + mic_calc mic; + + pkVar7 = *sta_info_tab[(txdesc->host).staid].sta_sec_info.cur_key; + if (pkVar7 != (key_info_tag *)0x0) { + uVar1 = pkVar7->cipher; + ptVar4 = (txdesc->lmac).buffer; + if (uVar1 != '\x01') { + if ((uVar1 == '\0') || (uVar1 == '\x03')) { + ptVar9 = &ptVar4->tbd; + do { + ptVar12 = ptVar9; + ptVar9 = (tx_pbd *)ptVar12->next; + } while (ptVar9 != (tx_pbd *)0x0); + *(tx_pbd **)&ptVar12->next = &ptVar4->tkip_mic_icv_pbd; + *(uint8_t **)&(ptVar4->tkip_mic_icv_pbd).datastartptr = ptVar4->tkip_mic_icv; + *(uint8_t **)&(ptVar4->tkip_mic_icv_pbd).dataendptr = ptVar4->tkip_mic_icv + 3; + (ptVar4->tkip_mic_icv_pbd).upatterntx = 0xcafefade; + (ptVar4->tkip_mic_icv_pbd).bufctrlinfo = 0; + (ptVar4->tkip_mic_icv_pbd).next = 0; + } + return; + } + ptVar9 = &ptVar4->tbd; + do { + ptVar12 = ptVar9; + ptVar9 = (tx_pbd *)ptVar12->next; + } while (ptVar9 != (tx_pbd *)0x0); + bVar2 = (txdesc->umac).head_len; + bVar3 = (txdesc->umac).hdr_len_802_2; + *(tx_pbd **)&ptVar12->next = &ptVar4->tkip_mic_icv_pbd; + *(uint8_t **)&(ptVar4->tkip_mic_icv_pbd).datastartptr = ptVar4->tkip_mic_icv; + *(uint8_t **)&(ptVar4->tkip_mic_icv_pbd).dataendptr = ptVar4->tkip_mic_icv + 0xb; + (ptVar4->tkip_mic_icv_pbd).upatterntx = 0xcafefade; + (ptVar4->tkip_mic_icv_pbd).bufctrlinfo = 0; + (ptVar4->tkip_mic_icv_pbd).next = 0; + ptVar13 = (txdesc->lmac).buffer; + me_mic_init((mic_calc *)auStack48,(uint32_t *)pkVar7->u,&(txdesc->host).eth_dest_addr, + &(txdesc->host).eth_src_addr,(txdesc->host).tid); + me_mic_calc((mic_calc *)auStack48,(int)ptVar4 + (uint)bVar2 + (0x14c - (uint)bVar3), + (uint)(txdesc->umac).hdr_len_802_2); + uVar5 = (ptVar13->tbd).next; + while (uVar5 != 0) { + iVar6 = *(int *)(uVar5 + 4); + if (iVar6 == 0) { + me_mic_end((mic_calc *)auStack48); + iVar8 = *(int *)(uVar5 + 8); + do { + puVar10 = auStack48 + iVar6; + puVar11 = (undefined *)(iVar8 + iVar6); + iVar6 = iVar6 + 1; + *puVar11 = *puVar10; + } while (iVar6 != 8); + return; + } + me_mic_calc((mic_calc *)auStack48,*(uint32_t *)(uVar5 + 8), + (*(int *)(uVar5 + 0xc) + 1) - *(uint32_t *)(uVar5 + 8)); + uVar5 = *(uint32_t *)(uVar5 + 4); + } + me_mic_end((mic_calc *)auStack48); + ebreak(); + } + return; +} + + + +void txu_cntrl_cfm(txdesc *txdesc) + +{ + ushort uVar1; + tx_cfm_tag *ptVar2; + uint32_t *puVar3; + + puVar3 = (uint32_t *)(txdesc->host).status_addr; + ptVar2 = ((txdesc->lmac).hw_desc)->cfm_ptr; + uVar1 = (txdesc->host).flags; + if ((uVar1 & 8) == 0) { + if ((uVar1 & 0x200) == 0) goto LAB_2300cefc; + } + else { + if (((uVar1 & 0x20) != 0) && (-1 < (int)(ptVar2->status << 8))) { + rxu_cntrl_get_pm(); + } + if (((txdesc->host).flags & 0x200) == 0) goto LAB_2300cefc; + if ((txdesc->host).staid == -1) { + assert_err("txdesc->host.staid != INVALID_STA_IDX","module",0x3a9); + } + txl_frame_send_qosnull_frame((txdesc->host).staid,0x17,(cfm_func_ptr *)0x0,(void *)0x0); + } + sta_info_tab[(txdesc->host).staid].ps_service_period = 0; +LAB_2300cefc: + ptVar2->status = ptVar2->status | 1; + *(undefined2 *)&ptVar2->credits = 0x101; + txdesc[-1].buf[0x6b] = 0; + *puVar3 = ptVar2->status; + return; +} + + + +void txu_cntrl_protect_mgmt_frame(txdesc *txdesc,uint32_t frame,uint16_t hdr_len) + +{ + byte bVar1; + ushort uVar2; + uint uVar3; + undefined2 in_register_00002032; + uint uStack20; + int tail_len; + + bVar1 = (txdesc->umac).head_len; + uVar3 = (uint)bVar1; + if (bVar1 == 0) { + uVar3 = txu_cntrl_sechdr_len_compute(txdesc,(int *)&uStack20); + (txdesc->umac).head_len = (uint8_t)uVar3; + (txdesc->umac).tail_len = (uint8_t)uStack20; + } + else { + uStack20 = (uint)(txdesc->umac).tail_len; + } + uVar2 = *(ushort *)frame; + *(undefined *)frame = *(undefined *)frame; + *(byte *)(frame + 1) = (byte)((uint)uVar2 >> 8) | 0x40; + txu_cntrl_sec_hdr_append(txdesc,CONCAT22(in_register_00002032,hdr_len) + frame + uVar3,0); + return; +} + + + +int _aid_list_delete(uint8_t *mac) + +{ + int iVar1; + int iVar2; + apm *paVar3; + + paVar3 = &apm_env; + iVar1 = 0; + do { + if (paVar3->aid_list[0].used != '\0') { + iVar2 = memcmp(paVar3->aid_list,mac,6); + if (iVar2 == 0) { + memset(paVar3->aid_list,0,6); + apm_env.aid_list[iVar1].used = '\0'; + return 0; + } + } + iVar1 = iVar1 + 1; + paVar3 = (apm *)((int)&(paVar3->bss_config).first + 3); + } while (iVar1 != 10); + return -1; +} + + + +void apm_sta_delete(uint8_t sta_idx,uint8_t *mac) + +{ + uint8_t *puVar1; + uint8_t *puVar2; + + puVar1 = (uint8_t *)ke_msg_alloc(0x1409,5,7,2); + puVar2 = (uint8_t *)ke_msg_alloc(0x1c09,0xd,7,1); + _aid_list_delete(mac); + mm_sec_machwkey_del(sta_idx + '\b'); + apm_env.assoc_sta_count = apm_env.assoc_sta_count + -1; + *puVar2 = sta_idx; + ke_msg_send(puVar2); + *puVar1 = sta_idx; + puVar1[1] = '\0'; + ke_msg_send(puVar1); + return; +} + + + +void apm_tx_cfm_handler(uint8_t *param_1,int param_2) + +{ + if (-1 < param_2 << 8) { + _aid_list_delete(param_1); + ke_msg_free(param_1 + -0xc); + printf("apm mlme assoc rsp send failed:%d,aid:%d\n",(uint)*(ushort *)(param_1 + 0x44)); + apm_env.assoc_sta_count = apm_env.assoc_sta_count + -1; + return; + } + if (*(short *)(param_1 + 0x44) != 0) { + ke_msg_send(); + return; + } + ke_msg_free(param_1 + -0xc); + return; +} + + + +void apm_init(void) + +{ + memset(&apm_env,0,0x60); + apm_env.aging_sta_idx = '\0'; + apm_env._22_2_ = 0xc00; + ke_state_set(7,0); + return; +} + + + +void apm_start_cfm(int param_1) + +{ + byte bVar1; + uint16_t uVar2; + apm_start_req *__src; + undefined *puVar3; + void *pvVar4; + uint uVar5; + int iVar6; + + __src = apm_env.param; + puVar3 = (undefined *)ke_msg_alloc(0x1c01,0xd,7,4); + if (param_1 == 0) { + uVar5 = (uint)__src->vif_idx; + pvVar4 = ke_msg_alloc(0x1e,0,7,4); + iVar6 = uVar5 + 10; + *(undefined *)((int)pvVar4 + 2) = 1; + *(uint8_t *)((int)pvVar4 + 3) = vif_info_tab[uVar5].index; + ke_msg_send(); + vif_info_tab[uVar5].flags = __src->flags; + uVar2 = __src->ctrl_port_ethertype; + vif_info_tab[uVar5].u[0x2ee] = 0; + *(uint16_t *)(vif_info_tab[uVar5].u + 0x2f0) = uVar2; + puVar3[2] = (vif_info_tab[uVar5].chan_ctxt)->idx; + puVar3[3] = __src->vif_idx + '\n'; + memcpy(&sta_info_tab[iVar6].info,__src,0xd); + sta_info_tab[iVar6].ctrl_port_state = '\x02'; + me_init_bcmc_rate(sta_info_tab + iVar6); + bVar1 = sta_info_tab[iVar6].pol_tbl.upd_field; + sta_info_tab[iVar6].mac_addr.array[0] = 1; + sta_info_tab[iVar6].pol_tbl.upd_field = bVar1 | 0x10; + sta_info_tab[iVar6].staid = __src->vif_idx + '\n'; + } + *puVar3 = (char)param_1; + puVar3[1] = __src->vif_idx; + ke_timer_set(0x1c0a,7,5000000); + ke_msg_send(puVar3); + ke_msg_free(__src[-1].phrase + 0x35); + apm_env.param = (apm_start_req *)0x0; + ke_state_set(7,0); + return; +} + + + +void apm_send_next_bss_param(void) + +{ + co_list_hdr *pcVar1; + + pcVar1 = co_list_pop_front(&apm_env.bss_config); + if (pcVar1 == (co_list_hdr *)0x0) { + assert_err("msg != NULL","module",0xbf); + } + ke_msg_send(pcVar1 + 3); + return; +} + + + +void apm_set_bss_param(void) + +{ + byte bVar1; + apm_start_req *rateset; + uint16_t uVar2; + undefined *puVar3; + void *__dest; + undefined4 *puVar4; + uint16_t *puVar5; + undefined *puVar6; + undefined2 extraout_var; + + rateset = apm_env.param; + bVar1 = (apm_env.param)->vif_idx; + puVar3 = (undefined *)ke_msg_alloc(0x1413,5,7,2); + __dest = ke_msg_alloc(0x18,0,7,7); + puVar4 = (undefined4 *)ke_msg_alloc(0x16,0,7,8); + puVar5 = (uint16_t *)ke_msg_alloc(0x14,0,7,4); + puVar6 = (undefined *)ke_msg_alloc(0x1411,5,7,2); + *puVar3 = 1; + puVar3[1] = vif_info_tab[bVar1].index; + co_list_push_back(&apm_env.bss_config,(co_list_hdr *)(puVar3 + -0xc)); + memcpy(__dest,&vif_info_tab[bVar1].mac_addr,6); + *(uint8_t *)((int)__dest + 6) = rateset->vif_idx; + co_list_push_back(&apm_env.bss_config,(co_list_hdr *)((int)__dest + -0xc)); + *(uint8_t *)((int)puVar4 + 5) = (rateset->chan).band; + uVar2 = me_legacy_rate_bitfield_build((mac_rateset *)rateset,true); + *puVar4 = CONCAT22(extraout_var,uVar2); + *(uint8_t *)(puVar4 + 1) = rateset->vif_idx; + co_list_push_back(&apm_env.bss_config,(co_list_hdr *)(puVar4 + -3)); + *puVar5 = rateset->bcn_int; + *(uint8_t *)(puVar5 + 1) = rateset->vif_idx; + co_list_push_back(&apm_env.bss_config,(co_list_hdr *)(puVar5 + -6)); + *puVar6 = 1; + puVar6[1] = rateset->vif_idx; + co_list_push_back(&apm_env.bss_config,(co_list_hdr *)(puVar6 + -0xc)); + apm_send_next_bss_param(); + ke_state_set(7,1); + return; +} + + + +void apm_stop(vif_info_tag *vif) + +{ + undefined *puVar1; + undefined *puVar2; + void *pvVar3; + + puVar1 = (undefined *)ke_msg_alloc(0x1413,5,7,2); + puVar2 = (undefined *)ke_msg_alloc(0x1411,5,7,2); + ke_timer_clear(0x1c0a,7); + *puVar1 = 0; + puVar1[1] = vif->index; + ke_msg_send(puVar1); + if (vif->active != false) { + pvVar3 = ke_msg_alloc(0x1e,0,7,4); + *(undefined *)((int)pvVar3 + 2) = 0; + *(uint8_t *)((int)pvVar3 + 3) = vif->index; + ke_msg_send(); + } + if (vif->chan_ctxt != (chan_ctxt_tag *)0x0) { + chan_ctxt_unlink(vif->index); + } + *puVar2 = 0; + puVar2[1] = vif->index; + ke_msg_send(puVar2); + return; +} + + + +_Bool apm_tx_int_ps_check(txdesc *txdesc) + +{ + byte bVar1; + undefined uVar2; + + if (vif_info_tab[(txdesc->host).vif_idx].type == '\x02') { + bVar1 = (txdesc->host).staid; + uVar2 = 1; + if (((bVar1 < 0xc) && (sta_info_tab[bVar1].ps_state == '\x01')) && + ((sta_info_tab[bVar1].ps_service_period & 3U) == 0)) { + (txdesc->host).flags = (txdesc->host).flags | 0x1000; + uVar2 = 0; + } + } + else { + uVar2 = 1; + } + return (_Bool)uVar2; +} + + + +void apm_tx_int_ps_postpone(txdesc *txdesc,sta_info_tag *sta) + +{ + byte bVar1; + sta_ps_traffic sVar2; + sta_ps_traffic sVar3; + uint16_t *puVar4; + + if ((int)((uint)(txdesc->host).flags << 0x13) < 0) { + bVar1 = (sta->info).uapsd_queues; + sVar2 = sta->traffic_avail; + if ((mac_ac2uapsd[(txdesc->host).tid] & bVar1) == 0) { + if ((sVar2 & PS_TRAFFIC_INT) != 0) { + return; + } + sVar3 = PS_TRAFFIC_INT; + } + else { + sVar3 = UAPSD_TRAFFIC_INT; + if ((sVar2 & UAPSD_TRAFFIC_INT) != 0) { + return; + } + } + sta->traffic_avail = sVar2 | sVar3; + if (((mac_ac2uapsd[(txdesc->host).tid] & bVar1) == 0) || (bVar1 == 0xf)) { + puVar4 = (uint16_t *)ke_msg_alloc(0x41,0,5,4); + *puVar4 = sta->aid; + *(uint8_t *)((int)puVar4 + 3) = sta->inst_nbr; + *(undefined *)(puVar4 + 1) = 1; + ke_msg_send(); + return; + } + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +txdesc * apm_tx_int_ps_get_postpone(vif_info_tag *vif,sta_info_tag *sta,int *stop) + +{ + uint8_t uVar1; + ushort uVar2; + co_list_hdr cVar3; + co_list_hdr element; + uint16_t *puVar4; + co_list_hdr *pcVar5; + uint uVar6; + int *piVar7; + sta_ps_traffic sVar8; + sta_ps_traffic sVar9; + co_list_hdr prev_element; + + sVar8 = vif->type; + if ((sVar8 == PS_TRAFFIC_INT) && (uVar6 = sta->ps_service_period, uVar6 != 0)) { + sVar9 = PS_TRAFFIC_HOST; + if ((uVar6 & 1) == 0) { + sVar9 = UAPSD_TRAFFIC_HOST; + sVar8 = UAPSD_TRAFFIC_INT; + } + if ((sVar8 & sta->traffic_avail) != 0) { + cVar3 = (co_list_hdr)(sta->tx_desc_post).first; + prev_element = (co_list_hdr)(co_list_hdr *)0x0; + while( true ) { + element = cVar3; + if (element == (co_list_hdr)0x0) { + assert_warn("txdesc","module",0x16f); + *stop = 1; + return (txdesc *)0x0; + } + if (((mac_ac2uapsd[*(byte *)((int)element + 0x2e)] & (sta->info).uapsd_queues) == 0) != + (uVar6 == 2)) break; + cVar3 = *(co_list_hdr *)element; + prev_element = element; + } + co_list_remove(&sta->tx_desc_post,(co_list_hdr *)prev_element,(co_list_hdr *)element); + *(char *)((int)element + 0x2e) = ((sta->ps_service_period & 8U) != 0) + '\x03'; + if (prev_element == (co_list_hdr)0x0) { + piVar7 = (int *)(sta->tx_desc_post).first; + } + else { + piVar7 = (int *)((co_list_hdr *)prev_element)->next; + } + while (piVar7 != (int *)0x0) { + if (((mac_ac2uapsd[*(byte *)((int)piVar7 + 0x2e)] & (sta->info).uapsd_queues) == 0) != + (sta->ps_service_period == 2)) goto LAB_2300d610; + piVar7 = (int *)*piVar7; + } + sVar8 = ~sVar8 & sta->traffic_avail; + sta->traffic_avail = sVar8; + if ((sVar8 & sVar9) == 0) { + puVar4 = (uint16_t *)ke_msg_alloc(0x41,0,5,4); + *puVar4 = sta->aid; + uVar1 = sta->inst_nbr; + *(undefined *)(puVar4 + 1) = 0; + *(uint8_t *)((int)puVar4 + 3) = uVar1; + ke_msg_send(); + } + else { +LAB_2300d610: + pcVar5 = ((co_list_hdr *)((int)element + 0x68))->next; + uVar2 = *(ushort *)&pcVar5[0x53].next; + *(char *)&pcVar5[0x53].next = (char)uVar2; + *(byte *)((int)&pcVar5[0x53].next + 1) = (byte)((uint)uVar2 >> 8) | 0x20; + } + return (txdesc *)element; + } + *stop = 1; + } + else { + *stop = 0; + } + return (txdesc *)0x0; +} + + + +void apm_tx_int_ps_clear(vif_info_tag *vif,uint8_t sta_idx) + +{ + sta_ps_traffic sVar1; + uint8_t uVar2; + uint16_t *puVar3; + undefined3 in_register_0000202d; + int iVar4; + + iVar4 = CONCAT31(in_register_0000202d,sta_idx); + if (vif->type != '\x02') { + return; + } + sta_mgmt_send_postponed_frame(vif,sta_info_tab + iVar4,0); + sVar1 = sta_info_tab[iVar4].traffic_avail; + if (((sVar1 & (PS_TRAFFIC_INT|UAPSD_TRAFFIC_INT)) != 0) && + (sta_info_tab[iVar4].traffic_avail = sVar1 & ~(PS_TRAFFIC_INT|UAPSD_TRAFFIC_INT), + (sVar1 & ~(PS_TRAFFIC_INT|UAPSD_TRAFFIC_INT)) == 0)) { + puVar3 = (uint16_t *)ke_msg_alloc(0x41,0,5,4); + *puVar3 = sta_info_tab[iVar4].aid; + uVar2 = sta_info_tab[iVar4].inst_nbr; + *(undefined *)(puVar3 + 1) = 0; + *(uint8_t *)((int)puVar3 + 3) = uVar2; + ke_msg_send(); + return; + } + return; +} + + + +void apm_sta_fw_delete(uint8_t sta_idx) + +{ + undefined3 in_register_00002029; + + apm_sta_delete(sta_idx,(uint8_t *)&sta_info_tab[CONCAT31(in_register_00002029,sta_idx)].mac_addr); + return; +} + + + +void apm_sta_add(uint8_t sta_idx) + +{ + undefined3 in_register_00002029; + int iVar1; + uint32_t *puVar2; + + iVar1 = CONCAT31(in_register_00002029,sta_idx); + puVar2 = (uint32_t *)ke_msg_alloc(0x1c08,0xd,7,0x1c); + sta_info_tab[iVar1].ctrl_port_state = '\x02'; + *puVar2 = sta_info_tab[iVar1].info.capa_flags; + memcpy(puVar2 + 1,&sta_info_tab[iVar1].mac_addr,6); + *(uint8_t *)((int)puVar2 + 0xb) = sta_info_tab[iVar1].staid; + *(uint8_t *)((int)puVar2 + 10) = sta_info_tab[iVar1].inst_nbr; + *(int8_t *)(puVar2 + 3) = sta_info_tab[iVar1].rssi; + puVar2[4] = sta_info_tab[iVar1].tsflo; + puVar2[5] = sta_info_tab[iVar1].tsfhi; + *(uint8_t *)(puVar2 + 6) = sta_info_tab[iVar1].data_rate; + ke_msg_send(puVar2); + return; +} + + + +void apm_send_mlme(vif_info_tag *vif,uint16_t fctl,mac_addr *ra,cfm_func_ptr *cfm_func,void *env, + uint16_t status_code) + +{ + uint8_t uVar1; + txl_buffer_tag *ptVar2; + uint16_t uVar3; + txl_frame_desc_tag *frame; + undefined2 in_register_0000202e; + uint uVar4; + int iVar5; + tx_hw_desc *ptVar6; + + _uVar3 = CONCAT22(in_register_0000202e,fctl); + frame = txl_frame_get((uint)(((vif->bss_info).chan)->band != '\0'),0x100); + if (frame == (txl_frame_desc_tag *)0x0) { + return; + } + ptVar2 = (frame->txdesc).lmac.buffer; + *(undefined *)((int)&ptVar2[1].length + 1) = (char)(fctl >> 8); + *(char *)&ptVar2[1].length = (char)fctl; + *(undefined *)((int)&ptVar2[1].length + 2) = 0; + *(undefined *)((int)&ptVar2[1].length + 3) = 0; + memcpy(&ptVar2[1].lenheader,ra,6); + memcpy((void *)((int)&ptVar2[1].lenpad + 2),&vif->mac_addr,6); + memcpy(&ptVar2[1].next,&vif->mac_addr,6); + uVar4 = (uint)txl_cntrl_env.seqnbr; + txl_cntrl_env.seqnbr = (uint16_t)((uVar4 + 1) * 0x10000 >> 0x10); + iVar5 = (uVar4 + 1) * 0x100000; + *(undefined *)((int)&ptVar2[1].txdesc + 2) = (char)((uint)iVar5 >> 0x10); + *(undefined *)((int)&ptVar2[1].txdesc + 3) = (char)((uint)iVar5 >> 0x18); + if (_uVar3 == 0xb0) { + uVar3 = me_build_authenticate((uint32_t)ptVar2[1].dma_desc,0,2,0,(uint32_t *)0x0); + _uVar3 = (uint)uVar3; + } + else { + if (_uVar3 == 0xc0) { + uVar3 = me_build_deauthenticate((uint32_t)ptVar2[1].dma_desc,status_code); + _uVar3 = (uint)uVar3; + } + else { + if (_uVar3 == 0x50) { + uVar3 = me_build_probe_rsp((uint32_t)ptVar2[1].dma_desc,vif->index); + _uVar3 = (uint)uVar3; + } + else { + uVar4 = 0x18; + if ((_uVar3 & 0xffffffdf) != 0x10) goto LAB_2300d868; + uVar3 = me_build_associate_rsp + ((uint32_t)ptVar2[1].dma_desc,vif->index,status_code,(me_sta_add_req *)env + ); + _uVar3 = (uint)uVar3; + } + } + } + uVar4 = _uVar3 + 0x18 & 0xffff; +LAB_2300d868: + ptVar6 = (frame->txdesc).lmac.hw_desc; + (ptVar6->thd).frmlen = uVar4 + 4; + (ptVar6->thd).field_5 = (ptVar6->thd).field_4 + -1 + uVar4; + uVar1 = vif->index; + (frame->txdesc).umac.head_len = '\0'; + (frame->txdesc).umac.tail_len = '\0'; + (frame->txdesc).host.vif_idx = uVar1; + (frame->txdesc).host.staid = -1; + (frame->cfm).cfm_func = cfm_func; + (frame->cfm).env = env; + txl_frame_push(frame,'\x03'); + return; +} + + + +_Bool apm_embedded_enabled(vif_info_tag *vif) + +{ + _Bool _Var1; + + if (vif != (vif_info_tag *)0x0) { + _Var1 = false; + if (vif->type == '\x02') { + _Var1 = apm_env.apm_emb_enabled; + } + return (_Bool)(_Var1 & 1); + } + return apm_env.apm_emb_enabled; +} + + + +void apm_bcn_set(void) + +{ + byte bVar1; + apm_start_req *paVar2; + _Bool _Var3; + uint32_t *puVar4; + undefined3 extraout_var; + + paVar2 = apm_env.param; + puVar4 = (uint32_t *) + ke_msg_alloc(0x3f,0,7,(uint16_t) + (((uint)(apm_env.param)->bcn_len + 0xc) * 0x10000 >> 0x10)); + *puVar4 = paVar2->bcn_addr; + *(uint16_t *)(puVar4 + 1) = paVar2->bcn_len; + *(uint16_t *)((int)puVar4 + 6) = paVar2->tim_oft; + *(uint8_t *)(puVar4 + 2) = paVar2->tim_len; + bVar1 = paVar2->vif_idx; + *(byte *)((int)puVar4 + 9) = bVar1; + _Var3 = apm_embedded_enabled(vif_info_tab + bVar1); + if (CONCAT31(extraout_var,_Var3) == 0) { + memcpy(puVar4 + 3,(void *)&paVar2->field_0xa7,(uint)paVar2->bcn_len); + } + else { + memcpy(puVar4 + 3,apm_env.bcn_buf,(uint)paVar2->bcn_len); + ke_free(apm_env.bcn_buf); + apm_env.bcn_buf = (uint8_t *)0x0; + } + ke_msg_send(puVar4); + ke_state_set(7,2); + return; +} + + + +void apm_probe_req_handler(ushort *param_1) + +{ + uint8_t uVar1; + ushort uVar2; + int iVar3; + vif_info_tag *vif; + uint __n; + scan_chan_tag *psVar4; + int iVar5; + uint uVar6; + + if (*(byte *)(param_1 + 4) == 0xff) { + vif = vif_mgmt_get_first_ap_inf(); + if (vif == (vif_info_tag *)0x0) { + return; + } + } + else { + vif = vif_info_tab + *(byte *)(param_1 + 4); + } + iVar3 = mac_ie_find(param_1 + 0x1a,(uint)*param_1 - 0x18 & 0xffff,0); + if ((iVar3 == 0) || (*(byte *)(iVar3 + 1) == 0)) { + if (apm_env.hidden_ssid != '\0') { + return; + } + } + else { + __n = (uint)(vif->bss_info).ssid.length; + if (__n != (uint)*(byte *)(iVar3 + 1)) { + return; + } + iVar3 = memcmp((void *)(iVar3 + 2),(vif->bss_info).ssid.array,__n); + if (iVar3 != 0) { + return; + } + } + iVar3 = mac_ie_find(param_1 + 0x1a,(uint)*param_1 - 0x18 & 0xffff,3); + if (iVar3 == 0) goto LAB_2300da50; + psVar4 = (vif->bss_info).chan; + uVar1 = psVar4->band; + uVar2 = psVar4->freq; + __n = (uint)uVar2; + if (uVar1 == '\0') { + uVar6 = 0; + if (((__n - 0x96c & 0xffff) < 0x49) && (uVar6 = 0xe, uVar2 != 0x9b4)) { + iVar5 = -0x967; +LAB_2300dac6: + uVar6 = (int)(__n + iVar5) / 5; + } + } + else { + uVar6 = 0; + if ((uVar1 == '\x01') && (uVar6 = 0, (__n - 0x138d & 0xffff) < 0x335)) { + iVar5 = -5000; + goto LAB_2300dac6; + } + } + if ((uint)*(byte *)(iVar3 + 2) != uVar6) { + return; + } +LAB_2300da50: + apm_send_mlme(vif,0x50,(mac_addr *)(param_1 + 0x13),(cfm_func_ptr *)0x0,(void *)0x0,0); + return; +} + + + +void apm_auth_handler(rxu_mgt_ind *param) + +{ + byte bVar1; + mac_addr *addr; + uint8_t sta_idx; + undefined3 extraout_var; + + bVar1 = param->inst_nbr; + if (bVar1 != 0xff) { + addr = (mac_addr *)(param[1].sa + 1); + sta_idx = hal_machw_search_addr(addr); + if (CONCAT31(extraout_var,sta_idx) != 0xff) { + apm_sta_delete(sta_idx,(uint8_t *)addr); + } + apm_send_mlme(vif_info_tab + bVar1,0xb0,addr,(cfm_func_ptr *)0x0,(void *)0x0,0); + return; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void apm_assoc_req_handler(ushort *param_1,int param_2) + +{ + uint8_t uVar1; + IEEEtypes_Addr_t IVar2; + uint8_t uVar3; + ushort *puVar4; + byte bVar5; + uint16_t status_code; + IEEEtypes_MacAddr_t *peerMacAddr; + int iVar6; + int iVar7; + undefined2 extraout_var; + uint8_t *puVar8; + int iVar9; + uint16_t fctl; + uint __n; + mac_rateset *pmVar10; + IEEEtypes_Addr_t *pIVar11; + IEEEtypes_Addr_t *pIVar12; + uint uVar13; + apm *paVar14; + mac_addr *ra; + short sVar15; + uint uVar16; + Cipher_t aCStack84 [4]; + undefined2 uStack80; + + uVar16 = (uint)*(byte *)(param_1 + 4); + if (*(byte *)(param_1 + 4) == 0xff) { + return; + } + peerMacAddr = (IEEEtypes_MacAddr_t *)ke_msg_alloc(0x1407,5,7,0x58); + ra = (mac_addr *)(param_1 + 0x13); + memset(peerMacAddr,0,0x58); + memcpy(peerMacAddr,ra,6); + (peerMacAddr + 0xc)[1] = *(IEEEtypes_Addr_t *)(param_1 + 4); + *(undefined4 *)(peerMacAddr + 0xc + 4) = *(undefined4 *)(param_1 + 8); + *(undefined4 *)(peerMacAddr + 0xd + 2) = *(undefined4 *)(param_1 + 10); + (peerMacAddr + 0xe)[0] = *(IEEEtypes_Addr_t *)(param_1 + 0xc); + (peerMacAddr + 0xe)[1] = *(IEEEtypes_Addr_t *)((int)param_1 + 0x1b); + if (param_2 == 0) { + puVar4 = param_1 + 0x1c; + uVar13 = (uint)*param_1 - 0x1c; + } + else { + puVar4 = param_1 + 0x1f; + uVar13 = (uint)*param_1 - 0x22; + } + status_code = 0x33; + if (param_1[0x1b] <= vif_info_tab[uVar16].bss_info.max_listen_interval) { + uVar13 = uVar13 & 0xffff; + iVar6 = mac_ie_find(puVar4,uVar13,0); + if (((iVar6 == 0) || + (__n = (uint)vif_info_tab[uVar16].bss_info.ssid.length, __n != (uint)*(byte *)(iVar6 + 1))) + || (iVar6 = memcmp((void *)(iVar6 + 2),vif_info_tab[uVar16].bss_info.ssid.array,__n), + iVar6 != 0)) { + status_code = 1; + } + else { + iVar7 = mac_ie_find(puVar4,uVar13,1); + status_code = 0x12; + if (iVar7 != 0) { + __n = (uint)*(byte *)(iVar7 + 1); + puVar8 = (uint8_t *)(iVar7 + 2); + uStack80 = uStack80 & 0xff00 | (ushort)*(byte *)(iVar7 + 1); + pmVar10 = (mac_rateset *)&uStack80; + while( true ) { + __n = __n - 1; + pmVar10 = (mac_rateset *)pmVar10->array; + if (__n == 0xffffffff) break; + uVar1 = *puVar8; + puVar8 = puVar8 + 1; + pmVar10->length = uVar1; + } + iVar7 = mac_ie_find(puVar4,uVar13,0x32); + if (iVar7 != 0) { + bVar5 = *(byte *)(iVar7 + 1); + __n = 0; + while ((uint)bVar5 != __n) { + *(undefined *)((int)&uStack80 + (byte)uStack80 + __n + 1) = + *(undefined *)(iVar7 + 2 + __n); + __n = __n + 1; + } + uStack80 = uStack80 & 0xff00 | (ushort)(byte)(bVar5 + (byte)uStack80); + } + status_code = me_legacy_rate_bitfield_build((mac_rateset *)&uStack80,false); + (peerMacAddr + 1)[0] = '\0'; + __n = 0; + while (__n < vif_info_tab[uVar16].bss_info.rate_set.length) { + iVar7 = (int)&vif_info_tab[uVar16].list_hdr.next + __n; + bVar5 = me_rate_translate(*(uint8_t *)(iVar7 + 0x3b1)); + if ((CONCAT22(extraout_var,status_code) >> ((uint)bVar5 & 0x1f) & 1U) == 0) { + if (*(char *)(iVar7 + 0x3b1) < '\0') { + status_code = 0x12; + goto fail; + } + } + else { + bVar5 = (peerMacAddr + 1)[0]; + (peerMacAddr + 1)[(uint)bVar5 + 1] = *(IEEEtypes_Addr_t *)(iVar7 + 0x3b1); + (peerMacAddr + 1)[0] = bVar5 + 1; + } + __n = __n + 1 & 0xff; + } + iVar7 = mac_ie_find(puVar4,uVar13,0x2d); + if (iVar7 != 0) { + *(undefined2 *)(peerMacAddr + 3 + 2) = *(undefined2 *)(iVar7 + 2); + pIVar11 = (IEEEtypes_Addr_t *)(iVar7 + 5); + (peerMacAddr + 3)[4] = *(IEEEtypes_Addr_t *)(iVar7 + 4); + pIVar12 = peerMacAddr + 3 + 5; + while (pIVar12 != peerMacAddr + 6 + 3) { + IVar2 = *pIVar11; + pIVar11 = pIVar11 + 1; + *pIVar12 = IVar2; + pIVar12 = pIVar12 + 1; + } + *(undefined2 *)(peerMacAddr + 6 + 4) = *(undefined2 *)(iVar7 + 0x15); + *(uint *)(peerMacAddr + 7 + 2) = (uint)*(ushort *)(iVar7 + 0x17); + (peerMacAddr + 8)[0] = *(IEEEtypes_Addr_t *)(iVar7 + 0x1b); + *(uint *)(peerMacAddr + 10 + 4) = *(uint *)(peerMacAddr + 10 + 4) | 2; + } + iVar7 = mac_vsie_find(puVar4,uVar13,&DAT_23075444,4); + if (iVar7 != 0) { + bVar5 = *(byte *)(iVar7 + 8); + *(uint *)(peerMacAddr + 10 + 4) = *(uint *)(peerMacAddr + 10 + 4) | 1; + (peerMacAddr + 0xb)[4] = bVar5 & 0xf; + (peerMacAddr + 0xb)[5] = bVar5 >> 4 & 6; + } + memset((mac_rateset *)&uStack80,0,2); + memset(aCStack84,0,1); + iVar7 = mac_ie_find(puVar4,uVar13,0x30); + if (iVar7 == 0) { + iVar7 = mac_vsie_find(puVar4,uVar13,&DAT_2307544c,4); + if (iVar7 != 0) { + uStack80 = uStack80 | 8; + aCStack84[0] = (Cipher_t)((byte)aCStack84[0] | 4); + } + } + else { + uStack80 = uStack80 | 0x20; + aCStack84[0] = (Cipher_t)((byte)aCStack84[0] | 8); + } + if (uap_conn_info != (cm_ConnectionInfo_t *)0x0) { + status_code = 0x2e; + if ((uStack80 & 0x28) == 0) goto fail; + InitStaKeyInfo(uap_conn_info,(SecurityMode_t *)(mac_rateset *)&uStack80,aCStack84,0,'\0'); + cm_SetPeerAddr(uap_conn_info,(IEEEtypes_MacAddr_t *)0x0,peerMacAddr); + } + uVar3 = apm_env.max_sta_supported; + uVar1 = apm_env.assoc_sta_count; + *(undefined2 *)(peerMacAddr + 0xb + 2) = 0; + if (uVar1 < uVar3) { + paVar14 = &apm_env; + iVar7 = -1; + do { + sVar15 = (short)iVar6; + if (paVar14->aid_list[0].used == '\0') { + if (iVar7 == -1) { + iVar7 = iVar6; + } + } + else { + iVar9 = memcmp(paVar14->aid_list,ra,6); + if (iVar9 == 0) { + apm_env.aid_list[iVar6].used = '\x01'; + goto LAB_2300dee6; + } + } + sVar15 = (short)iVar7; + iVar6 = iVar6 + 1; + paVar14 = (apm *)((int)&(paVar14->bss_config).first + 3); + } while (iVar6 != 10); + if (iVar7 != -1) { + memcpy(apm_env.aid_list + iVar7,ra,6); + apm_env.aid_list[iVar7].used = '\x01'; +LAB_2300dee6: + *(short *)(peerMacAddr + 0xb + 2) = sVar15 + 1; + apm_env.assoc_sta_count = apm_env.assoc_sta_count + '\x01'; + status_code = 0; + goto fail; + } + } + status_code = 0x11; + } + } + } +fail: + fctl = 0x30; + if (param_2 == 0) { + fctl = 0x10; + } + apm_send_mlme(vif_info_tab + uVar16,fctl,ra,apm_tx_cfm_handler,peerMacAddr,status_code); + return; +} + + + +void apm_deauth_handler(rxu_mgt_ind *param) + +{ + if ((param->inst_nbr != -1) && (param->sta_idx != -1)) { + apm_sta_delete(param->sta_idx,param[1].sa + 1); + return; + } + return; +} + + + +void apm_disassoc_handler(rxu_mgt_ind *param) + +{ + byte bVar1; + + bVar1 = param->inst_nbr; + if ((bVar1 != 0xff) && (param->sta_idx != -1)) { + apm_sta_delete(param->sta_idx,(uint8_t *)(mac_addr *)(param[1].sa + 1)); + apm_send_mlme(vif_info_tab + bVar1,0xc0,(mac_addr *)(param[1].sa + 1),(cfm_func_ptr *)0x0, + (void *)0x0,2); + return; + } + return; +} + + + +void apm_beacon_handler(rxu_mgt_ind *param) + +{ + return; +} + + + +void apm_sta_remove(uint8_t vif_idx,uint8_t sta_idx) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + + apm_send_mlme(vif_info_tab + CONCAT31(in_register_00002029,vif_idx),0xc0, + &sta_info_tab[CONCAT31(in_register_0000202d,sta_idx)].mac_addr,(cfm_func_ptr *)0x0, + (void *)0x0,2); + apm_sta_delete(sta_idx,(uint8_t *)&sta_info_tab[CONCAT31(in_register_0000202d,sta_idx)].mac_addr); + return; +} + + + +char * cfg_api_element_dump(void *val,CFG_ELEMENT_TYPE type,char *strs) + +{ + int iVar1; + char *pcVar2; + + switch((uint)type - 1 & 0xff) { + case 0: + if (*(char *)val == '\0') { + pcVar2 = "False"; + } + else { + pcVar2 = "True"; + } + iVar1 = snprintf(strs,0xf,"%s",pcVar2); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "Boolean"; + break; + case 1: + iVar1 = snprintf(strs,0xf,"%d",(int)*(char *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "SINT8"; + break; + case 2: + iVar1 = snprintf(strs,0xf,"%u",(uint)*(byte *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "UINT8"; + break; + case 3: + iVar1 = snprintf(strs,0xf,"%d",(int)*(short *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "SINT16"; + break; + case 4: + iVar1 = snprintf(strs,0xf,"%u",(uint)*(ushort *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "UINT16"; + break; + case 5: + iVar1 = snprintf(strs,0xf,"%ld",*(undefined4 *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "SINT32"; + break; + case 6: + iVar1 = snprintf(strs,0xf,"%lu",*(undefined4 *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "UINT32"; + break; + case 7: + iVar1 = snprintf(strs,0xf,"%lu",*(undefined4 *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "STRING"; + break; + default: + return (char *)0x0; + } + return pcVar2; +} + + + +int cfg_api_element_general_set(cfg_element_entry *entry,void *arg1,void *arg2) + +{ + undefined uVar1; + undefined2 uVar2; + uint uVar3; + undefined4 *puVar4; + + printf(" updating element: %s\r\n",entry->name); + uVar3 = (uint)entry->type - 1 & 0xffff; + if (6 < uVar3) { + return 0; + } + puVar4 = (undefined4 *)entry->val; + switch(uVar3) { + default: + uVar1 = *(undefined *)arg1; + break; + case 1: + uVar1 = *(undefined *)arg1; + break; + case 3: + uVar2 = *(undefined2 *)arg1; + goto LAB_2300e1dc; + case 4: + uVar2 = *(undefined2 *)arg1; +LAB_2300e1dc: + *(undefined2 *)puVar4 = uVar2; + return 0; + case 5: + case 6: + *puVar4 = *(undefined4 *)arg1; + return 0; + } + *(undefined *)puVar4 = uVar1; + return 0; +} + + + +int cfg_api_element_general_get(cfg_element_entry *entry,void *arg1,void *arg2) + +{ + return 0; +} + + + +int cfg_api_element_set(uint32_t task,uint32_t element,uint32_t type,void *arg1,void *arg2) + +{ + cfg_element_entry *pcVar1; + + pcVar1 = cfg_entrys_mm; + while (pcVar1 < &_fsymc_info_bloop) { + if ((pcVar1->task == task) && ((uint)pcVar1->element == element)) { + if ((uint)pcVar1->type == type) goto LAB_2300e244; + printf("type %lu NOT matched on element: %lu %lu %u\r\n",type,task,element); + } + pcVar1 = pcVar1 + 1; + } + if (pcVar1 != (cfg_element_entry *)&_fsymc_info_bloop) { +LAB_2300e244: + (*pcVar1->set)(pcVar1,arg1,arg2); + } + return 0; +} + + + +void co_list_init(co_list *list) + +{ + list->first = (co_list_hdr *)0x0; + list->last = (co_list_hdr *)0x0; + return; +} + + + +void co_list_push_back(co_list *list,co_list_hdr *list_hdr) + +{ + if (list_hdr == (co_list_hdr *)0x0) { + assert_err("list_hdr != NULL","module",0x47); + } + if (list->first == (co_list_hdr *)0x0) { + list->first = list_hdr; + } + else { + list->last->next = list_hdr; + } + list->last = list_hdr; + list_hdr->next = (co_list_hdr *)0x0; + return; +} + + + +void co_list_push_front(co_list *list,co_list_hdr *list_hdr) + +{ + if (list_hdr == (co_list_hdr *)0x0) { + assert_err("list_hdr != NULL","module",0x5e); + } + if (list->first == (co_list_hdr *)0x0) { + list->last = list_hdr; + } + list_hdr->next = list->first; + list->first = list_hdr; + return; +} + + + +co_list_hdr * co_list_pop_front(co_list *list) + +{ + co_list_hdr *pcVar1; + + pcVar1 = list->first; + if (pcVar1 != (co_list_hdr *)0x0) { + list->first = pcVar1->next; + } + return pcVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +void co_list_extract(co_list *list,co_list_hdr *list_hdr) + +{ + co_list_hdr cVar1; + co_list_hdr cVar2; + + if (list == (co_list *)0x0) { + assert_err("list != NULL","module",0x81); + } + cVar1 = (co_list_hdr)list->first; + if (cVar1 != (co_list_hdr)0x0) { + if (cVar1 == (co_list_hdr)list_hdr) { + list->first = list_hdr->next; + } + else { + do { + cVar2 = cVar1; + cVar1 = *(co_list_hdr *)cVar2; + if (cVar1 == (co_list_hdr)0x0) { + return; + } + } while (cVar1 != (co_list_hdr)list_hdr); + if (list->last == list_hdr) { + *(co_list_hdr *)&((co_list_hdr *)&list->last)->next = cVar2; + } + *(co_list_hdr **)cVar2 = list_hdr->next; + } + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +uint32_t co_list_cnt(co_list *list) + +{ + uint32_t uVar1; + int *piVar2; + + piVar2 = (int *)list->first; + uVar1 = 0; + while (piVar2 != (int *)0x0) { + uVar1 = uVar1 + 1; + piVar2 = (int *)*piVar2; + } + return uVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +void co_list_insert(co_list *list,co_list_hdr *element, + anon_subr__Bool_co_list_hdr_ptr_co_list_hdr_ptr *cmp) + +{ + co_list_hdr cVar1; + co_list_hdr cVar2; + _Bool _Var3; + undefined3 extraout_var; + co_list_hdr cVar4; + + cVar1 = (co_list_hdr)list->first; + cVar4 = (co_list_hdr)(co_list_hdr *)0x0; + while (cVar2 = cVar1, cVar2 != (co_list_hdr)0x0) { + _Var3 = (*cmp)(element,(co_list_hdr *)cVar2); + if (CONCAT31(extraout_var,_Var3) != 0) goto LAB_2300e398; + cVar1 = *(co_list_hdr *)cVar2; + cVar4 = cVar2; + } + list->last = element; +LAB_2300e398: + *(co_list_hdr *)&element->next = cVar2; + if (cVar4 == (co_list_hdr)0x0) { + list->first = element; + } + else { + ((co_list_hdr *)cVar4)->next = element; + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void co_list_insert_after(co_list *list,co_list_hdr *prev_element,co_list_hdr *element) + +{ + co_list_hdr cVar1; + + cVar1 = (co_list_hdr)list->first; + if (prev_element == (co_list_hdr *)0x0) { + co_list_push_front(list,element); + return; + } + while( true ) { + if (cVar1 == (co_list_hdr)0x0) { + return; + } + if (cVar1 == (co_list_hdr)prev_element) break; + cVar1 = *(co_list_hdr *)cVar1; + } + element->next = *(co_list_hdr **)cVar1; + *(co_list_hdr **)cVar1 = element; + if (element->next != (co_list_hdr *)0x0) { + return; + } + list->last = element; + return; +} + + + +void co_list_remove(co_list *list,co_list_hdr *prev_element,co_list_hdr *element) + +{ + if (list == (co_list *)0x0) { + assert_err("list != NULL","module",0x168); + } + if (prev_element == (co_list_hdr *)0x0) { + if (element == (co_list_hdr *)0x0) goto LAB_2300e43c; +LAB_2300e456: + list->first = element->next; + } + else { + if (prev_element->next != element) { + assert_err("(prev_element == NULL) || (prev_element->next == element)","module",0x169); + } + if (element == (co_list_hdr *)0x0) { +LAB_2300e43c: + assert_err("element != NULL","module",0x16a); + if (prev_element == (co_list_hdr *)0x0) goto LAB_2300e456; + } + prev_element->next = element->next; + if (list->last == element) { + list->last = prev_element; + } + } + element->next = (co_list_hdr *)0x0; + return; +} + + + +uint32_t co_crc32(uint32_t addr,uint32_t len,uint32_t crc) + +{ + uint32_t uVar1; + byte *pbVar2; + + uVar1 = 0; + while (uVar1 != len) { + pbVar2 = (byte *)(uVar1 + addr); + uVar1 = uVar1 + 1; + crc = crc << 8 ^ crc_tab[crc >> 0x18 ^ (uint)*pbVar2]; + } + return crc; +} + + +/* +Unable to decompile 'ke_evt_set' +Cause: Exception while decompiling 2300e49c: Decompiler process died + +*/ + +/* +Unable to decompile 'ke_evt_clear' +Cause: Exception while decompiling 2300e4b4: Decompiler process died + +*/ + + +void bl_event_handle(int param) + +{ + ke_evt_clear(0x40000000); + bl_main_event_handle(); + return; +} + + +/* +Unable to decompile 'bl_fw_statistic_dump' +Cause: Exception while decompiling 2300e4e4: Decompiler process died + +*/ + + +void bl60x_fw_dump_statistic(int forced) + +{ + if (forced != 0) { + bl_fw_statistic_dump(0); + return; + } + ke_evt_set(0x20); + return; +} + + + +void ke_evt_schedule(void) + +{ + int iVar1; + evt_ptr_t *peVar2; + + while (ke_env.evt_field != 0) { + iVar1 = __clzsi2(ke_env.evt_field); + peVar2 = ke_evt_hdlr[iVar1].func; + if ((0x1a < iVar1) || (peVar2 == (evt_ptr_t *)0x0)) { + assert_err("(event < KE_EVT_MAX) && ke_evt_hdlr[event].func","module",0xdd); + } + (*peVar2)(ke_evt_hdlr[iVar1].param); + } + return; +} + + + +void ke_init(void) + +{ + ke_env.mblock_first = ke_mem_init(); + ke_env.queue_saved.first = (co_list_hdr *)0x0; + ke_env.queue_saved.last = (co_list_hdr *)0x0; + ke_env.queue_sent.first = (co_list_hdr *)0x0; + ke_env.queue_sent.last = (co_list_hdr *)0x0; + ke_env.queue_timer.first = (co_list_hdr *)0x0; + ke_env.queue_timer.last = (co_list_hdr *)0x0; + ke_evt_clear(0xffffffff); + return; +} + + +/* +Unable to decompile 'ke_mem_init' +Cause: Exception while decompiling 2300e5dc: Decompiler process died + +*/ + +/* +Unable to decompile 'ke_malloc' +Cause: Exception while decompiling 2300e602: Decompiler process died + +*/ + +/* +Unable to decompile 'ke_free' +Cause: Exception while decompiling 2300e696: Decompiler process died + +*/ + + +void * ke_msg_alloc(ke_msg_id_t id,ke_task_id_t dest_id,ke_task_id_t src_id,uint16_t param_len) + +{ + undefined4 *puVar1; + undefined2 in_register_00002036; + + puVar1 = (undefined4 *)ke_malloc(CONCAT22(in_register_00002036,param_len) + 0xc); + if (puVar1 == (undefined4 *)0x0) { + assert_err("msg != NULL","module",0x50); + } + *(ke_msg_id_t *)(puVar1 + 1) = id; + *(ke_task_id_t *)((int)puVar1 + 6) = dest_id; + *(ke_task_id_t *)(puVar1 + 2) = src_id; + *(uint16_t *)((int)puVar1 + 10) = param_len; + *puVar1 = 0; + memset(puVar1 + 3,0,CONCAT22(in_register_00002036,param_len)); + return puVar1 + 3; +} + + + +void ke_msg_send(int param_1) + +{ + if (*(byte *)(param_1 + -6) < 0xf) { + if (*(byte *)(param_1 + -6) < 0xd) { + co_list_push_back(&ke_env.queue_sent,(co_list_hdr *)(param_1 + -0xc)); + ke_evt_set(0x1000000); + return; + } + } + else { + assert_err("id <= TASK_MAX","module",0xb6); + } + bl_rx_e2a_handler((void *)(param_1 + -8)); + ke_free((co_list_hdr *)(param_1 + -0xc)); + return; +} + + + +void ke_msg_send_basic(ke_msg_id_t id,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_msg_alloc(id,dest_id,src_id,0); + ke_msg_send(); + return; +} + + + +void ke_msg_forward_and_change_id + (void *param_ptr,ke_msg_id_t msg_id,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + *(ke_msg_id_t *)((int)param_ptr + -8) = msg_id; + *(ke_task_id_t *)((int)param_ptr + -6) = dest_id; + *(ke_task_id_t *)((int)param_ptr + -4) = src_id; + ke_msg_send(); + return; +} + + +/* +Unable to decompile 'ke_msg_free' +Cause: Exception while decompiling 2300e860: Decompiler process died + +*/ + + +_Bool cmp_dest_id(co_list_hdr *msg,uint32_t dest_id) + +{ + return (_Bool)((uint)*(ushort *)((int)&msg[1].next + 2) == dest_id); +} + + + +_Bool ke_task_local(ke_task_id_t id) + +{ + undefined2 in_register_0000202a; + + if (0xe < CONCAT22(in_register_0000202a,id)) { + assert_err("id <= TASK_MAX","module",0xb6); + } + return (_Bool)(CONCAT22(in_register_0000202a,id) < 0xd); +} + + + +ke_msg_func_t * ke_handler_search(ke_msg_id_t msg_id,ke_state_handler *state_handler) + +{ + undefined2 in_register_0000202a; + int iVar1; + + iVar1 = (uint)state_handler->msg_cnt - 1; + if (iVar1 == -1) { + return (ke_msg_func_t *)0x0; + } + do { + if ((uint)state_handler->msg_table[iVar1].id == CONCAT22(in_register_0000202a,msg_id)) { + if (state_handler->msg_table[iVar1].func == (ke_msg_func_t *)0x0) { + assert_err("state_handler->msg_table[i].func","module",0xf4); + } + return state_handler->msg_table[iVar1].func; + } + iVar1 = iVar1 + -1; + } while (iVar1 != -1); + return (ke_msg_func_t *)0x0; +} + + +/* +Unable to decompile 'ke_state_set' +Cause: Exception while decompiling 2300e902: Decompiler process died + +*/ + + +ke_state_t ke_state_get(ke_task_id_t id) + +{ + uint uVar1; + _Bool _Var2; + undefined2 in_register_0000202a; + undefined3 extraout_var; + uint uVar3; + + uVar1 = (uint)id & 0xff; + uVar3 = CONCAT22(in_register_0000202a,id) >> 8; + if (0xd < uVar1) { + assert_err("type < TASK_MAX","module",0xd7); + } + _Var2 = ke_task_local((ke_task_id_t)uVar1); + if (CONCAT31(extraout_var,_Var2) == 0) { + assert_err("ke_task_local(type)","module",0xd8); + } + if (TASK_DESC[uVar1].idx_max <= uVar3) { + assert_err("idx < TASK_DESC[type].idx_max","module",0xd9); + } + return TASK_DESC[uVar1].state[uVar3]; +} + + +/* +Unable to decompile 'ke_task_schedule' +Cause: Exception while decompiling 2300ea9a: Decompiler process died + +*/ + + +int ke_msg_discard(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + return 0; +} + + + +int ke_msg_save(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + return 2; +} + + +/* +Unable to decompile 'ke_timer_hw_set' +Cause: Exception while decompiling 2300ec08: Decompiler process died + +*/ + + +_Bool cmp_abs_time(co_list_hdr *timerA,co_list_hdr *timerB) + +{ + return (_Bool)((co_list_hdr *)0x11e1a300 < + (co_list_hdr *)((int)timerA[2].next - (int)timerB[2].next)); +} + + + +_Bool cmp_timer_id(co_list_hdr *timer,uint32_t timer_task) + +{ + if ((uint)*(ushort *)&timer[1].next == timer_task >> 0x10) { + return (_Bool)((uint)*(ushort *)((int)&timer[1].next + 2) == (timer_task & 0xffff)); + } + return false; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ke_timer_set(ke_msg_id_t timer_id,ke_task_id_t task_id,uint32_t delay) + +{ + bool bVar1; + co_list_hdr *pcVar2; + undefined2 in_register_0000202a; + char *condition; + co_list_hdr *element; + undefined2 in_register_0000202e; + int line; + + if (delay == 0) { + line = 0x8c; + condition = "delay > 0"; + } + else { + if (delay < 300000000) goto LAB_2300ecb6; + line = 0x8d; + condition = "delay < KE_TIMER_DELAY_MAX"; + } + assert_err(condition,"module",line); +LAB_2300ecb6: + bVar1 = false; + if ((ke_env.queue_timer.first != (co_list_hdr *)0x0) && + ((uint)*(ushort *)&ke_env.queue_timer.first[1].next == CONCAT22(in_register_0000202a,timer_id)) + ) { + bVar1 = (uint)*(ushort *)((int)&ke_env.queue_timer.first[1].next + 2) == + CONCAT22(in_register_0000202e,task_id); + } + element = ke_queue_extract(&ke_env.queue_timer,cmp_timer_id, + CONCAT22(in_register_0000202a,timer_id) << 0x10 | + CONCAT22(in_register_0000202e,task_id)); + if (element == (co_list_hdr *)0x0) { + element = (co_list_hdr *)ke_malloc(0xc); + if (element == (co_list_hdr *)0x0) { + assert_err("timer","module",0x9d); + } + *(ke_msg_id_t *)&element[1].next = timer_id; + *(ke_task_id_t *)((int)&element[1].next + 2) = task_id; + } + pcVar2 = (co_list_hdr *)(delay + _DAT_44b00120); + element[2].next = pcVar2; + co_list_insert(&ke_env.queue_timer,element,cmp_abs_time); + if ((bVar1) || (ke_env.queue_timer.first == element)) { + ke_timer_hw_set(ke_env.queue_timer.first); + } + if ((int)((int)pcVar2 - _DAT_44b00120) < 0) { + ke_evt_set(0x4000000); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ke_timer_clear(ke_msg_id_t timer_id,ke_task_id_t task_id) + +{ + co_list_hdr *pcVar1; + undefined2 in_register_0000202a; + co_list_hdr *mem_ptr; + undefined2 in_register_0000202e; + + mem_ptr = ke_env.queue_timer.first; + if (ke_env.queue_timer.first == (co_list_hdr *)0x0) { + return; + } + if (((uint)*(ushort *)&ke_env.queue_timer.first[1].next == CONCAT22(in_register_0000202a,timer_id) + ) && ((uint)*(ushort *)((int)&ke_env.queue_timer.first[1].next + 2) == + CONCAT22(in_register_0000202e,task_id))) { + co_list_pop_front(&ke_env.queue_timer); + pcVar1 = ke_env.queue_timer.first; + ke_timer_hw_set(ke_env.queue_timer.first); + if ((pcVar1 != (co_list_hdr *)0x0) && ((int)((int)pcVar1[2].next - _DAT_44b00120) < 0)) { + assert_err("!first || !ke_time_past(first->time)","module",0xd7); + } + } + else { + mem_ptr = ke_queue_extract(&ke_env.queue_timer,cmp_timer_id, + CONCAT22(in_register_0000202a,timer_id) << 0x10 | + CONCAT22(in_register_0000202e,task_id)); + if (mem_ptr == (co_list_hdr *)0x0) { + return; + } + } + ke_free(mem_ptr); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ke_timer_schedule(int dummy) + +{ + co_list_hdr *mem_ptr; + + while( true ) { + ke_evt_clear(0x4000000); + mem_ptr = ke_env.queue_timer.first; + if (ke_env.queue_timer.first == (co_list_hdr *)0x0) { + ke_timer_hw_set(0); + return; + } + if ((-1 < (int)ke_env.queue_timer.first[2].next + (-0x32 - _DAT_44b00120)) && + (ke_timer_hw_set(ke_env.queue_timer.first), -1 < (int)((int)mem_ptr[2].next - _DAT_44b00120)) + ) break; + mem_ptr = co_list_pop_front(&ke_env.queue_timer); + ke_msg_send_basic(*(ke_msg_id_t *)&mem_ptr[1].next,*(ke_task_id_t *)((int)&mem_ptr[1].next + 2), + 0xff); + ke_free(mem_ptr); + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void bl60x_current_time_us(longlong *time_now) + +{ + undefined4 uVar1; + + uVar1 = _DAT_44b080a8; + *(undefined4 *)time_now = _DAT_44b080a4; + *(undefined4 *)((int)time_now + 4) = uVar1; + return; +} + + + +byte * mac_ie_find(byte *param_1,int param_2,uint param_3) + +{ + byte *pbVar1; + + pbVar1 = param_1 + param_2; + while( true ) { + if (pbVar1 <= param_1) { + return (byte *)0; + } + if ((uint)*param_1 == param_3) break; + param_1 = param_1 + (uint)param_1[1] + 2; + } + return param_1; +} + + + +char * mac_vsie_find(char *param_1,int param_2,int param_3,int param_4) + +{ + int iVar1; + char *pcVar2; + int iVar3; + + pcVar2 = param_1 + param_2; + while (param_1 < pcVar2) { + if (*param_1 == -0x23) { + iVar3 = 0; + do { + if (param_4 == iVar3) { + return param_1; + } + iVar1 = iVar3 + 2; + iVar3 = iVar3 + 1; + } while (*(char *)(param_3 + iVar3 + -1) == param_1[iVar1]); + } + param_1 = param_1 + (uint)(byte)param_1[1] + 2; + } + if (param_1 != pcVar2) { + puts("--->>> addr != end\r\n"); + return (char *)0; + } + return (char *)0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BufferDesc_t * +GetTxEAPOLBuffer(cm_ConnectionInfo_t *connPtr,EAPOL_KeyMsg_Tx_t **ppTxEapol,BufferDesc_t *pBufDesc) + +{ + char "GetTxEAPOLBuffer" [17]; + void *pvVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"GetTxEAPOLBuffer"); + if (pBufDesc == (BufferDesc_t *)0x0) { + pBufDesc = (BufferDesc_t *)ke_malloc(0xc); + if (pBufDesc != (BufferDesc_t *)0x0) { + memset(pBufDesc,0,0xc); + pvVar1 = ke_malloc(0x200); + pBufDesc->Buffer = pvVar1; + if (pvVar1 != (void *)0x0) goto LAB_2300efca; + } + pBufDesc = (BufferDesc_t *)0x0; + } + else { +LAB_2300efca: + *(cm_ConnectionInfo_t **)&pBufDesc->intf = connPtr; + *ppTxEapol = (EAPOL_KeyMsg_Tx_t *)pBufDesc->Buffer; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075db0); + } + return pBufDesc; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void UpdateEAPOLWcbLenAndTransmit(BufferDesc_t *pBufDesc,UINT16 frameLen) + +{ + char "UpdateEAPOLWcbLenAndTransmit" [29]; + undefined2 in_register_0000202e; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"UpdateEAPOLWcbLenAndTransmit"); + txl_frame_send_eapol_frame + (*(uint8_t *)(pBufDesc->intf + 1),(cfm_func_ptr *)0x0,(void *)0x0, + (uint8_t *)((int)pBufDesc->Buffer + 0xe),CONCAT22(in_register_0000202e,frameLen) + 4); + ke_free(pBufDesc->Buffer); + ke_free(pBufDesc); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075dd8); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN keyMgmtProcessMsgExt(keyMgmtInfoSta_t *pKeyMgmtInfoSta,EAPOL_KeyMsg_t *pKeyMsg) + +{ + char "keyMgmtProcessMsgExt" [21]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtProcessMsgExt"); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075df8); + return 1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmtInitSta(cm_ConnectionInfo_t *connPtr) + +{ + char "KeyMgmtInitSta" [15]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtInitSta"); + KeyMgmtSta_InitSession(&connPtr->suppData->keyMgmtInfoSta); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075e10); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void keyMgmtSta_StartSession(cm_ConnectionInfo_t *connPtr,CHAR *pBssid,UINT8 *pStaAddr) + +{ + char "keyMgmtSta_StartSession" [24]; + supplicantData *psVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtSta_StartSession"); + psVar1 = connPtr->suppData; + *(cm_ConnectionInfo_t **)&(psVar1->keyMgmtInfoSta).connPtr = connPtr; + memcpy(connPtr->suppData->localStaAddr,pStaAddr,6); + memcpy(connPtr->suppData->localBssid,pBssid,6); + keyMgmtSta_StartSession_internal(&psVar1->keyMgmtInfoSta,10000000); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075ebc); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void init_customApp_mibs(supplicantData_t *suppData) + +{ + char "init_customApp_mibs" [20]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"init_customApp_mibs"); + memset(&suppData->customMIB_RSNStats,0,3); + memset(&suppData->customMIB_RSNConfig,0,0x1c); + *(ushort *)&(suppData->customMIB_RSNConfig).wpaType = + (ushort)(suppData->customMIB_RSNConfig).wpaType | 1; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075eec); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT8 supplicantIsEnabled(void *connectionPtr) + +{ + byte bVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantIsEnabled"); + bVar1 = 0; + if (*(int *)((int)connectionPtr + 8) != 0) { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"supplicantIsEnabled"); + bVar1 = (byte)((uint)*(undefined4 *)(*(int *)((int)connectionPtr + 8) + 0x34) >> 8) & 1; + } + return (UINT8)bVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantInitSession + (cm_ConnectionInfo_t *connPtr,CHAR *pSsid,UINT16 len,CHAR *pBssid,UINT8 *pStaAddr) + +{ + char "supplicantInitSession" [22]; + UINT8 UVar1; + undefined3 extraout_var; + undefined2 in_register_00002032; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantInitSession"); + UVar1 = supplicantIsEnabled(connPtr); + if (CONCAT31(extraout_var,UVar1) != 0) { + KeyMgmtInitSta(connPtr); + memcpy((connPtr->suppData->hashSsId).SsId,pSsid,CONCAT22(in_register_00002032,len)); + (connPtr->suppData->hashSsId).Len = (IEEEtypes_Len_t)len; + keyMgmtSta_StartSession(connPtr,pBssid,pStaAddr); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075ed4); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantDisable(cm_ConnectionInfo_t *connPtr) + +{ + char "supplicantDisable" [18]; + UINT8 UVar1; + undefined3 extraout_var; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantDisable"); + UVar1 = supplicantIsEnabled(connPtr); + if (CONCAT31(extraout_var,UVar1) != 0) { + mm_timer_clear(&(connPtr->suppData->keyMgmtInfoSta).rsnTimer); + *(byte *)&connPtr->suppData->customMIB_RSNConfig = + *(byte *)&connPtr->suppData->customMIB_RSNConfig & 0xfe; + init_customApp_mibs((supplicantData_t *)connPtr->suppData); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075f14); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantEnable(void *connectionPtr,int security_mode,void *mcstCipher,void *ucstCipher, + _Bool is_pmf_required) + +{ + char "supplicantEnable" [17]; + int iVar1; + UINT8 *__src; + undefined3 in_register_00002039; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantEnable"); + *(byte *)(*(int *)((int)connectionPtr + 8) + 0x35) = + *(byte *)(*(int *)((int)connectionPtr + 8) + 0x35) | 1; + if (security_mode - 4U < 3) { + *(ushort *)(*(int *)((int)connectionPtr + 8) + 0x36) = + *(ushort *)(*(int *)((int)connectionPtr + 8) + 0x36) | 0x20; + *(byte *)(*(int *)((int)connectionPtr + 8) + 0x35) = + *(byte *)(*(int *)((int)connectionPtr + 8) + 0x35) | 4; + *(ushort *)(*(int *)((int)connectionPtr + 8) + 0x4e) = + *(ushort *)(*(int *)((int)connectionPtr + 8) + 0x4e) | 1; + memcpy((void *)(*(int *)((int)connectionPtr + 8) + 0x38),mcstCipher,1); + memcpy((void *)(*(int *)((int)connectionPtr + 8) + 0x39),ucstCipher,1); + if (CONCAT31(in_register_00002039,is_pmf_required) == 0) { + *(undefined *)(*(int *)((int)connectionPtr + 8) + 0x3d) = 2; + } + else { + *(undefined *)(*(int *)((int)connectionPtr + 8) + 0x3d) = 6; + } + iVar1 = *(int *)((int)connectionPtr + 8); + __src = ""; + } + else { + if (security_mode != 3) goto LAB_2300f482; + *(ushort *)(*(int *)((int)connectionPtr + 8) + 0x36) = + *(ushort *)(*(int *)((int)connectionPtr + 8) + 0x36) | 8; + memcpy((void *)(*(int *)((int)connectionPtr + 8) + 0x38),mcstCipher,1); + memcpy((void *)(*(int *)((int)connectionPtr + 8) + 0x39),ucstCipher,1); + *(undefined *)(*(int *)((int)connectionPtr + 8) + 0x3d) = 2; + iVar1 = *(int *)((int)connectionPtr + 8); + __src = ""; + } + memcpy((void *)(iVar1 + 0x3a),__src,3); +LAB_2300f482: + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075f28); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT16 keyMgmtFormatWpaRsnIe + (cm_ConnectionInfo_t *connPtr,UINT8 *pos,IEEEtypes_MacAddr_t *pBssid, + IEEEtypes_MacAddr_t *pStaAddr,UINT8 *pPmkid,BOOLEAN addPmkid) + +{ + char "keyMgmtFormatWpaRsnIe" [22]; + uint16_t uVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtFormatWpaRsnIe"); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075f3c); + uVar1 = mm_get_rsn_wpa_ie(connPtr->staId,pos); + return (UINT16)uVar1; +} + + + +// WARNING: Variable defined which should be unmapped: pTxEapol +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +Status_e GeneratePWKMsg2(BufferDesc_t *pEAPoLBufDesc,UINT8 *pSNonce,UINT8 *pEAPOLMICKey, + UINT8 forceKeyDescVersion) + +{ + EAPOL_KeyMsg_Tx_t *pEVar1; + char "GeneratePWKMsg2" [16]; + cm_ConnectionInfo_t *connPtr; + Status_e SVar2; + UINT16 frameLen; + BufferDesc_t *pBufDesc; + EAPOL_KeyMsg_t *pRxEapol; + EAPOL_KeyMsg_Tx_t *pEStack36; + EAPOL_KeyMsg_Tx_t *pTxEapol; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"GeneratePWKMsg2"); + connPtr = (cm_ConnectionInfo_t *)pEAPoLBufDesc->intf; + pRxEapol = (EAPOL_KeyMsg_t *)pEAPoLBufDesc->Buffer; + pBufDesc = GetTxEAPOLBuffer(connPtr,&pEStack36,(BufferDesc_t *)0x0); + if (pBufDesc == (BufferDesc_t *)0x0) { + SVar2 = FAIL; + } + else { + KeyMgmtSta_PrepareEAPOLFrame + (pEStack36,pRxEapol,(IEEEtypes_MacAddr_t *)connPtr->suppData->localBssid, + (IEEEtypes_MacAddr_t *)connPtr->suppData->localStaAddr,pSNonce); + pEVar1 = pEStack36; + if ((pEStack36->keyMsg).desc_type != '\x01') { + frameLen = keyMgmtFormatWpaRsnIe + (connPtr,(pEStack36->keyMsg).key_data, + (IEEEtypes_MacAddr_t *)connPtr->suppData->localBssid, + (IEEEtypes_MacAddr_t *)connPtr->suppData->localStaAddr,(UINT8 *)0x0,0); + *(char *)&(pEVar1->keyMsg).key_material_len = (char)frameLen; + *(undefined *)((int)&(pEVar1->keyMsg).key_material_len + 1) = (char)(frameLen >> 8); + } + frameLen = KeyMgmtSta_PopulateEAPOLLengthMic(pEStack36,pEAPOLMICKey,'\x01',forceKeyDescVersion); + UpdateEAPOLWcbLenAndTransmit(pBufDesc,frameLen); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075e20); + SVar2 = FW_SUCCESS; + } + return SVar2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN KeyMgmtStaHsk_Recvd_PWKMsg1 + (BufferDesc_t *pEAPoLBufDesc,IEEEtypes_MacAddr_t *sa,IEEEtypes_MacAddr_t *da) + +{ + char "KeyMgmtStaHsk_Recvd_PWKMsg1" [28]; + int iVar1; + int iVar2; + Status_e SVar3; + EAPOL_KeyMsg_t *pEVar4; + BOOLEAN BVar5; + UINT8 *pPMK; + undefined3 extraout_var; + int iVar6; + keyMgmtInfoSta_t *pKeyMgmtInfoSta; + BOOLEAN in_fa0; + + iVar6 = pEAPoLBufDesc->intf; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtStaHsk_Recvd_PWKMsg1"); + iVar1 = *(int *)(iVar6 + 8); + pKeyMgmtInfoSta = (keyMgmtInfoSta_t *)(iVar1 + 0x54); + pEVar4 = GetKeyMsgNonceFromEAPOL(pEAPoLBufDesc,pKeyMgmtInfoSta); + if (pEVar4 == (EAPOL_KeyMsg_t *)0x0) { +LAB_2300f69e: + iVar2 = 0; + } + else { + iVar2 = supplicantAkmIsWpaWpa2((AkmSuite_t *)(*(int *)(iVar6 + 8) + 0x3a)); + if (iVar2 != 0) { + BVar5 = supplicantAkmIsWpaWpa2Psk((AkmSuite_t *)(*(int *)(iVar6 + 8) + 0x3a)); + if ((BVar5 == 0) || + (pPMK = pmkCacheFindPSK((UINT8 *)(*(int *)(iVar6 + 8) + 6), + *(UINT8 *)(*(int *)(iVar6 + 8) + 5)), pPMK == (UINT8 *)0x0)) + goto LAB_2300f69e; + supplicantAkmUsesKdf((AkmSuite_t *)(*(int *)(iVar6 + 8) + 0x3a)); + KeyMgmtSta_DeriveKeys + (pPMK,da,sa,(UINT8 *)pKeyMgmtInfoSta,(UINT8 *)(iVar1 + 0x74),(UINT8 *)(iVar1 + 0x94) + ,(UINT8 *)(iVar1 + 0xa4),(KeyData_t *)(iVar1 + 0x128),in_fa0); + iVar2 = 1; + } + SVar3 = GeneratePWKMsg2(pEAPoLBufDesc,(UINT8 *)(iVar1 + 0x74),(UINT8 *)(iVar1 + 0x94),'\0'); + if (CONCAT31(extraout_var,SVar3) == 0) { + if (iVar2 == 1) { + updateApReplayCounter(pKeyMgmtInfoSta,(UINT8 *)pEVar4->replay_cnt); + *(undefined4 *)(iVar1 + 0xcc) = 0; + } + } + else { + iVar2 = 0; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075e50); + } + return iVar2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantInit(supplicantData_t *suppData) + +{ + char "supplicantInit" [15]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantInit"); + init_customApp_mibs(suppData); + memset(&suppData->currParams,0xff,4); + memset(&suppData->keyMgmtInfoSta,0,0x144); + (suppData->keyMgmtInfoSta).sta_MIC_Error.disableStaAsso = 0; + (suppData->keyMgmtInfoSta).sta_MIC_Error.MICCounterMeasureEnabled = 1; + (suppData->keyMgmtInfoSta).sta_MIC_Error.status = NO_MIC_FAILURE; + KeyMgmtResetCounter(&suppData->keyMgmtInfoSta); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075f54); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void allocSupplicantData(void *connectionPtr) + +{ + char "allocSupplicantData" [20]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"allocSupplicantData"); + if (*(int *)((int)connectionPtr + 8) == 0) { + if ((*(char *)connectionPtr == '\0') && (keyMgmt_SuppData[0].inUse == 0)) { + keyMgmt_SuppData[0].inUse = 1; + supplicantInit(keyMgmt_SuppData); + *(undefined4 *)((int)connectionPtr + 8) = 0x4201153c; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075dc4); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT16 keyMgmtGetKeySize(cm_ConnectionInfo_t *connPtr,UINT8 isPairwise) + +{ + char "keyMgmtGetKeySize" [18]; + UINT16 UVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtGetKeySize"); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075f64); + UVar1 = keyMgmtGetKeySize_internal(&connPtr->suppData->customMIB_RSNConfig,isPairwise); + return UVar1; +} + + + +// WARNING: Variable defined which should be unmapped: key_add_req +// WARNING: Could not reconcile some variable overlaps + +uint8_t add_key_to_mac(cm_ConnectionInfo_t *connPtr,UINT8 pairwise) + +{ + uint32_t uVar1; + uint32_t uVar2; + size_t __n; + uint8_t uVar3; + UINT16 UVar4; + apInfo_t *paVar5; + undefined3 in_register_0000202d; + int iVar6; + KeyData_t *__src; + byte bStack60; + byte bStack59; + mm_key_add_req key_add_req; + + iVar6 = CONCAT31(in_register_0000202d,pairwise); + __n = 0x10; + if (connPtr->conType == '\0') { + UVar4 = keyMgmtGetKeySize(connPtr,pairwise); + __n = (uint)UVar4 & 0xff; + } + memset(&bStack60,0,0x2c); + key_add_req.key.array[7]._3_1_ = iVar6 != 0; + key_add_req.key.array[7]._1_1_ = connPtr->instNbr; + if (iVar6 == 0) { + bStack59 = 0xff; + if (connPtr->conType == '\0') { + __src = &(connPtr->suppData->keyMgmtInfoSta).GRKey; + bStack60 = (byte)(connPtr->suppData->keyMgmtInfoSta).GRKey.KeyIndex; + } + else { + paVar5 = cm_GetApInfo(connPtr); + __src = &(paVar5->bssData).grpKeyData; + bStack60 = (byte)(paVar5->bssData).grpKeyData.KeyIndex; + } + } + else { + bStack59 = connPtr->staId; + if (connPtr->conType == '\0') { + __src = &(connPtr->suppData->keyMgmtInfoSta).PWKey; + } + else { + __src = (KeyData_t *)((connPtr->TxRxCipherKeyBuf).cipher_key.ckd + 0x20); + } + } + memcpy(&key_add_req.key,__src,__n); + uVar2 = key_add_req.key.array[6]; + uVar1 = key_add_req.key.array[3]; + key_add_req.key_idx = (uint8_t)__n; + if (__n == 0x10) { + key_add_req.key.array[7]._0_1_ = 2; + } + else { + if (__n == 0x20) { + key_add_req.key.array[7]._0_1_ = 1; + if (iVar6 != 0) { + key_add_req.key.array[3] = key_add_req.key.array[5]; + key_add_req.key.array[5] = uVar1; + key_add_req.key.array[6] = key_add_req.key.array[4]; + key_add_req.key.array[4] = uVar2; + } + } + else { + if (__n == 0xd) { + key_add_req.key.array[7]._0_1_ = 3; + } + else { + if (__n == 5) { + key_add_req.key.array[7]._0_1_ = 0; + } + else { + assert_err("0","module",0x783); + } + } + } + } + printf("set key:sta_idx:%d, inst_nbr:%d, key_idx:%d,cipher_suite:%d,key_len:%d\r\n",(uint)bStack59 + ,(uint)key_add_req.key.array[7]._1_1_,(uint)bStack60,(uint)(byte)key_add_req.key.array[7], + (uint)key_add_req.key_idx); + uVar3 = mm_sec_machwkey_wr((mm_key_add_req *)&bStack60); + return uVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BufferReturnNotify_t * keyMgmtKeyGroupTxDone(void) + +{ + cm_ConnectionInfo_t *connPtr; + uint8_t uVar1; + cm_ConnectionInfo_t **in_a0; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtKeyGroupTxDone"); + connPtr = *in_a0; + if (connPtr->gtkHwKeyId != -1) { + mm_sec_machwkey_del(connPtr->gtkHwKeyId); + } + uVar1 = add_key_to_mac(connPtr,'\0'); + connPtr->gtkHwKeyId = uVar1; + (connPtr->suppData->keyMgmtInfoSta).RSNDataTrafficEnabled = 1; + if ((connPtr->suppData->keyMgmtInfoSta).RSNSecured == 0) { + (connPtr->suppData->keyMgmtInfoSta).RSNSecured = 1; + sm_handle_supplicant_result(connPtr->staId,0); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"keyMgmtKeyGroupTxDone"); + return (BufferReturnNotify_t *)0x0; +} + + + +// WARNING: Variable defined which should be unmapped: pTxEapol +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +Status_e GenerateGrpMsg2(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta) + +{ + char "GenerateGrpMsg2" [16]; + UINT16 frameLen_00; + BufferDesc_t *pBufDesc; + supplicantData *psVar1; + cm_ConnectionInfo_t *connPtr; + EAPOL_KeyMsg_t *pRxEapol; + UINT16 frameLen; + EAPOL_KeyMsg_Tx_t *pEStack36; + EAPOL_KeyMsg_Tx_t *pTxEapol; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"GenerateGrpMsg2"); + connPtr = (cm_ConnectionInfo_t *)pEAPoLBufDesc->intf; + pRxEapol = (EAPOL_KeyMsg_t *)pEAPoLBufDesc->Buffer; + pBufDesc = GetTxEAPOLBuffer(connPtr,&pEStack36,(BufferDesc_t *)0x0); + if (pBufDesc != (BufferDesc_t *)0x0) { + psVar1 = connPtr->suppData; + KeyMgmtSta_PrepareEAPOLFrame + (pEStack36,pRxEapol,(IEEEtypes_MacAddr_t *)psVar1->localBssid, + (IEEEtypes_MacAddr_t *)psVar1->localStaAddr,(UINT8 *)0x0); + frameLen_00 = KeyMgmtSta_PopulateEAPOLLengthMic + (pEStack36,pKeyMgmtInfoSta->EAPOL_MIC_Key,'\x01','\0'); + keyMgmtKeyGroupTxDone(); + UpdateEAPOLWcbLenAndTransmit(pBufDesc,frameLen_00); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075e40); + } + return (Status_e)(pBufDesc == (BufferDesc_t *)0x0); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +EAPOL_KeyMsg_t * KeyMgmtStaHsk_Recvd_GrpMsg1(BufferDesc_t *pEAPoLBufDesc) + +{ + char "KeyMgmtStaHsk_Recvd_GrpMsg1" [28]; + keyMgmtInfoSta_t *pKeyMgmtInfoSta; + Status_e SVar1; + EAPOL_KeyMsg_t *pEVar2; + undefined3 extraout_var; + + pKeyMgmtInfoSta = (keyMgmtInfoSta_t *)(*(int *)(pEAPoLBufDesc->intf + 8) + 0x54); + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtStaHsk_Recvd_GrpMsg1"); + pEVar2 = ProcessRxEAPOL_GrpMsg1(pEAPoLBufDesc,pKeyMgmtInfoSta); + if ((pEVar2 == (EAPOL_KeyMsg_t *)0x0) || + (SVar1 = GenerateGrpMsg2(pEAPoLBufDesc,pKeyMgmtInfoSta), CONCAT31(extraout_var,SVar1) != 0)) { + pEVar2 = (EAPOL_KeyMsg_t *)0x0; + } + else { + updateApReplayCounter(pKeyMgmtInfoSta,(UINT8 *)pEVar2->replay_cnt); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075e88); + } + return pEVar2; +} + + + +// WARNING: Variable defined which should be unmapped: key_add_req +// WARNING: Could not reconcile some variable overlaps + +uint8_t add_mfp_key_to_mac(cm_ConnectionInfo_t *connPtr,UINT8 pairwise) + +{ + uint8_t uVar1; + UINT16 UVar2; + undefined3 extraout_var; + undefined3 in_register_0000202d; + KeyData_t *__src; + undefined2 uStack60; + mm_key_add_req key_add_req; + + UVar2 = keyMgmtGetKeySize(connPtr,pairwise); + memset(&uStack60,0,0x2c); + key_add_req.key.array[7]._1_1_ = connPtr->instNbr; + key_add_req.key_idx = (uint8_t)((uint)UVar2 & 0xff); + key_add_req.key.array[7]._0_1_ = 5; + uStack60 = 0xff04; + if (CONCAT31(in_register_0000202d,pairwise) == 0) { + if (connPtr->conType != '\0') goto LAB_2300fc4a; + __src = &(connPtr->suppData->keyMgmtInfoSta).GRKey; + } + else { + if (connPtr->conType != '\0') goto LAB_2300fc4a; + __src = &(connPtr->suppData->keyMgmtInfoSta).PWKey; + } + memcpy(&key_add_req.key,__src,(uint)UVar2 & 0xff); +LAB_2300fc4a: + printf("set mfp key:sta_idx:%d, inst_nbr:%d, key_idx:%d,cipher_suite:%d,key_len:%d\r\n", + (uint)uStack60._1_1_,(uint)key_add_req.key.array[7]._1_1_,(uint)(byte)uStack60, + (uint)(byte)key_add_req.key.array[7],(uint)key_add_req.key_idx); + uVar1 = mm_sec_machwkey_wr((mm_key_add_req *)&uStack60); + printf("mfp hw id: %d\n",CONCAT31(extraout_var,uVar1)); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void keyMgmtPlumbPairwiseKey(cm_ConnectionInfo_t *connPtr) + +{ + char "keyMgmtPlumbPairwiseKey" [24]; + uint8_t uVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtPlumbPairwiseKey"); + memcpy(&(connPtr->suppData->keyMgmtInfoSta).PWKey,&(connPtr->suppData->keyMgmtInfoSta).newPWKey, + 0x28); + uVar1 = add_key_to_mac(connPtr,'\x01'); + connPtr->ptkHwKeyId = uVar1; + if ((connPtr->suppData->customMIB_RSNConfig).AKM.akmType == AKM_SHA256_PSK) { + uVar1 = add_mfp_key_to_mac(connPtr,'\x01'); + connPtr->mfpHwKeyId = uVar1; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075f78); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BufferReturnNotify_t * keyMgmtKeyPairwiseTxDone(void) + +{ + cm_ConnectionInfo_t **in_a0; + cm_ConnectionInfo_t *connPtr; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtKeyPairwiseTxDone"); + connPtr = *in_a0; + keyMgmtPlumbPairwiseKey(connPtr); + (connPtr->suppData->keyMgmtInfoSta).pwkHandshakeComplete = 1; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"keyMgmtKeyPairwiseTxDone"); + return (BufferReturnNotify_t *)0x0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +Status_e GeneratePWKMsg4(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta, + BOOLEAN groupKeyReceived) + +{ + char "GeneratePWKMsg4" [16]; + Status_e SVar1; + UINT16 frameLen; + BufferDesc_t *pBufDesc; + supplicantData *psVar2; + cm_ConnectionInfo_t *connPtr; + EAPOL_KeyMsg_t *pRxEapol; + EAPOL_KeyMsg_Tx_t *pEStack52; + EAPOL_KeyMsg_Tx_t *pTxEapol; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"GeneratePWKMsg4"); + connPtr = (cm_ConnectionInfo_t *)pEAPoLBufDesc->intf; + pRxEapol = (EAPOL_KeyMsg_t *)pEAPoLBufDesc->Buffer; + pBufDesc = GetTxEAPOLBuffer(connPtr,&pEStack52,(BufferDesc_t *)0x0); + if (pBufDesc == (BufferDesc_t *)0x0) { + SVar1 = FAIL; + } + else { + psVar2 = connPtr->suppData; + KeyMgmtSta_PrepareEAPOLFrame + (pEStack52,pRxEapol,(IEEEtypes_MacAddr_t *)psVar2->localBssid, + (IEEEtypes_MacAddr_t *)psVar2->localStaAddr,(UINT8 *)0x0); + frameLen = KeyMgmtSta_PopulateEAPOLLengthMic + (pEStack52,pKeyMgmtInfoSta->EAPOL_MIC_Key,'\x01','\0'); + UpdateEAPOLWcbLenAndTransmit(pBufDesc,frameLen); + if (groupKeyReceived == 0) { + keyMgmtKeyPairwiseTxDone(); + } + else { + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtKeyPairAndGroupTxDone"); + keyMgmtKeyPairwiseTxDone(); + keyMgmtKeyGroupTxDone(); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"keyMgmtKeyPairAndGroupTxDone"); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075e30); + SVar1 = FW_SUCCESS; + } + return SVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +EAPOL_KeyMsg_t * KeyMgmtStaHsk_Recvd_PWKMsg3(BufferDesc_t *pEAPoLBufDesc) + +{ + char "KeyMgmtStaHsk_Recvd_PWKMsg3" [28]; + int iVar1; + keyMgmtInfoSta_t *pKeyMgmtInfoSta; + Status_e SVar2; + EAPOL_KeyMsg_t *pEVar3; + undefined3 extraout_var; + + iVar1 = pEAPoLBufDesc->intf; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtStaHsk_Recvd_PWKMsg3"); + pKeyMgmtInfoSta = (keyMgmtInfoSta_t *)(*(int *)(iVar1 + 8) + 0x54); + pEVar3 = ProcessRxEAPOL_PwkMsg3(pEAPoLBufDesc,pKeyMgmtInfoSta); + if ((pEVar3 != (EAPOL_KeyMsg_t *)0x0) && + (SVar2 = GeneratePWKMsg4(pEAPoLBufDesc,pKeyMgmtInfoSta,(uint)(pEVar3->desc_type == '\x02')), + CONCAT31(extraout_var,SVar2) == 0)) { + updateApReplayCounter(pKeyMgmtInfoSta,(UINT8 *)pEVar3->replay_cnt); + pEVar3 = (EAPOL_KeyMsg_t *)0x0; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075e6c); + } + return pEVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ProcessKeyMgmtDataSta(BufferDesc_t *pBufDesc,IEEEtypes_MacAddr_t *sa,IEEEtypes_MacAddr_t *da) + +{ + char "ProcessKeyMgmtDataSta" [22]; + void *pvVar1; + + pvVar1 = pBufDesc->Buffer; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"ProcessKeyMgmtDataSta"); + if ((*(byte *)((int)pvVar1 + 6) & 8) == 0) { + KeyMgmtStaHsk_Recvd_GrpMsg1(pBufDesc); + } + else { + if ((*(byte *)((int)pvVar1 + 5) & 1) == 0) { + KeyMgmtStaHsk_Recvd_PWKMsg1(pBufDesc,sa,da); + } + else { + KeyMgmtStaHsk_Recvd_PWKMsg3(pBufDesc); + } + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075ea4); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT8 ProcessEAPoLPkt(BufferDesc_t *bufDesc,IEEEtypes_MacAddr_t *sa,IEEEtypes_MacAddr_t *da) + +{ + char "ProcessEAPoLPkt" [16]; + UINT8 UVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"ProcessEAPoLPkt"); + if (*(char *)((int)bufDesc->Buffer + 1) == '\x03') { + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"ProcessEAPoLKeyPkt"); + if (*(char *)bufDesc->intf == '\x02') { + ProcessKeyMgmtDataAp(bufDesc); + } + else { + ProcessKeyMgmtDataSta(bufDesc,sa,da); + } + UVar1 = '\x01'; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"ProcessEAPoLKeyPkt"); + } + else { + UVar1 = '\0'; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23075da0); + return UVar1; +} + + + +uchar process_rsn_ie(uint8_t *rsn_ie,Cipher_t *mcstCipher,Cipher_t *ucstCipher, + _Bool *is_pmf_required,SecurityMode_t *security_mode,_Bool wpa2_prefered) + +{ + int iVar1; + UINT8 *__s2; + Cipher_t CVar2; + undefined3 in_register_0000203d; + uint uVar3; + uint8_t *__s1; + uint8_t *__dest; + ushort auStack66 [2]; + uint16_t akmp_count; + + __s1 = rsn_ie + 0xe; + __dest = rsn_ie + 10; + if (*(short *)(rsn_ie + 8) == 2) { + rsn_ie[9] = '\0'; + rsn_ie[1] = rsn_ie[1] + -4; + rsn_ie[8] = '\x01'; + iVar1 = memcmp(__s1,"",4); + if (iVar1 == 0) { + memcpy(__dest,__s1,4); + } + memcpy(__s1,rsn_ie + 0x12,0xc); + } + memcpy(auStack66,__s1,2); + uVar3 = 0; + while (uVar3 < auStack66[0]) { + iVar1 = memcmp(__dest + (uVar3 + 1) * 4 + 2,"",4); + if (iVar1 == 0) { + *(byte *)security_mode = *(byte *)security_mode | 0x20; + } + else { + iVar1 = memcmp(__dest + (uVar3 + 1) * 4 + 2,"",4); + if (iVar1 == 0) { + *(byte *)&security_mode->field_0x1 = *(byte *)&security_mode->field_0x1 | 1; + } + } + uVar3 = uVar3 + 1 & 0xff; + } + if (auStack66[0] == 2) { + rsn_ie[1] = '\x14'; + auStack66[0] = 1; + memcpy(__s1,auStack66,2); + __s1 = rsn_ie + 0x14; + if (CONCAT31(in_register_0000203d,wpa2_prefered) == 0) { + __s2 = ""; + } + else { + __s2 = ""; + } + iVar1 = memcmp(__s1,__s2,4); + if (iVar1 == 0) { + memcpy(rsn_ie + 0x10,__s1,6); + } + memcpy(__s1,rsn_ie + 0x18,2); + } + if (((*(byte *)&security_mode->field_0x1 & 1) != 0) && + (((*(byte *)security_mode & 0x20) == 0 || (CONCAT31(in_register_0000203d,wpa2_prefered) == 0))) + ) { + *is_pmf_required = true; + rsn_ie[0x14] = -0x40; + rsn_ie[0x16] = '\0'; + rsn_ie[1] = rsn_ie[1] + '\x02'; + rsn_ie[0x17] = '\0'; + memcpy(rsn_ie + 0x18,"",4); + rsn_ie[1] = rsn_ie[1] + '\x04'; + } + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t)((byte)*ucstCipher | 8); +LAB_230101f8: + *ucstCipher = CVar2; + } + else { + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t)((byte)*ucstCipher | 4); + goto LAB_230101f8; + } + } + __s1 = rsn_ie + 4; + iVar1 = memcmp(__s1,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t)((byte)*mcstCipher | 8); + } + else { + iVar1 = memcmp(__s1,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t)((byte)*mcstCipher | 4); + } + else { + iVar1 = memcmp(__s1,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t)((byte)*mcstCipher | 2); + } + else { + iVar1 = memcmp(__s1,"",4); + if (iVar1 != 0) goto LAB_2301021a; + CVar2 = (Cipher_t)((byte)*mcstCipher | 1); + } + } + } + *mcstCipher = CVar2; +LAB_2301021a: + return (uchar)(rsn_ie[1] + '\x02'); +} + + + +uchar process_wpa_ie(uint8_t *wpa_ie,Cipher_t *mcstCipher,Cipher_t *ucstCipher) + +{ + int iVar1; + Cipher_t CVar2; + uint8_t *__dest; + uint8_t *__s1; + + __dest = wpa_ie + 0xe; + if (*(short *)(wpa_ie + 0xc) == 2) { + wpa_ie[1] = '\x16'; + __s1 = wpa_ie + 0x12; + wpa_ie[0xc] = '\x01'; + wpa_ie[0xd] = '\0'; + iVar1 = memcmp(__s1,"",4); + if (iVar1 == 0) { + memcpy(__dest,__s1,4); + } + memcpy(__s1,wpa_ie + 0x16,8); + } + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t)((byte)*ucstCipher | 8); +LAB_23010382: + *ucstCipher = CVar2; + } + else { + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t)((byte)*ucstCipher | 4); + goto LAB_23010382; + } + } + __dest = wpa_ie + 8; + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t)((byte)*mcstCipher | 8); + } + else { + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t)((byte)*mcstCipher | 4); + } + else { + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t)((byte)*mcstCipher | 2); + } + else { + iVar1 = memcmp(__dest,"",4); + if (iVar1 != 0) goto LAB_230103a4; + CVar2 = (Cipher_t)((byte)*mcstCipher | 1); + } + } + } + *mcstCipher = CVar2; +LAB_230103a4: + return (uchar)(wpa_ie[1] + '\x02'); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void keyMgmtStaRsnSecuredTimeoutHandler(void *env) + +{ + char "keyMgmtStaRsnSecuredTimeoutHandler" [35]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtStaRsnSecuredTimeoutHandler"); + if ((env != (void *)0x0) && (*(int *)((int)env + 0x78) == 0)) { + sm_handle_supplicant_result(*(uint8_t *)(*(int *)((int)env + 0x118) + 1),0xf); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230762f8); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantGenerateRand(UINT8 *dataOut,UINT32 length) + +{ + char "supplicantGenerateRand" [23]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantGenerateRand"); + bl_rand_stream(dataOut,length); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230760a8); + return; +} + + + +void ComputeEAPOL_MIC(EAPOL_KeyMsg_t *pKeyMsg,UINT16 data_length,UINT8 *MIC_Key,UINT8 MIC_Key_length + ,UINT8 micKeyDescVersion) + +{ + undefined2 in_register_0000202e; + undefined3 in_register_00002035; + undefined3 in_register_00002039; + uint uVar1; + uchar *output; + int iStack24; + int len; + UINT8 *pMicData; + + uVar1 = CONCAT31(in_register_00002039,micKeyDescVersion); + iStack24 = CONCAT22(in_register_0000202e,data_length); + if (uVar1 == 0) { + uVar1 = (uint)*(byte *)&(pKeyMsg->key_info).field_0x1 & 7; + } + output = pKeyMsg->key_MIC; + len = (int)pKeyMsg; + if (uVar1 == 1) { + Bl_hmac_md5((UINT8 *)pKeyMsg,iStack24,MIC_Key,CONCAT31(in_register_00002035,MIC_Key_length), + output); + } + else { + if (uVar1 == 2) { + Bl_hmac_sha1((uchar **)&len,&iStack24,1,MIC_Key,CONCAT31(in_register_00002035,MIC_Key_length), + output,0x10); + } + else { + bl_aes_cmac(MIC_Key,(UINT8 *)pKeyMsg,iStack24,output); + } + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT16 keyMgmtGetKeySize_internal(RSNConfig_t *pRsnConfig,UINT8 isPairwise) + +{ + Cipher_t CVar1; + char "keyMgmtGetKeySize_internal" [27]; + UINT16 UVar2; + undefined3 in_register_0000202d; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtGetKeySize_internal"); + if (CONCAT31(in_register_0000202d,isPairwise) == 0) { + CVar1 = pRsnConfig->mcstCipher; + UVar2 = 0x10; + if (((((byte)CVar1 & 8) == 0) && (UVar2 = 0xd, ((byte)CVar1 & 2) == 0)) && + (UVar2 = 0x20, ((byte)CVar1 & 1) != 0)) { + UVar2 = 5; + } + } + else { + UVar2 = 0x20; + if (((byte)pRsnConfig->ucstCipher & 8) != 0) { + UVar2 = 0x10; + } + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230760c0); + return UVar2; +} + + + +// WARNING: Variable defined which should be unmapped: tmpLo +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int isApReplayCounterFresh(keyMgmtInfoSta_t *pKeyMgmtInfoSta,UINT8 *pRxReplayCount) + +{ + char "isApReplayCounterFresh" [23]; + uint uVar1; + uint uVar2; + uint uVar3; + uint uVar4; + uint uStack24; + UINT32 tmpHi; + UINT32 tmpLo; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"isApReplayCounterFresh"); + memcpy(&uStack24,pRxReplayCount,4); + memcpy(&tmpHi,pRxReplayCount + 4,4); + uVar3 = uStack24 * 0x1000000 + (uStack24 >> 0x18) + (uStack24 & 0xff00) * 0x100 + + (uStack24 >> 8 & 0xff00); + uVar2 = pKeyMgmtInfoSta->apCounterHi; + uVar1 = 1; + if ((uVar3 <= uVar2) && (uVar1 = 0, uVar2 == uVar3)) { + uVar1 = 1; + uVar4 = tmpHi * 0x1000000 + (tmpHi >> 0x18) + (tmpHi & 0xff00) * 0x100 + (tmpHi >> 8 & 0xff00); + uVar3 = pKeyMgmtInfoSta->apCounterLo; + if ((uVar4 <= uVar3) && ((uVar1 = 0, uVar3 == uVar4 && ((uVar2 | uVar3) == 0)))) { + uVar1 = (uint)(pKeyMgmtInfoSta->apCounterZeroDone == 0); + } + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230760dc); + return uVar1; +} + + + +// WARNING: Variable defined which should be unmapped: tmpLo +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void updateApReplayCounter(keyMgmtInfoSta_t *pKeyMgmtStaInfo,UINT8 *pRxReplayCount) + +{ + char "updateApReplayCounter" [22]; + uint uVar1; + uint uVar2; + uint uStack24; + UINT32 tmpHi; + UINT32 tmpLo; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"updateApReplayCounter"); + memcpy(&uStack24,pRxReplayCount,4); + memcpy(&tmpHi,pRxReplayCount + 4,4); + uVar2 = uStack24 * 0x1000000 + (uStack24 >> 0x18) + (uStack24 & 0xff00) * 0x100 + + (uStack24 >> 8 & 0xff00); + uVar1 = tmpHi * 0x1000000 + (tmpHi >> 0x18) + (tmpHi & 0xff00) * 0x100 + (tmpHi >> 8 & 0xff00); + pKeyMgmtStaInfo->apCounterHi = uVar2; + pKeyMgmtStaInfo->apCounterLo = uVar1; + if ((uVar2 | uVar1) == 0) { + pKeyMgmtStaInfo->apCounterZeroDone = 1; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230760f4); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void formEAPOLEthHdr(EAPOL_KeyMsg_Tx_t *pTxEapol,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa) + +{ + char "formEAPOLEthHdr" [16]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"formEAPOLEthHdr"); + memcpy(pTxEapol,da,6); + memcpy((pTxEapol->ethHdr).sa,sa,6); + *(undefined *)&(pTxEapol->ethHdr).type = 0x88; + *(undefined *)((int)&(pTxEapol->ethHdr).type + 1) = 0x8e; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307610c); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN IsEAPOL_MICValid(EAPOL_KeyMsg_t *pKeyMsg,UINT8 *pMICKey) + +{ + UINT8 *__src; + int iVar1; + undefined auStack48 [4]; + UINT8 msgMIC [16]; + + __src = pKeyMsg->key_MIC; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"IsEAPOL_MICValid"); + memcpy(auStack48,__src,0x10); + memset(__src,0,0x10); + ComputeEAPOL_MIC(pKeyMsg,(UINT16)(((uint)CONCAT21((pKeyMsg->hdr_8021x).pckt_body_len, + *(undefined *) + ((int)&(pKeyMsg->hdr_8021x).pckt_body_len + 1)) + + 4) * 0x10000 >> 0x10),pMICKey,'\x10','\0'); + iVar1 = memcmp(__src,auStack48,0x10); + if (iVar1 == 0) { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"IsEAPOL_MICValid"); + } + return (uint)(iVar1 == 0); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT16 KeyMgmtSta_PopulateEAPOLLengthMic + (EAPOL_KeyMsg_Tx_t *pTxEapol,UINT8 *pEAPOLMICKey,UINT8 eapolProtocolVersion, + UINT8 forceKeyDescVersion) + +{ + undefined uVar1; + ushort uVar2; + char "KeyMgmtSta_PopulateEAPOLLengthMic" [34]; + UINT16 UVar3; + uint uVar4; + + UVar3 = 0; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_PopulateEAPOLLengthMic"); + if (pTxEapol != (EAPOL_KeyMsg_Tx_t *)0x0) { + uVar1 = *(undefined *)((int)&(pTxEapol->keyMsg).key_material_len + 1); + uVar2 = (pTxEapol->keyMsg).key_material_len; + uVar4 = (uint)uVar2 + 0x5f & 0xffff; + UVar3 = (UINT16)uVar4; + (pTxEapol->keyMsg).hdr_8021x.pckt_type = IEEE_8021X_PACKET_TYPE_EAPOL_KEY; + *(char *)&(pTxEapol->keyMsg).hdr_8021x.pckt_body_len = (char)(uVar4 >> 8); + *(undefined *)((int)&(pTxEapol->keyMsg).hdr_8021x.pckt_body_len + 1) = (char)uVar4; + *(undefined *)&(pTxEapol->keyMsg).key_material_len = uVar1; + (pTxEapol->keyMsg).hdr_8021x.protocol_ver = eapolProtocolVersion; + *(undefined *)((int)&(pTxEapol->keyMsg).key_material_len + 1) = + (char)((uint)CONCAT21(uVar2,uVar1) >> 8); + ComputeEAPOL_MIC(&pTxEapol->keyMsg,(UINT16)(((uint)uVar2 + 99) * 0x10000 >> 0x10),pEAPOLMICKey, + '\x10',forceKeyDescVersion); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23076130); + } + return UVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +KDE_t * parseKeyKDE(IEEEtypes_InfoElementHdr_t *pIe) + +{ + char "parseKeyKDE" [12]; + int iVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"parseKeyKDE"); + if (((pIe->ElementId != ELEM_ID_VENDOR_SPECIFIC) || (pIe->Len < 8)) || + (iVar1 = memcmp(pIe + 1,"",3), iVar1 != 0)) { + pIe = (IEEEtypes_InfoElementHdr_t *)0x0; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23076154); + } + return (KDE_t *)pIe; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +KDE_t * parseKeyKDE_DataType(UINT8 *pData,SINT32 dataLen,IEEEtypes_KDEDataType_e KDEDataType) + +{ + KDE_t *pKVar1; + undefined3 in_register_00002031; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"parseKeyKDE_DataType"); + if (pData != (UINT8 *)0x0) { + while (2 < dataLen) { + if (((IEEEtypes_InfoElementHdr_t *)pData)->ElementId == ELEM_ID_VENDOR_SPECIFIC) { + pKVar1 = parseKeyKDE((IEEEtypes_InfoElementHdr_t *)pData); + if ((pKVar1 != (KDE_t *)0x0) && + ((uint)pKVar1->dataType == CONCAT31(in_register_00002031,KDEDataType))) { + return pKVar1; + } + if (((IEEEtypes_InfoElementHdr_t *)pData)->Len == '\0') { + dataLen = 2; + } + } + dataLen = dataLen + (-2 - (uint)((IEEEtypes_InfoElementHdr_t *)pData)->Len); + pData = (UINT8 *)(&((IEEEtypes_InfoElementHdr_t *)pData)[1].ElementId + + (uint)((IEEEtypes_InfoElementHdr_t *)pData)->Len); + } + pData = (UINT8 *)0x0; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"parseKeyKDE_DataType"); + } + return (KDE_t *)pData; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +KDE_t * parseKeyDataGTK(UINT8 *pKey,UINT16 len,KeyData_t *pGRKey) + +{ + char "parseKeyDataGTK" [16]; + KDE_t *pKVar1; + undefined2 in_register_0000202e; + undefined auStack40 [4]; + UINT8 buf [8]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"parseKeyDataGTK"); + pKVar1 = parseKeyKDE_DataType(pKey,CONCAT22(in_register_0000202e,len),KDE_DATA_TYPE_GTK); + if (pKVar1 != (KDE_t *)0x0) { + memcpy(pGRKey,&pKVar1[1].length,(uint)pKVar1->length - 6); + pGRKey->KeyIndex = (ushort)pKVar1->data[0] & 3; + memcpy(auStack40,pGRKey->TxMICKey,8); + memcpy(pGRKey->TxMICKey,pGRKey->RxMICKey,8); + memcpy(pGRKey->RxMICKey,auStack40,8); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23076178); + return pKVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmtSta_ApplyKEK(EAPOL_KeyMsg_t *pKeyMsg,KeyData_t *pGRKey,UINT8 *EAPOL_Encr_Key) + +{ + byte bVar1; + undefined uVar2; + uint3 uVar3; + char "KeyMgmtSta_ApplyKEK" [20]; + UINT8 *cipher; + uint uVar4; + int iVar5; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_ApplyKEK"); + bVar1 = pKeyMsg->key_RSC[1]; + cipher = pKeyMsg->key_data; + pGRKey->TxIV16 = (ushort)bVar1 << 8; + pGRKey->TxIV16 = CONCAT11(bVar1,pKeyMsg->key_RSC[0]); + pGRKey->TxIV32 = 0xffffffff; + uVar2 = *(undefined *)((int)&pKeyMsg->key_material_len + 1); + uVar3 = CONCAT21(pKeyMsg->key_material_len,uVar2); + uVar4 = (uint)uVar3 & 0xffff; + *(undefined *)((int)&pKeyMsg->key_material_len + 1) = (char)(uVar4 >> 8); + bVar1 = *(byte *)&(pKeyMsg->key_info).field_0x1; + *(undefined *)&pKeyMsg->key_material_len = uVar2; + if ((bVar1 & 7) == 1) { + RC4_Encrypt(EAPOL_Encr_Key,pKeyMsg->EAPOL_key_IV,0x10,cipher,(ushort)uVar3,0x100); + } + else { + BL_AesUnWrap(EAPOL_Encr_Key,'\x02',(uVar4 >> 3) - 1,cipher,(UINT8 *)0x0,cipher); + iVar5 = (uint)pKeyMsg->key_material_len - 8; + *(char *)&pKeyMsg->key_material_len = (char)((uint)(iVar5 * 0x10000) >> 0x10); + *(undefined *)((int)&pKeyMsg->key_material_len + 1) = (char)((uint)iVar5 >> 8); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23076188); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN KeyMgmtSta_IsRxEAPOLValid(keyMgmtInfoSta_t *pKeyMgmtInfoSta,EAPOL_KeyMsg_t *pKeyMsg) + +{ + BOOLEAN BVar1; + int iVar2; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_IsRxEAPOLValid"); + if ((((pKeyMgmtInfoSta == (keyMgmtInfoSta_t *)0x0) || (pKeyMsg == (EAPOL_KeyMsg_t *)0x0)) || + (iVar2 = isApReplayCounterFresh(pKeyMgmtInfoSta,(UINT8 *)pKeyMsg->replay_cnt), iVar2 == 0)) || + (((*(byte *)&pKeyMsg->key_info & 1) != 0 && + ((((*(byte *)&(pKeyMsg->key_info).field_0x1 & 8) != 0 && + (iVar2 = memcmp(pKeyMsg->key_nonce,pKeyMgmtInfoSta,0x20), iVar2 != 0)) || + (BVar1 = IsEAPOL_MICValid(pKeyMsg,pKeyMgmtInfoSta->EAPOL_MIC_Key), BVar1 == 0)))))) { + BVar1 = 0; + } + else { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_IsRxEAPOLValid"); + BVar1 = 1; + } + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmtSta_PrepareEAPOLFrame + (EAPOL_KeyMsg_Tx_t *pTxEapol,EAPOL_KeyMsg_t *pRxEapol,IEEEtypes_MacAddr_t *da, + IEEEtypes_MacAddr_t *sa,UINT8 *pSNonce) + +{ + byte bVar1; + byte bVar2; + UINT32 UVar3; + char "KeyMgmtSta_PrepareEAPOLFrame" [29]; + byte bVar4; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_PrepareEAPOLFrame"); + if ((pTxEapol != (EAPOL_KeyMsg_Tx_t *)0x0) && (pRxEapol != (EAPOL_KeyMsg_t *)0x0)) { + memset(pTxEapol,0,0x72); + formEAPOLEthHdr(pTxEapol,da,sa); + (pTxEapol->keyMsg).desc_type = pRxEapol->desc_type; + bVar4 = *(byte *)&(pRxEapol->key_info).field_0x1 & 8; + bVar1 = *(byte *)&(pTxEapol->keyMsg).key_info.field_0x1; + bVar2 = *(byte *)&(pTxEapol->keyMsg).key_info; + *(byte *)&(pTxEapol->keyMsg).key_info.field_0x1 = bVar1 & 0xf7 | bVar4; + *(byte *)&(pTxEapol->keyMsg).key_info = bVar2 | 1; + *(byte *)&(pTxEapol->keyMsg).key_info = bVar2 & 0xfd | 1 | *(byte *)&pRxEapol->key_info & 2; + UVar3 = pRxEapol->replay_cnt[0]; + *(char *)(pTxEapol->keyMsg).replay_cnt = (char)*(undefined3 *)pRxEapol->replay_cnt; + *(undefined *)((int)(pTxEapol->keyMsg).replay_cnt + 1) = (char)(UVar3 >> 8); + *(undefined *)((int)(pTxEapol->keyMsg).replay_cnt + 2) = (char)(UVar3 >> 0x10); + *(undefined *)((int)(pTxEapol->keyMsg).replay_cnt + 3) = (char)(UVar3 >> 0x18); + UVar3 = pRxEapol->replay_cnt[1]; + *(char *)((pTxEapol->keyMsg).replay_cnt + 1) = (char)*(undefined3 *)(pRxEapol->replay_cnt + 1); + *(undefined *)((int)(pTxEapol->keyMsg).replay_cnt + 5) = (char)(UVar3 >> 8); + *(undefined *)((int)(pTxEapol->keyMsg).replay_cnt + 6) = (char)(UVar3 >> 0x10); + *(undefined *)((int)(pTxEapol->keyMsg).replay_cnt + 7) = (char)(UVar3 >> 0x18); + *(byte *)&(pTxEapol->keyMsg).key_info.field_0x1 = + bVar1 & 0xf0 | bVar4 | *(byte *)&(pRxEapol->key_info).field_0x1 & 7; + if (pSNonce != (UINT8 *)0x0) { + memcpy((pTxEapol->keyMsg).key_nonce,pSNonce,0x20); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230761b8); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN supplicantAkmIsWpaWpa2(AkmSuite_t *pAkm) + +{ + int iVar1; + BOOLEAN BVar2; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantAkmIsWpaWpa2"); + iVar1 = memcmp(pAkm,"",3); + if ((iVar1 == 0) || (iVar1 = memcmp(pAkm,"",3), iVar1 == 0)) { + BVar2 = 1; + } + else { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"supplicantAkmIsWpaWpa2"); + BVar2 = 0; + } + return BVar2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN supplicantAkmIsWpa2(AkmSuite_t *pAkm) + +{ + int iVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantAkmIsWpa2"); + iVar1 = memcmp(pAkm,"",3); + if (iVar1 != 0) { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"supplicantAkmIsWpa2"); + } + return (uint)(iVar1 == 0); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN supplicantAkmIsWpaWpa2Psk(AkmSuite_t *pAkm) + +{ + char "supplicantAkmIsWpaWpa2Psk" [26]; + uint uVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantAkmIsWpaWpa2Psk"); + uVar1 = supplicantAkmIsWpaWpa2(pAkm); + if (uVar1 == 0) { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23076204); + } + else { + uVar1 = 1; + if ((pAkm->akmType & 0xfb) != 2) { + uVar1 = (uint)(pAkm->akmType == AKM_FT_PSK); + } + } + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN supplicantAkmUsesKdf(AkmSuite_t *pAkm) + +{ + char "supplicantAkmUsesKdf" [21]; + BOOLEAN BVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantAkmUsesKdf"); + BVar1 = supplicantAkmIsWpa2(pAkm); + if ((BVar1 == 0) || (BVar1 = 1, 3 < (byte)(pAkm->akmType + ~AKM_WPA_MAX))) { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23076220); + BVar1 = 0; + } + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantConstructContext + (IEEEtypes_MacAddr_t *pAddr1,IEEEtypes_MacAddr_t *pAddr2,UINT8 *pNonce1, + UINT8 *pNonce2,UINT8 *pContext) + +{ + char "supplicantConstructContext" [27]; + int iVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantConstructContext"); + iVar1 = memcmp(pAddr1,pAddr2,6); + if (iVar1 < 0) { + memcpy(pContext,pAddr1,6); + pAddr1 = pAddr2; + } + else { + memcpy(pContext,pAddr2,6); + } + memcpy(pContext + 6,pAddr1,6); + iVar1 = memcmp(pNonce1,pNonce2,0x20); + if (iVar1 < 0) { + memcpy(pContext + 0xc,pNonce1,0x20); + pNonce1 = pNonce2; + } + else { + memcpy(pContext + 0xc,pNonce2,0x20); + } + memcpy(pContext + 0x2c,pNonce1,0x20); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23076238); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmt_DerivePTK(IEEEtypes_MacAddr_t *pAddr1,IEEEtypes_MacAddr_t *pAddr2,UINT8 *pNonce1, + UINT8 *pNonce2,UINT8 *pPTK,UINT8 *pPMK,BOOLEAN use_kdf) + +{ + char "KeyMgmt_DerivePTK" [18]; + UINT8 *pContext; + + pContext = pPTK + 200; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmt_DerivePTK"); + supplicantConstructContext(pAddr1,pAddr2,pNonce1,pNonce2,pContext); + if (use_kdf == 0) { + Bl_PRF(pPMK,0x20,(uchar *)"Pairwise key expansion",0x16,pContext,0x4c,pPTK,0x40); + } + else { + bl_sha256_crypto_kdf(pPMK,' ',"Pairwise key expansion",'\x16',pContext,0x4c,pPTK,0x180); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23076254); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmtSta_DeriveKeys + (UINT8 *pPMK,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa,UINT8 *ANonce, + UINT8 *SNonce,UINT8 *EAPOL_MIC_Key,UINT8 *EAPOL_Encr_Key,KeyData_t *newPWKey, + BOOLEAN use_kdf) + +{ + char "KeyMgmtSta_DeriveKeys" [22]; + BOOLEAN in_stack_00000000; + UINT8 aUStack548 [4]; + UINT8 pBuf [500]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_DeriveKeys"); + if (((pPMK != (UINT8 *)0x0) && (EAPOL_MIC_Key != (UINT8 *)0x0)) && (newPWKey != (KeyData_t *)0x0)) + { + KeyMgmt_DerivePTK(sa,da,ANonce,SNonce,aUStack548,pPMK,in_stack_00000000); + memcpy(EAPOL_MIC_Key,aUStack548,0x10); + memcpy(EAPOL_Encr_Key,pBuf + 0xc,0x10); + memcpy(newPWKey,pBuf + 0x1c,0x10); + memcpy(newPWKey->RxMICKey,pBuf + 0x2c,8); + memcpy(newPWKey->TxMICKey,pBuf + 0x34,8); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23076268); + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SetEAPOLKeyDescTypeVersion + (EAPOL_KeyMsg_Tx_t *pTxEapol,BOOLEAN isWPA2,BOOLEAN isKDF,BOOLEAN nonTKIP) + +{ + byte bVar1; + char "SetEAPOLKeyDescTypeVersion" [27]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"SetEAPOLKeyDescTypeVersion"); + bVar1 = *(byte *)&(pTxEapol->keyMsg).key_info.field_0x1; + (pTxEapol->keyMsg).desc_type = '\x02'; + *(byte *)&(pTxEapol->keyMsg).key_info.field_0x1 = bVar1 & 0xf8 | (isKDF != 0) + 2U; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23076280); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +EAPOL_KeyMsg_t * +GetKeyMsgNonceFromEAPOL(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta) + +{ + char "GetKeyMsgNonceFromEAPOL" [24]; + EAPOL_KeyMsg_t *pKeyMsg; + BOOLEAN BVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"GetKeyMsgNonceFromEAPOL"); + pKeyMsg = (EAPOL_KeyMsg_t *)pEAPoLBufDesc->Buffer; + BVar1 = KeyMgmtSta_IsRxEAPOLValid(pKeyMgmtInfoSta,pKeyMsg); + if (BVar1 == 0) { + pKeyMsg = (EAPOL_KeyMsg_t *)0x0; + } + else { + if ((*(byte *)&pKeyMsg->key_info & 1) == 0) { + memcpy(pKeyMgmtInfoSta,pKeyMsg->key_nonce,0x20); + supplicantGenerateRand(pKeyMgmtInfoSta->SNonce,0x20); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307629c); + } + return pKeyMsg; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +EAPOL_KeyMsg_t * +ProcessRxEAPOL_PwkMsg3(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta) + +{ + char "ProcessRxEAPOL_PwkMsg3" [23]; + EAPOL_KeyMsg_t *pKeyMsg; + BOOLEAN BVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"ProcessRxEAPOL_PwkMsg3"); + pKeyMsg = GetKeyMsgNonceFromEAPOL(pEAPoLBufDesc,pKeyMgmtInfoSta); + if (pKeyMsg == (EAPOL_KeyMsg_t *)0x0) { +LAB_2301145c: + pKeyMsg = (EAPOL_KeyMsg_t *)0x0; + } + else { + (pKeyMgmtInfoSta->newPWKey).TxIV16 = 1; + (pKeyMgmtInfoSta->newPWKey).TxIV32 = 0; + if ((*(byte *)&pKeyMsg->key_info & 0x10) != 0) { + mm_timer_clear(&pKeyMgmtInfoSta->rsnTimer); + KeyMgmtSta_ApplyKEK(pKeyMsg,&pKeyMgmtInfoSta->GRKey,pKeyMgmtInfoSta->EAPOL_Encr_Key); + BVar1 = keyMgmtProcessMsgExt(pKeyMgmtInfoSta,pKeyMsg); + if (BVar1 == 0) goto LAB_2301145c; + parseKeyDataGTK(pKeyMsg->key_data,pKeyMsg->key_material_len,&pKeyMgmtInfoSta->GRKey); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230762b4); + } + return pKeyMsg; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +EAPOL_KeyMsg_t * +ProcessRxEAPOL_GrpMsg1(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta) + +{ + char "ProcessRxEAPOL_GrpMsg1" [23]; + EAPOL_KeyMsg_t *pKeyMsg; + BOOLEAN BVar1; + KeyData_t *pGRKey; + UINT8 *__src; + UINT8 *__src_00; + undefined auStack40 [4]; + UINT8 buf [8]; + + pKeyMsg = GetKeyMsgNonceFromEAPOL(pEAPoLBufDesc,pKeyMgmtInfoSta); + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"ProcessRxEAPOL_GrpMsg1"); + if (pKeyMsg == (EAPOL_KeyMsg_t *)0x0) { +LAB_23011518: + pKeyMsg = (EAPOL_KeyMsg_t *)0x0; + } + else { + pGRKey = &pKeyMgmtInfoSta->GRKey; + KeyMgmtSta_ApplyKEK(pKeyMsg,pGRKey,pKeyMgmtInfoSta->EAPOL_Encr_Key); + pKeyMgmtInfoSta->RSNDataTrafficEnabled = 1; + mm_timer_clear(&pKeyMgmtInfoSta->rsnTimer); + if (pKeyMsg->desc_type == '\x02') { + parseKeyDataGTK(pKeyMsg->key_data,pKeyMsg->key_material_len,pGRKey); + BVar1 = keyMgmtProcessMsgExt(pKeyMgmtInfoSta,pKeyMsg); + if (BVar1 == 0) goto LAB_23011518; + } + else { + memcpy(pGRKey,pKeyMsg->key_data,(uint)pKeyMsg->key_material_len); + __src_00 = (pKeyMgmtInfoSta->GRKey).TxMICKey; + memcpy(auStack40,__src_00,8); + __src = (pKeyMgmtInfoSta->GRKey).RxMICKey; + memcpy(__src_00,__src,8); + memcpy(__src,auStack40,8); + (pKeyMgmtInfoSta->GRKey).KeyIndex = (ushort)(*(byte *)&(pKeyMsg->key_info).field_0x1 >> 4) & 3 + ; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230762cc); + } + return pKeyMsg; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmtResetCounter(keyMgmtInfoSta_t *pKeyMgmtInfo) + +{ + char "KeyMgmtResetCounter" [20]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtResetCounter"); + if (pKeyMgmtInfo != (keyMgmtInfoSta_t *)0x0) { + pKeyMgmtInfo->staCounterHi = 0; + pKeyMgmtInfo->staCounterLo = 0; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230762e4); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void keyMgmtSta_StartSession_internal(keyMgmtInfoSta_t *pKeyMgmtInfoSta,UINT32 expiry) + +{ + char "keyMgmtSta_StartSession_internal" [33]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtSta_StartSession_internal"); + if ((pKeyMgmtInfoSta->sta_MIC_Error).disableStaAsso == 0) { + mm_timer_set(&pKeyMgmtInfoSta->rsnTimer,_DAT_44b00120 + expiry); + } + pKeyMgmtInfoSta->apCounterLo = 0; + pKeyMgmtInfoSta->apCounterHi = 0; + pKeyMgmtInfoSta->apCounterZeroDone = 0; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307631c); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmtSta_InitSession(keyMgmtInfoSta_t *pKeyMgmtInfoSta) + +{ + char "KeyMgmtSta_InitSession" [23]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_InitSession"); + pKeyMgmtInfoSta->RSNDataTrafficEnabled = 0; + pKeyMgmtInfoSta->RSNSecured = 0; + pKeyMgmtInfoSta->pRxDecryptKey = (cipher_key_t *)0x0; + pKeyMgmtInfoSta->pwkHandshakeComplete = 0; + (pKeyMgmtInfoSta->rsnTimer).cb = keyMgmtStaRsnSecuredTimeoutHandler; + *(keyMgmtInfoSta_t **)&(pKeyMgmtInfoSta->rsnTimer).env = pKeyMgmtInfoSta; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23076340); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void set_psk(char *pSsid,UINT8 ssidLen,char *phrase) + +{ + char "set_psk" [8]; + size_t sVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"set_psk"); + memset(&nohostParams,0xff,0x43); + sVar1 = strlen(phrase); + pmkCacheSetPassphrase((UINT8 *)pSsid,ssidLen,(UINT8 *)phrase,(UINT8)sVar1); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2308ddc4); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void remove_psk(char *pSsid,UINT8 ssidLen) + +{ + char "remove_psk" [11]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"remove_psk"); + pmkCacheDeletePSK((UINT8 *)pSsid,ssidLen); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23076358); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void bl_sha256_crypto_kdf + (UINT8 *pKey,UINT8 key_len,char *label,UINT8 label_len,UINT8 *pContext, + UINT16 context_len,UINT8 *pOutput,UINT16 output_len) + +{ + UINT8 *mac; + undefined3 in_register_0000202d; + undefined2 in_register_0000203e; + undefined2 in_register_00002046; + ushort auStack114 [8]; + ushort uStack98; + UINT16 i; + ushort *puStack96; + UINT8 *vectors [4]; + size_t vectLen [4]; + + uStack98 = 1; + mac = pContext + CONCAT22(in_register_0000203e,context_len); + auStack114[0] = output_len; + while ((uint)uStack98 <= (CONCAT22(in_register_00002046,output_len) + 0xff >> 8 & 0xffU)) { + vectors[3] = (UINT8 *)0x2; + puStack96 = &uStack98; + vectors[0] = (UINT8 *)label; + vectors[1] = pContext; + vectors[2] = (UINT8 *)auStack114; + hmac_sha256_vector(pKey,CONCAT31(in_register_0000202d,key_len),4,(UINT8 **)&stack0xffffffa0, + (size_t *)(vectors + 3),mac); + mac = mac + 0x20; + uStack98 = uStack98 + 1; + } + memcpy(pOutput,pContext + CONCAT22(in_register_0000203e,context_len),(uint)(auStack114[0] >> 3)); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT8 * pmkCacheFindPSK(UINT8 *pSsid,UINT8 ssidLen) + +{ + char "pmkCacheFindPSK" [16]; + pmkElement_t *pPSK; + size_t sVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheFindPSK"); + pPSK = pmkCacheFindPSKElement(pSsid,ssidLen); + if (pPSK == (pmkElement_t *)0x0) { + if (PSKPassPhrase != '\0') { + pmkCacheAddPSK(pSsid,ssidLen,(UINT8 *)0x0,'\0'); + pPSK = pmkCacheFindPSKElement(pSsid,ssidLen); + sVar1 = strlen((char *)PSKPassPhrase); + pPSK = (pmkElement_t *)pPSK->PMK; + pmkCacheGeneratePSK(pSsid,ssidLen,PSKPassPhrase,(UINT8)sVar1,(UINT8 *)pPSK); + } + } + else { + pPSK = (pmkElement_t *)pPSK->PMK; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23076364); + return (UINT8 *)pPSK; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheSetPassphrase(UINT8 *pSsid,UINT8 ssidLen,UINT8 *pPassphrase,UINT8 PassphraseLen) + +{ + char "pmkCacheSetPassphrase" [22]; + pmkElement_t *pSsid_00; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheSetPassphrase"); + if (pPassphrase != (UINT8 *)0x0) { + memcpy(PSKPassPhrase,pPassphrase,0x40); + pmkCacheAddPSK(pSsid,ssidLen,pPassphrase,PassphraseLen); + pSsid_00 = pmkCacheFindPSKElement(pSsid,ssidLen); + pmkCacheGeneratePSK((UINT8 *)pSsid_00,pSsid_00->length,PSKPassPhrase,PassphraseLen,pSsid_00->PMK + ); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23076374); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheInit(void) + +{ + char "pmkCacheInit" [13]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheInit"); + memset(pmkCache,0,0x86); + memset(PSKPassPhrase,0,0x40); + replacementRankMax = '\0'; + dbg_test_print("%dms : Leave: %s\n",0x2307638c); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheRomInit(void) + +{ + char "pmkCacheRomInit" [16]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheRomInit"); + ramHook_MAX_PMK_CACHE_ENTRIES = 2; + ramHook_pmkCache = pmkCache; + ramHook_PSKPassPhrase = PSKPassPhrase; + dbg_test_print("%dms : Leave: %s\n",0x2307639c); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +pmkElement_t * pmkCacheNewElement(void) + +{ + char "pmkCacheNewElement" [19]; + uint uVar1; + pmkElement_t *__s; + pmkElement_t *ppVar2; + + ppVar2 = (pmkElement_t *)0x0; + uVar1 = 0; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheNewElement"); + while ((int)uVar1 < ramHook_MAX_PMK_CACHE_ENTRIES) { + if ((int)replacementRankMax == ramHook_MAX_PMK_CACHE_ENTRIES) { + ramHook_pmkCache[uVar1].replacementRank = ramHook_pmkCache[uVar1].replacementRank + -1; + } + if (ppVar2 == (pmkElement_t *)0x0) { + __s = ramHook_pmkCache + uVar1; + if (__s->replacementRank == '\0') { + memset(__s,0,0x43); + if (replacementRankMax < ramHook_MAX_PMK_CACHE_ENTRIES) { + replacementRankMax = replacementRankMax + '\x01'; + } + ramHook_pmkCache[uVar1].replacementRank = replacementRankMax; + ppVar2 = __s; + } + } + uVar1 = uVar1 + 1 & 0xff; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230763ac); + return ppVar2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheUpdateReplacementRank(pmkElement_t *pPMKElement) + +{ + char cVar1; + SINT8 SVar2; + pmkElement_t *ppVar3; + SINT32 SVar4; + char "pmkCacheUpdateReplacementRank" [30]; + uint uVar5; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheUpdateReplacementRank"); + SVar4 = ramHook_MAX_PMK_CACHE_ENTRIES; + ppVar3 = ramHook_pmkCache; + SVar2 = replacementRankMax; + if ((pPMKElement != (pmkElement_t *)0x0) && (pPMKElement->replacementRank != replacementRankMax)) + { + uVar5 = 0; + while ((int)uVar5 < SVar4) { + cVar1 = ppVar3[uVar5].replacementRank; + if (pPMKElement->replacementRank < cVar1) { + ppVar3[uVar5].replacementRank = cVar1 + -1; + } + uVar5 = uVar5 + 1 & 0xff; + } + pPMKElement->replacementRank = SVar2; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230763c0); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +pmkElement_t * pmkCacheFindPSKElement(UINT8 *pSsid,UINT8 ssidLen) + +{ + char "pmkCacheFindPSKElement" [23]; + uint uVar1; + pmkElement_t *pPMKElement; + pmkElement_t *__s1; + int iVar2; + undefined3 in_register_0000202d; + + pPMKElement = (pmkElement_t *)0x0; + uVar1 = 0; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheFindPSKElement"); + while ((int)uVar1 < ramHook_MAX_PMK_CACHE_ENTRIES) { + __s1 = ramHook_pmkCache + uVar1; + if (((__s1->replacementRank != '\0') && + ((uint)__s1->length == CONCAT31(in_register_0000202d,ssidLen))) && + (iVar2 = memcmp(__s1,pSsid,CONCAT31(in_register_0000202d,ssidLen)), iVar2 == 0)) { + pPMKElement = ramHook_pmkCache + uVar1; + } + uVar1 = uVar1 + 1 & 0xff; + } + pmkCacheUpdateReplacementRank(pPMKElement); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230763e0); + return pPMKElement; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheAddPSK(UINT8 *pSsid,UINT8 ssidLen,UINT8 *pPSK,UINT8 pPSKLen) + +{ + char "pmkCacheAddPSK" [15]; + pmkElement_t *__dest; + undefined3 in_register_0000202d; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheAddPSK"); + __dest = pmkCacheFindPSKElement(pSsid,ssidLen); + if (__dest == (pmkElement_t *)0x0) { + __dest = pmkCacheNewElement(); + memcpy(__dest,pSsid,CONCAT31(in_register_0000202d,ssidLen)); + __dest->length = ssidLen; + } + if (pPSK != (UINT8 *)0x0) { + memcpy(__dest->PMK,pPSK,0x20); + __dest->psk_length = pPSKLen; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230763f8); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheDeletePSK(UINT8 *pSsid,UINT8 ssidLen) + +{ + char "pmkCacheDeletePSK" [18]; + pmkElement_t *__s; + + __s = pmkCacheFindPSKElement(pSsid,ssidLen); + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheDeletePSK"); + if (__s != (pmkElement_t *)0x0) { + memset(__s,0,0x43); + replacementRankMax = replacementRankMax + -1; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23076408); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT8 pmkCacheGetHexNibble(UINT8 nibble) + +{ + undefined3 in_register_00002029; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheGetHexNibble"); + if (CONCAT31(in_register_00002029,nibble) < 0x61) { + if (CONCAT31(in_register_00002029,nibble) < 0x41) { + nibble = nibble + -0x30; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"pmkCacheGetHexNibble"); + } + else { + nibble = nibble + -0x37; + } + } + else { + nibble = nibble + -0x57; + } + return nibble; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheGeneratePSK(UINT8 *pSsid,UINT8 ssidLen,UINT8 *pPassphrase,UINT8 PassphraseLen, + UINT8 *pPSK) + +{ + char "pmkCacheGeneratePSK" [20]; + UINT8 UVar1; + byte bVar2; + undefined3 in_register_0000202d; + undefined3 in_register_00002035; + int iVar3; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheGeneratePSK"); + if ((pPSK != (UINT8 *)0x0) && (pPassphrase != (UINT8 *)0x0)) { + if (CONCAT31(in_register_00002035,PassphraseLen) - 8U < 0x38) { + utils_wifi_psk_cal_fast_bin + ((char *)pPassphrase,pSsid,CONCAT31(in_register_0000202d,ssidLen),pPSK); + } + else { + if (CONCAT31(in_register_00002035,PassphraseLen) == 0x40) { + iVar3 = 0; + do { + UVar1 = pmkCacheGetHexNibble(*pPassphrase); + bVar2 = pmkCacheGetHexNibble(pPassphrase[1]); + pPSK[iVar3 >> 1] = bVar2 | UVar1 << 4; + iVar3 = iVar3 + 2; + pPassphrase = pPassphrase + 2; + } while (iVar3 != 0x40); + } + } + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23076434); + return; +} + + + +void prepare_key(uchar *key_data_ptr,int key_data_len,rc4_key *key) + +{ + byte bVar1; + uchar *puVar2; + rc4_key *prVar3; + uint uVar4; + int iVar5; + uint uVar6; + uint uVar7; + + iVar5 = 0; + do { + key->state[iVar5] = (uchar)iVar5; + iVar5 = iVar5 + 1; + } while (iVar5 != 0x100); + key->x = '\0'; + key->y = '\0'; + uVar7 = 0; + uVar4 = 0; + prVar3 = key; + do { + bVar1 = prVar3->state[0]; + puVar2 = prVar3->state; + uVar6 = (uint)key_data_ptr[uVar4] + (uint)bVar1 + uVar7; + uVar7 = uVar6 & 0xff; + prVar3->state[0] = key->state[uVar6 & 0xff]; + key->state[uVar6 & 0xff] = bVar1; + uVar4 = (int)(uVar4 + 1) % key_data_len & 0xff; + prVar3 = (rc4_key *)(puVar2 + 1); + } while ((rc4_key *)&key->x != (rc4_key *)(puVar2 + 1)); + return; +} + + + +void rc4(uchar *buffer_ptr,int buffer_len,int skip,rc4_key *key) + +{ + byte bVar1; + byte bVar2; + byte *pbVar3; + uint uVar4; + int iVar5; + uint uVar6; + byte *pbVar7; + uint uVar8; + + bVar1 = key->x; + uVar4 = (uint)key->y; + iVar5 = 0; + while (uVar8 = (uint)bVar1 + iVar5 & 0xff, iVar5 < skip) { + bVar2 = key->state[uVar8 + 1 & 0xff]; + uVar4 = uVar4 + bVar2 & 0xff; + iVar5 = (iVar5 + 1) * 0x10000 >> 0x10; + key->state[uVar8 + 1 & 0xff] = key->state[uVar4]; + key->state[uVar4] = bVar2; + } + iVar5 = 0; + while (uVar6 = uVar8 + iVar5 & 0xff, iVar5 < buffer_len) { + pbVar7 = key->state + (uVar6 + 1 & 0xff); + bVar1 = *pbVar7; + uVar4 = uVar4 + (uint)bVar1 & 0xff; + *pbVar7 = key->state[uVar4]; + key->state[uVar4] = bVar1; + pbVar3 = buffer_ptr + iVar5; + iVar5 = (iVar5 + 1) * 0x10000 >> 0x10; + *pbVar3 = key->state[(uint)bVar1 + (uint)*pbVar7 & 0xff] ^ *pbVar3; + } + key->x = (uchar)uVar6; + key->y = (uchar)uVar4; + return; +} + + + +void RC4_Encrypt(uchar *Encr_Key,uchar *IV,ushort iv_length,uchar *Data,ushort data_length, + ushort skipBytes) + +{ + undefined2 in_register_00002032; + size_t __n; + undefined2 in_register_0000203a; + undefined2 in_register_0000203e; + uchar auStack64 [4]; + uchar key [32]; + + __n = CONCAT22(in_register_00002032,iv_length); + if ((int)(__n + 0x10) < 0x21) { + memcpy(auStack64,IV,__n); + memcpy(auStack64 + __n,Encr_Key,0x10); + prepare_key(auStack64,__n + 0x10,&rc4key); + rc4(Data,CONCAT22(in_register_0000203a,data_length),CONCAT22(in_register_0000203e,skipBytes), + &rc4key); + } + return; +} + + + +int sha256_compress(sha256_state *md,UINT8 *msgBuf,UINT8 *pScratchMem) + +{ + UINT32 *pUVar1; + UINT32 *pUVar2; + int iVar3; + uint uVar4; + uint *puVar5; + uint uVar6; + int *piVar7; + int *piVar8; + int iVar9; + int iVar10; + uint uVar11; + int *__dest; + ushort *puVar12; + ushort *puVar13; + uint uVar14; + uint uVar15; + uint uVar16; + + __dest = (int *)(pScratchMem + 0x100); + memcpy(__dest,md->state,0x20); + puVar5 = (uint *)pScratchMem; + puVar12 = (ushort *)msgBuf; + do { + puVar13 = puVar12 + 2; + *puVar5 = (((uint)(*puVar12 >> 8) | ((uint)*puVar12 & 0xff) << 8) << 8 | + (uint)*(byte *)(puVar12 + 1)) << 8 | (uint)*(byte *)((int)puVar12 + 3); + puVar5 = puVar5 + 1; + puVar12 = puVar13; + } while (puVar13 != (ushort *)(msgBuf + 0x40)); + piVar7 = (int *)(pScratchMem + 0x40); + do { + uVar6 = piVar7[-2]; + uVar4 = piVar7[-0xf]; + piVar8 = piVar7 + 1; + *piVar7 = ((uVar6 << 0xf | uVar6 >> 0x11) ^ (uVar6 << 0xd | uVar6 >> 0x13) ^ uVar6 >> 10) + + piVar7[-7] + piVar7[-0x10] + + ((uVar4 >> 7 | uVar4 << 0x19) ^ (uVar4 << 0xe | uVar4 >> 0x12) ^ uVar4 >> 3); + piVar7 = piVar8; + } while (__dest != piVar8); + iVar3 = 0; + do { + uVar4 = *(uint *)(pScratchMem + 0x110); + uVar14 = *(uint *)(pScratchMem + 0x118); + uVar15 = *(uint *)(pScratchMem + 0x114); + uVar6 = *(uint *)(pScratchMem + 0x100); + iVar9 = *(int *)((int)K + iVar3); + uVar11 = *(uint *)(pScratchMem + 0x104); + uVar16 = *(uint *)(pScratchMem + 0x108); + iVar10 = *(int *)(pScratchMem + iVar3); + *(uint *)(pScratchMem + 0x114) = uVar4; + iVar10 = ((uVar4 >> 6 | uVar4 << 0x1a) ^ (uVar4 >> 0xb | uVar4 << 0x15) ^ + (uVar4 << 7 | uVar4 >> 0x19)) + ((uVar14 ^ uVar15) & uVar4 ^ uVar14) + + *(int *)(pScratchMem + 0x11c) + iVar9 + iVar10; + *(int *)(pScratchMem + 0x110) = *(int *)(pScratchMem + 0x10c) + iVar10; + *(uint *)(pScratchMem + 0x104) = uVar6; + *(uint *)(pScratchMem + 0x11c) = uVar14; + *(uint *)(pScratchMem + 0x118) = uVar15; + *(uint *)(pScratchMem + 0x10c) = uVar16; + *(uint *)(pScratchMem + 0x108) = uVar11; + *(uint *)(pScratchMem + 0x100) = + iVar10 + ((uVar6 >> 2 | uVar6 << 0x1e) ^ (uVar6 >> 0xd | uVar6 << 0x13) ^ + (uVar6 << 10 | uVar6 >> 0x16)) + (uVar6 & uVar11 | (uVar6 | uVar11) & uVar16); + iVar3 = iVar3 + 4; + } while (iVar3 != 0x100); + pUVar1 = md->state; + do { + iVar3 = *__dest; + pUVar2 = pUVar1 + 1; + __dest = __dest + 1; + *pUVar1 = *pUVar1 + iVar3; + pUVar1 = pUVar2; + } while (&md->curlen != pUVar2); + return 0; +} + + + +void sha256_init(sha256_state *md) + +{ + *(undefined4 *)&md->length = 0; + md->state[0] = 0x6a09e667; + md->state[1] = 0xbb67ae85; + md->state[2] = 0x3c6ef372; + md->state[3] = 0xa54ff53a; + md->state[4] = 0x510e527f; + md->state[5] = 0x9b05688c; + md->state[6] = 0x1f83d9ab; + md->curlen = 0; + *(undefined4 *)((int)&md->length + 4) = 0; + md->state[7] = 0x5be0cd19; + return; +} + + + +void sha256_vector(size_t num_elem,UINT8 **addr,size_t *len,UINT8 *mac,UINT8 *pScratchMem) + +{ + int iVar1; + uint uVar2; + uint __n; + undefined4 uVar3; + undefined4 uVar4; + undefined4 *puVar5; + uint uVar6; + UINT8 *msgBuf; + UINT8 *pScratchMem_00; + int iVar7; + + pScratchMem_00 = pScratchMem + 0x70; + sha256_init((sha256_state *)pScratchMem); + iVar7 = 0; + do { + __n = *(uint *)(pScratchMem + 0x28); + if (iVar7 == num_elem << 2) { + if (__n < 0x40) { + uVar2 = __n * 8 + *(uint *)pScratchMem; + *(uint *)(pScratchMem + 4) = + (uint)(uVar2 < *(uint *)pScratchMem) + *(int *)(pScratchMem + 4); + *(uint *)pScratchMem = uVar2; + *(uint *)(pScratchMem + 0x28) = __n + 1; + pScratchMem[__n + 0x2c] = -0x80; + if (0x38 < __n + 1) { + while (__n = *(uint *)(pScratchMem + 0x28), __n < 0x40) { + *(uint *)(pScratchMem + 0x28) = __n + 1; + pScratchMem[__n + 0x2c] = '\0'; + } + sha256_compress((sha256_state *)pScratchMem,pScratchMem + 0x2c,pScratchMem_00); + *(undefined4 *)(pScratchMem + 0x28) = 0; + } + while (__n = *(uint *)(pScratchMem + 0x28), __n < 0x38) { + *(uint *)(pScratchMem + 0x28) = __n + 1; + pScratchMem[__n + 0x2c] = '\0'; + } + uVar3 = *(undefined4 *)pScratchMem; + pScratchMem[0x68] = (UINT8)((uint)uVar3 >> 0x18); + pScratchMem[0x69] = (UINT8)((uint)uVar3 >> 0x10); + pScratchMem[0x6b] = (UINT8)uVar3; + uVar4 = *(undefined4 *)(pScratchMem + 4); + pScratchMem[0x6a] = (UINT8)((uint)uVar3 >> 8); + pScratchMem[100] = (UINT8)((uint)uVar4 >> 0x18); + pScratchMem[0x65] = (UINT8)((uint)uVar4 >> 0x10); + pScratchMem[0x67] = (UINT8)uVar4; + pScratchMem[0x66] = (UINT8)((uint)uVar4 >> 8); + sha256_compress((sha256_state *)pScratchMem,pScratchMem + 0x2c,pScratchMem_00); + puVar5 = (undefined4 *)(pScratchMem + 8); + do { + puVar5 = puVar5 + 1; + uVar3 = *puVar5; + *mac = (UINT8)((uint)uVar3 >> 0x18); + mac[1] = (UINT8)((uint)uVar3 >> 0x10); + mac[2] = (UINT8)((uint)uVar3 >> 8); + mac[3] = (UINT8)uVar3; + puVar5 = puVar5; + mac = mac + 4; + } while (puVar5 != (undefined4 *)(pScratchMem + 0x28)); + } + return; + } + msgBuf = *(UINT8 **)((int)addr + iVar7); + uVar2 = *(uint *)((int)len + iVar7); + if (__n < 0x41) { + while (iVar1 = *(int *)(pScratchMem + 0x28), uVar2 != 0) { + if ((iVar1 == 0) && (0x3f < uVar2)) { + iVar1 = sha256_compress((sha256_state *)pScratchMem,msgBuf,pScratchMem_00); + if (iVar1 < 0) break; + uVar6 = *(uint *)pScratchMem; + msgBuf = msgBuf + 0x40; + __n = uVar6 + 0x200; + *(uint *)pScratchMem = __n; + *(uint *)(pScratchMem + 4) = (uint)(__n < uVar6) + *(int *)(pScratchMem + 4); + uVar2 = uVar2 - 0x40; + } + else { + __n = 0x40U - iVar1; + if (uVar2 < 0x40U - iVar1) { + __n = uVar2; + } + memcpy(pScratchMem + 0x2c + iVar1,msgBuf,__n); + iVar1 = *(int *)(pScratchMem + 0x28); + msgBuf = msgBuf + __n; + uVar2 = uVar2 - __n; + *(uint *)(pScratchMem + 0x28) = iVar1 + __n; + if (iVar1 + __n == 0x40) { + iVar1 = sha256_compress((sha256_state *)pScratchMem,pScratchMem + 0x2c,pScratchMem_00); + if (iVar1 < 0) break; + uVar6 = *(uint *)pScratchMem; + *(undefined4 *)(pScratchMem + 0x28) = 0; + __n = uVar6 + 0x200; + *(uint *)pScratchMem = __n; + *(uint *)(pScratchMem + 4) = (uint)(__n < uVar6) + *(int *)(pScratchMem + 4); + } + } + } + } + iVar7 = iVar7 + 4; + } while( true ); +} + + + +// WARNING: Variable defined which should be unmapped: pScratchMem + +void hmac_sha256_vector(UINT8 *key,size_t key_len,size_t num_elem,UINT8 **addr,size_t *len, + UINT8 *mac) + +{ + size_t *mac_00; + UINT8 **ppUVar1; + size_t **ppsVar2; + UINT8 **len_00; + UINT8 **ppUVar3; + size_t *psVar4; + int iVar5; + size_t *psVar6; + size_t sStack600; + uint *apuStack596 [4]; + size_t *psStack580; + UINT8 *_addr [6]; + size_t _len [6]; + UINT8 pScratchMem [500]; + + mac_00 = (size_t *)(pScratchMem + 0x3c); + sStack600 = key_len; + apuStack596[0] = (uint *)key; + if (0x40 < key_len) { + apuStack596[0] = (uint *)key; + sha256_vector(1,(UINT8 **)apuStack596,&sStack600,(UINT8 *)mac_00,pScratchMem + 0x5c); + sStack600 = 0x20; + apuStack596[0] = mac_00; + } + memset(_len + 5,0,0x40); + memcpy(_len + 5,apuStack596[0],sStack600); + psVar6 = _len + 5; + do { + psVar4 = psVar6 + 1; + *psVar6 = *psVar6 ^ 0x36363636; + psVar6 = psVar4; + } while (psVar4 != mac_00); + psStack580 = _len + 5; + len_00 = _addr + 5; + _addr[5] = (UINT8 *)0x40; + iVar5 = 0; + ppsVar2 = &psStack580; + ppUVar3 = len_00; + while( true ) { + ppsVar2 = ppsVar2 + 1; + ppUVar3 = ppUVar3 + 1; + if (iVar5 == num_elem << 2) break; + *ppsVar2 = *(size_t **)((int)addr + iVar5); + ppUVar1 = (UINT8 **)((int)len + iVar5); + iVar5 = iVar5 + 4; + *ppUVar3 = *ppUVar1; + } + sha256_vector(num_elem + 1,(UINT8 **)&psStack580,(size_t *)len_00,mac,pScratchMem + 0x5c); + memset(_len + 5,0,0x40); + memcpy(_len + 5,apuStack596[0],sStack600); + psVar6 = _len + 5; + do { + psVar4 = psVar6 + 1; + *psVar6 = *psVar6 ^ 0x5c5c5c5c; + psVar6 = psVar4; + } while (psVar4 != mac_00); + psStack580 = _len + 5; + _addr[5] = (UINT8 *)0x40; + _len[0] = 0x20; + _addr[0] = mac; + sha256_vector(2,(UINT8 **)&psStack580,(size_t *)len_00,mac,pScratchMem + 0x5c); + return; +} + + + +void KeyMgmtInit(cm_ConnectionInfo_t *connPtr) + +{ + UINT8 ssidLen; + apInfo_t *paVar1; + size_t sVar2; + UINT8 *pPassphrase; + + paVar1 = cm_GetApInfo(connPtr); + ROM_InitGTK(&(paVar1->bssData).grpKeyData,(paVar1->bssData).GNonce,connPtr->localMacAddr); + if ((paVar1->bssData).updatePassPhrase == 1) { + ssidLen = (connPtr->comData).SsIdLen; + pPassphrase = (paVar1->bssConfig).RsnConfig.PSKPassPhrase; + sVar2 = strlen((char *)pPassphrase); + pmkCacheGeneratePSK((UINT8 *)&connPtr->comData,ssidLen,pPassphrase,(UINT8)sVar2, + (paVar1->bssConfig).RsnConfig.PSKValue); + (paVar1->bssData).updatePassPhrase = 0; + } + return; +} + + + +BufferDesc_t * +PrepDefaultEapolMsg(cm_ConnectionInfo_t *connPtr,EAPOL_KeyMsg_Tx_t **pTxEapolPtr, + BufferDesc_t *pBufDesc) + +{ + apSpecificData_t *paVar1; + apInfo_t *paVar2; + BufferDesc_t *pBVar3; + uint nonTKIP; + EAPOL_KeyMsg_Tx_t *pEStack36; + EAPOL_KeyMsg_Tx_t *tx_eapol_ptr; + + paVar1 = cm_GetApData(connPtr); + paVar2 = cm_GetApInfo(connPtr); + pBVar3 = GetTxEAPOLBuffer(connPtr,&pEStack36,pBufDesc); + if (pBVar3 != (BufferDesc_t *)0x0) { + memset(pEStack36,0,0x72); + formEAPOLEthHdr(pEStack36,(IEEEtypes_MacAddr_t *)connPtr->peerMacAddr, + (IEEEtypes_MacAddr_t *)connPtr->localMacAddr); + nonTKIP = 1; + if (((byte)(paVar1->staData).keyMgmtInfo.rom.staUcstCipher & 8) == 0) { + nonTKIP = (uint)((byte)(paVar2->bssConfig).RsnConfig.mcstCipher >> 3) & 1; + } + SetEAPOLKeyDescTypeVersion + (pEStack36,*(uint *)&(paVar1->staData).keyMgmtInfo.rom >> 0x15 & 1,0,nonTKIP); + *pTxEapolPtr = pEStack36; + } + return pBVar3; +} + + + +// WARNING: Variable defined which should be unmapped: replay_cnt + +Status_e GeneratePWKMsg1(cm_ConnectionInfo_t *connPtr,BufferDesc_t *pBufDesc) + +{ + Status_e SVar1; + apSpecificData_t *paVar2; + BufferDesc_t *pBufDesc_00; + uint uVar3; + uint uVar4; + UINT32 UVar5; + EAPOL_KeyMsg_Tx_t *pEStack28; + EAPOL_KeyMsg_Tx_t *tx_eapol_ptr; + UINT32 replay_cnt [2]; + + paVar2 = cm_GetApData(connPtr); + pBufDesc_00 = PrepDefaultEapolMsg(connPtr,&pEStack28,pBufDesc); + if (pBufDesc_00 == (BufferDesc_t *)0x0) { + SVar1 = FAIL; + } + else { + UVar5 = (paVar2->staData).keyMgmtInfo.counterLo + 1; + (paVar2->staData).keyMgmtInfo.counterLo = UVar5; + if (UVar5 == 0) { + (paVar2->staData).keyMgmtInfo.counterHi = (paVar2->staData).keyMgmtInfo.counterHi + 1; + } + tx_eapol_ptr = (EAPOL_KeyMsg_Tx_t *)(paVar2->staData).keyMgmtInfo.counterHi; + supplicantGenerateRand((UINT8 *)&connPtr->TxRxCipherKeyBuf,0x20); + PopulateKeyMsg(pEStack28,&(paVar2->staData).keyMgmtInfo.rom.staUcstCipher,0x800, + (UINT32 *)&tx_eapol_ptr,(UINT8 *)&connPtr->TxRxCipherKeyBuf); + uVar3 = (uint)(pEStack28->keyMsg).key_material_len + 0x5f; + uVar4 = uVar3 & 0xffff; + (pEStack28->keyMsg).hdr_8021x.protocol_ver = (paVar2->staData).keyMgmtInfo.EAPOLProtoVersion; + (pEStack28->keyMsg).hdr_8021x.pckt_type = IEEE_8021X_PACKET_TYPE_EAPOL_KEY; + *(char *)&(pEStack28->keyMsg).hdr_8021x.pckt_body_len = (char)(uVar4 >> 8); + *(undefined *)((int)&(pEStack28->keyMsg).hdr_8021x.pckt_body_len + 1) = (char)uVar4; + UpdateEAPOLWcbLenAndTransmit(pBufDesc_00,(UINT16)(uVar3 * 0x10000 >> 0x10)); + SVar1 = FW_SUCCESS; + } + return SVar1; +} + + + +Status_e GeneratePWKMsg3(cm_ConnectionInfo_t *connPtr,BufferDesc_t *pBufDesc) + +{ + SecurityMode_t SVar1; + UINT16 frameLen; + BufferDesc_t *pBufDesc_00; + apSpecificData_t *paVar2; + apInfo_t *paVar3; + BOOLEAN BVar4; + uint8_t *pWPA2; + UINT32 UVar5; + Cipher_t *Cipher; + EAPOL_KeyMsg_Tx_t *pEStack44; + EAPOL_KeyMsg_Tx_t *tx_eapol_ptr; + UINT32 replay_cnt [2]; + + pBufDesc_00 = PrepDefaultEapolMsg(connPtr,&pEStack44,pBufDesc); + if (pBufDesc_00 != (BufferDesc_t *)0x0) { + paVar2 = cm_GetApData(connPtr); + paVar3 = cm_GetApInfo(connPtr); + UVar5 = (paVar2->staData).keyMgmtInfo.counterLo + 1; + (paVar2->staData).keyMgmtInfo.counterLo = UVar5; + if (UVar5 == 0) { + (paVar2->staData).keyMgmtInfo.counterHi = (paVar2->staData).keyMgmtInfo.counterHi + 1; + } + tx_eapol_ptr = (EAPOL_KeyMsg_Tx_t *)(paVar2->staData).keyMgmtInfo.counterHi; + Cipher = &(paVar2->staData).keyMgmtInfo.rom.staUcstCipher; + PopulateKeyMsg(pEStack44,Cipher, + ((ushort)(paVar2->staData).keyMgmtInfo.rom.staSecType & 0x20) << 10 | 0x880, + (UINT32 *)&tx_eapol_ptr,(UINT8 *)&connPtr->TxRxCipherKeyBuf); + SVar1 = (paVar2->staData).keyMgmtInfo.rom.staSecType; + pWPA2 = (uint8_t *)0x0; + if ((((ushort)SVar1 & 8) == 0) && (((ushort)SVar1 & 0x20) != 0)) { + pWPA2 = int_rsn_ie; + } + BVar4 = KeyData_UpdateKeyMaterial + (pEStack44,&(paVar2->staData).keyMgmtInfo.rom.staSecType,(void *)0x0,pWPA2); + if (BVar4 != 0) { + if (((ushort)(paVar2->staData).keyMgmtInfo.rom.staSecType & 0x20) == 0) { +LAB_230128b6: + frameLen = KeyMgmtSta_PopulateEAPOLLengthMic + (pEStack44,(paVar2->staData).keyMgmtInfo.EAPOL_MIC_Key, + (paVar2->staData).keyMgmtInfo.EAPOLProtoVersion, + *(byte *)&(pEStack44->keyMsg).key_info.field_0x1 & 7); + UpdateEAPOLWcbLenAndTransmit(pBufDesc_00,frameLen); + return FW_SUCCESS; + } + prepareKDE(pEStack44,&(paVar3->bssData).grpKeyData,(Cipher_t *)&(paVar3->bssConfig).RsnConfig) + ; + BVar4 = Encrypt_keyData(pEStack44,(paVar2->staData).keyMgmtInfo.EAPOL_Encr_Key,Cipher); + if (BVar4 != 0) goto LAB_230128b6; + } + vPortFree(pBufDesc_00->Buffer); + vPortFree(pBufDesc_00); + } + return FAIL; +} + + + +Status_e ProcessPWKMsg4(BufferDesc_t *pBufDesc) + +{ + SecurityMode_t SVar1; + cm_ConnectionInfo_t *connPtr; + Status_e SVar2; + apSpecificData_t *paVar3; + BOOLEAN BVar4; + + connPtr = (cm_ConnectionInfo_t *)pBufDesc->intf; + paVar3 = cm_GetApData(connPtr); + BVar4 = IsEAPOL_MICValid((EAPOL_KeyMsg_t *)pBufDesc->Buffer, + (paVar3->staData).keyMgmtInfo.EAPOL_MIC_Key); + if (BVar4 == 0) { + SVar2 = FAIL; + } + else { + (connPtr->TxRxCipherKeyBuf).cipher_key.ckd[0x44] = 1; + (connPtr->TxRxCipherKeyBuf).cipher_key.ckd[0x45] = 0; + (connPtr->TxRxCipherKeyBuf).cipher_key.ckd[0x40] = 0; + (connPtr->TxRxCipherKeyBuf).cipher_key.ckd[0x41] = 0; + (connPtr->TxRxCipherKeyBuf).cipher_key.ckd[0x42] = 0; + (connPtr->TxRxCipherKeyBuf).cipher_key.ckd[0x43] = 0; + add_key_to_mac(connPtr,'\x01'); + apm_sta_add(connPtr->staId); + SVar1 = (paVar3->staData).keyMgmtInfo.rom.staSecType; + (paVar3->staData).keyMgmtInfo.numHskTries = '\0'; + SVar2 = FW_SUCCESS; + if (((ushort)SVar1 & 0x20) != 0) { + (paVar3->staData).keyMgmtInfo.rom.keyMgmtState = HSK_END; + } + } + return SVar2; +} + + + +Status_e GenerateApEapolMsg(cm_ConnectionInfo_t *connPtr,keyMgmtState_e msgState, + BufferDesc_t *pBufDesc) + +{ + IEEEtypes_PwrMgmtMode_e IVar1; + uint uVar2; + Status_e SVar3; + apSpecificData_t *paVar4; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 in_register_0000202d; + + uVar2 = CONCAT31(in_register_0000202d,msgState); + paVar4 = cm_GetApData(connPtr); + if ((msgState & 1) == 0) { + uVar2 = uVar2 - 1 & 0xff; + } + IVar1 = (paVar4->staData).pwrSaveInfo.mode; + (paVar4->staData).keyMgmtInfo.rom.keyMgmtState = (keyMgmtState_e)uVar2; + if (IVar1 != PWR_MODE_PWR_SAVE) { + if (uVar2 == 1) { + SVar3 = GeneratePWKMsg1(connPtr,pBufDesc); + _SVar3 = CONCAT31(extraout_var,SVar3); + } + else { + if (uVar2 != 3) { + if (pBufDesc == (BufferDesc_t *)0x0) { + return FAIL; + } + vPortFree(pBufDesc->Buffer); + vPortFree(pBufDesc); + return FAIL; + } + SVar3 = GeneratePWKMsg3(connPtr,pBufDesc); + _SVar3 = CONCAT31(extraout_var_00,SVar3); + } + if (_SVar3 != 0) { + return (Status_e)_SVar3; + } + (paVar4->staData).keyMgmtInfo.rom.keyMgmtState = + (paVar4->staData).keyMgmtInfo.rom.keyMgmtState + MSG1_PENDING; + } + (paVar4->staData).keyMgmtInfo.numHskTries = (paVar4->staData).keyMgmtInfo.numHskTries + '\x01'; + return FW_SUCCESS; +} + + + +Status_e ProcessPWKMsg2(BufferDesc_t *pBufDesc) + +{ + cm_ConnectionInfo_t *connPtr; + EAPOL_KeyMsg_t *pKeyMsg; + Status_e SVar1; + apSpecificData_t *paVar2; + apInfo_t *paVar3; + BOOLEAN BVar4; + UINT8 *EAPOL_MIC_Key; + BOOLEAN in_fa0; + + connPtr = (cm_ConnectionInfo_t *)pBufDesc->intf; + paVar2 = cm_GetApData(connPtr); + paVar3 = cm_GetApInfo(connPtr); + pKeyMsg = (EAPOL_KeyMsg_t *)pBufDesc->Buffer; + EAPOL_MIC_Key = (paVar2->staData).keyMgmtInfo.EAPOL_MIC_Key; + KeyMgmtAp_DerivePTK((paVar3->bssConfig).RsnConfig.PSKValue, + (IEEEtypes_MacAddr_t *)connPtr->peerMacAddr, + (IEEEtypes_MacAddr_t *)(connPtr->comData).BssId, + (UINT8 *)&connPtr->TxRxCipherKeyBuf,pKeyMsg->key_nonce,EAPOL_MIC_Key, + (paVar2->staData).keyMgmtInfo.EAPOL_Encr_Key, + (KeyData_t *)((connPtr->TxRxCipherKeyBuf).cipher_key.ckd + 0x20),in_fa0); + BVar4 = IsEAPOL_MICValid(pKeyMsg,EAPOL_MIC_Key); + if (BVar4 != 0) { + (paVar2->staData).keyMgmtInfo.numHskTries = '\0'; + rsn_len = pKeyMsg[1].hdr_8021x.protocol_ver + '\x02'; + SVar1 = GenerateApEapolMsg(connPtr,MSG3_PENDING,(BufferDesc_t *)0x0); + return SVar1; + } + return FAIL; +} + + + +BOOLEAN SendEAPOLMsgUsingBufDesc(cm_ConnectionInfo_t *connPtr,BufferDesc_t *pBufDesc) + +{ + keyMgmtState_e msgState; + bool bVar1; + apSpecificData_t *paVar2; + + paVar2 = cm_GetApData(connPtr); + msgState = (paVar2->staData).keyMgmtInfo.rom.keyMgmtState; + bVar1 = (msgState & 1) != 0; + if (bVar1) { + GenerateApEapolMsg(connPtr,msgState,pBufDesc); + } + return (uint)bVar1; +} + + + +// WARNING: Variable defined which should be unmapped: rxCounterLo + +Status_e ProcessKeyMgmtDataAp(BufferDesc_t *pBufDesc) + +{ + keyMgmtState_e kVar1; + Status_e SVar2; + apSpecificData_t *paVar3; + void *pvVar4; + uint uStack24; + UINT32 rxCounterHi; + UINT32 rxCounterLo; + + paVar3 = cm_GetApData((cm_ConnectionInfo_t *)pBufDesc->intf); + pvVar4 = pBufDesc->Buffer; + if ((*(byte *)((int)pvVar4 + 5) & 4) == 0) { + memcpy(&uStack24,(void *)((int)pvVar4 + 9),4); + memcpy(&rxCounterHi,(void *)((int)pvVar4 + 0xd),4); + if (((paVar3->staData).keyMgmtInfo.counterHi == + (uStack24 >> 8 & 0xff00) + + (uStack24 & 0xff00) * 0x100 + uStack24 * 0x1000000 + (uStack24 >> 0x18)) && + ((paVar3->staData).keyMgmtInfo.counterLo == + (rxCounterHi >> 8 & 0xff00) + + rxCounterHi * 0x1000000 + (rxCounterHi >> 0x18) + (rxCounterHi & 0xff00) * 0x100)) { + kVar1 = (paVar3->staData).keyMgmtInfo.rom.keyMgmtState; + if (kVar1 == WAITING_4_MSG2) { + SVar2 = ProcessPWKMsg2(pBufDesc); + return SVar2; + } + if (kVar1 == WAITING_4_MSG4) { + SVar2 = ProcessPWKMsg4(pBufDesc); + return SVar2; + } + } + } + return FAIL; +} + + + +void InitStaKeyInfo(void *pConn,SecurityMode_t *secType,Cipher_t *pwCipher,UINT16 staRsnCap, + UINT8 akmType) + +{ + apKeyMgmtInfoSta_t *__s; + apSpecificData_t *paVar1; + + paVar1 = cm_GetApData((cm_ConnectionInfo_t *)pConn); + __s = &(paVar1->staData).keyMgmtInfo; + memset(__s,0,0x48); + InitKeyMgmtInfo((apKeyMgmtInfoStaRom_t *)__s,secType,pwCipher,staRsnCap,akmType); + (paVar1->staData).keyMgmtInfo.EAPOLProtoVersion = '\x01'; + return; +} + + + +void RemoveAPKeyInfo(void *pConn) + +{ + if (*(uint8_t *)((int)pConn + 3) != -1) { + mm_sec_machwkey_del(*(uint8_t *)((int)pConn + 3)); + return; + } + return; +} + + + +void InitGroupKey(cm_ConnectionInfo_t *connPtr) + +{ + uint8_t uVar1; + apInfo_t *paVar2; + int iVar3; + undefined3 extraout_var; + UINT32 UVar4; + + paVar2 = cm_GetApInfo(connPtr); + (paVar2->bssData).grpRekeyBcnCntConfigured = 0; + (paVar2->bssData).grpRekeyBcnCntRemaining = 0; + KeyMgmtInit(connPtr); + UVar4 = (paVar2->bssConfig).RsnConfig.GrpReKeyTime; + if (UVar4 != 0) { + iVar3 = UVar4 * 0x1e848 + -0x7d; + __udivdi3(); + (paVar2->bssData).grpRekeyBcnCntConfigured = iVar3 + 1U; + (paVar2->bssData).grpRekeyBcnCntRemaining = iVar3 + 1U; + } + uVar1 = add_key_to_mac(connPtr,'\0'); + connPtr->gtkHwKeyId = uVar1; + printf("gtkHwKeyId is %d\r\n",CONCAT31(extraout_var,uVar1)); + return; +} + + + +// WARNING: Variable defined which should be unmapped: inp_data + +void GenerateGTK_internal(KeyData_t *grpKeyData,UINT8 *nonce,IEEEtypes_Addr_t *StaMacAddr) + +{ + size_t prefix_len; + uchar auStack140 [4]; + UINT8 prefix [20]; + UINT8 GTK [32]; + UINT8 grpMasterKey [32]; + UINT8 inp_data [38]; + + memcpy(auStack140,"Group key expansion",0x14); + if ((grpKeyData != (KeyData_t *)0x0) && (nonce != (UINT8 *)0x0)) { + memcpy(grpMasterKey + 0x1c,StaMacAddr,6); + supplicantGenerateRand(nonce,0x20); + memcpy(inp_data + 2,nonce,0x20); + supplicantGenerateRand(GTK + 0x1c,0x20); + prefix_len = strlen((char *)auStack140); + Bl_PRF(GTK + 0x1c,0x20,auStack140,prefix_len,grpMasterKey + 0x1c,0x26,prefix + 0x10,0x20); + memcpy(grpKeyData,prefix + 0x10,0x10); + memcpy(grpKeyData->TxMICKey,GTK + 0xc,8); + memcpy(grpKeyData->RxMICKey,GTK + 0x14,8); + } + return; +} + + + +void PopulateKeyMsg(EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,Cipher_t *Cipher,UINT16 Type,UINT32 *replay_cnt, + UINT8 *Nonce) + +{ + byte bVar1; + undefined2 in_register_00002032; + int iVar2; + undefined uVar3; + byte bVar4; + uint uVar5; + + uVar5 = CONCAT22(in_register_00002032,Type); + if ((tx_eapol_ptr == (EAPOL_KeyMsg_Tx_t *)0x0) || (Cipher == (Cipher_t *)0x0)) { + return; + } + if (((byte)*Cipher & 4) == 0) { + if (((byte)*Cipher & 8) != 0) { + *(undefined *)&(tx_eapol_ptr->keyMsg).key_length = 0; + uVar3 = 0x10; + goto LAB_23012cc4; + } + } + else { + *(undefined *)&(tx_eapol_ptr->keyMsg).key_length = 0; + uVar3 = 0x20; +LAB_23012cc4: + *(undefined *)((int)&(tx_eapol_ptr->keyMsg).key_length + 1) = uVar3; + } + bVar1 = *(byte *)&(tx_eapol_ptr->keyMsg).key_info.field_0x1; + *(byte *)&(tx_eapol_ptr->keyMsg).key_info.field_0x1 = bVar1 | 0x80; + if ((int)(uVar5 << 0x14) < 0) { + *(byte *)&(tx_eapol_ptr->keyMsg).key_info.field_0x1 = bVar1 | 0x88; + if ((Type & 0x80) == 0) goto LAB_23012d0e; + bVar4 = *(byte *)&(tx_eapol_ptr->keyMsg).key_info; + *(byte *)&(tx_eapol_ptr->keyMsg).key_info.field_0x1 = bVar1 | 200; + bVar4 = bVar4 & 0xed | 1 | (byte)((uVar5 >> 0xf) << 1); + bVar1 = (byte)((uVar5 >> 0xf) << 4); + } + else { + bVar1 = (byte)((uVar5 >> 0xf) << 4); + bVar4 = *(byte *)&(tx_eapol_ptr->keyMsg).key_info & 0xec | 3; + } + *(byte *)&(tx_eapol_ptr->keyMsg).key_info = bVar1 | bVar4; +LAB_23012d0e: + uVar5 = *replay_cnt; + iVar2 = uVar5 * 0x1000000 + (uVar5 >> 0x18) + (uVar5 & 0xff00) * 0x100 + (uVar5 >> 8 & 0xff00); + *(char *)(tx_eapol_ptr->keyMsg).replay_cnt = (char)iVar2; + *(undefined *)((int)(tx_eapol_ptr->keyMsg).replay_cnt + 1) = (char)((uint)iVar2 >> 8); + *(undefined *)((int)(tx_eapol_ptr->keyMsg).replay_cnt + 2) = (char)((uint)iVar2 >> 0x10); + *(undefined *)((int)(tx_eapol_ptr->keyMsg).replay_cnt + 3) = (char)((uint)iVar2 >> 0x18); + uVar5 = replay_cnt[1]; + iVar2 = uVar5 * 0x1000000 + (uVar5 >> 0x18) + (uVar5 & 0xff00) * 0x100 + (uVar5 >> 8 & 0xff00); + *(char *)((tx_eapol_ptr->keyMsg).replay_cnt + 1) = (char)iVar2; + *(undefined *)((int)(tx_eapol_ptr->keyMsg).replay_cnt + 5) = (char)((uint)iVar2 >> 8); + *(undefined *)((int)(tx_eapol_ptr->keyMsg).replay_cnt + 6) = (char)((uint)iVar2 >> 0x10); + *(undefined *)((int)(tx_eapol_ptr->keyMsg).replay_cnt + 7) = (char)((uint)iVar2 >> 0x18); + memcpy((tx_eapol_ptr->keyMsg).key_nonce,Nonce,0x20); + return; +} + + + +void prepareKDE(EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,KeyData_t *grKey,Cipher_t *cipher) + +{ + uint uVar1; + uint uVar2; + int iVar3; + UINT8 *pUVar4; + UINT8 *__dest; + + if (tx_eapol_ptr != (EAPOL_KeyMsg_Tx_t *)0x0) { + if ((grKey != (KeyData_t *)0x0) && (cipher != (Cipher_t *)0x0)) { + pUVar4 = (tx_eapol_ptr->keyMsg).key_data + *(byte *)&(tx_eapol_ptr->keyMsg).key_material_len; + *pUVar4 = -0x23; + pUVar4[1] = '\x16'; + pUVar4[2] = '\0'; + pUVar4[3] = '\x0f'; + pUVar4[4] = -0x54; + pUVar4[5] = '\x01'; + pUVar4[6] = pUVar4[6] & 0xfc | 1; + memcpy(pUVar4 + 8,grKey,0x10); + __dest = pUVar4 + 0x18; + if (((byte)*cipher & 4) != 0) { + pUVar4[1] = pUVar4[1] + '\x10'; + memcpy(__dest,grKey->TxMICKey,8); + memcpy(pUVar4 + 0x20,grKey->RxMICKey,8); + __dest = pUVar4 + 0x28; + } + uVar1 = (uint)(tx_eapol_ptr->keyMsg).key_material_len + 2 + (uint)pUVar4[1]; + uVar2 = uVar1 & 0xffff; + *(char *)&(tx_eapol_ptr->keyMsg).key_material_len = (char)(uVar1 * 0x10000 >> 0x10); + *(undefined *)((int)&(tx_eapol_ptr->keyMsg).key_material_len + 1) = (char)(uVar2 >> 8); + uVar1 = -uVar2 & 7; + if (uVar1 != 0) { + *__dest = -0x23; + memset(__dest + 1,0,uVar1 - 1); + iVar3 = uVar1 + (tx_eapol_ptr->keyMsg).key_material_len; + *(char *)&(tx_eapol_ptr->keyMsg).key_material_len = (char)((uint)(iVar3 * 0x10000) >> 0x10); + *(undefined *)((int)&(tx_eapol_ptr->keyMsg).key_material_len + 1) = (char)((uint)iVar3 >> 8) + ; + } + } + return; + } + return; +} + + + +BOOLEAN Encrypt_keyData(EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,UINT8 *EAPOL_Encr_Key,Cipher_t *cipher) + +{ + void *pv; + UINT8 *cipher_00; + uint uVar1; + uint __n; + UINT8 *plain; + UINT8 aUStack48 [4]; + UINT8 key [16]; + + if (((tx_eapol_ptr != (EAPOL_KeyMsg_Tx_t *)0x0) && (EAPOL_Encr_Key != (UINT8 *)0x0)) && + (cipher != (Cipher_t *)0x0)) { + if (((byte)*cipher & 8) == 0) { + return (uint)((byte)*cipher >> 2) & 1; + } + pv = pvPortMalloc(0xc); + if (pv != (void *)0x0) { + cipher_00 = (UINT8 *)pvPortMalloc(400); + *(UINT8 **)((int)pv + 8) = cipher_00; + if (cipher_00 != (UINT8 *)0x0) { + memcpy(aUStack48,EAPOL_Encr_Key,0x10); + plain = (tx_eapol_ptr->keyMsg).key_data; + BL_AesWrap(aUStack48,'\x02',(uint)((tx_eapol_ptr->keyMsg).key_material_len >> 3),plain, + (UINT8 *)0x0,cipher_00); + uVar1 = (uint)(tx_eapol_ptr->keyMsg).key_material_len + 8; + __n = uVar1 & 0xffff; + *(char *)&(tx_eapol_ptr->keyMsg).key_material_len = (char)(uVar1 * 0x10000 >> 0x10); + *(undefined *)((int)&(tx_eapol_ptr->keyMsg).key_material_len + 1) = (char)(__n >> 8); + memcpy(plain,cipher_00,__n); + vPortFree(*(void **)((int)pv + 8)); + vPortFree(pv); + return 1; + } + } + return 0; + } + return 0; +} + + + +void KeyMgmtAp_DerivePTK(UINT8 *pPMK,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa,UINT8 *ANonce, + UINT8 *SNonce,UINT8 *EAPOL_MIC_Key,UINT8 *EAPOL_Encr_Key,KeyData_t *newPWKey + ,BOOLEAN use_kdf) + +{ + undefined auStack24 [4]; + UINT8 tmp [8]; + + KeyMgmtSta_DeriveKeys(pPMK,da,sa,ANonce,SNonce,EAPOL_MIC_Key,EAPOL_Encr_Key,newPWKey,use_kdf); + memcpy(auStack24,newPWKey->RxMICKey,8); + memcpy(newPWKey->RxMICKey,newPWKey->TxMICKey,8); + memcpy(newPWKey->TxMICKey,auStack24,8); + return; +} + + + +BOOLEAN KeyData_CopyWPAWP2(EAPOL_KeyMsg_Tx_t *pTxEAPOL,void *pIe) + +{ + size_t __n; + + if (pIe != (void *)0x0) { + __n = (uint)*(byte *)((int)pIe + 1) + 2; + *(char *)&(pTxEAPOL->keyMsg).key_material_len = (char)__n; + *(undefined *)((int)&(pTxEAPOL->keyMsg).key_material_len + 1) = (char)(__n >> 8); + memcpy((pTxEAPOL->keyMsg).key_data,pIe,__n); + return 1; + } + return 0; +} + + + +BOOLEAN KeyData_UpdateKeyMaterial + (EAPOL_KeyMsg_Tx_t *pTxEAPOL,SecurityMode_t *pSecType,void *pWPA,void *pWPA2) + +{ + BOOLEAN BVar1; + uint uVar2; + + if (((*(byte *)pSecType & 0x18) != 0) || + (uVar2 = 1, pWPA = pWPA2, (*(byte *)pSecType & 0x20) != 0)) { + BVar1 = KeyData_CopyWPAWP2(pTxEAPOL,pWPA); + uVar2 = (uint)(BVar1 != 0); + } + return uVar2; +} + + + +void ROM_InitGTK(KeyData_t *grpKeyData,UINT8 *nonce,IEEEtypes_Addr_t *StaMacAddr) + +{ + grpKeyData->TxIV32 = 0; + *(undefined4 *)&grpKeyData->TxIV16 = 0x10001; + GenerateGTK_internal(grpKeyData,nonce,StaMacAddr); + return; +} + + + +void InitKeyMgmtInfo(apKeyMgmtInfoStaRom_t *pKeyMgmtInfo,SecurityMode_t *secType,Cipher_t *pwCipher, + UINT16 staRsnCap,UINT8 akmType) + +{ + pKeyMgmtInfo->keyMgmtState = MSG1_PENDING; + memcpy(&pKeyMgmtInfo->staSecType,secType,2); + memcpy(&pKeyMgmtInfo->staUcstCipher,pwCipher,1); + pKeyMgmtInfo->staAkmType = akmType; + if ((*(byte *)secType & 0x20) != 0) { + pKeyMgmtInfo->staRsnCap = staRsnCap; + } + return; +} + + + +apInfo_t * cm_GetApInfo(cm_ConnectionInfo_t *connPtr) + +{ + if (connPtr != (cm_ConnectionInfo_t *)0x0) { + if (connPtr->conType == '\x02') { + return *(apInfo_t **)connPtr->specDat; + } + connPtr = (cm_ConnectionInfo_t *)0x0; + } + return (apInfo_t *)connPtr; +} + + + +apSpecificData_t * cm_GetApData(cm_ConnectionInfo_t *connPtr) + +{ + if (connPtr != (cm_ConnectionInfo_t *)0x0) { + if (connPtr->conType == '\x02') { + return (apSpecificData_t *)connPtr->specDat; + } + connPtr = (cm_ConnectionInfo_t *)0x0; + } + return (apSpecificData_t *)connPtr; +} + + + +Status_e cm_AllocAPResources(cm_ConnectionInfo_t *connPtr) + +{ + apSpecificData_t *paVar1; + BufferDesc_t *pBVar2; + void *pvVar3; + + paVar1 = cm_GetApData(connPtr); + if (paVar1->apInfoBuffDesc == (BufferDesc_t *)0x0) { + pBVar2 = (BufferDesc_t *)pvPortMalloc(0xc); + if (pBVar2 == (BufferDesc_t *)0x0) { + return FAIL; + } + pvVar3 = pvPortMalloc(0x120); + pBVar2->Buffer = pvVar3; + paVar1->apInfoBuffDesc = pBVar2; + paVar1->apInfo = (apInfo_t *)pBVar2->Buffer; + InitializeAp(connPtr); + } + return FW_SUCCESS; +} + + + +Status_e cm_AllocResources(cm_ConnectionInfo_t *connPtr) + +{ + Status_e SVar1; + + if (connPtr->conType == '\x02') { + SVar1 = cm_AllocAPResources(connPtr); + return SVar1; + } + return FW_SUCCESS; +} + + + +cm_ConnectionInfo_t * +cm_InitConnection(UINT8 conType,UINT8 bssType,UINT8 bssNum,IEEEtypes_MacAddr_t *bssId, + IEEEtypes_MacAddr_t *peerMacAddr,UINT8 channel,unkbyte0 *hostMdev) + +{ + cm_ConnectionInfo_t *connPtr; + Status_e SVar1; + undefined3 extraout_var; + IEEEtypes_Addr_t *__s; + + connPtr = (cm_ConnectionInfo_t *)pvPortMalloc(0xec); + if (connPtr != (cm_ConnectionInfo_t *)0x0) { + memset(connPtr,0,0xec); + connPtr->conType = conType; + SVar1 = cm_AllocResources(connPtr); + if (CONCAT31(extraout_var,SVar1) == 1) { + vPortFree(connPtr); + connPtr = (cm_ConnectionInfo_t *)0x0; + } + else { + if (peerMacAddr != (IEEEtypes_MacAddr_t *)0x0) { + memcpy(connPtr->peerMacAddr,peerMacAddr,6); + } + __s = (connPtr->comData).BssId; + memset(__s,0,6); + memset(&connPtr->comData,0,0x20); + (connPtr->comData).SsIdLen = '\0'; + if (bssId != (IEEEtypes_MacAddr_t *)0x0) { + memcpy(__s,bssId,6); + memcpy(connPtr->localMacAddr,bssId,6); + } + } + } + return connPtr; +} + + + +void cm_DeleteConnection(cm_ConnectionInfo_t *connPtr) + +{ + apSpecificData_t *paVar1; + + if (connPtr->conType == '\x02') { + paVar1 = cm_GetApData(connPtr); + if (paVar1->apInfoBuffDesc != (BufferDesc_t *)0x0) { + vPortFree(paVar1->apInfoBuffDesc->Buffer); + vPortFree(paVar1->apInfoBuffDesc); + paVar1->apInfoBuffDesc = (BufferDesc_t *)0x0; + paVar1->apInfo = (apInfo_t *)0x0; + } + } + vPortFree(connPtr); + return; +} + + + +void cm_SetPeerAddr(cm_ConnectionInfo_t *connPtr,IEEEtypes_MacAddr_t *bssId, + IEEEtypes_MacAddr_t *peerMacAddr) + +{ + if (bssId != (IEEEtypes_MacAddr_t *)0x0) { + memcpy((connPtr->comData).BssId,bssId,6); + } + if (peerMacAddr != (IEEEtypes_MacAddr_t *)0x0) { + memcpy(connPtr->peerMacAddr,peerMacAddr,6); + return; + } + return; +} + + + +void cm_SetComData(cm_ConnectionInfo_t *connPtr,char *ssid) + +{ + byte bVar1; + size_t sVar2; + + if (ssid != (char *)0x0) { + sVar2 = strlen(ssid); + (connPtr->comData).SsIdLen = (IEEEtypes_Len_t)sVar2; + memcpy(&connPtr->comData,ssid,0x20); + bVar1 = (connPtr->comData).SsIdLen; + if (bVar1 < 0x20) { + (connPtr->comData).SsId[bVar1] = '\0'; + } + return; + } + return; +} + + +/* +Unable to decompile 'assert_rec' +Cause: Exception while decompiling 2301323e: Decompiler process died + +*/ + + +void assert_err(char *condition,char *file,int line) + +{ + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void assert_warn(char *condition,char *file,int line) + +{ + return; +} + + + +void coex_dump_pta(void) + +{ + return; +} + + + +void coex_dump_wifi(void) + +{ + return; +} + + + +void coex_wifi_rf_forece_enable(int enable) + +{ + if (enable != 0) { + enable = 1; + } + rfc_coex_force_to(enable,0); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void coex_wifi_pti_forece_enable(int enable) + +{ + if (enable == 0) { + _DAT_44b00400 = _DAT_44b00400 & 0xffffffef; + } + else { + _DAT_44b00400 = _DAT_44b00400 | 0xf0000010; + } + if ((int)(_DAT_44b00400 << 4) < 0) { + _DAT_44b00400 = _DAT_44b00400 & 0xfbffffff; + } + else { + _DAT_44b00400 = _DAT_44b00400 & 0xfbffffff | 0x4000000; + } + return; +} + + +/* +Unable to decompile 'coex_wifi_pta_forece_enable' +Cause: Exception while decompiling 230132f8: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void wifi_main(void) + +{ + int iVar1; + uint uVar2; + + rfc_init(40000000); + _DAT_44b00400 = _DAT_44b00400 | 1; + mpif_clk_init(); + sysctrl_init(); + intc_init(); + ipc_emb_init(); + bl_init(); + _DAT_44b00404 = 0x24f037; + _DAT_44b00400 = 0x49; + _DAT_44920004 = 0x5010001f; + do { + if (_DAT_44b00120 << 0xc < 0) { + _DAT_44900084 = _DAT_44900084 | 1; + } + else { + _DAT_44900084 = _DAT_44900084 & 0xfffffffe; + } + if (ke_env.evt_field == 0) { + ipc_emb_wait(); + } + if ((packets_num_12624 & 0xf) == 0) { + uVar2 = _DAT_40007018 >> 0x18 & 7; + if (uVar2 != 0) { + if (uVar2 != 3) { + _DAT_40000014 = _DAT_40000014 | 0x40000; + } + if ((uVar2 != 0) && (uVar2 != 3)) { + _DAT_40002040 = _DAT_40002040 & 0xfffffffc; + _DAT_40002044 = _DAT_40002044 & 0xfffffffe; + } + } + if ((_DAT_40007018 >> 0x18 & 4) != 0) { + _DAT_40000014 = _DAT_40000014 | 0x5c2000; + _DAT_4000f90c = _DAT_4000f90c & 0xfffffffe | 4; + } + } + packets_num_12624 = packets_num_12624 + 1; + ke_evt_schedule(); + iVar1 = bl_sleep(); + coex_wifi_pta_forece_enable((uint)(iVar1 == 0)); + } while( true ); +} + + + +void ipc_emb_notify(void) + +{ + BaseType_t BStack20; + BaseType_t xHigherPriorityTaskWoken; + + if (xTaskToNotify == (TaskHandle_t)0x0) { + assert_err("NULL != xTaskToNotify","module",0x93); + } + if (TrapNetCounter == 0) { + xTaskGenericNotify(xTaskToNotify,0,eIncrement,(uint32_t *)0x0); + } + else { + vTaskNotifyGiveFromISR(xTaskToNotify,&BStack20); + if (BStack20 != 0) { + vTaskSwitchContext(); + } + } + return; +} + + + +void ipc_emb_wait(void) + +{ + ulTaskNotifyTake(1,0xffffffff); + ipc_emb_counter = ipc_emb_counter + 1; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_init(void) + +{ + xTaskToNotify = xTaskGetCurrentTaskHandle(); + memset(&ipc_emb_env,0,0x20); + ipc_emb_env.txdesc = ipc_shared_env.txdesc0; + if (_DAT_44800140 != 0x49504332) { + assert_err("ipc_emb_signature_get() == IPC_EMB_SIGNATURE_RESET","module",0xbb); + } + _DAT_4480010c = 0x1f03; + _DAT_44800114 = 0x3ff2a04; + _DAT_44800118 = 0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_tx_irq(void) + +{ + uint uVar1; + + uVar1 = _DAT_4480011c & 0x1f00; + if (uVar1 != 0) { + ke_evt_set(uVar1 >> 1); + _DAT_44800108 = uVar1; + _DAT_44800110 = uVar1; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_tx_evt(int queue_idx) + +{ + txdesc_host *ptVar1; + txdesc_host *ptVar2; + hostdesc *phVar3; + hostdesc *phVar4; + uint event; + hostdesc *__s; + + event = ipc_emb_evt_bit[queue_idx]; + ke_evt_clear(event); + ptVar1 = ipc_emb_env.txdesc; + while( true ) { + ptVar2 = ptVar1 + (ipc_emb_env.txdesc_idx & 3); + if (ptVar2->ready != 0xffffffff) { + _DAT_4480010c = 0x100; + return; + } + if (((event & 0x800) == 0) && ((ke_env.evt_field & 0x440800) != 0)) break; + __s = (hostdesc *)ptVar2->pad_txdesc; + _DAT_44800108 = 0x100; + memset(__s,0,0x2cc); + *(uint32_t **)(ptVar2->pad_txdesc + 0x1c) = ptVar2->pad_txdesc + 0x2e; + *(uint32_t **)(ptVar2->pad_txdesc + 0x1b) = ptVar2->pad_txdesc + 0x1c; + phVar3 = &ptVar2->host; + do { + phVar4 = (hostdesc *)&phVar3->packet_addr; + phVar3[1].packet_addr = phVar3->pbuf_addr; + phVar3 = phVar4; + } while (__s != phVar4); + ptVar2->pad_txdesc[0x19] = 0; + *(undefined4 *)(*(int *)ptVar2->pad_txdesc[0x1b] + 0x10) = 0; + ptVar2->pad_txdesc[0x27] = 0; + ptVar2->pad_txdesc[0x28] = 0; + ptVar2->pad_txdesc[0x29] = 0; + ptVar2->pad_txdesc[0x15] = 0; + txu_cntrl_push(__s,0); + ptVar2->ready = 1; + ipc_emb_env.txdesc_idx = ipc_emb_env.txdesc_idx + 1; + } + ke_evt_set(event); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_cfmback_irq(void) + +{ + uint uVar1; + + uVar1 = _DAT_4480011c; + if ((_DAT_4480011c & 0x20) != 0) { + _DAT_44800110 = 0x20; + _DAT_44800108 = 0x20; + ke_evt_set(0x40000); + } + if ((uVar1 & 0x10) != 0) { + _DAT_44800110 = 0x10; + _DAT_44800108 = 0x10; + ke_evt_set(0x80000); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_txcfm_ind(uint32_t queue_bits) + +{ + _DAT_44800100 = queue_bits << 7; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_msg_irq(void) + +{ + if ((_DAT_4480011c & 2) != 0) { + ke_evt_set(0x2000000); + _DAT_44800110 = 2; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_msg_evt(void) + +{ + undefined4 *puVar1; + uint8_t uVar2; + undefined4 *puVar3; + undefined4 *puVar4; + int iVar5; + + do { + if ((_DAT_44800104 & 2) == 0) { + ke_evt_clear(0x2000000); + _DAT_4480010c = 2; + return; + } + _DAT_44800108 = 2; + puVar1 = (undefined4 *)ke_malloc((uint)ipc_shared_env.msg_a2e_buf.msg[1]._2_2_ + 0xc); + if (puVar1 == (undefined4 *)0x0) { + assert_err("kmsg_dst != NULL","module",0x1d9); + } + *puVar1 = 0; + *(undefined2 *)(puVar1 + 1) = (undefined2)ipc_shared_env.msg_a2e_buf.msg[0]; + *(undefined2 *)((int)puVar1 + 6) = ipc_shared_env.msg_a2e_buf.msg[0]._2_2_; + *(undefined2 *)(puVar1 + 2) = 0xd; + *(ushort *)((int)puVar1 + 10) = ipc_shared_env.msg_a2e_buf.msg[1]._2_2_; + iVar5 = 0xc; + while (iVar5 + -0xc < (int)(uint)*(ushort *)((int)puVar1 + 10)) { + puVar3 = (undefined4 *)((int)&ipc_shared_env.msg_a2e_buf.dummy_word + iVar5); + puVar4 = (undefined4 *)((int)puVar1 + iVar5); + iVar5 = iVar5 + 4; + *puVar4 = *puVar3; + } + uVar2 = ipc_emb_env.ipc_msgacke2a_cnt + '\x01'; + ipc_shared_env.msg_a2e_buf.msg[1]._0_2_ = (ushort)ipc_emb_env.ipc_msgacke2a_cnt; + ipc_emb_env.ipc_msgacke2a_cnt = uVar2; + if (*(ushort *)((int)puVar1 + 6) < 0xf) { + if (0xc < *(ushort *)((int)puVar1 + 6)) goto LAB_2301395c; + } + else { + assert_err("id <= TASK_MAX","module",0xb6); +LAB_2301395c: + assert_err("ke_task_local(kmsg_dst->dest_id)","module",0x1ed); + } + _DAT_44800100 = 4; + ke_msg_send(puVar1 + 3); + } while( true ); +} + + + +void ipc_emb_msg_dma_int_handler(void) + +{ + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_dbg_dma_int_handler(void) + +{ + _DAT_44800100 = 1; + _DAT_44a00020 = 0x80; + return; +} + + + +void ipc_emb_dump(void) + +{ + return; +} + + + +void rf_set_channel(uint8_t bandwidth,uint16_t channel_freq) + +{ + undefined2 in_register_0000202e; + + rfc_config_channel(CONCAT22(in_register_0000202e,channel_freq)); + return; +} + + + +void rf_dump_status(void) + +{ + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mdm_txcbwmax_setf(uint8_t txcbwmax) + +{ + if ((txcbwmax & 0xfc) != 0) { + assert_err("(((uint32_t)txcbwmax << 24) & ~((uint32_t)0x03000000)) == 0","module",0xb58); + } + _DAT_44c00824 = _DAT_44c00824 & 0xfcffffff | (uint)txcbwmax << 0x18; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void phy_config_rxgain(int offset) + +{ + if ((int)rxgain_offset_vs_temperature != offset) { + rxgain_offset_vs_temperature = (int8_t)offset; + _DAT_44c0c080 = + ((int)rxgain_offset_vs_temperature + 0x19) * 0x1000000 | + ((int)rxgain_offset_vs_temperature + 0x12) * 0x10000 & 0xff0000U | + ((int)rxgain_offset_vs_temperature + 0xb) * 0x100 & 0xffffU | + (int)rxgain_offset_vs_temperature + 3U & 0xff; + _DAT_44c0c084 = + ((int)rxgain_offset_vs_temperature + 0x35) * 0x1000000 | + ((int)rxgain_offset_vs_temperature + 0x2d) * 0x10000 & 0xff0000U | + ((int)rxgain_offset_vs_temperature + 0x27) * 0x100 & 0xffffU | + (int)rxgain_offset_vs_temperature + 0x20U & 0xff; + _DAT_44c0c088 = (int)rxgain_offset_vs_temperature + 0x3bU & 0xff | _DAT_44c0c088 & 0xffffff00; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void agc_config(void) + +{ + _ACG_RWNXAGCCNTL = _ACG_RWNXAGCCNTL & 0xfffefbff; + _DAT_44c0b3a4 = _DAT_44c0b3a4 & 0xffff0000; + _DAT_44c0b394 = _DAT_44c0b394 & 0xff00ffff | 0xf80000; + _DAT_44c0b398 = _DAT_44c0b398 & 0xffff00ff | 0x9e00; + _DAT_44c0b3c4 = _DAT_44c0b3c4 & 0xffffff00 | 0xce; + _DAT_44c0b364 = _DAT_44c0b364 & 0xe0c0c0c0 | 0x83c3839; + _DAT_44c0b368 = _DAT_44c0b368 & 0xffc00c00 | 0x70070; + _DAT_44c0b36c = _DAT_44c0b36c & 0xf800f800 | 0x7280512; + _DAT_44c0b370 = _DAT_44c0b370 & 0xff80ffff | 0x580000; + _DAT_44c0b3c0 = _DAT_44c0b3c0 & 0xffffff | 0x18000000; + _DAT_44c0b380 = _DAT_44c0b380 & 0x3ff | 0x77f8400; + _DAT_44c0b384 = _DAT_44c0b384 & 0x3ff | 0xe7750800; + _DAT_44c0b388 = _DAT_44c0b388 & 0x3ff | 0x3d7a9400; + _DAT_44c0b38c = _DAT_44c0b38c & 0x23ff | 0x64038800; + _DAT_44c0c830 = _DAT_44c0c830 & 0x23ff | 0xfc1d9400; + _DAT_44c0c814 = _DAT_44c0c814 & 0xffffffc0 | 8; + _DAT_44c0c040 = _DAT_44c0c040 & 0xfe007fff | 0xc18000; + _DAT_44c0c044 = _DAT_44c0c044 & 0xffff0000 | 0x800; + phy_config_rxgain(0); + _DAT_44c0b3a0 = _DAT_44c0b3a0 & 0xffffff00 | 0x9e; + _DAT_44c0b3c0 = _DAT_44c0b3c0 & 0xffff0000 | 0xa3a4; + _DAT_44c0c82c = _DAT_44c0c82c & 0xff007700 | 0x2009b5; + _DAT_44c0c838 = _DAT_44c0c838 & 0x7ff80000 | 0x80000100; + _DAT_44c0c83c = _DAT_44c0c83c & 0x7ff00000 | 0x8000017c; + _DAT_44c0c840 = _DAT_44c0c840 & 0x7fc00000 | 0x80000100; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mdm_reset(void) + +{ + _DAT_44c00888 = 0; + return; +} + + + +void phy_powroffset_set(int8_t *power_offset) + +{ + int8_t *piVar1; + int8_t *piVar2; + int iVar3; + + iVar3 = 0; + do { + piVar1 = power_offset + iVar3; + piVar2 = poweroffset + iVar3; + iVar3 = iVar3 + 1; + *piVar2 = *piVar1; + } while (iVar3 != 0xe); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void phy_hw_set_channel(uint8_t band,uint16_t freq,uint16_t freq1,uint8_t chantype) + +{ + uint8_t channel; + undefined3 in_register_00002029; + int iVar1; + undefined2 in_register_0000202e; + int iVar2; + undefined3 in_register_00002035; + + iVar2 = CONCAT22(in_register_0000202e,freq); + iVar1 = CONCAT31(in_register_00002029,band); + if (CONCAT31(in_register_00002035,chantype) != 0) { + assert_err("chantype == PHY_CHNL_BW_20","module",0x144); + } + if (iVar1 != 0) { + assert_err("band == PHY_BAND_2G4","module",0x145); + } + _ACG_RWNXAGCCNTL = _ACG_RWNXAGCCNTL & 0xfffffeff; + __DATA_44c00820 = __DATA_44c00820 | 1; + __DATA_44c00800 = 0; + mdm_reset(); + _DAT_44c00838 = 0xb4; + _DAT_44c0088c = 0x1c13; + _DAT_44c00898 = 0x2d00438; + _DAT_44c00858 = _DAT_44c00858 & 0xffffff00; + _DAT_44c0081c = 0xf07; + _DAT_44c00834 = _DAT_44c00834 & 0xffffff | 0x6000000; + _DAT_44c00818 = 0x1880c06; + _DAT_44c00860 = 0x7f03; + _DAT_44c0b340 = 0; + _DAT_44c0b344 = 0; + _DAT_44c0b348 = 0; + mdm_txcbwmax_setf(chantype); + if (_DAT_44c0b000 << 10 < 0) { + _DAT_44c0b118 = 1; + } + rf_set_channel(chantype,freq1); + if (iVar1 == 0) { + channel = '\0'; + if ((0x48 < (iVar2 - 0x96cU & 0xffff)) || (channel = '\x0e', iVar2 == 0x9b4)) goto LAB_230140e2; + iVar1 = -0x967; + } + else { + channel = '\0'; + if ((iVar1 != 1) || (channel = '\0', 0x334 < (iVar2 - 0x138dU & 0xffff))) goto LAB_230140e2; + iVar1 = -5000; + } + channel = (uint8_t)((iVar2 + iVar1) / 5); +LAB_230140e2: + rfc_apply_tx_power_offset(channel,poweroffset); + trpc_update_vs_channel((int8_t)freq1); + return; +} + + + +void phy_get_channel(phy_channel_info *info,uint8_t index) + +{ + info->info1 = (uint)phy_env[0].chnl_type << 8 | (uint)phy_env[0].chnl_prim20_freq << 0x10 | + (uint)phy_env[0].band; + info->info2 = phy_env[0]._6_4_; + return; +} + + + +void phy_set_channel(uint8_t band,uint8_t type,uint16_t prim20_freq,uint16_t center1_freq, + uint16_t center2_freq,uint8_t index) + +{ + undefined3 in_register_00002029; + + if ((((ushort)(center1_freq - 0x96c) < 0x49) || (CONCAT31(in_register_00002029,band) != 0)) && + (CONCAT31(in_register_00002029,band) < 2)) { + phy_hw_set_channel(band,prim20_freq,center1_freq,type); + phy_env[0].chnl_prim20_freq = prim20_freq; + phy_env[0].chnl_center1_freq = center1_freq; + phy_env[0].band = band; + phy_env[0].chnl_type = type; + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void phy_get_version(uint32_t *version_1,uint32_t *version_2) + +{ + *version_1 = __DATA_44c00000; + *version_2 = 0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +_Bool phy_vht_supported(void) + +{ + byte bVar1; + + bVar1 = 1; + if (-1 < __DATA_44c00000 << 9) { + bVar1 = (byte)((uint)__DATA_44c00000 >> 0x19) & 1; + } + return (_Bool)bVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void phy_init(phy_cfg_tag *config) + +{ + uint uVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint32_t uVar3; + uint32_t *puVar4; + uint32_t *puVar5; + uint32_t *puVar6; + + __DATA_44c00800 = 0; + mdm_reset(); + __DATA_44c00820 = 0x20d; + uVar1 = ((__DATA_44c00000 >> 8 & 0xf) - 1 & 0xff) << 4; + if ((uVar1 & 0xffffff8f) != 0) { + assert_err("(((uint32_t)rxnssmax << 4) & ~((uint32_t)0x00000070)) == 0","module",0xa09); + } + __DATA_44c00820 = uVar1 | __DATA_44c00820 & 0xffffff8f; + uVar1 = ((__DATA_44c00000 >> 0xc & 0xf) - 1 & 0xff) << 0xc; + if ((uVar1 & 0xf8000) != 0) { + assert_err("(((uint32_t)rxndpnstsmax << 12) & ~((uint32_t)0x00007000)) == 0","module",0x987); + } + __DATA_44c00820 = __DATA_44c00000 >> 0x13 & 0x100 | uVar1 | __DATA_44c00820 & 0xffff8eff; + _Var2 = phy_vht_supported(); + __DATA_44c00820 = + (__DATA_44c00000 >> 0x1e & 1) << 0x14 | + (__DATA_44c00000 >> 0x1e & 1) << 0x10 | + (CONCAT31(extraout_var,_Var2) << 1 | __DATA_44c00820 & 0xfffffffd) & 0xffeeffff; + _DAT_44c03024 = _DAT_44c03024 & 0xffc0ffff | 0x2d0000; + _DAT_44c0089c = 0xffffffff; + _DAT_44c00824 = 0x20d; + uVar1 = ((__DATA_44c00000 >> 8 & 0xf) - 1 & 0xff) << 4; + if ((uVar1 & 0xffffff8f) != 0) { + assert_err("(((uint32_t)txnssmax << 4) & ~((uint32_t)0x00000070)) == 0","module",0xc0e); + } + _DAT_44c00824 = uVar1 | _DAT_44c00824 & 0xffffff8f; + uVar1 = ((__DATA_44c00000 >> 4 & 0xf) - 1 & 0xff) << 0x14; + if ((uVar1 & 0xf800000) != 0) { + assert_err("(((uint32_t)ntxmax << 20) & ~((uint32_t)0x00700000)) == 0","module",0xb72); + } + _DAT_44c00824 = uVar1 | _DAT_44c00824 & 0xff8fffff; + mdm_txcbwmax_setf((byte)(__DATA_44c00000 >> 0x18) & 3); + _DAT_44c00824 = __DATA_44c00000 >> 0x12 & 0x100 | _DAT_44c00824 & 0xfffffeff; + _Var2 = phy_vht_supported(); + _DAT_44c00824 = + (__DATA_44c00000 >> 0x1f) << 0x10 | + (CONCAT31(extraout_var_00,_Var2) << 1 | _DAT_44c00824 & 0xfffffffd) & 0xfffeffff; + _DAT_44c00834 = _DAT_44c00834 | 1; + _DAT_44c00818 = _DAT_44c00818 & 0xfffbffff; + _DAT_44c00830 = _DAT_44c00830 & 0xffff0000 | 0x1b0f; + _DAT_44c0083c = 0x4920492; + _DAT_44c00874 = _DAT_44c00874 & 0xf7ffffff | 0x8000000; + _DAT_44c0b500 = _DAT_44c0b500 & 0xffffcfff | 0x2000; + if (_DAT_44c0b000 << 10 < 0) { + _DAT_44c0b110 = _DAT_44c0b110 & 0xfffffff0; + _DAT_44c0b118 = 0; + } + _DAT_44c0b004 = 1; + _ACG_RWNXAGCCNTL = _ACG_RWNXAGCCNTL & 0xfffffffc | 1; + _DAT_44c0b3bc = 4000000; + _DAT_44c0b414 = _DAT_44c0b414 | 0x100; + agc_config(); + _ACG_RWNXAGCCNTL = _ACG_RWNXAGCCNTL & 0xffffefff | 0x1000; + _DAT_44c00874 = _DAT_44c00874 & 0xdfffffff | 0x20000000; + puVar6 = agcmem; + puVar4 = (uint32_t *)&DAT_54c0a000; + do { + uVar3 = *puVar6; + puVar5 = puVar4 + 1; + puVar6 = puVar6 + 1; + *puVar4 = uVar3; + puVar4 = puVar5; + } while (puVar5 != (uint32_t *)0x54c0a800); + _DAT_44c00874 = _DAT_44c00874 & 0xdfffffff; + _ACG_RWNXAGCCNTL = _ACG_RWNXAGCCNTL & 0xffffefff; + _DAT_44c0c020 = _DAT_44c0c020 & 0xfc00ffff | 0x140000; + phy_env[0].cfg = config->parameters; + phy_env[0]._4_4_ = 0xff00ff; + phy_env[0]._8_4_ = 0x50000ff; + trpc_init(); + pa_init(); + phy_tcal_reset(); + phy_tcal_start(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t phy_get_nss(void) + +{ + return (uint8_t)(((byte)((uint)__DATA_44c00000 >> 8) & 0xf) - 1); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t phy_get_ntx(void) + +{ + return (uint8_t)(((byte)(__DATA_44c00000 >> 4) & 0xf) - 1); +} + + + +void phy_stop(void) + +{ + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +_Bool phy_ldpc_tx_supported(void) + +{ + return (_Bool)((byte)((uint)__DATA_44c00000 >> 0x1a) & 1); +} + + + +uint8_t phy_get_mac_freq(void) + +{ + return '('; +} + + + +void phy_get_rf_gain_idx(int8_t *power,uint8_t *idx) + +{ + uint32_t uVar1; + + uVar1 = rfc_get_power_level(2,(int)*power * 10); + *idx = (uint8_t)uVar1; + return; +} + + + +void phy_get_rf_gain_capab(int8_t *max,int8_t *min) + +{ + int8_t iVar1; + + iVar1 = trpc_get_rf_max_power(); + *max = iVar1; + iVar1 = trpc_get_rf_min_power(); + *min = iVar1; + return; +} + + + +void mpif_clk_init(void) + +{ + return; +} + + + +void phy_mdm_isr(void) + +{ + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void phy_rc_isr(void) + +{ + _DAT_44c0b420 = _DAT_44c0b41c; + if ((_DAT_44c0b41c & 0x100) != 0) { + mdm_reset(); + return; + } + _DAT_44c0b420 = _DAT_44c0b41c; + return; +} + + + +void pa_init(void) + +{ + int iVar1; + pa_state_t *ppVar2; + pa_state_t *ppVar3; + + ppVar3 = pa_env; + do { + ppVar3->rss_state = '\0'; + ppVar3->rss_count = 0; + ppVar3->last_update = 0; + ppVar3->input_buffer_ptr = '\0'; + ppVar3->ce_state = '\0'; + ppVar3->ce = 0.00000000; + ppVar3->ce_num_up_cmds = '\0'; + ppVar3->ce_num_dn_cmds = '\0'; + iVar1 = 8; + ppVar2 = ppVar3; + do { + ppVar2->input_buffer[0].new = '\0'; + ppVar2->input_buffer[0].rssi = '\0'; + ppVar2->input_buffer[0].lna = '\0'; + ppVar2->input_buffer[0].ppm = 0.00000000; + iVar1 = iVar1 + -1; + ppVar2 = (pa_state_t *)&ppVar2->input_buffer[0].ppm; + } while (iVar1 != 0); + ppVar3 = ppVar3 + 1; + } while (ppVar3 != (pa_state_t *)&tcal_env); + return; +} + + + +// WARNING: Control flow encountered bad instruction data + +void pa_input(uint8_t id,rx_hd *rhd) + +{ + undefined3 in_register_00002029; + uint uVar1; + int iVar2; + + uVar1 = CONCAT31(in_register_00002029,id); + if (uVar1 < 4) { + iVar2 = (int)pa_env[uVar1].input_buffer_ptr; + pa_env[uVar1].last_update = rhd->tsflo; + pa_env[uVar1].input_buffer[iVar2].new = '\x01'; + pa_env[uVar1].input_buffer[iVar2].rssi = *(int8_t *)((int)&rhd->recvec1c + 3); + pa_env[uVar1].input_buffer[iVar2].lna = (char)((int)(rhd->recvec1d << 0x14) >> 0x1c); + if (((rhd->recvec1b & 0x70000) == 0) && ((rhd->recvec1a >> 0xc & 0xf) < 4)) { + __floatsidf((int)*(char *)((int)&rhd->recvec2a + 3)); + __muldf3(); + } + else { + __floatsidf(-(int)*(short *)((int)&rhd->recvec2a + 3)); + __muldf3(); + __divdf3(); + } + __truncdfsf2(); + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); + } + return; +} + + +/* +Unable to decompile 'pa_adapt' +Cause: Exception while decompiling 23014776: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t hal_get_capcode(void) + +{ + return (uint8_t)((byte)(_DAT_4000f884 >> 0x16) & 0x3f); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_set_capcode(uint32_t capcode) + +{ + _DAT_4000f884 = capcode << 0x10 | capcode << 0x16 | _DAT_4000f884 & 0xf000ffff; + return; +} + + + +_Bool hal_get_temperature(int16_t *temperature) + +{ + *temperature = hal_env.temperature; + return true; +} + + + +void hal_set_temperature(int16_t temperature) + +{ + hal_env.temperature = temperature; + return; +} + + + +void trpc_update_power(int8_t (*power_rate_table) [8]) + +{ + int iVar1; + int iVar2; + int iVar3; + int8_t *piVar4; + int8_t *piVar5; + + piVar4 = txpwr_vs_rate_table; + iVar2 = 0; + do { + iVar3 = 0; + do { + iVar1 = iVar3 + iVar2; + piVar5 = piVar4 + iVar3; + iVar3 = iVar3 + 1; + *piVar5 = (*power_rate_table)[iVar1]; + } while (iVar3 != 8); + iVar2 = iVar2 + 8; + piVar4 = piVar4 + 8; + } while (iVar2 != 0x18); + return; +} + + + +void trpc_power_get(int8_t *power_rate_table) + +{ + memcpy(power_rate_table,txpwr_vs_rate_table,0x18); + return; +} + + + +void trpc_update_power_11b(int8_t *power_rate_table) + +{ + int8_t *piVar1; + int8_t *piVar2; + int iVar3; + + iVar3 = 0; + do { + piVar1 = power_rate_table + iVar3; + piVar2 = txpwr_vs_rate_table + iVar3; + iVar3 = iVar3 + 1; + *piVar2 = *piVar1; + } while (iVar3 != 4); + return; +} + + + +void trpc_update_power_11g(int8_t *power_rate_table) + +{ + int8_t *piVar1; + int iVar2; + int8_t *piVar3; + + iVar2 = 0; + piVar3 = txpwr_vs_rate_table; + do { + piVar1 = power_rate_table + iVar2; + iVar2 = iVar2 + 1; + piVar3[8] = *piVar1; + piVar3 = piVar3 + 1; + } while (iVar2 != 8); + return; +} + + + +void trpc_update_power_11n(int8_t *power_rate_table) + +{ + int8_t *piVar1; + int iVar2; + int8_t *piVar3; + + iVar2 = 0; + piVar3 = txpwr_vs_rate_table; + do { + piVar1 = power_rate_table + iVar2; + iVar2 = iVar2 + 1; + piVar3[0x10] = *piVar1; + piVar3 = piVar3 + 1; + } while (iVar2 != 8); + return; +} + + + +void trpc_init(void) + +{ + int32_t iVar1; + + DAT_4201d148 = 0x98a; + iVar1 = rf_pri_get_txgain_max(); + trpc_env = (undefined)iVar1; + iVar1 = rf_pri_get_txgain_min(); + pwr_dbm_bottom = (int8_t)iVar1; + DAT_4201d146 = 0x1e; + DAT_4201d14a = 0x19; + return; +} + + + +int8_t trpc_get_rf_max_power(void) + +{ + return trpc_env; +} + + + +int8_t trpc_get_rf_min_power(void) + +{ + return pwr_dbm_bottom; +} + + + +uint8_t trpc_get_power_idx(uint8_t formatmod,uint8_t mcs,int8_t pwr_dbm) + +{ + int8_t pwr_dbm_bottom; + undefined3 in_register_00002029; + uint uVar1; + undefined3 in_register_0000202d; + int iVar2; + undefined3 in_register_00002031; + char cVar3; + uint uVar4; + char cVar5; + int iVar6; + + uVar1 = CONCAT31(in_register_00002029,formatmod); + uVar4 = 2; + if (uVar1 < 3) { + uVar4 = (uint)formatmod; + } + iVar6 = 3; + if (uVar1 != 0) { + iVar6 = 7; + } + cVar5 = DAT_4201d146; + if ((int)trpc_env < (int)DAT_4201d146) { + cVar5 = trpc_env; + } + if (CONCAT31(in_register_00002031,pwr_dbm) < (int)cVar5) { + cVar5 = pwr_dbm; + } + iVar2 = CONCAT31(in_register_0000202d,mcs); + if (iVar6 < CONCAT31(in_register_0000202d,mcs)) { + iVar2 = iVar6; + } + cVar3 = txpwr_vs_rate_table[iVar2 + uVar4 * 8]; + if (cVar5 < txpwr_vs_rate_table[iVar2 + uVar4 * 8]) { + cVar3 = cVar5; + } + if (pwr_dbm_bottom < cVar3) { + pwr_dbm_bottom = cVar3; + } + __floatsidf(((int)pwr_dbm_bottom * -0x1fe + (int)trpc_env) / 0x200); + __adddf3(); + uVar4 = __fixdfsi(); + iVar6 = 3; + if (uVar1 != 0) { + iVar6 = 0; + } + uVar4 = iVar6 + (uVar4 & 0xff) & 0xff; + if (0xf < uVar4) { + uVar4 = 0xf; + } + return (uint8_t)(uVar4 << 2); +} + + + +uint8_t trpc_get_default_power_idx(uint8_t formatmod,uint8_t mcs) + +{ + uint8_t uVar1; + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + int iVar2; + uint uVar3; + int iVar4; + + uVar3 = (uint)formatmod; + if (2 < CONCAT31(in_register_00002029,formatmod)) { + uVar3 = 2; + } + iVar4 = 3; + if (CONCAT31(in_register_00002029,formatmod) != 0) { + iVar4 = 7; + } + iVar2 = CONCAT31(in_register_0000202d,mcs); + if (iVar4 < CONCAT31(in_register_0000202d,mcs)) { + iVar2 = iVar4; + } + uVar1 = trpc_get_power_idx((uint8_t)uVar3,(uint8_t)iVar2,txpwr_vs_rate_table[iVar2 + uVar3 * 8]); + return uVar1; +} + + + +void trpc_update_vs_channel(int8_t channel_MHz) + +{ + undefined3 in_register_00002029; + int32_t iVar1; + + DAT_4201d148 = (undefined2)CONCAT31(in_register_00002029,channel_MHz); + iVar1 = rf_pri_get_txgain_max(); + trpc_env = (undefined)iVar1; + iVar1 = rf_pri_get_txgain_min(); + pwr_dbm_bottom = (int8_t)iVar1; + return; +} + + + +void trpc_update_vs_temperature(int8_t temperature) + +{ + int32_t iVar1; + + DAT_4201d14a._0_1_ = temperature; + iVar1 = rf_pri_get_txgain_max(); + trpc_env = (undefined)iVar1; + iVar1 = rf_pri_get_txgain_min(); + pwr_dbm_bottom = (int8_t)iVar1; + return; +} + + + +void phy_tcal_reset(void) + +{ + memset(&tcal_env,0,0x38); + tcal_env.prev_temperature = 0x19; + tcal_env.last_action_temperature[0] = 0x19; + tcal_env.last_action_temperature[1] = 0x19; + tcal_env.last_action_temperature[2] = 0x19; + tcal_env.last_action_temperature[3] = 0x19; + tcal_env.enabled = true; + return; +} + + + +void phy_tcal_start(void) + +{ + tcal_env.enabled = true; + return; +} + + + +void phy_tcal_txpwr(int16_t curr_temperature) + +{ + undefined2 in_register_0000202a; + + rf_pri_tx_gain_comp(CONCAT22(in_register_0000202a,curr_temperature)); + trpc_update_vs_temperature((int8_t)curr_temperature); + return; +} + + +/* +Unable to decompile 'phy_tcal_handle' +Cause: Exception while decompiling 23014d24: Decompiler process died + +*/ + + +void phy_tcal_callback(int16_t temperature) + +{ + hal_set_temperature(temperature); + if (tcal_env.enabled != false) { + phy_tcal_handle(); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_fsm_ctrl_en_setf(uint32_t x) + +{ + _DAT_40001004 = x << 1 | _DAT_40001004 & 0xfffffffd; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_fsm_st_dbg_en_setf(uint32_t x) + +{ + _DAT_4000126c = x << 3 | _DAT_4000126c & 0xfffffff7; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc3_setf(uint32_t x) + +{ + _DAT_40001630 = (x & 0x7f) << 0x18 | _DAT_40001630 & 0x80ffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc2_setf(uint32_t x) + +{ + _DAT_40001630 = (x & 0x7f) << 0x10 | _DAT_40001630 & 0xff80ffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc1_setf(uint32_t x) + +{ + _DAT_40001630 = (x & 0x7f) << 8 | _DAT_40001630 & 0xffff80ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc0_setf(uint32_t x) + +{ + _DAT_40001630 = x & 0x7f | _DAT_40001630 & 0xffffff80; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc7_setf(uint32_t x) + +{ + _DAT_40001634 = (x & 0x7f) << 0x18 | _DAT_40001634 & 0x80ffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc6_setf(uint32_t x) + +{ + _DAT_40001634 = (x & 0x7f) << 0x10 | _DAT_40001634 & 0xff80ffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc5_setf(uint32_t x) + +{ + _DAT_40001634 = (x & 0x7f) << 8 | _DAT_40001634 & 0xffff80ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc4_setf(uint32_t x) + +{ + _DAT_40001634 = x & 0x7f | _DAT_40001634 & 0xffffff80; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc11_setf(uint32_t x) + +{ + _DAT_40001638 = (x & 0x7f) << 0x18 | _DAT_40001638 & 0x80ffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc10_setf(uint32_t x) + +{ + _DAT_40001638 = (x & 0x7f) << 0x10 | _DAT_40001638 & 0xff80ffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc9_setf(uint32_t x) + +{ + _DAT_40001638 = (x & 0x7f) << 8 | _DAT_40001638 & 0xffff80ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc8_setf(uint32_t x) + +{ + _DAT_40001638 = x & 0x7f | _DAT_40001638 & 0xffffff80; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc15_setf(uint32_t x) + +{ + _DAT_4000163c = (x & 0x7f) << 0x18 | _DAT_4000163c & 0x80ffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc14_setf(uint32_t x) + +{ + _DAT_4000163c = (x & 0x7f) << 0x10 | _DAT_4000163c & 0xff80ffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc13_setf(uint32_t x) + +{ + _DAT_4000163c = (x & 0x7f) << 8 | _DAT_4000163c & 0xffff80ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc12_setf(uint32_t x) + +{ + _DAT_4000163c = x & 0x7f | _DAT_4000163c & 0xffffff80; + return; +} + + + +void wait_us(uint32_t us) + +{ + bool bVar1; + uint32_t n; + int iStack4; + + iStack4 = us << 4; + do { + bVar1 = iStack4 != 0; + iStack4 = iStack4 + -1; + } while (bVar1); + return; +} + + + +void _print_channel_info(void) + +{ + int iVar1; + + iVar1 = 8; + do { + iVar1 = iVar1 + -1; + wait_us(1000); + } while (iVar1 != 0); + iVar1 = 8; + do { + iVar1 = iVar1 + -1; + wait_us(1000); + } while (iVar1 != 0); + return; +} + + + +// WARNING: Control flow encountered bad instruction data + +void rfc_init(uint32_t xtalfreq_hz) + +{ + uint32_t rfg_index; + uint32_t dg; + + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rfc_rxdfe_set_notch0(uint8_t en,uint8_t alpha,int8_t nrmfc) + +{ + _DAT_40001700 = + ((uint)en & 1) << 6 | (uint)(byte)nrmfc << 8 | (uint)alpha & 7 | _DAT_40001700 & 0xffff00b8; + return; +} + + + +// WARNING: Variable defined which should be unmapped: ncf_freq_hz +// WARNING: Could not reconcile some variable overlaps +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rfc_config_channel(uint32_t channel_freq) + +{ + SItype SVar1; + uint8_t uStack21; + uint8_t ncf_on; + SItype SStack20; + int32_t ncf_freq_hz; + + _DAT_40001228 = _DAT_40001228 | 8; + _DAT_4000100c = _DAT_4000100c | 0x241; + _DAT_40001264 = channel_freq & 0xfff | _DAT_40001264 & 0xfffff000; + _DAT_40001268 = _DAT_40001268 & 0xfffdffff | 0x20000; + wait_us(10); + _DAT_40001268 = _DAT_40001268 & 0xfffdffff; + wait_us(10); + rf_fsm_ctrl_en_setf(0); + wait_us(10); + rf_fsm_ctrl_en_setf(1); + wait_us(10); + _DAT_4000126c = _DAT_4000126c & 0xfffffff8 | 1; + wait_us(10); + rf_fsm_st_dbg_en_setf(1); + wait_us(10); + _DAT_4000126c = _DAT_4000126c & 0xfffffff8 | 2; + wait_us(100); + rf_fsm_st_dbg_en_setf(0); + wait_us(10); + _print_channel_info(); + rf_pri_update_param(channel_freq); + rf_pri_get_notch_param(channel_freq,&uStack21,(int32_t *)&stack0xffffffec); + __floatsidf(SStack20); + __divdf3(); + __muldf3(); + __adddf3(); + SVar1 = __fixdfsi(); + rfc_rxdfe_set_notch0(uStack21,'\x01',(int8_t)SVar1); + _DAT_40001228 = _DAT_40001228 & 0xfffffff7; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rfc_coex_force_to(uint32_t force_enable,uint32_t bbmode) + +{ + rf_fsm_ctrl_en_setf(0); + wait_us(10); + _DAT_40001220 = + (uint)(force_enable != 0) << 0x1b | (bbmode & 1) << 0x1a | _DAT_40001220 & 0xf3ffffff; + wait_us(10); + rf_fsm_ctrl_en_setf(1); + return; +} + + + +uint32_t rfc_get_power_level(uint32_t formatmod,int32_t power) + +{ + uint32_t mode; + + mode = 0; + if ((formatmod != 0) && (mode = 1, formatmod != 1)) { + mode = 2; + } + mode = rf_pri_get_txgain_index(power,mode); + return mode << 2; +} + + + +void rfc_apply_tx_dvga(int8_t *dvga_qdb) + +{ + rf_tx_dvga_gain_qdb_gc0_setf((int)*dvga_qdb); + rf_tx_dvga_gain_qdb_gc1_setf((int)dvga_qdb[1]); + rf_tx_dvga_gain_qdb_gc2_setf((int)dvga_qdb[2]); + rf_tx_dvga_gain_qdb_gc3_setf((int)dvga_qdb[3]); + rf_tx_dvga_gain_qdb_gc4_setf((int)dvga_qdb[4]); + rf_tx_dvga_gain_qdb_gc5_setf((int)dvga_qdb[5]); + rf_tx_dvga_gain_qdb_gc6_setf((int)dvga_qdb[6]); + rf_tx_dvga_gain_qdb_gc7_setf((int)dvga_qdb[7]); + rf_tx_dvga_gain_qdb_gc8_setf((int)dvga_qdb[8]); + rf_tx_dvga_gain_qdb_gc9_setf((int)dvga_qdb[9]); + rf_tx_dvga_gain_qdb_gc10_setf((int)dvga_qdb[10]); + rf_tx_dvga_gain_qdb_gc11_setf((int)dvga_qdb[0xb]); + rf_tx_dvga_gain_qdb_gc12_setf((int)dvga_qdb[0xc]); + rf_tx_dvga_gain_qdb_gc13_setf((int)dvga_qdb[0xd]); + rf_tx_dvga_gain_qdb_gc14_setf((int)dvga_qdb[0xe]); + rf_tx_dvga_gain_qdb_gc15_setf((int)dvga_qdb[0xf]); + return; +} + + + +// WARNING: Variable defined which should be unmapped: dg +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rfc_apply_tx_power_offset(uint8_t channel,int8_t *power_offset) + +{ + uint32_t uStack56; + uint32_t rfg_index; + uint32_t dg; + + rf_pri_update_tx_power_offset(channel,power_offset); + rf_pri_query_txgain_table(0,&uStack56,&rfg_index); + _DAT_40001640 = uStack56 & 7 | _DAT_40001640 & 0xfffffff8; + rf_tx_dvga_gain_qdb_gc0_setf(rfg_index); + rf_pri_query_txgain_table(1,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 4 | _DAT_40001640 & 0xffffff8f; + rf_tx_dvga_gain_qdb_gc1_setf(rfg_index); + rf_pri_query_txgain_table(2,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 8 | _DAT_40001640 & 0xfffff8ff; + rf_tx_dvga_gain_qdb_gc2_setf(rfg_index); + rf_pri_query_txgain_table(3,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 0xc | _DAT_40001640 & 0xffff8fff; + rf_tx_dvga_gain_qdb_gc3_setf(rfg_index); + rf_pri_query_txgain_table(4,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 0x10 | _DAT_40001640 & 0xfff8ffff; + rf_tx_dvga_gain_qdb_gc4_setf(rfg_index); + rf_pri_query_txgain_table(5,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 0x14 | _DAT_40001640 & 0xff8fffff; + rf_tx_dvga_gain_qdb_gc5_setf(rfg_index); + rf_pri_query_txgain_table(6,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 0x18 | _DAT_40001640 & 0xf8ffffff; + rf_tx_dvga_gain_qdb_gc6_setf(rfg_index); + rf_pri_query_txgain_table(7,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 0x1c | _DAT_40001640 & 0x8fffffff; + rf_tx_dvga_gain_qdb_gc7_setf(rfg_index); + rf_pri_query_txgain_table(8,&uStack56,&rfg_index); + _DAT_40001644 = uStack56 & 7 | _DAT_40001644 & 0xfffffff8; + rf_tx_dvga_gain_qdb_gc8_setf(rfg_index); + rf_pri_query_txgain_table(9,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 4 | _DAT_40001644 & 0xffffff8f; + rf_tx_dvga_gain_qdb_gc9_setf(rfg_index); + rf_pri_query_txgain_table(10,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 8 | _DAT_40001644 & 0xfffff8ff; + rf_tx_dvga_gain_qdb_gc10_setf(rfg_index); + rf_pri_query_txgain_table(0xb,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 0xc | _DAT_40001644 & 0xffff8fff; + rf_tx_dvga_gain_qdb_gc11_setf(rfg_index); + rf_pri_query_txgain_table(0xc,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 0x10 | _DAT_40001644 & 0xfff8ffff; + rf_tx_dvga_gain_qdb_gc12_setf(rfg_index); + rf_pri_query_txgain_table(0xd,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 0x14 | _DAT_40001644 & 0xff8fffff; + rf_tx_dvga_gain_qdb_gc13_setf(rfg_index); + rf_pri_query_txgain_table(0xe,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 0x18 | _DAT_40001644 & 0xf8ffffff; + rf_tx_dvga_gain_qdb_gc14_setf(rfg_index); + rf_pri_query_txgain_table(0xf,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 0x1c | _DAT_40001644 & 0x8fffffff; + rf_tx_dvga_gain_qdb_gc15_setf(rfg_index); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_set_gain_table_regs(void) + +{ + _DAT_40001118 = + ((tx_pwr_table[12][2] << 0x18 | + (tx_pwr_table[12][3] << 0x10 | + (tx_pwr_table[14][0] << 0xe | + (tx_pwr_table[14][1] << 0xc | + (tx_pwr_table[14][2] << 8 | (_DAT_40001118 & 0xffffffe0 | tx_pwr_table[14][3]) & 0xfffff8ff) + & 0xffffcfff) & 0xffff3fff) & 0xffe0ffff) & 0xf8ffffff) & 0xcfffffff | + tx_pwr_table[12][1] << 0x1c) & 0x3fffffff | tx_pwr_table[12][0] << 0x1e; + _DAT_4000111c = + (tx_pwr_table[8][1] << 0x1c | + (tx_pwr_table[8][2] << 0x18 | + (tx_pwr_table[8][3] << 0x10 | + (tx_pwr_table[10][0] << 0xe | + (tx_pwr_table[10][1] << 0xc | + (tx_pwr_table[10][2] << 8 | (_DAT_4000111c & 0xffffffe0 | tx_pwr_table[10][3]) & 0xfffff8ff) + & 0xffffcfff) & 0xffff3fff) & 0xffe0ffff) & 0xf8ffffff) & 0xcfffffff) & 0x3fffffff | + tx_pwr_table[8][0] << 0x1e; + _DAT_40001120 = + tx_pwr_table[4][0] << 0x1e | + (tx_pwr_table[4][1] << 0x1c | + (tx_pwr_table[4][2] << 0x18 | + (tx_pwr_table[4][3] << 0x10 | + (tx_pwr_table[6][0] << 0xe | + (tx_pwr_table[6][1] << 0xc | + (tx_pwr_table[6][2] << 8 | (_DAT_40001120 & 0xffffffe0 | tx_pwr_table[6][3]) & 0xfffff8ff) & + 0xffffcfff) & 0xffff3fff) & 0xffe0ffff) & 0xf8ffffff) & 0xcfffffff) & 0x3fffffff; + _DAT_40001124 = + (tx_pwr_table[0][1] << 0x1c | + ((tx_pwr_table[0][3] << 0x10 | + (tx_pwr_table[2][0] << 0xe | + ((tx_pwr_table[2][2] << 8 | (_DAT_40001124 & 0xffffffe0 | tx_pwr_table[2][3]) & 0xfffff8ff) + & 0xffffcfff | tx_pwr_table[2][1] << 0xc) & 0xffff3fff) & 0xffe0ffff) & 0xf8ffffff | + tx_pwr_table[0][2] << 0x18) & 0xcfffffff) & 0x3fffffff | tx_pwr_table[0][0] << 0x1e; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_manu_pu(uint32_t mode) + +{ + int iVar1; + uint uVar2; + + if (mode == 5) { + _DAT_40001030 = _DAT_40001030 & 0xcefff8ff; + iVar1 = -0x39009000; + } + else { + if (5 < mode) { + if (7 < mode) goto LAB_23015d76; + _DAT_40001030 = _DAT_40001030 & 0x8f090ff; + uVar2 = 0xf00000; + goto LAB_23015daa; + } + if (mode != 4) { +LAB_23015d76: + _DAT_40001004 = _DAT_40001004 & 0xfffffffd; + _DAT_4000100c = 0; + _DAT_40001030 = _DAT_40001030 & 0x2df0feff | 0x25f06e00; + return; + } + _DAT_40001030 = _DAT_40001030 & 0x2cf8f8ff; + iVar1 = 0x24f87000; + } + uVar2 = iVar1 - 0x800; +LAB_23015daa: + _DAT_40001004 = _DAT_40001004 & 0xfffffffd; + _DAT_4000100c = 0; + _DAT_40001030 = _DAT_40001030 | uVar2; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_save_state_for_cal(void) + +{ + state_adda1 = _DAT_4000108c; + state_dfe_ctrl_0 = _DAT_40001600; + state_dfe_ctrl_3 = _DAT_4000160c; + state_dfe_ctrl_6 = _DAT_40001618; + state_dfe_ctrl_7 = _DAT_4000161c; + state_fbdv = _DAT_400010b8; + state_pa1 = _DAT_40001064; + state_pucr1 = _DAT_40001030; + state_rbb3 = _DAT_40001084; + state_rf_fsm_ctrl_hw = _DAT_40001004; + state_rf_resv_reg_1 = _DAT_400010f0; + state_rfcal_ctrlen = _DAT_4000101c; + state_rfctrl_hw_en = _DAT_4000100c; + state_rfif_dfe_ctrl0 = _DAT_40001220; + state_sdm1 = _DAT_400010c0; + state_sdm2 = _DAT_400010c4; + state_singen_ctrl0 = _DAT_4000120c; + state_singen_ctrl2 = _DAT_40001214; + state_singen_ctrl3 = _DAT_40001218; + state_sram_ctrl0 = _DAT_4000123c; + state_sram_ctrl1 = _DAT_40001240; + state_sram_ctrl2 = _DAT_40001244; + state_tbb = _DAT_40001070; + state_ten_ac = _DAT_40001058; + state_trx_gain1 = _DAT_40001048; + state_vco2 = _DAT_400010a4; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_restore_state_for_cal(void) + +{ + _DAT_40001004 = state_rf_fsm_ctrl_hw; + _DAT_4000100c = state_rfctrl_hw_en; + _DAT_4000101c = state_rfcal_ctrlen; + _DAT_40001030 = state_pucr1; + _DAT_40001048 = state_trx_gain1; + _DAT_40001058 = state_ten_ac; + _DAT_40001064 = state_pa1; + _DAT_40001070 = state_tbb; + _DAT_40001084 = state_rbb3; + _DAT_4000108c = state_adda1; + _DAT_400010a4 = state_vco2; + _DAT_400010b8 = state_fbdv; + _DAT_400010c0 = state_sdm1; + _DAT_400010c4 = state_sdm2; + _DAT_400010f0 = state_rf_resv_reg_1; + _DAT_4000120c = state_singen_ctrl0; + _DAT_40001214 = state_singen_ctrl2; + _DAT_40001218 = state_singen_ctrl3; + _DAT_40001220 = state_rfif_dfe_ctrl0; + _DAT_4000123c = state_sram_ctrl0; + _DAT_40001240 = state_sram_ctrl1; + _DAT_40001244 = state_sram_ctrl2; + _DAT_40001600 = state_dfe_ctrl_0; + _DAT_4000160c = state_dfe_ctrl_3; + _DAT_40001618 = state_dfe_ctrl_6; + _DAT_4000161c = state_dfe_ctrl_7; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_singen_start(void) + +{ + _DAT_4000120c = _DAT_4000120c & 0x7fffffff | 0x80000000; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t rf_pri_pm_pwr(void) + +{ + int iVar1; + int iVar2; + + do { + } while (-1 < (int)((_DAT_40001618 & 0xdfefffff | 0x20100000) << 3)); + iVar1 = (_DAT_40001620 << 7) >> 0x10; + iVar2 = (_DAT_40001624 << 7) >> 0x10; + _DAT_40001618 = _DAT_40001618 & 0xdfefffff; + return iVar1 * iVar1 + iVar2 * iVar2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_start_txdfe(void) + +{ + _DAT_40001220 = _DAT_40001220 & 0xffffe67f | 0x1182; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int32_t rf_pri_pm_pwr_avg(uint32_t iq,uint32_t acc_len) + +{ + int iVar1; + + do { + } while (-1 < (int)((_DAT_40001618 & 0xdfefffff) << 3)); + iVar1 = _DAT_40001624; + if (iq != 0) { + iVar1 = _DAT_40001620; + } + _DAT_40001618 = _DAT_40001618 & 0xdfefffff; + _DAT_4000161c = acc_len << 0x10 | _DAT_4000161c & 0xffff; + return (iVar1 << 7) >> 7; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_txcal_config_hw(void) + +{ + _DAT_40001180 = + (*(uint *)(rf_calib_data->txcal + 1) >> 6 & 0x3f) << 0x18 | + (*(uint *)rf_calib_data->txcal >> 6 & 0x3f) << 8 | + *(uint *)rf_calib_data->txcal & 0x3f | _DAT_40001180 & 0xc0c0c0c0 | + (*(uint *)(rf_calib_data->txcal + 1) & 0x3f) << 0x10; + _DAT_40001184 = + (*(uint *)(rf_calib_data->txcal + 3) >> 6 & 0x3f) << 0x18 | + (*(uint *)(rf_calib_data->txcal + 2) >> 6 & 0x3f) << 8 | + *(uint *)(rf_calib_data->txcal + 2) & 0x3f | _DAT_40001184 & 0xc0c0c0c0 | + (*(uint *)(rf_calib_data->txcal + 3) & 0x3f) << 0x10; + _DAT_40001188 = + (*(uint *)(rf_calib_data->txcal + 5) >> 6 & 0x3f) << 0x18 | + (*(uint *)(rf_calib_data->txcal + 4) >> 6 & 0x3f) << 8 | + *(uint *)(rf_calib_data->txcal + 4) & 0x3f | _DAT_40001188 & 0xc0c0c0c0 | + (*(uint *)(rf_calib_data->txcal + 5) & 0x3f) << 0x10; + _DAT_4000118c = + (*(uint *)(rf_calib_data->txcal + 7) >> 6 & 0x3f) << 0x18 | + (*(uint *)(rf_calib_data->txcal + 6) >> 6 & 0x3f) << 8 | + *(uint *)(rf_calib_data->txcal + 6) & 0x3f | _DAT_4000118c & 0xc0c0c0c0 | + (*(uint *)(rf_calib_data->txcal + 7) & 0x3f) << 0x10; + _DAT_40001190 = + (*(uint *)rf_calib_data->txcal >> 0xc & 0x7ff) << 0x10 | _DAT_40001190 & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[0].field_0x4 & 0x3ff; + _DAT_40001194 = + (*(uint *)(rf_calib_data->txcal + 1) >> 0xc & 0x7ff) << 0x10 | _DAT_40001194 & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[1].field_0x4 & 0x3ff; + _DAT_40001198 = + (*(uint *)(rf_calib_data->txcal + 2) >> 0xc & 0x7ff) << 0x10 | _DAT_40001198 & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[2].field_0x4 & 0x3ff; + _DAT_4000119c = + (*(uint *)(rf_calib_data->txcal + 3) >> 0xc & 0x7ff) << 0x10 | _DAT_4000119c & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[3].field_0x4 & 0x3ff; + _DAT_400011a0 = + (*(uint *)(rf_calib_data->txcal + 4) >> 0xc & 0x7ff) << 0x10 | _DAT_400011a0 & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[4].field_0x4 & 0x3ff; + _DAT_400011a4 = + (*(uint *)(rf_calib_data->txcal + 5) >> 0xc & 0x7ff) << 0x10 | _DAT_400011a4 & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[5].field_0x4 & 0x3ff; + _DAT_400011a8 = + (*(uint *)(rf_calib_data->txcal + 6) >> 0xc & 0x7ff) << 0x10 | _DAT_400011a8 & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[6].field_0x4 & 0x3ff; + _DAT_400011ac = + (*(uint *)(rf_calib_data->txcal + 7) >> 0xc & 0x7ff) << 0x10 | _DAT_400011ac & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[7].field_0x4 & 0x3ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint16_t rf_pri_fcal_meas(uint32_t cw) + +{ + _DAT_400010a0 = cw | _DAT_400010a0 & 0xffffff00; + BL602_Delay_US(100); + do { + } while (-1 < (int)((_DAT_400010ac | 0x10) << 0xb)); + _DAT_400010ac = _DAT_400010ac & 0xffffffef; + return (uint16_t)((uint)_DAT_400010a8 >> 0x10); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_rccal_config(uint32_t rbb_fc) + +{ + _DAT_40001080 = rbb_fc << 8 | rbb_fc << 0x18 | _DAT_40001080 & 0xc0ffc0ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_rccal_config(uint32_t iq,uint32_t rbb_fc) + +{ + if (iq != 0) { + rf_pri_rccal_config(rbb_fc); + return; + } + _DAT_40001080 = rbb_fc << 0x10 | _DAT_40001080 & 0xffc0ffc0 | rbb_fc; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_txcal_config(uint32_t param_ind,int32_t val) + +{ + uint uVar1; + + if (param_ind == 2) { + _DAT_40001600 = val << 0xc | _DAT_40001600 & 0xff800fff | 0x800000; + return; + } + if (param_ind != 3) { + if (param_ind == 0) { + _DAT_40001070 = _DAT_40001070 & 0xc0ffffff; + uVar1 = val << 0x18; + } + else { + if (param_ind != 1) { + return; + } + _DAT_40001070 = _DAT_40001070 & 0xffc0ffff; + uVar1 = val << 0x10; + } + _DAT_40001070 = uVar1 | _DAT_40001070; + return; + } + if (val < 0) { + val = val + 0x400; + } + _DAT_40001600 = val | _DAT_40001600 & 0xfffffc00 | 0x400; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int32_t rf_pri_txcal_search_core + (uint32_t param_ind,uint32_t center,uint32_t delta,uint32_t meas_freq) + +{ + uint32_t val; + uint32_t val_00; + uint32_t uVar1; + uint uVar2; + uint32_t uVar3; + + rf_pri_txcal_config(param_ind,center); + BL602_Delay_US(10); + _DAT_40001618 = meas_freq << 10 | _DAT_40001618 & 0xfff00000; + uVar1 = rf_pri_pm_pwr(); + do { + val = center - delta; + val_00 = center + delta; + if (param_ind < 2) { + if ((int)val < 0) { + val = 0; + } + if (0x3f < (int)val_00) { + val_00 = 0x3f; + } + } + else { + if (param_ind == 2) { + if ((int)val < 0) { + val = 0; + } + if (0x7ff < (int)val_00) { + val_00 = 0x7ff; + } + } + else { + if ((int)val < -0x200) { + val = 0xfffffe00; + } + if (0x1ff < (int)val_00) { + val_00 = 0x1ff; + } + } + } + rf_pri_txcal_config(param_ind,val); + delta = (int)delta >> 1; + BL602_Delay_US(10); + uVar2 = rf_pri_pm_pwr(); + if (uVar1 <= uVar2) { + rf_pri_txcal_config(param_ind,val_00); + BL602_Delay_US(10); + uVar3 = rf_pri_pm_pwr(); + val = center; + uVar2 = uVar1; + if (uVar3 < uVar1) { + val = val_00; + uVar2 = uVar3; + } + } + center = val; + uVar1 = uVar2; + } while (delta != 0); + return val; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_singen_config(uint32_t fcw) + +{ + _DAT_4000120c = fcw << 0x10 | _DAT_4000120c & 0xfc00ffff; + _DAT_40001214 = _DAT_40001214 & 0x3fffff; + _DAT_40001218 = _DAT_40001218 & 0x3fffff | 0xc0000000; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t rf_pri_rccal_iq(uint32_t iq) + +{ + uint uVar1; + uint32_t i; + USItype UVar2; + uint32_t uVar3; + uint uVar4; + int iVar5; + undefined4 uVar6; + + if (iq == 0) { + _DAT_4000160c = _DAT_4000160c & 0xfbffffff | 0x400; + } + else { + _DAT_4000160c = _DAT_4000160c & 0xfffffbff | 0x4000000; + } + _DAT_40001048 = _DAT_40001048 & 0xffff8cff | 0x3100; + rf_pri_singen_config(3); + _DAT_40001214 = _DAT_40001214 & 0xfffff800 | 0x3ff; + _DAT_40001218 = _DAT_40001218 & 0xfffff800 | 0x3ff; + uVar6 = rf_pri_singen_start(); + rf_pri_start_txdfe(uVar6); + _DAT_40001618 = _DAT_40001618 & 0xfff00000 | 0xc00; + rf_pri_pm_pwr_avg(iq,0x400); + i = rf_pri_pm_pwr(); + __floatunsidf(i); + __muldf3(); + UVar2 = __fixunsdfsi(); + _DAT_40001048 = _DAT_40001048 & 0xffff8cff | 0x6200; + rf_pri_singen_config(0xb5); + uVar6 = rf_pri_singen_start(); + rf_pri_start_txdfe(uVar6); + _DAT_40001618 = _DAT_40001618 & 0xfff00000 | 0x2d400; + i = 0; + uVar1 = 6; + uVar4 = 0x20; + do { + rf_pri_rccal_config(iq,uVar4 + i); + uVar3 = rf_pri_pm_pwr(); + if (UVar2 < uVar3) { + i = uVar4 + i; + } + uVar1 = uVar1 - 1; + uVar4 = uVar4 >> 1; + } while (uVar1 != 0); + iVar5 = 0x3f; + do { + rf_pri_rccal_config(iq,i); + uVar3 = rf_pri_pm_pwr(); + if (UVar2 < uVar3) { + uVar1 = uVar1 * 2 + 1 & 0xf; + i = i + 1; + if (uVar1 == 5) { + return 3; + } + } + else { + uVar1 = uVar1 * 2 & 0xf; + i = i - 1; + if (uVar1 == 10) { + return 3; + } + } + iVar5 = iVar5 + -1; + } while (iVar5 != 0); + return 2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_config_channel(void) + +{ + _DAT_400010a0 = + ((uint)((ushort)rf_calib_data->lo[9] >> 8) & 0x1f) << 0x10 | + (uint)(ushort)rf_calib_data->lo[9] & 0xff | _DAT_400010a0 & 0xffe0ff00; + _DAT_400010bc = + (((uint)(ushort)rf_calib_data->lo[9] & 0xff) >> 4) << 0x14 | _DAT_400010bc & 0xff0fffff; + _DAT_400010c4 = _DAT_400010c4 & 0xc0000000 | channel_div_table[9]; + _DAT_400010c0 = _DAT_400010c0 & 0xffffefff; + while( true ) { + _DAT_400010b8 = _DAT_400010b8 | 0x10000; + BL602_Delay_US(10); + _DAT_400010b8 = _DAT_400010b8 & 0xfffeffff; + BL602_Delay_US(0x32); + _DAT_400010b0 = _DAT_400010b0 | 0x10000000; + BL602_Delay_US(10); + _DAT_400010b0 = _DAT_400010b0 & 0xefffffff; + BL602_Delay_US(0x32); + if ((_DAT_400010b4 & 0x1100000) == 0) break; + printf("."); + } + printf("LO locked %ld %ld\r\n",(uint)(ushort)rf_calib_data->lo[9] & 0xff); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t rf_pri_roscal_iq(uint32_t iq) + +{ + uint uVar1; + int32_t iVar2; + uint uVar3; + uint uVar4; + int iVar5; + uint uVar6; + + uVar1 = 6; + uVar3 = 0; + uVar4 = 0x20; + do { + uVar6 = uVar4 + uVar3; + if (iq == 0) { + _DAT_4000107c = uVar6 | _DAT_4000107c & 0xffffffc0; + } + else { + _DAT_4000107c = uVar6 * 0x100 | _DAT_4000107c & 0xffffc0ff; + } + iVar2 = rf_pri_pm_pwr_avg(iq,0x400); + if (iVar2 < 1) { + uVar3 = uVar6; + } + uVar1 = uVar1 - 1; + uVar4 = uVar4 >> 1; + } while (uVar1 != 0); + iVar5 = 0x3f; + do { + if (iq == 0) { + _DAT_4000107c = _DAT_4000107c & 0xffffffc0 | uVar3; + } + else { + _DAT_4000107c = uVar3 << 8 | _DAT_4000107c & 0xffffc0ff; + } + iVar2 = rf_pri_pm_pwr_avg(iq,0x400); + if (iVar2 < 1) { + uVar1 = uVar1 * 2 & 0xf; + uVar3 = uVar3 + 1; + if (uVar1 == 10) { + return uVar3; + } + } + else { + uVar1 = uVar1 * 2 + 1 & 0xf; + uVar3 = uVar3 - 1; + if (uVar1 == 5) { + return uVar3; + } + } + iVar5 = iVar5 + -1; + } while (iVar5 != 0); + return uVar3; +} + + + +void rf_pri_chipv(uint8_t chipv) + +{ + regs_to_opti *prVar1; + undefined3 in_register_00002029; + undefined4 *puVar2; + undefined4 *puVar3; + int iVar4; + uint32_t *puVar5; + void_fn **ppvVar6; + int iVar7; + uint32_t *puVar8; + uint32_t *puVar9; + int iVar10; + void_fn **ppvVar11; + void_fn **ppvVar12; + + if (CONCAT31(in_register_00002029,chipv) == 0) { + tmxcss._0_4_ = 0x60003; + tmxcss[2] = 6; + iVar4 = 0x1c; + do { + iVar7 = iVar4 + -0x1c; + do { + *(undefined4 *)((int)tx_pwr_table + iVar7) = *(undefined4 *)((int)tx_pwr_table_a0 + iVar7); + *(undefined4 *)((int)tx_pwr_table_origin + iVar7) = + *(undefined4 *)((int)tx_pwr_table_a0 + iVar7); + iVar7 = iVar7 + 4; + } while (iVar4 != iVar7); + iVar4 = iVar4 + 0x1c; + } while (iVar4 != 0x1dc); + iVar4 = 0; + do { + puVar2 = (undefined4 *)((int)tx_pwr_ch_os_a0 + iVar4); + puVar3 = (undefined4 *)((int)tx_pwr_ch_os + iVar4); + iVar4 = iVar4 + 4; + *puVar3 = *puVar2; + } while (iVar4 != 0x38); + puVar5 = txcal_para; + puVar8 = txcal_para_a0; + do { + puVar9 = puVar8 + 4; + *puVar5 = *puVar8; + puVar5[1] = puVar8[1]; + puVar5[2] = puVar8[2]; + puVar5[3] = puVar8[3]; + puVar5 = puVar5 + 4; + puVar8 = puVar9; + } while (puVar9 != txcal_para_a1); + opti_regs->vbcore = 10; + prVar1 = opti_regs; + opti_regs->iet = 3; + prVar1->vbcore_11n = 10; + prVar1->iet_11n = 3; + prVar1->vbcore_11g = 10; + prVar1->iet_11g = 3; + prVar1->vbcore_11b = 10; + prVar1->iet_11b = 3; + prVar1->lo_fbdv_halfstep_en = 0; + prVar1->lo_fbdv_halfstep_en_tx = 0; + prVar1->lo_fbdv_halfstep_en_tx = 0; + prVar1->clkpll_reset_postdiv = 0; + prVar1->clkpll_dither_sel = 0; + return; + } + if (CONCAT31(in_register_00002029,chipv) == 1) { + tmxcss._0_4_ = 0x50005; + tmxcss[2] = 5; + iVar4 = 0x1c; + do { + iVar7 = iVar4 + -0x1c; + do { + iVar10 = iVar7; + *(undefined4 *)((int)tx_pwr_table + iVar10) = *(undefined4 *)((int)tx_pwr_table_a1 + iVar10) + ; + *(undefined4 *)((int)tx_pwr_table_origin + iVar10) = + *(undefined4 *)((int)tx_pwr_table_a1 + iVar10); + iVar7 = iVar10 + 4; + } while (iVar10 + 4 != iVar4); + iVar4 = iVar10 + 0x20; + } while (iVar4 != 0x1dc); + iVar4 = 0; + do { + puVar2 = (undefined4 *)((int)tx_pwr_ch_os_a1 + iVar4); + puVar3 = (undefined4 *)((int)tx_pwr_ch_os + iVar4); + iVar4 = iVar4 + 4; + *puVar3 = *puVar2; + } while (iVar4 != 0x38); + ppvVar6 = (void_fn **)txcal_para; + ppvVar11 = (void_fn **)txcal_para_a1; + do { + ppvVar12 = ppvVar11 + 4; + *ppvVar6 = *ppvVar11; + ppvVar6[1] = ppvVar11[1]; + ppvVar6[2] = ppvVar11[2]; + ppvVar6[3] = ppvVar11[3]; + ppvVar6 = ppvVar6 + 4; + ppvVar11 = ppvVar12; + } while (ppvVar12 != intc_irq_handlers); + opti_regs->vbcore = 0xc; + prVar1 = opti_regs; + opti_regs->iet = 5; + prVar1->vbcore_11n = 0xc; + prVar1->iet_11n = 5; + prVar1->vbcore_11g = 0xc; + prVar1->iet_11g = 5; + prVar1->vbcore_11b = 0xc; + prVar1->iet_11b = 5; + prVar1->lo_fbdv_halfstep_en = 1; + prVar1->lo_fbdv_halfstep_en_tx = 1; + prVar1->lo_fbdv_halfstep_en_tx = 1; + prVar1->clkpll_reset_postdiv = 1; + prVar1->clkpll_dither_sel = 2; + } + return; +} + + + +void rf_pri_update_tx_power_offset(uint8_t channel,int8_t *power_offset) + +{ + char cVar1; + undefined3 in_register_00002029; + int32_t *piVar2; + int32_t *piVar3; + + cVar1 = power_offset[CONCAT31(in_register_00002029,channel)]; + memcpy(tx_pwr_table,tx_pwr_table_origin,0x1c0); + piVar2 = tx_pwr_table; + do { + piVar3 = piVar2 + 7; + piVar2[5] = piVar2[5] + (int)cVar1 % 4; + piVar2[6] = piVar2[6] + ((int)cVar1 / 4) * -10; + piVar2 = piVar3; + } while (piVar3 != tx_pwr_table_origin); + rf_pri_set_gain_table_regs(); + return; +} + + + +void rf_pri_get_notch_param(uint32_t chanfreq_MHz,uint8_t *ncf_on,int32_t *ncf_freq_Hz) + +{ + uint uVar1; + int32_t iVar2; + + uVar1 = 0xd; + if (chanfreq_MHz < 0x9a9) { + uVar1 = (chanfreq_MHz - 0x96c) / 5; + } + iVar2 = rx_notch_para_40M[uVar1 * 2 + 1]; + *ncf_on = (uint8_t)rx_notch_para_40M[uVar1 * 2]; + *ncf_freq_Hz = iVar2; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_update_param(uint32_t chanfreq_MHz) + +{ + ushort uVar1; + int iVar2; + int32_t *piVar3; + int iVar4; + int iVar5; + int iVar6; + int32_t iVar7; + int iVar8; + uint32_t uVar9; + int32_t *piVar10; + + index_os_pre = 0; + index_os_pre_mdb = 0; + dvga_os_pre = 0; + up_dn = 0; + if ((chanfreq_MHz < 0x96c) || (chanfreq_MHz < 0x971)) { + iVar5 = 0; + } + else { + if (chanfreq_MHz < 0x97b) { + iVar5 = 1; + } + else { + if (chanfreq_MHz < 0x98a) { + iVar5 = 2; + } + else { + if (chanfreq_MHz < 0x999) { + iVar5 = 3; + } + else { + iVar4 = 8; + iVar5 = 7; + if (0x9a7 < chanfreq_MHz) goto LAB_23016d38; + iVar5 = 4; + } + } + } + } + uVar9 = Tchannels[iVar5]; + iVar8 = 0; + if (uVar9 != chanfreq_MHz) { + iVar8 = chanfreq_MHz - uVar9; + } + iVar6 = iVar5 + 1; + iVar4 = (uint)((Tchannel_os[iVar6] - Tchannel_os[iVar5]) * iVar8) / (Tchannels[iVar6] - uVar9) + + Tchannel_os[iVar5]; + iVar5 = (uint)((Tchannel_os_low[iVar6] - Tchannel_os_low[iVar5]) * iVar8) / + (Tchannels[iVar6] - uVar9) + Tchannel_os_low[iVar5]; +LAB_23016d38: + piVar3 = temps; + piVar10 = temps; + iVar8 = 0; + iVar6 = 10; + do { + iVar2 = (piVar10[4] + iVar8) - (0x14 - iVar5); + iVar8 = 0; + if (iVar6 < iVar2) { + iVar8 = iVar2 - iVar6; + iVar2 = iVar6; + } + piVar10[3] = iVar2; + iVar6 = iVar6 + -5; + piVar10 = piVar10 + -1; + } while (iVar6 != -10); + iVar8 = 0x38; + iVar5 = 0; + do { + iVar7 = (piVar3[5] - iVar5) + (0x14 - iVar4); + if (0x5f < iVar7) { + iVar7 = iVar7 + (5 - iVar4 / 4); + } + piVar3[6] = iVar7; + iVar6 = piVar3[6]; + iVar5 = 0; + if (iVar6 < iVar8) { + iVar5 = iVar8 - iVar6; + iVar6 = iVar8; + } + piVar3[6] = iVar6; + iVar8 = iVar8 + 5; + piVar3 = piVar3 + 1; + } while (iVar8 != 0x5b); + uVar1 = tmxcss[2]; + if (chanfreq_MHz < 0x986) { + uVar1 = tmxcss[1]; + } + _DAT_4000106c = (uint)uVar1 | _DAT_4000106c & 0xfffffff8; + tx_pwr_os = tx_pwr_ch_os[6]; + if (chanfreq_MHz != 0x98a) { + if (chanfreq_MHz < 0x98b) { + tx_pwr_os = tx_pwr_ch_os[2]; + if (chanfreq_MHz != 0x976) { + if (chanfreq_MHz < 0x977) { + tx_pwr_os = tx_pwr_ch_os[0]; + if ((chanfreq_MHz != 0x96c) && (tx_pwr_os = tx_pwr_ch_os[1], chanfreq_MHz != 0x971)) { + temps[4] = 0xf; + temps[5] = 0x33; + tx_pwr_os = 0; + return; + } + } + else { + tx_pwr_os = tx_pwr_ch_os[4]; + if (((chanfreq_MHz != 0x980) && (tx_pwr_os = tx_pwr_ch_os[5], chanfreq_MHz != 0x985)) && + (tx_pwr_os = tx_pwr_ch_os[3], chanfreq_MHz != 0x97b)) { + temps[4] = 0xf; + temps[5] = 0x33; + tx_pwr_os = 0; + return; + } + } + } + } + else { + tx_pwr_os = tx_pwr_ch_os[10]; + if (chanfreq_MHz != 0x99e) { + if (chanfreq_MHz < 0x99f) { + tx_pwr_os = tx_pwr_ch_os[8]; + if (((chanfreq_MHz != 0x994) && (tx_pwr_os = tx_pwr_ch_os[9], chanfreq_MHz != 0x999)) && + (tx_pwr_os = tx_pwr_ch_os[7], chanfreq_MHz != 0x98f)) { + temps[4] = 0xf; + temps[5] = 0x33; + tx_pwr_os = 0; + return; + } + } + else { + tx_pwr_os = tx_pwr_ch_os[12]; + if (((chanfreq_MHz != 0x9a8) && (tx_pwr_os = tx_pwr_ch_os[13], chanfreq_MHz != 0x9b4)) && + (tx_pwr_os = tx_pwr_ch_os[11], chanfreq_MHz != 0x9a3)) { + temps[4] = 0xf; + temps[5] = 0x33; + tx_pwr_os = 0; + return; + } + } + } + } + } + temps[4] = 0xf; + temps[5] = 0x33; + return; +} + + + +void rf_pri_xtalfreq(uint32_t xtalfreq) + +{ + if (xtalfreq == 0) { + channel_div_table[0] = 0x21638e39; + channel_div_table[1] = 0x2171c71c; + channel_div_table[2] = 0x21800000; + channel_div_table[3] = 0x218e38e4; + channel_div_table[4] = 0x219c71c7; + channel_div_table[5] = 0x21aaaaab; + channel_div_table[6] = 0x21b8e38e; + channel_div_table[7] = 0x21c71c72; + channel_div_table[8] = 0x21d55555; + channel_div_table[9] = 0x21e38e39; + channel_div_table[10] = 0x21f1c71c; + channel_div_table[11] = 0x22000000; + channel_div_table[12] = 0x220e38e4; + channel_div_table[13] = 0x221c71c7; + channel_div_table[14] = 0x222aaaab; + channel_div_table[15] = 0x2238e38e; + channel_div_table[16] = 0x22471c72; + channel_div_table[17] = 0x22555555; + channel_div_table[18] = 0x22638e39; + channel_div_table[19] = 0x2271c71c; + channel_div_table[20] = 0x22800000; + fcal_div = 0x500; + rx_notch_para_40M[4][0] = 1; + rx_notch_para_40M[6][0] = 1; + rx_notch_para_40M[7][0] = 1; + rx_notch_para_40M[12][0] = 1; + rx_notch_para_40M[1][1] = 7000000; + rx_notch_para_40M[2][1] = (int32_t)&DAT_001e8480; + rx_notch_para_40M[3][1] = -3000000; + rx_notch_para_40M[4][1] = -8000000; + rx_notch_para_40M[6][1] = 6000000; + rx_notch_para_40M[7][1] = 1000000; + rx_notch_para_40M[8][1] = -4000000; + rx_notch_para_40M[9][1] = -9000000; + rx_notch_para_40M[0][0] = 0; + rx_notch_para_40M[10][0] = 0; + rx_notch_para_40M[0][1] = 0; + rx_notch_para_40M[10][1] = 0; + rx_notch_para_40M[11][1] = 5000000; +LAB_2301713a: + channel_cnt_range[2] = 0xace7; + channel_cnt_range._0_4_ = 0xa6e7a6a7; + rx_notch_para_40M[11][0] = 1; + rx_notch_para_40M[9][0] = 1; + rx_notch_para_40M[5][1] = 0; + rx_notch_para_40M[5][0] = 0; + rx_notch_para_40M[3][0] = 1; + rx_notch_para_40M[2][0] = 1; + rx_notch_para_40M[1][0] = 1; + channel_cnt_table[20] = 0xac80; + channel_cnt_table._36_4_ = 0xac39abf2; + channel_cnt_table._32_4_ = 0xababab64; + channel_cnt_table._28_4_ = 0xab1caad5; + channel_cnt_table._24_4_ = 0xaa8eaa47; + channel_cnt_table._20_4_ = 0xaa00a9b9; + channel_cnt_table._16_4_ = 0xa972a92b; + channel_cnt_table._12_4_ = 0xa8e4a89c; + channel_cnt_table._8_4_ = 0xa855a80e; + channel_cnt_table._4_4_ = 0xa7c7a780; + channel_cnt_table._0_4_ = 0xa739a6f2; +LAB_2301713c: + rx_notch_para_40M[8][0] = 1; + rx_notch_para_40M[12][1] = 0; + } + else { + if (xtalfreq == 1) { + channel_div_table[0] = 0x1ed20d21; + channel_div_table[1] = 0x1edf2df3; + channel_div_table[2] = 0x1eec4ec5; + channel_div_table[3] = 0x1ef96f97; + channel_div_table[4] = 0x1f069069; + channel_div_table[5] = 0x1f13b13b; + channel_div_table[6] = 0x1f20d20d; + channel_div_table[7] = 0x1f2df2df; + channel_div_table[8] = 0x1f3b13b1; + channel_div_table[9] = 0x1f483483; + channel_div_table[10] = 0x1f555555; + channel_div_table[11] = 0x1f627627; + channel_div_table[12] = 0x1f6f96f9; + channel_div_table[13] = 0x1f7cb7cb; + channel_div_table[14] = 0x1f89d89e; + channel_div_table[15] = 0x1f96f970; + channel_div_table[16] = 0x1fa41a42; + channel_div_table[17] = 0x1fb13b14; + channel_div_table[18] = 0x1fbe5be6; + channel_div_table[19] = 0x1fcb7cb8; + channel_div_table[20] = 0x1fd89d8a; + channel_cnt_table._0_4_ = 0xa743a6fc; + channel_cnt_table._4_4_ = 0xa7d1a78a; + channel_cnt_table._8_4_ = 0xa860a819; + channel_cnt_table._12_4_ = 0xa8eea8a7; + channel_cnt_table._16_4_ = 0xa97ca935; + channel_cnt_table._20_4_ = 0xaa0aa9c3; + channel_cnt_table._24_4_ = 0xaa99aa52; + channel_cnt_table._28_4_ = 0xab27aae0; + channel_cnt_table._32_4_ = 0xabb5ab6e; + channel_cnt_table._36_4_ = 0xac43abfc; + channel_cnt_table[20] = 0xac8b; + channel_cnt_range._0_4_ = 0xa6f1a6b1; + channel_cnt_range[2] = 0xacf2; + fcal_div = 0x56b; + rx_notch_para_40M[0][1] = 6000000; + rx_notch_para_40M[1][1] = 1000000; + rx_notch_para_40M[2][1] = -4000000; + rx_notch_para_40M[3][1] = -9000000; + rx_notch_para_40M[5][1] = 7000000; + rx_notch_para_40M[6][1] = (int32_t)&DAT_001e8480; + rx_notch_para_40M[7][1] = -3000000; + rx_notch_para_40M[8][1] = -8000000; + rx_notch_para_40M[10][1] = 8000000; + rx_notch_para_40M[11][1] = 3000000; + rx_notch_para_40M[4][0] = 0; + rx_notch_para_40M[9][0] = 0; + rx_notch_para_40M[9][1] = 0; + rx_notch_para_40M[12][1] = -2000000; + rx_notch_para_40M[8][0] = xtalfreq; + rx_notch_para_40M[12][0] = xtalfreq; + } + else { + if (xtalfreq != 2) { + if (xtalfreq == 3) { + channel_div_table[0] = 0x14de38e4; + channel_div_table[1] = 0x14e71c72; + channel_div_table[2] = 0x14f00000; + channel_div_table[3] = 0x14f8e38e; + channel_div_table[4] = 0x1501c71c; + channel_div_table[5] = 0x150aaaab; + channel_div_table[6] = 0x15138e39; + channel_div_table[7] = 0x151c71c7; + channel_div_table[8] = 0x15255555; + channel_div_table[9] = 0x152e38e4; + channel_div_table[10] = 0x15371c72; + channel_div_table[11] = 0x15400000; + channel_div_table[12] = 0x1548e38e; + channel_div_table[13] = 0x1551c71c; + channel_div_table[14] = 0x155aaaab; + channel_div_table[15] = 0x15638e39; + channel_div_table[16] = 0x156c71c7; + channel_div_table[17] = 0x15755555; + channel_div_table[18] = 0x157e38e4; + channel_div_table[19] = 0x15871c72; + channel_div_table[20] = 0x15900000; + fcal_div = 0x800; + rx_notch_para_40M[0][0] = 1; + rx_notch_para_40M[10][0] = 1; + rx_notch_para_40M[0][1] = 7200000; + rx_notch_para_40M[1][1] = 2200000; + rx_notch_para_40M[2][1] = -2800000; + rx_notch_para_40M[3][1] = -7800000; + rx_notch_para_40M[8][1] = 5600000; + rx_notch_para_40M[9][1] = 600000; + rx_notch_para_40M[10][1] = -4400000; + rx_notch_para_40M[4][0] = 0; + rx_notch_para_40M[6][0] = 0; + rx_notch_para_40M[7][0] = 0; + rx_notch_para_40M[12][0] = 0; + rx_notch_para_40M[4][1] = 0; + rx_notch_para_40M[6][1] = 0; + rx_notch_para_40M[7][1] = 0; + rx_notch_para_40M[11][1] = -9400000; + goto LAB_2301713a; + } + if (xtalfreq == 4) { + channel_cnt_table._0_4_ = 0xa732a6eb; + channel_cnt_table._4_4_ = 0xa7c0a779; + channel_cnt_table._8_4_ = 0xa84fa808; + channel_cnt_table._12_4_ = 0xa8dda896; + channel_cnt_table._16_4_ = 0xa96ba924; + channel_cnt_table._20_4_ = 0xa9f9a9b2; + channel_cnt_table._24_4_ = 0xaa87aa40; + channel_cnt_table._28_4_ = 0xab16aacf; + channel_cnt_table._32_4_ = 0xaba4ab5d; + channel_cnt_table._36_4_ = 0xac32abeb; + channel_cnt_table[20] = 0xac79; + channel_div_table[0] = 0x14088889; + channel_div_table[1] = 0x14111111; + channel_div_table[2] = 0x1419999a; + channel_div_table[3] = 0x14222222; + channel_div_table[4] = 0x142aaaab; + channel_div_table[5] = 0x14333333; + channel_div_table[6] = 0x143bbbbc; + channel_div_table[7] = 0x14444444; + channel_div_table[8] = 0x144ccccd; + channel_div_table[9] = 0x14555555; + channel_div_table[10] = 0x145dddde; + channel_div_table[11] = 0x14666666; + channel_div_table[12] = 0x146eeeef; + channel_div_table[13] = 0x14777777; + channel_div_table[14] = 0x14800000; + channel_div_table[15] = 0x14888889; + channel_div_table[16] = 0x14911111; + channel_div_table[17] = 0x1499999a; + channel_div_table[18] = 0x14a22222; + channel_div_table[19] = 0x14aaaaab; + channel_div_table[20] = 0x14b33333; + rx_notch_para_40M[0][0] = 0; + rx_notch_para_40M[0][1] = 0; + rx_notch_para_40M[1][0] = 0; + rx_notch_para_40M[1][1] = 0; + rx_notch_para_40M[2][0] = 0; + rx_notch_para_40M[2][1] = 0; + rx_notch_para_40M[3][0] = 0; + rx_notch_para_40M[3][1] = 0; + rx_notch_para_40M[4][0] = 1; + rx_notch_para_40M[4][1] = 8000000; + rx_notch_para_40M[5][0] = 1; + rx_notch_para_40M[5][1] = 3000000; + rx_notch_para_40M[6][0] = 1; + rx_notch_para_40M[6][1] = -2000000; + rx_notch_para_40M[7][0] = 1; + rx_notch_para_40M[7][1] = -7000000; + rx_notch_para_40M[8][0] = 0; + rx_notch_para_40M[8][1] = 0; + rx_notch_para_40M[9][0] = 0; + rx_notch_para_40M[9][1] = 0; + rx_notch_para_40M[10][0] = 0; + rx_notch_para_40M[10][1] = 0; + rx_notch_para_40M[11][0] = 0; + rx_notch_para_40M[11][1] = 0; + rx_notch_para_40M[12][0] = 1; + rx_notch_para_40M[12][1] = 8000000; + rx_notch_para_40M[13][0] = 1; + rx_notch_para_40M[13][1] = -4000000; + channel_cnt_range._0_4_ = 0xa6e0a6a0; + channel_cnt_range[2] = 0xace0; + fcal_div = 0x855; + return; + } + if (xtalfreq != 5) { + return; + } + channel_div_table[0] = 0xf690690; + channel_div_table[1] = 0xf6f96f9; + channel_div_table[2] = 0xf762762; + channel_div_table[3] = 0xf7cb7cb; + channel_div_table[4] = 0xf834835; + channel_div_table[5] = 0xf89d89e; + channel_div_table[6] = 0xf906907; + channel_div_table[7] = 0xf96f970; + channel_div_table[8] = 0xf9d89d9; + channel_div_table[9] = 0xfa41a42; + channel_div_table[10] = 0xfaaaaab; + channel_div_table[11] = 0xfb13b14; + channel_div_table[12] = 0xfb7cb7d; + channel_div_table[13] = 0xfbe5be6; + channel_div_table[14] = 0xfc4ec4f; + channel_div_table[15] = 0xfcb7cb8; + channel_div_table[16] = 0xfd20d21; + channel_div_table[17] = 0xfd89d8a; + channel_div_table[18] = 0xfdf2df3; + channel_div_table[19] = 0xfe5be5c; + channel_div_table[20] = 0xfec4ec5; + channel_cnt_table._0_4_ = 0xa734a6ed; + channel_cnt_table._4_4_ = 0xa7c2a77b; + channel_cnt_table._8_4_ = 0xa850a809; + channel_cnt_table._12_4_ = 0xa8dea897; + channel_cnt_table._16_4_ = 0xa96da925; + channel_cnt_table._20_4_ = 0xa9fba9b4; + channel_cnt_table._24_4_ = 0xaa89aa42; + channel_cnt_table._28_4_ = 0xab17aad0; + channel_cnt_table._32_4_ = 0xaba5ab5e; + channel_cnt_table._36_4_ = 0xac34abec; + channel_cnt_table[20] = 0xac7b; + channel_cnt_range._0_4_ = 0xa6e2a6a2; + channel_cnt_range[2] = 0xace2; + fcal_div = 0xad5; + rx_notch_para_40M[5][0] = 1; + rx_notch_para_40M[6][0] = 1; + rx_notch_para_40M[7][0] = 1; + rx_notch_para_40M[5][1] = 7000000; + rx_notch_para_40M[6][1] = (int32_t)&DAT_001e8480; + rx_notch_para_40M[7][1] = -3000000; + rx_notch_para_40M[0][0] = 0; + rx_notch_para_40M[1][0] = 0; + rx_notch_para_40M[2][0] = 0; + rx_notch_para_40M[3][0] = 0; + rx_notch_para_40M[4][0] = 0; + rx_notch_para_40M[9][0] = 0; + rx_notch_para_40M[10][0] = 0; + rx_notch_para_40M[11][0] = 0; + rx_notch_para_40M[12][0] = 0; + rx_notch_para_40M[0][1] = 0; + rx_notch_para_40M[1][1] = 0; + rx_notch_para_40M[2][1] = 0; + rx_notch_para_40M[3][1] = 0; + rx_notch_para_40M[4][1] = 0; + rx_notch_para_40M[8][1] = -8000000; + rx_notch_para_40M[9][1] = 0; + rx_notch_para_40M[10][1] = 0; + rx_notch_para_40M[11][1] = 0; + goto LAB_2301713c; + } + channel_div_table[0] = 0x190aaaab; + channel_div_table[1] = 0x19155555; + channel_div_table[2] = 0x19200000; + channel_div_table[3] = 0x192aaaab; + channel_div_table[4] = 0x19355555; + channel_div_table[5] = 0x19400000; + channel_div_table[6] = 0x194aaaab; + channel_div_table[7] = 0x19555555; + channel_div_table[8] = 0x19600000; + channel_div_table[9] = 0x196aaaab; + channel_div_table[10] = 0x19755555; + channel_div_table[11] = 0x19800000; + channel_div_table[12] = 0x198aaaab; + channel_div_table[13] = 0x19955555; + channel_div_table[14] = 0x19a00000; + channel_div_table[15] = 0x19aaaaab; + channel_div_table[16] = 0x19b55555; + channel_div_table[17] = 0x19c00000; + channel_div_table[18] = 0x19caaaab; + channel_div_table[19] = 0x19d55555; + channel_div_table[20] = 0x19e00000; + channel_cnt_table._0_4_ = 0xa741a6fa; + channel_cnt_table._4_4_ = 0xa7d0a788; + channel_cnt_table._8_4_ = 0xa85ea817; + channel_cnt_table._12_4_ = 0xa8eca8a5; + channel_cnt_table._16_4_ = 0xa97aa933; + channel_cnt_table._20_4_ = 0xaa09a9c1; + channel_cnt_table._24_4_ = 0xaa97aa50; + channel_cnt_table._28_4_ = 0xab25aade; + channel_cnt_table._32_4_ = 0xabb3ab6c; + channel_cnt_table._36_4_ = 0xac42abfa; + channel_cnt_table[20] = 0xac89; + channel_cnt_range._0_4_ = 0xa6efa6af; + channel_cnt_range[2] = 0xacf0; + fcal_div = 0x6ab; + rx_notch_para_40M[4][0] = 1; + rx_notch_para_40M[9][0] = 1; + rx_notch_para_40M[12][0] = 1; + rx_notch_para_40M[2][1] = 10000000; + rx_notch_para_40M[3][1] = 5000000; + rx_notch_para_40M[5][1] = -5000000; + rx_notch_para_40M[6][1] = -10000000; + rx_notch_para_40M[9][1] = 7000000; + rx_notch_para_40M[10][1] = (int32_t)&DAT_001e8480; + rx_notch_para_40M[11][1] = -3000000; + rx_notch_para_40M[8][0] = 0; + rx_notch_para_40M[0][1] = 0; + rx_notch_para_40M[1][1] = 0; + rx_notch_para_40M[7][1] = 0; + rx_notch_para_40M[8][1] = 0; + rx_notch_para_40M[12][1] = -8000000; + } + rx_notch_para_40M[4][1] = 0; + rx_notch_para_40M[0][0] = rx_notch_para_40M[8][0]; + rx_notch_para_40M[1][0] = rx_notch_para_40M[8][0]; + rx_notch_para_40M[2][0] = rx_notch_para_40M[12][0]; + rx_notch_para_40M[3][0] = rx_notch_para_40M[12][0]; + rx_notch_para_40M[5][0] = rx_notch_para_40M[12][0]; + rx_notch_para_40M[6][0] = rx_notch_para_40M[12][0]; + rx_notch_para_40M[7][0] = rx_notch_para_40M[8][0]; + rx_notch_para_40M[10][0] = rx_notch_para_40M[12][0]; + rx_notch_para_40M[11][0] = rx_notch_para_40M[12][0]; + } + rx_notch_para_40M[13][0] = 0; + rx_notch_para_40M[13][1] = 0; + return; +} + + + +uint32_t rf_pri_get_vco_freq_cw(uint32_t chanfreq_MHz) + +{ + int iVar1; + + __floatunsidf(chanfreq_MHz - 0x964 >> 2); + __adddf3(); + iVar1 = __fixdfsi(); + if (0x14 < iVar1) { + iVar1 = 0x14; + } + return (uint)*(ushort *)(&(rf_calib_data->cal).field_0x8 + (iVar1 + 8) * 2) & 0xff; +} + + + +uint32_t rf_pri_get_vco_idac_cw(uint32_t chanfreq_MHz) + +{ + int iVar1; + + __floatunsidf(chanfreq_MHz - 0x964 >> 2); + __adddf3(); + iVar1 = __fixdfsi(); + if (0x14 < iVar1) { + iVar1 = 0x14; + } + return (uint)(*(ushort *)(&(rf_calib_data->cal).field_0x8 + (iVar1 + 8) * 2) >> 8) & 0x1f; +} + + + +int32_t rf_pri_get_txgain_max(void) + +{ + return tx_pwr_os_temperature + tx_pwr_table[0][6] + tx_pwr_os; +} + + + +int32_t rf_pri_get_txgain_min(void) + +{ + return tx_pwr_os_temperature + tx_pwr_table[15][6] + tx_pwr_os; +} + + + +uint32_t rf_pri_get_txgain_index(int32_t pwr,uint32_t mode) + +{ + int32_t *piVar1; + uint32_t uVar2; + + if (mode == 0) { + pwr = pwr + -0x1e; + } + piVar1 = tx_pwr_table; + uVar2 = 0; + do { + if (piVar1[6] + tx_pwr_os + tx_pwr_os_temperature <= pwr) { + return uVar2; + } + uVar2 = uVar2 + 1; + piVar1 = piVar1 + 7; + } while (uVar2 != 0x10); + return 0xf; +} + + + +void rf_pri_query_txgain_table(uint32_t index,uint32_t *rfg_index,uint32_t *dg) + +{ + if (0xf < index) { + index = 0xf; + } + *rfg_index = 7 - (index >> 1); + *dg = tx_pwr_table[index * 7 + 5]; + return; +} + + + +void rf_pri_update_dvga_os(int8_t dvga_os) + +{ + int iVar1; + int32_t *piVar2; + int8_t *piVar3; + + piVar2 = tx_pwr_table; + iVar1 = 0; + do { + piVar3 = temps_dvga + iVar1; + iVar1 = iVar1 + 1; + *piVar3 = (char)piVar2[5] + dvga_os; + piVar2 = piVar2 + 7; + } while (iVar1 != 0x10); + return; +} + + + +void rf_pri_tx_gain_comp(int32_t Tsens) + +{ + int iVar1; + int iVar2; + int32_t *piVar3; + uint uVar4; + + if (up_dn == 1) { + if ((Tthr <= Tsens) || (Tsens <= Tthr + -5)) { +LAB_23017d2a: + piVar3 = temps; + iVar2 = 0xc; + do { + if (piVar3[0xc] <= Tsens) break; + iVar2 = iVar2 + -1; + piVar3 = piVar3 + -1; + } while (iVar2 != -1); + if (iVar2 < 0) { + iVar2 = 0; + } + uVar4 = iVar2 - 4; + iVar1 = temps[iVar2]; + Tthr = iVar1; + if (Tsens < 0x23) { + if (iVar1 < Tsens) { + Tthr = temps[iVar2 + 1]; + if (0x22 < temps[iVar2 + 1]) { + Tthr = iVar1; + } + } + else { + uVar4 = iVar2 - 5; + } + } + else { + if (iVar1 < 0x24) { + Tthr = temps[iVar2 + 1]; + } + } + if (index_os_pre_mdb < (int)uVar4) { + up_dn = 1; + } + else { + if ((int)uVar4 < index_os_pre_mdb) { + up_dn = -1; + } + } + if ((int)uVar4 < 1) { + dvga_os_pre = 0; + index_os_pre = uVar4; + if (uVar4 != 0) { + dvga_os_pre = 0xffffffff; + if ((uVar4 & 1) != 0) { + dvga_os_pre = 1; + } + index_os_pre = (int)(uVar4 - 1) / 2; + } + } + else { + dvga_os_pre = uVar4 + 1 & 1; + if (dvga_os_pre == 0) { + dvga_os_pre = 0xffffffff; + } + index_os_pre = (int)(uVar4 + 1) >> 1; + } + tx_pwr_os_temperature = index_os_pre * -10; + index_os_pre_mdb = uVar4; + goto LAB_23017cfe; + } + } + else { + if (((up_dn != -1) || (Tsens <= Tthr)) || (Tthr + 5 <= Tsens)) goto LAB_23017d2a; + } + tx_pwr_os_temperature = index_os_pre * -10; +LAB_23017cfe: + rf_pri_update_dvga_os((int8_t)dvga_os_pre); + rfc_apply_tx_dvga(temps_dvga); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_txcal(void) + +{ + int32_t val; + uint32_t center; + uint val_00; + uint val_01; + uint32_t *puVar1; + int iVar2; + uint32_t *puVar3; + int32_t *piVar4; + uint val_02; + uint uVar5; + int iVar6; + + _DAT_40001014 = _DAT_40001014 & 0xff0fffff | 0x500000; + rf_pri_save_state_for_cal(); + rf_pri_manu_pu(5); + rf_pri_config_channel(); + _DAT_4000101c = _DAT_4000101c | 0x3000; + _DAT_40001084 = _DAT_40001084 | 0x80000000; + _DAT_40001064 = _DAT_40001064 | 0x400000; + iVar2 = 7; + _DAT_4000106c = (uint)tmxcss[0] | _DAT_4000106c & 0xfffffff8; + rf_pri_singen_config(0x3d); + puVar3 = txcal_para; + piVar4 = tx_pwr_table; + do { + _DAT_40001064 = *puVar3 << 0x1c | _DAT_40001064 & 0xfc3ffff | puVar3[2] << 0x12; + _DAT_40001058 = puVar3[1] << 0x10 | _DAT_40001058 & 0xfff8ffff; + _DAT_40001048 = *piVar4 << 0x1c | _DAT_40001048 & 0xce08ffff | piVar4[3] << 0x14 | 0x70000; + BL602_Delay_US(10); + val_02 = puVar3[3]; + uVar5 = val_02; + do { + uVar5 = uVar5 >> 1; + _DAT_40001214 = val_02 | _DAT_40001214 & 0xfffff800; + _DAT_40001218 = val_02 | _DAT_40001218 & 0xfffff800; + rf_pri_singen_start(); + rf_pri_start_txdfe(); + BL602_Delay_US(10); + val = rf_pri_pm_pwr_avg(1,0x400); + iVar6 = val >> 10; + printf("amp=%ld,step=%ld,adc_mean_i=%ld\r\n",val_02,uVar5,iVar6); + if (iVar6 < 0x141) { + val_00 = uVar5; + if (0xbf < iVar6) break; + } + else { + val_00 = -uVar5; + } + val_02 = val_02 + val_00; + } while (uVar5 != 0); + rf_pri_pm_pwr_avg(1,0x1000); + center = rf_pri_txcal_search_core(0,0x20,0x10,0x3d); + rf_pri_txcal_config(0,center); + uVar5 = rf_pri_txcal_search_core(1,0x20,0x10,0x3d); + _DAT_40001070 = uVar5 << 0x10 | _DAT_40001070 & 0xffc0ffff; + val_02 = rf_pri_txcal_search_core(0,center,2,0x3d); + rf_pri_txcal_config(0,val_02); + center = rf_pri_txcal_search_core(2,0x400,0x80,0x7a); + rf_pri_txcal_config(2,center); + val = rf_pri_txcal_search_core(3,0,0x40,0x7a); + rf_pri_txcal_config(3,val); + val_00 = rf_pri_txcal_search_core(2,center,0x40,0x7a); + rf_pri_txcal_config(2,val_00); + val_01 = rf_pri_txcal_search_core(3,0,0x20,0x7a); + rf_pri_txcal_config(3,val_01); + puVar1 = &rf_calib_data->inited + (iVar2 + 0xc) * 2; + puVar1[2] = puVar1[2] & 0xffffffc0 | val_02 & 0x3f; + puVar1[2] = puVar1[2] & 0xfffff03f | (uVar5 & 0x3f) << 6; + puVar1[2] = puVar1[2] & 0xff800fff | (val_00 & 0x7ff) << 0xc; + puVar1[3] = puVar1[3] & 0xfffffc00 | val_01 & 0x3ff; + printf("tosdac_i=%ld,tosdac_q=%ld,tx_iq_gain_comp=%ld,tx_iq_phase_comp=%ld\r\n",val_02,uVar5, + val_00); + iVar2 = iVar2 + -1; + puVar3 = puVar3 + 4; + piVar4 = piVar4 + 0xe; + if (iVar2 == -1) { + rf_pri_txcal_config_hw(); + _DAT_4000101c = _DAT_4000101c & 0xffffcfff; + rf_pri_restore_state_for_cal(); + _DAT_40001014 = _DAT_40001014 | 0xf00000; + _DAT_40001070 = + (*(uint *)(rf_calib_data->txcal + 3) >> 6 & 0x3f) << 0x10 | + (*(uint *)(rf_calib_data->txcal + 3) & 0x3f) << 0x18 | _DAT_40001070 & 0xc0c0ffff; + _DAT_40001600 = + *(uint *)&rf_calib_data->txcal[3].field_0x4 & 0x3ff | + *(uint *)(rf_calib_data->txcal + 3) & 0x7ff000 | _DAT_40001600 & 0xff800c00; + return; + } + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_roscal(void) + +{ + uint32_t uVar1; + uint uVar2; + + _DAT_40001014 = _DAT_40001014 & 0xffff3fff; + if ((_DAT_40001020 & 0x100) != 0) { + _DAT_40001014 = _DAT_40001014 | 0x4000; + rf_pri_save_state_for_cal(); + rf_pri_manu_pu(3); + _DAT_4000101c = _DAT_4000101c | 0x200; + rf_pri_config_channel(); + _DAT_40001048 = _DAT_40001048 & 0xffff8fff | 0x6300; + uVar1 = rf_pri_roscal_iq(1); + uVar2 = uVar1 & 0x3f; + *(uint *)(rf_calib_data->rxcal + 3) = *(uint *)(rf_calib_data->rxcal + 3) & 0xffffffc0 | uVar2; + _DAT_4000116c = _DAT_4000116c & 0xffc0ffff | uVar1 << 0x10; + printf("rosdac_i_gc3=%ld\r\n",uVar1); + *(uint *)(rf_calib_data->rxcal + 2) = *(uint *)(rf_calib_data->rxcal + 2) & 0xffffffc0 | uVar2; + _DAT_4000116c = uVar1 | _DAT_4000116c & 0xffffffc0; + printf("rosdac_i_gc2=%ld\r\n",uVar1); + *(uint *)(rf_calib_data->rxcal + 1) = *(uint *)(rf_calib_data->rxcal + 1) & 0xffffffc0 | uVar2; + _DAT_40001168 = uVar1 << 0x10 | _DAT_40001168 & 0xffc0ffff; + printf("rosdac_i_gc1=%ld\r\n",uVar1); + *(uint *)rf_calib_data->rxcal = *(uint *)rf_calib_data->rxcal & 0xffffffc0 | uVar2; + _DAT_40001168 = uVar1 | _DAT_40001168 & 0xffffffc0; + printf("rosdac_i_gc0=%ld\r\n",uVar1); + uVar1 = rf_pri_roscal_iq(0); + uVar2 = (uVar1 & 0x3f) << 6; + *(uint *)(rf_calib_data->rxcal + 3) = *(uint *)(rf_calib_data->rxcal + 3) & 0xfffff03f | uVar2; + _DAT_4000116c = _DAT_4000116c & 0xc0ffffff | uVar1 << 0x18; + printf("rosdac_q_gc3=%ld\r\n",uVar1); + *(uint *)(rf_calib_data->rxcal + 2) = *(uint *)(rf_calib_data->rxcal + 2) & 0xfffff03f | uVar2; + _DAT_4000116c = _DAT_4000116c & 0xffffc0ff | uVar1 << 8; + printf("rosdac_q_gc2=%ld\r\n",uVar1); + *(uint *)(rf_calib_data->rxcal + 1) = *(uint *)(rf_calib_data->rxcal + 1) & 0xfffff03f | uVar2; + _DAT_40001168 = uVar1 << 0x18 | _DAT_40001168 & 0xc0ffffff; + printf("rosdac_q_gc1=%ld\r\n",uVar1); + *(uint *)rf_calib_data->rxcal = *(uint *)rf_calib_data->rxcal & 0xfffff03f | uVar2; + _DAT_40001168 = uVar1 << 8 | _DAT_40001168 & 0xffffc0ff; + printf("rosdac_q_gc0=%ld\r\n",uVar1); + rf_pri_restore_state_for_cal(); + _DAT_40001014 = _DAT_40001014 | 0xc000; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_rccal(void) + +{ + rf_calib_data_tag *prVar1; + uint32_t uVar2; + uint32_t uVar3; + uint uVar4; + uint uVar5; + + _DAT_40001014 = _DAT_40001014 & 0xfff3ffff; + if ((_DAT_40001020 & 0x400) != 0) { + _DAT_40001014 = _DAT_40001014 | 0x40000; + rf_pri_save_state_for_cal(); + rf_pri_manu_pu(4); + _DAT_40001084 = _DAT_40001084 & 0xfcffffff | 0x2000000; + _DAT_4000108c = _DAT_4000108c | 0x1000; + _DAT_4000101c = _DAT_4000101c | 0x800; + uVar2 = rf_pri_rccal_iq(1); + uVar3 = rf_pri_rccal_iq(0); + prVar1 = rf_calib_data; + uVar5 = _DAT_40001080; + *(uint *)&(rf_calib_data->cal).field_0x4 = + *(uint *)&(rf_calib_data->cal).field_0x4 & 0xffffffc0 | _DAT_40001080 >> 0x18 & 0x3f; + *(uint *)&(prVar1->cal).field_0x4 = + *(uint *)&(prVar1->cal).field_0x4 & 0xfffff03f | (uVar5 >> 0x10 & 0x3f) << 6; + *(uint *)&(prVar1->cal).field_0x4 = + *(uint *)&(prVar1->cal).field_0x4 & 0xfffc0fff | (uVar5 >> 8 & 0x3f) << 0xc; + *(uint *)&(prVar1->cal).field_0x4 = + (uVar5 & 0x3f) << 0x12 | *(uint *)&(prVar1->cal).field_0x4 & 0xff03ffff; + printf("rbb_cap1_fc_i=%ld,rbb_cap2_fc_i=%ld,rbb_cap1_fc_q=%ld,rbb_cap2_fc_q=%ld\r\n", + *(uint *)&(prVar1->cal).field_0x4 & 0x3f,*(uint *)&(prVar1->cal).field_0x4 >> 0xc & 0x3f, + *(uint *)&(prVar1->cal).field_0x4 >> 6 & 0x3f, + *(uint *)&(prVar1->cal).field_0x4 >> 0x12 & 0x3f); + prVar1 = rf_calib_data; + uVar5 = *(uint *)&(rf_calib_data->cal).field_0x4 & 0x3f; + if (uVar5 < (*(uint *)&(rf_calib_data->cal).field_0x4 >> 6 & 0x3f)) { + uVar5 = *(uint *)&(rf_calib_data->cal).field_0x4 >> 6 & 0x3f; + } + if (uVar5 < (*(uint *)&(rf_calib_data->cal).field_0x4 >> 0xc & 0x3f)) { + uVar5 = *(uint *)&(rf_calib_data->cal).field_0x4 >> 0xc & 0x3f; + } + if (uVar5 < (*(uint *)&(rf_calib_data->cal).field_0x4 >> 0x12 & 0x3f)) { + uVar5 = *(uint *)&(rf_calib_data->cal).field_0x4 >> 0x12 & 0x3f; + } + uVar4 = 0x18; + if (0x27 < uVar5) { + uVar4 = 0x3f - uVar5; + } + uVar4 = uVar4 & 0xff; + *(uint *)&(rf_calib_data->cal).field_0x4 = + *(uint *)&(rf_calib_data->cal).field_0x4 & 0xffffffc0 | + *(int *)&(rf_calib_data->cal).field_0x4 + uVar4 & 0x3f; + *(uint *)&(prVar1->cal).field_0x4 = + ((*(uint *)&(prVar1->cal).field_0x4 >> 6) + uVar4 & 0x3f) << 6 | + *(uint *)&(prVar1->cal).field_0x4 & 0xfffff03f; + *(uint *)&(prVar1->cal).field_0x4 = + ((*(uint *)&(prVar1->cal).field_0x4 >> 0xc) + uVar4 & 0x3f) << 0xc | + *(uint *)&(prVar1->cal).field_0x4 & 0xfffc0fff; + *(uint *)&(prVar1->cal).field_0x4 = + ((*(uint *)&(prVar1->cal).field_0x4 >> 0x12) + uVar4 & 0x3f) << 0x12 | + *(uint *)&(prVar1->cal).field_0x4 & 0xff03ffff; + rf_pri_rccal_config(*(uint *)&(prVar1->cal).field_0x4 & 0x3f); + rf_pri_rccal_config(0,*(uint *)&(rf_calib_data->cal).field_0x4 >> 6 & 0x3f); + printf("new rbb_cap1_fc_i=%ld,rbb_cap2_fc_i=%ld,rbb_cap1_fc_q=%ld,rbb_cap2_fc_q=%ld\r\n", + *(uint *)&(rf_calib_data->cal).field_0x4 & 0x3f, + *(uint *)&(rf_calib_data->cal).field_0x4 >> 0xc & 0x3f, + *(uint *)&(rf_calib_data->cal).field_0x4 >> 6 & 0x3f, + *(uint *)&(rf_calib_data->cal).field_0x4 >> 0x12 & 0x3f); + rf_pri_restore_state_for_cal(); + if ((uVar2 == 2) || (uVar3 == 2)) { + _DAT_40001014 = _DAT_40001014 & 0xfff3ffff | 0x80000; + } + else { + _DAT_40001014 = _DAT_40001014 | 0xc0000; + } + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_lo_acal(void) + +{ + uint uVar1; + int iVar2; + int iVar3; + uint32_t *puVar4; + uint32_t *puVar5; + uint uVar6; + + _DAT_40001014 = _DAT_40001014 & 0xffffff3f | 0x40; + rf_pri_save_state_for_cal(); + rf_pri_manu_pu(6); + puVar4 = channel_div_table; + iVar3 = 0; + do { + _DAT_4000101c = _DAT_4000101c | 0x10; + _DAT_400010a4 = _DAT_400010a4 & 0xfffff8ff | 0x400; + uVar6 = 3; + uVar1 = 0x10; + _DAT_400010a0 = + (uint)*(ushort *)(&(rf_calib_data->cal).field_0x8 + (iVar3 + 8) * 2) & 0xff | + _DAT_400010a0 & 0xffe0ff00 | 0x100000; + _DAT_400010c4 = *puVar4; + BL602_Delay_US(1); + while (_DAT_400010a0 = _DAT_400010a0 & 0xffe0ffff | uVar1 << 0x10, uVar6 != 0xffffffff) { + BL602_Delay_US(1); + iVar2 = 1 << (uVar6 & 0x1f); + if ((int)(_DAT_400010a4 << 0x13) < 0) { + iVar2 = -iVar2; + } + uVar1 = uVar1 + iVar2; + uVar6 = uVar6 - 1; + } + BL602_Delay_US(1); + if ((-1 < (int)(_DAT_400010a4 << 0x13)) && (uVar1 < 0x1f)) { + uVar1 = uVar1 + 1; + } + puVar5 = (uint32_t *)((int)&rf_calib_data->inited + (iVar3 + 8) * 2); + *(ushort *)(puVar5 + 3) = *(ushort *)(puVar5 + 3) & 0xe0ff | (ushort)((uVar1 & 0x1f) << 8); + printf("%ldth channel,vco_idac_cw=%ld\r\n",iVar3,uVar1); + iVar3 = iVar3 + 1; + puVar4 = puVar4 + 1; + } while (iVar3 != 0x15); + rf_pri_restore_state_for_cal(); + _DAT_40001014 = _DAT_40001014 | 0xc0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_fcal(void) + +{ + uint cw; + uint16_t uVar1; + undefined2 extraout_var; + undefined2 extraout_var_00; + int iVar2; + uint32_t *puVar3; + uint uVar4; + uint uVar5; + uint cw_00; + uint16_t *puVar6; + uint uVar7; + + cw_00 = (uint)channel_cnt_range[0]; + uVar7 = (uint)channel_cnt_range[1]; + uVar5 = (uint)channel_cnt_range[2]; + _DAT_40001014 = _DAT_40001014 & 0xffffffcf | 0x10; + rf_pri_save_state_for_cal(); + rf_pri_manu_pu(7); + _DAT_4000101c = _DAT_4000101c | 8; + _DAT_400010a0 = _DAT_400010a0 & 0xffffff00 | 0x80; + _DAT_400010a8 = (uint)fcal_div | _DAT_400010a8 & 0xffff0000; + _DAT_400010c4 = 0x1000000; + _DAT_400010c0 = _DAT_400010c0 & 0xfffeffff | 0x1000; + _DAT_400010b8 = _DAT_400010b8 & 0xffffcfff | 0x10000; + BL602_Delay_US(10); + _DAT_400010c0 = _DAT_400010c0 | 0x10000; + _DAT_400010b8 = _DAT_400010b8 & 0xfffeffff; + BL602_Delay_US(0x32); + _DAT_400010a4 = _DAT_400010a4 & 0xfffffffc | 2; + BL602_Delay_US(0x32); + do { + uVar4 = 6; + cw = 0x80; + while (uVar4 != 0xffffffff) { + uVar1 = rf_pri_fcal_meas(cw); + if (CONCAT22(extraout_var,uVar1) < cw_00) { + iVar2 = -(1 << (uVar4 & 0x1f)); + } + else { + if (CONCAT22(extraout_var,uVar1) <= uVar7) break; + iVar2 = 1 << (uVar4 & 0x1f); + } + cw = cw + iVar2 & 0xffff; + uVar4 = uVar4 - 1; + } + if (0xe < cw) break; + printf("Unexpected cw %ld\r\n",cw); + _DAT_400010c0 = _DAT_400010c0 & 0xfffeffff; + _DAT_400010b8 = _DAT_400010b8 | 0x10000; + BL602_Delay_US(0x32); + _DAT_400010c0 = _DAT_400010c0 | 0x10000; + _DAT_400010b8 = _DAT_400010b8 & 0xfffeffff; + BL602_Delay_US(0x32); + } while( true ); + cw_00 = cw + 1 & 0xffff; + channel_cnt_opt_table[0] = rf_pri_fcal_meas(cw_00); + puVar6 = channel_cnt_opt_table; + do { + cw_00 = cw_00 - 1 & 0xffff; + uVar1 = rf_pri_fcal_meas(cw_00); + puVar6[1] = uVar1; + if (uVar5 < CONCAT22(extraout_var_00,uVar1)) break; + puVar6 = puVar6 + 1; + } while (cw_00 != (cw - 0x26 & 0xffff)); + iVar2 = 0; + uVar5 = 0; + puVar6 = channel_cw_table; + do { + while (cw_00 = uVar5 & 0xffff, + channel_cnt_opt_table[uVar5] < *(ushort *)((int)channel_cnt_table + iVar2)) { + uVar5 = (int)((cw_00 + 1) * 0x10000) >> 0x10; + } + *(short *)((int)channel_cw_table + iVar2) = ((short)cw + 2) - (short)cw_00; + if ((int)uVar5 < 1) { + uVar5 = 0; + } + else { + uVar5 = (int)((cw_00 - 1) * 0x10000) >> 0x10; + } + iVar2 = iVar2 + 2; + } while (iVar2 != 0x2a); + rf_pri_restore_state_for_cal(); + iVar2 = 0; + do { + puVar3 = (uint32_t *)((int)&rf_calib_data->inited + (iVar2 + 8) * 2); + iVar2 = iVar2 + 1; + *(ushort *)(puVar3 + 3) = *(ushort *)(puVar3 + 3) & 0xff00 | *puVar6 & 0xff; + printf("%ldth channel,lo_vco_freq_cw=%ld\r\n"); + puVar6 = puVar6 + 1; + } while (iVar2 != 0x15); + _DAT_40001014 = _DAT_40001014 | 0x30; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_full_cal(void) + +{ + _DAT_40001220 = _DAT_40001220 & 0xffffff9f | 0x61; + rf_pri_start_txdfe(); + rf_pri_fcal(); + rf_pri_lo_acal(); + rf_pri_roscal(); + rf_pri_rccal(); + rf_pri_txcal(); + _DAT_4000100c = _DAT_4000100c | 6; + _DAT_40001220 = _DAT_40001220 & 0xffffe61c; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_restore_cal_reg(void) + +{ + _DAT_40001168 = + (*(uint *)(rf_calib_data->rxcal + 1) >> 6 & 0x3f) << 0x18 | + (*(uint *)rf_calib_data->rxcal >> 6 & 0x3f) << 8 | + *(uint *)rf_calib_data->rxcal & 0x3f | _DAT_40001168 & 0xc0c0c0c0 | + (*(uint *)(rf_calib_data->rxcal + 1) & 0x3f) << 0x10; + _DAT_4000116c = + (*(uint *)(rf_calib_data->rxcal + 3) >> 6 & 0x3f) << 0x18 | + (*(uint *)(rf_calib_data->rxcal + 2) >> 6 & 0x3f) << 8 | + *(uint *)(rf_calib_data->rxcal + 2) & 0x3f | _DAT_4000116c & 0xc0c0c0c0 | + (*(uint *)(rf_calib_data->rxcal + 3) & 0x3f) << 0x10; + _DAT_40001080 = + (*(uint *)&(rf_calib_data->cal).field_0x4 >> 6 & 0x3f) << 0x10 | + (*(uint *)&(rf_calib_data->cal).field_0x4 >> 0xc & 0x3f) << 8 | + (*(uint *)&(rf_calib_data->cal).field_0x4 & 0x3f) << 0x18 | _DAT_40001080 & 0xc0c0c0c0 | + *(uint *)&(rf_calib_data->cal).field_0x4 >> 0x12 & 0x3f; + rf_pri_txcal_config_hw(); + _DAT_40001070 = + (*(uint *)(rf_calib_data->txcal + 3) >> 6 & 0x3f) << 0x10 | + (*(uint *)(rf_calib_data->txcal + 3) & 0x3f) << 0x18 | _DAT_40001070 & 0xc0c0ffff; + _DAT_40001600 = + *(uint *)(rf_calib_data->txcal + 3) & 0x7ff000 | _DAT_40001600 & 0xff800c00 | + *(uint *)&rf_calib_data->txcal[3].field_0x4 & 0x3ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_init(uint8_t reset,uint8_t chipv) + +{ + undefined3 in_register_00002029; + int iVar1; + + iVar1 = CONCAT31(in_register_00002029,reset); + rf_pri_chipv(chipv); + init_fast = (uint32_t)(iVar1 == 0); + _DAT_4000f814 = _DAT_4000f814 & 0xfffff0ff | 0x300; + _DAT_4000f030 = _DAT_4000f030 & 0xf0ffffff | 0x8000000; + _DAT_40001030 = _DAT_40001030 | 0x1001; + _DAT_4000f884 = _DAT_4000f884 | 4; + if (iVar1 != 0) { + BL602_Delay_MS(10); + } + _DAT_40001064 = _DAT_40001064 & 0xffff8008 | opti_regs->vbcore << 8 | opti_regs->iet << 4 | 0x4002 + ; + _DAT_40001128 = + _DAT_40001128 & 0xff800fff | opti_regs->vbcore_11n << 0x10 | opti_regs->iet_11n << 0xc | + 0x400000; + _DAT_4000112c = + (_DAT_4000112c & 0xfffff800 | opti_regs->vbcore_11g << 4 | opti_regs->iet_11g) & 0xff800fff | + 0x400 | opti_regs->vbcore_11b << 0x10 | opti_regs->iet_11b << 0xc | 0x400000; + _DAT_40001090 = _DAT_40001090 | 0x10000; + _DAT_400010b8 = opti_regs->lo_fbdv_halfstep_en << 4 | _DAT_400010b8 & 0xffffffef; + _DAT_40001138 = + (_DAT_40001138 & 0xfffffffc | opti_regs->lo_fbdv_halfstep_en_tx << 1 | + opti_regs->lo_fbdv_halfstep_en_tx) & 0xfffcfff7 | 0x300; + _DAT_40001130 = _DAT_40001130 & 0xfffefffe; + _DAT_4000e400 = opti_regs->clkpll_reset_postdiv << 1 | _DAT_4000e400 & 0xfffffffd; + _DAT_4000e418 = opti_regs->clkpll_dither_sel << 0x18 | _DAT_4000e418 & 0xfcffffff; + _DAT_4000108c = _DAT_4000108c & 0xfffffffc | 2; + _DAT_4000f030 = _DAT_4000f030 & 0xfff0ffff | 0xc0000; + rf_pri_set_gain_table_regs(); + _DAT_4000e404 = _DAT_4000e404 | 0x10000; + _DAT_4000e41c = _DAT_4000e41c | 0xff; + if (iVar1 == 0) { + rf_pri_restore_cal_reg(); + return; + } + rf_pri_full_cal(); + return; +} + + + +void rf_pri_update_power_offset(int32_t *power_offset) + +{ + undefined4 uVar1; + int iVar2; + + iVar2 = 0; + do { + uVar1 = *(undefined4 *)((int)power_offset + iVar2); + *(undefined4 *)((int)tx_pwr_ch_os_a1 + iVar2) = uVar1; + *(undefined4 *)((int)tx_pwr_ch_os + iVar2) = uVar1; + iVar2 = iVar2 + 4; + } while (iVar2 != 0x38); + return; +} + + + +int phyif_utils_decode(phyif_utils_recvtable_t *vec,int8_t *ppm) + +{ + char cVar1; + int8_t iVar2; + SItype SVar3; + + cVar1 = *(char *)((int)&vec->recvtable5 + 3); + if (((*(ushort *)((int)&vec->recvtable2 + 2) & 7) < 2) && ((vec->recvtable1 >> 0xc & 0xf) < 4)) { + __floatsidf(-(int)cVar1); + __muldf3(); + SVar3 = __fixdfsi(); + iVar2 = (int8_t)SVar3; + } + else { + iVar2 = (int8_t)((int)CONCAT11(*(undefined *)&vec->recvtable6,cVar1) / 0x7a); + } + *ppm = iVar2; + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sysctrl_init(void) + +{ + _DAT_44900068 = 0x8000000c; + _DAT_449000e0 = _DAT_449000e0 | 0x1ff00; + return; +} + + + +void intc_spurious(void) + +{ + assert_err("0","module",0x36); + return; +} + + + +void intc_enable_irq(int index) + +{ + *(int *)(((index >> 5) + 0x11244004) * 4) = 1 << (index & 0x1fU); + return; +} + + + +void intc_init(void) + +{ + intc_enable_irq(0x3f); + intc_enable_irq(0x3e); + intc_enable_irq(0x3d); + intc_enable_irq(0x18); + intc_enable_irq(0x19); + intc_enable_irq(0x1a); + intc_enable_irq(0x1b); + intc_enable_irq(0x1c); + intc_enable_irq(0x1d); + intc_enable_irq(0x1e); + intc_enable_irq(0x1f); + intc_enable_irq(0x20); + intc_enable_irq(0x21); + intc_enable_irq(0x23); + intc_enable_irq(0x37); + intc_enable_irq(0x35); + intc_enable_irq(0x32); + intc_enable_irq(0x34); + intc_enable_irq(0x36); + intc_enable_irq(10); + intc_enable_irq(0xb); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mac_irq(void) + +{ + void_fn *pvVar1; + + if ((_DAT_44910000 == 0) && (_DAT_44910004 == 0)) { + return; + } + pvVar1 = intc_irq_handlers[_DAT_44910040]; + if (pvVar1 == (void_fn *)0x0) { + assert_err("intc_irq_handlers[irq_idx] != NULL","module",0x9d); + } + (*pvVar1)(); + ipc_emb_notify(); + return; +} + + + +void bl_irq_handler(void) + +{ + ipc_host_disable_irq_e2a(); + ke_evt_set(0x40000000); + ipc_emb_notify(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_pwr_mgt_setf(uint8_t pwrmgt) + +{ + uint uVar1; + undefined3 in_register_00002029; + + uVar1 = CONCAT31(in_register_00002029,pwrmgt) << 2; + if ((uVar1 & 0xfffffffb) != 0) { + assert_err("(((uint32_t)pwrmgt << 2) & ~((uint32_t)0x00000004)) == 0","module",0x952); + } + _DAT_44b0004c = _DAT_44b0004c & 0xfffffffb | uVar1; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +chan_ctxt_tag * chan_get_next_chan(void) + +{ + int iVar1; + int iVar2; + chan_ctxt_tag *pcVar3; + uint uVar4; + ushort uVar5; + + iVar2 = _DAT_44b00120; + iVar1 = DAT_4201d1e8; + if (DAT_4201d1f8 != (chan_ctxt_tag *)0x0) { + if ((DAT_4201d1e8 != 0) && (*(char *)(DAT_4201d1e8 + 10) == '\x02')) { + return DAT_4201d1f8; + } + if (-1 < (_DAT_44b00120 + 0x1400) - DAT_4201d21c) { + return DAT_4201d1f8; + } + if (DAT_4201d1f8->status == '\x04') { + return DAT_4201d1f8; + } + } + pcVar3 = DAT_4201d1f8; + if ((DAT_4201d1e8 != 0) && (*(int *)(DAT_4201d1e8 + 4) - DAT_4201d21c < 0)) { + pcVar3 = vif_info_tab[*(byte *)(DAT_4201d1e8 + 8)].chan_ctxt; + if (pcVar3 == (chan_ctxt_tag *)0x0) { + assert_err("p_next_chan_entry","module",0x129); + } + if (-1 < (iVar2 + 0x1400) - *(int *)(iVar1 + 4)) goto LAB_230190f4; + uVar4 = 0; + if (pcVar3->nb_res_slots < pcVar3->nb_rem_slots) { + uVar4 = (uint)(ushort)(pcVar3->nb_rem_slots - pcVar3->nb_res_slots); + } + if (((uint)(*(int *)(iVar1 + 4) - iVar2) >> 10 & 0xffff) <= uVar4) { + return pcVar3; + } + } + uVar5 = 0; + if (chan_ctxt_pool[0].status != '\0') { + pcVar3 = chan_ctxt_pool; + uVar5 = chan_ctxt_pool[0].nb_rem_slots; + } + if ((chan_ctxt_pool[1].status != '\0') && (uVar5 <= chan_ctxt_pool[1].nb_rem_slots)) { + pcVar3 = chan_ctxt_pool + 1; + uVar5 = chan_ctxt_pool[1].nb_rem_slots; + } + if ((chan_ctxt_pool[2].status != '\0') && (uVar5 <= chan_ctxt_pool[2].nb_rem_slots)) { + return chan_ctxt_pool + 2; + } +LAB_230190f4: + if (pcVar3 == (chan_ctxt_tag *)0x0) { + assert_err("p_next_chan_entry","module",0x175); + } + return pcVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void chan_conn_less_delay_prog(void) + +{ + DAT_4201d248 = DAT_4201d248 | 0x10; + mm_timer_set((mm_timer_tag *)&DAT_4201d230,_DAT_44b00120 + 30000); + return; +} + + + +void chan_upd_nb_rem_slots(uint32_t current_time) + +{ + ushort uVar1; + ushort uVar2; + int in_a1; + uint uVar3; + + uVar1 = *(ushort *)current_time; + uVar3 = (uint)(in_a1 - DAT_4201d244) >> 10 & 0xffff; + uVar2 = (ushort)uVar3; + if (uVar1 < uVar3) { + uVar2 = uVar1; + } + *(ushort *)current_time = uVar1 - uVar2; + return; +} + + + +_Bool chan_tbtt_detect_conflict(void) + +{ + byte bVar1; + int in_a0; + int in_a1; + + if (((in_a0 - in_a1 < 0) || (bVar1 = 1, (in_a1 + 0x2800) - in_a0 < 0)) && + (bVar1 = 0, -1 < in_a1 - in_a0)) { + bVar1 = ~(byte)((uint)((in_a0 - in_a1) + 0x2800) >> 0x18) >> 7; + } + return (_Bool)bVar1; +} + + + +void chan_tbtt_insert(chan_tbtt_tag *p_tbtt_entry) + +{ + bool bVar1; + co_list_hdr list_hdr; + char cVar2; + _Bool _Var3; + undefined3 extraout_var; + undefined3 extraout_var_00; + co_list_hdr cVar4; + uint uVar5; + uint uVar6; + co_list_hdr prev_element; + co_list_hdr cVar7; + + list_hdr = (co_list_hdr)0x0; + cVar2 = '\0'; + cVar4 = DAT_4201d1e8; + prev_element = (co_list_hdr)0x0; + while (cVar4 != (co_list_hdr)0x0) { + if (cVar4 == (co_list_hdr)p_tbtt_entry) { + assert_err("p_elem != p_tbtt_entry","module",0x668); + } + uVar5 = p_tbtt_entry->time; + uVar6 = *(uint *)((int)cVar4 + 4); + cVar7 = cVar4; + if (*(char *)((int)cVar4 + 10) == '\x02') { + if ((uVar5 < uVar6) || + (_Var3 = chan_tbtt_detect_conflict(), CONCAT31(extraout_var_00,_Var3) != 0)) { +LAB_23019264: + cVar2 = '\x01'; + bVar1 = false; + list_hdr = (co_list_hdr)p_tbtt_entry; + goto LAB_230192ac; + } + } + else { + _Var3 = chan_tbtt_detect_conflict(); + if (CONCAT31(extraout_var,_Var3) == 0) { + if (uVar5 < uVar6) break; + } + else { + if (p_tbtt_entry->priority <= *(byte *)((int)cVar4 + 9)) goto LAB_23019264; + if (list_hdr == (co_list_hdr)0x0) { + list_hdr = cVar4; + } + cVar2 = cVar2 + '\x01'; + cVar7 = prev_element; + } + } + cVar4 = *(co_list_hdr *)cVar4; + prev_element = cVar7; + } + bVar1 = true; +LAB_230192ac: + while (cVar2 = cVar2 + -1, cVar2 != -1) { + if (list_hdr == (co_list_hdr)0x0) { + assert_err("p_delay_elem","module",0x6b1); + } + if (list_hdr != (co_list_hdr)p_tbtt_entry) { + if (*(char *)((int)list_hdr + 10) == '\x01') { + mm_timer_clear((mm_timer_tag *)&DAT_4201d200); + *(undefined *)((int)list_hdr + 10) = 0; + } + co_list_extract((co_list *)&DAT_4201d1e8,(co_list_hdr *)list_hdr); + } + co_list_push_back((co_list *)&DAT_4201d1f0,(co_list_hdr *)list_hdr); + list_hdr = *(co_list_hdr *)list_hdr; + } + if (!bVar1) { + return; + } + co_list_insert_after + ((co_list *)&DAT_4201d1e8,(co_list_hdr *)prev_element,(co_list_hdr *)p_tbtt_entry); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void chan_upd_ctxt_status(chan_ctxt_tag *p_chan_entry,uint8_t next_status) + +{ + undefined3 in_register_0000202d; + int iVar1; + ushort uVar2; + int iVar3; + uint32_t value; + + iVar1 = CONCAT31(in_register_0000202d,next_status); + if (iVar1 == 2) { + value = 0; + if (2 < p_chan_entry->idx) goto LAB_23019324; + iVar3 = 4000; + } + else { + value = 0; + if (iVar1 != 4) goto LAB_23019324; + if (p_chan_entry->idx < 3) { + if (1 < DAT_4201d24a) { + if ((p_chan_entry->nb_res_slots < p_chan_entry->nb_rem_slots) && + (uVar2 = p_chan_entry->nb_rem_slots - p_chan_entry->nb_res_slots, 4 < uVar2)) { + iVar3 = (uint)uVar2 << 10; + DAT_4201d244 = _DAT_44b00120; + goto LAB_23019322; + } + } + iVar1 = 5; + value = 0; + goto LAB_23019324; + } + iVar3 = (uint)p_chan_entry->nb_rem_slots << 10; + } +LAB_23019322: + value = iVar3 + _DAT_44b00120; +LAB_23019324: + p_chan_entry->status = (uint8_t)iVar1; + if (value != 0) { + DAT_4201d228 = p_chan_entry; + mm_timer_set((mm_timer_tag *)&DAT_4201d220,value); + return; + } + if (iVar1 != 3) { + mm_timer_clear((mm_timer_tag *)&DAT_4201d220); + return; + } + return; +} + + + +void chan_switch_start(chan_ctxt_tag *p_chan_entry) + +{ + undefined4 *puVar1; + + if (DAT_4201d1f8 == p_chan_entry) { + if ((1 < DAT_4201d24a) && (DAT_4201d1f8->idx < 3)) { + chan_upd_ctxt_status(p_chan_entry,'\x04'); + return; + } + } + else { + if (DAT_4201d1fc == (chan_ctxt_tag *)0x0) { + DAT_4201d1fc = p_chan_entry; + chan_upd_ctxt_status(p_chan_entry,'\x02'); + puVar1 = (undefined4 *)ke_msg_alloc(0x60,0,0xff,4); + *puVar1 = 0x230199ec; + ke_msg_send(); + return; + } + } + return; +} + + + +void chan_conn_less_delay_evt(void *env) + +{ + chan_ctxt_tag *p_chan_entry; + + if ((DAT_4201d248 & 1) == 0) { + if ((DAT_4201d248 & 2) == 0) { + return; + } + if ((DAT_4201d248 & 8) != 0) { + assert_err("(chan_env.status & CO_BIT(CHAN_ENV_SCAN_BIT)) == 0","module",0x2ce); + } + p_chan_entry = chan_ctxt_pool + 3; + DAT_4201d248 = DAT_4201d248 & 0xfd | 8; + } + else { + if ((DAT_4201d248 & 4) != 0) { + assert_err("(chan_env.status & CO_BIT(CHAN_ENV_ROC_BIT)) == 0","module",0x2c0); + } + p_chan_entry = chan_ctxt_pool + 4; + DAT_4201d248 = DAT_4201d248 & 0xfe | 4; + } + if (DAT_4201d1fc != 0) { + return; + } + chan_switch_start(p_chan_entry); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void chan_tbtt_switch_evt(void *env) + +{ + ushort uVar1; + undefined4 uVar2; + ushort uVar3; + chan_ctxt_tag *p_chan_entry; + + uVar2 = _DAT_44b00120; + if ((1 < DAT_4201d24a) && ((DAT_4201d248 & 0xc) == 0)) { + p_chan_entry = vif_info_tab[*(byte *)((int)env + 8)].chan_ctxt; + if ((DAT_4201d1fc == (chan_ctxt_tag *)0x0) || (DAT_4201d1fc == p_chan_entry)) { + *(undefined *)((int)env + 9) = 0; + chan_upd_nb_rem_slots(DAT_4201d1f8 + 0x12); + uVar1 = p_chan_entry->nb_res_slots; + uVar3 = uVar1; + if (10 < uVar1) { + uVar3 = 10; + } + p_chan_entry->nb_res_slots = uVar1 - uVar3; + DAT_4201d244 = uVar2; + *(undefined *)((int)env + 10) = 2; + if (DAT_4201d1fc == (chan_ctxt_tag *)0x0) { + chan_switch_start(p_chan_entry); + return; + } + } + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void chan_tbtt_schedule(chan_tbtt_tag *p_tbtt_entry) + +{ + void *pvVar1; + chan_tbtt_tag *p_tbtt_entry_00; + uint uVar2; + uint32_t uVar3; + + if (p_tbtt_entry != (chan_tbtt_tag *)0x0) { + chan_tbtt_insert(p_tbtt_entry); + while (DAT_4201d1f0 != 0) { + p_tbtt_entry_00 = (chan_tbtt_tag *)co_list_pop_front((co_list *)&DAT_4201d1f0); + uVar2 = (uint)p_tbtt_entry_00->vif_index; + if (vif_info_tab[uVar2].type == '\0') { + uVar3 = sta_info_tab[vif_info_tab[uVar2].u[4]].bcn_int; + } + else { + uVar3 = (uint)*(ushort *)(vif_info_tab[uVar2].u + 0x2e2) << 10; + } + p_tbtt_entry_00->time = uVar3 + p_tbtt_entry_00->time; + if (p_tbtt_entry_00->priority < 5) { + p_tbtt_entry_00->priority = p_tbtt_entry_00->priority + 1; + } + chan_tbtt_insert(p_tbtt_entry_00); + } + } + pvVar1 = DAT_4201d1e8; + if ((DAT_4201d1e8 != (void *)0x0) && (*(char *)((int)DAT_4201d1e8 + 10) == '\0')) { + if ((*(int *)((int)DAT_4201d1e8 + 4) - _DAT_44b00120) + -2000 < 0) { + chan_tbtt_switch_evt(DAT_4201d1e8); + return; + } + DAT_4201d208 = DAT_4201d1e8; + *(undefined *)((int)DAT_4201d1e8 + 10) = 1; + mm_timer_set((mm_timer_tag *)&DAT_4201d200,*(uint32_t *)((int)pvVar1 + 4)); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void chan_cde_evt(void *env) + +{ + int iVar1; + uint uVar2; + int iVar3; + chan_ctxt_tag *p_chan_entry; + int iVar4; + co_list_hdr *pcVar5; + co_list_hdr cVar6; + undefined2 uVar7; + ushort uVar8; + uint uVar9; + + iVar4 = _DAT_44b00120; + p_chan_entry = DAT_4201d1fc; + if ((1 < DAT_4201d24a) && (uVar2 = (uint)DAT_4201d248 & 0x2c, (DAT_4201d248 & 0x2c) == 0)) { + mm_timer_set((mm_timer_tag *)&DAT_4201d210,DAT_4201d240 + _DAT_44b00120); + DAT_4201d244 = iVar4; + uVar9 = 0; + cVar6 = (co_list_hdr)vif_mgmt_env.used_list.first; + while (cVar6 != (co_list_hdr)0x0) { + pcVar5 = ((co_list_hdr *)((int)cVar6 + 0x40))->next; + if (pcVar5 != (co_list_hdr *)0x0) { + uVar2 = uVar2 + 1 & 0xff; + if (((td_env[*(byte *)((int)cVar6 + 0x57)].status & 3) != 0) || + (*(char *)&((co_list_hdr *)((int)cVar6 + 0x58))->next == '\0')) { + uVar9 = uVar9 + 1 & 0xff; + } + *(undefined2 *)&pcVar5[4].next = 0; + *(undefined2 *)&pcVar5[5].next = 0; + } + cVar6 = *(co_list_hdr *)cVar6; + } + if (uVar2 != DAT_4201d240 / 0xc800) { + assert_warn("nb_vifs == (chan_env.cde_dur_us / (CHAN_VIF_NB_SLOTS * CHAN_SLOT_DURATION_US))", + "module",0x268); + } + if ((uVar9 == 0) || (uVar2 == uVar9)) { + iVar3 = 0; + iVar4 = 0x32; + } + else { + iVar4 = 10; + iVar3 = (int)((uVar2 - uVar9) * 0x280000 >> 0x10) / (int)uVar9; + } + cVar6 = (co_list_hdr)vif_mgmt_env.used_list.first; + while (cVar6 != (co_list_hdr)0x0) { + pcVar5 = ((co_list_hdr *)((int)cVar6 + 0x40))->next; + if (pcVar5 != (co_list_hdr *)0x0) { + if (((td_env[*(byte *)((int)cVar6 + 0x57)].status & 3) != 0) || + (iVar1 = iVar4, *(char *)&((co_list_hdr *)((int)cVar6 + 0x58))->next == '\0')) { + iVar1 = iVar3 + 0x32; + } + uVar7 = (undefined2)(((uint)*(ushort *)&pcVar5[4].next + iVar1) * 0x10000 >> 0x10); + *(undefined2 *)&pcVar5[4].next = uVar7; + *(undefined2 *)((int)&pcVar5[4].next + 2) = uVar7; + if (*(char *)((int)cVar6 + 0x56) == '\0') { + uVar2 = sta_info_tab[*(byte *)&((co_list_hdr *)((int)cVar6 + 0x60))->next].bcn_int; + } + else { + uVar2 = (uint)*(ushort *)((int)cVar6 + 0x33e) << 10; + } + uVar8 = (ushort)(DAT_4201d240 / uVar2); + if (DAT_4201d240 / uVar2 == 0) { + uVar8 = 1; + } + *(ushort *)&pcVar5[5].next = (uVar8 & 0xff) * 10 + *(short *)&pcVar5[5].next; + } + cVar6 = *(co_list_hdr *)cVar6; + } + if (DAT_4201d1f8 != (chan_ctxt_tag *)0x0) { + chan_upd_ctxt_status(DAT_4201d1f8,'\x01'); + } + p_chan_entry = chan_get_next_chan(); + if (env == (void *)0x0) { + chan_switch_start(p_chan_entry); + return; + } + } + DAT_4201d1fc = p_chan_entry; + return; +} + + +/* +Unable to decompile 'chan_pre_switch_channel' +Cause: Exception while decompiling 230197f8: Decompiler process died + +*/ + + +void chan_goto_idle_cb(void) + +{ + undefined uVar1; + co_list_hdr *pcVar2; + co_list_hdr cVar3; + uint8_t uVar4; + undefined3 extraout_var; + int iVar5; + + mm_force_idle_req(); + pcVar2 = DAT_4201d1f8; + cVar3 = (co_list_hdr)vif_mgmt_env.used_list.first; + if (((DAT_4201d1f8 != (co_list_hdr *)0x0) && ((DAT_4201d248 & 0x20) == 0)) && + ((ps_env.ps_on == false || ((ps_env.prevent_sleep & 8) != 0)))) { + iVar5 = 0; + blmac_pwr_mgt_setf('\x01'); + while (cVar3 != (co_list_hdr)0x0) { + if ((((pcVar2 == ((co_list_hdr *)((int)cVar3 + 0x40))->next) && + (*(char *)((int)cVar3 + 0x56) == '\0')) && + (*(char *)&((co_list_hdr *)((int)cVar3 + 0x58))->next != '\0')) && + (*(char *)&((co_list_hdr *)((int)cVar3 + 0x60))->next != -1)) { + uVar1 = *(undefined *)((int)&pcVar2[5].next + 2); + *(undefined *)((int)&pcVar2[5].next + 2) = 6; + uVar4 = txl_frame_send_null_frame + (*(uint8_t *)&((co_list_hdr *)((int)cVar3 + 0x60))->next,chan_tx_cfm, + (void *)0x0); + if (CONCAT31(extraout_var,uVar4) == 0) { + iVar5 = iVar5 + 1; + } + *(undefined *)((int)&pcVar2[5].next + 2) = uVar1; + } + cVar3 = *(co_list_hdr *)cVar3; + } + DAT_4201d249 = (undefined)iVar5; + if (iVar5 != 0) { + chan_upd_ctxt_status(DAT_4201d1fc,'\x03'); + mm_active(); + return; + } + } + chan_pre_switch_channel(); + return; +} + + + +void chan_tx_cfm(void *dummy,uint32_t status) + +{ + if (DAT_4201d249 == '\0') { + assert_err("chan_env.cfm_cnt","module",0x48f); + } + DAT_4201d249 = DAT_4201d249 + -1; + if (DAT_4201d249 == '\0') { + mm_force_idle_req(); + chan_pre_switch_channel(); + return; + } + return; +} + + +/* +Unable to decompile 'chan_ctxt_op_evt' +Cause: Exception while decompiling 23019b24: Decompiler process died + +*/ + + +void chan_init(void) + +{ + chan_ctxt_tag *__s; + int iVar1; + + __s = chan_ctxt_pool; + memset(&chan_env,0,0x74); + iVar1 = 0; + do { + memset(__s,0,0x1c); + *(undefined2 *)(&__s->channel + 1) = 0xff; + *(undefined *)((int)&__s->nb_res_slots + 3) = 0xff; + if (iVar1 < 3) { + co_list_push_back((co_list *)&chan_env,(co_list_hdr *)__s); + } + else { + if (iVar1 == 3) { + chan_ctxt_pool[3].channel.center2_freq = 0; + chan_ctxt_pool[3].channel.type = '\0'; + } + } + iVar1 = iVar1 + 1; + __s = __s + 1; + } while (iVar1 != 5); + DAT_4201d204 = chan_tbtt_switch_evt; + DAT_4201d214 = chan_cde_evt; + DAT_4201d218 = 0; + DAT_4201d224 = chan_ctxt_op_evt; + DAT_4201d234 = chan_conn_less_delay_evt; + return; +} + + + +void chan_scan_req(uint8_t band,uint16_t freq,int8_t pwr,uint32_t duration_us,uint8_t vif_index) + +{ + if (chan_ctxt_pool[3].idx != -1) { + assert_err("p_scan_chan->idx == CHAN_CTXT_UNUSED","module",0x8a1); + } + chan_ctxt_pool[3].taskid = 0xff; + chan_ctxt_pool[3]._22_2_ = 0x301; + chan_ctxt_pool[3].nb_rem_slots = (uint16_t)(duration_us >> 10); + if ((DAT_4201d248 & 0x10) == 0) { + chan_ctxt_pool[3].channel.band = band; + chan_ctxt_pool[3].channel.prim20_freq = freq; + chan_ctxt_pool[3].channel.center1_freq = freq; + chan_ctxt_pool[3].channel.tx_power = pwr; + chan_ctxt_pool[3].vif_index = vif_index; + DAT_4201d248 = DAT_4201d248 | 2; + chan_conn_less_delay_prog(); + return; + } + chan_ctxt_pool[3].channel.band = band; + chan_ctxt_pool[3].channel.prim20_freq = freq; + chan_ctxt_pool[3].channel.center1_freq = freq; + chan_ctxt_pool[3].channel.tx_power = pwr; + chan_ctxt_pool[3].taskid = 0xff; + chan_ctxt_pool[3]._22_2_ = 0x301; + chan_ctxt_pool[3].vif_index = vif_index; + DAT_4201d248 = DAT_4201d248 | 2; + return; +} + + + +uint8_t chan_roc_req(mm_remain_on_channel_req *req,ke_task_id_t taskid) + +{ + byte bVar1; + undefined2 in_register_0000202e; + + if (req->op_code == '\0') { + if (chan_ctxt_pool[4].idx == -1) { + chan_ctxt_pool[4].idx = '\x04'; + chan_ctxt_pool[4].channel.band = req->band; + chan_ctxt_pool[4].channel.type = req->type; + chan_ctxt_pool[4].channel.prim20_freq = req->prim20_freq; + chan_ctxt_pool[4].channel.center1_freq = req->center1_freq; + chan_ctxt_pool[4].channel.center2_freq = req->center2_freq; + chan_ctxt_pool[4].status = '\x01'; + chan_ctxt_pool[4].nb_rem_slots = (uint16_t)(req->duration_ms * 1000 >> 10); + chan_ctxt_pool[4].vif_index = req->vif_index; + chan_ctxt_pool[4].channel.tx_power = req->tx_power; + chan_ctxt_pool[4].taskid = taskid; + if (CONCAT22(in_register_0000202e,taskid) != 0) { + bVar1 = DAT_4201d248 & 0x10; + if ((DAT_4201d248 & 0x10) != 0) { + chan_ctxt_pool[4].status = '\x01'; + chan_ctxt_pool[4].idx = '\x04'; + DAT_4201d248 = DAT_4201d248 | 1; + return '\0'; + } + DAT_4201d248 = DAT_4201d248 | 1; + chan_conn_less_delay_prog(); + return bVar1; + } + DAT_4201d248 = DAT_4201d248 | 4; + if (DAT_4201d1fc != 0) { + chan_ctxt_pool[4].status = '\x01'; + chan_ctxt_pool[4].idx = '\x04'; + return '\0'; + } + chan_switch_start(chan_ctxt_pool + 4); + return '\0'; + } + } + else { + if (req->op_code == '\x01') { + if (chan_ctxt_pool[4].idx != -1) { + if (chan_ctxt_pool[4].status < 4) { + if (chan_ctxt_pool[4].status < 2) { + if (chan_ctxt_pool[4].status == '\x01') { + DAT_4201d248 = DAT_4201d248 & 0xfe; + } + } + else { + DAT_4201d1fc = 0; + DAT_4201d248 = DAT_4201d248 & 0xfb; + } + } + else { + if (chan_ctxt_pool[4].status == '\x04') { + mm_timer_clear((mm_timer_tag *)&DAT_4201d220); + chan_ctxt_op_evt(chan_ctxt_pool + 4); + } + } + chan_ctxt_pool[4].idx = -1; + if ((DAT_4201d248 & 0x12) == 0x10) { + DAT_4201d248 = DAT_4201d248 & 0xef; + mm_timer_clear((mm_timer_tag *)&DAT_4201d230); + DAT_4201d248 = DAT_4201d248 & 0xef; + } + } + return '\0'; + } + } + return '\x01'; +} + + + +uint8_t chan_ctxt_add(mm_chan_ctxt_add_req *p_add_req,uint8_t *idx) + +{ + uint8_t uVar1; + int iVar2; + co_list_hdr *pcVar3; + int iVar4; + chan_ctxt_tag *pcVar5; + + pcVar5 = chan_ctxt_pool; + iVar4 = 0; + do { + if (pcVar5->idx != -1) { + iVar2 = memcmp(p_add_req,&pcVar5->channel,8); + if (iVar2 == 0) { + *idx = (uint8_t)iVar4; + return (uint8_t)iVar2; + } + } + iVar4 = iVar4 + 1; + pcVar5 = pcVar5 + 1; + } while (iVar4 != 3); + pcVar3 = co_list_pop_front((co_list *)&chan_env); + if (pcVar3 != (co_list_hdr *)0x0) { + uVar1 = (char)((int)(pcVar3 + -0x10807453) >> 2) * -0x49; + *(uint8_t *)((int)&pcVar3[5].next + 3) = uVar1; + *idx = uVar1; + *(uint8_t *)&pcVar3[1].next = p_add_req->band; + *(uint8_t *)((int)&pcVar3[1].next + 1) = p_add_req->type; + *(uint16_t *)&pcVar3[2].next = p_add_req->center1_freq; + *(uint16_t *)((int)&pcVar3[2].next + 2) = p_add_req->center2_freq; + *(uint16_t *)((int)&pcVar3[1].next + 2) = p_add_req->prim20_freq; + *(int8_t *)&pcVar3[3].next = p_add_req->tx_power; + } + return (uint8_t)(pcVar3 == (co_list_hdr *)0x0); +} + + + +void chan_ctxt_del(uint8_t chan_idx) + +{ + undefined3 in_register_00002029; + int iVar1; + + iVar1 = CONCAT31(in_register_00002029,chan_idx); + if (chan_ctxt_pool[iVar1].idx == -1) { + assert_err("p_chan_entry->idx != CHAN_CTXT_UNUSED","module",0x989); + } + if (chan_ctxt_pool[iVar1].nb_linked_vif != '\0') { + assert_err("p_chan_entry->nb_linked_vif == 0","module",0x98b); + } + co_list_push_back((co_list *)&chan_env,(co_list_hdr *)(chan_ctxt_pool + iVar1)); + memset(chan_ctxt_pool + iVar1,0,0x1c); + chan_ctxt_pool[iVar1].taskid = 0xff; + chan_ctxt_pool[iVar1].idx = -1; + return; +} + + +/* +Unable to decompile 'chan_ctxt_update' +Cause: Exception while decompiling 2301a0c2: Decompiler process died + +*/ + + +void chan_tbtt_switch_update(vif_info_tag *p_vif_entry,uint32_t tbtt_time) + +{ + if ((((p_vif_entry->chan_ctxt != (chan_ctxt_tag *)0x0) && (p_vif_entry->chan_ctxt->status != '\0') + ) && ((p_vif_entry->tbtt_switch).time != tbtt_time - 0x9c4)) && + (((p_vif_entry->tbtt_switch).time = tbtt_time - 0x9c4, 1 < DAT_4201d24a && + ((p_vif_entry->tbtt_switch).status != '\x02')))) { + (p_vif_entry->tbtt_switch).status = '\0'; + co_list_extract((co_list *)&DAT_4201d1e8,(co_list_hdr *)&p_vif_entry->tbtt_switch); + chan_tbtt_schedule(&p_vif_entry->tbtt_switch); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void chan_bcn_to_evt(vif_info_tag *p_vif_entry) + +{ + ushort uVar1; + int iVar2; + chan_ctxt_tag *p_chan_entry; + ushort uVar3; + uint uVar4; + + iVar2 = _DAT_44b00120; + if ((p_vif_entry->tbtt_switch).status == '\x02') { + (p_vif_entry->tbtt_switch).status = '\0'; + p_chan_entry = DAT_4201d1f8; + co_list_extract((co_list *)&DAT_4201d1e8,(co_list_hdr *)&p_vif_entry->tbtt_switch); + if (((1 < DAT_4201d24a) && + (chan_tbtt_schedule(&p_vif_entry->tbtt_switch), (DAT_4201d248 & 0xc) == 0)) && + (DAT_4201d1fc == 0)) { + chan_upd_nb_rem_slots((uint32_t)&p_chan_entry->nb_rem_slots); + uVar1 = p_chan_entry->nb_res_slots; + if (uVar1 != 0) { + uVar4 = (uint)(iVar2 - DAT_4201d244) >> 10 & 0xffff; + uVar3 = (ushort)uVar4; + if (uVar1 < uVar4) { + uVar3 = uVar1; + } + p_chan_entry->nb_res_slots = uVar1 - uVar3; + } + DAT_4201d244 = iVar2; + p_chan_entry = chan_get_next_chan(); + if (DAT_4201d1f8 != p_chan_entry) { + chan_switch_start(p_chan_entry); + return; + } + } + } + return; +} + + + +void chan_bcn_detect_start(vif_info_tag *p_vif_entry) + +{ + byte bVar1; + chan_ctxt_tag *pcVar2; + undefined *puVar3; + + pcVar2 = p_vif_entry->chan_ctxt; + if (pcVar2 == (chan_ctxt_tag *)0x0) { + assert_err("p_chan_entry","module",0xb19); + } + if (((DAT_4201d248 & 0x40) == 0) && (1 < DAT_4201d24a)) { + bVar1 = p_vif_entry->u[4]; + puVar3 = (undefined *)ke_msg_alloc(0x46,0,0,0x14); + *puVar3 = 0; + puVar3[1] = p_vif_entry->index; + puVar3[2] = (pcVar2->channel).band; + puVar3[3] = (pcVar2->channel).type; + *(uint16_t *)(puVar3 + 4) = (pcVar2->channel).prim20_freq; + *(uint16_t *)(puVar3 + 6) = (pcVar2->channel).center1_freq; + *(uint16_t *)(puVar3 + 8) = (pcVar2->channel).center2_freq; + *(uint *)(puVar3 + 0xc) = (sta_info_tab[bVar1].bcn_int - 5000) / 1000; + puVar3[0x10] = (pcVar2->channel).tx_power; + ke_msg_send(); + DAT_4201d248 = DAT_4201d248 | 0x40; + } + return; +} + + + +_Bool chan_is_on_channel(vif_info_tag *p_vif_entry) + +{ + chan_ctxt_tag *pcVar1; + + if (DAT_4201d1f8 != 0) { + if (*(byte *)(DAT_4201d1f8 + 0x17) < 3) { + pcVar1 = (chan_ctxt_tag *)((int)p_vif_entry->chan_ctxt - DAT_4201d1f8); + } + else { + pcVar1 = (chan_ctxt_tag *)((uint)*(byte *)(DAT_4201d1f8 + 0x19) - (uint)p_vif_entry->index); + } + return (_Bool)(pcVar1 == (chan_ctxt_tag *)0x0); + } + return false; +} + + + +_Bool chan_is_tx_allowed(vif_info_tag *p_vif_entry) + +{ + bool bVar1; + undefined3 extraout_var; + + bVar1 = (bool)chan_is_on_channel(p_vif_entry); + if ((CONCAT31(extraout_var,bVar1) != 0) && (DAT_4201d1fc != 0)) { + bVar1 = *(char *)(DAT_4201d1f8 + 0x16) == '\x06'; + } + return (_Bool)bVar1; +} + + + +_Bool chan_is_on_operational_channel(vif_info_tag *p_vif_entry) + +{ + bool bVar1; + + bVar1 = false; + if ((DAT_4201d1f8 != (chan_ctxt_tag *)0x0) && (bVar1 = false, DAT_4201d1f8->idx < 3)) { + bVar1 = p_vif_entry->chan_ctxt == DAT_4201d1f8; + } + return (_Bool)bVar1; +} + + + +void chan_update_tx_power(chan_ctxt_tag *p_chan_entry) + +{ + int8_t iVar1; + int8_t iVar2; + char cVar3; + + if (p_chan_entry->nb_linked_vif == '\0') { + return; + } + iVar2 = '\x7f'; + if ((p_chan_entry == vif_info_tab[0].chan_ctxt) && + (iVar2 = vif_info_tab[0].user_tx_power, + vif_info_tab[0].tx_power < vif_info_tab[0].user_tx_power)) { + iVar2 = vif_info_tab[0].tx_power; + } + iVar1 = iVar2; + if (p_chan_entry == vif_info_tab[1].chan_ctxt) { + iVar1 = vif_info_tab[1].user_tx_power; + if (iVar2 < vif_info_tab[1].user_tx_power) { + iVar1 = iVar2; + } + cVar3 = vif_info_tab[1].tx_power; + if (vif_info_tab[1].tx_power < iVar1) goto LAB_2301a43a; + } + cVar3 = iVar1; + if (iVar1 == '\x7f') { + return; + } +LAB_2301a43a: + (p_chan_entry->channel).tx_power = cVar3; + return; +} + + + +void chan_ctxt_link(uint8_t vif_idx,uint8_t chan_idx) + +{ + uint8_t uVar1; + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + int iVar2; + chan_ctxt_tag *p_chan_entry; + + iVar2 = CONCAT31(in_register_0000202d,chan_idx); + p_chan_entry = chan_ctxt_pool + iVar2; + if (vif_info_tab[CONCAT31(in_register_00002029,vif_idx)].chan_ctxt != (chan_ctxt_tag *)0x0) { + assert_err("p_vif_entry->chan_ctxt == NULL","module",0x99c); + } + if (chan_ctxt_pool[iVar2].idx == -1) { + assert_err("p_chan_entry->idx != CHAN_CTXT_UNUSED","module",0x99d); + } + uVar1 = chan_ctxt_pool[iVar2].nb_linked_vif + '\x01'; + DAT_4201d240 = DAT_4201d240 + 0xc800; + vif_info_tab[CONCAT31(in_register_00002029,vif_idx)].chan_ctxt = p_chan_entry; + chan_ctxt_pool[iVar2].nb_linked_vif = uVar1; + if (uVar1 == '\x01') { + chan_ctxt_pool[iVar2].status = '\x01'; + DAT_4201d24a = DAT_4201d24a + '\x01'; + co_list_push_back((co_list *)&p_chan_entry,(co_list_hdr *)p_chan_entry); + if (DAT_4201d1fc == 0) { + if ((DAT_4201d248 & 0xc) == 0) { + if (DAT_4201d24a == '\x01') { + chan_switch_start(p_chan_entry); + } + else { + chan_cde_evt((void *)0x0); + } + } + } + else { + *(undefined *)(DAT_4201d1fc + 0x16) = 1; + DAT_4201d1fc = 0; + } + } + chan_update_tx_power(p_chan_entry); + return; +} + + + +void chan_ctxt_unlink(uint8_t vif_idx) + +{ + chan_ctxt_tag *pcVar1; + chan_ctxt_tag *p_chan_entry; + undefined3 in_register_00002029; + int iVar2; + + iVar2 = CONCAT31(in_register_00002029,vif_idx); + p_chan_entry = vif_info_tab[iVar2].chan_ctxt; + if (p_chan_entry == (chan_ctxt_tag *)0x0) { + assert_err("p_chan_entry != NULL","module",0x9e4); + } + co_list_extract((co_list *)&DAT_4201d1e8,(co_list_hdr *)&vif_info_tab[iVar2].tbtt_switch); + vif_info_tab[iVar2].tbtt_switch.status = '\0'; + vif_info_tab[iVar2].chan_ctxt = (chan_ctxt_tag *)0x0; + p_chan_entry->nb_linked_vif = p_chan_entry->nb_linked_vif + -1; + pcVar1 = DAT_4201d1fc; + if (p_chan_entry->status != '\0') { + DAT_4201d240 = DAT_4201d240 + -0xc800; + if (p_chan_entry->nb_linked_vif != '\0') goto LAB_2301a656; + co_list_extract((co_list *)&p_chan_entry,(co_list_hdr *)p_chan_entry); + p_chan_entry->status = '\0'; + DAT_4201d24a = DAT_4201d24a - 1; + if (DAT_4201d1f8 == p_chan_entry) { + DAT_4201d1f8 = (chan_ctxt_tag *)0x0; +LAB_2301a622: + if (pcVar1 == (chan_ctxt_tag *)0x0) { + if (DAT_4201d24a < 2) { + if (DAT_4201d24a == 1) { + chan_switch_start(p_chan_entry); + } + } + else { + chan_cde_evt((void *)0x0); + } + goto LAB_2301a648; + } + } + else { + if (pcVar1 != p_chan_entry) goto LAB_2301a622; + DAT_4201d1fc = (chan_ctxt_tag *)0x0; + } + DAT_4201d248 = DAT_4201d248 | 0x20; + } +LAB_2301a648: + if (p_chan_entry->nb_linked_vif == '\0') { + chan_ctxt_del(p_chan_entry->idx); + } +LAB_2301a656: + chan_tbtt_schedule((chan_tbtt_tag *)0x0); + chan_update_tx_power(p_chan_entry); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_dma_init(void) + +{ + co_list_init((co_list *)&hal_dma_env); + hal_dma_env.lli_cnt[0] = (uint16_t)_DAT_44a000a4; + co_list_init(hal_dma_env.prog + 1); + hal_dma_env.lli_cnt[1] = (uint16_t)_DAT_44a000ac; + return; +} + + +/* +Unable to decompile 'hal_dma_push' +Cause: Exception while decompiling 2301a6ba: Decompiler process died + +*/ + +/* +Unable to decompile 'hal_dma_evt' +Cause: Exception while decompiling 2301a74a: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t blmac_soft_reset_getf(void) + +{ + uint uVar1; + + uVar1 = _DAT_44b08050; + if ((_DAT_44b08050 & 0xfffffffe) != 0) { + assert_err("(localVal & ~((uint32_t)0x00000001)) == 0","module",0x11d); + } + return (uint8_t)uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_wt_2_crypt_clk_ratio_setf(uint8_t wt2cryptclkratio) + +{ + undefined3 in_register_00002029; + + _DAT_44b000f0 = CONCAT31(in_register_00002029,wt2cryptclkratio) | _DAT_44b000f0 & 0xfffffffc; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_rx_flow_cntrl_en_setf(void) + +{ + _DAT_44b00054 = _DAT_44b00054 & 0xfffeffff | 0x10000; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_key_sto_ram_reset_setf(void) + +{ + _DAT_44b0004c = _DAT_44b0004c & 0xffffdfff | 0x2000; + return; +} + + +/* +Unable to decompile 'hal_machw_idle_req' +Cause: Exception while decompiling 2301a80c: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_machw_stop(void) + +{ + uint8_t uVar1; + undefined3 extraout_var; + + _DAT_44b08050 = 1; + do { + uVar1 = blmac_soft_reset_getf(); + } while (CONCAT31(extraout_var,uVar1) != 0); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_machw_init(void) + +{ + uint uVar1; + uint8_t wt2cryptclkratio; + undefined3 extraout_var; + uint uVar2; + undefined3 extraout_var_00; + uint uVar3; + uint uVar4; + + _DAT_44b08050 = 1; + do { + wt2cryptclkratio = blmac_soft_reset_getf(); + } while (CONCAT31(extraout_var,wt2cryptclkratio) != 0); + _DAT_44b00404 = 0x24f637; + _DAT_44b00400 = 0x49; + _DAT_44920004 = 0x5010001f; + wt2cryptclkratio = phy_get_mac_freq(); + uVar2 = CONCAT31(uVar2._1_3_,wt2cryptclkratio); + uVar1 = _DAT_44b000e4 & 0xff; + uVar3 = _DAT_44b000e4 & 0xffffff00 | 0x28; + uVar4 = (((_DAT_44b000e4 & 0x3ff00) >> 8) * uVar2) / uVar1 << 8; + _DAT_44b000e4 = uVar3; + if ((uVar4 & 0xfc0000) != 0) { + assert_err("(((uint32_t)txrfdelayinmacclk << 8) & ~((uint32_t)0x0003FF00)) == 0","module",0x1d59 + ); + } + _DAT_44b000e4 = (_DAT_44b000e4 & 0xfffc00ff | uVar4 & 0xffff00) & 0xf003ffff | 0x2200000; + _DAT_44b000e8 = + (((_DAT_44b000e8 >> 8 & 0xffff) * uVar2) / uVar1 & 0xffff) << 8 | _DAT_44b000e8 & 0xff0000ff; + uVar3 = _DAT_44b000ec & 0xc00fffff | 0x2700000; + uVar4 = (((_DAT_44b000ec & 0xffc00) >> 10) * uVar2) / uVar1 << 10; + _DAT_44b000ec = uVar3; + if ((uVar4 & 0x3f00000) != 0) { + assert_err("(((uint32_t)txdelayrfoninmacclk << 10) & ~((uint32_t)0x000FFC00)) == 0","module", + 0x1ea2); + } + wt2cryptclkratio = '\x03'; + _DAT_44b000ec = _DAT_44b000ec & 0xfff00000 | uVar4 & 0x3fffc00 | 0xb4; + if ((0x1d < uVar2) && (wt2cryptclkratio = '\x02', 0x3b < uVar2)) { + wt2cryptclkratio = '\x01'; + } + blmac_wt_2_crypt_clk_ratio_setf(wt2cryptclkratio); + _DAT_44b000f4 = + (((_DAT_44b000f4 >> 8 & 0xffff) * uVar2) / uVar1 & 0xffff) << 8 | _DAT_44b000f4 & 0xff0000ff; + _DAT_44b000f8 = + (((_DAT_44b000f8 >> 8 & 0xffff) * uVar2) / uVar1 & 0xffff) << 8 | _DAT_44b000f8 & 0xff0000ff; + uVar3 = ((_DAT_44b00104 >> 0x14 & 0x3ff) * uVar2) / uVar1 << 0x14; + if ((uVar3 & 0xc0000000) != 0) { + assert_err("(((uint32_t)rifstoinmacclk << 20) & ~((uint32_t)0x3FF00000)) == 0","module",0x228a); + } + uVar3 = _DAT_44b00104 & 0xc00fffff | uVar3; + uVar4 = (((_DAT_44b00104 & 0xffc00) >> 10) * uVar2) / uVar1 << 10; + _DAT_44b00104 = uVar3; + if ((uVar4 & 0x3f00000) != 0) { + assert_err("(((uint32_t)rifsinmacclk << 10) & ~((uint32_t)0x000FFC00)) == 0","module",0x22a4); + } + uVar3 = _DAT_44b00104 & 0xfff003ff | uVar4 & 0x3fffc00; + uVar1 = ((_DAT_44b00104 & 0x3ff) * uVar2) / uVar1; + _DAT_44b00104 = uVar3; + if ((uVar1 & 0xfc00) != 0) { + assert_err("(((uint32_t)txdmaprocdlyinmacclk << 0) & ~((uint32_t)0x000003FF)) == 0","module", + 0x22be); + } + _DAT_44b00104 = _DAT_44b00104 & 0xfffffc00 | uVar1 & 0xffff; + _DAT_44b08074 = 0x8373f14c; + _DAT_44b0004c = _DAT_44b0004c & 0xfffff7ff; + if (_DAT_44b000d8 >> 0x18 < 0x11) { + assert_err("MM_STA_TO_KEY(NX_REMOTE_STA_MAX - 1) <= blmac_sta_key_max_index_getf()","module", + 0x124); + } + printf("[WF] [KEY] [CFG] nVAP is %d, endidx %d, startidx %d\r\n",2,0x11,8); + _DAT_44b000d8 = 0x21108; + _DAT_44b08080 = 0x800a07c0; + _DAT_44b0004c = _DAT_44b0004c | 0x4000780; + blmac_rx_flow_cntrl_en_setf(); + _DAT_44b00060 = 0x7fffffde; + _DAT_44b00114 = 0x3010a; + _DAT_44b00064 = 0xff900064; + _DAT_44b00150 = 0x1000; + _DAT_44b00224 = 0; + _DAT_44b000a0 = 0x2020; + _DAT_44b0004c = _DAT_44b0004c & 0xffffefff | 0x1000; + blmac_key_sto_ram_reset_setf(); + _DAT_44b00510 = 0x1c25; + _DAT_44b00310 = _DAT_44b00310 | 0x80; + wt2cryptclkratio = phy_get_ntx(); + uVar1 = (CONCAT31(extraout_var_00,wt2cryptclkratio) + 1) * 0x4000000; + if ((uVar1 & 0xe0000000) != 0) { + assert_err("(((uint32_t)maxphyntx << 26) & ~((uint32_t)0x1C000000)) == 0","module",0x1539); + } + _DAT_44b0004c = _DAT_44b0004c & 0xfdffffff | 0x2000000; + _DAT_44b0009c = _DAT_44b0009c & 0xe3ffffff | uVar1; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_machw_disable_int(void) + +{ + _DAT_44b08074 = _DAT_44b08074 & 0x7fffffff; + _DAT_44b08080 = _DAT_44b08080 & 0x7fffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_machw_reset(void) + +{ + char "hal_machw_reset" [16]; + + if ((_DAT_44b00038 & 0xf) != 0) { + helper_record_all_states("hal_machw_reset"); + } + _DAT_44b0004c = _DAT_44b0004c & 0xffffff7f; + _DAT_44b00038 = 0; + _DAT_44b00054 = 0x7c; + ps_env.prevent_sleep = ps_env.prevent_sleep & 0xfffffffb; + blmac_rx_flow_cntrl_en_setf(); + _DAT_44b0004c = _DAT_44b0004c | 0x80; + _DAT_44b08070 = 0x37ff187; + _DAT_44b08074 = _DAT_44b08074 & 0x7fffffff | 0x80000000; + _DAT_44b0807c = 0xffffffff; + _DAT_44b08080 = _DAT_44b08080 & 0x7fffffff | 0x80000000; + _DAT_44b0808c = _DAT_44b0808c & 0xffffffc0; + return; +} + + + +// WARNING: Removing unreachable block (ram,0x2301adcc) +// WARNING: Removing unreachable block (ram,0x2301add8) +// WARNING: Removing unreachable block (ram,0x2301ade2) + +uint8_t hal_machw_search_addr(mac_addr *addr) + +{ + // WARNING: Do nothing block with infinite loop + do { + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_machw_monitor_mode(void) + +{ + _DAT_44b08074 = _DAT_44b08074 & 0xfffffffc; + mm_env.rx_filter_umac = 0x7fffffde; + _DAT_44b00060 = mm_env.rx_filter_lmac_enable | 0x7fffffde; + _DAT_44b0004c = _DAT_44b0004c & 0xfffe3fff | 0xc700; + blmac_key_sto_ram_reset_setf(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +_Bool hal_machw_sleep_check(void) + +{ + uint uVar1; + + uVar1 = 0; + while (((1 << (uVar1 & 0x1f) & _DAT_44b0808c) == 0 || + (-1 < (-2000 - _DAT_44b00120) + *(int *)(&DAT_44b00128 + uVar1 * 4)))) { + uVar1 = uVar1 + 1; + if (uVar1 == 9) { + return true; + } + } + if (-1 < (5000 - _DAT_44b00120) + *(int *)(&DAT_44b00128 + uVar1 * 4)) { + return false; + } + assert_err("!hal_machw_time_past(blmac_abs_timer_get(i) + 5000)","module",0x208); + return false; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_machw_gen_handler(void) + +{ + uint uVar1; + uint uVar2; + char *condition; + int line; + + uVar2 = _DAT_44b08074 & _DAT_44b0806c; + _DAT_44b08070 = uVar2; + if ((uVar2 & 0x40001) != 0) { + ke_evt_set(0x400000); + } + if ((uVar2 & 0x80002) != 0) { + ke_evt_set(0x200000); + } + if ((uVar2 & 4) != 0) { + if ((_DAT_44b00038 & 0xf) == 0) { + _DAT_44b0808c = _DAT_44b0808c & 0xffffffdf; + ps_env.prevent_sleep = ps_env.prevent_sleep & 0xfffffffb; + ke_evt_set(0x800000); + } + else { + assert_rec("blmac_current_state_getf() == HW_IDLE","module",0x8c); + } + } + uVar1 = _DAT_44b08084; + if ((uVar2 & 8) != 0) { + _DAT_44b08088 = _DAT_44b08084; + if ((_DAT_44b08084 & 0x100) != 0) { + ke_evt_set(0x4000000); + } + if ((uVar1 & 0x40) != 0) { + rxl_timeout_int_handler(); + } + if ((uVar1 & 0x80) != 0) { + ke_evt_set(0x8000000); + } + if ((uVar1 & 1) != 0) { + assert_rec("HAL_AC0_TIMER_BIT timeout ","module",0x22f); + } + if ((uVar1 & 2) == 0) { + if ((uVar1 & 4) == 0) { + if ((uVar1 & 8) == 0) { + if ((uVar1 & 0x10) == 0) { + if ((uVar1 & 0x20) == 0) goto LAB_2301af80; + line = 0x236; + condition = "!(timer_pending & HAL_IDLE_TIMER_BIT)"; + } + else { + line = 0x235; + condition = "!(timer_pending & HAL_BCN_TIMER_BIT)"; + } + } + else { + line = 0x234; + condition = "!(timer_pending & HAL_AC3_TIMER_BIT)"; + } + } + else { + line = 0x233; + condition = "!(timer_pending & HAL_AC2_TIMER_BIT)"; + } + } + else { + line = 0x232; + condition = "!(timer_pending & HAL_AC1_TIMER_BIT)"; + } + assert_rec(condition,"module",line); + } +LAB_2301af80: + if ((uVar2 & 0x80) == 0) { + if ((uVar2 & 0x100) == 0) { + if ((int)(uVar2 << 0x13) < 0) { + line = 0x27a; + condition = "!(genirq_pending & NXMAC_PT_ERROR_BIT)"; + } + else { + if ((int)(uVar2 << 0x12) < 0) { + line = 0x27b; + condition = "!(genirq_pending & NXMAC_AC_0_TX_DMA_DEAD_BIT)"; + } + else { + if ((int)(uVar2 << 0x11) < 0) { + line = 0x27c; + condition = "!(genirq_pending & NXMAC_AC_1_TX_DMA_DEAD_BIT)"; + } + else { + if ((int)(uVar2 << 0x10) < 0) { + line = 0x27d; + condition = "!(genirq_pending & NXMAC_AC_2_TX_DMA_DEAD_BIT)"; + } + else { + if ((int)(uVar2 << 0xf) < 0) { + line = 0x27e; + condition = "!(genirq_pending & NXMAC_AC_3_TX_DMA_DEAD_BIT)"; + } + else { + if ((int)(uVar2 << 0xe) < 0) { + line = 0x27f; + condition = "!(genirq_pending & NXMAC_BCN_TX_DMA_DEAD_BIT)"; + } + else { + if ((int)(uVar2 << 10) < 0) { + line = 0x280; + condition = "!(genirq_pending & NXMAC_MAC_PHYIF_UNDER_RUN_BIT)"; + } + else { + if ((int)(uVar2 << 9) < 0) { + line = 0x281; + condition = "!(genirq_pending & NXMAC_PHY_ERR_BIT)"; + } + else { + if ((int)(uVar2 << 7) < 0) { + line = 0x282; + condition = "!(genirq_pending & NXMAC_RX_HEADER_DMA_DEAD_BIT)"; + } + else { + if ((int)(uVar2 << 6) < 0) { + line = 0x283; + condition = "!(genirq_pending & NXMAC_RX_PAYLOAD_DMA_DEAD_BIT)"; + } + else { + if (-1 < (int)(uVar2 << 0xb)) { + return; + } + line = 0x284; + condition = "!(genirq_pending & NXMAC_HW_ERR_BIT)"; + } + } + } + } + } + } + } + } + } + } + } + else { + line = 0x279; + condition = "!(genirq_pending & NXMAC_RX_FIFO_OVER_FLOW_BIT)"; + } + } + else { + line = 0x278; + condition = "!(genirq_pending & NXMAC_RX_DMA_EMPTY_BIT)"; + } + assert_rec(condition,"module",line); + return; +} + + + +void hal_mib_dump(void) + +{ + puts("---------- hal_mib_dump ----------\r\n"); + printf("machw_mib nx_rd_fifo_overflow_count is %u\r\n"); + puts("\r\n"); + return; +} + + + +int mm_monitor_channel_req_handler + (ke_msg_id_t msgid,mm_monitor_channel_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint16_t prim20_freq; + undefined4 *puVar1; + uint32_t uVar2; + uint16_t center1_freq; + + puVar1 = (undefined4 *)ke_msg_alloc(0x5f,src_id,dest_id,0x28); + center1_freq = (uint16_t)param->freq; + *puVar1 = 1; + puVar1[3] = 0x11111111; + puVar1[4] = 0x22222222; + puVar1[5] = 0x33333333; + puVar1[6] = 0x44444444; + puVar1[7] = 0x55555555; + puVar1[8] = 0x66666666; + puVar1[2] = 0; + puVar1[9] = 0x77777777; + uVar2 = param->freq; + puVar1[1] = uVar2; + prim20_freq = (uint16_t)uVar2; + if ((param->use_40Mhz != 0) && (center1_freq = prim20_freq + 10, param->higher_band == 0)) { + center1_freq = prim20_freq - 10; + } + phy_set_channel('\0',param->use_40Mhz != 0,prim20_freq,center1_freq,0,'\0'); + *puVar1 = 0; + ke_msg_send(puVar1); + return 0; +} + + + +int mm_monitor_enable_req_handler + (ke_msg_id_t msgid,mm_monitor_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined4 *puVar1; + uint32_t local_50; + phy_cfg_tag config; + + puVar1 = (undefined4 *)ke_msg_alloc(0x5d,src_id,dest_id,0x28); + *puVar1 = 1; + puVar1[3] = 0x11111111; + puVar1[4] = 0x22222222; + puVar1[5] = 0x33333333; + puVar1[6] = 0x44444444; + puVar1[7] = 0x55555555; + puVar1[8] = 0x66666666; + puVar1[2] = 0; + puVar1[9] = 0x77777777; + puVar1[1] = param->enable; + memset(&local_50,0,0x40); + local_50 = 0; + phy_init((phy_cfg_tag *)&local_50); + phy_set_channel('\0','\0',0x985,0x985,0,'\0'); + mm_active(); + *puVar1 = 0; + ke_msg_send(puVar1); + return 0; +} + + + +int mm_cfg_rssi_req_handler + (ke_msg_id_t msgid,mm_cfg_rssi_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + byte bVar1; + uint uVar2; + + uVar2 = (uint)param->vif_index; + if (vif_info_tab[uVar2].type != '\0') { + assert_err("vif_entry->type == VIF_STA","module",0x8fe); + } + vif_info_tab[uVar2].u[0x1a] = param->rssi_thold; + bVar1 = param->rssi_hyst; + vif_info_tab[uVar2].u[0x1c] = 0; + vif_info_tab[uVar2].u[0x1b] = bVar1; + return 0; +} + + + +int mm_set_ps_options_req_handler + (ke_msg_id_t msgid,mm_set_ps_options_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint uVar1; + + uVar1 = (uint)param->vif_index; + if (vif_info_tab[uVar1].type != '\0') { + assert_err("vif_entry->type == VIF_STA","module",0x815); + } + *(uint16_t *)vif_info_tab[uVar1].u = param->listen_interval; + *(_Bool *)(vif_info_tab[uVar1].u + 2) = param->dont_listen_bc_mc; + ke_msg_send_basic(0x4c,src_id,dest_id); + return 0; +} + + + +int mm_tim_update_req_handler + (ke_msg_id_t msgid,mm_tim_update_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + mm_tim_update(param); + return 1; +} + + + +int mm_bcn_change_req_handler + (ke_msg_id_t msgid,mm_bcn_change_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + mm_bcn_change(param); + return 1; +} + + + +int mm_remain_on_channel_req_handler + (ke_msg_id_t msgid,mm_remain_on_channel_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t uVar1; + uint8_t uVar2; + uint8_t *puVar3; + undefined2 in_register_00002036; + + uVar2 = chan_roc_req(param,src_id); + if (CONCAT22(in_register_00002036,src_id) != 0) { + puVar3 = (uint8_t *)ke_msg_alloc(0x47,src_id,dest_id,3); + uVar1 = param->op_code; + puVar3[1] = uVar2; + *puVar3 = uVar1; + puVar3[2] = '\x04'; + ke_msg_send(); + } + return 0; +} + + + +int mm_sta_del_req_handler + (ke_msg_id_t msgid,mm_sta_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + mm_sta_del(param->sta_idx); + ke_msg_send_basic(0xd,src_id,dest_id); + return 0; +} + + + +int mm_sta_add_req_handler + (ke_msg_id_t msgid,mm_sta_add_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t uVar1; + uint8_t *puVar2; + + puVar2 = (uint8_t *)ke_msg_alloc(0xb,src_id,dest_id,3); + uVar1 = mm_sta_add(param,puVar2 + 1,puVar2 + 2); + *puVar2 = uVar1; + ke_msg_send(puVar2); + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mm_key_del_req_handler + (ke_msg_id_t msgid,mm_key_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + if ((_DAT_44b000d8 >> 0x18) + 1 < (uint)param->hw_key_idx) { + assert_err("param->hw_key_idx <= MM_SEC_MAX_KEY_NBR","module",0x56e); + } + mm_sec_machwkey_del(param->hw_key_idx); + ke_msg_send_basic(0x27,src_id,dest_id); + return 0; +} + + + +int mm_key_add_req_handler + (ke_msg_id_t msgid,mm_key_add_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t uVar1; + undefined *puVar2; + + puVar2 = (undefined *)ke_msg_alloc(0x25,src_id,dest_id,2); + if (3 < param->key_idx) { + assert_err("param->key_idx < MAC_DEFAULT_KEY_COUNT","module",0x53d); + } + if (0x20 < (param->key).length) { + assert_err("param->key.length <= MAC_SEC_KEY_LEN","module",0x541); + } + if (5 < param->cipher_suite) { + assert_err("param->cipher_suite <= MAC_RSNIE_CIPHER_AES_CMAC","module",0x544); + } + uVar1 = mm_sec_machwkey_wr(param); + puVar2[1] = uVar1; + *puVar2 = 0; + ke_msg_send(puVar2); + return 0; +} + + + +int mm_set_power_req_handler + (ke_msg_id_t msgid,mm_set_power_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint uVar1; + uint8_t *idx; + + uVar1 = (uint)param->inst_nbr; + idx = (uint8_t *)ke_msg_alloc(0x2f,src_id,dest_id,2); + vif_info_tab[uVar1].user_tx_power = param->power; + idx[1] = vif_info_tab[uVar1].tx_power; + vif_info_tab[uVar1].tx_power = '\x7f'; + tpc_update_vif_tx_power(vif_info_tab + uVar1,(int8_t *)(idx + 1),idx); + ke_msg_send(idx); + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mm_set_idle_req_handler + (ke_msg_id_t msgid,mm_set_idle_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + int iVar1; + ke_state_t kVar2; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + + kVar2 = ke_state_get(dest_id); + if (CONCAT22(extraout_var,kVar2) == 3) { +LAB_2301b686: + iVar1 = 2; + } + else { + mm_env.host_idle = param->hw_idle; + if (mm_env.host_idle == '\0') { + kVar2 = ke_state_get(dest_id); + if (CONCAT22(extraout_var_01,kVar2) == 2) goto LAB_2301b686; + mm_active(); + } + else { + kVar2 = ke_state_get(dest_id); + if (CONCAT22(extraout_var_00,kVar2) != 0) { + if (CONCAT22(extraout_var_00,kVar2) == 2) { + return 2; + } + hal_machw_idle_req(); + ke_state_set(dest_id,2); + return 2; + } + if ((_DAT_44b00038 & 0xf) != 0) { + assert_err("blmac_current_state_getf() == HW_IDLE","module",0x47d); + } + mm_env._18_2_ = 0; + } + ke_msg_send_basic(0x23,src_id,dest_id); + iVar1 = 0; + } + return iVar1; +} + + +/* +Unable to decompile 'mm_reset_req_handler' +Cause: Exception while decompiling 2301b70e: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mm_version_req_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined4 *puVar1; + + puVar1 = (undefined4 *)ke_msg_alloc(5,src_id,dest_id,0x18); + *puVar1 = 0x5040000; + puVar1[1] = _DAT_44b00004; + puVar1[2] = _DAT_44b00008; + phy_get_version(puVar1 + 3,puVar1 + 4); + puVar1[5] = 0x89df; + ke_msg_send(puVar1); + return 0; +} + + + +int mm_start_req_handler + (ke_msg_id_t msgid,mm_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(dest_id); + if (CONCAT22(extraout_var,kVar1) != 0) { + assert_err("ke_state_get(dest_id) == MM_IDLE","module",0x135); + } + phy_init((phy_cfg_tag *)param); + phy_set_channel('\0','\0',0x96c,0x96c,0,'\0'); + tpc_update_tx_power('\x10'); + ps_env.uapsd_timeout = param->uapsd_timeout * 1000; + mm_env.lp_clk_accuracy = param->lp_clk_accuracy; + ke_msg_send_basic(3,src_id,dest_id); + mm_active(); + hal_machw_idle_req(); + ke_state_set(dest_id,2); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling + +int mm_set_ps_mode_req_handler + (ke_msg_id_t msgid,mm_set_ps_mode_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + vif_info_tag *vif_entry; + + vif_entry = (vif_info_tag *)vif_mgmt_env.used_list.first; + if (param->new_state == '\x03') { + while (vif_entry != (vif_info_tag *)0x0) { + if ((vif_entry->type == '\0') && (vif_entry->active != false)) { + ps_polling_frame(vif_entry); + } + vif_entry = *(vif_info_tag **)&vif_entry->list_hdr; + } + ke_msg_send_basic(0x32,ps_env.taskid,0); + } + else { + ps_set_mode(param->new_state,src_id); + } + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mm_force_idle_req_handler + (ke_msg_id_t msgid,mm_force_idle_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + int iVar1; + ke_state_t kVar2; + undefined2 extraout_var; + + kVar2 = ke_state_get(dest_id); + if (CONCAT22(extraout_var,kVar2) == 0) { + if ((_DAT_44b00038 & 0xf) != 0) { + assert_err("blmac_current_state_getf() == HW_IDLE","module",0x4c0); + } + ke_state_set(dest_id,3); + iVar1 = 0; + (*param->cb)(param->cb); + } + else { + iVar1 = 2; + if (CONCAT22(extraout_var,kVar2) != 2) { + hal_machw_idle_req(); + ke_state_set(dest_id,2); + } + } + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mm_hw_config_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + char cVar1; + byte bVar2; + _Bool _Var3; + uint8_t uVar4; + uint16_t uVar5; + uint32_t uVar6; + uint32_t uVar7; + int iVar8; + uint8_t uVar9; + ke_state_t kVar10; + ke_msg_id_t id; + undefined2 in_register_0000202a; + undefined2 extraout_var; + uint8_t *puVar11; + uint32_t uVar12; + uint32_t uVar13; + uint uVar14; + uint uVar15; + uint uVar16; + + uVar16 = CONCAT22(in_register_0000202a,msgid); + kVar10 = ke_state_get(dest_id); + if (CONCAT22(extraout_var,kVar10) != 0) { + if (1 < (CONCAT22(extraout_var,kVar10) - 2U & 0xffff)) { + mm_env.prev_hw_state = (byte)_DAT_44b00038 & 0xf; + kVar10 = ke_state_get(dest_id); + mm_env.prev_mm_state = (uint8_t)kVar10; + hal_machw_idle_req(); + ke_state_set(dest_id,2); + } + return 2; + } + if ((_DAT_44b00038 & 0xf) != 0) { + assert_err("blmac_current_state_getf() == HW_IDLE","module",0x77b); + } + iVar8 = DAT_4201d1f8; + if (uVar16 == 0x16) { + (&mm_env.rx_filter_lmac_enable)[(uint)*(byte *)((int)param + 5) + 4] = *(uint32_t *)param; + if ((iVar8 != 0) && (*(char *)(iVar8 + 4) == *(char *)((int)param + 5))) { + _DAT_44b000dc = 0x10; + } + id = 0x17; +LAB_2301baa6: + ke_msg_send_basic(id,src_id,dest_id); + } + else { + if (0x16 < uVar16) { + if (uVar16 == 0x1e) { + uVar16 = (uint)*(byte *)((int)param + 3); + if (vif_info_tab[uVar16].type == '\0') { + if (*(char *)((int)param + 2) == '\0') { + mm_timer_clear(&vif_info_tab[uVar16].tbtt_timer); + } + else { + uVar14 = (uint)vif_info_tab[uVar16].u[4]; + mm_timer_set(&vif_info_tab[uVar16].tbtt_timer, + _DAT_44b00120 + sta_info_tab[uVar14].bcn_int); + uVar5 = *(uint16_t *)param; + uVar12 = sta_info_tab[uVar14].bcn_int; + *(undefined2 *)vif_info_tab[uVar16].u = 0; + sta_info_tab[uVar14].aid = uVar5; + uVar15 = (uint)mm_env.lp_clk_accuracy; + vif_info_tab[uVar16].u[2] = 0; + sta_info_tab[uVar14].drift = (uint16_t)(((uVar15 + 0x14) * uVar12) / 1000000); + iVar8 = _DAT_44b00120; + vif_info_tab[uVar16].u[0x18] = 0; + *(undefined4 *)(vif_info_tab[uVar16].u + 0x14) = 0; + *(int *)(vif_info_tab[uVar16].u + 8) = iVar8; + vif_info_tab[uVar16].prevent_sleep = vif_info_tab[uVar16].prevent_sleep | 1; + *(int *)(vif_info_tab[uVar16].u + 0x10) = _DAT_44b00120; + chan_bcn_detect_start(vif_info_tab + uVar16); + } + } + _Var3 = *(_Bool *)((int)param + 2); + vif_info_tab[uVar16].active = _Var3; + if (_Var3 != false) { + _DAT_44b00200 = vif_info_tab[uVar16].txq_params[3]; + _DAT_44b00204 = vif_info_tab[uVar16].txq_params[3]; + _DAT_44b00208 = vif_info_tab[uVar16].txq_params[3]; + _DAT_44b0020c = vif_info_tab[uVar16].txq_params[3]; + mm_env_max_ampdu_duration_set(); + } + id = 0x1f; + } + else { + if (uVar16 < 0x1f) { + if (uVar16 == 0x1a) { + uVar16 = (uint)*(byte *)((int)param + 6); + vif_info_tab[0].txq_params[uVar16 * 0x176 + (uint)*(byte *)((int)param + 5)] = + *(uint32_t *)param; + if (vif_info_tab[uVar16].active != false) { + cVar1 = *(char *)((int)param + 5); + uVar13 = *(uint32_t *)param; + uVar12 = _DAT_44b00200; + uVar6 = uVar13; + uVar7 = _DAT_44b00208; + if (((cVar1 != '\x01') && (uVar12 = uVar13, uVar6 = _DAT_44b00204, cVar1 != '\0')) && + (uVar12 = _DAT_44b00200, uVar7 = uVar13, cVar1 != '\x02')) { + uVar7 = _DAT_44b00208; + _DAT_44b0020c = uVar13; + } + _DAT_44b00208 = uVar7; + _DAT_44b00204 = uVar6; + _DAT_44b00200 = uVar12; + mm_env_max_ampdu_duration_set(); + } + if (vif_info_tab[uVar16].type == '\0') { + ps_uapsd_set(vif_info_tab + uVar16,*(uint8_t *)((int)param + 5), + *(_Bool *)((int)param + 4)); + } + id = 0x1b; + } + else { + if (uVar16 == 0x1c) { + bVar2 = *(byte *)param; + if (((uint)bVar2 << 0xe & 0x3e0000) != 0) { + assert_err("(((uint32_t)abgnmode << 14) & ~((uint32_t)0x0001C000)) == 0","module", + 0x834); + } + _DAT_44b0004c = _DAT_44b0004c & 0xfffe3fff | (uint)bVar2 << 0xe; + id = 0x1d; + } + else { + if (uVar16 != 0x18) goto LAB_2301b960; + memcpy(&vif_info_tab[*(byte *)((int)param + 6)].bssid,param,6); + if ((uint)vif_mgmt_env.vif_sta_cnt + (uint)vif_mgmt_env.vif_ap_cnt == 1) { + _DAT_44b00020 = *(undefined4 *)param; + _DAT_44b00024 = (uint)*(ushort *)((int)param + 4); + } + id = 0x19; + } + } + } + else { + if (uVar16 == 0x28) { + uVar9 = '\x05'; + if (*(char *)param != '\0') { + uVar9 = '\0'; + _DAT_44b00054 = _DAT_44b00054 | 0x80; + } + puVar11 = (uint8_t *)ke_msg_alloc(0x29,src_id,dest_id,3); + *puVar11 = *(uint8_t *)((int)param + 1); + uVar4 = *(uint8_t *)((int)param + 2); + puVar11[2] = uVar9; + puVar11[1] = uVar4; + goto LAB_2301b9bc; + } + if (uVar16 == 0x3b) { + chan_ctxt_update((mm_chan_ctxt_update_req *)param); + id = 0x3c; + } + else { + if (uVar16 != 0x20) goto LAB_2301b960; + id = 0x21; + _DAT_44b000e8 = + (uint)*(byte *)param * (_DAT_44b000e4 & 0xff) * 0x100 | (uint)*(byte *)param; + } + } + } + goto LAB_2301baa6; + } + if (uVar16 == 0xe) { + mm_env.rx_filter_umac = *(uint32_t *)param; + _DAT_44b00060 = mm_env.rx_filter_umac | mm_env.rx_filter_lmac_enable; + id = 0xf; + goto LAB_2301baa6; + } + if (0xe < uVar16) { + if (uVar16 == 0x12) { + _DAT_44b00090 = (uint)*(byte *)param | _DAT_44b00090 & 0xffffff00 | 0x80000000; + id = 0x13; + } + else { + if (uVar16 != 0x14) { + if (uVar16 != 0x10) goto LAB_2301b960; + puVar11 = (uint8_t *)ke_msg_alloc(0x11,src_id,dest_id,2); + if (*(uint8_t *)((int)param + 8) != '\0') { + phy_set_channel(*(uint8_t *)param,*(uint8_t *)((int)param + 1), + *(uint16_t *)((int)param + 2),*(uint16_t *)((int)param + 4), + *(uint16_t *)((int)param + 6),*(uint8_t *)((int)param + 8)); + } + goto LAB_2301b9bc; + } + uVar16 = (uint)*(byte *)((int)param + 2); + if (vif_info_tab[uVar16].type == '\0') { + sta_info_tab[vif_info_tab[uVar16].u[4]].bcn_int = (uint)*(ushort *)param << 10; + } + else { + vif_mgmt_set_ap_bcn_int(vif_info_tab + uVar16,*(ushort *)param); + } + id = 0x15; + } + goto LAB_2301baa6; + } + if (uVar16 != 6) { + if (uVar16 != 8) { +LAB_2301b960: + assert_err("0","module",0x7ae); + iVar8 = 2; + goto LAB_2301baac; + } + if (*(byte *)param < 2) { + vif_mgmt_unregister(*(byte *)param); + } + if (vif_mgmt_env.used_list.first == (co_list_hdr *)0x0) { + hal_machw_monitor_mode(); + } + id = 9; + goto LAB_2301baa6; + } + puVar11 = (uint8_t *)ke_msg_alloc(7,src_id,dest_id,2); + uVar9 = vif_mgmt_register((mac_addr *)((int)param + 1),*(uint8_t *)param, + *(_Bool *)((int)param + 7),puVar11 + 1); + *puVar11 = uVar9; +LAB_2301b9bc: + ke_msg_send(puVar11); + } + iVar8 = 0; +LAB_2301baac: + uVar16 = (uint)mm_env.prev_hw_state; + if ((uVar16 << 4 & 0xffffff0f) != 0) { + assert_err("(((uint32_t)nextstate << 4) & ~((uint32_t)0x000000F0)) == 0","module",0x5b9); + } + _DAT_44b00038 = uVar16 << 4; + ke_state_set(dest_id,(ushort)mm_env.prev_mm_state); + return iVar8; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int bl60x_edca_get(int ac,uint8_t *aifs,uint8_t *cwmin,uint8_t *cwmax,uint16_t *txop) + +{ + uint uVar1; + uint uVar2; + + uVar1 = _DAT_44b00200; + uVar2 = _DAT_44b00204; + if (ac != 1) { + if (ac < 2) { + if (ac == 0) { + *txop = (uint16_t)(_DAT_44b00200 >> 0xc); + *cwmax = (byte)(uVar1 >> 8) & 0xf; + *cwmin = (byte)(uVar1 >> 4) & 0xf; + *aifs = (byte)uVar1 & 0xf; + return 0; + } + } + else { + uVar2 = _DAT_44b00208; + if ((ac == 2) || (uVar2 = _DAT_44b0020c, ac == 3)) goto LAB_2301be88; + } + return -1; + } +LAB_2301be88: + *txop = (uint16_t)(uVar2 >> 0xc); + *cwmax = (byte)(uVar2 >> 8) & 0xf; + *cwmin = (byte)(uVar2 >> 4) & 0xf; + *aifs = (byte)uVar2 & 0xf; + return 0; +} + + + +void bl_init(void) + +{ + fw_nap_chain_ptr = &fw_nap_chain; + bl_env.hw_in_doze = 0; + dbg_init(); + me_init(); + mm_init(); + ke_init(); + memset(&sta_conn_info,0,0xec); + sta_conn_info._4_2_ = 0xffff; + sta_conn_info.conType = '\0'; + sta_conn_info.gtkHwKeyId = -1; + supplicantFuncInit(); + allocSupplicantData(&sta_conn_info); + return; +} + + +/* +Unable to decompile 'bl_reset_evt' +Cause: Exception while decompiling 2301bf1c: Decompiler process died + +*/ + + +// WARNING: Type propagation algorithm not settling + +int bl_sleep(void) + +{ + vif_info_tag *p_vif_entry; + _Bool _Var1; + ke_state_t kVar2; + undefined2 extraout_var_01; + undefined3 extraout_var; + undefined3 extraout_var_00; + + if (ke_env.evt_field != 0) { + return 0; + } + kVar2 = ke_state_get(4); + if (((CONCAT22(extraout_var_01,kVar2) == 0) && (ps_env.ps_on != false)) && + (p_vif_entry = (vif_info_tag *)vif_mgmt_env.used_list.first, ps_env.prevent_sleep == 0)) { + while (p_vif_entry != (vif_info_tag *)0x0) { + _Var1 = chan_is_on_channel(p_vif_entry); + if ((CONCAT31(extraout_var_00,_Var1) != 0) && (p_vif_entry->prevent_sleep != 0)) { + return 0; + } + p_vif_entry = *(vif_info_tag **)&p_vif_entry->list_hdr; + } + if (txl_cntrl_env.pck_cnt == 0) { + _Var1 = hal_machw_sleep_check(); + return CONCAT31(extraout_var,_Var1); + } + } + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t bl_nap_calculate(void) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + + uVar2 = 0; + uVar1 = 0xffffffff; + do { + if ((1 << (uVar2 & 0x1f) & _DAT_44b0808c) != 0) { + uVar3 = *(uint *)(&DAT_44b00128 + uVar2 * 4); + if (_DAT_44b00120 < uVar3) { + uVar3 = uVar3 - _DAT_44b00120; + } + else { + uVar3 = (_DAT_44b00120 - 1) - uVar3; + } + if (uVar3 < uVar1) { + uVar1 = uVar3; + } + } + uVar2 = uVar2 + 1; + } while (uVar2 != 9); + return uVar1; +} + + + +void rx_swdesc_init(void) + +{ + rx_swdesc_tab[0].dma_hdrdesc = rx_dma_hdrdesc; + rx_swdesc_tab[1].dma_hdrdesc = &DAT_42043064; + rx_swdesc_tab[2].dma_hdrdesc = &DAT_420430c8; + rx_swdesc_tab[3].dma_hdrdesc = &DAT_4204312c; + rx_swdesc_tab[4].dma_hdrdesc = &DAT_42043190; + rx_swdesc_tab[5].dma_hdrdesc = &DAT_420431f4; + rx_swdesc_tab[6].dma_hdrdesc = &DAT_42043258; + rx_swdesc_tab[7].dma_hdrdesc = &DAT_420432bc; + rx_swdesc_tab[8].dma_hdrdesc = &DAT_42043320; + rx_swdesc_tab[9].dma_hdrdesc = &DAT_42043384; + rx_swdesc_tab[10].dma_hdrdesc = &DAT_420433e8; + rx_swdesc_tab[11].dma_hdrdesc = &DAT_4204344c; + rx_swdesc_tab[12].dma_hdrdesc = &DAT_420434b0; + return; +} + + + +int scan_cancel_req_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(2); + if (CONCAT22(extraout_var,kVar1) == 0) { + scan_send_cancel_cfm('\x01',src_id); + } + else { + DAT_42018f13 = 1; + } + return 0; +} + + + +int scan_start_req_handler + (ke_msg_id_t msgid,scan_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + int iVar1; + ke_state_t kVar2; + undefined *puVar3; + undefined2 extraout_var; + + puVar3 = (undefined *)ke_msg_alloc(0x801,src_id,dest_id,1); + kVar2 = ke_state_get(2); + if (CONCAT22(extraout_var,kVar2) == 0) { + if (param->chan_cnt == '\0') { + assert_err("param->chan_cnt > 0","module",0x46); + } + *puVar3 = 0; + DAT_42018f12 = 0; + iVar1 = 1; + param = param; + DAT_42018f10 = src_id; + scan_ie_download(param); + } + else { + *puVar3 = 8; + iVar1 = 0; + } + ke_msg_send(puVar3); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +undefined4 mm_scan_channel_end_ind_handler(void) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(2); + if (CONCAT22(extraout_var,kVar1) != 3) { + assert_err("ke_state_get(TASK_SCAN) == SCAN_WAIT_BEACON_PROBE_RSP","module",0xc4); + } + mm_env.rx_filter_lmac_enable = mm_env.rx_filter_lmac_enable & 0xffffddff; + _DAT_44b00060 = mm_env.rx_filter_lmac_enable | mm_env.rx_filter_umac; + DAT_42018f12 = DAT_42018f12 + 1; + if ((DAT_42018f12 < param->chan_cnt) && (DAT_42018f13 == '\0')) { + scan_set_channel_request(); + } + else { + ke_msg_free(¶m[-1].add_ies); + if (DAT_42018f13 == '\0') { + ke_msg_send_basic(0x802,DAT_42018f10,2); + } + else { + scan_send_cancel_cfm('\0',DAT_42018f10); + DAT_42018f13 = '\0'; + } + ke_state_set(2,0); + } + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mm_scan_channel_start_ind_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + scan_start_req *psVar1; + uint uVar2; + ke_state_t kVar3; + undefined2 extraout_var; + + psVar1 = param; + uVar2 = (uint)DAT_42018f12; + kVar3 = ke_state_get(2); + if (CONCAT22(extraout_var,kVar3) != 2) { + assert_err("ke_state_get(TASK_SCAN) == SCAN_WAIT_CHANNEL","module",0x9d); + } + mm_env.rx_filter_lmac_enable = mm_env.rx_filter_lmac_enable | 0x2200; + _DAT_44b00060 = mm_env.rx_filter_lmac_enable | mm_env.rx_filter_umac; + if ((psVar1->chan[uVar2].flags & 1) == 0) { + scan_probe_req_tx(); + } + ke_state_set(2,3); + return 0; +} + + + +void txl_buffer_reinit(void) + +{ + txl_buffer_env.list[0].first = (txl_buffer_tag *)0x0; + txl_buffer_env.list[0].last = (txl_buffer_tag *)0x0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_buffer_init(void) + +{ + uint uVar1; + txl_buffer_control *ptVar2; + txl_buffer_control *ptVar3; + uint8_t uVar4; + byte bVar5; + undefined3 extraout_var; + undefined3 extraout_var_00; + + txl_buffer_reinit(); + ptVar3 = txl_buffer_control_desc; + do { + *(undefined4 *)ptVar3->field_0 = 0xbadcab1e; + uVar4 = phy_get_ntx(); + *(int *)(ptVar3->field_0 + 4) = CONCAT31(extraout_var,uVar4) << 0xe; + bVar5 = phy_get_ntx(); + *(int *)(ptVar3->field_0 + 8) = (1 << ((uint)bVar5 + 1 & 0x1f)) + -1; + *(undefined4 *)(ptVar3->field_0 + 0xc) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x10) = 0xffff0704; + *(undefined4 *)(ptVar3->field_0 + 0x14) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x18) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x1c) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x20) = 0; + ptVar2 = ptVar3 + 1; + *(uint *)(ptVar3->field_0 + 0x24) = _DAT_44b000a0 & 0xff; + *(uint *)(ptVar3->field_0 + 0x28) = _DAT_44b000a0 & 0xff; + *(uint *)(ptVar3->field_0 + 0x2c) = _DAT_44b000a0 & 0xff; + uVar1 = _DAT_44b000a0; + ptVar3->mac_control_info = 0x2200; + ptVar3->phy_control_info = 0x3f0000; + *(uint *)(ptVar3->field_0 + 0x30) = uVar1 & 0xff; + ptVar3 = ptVar2; + } while (ptVar2 != txl_frame_buf_ctrl); + ptVar3 = txl_buffer_control_desc_bcmc; + do { + *(undefined4 *)ptVar3->field_0 = 0xbadcab1e; + uVar4 = phy_get_ntx(); + *(int *)(ptVar3->field_0 + 4) = CONCAT31(extraout_var_00,uVar4) << 0xe; + bVar5 = phy_get_ntx(); + *(int *)(ptVar3->field_0 + 8) = (1 << ((uint)bVar5 + 1 & 0x1f)) + -1; + *(undefined4 *)(ptVar3->field_0 + 0xc) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x10) = 0xffff0704; + *(undefined4 *)(ptVar3->field_0 + 0x14) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x18) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x1c) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x20) = 0; + uVar1 = _DAT_44b000a0; + ptVar2 = ptVar3 + 1; + *(undefined4 *)(ptVar3->field_0 + 0x28) = 0; + *(uint *)(ptVar3->field_0 + 0x24) = uVar1 & 0xff; + *(undefined4 *)(ptVar3->field_0 + 0x2c) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x30) = 0; + ptVar3->mac_control_info = 0; + ptVar3->phy_control_info = 0x3f0000; + ptVar3 = ptVar2; + } while (ptVar2 != txl_buffer_control_desc); + return; +} + + + +void txl_buffer_reset(void) + +{ + txl_buffer_env.list[0].first = (txl_buffer_tag *)0x0; + txl_buffer_env.list[0].last = (txl_buffer_tag *)0x0; + return; +} + + + +txl_buffer_tag * txl_buffer_alloc(txdesc *txdesc,uint8_t access_category,uint8_t user_idx) + +{ + ushort uVar1; + txl_buffer_tag *ptVar2; + txl_buffer_tag *ptVar3; + txl_buffer_control *ptVar4; + uint uVar5; + int iVar6; + int iVar7; + + uVar5 = (uint)(txdesc->umac).head_len; + *(uint8_t *)(txdesc->buf + 0x3b) = user_idx; + txdesc->buf[2] = (uVar5 + 0xf & 0xfffffff0) - uVar5; + txdesc->buf[0xe] = 0xcafefade; + uVar1 = (txdesc->host).flags; + txdesc->buf[1] = uVar5; + ptVar3 = (txl_buffer_tag *)txdesc->buf; + if ((uVar1 & 8) == 0) { + txu_cntrl_frame_build(txdesc,(int)txdesc->buf + uVar5 + 0x14c); + } + ptVar4 = (txdesc->umac).buf_control; + iVar6 = 0; + do { + iVar7 = iVar6 + 4; + *(undefined4 *)((int)txdesc->buf + iVar6 + 0xf0) = *(undefined4 *)(ptVar4->field_0 + iVar6); + iVar6 = iVar7; + } while (iVar7 != 0x3c); + ptVar2 = ptVar3; + if (txl_buffer_env.list[0].first != (txl_buffer_tag *)0x0) { + (txl_buffer_env.list[0].last)->next = ptVar3; + ptVar2 = txl_buffer_env.list[0].first; + } + txl_buffer_env.list[0].first = ptVar2; + txl_buffer_env.list[0].last = ptVar3; + txdesc->buf[4] = 0; + return ptVar3; +} + + + +void txl_buffer_update_thd(txdesc *txdesc) + +{ + char "txl_buffer_update_thd" [22]; + uint32_t *puVar1; + int iVar2; + tx_pbd *in_a2; + tx_pbd *ptVar3; + uint32_t uVar4; + txl_buffer_tag *ptVar5; + tx_hw_desc *ptVar6; + uint32_t uVar7; + + ptVar5 = (txdesc->lmac).buffer; + ptVar6 = (txdesc->lmac).hw_desc; + puVar1 = (txdesc->host).pbuf_chained_ptr; + iVar2 = 0; + ptVar3 = ptVar5->tbd_body; + while (*puVar1 != 0) { + ptVar3->upatterntx = 0xcafefade; + uVar4 = *puVar1; + ptVar3->datastartptr = uVar4; + uVar7 = puVar1[4]; + ptVar3->bufctrlinfo = 0; + iVar2 = iVar2 + 1; + ptVar3->dataendptr = (uVar4 + uVar7) - 1; + *(tx_pbd **)&ptVar3->next = ptVar3 + 1; + puVar1 = puVar1 + 1; + in_a2 = ptVar3; + ptVar3 = ptVar3 + 1; + } + if (iVar2 == 0) { + printf("%s: assert when set add_pbd chain\r\n","txl_buffer_update_thd"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + uVar4 = ptVar5->lenheader; + (ptVar5->tbd).upatterntx = 0xcafefade; + *(txl_buffer_tag **)&(ptVar5->tbd).datastartptr = ptVar5 + 1; + *(uint8_t **)&(ptVar5->tbd).dataendptr = ptVar5->tkip_mic_icv + uVar4 + 0xb; + *(tx_pbd **)&(ptVar5->tbd).next = ptVar5->tbd_body; + (ptVar5->tbd).bufctrlinfo = 0; + *(tx_pbd **)&(ptVar6->thd).field_3 = &ptVar5->tbd; + in_a2->bufctrlinfo = 0; + (ptVar6->thd).macctrlinfo2 = 0x100; + in_a2->next = 0; + return; +} + + + +void txl_cfm_init(void) + +{ + memset(&txl_cfm_env,0,0x28); + co_list_init((co_list *)&txl_cfm_env); + co_list_init(txl_cfm_env.cfmlist + 1); + co_list_init(txl_cfm_env.cfmlist + 2); + co_list_init(txl_cfm_env.cfmlist + 3); + co_list_init(txl_cfm_env.cfmlist + 4); + return; +} + + + +void txl_cfm_push(txdesc *txdesc,uint32_t status,uint8_t access_category) + +{ + undefined3 in_register_00002031; + + ((txdesc->lmac).hw_desc)->cfm_ptr->status = status; + co_list_push_back(txl_cfm_env.cfmlist + CONCAT31(in_register_00002031,access_category), + (co_list_hdr *)txdesc); + ke_evt_set(txl_cfm_evt_bit[CONCAT31(in_register_00002031,access_category)]); + return; +} + + +/* +Unable to decompile 'txl_cfm_evt' +Cause: Exception while decompiling 2301c59a: Decompiler process died + +*/ + + +void txl_cfm_flush(uint8_t access_category,co_list *list,uint32_t status) + +{ + txdesc *txdesc; + tx_cfm_tag *ptVar1; + + while (txdesc = (txdesc *)co_list_pop_front(list), txdesc != (txdesc *)0x0) { + ptVar1 = ((txdesc->lmac).hw_desc)->cfm_ptr; + if ((txdesc->lmac).agg_desc == (tx_agg_desc *)0x0) { + if (-1 < (int)ptVar1->status) { + ptVar1->status = status; + } + } + else { + ptVar1->status = status | 0x3c000000; + } + if ((txdesc->host).packet_addr == 0) { + txl_frame_cfm(txdesc); + } + else { + txu_cntrl_cfm(txdesc); + txl_cntrl_env.pck_cnt = txl_cntrl_env.pck_cnt - 1; + if ((txdesc->lmac).buffer != (txl_buffer_tag *)0x0) { + (txdesc->lmac).buffer = (txl_buffer_tag *)0x0; + } + } + } + txl_frame_evt(0); + ipc_emb_txcfm_ind(1 << ((uint)access_category & 0x1f)); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_cfm_dma_int_handler(void) + +{ + ps_env.prevent_sleep = ps_env.prevent_sleep & 0xfffffffe; + _DAT_44a00020 = _DAT_44a00024 & 0x100; + return; +} + + + +void txl_cfm_dump(void) + +{ + txl_cfm_env_tag *list; + uint32_t uVar1; + uint32_t **ppuVar2; + + list = &txl_cfm_env; + do { + uVar1 = co_list_cnt((co_list *)list); + if (uVar1 != 0) { + ppuVar2 = (uint32_t **)((bam_env_tag *)list)->pkt_cnt; + while (ppuVar2 != (uint32_t **)0x0) { + ppuVar2 = (uint32_t **)*ppuVar2; + } + } + list = (txl_cfm_env_tag *)&((bam_env_tag *)list)->ssn; + } while ((bam_env_tag *)list != bam_env); + return; +} + + + +void bam_init(void) + +{ + bam_env[0].sta_idx = -1; + ke_state_set(8,0); + return; +} + + + +void bam_send_air_action_frame + (int param_1,bam_env_tag *param_2,int param_3,uint8_t param_4,int param_5, + uint16_t param_6,cfm_func_ptr *param_7) + +{ + byte bVar1; + uint8_t ac; + uint16_t uVar2; + txl_frame_desc_tag *frame; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + txl_buffer_tag *ptVar3; + tx_hw_desc *ptVar4; + int iVar5; + uint uVar6; + char acStack72 [20]; + + bVar1 = sta_info_tab[param_1].inst_nbr; + uVar6 = (uint)bVar1; + phy_get_channel((phy_channel_info *)acStack72,'\0'); + frame = txl_frame_get((uint)(acStack72[0] != '\0'),0x100); + if (frame == (txl_frame_desc_tag *)0x0) { + return; + } + tpc_update_frame_tx_power(vif_info_tab + uVar6,frame); + ptVar3 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar3[1].length = 0xd0; + *(undefined *)((int)&ptVar3[1].length + 1) = 0; + *(undefined *)((int)&ptVar3[1].length + 2) = 0; + *(undefined *)((int)&ptVar3[1].length + 3) = 0; + *(uint16_t *)&ptVar3[1].lenheader = sta_info_tab[param_1].mac_addr.array[0]; + *(uint16_t *)((int)&ptVar3[1].lenheader + 2) = sta_info_tab[param_1].mac_addr.array[1]; + *(uint16_t *)&ptVar3[1].lenpad = sta_info_tab[param_1].mac_addr.array[2]; + *(uint16_t *)((int)&ptVar3[1].lenpad + 2) = vif_info_tab[uVar6].mac_addr.array[0]; + *(uint16_t *)&ptVar3[1].flags = vif_info_tab[uVar6].mac_addr.array[1]; + *(uint16_t *)((int)&ptVar3[1].flags + 2) = vif_info_tab[uVar6].mac_addr.array[2]; + if (vif_info_tab[uVar6].type == '\x02') { + *(uint16_t *)&ptVar3[1].next = vif_info_tab[uVar6].mac_addr.array[0]; + *(uint16_t *)((int)&ptVar3[1].next + 2) = vif_info_tab[uVar6].mac_addr.array[1]; + uVar2 = vif_info_tab[uVar6].mac_addr.array[2]; + } + else { + *(uint16_t *)&ptVar3[1].next = sta_info_tab[param_1].mac_addr.array[0]; + *(uint16_t *)((int)&ptVar3[1].next + 2) = sta_info_tab[param_1].mac_addr.array[1]; + uVar2 = sta_info_tab[param_1].mac_addr.array[2]; + } + *(uint16_t *)&ptVar3[1].txdesc = uVar2; + uVar6 = (uint)txl_cntrl_env.seqnbr; + txl_cntrl_env.seqnbr = (uint16_t)((uVar6 + 1) * 0x10000 >> 0x10); + iVar5 = (uVar6 + 1) * 0x100000; + *(undefined *)((int)&ptVar3[1].txdesc + 2) = (char)((uint)iVar5 >> 0x10); + *(undefined *)((int)&ptVar3[1].txdesc + 3) = (char)((uint)iVar5 >> 0x18); + (frame->txdesc).host.vif_idx = bVar1; + (frame->txdesc).host.staid = (uint8_t)param_1; + if (param_3 == 1) { + uVar2 = me_build_add_ba_rsp((uint32_t)ptVar3[1].dma_desc,param_2,(uint16_t)param_5,param_4, + param_6); + iVar5 = CONCAT22(extraout_var_00,uVar2); +LAB_2301c8fc: + iVar5 = iVar5 + 0x18; + } + else { + if (param_3 == 0) { + ac = "\x01"[param_5 >> 2 & 0xf]; + uVar2 = me_build_add_ba_req((uint32_t)ptVar3[1].dma_desc,param_2); + iVar5 = CONCAT22(extraout_var,uVar2) + 0x18; + goto LAB_2301c8ae; + } + if (param_3 == 2) { + uVar2 = me_build_del_ba((uint32_t)ptVar3[1].dma_desc,param_2,param_6); + iVar5 = CONCAT22(extraout_var_01,uVar2); + goto LAB_2301c8fc; + } + assert_warn("0","module",0x25d); + iVar5 = 0x18; + } + ac = '\x03'; +LAB_2301c8ae: + ptVar4 = (frame->txdesc).lmac.hw_desc; + (ptVar4->thd).field_5 = (ptVar4->thd).field_4 + -1 + iVar5; + (ptVar4->thd).frmlen = iVar5 + 4; + if (param_7 != (cfm_func_ptr *)0x0) { + (frame->cfm).cfm_func = param_7; + *(bam_env_tag **)&(frame->cfm).env = param_2; + } + txl_frame_push(frame,ac); + return; +} + + + +undefined4 rxu_mgt_ind_handler(int param_1) + +{ + int iVar1; + int iVar2; + byte bVar3; + byte bVar4; + ushort uVar5; + uint uVar6; + uint uVar7; + + if (*(char *)(param_1 + 0x1d) == '\0') { + uVar5 = *(ushort *)(param_1 + 0x1f); + bVar3 = *(byte *)(param_1 + 7); + bVar4 = *(byte *)(param_1 + 0x1e); + iVar1 = 0x408; + if ((uVar5 & 1) != 0) { + iVar1 = 0x40c; + } + iVar2 = 0x418; + if ((uVar5 & 2) == 0) { + iVar2 = 0x42c; + } + uVar7 = (uint)(uVar5 >> 6); + printf( + "-----------------> AABA Request:\r\n A-MSDU: %s\r\n Block Ack Policy: %s\r\n TID: %u\r\n Number of Buffers: %u\r\n" + ,iVar1 + 0x23078000,iVar2 + 0x23078000,(int)(uint)uVar5 >> 2 & 0xf,uVar7); + if (8 < uVar5 >> 6) { + uVar7 = 8; + } + uVar6 = SEXT24((short)((ushort)(uVar7 << 6) | uVar5 & 0x3e | 2)); + uVar7 = uVar6 & 0xffff; + printf( + "-----------------> AABA Response:\r\n A-MSDU: %s\r\n Block Ack Policy: %s\r\n TID: %u\r\n Number of Buffers: %u\r\n" + ,"Not Permitted","Immediate Block Ack",(int)uVar6 >> 2 & 0xf,uVar7 >> 6); + bam_send_air_action_frame((uint)bVar3,0,1,(uint)bVar4,uVar7,0,0); + return 0; + } + return 0; +} + + + +void co_pack8p(uint32_t dst,uint8_t *src,uint32_t len) + +{ + uint8_t *puVar1; + uint8_t *puVar2; + uint32_t uVar3; + + uVar3 = 0; + while (len != uVar3) { + puVar1 = src + uVar3; + puVar2 = (uint8_t *)(dst + uVar3); + uVar3 = uVar3 + 1; + *puVar2 = *puVar1; + } + return; +} + + + +int phy_freq_to_channel(uint8_t band,uint16_t freq) + +{ + undefined3 in_register_00002029; + undefined2 in_register_0000202e; + int iVar1; + int iVar2; + + iVar1 = CONCAT22(in_register_0000202e,freq); + if (CONCAT31(in_register_00002029,band) == 0) { + if (0x48 < (iVar1 - 0x96cU & 0xffff)) { + return 0; + } + if (iVar1 == 0x9b4) { + return 0xe; + } + iVar2 = -0x967; + } + else { + if (CONCAT31(in_register_00002029,band) != 1) { + return 0; + } + if (0x334 < (iVar1 - 0x138dU & 0xffff)) { + return 0; + } + iVar2 = -5000; + } + return (iVar1 + iVar2) / 5; +} + + + +uint16_t phy_channel_to_freq(uint8_t band,int channel) + +{ + undefined3 in_register_00002029; + int iVar1; + + if (CONCAT31(in_register_00002029,band) == 0) { + if (0xd < channel - 1U) { + return 0xffff; + } + if (channel == 0xe) { + return 0x9b4; + } + iVar1 = 0x967; + } + else { + if (0xa4 < channel - 1U) { + return 0xffff; + } + iVar1 = 5000; + } + return (uint16_t)((uint)((channel * 5 + iVar1) * 0x10000) >> 0x10); +} + + + +uint32_t me_add_ie_ssid(uint32_t *frame_addr,uint8_t ssid_len,uint8_t *p_ssid) + +{ + undefined3 in_register_0000202d; + uint32_t len; + + len = CONCAT31(in_register_0000202d,ssid_len); + *(undefined *)*frame_addr = 0; + *(uint8_t *)(*frame_addr + 1) = ssid_len; + if (len != 0) { + co_pack8p(*frame_addr + 2,p_ssid,len); + } + *frame_addr = *frame_addr + len + 2; + return len + 2; +} + + + +uint32_t me_add_ie_supp_rates(uint32_t *frame_addr,mac_rateset *p_rateset) + +{ + uint32_t len; + byte bVar1; + + bVar1 = p_rateset->length; + len = 8; + if (bVar1 < 9) { + len = (uint)bVar1; + } + *(undefined *)*frame_addr = 1; + if (8 < bVar1) { + bVar1 = 8; + } + *(byte *)(*frame_addr + 1) = bVar1; + co_pack8p(*frame_addr + 2,p_rateset->array,len); + *frame_addr = *frame_addr + len + 2; + return len + 2; +} + + + +uint32_t me_add_ie_ext_supp_rates(uint32_t *frame_addr,mac_rateset *p_rateset) + +{ + byte bVar1; + uint32_t uVar2; + uint32_t len; + + bVar1 = p_rateset->length; + *(undefined *)*frame_addr = 0x32; + uVar2 = (uint)bVar1 - 6; + len = (uint)bVar1 - 8; + *(undefined *)(*frame_addr + 1) = (char)len; + co_pack8p(*frame_addr + 2,p_rateset->array + 8,len); + *frame_addr = *frame_addr + uVar2; + return uVar2; +} + + + +uint32_t me_add_ie_ds(uint32_t *frame_addr,uint8_t channel) + +{ + *(undefined *)*frame_addr = 3; + *(undefined *)(*frame_addr + 1) = 1; + *(uint8_t *)(*frame_addr + 2) = channel; + *frame_addr = *frame_addr + 3; + return 3; +} + + + +uint32_t me_add_ie_erp(uint32_t *frame_addr,uint8_t erp_info) + +{ + *(undefined *)*frame_addr = 0x2a; + *(undefined *)(*frame_addr + 1) = 1; + *(uint8_t *)(*frame_addr + 2) = erp_info; + *frame_addr = *frame_addr + 3; + return 3; +} + + + +uint32_t me_add_ie_rsn(uint32_t *frame_addr,uint8_t enc_type) + +{ + undefined3 in_register_0000202d; + uint32_t uVar1; + uint32_t uVar2; + + if (CONCAT31(in_register_0000202d,enc_type) == 1) { + *(undefined *)*frame_addr = 0x30; + *(undefined *)(*frame_addr + 1) = 0x14; + uVar1 = *frame_addr; + *(uint8_t *)(uVar1 + 2) = enc_type; + *(undefined *)(uVar1 + 3) = 0; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 6) = 0xac; + *(undefined *)(uVar1 + 7) = 4; + *(undefined *)(uVar1 + 4) = 0; + *(undefined *)(uVar1 + 5) = 0xf; + uVar1 = *frame_addr; + *(uint8_t *)(uVar1 + 8) = enc_type; + *(undefined *)(uVar1 + 9) = 0; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 0xc) = 0xac; + *(undefined *)(uVar1 + 0xd) = 4; + *(undefined *)(uVar1 + 10) = 0; + *(undefined *)(uVar1 + 0xb) = 0xf; + uVar2 = *frame_addr; + uVar1 = 0x16; + *(uint8_t *)(uVar2 + 0xe) = enc_type; + *(undefined *)(uVar2 + 0xf) = 0; + uVar2 = *frame_addr; + *(undefined *)(uVar2 + 0x12) = 0xac; + *(undefined *)(uVar2 + 0x10) = 0; + *(undefined *)(uVar2 + 0x11) = 0xf; + *(undefined *)(uVar2 + 0x13) = 2; + uVar2 = *frame_addr; + *(undefined *)(uVar2 + 0x14) = 0; + *(undefined *)(uVar2 + 0x15) = 0; + } + else { + uVar1 = 0; + if (CONCAT31(in_register_0000202d,enc_type) == 2) { + *(undefined *)*frame_addr = 0x30; + *(undefined *)(*frame_addr + 1) = 0x18; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 2) = 1; + *(undefined *)(uVar1 + 3) = 0; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 4) = 0; + *(undefined *)(uVar1 + 5) = 0xf; + *(undefined *)(uVar1 + 6) = 0xac; + *(uint8_t *)(uVar1 + 7) = enc_type; + uVar1 = *frame_addr; + *(uint8_t *)(uVar1 + 8) = enc_type; + *(undefined *)(uVar1 + 9) = 0; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 10) = 0; + *(undefined *)(uVar1 + 0xb) = 0xf; + *(undefined *)(uVar1 + 0xc) = 0xac; + *(uint8_t *)(uVar1 + 0xd) = enc_type; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 0x11) = 4; + *(undefined *)(uVar1 + 0xe) = 0; + *(undefined *)(uVar1 + 0xf) = 0xf; + *(undefined *)(uVar1 + 0x10) = 0xac; + uVar2 = *frame_addr; + uVar1 = 0x1a; + *(undefined *)(uVar2 + 0x12) = 1; + *(undefined *)(uVar2 + 0x13) = 0; + uVar2 = *frame_addr; + *(undefined *)(uVar2 + 0x14) = 0; + *(undefined *)(uVar2 + 0x15) = 0xf; + *(undefined *)(uVar2 + 0x16) = 0xac; + *(uint8_t *)(uVar2 + 0x17) = enc_type; + uVar2 = *frame_addr; + *(undefined *)(uVar2 + 0x18) = 0; + *(undefined *)(uVar2 + 0x19) = 0; + } + } + *frame_addr = *frame_addr + uVar1; + return uVar1; +} + + + +uint32_t me_add_ie_wpa(uint32_t *frame_addr,uint8_t enc_type) + +{ + uint32_t uVar1; + undefined3 in_register_0000202d; + uint32_t uVar2; + + uVar1 = 0; + if (CONCAT31(in_register_0000202d,enc_type) == 2) { + *(undefined *)*frame_addr = 0xdd; + *(undefined *)(*frame_addr + 1) = 0x1c; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 5) = 1; + *(undefined *)(uVar1 + 2) = 0; + *(undefined *)(uVar1 + 3) = 0x50; + *(undefined *)(uVar1 + 4) = 0xf2; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 6) = 1; + *(undefined *)(uVar1 + 7) = 0; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 8) = 0; + *(undefined *)(uVar1 + 9) = 0x50; + *(undefined *)(uVar1 + 10) = 0xf2; + *(uint8_t *)(uVar1 + 0xb) = enc_type; + uVar1 = *frame_addr; + *(uint8_t *)(uVar1 + 0xc) = enc_type; + *(undefined *)(uVar1 + 0xd) = 0; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 0xe) = 0; + *(undefined *)(uVar1 + 0xf) = 0x50; + *(undefined *)(uVar1 + 0x10) = 0xf2; + *(uint8_t *)(uVar1 + 0x11) = enc_type; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 0x12) = 0; + *(undefined *)(uVar1 + 0x13) = 0x50; + *(undefined *)(uVar1 + 0x14) = 0xf2; + *(undefined *)(uVar1 + 0x15) = 4; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 0x16) = 1; + *(undefined *)(uVar1 + 0x17) = 0; + uVar2 = *frame_addr; + uVar1 = 0x1e; + *(undefined *)(uVar2 + 0x18) = 0; + *(undefined *)(uVar2 + 0x19) = 0x50; + *(undefined *)(uVar2 + 0x1a) = 0xf2; + *(uint8_t *)(uVar2 + 0x1b) = enc_type; + } + *frame_addr = *frame_addr + uVar1; + return uVar1; +} + + + +uint32_t me_add_ie_tim(uint32_t *frame_addr,uint8_t dtim_period) + +{ + *(undefined *)*frame_addr = 5; + *(undefined *)(*frame_addr + 1) = 4; + *(uint8_t *)(*frame_addr + 3) = dtim_period; + *frame_addr = *frame_addr + 6; + return 6; +} + + + +uint32_t me_add_ie_ht_capa(uint32_t *frame_addr) + +{ + uint16_t uVar1; + uint32_t uVar2; + uint uVar3; + + uVar3 = (uint)me_env.ht_cap.ht_capa_info; + *(undefined *)*frame_addr = 0x2d; + *(undefined *)(*frame_addr + 1) = 0x1a; + uVar2 = *frame_addr; + *(byte *)(uVar2 + 2) = (byte)(uVar3 & 0xfffffff3) | 0xc; + *(undefined *)(uVar2 + 3) = (char)((uVar3 & 0xfffffff3) >> 8); + *(uint8_t *)(*frame_addr + 4) = me_env.ht_cap.a_mpdu_param; + co_pack8p(*frame_addr + 5,me_env.ht_cap.mcs_rate,0x10); + uVar1 = me_env.ht_cap.ht_extended_capa; + uVar2 = *frame_addr; + *(undefined *)(uVar2 + 0x15) = (char)me_env.ht_cap.ht_extended_capa; + *(undefined *)(uVar2 + 0x16) = (char)(uVar1 >> 8); + co_pack8p(*frame_addr + 0x17,(uint8_t *)&me_env.ht_cap.tx_beamforming_capa,4); + *(uint8_t *)(*frame_addr + 0x1b) = me_env.ht_cap.asel_capa; + *frame_addr = *frame_addr + 0x1c; + return 0x1c; +} + + + +uint32_t me_add_ie_ht_oper(uint32_t *frame_addr,vif_info_tag *p_vif_entry) + +{ + chan_ctxt_tag *pcVar1; + int iVar2; + uint8_t uVar3; + uint32_t uVar4; + + pcVar1 = p_vif_entry->chan_ctxt; + *(undefined *)*frame_addr = 0x3d; + *(undefined *)(*frame_addr + 1) = 0x16; + iVar2 = phy_freq_to_channel((pcVar1->channel).band,(pcVar1->channel).prim20_freq); + *(undefined *)(*frame_addr + 2) = (char)iVar2; + uVar3 = (pcVar1->channel).type; + if ((uVar3 != '\0') && + (uVar3 = '\a', (pcVar1->channel).prim20_freq <= (pcVar1->channel).center1_freq)) { + uVar3 = '\x05'; + } + *(uint8_t *)(*frame_addr + 3) = uVar3; + uVar4 = *frame_addr; + *(undefined *)(uVar4 + 4) = 3; + *(undefined *)(uVar4 + 5) = 0; + uVar4 = *frame_addr; + *(undefined *)(uVar4 + 6) = 0; + *(undefined *)(uVar4 + 7) = 0; + *(undefined *)(*frame_addr + 8) = 0xff; + *frame_addr = *frame_addr + 0x18; + return 0x18; +} + + + +uint16_t me_build_authenticate + (uint32_t frame,uint16_t algo_type,uint16_t seq_nbr,uint16_t status_code, + uint32_t *challenge_array_ptr) + +{ + undefined *puVar1; + undefined *puVar2; + int iVar3; + + *(char *)frame = (char)algo_type; + *(undefined *)(frame + 2) = (char)seq_nbr; + *(undefined *)(frame + 4) = (char)status_code; + *(undefined *)(frame + 1) = (char)(algo_type >> 8); + *(undefined *)(frame + 3) = (char)(seq_nbr >> 8); + *(undefined *)(frame + 5) = (char)(status_code >> 8); + if (challenge_array_ptr != (uint32_t *)0x0) { + *(undefined *)(frame + 6) = 0x10; + *(undefined *)(frame + 7) = 0x80; + iVar3 = 0; + do { + puVar1 = (undefined *)((int)challenge_array_ptr + iVar3); + puVar2 = (undefined *)(frame + 8 + iVar3); + iVar3 = iVar3 + 1; + *puVar2 = *puVar1; + } while (iVar3 != 0x80); + return 0x88; + } + return 6; +} + + + +uint16_t me_build_deauthenticate(uint32_t frame,uint16_t reason_code) + +{ + *(char *)frame = (char)reason_code; + *(undefined *)(frame + 1) = (char)(reason_code >> 8); + return 2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +uint16_t me_build_associate_req + (uint32_t frame,mac_bss_info *bss,mac_addr *old_ap_addr_ptr,uint8_t vif_idx, + uint32_t *ie_addr,uint16_t *ie_len,sm_connect_req *con_par) + +{ + byte bVar1; + uint32_t *puVar2; + uint8_t uVar3; + ushort uVar4; + mac_ssid *pmVar5; + int8_t *piVar6; + uint uVar7; + uint16_t uVar8; + short sVar9; + int iVar10; + uint16_t uVar11; + uint32_t uVar12; + uint32_t uVar13; + uint uVar14; + char *pcVar15; + int8_t *dst; + uint uVar16; + uint uVar17; + uint uVar18; + uint uVar19; + me_chan_config_req *pmVar20; + char cVar21; + char cVar22; + uint uVar23; + uint8_t uVar24; + int8_t *apiStack100 [4]; + int8_t iStack81; + undefined2 uStack80; + undefined uStack78; + int8_t min; + int8_t max; + + uVar8 = con_par->listen_interval; + uVar4 = con_par->ie_len; + if (uVar8 == 0) { + uVar8 = 5; + } + apiStack100[0] = (int8_t *)frame; + uVar11 = me_build_capability(vif_idx); + *apiStack100[0] = (int8_t)uVar11; + apiStack100[0][1] = (int8_t)(uVar11 >> 8); + apiStack100[0][2] = (int8_t)uVar8; + apiStack100[0][3] = (int8_t)(uVar8 >> 8); + iVar10 = 4; + if (old_ap_addr_ptr != (mac_addr *)0x0) { + iVar10 = 10; + *(uint16_t *)(apiStack100[0] + 4) = old_ap_addr_ptr->array[0]; + *(uint16_t *)(apiStack100[0] + 6) = old_ap_addr_ptr->array[1]; + *(uint16_t *)(apiStack100[0] + 8) = old_ap_addr_ptr->array[2]; + } + apiStack100[0] = apiStack100[0] + iVar10; + *(int8_t **)ie_addr = apiStack100[0]; + uVar12 = me_add_ie_ssid((uint32_t *)apiStack100,(bss->ssid).length,(bss->ssid).array); + uVar13 = me_add_ie_supp_rates((uint32_t *)apiStack100,&bss->rate_set); + sVar9 = (short)iVar10 + (short)uVar13 + (short)uVar12; + if (8 < (bss->rate_set).length) { + uVar12 = me_add_ie_ext_supp_rates((uint32_t *)apiStack100,&bss->rate_set); + sVar9 = sVar9 + (short)uVar12; + } + if ((uVar11 & 0x100) != 0) { + dst = apiStack100[0] + 1; + *apiStack100[0] = '!'; + apiStack100[0] = apiStack100[0] + 2; + *dst = '\x02'; + phy_get_rf_gain_capab((int8_t *)&uStack80,&iStack81); + bVar1 = bss->chan->tx_power; + if ((char)bVar1 < (char)uStack80) { + uStack80 = uStack80 & 0xff00 | (ushort)bVar1; + } + *apiStack100[0] = iStack81; + apiStack100[0][1] = (char)uStack80; + dst = apiStack100[0] + 3; + apiStack100[0][2] = '$'; + apiStack100[0] = apiStack100[0] + 4; + if (bss->chan->band == '\0') { + pmVar20 = &me_env.chan; + iVar10 = 1; + uVar3 = me_env.chan.chan2G4_cnt; + } + else { + pmVar20 = (me_chan_config_req *)me_env.chan.chan5G; + iVar10 = 4; + uVar3 = me_env.chan.chan5G_cnt; + } + uVar19 = 0; + cVar21 = '\0'; + uVar24 = '\0'; + uVar7 = 0; + uVar17 = 0; + while( true ) { + piVar6 = apiStack100[0]; + uVar23 = uVar19 + 2 & 0xff; + pcVar15 = apiStack100[0] + 1; + if (uVar24 == uVar3) break; + uVar16 = uVar7; + uVar18 = uVar17; + if ((pmVar20->chan2G4[0].flags & 2) == 0) { + uVar14 = phy_freq_to_channel(pmVar20->chan2G4[0].band,pmVar20->chan2G4[0].freq); + uVar16 = uVar14 & 0xff; + uVar18 = uVar16; + cVar22 = cVar21; + if ((cVar21 != '\0') && (uVar18 = uVar17, (uVar14 & 0xff) - uVar7 != iVar10)) { + cVar22 = cVar21 + '\x01'; + *piVar6 = (int8_t)uVar17; + apiStack100[0] = piVar6 + 2; + *pcVar15 = cVar21; + uVar19 = uVar23; + } + cVar21 = cVar22 + '\x01'; + pmVar20 = (me_chan_config_req *)(pmVar20->chan2G4 + 1); + } + uVar24 = uVar24 + '\x01'; + uVar7 = uVar16; + uVar17 = uVar18; + } + *apiStack100[0] = (int8_t)uVar17; + sVar9 = sVar9 + 6 + (short)uVar23; + apiStack100[0] = apiStack100[0] + 2; + *pcVar15 = cVar21; + *dst = (int8_t)uVar23; + } + pmVar5 = &con_par->ssid; + iVar10 = -(int)con_par; + while ((sm_connect_req *)(&pmVar5->length + uVar4) != con_par) { + puVar2 = con_par->ie_buf; + dst = apiStack100[0] + iVar10 + (int)con_par; + con_par = (sm_connect_req *)(con_par->ssid).array; + *dst = *(int8_t *)puVar2; + } + uVar8 = sVar9 + uVar4; + dst = apiStack100[0] + uVar4; + apiStack100[0] = dst; + if ((bss->valid_flags & 1) != 0) { + memset(&uStack78,0,0xe); + uStack80 = 0x7dd; + min = 'P'; + co_pack8p((uint32_t)dst,(uint8_t *)&uStack80,9); + uVar8 = uVar8 + (ushort)uStack80._1_1_ + 2; + apiStack100[0] = apiStack100[0] + (uint)uStack80._1_1_ + 2; + } + if (((bss->valid_flags & 2) != 0) && (me_env.ht_supported != false)) { + uVar12 = me_add_ie_ht_capa((uint32_t *)apiStack100); + uVar8 = uVar8 + (short)uVar12; + } + *ie_len = (short)apiStack100[0] - (short)*ie_addr; + return uVar8; +} + + + +uint16_t me_build_add_ba_req(uint32_t frame,bam_env_tag *bam_env) + +{ + uint16_t uVar1; + uint uVar2; + int iVar3; + + *(undefined *)frame = 3; + *(undefined *)(frame + 1) = 0; + *(uint8_t *)(frame + 2) = bam_env->dialog_token; + uVar2 = (uint)bam_env->ba_policy << 1 | (uint)bam_env->tid << 2 | (uint)bam_env->buffer_size << 6; + *(undefined *)(frame + 3) = (char)uVar2; + *(undefined *)(frame + 4) = (char)(uVar2 >> 8); + uVar1 = bam_env->ba_timeout; + *(undefined *)(frame + 5) = (char)uVar1; + *(undefined *)(frame + 6) = (char)(uVar1 >> 8); + iVar3 = (uint)bam_env->ssn << 0x14; + *(undefined *)(frame + 7) = (char)((uint)iVar3 >> 0x10); + *(undefined *)(frame + 8) = (char)((uint)iVar3 >> 0x18); + return 9; +} + + + +uint16_t me_build_add_ba_rsp(uint32_t frame,bam_env_tag *bam_env,uint16_t param,uint8_t dialog_token + ,uint16_t status_code) + +{ + undefined2 in_register_0000203a; + + *(undefined *)frame = 3; + *(undefined *)(frame + 1) = 1; + *(undefined *)(frame + 5) = (char)param; + *(undefined *)(frame + 4) = (char)(status_code >> 8); + *(uint8_t *)(frame + 2) = dialog_token; + *(undefined *)(frame + 3) = (char)status_code; + *(undefined *)(frame + 6) = (char)(param >> 8); + if (CONCAT22(in_register_0000203a,status_code) == 0) { + *(undefined *)(frame + 7) = 0xd0; + *(undefined *)(frame + 8) = 7; + } + else { + *(undefined *)(frame + 7) = 0; + *(undefined *)(frame + 8) = 0; + } + return 9; +} + + + +uint16_t me_build_del_ba(uint32_t frame,bam_env_tag *bam_env,uint16_t reason_code) + +{ + byte bVar1; + + *(undefined *)frame = 3; + *(undefined *)(frame + 1) = 2; + bVar1 = (byte)(((uint)bam_env->tid << 0x1c) >> 0x18); + if (bam_env->dev_type == '\x01') { + bVar1 = bVar1 | 8; + } + *(undefined *)(frame + 2) = 0; + *(byte *)(frame + 3) = bVar1; + *(undefined *)(frame + 4) = (char)reason_code; + *(undefined *)(frame + 5) = (char)(reason_code >> 8); + return 6; +} + + + +void me_extract_rate_set(uint32_t buffer,uint16_t buflen,mac_rateset *mac_rate_set_ptr) + +{ + byte bVar1; + byte bVar2; + int iVar3; + undefined2 in_register_0000202e; + uint uVar4; + uint8_t *puVar5; + uint uVar6; + + mac_rate_set_ptr->length = '\0'; + iVar3 = mac_ie_find(CONCAT22(in_register_0000202e,buflen),1); + if (iVar3 != 0) { + bVar1 = *(byte *)(iVar3 + 1); + uVar4 = (uint)bVar1; + if (bVar1 < 0xd) { + puVar5 = mac_rate_set_ptr->array; + while (uVar4 = uVar4 - 1, uVar4 != 0xffffffff) { + *puVar5 = (puVar5 + 1)[iVar3 - (int)mac_rate_set_ptr]; + puVar5 = puVar5 + 1; + } + mac_rate_set_ptr->length = bVar1; + iVar3 = mac_ie_find(buffer,CONCAT22(in_register_0000202e,buflen),0x32); + if (iVar3 != 0) { + bVar1 = *(byte *)(iVar3 + 1); + uVar4 = (uint)bVar1; + if (0xc < mac_rate_set_ptr->length + uVar4) { + assert_err("mac_rate_set_ptr->length + elmt_length <= MAC_RATESET_LEN","module",0x396); + } + bVar2 = mac_rate_set_ptr->length; + if (bVar2 + uVar4 < 0xd) { + uVar6 = 0; + while (uVar4 != uVar6) { + mac_rate_set_ptr->array[bVar2 + uVar6] = *(uint8_t *)(iVar3 + 2 + uVar6); + uVar6 = uVar6 + 1; + } + mac_rate_set_ptr->length = bVar1 + mac_rate_set_ptr->length; + } + } + } + } + return; +} + + + +void me_extract_power_constraint(uint32_t buffer,uint16_t buflen,mac_bss_info *bss) + +{ + int iVar1; + uint8_t uVar2; + + iVar1 = mac_ie_find(0x20); + uVar2 = '\0'; + if (iVar1 != 0) { + uVar2 = *(uint8_t *)(iVar1 + 2); + } + bss->power_constraint = uVar2; + return; +} + + + +void me_extract_country_reg(int param_1) + +{ + uint16_t *puVar1; + int iVar2; + uint uVar3; + byte *pbVar4; + uint uVar5; + byte bVar6; + uint uVar7; + int iVar8; + + iVar2 = mac_ie_find(7); + if (iVar2 != 0) { + puVar1 = *(uint16_t **)(param_1 + 0x4c); + iVar8 = 1; + if (*(uint8_t *)(puVar1 + 1) != '\0') { + iVar8 = 4; + } + uVar3 = phy_freq_to_channel(*(uint8_t *)(puVar1 + 1),*puVar1); + uVar7 = 5; + while (uVar7 <= (uint)*(byte *)(iVar2 + 1) + 1) { + pbVar4 = (byte *)(uVar7 + iVar2); + uVar5 = (uint)*pbVar4; + bVar6 = 0; + while (bVar6 != pbVar4[1]) { + if (uVar5 == (uVar3 & 0xff)) { + *(byte *)(puVar1 + 2) = pbVar4[2]; + return; + } + bVar6 = bVar6 + 1; + uVar5 = uVar5 + iVar8 & 0xff; + } + uVar7 = uVar7 + 3 & 0xff; + } + } + return; +} + + + +void me_extract_mobility_domain(uint32_t buffer,uint16_t buflen,mac_bss_info *bss) + +{ + int iVar1; + + iVar1 = mac_ie_find(0x36); + if (iVar1 == 0) { + (bss->mde).mdid = 0; + (bss->mde).ft_capability_policy = '\0'; + } + else { + (bss->mde).mdid = *(uint16_t *)(iVar1 + 2); + (bss->mde).ft_capability_policy = *(uint8_t *)(iVar1 + 4); + } + return; +} + + + +uint me_extract_csa(undefined4 param_1,undefined4 param_2,undefined *param_3,int param_4) + +{ + byte bVar1; + byte bVar2; + bool band; + short sVar3; + uint16_t uVar4; + uint16_t uVar5; + uint16_t uVar6; + uint uVar7; + uint uVar8; + int iVar9; + int iVar10; + undefined uVar11; + + uVar7 = mac_ie_find(0x25); + uVar8 = mac_ie_find(param_1,param_2,0x3c); + if ((uVar7 | uVar8) == 0) { + return 0; + } + iVar9 = mac_ie_find(param_1,param_2,0x3e); + iVar10 = mac_ie_find(param_1,param_2,0xc4); + if (iVar10 != 0) { + iVar10 = mac_ie_find(iVar10 + 2,(uint)*(byte *)(iVar10 + 1),0xc2); + } + if (uVar7 == 0) { + bVar1 = *(byte *)(uVar8 + 5); + *param_3 = *(undefined *)(uVar8 + 2); + bVar2 = *(byte *)(uVar8 + 4); + } + else { + bVar1 = *(byte *)(uVar7 + 4); + *param_3 = *(undefined *)(uVar7 + 2); + bVar2 = *(byte *)(uVar7 + 3); + } + uVar7 = (uint)bVar1; + if (bVar1 == 0) { + uVar7 = 2; + } + band = 0xe < bVar2; + uVar4 = phy_channel_to_freq(band,(uint)bVar2); + if (iVar10 != 0) { + uVar8 = (uint)*(byte *)(iVar10 + 2) - 1 & 0xff; + bVar1 = *(byte *)(iVar10 + 4); + uVar11 = 1; + if (uVar8 < 3) { + uVar11 = *(undefined *)((int)&CSWTCH_115 + uVar8); + } + uVar5 = phy_channel_to_freq(band,(uint)*(byte *)(iVar10 + 3)); + uVar6 = 0; + if (bVar1 != 0) { + uVar6 = phy_channel_to_freq(band,(uint)bVar1); + } + goto LAB_2301d564; + } + if (iVar9 == 0) { +LAB_2301d5c6: + uVar6 = 0; + uVar11 = 0; + uVar5 = uVar4; + } + else { + sVar3 = 10; + if (*(char *)(iVar9 + 2) != '\x01') { + if (*(char *)(iVar9 + 2) != '\x03') goto LAB_2301d5c6; + sVar3 = -10; + } + uVar6 = 0; + uVar11 = 1; + uVar5 = uVar4 + sVar3; + } +LAB_2301d564: + *(uint16_t *)(param_4 + 6) = uVar6; + *(bool *)param_4 = band; + *(undefined *)(param_4 + 1) = uVar11; + *(uint16_t *)(param_4 + 2) = uVar4; + *(uint16_t *)(param_4 + 4) = uVar5; + return uVar7; +} + + + +// WARNING: Could not reconcile some variable overlaps + +uint16_t me_build_beacon(uint32_t frame,uint8_t vif_idx,uint16_t *tim_oft,uint8_t *tim_len, + uint8_t hidden_ssid) + +{ + uint8_t enc_type; + short sVar1; + uint16_t uVar2; + uint32_t uVar3; + uint32_t uVar4; + uint32_t uVar5; + uint32_t uVar6; + uint8_t ssid_len; + undefined3 in_register_0000202d; + int iVar7; + uint8_t *p_ssid; + undefined3 in_register_00002039; + uint uVar8; + int iVar9; + undefined *puVar10; + mac_rateset *p_rateset; + uint32_t uStack68; + undefined2 uStack64; + undefined uStack62; + undefined uStack61; + uint8_t wme_ie [16]; + + iVar7 = CONCAT31(in_register_0000202d,vif_idx); + enc_type = vif_info_tab[iVar7].bss_info.sec_type; + *(undefined *)frame = 0x80; + *(undefined *)(frame + 1) = 0; + *(undefined *)(frame + 2) = 0; + *(undefined *)(frame + 3) = 0; + uStack68 = frame; + memcpy((void *)(frame + 4),&mac_addr_bcst,6); + memcpy((void *)(frame + 10),&vif_info_tab[iVar7].mac_addr,6); + memcpy((void *)(frame + 0x10),&vif_info_tab[iVar7].mac_addr,6); + uVar8 = (uint)txl_cntrl_env.seqnbr; + txl_cntrl_env.seqnbr = (uint16_t)((uVar8 + 1) * 0x10000 >> 0x10); + iVar9 = (uVar8 + 1) * 0x100000; + *(undefined *)(frame + 0x16) = (char)((uint)iVar9 >> 0x10); + *(undefined *)(frame + 0x17) = (char)((uint)iVar9 >> 0x18); + uVar2 = vif_info_tab[iVar7].bss_info.beacon_interval; + *(undefined *)(uStack68 + 0x20) = (char)uVar2; + *(undefined *)(uStack68 + 0x21) = (char)(uVar2 >> 8); + uVar2 = me_build_capability(vif_idx); + if (enc_type != '\0') { + uVar2 = uVar2 | 0x10; + } + p_ssid = vif_info_tab[iVar7].bss_info.ssid.array; + *(undefined *)(uStack68 + 0x22) = (char)uVar2; + *(undefined *)(uStack68 + 0x23) = (char)(uVar2 >> 8); + uStack68 = uStack68 + 0x24; + if (CONCAT31(in_register_00002039,hidden_ssid) == 0) { + ssid_len = vif_info_tab[iVar7].bss_info.ssid.length; + } + else { + printf("Using Hidden SSID [%s]\r\n",p_ssid); + p_ssid = (uint8_t *)0x0; + ssid_len = '\0'; + } + uVar3 = me_add_ie_ssid(&uStack68,ssid_len,p_ssid); + p_rateset = &vif_info_tab[iVar7].bss_info.rate_set; + uVar4 = me_add_ie_supp_rates(&uStack68,p_rateset); + uVar8 = (uVar3 + 0x24 & 0xffff) + uVar4 & 0xffff; + if (8 < vif_info_tab[iVar7].bss_info.rate_set.length) { + uVar3 = me_add_ie_ext_supp_rates(&uStack68,p_rateset); + uVar8 = uVar8 + uVar3 & 0xffff; + } + uVar3 = me_add_ie_ds(&uStack68, + (char)((int)((uint)(vif_info_tab[iVar7].bss_info.chan)->freq - 0x96c) / 5) + + '\x01'); + *tim_oft = (uint16_t)((uVar8 + uVar3) * 0x10000 >> 0x10); + uVar4 = me_add_ie_tim(&uStack68,*(uint8_t *)&vif_info_tab[iVar7].bss_info.beacon_period); + *tim_len = (uint8_t)(uVar4 & 0xff); + uVar5 = me_add_ie_rsn(&uStack68,enc_type); + memcpy(int_rsn_ie,(void *)(uStack68 - (uVar5 & 0xff)),uVar5 & 0xff); + uVar6 = me_add_ie_erp(&uStack68,'\0'); + sVar1 = (short)(uVar8 + uVar3) + (short)(uVar4 & 0xff) + (short)uVar6 + ((ushort)uVar5 & 0xff); + if ((vif_info_tab[iVar7].bss_info.valid_flags & 2) != 0) { + uVar3 = me_add_ie_ht_capa(&uStack68); + uVar4 = me_add_ie_ht_oper(&uStack68,vif_info_tab + iVar7); + sVar1 = sVar1 + (short)uVar4 + (short)uVar3; + } + uVar3 = me_add_ie_wpa(&uStack68,enc_type); + uVar2 = sVar1 + (short)uVar3; + if ((vif_info_tab[iVar7].bss_info.valid_flags & 1) != 0) { + memset(&uStack62,0,0xe); + uStack64 = 0x7dd; + uStack61 = 0x50; + wme_ie._0_2_ = 0x2f2; + wme_ie[3] = '\x01'; + wme_ie[4] = vif_info_tab[iVar7].bss_info.edca_param.qos_info; + co_pack8p(uStack68,(uint8_t *)&uStack64,9); + *(char *)(uStack68 + 1) = *(char *)(uStack68 + 1) + '\x11'; + puVar10 = (undefined *)(uStack68 + 2 + (uint)uStack64._1_1_); + *puVar10 = 0; + uVar3 = vif_info_tab[iVar7].txq_params[1]; + puVar10[1] = (char)uVar3; + puVar10[2] = (char)(uVar3 >> 8); + puVar10[3] = (char)(uVar3 >> 0x10); + puVar10[4] = (char)(uVar3 >> 0x18); + uVar3 = vif_info_tab[iVar7].txq_params[0]; + puVar10[5] = (char)uVar3; + puVar10[6] = (char)(uVar3 >> 8); + puVar10[7] = (char)(uVar3 >> 0x10); + puVar10[8] = (char)(uVar3 >> 0x18); + uVar3 = vif_info_tab[iVar7].txq_params[2]; + puVar10[9] = (char)uVar3; + puVar10[10] = (char)(uVar3 >> 8); + puVar10[0xb] = (char)(uVar3 >> 0x10); + puVar10[0xc] = (char)(uVar3 >> 0x18); + uVar3 = vif_info_tab[iVar7].txq_params[3]; + puVar10[0xd] = (char)uVar3; + puVar10[0xe] = (char)(uVar3 >> 8); + puVar10[0xf] = (char)(uVar3 >> 0x10); + puVar10[0x10] = (char)(uVar3 >> 0x18); + uVar2 = uVar2 + (ushort)uStack64._1_1_ + 0x13; + } + return uVar2; +} + + + +// WARNING: Variable defined which should be unmapped: wme_ie +// WARNING: Could not reconcile some variable overlaps + +uint16_t me_build_probe_rsp(uint32_t frame,uint8_t vif_idx) + +{ + uint8_t enc_type; + short sVar1; + uint16_t uVar2; + uint32_t uVar3; + uint32_t uVar4; + int iVar5; + uint32_t uVar6; + undefined3 in_register_0000202d; + int iVar7; + scan_chan_tag *psVar8; + undefined *puVar9; + mac_rateset *p_rateset; + uint32_t uStack52; + undefined2 uStack48; + undefined uStack46; + undefined uStack45; + uint8_t wme_ie [16]; + + iVar7 = CONCAT31(in_register_0000202d,vif_idx); + enc_type = vif_info_tab[iVar7].bss_info.sec_type; + uVar2 = vif_info_tab[iVar7].bss_info.beacon_interval; + *(undefined *)(frame + 8) = (char)uVar2; + *(undefined *)(frame + 9) = (char)(uVar2 >> 8); + uStack52 = frame; + uVar2 = me_build_capability(vif_idx); + if (enc_type != '\0') { + uVar2 = uVar2 | 0x10; + } + *(undefined *)(uStack52 + 10) = (char)uVar2; + *(undefined *)(uStack52 + 0xb) = (char)(uVar2 >> 8); + uStack52 = uStack52 + 0xc; + p_rateset = &vif_info_tab[iVar7].bss_info.rate_set; + uVar3 = me_add_ie_ssid(&uStack52,vif_info_tab[iVar7].bss_info.ssid.length, + vif_info_tab[iVar7].bss_info.ssid.array); + uVar4 = me_add_ie_supp_rates(&uStack52,p_rateset); + sVar1 = (short)uVar3 + (short)uVar4 + 0xc; + if (8 < vif_info_tab[iVar7].bss_info.rate_set.length) { + uVar3 = me_add_ie_ext_supp_rates(&uStack52,p_rateset); + sVar1 = sVar1 + (short)uVar3; + } + psVar8 = vif_info_tab[iVar7].bss_info.chan; + iVar5 = phy_freq_to_channel(psVar8->band,psVar8->freq); + uVar3 = me_add_ie_ds(&uStack52,(uint8_t)iVar5); + uVar4 = me_add_ie_rsn(&uStack52,enc_type); + uVar6 = me_add_ie_erp(&uStack52,'\0'); + sVar1 = sVar1 + (short)uVar4 + (short)uVar3 + (short)uVar6; + if ((vif_info_tab[iVar7].bss_info.valid_flags & 2) != 0) { + uVar3 = me_add_ie_ht_capa(&uStack52); + uVar4 = me_add_ie_ht_oper(&uStack52,vif_info_tab + iVar7); + sVar1 = sVar1 + (short)uVar4 + (short)uVar3; + } + uVar3 = me_add_ie_wpa(&uStack52,enc_type); + uVar2 = sVar1 + (short)uVar3; + if ((vif_info_tab[iVar7].bss_info.valid_flags & 1) != 0) { + memset(&uStack46,0,0xe); + uStack48 = 0x7dd; + uStack45 = 0x50; + wme_ie._0_2_ = 0x2f2; + wme_ie[3] = '\x01'; + wme_ie[4] = vif_info_tab[iVar7].bss_info.edca_param.qos_info; + co_pack8p(uStack52,(uint8_t *)&uStack48,9); + *(char *)(uStack52 + 1) = *(char *)(uStack52 + 1) + '\x11'; + puVar9 = (undefined *)(uStack52 + 2 + (uint)uStack48._1_1_); + *puVar9 = 0; + uVar3 = vif_info_tab[iVar7].txq_params[1]; + puVar9[1] = (char)uVar3; + puVar9[2] = (char)(uVar3 >> 8); + puVar9[3] = (char)(uVar3 >> 0x10); + puVar9[4] = (char)(uVar3 >> 0x18); + uVar3 = vif_info_tab[iVar7].txq_params[0]; + puVar9[5] = (char)uVar3; + puVar9[6] = (char)(uVar3 >> 8); + puVar9[7] = (char)(uVar3 >> 0x10); + puVar9[8] = (char)(uVar3 >> 0x18); + uVar3 = vif_info_tab[iVar7].txq_params[2]; + puVar9[9] = (char)uVar3; + puVar9[10] = (char)(uVar3 >> 8); + puVar9[0xb] = (char)(uVar3 >> 0x10); + puVar9[0xc] = (char)(uVar3 >> 0x18); + uVar3 = vif_info_tab[iVar7].txq_params[3]; + puVar9[0xd] = (char)uVar3; + puVar9[0xe] = (char)(uVar3 >> 8); + puVar9[0xf] = (char)(uVar3 >> 0x10); + puVar9[0x10] = (char)(uVar3 >> 0x18); + uVar2 = uVar2 + (ushort)uStack48._1_1_ + 0x13; + } + return uVar2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +uint16_t me_build_associate_rsp + (uint32_t frame,uint8_t vif_idx,uint16_t status_code,me_sta_add_req *req) + +{ + uint8_t uVar1; + ushort uVar2; + uint16_t uVar3; + uint32_t uVar4; + uint32_t uVar5; + undefined3 in_register_0000202d; + int iVar6; + undefined2 in_register_00002032; + undefined *puStack52; + undefined2 uStack48; + undefined uStack46; + undefined uStack45; + uint8_t wme_ie [16]; + + iVar6 = CONCAT31(in_register_0000202d,vif_idx); + uVar1 = vif_info_tab[iVar6].bss_info.sec_type; + puStack52 = (undefined *)frame; + uVar3 = me_build_capability(vif_idx); + if (uVar1 != '\0') { + uVar3 = uVar3 | 0x10; + } + *puStack52 = (char)uVar3; + puStack52[1] = (char)(uVar3 >> 8); + uVar3 = 6; + puStack52[2] = (char)status_code; + puStack52[3] = (char)(status_code >> 8); + uVar2 = req->aid; + puStack52[4] = (char)uVar2; + puStack52[5] = (byte)((uint)uVar2 >> 8) | 0xc0; + puStack52 = puStack52 + 6; + if (CONCAT22(in_register_00002032,status_code) == 0) { + uVar4 = me_add_ie_supp_rates((uint32_t *)&puStack52,&req->rate_set); + uVar3 = (short)uVar4 + 6; + if (8 < (req->rate_set).length) { + uVar4 = me_add_ie_ext_supp_rates((uint32_t *)&puStack52,&req->rate_set); + uVar3 = uVar3 + (short)uVar4; + } + if ((req->flags & 2) != 0) { + uVar4 = me_add_ie_ht_capa((uint32_t *)&puStack52); + uVar5 = me_add_ie_ht_oper((uint32_t *)&puStack52,vif_info_tab + iVar6); + uVar3 = uVar3 + (short)uVar5 + (short)uVar4; + } + if ((req->flags & 1) != 0) { + memset(&uStack46,0,0xe); + uStack48 = 0x7dd; + uStack45 = 0x50; + wme_ie._0_2_ = 0x2f2; + wme_ie[3] = '\x01'; + wme_ie[4] = vif_info_tab[iVar6].bss_info.edca_param.qos_info; + co_pack8p((uint32_t)puStack52,(uint8_t *)&uStack48,9); + puStack52[1] = puStack52[1] + '\x11'; + puStack52 = puStack52 + (uint)uStack48._1_1_ + 2; + *puStack52 = 0; + uVar4 = vif_info_tab[iVar6].txq_params[1]; + puStack52[1] = (char)uVar4; + puStack52[2] = (char)(uVar4 >> 8); + puStack52[3] = (char)(uVar4 >> 0x10); + puStack52[4] = (char)(uVar4 >> 0x18); + uVar4 = vif_info_tab[iVar6].txq_params[0]; + puStack52[5] = (char)uVar4; + puStack52[6] = (char)(uVar4 >> 8); + puStack52[7] = (char)(uVar4 >> 0x10); + puStack52[8] = (char)(uVar4 >> 0x18); + uVar4 = vif_info_tab[iVar6].txq_params[2]; + puStack52[9] = (char)uVar4; + puStack52[10] = (char)(uVar4 >> 8); + puStack52[0xb] = (char)(uVar4 >> 0x10); + puStack52[0xc] = (char)(uVar4 >> 0x18); + uVar4 = vif_info_tab[iVar6].txq_params[3]; + puStack52[0xd] = (char)uVar4; + puStack52[0xe] = (char)(uVar4 >> 8); + puStack52[0xf] = (char)(uVar4 >> 0x10); + puStack52[0x10] = (char)(uVar4 >> 0x18); + uVar3 = uVar3 + (ushort)uStack48._1_1_ + 0x13; + } + } + return uVar3; +} + + + +int me_rc_set_rate_req_handler + (ke_msg_id_t msgid,me_rc_set_rate_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + byte bVar1; + uint16_t fixed_rate_config; + rc_sta_stats *rc_ss; + _Bool _Var2; + undefined3 extraout_var; + + bVar1 = param->sta_idx; + rc_ss = sta_info_tab[bVar1].pol_tbl.sta_stats; + if (rc_ss == (rc_sta_stats *)0x0) { + assert_err("rc_ss != NULL","module",0x31d); + } + fixed_rate_config = param->fixed_rate_cfg; + if (fixed_rate_config == 0xffff) { + rc_ss->fixed_rate_cfg = 0xffff; + rc_ss->info = rc_ss->info & 0x9f; + rc_update_bw_nss_max(sta_info_tab[bVar1].staid,rc_ss->bw_max,rc_ss->no_ss); + } + else { + _Var2 = rc_check_fixed_rate_config(rc_ss,fixed_rate_config); + if (CONCAT31(extraout_var,_Var2) != 0) { + rc_ss->fixed_rate_cfg = fixed_rate_config; + rc_ss->info = rc_ss->info & 0x9f | 0x20; + } + } + return 0; +} + + + +int me_rc_stats_req_handler + (ke_msg_id_t msgid,me_rc_stats_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + rc_sta_stats *rc_ss; + byte *pbVar1; + uint32_t uVar2; + uint uVar3; + + pbVar1 = (byte *)ke_msg_alloc(0x140f,src_id,dest_id,0xd0); + rc_ss = sta_info_tab[param->sta_idx].pol_tbl.sta_stats; + *pbVar1 = param->sta_idx; + if (rc_ss == (rc_sta_stats *)0x0) { + *(undefined2 *)(pbVar1 + 2) = 0; + } + else { + *(uint16_t *)(pbVar1 + 2) = rc_ss->no_samples; + uVar3 = 0; + *(uint16_t *)(pbVar1 + 4) = rc_ss->ampdu_len; + *(uint16_t *)(pbVar1 + 6) = rc_ss->ampdu_packets; + *(uint32_t *)(pbVar1 + 8) = rc_ss->avg_ampdu_len; + pbVar1[0xc] = rc_ss->sw_retry_step; + pbVar1[0xd] = rc_ss->sample_wait; + memcpy(pbVar1 + 0x10,rc_ss->retry,0x20); + memcpy(pbVar1 + 0x30,rc_ss->rate_stats,0x78); + while (uVar3 < rc_ss->no_samples) { + uVar2 = rc_calc_tp(rc_ss,(uint8_t)uVar3); + *(uint32_t *)(pbVar1 + (uVar3 + 0x28) * 4 + 8) = uVar2; + uVar3 = uVar3 + 1 & 0xffff; + } + } + ke_msg_send(pbVar1); + return 0; +} + + + +int me_traffic_ind_req_handler + (ke_msg_id_t msgid,me_traffic_ind_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint uVar1; + uint16_t *puVar2; + sta_ps_traffic sVar3; + sta_ps_traffic sVar4; + + uVar1 = (uint)param->sta_idx; + sVar4 = sta_info_tab[uVar1].traffic_avail; + if (param->uapsd == false) { + if (param->tx_avail == '\0') { + sVar4 = sVar4 & ~PS_TRAFFIC_HOST; + } + else { + sVar4 = sVar4 | PS_TRAFFIC_HOST; + } + sta_info_tab[uVar1].traffic_avail = sVar4; + } + else { + sVar3 = sVar4 & ~UAPSD_TRAFFIC_HOST; + if (param->tx_avail != '\0') { + sVar3 = sVar4 | UAPSD_TRAFFIC_HOST; + } + sta_info_tab[uVar1].traffic_avail = sVar3; + if (sta_info_tab[uVar1].info.uapsd_queues != '\x0f') goto LAB_2301df24; + } + puVar2 = (uint16_t *)ke_msg_alloc(0x41,0,5,4); + *puVar2 = sta_info_tab[uVar1].aid; + *(uint8_t *)((int)puVar2 + 3) = sta_info_tab[uVar1].inst_nbr; + *(uint8_t *)(puVar2 + 1) = param->tx_avail; + ke_msg_send(); +LAB_2301df24: + ke_msg_send_basic(0x140d,src_id,dest_id); + return 0; +} + + + +int me_sta_del_req_handler + (ke_msg_id_t msgid,me_sta_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t *puVar1; + undefined *puVar2; + + puVar1 = (uint8_t *)ke_msg_alloc(0xc,0,5,1); + *puVar1 = param->sta_idx; + ke_msg_send(); + if (param->tdls_sta != false) { + puVar2 = (undefined *)ke_msg_alloc(0x1413,5,6,2); + *puVar2 = 0; + puVar2[1] = sta_info_tab[param->sta_idx].inst_nbr; + ke_msg_send(); + } + ke_msg_send_basic(0x140a,src_id,dest_id); + return 0; +} + + + +int me_set_control_port_req_handler + (ke_msg_id_t msgid,me_set_control_port_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + byte bVar1; + undefined *puVar2; + uint8_t uVar3; + uint uVar4; + + uVar4 = (uint)param->sta_idx; + bVar1 = sta_info_tab[uVar4].inst_nbr; + uVar3 = (param->control_port_open != false) + '\x01'; + sta_info_tab[uVar4].ctrl_port_state = uVar3; + if ((vif_info_tab[bVar1].type == '\0') && (uVar3 == '\x02')) { + puVar2 = (undefined *)ke_msg_alloc(0x1413,5,6,2); + *puVar2 = 0; + puVar2[1] = sta_info_tab[uVar4].inst_nbr; + ke_msg_send(); + } + ke_msg_send_basic(0x1405,src_id,dest_id); + return 0; +} + + + +int me_chan_config_req_handler + (ke_msg_id_t msgid,me_chan_config_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + memcpy(&me_env.chan,param,0xfe); + ke_msg_send_basic(0x1403,src_id,dest_id); + return 0; +} + + + +int mm_set_ps_mode_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(dest_id); + if (CONCAT22(extraout_var,kVar1) != 1) { + assert_err("ke_state_get(dest_id) == ME_BUSY","module",699); + } + if (me_env.requester_id != 0xff) { + ke_msg_send_basic(0x1414,me_env.requester_id,dest_id); + } + ke_state_set(dest_id,0); + return 0; +} + + + +int mm_set_idle_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(dest_id); + if (CONCAT22(extraout_var,kVar1) != 1) { + assert_err("ke_state_get(dest_id) == ME_BUSY","module",0x252); + } + if (me_env.requester_id != 0xff) { + ke_msg_send_basic(0x1412,me_env.requester_id,dest_id); + } + ke_state_set(dest_id,0); + return 0; +} + + + +int me_config_req_handler + (ke_msg_id_t msgid,me_config_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t uVar1; + undefined *puVar2; + undefined3 extraout_var; + + puVar2 = (undefined *)ke_msg_alloc(0x31,0,5,1); + me_env.ht_supported = param->ht_supp; + memcpy(&me_env.ht_cap,param,0x20); + ke_msg_send_basic(0x1401,src_id,dest_id); + if (me_env.ht_supported == false) { + me_env._302_2_ = 0; + } + else { + uVar1 = phy_get_nss(); + me_env._302_2_ = + CONCAT11((char)(me_env.ht_cap.ht_capa_info >> 1), + (char)(CONCAT31(extraout_var,uVar1) + 1 >> 1)) & 0x1ff; + } + me_env.tx_lft = param->tx_lft; + me_env.ps_on = param->ps_on; + if (me_env.ps_on != false) { + me_env.requester_id = 0xff; + *puVar2 = 2; + ke_msg_send(puVar2); + ke_state_set(5,1); + } + return 0; +} + + + +int me_set_ps_disable_req_handler + (ke_msg_id_t msgid,me_set_ps_disable_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + char *pcVar2; + + if (me_env.ps_on != false) { + kVar1 = ke_state_get(5); + if (CONCAT22(extraout_var,kVar1) == 1) { + return 2; + } + if (me_env.ps_disable_vifs == 0) { + if (param->ps_disable != false) goto LAB_2301e26a; + } + else { + if (param->ps_disable == false) { +LAB_2301e26a: + pcVar2 = (char *)ke_msg_alloc(0x31,0,dest_id,1); + if (param->ps_disable == false) { + me_env.ps_disable_vifs = ~(1 << ((uint)param->vif_idx & 0x1f)) & me_env.ps_disable_vifs; + } + else { + me_env.ps_disable_vifs = 1 << ((uint)param->vif_idx & 0x1f) | me_env.ps_disable_vifs; + } + me_env.requester_id = src_id; + *pcVar2 = (me_env.ps_disable_vifs == 0) << 1; + ke_msg_send(); + ke_state_set(dest_id,1); + return 0; + } + me_env.ps_disable_vifs = 1 << ((uint)param->vif_idx & 0x1f) | me_env.ps_disable_vifs; + } + } + ke_msg_send_basic(0x1414,src_id,dest_id); + return 0; +} + + + +int me_set_active_req_handler + (ke_msg_id_t msgid,me_set_active_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + void *pvVar2; + + kVar1 = ke_state_get(5); + if (CONCAT22(extraout_var,kVar1) == 1) { + return 2; + } + if (me_env.active_vifs == 0) { + if (param->active != false) goto LAB_2301e304; + } + else { + if (param->active == false) { +LAB_2301e304: + pvVar2 = ke_msg_alloc(0x22,0,dest_id,1); + if (param->active == false) { + me_env.active_vifs = ~(1 << ((uint)param->vif_idx & 0x1f)) & me_env.active_vifs; + } + else { + me_env.active_vifs = 1 << ((uint)param->vif_idx & 0x1f) | me_env.active_vifs; + } + me_env.requester_id = src_id; + *(bool *)pvVar2 = me_env.active_vifs == 0; + ke_msg_send(); + ke_state_set(dest_id,1); + return 0; + } + me_env.active_vifs = 1 << ((uint)param->vif_idx & 0x1f) | me_env.active_vifs; + } + ke_msg_send_basic(0x1412,src_id,dest_id); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int me_sta_add_req_handler + (ke_msg_id_t msgid,me_sta_add_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + byte bVar1; + byte bVar2; + _Bool _Var3; + byte *sta_idx; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined *puVar4; + undefined3 extraout_var_01; + uint uVar5; + uint uVar6; + uint uVar7; + int iVar8; + uint8_t uStack81; + uint8_t hw_sta_idx; + uint32_t uStack80; + mm_sta_add_req sta_add_req; + + sta_idx = (byte *)ke_msg_alloc(0x1408,src_id,dest_id,3); + bVar1 = rxu_cntrl_get_pm(); + sta_add_req.mac_addr.array[1]._1_1_ = param->vif_idx; + uVar7 = (uint)sta_add_req.mac_addr.array[1]._1_1_; + if ((param->flags & 2) == 0) { + sta_add_req.mac_addr.array[1]._0_1_ = '\0'; + sta_add_req.paid_gid._0_2_ = 0; + } + else { + uVar5 = (uint)(param->ht_cap).a_mpdu_param; + sta_add_req.mac_addr.array[1]._0_1_ = '\x01'; + uVar6 = (int)uVar5 >> 2 & 7; + if (2 < uVar6) { + sta_add_req.mac_addr.array[1]._0_1_ = (uint8_t)(1 << (uVar6 - 3 & 0x1f)); + } + sta_add_req.paid_gid._0_2_ = (short)(1 << (uVar5 & 3) + 0xd) - 1; + } + sta_add_req.ampdu_size_max_vht = 0; + memcpy((void *)((int)&sta_add_req.paid_gid + 2),param,6); + sta_add_req.mac_addr.array[2]._1_1_ = param->rssi; + sta_add_req._16_4_ = param->tsflo; + sta_add_req.tsflo = param->tsfhi; + uStack80 = 0; + sta_add_req.tsfhi._0_1_ = param->data_rate; + bVar2 = mm_sta_add((mm_sta_add_req *)&stack0xffffffb0,sta_idx,&uStack81); + sta_idx[1] = bVar2; + if (CONCAT31(extraout_var_00,bVar2) != 0) goto LAB_2301e56a; + uVar5 = (uint)*sta_idx; + memcpy(&sta_info_tab[uVar5].info,¶m->rate_set,0xd); + if ((param->flags & 1) == 0) { +LAB_2301e46c: + iVar8 = 0; + } + else { + uVar6 = sta_info_tab[uVar5].info.capa_flags; + sta_info_tab[uVar5].info.capa_flags = uVar6 | 1; + if (((param->flags & 2) == 0) || (me_env.ht_supported == false)) goto LAB_2301e46c; + sta_info_tab[uVar5].info.capa_flags = uVar6 | 3; + memcpy(&sta_info_tab[uVar5].info.ht_cap,¶m->ht_cap,0x20); + _Var3 = me_set_sta_ht_vht_param(sta_info_tab + uVar5,&vif_info_tab[uVar7].bss_info); + iVar8 = CONCAT31(extraout_var_01,_Var3); + } + sta_info_tab[uVar5].info.uapsd_queues = param->uapsd_queues; + sta_info_tab[uVar5].info.max_sp_len = param->max_sp_len; + sta_info_tab[uVar5].aid = param->aid; + me_init_rate(sta_info_tab + uVar5); + if (((param->flags & 0x10) != 0) && (bVar2 = param->opmode, -1 < (char)bVar2)) { + me_sta_bw_nss_max_upd(sta_info_tab[uVar5].staid,bVar2 & 3,bVar2 >> 4); + } + if (iVar8 != 0) { + me_sta_bw_nss_max_upd(sta_info_tab[uVar5].staid,-1,'\0'); + } + sta_info_tab[uVar5].pol_tbl.upd_field = sta_info_tab[uVar5].pol_tbl.upd_field | 0x10; + sta_info_tab[uVar5].ctrl_port_state = ((vif_info_tab[uVar7].flags & 1) == 0) + '\x01'; + sta_info_tab[uVar5].ctrl_port_ethertype = + *(ushort *)(vif_info_tab[uVar7].u + 0x2f0) >> 8 | + *(ushort *)(vif_info_tab[uVar7].u + 0x2f0) << 8; + sta_idx[2] = bVar1; + if (CONCAT31(extraout_var,bVar1) != 0) { + sta_info_tab[uVar5].ps_state = bVar1; + if (vif_info_tab[uVar7].u[0x2ee] == 0) { + uVar5 = (uint)vif_info_tab[uVar7].index + 10 & 0xff; + puVar4 = (undefined *)ke_msg_alloc(0x49,0xd,0,2); + sta_info_tab[uVar5].ps_state = '\x01'; + *puVar4 = (char)uVar5; + puVar4[1] = 1; + ke_msg_send(); + } + vif_info_tab[uVar7].u[0x2ee] = vif_info_tab[uVar7].u[0x2ee] + 1; + } +LAB_2301e56a: + ke_msg_send(sta_idx); + return 0; +} + + + +void cfm_raw_send(void *env,uint32_t status) + +{ + printf("send complete, status is %08lX\r\n"); + return; +} + + + +int scanu_raw_send_req_handler + (ke_msg_id_t msgid,scanu_raw_send_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + size_t __n; + txl_frame_desc_tag *frame; + tx_hw_desc *ptVar1; + void *__src; + + printf("[FW] pkt address is %p, len is %lu\r\n",param->pkt,param->len); + scanu_raw_send_cfm('\0',src_id); + __src = param->pkt; + __n = param->len; + frame = txl_frame_get(0,0x100); + if (frame != (txl_frame_desc_tag *)0x0) { + memcpy((frame->txdesc).lmac.buffer + 1,__src,__n); + (frame->txdesc).host.staid = -1; + (frame->cfm).cfm_func = cfm_raw_send; + ptVar1 = (frame->txdesc).lmac.hw_desc; + (frame->txdesc).host.vif_idx = '\0'; + (frame->txdesc).umac.head_len = '\0'; + (frame->txdesc).umac.tail_len = '\0'; + *(txl_frame_desc_tag **)&(frame->cfm).env = frame; + (ptVar1->thd).field_5 = (ptVar1->thd).field_4 + (__n - 1); + (ptVar1->thd).frmlen = __n + 4; + txl_frame_push_force(frame,'\x03'); + } + return 0; +} + + + +int scanu_join_req_handler + (ke_msg_id_t msgid,scanu_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + vif_info_tab[param->vif_idx].bss_info.valid_flags = 0; + scanu_env._362_2_ = 1; + scanu_env.bssid.array._0_4_ = *(undefined4 *)(param->bssid).array; + scanu_env.bssid.array[2] = (param->bssid).array[2]; + scanu_env.param = param; + scanu_env.src_id = src_id; + if ((*(byte *)(param->bssid).array & 1) != 0) { + assert_err("!MAC_ADDR_GROUP(¶m->bssid)","module",0xb6); + } + scanu_start(); + return 1; +} + + + +int scanu_start_req_handler + (ke_msg_id_t msgid,scanu_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined2 in_register_0000202a; + + scanu_env._362_2_ = 0; + scanu_env.bssid.array._0_4_ = *(undefined4 *)(param->bssid).array; + scanu_env.bssid.array[2] = (param->bssid).array[2]; + scanu_env.param = param; + scanu_env.src_id = src_id; + scanu_start(CONCAT22(in_register_0000202a,msgid)); + return 1; +} + + + +int rxu_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + int iVar1; + + iVar1 = scanu_frame_handler(param); + return iVar1; +} + + + +int scan_done_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined2 in_register_0000202a; + + scanu_env.band = scanu_env.band + '\x01'; + scanu_scan_next(CONCAT22(in_register_0000202a,msgid)); + return 0; +} + + + +int scan_start_cfm_handler + (ke_msg_id_t msgid,scan_start_cfm *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + if (param->status != '\0') { + scanu_confirm(param->status); + return 0; + } + return 0; +} + + + +int me_set_ps_disable_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined2 extraout_var_02; + + kVar1 = ke_state_get(6); + if (((CONCAT22(extraout_var,kVar1) != 4) && + (kVar1 = ke_state_get(6), CONCAT22(extraout_var_00,kVar1) != 0)) && + (kVar1 = ke_state_get(6), CONCAT22(extraout_var_01,kVar1) != 8)) { + assert_err( + "(ke_state_get(TASK_SM) == SM_BSS_PARAM_SETTING) || (ke_state_get(TASK_SM) == SM_IDLE) || (ke_state_get(TASK_SM) == SM_DISCONNECTING)" + ,"module",0x1db); + } + kVar1 = ke_state_get(6); + if (CONCAT22(extraout_var_02,kVar1) == 4) { + sm_send_next_bss_param(); + } + return 0; +} + + + +int mm_bss_param_setting_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(6); + if (CONCAT22(extraout_var,kVar1) != 4) { + assert_err("ke_state_get(TASK_SM) == SM_BSS_PARAM_SETTING","module",0x1fa); + } + sm_send_next_bss_param(); + return 0; +} + + + +int sm_rsp_timeout_ind_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + undefined2 extraout_var_00; + + kVar1 = ke_state_get(6); + if ((CONCAT22(extraout_var,kVar1) == 5) || + (kVar1 = ke_state_get(6), CONCAT22(extraout_var_00,kVar1) == 6)) { + sm_connect_ind(0xb); + } + return 0; +} + + + +int scanu_start_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + mac_addr *pmStack24; + mac_addr *bssid; + scan_chan_tag *chan; + + pmStack24 = (mac_addr *)0x0; + bssid = (mac_addr *)0x0; + kVar1 = ke_state_get(6); + if (CONCAT22(extraout_var,kVar1) != 1) { + assert_err("ke_state_get(TASK_SM) == SM_SCANNING","module",0x10a); + } + sm_get_bss_params(&pmStack24,(scan_chan_tag **)&bssid); + if ((pmStack24 == (mac_addr *)0x0) || ((scan_chan_tag *)bssid == (scan_chan_tag *)0x0)) { + sm_connect_ind(0xc); + } + else { + sm_join_bss(pmStack24,(scan_chan_tag *)bssid,false); + } + return 0; +} + + + +int mm_connection_loss_ind_handler + (ke_msg_id_t msgid,mm_connection_loss_ind *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + int iVar1; + ke_state_t kVar2; + undefined2 extraout_var; + uint uVar3; + + uVar3 = (uint)param->inst_nbr; + kVar2 = ke_state_get(6); + iVar1 = 2; + if (CONCAT22(extraout_var,kVar2) == 0) { + iVar1 = 0; + if ((vif_info_tab[uVar3].type == '\0') && (vif_info_tab[uVar3].active != false)) { + ke_state_set(6,8); + sm_disconnect_process(vif_info_tab + uVar3,0x10); + } + } + return iVar1; +} + + + +int scanu_join_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + sm_connect_req *psVar1; + uint8_t uVar2; + ke_state_t kVar3; + undefined2 extraout_var_00; + undefined3 extraout_var; + void *pvVar4; + undefined uVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint8_t auStack33 [4]; + uint8_t chan_idx; + + psVar1 = sm_env.connect_param; + kVar3 = ke_state_get(6); + if (CONCAT22(extraout_var_00,kVar3) != 2) { + assert_err("ke_state_get(TASK_SM) == SM_JOINING","module",0x134); + } + uVar8 = (uint)psVar1->vif_idx; + if ((int)vif_info_tab[uVar8].bss_info.valid_flags < 0) { + uVar2 = sm_add_chan_ctx(auStack33); + if (CONCAT31(extraout_var,uVar2) == 0) { + pvVar4 = ke_msg_alloc(10,0,6,0x20); + chan_ctxt_link(psVar1->vif_idx,auStack33[0]); + *(uint8_t *)((int)pvVar4 + 0x11) = psVar1->vif_idx; + memcpy((void *)((int)pvVar4 + 10),&vif_info_tab[uVar8].bss_info.bssid,6); + *(undefined *)((int)pvVar4 + 0x12) = 0; + if ((vif_info_tab[uVar8].bss_info.valid_flags & 2) != 0) { + uVar6 = (uint)vif_info_tab[uVar8].bss_info.ht_cap.a_mpdu_param; + uVar5 = 1; + uVar7 = (int)uVar6 >> 2 & 7; + if (2 < uVar7) { + uVar5 = (undefined)(1 << (uVar7 - 3 & 0x1f)); + } + *(undefined *)((int)pvVar4 + 0x10) = uVar5; + *(short *)((int)pvVar4 + 8) = (short)(1 << (uVar6 & 3) + 0xd) + -1; + } + *(undefined4 *)((int)pvVar4 + 4) = 0; + ke_msg_send(pvVar4); + ke_state_set(6,3); + } + else { + sm_connect_ind(0xd); + } + vif_info_tab[uVar8].flags = psVar1->flags; + if ((psVar1->flags & 4) != 0) { + vif_info_tab[uVar8].bss_info.valid_flags = + vif_info_tab[uVar8].bss_info.valid_flags & 0xfffffff9; + } + } + else { + if (sm_env.join_passive == false) { + sm_connect_ind(0xe); + } + else { + sm_join_bss(&vif_info_tab[uVar8].bss_info.bssid,vif_info_tab[uVar8].bss_info.chan,true); + } + } + return 0; +} + + + +// WARNING: Variable defined which should be unmapped: chan + +int sm_connect_req_handler + (ke_msg_id_t msgid,sm_connect_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + int iVar1; + ke_state_t kVar2; + undefined2 extraout_var; + undefined *puVar3; + undefined2 extraout_var_00; + undefined uVar4; + uint uVar5; + mac_addr *pmStack40; + mac_addr *bssid; + scan_chan_tag *chan; + + pmStack40 = (mac_addr *)0x0; + bssid = (mac_addr *)0x0; + uVar5 = (uint)param->vif_idx; + kVar2 = ke_state_get(6); + if (CONCAT22(extraout_var,kVar2) == 8) { + return 2; + } + puVar3 = (undefined *)ke_msg_alloc(0x1801,src_id,dest_id,1); + kVar2 = ke_state_get(6); + if (CONCAT22(extraout_var_00,kVar2) == 0) { + if ((vif_info_tab[uVar5].type == '\0') && (vif_info_tab[uVar5].active == false)) { + if (param->auth_type != '\x02') { + if (vif_info_tab[uVar5].u[4] != 0xff) { + assert_err("vif->u.sta.ap_id == INVALID_STA_IDX","module",0x59); + } + if (vif_info_tab[uVar5].chan_ctxt != (chan_ctxt_tag *)0x0) { + assert_err("vif->chan_ctxt == NULL","module",0x5a); + } + } + } + else { + if (param->auth_type != '\x02') { + iVar1 = 0; + uVar4 = 9; + goto LAB_2301eb3e; + } + } + if (sm_env.connect_param != (sm_connect_req *)0x0) { + assert_err("NULL == sm_env.connect_param","module",0x5d); + } + sm_env.connect_param = param; + if (sm_env.connect_ind != (sm_connect_ind *)0x0) { + assert_err("NULL == sm_env.connect_ind","module",0x61); + } + sm_env.connect_ind = (sm_connect_ind *)ke_msg_alloc(0x1802,src_id,dest_id,0x354); + sm_env.exist_ssid_idx = -1; + sm_env.ft_over_ds = false; + printf("connecting using vif_idx %u\r\n",(uint)param->vif_idx); + if (param->auth_type == '\x02') { + sm_env.ft_over_ds = true; + memcpy(&sm_env.ft_old_bssid,&vif_info_tab[param->vif_idx].bssid,6); + ke_state_set(6,8); + sm_disconnect_process(vif_info_tab + param->vif_idx,0); + } + else { + if ((param->chan).freq == 0xffff) { + sm_get_bss_params(&pmStack40,(scan_chan_tag **)&bssid); + } + else { + pmStack40 = ¶m->bssid; + bssid = (mac_addr *)¶m->chan; + } + if ((pmStack40 == (mac_addr *)0x0) || ((scan_chan_tag *)bssid == (scan_chan_tag *)0x0)) { + sm_scan_bss(pmStack40,(scan_chan_tag *)bssid); + } + else { + sm_join_bss(pmStack40,(scan_chan_tag *)bssid,false); + } + } + iVar1 = 1; + uVar4 = 0; + } + else { + iVar1 = 0; + uVar4 = 8; + } +LAB_2301eb3e: + *puVar3 = uVar4; + ke_msg_send(puVar3); + return iVar1; +} + + + +int rxu_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + int iVar2; + ushort uVar3; + + uVar3 = param->framectrl & 0xfc; + if (uVar3 == 0xb0) { + kVar1 = ke_state_get(6); + if (CONCAT22(extraout_var,kVar1) == 5) { + sm_auth_handler(param); + } + } + else { + if ((uVar3 == 0x10) || (uVar3 == 0x30)) { + kVar1 = ke_state_get(6); + if (CONCAT22(extraout_var_00,kVar1) == 6) { + sm_assoc_rsp_handler(param); + } + } + else { + if (((uVar3 == 0xc0) || (uVar3 == 0xa0)) && + (kVar1 = ke_state_get(6), CONCAT22(extraout_var_01,kVar1) == 0)) { + iVar2 = sm_deauth_handler(param); + return iVar2; + } + } + } + return 0; +} + + + +int mm_set_vif_state_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + byte bVar1; + sm_connect_req *psVar2; + ke_state_t kVar3; + undefined2 extraout_var; + uint8_t *puVar4; + undefined *puVar5; + uint8_t uVar6; + uint uVar7; + + kVar3 = ke_state_get(6); + psVar2 = sm_env.connect_param; + if (CONCAT22(extraout_var,kVar3) == 7) { + uVar7 = (uint)(sm_env.connect_param)->vif_idx; + bVar1 = vif_info_tab[uVar7].u[4]; + puVar4 = (uint8_t *)ke_msg_alloc(0x4b,0,6,6); + *(_Bool *)(puVar4 + 4) = psVar2->dont_wait_bcmc; + *(uint16_t *)(puVar4 + 2) = psVar2->listen_interval; + *puVar4 = psVar2->vif_idx; + ke_msg_send(); + uVar6 = ((vif_info_tab[uVar7].flags & 1) == 0) + '\x01'; + sta_info_tab[bVar1].ctrl_port_state = uVar6; + sta_info_tab[bVar1].ctrl_port_ethertype = + psVar2->ctrl_port_ethertype >> 8 | psVar2->ctrl_port_ethertype << 8; + if (uVar6 == '\x02') { + puVar5 = (undefined *)ke_msg_alloc(0x1413,5,6,2); + *puVar5 = 0; + puVar5[1] = psVar2->vif_idx; + ke_msg_send(); + } + if ((*(uint *)&vif_info_tab[uVar7].bss_info.is_supplicant_enabled & 0x12800) == 0) { + sm_connect_ind(0); + } + } + return 0; +} + + + +int me_set_active_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + mac_addr *pmStack24; + mac_addr *bssid; + scan_chan_tag *chan; + + kVar1 = ke_state_get(6); + if ((CONCAT22(extraout_var,kVar1) != 4) && + (kVar1 = ke_state_get(6), CONCAT22(extraout_var_00,kVar1) != 8)) { + assert_err( + "(ke_state_get(TASK_SM) == SM_BSS_PARAM_SETTING) || (ke_state_get(TASK_SM) == SM_DISCONNECTING)" + ,"module",0x216); + } + kVar1 = ke_state_get(6); + if (CONCAT22(extraout_var_01,kVar1) == 8) { + if (sm_env.ft_over_ds == false) { + ke_state_set(6,0); + } + else { + pmStack24 = (mac_addr *)0x0; + bssid = (mac_addr *)0x0; + sm_get_bss_params(&pmStack24,(scan_chan_tag **)&bssid); + sm_join_bss(pmStack24,(scan_chan_tag *)bssid,false); + } + } + else { + if (sm_env.ft_over_ds == false) { + sm_auth_send(1,(uint32_t *)0x0); + } + else { + sm_assoc_req_send(); + } + } + return 0; +} + + + +int mm_sta_add_cfm_handler + (ke_msg_id_t msgid,mm_sta_add_cfm *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint uVar1; + ke_state_t kVar2; + undefined2 extraout_var; + uint uVar3; + uint uVar4; + + kVar2 = ke_state_get(6); + if (CONCAT22(extraout_var,kVar2) != 3) { + assert_err("ke_state_get(TASK_SM) == SM_STA_ADDING","module",0x19c); + } + if (param->status == '\0') { + uVar4 = (uint)param->sta_idx; + uVar1 = (uint)sta_info_tab[uVar4].inst_nbr; + memcpy(&sta_info_tab[uVar4].info,&vif_info_tab[uVar1].bss_info.rate_set,0xd); + uVar3 = vif_info_tab[uVar1].bss_info.valid_flags; + if ((uVar3 & 1) != 0) { + sta_info_tab[uVar4].info.capa_flags = sta_info_tab[uVar4].info.capa_flags | 1; + } + if ((uVar3 & 2) != 0) { + sta_info_tab[uVar4].info.capa_flags = sta_info_tab[uVar4].info.capa_flags | 2; + memcpy(&sta_info_tab[uVar4].info.ht_cap,&vif_info_tab[uVar1].bss_info,0x20); + me_set_sta_ht_vht_param(sta_info_tab + uVar4,&vif_info_tab[uVar1].bss_info); + } + sm_set_bss_param(); + } + else { + sm_connect_ind(0xf); + } + return 0; +} + + + +int sm_disconnect_req_handler + (ke_msg_id_t msgid,sm_disconnect_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + int iVar2; + + kVar1 = ke_state_get(6); + iVar2 = 2; + if (CONCAT22(extraout_var,kVar1) == 0) { + sm_disconnect(param->vif_idx,param->reason_code); + ke_msg_send_basic(0x1804,0xd,6); + iVar2 = 0; + } + return iVar2; +} + + + +int apm_sta_connect_timeout_ind_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t sta_idx; + sta_info_tag *psVar1; + TickType_t TVar2; + + TVar2 = xTaskGetTickCount(); + psVar1 = sta_info_tab; + sta_idx = '\0'; + do { + if ((psVar1->time_last_seen != 0) && (30000 < (int)(TVar2 - psVar1->time_last_seen))) { + apm_sta_fw_delete(sta_idx); + } + sta_idx = sta_idx + '\x01'; + psVar1 = psVar1 + 1; + } while (sta_idx != '\f'); + ke_timer_set(0x1c0a,7,5000000); + return 0; +} + + + +int rxu_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + undefined4 uVar1; + ushort uVar2; + + uVar2 = param->framectrl & 0xfc; + if (uVar2 == 0x40) { + apm_probe_req_handler(); + } + else { + if (uVar2 == 0xb0) { + apm_auth_handler(param); + } + else { + uVar1 = 0; + if ((param->framectrl & 0xfc) != 0) { + if (uVar2 != 0x20) { + if (uVar2 == 0xc0) { + apm_deauth_handler(param); + return 0; + } + if (uVar2 == 0xa0) { + apm_disassoc_handler(param); + return 0; + } + if (uVar2 != 0x80) { + return 0; + } + apm_beacon_handler(param); + return 0; + } + uVar1 = 1; + } + apm_assoc_req_handler(uVar1); + } + } + return 0; +} + + + +int apm_sta_add_cfm_handler + (ke_msg_id_t msgid,me_sta_add_cfm *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + if (uap_conn_info == (cm_ConnectionInfo_t *)0x0) { + apm_sta_add(param->sta_idx); + } + else { + uap_conn_info->staId = param->sta_idx; + SendEAPOLMsgUsingBufDesc(uap_conn_info,(BufferDesc_t *)0x0); + } + return 0; +} + + + +int apm_sta_del_req_handler + (ke_msg_id_t msgid,apm_sta_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *puVar1; + + puVar1 = (undefined *)ke_msg_alloc(0x1c0c,src_id,dest_id,3); + if ((vif_info_tab[param->vif_idx].type == '\x02') && (param->sta_idx < 0xd)) { + apm_sta_remove(param->vif_idx,param->sta_idx); + *puVar1 = 0; + } + else { + *puVar1 = 0xff; + } + ke_msg_send(puVar1); + return 0; +} + + +/* +Unable to decompile 'apm_stop_cac_req_handler' +Cause: Exception while decompiling 2301f08a: Decompiler process died + +*/ + + +int apm_conf_max_sta_req_handler + (ke_msg_id_t msgid,apm_conf_max_sta_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + apm_env.max_sta_supported = param->max_sta_supported; + if (0xc < apm_env.max_sta_supported) { + apm_env.max_sta_supported = 0xc; + } + ke_msg_send_basic(0x1c0e,src_id,dest_id); + return 0; +} + + +/* +Unable to decompile 'apm_start_cac_req_handler' +Cause: Exception while decompiling 2301f130: Decompiler process died + +*/ + + +int me_set_ps_disable_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + + kVar1 = ke_state_get(7); + if ((CONCAT22(extraout_var,kVar1) != 1) && + (kVar1 = ke_state_get(7), CONCAT22(extraout_var_00,kVar1) != 0)) { + assert_err( + "(ke_state_get(TASK_APM) == APM_BSS_PARAM_SETTING) || (ke_state_get(TASK_APM) == APM_IDLE)" + ,"module",0xee); + } + kVar1 = ke_state_get(7); + if (CONCAT22(extraout_var_01,kVar1) == 1) { + apm_send_next_bss_param(); + } + return 0; +} + + + +int mm_bss_param_setting_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(7); + if (CONCAT22(extraout_var,kVar1) != 1) { + assert_err("ke_state_get(TASK_APM) == APM_BSS_PARAM_SETTING","module",0x110); + } + apm_send_next_bss_param(); + return 0; +} + + + +int mm_bcn_change_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + + kVar1 = ke_state_get(7); + if (CONCAT22(extraout_var,kVar1) != 2) { + assert_err("ke_state_get(TASK_APM) == APM_BCN_SETTING","module",0x156); + } + apm_start_cfm(0); + return 0; +} + + + +int apm_stop_req_handler + (ke_msg_id_t msgid,apm_stop_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint uVar1; + ke_state_t kVar2; + undefined2 extraout_var; + + uVar1 = (uint)param->vif_idx; + if ((vif_info_tab[uVar1].type == '\x02') && (vif_info_tab[uVar1].active != false)) { + kVar2 = ke_state_get(7); + if (CONCAT22(extraout_var,kVar2) != 0) { + return 2; + } + if (apm_env.apm_emb_enabled != false) { + apm_env.apm_emb_enabled = false; + } + apm_stop(vif_info_tab + uVar1); + if (uap_conn_info != (cm_ConnectionInfo_t *)0x0) { + RemoveAPKeyInfo(uap_conn_info); + cm_DeleteConnection(uap_conn_info); + uap_conn_info = (cm_ConnectionInfo_t *)0x0; + } + } + ke_msg_send_basic(0x1c03,src_id,dest_id); + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int apm_start_req_handler + (ke_msg_id_t msgid,apm_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint32_t uVar1; + char "apm_start_req_handler" [22]; + uint8_t uVar2; + _Bool _Var3; + ke_state_t kVar4; + uint16_t uVar5; + undefined2 extraout_var_01; + undefined3 extraout_var; + scan_chan_tag *psVar6; + undefined3 extraout_var_00; + int iVar7; + undefined *puVar8; + uint uVar9; + undefined uVar10; + uint8_t *ssid; + uint8_t uStack51; + int8_t iStack50; + uint8_t auStack49 [2]; + uint8_t chan_idx; + int8_t pwr; + uint8_t idx; + + printf("[WF] received APM Start %s:%d\r\n","apm_start_req_handler",0x4c); + uVar9 = (uint)param->vif_idx; + uVar10 = 4; + if (vif_info_tab[uVar9].type == '\x02') { + kVar4 = ke_state_get(7); + if (CONCAT22(extraout_var_01,kVar4) == 0) { + if (vif_info_tab[uVar9].active == false) { + if (vif_info_tab[uVar9].chan_ctxt != (chan_ctxt_tag *)0x0) { + assert_err("vif->chan_ctxt == NULL","module",0x67); + } + apm_env.param = param; + uVar2 = me_add_chan_ctx(&uStack51,¶m->chan,param->center_freq1,param->center_freq2, + param->ch_width); + uVar10 = 1; + if (CONCAT31(extraout_var,uVar2) == 0) { + psVar6 = me_freq_to_chan_ptr((param->chan).band,(param->chan).freq); + vif_info_tab[uVar9].bss_info.chan = psVar6; + psVar6->tx_power = (param->chan).tx_power; + vif_info_tab[uVar9].bss_info.center_freq1 = (uint16_t)param->center_freq1; + vif_info_tab[uVar9].bss_info.center_freq2 = (uint16_t)param->center_freq2; + uVar2 = param->ch_width; + if (uVar2 == '\x04') { + uVar2 = '\x03'; + } + vif_info_tab[uVar9].bss_info.bw = uVar2; + uVar2 = param->ch_width; + vif_info_tab[uVar9].bss_info.power_constraint = '\0'; + vif_info_tab[uVar9].bss_info.phy_bw = uVar2; + chan_ctxt_link(param->vif_idx,uStack51); + apm_env.apm_emb_enabled = param->apm_emb_enabled; + apm_env.hidden_ssid = param->hidden_ssid; + _Var3 = apm_embedded_enabled(vif_info_tab + uVar9); + if (CONCAT31(extraout_var_00,_Var3) != 0) { + me_get_basic_rates(¶m->rate_set,(mac_rateset *)param); + if (param->qos_supported != '\0') { + vif_info_tab[uVar9].bss_info.valid_flags = + vif_info_tab[uVar9].bss_info.valid_flags | 1; + } + if (me_env.ht_supported != false) { + vif_info_tab[uVar9].bss_info.valid_flags = + vif_info_tab[uVar9].bss_info.valid_flags | 2; + } + vif_info_tab[uVar9].bss_info.beacon_interval = param->bcn_int; + vif_info_tab[uVar9].bss_info.beacon_period = (ushort)param->beacon_period; + vif_info_tab[uVar9].bss_info.sec_type = param->ap_sec_type; + memcpy(&vif_info_tab[uVar9].bss_info.ssid,¶m->ssid,0x22); + vif_info_tab[uVar9].bss_info.ssid.array[vif_info_tab[uVar9].bss_info.ssid.length] = '\0' + ; + *(undefined4 *)vif_info_tab[uVar9].bss_info.bssid.array = + *(undefined4 *)vif_info_tab[uVar9].mac_addr.array; + vif_info_tab[uVar9].bss_info.bssid.array[2] = vif_info_tab[uVar9].mac_addr.array[2]; + memcpy(&vif_info_tab[uVar9].bss_info.rate_set,¶m->rate_set,0xd); + vif_info_tab[uVar9].txq_params[0] = _DAT_44b00200; + vif_info_tab[uVar9].txq_params[1] = _DAT_44b00204; + vif_info_tab[uVar9].txq_params[2] = _DAT_44b00208; + uVar1 = _DAT_44b0020c; + vif_info_tab[uVar9].bss_info.edca_param.qos_info = '\0'; + vif_info_tab[uVar9].txq_params[3] = uVar1; + *(undefined4 *)&vif_info_tab[uVar9].bss_info.aid_bitmap = 0xffff0000; + apm_env.bcn_buf = (uint8_t *)ke_malloc(0x14d); + uVar5 = me_build_beacon((uint32_t)apm_env.bcn_buf,vif_info_tab[uVar9].index, + ¶m->tim_oft,¶m->tim_len,apm_env.hidden_ssid); + param->bcn_len = uVar5; + if (param->ap_sec_type == '\0') { + uap_conn_info = (cm_ConnectionInfo_t *)0x0; + } + else { + uap_conn_info = + cm_InitConnection('\x02','\0','\0', + (IEEEtypes_MacAddr_t *)&vif_info_tab[uVar9].bss_info.bssid, + (IEEEtypes_MacAddr_t *)0x0,'\0',(unkbyte0 *)0x0); + ssid = vif_info_tab[uVar9].bss_info.ssid.array; + ap_setpsk(uap_conn_info,(CHAR *)ssid,(CHAR *)param->phrase); + cm_SetComData(uap_conn_info,(char *)ssid); + uap_conn_info->instNbr = param->vif_idx; + printf("%s:uap_conn_info->instNbr = %d\r\n",0x23078994,(uint)uap_conn_info->instNbr); + InitGroupKey(uap_conn_info); + } + } + if ((param->chan).band == '\0') { + uVar5 = me_legacy_rate_bitfield_build(&vif_info_tab[uVar9].bss_info.rate_set,true); + if ((uVar5 & 0xf) == 0) { + vif_info_tab[uVar9].bss_info.high_11b_rate = '\x01'; + } + else { + iVar7 = __clzsi2((uint)uVar5 & 0xf); + vif_info_tab[uVar9].bss_info.high_11b_rate = '\x1f' - (char)iVar7; + } + } + apm_set_bss_param(); + iStack50 = (vif_info_tab[uVar9].bss_info.chan)->tx_power; + tpc_update_vif_tx_power(vif_info_tab + uVar9,&iStack50,auStack49); + printf("[WF] return with other handler\r\n"); + return 1; + } + } + else { + uVar10 = 9; + } + } + else { + uVar10 = 8; + } + } + printf("[WF] Sending APM CFM %s:%d\r\n",0x23078994,0xcc); + puVar8 = (undefined *)ke_msg_alloc(0x1c01,src_id,dest_id,4); + *puVar8 = uVar10; + puVar8[1] = param->vif_idx; + ke_msg_send(); + return 0; +} + + + +int me_set_active_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + + kVar1 = ke_state_get(7); + if ((CONCAT22(extraout_var,kVar1) != 1) && + (kVar1 = ke_state_get(7), CONCAT22(extraout_var_00,kVar1) != 0)) { + assert_err( + "(ke_state_get(TASK_APM) == APM_BSS_PARAM_SETTING) || (ke_state_get(TASK_APM) == APM_IDLE)" + ,"module",0x12f); + } + kVar1 = ke_state_get(7); + if (CONCAT22(extraout_var_01,kVar1) == 1) { + if (apm_env.bss_config.first != (co_list_hdr *)0x0) { + assert_err("co_list_is_empty(&apm_env.bss_config)","module",0x135); + } + apm_bcn_set(); + } + return 0; +} + + + +int hostapd_mgt_ind_handler + (ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ushort uVar1; + + uVar1 = param->framectrl & 0xfc; + if ((uVar1 != 0x40) && (uVar1 != 0xb0)) { + return 0; + } + ke_state_get(10); + return 0; +} + + + +void dump_cfg_entries(void) + +{ + cfg_element_entry *pcVar1; + char *pcVar2; + char acStack64 [4]; + char strs [16]; + + puts("================= CFG TASK =================\r\n"); + pcVar1 = cfg_entrys_mm; + while (pcVar1 < &_fsymc_info_bloop) { + printf("entry %p\r\n",pcVar1); + printf(" task : %lu\r\n",(blog_level_t *)pcVar1->task); + printf(" element : %u\r\n",(uint)pcVar1->element); + printf(" type : %u\r\n",(uint)pcVar1->type); + printf(" name : %s\r\n",pcVar1->name); + pcVar2 = cfg_api_element_dump(pcVar1->val,*(CFG_ELEMENT_TYPE *)&pcVar1->type,acStack64); + printf(" type : %s\r\n",pcVar2); + printf(" val : %s\r\n"); + puts("------------------------\r\n"); + pcVar1 = pcVar1 + 1; + } + puts("---------------------------------------------\r\n"); + return; +} + + + +// WARNING: Variable defined which should be unmapped: val + +int cfg_start_req_handler + (ke_msg_id_t msgid,cfg_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined2 in_register_0000202a; + undefined *puVar1; + int iVar2; + undefined4 uStack20; + uint32_t val [1]; + + if (param->ops == 0) { + iVar2 = utils_tlv_bl_unpack_auto + ((uint32_t *)(param + 5),param[4].ops,*(uint16_t *)¶m[3].ops,&uStack20); + printf("unpack ret is %d, result is %lu\r\n",iVar2,uStack20); + cfg_api_element_set(param[1].ops,param[2].ops,param[3].ops,&uStack20,(void *)0x0); + } + else { + if (2 < param->ops) { + dump_cfg_entries(CONCAT22(in_register_0000202a,msgid)); + } + } + puVar1 = (undefined *)ke_msg_alloc(0x3001,src_id,dest_id,1); + *puVar1 = 0; + ke_msg_send(); + return 0; +} + + + +void dbg_init(void) + +{ + memset(&dbg_env,0,8); + dbg_env.filter_module = 0xffffffff; + dbg_env.filter_severity = 2; + return; +} + + + +void dbg_test_print(char *fmt,...) + +{ + byte bVar1; + uint uVar2; + byte *pbVar3; + va_list args; + + if (dbg_env.filter_severity != 0) { + pbVar3 = (byte *)(fmt + 2); + do { + bVar1 = *fmt; + uVar2 = (uint)bVar1; + if (-1 < (char)bVar1) { + return; + } + if (bVar1 < 0x88) { + if ((~dbg_env.filter_module >> (uVar2 - 0x80 & 0x1f) & 1) != 0) { + return; + } + } + else { + if (5 < (uVar2 + 0x66 & 0xff)) { + assert_err("DBG_SEV_MIN <= prefix && prefix < DBG_SEV_MAX","module",0x297); + } + if (dbg_env.filter_severity <= uVar2 - 0x9a) { + return; + } + } + fmt = (char *)((byte *)fmt + 1); + } while (pbVar3 != (byte *)fmt); + } + return; +} + + + +int dbg_get_sys_stat_req_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined4 *puVar1; + + puVar1 = (undefined4 *)ke_msg_alloc(0x40a,src_id,dest_id,0xc); + *puVar1 = 0; + puVar1[1] = 0; + puVar1[2] = 0; + ke_msg_send(); + return 0; +} + + + +int dbg_mem_write_req_handler + (ke_msg_id_t msgid,dbg_mem_write_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint32_t **ppuVar1; + uint32_t **ppuVar2; + + ppuVar1 = (uint32_t **)ke_msg_alloc(0x403,src_id,dest_id,8); + *(uint32_t *)param->memaddr = param->memdata; + ppuVar2 = (uint32_t **)param->memaddr; + *(uint32_t ***)ppuVar1 = ppuVar2; + ppuVar1[1] = *ppuVar2; + ke_msg_send(); + return 0; +} + + + +int dbg_mem_read_req_handler + (ke_msg_id_t msgid,dbg_mem_read_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint32_t *puVar1; + + puVar1 = (uint32_t *)ke_msg_alloc(0x401,src_id,dest_id,8); + puVar1[1] = *(uint32_t *)param->memaddr; + *puVar1 = param->memaddr; + ke_msg_send(); + return 0; +} + + + +int dbg_set_sev_filter_req_handler + (ke_msg_id_t msgid,dbg_set_sev_filter_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + dbg_env.filter_severity = param->sev_filter; + ke_msg_send_basic(0x407,src_id,dest_id); + return 0; +} + + + +int dbg_set_mod_filter_req_handler + (ke_msg_id_t msgid,dbg_set_mod_filter_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + dbg_env.filter_module = param->mod_filter; + ke_msg_send_basic(0x405,src_id,dest_id); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling + +co_list_hdr * +ke_queue_extract(co_list *queue,anon_subr__Bool_co_list_hdr_ptr_uint32_t *func,uint32_t arg) + +{ + co_list_hdr cVar1; + co_list_hdr cVar2; + _Bool _Var3; + undefined3 extraout_var; + co_list_hdr cVar4; + + cVar4 = (co_list_hdr)queue->first; + cVar1 = (co_list_hdr)0x0; + do { + cVar2 = cVar1; + cVar1 = cVar4; + if (cVar1 == (co_list_hdr)0x0) { + return (co_list_hdr *)0; + } + _Var3 = (*func)((co_list_hdr *)cVar1,arg); + cVar4 = *(co_list_hdr *)cVar1; + } while (CONCAT31(extraout_var,_Var3) == 0); + if (cVar2 == (co_list_hdr)0x0) { + *(co_list_hdr *)&queue->first = cVar4; + } + else { + *(co_list_hdr *)cVar2 = cVar4; + } + if (*(int *)cVar1 == 0) { + *(co_list_hdr *)&queue->last = cVar2; + } + else { + *(undefined4 *)cVar1 = 0; + } + return (co_list_hdr *)cVar1; +} + + + +void bl_aes_128(UINT8 *key,UINT8 *input,UINT8 *output) + +{ + BL_AesEncrypt(key,'\x02',input,output); + return; +} + + + +void xor_128(UINT8 *a,UINT8 *b,UINT8 *out) + +{ + byte *pbVar1; + int iVar2; + byte *pbVar3; + byte *pbVar4; + + iVar2 = 0; + do { + pbVar1 = a + iVar2; + pbVar4 = b + iVar2; + pbVar3 = out + iVar2; + iVar2 = iVar2 + 1; + *pbVar3 = *pbVar1 ^ *pbVar4; + } while (iVar2 != 0x10); + return; +} + + + +void leftshift_onebit(UINT8 *input,UINT8 *output) + +{ + byte *pbVar1; + int iVar2; + byte bVar3; + byte *pbVar4; + + bVar3 = 0; + iVar2 = 0xf; + do { + pbVar1 = input + iVar2; + pbVar4 = output + iVar2; + iVar2 = iVar2 + -1; + *pbVar4 = bVar3 | *pbVar1 << 1; + bVar3 = *pbVar1 >> 7; + } while (iVar2 != -1); + return; +} + + + +// WARNING: Variable defined which should be unmapped: tmp + +void generate_subkey(UINT8 *key,UINT8 *K1,UINT8 *K2) + +{ + UINT8 local_40 [4]; + UINT8 L [16]; + UINT8 Z [16]; + UINT8 tmp [16]; + + memset(L + 0xc,0,0x10); + bl_aes_128(key,L + 0xc,local_40); + if ((char)local_40[0] < '\0') { + leftshift_onebit(local_40,Z + 0xc); + xor_128(Z + 0xc,"",K1); + } + else { + leftshift_onebit(local_40,K1); + } + if ((char)*K1 < '\0') { + leftshift_onebit(K1,Z + 0xc); + xor_128(Z + 0xc,"",K2); + } + else { + leftshift_onebit(K1,K2); + } + return; +} + + + +void padding(UINT8 *lastb,UINT8 *pad,int length) + +{ + int iVar1; + + iVar1 = 0; + do { + if (iVar1 < length) { + pad[iVar1] = lastb[iVar1]; + } + else { + if (length == iVar1) { + pad[length] = -0x80; + } + else { + pad[iVar1] = '\0'; + } + } + iVar1 = iVar1 + 1; + } while (iVar1 != 0x10); + return; +} + + + +void bl_aes_cmac(UINT8 *key,UINT8 *input,int length,UINT8 *mac) + +{ + int iVar1; + int iVar2; + UINT8 *a; + UINT8 *pUVar3; + UINT8 local_80 [4]; + UINT8 X [16]; + UINT8 Y [16]; + UINT8 M_last [16]; + UINT8 padded [16]; + UINT8 K1 [16]; + UINT8 K2 [16]; + + generate_subkey(key,padded + 0xc,K1 + 0xc); + iVar1 = (length + 0xf) / 0x10; + if (iVar1 == 0) { + iVar1 = 1; + } + else { + if ((length & 0xfU) == 0) { + pUVar3 = padded; + a = input + (iVar1 + -1) * 0x10; + goto LAB_2301fbde; + } + } + padding(input + (iVar1 + -1) * 0x10,M_last + 0xc,length % 0x10); + pUVar3 = K1; + a = M_last + 0xc; +LAB_2301fbde: + xor_128(a,pUVar3 + 0xc,Y + 0xc); + memset(local_80,0,0x10); + iVar2 = 0; + while (iVar2 < iVar1 + -1) { + xor_128(local_80,input + iVar2 * 0x10,X + 0xc); + bl_aes_128(key,X + 0xc,local_80); + iVar2 = iVar2 + 1; + } + xor_128(local_80,Y + 0xc,X + 0xc); + bl_aes_128(key,X + 0xc,local_80); + iVar1 = 0; + do { + pUVar3 = local_80 + iVar1; + a = mac + iVar1; + iVar1 = iVar1 + 1; + *a = *pUVar3; + } while (iVar1 != 0x10); + return; +} + + + +int BL_AES_MEMCMP(UINT8 *dst,UINT8 *src,int len) + +{ + int iVar1; + int iVar2; + + iVar2 = 0; + iVar1 = len; + while (len != iVar2) { + if (dst[iVar2] == src[iVar2]) { + iVar1 = iVar1 + -1; + } + iVar2 = iVar2 + 1; + } + return -(uint)(iVar1 != 0); +} + + + +void BL_AES_MEMSET(UINT8 *dst,UINT8 val,int size) + +{ + UINT8 *pUVar1; + + pUVar1 = dst; + while (pUVar1 != dst + size) { + *pUVar1 = val; + pUVar1 = pUVar1 + 1; + } + return; +} + + + +void BL_AES_MEMCPY(UINT8 *dst,UINT8 *src,int size) + +{ + UINT8 *pUVar1; + UINT8 *pUVar2; + int iVar3; + + if (dst < src) { + iVar3 = 0; + while (iVar3 != size) { + pUVar1 = src + iVar3; + pUVar2 = dst + iVar3; + iVar3 = iVar3 + 1; + *pUVar2 = *pUVar1; + } + return; + } + while (size = size + -1, size != -1) { + dst[size] = src[size]; + } + return; +} + + + +int BL_AesEncrypt(UINT8 *kek,UINT8 kekLen,UINT8 *data,UINT8 *ret) + +{ + undefined3 in_register_0000202d; + undefined auStack416 [4]; + UINT8 pBuf [400]; + + rijndael_set_key((rijndael_ctx *)auStack416,kek,CONCAT31(in_register_0000202d,kekLen) << 6,1); + rijndael_encrypt((rijndael_ctx *)auStack416,data,ret); + return 0; +} + + + +int BL_AesWrap(UINT8 *kek,UINT8 kekLen,UINT32 n,UINT8 *plain,UINT8 *keyIv,UINT8 *cipher) + +{ + int iVar1; + uint uVar2; + int iVar3; + int iVar4; + UINT8 aUStack72 [4]; + UINT8 a [8]; + UINT8 b [16]; + + if (n != 0) { + BL_AES_MEMSET(a + 4,'\0',0x10); + if (keyIv == (UINT8 *)0x0) { + keyIv = BL_DEFAULT_IV; + } + BL_AES_MEMCPY(aUStack72,keyIv,8); + BL_AES_MEMCPY(cipher + 8,plain,n << 3); + uVar2 = 0; + iVar4 = 6; + do { + iVar1 = 1; + while (iVar3 = iVar1 * 8, iVar1 != n + 1) { + BL_AES_MEMCPY(a + 4,aUStack72,8); + BL_AES_MEMCPY(b + 4,cipher + iVar3,8); + BL_AesEncrypt(kek,kekLen,a + 4,a + 4); + BL_AES_MEMCPY(aUStack72,a + 4,8); + a[3] = (char)uVar2 + (char)iVar1 ^ a[3]; + iVar1 = iVar1 + 1; + BL_AES_MEMCPY(cipher + iVar3,b + 4,8); + } + iVar4 = iVar4 + -1; + uVar2 = uVar2 + (n & 0xff) & 0xff; + } while (iVar4 != 0); + BL_AES_MEMCPY(cipher,aUStack72,8); + return 0; + } + return -1; +} + + + +int BL_AesUnWrap(UINT8 *kek,UINT8 kekLen,UINT32 n,UINT8 *cipher,UINT8 *keyIv,UINT8 *plain) + +{ + uint uVar1; + undefined3 in_register_0000202d; + UINT32 UVar2; + UINT8 *src; + int iVar3; + UINT8 aUStack472 [4]; + UINT8 a [8]; + UINT8 b [16]; + UINT8 pBuf [400]; + + if (n != 0) { + BL_AES_MEMSET(aUStack472,'\0',8); + BL_AES_MEMSET(a + 4,'\0',0x10); + BL_AES_MEMCPY(aUStack472,cipher,8); + uVar1 = (n & 0xff) * 5; + BL_AES_MEMCPY(plain,cipher + 8,n * 8); + rijndael_set_key((rijndael_ctx *)(b + 0xc),kek,CONCAT31(in_register_0000202d,kekLen) << 6,0); + iVar3 = 6; + do { + UVar2 = n; + src = plain + n * 8 + -8; + while (0 < (int)UVar2) { + BL_AES_MEMCPY(a + 4,aUStack472,8); + b[3] = (char)(uVar1 & 0xff) + (char)UVar2 ^ b[3]; + BL_AES_MEMCPY(b + 4,src,8); + rijndael_decrypt((rijndael_ctx *)(b + 0xc),a + 4,a + 4); + BL_AES_MEMCPY(aUStack472,a + 4,8); + BL_AES_MEMCPY(src,b + 4,8); + src = src + -8; + UVar2 = UVar2 - 1; + } + uVar1 = (uVar1 & 0xff) - (n & 0xff); + iVar3 = iVar3 + -1; + } while (iVar3 != 0); + if (keyIv == (UINT8 *)0x0) { + keyIv = BL_DEFAULT_IV; + } + iVar3 = BL_AES_MEMCMP(keyIv,aUStack472,8); + return -(uint)(iVar3 != 0); + } + return -1; +} + + + +// WARNING: Variable defined which should be unmapped: pBuf + +void Bl_hmac_md5(UINT8 *text_data,int text_len,UINT8 *key,int key_len,void *digest) + +{ + ulong *puVar1; + Bl_MD5_CTX *pBVar2; + Bl_MD5_CTX *context; + Bl_MD5_CTX *context_00; + undefined auStack584 [4]; + Bl_MD5_CTX tctx; + uchar pBuf [400]; + + if (0x40 < key_len) { + wpa_MD5Init((Bl_MD5_CTX *)auStack584); + wpa_MD5Update((Bl_MD5_CTX *)auStack584,key,key_len); + wpa_MD5Final(pBuf + 0x94,(Bl_MD5_CTX *)auStack584); + key_len = 0x10; + key = pBuf + 0x94; + } + memset(tctx.buffer + 0x3c,0,0x40); + memcpy(tctx.buffer + 0x3c,key,key_len); + context_00 = (Bl_MD5_CTX *)(pBuf + 0x3c); + pBVar2 = (Bl_MD5_CTX *)(tctx.buffer + 0x3c); + do { + puVar1 = pBVar2->state; + pBVar2->state[0] = pBVar2->state[0] ^ 0x36363636; + pBVar2 = (Bl_MD5_CTX *)(puVar1 + 1); + } while ((Bl_MD5_CTX *)(puVar1 + 1) != context_00); + wpa_MD5Init(context_00); + wpa_MD5Update(context_00,tctx.buffer + 0x3c,0x40); + wpa_MD5Update(context_00,text_data,text_len); + wpa_MD5Final((uchar *)digest,context_00); + memset(tctx.buffer + 0x3c,0,0x40); + memcpy(tctx.buffer + 0x3c,key,key_len); + pBVar2 = (Bl_MD5_CTX *)(tctx.buffer + 0x3c); + do { + context = (Bl_MD5_CTX *)(pBVar2->state + 1); + pBVar2->state[0] = pBVar2->state[0] ^ 0x5c5c5c5c; + pBVar2 = context; + } while (context != context_00); + wpa_MD5Init(context); + wpa_MD5Update(context,tctx.buffer + 0x3c,0x40); + wpa_MD5Update(context,(UINT8 *)digest,0x10); + wpa_MD5Final((uchar *)digest,context); + return; +} + + + +void Bl_hmac_sha1(uchar **ppText,int *pTextLen,int textNum,uchar *key,int key_len,uchar *output, + int outputLen) + +{ + uint *puVar1; + uint *__src; + uchar **ppuVar2; + int iVar3; + uint *Message_Digest; + uint local_1c0; + uchar pBuf [400]; + + if (0x40 < key_len) { + Bl_SHA1Init((Bl_SHA1_CTX *)(pBuf + 0x50)); + Bl_SHA1Update((Bl_SHA1_CTX *)(pBuf + 0x50),key,key_len); + Bl_SHA1Final((Bl_SHA1_CTX *)(pBuf + 0x50),key); + key_len = 0x14; + } + memset(&local_1c0,0,0x40); + memcpy(&local_1c0,key,key_len); + Message_Digest = (uint *)(pBuf + 0x3c); + puVar1 = &local_1c0; + do { + __src = puVar1 + 2; + *puVar1 = *puVar1 ^ 0x36363636; + puVar1[1] = puVar1[1] ^ 0x36363636; + puVar1 = __src; + } while (__src != Message_Digest); + Bl_SHA1Init((Bl_SHA1_CTX *)(pBuf + 0x50)); + Bl_SHA1Update((Bl_SHA1_CTX *)(pBuf + 0x50),(UINT8 *)&local_1c0,0x40); + iVar3 = 0; + while (iVar3 < textNum) { + puVar1 = (uint *)(pTextLen + iVar3); + ppuVar2 = ppText + iVar3; + iVar3 = iVar3 + 1; + Bl_SHA1Update((Bl_SHA1_CTX *)(pBuf + 0x50),*ppuVar2,*puVar1); + } + Bl_SHA1Final((Bl_SHA1_CTX *)(pBuf + 0x50),(UINT8 *)Message_Digest); + memset(&local_1c0,0,0x40); + memcpy(&local_1c0,key,key_len); + puVar1 = &local_1c0; + do { + __src = puVar1 + 2; + *puVar1 = *puVar1 ^ 0x5c5c5c5c; + puVar1[1] = puVar1[1] ^ 0x5c5c5c5c; + puVar1 = __src; + } while (__src != Message_Digest); + Bl_SHA1Init((Bl_SHA1_CTX *)(pBuf + 0x50)); + Bl_SHA1Update((Bl_SHA1_CTX *)(pBuf + 0x50),(UINT8 *)&local_1c0,0x40); + Bl_SHA1Update((Bl_SHA1_CTX *)(pBuf + 0x50),(UINT8 *)__src,0x14); + Bl_SHA1Final((Bl_SHA1_CTX *)(pBuf + 0x50),(UINT8 *)__src); + memcpy(output,__src,outputLen); + return; +} + + + +void Bl_PRF(uchar *key,int key_len,uchar *prefix,int prefix_len,uchar *data,int data_len, + uchar *output,int len) + +{ + char cVar1; + int iVar2; + int iVar3; + int iVar4; + int local_b0; + int total_len; + uchar *pText; + UINT8 prf_input [120]; + + total_len = (int)&pText; + memset(&pText,0,0x78); + if (prefix == (uchar *)0x0) { + memcpy(&pText,data,data_len); + local_b0 = data_len; + } + else { + memcpy(&pText,prefix,prefix_len); + local_b0 = prefix_len + 1 + data_len; + *(undefined *)((int)&pText + prefix_len) = 0; + memcpy((void *)((int)&pText + prefix_len + 1),data,data_len); + } + *(undefined *)((int)&pText + local_b0) = 0; + iVar4 = 0; + iVar3 = 0; + local_b0 = local_b0 + 1; + while( true ) { + iVar2 = (iVar3 * -0x14 + len) * 0x1000000; + cVar1 = (char)((uint)iVar2 >> 0x18); + if ((len + 0x13) / 0x14 <= iVar3) break; + if (0x14 < iVar2 >> 0x18) { + cVar1 = '\x14'; + } + Bl_hmac_sha1((uchar **)&total_len,&local_b0,1,key,key_len,output + iVar4,(int)cVar1); + iVar4 = iVar4 + (int)cVar1; + iVar3 = iVar3 + 1; + *(char *)((int)&total_len + local_b0 + 3) = *(char *)((int)&total_len + local_b0 + 3) + '\x01'; + } + return; +} + + + +void wpa_MD5Transform(UINT32 *state,ulong *block) + +{ + ulong uVar1; + ulong uVar2; + ulong uVar3; + ulong uVar4; + ulong uVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint uVar9; + uint uVar10; + uint uVar11; + uint uVar12; + ulong uVar13; + ulong uVar14; + ulong uVar15; + ulong uVar16; + ulong uVar17; + ulong uVar18; + ulong uVar19; + uint uVar20; + uint uVar21; + ulong uVar22; + ulong uVar23; + ulong uVar24; + ulong uVar25; + + uVar19 = *block; + uVar20 = state[2]; + uVar21 = state[3]; + uVar12 = state[1]; + uVar5 = block[1]; + uVar8 = ((uVar20 ^ uVar21) & uVar12 ^ uVar21) + *state + uVar19 + 0xd76aa478; + uVar9 = (uVar8 >> 0x19 | uVar8 * 0x80) + uVar12; + uVar22 = block[2]; + uVar8 = ((uVar12 ^ uVar20) & uVar9 ^ uVar20) + uVar5 + 0xe8c7b756 + uVar21; + uVar6 = (uVar8 >> 0x14 | uVar8 * 0x1000) + uVar9; + uVar8 = ((uVar12 ^ uVar9) & uVar6 ^ uVar12) + uVar22 + 0x242070db + uVar20; + uVar14 = block[3]; + uVar8 = (uVar8 * 0x20000 | uVar8 >> 0xf) + uVar6; + uVar7 = ((uVar9 ^ uVar6) & uVar8 ^ uVar9) + uVar14 + 0xc1bdceee + uVar12; + uVar24 = block[4]; + uVar7 = (uVar7 * 0x400000 | uVar7 >> 10) + uVar8; + uVar9 = ((uVar6 ^ uVar8) & uVar7 ^ uVar6) + uVar24 + 0xf57c0faf + uVar9; + uVar16 = block[5]; + uVar9 = (uVar9 >> 0x19 | uVar9 * 0x80) + uVar7; + uVar6 = ((uVar8 ^ uVar7) & uVar9 ^ uVar8) + uVar16 + 0x4787c62a + uVar6; + uVar1 = block[6]; + uVar6 = (uVar6 >> 0x14 | uVar6 * 0x1000) + uVar9; + uVar8 = ((uVar7 ^ uVar9) & uVar6 ^ uVar7) + uVar1 + 0xa8304613 + uVar8; + uVar18 = block[7]; + uVar8 = (uVar8 * 0x20000 | uVar8 >> 0xf) + uVar6; + uVar7 = ((uVar9 ^ uVar6) & uVar8 ^ uVar9) + uVar18 + 0xfd469501 + uVar7; + uVar4 = block[8]; + uVar7 = (uVar7 * 0x400000 | uVar7 >> 10) + uVar8; + uVar9 = ((uVar6 ^ uVar8) & uVar7 ^ uVar6) + uVar4 + 0x698098d8 + uVar9; + uVar2 = block[9]; + uVar9 = (uVar9 >> 0x19 | uVar9 * 0x80) + uVar7; + uVar6 = ((uVar8 ^ uVar7) & uVar9 ^ uVar8) + uVar2 + 0x8b44f7af + uVar6; + uVar13 = block[10]; + uVar6 = (uVar6 >> 0x14 | uVar6 * 0x1000) + uVar9; + uVar8 = ((uVar7 ^ uVar9) & uVar6 ^ uVar7) + (uVar13 - 0xa44f) + uVar8; + uVar23 = block[0xb]; + uVar8 = (uVar8 * 0x20000 | uVar8 >> 0xf) + uVar6; + uVar7 = ((uVar9 ^ uVar6) & uVar8 ^ uVar9) + uVar23 + 0x895cd7be + uVar7; + uVar15 = block[0xc]; + uVar7 = (uVar7 * 0x400000 | uVar7 >> 10) + uVar8; + uVar9 = ((uVar6 ^ uVar8) & uVar7 ^ uVar6) + uVar15 + 0x6b901122 + uVar9; + uVar25 = block[0xd]; + uVar9 = (uVar9 >> 0x19 | uVar9 * 0x80) + uVar7; + uVar6 = ((uVar8 ^ uVar7) & uVar9 ^ uVar8) + uVar25 + 0xfd987193 + uVar6; + uVar17 = block[0xe]; + uVar6 = (uVar6 >> 0x14 | uVar6 * 0x1000) + uVar9; + uVar8 = ((uVar7 ^ uVar9) & uVar6 ^ uVar7) + uVar17 + 0xa679438e + uVar8; + uVar3 = block[0xf]; + uVar8 = (uVar8 * 0x20000 | uVar8 >> 0xf) + uVar6; + uVar7 = ((uVar9 ^ uVar6) & uVar8 ^ uVar9) + uVar3 + 0x49b40821 + uVar7; + uVar7 = (uVar7 * 0x400000 | uVar7 >> 10) + uVar8; + uVar9 = ((uVar8 ^ uVar7) & uVar6 ^ uVar8) + uVar5 + 0xf61e2562 + uVar9; + uVar9 = (uVar9 >> 0x1b | uVar9 * 0x20) + uVar7; + uVar6 = ((uVar7 ^ uVar9) & uVar8 ^ uVar7) + uVar1 + 0xc040b340 + uVar6; + uVar6 = (uVar6 >> 0x17 | uVar6 * 0x200) + uVar9; + uVar8 = ((uVar9 ^ uVar6) & uVar7 ^ uVar9) + uVar23 + 0x265e5a51 + uVar8; + uVar8 = (uVar8 >> 0x12 | uVar8 * 0x4000) + uVar6; + uVar7 = ((uVar6 ^ uVar8) & uVar9 ^ uVar6) + uVar19 + 0xe9b6c7aa + uVar7; + uVar7 = (uVar7 * 0x100000 | uVar7 >> 0xc) + uVar8; + uVar9 = ((uVar8 ^ uVar7) & uVar6 ^ uVar8) + uVar16 + 0xd62f105d + uVar9; + uVar9 = (uVar9 >> 0x1b | uVar9 * 0x20) + uVar7; + uVar6 = ((uVar7 ^ uVar9) & uVar8 ^ uVar7) + uVar13 + 0x2441453 + uVar6; + uVar6 = (uVar6 >> 0x17 | uVar6 * 0x200) + uVar9; + uVar8 = ((uVar9 ^ uVar6) & uVar7 ^ uVar9) + uVar3 + 0xd8a1e681 + uVar8; + uVar8 = (uVar8 >> 0x12 | uVar8 * 0x4000) + uVar6; + uVar7 = ((uVar6 ^ uVar8) & uVar9 ^ uVar6) + uVar24 + 0xe7d3fbc8 + uVar7; + uVar7 = (uVar7 * 0x100000 | uVar7 >> 0xc) + uVar8; + uVar9 = ((uVar8 ^ uVar7) & uVar6 ^ uVar8) + uVar2 + 0x21e1cde6 + uVar9; + uVar9 = (uVar9 >> 0x1b | uVar9 * 0x20) + uVar7; + uVar6 = ((uVar7 ^ uVar9) & uVar8 ^ uVar7) + uVar17 + 0xc33707d6 + uVar6; + uVar6 = (uVar6 >> 0x17 | uVar6 * 0x200) + uVar9; + uVar8 = ((uVar9 ^ uVar6) & uVar7 ^ uVar9) + uVar14 + 0xf4d50d87 + uVar8; + uVar8 = (uVar8 >> 0x12 | uVar8 * 0x4000) + uVar6; + uVar7 = ((uVar6 ^ uVar8) & uVar9 ^ uVar6) + uVar4 + 0x455a14ed + uVar7; + uVar7 = (uVar7 * 0x100000 | uVar7 >> 0xc) + uVar8; + uVar9 = ((uVar8 ^ uVar7) & uVar6 ^ uVar8) + uVar25 + 0xa9e3e905 + uVar9; + uVar9 = (uVar9 >> 0x1b | uVar9 * 0x20) + uVar7; + uVar6 = ((uVar7 ^ uVar9) & uVar8 ^ uVar7) + uVar22 + 0xfcefa3f8 + uVar6; + uVar6 = (uVar6 >> 0x17 | uVar6 * 0x200) + uVar9; + uVar8 = ((uVar9 ^ uVar6) & uVar7 ^ uVar9) + uVar8 + uVar18 + 0x676f02d9; + uVar8 = (uVar8 >> 0x12 | uVar8 * 0x4000) + uVar6; + uVar7 = (uVar9 & (uVar6 ^ uVar8) ^ uVar6) + uVar15 + 0x8d2a4c8a + uVar7; + uVar7 = (uVar7 * 0x100000 | uVar7 >> 0xc) + uVar8; + uVar9 = uVar9 + (uVar16 - 0x5c6be) + (uVar6 ^ uVar8 ^ uVar7); + uVar10 = (uVar9 >> 0x1c | uVar9 * 0x10) + uVar7; + uVar6 = (uVar8 ^ uVar7 ^ uVar10) + uVar4 + 0x8771f681 + uVar6; + uVar6 = (uVar6 >> 0x15 | uVar6 * 0x800) + uVar10; + uVar8 = (uVar7 ^ uVar10 ^ uVar6) + uVar23 + 0x6d9d6122 + uVar8; + uVar8 = (uVar8 >> 0x10 | uVar8 * 0x10000) + uVar6; + uVar7 = (uVar10 ^ uVar6 ^ uVar8) + uVar17 + 0xfde5380c + uVar7; + uVar9 = (uVar7 * 0x800000 | uVar7 >> 9) + uVar8; + uVar7 = (uVar6 ^ uVar8 ^ uVar9) + uVar5 + 0xa4beea44 + uVar10; + uVar10 = (uVar7 >> 0x1c | uVar7 * 0x10) + uVar9; + uVar6 = (uVar8 ^ uVar9 ^ uVar10) + uVar6 + uVar24 + 0x4bdecfa9; + uVar6 = (uVar6 >> 0x15 | uVar6 * 0x800) + uVar10; + uVar8 = (uVar9 ^ uVar10 ^ uVar6) + uVar8 + uVar18 + 0xf6bb4b60; + uVar7 = (uVar8 >> 0x10 | uVar8 * 0x10000) + uVar6; + uVar8 = (uVar10 ^ uVar6 ^ uVar7) + uVar13 + 0xbebfbc70 + uVar9; + uVar9 = (uVar8 * 0x800000 | uVar8 >> 9) + uVar7; + uVar8 = (uVar6 ^ uVar7 ^ uVar9) + uVar10 + uVar25 + 0x289b7ec6; + uVar8 = (uVar8 >> 0x1c | uVar8 * 0x10) + uVar9; + uVar6 = (uVar7 ^ uVar9 ^ uVar8) + uVar6 + uVar19 + 0xeaa127fa; + uVar10 = (uVar6 >> 0x15 | uVar6 * 0x800) + uVar8; + uVar6 = (uVar9 ^ uVar8 ^ uVar10) + uVar14 + 0xd4ef3085 + uVar7; + uVar7 = (uVar6 >> 0x10 | uVar6 * 0x10000) + uVar10; + uVar6 = (uVar8 ^ uVar10 ^ uVar7) + uVar9 + uVar1 + 0x4881d05; + uVar6 = (uVar6 * 0x800000 | uVar6 >> 9) + uVar7; + uVar8 = (uVar10 ^ uVar7 ^ uVar6) + uVar8 + uVar2 + 0xd9d4d039; + uVar9 = (uVar8 >> 0x1c | uVar8 * 0x10) + uVar6; + uVar8 = (uVar7 ^ uVar6 ^ uVar9) + uVar10 + uVar15 + 0xe6db99e5; + uVar8 = (uVar8 >> 0x15 | uVar8 * 0x800) + uVar9; + uVar7 = (uVar6 ^ uVar9 ^ uVar8) + uVar3 + 0x1fa27cf8 + uVar7; + uVar7 = (uVar7 >> 0x10 | uVar7 * 0x10000) + uVar8; + uVar6 = (uVar9 ^ uVar8 ^ uVar7) + uVar6 + uVar22 + 0xc4ac5665; + uVar10 = (uVar6 * 0x800000 | uVar6 >> 9) + uVar7; + uVar6 = ((~uVar8 | uVar10) ^ uVar7) + uVar19 + 0xf4292244 + uVar9; + uVar9 = (uVar6 >> 0x1a | uVar6 * 0x40) + uVar10; + uVar8 = ((~uVar7 | uVar9) ^ uVar10) + uVar18 + 0x432aff97 + uVar8; + uVar8 = (uVar8 >> 0x16 | uVar8 * 0x400) + uVar9; + uVar6 = ((~uVar10 | uVar8) ^ uVar9) + uVar17 + 0xab9423a7 + uVar7; + uVar7 = (uVar6 >> 0x11 | uVar6 * 0x8000) + uVar8; + uVar6 = ((~uVar9 | uVar7) ^ uVar8) + uVar10 + uVar16 + 0xfc93a039; + uVar6 = (uVar6 * 0x200000 | uVar6 >> 0xb) + uVar7; + uVar9 = ((~uVar8 | uVar6) ^ uVar7) + uVar9 + uVar15 + 0x655b59c3; + uVar11 = (uVar9 >> 0x1a | uVar9 * 0x40) + uVar6; + uVar8 = ((~uVar7 | uVar11) ^ uVar6) + uVar8 + uVar14 + 0x8f0ccc92; + uVar10 = (uVar8 >> 0x16 | uVar8 * 0x400) + uVar11; + uVar8 = ((~uVar6 | uVar10) ^ uVar11) + (uVar13 - 0x100b83) + uVar7; + uVar7 = (uVar8 >> 0x11 | uVar8 * 0x8000) + uVar10; + uVar8 = ((~uVar11 | uVar7) ^ uVar10) + uVar5 + 0x85845dd1 + uVar6; + uVar9 = (uVar8 * 0x200000 | uVar8 >> 0xb) + uVar7; + uVar8 = ((~uVar10 | uVar9) ^ uVar7) + uVar11 + uVar4 + 0x6fa87e4f; + uVar6 = (uVar8 >> 0x1a | uVar8 * 0x40) + uVar9; + uVar8 = ((~uVar7 | uVar6) ^ uVar9) + uVar10 + uVar3 + 0xfe2ce6e0; + uVar8 = (uVar8 >> 0x16 | uVar8 * 0x400) + uVar6; + uVar7 = ((~uVar9 | uVar8) ^ uVar6) + uVar7 + uVar1 + 0xa3014314; + uVar7 = (uVar7 >> 0x11 | uVar7 * 0x8000) + uVar8; + uVar9 = ((~uVar6 | uVar7) ^ uVar8) + uVar25 + 0x4e0811a1 + uVar9; + uVar9 = (uVar9 * 0x200000 | uVar9 >> 0xb) + uVar7; + uVar6 = ((~uVar8 | uVar9) ^ uVar7) + uVar6 + uVar24 + 0xf7537e82; + uVar11 = (uVar6 >> 0x1a | uVar6 * 0x40) + uVar9; + uVar8 = ((~uVar7 | uVar11) ^ uVar9) + uVar8 + uVar23 + 0xbd3af235; + uVar10 = (uVar8 >> 0x16 | uVar8 * 0x400) + uVar11; + uVar8 = ((~uVar9 | uVar10) ^ uVar11) + uVar7 + uVar22 + 0x2ad7d2bb; + uVar6 = (uVar8 >> 0x11 | uVar8 * 0x8000) + uVar10; + uVar8 = ((~uVar11 | uVar6) ^ uVar10) + uVar2 + 0xeb86d391 + uVar9; + *state = uVar11 + *state; + state[2] = uVar20 + uVar6; + state[3] = uVar21 + uVar10; + state[1] = uVar12 + uVar6 + (uVar8 * 0x200000 | uVar8 >> 0xb); + memset(block,0,0x40); + return; +} + + + +void wpa_MD5Init(Bl_MD5_CTX *context) + +{ + context->state[0] = 0x67452301; + context->state[1] = 0xefcdab89; + context->state[2] = 0x98badcfe; + context->count[1] = 0; + context->count[0] = 0; + context->state[3] = 0x10325476; + return; +} + + + +void wpa_MD5Update(Bl_MD5_CTX *context,UINT8 *input,UINT32 inputLen) + +{ + uint uVar1; + uint __n; + + uVar1 = context->count[0]; + __n = uVar1 + inputLen * 8; + context->count[0] = __n; + uVar1 = uVar1 >> 3 & 0x3f; + if (__n < inputLen * 8) { + context->count[1] = context->count[1] + 1; + } + context->count[1] = (inputLen >> 0x1d) + context->count[1]; + __n = 0x40 - uVar1; + if (inputLen < __n) { + __n = 0; + } + else { + memcpy(context->buffer + uVar1,input,__n); + wpa_MD5Transform((UINT32 *)context,(ulong *)context->buffer); + while (__n + 0x3f < inputLen) { + memcpy(context->scratch,input + __n,0x40); + wpa_MD5Transform((UINT32 *)context,context->scratch); + __n = __n + 0x40; + } + uVar1 = 0; + } + memcpy(context->buffer + uVar1,input + __n,inputLen - __n); + return; +} + + + +void wpa_MD5Final(uchar *digest,Bl_MD5_CTX *context) + +{ + uint uVar1; + int iVar2; + UINT8 aUStack24 [4]; + uchar bits [8]; + + memcpy(aUStack24,context->count,8); + uVar1 = context->count[0] >> 3 & 0x3f; + if (uVar1 < 0x38) { + iVar2 = 0x38; + } + else { + iVar2 = 0x78; + } + wpa_MD5Update(context,PADDING,iVar2 - uVar1); + wpa_MD5Update(context,aUStack24,8); + memcpy(digest,context,0x10); + memset(context,0,0x98); + return; +} + + + +int rijndaelKeySetupEnc(u32 *rk,u8 *cipherKey,int keyBits) + +{ + uint uVar1; + uint uVar2; + u32 *puVar3; + u32 *puVar4; + + *rk = (uint)*cipherKey << 0x18 ^ (uint)cipherKey[1] << 0x10 ^ (uint)cipherKey[3] ^ + (uint)cipherKey[2] << 8; + rk[1] = (uint)cipherKey[4] << 0x18 ^ (uint)cipherKey[5] << 0x10 ^ (uint)cipherKey[7] ^ + (uint)cipherKey[6] << 8; + rk[2] = (uint)cipherKey[8] << 0x18 ^ (uint)cipherKey[9] << 0x10 ^ (uint)cipherKey[0xb] ^ + (uint)cipherKey[10] << 8; + rk[3] = (uint)cipherKey[0xc] << 0x18 ^ (uint)cipherKey[0xd] << 0x10 ^ (uint)cipherKey[0xf] ^ + (uint)cipherKey[0xe] << 8; + if (keyBits == 0x80) { + puVar3 = rcon; + puVar4 = rk + 0x24; + while( true ) { + uVar1 = *puVar3; + uVar2 = rk[3]; + puVar3 = puVar3 + 1; + uVar1 = *rk ^ uVar1 ^ (uint)Te4[uVar2 >> 0x18] ^ (uint)Te4[uVar2 & 0xff] << 8 ^ + (uint)Te4[uVar2 >> 0x10 & 0xff] << 0x18 ^ (uint)Te4[uVar2 >> 8 & 0xff] << 0x10; + rk[4] = uVar1; + uVar1 = uVar1 ^ rk[1]; + rk[5] = uVar1; + uVar1 = uVar1 ^ rk[2]; + rk[6] = uVar1; + rk[7] = uVar1 ^ uVar2; + if (rk == puVar4) break; + rk = rk + 4; + } + return 10; + } + return 0; +} + + + +void rijndael_set_key(rijndael_ctx *ctx,u8 *key,int bits,int encrypt) + +{ + int iVar1; + u32 *rk; + int iVar2; + u32 uVar3; + u32 *puVar4; + uint uVar5; + int *piVar6; + + rk = ctx->key; + iVar2 = rijndaelKeySetupEnc(rk,key,bits); + ctx->Nr = iVar2; + if (encrypt == 0) { + ctx->decrypt = 1; + if (iVar2 == 0) { + iVar2 = rijndaelKeySetupEnc(rk,key,bits); + } + puVar4 = rk; + piVar6 = &ctx->decrypt + iVar2 * 4; + while (encrypt < iVar2 * 4 - encrypt) { + uVar3 = *puVar4; + encrypt = encrypt + 4; + *puVar4 = piVar6[2]; + piVar6[2] = uVar3; + uVar3 = puVar4[1]; + puVar4[1] = piVar6[3]; + piVar6[3] = uVar3; + uVar3 = puVar4[2]; + puVar4[2] = piVar6[4]; + piVar6[4] = uVar3; + uVar3 = puVar4[3]; + puVar4[3] = piVar6[5]; + piVar6[5] = uVar3; + puVar4 = puVar4 + 4; + piVar6 = piVar6 + -4; + } + iVar1 = 1; + while (iVar1 < iVar2) { + puVar4 = rk + 4; + uVar5 = *puVar4; + iVar1 = iVar1 + 1; + *puVar4 = Td2[Te4[uVar5 >> 8 & 0xff]] ^ + Td0[Te4[uVar5 >> 0x18]] ^ Td3[Te4[uVar5 & 0xff]] ^ Td1[Te4[uVar5 >> 0x10 & 0xff]]; + uVar5 = rk[5]; + rk[5] = Td2[Te4[uVar5 >> 8 & 0xff]] ^ + Td0[Te4[uVar5 >> 0x18]] ^ Td3[Te4[uVar5 & 0xff]] ^ Td1[Te4[uVar5 >> 0x10 & 0xff]]; + uVar5 = rk[6]; + rk[6] = Td2[Te4[uVar5 >> 8 & 0xff]] ^ + Td0[Te4[uVar5 >> 0x18]] ^ Td3[Te4[uVar5 & 0xff]] ^ Td1[Te4[uVar5 >> 0x10 & 0xff]]; + uVar5 = rk[7]; + rk[7] = Td2[Te4[uVar5 >> 8 & 0xff]] ^ + Td0[Te4[uVar5 >> 0x18]] ^ Td3[Te4[uVar5 & 0xff]] ^ Td1[Te4[uVar5 >> 0x10 & 0xff]]; + rk = puVar4; + } + } + else { + ctx->decrypt = 0; + } + return; +} + + + +void rijndael_decrypt(rijndael_ctx *ctx,u8 *src,u8 *dst) + +{ + byte bVar1; + byte bVar2; + byte bVar3; + u32 *puVar4; + uint uVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint uVar9; + uint uVar10; + uint uVar11; + uint uVar12; + int iVar13; + uint uVar14; + int iVar15; + uint uVar16; + uint uVar17; + uint uVar18; + uint uVar19; + + uVar10 = (uint)*src << 0x18 ^ (uint)src[1] << 0x10 ^ (uint)src[3] ^ (uint)src[2] << 8 ^ + ctx->key[0]; + uVar16 = (uint)src[4] << 0x18 ^ (uint)src[5] << 0x10 ^ (uint)src[7] ^ (uint)src[6] << 8 ^ + ctx->key[1]; + uVar14 = (uint)src[8] << 0x18 ^ (uint)src[9] << 0x10 ^ (uint)src[0xb] ^ (uint)src[10] << 8 ^ + ctx->key[2]; + uVar11 = (uint)src[0xc] << 0x18 ^ (uint)src[0xd] << 0x10 ^ (uint)src[0xf] ^ (uint)src[0xe] << 8 ^ + ctx->key[3]; + iVar13 = ctx->Nr >> 1; + puVar4 = ctx->key; + iVar15 = iVar13; + while( true ) { + uVar5 = Td0[uVar10 >> 0x18] ^ Td3[uVar16 & 0xff] ^ puVar4[4] ^ + *(uint *)((int)Td1 + (uVar11 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Td2 + (uVar14 >> 6 & 0x3fc)); + iVar15 = iVar15 + -1; + uVar17 = uVar5 >> 0x10 & 0xff; + uVar6 = Td0[uVar16 >> 0x18] ^ Td3[uVar14 & 0xff] ^ puVar4[5] ^ + *(uint *)((int)Td1 + (uVar10 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Td2 + (uVar11 >> 6 & 0x3fc)); + uVar8 = Td0[uVar14 >> 0x18] ^ Td3[uVar11 & 0xff] ^ puVar4[6] ^ + *(uint *)((int)Td1 + (uVar16 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Td2 + (uVar10 >> 6 & 0x3fc)); + uVar12 = Td0[uVar11 >> 0x18] ^ Td3[uVar10 & 0xff] ^ puVar4[7] ^ + *(uint *)((int)Td1 + (uVar14 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Td2 + (uVar16 >> 6 & 0x3fc)); + uVar19 = uVar12 >> 0x10 & 0xff; + uVar18 = uVar8 >> 8 & 0xff; + uVar10 = puVar4[8]; + uVar16 = uVar12 >> 8 & 0xff; + uVar11 = uVar6 >> 0x10 & 0xff; + uVar14 = uVar5 >> 8 & 0xff; + uVar9 = uVar8 >> 0x10 & 0xff; + uVar7 = uVar6 >> 8 & 0xff; + if (iVar15 == 0) break; + uVar10 = Td0[uVar5 >> 0x18] ^ Td3[uVar6 & 0xff] ^ uVar10 ^ Td1[uVar19] ^ Td2[uVar18]; + uVar16 = Td0[uVar6 >> 0x18] ^ Td3[uVar8 & 0xff] ^ puVar4[9] ^ Td1[uVar17] ^ Td2[uVar16]; + uVar14 = Td0[uVar8 >> 0x18] ^ Td3[uVar12 & 0xff] ^ puVar4[10] ^ Td1[uVar11] ^ Td2[uVar14]; + uVar11 = Td0[uVar12 >> 0x18] ^ Td3[uVar5 & 0xff] ^ puVar4[0xb] ^ Td1[uVar9] ^ Td2[uVar7]; + puVar4 = puVar4 + 8; + } + puVar4 = ctx->key + iVar13 * 8; + uVar10 = (uint)Td4[uVar5 >> 0x18] << 0x18 ^ (uint)Td4[uVar19] << 0x10 ^ (uint)Td4[uVar6 & 0xff] ^ + (uint)Td4[uVar18] << 8 ^ uVar10; + *dst = (u8)(uVar10 >> 0x18); + dst[1] = (u8)(uVar10 >> 0x10); + dst[2] = (u8)(uVar10 >> 8); + bVar1 = Td4[uVar17]; + bVar2 = Td4[uVar6 >> 0x18]; + bVar3 = Td4[uVar8 & 0xff]; + dst[3] = (u8)uVar10; + uVar10 = (uint)bVar2 << 0x18 ^ (uint)bVar1 << 0x10 ^ (uint)bVar3 ^ (uint)Td4[uVar16] << 8 ^ + puVar4[1]; + dst[4] = (u8)(uVar10 >> 0x18); + dst[5] = (u8)(uVar10 >> 0x10); + dst[6] = (u8)(uVar10 >> 8); + dst[7] = (u8)uVar10; + bVar1 = Td4[uVar12 >> 0x18]; + uVar10 = (uint)Td4[uVar8 >> 0x18] << 0x18 ^ (uint)Td4[uVar11] << 0x10 ^ (uint)Td4[uVar12 & 0xff] ^ + (uint)Td4[uVar14] << 8 ^ puVar4[2]; + dst[8] = (u8)(uVar10 >> 0x18); + dst[9] = (u8)(uVar10 >> 0x10); + dst[0xb] = (u8)uVar10; + bVar2 = Td4[uVar9]; + dst[10] = (u8)(uVar10 >> 8); + uVar10 = (uint)bVar1 << 0x18 ^ (uint)bVar2 << 0x10 ^ (uint)Td4[uVar5 & 0xff] ^ + (uint)Td4[uVar7] << 8 ^ puVar4[3]; + dst[0xc] = (u8)(uVar10 >> 0x18); + dst[0xd] = (u8)(uVar10 >> 0x10); + dst[0xe] = (u8)(uVar10 >> 8); + dst[0xf] = (u8)uVar10; + return; +} + + + +void rijndael_encrypt(rijndael_ctx *ctx,u8 *src,u8 *dst) + +{ + byte bVar1; + byte bVar2; + byte bVar3; + u32 *puVar4; + uint uVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint uVar9; + uint uVar10; + uint uVar11; + uint uVar12; + int iVar13; + uint uVar14; + int iVar15; + uint uVar16; + uint uVar17; + uint uVar18; + uint uVar19; + + uVar10 = (uint)*src << 0x18 ^ (uint)src[1] << 0x10 ^ (uint)src[3] ^ (uint)src[2] << 8 ^ + ctx->key[0]; + uVar16 = (uint)src[4] << 0x18 ^ (uint)src[5] << 0x10 ^ (uint)src[7] ^ (uint)src[6] << 8 ^ + ctx->key[1]; + uVar14 = (uint)src[8] << 0x18 ^ (uint)src[9] << 0x10 ^ (uint)src[0xb] ^ (uint)src[10] << 8 ^ + ctx->key[2]; + uVar11 = (uint)src[0xc] << 0x18 ^ (uint)src[0xd] << 0x10 ^ (uint)src[0xf] ^ (uint)src[0xe] << 8 ^ + ctx->key[3]; + iVar13 = ctx->Nr >> 1; + puVar4 = ctx->key; + iVar15 = iVar13; + while( true ) { + uVar8 = Te0[uVar10 >> 0x18] ^ Te3[uVar11 & 0xff] ^ puVar4[4] ^ + *(uint *)((int)Te1 + (uVar16 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Te2 + (uVar14 >> 6 & 0x3fc)); + iVar15 = iVar15 + -1; + uVar6 = Te0[uVar16 >> 0x18] ^ Te3[uVar10 & 0xff] ^ puVar4[5] ^ + *(uint *)((int)Te1 + (uVar14 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Te2 + (uVar11 >> 6 & 0x3fc)); + uVar5 = Te0[uVar14 >> 0x18] ^ Te3[uVar16 & 0xff] ^ puVar4[6] ^ + *(uint *)((int)Te1 + (uVar11 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Te2 + (uVar10 >> 6 & 0x3fc)); + uVar12 = Te0[uVar11 >> 0x18] ^ Te3[uVar14 & 0xff] ^ puVar4[7] ^ + *(uint *)((int)Te1 + (uVar10 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Te2 + (uVar16 >> 6 & 0x3fc)); + uVar19 = uVar6 >> 0x10 & 0xff; + uVar18 = uVar5 >> 8 & 0xff; + uVar10 = puVar4[8]; + uVar17 = uVar5 >> 0x10 & 0xff; + uVar16 = uVar12 >> 8 & 0xff; + uVar11 = uVar12 >> 0x10 & 0xff; + uVar14 = uVar8 >> 8 & 0xff; + uVar9 = uVar8 >> 0x10 & 0xff; + uVar7 = uVar6 >> 8 & 0xff; + if (iVar15 == 0) break; + uVar10 = Te0[uVar8 >> 0x18] ^ Te3[uVar12 & 0xff] ^ uVar10 ^ Te1[uVar19] ^ Te2[uVar18]; + uVar16 = Te0[uVar6 >> 0x18] ^ Te3[uVar8 & 0xff] ^ puVar4[9] ^ Te1[uVar17] ^ Te2[uVar16]; + uVar14 = Te0[uVar5 >> 0x18] ^ Te3[uVar6 & 0xff] ^ puVar4[10] ^ Te1[uVar11] ^ Te2[uVar14]; + uVar11 = Te0[uVar12 >> 0x18] ^ Te3[uVar5 & 0xff] ^ puVar4[0xb] ^ Te1[uVar9] ^ Te2[uVar7]; + puVar4 = puVar4 + 8; + } + puVar4 = ctx->key + iVar13 * 8; + uVar10 = (uint)Te4[uVar8 >> 0x18] << 0x18 ^ (uint)Te4[uVar19] << 0x10 ^ (uint)Te4[uVar12 & 0xff] ^ + (uint)Te4[uVar18] << 8 ^ uVar10; + *dst = (u8)(uVar10 >> 0x18); + dst[1] = (u8)(uVar10 >> 0x10); + dst[2] = (u8)(uVar10 >> 8); + bVar1 = Te4[uVar17]; + bVar2 = Te4[uVar6 >> 0x18]; + bVar3 = Te4[uVar8 & 0xff]; + dst[3] = (u8)uVar10; + uVar10 = (uint)bVar2 << 0x18 ^ (uint)bVar1 << 0x10 ^ (uint)bVar3 ^ (uint)Te4[uVar16] << 8 ^ + puVar4[1]; + dst[4] = (u8)(uVar10 >> 0x18); + dst[5] = (u8)(uVar10 >> 0x10); + dst[6] = (u8)(uVar10 >> 8); + dst[7] = (u8)uVar10; + bVar1 = Te4[uVar12 >> 0x18]; + uVar10 = (uint)Te4[uVar5 >> 0x18] << 0x18 ^ (uint)Te4[uVar11] << 0x10 ^ (uint)Te4[uVar6 & 0xff] ^ + (uint)Te4[uVar14] << 8 ^ puVar4[2]; + dst[8] = (u8)(uVar10 >> 0x18); + dst[9] = (u8)(uVar10 >> 0x10); + dst[0xb] = (u8)uVar10; + bVar2 = Te4[uVar9]; + dst[10] = (u8)(uVar10 >> 8); + uVar10 = (uint)bVar1 << 0x18 ^ (uint)bVar2 << 0x10 ^ (uint)Te4[uVar5 & 0xff] ^ + (uint)Te4[uVar7] << 8 ^ puVar4[3]; + dst[0xc] = (u8)(uVar10 >> 0x18); + dst[0xd] = (u8)(uVar10 >> 0x10); + dst[0xe] = (u8)(uVar10 >> 8); + dst[0xf] = (u8)uVar10; + return; +} + + + +void Bl_SHA1ProcessMessageBlock(Bl_SHA1_CTX *context) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + UINT32 *pUVar4; + uint uVar5; + UINT32 *pUVar6; + UINT32 *pUVar7; + uint uVar8; + UINT32 UVar9; + uint uVar10; + uint uVar11; + UINT32 UVar12; + uint uVar13; + uint uVar14; + uint uVar15; + UINT32 UVar16; + + pUVar4 = context->Scratch; + pUVar6 = pUVar4; + do { + pUVar7 = pUVar6 + 1; + *pUVar6 = (uint)*(byte *)(pUVar6 + 0x10) << 0x18 | (uint)*(byte *)((int)pUVar6 + 0x41) << 0x10 | + (uint)*(byte *)((int)pUVar6 + 0x42) << 8 | (uint)*(byte *)((int)pUVar6 + 0x43); + pUVar6 = pUVar7; + } while ((UINT32 *)context->Message_Block != pUVar7); + uVar11 = 0; + uVar8 = context->Intermediate_Hash[2]; + uVar10 = context->Intermediate_Hash[0]; + UVar12 = context->Intermediate_Hash[1]; + uVar2 = context->Intermediate_Hash[3]; + UVar16 = context->Intermediate_Hash[4]; + do { + uVar13 = uVar2; + uVar3 = uVar10; + uVar2 = uVar8; + if ((uVar11 & 0x30) == 0) { + UVar9 = context->Scratch[uVar11]; + } + else { + uVar8 = pUVar4[uVar11 + 0xd & 0xf] ^ pUVar4[uVar11 + 8 & 0xf] ^ pUVar4[uVar11 & 0xf] ^ + pUVar4[uVar11 + 2 & 0xf]; + UVar9 = uVar8 >> 0x1f | uVar8 << 1; + pUVar4[uVar11 & 0xf] = UVar9; + } + uVar11 = uVar11 + 1; + uVar10 = UVar9 + ((uVar2 ^ uVar13) & UVar12 ^ uVar13) + + (uVar3 << 5 | uVar3 >> 0x1b) + 0x5a827999 + UVar16; + uVar8 = UVar12 << 0x1e | UVar12 >> 2; + UVar12 = uVar3; + UVar16 = uVar13; + } while (uVar11 != 0x14); + do { + uVar14 = uVar10; + uVar1 = uVar2; + uVar2 = uVar11 + 0xd; + uVar10 = uVar11 + 8; + uVar15 = uVar11 & 0xf; + uVar5 = uVar11 + 2; + uVar11 = uVar11 + 1; + uVar2 = pUVar4[uVar2 & 0xf] ^ pUVar4[uVar10 & 0xf] ^ pUVar4[uVar15] ^ pUVar4[uVar5 & 0xf]; + uVar2 = uVar2 >> 0x1f | uVar2 << 1; + pUVar4[uVar15] = uVar2; + uVar10 = (uVar3 ^ uVar8 ^ uVar1) + (uVar14 << 5 | uVar14 >> 0x1b) + 0x6ed9eba1 + uVar2 + uVar13; + uVar5 = uVar3 << 0x1e | uVar3 >> 2; + uVar2 = uVar8; + uVar3 = uVar14; + uVar8 = uVar5; + uVar13 = uVar1; + } while (uVar11 != 0x28); + do { + uVar8 = uVar10; + uVar13 = uVar11 + 0xd; + uVar10 = uVar11 + 8; + uVar15 = uVar11 & 0xf; + uVar3 = uVar11 + 2; + uVar11 = uVar11 + 1; + uVar10 = pUVar4[uVar13 & 0xf] ^ pUVar4[uVar10 & 0xf] ^ pUVar4[uVar15] ^ pUVar4[uVar3 & 0xf]; + uVar10 = uVar10 >> 0x1f | uVar10 << 1; + pUVar4[uVar15] = uVar10; + uVar10 = ((uVar5 | uVar2) & uVar14 | uVar5 & uVar2) + (uVar8 << 5 | uVar8 >> 0x1b) + 0x8f1bbcdc + + uVar10 + uVar1; + uVar13 = uVar14 << 0x1e | uVar14 >> 2; + uVar1 = uVar2; + uVar14 = uVar8; + uVar3 = uVar2; + uVar2 = uVar5; + uVar5 = uVar13; + } while (uVar11 != 0x3c); + do { + uVar15 = uVar13; + uVar5 = uVar2; + uVar1 = uVar10; + uVar10 = uVar11 + 0xd; + uVar13 = uVar11 + 8; + uVar2 = uVar11 & 0xf; + uVar14 = uVar11 + 2; + uVar11 = uVar11 + 1; + uVar10 = pUVar4[uVar10 & 0xf] ^ pUVar4[uVar13 & 0xf] ^ pUVar4[uVar2] ^ pUVar4[uVar14 & 0xf]; + uVar10 = uVar10 >> 0x1f | uVar10 << 1; + pUVar4[uVar2] = uVar10; + uVar10 = uVar10 + (uVar8 ^ uVar15 ^ uVar5) + (uVar1 << 5 | uVar1 >> 0x1b) + 0xca62c1d6 + uVar3; + uVar13 = uVar8 << 0x1e | uVar8 >> 2; + uVar8 = uVar1; + uVar3 = uVar5; + uVar2 = uVar15; + } while (uVar11 != 0x50); + context->Message_Block_Index = 0; + UVar12 = context->Intermediate_Hash[1]; + context->Intermediate_Hash[0] = uVar10 + context->Intermediate_Hash[0]; + context->Intermediate_Hash[1] = uVar1 + UVar12; + context->Intermediate_Hash[2] = uVar13 + context->Intermediate_Hash[2]; + context->Intermediate_Hash[3] = uVar15 + context->Intermediate_Hash[3]; + context->Intermediate_Hash[4] = uVar5 + context->Intermediate_Hash[4]; + return; +} + + + +int Bl_SHA1Init(Bl_SHA1_CTX *context) + +{ + if (context != (Bl_SHA1_CTX *)0x0) { + context->Intermediate_Hash[0] = 0x67452301; + context->Intermediate_Hash[1] = 0xefcdab89; + context->Intermediate_Hash[2] = 0x98badcfe; + context->Intermediate_Hash[3] = 0x10325476; + context->Length_Low = 0; + context->Length_High = 0; + context->Intermediate_Hash[4] = 0xc3d2e1f0; + *(undefined4 *)&context->Message_Block_Index = 0; + return 0; + } + return 1; +} + + + +int Bl_SHA1Final(Bl_SHA1_CTX *context,UINT8 *Message_Digest) + +{ + short sVar1; + ushort uVar2; + int iVar3; + uint uVar4; + UINT32 UVar5; + SINT16 *pSVar6; + + uVar4 = 1; + if (((context != (Bl_SHA1_CTX *)0x0) && (Message_Digest != (UINT8 *)0x0)) && + (uVar4 = (uint)context->Corrupted, context->Corrupted == 0)) { + if (context->Computed == '\0') { + iVar3 = (int)context->Message_Block_Index; + context->Message_Block_Index = (SINT16)((uint)((iVar3 + 1) * 0x10000) >> 0x10); + context->Message_Block[iVar3] = -0x80; + if (iVar3 < 0x38) { + while( true ) { + sVar1 = context->Message_Block_Index; + if (0x37 < (int)sVar1) break; + context->Message_Block_Index = sVar1 + 1; + context->Message_Block[(int)sVar1] = '\0'; + } + } + else { + while( true ) { + sVar1 = context->Message_Block_Index; + if (0x3f < (int)sVar1) break; + context->Message_Block_Index = sVar1 + 1; + context->Message_Block[(int)sVar1] = '\0'; + } + Bl_SHA1ProcessMessageBlock(context); + while( true ) { + sVar1 = context->Message_Block_Index; + if (0x37 < (int)sVar1) break; + context->Message_Block_Index = sVar1 + 1; + context->Message_Block[(int)sVar1] = '\0'; + } + } + UVar5 = context->Length_High; + *(ushort *)(context->Message_Block + 0x3a) = + *(ushort *)&context->Length_High << 8 | *(ushort *)&context->Length_High >> 8; + context->Message_Block[0x39] = (UINT8)(UVar5 >> 0x10); + uVar2 = *(ushort *)&context->Length_Low; + context->Message_Block[0x38] = (UINT8)(UVar5 >> 0x18); + UVar5 = context->Length_Low; + *(ushort *)(context->Message_Block + 0x3e) = uVar2 << 8 | uVar2 >> 8; + context->Message_Block[0x3d] = (UINT8)(UVar5 >> 0x10); + context->Message_Block[0x3c] = (UINT8)(UVar5 >> 0x18); + Bl_SHA1ProcessMessageBlock(context); + pSVar6 = (SINT16 *)context->Message_Block; + do { + *(UINT8 *)pSVar6 = '\0'; + pSVar6 = (SINT16 *)((int)pSVar6 + 1); + } while (&context->Message_Block_Index != pSVar6); + context->Length_Low = 0; + context->Length_High = 0; + context->Computed = '\x01'; + } + uVar4 = 0; + do { + Message_Digest[uVar4] = + (UINT8)(*(uint *)((int)context->Intermediate_Hash + (uVar4 & 0xfffffffc)) >> + ((~uVar4 & 3) << 3)); + uVar4 = uVar4 + 1; + } while (uVar4 != 0x14); + memset(context,0,0xa0); + return 0; + } + return uVar4; +} + + + +int Bl_SHA1Update(Bl_SHA1_CTX *context,UINT8 *message_array,uint length) + +{ + short sVar1; + UINT8 *pUVar2; + uint uVar3; + UINT32 UVar4; + int iVar5; + + if (length == 0) { + return 0; + } + uVar3 = 1; + if ((context != (Bl_SHA1_CTX *)0x0) && (message_array != (UINT8 *)0x0)) { + if (context->Computed == '\0') { + uVar3 = (uint)context->Corrupted; + if (context->Corrupted == 0) { + pUVar2 = message_array + length; + while ((message_array != pUVar2 && (context->Corrupted == '\0'))) { + sVar1 = context->Message_Block_Index; + iVar5 = ((int)sVar1 + 1) * 0x10000; + context->Message_Block_Index = (SINT16)((uint)iVar5 >> 0x10); + context->Message_Block[(int)sVar1] = *message_array; + UVar4 = context->Length_Low + 8; + context->Length_Low = UVar4; + if ((UVar4 == 0) && + (UVar4 = context->Length_High + 1, context->Length_High = UVar4, UVar4 == 0)) { + context->Corrupted = '\x01'; + } + if (iVar5 >> 0x10 == 0x40) { + Bl_SHA1ProcessMessageBlock(context); + } + message_array = message_array + 1; + } + uVar3 = 0; + } + } + else { + context->Corrupted = '\x03'; + uVar3 = 3; + } + } + return uVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +Status_e supplicantRestoreDefaults(void) + +{ + char "supplicantRestoreDefaults" [26]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantRestoreDefaults"); + pmkCacheInit(); + pmkCacheRomInit(); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307af3c); + return FW_SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantFuncInit(void) + +{ + char "supplicantFuncInit" [19]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantFuncInit"); + supplicantRestoreDefaults(); + dbg_test_print("%dms : Leave: %s\n",0x2307af58); + return; +} + + + +void ap_setpsk(cm_ConnectionInfo_t *connPtr,CHAR *ssid,CHAR *passphrase) + +{ + apInfo_t *paVar1; + size_t sVar2; + + paVar1 = cm_GetApInfo(connPtr); + if (paVar1 != (apInfo_t *)0x0) { + sVar2 = strlen(ssid); + (paVar1->bssConfig).comData.SsIdLen = (IEEEtypes_Len_t)sVar2; + memcpy(&(paVar1->bssConfig).comData,ssid,0x20); + sVar2 = strlen(passphrase); + (paVar1->bssConfig).RsnConfig.PSKPassPhraseLen = (UINT8)sVar2; + memcpy((paVar1->bssConfig).RsnConfig.PSKPassPhrase,passphrase,0x40); + return; + } + return; +} + + + +void ap_resetConfiguration(cm_ConnectionInfo_t *connPtr) + +{ + ushort uVar1; + apInfo_t *paVar2; + apSpecificData_t *paVar3; + size_t sVar4; + + paVar2 = cm_GetApInfo(connPtr); + paVar3 = cm_GetApData(connPtr); + if ((paVar2 != (apInfo_t *)0x0) && (paVar3 != (apSpecificData_t *)0x0)) { + sVar4 = strlen("Marvell Micro AP"); + (paVar2->bssConfig).comData.SsIdLen = (IEEEtypes_Len_t)sVar4; + memcpy(&(paVar2->bssConfig).comData,"Marvell Micro AP",0x20); + (paVar2->bssData).updatePassPhrase = 1; + memset(&(paVar2->bssConfig).RsnConfig,0,0x7c); + uVar1 = *(ushort *)&(paVar2->bssConfig).RsnConfig; + (paVar2->bssConfig).RsnConfig.AuthKeyCount = 1; + *(ushort *)&(paVar2->bssConfig).RsnConfig = uVar1 & 0xf7 | 0x108; + *(ushort *)&(paVar2->bssConfig).RsnConfig.wpa2UcstCipher = + *(ushort *)&(paVar2->bssConfig).RsnConfig.wpa2UcstCipher & 0xf7 | 0x108; + (paVar2->bssConfig).RsnConfig.MaxPwsHskRetries = '\x03'; + (paVar2->bssConfig).RsnConfig.MaxGrpHskRetries = '\x03'; + (paVar2->bssConfig).RsnConfig.PwsHskTimeOut = 100; + (paVar2->bssConfig).RsnConfig.GrpHskTimeOut = 100; + (paVar2->bssConfig).RsnConfig.GrpReKeyTime = 0x15180; + } + return; +} + + + +void InitializeAp(cm_ConnectionInfo_t *connPtr) + +{ + ushort uVar1; + apInfo_t *paVar2; + apSpecificData_t *paVar3; + size_t sVar4; + + paVar2 = cm_GetApInfo(connPtr); + paVar3 = cm_GetApData(connPtr); + if ((paVar2 != (apInfo_t *)0x0) && (paVar3 != (apSpecificData_t *)0x0)) { + sVar4 = strlen("Marvell Micro AP"); + (paVar2->bssConfig).comData.SsIdLen = (IEEEtypes_Len_t)sVar4; + memcpy(&(paVar2->bssConfig).comData,"Marvell Micro AP",0x20); + (paVar2->bssData).updatePassPhrase = 1; + memset(&(paVar2->bssConfig).RsnConfig,0,0x7c); + uVar1 = *(ushort *)&(paVar2->bssConfig).RsnConfig; + (paVar2->bssConfig).RsnConfig.AuthKeyCount = 1; + *(ushort *)&(paVar2->bssConfig).RsnConfig = uVar1 & 0xf7 | 0x108; + *(ushort *)&(paVar2->bssConfig).RsnConfig.wpa2UcstCipher = + *(ushort *)&(paVar2->bssConfig).RsnConfig.wpa2UcstCipher & 0xf7 | 0x108; + (paVar2->bssConfig).RsnConfig.MaxPwsHskRetries = '\x03'; + (paVar2->bssConfig).RsnConfig.MaxGrpHskRetries = '\x03'; + (paVar2->bssConfig).RsnConfig.PwsHskTimeOut = 100; + (paVar2->bssConfig).RsnConfig.GrpHskTimeOut = 100; + (paVar2->bssConfig).RsnConfig.GrpReKeyTime = 0x15180; + } + return; +} + + + +int bl60x_check_mac_status(int *is_ok) + +{ + int iVar1; + dump_data_t *pdVar2; + + iVar1 = 0; + pdVar2 = dump_data_poll; + while( true ) { + if ((int)(uint)dump_data_ptr <= iVar1) { + *is_ok = 0; + return 0; + } + if (pdVar2->mac_debugRegHWSM2 != 0x8801e000) break; + iVar1 = iVar1 + 1; + pdVar2 = pdVar2 + 1; + } + *is_ok = 1; + return 0; +} + + + +void helper_record_dump(void) + +{ + uint32_t *puVar1; + dump_data_t *pdVar2; + int iVar3; + + pdVar2 = dump_data_poll; + puts("========= helper_record_dump\r\n"); + iVar3 = 0; + while (iVar3 < (int)(uint)dump_data_ptr) { + printf("[%d] time %ld, func %s\r\n",iVar3,pdVar2->time,pdVar2->func_name); + printf("MAC: %08lx: rxControlCs %d,txControlCs %d,macControlCs %d\r\n",pdVar2->mac_debugRegHWSM2 + ,pdVar2->mac_debugRegHWSM2 & 0x3f,pdVar2->mac_debugRegHWSM2 >> 8 & 0x1ff, + (uint)*(byte *)((int)&pdVar2->mac_debugRegHWSM2 + 3)); + iVar3 = iVar3 + 1; + printf("MAC: Coex %04x,Backoff %04x,MPIF %04x,MPIF2 %04x\r\n",(uint)pdVar2->mac_debugPortCoex, + (uint)pdVar2->mac_debugPortBackoff,(uint)pdVar2->mac_debugPortMacPhyIf, + (uint)pdVar2->mac_debugPortMacPhyIf2); + printf("PHY: MainFSM %04x,TDTX %04x,DSSSCCK1 %04x,DSSSCCKTx %04x\r\n", + (uint)pdVar2->phy_debugPortMainFSM,(uint)pdVar2->phy_debugPortTDTX, + (uint)pdVar2->phy_debugPortDSSSCCK1,(uint)pdVar2->phy_debugPortDSSSCCKTx); + puVar1 = &pdVar2->rf_state; + pdVar2 = pdVar2 + 1; + printf("RFC: RC %s, RF %s\r\n",rf_state_str[*puVar1]); + } + printf("\r\n\r\n"); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void helper_record_rc_rf_states(uint *param_1,uint *param_2) + +{ + uint uVar1; + + _DAT_40001220 = _DAT_40001220 & 0xfffffff | 0x20000000; + uVar1 = _DAT_40001224 >> 0x19; + *param_1 = _DAT_40001224 >> 0x1c & 7; + *param_2 = uVar1 & 7; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void helper_record_all_states(char *func_name) + +{ + uint32_t uVar1; + uint uVar2; + uint uVar3; + uint uVar4; + + uVar1 = _DAT_44b00120; + uVar4 = (uint)dump_data_ptr; + dump_data_poll[uVar4].func_name = func_name; + dump_data_poll[uVar4].time = uVar1; + helper_record_rc_rf_states(uVar4 * 0x28 + 0x42012024,uVar4 * 0x28 + 0x42012028); + dump_data_poll[uVar4].mac_debugRegHWSM1 = _DAT_44b00500; + dump_data_poll[uVar4].mac_debugRegHWSM2 = _DAT_44b00504; + _DAT_44b00510 = _DAT_44b00510 & 0xffff0000 | 0x31; + *(undefined4 *)&dump_data_poll[uVar4].mac_debugPortCoex = _DAT_44b0050c; + _DAT_44b00510 = _DAT_44b00510 & 0xffff0000 | 0x2f0b; + *(undefined4 *)&dump_data_poll[uVar4].mac_debugPortMacPhyIf = _DAT_44b0050c; + _DAT_44900068 = _DAT_44900068 & 0xffff0000 | 0x14; + _DAT_400000d0 = 4; + _DAT_400000d4 = 0x40000004; + _DAT_400000d8 = 0x80000004; + _DAT_400000dc = 0xc0000004; + uVar2 = _DAT_400000e0 & 0xfffffffe; + uVar3 = _DAT_400000e0 >> 1; + _DAT_400000e0 = uVar2; + dump_data_poll[uVar4].phy_debugPortTDTX = (uint16_t)uVar3; + dump_data_poll[uVar4].phy_debugPortMainFSM = (ushort)(uVar2 >> 0x11); + _DAT_44900074 = 0xb09; + uVar2 = _DAT_400000e0 & 0xfffffffe; + uVar3 = _DAT_400000e0 >> 1; + _DAT_400000e0 = uVar2; + dump_data_poll[uVar4].phy_debugPortDSSSCCK1 = (uint16_t)uVar3; + dump_data_poll[uVar4].phy_debugPortDSSSCCKTx = (ushort)(uVar2 >> 0x11); + dump_data_ptr = dump_data_ptr + 1 & 0xf; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +u32_conflict3 ipc_emb2app_rawstatus_get(void) + +{ + return _DAT_44800004; +} + + + +void ipc_host_init(ipc_host_env_tag *env,ipc_host_cb_tag *cb, + ipc_shared_env_tag_conflict3 *shared_env_ptr,void *pthis) + +{ + printf("[IPC] [TX] Low level size %d, driver size %d, total size %d\r\n",internel_cal_size_tx_desc + ,internel_cal_size_tx_hdr,internel_cal_size_tx_desc + internel_cal_size_tx_hdr); + utils_list_init(&tx_list_bl); + memset(env,0,0xe4); + *(ipc_shared_env_tag_conflict3 **)&env->shared = shared_env_ptr; + memcpy(env,cb,0x20); + env->rx_bufnb = 2; + env->rxdesc_nb = '\x02'; + env->ipc_e2amsg_bufnb = 8; + env->ipc_e2amsg_bufsz = 0x3e0; + env->pthis = pthis; + env->rx_bufsz = 0x800; + env->tx_host_id = env->tx_host_id0; + env->txdesc = (txdesc_host *)shared_env_ptr->txdesc0; + memset((txdesc_host *)shared_env_ptr->txdesc0,0,0xcc0); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int ipc_host_msg_push(ipc_host_env_tag *env,void *msg_buf,uint16_t len) + +{ + undefined2 in_register_00002032; + int iVar1; + ipc_shared_env_tag_conflict30 *piVar2; + int iVar3; + + iVar1 = *(int *)((int)msg_buf + 0xc); + piVar2 = env->shared; + iVar3 = 0; + while (iVar3 < CONCAT22(in_register_00002032,len)) { + *(undefined4 *)((int)(piVar2->msg_a2e_buf).msg + iVar3) = *(undefined4 *)(iVar1 + iVar3); + iVar3 = iVar3 + 4; + } + env->msga2e_hostid = msg_buf; + _DAT_44800000 = 2; + return 0; +} + + + +uint32_t ipc_host_get_rawstatus(ipc_host_env_tag *env) + +{ + u32_conflict3 uVar1; + + uVar1 = ipc_emb2app_rawstatus_get(); + return uVar1; +} + + + +txdesc_host * ipc_host_txdesc_get(ipc_host_env_tag *env) + +{ + uint uVar1; + uint uVar2; + + uVar1 = env->txdesc_used_idx; + uVar2 = env->txdesc_free_idx; + if (uVar2 < uVar1) { + used_issue = used_issue + 1; + } + if (uVar1 + 4 != uVar2) { + if (uVar2 - uVar1 < 5) { + return env->txdesc + (uVar2 & 3); + } + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + return (txdesc_host *)0x0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_host_txdesc_push(ipc_host_env_tag *env,void *host_id) + +{ + uint uVar1; + + uVar1 = env->txdesc_free_idx & 3; + env->txdesc[uVar1].ready = 0xffffffff; + env->tx_host_id[uVar1] = host_id; + env->txdesc_free_idx = env->txdesc_free_idx + 1; + _DAT_44800000 = 0x100; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_host_irq(ipc_host_env_tag *env,uint32_t status) + +{ + uint uVar1; + uint8_t uVar2; + int iVar3; + undefined3 extraout_var; + void *pvVar4; + anon_subr_uint8_t_void_ptr_void_ptr_for_recv_msgack_ind *paVar5; + uint uVar6; + int *piVar7; + uint uVar8; + + uVar1 = _DAT_4480001c | status; + _DAT_44800008 = status; + if ((uVar1 & 0x780) != 0) { + piVar7 = nx_txdesc_cnt_msk; + uVar8 = 7; + do { + if ((1 << (uVar8 & 0x1f) & uVar1) != 0) { + while( true ) { + uVar6 = env->txdesc_used_idx & *piVar7; + if ((env->tx_host_id[uVar6] == (void *)0x0) || + (iVar3 = (*(env->cb).send_data_cfm)(env->pthis,env->tx_host_id[uVar6]), iVar3 != 0)) + break; + env->tx_host_id[uVar6] = (void *)0x0; + env->txdesc_used_idx = env->txdesc_used_idx + 1; + bl_tx_notify(); + } + } + uVar8 = uVar8 + 1; + piVar7 = (int *)((uint *)piVar7 + 1); + } while (uVar8 != 0xb); + } + bl_tx_resend(); + if ((uVar1 & 4) != 0) { + pvVar4 = env->msga2e_hostid; + env->msga2e_cnt = env->msga2e_cnt + '\x01'; + paVar5 = (env->cb).recv_msgack_ind; + env->msga2e_hostid = (void *)0x0; + (*paVar5)(env->pthis,pvVar4); + } + if ((uVar1 & 1) != 0) { + do { + uVar2 = (*(env->cb).recv_dbg_ind) + (env->pthis, + (&(env->cb).recv_data_ind)[((uint)env->ipc_host_dbg_idx + 0x16) * 2]); + } while (CONCAT31(extraout_var,uVar2) == 0); + } + if ((uVar1 & 0x10) != 0) { + (*(env->cb).prim_tbtt_ind)(env->pthis); + } + if ((uVar1 & 0x20) != 0) { + // WARNING: Could not recover jumptable at 0x230223be. Too many branches + // WARNING: Treating indirect jump as call + (*(env->cb).sec_tbtt_ind)(env->pthis); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_host_enable_irq(ipc_host_env_tag *env,uint32_t value) + +{ + _DAT_4480000c = value; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_host_disable_irq_e2a(void) + +{ + _DAT_44800010 = 0x7ff; + return; +} + + + +int bl_main_disconnect(void) + +{ + bl_send_sm_disconnect_req(&wifi_hw,0x34); + return 0; +} + + + +int bl_main_powersaving(int mode) + +{ + int iVar1; + + iVar1 = bl_send_mm_powersaving_req(&wifi_hw,mode); + return iVar1; +} + + + +int bl_main_denoise(int mode) + +{ + int iVar1; + + iVar1 = bl_send_mm_denoise_req(&wifi_hw,mode); + return iVar1; +} + + + +int bl_main_monitor(void) + +{ + undefined auStack56 [4]; + mm_monitor_cfm cfm; + + memset(auStack56,0,0x28); + bl_send_monitor_enable(&wifi_hw,(mm_monitor_cfm *)auStack56); + return 0; +} + + + +int bl_main_phy_up(void) + +{ + int iVar1; + + iVar1 = bl_send_start(&wifi_hw); + if (iVar1 == 0) { + wifi_hw.drv_flags = wifi_hw.drv_flags | 4; + } + else { + iVar1 = -1; + } + return iVar1; +} + + + +int bl_main_monitor_channel_set(int channel,int use_40MHZ) + +{ + undefined auStack56 [4]; + mm_monitor_channel_cfm cfm; + + bl_send_monitor_channel_set(&wifi_hw,(mm_monitor_channel_cfm *)auStack56,channel,use_40MHZ); + return 0; +} + + + +int bl_main_if_remove(uint8_t vif_index) + +{ + undefined3 in_register_00002029; + + printf("[WF] MM_REMOVE_IF_REQ Sending with vif_index %u...\r\n", + CONCAT31(in_register_00002029,vif_index)); + bl_send_remove_if(&wifi_hw,vif_index); + printf("[WF] MM_REMOVE_IF_REQ Done\r\n"); + return 0; +} + + + +int bl_main_raw_send(uint8_t *pkt,int len) + +{ + int iVar1; + + iVar1 = bl_send_scanu_raw_send(&wifi_hw,pkt,len); + return iVar1; +} + + + +int bl_main_rate_config(uint8_t sta_idx,uint16_t fixed_rate_cfg) + +{ + int iVar1; + + iVar1 = bl_send_me_rate_config_req(&wifi_hw,sta_idx,fixed_rate_cfg); + return iVar1; +} + + + +int bl_main_set_country_code(char *country_code) + +{ + bl_msg_update_channel_cfg(country_code); + bl_send_me_chan_config_req(&wifi_hw); + return 0; +} + + + +int bl_main_get_channel_nums(void) + +{ + return channel_num_default; +} + + + +int bl_main_if_add(int is_sta,netif *netif,uint8_t *vif_index) + +{ + uint uVar1; + int iVar2; + undefined *puVar3; + mm_add_if_cfm amStack36 [2]; + mm_add_if_cfm add_if_cfm; + + if (is_sta == 0) { + puVar3 = &UNK_2307b2d0; + } + else { + puVar3 = &UNK_2307b2cc; + } + printf("[WF] MM_ADD_IF_REQ Sending: %s\r\n",puVar3); + iVar2 = bl_send_add_if(&wifi_hw,netif->hwaddr,(is_sta == 0) + NL80211_IFTYPE_STATION,false, + amStack36); + printf("[WF] MM_ADD_IF_REQ Done\r\n"); + if (iVar2 == 0) { + if (amStack36[0].status == '\0') { + uVar1 = (uint)amStack36[0].inst_nbr; + if (is_sta != 0) { + wifi_hw.vif_index_sta = (uint)amStack36[0].inst_nbr; + uVar1 = wifi_hw.vif_index_ap; + } + wifi_hw.vif_index_ap = uVar1; + *vif_index = amStack36[0].inst_nbr; + printf("[WF] vif_index from LAMC is %d\r\n"); + wifi_hw.vif_table[amStack36[0].inst_nbr].dev = netif; + wifi_hw.vif_table[amStack36[0].inst_nbr].up = true; + } + else { + printf("%s: Status Error(%d)\n",&UNK_2307b314); + iVar2 = -5; + } + } + return iVar2; +} + + + +int bl_main_apm_start(char *ssid,char *password,int channel,uint8_t vif_index,uint8_t hidden_ssid) + +{ + int iVar1; + undefined3 in_register_00002035; + apm_start_cfm local_24; + apm_start_cfm start_ap_cfm; + + memset(&local_24,0,4); + printf("[WF] APM_START_REQ Sending with vif_index %u\r\n",CONCAT31(in_register_00002035,vif_index) + ); + iVar1 = bl_send_apm_start_req(&wifi_hw,&local_24,ssid,password,channel,vif_index,hidden_ssid); + printf("[WF] APM_START_REQ Done\r\n"); + printf("[WF] status is %02X\r\n",(uint)local_24.status); + printf("[WF] vif_idx is %02X\r\n",(uint)local_24.vif_idx); + printf("[WF] ch_idx is %02X\r\n",(uint)local_24.ch_idx); + printf("[WF] bcmc_idx is %02X\r\n",(uint)local_24.bcmc_idx); + wifi_hw.ap_bcmc_idx = (uint)local_24.bcmc_idx; + return iVar1; +} + + + +int bl_main_apm_stop(uint8_t vif_index) + +{ + undefined3 in_register_00002029; + int iVar1; + + printf("[WF] APM_STOP_REQ Sending with vif_index %u\r\n",CONCAT31(in_register_00002029,vif_index)) + ; + iVar1 = bl_send_apm_stop_req(&wifi_hw,vif_index); + printf("[WF] APM_STOP_REQ Done\r\n"); + return iVar1; +} + + + +int bl_main_apm_sta_cnt_get(uint8_t *sta_cnt) + +{ + *sta_cnt = '\f'; + return 0; +} + + + +int bl_main_apm_sta_info_get(wifi_apm_sta_info *apm_sta_info,uint8_t idx) + +{ + undefined3 in_register_0000202d; + int iVar1; + + iVar1 = CONCAT31(in_register_0000202d,idx); + if (wifi_hw.sta_table[iVar1].is_used != '\0') { + apm_sta_info->sta_idx = wifi_hw.sta_table[iVar1].sta_idx; + apm_sta_info->is_used = wifi_hw.sta_table[iVar1].is_used; + apm_sta_info->rssi = (int)wifi_hw.sta_table[iVar1].rssi; + apm_sta_info->tsflo = wifi_hw.sta_table[iVar1].tsflo; + apm_sta_info->tsfhi = wifi_hw.sta_table[iVar1].tsfhi; + apm_sta_info->data_rate = wifi_hw.sta_table[iVar1].data_rate; + memcpy(apm_sta_info->sta_mac,wifi_hw.sta_table + iVar1,6); + return 0; + } + return 0; +} + + + +int bl_main_apm_sta_delete(uint8_t sta_idx) + +{ + byte vif_idx; + undefined3 in_register_00002029; + int iVar1; + int iVar2; + apm_sta_del_cfm aStack36; + apm_sta_del_cfm sta_del_cfm; + + iVar1 = CONCAT31(in_register_00002029,sta_idx); + memset(&aStack36,0,3); + vif_idx = wifi_hw.sta_table[iVar1].vif_idx; + printf("[WF] APM_STA_DEL_REQ: sta_idx = %u, vif_idx = %u\r\n",iVar1,(uint)vif_idx); + bl_send_apm_sta_del_req(&wifi_hw,&aStack36,sta_idx,vif_idx); + iVar2 = -1; + if (aStack36.status == '\0') { + memset(wifi_hw.sta_table + iVar1,0,0x1c); + iVar2 = 0; + } + return iVar2; +} + + + +int bl_main_apm_remove_all_sta(void) + +{ + uint8_t sta_idx; + u8 *puVar1; + + puVar1 = &wifi_hw.sta_table[0].is_used; + sta_idx = '\0'; + do { + if (*puVar1 == '\x01') { + bl_main_apm_sta_delete(sta_idx); + } + sta_idx = sta_idx + '\x01'; + puVar1 = puVar1 + 0x1c; + } while (sta_idx != '\f'); + return 0; +} + + + +int bl_main_conf_max_sta(uint8_t max_sta_supported) + +{ + int iVar1; + + iVar1 = bl_send_apm_conf_max_sta_req(&wifi_hw,max_sta_supported); + return iVar1; +} + + + +int bl_main_cfg_task_req + (uint32_t ops,uint32_t task,uint32_t element,uint32_t type,void *arg1,void *arg2) + +{ + int iVar1; + + iVar1 = bl_send_cfg_task_req(&wifi_hw,ops,task,element,type,arg1,arg2); + return iVar1; +} + + + +int bl_main_scan(void) + +{ + bl_send_scanu_req(&wifi_hw); + return 0; +} + + + +int bl_cfg80211_connect(bl_hw *bl_hw,cfg80211_connect_params *sme) + +{ + int iVar1; + sm_connect_cfm asStack20 [4]; + sm_connect_cfm sm_connect_cfm; + + iVar1 = bl_send_sm_connect_req(bl_hw,sme,asStack20); + if (iVar1 == 0) { + iVar1 = -5; + if ((byte)asStack20[0] < 10) { + iVar1 = (int)(char)CSWTCH_6[(byte)asStack20[0]]; + } + } + return iVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bl_main_connect(uint8_t *ssid,int ssid_len,uint8_t *psk,int psk_len,uint8_t *pmk,int pmk_len, + uint8_t *mac,uint8_t band,uint16_t freq) + +{ + short in_stack_00000000; + nl80211_band anStack272 [4]; + cfg80211_connect_params sme; + + memset(anStack272,0,0xf0); + sme.crypto.cipher_group = 0; + sme.ssid_len._0_1_ = __NL80211_AUTHTYPE_NUM; + sme.pmk._0_1_ = (u8)psk_len; + sme.pmk._1_1_ = (u8)pmk_len; + if (mac != (uint8_t *)0x0) { + sme.channel_hint = (ieee80211_channel *)mac; + } + if (in_stack_00000000 != 0) { + sme.channel._4_4_ = 0; + anStack272[0] = band; + } + sme.bssid_hint = ssid; + sme.ssid = (u8 *)ssid_len; + sme.crypto.wep_tx_key = (int)psk; + sme.key = pmk; + bl_cfg80211_connect(&wifi_hw,(cfg80211_connect_params *)anStack272); + return 0; +} + + + +void bl_main_event_handle(void) + +{ + bl_irq_bottomhalf(&wifi_hw); + bl_tx_try_flush(); + return; +} + + + +void bl_main_lowlevel_init(void) + +{ + bl_irqs_init(&wifi_hw); + return; +} + + + +int bl_main_rtthread_start(bl_hw **bl_hw) + +{ + int iVar1; + char *__format; + + bl_main_lowlevel_init(); + *bl_hw = &wifi_hw; + wifi_hw.vifs.next = &wifi_hw.vifs; + wifi_hw.vifs.prev = &wifi_hw.vifs; + wifi_hw.mod_params = &bl_mod_params; + iVar1 = bl_platform_on(&wifi_hw); + if (iVar1 == 0) { + ipc_host_enable_irq(wifi_hw.ipc_env,0x7ff); + bl_wifi_enable_irq(); + iVar1 = bl_send_reset(&wifi_hw); + if (iVar1 == 0) { + vTaskDelay(5); + iVar1 = bl_send_version_req(&wifi_hw,&wifi_hw.version_cfm); + if (iVar1 != 0) { + return 0; + } + printf("[version] lmac %u.%u.%u.%u\r\n",wifi_hw.version_cfm.version_lmac >> 0x18, + wifi_hw.version_cfm.version_lmac >> 0x10 & 0xff, + wifi_hw.version_cfm.version_lmac >> 8 & 0xff,wifi_hw.version_cfm.version_lmac & 0xff); + printf("[version] version_machw_1 %08X\r\n",wifi_hw.version_cfm.version_machw_1); + printf("[version] version_machw_2 %08X\r\n",wifi_hw.version_cfm.version_machw_2); + printf("[version] version_phy_1 %08X\r\n",wifi_hw.version_cfm.version_phy_1); + printf("[version] version_phy_2 %08X\r\n",wifi_hw.version_cfm.version_phy_2); + printf("[version] features %08X\r\n",wifi_hw.version_cfm.features); + iVar1 = bl_handle_dynparams(&wifi_hw); + if (iVar1 == 0) { + bl_send_me_config_req(&wifi_hw); + bl_send_me_chan_config_req(&wifi_hw); + wifi_hw.status = RWNX_INTERFACE_STATUS_UP; + return 0; + } + __format = "bl_handle_dynparams Error\r\n"; + } + else { + __format = "bl_send_reset Error\r\n"; + } + } + else { + __format = "bl_platform_on Error\r\n"; + } + printf(__format); + return 0; +} + + + +int bl_handle_dynparams(bl_hw *bl_hw) + +{ + ushort uVar1; + short sVar2; + char "bl_handle_dynparams" [20]; + int iVar3; + short sVar4; + uint uVar5; + bl_mod_params *pbVar6; + + uVar5 = bl_hw->flags; + bl_hw->flags = uVar5 | 0x40000; + pbVar6 = bl_hw->mod_params; + if (pbVar6->tdls != false) { + bl_hw->flags = uVar5 | 0x58000; + } + if (pbVar6->ap_uapsd_on != false) { + bl_hw->flags = bl_hw->flags | 0x4000; + } + if (5 < (uint)pbVar6->phy_cfg) { + pbVar6->phy_cfg = 2; + } + if (2 < (uint)bl_hw->mod_params->mcs_map) { + bl_hw->mod_params->mcs_map = 0; + } + uVar1 = (bl_hw->ht_cap).cap; + pbVar6 = bl_hw->mod_params; + iVar3 = pbVar6->nss; + (bl_hw->ht_cap).cap = uVar1 | 0x100; + if (pbVar6->ldpc_on != false) { + (bl_hw->ht_cap).cap = uVar1 | 0x101; + } + sVar2 = (short)iVar3; + if (pbVar6->use_2040 == false) { + (bl_hw->ht_cap).mcs.rx_highest = sVar2 * 0x41; + (bl_hw->ht_cap).mcs.rx_mask[0] = -1; + } + else { + uVar1 = (bl_hw->ht_cap).cap; + (bl_hw->ht_cap).mcs.rx_mask[4] = '\x01'; + (bl_hw->ht_cap).cap = uVar1 | 2; + (bl_hw->ht_cap).mcs.rx_highest = sVar2 * 0x87; + } + if (1 < iVar3) { + (bl_hw->ht_cap).cap = (bl_hw->ht_cap).cap | 0x80; + } + if (pbVar6->sgi != false) { + uVar1 = (bl_hw->ht_cap).cap; + (bl_hw->ht_cap).cap = uVar1 | 0x20; + if (pbVar6->use_2040 == false) { + sVar4 = 0x48; + } + else { + (bl_hw->ht_cap).cap = uVar1 | 0x60; + sVar4 = 0x96; + } + (bl_hw->ht_cap).mcs.rx_highest = sVar2 * sVar4; + } + (bl_hw->ht_cap).cap = (bl_hw->ht_cap).cap | 0xc; + if (pbVar6->ht_on == false) { + (bl_hw->ht_cap).ht_supported = false; + } + if (pbVar6->custregd != false) { + printf("\n\n%s: CAUTION: USING PERMISSIVE CUSTOM REGULATORY RULES\n\n","bl_handle_dynparams"); + return 0; + } + return 0; +} + + + +int bl_send_msg(bl_hw *bl_hw,void *msg_params,int reqcfm,lmac_msg_id_t reqid,void *cfm) + +{ + ushort uVar1; + lmac_msg_id_t lVar2; + bool bVar3; + char "bl_send_msg" [12]; + bl_cmd *__s; + int iVar4; + undefined2 in_register_00002036; + lmac_msg *pv; + + iVar4 = CONCAT22(in_register_00002036,reqid); + pv = (lmac_msg *)((int)msg_params + -8); + if ((((((bl_hw->drv_flags >> 2 & 1) == 0) && ((reqid & 0xfffd) != 1)) && (iVar4 != 5)) && + ((iVar4 != 0x23 && ((reqid & 0xfffd) != 0x1401)))) && (iVar4 != 0x32)) { + printf("%s: bypassing (RWNX_DEV_RESTARTING set) 0x%02x\n","bl_send_msg",iVar4); + } + else { + if (bl_hw->ipc_env != (ipc_host_env_tag *)0x0) { + uVar1 = *(ushort *)((int)msg_params + -8); + bVar3 = true; + if (((uVar1 != 0x41) && (uVar1 != 0x50)) && ((uVar1 + 0xebf4 & 0xfffb) != 0)) { + bVar3 = (uVar1 & 0xfffb) == 0x2408; + } + __s = (bl_cmd *)pvPortMalloc(0x40); + if (__s == (bl_cmd *)0x0) { + vPortFree(pv); + printf("%s: failed to allocate mem for cmd, size is %d\r\n",0x2307b550,0x40); + return -0xc; + } + memset(__s,0,0x40); + __s->result = 4; + lVar2 = *(lmac_msg_id_t *)((int)msg_params + -8); + __s->reqid = reqid; + __s->a2e_msg = pv; + __s->id = lVar2; + __s->e2a_msg = cfm; + if (bVar3) { + __s->flags = 1; + } + if (reqcfm != 0) { + __s->flags = __s->flags | 2; + } + iVar4 = (*(bl_hw->cmd_mgr).queue)(&bl_hw->cmd_mgr,__s); + if (!bVar3) { + vPortFree(__s); + return iVar4; + } + return __s->result; + } + printf("%s: bypassing (restart must have failed)\r\n",0x2307b550); + } + vPortFree(pv); + return -0x10; +} + + + +void * bl_msg_zalloc(lmac_msg_id_t id,lmac_task_id_t dest_id,uint16_t param_len) + +{ + lmac_msg_id_t *__s; + undefined2 in_register_00002032; + size_t xWantedSize; + + xWantedSize = CONCAT22(in_register_00002032,param_len) + 8; + __s = (lmac_msg_id_t *)pvPortMalloc(xWantedSize); + if (__s == (lmac_msg_id_t *)0x0) { + printf("%s: msg allocation failed\n",0x2307b540); + } + else { + memset(__s,0,xWantedSize); + *__s = id; + __s[1] = dest_id; + __s[2] = 100; + __s[3] = param_len; + __s = __s + 4; + } + return __s; +} + + + +void bl_msg_update_channel_cfg(char *code) + +{ + int iVar1; + int iVar2; + char *__format; + ieee80211_dot_d *piVar3; + + piVar3 = country_list; + iVar1 = 0; + do { + iVar2 = strcmp(piVar3->code,code); + if (iVar2 == 0) { + __format = "[WF] country code %s used, num of channel %d\r\n"; + channel_num_default = country_list[iVar1].channel_num; + channels_default = country_list[iVar1].channels; + goto LAB_23022de2; + } + iVar1 = iVar1 + 1; + piVar3 = piVar3 + 1; + } while (iVar1 != 4); + channel_num_default = 0xe; + __format = "[WF] %s NOT found, using JP instead, num of channel %d\r\n"; + channels_default = bl_channels_24_JP; +LAB_23022de2: + printf(__format,code,channel_num_default); + return; +} + + + +int bl_msg_get_channel_nums(void) + +{ + return channel_num_default; +} + + + +int bl_send_reset(bl_hw *bl_hw) + +{ + void *msg_params; + int iVar1; + + msg_params = bl_msg_zalloc(0,0,0); + if (msg_params != (void *)0x0) { + iVar1 = bl_send_msg(bl_hw,msg_params,1,1,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_monitor_enable(bl_hw *bl_hw,mm_monitor_cfm *cfm) + +{ + undefined4 *msg_params; + int iVar1; + + msg_params = (undefined4 *)bl_msg_zalloc(0x5c,0,4); + if (msg_params != (undefined4 *)0x0) { + *msg_params = 1; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x5d,cfm); + return iVar1; + } + return -0xc; +} + + + +int bl_send_monitor_channel_set(bl_hw *bl_hw,mm_monitor_channel_cfm *cfm,int channel,int use_40Mhz) + +{ + uint uVar1; + uint *msg_params; + int iVar2; + + msg_params = (uint *)bl_msg_zalloc(0x5e,0,0xc); + if (msg_params == (uint *)0x0) { + return -0xc; + } + if (channel - 1U < 0xe) { + if (channel == 0xe) { + uVar1 = 0x9b4; + } + else { + uVar1 = channel * 5 + 0x967U & 0xffff; + } + } + else { + uVar1 = 0xffff; + } + *msg_params = uVar1; + if (use_40Mhz == 0) { + msg_params[1] = 0; + } + else { + msg_params[1] = 1; + if (use_40Mhz != 1) { + msg_params[2] = 1; + goto LAB_23022f04; + } + } + msg_params[2] = 0; +LAB_23022f04: + iVar2 = bl_send_msg(bl_hw,msg_params,1,0x5f,cfm); + return iVar2; +} + + + +int bl_send_version_req(bl_hw *bl_hw,mm_version_cfm *cfm) + +{ + void *msg_params; + int iVar1; + + msg_params = bl_msg_zalloc(4,0,0); + if (msg_params != (void *)0x0) { + iVar1 = bl_send_msg(bl_hw,msg_params,1,5,cfm); + return iVar1; + } + return -0xc; +} + + + +int bl_send_me_config_req(bl_hw *bl_hw) + +{ + u8 *puVar1; + u16 *msg_params; + int iVar2; + u8 *puVar3; + ieee80211_mcs_info *piVar4; + + msg_params = (u16 *)bl_msg_zalloc(0x1400,5,0x34); + if (msg_params != (u16 *)0x0) { + printf("[ME] HT supp %d, VHT supp %d\r\n",1,0); + msg_params[0x17] = 1; + *msg_params = (bl_hw->ht_cap).cap; + *(u8 *)(msg_params + 1) = (bl_hw->ht_cap).ampdu_density << 2 | (bl_hw->ht_cap).ampdu_factor; + piVar4 = &(bl_hw->ht_cap).mcs; + puVar3 = (u8 *)((int)msg_params + 3); + while (piVar4 != (ieee80211_mcs_info *)&bl_hw->vif_started) { + puVar1 = piVar4->rx_mask; + piVar4 = (ieee80211_mcs_info *)(piVar4->rx_mask + 1); + *puVar3 = *puVar1; + puVar3 = puVar3 + 1; + } + msg_params[10] = 0; + *(undefined4 *)(msg_params + 0xc) = 0; + *(undefined *)(msg_params + 0xe) = 0; + *(_Bool *)(msg_params + 0x18) = bl_hw->mod_params->ps_on; + msg_params[0x16] = (u16)bl_hw->mod_params->tx_lft; + iVar2 = bl_send_msg(bl_hw,msg_params,1,0x1401,(void *)0x0); + return iVar2; + } + return -0xc; +} + + + +int bl_send_me_chan_config_req(bl_hw *bl_hw) + +{ + byte bVar1; + void *msg_params; + int iVar2; + uint uVar3; + u16 *puVar4; + + msg_params = bl_msg_zalloc(0x1402,5,0xfe); + if (msg_params == (void *)0x0) { + return -0xc; + } + *(undefined *)((int)msg_params + 0xfc) = 0; + iVar2 = 0; + while (iVar2 < channel_num_default) { + bVar1 = *(byte *)((int)msg_params + 0xfc); + puVar4 = (u16 *)((uint)bVar1 * 6 + (int)msg_params); + *(undefined *)((int)puVar4 + 3) = 0; + if ((channels_default[iVar2].flags & 1) != 0) { + *(undefined *)((int)puVar4 + 3) = 2; + } + uVar3 = channels_default[iVar2].flags; + *(undefined *)(puVar4 + 1) = 0; + *(byte *)((int)puVar4 + 3) = (uVar3 & 10) != 0 | *(byte *)((int)puVar4 + 3); + *puVar4 = channels_default[iVar2].center_freq; + *(char *)(puVar4 + 2) = (char)channels_default[iVar2].max_power; + uVar3 = (uint)bVar1 + 1 & 0xff; + *(undefined *)((int)msg_params + 0xfc) = (char)uVar3; + if (uVar3 == 0xe) break; + iVar2 = iVar2 + 1; + } + *(undefined *)((int)msg_params + 0xfd) = 0; + iVar2 = bl_send_msg(bl_hw,msg_params,1,0x1403,(void *)0x0); + return iVar2; +} + + + +int bl_send_me_rate_config_req(bl_hw *bl_hw,uchar sta_idx,uint16_t fixed_rate_cfg) + +{ + uchar *msg_params; + int iVar1; + + msg_params = (uchar *)bl_msg_zalloc(0x1410,5,4); + if (msg_params != (uchar *)0x0) { + *msg_params = sta_idx; + *(uint16_t *)(msg_params + 2) = fixed_rate_cfg; + iVar1 = bl_send_msg(bl_hw,msg_params,0,0,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_start(bl_hw *bl_hw) + +{ + void *__dest; + int iVar1; + + __dest = bl_msg_zalloc(2,0,0x48); + if (__dest != (void *)0x0) { + (bl_hw->phy_config).parameters = 1; + memcpy(__dest,&bl_hw->phy_config,0x40); + *(int *)((int)__dest + 0x40) = bl_hw->mod_params->uapsd_timeout; + *(undefined2 *)((int)__dest + 0x44) = (short)bl_hw->mod_params->lp_clk_ppm; + iVar1 = bl_send_msg(bl_hw,__dest,1,3,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_add_if(bl_hw *bl_hw,uchar *mac,nl80211_iftype iftype,_Bool p2p,mm_add_if_cfm *cfm) + +{ + undefined *msg_params; + int iVar1; + undefined uVar2; + + msg_params = (undefined *)bl_msg_zalloc(6,0,8); + if (msg_params == (undefined *)0x0) { + return -0xc; + } + memcpy(msg_params + 1,mac,6); + switch((uint)iftype - 1 & 0xff) { + case 0: + uVar2 = 1; + break; + case 3: + return -1; + case 6: + uVar2 = 3; + break; + case 7: + msg_params[7] = 1; + default: + *msg_params = 0; + goto LAB_2302320e; + case 8: + msg_params[7] = 1; + case 2: + uVar2 = 2; + } + *msg_params = uVar2; +LAB_2302320e: + iVar1 = bl_send_msg(bl_hw,msg_params,1,7,cfm); + return iVar1; +} + + + +int bl_send_remove_if(bl_hw *bl_hw,uchar inst_nbr) + +{ + uchar *msg_params; + int iVar1; + + msg_params = (uchar *)bl_msg_zalloc(8,0,1); + if (msg_params != (uchar *)0x0) { + *msg_params = inst_nbr; + iVar1 = bl_send_msg(bl_hw,msg_params,1,9,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_scanu_req(bl_hw *bl_hw) + +{ + u16 uVar1; + u16 *msg_params; + int iVar2; + ieee80211_channel *piVar3; + int iVar4; + u16 *puVar5; + + msg_params = (u16 *)bl_msg_zalloc(0x1000,4,0x154); + if (msg_params != (u16 *)0x0) { + iVar4 = bl_hw->vif_index_sta; + msg_params[0xa6] = 0; + *(char *)(msg_params + 0xa7) = (char)iVar4; + iVar4 = channel_num_default; + *(undefined *)((int)msg_params + 0x14f) = (char)channel_num_default; + *(undefined4 *)(msg_params + 0xa0) = 0xffffffff; + msg_params[0xa2] = 0xffff; + msg_params[0xa8] = 0x100; + *(undefined4 *)(msg_params + 0xa4) = 0; + iVar2 = 0; + puVar5 = msg_params; + while (iVar2 < (int)(iVar4 & 0xffU)) { + piVar3 = channels_default + iVar2; + *(nl80211_band *)(puVar5 + 1) = piVar3->band; + uVar1 = piVar3->center_freq; + *(undefined *)((int)puVar5 + 3) = 1; + *puVar5 = uVar1; + *(char *)(puVar5 + 2) = (char)piVar3->max_reg_power; + iVar2 = iVar2 + 1; + puVar5 = puVar5 + 3; + } + iVar4 = bl_send_msg(bl_hw,msg_params,0,0,(void *)0x0); + return iVar4; + } + return -0xc; +} + + + +int bl_send_scanu_raw_send(bl_hw *bl_hw,uint8_t *pkt,int len) + +{ + uint8_t **msg_params; + int iVar1; + undefined auStack36 [4]; + scanu_raw_send_cfm cfm; + + msg_params = (uint8_t **)bl_msg_zalloc(0x1005,4,8); + if (msg_params == (uint8_t **)0x0) { + iVar1 = -0xc; + } + else { + *msg_params = pkt; + *(int *)(msg_params + 1) = len; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x1006,auStack36); + } + return iVar1; +} + + + +int bl_send_sm_connect_req(bl_hw *bl_hw,cfg80211_connect_params *sme,sm_connect_cfm *cfm) + +{ + _Bool _Var1; + char "bl_send_sm_connect_req" [23]; + undefined *msg_params; + int iVar2; + nl80211_auth_type nVar3; + u32_conflict15 uVar4; + uint uVar5; + uint uVar6; + __be16 _Var7; + u8 *puVar8; + uint __n; + + msg_params = (undefined *)bl_msg_zalloc(0x1800,6,0x1c4); + if (msg_params == (undefined *)0x0) { + return -0xc; + } + __n = 0; + if ((sme->crypto).n_ciphers_pairwise != 0) { + uVar4 = (sme->crypto).ciphers_pairwise[0]; + __n = 4; + if ((1 < uVar4 - 0xfac01) && (__n = 0, uVar4 == 0xfac05)) { + __n = 4; + } + } + if ((sme->crypto).control_port != false) { + __n = __n | 1; + } + if ((sme->crypto).control_port_no_encrypt != false) { + __n = __n | 2; + } + if (((sme->crypto).cipher_group & 0xfffffffb) != 0xfac01) { + __n = __n | 8; + } + if (sme->mfp == NL80211_MFP_REQUIRED) { + __n = __n | 0x10; + } + _Var7 = (sme->crypto).control_port_ethertype; + if (_Var7 == 0) { + _Var7 = 0x888e; + } + *(__be16 *)(msg_params + 0x34) = _Var7; + puVar8 = sme->bssid; + if (puVar8 == (u8 *)0x0) { +LAB_23023458: + memcpy(msg_params + 0x22,&mac_addr_bcst,6); + } + else { + if (*puVar8 == -1) { + uVar5 = 0; + if (((puVar8[1] == -1) && (puVar8[2] == -1)) && + ((puVar8[3] == -1 && ((puVar8[4] == -1 && (puVar8[5] == -1)))))) goto LAB_23023458; + } + else { + if ((((*puVar8 == '\0') && (puVar8[1] == '\0')) && (puVar8[2] == '\0')) && + ((puVar8[3] == '\0' && (uVar5 = (uint)puVar8[4], puVar8[4] == 0)))) { + if (puVar8[5] == '\0') goto LAB_23023458; + } + else { + uVar5 = 0; + } + } + do { + uVar6 = uVar5 + 1; + msg_params[uVar5 + 0x22] = sme->bssid[uVar5]; + uVar5 = uVar6; + } while (uVar6 != 6); + } + msg_params[0x3d] = (char)bl_hw->vif_index_sta; + if ((sme->channel).center_freq == 0) { + *(undefined2 *)(msg_params + 0x28) = 0xffff; + } + else { + msg_params[0x2a] = (sme->channel).band; + *(u16 *)(msg_params + 0x28) = (sme->channel).center_freq; + *(bool *)(msg_params + 0x2b) = ((sme->channel).flags & 10) != 0; + } + uVar5 = 0; + while (uVar5 < sme->ssid_len) { + msg_params[uVar5 + 1] = sme->ssid[uVar5]; + uVar5 = uVar5 + 1; + } + *msg_params = (char)sme->ssid_len; + *(uint *)(msg_params + 0x30) = __n; + __n = sme->ie_len; + if (0x100 < __n) { + printf("%s:%d\r\n","bl_send_sm_connect_req",0x30a); + return -0x16; + } + if (__n != 0) { + memcpy(msg_params + 0x40,sme->ie,__n); + } + *(short *)(msg_params + 0x36) = (short)sme->ie_len; + _Var1 = bl_mod_params.listen_bcmc; + *(short *)(msg_params + 0x38) = (short)bl_mod_params.listen_itv; + msg_params[0x3a] = _Var1 ^ 1; + nVar3 = sme->auth_type; + if (nVar3 == __NL80211_AUTHTYPE_NUM) { + nVar3 = NL80211_AUTHTYPE_OPEN_SYSTEM; + } + msg_params[0x3b] = nVar3; + msg_params[0x3c] = (char)bl_mod_params.uapsd_queues; + msg_params[0x140] = 1; + if (sme->key_len != 0) { + memcpy(msg_params + 0x141,sme->key,(uint)sme->key_len); + } + if (sme->pmk_len != 0) { + memcpy(msg_params + 0x181,sme->pmk,(uint)sme->pmk_len); + } + iVar2 = bl_send_msg(bl_hw,msg_params,1,0x1801,cfm); + return iVar2; +} + + + +int bl_send_sm_disconnect_req(bl_hw *bl_hw,u16 reason) + +{ + u16 *msg_params; + int iVar1; + + msg_params = (u16 *)bl_msg_zalloc(0x1803,6,4); + if (msg_params != (u16 *)0x0) { + *msg_params = reason; + *(char *)(msg_params + 1) = (char)bl_hw->vif_index_sta; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x1804,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_mm_powersaving_req(bl_hw *bl_hw,int mode) + +{ + undefined *msg_params; + int iVar1; + + msg_params = (undefined *)bl_msg_zalloc(0x31,0,1); + if (msg_params != (undefined *)0x0) { + *msg_params = (char)mode; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x32,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_mm_denoise_req(bl_hw *bl_hw,int mode) + +{ + undefined *msg_params; + int iVar1; + + msg_params = (undefined *)bl_msg_zalloc(0x30,0,1); + if (msg_params != (undefined *)0x0) { + *msg_params = (char)mode; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x32,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_apm_start_req + (bl_hw *bl_hw,apm_start_cfm *cfm,char *ssid,char *password,int channel,uchar vif_index + ,uchar hidden_ssid) + +{ + void *msg_params; + size_t __n; + int iVar1; + uint uVar2; + undefined auStack44 [4]; + uint8_t rate [12]; + + memcpy(auStack44,&DAT_2307b534,0xc); + msg_params = bl_msg_zalloc(0x1c00,7,0xa8); + if (msg_params == (void *)0x0) { + iVar1 = -0xc; + } + else { + *(undefined *)((int)msg_params + 0x10) = 0; + if (channel - 1U < 0xe) { + if (channel == 0xe) { + uVar2 = 0x9b4; + } + else { + uVar2 = channel * 5 + 0x967U & 0xffff; + } + } + else { + uVar2 = 0xffff; + } + *(undefined2 *)((int)msg_params + 0xe) = (short)uVar2; + *(uint *)((int)msg_params + 0x14) = uVar2; + *(undefined2 *)((int)msg_params + 0x28) = 100; + *(undefined4 *)((int)msg_params + 0x2c) = 8; + *(undefined2 *)((int)msg_params + 0x30) = 0x8e88; + *(undefined *)((int)msg_params + 0x32) = 6; + *(uchar *)((int)msg_params + 0x1d) = hidden_ssid; + *(uchar *)((int)msg_params + 0x33) = vif_index; + *(undefined *)((int)msg_params + 0x11) = 0; + *(undefined *)((int)msg_params + 0x12) = 0; + *(undefined4 *)((int)msg_params + 0x18) = 0; + *(undefined *)((int)msg_params + 0x1c) = 0; + *(undefined4 *)((int)msg_params + 0x20) = 0; + *(undefined4 *)((int)msg_params + 0x24) = 0; + __n = strlen(password); + *(undefined *)((int)msg_params + 0x34) = 1; + *(bool *)((int)msg_params + 0x66) = __n != 0; + __n = strlen(ssid); + memcpy((void *)((int)msg_params + 0x45),ssid,__n); + __n = strlen(password); + memcpy((void *)((int)msg_params + 0x67),password,__n); + __n = strlen(ssid); + *(undefined *)((int)msg_params + 0x44) = (char)__n; + *(undefined *)((int)msg_params + 0x35) = 0xc; + memcpy((void *)((int)msg_params + 0x36),auStack44,0xc); + *(undefined2 *)((int)msg_params + 0x42) = 0x101; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x1c01,cfm); + } + return iVar1; +} + + + +int bl_send_apm_stop_req(bl_hw *bl_hw,uchar vif_idx) + +{ + uchar *msg_params; + int iVar1; + + msg_params = (uchar *)bl_msg_zalloc(0x1c02,7,1); + if (msg_params != (uchar *)0x0) { + *msg_params = vif_idx; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x1c03,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_apm_sta_del_req(bl_hw *bl_hw,apm_sta_del_cfm *cfm,uchar sta_idx,uchar vif_idx) + +{ + uchar *msg_params; + int iVar1; + + msg_params = (uchar *)bl_msg_zalloc(0x1c0b,7,2); + if (msg_params != (uchar *)0x0) { + msg_params[1] = sta_idx; + *msg_params = vif_idx; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x1c0c,cfm); + return iVar1; + } + return -0xc; +} + + + +int bl_send_apm_conf_max_sta_req(bl_hw *bl_hw,uchar max_sta_supported) + +{ + uchar *msg_params; + int iVar1; + + msg_params = (uchar *)bl_msg_zalloc(0x1c0d,7,1); + if (msg_params != (uchar *)0x0) { + *msg_params = max_sta_supported; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x1c0e,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_cfg_task_req + (bl_hw *bl_hw,uint32_t ops,uint32_t task,uint32_t element,uint32_t type,void *arg1, + void *arg2) + +{ + uint32_t *msg_params; + int iVar1; + TickType_t TVar2; + uint32_t uVar3; + + msg_params = (uint32_t *)bl_msg_zalloc(0x3000,0xc,0x24); + if (msg_params == (uint32_t *)0x0) { + return -0xc; + } + *msg_params = ops; + if (ops < 3) { + if (ops == 0) { + msg_params[1] = task; + msg_params[2] = element; + msg_params[3] = type; + uVar3 = utils_tlv_bl_pack_auto(msg_params + 5,8,(uint16_t)type,arg1); + msg_params[4] = uVar3; + } + } + else { + if (ops != 3) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ASSERT: %s:%d\r\n",TVar2,&UNK_2307c064,&UNK_2307c058,0x40f, + &UNK_2307c058,0x40f); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + msg_params[1] = task; + msg_params[2] = element; + msg_params[4] = 0; + } + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x3001,(void *)0x0); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int bl_platform_on(bl_hw *bl_hw) + +{ + int iVar1; + + ipc_shenv = &ipc_shared_env; + iVar1 = bl_ipc_init(bl_hw,(ipc_shared_env_tag_conflict21 *)&ipc_shared_env); + if (iVar1 == 0) { + _DAT_44800008 = 0xffffffff; + } + return iVar1; +} + + + +int bl_rx_chan_pre_switch_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + return 0; +} + + + +int bl_rx_rssi_status_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + if (cb_rssi != (wifi_event_rssi_cb_t *)0x0) { + (*cb_rssi)(cb_rssi_env,*(int8_t *)((int)msg->param + 2)); + return 0; + } + return 0; +} + + + +int bl_rx_apm_sta_del_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + printf("[WF] APM_STA_DEL_IND\r\n"); + printf("[WF] sta_idx %u\r\n",(uint)*(byte *)msg->param); + if (*(byte *)msg->param < 0xc) { + bl_hw->sta_table[*(byte *)msg->param].is_used = '\0'; + } + else { + printf("[WF] --------- Potential illegal sta_idx\r\n"); + } + aos_post_event(2,0x16,(uint)*(byte *)msg->param); + return 0; +} + + + +int bl_rx_apm_sta_add_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + byte bVar1; + int *piVar2; + + printf("[WF] APM_STA_ADD_IND\r\n"); + printf("[WF] flags %08X\r\n",msg->param[0]); + printf("[WF] MAC %02X:%02X:%02X:%02X:%02X:%02X\r\n",(uint)*(byte *)(msg->param + 1), + (uint)*(byte *)((int)msg->param + 5),(uint)*(byte *)((int)msg->param + 6), + (uint)*(byte *)((int)msg->param + 7),(uint)*(byte *)(msg->param + 2), + (uint)*(byte *)((int)msg->param + 9)); + printf("[WF] vif_idx %u\r\n",(uint)*(byte *)((int)msg->param + 10)); + printf("[WF] sta_idx %u\r\n",(uint)*(byte *)((int)msg->param + 0xb)); + bVar1 = *(byte *)((int)msg->param + 0xb); + if (bVar1 < 0xc) { + memcpy(bl_hw->sta_table + (uint)bVar1,msg->param + 1,6); + piVar2 = &bl_hw->is_up + (uint)bVar1 * 7; + *(undefined *)((int)piVar2 + 0xc99) = *(undefined *)((int)msg->param + 0xb); + *(undefined *)((int)piVar2 + 0xc9a) = *(undefined *)((int)msg->param + 10); + *(undefined *)(piVar2 + 0x326) = 1; + *(undefined *)(piVar2 + 0x327) = *(undefined *)(msg->param + 3); + piVar2[0x328] = msg->param[4]; + piVar2[0x329] = msg->param[5]; + *(undefined *)(piVar2 + 0x32a) = *(undefined *)(msg->param + 6); + } + else { + printf("[WF] ------ Potential illegal sta_idx\r\n"); + } + aos_post_event(2,0x15,(uint)*(byte *)((int)msg->param + 0xb)); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void notify_event_scan_done(int join_scan) + +{ + wifi_event wStack24; + uint8_t buffer [8]; + + memset(&wStack24,0,4); + memset(buffer,0,4); + buffer._0_4_ = 0xec; + wStack24 = (wifi_event)((uint)(join_scan != 0) + 1); + if (cb_event != (wifi_event_cb_t *)0x0) { + (*cb_event)(cb_event_env,&wStack24); + } + return; +} + + + +int bl_rx_scanu_join_cfm(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + notify_event_scan_done(1); + return 0; +} + + + +int bl_rx_scanu_start_cfm(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + notify_event_scan_done(0); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bl_rx_chan_switch_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + wifi_event wStack24; + uint8_t buffer [8]; + + buffer._0_4_ = (uint)*(byte *)msg->param; + memset(&wStack24,0,4); + memset(buffer,0,4); + wStack24 = (wifi_event)0x0; + if (cb_event != (wifi_event_cb_t *)0x0) { + (*cb_event)(cb_event_env,&wStack24); + } + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bl_rx_sm_connect_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + netif *netif; + sm_reason_code *psVar1; + uint uVar2; + int iVar3; + u32_l local_40; + wifi_event_sm_connect_ind ind_new; + + psVar1 = reason_list; + iVar3 = 0; + do { + if (psVar1->reason_code == *(uint16_t *)msg->param) goto LAB_23023c3e; + iVar3 = iVar3 + 1; + psVar1 = psVar1 + 1; + } while (iVar3 != 0x10); + iVar3 = 0; +LAB_23023c3e: + printf("[RX] Connection Status\r\n"); + printf("[RX] status_code %u\r\n",(uint)*(ushort *)msg->param); + printf("[RX] connect result: %s\r\n",reason_list[iVar3].action); + printf("[RX] MAC %02X:%02X:%02X:%02X:%02X:%02X\r\n",(uint)*(byte *)((int)msg->param + 2), + (uint)*(byte *)((int)msg->param + 3),(uint)*(byte *)(msg->param + 1), + (uint)*(byte *)((int)msg->param + 5),(uint)*(byte *)((int)msg->param + 6), + (uint)*(byte *)((int)msg->param + 7)); + printf("[RX] vif_idx %u\r\n",(uint)*(byte *)((int)msg->param + 9)); + printf("[RX] ap_idx %u\r\n",(uint)*(byte *)((int)msg->param + 10)); + printf("[RX] ch_idx %u\r\n",(uint)*(byte *)((int)msg->param + 0xb)); + printf("[RX] qos %u\r\n",(uint)*(byte *)(msg->param + 3)); + printf("[RX] acm %u\r\n",(uint)*(byte *)((int)msg->param + 0xd)); + printf("[RX] assoc_req_ie_len %u\r\n",(uint)*(ushort *)((int)msg->param + 0xe)); + printf("[RX] assoc_rsp_ie_len %u\r\n",(uint)*(ushort *)(msg->param + 4)); + printf("[RX] aid %u\r\n",(uint)*(ushort *)(msg->param + 0xcd)); + printf("[RX] band %u\r\n",(uint)*(byte *)((int)msg->param + 0x336)); + printf("[RX] center_freq %u\r\n",(uint)*(ushort *)(msg->param + 0xce)); + printf("[RX] width %u\r\n",(uint)*(byte *)((int)msg->param + 0x33a)); + printf("[RX] center_freq1 %u\r\n",msg->param[0xcf]); + printf("[RX] center_freq2 %u\r\n",msg->param[0xd0]); + if (*(short *)msg->param == 0) { + bl_hw->sta_idx = (uint)*(byte *)((int)msg->param + 10); + bl_hw->is_up = 1; + } + else { + bl_hw->is_up = 0; + } + memset(&local_40,0,0x20); + local_40 = msg->param[0]; + ind_new._0_4_ = msg->param[1]; + ind_new.bssid[2] = *(uint8_t *)((int)msg->param + 9); + ind_new.bssid[3] = *(uint8_t *)((int)msg->param + 10); + ind_new.bssid[4] = *(uint8_t *)((int)msg->param + 0xb); + ind_new._8_4_ = (uint)*(byte *)(msg->param + 3); + ind_new.qos._0_2_ = *(uint16_t *)(msg->param + 0xcd); + ind_new.qos._2_1_ = *(uint8_t *)((int)msg->param + 0x336); + ind_new.aid = *(uint16_t *)(msg->param + 0xce); + ind_new.band = *(uint8_t *)((int)msg->param + 0x33a); + ind_new._20_4_ = msg->param[0xcf]; + ind_new.center_freq1 = msg->param[0xd0]; + if (cb_sm_connect_ind != (wifi_event_sm_connect_ind_cb_t *)0x0) { + (*cb_sm_connect_ind)(cb_sm_connect_ind_env,(wifi_event_sm_connect_ind *)&local_40); + } + if (*(short *)msg->param == 0) { + uVar2 = (uint)*(byte *)((int)msg->param + 9); + if (bl_hw->vif_table + uVar2 != (bl_vif *)0x0) { + netif = (netif *)(&bl_hw->is_up + uVar2 * 0x31)[0xda]; + if (netif != (netif *)0x0) { + netifapi_netif_common(netif,netif_set_link_up,(netifapi_errt_fn)0x0); + netifapi_netif_common + ((netif *)(&bl_hw->is_up + uVar2 * 0x31)[0xda],netif_set_default, + (netifapi_errt_fn)0x0); + return 0; + } + } + printf("[RX] -------- CRITICAL when check netif. ptr is %p:%p\r\n"); + } + return 0; +} + + + +// WARNING: Variable defined which should be unmapped: ind_new +// WARNING: Could not reconcile some variable overlaps + +int bl_rx_sm_disconnect_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + netif *netif; + uint uVar1; + ip4_addr_t iStack28; + ip4_addr_t addr_any; + wifi_event_sm_disconnect_ind ind_new; + + iStack28 = (ip4_addr_t)ipaddr_addr("0.0.0.0"); + printf("[RX] sm_disconnect_ind\r\n reason_code %u\r\n",(uint)*(ushort *)msg->param); + printf("[RX] vif_idx %u\r\n",(uint)*(byte *)((int)msg->param + 2)); + printf("[RX] ft_over_ds %u\r\n",(uint)*(byte *)((int)msg->param + 3)); + if (cb_sm_disconnect_ind != (wifi_event_sm_disconnect_ind_cb_t *)0x0) { + memset(&addr_any,0,8); + addr_any.addr._0_2_ = *(uint16_t *)msg->param; + addr_any.addr._2_1_ = *(uint8_t *)((int)msg->param + 2); + (*cb_sm_disconnect_ind)(cb_sm_disconnect_ind_env,(wifi_event_sm_disconnect_ind *)&addr_any); + } + uVar1 = (uint)*(byte *)((int)msg->param + 2); + if (bl_hw->vif_table + uVar1 != (bl_vif *)0x0) { + netif = (netif *)(&bl_hw->is_up + uVar1 * 0x31)[0xda]; + if (netif != (netif *)0x0) { + netifapi_netif_common(netif,netif_set_link_down,(netifapi_errt_fn)0x0); + netifapi_netif_set_addr + ((netif *)(&bl_hw->is_up + uVar1 * 0x31)[0xda],&iStack28,&iStack28,&iStack28); + } + } + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +undefined4 bl_rx_scanu_result_ind(int param_1,longlong param_2) + +{ + uchar uVar1; + void *__src; + undefined3 extraout_var; + uint __n; + SecurityMode_t *security_mode; + _Bool wpa2_prefered; + byte bVar2; + ushort uVar3; + int iVar4; + byte *pbVar5; + byte *pbVar6; + _Bool _Stack121; + uint8_t auStack120 [32]; + undefined2 uStack88; + undefined2 uStack86; + undefined2 uStack84; + undefined auStack82 [33]; + int8_t iStack49; + int8_t iStack48; + int8_t iStack47; + byte bStack46; + uint8_t uStack45; + undefined4 uStack44; + undefined4 uStack40; + uint uStack36; + SecurityMode_t aSStack32 [4]; + + _Stack121 = false; + memset(auStack120,0,0x20); + security_mode = (SecurityMode_t *)0x80; + uVar3 = *(ushort *)(param_1 + 0x24) & 0xfc; + if (uVar3 != 0x80) { + if (uVar3 != 0x50) { + printf("Bug Scan IND?\r\n"); + return 0; + } + printf("Probe Response\r\n"); + if (cb_probe_resp_ind == (wifi_event_probe_resp_ind_cb_t *)0x0) { + return 0; + } + (*cb_probe_resp_ind)((void *)0x0,param_2); + return 0; + } + if (cb_beacon_ind == (wifi_event_beacon_ind_cb_t *)0x0) { + return 0; + } + memset(&uStack88,0,0x38); + uVar3 = *(ushort *)(param_1 + 8); + pbVar6 = (byte *)(param_1 + 0x48); + iVar4 = 0; + pbVar5 = pbVar6; + while (iVar4 < (int)(uint)uVar3) { + security_mode = (SecurityMode_t *)(uint)*pbVar5; + __n = (uint)pbVar5[1]; + if (*pbVar5 == 0) { + if (pbVar5[1] < 0x21) { + uStack36 = __n; + memcpy(auStack82,pbVar5 + 2,__n); + security_mode = aSStack32; + auStack82[pbVar5[1]] = 0; + } + break; + } + iVar4 = iVar4 + __n + 2; + pbVar5 = pbVar5 + __n + 2; + } + iVar4 = 0; + pbVar5 = pbVar6; + while (iVar4 < (int)(uint)*(ushort *)(param_1 + 8)) { + security_mode = (SecurityMode_t *)(uint)pbVar5[1]; + if (*pbVar5 == 3) { + if (pbVar5[1] < 0x21) { + bStack46 = pbVar5[2]; + } + break; + } + security_mode = security_mode + 1; + iVar4 = &security_mode->field_0x0 + iVar4; + pbVar5 = pbVar5 + (int)security_mode; + } + if ((*(ushort *)(param_1 + 0x46) & 0x10) == 0) { + uStack45 = '\0'; + goto LAB_230240a6; + } + __n = (uint)uVar3 - 0x24 & 0xffff; + __src = (void *)mac_ie_find(pbVar6,__n,0x30); + iVar4 = 0; + if (__src != (void *)0x0) { + wpa2_prefered = (_Bool)(uStack40._1_1_ | 0x20); + uStack40 = uStack40 | 0x2000; + memcpy(auStack120,__src,(uint)*(byte *)((int)__src + 1) + 2 & 0xff); + uVar1 = process_rsn_ie(auStack120,(Cipher_t *)((int)&uStack44 + 3),(Cipher_t *)&uStack40, + &_Stack121,security_mode,wpa2_prefered); + iVar4 = CONCAT31(extraout_var,uVar1); + } + __src = (void *)mac_vsie_find(pbVar6,__n,&DAT_2307c188,4); + if ((__src != (void *)0x0) && (uStack40 = uStack40 | 0x800, iVar4 == 0)) { + memcpy(auStack120,__src,(uint)*(byte *)((int)__src + 1) + 2 & 0xff); + process_wpa_ie(auStack120,(Cipher_t *)((int)&uStack44 + 1),(Cipher_t *)((int)&uStack44 + 2)); + } + if ((uStack40 & 0x2800) == 0x2800) { + bVar2 = (byte)uStack40._0_1_ | (byte)uStack44._2_1_; + __n = (uint)bVar2 & 8; + if ((bVar2 & 4) == 0) { + if ((bVar2 & 8) != 0) { + if (((uStack44 & 0x8000800) == 0) && ((uStack44 & 0x4000400) != 0)) goto LAB_23024090; +LAB_23024118: + bVar2 = 2; + goto next; + } + } + else { +LAB_2302408c: + bVar2 = 3; + if (__n != 0) { +LAB_23024090: + bVar2 = 4; + } +next: + uStack44 = uStack44 & 0xffffff00 | (uint)bVar2; + if ((uStack40 & 0x2800) != 0x2800) goto LAB_23024172; + } + uStack45 = '\x04'; + } + else { + if ((uStack40 & 0x800) == 0) { + if ((uStack40 & 0x2000) == 0) { + uStack44 = CONCAT31(uStack44._1_3_,1); + } + else { + __n = uStack40 & 8; + if ((uStack40 & 4) != 0) goto LAB_2302408c; + if ((uStack40 & 8) != 0) { + uStack44._1_1_ = uStack44._3_1_; + goto LAB_23024146; + } + } + } + else { + __n = (uint)(byte)uStack44._2_1_ & 8; + if ((uStack44 & 0x40000) != 0) goto LAB_2302408c; + if ((uStack44 & 0x80000) != 0) { +LAB_23024146: + if ((((byte)uStack44._1_1_ & 8) != 0) || (((byte)uStack44._1_1_ & 4) == 0)) + goto LAB_23024118; + goto LAB_23024090; + } + } +LAB_23024172: + if ((uStack40 & 0x2000) == 0) { + if ((uStack40 & 0x800) == 0) { + uStack45 = '\x01'; + } + else { + uStack45 = '\x02'; + } + } + else { + uStack45 = '\x03'; + } + } +LAB_230240a6: + iStack49 = *(int8_t *)(param_1 + 0x20); + iStack48 = *(int8_t *)(param_1 + 0x21); + iStack47 = *(int8_t *)(param_1 + 0x22); + uStack88 = *(undefined2 *)(param_1 + 0x34); + uStack86 = *(undefined2 *)(param_1 + 0x36); + uStack84 = *(undefined2 *)(param_1 + 0x38); + (*cb_beacon_ind)(cb_beacon_ind_env,(wifi_event_beacon_ind_conflict *)&uStack88); + return 0; +} + + + +undefined4 bl_rx_mesh_path_update_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_mesh_proxy_update_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_remain_on_channel_exp_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_ps_change_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_traffic_req_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_csa_counter_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_csa_finish_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_csa_traffic_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_channel_survey_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_dbg_error_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_tdls_chan_switch_cfm(void) + +{ + return 0; +} + + + +undefined4 bl_rx_tdls_chan_switch_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_tdls_chan_switch_base_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_tdls_peer_ps_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_me_tkip_mic_failure_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_me_tx_credits_update_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_mesh_path_create_cfm(void) + +{ + return 0; +} + + + +undefined4 bl_rx_mesh_peer_update_ind(void) + +{ + return 0; +} + + + +int bl_rx_sm_connect_ind_cb_register(void *env,wifi_event_sm_connect_ind_cb_t *cb) + +{ + cb_sm_connect_ind = cb; + cb_sm_connect_ind_env = env; + return 0; +} + + + +int bl_rx_sm_disconnect_ind_cb_register(void *env,wifi_event_sm_disconnect_ind_cb_t *cb) + +{ + cb_sm_disconnect_ind = cb; + cb_sm_disconnect_ind_env = env; + return 0; +} + + + +int bl_rx_beacon_ind_cb_register(void *env,wifi_event_beacon_ind_cb_t *cb) + +{ + cb_beacon_ind = cb; + cb_beacon_ind_env = env; + return 0; +} + + + +int bl_rx_probe_resp_ind_cb_register(void *env,wifi_event_probe_resp_ind_cb_t *cb) + +{ + cb_probe_resp_ind = cb; + return 0; +} + + + +int bl_rx_pkt_cb_register(void *env,wifi_event_pkt_cb_t *cb) + +{ + cb_pkt = cb; + cb_pkt_env = env; + return 0; +} + + + +int bl_rx_pkt_cb_unregister(void *env) + +{ + cb_pkt = (wifi_event_pkt_cb_t *)0x0; + cb_pkt_env = (void *)0x0; + return 0; +} + + + +int bl_rx_rssi_cb_register(void *env,wifi_event_rssi_cb_t *cb) + +{ + cb_rssi = cb; + cb_rssi_env = env; + return 0; +} + + + +int bl_rx_event_register(void *env,wifi_event_cb_t *cb) + +{ + cb_event = cb; + cb_event_env = env; + return 0; +} + + + +void bl_rx_e2a_handler(void *arg) + +{ + // WARNING: Could not recover jumptable at 0x230242f0. Too many branches + // WARNING: Treating indirect jump as call + (*wifi_hw.cmd_mgr.msgind) + ((bl_cmd_mgr *)0x4201d5b0,(ipc_e2a_msg *)arg, + (msg_cb_fct *)msg_hdlrs[*(ushort *)arg >> 10][(uint)*(ushort *)arg & 0x3ff]); + return; +} + + + +void bl_rx_pkt_cb(uint8_t *pkt,int len) + +{ + if (cb_pkt != (wifi_event_pkt_cb_t *)0x0) { + // WARNING: Could not recover jumptable at 0x2302430a. Too many branches + // WARNING: Treating indirect jump as call + (*cb_pkt)(cb_pkt_env,pkt,len); + return; + } + return; +} + + + +void bl_tx_push(bl_hw *bl_hw,bl_txhdr_conflict1 *txhdr) + +{ + hostdesc *phVar1; + hostdesc *phVar2; + txdesc_host *ptVar3; + hostdesc_conflict44 *phVar4; + uint32_t *host_id; + + host_id = txhdr->p; + ptVar3 = ipc_host_txdesc_get(bl_hw->ipc_env); + if (&ptVar3->host == (hostdesc *)0x0) { + printf("%d:ASSERT_ERR(host)\n",0x37); + } + phVar1 = &ptVar3->host; + phVar4 = &txhdr->host; + do { + phVar2 = (hostdesc *)((int)&phVar1->pbuf_addr + 1); + *(undefined *)&phVar1->pbuf_addr = *(undefined *)&phVar4->pbuf_addr; + phVar1 = phVar2; + phVar4 = (hostdesc_conflict44 *)((int)&phVar4->pbuf_addr + 1); + } while ((hostdesc *)ptVar3->pad_txdesc != phVar2); + ipc_host_txdesc_push(bl_hw->ipc_env,host_id); + (bl_hw->stats).cfm_balance = (bl_hw->stats).cfm_balance + 1; + return; +} + + + +void bl_tx_resend(void) + +{ + bl_hw *bl_hw; + txdesc_host *ptVar1; + uint uVar2; + + vTaskEnterCritical(); + while ((txhdr_pos_r != txhdr_pos_w && + (ptVar1 = ipc_host_txdesc_get(bl_hw_static->ipc_env), bl_hw = bl_hw_static, + ptVar1 != (txdesc_host *)0x0))) { + uVar2 = txhdr_pos_r & 7; + txhdr_hodler[uVar2]->status = 0; + bl_tx_push(bl_hw,(bl_txhdr_conflict1 *)txhdr_hodler[uVar2]); + txhdr_pos_r = txhdr_pos_r + 1; + } + vTaskExitCritical(); + return; +} + + + +void bl_tx_try_flush(void) + +{ + txdesc_host *ptVar1; + bl_txhdr_conflict1 *txhdr; + + vTaskEnterCritical(); + while ((ptVar1 = ipc_host_txdesc_get(bl_hw_static->ipc_env), ptVar1 != (txdesc_host *)0x0 && + (txhdr = (bl_txhdr_conflict1 *)utils_list_pop_front(&tx_list_bl), + txhdr != (bl_txhdr_conflict1 *)0x0))) { + bl_tx_push(bl_hw_static,txhdr); + } + vTaskExitCritical(); + return; +} + + + +int bl_txdatacfm(void *pthis,void *host_id) + +{ + bl_txhdr_conflict *pbVar1; + int iVar2; + + pbVar1 = (bl_txhdr_conflict *)((-*(int *)((int)host_id + 4) & 3U) + *(int *)((int)host_id + 4)); + iVar2 = pbVar1->status; + if (iVar2 == 0) { + return -1; + } + if (iVar2 << 0xf < 0) { + if (((txhdr_pos_w + 1 ^ txhdr_pos_r) & 7) != 0) { + puts(" push back\r\n"); + txhdr_hodler[txhdr_pos_w & 7] = pbVar1; + txhdr_pos_w = txhdr_pos_w + 1; + return 0; + } + puts(" NOT push back when no mem\r\n"); + } + pbuf_free((pbuf *)host_id); + return 0; +} + + + +void bl_tx_notify(void) + +{ + if (taskHandle_output != (TaskHandle_t)0x0) { + xTaskGenericNotify(taskHandle_output,0,eIncrement,(uint32_t *)0x0); + return; + } + return; +} + + + +err_t bl_output(bl_hw *bl_hw,netif *netif,pbuf *p,int is_sta) + +{ + u16_t uVar1; + undefined2 uVar2; + utils_list_hdr *list_hdr; + err_t eVar3; + u8_t uVar4; + undefined3 extraout_var; + undefined uVar5; + pbuf *ppVar6; + uint8_t *mac; + int iVar7; + utils_list_hdr *puVar8; + + if ((bl_hw == (bl_hw *)0x0) || ((netif->flags & 4) == 0)) { + printf("[TX] wifi is down, return now\r\n"); + eVar3 = -0xb; + } + else { + if (taskHandle_output == (TaskHandle_t)0x0) { + taskHandle_output = xTaskGetCurrentTaskHandle(); + } + mac = (uint8_t *)p->payload; + uVar1 = p->tot_len; + bl_hw_static = bl_hw; + uVar4 = pbuf_header(p,0x80); + if (CONCAT31(extraout_var,uVar4) == 0) { + list_hdr = (utils_list_hdr *)((-(int)p->payload & 3U) + (int)p->payload); + memset(list_hdr,0,0x5c); + *(pbuf **)&list_hdr[2].next = p; + memcpy(list_hdr + 7,mac,6); + memcpy((void *)((int)&list_hdr[8].next + 2),mac + 6,6); + *(pbuf **)&list_hdr[3].next = p; + uVar2 = *(undefined2 *)(mac + 0xc); + *(undefined *)((int)&list_hdr[0xd].next + 2) = 0; + *(undefined2 *)&list_hdr[10].next = uVar2; + if (is_sta == 0) { + uVar5 = *(undefined *)&bl_hw->vif_index_ap; + } + else { + uVar5 = *(undefined *)&bl_hw->vif_index_sta; + } + *(undefined *)((int)&list_hdr[0xd].next + 3) = uVar5; + *(undefined2 *)((int)&list_hdr[0xe].next + 2) = 0; + *(u16_t *)&list_hdr[5].next = uVar1 - 0xe; + if (is_sta == 0) { + iVar7 = bl_utils_idx_lookup(bl_hw,mac); + *(char *)&list_hdr[0xe].next = (char)iVar7; + } + else { + *(char *)&list_hdr[0xe].next = (char)bl_hw->sta_idx; + } + puVar8 = list_hdr + 0xf; + iVar7 = 0; + ppVar6 = p; + do { + if (iVar7 == 0) { + list_hdr[0xf].next = (utils_list_hdr *)((int)ppVar6->payload + 0x8e); + list_hdr[0x13].next = (utils_list_hdr *)((uint)ppVar6->len - 0x8e); + } + else { + if (iVar7 == 4) { + printf("[TX] [PBUF] Please fix for bigger chained pbuf, total_len %d\r\n", + (uint)p->tot_len); + } + puVar8->next = (utils_list_hdr *)ppVar6->payload; + puVar8[4].next = (utils_list_hdr *)(uint)ppVar6->len; + } + ppVar6 = ppVar6->next; + iVar7 = iVar7 + 1; + puVar8 = puVar8 + 1; + } while (ppVar6 != (pbuf *)0x0); + if (2 < iVar7) { + printf("[TX] [LOOP] Chain Used %d\r\n",iVar7); + } + list_hdr[4].next = (utils_list_hdr *)0x11111111; + list_hdr[6].next = list_hdr + 1; + list_hdr[1].next = (utils_list_hdr *)0x0; + pbuf_ref(p); + vTaskEnterCritical(); + utils_list_push_back(&tx_list_bl,list_hdr); + vTaskExitCritical(); + bl_irq_handler(); + eVar3 = '\0'; + } + else { + printf("[TX] Reserve room failed for header\r\n"); + eVar3 = -0xc; + } + } + return eVar3; +} + + + +u8 bl_radarind(void *pthis,void *hostid) + +{ + return '\0'; +} + + + +u8 bl_msgackind(bl_hw *pthis,void *hostid) + +{ + (*(pthis->cmd_mgr).llind)(&pthis->cmd_mgr,(bl_cmd *)hostid); + return '\0'; +} + + + +void bl_prim_tbtt_ind(void *pthis) + +{ + return; +} + + + +void my_pbuf_free_custom(pbuf *p) + +{ + bl60x_firmwre_mpdu_free(p[1].payload); + return; +} + + + +undefined4 bl_dbgind(void) + +{ + return 0; +} + + + +void bl_sec_tbtt_ind(void) + +{ + return; +} + + + +void my_pbuf_free_custom_fake(void) + +{ + return; +} + + + +// WARNING: Control flow encountered bad instruction data + +int tcpip_stack_input(void *swdesc,uchar status,void *hwhdr,uint msdu_offset,wifi_pkt *pkt) + +{ + if ((status & 1) == 0) { + return -1; + } + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +int bl_utils_idx_lookup(bl_hw *bl_hw,uint8_t *mac) + +{ + bl_sta *__s1; + int iVar1; + int iVar2; + + __s1 = bl_hw->sta_table; + iVar1 = 0; + while ((__s1->is_used == '\0' || (iVar2 = memcmp(__s1,mac,6), iVar2 != 0))) { + iVar1 = iVar1 + 1; + __s1 = __s1 + 1; + if (iVar1 == 0xc) { + return wifi_hw.ap_bcmc_idx; + } + } + return iVar1; +} + + + +int bl_ipc_init(bl_hw *bl_hw,ipc_shared_env_tag_conflict21 *ipc_shared_mem) + +{ + code *local_30; + ipc_host_cb_tag cb; + + memset(&local_30,0,0x20); + cb.recv_data_ind = bl_radarind; + cb.recv_msg_ind = bl_msgackind; + cb.recv_msgack_ind = bl_dbgind; + local_30 = bl_txdatacfm; + cb.recv_dbg_ind = bl_prim_tbtt_ind; + cb.prim_tbtt_ind = bl_sec_tbtt_ind; + cb.send_data_cfm = (anon_subr_int_void_ptr_void_ptr_for_send_data_cfm *)0x0; + cb.recv_radar_ind = (anon_subr_uint8_t_void_ptr_void_ptr_for_recv_radar_ind *)0x0; + ipc_env = (ipc_host_env_tag *)pvPortMalloc(0xe4); + bl_hw->ipc_env = ipc_env; + ipc_host_init(ipc_env,(ipc_host_cb_tag *)&local_30,(ipc_shared_env_tag_conflict3 *)ipc_shared_mem, + bl_hw); + bl_cmd_mgr_init(&bl_hw->cmd_mgr); + return 0; +} + + + +void bl_utils_dump(void) + +{ + int iVar1; + uint uVar2; + int iVar3; + + puts("---------- bl_utils_dump -----------\r\n"); + printf("txdesc_free_idx: %lu(%lu)\r\n",ipc_env->txdesc_free_idx,ipc_env->txdesc_free_idx & 3); + printf("txdesc_used_idx: %lu(%lu)\r\n",ipc_env->txdesc_used_idx,ipc_env->txdesc_used_idx & 3); + iVar1 = 0; + printf("tx_host_id0 cnt: %d(used %ld)\r\n",4,ipc_env->txdesc_free_idx - ipc_env->txdesc_used_idx); + puts(" list: pbuf status ptr status\r\n"); + do { + uVar2 = ipc_env->txdesc_used_idx + iVar1; + if (uVar2 == ipc_env->txdesc_free_idx) break; + iVar1 = iVar1 + 1; + iVar3 = *(int *)((&(ipc_env->cb).recv_radar_ind)[(uVar2 & 3) + 0x10] + 4); + iVar3 = (-iVar3 & 3U) + iVar3; + printf(" [%lu]%p(%p:%08lX)\r\n",*(undefined4 *)(iVar3 + 0x18),*(undefined4 *)(iVar3 + 4)); + } while (iVar1 != 4); + puts("========== bl_utils_dump End =======\r\n"); + return; +} + + + +_Bool stateSnifferGuard(void *ch,event *event) + +{ + return (_Bool)(ch == (void *)(uint)*(byte *)event->data); +} + + + +_Bool stateConnectedIPYesGuard_ip_update(void *ch,event *event) + +{ + return (_Bool)(ch == (void *)(uint)*(byte *)event->data); +} + + + +void printErrMsg(void *stateData,event *event) + +{ + printf("ENTERED ERROR STATE!"); + return; +} + + + +void stateSnifferExit(void *stateData,event *event) + +{ + printf("[WF][SM] Exiting %s state\r\n",stateData); + return; +} + + + +void stateSnifferAction(void *oldStateData,event *event,void *newStateData) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n",oldStateData); + return; +} + + + +void stateConnectedIPNoAction_ipgot(void *oldStateData,event *event,void *newStateData) + +{ + uint *puVar1; + uint *puVar2; + uint uVar3; + uint uVar4; + + puVar1 = (uint *)((int)event->data + 0xd); + puVar2 = (uint *)((int)event->data + 0x11); + uVar4 = *puVar1; + uVar3 = *puVar2; + printf( + "[WF][SM] IP GOT IP:%u.%u.%u.%u, MASK: %u.%u.%u.%u, Gateway: %u.%u.%u.%u, dns1: %u.%u.%u.%u, dns2: %u.%u.%u.%u\r\n" + ,uVar4 & 0xff,uVar4 >> 8 & 0xff,(uint)(*(uint3 *)puVar1 >> 0x10),uVar4 >> 0x18,uVar3 & 0xff + ,uVar3 >> 8 & 0xff,(uint)(*(uint3 *)puVar2 >> 0x10)); + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n",oldStateData,newStateData); + return; +} + + + +void stateGlobalEnter(void *stateData,event *event) + +{ + printf("[WF][SM] Entering %s state\r\n",stateData); + return; +} + + + +void stateGlobalAction(void *oldStateData,event *event,void *newStateData) + +{ + printf("[WF][SM] Global Action\r\n"); + return; +} + + + +void stateConnectingEnter(void *stateData,event *event) + +{ + printf("[WF][SM] Entering %s state\r\n",stateData); + aos_post_event(2,8,0); + return; +} + + + +_Bool stateSnifferGuard_ChannelSet(void *ch,event *event) + +{ + byte *pbVar1; + + pbVar1 = (byte *)event->data; + if (ch == (void *)(uint)*pbVar1) { + bl_main_monitor_channel_set(*(int *)(pbVar1 + 1),*(int *)(pbVar1 + 5)); + return false; + } + return false; +} + + + +_Bool stateIdleGuard_sniffer(void *ev,event *event) + +{ + if (ev == (void *)(uint)*(byte *)event->data) { + bl_main_monitor(); + return true; + } + return false; +} + + + +void stateConnectedIPNoExit(void *stateData,event *event) + +{ + printf("[WF][SM] Exiting %s state\r\n",stateData); + xTimerGenericCommand((TimerHandle_t)((int)stateData + 0x20),3,0,(BaseType_t *)0x0,0); + xTimerGenericCommand((TimerHandle_t)((int)stateData + 0x20),5,0,(BaseType_t *)0x0,0); + return; +} + + + +void stateDisconnect_action_idle(void *oldStateData,event *event,void *newStateData) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n",oldStateData); + printf("[WF][SM] Removing STA interface...\r\n"); + bl_main_if_remove(wifiMgmr.wlan_sta.vif_index); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void stateDisconnect_action_reconnect(void *oldStateData,event *event,void *newStateData) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n",oldStateData); + printf("[WF][SM] Action Connect\r\n"); + printf(" ssid %s\r\n",(uint8_t *)((int)oldStateData + 0x4d)); + printf(" ssid len %u\r\n",*(undefined4 *)((int)oldStateData + 0x6e)); + printf(" psk %s\r\n",(uint8_t *)((int)oldStateData + 0x72)); + printf(" psk len %u\r\n",*(undefined4 *)((int)oldStateData + 0xf4)); + printf(" pmk %s\r\n",(uint8_t *)((int)oldStateData + 0xb3)); + printf(" pmk len %u\r\n",*(undefined4 *)((int)oldStateData + 0xf8)); + printf(" mac %02X:%02X:%02X:%02X:%02X:%02X\r\n", + (uint)*(byte *)((int)oldStateData + 0x101),(uint)*(byte *)((int)oldStateData + 0x100), + (uint)*(byte *)((int)oldStateData + 0xff),(uint)*(byte *)((int)oldStateData + 0xfe), + (uint)*(byte *)((int)oldStateData + 0xfd),(uint)*(byte *)((int)oldStateData + 0xfc)); + bl_main_connect((uint8_t *)((int)oldStateData + 0x4d),*(int *)((int)oldStateData + 0x6e), + (uint8_t *)((int)oldStateData + 0x72),*(int *)((int)oldStateData + 0xf4), + (uint8_t *)((int)oldStateData + 0xb3),*(int *)((int)oldStateData + 0xf8), + (uint8_t *)((int)oldStateData + 0xfc),'\0',_DAT_00000010); + aos_post_event(2,3,0); + return; +} + + + +void ip_obtaining_timeout(timer_cb_arg_t data) + +{ + pvTimerGetTimerID((TimerHandle_t)data); + printf("[WF][SM] IP obtaining timeout\r\n"); + wifi_mgmr_api_fw_disconnect(); + return; +} + + + +void stateConnectedIPNoEnter(void *stateData,event *event) + +{ + uint32_t uVar1; + uint32_t uVar2; + uint32_t uVar3; + uint32_t uVar4; + uint32_t uVar5; + TickType_t xOptionalValue; + ip4_addr_t iStack44; + ip4_addr_t addr_ipaddr; + ip4_addr_t addr_netmask; + ip4_addr_t addr_gw; + + printf("[WF][SM] Entering %s state\r\n",stateData); + xTimerCreateStatic("wifi IP obtaining",15000,0,stateData,ip_obtaining_timeout, + (StaticTimer_t *)(TimerHandle_t)((int)stateData + 0x20)); + xOptionalValue = xTaskGetTickCount(); + xTimerGenericCommand + ((TimerHandle_t)((int)stateData + 0x20),1,xOptionalValue,(BaseType_t *)0x0,0xffffffff); + vTaskEnterCritical(); + uVar5 = wifiMgmr.wlan_sta.ipv4.dns2; + uVar4 = wifiMgmr.wlan_sta.ipv4.dns1; + uVar3 = wifiMgmr.wlan_sta.ipv4.gw; + uVar2 = wifiMgmr.wlan_sta.ipv4.mask; + uVar1 = wifiMgmr.wlan_sta.ipv4.ip; + vTaskExitCritical(); + if (uVar1 == 0) { + printf("[WF][SM] DHCP Starting...%p\r\n",0x4201e474); + wifi_netif_dhcp_start((netif *)&wifiMgmr.wlan_sta.netif); + } + else { + printf("[WF][SM] Static IP Starting...%p\r\n",0x4201e474); + iStack44 = (ip_addr_t)uVar4; + dns_setserver('\0',(ip_addr_t *)&iStack44); + iStack44 = (ip_addr_t)uVar5; + dns_setserver('\x01',(ip_addr_t *)&iStack44); + iStack44 = (ip_addr_t)uVar1; + addr_ipaddr = uVar2; + addr_netmask = uVar3; + netifapi_netif_common((netif *)&wifiMgmr.wlan_sta.netif,dhcp_stop,(netifapi_errt_fn)0x0); + netifapi_netif_set_addr((netif *)&wifiMgmr.wlan_sta.netif,&iStack44,&addr_ipaddr,&addr_netmask); + } + aos_post_event(2,4,0); + return; +} + + + +_Bool stateConnectedIPNoGuard_disconnect(void *ch,event *event) + +{ + if (ch == (void *)(uint)*(byte *)event->data) { + bl_main_disconnect(); + return false; + } + return false; +} + + + +_Bool stateConnectedIPYesGuard_disconnect(void *ch,event *event) + +{ + if (ch == (void *)(uint)*(byte *)event->data) { + bl_main_disconnect(); + return false; + } + return false; +} + + + +_Bool stateConnectedIPYesGuard_rcconfig(void *ch,event *event) + +{ + byte *pbVar1; + + pbVar1 = (byte *)event->data; + if (ch == (void *)(uint)*pbVar1) { + printf("[WF][SM] rate config, use sta_idx 0, rate_config %04X\r\n",*(undefined4 *)(pbVar1 + 1)); + bl_main_rate_config('\0',*(uint16_t *)(pbVar1 + 1)); + } + return false; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void stateIdleAction_connect(void *oldStateData,event *event,void *newStateData) + +{ + void *pvVar1; + wifi_mgmr_profile_msg_t *profile_msg; + char *pcVar2; + + pvVar1 = event->data; + *(undefined *)((int)pvVar1 + 0x2d) = 0; + *(undefined *)((int)pvVar1 + 0x72) = 0; + printf("[WF][SM] Action Connect\r\n"); + profile_msg = (wifi_mgmr_profile_msg_t *)((int)pvVar1 + 0xd); + printf(" ssid %s\r\n",profile_msg); + printf(" ssid len %u\r\n",*(undefined4 *)((int)pvVar1 + 0x2e)); + printf(" psk %s\r\n",(uint8_t *)((int)pvVar1 + 0x32)); + printf(" psk len %u\r\n",*(undefined4 *)((int)pvVar1 + 0xb4)); + printf(" pmk %s\r\n",(uint8_t *)((int)pvVar1 + 0x73)); + printf(" pmk len %u\r\n",*(undefined4 *)((int)pvVar1 + 0xb8)); + printf(" channel band %d\r\n",(uint)*(byte *)((int)pvVar1 + 0xc2)); + printf(" channel freq %d\r\n",(uint)*(ushort *)((int)pvVar1 + 0xc3)); + printf(" mac %02X:%02X:%02X:%02X:%02X:%02X\r\n",(uint)*(byte *)((int)pvVar1 + 0xc1), + (uint)*(byte *)((int)pvVar1 + 0xc0),(uint)*(byte *)((int)pvVar1 + 0xbf), + (uint)*(byte *)((int)pvVar1 + 0xbe),(uint)*(byte *)((int)pvVar1 + 0xbd), + (uint)*(byte *)((int)pvVar1 + 0xbc)); + if (*(char *)((int)pvVar1 + 0xc5) == '\0') { + pcVar2 = "false"; + } + else { + pcVar2 = "true"; + } + printf(" dhcp status: %s\r\n",pcVar2); + wifi_mgmr_profile_add(&wifiMgmr,profile_msg,-1); + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n",oldStateData,newStateData); + bl_main_connect((uint8_t *)profile_msg,*(int *)((int)pvVar1 + 0x2e), + (uint8_t *)((int)pvVar1 + 0x32),*(int *)((int)pvVar1 + 0xb4), + (uint8_t *)((int)pvVar1 + 0x73),*(int *)((int)pvVar1 + 0xb8), + (uint8_t *)((int)pvVar1 + 0xbc),*(uint8_t *)((int)pvVar1 + 0xc2),_DAT_00000010); + return; +} + + + +_Bool stateGlobal_cfg_req(void *ch,event *event) + +{ + char *pcVar1; + + pcVar1 = (char *)event->data; + if (*pcVar1 == '\x16') { + bl_main_cfg_task_req + (*(uint32_t *)(pcVar1 + 0xd),*(uint32_t *)(pcVar1 + 0x11),*(uint32_t *)(pcVar1 + 0x15) + ,*(uint32_t *)(pcVar1 + 0x19),pcVar1 + 0x21,(void *)0x0); + return false; + } + return false; +} + + + +_Bool stateGlobalGuard_fw_powersaving(void *ch,event *event) + +{ + char *pcVar1; + + pcVar1 = (char *)event->data; + if (*pcVar1 == '\x10') { + printf("------>>>>>> Powersaving CMD, mode: %u\r\n",*(undefined4 *)(pcVar1 + 1)); + bl_main_powersaving(*(int *)(pcVar1 + 1)); + } + return false; +} + + + +_Bool stateGlobalGuard_conf_max_sta(void *ev,event *event) + +{ + char *pcVar1; + + pcVar1 = (char *)event->data; + if (*pcVar1 == '\n') { + printf("[WF][SM] Conf max sta supported %lu...\r\n",*(undefined4 *)(pcVar1 + 1)); + bl_main_conf_max_sta(pcVar1[1]); + } + return false; +} + + + +_Bool stateGlobalGuard_AP(void *ev,event *event) + +{ + char "stateGlobalGuard_AP" [20]; + char *pcVar1; + int iVar2; + + pcVar1 = (char *)event->data; + if (*pcVar1 == '\b') { + iVar2 = bl_main_if_add(0,(netif *)&wifiMgmr.wlan_ap.netif,&wifiMgmr.wlan_ap.vif_index); + if (iVar2 == 0) { + netifapi_netif_common + ((netif *)&wifiMgmr.wlan_ap.netif,netif_set_link_up,(netifapi_errt_fn)0x0); + netifapi_netif_common((netif *)&wifiMgmr.wlan_ap.netif,dhcpd_start,(netifapi_errt_fn)0x0); + printf("[WF][SM] start AP with ssid %s;\r\n",pcVar1 + 0x11); + printf("[WF][SM] pwd %s;\r\n",pcVar1 + 0x37); + printf("[WF][SM] channel %ld;\r\n",*(undefined4 *)(pcVar1 + 0xd)); + bl_main_apm_start(pcVar1 + 0x11,pcVar1 + 0x37,*(int *)(pcVar1 + 0xd), + wifiMgmr.wlan_ap.vif_index,pcVar1[0x32]); + wifiMgmr.inf_ap_enabled = 1; + dns_server_init(); + aos_post_event(2,0xb,0); + } + else { + printf("[WF][SM] %s: add AP iface failed\r\n","stateGlobalGuard_AP"); + } + } + return false; +} + + + +_Bool stateGlobalGuard_scan_beacon(void *ch,event *event) + +{ + byte bVar1; + bool bVar2; + byte *pbVar3; + int iVar4; + int iVar5; + TickType_t TVar6; + size_t sVar7; + int iVar8; + int iVar9; + TickType_t TVar10; + uint32_t uVar11; + wifi_mgmr_t *pwVar12; + int iVar13; + wifi_mgmr_scan_item_t *__s; + uint32_t uVar14; + + pbVar3 = (byte *)event->data; + if (ch == (void *)(uint)*pbVar3) { + pwVar12 = &wifiMgmr; + if ((((int)(uint)pbVar3[0x3b] <= wifiMgmr.channel_nums) && (pbVar3[0x3b] != 0)) && + ((pbVar3[0xd] != 0 || ((wifiMgmr.features & 1) != 0)))) { + TVar6 = xTaskGetTickCount(); + bVar2 = false; + uVar14 = 0xffffffff; + iVar4 = -1; + iVar13 = 0; + iVar9 = -1; + do { + iVar5 = iVar13; + if (wifiMgmr.channel_nums < (int)(uint)pwVar12->scan_items[0].channel) { + memset(pwVar12->scan_items,0,0x3c); + pwVar12->scan_items[0].is_used = '\0'; + } + else { + if (pwVar12->scan_items[0].is_used != '\0') { + uVar11 = pwVar12->scan_items[0].timestamp_lastseen; + if ((!bVar2) || ((int)(uVar11 - uVar14) < 0)) { + iVar4 = iVar13; + uVar14 = uVar11; + } + iVar8 = memcmp(pwVar12->scan_items[0].bssid,pbVar3 + 0x35,6); + iVar5 = iVar9; + bVar2 = true; + if ((iVar8 == 0) && + (iVar9 = strcmp((char *)(pbVar3 + 0xd),(char *)pwVar12->scan_items), bVar2 = true, + iVar9 == 0)) { + if (((char)pbVar3[0x3c] < wifiMgmr.scan_items[iVar13].rssi) && + (TVar10 = xTaskGetTickCount(), + (int)(TVar10 - wifiMgmr.scan_items[iVar13].timestamp_lastseen) < 3000)) { + return false; + } + wifiMgmr.scan_items[iVar13].channel = pbVar3[0x3b]; + wifiMgmr.scan_items[iVar13].rssi = pbVar3[0x3c]; + wifiMgmr.scan_items[iVar13].ppm_abs = pbVar3[0x3d]; + bVar1 = pbVar3[0x3e]; + wifiMgmr.scan_items[iVar13].timestamp_lastseen = TVar6; + wifiMgmr.scan_items[iVar13].ppm_rel = bVar1; + wifiMgmr.scan_items[iVar13].auth = pbVar3[0x3f]; + wifiMgmr.scan_items[iVar13].cipher = pbVar3[0x40]; + return false; + } + } + } + iVar13 = iVar13 + 1; + pwVar12 = (wifi_mgmr_t *)&(pwVar12->wlan_sta).netif.input; + iVar9 = iVar5; + } while (iVar13 != 0x32); + if ((iVar5 != -1) || (iVar5 = iVar4, iVar4 != -1)) { + __s = wifiMgmr.scan_items + iVar5; + memset(__s,0,0x3c); + strncpy((char *)__s,(char *)(pbVar3 + 0xd),0x20); + wifiMgmr.scan_items[iVar5].ssid_tail[0] = '\0'; + sVar7 = strlen((char *)__s); + wifiMgmr.scan_items[iVar5].ssid_len = sVar7; + memcpy(wifiMgmr.scan_items[iVar5].bssid,pbVar3 + 0x35,6); + wifiMgmr.scan_items[iVar5].channel = pbVar3[0x3b]; + bVar1 = pbVar3[0x3c]; + wifiMgmr.scan_items[iVar5].timestamp_lastseen = TVar6; + wifiMgmr.scan_items[iVar5].rssi = bVar1; + wifiMgmr.scan_items[iVar5].auth = pbVar3[0x3f]; + wifiMgmr.scan_items[iVar5].cipher = pbVar3[0x40]; + wifiMgmr.scan_items[iVar5].is_used = '\x01'; + } + } + } + return false; +} + + + +void __reload_tsen(timer_cb_arg_t data) + +{ + pvTimerGetTimerID((TimerHandle_t)data); + wifi_mgmr_api_fw_tsen_reload(); + return; +} + + + +void event_cb_wifi_event_mgmr(input_event_t *event,void *private_data) + +{ + if (event->code == 0x14) { + aos_post_delayed_action(0x55,trigger_auto_denoise,(void *)0x0); + return; + } + return; +} + + + +void trigger_auto_denoise(void *arg) + +{ + if (auto_repeat != 0) { + wifi_mgmr_api_denoise_enable(); + aos_post_delayed_action(0x55,trigger_auto_denoise,(void *)0x0); + return; + } + return; +} + + + +void stateDisconnect_exit(void *stateData,event *event) + +{ + printf("[WF][SM] Exiting %s state\r\n",stateData); + if (*(char *)((int)stateData + 0x4c) != '\0') { + printf("Delete Timer.\r\n"); + xTimerGenericCommand((TimerHandle_t)((int)stateData + 0x20),3,0,(BaseType_t *)0x0,0); + xTimerGenericCommand((TimerHandle_t)((int)stateData + 0x20),5,0,(BaseType_t *)0x0,0); + *(undefined *)((int)stateData + 0x4c) = 0; + return; + } + printf("Delete Timer Skipped\r\n"); + return; +} + + + +void disconnect_retry(timer_cb_arg_t data) + +{ + void *pvVar1; + int iVar2; + + pvVar1 = pvTimerGetTimerID((TimerHandle_t)data); + iVar2 = wifi_mgmr_profile_get(&wifiMgmr,(wifi_mgmr_profile_msg_t *)((int)pvVar1 + 0x4d)); + if (iVar2 != 0) { + printf("[WF][SM] Retry Again --->>> retry Abort, since profile copy failed\r\n"); + return; + } + printf("[WF][SM] Retry Again --->>> retry connect\r\n"); + wifi_mgmr_api_reconnect(); + return; +} + + + +_Bool stateGlobalGuard_fw_disconnect(void *ch,event *event) + +{ + if (*(char *)event->data == '\x0f') { + printf("Disconnect CMD\r\n"); + bl_main_disconnect(); + return false; + } + return false; +} + + + +void stateConnectedIPYes_exit(void *stateData,event *event) + +{ + ip4_addr_t iStack20; + ip4_addr_t addr_ipaddr; + + iStack20 = (ip4_addr_t)0x0; + printf("[WF][SM] Exiting %s state\r\n",stateData); + netifapi_netif_common((netif *)&wifiMgmr.wlan_sta.netif,dhcp_stop,(netifapi_errt_fn)0x0); + netifapi_netif_set_addr((netif *)&wifiMgmr.wlan_sta.netif,&iStack20,&iStack20,&iStack20); + if (auto_repeat != 0) { + auto_repeat = 0; + bl_main_denoise(0); + } + return; +} + + + +_Bool stateGlobalGuard_denoise(void *ev,event *event) + +{ + int mode; + + if (*(char *)event->data != '\f') { + return false; + } + if (*(int *)(event->data + 1) == 0) { + auto_repeat = 0; + mode = 0; + } + else { + if (wifiMgmr.m.currentState != &stateConnectedIPYes) { + return false; + } + mode = 3; + if (auto_repeat == 0) { + auto_repeat = 1; + bl_main_denoise(1); + aos_post_event(2,0x14,0); + return false; + } + } + bl_main_denoise(mode); + return false; +} + + + +_Bool stateIdleGuard_connect(void *ev,event *event) + +{ + int iVar1; + + if (ev == (void *)(uint)*(byte *)event->data) { + iVar1 = bl_main_if_add(1,(netif *)&wifiMgmr.wlan_sta.netif,&wifiMgmr.wlan_sta.vif_index); + if (iVar1 != 0) { + printf("[WF][SM] %s: add STA iface failed\r\n","stateIdleGuard_connect"); + } + return (_Bool)(iVar1 == 0); + } + return false; +} + + + +_Bool stateIfaceDownGuard_phyup(void *ev,event *event) + +{ + bool bVar1; + int iVar2; + + if (ev == (void *)(uint)*(byte *)event->data) { + iVar2 = bl_main_phy_up(); + bVar1 = iVar2 == 0; + } + else { + printf("[WF][SM] state mismatch\r\n"); + bVar1 = false; + } + return (_Bool)bVar1; +} + + + +_Bool stateSnifferGuard_raw_send(void *ch,event *event) + +{ + char *pcVar1; + + if (((wifiMgmr.m.currentState != &stateIdle) && (wifiMgmr.m.currentState != &stateIfaceDown)) && + (pcVar1 = (char *)event->data, *pcVar1 == '\x15')) { + bl_main_raw_send(*(uint8_t **)(pcVar1 + 1),*(int *)(pcVar1 + 5)); + return false; + } + return false; +} + + + +_Bool stateGlobalGuard_stop(void *ev,event *event) + +{ + if (*(char *)event->data == '\t') { + printf("[WF][SM] Stoping AP interface...\r\n"); + bl_main_apm_stop(wifiMgmr.wlan_ap.vif_index); + printf("[WF][SM] Removing and deauth all sta client...\r\n"); + bl_main_apm_remove_all_sta(); + printf("[WF][SM] Removing AP interface...\r\n"); + bl_main_if_remove(wifiMgmr.wlan_ap.vif_index); + printf("[WF][SM] Stopping DHCP on AP interface...\r\n"); + netifapi_netif_common((netif *)&wifiMgmr.wlan_ap.netif,(netifapi_void_fn)0x0,dhcp_server_stop); + printf("[WF][SM] Removing ETH interface ...\r\n"); + netifapi_netif_common((netif *)&wifiMgmr.wlan_ap.netif,netif_remove,(netifapi_errt_fn)0x0); + wifiMgmr.inf_ap_enabled = 0; + aos_post_event(2,0xc,0); + return false; + } + return false; +} + + + +_Bool stateGlobalGuard_enable_autoreconnect(void *ch,event *event) + +{ + if (ch == (void *)(uint)*(byte *)event->data) { + printf("Enable Auto Reconnect\r\n"); + wifi_mgmr_profile_autoreconnect_enable(&wifiMgmr,-1); + return false; + } + return false; +} + + + +_Bool stateGlobalGuard_disable_autoreconnect(void *ch,event *event) + +{ + bool bVar1; + + if (ch == (void *)(uint)*(byte *)event->data) { + bVar1 = wifiMgmr.m.currentState != &stateDisconnect; + if (bVar1) { + printf("Disable Auto Reconnect\r\n"); + wifi_mgmr_profile_autoreconnect_disable(&wifiMgmr,-1); + } + else { + printf("Disable Autoreconnect in Disconnec State\r\n"); + printf("[WF][SM] Removing STA interface...\r\n"); + bl_main_if_remove(wifiMgmr.wlan_sta.vif_index); + } + return (_Bool)!bVar1; + } + return false; +} + + + +// WARNING: Variable defined which should be unmapped: is_ok + +void stateDisconnect_enter(void *stateData,event *event) + +{ + int iVar1; + TickType_t xOptionalValue; + uint uVar2; + uint uStack20; + int is_ok; + + uStack20 = 0; + printf("[WF][SM] Entering %s state\r\n",stateData); + iVar1 = wifi_mgmr_profile_autoreconnect_is_enabled(&wifiMgmr,-1); + if (iVar1 == 0) { + printf("[WF][SM] Will NOT retry connect\r\n"); + } + else { + xTimerCreateStatic("wifi disconnect",2000,0,stateData,disconnect_retry, + (StaticTimer_t *)(TimerHandle_t)((int)stateData + 0x20)); + printf("[WF][SM] Will retry in 2000 ticks\r\n"); + xOptionalValue = xTaskGetTickCount(); + xTimerGenericCommand + ((TimerHandle_t)((int)stateData + 0x20),1,xOptionalValue,(BaseType_t *)0x0,0xffffffff) + ; + *(undefined *)((int)stateData + 0x4c) = 1; + } + aos_post_event(2,5,(uint)wifiMgmr.wifi_mgmr_stat_info.status_code); + uVar2 = bl60x_check_mac_status((int *)&uStack20); + if ((uVar2 | uStack20) == 0) { + aos_post_event(2,0x17,0); + helper_record_dump(); + } + if ((wifiMgmr.pending_task & 1) != 0) { + printf("[WF][SM] Pending Scan Sent\r\n"); + bl_main_scan(); + wifiMgmr.pending_task = wifiMgmr.pending_task & 0xfffffffe; + } + return; +} + + + +_Bool stateGlobalGuard_fw_scan(void *ch,event *event) + +{ + if (*(char *)event->data == '\x12') { + if (((wifiMgmr.m.currentState == &stateConnecting) || + (wifiMgmr.m.currentState == &stateConnectedIPNo)) || + (wifiMgmr.m.currentState == &stateDisconnect)) { + printf("------>>>>>> Scan CMD Pending\r\n"); + wifiMgmr.pending_task = wifiMgmr.pending_task | 1; + } + else { + if (((wifiMgmr.m.currentState == &stateIdle) || + (wifiMgmr.m.currentState == &stateConnectedIPYes)) || + (wifiMgmr.m.currentState == &stateSniffer)) { + printf("------>>>>>> Scan CMD\r\n"); + bl_main_scan(); + } + else { + printf("------>>>>>> FW busy\r\n"); + aos_post_event(2,9,1); + } + } + return false; + } + return false; +} + + + +uint stateDisconnect_guard(uint param_1,int param_2) + +{ + return (uint)(param_1 == (uint)**(byte **)(param_2 + 4)); +} + + + +void stateGlobalExit(void) + +{ + printf("[WF][SM] Entering %s state\r\n"); + return; +} + + + +void stateSnifferEnter(void) + +{ + printf("[WF][SM] Entering %s state\r\n"); + return; +} + + + +uint stateConnectingGuard(uint param_1,int param_2) + +{ + return (uint)(param_1 == (uint)**(byte **)(param_2 + 4)); +} + + + +void stateConnectingAction_connected(void) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n"); + return; +} + + + +void stateConnectingAction_disconnect(void) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n"); + return; +} + + + +void stateConnectingExit(void) + +{ + printf("[WF][SM] Exiting %s state\r\n"); + return; +} + + + +void stateIdleAction_sniffer(void) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n"); + return; +} + + + +void stateIdleEnter(void) + +{ + printf("[WF][SM] Entering %s state\r\n"); + return; +} + + + +void stateIdleExit(void) + +{ + printf("[WF][SM] Entering %s state\r\n"); + return; +} + + + +void stateIfaceDownAction_phyup(void) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n"); + return; +} + + + +void stateIfaceDownEnter(void) + +{ + printf("[WF][SM] Entering %s state\r\n"); + return; +} + + + +void stateIfaceDownExit(void) + +{ + printf("[WF][SM] Exiting %s state\r\n"); + return; +} + + + +uint stateConnectedIPNoGuard(uint param_1,int param_2) + +{ + return (uint)(param_1 == (uint)**(byte **)(param_2 + 4)); +} + + + +void stateConnectedIPNoAction_disconnect(void) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n"); + return; +} + + + +uint stateConnectedIPYesGuard(uint param_1,int param_2) + +{ + return (uint)(param_1 == (uint)**(byte **)(param_2 + 4)); +} + + + +void stateConnectedIPYes_action(void) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n"); + return; +} + + + +void stateConnectedIPYes_enter(void *stateData,event *event) + +{ + printf("[WF][SM] Entering %s state\r\n",stateData); + aos_post_event(2,7,0); + if ((wifiMgmr.pending_task & 1) != 0) { + printf("[WF][SM] Pending Scan Sent\r\n"); + bl_main_scan(); + wifiMgmr.pending_task = wifiMgmr.pending_task & 0xfffffffe; + } + return; +} + + + +char * wifi_mgmr_auth_to_str(uint8_t auth) + +{ + undefined3 in_register_00002029; + + switch(CONCAT31(in_register_00002029,auth)) { + case 0: + return "Open"; + case 1: + return "WEP"; + case 2: + return "WPA-PSK"; + case 3: + return "WPA2-PSK"; + case 4: + return "WPA2-PSK/WPA-PSK"; + case 5: + return "WPA/WPA2-Enterprise"; + default: + return "Unknown"; + } +} + + + +char * wifi_mgmr_cipher_to_str(uint8_t cipher) + +{ + undefined3 in_register_00002029; + int iVar1; + + iVar1 = CONCAT31(in_register_00002029,cipher); + if (iVar1 == 0) { + return "NONE"; + } + if (iVar1 == 1) { + return "WEP"; + } + if (iVar1 == 2) { + return "AES"; + } + if (iVar1 != 3) { + if (iVar1 != 4) { + return "Unknown"; + } + return "TKIP/AES"; + } + return "TKIP"; +} + + + +int wifi_mgmr_event_notify(wifi_mgmr_msg_t *msg) + +{ + size_t sVar1; + int iVar2; + + while (wifiMgmr.ready == '\0') { + printf("Wait Wi-Fi Mgmr Start up...\r\n"); + vTaskDelay(0x14); + } + sVar1 = xStreamBufferSend((StreamBufferHandle_t)&wifiMgmr.mq,msg,msg->len,0xffffffff); + iVar2 = 0; + if (sVar1 == 0) { + printf("Failed when send msg 0x%p, len dec:%u\r\n",msg,msg->len); + iVar2 = -1; + } + return iVar2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void wifi_mgmr_start(void) + +{ + TickType_t xOptionalValue; + size_t sVar1; + void *pvRxData; + int16_t iStack274; + int16_t temp; + int iStack272; + event ev; + uint8_t buffer [232]; + + pvRxData = (void *)((int)&ev.data + 1); + iStack272 = 1; + ev.type = (int)pvRxData; + stateM_init(&wifiMgmr.m,&stateIfaceDown,&stateError); + wifi_mgmr_event_init(); + aos_register_event_filter(2,event_cb_wifi_event_mgmr,(void *)0x0); + aos_post_event(2,2,0); + hal_sys_capcode_update(-1,-1); + printf("[WF][SM] reload tsen \r\n"); + xTimerCreateStatic("wifi reload tsen",10000,1,&state_tsen_reload_data,__reload_tsen, + (StaticTimer_t *)&state_tsen_reload_data.timer); + xOptionalValue = xTaskGetTickCount(); + xTimerGenericCommand + ((TimerHandle_t)&state_tsen_reload_data.timer,1,xOptionalValue,(BaseType_t *)0x0, + 0xffffffff); + do { + while( true ) { + do { + sVar1 = xStreamBufferReceive((StreamBufferHandle_t)&wifiMgmr.mq,pvRxData,0xe0,0xffffffff); + } while (sVar1 == 0); + if (ev.data._1_1_ != 0xd) break; + iStack274 = 0; + if ((((wifiMgmr.m.currentState == &stateConnecting) || + (wifiMgmr.m.currentState == &stateDisconnect)) || + (wifiMgmr.m.currentState == &stateConnectedIPYes)) || + ((wifiMgmr.m.currentState == &stateSniffer || + (wifiMgmr.m.currentState == &stateConnectedIPNo)))) { + bl_tsen_adc_get(&iStack274,0); + phy_tcal_callback(iStack274); + } + } + iStack272 = 1; + if (0xd < ev.data._1_1_) { + iStack272 = (uint)(0x16 < ev.data._1_1_) << 1; + } + stateM_handleEvent(&wifiMgmr.m,(event *)&stack0xfffffef0); + } while( true ); +} + + + +void _wifi_mgmr_entry(void *pvParameters) + +{ + wifi_conf_t *conf; + TaskHandle_t aptStack36 [4]; + code *pcStack20; + + pcStack20 = wifi_mgmr_start_background; + conf = (wifi_conf_t *)wifi_mgmr_start(); + wifi_mgmr_drv_init(conf); + aptStack36[0] = (TaskHandle_t)0x0; + xTaskCreate(_wifi_mgmr_entry,"wifi_mgmr",0x300,(void *)0x0,0x1c,aptStack36); + return; +} + + + +void wifi_mgmr_start_background(wifi_conf_t *conf) + +{ + TaskHandle_t ptStack20; + TaskHandle_t xHandle; + + wifi_mgmr_drv_init(conf); + ptStack20 = (TaskHandle_t)0x0; + xTaskCreate(_wifi_mgmr_entry,"wifi_mgmr",0x300,(void *)0x0,0x1c,&ptStack20); + return; +} + + + +int wifi_mgmr_init(void) + +{ + StreamBufferHandle_t pSVar1; + + pSVar1 = xStreamBufferGenericCreateStatic + (0x8c0,0,1,wifiMgmr.mq_pool,(StaticStreamBuffer_t *)&wifiMgmr.mq); + wifiMgmr.ready = '\x01'; + wifiMgmr.scan_item_timeout = 15000; + return (uint)(pSVar1 == (StreamBufferHandle_t)0x0); +} + + + +int wifi_mgmr_state_get_internal(int *state) + +{ + uint16_t uVar1; + int iVar2; + + uVar1 = wifiMgmr.wifi_mgmr_stat_info.status_code; + if (wifiMgmr.m.currentState == &stateIdle) { + if (wifiMgmr.inf_ap_enabled != 0) { + iVar2 = 0x11; + goto LAB_230262ac; + } + iVar2 = 1; + } + else { + if (wifiMgmr.m.currentState == &stateConnecting) { + if (wifiMgmr.inf_ap_enabled != 0) { + iVar2 = 0x12; + goto LAB_230262ac; + } + iVar2 = 2; + } + else { + if (wifiMgmr.m.currentState == &stateConnectedIPNo) { + if (wifiMgmr.inf_ap_enabled == 0) { + iVar2 = 3; + } + else { + iVar2 = 0x13; + } + goto LAB_230262ac; + } + if (wifiMgmr.m.currentState == &stateConnectedIPYes) { + if (wifiMgmr.inf_ap_enabled == 0) { + iVar2 = 4; + } + else { + iVar2 = 0x14; + } + goto LAB_230262ac; + } + if (wifiMgmr.m.currentState != &stateDisconnect) { + if (wifiMgmr.m.currentState == &stateIfaceDown) { + iVar2 = 6; + } + else { + if (wifiMgmr.m.currentState != &stateSniffer) { + *state = 0; + return 0; + } + iVar2 = 7; + } + goto LAB_230262ac; + } + if (wifiMgmr.inf_ap_enabled != 0) { + iVar2 = 0x15; + goto LAB_230262ac; + } + iVar2 = 5; + } + } + *state = iVar2; + if (uVar1 == 8) { + iVar2 = 8; + } + else { + if (uVar1 != 0xc) { + return 0; + } + iVar2 = 9; + } +LAB_230262ac: + *state = iVar2; + return 0; +} + + + +void wifi_mgmr_set_connect_stat_info(wifi_event_sm_connect_ind *ind,uint8_t type_ind) + +{ + uint8_t uVar1; + uint8_t *puVar2; + uint8_t *puVar3; + + wifiMgmr.wifi_mgmr_stat_info.status_code = ind->status_code; + puVar2 = ind->bssid; + puVar3 = wifiMgmr.wifi_mgmr_stat_info.bssid; + do { + uVar1 = *puVar2; + puVar2 = puVar2 + 1; + *puVar3 = uVar1; + puVar3 = puVar3 + 1; + } while (puVar2 != &ind->vif_idx); + wifiMgmr.wifi_mgmr_stat_info.type_ind = type_ind; + wifiMgmr.wifi_mgmr_stat_info.chan_freq = ind->center_freq; + wifiMgmr.wifi_mgmr_stat_info.chan_band = ind->band; + return; +} + + + +int wifi_mgmr_set_country_code_internal(char *country_code) + +{ + bl_main_set_country_code(country_code); + strncpy(wifiMgmr.country_code,country_code,3); + wifiMgmr.country_code[2] = '\0'; + wifiMgmr.channel_nums = bl_main_get_channel_nums(); + return 0; +} + + + +int wifi_mgmr_ap_sta_cnt_get_internal(uint8_t *sta_cnt) + +{ + bl_main_apm_sta_cnt_get(sta_cnt); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +int wifi_mgmr_ap_sta_info_get_internal(wifi_mgmr_sta_basic_info_t *sta_info_internal,uint8_t idx) + +{ + undefined2 uStack40; + wifi_apm_sta_info apm_sta_info; + + memset(&uStack40,0,0x18); + bl_main_apm_sta_info_get((wifi_apm_sta_info *)&uStack40,idx); + *(undefined2 *)sta_info_internal = uStack40; + sta_info_internal->rssi = apm_sta_info.tsflo; + sta_info_internal->tsflo = apm_sta_info.tsfhi; + sta_info_internal->tsfhi = apm_sta_info.sta_mac._2_4_; + sta_info_internal->data_rate = (uint8_t)apm_sta_info.rssi; + memcpy(sta_info_internal->sta_mac,&uStack40 + 1,6); + return 0; +} + + + +int wifi_mgmr_ap_sta_delete_internal(uint8_t sta_idx) + +{ + bl_main_apm_sta_delete(sta_idx); + return 0; +} + + + +int wifi_mgmr_scan_complete_notify(void) + +{ + wifi_mgmr_scan_complete_callback(); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int wifi_mgmr_api_connect(char *ssid,char *psk,char *pmk,uint8_t *mac,uint8_t band,uint16_t freq) + +{ + size_t __n; + int iVar1; + undefined3 in_register_00002039; + undefined2 in_register_0000203e; + WIFI_MGMR_EVENT_T WStack232; + undefined uStack231; + undefined uStack230; + undefined uStack229; + uint8_t buffer [198]; + + memset(&WStack232,0,0xc6); + WStack232 = WIFI_MGMR_EVENT_APP_CONNECT; + uStack231 = 0x44; + uStack230 = 0x33; + uStack229 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = -0x3a; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + __n = strlen(ssid); + buffer._42_2_ = (undefined2)__n; + buffer._44_2_ = (undefined2)(__n >> 0x10); + memcpy(buffer + 9,ssid,__n); + buffer[41] = '\0'; + if (psk == (char *)0x0) { + buffer._176_4_ = 0; +LAB_23026504: + buffer[110] = '\0'; + if (pmk == (char *)0x0) { + buffer._180_4_ = 0; + } + else { + buffer._180_4_ = strlen(pmk); + if (buffer._180_4_ != 0) { + if (buffer._180_4_ != 0x40) goto LAB_23026562; + memcpy(buffer + 0x6f,pmk,0x40); + } + } + buffer[175] = '\0'; + if (mac != (uint8_t *)0x0) { + memcpy(buffer + 0xb8,mac,6); + } + if (CONCAT22(in_register_0000203e,freq) != 0) { + buffer[191] = (uint8_t)freq; + buffer[192] = (uint8_t)(freq >> 8); + buffer[190] = band; + printf("wifi mgmr band:%d freq: %d\r\n",CONCAT31(in_register_00002039,band), + CONCAT22(in_register_0000203e,freq)); + } + buffer[193] = '\x01'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack232); + iVar1 = 0; + } + else { + buffer._176_4_ = strlen(psk); + if (buffer._176_4_ < 0x41) { + if (buffer._176_4_ != 0) { + memcpy(buffer + 0x2e,psk,buffer._176_4_); + } + goto LAB_23026504; + } +LAB_23026562: + iVar1 = -1; + } + return iVar1; +} + + + +int wifi_mgmr_api_cfg_req + (uint32_t ops,uint32_t task,uint32_t element,uint32_t type,uint32_t length, + uint32_t *buf) + +{ + int iVar1; + WIFI_MGMR_EVENT_T WStack100; + undefined uStack99; + undefined uStack98; + undefined uStack97; + uint8_t buffer [65]; + + if (length < 0x21) { + memset(&WStack100,0,0x41); + WStack100 = WIFI_MGMR_EVENT_FW_CFG_REQ; + uStack99 = 0x44; + uStack98 = 0x33; + uStack97 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + iVar1 = length + 0xc6; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[6] = (uint8_t)((uint)iVar1 >> 8); + buffer[7] = (uint8_t)((uint)iVar1 >> 0x10); + buffer[10] = (uint8_t)(ops >> 8); + buffer[11] = (uint8_t)(ops >> 0x10); + buffer[14] = (uint8_t)(task >> 8); + buffer[15] = (uint8_t)(task >> 0x10); + buffer[18] = (uint8_t)(element >> 8); + buffer[19] = (uint8_t)(element >> 0x10); + buffer[22] = (uint8_t)(type >> 8); + buffer[23] = (uint8_t)(type >> 0x10); + buffer[5] = (uint8_t)iVar1; + buffer[9] = (uint8_t)ops; + buffer[13] = (uint8_t)task; + buffer[17] = (uint8_t)element; + buffer[21] = (uint8_t)type; + buffer[26] = (uint8_t)(length >> 8); + buffer[27] = (uint8_t)(length >> 0x10); + buffer[8] = (uint8_t)((uint)iVar1 >> 0x18); + buffer[12] = (uint8_t)(ops >> 0x18); + buffer[16] = (uint8_t)(task >> 0x18); + buffer[20] = (uint8_t)(element >> 0x18); + buffer[24] = (uint8_t)(type >> 0x18); + buffer[25] = (uint8_t)length; + buffer[28] = (uint8_t)(length >> 0x18); + if (length != 0) { + memcpy(buffer + 0x1d,buf,length); + } + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack100); + return 0; + } + return -1; +} + + + +// WARNING: Variable defined which should be unmapped: buffer + +int wifi_mgmr_api_ip_got(uint32_t ip,uint32_t mask,uint32_t gw,uint32_t dns1,uint32_t dns2) + +{ + WIFI_MGMR_EVENT_T WStack52; + undefined uStack51; + undefined uStack50; + undefined uStack49; + uint8_t buffer [33]; + + memset(&WStack52,0,0x21); + WStack52 = WIFI_MGMR_EVENT_APP_IP_GOT; + uStack51 = 0x44; + uStack50 = 0x33; + uStack49 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '!'; + buffer[10] = (uint8_t)(ip >> 8); + buffer[11] = (uint8_t)(ip >> 0x10); + buffer[14] = (uint8_t)(mask >> 8); + buffer[15] = (uint8_t)(mask >> 0x10); + buffer[18] = (uint8_t)(gw >> 8); + buffer[19] = (uint8_t)(gw >> 0x10); + buffer[9] = (uint8_t)ip; + buffer[13] = (uint8_t)mask; + buffer[17] = (uint8_t)gw; + buffer[21] = (uint8_t)dns1; + buffer[22] = (uint8_t)(dns1 >> 8); + buffer[12] = (uint8_t)(ip >> 0x18); + buffer[16] = (uint8_t)(mask >> 0x18); + buffer[20] = (uint8_t)(gw >> 0x18); + buffer[23] = (uint8_t)(dns1 >> 0x10); + buffer[24] = (uint8_t)(dns1 >> 0x18); + buffer[25] = (uint8_t)dns2; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + buffer[26] = (uint8_t)(dns2 >> 8); + buffer[27] = (uint8_t)(dns2 >> 0x10); + buffer[28] = (uint8_t)(dns2 >> 0x18); + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack52); + return 0; +} + + + +int wifi_mgmr_api_ip_update(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_GLB_IP_UPDATE; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_reconnect(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_RECONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_disable_autoreconnect(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_GLB_DISABLE_AUTORECONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_enable_autoreconnect(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_GLB_ENABLE_AUTORECONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_disconnect(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_DISCONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_rate_config(uint16_t config) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_RC_CONFIG; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + uStack31 = (undefined)config; + buffer[4] = 'U'; + uStack30 = (undefined)(config >> 8); + uStack29 = 0; + buffer[0] = '\0'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_conf_max_sta(uint8_t max_sta_supported) + +{ + WIFI_MGMR_EVENT_T local_20; + uint8_t uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_CONF_MAX_STA; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + uStack30 = 0; + uStack29 = 0; + buffer[0] = '\0'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + uStack31 = max_sta_supported; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_ifaceup(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_PHY_UP; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_sniffer_enable(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_SNIFFER; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_scan_item_beacon + (uint8_t channel,int8_t rssi,uint8_t auth,uint8_t *mac,uint8_t *ssid,int len, + int8_t ppm_abs,int8_t ppm_rel,uint8_t cipher) + +{ + WIFI_MGMR_EVENT_T WStack108; + undefined uStack107; + undefined uStack106; + undefined uStack105; + uint8_t buffer [73]; + + memset(&WStack108,0,0x49); + WStack108 = WIFI_MGMR_EVENT_GLB_SCAN_IND_BEACON; + uStack107 = 0x44; + uStack106 = 0x33; + uStack105 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = 'I'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + memcpy(buffer + 9,ssid,len); + buffer[45] = (uint8_t)len; + buffer[46] = (uint8_t)((uint)len >> 8); + buffer[47] = (uint8_t)((uint)len >> 0x10); + buffer[48] = (uint8_t)((uint)len >> 0x18); + buffer[41] = '\0'; + memcpy(buffer + 0x31,mac,6); + buffer[55] = channel; + buffer[56] = rssi; + buffer[57] = ppm_abs; + buffer[58] = ppm_rel; + buffer[59] = auth; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack108); + return 0; +} + + + +int wifi_mgmr_api_fw_disconnect(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_FW_DISCONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_fw_tsen_reload(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + local_20 = WIFI_MGMR_EVENT_APP_RELOAD_TSEN; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_fw_scan(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_FW_SCAN; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_fw_powersaving(int mode) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_FW_POWERSAVING; + uStack30 = (undefined)((uint)mode >> 8); + uStack29 = (undefined)((uint)mode >> 0x10); + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + uStack31 = (undefined)mode; + buffer[4] = 'U'; + buffer[0] = (uint8_t)((uint)mode >> 0x18); + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int wifi_mgmr_api_ap_start(char *ssid,char *passwd,int channel,uint8_t hidden_ssid) + +{ + size_t sVar1; + int iVar2; + undefined3 in_register_00002035; + WIFI_MGMR_EVENT_T WStack156; + undefined uStack155; + undefined uStack154; + undefined uStack153; + uint8_t buffer [124]; + + if (ssid == (char *)0x0) { + return -1; + } + memset(&WStack156,0,0x7c); + sVar1 = strlen(ssid); + buffer[47] = (uint8_t)sVar1; + buffer._48_4_ = buffer._48_4_ & 0xff000000 | sVar1 >> 8; + if (sVar1 < 0x21) { + if (passwd != (char *)0x0) { + buffer._116_4_ = strlen(passwd); + if (0x20 < buffer._116_4_) goto LAB_23026f80; + } + WStack156 = WIFI_MGMR_EVENT_APP_AP_START; + uStack155 = 0x44; + uStack154 = 0x33; + uStack153 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '|'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + memcpy(buffer + 0xd,ssid,(uint)buffer[47] | buffer._48_4_ << 8); + if (passwd == (char *)0x0) { + buffer._116_4_ = 0; + } + else { + memcpy(buffer + 0x33,passwd,buffer._116_4_); + } + buffer[9] = (uint8_t)channel; + buffer[10] = (uint8_t)((uint)channel >> 8); + buffer[46] = CONCAT31(in_register_00002035,hidden_ssid) != 0; + buffer[11] = (uint8_t)((uint)channel >> 0x10); + buffer[12] = (uint8_t)((uint)channel >> 0x18); + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack156); + iVar2 = 0; + } + else { +LAB_23026f80: + iVar2 = -1; + } + return iVar2; +} + + + +int wifi_mgmr_api_ap_stop(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_AP_STOP; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_idle(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + local_20 = WIFI_MGMR_EVENT_APP_IDLE; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_denoise_enable(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_DENOISE; + uStack31 = 1; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + uStack30 = 0; + uStack29 = 0; + buffer[0] = '\0'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_denoise_disable(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_DENOISE; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + uStack31 = 0; + uStack30 = 0; + uStack29 = 0; + buffer[0] = '\0'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_raw_send(uint8_t *pkt,int len) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_FW_DATA_RAW_SEND; + uStack30 = (undefined)((uint)pkt >> 8); + uStack29 = (undefined)((uint)pkt >> 0x10); + buffer[2] = (uint8_t)((uint)len >> 8); + uStack31 = SUB41(pkt,0); + buffer[1] = (uint8_t)len; + buffer[3] = (uint8_t)((uint)len >> 0x10); + buffer[0] = (uint8_t)((uint)pkt >> 0x18); + buffer[4] = (uint8_t)((uint)len >> 0x18); + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_set_country_code(char *country_code) + +{ + wifi_mgmr_set_country_code_internal(country_code); + return 0; +} + + + +void cmd_rf_dump(char *buf,int len,int argc,char **argv) + +{ + return; +} + + + +void cmd_dump_reset(char *buf,int len,int argc,char **argv) + +{ + pkt_counter = 10; + return; +} + + + +void cmd_wifi_power_table_update(char *buf,int len,int argc,char **argv) + +{ + int8_t aiStack56 [4]; + int8_t power_table_test [38]; + + memcpy(aiStack56,&DAT_2307d844,0x26); + bl_tpc_update_power_table(aiStack56); + return; +} + + + +void cmd_wifi_state_get(char *buf,int len,int argc,char **argv) + +{ + char *__format; + int iStack20; + int state; + + iStack20 = 0; + wifi_mgmr_state_get(&iStack20); + switch(iStack20) { + case 0: + __format = "wifi state unknown\r\n"; + break; + case 1: + __format = "wifi state idle\r\n"; + break; + case 2: + __format = "wifi state connecting\r\n"; + break; + case 3: + __format = "wifi state connected ip getting\r\n"; + break; + case 4: + __format = "wifi state connected ip got\r\n"; + break; + case 5: + __format = "wifi state disconnect\r\n"; + break; + case 6: + __format = "wifi state ifdown\r\n"; + break; + case 7: + __format = "wifi state sniffer\r\n"; + break; + case 8: + __format = "wifi state psk error\r\n"; + break; + case 9: + __format = "wifi state no ap found\r\n"; + break; + default: + goto switchD_2302724c_caseD_a; + case 0x11: + __format = "wifi state with ap idle\r\n"; + break; + case 0x12: + __format = "wifi state with ap connecting\r\n"; + break; + case 0x13: + __format = "wifi state with ap connected ip getting\r\n"; + break; + case 0x14: + __format = "wifi state with ap connected ip got\r\n"; + break; + case 0x15: + __format = "wifi state with ap disconnect\r\n"; + } + printf(__format); +switchD_2302724c_caseD_a: + return; +} + + + +void wifi_sta_get_state_cmd(char *buf,int len,int argc,char **argv) + +{ + char "wifi_sta_get_state_cmd" [23]; + char *__format; + int iStack20; + int state; + + iStack20 = 0; + wifi_mgmr_state_get(&iStack20); + printf("%s:wifi state = 0x%x\r\n","wifi_sta_get_state_cmd",iStack20); + if (iStack20 == 0) { + __format = "wifi current state: WIFI_STATE_UNKNOWN\r\n"; + } + else { + if (iStack20 == 1) { + __format = "wifi current state: WIFI_STATE_IDLE\r\n"; + } + else { + if (iStack20 == 2) { + __format = "wifi current state: WIFI_STATE_CONNECTING\r\n"; + } + else { + if (iStack20 == 3) { + __format = "wifi current state: WIFI_STATE_CONNECTED_IP_GETTING\r\n"; + } + else { + if (iStack20 == 4) { + __format = "wifi current state: WIFI_STATE_CONNECTED_IP_GOT\r\n"; + } + else { + if (iStack20 == 5) { + __format = "wifi current state: WIFI_STATE_DISCONNECT\r\n"; + } + else { + if (iStack20 == 0x11) { + __format = "wifi current state: WIFI_STATE_WITH_AP_IDLE\r\n"; + } + else { + if (iStack20 == 0x12) { + __format = "wifi current state: WIFI_STATE_WITH_AP_CONNECTING\r\n"; + } + else { + if (iStack20 == 0x13) { + __format = "wifi current state: WIFI_STATE_WITH_AP_CONNECTED_IP_GETTING\r\n"; + } + else { + if (iStack20 == 0x14) { + __format = "wifi current state: WIFI_STATE_WITH_AP_CONNECTED_IP_GOT\r\n"; + } + else { + if (iStack20 == 0x15) { + __format = "wifi current state: WIFI_STATE_WITH_AP_DISCONNECT\r\n"; + } + else { + if (iStack20 == 6) { + __format = "wifi current state: WIFI_STATE_IFDOWN\r\n"; + } + else { + if (iStack20 == 7) { + __format = "wifi current state: WIFI_STATE_SNIFFER\r\n"; + } + else { + if (iStack20 == 8) { + __format = "wifi current state: WIFI_STATE_PSK_ERROR\r\n"; + } + else { + if (iStack20 == 9) { + __format = "wifi current state: WIFI_STATE_NO_AP_FOUND\r\n"; + } + else { + __format = "wifi current state: invalid\r\n"; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + printf(__format); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void wifi_edca_dump_cmd(char *buf,int len,int argc,char **argv) + +{ + byte local_15; + byte local_14; + byte local_13; + uint8_t aifs; + ushort uStack18; + uint8_t cwmin; + uint8_t cwmax; + uint16_t txop; + + local_15 = 0; + local_14 = 0; + local_13 = 0; + uStack18 = 0; + puts("EDCA Statistic:\r\n"); + bl60x_edca_get(0,&local_15,&local_14,&local_13,(uint16_t *)&stack0xffffffee); + puts(" AC_BK:"); + printf("aifs %3u, cwmin %3u, cwmax %3u, txop %4u\r\n",(uint)local_15,(uint)local_14,(uint)local_13 + ,(uint)uStack18); + bl60x_edca_get(1,&local_15,&local_14,&local_13,(uint16_t *)&stack0xffffffee); + puts(" AC_BE:"); + printf("aifs %3u, cwmin %3u, cwmax %3u, txop %4u\r\n",(uint)local_15,(uint)local_14,(uint)local_13 + ,(uint)uStack18); + bl60x_edca_get(2,&local_15,&local_14,&local_13,(uint16_t *)&stack0xffffffee); + puts(" AC_VI:"); + printf("aifs %3u, cwmin %3u, cwmax %3u, txop %4u\r\n",(uint)local_15,(uint)local_14,(uint)local_13 + ,(uint)uStack18); + bl60x_edca_get(3,&local_15,&local_14,&local_13,(uint16_t *)&stack0xffffffee); + puts(" AC_VO:"); + printf("aifs %3u, cwmin %3u, cwmax %3u, txop %4u\r\n",(uint)local_15,(uint)local_14,(uint)local_13 + ,(uint)uStack18); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void wifi_ap_sta_list_get_cmd(char *buf,int len,int argc,char **argv) + +{ + char cVar1; + uint uVar2; + char *__format; + wifi_ap_data_rate *pwVar3; + byte bStack77; + uint8_t sta_cnt; + uint uStack76; + int state; + wifi_sta_basic_info sta_info; + + uStack76 = 0; + bStack77 = 0; + wifi_mgmr_state_get((int *)&stack0xffffffb4); + if ((uStack76 & 0x10) == 0) { + __format = "wifi AP is not enabled, state = %d\r\n"; + uVar2 = uStack76; + } + else { + wifi_mgmr_ap_sta_cnt_get(&bStack77); + if (bStack77 != 0) { + memset(&state,0,0x18); + printf("sta list:\r\n"); + printf( + "-----------------------------------------------------------------------------------\r\n" + ); + printf( + "No. StaIndex Mac-Address Signal DateRate TimeStamp\r\n" + ); + printf( + "-----------------------------------------------------------------------------------\r\n" + ); + uVar2 = 0; + do { + if (bStack77 <= uVar2) { + return; + } + wifi_mgmr_ap_sta_info_get((wifi_sta_basic_info *)&state,(uint8_t)uVar2); + if ((state._1_1_ != '\0') && ((uint8_t)state != -0x11)) { + pwVar3 = data_rate_list; + cVar1 = '\0'; + do { + if (pwVar3->data_rate == (uint8_t)sta_info.rssi) break; + cVar1 = cVar1 + '\x01'; + pwVar3 = pwVar3 + 1; + } while (cVar1 != '\f'); + printf( + " %u %u %02X:%02X:%02X:%02X:%02X:%02X %d %s 0x%llx\r\n" + ,uVar2,(uint)state._2_1_,(uint)state._3_1_,(uint)sta_info.sta_idx, + (uint)sta_info.is_used,(uint)sta_info.sta_mac[0]); + } + uVar2 = uVar2 + 1 & 0xff; + } while( true ); + } + uVar2 = 0; + __format = "no sta connect current AP, sta_cnt = %d\r\n"; + } + printf(__format,uVar2); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void wifi_ap_sta_delete_cmd(char *buf,int len,int argc,char **argv) + +{ + char cVar1; + byte idx; + char *__format; + size_t sVar2; + char *pcVar3; + char *__s; + byte bVar4; + char cVar5; + byte bStack45; + uint8_t sta_cnt; + char *pcStack44; + int state; + wifi_sta_basic_info sta_info; + + pcStack44 = (char *)0x0; + bStack45 = 0; + if (argc == 2) { + wifi_mgmr_state_get((int *)&stack0xffffffd4); + if (((uint)pcStack44 & 0x10) == 0) { + __format = "wifi AP is not enabled, state = %d\r\n"; + pcVar3 = pcStack44; + } + else { + printf("Delete Sta No.%s \r\n",argv[1]); + __s = argv[1]; + idx = 0; + sVar2 = strlen(__s); + cVar5 = '\x01'; + __format = __s + sVar2; + *__format = '\0'; + pcVar3 = __format; + while ((int)(__format + -(int)pcVar3) < (int)sVar2) { + cVar1 = pcVar3[-1]; + bVar4 = cVar1 - 0x30; + if (9 < bVar4) { + if ((byte)(cVar1 + 0x9fU) < 6) { + bVar4 = cVar1 + 0xa9; + } + else { + bVar4 = 0; + if ((byte)(cVar1 + 0xbfU) < 6) { + bVar4 = cVar1 - 0x37; + } + } + } + pcVar3 = pcVar3 + -1; + idx = idx + bVar4 * cVar5; + cVar5 = cVar5 * '\n'; + } + pcVar3 = (char *)(uint)idx; + printf("sta_str: %s, str_len: %d, sta_num: %d, q: %s\r\n",__s,pcVar3); + printf("sta num = %d \r\n",pcVar3); + wifi_mgmr_ap_sta_cnt_get(&bStack45); + if ((bStack45 == 0) || ((char *)(uint)bStack45 < pcVar3)) { + __format = "no valid sta in list or sta idx(%d) is invalid\r\n"; + pcVar3 = (char *)(uint)bStack45; + } + else { + memset(&state,0,0x18); + wifi_mgmr_ap_sta_info_get((wifi_sta_basic_info *)&state,idx); + if ((state._1_1_ != '\0') && ((uint8_t)state != -0x11)) { + printf("sta info: No.%u,sta_idx = %u,mac = %02X:%02X:%02X:%02X:%02X:%02X,rssi = %d\r\n", + pcVar3,(uint)state._2_1_,(uint)state._3_1_,(uint)sta_info.sta_idx, + (uint)sta_info.is_used,(uint)sta_info.sta_mac[0]); + wifi_mgmr_ap_sta_delete((uint8_t)state); + return; + } + __format = "No.%d sta is invalid\r\n"; + } + } + } + else { + __format = "[USAGE]: %s sta_num\r\n"; + pcVar3 = *argv; + } + printf(__format,pcVar3); + return; +} + + + +void cmd_wifi_coex_pta_force_off(char *buf,int len,int argc,char **argv) + +{ + coex_wifi_pta_forece_enable(0); + return; +} + + + +void cmd_wifi_coex_pta_force_on(char *buf,int len,int argc,char **argv) + +{ + coex_wifi_pta_forece_enable(1); + return; +} + + + +void cmd_wifi_coex_pti_force_off(char *buf,int len,int argc,char **argv) + +{ + coex_wifi_pti_forece_enable(0); + return; +} + + + +void cmd_wifi_coex_pti_force_on(char *buf,int len,int argc,char **argv) + +{ + coex_wifi_pti_forece_enable(1); + return; +} + + + +void cmd_wifi_coex_rf_force_off(char *buf,int len,int argc,char **argv) + +{ + coex_wifi_rf_forece_enable(0); + return; +} + + + +void cmd_wifi_coex_rf_force_on(char *buf,int len,int argc,char **argv) + +{ + coex_wifi_rf_forece_enable(1); + return; +} + + + +void cmd_wifi_mib(char *buf,int len,int argc,char **argv) + +{ + hal_mib_dump(); + utils_hexdump(*argv,0x1e); + return; +} + + + +void cmd_wifi_cfg(char *buf,int len,int argc,char **argv) + +{ + uint uVar1; + uint32_t task; + int iVar2; + uint32_t ops; + uint32_t length; + uint32_t *buf_00; + uint32_t element; + uint32_t type; + uint32_t uStack88; + uint32_t val [1]; + getopt_env_t getopt_env; + + type = 0; + utils_getopt_init((getopt_env_t *)val,0); + element = 0; + task = 0; + uVar1 = 4; + while (iVar2 = utils_getopt((getopt_env_t *)val,argc,argv,":c:T:e:t:v:"), iVar2 != -1) { + if (iVar2 == 99) { + iVar2 = strcmp("dump",(char *)val); + if (iVar2 == 0) { + uVar1 = 3; + } + else { + iVar2 = strcmp("set",(char *)val); + if (iVar2 == 0) { + uVar1 = 0; + } + else { + iVar2 = strcmp("get",(char *)val); + if (iVar2 == 0) { + uVar1 = 1; + } + else { + iVar2 = strcmp("reset",(char *)val); + if (iVar2 == 0) { + uVar1 = 2; + } + } + } + } + } + else { + if (iVar2 < 100) { + if (iVar2 == 0x3f) { + printf("%s: unknown option %c\r\n",*argv,getopt_env.opterr); + return; + } + if (iVar2 == 0x54) { + type = atoi((char *)val); + } + } + else { + if (iVar2 == 0x74) { + task = atoi((char *)val); + } + else { + if (iVar2 == 0x76) { + uStack88 = atoi((char *)val); + } + else { + if (iVar2 == 0x65) { + element = atoi((char *)val); + } + } + } + } + } + } + printf("Target CFG Element Info, task: %lu, element %lu, type %lu, val %lu\r\n",task,element,type, + uStack88); + if (uVar1 == 2) { + printf(" OPS: %s\r\n","reset"); + buf_00 = (uint32_t *)0x0; + length = 0; + type = 0; + ops = 2; + } + else { + if (uVar1 < 3) { + if (uVar1 == 1) { + printf(" OPS: %s\r\n",0x2308276c); + buf_00 = &uStack88; + length = 4; + ops = 1; + goto LAB_230278a4; + } + } + else { + if (uVar1 == 3) { + printf(" OPS: %s\r\n",0x23082780); + buf_00 = (uint32_t *)0x0; + length = 0; + type = 0; + element = 0; + task = 0; + ops = 3; + goto LAB_230278a4; + } + if (uVar1 == 4) { + printf("UNKNOWN OPS\r\n"); + return; + } + } + printf(" OPS: %s\r\n",0x23082744); + buf_00 = &uStack88; + length = 4; + ops = 0; + } +LAB_230278a4: + wifi_mgmr_cfg_req(ops,task,element,type,length,buf_00); + return; +} + + + +void cmd_wifi_ap_stop(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_ap_stop((wifi_interface_t *)0x0); + printf("--->>> cmd_wifi_ap_stop\r\n"); + return; +} + + + +// WARNING: Variable defined which should be unmapped: ssid_name + +void cmd_wifi_ap_start(char *buf,int len,int argc,char **argv) + +{ + wifi_interface_t *interface; + uint hidden_ssid; + char *passwd; + int channel; + uint8_t auStack56 [3]; + byte bStack53; + uint8_t mac [6]; + char ssid_name [32]; + + memset(auStack56,0,6); + bl_wifi_mac_addr_get(auStack56); + memset(mac + 4,0,0x20); + snprintf((char *)(mac + 4),0x20,"BL60X_uAP_%02X%02X%02X",(uint)bStack53,(uint)mac[0],(uint)mac[1]) + ; + interface = (wifi_interface_t *)wifi_mgmr_ap_enable(); + if (argc == 1) { + channel = 1; + passwd = (char *)0x0; + hidden_ssid = 0; + } + else { + channel = atoi(argv[1]); + if (10 < channel - 1U) { + return; + } + passwd = "12345678"; + hidden_ssid = (uint)(argc == 3); + } + wifi_mgmr_ap_start(interface,(char *)(mac + 4),hidden_ssid,passwd,channel); + return; +} + + + +void wifi_sniffer_off_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_sniffer_disable(); + wifi_mgmr_sniffer_unregister((void *)0x0); + return; +} + + + +void wifi_sniffer_on_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_sniffer_enable(); + wifi_mgmr_sniffer_register((void *)0x0,sniffer_cb); + return; +} + + + +int wifi_denoise_disable_cmd(void) + +{ + WIFI_MGMR_EVENT_T WStack32; + undefined uStack31; + undefined uStack30; + undefined uStack29; + undefined uStack28; + undefined uStack27; + undefined uStack26; + undefined uStack25; + undefined uStack24; + undefined uStack23; + undefined uStack22; + undefined uStack21; + undefined uStack20; + + memset(&WStack32,0,0xd); + WStack32 = WIFI_MGMR_EVENT_APP_DENOISE; + uStack27 = 0x88; + uStack26 = 0x77; + uStack25 = 0x66; + uStack24 = 0x55; + uStack31 = 0; + uStack30 = 0; + uStack29 = 0; + uStack28 = 0; + uStack23 = 0xd; + uStack22 = 0; + uStack21 = 0; + uStack20 = 0; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack32); + return 0; +} + + + +int wifi_denoise_enable_cmd(void) + +{ + WIFI_MGMR_EVENT_T WStack32; + undefined uStack31; + undefined uStack30; + undefined uStack29; + undefined uStack28; + undefined uStack27; + undefined uStack26; + undefined uStack25; + undefined uStack24; + undefined uStack23; + undefined uStack22; + undefined uStack21; + undefined uStack20; + + memset(&WStack32,0,0xd); + WStack32 = WIFI_MGMR_EVENT_APP_DENOISE; + uStack31 = 1; + uStack27 = 0x88; + uStack26 = 0x77; + uStack25 = 0x66; + uStack24 = 0x55; + uStack30 = 0; + uStack29 = 0; + uStack28 = 0; + uStack23 = 0xd; + uStack22 = 0; + uStack21 = 0; + uStack20 = 0; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack32); + return 0; +} + + + +void wifi_power_saving_off_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_sta_powersaving(0); + return; +} + + + +void wifi_power_saving_on_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_sta_powersaving(2); + return; +} + + + +void wifi_rc_fixed_disable(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_rate_config(0xffff); + return; +} + + + +int wifi_disable_autoreconnect_cmd(void) + +{ + wifi_mgmr_api_disable_autoreconnect(); + return 0; +} + + + +int wifi_enable_autoreconnect_cmd(void) + +{ + wifi_mgmr_api_enable_autoreconnect(); + return 0; +} + + + +void wifi_disconnect_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_sta_disconnect(); + vTaskDelay(1000); + wifi_mgmr_sta_disable((wifi_interface_t *)0x0); + return; +} + + + +int wifi_sta_ip_unset_cmd(void) + +{ + int iVar1; + + iVar1 = wifi_mgmr_sta_ip_set(0,0,0,0,0); + return iVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void wifi_sta_ip_info(char *buf,int len,int argc,char **argv) + +{ + char *pcVar1; + ip4_addr_t iStack80; + ip4_addr_t ip; + ip4_addr_t gw; + ip4_addr_t mask; + ip4_addr_t dns1; + ip4_addr_t dns2; + int rssi; + int8_t power_rate_table [38]; + + wifi_mgmr_sta_ip_get((uint32_t *)&iStack80,(uint32_t *)&ip,(uint32_t *)&gw); + wifi_mgmr_sta_dns_get((uint32_t *)&mask,(uint32_t *)&dns1); + wifi_mgmr_rssi_get((int *)&dns2); + bl_tpc_power_table_get((int8_t *)&rssi); + printf("RSSI: %ddbm\r\n",dns2); + pcVar1 = ip4addr_ntoa(&iStack80); + printf("IP : %s \r\n",pcVar1); + pcVar1 = ip4addr_ntoa(&gw); + printf("MASK: %s \r\n",pcVar1); + pcVar1 = ip4addr_ntoa(&ip); + printf("GW : %s \r\n",pcVar1); + pcVar1 = ip4addr_ntoa(&mask); + printf("DNS1: %s \r\n",pcVar1); + pcVar1 = ip4addr_ntoa(&dns1); + printf("DNS2: %s \r\n",pcVar1); + puts("Power Table (dbm):\r\n"); + puts("--------------------------------\r\n"); + printf(" 11b: %u %u %u %u (1Mbps 2Mbps 5.5Mbps 11Mbps)\r\n",(int)(char)rssi, + (int)rssi._1_1_,(int)rssi._2_1_,(int)rssi._3_1_); + printf( + " 11g: %u %u %u %u %u %u %u %u (6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps)\r\n" + ,(int)power_rate_table[4],(int)power_rate_table[5],(int)power_rate_table[6], + (int)power_rate_table[7],(int)power_rate_table[8],(int)power_rate_table[9], + (int)power_rate_table[10]); + printf(" 11n: %u %u %u %u %u %u %u %u (MCS0 ~ MCS7)\r\n",(int)power_rate_table[12], + (int)power_rate_table[13],(int)power_rate_table[14],(int)power_rate_table[15], + (int)power_rate_table[16],(int)power_rate_table[17],(int)power_rate_table[18]); + puts("--------------------------------\r\n"); + return; +} + + + +void cmd_wifi_raw_send(char *buf,int len,int argc,char **argv) + +{ + uint32_t seq; + char *__s; + int iVar1; + + iVar1 = seq << 4; + packet_raw[22] = (uint8_t)iVar1; + seq = seq + 1; + packet_raw[23] = (uint8_t)((uint)iVar1 >> 8); + iVar1 = wifi_mgmr_raw_80211_send(packet_raw,0x18); + if (iVar1 == 0) { + __s = "Raw send succeed\r\n"; + } + else { + __s = "Raw send failed\r\n"; + } + puts(__s); + return; +} + + + +void wifi_scan_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_scan((void *)0x0,(scan_complete_cb_t *)0x0); + return; +} + + + +void sniffer_cb(void *env,uint8_t *pkt,int len) + +{ + TickType_t TVar1; + + sniffer_counter_5067 = sniffer_counter_5067 + 1; + TVar1 = xTaskGetTickCount(); + if (10000 < (int)(TVar1 - last_tick_5069)) { + last_tick_5069 = xTaskGetTickCount(); + } + return; +} + + + +void cmd_wifi_dump(char *buf,int len,int argc,char **argv) + +{ + if (argc < 2) { + puts("[CLI] Dump statistic use normal mode\r\n"); + vTaskEnterCritical(); + } + else { + puts("[CLI] Dump statistic use forced mode\r\n"); + vTaskEnterCritical(); + } + bl60x_fw_dump_statistic((uint)(argc >= 2)); + vTaskExitCritical(); + return; +} + + + +void cmd_wifi_ap_conf_max_sta(char *buf,int len,int argc,char **argv) + +{ + int iVar1; + + if (argc != 2) { + printf("Usage: wifi_ap_max_sta [num]\r\n"); + return; + } + iVar1 = atoi(argv[1]); + printf("Conf Max Sta to %d\r\n",iVar1); + wifi_mgmr_conf_max_sta((uint8_t)iVar1); + return; +} + + + +void wifi_mon_cmd(char *buf,int len,int argc,char **argv) + +{ + if (1 < argc) { + wifi_mgmr_sniffer_enable(); + return; + } + wifi_mgmr_sniffer_register((void *)0x0,sniffer_cb); + return; +} + + + +void wifi_rc_fixed_enable(char *buf,int len,int argc,char **argv) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + char *pcVar4; + uint uVar5; + + if (argc != 4) { + printf("rc_fix_en [b/g/n] [MCS] [GI]"); + return; + } + uVar1 = atoi(argv[1]); + uVar5 = uVar1 & 0xff; + uVar2 = atoi(argv[2]); + uVar3 = atoi(argv[3]); + if (uVar5 == 1) { + pcVar4 = "n mode"; + } + else { + pcVar4 = "b/g mdoe"; + } + printf("wifi set mode:%s, mcs:%d, gi:%d\r\n",pcVar4,uVar2 & 0xff,uVar3 & 0xff); + if (uVar5 == 1) { + uVar1 = ((uVar1 & 0xff) << 0xc | (uVar3 & 0xff) << 9) & 0xffff | uVar2 & 0xff; + } + else { + uVar1 = 0; + if (uVar5 == 0) { + uVar1 = uVar2 & 0xff | 0x600; + } + } + printf("wifi rc:0x%x\r\n",uVar1); + wifi_mgmr_rate_config((uint16_t)uVar1); + return; +} + + + +void wifi_connect_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_interface_t *wifi_interface; + + if (argc != 3) { + printf("[USAGE]: %s [ssid] [password]\r\n",*argv); + return; + } + wifi_interface = (wifi_interface_t *)wifi_mgmr_sta_enable(); + wifi_mgmr_sta_connect(wifi_interface,argv[1],argv[2],(char *)0x0,(uint8_t *)0x0,'\0',0); + return; +} + + + +void wifi_sta_ip_set_cmd(char *buf,int len,int argc,char **argv) + +{ + ip4_addr_t ip; + ip4_addr_t mask; + ip4_addr_t gw; + ip4_addr_t dns1; + ip4_addr_t dns2; + ip4_addr_t iStack56; + ip4_addr_t addr; + char addr_str [20]; + + if (argc == 6) { + ip = (ip4_addr_t)ipaddr_addr(argv[1]); + mask = (ip4_addr_t)ipaddr_addr(argv[2]); + gw = (ip4_addr_t)ipaddr_addr(argv[3]); + dns1 = (ip4_addr_t)ipaddr_addr(argv[4]); + dns2 = (ip4_addr_t)ipaddr_addr(argv[5]); + iStack56 = ip; + ip4addr_ntoa_r(&iStack56,(char *)&addr,0x14); + puts("IP : "); + puts((char *)&addr); + puts("\r\n"); + iStack56 = mask; + ip4addr_ntoa_r(&iStack56,(char *)&addr,0x14); + puts("MASK: "); + puts((char *)&addr); + puts("\r\n"); + iStack56 = gw; + ip4addr_ntoa_r(&iStack56,(char *)&addr,0x14); + puts("GW : "); + puts((char *)&addr); + puts("\r\n"); + iStack56 = dns1; + ip4addr_ntoa_r(&iStack56,(char *)&addr,0x14); + puts("DNS1: "); + puts((char *)&addr); + puts("\r\n"); + iStack56 = dns2; + ip4addr_ntoa_r(&iStack56,(char *)&addr,0x14); + puts("DNS2: "); + puts((char *)&addr); + puts("\r\n"); + wifi_mgmr_sta_ip_set((uint32_t)ip,(uint32_t)mask,(uint32_t)gw,(uint32_t)dns1,(uint32_t)dns2); + } + else { + puts("Illegal CMD format\r\n"); + } + return; +} + + + +void wifi_scan_filter_cmd(char *buf,int len,int argc,char **argv) + +{ + if (argc == 2) { + wifi_mgmr_scan_filter_hidden_ssid((uint)(*argv[1] == '1')); + return; + } + return; +} + + + +void wifi_capcode_cmd(char *buf,int len,int argc,char **argv) + +{ + uint8_t uVar1; + char *__format; + undefined3 extraout_var; + int iVar2; + char *pcVar3; + + if (argc - 1U < 2) { + if (argc != 1) { + iVar2 = atoi(argv[1]); + printf("Setting capcode to %d\r\n",iVar2); + if (0 < iVar2) { + hal_sys_capcode_update((uint8_t)iVar2,(uint8_t)iVar2); + return; + } + return; + } + uVar1 = hal_sys_capcode_get(); + pcVar3 = (char *)CONCAT31(extraout_var,uVar1); + __format = "Capcode %u is being used\r\n"; + } + else { + pcVar3 = *argv; + __format = "Usage: %s capcode\r\n"; + } + printf(__format,pcVar3); + return; +} + + + +int wifi_mgmr_cli_scanlist(void) + +{ + byte bVar1; + byte bVar2; + byte bVar3; + byte bVar4; + byte bVar5; + byte bVar6; + wifi_mgmr_t *pwVar7; + int iVar8; + TickType_t TVar9; + + printf("cached scan list\r\n"); + pwVar7 = &wifiMgmr; + printf( + "****************************************************************************************************\r\n" + ); + iVar8 = 0; + do { + if (pwVar7->scan_items[0].is_used == '\0') { +LAB_2302810e: + printf("index[%02d]: empty\r\n",iVar8); + } + else { + TVar9 = xTaskGetTickCount(); + if ((uint)wifiMgmr.scan_item_timeout <= TVar9 - pwVar7->scan_items[0].timestamp_lastseen) + goto LAB_2302810e; + bVar1 = pwVar7->scan_items[0].channel; + bVar2 = pwVar7->scan_items[0].bssid[0]; + bVar3 = pwVar7->scan_items[0].bssid[1]; + bVar4 = pwVar7->scan_items[0].bssid[2]; + bVar5 = pwVar7->scan_items[0].bssid[3]; + bVar6 = pwVar7->scan_items[0].bssid[4]; + wifi_mgmr_auth_to_str(pwVar7->scan_items[0].auth); + wifi_mgmr_cipher_to_str(pwVar7->scan_items[0].cipher); + printf( + "index[%02d]: channel %02u, bssid %02X:%02X:%02X:%02X:%02X:%02X, rssi %3d, ppm abs:rel %3d : %3d, auth %20s, cipher:%12s, SSID %s\r\n" + ,iVar8,(uint)bVar1,(uint)bVar2,(uint)bVar3,(uint)bVar4,(uint)bVar5,(uint)bVar6); + } + iVar8 = iVar8 + 1; + pwVar7 = (wifi_mgmr_t *)&(pwVar7->wlan_sta).netif.input; + if (iVar8 == 0x32) { + printf( + "----------------------------------------------------------------------------------------------------\r\n" + ); + return 0; + } + } while( true ); +} + + + +int wifi_mgmr_ext_dump_needed(void) + +{ + bool bVar1; + + bVar1 = 0 < pkt_counter; + if (bVar1) { + pkt_counter = pkt_counter + -1; + } + return (uint)bVar1; +} + + + +int wifi_mgmr_cli_init(void) + +{ + return 0; +} + + + +int mac_is_unvalid(uint8_t *mac) + +{ + int iVar1; + + iVar1 = 1; + do { + if (mac[iVar1] != *mac) { + return 0; + } + iVar1 = iVar1 + 1; + } while (iVar1 != 6); + return (uint)((byte)(*mac - 1) < 0xfe) ^ 1; +} + + + +int wifi_mgmr_psk_cal(char *password,char *ssid,int ssid_len,char *output) + +{ + int iVar1; + uchar auStack48 [4]; + char psk [32]; + + iVar1 = bl60x_fw_password_hash(password,(uchar *)ssid,ssid_len,auStack48); + if (iVar1 == 0) { + utils_bin2hex(output,auStack48,0x20); + } + return iVar1; +} + + + +int wifi_mgmr_drv_init(wifi_conf_t *conf) + +{ + bl606a0_wifi_init(conf); + wifi_mgmr_api_set_country_code((char *)conf); + wifi_mgmr_init(); + wifi_mgmr_api_ifaceup(); + return 0; +} + + + +// WARNING: Variable defined which should be unmapped: gw + +wifi_interface_t wifi_mgmr_sta_enable(void) + +{ + int done; + int iVar1; + ip4_addr_t iStack28; + ip4_addr_t ipaddr; + ip4_addr_t netmask; + ip4_addr_t gw; + + if (done == 1) { + printf("----- BUG FIXME? NOT do STA enable again\r\n"); + } + else { + done = 1; + printf("---------STA enable\r\n"); + wifiMgmr.wlan_sta.mode = 0; + iStack28 = (ip4_addr_t)0x0; + ipaddr = 0; + netmask = 0; + memcpy(wifiMgmr.wlan_sta.netif.hwaddr,wifiMgmr.wlan_sta.mac,6); + iVar1 = mac_is_unvalid(wifiMgmr.wlan_sta.netif.hwaddr); + if (iVar1 != 0) { + bl_wifi_mac_addr_get(wifiMgmr.wlan_sta.netif.hwaddr); + iVar1 = mac_is_unvalid(wifiMgmr.wlan_sta.netif.hwaddr); + if (iVar1 != 0) { + wifiMgmr.wlan_sta.netif.hwaddr._0_2_ = 0x50c0; + wifiMgmr.wlan_sta.netif.hwaddr._2_4_ = 0x100c943; + } + memcpy(wifiMgmr.wlan_sta.mac,wifiMgmr.wlan_sta.netif.hwaddr,6); + } + netifapi_netif_add((netif *)&wifiMgmr.wlan_sta.netif,&iStack28,&ipaddr,&netmask,(void *)0x0, + bl606a0_wifi_netif_init,tcpip_input); + wifiMgmr.wlan_sta.netif.name = 0x7473; + wifiMgmr.wlan_sta.netif.flags = wifiMgmr.wlan_sta.netif.flags | 0x24; + netif_set_default((netif *)&wifiMgmr.wlan_sta.netif); + netif_set_up((netif *)&wifiMgmr.wlan_sta.netif); + } + return &wifiMgmr.wlan_sta; +} + + + +int wifi_mgmr_sta_disable(wifi_interface_t *interface) + +{ + wifi_mgmr_api_idle(); + return 0; +} + + + +int wifi_mgmr_sta_ip_get(uint32_t *ip,uint32_t *gw,uint32_t *mask) + +{ + *ip = wifiMgmr.wlan_sta.netif.ip_addr; + *mask = wifiMgmr.wlan_sta.netif.netmask; + *gw = wifiMgmr.wlan_sta.netif.gw; + return 0; +} + + + +int wifi_mgmr_sta_dns_get(uint32_t *dns1,uint32_t *dns2) + +{ + ip_addr_t *piVar1; + + piVar1 = dns_getserver('\0'); + *dns1 = piVar1->addr; + piVar1 = dns_getserver('\x01'); + *dns2 = piVar1->addr; + return 0; +} + + + +int wifi_mgmr_sta_ip_set(uint32_t ip,uint32_t mask,uint32_t gw,uint32_t dns1,uint32_t dns2) + +{ + vTaskEnterCritical(); + wifiMgmr.wlan_sta.ipv4.ip = ip; + wifiMgmr.wlan_sta.ipv4.mask = mask; + wifiMgmr.wlan_sta.ipv4.gw = gw; + wifiMgmr.wlan_sta.ipv4.dns1 = dns1; + wifiMgmr.wlan_sta.ipv4.dns2 = dns2; + vTaskExitCritical(); + wifi_mgmr_api_ip_update(); + return 0; +} + + + +int wifi_mgmr_sta_ip_unset(void) + +{ + int iVar1; + + iVar1 = wifi_mgmr_sta_ip_set(0,0,0,0,0); + return iVar1; +} + + + +int wifi_mgmr_sta_disconnect(void) + +{ + wifi_mgmr_api_disconnect(); + return 0; +} + + + +int wifi_mgmr_sta_powersaving(int ps) + +{ + if ((ps == 1) || (ps == 2)) { + wifi_mgmr_api_fw_powersaving(ps); + ps = 0; + } + else { + if (ps == 0) { + wifi_mgmr_api_fw_powersaving(0); + } + else { + ps = -1; + } + } + return ps; +} + + + +int wifi_mgmr_sta_autoconnect_enable(void) + +{ + wifi_mgmr_api_enable_autoreconnect(); + return 0; +} + + + +int wifi_mgmr_sta_autoconnect_disable(void) + +{ + wifi_mgmr_api_disable_autoreconnect(); + return 0; +} + + + +void wifi_mgmr_sta_ssid_set(char *ssid) + +{ + size_t __n; + + __n = strlen(ssid); + if (__n != 0) { + __n = strlen(ssid); + memcpy(wifiMgmr.wifi_mgmr_stat_info.ssid,ssid,__n); + return; + } + return; +} + + + +void wifi_mgmr_sta_psk_set(char *psk) + +{ + size_t __n; + + __n = strlen(psk); + if (__n != 0) { + __n = strlen(psk); + memcpy(wifiMgmr.wifi_mgmr_stat_info.psk,psk,__n); + return; + } + return; +} + + + +int wifi_mgmr_sta_connect + (wifi_interface_t *wifi_interface,char *ssid,char *psk,char *pmk,uint8_t *mac, + uint8_t band,uint16_t freq) + +{ + int iVar1; + + wifi_mgmr_sta_ssid_set(ssid); + wifi_mgmr_sta_psk_set(psk); + iVar1 = wifi_mgmr_api_connect(ssid,psk,pmk,mac,band,freq); + return iVar1; +} + + + +// WARNING: Variable defined which should be unmapped: gw + +wifi_interface_t wifi_mgmr_ap_enable(void) + +{ + int iVar1; + ip4_addr_t iStack28; + ip4_addr_t ipaddr; + ip4_addr_t netmask; + ip4_addr_t gw; + + wifiMgmr.wlan_ap.mode = 1; + iStack28 = (ip4_addr_t)0x10ba8c0; + ipaddr = 0xffffff; + netmask = 0; + memcpy(wifiMgmr.wlan_ap.netif.hwaddr,wifiMgmr.wlan_ap.mac,6); + iVar1 = mac_is_unvalid(wifiMgmr.wlan_ap.netif.hwaddr); + if (iVar1 != 0) { + bl_wifi_mac_addr_get(wifiMgmr.wlan_ap.netif.hwaddr); + iVar1 = mac_is_unvalid(wifiMgmr.wlan_ap.netif.hwaddr); + if (iVar1 != 0) { + wifiMgmr.wlan_ap.netif.hwaddr._0_2_ = 0x50c0; + wifiMgmr.wlan_ap.netif.hwaddr._2_4_ = 0x100c943; + } + memcpy(wifiMgmr.wlan_ap.mac,wifiMgmr.wlan_ap.netif.hwaddr,6); + } + netifapi_netif_add((netif *)&wifiMgmr.wlan_ap.netif,&iStack28,&ipaddr,&netmask,(void *)0x0, + bl606a0_wifi_netif_init,tcpip_input); + wifiMgmr.wlan_ap.netif.name = 0x7061; + netif_set_default((netif *)&wifiMgmr.wlan_ap.netif); + netif_set_up((netif *)&wifiMgmr.wlan_ap.netif); + return &wifiMgmr.wlan_ap; +} + + + +int wifi_mgmr_ap_start(wifi_interface_t *interface,char *ssid,int hidden_ssid,char *passwd, + int channel) + +{ + wifi_mgmr_api_ap_start(ssid,passwd,channel,(uint8_t)hidden_ssid); + return 0; +} + + + +int wifi_mgmr_ap_stop(wifi_interface_t *interface) + +{ + wifi_mgmr_api_ap_stop(); + return 0; +} + + + +int wifi_mgmr_ap_sta_cnt_get(uint8_t *sta_cnt) + +{ + wifi_mgmr_ap_sta_cnt_get_internal(sta_cnt); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +int wifi_mgmr_ap_sta_info_get(wifi_sta_basic_info *sta_info,uint8_t idx) + +{ + undefined2 uStack40; + wifi_mgmr_sta_basic_info sta_info_internal; + + memset(&uStack40,0,0x18); + wifi_mgmr_ap_sta_info_get_internal((wifi_mgmr_sta_basic_info_t *)&uStack40,idx); + *(undefined2 *)sta_info = uStack40; + sta_info->rssi = sta_info_internal.tsflo; + sta_info->tsflo = sta_info_internal.tsfhi; + sta_info->tsfhi = sta_info_internal.sta_mac._2_4_; + sta_info->data_rate = (uint8_t)sta_info_internal.rssi; + memcpy(sta_info->sta_mac,&uStack40 + 1,6); + return 0; +} + + + +int wifi_mgmr_ap_sta_delete(uint8_t sta_idx) + +{ + wifi_mgmr_ap_sta_delete_internal(sta_idx); + return 0; +} + + + +int wifi_mgmr_sniffer_register(void *env,sniffer_cb_t *cb) + +{ + bl_rx_pkt_cb_register(env,(wifi_event_pkt_cb_t *)cb); + return 0; +} + + + +int wifi_mgmr_sniffer_unregister(void *env) + +{ + bl_rx_pkt_cb_unregister(env); + return 0; +} + + + +int wifi_mgmr_sniffer_enable(void) + +{ + wifi_mgmr_api_sniffer_enable(); + return 0; +} + + + +int wifi_mgmr_sniffer_disable(void) + +{ + wifi_mgmr_api_idle(); + return 0; +} + + + +int wifi_mgmr_rate_config(uint16_t config) + +{ + WIFI_MGMR_EVENT_T WStack32; + undefined uStack31; + undefined uStack30; + undefined uStack29; + undefined uStack28; + undefined uStack27; + undefined uStack26; + undefined uStack25; + undefined uStack24; + undefined uStack23; + undefined uStack22; + undefined uStack21; + undefined uStack20; + + memset(&WStack32,0,0xd); + WStack32 = WIFI_MGMR_EVENT_APP_RC_CONFIG; + uStack27 = 0x88; + uStack26 = 0x77; + uStack25 = 0x66; + uStack31 = (undefined)config; + uStack24 = 0x55; + uStack30 = (undefined)(config >> 8); + uStack29 = 0; + uStack28 = 0; + uStack23 = 0xd; + uStack22 = 0; + uStack21 = 0; + uStack20 = 0; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack32); + return 0; +} + + + +int wifi_mgmr_conf_max_sta(uint8_t max_sta_supported) + +{ + WIFI_MGMR_EVENT_T WStack32; + uint8_t uStack31; + undefined uStack30; + undefined uStack29; + undefined uStack28; + undefined uStack27; + undefined uStack26; + undefined uStack25; + undefined uStack24; + undefined uStack23; + undefined uStack22; + undefined uStack21; + undefined uStack20; + + memset(&WStack32,0,0xd); + WStack32 = WIFI_MGMR_EVENT_APP_CONF_MAX_STA; + uStack27 = 0x88; + uStack26 = 0x77; + uStack25 = 0x66; + uStack24 = 0x55; + uStack30 = 0; + uStack29 = 0; + uStack28 = 0; + uStack23 = 0xd; + uStack22 = 0; + uStack21 = 0; + uStack20 = 0; + uStack31 = max_sta_supported; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack32); + return 0; +} + + + +int wifi_mgmr_state_get(int *state) + +{ + uint16_t uVar1; + int iVar2; + + uVar1 = wifiMgmr.wifi_mgmr_stat_info.status_code; + if (wifiMgmr.m.currentState == &stateIdle) { + if (wifiMgmr.inf_ap_enabled != 0) { + iVar2 = 0x11; + goto LAB_230262ac; + } + iVar2 = 1; + } + else { + if (wifiMgmr.m.currentState == &stateConnecting) { + if (wifiMgmr.inf_ap_enabled != 0) { + iVar2 = 0x12; + goto LAB_230262ac; + } + iVar2 = 2; + } + else { + if (wifiMgmr.m.currentState == &stateConnectedIPNo) { + if (wifiMgmr.inf_ap_enabled == 0) { + iVar2 = 3; + } + else { + iVar2 = 0x13; + } + goto LAB_230262ac; + } + if (wifiMgmr.m.currentState == &stateConnectedIPYes) { + if (wifiMgmr.inf_ap_enabled == 0) { + iVar2 = 4; + } + else { + iVar2 = 0x14; + } + goto LAB_230262ac; + } + if (wifiMgmr.m.currentState != &stateDisconnect) { + if (wifiMgmr.m.currentState == &stateIfaceDown) { + iVar2 = 6; + } + else { + if (wifiMgmr.m.currentState != &stateSniffer) { + *state = 0; + return 0; + } + iVar2 = 7; + } + goto LAB_230262ac; + } + if (wifiMgmr.inf_ap_enabled != 0) { + iVar2 = 0x15; + goto LAB_230262ac; + } + iVar2 = 5; + } + } + *state = iVar2; + if (uVar1 == 8) { + iVar2 = 8; + } + else { + if (uVar1 != 0xc) { + return 0; + } + iVar2 = 9; + } +LAB_230262ac: + *state = iVar2; + return 0; +} + + + +int wifi_mgmr_rssi_get(int *rssi) + +{ + *rssi = (int)wifiMgmr.wlan_sta.field_5; + return 0; +} + + + +int wifi_mgmr_raw_80211_send(uint8_t *pkt,int len) + +{ + if (len < 0x1e1) { + wifi_mgmr_api_raw_send(pkt,len); + return 0; + } + return -1; +} + + + +int wifi_mgmr_scan(void *data,scan_complete_cb_t *cb) + +{ + scan_cb = cb; + scan_data = data; + wifi_mgmr_api_fw_scan(); + return 0; +} + + + +int wifi_mgmr_cfg_req(uint32_t ops,uint32_t task,uint32_t element,uint32_t type,uint32_t length, + uint32_t *buf) + +{ + int iVar1; + WIFI_MGMR_EVENT_T WStack100; + undefined uStack99; + undefined uStack98; + undefined uStack97; + undefined uStack96; + undefined uStack95; + undefined uStack94; + undefined uStack93; + undefined uStack92; + undefined uStack91; + undefined uStack90; + undefined uStack89; + undefined uStack88; + undefined uStack87; + undefined uStack86; + undefined uStack85; + undefined uStack84; + undefined uStack83; + undefined uStack82; + undefined uStack81; + undefined uStack80; + undefined uStack79; + undefined uStack78; + undefined uStack77; + undefined uStack76; + undefined uStack75; + undefined uStack74; + undefined uStack73; + undefined uStack72; + undefined uStack71; + undefined uStack70; + undefined uStack69; + undefined uStack68; + undefined auStack67 [39]; + + if (length < 0x21) { + memset(&WStack100,0,0x41); + WStack100 = WIFI_MGMR_EVENT_FW_CFG_REQ; + uStack99 = 0x44; + uStack98 = 0x33; + uStack97 = 0x22; + uStack96 = 0x11; + uStack95 = 0x88; + uStack94 = 0x77; + iVar1 = length + 0xc6; + uStack93 = 0x66; + uStack92 = 0x55; + uStack90 = (undefined)((uint)iVar1 >> 8); + uStack89 = (undefined)((uint)iVar1 >> 0x10); + uStack86 = (undefined)(ops >> 8); + uStack85 = (undefined)(ops >> 0x10); + uStack82 = (undefined)(task >> 8); + uStack81 = (undefined)(task >> 0x10); + uStack78 = (undefined)(element >> 8); + uStack77 = (undefined)(element >> 0x10); + uStack74 = (undefined)(type >> 8); + uStack73 = (undefined)(type >> 0x10); + uStack91 = (undefined)iVar1; + uStack87 = (undefined)ops; + uStack83 = (undefined)task; + uStack79 = (undefined)element; + uStack75 = (undefined)type; + uStack70 = (undefined)(length >> 8); + uStack69 = (undefined)(length >> 0x10); + uStack88 = (undefined)((uint)iVar1 >> 0x18); + uStack84 = (undefined)(ops >> 0x18); + uStack80 = (undefined)(task >> 0x18); + uStack76 = (undefined)(element >> 0x18); + uStack72 = (undefined)(type >> 0x18); + uStack71 = (undefined)length; + uStack68 = (undefined)(length >> 0x18); + if (length != 0) { + memcpy(auStack67,buf,length); + } + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack100); + return 0; + } + return -1; +} + + + +int wifi_mgmr_scan_filter_hidden_ssid(int filter) + +{ + vTaskEnterCritical(); + if (filter == 0) { + wifiMgmr.features = wifiMgmr.features | 1; + } + else { + wifiMgmr.features = wifiMgmr.features & 0xfffffffe; + } + vTaskExitCritical(); + return 0; +} + + + +int wifi_mgmr_scan_complete_callback(void) + +{ + char "wifi_mgmr_scan_complete_callback" [33]; + undefined4 uStack20; + int status; + + uStack20 = 0; + printf("%s: scan complete\r\n","wifi_mgmr_scan_complete_callback"); + if (scan_cb != (scan_complete_cb_t *)0x0) { + uStack20 = 1; + (*scan_cb)(scan_data,&uStack20); + } + return 0; +} + + + +char * wifi_mgmr_status_code_str(uint16_t status_code) + +{ + undefined2 in_register_0000202a; + + if (CONCAT22(in_register_0000202a,status_code) < 0x11) { + return *(char **)(CSWTCH_17 + CONCAT22(in_register_0000202a,status_code) * 4); + } + return "Unknown Status Code"; +} + + + +int wifi_mgmr_profile_add(wifi_mgmr_t *mgmr,wifi_mgmr_profile_msg_t *profile_msg,int index) + +{ + wifi_mgmr_profile_t *__s; + int iVar1; + + if (index == -1) { + __s = mgmr->profiles; + if (__s == (wifi_mgmr_profile_t *)0x0) { + return -1; + } + } + else { + if (mgmr->profiles[0].isUsed == '\0') { + iVar1 = 0; + } + else { + if (mgmr->profiles[1].isUsed != '\0') { + return -1; + } + iVar1 = 1; + } + mgmr->profile_active_index = iVar1; + __s = mgmr->profiles + iVar1; + printf("[WF][PF] Using free profile, idx is @%d\r\n"); + } + memset(__s,0,0xc4); + *(undefined2 *)&__s->isActive = 0x100; + __s->ssid_len = profile_msg->ssid_len; + __s->psk_len = profile_msg->psk_len; + __s->pmk_len = profile_msg->pmk_len; + __s->priority = -1; + memcpy(__s,profile_msg,0x21); + memcpy(__s->psk,profile_msg->psk,0x41); + memcpy(__s->pmk,profile_msg->pmk,0x41); + memcpy(__s->mac,profile_msg->mac,6); + __s->dhcp_use = profile_msg->dhcp_use; + return 0; +} + + + +int wifi_mgmr_profile_get(wifi_mgmr_t *mgmr,wifi_mgmr_profile_msg_t *profile_msg) + +{ + int iVar1; + uint8_t *puVar2; + undefined4 uVar3; + + if (mgmr->profiles[0].isUsed == '\x01') { + iVar1 = 0; + } + else { + iVar1 = 1; + if (mgmr->profiles[1].isUsed != '\x01') { + return -1; + } + } + printf("[WF][PF] Using profile, idx is @%d\r\n",iVar1); + memset(profile_msg,0,0xb9); + puVar2 = &mgmr->ready + iVar1 * 0xc4; + uVar3 = *(undefined4 *)(puVar2 + 0x114); + *(char *)&profile_msg->ssid_len = (char)uVar3; + *(undefined *)((int)&profile_msg->ssid_len + 1) = (char)((uint)uVar3 >> 8); + *(undefined *)((int)&profile_msg->ssid_len + 2) = (char)((uint)uVar3 >> 0x10); + *(undefined *)((int)&profile_msg->ssid_len + 3) = (char)((uint)uVar3 >> 0x18); + uVar3 = *(undefined4 *)(puVar2 + 0x15c); + *(char *)&profile_msg->psk_len = (char)uVar3; + *(undefined *)((int)&profile_msg->psk_len + 1) = (char)((uint)uVar3 >> 8); + *(undefined *)((int)&profile_msg->psk_len + 2) = (char)((uint)uVar3 >> 0x10); + *(undefined *)((int)&profile_msg->psk_len + 3) = (char)((uint)uVar3 >> 0x18); + uVar3 = *(undefined4 *)(puVar2 + 0x1a4); + *(char *)&profile_msg->pmk_len = (char)uVar3; + *(undefined *)((int)&profile_msg->pmk_len + 1) = (char)((uint)uVar3 >> 8); + *(undefined *)((int)&profile_msg->pmk_len + 2) = (char)((uint)uVar3 >> 0x10); + *(undefined *)((int)&profile_msg->pmk_len + 3) = (char)((uint)uVar3 >> 0x18); + profile_msg->dhcp_use = puVar2[0x1ae]; + memcpy(profile_msg,mgmr->profiles + iVar1,0x21); + memcpy(profile_msg->psk,mgmr->profiles[iVar1].psk,0x41); + memcpy(profile_msg->pmk,mgmr->profiles[iVar1].pmk,0x41); + memcpy(profile_msg->mac,mgmr->profiles[iVar1].mac,6); + return 0; +} + + + +int wifi_mgmr_profile_autoreconnect_is_enabled(wifi_mgmr_t *mgmr,int index) + +{ + return (uint)(mgmr->disable_autoreconnect == '\0'); +} + + + +int wifi_mgmr_profile_autoreconnect_disable(wifi_mgmr_t *mgmr,int index) + +{ + mgmr->disable_autoreconnect = '\x01'; + return 0; +} + + + +int wifi_mgmr_profile_autoreconnect_enable(wifi_mgmr_t *mgmr,int index) + +{ + mgmr->disable_autoreconnect = '\0'; + return 0; +} + + + +int wifi_netif_dhcp_start(netif *netif) + +{ + netifapi_netif_common(netif,(netifapi_void_fn)0x0,dhcp_start); + return 0; +} + + + +void cb_rssi_ind(void *env,int8_t rssi) + +{ + wifiMgmr.wlan_sta.field_5 = rssi; + return; +} + + + +void cb_probe_resp_ind(void *env) + +{ + printf("timestamp = 0x%llx\r\n"); + return; +} + + + +void cb_beacon_ind(void *env,wifi_event_beacon_ind_conflict4 *ind) + +{ + wifi_mgmr_api_scan_item_beacon + (ind->channel,ind->rssi,ind->auth,(uint8_t *)ind,ind->ssid,ind->ssid_len,ind->ppm_abs, + ind->ppm_rel,DAT_00000010); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void cb_disconnect_ind(void *env,wifi_event_sm_disconnect_ind *ind) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + wifi_mgmr_msg_t msg_wifi; + + memset(&local_20,0,0xd); + printf("sending disconnect\r\n"); + local_20 = WIFI_MGMR_EVENT_FW_IND_DISCONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + msg_wifi.ev = WIFI_MGMR_EVENT_FW_CHANNEL_SET; + msg_wifi.data1._0_1_ = 0x88; + msg_wifi.data1._1_1_ = 0x77; + msg_wifi.data1._2_1_ = 0x66; + msg_wifi.data1._3_1_ = 0x55; + msg_wifi.data2._0_1_ = 0xd; + wifiMgmr.wifi_mgmr_stat_info.type_ind = '\x02'; + wifiMgmr.wifi_mgmr_stat_info.status_code = ind->reason_code; + msg_wifi.data2._1_1_ = 0; + msg_wifi.data2._2_1_ = 0; + msg_wifi.data2._3_1_ = 0; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void cb_connect_ind(void *env,wifi_event_sm_connect_ind *ind) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + wifi_mgmr_msg_t msg_wifi; + + memset(&local_20,0,0xd); + local_20 = (ind->status_code == 0) + WIFI_MGMR_EVENT_FW_IND_DISCONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + msg_wifi.ev = WIFI_MGMR_EVENT_FW_CHANNEL_SET; + msg_wifi.data1._0_1_ = 0x88; + msg_wifi.data1._1_1_ = 0x77; + msg_wifi.data1._2_1_ = 0x66; + msg_wifi.data1._3_1_ = 0x55; + msg_wifi.data2._0_1_ = 0xd; + msg_wifi.data2._1_1_ = 0; + msg_wifi.data2._2_1_ = 0; + msg_wifi.data2._3_1_ = 0; + wifi_mgmr_set_connect_stat_info(ind,'\x01'); + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return; +} + + + +void cb_event_ind(void *env,wifi_event *event) + +{ + int iVar1; + uint16_t code; + uint32_t uVar2; + + uVar2 = event->id; + if (uVar2 == 1) { + puts("[WIFI] [IND] SCAN Done\r\n"); + wifi_mgmr_scan_complete_notify(); + code = 9; +LAB_23028b2c: + aos_post_event(2,code,0); + return; + } + if (uVar2 == 0) { + uVar2 = event[1].id; + iVar1 = -400; + wifiMgmr.channel = uVar2; + } + else { + if (uVar2 == 2) { + code = 10; + goto LAB_23028b2c; + } + iVar1 = -0x154; + } + printf(" SKIP Notify for set Empty Address\r\n" + iVar1 + 0x20,uVar2); + return; +} + + + +int wifi_mgmr_event_init(void) + +{ + bl_rx_sm_connect_ind_cb_register((void *)0x0,cb_connect_ind); + bl_rx_sm_disconnect_ind_cb_register((void *)0x0,cb_disconnect_ind); + bl_rx_beacon_ind_cb_register((void *)0x0,cb_beacon_ind); + bl_rx_probe_resp_ind_cb_register((void *)0x0,cb_probe_resp_ind); + bl_rx_rssi_cb_register((void *)0x0,cb_rssi_ind); + bl_rx_event_register((void *)0x0,cb_event_ind); + return 0; +} + + + +void cmd_mgr_print(bl_cmd_mgr *cmd_mgr) + +{ + list_head *plVar1; + + xQueueSemaphoreTake((QueueHandle_t)cmd_mgr->lock,0xffffffff); + plVar1 = (cmd_mgr->cmds).next; + while (plVar1 != &cmd_mgr->cmds) { + plVar1 = plVar1->next; + } + xQueueGenericSend((QueueHandle_t)cmd_mgr->lock,(void *)0x0,0,0); + return; +} + + + +void cmd_complete(bl_cmd *cmd) + +{ + ushort uVar1; + int *in_a1; + int iVar2; + int *piVar3; + + (cmd->list).next = (list_head *)((int)&(cmd->list).next[-1].prev + 3); + piVar3 = (int *)in_a1[1]; + iVar2 = *in_a1; + *(int **)(iVar2 + 4) = piVar3; + *piVar3 = iVar2; + *in_a1 = 0x100100; + in_a1[1] = 0x200200; + uVar1 = *(ushort *)(in_a1 + 6); + *(ushort *)(in_a1 + 6) = uVar1 | 0x20; + if ((uVar1 & 1) != 0) { + vPortFree(in_a1); + return; + } + if ((uVar1 & 0x18) == 0) { + in_a1[0xf] = 0; + xEventGroupSetBits((EventGroupHandle_t)(in_a1 + 7),1); + return; + } + return; +} + + + +int cmd_mgr_msgind(bl_cmd_mgr *cmd_mgr,ipc_e2a_msg *msg,msg_cb_fct *cb) + +{ + bool bVar1; + bl_cmd *pbVar2; + int iVar3; + + xQueueSemaphoreTake((QueueHandle_t)cmd_mgr->lock,0xffffffff); + pbVar2 = (bl_cmd *)(cmd_mgr->cmds).next; + do { + if (pbVar2 == (bl_cmd *)&cmd_mgr->cmds) { + bVar1 = false; +LAB_23028c80: + xQueueGenericSend((QueueHandle_t)cmd_mgr->lock,(void *)0x0,0,0); + if ((!bVar1) && (cb != (msg_cb_fct *)0x0)) { + (*cb)((bl_hw *)&cmd_mgr[-1].drain,(bl_cmd *)0x0,msg); + } + return 0; + } + if (((pbVar2->reqid == msg->id) && ((pbVar2->flags & 0x10) != 0)) && + ((cb == (msg_cb_fct *)0x0 || + (iVar3 = (*cb)((bl_hw *)&cmd_mgr[-1].drain,pbVar2,msg), iVar3 == 0)))) { + pbVar2->flags = pbVar2->flags & 0xffef; + if ((pbVar2->e2a_msg != (char *)0x0) && (msg->param_len != 0)) { + memcpy(pbVar2->e2a_msg,msg->param,(uint)msg->param_len); + } + bVar1 = true; + if ((pbVar2->flags & 0x18) == 0) { + cmd_complete((bl_cmd *)&cmd_mgr->queue_sz); + } + goto LAB_23028c80; + } + pbVar2 = (bl_cmd *)(pbVar2->list).next; + } while( true ); +} + + + +int cmd_mgr_llind(bl_cmd_mgr *cmd_mgr,bl_cmd *cmd) + +{ + ushort uVar1; + char "cmd_mgr_llind" [14]; + bl_cmd *msg_buf; + bl_cmd *pbVar2; + _Bool __warned; + + xQueueSemaphoreTake((QueueHandle_t)cmd_mgr->lock,0xffffffff); + msg_buf = (bl_cmd *)(cmd_mgr->cmds).next; + pbVar2 = (bl_cmd *)0x0; + do { + if (msg_buf == (bl_cmd *)&cmd_mgr->cmds) { + msg_buf = (bl_cmd *)0x0; + if (pbVar2 != (bl_cmd *)0x0) { +LAB_23028d50: + uVar1 = cmd->flags; + cmd->flags = uVar1 & 0xfff7; + if ((uVar1 & 0x10) == 0) { + cmd_complete((bl_cmd *)&cmd_mgr->queue_sz); + } + if (msg_buf != (bl_cmd *)0x0) { +LAB_23028d6c: + msg_buf->flags = msg_buf->flags & 0xfffb; + ipc_host_msg_push(*(ipc_host_env_tag **)(cmd_mgr + 1),msg_buf, + (uint16_t)(((uint)msg_buf->a2e_msg->param_len + 8) * 0x10000 >> 0x10)); + vPortFree(msg_buf->a2e_msg); + } + } + xQueueGenericSend((QueueHandle_t)cmd_mgr->lock,(void *)0x0,0,0); + return 0; + } + if ((pbVar2 == (bl_cmd *)0x0) && ((list_head *)msg_buf->tkn == (list_head *)cmd->tkn)) { + pbVar2 = msg_buf; + if ((msg_buf != cmd) && (__warned == false)) { + printf("%s:%d\r\n","cmd_mgr_llind",0xcf); + __warned = true; + } + } + else { + if ((msg_buf->flags & 4) != 0) { + if (pbVar2 == (bl_cmd *)0x0) goto LAB_23028d6c; + goto LAB_23028d50; + } + } + msg_buf = (bl_cmd *)(msg_buf->list).next; + } while( true ); +} + + + +undefined4 cmd_mgr_queue(char *param_1,char **param_2) + +{ + bool bVar1; + ushort uVar2; + undefined4 uVar3; + EventBits_t EVar4; + char *pcVar5; + char **ppcVar6; + int iVar7; + + xQueueSemaphoreTake(*(QueueHandle_t *)(param_1 + 0x18),0xffffffff); + if (*param_1 == '\x02') { + param_2[0xf] = &DAT_00000020; + xQueueGenericSend(*(QueueHandle_t *)(param_1 + 0x18),(void *)0x0,0,0); + uVar3 = 0xffffffe0; + } + else { + if (param_1 + 0x10 == *(char **)(param_1 + 0x10)) { + bVar1 = false; + } + else { + if (*(int *)(param_1 + 8) == *(int *)(param_1 + 0xc)) { + param_2[0xf] = &DAT_0000000c; + xQueueGenericSend(*(QueueHandle_t *)(param_1 + 0x18),(void *)0x0,0,0); + return 0xfffffff4; + } + bVar1 = false; + if ((*(ushort *)(*(int *)(param_1 + 0x14) + 0x18) & 0xc) != 0) { + bVar1 = true; + *(ushort *)(param_2 + 6) = *(ushort *)(param_2 + 6) | 4; + } + } + if ((*(ushort *)(param_2 + 6) & 2) == 0) { + uVar2 = 8; + } + else { + uVar2 = 0x18; + } + *(ushort *)(param_2 + 6) = *(ushort *)(param_2 + 6) | uVar2; + pcVar5 = *(char **)(param_1 + 4); + *(char **)(param_1 + 4) = pcVar5 + 1; + param_2[5] = pcVar5; + param_2[0xf] = &DAT_00000004; + if ((*(ushort *)(param_2 + 6) & 1) == 0) { + xEventGroupCreateStatic((StaticEventGroup_t *)(param_2 + 7)); + } + ppcVar6 = *(char ***)(param_1 + 0x14); + *(char ***)(param_1 + 0x14) = param_2; + *param_2 = param_1 + 0x10; + *(char ***)(param_2 + 1) = ppcVar6; + *(char ***)ppcVar6 = param_2; + iVar7 = *(int *)(param_1 + 8); + *(int *)(param_1 + 8) = iVar7 + 1; + xQueueGenericSend(*(QueueHandle_t *)(param_1 + 0x18),(void *)0x0,0,0); + if (!bVar1) { + ipc_host_msg_push(*(ipc_host_env_tag **)(param_1 + 0x30),param_2, + (uint16_t)(((uint)*(ushort *)(param_2[3] + 6) + 8) * 0x10000 >> 0x10)); + vPortFree(param_2[3]); + } + if ((*(ushort *)(param_2 + 6) & 1) == 0) { + EVar4 = xEventGroupWaitBits((EventGroupHandle_t)(param_2 + 7),1,1,0,(iVar7 + 1) * 1000000); + if ((EVar4 & 1) == 0) { + xQueueSemaphoreTake(*(QueueHandle_t *)(param_1 + 0x18),0xffffffff); + *param_1 = '\x02'; + if ((*(ushort *)(param_2 + 6) & 0x20) == 0) { + param_2[0xf] = (char *)0x6e; + cmd_complete((bl_cmd *)(param_1 + 8)); + } + xQueueGenericSend(*(QueueHandle_t *)(param_1 + 0x18),(void *)0x0,0,0); + } + vEventGroupDelete((EventGroupHandle_t)(param_2 + 7)); + } + else { + param_2[0xf] = (char *)0x0; + } + uVar3 = 0; + } + return uVar3; +} + + + +void cmd_mgr_drain(bl_cmd_mgr *cmd_mgr) + +{ + list_head *plVar1; + list_head *plVar2; + list_head *plVar3; + list_head *plVar4; + + xQueueSemaphoreTake((QueueHandle_t)cmd_mgr->lock,0xffffffff); + plVar2 = (cmd_mgr->cmds).next; + plVar3 = plVar2->next; + while (plVar1 = plVar3, plVar2 != &cmd_mgr->cmds) { + plVar4 = plVar2->prev; + plVar3 = plVar2->next; + plVar3->prev = plVar4; + plVar4->next = plVar3; + plVar2->next = (list_head *)0x100100; + plVar2->prev = (list_head *)0x200200; + cmd_mgr->queue_sz = cmd_mgr->queue_sz - 1; + if ((*(ushort *)&plVar2[3].next & 1) == 0) { + xEventGroupSetBits((EventGroupHandle_t)&plVar2[3].prev,1); + } + plVar3 = plVar1->next; + plVar2 = plVar1; + } + xQueueGenericSend((QueueHandle_t)cmd_mgr->lock,(void *)0x0,0,0); + return; +} + + + +void bl_cmd_mgr_init(bl_cmd_mgr *cmd_mgr) + +{ + QueueHandle_t pQVar1; + + (cmd_mgr->cmds).next = &cmd_mgr->cmds; + (cmd_mgr->cmds).prev = &cmd_mgr->cmds; + pQVar1 = xQueueCreateMutex('\x01'); + cmd_mgr->max_queue_sz = 8; + cmd_mgr->queue = cmd_mgr_queue; + cmd_mgr->print = cmd_mgr_print; + cmd_mgr->drain = cmd_mgr_drain; + cmd_mgr->llind = cmd_mgr_llind; + *(QueueHandle_t *)&cmd_mgr->lock = pQVar1; + cmd_mgr->msgind = cmd_mgr_msgind; + return; +} + + + +int bl_irqs_init(bl_hw *bl_hw) + +{ + return 0; +} + + + +void bl_irq_bottomhalf(bl_hw *bl_hw) + +{ + uint uVar1; + uint status; + TickType_t TVar2; + + xTaskGetTickCount(); + uVar1 = 0; + status = ipc_host_get_rawstatus(bl_hw->ipc_env); + do { + while (status != 0) { + uVar1 = uVar1 | status; + ipc_host_irq(bl_hw->ipc_env,status); + status = ipc_host_get_rawstatus(bl_hw->ipc_env); + } + TVar2 = xTaskGetTickCount(); + if ((uVar1 & 8) != 0) { + (bl_hw->stats).last_rx = TVar2; + } + if ((uVar1 & 0x780) != 0) { + (bl_hw->stats).last_tx = TVar2; + } + ipc_host_enable_irq(bl_hw->ipc_env,0x7ff); + status = ipc_host_get_rawstatus(bl_hw->ipc_env); + } while (status != 0); + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void goToErrorState(stateMachine *fsm,event *event) + +{ + state *psVar1; + + fsm->previousState = fsm->currentState; + psVar1 = fsm->errorState; + fsm->currentState = psVar1; + if ((psVar1 != (state *)0x0) && + (psVar1->entryAction != (anon_subr_void_void_ptr_event_ptr_for_entryAction *)0x0)) { + // WARNING: Could not recover jumptable at 0x23029062. Too many branches + // WARNING: Treating indirect jump as call + (*psVar1->entryAction)(psVar1->data); + return; + } + return; +} + + + +void stateM_init(stateMachine *fsm,state *initialState,state *errorState) + +{ + if (fsm != (stateMachine *)0x0) { + fsm->currentState = initialState; + fsm->previousState = (state *)0x0; + fsm->errorState = errorState; + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +int stateM_handleEvent(stateMachine *fsm,event *event) + +{ + state *psVar1; + state *psVar2; + int iVar3; + int *piVar4; + uint uVar5; + + if (fsm == (stateMachine *)0x0) { + return -2; + } + iVar3 = -2; + if (event != (event *)0x0) { + psVar1 = fsm->currentState; + if (psVar1 == (state *)0x0) { +LAB_23029090: + goToErrorState(fsm,event); + iVar3 = -1; + } + else { + psVar2 = (state *)psVar1->numTransitions; + while (psVar2 != (state *)0x0) { + uVar5 = 0; + while (uVar5 < psVar1->numTransitions) { + piVar4 = &psVar1->transitions->eventType + uVar5 * 5; + if ((*piVar4 == event->type) && + (((code *)piVar4[2] == (code *)0x0 || + (iVar3 = (*(code *)piVar4[2])(piVar4[1],event), iVar3 != 0)))) { + psVar1 = (state *)piVar4[4]; + if ((state *)piVar4[4] != (state *)0x0) { + do { + psVar2 = psVar1; + psVar1 = psVar2->entryState; + } while (psVar2->entryState != (state *)0x0); + psVar1 = fsm->currentState; + if ((psVar1 != psVar2) && + (psVar1->exitAction != (anon_subr_void_void_ptr_event_ptr_for_exitAction *)0x0)) { + (*psVar1->exitAction)(psVar1->data,event); + } + if ((code *)piVar4[3] != (code *)0x0) { + (*(code *)piVar4[3])(fsm->currentState->data,event,psVar2->data); + } + if ((fsm->currentState != psVar2) && + (psVar2->entryAction != (anon_subr_void_void_ptr_event_ptr_for_entryAction *)0x0)) + { + (*psVar2->entryAction)(psVar2->data,event); + } + psVar1 = fsm->currentState; + fsm->currentState = psVar2; + fsm->previousState = psVar1; + if (psVar1 == psVar2) { + return 1; + } + if (fsm->errorState == psVar2) { + return -1; + } + if (psVar2->numTransitions == 0) { + return 3; + } + return 0; + } + goto LAB_23029090; + } + uVar5 = uVar5 + 1; + } + psVar1 = psVar1->parentState; + psVar2 = psVar1; + } + iVar3 = 2; + } + } + return iVar3; +} + + + +void netif_status_callback(netif *netif) + +{ + uint32_t ip; + char *pcVar1; + ip_addr_t *piVar2; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + + pcVar1 = ip4addr_ntoa((ip4_addr_t *)&netif->ip_addr); + printf("[lwip] netif status callback\r\n IP: %s\r\n",pcVar1); + pcVar1 = ip4addr_ntoa((ip4_addr_t *)&netif->netmask); + printf(" MK: %s\r\n",pcVar1); + pcVar1 = ip4addr_ntoa((ip4_addr_t *)&netif->gw); + printf(" GW: %s\r\n",pcVar1); + if (((ip4_addr_t *)&netif->ip_addr != (ip4_addr_t *)0x0) && ((netif->ip_addr).addr != 0)) { + wifi_mgmr_api_ip_update(); + mask = (netif->netmask).addr; + gw = (netif->gw).addr; + ip = (netif->ip_addr).addr; + piVar2 = dns_getserver('\0'); + dns1 = piVar2->addr; + piVar2 = dns_getserver('\x01'); + wifi_mgmr_api_ip_got(ip,mask,gw,dns1,piVar2->addr); + return; + } + printf(" SKIP Notify for set Empty Address\r\n"); + return; +} + + + +err_t wifi_tx(netif *netif,pbuf *p) + +{ + err_t eVar1; + TickType_t TVar2; + pbuf *ppVar3; + + ppVar3 = p; + if (p->tot_len < 0x5eb) { + do { + ppVar3 = ppVar3->next; + } while (ppVar3 != (pbuf *)0x0); + eVar1 = '\0'; + bl_output(bl606a0_sta,netif,p,(uint)(netif[-1].client_data[1] == (void *)0x0)); + } + else { + TVar2 = xTaskGetTickCount(); + eVar1 = -0xc; + if (2000 < TVar2 - ticks_7281) { + printf("[TX] %s, TX size too big: %u bytes\r\n",&__func___7282,(uint)p->tot_len); + ticks_7281 = xTaskGetTickCount(); + } + } + return eVar1; +} + + + +err_t bl606a0_wifi_netif_init(netif *netif) + +{ + netif->hostname = "bl606a0"; + netif->mtu = 0x5dc; + *(undefined2 *)&netif->hwaddr_len = 0xa06; + netif->output = etharp_output; + netif->linkoutput = wifi_tx; + netif_set_status_callback(netif,netif_status_callback); + return '\0'; +} + + + +int bl606a0_wifi_init(wifi_conf_t *conf) + +{ + int iVar1; + byte bStack24; + byte bStack23; + byte bStack22; + byte bStack21; + uint8_t mac [6]; + + printf("\r\n\r\n[BL] Initi Wi-Fi"); + memset(&bStack24,0,6); + bl_wifi_mac_addr_get(&bStack24); + printf(" with MAC #### %02X:%02X:%02X:%02X:%02X:%02X ####\r\n",(uint)bStack24,(uint)bStack23, + (uint)bStack22,(uint)bStack21,(uint)mac[0],(uint)mac[1]); + bl_msg_update_channel_cfg((char *)conf); + printf("-----------------------------------------------------\r\n"); + bl_wifi_clock_enable(); + memset(&bl606a0_sta,0,4); + iVar1 = bl_main_rtthread_start((bl_hw **)&bl606a0_sta); + return iVar1; +} + + + +uint32_t fdt32_ld(fdt32_t *p) + +{ + return (uint)*(byte *)((int)p + 2) << 8 | + (uint)*(byte *)p << 0x18 | (uint)*(byte *)((int)p + 1) << 0x10 | + (uint)*(byte *)((int)p + 3); +} + + + +int nextprop_(void *fdt,int offset) + +{ + uint32_t uVar1; + int iStack36; + int nextoffset; + + while( true ) { + uVar1 = fdt_next_tag(fdt,offset,&iStack36); + if (uVar1 == 3) { + return offset; + } + if (uVar1 == 9) break; + offset = iStack36; + if (uVar1 != 4) { + return -1; + } + } + if (iStack36 < 0) { + return iStack36; + } + return -0xb; +} + + + +fdt_property * fdt_get_property_by_offset_(void *fdt,int offset,int *lenp) + +{ + fdt_property *pfVar1; + uint32_t uVar2; + + uVar2 = fdt_check_prop_offset_(fdt,offset); + if ((int)uVar2 < 0) { + pfVar1 = (fdt_property *)0x0; + if (lenp == (int *)0x0) { + return (fdt_property *)0x0; + } + } + else { + uVar2 = fdt32_ld((fdt32_t *)((int)fdt + 8)); + pfVar1 = (fdt_property *)((int)fdt + uVar2 + offset); + if (lenp == (int *)0x0) { + return pfVar1; + } + uVar2 = fdt32_ld(&pfVar1->len); + } + *lenp = uVar2; + return pfVar1; +} + + + +char * fdt_get_string(void *fdt,int stroffset,int *lenp) + +{ + char *__s; + uint32_t uVar1; + void *pvVar2; + uint __n; + uint uVar3; + + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0xc)); + pvVar2 = (void *)fdt_ro_probe_(fdt); + if (pvVar2 == (void *)0x0) { + uVar3 = uVar1 + stroffset; + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 4)); + if (uVar3 < uVar1) { + __n = uVar1 - uVar3; + uVar1 = fdt32_ld((fdt32_t *)fdt); + if (uVar1 == 0xd00dfeed) { + if (-1 < stroffset) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x14)); + if (0x10 < uVar1) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x20)); + if (uVar1 <= (uint)stroffset) goto LAB_230294a2; + if (uVar1 - stroffset < __n) { + __n = uVar1 - stroffset; + } + } +LAB_23029442: + __s = (char *)((int)fdt + uVar3); + pvVar2 = memchr(__s,0,__n); + if (pvVar2 != (void *)0x0) { + pvVar2 = (void *)((int)pvVar2 - (int)__s); + goto joined_r0x23029498; + } + pvVar2 = (void *)0xfffffff8; + goto fail; + } + } + else { + if (uVar1 != 0x2ff20112) { + pvVar2 = (void *)0xfffffff3; + goto fail; + } + if ((stroffset < 0) && + (uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x20)), -uVar1 <= (uint)stroffset)) { + if ((uint)-stroffset < __n) { + __n = -stroffset; + } + goto LAB_23029442; + } + } + } +LAB_230294a2: + pvVar2 = (void *)0xfffffffc; + } +fail: + __s = (char *)0x0; +joined_r0x23029498: + if (lenp != (int *)0x0) { + *(void **)lenp = pvVar2; + } + return __s; +} + + + +char * fdt_get_name(void *fdt,int nodeoffset,int *len) + +{ + uint32_t uVar1; + size_t sVar2; + uint32_t uVar3; + char *__s; + + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 8)); + sVar2 = fdt_ro_probe_(fdt); + if ((sVar2 == 0) && (sVar2 = fdt_check_node_offset_(fdt,nodeoffset), -1 < (int)sVar2)) { + uVar3 = fdt32_ld((fdt32_t *)((int)fdt + 0x14)); + __s = (char *)((int)fdt + nodeoffset + uVar1 + 4); + if (uVar3 < 0x10) { + __s = strrchr(__s,0x2f); + if (__s == (char *)0x0) { + sVar2 = 0xfffffff5; + goto fail; + } + __s = __s + 1; + } + if (len == (int *)0x0) { + return __s; + } + sVar2 = strlen(__s); + } + else { +fail: + __s = (char *)0x0; + if (len == (int *)0x0) { + return (char *)0x0; + } + } + *len = sVar2; + return __s; +} + + + +int fdt_subnode_offset_namelen(void *fdt,int offset,char *name,int namelen) + +{ + int iVar1; + char *__s1; + void *pvVar2; + int iStack40; + int depth; + int olen; + + iVar1 = fdt_ro_probe_(fdt); + if (iVar1 == 0) { + iStack40 = 0; + while (-1 < offset) { + if (iStack40 < 0) goto LAB_23029550; + if ((((iStack40 == 1) && (__s1 = fdt_get_name(fdt,offset,&depth), __s1 != (char *)0x0)) && + (namelen <= depth)) && (iVar1 = memcmp(__s1,name,namelen), iVar1 == 0)) { + if (__s1[namelen] == '\0') { + return offset; + } + pvVar2 = memchr(name,0x40,namelen); + if ((pvVar2 == (void *)0x0) && (__s1[namelen] == '@')) { + return offset; + } + } + offset = fdt_next_node(fdt,offset,&iStack40); + } + iVar1 = offset; + if (iStack40 < 0) { +LAB_23029550: + iVar1 = -1; + } + } + return iVar1; +} + + + +int fdt_subnode_offset(void *fdt,int parentoffset,char *name) + +{ + size_t namelen; + int iVar1; + + namelen = strlen(name); + iVar1 = fdt_subnode_offset_namelen(fdt,parentoffset,name,namelen); + return iVar1; +} + + + +int fdt_first_property_offset(void *fdt,int nodeoffset) + +{ + int offset; + + offset = fdt_check_node_offset_(fdt,nodeoffset); + if (-1 < offset) { + offset = nextprop_(fdt,offset); + return offset; + } + return offset; +} + + + +int fdt_next_property_offset(void *fdt,int offset) + +{ + int offset_00; + + offset_00 = fdt_check_prop_offset_(fdt,offset); + if (-1 < offset_00) { + offset_00 = nextprop_(fdt,offset_00); + return offset_00; + } + return offset_00; +} + + + +// WARNING: Variable defined which should be unmapped: slen + +fdt_property * +fdt_get_property_namelen_(void *fdt,int offset,char *name,int namelen,int *lenp,int *poffset) + +{ + int offset_00; + fdt_property *pfVar1; + uint32_t stroffset; + char *__s1; + int iVar2; + int iStack36; + int slen; + + offset_00 = fdt_first_property_offset(fdt,offset); + do { + if (offset_00 < 0) { +LAB_2302964e: + if (lenp != (int *)0x0) { + *lenp = offset_00; + } + return (fdt_property *)0x0; + } + pfVar1 = fdt_get_property_by_offset_(fdt,offset_00,lenp); + if (pfVar1 == (fdt_property *)0x0) { + offset_00 = -0xd; + goto LAB_2302964e; + } + stroffset = fdt32_ld(&pfVar1->nameoff); + __s1 = fdt_get_string(fdt,stroffset,&iStack36); + if (((__s1 != (char *)0x0) && (namelen == iStack36)) && + (iVar2 = memcmp(__s1,name,namelen), iVar2 == 0)) { + if (poffset == (int *)0x0) { + return pfVar1; + } + *poffset = offset_00; + return pfVar1; + } + offset_00 = fdt_next_property_offset(fdt,offset_00); + } while( true ); +} + + + +void * fdt_getprop_namelen(void *fdt,int nodeoffset,char *name,int namelen,int *lenp) + +{ + fdt_property *pfVar1; + uint32_t uVar2; + int iStack20; + int poffset; + + pfVar1 = fdt_get_property_namelen_(fdt,nodeoffset,name,namelen,lenp,&iStack20); + if (pfVar1 != (fdt_property *)0x0) { + uVar2 = fdt32_ld((fdt32_t *)((int)fdt + 0x14)); + if (((uVar2 < 0x10) && ((iStack20 + 0xcU & 7) != 0)) && + (uVar2 = fdt32_ld(&pfVar1->len), 7 < uVar2)) { + pfVar1 = (fdt_property *)&pfVar1[1].len; + } + else { + pfVar1 = pfVar1 + 1; + } + } + return pfVar1; +} + + + +void * fdt_getprop(void *fdt,int nodeoffset,char *name,int *lenp) + +{ + size_t namelen; + void *pvVar1; + + namelen = strlen(name); + pvVar1 = fdt_getprop_namelen(fdt,nodeoffset,name,namelen,lenp); + return pvVar1; +} + + + +// WARNING: Variable defined which should be unmapped: length + +int fdt_stringlist_count(void *fdt,int nodeoffset,char *property) + +{ + int iVar1; + char *__string; + size_t sVar2; + char *pcVar3; + int iStack20; + int length; + + __string = (char *)fdt_getprop(fdt,nodeoffset,property,&iStack20); + iVar1 = iStack20; + if (__string != (char *)0x0) { + pcVar3 = __string + iStack20; + iVar1 = 0; + while (__string < pcVar3) { + sVar2 = strnlen(__string,(size_t)(pcVar3 + -(int)__string)); + iStack20 = sVar2 + 1; + __string = __string + iStack20; + if (pcVar3 < __string) { + return -0xf; + } + iVar1 = iVar1 + 1; + } + } + return iVar1; +} + + + +char * fdt_stringlist_get(void *fdt,int nodeoffset,char *property,int idx,int *lenp) + +{ + char *__string; + size_t sVar1; + int iVar2; + char *pcVar3; + int iStack36; + int length; + + __string = (char *)fdt_getprop(fdt,nodeoffset,property,&iStack36); + if (__string == (char *)0x0) { + if (lenp != (int *)0x0) { + *lenp = iStack36; + return (char *)0x0; + } + } + else { + pcVar3 = __string + iStack36; + while (__string < pcVar3) { + sVar1 = strnlen(__string,(size_t)(pcVar3 + -(int)__string)); + iStack36 = sVar1 + 1; + if (pcVar3 < __string + iStack36) { + iVar2 = -0xf; + if (lenp == (int *)0x0) { + return (char *)0x0; + } + goto LAB_230297ce; + } + if (idx == 0) { + if (lenp != (int *)0x0) { + *lenp = sVar1; + return __string; + } + return __string; + } + idx = idx + -1; + __string = __string + iStack36; + } + if (lenp != (int *)0x0) { + iVar2 = -1; +LAB_230297ce: + *lenp = iVar2; + } + } + return (char *)0x0; +} + + + +void blfdt(char *buf,int len,int argc,char **argv) + +{ + tc_fdt_wifi(); + tc_blfdtdump(); + return; +} + + + +int blfdt_cli_init(void) + +{ + return 0; +} + + + +uint32_t fdt32_ld(fdt32_t *p) + +{ + return (uint)*(byte *)((int)p + 2) << 8 | + (uint)*(byte *)p << 0x18 | (uint)*(byte *)((int)p + 1) << 0x10 | + (uint)*(byte *)((int)p + 3); +} + + + +int fdt_ro_probe_(void *fdt) + +{ + uint32_t uVar1; + int iVar2; + + uVar1 = fdt32_ld((fdt32_t *)fdt); + if (uVar1 == 0xd00dfeed) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x14)); + iVar2 = -10; + if (1 < uVar1) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x18)); + iVar2 = 0; + if (0x11 < uVar1) { + iVar2 = -10; + } + } + } + else { + iVar2 = -9; + if (uVar1 == 0x2ff20112) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x24)); + iVar2 = 0; + if (uVar1 == 0) { + iVar2 = -7; + } + } + } + return iVar2; +} + + + +void * fdt_offset_ptr(void *fdt,int offset,uint len) + +{ + uint32_t uVar1; + void *pvVar2; + uint uVar3; + + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 8)); + uVar3 = uVar1 + offset; + pvVar2 = (void *)0x0; + if ((uint)offset <= uVar3) { + pvVar2 = (void *)0x0; + if (uVar3 <= uVar3 + len) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 4)); + pvVar2 = (void *)0x0; + if (uVar3 + len <= uVar1) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x14)); + if (0x10 < uVar1) { + if (len + offset < (uint)offset) { + return (void *)0x0; + } + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x24)); + if (uVar1 < len + offset) { + return (void *)0x0; + } + } + pvVar2 = (void *)((int)fdt + uVar3); + } + } + } + return pvVar2; +} + + + +uint32_t fdt_next_tag(void *fdt,int startoffset,int *nextoffset) + +{ + int offset; + int offset_00; + uint *puVar1; + char *pcVar2; + void *pvVar3; + uint32_t uVar4; + uint uVar5; + uint uVar6; + + *nextoffset = -8; + puVar1 = (uint *)fdt_offset_ptr(fdt,startoffset,4); + if (puVar1 != (uint *)0x0) { + uVar5 = *puVar1; + offset = startoffset + 4; + uVar5 = uVar5 << 0x18 | uVar5 >> 0x18 | (uVar5 >> 8 & 0xff) << 0x10 | + (uVar5 >> 0x10 & 0xff) << 8; + *nextoffset = -0xb; + offset_00 = offset; + switch(uVar5) { + case 1: + do { + offset = offset_00 + 1; + pcVar2 = (char *)fdt_offset_ptr(fdt,offset_00,1); + if (pcVar2 == (char *)0x0) { + return 9; + } + offset_00 = offset; + } while (*pcVar2 != '\0'); + break; + case 2: + case 4: + case 9: + break; + case 3: + puVar1 = (uint *)fdt_offset_ptr(fdt,offset,4); + if (puVar1 == (uint *)0x0) { + return 9; + } + uVar6 = *puVar1; + uVar6 = uVar6 << 0x18 | uVar6 >> 0x18 | (uVar6 >> 8 & 0xff) << 0x10 | + (uVar6 >> 0x10 & 0xff) << 8; + uVar4 = fdt32_ld((fdt32_t *)((int)fdt + 0x14)); + offset = startoffset + 0xcU + uVar6; + if (((uVar4 < 0x10) && (7 < uVar6)) && ((startoffset + 0xcU & 7) != 0)) { + offset = offset + 4; + } + break; + default: + goto LAB_23029986; + } + pvVar3 = fdt_offset_ptr(fdt,startoffset,offset - startoffset); + if (pvVar3 != (void *)0x0) { + *nextoffset = offset + 3U & 0xfffffffc; + return uVar5; + } + } +LAB_23029986: + return 9; +} + + + +int fdt_check_node_offset_(void *fdt,int offset) + +{ + uint32_t uVar1; + int aiStack20 [4]; + + if (((offset < 0) || ((offset & 3U) != 0)) || + (aiStack20[0] = offset, uVar1 = fdt_next_tag(fdt,offset,aiStack20), uVar1 != 1)) { + aiStack20[0] = -4; + } + return aiStack20[0]; +} + + + +int fdt_check_prop_offset_(void *fdt,int offset) + +{ + uint32_t uVar1; + int aiStack20 [4]; + + if (((offset < 0) || ((offset & 3U) != 0)) || + (aiStack20[0] = offset, uVar1 = fdt_next_tag(fdt,offset,aiStack20), uVar1 != 3)) { + aiStack20[0] = -4; + } + return aiStack20[0]; +} + + + +int fdt_next_node(void *fdt,int offset,int *depth) + +{ + uint32_t uVar1; + int iVar2; + int iStack36; + int nextoffset; + + iStack36 = 0; + if (offset < 0) goto LAB_23029a68; + iStack36 = fdt_check_node_offset_(fdt,offset); + iVar2 = iStack36; + do { + if (iVar2 < 0) { + return iStack36; + } +LAB_23029a68: + do { + while (iVar2 = iStack36, uVar1 = fdt_next_tag(fdt,iStack36,&iStack36), uVar1 != 2) { + if (uVar1 == 9) { + if (iStack36 < 0) { + if (iStack36 != -8) { + return iStack36; + } + if (depth != (int *)0x0) { + return -8; + } + } + return -1; + } + if (uVar1 == 1) { + if (depth == (int *)0x0) { + return iVar2; + } + *depth = *depth + 1; + return iVar2; + } + } + } while (depth == (int *)0x0); + iVar2 = *depth + -1; + *depth = iVar2; + } while( true ); +} + + + +uint32_t fdt32_to_cpu(fdt32_t x) + +{ + return (x >> 0x10 & 0xff) << 8 | x << 0x18 | x >> 0x18 | (x >> 8 & 0xff) << 0x10; +} + + + +uint64_t fdt64_to_cpu(void) + +{ + uint64_t in_fa0; + + return in_fa0; +} + + + +uint32_t fdt32_ld(fdt32_t *p) + +{ + return (uint)*(byte *)((int)p + 2) << 8 | + (uint)*(byte *)p << 0x18 | (uint)*(byte *)((int)p + 1) << 0x10 | + (uint)*(byte *)((int)p + 3); +} + + + +_Bool util_is_printable_string(void *data,int len) + +{ + byte *pbVar1; + undefined uVar2; + byte *pbVar3; + byte *pbVar4; + + if (len == 0) { +LAB_23029ba0: + uVar2 = 0; + } + else { + pbVar1 = (byte *)(len + (int)data); + uVar2 = 0; + if (pbVar1[-1] == 0) { + while (pbVar3 = (byte *)data, data < pbVar1) { + do { + pbVar4 = pbVar3; + if ((*pbVar3 == 0) || ((_ctype_[(uint)*pbVar3 + 1] & 0x97) == 0)) break; + pbVar3 = pbVar3 + 1; + pbVar4 = pbVar1; + } while (pbVar1 != pbVar3); + if ((*pbVar4 != 0) || ((byte *)data == pbVar4)) goto LAB_23029ba0; + data = pbVar4 + 1; + } + uVar2 = 1; + } + } + return (_Bool)uVar2; +} + + + +void utilfdt_print_data(char *data,int len) + +{ + char *__format; + _Bool _Var1; + undefined3 extraout_var; + size_t sVar2; + uint32_t uVar3; + undefined1 *puVar4; + int iVar5; + + if (len == 0) { + return; + } + _Var1 = util_is_printable_string(data,len); + if (CONCAT31(extraout_var,_Var1) != 0) { + printf(" = "); + __format = data + len; + while( true ) { + printf("\"%s\"",data); + sVar2 = strlen(data); + data = data + sVar2 + 1; + if (__format <= data) break; + printf(", "); + } + return; + } + if ((len & 3U) == 0) { + printf(" = <"); + iVar5 = 0; + while (iVar5 < len / 4) { + uVar3 = fdt32_to_cpu(*(fdt32_t *)(data + iVar5 * 4)); + puVar4 = (undefined1 *)0x23080f8c; + if (len / 4 + -1 <= iVar5) { + puVar4 = &DAT_23088e60; + } + printf("0x%08x%s",uVar3,puVar4); + iVar5 = iVar5 + 1; + } + __format = ">"; + } + else { + printf(" = ["); + iVar5 = 0; + while (iVar5 < len) { + puVar4 = (undefined1 *)0x23080f8c; + if (len + -1 <= iVar5) { + puVar4 = &DAT_23088e60; + } + printf("%02x%s",(uint)(byte)data[iVar5],puVar4); + iVar5 = iVar5 + 1; + } + __format = "]"; + } + printf(__format); + return; +} + + + +undefined4 tc_blfdtdump(void) + +{ + uint8_t *__s; + uint *puVar1; + fdt32_t *pfVar2; + TickType_t TVar3; + uint32_t len; + uint32_t uVar4; + uint32_t uVar5; + uint32_t uVar6; + uint32_t uVar7; + uint32_t uVar8; + uint uVar9; + uint uVar10; + undefined *puVar11; + undefined4 uVar12; + size_t sVar13; + char *__format; + uint uVar14; + uint uVar15; + int iVar16; + fdt32_t *pfVar17; + undefined *puVar18; + int iVar19; + fdt32_t *data; + uint64_t uVar20; + fdt32_t *pfStack72; + + __s = tc_wifi_dtb; + while( true ) { + if ((int)(&UNK_2308063b + -(int)__s) < 4) break; + __s = (uint8_t *)memchr(__s,0xd0,-(int)__s + 0x23080637); + if ((fdt32_t *)__s == (fdt32_t *)0x0) goto LAB_23029ed2; + len = fdt32_ld((fdt32_t *)__s); + if (len == 0xd00dfeed) { + puVar18 = &UNK_2308063b + -(int)__s; + if ((((((undefined *)0x27 < puVar18) && (len = fdt32_ld((fdt32_t *)__s + 5), len < 0x12)) && + (len = fdt32_ld((fdt32_t *)__s + 6), len < 0x12)) && + ((puVar11 = (undefined *)fdt32_ld((fdt32_t *)__s + 1), puVar11 < puVar18 && + (puVar11 = (undefined *)fdt32_ld((fdt32_t *)__s + 2), puVar11 < puVar18)))) && + (puVar11 = (undefined *)fdt32_ld((fdt32_t *)__s + 3), puVar11 < puVar18)) + goto LAB_23029d34; + printf("%s: skipping fdt magic at offset %#tx\r\n","fdtbuff",(fdt32_t *)__s + -0x8c1fce3); + } + __s = (uint8_t *)((int)__s + 1); + } + if (((fdt32_t *)__s == (fdt32_t *)0x0) || (&UNK_2308063b + -(int)__s < (undefined *)0x28)) { +LAB_23029ed2: + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %s: could not locate fdt magic\r\n",&DAT_23072bcc, + "tc_blfdt_dump.c",0x149,"fdtbuff"); + printf("dump failed\r\n"); + uVar12 = 0xffffffff; + } + else { +LAB_23029d34: + printf("%s: found fdt at offset %#tx\r\n","fdtbuff",(fdt32_t *)__s + -0x8c1fce3); + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] dump_blob.",TVar3,&DAT_2307f16c,"tc_blfdt_dump.c",0x153); + len = fdt32_to_cpu(((fdt32_t *)__s)[4]); + uVar4 = fdt32_to_cpu(((fdt32_t *)__s)[2]); + uVar5 = fdt32_to_cpu(((fdt32_t *)__s)[3]); + uVar6 = fdt32_to_cpu(((fdt32_t *)__s)[5]); + uVar7 = fdt32_to_cpu(((fdt32_t *)__s)[1]); + printf("/dts-v1/;\r\n"); + uVar8 = fdt32_to_cpu(*(fdt32_t *)__s); + printf("// magic:\t\t0x%lx\r\n",uVar8); + printf("// totalsize:\t\t0x%lx (%lu)\r\n",uVar7); + printf("// off_dt_struct:\t0x%lx\r\n",uVar4); + printf("// off_dt_strings:\t0x%lx\r\n",uVar5); + printf("// off_mem_rsvmap:\t0x%lx\r\n",len); + printf("// version:\t\t%lu\r\n",uVar6); + uVar7 = fdt32_to_cpu(((fdt32_t *)__s)[6]); + printf("// last_comp_version:\t%lu\r\n",uVar7); + if (1 < uVar6) { + uVar7 = fdt32_to_cpu(((fdt32_t *)__s)[7]); + printf("// boot_cpuid_phys:\t0x%lx\r\n",uVar7); + if (uVar6 != 2) { + uVar7 = fdt32_to_cpu(((fdt32_t *)__s)[8]); + printf("// size_dt_strings:\t0x%lx\r\n",uVar7); + if (0x10 < uVar6) { + uVar7 = fdt32_to_cpu(((fdt32_t *)__s)[9]); + printf("// size_dt_struct:\t0x%lx\r\n",uVar7); + } + } + } + printf("\r\n"); + puVar1 = (uint *)(len + (int)__s); + while( true ) { + uVar9 = *puVar1; + uVar14 = puVar1[1]; + fdt64_to_cpu(); + uVar10 = puVar1[2]; + uVar15 = puVar1[3]; + uVar20 = fdt64_to_cpu(); + if ((uVar9 | uVar10 | uVar15 | uVar14) == 0) break; + printf("/memreserve/ %#llx %#llx;\r\n",uVar10,uVar15,(int)uVar20); + puVar1 = puVar1 + 4; + } + iVar19 = 0; + pfStack72 = (fdt32_t *)&DAT_23085d30; + pfVar17 = (fdt32_t *)((int)__s + uVar4); + while( true ) { + data = pfVar17 + 1; + len = fdt32_to_cpu(*pfVar17); + if (len == 9) break; + puVar18 = &DAT_2307f0c0; + if ((len < 10) && + (puVar18 = *(undefined **)(&names_3639 + len * 4), + *(undefined **)(&names_3639 + len * 4) == (undefined *)0x0)) { + puVar18 = &DAT_2307f0c0; + } + printf("// %04x: tag: 0x%08lx (%s)\r\n",(int)data + (-4 - (int)__s),len,puVar18); + if (len == 1) { + sVar13 = strlen((char *)data); + pfVar2 = data; + if (*(char *)(pfVar17 + 1) == '\0') { + pfVar2 = pfStack72; + } + printf("%*s%s {\r\n",&DAT_23088e60,pfVar2); + iVar19 = iVar19 + 1; + pfVar17 = (fdt32_t *)((int)data + sVar13 + 4 & 0xfffffffc); + } + else { + if (len == 2) { + iVar19 = iVar19 + -1; + __format = "%*s};\r\n"; +LAB_2302a036: + printf(__format,&DAT_23088e60); + pfVar17 = data; + } + else { + if (len == 4) { + __format = "%*s// [NOP]\r\n"; + goto LAB_2302a036; + } + if (len != 3) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %*s ** Unknown tag 0x%08lx\r\n",&DAT_23072bcc, + "tc_blfdt_dump.c",0xf7,iVar19 << 2,&DAT_23088e60,len); + break; + } + data = pfVar17 + 3; + len = fdt32_to_cpu(pfVar17[1]); + uVar4 = fdt32_to_cpu(pfVar17[2]); + iVar16 = (int)__s + uVar5 + uVar4; + if ((uVar6 < 0x10) && (7 < (int)len)) { + data = (fdt32_t *)((uint)((int)pfVar17 + 0x13) & 0xfffffff8); + } + printf("// %04x: string: %s\r\n",iVar16); + printf("// %04x: value\r\n",(fdt32_t *)((int)data - (int)__s)); + printf("%*s%s",iVar19 << 2,&DAT_23088e60,iVar16); + utilfdt_print_data((char *)data,len); + pfVar17 = (fdt32_t *)((int)data + len + 3 & 0xfffffffc); + printf(";\r\n"); + } + } + } + printf("dump successed\r\n"); + uVar12 = 0; + } + return uVar12; +} + + + +undefined4 tc_fdt_wifi_module(void) + +{ + int idx; + int parentoffset; + char *format; + int nodeoffset; + uint *puVar1; + TickType_t TVar2; + void *__src; + int iVar3; + undefined4 uVar4; + uint uVar5; + int iStack308; + undefined auStack304 [256]; + + iStack308 = 0; + parentoffset = fdt_subnode_offset(tc_wifi_dtb,0,"wifi"); + if (parentoffset < 1) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0x37; + format = "[%10u][%s: %s:%4d] wifi NULL.\r\n"; + } + else { + nodeoffset = fdt_subnode_offset(tc_wifi_dtb,parentoffset,"region"); + if (0 < nodeoffset) { + puVar1 = (uint *)fdt_getprop(tc_wifi_dtb,nodeoffset,"country_code",&iStack308); + if (puVar1 == (uint *)0x0) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0x42; + format = "[%10u][%s: %s:%4d] country_code NULL.\r\n"; + goto LAB_2302a1c6; + } + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar5 = *puVar1; + bl_printk("[%10u][%s: %s:%4d] value = %ld, lentmp = %d\r\n",TVar2,&DAT_2307f16c, + "tc_blfdt_wifi.c",0x40, + uVar5 << 0x18 | uVar5 >> 0x18 | (uVar5 >> 8 & 0xff) << 0x10 | + (uVar5 >> 0x10 & 0xff) << 8,iStack308); + } + nodeoffset = fdt_subnode_offset(tc_wifi_dtb,parentoffset,"mac"); + if (0 < nodeoffset) { + __src = fdt_getprop(tc_wifi_dtb,nodeoffset,"sta_mac_addr",&iStack308); + if (iStack308 != 6) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0x52; + format = "[%10u][%s: %s:%4d] sta_mac_addr NULL.\r\n"; + goto LAB_2302a1c6; + } + memcpy(auStack304,__src,6); + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] sta_mac :\r\n",TVar2,&DAT_2307f16c,"tc_blfdt_wifi.c",0x4f); + log_buf_out("tc_blfdt_wifi.c",0x50,auStack304,6,LOG_BUF_OUT_DATA_TYPE_HEX); + __src = fdt_getprop(tc_wifi_dtb,nodeoffset,"ap_mac_addr",&iStack308); + if (iStack308 == 6) { + memcpy(auStack304,__src,6); + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ap_mac :\r\n",TVar2,&DAT_2307f16c,"tc_blfdt_wifi.c",0x5c); + log_buf_out("tc_blfdt_wifi.c",0x5d,auStack304,6,LOG_BUF_OUT_DATA_TYPE_HEX); + } + } + nodeoffset = fdt_subnode_offset(tc_wifi_dtb,parentoffset,"ap"); + if (nodeoffset < 1) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0x98; + } + else { + iVar3 = fdt_stringlist_count(tc_wifi_dtb,nodeoffset,"ssid"); + if (0 < iVar3) { + idx = 0; + do { + format = fdt_stringlist_get(tc_wifi_dtb,nodeoffset,"ssid",idx,&iStack308); + if (0 < iStack308) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ap string[%d] = %s, lentmp = %d\r\n",TVar2,&DAT_2307f16c, + "tc_blfdt_wifi.c",0x6a,idx,format,iStack308); + } + idx = idx + 1; + } while (iVar3 != idx); + iVar3 = fdt_stringlist_count(tc_wifi_dtb,nodeoffset,"pwd"); + if (iVar3 < 1) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0x7d; + format = "[%10u][%s: %s:%4d] pwd NULL.\r\n"; + } + else { + idx = 0; + do { + format = fdt_stringlist_get(tc_wifi_dtb,nodeoffset,"pwd",idx,&iStack308); + if (0 < iStack308) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwd string[%d] = %s, lentmp = %d\r\n",TVar2, + &DAT_2307f16c,"tc_blfdt_wifi.c",0x79,idx,format,iStack308); + } + idx = idx + 1; + } while (iVar3 != idx); + puVar1 = (uint *)fdt_getprop(tc_wifi_dtb,nodeoffset,"ap_channel",&iStack308); + if (puVar1 == (uint *)0x0) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0x86; + format = "[%10u][%s: %s:%4d] ap_channel NULL.\r\n"; + } + else { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar5 = *puVar1; + bl_printk("[%10u][%s: %s:%4d] ap_channel = %ld\r\n",TVar2,&DAT_2307f16c, + "tc_blfdt_wifi.c",0x84, + uVar5 << 0x18 | uVar5 >> 0x18 | (uVar5 >> 8 & 0xff) << 0x10 | + (uVar5 >> 0x10 & 0xff) << 8); + iVar3 = fdt_stringlist_count(tc_wifi_dtb,nodeoffset,"auto_chan_detect"); + idx = 0; + if (iVar3 < 1) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0x94; + format = "[%10u][%s: %s:%4d] auto_chan_detect NULL.\r\n"; + } + else { + do { + format = fdt_stringlist_get(tc_wifi_dtb,nodeoffset,"auto_chan_detect",idx,&iStack308 + ); + if (0 < iStack308) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] auto_chan_detect string[%d] = %s, lentmp = %d\r\n", + TVar2,&DAT_2307f16c,"tc_blfdt_wifi.c",0x90,idx,format,iStack308); + } + idx = idx + 1; + } while (iVar3 != idx); + parentoffset = fdt_subnode_offset(tc_wifi_dtb,parentoffset,"brd_rf"); + if (parentoffset < 1) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0xdc; + format = "[%10u][%s: %s:%4d] brd_rf NULL.\r\n"; + } + else { + __src = fdt_getprop(tc_wifi_dtb,parentoffset,"xtal",&iStack308); + if (iStack308 == 0x14) { + memcpy(auStack304,__src,0x14); + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] xtal :\r\n",TVar2,&DAT_2307f16c,"tc_blfdt_wifi.c", + 0xa5); + log_buf_out("tc_blfdt_wifi.c",0xa6,auStack304,0x14,LOG_BUF_OUT_DATA_TYPE_HEX); + __src = fdt_getprop(tc_wifi_dtb,parentoffset,"pwr_table",&iStack308); + if (iStack308 != 0x100) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table NULL. lentmp = %d.\r\n",&DAT_23072bcc, + "tc_blfdt_wifi.c",0xb4,iStack308); + return 0xffffffff; + } + memcpy(auStack304,__src,0x100); + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table :\r\n",TVar2,&DAT_2307f16c, + "tc_blfdt_wifi.c",0xb1); + log_buf_out("tc_blfdt_wifi.c",0xb2,auStack304,0x100,LOG_BUF_OUT_DATA_TYPE_HEX); + __src = fdt_getprop(tc_wifi_dtb,parentoffset,"channel_div_table",&iStack308); + if (iStack308 == 0x3c) { + memcpy(auStack304,__src,0x3c); + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] channel_div_table :\r\n",TVar2,&DAT_2307f16c, + "tc_blfdt_wifi.c",0xbd); + log_buf_out("tc_blfdt_wifi.c",0xbe,auStack304,0x3c,LOG_BUF_OUT_DATA_TYPE_HEX); + __src = fdt_getprop(tc_wifi_dtb,parentoffset,"channel_cnt_table",&iStack308); + if (iStack308 == 0x38) { + memcpy(auStack304,__src,0x38); + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] channel_cnt_table :\r\n",TVar2,&DAT_2307f16c, + "tc_blfdt_wifi.c",0xc9); + log_buf_out("tc_blfdt_wifi.c",0xca,auStack304,0x38,LOG_BUF_OUT_DATA_TYPE_HEX); + __src = fdt_getprop(tc_wifi_dtb,parentoffset,"lo_fcal_div",&iStack308); + if (iStack308 == 4) { + memcpy(auStack304,__src,4); + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] lo_fcal_div :\r\n",TVar2,&DAT_2307f16c, + "tc_blfdt_wifi.c",0xd5); + log_buf_out("tc_blfdt_wifi.c",0xd6,auStack304,4,LOG_BUF_OUT_DATA_TYPE_HEX); + return 0; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0xd8; + format = "[%10u][%s: %s:%4d] lo_fcal_div NULL.\r\n"; + } + else { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0xcc; + format = "[%10u][%s: %s:%4d] channel_cnt_table NULL.\r\n"; + } + } + else { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0xc0; + format = "[%10u][%s: %s:%4d] channel_div_table NULL.\r\n"; + } + } + else { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0xa8; + format = "[%10u][%s: %s:%4d] xtal NULL."; + } + } + } + } + } + goto LAB_2302a1c6; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0x6e; + } + format = "[%10u][%s: %s:%4d] ap NULL.\r\n"; + } +LAB_2302a1c6: + bl_printk(format,&DAT_23072bcc,"tc_blfdt_wifi.c",uVar4); + return 0xffffffff; +} + + + +int tc_fdt_wifi(void) + +{ + int iVar1; + char *__format; + + iVar1 = tc_fdt_wifi_module(); + if (iVar1 == 0) { + __format = "fdt wifi module successed\r\n"; + } + else { + __format = "fdt wifi module failed\r\n"; + } + printf(__format); + return iVar1; +} + + + +void cmd_blog_info_dump(char *buf,int len,int argc,char **argv) + +{ + blog_info_t *pbVar1; + blog_info_t *pbVar2; + size_t __n; + int iVar3; + char *pcVar4; + byte *pbVar5; + byte **ppbVar6; + char local_b0 [4]; + char name_buf [128]; + + memset(local_b0,0,0x80); + bl_printk("blog code1 = %p - %p\r\n",&_fsymc_info_bloop,&_fsymf_info_bloopbloop_base); + bl_printk("blog code2 = %p - %p\r\n",&_fsymf_info_bloopbloop_base,&_bl_static_blogfile_code_end); + bl_printk("blog code3 = %p - %p\r\n",&_bl_static_blogfile_code_end,&_bl_static_blogfile_code_end); + pbVar1 = &_fsymc_info_bloop; + do { + if ((blog_info_t *)((int)&_fsymc_info_loopset.name + 3U) < pbVar1) { + return; + } + __n = strlen(pbVar1->name); + if (0x80 < __n) { + bl_printk("name too long.\r\n"); + return; + } + if (local_b0[0] == '\0') { +LAB_2302aada: + bl_printk("[%-48s] = [%d]\r\n",pbVar1->name,(uint)*pbVar1->level); + if ((local_b0[0] == '\0') || (iVar3 = strcmp(pbVar1->name,local_b0), iVar3 != 0)) { + pbVar2 = &_fsymf_info_bloopbloop_base; + strcpy(local_b0,pbVar1->name); + while (pbVar2 < (blog_info_t *)&_bl_static_blogfile_code_end) { + pcVar4 = strstr(pbVar2->name,pbVar1->name); + if (pcVar4 == pbVar2->name) { + ppbVar6 = (byte **)&_bl_static_blogfile_code_end; + bl_printk("[%-48s] = [%d]\r\n",pcVar4,(uint)*pbVar2->level); + while (ppbVar6 < &_bl_static_blogfile_code_end) { + pbVar5 = (byte *)strstr((char *)ppbVar6[1],pbVar2->name); + if (pbVar5 == ppbVar6[1]) { + bl_printk("[%-48s] = [%d]\r\n",pbVar5,(uint)**ppbVar6); + } + ppbVar6 = ppbVar6 + 2; + } + } + pbVar2 = pbVar2 + 1; + } + } + } + else { + iVar3 = strcmp(local_b0,pbVar1->name); + if (iVar3 != 0) { + __n = strlen(local_b0); + memset(local_b0,0,__n); + goto LAB_2302aada; + } + } + pbVar1 = pbVar1 + 1; + } while( true ); +} + + + +void cmd_blog_set_level(char *buf,int len,int argc,char **argv) + +{ + blog_info_t *pbVar1; + int iVar2; + char *format; + size_t sVar3; + int iVar4; + char *__s; + int iVar5; + blog_info_t *pbVar6; + blog_level_t bVar7; + int iVar8; + + if (argc != 3) { + bl_printk("arg error.\r\n"); + goto LAB_2302ab82; + } + iVar2 = strcmp(argv[1],"all"); + if (iVar2 == 0) { + bVar7 = BLOG_LEVEL_ALL; +LAB_2302ac30: + __s = argv[2]; + sVar3 = strlen(__s); + iVar5 = 0; + iVar2 = 0; + while (iVar2 < (int)sVar3) { + if (__s[iVar2] == '.') { + iVar5 = iVar5 + 1; + } + iVar2 = iVar2 + 1; + } + if (iVar5 == 0) { + pbVar1 = &_fsymf_info_bloopbloop_base; + pbVar6 = &_fsymc_info_bloop; + } + else { + if (iVar5 == 1) { + pbVar1 = (blog_info_t *)&_bl_static_blogfile_code_end; + pbVar6 = &_fsymf_info_bloopbloop_base; + } + else { + if (iVar5 != 2) { + __s = argv[2]; + format = "input name = %s not support.\r\n"; + goto LAB_2302ac28; + } + pbVar1 = (blog_info_t *)&_bl_static_blogfile_code_end; + pbVar6 = (blog_info_t *)&_bl_static_blogfile_code_end; + } + } + iVar2 = ((int)((int)pbVar1 - (int)pbVar6) >> 3) + -1; + iVar5 = 0; + while (__s = argv[2], iVar5 <= iVar2) { + iVar8 = iVar5 + iVar2 >> 1; + pbVar1 = pbVar6 + iVar8; + iVar4 = strcmp(pbVar1->name,__s); + if (iVar4 < 0) { + iVar5 = iVar8 + 1; + } + else { + if (iVar4 == 0) { + *pbVar1->level = bVar7; + bl_printk("set %s = %d\r\n",pbVar1->name,(uint)*pbVar1->level); + return; + } + iVar2 = iVar8 + -1; + } + } + format = "input name = %s not find.\r\n"; + } + else { + iVar2 = strcmp(argv[1],"debug"); + bVar7 = BLOG_LEVEL_DEBUG; + if (iVar2 == 0) goto LAB_2302ac30; + iVar2 = strcmp(argv[1],"info"); + bVar7 = BLOG_LEVEL_INFO; + if (iVar2 == 0) goto LAB_2302ac30; + iVar2 = strcmp(argv[1],"warn"); + bVar7 = BLOG_LEVEL_WARN; + if (iVar2 == 0) goto LAB_2302ac30; + iVar2 = strcmp(argv[1],"error"); + bVar7 = BLOG_LEVEL_ERROR; + if (iVar2 == 0) goto LAB_2302ac30; + iVar2 = strcmp(argv[1],"assert"); + bVar7 = BLOG_LEVEL_ASSERT; + if (iVar2 == 0) goto LAB_2302ac30; + iVar2 = strcmp(argv[1],"never"); + bVar7 = BLOG_LEVEL_NEVER; + if (iVar2 == 0) goto LAB_2302ac30; + __s = argv[1]; + format = "input level = %s not support.\r\n"; + } +LAB_2302ac28: + bl_printk(format,__s); +LAB_2302ab82: + bl_printk("set blog error.\r\n"); + return; +} + + + +void blog_init(void) + +{ + blog_level_t **ppbVar1; + undefined *puVar2; + blog_info_t *pbVar3; + undefined4 *puVar4; + + bl_printk("\r\nblog init set power on level %d, %d, %d.\r\n",2,2); + pbVar3 = &_fsymc_info_bloop; + while (pbVar3 < &_fsymf_info_bloopbloop_base) { + ppbVar1 = &pbVar3->level; + pbVar3 = pbVar3 + 1; + **ppbVar1 = BLOG_LEVEL_INFO; + } + pbVar3 = &_fsymf_info_bloopbloop_base; + while (pbVar3 < (blog_info_t *)&_bl_static_blogfile_code_end) { + ppbVar1 = &pbVar3->level; + pbVar3 = pbVar3 + 1; + **ppbVar1 = BLOG_LEVEL_INFO; + } + puVar4 = (undefined4 *)&_bl_static_blogfile_code_end; + while (puVar4 < &_bl_static_blogfile_code_end) { + puVar2 = (undefined *)*puVar4; + puVar4 = puVar4 + 2; + *puVar2 = 2; + } + return; +} + + + +int ota_dump_cmd(void) + +{ + _dump_partition(); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +void ota_tcp_cmd(char **argv) + +{ + int iVar1; + uint32_t uVar2; + uint8_t uVar3; + hostent *phVar4; + char *__s; + int s; + uchar *input; + undefined3 extraout_var; + int iVar5; + ssize_t sVar6; + uint addr; + int iVar7; + uint ilen; + int iVar8; + bl_mtd_handle_t local_150; + bl_mtd_handle_t handle; + uint32_t address; + uint32_t bin_size; + sockaddr_in dest; + uint8_t sha256_result [32]; + uint8_t sha256_img [32]; + char str [33]; + byte bStack206; + HALPartition_Entry_Config ptEntry; + iot_sha256_context ctx; + + phVar4 = lwip_gethostbyname(argv[1]); + if (phVar4 == (hostent *)0x0) { + __s = "gethostbyname Failed\r\n"; + } + else { + s = bl_mtd_open("FW",&local_150,1); + if (s == 0) { + s = lwip_socket(2,1,0); + if (s < 0) { + printf("Error in socket\r\n"); + } + else { + memset(&bin_size,0,0x10); + bin_size._1_1_ = '\x02'; + bin_size._2_2_ = lwip_htons(0xd05); + handle = (bl_mtd_handle_t)((ip4_addr_t *)((ip4_addr_t *)phVar4->h_addr_list)->addr)->addr; + dest._0_4_ = (ip4_addr_t)handle; + __s = ip4addr_ntoa((ip4_addr_t *)&handle); + input = (uchar *)pvPortMalloc(0x200); + uVar3 = hal_boot2_get_active_partition(); + printf("Starting OTA test. OTA bin addr is %p\r\n",input); + printf("[OTA] [TEST] activeID is %u\r\n",CONCAT31(extraout_var,uVar3)); + iVar5 = hal_boot2_get_active_entries(0,(HALPartition_Entry_Config *)(str + 0x20)); + if (iVar5 == 0) { + address = *(uint32_t *)(&ptEntry.type + ((uint)(bStack206 == 0) + 4) * 4); + iVar7 = *(int *)(ptEntry.name + (uint)(bStack206 == 0) * 4 + 5); + printf("Starting OTA test. OTA size is %lu\r\n"); + printf("[OTA] [TEST] activeIndex is %u, use OTA address=%08x\r\n",(uint)bStack206,iVar7); + printf("[OTA] [TEST] Erase flash with size %lu...",address); + bl_mtd_erase_all(local_150); + printf("Done\r\n"); + printf("Server ip Address : %s\r\n",__s); + iVar5 = lwip_connect(s,(sockaddr *)&bin_size,0x10); + if (iVar5 == 0) { + utils_sha256_init((iot_sha256_context *)&ptEntry.age); + utils_sha256_starts((iot_sha256_context *)&ptEntry.age); + memset(dest.sin_zero + 4,0,0x20); + iVar5 = 0; + uVar2 = 0; + addr = 0; + ilen = 0; +LAB_2302af8e: + while (sVar6 = lwip_read(s,input + ilen,0x200 - ilen), -1 < sVar6) { + uVar2 = uVar2 + sVar6; + if (sVar6 == 0) { + printf("[OTA] [TEST] seems ota file ends unexpectedly, already transfer %u\r\n", + uVar2); + goto LAB_2302afbc; + } + printf("total = %d, ret = %d\n\r",uVar2,sVar6); + ilen = ilen + sVar6; + if (iVar5 != 0) { + if (address != uVar2) goto code_r0x2302b164; + goto LAB_2302b180; + } + if (0x1ff < ilen) { + if (ilen != 0x200) { + printf("[OTA] [TCP] Assert for unexpected error %d\r\n",ilen); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + memcpy(sha256_img + 0x1c,input,0x10); + str[12] = '\0'; + puts("[OTA] [HEADER] ota header is "); + puts((char *)(sha256_img + 0x1c)); + puts("\r\n"); + memcpy(sha256_img + 0x1c,input + 0x10,4); + str[0] = '\0'; + puts("[OTA] [HEADER] file type is "); + puts((char *)(sha256_img + 0x1c)); + puts("\r\n"); + __s = strstr((char *)(sha256_img + 0x1c),"XZ"); + memcpy(&address,input + 0x14,4); + printf("[OTA] [HEADER] file length (exclude ota header) is %lu\r\n",address); + memcpy(sha256_img + 0x1c,input + 0x20,0x10); + str[12] = '\0'; + puts("[OTA] [HEADER] ver_hardware is "); + puts((char *)(sha256_img + 0x1c)); + puts("\r\n"); + memcpy(sha256_img + 0x1c,input + 0x30,0x10); + str[12] = '\0'; + puts("[OTA] [HEADER] ver_software is "); + puts((char *)(sha256_img + 0x1c)); + puts("\r\n"); + memcpy(sha256_img + 0x1c,input + 0x40,0x20); + str[28] = '\0'; + puts("[OTA] [HEADER] sha256 is "); + do { + iVar8 = iVar5 + 0x1c; + iVar5 = iVar5 + 1; + printf("%02X",(uint)sha256_img[iVar8]); + } while (iVar5 != 0x20); + puts("\r\n"); + memcpy(sha256_result + 0x1c,input + 0x40,0x20); + iVar5 = -0x2f0; + if (__s == (char *)0x0) { + iVar5 = -0x2ec; + } + uVar2 = uVar2 - 0x200; + printf("[OTA] [TCP] Update bin_size to %lu, file status %s\r\n",address, + iVar5 + 0x23081000); + ilen = 0; + iVar5 = 1; + } + } + printf("ret = %d, err = %d\n\r",sVar6,errno); +LAB_2302afbc: + lwip_close(s); + vPortFree(input); + utils_sha256_free((iot_sha256_context *)&ptEntry.age); + goto LAB_2302ae54; + } + printf("Error in connect\r\n"); + lwip_close(s); + } + else { + printf("PtTable_Get_Active_Entries fail\r\n"); + } + vPortFree(input); + } +LAB_2302ae54: + bl_mtd_close(local_150); + return; + } + __s = "Open Default FW partition failed\r\n"; + } + puts(__s); + return; +code_r0x2302b164: + if (0x1ff < ilen) { + if (ilen != 0x200) { + printf("[OTA] [TCP] Assert for unexpected error %d\r\n",ilen); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } +LAB_2302b180: + printf("Will Write %u to %08X from %p\r\n",ilen,iVar7 + addr,input); + utils_sha256_update((iot_sha256_context *)&ptEntry.age,input,ilen); + bl_mtd_write(local_150,addr,ilen,input); + addr = addr + ilen; + ilen = 0; + if (uVar2 == address) { + utils_sha256_finish((iot_sha256_context *)&ptEntry.age,(uint8_t *)(dest.sin_zero + 4)); + puts("\r\nCalculated SHA256 Checksum:"); + do { + iVar8 = ilen + 4; + ilen = ilen + 1; + printf("%02X",(uint)(byte)dest.sin_zero[iVar8]); + } while (ilen != 0x20); + puts("\r\nHeader SET SHA256 Checksum:"); + iVar8 = 0; + do { + iVar1 = iVar8 + 0x1c; + iVar8 = iVar8 + 1; + printf("%02X",(uint)sha256_result[iVar1]); + } while (iVar8 != 0x20); + puts("\r\n"); + iVar8 = memcmp(sha256_result + 0x1c,dest.sin_zero + 4,0x20); + if (iVar8 != 0) { + printf("[OTA] [TCP] SHA256 NOT Correct\r\n"); + goto LAB_2302afbc; + } + printf("[OTA] [TCP] prepare OTA partition info\r\n"); + ptEntry.maxLen[1] = address; + printf("[OTA] [TCP] Update PARTITION, partition len is %lu\r\n"); + hal_boot2_update_ptable((HALPartition_Entry_Config *)(str + 0x20)); + printf("[OTA] [TCP] Rebooting\r\n"); + hal_reboot(); + ilen = 0; + } + } + goto LAB_2302af8e; +} + + + +void ota_tcp_cmd(char *buf,int len,int argc,char **argv) + +{ + if (argc != 2) { + printf("Usage: %s IP\r\n",*argv); + return; + } + ota_tcp_cmd(argv); + return; +} + + + +int bl_sys_ota_cli_init(void) + +{ + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void cmd_sys_time_now(char *buf,int len,int argc,char **argv) + +{ + UDItype UVar1; + undefined4 local_30; + uint64_t epoch_ms; + undefined auStack36 [4]; + utils_time_date_t date; + + local_30 = 0; + epoch_ms._0_4_ = 0; + puts("BL SYS TIME time is\r\n"); + bl_sys_time_get((uint64_t *)&local_30); + UVar1 = __udivdi3(); + utils_time_date_from_epoch(auStack36,(int)UVar1); + return; +} + + + +int bl_sys_time_cli_init(void) + +{ + return 0; +} + + + +void bl_sys_time_update(undefined4 param_1,undefined4 param_2) + +{ + time_synced._0_4_ = xTaskGetTickCount(); + epoch_time._0_4_ = param_1; + epoch_time._4_4_ = param_2; + time_synced._4_4_ = 0; + return; +} + + + +int bl_sys_time_get(uint64_t *epoch) + +{ + TickType_t TVar1; + int iVar2; + uint uVar3; + uint uVar4; + + if (((uint)epoch_time | epoch_time._4_4_) == 0) { + iVar2 = -1; + } + else { + TVar1 = xTaskGetTickCount(); + uVar4 = TVar1 - (int)time_synced; + uVar3 = (uint)epoch_time + uVar4; + iVar2 = ((int)uVar4 >> 0x1f) + epoch_time._4_4_; + *(uint *)epoch = uVar3; + *(int *)((int)epoch + 4) = (uint)(uVar3 < uVar4) + iVar2; + iVar2 = 0; + } + return iVar2; +} + + + +int bl_sys_time_sync_state(uint32_t *xTicksToJump) + +{ + bool bVar1; + TickType_t TVar2; + TickType_t TVar3; + uint uVar4; + uint64_t uVar5; + + if (sync_init != 0) { + vTaskEnterCritical(); + TVar2 = xTaskGetTickCount(); + TVar3 = TVar2; + uVar5 = bl_rtc_get_timestamp_ms(); + vTaskExitCritical((int)uVar5); + uVar4 = TVar3 - init_tick_rtc; + bVar1 = TVar2 - init_tick_rtos < uVar4; + if (bVar1) { + *xTicksToJump = (init_tick_rtos - TVar2) + uVar4; + } + return (uint)bVar1; + } + return -1; +} + + + +cli_command * cli_command_get(int idx,int *is_static_cmd) + +{ + cli_st *pcVar1; + cli_command *pcVar2; + + pcVar1 = cli; + pcVar2 = (cli_command *)0xffffffff; + if (-1 < idx) { + pcVar2 = (cli_command *)0xffffffff; + if ((uint)idx < cli->num_static_cmds + 8) { + if ((uint)idx < cli->num_static_cmds) { + if (is_static_cmd != (int *)0x0) { + *is_static_cmd = 1; + } + pcVar2 = pcVar1->static_cmds + idx; + } + else { + if (is_static_cmd != (int *)0x0) { + *is_static_cmd = 0; + } + pcVar2 = pcVar1->dynamic_cmds[idx - pcVar1->num_static_cmds]; + } + } + } + return pcVar2; +} + + + +void exit_cmd(char *buf,int len,int argc,char **argv) + +{ + cliexit = 1; + return; +} + + + +int cb_idnoe(void *arg,inode_t *node) + +{ + uint8_t uVar1; + char *pcVar2; + undefined4 uVar3; + + if (*(int *)arg == 0) { + *(undefined4 *)arg = 1; + printf("\tSize\t\t\t\t\t Name\t\t\tFiletype\r\n"); + printf("----------------------------------------------------------------------------------\r\n") + ; + } + uVar1 = node->type; + uVar3 = 0x1c; + if ((1 < (byte)(uVar1 - 1)) && (uVar3 = 0x50, uVar1 != '\x03')) { + uVar3 = 0; + } + if (uVar1 == '\x01') { + pcVar2 = "Char Device"; + } + else { + if (uVar1 == '\x02') { + pcVar2 = "Block Device"; + } + else { + if (uVar1 == '\x03') { + pcVar2 = "File System"; + } + else { + pcVar2 = "Unknown"; + } + } + } + printf("%10d\t\t%30s\t\t\t%s\r\n",uVar3,node->i_name,pcVar2); + return 0; +} + + + +void ota_cmd(char *buf,int len,int argc,char **argv) + +{ + aos_task_new("LOCAL OTA",tftp_ota_thread,(void *)0x0,0x1000); + return; +} + + + +void tftp_ota_thread(void *arg) + +{ + aos_task_exit(0); + return; +} + + + +void cat_cmd(char *buf,int len,int argc,char **argv) + +{ + int fd; + ssize_t sVar1; + byte local_11 [4]; + char ch; + + if (argc != 2) { + printf("invalid parameter!\r\n"); + } + fd = aos_open(argv[1],0); + if (fd < 0) { + printf("open %s failed!\r\n",argv[1]); + } + else { + while (sVar1 = aos_read(fd,local_11,1), sVar1 == 1) { + printf("%c",(uint)local_11[0]); + } + printf("\r\n"); + aos_close(fd); + } + return; +} + + + +void hexdump_cmd(char *buf,int len,int argc,char **argv) + +{ + int fd; + void *local_18; + romfs_filebuf_t filebuf; + + if (argc != 2) { + printf("invalid parameter!\r\n"); + } + fd = aos_open(argv[1],0); + if (fd < 0) { + printf("open %s failed!\r\n",argv[1]); + } + else { + memset(&local_18,0,8); + aos_ioctl(fd,1,(ulong)&local_18); + printf("Found file %s. XIP Addr %p, len %lu\r\n",argv[1],local_18,filebuf.buf); + utils_hexdump(local_18,(uint)filebuf.buf); + aos_close(fd); + } + return; +} + + + +int aos_cli_init(int use_thread) + +{ + cli_st *pcVar1; + int iVar2; + + cli = (cli_st *)aos_malloc(0x244); + iVar2 = 0xc; + if (cli != (cli_st *)0x0) { + memset(cli,0,0x244); + pcVar1 = cli; + cli->static_cmds = cmds_user; + pcVar1->echo_disabled = 0; + pcVar1->num_static_cmds = 0x6c; + pcVar1->num_commands = 0x6c; + pcVar1->initialized = 1; + iVar2 = 0; + } + return iVar2; +} + + + +void * aos_cli_event_cb_read_get(void) + +{ + return console_cb_read; +} + + + +int cli_putstr(char *msg) + +{ + int iVar1; + size_t sVar2; + ssize_t sVar3; + + sVar2 = strlen(msg); + iVar1 = 0; + while ((iVar1 < (int)sVar2 && + (sVar3 = aos_write(fd_console,msg + iVar1,sVar2 - iVar1), -1 < sVar3))) { + iVar1 = iVar1 + sVar3; + } + return 0; +} + + + +void ps_cmd(char *buf,int len,int argc,char **argv) + +{ + char *__dest; + char *__dest_00; + size_t sVar1; + int iVar2; + + __dest_00 = (char *)pvPortMalloc(0x600); + if (__dest_00 != (char *)0x0) { + strcpy(__dest_00,"Task"); + sVar1 = strlen(__dest_00); + __dest = __dest_00 + sVar1; + sVar1 = strlen("Task"); + iVar2 = sVar1 - (int)__dest; + while ((int)(__dest + iVar2) < 0xd) { + *__dest = ' '; + __dest = __dest + 1; + *__dest = '\0'; + } + strcpy(__dest, + "State Priority Stack # Base\r\n********************************************************\r\n" + ); + sVar1 = strlen( + "State Priority Stack # Base\r\n********************************************************\r\n" + ); + vTaskList(__dest + sVar1); + cli_putstr(__dest_00); + vPortFree(__dest_00); + return; + } + return; +} + + + +int aos_cli_printf(char *msg,...) + +{ + size_t sVar1; + int iVar2; + undefined4 in_a1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list ap; + char message [256]; + undefined4 uStack28; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack28 = in_a1; + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + memset(&ap,0,0x100); + sVar1 = 0; + if (esc_tag_len != '\0') { + strcpy((char *)&ap,esc_tag); + sVar1 = strlen(esc_tag); + } + iVar2 = vsnprintf((char *)((int)&ap + sVar1),0x100 - sVar1,msg,&uStack28); + if (0 < iVar2) { + cli_putstr((char *)&ap); + } + return 0; +} + + + +int proc_onecmd(int argc,char **argv) + +{ + cli_st *pcVar1; + cli_st *pcVar2; + char *__s1; + cli_command *pcVar3; + int iVar4; + uint idx; + uint uVar5; + char *__n; + char *__s2; + + if (argc < 1) { + return 0; + } + if (cli->echo_disabled == 0) { + printf("\r\n"); + } + __n = (char *)0x0; + __s1 = strchr(*argv,0x2e); + __s2 = *argv; + if (__s1 != (char *)0x0) { + __n = __s1 + -(int)__s2; + } + idx = 0; + uVar5 = 0; + while( true ) { + if (cli->num_static_cmds + 8 <= idx) { + return 1; + } + if (cli->num_commands <= uVar5) break; + pcVar3 = cli_command_get(idx,(int *)0x0); + __s1 = pcVar3->name; + if (__s1 != (char *)0x0) { + if (__n == (char *)0x0) { + iVar4 = strcmp(__s1,__s2); + } + else { + iVar4 = strncmp(__s1,__s2,(size_t)__n); + } + pcVar1 = cli; + if (iVar4 == 0) { + __s1 = (char *)aos_malloc(0x200); + pcVar2 = cli; + pcVar1->outbuf = __s1; + if (pcVar2->outbuf == (char *)0x0) { + aos_cli_printf("Error! cli alloc mem fail!\r\n"); + return 1; + } + memset(pcVar2->outbuf,0,0x200); + (*pcVar3->function)(cli->outbuf,0x200,argc,argv); + aos_cli_printf("%s",cli->outbuf); + aos_free(cli->outbuf); + cli->outbuf = (char *)0x0; + return 0; + } + uVar5 = uVar5 + 1; + } + idx = idx + 1; + } + return 1; +} + + + +void ls_cmd(char *buf,int len,int argc,char **argv) + +{ + stat *st; + int iVar1; + aos_dir_t *dir; + aos_dirent_t *paVar2; + char *msg; + size_t __n; + size_t sVar3; + undefined4 uStack180; + int env; + char path_name [128]; + + uStack180 = 0; + st = (stat *)pvPortMalloc(0x58); + memset(stat,0,0x58); + memset(&env,0,0x80); + if (argc == 2) { + iVar1 = strcmp(argv[1],"/sdcard"); + if (iVar1 == 0) { + dir = aos_opendir("/sdcard"); + if (dir == (aos_dir_t *)0x0) { + msg = "can not open sdcard\r\n"; +LAB_2302b970: + printf(msg); + goto LAB_2302b94a; + } + printf("\tSize\t\t\t\t\t Name\t\t\tFiletype\r\n"); + printf( + "----------------------------------------------------------------------------------\r\n" + ); + while (paVar2 = aos_readdir(dir), paVar2 != (aos_dirent_t *)0x0) { + snprintf((char *)&env,0x7f,"/sdcard/%s",&paVar2->field_0x5); + iVar1 = aos_stat((char *)&env,st); + if (iVar1 == 0) { + iVar1 = 0x450; + if (-1 < (int)(st->st_mode << 0x11)) { + iVar1 = 0x46c; + } + printf("\r\nCalculated SHA256 Checksum:" + iVar1 + 0x18,st->st_size,&paVar2->field_0x5); + } + } + } + else { + msg = argv[1]; + __n = strlen("/romfs"); + iVar1 = memcmp(msg,"/romfs",__n); + if (iVar1 != 0) { + iVar1 = strcmp(argv[1],"/"); + if (iVar1 != 0) { + msg = "un-supported direcotry!\r\n"; + goto LAB_2302ba96; + } + goto LAB_2302ba7e; + } + dir = aos_opendir(argv[1]); + if (dir == (aos_dir_t *)0x0) { + msg = "can not open romfs\r\n"; + goto LAB_2302b970; + } + printf("\tSize\t\t\t\t\t Name\t\t\tFiletype\r\n"); + printf( + "----------------------------------------------------------------------------------\r\n" + ); + while (paVar2 = aos_readdir(dir), paVar2 != (aos_dirent_t *)0x0) { + memset(&env,0,0x80); + snprintf((char *)&env,0x7f,"%s",argv[1]); + __n = strlen((char *)&env); + if (*(char *)((int)&uStack180 + __n + 3) != '/') { + __n = strlen((char *)&env); + *(undefined *)((int)&env + __n) = 0x2f; + } + __n = strlen((char *)&env); + sVar3 = strlen((char *)&env); + snprintf((char *)((int)&env + __n),0x7f - sVar3,"%s",&paVar2->field_0x5); + iVar1 = aos_stat((char *)&env,st); + if (iVar1 == 0) { + iVar1 = 0x450; + if (-1 < (int)(st->st_mode << 0x11)) { + iVar1 = 0x46c; + } + printf("\r\nCalculated SHA256 Checksum:" + iVar1 + 0x18,st->st_size,&paVar2->field_0x5); + } + } + } + aos_closedir(dir); + } + else { + if (argc != 1) { + msg = "invalid parameter!\r\n"; +LAB_2302ba96: + aos_cli_printf(msg); + goto LAB_2302b94a; + } +LAB_2302ba7e: + inode_forearch_name(cb_idnoe,&uStack180); + } +LAB_2302b94a: + vPortFree(st); + return; +} + + + +void uptime_cmd(char *buf,int len,int argc,char **argv) + +{ + char *pcVar1; + char *pcVar2; + int iVar3; + int iVar4; + longlong lVar5; + DItype DVar6; + + lVar5 = aos_now_ms(); + aos_cli_printf("UP time in ms %llu\r\n",buf,len,(int)lVar5); + pcVar1 = buf; + iVar3 = len; + __divdi3(); + __moddi3(); + pcVar2 = buf; + iVar4 = len; + __divdi3(); + __moddi3(); + __divdi3(); + __divdi3(); + DVar6 = __moddi3(); + aos_cli_printf("UP time in %llu days, %llu hours, %llu minutes, %llu seconds\r\n",buf,len,pcVar2, + iVar4,pcVar1,iVar3,(int)DVar6); + return; +} + + + +void reset_cmd(char *buf,int len,int argc,char **argv) + +{ + aos_cli_printf("system reset\r\n"); + hal_sys_reset(); + return; +} + + + +void poweroff_cmd(char *buf,int len,int argc,char **argv) + +{ + aos_cli_printf("poweroff\r\n"); + hal_poweroff(); + return; +} + + + +void reboot_cmd(char *buf,int len,int argc,char **argv) + +{ + aos_cli_printf("reboot\r\n"); + hal_reboot(); + return; +} + + + +// WARNING: Variable defined which should be unmapped: desc + +void version_cmd(char *buf,int len,int argc,char **argv) + +{ + int iVar1; + size_t sVar2; + int iStack76; + int num; + uint addr [4]; + uint size [4]; + char desc [4] [6]; + + iStack76 = 4; + aos_cli_printf("kernel version :posix\r\n"); + aos_cli_printf("release_bl_iot_sdk_1.6.11-1-g66bb28da-dirty"); + aos_cli_printf("\r\n"); + iVar1 = bl_chip_memory_ram(&iStack76,(uint *)&num,addr + 3,(char (*) [6])(size + 3)); + if (iVar1 == 0) { + aos_cli_printf("Memory Configuration on %d banks:\r\n",iStack76); + while (iVar1 < iStack76) { + aos_cli_printf(" [%d]%6s %6u Kbytes @ %p\r\n",iVar1,(int)size + iVar1 * 6 + 0xc, + addr[iVar1 + 3] >> 10,(&num)[iVar1]); + iVar1 = iVar1 + 1; + } + } + sVar2 = xPortGetFreeHeapSize(); + aos_cli_printf("Heap left: %d Bytes\r\n",sVar2); + return; +} + + + +void devname_cmd(char *buf,int len,int argc,char **argv) + +{ + aos_cli_printf("device name: %s\r\n",&UNK_23081328); + return; +} + + + +void echo_cmd(char *buf,int len,int argc,char **argv) + +{ + int iVar1; + char *pcVar2; + + if (argc == 1) { + if (cli->echo_disabled == 0) { + pcVar2 = "Enabled"; + } + else { + pcVar2 = "Disabled"; + } + aos_cli_printf("Usage: echo on/off. Echo is currently %s\r\n",pcVar2); + return; + } + iVar1 = strcmp(argv[1],"on"); + if (iVar1 == 0) { + aos_cli_printf("Enable echo\r\n"); + cli->echo_disabled = 0; + } + else { + iVar1 = strcmp(argv[1],"off"); + if (iVar1 == 0) { + aos_cli_printf("Disable echo\r\n"); + cli->echo_disabled = 1; + } + } + return; +} + + + +void mmem_cmd(char *buf,int len,int argc,char **argv) + +{ + uint uVar1; + int iVar2; + uint uVar3; + + if (argc == 3) { + iVar2 = 4; +LAB_2302bd2e: + uVar1 = strtol(argv[2],(char **)0x0,0); + } + else { + if (argc == 4) { + iVar2 = strtol(argv[3],(char **)0x0,0); + goto LAB_2302bd2e; + } + if (argc != 2) goto LAB_2302bd4c; + uVar1 = 0; + iVar2 = 4; + } + len = strtol(argv[1],(char **)0x0,0); + if ((uint *)len != (uint *)0x0) { + if (iVar2 == 1) { + uVar3 = (uint)*(byte *)len; + *(byte *)len = (byte)uVar1; + uVar1 = (uint)*(byte *)len; + } + else { + if (iVar2 == 2) { + uVar3 = (uint)*(ushort *)len; + *(ushort *)len = (ushort)uVar1; + uVar1 = (uint)*(ushort *)len; + } + else { + uVar3 = *(uint *)len; + *(uint *)len = uVar1; + uVar1 = *(uint *)len; + } + } + aos_cli_printf("value on 0x%x change from 0x%x to 0x%x.\r\n",len,uVar3,uVar1); + return; + } +LAB_2302bd4c: + aos_cli_printf( + "m \r\naddr : address to modify\r\nvalue : new value (default is 0)\r\nwidth : width of unit, 1/2/4 (default is 4)\r\n" + ,len); + return; +} + + + +void pmem_cmd(char *buf,int len,int argc,char **argv) + +{ + ushort uVar1; + undefined4 *puVar2; + int iVar3; + undefined4 uVar4; + long lVar5; + uint uVar6; + char *pcStack52; + char *pos; + + pcStack52 = (char *)0x0; + if (argc == 3) { + lVar5 = 4; +LAB_2302be3e: + iVar3 = strtol(argv[2],(char **)0x0,0); + if (0x400 < iVar3) { + iVar3 = 0x400; + } + } + else { + if (argc == 4) { + lVar5 = strtol(argv[3],(char **)0x0,0); + goto LAB_2302be3e; + } + lVar5 = 4; + iVar3 = 0x10; + puVar2 = (undefined4 *)0x0; + if (argc != 2) goto LAB_2302be02; + } + puVar2 = (undefined4 *)strtol(argv[1],&pcStack52,0); +LAB_2302be02: + if ((pcStack52 == (char *)0x0) || (pcStack52 == argv[1])) { + aos_cli_printf( + "p \r\naddr : address to display\r\nnunits: number of units to display (default is 16)\r\nwidth : width of unit, 1/2/4 (default is 4)\r\n" + ); + } + else { + if (lVar5 == 1) { + uVar6 = 0; + while ((int)uVar6 < iVar3) { + if ((uVar6 & 0xf) == 0) { + aos_cli_printf("0x%08x:",(byte *)((int)puVar2 + uVar6)); + } + aos_cli_printf(" %02x",(uint)*(byte *)((int)puVar2 + uVar6)); + if ((uVar6 & 0xf) == 0xf) { + aos_cli_printf("\r\n"); + } + uVar6 = uVar6 + 1; + } + } + else { + if (lVar5 == 2) { + uVar6 = 0; + while ((int)uVar6 < iVar3) { + if ((uVar6 & 7) == 0) { + aos_cli_printf("0x%08x:",puVar2); + } + uVar1 = *(ushort *)puVar2; + puVar2 = (undefined4 *)((int)puVar2 + 2); + aos_cli_printf(" %04x",(uint)uVar1); + if ((uVar6 & 7) == 7) { + aos_cli_printf("\r\n"); + } + uVar6 = uVar6 + 1; + } + } + else { + uVar6 = 0; + while ((int)uVar6 < iVar3) { + if ((uVar6 & 3) == 0) { + aos_cli_printf("0x%08x:",puVar2); + } + uVar4 = *puVar2; + puVar2 = puVar2 + 1; + aos_cli_printf(" %08x",uVar4); + if ((uVar6 & 3) == 3) { + aos_cli_printf("\r\n"); + } + uVar6 = uVar6 + 1; + } + } + } + } + return; +} + + + +void help_cmd(char *buf,int len,int argc,char **argv) + +{ + cli_command *pcVar1; + uint idx; + char *pcVar2; + uint uVar3; + + aos_cli_printf("====Build-in Commands====\r\n"); + pcVar1 = built_ins; + aos_cli_printf("====Support %d cmds once, seperate by ; ====\r\n",4); + do { + if (pcVar1->name != (char *)0x0) { + pcVar2 = pcVar1->help; + if (pcVar1->help == (char *)0x0) { + pcVar2 = ""; + } + aos_cli_printf("%-25s: %s\r\n",pcVar2); + } + pcVar1 = pcVar1 + 1; + } while (pcVar1 != cmds_user); + aos_cli_printf("\r\n"); + aos_cli_printf("====User Commands====\r\n"); + uVar3 = 0x10; + idx = 0; + while ((idx < cli->num_static_cmds + 8 && (uVar3 < cli->num_commands))) { + pcVar1 = cli_command_get(idx,(int *)0x0); + if (((pcVar1 < built_ins) || ((cli_command *)((int)&built_ins[0xf].function + 3U) < pcVar1)) && + (pcVar1->name != (char *)0x0)) { + pcVar2 = pcVar1->help; + if (pcVar1->help == (char *)0x0) { + pcVar2 = ""; + } + aos_cli_printf("%-25s: %s\r\n",pcVar2); + uVar3 = uVar3 + 1; + } + idx = idx + 1; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int cli_getchar(char *inbuf) + +{ + int32_t iVar1; + uint uVar2; + uint32_t local_50; + uint32_t recv_size; + uart_dev_t uart_stdio; + + local_50 = 0; + memset(&recv_size,0,0x3c); + recv_size._0_1_ = '\0'; + iVar1 = hal_uart_recv_II((uart_dev_t *)&recv_size,inbuf,1,&local_50,0xffffffff); + if (iVar1 == 0) { + uVar2 = (uint)(local_50 == 1); + } + else { + uVar2 = 0; + } + return uVar2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void cli_main_input(char *buffer,int count) + +{ + byte bVar1; + char cVar2; + cli_st *pcVar3; + cli_st *pcVar4; + uint8_t uVar5; + anon_struct *paVar6; + undefined1 *argv; + size_t __n; + cli_command *pcVar7; + uint uVar8; + char *__s1; + char *__s; + anon_struct aVar9; + int iVar10; + byte *__src; + char *__s_00; + uint idx; + int iVar11; + size_t __n_00; + int iVar12; + uint uStack84; + anon_struct stat; + char c; + + pcVar3 = cli; + __s1 = cli->inbuf; + if (__s1 == (char *)0x0) { + __s1 = "inbuf_null\r\n"; +LAB_2302c170: + aos_cli_printf(__s1); + return; + } + iVar11 = 0; + uVar5 = esc_tag_len; +LAB_2302c092: + esc_tag_len = uVar5; + if (buffer == (char *)0x0) { + iVar12 = cli_getchar((char *)&stat); + if (iVar12 != 1) { + return; + } + } + else { + if (count <= iVar11) { + return; + } + __src = (byte *)(buffer + iVar11); + iVar11 = iVar11 + 1; + stat = (anon_struct)((uint)stat & 0xffffff00 | (uint)*__src); + } + pcVar4 = cli; + cVar2 = key1_4391; + if ((stat._0_1_ != '\n') && (stat._0_1_ != '\r')) { + uVar5 = esc_tag_len; + if (stat._0_1_ == '\x1b') { + esc_4390 = '\x01'; + key1_4391 = -1; + key2_4392 = -1; + } + else { + if (esc_4390 != '\0') { + if (key1_4391 < '\0') { + __s = (char *)(int)stat._0_1_; + key1_4391 = stat._0_1_; + if (__s == (char *)0x5b) goto LAB_2302c092; + __s1[pcVar3->bp] = '\x1b'; + idx = pcVar3->bp + 1; + pcVar3->bp = idx; + __s1[idx] = stat._0_1_; + pcVar3->bp = pcVar3->bp + 1; + if (cli->echo_disabled == 0) { + __s_00 = "\x1b%c"; +LAB_2302c1fa: + printf(__s_00,__s); + } + } + else { + if ((key2_4392 < '\0') && (key2_4392 = stat._0_1_, stat._0_1_ == 't')) { + esc_tag[0] = '\x1b'; + esc_tag[1] = key1_4391; + esc_tag_len = '\x02'; + } + idx = SEXT14(key2_4392); + if (((idx & 0xff) - 0x41 & 0xff) < 2) { + __s_00 = __s1; + if (idx == 0x41) { + iVar10 = cli->his_idx; + iVar12 = iVar10; + do { + iVar12 = (iVar12 + 0xff) % 0x100; + if (cli->history[iVar12] != '\0') { + if (iVar10 != iVar12) { + do { + iVar12 = (iVar12 + 0xff) % 0x100; + } while (cli->history[iVar12] != '\0'); + iVar12 = (iVar12 + 1) % 0x100; + } + break; + } + } while (iVar10 != iVar12); + cli->his_idx = iVar12; + while (pcVar4->history[iVar10] != '\0') { + *__s_00 = pcVar4->history[iVar10]; + iVar10 = (iVar10 + 1) % 0x100; + __s_00 = __s_00 + 1; + } + } + else { + iVar10 = cli->his_idx; + iVar12 = iVar10; + while (cli->history[iVar12] != '\0') { + iVar12 = (iVar12 + 1) % 0x100; + } + if (iVar10 != iVar12) { + do { + iVar12 = (iVar12 + 1) % 0x100; + } while (cli->history[iVar12] == '\0'); + } + cli->his_idx = iVar12; + while (pcVar4->history[iVar10] != '\0') { + *__s_00 = pcVar4->history[iVar10]; + iVar10 = (iVar10 + 1) % 0x100; + __s_00 = __s_00 + 1; + } + } + *__s_00 = '\0'; + printf("\r\n# %s",__s1); + __n = strlen(__s1); + pcVar3->bp = __n; + esc_tag[0] = '\0'; + esc_tag_len = '\0'; + } + else { + if (idx == 0x74) { + if (0x3f < esc_tag_len) { + esc_tag[0] = '\0'; + esc_tag_len = '\0'; + esc_4390 = '\0'; + printf("Error: esc_tag buffer overflow\r\n"); + uVar5 = esc_tag_len; + goto LAB_2302c092; + } + idx = (uint)esc_tag_len + 1 & 0xff; + esc_tag[(uint)esc_tag_len] = stat._0_1_; + pcVar4 = cli; + uVar5 = (uint8_t)idx; + if (stat._0_1_ != 'm') goto LAB_2302c092; + esc_tag[idx] = '\0'; + esc_tag_len = esc_tag_len + '\x02'; + if (pcVar4->echo_disabled == 0) { + __s = esc_tag; + __s_00 = "%s"; + goto LAB_2302c1fa; + } + } + else { + __s1[pcVar3->bp] = '\x1b'; + uVar8 = pcVar3->bp + 1; + pcVar3->bp = uVar8; + __s1[uVar8] = cVar2; + uVar8 = pcVar3->bp + 1; + pcVar3->bp = uVar8; + __s1[uVar8] = (char)(idx & 0xff); + pcVar3->bp = pcVar3->bp + 1; + if (cli->echo_disabled == 0) { + printf("\x1b%c%c"); + } + esc_tag[0] = '\0'; + esc_tag_len = '\0'; + } + } + } + esc_4390 = '\0'; + uVar5 = esc_tag_len; + goto LAB_2302c092; + } + __s1[pcVar3->bp] = stat._0_1_; + if ((stat._0_1_ == '\b') || (stat._0_1_ == '\x7f')) { + uVar5 = esc_tag_len; + if ((pcVar3->bp != 0) && + (pcVar3->bp = pcVar3->bp - 1, uVar5 = esc_tag_len, cli->echo_disabled == 0)) { + printf("%c %c",8,8); + uVar5 = esc_tag_len; + } + } + else { + if (stat._0_1_ == '\t') { + __s1[pcVar3->bp] = '\0'; + aos_cli_printf("\r\n"); + iVar12 = 0; + uVar8 = 0; + idx = 0; + __s_00 = (char *)0x0; + while ((idx < cli->num_static_cmds + 8 && (uVar8 < cli->num_commands))) { + pcVar7 = cli_command_get(idx,(int *)0x0); + __s = __s_00; + if (pcVar7->name != (char *)0x0) { + iVar10 = strncmp(__s1,pcVar7->name,pcVar3->bp); + if (iVar10 == 0) { + iVar12 = iVar12 + 1; + __s = pcVar7->name; + if (iVar12 != 1) { + if (iVar12 == 2) { + aos_cli_printf("%s %s ",__s_00); + __s = __s_00; + } + else { + aos_cli_printf("%s ",__s); + __s = __s_00; + } + } + } + uVar8 = uVar8 + 1; + } + idx = idx + 1; + __s_00 = __s; + } + if (iVar12 == 1) { + if ((__s_00 != (char *)0x0) && (__n = strlen(__s_00), __n < 0x100)) { + idx = pcVar3->bp; + memcpy(__s1 + idx,__s_00 + idx,__n - idx); + iVar12 = (__n - idx) + pcVar3->bp; + pcVar3->bp = iVar12 + 1; + __s1[iVar12] = ' '; + __s1[pcVar3->bp] = '\0'; + } + } + else { + if (1 < iVar12) { + aos_cli_printf("\r\n"); + } + } + aos_cli_printf("%s%s",&DAT_230812a4,__s1); + uVar5 = esc_tag_len; + } + else { + if (cli->echo_disabled == 0) { + printf("%c",(uint)stat & 0xff); + } + idx = pcVar3->bp + 1; + pcVar3->bp = idx; + uVar5 = esc_tag_len; + if (0xff < idx) { + aos_cli_printf("Error: input buffer overflow\r\n"); + aos_cli_printf("# "); + pcVar3->bp = 0; + return; + } + } + } + } + goto LAB_2302c092; + } + __s1[pcVar3->bp] = '\0'; + __s1 = pcVar4->inbuf; + pcVar3->bp = 0; + __n = strlen(__s1); + if (__n != 0) { + __s = cli->inbuf; + __n = strlen(__s); + pcVar3 = cli; + __n = __n + 1; + iVar11 = cli->his_cur; + __n_00 = 0x100 - iVar11; + cli->his_idx = iVar11; + __s_00 = pcVar3->history + iVar11; + iVar12 = iVar11 + __n + -1; + if ((int)__n_00 < (int)__n) { + iVar12 = iVar12 % 0x100; + cVar2 = pcVar3->history[iVar12]; + strncpy(__s_00,__s,__n_00); + __n = __n - __n_00; + __s = __s + __n_00; + __s_00 = cli->history; + } + else { + cVar2 = pcVar3->history[iVar11 + __n + -1]; + } + strncpy(__s_00,__s,__n); + pcVar3 = cli; + iVar11 = (iVar12 + 1) % 0x100; + cli->his_cur = iVar11; + if (cVar2 != '\0') { + while (iVar12 = (int)&pcVar3->initialized + iVar11, *(char *)(iVar12 + 0x144) != '\0') { + *(undefined *)(iVar12 + 0x144) = 0; + iVar11 = (iVar11 + 1) % 0x100; + } + } + } + stat = (anon_struct)0x0; + memset(argvall_4313,0,0x100); + memset(&stat,0,0x10); + memset(&uStack84,0,4); + iVar11 = 0; + paVar6 = &stat; + iVar12 = 0; + do { + __src = (byte *)(__s1 + iVar11); + bVar1 = *__src; + if (bVar1 != 0x20) { + if (0x20 < bVar1) { + if (bVar1 == 0x22) { + if (((iVar11 == 0) || (__s_00 = __s1 + iVar11 + -1, *__s_00 != '\\')) || + ((uStack84 & 1) == 0)) { + idx = uStack84 & 3; + if (idx != 1) { + if (idx == 2) goto LAB_2302c80a; + if (idx == 0) { + aVar9 = *paVar6; + uStack84 = uStack84 & 0xfffffffc | 3; + *(int *)paVar6 = (int)aVar9 + 1; + *(char **)(argvall_4313 + (iVar12 * 0x10 + (int)aVar9) * 4) = __s1 + iVar11 + 1; + } + else { + if (idx == 3) { + uStack84._0_1_ = (byte)uStack84 & 0xfc; + goto LAB_2302c7d0; + } + } + } + } + else { +LAB_2302c76c: + iVar11 = iVar11 + -1; + __n = strlen((char *)__src); + memcpy(__s_00,__src,__n + 1); + } + } + else { + if (bVar1 != 0x3b) goto LAB_2302c13a; + if (((iVar11 != 0) && (__s_00 = __s1 + iVar11 + -1, *__s_00 == '\\')) && + ((uStack84 & 1) != 0)) goto LAB_2302c76c; + if ((uStack84 & 2) != 0) goto LAB_2302c80a; + if ((uStack84 & 3) == 1) { + uStack84 = uStack84 & 0xfffffffe; + *__src = 0; + if ((*paVar6 != (anon_struct)0x0) && (iVar12 = iVar12 + 1, iVar12 < 4)) { + paVar6 = &stat + iVar12; + } + } + } + goto LAB_2302c6c4; + } + if (bVar1 != 0) { +LAB_2302c13a: + if ((uStack84 & 1) == 0) { + aVar9 = *paVar6; + uStack84 = uStack84 | 1; + *(int *)paVar6 = (int)aVar9 + 1; + *(byte **)(argvall_4313 + (iVar12 * 0x10 + (int)aVar9) * 4) = __src; + } + goto LAB_2302c6c4; + } + if ((uStack84 & 2) == 0) { + uStack84 = uStack84 | 4; + goto LAB_2302c6c4; + } +LAB_2302c80a: + aos_cli_printf("syntax error\r\n"); + goto LAB_2302c72c; + } + if (((iVar11 != 0) && (__s_00 = __s1 + iVar11 + -1, *__s_00 == '\\')) && ((uStack84 & 1) != 0)) + goto LAB_2302c76c; + if ((uStack84 & 3) == 1) { + uStack84._0_1_ = (byte)uStack84 & 0xfe; +LAB_2302c7d0: + uStack84 = uStack84 & 0xffffff00 | (uint)(byte)uStack84; + *__src = 0; + } +LAB_2302c6c4: + } while ((((uStack84 & 4) == 0) && (iVar11 = iVar11 + 1, iVar11 < 0x100)) && + ((iVar12 < 4 && ((int)*paVar6 < 0x10)))); + if ((uStack84 & 2) != 0) goto LAB_2302c80a; + paVar6 = &stat; + argv = argvall_4313; + idx = 0; + iVar11 = 0; + do { + iVar11 = iVar11 + 1; + uVar8 = proc_onecmd((int)*paVar6,(char **)argv); + idx = idx | uVar8; + if (iVar12 < iVar11) break; + paVar6 = paVar6 + 1; + argv = (undefined1 *)((char **)argv + 0x10); + } while (iVar11 != 4); + if (idx == 1) { + if (__s1 != (char *)0x0) { + aos_cli_printf("command \'%s\' not found\r\n",__s1); + } + } + else { + if (idx == 2) goto LAB_2302c80a; + } +LAB_2302c72c: + aos_cli_printf("\r\n"); + esc_tag[0] = '\0'; + esc_tag_len = '\0'; + __s1 = "# "; + goto LAB_2302c170; +} + + + +void console_cb_read(int fd,void *param) + +{ + ssize_t count; + char acStack32 [4]; + char buffer [16]; + + count = aos_read(fd,acStack32,0x10); + if (0 < count) { + if (count < 0x11) { + fd_console = fd; + cli_main_input(acStack32,count); + } + else { + printf("-------------BUG from aos_read for ret\r\n"); + } + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: qry +// WARNING: Could not reconcile some variable overlaps + +void get_dns_request(void *arg,udp_pcb *upcb,pbuf *p,ip_addr_t *addr,u16_t port) + +{ + u16_t uVar1; + int iVar2; + pbuf *buf; + uint uVar3; + char *dataptr; + char *pcVar4; + uint uVar5; + uint local_50; + int len; + dns_ans_hdr hdr; + dns_ans_hdr hdr_1; + dns_ans_ans qry; + + *(udp_pcb **)((int)arg + 0x108) = upcb; + *(ip_addr_t **)((int)arg + 0x10c) = addr; + *(u16_t *)((int)arg + 0x110) = port; + if (0xb < p->tot_len) { + pbuf_copy_partial(p,&len,0xc,0); + uVar1 = lwip_htons((u16_t)len); + *(u16_t *)((int)arg + 0x100) = uVar1; + uVar1 = lwip_htons(hdr.id); + *(u16_t *)((int)arg + 0x102) = uVar1; + local_50 = (uint)p->tot_len; + if (0xff < p->tot_len) { + local_50 = 0xff; + } + pbuf_copy_partial(p,arg,(u16_t)local_50,0xc); + iVar2 = utils_dns_domain_get((uint8_t *)arg,(uint8_t *)arg,(int *)&local_50); + if (iVar2 == 0) { + if ((0 < (int)local_50) && (*(char *)((int)arg + (local_50 - 1)) == '.')) { + local_50 = local_50 - 1; + } + *(undefined *)(local_50 + (int)arg) = 0; + } + } + pbuf_free(p); + buf = pbuf_alloc(PBUF_TRANSPORT,0x200,PBUF_RAM); + if (buf != (pbuf *)0x0) { + memset(&hdr.numauthrr,0,0xc); + pcVar4 = (char *)((int)arg + -1); + uVar3 = 0xc; + hdr.numauthrr = lwip_htons(*(u16_t *)((int)arg + 0x100)); + hdr.numextrarr = lwip_htons(0x8180); + hdr_1.id = lwip_htons(1); + hdr_1.flag = lwip_htons(1); + hdr_1.numquestions = lwip_htons(0); + hdr_1.numanswers = lwip_htons(0); + pbuf_take(buf,&hdr.numauthrr,0xc); + do { + dataptr = pcVar4 + 1; + uVar5 = 0; + pcVar4 = dataptr; + while ((*pcVar4 != '.' && (*pcVar4 != '\0'))) { + uVar5 = uVar5 + 1 & 0xff; + pcVar4 = pcVar4 + 1; + } + pbuf_put_at(buf,(u16_t)uVar3,(u8_t)uVar5); + pbuf_take_at(buf,dataptr,(u16_t)((uint)((int)(pcVar4 + -(int)dataptr) * 0x10000) >> 0x10), + (u16_t)((uVar3 + 1) * 0x10000 >> 0x10)); + uVar5 = uVar3 + uVar5 & 0xffff; + uVar3 = uVar5 + 1 & 0xffff; + } while (*pcVar4 != '\0'); + pbuf_put_at(buf,(u16_t)((uVar5 + 1) * 0x10000 >> 0x10),'\0'); + hdr_1.numauthrr = lwip_htons(1); + hdr_1.numextrarr = lwip_htons(1); + lwip_htons(0xc00c); + lwip_htons(1); + lwip_htons(1); + lwip_htons(0); + lwip_htonl(0x3c0004); + lwip_htonl(0xc0a8a901); + pbuf_take_at(buf,&hdr_1.numauthrr,0x14,(u16_t)((uVar5 + 2) * 0x10000 >> 0x10)); + pbuf_realloc(buf,(u16_t)((uVar5 + 0x16) * 0x10000 >> 0x10)); + udp_sendto(*(udp_pcb **)((int)arg + 0x108),buf,*(ip_addr_t **)((int)arg + 0x10c), + *(u16_t *)((int)arg + 0x110)); + pbuf_free(buf); + } + return; +} + + + +void dns_server_init(void) + +{ + err_t eVar1; + udp_pcb *pcb; + undefined3 extraout_var; + void *__s; + + pcb = udp_new(); + if (pcb == (udp_pcb *)0x0) { + return; + } + eVar1 = udp_bind(pcb,&ip_addr_any,0x35); + if ((CONCAT31(extraout_var,eVar1) == 0) && (__s = pvPortMalloc(0x114), __s != (void *)0x0)) { + memset(__s,0,4); + udp_recv(pcb,get_dns_request,__s); + return; + } + udp_remove(pcb); + return; +} + + + +EfErrCode easyflash_init(void) + +{ + EfErrCode EVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + char *format; + size_t local_18; + size_t default_env_set_size; + ef_env *default_env_set; + + local_18 = 0; + EVar1 = ef_port_init((ef_env **)&default_env_set_size,&local_18); + if ((CONCAT31(extraout_var,EVar1) == 0) && + (EVar1 = ef_env_init((ef_env *)default_env_set_size,local_18), + CONCAT31(extraout_var_00,EVar1) == 0)) { + format = "EasyFlash V%s is initialize success.\r\n"; + } + else { + format = "EasyFlash V%s is initialize fail.\r\n"; + } + ef_log_info(format,&UNK_23081918); + ef_log_info("You can get the latest version on https://github.com/armink/EasyFlash .\r\n"); + return EVar1; +} + + + +size_t get_status(uint8_t *status_table,size_t status_num) + +{ + size_t sVar1; + size_t sVar2; + + sVar2 = status_num - 1; + do { + sVar1 = sVar2; + sVar2 = sVar1 - 1; + if (sVar2 == 0xffffffff) { + return sVar1; + } + } while (status_table[sVar2] != '\0'); + return sVar1; +} + + + +void update_sector_cache(uint32_t sec_addr,uint32_t empty_addr) + +{ + sector_cache_node *psVar1; + int iVar2; + int iVar3; + uint32_t uVar4; + + psVar1 = sector_cache_table; + iVar2 = 4; + iVar3 = 0; + do { + uVar4 = psVar1->addr; + if ((sec_addr < empty_addr) && (empty_addr < sec_addr + 0x1000)) { + if (sec_addr == uVar4) { + psVar1 = sector_cache_table + iVar3; + goto LAB_2302cb84; + } + if ((uVar4 == 0xffffffff) && (iVar2 == 4)) { + iVar2 = iVar3; + } + } + else { + if (sec_addr == uVar4) { + sector_cache_table[iVar3].addr = 0xffffffff; + return; + } + } + iVar3 = iVar3 + 1; + psVar1 = psVar1 + 1; + } while (iVar3 != 4); + if (iVar2 != 4) { + psVar1 = sector_cache_table + iVar2; + psVar1->addr = sec_addr; +LAB_2302cb84: + psVar1->empty_addr = empty_addr; + } + return; +} + + + +uint32_t get_next_sector_addr(sector_meta_data_t pre_sec) + +{ + uint uVar1; + int iVar2; + + uVar1 = env_start_addr; + if (pre_sec->addr != 0xffffffff) { + if (pre_sec->combined == 0xffffffff) { + iVar2 = 0x1000; + } + else { + iVar2 = pre_sec->combined << 0xc; + } + uVar1 = iVar2 + pre_sec->addr; + if (env_start_addr + 0x8000 <= uVar1) { + return 0xffffffff; + } + } + return uVar1; +} + + + +_Bool gc_check_cb(sector_meta_data_t sector,void *arg1,void *arg2) + +{ + if (sector->check_ok != false) { + *(int *)arg1 = *(int *)arg1 + 1; + } + return false; +} + + + +void update_env_cache(char *name,size_t name_len,uint32_t addr) + +{ + uint32_t uVar1; + int iVar2; + env_cache_node *peVar3; + int iVar4; + int iVar5; + ushort uVar6; + + uVar1 = ef_calc_crc32(0,name,name_len); + peVar3 = env_cache_table; + uVar6 = 0xffff; + iVar5 = 0x10; + iVar2 = 0x10; + iVar4 = 0; + do { + if (addr == 0xffffffff) { + if ((uint)peVar3->name_crc == uVar1 >> 0x10) { + peVar3 = env_cache_table + iVar4; + env_cache_table[iVar4].addr = 0xffffffff; + goto LAB_2302cc82; + } + } + else { + if ((uint)peVar3->name_crc == uVar1 >> 0x10) { + env_cache_table[iVar4].addr = addr; + return; + } + if (peVar3->addr == 0xffffffff) { + if (iVar2 == 0x10) { + iVar2 = iVar4; + } + } + else { + if (peVar3->active != 0) { + peVar3->active = peVar3->active - 1; + } + if (peVar3->active < uVar6) { + iVar5 = iVar4; + uVar6 = peVar3->active; + } + } + } + iVar4 = iVar4 + 1; + peVar3 = peVar3 + 1; + } while (iVar4 != 0x10); + if ((iVar2 != 0x10) || (iVar2 = iVar5, iVar5 != 0x10)) { + peVar3 = env_cache_table + iVar2; + env_cache_table[iVar2].addr = addr; + peVar3->name_crc = (uint16_t)(uVar1 >> 0x10); +LAB_2302cc82: + peVar3->active = 0; + } + return; +} + + + +_Bool find_env_cb(env_node_obj_t env,void *arg1,void *arg2) + +{ + _Bool _Var1; + size_t sVar2; + int iVar3; + + sVar2 = strlen((char *)arg1); + if (((((uint)env->name_len == sVar2) && (_Var1 = env->crc_is_ok, _Var1 != false)) && + (env->status == ENV_WRITE)) && + (iVar3 = strncmp(env->name,(char *)arg1,(uint)env->name_len), iVar3 == 0)) { + *(undefined *)arg2 = 1; + } + else { + _Var1 = false; + } + return _Var1; +} + + + +_Bool sector_statistics_cb(sector_meta_data_t sector,void *arg1,void *arg2) + +{ + sector_store_status_t sVar1; + + if (sector->check_ok != false) { + sVar1 = (sector->status).store; + if (sVar1 == SECTOR_STORE_EMPTY) { + *(int *)arg1 = *(int *)arg1 + 1; + } + else { + if (sVar1 == SECTOR_STORE_USING) { + *(int *)arg2 = *(int *)arg2 + 1; + } + } + } + return false; +} + + + +_Bool alloc_env_cb(sector_meta_data_t sector,void *arg1,void *arg2) + +{ + sector_dirty_status_t sVar1; + _Bool _Var2; + + _Var2 = sector->check_ok; + if (_Var2 != false) { + if ((*(uint *)arg1 < sector->remain) && + ((sVar1 = (sector->status).dirty, sVar1 == SECTOR_DIRTY_FALSE || + ((sVar1 == SECTOR_DIRTY_TRUE && (gc_request == false)))))) { + *(uint32_t *)arg2 = sector->empty_env; + } + else { + _Var2 = false; + } + } + return _Var2; +} + + + +EfErrCode write_status(uint32_t addr,uint8_t *status_table,size_t status_num,size_t status_index) + +{ + EfErrCode EVar1; + + if (status_num <= status_index) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x111, + "(%s) has assert failed at %s.\r\n","status_index < status_num","write_status"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + if (status_table == (uint8_t *)0x0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x112, + "(%s) has assert failed at %s.\r\n","status_table","write_status"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + memset(status_table,0xff,status_num * 8 - 1 >> 3); + status_table[status_index - 1] = 0; + EVar1 = ef_port_write(addr + (status_index - 1),(uint32_t *)(status_table + (status_index - 1)),1) + ; + return EVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +EfErrCode read_env(env_node_obj_t env) + +{ + char "read_env" [9]; + uint uVar1; + uint32_t crc; + size_t size; + uint uVar2; + uint32_t uStack92; + env_hdr_data env_hdr; + uint8_t buf [32]; + + ef_port_read((env->addr).start,&uStack92,0x1c); + size = get_status((uint8_t *)&uStack92,6); + env->status = (env_status_t)(size & 0xff); + env->len = env_hdr.magic; + uVar2 = env_hdr.magic - 0x14; + if (uVar2 < 0x7fed) { + if (env_hdr.magic - 0xfed < 0x7013) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x223 + ,"(%s) has assert failed at %s.\r\n",0x23076768,"read_env"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + uVar1 = 0; + crc = 0; + while (uVar1 < uVar2) { + size = 0x20; + if (uVar2 <= uVar1 + 0x20) { + size = uVar2 - uVar1; + } + ef_port_read((env->addr).start + 0x14 + uVar1,&env_hdr.value_len,size); + crc = ef_calc_crc32(crc,&env_hdr.value_len,size); + uVar1 = uVar1 + size; + } + if (env_hdr.len == crc) { + crc = (env->addr).start + 0x1c; + env->crc_is_ok = true; + ef_port_read(crc,(uint32_t *)env->name,(uint)(byte)env_hdr.crc32); + (env->addr).value = crc + (byte)env_hdr.crc32; + env->value_len = env_hdr._20_4_; + env->name_len = (byte)env_hdr.crc32; + return EF_NO_ERR; + } + } + else { + env->len = 0x1c; + if ((size & 0xff) != 5) { + env->status = ENV_ERR_HDR; + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x21c + ,"Error: The ENV @0x%08X length has an error.\r\n",(env->addr).start); + write_status((env->addr).start,(uint8_t *)&uStack92,6,5); + } + } + env->crc_is_ok = false; + return EF_READ_ERR; +} + + + +// WARNING: Variable defined which should be unmapped: status_table + +EfErrCode update_sec_status(sector_meta_data_t sector,size_t new_env_len,_Bool *is_full) + +{ + sector_store_status_t sVar1; + EfErrCode EVar2; + uint8_t auStack20 [4]; + uint8_t status_table [3]; + + sVar1 = (sector->status).store; + if (sVar1 == SECTOR_STORE_EMPTY) { + EVar2 = write_status(sector->addr,auStack20,4,2); + } + else { + EVar2 = EF_NO_ERR; + if (sVar1 == SECTOR_STORE_USING) { + if ((sector->remain < 0x5c) || (sector->remain - new_env_len < 0x5c)) { + EVar2 = write_status(sector->addr,auStack20,4,3); + update_sector_cache(sector->addr,sector->addr + 0x1000); + if (is_full != (_Bool *)0x0) { + *is_full = true; + } + } + else { + if (is_full != (_Bool *)0x0) { + *is_full = false; + } + } + } + } + return EVar2; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +EfErrCode format_sector(uint32_t addr) + +{ + EfErrCode EVar1; + undefined3 extraout_var; + undefined uStack36; + undefined uStack33; + sector_hdr_data sec_hdr; + + if ((addr & 0xfff) != 0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x3b5, + "(%s) has assert failed at %s.\r\n","addr % SECTOR_SIZE == 0","format_sector"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + EVar1 = ef_port_erase(addr,0x1000); + if (CONCAT31(extraout_var,EVar1) == 0) { + memset(&uStack36,0xff,0x14); + memset(&uStack36,0xff,3); + uStack36 = 0; + memset(&uStack36 + 3,0xff,3); + sec_hdr._4_4_ = 0x30344645; + uStack33 = 0; + sec_hdr.magic = 0xffffffff; + sec_hdr.combined = 0xffffffff; + EVar1 = ef_port_write(addr,&uStack36,0x14); + update_sector_cache(addr,addr + 0x1000); + } + return EVar1; +} + + + +_Bool check_sec_hdr_cb(sector_meta_data_t sector,void *arg1,void *arg2) + +{ + if (sector->check_ok == false) { + ef_log_info("Warning: Sector header check failed. Format this sector (0x%08x).\r\n",sector->addr + ); + *(int *)arg1 = *(int *)arg1 + 1; + format_sector(sector->addr); + return false; + } + return false; +} + + + +_Bool print_env_cb(env_node_obj_t env,void *arg1,void *arg2) + +{ + _Bool _Var1; + uint uVar2; + uint uVar3; + size_t sVar4; + size_t size; + int iVar5; + _Bool _Var6; + uint32_t local_50; + uint8_t buf [32]; + + _Var1 = env->crc_is_ok; + if ((_Var1 != false) && (*(uint32_t *)arg1 = *(int *)arg1 + env->len, env->status == ENV_WRITE)) { + ef_print("%.*s=",(uint)env->name_len,env->name); + if (env->value_len < 0xf8c) { + iVar5 = 2; + _Var6 = false; + while( true ) { + uVar2 = 0; + while (uVar3 = env->value_len, uVar2 < uVar3) { + size = 0x20; + if (uVar3 <= uVar2 + 0x20) { + size = uVar3 - uVar2; + } + ef_port_read((env->addr).value + uVar2,&local_50,size); + sVar4 = 0; + if (_Var6 == false) { + while (size != sVar4) { + if (0x5e < (uint)*(byte *)((int)&local_50 + sVar4) - 0x20) goto LAB_2302d108; + sVar4 = sVar4 + 1; + } + } + else { + ef_print("%.*s",size,&local_50); + } + uVar2 = uVar2 + size; + } + if (iVar5 == 1) break; + iVar5 = 1; + _Var6 = _Var1; + } + } + else { +LAB_2302d108: + ef_print("blob @0x%08X %dbytes",(env->addr).value,env->value_len); + } + ef_print("\r\n"); + } + return false; +} + + + +// WARNING: Variable defined which should be unmapped: buf + +uint32_t get_next_env_addr(sector_meta_data_t sector,env_node_obj_t pre_env) + +{ + uint uVar1; + uint32_t uVar2; + sector_cache_node *psVar3; + uint addr; + int iVar4; + uint32_t *puVar5; + uint32_t uVar6; + uint32_t local_40; + uint8_t buf [32]; + + if ((sector->status).store != SECTOR_STORE_EMPTY) { + addr = (pre_env->addr).start; + uVar6 = sector->addr; + if (addr == 0xffffffff) { + return uVar6 + 0x14; + } + if (addr <= uVar6 + 0x1000) { + uVar1 = addr + 1; + if (pre_env->crc_is_ok != false) { + uVar1 = pre_env->len + addr; + } + psVar3 = sector_cache_table; + iVar4 = 0; + do { + if ((uVar1 & 0xfffff000) == psVar3->addr) { + if (uVar1 == sector_cache_table[iVar4].empty_addr) goto LAB_2302d1b4; + break; + } + iVar4 = iVar4 + 1; + psVar3 = psVar3 + 1; + } while (iVar4 != 4); + addr = uVar1; + while (addr < uVar6 + 0xfec) { + ef_port_read(addr,&local_40,0x20); + uVar2 = addr - 8; + puVar5 = &local_40; + do { + if (uVar6 + 0xfe4 == uVar2) break; + if ((*puVar5 == 0x3034564b) && (uVar1 <= uVar2)) goto LAB_2302d1b6; + uVar2 = uVar2 + 1; + puVar5 = (uint32_t *)((int)puVar5 + 1); + } while (addr + 0x14 != uVar2); + addr = addr + 0x1c; + } +LAB_2302d1b4: + uVar2 = 0xffffffff; +LAB_2302d1b6: + if ((sector->addr + 0x1000 < uVar2) || (pre_env->len == 0)) { + uVar2 = 0xffffffff; + } + return uVar2; + } + } + return 0xffffffff; +} + + + +// WARNING: Could not reconcile some variable overlaps + +EfErrCode read_sector_meta_data(uint32_t addr,sector_meta_data_t sector,_Bool traversal) + +{ + char cVar1; + EfErrCode EVar2; + uint uVar3; + size_t size; + undefined3 in_register_00002031; + sector_cache_node *psVar4; + int iVar5; + uint32_t uVar6; + uint32_t uVar7; + size_t sVar8; + uint addr_00; + char cVar9; + uint32_t uVar10; + undefined4 uStack188; + sector_hdr_data sec_hdr; + uint8_t buf [32]; + env_node_obj env_meta; + + if ((addr & 0xfff) != 0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x24a, + "(%s) has assert failed at %s.\r\n","addr % SECTOR_SIZE == 0", + "read_sector_meta_data"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + ef_port_read(addr,&uStack188,0x14); + sector->addr = addr; + sector->magic = sec_hdr._4_4_; + if (sec_hdr._4_4_ == 0x30344645) { + sector->combined = sec_hdr.magic; + sector->check_ok = true; + size = get_status((uint8_t *)&uStack188,4); + uVar3 = size & 0xff; + EVar2 = (EfErrCode)uVar3; + (sector->status).store = EVar2; + size = get_status((uint8_t *)((int)&uStack188 + 3),4); + (sector->status).dirty = (sector_dirty_status_t)size; + if (CONCAT31(in_register_00002031,traversal) != 0) { + sector->remain = 0; + sector->empty_env = addr + 0x14; + if (uVar3 == 1) { + sector->remain = 0xfec; + } + else { + if (uVar3 == 2) { + psVar4 = sector_cache_table; + iVar5 = 0; + do { + if (addr == psVar4->addr) { + uVar6 = sector_cache_table[iVar5].empty_addr; + sector->empty_env = uVar6; + sector->remain = (addr + 0x1000) - uVar6; + goto LAB_2302d302; + } + iVar5 = iVar5 + 1; + psVar4 = psVar4 + 1; + } while (iVar5 != 4); + sector->remain = 0xfec; + do { + uVar6 = get_next_env_addr(sector,(env_node_obj_t)(buf + 0x1c)); + if (uVar6 == 0xffffffff) { + EVar2 = EF_NO_ERR; +LAB_2302d3a0: + uVar7 = sector->addr; + uVar6 = sector->empty_env; + uVar3 = uVar7 + 0x1000; + cVar9 = '\0'; + uVar10 = uVar6; + while (addr_00 = uVar10, addr_00 < uVar3) { + uVar10 = addr_00 + 0x20; + size = 0x20; + if (uVar3 <= uVar10) { + size = (uVar7 + 0x1020) - uVar10; + } + ef_port_read(addr_00,&sec_hdr.reserved,size); + sVar8 = 0; + while (size != sVar8) { + cVar1 = *(char *)((int)&sec_hdr.reserved + sVar8); + if ((cVar9 != -1) && (cVar1 == -1)) { + uVar6 = addr_00 + sVar8; + } + sVar8 = sVar8 + 1; + cVar9 = cVar1; + } + } + if (cVar9 != -1) { + uVar6 = uVar3; + } + if (sector->empty_env != uVar6) { + sector->empty_env = uVar6; + sector->remain = (sector->addr + 0x1000) - uVar6; + } + update_sector_cache(sector->addr,sector->empty_env); + return EVar2; + } + read_env((env_node_obj_t)(buf + 0x1c)); + if ((buf[29] == '\0') && ((buf[28] & 0xfb) != 1)) { + ef_log_info("Error: The ENV (@0x%08X) CRC32 check failed!\r\n",uVar6); + sector->remain = 0; + goto LAB_2302d3a0; + } + sector->empty_env = sector->empty_env + env_meta.magic; + sector->remain = sector->remain - env_meta.magic; + } while( true ); + } + } + } +LAB_2302d302: + EVar2 = EF_NO_ERR; + } + else { + sector->check_ok = false; + sector->combined = 0xffffffff; + EVar2 = EF_ENV_INIT_FAILED; + } + return EVar2; +} + + + +void sector_iterator(sector_meta_data_t sector,sector_store_status_t status,void *arg1,void *arg2, + anon_subr__Bool_sector_meta_data_t_void_ptr_void_ptr *callback, + _Bool traversal_env) + +{ + _Bool _Var1; + uint32_t addr; + undefined3 extraout_var; + undefined3 in_register_0000202d; + undefined3 in_register_0000203d; + + sector->addr = 0xffffffff; + do { + do { + addr = get_next_sector_addr(sector); + if (addr == 0xffffffff) { + return; + } + read_sector_meta_data(addr,sector,false); + } while ((CONCAT31(in_register_0000202d,status) != 0) && + ((uint)(sector->status).store != CONCAT31(in_register_0000202d,status))); + if (CONCAT31(in_register_0000203d,traversal_env) != 0) { + read_sector_meta_data(addr,sector,true); + } + _Var1 = (*callback)(sector,arg1,arg2); + } while (CONCAT31(extraout_var,_Var1) == 0); + return; +} + + + +// WARNING: Variable defined which should be unmapped: using_sector + +uint32_t alloc_env(sector_meta_data_t sector,size_t env_size) + +{ + size_t asStack36 [2]; + uint32_t local_1c; + uint32_t empty_env; + size_t empty_sector; + size_t using_sector; + + local_1c = 0xffffffff; + empty_env = 0; + empty_sector = 0; + asStack36[0] = env_size; + sector_iterator(sector,SECTOR_STORE_UNUSED,&empty_env,&empty_sector,sector_statistics_cb,false); + if (empty_sector != 0) { + sector_iterator(sector,SECTOR_STORE_USING,asStack36,&local_1c,alloc_env_cb,true); + } + if ((empty_env != 0) && (local_1c == 0xffffffff)) { + if ((empty_env < 2) && (gc_request == false)) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x42d + ,"Trigger a GC check after alloc ENV failed.\r\n"); + gc_request = true; + } + else { + sector_iterator(sector,SECTOR_STORE_EMPTY,asStack36,&local_1c,alloc_env_cb,true); + } + } + return local_1c; +} + + + +void gc_collect(void) + +{ + uint uStack44; + size_t empty_sec; + sector_meta_data sector; + + uStack44 = 0; + sector_iterator((sector_meta_data_t)&empty_sec,SECTOR_STORE_EMPTY,&uStack44,(void *)0x0, + gc_check_cb,false); + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x4fa, + "The remain empty sector is %d, GC threshold is %d.\r\n",uStack44,1); + if (uStack44 < 2) { + sector_iterator((sector_meta_data_t)&empty_sec,SECTOR_STORE_UNUSED,(void *)0x0,(void *)0x0,do_gc + ,false); + } + gc_request = false; + return; +} + + + +uint32_t new_env(sector_meta_data_t sector,size_t env_size) + +{ + uint32_t uVar1; + + uVar1 = alloc_env(sector,env_size); + if ((uVar1 == 0xffffffff) && (gc_request != false)) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x4b6, + "Warning: Alloc an ENV (size %d) failed when new ENV. Now will GC then retry.\r\n", + env_size); + gc_collect(); + uVar1 = alloc_env(sector,env_size); + } + return uVar1; +} + + + +_Bool check_and_recovery_gc_cb(sector_meta_data_t sector,void *arg1,void *arg2) + +{ + if ((sector->check_ok != false) && ((sector->status).dirty == SECTOR_DIRTY_GC)) { + gc_request = true; + gc_collect(); + return false; + } + return false; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void env_iterator(env_node_obj_t env,void *arg1,void *arg2, + anon_subr__Bool_env_node_obj_t_void_ptr_void_ptr *callback) + +{ + EfErrCode EVar1; + _Bool _Var2; + uint32_t addr; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined uStack56; + sector_store_status_t sStack55; + sector_meta_data sector; + + sector._0_4_ = 0xffffffff; + do { + do { + addr = get_next_sector_addr((sector_meta_data_t)&uStack56); + if (addr == 0xffffffff) { + return; + } + EVar1 = read_sector_meta_data(addr,(sector_meta_data_t)&uStack56,false); + } while ((CONCAT31(extraout_var,EVar1) != 0) || (1 < (byte)(sStack55 + ~SECTOR_STORE_EMPTY))); + (env->addr).start = 0xffffffff; + while( true ) { + addr = get_next_env_addr((sector_meta_data_t)&uStack56,env); + (env->addr).start = addr; + if (addr == 0xffffffff) break; + read_env(env); + _Var2 = (*callback)(env,arg1,arg2); + if (CONCAT31(extraout_var_00,_Var2) != 0) { + return; + } + } + } while( true ); +} + + + +_Bool find_env(char *key,env_node_obj_t env) + +{ + char cVar1; + int iVar2; + size_t size; + uint32_t uVar3; + int iVar4; + uint16_t uVar5; + env_cache_node *peVar6; + char local_70; + char saved_name [64]; + + size = strlen(key); + uVar3 = ef_calc_crc32(0,key,size); + peVar6 = env_cache_table; + iVar2 = 0; + do { + if ((peVar6->addr != 0xffffffff) && ((uint)peVar6->name_crc == uVar3 >> 0x10)) { + ef_port_read(peVar6->addr + 0x1c,&local_70,0x40); + iVar4 = strncmp(key,(char *)&local_70,size); + if (iVar4 == 0) { + (env->addr).start = env_cache_table[iVar2].addr; + uVar5 = 0xffff; + if (env_cache_table[iVar2].active < 0xffef) { + uVar5 = env_cache_table[iVar2].active + 0x10; + } + env_cache_table[iVar2].active = uVar5; + read_env(env); + return true; + } + } + iVar2 = iVar2 + 1; + peVar6 = peVar6 + 1; + } while (iVar2 != 0x10); + local_70 = '\0'; + env_iterator(env,key,&local_70,find_env_cb); + cVar1 = local_70; + if (local_70 != '\0') { + update_env_cache(key,size,(env->addr).start); + } + return (_Bool)cVar1; +} + + + +EfErrCode del_env(char *key,env_node_obj_t old_env,_Bool complete_del) + +{ + _Bool last_is_complete_del; + int iVar1; + _Bool _Var2; + EfErrCode EVar3; + undefined3 extraout_var; + uint32_t addr; + undefined3 extraout_var_00; + size_t sVar4; + undefined3 extraout_var_01; + size_t name_len; + undefined3 in_register_00002031; + uint32_t uStack128; + uint8_t status_table [5]; + env_node_obj env; + + if (old_env == (env_node_obj_t)0x0) { + _Var2 = find_env(key,(env_node_obj_t)(status_table + 4)); + if (CONCAT31(extraout_var,_Var2) == 0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x447 + ,"Not found \'%s\' in ENV.\r\n",key); + return EF_ENV_NAME_ERR; + } + old_env = (env_node_obj_t)(status_table + 4); + } + addr = (old_env->addr).start; + if (CONCAT31(in_register_00002031,complete_del) == 0) { + EVar3 = write_status(addr,(uint8_t *)&uStack128,6,3); + iVar1 = CONCAT31(extraout_var_00,EVar3); + last_is_complete_del = true; + } + else { + EVar3 = write_status(addr,(uint8_t *)&uStack128,6,4); + iVar1 = CONCAT31(extraout_var_01,EVar3); + if ((last_is_complete_del == false) && (iVar1 == 0)) { + if (key == (char *)0x0) { + name_len = (size_t)old_env->name_len; + key = old_env->name; + } + else { + name_len = strlen(key); + } + update_env_cache(key,name_len,0xffffffff); + } + last_is_complete_del = false; + } + EVar3 = (EfErrCode)iVar1; + if (iVar1 == 0) { + addr = ((old_env->addr).start & 0xfffff000) + 3; + ef_port_read(addr,&uStack128,3); + sVar4 = get_status((uint8_t *)&uStack128,4); + if (sVar4 == 1) { + EVar3 = write_status(addr,(uint8_t *)&uStack128,4,2); + } + } + return EVar3; +} + + + +EfErrCode move_env(env_node_obj_t env) + +{ + EfErrCode EVar1; + uint32_t addr; + uint uVar2; + size_t new_env_len; + uint uVar3; + char *__src; + char cStack229; + undefined auStack228 [3]; + _Bool find_ok; + sector_meta_data sector; + uint8_t status_table [5]; + undefined auStack136 [4]; + env_node_obj env_bak; + + if (env->status == ENV_WRITE) { + del_env((char *)0x0,env,false); + } + addr = alloc_env((sector_meta_data_t)auStack228,env->len); + if (addr == 0xffffffff) { + return EF_ENV_FULL; + } + __src = env->name; + if (in_recovery_check != false) { + memset(§or.empty_env,0,0x41); + strncpy((char *)§or.empty_env,__src,(uint)env->name_len); + cStack229 = '\0'; + env_iterator((env_node_obj_t)auStack136,§or.empty_env,&cStack229,find_env_cb); + EVar1 = EF_NO_ERR; + if (cStack229 != '\0') goto __exit; + } + new_env_len = env->len; + update_sec_status((sector_meta_data_t)auStack228,new_env_len,(_Bool *)0x0); + write_status(addr,(uint8_t *)§or.empty_env,6,1); + uVar3 = new_env_len - 8; + uVar2 = 0; + EVar1 = EF_NO_ERR; + while (uVar2 < uVar3) { + new_env_len = 0x20; + if (uVar3 <= uVar2 + 0x20) { + new_env_len = uVar3 - uVar2; + } + ef_port_read((env->addr).start + 8 + uVar2,(uint32_t *)auStack136,new_env_len); + EVar1 = ef_port_write(addr + 8 + uVar2,(uint32_t *)auStack136,new_env_len); + uVar2 = uVar2 + new_env_len; + } + write_status(addr,(uint8_t *)§or.empty_env,6,2); + update_sector_cache(addr & 0xfffff000,env->value_len + 0x1c + (uint)env->name_len + addr); + update_env_cache(__src,(uint)env->name_len,addr); + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x4a6, + "Moved the ENV (%.*s) from 0x%08X to 0x%08X.\r\n",(uint)env->name_len,__src, + (env->addr).start,addr); +__exit: + del_env((char *)0x0,env,true); + return EVar1; +} + + + +_Bool check_and_recovery_env_cb(env_node_obj_t env,void *arg1,void *arg2) + +{ + _Bool _Var1; + EfErrCode EVar2; + undefined3 extraout_var; + uint8_t auStack24 [4]; + uint8_t status_table [5]; + + _Var1 = env->crc_is_ok; + if ((_Var1 == false) || (env->status != ENV_PRE_DELETE)) { + _Var1 = false; + if (env->status == ENV_PRE_WRITE) { + write_status((env->addr).start,auStack24,6,5); + _Var1 = true; + } + } + else { + ef_log_info("Found an ENV (%.*s) which has changed value failed. Now will recovery it.\r\n", + (uint)env->name_len,env->name); + EVar2 = move_env(env); + if (CONCAT31(extraout_var,EVar2) == 0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x6d5 + ,"Recovery the ENV successful.\r\n"); + _Var1 = false; + } + else { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x6d7 + , + "Warning: Moved an ENV (size %d) failed when recovery. Now will GC then retry.\r\n" + ,env->len); + } + } + return _Var1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +_Bool do_gc(sector_meta_data_t sector,void *arg1,void *arg2) + +{ + EfErrCode EVar1; + undefined3 extraout_var; + uint8_t auStack124 [4]; + uint8_t status_table [3]; + env_node_obj env; + + if ((sector->check_ok != false) && ((byte)((sector->status).dirty + ~SECTOR_DIRTY_FALSE) < 2)) { + write_status(sector->addr + 3,auStack124,4,3); + env.name._60_4_ = 0xffffffff; + while( true ) { + env.name._60_4_ = get_next_env_addr(sector,(env_node_obj_t)status_table); + if (env.name._60_4_ == 0xffffffff) break; + read_env((env_node_obj_t)status_table); + if ((((_Bool)status_table[1] != false) && ((byte)(status_table[0] + ~ENV_PRE_WRITE) < 2)) && + (EVar1 = move_env((env_node_obj_t)status_table), CONCAT31(extraout_var,EVar1) != 0)) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c", + 0x4e1,"Error: Moved the ENV (%.*s) for GC failed.\r\n",(uint)status_table[2], + &env.value_len); + } + } + format_sector(sector->addr); + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x4e6, + "Collect a sector @0x%08X\r\n",sector->addr); + return false; + } + return false; +} + + + +// WARNING: Could not reconcile some variable overlaps + +EfErrCode create_env_blob(sector_meta_data_t sector,char *key,void *value,size_t len) + +{ + size_t size; + uint size_00; + uint32_t addr; + EfErrCode EVar1; + size_t sVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + undefined auStack64 [3]; + _Bool _Stack61; + uint8_t align_data [1]; + _Bool is_full; + env_hdr_data env_hdr; + + addr = sector->empty_env; + _Stack61 = false; + sVar2 = strlen(key); + if (sVar2 < 0x41) { + memset(align_data,0xff,0x1c); + env_hdr._4_4_ = 0x3034564b; + sVar2 = strlen(key); + env_hdr.crc32._0_1_ = (byte)sVar2; + env_hdr.magic = len + 0x1c + (sVar2 & 0xff); + env_hdr._20_4_ = len; + if (env_hdr.magic < 0xfed) { + if ((addr == 0xffffffff) && (addr = new_env(sector,env_hdr.magic), addr == 0xffffffff)) { + return EF_ENV_FULL; + } + EVar1 = update_sec_status(sector,env_hdr.magic,&_Stack61); + if (CONCAT31(extraout_var,EVar1) == 0) { + env_hdr.len = ef_calc_crc32(0,&env_hdr.crc32,8); + env_hdr.len = ef_calc_crc32(env_hdr.len,key,(uint)(byte)env_hdr.crc32); + env_hdr.len = ef_calc_crc32(env_hdr.len,value,env_hdr._20_4_); + EVar1 = write_status(addr,align_data,6,1); + if ((CONCAT31(extraout_var_00,EVar1) == 0) && + (EVar1 = ef_port_write(addr + 8,(uint32_t *)(env_hdr.status_table + 4),0x14), + CONCAT31(extraout_var_01,EVar1) == 0)) { + size_00 = (uint)(byte)env_hdr.crc32; + memset(auStack64,0xff,1); + EVar1 = ef_port_write(addr + 0x1c,(uint32_t *)key,size_00); + if (_Stack61 == false) { + update_sector_cache(sector->addr, + env_hdr._20_4_ + 0x1c + (uint)(byte)env_hdr.crc32 + addr); + } + update_env_cache(key,(uint)(byte)env_hdr.crc32,addr); + size = env_hdr._20_4_; + if (CONCAT31(extraout_var_02,EVar1) == 0) { + size_00 = (uint)(byte)env_hdr.crc32; + memset(auStack64,0xff,1); + EVar1 = ef_port_write(size_00 + 0x1c + addr,(uint32_t *)value,size); + if (((CONCAT31(extraout_var_03,EVar1) == 0) && + (EVar1 = write_status(addr,align_data,6,2), CONCAT31(extraout_var_04,EVar1) == 0)) + && (_Stack61 != false)) { + ef_log_debug( + "/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c" + ,0x562,"Trigger a GC check after created ENV.\r\n"); + gc_request = true; + } + } + } + } + } + else { + ef_log_info("Error: The ENV size is too big\r\n"); + EVar1 = EF_ENV_FULL; + } + } + else { + ef_log_info("Error: The ENV name length is more than %d\r\n",0x40); + EVar1 = EF_ENV_NAME_ERR; + } + return EVar1; +} + + + +size_t ef_get_env_blob(char *key,void *value_buf,size_t buf_len,size_t *saved_value_len) + +{ + size_t sVar1; + _Bool _Var2; + TickType_t TVar3; + char *format; + size_t sVar4; + undefined3 extraout_var; + undefined4 uVar5; + undefined auStack120 [4]; + env_node_obj env; + + if (init_ok == false) { + ef_log_info("ENV isn\'t initialize OK.\r\n"); + sVar1 = 0; + } + else { + if ((key == (char *)0x0) || (value_buf == (void *)0x0)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar5 = 0x34c; + format = "[%10u][%s: %s:%4d] key = %p, value_buf = %p\r\n"; + } + else { + sVar4 = strlen(key); + if (sVar4 < 0x41) { + ef_port_env_lock(); + _Var2 = find_env(key,(env_node_obj_t)auStack120); + sVar1 = 0; + if (CONCAT31(extraout_var,_Var2) != 0) { + if (saved_value_len != (size_t *)0x0) { + *saved_value_len = env.len; + } + if (env.len < buf_len) { + buf_len = env.len; + } + ef_port_read(env.addr.start,(uint32_t *)value_buf,buf_len); + sVar1 = buf_len; + } + ef_port_env_unlock(); + return sVar1; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + key = (char *)strlen(key); + value_buf = (void *)0x40; + uVar5 = 0x351; + format = "[%10u][%s: %s:%4d] key err. %d > %d\r\n"; + } + bl_printk(format,TVar3,&DAT_23081ce8,&UNK_23081cdc,uVar5,key,value_buf); + sVar1 = 8; + } + return sVar1; +} + + + +EfErrCode ef_del_env(char *key) + +{ + EfErrCode EVar1; + TickType_t TVar2; + size_t sVar3; + EfErrCode result; + + if (init_ok == false) { + ef_log_info("Error: ENV isn\'t initialize OK.\r\n"); + EVar1 = EF_ENV_INIT_FAILED; + } + else { + if ((key == (char *)0x0) || (sVar3 = strlen(key), 0x40 < sVar3)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] key = %p\r\n",TVar2,&DAT_23081ce8,&UNK_23081cdc,0x57d,key); + EVar1 = EF_NO_ERR; + } + else { + ef_port_env_lock(); + EVar1 = del_env(key,(env_node_obj_t)0x0,true); + ef_port_env_unlock(); + } + } + return EVar1; +} + + + +EfErrCode ef_set_env_blob(char *key,void *value_buf,size_t buf_len) + +{ + _Bool _Var1; + EfErrCode EVar2; + TickType_t TVar3; + char *format; + size_t sVar4; + uint32_t uVar5; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined4 uVar6; + + if (init_ok == false) { + ef_log_info("ENV isn\'t initialize OK.\r\n"); + return EF_ENV_INIT_FAILED; + } + if ((key == (char *)0x0) || (value_buf == (void *)0x0)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar6 = 0x5d4; + format = "[%10u][%s: %s:%4d] key = %p, value_buf = %p\r\n"; + } + else { + sVar4 = strlen(key); + if (sVar4 < 0x41) { + if (buf_len < 0xf8d) { + ef_port_env_lock(); + sVar4 = strlen(key); + uVar5 = new_env((sector_meta_data_t)sector_3152,buf_len + 0x1c + sVar4); + EVar2 = EF_ENV_FULL; + if (uVar5 != 0xffffffff) { + _Var1 = find_env(key,(env_node_obj_t)env_3151); + if ((CONCAT31(extraout_var,_Var1) == 0) || + (EVar2 = del_env(key,(env_node_obj_t)env_3151,false), + CONCAT31(extraout_var_01,EVar2) == 0)) { + EVar2 = create_env_blob((sector_meta_data_t)sector_3152,key,value_buf,buf_len); + if ((CONCAT31(extraout_var,_Var1) != 0) && (CONCAT31(extraout_var_00,EVar2) == 0)) { + EVar2 = del_env(key,(env_node_obj_t)env_3151,true); + } + } + if (gc_request != false) { + gc_collect(); + } + } + ef_port_env_unlock(); + return EVar2; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + value_buf = (void *)0xf8c; + uVar6 = 0x5de; + format = "[%10u][%s: %s:%4d] buf_len err. %d > %d\r\n"; + key = (char *)buf_len; + } + else { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + key = (char *)strlen(key); + value_buf = (void *)0x40; + uVar6 = 0x5d9; + format = "[%10u][%s: %s:%4d] key err. %d > %d\r\n"; + } + } + bl_printk(format,TVar3,&DAT_23081ce8,&UNK_23081cdc,uVar6,key,value_buf); + return EF_ENV_ARG_ERR; +} + + + +EfErrCode ef_set_env(char *key,char *value) + +{ + EfErrCode EVar1; + size_t buf_len; + + buf_len = strlen(value); + EVar1 = ef_set_env_blob(key,value,buf_len); + return EVar1; +} + + + +EfErrCode ef_save_env(void) + +{ + return EF_NO_ERR; +} + + + +EfErrCode ef_env_set_default(void) + +{ + uint uVar1; + uint32_t addr; + EfErrCode EVar2; + undefined3 extraout_var; + size_t len; + ef_env *peVar3; + undefined auStack56 [4]; + sector_meta_data sector; + + if (default_env_set == (ef_env *)0x0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x621, + "(%s) has assert failed at %s.\r\n","default_env_set","ef_env_set_default"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + if (default_env_set_size == 0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x622, + "(%s) has assert failed at %s.\r\n","default_env_set_size","ef_env_set_default"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + ef_port_env_lock(); + addr = env_start_addr; + while (addr < env_start_addr + 0x8000) { + EVar2 = format_sector(addr); + if (CONCAT31(extraout_var,EVar2) != 0) goto __exit; + addr = addr + 0x1000; + } + uVar1 = 0; + while (uVar1 < default_env_set_size) { + len = default_env_set[uVar1].value_len; + if (len == 0) { + len = strlen((char *)default_env_set[uVar1].value); + } + sector.remain = 0xffffffff; + peVar3 = default_env_set + uVar1; + uVar1 = uVar1 + 1; + create_env_blob((sector_meta_data_t)auStack56,peVar3->key,peVar3->value,len); + } + EVar2 = EF_NO_ERR; +__exit: + ef_port_env_unlock(); + return EVar2; +} + + + +void ef_print_env(void) + +{ + int local_6c; + size_t using_size; + env_node_obj env; + + local_6c = 0; + if (init_ok == false) { + ef_log_info("ENV isn\'t initialize OK.\r\n"); + } + else { + ef_port_env_lock(); + env_iterator((env_node_obj_t)&using_size,&local_6c,(void *)0x0,print_env_cb); + ef_print("\r\nmode: next generation\r\n"); + ef_print("size: %lu/%lu bytes.\r\n",local_6c + 0x8c,0x7000); + ef_port_env_unlock(); + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: env + +EfErrCode ef_load_env(void) + +{ + int iStack132; + size_t check_failed_count; + sector_meta_data sector; + env_node_obj env; + + in_recovery_check = true; + iStack132 = 0; + sector_iterator((sector_meta_data_t)&check_failed_count,SECTOR_STORE_UNUSED,&iStack132,(void *)0x0 + ,check_sec_hdr_cb,false); + if (iStack132 == 8) { + ef_log_info("Warning: All sector header check failed. Set it to default.\r\n"); + ef_env_set_default(); + } + ef_port_env_lock(); + sector_iterator((sector_meta_data_t)&check_failed_count,SECTOR_STORE_UNUSED,(void *)0x0, + (void *)0x0,check_and_recovery_gc_cb,false); + while( true ) { + env_iterator((env_node_obj_t)§or.empty_env,(void *)0x0,(void *)0x0,check_and_recovery_env_cb + ); + if (gc_request == false) break; + gc_collect(); + } + in_recovery_check = false; + ef_port_env_unlock(); + return EF_NO_ERR; +} + + + +EfErrCode ef_env_init(ef_env *default_env,size_t default_env_size) + +{ + char "ef_env_init" [12]; + EfErrCode EVar1; + undefined3 extraout_var; + env_cache_node *peVar2; + + if (default_env == (ef_env *)0x0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x71e, + "(%s) has assert failed at %s.\r\n","default_env","ef_env_init"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + EVar1 = EF_NO_ERR; + if (init_ok == false) { + sector_cache_table[0].addr = 0xffffffff; + sector_cache_table[1].addr = 0xffffffff; + sector_cache_table[2].addr = 0xffffffff; + sector_cache_table[3].addr = 0xffffffff; + peVar2 = env_cache_table; + do { + peVar2->addr = 0xffffffff; + peVar2 = peVar2 + 1; + } while (peVar2 != (env_cache_node *)sector_3152); + env_start_addr = 0; + default_env_set = default_env; + default_env_set_size = default_env_size; + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x738, + "ENV start address is 0x%08X, size is %d bytes.\r\n",0,0x8000); + EVar1 = ef_load_env(); + if (CONCAT31(extraout_var,EVar1) == 0) { + init_ok = true; + } + } + return EVar1; +} + + + +EfErrCode ef_port_read(uint32_t addr,uint32_t *buf,size_t size) + +{ + int iVar1; + + iVar1 = bl_mtd_read(handle,addr,size,(uint8_t *)buf); + return (EfErrCode)((iVar1 < 0) << 1); +} + + + +EfErrCode ef_port_write(uint32_t addr,uint32_t *buf,size_t size) + +{ + EfErrCode EVar1; + int iVar2; + + iVar2 = bl_mtd_write(handle,addr,size,(uint8_t *)buf); + if (iVar2 < 0) { + EVar1 = EF_WRITE_ERR; + } + else { + EVar1 = EF_NO_ERR; + } + return EVar1; +} + + + +void ef_port_env_lock(void) + +{ + xQueueSemaphoreTake((QueueHandle_t)env_cache_lock,0xffffffff); + return; +} + + + +void ef_port_env_unlock(void) + +{ + xQueueGenericSend((QueueHandle_t)env_cache_lock,(void *)0x0,0,0); + return; +} + + + +void ef_log_debug(char *file,long line,char *format,...) + +{ + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list args; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + vprint(format,&uStack20); + return; +} + + + +EfErrCode ef_port_erase(uint32_t addr,size_t size) + +{ + char "ef_port_erase" [14]; + int iVar1; + + if ((addr & 0xfff) != 0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_port.c",0x77, + "(%s) has assert failed at %s.\r\n","addr % EF_ERASE_MIN_SIZE == 0","ef_port_erase" + ); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + iVar1 = bl_mtd_erase(handle,addr,size); + return (EfErrCode)((uint)iVar1 >> 0x1f); +} + + + +void ef_log_info(char *format,...) + +{ + undefined4 in_a1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list args; + undefined4 uStack28; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack28 = in_a1; + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + vprint(format,&uStack28); + return; +} + + + +// WARNING: Variable defined which should be unmapped: info +// WARNING: Could not reconcile some variable overlaps + +EfErrCode ef_port_init(ef_env **default_env,size_t *default_env_size) + +{ + int iVar1; + undefined auStack44 [4]; + bl_mtd_info_t info; + + iVar1 = bl_mtd_open("PSM",&handle,2); + if (iVar1 < 0) { + ef_log_info("[EF] [PART] [XIP] error when get PSM partition %d\r\n",iVar1); + puts("[EF] [PART] [XIP] Dead Loop. Reason: no Valid PSM partition found\r\n"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + memset(auStack44,0,0x1c); + bl_mtd_info(handle,(bl_mtd_info_t *)auStack44); + ef_log_info("[EF] Found Valid PSM partition, XIP Addr %08x, flash addr %08x\r\n",info.size, + info.name._12_4_); + *default_env = default_env_set; + *default_env_size = 1; + printf("*default_env_size = 0x%08x\r\n",1); + env_cache_lock = (SemaphoreHandle_t)xQueueCreateMutex('\x01'); + return EF_NO_ERR; +} + + + +void ef_print(char *format,...) + +{ + undefined4 in_a1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list args; + undefined4 uStack28; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack28 = in_a1; + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + vprint(format,&uStack28); + return; +} + + + +uint32_t ef_calc_crc32(uint32_t crc,void *buf,size_t size) + +{ + uint uVar1; + byte *pbVar2; + + uVar1 = ~crc; + pbVar2 = (byte *)buf; + while (pbVar2 != (byte *)(size + (int)buf)) { + uVar1 = uVar1 >> 8 ^ crc32_table[(*pbVar2 ^ uVar1) & 0xff]; + pbVar2 = pbVar2 + 1; + } + return ~uVar1; +} + + + +void psm_get_cmd(char *buf,int len,int argc,char **argv) + +{ + return; +} + + + +void psm_test_cmd(void) + +{ + size_t *psVar1; + EfErrCode EVar2; + void *__s; + void *__s_00; + undefined3 extraout_var; + size_t __n; + char *format; + int iVar3; + undefined *puVar4; + undefined4 uVar5; + size_t xWantedSize; + size_t sVar6; + size_t sStack92; + size_t local_58 [6]; + size_t asStack64 [3]; + + psVar1 = local_58; + memcpy(local_58,&DAT_23082570,0x18); + do { + sVar6 = *psVar1; + sStack92 = 0; + xWantedSize = sVar6 + 1; + __s = pvPortMalloc(xWantedSize); + __s_00 = pvPortMalloc(xWantedSize); + if ((__s == (void *)0x0) || (__s_00 == (void *)0x0)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] kvbin malloc %d byte error\r\n",&DAT_2307f16c,"easyflash_cli.c", + 0x3d); + if (__s != (void *)0x0) goto LAB_2302e4c6; + } + else { + memset(__s,0,xWantedSize); + memset(__s_00,0,xWantedSize); + xWantedSize = 0; + while (xWantedSize != sVar6) { + *(undefined *)((int)__s + xWantedSize) = 0x76; + xWantedSize = xWantedSize + 1; + } + EVar2 = ef_set_env_blob("1234567890123456789012345678901234567890123456789012345678901234",__s + ,xWantedSize); + iVar3 = CONCAT31(extraout_var,EVar2); + __n = ef_get_env_blob("1234567890123456789012345678901234567890123456789012345678901234", + __s_00,xWantedSize,&sStack92); + if ((iVar3 == 0) && (xWantedSize == __n)) { + iVar3 = memcmp(__s_00,__s,__n); + if (iVar3 == 0) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] kvbin set %ld byte bin -> read %ld byte -> memcmp success.\r\n" + ,&DAT_2307f16c,"easyflash_cli.c",0x56,__n,__n); + goto LAB_2302e4c6; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + iVar3 = 0; + uVar5 = 0x52; + puVar4 = &DAT_23072bcc; + format = + "[%10u][%s: %s:%4d] kvbin set/get %ld byte , res1 = %ld, res2 = %d. memcmp error\r\n"; + sVar6 = __n; + } + else { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar5 = 0x4d; + puVar4 = &DAT_23081ce8; + format = "[%10u][%s: %s:%4d] kvbin set/get %ld byte error, res1 = %ld, res2 = %d.\r\n"; + } + bl_printk(format,puVar4,"easyflash_cli.c",uVar5,sVar6,iVar3,__n); +LAB_2302e4c6: + vPortFree(__s); + } + if (__s_00 != (void *)0x0) { + vPortFree(__s_00); + } + psVar1 = psVar1 + 1; + if (psVar1 == asStack64) { + ef_del_env("1234567890123456789012345678901234567890123456789012345678901234"); + return; + } + } while( true ); +} + + + +EfErrCode psm_erase_cmd(void) + +{ + uint uVar1; + uint32_t addr; + EfErrCode EVar2; + undefined3 extraout_var; + size_t len; + ef_env *peVar3; + sector_meta_data sStack56; + + if (default_env_set == (ef_env *)0x0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x621, + "(%s) has assert failed at %s.\r\n","default_env_set","ef_env_set_default"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + if (default_env_set_size == 0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x622, + "(%s) has assert failed at %s.\r\n","default_env_set_size","ef_env_set_default"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + ef_port_env_lock(); + addr = env_start_addr; + while (addr < env_start_addr + 0x8000) { + EVar2 = format_sector(addr); + if (CONCAT31(extraout_var,EVar2) != 0) goto __exit; + addr = addr + 0x1000; + } + uVar1 = 0; + while (uVar1 < default_env_set_size) { + len = default_env_set[uVar1].value_len; + if (len == 0) { + len = strlen((char *)default_env_set[uVar1].value); + } + sStack56.empty_env = 0xffffffff; + peVar3 = default_env_set + uVar1; + uVar1 = uVar1 + 1; + create_env_blob((sector_meta_data_t)&sStack56,peVar3->key,peVar3->value,len); + } + EVar2 = EF_NO_ERR; +__exit: + ef_port_env_unlock(); + return EVar2; +} + + + +void psm_dump_cmd(void) + +{ + int iStack108; + env_node_obj eStack104; + + iStack108 = 0; + if (init_ok == false) { + ef_log_info("ENV isn\'t initialize OK.\r\n"); + } + else { + ef_port_env_lock(); + env_iterator((env_node_obj_t)&eStack104,&iStack108,(void *)0x0,print_env_cb); + ef_print("\r\nmode: next generation\r\n"); + ef_print("size: %lu/%lu bytes.\r\n",iStack108 + 0x8c,0x7000); + ef_port_env_unlock(); + } + return; +} + + + +void psm_unset_cmd(char *buf,int len,int argc,char **argv) + +{ + if (argc != 2) { + printf("usage: psm_unset [key]\r\n"); + return; + } + ef_del_env(argv[1]); + ef_save_env(); + return; +} + + + +void psm_set_cmd(char *buf,int len,int argc,char **argv) + +{ + if (argc != 3) { + printf("usage: psm_set [key] [value]\r\n"); + return; + } + ef_set_env(argv[1],argv[2]); + ef_save_env(); + return; +} + + + +int easyflash_cli_init(void) + +{ + return 0; +} + + + +// WARNING: Removing unreachable block (ram,0x2302e680) +// WARNING: Removing unreachable block (ram,0x2302e696) + +EventGroupHandle_t xEventGroupCreateStatic(StaticEventGroup_t *pxEventGroupBuffer) + +{ + size_t xSize; + + if (pxEventGroupBuffer == (StaticEventGroup_t *)0x0) { + vAssertCalled(); + } + else { + pxEventGroupBuffer->xDummy1 = 0; + vListInitialise((List_t *)&pxEventGroupBuffer->xDummy2); + pxEventGroupBuffer->ucDummy4 = '\x01'; + } + return (EventGroupHandle_t)pxEventGroupBuffer; +} + + + +EventBits_t +xEventGroupWaitBits(EventGroupHandle_t xEventGroup,EventBits_t uxBitsToWaitFor, + BaseType_t xClearOnExit,BaseType_t xWaitForAllBits,TickType_t xTicksToWait) + +{ + uint uVar1; + BaseType_t BVar2; + uint uVar3; + + if (xEventGroup == (EventGroupHandle_t)0x0) { + vAssertCalled(); + } + if (((uxBitsToWaitFor & 0xff000000) == 0) && (uxBitsToWaitFor != 0)) { + BVar2 = xTaskGetSchedulerState(); + if (BVar2 != 0) goto LAB_2302e6c8; +LAB_2302e748: + if (xTicksToWait == 0) goto LAB_2302e6c8; + vAssertCalled(); + vTaskSuspendAll(); + uVar1 = xEventGroup->uxEventBits; + uVar3 = uxBitsToWaitFor & uVar1; + if (xWaitForAllBits != 0) goto LAB_2302e70c; +LAB_2302e6d8: + if (uVar3 == 0) { +LAB_2302e710: + if (xTicksToWait == 0) goto LAB_2302e762; + uVar1 = (uint)(xClearOnExit != 0) << 0x18; + if (xWaitForAllBits != 0) { + uVar1 = uVar1 | 0x4000000; + } + vTaskPlaceOnUnorderedEventList + (&xEventGroup->xTasksWaitingForBits,uVar1 | uxBitsToWaitFor,xTicksToWait); + BVar2 = xTaskResumeAll(); + if (BVar2 == 0) { + ecall(); + } + uVar1 = uxTaskResetEventItemValue(); + if ((int)(uVar1 << 6) < 0) goto LAB_2302e740; + vTaskEnterCritical(); + uVar1 = xEventGroup->uxEventBits; + if (xWaitForAllBits == 0) { + if ((uxBitsToWaitFor & uVar1) != 0) { +LAB_2302e788: + if (xClearOnExit != 0) { + xEventGroup->uxEventBits = ~uxBitsToWaitFor & uVar1; + } + } + } + else { + if (uxBitsToWaitFor == (uxBitsToWaitFor & uVar1)) goto LAB_2302e788; + } + vTaskExitCritical(); +LAB_2302e740: + return uVar1 & 0xffffff; + } + } + else { + vAssertCalled(); + BVar2 = xTaskGetSchedulerState(); + if (BVar2 == 0) goto LAB_2302e748; +LAB_2302e6c8: + vTaskSuspendAll(); + uVar1 = xEventGroup->uxEventBits; + uVar3 = uxBitsToWaitFor & uVar1; + if (xWaitForAllBits == 0) goto LAB_2302e6d8; +LAB_2302e70c: + if (uxBitsToWaitFor != uVar3) goto LAB_2302e710; + } + if (xClearOnExit != 0) { + xEventGroup->uxEventBits = ~uxBitsToWaitFor & uVar1; + xTaskResumeAll(); + return uVar1; + } +LAB_2302e762: + xTaskResumeAll(); + return uVar1; +} + + + +EventBits_t xEventGroupSetBits(EventGroupHandle_t xEventGroup,EventBits_t uxBitsToSet) + +{ + xLIST_ITEM *pxEventListItem; + xLIST_ITEM *pxVar1; + uint uVar2; + uint uVar3; + xLIST_ITEM *pxVar4; + uint uVar5; + + if (xEventGroup == (EventGroupHandle_t)0x0) { + vAssertCalled(); + } + if ((uxBitsToSet & 0xff000000) != 0) { + vAssertCalled(); + } + vTaskSuspendAll(); + pxEventListItem = (xEventGroup->xTasksWaitingForBits).xListEnd.pxNext; + pxVar4 = (xLIST_ITEM *)&(xEventGroup->xTasksWaitingForBits).xListEnd; + uxBitsToSet = uxBitsToSet | xEventGroup->uxEventBits; + xEventGroup->uxEventBits = uxBitsToSet; + if (pxVar4 != pxEventListItem) { + uVar5 = 0; + do { + while( true ) { + uVar3 = ((ListItem_t *)pxEventListItem)->xItemValue; + uVar2 = uVar3 & 0xffffff; + pxVar1 = ((ListItem_t *)pxEventListItem)->pxNext; + if ((int)(uVar3 << 5) < 0) break; + if ((uVar2 & uxBitsToSet) != 0) { +LAB_2302e806: + if ((int)(uVar3 << 7) < 0) { + uVar5 = uVar5 | uVar2; + } + vTaskRemoveFromUnorderedEventList((ListItem_t *)pxEventListItem,uxBitsToSet | 0x2000000); + uxBitsToSet = xEventGroup->uxEventBits; + } + pxEventListItem = pxVar1; + if (pxVar4 == pxVar1) goto LAB_2302e81c; + } + if (uVar2 == (uVar2 & uxBitsToSet)) goto LAB_2302e806; + pxEventListItem = pxVar1; + } while (pxVar4 != pxVar1); +LAB_2302e81c: + uxBitsToSet = uxBitsToSet & ~uVar5; + } + xEventGroup->uxEventBits = uxBitsToSet; + xTaskResumeAll(); + return xEventGroup->uxEventBits; +} + + + +void vEventGroupDelete(EventGroupHandle_t xEventGroup) + +{ + ListItem_t *pxEventListItem; + UBaseType_t UVar1; + + vTaskSuspendAll(); + UVar1 = (xEventGroup->xTasksWaitingForBits).uxNumberOfItems; + while (UVar1 != 0) { + while (pxEventListItem = (ListItem_t *)(xEventGroup->xTasksWaitingForBits).xListEnd.pxNext, + pxEventListItem != (ListItem_t *)&(xEventGroup->xTasksWaitingForBits).xListEnd) { + vTaskRemoveFromUnorderedEventList(pxEventListItem,0x2000000); + if ((xEventGroup->xTasksWaitingForBits).uxNumberOfItems == 0) goto LAB_2302e890; + } + vAssertCalled(); + vTaskRemoveFromUnorderedEventList + ((ListItem_t *)(xEventGroup->xTasksWaitingForBits).xListEnd.pxNext,0x2000000); + UVar1 = (xEventGroup->xTasksWaitingForBits).uxNumberOfItems; + } +LAB_2302e890: + if (xEventGroup->ucStaticallyAllocated != '\0') { + xTaskResumeAll(); + return; + } + vPortFree(xEventGroup); + xTaskResumeAll(); + return; +} + + + +void vListInitialise(List_t *pxList) + +{ + ListItem_t *pLVar1; + + pLVar1 = (ListItem_t *)&pxList->xListEnd; + pxList->pxIndex = pLVar1; + (pxList->xListEnd).xItemValue = 0xffffffff; + *(ListItem_t **)&(pxList->xListEnd).pxNext = pLVar1; + *(ListItem_t **)&(pxList->xListEnd).pxPrevious = pLVar1; + pxList->uxNumberOfItems = 0; + return; +} + + + +void vListInitialiseItem(ListItem_t *pxItem) + +{ + pxItem->pvContainer = (xLIST *)0x0; + return; +} + + + +void vListInsertEnd(List_t *pxList,ListItem_t *pxNewListItem) + +{ + xLIST_ITEM *pxVar1; + ListItem_t *pLVar2; + + pLVar2 = pxList->pxIndex; + *(ListItem_t **)&pxNewListItem->pxNext = pLVar2; + pxVar1 = pLVar2->pxPrevious; + pxNewListItem->pxPrevious = pxVar1; + *(ListItem_t **)&pxVar1->pxNext = pxNewListItem; + *(ListItem_t **)&pLVar2->pxPrevious = pxNewListItem; + *(List_t **)&pxNewListItem->pvContainer = pxList; + pxList->uxNumberOfItems = pxList->uxNumberOfItems + 1; + return; +} + + + +void vListInsert(List_t *pxList,ListItem_t *pxNewListItem) + +{ + xLIST_ITEM *pxVar1; + xLIST_ITEM *pxVar2; + + pxVar2 = (xLIST_ITEM *)&pxList->xListEnd; + if (pxNewListItem->xItemValue == 0xffffffff) { + pxVar1 = (pxList->xListEnd).pxPrevious; + pxVar2 = pxVar1->pxNext; + } + else { + do { + pxVar1 = pxVar2; + pxVar2 = pxVar1->pxNext; + } while (pxVar2->xItemValue <= pxNewListItem->xItemValue); + } + pxNewListItem->pxNext = pxVar2; + *(ListItem_t **)&pxVar2->pxPrevious = pxNewListItem; + pxNewListItem->pxPrevious = pxVar1; + *(ListItem_t **)&pxVar1->pxNext = pxNewListItem; + *(List_t **)&pxNewListItem->pvContainer = pxList; + pxList->uxNumberOfItems = pxList->uxNumberOfItems + 1; + return; +} + + + +UBaseType_t uxListRemove(ListItem_t *pxItemToRemove) + +{ + xLIST_ITEM *pxVar1; + xLIST *pxVar2; + + pxVar1 = pxItemToRemove->pxPrevious; + pxVar2 = pxItemToRemove->pvContainer; + pxItemToRemove->pxNext->pxPrevious = pxVar1; + pxVar1->pxNext = pxItemToRemove->pxNext; + if (pxVar2->pxIndex != pxItemToRemove) { + pxItemToRemove->pvContainer = (xLIST *)0x0; + pxVar2->uxNumberOfItems = pxVar2->uxNumberOfItems - 1; + return pxVar2->uxNumberOfItems; + } + pxVar2->pxIndex = (ListItem_t *)pxItemToRemove->pxPrevious; + pxItemToRemove->pvContainer = (xLIST *)0x0; + pxVar2->uxNumberOfItems = pxVar2->uxNumberOfItems - 1; + return pxVar2->uxNumberOfItems; +} + + + +BaseType_t prvCopyDataToQueue(Queue_t *pxQueue,void *pvItemToQueue,BaseType_t xPosition) + +{ + UBaseType_t UVar1; + BaseType_t BVar2; + UBaseType_t UVar3; + size_t __n; + int8_t *piVar4; + int8_t *piVar5; + + __n = pxQueue->uxItemSize; + UVar1 = pxQueue->uxMessagesWaiting; + if (__n == 0) { + UVar1 = UVar1 + 1; + BVar2 = 0; + if (pxQueue->pcHead == (int8_t *)0x0) { + BVar2 = xTaskPriorityDisinherit(*(TaskHandle_t *)&pxQueue->u); + *(undefined4 *)&pxQueue->u = 0; + } + } + else { + if (xPosition == 0) { + UVar1 = UVar1 + 1; + memcpy(pxQueue->pcWriteTo,pvItemToQueue,__n); + piVar4 = pxQueue->pcWriteTo; + BVar2 = 0; + pxQueue->pcWriteTo = piVar4 + pxQueue->uxItemSize; + if (*(int8_t **)&pxQueue->u <= piVar4 + pxQueue->uxItemSize) { + pxQueue->uxMessagesWaiting = UVar1; + pxQueue->pcWriteTo = pxQueue->pcHead; + return 0; + } + } + else { + memcpy(*(void **)((int)&pxQueue->u + 4),pvItemToQueue,__n); + UVar3 = pxQueue->uxItemSize; + piVar4 = pxQueue->pcHead; + piVar5 = (int8_t *)(*(int *)((int)&pxQueue->u + 4) + -UVar3); + *(int8_t **)((int)&pxQueue->u + 4) = piVar5; + if (piVar5 < piVar4) { + *(int *)((int)&pxQueue->u + 4) = -UVar3 + *(int *)&pxQueue->u; + } + if (xPosition != 2) { + pxQueue->uxMessagesWaiting = UVar1 + 1; + return 0; + } + BVar2 = 0; + if (UVar1 == 0) { + UVar1 = 1; + } + } + } + pxQueue->uxMessagesWaiting = UVar1; + return BVar2; +} + + + +void prvCopyDataFromQueue(Queue_t *pxQueue,void *pvBuffer) + +{ + int8_t *__src; + size_t __n; + int8_t *piVar1; + + __n = pxQueue->uxItemSize; + if (__n != 0) { + piVar1 = *(int8_t **)&pxQueue->u; + __src = (int8_t *)(*(int *)((int)&pxQueue->u + 4) + __n); + *(int8_t **)((int)&pxQueue->u + 4) = __src; + if (piVar1 <= __src) { + __src = pxQueue->pcHead; + *(int8_t **)((int)&pxQueue->u + 4) = __src; + } + memcpy(pvBuffer,__src,__n); + return; + } + return; +} + + + +void prvUnlockQueue(Queue_t *pxQueue) + +{ + char cVar1; + int iVar2; + BaseType_t BVar3; + uint uVar4; + + vTaskEnterCritical(); + iVar2 = (int)pxQueue->cTxLock; + if ((0 < iVar2) && ((pxQueue->xTasksWaitingToReceive).uxNumberOfItems != 0)) { + do { + BVar3 = xTaskRemoveFromEventList(&pxQueue->xTasksWaitingToReceive); + if (BVar3 == 0) { + uVar4 = iVar2 - 1U & 0xff; + cVar1 = (char)uVar4; + } + else { + vTaskMissedYield(); + uVar4 = iVar2 - 1U & 0xff; + cVar1 = (char)uVar4; + } + } while ((uVar4 != 0) && + (iVar2 = (int)cVar1, (pxQueue->xTasksWaitingToReceive).uxNumberOfItems != 0)); + } + pxQueue->cTxLock = -1; + vTaskExitCritical(); + vTaskEnterCritical(); + iVar2 = (int)pxQueue->cRxLock; + if ((0 < iVar2) && ((pxQueue->xTasksWaitingToSend).uxNumberOfItems != 0)) { + do { + BVar3 = xTaskRemoveFromEventList(&pxQueue->xTasksWaitingToSend); + if (BVar3 == 0) { + uVar4 = iVar2 - 1U & 0xff; + cVar1 = (char)uVar4; + } + else { + vTaskMissedYield(); + uVar4 = iVar2 - 1U & 0xff; + cVar1 = (char)uVar4; + } + } while ((uVar4 != 0) && + (iVar2 = (int)cVar1, (pxQueue->xTasksWaitingToSend).uxNumberOfItems != 0)); + } + pxQueue->cRxLock = -1; + vTaskExitCritical(); + return; +} + + + +BaseType_t xQueueGenericReset(QueueHandle_t xQueue,BaseType_t xNewQueue) + +{ + BaseType_t BVar1; + int8_t *piVar2; + int iVar3; + + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + vTaskEnterCritical(); + piVar2 = xQueue->pcHead; + xQueue->uxMessagesWaiting = 0; + iVar3 = xQueue->uxItemSize * xQueue->uxLength; + xQueue->cRxLock = -1; + xQueue->pcWriteTo = piVar2; + xQueue->cTxLock = -1; + *(int8_t **)&xQueue->u = piVar2 + iVar3; + *(int8_t **)((int)&xQueue->u + 4) = piVar2 + (iVar3 - xQueue->uxItemSize); + if (xNewQueue == 0) { + if (((xQueue->xTasksWaitingToSend).uxNumberOfItems != 0) && + (BVar1 = xTaskRemoveFromEventList(&xQueue->xTasksWaitingToSend), BVar1 != 0)) { + ecall(); + vTaskExitCritical(); + return 1; + } + vTaskExitCritical(); + return 1; + } + vListInitialise(&xQueue->xTasksWaitingToSend); + vListInitialise(&xQueue->xTasksWaitingToReceive); + vTaskExitCritical(); + return 1; +} + + + +// WARNING: Removing unreachable block (ram,0x2302eb7e) + +QueueHandle_t +xQueueGenericCreateStatic + (UBaseType_t uxQueueLength,UBaseType_t uxItemSize,uint8_t *pucQueueStorage, + StaticQueue_t *pxStaticQueue,uint8_t ucQueueType) + +{ + size_t xSize; + + if (uxQueueLength == 0) { + vAssertCalled(); + } + if (pxStaticQueue == (StaticQueue_t *)0x0) { + vAssertCalled(); + } + if (pucQueueStorage == (uint8_t *)0x0) { + if (uxItemSize == 0) goto LAB_2302eb82; + } + else { + if (uxItemSize != 0) goto LAB_2302eb82; + } + vAssertCalled(); +LAB_2302eb82: + if (pxStaticQueue != (StaticQueue_t *)0x0) { + pxStaticQueue->ucDummy6 = '\x01'; + if (uxItemSize == 0) { + pucQueueStorage = (uint8_t *)pxStaticQueue; + } + *(uint8_t **)pxStaticQueue->pvDummy1 = pucQueueStorage; + pxStaticQueue->uxDummy4[1] = uxQueueLength; + pxStaticQueue->uxDummy4[2] = uxItemSize; + xQueueGenericReset((QueueHandle_t)pxStaticQueue,1); + pxStaticQueue->ucDummy9 = ucQueueType; + } + return (QueueHandle_t)pxStaticQueue; +} + + + +QueueHandle_t +xQueueGenericCreate(UBaseType_t uxQueueLength,UBaseType_t uxItemSize,uint8_t ucQueueType) + +{ + QueueHandle_t xQueue; + + if (uxQueueLength == 0) { + vAssertCalled(); + } + if (uxItemSize == 0) { + xQueue = (QueueHandle_t)pvPortMalloc(0x50); + if (xQueue == (QueueHandle_t)0x0) { + return (QueueHandle_t)0x0; + } + xQueue->ucStaticallyAllocated = '\0'; + *(QueueHandle_t *)&xQueue->pcHead = xQueue; + } + else { + xQueue = (QueueHandle_t)pvPortMalloc(uxQueueLength * uxItemSize + 0x50); + if (xQueue == (QueueHandle_t)0x0) { + return (QueueHandle_t)0x0; + } + xQueue->ucStaticallyAllocated = '\0'; + *(QueueHandle_t *)&xQueue->pcHead = xQueue + 1; + } + xQueue->uxLength = uxQueueLength; + xQueue->uxItemSize = uxItemSize; + xQueueGenericReset(xQueue,1); + xQueue->ucQueueType = ucQueueType; + return xQueue; +} + + + +QueueHandle_t xQueueCreateCountingSemaphore(UBaseType_t uxMaxCount,UBaseType_t uxInitialCount) + +{ + bool bVar1; + QueueHandle_t pQVar2; + + if (uxMaxCount == 0) { + vAssertCalled(); + bVar1 = uxInitialCount == 0; + } + else { + bVar1 = uxInitialCount <= uxMaxCount; + } + if (!bVar1) { + vAssertCalled(); + } + pQVar2 = xQueueGenericCreate(uxMaxCount,0,'\x02'); + if (pQVar2 != (QueueHandle_t)0x0) { + pQVar2->uxMessagesWaiting = uxInitialCount; + } + return pQVar2; +} + + + +// WARNING: Variable defined which should be unmapped: xTimeOut + +BaseType_t +xQueueGenericSend(QueueHandle_t xQueue,void *pvItemToQueue,TickType_t xTicksToWait, + BaseType_t xCopyPosition) + +{ + bool bVar1; + BaseType_t BVar2; + int iVar3; + TickType_t local_34 [3]; + undefined auStack40 [4]; + TimeOut_t xTimeOut; + + local_34[0] = xTicksToWait; + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + if ((pvItemToQueue == (void *)0x0) && (xQueue->uxItemSize != 0)) { + vAssertCalled(); + } + if ((xCopyPosition == 2) && (xQueue->uxLength != 1)) { + vAssertCalled(); + } + BVar2 = xTaskGetSchedulerState(); + if ((BVar2 == 0) && (local_34[0] != 0)) { + vAssertCalled(); + } + vTaskEnterCritical(); + bVar1 = false; + if (xQueue->uxLength <= xQueue->uxMessagesWaiting) { + do { + if (xCopyPosition == 2) break; + if (local_34[0] == 0) { + vTaskExitCritical(); + return 0; + } + if (!bVar1) { + vTaskInternalSetTimeOutState((TimeOut_t *)auStack40); + } + vTaskExitCritical(); + vTaskSuspendAll(); + vTaskEnterCritical(); + if (xQueue->cRxLock == -1) { + xQueue->cRxLock = '\0'; + } + if (xQueue->cTxLock == -1) { + xQueue->cTxLock = '\0'; + } + vTaskExitCritical(); + BVar2 = xTaskCheckForTimeOut((TimeOut_t *)auStack40,local_34); + if (BVar2 != 0) { + prvUnlockQueue((Queue_t *)xQueue); + xTaskResumeAll(); + return 0; + } + vTaskEnterCritical(); + if (xQueue->uxMessagesWaiting == xQueue->uxLength) { + vTaskExitCritical(); + vTaskPlaceOnEventList(&xQueue->xTasksWaitingToSend,local_34[0]); + prvUnlockQueue((Queue_t *)xQueue); + BVar2 = xTaskResumeAll(); + if (BVar2 == 0) { + ecall(); + } + } + else { + vTaskExitCritical(); + prvUnlockQueue((Queue_t *)xQueue); + xTaskResumeAll(); + } + bVar1 = true; + vTaskEnterCritical(); + } while (xQueue->uxLength <= xQueue->uxMessagesWaiting); + } + iVar3 = prvCopyDataToQueue((Queue_t *)xQueue,pvItemToQueue,xCopyPosition); + if ((xQueue->xTasksWaitingToReceive).uxNumberOfItems != 0) { + iVar3 = xTaskRemoveFromEventList(&xQueue->xTasksWaitingToReceive); + } + if (iVar3 != 0) { + ecall(); + } + vTaskExitCritical(); + return 1; +} + + + +QueueHandle_t xQueueCreateMutexStatic(uint8_t ucQueueType,StaticQueue_t *pxStaticQueue) + +{ + QueueHandle_t xQueue; + + xQueue = xQueueGenericCreateStatic(1,0,(uint8_t *)0x0,pxStaticQueue,ucQueueType); + if (xQueue != (QueueHandle_t)0x0) { + *(undefined4 *)&xQueue->u = 0; + xQueue->pcHead = (int8_t *)0x0; + *(undefined4 *)((int)&xQueue->u + 4) = 0; + xQueueGenericSend(xQueue,(void *)0x0,0,0); + } + return xQueue; +} + + + +BaseType_t xQueueGiveMutexRecursive(QueueHandle_t xMutex) + +{ + BaseType_t BVar1; + TaskHandle_t ptVar2; + int iVar3; + TaskHandle_t ptVar4; + + if (xMutex == (QueueHandle_t)0x0) { + vAssertCalled(); + } + ptVar4 = *(TaskHandle_t *)&xMutex->u; + ptVar2 = xTaskGetCurrentTaskHandle(); + BVar1 = 0; + if (ptVar4 == ptVar2) { + iVar3 = *(int *)((int)&xMutex->u + 4) + -1; + *(int *)((int)&xMutex->u + 4) = iVar3; + BVar1 = 1; + if (iVar3 == 0) { + xQueueGenericSend(xMutex,(void *)0x0,0,0); + BVar1 = 1; + } + } + return BVar1; +} + + + +QueueHandle_t xQueueCreateMutex(uint8_t ucQueueType) + +{ + QueueHandle_t xQueue; + + xQueue = xQueueGenericCreate(1,0,ucQueueType); + if (xQueue != (QueueHandle_t)0x0) { + *(undefined4 *)&xQueue->u = 0; + xQueue->pcHead = (int8_t *)0x0; + *(undefined4 *)((int)&xQueue->u + 4) = 0; + xQueueGenericSend(xQueue,(void *)0x0,0,0); + } + return xQueue; +} + + + +BaseType_t +xQueueGenericSendFromISR + (QueueHandle_t xQueue,void *pvItemToQueue,BaseType_t *pxHigherPriorityTaskWoken, + BaseType_t xCopyPosition) + +{ + byte bVar1; + BaseType_t BVar2; + + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + if ((pvItemToQueue == (void *)0x0) && (xQueue->uxItemSize != 0)) { + vAssertCalled(); + } + if (xCopyPosition == 2) { + if (xQueue->uxLength != 1) { + vAssertCalled(); + } + } + else { + if (xQueue->uxLength <= xQueue->uxMessagesWaiting) { + return 0; + } + } + bVar1 = xQueue->cTxLock; + prvCopyDataToQueue((Queue_t *)xQueue,pvItemToQueue,xCopyPosition); + if (bVar1 == 0xff) { + if ((((xQueue->xTasksWaitingToReceive).uxNumberOfItems != 0) && + (BVar2 = xTaskRemoveFromEventList(&xQueue->xTasksWaitingToReceive), BVar2 != 0)) && + (pxHigherPriorityTaskWoken != (BaseType_t *)0x0)) { + *pxHigherPriorityTaskWoken = 1; + } + return 1; + } + xQueue->cTxLock = (int8_t)(((uint)bVar1 + 1) * 0x1000000 >> 0x18); + return 1; +} + + + +BaseType_t xQueueGiveFromISR(QueueHandle_t xQueue,BaseType_t *pxHigherPriorityTaskWoken) + +{ + BaseType_t BVar1; + int8_t *piVar2; + + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + if (xQueue->uxItemSize == 0) { + piVar2 = xQueue->pcHead; + } + else { + vAssertCalled(); + piVar2 = xQueue->pcHead; + } + if ((piVar2 == (int8_t *)0x0) && (*(int *)&xQueue->u != 0)) { + vAssertCalled(); + } + BVar1 = 0; + if (xQueue->uxMessagesWaiting < xQueue->uxLength) { + xQueue->uxMessagesWaiting = xQueue->uxMessagesWaiting + 1; + if (xQueue->cTxLock == 0xff) { + if ((((xQueue->xTasksWaitingToReceive).uxNumberOfItems != 0) && + (BVar1 = xTaskRemoveFromEventList(&xQueue->xTasksWaitingToReceive), BVar1 != 0)) && + (pxHigherPriorityTaskWoken != (BaseType_t *)0x0)) { + *pxHigherPriorityTaskWoken = 1; + return 1; + } + } + else { + xQueue->cTxLock = (int8_t)(((uint)(byte)xQueue->cTxLock + 1) * 0x1000000 >> 0x18); + } + BVar1 = 1; + } + return BVar1; +} + + + +BaseType_t xQueueReceive(QueueHandle_t xQueue,void *pvBuffer,TickType_t xTicksToWait) + +{ + BaseType_t BVar1; + UBaseType_t UVar2; + TickType_t local_34 [3]; + undefined auStack40 [4]; + TimeOut_t xTimeOut; + + local_34[0] = xTicksToWait; + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + if ((pvBuffer == (void *)0x0) && (xQueue->uxItemSize != 0)) { + vAssertCalled(); + } + BVar1 = xTaskGetSchedulerState(); + if ((BVar1 == 0) && (local_34[0] != 0)) { + vAssertCalled(); + } + vTaskEnterCritical(); + UVar2 = xQueue->uxMessagesWaiting; + if (UVar2 != 0) { +LAB_2302f0a0: + prvCopyDataFromQueue((Queue_t *)xQueue,pvBuffer); + xQueue->uxMessagesWaiting = UVar2 - 1; + if (((xQueue->xTasksWaitingToSend).uxNumberOfItems != 0) && + (BVar1 = xTaskRemoveFromEventList(&xQueue->xTasksWaitingToSend), BVar1 != 0)) { + ecall(); + } + vTaskExitCritical(); + return 1; + } + if (local_34[0] != 0) { + vTaskInternalSetTimeOutState((TimeOut_t *)auStack40); + do { + vTaskExitCritical(); + vTaskSuspendAll(); + vTaskEnterCritical(); + if (xQueue->cRxLock == -1) { + xQueue->cRxLock = '\0'; + } + if (xQueue->cTxLock == -1) { + xQueue->cTxLock = '\0'; + } + vTaskExitCritical(); + BVar1 = xTaskCheckForTimeOut((TimeOut_t *)auStack40,local_34); + if (BVar1 == 0) { + vTaskEnterCritical(); + if (xQueue->uxMessagesWaiting == 0) { + vTaskExitCritical(); + vTaskPlaceOnEventList(&xQueue->xTasksWaitingToReceive,local_34[0]); + prvUnlockQueue((Queue_t *)xQueue); + BVar1 = xTaskResumeAll(); + if (BVar1 == 0) { + ecall(); + } + goto LAB_2302f094; + } + vTaskExitCritical(); + prvUnlockQueue((Queue_t *)xQueue); + xTaskResumeAll(); + vTaskEnterCritical(); + UVar2 = xQueue->uxMessagesWaiting; + } + else { + prvUnlockQueue((Queue_t *)xQueue); + xTaskResumeAll(); + vTaskEnterCritical(); + if (xQueue->uxMessagesWaiting == 0) break; + vTaskExitCritical(); +LAB_2302f094: + vTaskEnterCritical(); + UVar2 = xQueue->uxMessagesWaiting; + } + if (UVar2 != 0) goto LAB_2302f0a0; + } while (local_34[0] != 0); + } + vTaskExitCritical(); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling + +BaseType_t xQueueSemaphoreTake(QueueHandle_t xQueue,TickType_t xTicksToWait) + +{ + bool bVar1; + BaseType_t BVar2; + TaskHandle_t ptVar3; + UBaseType_t uxHighestPriorityWaitingTask; + int iVar4; + TickType_t local_34 [3]; + undefined auStack40 [4]; + TimeOut_t xTimeOut; + + local_34[0] = xTicksToWait; + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + if (xQueue->uxItemSize != 0) { + vAssertCalled(); + } + BVar2 = xTaskGetSchedulerState(); + if ((BVar2 == 0) && (local_34[0] != 0)) { + vAssertCalled(); + } + vTaskEnterCritical(); + uxHighestPriorityWaitingTask = xQueue->uxMessagesWaiting; + iVar4 = 0; + bVar1 = false; + while( true ) { + if (uxHighestPriorityWaitingTask != 0) { + xQueue->uxMessagesWaiting = uxHighestPriorityWaitingTask - 1; + if (xQueue->pcHead == (int8_t *)0x0) { + ptVar3 = pvTaskIncrementMutexHeldCount(); + *(TaskHandle_t *)&xQueue->u = ptVar3; + } + if (((xQueue->xTasksWaitingToSend).uxNumberOfItems != 0) && + (BVar2 = xTaskRemoveFromEventList(&xQueue->xTasksWaitingToSend), BVar2 != 0)) { + ecall(); + } + vTaskExitCritical(); + return 1; + } + if (local_34[0] == 0) break; + if (!bVar1) { + vTaskInternalSetTimeOutState((TimeOut_t *)auStack40); + } + vTaskExitCritical(); + vTaskSuspendAll(); + vTaskEnterCritical(); + if (xQueue->cRxLock == -1) { + xQueue->cRxLock = '\0'; + } + if (xQueue->cTxLock == -1) { + xQueue->cTxLock = '\0'; + } + vTaskExitCritical(); + BVar2 = xTaskCheckForTimeOut((TimeOut_t *)auStack40,local_34); + if (BVar2 == 0) { + vTaskEnterCritical(); + if (xQueue->uxMessagesWaiting == 0) { + vTaskExitCritical(); + if (xQueue->pcHead == (int8_t *)0x0) { + vTaskEnterCritical(); + iVar4 = xTaskPriorityInherit(*(TaskHandle_t *)&xQueue->u); + vTaskExitCritical(); + } + vTaskPlaceOnEventList(&xQueue->xTasksWaitingToReceive,local_34[0]); + prvUnlockQueue((Queue_t *)xQueue); + BVar2 = xTaskResumeAll(); + if (BVar2 == 0) { + ecall(); + } + } + else { + vTaskExitCritical(); + prvUnlockQueue((Queue_t *)xQueue); + xTaskResumeAll(); + } + } + else { + prvUnlockQueue((Queue_t *)xQueue); + xTaskResumeAll(); + vTaskEnterCritical(); + if (xQueue->uxMessagesWaiting == 0) { + vTaskExitCritical(); + if (iVar4 == 0) { + return 0; + } + vTaskEnterCritical(); + uxHighestPriorityWaitingTask = (xQueue->xTasksWaitingToReceive).uxNumberOfItems; + if (uxHighestPriorityWaitingTask != 0) { + uxHighestPriorityWaitingTask = + 0x20 - ((xQueue->xTasksWaitingToReceive).xListEnd.pxNext)->xItemValue; + } + vTaskPriorityDisinheritAfterTimeout + (*(TaskHandle_t *)&xQueue->u,uxHighestPriorityWaitingTask); + vTaskExitCritical(); + return 0; + } + vTaskExitCritical(); + } + bVar1 = true; + vTaskEnterCritical(); + uxHighestPriorityWaitingTask = xQueue->uxMessagesWaiting; + } + if (iVar4 != 0) { + vAssertCalled(); + } + vTaskExitCritical(); + return 0; +} + + + +BaseType_t xQueueTakeMutexRecursive(QueueHandle_t xMutex,TickType_t xTicksToWait) + +{ + TaskHandle_t ptVar1; + TaskHandle_t ptVar2; + BaseType_t BVar3; + + if (xMutex == (QueueHandle_t)0x0) { + vAssertCalled(); + } + ptVar1 = *(TaskHandle_t *)&xMutex->u; + ptVar2 = xTaskGetCurrentTaskHandle(); + if (ptVar1 != ptVar2) { + BVar3 = xQueueSemaphoreTake(xMutex,xTicksToWait); + if (BVar3 != 0) { + *(int *)((int)&xMutex->u + 4) = *(int *)((int)&xMutex->u + 4) + 1; + } + return BVar3; + } + *(int *)((int)&xMutex->u + 4) = *(int *)((int)&xMutex->u + 4) + 1; + return 1; +} + + + +UBaseType_t uxQueueMessagesWaiting(QueueHandle_t xQueue) + +{ + UBaseType_t UVar1; + + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + vTaskEnterCritical(); + UVar1 = xQueue->uxMessagesWaiting; + vTaskExitCritical(); + return UVar1; +} + + + +void vQueueDelete(QueueHandle_t xQueue) + +{ + QueueHandle_t *ppQVar1; + int iVar2; + QueueRegistryItem_t *pQVar3; + + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + iVar2 = 0; + pQVar3 = xQueueRegistry; + do { + ppQVar1 = &pQVar3->xHandle; + pQVar3 = pQVar3 + 1; + if (*ppQVar1 == (QueueHandle_t)0x0) { + xQueueRegistry[iVar2].pcQueueName = (char *)0x0; + xQueueRegistry[iVar2].xHandle = (QueueHandle_t)0x0; + break; + } + iVar2 = iVar2 + 1; + } while (iVar2 != 8); + if (cRam00000046 != '\0') { + return; + } + vPortFree((void *)0x0); + return; + } + iVar2 = 0; + pQVar3 = xQueueRegistry; + do { + ppQVar1 = &pQVar3->xHandle; + pQVar3 = pQVar3 + 1; + if (xQueue == *ppQVar1) { + xQueueRegistry[iVar2].pcQueueName = (char *)0x0; + xQueueRegistry[iVar2].xHandle = (QueueHandle_t)0x0; + break; + } + iVar2 = iVar2 + 1; + } while (iVar2 != 8); + if (xQueue->ucStaticallyAllocated != '\0') { + return; + } + vPortFree(xQueue); + return; +} + + + +void vQueueAddToRegistry(QueueHandle_t xQueue,char *pcQueueName) + +{ + char **ppcVar1; + int iVar2; + QueueRegistryItem_t *pQVar3; + + iVar2 = 0; + pQVar3 = xQueueRegistry; + do { + ppcVar1 = &pQVar3->pcQueueName; + pQVar3 = pQVar3 + 1; + if (*ppcVar1 == (char *)0x0) { + xQueueRegistry[iVar2].pcQueueName = pcQueueName; + xQueueRegistry[iVar2].xHandle = xQueue; + return; + } + iVar2 = iVar2 + 1; + } while (iVar2 != 8); + return; +} + + + +void vQueueWaitForMessageRestricted + (QueueHandle_t xQueue,TickType_t xTicksToWait,BaseType_t xWaitIndefinitely) + +{ + vTaskEnterCritical(); + if (xQueue->cRxLock == -1) { + xQueue->cRxLock = '\0'; + } + if (xQueue->cTxLock == -1) { + xQueue->cTxLock = '\0'; + } + vTaskExitCritical(); + if (xQueue->uxMessagesWaiting != 0) { + prvUnlockQueue((Queue_t *)xQueue); + return; + } + vTaskPlaceOnEventListRestricted(&xQueue->xTasksWaitingToReceive,xTicksToWait,xWaitIndefinitely); + prvUnlockQueue((Queue_t *)xQueue); + return; +} + + + +void prvInitialiseNewStreamBuffer + (StreamBuffer_t *pxStreamBuffer,uint8_t *pucBuffer,size_t xBufferSizeBytes, + size_t xTriggerLevelBytes,uint8_t ucFlags) + +{ + uint8_t *puVar1; + + puVar1 = (uint8_t *)memset(pucBuffer,0x55,xBufferSizeBytes); + if (pucBuffer != puVar1) { + vAssertCalled(); + } + memset(pxStreamBuffer,0,0x24); + pxStreamBuffer->pucBuffer = pucBuffer; + pxStreamBuffer->xLength = xBufferSizeBytes; + pxStreamBuffer->xTriggerLevelBytes = xTriggerLevelBytes; + pxStreamBuffer->ucFlags = ucFlags; + return; +} + + + +size_t prvWriteBytesToBuffer(StreamBuffer_t *pxStreamBuffer,uint8_t *pucData,size_t xCount) + +{ + uint uVar1; + uint __n; + size_t __n_00; + + if (xCount == 0) { + vAssertCalled(); + uVar1 = pxStreamBuffer->xHead; + if (pxStreamBuffer->xLength < uVar1) { + __n_00 = 0; + goto LAB_2302f4f8; + } + memcpy(pxStreamBuffer->pucBuffer + uVar1,pucData,0); + __n = pxStreamBuffer->xLength; + if (uVar1 < __n) goto LAB_2302f4d6; + } + else { + uVar1 = pxStreamBuffer->xHead; + __n_00 = pxStreamBuffer->xLength - uVar1; + if (xCount < __n_00) { + __n = uVar1 + xCount; + __n_00 = xCount; + } + else { + __n = uVar1 + __n_00; + } + if (pxStreamBuffer->xLength < __n) { +LAB_2302f4f8: + vAssertCalled(); + } + memcpy(pxStreamBuffer->pucBuffer + uVar1,pucData,__n_00); + if (__n_00 < xCount) { + __n = xCount - __n_00; + if (pxStreamBuffer->xLength < __n) { + vAssertCalled(); + memcpy(pxStreamBuffer->pucBuffer,pucData + __n_00,__n); + } + else { + memcpy(pxStreamBuffer->pucBuffer,pucData + __n_00,__n); + } + } + __n = pxStreamBuffer->xLength; + uVar1 = uVar1 + xCount; + if (uVar1 < __n) goto LAB_2302f4d6; + } + uVar1 = uVar1 - __n; +LAB_2302f4d6: + pxStreamBuffer->xHead = uVar1; + return xCount; +} + + + +size_t prvReadBytesFromBuffer + (StreamBuffer_t *pxStreamBuffer,uint8_t *pucData,size_t xMaxCount, + size_t xBytesAvailable) + +{ + size_t sVar1; + uint __n; + + if (xMaxCount <= xBytesAvailable) { + xBytesAvailable = xMaxCount; + } + if (xBytesAvailable == 0) { + return 0; + } + sVar1 = pxStreamBuffer->xTail; + __n = pxStreamBuffer->xLength - sVar1; + if (xBytesAvailable < __n) { + __n = xBytesAvailable; + if (xBytesAvailable <= xMaxCount) goto LAB_2302f566; +LAB_2302f5c0: + vAssertCalled(); + if (sVar1 + __n <= pxStreamBuffer->xLength) goto LAB_2302f56e; + } + else { + if (xMaxCount < __n) goto LAB_2302f5c0; +LAB_2302f566: + if (sVar1 + __n <= pxStreamBuffer->xLength) goto LAB_2302f56e; + } + vAssertCalled(); +LAB_2302f56e: + memcpy(pucData,pxStreamBuffer->pucBuffer + sVar1,__n); + if (__n < xBytesAvailable) { + if (xMaxCount < xBytesAvailable) { + vAssertCalled(); + } + memcpy(pucData + __n,pxStreamBuffer->pucBuffer,xBytesAvailable - __n); + } + sVar1 = sVar1 + xBytesAvailable; + if (pxStreamBuffer->xLength <= sVar1) { + sVar1 = sVar1 - pxStreamBuffer->xLength; + } + pxStreamBuffer->xTail = sVar1; + return xBytesAvailable; +} + + + +StreamBufferHandle_t +xStreamBufferGenericCreate + (size_t xBufferSizeBytes,size_t xTriggerLevelBytes,BaseType_t xIsMessageBuffer) + +{ + uint8_t uVar1; + StreamBuffer_t *pxStreamBuffer; + uint8_t ucFlags; + + ucFlags = (uint8_t)xBufferSizeBytes; + if (xIsMessageBuffer == 1) { + uVar1 = '\x01'; + if (xBufferSizeBytes < 5) { + vAssertCalled(); + uVar1 = '\x01'; + } +joined_r0x2302f64a: + ucFlags = uVar1; + if (xTriggerLevelBytes <= xBufferSizeBytes) goto joined_r0x2302f5f8; + } + else { + uVar1 = '\0'; + if (xBufferSizeBytes != 0) goto joined_r0x2302f64a; + vAssertCalled(); + if (xTriggerLevelBytes == 0) goto joined_r0x2302f5f8; + } + vAssertCalled(); +joined_r0x2302f5f8: + if (xTriggerLevelBytes == 0) { + xTriggerLevelBytes = 1; + } + pxStreamBuffer = (StreamBuffer_t *)pvPortMalloc(xBufferSizeBytes + 0x25); + if (pxStreamBuffer != (StreamBuffer_t *)0x0) { + prvInitialiseNewStreamBuffer + (pxStreamBuffer,(uint8_t *)(pxStreamBuffer + 1),xBufferSizeBytes + 1, + xTriggerLevelBytes,ucFlags); + } + return (StreamBufferHandle_t)pxStreamBuffer; +} + + + +// WARNING: Removing unreachable block (ram,0x2302f6dc) + +StreamBufferHandle_t +xStreamBufferGenericCreateStatic + (size_t xBufferSizeBytes,size_t xTriggerLevelBytes,BaseType_t xIsMessageBuffer, + uint8_t *pucStreamBufferStorageArea,StaticStreamBuffer_t *pxStaticStreamBuffer) + +{ + size_t xSize; + + if (pucStreamBufferStorageArea == (uint8_t *)0x0) { + vAssertCalled(); + } + if (pxStaticStreamBuffer == (StaticStreamBuffer_t *)0x0) { + vAssertCalled(); + } + if (xBufferSizeBytes < xTriggerLevelBytes) { + vAssertCalled(); + } + if (xTriggerLevelBytes == 0) { + xTriggerLevelBytes = 1; + } + if (xBufferSizeBytes < 5) { + vAssertCalled(); + } + if (pucStreamBufferStorageArea == (uint8_t *)0x0) { + pxStaticStreamBuffer = (StaticStreamBuffer_t *)0x0; + } + else { + if (pxStaticStreamBuffer != (StaticStreamBuffer_t *)0x0) { + prvInitialiseNewStreamBuffer + ((StreamBuffer_t *)pxStaticStreamBuffer,pucStreamBufferStorageArea,xBufferSizeBytes, + xTriggerLevelBytes,(xIsMessageBuffer != 0) + '\x02'); + pxStaticStreamBuffer->ucDummy3 = pxStaticStreamBuffer->ucDummy3 | 2; + } + } + return (StreamBufferHandle_t)pxStaticStreamBuffer; +} + + + +void vStreamBufferDelete(StreamBufferHandle_t xStreamBuffer) + +{ + if (xStreamBuffer == (StreamBufferHandle_t)0x0) { + vAssertCalled(); + if ((bRam0000001c & 2) == 0) { + vPortFree((void *)0x0); + return; + } + memset((void *)0x0,0,0x24); + return; + } + if ((xStreamBuffer->ucFlags & 2) == 0) { + vPortFree(xStreamBuffer); + return; + } + memset(xStreamBuffer,0,0x24); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +size_t xStreamBufferSpacesAvailable(StreamBufferHandle_t xStreamBuffer) + +{ + uint uVar1; + size_t sVar2; + uint uVar3; + + if (xStreamBuffer == (StreamBufferHandle_t)0x0) { + vAssertCalled(); + sVar2 = (_DAT_00000008 + ___EM_SIZE + -1) - _DAT_00000004; + if (_DAT_00000008 <= sVar2) { + sVar2 = sVar2 - _DAT_00000008; + } + return sVar2; + } + uVar3 = xStreamBuffer->xLength; + uVar1 = (uVar3 + xStreamBuffer->xTail + -1) - xStreamBuffer->xHead; + if (uVar3 <= uVar1) { + return uVar1 - uVar3; + } + return uVar1; +} + + + +size_t xStreamBufferSend(StreamBufferHandle_t xStreamBuffer,void *pvTxData,size_t xDataLengthBytes, + TickType_t xTicksToWait) + +{ + TaskHandle_t ptVar1; + BaseType_t BVar2; + uint uVar3; + uint uVar4; + size_t sVar5; + TickType_t aTStack52 [2]; + size_t sStack44; + undefined auStack40 [4]; + TimeOut_t xTimeOut; + + aTStack52[0] = xTicksToWait; + if (pvTxData == (void *)0x0) { + vAssertCalled(); + } + if (xStreamBuffer == (StreamBufferHandle_t)0x0) { + vAssertCalled(); + } + sVar5 = xDataLengthBytes; + if (((xStreamBuffer->ucFlags & 1) == 0) || + (sVar5 = xDataLengthBytes + 4, xDataLengthBytes < sVar5)) { + if (aTStack52[0] != 0) goto LAB_2302f7ba; +LAB_2302f85c: + uVar3 = xStreamBufferSpacesAvailable(xStreamBuffer); + if (uVar3 != 0) goto LAB_2302f80c; +LAB_2302f868: + sVar5 = 0; + } + else { + vAssertCalled(); + if (aTStack52[0] == 0) goto LAB_2302f85c; +LAB_2302f7ba: + vTaskSetTimeOutState((TimeOut_t *)auStack40); + do { + vTaskEnterCritical(); + uVar3 = xStreamBufferSpacesAvailable(xStreamBuffer); + if (sVar5 <= uVar3) { + vTaskExitCritical(); + break; + } + xTaskNotifyStateClear((TaskHandle_t)0x0); + if (xStreamBuffer->xTaskWaitingToSend != (TaskHandle_t)0x0) { + vAssertCalled(); + } + ptVar1 = xTaskGetCurrentTaskHandle(); + xStreamBuffer->xTaskWaitingToSend = ptVar1; + vTaskExitCritical(); + xTaskNotifyWait(0,0,(uint32_t *)0x0,aTStack52[0]); + xStreamBuffer->xTaskWaitingToSend = (TaskHandle_t)0x0; + BVar2 = xTaskCheckForTimeOut((TimeOut_t *)auStack40,aTStack52); + } while (BVar2 == 0); + if (uVar3 == 0) goto LAB_2302f85c; +LAB_2302f80c: + if ((xStreamBuffer->ucFlags & 1) == 0) { + sStack44 = xDataLengthBytes; + if (uVar3 < xDataLengthBytes) { + sStack44 = uVar3; + } + } + else { + if (uVar3 < sVar5) goto LAB_2302f868; + sStack44 = xDataLengthBytes; + prvWriteBytesToBuffer((StreamBuffer_t *)xStreamBuffer,(uint8_t *)&sStack44,4); + } + sVar5 = prvWriteBytesToBuffer((StreamBuffer_t *)xStreamBuffer,(uint8_t *)pvTxData,sStack44); + if (sVar5 != 0) { + uVar3 = xStreamBuffer->xLength; + uVar4 = (xStreamBuffer->xHead + uVar3) - xStreamBuffer->xTail; + if (uVar3 <= uVar4) { + uVar4 = uVar4 - uVar3; + } + if (xStreamBuffer->xTriggerLevelBytes <= uVar4) { + vTaskSuspendAll(); + if (xStreamBuffer->xTaskWaitingToReceive != (TaskHandle_t)0x0) { + xTaskGenericNotify(xStreamBuffer->xTaskWaitingToReceive,0,eNoAction,(uint32_t *)0x0); + xStreamBuffer->xTaskWaitingToReceive = (TaskHandle_t)0x0; + } + xTaskResumeAll(); + } + } + } + return sVar5; +} + + + +size_t xStreamBufferSendFromISR + (StreamBufferHandle_t xStreamBuffer,void *pvTxData,size_t xDataLengthBytes, + BaseType_t *pxHigherPriorityTaskWoken) + +{ + size_t sVar1; + uint uVar2; + uint uVar3; + size_t sVar4; + size_t asStack36 [3]; + + if (pvTxData == (void *)0x0) { + vAssertCalled(); + } + if (xStreamBuffer == (StreamBufferHandle_t)0x0) { + vAssertCalled(); + } + sVar4 = xDataLengthBytes; + if ((xStreamBuffer->ucFlags & 1) != 0) { + sVar4 = xDataLengthBytes + 4; + } + sVar1 = xStreamBufferSpacesAvailable(xStreamBuffer); + if (sVar1 == 0) { +LAB_2302f8de: + sVar4 = 0; + } + else { + if ((xStreamBuffer->ucFlags & 1) == 0) { + asStack36[0] = xDataLengthBytes; + if (sVar1 < xDataLengthBytes) { + asStack36[0] = sVar1; + } + } + else { + if (sVar1 < sVar4) goto LAB_2302f8de; + asStack36[0] = xDataLengthBytes; + prvWriteBytesToBuffer((StreamBuffer_t *)xStreamBuffer,(uint8_t *)asStack36,4); + } + sVar4 = prvWriteBytesToBuffer((StreamBuffer_t *)xStreamBuffer,(uint8_t *)pvTxData,asStack36[0]); + if (sVar4 != 0) { + uVar2 = xStreamBuffer->xLength; + uVar3 = (xStreamBuffer->xHead + uVar2) - xStreamBuffer->xTail; + if (uVar2 <= uVar3) { + uVar3 = uVar3 - uVar2; + } + if ((xStreamBuffer->xTriggerLevelBytes <= uVar3) && + (xStreamBuffer->xTaskWaitingToReceive != (TaskHandle_t)0x0)) { + xTaskGenericNotifyFromISR + (xStreamBuffer->xTaskWaitingToReceive,0,eNoAction,(uint32_t *)0x0, + pxHigherPriorityTaskWoken); + xStreamBuffer->xTaskWaitingToReceive = (TaskHandle_t)0x0; + } + } + } + return sVar4; +} + + + +size_t xStreamBufferReceive + (StreamBufferHandle_t xStreamBuffer,void *pvRxData,size_t xBufferLengthBytes, + TickType_t xTicksToWait) + +{ + bool bVar1; + byte bVar2; + size_t xBytesAvailable; + TaskHandle_t ptVar3; + uint uVar4; + uint uVar5; + uint xMaxCount; + size_t sVar6; + uint uStack36; + size_t xTempNextMessageLength; + + if (pvRxData == (void *)0x0) { + vAssertCalled(); + } + if (xStreamBuffer == (StreamBufferHandle_t)0x0) { + vAssertCalled(); + } + bVar2 = xStreamBuffer->ucFlags; + uVar5 = (uint)bVar2 & 1; + xMaxCount = uVar5 * 4; + if (xTicksToWait != 0) { + vTaskEnterCritical(); + uVar4 = xStreamBuffer->xLength; + xBytesAvailable = (xStreamBuffer->xHead + uVar4) - xStreamBuffer->xTail; + if (uVar4 <= xBytesAvailable) { + xBytesAvailable = xBytesAvailable - uVar4; + } + if (xMaxCount < xBytesAvailable) { + vTaskExitCritical(); + goto LAB_2302f9ce; + } + xTaskNotifyStateClear((TaskHandle_t)0x0); + if (xStreamBuffer->xTaskWaitingToReceive != (TaskHandle_t)0x0) { + vAssertCalled(); + } + ptVar3 = xTaskGetCurrentTaskHandle(); + xStreamBuffer->xTaskWaitingToReceive = ptVar3; + vTaskExitCritical(); + xTaskNotifyWait(0,0,(uint32_t *)0x0,xTicksToWait); + xStreamBuffer->xTaskWaitingToReceive = (TaskHandle_t)0x0; + } + uVar4 = xStreamBuffer->xLength; + xBytesAvailable = (xStreamBuffer->xHead + uVar4) - xStreamBuffer->xTail; + if (uVar4 <= xBytesAvailable) { + xBytesAvailable = xBytesAvailable - uVar4; + } + if (xBytesAvailable <= xMaxCount) { + return 0; + } +LAB_2302f9ce: + if ((bVar2 & 1) != 0) { + sVar6 = xStreamBuffer->xTail; + prvReadBytesFromBuffer + ((StreamBuffer_t *)xStreamBuffer,(uint8_t *)&uStack36,xMaxCount,xBytesAvailable); + xBytesAvailable = xBytesAvailable + uVar5 * -4; + bVar1 = xBufferLengthBytes < uStack36; + xBufferLengthBytes = uStack36; + if (bVar1) { + xStreamBuffer->xTail = sVar6; + xBufferLengthBytes = 0; + } + } + xBytesAvailable = + prvReadBytesFromBuffer + ((StreamBuffer_t *)xStreamBuffer,(uint8_t *)pvRxData,xBufferLengthBytes, + xBytesAvailable); + if (xBytesAvailable == 0) { + return 0; + } + vTaskSuspendAll(); + if (xStreamBuffer->xTaskWaitingToSend != (TaskHandle_t)0x0) { + xTaskGenericNotify(xStreamBuffer->xTaskWaitingToSend,0,eNoAction,(uint32_t *)0x0); + xStreamBuffer->xTaskWaitingToSend = (TaskHandle_t)0x0; + } + xTaskResumeAll(); + return xBytesAvailable; +} + + + +// WARNING: Variable defined which should be unmapped: xTempNextMessageLength + +size_t xStreamBufferReceiveFromISR + (StreamBufferHandle_t xStreamBuffer,void *pvRxData,size_t xBufferLengthBytes, + BaseType_t *pxHigherPriorityTaskWoken) + +{ + bool bVar1; + size_t xBytesAvailable; + uint uVar2; + uint uVar3; + uint xMaxCount; + size_t sVar4; + uint uStack36; + size_t xTempNextMessageLength; + + if (pvRxData == (void *)0x0) { + vAssertCalled(); + } + if (xStreamBuffer == (StreamBufferHandle_t)0x0) { + vAssertCalled(); + } + uVar2 = xStreamBuffer->xLength; + uVar3 = (uint)xStreamBuffer->ucFlags & 1; + xBytesAvailable = (xStreamBuffer->xHead + uVar2) - xStreamBuffer->xTail; + xMaxCount = uVar3 * 4; + if (uVar2 <= xBytesAvailable) { + xBytesAvailable = xBytesAvailable - uVar2; + } + if (xMaxCount < xBytesAvailable) { + if ((xStreamBuffer->ucFlags & 1) != 0) { + sVar4 = xStreamBuffer->xTail; + prvReadBytesFromBuffer + ((StreamBuffer_t *)xStreamBuffer,(uint8_t *)&uStack36,xMaxCount,xBytesAvailable); + xBytesAvailable = xBytesAvailable + uVar3 * -4; + bVar1 = xBufferLengthBytes < uStack36; + xBufferLengthBytes = uStack36; + if (bVar1) { + xStreamBuffer->xTail = sVar4; + xBufferLengthBytes = 0; + } + } + xBytesAvailable = + prvReadBytesFromBuffer + ((StreamBuffer_t *)xStreamBuffer,(uint8_t *)pvRxData,xBufferLengthBytes, + xBytesAvailable); + if (xBytesAvailable != 0) { + if (xStreamBuffer->xTaskWaitingToSend == (TaskHandle_t)0x0) { + return xBytesAvailable; + } + xTaskGenericNotifyFromISR + (xStreamBuffer->xTaskWaitingToSend,0,eNoAction,(uint32_t *)0x0, + pxHigherPriorityTaskWoken); + xStreamBuffer->xTaskWaitingToSend = (TaskHandle_t)0x0; + return xBytesAvailable; + } + } + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BaseType_t xStreamBufferIsEmpty(StreamBufferHandle_t xStreamBuffer) + +{ + if (xStreamBuffer != (StreamBufferHandle_t)0x0) { + return (uint)(xStreamBuffer->xHead == xStreamBuffer->xTail); + } + vAssertCalled(); + return (uint)(_DAT_00000004 == ___EM_SIZE); +} + + + +void prvResetNextTaskUnblockTime(void) + +{ + xNextTaskUnblockTime = *(TickType_t *)((int)((pxDelayedTaskList->xListEnd).pxNext)->pvOwner + 4); + return; +} + + + +void prvInitialiseNewTask + (TaskFunction_t *pxTaskCode,char *pcName,uint32_t ulStackDepth,void *pvParameters, + UBaseType_t uxPriority,TaskHandle_t *pxCreatedTask,TCB_t *pxNewTCB) + +{ + char cVar1; + char *pcVar2; + char *pcVar3; + StackType_t *pSVar4; + + memset(pxNewTCB->pxStack,0xa5,ulStackDepth * 4); + pSVar4 = pxNewTCB->pxStack; + if (pcName == (char *)0x0) { + pxNewTCB->pcTaskName[0] = '\0'; + } + else { + pcVar2 = pcName + 0x10; + pcVar3 = pxNewTCB->pcTaskName; + do { + cVar1 = *pcName; + pcName = pcName + 1; + *pcVar3 = cVar1; + if (cVar1 == '\0') break; + pcVar3 = pcVar3 + 1; + } while (pcName != pcVar2); + pxNewTCB->pcTaskName[0xf] = '\0'; + } + if (0x1f < uxPriority) { + uxPriority = 0x1f; + } + pxNewTCB->uxPriority = uxPriority; + pxNewTCB->uxBasePriority = uxPriority; + pxNewTCB->uxMutexesHeld = 0; + vListInitialiseItem(&pxNewTCB->xStateListItem); + vListInitialiseItem(&pxNewTCB->xEventListItem); + pxNewTCB->ulNotifiedValue = 0; + *(TCB_t **)&(pxNewTCB->xStateListItem).pvOwner = pxNewTCB; + (pxNewTCB->xEventListItem).xItemValue = 0x20 - uxPriority; + *(TCB_t **)&(pxNewTCB->xEventListItem).pvOwner = pxNewTCB; + pxNewTCB->uxCriticalNesting = 0; + pxNewTCB->ucNotifyState = '\0'; + pSVar4 = (StackType_t *) + pxPortInitialiseStack + ((uint)(pSVar4 + (ulStackDepth - 1)) & 0xfffffff8,pxTaskCode,pvParameters); + pxNewTCB->pxTopOfStack = pSVar4; + if (pxCreatedTask != (TaskHandle_t *)0x0) { + *(TCB_t **)pxCreatedTask = pxNewTCB; + } + return; +} + + + +void prvDeleteTCB(TCB_t *pxTCB) + +{ + uint8_t uVar1; + + uVar1 = pxTCB->ucStaticallyAllocated; + if (uVar1 == '\0') { + vPortFree(pxTCB->pxStack); + vPortFree(pxTCB); + return; + } + if (uVar1 != '\x01') { + if (uVar1 == '\x02') { + return; + } + vAssertCalled(); + return; + } + vPortFree(pxTCB); + return; +} + + + +void prvAddCurrentTaskToDelayedList(TickType_t xTicksToWait,BaseType_t xCanBlockIndefinitely) + +{ + TickType_t TVar1; + uint uVar2; + UBaseType_t UVar3; + + TVar1 = xTickCount; + UVar3 = uxListRemove(&pxCurrentTCB->xStateListItem); + if (UVar3 == 0) { + uxTopReadyPriority = ~(1 << (pxCurrentTCB->uxPriority & 0x1f)) & uxTopReadyPriority; + } + if ((xTicksToWait == 0xffffffff) && (xCanBlockIndefinitely != 0)) { + vListInsertEnd(&xSuspendedTaskList,&pxCurrentTCB->xStateListItem); + return; + } + uVar2 = xTicksToWait + TVar1; + (pxCurrentTCB->xStateListItem).xItemValue = uVar2; + if (TVar1 <= uVar2) { + vListInsert(pxDelayedTaskList,&pxCurrentTCB->xStateListItem); + if (uVar2 < xNextTaskUnblockTime) { + xNextTaskUnblockTime = uVar2; + } + return; + } + vListInsert(pxOverflowDelayedTaskList,&pxCurrentTCB->xStateListItem); + return; +} + + + +void vTaskEnterCritical(void) + +{ + pxCurrentTCB->uxCriticalNesting = pxCurrentTCB->uxCriticalNesting + 1; + return; +} + + + +void vTaskExitCritical(void) + +{ + pxCurrentTCB->uxCriticalNesting = pxCurrentTCB->uxCriticalNesting - 1; + return; +} + + + +void prvAddNewTaskToReadyList(TCB_t *pxNewTCB) + +{ + uint uVar1; + List_t *pxList; + List_t *pLVar2; + + if (xSchedulerRunning != 0) { + vTaskEnterCritical(); + } + uxCurrentNumberOfTasks = uxCurrentNumberOfTasks + 1; + if (pxCurrentTCB == (TCB_t *)0x0) { + if (uxCurrentNumberOfTasks == 1) { + pxList = pxReadyTasksLists; + pxCurrentTCB = pxNewTCB; + do { + pLVar2 = pxList + 1; + vListInitialise(pxList); + pxList = pLVar2; + } while (pLVar2 != &xDelayedTaskList1); + vListInitialise(&xDelayedTaskList1); + vListInitialise(&xDelayedTaskList2); + vListInitialise(&xPendingReadyList); + vListInitialise(&xTasksWaitingTermination); + vListInitialise(&xSuspendedTaskList); + pxDelayedTaskList = &xDelayedTaskList1; + pxOverflowDelayedTaskList = &xDelayedTaskList2; + uVar1 = pxNewTCB->uxPriority; + } + else { + uVar1 = pxNewTCB->uxPriority; + pxCurrentTCB = pxNewTCB; + } + } + else { + uVar1 = pxNewTCB->uxPriority; + if ((xSchedulerRunning == 0) && (pxCurrentTCB->uxPriority <= uVar1)) { + pxCurrentTCB = pxNewTCB; + } + } + uxTaskNumber = uxTaskNumber + 1; + uxTopReadyPriority = 1 << (uVar1 & 0x1f) | uxTopReadyPriority; + pxNewTCB->uxTCBNumber = uxTaskNumber; + vListInsertEnd(pxReadyTasksLists + uVar1,&pxNewTCB->xStateListItem); + if ((xSchedulerRunning != 0) && (pxCurrentTCB->uxCriticalNesting != 0)) { + vTaskExitCritical(); + } + if ((xSchedulerRunning != 0) && (pxCurrentTCB->uxPriority < pxNewTCB->uxPriority)) { + ecall(); + } + return; +} + + +/* +Unable to decompile 'prvIdleTask' +Cause: Exception while decompiling 2302fea6: Decompiler process died + +*/ + + +// WARNING: Removing unreachable block (ram,0x2302ff8e) +// WARNING: Removing unreachable block (ram,0x2302ffd4) + +TaskHandle_t +xTaskCreateStatic(TaskFunction_t *pxTaskCode,char *pcName,uint32_t ulStackDepth,void *pvParameters, + UBaseType_t uxPriority,StackType_t *puxStackBuffer,StaticTask_t *pxTaskBuffer) + +{ + TaskHandle_t ptVar1; + size_t xSize; + TaskHandle_t xReturn; + + ptVar1 = (TaskHandle_t)xSize; + if (puxStackBuffer == (StackType_t *)0x0) { + vAssertCalled(); + ptVar1 = (TaskHandle_t)xSize; + } + if (pxTaskBuffer == (StaticTask_t *)0x0) { + vAssertCalled(); + return (TaskHandle_t)0x0; + } + xSize = 0; + if (puxStackBuffer != (StackType_t *)0x0) { + pxTaskBuffer->uxDummy20 = '\x02'; + *(StackType_t **)&pxTaskBuffer->pxDummy6 = puxStackBuffer; + xSize = (size_t)ptVar1; + prvInitialiseNewTask + (pxTaskCode,pcName,ulStackDepth,pvParameters,uxPriority,(TaskHandle_t *)&xSize, + (TCB_t *)pxTaskBuffer); + prvAddNewTaskToReadyList((TCB_t *)pxTaskBuffer); + } + return (TaskHandle_t)xSize; +} + + + +BaseType_t +xTaskCreate(TaskFunction_t *pxTaskCode,char *pcName,uint16_t usStackDepth,void *pvParameters, + UBaseType_t uxPriority,TaskHandle_t *pxCreatedTask) + +{ + StackType_t *pv; + TCB_t *pxNewTCB; + BaseType_t BVar1; + undefined2 in_register_00002032; + + pv = (StackType_t *)pvPortMalloc(CONCAT22(in_register_00002032,usStackDepth) << 2); + if (pv == (StackType_t *)0x0) { + BVar1 = -1; + } + else { + pxNewTCB = (TCB_t *)pvPortMalloc(0x60); + if (pxNewTCB == (TCB_t *)0x0) { + vPortFree(pv); + BVar1 = -1; + } + else { + pxNewTCB->pxStack = pv; + pxNewTCB->ucStaticallyAllocated = '\0'; + prvInitialiseNewTask + (pxTaskCode,pcName,CONCAT22(in_register_00002032,usStackDepth),pvParameters, + uxPriority,pxCreatedTask,pxNewTCB); + prvAddNewTaskToReadyList(pxNewTCB); + BVar1 = 1; + } + } + return BVar1; +} + + + +void vTaskDelete(TaskHandle_t xTaskToDelete) + +{ + UBaseType_t UVar1; + + if (xSchedulerRunning != 0) { + vTaskEnterCritical(); + } + if (xTaskToDelete == (TaskHandle_t)0x0) { + xTaskToDelete = (TaskHandle_t)pxCurrentTCB; + } + UVar1 = uxListRemove(&((TCB_t *)xTaskToDelete)->xStateListItem); + if ((UVar1 == 0) && (pxReadyTasksLists[((TCB_t *)xTaskToDelete)->uxPriority].uxNumberOfItems == 0) + ) { + uxTopReadyPriority = ~(1 << (((TCB_t *)xTaskToDelete)->uxPriority & 0x1f)) & uxTopReadyPriority; + } + if ((((TCB_t *)xTaskToDelete)->xEventListItem).pvContainer != (xLIST *)0x0) { + uxListRemove(&((TCB_t *)xTaskToDelete)->xEventListItem); + } + uxTaskNumber = uxTaskNumber + 1; + if (pxCurrentTCB == (TCB_t *)xTaskToDelete) { + vListInsertEnd(&xTasksWaitingTermination,&((TCB_t *)xTaskToDelete)->xStateListItem); + uxDeletedTasksWaitingCleanUp = uxDeletedTasksWaitingCleanUp + 1; + } + else { + uxCurrentNumberOfTasks = uxCurrentNumberOfTasks - 1; + prvDeleteTCB((TCB_t *)xTaskToDelete); + if (pxDelayedTaskList->uxNumberOfItems == 0) { + xNextTaskUnblockTime = 0xffffffff; + } + else { + prvResetNextTaskUnblockTime(); + } + } + if ((xSchedulerRunning != 0) && (pxCurrentTCB->uxCriticalNesting != 0)) { + vTaskExitCritical(); + } + if ((xSchedulerRunning != 0) && (pxCurrentTCB == (TCB_t *)xTaskToDelete)) { + if (uxSchedulerSuspended == 0) { + ecall(); + } + else { + vAssertCalled(); + ecall(); + } + return; + } + return; +} + + +/* +Unable to decompile 'eTaskGetState' +Cause: Exception while decompiling 23030196: Decompiler process died + +*/ + +/* +Unable to decompile 'vTaskStartScheduler' +Cause: Exception while decompiling 23030264: Decompiler process died + +*/ + + +void vTaskSuspendAll(void) + +{ + uxSchedulerSuspended = uxSchedulerSuspended + 1; + return; +} + + + +TickType_t xTaskGetTickCount(void) + +{ + return xTickCount; +} + + + +BaseType_t xTaskGetTickCount2(TickType_t *ticks,BaseType_t *overflow) + +{ + BaseType_t BVar1; + + BVar1 = xNumOfOverflows; + *ticks = xTickCount; + *overflow = BVar1; + return 1; +} + + + +TickType_t xTaskGetTickCountFromISR(void) + +{ + return xTickCount; +} + + + +char * pcTaskGetName(TaskHandle_t xTaskToQuery) + +{ + if ((xTaskToQuery == (TaskHandle_t)0x0) && + (xTaskToQuery = (TaskHandle_t)pxCurrentTCB, pxCurrentTCB == (TCB_t *)0x0)) { + vAssertCalled(); + return (char *)0x34; + } + return ((TCB_t *)xTaskToQuery)->pcTaskName; +} + + + +BaseType_t xTaskIncrementTick(void) + +{ + List_t *pLVar1; + List_t *pLVar2; + TickType_t TVar3; + void *pvVar4; + int iVar5; + int iVar6; + uint uVar7; + uint32_t uStack52; + uint32_t tmp; + + iVar6 = bl_sys_time_sync_state(&uStack52); + if (iVar6 != 0) { + if (uxSchedulerSuspended == 0) { + uVar7 = xTickCount + 1; + xTickCount = uVar7; + if (uVar7 == 0) { + if (pxDelayedTaskList->uxNumberOfItems != 0) { + vAssertCalled(); + } + pLVar2 = pxOverflowDelayedTaskList; + pLVar1 = pxDelayedTaskList; + pxDelayedTaskList = pxOverflowDelayedTaskList; + pxOverflowDelayedTaskList = pLVar1; + xNumOfOverflows = xNumOfOverflows + 1; + if (pLVar2->uxNumberOfItems == 0) { + xNextTaskUnblockTime = 0xffffffff; + } + else { + prvResetNextTaskUnblockTime(); + } + } + if (uVar7 < xNextTaskUnblockTime) { + iVar6 = 0; + TVar3 = xNextTaskUnblockTime; + } + else { + iVar6 = 0; + while (iVar5 = iVar6, pxDelayedTaskList->uxNumberOfItems != 0) { + while( true ) { + pvVar4 = ((pxDelayedTaskList->xListEnd).pxNext)->pvOwner; + TVar3 = *(uint *)((int)pvVar4 + 4); + if (uVar7 < *(uint *)((int)pvVar4 + 4)) goto LAB_230304b2; + uxListRemove((ListItem_t *)((int)pvVar4 + 4)); + if (*(int *)((int)pvVar4 + 0x28) != 0) { + uxListRemove((ListItem_t *)((int)pvVar4 + 0x18)); + } + uxTopReadyPriority = 1 << (*(uint *)((int)pvVar4 + 0x2c) & 0x1f) | uxTopReadyPriority; + vListInsertEnd(pxReadyTasksLists + *(uint *)((int)pvVar4 + 0x2c), + (ListItem_t *)((int)pvVar4 + 4)); + if (*(uint *)((int)pvVar4 + 0x2c) < pxCurrentTCB->uxPriority) break; + iVar6 = 1; + iVar5 = 1; + if (pxDelayedTaskList->uxNumberOfItems == 0) goto LAB_23030498; + } + } +LAB_23030498: + xNextTaskUnblockTime = 0xffffffff; + iVar6 = iVar5; + TVar3 = xNextTaskUnblockTime; + } +LAB_230304b2: + xNextTaskUnblockTime = TVar3; + if (1 < pxReadyTasksLists[pxCurrentTCB->uxPriority].uxNumberOfItems) { + iVar6 = 1; + } + } + else { + iVar6 = 0; + uxPendedTicks = uxPendedTicks + 1; + } + if (xYieldPending != 0) { + iVar6 = 1; + } + } + return iVar6; +} + + +/* +Unable to decompile 'xTaskResumeAll' +Cause: Exception while decompiling 230304dc: Decompiler process died + +*/ + + +void vTaskDelay(TickType_t xTicksToDelay) + +{ + BaseType_t BVar1; + + if (xTicksToDelay == 0) { + ecall(); + return; + } + if (uxSchedulerSuspended != 0) { + vAssertCalled(); + } + uxSchedulerSuspended = uxSchedulerSuspended + 1; + prvAddCurrentTaskToDelayedList(xTicksToDelay,0); + BVar1 = xTaskResumeAll(); + if (BVar1 == 0) { + ecall(); + } + return; +} + + + +void vTaskSwitchContext(void) + +{ + int iVar1; + StackType_t *pSVar2; + xLIST_ITEM *pxVar3; + + if (uxSchedulerSuspended == 0) { + xYieldPending = 0; + pSVar2 = pxCurrentTCB->pxStack; + if ((((*pSVar2 != 0xa5a5a5a5) || (pSVar2[1] != 0xa5a5a5a5)) || (pSVar2[2] != 0xa5a5a5a5)) || + (pSVar2[3] != 0xa5a5a5a5)) { + vApplicationStackOverflowHook((TaskHandle_t)pxCurrentTCB,pxCurrentTCB->pcTaskName); + } + iVar1 = __clzsi2(uxTopReadyPriority); + iVar1 = 0x1f - iVar1; + if (pxReadyTasksLists[iVar1].uxNumberOfItems == 0) { + vAssertCalled(); + } + pxVar3 = (pxReadyTasksLists[iVar1].pxIndex)->pxNext; + *(xLIST_ITEM **)&pxReadyTasksLists[iVar1].pxIndex = pxVar3; + if (pxVar3 == (xLIST_ITEM *)(iVar1 * 0x14 + 0x42012544)) { + pxVar3 = pxVar3->pxNext; + *(xLIST_ITEM **)&pxReadyTasksLists[iVar1].pxIndex = pxVar3; + } + pxCurrentTCB = (TCB_t *)pxVar3->pvOwner; + return; + } + xYieldPending = 1; + return; +} + + + +void vTaskPlaceOnEventList(List_t *pxEventList,TickType_t xTicksToWait) + +{ + if (pxEventList == (List_t *)0x0) { + vAssertCalled(); + } + vListInsert(pxEventList,&pxCurrentTCB->xEventListItem); + prvAddCurrentTaskToDelayedList(xTicksToWait,1); + return; +} + + + +void vTaskPlaceOnUnorderedEventList + (List_t *pxEventList,TickType_t xItemValue,TickType_t xTicksToWait) + +{ + ListItem_t *pxNewListItem; + + if (pxEventList == (List_t *)0x0) { + vAssertCalled(); + } + if (uxSchedulerSuspended == 0) { + vAssertCalled(); + } + pxNewListItem = &pxCurrentTCB->xEventListItem; + (pxCurrentTCB->xEventListItem).xItemValue = xItemValue | 0x80000000; + vListInsertEnd(pxEventList,pxNewListItem); + prvAddCurrentTaskToDelayedList(xTicksToWait,1); + return; +} + + + +void vTaskPlaceOnEventListRestricted + (List_t *pxEventList,TickType_t xTicksToWait,BaseType_t xWaitIndefinitely) + +{ + if (pxEventList == (List_t *)0x0) { + vAssertCalled(); + } + vListInsertEnd(pxEventList,&pxCurrentTCB->xEventListItem); + if (xWaitIndefinitely != 0) { + xTicksToWait = 0xffffffff; + } + prvAddCurrentTaskToDelayedList(xTicksToWait,xWaitIndefinitely); + return; +} + + + +BaseType_t xTaskRemoveFromEventList(List_t *pxEventList) + +{ + bool bVar1; + void *pvVar2; + + pvVar2 = ((pxEventList->xListEnd).pxNext)->pvOwner; + if (pvVar2 == (void *)0x0) { + vAssertCalled(); + } + uxListRemove((ListItem_t *)((int)pvVar2 + 0x18)); + if (uxSchedulerSuspended == 0) { + uxListRemove((ListItem_t *)((int)pvVar2 + 4)); + uxTopReadyPriority = 1 << (*(uint *)((int)pvVar2 + 0x2c) & 0x1f) | uxTopReadyPriority; + vListInsertEnd(pxReadyTasksLists + *(uint *)((int)pvVar2 + 0x2c),(ListItem_t *)((int)pvVar2 + 4) + ); + } + else { + vListInsertEnd(&xPendingReadyList,(ListItem_t *)((int)pvVar2 + 0x18)); + } + bVar1 = pxCurrentTCB->uxPriority < *(uint *)((int)pvVar2 + 0x2c); + if (bVar1) { + xYieldPending = 1; + } + return (uint)bVar1; +} + + + +void vTaskRemoveFromUnorderedEventList(ListItem_t *pxEventListItem,TickType_t xItemValue) + +{ + void *pvVar1; + + if (uxSchedulerSuspended == 0) { + vAssertCalled(); + pvVar1 = pxEventListItem->pvOwner; + pxEventListItem->xItemValue = xItemValue | 0x80000000; + } + else { + pvVar1 = pxEventListItem->pvOwner; + pxEventListItem->xItemValue = xItemValue | 0x80000000; + } + if (pvVar1 == (void *)0x0) { + vAssertCalled(); + } + uxListRemove(pxEventListItem); + uxListRemove((ListItem_t *)((int)pvVar1 + 4)); + uxTopReadyPriority = 1 << (*(uint *)((int)pvVar1 + 0x2c) & 0x1f) | uxTopReadyPriority; + vListInsertEnd(pxReadyTasksLists + *(uint *)((int)pvVar1 + 0x2c),(ListItem_t *)((int)pvVar1 + 4)); + if (pxCurrentTCB->uxPriority < *(uint *)((int)pvVar1 + 0x2c)) { + xYieldPending = 1; + } + return; +} + + +/* +Unable to decompile 'vTaskSetTimeOutState' +Cause: Exception while decompiling 23030936: Decompiler process died + +*/ + + +void vTaskInternalSetTimeOutState(TimeOut_t *pxTimeOut) + +{ + TickType_t TVar1; + + TVar1 = xTickCount; + pxTimeOut->xOverflowCount = xNumOfOverflows; + pxTimeOut->xTimeOnEntering = TVar1; + return; +} + + +/* +Unable to decompile 'xTaskCheckForTimeOut' +Cause: Exception while decompiling 230309ac: Decompiler process died + +*/ + + +void vTaskMissedYield(void) + +{ + xYieldPending = 1; + return; +} + + + +void vTaskGetInfo(TaskHandle_t xTask,TaskStatus_t *pxTaskStatus,BaseType_t xGetFreeStackSpace, + eTaskState eState) + +{ + eTaskState eVar1; + undefined3 in_register_00002035; + UBaseType_t UVar2; + uint uVar3; + + if (xTask == (TaskHandle_t)0x0) { + xTask = (TaskHandle_t)pxCurrentTCB; + } + pxTaskStatus->pcTaskName = xTask->pcTaskName; + pxTaskStatus->xHandle = xTask; + pxTaskStatus->uxCurrentPriority = xTask->uxPriority; + pxTaskStatus->pxStackBase = xTask->pxStack; + pxTaskStatus->xTaskNumber = xTask->uxTCBNumber; + UVar2 = xTask->uxBasePriority; + pxTaskStatus->ulRunTimeCounter = 0; + pxTaskStatus->uxBasePriority = UVar2; + if (CONCAT31(in_register_00002035,eState) == 5) { + eVar1 = eTaskGetState(xTask); + pxTaskStatus->eCurrentState = eVar1; + } + else { + if (pxCurrentTCB == (TCB_t *)xTask) { + pxTaskStatus->eCurrentState = eRunning; + } + else { + pxTaskStatus->eCurrentState = eState; + if (CONCAT31(in_register_00002035,eState) == 3) { + uxSchedulerSuspended = uxSchedulerSuspended + 1; + if ((xTask->xEventListItem).pvContainer != (xLIST *)0x0) { + pxTaskStatus->eCurrentState = eBlocked; + } + xTaskResumeAll(); + } + } + } + if (xGetFreeStackSpace != 0) { + if (*(char *)xTask->pxStack == -0x5b) { + uVar3 = 0; + do { + uVar3 = uVar3 + 1; + } while (*(char *)((int)xTask->pxStack + uVar3) == -0x5b); + pxTaskStatus->usStackHighWaterMark = (uint16_t)(uVar3 >> 2); + } + else { + pxTaskStatus->usStackHighWaterMark = 0; + } + return; + } + pxTaskStatus->usStackHighWaterMark = 0; + return; +} + + + +UBaseType_t +prvListTasksWithinSingleList(TaskStatus_t *pxTaskStatusArray,List_t *pxList,eTaskState eState) + +{ + TaskHandle_t xTask; + xLIST_ITEM *pxVar1; + int iVar2; + TaskHandle_t ptVar3; + + pxVar1 = pxList->pxIndex->pxNext; + *(xLIST_ITEM **)&pxList->pxIndex = pxVar1; + if (pxVar1 == (xLIST_ITEM *)&pxList->xListEnd) { + pxVar1 = (pxList->xListEnd).pxNext; + *(xLIST_ITEM **)&pxList->pxIndex = pxVar1; + } + ptVar3 = (TaskHandle_t)pxVar1->pvOwner; + iVar2 = 0; + while( true ) { + pxVar1 = pxVar1->pxNext; + *(xLIST_ITEM **)&pxList->pxIndex = pxVar1; + if ((xLIST_ITEM *)&pxList->xListEnd == pxVar1) { + pxVar1 = (pxList->xListEnd).pxNext; + *(xLIST_ITEM **)&pxList->pxIndex = pxVar1; + xTask = (TaskHandle_t)pxVar1->pvOwner; + vTaskGetInfo(xTask,pxTaskStatusArray,1,eState); + } + else { + xTask = (TaskHandle_t)pxVar1->pvOwner; + vTaskGetInfo(xTask,pxTaskStatusArray,1,eState); + } + if (ptVar3 == xTask) break; + iVar2 = iVar2 + 1; + pxTaskStatusArray = pxTaskStatusArray + 1; + pxVar1 = (xLIST_ITEM *)pxList->pxIndex; + } + return iVar2 + 1; +} + + + +UBaseType_t +uxTaskGetSystemState + (TaskStatus_t *pxTaskStatusArray,UBaseType_t uxArraySize,uint32_t *pulTotalRunTime) + +{ + int iVar1; + UBaseType_t UVar2; + int iVar3; + TaskStatus_t *pxTaskStatusArray_00; + UBaseType_t UVar4; + List_t *pxList; + + uxSchedulerSuspended = uxSchedulerSuspended + 1; + UVar4 = 0; + if (uxCurrentNumberOfTasks <= uxArraySize) { + pxList = pxReadyTasksLists + 0x1f; + iVar1 = 0x20; + UVar4 = 0; + iVar3 = 0; + do { + iVar1 = iVar1 + -1; + pxTaskStatusArray_00 = (TaskStatus_t *)(&pxTaskStatusArray->xHandle + iVar3 + UVar4); + if (pxReadyTasksLists[iVar1].uxNumberOfItems != 0) { + UVar2 = prvListTasksWithinSingleList(pxTaskStatusArray_00,pxList,eReady); + UVar4 = UVar4 + UVar2; + iVar3 = UVar4 * 8; + pxTaskStatusArray_00 = pxTaskStatusArray + UVar4; + } + pxList = pxList + -1; + } while (iVar1 != 0); + if (pxDelayedTaskList->uxNumberOfItems != 0) { + UVar2 = prvListTasksWithinSingleList(pxTaskStatusArray_00,pxDelayedTaskList,eBlocked); + UVar4 = UVar4 + UVar2; + pxTaskStatusArray_00 = pxTaskStatusArray + UVar4; + } + if (pxOverflowDelayedTaskList->uxNumberOfItems != 0) { + UVar2 = prvListTasksWithinSingleList(pxTaskStatusArray_00,pxOverflowDelayedTaskList,eBlocked); + UVar4 = UVar4 + UVar2; + pxTaskStatusArray_00 = pxTaskStatusArray + UVar4; + } + if (xTasksWaitingTermination.uxNumberOfItems != 0) { + UVar2 = prvListTasksWithinSingleList(pxTaskStatusArray_00,&xTasksWaitingTermination,eDeleted); + UVar4 = UVar4 + UVar2; + pxTaskStatusArray_00 = pxTaskStatusArray + UVar4; + } + if (xSuspendedTaskList.uxNumberOfItems != 0) { + UVar2 = prvListTasksWithinSingleList(pxTaskStatusArray_00,&xSuspendedTaskList,eSuspended); + UVar4 = UVar4 + UVar2; + } + if (pulTotalRunTime != (uint32_t *)0x0) { + *pulTotalRunTime = 0; + } + } + xTaskResumeAll(); + return UVar4; +} + + + +UBaseType_t uxTaskGetStackHighWaterMark(TaskHandle_t xTask) + +{ + char cVar1; + uint uVar2; + StackType_t *pSVar3; + + if (xTask == (TaskHandle_t)0x0) { + pSVar3 = pxCurrentTCB->pxStack; + cVar1 = *(char *)pSVar3; + } + else { + pSVar3 = xTask->pxStack; + cVar1 = *(char *)pSVar3; + } + if (cVar1 == -0x5b) { + uVar2 = 0; + do { + uVar2 = uVar2 + 1; + } while (*(char *)((int)pSVar3 + uVar2) == -0x5b); + return uVar2 >> 2 & 0xffff; + } + return 0; +} + + + +TaskHandle_t xTaskGetCurrentTaskHandle(void) + +{ + return (TaskHandle_t)pxCurrentTCB; +} + + + +BaseType_t xTaskGetSchedulerState(void) + +{ + BaseType_t BVar1; + + BVar1 = 1; + if (xSchedulerRunning != 0) { + BVar1 = (uint)(uxSchedulerSuspended == 0) << 1; + } + return BVar1; +} + + + +BaseType_t xTaskPriorityInherit(TaskHandle_t pxMutexHolder) + +{ + UBaseType_t UVar1; + uint uVar2; + + if (pxMutexHolder == (TaskHandle_t)0x0) { + return 0; + } + uVar2 = pxMutexHolder->uxPriority; + if (uVar2 < pxCurrentTCB->uxPriority) { + if (-1 < (int)(pxMutexHolder->xEventListItem).xItemValue) { + (pxMutexHolder->xEventListItem).xItemValue = 0x20 - pxCurrentTCB->uxPriority; + } + if ((List_t *)(pxMutexHolder->xStateListItem).pvContainer != pxReadyTasksLists + uVar2) { + pxMutexHolder->uxPriority = pxCurrentTCB->uxPriority; + return 1; + } + UVar1 = uxListRemove(&pxMutexHolder->xStateListItem); + if ((UVar1 == 0) && (pxReadyTasksLists[pxMutexHolder->uxPriority].uxNumberOfItems == 0)) { + uxTopReadyPriority = ~(1 << (pxMutexHolder->uxPriority & 0x1f)) & uxTopReadyPriority; + } + uVar2 = pxCurrentTCB->uxPriority; + uxTopReadyPriority = 1 << (uVar2 & 0x1f) | uxTopReadyPriority; + pxMutexHolder->uxPriority = uVar2; + vListInsertEnd(pxReadyTasksLists + uVar2,&pxMutexHolder->xStateListItem); + uVar2 = 1; + } + else { + uVar2 = (uint)(pxMutexHolder->uxBasePriority < pxCurrentTCB->uxPriority); + } + return uVar2; +} + + + +BaseType_t xTaskPriorityDisinherit(TaskHandle_t pxMutexHolder) + +{ + uint uVar1; + UBaseType_t UVar2; + + if (pxMutexHolder == (TaskHandle_t)0x0) { + return 0; + } + if (pxCurrentTCB != (TCB_t *)pxMutexHolder) { + vAssertCalled(); + } + if (pxMutexHolder->uxMutexesHeld == 0) { + vAssertCalled(); + UVar2 = pxMutexHolder->uxMutexesHeld - 1; + pxMutexHolder->uxMutexesHeld = UVar2; + if (pxMutexHolder->uxPriority == pxMutexHolder->uxBasePriority) { + return 0; + } + } + else { + UVar2 = pxMutexHolder->uxMutexesHeld - 1; + pxMutexHolder->uxMutexesHeld = UVar2; + if (pxMutexHolder->uxPriority == pxMutexHolder->uxBasePriority) { + return 0; + } + } + if (UVar2 != 0) { + return 0; + } + UVar2 = uxListRemove(&pxMutexHolder->xStateListItem); + if ((UVar2 == 0) && (pxReadyTasksLists[pxMutexHolder->uxPriority].uxNumberOfItems == 0)) { + uxTopReadyPriority = ~(1 << (pxMutexHolder->uxPriority & 0x1f)) & uxTopReadyPriority; + } + uVar1 = pxMutexHolder->uxBasePriority; + uxTopReadyPriority = 1 << (uVar1 & 0x1f) | uxTopReadyPriority; + pxMutexHolder->uxPriority = uVar1; + (pxMutexHolder->xEventListItem).xItemValue = 0x20 - uVar1; + vListInsertEnd(pxReadyTasksLists + uVar1,&pxMutexHolder->xStateListItem); + return 1; +} + + + +void vTaskPriorityDisinheritAfterTimeout + (TaskHandle_t pxMutexHolder,UBaseType_t uxHighestPriorityWaitingTask) + +{ + UBaseType_t UVar1; + TickType_t TVar2; + uint uVar3; + int iVar4; + uint uVar5; + + if (pxMutexHolder == (TaskHandle_t)0x0) { + return; + } + if (pxMutexHolder->uxMutexesHeld == 0) { + vAssertCalled(); + uVar5 = pxMutexHolder->uxBasePriority; + } + else { + uVar5 = pxMutexHolder->uxBasePriority; + } + if (uVar5 < uxHighestPriorityWaitingTask) { + uVar3 = pxMutexHolder->uxPriority; + if (uVar3 == uxHighestPriorityWaitingTask) { + return; + } + } + else { + uVar3 = pxMutexHolder->uxPriority; + uxHighestPriorityWaitingTask = uVar5; + if (uVar3 == uVar5) { + return; + } + } + if (pxMutexHolder->uxMutexesHeld == 1) { + if (pxCurrentTCB == (TCB_t *)pxMutexHolder) { + vAssertCalled(); + uVar3 = pxMutexHolder->uxPriority; + } + TVar2 = (pxMutexHolder->xEventListItem).xItemValue; + pxMutexHolder->uxPriority = uxHighestPriorityWaitingTask; + if (-1 < (int)TVar2) { + (pxMutexHolder->xEventListItem).xItemValue = 0x20 - uxHighestPriorityWaitingTask; + } + if ((List_t *)(pxMutexHolder->xStateListItem).pvContainer == pxReadyTasksLists + uVar3) { + UVar1 = uxListRemove(&pxMutexHolder->xStateListItem); + if (UVar1 == 0) { + uVar5 = pxMutexHolder->uxPriority; + iVar4 = uVar5 * 4; + uVar3 = 1 << (uVar5 & 0x1f); + if (pxReadyTasksLists[uVar5].uxNumberOfItems == 0) { + uxTopReadyPriority = ~uVar3 & uxTopReadyPriority; + } + } + else { + uVar5 = pxMutexHolder->uxPriority; + uVar3 = 1 << (uVar5 & 0x1f); + iVar4 = uVar5 << 2; + } + uxTopReadyPriority = uVar3 | uxTopReadyPriority; + vListInsertEnd((List_t *)(&pxReadyTasksLists[0].uxNumberOfItems + iVar4 + uVar5), + &pxMutexHolder->xStateListItem); + return; + } + } + return; +} + + + +void vTaskEnterCritical(void) + +{ + if (xSchedulerRunning == 0) { + return; + } + vTaskEnterCritical(); + return; +} + + + +void vTaskExitCritical(void) + +{ + if ((xSchedulerRunning != 0) && (pxCurrentTCB->uxCriticalNesting != 0)) { + vTaskExitCritical(); + return; + } + return; +} + + + +void vTaskList(char *pcWriteBuffer) + +{ + TaskStatus_t *pTVar1; + TaskStatus_t *pxTaskStatusArray; + UBaseType_t uxArraySize; + size_t sVar2; + char *pcVar3; + uint uVar4; + + uxArraySize = uxCurrentNumberOfTasks; + *pcWriteBuffer = '\0'; + pxTaskStatusArray = (TaskStatus_t *)pvPortMalloc(uxArraySize * 0x24); + if (pxTaskStatusArray != (TaskStatus_t *)0x0) { + uxArraySize = uxTaskGetSystemState(pxTaskStatusArray,uxArraySize,(uint32_t *)0x0); + if (uxArraySize != 0) { + pTVar1 = pxTaskStatusArray; + do { + uVar4 = 0; + if (pTVar1->eCurrentState < eInvalid) { + uVar4 = (uint)(byte)"XRBSD"[pTVar1->eCurrentState]; + } + strcpy(pcWriteBuffer,pTVar1->pcTaskName); + sVar2 = strlen(pcWriteBuffer); + if (sVar2 < 0xf) { + pcVar3 = pcWriteBuffer + sVar2; + do { + *pcVar3 = ' '; + pcVar3 = pcVar3 + 1; + } while (pcWriteBuffer + 0xf != pcVar3); + sVar2 = 0xf; + } + pcWriteBuffer = pcWriteBuffer + sVar2; + *pcWriteBuffer = '\0'; + sprintf(pcWriteBuffer,"\t%c\t%u\t%u\t%u\t%p\r\n",uVar4,pTVar1->uxCurrentPriority, + (uint)pTVar1->usStackHighWaterMark,pTVar1->xTaskNumber,pTVar1->pxStackBase); + sVar2 = strlen(pcWriteBuffer); + pTVar1 = pTVar1 + 1; + pcWriteBuffer = pcWriteBuffer + sVar2; + } while (pTVar1 != pxTaskStatusArray + uxArraySize); + } + vPortFree(pxTaskStatusArray); + return; + } + return; +} + + + +TickType_t uxTaskResetEventItemValue(void) + +{ + TickType_t TVar1; + + TVar1 = (pxCurrentTCB->xEventListItem).xItemValue; + (pxCurrentTCB->xEventListItem).xItemValue = 0x20 - pxCurrentTCB->uxPriority; + return TVar1; +} + + + +TaskHandle_t pvTaskIncrementMutexHeldCount(void) + +{ + if (pxCurrentTCB != (TCB_t *)0x0) { + pxCurrentTCB->uxMutexesHeld = pxCurrentTCB->uxMutexesHeld + 1; + } + return (TaskHandle_t)pxCurrentTCB; +} + + +/* +Unable to decompile 'ulTaskNotifyTake' +Cause: Exception while decompiling 2303116c: Decompiler process died + +*/ + +/* +Unable to decompile 'xTaskNotifyWait' +Cause: Exception while decompiling 23031212: Decompiler process died + +*/ + +/* +Unable to decompile 'xTaskGenericNotify' +Cause: +Low-level Error: Assignment to constant at r0x2303130c +*/ + + +BaseType_t +xTaskGenericNotifyFromISR + (TaskHandle_t xTaskToNotify,uint32_t ulValue,eNotifyAction eAction, + uint32_t *pulPreviousNotificationValue,BaseType_t *pxHigherPriorityTaskWoken) + +{ + uint8_t uVar1; + undefined3 in_register_00002031; + + if (xTaskToNotify == (TaskHandle_t)0x0) { + vAssertCalled(); + } + if (pulPreviousNotificationValue != (uint32_t *)0x0) { + *pulPreviousNotificationValue = xTaskToNotify->ulNotifiedValue; + } + uVar1 = xTaskToNotify->ucNotifyState; + xTaskToNotify->ucNotifyState = '\x02'; + switch(CONCAT31(in_register_00002031,eAction)) { + case 0: + break; + case 1: + xTaskToNotify->ulNotifiedValue = ulValue | xTaskToNotify->ulNotifiedValue; + break; + case 2: + xTaskToNotify->ulNotifiedValue = xTaskToNotify->ulNotifiedValue + 1; + break; + case 4: + if (uVar1 == '\x02') { + return 0; + } + case 3: + xTaskToNotify->ulNotifiedValue = ulValue; + break; + default: + if (xTaskToNotify->ulNotifiedValue != 0xffffffff) { + vAssertCalled(); + } + } + if (uVar1 == '\x01') { + if ((xTaskToNotify->xEventListItem).pvContainer != (xLIST *)0x0) { + vAssertCalled(); + } + if (uxSchedulerSuspended == 0) { + uxListRemove(&xTaskToNotify->xStateListItem); + uxTopReadyPriority = 1 << (xTaskToNotify->uxPriority & 0x1f) | uxTopReadyPriority; + vListInsertEnd(pxReadyTasksLists + xTaskToNotify->uxPriority,&xTaskToNotify->xStateListItem); + } + else { + vListInsertEnd(&xPendingReadyList,&xTaskToNotify->xEventListItem); + } + if (pxCurrentTCB->uxPriority < xTaskToNotify->uxPriority) { + if (pxHigherPriorityTaskWoken != (BaseType_t *)0x0) { + *pxHigherPriorityTaskWoken = 1; + } + xYieldPending = 1; + } + } + return 1; +} + + + +void vTaskNotifyGiveFromISR(TaskHandle_t xTaskToNotify,BaseType_t *pxHigherPriorityTaskWoken) + +{ + uint8_t uVar1; + + if (xTaskToNotify == (TaskHandle_t)0x0) { + vAssertCalled(); + } + uVar1 = xTaskToNotify->ucNotifyState; + xTaskToNotify->ucNotifyState = '\x02'; + xTaskToNotify->ulNotifiedValue = xTaskToNotify->ulNotifiedValue + 1; + if (uVar1 == '\x01') { + if ((xTaskToNotify->xEventListItem).pvContainer != (xLIST *)0x0) { + vAssertCalled(); + } + if (uxSchedulerSuspended == 0) { + uxListRemove(&xTaskToNotify->xStateListItem); + uxTopReadyPriority = 1 << (xTaskToNotify->uxPriority & 0x1f) | uxTopReadyPriority; + vListInsertEnd(pxReadyTasksLists + xTaskToNotify->uxPriority,&xTaskToNotify->xStateListItem); + } + else { + vListInsertEnd(&xPendingReadyList,&xTaskToNotify->xEventListItem); + } + if (pxCurrentTCB->uxPriority < xTaskToNotify->uxPriority) { + if (pxHigherPriorityTaskWoken != (BaseType_t *)0x0) { + *pxHigherPriorityTaskWoken = 1; + } + xYieldPending = 1; + return; + } + } + return; +} + + + +BaseType_t xTaskNotifyStateClear(TaskHandle_t xTask) + +{ + bool bVar1; + + if (xTask == (TaskHandle_t)0x0) { + xTask = (TaskHandle_t)pxCurrentTCB; + } + if (xSchedulerRunning != 0) { + vTaskEnterCritical(); + } + bVar1 = ((TCB_t *)xTask)->ucNotifyState == '\x02'; + if (bVar1) { + ((TCB_t *)xTask)->ucNotifyState = '\0'; + } + if ((xSchedulerRunning != 0) && (pxCurrentTCB->uxCriticalNesting != 0)) { + vTaskExitCritical(); + } + return (uint)bVar1; +} + + + +void prvCheckForValidListAndQueue(void) + +{ + uint8_t ucStaticTimerQueueStorage [64]; + StaticQueue_t xStaticTimerQueue; + + vTaskEnterCritical(); + if (xTimerQueue == (QueueHandle_t)0x0) { + vListInitialise(&xActiveTimerList1); + vListInitialise(&xActiveTimerList2); + pxCurrentTimerList = &xActiveTimerList1; + pxOverflowTimerList = &xActiveTimerList2; + xTimerQueue = xQueueGenericCreateStatic + (4,0x10,ucStaticTimerQueueStorage,&xStaticTimerQueue,'\0'); + if (xTimerQueue != (QueueHandle_t)0x0) { + vQueueAddToRegistry(xTimerQueue,"TmrQ"); + } + } + vTaskExitCritical(); + return; +} + + + +BaseType_t +prvInsertTimerInActiveList + (Timer_t *pxTimer,TickType_t xNextExpiryTime,TickType_t xTimeNow,TickType_t xCommandTime) + +{ + (pxTimer->xTimerListItem).xItemValue = xNextExpiryTime; + *(Timer_t **)&(pxTimer->xTimerListItem).pvOwner = pxTimer; + if (xTimeNow < xNextExpiryTime) { + if ((xCommandTime <= xTimeNow) || (xNextExpiryTime < xCommandTime)) { + vListInsert(pxCurrentTimerList,&pxTimer->xTimerListItem); + return 0; + } + } + else { + if (xTimeNow - xCommandTime < pxTimer->xTimerPeriodInTicks) { + vListInsert(pxOverflowTimerList,&pxTimer->xTimerListItem); + return 0; + } + } + return 1; +} + + + +BaseType_t xTimerCreateTimerTask(void) + +{ + StaticTask_t *pSStack28; + StaticTask_t *pxTimerTaskTCBBuffer; + StackType_t *pxTimerTaskStackBuffer; + uint32_t ulTimerTaskStackSize; + + prvCheckForValidListAndQueue(); + if (xTimerQueue != (QueueHandle_t)0x0) { + pSStack28 = (StaticTask_t *)0x0; + pxTimerTaskTCBBuffer = (StaticTask_t *)0x0; + vApplicationGetTimerTaskMemory + (&pSStack28,(StackType_t **)&pxTimerTaskTCBBuffer,(uint32_t *)&pxTimerTaskStackBuffer) + ; + xTimerTaskHandle = + xTaskCreateStatic(prvTimerTask,"Tmr Svc",(uint32_t)pxTimerTaskStackBuffer,(void *)0x0,0x1f, + (StackType_t *)pxTimerTaskTCBBuffer,pSStack28); + if (xTimerTaskHandle != (TaskHandle_t)0x0) { + return 1; + } + } + vAssertCalled(); + return 0; +} + + + +// WARNING: Removing unreachable block (ram,0x230317ba) + +TimerHandle_t +xTimerCreateStatic(char *pcTimerName,TickType_t xTimerPeriodInTicks,UBaseType_t uxAutoReload, + void *pvTimerID,TimerCallbackFunction_t *pxCallbackFunction, + StaticTimer_t *pxTimerBuffer) + +{ + size_t xSize; + + if (pxTimerBuffer == (StaticTimer_t *)0x0) { + vAssertCalled(0x2c); + } + else { + pxTimerBuffer->ucDummy8 = '\x02'; + if (xTimerPeriodInTicks == 0) { + vAssertCalled(); + } + prvCheckForValidListAndQueue(); + *(char **)&pxTimerBuffer->pvDummy1 = pcTimerName; + pxTimerBuffer->xDummy3 = xTimerPeriodInTicks; + pxTimerBuffer->pvDummy5 = pvTimerID; + *(TimerCallbackFunction_t **)&pxTimerBuffer->pvDummy6 = pxCallbackFunction; + vListInitialiseItem((ListItem_t *)&pxTimerBuffer->xDummy2); + if (uxAutoReload != 0) { + pxTimerBuffer->ucDummy8 = pxTimerBuffer->ucDummy8 | 4; + } + } + return (TimerHandle_t)pxTimerBuffer; +} + + + +// WARNING: Could not reconcile some variable overlaps + +BaseType_t +xTimerGenericCommand + (TimerHandle_t xTimer,BaseType_t xCommandID,TickType_t xOptionalValue, + BaseType_t *pxHigherPriorityTaskWoken,TickType_t xTicksToWait) + +{ + BaseType_t BVar1; + BaseType_t BStack48; + DaemonTaskMessage_t xMessage; + + if (xTimer == (TimerHandle_t)0x0) { + vAssertCalled(); + } + BVar1 = 0; + if (xTimerQueue != (QueueHandle_t)0x0) { + BStack48 = xCommandID; + xMessage.xMessageID = xOptionalValue; + xMessage.u._0_4_ = xTimer; + if (5 < xCommandID) { + BVar1 = xQueueGenericSendFromISR(xTimerQueue,&BStack48,pxHigherPriorityTaskWoken,0); + return BVar1; + } + BVar1 = xTaskGetSchedulerState(); + if (BVar1 == 2) { + BVar1 = xQueueGenericSend(xTimerQueue,&BStack48,xTicksToWait,0); + return BVar1; + } + BVar1 = xQueueGenericSend(xTimerQueue,&BStack48,0,0); + } + return BVar1; +} + + + +void prvSwitchTimerLists(void) + +{ + List_t *pxList; + TimerHandle_t xTimer; + BaseType_t BVar1; + xLIST_ITEM *pxVar2; + uint uVar3; + uint xOptionalValue; + + while (pxList = pxCurrentTimerList, pxCurrentTimerList->uxNumberOfItems != 0) { + pxVar2 = (pxCurrentTimerList->xListEnd).pxNext; + xTimer = (TimerHandle_t)pxVar2->pvOwner; + xOptionalValue = pxVar2->xItemValue; + uxListRemove(&xTimer->xTimerListItem); + (*xTimer->pxCallbackFunction)(xTimer); + pxList = pxCurrentTimerList; + if ((xTimer->ucStatus & 4) != 0) { + uVar3 = xTimer->xTimerPeriodInTicks + xOptionalValue; + if (xOptionalValue < uVar3) { + (xTimer->xTimerListItem).xItemValue = uVar3; + *(TimerHandle_t *)&(xTimer->xTimerListItem).pvOwner = xTimer; + vListInsert(pxList,&xTimer->xTimerListItem); + } + else { + BVar1 = xTimerGenericCommand(xTimer,0,xOptionalValue,(BaseType_t *)0x0,0); + if (BVar1 == 0) { + vAssertCalled(); + } + } + } + } + pxCurrentTimerList = pxOverflowTimerList; + pxOverflowTimerList = pxList; + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void prvTimerTask(void *pvParameters) + +{ + uint xTimeNow; + BaseType_t BVar1; + TickType_t xTimeNow_00; + TickType_t TVar2; + uint xWaitIndefinitely; + UBaseType_t xCommandTime; + Timer_t *pxTimer; + uint uStack64; + DaemonTaskMessage_t xMessage; + + do { + xCommandTime = pxCurrentTimerList->uxNumberOfItems; + if (xCommandTime == 0) { + vTaskSuspendAll(pvParameters); + xTimeNow = xTaskGetTickCount(); + if (xTimeNow < xLastTime_2297) goto LAB_23031aa2; + xWaitIndefinitely = (uint)(pxOverflowTimerList->uxNumberOfItems == 0); +LAB_2303199c: + xLastTime_2297 = xTimeNow; + vQueueWaitForMessageRestricted(xTimerQueue,xCommandTime - xTimeNow,xWaitIndefinitely); + BVar1 = xTaskResumeAll(); + if (BVar1 == 0) { + ecall(); + } + } + else { + xCommandTime = ((pxCurrentTimerList->xListEnd).pxNext)->xItemValue; + vTaskSuspendAll(pvParameters); + xTimeNow = xTaskGetTickCount(); + if (xTimeNow < xLastTime_2297) { +LAB_23031aa2: + prvSwitchTimerLists(); + xLastTime_2297 = xTimeNow; + xTaskResumeAll(); + } + else { + xWaitIndefinitely = 0; + if (xTimeNow < xCommandTime) goto LAB_2303199c; + xLastTime_2297 = xTimeNow; + xTaskResumeAll(); + pxTimer = (Timer_t *)((pxCurrentTimerList->xListEnd).pxNext)->pvOwner; + uxListRemove(&pxTimer->xTimerListItem); + if ((pxTimer->ucStatus & 4) == 0) { + pxTimer->ucStatus = pxTimer->ucStatus & 0xfe; + } + else { + BVar1 = prvInsertTimerInActiveList + (pxTimer,pxTimer->xTimerPeriodInTicks + xCommandTime,xTimeNow, + xCommandTime); + if ((BVar1 != 0) && + (BVar1 = xTimerGenericCommand + ((TimerHandle_t)pxTimer,0,xCommandTime,(BaseType_t *)0x0,0), + BVar1 == 0)) { + vAssertCalled(); + } + } + (*pxTimer->pxCallbackFunction)((TimerHandle_t)pxTimer); + } + } + while (pvParameters = (void *)xQueueReceive(xTimerQueue,&uStack64,0), + pvParameters != (void *)0x0) { + if ((-1 < (int)uStack64) || + ((*(code *)xMessage.xMessageID)((Timer_t *)xMessage.u,xMessage.u._4_4_,xMessage.xMessageID) + , -1 < (int)uStack64)) { + pxTimer = (Timer_t *)xMessage.u; + if ((((Timer_t *)xMessage.u)->xTimerListItem).pvContainer != (xLIST *)0x0) { + uxListRemove(&((Timer_t *)xMessage.u)->xTimerListItem); + } + xTimeNow_00 = xTaskGetTickCount(); + if (xTimeNow_00 < xLastTime_2297) { + prvSwitchTimerLists(); + } + xLastTime_2297 = xTimeNow_00; + switch(uStack64) { + case 0: + case 1: + case 2: + case 6: + case 7: + pxTimer->ucStatus = pxTimer->ucStatus | 1; + BVar1 = prvInsertTimerInActiveList + (pxTimer,pxTimer->xTimerPeriodInTicks + xMessage.xMessageID,xTimeNow_00, + xMessage.xMessageID); + if (((BVar1 != 0) && + ((*pxTimer->pxCallbackFunction)((TimerHandle_t)pxTimer), (pxTimer->ucStatus & 4) != 0) + ) && (BVar1 = xTimerGenericCommand + ((TimerHandle_t)pxTimer,0, + xMessage.xMessageID + pxTimer->xTimerPeriodInTicks, + (BaseType_t *)0x0,0), BVar1 == 0)) { + vAssertCalled(); + } + break; + case 3: + case 8: + pxTimer->ucStatus = pxTimer->ucStatus & 0xfe; + break; + case 4: + case 9: + pxTimer->ucStatus = pxTimer->ucStatus | 1; + pxTimer->xTimerPeriodInTicks = xMessage.xMessageID; + TVar2 = xMessage.xMessageID; + if (xMessage.xMessageID == 0) { + vAssertCalled(); + TVar2 = pxTimer->xTimerPeriodInTicks; + } + prvInsertTimerInActiveList(pxTimer,TVar2 + xTimeNow_00,xTimeNow_00,xTimeNow_00); + break; + case 5: + if ((pxTimer->ucStatus & 2) == 0) { + vPortFree(pxTimer); + } + else { + pxTimer->ucStatus = pxTimer->ucStatus & 0xfe; + } + } + } + } + } while( true ); +} + + + +void * pvTimerGetTimerID(TimerHandle_t xTimer) + +{ + void *pvVar1; + + if (xTimer == (TimerHandle_t)0x0) { + vAssertCalled(); + } + vTaskEnterCritical(); + pvVar1 = xTimer->pvTimerID; + vTaskExitCritical(); + return pvVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void vPortSetupTimerInterrupt(void) + +{ + _DAT_02004000 = _DAT_0200bff8 + 10000; + _DAT_02004004 = (uint)(_DAT_0200bff8 + 10000 < _DAT_0200bff8) + _DAT_0200bffc; + ullNextTime._0_4_ = _DAT_0200bff8 + 20000; + ullNextTime._4_4_ = _DAT_0200bffc + (uint)(_DAT_0200bff8 + 20000 < _DAT_0200bff8); + return; +} + + +/* +Unable to decompile 'xPortStartScheduler' +Cause: Exception while decompiling 23031b92: Decompiler process died + +*/ + +/* +Unable to decompile 'xPortStartFirstTask' +Cause: Exception while decompiling 23031f00: Decompiler process died + +*/ + + +// WARNING: Removing unreachable block (ram,0x23032000) + +void pxPortInitialiseStack(int param_1,undefined4 param_2,undefined4 param_3) + +{ + int iVar1; + undefined4 *puVar2; + uint in_mstatus; + + *(uint *)(param_1 + -4) = in_mstatus & 0xfffffff7 | 0x1880; + *(undefined4 *)(param_1 + -0x5c) = param_3; + puVar2 = (undefined4 *)(param_1 + -0x74); + *puVar2 = 0; + iVar1 = 0x22; + while (iVar1 != 0) { + puVar2 = puVar2 + -1; + *puVar2 = 0; + iVar1 = iVar1 + -1; + } + puVar2[-1] = param_2; + return; +} + + + +void prvInsertBlockIntoFreeList(BlockLink_t *pxBlockToInsert) + +{ + size_t sVar1; + BlockLink_t *pBVar2; + BlockLink_t *pBVar3; + + pBVar3 = &xStart; + do { + pBVar2 = pBVar3; + pBVar3 = (BlockLink_t *)pBVar2->pxNextFreeBlock; + } while (pBVar3 < pxBlockToInsert); + sVar1 = pxBlockToInsert->xBlockSize; + if (pxBlockToInsert == (BlockLink_t *)(pBVar2->xBlockSize + (int)&pBVar2->pxNextFreeBlock)) { + sVar1 = pBVar2->xBlockSize + sVar1; + pBVar2->xBlockSize = sVar1; + pxBlockToInsert = pBVar2; + } + if ((pBVar3 == (BlockLink_t *)(sVar1 + (int)&pxBlockToInsert->pxNextFreeBlock)) && + (pBVar3 != pxEnd)) { + pxBlockToInsert->xBlockSize = sVar1 + pBVar3->xBlockSize; + pxBlockToInsert->pxNextFreeBlock = pBVar2->pxNextFreeBlock->pxNextFreeBlock; + } + else { + *(BlockLink_t **)&pxBlockToInsert->pxNextFreeBlock = pBVar3; + } + if (pxBlockToInsert != pBVar2) { + *(BlockLink_t **)&pBVar2->pxNextFreeBlock = pxBlockToInsert; + } + return; +} + + + +void * pvPortMalloc(size_t xWantedSize) + +{ + size_t sVar1; + size_t sVar2; + BlockLink_t *pBVar3; + A_BLOCK_LINK *pAVar4; + BlockLink_t *pxBlockToInsert; + uint uVar5; + uint uVar6; + + if (pxEnd == (BlockLink_t *)0x0) { + vAssertCalled(); + } + vTaskSuspendAll(); + sVar2 = xFreeBytesRemaining; + sVar1 = xBlockAllocatedBit; + if (((xBlockAllocatedBit & xWantedSize) == 0) && (xWantedSize != 0)) { + uVar6 = xWantedSize + 8; + if ((uVar6 & 7) != 0) { + uVar6 = (uVar6 & 0xfffffff8) + 8; + } + if ((uVar6 != 0) && (uVar6 <= xFreeBytesRemaining)) { + pAVar4 = xStart.pxNextFreeBlock; + pBVar3 = &xStart; + do { + pxBlockToInsert = pBVar3; + pBVar3 = (BlockLink_t *)pAVar4; + if (uVar6 <= pBVar3->xBlockSize) break; + pAVar4 = pBVar3->pxNextFreeBlock; + } while (pBVar3->pxNextFreeBlock != (A_BLOCK_LINK *)0x0); + if (pxEnd != pBVar3) { + pAVar4 = pxBlockToInsert->pxNextFreeBlock; + pxBlockToInsert->pxNextFreeBlock = pBVar3->pxNextFreeBlock; + uVar5 = pBVar3->xBlockSize; + pAVar4 = pAVar4 + 1; + if (0x10 < uVar5 - uVar6) { + pxBlockToInsert = (BlockLink_t *)((int)&pBVar3->pxNextFreeBlock + uVar6); + pxBlockToInsert->xBlockSize = uVar5 - uVar6; + pBVar3->xBlockSize = uVar6; + prvInsertBlockIntoFreeList(pxBlockToInsert); + uVar5 = pBVar3->xBlockSize; + } + xFreeBytesRemaining = sVar2 - uVar5; + if (xFreeBytesRemaining < xMinimumEverFreeBytesRemaining) { + xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; + } + pBVar3->xBlockSize = sVar1 | uVar5; + pBVar3->pxNextFreeBlock = (A_BLOCK_LINK *)0x0; + xTaskResumeAll(); + if (pAVar4 != (A_BLOCK_LINK *)0x0) { + return pAVar4; + } + goto LAB_230321be; + } + } + } + xTaskResumeAll(); +LAB_230321be: + vApplicationMallocFailedHook(); + return (void *)0x0; +} + + + +void vPortFree(void *pv) + +{ + uint uVar1; + + if (pv == (void *)0x0) { + return; + } + uVar1 = *(uint *)((int)pv + -4); + if ((uVar1 & xBlockAllocatedBit) == 0) { + vAssertCalled(); + if (*(int *)((int)pv + -8) == 0) { + uVar1 = *(uint *)((int)pv + -4); + if ((uVar1 & xBlockAllocatedBit) == 0) { + return; + } + goto LAB_230322ce; + } + } + else { + if (*(int *)((int)pv + -8) == 0) goto LAB_230322ce; + } + vAssertCalled(); + uVar1 = *(uint *)((int)pv + -4); + if (((uVar1 & xBlockAllocatedBit) == 0) || (*(int *)((int)pv + -8) != 0)) { + return; + } +LAB_230322ce: + *(uint *)((int)pv + -4) = ~xBlockAllocatedBit & uVar1; + vTaskSuspendAll(); + xFreeBytesRemaining = *(int *)((int)pv + -4) + xFreeBytesRemaining; + prvInsertBlockIntoFreeList((BlockLink_t *)((int)pv + -8)); + xTaskResumeAll(); + return; +} + + + +size_t xPortGetFreeHeapSize(void) + +{ + return xFreeBytesRemaining; +} + + + +void vPortDefineHeapRegions(HeapRegion_t *pxHeapRegions) + +{ + size_t sVar1; + BlockLink_t *pBVar2; + BlockLink_t *pBVar3; + BlockLink_t *pBVar4; + A_BLOCK_LINK *pAVar5; + int iVar6; + size_t sVar7; + + if (pxEnd == (BlockLink_t *)0x0) { + sVar1 = pxHeapRegions->xSizeInBytes; + pBVar4 = pxEnd; + } + else { + vAssertCalled(); + sVar1 = pxHeapRegions->xSizeInBytes; + pBVar4 = pxEnd; + } + pxEnd = pBVar4; + if (sVar1 == 0) { + xMinimumEverFreeBytesRemaining = 0; + } + else { + iVar6 = 0; + sVar7 = 0; + do { + pBVar3 = (BlockLink_t *)pxHeapRegions->pucStartAddress; + pBVar2 = pBVar3; + if (((uint)pBVar3 & 7) != 0) { + pBVar2 = (BlockLink_t *)((int)&pBVar3->xBlockSize + 3U & 0xfffffff8); + sVar1 = (int)pBVar3 + (sVar1 - (int)pBVar2); + } + if (iVar6 == 0) { + xStart.xBlockSize = 0; + pBVar3 = pBVar4; + xStart.pxNextFreeBlock = (A_BLOCK_LINK *)pBVar2; + } + else { + if (pBVar4 == (BlockLink_t *)0x0) { + vAssertCalled(); + pBVar4 = pxEnd; + } + pBVar3 = pBVar4; + if (pBVar2 <= pBVar4) { + vAssertCalled(); + pBVar3 = pxEnd; + } + } + pBVar4 = (BlockLink_t *)((int)&pBVar2[-1].pxNextFreeBlock + sVar1 & 0xfffffff8); + ((A_BLOCK_LINK *)pBVar4)->xBlockSize = 0; + ((A_BLOCK_LINK *)pBVar4)->pxNextFreeBlock = (A_BLOCK_LINK *)0x0; + pAVar5 = (A_BLOCK_LINK *)((int)pBVar4 - (int)pBVar2); + pxEnd = pBVar4; + *(A_BLOCK_LINK **)&pBVar2->xBlockSize = pAVar5; + *(BlockLink_t **)&pBVar2->pxNextFreeBlock = pBVar4; + if (pBVar3 != (BlockLink_t *)0x0) { + *(BlockLink_t **)&pBVar3->pxNextFreeBlock = pBVar2; + pAVar5 = (A_BLOCK_LINK *)pBVar2->xBlockSize; + } + sVar1 = pxHeapRegions[1].xSizeInBytes; + sVar7 = (int)&pAVar5->pxNextFreeBlock + sVar7; + iVar6 = iVar6 + 1; + pxHeapRegions = pxHeapRegions + 1; + } while (sVar1 != 0); + xMinimumEverFreeBytesRemaining = sVar7; + if (sVar7 != 0) { + xBlockAllocatedBit = 0x80000000; + xFreeBytesRemaining = sVar7; + return; + } + } + xFreeBytesRemaining = xMinimumEverFreeBytesRemaining; + vAssertCalled(); + xBlockAllocatedBit = 0x80000000; + return; +} + + + +void uart_generic_notify_handler(uint8_t id) + +{ + uint uVar1; + uint uVar2; + undefined3 in_register_00002029; + int iVar3; + uint32_t uVar4; + + iVar3 = CONCAT31(in_register_00002029,id); + uVar4 = uartAddr[iVar3]; + uVar2 = *(uint *)(uVar4 + 0x20); + uVar1 = *(uint *)(uVar4 + 0x24); + if (((uVar2 & 1) != 0) && ((uVar1 & 1) == 0)) { + *(undefined4 *)(uVar4 + 0x28) = 1; + } + if (((uVar2 & 2) != 0) && ((uVar1 & 2) == 0)) { + *(undefined4 *)(uVar4 + 0x28) = 2; + if (g_uart_notify_arg[iVar3].rx_cb != (cb_uart_notify_t *)0x0) { + (*g_uart_notify_arg[iVar3].rx_cb)(g_uart_notify_arg[iVar3].rx_cb_arg); + } + } + if (((uVar2 & 4) != 0) && ((uVar1 & 4) == 0)) { + if (g_uart_notify_arg[iVar3].tx_cb != (cb_uart_notify_t *)0x0) { + (*g_uart_notify_arg[iVar3].tx_cb)(g_uart_notify_arg[iVar3].tx_cb_arg); + } + } + if (((uVar2 & 8) != 0) && ((uVar1 & 8) == 0)) { + if (g_uart_notify_arg[iVar3].rx_cb != (cb_uart_notify_t *)0x0) { + (*g_uart_notify_arg[iVar3].rx_cb)(g_uart_notify_arg[iVar3].rx_cb_arg); + } + } + if (((uVar2 & 0x10) != 0) && ((uVar1 & 0x10) == 0)) { + *(undefined4 *)(uVar4 + 0x28) = 0x10; + if (g_uart_notify_arg[iVar3].rx_cb != (cb_uart_notify_t *)0x0) { + (*g_uart_notify_arg[iVar3].rx_cb)(g_uart_notify_arg[iVar3].rx_cb_arg); + } + } + if (((uVar2 & 0x20) != 0) && ((uVar1 & 0x20) == 0)) { + *(undefined4 *)(uVar4 + 0x28) = 0x20; + } + return; +} + + + +void UART0_IRQHandler(void) + +{ + uart_generic_notify_handler('\0'); + return; +} + + + +void UART1_IRQHandler(void) + +{ + uart_generic_notify_handler('\x01'); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bl_uart_init(uint8_t id,uint8_t tx_pin,uint8_t rx_pin,uint8_t cts_pin,uint8_t rts_pin, + uint32_t baudrate) + +{ + uint8_t uart_clk_init; + GLB_UART_SIG_FUN_Type fun; + undefined3 in_register_00002029; + GLB_UART_SIG_FUN_Type fun_00; + UART_FifoCfg_Type UStack60; + UART_FifoCfg_Type fifoCfg; + GLB_GPIO_Cfg_Type cfg; + UART_CFG_Type uartCfg; + + memcpy(&cfg.drive,&DAT_23082820,0x10); + UStack60 = DAT_4200d9c0; + if (uart_clk_init == '\0') { + GLB_Set_UART_CLK('\x01',HBN_UART_CLK_160M,'\x03'); + uart_clk_init = '\x01'; + } + fifoCfg.rxFifoDmaThreshold = '\a'; + fifoCfg._2_2_ = 2; + cfg._0_2_ = 0x101; + fifoCfg.txFifoDmaThreshold = rx_pin; + GLB_GPIO_Init((GLB_GPIO_Cfg_Type *)&fifoCfg); + fifoCfg._2_2_ = 2; + fifoCfg.txFifoDmaThreshold = tx_pin; + GLB_GPIO_Init((GLB_GPIO_Cfg_Type *)&fifoCfg); + if (CONCAT31(in_register_00002029,id) == 0) { + fun = GLB_UART_SIG_FUN_UART0_RXD; + fun_00 = GLB_UART_SIG_FUN_UART0_TXD; + } + else { + fun = GLB_UART_SIG_FUN_UART1_RXD; + fun_00 = GLB_UART_SIG_FUN_UART1_TXD; + } + GLB_UART_Fun_Sel(tx_pin & 7,fun_00); + GLB_UART_Fun_Sel(rx_pin & 7,fun); + stack0xffffffd0 = 40000000; + UART_IntMask(id,UART_INT_ALL,MASK); + UART_Disable(id,UART_TXRX); + UART_Init(id,(UART_CFG_Type *)&cfg.drive); + UART_TxFreeRun(id,ENABLE); + UART_FifoConfig(id,&UStack60); + UART_Enable(id,UART_TXRX); + return 0; +} + + + +int bl_uart_data_send(uint8_t id,uint8_t data) + +{ + uint32_t uVar1; + uint8_t uVar2; + undefined3 in_register_00002029; + undefined3 extraout_var; + + uVar1 = uartAddr[CONCAT31(in_register_00002029,id)]; + do { + uVar2 = UART_GetTxFifoCount(id); + } while (CONCAT31(extraout_var,uVar2) == 0); + *(uint8_t *)(uVar1 + 0x88) = data; + return 0; +} + + + +int bl_uart_data_recv(uint8_t id) + +{ + uint32_t uVar1; + uint8_t uVar2; + undefined3 in_register_00002029; + undefined3 extraout_var; + uint uVar3; + + uVar1 = uartAddr[CONCAT31(in_register_00002029,id)]; + uVar2 = UART_GetRxFifoCount(id); + if (CONCAT31(extraout_var,uVar2) == 0) { + uVar3 = 0xffffffff; + } + else { + uVar3 = (uint)*(byte *)(uVar1 + 0x8c); + } + return uVar3; +} + + + +int bl_uart_int_rx_enable(uint8_t id) + +{ + UART_SetRxTimeoutValue(id,'\x18'); + UART_IntMask(id,UART_INT_RX_FIFO_REQ,UNMASK); + UART_IntMask(id,UART_INT_RX_END,UNMASK); + UART_IntMask(id,UART_INT_RTO,UNMASK); + return 0; +} + + + +int bl_uart_int_rx_disable(uint8_t id) + +{ + UART_IntMask(id,UART_INT_RX_FIFO_REQ,MASK); + UART_IntMask(id,UART_INT_RX_END,MASK); + UART_IntMask(id,UART_INT_RTO,MASK); + return 0; +} + + + +int bl_uart_int_tx_enable(uint8_t id) + +{ + UART_IntMask(id,UART_INT_TX_FIFO_REQ,UNMASK); + return 0; +} + + + +int bl_uart_int_tx_disable(uint8_t id) + +{ + UART_IntMask(id,UART_INT_TX_FIFO_REQ,MASK); + return 0; +} + + + +int bl_uart_flush(uint8_t id) + +{ + uint8_t uVar1; + undefined3 extraout_var; + + do { + uVar1 = UART_GetTxFifoCount(id); + } while (CONCAT31(extraout_var,uVar1) != 0x20); + return 0; +} + + + +void bl_uart_getdefconfig(uint8_t id,uint8_t *parity) + +{ + if (parity != (uint8_t *)0x0) { + *parity = '\0'; + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: UartCfg +// WARNING: Could not reconcile some variable overlaps + +void bl_uart_setconfig(uint8_t id,uint32_t baudrate,UART_Parity_Type parity) + +{ + undefined auStack32 [4]; + UART_CFG_Type UartCfg; + + memcpy(auStack32,&DAT_23082830,0x10); + UartCfg.uartClk = baudrate; + UartCfg.baudRate._2_1_ = parity; + UART_Disable(id,UART_TXRX); + UART_Init(id,(UART_CFG_Type *)auStack32); + UART_TxFreeRun(id,ENABLE); + UART_Enable(id,UART_TXRX); + return; +} + + + +void bl_uart_setbaud(uint8_t id,uint32_t baud) + +{ + bl_uart_setconfig(id,baud,UART_PARITY_NONE); + return; +} + + + +int bl_uart_int_enable(uint8_t id) + +{ + undefined3 in_register_00002029; + uint source; + + if (CONCAT31(in_register_00002029,id) == 0) { + bl_uart_int_rx_enable(id); + bl_uart_int_tx_enable('\0'); + bl_irq_register(0x2d,UART0_IRQHandler); + source = 0x2d; + } + else { + if (CONCAT31(in_register_00002029,id) != 1) { + return -1; + } + bl_uart_int_rx_enable(id); + bl_uart_int_tx_enable('\x01'); + bl_irq_register(0x2e,UART1_IRQHandler); + source = 0x2e; + } + bl_irq_enable(source); + return 0; +} + + + +int bl_uart_int_disable(uint8_t id) + +{ + undefined3 in_register_00002029; + uint source; + + if (CONCAT31(in_register_00002029,id) == 0) { + bl_uart_int_rx_disable(id); + bl_uart_int_tx_disable('\0'); + bl_irq_unregister(0x2d,UART0_IRQHandler); + source = 0x2d; + } + else { + if (CONCAT31(in_register_00002029,id) != 1) { + return -1; + } + bl_uart_int_rx_disable(id); + bl_uart_int_tx_disable('\x01'); + bl_irq_unregister(0x2e,UART1_IRQHandler); + source = 0x2e; + } + bl_irq_disable(source); + return 0; +} + + + +int bl_uart_int_rx_notify_register(uint8_t id,cb_uart_notify_t *cb,void *arg) + +{ + undefined3 in_register_00002029; + uint uVar1; + + uVar1 = CONCAT31(in_register_00002029,id); + if (uVar1 < 2) { + g_uart_notify_arg[uVar1].rx_cb = cb; + g_uart_notify_arg[uVar1].rx_cb_arg = arg; + return 0; + } + return -1; +} + + + +int bl_uart_int_tx_notify_register(uint8_t id,cb_uart_notify_t *cb,void *arg) + +{ + undefined3 in_register_00002029; + uint uVar1; + + uVar1 = CONCAT31(in_register_00002029,id); + if (uVar1 < 2) { + g_uart_notify_arg[uVar1].tx_cb = cb; + g_uart_notify_arg[uVar1].tx_cb_arg = arg; + return 0; + } + return -1; +} + + + +// WARNING: Removing unreachable block (ram,0x23032876) + +int bl_chip_info(char *info) + +{ + char *pcVar1; + undefined *__src; + uint uVar2; + uint in_register_90000c04; + uint32_t misa; + + uVar2 = in_register_90000c04 >> 0x1e; + if (uVar2 == 2) { + memcpy(info,&DAT_23082b04,4); + pcVar1 = info + 4; + } + else { + if (uVar2 == 3) { + memcpy(info,"RV128",5); + pcVar1 = info + 5; + } + else { + pcVar1 = info + 4; + if (uVar2 == 1) { + __src = &DAT_23082afc; + } + else { + __src = &DAT_23082b14; + } + memcpy(info,__src,4); + } + } + *pcVar1 = '-'; + pcVar1 = pcVar1 + 1; + uVar2 = 0; + do { + if ((1 << (uVar2 & 0x1f) & in_register_90000c04) != 0) { + *pcVar1 = (char)uVar2 + 'A'; + pcVar1 = pcVar1 + 1; + } + uVar2 = uVar2 + 1; + } while (uVar2 != 0x1a); + *pcVar1 = '\0'; + return 0; +} + + + +int bl_chip_banner(char **banner) + +{ + *banner = + "██████╗ ██╗ ██████╗ ██████╗ ██████╗\n\r██╔══██╗██║ ██╔════╝ ██╔═████╗╚════██╗\n\r██████╔╝██║ ███████╗ ██║██╔██║ █████╔╝\n\r██╔══██╗██║ ██╔═══██╗████╔╝██║██╔═══╝\n\r██████╔╝███████╗╚██████╔╝╚██████╔╝███████╗\n\r╚═════╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝\n\r" + ; + return 0; +} + + + +int bl_chip_memory_ram(int *num,uint *addr,uint *size,char (*desc) [6]) + +{ + if (2 < *num) { + *num = 3; + *addr = 0x23000000; + *size = 0x400000; + strcpy((char *)desc,"flash"); + addr[1] = 0x4200c000; + size[1] = 0x36000; + strcpy((char *)(desc + 1),"tcm"); + addr[2] = 0x42042000; + size[2] = 0xa000; + strcpy((char *)(desc + 2),"wifi"); + return 0; + } + return -1; +} + + + +void _cb_cmd(void *arg) + +{ + TickType_t TVar1; + + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [DMA] [TEST] Callback is working, arg is %p\r\n",TVar1, + &DAT_2307f16c,"bl_cks.c",0xe5,arg); + } + *(undefined4 *)((int)arg + 8) = 0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +undefined4 bl_cks_test(void) + +{ + ushort uVar1; + TickType_t TVar2; + char *format; + undefined *puVar3; + undefined4 uVar4; + int iVar5; + uint uVar6; + uint uVar7; + undefined2 local_80; + ushort uStack126; + undefined4 uStack124; + undefined4 uStack120; + bl_dma_item bStack116; + undefined auStack88 [4]; + undefined4 uStack84; + undefined4 uStack80; + undefined2 *puStack76; + undefined *puStack72; + undefined **ppuStack68; + undefined4 uStack64; + undefined auStack60 [4]; + undefined4 uStack56; + undefined4 uStack52; + undefined *puStack48; + ushort *puStack44; + undefined4 uStack40; + undefined4 uStack36; + + puStack76 = &local_80; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] --->>> case1 test\r\n",TVar2,&DAT_2307f16c,"bl_cks.c",0x137); + } + DAT_4000a700 = 1; + iVar5 = 0; + do { + DAT_4000a704 = data_src1_2802[iVar5]; + iVar5 = iVar5 + 1; + } while (iVar5 != 0x14); + uVar6 = (uint)_DAT_4000a708; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] CKS result with LE is %04x, should be %02x%02x\r\n",TVar2, + &DAT_2307f16c,"bl_cks.c",0x40,uVar6,0x61,0xb8); + } + DAT_4000a700 = 2; + iVar5 = 0; + do { + DAT_4000a704 = data_src1_2802[iVar5]; + iVar5 = iVar5 + 1; + } while (iVar5 != 0x14); + uVar6 = (uint)_DAT_4000a708; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] CKS result with BE is %04x, should be %02x%02x\r\n",TVar2, + &DAT_2307f16c,"bl_cks.c",0x48,uVar6,0x61,0xb8); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] --->>> case2 test\r\n",TVar2,&DAT_2307f16c,"bl_cks.c",0x139); + } + } + DAT_4000a700 = 1; + DAT_4000a704 = 0x3f; + uVar6 = (uint)_DAT_4000a708; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] CKS LE result is %04x, %04x\r\n",TVar2,&DAT_2307f16c,"bl_cks.c", + 0x61,uVar6,0xc0e0); + } + uVar1 = _DAT_4000a708; + DAT_4000a700 = 2; + DAT_4000a704 = 0x3f; + uVar6 = (uint)_DAT_4000a708; + if (_fsymc_level_hal_drv < BLOG_LEVEL_WARN) { + if (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] CKS BE result is %04x, %04x\r\n",TVar2,&DAT_2307f16c,"bl_cks.c", + 0x73,uVar6,0xc0e0); + if (uVar1 != 0xc0e0) goto LAB_2303332e; + if ((BLOG_LEVEL_INFO < _fsymc_level_hal_drv) || (BLOG_LEVEL_INFO < _fsymf_level_hal_drvbl_cks) + ) goto LAB_23032c88; + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar6 = 0xc0e0; + uVar4 = 0x75; + format = "[%10u][%s: %s:%4d] ====== Success %04X Checksum=====\r\n"; +LAB_23032c7a: + bl_printk(format,TVar2,&DAT_2307f16c,"bl_cks.c",uVar4,uVar6); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN) + ) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] --->>> case3 test\r\n",TVar2,&DAT_2307f16c,"bl_cks.c",0x13b); + } + } + else { + if (_DAT_4000a708 != 0xc0e0) goto LAB_23033338; + } + } + else { + if (_DAT_4000a708 != 0xc0e0) { +LAB_2303332e: + if (_fsymc_level_hal_drv < BLOG_LEVEL_WARN) { +LAB_23033338: + if (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar4 = 0x77; + format = "[%10u][%s: %s:%4d] ====== Failed %04X Checksum======\r\n"; + goto LAB_23032c7a; + } + } + } + } +LAB_23032c88: + DAT_4000a700 = 1; + iVar5 = 1000; + do { + DAT_4000a704 = 0x3f; + iVar5 = iVar5 + -1; + } while (iVar5 != 0); + uVar6 = 0xf69118; + while (uVar6 >> 0x10 != 0) { + uVar6 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + } + uVar7 = (uint)_DAT_4000a708; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] CKS LE result is %04x, %04x\r\n",TVar2,&DAT_2307f16c,"bl_cks.c", + 0x91,uVar7,~uVar6 & 0xffff); + } + DAT_4000a700 = 2; + iVar5 = 1000; + do { + DAT_4000a704 = 0x3f; + iVar5 = iVar5 + -1; + } while (iVar5 != 0); + uVar6 = 0xf69118; + while (uVar6 >> 0x10 != 0) { + uVar6 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + } + uVar7 = (uint)_DAT_4000a708; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] CKS BE result is %04x, %04x\r\n",TVar2,&DAT_2307f16c,"bl_cks.c", + 0xa3,uVar7,~uVar6 & 0xffff); + } + if (uVar7 == (~uVar6 & 0xffff)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar4 = 0xa5; + puVar3 = &DAT_2307f16c; + format = "[%10u][%s: %s:%4d] ====== Success %04X Checksum=====\r\n"; +LAB_230330f0: + bl_printk(format,TVar2,puVar3,"bl_cks.c",uVar4,uVar7); + goto LAB_230330f4; + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar4 = 0xa7; + puVar3 = &DAT_23072bcc; + format = "[%10u][%s: %s:%4d] ====== Failed %04X Checksum======\r\n"; + goto LAB_230330f0; + } +LAB_230330f4: + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] --->>> case4 test\r\n",TVar2,&DAT_2307f16c,"bl_cks.c",0x13d); + } + } + DAT_4000a700 = 1; + DAT_4000a704 = 0xa1; + uVar6 = (uint)_DAT_4000a708; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] CKS LE result is %04x, %04x\r\n",TVar2,&DAT_2307f16c,"bl_cks.c", + 0xc4,uVar6,0xc03f); + } + uVar1 = _DAT_4000a708; + DAT_4000a700 = 2; + DAT_4000a704 = 0xa1; + uVar6 = (uint)_DAT_4000a708; + if (_fsymc_level_hal_drv < BLOG_LEVEL_WARN) { + if (BLOG_LEVEL_INFO < _fsymf_level_hal_drvbl_cks) { + if (_DAT_4000a708 == 0xc03f) goto LAB_23032ef6; + goto LAB_230332e4; + } + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] CKS BE result is %04x, %04x\r\n",TVar2,&DAT_2307f16c,"bl_cks.c", + 0xd8,uVar6,0xc03f); + if (uVar1 != 0xc03f) goto LAB_230332da; + if ((BLOG_LEVEL_INFO < _fsymc_level_hal_drv) || (BLOG_LEVEL_INFO < _fsymf_level_hal_drvbl_cks)) + goto LAB_23032ef6; + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar6 = 0xc03f; + uVar4 = 0xda; + puVar3 = &DAT_2307f16c; + format = "[%10u][%s: %s:%4d] ====== Success %04X Checksum=====\r\n"; +LAB_230331c2: + bl_printk(format,TVar2,puVar3,"bl_cks.c",uVar4,uVar6); + } + else { + if (_DAT_4000a708 == 0xc03f) goto LAB_23032ef6; +LAB_230332da: + if (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) { +LAB_230332e4: + if (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_ASSERT) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar4 = 0xdc; + puVar3 = &DAT_23072bcc; + format = "[%10u][%s: %s:%4d] ====== Failed %04X Checksum======\r\n"; + goto LAB_230331c2; + } + } + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_cks < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] --->>> case5 test\r\n",TVar2,&DAT_2307f16c,"bl_cks.c",0x13f); + } +LAB_23032ef6: + bStack116.arg = &bStack116; + local_80 = 0x3f1f; + uStack124 = 1; + uStack120 = 2; + uStack126 = 0; + memset(bStack116.arg,0,0x1c); + memset(auStack88,0,0x1c); + memset(auStack60,0,0x1c); + bStack116.src = &uStack124; + bStack116.dst = &DAT_4000a700; + bStack116.next = &puStack76; + bStack116.ctrl = 0x4480002; + bStack116.cb = _cb_cmd; + puStack72 = &DAT_4000a704; + puStack48 = &DAT_4000a708; + ppuStack68 = &puStack48; + puStack44 = &uStack126; + uStack64 = 0x403e8; + uStack84 = 0; + uStack80 = 0; + uStack40 = 0; + uStack36 = 0x80240001; + uStack56 = 0; + uStack52 = 0; + bl_dma_copy(bStack116.arg); + while (bStack116.arg != (bl_dma_item *)0x0) { + vTaskDelay(2); + } + if (uStack126 == 0x6df1) { + if (BLOG_LEVEL_INFO < _fsymc_level_hal_drv) { + return 0; + } + if (BLOG_LEVEL_INFO < _fsymf_level_hal_drvbl_cks) { + return 0; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0x12f; + puVar3 = &DAT_2307f16c; + format = "[%10u][%s: %s:%4d] ====== Success %04X Checksum=====\r\n"; + } + else { + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return 0; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvbl_cks) { + return 0; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar4 = 0x131; + puVar3 = &DAT_23072bcc; + format = "[%10u][%s: %s:%4d] ====== Failed %04X Checksum======\r\n"; + } + bl_printk(format,puVar3,"bl_cks.c",uVar4,(uint)uStack126); + return 0; +} + + + +void _cb_cmd(void *arg) + +{ + TickType_t TVar1; + + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_dma < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [DMA] [TEST] Callback is working, arg is %p\r\n",TVar1, + &DAT_2307f16c,"bl_dma.c",0x19c,arg); + } + *(undefined4 *)((int)arg + 8) = 0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void bl_dma_int_process(void) + +{ + uint uVar1; + uint uVar2; + int iVar3; + uint uVar4; + uint uVar5; + uint uVar6; + uint uVar7; + int *piStack52; + dma_ctx *pstctx; + + uVar1 = _DAT_4000c00c; + uVar2 = _DAT_4000c004; + uVar5 = 0; + bl_irq_ctx_get(0x1f,&piStack52); + do { + uVar4 = 1 << (uVar5 & 0x1f); + uVar7 = uVar4 & uVar2; + uVar6 = uVar4 & uVar1; + if (uVar7 == 0) { + if (uVar6 != 0) { +LAB_23033424: + uVar2 = _DAT_4000c010 | uVar4; + _DAT_4000c010 = uVar2; + goto LAB_2303342e; + } + } + else { + uVar2 = _DAT_4000c008 | uVar4; + _DAT_4000c008 = uVar2; + if (uVar6 != 0) goto LAB_23033424; +LAB_2303342e: + iVar3 = *(int *)(*piStack52 + 4); + while (iVar3 != *piStack52) { + if (*(uint *)(iVar3 + 8) == uVar5) { + if ((*(code **)(iVar3 + 0xc) != (code *)0x0) && (uVar7 != 0)) { + (**(code **)(iVar3 + 0xc))(); + } + if ((*(code **)(iVar3 + 0x10) != (code *)0x0) && (uVar6 != 0)) { + (**(code **)(iVar3 + 0x10))(); + } + } + iVar3 = *(int *)(iVar3 + 4); + } + } + uVar5 = uVar5 + 1; + if (uVar5 == 4) { + return; + } + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int bl_dma_int_clear(int ch) + +{ + uint uVar1; + + uVar1 = 1 << (ch & 0x1fU); + if ((_DAT_4000c004 & uVar1 & 0xff) != 0) { + _DAT_4000c008 = _DAT_4000c008 | uVar1; + } + if ((_DAT_4000c00c & uVar1 & 0xff) != 0) { + _DAT_4000c010 = uVar1 | _DAT_4000c010; + } + return 0; +} + + + +void bl_dma_IRQHandler(void) + +{ + utils_list_hdr *puVar1; + TickType_t TVar2; + + bl_dma_int_clear(0); + puVar1 = utils_list_pop_front(&dma_copy_list); + if (puVar1 == (utils_list_hdr *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_dma < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [INT] ASSERT here for empty chain\r\n",TVar2,&DAT_2307f16c, + "bl_dma.c",0x9d); + } + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + if (puVar1[1].next != (utils_list_hdr *)0x0) { + (*(code *)puVar1[1].next)(puVar1[2].next); + } + if (dma_copy_list.first != (utils_list_hdr *)0x0) { + DMA_LLI_Update('\0',(uint32_t)(dma_copy_list.first + 3)); + DMA_Channel_Enable('\0'); + return; + } + return; +} + + + +void bl_dma_copy(bl_dma_item *first) + +{ + vTaskEnterCritical(); + if (dma_copy_list.first == (utils_list_hdr *)0x0) { + DMA_LLI_Update('\0',(uint32_t)&first->src); + DMA_Channel_Enable('\0'); + } + utils_list_push_back(&dma_copy_list,(utils_list_hdr *)first); + vTaskExitCritical(); + return; +} + + + +int bl_dma_irq_register(int channel,void *tc_handler,void *interr_handler,void *ctx) + +{ + int iVar1; + TickType_t TVar2; + int *piVar3; + int **ppiVar4; + int *piStack36; + dma_ctx *pstctx; + + if (((uint)channel < 5) && (tc_handler != (void *)0x0)) { + bl_irq_ctx_get(0x1f,&piStack36); + iVar1 = *(int *)(*piStack36 + 4); + while (*piStack36 != iVar1) { + if (channel == *(int *)(iVar1 + 8)) { + if (BLOG_LEVEL_WARN < _fsymc_level_hal_drv) { + return -1; + } + if (BLOG_LEVEL_WARN < _fsymf_level_hal_drvbl_dma) { + return -1; + } + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] channel %d already register \r\n",TVar2,&DAT_23081ce8, + "bl_dma.c",0x124,*(undefined4 *)(iVar1 + 8)); + return -1; + } + iVar1 = *(int *)(iVar1 + 4); + } + piVar3 = (int *)pvPortMalloc(0x18); + if (((piVar3 == (int *)0x0) && (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvbl_dma < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] malloc dma node failed. \r\n",TVar2,&DAT_23072bcc,"bl_dma.c", + 0x12a); + } + piVar3[2] = channel; + *(void **)(piVar3 + 3) = tc_handler; + *(void **)(piVar3 + 4) = interr_handler; + *(void **)(piVar3 + 5) = ctx; + iVar1 = *piStack36; + ppiVar4 = *(int ***)(iVar1 + 4); + *piVar3 = iVar1; + *(int ***)(piVar3 + 1) = ppiVar4; + *(int **)(iVar1 + 4) = piVar3; + *ppiVar4 = piVar3; + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvbl_dma < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] not valid para \r\n",TVar2,&DAT_23072bcc,"bl_dma.c",0x11c); + } + } + return -1; +} + + + +void bl_dma_init(void) + +{ + void **ctx; + char *format; + void *pvVar1; + undefined4 uVar2; + undefined2 uStack20; + DMA_Periph_Req_Type DStack18; + DMA_LLI_Cfg_Type lliCfg; + + uStack20 = 0; + DStack18 = DMA_REQ_UART0_RX; + utils_list_init(&dma_copy_list); + ctx = (void **)pvPortMalloc(4); + if (ctx == (void **)0x0) { + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvbl_dma) { + return; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar2 = 0x180; + format = "[%10u][%s: %s:%4d] malloc dma ctx failed \r\n"; + } + else { + pvVar1 = pvPortMalloc(8); + *ctx = pvVar1; + if (pvVar1 != (void *)0x0) { + *(void **)((int)pvVar1 + 4) = pvVar1; + *(void **)pvVar1 = pvVar1; + DMA_Enable(); + DMA_IntMask('\0',DMA_INT_ALL,MASK); + DMA_IntMask('\0',DMA_INT_TCOMPLETED,UNMASK); + DMA_IntMask('\0',DMA_INT_ERR,UNMASK); + DMA_LLI_Init('\0',(DMA_LLI_Cfg_Type *)&uStack20); + bl_irq_register_with_ctx(0x1f,bl_dma_int_process,ctx); + bl_dma_irq_register(0,bl_dma_IRQHandler,(void *)0x0,(void *)0x0); + bl_irq_enable(0x1f); + return; + } + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvbl_dma) { + return; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar2 = 0x187; + format = "[%10u][%s: %s:%4d] malloc dma pstqueue failed \r\n"; + } + bl_printk(format,&DAT_23072bcc,"bl_dma.c",uVar2); + return; +} + + + +void bl_dma_test(void) + +{ + bl_dma_item *first; + void *__s; + void *__s_00; + TickType_t TVar1; + + first = (bl_dma_item *)pvPortMalloc(0x1c); + __s = pvPortMalloc(0x44); + __s_00 = pvPortMalloc(0x44); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_dma < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [TEST] [DMA] first %p, src %p, dst %p\r\n",TVar1,&DAT_2307f16c, + "bl_dma.c",0x1af,first,__s,__s_00); + } + memset(first,0,0x1c); + memset(__s,1,0x44); + memset(__s_00,0xff,0x44); + first->ctrl = 0x8c49b011; + *(void **)&first->src = __s; + *(void **)&first->dst = __s_00; + first->next = 0; + first->cb = _cb_cmd; + *(bl_dma_item **)&first->arg = first; + bl_dma_copy(first); + while (first->arg != (void *)0x0) { + vTaskDelay(2); + } + vPortFree((void *)first->src); + vPortFree((void *)first->dst); + vPortFree(first); + return; +} + + + +void _irq_num_check(int irqnum) + +{ + TickType_t TVar1; + + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && (_fsymf_level_hal_drvbl_irq < BLOG_LEVEL_ASSERT) + ) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] illegal irqnum %d\r\n",TVar1,&DAT_23072bcc,"bl_irq.c",0x70,irqnum) + ; + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void bl_irq_enable(uint source) + +{ + (&DAT_02800400)[source] = 1; + return; +} + + + +void bl_irq_disable(uint source) + +{ + (&DAT_02800400)[source] = 0; + return; +} + + + +void bl_irq_exception_trigger(BL_IRQ_EXCEPTION_TYPE_T type,void *ptr) + +{ + undefined3 in_register_00002029; + uint uVar1; + undefined4 uVar2; + undefined auStack20 [4]; + uint32_t fun_val; + + uVar1 = CONCAT31(in_register_00002029,type); + if (uVar1 < 3) { + if (uVar1 == 0) { + uVar2 = *(undefined4 *)ptr; + } + else { + uVar2 = 0x12345678; + *(undefined4 *)ptr = 0x12345678; + } + } + else { + uVar2 = 0x12345678; + if (uVar1 == 3) { + (*(code *)auStack20)(0x12345678,auStack20); + uVar2 = 0x12345678; + } + } + printf("Trigger exception val is %08lx\r\n",uVar2); + return; +} + + + +void bl_irq_register_with_ctx(int irqnum,void *handler,void *ctx) + +{ + TickType_t TVar1; + + if (0x4f < (uint)irqnum) { + _irq_num_check(irqnum); + } + if (handler_list[irqnum] == (anon_subr_void *)0x0) goto LAB_23033a6a; + if (handler_list[irqnum] == (anon_subr_void *)handler) { +LAB_23033adc: + handler_list[irqnum] = handler; + if ((anon_subr_void *)ctx == (anon_subr_void *)0x0) { + handler_list[irqnum + 0x50] = (anon_subr_void *)0x0; + } + else { + handler_list[irqnum + 0x50] = ctx; + } + } + else { + if (_fsymc_level_hal_drv < BLOG_LEVEL_ERROR) { + if (_fsymf_level_hal_drvbl_irq < BLOG_LEVEL_ERROR) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] IRQ %d already registered with %p \r\n",TVar1,&DAT_23081ce8, + "bl_irq.c",0x7e,irqnum,handler_list[irqnum]); + goto LAB_23033a6a; + } + if ((anon_subr_void *)handler != (anon_subr_void *)0x0) goto LAB_23033adc; + } + else { +LAB_23033a6a: + if ((anon_subr_void *)handler != (anon_subr_void *)0x0) goto LAB_23033adc; + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return; + } + } + if (_fsymf_level_hal_drvbl_irq < BLOG_LEVEL_ASSERT) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] handler is NULL pointer! \r\n",TVar1,&DAT_23072bcc,"bl_irq.c", + 0x82); + return; + } + } + return; +} + + + +void bl_irq_ctx_get(int irqnum,void **ctx) + +{ + if (0x4f < (uint)irqnum) { + _irq_num_check(irqnum); + } + *(anon_subr_void **)ctx = handler_list[irqnum + 0x50]; + return; +} + + + +void bl_irq_register(int irqnum,void *handler) + +{ + bl_irq_register_with_ctx(irqnum,handler,(void *)0x0); + return; +} + + + +void bl_irq_unregister(int irqnum,void *handler) + +{ + TickType_t TVar1; + + if (0x4f < (uint)irqnum) { + _irq_num_check(irqnum); + } + if (((handler_list[irqnum] != (anon_subr_void *)handler) && + (_fsymc_level_hal_drv < BLOG_LEVEL_ERROR)) && (_fsymf_level_hal_drvbl_irq < BLOG_LEVEL_ERROR)) + { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] IRQ %d:%p Not match with registered %p\r\n",TVar1,&DAT_23081ce8, + "bl_irq.c",0xa8,irqnum,handler,handler_list[irqnum]); + } + handler_list[irqnum] = handler; + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void interrupt_entry(uint32_t mcause) + +{ + anon_subr_void *UNRECOVERED_JUMPTABLE_00; + uint uVar1; + + uVar1 = mcause & 0x7ffffff; + if (uVar1 < 0x50) { + UNRECOVERED_JUMPTABLE_00 = handler_list[uVar1]; + if (UNRECOVERED_JUMPTABLE_00 != (anon_subr_void *)0x0) { + if (handler_list[uVar1 + 0x50] != (anon_subr_void *)0x0) { + // WARNING: Could not recover jumptable at 0x23033c02. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE_00)(); + return; + } + // WARNING: Could not recover jumptable at 0x23033c04. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE_00)(); + return; + } + } + printf("Cannot handle mcause 0x%lx:%lu, adjust to externel(0x%lx:%lu)\r\n",uVar1,uVar1 - 0x10); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void exception_entry(uint32_t mcause,uint32_t mepc,uint32_t mtval,uintptr_t *regs) + +{ + char *__s; + + if ((mcause & 0x3ff) == 4) { + misaligned_load_trap(mcause,mepc); + return; + } + if ((mcause & 0x3ff) != 6) { + puts("Exception Entry--->>>\r\n"); + printf("mcause %08lx, mepc %08lx, mtval %08lx\r\n",mcause,mepc,mtval); + printf("Exception code: %lu\r\n",mcause & 0xffff); + switch(mcause & 0xffff) { + case 0: + __s = " msg: Instruction address misaligned\r\n"; + break; + case 1: + __s = " msg: Instruction access fault\r\n"; + break; + case 2: + __s = " msg: Illegal instruction\r\n"; + break; + case 3: + __s = " msg: Breakpoint\r\n"; + break; + case 4: + __s = " msg: Load address misaligned\r\n"; + break; + case 5: + __s = " msg: Load access fault\r\n"; + break; + case 6: + __s = " msg: Store/AMO access misaligned\r\n"; + break; + case 7: + __s = " msg: Store/AMO access fault\r\n"; + break; + case 8: + __s = " msg: Environment call from U-mode\r\n"; + break; + case 9: + __s = " msg: Environment call from S-mode\r\n"; + break; + case 10: + case 0xe: + __s = " msg: Reserved\r\n"; + break; + case 0xb: + __s = " msg: Environment call from M-mode\r\n"; + break; + case 0xc: + __s = " msg: Instruction page fault\r\n"; + break; + case 0xd: + __s = " msg: Load page fault\r\n"; + break; + case 0xf: + __s = " msg: Store/AMO page fault\r\n"; + break; + default: + __s = " msg: Reserved default exception\r\n"; + } + puts(__s); + backtrace_riscv(printf,regs); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + misaligned_store_trap(mcause,mepc); + return; +} + + + +void bl_irq_init(void) + +{ + undefined *puVar1; + + puts("[IRQ] Clearing and Disable all the pending IRQ...\r\n"); + puVar1 = &DAT_02800400; + do { + *puVar1 = 0; + puVar1 = puVar1 + 1; + } while (puVar1 != (undefined *)0x2800480); + puVar1 = &DAT_02800000; + do { + *puVar1 = 0; + puVar1 = puVar1 + 1; + } while (puVar1 != (undefined *)0x2800080); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void _trng_trigger(void) + +{ + if ((_DAT_40004200 & 1) == 0) { + _DAT_40004200 = _DAT_40004200 | 0x606; + _DAT_4000422c = trng_buffer[0]; + _DAT_40004230 = trng_buffer[1]; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void wait_trng4feed(void) + +{ + do { + } while ((_DAT_40004200 & 1) != 0); + _DAT_40004200 = _DAT_40004200 & 0xfffffffd | 0x200; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && (_fsymf_level_hal_drvbl_sec < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Feed random number is %08lx\r\n","DEBUG ","bl_sec.c",0x5b, + trng_buffer[0]); + } + trng_buffer[0] = _DAT_40004208; + trng_buffer[1] = _DAT_4000420c; + trng_buffer[2] = _DAT_40004210; + trng_buffer[3] = _DAT_40004214; + trng_buffer[4] = _DAT_40004218; + trng_buffer[5] = _DAT_4000421c; + trng_buffer[6] = _DAT_40004220; + trng_buffer[7] = _DAT_40004224; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_trng_IRQHandler(uint param_1,int param_2) + +{ + aos_now_ms(); + if ((param_2 < 1) && ((param_2 != 0 || (param_1 < 2000)))) { + puts("[BL] [SEC] TRNG Handler\r\n"); + } + _DAT_40004200 = _DAT_40004200 & 0xfffffffd | 0x200; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && (_fsymf_level_hal_drvbl_sec < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] random number is %08lx\r\n","DEBUG ","bl_sec.c",0xab, + trng_buffer[0]); + } + trng_buffer[0] = _DAT_40004208; + trng_buffer[1] = _DAT_4000420c; + trng_buffer[2] = _DAT_40004210; + trng_buffer[3] = _DAT_40004214; + trng_buffer[4] = _DAT_40004218; + trng_buffer[5] = _DAT_4000421c; + trng_buffer[6] = _DAT_40004220; + trng_buffer[7] = _DAT_40004224; + return; +} + + + +void bl_sec_pka_IRQHandler(void) + +{ + puts("--->>> PKA IRQ\r\n"); + SEC_Eng_IntMask(SEC_ENG_INT_PKA,MASK); + return; +} + + + +uint32_t bl_sec_get_random_word(void) + +{ + uint uVar1; + + uVar1 = trng_idx & 7; + if (uVar1 == 0) { + trng_idx = uVar1; + _trng_trigger(); + } + trng_idx = uVar1 + 1; + return trng_buffer[uVar1]; +} + + + +void bl_rand_stream(uint8_t *buf,int len) + +{ + size_t __n; + int iVar1; + + if (trng_idx != 0) { + _trng_trigger(); + wait_trng4feed(); + trng_idx = 0; + } + iVar1 = 0; + while (0 < len) { + if (trng_idx != 0) { + _trng_trigger(); + wait_trng4feed(); + trng_idx = 0; + } + __n = len; + if (0x20 < len) { + __n = 0x20; + } + memcpy(buf + iVar1,trng_buffer,__n); + iVar1 = iVar1 + __n; + len = len - __n; + trng_idx = 0x1f; + } + _trng_trigger(); + wait_trng4feed(); + trng_idx = 0; + return; +} + + + +int bl_rand(void) + +{ + int iVar1; + uint32_t uVar2; + + iVar1 = 0x13; + do { + uVar2 = bl_sec_get_random_word(); + iVar1 = iVar1 + -1; + if (iVar1 == 0) { + puts("[BL] [SEC] Failed after loop (17)\r\n"); + break; + } + } while (uVar2 == 0); + return uVar2 >> 1; +} + + + +int bl_sec_init(void) + +{ + g_bl_sec_sha_mutex = + (SemaphoreHandle_t)xQueueCreateMutexStatic('\x01',(StaticQueue_t *)&sha_mutex_buf); + _trng_trigger(); + wait_trng4feed(); + _trng_trigger(); + wait_trng4feed(); + bl_irq_register(0x1c,sec_trng_IRQHandler); + bl_irq_enable(0x1c); + return 0; +} + + + +int bl_sec_test(void) + +{ + int iVar1; + + bl_printk("------------------TRNG TEST---------------------------------\r\n"); + iVar1 = bl_rand(); + bl_printk("**********TRNG TEST rand[%08x]**************\r\n",iVar1); + iVar1 = bl_rand(); + bl_printk("**********TRNG TEST rand[%08x]**************\r\n",iVar1); + bl_printk("------------------------------------------------------------\r\n"); + return 0; +} + + + +void _dump_rsa_data(uint8_t *data,int size) + +{ + uint uVar1; + + uVar1 = 0; + do { + if (size <= (int)uVar1) { + return; + } + if ((uVar1 & 0xf) == 0) { + bl_printk("[%04X]:",uVar1); +LAB_2303415a: + bl_printk(" %02X",(uint)data[uVar1]); + } + else { + if ((uVar1 & 0xf) != 0xf) goto LAB_2303415a; + bl_printk(" %02X",(uint)data[uVar1]); + puts("\r\n"); + } + uVar1 = uVar1 + 1; + } while( true ); +} + + + +void _pka_test_case_xgcd(void) + +{ + uint8_t "" [256]; + uint8_t n [256]; + uint8_t "" [256]; + uint8_t uStack273; + undefined auStack272 [3]; + uint8_t pka_a_eq_0; + uint32_t result [64]; + + uStack273 = '\0'; + Sec_Eng_PKA_Reset(); + Sec_Eng_PKA_BigEndian_Enable(); + Sec_Eng_PKA_Write_Data + (SEC_ENG_PKA_REG_SIZE_256,'\x01',(uint32_t *)(uint8_t *)&ram0x230839c4,0x40,'\0'); + Sec_Eng_PKA_CREG(SEC_ENG_PKA_REG_SIZE_256,'\x02','\0','\0'); + Sec_Eng_PKA_CREG(SEC_ENG_PKA_REG_SIZE_256,'\x03','\0','\x01'); + Sec_Eng_PKA_Write_Data(SEC_ENG_PKA_REG_SIZE_256,'\0',(uint32_t *)"",0x40,'\0'); + Sec_Eng_PKA_LMUL2N('\n','\x01','\b','\0',0x800,'\0'); + Sec_Eng_PKA_LDIV('\b','\0','\n','\x01','\b','\x01','\0'); + Sec_Eng_PKA_MREM('\b','\x04','\n','\x01','\b','\x01','\0'); + Sec_Eng_PKA_CREG(SEC_ENG_PKA_REG_SIZE_512,'\x01','\0','\x01'); + Sec_Eng_PKA_Move_Data('\b','\x02','\b','\x01','\0'); + Sec_Eng_PKA_Move_Data('\b','\x01','\b','\x04','\x01'); + Sec_Eng_PKA_Write_Data(SEC_ENG_PKA_REG_SIZE_256,'\x04',(uint32_t *)"",0x40,'\0'); + Sec_Eng_PKA_Write_Data(SEC_ENG_PKA_REG_SIZE_256,'\x05',(uint32_t *)0x23083ac4,0x40,'\0'); + Sec_Eng_PKA_Write_Data(SEC_ENG_PKA_REG_SIZE_256,'\x06',(uint32_t *)0x23083ac4,0x40,'\0'); + Sec_Eng_PKA_Write_Data(SEC_ENG_PKA_REG_SIZE_256,'\a',(uint32_t *)0x2308341c,0x40,'\0'); + Sec_Eng_PKA_LMUL('\b','\b','\b','\0','\b','\x05','\0'); + Sec_Eng_PKA_LSUB('\b','\b','\b','\x04','\b','\b','\0'); + Sec_Eng_PKA_LMUL('\b','\t','\b','\0','\b','\a','\0'); + Sec_Eng_PKA_LSUB('\b','\t','\b','\x06','\b','\t','\0'); + Sec_Eng_PKA_Move_Data('\b','\x04','\b','\x05','\0'); + Sec_Eng_PKA_Move_Data('\b','\x05','\b','\b','\0'); + Sec_Eng_PKA_Move_Data('\b','\x06','\b','\a','\0'); + Sec_Eng_PKA_Move_Data('\b','\a','\b','\t','\x01'); + while (uStack273 == '\0') { + Sec_Eng_PKA_LDIV('\b','\0','\b','\x02','\b','\x01','\0'); + Sec_Eng_PKA_MREM('\b','\x03','\b','\x02','\b','\x01','\0'); + Sec_Eng_PKA_LMUL('\b','\b','\b','\0','\b','\x05','\0'); + Sec_Eng_PKA_LSUB('\b','\b','\b','\x04','\b','\b','\0'); + Sec_Eng_PKA_LMUL('\b','\t','\b','\0','\b','\a','\0'); + Sec_Eng_PKA_LSUB('\b','\t','\b','\x06','\b','\t','\0'); + Sec_Eng_PKA_Move_Data('\b','\x02','\b','\x01','\0'); + Sec_Eng_PKA_Move_Data('\b','\x04','\b','\x05','\0'); + Sec_Eng_PKA_Move_Data('\b','\x05','\b','\b','\0'); + Sec_Eng_PKA_Move_Data('\b','\x06','\b','\a','\0'); + Sec_Eng_PKA_Move_Data('\b','\a','\b','\t','\x01'); + Sec_Eng_PKA_Move_Data('\b','\x01','\b','\x03','\x01'); + Sec_Eng_PKA_Write_Data(SEC_ENG_PKA_REG_SIZE_256,'\n',(uint32_t *)0x23083ac4,0x40,'\0'); + Sec_Eng_PKA_LCMP(&uStack273,'\b','\x01','\b','\n'); + } + Sec_Eng_PKA_Read_Data(SEC_ENG_PKA_REG_SIZE_256,'\x06',(uint32_t *)auStack272,'@'); + _dump_rsa_data(auStack272,0x100); + return; +} + + + +void _pka_test_case2(uint8_t param_1) + +{ + bool bVar1; + uint8_t encrypted [256]; + uint8_t inv_r [256]; + uint8_t m [256]; + uint8_t n [256]; + uint8_t nprime [256]; + uint8_t "" [4]; + uint32_t *puVar2; + uint8_t *puVar3; + char *format; + undefined *puVar4; + undefined4 uVar5; + int iVar6; + uint32_t local_130; + uint32_t result [64]; + + Sec_Eng_PKA_Reset(); + Sec_Eng_PKA_BigEndian_Enable(); + Sec_Eng_PKA_Write_Data + (SEC_ENG_PKA_REG_SIZE_256,'\0',(uint32_t *)(uint8_t *)&ram0x230838c4,0x40,'\0'); + Sec_Eng_PKA_Write_Data + (SEC_ENG_PKA_REG_SIZE_256,'\x01',(uint32_t *)(uint8_t *)&ram0x23083bc4,0x40,'\0'); + Sec_Eng_PKA_Write_Data + (SEC_ENG_PKA_REG_SIZE_256,'\x02',(uint32_t *)(uint8_t *)0x230837c4,0x40,'\0'); + Sec_Eng_PKA_Write_Data(SEC_ENG_PKA_REG_SIZE_256,'\x03',(uint32_t *)"",1,'\0'); + Sec_Eng_PKA_CREG(SEC_ENG_PKA_REG_SIZE_256,'\x04','\0','\0'); + Sec_Eng_PKA_CREG(SEC_ENG_PKA_REG_SIZE_256,'\x05','\0','\x01'); + Sec_Eng_PKA_LMUL2N('\n','\x02','\b','\x02',0x800,'\0'); + Sec_Eng_PKA_MREM('\b','\x02','\n','\x02','\b','\0','\0'); + Sec_Eng_PKA_CREG(SEC_ENG_PKA_REG_SIZE_512,'\x02','\0','\x01'); + Sec_Eng_PKA_MEXP('\b','\x04','\b','\x02','\b','\x03','\b','\0',DAT_00000010); + Sec_Eng_PKA_Move_Data('\b','\x02','\b','\x04','\x01'); + Sec_Eng_PKA_Write_Data + (SEC_ENG_PKA_REG_SIZE_256,'\x01',(uint32_t *)(uint8_t *)&ram0x230836c4,0x40,'\0'); + Sec_Eng_PKA_CREG(SEC_ENG_PKA_REG_SIZE_256,'\x04','\0','\0'); + Sec_Eng_PKA_CREG(SEC_ENG_PKA_REG_SIZE_256,'\x05','\0','\x01'); + Sec_Eng_PKA_LMUL('\n','\x02','\b','\x02','\b','\x01','\0'); + Sec_Eng_PKA_MREM('\b','\x02','\n','\x02','\b','\0','\0'); + Sec_Eng_PKA_CREG(SEC_ENG_PKA_REG_SIZE_512,'\x02','\0','\x01'); + Sec_Eng_PKA_Read_Data(SEC_ENG_PKA_REG_SIZE_256,'\x02',&local_130,'@'); + _dump_rsa_data((uint8_t *)&local_130,0x100); + puVar2 = &local_130; + puVar3 = &ram0x230835c4; + bVar1 = false; + iVar6 = 0; + while (iVar6 != 0x100) { + if (((*(uint8_t *)puVar2 != *puVar3) && (bVar1 = true, _fsymc_level_hal_drv < BLOG_LEVEL_WARN)) + && (_fsymf_level_hal_drvbl_sec < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + puVar4 = (undefined *)0x2307b100; + if (*(uint8_t *)puVar2 != *puVar3) { + puVar4 = &UNK_23083384; + } + bl_printk("[%10u][%s: %s:%4d] %s[%02d], %02x %02x\r\n",&DAT_2307f16c,"bl_sec.c",0xf9,puVar4, + iVar6); + bVar1 = true; + } + iVar6 = iVar6 + 1; + puVar2 = (uint32_t *)((int)puVar2 + 1); + puVar3 = puVar3 + 1; + } + if (bVar1) { + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvbl_sec) { + return; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar5 = 0xfd; + puVar4 = &DAT_23072bcc; + format = "[%10u][%s: %s:%4d] ====== Failed %lu Bytes======\r\n"; + } + else { + if (BLOG_LEVEL_INFO < _fsymc_level_hal_drv) { + return; + } + if (BLOG_LEVEL_INFO < _fsymf_level_hal_drvbl_sec) { + return; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar5 = 0xff; + puVar4 = &DAT_2307f16c; + format = "[%10u][%s: %s:%4d] ====== Success %lu Bytes=====\r\n"; + } + bl_printk(format,puVar4,"bl_sec.c",uVar5,0x100); + return; +} + + + +int bl_pka_test(void) + +{ + bl_irq_register(0x1b,bl_sec_pka_IRQHandler); + bl_irq_enable(0x1b); + _pka_test_case2(); + _pka_test_case_xgcd(); + _pka_test_case2(); + return 0; +} + + + +void int_timer_cb(void) + +{ + BaseType_t BVar1; + + TIMER_ClearIntStatus(TIMER_CH1,TIMER_COMP_ID_0); + BVar1 = xTaskIncrementTick(); + if (BVar1 != 0) { + vTaskSwitchContext(); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t bl_timer_now_us(void) + +{ + uint32_t uVar1; + + uVar1 = _DAT_0200bff8; + __udivdi3(); + return uVar1; +} + + + +int bl_timer_tick_enable(void) + +{ + TIMER_Chan_Type aTStack40 [4]; + TIMER_CFG_Type timerCh1Cfg; + + memcpy(aTStack40,&DAT_23083d64,0x18); + TIMER_IntMask(TIMER_CH1,TIMER_INT_ALL,MASK); + TIMER_Disable(aTStack40[0]); + TIMER_Init((TIMER_CFG_Type *)aTStack40); + TIMER_ClearIntStatus(aTStack40[0],TIMER_COMP_ID_0); + TIMER_ClearIntStatus(aTStack40[0],TIMER_COMP_ID_1); + TIMER_ClearIntStatus(aTStack40[0],TIMER_COMP_ID_2); + TIMER_IntMask(aTStack40[0],TIMER_INT_COMP_0,UNMASK); + TIMER_IntMask(aTStack40[0],TIMER_INT_COMP_1,MASK); + TIMER_IntMask(aTStack40[0],TIMER_INT_COMP_2,MASK); + TIMER_Enable(aTStack40[0]); + bl_irq_enable(0x35); + bl_irq_register(0x35,int_timer_cb); + return 0; +} + + + +// WARNING: Variable defined which should be unmapped: val + +void cmd_gpio_get(char *buf,int len,int argc,char **argv) + +{ + TickType_t TVar1; + int iVar2; + int iVar3; + undefined *puVar4; + uint8_t auStack17 [4]; + uint8_t val; + + if (argc == 2) { + iVar2 = atoi(argv[1]); + if (iVar2 < 0) { + puts("Illegal arg\r\n"); + } + else { + iVar3 = bl_gpio_input_get((uint8_t)iVar2,auStack17); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_gpio_cli < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + if (iVar3 == 0) { + if (auStack17[0] == '\0') { + puVar4 = &UNK_23083e38; + } + else { + puVar4 = &UNK_23083e30; + } + } + else { + puVar4 = &UNK_23083e2c; + } + bl_printk("[%10u][%s: %s:%4d] GPIO%d val is %s\r\n",TVar1,&DAT_2307f16c,"bl_gpio_cli.c",0x72 + ,iVar2,puVar4); + } + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_gpio_cli < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Usage: %s 24\r\n get GPIO24 value\r\n",TVar1,&DAT_2307f16c, + "bl_gpio_cli.c",0x66,*argv); + } + } + return; +} + + + +void cmd_gpio_set(char *buf,int len,int argc,char **argv) + +{ + TickType_t TVar1; + int iVar2; + int iVar3; + undefined *puVar4; + + if (argc == 3) { + iVar2 = atoi(argv[1]); + iVar3 = atoi(argv[2]); + if ((-1 < iVar2) && (-1 < iVar3)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_gpio_cli < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + if (iVar3 == 0) { + puVar4 = &UNK_23083ebc; + } + else { + puVar4 = &UNK_23083e30; + } + bl_printk("[%10u][%s: %s:%4d] GPIO%d is set to %s\r\n",TVar1,&DAT_2307f16c,"bl_gpio_cli.c", + 0x59,iVar2,puVar4); + } + bl_gpio_output_set((uint8_t)iVar2,iVar3 != 0); + return; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvbl_gpio_cli < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Illegal arg\r\n",TVar1,&DAT_23072bcc,"bl_gpio_cli.c",0x53); + return; + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_gpio_cli < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Usage: %s 24 1\r\n set GPIO24 output to high\r\n",TVar1, + &DAT_2307f16c,"bl_gpio_cli.c",0x4d,*argv); + return; + } + } + return; +} + + + +void cmd_gpio_func(char *buf,int len,int argc,char **argv) + +{ + TickType_t TVar1; + int iVar2; + int iVar3; + int iVar4; + int iVar5; + char *pcVar6; + char *pcVar7; + + if (argc == 5) { + iVar2 = atoi(argv[1]); + iVar3 = atoi(argv[2]); + iVar4 = atoi(argv[3]); + iVar5 = atoi(argv[4]); + if ((((-1 < iVar2) && (-1 < iVar3)) && (-1 < iVar4)) && (-1 < iVar5)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_gpio_cli < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + if (iVar3 == 0) { + pcVar6 = "output"; + } + else { + pcVar6 = "input"; + } + if (iVar4 == 0) { + pcVar7 = "null"; + } + else { + pcVar7 = "Active"; + } + bl_printk("[%10u][%s: %s:%4d] GPIO%d is set %s with %s pullup %s pulldown\r\n",TVar1, + &DAT_2307f16c,"bl_gpio_cli.c",0x3e,iVar2,pcVar6,pcVar7); + } + if (iVar3 != 0) { + bl_gpio_enable_input((uint8_t)iVar2,iVar4 != 0,iVar5 != 0); + return; + } + bl_gpio_enable_output((uint8_t)iVar2,iVar4 != 0,iVar5 != 0); + return; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvbl_gpio_cli < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Illegal arg\r\n",TVar1,&DAT_23072bcc,"bl_gpio_cli.c",0x36); + return; + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_gpio_cli < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Usage: %s 24 1 1 0\r\n set GPIO24 to input with pullup\r\n", + TVar1,&DAT_2307f16c,"bl_gpio_cli.c",0x2e,*argv); + return; + } + } + return; +} + + + +int bl_gpio_cli_init(void) + +{ + return 0; +} + + + +int bl_efuse_read_mac(uint8_t *mac) + +{ + EF_Ctrl_Read_MAC_Address(mac); + return 0; +} + + + +int bl_efuse_read_mac_factory(uint8_t *mac) + +{ + int8_t iVar1; + undefined3 extraout_var; + + iVar1 = mfg_media_read_macaddr(mac,'\x01'); + return -(uint)(CONCAT31(extraout_var,iVar1) != 0); +} + + + +int bl_efuse_read_capcode(uint8_t *capcode) + +{ + int8_t iVar1; + undefined3 extraout_var; + + iVar1 = mfg_media_read_xtal_capcode(capcode,'\x01'); + return -(uint)(CONCAT31(extraout_var,iVar1) != 0); +} + + + +int bl_efuse_read_pwroft(int8_t *poweroffset) + +{ + int8_t iVar1; + undefined3 extraout_var; + + iVar1 = mfg_media_read_poweroffset(poweroffset,'\x01'); + return -(uint)(CONCAT31(extraout_var,iVar1) != 0); +} + + + +void Aes_Compare_Data(uint8_t *expected,uint8_t *input,uint32_t len) + +{ + bool bVar1; + uint32_t uVar2; + TickType_t TVar3; + char *format; + undefined *puVar4; + undefined4 uVar5; + + bVar1 = false; + uVar2 = 0; + while (uVar2 != len) { + if (((input[uVar2] != expected[uVar2]) && (bVar1 = true, _fsymc_level_hal_drv < BLOG_LEVEL_WARN) + ) && (_fsymf_level_hal_drvbl_sec_aes < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + puVar4 = (undefined *)0x2307b100; + if (input[uVar2] != expected[uVar2]) { + puVar4 = &UNK_23083384; + } + bl_printk("[%10u][%s: %s:%4d] %s[%02d], %02x %02x\r\n",TVar3,&DAT_2307f16c,"bl_sec_aes.c",0x3b + ,puVar4,uVar2); + bVar1 = true; + } + uVar2 = uVar2 + 1; + } + if (bVar1) { + if ((BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) || + (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvbl_sec_aes)) { + return; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar5 = 0x3f; + puVar4 = &DAT_23072bcc; + format = "[%10u][%s: %s:%4d] ====== Failed %lu Bytes======\r\n"; + } + else { + if (BLOG_LEVEL_INFO < _fsymc_level_hal_drv) { + return; + } + if (BLOG_LEVEL_INFO < _fsymf_level_hal_drvbl_sec_aes) { + return; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar5 = 0x41; + puVar4 = &DAT_2307f16c; + format = "[%10u][%s: %s:%4d] ====== Success %lu Bytes=====\r\n"; + } + bl_printk(format,TVar3,puVar4,"bl_sec_aes.c",uVar5,len); + return; +} + + + +void _dump_iv_status(SEC_Eng_AES_Link_Config_Type_conflict1 *linkCfg) + +{ + byte bVar1; + uint32_t *puVar2; + + puVar2 = &linkCfg->aesIV0; + do { + bVar1 = *(byte *)puVar2; + puVar2 = (uint32_t *)((int)puVar2 + 1); + bl_printk("%02x",(uint)bVar1); + } while (puVar2 != &linkCfg->aesKey0); + bl_printk("\r\n"); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void bl_sec_aes_IRQHandler(void) + +{ + bl_printk("--->>> AES IRQ\r\n"); + _DAT_40004100 = _DAT_40004100 | 0x200; + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void Sec_Eng_AES_Link_Case_CBC_128(SEC_ENG_AES_ID_Type aesId) + +{ + uint8_t aesResult_entrypted_cbc_128 [64]; + TickType_t TVar1; + uint8_t auStack124 [4]; + uint8_t aesDstBuf [32]; + SEC_Eng_AES_Link_Config_Type_conflict1 linkCfg; + + memset(aesDstBuf + 0x1c,0,0x3c); + aesDstBuf._28_4_ = 0x12400; + Sec_Eng_AES_Enable_Link(aesId); + puts("[CBC] AES-128-CBC case...\r\n"); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_sec_aes < BLOG_LEVEL_WARN) + ) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [CBC] IV Status Initial, %08lx\r\n",TVar1,&DAT_2307f16c, + "bl_sec_aes.c",0x84,linkCfg._0_4_); + } + _dump_iv_status((SEC_Eng_AES_Link_Config_Type_conflict1 *)(aesDstBuf + 0x1c)); + Sec_Eng_AES_Link_Work(aesId,(uint32_t)(aesDstBuf + 0x1c),aesSrcBuf_data,0x20,auStack124); + Aes_Compare_Data((uint8_t *)&ram0x23084198,(uint8_t *)linkCfg.aesSrcAddr,0x20); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_sec_aes < BLOG_LEVEL_WARN) + ) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [CBC] IV Status After, %08lx\r\n",TVar1,&DAT_2307f16c, + "bl_sec_aes.c",0x88,linkCfg._0_4_); + } + _dump_iv_status((SEC_Eng_AES_Link_Config_Type_conflict1 *)(aesDstBuf + 0x1c)); + Sec_Eng_AES_Link_Work(aesId,(uint32_t)(aesDstBuf + 0x1c),aesSrcBuf_data + 0x20,0x10,auStack124); + Aes_Compare_Data((uint8_t *)0x230841b8,(uint8_t *)linkCfg.aesSrcAddr,0x10); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_sec_aes < BLOG_LEVEL_WARN) + ) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [CBC] IV Status After %08lx\r\n",TVar1,&DAT_2307f16c, + "bl_sec_aes.c",0x8d,linkCfg._0_4_); + } + _dump_iv_status((SEC_Eng_AES_Link_Config_Type_conflict1 *)(aesDstBuf + 0x1c)); + Sec_Eng_AES_Link_Work(aesId,(uint32_t)(aesDstBuf + 0x1c),aesSrcBuf_data + 0x30,0x10,auStack124); + Aes_Compare_Data((uint8_t *)0x230841c8,(uint8_t *)linkCfg.aesSrcAddr,0x10); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_sec_aes < BLOG_LEVEL_WARN) + ) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [CBC] IV Status After, %08lx\r\n",TVar1,&DAT_2307f16c, + "bl_sec_aes.c",0x92,linkCfg._0_4_); + } + _dump_iv_status((SEC_Eng_AES_Link_Config_Type_conflict1 *)(aesDstBuf + 0x1c)); + Sec_Eng_AES_Disable_Link(aesId); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void Sec_Eng_AES_Link_Case_CTR_128(SEC_ENG_AES_ID_Type aesId) + +{ + uint8_t aesResult_entrypted_ctr_128 [64]; + TickType_t TVar1; + uint8_t auStack124 [4]; + uint8_t aesDstBuf [32]; + SEC_Eng_AES_Link_Config_Type_conflict1 linkCfg; + + memset(aesDstBuf + 0x1c,0,0x3c); + aesDstBuf._28_4_ = 0x11400; + Sec_Eng_AES_Enable_Link(aesId); + puts("[CTR] AES-128-CTR case...\r\n"); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_sec_aes < BLOG_LEVEL_WARN) + ) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [CTR] IV Status Initial, %08lx\r\n",TVar1,&DAT_2307f16c, + "bl_sec_aes.c",0xbe,linkCfg._0_4_); + } + _dump_iv_status((SEC_Eng_AES_Link_Config_Type_conflict1 *)(aesDstBuf + 0x1c)); + Sec_Eng_AES_Link_Work(aesId,(uint32_t)(aesDstBuf + 0x1c),aesSrcBuf_data,0x20,auStack124); + Aes_Compare_Data((uint8_t *)&ram0x230841d8,(uint8_t *)linkCfg.aesSrcAddr,0x20); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_sec_aes < BLOG_LEVEL_WARN) + ) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [CTR] IV Status After %08lx\r\n",TVar1,&DAT_2307f16c, + "bl_sec_aes.c",0xc4,linkCfg._0_4_); + } + _dump_iv_status((SEC_Eng_AES_Link_Config_Type_conflict1 *)(aesDstBuf + 0x1c)); + Sec_Eng_AES_Link_Work(aesId,(uint32_t)(aesDstBuf + 0x1c),aesSrcBuf_data + 0x20,0x10,auStack124); + Aes_Compare_Data((uint8_t *)0x230841f8,(uint8_t *)linkCfg.aesSrcAddr,0x10); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_sec_aes < BLOG_LEVEL_WARN) + ) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [CTR] IV Status After %08lx\r\n",TVar1,&DAT_2307f16c, + "bl_sec_aes.c",0xc9,linkCfg._0_4_); + } + _dump_iv_status((SEC_Eng_AES_Link_Config_Type_conflict1 *)(aesDstBuf + 0x1c)); + Sec_Eng_AES_Link_Work(aesId,(uint32_t)(aesDstBuf + 0x1c),aesSrcBuf_data + 0x30,0x10,auStack124); + Aes_Compare_Data((uint8_t *)0x23084208,(uint8_t *)linkCfg.aesSrcAddr,0x10); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_sec_aes < BLOG_LEVEL_WARN) + ) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [CTR] IV Status After, %08lx\r\n",TVar1,&DAT_2307f16c, + "bl_sec_aes.c",0xce,linkCfg._0_4_); + } + _dump_iv_status((SEC_Eng_AES_Link_Config_Type_conflict1 *)(aesDstBuf + 0x1c)); + Sec_Eng_AES_Disable_Link(aesId); + return; +} + + + +// WARNING: Variable defined which should be unmapped: linkCfg +// WARNING: Could not reconcile some variable overlaps + +void Sec_Eng_AES_Link_Case_ECB_128(SEC_ENG_AES_ID_Type aesId) + +{ + uint8_t aesResult_entrypted_ecb_128 [64]; + uint8_t auStack108 [4]; + uint8_t aesDstBuf [32]; + SEC_Eng_AES_Link_Config_Type_conflict1 linkCfg; + + memset(aesDstBuf + 0x1c,0,0x3c); + aesDstBuf._28_4_ = 0x10400; + puts("[ECB] AES-128-ECB case...\r\n"); + Sec_Eng_AES_Enable_Link(aesId); + Sec_Eng_AES_Link_Work(aesId,(uint32_t)(aesDstBuf + 0x1c),aesSrcBuf_data,0x20,auStack108); + Aes_Compare_Data((uint8_t *)&ram0x23084218,(uint8_t *)linkCfg.aesSrcAddr,0x20); + Sec_Eng_AES_Link_Work(aesId,(uint32_t)(aesDstBuf + 0x1c),aesSrcBuf_data + 0x20,0x10,auStack108); + Aes_Compare_Data((uint8_t *)0x23084238,(uint8_t *)linkCfg.aesSrcAddr,0x10); + Sec_Eng_AES_Link_Work(aesId,(uint32_t)(aesDstBuf + 0x1c),aesSrcBuf_data + 0x30,0x10,auStack108); + Aes_Compare_Data((uint8_t *)0x23084248,(uint8_t *)linkCfg.aesSrcAddr,0x10); + Sec_Eng_AES_Disable_Link(aesId); + return; +} + + + +int bl_sec_aes_test(void) + +{ + bl_irq_register(0x1d,bl_sec_aes_IRQHandler); + bl_irq_enable(0x1d); + bl_printk( + "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n" + ); + Sec_Eng_AES_Link_Case_CBC_128(SEC_ENG_AES_ID0); + bl_printk( + "####################################################################################\r\n" + ); + Sec_Eng_AES_Link_Case_CTR_128(SEC_ENG_AES_ID0); + bl_printk( + "####################################################################################\r\n" + ); + Sec_Eng_AES_Link_Case_ECB_128(SEC_ENG_AES_ID0); + bl_printk( + "------------------------------------------------------------------------------------\r\n" + ); + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void bl_sec_sha_IRQHandler(void) + +{ + puts("--->>> SHA IRQ\r\n"); + _DAT_40004000 = _DAT_40004000 | 0x200; + return; +} + + + +int bl_sha_mutex_take(void) + +{ + BaseType_t BVar1; + TickType_t TVar2; + int iVar3; + + BVar1 = xQueueSemaphoreTake((QueueHandle_t)g_bl_sec_sha_mutex,0xffffffff); + iVar3 = 0; + if (((BVar1 != 1) && (iVar3 = -1, _fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvbl_sec_sha < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] sha semphr take failed\r\n",TVar2,&DAT_23072bcc,"bl_sec_sha.c", + 0x36); + iVar3 = -1; + } + return iVar3; +} + + + +int bl_sha_mutex_give(void) + +{ + BaseType_t BVar1; + TickType_t TVar2; + int iVar3; + + BVar1 = xQueueGenericSend((QueueHandle_t)g_bl_sec_sha_mutex,(void *)0x0,0,0); + iVar3 = 0; + if (((BVar1 != 1) && (iVar3 = -1, _fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvbl_sec_sha < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] sha semphr give failed\\n",TVar2,&DAT_23072bcc,"bl_sec_sha.c",0x3f + ); + iVar3 = -1; + } + return iVar3; +} + + + +void bl_sha_init(bl_sha_ctx_t *ctx,bl_sha_type_t type) + +{ + Sec_Eng_SHA256_Init((SEC_Eng_SHA256_Ctx *)ctx,SEC_ENG_SHA_ID0,type,ctx->tmp,ctx->pad); + Sec_Eng_SHA_Start(SEC_ENG_SHA_ID0); + return; +} + + + +int bl_sha_update(bl_sha_ctx_t *ctx,uint8_t *input,uint32_t len) + +{ + BL_Err_Type BVar1; + undefined3 extraout_var; + + BVar1 = Sec_Eng_SHA256_Update((SEC_Eng_SHA256_Ctx *)ctx,SEC_ENG_SHA_ID0,input,len); + return CONCAT31(extraout_var,BVar1); +} + + + +int bl_sha_finish(bl_sha_ctx_t *ctx,uint8_t *hash) + +{ + BL_Err_Type BVar1; + undefined3 extraout_var; + + BVar1 = Sec_Eng_SHA256_Finish((SEC_Eng_SHA256_Ctx *)ctx,SEC_ENG_SHA_ID0,hash); + return CONCAT31(extraout_var,BVar1); +} + + + +// WARNING: Could not reconcile some variable overlaps + +void sha256_test_case0(void) + +{ + uint8_t sha256_test_result [32]; + undefined *puVar1; + int iVar2; + char *format; + bool bVar3; + undefined auStack220 [4]; + sha256_link_item_t sha256_link; + + memset(auStack220,0,0xbc); + sha256_link.ctx.linkAddr = 0x10400; + sha256_link.linkCfg._0_4_ = 0x50020000; + bl_irq_register(0x1e,bl_sec_sha_IRQHandler); + bl_irq_enable(0x1e); + Sec_Eng_SHA_Enable_Link(SEC_ENG_SHA_ID0); + Sec_Eng_SHA256_Link_Init + ((SEC_Eng_SHA256_Link_Ctx *)auStack220,SEC_ENG_SHA_ID0, + (uint32_t)&sha256_link.ctx.linkAddr,sha256_link.linkCfg.result + 7, + sha256_link.tmp + 0xf); + Sec_Eng_SHA256_Link_Update + ((SEC_Eng_SHA256_Link_Ctx *)auStack220,SEC_ENG_SHA_ID0, + "1111111111111111111111111111111111111111111111111111111111111111hal_drv.bl_sec_sha", + 0x40); + Sec_Eng_SHA256_Link_Finish + ((SEC_Eng_SHA256_Link_Ctx *)auStack220,SEC_ENG_SHA_ID0, + (uint8_t *)&sha256_link.linkCfg.shaSrcAddr); + Sec_Eng_SHA_Disable_Link(SEC_ENG_SHA_ID0); + puVar1 = auStack220; + bVar3 = false; + iVar2 = 0; + do { + if (((uint8_t *)&ram0x2308449c)[iVar2] != puVar1[0x1c]) { + bl_printk("%s[%02d], %02x %02x\r\n",&UNK_23083384,iVar2); + bVar3 = true; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 1; + } while (iVar2 != 0x20); + if (bVar3) { + format = "====== Failed %lu Bytes======\r\n"; + } + else { + format = "====== Success %lu Bytes=====\r\n"; + } + bl_printk(format); + return; +} + + + +int bl_sec_sha_test(void) + +{ + puts("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n"); + puts("^^^^^^^^^^^^^^^^^^^^^^^SHA256 TEST CASE^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n"); + sha256_test_case0(); + puts("------------------------------------------------------------------------------------\r\n"); + return 0; +} + + + +int bl_wifi_clock_enable(void) + +{ + int called; + + return 0; +} + + + +int bl_wifi_enable_irq(void) + +{ + bl_irq_register(0x46,mac_irq); + bl_irq_register(0x4f,bl_irq_handler); + bl_irq_enable(0x46); + bl_irq_enable(0x4f); + puts("Enable BMX IRQ\r\n"); + return 0; +} + + + +int bl_wifi_sta_mac_addr_set(uint8_t *mac) + +{ + memcpy(&wifi_env,mac,6); + return 0; +} + + + +int bl_wifi_ap_mac_addr_set(uint8_t *mac) + +{ + memcpy(wifi_env.ap_mac_addr_board,mac,6); + return 0; +} + + + +int bl_wifi_mac_addr_get(uint8_t *mac) + +{ + memcpy(mac,&wifi_env,6); + return 0; +} + + + +int bl_wifi_country_code_set(uint8_t country_code) + +{ + wifi_env.country_code = country_code; + return 0; +} + + + +int bl_wifi_ap_info_set(uint8_t *ssid,uint8_t ssid_len,uint8_t *psk,uint8_t psk_len,uint8_t chan) + +{ + undefined3 in_register_0000202d; + undefined3 in_register_00002035; + + memset(&wifi_env.ap_info,0,99); + memcpy(&wifi_env.ap_info,ssid,CONCAT31(in_register_0000202d,ssid_len)); + memcpy(wifi_env.ap_info.psk,psk,CONCAT31(in_register_00002035,psk_len)); + wifi_env.ap_info.chan = chan; + wifi_env.ap_info_en = '\x01'; + return 0; +} + + + +int bl_wifi_sta_info_set + (uint8_t *ssid,uint8_t ssid_len,uint8_t *psk,uint8_t psk_len,int autoconnect) + +{ + undefined3 in_register_0000202d; + undefined3 in_register_00002035; + + memset(&wifi_env.sta_info,0,99); + memcpy(&wifi_env.sta_info,ssid,CONCAT31(in_register_0000202d,ssid_len)); + memcpy(wifi_env.sta_info.psk,psk,CONCAT31(in_register_00002035,psk_len)); + wifi_env.sta_info_en = (uint8_t)autoconnect; + return 0; +} + + + +int bl_wifi_sta_info_get(bl_wifi_ap_info_t *sta_info) + +{ + if (wifi_env.sta_info_en == '\x01') { + memcpy(sta_info,&wifi_env.sta_info,99); + return 0; + } + return -1; +} + + + +int cmd_timer_start(void) + +{ + TIMER_CFG_Type TStack40; + + memcpy(&TStack40,&DAT_23083d64,0x18); + TIMER_IntMask(TIMER_CH1,TIMER_INT_ALL,MASK); + TIMER_Disable(TStack40.timerCh); + TIMER_Init(&TStack40); + TIMER_ClearIntStatus(TStack40.timerCh,TIMER_COMP_ID_0); + TIMER_ClearIntStatus(TStack40.timerCh,TIMER_COMP_ID_1); + TIMER_ClearIntStatus(TStack40.timerCh,TIMER_COMP_ID_2); + TIMER_IntMask(TStack40.timerCh,TIMER_INT_COMP_0,UNMASK); + TIMER_IntMask(TStack40.timerCh,TIMER_INT_COMP_1,MASK); + TIMER_IntMask(TStack40.timerCh,TIMER_INT_COMP_2,MASK); + TIMER_Enable(TStack40.timerCh); + bl_irq_enable(0x35); + bl_irq_register(0x35,int_timer_cb); + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void cmd_wdt_disable(void) + +{ + _DAT_4000a564 = _DAT_4000a564 & 0xfffffffe; + _DAT_4000a59c = _DAT_4000a59c & 0xffff0000 | 0xbaba; + _DAT_4000a5a0 = _DAT_4000a5a0 & 0xffff0000 | 0xeb10; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void cmd_wdt_feed(void) + +{ + _DAT_4000a598 = _DAT_4000a598 | 1; + _DAT_4000a59c = _DAT_4000a59c & 0xffff0000 | 0xbaba; + _DAT_4000a5a0 = _DAT_4000a5a0 & 0xffff0000 | 0xeb10; + return; +} + + + +void cmd_wdt_init(int param_1,undefined4 *param_2) + +{ + int ms; + + if (param_1 != 2) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Usage: %s ms\r\n",&DAT_2307f16c,"bl_wdt_cli.c",0x2a,*param_2); + return; + } + ms = atoi((char *)param_2[1]); + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Init WDT with %dms\r\n",&DAT_2307f16c,"bl_wdt_cli.c",0x2e,ms); + if (0 < ms) { + bl_wdt_init(ms); + return; + } + return; +} + + + +int bl_wdt_cli_init(void) + +{ + return 0; +} + + + +uint32_t fdt32_to_cpu(fdt32_t x) + +{ + return (x >> 0x10 & 0xff) << 8 | x << 0x18 | x >> 0x18 | (x >> 8 & 0xff) << 0x10; +} + + + +int dev_uart_init(uint8_t id,char *path,uint32_t rx_buf_size,uint32_t tx_buf_size) + +{ + uart_dev_t **ppuVar1; + undefined3 in_register_00002029; + uint uVar2; + TickType_t TVar3; + char *format; + void *pvVar4; + int iVar5; + undefined4 uVar6; + uart_dev_t *__s; + + uVar2 = CONCAT31(in_register_00002029,id); + if ((uVar2 < 3) && (path != (char *)0x0)) { + if (uVar2 == 0) { + ppuVar1 = &dev_uart0; + __s = dev_uart0; + } + else { + if (uVar2 != 1) { + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return -1; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_uart) { + return -1; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar6 = 0x74; + format = "[%10u][%s: %s:%4d] err.\r\n"; + goto LAB_23035abc; + } + ppuVar1 = &dev_uart1; + __s = dev_uart1; + } + if (__s == (uart_dev_t *)0x0) { + __s = (uart_dev_t *)pvPortMalloc(0x3c); + *ppuVar1 = __s; + if (__s == (uart_dev_t *)0x0) { + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return -1; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_uart) { + return -1; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar6 = 0x3c; + } + else { + memset(__s,0,0x3c); + (*ppuVar1)->read_block_flag = '\x02'; + (*ppuVar1)->priv = (void *)0x0; + __s = *ppuVar1; + pvVar4 = pvPortMalloc(4); + __s->priv = pvVar4; + if ((*ppuVar1)->priv != (void *)0x0) { + memset((*ppuVar1)->priv,0,4); + (*ppuVar1)->rx_buf_size = rx_buf_size; + (*ppuVar1)->tx_buf_size = tx_buf_size; + if (*ppuVar1 == (uart_dev_t *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] mem err.\r\n",TVar3,&DAT_23072bcc,"hal_uart.c",0x50); + } + } + else { + (*ppuVar1)->port = id; + (*ppuVar1)->read_block_flag = '\x02'; + ((*ppuVar1)->config).baud_rate = 0x1c200; + ((*ppuVar1)->config).data_width = DATA_WIDTH_8BIT; + ((*ppuVar1)->config).parity = NO_PARITY; + ((*ppuVar1)->config).stop_bits = STOP_BITS_1; + ((*ppuVar1)->config).flow_control = FLOW_CONTROL_DISABLED; + ((*ppuVar1)->config).mode = MODE_TX_RX; + } + iVar5 = aos_register_driver(path,(file_ops_t *)&uart_ops,*ppuVar1); + return iVar5; + } + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return -1; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_uart) { + return -1; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar6 = 0x45; + } + format = "[%10u][%s: %s:%4d] mem err.\r\n"; + goto LAB_23035abc; + } + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return -1; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_uart) { + return -1; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar6 = 0x36; + } + else { + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return -1; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_uart) { + return -1; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar6 = 0x65; + } + format = "[%10u][%s: %s:%4d] arg err.\r\n"; +LAB_23035abc: + bl_printk(format,TVar3,&DAT_23072bcc,"hal_uart.c",uVar6); + return -1; +} + + + +int32_t hal_uart_send_trigger(uart_dev_t *uart) + +{ + bl_uart_int_tx_enable(uart->port); + return 0; +} + + + +int32_t hal_uart_send_trigger_off(uart_dev_t *uart) + +{ + bl_uart_int_tx_disable(uart->port); + return 0; +} + + + +int32_t hal_uart_init(uart_dev_t *uart) + +{ + int iVar1; + int iVar2; + hal_uart_parity_t ahStack17 [4]; + uint8_t parity; + + iVar2 = aos_mutex_new((aos_mutex_t *)uart->priv); + iVar1 = -1; + if (iVar2 == 0) { + bl_uart_getdefconfig(uart->port,ahStack17); + if (ahStack17[0] == NO_PARITY) { + (uart->config).parity = NO_PARITY; + } + else { + if (ahStack17[0] != ODD_PARITY) { + ahStack17[0] = EVEN_PARITY; + } + (uart->config).parity = ahStack17[0]; + } + bl_uart_int_enable(uart->port); + iVar1 = iVar2; + } + return iVar1; +} + + + +int32_t hal_uart_recv_II(uart_dev_t *uart,void *data,uint32_t expect_size,uint32_t *recv_size, + uint32_t timeout) + +{ + uint32_t uVar1; + int iVar2; + + uVar1 = 0; + while (uVar1 != expect_size) { + iVar2 = bl_uart_data_recv(uart->port); + if (iVar2 < 0) break; + *(undefined *)((int)data + uVar1) = (char)iVar2; + uVar1 = uVar1 + 1; + } + *recv_size = uVar1; + return 0; +} + + + +int32_t hal_uart_send(uart_dev_t *uart,void *data,uint32_t size,uint32_t timeout) + +{ + uint8_t data_00; + uint8_t *puVar1; + + puVar1 = (uint8_t *)((int)data + size); + while ((uint8_t *)data != puVar1) { + data_00 = *(uint8_t *)data; + data = (uint8_t *)data + 1; + bl_uart_data_send(uart->port,data_00); + } + return 0; +} + + + +int32_t hal_uart_finalize(uart_dev_t *uart) + +{ + aos_mutex_t *mutex; + + mutex = (aos_mutex_t *)uart->priv; + bl_uart_int_disable(uart->port); + aos_mutex_free(mutex); + return 0; +} + + + +int32_t hal_uart_notify_register(uart_dev_t *uart,hal_uart_int_t type,anon_subr_void_void_ptr *cb) + +{ + undefined3 in_register_0000202d; + + if (CONCAT31(in_register_0000202d,type) == 0) { + bl_uart_int_tx_notify_register(uart->port,(cb_uart_notify_t *)cb,uart); + } + else { + if (CONCAT31(in_register_0000202d,type) != 1) { + return -1; + } + bl_uart_int_rx_notify_register(uart->port,(cb_uart_notify_t *)cb,uart); + } + return 0; +} + + + +undefined4 vfs_uart_init(void *param_1,int param_2) + +{ + int nodeoffset; + char *property; + int nodeoffset_00; + TickType_t TVar1; + fdt32_t *pfVar2; + uint32_t baudrate; + uint32_t uVar3; + int iVar4; + char *__s2; + uint32_t uVar5; + undefined4 uVar6; + int iVar7; + char *name; + fdt32_t x; + fdt32_t x_00; + char **ppcVar8; + uint32_t rx_buf_size; + uint32_t tx_buf_size; + fdt32_t x_01; + uint8_t uStack152; + char **ppcStack148; + uint local_7c; + char *pcStack120; + char *pcStack116; + char *local_70; + undefined4 uStack108; + byte bStack104; + uint8_t uStack92; + uint8_t uStack80; + uint8_t uStack68; + char *apcStack64 [3]; + + if (inited == '\x01') { + return 0; + } + pcStack120 = "uart@4000A000"; + pcStack116 = "uart@4000A100"; + local_7c = 0; + memcpy(&local_70,&PTR_DAT_230845d0,0x30); + ppcStack148 = &pcStack120; + iVar7 = 0; + do { + name = *ppcStack148; + nodeoffset = fdt_subnode_offset(param_1,param_2,name); + if (nodeoffset < 1) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 300; + goto LAB_23035e5a; + } + } + else { + name = (char *)fdt_stringlist_count(param_1,nodeoffset,"status"); + if (name == (char *)0x1) { + name = fdt_stringlist_get(param_1,nodeoffset,"status",0,(int *)&local_7c); + if ((local_7c == 4) && (nodeoffset_00 = memcmp(&DAT_23084714,name,4), nodeoffset_00 == 0)) { + name = (char *)fdt_stringlist_count(param_1,nodeoffset,"path"); + if (name == (char *)0x1) { + name = fdt_stringlist_get(param_1,nodeoffset,"path",0,(int *)&local_7c); + if (((0x20 < local_7c) && (_fsymc_level_hal_drv < BLOG_LEVEL_WARN)) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] path lentmp = %d\r\n",TVar1,&DAT_2307f16c, + "hal_uart.c",0x144,iVar7,local_7c); + } + pfVar2 = (fdt32_t *)fdt_getprop(param_1,nodeoffset,"baudrate",(int *)&local_7c); + if (pfVar2 == (fdt32_t *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x14b; + name = "[%10u][%s: %s:%4d] uart[%d] baudrate NULL.\r\n"; +LAB_23036086: + bl_printk(name,&DAT_2307f16c,"hal_uart.c",uVar6,iVar7); + } + } + else { + x_00 = *pfVar2; + pfVar2 = (fdt32_t *)fdt_getprop(param_1,nodeoffset,"id",(int *)&local_7c); + if (pfVar2 == (fdt32_t *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x153; + name = "[%10u][%s: %s:%4d] uart[%d] id NULL.\r\n"; + goto LAB_23036086; + } + } + else { + x = *pfVar2; + nodeoffset_00 = fdt_subnode_offset(param_1,nodeoffset,"buf_size"); + if (nodeoffset_00 < 1) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] buf_size NULL, will use default.\r\n", + TVar1,&DAT_2307f16c,"hal_uart.c",0x15b,iVar7); + } + tx_buf_size = 0x200; + rx_buf_size = 0x200; +LAB_2303620a: + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] rx_buf_size %d, tx_buf_size %d\r\n",TVar1 + ,&DAT_2307f16c,"hal_uart.c",0x16c,iVar7,rx_buf_size,tx_buf_size); + } + baudrate = fdt32_to_cpu(x_00); + uVar3 = fdt32_to_cpu(x); + ppcVar8 = &local_70; + do { + nodeoffset_00 = fdt_subnode_offset(param_1,nodeoffset,"feature"); + if (nodeoffset_00 < 1) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] feature NULL.\r\n",TVar1, + &DAT_2307f16c,"hal_uart.c",0x171,iVar7); + } + } + else { + property = *ppcVar8; + iVar4 = fdt_stringlist_count(param_1,nodeoffset_00,property); + if (iVar4 == 1) { + __s2 = fdt_stringlist_get(param_1,nodeoffset_00,property,0,(int *)&local_7c) + ; + if ((local_7c == 4) && + (nodeoffset_00 = memcmp(&DAT_23084714,__s2,4), nodeoffset_00 == 0)) { + nodeoffset_00 = fdt_subnode_offset(param_1,nodeoffset,"pin"); + if (nodeoffset_00 < 1) { + if ((BLOG_LEVEL_INFO < _fsymc_level_hal_drv) || + (BLOG_LEVEL_INFO < _fsymf_level_hal_drvhal_uart)) goto LAB_230363c4; + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] pin NULL.\r\n",TVar1, + &DAT_2307f16c,"hal_uart.c",0x182,iVar7); + break; + } + property = ppcVar8[1]; + pfVar2 = (fdt32_t *) + fdt_getprop(param_1,nodeoffset_00,property,(int *)&local_7c); + if (pfVar2 == (fdt32_t *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] %s NULL.\r\n",TVar1, + &DAT_2307f16c,"hal_uart.c",0x187,iVar7,property); + } + } + else { + uVar5 = fdt32_to_cpu(*pfVar2); + *(char *)(ppcVar8 + 2) = (char)uVar5; + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] %s status = %s lentmp = %d\r\n", + TVar1,&DAT_2307f16c,"hal_uart.c",0x17b,iVar7,property,__s2); + } + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] %s countindex = %d.\r\n",TVar1, + &DAT_2307f16c,"hal_uart.c",0x176,iVar7,property,iVar4); + } + } + } + ppcVar8 = ppcVar8 + 3; + } while (apcStack64 != ppcVar8); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] id = %d, %s = %d, %s = %d, %s = %d, %s = %d baudrate = %ld.\r\n" + ,TVar1,&DAT_2307f16c,"hal_uart.c",0x192,uVar3 & 0xff,uStack108, + (uint)bStack104); + } +LAB_230363c4: + uStack152 = (uint8_t)uVar3; + bl_uart_flush(uStack152); + bl_uart_init(uStack152,bStack104,uStack92,uStack80,uStack68,baudrate); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] bl_uart_init %d ok.\r\n",TVar1,&DAT_2307f16c, + "hal_uart.c",0x19a,uVar3 & 0xff); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] bl_uart_init %d baudrate = %ld ok.\r\n",TVar1, + &DAT_2307f16c,"hal_uart.c",0x19b,uVar3 & 0xff,baudrate); + } + } + nodeoffset = dev_uart_init(uStack152,name,rx_buf_size,tx_buf_size); + if (((nodeoffset != 0) && (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] dev_uart_init err.\r\n",&DAT_23072bcc,"hal_uart.c" + ,0x19e); + } + } + else { + pfVar2 = (fdt32_t *)fdt_getprop(param_1,nodeoffset_00,"rx_size",(int *)&local_7c); + if (pfVar2 == (fdt32_t *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + name = "rx_size"; + uVar6 = 0x161; +LAB_23035e5a: + property = "[%10u][%s: %s:%4d] uart[%d] %s NULL.\r\n"; + goto LAB_23035ece; + } + } + else { + x_01 = *pfVar2; + pfVar2 = (fdt32_t *) + fdt_getprop(param_1,nodeoffset_00,"tx_size",(int *)&local_7c); + if (pfVar2 != (fdt32_t *)0x0) { + rx_buf_size = fdt32_to_cpu(x_01); + tx_buf_size = fdt32_to_cpu(*pfVar2); + goto LAB_2303620a; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + name = "tx_size"; + uVar6 = 0x167; + goto LAB_23035e5a; + } + } + } + } + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x13e; + property = "[%10u][%s: %s:%4d] uart[%d] path_countindex = %d NULL.\r\n"; + goto LAB_23035ece; + } + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x137; + property = "[%10u][%s: %s:%4d] uart[%d] status = %s\r\n"; + goto LAB_23035ece; + } + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x132; + property = "[%10u][%s: %s:%4d] uart[%d] status_countindex = %d NULL.\r\n"; +LAB_23035ece: + bl_printk(property,&DAT_2307f16c,"hal_uart.c",uVar6,iVar7,name); + } + } + } + ppcStack148 = ppcStack148 + 1; + if (iVar7 != 0) { + inited = (int8_t)iVar7; + return 0; + } + iVar7 = 1; + } while( true ); +} + + + +int32_t hal_uart_send_flush(uart_dev_t *uart,uint32_t timeout) + +{ + bl_uart_flush(uart->port); + return 0; +} + + + +void hal_uart_setbaud(uart_dev_t *uart,uint32_t baud) + +{ + bl_uart_setbaud(uart->port,baud); + return; +} + + + +void hal_uart_setconfig(uart_dev_t *uart,uint32_t baud,hal_uart_parity_t parity) + +{ + bl_uart_setconfig(uart->port,baud,parity); + return; +} + + + +undefined4 hal_gpio_init_from_dts(void *param_1,int param_2) + +{ + uint uVar1; + uint *puVar2; + int nodeoffset; + char *format; + TickType_t TVar3; + int iVar4; + char *format_00; + undefined *puVar5; + undefined4 uVar6; + uint uVar7; + int iVar8; + int local_5c; + char acStack88 [11]; + undefined uStack77; + uint uStack76; + char cStack72; + byte bStack71; + byte bStack70; + undefined uStack69; + uint uStack68; + + uStack76 = 0; + puVar2 = (uint *)fdt_getprop(param_1,param_2,"max_num",(int *)&uStack76); + uVar1 = 0xffffffff; + if (puVar2 != (uint *)0x0) { + uVar1 = *puVar2; + uVar1 = uVar1 << 0x18 | uVar1 >> 0x18 | (uVar1 >> 8 & 0xff) << 0x10 | + (uVar1 >> 0x10 & 0xff) << 8; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvhal_gpio < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [HAL] [GPIO] Max num is %d\r\n",&DAT_2307f16c,"hal_gpio.c",0xb5, + uVar1); + } + iVar8 = 0; + do { + if ((int)uVar1 <= iVar8) { + return 0; + } + snprintf(acStack88,0xb,"gpio%u",iVar8); + uStack77 = 0; + local_5c = 0; + nodeoffset = fdt_subnode_offset(param_1,param_2,acStack88); + if (nodeoffset < 0) { + if (BLOG_LEVEL_INFO < _fsymc_level_hal_drv) { + return 0; + } + if (BLOG_LEVEL_INFO < _fsymf_level_hal_drvhal_gpio) { + return 0; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %s NOT found\r\n",&DAT_2307f16c,"hal_gpio.c",0x61,acStack88); + return 0; + } + memset(&uStack76,0,0xc); + cStack72 = '\0'; + format = fdt_stringlist_get(param_1,nodeoffset,"status",0,&local_5c); + if ((local_5c == 4) && (iVar4 = memcmp(&DAT_23084714,format,4), iVar4 == 0)) { + puVar2 = (uint *)fdt_getprop(param_1,nodeoffset,"pin",&local_5c); + if (puVar2 == (uint *)0x0) { + if ((BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) || + (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_gpio)) goto LAB_2303678a; + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x70; + format = "[%10u][%s: %s:%4d] no pin found for %s\r\n"; +LAB_23036848: + bl_printk(format,&DAT_23072bcc,"hal_gpio.c",uVar6,acStack88); + } + else { + uVar7 = *puVar2; + uStack76 = (uVar7 >> 0x10 & 0xff) << 8 | + uVar7 << 0x18 | uVar7 >> 0x18 | (uVar7 >> 8 & 0xff) << 0x10; + format = fdt_stringlist_get(param_1,nodeoffset,"feature",0,&local_5c); + if ((local_5c != 3) || (iVar4 = memcmp("led",format,3), iVar4 != 0)) { + if ((BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) || + (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_gpio)) goto LAB_2303678a; + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x79; +LAB_230369ca: + puVar5 = &DAT_23072bcc; + format_00 = "[%10u][%s: %s:%4d] %s: unvalid GPIO config %3s\r\n"; + goto LAB_2303687e; + } + bStack71 = 0; + format = fdt_stringlist_get(param_1,nodeoffset,"active",0,&local_5c); + if (local_5c == 2) { + iVar4 = memcmp(&DAT_23084b70,format,2); + if (iVar4 == 0) { + bStack70 = 1; + } + else { + if ((local_5c != 2) || (iVar4 = memcmp(&DAT_23084b74,format,2), iVar4 != 0)) + goto LAB_23036a06; + bStack70 = 0; + } + format = fdt_stringlist_get(param_1,nodeoffset,"mode",0,&local_5c); + if ((local_5c == 5) && (iVar4 = memcmp("blink",format,5), iVar4 == 0)) { + uStack69 = 0; + } + else { + if ((local_5c != 9) || (iVar4 = memcmp("heartbeat",format,9), iVar4 != 0)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_gpio < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x8d; + goto LAB_230369ca; + } + goto LAB_2303678a; + } + uStack69 = 1; + } + puVar2 = (uint *)fdt_getprop(param_1,nodeoffset,"time",&local_5c); + if (puVar2 == (uint *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_gpio < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x93; + format = "[%10u][%s: %s:%4d] %s: unvalid GPIO config\r\n"; + goto LAB_23036848; + } + } + else { + uVar7 = *puVar2; + uStack68 = (uVar7 >> 0x10 & 0xff) << 8 | + uVar7 << 0x18 | uVar7 >> 0x18 | (uVar7 >> 8 & 0xff) << 0x10; + cStack72 = '\x01'; + } + } + else { +LAB_23036a06: + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_gpio < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x83; + goto LAB_230369ca; + } + } + } + } + else { + if ((BLOG_LEVEL_INFO < _fsymc_level_hal_drv) || + (BLOG_LEVEL_INFO < _fsymf_level_hal_drvhal_gpio)) goto LAB_2303678a; + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x6a; + puVar5 = &DAT_2307f16c; + format_00 = "[%10u][%s: %s:%4d] [%s] status = %s\r\n"; +LAB_2303687e: + bl_printk(format_00,puVar5,"hal_gpio.c",uVar6,acStack88,format); + } +LAB_2303678a: + if (cStack72 == '\x01') { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_gpio < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] New CONF: GPIO%02u: feature %u, active %u, mode %u, time %u\r\n" + ,TVar3,&DAT_2307f16c,"hal_gpio.c",0xa6,uStack76,(uint)bStack71,(uint)bStack70); + } + loopset_led_trigger(uStack76,uStack68); + } + else { + if (((cStack72 == '\0') && (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvhal_gpio < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %s: unvalid GPIO config\r\n",&DAT_23072bcc,"hal_gpio.c",0xc3, + acStack88); + } + } + iVar8 = iVar8 + 1; + } while( true ); +} + + + +void _dump_partition(void) + +{ + int iVar1; + anon_struct_conflict371 *paVar2; + + bl_printk("======= PtTable_Config @%p=======\r\n",0x4200d9cc); + bl_printk("magicCode 0x%08X;",boot2_partition_table.table.ptTable.magicCode); + bl_printk(" version 0x%04X;",(uint)boot2_partition_table.table.ptTable.version); + bl_printk(" entryCnt %u;",(uint)boot2_partition_table.table.ptTable.entryCnt); + bl_printk(" age %lu;",boot2_partition_table.table.ptTable.age); + bl_printk(" crc32 0x%08X\r\n"); + bl_printk( + "idx type device activeIndex name Address[0] Address[1] Length[0] Length[1] age\r\n" + ); + iVar1 = 0; + paVar2 = &boot2_partition_table; + while( true ) { + if ((int)(uint)boot2_partition_table.table.ptTable.entryCnt <= iVar1) break; + bl_printk("[%02d] ",iVar1); + iVar1 = iVar1 + 1; + bl_printk(" %02u",(uint)(paVar2->table).ptEntries[0].type); + bl_printk(" %u",(uint)(paVar2->table).ptEntries[0].device); + bl_printk(" %u",(uint)(paVar2->table).ptEntries[0].activeIndex); + bl_printk(" %8s",(paVar2->table).ptEntries[0].name); + bl_printk(" %p",(paVar2->table).ptEntries[0].Address[0]); + bl_printk(" %p",(paVar2->table).ptEntries[0].Address[1]); + bl_printk(" %p",(paVar2->table).ptEntries[0].maxLen[0]); + bl_printk(" %p",(paVar2->table).ptEntries[0].maxLen[1]); + bl_printk(" %lu\r\n"); + paVar2 = (anon_struct_conflict371 *)((paVar2->table).ptEntries[0].Address + 1); + } + return; +} + + + +int hal_boot2_update_ptable(HALPartition_Entry_Config *ptEntry_hal) + +{ + uint8_t uVar1; + PtTable_Error_Type PVar2; + undefined3 extraout_var; + + *(bool *)&ptEntry_hal->activeIndex = ptEntry_hal->activeIndex == '\0'; + uVar1 = boot2_partition_table.partition_active_idx; + ptEntry_hal->age = ptEntry_hal->age + 1; + PVar2 = PtTable_Update_Entry + ((SPI_Flash_Cfg_Type *)0x0,uVar1 == '\0',&boot2_partition_table.table, + (PtTable_Entry_Config *)ptEntry_hal); + return CONCAT31(extraout_var,PVar2); +} + + + +uint32_t hal_boot2_get_flash_addr(void) + +{ + return (uint)boot2_partition_table.table.ptTable.entryCnt * 0x24 + 0x42049c18; +} + + + +int hal_boot2_partition_bus_addr + (char *name,uint32_t *addr0,uint32_t *addr1,uint32_t *size0,uint32_t *size1, + int *active) + +{ + byte bVar1; + uint uVar2; + uint uVar3; + int iVar4; + anon_struct_conflict371 *paVar5; + uint uVar6; + uint uVar7; + anon_struct_conflict371 *paVar8; + + if (boot2_partition_table.table.ptTable.magicCode != 0x54504642) { + return -5; + } + paVar8 = &boot2_partition_table; + paVar5 = &boot2_partition_table; + uVar2 = 0; + while ((int)uVar2 < (int)(uint)boot2_partition_table.table.ptTable.entryCnt) { + iVar4 = strcmp((char *)(paVar5->table).ptEntries[0].name,name); + paVar5 = (anon_struct_conflict371 *)((paVar5->table).ptEntries[0].Address + 1); + if (iVar4 == 0) break; + uVar2 = uVar2 + 1; + } + iVar4 = -2; + if (uVar2 != (uint)boot2_partition_table.table.ptTable.entryCnt) { + uVar7 = boot2_partition_table.table.ptEntries[uVar2].Address[0]; + uVar6 = boot2_partition_table.table.ptEntries[uVar2].Address[1]; + *active = (uint)boot2_partition_table.table.ptEntries[uVar2].activeIndex; + *size0 = boot2_partition_table.table.ptEntries[uVar2].maxLen[0]; + uVar3 = 0; + *size1 = *(uint32_t *)((int)&boot2_partition_table.table.ptTable + (uVar2 + 1) * 0x24 + 4); + while ((int)uVar3 < (int)(uint)boot2_partition_table.table.ptTable.entryCnt) { + iVar4 = strcmp((char *)(paVar8->table).ptEntries[0].name,"FW"); + paVar8 = (anon_struct_conflict371 *)((paVar8->table).ptEntries[0].Address + 1); + if (iVar4 == 0) break; + uVar3 = uVar3 + 1; + } + iVar4 = -0x8c; + if (uVar3 != (uint)boot2_partition_table.table.ptTable.entryCnt) { + if (uVar7 != 0) { + if (uVar7 < boot2_partition_table.table.ptEntries[uVar3].Address[0]) { + return -0x16; + } + if (uVar7 < boot2_partition_table.table.ptEntries[uVar3].Address[1]) { + return -0x16; + } + } + if (uVar6 != 0) { + if (uVar6 < boot2_partition_table.table.ptEntries[uVar3].Address[0]) { + return -0x16; + } + if (uVar6 < boot2_partition_table.table.ptEntries[uVar3].Address[1]) { + return -0x16; + } + } + iVar4 = -0xe; + bVar1 = boot2_partition_table.table.ptEntries[uVar3].activeIndex; + if (bVar1 < 2) { + iVar4 = 0; + *addr0 = (uVar7 + 0x22fff000) - + (&boot2_partition_table.table.ptTable.crc32)[(uint)bVar1 + uVar3 * 9 + 4]; + *addr1 = (uVar6 + 0x22fff000) - + (&boot2_partition_table.table.ptTable.crc32) + [uVar3 * 9 + (uint)boot2_partition_table.table.ptEntries[uVar3].activeIndex + 4]; + } + } + } + return iVar4; +} + + + +int hal_boot2_partition_bus_addr_active(char *name,uint32_t *addr,uint32_t *size) + +{ + int iVar1; + uint32_t uStack36; + uint32_t addr0; + uint32_t addr1; + uint32_t size0; + uint32_t size1; + int active; + + iVar1 = hal_boot2_partition_bus_addr(name,&uStack36,&addr0,&addr1,&size0,(int *)&size1); + if (iVar1 == 0) { + if (size1 != 0) { + uStack36 = addr0; + } + *addr = uStack36; + if (size1 != 0) { + addr1 = size0; + } + *size = addr1; + } + return iVar1; +} + + + +int hal_boot2_partition_bus_addr_inactive(char *name,uint32_t *addr,uint32_t *size) + +{ + int iVar1; + uint32_t uStack36; + uint32_t addr0; + uint32_t addr1; + uint32_t size0; + uint32_t size1; + int active; + + iVar1 = hal_boot2_partition_bus_addr(name,&uStack36,&addr0,&addr1,&size0,(int *)&size1); + if (iVar1 == 0) { + if (size1 != 0) { + addr0 = uStack36; + } + *addr = addr0; + if (size1 != 0) { + size0 = addr1; + } + *size = size0; + } + return iVar1; +} + + + +int hal_boot2_partition_addr + (char *name,uint32_t *addr0,uint32_t *addr1,uint32_t *size0,uint32_t *size1, + int *active) + +{ + uint uVar1; + anon_struct_conflict371 *paVar2; + int iVar3; + + if (boot2_partition_table.table.ptTable.magicCode == 0x54504642) { + paVar2 = &boot2_partition_table; + uVar1 = 0; + while ((int)uVar1 < (int)(uint)boot2_partition_table.table.ptTable.entryCnt) { + iVar3 = strcmp((char *)(paVar2->table).ptEntries[0].name,name); + paVar2 = (anon_struct_conflict371 *)((paVar2->table).ptEntries[0].Address + 1); + if (iVar3 == 0) break; + uVar1 = uVar1 + 1; + } + iVar3 = -2; + if (uVar1 != (uint)boot2_partition_table.table.ptTable.entryCnt) { + *addr0 = boot2_partition_table.table.ptEntries[uVar1].Address[0]; + *addr1 = boot2_partition_table.table.ptEntries[uVar1].Address[1]; + *size0 = boot2_partition_table.table.ptEntries[uVar1].maxLen[0]; + *size1 = *(uint32_t *)((int)&boot2_partition_table.table.ptTable + (uVar1 + 1) * 0x24 + 4); + iVar3 = 0; + *active = (uint)boot2_partition_table.table.ptEntries[uVar1].activeIndex; + } + } + else { + iVar3 = -5; + } + return iVar3; +} + + + +int hal_boot2_partition_addr_active(char *name,uint32_t *addr,uint32_t *size) + +{ + int iVar1; + uint32_t uStack36; + uint32_t addr0; + uint32_t addr1; + uint32_t size0; + uint32_t size1; + int active; + + iVar1 = hal_boot2_partition_addr(name,&uStack36,&addr0,&addr1,&size0,(int *)&size1); + if (iVar1 == 0) { + if (size1 != 0) { + uStack36 = addr0; + } + *addr = uStack36; + if (size1 != 0) { + addr1 = size0; + } + *size = addr1; + } + return iVar1; +} + + + +int hal_boot2_partition_addr_inactive(char *name,uint32_t *addr,uint32_t *size) + +{ + int iVar1; + uint32_t uStack36; + uint32_t addr0; + uint32_t addr1; + uint32_t size0; + uint32_t size1; + int active; + + iVar1 = hal_boot2_partition_addr(name,&uStack36,&addr0,&addr1,&size0,(int *)&size1); + if (iVar1 == 0) { + if (size1 != 0) { + addr0 = uStack36; + } + *addr = addr0; + if (size1 != 0) { + size0 = addr1; + } + *size = size0; + } + return iVar1; +} + + + +uint8_t hal_boot2_get_active_partition(void) + +{ + return boot2_partition_table.partition_active_idx; +} + + + +int hal_boot2_get_active_entries(int type,HALPartition_Entry_Config *ptEntry_hal) + +{ + PtTable_Error_Type PVar1; + undefined3 extraout_var; + + PVar1 = PtTable_Get_Active_Entries + (&boot2_partition_table.table,(PtTable_Entry_Type)type, + (PtTable_Entry_Config *)ptEntry_hal); + return -(uint)(CONCAT31(extraout_var,PVar1) != 0); +} + + + +int hal_boot2_dump(void) + +{ + _dump_partition(); + return 0; +} + + + +int hal_boot2_init(void) + +{ + TickType_t TVar1; + + boot2_partition_table.partition_active_idx = ram_heap[7232]; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvhal_boot2 < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [HAL] [BOOT2] Active Partition[%u] consumed %d Bytes\r\n",TVar1, + &DAT_2307f16c,"hal_boot2.c",0x114,(uint)boot2_partition_table.partition_active_idx, + 0x254); + } + _dump_partition(); + bl_flash_config_update(); + return 0; +} + + + +int hal_reboot(void) + +{ + GLB_SW_POR_Reset(); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void hal_sys_reset(void) + +{ + GLB_SW_System_Reset(); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void hal_poweroff(void) + +{ + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_sys_capcode_update(uint8_t capin,uint8_t capout) + +{ + uint8_t capin_static; + uint8_t capout_static; + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + + if ((CONCAT31(in_register_00002029,capin) != 0xff) && + (CONCAT31(in_register_0000202d,capout) != 0xff)) { + (*_DAT_2101081c)(); + return; + } + // WARNING: Could not recover jumptable at 0x230370ea. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_2101081c)((uint)capin_static,(uint)capout_static); + return; +} + + + +uint8_t hal_sys_capcode_get(void) + +{ + uint8_t uVar1; + + uVar1 = AON_Get_Xtal_CapCode(); + return uVar1; +} + + + +uint32_t fdt32_to_cpu(fdt32_t x) + +{ + return (x >> 0x10 & 0xff) << 8 | x << 0x18 | x >> 0x18 | (x >> 8 & 0xff) << 0x10; +} + + + +uint32_t hal_board_get_factory_addr(void) + +{ + return factory_addr; +} + + + +// WARNING: Could not reconcile some variable overlaps + +undefined4 hal_board_cfg(void) + +{ + char cVar1; + byte bVar2; + uint32_t fdt; + int parentoffset; + TickType_t TVar3; + int nodeoffset; + int iVar4; + char *format; + size_t sVar5; + uint32_t uVar6; + uint32_t uVar7; + void *__src; + uint32_t autoconnect; + fdt32_t x; + int iVar8; + int iVar9; + char *pcVar10; + uint8_t chan; + undefined4 uVar11; + size_t *psVar12; + size_t *psVar13; + byte *pbVar14; + fdt32_t *pfVar15; + uint8_t capin; + uint8_t psk_len; + fdt32_t *pfVar16; + int iStack220; + byte local_c4 [4]; + uint32_t uStack192; + int iStack188; + size_t sStack184; + size_t local_b4; + size_t local_b0 [4]; + size_t local_a0 [3]; + size_t asStack146 [4]; + undefined4 local_80; + byte bStack124; + byte bStack123; + + parentoffset = hal_boot2_partition_addr_active("factory",&factory_addr,&uStack192); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [MAIN] [BOARD] [FLASH] addr from partition is %08x, ret is %d\r\n" + ,TVar3,&DAT_2307f16c,"hal_board.c",0x376,factory_addr,parentoffset); + } + if (factory_addr == 0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] [MAIN] [BOARD] [FLASH] Dead loop. Reason: NO valid Param Parition found\r\n" + ,TVar3,&DAT_23072bcc,"hal_board.c",0x378); + } + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + parentoffset = hal_boot2_partition_bus_addr_active("factory",&factory_addr,&uStack192); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [MAIN] [BOARD] [XIP] addr from partition is %08x, ret is %d\r\n", + TVar3,&DAT_2307f16c,"hal_board.c",0x37e,factory_addr,parentoffset); + } + fdt = factory_addr; + if (factory_addr == 0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] [MAIN] [BOARD] [XIP] Dead loop. Reason: NO valid Param Parition found\r\n" + ,TVar3,&DAT_23072bcc,"hal_board.c",0x380); + } + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + iStack188 = 0; + parentoffset = fdt_subnode_offset((void *)factory_addr,0,"wifi"); + if (((parentoffset < 1) && (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] wifi NULL.\r\n",TVar3,&DAT_23072bcc,"hal_board.c",0x242); + } + nodeoffset = fdt_subnode_offset((void *)fdt,parentoffset,"brd_rf"); + if (0 < nodeoffset) { + local_a0[0] = 0; + iVar4 = fdt_stringlist_count((void *)fdt,nodeoffset,"xtal_mode"); + if (iVar4 == 1) { + format = fdt_stringlist_get((void *)fdt,nodeoffset,"xtal_mode",0,(int *)local_a0); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] xtal_mode length %d\r\n",TVar3,&DAT_2307f16c,"hal_board.c", + 0x141,local_a0[0]); + } + if ((int)local_a0[0] < 3) { + memcpy(local_b0,format,local_a0[0]); + local_b0[0] = local_b0[0] & 0xff00ffff; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] xtal_mode is %s\r\n",TVar3,&DAT_2307f16c,"hal_board.c",0x145 + ,local_b0); + } + sVar5 = strlen((char *)local_b0); + iVar4 = 0; + while (iVar4 < (int)sVar5) { + if (*(char *)((int)local_b0 + iVar4) == 'F') { + local_80 = 0; + pfVar15 = (fdt32_t *)fdt_getprop((void *)fdt,nodeoffset,"xtal",&local_80); + if (local_80 == 0x14) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + autoconnect = fdt32_to_cpu(*pfVar15); + uVar6 = fdt32_to_cpu(pfVar15[1]); + uVar7 = fdt32_to_cpu(pfVar15[2]); + fdt32_to_cpu(pfVar15[3]); + fdt32_to_cpu(pfVar15[4]); + bl_printk("[%10u][%s: %s:%4d] xtal dtb in DEC :%u %u %u %u %u\r\n",TVar3, + &DAT_2307f16c,"hal_board.c",0xf9,autoconnect & 0xff,uVar6 & 0xff, + uVar7 & 0xff); + } + autoconnect = fdt32_to_cpu(*pfVar15); + capin = (uint8_t)autoconnect; + autoconnect = fdt32_to_cpu(pfVar15[1]); + local_80._0_1_ = (byte)autoconnect; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] get xtal from F ready\r\n",TVar3,"DEBUG ", + "hal_board.c",0x114); + } + goto LAB_23037596; + } + if (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) { + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] xtal dtb NULL.",TVar3,&DAT_23072bcc,"hal_board.c", + 0x100); + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x117; + format = "[%10u][%s: %s:%4d] get xtal from F failed\r\n"; + goto LAB_23037900; + } + } + } + else { + if (*(char *)((int)local_b0 + iVar4) != 'M') { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ASSERT: %s:%d\r\n",TVar3,&UNK_2307c064,"hal_board.c", + 0x128,"hal_board.c",0x128); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + local_80 = local_80 & 0xffffff00; + iVar8 = bl_efuse_read_capcode((uint8_t *)&local_80); + if (iVar8 == 0) { + capin = (byte)local_80; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] get xtal from M ready\r\n",TVar3,"DEBUG ", + "hal_board.c",0x11f); + } + goto LAB_23037596; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x122; + format = "[%10u][%s: %s:%4d] get xtal from M failed\r\n"; +LAB_23037900: + bl_printk(format,TVar3,"DEBUG ","hal_board.c",uVar11); + } + } + iVar4 = iVar4 + 1; + if (iVar4 == 2) break; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Using Default xtal\r\n",TVar3,&DAT_2307f16c,"hal_board.c", + 0x12e); + } + local_80._0_1_ = '2'; + capin = '2'; +LAB_23037596: + hal_sys_capcode_update(capin,(byte)local_80); + } + } + __src = fdt_getprop((void *)fdt,nodeoffset,"channel_div_table",&iStack188); + if (iStack188 == 0x3c) { + iVar4 = 0; + do { + autoconnect = fdt32_to_cpu(*(fdt32_t *)((int)__src + iVar4)); + *(uint32_t *)((int)&local_80 + iVar4) = autoconnect; + iVar4 = iVar4 + 4; + } while (iVar4 != 0x3c); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] channel_div_table :\r\n",TVar3,&DAT_2307f16c,"hal_board.c",600 + ); + } + log_buf_out("hal_board.c",0x259,&local_80,0x3c,LOG_BUF_OUT_DATA_TYPE_HEX); + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] channel_div_table NULL.\r\n",TVar3,&DAT_23072bcc,"hal_board.c" + ,0x25b); + } + } + pfVar15 = (fdt32_t *)fdt_getprop((void *)fdt,nodeoffset,"channel_cnt_table",&iStack188); + if (iStack188 == 0x38) { + pfVar16 = pfVar15 + 0xe; + psVar12 = local_a0; + do { + x = *pfVar15; + pfVar15 = pfVar15 + 1; + autoconnect = fdt32_to_cpu(x); + *(short *)psVar12 = (short)autoconnect; + psVar12 = (size_t *)((int)psVar12 + 2); + } while (pfVar16 != pfVar15); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] channel_cnt_table :\r\n",TVar3,&DAT_2307f16c,"hal_board.c", + 0x263); + } + log_buf_out("hal_board.c",0x264,local_a0,0x38,LOG_BUF_OUT_DATA_TYPE_HEX); + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] channel_cnt_table NULL.\r\n",TVar3,&DAT_23072bcc,"hal_board.c" + ,0x266); + } + } + pfVar15 = (fdt32_t *)fdt_getprop((void *)fdt,nodeoffset,"lo_fcal_div",&iStack188); + if (iStack188 == 4) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + x = *pfVar15; + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + autoconnect = fdt32_to_cpu(x); + bl_printk("[%10u][%s: %s:%4d] lo_fcal_div : %d\r\n",TVar3,&DAT_2307f16c,"hal_board.c",0x26c, + autoconnect & 0xffff); + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] lo_fcal_div NULL.\r\n",TVar3,&DAT_23072bcc,"hal_board.c",0x26e + ); + } + } + } + nodeoffset = fdt_subnode_offset((void *)fdt,parentoffset,"mac"); + if (0 < nodeoffset) { + local_b4 = 0; + iVar4 = fdt_stringlist_count((void *)fdt,nodeoffset,"mode"); + if (iVar4 == 1) { + format = fdt_stringlist_get((void *)fdt,nodeoffset,"mode",0,(int *)&local_b4); + bl_printk("MAC address mode length %d\r\n",local_b4); + if ((int)local_b4 < 4) { + memcpy(local_b0,format,local_b4); + local_b0[0] = local_b0[0] & 0xffffff; + bl_printk("MAC address mode is %s\r\n",local_b0); + sVar5 = strlen((char *)local_b0); + iVar4 = 0; + do { + if ((int)sVar5 <= iVar4) break; + cVar1 = *(char *)((int)local_b0 + iVar4); + if (cVar1 == 'F') { + __src = fdt_getprop((void *)fdt,nodeoffset,"sta_mac_addr",(int *)local_a0); + if (local_a0[0] == 6) { + memcpy(&local_80,__src,6); + bl_wifi_sta_mac_addr_set((uint8_t *)&local_80); + __src = fdt_getprop((void *)fdt,nodeoffset,"ap_mac_addr",(int *)local_a0); + if (local_a0[0] == 6) { + memcpy(&local_80,__src,6); + bl_wifi_ap_mac_addr_set((uint8_t *)&local_80); + if (BLOG_LEVEL_DEBUG < _fsymc_level_hal_drv) goto LAB_23037b5a; + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x9b; + format = "[%10u][%s: %s:%4d] get MAC from F ready\r\n"; + goto LAB_23037b56; + } + goto LAB_23037b64; + } + if (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) { + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x54; + format = "[%10u][%s: %s:%4d] ap_mac_addr NULL.\r\n"; + goto LAB_23038094; + } + goto LAB_23038098; + } + } + else { + if (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) { + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x47; + format = "[%10u][%s: %s:%4d] sta_mac_addr NULL.\r\n"; +LAB_23038094: + bl_printk(format,TVar3,&DAT_23072bcc,"hal_board.c",uVar11); + } +LAB_23038098: + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x9e; + format = "[%10u][%s: %s:%4d] get MAC from F failed\r\n"; + goto LAB_2303786a; + } + } + } + } + else { + if (cVar1 == 'M') { + iVar8 = bl_efuse_read_mac_factory((uint8_t *)&local_80); + if (iVar8 == 0) { + if (((byte)(bStack123 | + bStack124 | + local_80._3_1_ | local_80._2_1_ | (byte)local_80 | local_80._1_1_) != 0) + && (((byte)local_80 & local_80._1_1_ & local_80._2_1_ & local_80._3_1_ & + bStack124 & bStack123) != 1)) { + if (BLOG_LEVEL_DEBUG < _fsymc_level_hal_drv) goto LAB_23037b5a; + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0xa6; + format = "[%10u][%s: %s:%4d] get MAC from M ready\r\n"; + goto LAB_23037b56; + } + goto LAB_23037b64; + } + } + if ((BLOG_LEVEL_DEBUG < _fsymc_level_hal_drv) || + (BLOG_LEVEL_DEBUG < _fsymf_level_hal_drvhal_board)) goto LAB_2303786e; + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0xa9; + format = "[%10u][%s: %s:%4d] get MAC from M failed\r\n"; + } + else { + if (cVar1 != 'B') { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ASSERT: %s:%d\r\n",TVar3,&UNK_2307c064,"hal_board.c", + 0xaf,"hal_board.c",0xaf); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + bl_efuse_read_mac((uint8_t *)&local_80); + if (((byte)(bStack123 | + bStack124 | + local_80._3_1_ | local_80._2_1_ | (byte)local_80 | local_80._1_1_) != 0) && + (((byte)local_80 & local_80._1_1_ & local_80._2_1_ & local_80._3_1_ & bStack124 & + bStack123) != 1)) { + if (BLOG_LEVEL_DEBUG < _fsymc_level_hal_drv) goto LAB_23037b5a; + if (BLOG_LEVEL_DEBUG < _fsymf_level_hal_drvhal_board) goto LAB_23037b64; + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x90; + format = "[%10u][%s: %s:%4d] get MAC from B ready\r\n"; +LAB_23037b56: + bl_printk(format,TVar3,"DEBUG ","hal_board.c",uVar11); + goto LAB_23037b5a; + } + if ((BLOG_LEVEL_DEBUG < _fsymc_level_hal_drv) || + (BLOG_LEVEL_DEBUG < _fsymf_level_hal_drvhal_board)) goto LAB_2303786e; + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x93; + format = "[%10u][%s: %s:%4d] get MAC from B failed\r\n"; + } +LAB_2303786a: + bl_printk(format,TVar3,"DEBUG ","hal_board.c",uVar11); + } +LAB_2303786e: + iVar4 = iVar4 + 1; + } while (iVar4 != 3); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Using Default MAC address\r\n",TVar3,&DAT_2307f16c, + "hal_board.c",0xb5); + } + memcpy(&local_80,&mac_default_3782,6); +LAB_23037b5a: + if (_fsymc_level_hal_drv < BLOG_LEVEL_WARN) { +LAB_23037b64: + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Set MAC addrress %02X:%02X:%02X:%02X:%02X:%02X\r\n",TVar3, + &DAT_2307f16c,"hal_board.c",0xc0,local_80 & 0xff,local_80 >> 8 & 0xff, + local_80 >> 0x10 & 0xff); + } + } + bl_wifi_ap_mac_addr_set((uint8_t *)&local_80); + bl_wifi_sta_mac_addr_set((uint8_t *)&local_80); + } + } + } + nodeoffset = fdt_subnode_offset((void *)fdt,parentoffset,"region"); + if (0 < nodeoffset) { + pfVar15 = (fdt32_t *)fdt_getprop((void *)fdt,nodeoffset,"country_code",&iStack188); + if (iStack188 == 4) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + autoconnect = fdt32_to_cpu(*pfVar15); + bl_printk("[%10u][%s: %s:%4d] country_code : %d\r\n",TVar3,&DAT_2307f16c,"hal_board.c",0x27f + ,autoconnect & 0xff); + } + autoconnect = fdt32_to_cpu(*pfVar15); + bl_wifi_country_code_set((uint8_t)autoconnect); + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] country_code NULL.\r\n",TVar3,&DAT_23072bcc,"hal_board.c", + 0x283); + } + } + } + nodeoffset = fdt_subnode_offset((void *)fdt,parentoffset,"brd_rf"); + if (nodeoffset < 1) goto LAB_23038860; + __src = fdt_getprop((void *)fdt,nodeoffset,"pwr_table_11b",&iStack188); + if (iStack188 == 0x10) { + iVar4 = 0; + do { + autoconnect = fdt32_to_cpu(*(fdt32_t *)(iVar4 * 4 + (int)__src)); + *(undefined *)((int)&local_80 + iVar4) = (char)autoconnect; + iVar4 = iVar4 + 1; + } while (iVar4 != 4); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table_11b :%u %u %u %u\r\n",TVar3,&DAT_2307f16c, + "hal_board.c",0x298,local_80 & 0xff,local_80 >> 8 & 0xff,local_80 >> 0x10 & 0xff); + } + bl_tpc_update_power_rate_11b((int8_t *)&local_80); + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table_11b NULL. lentmp = %d\r\n",TVar3,&DAT_23072bcc, + "hal_board.c",0x29b,iStack188); + } + } + __src = fdt_getprop((void *)fdt,nodeoffset,"pwr_table_11g",&iStack188); + if (iStack188 == 0x20) { + iVar4 = 0; + do { + autoconnect = fdt32_to_cpu(*(fdt32_t *)(iVar4 * 4 + (int)__src)); + *(undefined *)((int)&local_80 + iVar4) = (char)autoconnect; + iVar4 = iVar4 + 1; + } while (iVar4 != 8); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table_11g :%u %u %u %u %u %u %u %u\r\n",TVar3,&DAT_2307f16c, + "hal_board.c",0x2ac,local_80 & 0xff,local_80 >> 8 & 0xff,local_80 >> 0x10 & 0xff); + } + bl_tpc_update_power_rate_11g((int8_t *)&local_80); + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table_11g NULL. lentmp = %d\r\n",TVar3,&DAT_23072bcc, + "hal_board.c",0x2af,iStack188); + } + } + __src = fdt_getprop((void *)fdt,nodeoffset,"pwr_table_11n",&iStack188); + if (iStack188 == 0x20) { + iVar4 = 0; + do { + autoconnect = fdt32_to_cpu(*(fdt32_t *)(iVar4 * 4 + (int)__src)); + *(undefined *)((int)&local_80 + iVar4) = (char)autoconnect; + iVar4 = iVar4 + 1; + } while (iVar4 != 8); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table_11n :%u %u %u %u %u %u %u %u\r\n",TVar3,&DAT_2307f16c, + "hal_board.c",0x2c0,local_80 & 0xff,local_80 >> 8 & 0xff,local_80 >> 0x10 & 0xff); + } + bl_tpc_update_power_rate_11n((int8_t *)&local_80); + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table_11n NULL. lentmp = %d\r\n",TVar3,&DAT_23072bcc, + "hal_board.c",0x2c3,iStack188); + } + } + sStack184 = 0; + iVar4 = fdt_stringlist_count((void *)fdt,nodeoffset,"pwr_mode"); + if (iVar4 != 1) goto LAB_23038860; + format = fdt_stringlist_get((void *)fdt,nodeoffset,"pwr_mode",0,(int *)&sStack184); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_mode length %d\r\n",TVar3,&DAT_2307f16c,"hal_board.c",0x1c1, + sStack184); + } + if (2 < (int)sStack184) goto LAB_23038860; + memcpy(local_c4,format,sStack184); + local_c4[2] = 0; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_mode is %s\r\n",TVar3,&DAT_2307f16c,"hal_board.c",0x1c5, + local_c4); + } + memset(local_b0,0,0xe); + memset(local_a0,0,0xe); + sVar5 = strlen((char *)local_c4); + pbVar14 = local_c4; + iStack220 = 0; + iVar8 = 0; + do { + if ((int)sVar5 <= iVar8) break; + bVar2 = *pbVar14; + if (bVar2 == 0x46) { +LAB_230383fa: + local_b4 = 0; + __src = fdt_getprop((void *)fdt,nodeoffset,"pwr_offset",(int *)&local_b4); + if (local_b4 != 0x38) { + if (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) { + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_offset NULL. lentmp = %d\r\n",TVar3,&DAT_23072bcc, + "hal_board.c",0x15f,local_b4); + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x1a0; + format = "[%10u][%s: %s:%4d] get pwr offset from F(f) failed\r\n"; + goto LAB_23038748; + } + } + goto LAB_230386be; + } + nodeoffset = 0; + do { + autoconnect = fdt32_to_cpu(*(fdt32_t *)(nodeoffset * 4 + (int)__src)); + *(undefined *)((int)local_a0 + nodeoffset) = (char)autoconnect; + nodeoffset = nodeoffset + 1; + } while (nodeoffset != 0xe); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_offset from dtb:\r\n",TVar3,&DAT_2307f16c,"hal_board.c", + 0x156); + } + log_buf_out("hal_board.c",0x157,local_a0,0xe,LOG_BUF_OUT_DATA_TYPE_HEX); + psVar12 = local_a0; + do { + psVar13 = (size_t *)((int)psVar12 + 1); + *(char *)psVar12 = *(char *)psVar12 + -10; + psVar12 = psVar13; + } while (asStack146 != psVar13); + if (_fsymc_level_hal_drv < BLOG_LEVEL_WARN) { + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_offset from dtb (rebase on %d):\r\n",TVar3,&DAT_2307f16c + ,"hal_board.c",0x15b,10); + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] get pwr offset from F(f) ready\r\n",TVar3,"DEBUG ", + "hal_board.c",399); + } + } + if (*pbVar14 == 0x42) { + nodeoffset = 0; + do { + *(undefined *)((int)local_b0 + nodeoffset) = *(undefined *)((int)local_a0 + nodeoffset); + nodeoffset = nodeoffset + 1; + } while (nodeoffset != 0xe); + if ((BLOG_LEVEL_DEBUG < _fsymc_level_hal_drv) || + (BLOG_LEVEL_DEBUG < _fsymf_level_hal_drvhal_board)) goto LAB_23038844; + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x195; + pcVar10 = "DEBUG "; + format = "[%10u][%s: %s:%4d] Use pwr offset from F only\r\n"; + goto LAB_23038656; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Use pwr offset from f in incremental mode\r\n",TVar3,"DEBUG ", + "hal_board.c",0x199); + } + nodeoffset = 0; + psVar12 = local_b0; + do { + format = (char *)((int)local_a0 + nodeoffset); + nodeoffset = nodeoffset + 1; + *(char *)psVar12 = *format + *(char *)psVar12; + psVar12 = (size_t *)((int)psVar12 + 1); + } while (nodeoffset != 0xe); + goto LAB_23038844; + } + if (bVar2 < 0x47) { + if (bVar2 != 0x42) { +LAB_23037f9e: + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ASSERT: %s:%d\r\n",TVar3,&UNK_2307c064,"hal_board.c",0x1a6, + "hal_board.c",0x1a6); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + } + else { + if (bVar2 != 0x62) { + if (bVar2 != 0x66) goto LAB_23037f9e; + goto LAB_230383fa; + } + } + iVar9 = bl_efuse_read_pwroft((int8_t *)local_a0); + if (iVar9 != 0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x186; + format = "[%10u][%s: %s:%4d] get pwr offset from B(b) failed\r\n"; +LAB_23038748: + bl_printk(format,TVar3,"DEBUG ","hal_board.c",uVar11); + } + goto LAB_230386be; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] get pwr offset from B(b) ready\r\n",TVar3,&DAT_2307f16c, + "hal_board.c",0x175); + } + log_buf_out("hal_board.c",0x176,local_a0,0xe,LOG_BUF_OUT_DATA_TYPE_INT8); + if (*pbVar14 == 0x42) goto LAB_23038602; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Use pwr offset from b in incremental mode\r\n",TVar3,"DEBUG ", + "hal_board.c",0x180); + } + psVar12 = local_b0; + do { + format = (char *)((int)local_a0 + iVar9); + iVar9 = iVar9 + 1; + *(char *)psVar12 = *format + *(char *)psVar12; + psVar12 = (size_t *)((int)psVar12 + 1); + iStack220 = iVar4; + } while (iVar9 != 0xe); +LAB_230386be: + iVar8 = iVar8 + 1; + pbVar14 = pbVar14 + 1; + } while (iVar8 != 2); + if (((iStack220 == 0) && (_fsymc_level_hal_drv < BLOG_LEVEL_WARN)) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x1ac; + pcVar10 = "\x1b[32mINFO \x1b[0m"; + format = "[%10u][%s: %s:%4d] Using Default pwr offset\r\n"; + goto LAB_23038656; + } +LAB_23038844: + log_buf_out("hal_board.c",0x1ae,local_b0,0xe,LOG_BUF_OUT_DATA_TYPE_INT8); + phy_powroffset_set((int8_t *)local_b0); +LAB_23038860: + local_b0[0] = 0; + nodeoffset = fdt_subnode_offset((void *)fdt,parentoffset,"ap"); + if (0 < nodeoffset) { + iVar4 = fdt_stringlist_count((void *)fdt,nodeoffset,"ssid"); + if ((iVar4 == 1) && + (format = fdt_stringlist_get((void *)fdt,nodeoffset,"ssid",0,(int *)local_b0), + local_b0[0] - 1 < 0x1f)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ap_ssid string[%d] = %s, ap_ssid_len = %d\r\n",TVar3, + &DAT_2307f16c,"hal_board.c",0x213,0,format,local_b0[0]); + } + memcpy(local_a0,format,local_b0[0]); + *(undefined *)((int)local_a0 + local_b0[0]) = 0; + capin = (uint8_t)local_b0[0]; + } + else { + capin = '\0'; + } + iVar4 = fdt_stringlist_count((void *)fdt,nodeoffset,"pwd"); + if ((iVar4 == 1) && + (format = fdt_stringlist_get((void *)fdt,nodeoffset,"pwd",0,(int *)local_b0), + local_b0[0] - 1 < 0x1f)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ap_psk string[%d] = %s, ap_psk_len = %d\r\n",TVar3, + &DAT_2307f16c,"hal_board.c",0x21e,0,format,local_b0[0]); + } + memcpy(&local_80,format,local_b0[0]); + *(undefined *)((int)&local_80 + local_b0[0]) = 0; + psk_len = (uint8_t)local_b0[0]; + } + else { + psk_len = '\0'; + } + pfVar15 = (fdt32_t *)fdt_getprop((void *)fdt,nodeoffset,"ap_channel",(int *)local_b0); + if (pfVar15 == (fdt32_t *)0x0) { + chan = '\0'; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (chan = '\0', _fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ap_channel NULL.\r\n",TVar3,&DAT_23072bcc,"hal_board.c",0x22b) + ; + chan = '\0'; + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + autoconnect = fdt32_to_cpu(*pfVar15); + bl_printk("[%10u][%s: %s:%4d] ap_channel = %ld\r\n",TVar3,&DAT_2307f16c,"hal_board.c",0x227, + autoconnect); + } + autoconnect = fdt32_to_cpu(*pfVar15); + chan = (uint8_t)autoconnect; + } + bl_wifi_ap_info_set((uint8_t *)local_a0,capin,(uint8_t *)&local_80,psk_len,chan); + } + local_b0[0] = 0; + parentoffset = fdt_subnode_offset((void *)fdt,parentoffset,"sta"); + if (0 < parentoffset) { + nodeoffset = fdt_stringlist_count((void *)fdt,parentoffset,"ssid"); + if ((nodeoffset == 1) && + (format = fdt_stringlist_get((void *)fdt,parentoffset,"ssid",0,(int *)local_b0), + local_b0[0] - 1 < 0x1f)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [STA] ap_ssid string[%d] = %s, ap_ssid_len = %d\r\n",TVar3, + &DAT_2307f16c,"hal_board.c",0x1df,0,format,local_b0[0]); + } + memcpy(local_a0,format,local_b0[0]); + *(undefined *)((int)local_a0 + local_b0[0]) = 0; + capin = (uint8_t)local_b0[0]; + } + else { + capin = '\0'; + } + nodeoffset = fdt_stringlist_count((void *)fdt,parentoffset,"pwd"); + if ((nodeoffset == 1) && + (format = fdt_stringlist_get((void *)fdt,parentoffset,"pwd",0,(int *)local_b0), + local_b0[0] - 1 < 0x1f)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [STA] ap_psk string[%d] = %s, ap_psk_len = %d\r\n",TVar3, + &DAT_2307f16c,"hal_board.c",0x1ea,0,format,local_b0[0]); + } + memcpy(&local_80,format,local_b0[0]); + *(undefined *)((int)&local_80 + local_b0[0]) = 0; + psk_len = (uint8_t)local_b0[0]; + } + else { + psk_len = '\0'; + } + pfVar15 = (fdt32_t *)fdt_getprop((void *)fdt,parentoffset,"auto_connect_enable",(int *)local_b0) + ; + autoconnect = 0; + if (pfVar15 != (fdt32_t *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + autoconnect = fdt32_to_cpu(*pfVar15); + bl_printk("[%10u][%s: %s:%4d] auto_connect_enable = %ld\r\n",TVar3,&DAT_2307f16c, + "hal_board.c",0x1f2,autoconnect); + } + autoconnect = fdt32_to_cpu(*pfVar15); + } + bl_wifi_sta_info_set((uint8_t *)local_a0,capin,(uint8_t *)&local_80,psk_len,autoconnect); + } + parentoffset = fdt_subnode_offset((void *)fdt,0,"bluetooth"); + if (((parentoffset < 1) && (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] bt NULL.\r\n",TVar3,&DAT_23072bcc,"hal_board.c",0x2cd); + } + parentoffset = fdt_subnode_offset((void *)fdt,parentoffset,"brd_rf"); + if (0 < parentoffset) { + pfVar15 = (fdt32_t *)fdt_getprop((void *)fdt,parentoffset,"pwr_table_ble",&iStack188); + fdt = 0; + if (pfVar15 != (fdt32_t *)0x0) { + fdt = fdt32_to_cpu(*pfVar15); + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] set pwr_table_ble = %ld in dts\r\n",&DAT_2307f16c,"hal_board.c", + 0x2d9,fdt); + } + } + return 0; +LAB_23038602: + do { + *(undefined *)((int)local_b0 + iVar9) = *(undefined *)((int)local_a0 + iVar9); + iVar9 = iVar9 + 1; + } while (iVar9 != 0xe); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) + { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x17c; + pcVar10 = "DEBUG "; + format = "[%10u][%s: %s:%4d] Use pwr offset from B only\r\n"; +LAB_23038656: + bl_printk(format,TVar3,pcVar10,"hal_board.c",uVar11); + } + goto LAB_23038844; +} + + + +// WARNING: Control flow encountered bad instruction data + +void bl_tsen_adc_get(void) + +{ + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +uint64_t bl_rtc_get_counter(void) + +{ + uint64_t in_fa0; + uint32_t uStack24; + uint32_t valLow; + uint32_t valHigh; + + HBN_Get_RTC_Timer_Val(&uStack24,&valLow); + return in_fa0; +} + + + +uint64_t bl_rtc_get_timestamp_ms(void) + +{ + uint64_t uVar1; + + uVar1 = bl_rtc_get_counter(); + return uVar1; +} + + + +int hal_wifi_start_firmware_task(void) + +{ + StackType_t wifi_fw_stack [1536]; + StaticTask_t wifi_fw_task; + + xTaskCreateStatic(wifi_main,"fw",0x600,(void *)0x0,0x1e,(StackType_t *)&ram0x42012be8, + (StaticTask_t *)&ram0x420143e8); + return 0; +} + + + +int bl_sys_reset_por(void) + +{ + GLB_SW_POR_Reset(); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void bl_sys_reset_system(void) + +{ + GLB_SW_System_Reset(); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +int bl_sys_isxipaddr(uint32_t addr) + +{ + return (uint)(((addr & 0xff000000) + 0xdd000000 & 0xdf000000) == 0); +} + + + +PtTable_Error_Type +PtTable_Update_Entry + (SPI_Flash_Cfg_Type *pFlashCfg,PtTable_ID_Type targetTableID,PtTable_Stuff_Config *ptStuff + ,PtTable_Entry_Config *ptEntry) + +{ + uint uVar1; + PtTable_Error_Type PVar2; + uint32_t len; + uint32_t uVar3; + undefined3 in_register_0000202d; + PtTable_Entry_Config *__dest; + PtTable_Entry_Config *dataIn; + uint32_t addr; + + if ((ptEntry == (PtTable_Entry_Config *)0x0) || (ptStuff == (PtTable_Stuff_Config *)0x0)) { + return PT_ERROR_PARAMETER; + } + dataIn = ptStuff->ptEntries; + PVar2 = PT_ERROR_TABLE_NOT_VALID; + if (CONCAT31(in_register_0000202d,targetTableID) != 2) { + addr = 0xe000; + if (CONCAT31(in_register_0000202d,targetTableID) != 0) { + addr = 0xf000; + } + uVar1 = 0; + __dest = dataIn; + while (uVar1 < (ptStuff->ptTable).entryCnt) { + if (__dest->type == ptEntry->type) { + memcpy(__dest,ptEntry,0x24); + break; + } + uVar1 = uVar1 + 1; + __dest = __dest + 1; + } + if ((uint)(ptStuff->ptTable).entryCnt == uVar1) { + if (0xf < uVar1) { + return PT_ERROR_ENTRY_UPDATE_FAIL; + } + memcpy(dataIn + uVar1,ptEntry,0x24); + (ptStuff->ptTable).entryCnt = (ptStuff->ptTable).entryCnt + 1; + } + (ptStuff->ptTable).age = (ptStuff->ptTable).age + 1; + len = BFLB_Soft_CRC32(ptStuff,0xc); + uVar1 = (uint)(ptStuff->ptTable).entryCnt; + (ptStuff->ptTable).crc32 = len; + len = uVar1 * 0x24; + uVar3 = BFLB_Soft_CRC32(dataIn,len); + *(uint32_t *)(dataIn + uVar1) = uVar3; + uVar1 = bl_flash_erase(addr,len + 0x14); + if ((uVar1 & 0xff) == 0) { + uVar1 = bl_flash_write(addr,(uint8_t *)ptStuff,0x254); + if ((uVar1 & 0xff) == 0) { + return (PtTable_Error_Type)(uVar1 & 0xff); + } + } + PVar2 = PT_ERROR_FALSH_WRITE; + } + return PVar2; +} + + + +PtTable_Error_Type +PtTable_Get_Active_Entries + (PtTable_Stuff_Config *ptStuff,PtTable_Entry_Type type,PtTable_Entry_Config *ptEntry) + +{ + undefined3 in_register_0000202d; + PtTable_Entry_Config *pPVar1; + uint uVar2; + + if (ptStuff == (PtTable_Stuff_Config *)0x0) { + return PT_ERROR_PARAMETER; + } + if (ptEntry != (PtTable_Entry_Config *)0x0) { + uVar2 = 0; + pPVar1 = ptStuff->ptEntries; + while( true ) { + if ((ptStuff->ptTable).entryCnt <= uVar2) { + return PT_ERROR_ENTRY_NOT_FOUND; + } + if ((uint)pPVar1->type == CONCAT31(in_register_0000202d,type)) break; + uVar2 = uVar2 + 1; + pPVar1 = pPVar1 + 1; + } + memcpy(ptEntry,ptStuff->ptEntries + uVar2,0x24); + return PT_ERROR_SUCCESS; + } + return PT_ERROR_PARAMETER; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bl_gpio_enable_output(uint8_t pin,uint8_t pullup,uint8_t pulldown) + +{ + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + uint8_t uStack24; + uint8_t uStack23; + uint8_t uStack22; + uint8_t uStack21; + GLB_GPIO_Cfg_Type cfg; + + cfg._0_2_ = 0x100; + uStack23 = '\v'; + uStack22 = '\x01'; + if (CONCAT31(in_register_0000202d,pullup) == 0) { + uStack21 = '\x02'; + } + else { + uStack21 = '\0'; + } + if (CONCAT31(in_register_00002031,pulldown) != 0) { + uStack21 = '\x01'; + } + uStack24 = pin; + GLB_GPIO_Init((GLB_GPIO_Cfg_Type *)&uStack24); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bl_gpio_enable_input(uint8_t pin,uint8_t pullup,uint8_t pulldown) + +{ + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + uint8_t uStack24; + uint8_t uStack23; + uint8_t uStack22; + uint8_t uStack21; + GLB_GPIO_Cfg_Type cfg; + + cfg._0_2_ = 0x100; + uStack23 = '\v'; + uStack22 = '\0'; + if (CONCAT31(in_register_0000202d,pullup) == 0) { + uStack21 = '\x02'; + } + else { + uStack21 = '\0'; + } + if (CONCAT31(in_register_00002031,pulldown) != 0) { + uStack21 = '\x01'; + } + uStack24 = pin; + GLB_GPIO_Init((GLB_GPIO_Cfg_Type *)&uStack24); + return 0; +} + + + +int bl_gpio_output_set(uint8_t pin,uint8_t value) + +{ + undefined3 in_register_0000202d; + + GLB_GPIO_Write(pin,(uint)(CONCAT31(in_register_0000202d,value) != 0)); + return 0; +} + + + +int bl_gpio_input_get(uint8_t pin,uint8_t *value) + +{ + uint32_t uVar1; + + uVar1 = GLB_GPIO_Read(pin); + *value = (uint8_t)uVar1; + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int bl_flash_erase(uint32_t addr,int len) + +{ + if (boot2_flashCfg.flashCfg.mid != '\0') { + (*_DAT_21010ab0)(0x4200dc24,addr,len,_DAT_21010ab0); + return 0; + } + return -1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int bl_flash_write(uint32_t addr,uint8_t *src,int len) + +{ + if (boot2_flashCfg.flashCfg.mid != '\0') { + (*_DAT_21010aac)(0x4200dc24,addr,src,len,_DAT_21010aac); + return 0; + } + return -1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int bl_flash_read(uint32_t addr,uint8_t *dst,int len) + +{ + if (boot2_flashCfg.flashCfg.mid != '\0') { + (*_DAT_21010aa8)(0x4200dc24,addr,dst,len,_DAT_21010aa8); + return 0; + } + return -1; +} + + + +undefined4 bl_flash_config_update(void) + +{ + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ======= FlashCfg magiccode @%p, code 0x%08lX =======\r\n", + &DAT_2307f16c,"bl_flash.c",0x60,0x42049c18,boot2_flashCfg.magic); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN) + ) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] mid \t\t0x%X\r\n",&DAT_2307f16c,"bl_flash.c",0x61, + (uint)boot2_flashCfg.flashCfg.mid); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] clkDelay \t0x%X\r\n",&DAT_2307f16c,"bl_flash.c",0x62, + (uint)boot2_flashCfg.flashCfg.clkDelay); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] clkInvert \t0x%X\r\n",&DAT_2307f16c,"bl_flash.c",99, + (uint)boot2_flashCfg.flashCfg.clkInvert); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] sector size\t%uKBytes\r\n",&DAT_2307f16c,"bl_flash.c",100, + (uint)boot2_flashCfg.flashCfg.sectorSize); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] page size\t%uBytes\r\n",&DAT_2307f16c,"bl_flash.c",0x65, + (uint)boot2_flashCfg.flashCfg.pageSize); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] ---------------------------------------------------------------\r\n" + ,&DAT_2307f16c,"bl_flash.c",0x66); + } + } + } + } + } + } + } + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void bl_wdt_feed(void) + +{ + _DAT_4000a598 = _DAT_4000a598 | 1; + _DAT_4000a59c = _DAT_4000a59c & 0xffff0000 | 0xbaba; + _DAT_4000a5a0 = _DAT_4000a5a0 & 0xffff0000 | 0xeb10; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void bl_wdt_disable(void) + +{ + _DAT_4000a564 = _DAT_4000a564 & 0xfffffffe; + _DAT_4000a59c = _DAT_4000a59c & 0xffff0000 | 0xbaba; + _DAT_4000a5a0 = _DAT_4000a5a0 & 0xffff0000 | 0xeb10; + return; +} + + + +int bl_wdt_init(int ms) + +{ + if (ms < 0xfff) { + WDT_Disable(); + WDT_Set_Clock(TIMER_CLKSRC_32K,'\x01'); + WDT_SetCompValue((uint16_t)((uint)(ms << 0x14) >> 0x10)); + WDT_ResetCounterValue(); + WDT_IntMask(WDT_INT,MASK); + WDT_Enable(); + return 0; + } + return -1; +} + + + +err_t httpc_tcp_sent(void *arg,altcp_pcb *pcb,u16_t len) + +{ + return '\0'; +} + + + +err_t httpc_get_internal_addr(httpc_state_t *req,ip_addr_t *ipaddr) + +{ + err_t eVar1; + + if (&req->remote_addr != ipaddr) { + (req->remote_addr).addr = ipaddr->addr; + } + eVar1 = altcp_connect(req->pcb,&req->remote_addr,req->remote_port,httpc_tcp_connected); + return eVar1; +} + + + +err_t httpc_free_state(httpc_state_t *req) + +{ + altcp_pcb *conn; + err_t eVar1; + undefined3 extraout_var; + + if (req->request != (pbuf *)0x0) { + pbuf_free(req->request); + req->request = (pbuf *)0x0; + } + if (req->rx_hdrs != (pbuf *)0x0) { + pbuf_free(req->rx_hdrs); + req->rx_hdrs = (pbuf *)0x0; + } + conn = req->pcb; + mem_free(req); + if (conn != (altcp_pcb *)0x0) { + altcp_arg(conn,(void *)0x0); + altcp_recv(conn,(altcp_recv_fn *)0x0); + altcp_err(conn,(altcp_err_fn *)0x0); + altcp_poll(conn,(altcp_poll_fn *)0x0,'\0'); + altcp_sent(conn,(altcp_sent_fn *)0x0); + eVar1 = altcp_close(conn); + if (CONCAT31(extraout_var,eVar1) != 0) { + altcp_abort(conn); + return -0xd; + } + } + return '\0'; +} + + + +err_t httpc_close(httpc_state_t *req,httpc_result_t result,u32_t server_response,err_t err) + +{ + err_t eVar1; + httpc_result_fn *phVar2; + + if (req != (httpc_state_t *)0x0) { + if ((req->conn_settings != (httpc_connection_t_conflict *)0x0) && + (phVar2 = req->conn_settings->result_fn, phVar2 != (httpc_result_fn *)0x0)) { + (*phVar2)(req->callback_arg,result,req->rx_content_len,server_response,err); + } + eVar1 = httpc_free_state(req); + return eVar1; + } + return '\0'; +} + + + +err_t httpc_tcp_recv(void *arg,altcp_pcb *pcb,pbuf *p,err_t r) + +{ + ushort uVar1; + uint uVar2; + err_t err; + u8_t uVar3; + byte bVar4; + u16_t len; + u16_t start_offset; + undefined2 extraout_var_01; + undefined2 extraout_var_02; + undefined2 extraout_var_03; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined2 extraout_var_04; + undefined2 extraout_var_05; + undefined2 extraout_var_06; + undefined2 extraout_var_07; + undefined2 extraout_var_08; + undefined2 extraout_var_09; + httpc_result_t result; + u16_t start_offset_00; + undefined3 in_register_00002035; + code *pcVar5; + int iVar6; + pbuf *p_00; + char acStack64 [4]; + char status_num [10]; + + *(undefined4 *)((int)arg + 0xc) = 0x1e; + if (p == (pbuf *)0x0) { + result = HTTPC_RESULT_ERR_CLOSED; + if (*(char *)((int)arg + 0x30) == '\x02') { + result = HTTPC_RESULT_OK; + if ((*(int *)((int)arg + 0x2c) != -1) && + (*(int *)((int)arg + 0x2c) != *(int *)((int)arg + 0x28))) { + result = HTTPC_RESULT_ERR_CONTENT_LEN; + } + } + uVar1 = *(ushort *)((int)arg + 0x1a); + err = '\0'; + goto LAB_2303957c; + } + if (*(char *)((int)arg + 0x30) == '\x02') goto LAB_230395a8; + if (*(pbuf **)((int)arg + 0x14) == (pbuf *)0x0) { + *(pbuf **)((int)arg + 0x14) = p; + } + else { + pbuf_cat(*(pbuf **)((int)arg + 0x14),p); + } + if (*(char *)((int)arg + 0x30) == '\0') { + p_00 = *(pbuf **)((int)arg + 0x14); + len = pbuf_memfind(p_00,"\r\n",2,0); + if (CONCAT22(extraout_var_01,len) == 0xffff) goto LAB_23039782; + start_offset = pbuf_memfind(p_00," ",1,0); + iVar6 = CONCAT22(extraout_var_02,start_offset); + if (((iVar6 == 0xffff) || + (start_offset = pbuf_memcmp(p_00,0,&DAT_23085d2c,5), + CONCAT22(extraout_var_03,start_offset) != 0)) || + (uVar3 = pbuf_get_at(p_00,6), CONCAT31(extraout_var,uVar3) != 0x2e)) goto LAB_23039782; + bVar4 = pbuf_get_at(p_00,5); + uVar3 = pbuf_get_at(p_00,7); + *(ushort *)((int)arg + 0x18) = + (short)CONCAT31(extraout_var_00,uVar3) - 0x30U | + (ushort)(((uint)bVar4 - 0x30 & 0xffff) << 8); + start_offset_00 = (u16_t)((uint)((iVar6 + 1) * 0x10000) >> 0x10); + start_offset = pbuf_memfind(p_00," ",1,start_offset_00); + if (CONCAT22(extraout_var_04,start_offset) == 0xffff) { + iVar6 = CONCAT22(extraout_var_01,len) - iVar6; + } + else { + iVar6 = CONCAT22(extraout_var_04,start_offset) - iVar6; + } + memset(acStack64,0,10); + len = pbuf_copy_partial(p_00,acStack64,(u16_t)((uint)((iVar6 + -1) * 0x10000) >> 0x10), + start_offset_00); + if ((iVar6 + -1 != CONCAT22(extraout_var_05,len)) || + (iVar6 = atoi(acStack64), 0xfffe < iVar6 - 1U)) goto LAB_23039782; + *(undefined2 *)((int)arg + 0x1a) = (short)iVar6; + *(undefined *)((int)arg + 0x30) = 1; +LAB_230396b8: + p_00 = *(pbuf **)((int)arg + 0x14); + len = pbuf_memfind(p_00,&DAT_2307b07c,4,0); + if (CONCAT22(extraout_var_06,len) < 0xfffd) { + *(undefined4 *)((int)arg + 0x2c) = 0xffffffff; + start_offset = pbuf_memfind(p_00,"Content-Length: ",0x10,0); + iVar6 = CONCAT22(extraout_var_07,start_offset); + if (iVar6 != 0xffff) { + start_offset = pbuf_memfind(p_00,"\r\n",2,start_offset); + if (CONCAT22(extraout_var_08,start_offset) != 0xffff) { + memset(acStack64,0,0x10); + uVar2 = (CONCAT22(extraout_var_08,start_offset) - iVar6) - 0x10; + start_offset = pbuf_copy_partial(p_00,acStack64,(u16_t)(uVar2 * 0x10000 >> 0x10), + (u16_t)((uint)((iVar6 + 0x10) * 0x10000) >> 0x10)); + if (((uVar2 & 0xffff) == CONCAT22(extraout_var_09,start_offset)) && + (iVar6 = atoi(acStack64), -1 < iVar6)) { + *(int *)((int)arg + 0x2c) = iVar6; + } + } + } + uVar2 = CONCAT22(extraout_var_06,len) + 4; + len = (u16_t)(uVar2 * 0x10000 >> 0x10); + altcp_recved(pcb,len); + if ((*(int *)((int)arg + 0x20) != 0) && + (pcVar5 = *(code **)(*(int *)((int)arg + 0x20) + 0x18), pcVar5 != (code *)0x0)) { + iVar6 = (*pcVar5)(arg,*(undefined4 *)((int)arg + 0x24),*(undefined4 *)((int)arg + 0x14), + uVar2 & 0xffff,*(undefined4 *)((int)arg + 0x2c)); + err = (err_t)iVar6; + if (iVar6 != 0) { + uVar1 = *(ushort *)((int)arg + 0x1a); + result = HTTPC_RESULT_LOCAL_ABORT; +LAB_2303957c: + err = httpc_close((httpc_state_t *)arg,result,(uint)uVar1,err); + return err; + } + } + p = pbuf_free_header(*(pbuf **)((int)arg + 0x14),len); + *(undefined4 *)((int)arg + 0x14) = 0; + *(undefined *)((int)arg + 0x30) = 2; + if (p == (pbuf *)0x0) { + return '\0'; + } + goto LAB_230395a8; + } + } + else { +LAB_23039782: + if (*(char *)((int)arg + 0x30) == '\x01') goto LAB_230396b8; + } + if (*(char *)((int)arg + 0x30) != '\x02') { + return '\0'; + } +LAB_230395a8: + *(int *)((int)arg + 0x28) = *(int *)((int)arg + 0x28) + (uint)p->tot_len; + if (*(code **)((int)arg + 0x1c) == (code *)0x0) { + altcp_recved(pcb,p->tot_len); + pbuf_free(p); + return '\0'; + } + err = (**(code **)((int)arg + 0x1c)) + (*(undefined4 *)((int)arg + 0x24),pcb,p,CONCAT31(in_register_00002035,r)); + return err; +} + + + +void httpc_dns_found(char *hostname,ip_addr_t *ipaddr,void *arg) + +{ + err_t err; + undefined3 extraout_var; + httpc_result_t result; + + if (ipaddr == (ip_addr_t *)0x0) { + result = HTTPC_RESULT_ERR_HOSTNAME; + err = -0x10; + } + else { + err = httpc_get_internal_addr((httpc_state_t *)arg,ipaddr); + result = HTTPC_RESULT_ERR_CONNECT; + if (CONCAT31(extraout_var,err) == 0) { + return; + } + } + httpc_close((httpc_state_t *)arg,result,0,err); + return; +} + + + +err_t httpc_tcp_poll(void *arg,altcp_pcb *pcb) + +{ + err_t eVar1; + int iVar2; + + if ((arg != (void *)0x0) && + ((*(int *)((int)arg + 0xc) == 0 || + (iVar2 = *(int *)((int)arg + 0xc) + -1, *(int *)((int)arg + 0xc) = iVar2, iVar2 == 0)))) { + eVar1 = httpc_close((httpc_state_t *)arg,HTTPC_RESULT_ERR_TIMEOUT,0,'\0'); + return eVar1; + } + return '\0'; +} + + + +void httpc_tcp_err(void *arg,err_t err) + +{ + if (arg != (void *)0x0) { + *(undefined4 *)arg = 0; + httpc_close((httpc_state_t *)arg,HTTPC_RESULT_ERR_CLOSED,0,err); + return; + } + return; +} + + + +err_t httpc_tcp_connected(void *arg,altcp_pcb *pcb,err_t err) + +{ + err_t err_00; + undefined3 extraout_var; + + err_00 = altcp_write(*(altcp_pcb **)arg,*(void **)(*(int *)((int)arg + 0x10) + 4), + (u16_t)(((uint)*(ushort *)(*(int *)((int)arg + 0x10) + 10) - 1) * 0x10000 >> + 0x10),'\x01'); + if (CONCAT31(extraout_var,err_00) != 0) { + err_00 = httpc_close((httpc_state_t *)arg,HTTPC_RESULT_ERR_MEM,0,err_00); + return err_00; + } + pbuf_free(*(pbuf **)((int)arg + 0x10)); + *(undefined4 *)((int)arg + 0x10) = 0; + altcp_output(*(altcp_pcb **)arg); + return '\0'; +} + + + +int httpc_create_request_string + (httpc_connection_t_conflict *settings,char *server_name,int server_port,char *uri, + char *buffer,size_t buffer_size) + +{ + int iVar1; + size_t sVar2; + char *pcVar3; + + if (settings->use_proxy == '\0') { + if (settings->req_type == '\x01') { + pcVar3 = (char *)0x0; + if (settings->content_type < 4) { + pcVar3 = g_cont_type[settings->content_type]; + } + sVar2 = strlen((char *)settings->data); + iVar1 = snprintf(buffer,buffer_size, + + "POST %s HTTP/1.1\r\nContent-Type: %s\r\nContent-Length: %d\r\nUser-Agent: %s\r\nHost: %s\r\nAccept: */*\r\nConnection: Close\r\n\r\n%s" + ,uri,pcVar3,sVar2,&UNK_23085ba4,server_name); + return iVar1; + } + iVar1 = snprintf(buffer,buffer_size, + + "GET %s HTTP/1.1\r\nUser-Agent: %s\r\nAccept: */*\r\nHost: %s\r\nConnection: Close\r\n\r\n" + ,&UNK_23085ba4,server_name); + return iVar1; + } + if (server_port != 0x50) { + iVar1 = snprintf(buffer,buffer_size, + + "GET http://%s:%d%s HTTP/1.1\r\nUser-Agent: %s\r\nAccept: */*\r\nHost: %s\r\nConnection: Close\r\n\r\n" + ,server_name,server_port,uri,&UNK_23085ba4); + return iVar1; + } + iVar1 = snprintf(buffer,buffer_size, + + "GET http://%s%s HTTP/1.1\r\nUser-Agent: %s\r\nAccept: */*\r\nHost: %s\r\nConnection: Close\r\n\r\n" + ,server_name,uri,&UNK_23085ba4,server_name); + return iVar1; +} + + + +err_t httpc_init_connection_common + (httpc_state_t **connection,httpc_connection_t_conflict *settings,char *server_name, + u16_t server_port,char *uri,altcp_recv_fn *recv_fn,void *callback_arg) + +{ + uint uVar1; + httpc_state_t *req; + pbuf *ppVar2; + altcp_pcb *conn; + uint uVar3; + undefined2 in_register_00002036; + int server_port_00; + err_t eVar4; + + server_port_00 = CONCAT22(in_register_00002036,server_port); + uVar1 = httpc_create_request_string(settings,server_name,server_port_00,uri,(char *)0x0,0); + if (uVar1 < 0xffff) { + req = (httpc_state_t *)mem_malloc(0x34); + if (req == (httpc_state_t *)0x0) { + return -1; + } + memset(req,0,0x34); + req->timeout_ticks = 0x1e; + ppVar2 = pbuf_alloc(PBUF_RAW,(u16_t)((uVar1 + 1) * 0x10000 >> 0x10),PBUF_RAM); + req->request = ppVar2; + if ((ppVar2 != (pbuf *)0x0) && (ppVar2->next == (pbuf *)0x0)) { + req->hdr_content_len = 0xffffffff; + conn = altcp_new(settings->altcp_allocator); + req->pcb = conn; + if (conn != (altcp_pcb *)0x0) { + if (settings->use_proxy != '\0') { + server_port = settings->proxy_port; + } + req->remote_port = server_port; + altcp_arg(conn,req); + altcp_recv(req->pcb,httpc_tcp_recv); + altcp_err(req->pcb,httpc_tcp_err); + altcp_poll(req->pcb,httpc_tcp_poll,'\x01'); + altcp_sent(req->pcb,httpc_tcp_sent); + uVar3 = httpc_create_request_string + (settings,server_name,server_port_00,uri,(char *)req->request->payload, + uVar1 + 1); + if (uVar1 == uVar3) { + req->recv_fn = recv_fn; + req->conn_settings = settings; + req->callback_arg = callback_arg; + *connection = req; + return '\0'; + } + httpc_free_state(req); + goto LAB_23039a74; + } + } + httpc_free_state(req); + eVar4 = -1; + } + else { +LAB_23039a74: + eVar4 = -6; + } + return eVar4; +} + + + +err_t httpc_get_file_dns(char *server_name,u16_t port,char *uri, + httpc_connection_t_conflict *settings,altcp_recv_fn *recv_fn, + void *callback_arg,httpc_state_t **connection) + +{ + httpc_state_t *req_00; + err_t eVar1; + err_t eVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + httpc_state_t *phStack36; + httpc_state_t *req; + + if (server_name == (char *)0x0) { + return -0x10; + } + if (uri == (char *)0x0) { + return -0x10; + } + if (recv_fn == (altcp_recv_fn *)0x0) { + return -0x10; + } + eVar1 = httpc_init_connection_common + (&phStack36,settings,server_name,port,uri,recv_fn,callback_arg); + req_00 = phStack36; + if (CONCAT31(extraout_var,eVar1) != 0) { + return eVar1; + } + if (settings->use_proxy == '\0') { + settings = (httpc_connection_t_conflict *)&phStack36->remote_addr; + eVar2 = dns_gethostbyname(server_name,(ip_addr_t *)settings,httpc_dns_found,phStack36); + if (CONCAT31(extraout_var_01,eVar2) != 0) { + if (CONCAT31(extraout_var_01,eVar2) == -5) goto LAB_23039b0a; + goto LAB_23039ad0; + } + } + eVar2 = httpc_get_internal_addr(req_00,(ip_addr_t *)settings); + if (CONCAT31(extraout_var_00,eVar2) == 0) { +LAB_23039b0a: + if (connection == (httpc_state_t **)0x0) { + return eVar1; + } + *connection = phStack36; + return eVar1; + } +LAB_23039ad0: + httpc_free_state(phStack36); + return eVar2; +} + + + +void proc_entry_looprt(void *pvParameters) + +{ + bloop_run(&looprt); + do { + puts("--->>> Error terminated looprt\r\n"); + vTaskDelay(1000); + } while( true ); +} + + + +void looprt_evt_notify_async(uint task,uint32_t evt_map) + +{ + bloop_evt_set_async(&looprt,task,evt_map); + return; +} + + + +void looprt_evt_status_dump(void) + +{ + bloop_status_dump(&looprt); + return; +} + + + +void looprt_evt_schedule(int task,uint32_t evt_map,int delay_ms) + +{ + loop_timer *timer; + + timer = (loop_timer *)pvPortMalloc(0x24); + if (timer != (loop_timer *)0x0) { + bloop_timer_init(timer,1); + bloop_timer_configure + (timer,delay_ms,(anon_subr_void_loop_ctx_ptr_loop_timer_ptr_void_ptr *)0x0,(void *)0x0 + ,task,evt_map); + bloop_timer_register(&looprt,timer); + return; + } + return; +} + + + +int looprt_start(StackType_t *proc_stack_looprt,int stack_count,StaticTask_t *proc_task_looprt) + +{ + bloop_init(&looprt); + bloop_handler_register(&looprt,&bloop_handler_sys,0x1f); + looprt_evt_status_dump(); + xTaskCreateStatic(proc_entry_looprt,"bloop_rt",stack_count,(void *)0x0,0x1a,proc_stack_looprt, + proc_task_looprt); + bloop_wait_startup(&looprt); + return 0; +} + + + +int looprt_start_auto(void) + +{ + bloop_init(&looprt); + bloop_handler_register(&looprt,&bloop_handler_sys,0x1f); + looprt_evt_status_dump(); + xTaskCreate(proc_entry_looprt,"bloop_rt",0x1000,(void *)0x0,0x1a,(TaskHandle_t *)0x0); + bloop_wait_startup(&looprt); + return 0; +} + + + +int looprt_handler_register(loop_evt_handler *handler,int priority) + +{ + int iVar1; + + if (looprt.looper != (TaskHandle_t)0x0) { + iVar1 = bloop_handler_register(&looprt,handler,priority); + return iVar1; + } + return -1; +} + + + +int looprt_timer_register(loop_timer *timer) + +{ + bloop_timer_register(&looprt,timer); + return 0; +} + + + +void cmd_looprt_test(char *buf,int len,int argc,char **argv) + +{ + puts("====== looprt test ======\r\n"); + printf("struct loop_ctx size is %d\r\n",0x4a0); + printf("MSG size is %d\r\n",0x18); + looprt_start_auto(); + return; +} + + + +void cmd_looprt_test_status(char *buf,int len,int argc,char **argv) + +{ + puts("====== looprt test status ======\r\n"); + looprt_evt_status_dump(); + return; +} + + + +void cmd_looprt_test_evt(char *buf,int len,int argc,char **argv) + +{ + puts("====== looprt EVT ======\r\n"); + looprt_evt_notify_async(0x1f,0); + return; +} + + + +void cmd_looprt_test_evt_dump(char *buf,int len,int argc,char **argv) + +{ + puts("====== looprt EVT status ======\r\n"); + looprt_evt_notify_async(0x1f,1); + return; +} + + + +void cmd_looprt_test_schedule_evt1(char *buf,int len,int argc,char **argv) + +{ + puts("====== looprt Schedule EVT1 ======\r\n"); + looprt_evt_schedule(0x1f,1,20000); + return; +} + + + +void cmd_looprt_test_schedule_evt2(char *buf,int len,int argc,char **argv) + +{ + puts("====== looprt Schedule EVT2 ======\r\n"); + looprt_evt_schedule(0x1f,1,10000); + return; +} + + + +int looprt_test_cli_init(void) + +{ + return 0; +} + + + +void _cb_led_trigger(loop_ctx *loop,loop_timer *timer,void *arg) + +{ + TickType_t TVar1; + undefined *puVar2; + + bl_gpio_output_set(*(uint8_t *)((int)arg + 0x30),*(int *)((int)arg + 0x38) != 0); + if ((_fsymc_level_loopset < BLOG_LEVEL_INFO) && + (_fsymf_level_loopsetloopset_led < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + if (*(int *)((int)arg + 0x38) == 0) { + puVar2 = &DAT_23084b74; + } + else { + puVar2 = &DAT_23084b70; + } + bl_printk("[%10u][%s: %s:%4d] [LED] [CB] Set pin %d to %s\r\n",TVar1,"DEBUG ","loopset_led.c", + 0x95,*(undefined4 *)((int)arg + 0x30),puVar2); + } + *(uint *)((int)arg + 0x38) = (uint)(*(int *)((int)arg + 0x38) == 0); + return; +} + + + +int _led_bloop_msg(loop_ctx *loop,loop_evt_handler *handler,loop_msg *msg) + +{ + TickType_t TVar1; + + if ((_fsymc_level_loopset < BLOG_LEVEL_INFO) && + (_fsymf_level_loopsetloopset_led < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] [LED] [MSG] called with msg info\r\n priority %u\r\n dst %u\r\n msgid %u\r\n src %u\r\n arg1 %p\r\n arg2 %p\r\n" + ,TVar1,"DEBUG ","loopset_led.c",0x78,(uint)*(byte *)&msg->u, + (uint)*(byte *)((int)&msg->u + 1),(uint)*(byte *)((int)&msg->u + 2)); + return 0; + } + return 0; +} + + + +int _led_bloop_evt(loop_ctx *loop,loop_evt_handler *handler,uint32_t *bitmap_evt, + uint32_t *evt_type_map) + +{ + char **ppcVar1; + uint uVar2; + TickType_t TVar3; + char *pcVar4; + undefined *puVar5; + char *pcVar6; + char **ppcVar7; + char **ppcVar8; + + uVar2 = *evt_type_map; + do { + if ((uVar2 & 1) == 0) { + if ((uVar2 & 2) == 0) { + if (uVar2 != 0) { + printf("[ASSERT] [ERR] %s:%d\r\n","loopset_led.c",0x5e); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + break; + } + pcVar6 = handler[1].name; + ppcVar7 = (char **)0x0; + ppcVar1 = *(char ***)(pcVar6 + 0xc); + if (ppcVar1 != (char **)0x0) { + ppcVar7 = (char **)ppcVar1[1]; + } + while (ppcVar8 = ppcVar7, ppcVar1 != (char **)(pcVar6 + 8)) { + if ((_fsymc_level_loopset < BLOG_LEVEL_WARN) && + (_fsymf_level_loopsetloopset_led < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(loop); + } + puVar5 = &DAT_23084b70; + if (ppcVar1[0xd] == (char *)0x0) { + puVar5 = &DAT_23084b74; + } + pcVar4 = "Hearbeat"; + if (ppcVar1[0xb] == (char *)0x0) { + pcVar4 = "Blink"; + } + bl_printk("[%10u][%s: %s:%4d] [LED] New Trigger: PIN %d, active level %s, type %s\r\n", + TVar3,&DAT_2307f16c,"loopset_led.c",0x4b,ppcVar1[0xc],puVar5,pcVar4); + } + loop = (loop_ctx *)looprt_timer_register((loop_timer *)(ppcVar1 + 2)); + ppcVar7 = (char **)ppcVar1[1]; + pcVar4 = *ppcVar1; + *(char ***)(pcVar4 + 4) = ppcVar7; + *ppcVar7 = pcVar4; + ppcVar7 = *(char ***)(pcVar6 + 4); + *ppcVar1 = pcVar6; + *(char ***)(ppcVar1 + 1) = ppcVar7; + *(char ***)(pcVar6 + 4) = ppcVar1; + *(char ***)ppcVar7 = ppcVar1; + ppcVar1 = ppcVar8; + ppcVar7 = (char **)0x0; + if (ppcVar8 != (char **)0x0) { + ppcVar7 = (char **)ppcVar8[1]; + } + } + uVar2 = uVar2 & 0xfffffffd; + } + else { + uVar2 = uVar2 & 0xfffffffe; + } + } while (uVar2 != 0); + *evt_type_map = 0; + return 0; +} + + + +int loopset_led_hook_on_looprt(void) + +{ + loop_evt_handler_holder _led_bloop_handler_holder; + int iVar1; + + led_ctx.trigger_queue.next = &led_ctx; + led_ctx.trigger_queue.prev = &led_ctx; + led_ctx.waiting_queue.next = (utils_dlist_s *)&led_ctx.waiting_queue; + led_ctx.waiting_queue.prev = (utils_dlist_s *)&led_ctx.waiting_queue; + iVar1 = looprt_handler_register((loop_evt_handler *)(loop_evt_handler_holder *)&ram0x23086060,1); + return iVar1; +} + + + +void loopset_led_trigger(int pin,uint timeon_ms) + +{ + utils_dlist_s **ppuVar1; + loop_timer *timer; + utils_dlist_s *__s; + TickType_t TVar2; + + __s = (utils_dlist_s *)pvPortMalloc(0x3c); + if (__s == (utils_dlist_s *)0x0) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ASSERT: %s:%d\r\n",TVar2,&UNK_2307c064,"loopset_led.c",0x9e, + "loopset_led.c",0x9e); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + memset(__s,0,0x3c); + timer = (loop_timer *)(__s + 1); + *(int *)&__s[6].prev = pin; + bloop_timer_init(timer,0); + bloop_timer_repeat_enable(timer); + bloop_timer_configure(timer,timeon_ms,_cb_led_trigger,__s,1,1); + bl_gpio_enable_output((uint8_t)pin,'\0','\0'); + vTaskEnterCritical(); + __s->prev = (utils_dlist_s *)0x420148f0; + __s->next = led_ctx.waiting_queue.next; + ppuVar1 = &(led_ctx.waiting_queue.next)->prev; + led_ctx.waiting_queue.next = __s; + *ppuVar1 = __s; + vTaskExitCritical(); + looprt_evt_notify_async(1,2); + return; +} + + + +err_t sys_mbox_new(sys_mbox_t *mbox,int size) + +{ + QueueHandle_t pQVar1; + u16_t uVar2; + + pQVar1 = xQueueGenericCreate(0x32,4,'\0'); + *(QueueHandle_t *)mbox = pQVar1; + uVar2 = (u16_t)(((uint)lwip_stats.sys.mbox.used + 1) * 0x10000 >> 0x10); + if ((uint)lwip_stats.sys.mbox.max < ((uint)lwip_stats.sys.mbox.used + 1 & 0xffff)) { + lwip_stats.sys.mbox.max = uVar2; + } + lwip_stats.sys.mbox.used = uVar2; + return (err_t)-(*mbox == (sys_mbox_t)0x0); +} + + + +void sys_mbox_free(sys_mbox_t *mbox) + +{ + UBaseType_t UVar1; + + UVar1 = uxQueueMessagesWaiting((QueueHandle_t)*mbox); + if (UVar1 != 0) { + lwip_stats.sys.mbox.err = lwip_stats.sys.mbox.err + 1; + } + vQueueDelete((QueueHandle_t)*mbox); + lwip_stats.sys.mbox.used = lwip_stats.sys.mbox.used - 1; + return; +} + + + +void sys_mbox_post(sys_mbox_t *mbox,void *data) + +{ + BaseType_t BVar1; + void *apvStack20 [2]; + + apvStack20[0] = data; + do { + BVar1 = xQueueGenericSend((QueueHandle_t)*mbox,apvStack20,0xffffffff,0); + } while (BVar1 != 1); + return; +} + + + +err_t sys_mbox_trypost(sys_mbox_t *mbox,void *msg) + +{ + err_t eVar1; + BaseType_t BVar2; + void *apvStack20 [4]; + + apvStack20[0] = msg; + BVar2 = xQueueGenericSend((QueueHandle_t)*mbox,apvStack20,0,0); + if (BVar2 == 1) { + eVar1 = '\0'; + } + else { + eVar1 = -1; + lwip_stats.sys.mbox.err = lwip_stats.sys.mbox.err + 1; + } + return eVar1; +} + + + +u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox,void **msg,u32_t timeout) + +{ + TickType_t TVar1; + BaseType_t BVar2; + TickType_t TVar3; + void *local_24; + void *dummyptr; + + TVar1 = xTaskGetTickCount(); + if (msg == (void **)0x0) { + msg = &local_24; + } + if (timeout == 0) { + do { + BVar2 = xQueueReceive((QueueHandle_t)*mbox,msg,0xffffffff); + } while (BVar2 != 1); + } + else { + BVar2 = xQueueReceive((QueueHandle_t)*mbox,msg,timeout); + if (BVar2 != 1) { + *msg = (void *)0x0; + return 0xffffffff; + } + } + TVar3 = xTaskGetTickCount(); + return TVar3 - TVar1; +} + + + +u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox,void **msg) + +{ + BaseType_t BVar1; + void *pvStack20; + void *dummyptr; + + if (msg == (void **)0x0) { + msg = &pvStack20; + } + BVar1 = xQueueReceive((QueueHandle_t)*mbox,msg,0); + return -(uint)(BVar1 != 1); +} + + + +uint sys_mbox_valid(int *param_1) + +{ + return (uint)(*param_1 != 0); +} + + + +void sys_mbox_set_invalid(undefined4 *param_1) + +{ + *param_1 = 0; + return; +} + + + +err_t sys_sem_new(sys_sem_t *sem,u8_t count) + +{ + err_t eVar1; + QueueHandle_t xQueue; + undefined3 in_register_0000202d; + uint uVar2; + + xQueue = xQueueGenericCreate(1,0,'\x03'); + *(QueueHandle_t *)sem = xQueue; + if (xQueue != (QueueHandle_t)0x0) { + xQueueGenericSend(xQueue,(void *)0x0,0,0); + } + if ((QueueHandle_t)*sem == (QueueHandle_t)0x0) { + lwip_stats.sys.sem.err = lwip_stats.sys.sem.err + 1; + eVar1 = -1; + } + else { + if (CONCAT31(in_register_0000202d,count) == 0) { + xQueueSemaphoreTake((QueueHandle_t)*sem,1); + } + uVar2 = (uint)lwip_stats.sys.sem.used; + lwip_stats.sys.sem.used = (u16_t)((uVar2 + 1) * 0x10000 >> 0x10); + eVar1 = '\0'; + if ((uint)lwip_stats.sys.sem.max < (uVar2 + 1 & 0xffff)) { + eVar1 = '\0'; + lwip_stats.sys.sem.max = lwip_stats.sys.sem.used; + } + } + return eVar1; +} + + + +u32_t sys_arch_sem_wait(sys_sem_t *sem,u32_t timeout) + +{ + TickType_t TVar1; + BaseType_t BVar2; + TickType_t TVar3; + + TVar1 = xTaskGetTickCount(); + if (timeout == 0) { + do { + BVar2 = xQueueSemaphoreTake((QueueHandle_t)*sem,0xffffffff); + } while (BVar2 != 1); + } + else { + BVar2 = xQueueSemaphoreTake((QueueHandle_t)*sem,timeout); + if (BVar2 != 1) { + return 0xffffffff; + } + } + TVar3 = xTaskGetTickCount(); + return TVar3 - TVar1; +} + + + +void sys_sem_free(sys_sem_t *sem) + +{ + lwip_stats.sys.sem.used = lwip_stats.sys.sem.used - 1; + vQueueDelete((QueueHandle_t)*sem); + return; +} + + + +int sys_sem_valid(sys_sem_t *sem) + +{ + return (uint)(*sem != (sys_sem_t)0x0); +} + + + +void sys_sem_set_invalid(sys_sem_t *sem) + +{ + *sem = (sys_sem_t)0x0; + return; +} + + + +void sys_init(void) + +{ + s_nextthread = 0; + return; +} + + + +err_t sys_mutex_new(sys_mutex_t *mutex) + +{ + err_t eVar1; + QueueHandle_t pQVar2; + uint uVar3; + + pQVar2 = xQueueCreateMutex('\x01'); + *(QueueHandle_t *)mutex = pQVar2; + if (pQVar2 == (QueueHandle_t)0x0) { + lwip_stats.sys.mutex.err = lwip_stats.sys.mutex.err + 1; + eVar1 = -1; + } + else { + uVar3 = (uint)lwip_stats.sys.mutex.used; + lwip_stats.sys.mutex.used = (u16_t)((uVar3 + 1) * 0x10000 >> 0x10); + eVar1 = '\0'; + if ((uint)lwip_stats.sys.mutex.max < (uVar3 + 1 & 0xffff)) { + eVar1 = '\0'; + lwip_stats.sys.mutex.max = lwip_stats.sys.mutex.used; + } + } + return eVar1; +} + + + +void sys_mutex_lock(sys_mutex_t *mutex) + +{ + sys_arch_sem_wait((sys_sem_t *)mutex,0); + return; +} + + + +void sys_mutex_unlock(sys_mutex_t *mutex) + +{ + xQueueGenericSend((QueueHandle_t)*mutex,(void *)0x0,0,0); + return; +} + + + +void sys_sem_signal(sys_mutex_t *mutex) + +{ + xQueueGenericSend((QueueHandle_t)*mutex,(void *)0x0,0,0); + return; +} + + + +sys_thread_t sys_thread_new(char *name,lwip_thread_fn *thread,void *arg,int stacksize,int prio) + +{ + BaseType_t BVar1; + TaskHandle_t ptStack20; + TaskHandle_t CreatedTask; + + if (s_nextthread < 6) { + BVar1 = xTaskCreate((TaskFunction_t *)thread,name,(uint16_t)stacksize,arg,prio,&ptStack20); + if (BVar1 != 1) { + ptStack20 = (sys_thread_t)0x0; + } + return ptStack20; + } + return (sys_thread_t)0x0; +} + + + +sys_prot_t sys_arch_protect(void) + +{ + vTaskEnterCritical(); + return 1; +} + + + +void sys_arch_unprotect(void) + +{ + if ((xSchedulerRunning != 0) && (pxCurrentTCB->uxCriticalNesting != 0)) { + vTaskExitCritical(); + return; + } + return; +} + + + +TickType_t sys_now(void) + +{ + return xTickCount; +} + + + +// WARNING: Variable defined which should be unmapped: addr + +hostent * lwip_gethostbyname(char *name) + +{ + char *s_aliases; + ip_addr_t s_hostent_addr; + ip_addr_t *s_phostent_addr [2]; + hostent s_hostent; + char s_hostname [257]; + err_t eVar1; + undefined3 extraout_var; + hostent *phVar2; + ip_addr_t iStack20; + ip_addr_t addr; + + eVar1 = netconn_gethostbyname(name,&iStack20); + if (CONCAT31(extraout_var,eVar1) == 0) { + s_hostent_addr = (u32_t)iStack20; + s_phostent_addr[0] = (ip_addr_t *)0x4200ded8; + s_phostent_addr[1] = (ip_addr_t *)0x0; + strncpy((char *)0x4201490c,name,0x100); + phVar2 = (hostent *)0x420148f8; + } + else { + h_errno = 0xd2; + phVar2 = (hostent *)0x0; + } + return phVar2; +} + + + +void lwip_freeaddrinfo(addrinfo *ai) + +{ + addrinfo *paVar1; + + if (ai != (addrinfo *)0x0) { + do { + paVar1 = ai->ai_next; + memp_free(MEMP_NETDB,ai); + ai = paVar1; + } while (paVar1 != (addrinfo *)0x0); + return; + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: addr +// WARNING: Type propagation algorithm not settling + +int lwip_getaddrinfo(char *nodename,char *servname,addrinfo *hints,addrinfo **res) + +{ + err_t eVar1; + u16_t n; + int iVar2; + size_t __n; + undefined3 extraout_var; + addrinfo *__s; + size_t __n_00; + uint uVar3; + ip_addr_t iStack36; + ip_addr_t addr; + + if (res == (addrinfo **)0x0) { + return 0xca; + } + *res = (addrinfo *)0x0; + if (nodename != (char *)0x0) { + if (hints != (addrinfo *)0x0) goto LAB_2303a49a; + n = 0; + if (servname != (char *)0x0) goto LAB_2303a4ac; + goto LAB_2303a502; + } + if (servname == (char *)0x0) { + return 200; + } + if (hints == (addrinfo *)0x0) { +LAB_2303a4ac: + iVar2 = atoi(servname); + n = (u16_t)iVar2; + if (0xfffe < iVar2 - 1U) { + return 0xc9; + } + if (nodename != (char *)0x0) { + if (hints == (addrinfo *)0x0) { +LAB_2303a502: + eVar1 = netconn_gethostbyname(nodename,&iStack36); + if (CONCAT31(extraout_var,eVar1) != 0) { + return 0xca; + } + } + else { +LAB_2303a4ca: + if ((hints->ai_flags & 4U) == 0) goto LAB_2303a502; + iVar2 = ip4addr_aton(nodename,(ip4_addr_t *)&iStack36); + if (iVar2 == 0) { + return 200; + } + } + __n = strlen(nodename); + __n_00 = __n + 0x31; + if (0x100 < __n) { + return 0xca; + } + goto LAB_2303a53c; + } + } + else { +LAB_2303a49a: + uVar3 = hints->ai_family & 0xfffffffd; + n = (u16_t)uVar3; + if (uVar3 != 0) { + return 0xcc; + } + if (servname != (char *)0x0) goto LAB_2303a4ac; + if (nodename != (char *)0x0) goto LAB_2303a4ca; + } + if ((hints == (addrinfo *)0x0) || ((hints->ai_flags & 1U) == 0)) { + iStack36 = (ip4_addr_t)0x100007f; + } + else { + iStack36 = (ip4_addr_t)0x0; + } + __n = 0; + __n_00 = 0x30; +LAB_2303a53c: + __s = (addrinfo *)memp_malloc(MEMP_NETDB); + iVar2 = 0xcb; + if (__s != (addrinfo *)0x0) { + memset(__s,0,__n_00); + *(ip4_addr_t *)&((ip4_addr_t *)&__s[1].ai_family)->addr = iStack36; + *(undefined2 *)&__s[1].ai_flags = 0x210; + n = lwip_htons(n); + *(u16_t *)((int)&__s[1].ai_flags + 2) = n; + __s->ai_family = 2; + if (hints != (addrinfo *)0x0) { + __s->ai_socktype = hints->ai_socktype; + __s->ai_protocol = hints->ai_protocol; + } + if (nodename != (char *)0x0) { + *(socklen_t **)&__s->ai_canonname = &__s[1].ai_addrlen; + memcpy(&__s[1].ai_addrlen,nodename,__n); + __s->ai_canonname[__n] = '\0'; + } + __s->ai_addrlen = 0x10; + *(addrinfo **)&__s->ai_addr = __s + 1; + *res = __s; + iVar2 = 0; + } + return iVar2; +} + + + +err_t netifapi_do_netif_add(tcpip_api_call_data *m) + +{ + err_t eVar1; + netif *pnVar2; + + pnVar2 = netif_add(*(netif **)(m + 1),(ip4_addr_t *)m[1].sem,*(ip4_addr_t **)(m + 2), + (ip4_addr_t *)m[2].sem,*(void **)(m + 3),(netif_init_fn_conflict *)m[3].sem, + *(netif_input_fn **)(m + 4)); + if (pnVar2 == (netif *)0x0) { + eVar1 = -0xc; + } + else { + eVar1 = '\0'; + } + return eVar1; +} + + + +err_t netifapi_do_netif_set_addr(tcpip_api_call_data *m) + +{ + netif_set_addr(*(netif **)(m + 1),(ip4_addr_t *)m[1].sem,*(ip4_addr_t **)(m + 2), + (ip4_addr_t *)m[2].sem); + return '\0'; +} + + + +err_t netifapi_do_netif_common(tcpip_api_call_data *m) + +{ + err_t eVar1; + + if (*(code **)(m + 2) != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x2303a5f4. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (**(code **)(m + 2))(); + return eVar1; + } + (*(code *)m[1].sem)(*(undefined4 *)(m + 1),m[1].sem); + return '\0'; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netifapi_netif_add(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw, + void *state,netif_init_fn init,netif_input_fn *input) + +{ + err_t eVar1; + undefined auStack52 [4]; + netifapi_msg msg; + + if (ipaddr == (ip4_addr_t *)0x0) { + ipaddr = (ip4_addr_t *)&ip_addr_any; + } + if (netmask == (ip4_addr_t *)0x0) { + netmask = (ip4_addr_t *)&ip_addr_any; + } + if (gw == (ip4_addr_t *)0x0) { + gw = (ip4_addr_t *)&ip_addr_any; + } + msg.call.sem = (sys_sem_t)netif; + msg.netif = (netif *)ipaddr; + msg.msg._0_4_ = netmask; + msg.msg._4_4_ = gw; + msg.msg._8_4_ = state; + msg.msg._12_4_ = init; + msg.msg._16_4_ = input; + eVar1 = tcpip_api_call(netifapi_do_netif_add,(tcpip_api_call_data *)auStack52); + return eVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netifapi_netif_set_addr(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw) + +{ + err_t eVar1; + undefined auStack52 [4]; + netifapi_msg msg; + + if (ipaddr == (ip4_addr_t *)0x0) { + ipaddr = (ip4_addr_t *)&ip_addr_any; + } + if (netmask == (ip4_addr_t *)0x0) { + netmask = (ip4_addr_t *)&ip_addr_any; + } + if (gw == (ip4_addr_t *)0x0) { + gw = (ip4_addr_t *)&ip_addr_any; + } + msg.call.sem = (sys_sem_t)netif; + msg.netif = (netif *)ipaddr; + msg.msg._0_4_ = netmask; + msg.msg._4_4_ = gw; + eVar1 = tcpip_api_call(netifapi_do_netif_set_addr,(tcpip_api_call_data *)auStack52); + return eVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netifapi_netif_common(netif *netif,netifapi_void_fn voidfunc,netifapi_errt_fn errtfunc) + +{ + err_t eVar1; + undefined auStack52 [4]; + netifapi_msg msg; + + msg.call.sem = (sys_sem_t)netif; + msg.netif = (netif *)voidfunc; + msg.msg._0_4_ = errtfunc; + eVar1 = tcpip_api_call(netifapi_do_netif_common,(tcpip_api_call_data *)auStack52); + return eVar1; +} + + + +int alloc_socket(netconn *newconn,int accepted) + +{ + int iVar1; + u16_t uVar2; + lwip_sock *plVar3; + + uVar2 = (u16_t)accepted; + plVar3 = sockets; + iVar1 = 0; + do { + sys_arch_protect(); + if (plVar3->conn == (netconn *)0x0) { + sockets[iVar1].conn = newconn; + sys_arch_unprotect(); + sockets[iVar1].lastdata = 0; + sockets[iVar1].rcvevent = 0; + if ((newconn->type & 0xf0) != NETCONN_TCP) { + uVar2 = 1; + } + sockets[iVar1].sendevent = uVar2; + sockets[iVar1].errevent = 0; + return iVar1; + } + iVar1 = iVar1 + 1; + sys_arch_unprotect(); + plVar3 = plVar3 + 1; + } while (iVar1 != 0x15); + return -1; +} + + + +void lwip_link_select_cb(lwip_select_cb *select_cb) + +{ + sys_arch_protect(); + select_cb->next = select_cb_list; + if (select_cb_list != (lwip_select_cb *)0x0) { + select_cb_list->prev = select_cb; + } + select_cb_ctr = select_cb_ctr + 1; + select_cb_list = select_cb; + sys_arch_unprotect(); + return; +} + + + +void lwip_unlink_select_cb(lwip_select_cb *select_cb) + +{ + lwip_select_cb **pplVar1; + + sys_arch_protect(); + if (select_cb->next != (lwip_select_cb *)0x0) { + select_cb->next->prev = select_cb->prev; + } + pplVar1 = &select_cb_list; + if (select_cb_list != select_cb) { + pplVar1 = (lwip_select_cb **)select_cb->prev; + } + ((lwip_select_cb *)pplVar1)->next = select_cb->next; + select_cb_ctr = select_cb_ctr + 1; + sys_arch_unprotect(); + return; +} + + + +int lwip_selscan(int maxfdp1,_types_fd_set *readset_in,_types_fd_set *writeset_in, + _types_fd_set *exceptset_in,_types_fd_set *readset_out,_types_fd_set *writeset_out, + _types_fd_set *exceptset_out) + +{ + short sVar1; + u16_t uVar2; + u16_t uVar3; + uint uVar4; + uint uVar5; + int iVar6; + int iVar7; + lwip_sock *plVar8; + s16_t rcvevent; + fd_mask local_58; + _types_fd_set lreadset; + _types_fd_set lwriteset; + _types_fd_set lexceptset; + + iVar6 = 0; + do { + *(undefined *)((int)&local_58 + iVar6) = 0; + iVar6 = iVar6 + 1; + } while (iVar6 != 8); + iVar6 = 0; + do { + *(undefined *)((int)lreadset.fds_bits + iVar6 + 4) = 0; + iVar6 = iVar6 + 1; + } while (iVar6 != 8); + iVar6 = 0; + do { + *(undefined *)((int)lwriteset.fds_bits + iVar6 + 4) = 0; + iVar6 = iVar6 + 1; + } while (iVar6 != 8); + plVar8 = sockets; + iVar6 = 0; + uVar4 = 0; + do { + if (maxfdp1 <= (int)uVar4) { + readset_out->fds_bits[0] = local_58; + readset_out->fds_bits[1] = lreadset.fds_bits[0]; + writeset_out->fds_bits[0] = lreadset.fds_bits[1]; + writeset_out->fds_bits[1] = lwriteset.fds_bits[0]; + exceptset_out->fds_bits[0] = lwriteset.fds_bits[1]; + exceptset_out->fds_bits[1] = lexceptset.fds_bits[0]; + return iVar6; + } + if ((((readset_in != (_types_fd_set *)0x0) && + ((1 << (uVar4 & 0x1f) & readset_in->fds_bits[uVar4 >> 5]) != 0)) || + ((writeset_in != (_types_fd_set *)0x0 && + ((1 << (uVar4 & 0x1f) & writeset_in->fds_bits[uVar4 >> 5]) != 0)))) || + ((exceptset_in != (_types_fd_set *)0x0 && + ((1 << (uVar4 & 0x1f) & exceptset_in->fds_bits[uVar4 >> 5]) != 0)))) { + sys_arch_protect(); + if (0x14 < uVar4) { + sys_arch_unprotect(); + return -1; + } + uVar2 = plVar8->sendevent; + uVar3 = plVar8->errevent; + iVar7 = plVar8->lastdata; + sVar1 = plVar8->rcvevent; + sys_arch_unprotect(); + if (((readset_in != (_types_fd_set *)0x0) && + (uVar5 = 1 << (uVar4 & 0x1f), (readset_in->fds_bits[0] & uVar5) != 0)) && + ((iVar7 != 0 || (0 < sVar1)))) { + iVar6 = iVar6 + 1; + local_58 = local_58 | uVar5; + } + if (((writeset_in != (_types_fd_set *)0x0) && + (uVar5 = 1 << (uVar4 & 0x1f), (writeset_in->fds_bits[0] & uVar5) != 0)) && (uVar2 != 0)) { + iVar6 = iVar6 + 1; + lreadset.fds_bits[1] = lreadset.fds_bits[1] | uVar5; + } + if (((exceptset_in != (_types_fd_set *)0x0) && + (uVar5 = 1 << (uVar4 & 0x1f), (exceptset_in->fds_bits[0] & uVar5) != 0)) && (uVar3 != 0)) + { + iVar6 = iVar6 + 1; + lwriteset.fds_bits[1] = lwriteset.fds_bits[1] | uVar5; + } + } + uVar4 = uVar4 + 1; + plVar8 = plVar8 + 1; + } while( true ); +} + + + +ssize_t lwip_recv_tcp(lwip_sock *sock,void *mem,size_t len,int flags) + +{ + size_t len_00; + err_t err; + pbuf *ppVar1; + undefined3 extraout_var; + int iVar2; + void *dataptr; + u8_t apiflags; + uint uVar3; + pbuf *ppStack52; + pbuf *p; + + if ((int)len < 0) { + len = 0x7fffffff; + } + apiflags = '\b'; + if ((flags & 8U) != 0) { + apiflags = '\f'; + } + len_00 = 0; + do { + ppVar1 = (pbuf *)sock->lastdata; + if ((pbuf *)sock->lastdata == (pbuf *)0x0) { + err = netconn_recv_tcp_pbuf_flags(sock->conn,&ppStack52,apiflags); + if (CONCAT31(extraout_var,err) != 0) { + if (len_00 == 0) { + iVar2 = err_to_errno(err); + if (iVar2 != 0) { + errno = iVar2; + } + return -(uint)(CONCAT31(extraout_var,err) != -0xf); + } + if ((flags & 1U) != 0) { + return len_00; + } + goto LAB_2303a9bc; + } + *(pbuf **)&sock->lastdata = ppStack52; + ppVar1 = ppStack52; + } + ppStack52 = ppVar1; + uVar3 = (uint)ppStack52->tot_len; + if ((int)len <= (int)uVar3) { + uVar3 = len & 0xffff; + } + dataptr = (void *)((int)mem + len_00); + len_00 = uVar3 + len_00; + pbuf_copy_partial(ppStack52,dataptr,(u16_t)uVar3,0); + if ((flags & 1U) != 0) { + if (len_00 != 0) { + return len_00; + } + goto LAB_2303aa2c; + } + if ((int)(ppStack52->tot_len - uVar3) < 1) { + sock->lastdata = 0; + pbuf_free(ppStack52); + } + else { + ppVar1 = pbuf_free_header(ppStack52,(u16_t)uVar3); + *(pbuf **)&sock->lastdata = ppVar1; + } + len = len - uVar3; + apiflags = '\x1c'; + } while (0 < (int)len); + if (len_00 == 0) { +LAB_2303aa2c: + len_00 = 0; + } + else { +LAB_2303a9bc: + netconn_tcp_recvd(sock->conn,len_00); + } + return len_00; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int lwip_sock_make_addr(u16_t port,sockaddr *from,socklen_t *fromlen) + +{ + int iVar1; + undefined2 in_register_0000202a; + size_t *in_a3; + uint uVar2; + undefined2 uStack32; + u16_t uStack30; + sockaddr_aligned saddr; + + uStack32 = 0x210; + uStack30 = lwip_htons((u16_t)from); + saddr._0_4_ = *(undefined4 *)CONCAT22(in_register_0000202a,port); + memset(saddr + 4,0,8); + uVar2 = (uint)(byte)uStack32; + iVar1 = 1; + if ((uVar2 <= *in_a3) && (iVar1 = 0, uVar2 < *in_a3)) { + *in_a3 = uVar2; + } + memcpy(fromlen,&uStack32,*in_a3); + return iVar1; +} + + + +void free_socket(lwip_sock *sock,int is_tcp) + +{ + netbuf *buf; + netconn *conn; + + sys_arch_protect(); + buf = (netbuf *)sock->lastdata; + conn = sock->conn; + sock->lastdata = 0; + sock->conn = (netconn *)0x0; + sys_arch_unprotect(); + if (buf != (netbuf *)0x0) { + if (is_tcp == 0) { + netbuf_delete(buf); + } + else { + pbuf_free((pbuf *)buf); + } + } + if (conn != (netconn *)0x0) { + netconn_delete(conn); + return; + } + return; +} + + + +err_t lwip_recvfrom_udp_raw(lwip_sock *sock,int flags,msghdr *msg,u16_t *datagram_len) + +{ + ushort uVar1; + uint uVar2; + err_t eVar3; + undefined3 extraout_var; + uint uVar4; + uint uVar5; + int iVar6; + netbuf *pnStack52; + netbuf *buf; + + if ((msg->msg_iov != (iovec *)0x0) || (eVar3 = -0x10, msg->msg_iovlen < 1)) { + pnStack52 = (netbuf *)sock->lastdata; + if (pnStack52 == (netbuf *)0x0) { + eVar3 = netconn_recv_udp_raw_netbuf_flags(sock->conn,&pnStack52,((flags & 8U) != 0) << 2); + if (CONCAT31(extraout_var,eVar3) != 0) { + return eVar3; + } + *(netbuf **)&sock->lastdata = pnStack52; + } + iVar6 = 0; + uVar2 = 0; + uVar1 = pnStack52->p->tot_len; + while ((iVar6 < msg->msg_iovlen && (uVar2 < uVar1))) { + uVar4 = msg->msg_iov[iVar6].iov_len; + uVar5 = uVar1 - uVar2 & 0xffff; + if (uVar4 <= uVar5) { + uVar5 = uVar4 & 0xffff; + } + pbuf_copy_partial(pnStack52->p,msg->msg_iov[iVar6].iov_base,(u16_t)uVar5,(u16_t)uVar2); + uVar2 = uVar2 + uVar5 & 0xffff; + iVar6 = iVar6 + 1; + } + if (((socklen_t *)msg->msg_name != (socklen_t *)0x0) && (msg->msg_namelen != 0)) { + lwip_sock_make_addr((short)pnStack52 + 8,(sockaddr *)(uint)pnStack52->port, + (socklen_t *)msg->msg_name); + } + msg->msg_flags = 0; + if (msg->msg_control != (void *)0x0) { + msg->msg_controllen = 0; + } + if ((flags & 1U) == 0) { + sock->lastdata = 0; + netbuf_delete(pnStack52); + } + *datagram_len = uVar1; + eVar3 = '\0'; + } + return eVar3; +} + + + +lwip_sock * get_socket(int fd) + +{ + lwip_sock *plVar1; + + if ((0x14 < (uint)fd) || (plVar1 = sockets + fd, plVar1->conn == (netconn *)0x0)) { + errno = 9; + plVar1 = (lwip_sock *)0x0; + } + return plVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +void lwip_setsockopt_callback(void *arg) + +{ + ip4_addr_t iVar1; + err_t eVar2; + ip4_addr_t *name; + sys_mutex_t mutex; + lwip_sock *plVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + netif *netif; + netconn *pnVar4; + lwip_socket_multicast_pair *plVar5; + uint uVar6; + int iVar7; + byte bVar8; + netconn_type nVar9; + int iVar10; + u32_t uVar11; + uint fd; + ip4_addr_t iStack40; + ip4_addr_t if_addr; + ip4_addr_t multi_addr; + + fd = *(uint *)arg; + iVar1 = (ip4_addr_t)((ip4_addr_t *)((int)arg + 4))->addr; + iVar10 = *(int *)((int)arg + 8); + bVar8 = (byte)iVar10; + uVar6 = *(uint *)((int)arg + 0x10); + name = *(ip4_addr_t **)((int)arg + 0xc); + if ((0x14 < fd) || (pnVar4 = sockets[fd].conn, pnVar4 == (netconn *)0x0)) { + iVar1 = (ip4_addr_t)0x9; + goto LAB_2303ac7e; + } + if (iVar1 == (ip4_addr_t)0x6) { + iVar1 = (ip4_addr_t)0x16; + if ((((uVar6 < 4) || (iVar7 = pnVar4->pcb, iVar7 == 0)) || + (iVar1 = (ip4_addr_t)0x5c, (pnVar4->type & 0xf0) != NETCONN_TCP)) || + ((iVar1 = (ip4_addr_t)0x16, *(char *)(iVar7 + 0x14) == '\x01' || + (iVar1 = (ip4_addr_t)0x5c, 4 < iVar10 - 1U)))) goto LAB_2303ac7e; + iVar1 = (ip4_addr_t)name->addr; + switch(iVar10) { + case 1: + if (iVar1 == (ip4_addr_t)0x0) { + *(ushort *)(iVar7 + 0x1a) = *(ushort *)(iVar7 + 0x1a) & 0xffbf; + goto LAB_2303ac7e; + } + *(ushort *)(iVar7 + 0x1a) = *(ushort *)(iVar7 + 0x1a) | 0x40; + break; + case 3: + iVar1 = (ip4_addr_t)((int)iVar1 * 1000); + case 2: + *(ip4_addr_t *)&((ip4_addr_t *)(iVar7 + 0x94))->addr = iVar1; + break; + case 4: + *(int *)(iVar7 + 0x98) = (int)iVar1 * 1000; + break; + case 5: + *(ip4_addr_t *)&((ip4_addr_t *)(iVar7 + 0x9c))->addr = iVar1; + } +LAB_2303acfa: + iVar1 = (ip4_addr_t)0x0; + goto LAB_2303ac7e; + } + if (iVar1 == (ip4_addr_t)0xfff) { + if (iVar10 == 0x1005) { + iVar1 = (ip4_addr_t)0x16; + if ((uVar6 < 0x10) || (iVar10 = name->addr * 1000 + *(int *)(name + 2) / 1000, iVar10 < 0)) + goto LAB_2303ac7e; + pnVar4->send_timeout = iVar10; + } + else { + if (iVar10 < 0x1006) { + if (((iVar10 != 8) && (iVar10 != 0x20)) && (iVar10 != 4)) goto switchD_2303add6_caseD_7; + if (iVar10 == 0x20) { + iVar1 = (ip4_addr_t)0x5c; + if ((pnVar4->type & 0xf0) != NETCONN_UDP) goto LAB_2303ac7e; + } + else { + if ((iVar10 != 4) && (iVar10 != 8)) { + bVar8 = 0; + } + } + iVar1 = (ip4_addr_t)0x16; + if ((uVar6 < 4) || (iVar10 = pnVar4->pcb, iVar1 = (ip4_addr_t)0x16, iVar10 == 0)) + goto LAB_2303ac7e; + iVar1 = (ip4_addr_t)name->addr; + if (iVar1 == (ip4_addr_t)0x0) { + *(byte *)(iVar10 + 9) = *(byte *)(iVar10 + 9) & ~bVar8; + goto LAB_2303ac7e; + } + *(byte *)(iVar10 + 9) = *(byte *)(iVar10 + 9) | bVar8; + } + else { + if (iVar10 == 0x100a) { + iVar1 = (ip4_addr_t)0x16; + if (((uVar6 < 4) || (iVar10 = pnVar4->pcb, iVar10 == 0)) || + (iVar1 = (ip4_addr_t)0x5c, (pnVar4->type & 0xf0) != NETCONN_UDP)) goto LAB_2303ac7e; + iVar1 = (ip4_addr_t)name->addr; + if (iVar1 == (ip4_addr_t)0x0) { + bVar8 = *(byte *)(iVar10 + 0x10) & 0xfe; + goto LAB_2303ad60; + } + *(byte *)(iVar10 + 0x10) = *(byte *)(iVar10 + 0x10) | 1; + } + else { + if (iVar10 == 0x100b) { + iVar1 = (ip4_addr_t)0x16; + if (uVar6 < 6) goto LAB_2303ac7e; + netif = (netif *)0x0; + if (*(char *)&name->addr != '\0') { + netif = netif_find((char *)name); + iVar1 = (ip4_addr_t)0x13; + if (netif == (netif *)0x0) goto LAB_2303ac7e; + } + pnVar4 = sockets[fd].conn; + nVar9 = pnVar4->type & 0xf0; + if (nVar9 == NETCONN_UDP) { + udp_bind_netif((udp_pcb *)pnVar4->pcb,netif); + } + else { + if (nVar9 != NETCONN_RAW) { + iVar1 = (ip4_addr_t)0x0; + if (nVar9 == NETCONN_TCP) { + tcp_bind_netif((tcp_pcb *)pnVar4->pcb,netif); + } + goto LAB_2303ac7e; + } + raw_bind_netif((raw_pcb *)pnVar4->pcb,netif); + } + } + else { + if (iVar10 != 0x1006) goto switchD_2303add6_caseD_7; + iVar1 = (ip4_addr_t)0x16; + if ((uVar6 < 0x10) || + (uVar11 = name->addr * 1000 + *(int *)(name + 2) / 1000, (int)uVar11 < 0)) + goto LAB_2303ac7e; + pnVar4->recv_timeout = uVar11; + } + } + } + } + goto LAB_2303acfa; + } + if (iVar1 != (ip4_addr_t)0x0) goto switchD_2303add6_caseD_7; + switch(iVar10) { + case 1: + if ((3 < uVar6) && (pnVar4->pcb != 0)) { + *(undefined *)(pnVar4->pcb + 10) = (char)name->addr; + goto LAB_2303ac7e; + } + goto LAB_2303afd4; + case 2: + if ((3 < uVar6) && (pnVar4->pcb != 0)) { + *(undefined *)(pnVar4->pcb + 0xb) = (char)name->addr; + goto LAB_2303ac7e; + } +LAB_2303afd4: + iVar1 = (ip4_addr_t)0x16; + goto LAB_2303ac7e; + case 3: + case 4: + if ((uVar6 < 8) || (pnVar4->pcb == 0)) goto LAB_2303afd4; + if ((pnVar4->type & 0xf0) == NETCONN_UDP) { + iStack40 = (ip4_addr_t)name[1].addr; + if_addr = name->addr; + if (iVar10 == 3) { + plVar3 = get_socket(fd); + if (plVar3 != (lwip_sock *)0x0) { + plVar5 = socket_ipv4_multicast_memberships; + iVar10 = 0; + do { + if (plVar5->sock == (lwip_sock *)0x0) { + socket_ipv4_multicast_memberships[iVar10].sock = plVar3; + *(ip4_addr_t *)&socket_ipv4_multicast_memberships[iVar10].if_addr.addr = iStack40; + socket_ipv4_multicast_memberships[iVar10].multi_addr.addr = if_addr; + eVar2 = igmp_joingroup(&iStack40,&if_addr); + iVar10 = CONCAT31(extraout_var,eVar2); + goto LAB_2303aed6; + } + iVar10 = iVar10 + 1; + plVar5 = plVar5 + 1; + } while (iVar10 != 0x15); + } + iVar1 = (ip4_addr_t)0xc; + } + else { + eVar2 = igmp_leavegroup(&iStack40,&if_addr); + iVar10 = CONCAT31(extraout_var_00,eVar2); + plVar3 = get_socket(fd); + if (plVar3 != (lwip_sock *)0x0) { + plVar5 = socket_ipv4_multicast_memberships; + iVar7 = 0; + do { + if (((plVar3 == plVar5->sock) && ((ip4_addr_t)(plVar5->if_addr).addr == iStack40)) && + ((plVar5->multi_addr).addr == if_addr)) { + socket_ipv4_multicast_memberships[iVar7].sock = (lwip_sock *)0x0; + socket_ipv4_multicast_memberships[iVar7].if_addr.addr = 0; + socket_ipv4_multicast_memberships[iVar7].multi_addr.addr = 0; + break; + } + iVar7 = iVar7 + 1; + plVar5 = plVar5 + 1; + } while (iVar7 != 0x15); + } +LAB_2303aed6: + if (iVar10 != 0) { + iVar1 = (ip4_addr_t)0x63; + } + } + goto LAB_2303ac7e; + } + break; + case 5: + if ((uVar6 == 0) || (pnVar4->pcb == 0)) goto LAB_2303afd4; + if ((pnVar4->type & 0xf0) == NETCONN_UDP) { + *(undefined *)(pnVar4->pcb + 0x1d) = *(undefined *)&name->addr; + goto LAB_2303ac7e; + } + break; + case 6: + if ((uVar6 < 4) || (pnVar4->pcb == 0)) goto LAB_2303afd4; + if ((pnVar4->type & 0xf0) == NETCONN_UDP) { + ((ip4_addr_t *)(pnVar4->pcb + 0x18))->addr = name->addr; + goto LAB_2303ac7e; + } + break; + case 7: + if ((uVar6 == 0) || (iVar10 = pnVar4->pcb, iVar10 == 0)) goto LAB_2303afd4; + if ((pnVar4->type & 0xf0) == NETCONN_UDP) { + if (*(char *)&name->addr == '\0') { + bVar8 = *(byte *)(iVar10 + 0x10) & 0xf7; + } + else { + bVar8 = *(byte *)(iVar10 + 0x10) | 8; + } +LAB_2303ad60: + *(byte *)(iVar10 + 0x10) = bVar8; + goto LAB_2303ac7e; + } + } +switchD_2303add6_caseD_7: + iVar1 = (ip4_addr_t)0x5c; +LAB_2303ac7e: + mutex = *(sys_mutex_t *)((int)arg + 0x18); + *(ip4_addr_t *)&((ip4_addr_t *)((int)arg + 0x14))->addr = iVar1; + sys_sem_signal((sys_mutex_t *)mutex); + return; +} + + + +void event_callback(netconn *conn,netconn_evt evt,u16_t len) + +{ + short sVar1; + u16_t uVar2; + u16_t uVar3; + bool bVar4; + lwip_select_cb *plVar5; + lwip_select_cb *plVar6; + uint fd; + sys_prot_t sVar7; + lwip_sock *plVar8; + undefined3 in_register_0000202d; + nfds_t nVar9; + int iVar10; + ushort *puVar11; + uint uVar12; + uint uVar13; + + if (conn == (netconn *)0x0) { + return; + } + fd = conn->socket; + if ((int)fd < 0) { + sVar7 = sys_arch_protect(); + fd = conn->socket; + if ((int)fd < 0) { + if (CONCAT31(in_register_0000202d,evt) == 0) { + conn->socket = fd - 1; + } + goto LAB_2303b018; + } + sys_arch_unprotect(sVar7); + } + plVar8 = get_socket(fd); + if (plVar8 == (lwip_sock *)0x0) { + return; + } + sVar7 = sys_arch_protect(); + bVar4 = true; + switch(CONCAT31(in_register_0000202d,evt)) { + case 0: + iVar10 = ((uint)(ushort)plVar8->rcvevent + 1) * 0x10000; + plVar8->rcvevent = (s16_t)((uint)iVar10 >> 0x10); + bVar4 = iVar10 >> 0x10 < 2; + break; + case 1: + plVar8->rcvevent = plVar8->rcvevent + -1; + goto LAB_2303b0cc; + case 2: + uVar2 = plVar8->sendevent; + plVar8->sendevent = 1; + bVar4 = uVar2 == 0; + break; + case 3: + plVar8->sendevent = 0; +LAB_2303b0cc: + bVar4 = false; + break; + case 4: + bVar4 = true; + plVar8->errevent = 1; + } + if ((plVar8->select_waiting != '\0') && (bVar4)) { + sVar1 = plVar8->rcvevent; + uVar2 = plVar8->sendevent; + uVar3 = plVar8->errevent; + sys_arch_unprotect(); + sVar7 = sys_arch_protect(); + uVar12 = fd >> 5; + uVar13 = 1 << (fd & 0x1f); + plVar5 = select_cb_list; + while (plVar6 = plVar5, iVar10 = select_cb_ctr, plVar6 != (lwip_select_cb *)0x0) { + if (plVar6->sem_signalled == 0) { + if (plVar6->poll_fds == (pollfd *)0x0) { + if (((((0 < sVar1) && (plVar6->readset != (_types_fd_set *)0x0)) && + ((uVar13 & plVar6->readset->fds_bits[uVar12]) != 0)) || + (((uVar2 != 0 && (plVar6->writeset != (_types_fd_set *)0x0)) && + ((uVar13 & plVar6->writeset->fds_bits[uVar12]) != 0)))) || + (((uVar3 != 0 && (plVar6->exceptset != (_types_fd_set *)0x0)) && + ((uVar13 & plVar6->exceptset->fds_bits[uVar12]) != 0)))) { +LAB_2303b17c: + plVar6->sem_signalled = 1; + sys_sem_signal((sys_mutex_t *)&plVar6->sem); + } + } + else { + puVar11 = (ushort *)&plVar6->poll_fds->events; + nVar9 = 0; + while (nVar9 != plVar6->poll_nfds) { + if ((fd == *(uint *)(puVar11 + -2)) && + ((((0 < sVar1 && ((*puVar11 & 1) != 0)) || ((uVar2 != 0 && ((*puVar11 & 2) != 0)))) + || (uVar3 != 0)))) goto LAB_2303b17c; + nVar9 = nVar9 + 1; + puVar11 = puVar11 + 4; + } + } + } + sys_arch_unprotect(sVar7); + sVar7 = sys_arch_protect(); + plVar5 = select_cb_list; + if (select_cb_ctr == iVar10) { + plVar5 = plVar6->next; + } + } + } +LAB_2303b018: + sys_arch_unprotect(sVar7); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int lwip_accept(int s,sockaddr *addr,socklen_t *addrlen) + +{ + int iVar1; + err_t err; + lwip_sock *plVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + int iVar3; + u16_t uStack58; + u16_t port; + netconn *pnStack56; + netconn *newconn; + ip_addr_t naddr; + sockaddr_aligned tempaddr; + + uStack58 = 0; + plVar2 = get_socket(s); + if (plVar2 == (lwip_sock *)0x0) { + return -1; + } + err = netconn_accept(plVar2->conn,(netconn **)&stack0xffffffc8); + if (CONCAT31(extraout_var,err) == 0) { + iVar3 = alloc_socket(pnStack56,1); + if (iVar3 == -1) { + netconn_delete(pnStack56); + errno = 0x17; + return -1; + } + sys_arch_protect(); + iVar1 = pnStack56->socket; + pnStack56->socket = iVar3; + sys_arch_unprotect(); + if (pnStack56->callback != (netconn_callback *)0x0) { + iVar1 = (int)(short)~(ushort)iVar1; + while (0 < iVar1) { + iVar1 = iVar1 + -1; + (*pnStack56->callback)(pnStack56,NETCONN_EVT_RCVPLUS,0); + } + } + if (addr == (sockaddr *)0x0) { + return iVar3; + } + if (addrlen == (socklen_t *)0x0) { + return iVar3; + } + err = netconn_getaddr(pnStack56,(ip_addr_t *)&newconn,&uStack58,'\0'); + if (CONCAT31(extraout_var_00,err) == 0) { + naddr.addr._0_2_ = 0x210; + naddr.addr._2_2_ = lwip_htons(uStack58); + tempaddr._0_4_ = (ip_addr_t)newconn; + memset(tempaddr + 4,0,8); + if ((uint)(byte)naddr.addr < *addrlen) { + *addrlen = (uint)(byte)naddr.addr; + } + memcpy(addr,&naddr,*addrlen); + return iVar3; + } + netconn_delete(pnStack56); + free_socket(sockets + iVar3,1); + } + else { + if ((plVar2->conn->type & 0xf0) != NETCONN_TCP) { + errno = 0x5f; + return -1; + } + if (CONCAT31(extraout_var,err) == -0xf) { + errno = 0x16; + return -1; + } + } + iVar3 = err_to_errno(err); + if (iVar3 != 0) { + errno = iVar3; + } + return -1; +} + + + +// WARNING: Type propagation algorithm not settling + +int lwip_bind(int s,sockaddr *name,socklen_t namelen) + +{ + err_t err; + u16_t port; + lwip_sock *plVar1; + int iVar2; + undefined3 extraout_var; + ip_addr_t iStack20; + ip_addr_t local_addr; + + plVar1 = get_socket(s); + if (plVar1 != (lwip_sock *)0x0) { + if (((namelen == 0x10) && (name->sa_family == '\x02')) && (((uint)name & 3) == 0)) { + iStack20 = (ip_addr_t)((ip_addr_t *)(name->sa_data + 2))->addr; + port = lwip_htons(*(u16_t *)name->sa_data); + err = netconn_bind(plVar1->conn,&iStack20,port); + if (CONCAT31(extraout_var,err) == 0) { + return 0; + } + } + else { + err = -0x10; + } + iVar2 = err_to_errno(err); + if (iVar2 != 0) { + errno = iVar2; + } + } + return -1; +} + + + +// WARNING: Type propagation algorithm not settling + +int lwip_close(int s) + +{ + lwip_socket_multicast_pair *plVar1; + uint is_tcp; + err_t err; + lwip_sock *sock; + netconn *pnVar2; + undefined3 extraout_var; + int iVar3; + ip_addr_t iStack40; + ip_addr_t multi_addr; + ip_addr_t if_addr; + + sock = get_socket(s); + if (sock != (lwip_sock *)0x0) { + is_tcp = 0; + if (sock->conn != (netconn *)0x0) { + is_tcp = (uint)((sock->conn->type & 0xf0) == NETCONN_TCP); + } + pnVar2 = (netconn *)get_socket(s); + if (pnVar2 != (netconn *)0x0) { + plVar1 = socket_ipv4_multicast_memberships; + do { + if (pnVar2 == ((lwip_sock *)plVar1)->conn) { + iStack40 = (ip_addr_t)((ip_addr_t *)&((lwip_sock *)plVar1)->rcvevent)->addr; + ((lwip_sock *)plVar1)->conn = (netconn *)0x0; + *(undefined4 *)&((lwip_sock *)plVar1)->rcvevent = 0; + multi_addr = ((ip_addr_t *)&((lwip_sock *)plVar1)->lastdata)->addr; + ((lwip_sock *)plVar1)->lastdata = 0; + netconn_join_leave_group(*(netconn **)&pnVar2->type,&iStack40,&multi_addr,NETCONN_LEAVE); + } + plVar1 = (lwip_socket_multicast_pair *)&((lwip_sock *)plVar1)->errevent; + } while ((lwip_sock *)plVar1 != sockets); + } + err = netconn_prepare_delete(sock->conn); + if (CONCAT31(extraout_var,err) == 0) { + free_socket(sock,is_tcp); + return 0; + } + iVar3 = err_to_errno(err); + if (iVar3 != 0) { + errno = iVar3; + } + } + return -1; +} + + + +// WARNING: Type propagation algorithm not settling + +int lwip_connect(int s,sockaddr *name,socklen_t namelen) + +{ + err_t err; + u16_t port; + lwip_sock *plVar1; + undefined3 extraout_var; + int iVar2; + undefined3 extraout_var_00; + ip_addr_t iStack20; + ip_addr_t remote_addr; + + plVar1 = get_socket(s); + if (plVar1 == (lwip_sock *)0x0) { + return 0xffffffff; + } + if (name->sa_family == '\0') { + err = netconn_disconnect(plVar1->conn); + iVar2 = CONCAT31(extraout_var,err); + } + else { + if (((namelen != 0x10) || (name->sa_family != '\x02')) || (((uint)name & 3) != 0)) { + err = -0x10; + goto LAB_2303b43e; + } + iStack20 = (ip_addr_t)((ip_addr_t *)(name->sa_data + 2))->addr; + port = lwip_htons(*(u16_t *)name->sa_data); + err = netconn_connect(plVar1->conn,&iStack20,port); + iVar2 = CONCAT31(extraout_var_00,err); + } + err = (err_t)iVar2; + if (iVar2 == 0) { + return 0; + } +LAB_2303b43e: + iVar2 = err_to_errno(err); + if (iVar2 != 0) { + errno = iVar2; + } + return -1; +} + + + +int lwip_listen(int s,int backlog) + +{ + err_t err; + lwip_sock *plVar1; + undefined3 extraout_var; + int iVar2; + u8_t backlog_00; + + plVar1 = get_socket(s); + if (plVar1 != (lwip_sock *)0x0) { + if (backlog < 0) { + backlog = 0; + } + backlog_00 = (u8_t)backlog; + if (0xff < backlog) { + backlog_00 = -1; + } + err = netconn_listen_with_backlog(plVar1->conn,backlog_00); + if (CONCAT31(extraout_var,err) == 0) { + return 0; + } + if ((plVar1->conn->type & 0xf0) == NETCONN_TCP) { + iVar2 = err_to_errno(err); + if (iVar2 != 0) { + errno = iVar2; + } + } + else { + errno = 0x5f; + } + } + return -1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +ssize_t lwip_recvfrom(int s,void *mem,size_t len,int flags,sockaddr *from,socklen_t *fromlen) + +{ + uint uVar1; + err_t err; + lwip_sock *sock; + ssize_t sVar2; + undefined3 extraout_var; + int iVar3; + socklen_t sVar4; + u16_t uStack70; + u16_t datagram_len; + void *pvStack68; + iovec vec; + msghdr msg; + + sock = get_socket(s); + if (sock != (lwip_sock *)0x0) { + if ((sock->conn->type & 0xf0) == NETCONN_TCP) { + sVar2 = lwip_recv_tcp(sock,mem,len,flags); + if (from == (sockaddr *)0x0) { + return sVar2; + } + if (fromlen == (socklen_t *)0x0) { + return sVar2; + } + netconn_getaddr(sock->conn,(ip_addr_t *)&vec.iov_len,(u16_t *)&stack0xffffffbc,'\0'); + lwip_sock_make_addr((short)register0x00002008 - 0x3c,(sockaddr *)((uint)pvStack68 & 0xffff), + (socklen_t *)from); + return sVar2; + } + uStack70 = 0; + sVar4 = 0; + if (fromlen != (socklen_t *)0x0) { + sVar4 = *fromlen; + } + pvStack68 = mem; + vec.iov_base = (void *)len; + vec.iov_len = (size_t)from; + err = lwip_recvfrom_udp_raw(sock,flags,(msghdr *)&vec.iov_len,&uStack70); + if (CONCAT31(extraout_var,err) == 0) { + uVar1 = (uint)uStack70; + if (len < (uint)uStack70) { + uVar1 = len; + } + if (fromlen == (socklen_t *)0x0) { + return uVar1; + } + *fromlen = sVar4; + return uVar1; + } + iVar3 = err_to_errno(err); + if (iVar3 != 0) { + errno = iVar3; + } + } + return -1; +} + + + +ssize_t lwip_read(int s,void *mem,size_t len) + +{ + ssize_t sVar1; + + sVar1 = lwip_recvfrom(s,mem,len,0,(sockaddr *)0x0,(socklen_t *)0x0); + return sVar1; +} + + + +ssize_t lwip_recv(int s,void *mem,size_t len,int flags) + +{ + ssize_t sVar1; + + sVar1 = lwip_recvfrom(s,mem,len,flags,(sockaddr *)0x0,(socklen_t *)0x0); + return sVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +ssize_t lwip_sendto(int s,void *data,size_t size,int flags,sockaddr *to,socklen_t tolen) + +{ + err_t eVar1; + lwip_sock *plVar2; + ssize_t sVar3; + int iVar4; + void *pvVar5; + undefined3 extraout_var; + int iVar6; + pbuf *ppStack52; + netbuf buf; + + plVar2 = get_socket(s); + if (plVar2 == (lwip_sock *)0x0) { + return -1; + } + if ((plVar2->conn->type & 0xf0) == NETCONN_TCP) { + sVar3 = lwip_send(s,data,size,flags); + return sVar3; + } + if (0xffff < size) { + errno = 0x5a; + return -1; + } + if (to != (sockaddr *)0x0) { + if ((tolen != 0x10) || (to->sa_family != '\x02')) goto LAB_2303b61c; + tolen = (uint)to & 3; + } + if (tolen == 0) { + buf.p = (pbuf *)0x0; + ppStack52 = (pbuf *)0x0; + buf.addr.addr._2_1_ = '\0'; + if (to == (sockaddr *)0x0) { + buf.ptr = (pbuf *)0x0; + buf.addr.addr._0_2_ = 0; + } + else { + buf.ptr = *(pbuf **)(to->sa_data + 2); + buf.addr.addr._0_2_ = lwip_htons(*(u16_t *)to->sa_data); + } + pvVar5 = netbuf_alloc((netbuf *)&ppStack52,(u16_t)size); + iVar4 = -1; + if (pvVar5 != (void *)0x0) { + if ((plVar2->conn->type & 0xf0) == NETCONN_RAW) { + memcpy(ppStack52->payload,data,size); + } + else { + buf.port = lwip_chksum_copy(ppStack52->payload,data,(u16_t)size); + buf.addr.addr._2_1_ = '\x02'; + } + eVar1 = netconn_send(plVar2->conn,(netbuf *)&ppStack52); + iVar4 = CONCAT31(extraout_var,eVar1); + } + netbuf_free((netbuf *)&ppStack52); + iVar6 = err_to_errno((err_t)iVar4); + if (iVar6 != 0) { + errno = iVar6; + } + if (iVar4 != 0) { + return -1; + } + return size; + } +LAB_2303b61c: + iVar4 = err_to_errno(-0x10); + if (iVar4 != 0) { + errno = iVar4; + } + return -1; +} + + + +ssize_t lwip_send(int s,void *data,size_t size,int flags) + +{ + err_t err; + lwip_sock *plVar1; + ssize_t sVar2; + undefined3 extraout_var; + int iVar3; + byte bVar4; + size_t sStack20; + size_t written; + + plVar1 = get_socket(s); + if (plVar1 != (lwip_sock *)0x0) { + if ((plVar1->conn->type & 0xf0) != NETCONN_TCP) { + sVar2 = lwip_sendto(s,data,size,flags,(sockaddr *)0x0,0); + return sVar2; + } + bVar4 = 3; + if ((flags & 0x10U) == 0) { + bVar4 = 1; + } + sStack20 = 0; + err = netconn_write_partly(plVar1->conn,data,size,bVar4 | (byte)(flags >> 1) & 4,&sStack20); + iVar3 = err_to_errno(err); + if (iVar3 != 0) { + errno = iVar3; + } + if (CONCAT31(extraout_var,err) == 0) { + return sStack20; + } + } + return -1; +} + + + +int lwip_socket(int domain,int type,int protocol) + +{ + netconn_type t; + netconn *newconn; + int iVar1; + u8_t proto; + + if (type == 2) { + t = NETCONN_UDPLITE; + if (protocol != 0x88) { + t = NETCONN_UDP; + } + proto = '\0'; + } + else { + if (type == 3) { + proto = (u8_t)protocol; + t = NETCONN_RAW; + } + else { + if (type != 1) { + errno = 0x16; + return -1; + } + proto = '\0'; + t = NETCONN_TCP; + } + } + newconn = netconn_new_with_proto_and_callback(t,proto,event_callback); + if (newconn == (netconn *)0x0) { + errno = 0x69; + return -1; + } + iVar1 = alloc_socket(newconn,0); + if (iVar1 != -1) { + newconn->socket = iVar1; + return iVar1; + } + netconn_delete(newconn); + errno = 0x17; + return -1; +} + + + +ssize_t lwip_write(int s,void *data,size_t size) + +{ + ssize_t sVar1; + + sVar1 = lwip_send(s,data,size,0); + return sVar1; +} + + + +int lwip_select(int maxfdp1,_types_fd_set *readset,_types_fd_set *writeset,_types_fd_set *exceptset, + timeval *timeout) + +{ + uint uVar1; + err_t eVar2; + uint uVar3; + undefined3 extraout_var; + sys_prot_t sVar4; + u8_t uVar5; + u32_t timeout_00; + lwip_sock *plVar6; + uint uVar7; + lwip_sock *plVar8; + fd_mask local_7c; + _types_fd_set lreadset; + _types_fd_set lwriteset; + _types_fd_set lexceptset; + lwip_select_cb select_cb; + + if ((uint)maxfdp1 < 0x41) { + uVar3 = lwip_selscan(maxfdp1,readset,writeset,exceptset,(_types_fd_set *)&local_7c, + (_types_fd_set *)(lreadset.fds_bits + 1), + (_types_fd_set *)(lwriteset.fds_bits + 1)); + if ((int)uVar3 < 0) { + errno = 9; + } + else { + uVar7 = uVar3; + if ((uVar3 != 0) || + (((timeout != (timeval *)0x0 && + ((*(uint *)&timeout->tv_sec | *(uint *)((int)&timeout->tv_sec + 4)) == 0)) && + (uVar7 = timeout->tv_usec, uVar7 == 0)))) { +LAB_2303b9b6: + if (readset != (_types_fd_set *)0x0) { + readset->fds_bits[0] = local_7c; + readset->fds_bits[1] = lreadset.fds_bits[0]; + } + if (writeset != (_types_fd_set *)0x0) { + writeset->fds_bits[0] = lreadset.fds_bits[1]; + writeset->fds_bits[1] = lwriteset.fds_bits[0]; + } + if (exceptset == (_types_fd_set *)0x0) { + return uVar7; + } + exceptset->fds_bits[0] = lwriteset.fds_bits[1]; + exceptset->fds_bits[1] = lexceptset.fds_bits[0]; + return uVar7; + } + memset(lexceptset.fds_bits + 1,0,0x24); + select_cb.prev = (lwip_select_cb *)readset; + select_cb.readset = writeset; + select_cb.writeset = exceptset; + eVar2 = sys_sem_new((sys_sem_t *)&select_cb.sem_signalled,'\0'); + if (CONCAT31(extraout_var,eVar2) == 0) { + plVar6 = sockets; + plVar8 = sockets; + lwip_link_select_cb((lwip_select_cb *)(lexceptset.fds_bits + 1)); + uVar1 = 0; + while (uVar1 != maxfdp1) { + if ((((readset != (_types_fd_set *)0x0) && + ((1 << (uVar1 & 0x1f) & readset->fds_bits[uVar1 >> 5]) != 0)) || + ((writeset != (_types_fd_set *)0x0 && + ((1 << (uVar1 & 0x1f) & writeset->fds_bits[uVar1 >> 5]) != 0)))) || + ((exceptset != (_types_fd_set *)0x0 && + ((1 << (uVar1 & 0x1f) & exceptset->fds_bits[uVar1 >> 5]) != 0)))) { + sys_arch_protect(); + if ((int)uVar1 < 0x15) { + uVar5 = plVar8->select_waiting + '\x01'; + plVar8->select_waiting = uVar5; + if (uVar5 != '\0') { + sys_arch_unprotect(); + goto LAB_2303b9ec; + } + sockets[uVar1].select_waiting = -1; + sys_arch_unprotect(); + errno = 0x10; + } + else { + sys_arch_unprotect(); + errno = 9; + } + uVar7 = 0xffffffff; + timeout_00 = 0; + goto LAB_2303b986; + } +LAB_2303b9ec: + uVar1 = uVar1 + 1; + plVar8 = plVar8 + 1; + } + uVar7 = lwip_selscan(maxfdp1,readset,writeset,exceptset,(_types_fd_set *)&local_7c, + (_types_fd_set *)(lreadset.fds_bits + 1), + (_types_fd_set *)(lwriteset.fds_bits + 1)); + timeout_00 = 0; + if (uVar7 == 0) { + timeout_00 = 0; + if ((timeout != (timeval *)0x0) && + (timeout_00 = *(int *)&timeout->tv_sec * 1000 + (timeout->tv_usec + 500) / 1000, + (int)timeout_00 < 1)) { + timeout_00 = 1; + } + timeout_00 = sys_arch_sem_wait((sys_sem_t *)&select_cb.sem_signalled,timeout_00); + uVar1 = maxfdp1; + } +LAB_2303b986: + while (uVar3 != uVar1) { + if ((((readset != (_types_fd_set *)0x0) && + ((1 << (uVar3 & 0x1f) & readset->fds_bits[uVar3 >> 5]) != 0)) || + ((writeset != (_types_fd_set *)0x0 && + ((1 << (uVar3 & 0x1f) & writeset->fds_bits[uVar3 >> 5]) != 0)))) || + ((exceptset != (_types_fd_set *)0x0 && + ((1 << (uVar3 & 0x1f) & exceptset->fds_bits[uVar3 >> 5]) != 0)))) { + sVar4 = sys_arch_protect(); + if ((int)uVar3 < 0x15) { + if (plVar6->select_waiting != '\0') { + plVar6->select_waiting = plVar6->select_waiting + -1; + } + sys_arch_unprotect(sVar4); + } + else { + sys_arch_unprotect(sVar4); + uVar7 = 0xffffffff; + errno = 9; + } + } + uVar3 = uVar3 + 1; + plVar6 = plVar6 + 1; + } + lwip_unlink_select_cb((lwip_select_cb *)(lexceptset.fds_bits + 1)); + sys_sem_free((sys_sem_t *)&select_cb.sem_signalled); + if (-1 < (int)uVar7) { + if (timeout_00 != 0xffffffff) { + uVar7 = lwip_selscan(maxfdp1,readset,writeset,exceptset,(_types_fd_set *)&local_7c, + (_types_fd_set *)(lreadset.fds_bits + 1), + (_types_fd_set *)(lwriteset.fds_bits + 1)); + } + goto LAB_2303b9b6; + } + } + else { + errno = 0xc; + } + } + } + else { + errno = 0x16; + } + return -1; +} + + + +int lwip_shutdown(int s,int how) + +{ + err_t err; + lwip_sock *plVar1; + netconn *conn; + undefined3 extraout_var; + int iVar2; + u8_t shut_tx; + u8_t shut_rx; + + plVar1 = get_socket(s); + if (plVar1 != (lwip_sock *)0x0) { + conn = plVar1->conn; + if (conn == (netconn *)0x0) { + errno = 0x6b; + } + else { + if ((conn->type & 0xf0) == NETCONN_TCP) { + if (how == 0) { + shut_tx = '\0'; + shut_rx = '\x01'; + } + else { + shut_rx = '\x01'; + if (how == 1) { + shut_tx = '\x01'; + shut_rx = '\0'; + } + else { + shut_tx = '\x01'; + if (how != 2) { + errno = 0x16; + return -1; + } + } + } + err = netconn_shutdown(conn,shut_rx,shut_tx); + iVar2 = err_to_errno(err); + if (iVar2 != 0) { + errno = iVar2; + } + return -(uint)(CONCAT31(extraout_var,err) != 0); + } + errno = 0x5f; + } + } + return -1; +} + + + +int lwip_setsockopt(int s,int level,int optname,void *optval,socklen_t optlen) + +{ + err_t err; + lwip_sock *plVar1; + undefined3 extraout_var; + socklen_t sVar2; + int iStack44; + lwip_setgetsockopt_data data; + + plVar1 = get_socket(s); + sVar2 = errno; + if (plVar1 != (lwip_sock *)0x0) { + if (optval == (void *)0x0) { + errno = 0xe; + sVar2 = errno; + } + else { + data.optlen = 0; + data.err = (int)&plVar1->conn->op_completed; + iStack44 = s; + data.s = level; + data.level = optname; + data.optname = (int)optval; + data.optval = optlen; + err = tcpip_callback(lwip_setsockopt_callback,&iStack44); + if (CONCAT31(extraout_var,err) == 0) { + sys_arch_sem_wait((sys_sem_t *)data.err,0); + sVar2 = data.optlen; + if (data.optlen == 0) { + return 0; + } + } + else { + sVar2 = err_to_errno(err); + if (sVar2 == 0) { + return -1; + } + } + } + } + errno = sVar2; + return -1; +} + + + +int lwip_fcntl(int s,int cmd,int val) + +{ + ushort uVar1; + uint uVar2; + lwip_sock *plVar3; + byte bVar4; + int iVar5; + + plVar3 = get_socket(s); + if (plVar3 != (lwip_sock *)0x0) { + if (cmd == 3) { + uVar2 = 6; + bVar4 = plVar3->conn->flags; + if ((plVar3->conn->type & 0xf0) == NETCONN_TCP) { + sys_arch_protect(); + uVar2 = 0; + iVar5 = plVar3->conn->pcb; + if ((iVar5 != 0) && + (uVar1 = *(ushort *)(iVar5 + 0x1a), uVar2 = (uint)((uVar1 & 0x10) == 0) << 1, + (uVar1 & 0x20) == 0)) { + uVar2 = uVar2 | 4; + } + sys_arch_unprotect(); + } + return uVar2 | (int)(uint)bVar4 >> 1 & 1U; + } + if ((cmd == 4) && ((val & 0xfffffff8U) == 0)) { + bVar4 = plVar3->conn->flags; + if ((val & 1U) == 0) { + bVar4 = bVar4 & 0xfd; + } + else { + bVar4 = bVar4 | 2; + } + plVar3->conn->flags = bVar4; + return 0; + } + errno = 0x26; + } + return -1; +} + + + +void tcpip_thread(void *arg) + +{ + byte *mem; + undefined uVar1; + memp_t type; + u32_t timeout; + int iVar2; + undefined *puVar3; + byte *pbStack36; + tcpip_msg *msg; + + if (tcpip_init_done != (tcpip_init_done_fn)0x0) { + (*tcpip_init_done)(tcpip_init_done_arg); + } +switchD_2303bc70_caseD_5: + do { + while (timeout = sys_timeouts_sleeptime(), timeout != 0xffffffff) { + if ((timeout != 0) && + (timeout = sys_arch_mbox_fetch(&tcpip_mbox,&pbStack36,timeout), timeout != 0xffffffff)) + goto LAB_2303bc5e; + sys_check_timeouts(); + } + sys_arch_mbox_fetch(&tcpip_mbox,&pbStack36,0); +LAB_2303bc5e: + mem = pbStack36; + } while (pbStack36 == (byte *)0x0); + switch(*pbStack36) { + case 0: + case 4: + (**(code **)(pbStack36 + 4))(*(undefined4 *)(pbStack36 + 8),*(code **)(pbStack36 + 4)); + goto switchD_2303bc70_caseD_5; + case 1: + puVar3 = *(undefined **)(pbStack36 + 8); + uVar1 = (**(code **)(pbStack36 + 4))(puVar3,*(code **)(pbStack36 + 4)); + *puVar3 = uVar1; + sys_sem_signal((sys_mutex_t *)*(sys_mutex_t *)(mem + 0xc)); + goto switchD_2303bc70_caseD_5; + case 2: + iVar2 = (**(code **)(pbStack36 + 0xc)) + (*(undefined4 *)(pbStack36 + 4),*(undefined4 *)(pbStack36 + 8), + *(code **)(pbStack36 + 0xc)); + if (iVar2 != 0) { + pbuf_free(*(pbuf **)(mem + 4)); + } + type = MEMP_TCPIP_MSG_INPKT; + break; + case 3: + (**(code **)(pbStack36 + 4))(*(undefined4 *)(pbStack36 + 8),*(code **)(pbStack36 + 4)); + type = MEMP_TCPIP_MSG_API; + break; + default: + goto switchD_2303bc70_caseD_5; + } + memp_free(type,mem); + goto switchD_2303bc70_caseD_5; +} + + + +err_t tcpip_inpkt(pbuf *p,netif *inp,netif_input_fn *input_fn) + +{ + err_t eVar1; + undefined *msg; + undefined3 extraout_var; + + sys_mbox_valid(&tcpip_mbox); + msg = (undefined *)memp_malloc(MEMP_TCPIP_MSG_INPKT); + if (msg == (undefined *)0x0) { + printf("[LWIP] NO TCP MSG\r\n"); + } + else { + *(netif **)(msg + 8) = inp; + *msg = 2; + *(pbuf **)(msg + 4) = p; + *(netif_input_fn **)(msg + 0xc) = input_fn; + eVar1 = sys_mbox_trypost(&tcpip_mbox,msg); + if (CONCAT31(extraout_var,eVar1) == 0) { + return eVar1; + } + printf("[LWIP] NO MBOX\r\n"); + memp_free(MEMP_TCPIP_MSG_INPKT,msg); + } + return -1; +} + + + +err_t tcpip_input(pbuf *p,netif *inp) + +{ + err_t eVar1; + code *input_fn; + + if ((inp->flags & 0x18) == 0) { + input_fn = ip4_input; + } + else { + input_fn = ethernet_input; + } + eVar1 = tcpip_inpkt(p,inp,input_fn); + return eVar1; +} + + + +err_t tcpip_callback(tcpip_callback_fn function,void *ctx) + +{ + err_t eVar1; + undefined *data; + + sys_mbox_valid(&tcpip_mbox); + data = (undefined *)memp_malloc(MEMP_TCPIP_MSG_API); + if (data == (undefined *)0x0) { + eVar1 = -1; + } + else { + *data = 3; + *(void **)(data + 8) = ctx; + *(tcpip_callback_fn *)(data + 4) = function; + sys_mbox_post(&tcpip_mbox,data); + eVar1 = '\0'; + } + return eVar1; +} + + + +err_t tcpip_try_callback(tcpip_callback_fn function,void *ctx) + +{ + err_t eVar1; + undefined *msg; + undefined3 extraout_var; + + sys_mbox_valid(&tcpip_mbox); + msg = (undefined *)memp_malloc(MEMP_TCPIP_MSG_API); + if (msg != (undefined *)0x0) { + *(void **)(msg + 8) = ctx; + *msg = 3; + *(tcpip_callback_fn *)(msg + 4) = function; + eVar1 = sys_mbox_trypost(&tcpip_mbox,msg); + if (CONCAT31(extraout_var,eVar1) == 0) { + return eVar1; + } + memp_free(MEMP_TCPIP_MSG_API,msg); + } + return -1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t tcpip_send_msg_wait_sem(tcpip_callback_fn fn,void *apimsg,sys_sem_t *sem) + +{ + undefined auStack32 [4]; + tcpip_msg msg; + + sys_sem_valid(sem); + sys_mbox_valid(&tcpip_mbox); + auStack32[0] = 0; + msg._0_4_ = fn; + msg.msg._0_4_ = apimsg; + sys_mbox_post(&tcpip_mbox,auStack32); + sys_arch_sem_wait(sem,0); + return '\0'; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t tcpip_api_call(tcpip_api_call_fn *fn,tcpip_api_call_data *call) + +{ + sys_sem_t *sem; + err_t eVar1; + undefined3 extraout_var; + undefined local_30 [4]; + tcpip_msg msg; + + sem = &call->sem; + eVar1 = sys_sem_new(sem,'\0'); + if (CONCAT31(extraout_var,eVar1) == 0) { + sys_mbox_valid(&tcpip_mbox); + local_30[0] = 1; + msg._0_4_ = fn; + msg.msg._0_4_ = call; + msg.msg._4_4_ = sem; + sys_mbox_post(&tcpip_mbox,local_30); + sys_arch_sem_wait(msg.msg._4_4_,0); + sys_sem_free(sem); + eVar1 = call->err; + } + return eVar1; +} + + + +void tcpip_init(tcpip_init_done_fn initfunc,void *arg) + +{ + lwip_init(); + tcpip_init_done = initfunc; + tcpip_init_done_arg = arg; + sys_mbox_new(&tcpip_mbox,0x32); + sys_thread_new("TCP/IP",tcpip_thread,(void *)0x0,4000,0x1e); + return; +} + + + +altcp_pcb * altcp_alloc(void) + +{ + altcp_pcb *__s; + + __s = (altcp_pcb *)memp_malloc(MEMP_ALTCP_PCB); + if (__s != (altcp_pcb *)0x0) { + memset(__s,0,0x2c); + } + return __s; +} + + + +void altcp_free(altcp_pcb *conn) + +{ + altcp_dealloc_fn paVar1; + + if (conn == (altcp_pcb *)0x0) { + return; + } + if ((conn->fns != (altcp_functions *)0x0) && + (paVar1 = conn->fns->dealloc, paVar1 != (altcp_dealloc_fn)0x0)) { + (*paVar1)(conn); + } + memp_free(MEMP_ALTCP_PCB,conn); + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +altcp_pcb * altcp_new_ip_type(altcp_allocator_t *allocator,u8_t ip_type) + +{ + altcp_pcb *paVar1; + + if (allocator == (altcp_allocator_t *)0x0) { + paVar1 = altcp_tcp_new_ip_type(ip_type); + return paVar1; + } + if (allocator->alloc != (altcp_new_fn *)0x0) { + // WARNING: Could not recover jumptable at 0x2303bf52. Too many branches + // WARNING: Treating indirect jump as call + paVar1 = (*allocator->alloc)(allocator->arg); + return paVar1; + } + return (altcp_pcb *)0x0; +} + + + +altcp_pcb * altcp_new(altcp_allocator_t *allocator) + +{ + altcp_pcb *paVar1; + + paVar1 = altcp_new_ip_type(allocator,'\0'); + return paVar1; +} + + + +void altcp_arg(altcp_pcb *conn,void *arg) + +{ + if (conn != (altcp_pcb *)0x0) { + conn->arg = arg; + } + return; +} + + + +void altcp_recv(altcp_pcb *conn,altcp_recv_fn *recv) + +{ + if (conn != (altcp_pcb *)0x0) { + conn->recv = recv; + } + return; +} + + + +void altcp_sent(altcp_pcb *conn,altcp_sent_fn *sent) + +{ + if (conn != (altcp_pcb *)0x0) { + conn->sent = sent; + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void altcp_poll(altcp_pcb *conn,altcp_poll_fn *poll,u8_t interval) + +{ + altcp_set_poll_fn UNRECOVERED_JUMPTABLE; + undefined3 in_register_00002031; + + if (conn != (altcp_pcb *)0x0) { + conn->poll = poll; + conn->pollinterval = interval; + if ((conn->fns != (altcp_functions *)0x0) && + (UNRECOVERED_JUMPTABLE = conn->fns->set_poll, UNRECOVERED_JUMPTABLE != (altcp_set_poll_fn)0x0 + )) { + // WARNING: Could not recover jumptable at 0x2303bf86. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)((altcp_pcb *)CONCAT31(in_register_00002031,interval)); + return; + } + } + return; +} + + + +void altcp_err(altcp_pcb *conn,altcp_err_fn *err) + +{ + if (conn != (altcp_pcb *)0x0) { + conn->err = err; + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void altcp_recved(altcp_pcb *conn,u16_t len) + +{ + altcp_recved_fn *UNRECOVERED_JUMPTABLE; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->recved, UNRECOVERED_JUMPTABLE != (altcp_recved_fn *)0x0)) { + // WARNING: Could not recover jumptable at 0x2303bf9e. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(); + return; + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +err_t altcp_connect(altcp_pcb *conn,ip_addr_t *ipaddr,u16_t port,altcp_connected_fn connected) + +{ + altcp_connect_fn *UNRECOVERED_JUMPTABLE; + err_t eVar1; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->connect, UNRECOVERED_JUMPTABLE != (altcp_connect_fn *)0x0)) + { + // WARNING: Could not recover jumptable at 0x2303bfb0. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (*UNRECOVERED_JUMPTABLE)(); + return eVar1; + } + return -6; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void altcp_abort(altcp_pcb *conn) + +{ + altcp_abort_fn UNRECOVERED_JUMPTABLE; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->abort, UNRECOVERED_JUMPTABLE != (altcp_abort_fn)0x0)) { + // WARNING: Could not recover jumptable at 0x2303bfc4. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(); + return; + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +err_t altcp_close(altcp_pcb *conn) + +{ + altcp_close_fn UNRECOVERED_JUMPTABLE; + err_t eVar1; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->close, UNRECOVERED_JUMPTABLE != (altcp_close_fn)0x0)) { + // WARNING: Could not recover jumptable at 0x2303bfd6. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (*UNRECOVERED_JUMPTABLE)(); + return eVar1; + } + return -6; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +err_t altcp_write(altcp_pcb *conn,void *dataptr,u16_t len,u8_t apiflags) + +{ + altcp_write_fn *UNRECOVERED_JUMPTABLE; + err_t eVar1; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->write, UNRECOVERED_JUMPTABLE != (altcp_write_fn *)0x0)) { + // WARNING: Could not recover jumptable at 0x2303bfea. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (*UNRECOVERED_JUMPTABLE)(); + return eVar1; + } + return -6; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +err_t altcp_output(altcp_pcb *conn) + +{ + altcp_output_fn UNRECOVERED_JUMPTABLE; + err_t eVar1; + + if (((conn != (altcp_pcb *)0x0) && (conn->fns != (altcp_functions *)0x0)) && + (UNRECOVERED_JUMPTABLE = conn->fns->output, UNRECOVERED_JUMPTABLE != (altcp_output_fn)0x0)) { + // WARNING: Could not recover jumptable at 0x2303bffe. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (*UNRECOVERED_JUMPTABLE)(); + return eVar1; + } + return -6; +} + + + +err_t altcp_tcp_connected(void *arg,tcp_pcb *tpcb,err_t err) + +{ + err_t eVar1; + + if ((arg != (void *)0x0) && (*(code **)((int)arg + 0x14) != (code *)0x0)) { + // WARNING: Could not recover jumptable at 0x2303c012. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (**(code **)((int)arg + 0x14))(*(undefined4 *)((int)arg + 8),arg); + return eVar1; + } + return '\0'; +} + + + +err_t altcp_tcp_sent(void *arg,tcp_pcb *tpcb,u16_t len) + +{ + err_t eVar1; + + if ((arg != (void *)0x0) && (*(code **)((int)arg + 0x1c) != (code *)0x0)) { + // WARNING: Could not recover jumptable at 0x2303c026. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (**(code **)((int)arg + 0x1c))(*(undefined4 *)((int)arg + 8),arg); + return eVar1; + } + return '\0'; +} + + + +err_t altcp_tcp_poll(void *arg,tcp_pcb *tpcb) + +{ + err_t eVar1; + + if ((arg != (void *)0x0) && (*(code **)((int)arg + 0x20) != (code *)0x0)) { + // WARNING: Could not recover jumptable at 0x2303c03a. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (**(code **)((int)arg + 0x20))(*(undefined4 *)((int)arg + 8),arg); + return eVar1; + } + return '\0'; +} + + + +u16_t altcp_tcp_mss(altcp_pcb *conn) + +{ + if (conn != (altcp_pcb *)0x0) { + return *(u16_t *)((int)conn->state + 0x32); + } + return 0; +} + + + +u16_t altcp_tcp_sndbuf(altcp_pcb *conn) + +{ + if (conn != (altcp_pcb *)0x0) { + return *(u16_t *)((int)conn->state + 100); + } + return 0; +} + + + +u16_t altcp_tcp_sndqueuelen(altcp_pcb *conn) + +{ + if (conn != (altcp_pcb *)0x0) { + return *(u16_t *)((int)conn->state + 0x66); + } + return 0; +} + + + +void altcp_tcp_nagle_disable(altcp_pcb *conn) + +{ + void *pvVar1; + + if ((conn != (altcp_pcb *)0x0) && (pvVar1 = conn->state, pvVar1 != (void *)0x0)) { + *(ushort *)((int)pvVar1 + 0x1a) = *(ushort *)((int)pvVar1 + 0x1a) | 0x40; + } + return; +} + + + +void altcp_tcp_nagle_enable(altcp_pcb *conn) + +{ + void *pvVar1; + + if ((conn != (altcp_pcb *)0x0) && (pvVar1 = conn->state, pvVar1 != (void *)0x0)) { + *(ushort *)((int)pvVar1 + 0x1a) = *(ushort *)((int)pvVar1 + 0x1a) & 0xffbf; + } + return; +} + + + +int altcp_tcp_nagle_disabled(altcp_pcb *conn) + +{ + if ((conn != (altcp_pcb *)0x0) && (conn->state != (void *)0x0)) { + return (uint)(*(ushort *)((int)conn->state + 0x1a) >> 6) & 1; + } + return 0; +} + + + +void altcp_tcp_dealloc(altcp_pcb *conn) + +{ + return; +} + + + +ip_addr_t * altcp_tcp_get_ip(altcp_pcb *conn,int local) + +{ + if (((conn != (altcp_pcb *)0x0) && (conn = (altcp_pcb *)conn->state, conn != (altcp_pcb *)0x0)) && + (local == 0)) { + conn = (altcp_pcb *)&conn->inner_conn; + } + return (ip_addr_t *)conn; +} + + + +u16_t altcp_tcp_get_port(altcp_pcb *conn,int local) + +{ + void *pvVar1; + + if ((conn != (altcp_pcb *)0x0) && (pvVar1 = conn->state, pvVar1 != (void *)0x0)) { + if (local == 0) { + return *(u16_t *)((int)pvVar1 + 0x18); + } + return *(u16_t *)((int)pvVar1 + 0x16); + } + return 0; +} + + + +void altcp_tcp_setup_callbacks(altcp_pcb *conn,tcp_pcb *tpcb) + +{ + tcp_arg(tpcb,conn); + tcp_recv(tpcb,altcp_tcp_recv); + tcp_sent(tpcb,altcp_tcp_sent); + tcp_err(tpcb,altcp_tcp_err); + return; +} + + + +void altcp_tcp_err(void *arg,err_t err) + +{ + if (arg != (void *)0x0) { + *(undefined4 *)((int)arg + 0xc) = 0; + if (*(code **)((int)arg + 0x24) != (code *)0x0) { + (**(code **)((int)arg + 0x24))(*(undefined4 *)((int)arg + 8)); + } + altcp_free((altcp_pcb *)arg); + return; + } + return; +} + + + +err_t altcp_tcp_get_tcp_addrinfo(altcp_pcb *conn,int local,ip_addr_t *addr,u16_t *port) + +{ + err_t eVar1; + + if (conn != (altcp_pcb *)0x0) { + eVar1 = tcp_tcp_get_tcp_addrinfo((tcp_pcb *)conn->state,local,addr,port); + return eVar1; + } + return -6; +} + + + +void altcp_tcp_setprio(altcp_pcb *conn,u8_t prio) + +{ + if (conn != (altcp_pcb *)0x0) { + tcp_setprio((tcp_pcb *)conn->state,prio); + return; + } + return; +} + + + +err_t altcp_tcp_output(altcp_pcb *conn) + +{ + err_t eVar1; + + if (conn != (altcp_pcb *)0x0) { + eVar1 = tcp_output((tcp_pcb *)conn->state); + return eVar1; + } + return -6; +} + + + +err_t altcp_tcp_write(altcp_pcb *conn,void *dataptr,u16_t len,u8_t apiflags) + +{ + err_t eVar1; + + if (conn != (altcp_pcb *)0x0) { + eVar1 = tcp_write((tcp_pcb *)conn->state,dataptr,len,apiflags); + return eVar1; + } + return -6; +} + + + +err_t altcp_tcp_shutdown(altcp_pcb *conn,int shut_rx,int shut_tx) + +{ + err_t eVar1; + + if (conn != (altcp_pcb *)0x0) { + eVar1 = tcp_shutdown((tcp_pcb *)conn->state,shut_rx,shut_tx); + return eVar1; + } + return -6; +} + + + +err_t altcp_tcp_close(altcp_pcb *conn) + +{ + tcp_pcb *pcb; + err_t eVar1; + undefined3 extraout_var; + tcp_poll_fn *poll; + + eVar1 = -6; + if (conn != (altcp_pcb *)0x0) { + pcb = (tcp_pcb *)conn->state; + if (pcb != (tcp_pcb *)0x0) { + poll = pcb->poll; + tcp_arg(pcb,(void *)0x0); + tcp_recv(pcb,(tcp_recv_fn *)0x0); + tcp_sent(pcb,(tcp_sent_fn *)0x0); + tcp_err(pcb,(tcp_err_fn *)0x0); + tcp_poll(pcb,(tcp_poll_fn *)0x0,pcb->pollinterval); + eVar1 = tcp_close(pcb); + if (CONCAT31(extraout_var,eVar1) != 0) { + altcp_tcp_setup_callbacks(conn,pcb); + tcp_poll(pcb,poll,pcb->pollinterval); + return eVar1; + } + conn->state = (void *)0x0; + } + altcp_free(conn); + eVar1 = '\0'; + } + return eVar1; +} + + + +void altcp_tcp_abort(altcp_pcb *conn) + +{ + if ((conn != (altcp_pcb *)0x0) && ((tcp_pcb *)conn->state != (tcp_pcb *)0x0)) { + tcp_abort((tcp_pcb *)conn->state); + return; + } + return; +} + + + +altcp_pcb * altcp_tcp_listen(altcp_pcb *conn,u8_t backlog,err_t *err) + +{ + tcp_pcb *pcb; + + if ((conn == (altcp_pcb *)0x0) || + (pcb = tcp_listen_with_backlog_and_err((tcp_pcb *)conn->state,backlog,err), + pcb == (tcp_pcb *)0x0)) { + conn = (altcp_pcb *)0x0; + } + else { + *(tcp_pcb **)&conn->state = pcb; + tcp_accept(pcb,altcp_tcp_accept); + } + return conn; +} + + + +err_t altcp_tcp_connect(altcp_pcb *conn,ip_addr_t *ipaddr,u16_t port,altcp_connected_fn connected) + +{ + err_t eVar1; + + if (conn != (altcp_pcb *)0x0) { + conn->connected = connected; + eVar1 = tcp_connect((tcp_pcb *)conn->state,ipaddr,port,altcp_tcp_connected); + return eVar1; + } + return -6; +} + + + +err_t altcp_tcp_bind(altcp_pcb *conn,ip_addr_t *ipaddr,u16_t port) + +{ + err_t eVar1; + + if (conn != (altcp_pcb *)0x0) { + eVar1 = tcp_bind((tcp_pcb *)conn->state,ipaddr,port); + return eVar1; + } + return -6; +} + + + +void altcp_tcp_recved(altcp_pcb *conn,u16_t len) + +{ + if (conn != (altcp_pcb *)0x0) { + tcp_recved((tcp_pcb *)conn->state,len); + return; + } + return; +} + + + +err_t altcp_tcp_recv(void *arg,tcp_pcb *tpcb,pbuf *p,err_t err) + +{ + err_t eVar1; + + if ((arg != (void *)0x0) && (*(code **)((int)arg + 0x18) != (code *)0x0)) { + // WARNING: Could not recover jumptable at 0x2303c266. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (**(code **)((int)arg + 0x18))(*(undefined4 *)((int)arg + 8)); + return eVar1; + } + if (p != (pbuf *)0x0) { + pbuf_free(p); + return '\0'; + } + return '\0'; +} + + + +void altcp_tcp_set_poll(altcp_pcb *conn,u8_t interval) + +{ + if (conn != (altcp_pcb *)0x0) { + tcp_poll((tcp_pcb *)conn->state,altcp_tcp_poll,interval); + return; + } + return; +} + + + +err_t altcp_tcp_accept(void *arg,tcp_pcb *new_tpcb,err_t err) + +{ + err_t eVar1; + altcp_pcb *conn; + undefined3 in_register_00002031; + + if ((arg != (void *)0x0) && (*(int *)((int)arg + 0x10) != 0)) { + conn = altcp_alloc(); + if (conn != (altcp_pcb *)0x0) { + altcp_tcp_setup_callbacks(conn,new_tpcb); + *(tcp_pcb **)&conn->state = new_tpcb; + conn->fns = (altcp_functions *)0x230861a8; + // WARNING: Could not recover jumptable at 0x2303c2dc. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (**(code **)((int)arg + 0x10)) + (*(undefined4 *)((int)arg + 8),conn,CONCAT31(in_register_00002031,err)); + return eVar1; + } + return -1; + } + return -0x10; +} + + + +altcp_pcb * altcp_tcp_new_ip_type(u8_t ip_type) + +{ + altcp_pcb *conn; + tcp_pcb *pcb; + + pcb = tcp_new_ip_type(ip_type); + conn = (altcp_pcb *)0x0; + if (pcb != (tcp_pcb *)0x0) { + conn = altcp_alloc(); + if (conn == (altcp_pcb *)0x0) { + tcp_close(pcb); + } + else { + altcp_tcp_setup_callbacks(conn,pcb); + *(tcp_pcb **)&conn->state = pcb; + conn->fns = (altcp_functions *)0x230861a8; + } + } + return conn; +} + + + +u16_t lwip_htons(u16_t n) + +{ + undefined2 in_register_0000202a; + + return (u16_t)((ushort)(CONCAT22(in_register_0000202a,n) >> 8) | n << 8); +} + + + +u32_t lwip_htonl(u32_t n) + +{ + return n >> 8 & 0xff00 | n << 0x18 | n >> 0x18 | (n & 0xff00) << 8; +} + + + +int lwip_strnicmp(char *str1,char *str2,size_t len) + +{ + byte bVar1; + int iVar2; + + iVar2 = 0; + while( true ) { + bVar1 = str1[iVar2]; + if ((bVar1 != str2[iVar2]) && + ((0x19 < (byte)((bVar1 | 0x20) + 0x9f) || + ((byte)(bVar1 | 0x20) != (byte)(str2[iVar2] | 0x20U))))) break; + if ((len - 1 == iVar2) || (iVar2 = iVar2 + 1, bVar1 == 0)) { + return 0; + } + } + return 1; +} + + + +void dns_call_found(u8_t idx,ip_addr_t *addr) + +{ + undefined3 in_register_00002029; + int iVar1; + + iVar1 = CONCAT31(in_register_00002029,idx); + if (dns_requests[iVar1].found != (dns_found_callback *)0x0) { + (*dns_requests[iVar1].found)(dns_table[iVar1].name,addr,dns_requests[iVar1].arg); + } + dns_requests[iVar1].found = (dns_found_callback *)0x0; + return; +} + + + +// WARNING: Variable defined which should be unmapped: hdr + +err_t dns_send(u8_t idx) + +{ + u8_t *dataptr; + u8_t *puVar1; + err_t eVar2; + undefined3 in_register_00002029; + int iVar3; + size_t sVar4; + pbuf *buf; + uint uVar5; + uint uVar6; + uint uVar7; + undefined4 local_40; + dns_query qry; + dns_hdr hdr; + + iVar3 = CONCAT31(in_register_00002029,idx); + if (dns_servers[dns_table[iVar3].server_idx].addr == 0) { + dns_call_found(idx,(ip_addr_t *)0x0); + eVar2 = '\0'; + dns_table[iVar3].state = '\0'; + } + else { + sVar4 = strlen(dns_table[iVar3].name); + buf = pbuf_alloc(PBUF_TRANSPORT,(u16_t)((sVar4 + 0x12) * 0x10000 >> 0x10),PBUF_RAM); + eVar2 = -1; + if (buf != (pbuf *)0x0) { + memset(&qry,0,0xc); + qry.type = lwip_htons(dns_table[iVar3].txid); + qry.cls._0_1_ = 1; + puVar1 = &dns_table[iVar3].seqno; + pbuf_take(buf,&qry,0xc); + uVar6 = 0xc; + do { + dataptr = puVar1 + 1; + uVar5 = 0; + puVar1 = dataptr; + while ((*puVar1 != '.' && (*puVar1 != '\0'))) { + uVar5 = uVar5 + 1 & 0xff; + puVar1 = puVar1 + 1; + } + if (0xfffe < uVar6 + uVar5) { + pbuf_free(buf); + return -6; + } + pbuf_put_at(buf,(u16_t)uVar6,(u8_t)uVar5); + pbuf_take_at(buf,dataptr,(u16_t)((uint)((int)(puVar1 + -(int)dataptr) * 0x10000) >> 0x10), + (u16_t)((uVar6 + 1) * 0x10000 >> 0x10)); + uVar7 = uVar6 + uVar5 & 0xffff; + uVar5 = uVar7 + 1; + uVar6 = uVar5 & 0xffff; + } while (*puVar1 != '\0'); + pbuf_put_at(buf,(u16_t)(uVar5 * 0x10000 >> 0x10),'\0'); + local_40 = 0x1000100; + pbuf_take_at(buf,&local_40,4,(u16_t)((uVar7 + 2) * 0x10000 >> 0x10)); + eVar2 = udp_sendto(dns_pcbs,buf,dns_servers + dns_table[iVar3].server_idx,0x35); + pbuf_free(buf); + } + } + return eVar2; +} + + + +void dns_check_entry(u8_t i) + +{ + undefined3 in_register_00002029; + int iVar1; + u8_t uVar2; + u16_t uVar3; + uint uVar4; + uint uVar5; + u32_t uVar6; + dns_table_entry_conflict1 *pdVar7; + + iVar1 = CONCAT31(in_register_00002029,i); + uVar2 = dns_table[iVar1].state; + if (uVar2 != '\x02') { + if (uVar2 != '\x03') { + if (uVar2 != '\x01') { + return; + } + uVar4 = (uint)dns_txid; + do { + uVar5 = uVar4 + 1; + uVar4 = uVar5 & 0xffff; + pdVar7 = dns_table; + while ((pdVar7->state != '\x02' || ((uint)pdVar7->txid != uVar4))) { + pdVar7 = pdVar7 + 1; + if (pdVar7 == (dns_table_entry_conflict1 *)arp_table) { + uVar3 = (u16_t)(uVar5 * 0x10000 >> 0x10); + dns_txid = uVar3; + *(undefined2 *)&dns_table[iVar1].state = 2; + dns_table[iVar1].txid = uVar3; + *(undefined2 *)&dns_table[iVar1].tmr = 1; + goto LAB_2303c5fe; + } + } + } while( true ); + } + uVar6 = dns_table[iVar1].ttl; + if ((uVar6 != 0) && (uVar6 = uVar6 - 1, dns_table[iVar1].ttl = uVar6, uVar6 != 0)) { + return; + } +LAB_2303c65a: + dns_table[iVar1].state = '\0'; + return; + } + uVar2 = dns_table[iVar1].tmr + -1; + dns_table[iVar1].tmr = uVar2; + if (uVar2 != '\0') { + return; + } + uVar2 = dns_table[iVar1].retries + '\x01'; + dns_table[iVar1].retries = uVar2; + if (uVar2 == '\x04') { + if ((dns_table[iVar1].server_idx != '\0') || (dns_servers[1] == 0)) { + dns_call_found(i,(ip_addr_t *)0x0); + goto LAB_2303c65a; + } + dns_table[iVar1].server_idx = '\x01'; + *(undefined2 *)&dns_table[iVar1].tmr = 1; + } + else { + dns_table[iVar1].tmr = uVar2; + } +LAB_2303c5fe: + dns_send(i); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void dns_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port) + +{ + u8_t i; + uint uVar1; + u16_t uVar2; + u16_t uVar3; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined2 extraout_var_02; + uint uVar4; + int iVar5; + undefined2 extraout_var_03; + uint uVar6; + undefined2 extraout_var_04; + undefined2 extraout_var_05; + u32_t uVar7; + undefined2 extraout_var_06; + dns_table_entry_conflict1 *pdVar8; + byte *pbVar9; + int iVar10; + uint uVar11; + byte *pbVar12; + short sStack96; + short sStack94; + dns_query qry; + ip4_addr_t ip4addr; + dns_hdr hdr; + dns_answer ans; + + if (0xf < p->tot_len) { + uVar2 = pbuf_copy_partial(p,&ip4addr,0xc,0); + uVar1 = CONCAT22(extraout_var,uVar2); + if (uVar1 == 0xc) { + iVar10 = 0; + uVar2 = lwip_htons((u16_t)ip4addr.addr); + pdVar8 = dns_table; + do { + i = (u8_t)iVar10; + if ((pdVar8->state == '\x02') && ((uint)pdVar8->txid == CONCAT22(extraout_var_00,uVar2))) { + uVar2 = lwip_htons(hdr.id); + uVar3 = lwip_htons(hdr._2_2_); + uVar11 = CONCAT22(extraout_var_02,uVar3); + if ((ip4addr.addr._2_1_ < '\0') && + ((CONCAT22(extraout_var_01,uVar2) == 1 && + (addr->addr == dns_servers[dns_table[iVar10].server_idx].addr)))) { + pbVar12 = (byte *)dns_table[iVar10].name; + goto LAB_2303c752; + } + break; + } + iVar10 = iVar10 + 1; + pdVar8 = pdVar8 + 1; + } while (iVar10 != 4); + } + } + goto ignore_packet; + while( true ) { + pbVar9 = pbVar12 + uVar4; + while( true ) { + uVar1 = uVar1 + 1 & 0xffff; + if (pbVar12 == pbVar9) break; + uVar4 = pbuf_try_get_at(p,(u16_t)uVar1); + if ((int)uVar4 < 0) goto ignore_packet; + uVar6 = (uint)*pbVar12; + if ((_ctype_[uVar6 + 1] & 3) == 1) { + uVar6 = uVar6 + 0x20; + } + uVar4 = uVar4 & 0xff; + if ((_ctype_[uVar4 + 1] & 3) == 1) { + uVar4 = uVar4 + 0x20; + } + if ((uVar6 != uVar4) || (uVar1 == 0xffff)) goto ignore_packet; + pbVar12 = pbVar12 + 1; + } + pbVar12 = pbVar12 + 1; + iVar5 = pbuf_try_get_at(p,(u16_t)uVar1); + if (iVar5 < 0) goto ignore_packet; + if (iVar5 == 0) break; +LAB_2303c752: + uVar4 = pbuf_try_get_at(p,(u16_t)uVar1); + if ((((int)uVar4 < 0) || (uVar1 == 0xffff)) || ((uVar4 & 0xc0) == 0xc0)) goto ignore_packet; + } + if (uVar1 != 0xffff) { + uVar4 = uVar1 + 1 & 0xffff; + if (((uVar4 != 0xffff) && + (uVar2 = pbuf_copy_partial(p,&sStack96,4,(u16_t)((uVar1 + 1) * 0x10000 >> 0x10)), + CONCAT22(extraout_var_03,uVar2) == 4)) && + ((sStack94 == 0x100 && ((sStack96 == 0x100 && (uVar4 < 0xfffc)))))) { + if ((ip4addr.addr._3_1_ & 0xf) == 0) { + uVar1 = uVar1 + 5; + while ((uVar1 = uVar1 & 0xffff, uVar11 != 0 && (uVar1 < p->tot_len))) { + do { + uVar4 = uVar1 + 1 & 0xffff; + uVar6 = pbuf_try_get_at(p,(u16_t)uVar1); + if (((int)uVar6 < 0) || (uVar4 == 0)) goto ignore_packet; + if ((uVar6 & 0xc0) == 0xc0) break; + uVar6 = uVar6 + uVar4; + if ((int)(uint)p->tot_len <= (int)uVar6) goto ignore_packet; + uVar1 = uVar6 & 0xffff; + iVar5 = pbuf_try_get_at(p,(u16_t)(uVar6 * 0x10000 >> 0x10)); + if (iVar5 < 0) goto ignore_packet; + uVar4 = uVar1; + } while (iVar5 != 0); + if (uVar4 == 0xffff) goto ignore_packet; + uVar1 = uVar4 + 1 & 0xffff; + if (((uVar1 == 0xffff) || + (uVar2 = pbuf_copy_partial(p,&hdr.numauthrr,10,(u16_t)((uVar4 + 1) * 0x10000 >> 0x10)) + , CONCAT22(extraout_var_04,uVar2) != 10)) || (0xfff5 < uVar1)) goto ignore_packet; + uVar1 = uVar4 + 0xb & 0xffff; + if (((hdr.numextrarr == 0x100) && (hdr.numauthrr == 0x100)) && ((u16_t)ans.ttl == 0x400)) + { + uVar2 = pbuf_copy_partial(p,&qry,4,(u16_t)((uVar4 + 0xb) * 0x10000 >> 0x10)); + if (CONCAT22(extraout_var_05,uVar2) == 4) { + *(dns_query *)&dns_table[iVar10].ipaddr = qry; + pbuf_free(p); + uVar7 = lwip_htonl(ans._0_4_); + dns_table[iVar10].state = '\x03'; + if (uVar7 < 0x93a81) { + dns_table[iVar10].ttl = uVar7; + } + else { + dns_table[iVar10].ttl = 0x93a80; + } + dns_call_found(i,&dns_table[iVar10].ipaddr); + if (dns_table[iVar10].ttl != 0) { + return; + } + if (dns_table[iVar10].state != '\x03') { + return; + } + dns_table[iVar10].state = '\0'; + return; + } + goto ignore_packet; + } + uVar2 = lwip_htons((u16_t)ans.ttl); + if (0xffff < (int)(CONCAT22(extraout_var_06,uVar2) + uVar1)) goto ignore_packet; + uVar2 = lwip_htons((u16_t)ans.ttl); + uVar1 = uVar2 + uVar1; + uVar11 = uVar11 - 1 & 0xffff; + } + } + else { + if ((dns_table[iVar10].server_idx == '\0') && (dns_servers[1] != 0)) { + *(undefined2 *)&dns_table[iVar10].tmr = 0x301; + dns_check_entry(i); + goto ignore_packet; + } + } + pbuf_free(p); + dns_call_found(i,(ip_addr_t *)0x0); + dns_table[iVar10].state = '\0'; + return; + } + } +ignore_packet: + pbuf_free(p); + return; +} + + + +void dns_init(void) + +{ + if (dns_pcbs == (udp_pcb *)0x0) { + dns_pcbs = udp_new_ip_type(); + udp_bind(dns_pcbs,&ip_addr_any,0); + udp_recv(dns_pcbs,dns_recv,(void *)0x0); + return; + } + return; +} + + + +void dns_setserver(u8_t numdns,ip_addr_t *dnsserver) + +{ + undefined3 in_register_00002029; + u32_t uVar1; + + if (CONCAT31(in_register_00002029,numdns) < 2) { + if (dnsserver == (ip_addr_t *)0x0) { + uVar1 = 0; + } + else { + uVar1 = dnsserver->addr; + } + dns_servers[CONCAT31(in_register_00002029,numdns)].addr = uVar1; + } + return; +} + + + +ip_addr_t * dns_getserver(u8_t numdns) + +{ + undefined3 in_register_00002029; + + if (CONCAT31(in_register_00002029,numdns) < 2) { + return dns_servers + CONCAT31(in_register_00002029,numdns); + } + return &ip_addr_any; +} + + + +void dns_tmr(void) + +{ + dns_check_entry('\0'); + dns_check_entry('\x01'); + dns_check_entry('\x02'); + dns_check_entry('\x03'); + return; +} + + + +err_t dns_gethostbyname_addrtype + (char *hostname,ip_addr_t *addr,dns_found_callback *found,void *callback_arg, + u8_t dns_addrtype) + +{ + u8_t uVar1; + uint uVar2; + size_t __n; + int iVar3; + int iVar4; + uint uVar5; + byte bVar6; + err_t eVar7; + byte bVar8; + uint uVar9; + dns_table_entry_conflict1 *pdVar10; + dns_table_entry_conflict1 *pdVar11; + + if (addr == (ip_addr_t *)0x0) { + return -0x10; + } + if ((((hostname == (char *)0x0) || (*hostname == '\0')) || (dns_pcbs == (udp_pcb *)0x0)) || + (__n = strlen(hostname), 0xff < __n)) { + eVar7 = -0x10; + } + else { + iVar3 = ip4addr_aton(hostname,(ip4_addr_t *)addr); + eVar7 = '\0'; + if (iVar3 == 0) { + pdVar10 = dns_table; + pdVar11 = dns_table; + iVar3 = 0; + do { + if ((pdVar11->state == '\x03') && + (iVar4 = lwip_strnicmp(hostname,pdVar11->name,0x100), iVar4 == 0)) { + addr->addr = dns_table[iVar3].ipaddr.addr; + return '\0'; + } + uVar1 = dns_seqno; + iVar3 = iVar3 + 1; + pdVar11 = pdVar11 + 1; + } while (iVar3 != 4); + eVar7 = -6; + if (dns_servers[0] != 0) { + uVar9 = 0; + uVar2 = 4; + bVar6 = 0; + do { + uVar5 = uVar9 & 0xff; + if (pdVar10->state == '\0') goto LAB_2303cba6; + if ((pdVar10->state == '\x03') && (bVar8 = dns_seqno - pdVar10->seqno, bVar6 < bVar8)) { + uVar2 = uVar5; + bVar6 = bVar8; + } + uVar9 = uVar9 + 1; + pdVar10 = pdVar10 + 1; + } while (uVar9 != 4); + eVar7 = -1; + if ((uVar2 != 4) && + (eVar7 = -1, uVar5 = uVar2, uVar9 = uVar2, dns_table[uVar2].state == '\x03')) { +LAB_2303cba6: + iVar3 = uVar9 * 0x110; + (&dns_table[0].state)[iVar3] = '\x01'; + (&dns_table[0].seqno)[iVar3] = uVar1; + dns_requests[uVar5].found = found; + dns_requests[uVar5].arg = callback_arg; + memcpy(dns_table[0].name + iVar3,hostname,__n); + dns_table[0].name[iVar3 + __n] = '\0'; + dns_seqno = dns_seqno + '\x01'; + dns_check_entry((u8_t)uVar5); + eVar7 = -5; + } + } + } + } + return eVar7; +} + + + +err_t dns_gethostbyname(char *hostname,ip_addr_t *addr,dns_found_callback *found,void *callback_arg) + +{ + err_t eVar1; + + eVar1 = dns_gethostbyname_addrtype(hostname,addr,found,callback_arg,'\0'); + return eVar1; +} + + + +u16_t lwip_standard_chksum(void *dataptr,int len) + +{ + byte bVar1; + ushort uVar2; + uint uVar3; + uint uVar4; + uint uVar5; + int iVar6; + u16_t t; + ushort uStack2; + + uStack2 = 0; + uVar3 = (uint)dataptr & 1; + if ((uVar3 != 0) && (0 < len)) { + bVar1 = *(byte *)dataptr; + len = len + -1; + dataptr = (void *)((int)dataptr + 1); + uStack2 = (ushort)bVar1 << 8; + } + uVar5 = (uint)dataptr & 3; + if ((uVar5 != 0) && (uVar5 = 0, 1 < len)) { + uVar5 = (uint)*(ushort *)dataptr; + len = len + -2; + dataptr = (void *)((int)dataptr + 2); + } + while (7 < len) { + uVar4 = *(int *)dataptr + uVar5; + if (uVar4 < uVar5) { + uVar4 = uVar4 + 1; + } + uVar5 = ((int *)dataptr)[1] + uVar4; + if (uVar5 < uVar4) { + uVar5 = uVar5 + 1; + } + len = len + -8; + dataptr = (int *)dataptr + 2; + } + iVar6 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + while (1 < len) { + len = len + -2; + iVar6 = iVar6 + (uint)*(ushort *)dataptr; + dataptr = (int *)((int)dataptr + 2); + } + if (len == 1) { + uStack2 = uStack2 | *(byte *)dataptr; + } + uVar5 = ((uint)uStack2 + iVar6 >> 0x10) + ((uint)uStack2 + iVar6 & 0xffff); + iVar6 = (uVar5 >> 0x10) + (uVar5 & 0xffff); + uVar2 = (ushort)iVar6; + if (uVar3 != 0) { + uVar2 = (ushort)((uint)iVar6 >> 8) & 0xff | uVar2 * 0x100; + } + return (u16_t)uVar2; +} + + + +u16_t inet_chksum_pseudo(pbuf *p,u8_t proto,u16_t proto_len,ip4_addr_t *src,ip4_addr_t *dest) + +{ + bool bVar1; + int iVar2; + u16_t uVar3; + u16_t uVar4; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined3 in_register_0000202d; + uint uVar5; + + uVar5 = (src->addr >> 0x10) + (dest->addr & 0xffff) + (dest->addr >> 0x10) + (src->addr & 0xffff); + uVar5 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + uVar5 = (uVar5 >> 0x10) + (uVar5 & 0xffff); + bVar1 = false; + while (p != (pbuf *)0x0) { + uVar3 = lwip_standard_chksum(p->payload,(uint)p->len); + uVar5 = uVar5 + CONCAT22(extraout_var_01,uVar3); + uVar5 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + if ((p->len & 1) != 0) { + bVar1 = (bool)(bVar1 ^ 1); + uVar5 = uVar5 >> 8 & 0xff | uVar5 * 0x100 & 0xffff; + } + p = p->next; + } + if (bVar1) { + uVar5 = uVar5 >> 8 & 0xff | (uVar5 & 0xff) << 8; + } + uVar3 = lwip_htons((u16_t)CONCAT31(in_register_0000202d,proto)); + uVar4 = lwip_htons(proto_len); + uVar5 = uVar5 + CONCAT22(extraout_var_00,uVar4) + CONCAT22(extraout_var,uVar3); + iVar2 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + return (u16_t)~((short)iVar2 + (short)((uint)iVar2 >> 0x10)); +} + + + +u16_t ip_chksum_pseudo(pbuf *p,u8_t proto,u16_t proto_len,ip4_addr_t *src,ip4_addr_t *dest) + +{ + bool bVar1; + int iVar2; + u16_t uVar3; + u16_t uVar4; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined3 in_register_0000202d; + uint uVar5; + + uVar5 = (src->addr >> 0x10) + (dest->addr & 0xffff) + (dest->addr >> 0x10) + (src->addr & 0xffff); + uVar5 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + uVar5 = (uVar5 >> 0x10) + (uVar5 & 0xffff); + bVar1 = false; + while (p != (pbuf *)0x0) { + uVar3 = lwip_standard_chksum(p->payload,(uint)p->len); + uVar5 = uVar5 + CONCAT22(extraout_var_01,uVar3); + uVar5 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + if ((p->len & 1) != 0) { + bVar1 = (bool)(bVar1 ^ 1); + uVar5 = uVar5 >> 8 & 0xff | uVar5 * 0x100 & 0xffff; + } + p = p->next; + } + if (bVar1) { + uVar5 = uVar5 >> 8 & 0xff | (uVar5 & 0xff) << 8; + } + uVar3 = lwip_htons((u16_t)CONCAT31(in_register_0000202d,proto)); + uVar4 = lwip_htons(proto_len); + uVar5 = uVar5 + CONCAT22(extraout_var_00,uVar4) + CONCAT22(extraout_var,uVar3); + iVar2 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + return (u16_t)~((short)iVar2 + (short)((uint)iVar2 >> 0x10)); +} + + + +u16_t inet_chksum_pseudo_partial + (pbuf *p,u8_t proto,u16_t proto_len,u16_t chksum_len,ip4_addr_t *src, + ip4_addr_t *dest) + +{ + bool bVar1; + int iVar2; + u16_t uVar3; + u16_t uVar4; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined3 in_register_0000202d; + undefined2 in_register_00002036; + uint uVar5; + uint uVar6; + uint uVar7; + + uVar5 = CONCAT22(in_register_00002036,chksum_len); + uVar6 = (src->addr >> 0x10) + (dest->addr & 0xffff) + (dest->addr >> 0x10) + (src->addr & 0xffff); + uVar6 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + uVar6 = (uVar6 >> 0x10) + (uVar6 & 0xffff); + bVar1 = false; + while ((p != (pbuf *)0x0 && (uVar5 != 0))) { + uVar7 = (uint)p->len; + if (uVar5 < (uint)p->len) { + uVar7 = uVar5; + } + uVar3 = lwip_standard_chksum(p->payload,uVar7 & 0xffff); + uVar6 = uVar6 + CONCAT22(extraout_var_01,uVar3); + uVar6 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + uVar5 = uVar5 - (uVar7 & 0xffff) & 0xffff; + if ((p->len & 1) != 0) { + bVar1 = (bool)(bVar1 ^ 1); + uVar6 = uVar6 >> 8 & 0xff | uVar6 * 0x100 & 0xffff; + } + p = p->next; + } + if (bVar1) { + uVar6 = uVar6 >> 8 & 0xff | (uVar6 & 0xff) << 8; + } + uVar3 = lwip_htons((u16_t)CONCAT31(in_register_0000202d,proto)); + uVar4 = lwip_htons(proto_len); + uVar6 = uVar6 + CONCAT22(extraout_var_00,uVar4) + CONCAT22(extraout_var,uVar3); + iVar2 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + return (u16_t)~((short)iVar2 + (short)((uint)iVar2 >> 0x10)); +} + + + +u16_t ip_chksum_pseudo_partial + (pbuf *p,u8_t proto,u16_t proto_len,u16_t chksum_len,ip4_addr_t *src, + ip4_addr_t *dest) + +{ + bool bVar1; + int iVar2; + u16_t uVar3; + u16_t uVar4; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined3 in_register_0000202d; + uint uVar5; + undefined2 in_register_00002036; + uint uVar6; + uint uVar7; + + uVar5 = CONCAT22(in_register_00002036,chksum_len); + uVar6 = (src->addr >> 0x10) + (dest->addr & 0xffff) + (dest->addr >> 0x10) + (src->addr & 0xffff); + uVar6 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + uVar6 = (uVar6 >> 0x10) + (uVar6 & 0xffff); + bVar1 = false; + while ((p != (pbuf *)0x0 && (uVar5 != 0))) { + uVar7 = (uint)p->len; + if (uVar5 < (uint)p->len) { + uVar7 = uVar5; + } + uVar3 = lwip_standard_chksum(p->payload,uVar7 & 0xffff); + uVar6 = uVar6 + CONCAT22(extraout_var_01,uVar3); + uVar6 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + uVar5 = uVar5 - (uVar7 & 0xffff) & 0xffff; + if ((p->len & 1) != 0) { + bVar1 = (bool)(bVar1 ^ 1); + uVar6 = uVar6 >> 8 & 0xff | uVar6 * 0x100 & 0xffff; + } + p = p->next; + } + if (bVar1) { + uVar6 = uVar6 >> 8 & 0xff | (uVar6 & 0xff) << 8; + } + uVar3 = lwip_htons((u16_t)CONCAT31(in_register_0000202d,proto)); + uVar4 = lwip_htons(proto_len); + uVar6 = uVar6 + CONCAT22(extraout_var_00,uVar4) + CONCAT22(extraout_var,uVar3); + iVar2 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + return (u16_t)~((short)iVar2 + (short)((uint)iVar2 >> 0x10)); +} + + + +u16_t inet_chksum(void *dataptr,u16_t len) + +{ + u16_t uVar1; + undefined2 in_register_0000202e; + + uVar1 = lwip_standard_chksum(dataptr,CONCAT22(in_register_0000202e,len)); + return ~uVar1; +} + + + +u16_t inet_chksum_pbuf(pbuf *p) + +{ + bool bVar1; + ushort uVar2; + uint uVar3; + u16_t uVar4; + undefined2 extraout_var; + + bVar1 = false; + uVar3 = 0; + while (uVar2 = (ushort)uVar3, p != (pbuf *)0x0) { + uVar4 = lwip_standard_chksum(p->payload,(uint)p->len); + uVar3 = uVar3 + CONCAT22(extraout_var,uVar4); + uVar3 = (uVar3 & 0xffff) + (uVar3 >> 0x10); + if ((p->len & 1) != 0) { + bVar1 = (bool)(bVar1 ^ 1); + uVar3 = uVar3 >> 8 & 0xff | uVar3 * 0x100 & 0xffff; + } + p = p->next; + } + if (bVar1) { + uVar2 = (ushort)(uVar3 >> 8) & 0xff | (ushort)((uVar3 & 0xff) << 8); + } + return (u16_t)~uVar2; +} + + + +u16_t lwip_chksum_copy(void *dst,void *src,u16_t len) + +{ + u16_t uVar1; + undefined2 in_register_00002032; + + memcpy(dst,src,CONCAT22(in_register_00002032,len)); + uVar1 = lwip_standard_chksum(dst,CONCAT22(in_register_00002032,len)); + return uVar1; +} + + + +void lwip_init(void) + +{ + stats_init(); + sys_init(); + mem_init(); + memp_init(); + netif_init(); + udp_init(); + tcp_init(); + igmp_init(); + dns_init(); + sys_timeouts_init(); + return; +} + + + +void dhcp_set_state(dhcp *dhcp,u8_t new_state) + +{ + undefined3 in_register_0000202d; + + if ((uint)dhcp->state != CONCAT31(in_register_0000202d,new_state)) { + dhcp->state = new_state; + dhcp->tries = '\0'; + dhcp->request_timeout = 0; + } + return; +} + + + +u16_t dhcp_option_short(u16_t options_out_len,u8_t *options,u16_t value) + +{ + undefined2 in_register_0000202a; + int iVar1; + + iVar1 = CONCAT22(in_register_0000202a,options_out_len); + options[iVar1] = (u8_t)(value >> 8); + options[iVar1 + 1U & 0xffff] = (u8_t)value; + return (u16_t)((uint)((iVar1 + 2) * 0x10000) >> 0x10); +} + + + +u16_t dhcp_option_long(u16_t options_out_len,u8_t *options,u32_t value) + +{ + undefined2 in_register_0000202a; + int iVar1; + + iVar1 = CONCAT22(in_register_0000202a,options_out_len); + options[iVar1] = (u8_t)(value >> 0x18); + options[iVar1 + 1U & 0xffff] = (u8_t)(value >> 0x10); + options[iVar1 + 2U & 0xffff] = (u8_t)(value >> 8); + options[iVar1 + 3U & 0xffff] = (u8_t)value; + return (u16_t)((uint)((iVar1 + 4) * 0x10000) >> 0x10); +} + + + +pbuf * dhcp_create_msg(netif *netif,dhcp *dhcp,u8_t message_type,u16_t *options_out_len) + +{ + u8_t uVar1; + u32_t xid; + undefined *__s; + u32_t uVar2; + undefined3 in_register_00002031; + int iVar3; + u8_t *puVar4; + u8_t *puVar5; + pbuf *ppVar6; + + iVar3 = CONCAT31(in_register_00002031,message_type); + if (((netif == (netif *)0x0) || (dhcp == (dhcp *)0x0)) || + (ppVar6 = pbuf_alloc(PBUF_TRANSPORT,0x134,PBUF_RAM), ppVar6 == (pbuf *)0x0)) { + ppVar6 = (pbuf *)0x0; + } + else { + if ((iVar3 != 3) || (dhcp->state == '\x03')) { + if (dhcp->tries == '\0') { + xid = bl_rand(); + } + dhcp->xid = xid; + } + __s = (undefined *)ppVar6->payload; + memset(__s,0,0x134); + *__s = 1; + __s[1] = 1; + __s[2] = netif->hwaddr_len; + uVar2 = lwip_htonl(dhcp->xid); + __s[4] = (char)uVar2; + __s[5] = (char)(uVar2 >> 8); + __s[6] = (char)(uVar2 >> 0x10); + __s[7] = (char)(uVar2 >> 0x18); + if (((iVar3 == 4) || ((iVar3 - 7U & 0xff) < 2)) || + ((iVar3 == 3 && ((byte)(dhcp->state - 4) < 2)))) { + uVar2 = (netif->ip_addr).addr; + __s[0xc] = (char)uVar2; + __s[0xd] = (char)(uVar2 >> 8); + __s[0xe] = (char)(uVar2 >> 0x10); + __s[0xf] = (char)(uVar2 >> 0x18); + } + puVar5 = netif->hwaddr; + puVar4 = __s + 0x1c; + do { + uVar1 = *puVar5; + puVar5 = puVar5 + 1; + *puVar4 = uVar1; + puVar4 = puVar4 + 1; + } while (puVar5 != &netif->hwaddr_len); + __s[0xec] = 99; + __s[0xef] = 99; + __s[0xed] = 0x82; + __s[0xf0] = 0x35; + __s[0xf1] = 1; + __s[0xee] = 0x53; + __s[0xf2] = message_type; + *options_out_len = 3; + } + return ppVar6; +} + + + +void dhcp_option_trailer(u16_t options_out_len,u8_t *options,pbuf *p_out) + +{ + undefined2 in_register_0000202a; + uint uVar1; + + uVar1 = CONCAT22(in_register_0000202a,options_out_len) + 1U & 0xffff; + options[CONCAT22(in_register_0000202a,options_out_len)] = -1; + options = options + uVar1; + while (uVar1 < 0x44) { + *options = '\0'; + uVar1 = uVar1 + 1 & 0xffff; + options = options + 1; + } + pbuf_realloc(p_out,(u16_t)((uVar1 + 0xf0) * 0x10000 >> 0x10)); + return; +} + + + +err_t dhcp_discover(netif *netif) + +{ + u8_t *options; + dhcp *dhcp; + pbuf *p_out; + undefined2 extraout_var; + uint uVar1; + int iVar2; + u16_t auStack34 [2]; + u16_t options_out_len; + + dhcp = (dhcp *)netif->client_data[0]; + (dhcp->offered_ip_addr).addr = 0; + dhcp_set_state(dhcp,'\x06'); + p_out = dhcp_create_msg(netif,dhcp,'\x01',auStack34); + if (p_out != (pbuf *)0x0) { + uVar1 = (uint)auStack34[0]; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar1] = '9'; + options[uVar1 + 1 & 0xffff] = '\x02'; + auStack34[0] = (u16_t)((uVar1 + 2) * 0x10000 >> 0x10); + auStack34[0] = dhcp_option_short(auStack34[0],options,netif->mtu); + options[CONCAT22(extraout_var,auStack34[0])] = '7'; + options[CONCAT22(extraout_var,auStack34[0]) + 1U & 0xffff] = '\x04'; + auStack34[0] = auStack34[0] + 2; + iVar2 = 0; + do { + options[(uint)auStack34[0]] = "\x01\x03\x1c\x06"[iVar2]; + auStack34[0] = (u16_t)(((uint)auStack34[0] + 1) * 0x10000 >> 0x10); + iVar2 = iVar2 + 1; + } while (iVar2 != 4); + dhcp_option_trailer(auStack34[0],options,p_out); + udp_sendto_if_src(dhcp_pcb,p_out,&ip_addr_broadcast,0x43,netif,&ip_addr_any); + pbuf_free(p_out); + } + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + if (dhcp->tries < 6) { + uVar1 = (uint)((1 << ((uint)dhcp->tries & 0x1f)) * 0x3e80000) >> 0x10; + } + else { + uVar1 = 60000; + } + dhcp->request_timeout = (u16_t)((int)(uVar1 + 499) / 500); + return '\0'; +} + + + +void dhcp_check(netif *netif) + +{ + dhcp *dhcp; + + dhcp = (dhcp *)netif->client_data[0]; + dhcp_set_state(dhcp,'\b'); + etharp_query(netif,&dhcp->offered_ip_addr,(pbuf *)0x0); + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + dhcp->request_timeout = 1; + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void dhcp_bind(netif *netif) + +{ + byte bVar1; + dhcp *dhcp; + u16_t uVar2; + uint uVar3; + int iVar4; + ip4_addr_t iStack24; + ip4_addr_t sn_mask; + ip4_addr_t gw_addr; + + if (netif == (netif *)0x0) { + return; + } + dhcp = (dhcp *)netif->client_data[0]; + if (dhcp == (dhcp *)0x0) { + return; + } + dhcp->lease_used = 0; + if (dhcp->offered_t0_lease != 0xffffffff) { + uVar3 = dhcp->offered_t0_lease + 0x1e; + if (uVar3 < 0x3c0000) { + uVar3 = uVar3 / 0x3c; + uVar2 = (u16_t)uVar3; + if (uVar3 == 0) { + dhcp->t0_timeout = 1; + goto LAB_2303d354; + } + } + else { + uVar2 = 0xffff; + } + dhcp->t0_timeout = uVar2; + } +LAB_2303d354: + if (dhcp->offered_t1_renew != 0xffffffff) { + uVar3 = dhcp->offered_t1_renew + 0x1e; + if (uVar3 < 0x3c0000) { + uVar3 = uVar3 / 0x3c; + uVar2 = (u16_t)uVar3; + if (uVar3 != 0) goto LAB_2303d376; + dhcp->t1_timeout = 1; + } + else { + uVar2 = 0xffff; +LAB_2303d376: + dhcp->t1_timeout = uVar2; + } + dhcp->t1_renew_time = dhcp->t1_timeout; + } + if (dhcp->offered_t2_rebind == 0xffffffff) goto LAB_2303d3b0; + uVar3 = dhcp->offered_t2_rebind + 0x1e; + if (uVar3 < 0x3c0000) { + uVar3 = uVar3 / 0x3c; + uVar2 = (u16_t)uVar3; + if (uVar3 != 0) goto LAB_2303d3a4; + dhcp->t2_timeout = 1; + } + else { + uVar2 = 0xffff; +LAB_2303d3a4: + dhcp->t2_timeout = uVar2; + } + dhcp->t2_rebind_time = dhcp->t2_timeout; +LAB_2303d3b0: + if ((dhcp->t2_timeout <= dhcp->t1_timeout) && (dhcp->t2_timeout != 0)) { + dhcp->t1_timeout = 0; + } + if (dhcp->subnet_mask_given == '\0') { + bVar1 = *(byte *)&(dhcp->offered_ip_addr).addr; + if ((char)bVar1 < '\0') { + if (bVar1 < 0xc0) { + iVar4 = 0x10000; + } + else { + iVar4 = 0x1000000; + } + iStack24 = (ip4_addr_t)(iVar4 - 1); + } + else { + iStack24 = (ip4_addr_t)0xff; + } + } + else { + iStack24 = (ip4_addr_t)(dhcp->offered_sn_mask).addr; + } + sn_mask = (dhcp->offered_gw_addr).addr; + if ((ip4_addr_t)sn_mask == (ip4_addr_t)0x0) { + sn_mask = (dhcp->offered_ip_addr).addr & (uint)iStack24 | 0x1000000; + } + dhcp_set_state(dhcp,'\n'); + netif_set_addr(netif,&dhcp->offered_ip_addr,&iStack24,&sn_mask); + return; +} + + + +err_t dhcp_inc_pcb_refcount(void) + +{ + udp_pcb *pcb; + + if (dhcp_pcb_refcount == '\0') { + pcb = udp_new(); + if (pcb == (udp_pcb *)0x0) { + dhcp_pcb = pcb; + return -1; + } + dhcp_pcb = pcb; + pcb->so_options = pcb->so_options | 0x20; + udp_bind(pcb,&ip_addr_any,0x44); + udp_connect(dhcp_pcb,&ip_addr_any,0x43); + udp_recv(dhcp_pcb,dhcp_recv,(void *)0x0); + } + dhcp_pcb_refcount = dhcp_pcb_refcount + '\x01'; + return '\0'; +} + + + +u16_t dhcp_option_hostname(u16_t options_out_len,u8_t *options) + +{ + undefined2 in_register_0000202a; + int iVar1; + size_t sVar2; + u8_t **in_a2; + u8_t *puVar3; + u8_t *puVar4; + uint uVar5; + uint uVar6; + uint uVar7; + + iVar1 = CONCAT22(in_register_0000202a,options_out_len); + if ((*in_a2 != (u8_t *)0x0) && (sVar2 = strlen((char *)*in_a2), sVar2 != 0)) { + puVar3 = *in_a2; + uVar6 = 0x41U - iVar1; + if (sVar2 < 0x41U - iVar1) { + uVar6 = sVar2; + } + options[iVar1] = '\f'; + uVar5 = iVar1 + 2U & 0xffff; + options[iVar1 + 1U & 0xffff] = (u8_t)uVar6; + puVar4 = puVar3; + uVar7 = uVar5; + while (puVar4 != puVar3 + uVar6) { + options[uVar7] = *puVar4; + uVar7 = uVar7 + 1 & 0xffff; + puVar4 = puVar4 + 1; + } + options_out_len = (short)uVar5 + (short)uVar6; + } + return options_out_len; +} + + + +err_t dhcp_reboot(netif *netif) + +{ + u8_t *options; + dhcp *dhcp; + err_t eVar1; + u16_t options_out_len_00; + pbuf *p_out; + undefined2 extraout_var; + u32_t value; + undefined2 extraout_var_00; + uint uVar2; + int iVar3; + u16_t auStack34 [2]; + u16_t options_out_len; + + dhcp = (dhcp *)netif->client_data[0]; + dhcp_set_state(dhcp,'\x03'); + p_out = dhcp_create_msg(netif,dhcp,'\x03',auStack34); + eVar1 = -1; + if (p_out != (pbuf *)0x0) { + uVar2 = (uint)auStack34[0]; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar2] = '9'; + options[uVar2 + 1 & 0xffff] = '\x02'; + auStack34[0] = (u16_t)((uVar2 + 2) * 0x10000 >> 0x10); + options_out_len_00 = dhcp_option_short(auStack34[0],options,0x240); + iVar3 = CONCAT22(extraout_var,options_out_len_00); + options[iVar3] = '2'; + options[iVar3 + 1U & 0xffff] = '\x04'; + options_out_len_00 = (u16_t)((uint)((iVar3 + 2) * 0x10000) >> 0x10); + auStack34[0] = options_out_len_00; + value = lwip_htonl((dhcp->offered_ip_addr).addr); + auStack34[0] = dhcp_option_long(options_out_len_00,options,value); + options[CONCAT22(extraout_var_00,auStack34[0])] = '7'; + options[CONCAT22(extraout_var_00,auStack34[0]) + 1U & 0xffff] = '\x04'; + auStack34[0] = auStack34[0] + 2; + iVar3 = 0; + do { + options[(uint)auStack34[0]] = "\x01\x03\x1c\x06"[iVar3]; + auStack34[0] = (u16_t)(((uint)auStack34[0] + 1) * 0x10000 >> 0x10); + iVar3 = iVar3 + 1; + } while (iVar3 != 4); + auStack34[0] = dhcp_option_hostname(auStack34[0],options); + dhcp_option_trailer(auStack34[0],options,p_out); + eVar1 = udp_sendto_if(dhcp_pcb,p_out,&ip_addr_broadcast,0x43,netif); + pbuf_free(p_out); + } + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + if (dhcp->tries < 10) { + uVar2 = (uint)dhcp->tries * 0x3e80000 >> 0x10; + } + else { + uVar2 = 10000; + } + dhcp->request_timeout = (u16_t)((int)(uVar2 + 499) / 500); + return eVar1; +} + + + +err_t dhcp_select(netif *netif) + +{ + u8_t *options; + dhcp *dhcp; + err_t eVar1; + u16_t options_out_len_00; + pbuf *p_out; + undefined2 extraout_var; + u32_t value; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + uint uVar2; + int iVar3; + u16_t auStack34 [2]; + u16_t options_out_len; + + eVar1 = -0x10; + if (netif != (netif *)0x0) { + dhcp = (dhcp *)netif->client_data[0]; + eVar1 = -6; + if (dhcp != (dhcp *)0x0) { + dhcp_set_state(dhcp,'\x01'); + p_out = dhcp_create_msg(netif,dhcp,'\x03',auStack34); + eVar1 = -1; + if (p_out != (pbuf *)0x0) { + uVar2 = (uint)auStack34[0]; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar2] = '9'; + options[uVar2 + 1 & 0xffff] = '\x02'; + auStack34[0] = (u16_t)((uVar2 + 2) * 0x10000 >> 0x10); + options_out_len_00 = dhcp_option_short(auStack34[0],options,netif->mtu); + iVar3 = CONCAT22(extraout_var,options_out_len_00); + options[iVar3] = '2'; + options[iVar3 + 1U & 0xffff] = '\x04'; + options_out_len_00 = (u16_t)((uint)((iVar3 + 2) * 0x10000) >> 0x10); + auStack34[0] = options_out_len_00; + value = lwip_htonl((dhcp->offered_ip_addr).addr); + options_out_len_00 = dhcp_option_long(options_out_len_00,options,value); + iVar3 = CONCAT22(extraout_var_00,options_out_len_00); + options[iVar3] = '6'; + options[iVar3 + 1U & 0xffff] = '\x04'; + options_out_len_00 = (u16_t)((uint)((iVar3 + 2) * 0x10000) >> 0x10); + auStack34[0] = options_out_len_00; + value = lwip_htonl((dhcp->server_ip_addr).addr); + auStack34[0] = dhcp_option_long(options_out_len_00,options,value); + options[CONCAT22(extraout_var_01,auStack34[0])] = '7'; + options[CONCAT22(extraout_var_01,auStack34[0]) + 1U & 0xffff] = '\x04'; + auStack34[0] = auStack34[0] + 2; + iVar3 = 0; + do { + options[(uint)auStack34[0]] = "\x01\x03\x1c\x06"[iVar3]; + auStack34[0] = (u16_t)(((uint)auStack34[0] + 1) * 0x10000 >> 0x10); + iVar3 = iVar3 + 1; + } while (iVar3 != 4); + auStack34[0] = dhcp_option_hostname(auStack34[0],options); + dhcp_option_trailer(auStack34[0],options,p_out); + eVar1 = udp_sendto_if_src(dhcp_pcb,p_out,&ip_addr_broadcast,0x43,netif,&ip_addr_any); + pbuf_free(p_out); + } + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + if (dhcp->tries < 6) { + uVar2 = (uint)((1 << ((uint)dhcp->tries & 0x1f)) * 0x3e80000) >> 0x10; + } + else { + uVar2 = 60000; + } + dhcp->request_timeout = (u16_t)((int)(uVar2 + 499) / 500); + } + } + return eVar1; +} + + + +void dhcp_dec_pcb_refcount(void) + +{ + dhcp_pcb_refcount = dhcp_pcb_refcount + -1; + if (dhcp_pcb_refcount == '\0') { + udp_remove(dhcp_pcb); + dhcp_pcb = (udp_pcb *)0x0; + return; + } + return; +} + + + +void dhcp_handle_ack(dhcp_msg *msg_in) + +{ + u8_t uVar1; + u32_t uVar2; + int in_a1; + uint uVar3; + ip_addr_t iStack20; + ip_addr_t dns_addr; + + uVar1 = dhcp_rx_options_given[3]; + *(undefined4 *)(msg_in->chaddr + 4) = 0; + *(undefined4 *)(msg_in->chaddr + 8) = 0; + if (uVar1 != '\0') { + *(u32_t *)(msg_in->chaddr + 0xc) = dhcp_rx_options_val[3]; + } + uVar3 = dhcp_rx_options_val[4]; + if (dhcp_rx_options_given[4] == '\0') { + uVar3 = *(uint *)(msg_in->chaddr + 0xc) >> 1; + } + *(uint *)msg_in->sname = uVar3; + uVar3 = dhcp_rx_options_val[5]; + if (dhcp_rx_options_given[5] == '\0') { + uVar3 = (uint)(*(int *)(msg_in->chaddr + 0xc) * 7) >> 3; + } + *(uint *)(msg_in->sname + 4) = uVar3; + *(undefined4 *)msg_in->chaddr = *(undefined4 *)(in_a1 + 0x10); + if (dhcp_rx_options_given[6] == '\0') { + *(undefined *)((int)&msg_in->xid + 3) = 0; + } + else { + uVar2 = lwip_htonl(dhcp_rx_options_val[6]); + *(u32_t *)(msg_in->chaddr + 4) = uVar2; + *(undefined *)((int)&msg_in->xid + 3) = 1; + } + if (dhcp_rx_options_given[7] != '\0') { + uVar2 = lwip_htonl(dhcp_rx_options_val[7]); + *(u32_t *)(msg_in->chaddr + 8) = uVar2; + } + if (dhcp_rx_options_given[8] != '\0') { + iStack20 = (ip_addr_t)lwip_htonl(dhcp_rx_options_val[8]); + dns_setserver('\0',&iStack20); + if (dhcp_rx_options_given[9] != '\0') { + iStack20 = (ip_addr_t)lwip_htonl(dhcp_rx_options_val[9]); + dns_setserver('\x01',&iStack20); + } + } + return; +} + + + +void dhcp_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port) + +{ + byte bVar1; + byte bVar2; + bool bVar3; + pbuf **pppVar4; + netif *netif; + uint uVar5; + void *pvVar6; + u16_t uVar7; + u32_t uVar8; + undefined2 extraout_var; + void *pvVar9; + uint uVar10; + char *pcVar11; + uint uVar12; + u8_t *puVar13; + u32_t *puVar14; + pbuf *buf; + uint uVar15; + uint uVar16; + int iVar17; + uint uVar18; + void *pvStack96; + u32_t uStack68; + u32_t value; + + netif = ip_data.current_input_netif; + puVar14 = (u32_t *)(ip_data.current_input_netif)->client_data[0]; + if ((((puVar14 != (u32_t *)0x0) && (*(char *)(puVar14 + 1) != '\0')) && (0x2b < p->len)) && + (pcVar11 = (char *)p->payload, *pcVar11 == '\x02')) { + uVar16 = 0; + do { + if (((uint)(ip_data.current_input_netif)->hwaddr_len <= (uVar16 & 0xff)) || (uVar16 == 6)) { + uVar8 = lwip_htonl(*(u32_t *)(pcVar11 + 4)); + if ((uVar8 == *puVar14) && (memset(dhcp_rx_options_given,0,10), 0x2b < p->len)) { + uVar16 = (uint)p->tot_len; + bVar3 = false; + uVar18 = 0xf0; + buf = p; + goto LAB_2303da8a; + } + break; + } + puVar13 = (ip_data.current_input_netif)->hwaddr + uVar16; + iVar17 = uVar16 + 0x1c; + uVar16 = uVar16 + 1; + } while (pcVar11[iVar17] == *puVar13); + } +free_pbuf_and_return: + pbuf_free(p); + return; +LAB_2303da8a: + do { + uVar12 = (uint)buf->len; + if (uVar18 < uVar12) { + pvStack96 = buf->payload; + uVar12 = uVar18; +LAB_2303dccc: + if (uVar16 <= uVar12) goto LAB_2303dce2; + bVar2 = *(byte *)((int)pvStack96 + uVar12); + if (bVar2 == 0xff) goto LAB_2303dce2; + uVar15 = uVar12 + 2 & 0xffff; + if (uVar15 < uVar12) break; + if (uVar12 + 1 < (uint)buf->len) { + bVar1 = ((byte *)((int)pvStack96 + uVar12))[1]; +LAB_2303db20: + uVar10 = (uint)bVar1; + if (bVar2 == 0x33) { + if (bVar1 != 4) break; + uVar5 = 4; + iVar17 = 3; + } + else { + if (bVar2 < 0x34) { + if (bVar2 == 1) { + if (bVar1 == 4) { + uVar5 = 4; + iVar17 = 6; + goto LAB_2303dba6; + } + break; + } + if (bVar2 == 0) goto LAB_2303dc92; + if (bVar2 != 3) goto LAB_2303db3e; + if (uVar10 <= bVar2) break; + iVar17 = 7; + uVar5 = 4; + } + else { + if (bVar2 == 0x36) { +LAB_2303dc78: + if (uVar10 != 4) break; + uVar5 = 4; + iVar17 = 2; + } + else { + if (bVar2 < 0x37) { + if (bVar2 == 0x34) goto LAB_2303dc62; +LAB_2303db70: + if (bVar2 == 0x35) { + if (uVar10 != 1) break; + uVar5 = 1; + iVar17 = 1; + } + else { +LAB_2303db42: + iVar17 = -1; + uVar5 = 0; + } + } + else { + if (bVar2 == 0x3a) goto LAB_2303dc86; +LAB_2303db8c: + if (bVar2 != 0x3b) goto LAB_2303db42; + if (uVar10 != 4) break; + uVar5 = 4; + iVar17 = 5; + } + } + } + } + } + else { + if (buf->next != (pbuf *)0x0) { + bVar1 = *(byte *)buf->next->payload; + goto LAB_2303db20; + } + if (bVar2 == 0x33) break; + if (bVar2 < 0x34) { + if (bVar2 == 1) break; + if (bVar2 != 0) { + if (bVar2 != 3) { + uVar10 = 0; +LAB_2303db3e: + if (bVar2 != 6) goto LAB_2303db42; + if ((uVar10 & 3) == 0) { + uVar5 = uVar10; + if (8 < uVar10) { + uVar5 = 8; + } + if (uVar5 <= uVar10) { + iVar17 = 8; + goto LAB_2303dba6; + } + } + } + break; + } +LAB_2303dc92: + uVar12 = uVar12 + 1 & 0xffff; + goto LAB_2303dc9a; + } + if (bVar2 == 0x36) { + uVar10 = 0; + goto LAB_2303dc78; + } + if (bVar2 < 0x37) { + if (bVar2 != 0x34) { + uVar10 = 0; + goto LAB_2303db70; + } + uVar10 = 0; +LAB_2303dc62: + if ((uVar10 != 1) || (uVar18 != 0xf0)) break; + uVar5 = 1; + iVar17 = 0; + } + else { + if (bVar2 != 0x3a) { + uVar10 = 0; + goto LAB_2303db8c; + } + uVar10 = 0; +LAB_2303dc86: + if (uVar10 != 4) break; + uVar5 = 4; + iVar17 = 4; + } + } +LAB_2303dba6: + if (0xfffd < uVar10 + uVar12) break; + uVar12 = uVar10 + uVar15 & 0xffff; + if (uVar5 != 0) { + uStack68 = 0; + puVar13 = dhcp_rx_options_given + iVar17; + while (*puVar13 == '\0') { + uVar10 = uVar5; + if (4 < uVar5) { + uVar10 = 4; + } + uVar7 = pbuf_copy_partial(buf,&uStack68,(u16_t)uVar10,(u16_t)uVar15); + if (uVar10 != CONCAT22(extraout_var,uVar7)) goto free_pbuf_and_return; + if (uVar5 < 5) { + if (uVar5 == 4) { + uStack68 = lwip_htonl(uStack68); + } + else { + if (uVar5 != 1) goto free_pbuf_and_return; + uStack68 = uStack68 & 0xff; + } + dhcp_rx_options_given[iVar17] = '\x01'; + dhcp_rx_options_val[iVar17] = uStack68; + break; + } + if ((uVar5 & 3) != 0) goto free_pbuf_and_return; + *puVar13 = '\x01'; + uVar8 = lwip_htonl(uStack68); + dhcp_rx_options_val[iVar17] = uVar8; + uVar10 = uVar15 + 4 & 0xffff; + uVar5 = uVar5 - 4 & 0xff; + puVar13 = puVar13 + 1; + if (uVar10 < uVar15) goto free_pbuf_and_return; + iVar17 = iVar17 + 1; + uVar15 = uVar10; + } + } +LAB_2303dc9a: + uVar15 = (uint)buf->len; + if (uVar15 <= uVar12) { + uVar12 = uVar12 - uVar15 & 0xffff; + uVar16 = uVar16 - uVar15 & 0xffff; + if ((uVar16 <= uVar12) || (buf = buf->next, buf == (pbuf *)0x0)) break; + pvStack96 = buf->payload; + } + goto LAB_2303dccc; + } + pppVar4 = &buf->next; + uVar18 = uVar18 - uVar12 & 0xffff; + uVar16 = uVar16 - uVar12 & 0xffff; + buf = *pppVar4; + } while (*pppVar4 != (pbuf *)0x0); + goto free_pbuf_and_return; +LAB_2303dce2: + if (dhcp_rx_options_given[0] != '\0') { + dhcp_rx_options_given[0] = '\0'; + if (dhcp_rx_options_val[0] == 1) { +LAB_2303dd96: + uVar16 = 0xec; + uVar18 = 0x6c; + buf = p; + goto LAB_2303da8a; + } + if (dhcp_rx_options_val[0] == 2) goto LAB_2303dd80; + if (dhcp_rx_options_val[0] == 3) { + bVar3 = true; + goto LAB_2303dd96; + } + } + if (!bVar3) { + if (dhcp_rx_options_given[1] == '\0') goto free_pbuf_and_return; + pvVar9 = p->payload; + if ((char)dhcp_rx_options_val[1] != '\x05') { + if ((char)dhcp_rx_options_val[1] == '\x06') { + if (((byte)(*(char *)((int)puVar14 + 5) - 3U) < 3) || + (*(char *)((int)puVar14 + 5) == '\x01')) { + dhcp_set_state((dhcp *)netif->client_data[0],'\f'); + netif_set_addr(netif,(ip4_addr_t *)&ip_addr_any,(ip4_addr_t *)&ip_addr_any, + (ip4_addr_t *)&ip_addr_any); + dhcp_discover(netif); + } + } + else { + if ((((char)dhcp_rx_options_val[1] == '\x02') && (*(char *)((int)puVar14 + 5) == '\x06')) && + (dhcp_rx_options_given[2] != '\0')) { + pvVar6 = netif->client_data[0]; + *(undefined2 *)((int)pvVar6 + 8) = 0; + uVar8 = lwip_htonl(dhcp_rx_options_val[2]); + *(u32_t *)((int)pvVar6 + 0x18) = uVar8; + *(undefined4 *)((int)pvVar6 + 0x1c) = *(undefined4 *)((int)pvVar9 + 0x10); + dhcp_select(netif); + } + } + goto free_pbuf_and_return; + } + if (*(char *)((int)puVar14 + 5) == '\x01') { + dhcp_handle_ack((dhcp_msg *)netif->client_data[0]); + if ((netif->flags & 8) != 0) { + dhcp_check(netif); + goto free_pbuf_and_return; + } + } + else { + if (2 < (byte)(*(char *)((int)puVar14 + 5) - 3U)) goto free_pbuf_and_return; + dhcp_handle_ack((dhcp_msg *)netif->client_data[0]); + } + dhcp_bind(netif); + goto free_pbuf_and_return; + } +LAB_2303dd80: + bVar3 = false; + uVar16 = 0x6c; + uVar18 = 0x2c; + buf = p; + goto LAB_2303da8a; +} + + + +void dhcp_network_changed(netif *netif) + +{ + byte bVar1; + void *pvVar2; + + pvVar2 = netif->client_data[0]; + if (pvVar2 == (void *)0x0) { + return; + } + bVar1 = *(byte *)((int)pvVar2 + 5); + if (bVar1 < 6) { + if (2 < bVar1) { +LAB_2303dec6: + *(undefined *)((int)pvVar2 + 6) = 0; + dhcp_reboot(netif); + return; + } + if (bVar1 == 0) { + return; + } + } + else { + if (bVar1 == 10) goto LAB_2303dec6; + } + *(undefined *)((int)pvVar2 + 6) = 0; + dhcp_discover(netif); + return; +} + + + +void dhcp_arp_reply(netif *netif,ip4_addr_t *addr) + +{ + dhcp *dhcp; + u8_t *options; + pbuf *p_out; + u32_t value; + uint uVar1; + u16_t options_out_len_00; + u16_t auStack34 [2]; + u16_t options_out_len; + + if (netif != (netif *)0x0) { + dhcp = (dhcp *)netif->client_data[0]; + if (((dhcp != (dhcp *)0x0) && (dhcp->state == '\b')) && + (addr->addr == (dhcp->offered_ip_addr).addr)) { + dhcp_set_state(dhcp,'\f'); + p_out = dhcp_create_msg(netif,dhcp,'\x04',auStack34); + if (p_out != (pbuf *)0x0) { + uVar1 = (uint)auStack34[0]; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar1] = '2'; + options[uVar1 + 1 & 0xffff] = '\x04'; + options_out_len_00 = (u16_t)((uVar1 + 2) * 0x10000 >> 0x10); + auStack34[0] = options_out_len_00; + value = lwip_htonl((dhcp->offered_ip_addr).addr); + auStack34[0] = dhcp_option_long(options_out_len_00,options,value); + dhcp_option_trailer(auStack34[0],options,p_out); + udp_sendto_if_src(dhcp_pcb,p_out,&ip_addr_broadcast,0x43,netif,&ip_addr_any); + pbuf_free(p_out); + } + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + dhcp->request_timeout = 0x14; + } + return; + } + return; +} + + + +err_t dhcp_renew(netif *netif) + +{ + u8_t *options; + dhcp *dhcp; + err_t eVar1; + pbuf *p_out; + undefined2 extraout_var; + uint uVar2; + int iVar3; + u16_t auStack34 [2]; + u16_t options_out_len; + + dhcp = (dhcp *)netif->client_data[0]; + dhcp_set_state(dhcp,'\x05'); + p_out = dhcp_create_msg(netif,dhcp,'\x03',auStack34); + eVar1 = -1; + if (p_out != (pbuf *)0x0) { + uVar2 = (uint)auStack34[0]; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar2] = '9'; + options[uVar2 + 1 & 0xffff] = '\x02'; + auStack34[0] = (u16_t)((uVar2 + 2) * 0x10000 >> 0x10); + auStack34[0] = dhcp_option_short(auStack34[0],options,netif->mtu); + options[CONCAT22(extraout_var,auStack34[0])] = '7'; + options[CONCAT22(extraout_var,auStack34[0]) + 1U & 0xffff] = '\x04'; + auStack34[0] = auStack34[0] + 2; + iVar3 = 0; + do { + options[(uint)auStack34[0]] = "\x01\x03\x1c\x06"[iVar3]; + auStack34[0] = (u16_t)(((uint)auStack34[0] + 1) * 0x10000 >> 0x10); + iVar3 = iVar3 + 1; + } while (iVar3 != 4); + auStack34[0] = dhcp_option_hostname(auStack34[0],options); + dhcp_option_trailer(auStack34[0],options,p_out); + eVar1 = udp_sendto_if(dhcp_pcb,p_out,&dhcp->server_ip_addr,0x43,netif); + pbuf_free(p_out); + } + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + if (dhcp->tries < 10) { + uVar2 = (uint)dhcp->tries * 0x7d00000 >> 0x10; + } + else { + uVar2 = 20000; + } + dhcp->request_timeout = (u16_t)((int)(uVar2 + 499) / 500); + return eVar1; +} + + + +u8_t dhcp_supplied_address(netif *netif) + +{ + byte bVar1; + bool bVar2; + + if ((netif != (netif *)0x0) && (netif->client_data[0] != (void *)0x0)) { + bVar1 = *(byte *)((int)netif->client_data[0] + 5); + bVar2 = true; + if (bVar1 != 10) { + bVar2 = (uint)bVar1 - 4 < 2; + } + return (u8_t)bVar2; + } + return '\0'; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +void dhcp_release_and_stop(netif *netif) + +{ + dhcp *dhcp; + u8_t uVar1; + undefined3 extraout_var; + pbuf *p_out; + u32_t value; + uint uVar2; + u8_t *options; + u16_t options_out_len_00; + u16_t uStack38; + u16_t options_out_len; + ip_addr_t n; + ip_addr_t server_ip_addr; + + dhcp = (dhcp *)netif->client_data[0]; + if ((dhcp != (dhcp *)0x0) && (dhcp->state != '\0')) { + n = (ip_addr_t)(dhcp->server_ip_addr).addr; + (dhcp->offered_ip_addr).addr = 0; + (dhcp->server_ip_addr).addr = 0; + (dhcp->offered_sn_mask).addr = 0; + (dhcp->offered_gw_addr).addr = 0; + dhcp->offered_t2_rebind = 0; + dhcp->offered_t1_renew = 0; + dhcp->offered_t0_lease = 0; + dhcp->t1_renew_time = 0; + *(undefined4 *)&dhcp->t2_rebind_time = 0; + dhcp->t0_timeout = 0; + uVar1 = dhcp_supplied_address(netif); + if ((CONCAT31(extraout_var,uVar1) != 0) && + (p_out = dhcp_create_msg(netif,dhcp,'\a',&uStack38), p_out != (pbuf *)0x0)) { + uVar2 = (uint)uStack38; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar2] = '6'; + options[uVar2 + 1 & 0xffff] = '\x04'; + options_out_len_00 = (u16_t)((uVar2 + 2) * 0x10000 >> 0x10); + uStack38 = options_out_len_00; + value = lwip_htonl((u32_t)n); + uStack38 = dhcp_option_long(options_out_len_00,options,value); + dhcp_option_trailer(uStack38,options,p_out); + udp_sendto_if(dhcp_pcb,p_out,(ip_addr_t *)&stack0xffffffdc,0x43,netif); + pbuf_free(p_out); + } + netif_set_addr(netif,(ip4_addr_t *)&ip_addr_any,(ip4_addr_t *)&ip_addr_any, + (ip4_addr_t *)&ip_addr_any); + dhcp_set_state(dhcp,'\0'); + if (dhcp->pcb_allocated != '\0') { + dhcp_dec_pcb_refcount(); + dhcp->pcb_allocated = '\0'; + } + } + return; +} + + + +err_t dhcp_start(netif *netif) + +{ + err_t eVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + dhcp *dhcp; + + if (netif == (netif *)0x0) { + return -0x10; + } + if ((netif->flags & 1) == 0) { + return -0x10; + } + dhcp = (dhcp *)netif->client_data[0]; + if (0x23f < netif->mtu) { + if (dhcp == (dhcp *)0x0) { + dhcp = (dhcp *)mem_malloc(0x34); + if (dhcp == (dhcp *)0x0) { + return -1; + } + *(dhcp **)netif->client_data = dhcp; + } + else { + if (dhcp->pcb_allocated != '\0') { + dhcp_dec_pcb_refcount(); + } + } + memset(dhcp,0,0x34); + eVar1 = dhcp_inc_pcb_refcount(); + if (CONCAT31(extraout_var,eVar1) == 0) { + dhcp->pcb_allocated = '\x01'; + if ((netif->flags & 4) == 0) { + dhcp_set_state(dhcp,'\x02'); + return eVar1; + } + eVar1 = dhcp_discover(netif); + if (CONCAT31(extraout_var_00,eVar1) == 0) { + return eVar1; + } + dhcp_release_and_stop(netif); + } + } + return -1; +} + + + +void dhcp_coarse_tmr(void) + +{ + short sVar1; + netif *netif; + dhcp *dhcp; + pbuf *p_out; + undefined2 extraout_var; + uint uVar2; + void *pvVar3; + int iVar4; + u8_t *options; + u16_t auStack50 [2]; + u16_t options_out_len; + + netif = netif_list; + while (netif != (netif *)0x0) { + pvVar3 = netif->client_data[0]; + if ((pvVar3 != (void *)0x0) && (*(char *)((int)pvVar3 + 5) != '\0')) { + if ((*(ushort *)((int)pvVar3 + 0x14) == 0) || + (uVar2 = (uint)*(ushort *)((int)pvVar3 + 0x12) + 1, + *(undefined2 *)((int)pvVar3 + 0x12) = (short)(uVar2 * 0x10000 >> 0x10), + (uint)*(ushort *)((int)pvVar3 + 0x14) != (uVar2 & 0xffff))) { + sVar1 = *(short *)((int)pvVar3 + 0x10); + if ((sVar1 == 0) || (*(short *)((int)pvVar3 + 0x10) = sVar1 + -1, sVar1 != 1)) { + sVar1 = *(short *)((int)pvVar3 + 0xe); + if ((sVar1 != 0) && (*(short *)((int)pvVar3 + 0xe) = sVar1 + -1, sVar1 == 1)) { + pvVar3 = netif->client_data[0]; + if (((*(byte *)((int)pvVar3 + 5) & 0xfb) == 1) || (*(byte *)((int)pvVar3 + 5) == 10)) { + dhcp_renew(netif); + iVar4 = (uint)*(ushort *)((int)pvVar3 + 0xc) - (uint)*(ushort *)((int)pvVar3 + 0x12); + if (1 < iVar4) { + *(undefined2 *)((int)pvVar3 + 0xe) = (short)(iVar4 >> 1); + } + } + } + } + else { + dhcp = (dhcp *)netif->client_data[0]; + if ((dhcp->state < 0xb) && ((0x432U >> ((uint)dhcp->state & 0x1f) & 1) != 0)) { + dhcp_set_state(dhcp,'\x04'); + p_out = dhcp_create_msg(netif,dhcp,'\x03',auStack50); + if (p_out != (pbuf *)0x0) { + uVar2 = (uint)auStack50[0]; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar2] = '9'; + options[uVar2 + 1 & 0xffff] = '\x02'; + auStack50[0] = (u16_t)((uVar2 + 2) * 0x10000 >> 0x10); + auStack50[0] = dhcp_option_short(auStack50[0],options,netif->mtu); + options[CONCAT22(extraout_var,auStack50[0])] = '7'; + options[CONCAT22(extraout_var,auStack50[0]) + 1U & 0xffff] = '\x04'; + auStack50[0] = auStack50[0] + 2; + iVar4 = 0; + do { + options[(uint)auStack50[0]] = "\x01\x03\x1c\x06"[iVar4]; + auStack50[0] = (u16_t)(((uint)auStack50[0] + 1) * 0x10000 >> 0x10); + iVar4 = iVar4 + 1; + } while (iVar4 != 4); + auStack50[0] = dhcp_option_hostname(auStack50[0],options); + dhcp_option_trailer(auStack50[0],options,p_out); + udp_sendto_if(dhcp_pcb,p_out,&ip_addr_broadcast,0x43,netif); + pbuf_free(p_out); + } + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + uVar2 = 10000; + if (dhcp->tries < 10) { + uVar2 = (uint)dhcp->tries * 0x3e80000 >> 0x10; + } + dhcp->request_timeout = (u16_t)((int)(uVar2 + 499) / 500); + iVar4 = (uint)dhcp->t0_timeout - (uint)dhcp->lease_used; + if (1 < iVar4) { + dhcp->t2_rebind_time = (u16_t)(iVar4 >> 1); + } + } + } + } + else { + dhcp_release_and_stop(netif); + dhcp_start(netif); + } + } + netif = netif->next; + } + return; +} + + + +void dhcp_fine_tmr(void) + +{ + char cVar1; + ushort uVar2; + netif *netif; + void *pvVar3; + + netif = netif_list; + do { + if (netif == (netif *)0x0) { + return; + } + pvVar3 = netif->client_data[0]; + if (pvVar3 != (void *)0x0) { + uVar2 = *(ushort *)((int)pvVar3 + 8); + if (uVar2 < 2) { + if (uVar2 == 1) { + *(undefined2 *)((int)pvVar3 + 8) = 0; + pvVar3 = netif->client_data[0]; + cVar1 = *(char *)((int)pvVar3 + 5); + if ((cVar1 == '\f') || (cVar1 == '\x06')) { +LAB_2303e534: + dhcp_discover(netif); + } + else { + if (cVar1 == '\x01') { + if (*(byte *)((int)pvVar3 + 6) < 6) { + dhcp_select(netif); + } + else { + dhcp_release_and_stop(netif); + dhcp_start(netif); + } + } + else { + if (cVar1 == '\b') { + if (*(byte *)((int)pvVar3 + 6) < 2) { + dhcp_check(netif); + } + else { + dhcp_bind(netif); + } + } + else { + if (cVar1 == '\x03') { + if (1 < *(byte *)((int)pvVar3 + 6)) goto LAB_2303e534; + dhcp_reboot(netif); + } + } + } + } + } + } + else { + *(short *)((int)pvVar3 + 8) = uVar2 - 1; + } + } + netif = netif->next; + } while( true ); +} + + + +// WARNING: Type propagation algorithm not settling + +void dhcp_stop(netif *netif) + +{ + dhcp *dhcp; + u8_t uVar1; + undefined3 extraout_var; + pbuf *p_out; + u32_t value; + uint uVar2; + u8_t *options; + u16_t options_out_len; + u16_t uStack38; + ip_addr_t aiStack36 [3]; + + dhcp = (dhcp *)netif->client_data[0]; + if ((dhcp != (dhcp *)0x0) && (dhcp->state != '\0')) { + aiStack36[0] = (ip_addr_t)(dhcp->server_ip_addr).addr; + (dhcp->offered_ip_addr).addr = 0; + (dhcp->server_ip_addr).addr = 0; + (dhcp->offered_sn_mask).addr = 0; + (dhcp->offered_gw_addr).addr = 0; + dhcp->offered_t2_rebind = 0; + dhcp->offered_t1_renew = 0; + dhcp->offered_t0_lease = 0; + dhcp->t1_renew_time = 0; + *(undefined4 *)&dhcp->t2_rebind_time = 0; + dhcp->t0_timeout = 0; + uVar1 = dhcp_supplied_address(netif); + if ((CONCAT31(extraout_var,uVar1) != 0) && + (p_out = dhcp_create_msg(netif,dhcp,'\a',&uStack38), p_out != (pbuf *)0x0)) { + uVar2 = (uint)uStack38; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar2] = '6'; + options[uVar2 + 1 & 0xffff] = '\x04'; + options_out_len = (u16_t)((uVar2 + 2) * 0x10000 >> 0x10); + uStack38 = options_out_len; + value = lwip_htonl((u32_t)aiStack36[0]); + uStack38 = dhcp_option_long(options_out_len,options,value); + dhcp_option_trailer(uStack38,options,p_out); + udp_sendto_if(dhcp_pcb,p_out,aiStack36,0x43,netif); + pbuf_free(p_out); + } + netif_set_addr(netif,(ip4_addr_t *)&ip_addr_any,(ip4_addr_t *)&ip_addr_any, + (ip4_addr_t *)&ip_addr_any); + dhcp_set_state(dhcp,'\0'); + if (dhcp->pcb_allocated != '\0') { + dhcp_dec_pcb_refcount(); + dhcp->pcb_allocated = '\0'; + } + } + return; +} + + + +void etharp_free_entry(int i) + +{ + pbuf *p; + + p = arp_table[i].q; + if (p != (pbuf *)0x0) { + pbuf_free(p); + arp_table[i].q = (pbuf *)0x0; + } + arp_table[i].state = '\0'; + return; +} + + + +s16_t etharp_find_entry(ip4_addr_t *ipaddr,u8_t flags,netif *netif) + +{ + ushort uVar1; + ushort uVar2; + int iVar3; + int iVar4; + int i; + undefined3 in_register_0000202d; + etharp_entry *peVar5; + int iVar6; + s16_t sVar7; + int iVar8; + uint uVar9; + int iVar10; + ushort uVar11; + ushort uVar12; + + peVar5 = arp_table; + uVar2 = 0; + uVar12 = 0; + uVar11 = 0; + iVar3 = 10; + iVar8 = 0; + iVar10 = 10; + iVar4 = 10; + iVar6 = 10; + do { + i = iVar6; + if (iVar6 == 10) { + i = iVar8; + } + if (peVar5->state != '\0') { + if ((ipaddr != (ip4_addr_t *)0x0) && (ipaddr->addr == (peVar5->ipaddr).addr)) { + if (netif == (netif *)0x0) { + return (s16_t)iVar8; + } + if (peVar5->netif == netif) { + return (s16_t)iVar8; + } + } + uVar1 = peVar5->ctime; + if (peVar5->state == '\x01') { + if (peVar5->q == (pbuf *)0x0) { + i = iVar6; + if (uVar12 <= uVar1) { + iVar4 = iVar8; + uVar12 = uVar1; + } + } + else { + i = iVar6; + if (uVar11 <= uVar1) { + iVar3 = iVar8; + uVar11 = uVar1; + } + } + } + else { + i = iVar6; + if (uVar2 <= uVar1) { + iVar10 = iVar8; + uVar2 = uVar1; + } + } + } + uVar9 = iVar8 + 1U & 0xffff; + peVar5 = peVar5 + 1; + iVar8 = (int)(short)uVar9; + iVar6 = i; + if (uVar9 == 10) { + sVar7 = -1; + if (CONCAT31(in_register_0000202d,flags) == 1) { + if (i == 10) { + i = iVar10; + if (((iVar10 == 10) && (i = iVar4, iVar4 == 10)) && (i = iVar3, iVar3 == 10)) { + return -1; + } + etharp_free_entry(i); + } + sVar7 = (s16_t)i; + if (ipaddr != (ip4_addr_t *)0x0) { + arp_table[i].ipaddr.addr = ipaddr->addr; + } + arp_table[i].ctime = 0; + arp_table[i].netif = netif; + } + return sVar7; + } + } while( true ); +} + + + +err_t etharp_raw(netif *netif,eth_addr *ethsrc_addr,eth_addr *ethdst_addr,eth_addr *hwsrc_addr, + ip4_addr_t *ipsrc_addr,eth_addr *hwdst_addr,ip4_addr_t *ipdst_addr,u16_t opcode) + +{ + undefined *puVar1; + err_t eVar2; + u16_t uVar3; + pbuf *p; + + p = pbuf_alloc(PBUF_LINK,0x1c,PBUF_RAM); + if (p == (pbuf *)0x0) { + eVar2 = -1; + lwip_stats.etharp.memerr = lwip_stats.etharp.memerr + 1; + } + else { + puVar1 = (undefined *)p->payload; + uVar3 = lwip_htons(opcode); + puVar1[6] = (char)uVar3; + puVar1[7] = (char)(uVar3 >> 8); + memcpy(puVar1 + 8,hwsrc_addr,6); + memcpy(puVar1 + 0x12,hwdst_addr,6); + memcpy(puVar1 + 0xe,ipsrc_addr,4); + memcpy(puVar1 + 0x18,ipdst_addr,4); + puVar1[1] = 1; + puVar1[2] = 8; + puVar1[4] = 6; + puVar1[5] = 4; + *puVar1 = 0; + puVar1[3] = 0; + ethernet_output(netif,p,ethsrc_addr,ethdst_addr,0x806); + lwip_stats.etharp.xmit = lwip_stats.etharp.xmit + 1; + pbuf_free(p); + eVar2 = '\0'; + } + return eVar2; +} + + + +void etharp_cleanup_netif(netif *netif) + +{ + etharp_entry *peVar1; + int i; + + peVar1 = arp_table; + i = 0; + do { + if ((peVar1->state != '\0') && (peVar1->netif == netif)) { + etharp_free_entry(i); + } + i = i + 1; + peVar1 = peVar1 + 1; + } while (i != 10); + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void etharp_input(pbuf *p,netif *netif) + +{ + bool bVar1; + short *psVar2; + u8_t uVar3; + s16_t sVar4; + undefined3 extraout_var; + short extraout_var_00; + ip4_addr_t iVar5; + eth_addr *dst; + u8_t flags; + pbuf *p_00; + ip4_addr_t iStack56; + ip4_addr_t sipaddr; + ip4_addr_t dipaddr; + + if (netif != (netif *)0x0) { + psVar2 = (short *)p->payload; + if ((((*psVar2 == 0x100) && (*(char *)(psVar2 + 2) == '\x06')) && + (*(char *)((int)psVar2 + 5) == '\x04')) && (psVar2[1] == 8)) { + lwip_stats.etharp.recv = lwip_stats.etharp.recv + 1; + memcpy(&iStack56,psVar2 + 7,4); + memcpy(&sipaddr,psVar2 + 0xc,4); + iVar5 = (ip4_addr_t)(netif->ip_addr).addr; + dst = (eth_addr *)(psVar2 + 4); + if ((iVar5 == (ip4_addr_t)0x0) || (iVar5 != (ip4_addr_t)sipaddr)) { + bVar1 = false; + flags = '\x02'; + } + else { + bVar1 = true; + flags = '\x01'; + } + if (((iStack56 != (ip4_addr_t)0x0) && + (uVar3 = ip4_addr_isbroadcast_u32((u32_t)iStack56,netif), + CONCAT31(extraout_var,uVar3) == 0)) && (((uint)iStack56 & 0xf0) != 0xe0)) { + sVar4 = etharp_find_entry(&iStack56,flags,netif); + _sVar4 = CONCAT22(extraout_var_00,sVar4); + if (-1 < extraout_var_00) { + arp_table[_sVar4].state = '\x02'; + arp_table[_sVar4].netif = netif; + memcpy(&arp_table[_sVar4].ethaddr,dst,6); + p_00 = arp_table[_sVar4].q; + arp_table[_sVar4].ctime = 0; + if (p_00 != (pbuf *)0x0) { + arp_table[_sVar4].q = (pbuf *)0x0; + ethernet_output(netif,p_00,(eth_addr *)netif->hwaddr,dst,0x800); + pbuf_free(p_00); + } + } + } + if (psVar2[3] == 0x100) { + if (bVar1) { + etharp_raw(netif,(eth_addr *)netif->hwaddr,dst,(eth_addr *)netif->hwaddr, + (ip4_addr_t *)&netif->ip_addr,dst,&iStack56,2); + } + } + else { + if (psVar2[3] == 0x200) { + dhcp_arp_reply(netif,&iStack56); + } + else { + lwip_stats.etharp.err = lwip_stats.etharp.err + 1; + } + } + } + else { + lwip_stats.etharp.proterr = lwip_stats.etharp.proterr + 1; + lwip_stats.etharp.drop = lwip_stats.etharp.drop + 1; + } + pbuf_free(p); + return; + } + return; +} + + + +err_t etharp_request(netif *netif,ip4_addr_t *ipaddr) + +{ + err_t eVar1; + + eVar1 = etharp_raw(netif,(eth_addr *)netif->hwaddr,ðbroadcast,(eth_addr *)netif->hwaddr, + (ip4_addr_t *)&netif->ip_addr,ðzero,ipaddr,1); + return eVar1; +} + + + +void etharp_tmr(void) + +{ + u8_t uVar1; + etharp_entry *peVar2; + int i; + uint uVar3; + uint uVar4; + + peVar2 = arp_table; + i = 0; + do { + uVar1 = peVar2->state; + if (uVar1 != '\0') { + uVar3 = (uint)peVar2->ctime + 1; + uVar4 = uVar3 & 0xffff; + peVar2->ctime = (u16_t)(uVar3 * 0x10000 >> 0x10); + if (uVar4 < 300) { + if (uVar1 == '\x01') { + if (4 < uVar4) goto LAB_2303ea08; + etharp_request(peVar2->netif,&peVar2->ipaddr); + } + else { + if (uVar1 == '\x03') { + peVar2->state = '\x04'; + } + else { + if (uVar1 == '\x04') { + peVar2->state = '\x02'; + } + } + } + } + else { +LAB_2303ea08: + etharp_free_entry(i); + } + } + i = i + 1; + peVar2 = peVar2 + 1; + if (i == 10) { + return; + } + } while( true ); +} + + + +err_t etharp_output_to_arp_index(netif *netif,pbuf *q,netif_addr_idx_t arp_idx) + +{ + err_t eVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 in_register_00002031; + int iVar2; + eth_addr *ethsrc_addr; + + iVar2 = CONCAT31(in_register_00002031,arp_idx); + ethsrc_addr = (eth_addr *)netif->hwaddr; + if (arp_table[iVar2].state == '\x02') { + if (arp_table[iVar2].ctime < 0x11d) { + if (arp_table[iVar2].ctime < 0x10e) goto LAB_2303eaa0; + eVar1 = etharp_raw(netif,ethsrc_addr,&arp_table[iVar2].ethaddr,ethsrc_addr, + (ip4_addr_t *)&netif->ip_addr,ðzero,&arp_table[iVar2].ipaddr,1); + _eVar1 = CONCAT31(extraout_var_00,eVar1); + } + else { + eVar1 = etharp_request(netif,&arp_table[iVar2].ipaddr); + _eVar1 = CONCAT31(extraout_var,eVar1); + } + if (_eVar1 == 0) { + arp_table[iVar2].state = '\x03'; + } + } +LAB_2303eaa0: + eVar1 = ethernet_output(netif,q,ethsrc_addr,&arp_table[iVar2].ethaddr,0x800); + return eVar1; +} + + + +err_t etharp_query(netif *netif,ip4_addr_t *ipaddr,pbuf *q) + +{ + pbuf **pppVar1; + u8_t uVar2; + err_t eVar3; + ushort uVar4; + undefined3 extraout_var; + short extraout_var_00; + pbuf *ppVar5; + uint uVar6; + + uVar2 = ip4_addr_isbroadcast_u32(ipaddr->addr,netif); + if (((CONCAT31(extraout_var,uVar2) != 0) || ((ipaddr->addr & 0xf0) == 0xe0)) || + (ipaddr->addr == 0)) { + return -0x10; + } + uVar4 = etharp_find_entry(ipaddr,'\x01',netif); + if (extraout_var_00 < 0) { + if (q != (pbuf *)0x0) { + lwip_stats.etharp.memerr = lwip_stats.etharp.memerr + 1; + } + return (err_t)uVar4; + } + uVar6 = (uint)uVar4 & 0xff; + if (arp_table[uVar6].state == '\0') { + arp_table[uVar6].state = '\x01'; + arp_table[uVar6].netif = netif; + } + else { + eVar3 = -1; + if (q != (pbuf *)0x0) goto LAB_2303eb7e; + } + eVar3 = etharp_request(netif,ipaddr); + if (q == (pbuf *)0x0) { + return eVar3; + } +LAB_2303eb7e: + if (1 < arp_table[uVar6].state) { + etharp_cached_entry = (netif_addr_idx_t)uVar6; + eVar3 = ethernet_output(netif,q,(eth_addr *)netif->hwaddr,&arp_table[uVar6].ethaddr,0x800); + return eVar3; + } + ppVar5 = q; + if (arp_table[uVar6].state == 1) { + do { + if ((ppVar5->type_internal & 0x40) != 0) { + q = pbuf_clone(PBUF_LINK,PBUF_RAM,q); + if (q == (pbuf *)0x0) { + lwip_stats.etharp.memerr = lwip_stats.etharp.memerr + 1; + return -1; + } + goto LAB_2303ebe4; + } + pppVar1 = &ppVar5->next; + ppVar5 = *pppVar1; + } while (*pppVar1 != (pbuf *)0x0); + pbuf_ref(q); +LAB_2303ebe4: + if (arp_table[uVar6].q != (pbuf *)0x0) { + pbuf_free(arp_table[uVar6].q); + } + arp_table[uVar6].q = q; + eVar3 = '\0'; + } + return eVar3; +} + + + +// WARNING: Variable defined which should be unmapped: mcastaddr + +err_t etharp_output(netif *netif,pbuf *q,ip4_addr_t *ipaddr) + +{ + netif_addr_idx_t nVar1; + u8_t uVar2; + err_t eVar3; + undefined3 extraout_var; + eth_addr *dst; + uint uVar4; + uint uVar5; + etharp_entry *peVar6; + undefined2 uStack24; + u8_t uStack22; + byte bStack21; + eth_addr mcastaddr; + + uVar2 = ip4_addr_isbroadcast_u32(ipaddr->addr,netif); + uVar4 = CONCAT31(extraout_var,uVar2); + if (uVar4 == 0) { + uVar5 = ipaddr->addr; + if ((uVar5 & 0xf0) != 0xe0) { + if (((((netif->ip_addr).addr ^ uVar5) & (netif->netmask).addr) != 0) && + ((uVar5 & 0xffff) != 0xfea9)) { + if ((netif->gw).addr == 0) { + return -4; + } + ipaddr = (ip4_addr_t *)&netif->gw; + } + uVar5 = (uint)etharp_cached_entry; + peVar6 = arp_table; + if (((arp_table[uVar5].state < 2) || (arp_table[uVar5].netif != netif)) || + (ipaddr->addr != arp_table[uVar5].ipaddr.addr)) { + while (((peVar6->state < 2 || (peVar6->netif != netif)) || + (nVar1 = (netif_addr_idx_t)uVar4, ipaddr->addr != (peVar6->ipaddr).addr))) { + uVar4 = uVar4 + 1 & 0xff; + peVar6 = peVar6 + 1; + if (uVar4 == 10) { + eVar3 = etharp_query(netif,ipaddr,q); + return eVar3; + } + } + } + else { + lwip_stats.etharp.cachehit = lwip_stats.etharp.cachehit + 1; + nVar1 = etharp_cached_entry; + } + etharp_cached_entry = nVar1; + eVar3 = etharp_output_to_arp_index(netif,q,etharp_cached_entry); + return eVar3; + } + uStack24 = 1; + uStack22 = '^'; + dst = (eth_addr *)&uStack24; + bStack21 = *(byte *)((int)&ipaddr->addr + 1) & 0x7f; + mcastaddr.addr[0] = *(u8_t *)((int)&ipaddr->addr + 2); + mcastaddr.addr[1] = *(u8_t *)((int)&ipaddr->addr + 3); + } + else { + dst = ðbroadcast; + } + eVar3 = ethernet_output(netif,q,(eth_addr *)netif->hwaddr,dst,0x800); + return eVar3; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void igmp_send(netif *netif,igmp_group *group,u8_t type) + +{ + u8_t *dataptr; + u16_t uVar1; + pbuf *p; + undefined3 in_register_00002031; + ip4_addr_t *dest; + u8_t uVar2; + u8_t uVar3; + u8_t uVar4; + u32_t uVar5; + ip4_addr_t iStack40; + ip4_addr_t src; + u16_t ra [2]; + + iStack40 = (ip4_addr_t)0; + p = pbuf_alloc(PBUF_TRANSPORT,8,PBUF_RAM); + if (p == (pbuf *)0x0) { + lwip_stats.igmp.memerr = lwip_stats.igmp.memerr + 1; + } + else { + iStack40 = (ip4_addr_t)(netif->ip_addr).addr; + uVar5 = (group->group_address).addr; + dataptr = (u8_t *)p->payload; + uVar4 = (u8_t)(uVar5 >> 0x18); + uVar2 = (u8_t)(uVar5 >> 8); + uVar3 = (u8_t)(uVar5 >> 0x10); + if (CONCAT31(in_register_00002031,type) == 0x16) { + dataptr[7] = uVar4; + dataptr[4] = (u8_t)uVar5; + dataptr[5] = uVar2; + dataptr[6] = uVar3; + dest = &group->group_address; + group->last_reporter_flag = '\x01'; + } + else { + dataptr[4] = (u8_t)uVar5; + dataptr[5] = uVar2; + dataptr[6] = uVar3; + dataptr[7] = uVar4; + dest = &allrouters; + } + *dataptr = type; + dataptr[1] = '\0'; + dataptr[2] = '\0'; + dataptr[3] = '\0'; + uVar1 = inet_chksum(dataptr,8); + dataptr[2] = (u8_t)uVar1; + dataptr[3] = (u8_t)(uVar1 >> 8); + src = 0x494; + lwip_stats.igmp.xmit = lwip_stats.igmp.xmit + 1; + ip4_output_if_opt(p,&iStack40,dest,'\x01','\0','\x02',netif,&src,_DAT_00000010); + pbuf_free(p); + } + return; +} + + + +void igmp_delaying_member(igmp_group *group,u8_t maxresp) + +{ + uint uVar1; + undefined3 in_register_0000202d; + uint uVar2; + + uVar2 = CONCAT31(in_register_0000202d,maxresp); + if ((group->group_state != '\x02') && + ((group->group_state != '\x01' || ((group->timer != 0 && (group->timer <= uVar2)))))) { + return; + } + if (2 < uVar2) { + uVar1 = bl_rand(); + group->timer = (u16_t)(uVar1 % uVar2); + if (uVar1 % uVar2 != 0) goto LAB_2303ee92; + } + group->timer = 1; +LAB_2303ee92: + group->group_state = '\x01'; + return; +} + + + +void igmp_init(void) + +{ + allrouters = 0x20000e0; + allsystems = 0x10000e0; + return; +} + + + +err_t igmp_stop(netif *netif) + +{ + void **mem; + void *pvVar1; + + mem = (void **)netif->client_data[1]; + netif->client_data[1] = (void *)0x0; + while (mem != (void **)0x0) { + pvVar1 = *mem; + if (netif->igmp_mac_filter != (netif_igmp_mac_filter_fn *)0x0) { + (*netif->igmp_mac_filter)(netif,(ip4_addr_t *)(mem + 1),NETIF_DEL_MAC_FILTER); + } + memp_free(MEMP_IGMP_GROUP,mem); + mem = (void **)pvVar1; + } + return '\0'; +} + + + +// WARNING: Type propagation algorithm not settling + +void igmp_report_groups(netif *netif) + +{ + igmp_group *group; + + if ((igmp_group *)netif->client_data[1] != (igmp_group *)0x0) { + group = ((igmp_group *)netif->client_data[1])->next; + while (group != (igmp_group *)0x0) { + igmp_delaying_member(group,'\x05'); + group = group->next; + } + return; + } + return; +} + + + +igmp_group * igmp_lookfor_group(netif *ifp,ip4_addr_t *addr) + +{ + igmp_group *piVar1; + + piVar1 = (igmp_group *)ifp->client_data[1]; + while ((piVar1 != (igmp_group *)0x0 && ((piVar1->group_address).addr != addr->addr))) { + piVar1 = piVar1->next; + } + return piVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +igmp_group * igmp_lookup_group(netif *ifp,ip4_addr_t *addr) + +{ + igmp_group *piVar1; + igmp_group *piVar2; + u32_t uVar3; + + piVar2 = igmp_lookfor_group(ifp,addr); + if (piVar2 == (igmp_group *)0x0) { + piVar1 = (igmp_group *)ifp->client_data[1]; + piVar2 = (igmp_group *)memp_malloc(MEMP_IGMP_GROUP); + if (piVar2 != (igmp_group *)0x0) { + uVar3 = 0; + if (addr != (ip4_addr_t *)0x0) { + uVar3 = addr->addr; + } + (piVar2->group_address).addr = uVar3; + *(undefined4 *)&piVar2->last_reporter_flag = 0; + piVar2->use = '\0'; + if (piVar1 == (igmp_group *)0x0) { + piVar2->next = (igmp_group *)0x0; + *(igmp_group **)(ifp->client_data + 1) = piVar2; + } + else { + piVar2->next = piVar1->next; + piVar1->next = piVar2; + } + } + } + return piVar2; +} + + + +err_t igmp_start(netif *netif) + +{ + err_t eVar1; + igmp_group *piVar2; + + piVar2 = igmp_lookup_group(netif,&allsystems); + if (piVar2 == (igmp_group *)0x0) { + eVar1 = -1; + } + else { + piVar2->group_state = '\x02'; + piVar2->use = piVar2->use + '\x01'; + eVar1 = '\0'; + if (netif->igmp_mac_filter != (netif_igmp_mac_filter_fn *)0x0) { + (*netif->igmp_mac_filter)(netif,&allsystems,NETIF_ADD_MAC_FILTER); + eVar1 = '\0'; + } + } + return eVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +void igmp_input(pbuf *p,netif *inp,ip4_addr_t *dest) + +{ + ip4_addr_t iVar1; + char *dataptr; + u16_t uVar2; + undefined2 extraout_var; + igmp_group *group; + ip4_addr_t iStack36; + ip4_addr_t groupaddr; + + lwip_stats.igmp.recv = lwip_stats.igmp.recv + 1; + if (p->len < 8) { + pbuf_free(p); + lwip_stats.igmp.lenerr = lwip_stats.igmp.lenerr + 1; + return; + } + dataptr = (char *)p->payload; + uVar2 = inet_chksum(dataptr,p->len); + if (CONCAT22(extraout_var,uVar2) != 0) { + pbuf_free(p); + lwip_stats.igmp.chkerr = lwip_stats.igmp.chkerr + 1; + return; + } + group = igmp_lookfor_group(inp,dest); + if (group == (igmp_group *)0x0) { + pbuf_free(p); + lwip_stats.igmp.drop = lwip_stats.igmp.drop + 1; + return; + } + if (*dataptr == '\x11') { + iVar1 = (ip4_addr_t)((ip4_addr_t *)(dataptr + 4))->addr; + if (dest->addr == allsystems) { + if (iVar1 == (ip4_addr_t)0x0) { + if (dataptr[1] == '\0') { + lwip_stats.igmp.rx_v1 = lwip_stats.igmp.rx_v1 + 1; + dataptr[1] = '\n'; + } + else { + lwip_stats.igmp.rx_general = lwip_stats.igmp.rx_general + 1; + } + if ((igmp_group *)inp->client_data[1] != (igmp_group *)0x0) { + group = ((igmp_group *)inp->client_data[1])->next; + while (group != (igmp_group *)0x0) { + igmp_delaying_member(group,dataptr[1]); + group = group->next; + } + } + goto LAB_2303f0da; + } + iStack36 = iVar1; + group = igmp_lookfor_group(inp,&iStack36); + if (group == (igmp_group *)0x0) { + lwip_stats.igmp.drop = lwip_stats.igmp.drop + 1; + goto LAB_2303f0da; + } + } + else { + if (iVar1 == (ip4_addr_t)0x0) goto LAB_2303f07c; + } + lwip_stats.igmp.rx_group = lwip_stats.igmp.rx_group + 1; + igmp_delaying_member(group,dataptr[1]); + } + else { + if (*dataptr == '\x16') { + lwip_stats.igmp.rx_report = lwip_stats.igmp.rx_report + 1; + if (group->group_state == '\x01') { + *(undefined4 *)&group->last_reporter_flag = 0x200; + } + goto LAB_2303f0da; + } +LAB_2303f07c: + lwip_stats.igmp.proterr = lwip_stats.igmp.proterr + 1; + } +LAB_2303f0da: + pbuf_free(p); + return; +} + + + +err_t igmp_joingroup_netif(netif *netif,ip4_addr_t *groupaddr) + +{ + u16_t uVar1; + igmp_group *group; + uint uVar2; + err_t eVar3; + + if (((groupaddr->addr & 0xf0) == 0xe0) && (eVar3 = -6, groupaddr->addr != allsystems)) { + if ((netif->flags & 0x20) != 0) { + group = igmp_lookup_group(netif,groupaddr); + eVar3 = -1; + if (group != (igmp_group *)0x0) { + if (group->group_state == '\0') { + if ((group->use == '\0') && (netif->igmp_mac_filter != (netif_igmp_mac_filter_fn *)0x0)) { + (*netif->igmp_mac_filter)(netif,groupaddr,NETIF_ADD_MAC_FILTER); + } + lwip_stats.igmp.tx_join = lwip_stats.igmp.tx_join + 1; + igmp_send(netif,group,'\x16'); + uVar2 = bl_rand(); + uVar1 = (u16_t)(uVar2 % 5); + if (uVar2 % 5 == 0) { + uVar1 = 1; + } + group->timer = uVar1; + group->group_state = '\x01'; + } + group->use = group->use + '\x01'; + eVar3 = '\0'; + } + } + return eVar3; + } + return -6; +} + + + +err_t igmp_joingroup(ip4_addr_t *ifaddr,ip4_addr_t *groupaddr) + +{ + netif *netif; + err_t eVar1; + int iVar2; + undefined3 extraout_var; + + if ((groupaddr->addr & 0xf0) != 0xe0) { + return -6; + } + iVar2 = -6; + eVar1 = -6; + netif = netif_list; + if (groupaddr->addr != allsystems) { + while (eVar1 = (err_t)iVar2, netif != (netif *)0x0) { + if (((netif->flags & 0x20) != 0) && + (((ifaddr == (ip4_addr_t *)0x0 || (ifaddr->addr == 0)) || + (ifaddr->addr == (netif->ip_addr).addr)))) { + eVar1 = igmp_joingroup_netif(netif,groupaddr); + iVar2 = CONCAT31(extraout_var,eVar1); + if (iVar2 != 0) { + return eVar1; + } + } + netif = netif->next; + } + } + return eVar1; +} + + + +err_t igmp_leavegroup_netif(netif *netif,ip4_addr_t *groupaddr) + +{ + igmp_group *piVar1; + igmp_group *group; + err_t eVar2; + igmp_group *piVar3; + + if (((groupaddr->addr & 0xf0) != 0xe0) || (eVar2 = -6, groupaddr->addr == allsystems)) { + return -6; + } + if ((netif->flags & 0x20) != 0) { + group = igmp_lookfor_group(netif,groupaddr); + eVar2 = -6; + if (group != (igmp_group *)0x0) { + if (group->use < 2) { + piVar1 = (igmp_group *)netif->client_data[1]; + do { + piVar3 = piVar1; + if (piVar3 == (igmp_group *)0x0) goto LAB_2303f2b0; + piVar1 = piVar3->next; + } while (group != piVar3->next); + piVar3->next = group->next; +LAB_2303f2b0: + if (group->last_reporter_flag != '\0') { + lwip_stats.igmp.tx_leave = lwip_stats.igmp.tx_leave + 1; + igmp_send(netif,group,'\x17'); + } + if (netif->igmp_mac_filter != (netif_igmp_mac_filter_fn *)0x0) { + (*netif->igmp_mac_filter)(netif,groupaddr,NETIF_DEL_MAC_FILTER); + } + memp_free(MEMP_IGMP_GROUP,group); + } + else { + group->use = group->use - 1; + } + eVar2 = '\0'; + } + } + return eVar2; +} + + + +err_t igmp_leavegroup(ip4_addr_t *ifaddr,ip4_addr_t *groupaddr) + +{ + netif *netif; + int iVar1; + err_t eVar2; + undefined3 extraout_var; + + eVar2 = -6; + if ((groupaddr->addr & 0xf0) == 0xe0) { + iVar1 = -6; + eVar2 = -6; + netif = netif_list; + if (groupaddr->addr != allsystems) { + while (eVar2 = (err_t)iVar1, netif != (netif *)0x0) { + if (((netif->flags & 0x20) != 0) && + (((ifaddr == (ip4_addr_t *)0x0 || (ifaddr->addr == 0)) || + (ifaddr->addr == (netif->ip_addr).addr)))) { + eVar2 = igmp_leavegroup_netif(netif,groupaddr); + if (iVar1 != 0) { + iVar1 = CONCAT31(extraout_var,eVar2); + } + } + netif = netif->next; + } + } + } + return eVar2; +} + + + +void igmp_tmr(void) + +{ + igmp_group *group; + netif *netif; + uint uVar1; + + netif = netif_list; + while (netif != (netif *)0x0) { + group = (igmp_group *)netif->client_data[1]; + while (group != (igmp_group *)0x0) { + if ((((group->timer != 0) && + (uVar1 = (uint)group->timer - 1, group->timer = (u16_t)(uVar1 * 0x10000 >> 0x10), + (uVar1 & 0xffff) == 0)) && (group->group_state == '\x01')) && + ((group->group_address).addr != allsystems)) { + group->group_state = '\x02'; + lwip_stats.igmp.tx_report = lwip_stats.igmp.tx_report + 1; + igmp_send(netif,group,'\x16'); + } + group = group->next; + } + netif = netif->next; + } + return; +} + + + +int ip4_input_accept(netif *netif) + +{ + u8_t uVar1; + int iVar2; + undefined3 extraout_var; + u32_t uVar3; + + if ((netif->flags & 1) == 0) { + return 0; + } + uVar3 = (netif->ip_addr).addr; + iVar2 = 0; + if (uVar3 != 0) { + iVar2 = 1; + if (uVar3 != ip_data.current_iphdr_dest) { + uVar1 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_dest,netif); + return (uint)(CONCAT31(extraout_var,uVar1) != 0); + } + } + return iVar2; +} + + + +netif * ip4_route(ip4_addr_t *dest) + +{ + byte bVar1; + netif *pnVar2; + netif *pnVar3; + uint uVar4; + uint uVar5; + + uVar5 = dest->addr; + pnVar2 = netif_list; + if (((uVar5 & 0xf0) != 0xe0) || + (pnVar3 = ip4_default_multicast_netif, ip4_default_multicast_netif == (netif *)0x0)) { + while (pnVar2 != (netif *)0x0) { + bVar1 = pnVar2->flags; + if ((((bVar1 & 1) != 0) && ((bVar1 >> 2 & 1) != 0)) && + (uVar4 = (pnVar2->ip_addr).addr, uVar4 != 0)) { + if (((uVar4 ^ uVar5) & (pnVar2->netmask).addr) == 0) { + return pnVar2; + } + if (((bVar1 & 2) == 0) && (uVar5 == (pnVar2->gw).addr)) { + return pnVar2; + } + } + pnVar2 = pnVar2->next; + } + if (((netif_default == (netif *)0x0) || ((netif_default->flags & 5) != 5)) || + (((netif_default->ip_addr).addr == 0 || (pnVar3 = netif_default, (uVar5 & 0xff) == 0x7f)))) { + lwip_stats.ip.rterr = lwip_stats.ip.rterr + 1; + return (netif *)0x0; + } + } + return pnVar3; +} + + + +err_t ip4_input(pbuf *p,netif *inp) + +{ + byte bVar1; + uint uVar2; + u8_t uVar3; + raw_input_state_t rVar4; + u16_t new_len; + undefined2 extraout_var_02; + undefined2 extraout_var_03; + igmp_group *piVar5; + undefined3 extraout_var; + int iVar6; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + ip_hdr *dataptr; + netif *netif; + uint uVar7; + + lwip_stats.ip.recv = lwip_stats.ip.recv + 1; + dataptr = (ip_hdr *)p->payload; + bVar1 = dataptr->_v_hl; + if (bVar1 >> 4 != 4) { + pbuf_free(p); + lwip_stats.ip.drop = lwip_stats.ip.drop + 1; + lwip_stats.ip.err = lwip_stats.ip.err + 1; + return '\0'; + } + new_len = lwip_htons(dataptr->_len); + uVar7 = (uint)bVar1 & 0xf; + uVar2 = (uVar7 << 0x12) >> 0x10; + if (CONCAT22(extraout_var_02,new_len) < (uint)p->tot_len) { + pbuf_realloc(p,new_len); + } + if (((p->len < uVar2) || ((uint)p->tot_len < CONCAT22(extraout_var_02,new_len))) || (uVar2 < 0x14) + ) { + pbuf_free(p); + lwip_stats.ip.lenerr = lwip_stats.ip.lenerr + 1; + goto LAB_2303f588; + } + new_len = inet_chksum(dataptr,(u16_t)((uVar7 << 0x12) >> 0x10)); + if (CONCAT22(extraout_var_03,new_len) != 0) { + pbuf_free(p); + lwip_stats.ip.chkerr = lwip_stats.ip.chkerr + 1; + goto LAB_2303f588; + } + ip_data.current_iphdr_dest = (dataptr->dest).addr; + ip_data.current_iphdr_src = (dataptr->src).addr; + netif = inp; + if ((ip_data.current_iphdr_dest & 0xf0) == 0xe0) { + if (((inp->flags & 0x20) == 0) || + (piVar5 = igmp_lookfor_group(inp,(ip4_addr_t *)&ip_data.current_iphdr_dest), + piVar5 == (igmp_group *)0x0)) goto LAB_2303f60e; + if ((ip_data.current_iphdr_dest != 0x10000e0) || (ip_data.current_iphdr_src != 0)) + goto LAB_2303f63e; + } + else { + iVar6 = ip4_input_accept(inp); + if (iVar6 == 0) { + netif = netif_list; + if ((char)ip_data.current_iphdr_dest.addr != '\x7f') { + while (netif != (netif *)0x0) { + if ((netif != inp) && (iVar6 = ip4_input_accept(netif), iVar6 != 0)) goto LAB_2303f63e; + netif = netif->next; + } + } + } + else { + if (inp != (netif *)0x0) goto LAB_2303f63e; + } +LAB_2303f60e: + if ((dataptr->_proto != '\x11') || (netif = inp, (&dataptr->_len)[uVar7 * 2] != 0x4400)) { + netif = (netif *)0x0; +LAB_2303f63e: + if ((ip_data.current_iphdr_src != 0) && + ((uVar3 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_src,inp), + CONCAT31(extraout_var,uVar3) != 0 || ((ip_data.current_iphdr_src & 0xf0) == 0xe0)))) { + pbuf_free(p); + goto LAB_2303f588; + } + } + if (netif == (netif *)0x0) { + lwip_stats.ip.drop = lwip_stats.ip.drop + 1; + pbuf_free(p); + return '\0'; + } + } + if (((uint)*(byte *)&dataptr->_offset & 0x3f | (uint)*(byte *)((int)&dataptr->_offset + 1) << 8) + == 0) { + ip_data.current_ip_header_tot_len = (u16_t)(((uint)dataptr->_v_hl & 0xf) << 2); + ip_data.current_netif = netif; + ip_data.current_input_netif = inp; + ip_data.current_ip4_header = dataptr; + rVar4 = raw_input(p,inp); + if (CONCAT31(extraout_var_00,rVar4) != 1) { + pbuf_remove_header(p,uVar7 * 4); + bVar1 = dataptr->_proto; + if (bVar1 == 2) { + igmp_input(p,inp,(ip4_addr_t *)&ip_data.current_iphdr_dest); + } + else { + if (bVar1 < 3) { + if (bVar1 == 1) { + icmp_input(p,inp); + ip_data.current_netif = (netif *)0x0; + ip_data.current_input_netif = (netif *)0x0; + ip_data.current_ip4_header = (ip_hdr *)0x0; + ip_data.current_ip_header_tot_len = 0; + ip_data.current_iphdr_src = 0; + ip_data.current_iphdr_dest = 0; + return '\0'; + } + } + else { + if (bVar1 == 6) { + tcp_input(p,inp); + ip_data.current_netif = (netif *)0x0; + ip_data.current_input_netif = (netif *)0x0; + ip_data.current_ip4_header = (ip_hdr *)0x0; + ip_data.current_ip_header_tot_len = 0; + ip_data.current_iphdr_src = 0; + ip_data.current_iphdr_dest = 0; + return '\0'; + } + if (bVar1 == 0x11) { + udp_input(p,inp); + ip_data.current_netif = (netif *)0x0; + ip_data.current_input_netif = (netif *)0x0; + ip_data.current_ip4_header = (ip_hdr *)0x0; + ip_data.current_ip_header_tot_len = 0; + ip_data.current_iphdr_src = 0; + ip_data.current_iphdr_dest = 0; + return '\0'; + } + } + if (CONCAT31(extraout_var_00,rVar4) != 2) { + uVar3 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_dest,netif); + if ((CONCAT31(extraout_var_01,uVar3) == 0) && + ((ip_data.current_iphdr_dest & 0xf0) != 0xe0)) { + pbuf_header_force(p,(s16_t)(uVar7 * 4)); + icmp_dest_unreach(p,ICMP_DUR_PROTO); + } + lwip_stats.ip.proterr = lwip_stats.ip.proterr + 1; + lwip_stats.ip.drop = lwip_stats.ip.drop + 1; + } + pbuf_free(p); + } + } + ip_data.current_netif = (netif *)0x0; + ip_data.current_input_netif = (netif *)0x0; + ip_data.current_ip4_header = (ip_hdr *)0x0; + ip_data.current_ip_header_tot_len = 0; + ip_data.current_iphdr_src = 0; + ip_data.current_iphdr_dest = 0; + return '\0'; + } + pbuf_free(p); + lwip_stats.ip.opterr = lwip_stats.ip.opterr + 1; +LAB_2303f588: + lwip_stats.ip.drop = lwip_stats.ip.drop + 1; + return '\0'; +} + + + +// WARNING: Type propagation algorithm not settling + +err_t ip4_output_if_opt_src + (pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto,netif *netif, + void *ip_options,u16_t optlen) + +{ + uint header_size_increment; + undefined *puVar1; + uint uVar2; + u8_t uVar3; + err_t eVar4; + u16_t uVar5; + u16_t n; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined2 extraout_var_01; + undefined2 extraout_var_02; + undefined3 in_register_00002035; + undefined3 in_register_00002039; + int iVar6; + undefined3 in_register_0000203d; + int iVar7; + uint uVar8; + uint __n; + int iVar9; + ushort in_stack_00000000; + ip4_addr_t iStack52; + ip4_addr_t dest_addr; + + __n = (uint)in_stack_00000000; + if (dest == (ip4_addr_t *)0x0) { + if (0x13 < p->len) { + dest = &iStack52; + iStack52 = (ip4_addr_t)((ip4_addr_t *)((int)p->payload + 0x10))->addr; + goto LAB_2303f9c0; + } + } + else { + if (in_stack_00000000 == 0) { + uVar2 = 0x14; + iVar9 = 0; + } + else { + if (0x28 < in_stack_00000000) { + lwip_stats.ip.err = lwip_stats.ip.err + 1; + return -6; + } + header_size_increment = __n + 3 & 0xfffc; + uVar3 = pbuf_add_header(p,header_size_increment); + uVar2 = header_size_increment + 0x14 & 0xffff; + if (CONCAT31(extraout_var,uVar3) != 0) goto LAB_2303f856; + memcpy(p->payload,ip_options,__n); + if (__n < header_size_increment) { + memset((void *)((int)p->payload + __n),0,header_size_increment - __n); + } + iVar7 = 0; + iVar9 = 0; + do { + iVar6 = iVar7 * 2; + iVar7 = iVar7 + 1; + iVar9 = iVar9 + (uint)*(ushort *)(iVar6 + (int)p->payload); + } while (iVar7 < (int)(header_size_increment >> 1)); + } + uVar3 = pbuf_add_header(p,0x14); + if (CONCAT31(extraout_var_00,uVar3) == 0) { + puVar1 = (undefined *)p->payload; + puVar1[8] = ttl; + puVar1[9] = proto; + header_size_increment = dest->addr; + uVar8 = CONCAT31(in_register_00002035,ttl) << 8 | CONCAT31(in_register_0000203d,proto); + puVar1[0x10] = (char)header_size_increment; + puVar1[0x11] = (char)(header_size_increment >> 8); + puVar1[0x12] = (char)(header_size_increment >> 0x10); + __n = uVar2 >> 2 & 0xff | 0x40; + *puVar1 = (char)__n; + __n = __n << 8 | CONCAT31(in_register_00002039,tos); + puVar1[0x13] = (char)(header_size_increment >> 0x18); + puVar1[1] = tos; + uVar5 = lwip_htons(p->tot_len); + puVar1[2] = (char)uVar5; + n = ip_id; + puVar1[3] = (char)(uVar5 >> 8); + puVar1[6] = 0; + puVar1[7] = 0; + n = lwip_htons(n); + puVar1[5] = (char)(n >> 8); + puVar1[4] = (char)n; + ip_id = ip_id + 1; + if (src == (ip4_addr_t *)0x0) { + uVar2 = 0; + } + else { + uVar2 = src->addr; + } + puVar1[0xf] = (char)(uVar2 >> 0x18); + puVar1[0xc] = (char)uVar2; + puVar1[0xd] = (char)(uVar2 >> 8); + __n = (uVar2 & 0xffff) + + CONCAT22(extraout_var_02,n) + + (((int)__n >> 8 | __n << 8) & 0xffff) + + ((uVar8 << 8 | (int)uVar8 >> 8) & 0xffff) + + (header_size_increment & 0xffff) + (header_size_increment >> 0x10) + iVar9 + + CONCAT22(extraout_var_01,uVar5) + (uVar2 >> 0x10); + puVar1[0xe] = (char)(uVar2 >> 0x10); + __n = (__n & 0xffff) + (__n >> 0x10); + __n = ~((__n >> 0x10) + __n); + puVar1[10] = (char)__n; + puVar1[0xb] = (char)(__n >> 8); +LAB_2303f9c0: + lwip_stats.ip.xmit = lwip_stats.ip.xmit + 1; + eVar4 = (*netif->output)(netif,p,dest); + return eVar4; + } + } +LAB_2303f856: + lwip_stats.ip.err = lwip_stats.ip.err + 1; + return -2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +err_t ip4_output_if_opt(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto, + netif *netif,void *ip_options,u16_t optlen) + +{ + err_t eVar1; + + if ((dest != (ip4_addr_t *)0x0) && ((src == (ip4_addr_t *)0x0 || (src->addr == 0)))) { + src = (ip4_addr_t *)&netif->ip_addr; + } + eVar1 = ip4_output_if_opt_src(p,src,dest,ttl,tos,proto,netif,ip_options,optlen); + return eVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +err_t ip4_output_if(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto, + netif *netif) + +{ + err_t eVar1; + + eVar1 = ip4_output_if_opt(p,src,dest,ttl,tos,proto,netif,(void *)0x0,_DAT_00000010); + return eVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +err_t ip4_output_if_src(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto, + netif *netif) + +{ + err_t eVar1; + + eVar1 = ip4_output_if_opt_src(p,src,dest,ttl,tos,proto,netif,(void *)0x0,_DAT_00000010); + return eVar1; +} + + + +u8_t ip4_addr_isbroadcast_u32(u32_t addr,netif *netif) + +{ + byte bVar1; + uint uVar2; + uint uVar3; + + if (addr - 1 < 0xfffffffe) { + bVar1 = netif->flags & 2; + if ((netif->flags & 2) != 0) { + uVar3 = (netif->ip_addr).addr; + bVar1 = 0; + if ((uVar3 != addr) && (uVar2 = (netif->netmask).addr, ((uVar3 ^ addr) & uVar2) == 0)) { + uVar2 = ~uVar2; + return (u8_t)((uVar2 & addr) == uVar2); + } + } + } + else { + bVar1 = 1; + } + return (u8_t)bVar1; +} + + + +int ip4addr_aton(char *cp,ip4_addr_t *addr) + +{ + byte bVar1; + int iVar2; + u32_t n; + u32_t *puVar3; + uint uVar4; + uint uVar5; + int iVar6; + u32_t uStack32; + u32_t parts [4]; + + bVar1 = *cp; + puVar3 = &uStack32; +LAB_2303fabc: + uVar5 = (uint)bVar1; + if ((_ctype_[uVar5 + 1] & 4) == 0) { + return 0; + } + iVar6 = 10; + if (bVar1 == 0x30) { + uVar5 = (uint)(byte)cp[1]; + if ((uVar5 & 0xdf) == 0x58) { + uVar5 = (uint)(byte)cp[2]; + iVar6 = 0x10; + cp = cp + 2; + } + else { + cp = cp + 1; + iVar6 = 8; + } + } + n = 0; + do { + bVar1 = _ctype_[uVar5 + 1]; + if ((bVar1 & 4) == 0) { + if ((iVar6 != 0x10) || ((bVar1 & 0x44) == 0)) break; + iVar2 = 0x61; + if ((bVar1 & 3) != 2) { + iVar2 = 0x41; + } + n = n << 4 | (uVar5 + 10) - iVar2; + } + else { + n = (iVar6 * n + uVar5) - 0x30; + } + uVar5 = (uint)(byte)cp[1]; + cp = cp + 1; + } while( true ); + if (uVar5 == 0x2e) { + if (puVar3 == parts + 2) { + return 0; + } + *puVar3 = n; + bVar1 = cp[1]; + cp = cp + 1; + puVar3 = puVar3 + 1; + goto LAB_2303fabc; + } + if ((uVar5 != 0) && ((bVar1 & 8) == 0)) { + return 0; + } + iVar6 = (int)((int)puVar3 - (int)&uStack32) >> 2; + iVar2 = iVar6 + 1; + if (iVar2 == 2) { + if (0xffffff < n) { + return 0; + } + if (0xff < uStack32) { + return 0; + } + uVar5 = uStack32 << 0x18; + } + else { + if (iVar2 < 3) { + if (iVar6 == -1) { + return 0; + } + goto LAB_2303fb6a; + } + if (iVar2 == 3) { + if (0xffff < n) { + return 0; + } + if (0xff < uStack32) { + return 0; + } + if (0xff < parts[0]) { + return 0; + } + uVar5 = uStack32 << 0x18; + uVar4 = parts[0] << 0x10; + } + else { + if (iVar2 != 4) goto LAB_2303fb6a; + if (0xff < n) { + return 0; + } + if (0xff < uStack32) { + return 0; + } + if (0xff < parts[0]) { + return 0; + } + if (0xff < parts[1]) { + return 0; + } + uVar5 = uStack32 << 0x18 | parts[0] << 0x10; + uVar4 = parts[1] << 8; + } + uVar5 = uVar5 | uVar4; + } + n = n | uVar5; +LAB_2303fb6a: + if (addr != (ip4_addr_t *)0x0) { + n = lwip_htonl(n); + addr->addr = n; + return 1; + } + return 1; +} + + + +u32_t ipaddr_addr(char *cp) + +{ + int iVar1; + ip4_addr_t iStack20; + ip4_addr_t val; + + iVar1 = ip4addr_aton(cp,&iStack20); + if (iVar1 == 0) { + iStack20 = (ip4_addr_t)0xffffffff; + } + return (u32_t)iStack20; +} + + + +// WARNING: Could not reconcile some variable overlaps + +char * ip4addr_ntoa_r(ip4_addr_t *addr,char *buf,int buflen) + +{ + bool bVar1; + uint uVar2; + int iVar3; + int iVar4; + byte *pbVar5; + uint uVar6; + char *pcVar7; + uint uVar8; + uint uVar9; + char *pcVar10; + u32_t s_addr; + char local_8 [4]; + char inv [3]; + + _inv = addr->addr; + iVar3 = 0; + pbVar5 = (byte *)inv; + pcVar10 = buf; + while( true ) { + uVar2 = 0; + uVar9 = (uint)*pbVar5; + do { + uVar8 = uVar2; + uVar6 = uVar9 / 10; + local_8[uVar8] = (char)(uVar9 % 10) + '0'; + bVar1 = 9 < uVar9; + uVar2 = uVar8 + 1 & 0xff; + uVar9 = uVar6; + } while (bVar1); + *pbVar5 = (byte)uVar6; + iVar4 = iVar3; + pcVar7 = pcVar10; + while (iVar3 = iVar4 + 1, uVar8 != 0xff) { + if (buflen <= iVar4) { + return (char *)0x0; + } + *pcVar7 = local_8[uVar8]; + iVar4 = iVar3; + pcVar7 = pcVar7 + 1; + uVar8 = uVar8 - 1 & 0xff; + } + if (buflen <= iVar4) break; + *pcVar7 = '.'; + pbVar5 = pbVar5 + 1; + pcVar10 = pcVar7 + 1; + if (pbVar5 == (byte *)register0x00002008) { + *pcVar7 = '\0'; + return buf; + } + } + return (char *)0x0; +} + + + +char * ip4addr_ntoa(ip4_addr_t *addr) + +{ + char str [16]; + char *pcVar1; + + pcVar1 = ip4addr_ntoa_r(addr,(char *)&ram0x420151ac,0x10); + return pcVar1; +} + + + +void mem_init(void) + +{ + ram = ram_heap; + ram_heap._0_4_ = 0x2000; + ram_heap[4] = '\0'; + ram_end = (mem *)(ram_heap + 0x2000); + ram_heap._8192_4_ = 0x20002000; + ram_heap[8196] = '\x01'; + lfree = (mem *)ram_heap; + lwip_stats.mem.avail = 0x2000; + sys_mutex_new(&mem_mutex); + return; +} + + + +void mem_free(uint param_1) + +{ + ushort uVar1; + ushort uVar2; + short sVar3; + u8_t *puVar4; + mem *pmVar5; + mem *pmVar6; + mem *pmVar7; + uint uVar8; + mem *pmVar9; + + if (param_1 == 0) { + return; + } + if ((((param_1 & 3) == 0) && (pmVar6 = (mem *)(param_1 - 8), ram <= pmVar6)) && + ((mem *)(param_1 + 0xc) <= ram_end)) { + sys_mutex_lock(&mem_mutex); + pmVar5 = ram_end; + puVar4 = ram; + pmVar9 = lfree; + if (*(char *)(param_1 - 4) != '\0') { + uVar1 = *(ushort *)(param_1 - 8); + if ((uVar1 < 0x2001) && (uVar2 = *(ushort *)(param_1 - 6), uVar2 < 0x2001)) { + pmVar7 = (mem *)((int)pmVar6 - (int)ram); + uVar8 = (uint)pmVar7 & 0xffff; + if ((uVar8 == (uint)uVar2) || ((uint)*(ushort *)(ram + (uint)uVar2) == uVar8)) { + if (((mem *)(ram + uVar1) == ram_end) || ((uint)((mem *)(ram + uVar1))->prev == uVar8)) { + *(undefined *)(param_1 - 4) = 0; + if (pmVar6 < pmVar9) { + lfree = pmVar6; + } + sVar3 = (short)((uint)((int)pmVar7 * 0x10000) >> 0x10); + lwip_stats.mem.used = (lwip_stats.mem.used - uVar1) + sVar3; + pmVar9 = (mem *)(puVar4 + *(ushort *)(param_1 - 8)); + if (((pmVar6 != pmVar9) && (pmVar9->used == '\0')) && (pmVar5 != pmVar9)) { + if (pmVar9 == lfree) { + lfree = pmVar6; + } + *(mem_size_t *)(param_1 - 8) = pmVar9->next; + if (pmVar9->next != 0x2000) { + *(short *)(puVar4 + (uint)pmVar9->next + 2) = sVar3; + } + } + uVar1 = *(ushort *)(param_1 - 6); + pmVar9 = (mem *)(puVar4 + uVar1); + if ((pmVar6 != pmVar9) && (pmVar9->used == '\0')) { + if (pmVar6 == lfree) { + lfree = pmVar9; + } + pmVar9->next = *(mem_size_t *)(param_1 - 8); + if (*(ushort *)(param_1 - 8) != 0x2000) { + *(ushort *)(puVar4 + (uint)*(ushort *)(param_1 - 8) + 2) = uVar1; + } + } + sys_mutex_unlock(&mem_mutex); + return; + } + } + } + } + sys_mutex_unlock(&mem_mutex); + } + sys_arch_protect(); + lwip_stats.mem.illegal = lwip_stats.mem.illegal + 1; + sys_arch_unprotect(); + return; +} + + + +mem * mem_trim(mem *param_1,uint param_2) + +{ + mem_size_t mVar1; + short sVar2; + u8_t *puVar3; + uint uVar4; + mem_size_t mVar5; + uint uVar6; + uint uVar7; + mem *pmVar8; + mem *pmVar9; + undefined2 uVar10; + uint uVar11; + uint uVar12; + uint uVar13; + + uVar4 = param_2 + 3 & 0xfffc; + if (uVar4 < 0xc) { + uVar4 = 0xc; + } + else { + if (0x2000 < uVar4) { + return (mem *)0; + } + } + if (uVar4 < param_2) { + return (mem *)0; + } + if ((param_1 < ram) || (ram_end <= param_1)) { + sys_arch_protect(); + lwip_stats.mem.illegal = lwip_stats.mem.illegal + 1; + sys_arch_unprotect(); + return param_1; + } + uVar6 = (int)param_1 + (-8 - (int)ram); + uVar11 = (uint)*(ushort *)¶m_1[-2].used - 8; + uVar7 = uVar6 & 0xffff; + uVar12 = uVar11 & 0xffff; + uVar13 = uVar12 - uVar7 & 0xffff; + if (uVar13 < uVar4) { + return (mem *)0; + } + if (uVar13 == uVar4) { + return param_1; + } + sys_mutex_lock(&mem_mutex); + puVar3 = ram; + pmVar8 = (mem *)(ram + *(ushort *)¶m_1[-2].used); + mVar5 = (mem_size_t)uVar7; + if (pmVar8->used == '\0') { + uVar6 = uVar7 + 8 + uVar4; + mVar1 = pmVar8->next; + pmVar9 = (mem *)(ram + (uVar6 & 0xffff)); + if (lfree == pmVar8) { + lfree = pmVar9; + } + pmVar9->used = '\0'; + pmVar9->next = mVar1; + pmVar9->prev = mVar5; + uVar10 = (undefined2)(uVar6 * 0x10000 >> 0x10); + *(undefined2 *)¶m_1[-2].used = uVar10; + if (pmVar9->next != 0x2000) { + *(undefined2 *)(puVar3 + (uint)pmVar9->next + 2) = uVar10; + } + sVar2 = (mVar5 - (short)uVar12) + lwip_stats.mem.used; + } + else { + if (uVar13 < uVar4 + 0x14) goto LAB_2303ff8e; + uVar7 = uVar7 + 8 + uVar4; + pmVar8 = (mem *)(ram + (uVar7 & 0xffff)); + if (pmVar8 < lfree) { + lfree = pmVar8; + } + pmVar8->used = '\0'; + mVar1 = *(mem_size_t *)¶m_1[-2].used; + pmVar8->prev = mVar5; + pmVar8->next = mVar1; + uVar10 = (undefined2)(uVar7 * 0x10000 >> 0x10); + *(undefined2 *)¶m_1[-2].used = uVar10; + if (pmVar8->next != 0x2000) { + *(undefined2 *)(puVar3 + (uint)pmVar8->next + 2) = uVar10; + } + sVar2 = ((short)(uVar6 * 0x10000 >> 0x10) - (short)(uVar11 * 0x10000 >> 0x10)) + + lwip_stats.mem.used; + } + lwip_stats.mem.used = (short)uVar4 + sVar2; +LAB_2303ff8e: + sys_mutex_unlock(&mem_mutex); + return param_1; +} + + + +mem_size_t * mem_malloc(uint param_1) + +{ + ushort uVar1; + u8_t *puVar2; + mem_size_t *pmVar3; + mem *pmVar4; + uint uVar5; + uint uVar6; + ushort *puVar7; + mem_size_t mVar8; + uint uVar9; + uint uVar10; + mem *pmVar11; + + if (param_1 == 0) { +LAB_23040080: + pmVar3 = (mem_size_t *)0x0; + } + else { + uVar5 = param_1 + 3 & 0xfffc; + if (uVar5 < 0xc) { + uVar5 = 0xc; + } + else { + if (0x2000 < uVar5) { + return (mem_size_t *)0; + } + } + pmVar3 = (mem_size_t *)0x0; + if (param_1 <= uVar5) { + sys_mutex_lock(&mem_mutex); + puVar2 = ram; + pmVar11 = lfree; + uVar9 = (uint)((int)lfree - (int)ram) & 0xffff; + do { + uVar10 = uVar9; + if (0x2000 - uVar5 <= uVar10) { + lwip_stats.mem.err = lwip_stats.mem.err + 1; + sys_mutex_unlock(&mem_mutex); + goto LAB_23040080; + } + pmVar4 = (mem *)(ram + uVar10); + uVar9 = (uint)pmVar4->next; + } while ((pmVar4->used != '\0') || (uVar6 = (-8 - uVar10) + uVar9, uVar6 < uVar5)); + if (uVar6 < uVar5 + 0x14) { + pmVar4->used = '\x01'; + uVar10 = (uVar9 + lwip_stats.mem.used) - uVar10; + lwip_stats.mem.used = (mem_size_t)(uVar10 * 0x10000 >> 0x10); + if ((uint)lwip_stats.mem.max < (uVar10 & 0xffff)) { + lwip_stats.mem.max = lwip_stats.mem.used; + } + } + else { + uVar9 = uVar5 + 8 + uVar10; + puVar7 = (ushort *)(ram + (uVar9 & 0xffff)); + *(undefined *)(puVar7 + 2) = 0; + uVar1 = pmVar4->next; + puVar7[1] = (ushort)uVar10; + *puVar7 = uVar1; + mVar8 = (mem_size_t)(uVar9 * 0x10000 >> 0x10); + pmVar4->next = mVar8; + pmVar4->used = '\x01'; + if (*puVar7 != 0x2000) { + *(mem_size_t *)(puVar2 + (uint)*puVar7 + 2) = mVar8; + } + uVar5 = uVar5 + (uint)lwip_stats.mem.used + 8; + lwip_stats.mem.used = (mem_size_t)(uVar5 * 0x10000 >> 0x10); + if ((uint)lwip_stats.mem.max < (uVar5 & 0xffff)) { + lwip_stats.mem.max = lwip_stats.mem.used; + } + } + if (pmVar11 == pmVar4) { + while ((lfree = pmVar11, pmVar11->used != '\0' && (ram_end != pmVar11))) { + pmVar11 = (mem *)(puVar2 + pmVar11->next); + } + } + sys_mutex_unlock(&mem_mutex); + pmVar3 = &pmVar4[1].prev; + } + } + return pmVar3; +} + + + +// WARNING: Type propagation algorithm not settling + +void * do_memp_malloc_pool(memp_desc *desc) + +{ + memp mVar1; + sys_prot_t sVar2; + stats_mem *psVar3; + + sVar2 = sys_arch_protect(); + mVar1 = (memp)((memp *)desc->tab)->next; + if (mVar1 == (memp)0x0) { + desc->stats->err = desc->stats->err + 1; + } + else { + *(memp *)&((memp *)desc->tab)->next = *(memp *)mVar1; + desc->stats->used = desc->stats->used + 1; + psVar3 = desc->stats; + if (psVar3->max < psVar3->used) { + psVar3->max = psVar3->used; + } + } + sys_arch_unprotect(sVar2); + return (void *)mVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +void memp_init_pool(memp_desc *desc) + +{ + int iVar1; + memp mVar2; + + iVar1 = 0; + *desc->tab = (memp *)0x0; + mVar2 = (memp)((uint)(desc->base + 3) & 0xfffffffc); + while (iVar1 < (int)(uint)desc->num) { + iVar1 = iVar1 + 1; + *(memp **)mVar2 = ((memp *)desc->tab)->next; + *(memp *)&((memp *)desc->tab)->next = mVar2; + mVar2 = (memp)((int)mVar2 + (uint)desc->size); + } + desc->stats->avail = desc->num; + return; +} + + + +void memp_init(void) + +{ + stats_ *psVar1; + int iVar2; + memp_desc *desc; + + iVar2 = 0; + psVar1 = &lwip_stats; + do { + desc = *(memp_desc **)((int)memp_pools + iVar2); + iVar2 = iVar2 + 4; + memp_init_pool(desc); + psVar1->memp[0] = desc->stats; + psVar1 = (stats_ *)&(psVar1->link).fw; + } while (iVar2 != 0x3c); + return; +} + + + +void * memp_malloc(memp_t type) + +{ + undefined3 in_register_00002029; + void *pvVar1; + + if (CONCAT31(in_register_00002029,type) < 0xf) { + pvVar1 = do_memp_malloc_pool(memp_pools[CONCAT31(in_register_00002029,type)]); + return pvVar1; + } + return (void *)0x0; +} + + + +void memp_free(memp_t type,void *mem) + +{ + memp_desc *pmVar1; + undefined3 in_register_00002029; + + if ((CONCAT31(in_register_00002029,type) < 0xf) && (mem != (void *)0x0)) { + pmVar1 = memp_pools[CONCAT31(in_register_00002029,type)]; + sys_arch_protect(); + pmVar1->stats->used = pmVar1->stats->used - 1; + *(memp **)mem = *pmVar1->tab; + *pmVar1->tab = mem; + sys_arch_unprotect(); + return; + } + return; +} + + + +err_t netif_null_output_ip4(netif *netif,pbuf *p,ip4_addr_t *ipaddr) + +{ + return -0xc; +} + + + +void netif_issue_reports(netif *netif,u8_t report_type) + +{ + if (((netif->flags & 5) != 5) || ((report_type & 1) == 0)) { + return; + } + if ((netif->ip_addr).addr != 0) { + if ((netif->flags & 8) != 0) { + etharp_request(netif,(ip4_addr_t *)&netif->ip_addr); + } + if ((netif->flags & 0x20) != 0) { + igmp_report_groups(netif); + return; + } + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: new_addr +// WARNING: Type propagation algorithm not settling + +int netif_do_set_ipaddr(netif *netif,ip4_addr_t *ipaddr,ip_addr_t *old_addr) + +{ + ip_addr_t iVar1; + ip_addr_t iStack20; + ip_addr_t new_addr; + + iVar1 = (ip_addr_t)(netif->ip_addr).addr; + iStack20 = (ip_addr_t)ipaddr->addr; + if (iStack20 != iVar1) { + *(ip_addr_t *)&old_addr->addr = iVar1; + tcp_netif_ip_addr_changed(old_addr,&iStack20); + udp_netif_ip_addr_changed(old_addr,&iStack20); + raw_netif_ip_addr_changed(old_addr,&iStack20); + (netif->ip_addr).addr = ipaddr->addr; + netif_issue_reports(netif,'\x01'); + if (netif->status_callback != (netif_status_callback_fn *)0x0) { + (*netif->status_callback)(netif); + } + return 1; + } + return 0; +} + + + +void netif_init(void) + +{ + return; +} + + + +void netif_set_ipaddr(netif *netif,ip4_addr_t *ipaddr) + +{ + ip_addr_t iStack20; + ip_addr_t old_addr; + + if (netif != (netif *)0x0) { + if (ipaddr == (ip4_addr_t *)0x0) { + ipaddr = (ip4_addr_t *)&ip_addr_any; + } + netif_do_set_ipaddr(netif,ipaddr,&iStack20); + return; + } + return; +} + + + +void netif_set_netmask(netif *netif,ip4_addr_t *netmask) + +{ + if (netif != (netif *)0x0) { + if (netmask == (ip4_addr_t *)0x0) { + netmask = (ip4_addr_t *)&ip_addr_any; + } + if (netmask->addr != (netif->netmask).addr) { + (netif->netmask).addr = netmask->addr; + } + } + return; +} + + + +void netif_set_gw(netif *netif,ip4_addr_t *gw) + +{ + if (netif != (netif *)0x0) { + if (gw == (ip4_addr_t *)0x0) { + gw = (ip4_addr_t *)&ip_addr_any; + } + if (gw->addr != (netif->gw).addr) { + (netif->gw).addr = gw->addr; + } + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: old_addr + +void netif_set_addr(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw) + +{ + bool bVar1; + ip_addr_t iStack20; + ip_addr_t old_addr; + + if (ipaddr == (ip4_addr_t *)0x0) { + ipaddr = (ip4_addr_t *)&ip_addr_any; + } + if (netmask == (ip4_addr_t *)0x0) { + netmask = (ip4_addr_t *)&ip_addr_any; + } + if (gw == (ip4_addr_t *)0x0) { + gw = (ip4_addr_t *)&ip_addr_any; + } + bVar1 = ipaddr->addr == 0; + if (bVar1) { + netif_do_set_ipaddr(netif,ipaddr,&iStack20); + } + if (netmask->addr != (netif->netmask).addr) { + (netif->netmask).addr = netmask->addr; + } + if (gw->addr != (netif->gw).addr) { + (netif->gw).addr = gw->addr; + } + if (!bVar1) { + netif_do_set_ipaddr(netif,ipaddr,&iStack20); + } + return; +} + + + +netif * netif_add(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw,void *state, + netif_init_fn_conflict *init,netif_input_fn *input) + +{ + u8_t uVar1; + err_t eVar2; + undefined3 extraout_var; + netif *pnVar3; + + if ((netif != (netif *)0x0) && (init != (netif_init_fn_conflict *)0x0)) { + if (ipaddr == (ip4_addr_t *)0x0) { + ipaddr = (ip4_addr_t *)&ip_addr_any; + } + if (netmask == (ip4_addr_t *)0x0) { + netmask = (ip4_addr_t *)&ip_addr_any; + } + if (gw == (ip4_addr_t *)0x0) { + gw = (ip4_addr_t *)&ip_addr_any; + } + netif->output = netif_null_output_ip4; + (netif->ip_addr).addr = 0; + (netif->netmask).addr = 0; + (netif->gw).addr = 0; + netif->mtu = 0; + netif->flags = '\0'; + memset(netif->client_data,0,0xc); + netif->state = state; + uVar1 = netif_num; + netif->input = input; + netif->num = uVar1; + netif->status_callback = (netif_status_callback_fn *)0x0; + netif->link_callback = (netif_status_callback_fn *)0x0; + netif->igmp_mac_filter = (netif_igmp_mac_filter_fn *)0x0; + netif_set_addr(netif,ipaddr,netmask,gw); + eVar2 = (*init)(netif); + if (CONCAT31(extraout_var,eVar2) == 0) { + do { + if (netif->num == -1) { + netif->num = '\0'; + } + uVar1 = netif->num; + pnVar3 = netif_list; + while( true ) { + if (pnVar3 == (netif *)0x0) { + netif_num = '\0'; + if (uVar1 != -2) { + netif_num = uVar1 + '\x01'; + } + netif->next = netif_list; + if ((netif->flags & 0x20) == 0) { + netif_list = netif; + return netif; + } + netif_list = netif; + igmp_start(netif); + return netif; + } + if (pnVar3->num == uVar1) break; + pnVar3 = pnVar3->next; + } + netif->num = uVar1 + '\x01'; + } while( true ); + } + } + return (netif *)0x0; +} + + + +void netif_set_default(netif *netif) + +{ + netif_default = netif; + return; +} + + + +void netif_set_up(netif *netif) + +{ + if (netif == (netif *)0x0) { + return; + } + if ((netif->flags & 1) == 0) { + netif->flags = netif->flags | 1; + if (netif->status_callback != (netif_status_callback_fn *)0x0) { + (*netif->status_callback)(netif); + } + netif_issue_reports(netif,'\x03'); + return; + } + return; +} + + + +void netif_set_down(netif *netif) + +{ + byte bVar1; + + if (netif == (netif *)0x0) { + return; + } + bVar1 = netif->flags; + if ((bVar1 & 1) != 0) { + netif->flags = bVar1 & 0xfe; + if ((bVar1 & 8) != 0) { + etharp_cleanup_netif(netif); + } + if (netif->status_callback != (netif_status_callback_fn *)0x0) { + // WARNING: Could not recover jumptable at 0x23040594. Too many branches + // WARNING: Treating indirect jump as call + (*netif->status_callback)(netif); + return; + } + } + return; +} + + + +void netif_remove(netif *netif) + +{ + netif *pnVar1; + ip_addr_t *old_addr; + netif *pnVar2; + + if (netif == (netif *)0x0) { + return; + } + if ((netif->ip_addr).addr != 0) { + old_addr = &netif->ip_addr; + tcp_netif_ip_addr_changed(old_addr,(ip_addr_t *)0x0); + udp_netif_ip_addr_changed(old_addr,(ip_addr_t *)0x0); + raw_netif_ip_addr_changed(old_addr,(ip_addr_t *)0x0); + } + if ((netif->flags & 0x20) != 0) { + igmp_stop(netif); + } + if ((netif->flags & 1) != 0) { + netif_set_down(netif); + } + if (netif_default == netif) { + netif_default = (netif *)0x0; + } + pnVar1 = netif_list; + if (netif_list == netif) { + netif_list = netif->next; + } + else { + do { + pnVar2 = pnVar1; + if (pnVar2 == (netif *)0x0) { + return; + } + pnVar1 = pnVar2->next; + } while (pnVar2->next != netif); + pnVar2->next = netif->next; + } + return; +} + + + +void netif_set_status_callback(netif *netif,netif_status_callback_fn *status_callback) + +{ + if (netif != (netif *)0x0) { + netif->status_callback = status_callback; + } + return; +} + + + +void netif_set_link_up(netif *netif) + +{ + if (netif == (netif *)0x0) { + return; + } + if ((netif->flags & 4) == 0) { + netif->flags = netif->flags | 4; + dhcp_network_changed(netif); + netif_issue_reports(netif,'\x03'); + if (netif->link_callback != (netif_status_callback_fn *)0x0) { + // WARNING: Could not recover jumptable at 0x23040666. Too many branches + // WARNING: Treating indirect jump as call + (*netif->link_callback)(netif); + return; + } + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void netif_set_link_down(netif *netif) + +{ + if (netif != (netif *)0x0) { + if ((netif->flags & 4) != 0) { + netif->flags = netif->flags & 0xfb; + if (netif->link_callback != (netif_status_callback_fn *)0x0) { + // WARNING: Could not recover jumptable at 0x2304068c. Too many branches + // WARNING: Treating indirect jump as call + (*netif->link_callback)(); + return; + } + } + } + return; +} + + + +netif * netif_get_by_index(u8_t idx) + +{ + undefined3 in_register_00002029; + netif *pnVar1; + netif *pnVar2; + + pnVar1 = netif_list; + pnVar2 = (netif *)0x0; + if (CONCAT31(in_register_00002029,idx) != 0) { + while ((pnVar2 = pnVar1, pnVar1 != (netif *)0x0 && + (((uint)pnVar1->num + 1 & 0xff) != CONCAT31(in_register_00002029,idx)))) { + pnVar1 = pnVar1->next; + } + } + return pnVar2; +} + + + +netif * netif_find(char *name) + +{ + uint uVar1; + netif *pnVar2; + + if (name == (char *)0x0) { + return (netif *)0x0; + } + uVar1 = atoi(name + 2); + pnVar2 = netif_list; + while( true ) { + if (pnVar2 == (netif *)0x0) { + return (netif *)0x0; + } + if ((((uint)pnVar2->num == (uVar1 & 0xff)) && (*name == pnVar2->name[0])) && + (name[1] == pnVar2->name[1])) break; + pnVar2 = pnVar2->next; + } + return pnVar2; +} + + + +pbuf * pbuf_skip_const(pbuf *in,u16_t in_offset,u16_t *out_offset) + +{ + pbuf *ppVar1; + undefined2 in_register_0000202e; + + if ((in != (pbuf *)0x0) && ((uint)in->len <= CONCAT22(in_register_0000202e,in_offset))) { + ppVar1 = pbuf_skip_const(in->next,(u16_t)((CONCAT22(in_register_0000202e,in_offset) - + (uint)in->len) * 0x10000 >> 0x10),out_offset); + return ppVar1; + } + if (out_offset != (u16_t *)0x0) { + *out_offset = in_offset; + } + return in; +} + + + +void pbuf_free_ooseq_callback(void *arg) + +{ + tcp_pcb *pcb; + + sys_arch_protect(); + pbuf_free_ooseq_pending = '\0'; + sys_arch_unprotect(); + pcb = tcp_active_pcbs; + while( true ) { + if (pcb == (tcp_pcb *)0x0) { + return; + } + if (pcb->ooseq != (tcp_seg *)0x0) break; + pcb = pcb->next; + } + tcp_free_ooseq(pcb); + return; +} + + + +u8_t pbuf_add_header_impl(pbuf *p,size_t header_size_increment,u8_t force) + +{ + u8_t uVar1; + pbuf *ppVar2; + undefined3 in_register_00002031; + uint uVar3; + + if (p == (pbuf *)0x0) { + uVar1 = '\x01'; + } + else { + uVar1 = '\x01'; + if ((header_size_increment < 0x10000) && (uVar1 = '\0', header_size_increment != 0)) { + uVar3 = (uint)p->tot_len + (header_size_increment & 0xffff); + uVar1 = '\x01'; + if ((header_size_increment & 0xffff) <= (uVar3 & 0xffff)) { + if ((char)p->type_internal < '\0') { + ppVar2 = (pbuf *)((int)p->payload - header_size_increment); + if (ppVar2 < p + 1) { + return '\x01'; + } + } + else { + if (CONCAT31(in_register_00002031,force) == 0) { + return '\x01'; + } + ppVar2 = (pbuf *)((int)p->payload - header_size_increment); + } + *(pbuf **)&p->payload = ppVar2; + p->tot_len = (u16_t)(uVar3 * 0x10000 >> 0x10); + p->len = (short)header_size_increment + p->len; + return '\0'; + } + } + } + return uVar1; +} + + + +pbuf * pbuf_alloc_reference(void *payload,u16_t length,pbuf_type type) + +{ + pbuf *ppVar1; + + ppVar1 = (pbuf *)memp_malloc(MEMP_PBUF); + if (ppVar1 != (pbuf *)0x0) { + ppVar1->next = (pbuf *)0x0; + ppVar1->payload = payload; + ppVar1->tot_len = length; + ppVar1->len = length; + ppVar1->type_internal = (u8_t)type; + ppVar1->flags = '\0'; + *(undefined2 *)&ppVar1->ref = 1; + } + return ppVar1; +} + + + +pbuf * pbuf_alloced_custom(pbuf_layer l,u16_t length,pbuf_type type,pbuf_custom *p,void *payload_mem + ,u16_t payload_mem_len) + +{ + undefined3 in_register_00002029; + uint uVar1; + undefined2 in_register_0000202e; + undefined2 in_register_0000203e; + + uVar1 = CONCAT31(in_register_00002029,l) + 3U & 0xfffffffc; + if (CONCAT22(in_register_0000202e,length) + uVar1 <= + CONCAT22(in_register_0000203e,payload_mem_len)) { + if (payload_mem != (void *)0x0) { + payload_mem = (void *)((int)payload_mem + uVar1); + } + (p->pbuf).flags = '\x02'; + (p->pbuf).next = (pbuf *)0x0; + (p->pbuf).payload = payload_mem; + (p->pbuf).tot_len = length; + (p->pbuf).len = length; + (p->pbuf).type_internal = (u8_t)type; + *(undefined2 *)&(p->pbuf).ref = 1; + return (pbuf *)p; + } + return (pbuf *)0x0; +} + + + +u8_t pbuf_add_header(pbuf *p,size_t header_size_increment) + +{ + u8_t uVar1; + + uVar1 = pbuf_add_header_impl(p,header_size_increment,'\0'); + return uVar1; +} + + + +u8_t pbuf_remove_header(pbuf *p,size_t header_size_decrement) + +{ + u8_t uVar1; + + if (p == (pbuf *)0x0) { + uVar1 = '\x01'; + } + else { + uVar1 = '\x01'; + if ((header_size_decrement < 0x10000) && (uVar1 = '\0', header_size_decrement != 0)) { + uVar1 = '\x01'; + if ((header_size_decrement & 0xffff) <= (uint)p->len) { + p->len = p->len - (short)header_size_decrement; + p->payload = (void *)(header_size_decrement + (int)p->payload); + p->tot_len = p->tot_len - (short)header_size_decrement; + return '\0'; + } + } + } + return uVar1; +} + + + +u8_t pbuf_header(pbuf *p,s16_t header_size_increment) + +{ + u8_t uVar1; + short in_register_0000202e; + + if (in_register_0000202e < 0) { + uVar1 = pbuf_remove_header(p,-CONCAT22(in_register_0000202e,header_size_increment)); + return uVar1; + } + uVar1 = pbuf_add_header_impl(p,CONCAT22(in_register_0000202e,header_size_increment),'\0'); + return uVar1; +} + + + +u8_t pbuf_header_force(pbuf *p,s16_t header_size_increment) + +{ + u8_t uVar1; + short in_register_0000202e; + + if (in_register_0000202e < 0) { + uVar1 = pbuf_remove_header(p,-CONCAT22(in_register_0000202e,header_size_increment)); + return uVar1; + } + uVar1 = pbuf_add_header_impl(p,CONCAT22(in_register_0000202e,header_size_increment),'\x01'); + return uVar1; +} + + + +u8_t pbuf_free(pbuf *p) + +{ + u8_t uVar1; + u8_t uVar2; + pbuf *ppVar3; + memp_t type; + byte bVar4; + + uVar1 = '\0'; + if (p != (pbuf *)0x0) { + uVar1 = '\0'; + do { + sys_arch_protect(); + uVar2 = p->ref + -1; + p->ref = uVar2; + sys_arch_unprotect(); + if (uVar2 != '\0') { + return uVar1; + } + ppVar3 = p->next; + if ((p->flags & 2) == 0) { + type = MEMP_PBUF_POOL; + bVar4 = p->type_internal & 0xf; + if (bVar4 != 2) { + if (bVar4 != 1) { + if ((p->type_internal & 0xf) == 0) { + mem_free(p); + } + goto LAB_230408d6; + } + type = MEMP_PBUF; + } + memp_free(type,p); + } + else { + (*(code *)p[1].next)(p,p[1].next); + } +LAB_230408d6: + uVar1 = uVar1 + '\x01'; + p = ppVar3; + } while (ppVar3 != (pbuf *)0x0); + } + return uVar1; +} + + + +pbuf * pbuf_alloc(pbuf_layer layer,u16_t length,pbuf_type type) + +{ + u8_t uVar1; + uint uVar2; + uint uVar3; + pbuf *ppVar4; + err_t eVar5; + undefined3 in_register_00002029; + pbuf *p; + pbuf *ppVar6; + undefined3 extraout_var; + undefined2 in_register_0000202e; + undefined2 in_register_00002032; + uint uVar7; + pbuf *ppVar8; + + uVar7 = CONCAT22(in_register_00002032,type); + uVar3 = CONCAT22(in_register_0000202e,length); + if (uVar7 != 0x41) { + if (uVar7 < 0x42) { + if (uVar7 == 1) goto LAB_230409bc; + } + else { + uVar2 = CONCAT31(in_register_00002029,layer) & 0xffff; + if (uVar7 == 0x182) { + p = (pbuf *)0x0; + ppVar8 = (pbuf *)0x0; + while (ppVar6 = (pbuf *)memp_malloc(MEMP_PBUF_POOL), ppVar6 != (pbuf *)0x0) { + uVar7 = 0x2f8 - (uVar2 + 3 & 0xfffffffc); + if (uVar3 < (uVar7 & 0xffff)) { + uVar7 = uVar3; + } + ppVar6->next = (pbuf *)0x0; + ppVar6->payload = (void *)((int)&ppVar6[1].next + uVar2 + 3 & 0xfffffffc); + ppVar6->tot_len = (u16_t)uVar3; + ppVar6->len = (u16_t)uVar7; + *(undefined4 *)&ppVar6->type_internal = 0x10082; + ppVar4 = ppVar6; + if (p != (pbuf *)0x0) { + ppVar8->next = ppVar6; + ppVar4 = p; + } + uVar3 = uVar3 - (uVar7 & 0xffff) & 0xffff; + uVar2 = 0; + p = ppVar4; + ppVar8 = ppVar6; + if (uVar3 == 0) { + return ppVar4; + } + } + sys_arch_protect(); + uVar1 = pbuf_free_ooseq_pending; + pbuf_free_ooseq_pending = '\x01'; + sys_arch_unprotect(); + if ((uVar1 == '\0') && + (eVar5 = tcpip_try_callback(pbuf_free_ooseq_callback,(void *)0x0), + CONCAT31(extraout_var,eVar5) != 0)) { + sys_arch_protect(); + pbuf_free_ooseq_pending = '\0'; + sys_arch_unprotect(); + } + if (p != (pbuf *)0x0) { + pbuf_free(p); + } + } + else { + if (uVar7 == 0x280) { + uVar7 = uVar3 + 3 & 0xfffffffc; + uVar3 = (uVar2 + 3 & 0xfffffffc) + uVar7 & 0xffff; + if ((uVar7 <= uVar3) && (uVar7 <= (uVar3 + 0x10 & 0xffff))) { + p = (pbuf *)mem_malloc(); + if (p == (pbuf *)0x0) { + return (pbuf *)0x0; + } + p->next = (pbuf *)0x0; + p->payload = (void *)((int)&p[1].next + CONCAT31(in_register_00002029,layer) + 3 & + 0xfffffffc); + p->tot_len = length; + p->len = length; + *(undefined4 *)&p->type_internal = 0x10080; + return p; + } + } + } + } + return (pbuf *)0x0; + } +LAB_230409bc: + p = pbuf_alloc_reference((void *)0x0,length,type); + return p; +} + + + +void pbuf_realloc(pbuf *p,u16_t new_len) + +{ + ushort uVar1; + uint uVar2; + undefined2 in_register_0000202e; + uint uVar3; + + uVar2 = CONCAT22(in_register_0000202e,new_len); + uVar1 = p->tot_len; + if (uVar2 < uVar1) { + while (uVar3 = (uint)p->len, uVar3 < uVar2) { + p->tot_len = p->tot_len + (new_len - uVar1); + uVar2 = uVar2 - uVar3 & 0xffff; + p = p->next; + } + if ((((p->type_internal & 0xf) == 0) && (uVar3 != uVar2)) && ((p->flags & 2) == 0)) { + p = (pbuf *)mem_trim(p,(int)p->payload + (uVar2 - (int)p) & 0xffff); + } + p->len = (u16_t)uVar2; + p->tot_len = (u16_t)uVar2; + if (p->next != (pbuf *)0x0) { + pbuf_free(p->next); + } + p->next = (pbuf *)0x0; + return; + } + return; +} + + + +pbuf * pbuf_free_header(pbuf *q,u16_t size) + +{ + pbuf *ppVar1; + undefined2 in_register_0000202e; + uint header_size_decrement; + + header_size_decrement = CONCAT22(in_register_0000202e,size); + while( true ) { + if (header_size_decrement == 0) { + return q; + } + if (q == (pbuf *)0x0) break; + if (header_size_decrement < q->len) { + pbuf_remove_header(q,header_size_decrement); + return q; + } + ppVar1 = q->next; + header_size_decrement = header_size_decrement - q->len & 0xffff; + q->next = (pbuf *)0x0; + pbuf_free(q); + q = ppVar1; + } + return (pbuf *)0x0; +} + + + +u16_t pbuf_clen(pbuf *p) + +{ + u16_t uVar1; + + uVar1 = 0; + while (p != (pbuf *)0x0) { + uVar1 = uVar1 + 1; + p = p->next; + } + return uVar1; +} + + + +void pbuf_ref(pbuf *p) + +{ + if (p != (pbuf *)0x0) { + sys_arch_protect(); + p->ref = p->ref + '\x01'; + sys_arch_unprotect(); + return; + } + return; +} + + + +void pbuf_cat(pbuf *h,pbuf *t) + +{ + pbuf *ppVar1; + + if (h != (pbuf *)0x0) { + if (t == (pbuf *)0x0) { + return; + } + do { + ppVar1 = h; + ppVar1->tot_len = (u16_t)(((uint)ppVar1->tot_len + (uint)t->tot_len) * 0x10000 >> 0x10); + h = ppVar1->next; + } while (ppVar1->next != (pbuf *)0x0); + ppVar1->next = t; + } + return; +} + + + +void pbuf_chain(pbuf *h,pbuf *t) + +{ + pbuf_cat(h,t); + pbuf_ref(t); + return; +} + + + +err_t pbuf_copy(pbuf *p_to,pbuf *p_from) + +{ + err_t eVar1; + uint uVar2; + uint __n; + uint uVar3; + uint uVar4; + + if (p_to == (pbuf *)0x0) { + return -0x10; + } + if ((p_from == (pbuf *)0x0) || (p_to->tot_len < p_from->tot_len)) { +LAB_23040c06: + eVar1 = -0x10; + } + else { + uVar4 = 0; + uVar3 = 0; + do { + __n = p_to->len - uVar3; + uVar2 = p_from->len - uVar4; + if (uVar2 < __n) { + __n = uVar2; + } + memcpy((void *)((int)p_to->payload + uVar3),(void *)((int)p_from->payload + uVar4),__n); + uVar4 = uVar4 + __n; + uVar3 = uVar3 + __n; + if (p_from->len <= uVar4) { + p_from = p_from->next; + uVar4 = 0; + } + if (uVar3 == (uint)p_to->len) { + p_to = p_to->next; + if (p_to == (pbuf *)0x0) { + if (p_from == (pbuf *)0x0) { + return '\0'; + } + goto LAB_23040c06; + } + uVar3 = 0; + } + if ((((p_from != (pbuf *)0x0) && (p_from->len == p_from->tot_len)) && + (p_from->next != (pbuf *)0x0)) || + ((p_to->len == p_to->tot_len && (p_to->next != (pbuf *)0x0)))) { + return -6; + } + } while (p_from != (pbuf *)0x0); + eVar1 = '\0'; + } + return eVar1; +} + + + +u16_t pbuf_copy_partial(pbuf *buf,void *dataptr,u16_t len,u16_t offset) + +{ + u16_t uVar1; + uint uVar2; + uint uVar3; + uint __n; + undefined2 in_register_00002032; + undefined2 in_register_00002036; + uint uVar4; + + uVar4 = CONCAT22(in_register_00002036,offset); + uVar3 = CONCAT22(in_register_00002032,len); + uVar1 = 0; + if (buf != (pbuf *)0x0) { + uVar2 = 0; + uVar1 = 0; + if (dataptr != (void *)0x0) { + while ((uVar1 = (u16_t)uVar2, uVar3 != 0 && (buf != (pbuf *)0x0))) { + __n = (uint)buf->len; + if ((uVar4 == 0) || (uVar4 < __n)) { + __n = __n - uVar4 & 0xffff; + if (uVar3 < __n) { + __n = uVar3; + } + __n = __n & 0xffff; + memcpy((void *)((int)dataptr + uVar2),(void *)((int)buf->payload + uVar4),__n); + uVar2 = uVar2 + __n & 0xffff; + uVar3 = uVar3 - __n & 0xffff; + uVar4 = 0; + } + else { + uVar4 = uVar4 - __n & 0xffff; + } + buf = buf->next; + } + } + } + return uVar1; +} + + + +err_t pbuf_take(pbuf *buf,void *dataptr,u16_t len) + +{ + uint uVar1; + err_t eVar2; + undefined2 in_register_00002032; + uint __n; + int iVar3; + + uVar1 = CONCAT22(in_register_00002032,len); + if (buf != (pbuf *)0x0) { + eVar2 = -0x10; + if (dataptr != (void *)0x0) { + eVar2 = -1; + iVar3 = 0; + if (uVar1 <= buf->tot_len) { + while (uVar1 != 0) { + __n = (uint)buf->len; + if (uVar1 < (uint)buf->len) { + __n = uVar1; + } + memcpy(buf->payload,(void *)((int)dataptr + iVar3),__n); + buf = buf->next; + uVar1 = uVar1 - __n; + iVar3 = iVar3 + __n; + } + eVar2 = '\0'; + } + } + return eVar2; + } + return -0x10; +} + + + +err_t pbuf_take_at(pbuf *buf,void *dataptr,u16_t len,u16_t offset) + +{ + err_t eVar1; + pbuf *ppVar2; + undefined2 in_register_00002032; + size_t sVar3; + uint uVar4; + uint uVar5; + size_t __n; + u16_t auStack34 [2]; + u16_t target_offset; + + sVar3 = CONCAT22(in_register_00002032,len); + ppVar2 = pbuf_skip_const(buf,offset,auStack34); + if (ppVar2 == (pbuf *)0x0) { + eVar1 = -1; + } + else { + uVar4 = (uint)auStack34[0]; + eVar1 = -1; + if ((int)(uVar4 + sVar3) <= (int)(uint)ppVar2->tot_len) { + uVar5 = ppVar2->len - uVar4; + __n = sVar3; + if ((int)uVar5 < (int)sVar3) { + __n = uVar5 & 0xffff; + } + memcpy((void *)((int)ppVar2->payload + uVar4),dataptr,__n); + eVar1 = '\0'; + if ((sVar3 - __n & 0xffff) != 0) { + eVar1 = pbuf_take(ppVar2->next,(void *)((int)dataptr + __n), + (u16_t)((sVar3 - __n) * 0x10000 >> 0x10)); + } + } + } + return eVar1; +} + + + +pbuf * pbuf_clone(pbuf_layer layer,pbuf_type type,pbuf *p) + +{ + pbuf *p_to; + + p_to = pbuf_alloc(layer,p->tot_len,type); + if (p_to != (pbuf *)0x0) { + pbuf_copy(p_to,p); + } + return p_to; +} + + + +int pbuf_try_get_at(pbuf *p,u16_t offset) + +{ + pbuf *ppVar1; + uint uVar2; + u16_t auStack18 [2]; + u16_t q_idx; + + ppVar1 = pbuf_skip_const(p,offset,auStack18); + uVar2 = 0xffffffff; + if (ppVar1 != (pbuf *)0x0) { + uVar2 = 0xffffffff; + if ((uint)auStack18[0] < (uint)ppVar1->len) { + uVar2 = (uint)*(byte *)((int)ppVar1->payload + (uint)auStack18[0]); + } + } + return uVar2; +} + + + +u8_t pbuf_get_at(pbuf *p,u16_t offset) + +{ + u8_t uVar1; + + _uVar1 = pbuf_try_get_at(p,offset); + uVar1 = (u8_t)_uVar1; + if (_uVar1 < 0) { + uVar1 = '\0'; + } + return uVar1; +} + + + +void pbuf_put_at(pbuf *p,u16_t offset,u8_t data) + +{ + pbuf *ppVar1; + u16_t auStack18 [2]; + u16_t q_idx; + + ppVar1 = pbuf_skip_const(p,offset,auStack18); + if ((ppVar1 != (pbuf *)0x0) && ((uint)auStack18[0] < (uint)ppVar1->len)) { + *(u8_t *)((int)ppVar1->payload + (uint)auStack18[0]) = data; + } + return; +} + + + +u16_t pbuf_memcmp(pbuf *p,u16_t offset,void *s2,u16_t n) + +{ + byte *pbVar1; + ushort *puVar2; + uint uVar3; + u8_t uVar4; + undefined3 extraout_var; + undefined2 in_register_0000202e; + undefined2 in_register_00002036; + short sVar5; + uint uVar6; + + uVar3 = CONCAT22(in_register_0000202e,offset); + if ((int)(uint)p->tot_len < (int)(uVar3 + CONCAT22(in_register_00002036,n))) { + return 0xffff; + } + do { + puVar2 = &p->len; + if (uVar3 < *puVar2) break; + p = p->next; + uVar3 = uVar3 - *puVar2 & 0xffff; + } while (p != (pbuf *)0x0); + uVar6 = 0; + do { + _sVar5 = uVar6 & 0xffff; + sVar5 = (short)_sVar5; + if (CONCAT22(in_register_00002036,n) <= _sVar5) { + return 0; + } + uVar4 = pbuf_get_at(p,(u16_t)((_sVar5 + uVar3) * 0x10000 >> 0x10)); + pbVar1 = (byte *)((int)s2 + uVar6); + uVar6 = uVar6 + 1; + } while ((uint)*pbVar1 == CONCAT31(extraout_var,uVar4)); + if (0xfffe < _sVar5) { + sVar5 = -2; + } + return sVar5 + 1; +} + + + +u16_t pbuf_memfind(pbuf *p,void *mem,u16_t mem_len,u16_t start_offset) + +{ + ushort uVar1; + uint uVar2; + u16_t uVar3; + undefined2 extraout_var; + undefined2 in_register_00002032; + undefined2 in_register_00002036; + + uVar2 = CONCAT22(in_register_00002036,start_offset); + uVar1 = p->tot_len; + if ((int)(CONCAT22(in_register_00002032,mem_len) + uVar2) <= (int)(uint)uVar1) { + while (uVar2 <= ((uint)uVar1 - CONCAT22(in_register_00002032,mem_len) & 0xffff)) { + uVar3 = pbuf_memcmp(p,(u16_t)uVar2,mem,mem_len); + if (CONCAT22(extraout_var,uVar3) == 0) { + return (u16_t)uVar2; + } + uVar2 = uVar2 + 1 & 0xffff; + } + } + return 0xffff; +} + + + +raw_input_state_t raw_input(pbuf *p,netif *inp) + +{ + u8_t uVar1; + raw_pcb *prVar2; + raw_pcb *prVar3; + u8_t uVar4; + raw_input_state_t rVar5; + u8_t uVar6; + undefined3 extraout_var; + undefined3 extraout_var_00; + u32_t uVar7; + raw_pcb *prVar8; + + uVar4 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_dest,ip_data.current_netif); + uVar1 = *(u8_t *)((int)p->payload + 9); + rVar5 = RAW_INPUT_NONE; + prVar2 = raw_pcbs; + prVar8 = (raw_pcb *)0x0; + do { + prVar3 = prVar2; + if (prVar3 == (raw_pcb *)0x0) { + return rVar5; + } + if ((prVar3->protocol == uVar1) && + ((prVar3->netif_idx == '\0' || + (prVar3->netif_idx == (u8_t)((ip_data.current_input_netif)->num + '\x01'))))) { + uVar7 = (prVar3->local_ip).addr; + if (CONCAT31(extraout_var,uVar4) == 0) { + if ((uVar7 == 0) || (ip_data.current_iphdr_dest == uVar7)) goto LAB_23040f92; + } + else { + if (uVar7 == 0) { +LAB_23040f92: + if ((((prVar3->flags & 1) == 0) || ((prVar3->remote_ip).addr == ip_data.current_iphdr_src) + ) && (prVar3->recv != (raw_recv_fn *)0x0)) { + uVar6 = (*prVar3->recv)(prVar3->recv_arg,prVar3,p,(ip_addr_t *)0x4201fed0); + if (CONCAT31(extraout_var_00,uVar6) != 0) { + if (prVar8 == (raw_pcb *)0x0) { + return RAW_INPUT_EATEN; + } + prVar8->next = prVar3->next; + prVar3->next = raw_pcbs; + raw_pcbs = prVar3; + return RAW_INPUT_EATEN; + } + rVar5 = RAW_INPUT_DELIVERED; + } + } + } + } + prVar2 = prVar3->next; + prVar8 = prVar3; + } while( true ); +} + + + +err_t raw_bind(raw_pcb *pcb,ip_addr_t *ipaddr) + +{ + err_t eVar1; + + eVar1 = -6; + if ((pcb != (raw_pcb *)0x0) && (ipaddr != (ip_addr_t *)0x0)) { + (pcb->local_ip).addr = ipaddr->addr; + eVar1 = '\0'; + } + return eVar1; +} + + + +void raw_bind_netif(raw_pcb *pcb,netif *netif) + +{ + u8_t uVar1; + + uVar1 = '\0'; + if (netif != (netif *)0x0) { + uVar1 = netif->num + '\x01'; + } + pcb->netif_idx = uVar1; + return; +} + + + +err_t raw_connect(raw_pcb *pcb,ip_addr_t *ipaddr) + +{ + if ((pcb != (raw_pcb *)0x0) && (ipaddr != (ip_addr_t *)0x0)) { + (pcb->remote_ip).addr = ipaddr->addr; + pcb->flags = pcb->flags | 1; + return '\0'; + } + return -6; +} + + + +void raw_recv(raw_pcb *pcb,raw_recv_fn *recv,void *recv_arg) + +{ + pcb->recv = recv; + pcb->recv_arg = recv_arg; + return; +} + + + +err_t raw_sendto_if_src(raw_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,netif *netif,ip_addr_t *src_ip) + +{ + err_t eVar1; + u8_t ttl; + undefined3 extraout_var; + pbuf *h; + undefined3 extraout_var_00; + + if ((((pcb == (raw_pcb *)0x0) || (dst_ip == (ip_addr_t *)0x0)) || (netif == (netif *)0x0)) || + (src_ip == (ip_addr_t *)0x0)) { + return -6; + } + if ((pcb->flags & 2) != 0) { + if (p->len < 0x14) { + return -6; + } + eVar1 = ip4_output_if(p,(ip4_addr_t *)src_ip,(ip4_addr_t *)0x0,'\0','\0','\0',netif); + return eVar1; + } + if (0xffeb < p->tot_len) { + return -1; + } + ttl = pbuf_add_header(p,0x14); + if (CONCAT31(extraout_var,ttl) == 0) { + ttl = pbuf_remove_header(p,0x14); + h = p; + if (CONCAT31(extraout_var_00,ttl) != 0) { + return -1; + } + } + else { + h = pbuf_alloc(PBUF_IP,0,PBUF_RAM); + if (h == (pbuf *)0x0) { + return -1; + } + if (p->tot_len != 0) { + pbuf_chain(h,p); + } + } + if ((pcb->flags & 4) == 0) { +LAB_23041106: + if ((dst_ip->addr & 0xf0) == 0xe0) { + ttl = pcb->mcast_ttl; + goto LAB_2304111a; + } + } + else { + if ((dst_ip->addr & 0xf0) == 0xe0) { + h->flags = h->flags | 4; + goto LAB_23041106; + } + } + ttl = pcb->ttl; +LAB_2304111a: + eVar1 = ip4_output_if(h,(ip4_addr_t *)src_ip,(ip4_addr_t *)dst_ip,ttl,pcb->tos,pcb->protocol,netif + ); + if (p != h) { + pbuf_free(h); + return eVar1; + } + return eVar1; +} + + + +err_t raw_sendto(raw_pcb *pcb,pbuf *p,ip_addr_t *ipaddr) + +{ + err_t eVar1; + netif *netif; + raw_pcb *src_ip; + uint uVar2; + + if ((pcb == (raw_pcb *)0x0) || (ipaddr == (ip_addr_t *)0x0)) { + return -6; + } + if (pcb->netif_idx == '\0') { + if (((ipaddr->addr & 0xf0) == 0xe0) && + (netif = netif_get_by_index(pcb->mcast_ifindex), netif != (netif *)0x0)) goto LAB_230411a2; + netif = ip4_route((ip4_addr_t *)ipaddr); + } + else { + netif = netif_get_by_index(pcb->netif_idx); + } + if (netif == (netif *)0x0) { + return -4; + } +LAB_230411a2: + uVar2 = (pcb->local_ip).addr; + if ((uVar2 == 0) || (src_ip = pcb, (uVar2 & 0xf0) == 0xe0)) { + src_ip = (raw_pcb *)&netif->ip_addr; + } + eVar1 = raw_sendto_if_src(pcb,p,ipaddr,netif,(ip_addr_t *)src_ip); + return eVar1; +} + + + +err_t raw_send(raw_pcb *pcb,pbuf *p) + +{ + err_t eVar1; + + eVar1 = raw_sendto(pcb,p,&pcb->remote_ip); + return eVar1; +} + + + +void raw_remove(raw_pcb *pcb) + +{ + raw_pcb *prVar1; + raw_pcb *prVar2; + + prVar1 = raw_pcbs; + if (raw_pcbs == pcb) { + raw_pcbs = pcb->next; + } + else { + do { + prVar2 = prVar1; + if ((prVar2 == (raw_pcb *)0x0) || (prVar1 = prVar2->next, prVar1 == (raw_pcb *)0x0)) + goto LAB_230411f0; + } while (prVar1 != pcb); + prVar2->next = pcb->next; + } +LAB_230411f0: + memp_free(MEMP_RAW_PCB,pcb); + return; +} + + + +raw_pcb * raw_new(u8_t proto) + +{ + raw_pcb *prVar1; + raw_pcb *__s; + + __s = (raw_pcb *)memp_malloc(MEMP_RAW_PCB); + if (__s != (raw_pcb *)0x0) { + memset(__s,0,0x1c); + __s->ttl = -1; + __s->mcast_ttl = -1; + __s->protocol = proto; + prVar1 = __s; + __s->next = raw_pcbs; + raw_pcbs = prVar1; + } + return __s; +} + + + +raw_pcb * raw_new_ip_type(u8_t type,u8_t proto) + +{ + raw_pcb *prVar1; + + prVar1 = raw_new(proto); + return prVar1; +} + + + +void raw_netif_ip_addr_changed(ip_addr_t *old_addr,ip_addr_t *new_addr) + +{ + raw_pcb *prVar1; + + if ((((old_addr != (ip_addr_t *)0x0) && (old_addr->addr != 0)) && (new_addr != (ip_addr_t *)0x0)) + && (prVar1 = raw_pcbs, new_addr->addr != 0)) { + while (prVar1 != (raw_pcb *)0x0) { + if ((prVar1->local_ip).addr == old_addr->addr) { + (prVar1->local_ip).addr = new_addr->addr; + } + prVar1 = prVar1->next; + } + } + return; +} + + + +raw_pcb * raw_get_pcbs(void) + +{ + return raw_pcbs; +} + + + +void stats_init(void) + +{ + return; +} + + + +// WARNING: Variable defined which should be unmapped: ip_str +// WARNING: Type propagation algorithm not settling + +void stats_netstat(void *ctx) + +{ + ushort uVar1; + ip4_addr_t addr; + int iVar2; + udp_pcb *addr_00; + raw_pcb *addr_01; + char *pcVar3; + int iVar4; + tcp_pcb ***ppptStack164; + tcp_pcb ***_tcp_pcb_list; + char ip_str [128]; + + memset(&_tcp_pcb_list,0,0x80); + ppptStack164 = (tcp_pcb ***)0x0; + iVar2 = tcp_get_pcbs(&ppptStack164); + addr_00 = udp_get_pcbs(); + addr_01 = raw_get_pcbs(); + printf("netstat tools\r\n"); + iVar4 = 0; + while (iVar4 < iVar2) { + addr = (ip4_addr_t)((ip4_addr_t *)ppptStack164[iVar4])->addr; + while (addr != (ip4_addr_t)0x0) { + ip4addr_ntoa_r((ip4_addr_t *)addr,(char *)&_tcp_pcb_list,0x80); + printf("TCP\t%s:%hu\t",&_tcp_pcb_list, + (uint)*(ushort *)((int)&((ip4_addr_t *)((int)addr + 0x14))->addr + 2)); + ip4addr_ntoa_r((ip4_addr_t *)((int)addr + 4),(char *)&_tcp_pcb_list,0x80); + uVar1 = *(ushort *)&((ip4_addr_t *)((int)addr + 0x18))->addr; + pcVar3 = tcp_debug_state_str(*(tcp_state *)&((ip4_addr_t *)((int)addr + 0x14))->addr); + printf("%s:%hu\t%s\r\n",&_tcp_pcb_list,(uint)uVar1,pcVar3); + addr = (ip4_addr_t)((ip4_addr_t *)&((ip4_addr_t *)((int)addr + 0xc))->addr)->addr; + } + iVar4 = iVar4 + 1; + } + while (addr_00 != (udp_pcb *)0x0) { + ip4addr_ntoa_r((ip4_addr_t *)addr_00,(char *)&_tcp_pcb_list,0x80); + printf("UDP\t%s:%hu\t",&_tcp_pcb_list,(uint)addr_00->local_port); + ip4addr_ntoa_r((ip4_addr_t *)&addr_00->remote_ip,(char *)&_tcp_pcb_list,0x80); + printf("%s:%hu\r\n",&_tcp_pcb_list,(uint)addr_00->remote_port); + addr_00 = addr_00->next; + } + while (addr_01 != (raw_pcb *)0x0) { + ip4addr_ntoa_r((ip4_addr_t *)addr_01,(char *)&_tcp_pcb_list,0x80); + printf("RAW\t%s\t",&_tcp_pcb_list); + ip4addr_ntoa_r((ip4_addr_t *)&addr_01->remote_ip,(char *)&_tcp_pcb_list,0x80); + printf("%s\t%d\r\n",&_tcp_pcb_list,(uint)addr_01->protocol); + addr_01 = addr_01->next; + } + return; +} + + + +u16_t tcp_new_port(void) + +{ + uint uVar1; + uint uVar2; + u32_t uVar3; + tcp_pcb ***ppptVar4; + + uVar2 = 0x4000; +again: + tcp_port = tcp_port + 1; + if (tcp_port == 0xffff) { + tcp_port = 0xc000; + } + ppptVar4 = tcp_pcb_lists; + do { + uVar3 = (((tcp_pcb *)*ppptVar4)->local_ip).addr; + while (uVar3 != 0) { + if (*(u16_t *)(uVar3 + 0x16) == tcp_port) { + uVar1 = uVar2 - 1; + uVar2 = uVar1 & 0xffff; + if (uVar2 == 0) { + return (u16_t)(uVar1 * 0x10000 >> 0x10); + } + goto again; + } + uVar3 = *(u32_t *)(uVar3 + 0xc); + } + ppptVar4 = (tcp_pcb ***)((tcp_pcb **)ppptVar4 + 1); + if (ppptVar4 == (tcp_pcb ***)tcp_state_str) { + return tcp_port; + } + } while( true ); +} + + + +err_t tcp_close_shutdown_fin(tcp_pcb *pcb) + +{ + err_t eVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + tcp_state tVar2; + + tVar2 = pcb->state; + if (tVar2 != ESTABLISHED) { + if (tVar2 == CLOSE_WAIT) { + eVar1 = tcp_send_fin(pcb); + _eVar1 = CONCAT31(extraout_var_00,eVar1); + if (_eVar1 != 0) goto LAB_2304146c; + tVar2 = LAST_ACK; + goto LAB_2304144a; + } + if (tVar2 != SYN_RCVD) { + return '\0'; + } + } + eVar1 = tcp_send_fin(pcb); + _eVar1 = CONCAT31(extraout_var,eVar1); + if (_eVar1 != 0) { +LAB_2304146c: + if (_eVar1 == -1) { + pcb->flags = pcb->flags | 8; + return '\0'; + } + return (err_t)_eVar1; + } + tVar2 = FIN_WAIT_1; +LAB_2304144a: + pcb->state = tVar2; + tcp_output(pcb); + return '\0'; +} + + + +void tcp_init(void) + +{ + uint uVar1; + + uVar1 = bl_rand(); + tcp_port = (u16_t)(((uVar1 & 0x3fff) - 0x4000) * 0x10000 >> 0x10); + printf("-------------------->>>>>>>> LWIP tcp_port %u\r\n"); + return; +} + + + +void tcp_free(tcp_pcb *pcb) + +{ + memp_free(MEMP_TCP_PCB,pcb); + return; +} + + + +err_t tcp_bind(tcp_pcb *pcb,ip_addr_t *ipaddr,u16_t port) + +{ + tcp_pcb *ptVar1; + err_t eVar2; + undefined2 extraout_var; + int iVar3; + undefined2 in_register_00002032; + tcp_pcb ***ppptVar4; + u32_t *puVar5; + + if (ipaddr == (ip_addr_t *)0x0) { + ipaddr = &ip_addr_any; + } + eVar2 = -0x10; + if ((pcb != (tcp_pcb *)0x0) && (eVar2 = -6, pcb->state == CLOSED)) { + if (CONCAT22(in_register_00002032,port) == 0) { + port = tcp_new_port(); + if (CONCAT22(extraout_var,port) == 0) { + return -2; + } + } + else { + ppptVar4 = tcp_pcb_lists; + iVar3 = 0; + do { + puVar5 = (u32_t *)(((tcp_pcb *)*ppptVar4)->local_ip).addr; + while (puVar5 != (u32_t *)0x0) { + if ((((uint)*(ushort *)((int)puVar5 + 0x16) == CONCAT22(in_register_00002032,port)) && + (((pcb->so_options & 4) == 0 || ((*(byte *)((int)puVar5 + 9) & 4) == 0)))) && + ((*puVar5 == 0 || ((ipaddr->addr == 0 || (*puVar5 == ipaddr->addr)))))) { + return -8; + } + puVar5 = (u32_t *)puVar5[3]; + } + iVar3 = iVar3 + 1; + ppptVar4 = (tcp_pcb ***)((tcp_pcb **)ppptVar4 + 1); + } while ((uint)((pcb->so_options & 4) == 0) + 3 != iVar3); + } + if (ipaddr->addr != 0) { + (pcb->local_ip).addr = ipaddr->addr; + } + pcb->local_port = port; + ptVar1 = pcb; + pcb->next = tcp_bound_pcbs; + tcp_bound_pcbs = ptVar1; + tcp_timer_needed(); + eVar2 = '\0'; + } + return eVar2; +} + + + +void tcp_bind_netif(tcp_pcb *pcb,netif *netif) + +{ + u8_t uVar1; + + uVar1 = '\0'; + if (netif != (netif *)0x0) { + uVar1 = netif->num + '\x01'; + } + pcb->netif_idx = uVar1; + return; +} + + + +tcp_pcb * tcp_listen_with_backlog_and_err(tcp_pcb *pcb,u8_t backlog,err_t *err) + +{ + u8_t uVar1; + tcp_pcb *ptVar2; + tcp_pcb *ptVar3; + err_t eVar4; + tcp_pcb *ptVar5; + + if (pcb == (tcp_pcb *)0x0) { + ptVar3 = (tcp_pcb *)0x0; + eVar4 = -0x10; + } + else { + if (pcb->state == CLOSED) { + ptVar3 = tcp_listen_pcbs; + if ((pcb->so_options & 4) != 0) { + while (ptVar3 != (tcp_pcb *)0x0) { + if ((ptVar3->local_port == pcb->local_port) && + ((ptVar3->local_ip).addr == (pcb->local_ip).addr)) { + eVar4 = -8; + goto LAB_2304166a; + } + ptVar3 = ptVar3->next; + } + } + ptVar3 = (tcp_pcb *)memp_malloc(MEMP_TCP_PCB_LISTEN); + eVar4 = -1; + if (ptVar3 != (tcp_pcb *)0x0) { + ptVar3->callback_arg = pcb->callback_arg; + ptVar3->local_port = pcb->local_port; + ptVar3->state = LISTEN; + ptVar3->prio = pcb->prio; + uVar1 = pcb->so_options; + ptVar3->netif_idx = '\0'; + ptVar3->so_options = uVar1; + ptVar3->ttl = pcb->ttl; + ptVar3->tos = pcb->tos; + (ptVar3->local_ip).addr = (pcb->local_ip).addr; + if (pcb->local_port != 0) { + ptVar2 = tcp_bound_pcbs; + if (tcp_bound_pcbs == pcb) { + tcp_bound_pcbs = pcb->next; + } + else { + do { + ptVar5 = ptVar2; + if (ptVar5 == (tcp_pcb *)0x0) goto LAB_230415fc; + ptVar2 = ptVar5->next; + } while (ptVar5->next != pcb); + ptVar5->next = pcb->next; + } +LAB_230415fc: + pcb->next = (tcp_pcb *)0x0; + } + tcp_free(pcb); + *(undefined4 *)&ptVar3->remote_port = 0x23041bc6; + ptVar2 = ptVar3; + ptVar3->next = tcp_listen_pcbs; + tcp_listen_pcbs = ptVar2; + tcp_timer_needed(); + eVar4 = '\0'; + } + } + else { + eVar4 = -0xf; +LAB_2304166a: + ptVar3 = (tcp_pcb *)0x0; + } + } + if (err != (err_t *)0x0) { + *err = eVar4; + } + return ptVar3; +} + + + +u32_t tcp_update_rcv_ann_wnd(tcp_pcb *pcb) + +{ + u32_t uVar1; + u32_t uVar2; + u32_t uVar3; + uint uVar4; + + uVar3 = pcb->rcv_ann_right_edge; + uVar2 = pcb->rcv_nxt; + uVar4 = (uint)pcb->mss; + uVar1 = (pcb->rcv_wnd - uVar3) + uVar2; + if (0x408 < pcb->mss) { + uVar4 = 0x408; + } + if (-1 < (int)(uVar1 - uVar4)) { + pcb->rcv_ann_wnd = pcb->rcv_wnd; + return uVar1; + } + if ((int)(uVar2 - uVar3) < 1) { + pcb->rcv_ann_wnd = (short)uVar3 - (short)uVar2; + } + else { + pcb->rcv_ann_wnd = 0; + } + return 0; +} + + + +void tcp_recved(tcp_pcb *pcb,u16_t len) + +{ + u32_t uVar1; + tcpwnd_size_t tVar2; + + if (pcb == (tcp_pcb *)0x0) { + return; + } + tVar2 = len + pcb->rcv_wnd; + if ((0x810 < tVar2) || (tVar2 < pcb->rcv_wnd)) { + tVar2 = 0x810; + } + pcb->rcv_wnd = tVar2; + uVar1 = tcp_update_rcv_ann_wnd(pcb); + if (0x407 < uVar1) { + pcb->flags = pcb->flags | 2; + tcp_output(pcb); + return; + } + return; +} + + + +void tcp_seg_free(tcp_seg *seg) + +{ + if (seg == (tcp_seg *)0x0) { + return; + } + if (seg->p != (pbuf *)0x0) { + pbuf_free(seg->p); + } + memp_free(MEMP_TCP_SEG,seg); + return; +} + + + +void tcp_segs_free(tcp_seg *seg) + +{ + tcp_seg *ptVar1; + + if (seg != (tcp_seg *)0x0) { + do { + ptVar1 = seg->next; + tcp_seg_free(seg); + seg = ptVar1; + } while (ptVar1 != (tcp_seg *)0x0); + return; + } + return; +} + + + +void tcp_setprio(tcp_pcb *pcb,u8_t prio) + +{ + if (pcb != (tcp_pcb *)0x0) { + pcb->prio = prio; + } + return; +} + + + +tcp_seg * tcp_seg_copy(tcp_seg *seg) + +{ + tcp_seg *__dest; + + __dest = (tcp_seg *)memp_malloc(MEMP_TCP_SEG); + if (__dest != (tcp_seg *)0x0) { + memcpy(__dest,seg,0x14); + pbuf_ref(__dest->p); + } + return __dest; +} + + + +void tcp_arg(tcp_pcb *pcb,void *arg) + +{ + if (pcb != (tcp_pcb *)0x0) { + pcb->callback_arg = arg; + } + return; +} + + + +void tcp_recv(tcp_pcb *pcb,tcp_recv_fn *recv) + +{ + if (pcb != (tcp_pcb *)0x0) { + pcb->recv = recv; + } + return; +} + + + +void tcp_sent(tcp_pcb *pcb,tcp_sent_fn *sent) + +{ + if (pcb != (tcp_pcb *)0x0) { + pcb->sent = sent; + } + return; +} + + + +void tcp_err(tcp_pcb *pcb,tcp_err_fn *err) + +{ + if (pcb != (tcp_pcb *)0x0) { + pcb->errf = err; + } + return; +} + + + +void tcp_accept(tcp_pcb *pcb,tcp_accept_fn accept) + +{ + if ((pcb != (tcp_pcb *)0x0) && (pcb->state == LISTEN)) { + *(tcp_accept_fn *)&pcb->remote_port = accept; + } + return; +} + + + +void tcp_poll(tcp_pcb *pcb,tcp_poll_fn *poll,u8_t interval) + +{ + if (pcb != (tcp_pcb *)0x0) { + pcb->poll = poll; + pcb->pollinterval = interval; + } + return; +} + + + +u32_t tcp_next_iss(tcp_pcb *pcb) + +{ + u32_t iss; + + return iss + tcp_ticks; +} + + + +u16_t tcp_eff_send_mss_netif(u16_t sendmss,netif *outif,ip_addr_t *dest) + +{ + ushort uVar1; + u16_t uVar2; + undefined2 in_register_0000202a; + uint uVar3; + + uVar2 = sendmss; + if (outif != (netif *)0x0) { + uVar1 = outif->mtu; + if (((uVar1 != 0) && (uVar2 = 0, 0x28 < uVar1)) && + (uVar3 = (uint)uVar1 - 0x28 & 0xffff, uVar2 = (u16_t)uVar3, + CONCAT22(in_register_0000202a,sendmss) < uVar3)) { + uVar2 = sendmss; + } + } + return uVar2; +} + + + +err_t tcp_connect(tcp_pcb *pcb,ip_addr_t *ipaddr,u16_t port,tcp_connected_fn connected) + +{ + u16_t uVar1; + err_t eVar2; + u16_t uVar3; + netif *outif; + undefined2 extraout_var_00; + u32_t uVar4; + undefined3 extraout_var; + undefined2 in_register_00002032; + tcp_pcb *ptVar5; + tcp_pcb *ptVar6; + + eVar2 = -0x10; + if (((pcb != (tcp_pcb *)0x0) && (ipaddr != (ip_addr_t *)0x0)) && + (eVar2 = -10, pcb->state == CLOSED)) { + (pcb->remote_ip).addr = ipaddr->addr; + pcb->remote_port = port; + if (pcb->netif_idx == '\0') { + outif = ip4_route((ip4_addr_t *)&pcb->remote_ip); + } + else { + outif = netif_get_by_index(pcb->netif_idx); + } + eVar2 = -4; + if (outif != (netif *)0x0) { + if ((pcb->local_ip).addr == 0) { + (pcb->local_ip).addr = (outif->ip_addr).addr; + } + uVar1 = pcb->local_port; + if (uVar1 == 0) { + uVar3 = tcp_new_port(); + pcb->local_port = uVar3; + if (CONCAT22(extraout_var_00,uVar3) == 0) { + return -2; + } + } + else { + ptVar5 = tcp_active_pcbs; + if ((pcb->so_options & 4) != 0) { + while (ptVar6 = tcp_tw_pcbs, ptVar5 != (tcp_pcb *)0x0) { + if (((ptVar5->local_port == uVar1) && + ((uint)ptVar5->remote_port == CONCAT22(in_register_00002032,port))) && + (((ptVar5->local_ip).addr == (pcb->local_ip).addr && + ((ptVar5->remote_ip).addr == ipaddr->addr)))) { + return -8; + } + ptVar5 = ptVar5->next; + } + while (ptVar6 != (tcp_pcb *)0x0) { + if (((ptVar6->local_port == uVar1) && + ((uint)ptVar6->remote_port == CONCAT22(in_register_00002032,port))) && + (((ptVar6->local_ip).addr == (pcb->local_ip).addr && + ((ptVar6->remote_ip).addr == ipaddr->addr)))) { + return -8; + } + ptVar6 = ptVar6->next; + } + } + } + uVar4 = tcp_next_iss(pcb); + *(undefined4 *)&pcb->rcv_wnd = 0x8100810; + pcb->snd_nxt = uVar4; + pcb->snd_wnd = 0x810; + uVar4 = uVar4 - 1; + pcb->lastack = uVar4; + pcb->snd_wl2 = uVar4; + pcb->snd_lbb = uVar4; + pcb->mss = 0x218; + pcb->rcv_nxt = 0; + pcb->rcv_ann_right_edge = 0; + uVar3 = tcp_eff_send_mss_netif(0x218,outif,&pcb->remote_ip); + pcb->mss = uVar3; + pcb->cwnd = 1; + pcb->connected = connected; + eVar2 = tcp_enqueue_flags(pcb,'\x02'); + if (CONCAT31(extraout_var,eVar2) == 0) { + pcb->state = SYN_SENT; + if (uVar1 != 0) { + ptVar5 = tcp_bound_pcbs; + if (tcp_bound_pcbs == pcb) { + tcp_bound_pcbs = pcb->next; + } + else { + do { + ptVar6 = ptVar5; + if (ptVar6 == (tcp_pcb *)0x0) goto LAB_2304193a; + ptVar5 = ptVar6->next; + } while (ptVar6->next != pcb); + ptVar6->next = pcb->next; + } + } +LAB_2304193a: + ptVar5 = pcb; + pcb->next = tcp_active_pcbs; + tcp_active_pcbs = ptVar5; + tcp_timer_needed(); + tcp_active_pcbs_changed = '\x01'; + tcp_output(pcb); + } + } + } + return eVar2; +} + + + +char * tcp_debug_state_str(tcp_state s) + +{ + undefined3 in_register_00002029; + + return tcp_state_str[CONCAT31(in_register_00002029,s)]; +} + + + +err_t tcp_tcp_get_tcp_addrinfo(tcp_pcb *pcb,int local,ip_addr_t *addr,u16_t *port) + +{ + u16_t uVar1; + + if (pcb == (tcp_pcb *)0x0) { + return -6; + } + if (local == 0) { + if (addr != (ip_addr_t *)0x0) { + addr->addr = (pcb->remote_ip).addr; + } + if (port == (u16_t *)0x0) { + return '\0'; + } + uVar1 = pcb->remote_port; + } + else { + if (addr != (ip_addr_t *)0x0) { + addr->addr = (pcb->local_ip).addr; + } + if (port == (u16_t *)0x0) { + return '\0'; + } + uVar1 = pcb->local_port; + } + *port = uVar1; + return '\0'; +} + + + +void tcp_free_ooseq(tcp_pcb *pcb) + +{ + if (pcb->ooseq != (tcp_seg *)0x0) { + tcp_segs_free(pcb->ooseq); + pcb->ooseq = (tcp_seg *)0x0; + return; + } + return; +} + + + +void tcp_pcb_purge(tcp_pcb *pcb) + +{ + if (((pcb != (tcp_pcb *)0x0) && (LISTEN < pcb->state)) && (pcb->state != TIME_WAIT)) { + if (pcb->refused_data != (pbuf *)0x0) { + pbuf_free(pcb->refused_data); + pcb->refused_data = (pbuf *)0x0; + } + if (pcb->ooseq != (tcp_seg *)0x0) { + tcp_free_ooseq(pcb); + } + pcb->rtime = -1; + tcp_segs_free(pcb->unsent); + tcp_segs_free(pcb->unacked); + pcb->unsent = (tcp_seg *)0x0; + pcb->unacked = (tcp_seg *)0x0; + pcb->unsent_oversize = 0; + return; + } + return; +} + + + +void tcp_pcb_remove(tcp_pcb **pcblist,tcp_pcb *pcb) + +{ + tcp_pcb *ptVar1; + tcp_pcb *ptVar2; + + ptVar1 = *pcblist; + if (*pcblist == pcb) { + *pcblist = pcb->next; + } + else { + do { + ptVar2 = ptVar1; + if (ptVar2 == (tcp_pcb *)0x0) goto LAB_23041a5a; + ptVar1 = ptVar2->next; + } while (ptVar2->next != pcb); + ptVar2->next = pcb->next; + } +LAB_23041a5a: + pcb->next = (tcp_pcb *)0x0; + tcp_pcb_purge(pcb); + if (((pcb->state != TIME_WAIT) && (pcb->state != LISTEN)) && ((pcb->flags & 1) != 0)) { + pcb->flags = pcb->flags | 2; + tcp_output(pcb); + } + pcb->state = CLOSED; + pcb->local_port = 0; + return; +} + + + +void tcp_abandon(tcp_pcb *pcb,int reset) + +{ + tcp_pcb *ptVar1; + u16_t uVar2; + tcp_pcb *ptVar3; + tcp_err_fn *UNRECOVERED_JUMPTABLE; + void *pvVar4; + u32_t seqno; + u32_t ackno; + + if (pcb == (tcp_pcb *)0x0) { + return; + } + if (pcb->state == TIME_WAIT) { + tcp_pcb_remove(&tcp_tw_pcbs,pcb); + tcp_free(pcb); + return; + } + seqno = pcb->snd_nxt; + ackno = pcb->rcv_nxt; + UNRECOVERED_JUMPTABLE = pcb->errf; + pvVar4 = pcb->callback_arg; + uVar2 = pcb->local_port; + if (pcb->state == CLOSED) { + reset = 0; + if (uVar2 != 0) { + ptVar1 = tcp_bound_pcbs; + if (tcp_bound_pcbs == pcb) { + tcp_bound_pcbs = pcb->next; + } + else { + do { + ptVar3 = ptVar1; + if (ptVar3 == (tcp_pcb *)0x0) goto LAB_23041b20; + ptVar1 = ptVar3->next; + } while (ptVar3->next != pcb); + ptVar3->next = pcb->next; + } +LAB_23041b20: + pcb->next = (tcp_pcb *)0x0; + uVar2 = 0; + reset = 0; + } + } + else { + tcp_pcb_remove(&tcp_active_pcbs,pcb); + tcp_active_pcbs_changed = '\x01'; + } + if (pcb->unacked != (tcp_seg *)0x0) { + tcp_segs_free(pcb->unacked); + } + if (pcb->unsent != (tcp_seg *)0x0) { + tcp_segs_free(pcb->unsent); + } + if (pcb->ooseq != (tcp_seg *)0x0) { + tcp_segs_free(pcb->ooseq); + } + if (reset != 0) { + tcp_rst(pcb,seqno,ackno,(ip_addr_t *)pcb,&pcb->remote_ip,uVar2,pcb->remote_port); + } + tcp_free(pcb); + if (UNRECOVERED_JUMPTABLE == (tcp_err_fn *)0x0) { + return; + } + // WARNING: Could not recover jumptable at 0x23041b7c. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(pvVar4,-0xd); + return; +} + + + +void tcp_abort(tcp_pcb *pcb) + +{ + tcp_abandon(pcb,1); + return; +} + + + +err_t tcp_accept_null(void *arg,tcp_pcb *pcb,err_t err) + +{ + tcp_abort(pcb); + return -0xd; +} + + + +void tcp_netif_ip_addr_changed_pcblist(tcp_pcb *pcb_list) + +{ + tcp_pcb *in_a1; + tcp_pcb *pcb; + + while (pcb = in_a1, pcb != (tcp_pcb *)0x0) { + in_a1 = pcb->next; + if ((pcb->local_ip).addr == (pcb_list->local_ip).addr) { + tcp_abort(pcb); + } + } + return; +} + + + +void tcp_netif_ip_addr_changed(ip_addr_t *old_addr,ip_addr_t *new_addr) + +{ + u32_t *puVar1; + + if (old_addr == (ip_addr_t *)0x0) { + return; + } + if (old_addr->addr != 0) { + tcp_netif_ip_addr_changed_pcblist((tcp_pcb *)old_addr); + tcp_netif_ip_addr_changed_pcblist((tcp_pcb *)old_addr); + if ((new_addr != (ip_addr_t *)0x0) && (puVar1 = tcp_listen_pcbs, new_addr->addr != 0)) { + while (puVar1 != (u32_t *)0x0) { + if (*puVar1 == old_addr->addr) { + *puVar1 = new_addr->addr; + } + puVar1 = (u32_t *)puVar1[3]; + } + } + } + return; +} + + + +void tcp_kill_state(tcp_state state) + +{ + undefined3 in_register_00002029; + uint uVar1; + tcp_pcb *pcb; + uint uVar2; + tcp_pcb *ptVar3; + + uVar1 = 0; + pcb = (tcp_pcb *)0x0; + ptVar3 = tcp_active_pcbs; + while (ptVar3 != (tcp_pcb *)0x0) { + if (((uint)ptVar3->state == CONCAT31(in_register_00002029,state)) && + (uVar2 = tcp_ticks - ptVar3->tmr, uVar1 <= uVar2)) { + uVar1 = uVar2; + pcb = ptVar3; + } + ptVar3 = ptVar3->next; + } + if (pcb != (tcp_pcb *)0x0) { + tcp_abandon(pcb,0); + return; + } + return; +} + + + +tcp_pcb * tcp_alloc(u8_t prio) + +{ + u32_t uVar1; + tcp_pcb *pcb; + undefined3 in_register_00002029; + uint uVar2; + uint uVar3; + uint uVar4; + tcp_pcb *ptVar5; + int iVar6; + + iVar6 = CONCAT31(in_register_00002029,prio); + pcb = (tcp_pcb *)memp_malloc(MEMP_TCP_PCB); + ptVar5 = tcp_active_pcbs; + if (pcb != (tcp_pcb *)0x0) goto LAB_23041d62; + while (pcb = ptVar5, pcb != (tcp_pcb *)0x0) { + ptVar5 = pcb->next; + if ((pcb->flags & 8) != 0) { + pcb->flags = pcb->flags & 0xfff7; + tcp_close_shutdown_fin(pcb); + } + } + uVar3 = 0; + ptVar5 = tcp_tw_pcbs; + while (ptVar5 != (tcp_pcb *)0x0) { + uVar4 = tcp_ticks - ptVar5->tmr; + if (uVar3 <= uVar4) { + pcb = ptVar5; + uVar3 = uVar4; + } + ptVar5 = ptVar5->next; + } + if (pcb != (tcp_pcb *)0x0) { + tcp_abort(pcb); + } + pcb = (tcp_pcb *)memp_malloc(MEMP_TCP_PCB); + if (pcb == (tcp_pcb *)0x0) { + tcp_kill_state(LAST_ACK); + pcb = (tcp_pcb *)memp_malloc(MEMP_TCP_PCB); + if (pcb == (tcp_pcb *)0x0) { + tcp_kill_state(CLOSING); + pcb = (tcp_pcb *)memp_malloc(MEMP_TCP_PCB); + if (pcb == (tcp_pcb *)0x0) { + if ((char)prio < '\0') { + iVar6 = 0x7f; +LAB_23041e24: + uVar3 = iVar6 - 1U & 0xff; + uVar4 = 0; + ptVar5 = tcp_active_pcbs; + while (ptVar5 != (tcp_pcb *)0x0) { + uVar2 = (uint)ptVar5->prio; + if ((uVar2 < uVar3) || ((uVar2 == uVar3 && (uVar4 <= tcp_ticks - ptVar5->tmr)))) { + uVar4 = tcp_ticks - ptVar5->tmr; + pcb = ptVar5; + uVar3 = uVar2; + } + ptVar5 = ptVar5->next; + } + if (pcb != (tcp_pcb *)0x0) { + tcp_abort(pcb); + } + } + else { + if (iVar6 != 0) goto LAB_23041e24; + } + pcb = (tcp_pcb *)memp_malloc(MEMP_TCP_PCB); + if (pcb == (tcp_pcb *)0x0) { + return (tcp_pcb *)0x0; + } + lwip_stats.memp[2]->err = lwip_stats.memp[2]->err - 1; + } + lwip_stats.memp[2]->err = lwip_stats.memp[2]->err - 1; + } + lwip_stats.memp[2]->err = lwip_stats.memp[2]->err - 1; + } + lwip_stats.memp[2]->err = lwip_stats.memp[2]->err - 1; +LAB_23041d62: + memset(pcb,0,0xa4); + pcb->snd_buf = 0x1580; + *(undefined4 *)&pcb->rcv_wnd = 0x8100810; + pcb->ttl = -1; + pcb->rto = 6; + pcb->sv = 6; + *(undefined4 *)&pcb->rtime = 0x218ffff; + uVar1 = tcp_ticks; + pcb->prio = prio; + pcb->tmr = uVar1; + pcb->last_timer = tcp_timer_ctr; + *(undefined4 *)&pcb->cwnd = 0x15800001; + pcb->recv = tcp_recv_null; + pcb->keep_idle = 7200000; + pcb->keep_intvl = 75000; + pcb->keep_cnt = 9; + return pcb; +} + + + +tcp_pcb * tcp_new_ip_type(u8_t type) + +{ + tcp_pcb *ptVar1; + + ptVar1 = tcp_alloc('@'); + return ptVar1; +} + + + +err_t tcp_close_shutdown(tcp_pcb *pcb,u8_t rst_on_unacked_data) + +{ + tcp_state tVar1; + err_t eVar2; + undefined3 in_register_0000202d; + tcp_pcb *ptVar3; + tcp_pcb *ptVar4; + tcp_pcb ***ppptVar5; + + tVar1 = pcb->state; + if (((CONCAT31(in_register_0000202d,rst_on_unacked_data) == 0) || + ((tVar1 != ESTABLISHED && (tVar1 != CLOSE_WAIT)))) || + ((pcb->refused_data == (pbuf *)0x0 && (pcb->rcv_wnd == 0x810)))) { + if (tVar1 == LISTEN) { + ppptVar5 = tcp_pcb_lists; + do { + ptVar3 = *ppptVar5[1]; + while (ptVar3 != (tcp_pcb *)0x0) { + if (pcb == (tcp_pcb *)ptVar3->listener) { + ptVar3->listener = (tcp_pcb_listen *)0x0; + } + ptVar3 = ptVar3->next; + } + ppptVar5 = ppptVar5 + 1; + } while (ppptVar5 != (tcp_pcb ***)0x2308643c); + tcp_pcb_remove((tcp_pcb **)&tcp_listen_pcbs,pcb); + memp_free(MEMP_TCP_PCB_LISTEN,pcb); + return '\0'; + } + if (tVar1 == CLOSED) { + if (pcb->local_port != 0) { + ptVar3 = tcp_bound_pcbs; + if (tcp_bound_pcbs == pcb) { + tcp_bound_pcbs = pcb->next; + } + else { + do { + ptVar4 = ptVar3; + if (ptVar4 == (tcp_pcb *)0x0) goto LAB_23041f3a; + ptVar3 = ptVar4->next; + } while (ptVar4->next != pcb); + ptVar4->next = pcb->next; + } +LAB_23041f3a: + pcb->next = (tcp_pcb *)0x0; + } + } + else { + if (tVar1 != SYN_SENT) { + eVar2 = tcp_close_shutdown_fin(pcb); + return eVar2; + } + tcp_pcb_remove(&tcp_active_pcbs,pcb); + tcp_active_pcbs_changed = '\x01'; + } + } + else { + tcp_rst(pcb,pcb->snd_nxt,pcb->rcv_nxt,(ip_addr_t *)pcb,&pcb->remote_ip,pcb->local_port, + pcb->remote_port); + tcp_pcb_purge(pcb); + ptVar3 = tcp_active_pcbs; + if (tcp_active_pcbs == pcb) { + tcp_active_pcbs = pcb->next; + } + else { + do { + ptVar4 = ptVar3; + if (ptVar4 == (tcp_pcb *)0x0) goto LAB_23041ecc; + ptVar3 = ptVar4->next; + } while (ptVar4->next != pcb); + ptVar4->next = pcb->next; + } +LAB_23041ecc: + ptVar3 = tcp_input_pcb; + tcp_active_pcbs_changed = '\x01'; + pcb->next = (tcp_pcb *)0x0; + if (ptVar3 == pcb) { + tcp_trigger_input_pcb_close(); + return '\0'; + } + } + tcp_free(pcb); + return '\0'; +} + + + +err_t tcp_close(tcp_pcb *pcb) + +{ + err_t eVar1; + + if (pcb != (tcp_pcb *)0x0) { + if (pcb->state != LISTEN) { + pcb->flags = pcb->flags | 0x10; + } + eVar1 = tcp_close_shutdown(pcb,'\x01'); + return eVar1; + } + return -0x10; +} + + + +err_t tcp_recv_null(void *arg,tcp_pcb *pcb,pbuf *p,err_t err) + +{ + err_t eVar1; + undefined3 in_register_00002035; + + if (pcb == (tcp_pcb *)0x0) { + return -0x10; + } + if (p != (pbuf *)0x0) { + tcp_recved(pcb,p->tot_len); + pbuf_free(p); + return '\0'; + } + if (CONCAT31(in_register_00002035,err) == 0) { + eVar1 = tcp_close(pcb); + return eVar1; + } + return '\0'; +} + + + +err_t tcp_process_refused_data(tcp_pcb *pcb) + +{ + byte bVar1; + err_t eVar2; + err_t eVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + pbuf *p; + + if (pcb == (tcp_pcb *)0x0) { + return -0x10; + } + p = pcb->refused_data; + bVar1 = p->flags; + pcb->refused_data = (pbuf *)0x0; + if (pcb->recv == (tcp_recv_fn *)0x0) { + eVar2 = tcp_recv_null((void *)0x0,pcb,p,'\0'); + _eVar2 = CONCAT31(extraout_var_01,eVar2); + } + else { + eVar2 = (*pcb->recv)(pcb->callback_arg,pcb,p,'\0'); + _eVar2 = CONCAT31(extraout_var,eVar2); + } + eVar2 = (err_t)_eVar2; + if (_eVar2 == 0) { + if ((bVar1 & 0x20) == 0) { + return eVar2; + } + if (pcb->rcv_wnd != 0x810) { + pcb->rcv_wnd = pcb->rcv_wnd + 1; + } + if (pcb->recv == (tcp_recv_fn *)0x0) { + return eVar2; + } + eVar3 = (*pcb->recv)(pcb->callback_arg,pcb,(pbuf *)0x0,'\0'); + if (CONCAT31(extraout_var_00,eVar3) != -0xd) { + return eVar2; + } + } + else { + if (_eVar2 != -0xd) { + pcb->refused_data = p; + return -5; + } + } + return -0xd; +} + + + +void tcp_fasttmr(void) + +{ + tcp_pcb *pcb; + tcp_pcb *ptVar1; + + tcp_timer_ctr = tcp_timer_ctr + '\x01'; + pcb = tcp_active_pcbs; + while( true ) { + if (pcb == (tcp_pcb *)0x0) { + return; + } + if (pcb->last_timer == tcp_timer_ctr) break; + pcb->last_timer = tcp_timer_ctr; + if ((pcb->flags & 1) != 0) { + pcb->flags = pcb->flags | 2; + tcp_output(pcb); + pcb->flags = pcb->flags & 0xfffc; + } + if ((pcb->flags & 8) != 0) { + pcb->flags = pcb->flags & 0xfff7; + tcp_close_shutdown_fin(pcb); + } + ptVar1 = pcb->next; + if (pcb->refused_data == (pbuf *)0x0) goto LAB_23042130; + tcp_active_pcbs_changed = '\0'; + tcp_process_refused_data(pcb); + pcb = tcp_active_pcbs; + if (tcp_active_pcbs_changed == '\0') { +LAB_23042130: + pcb = ptVar1; + } + } + ptVar1 = pcb->next; + goto LAB_23042130; +} + + + +err_t tcp_shutdown(tcp_pcb *pcb,int shut_rx,int shut_tx) + +{ + tcp_state tVar1; + err_t eVar2; + u8_t rst_on_unacked_data; + + rst_on_unacked_data = (u8_t)shut_rx; + if (pcb == (tcp_pcb *)0x0) { + return -0x10; + } + tVar1 = pcb->state; + if (tVar1 == LISTEN) { +LAB_23042196: + eVar2 = -0xb; + } + else { + if (shut_rx == 0) { + if (shut_tx != 0) { + if ((tVar1 < CLOSING) && ((1 << ((uint)tVar1 & 0x1f) & 0x98U) != 0)) goto LAB_23042188; + goto LAB_23042196; + } + } + else { + rst_on_unacked_data = '\x01'; + pcb->flags = pcb->flags | 0x10; + if (shut_tx != 0) { +LAB_23042188: + eVar2 = tcp_close_shutdown(pcb,rst_on_unacked_data); + return eVar2; + } + if (pcb->refused_data != (pbuf *)0x0) { + pbuf_free(pcb->refused_data); + pcb->refused_data = (pbuf *)0x0; + } + } + eVar2 = '\0'; + } + return eVar2; +} + + + +void tcp_slowtmr(void) + +{ + tcp_state tVar1; + short sVar2; + tcp_pcb *pcb; + uint uVar3; + tcp_err_fn *ptVar4; + err_t eVar5; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + uint uVar6; + byte bVar7; + uint uVar8; + u32_t uVar9; + byte bVar10; + s16_t sVar11; + void *pvVar12; + tcp_pcb *ptVar13; + tcp_pcb *pcb_00; + + tcp_ticks = tcp_ticks + 1; + tcp_timer_ctr = tcp_timer_ctr + '\x01'; + do { + pcb_00 = tcp_active_pcbs; + ptVar13 = (tcp_pcb *)0x0; +LAB_23042200: + do { + while( true ) { + pcb = pcb_00; + pcb_00 = tcp_tw_pcbs; + if (pcb == (tcp_pcb *)0x0) { + while (pcb_00 != (tcp_pcb *)0x0) { + if (tcp_ticks - pcb_00->tmr < 0xf1) { + pcb = pcb_00; + pcb_00 = pcb_00->next; + } + else { + tcp_pcb_purge(pcb_00); + ptVar13 = pcb_00->next; + if (pcb != (tcp_pcb *)0x0) { + pcb->next = pcb_00->next; + ptVar13 = tcp_tw_pcbs; + } + tcp_tw_pcbs = ptVar13; + ptVar13 = pcb_00->next; + tcp_free(pcb_00); + pcb_00 = ptVar13; + } + } + return; + } + if (pcb->last_timer != tcp_timer_ctr) break; + pcb_00 = pcb->next; + ptVar13 = pcb; + } + pcb->last_timer = tcp_timer_ctr; + if (pcb->state == SYN_SENT) { + bVar7 = 5; + } + else { + bVar7 = 0xb; + } + uVar3 = 1; + if (pcb->nrtx <= bVar7) { + uVar3 = (uint)pcb->persist_backoff; + if (pcb->persist_backoff == 0) { + sVar2 = pcb->rtime; + if (sVar2 < 0) { +LAB_23042456: + if (pcb->rtime < pcb->rto) goto LAB_230422b0; + } + else { + if (sVar2 != 0x7fff) { + pcb->rtime = sVar2 + 1; + goto LAB_23042456; + } + } + eVar5 = tcp_rexmit_rto_prepare(pcb); + if ((CONCAT31(extraout_var_02,eVar5) == 0) || + ((pcb->unacked == (tcp_seg *)0x0 && (pcb->unsent != (tcp_seg *)0x0)))) { + if (pcb->state != SYN_SENT) { + uVar6 = (uint)pcb->nrtx; + if (0xc < pcb->nrtx) { + uVar6 = 0xc; + } + _sVar11 = ((int)pcb->sa >> 3) + (int)pcb->sv << + ((uint)"\x01\x02\x03\x04\x05\x06\a\a\a\a\a\a\a"[uVar6] & 0x1f); + sVar11 = (s16_t)_sVar11; + if (0x7ffe < _sVar11) { + sVar11 = 0x7fff; + } + pcb->rto = sVar11; + } + pcb->rtime = 0; + uVar6 = (uint)pcb->snd_wnd; + if ((uint)pcb->cwnd < (uint)pcb->snd_wnd) { + uVar6 = (uint)pcb->cwnd; + } + uVar8 = (uint)pcb->mss << 0x11; + pcb->ssthresh = (tcpwnd_size_t)(uVar6 >> 1); + if (uVar6 >> 1 < uVar8 >> 0x10) { + pcb->ssthresh = (tcpwnd_size_t)(uVar8 >> 0x10); + } + pcb->cwnd = pcb->mss; + pcb->bytes_acked = 0; + tcp_rexmit_rto_commit(pcb); + goto LAB_230422b2; + } + } + else { + if (0xb < pcb->persist_probe) { + uVar3 = 1; + goto LAB_230422b2; + } + bVar7 = *(byte *)((int)&ip_addr_broadcast.addr + uVar3 + 3); + if ((bVar7 <= pcb->persist_cnt) || + (bVar10 = pcb->persist_cnt + 1, pcb->persist_cnt = bVar10, bVar7 <= bVar10)) { + if (pcb->snd_wnd == 0) { + eVar5 = tcp_zero_window_probe(pcb); + if (CONCAT31(extraout_var_01,eVar5) == 0) goto LAB_230423a0; + } + else { + eVar5 = tcp_split_unsent_seg(pcb,pcb->snd_wnd); + if ((CONCAT31(extraout_var,eVar5) != 0) || + (eVar5 = tcp_output(pcb), CONCAT31(extraout_var_00,eVar5) != 0)) { +LAB_230423a0: + pcb->persist_cnt = '\0'; + if (pcb->persist_backoff < 7) { + pcb->persist_backoff = pcb->persist_backoff + 1; + } + } + } + } + } +LAB_230422b0: + uVar3 = 0; + } +LAB_230422b2: + tVar1 = pcb->state; + if (((tVar1 == FIN_WAIT_2) && ((pcb->flags & 0x10) != 0)) && (0x28 < tcp_ticks - pcb->tmr)) { + uVar3 = uVar3 + 1 & 0xff; + } + bVar7 = pcb->so_options & 8; + if (((pcb->so_options & 8) != 0) && + ((tVar1 == ESTABLISHED || (bVar7 = 0, tVar1 == CLOSE_WAIT)))) { + uVar6 = tcp_ticks - pcb->tmr; + if ((pcb->keep_intvl * pcb->keep_cnt + pcb->keep_idle) / 500 < uVar6) { + uVar3 = uVar3 + 1 & 0xff; + bVar7 = 1; + } + else { + bVar7 = 0; + if ((((uint)pcb->keep_cnt_sent * pcb->keep_intvl + pcb->keep_idle) / 500 < uVar6) && + (eVar5 = tcp_keepalive(pcb), bVar7 = 0, CONCAT31(extraout_var_03,eVar5) == 0)) { + pcb->keep_cnt_sent = pcb->keep_cnt_sent + '\x01'; + } + } + } + if ((pcb->ooseq != (tcp_seg *)0x0) && ((uint)((int)pcb->rto * 6) <= tcp_ticks - pcb->tmr)) { + tcp_free_ooseq(pcb); + } + tVar1 = pcb->state; + if (tVar1 == SYN_RCVD) { + if (0x28 < tcp_ticks - pcb->tmr) { + uVar3 = uVar3 + 1 & 0xff; + } +LAB_23042362: + if (uVar3 == 0) { + pcb_00 = pcb->next; + bVar7 = pcb->polltmr + 1; + pcb->polltmr = bVar7; + ptVar13 = pcb; + if (pcb->pollinterval <= bVar7) { + pcb->polltmr = '\0'; + tcp_active_pcbs_changed = '\0'; + if (pcb->poll != (tcp_poll_fn *)0x0) { + eVar5 = (*pcb->poll)(pcb->callback_arg,pcb); + if (tcp_active_pcbs_changed != '\0') break; + if (CONCAT31(extraout_var_04,eVar5) != 0) goto LAB_23042200; + } + tcp_output(pcb); + } + goto LAB_23042200; + } + } + else { + if (tVar1 == LAST_ACK) { + uVar9 = pcb->tmr; + uVar6 = 0xf0; + } + else { + if ((tVar1 != FIN_WAIT_1) && (tVar1 != CLOSING)) goto LAB_23042362; + uVar9 = pcb->tmr; + uVar6 = 10; + } + if (tcp_ticks - uVar9 <= uVar6) goto LAB_23042362; + } + ptVar4 = pcb->errf; + tcp_pcb_purge(pcb); + pcb_00 = pcb->next; + if (ptVar13 != (tcp_pcb *)0x0) { + ptVar13->next = pcb->next; + pcb_00 = tcp_active_pcbs; + } + tcp_active_pcbs = pcb_00; + if (bVar7 != 0) { + tcp_rst(pcb,pcb->snd_nxt,pcb->rcv_nxt,(ip_addr_t *)pcb,&pcb->remote_ip,pcb->local_port, + pcb->remote_port); + } + pvVar12 = pcb->callback_arg; + pcb_00 = pcb->next; + tcp_free(pcb); + tcp_active_pcbs_changed = '\0'; + } while ((ptVar4 == (tcp_err_fn *)0x0) || + ((*ptVar4)(pvVar12,-0xd), tcp_active_pcbs_changed == '\0')); + } while( true ); +} + + + +void tcp_tmr(void) + +{ + tcp_fasttmr(); + tcp_timer = tcp_timer + 1; + if ((tcp_timer & 1) != 0) { + tcp_slowtmr(); + return; + } + return; +} + + + +int tcp_get_pcbs(tcp_pcb ****list) + +{ + *list = tcp_pcb_lists; + return 4; +} + + + +u8_t tcp_get_next_optbyte(void) + +{ + uint uVar1; + + uVar1 = (uint)tcp_optidx; + if ((tcphdr_opt2 != (u8_t *)0x0) && (tcphdr_opt1len <= uVar1)) { + tcp_optidx = tcp_optidx + 1; + return tcphdr_opt2[uVar1 - tcphdr_opt1len & 0xff]; + } + tcp_optidx = tcp_optidx + 1; + return *(u8_t *)((int)&tcphdr[1].src + uVar1); +} + + + +void tcp_oos_insert_segment(tcp_seg *cseg,tcp_seg *next) + +{ + u32_t uVar1; + ushort uVar2; + tcp_seg *ptVar3; + u16_t new_len; + int iVar4; + tcp_hdr *ptVar5; + + new_len = lwip_htons(cseg->tcphdr->_hdrlen_rsvd_flags); + if ((new_len & 1) == 0) { + do { + iVar4 = cseg->len + seqno; + uVar1 = next->tcphdr->seqno; + if ((int)(iVar4 - (next->len + uVar1)) < 0) { + if (0 < (int)(iVar4 - uVar1)) { + new_len = (u16_t)((uVar1 - seqno) * 0x10000 >> 0x10); + cseg->len = new_len; + pbuf_realloc(cseg->p,new_len); + } + goto LAB_23042662; + } + new_len = lwip_htons(next->tcphdr->_hdrlen_rsvd_flags); + if ((new_len & 1) != 0) { + uVar2 = cseg->tcphdr->_hdrlen_rsvd_flags; + new_len = lwip_htons(1); + ptVar5 = cseg->tcphdr; + uVar2 = new_len | uVar2; + *(char *)&ptVar5->_hdrlen_rsvd_flags = (char)uVar2; + *(undefined *)((int)&ptVar5->_hdrlen_rsvd_flags + 1) = (char)((uint)uVar2 >> 8); + } + ptVar3 = next->next; + tcp_seg_free(next); + next = ptVar3; + } while (ptVar3 != (tcp_seg *)0x0); + } + else { + tcp_segs_free(next); + } + next = (tcp_seg *)0x0; +LAB_23042662: + cseg->next = next; + return; +} + + + +void tcp_parseopt(undefined2 *param_1) + +{ + uint uVar1; + u8_t uVar2; + byte bVar3; + undefined2 uVar4; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + + tcp_optidx = 0; + while( true ) { + while( true ) { + do { + uVar1 = (uint)tcphdr_optlen; + if (uVar1 <= tcp_optidx) { + return; + } + uVar2 = tcp_get_next_optbyte(); + } while (CONCAT31(extraout_var,uVar2) == 1); + if (uVar2 == '\0') { + return; + } + if (CONCAT31(extraout_var,uVar2) == 2) break; + uVar2 = tcp_get_next_optbyte(); + if (CONCAT31(extraout_var_02,uVar2) < 2) { + return; + } + tcp_optidx = (tcp_optidx - 2) + (short)CONCAT31(extraout_var_02,uVar2); + } + uVar2 = tcp_get_next_optbyte(); + if (CONCAT31(extraout_var_00,uVar2) != 4) { + return; + } + if (uVar1 <= (uint)tcp_optidx + 1) break; + bVar3 = tcp_get_next_optbyte(); + uVar2 = tcp_get_next_optbyte(); + uVar1 = CONCAT31(extraout_var_01,uVar2) & 0xffff | ((uint)bVar3 << 0x18) >> 0x10; + uVar4 = (undefined2)uVar1; + if (0x2af < (uVar1 - 1 & 0xffff)) { + uVar4 = 0x2b0; + } + *param_1 = uVar4; + } + return; +} + + + +int tcp_input_delayed_close(tcp_pcb *pcb) + +{ + if ((recv_flags & 0x10) != 0) { + if (((pcb->flags & 0x10) == 0) && (pcb->errf != (tcp_err_fn *)0x0)) { + (*pcb->errf)(pcb->callback_arg,-0xf); + } + tcp_pcb_remove(&tcp_active_pcbs,pcb); + tcp_free(pcb); + return 1; + } + return 0; +} + + + +tcp_seg * tcp_free_acked_segments(tcp_seg *seg_list) + +{ + ushort uVar1; + tcp_seg *ptVar2; + u16_t uVar3; + u32_t uVar4; + tcp_seg *in_a1; + + while( true ) { + if (in_a1 == (tcp_seg *)0x0) { + return (tcp_seg *)0x0; + } + uVar4 = lwip_htonl(in_a1->tcphdr->seqno); + uVar1 = in_a1->len; + uVar3 = lwip_htons(in_a1->tcphdr->_hdrlen_rsvd_flags); + if (0 < (int)((uVar1 - ackno) + uVar4 + (uint)((uVar3 & 3) != 0))) break; + ptVar2 = in_a1->next; + uVar3 = pbuf_clen(in_a1->p); + *(u16_t *)&seg_list->next = *(short *)&seg_list->next - uVar3; + recv_acked = in_a1->len + recv_acked; + tcp_seg_free(in_a1); + in_a1 = ptVar2; + } + return in_a1; +} + + + +void tcp_receive(tcp_pcb *pcb) + +{ + ushort n; + ushort uVar1; + short sVar2; + tcp_seg *cseg; + tcp_seg *next; + u16_t new_len; + u16_t uVar3; + int iVar4; + u32_t uVar5; + pbuf *p; + u32_t uVar6; + uint header_size_decrement; + u32_t uVar7; + uint uVar8; + tcp_hdr *ptVar9; + tcpwnd_size_t tVar10; + short sVar11; + tcpflags_t tVar12; + uint uVar13; + uint uVar14; + tcp_seg *ptVar15; + + uVar5 = seqno; + uVar7 = ackno; + if ((flags & 0x10) != 0) { + n = pcb->snd_wnd; + uVar6 = pcb->snd_wl2; + if ((((int)(pcb->snd_wl1 - seqno) < 0) || + ((pcb->snd_wl1 == seqno && ((int)(uVar6 - ackno) < 0)))) || + ((uVar6 == ackno && ((uint)n < (uint)tcphdr->wnd)))) { + uVar1 = tcphdr->wnd; + pcb->snd_wnd = uVar1; + if (pcb->snd_wnd_max < uVar1) { + pcb->snd_wnd_max = uVar1; + } + pcb->snd_wl1 = uVar5; + pcb->snd_wl2 = uVar7; + } + uVar13 = uVar7 - pcb->lastack; + if ((int)uVar13 < 1) { + if ((((tcplen == 0) && ((uint)pcb->snd_wnd + pcb->snd_wl2 == (uint)n + uVar6)) && + (-1 < pcb->rtime)) && (pcb->lastack == uVar7)) { + if (pcb->dupacks != -1) { + pcb->dupacks = pcb->dupacks + '\x01'; + } + if (pcb->dupacks < 4) { + if (pcb->dupacks != 3) goto LAB_2304299c; + } + else { + tVar10 = pcb->mss + pcb->cwnd; + if (tVar10 < pcb->cwnd) { + tVar10 = 0xffff; + } + pcb->cwnd = tVar10; + } + tcp_rexmit_fast(pcb); + } + else { + pcb->dupacks = '\0'; + } + } + else { + if ((int)(uVar7 - pcb->snd_nxt) < 1) { + if ((pcb->flags & 4) != 0) { + pcb->flags = pcb->flags & 0xfffb; + pcb->bytes_acked = 0; + pcb->cwnd = pcb->ssthresh; + } + pcb->lastack = uVar7; + pcb->rto = (pcb->sa >> 3) + pcb->sv; + *(undefined2 *)&pcb->nrtx = 0; + if (SYN_RCVD < pcb->state) { + header_size_decrement = (uint)pcb->cwnd; + uVar13 = uVar13 & 0xffff; + if (header_size_decrement < pcb->ssthresh) { + uVar8 = ((uint)((pcb->flags & 0x800) == 0) + 1) * (uint)pcb->mss; + if (uVar13 < (uVar8 & 0xffff)) { + uVar8 = uVar13; + } + } + else { + uVar13 = uVar13 + pcb->bytes_acked; + uVar8 = uVar13 & 0xffff; + sVar11 = (short)uVar8; + if (uVar8 < pcb->bytes_acked) { + sVar11 = -1; + } + else { + if (uVar8 < header_size_decrement) { + pcb->bytes_acked = (tcpwnd_size_t)(uVar13 * 0x10000 >> 0x10); + goto LAB_23042cf8; + } + } + pcb->bytes_acked = sVar11 - pcb->cwnd; + uVar8 = (uint)pcb->mss; + } + uVar13 = header_size_decrement + uVar8 & 0xffff; + tVar10 = (tcpwnd_size_t)uVar13; + if (uVar13 < header_size_decrement) { + tVar10 = 0xffff; + } + pcb->cwnd = tVar10; + } +LAB_23042cf8: + cseg = tcp_free_acked_segments((tcp_seg *)&pcb->snd_queuelen); + pcb->unacked = cseg; + cseg = tcp_free_acked_segments((tcp_seg *)&pcb->snd_queuelen); + ptVar15 = pcb->unacked; + pcb->unsent = cseg; + pcb->polltmr = '\0'; + pcb->rtime = -(ushort)(ptVar15 == (tcp_seg *)0x0); + if (cseg == (tcp_seg *)0x0) { + pcb->unsent_oversize = 0; + } + pcb->snd_buf = pcb->snd_buf + recv_acked; + if ((int)((uint)pcb->flags << 0x14) < 0) { + if (ptVar15 == (tcp_seg *)0x0) { + if (cseg != (tcp_seg *)0x0) { + uVar7 = pcb->rto_end; + ptVar9 = cseg->tcphdr; + goto LAB_23042d74; + } + } + else { + uVar7 = pcb->rto_end; + ptVar9 = ptVar15->tcphdr; +LAB_23042d74: + uVar5 = lwip_htonl(ptVar9->seqno); + if (0 < (int)(uVar7 - uVar5)) goto LAB_2304299c; + } + pcb->flags = pcb->flags & 0xf7ff; + } + } + else { + tcp_send_empty_ack(pcb); + } + } +LAB_2304299c: + if ((pcb->rttest != 0) && ((int)(pcb->rtseq - ackno) < 0)) { + uVar8 = (uint)(ushort)tcp_ticks; + header_size_decrement = pcb->rttest & 0xffff; + uVar13 = (int)pcb->sa >> 3 & 0xffff; + uVar14 = (uVar8 - header_size_decrement) - uVar13 & 0xffff; + iVar4 = (int)(short)uVar14; + sVar11 = (short)((uVar14 + (int)pcb->sa) * 0x10000 >> 0x10); + pcb->sa = sVar11; + if (iVar4 < 0) { + iVar4 = (int)(((header_size_decrement - uVar8) + uVar13) * 0x10000) >> 0x10; + } + pcb->rttest = 0; + sVar2 = (short)((uint)((((int)pcb->sv - ((int)pcb->sv >> 2)) + iVar4) * 0x10000) >> 0x10); + pcb->sv = sVar2; + pcb->rto = (sVar11 >> 3) + sVar2; + } + } + uVar7 = pcb->rcv_nxt; + if ((tcplen == 0) || (FIN_WAIT_2 < pcb->state)) { + if ((-1 < (int)(seqno - uVar7)) && ((int)(((seqno + 1) - uVar7) - (uint)pcb->rcv_wnd) < 1)) { + return; + } + tVar12 = pcb->flags; + } + else { + uVar13 = uVar7 - seqno; + if (((int)(uVar13 - 1) < 0) || (0 < (int)(((1 - seqno) - (uint)tcplen) + uVar7))) { + if ((int)(seqno - uVar7) < 0) { + pcb->flags = pcb->flags | 2; + } + } + else { + header_size_decrement = uVar13 & 0xffff; + inseg.len = inseg.len - (short)(uVar13 * 0x10000 >> 0x10); + iVar4 = (inseg.p)->tot_len - header_size_decrement; + p = inseg.p; + while (n = p->len, n < header_size_decrement) { + p->tot_len = (u16_t)((uint)(iVar4 * 0x10000) >> 0x10); + p->len = 0; + header_size_decrement = header_size_decrement - n & 0xffff; + p = p->next; + } + pbuf_remove_header(p,header_size_decrement); + ptVar9 = inseg.tcphdr; + uVar7 = pcb->rcv_nxt; + seqno = uVar7; + *(char *)&(inseg.tcphdr)->seqno = (char)uVar7; + *(undefined *)((int)&ptVar9->seqno + 1) = (char)(uVar7 >> 8); + *(undefined *)((int)&ptVar9->seqno + 2) = (char)(uVar7 >> 0x10); + *(undefined *)((int)&ptVar9->seqno + 3) = (char)(uVar7 >> 0x18); + } + uVar7 = pcb->rcv_nxt; + if (((int)(seqno - uVar7) < 0) || (0 < (int)(((seqno + 1) - uVar7) - (uint)pcb->rcv_wnd))) { +LAB_23042ffc: + tcp_send_empty_ack(pcb); + return; + } + if (seqno != uVar7) { + cseg = pcb->ooseq; + ptVar15 = (tcp_seg *)0x0; + if (pcb->ooseq == (tcp_seg *)0x0) { + cseg = tcp_seg_copy(&inseg); + pcb->ooseq = cseg; + } + else { + do { + next = cseg; + uVar7 = next->tcphdr->seqno; + if (seqno == uVar7) { + if ((next->len < inseg.len) && (cseg = tcp_seg_copy(&inseg), cseg != (tcp_seg *)0x0)) { + if (ptVar15 == (tcp_seg *)0x0) { + pcb->ooseq = cseg; + } + else { + ptVar15->next = cseg; + } +LAB_23043062: + tcp_oos_insert_segment(cseg,next); + } + goto LAB_23042ffc; + } + if (ptVar15 == (tcp_seg *)0x0) { + if ((int)(seqno - uVar7) < 0) { + cseg = tcp_seg_copy(&inseg); + if (cseg != (tcp_seg *)0x0) { + pcb->ooseq = cseg; + goto LAB_23043062; + } + goto LAB_23042ffc; + } + } + else { + if ((-1 < (int)((seqno - 1) - ptVar15->tcphdr->seqno)) && + ((int)((seqno + 1) - uVar7) < 1)) { + cseg = tcp_seg_copy(&inseg); + if (cseg != (tcp_seg *)0x0) { + uVar7 = ptVar15->tcphdr->seqno; + if (0 < (int)((ptVar15->len + uVar7) - seqno)) { + new_len = (u16_t)((seqno - uVar7) * 0x10000 >> 0x10); + ptVar15->len = new_len; + pbuf_realloc(ptVar15->p,new_len); + } + ptVar15->next = cseg; + goto LAB_23043062; + } + goto LAB_23042ffc; + } + } + cseg = next->next; + ptVar15 = next; + } while (next->next != (tcp_seg *)0x0); + if ((0 < (int)(seqno - uVar7)) && + (new_len = lwip_htons(next->tcphdr->_hdrlen_rsvd_flags), (new_len & 1) == 0)) { + cseg = tcp_seg_copy(&inseg); + next->next = cseg; + if (cseg != (tcp_seg *)0x0) { + uVar7 = next->tcphdr->seqno; + if (0 < (int)((next->len + uVar7) - seqno)) { + new_len = (u16_t)((seqno - uVar7) * 0x10000 >> 0x10); + next->len = new_len; + pbuf_realloc(next->p,new_len); + } + if (0 < (int)(((tcplen + seqno) - pcb->rcv_nxt) - (uint)pcb->rcv_wnd)) { + new_len = lwip_htons(next->next->tcphdr->_hdrlen_rsvd_flags); + if ((new_len & 1) != 0) { + n = next->next->tcphdr->_hdrlen_rsvd_flags; + new_len = lwip_htons(n); + new_len = lwip_htons(new_len & 0x3e); + ptVar9 = next->next->tcphdr; + uVar13 = (uint)n & 0xffffc0ff | (uint)new_len; + *(char *)&ptVar9->_hdrlen_rsvd_flags = (char)uVar13; + *(undefined *)((int)&ptVar9->_hdrlen_rsvd_flags + 1) = (char)(uVar13 >> 8); + } + next->next->len = (pcb->rcv_wnd - (short)seqno) + (short)pcb->rcv_nxt; + pbuf_realloc(next->next->p,next->next->len); + new_len = next->next->len; + uVar3 = lwip_htons(next->next->tcphdr->_hdrlen_rsvd_flags); + tcplen = new_len + ((uVar3 & 3) != 0); + } + } + } + } + goto LAB_23042ffc; + } + uVar13 = (uint)inseg.len; + new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + uVar13 = ((new_len & 3) != 0) + uVar13; + tcplen = (u16_t)(uVar13 * 0x10000 >> 0x10); + if ((uint)pcb->rcv_wnd < (uVar13 & 0xffff)) { + new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + if ((new_len & 1) != 0) { + n = (inseg.tcphdr)->_hdrlen_rsvd_flags; + new_len = lwip_htons(n); + new_len = lwip_htons(new_len & 0x3e); + ptVar9 = inseg.tcphdr; + uVar13 = (uint)n & 0xffffc0ff | (uint)new_len; + *(char *)&(inseg.tcphdr)->_hdrlen_rsvd_flags = (char)uVar13; + *(undefined *)((int)&ptVar9->_hdrlen_rsvd_flags + 1) = (char)(uVar13 >> 8); + } + inseg.len = pcb->rcv_wnd; + new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + if ((new_len & 2) != 0) { + inseg.len = inseg.len - 1; + } + pbuf_realloc(inseg.p,inseg.len); + new_len = inseg.len; + uVar3 = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + tcplen = new_len + ((uVar3 & 3) != 0); + } + if (pcb->ooseq != (tcp_seg *)0x0) { + new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + if ((new_len & 1) == 0) { + cseg = pcb->ooseq; + while (cseg != (tcp_seg *)0x0) { + uVar7 = cseg->tcphdr->seqno; + if ((int)((tcplen + seqno) - (cseg->len + uVar7)) < 0) { + if (0 < (int)((tcplen + seqno) - uVar7)) { + inseg.len = (short)uVar7 - (short)seqno; + new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + if ((new_len & 2) != 0) { + inseg.len = inseg.len - 1; + } + pbuf_realloc(inseg.p,inseg.len); + new_len = inseg.len; + uVar3 = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + tcplen = new_len + ((uVar3 & 3) != 0); + } + break; + } + new_len = lwip_htons(cseg->tcphdr->_hdrlen_rsvd_flags); + if (((new_len & 1) != 0) && + (new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags), (new_len & 2) == 0)) { + n = (inseg.tcphdr)->_hdrlen_rsvd_flags; + new_len = lwip_htons(1); + ptVar9 = inseg.tcphdr; + n = n | new_len; + *(char *)&(inseg.tcphdr)->_hdrlen_rsvd_flags = (char)n; + *(undefined *)((int)&ptVar9->_hdrlen_rsvd_flags + 1) = (char)((uint)n >> 8); + new_len = inseg.len; + uVar3 = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + tcplen = new_len + ((uVar3 & 3) != 0); + } + ptVar15 = cseg->next; + tcp_seg_free(cseg); + cseg = ptVar15; + } + pcb->ooseq = cseg; + } + else { + while (cseg = pcb->ooseq, cseg != (tcp_seg *)0x0) { + pcb->ooseq = cseg->next; + tcp_seg_free(cseg); + } + } + } + tVar10 = pcb->rcv_wnd - tcplen; + pcb->rcv_nxt = seqno + tcplen; + pcb->rcv_wnd = tVar10; + tcp_update_rcv_ann_wnd(pcb); + if ((inseg.p)->tot_len != 0) { + recv_data = inseg.p; + inseg.p = (pbuf *)0x0; + } + new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + if ((new_len & 1) != 0) { + recv_flags = recv_flags | 0x20; + } + while (cseg = pcb->ooseq, cseg != (tcp_seg *)0x0) { + uVar7 = cseg->tcphdr->seqno; + if (uVar7 != pcb->rcv_nxt) break; + n = cseg->len; + seqno = uVar7; + new_len = lwip_htons(cseg->tcphdr->_hdrlen_rsvd_flags); + pcb->rcv_nxt = (uint)((new_len & 3) != 0) + (uint)n + pcb->rcv_nxt; + lwip_htons(cseg->tcphdr->_hdrlen_rsvd_flags); + new_len = cseg->len; + uVar3 = lwip_htons(cseg->tcphdr->_hdrlen_rsvd_flags); + pcb->rcv_wnd = pcb->rcv_wnd - (((uVar3 & 3) != 0) + new_len); + tcp_update_rcv_ann_wnd(pcb); + p = cseg->p; + if (p->tot_len != 0) { + if (recv_data != (pbuf *)0x0) { + pbuf_cat(recv_data,p); + p = recv_data; + } + recv_data = p; + cseg->p = (pbuf *)0x0; + } + new_len = lwip_htons(cseg->tcphdr->_hdrlen_rsvd_flags); + if (((new_len & 1) != 0) && (recv_flags = recv_flags | 0x20, pcb->state == ESTABLISHED)) { + pcb->state = CLOSE_WAIT; + } + pcb->ooseq = cseg->next; + tcp_seg_free(cseg); + } + n = pcb->flags; + if ((n & 1) == 0) { + tVar12 = n | 1; + goto LAB_23042fca; + } + tVar12 = n & 0xfffe; + } + tVar12 = tVar12 | 2; +LAB_23042fca: + pcb->flags = tVar12; + return; +} + + + +// WARNING: Restarted to delay deadcode elimination for space: ram + +void tcp_input(pbuf *p,netif *inp) + +{ + ushort uVar1; + u16_t uVar2; + byte bVar3; + tcp_hdr *ptVar4; + tcp_hdr *ptVar5; + tcp_pcb *ptVar6; + u8_t uVar7; + err_t eVar8; + u16_t sendmss; + tcpwnd_size_t tVar9; + undefined3 extraout_var; + undefined2 extraout_var_08; + undefined2 extraout_var_09; + undefined3 extraout_var_00; + tcp_pcb *pcb; + u32_t uVar10; + netif *outif; + undefined3 extraout_var_01; + undefined2 extraout_var_10; + tcp_seg *seg; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + undefined3 extraout_var_05; + undefined3 extraout_var_06; + undefined3 extraout_var_07; + uint header_size_decrement; + u32_t ackno; + int iVar11; + tcp_state tVar12; + u16_t uVar13; + tcpflags_t tVar14; + uint uVar15; + void *pvVar16; + tcp_accept_fn paVar17; + uint uVar18; + tcp_pcb *ptVar19; + pbuf *p_00; + u16_t remote_port; + tcp_pcb *ptVar20; + tcp_pcb *pcb_00; + + lwip_stats.tcp.recv = lwip_stats.tcp.recv + 1; + tcphdr = (tcp_hdr *)p->payload; + if (p->len < 0x14) goto LAB_230432a4; + uVar7 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_dest,ip_data.current_netif); + if ((CONCAT31(extraout_var,uVar7) == 0) && ((ip_data.current_iphdr_dest & 0xf0) != 0xe0)) { + sendmss = ip_chksum_pseudo(p,'\x06',p->tot_len,(ip4_addr_t *)&ip_data.current_iphdr_src, + (ip4_addr_t *)&ip_data.current_iphdr_dest); + if (CONCAT22(extraout_var_08,sendmss) == 0) { + sendmss = lwip_htons(tcphdr->_hdrlen_rsvd_flags); + header_size_decrement = CONCAT22(extraout_var_09,sendmss) >> 10 & 0xfc; + if ((0x13 < header_size_decrement) && (header_size_decrement <= p->tot_len)) { + tcphdr_optlen = (u16_t)((header_size_decrement - 0x14) * 0x10000 >> 0x10); + tcphdr_opt2 = (u8_t *)0x0; + if (p->len < header_size_decrement) { + pbuf_remove_header(p,0x14); + sendmss = tcphdr_optlen; + uVar1 = p->len; + header_size_decrement = (uint)tcphdr_optlen; + tcphdr_opt1len = uVar1; + pbuf_remove_header(p,(uint)uVar1); + p_00 = p->next; + header_size_decrement = header_size_decrement - (uint)uVar1 & 0xffff; + if (p_00->len < header_size_decrement) goto LAB_230432a4; + tcphdr_opt2 = (u8_t *)p_00->payload; + pbuf_remove_header(p_00,header_size_decrement); + p->tot_len = (uVar1 + p->tot_len) - sendmss; + } + else { + tcphdr_opt1len = tcphdr_optlen; + pbuf_remove_header(p,header_size_decrement); + } + ptVar4 = tcphdr; + sendmss = lwip_htons(tcphdr->src); + *(char *)&ptVar4->src = (char)sendmss; + *(undefined *)((int)&ptVar4->src + 1) = (char)(sendmss >> 8); + ptVar4 = tcphdr; + sendmss = lwip_htons(tcphdr->dest); + *(char *)&ptVar4->dest = (char)sendmss; + *(undefined *)((int)&ptVar4->dest + 1) = (char)(sendmss >> 8); + ptVar4 = tcphdr; + seqno = lwip_htonl(tcphdr->seqno); + *(undefined *)((int)&ptVar4->seqno + 1) = (char)(seqno >> 8); + *(undefined *)((int)&ptVar4->seqno + 2) = (char)(seqno >> 0x10); + *(char *)&ptVar4->seqno = (char)seqno; + *(undefined *)((int)&ptVar4->seqno + 3) = (char)(seqno >> 0x18); + ptVar4 = tcphdr; + ackno = lwip_htonl(tcphdr->ackno); + *(undefined *)((int)&ptVar4->ackno + 1) = (char)(ackno >> 8); + *(undefined *)((int)&ptVar4->ackno + 2) = (char)(ackno >> 0x10); + *(char *)&ptVar4->ackno = (char)ackno; + *(undefined *)((int)&ptVar4->ackno + 3) = (char)(ackno >> 0x18); + ptVar4 = tcphdr; + sendmss = lwip_htons(tcphdr->wnd); + ptVar5 = tcphdr; + *(char *)&ptVar4->wnd = (char)sendmss; + *(undefined *)((int)&ptVar4->wnd + 1) = (char)(sendmss >> 8); + sendmss = lwip_htons(ptVar5->_hdrlen_rsvd_flags); + ptVar19 = tcp_active_pcbs; + ptVar6 = tcp_listen_pcbs; + ptVar4 = tcphdr; + flags = (byte)sendmss & 0x3f; + tcplen = p->tot_len; + header_size_decrement = (uint)tcplen; + if (((sendmss & 3) == 0) || + (uVar15 = header_size_decrement + 1, tcplen = (u16_t)(uVar15 * 0x10000 >> 0x10), + header_size_decrement <= (uVar15 & 0xffff))) { + uVar2 = tcplen; + pcb = tcp_active_pcbs; + ptVar20 = (tcp_pcb *)0x0; +LAB_230434e6: + pcb_00 = pcb; + pcb = tcp_tw_pcbs; + if (pcb_00 == (tcp_pcb *)0x0) goto LAB_2304374c; + if (((((pcb_00->netif_idx != '\0') && + (pcb_00->netif_idx != (u8_t)((ip_data.current_input_netif)->num + '\x01'))) || + (pcb_00->remote_port != tcphdr->src)) || + ((pcb_00->local_port != tcphdr->dest || + ((pcb_00->remote_ip).addr != ip_data.current_iphdr_src)))) || + ((pcb_00->local_ip).addr != ip_data.current_iphdr_dest)) goto LAB_23043672; + if (ptVar20 == (tcp_pcb *)0x0) { + lwip_stats.tcp.cachehit = lwip_stats.tcp.cachehit + 1; + } + else { + tcp_active_pcbs = pcb_00; + ptVar20->next = pcb_00->next; + pcb_00->next = ptVar19; + } + inseg.len = p->tot_len; + recv_data = (pbuf *)0x0; + recv_flags = '\0'; + recv_acked = 0; + inseg.next = (tcp_seg *)0x0; + inseg.tcphdr = ptVar4; + inseg.p = p; + if ((sendmss & 8) != 0) { + p->flags = p->flags | 1; + } + if ((pcb_00->refused_data != (pbuf *)0x0) && + ((eVar8 = tcp_process_refused_data(pcb_00), CONCAT31(extraout_var_00,eVar8) == -0xd || + ((pcb_00->refused_data != (pbuf *)0x0 && (tcplen != 0)))))) { + if (pcb_00->rcv_ann_wnd == 0) { + tcp_send_empty_ack(pcb_00); + } + lwip_stats.tcp.drop = lwip_stats.tcp.drop + 1; + goto aborted; + } + uVar7 = flags; + tcp_input_pcb = pcb_00; + if ((flags & 4) != 0) { + if (pcb_00->state == SYN_SENT) { + if (pcb_00->snd_nxt != ackno) goto switchD_23043a08_caseD_8; + } + else { + if (pcb_00->rcv_nxt != seqno) { + iVar11 = seqno - pcb_00->rcv_nxt; + if ((-1 < iVar11) && ((int)(iVar11 - (uint)pcb_00->rcv_wnd) < 1)) goto LAB_23043994; + goto switchD_23043a08_caseD_8; + } + } + recv_flags = recv_flags | 8; + tVar14 = pcb_00->flags & 0xfffe; +LAB_2304394e: + pcb_00->flags = tVar14; + goto switchD_23043a08_caseD_8; + } + bVar3 = flags & 2; + tVar14 = pcb_00->flags; + if (((flags & 2) != 0) && (1 < (byte)(pcb_00->state + ~LISTEN))) { +LAB_230439b6: + tVar14 = tVar14 | 2; + goto LAB_2304394e; + } + if ((tVar14 & 0x10) == 0) { + pcb_00->tmr = tcp_ticks; + } + *(undefined2 *)&pcb_00->persist_probe = 0; + if (tcphdr_optlen != 0) { + tcp_parseopt(&pcb_00->mss); + } + ackno = seqno; + switch((uint)pcb_00->state - 2 & 0xff) { + case 0: + if (((uVar7 & 0x12) != 0x12) || (uVar10 = pcb_00->lastack + 1, uVar10 != ackno)) { + if (((uVar7 & 0x10) != 0) && + (tcp_rst(pcb_00,ackno,seqno + tcplen,&ip_data.current_iphdr_dest, + &ip_data.current_iphdr_src,tcphdr->dest,tcphdr->src), pcb_00->nrtx < 6)) { + pcb_00->rtime = 0; + tcp_rexmit_rto(pcb_00); + } + goto switchD_23043a08_caseD_8; + } + pcb_00->lastack = uVar10; + uVar10 = ackno + 1; + pcb_00->rcv_nxt = uVar10; + pcb_00->rcv_ann_right_edge = uVar10; + sendmss = pcb_00->mss; + uVar2 = tcphdr->wnd; + pcb_00->snd_wl1 = ackno - 1; + pcb_00->snd_wnd = uVar2; + pcb_00->snd_wnd_max = uVar2; + pcb_00->state = ESTABLISHED; + outif = ip4_route((ip4_addr_t *)&pcb_00->remote_ip); + sendmss = tcp_eff_send_mss_netif + (sendmss,outif,(ip_addr_t *)(ip4_addr_t *)&pcb_00->remote_ip); + iVar11 = CONCAT22(extraout_var_10,sendmss); + uVar15 = iVar11 << 1; + pcb_00->mss = sendmss; + tVar9 = 0x111c; + header_size_decrement = uVar15; + if (uVar15 < 0x111c) { + header_size_decrement = 0x111c; + } + if ((uint)(iVar11 << 2) < header_size_decrement) { + tVar9 = (tcpwnd_size_t)((uint)(iVar11 << 0x12) >> 0x10); + } + else { + if (0x111c < uVar15) { + tVar9 = (tcpwnd_size_t)((uint)(iVar11 << 0x11) >> 0x10); + } + } + pcb_00->cwnd = tVar9; + seg = pcb_00->unacked; + pcb_00->snd_queuelen = pcb_00->snd_queuelen - 1; + if (seg == (tcp_seg *)0x0) { + seg = pcb_00->unsent; + pcb_00->unsent = seg->next; + } + else { + pcb_00->unacked = seg->next; + } + tcp_seg_free(seg); + if (pcb_00->unacked == (tcp_seg *)0x0) { + pcb_00->rtime = -1; + } + else { + pcb_00->rtime = 0; + pcb_00->nrtx = '\0'; + } + if ((pcb_00->connected == (tcp_connected_fn)0x0) || + (eVar8 = (*pcb_00->connected)(pcb_00->callback_arg,pcb_00,'\0'), + CONCAT31(extraout_var_02,eVar8) != -0xd)) { +LAB_23043994: + tVar14 = pcb_00->flags; + goto LAB_230439b6; + } + goto aborted; + case 1: + if ((uVar7 & 0x10) == 0) { + if ((bVar3 != 0) && (pcb_00->rcv_nxt - 1 == seqno)) { + tcp_rexmit(pcb_00); + } + goto switchD_23043a08_caseD_8; + } + if (((int)((ackno - 1) - pcb_00->lastack) < 0) || (0 < (int)(ackno - pcb_00->snd_nxt))) + { + tcp_rst(pcb_00,ackno,seqno + tcplen,&ip_data.current_iphdr_dest, + &ip_data.current_iphdr_src,tcphdr->dest,tcphdr->src); + goto switchD_23043a08_caseD_8; + } + pcb_00->state = ESTABLISHED; + if ((pcb_00->listener == (tcp_pcb_listen *)0x0) || + (paVar17 = pcb_00->listener->accept, paVar17 == (tcp_accept_fn)0x0)) + goto LAB_23043b68; + eVar8 = (*paVar17)(pcb_00->callback_arg,pcb_00,'\0'); + if (CONCAT31(extraout_var_03,eVar8) != 0) { + if (CONCAT31(extraout_var_03,eVar8) == -0xd) goto aborted; + goto LAB_23043b68; + } + tcp_receive(pcb_00); + if (recv_acked != 0) { + recv_acked = recv_acked - 1; + } + uVar18 = (uint)pcb_00->mss; + uVar15 = uVar18 << 1; + tVar9 = 0x111c; + header_size_decrement = uVar15; + if (uVar15 < 0x111c) { + header_size_decrement = 0x111c; + } + if (uVar18 << 2 < header_size_decrement) { + tVar9 = (tcpwnd_size_t)((uVar18 << 0x12) >> 0x10); + } + else { + if (0x111c < uVar15) { + tVar9 = (tcpwnd_size_t)((uVar18 << 0x11) >> 0x10); + } + } + pcb_00->cwnd = tVar9; + break; + case 2: + case 5: + tcp_receive(pcb_00); + break; + case 3: + tcp_receive(pcb_00); + if ((recv_flags & 0x20) != 0) { + if ((((flags & 0x10) == 0) || (pcb_00->snd_nxt != ackno)) || + (pcb_00->unsent != (tcp_seg *)0x0)) { + pcb_00->flags = pcb_00->flags | 2; + tVar12 = CLOSING; + goto LAB_23043bda; + } + pcb_00->flags = pcb_00->flags | 2; + tcp_pcb_purge(pcb_00); + ptVar6 = tcp_active_pcbs; + if (pcb_00 == tcp_active_pcbs) goto LAB_23043c86; + goto LAB_23043c9c; + } + if ((((flags & 0x10) == 0) || (pcb_00->snd_nxt != ackno)) || + (pcb_00->unsent != (tcp_seg *)0x0)) goto switchD_23043a08_caseD_8; + tVar12 = FIN_WAIT_2; + goto LAB_23043bda; + case 4: + tcp_receive(pcb_00); + if ((recv_flags & 0x20) == 0) goto switchD_23043a08_caseD_8; + pcb_00->flags = pcb_00->flags | 2; + tcp_pcb_purge(pcb_00); + ptVar6 = tcp_active_pcbs; + if (pcb_00 == tcp_active_pcbs) goto LAB_23043c86; + goto LAB_23043d18; + case 6: + tcp_receive(pcb_00); + if ((((flags & 0x10) == 0) || (pcb_00->snd_nxt != ackno)) || + (pcb_00->unsent != (tcp_seg *)0x0)) goto switchD_23043a08_caseD_8; + tcp_pcb_purge(pcb_00); + ptVar6 = tcp_active_pcbs; + if (pcb_00 != tcp_active_pcbs) goto LAB_23043d52; +LAB_23043c86: + tcp_active_pcbs = pcb_00->next; + goto LAB_23043c9e; + case 7: + tcp_receive(pcb_00); + if ((((flags & 0x10) != 0) && (pcb_00->snd_nxt == ackno)) && + (pcb_00->unsent == (tcp_seg *)0x0)) { + recv_flags = recv_flags | 0x10; + } + default: + goto switchD_23043a08_caseD_8; + } + if ((recv_flags & 0x20) == 0) goto switchD_23043a08_caseD_8; + pcb_00->flags = pcb_00->flags | 2; + tVar12 = CLOSE_WAIT; +LAB_23043bda: + pcb_00->state = tVar12; + goto switchD_23043a08_caseD_8; + } + } +LAB_230432a4: + lwip_stats.tcp.lenerr = lwip_stats.tcp.lenerr + 1; + } + else { + lwip_stats.tcp.chkerr = lwip_stats.tcp.chkerr + 1; + } + } + else { + lwip_stats.tcp.proterr = lwip_stats.tcp.proterr + 1; + } + lwip_stats.tcp.drop = lwip_stats.tcp.drop + 1; +LAB_23043728: + pbuf_free(p); + return; +LAB_2304374c: + if (pcb == (tcp_pcb *)0x0) goto code_r0x2304374e; + if ((((pcb->netif_idx == '\0') || + (pcb->netif_idx == (u8_t)((ip_data.current_input_netif)->num + '\x01'))) && + ((remote_port = pcb->remote_port, remote_port == tcphdr->src && + ((uVar13 = pcb->local_port, uVar13 == tcphdr->dest && + (ip_data.current_iphdr_src == (pcb->remote_ip).addr)))))) && + (ip_data.current_iphdr_dest == (pcb->local_ip).addr)) { + if ((sendmss & 4) != 0) goto LAB_23043728; + if ((sendmss & 2) == 0) { + if ((sendmss & 1) != 0) { + pcb->tmr = tcp_ticks; + } + } + else { + iVar11 = seqno - pcb->rcv_nxt; + if ((-1 < iVar11) && ((int)(iVar11 - (uint)pcb->rcv_wnd) < 1)) { + ackno = tcplen + seqno; + goto LAB_23043702; + } + } + if (uVar2 == 0) goto LAB_23043728; + pcb->flags = pcb->flags | 2; + goto LAB_23043724; + } + pcb = pcb->next; + goto LAB_2304374c; +code_r0x2304374e: + ptVar20 = (tcp_pcb *)0x0; + pcb_00 = (tcp_pcb *)0x0; + ptVar19 = tcp_listen_pcbs; + while (ptVar19 != (tcp_pcb *)0x0) { + if (((ptVar19->netif_idx == '\0') || + (ptVar19->netif_idx == (u8_t)((ip_data.current_input_netif)->num + '\x01'))) && + (ptVar19->local_port == tcphdr->dest)) { + ackno = (ptVar19->local_ip).addr; + if (ip_data.current_iphdr_dest == ackno) goto LAB_230437aa; + if (ackno == 0) { + ptVar20 = ptVar19; + pcb_00 = pcb; + } + } + pcb = ptVar19; + ptVar19 = ptVar19->next; + } + pcb = pcb_00; + ptVar19 = ptVar20; + if (ptVar20 == (tcp_pcb *)0x0) { + sendmss = lwip_htons(tcphdr->_hdrlen_rsvd_flags); + if ((sendmss & 4) != 0) goto LAB_23043728; + lwip_stats.tcp.proterr = lwip_stats.tcp.proterr + 1; + lwip_stats.tcp.drop = lwip_stats.tcp.drop + 1; + remote_port = tcphdr->src; + uVar13 = tcphdr->dest; + ackno = seqno + tcplen; + pcb = (tcp_pcb *)0x0; + } + else { +LAB_230437aa: + if (pcb == (tcp_pcb *)0x0) { + lwip_stats.tcp.cachehit = lwip_stats.tcp.cachehit + 1; + } + else { + tcp_listen_pcbs = ptVar19; + pcb->next = ptVar19->next; + ptVar19->next = ptVar6; + } + if ((sendmss & 4) != 0) goto LAB_23043728; + if ((sendmss & 0x10) == 0) { + if ((sendmss & 2) != 0) { + pcb = tcp_alloc(ptVar19->prio); + ptVar4 = tcphdr; + if (pcb == (tcp_pcb *)0x0) { + lwip_stats.tcp.memerr = lwip_stats.tcp.memerr + 1; + if (*(code **)&ptVar19->remote_port != (code *)0x0) { + (**(code **)&ptVar19->remote_port)(ptVar19->callback_arg,0,0xffffffff); + } + } + else { + (pcb->local_ip).addr = ip_data.current_iphdr_dest; + (pcb->remote_ip).addr = ip_data.current_iphdr_src; + pcb->local_port = ptVar19->local_port; + pcb->remote_port = ptVar4->src; + pcb->state = SYN_RCVD; + ackno = seqno + 1; + pcb->rcv_nxt = ackno; + pcb->rcv_ann_right_edge = ackno; + uVar10 = tcp_next_iss(pcb); + ackno = seqno; + pcb->snd_wl2 = uVar10; + pcb->snd_nxt = uVar10; + pcb->lastack = uVar10; + pcb->snd_lbb = uVar10; + pcb->snd_wl1 = ackno - 1; + pvVar16 = ptVar19->callback_arg; + *(tcp_pcb **)&pcb->listener = ptVar19; + pcb->callback_arg = pvVar16; + pcb->so_options = ptVar19->so_options & 0xc; + pcb->netif_idx = ptVar19->netif_idx; + ptVar6 = pcb; + pcb->next = tcp_active_pcbs; + tcp_active_pcbs = ptVar6; + tcp_timer_needed(); + tcp_active_pcbs_changed = '\x01'; + if (tcphdr_optlen != 0) { + tcp_parseopt(&pcb->mss); + } + uVar2 = tcphdr->wnd; + sendmss = pcb->mss; + pcb->snd_wnd = uVar2; + pcb->snd_wnd_max = uVar2; + outif = ip4_route((ip4_addr_t *)&pcb->remote_ip); + sendmss = tcp_eff_send_mss_netif(sendmss,outif,(ip_addr_t *)(ip4_addr_t *)&pcb->remote_ip) + ; + pcb->mss = sendmss; + eVar8 = tcp_enqueue_flags(pcb,'\x12'); + if (CONCAT31(extraout_var_01,eVar8) == 0) { +LAB_23043724: + tcp_output(pcb); + } + else { + tcp_abandon(pcb,0); + } + } + } + goto LAB_23043728; + } + remote_port = tcphdr->src; + uVar13 = tcphdr->dest; + ackno = seqno + tcplen; + pcb = ptVar19; + } +LAB_23043702: + tcp_rst(pcb,ackno,ackno,&ip_data.current_iphdr_dest,&ip_data.current_iphdr_src,uVar13,remote_port) + ; + goto LAB_23043728; +LAB_23043672: + pcb = pcb_00->next; + ptVar20 = pcb_00; + goto LAB_230434e6; + while (ptVar6 = ptVar19->next, pcb_00 != ptVar19->next) { +LAB_23043d52: + ptVar19 = ptVar6; + if (ptVar19 == (tcp_pcb *)0x0) goto LAB_23043c9e; + } + goto LAB_23043c94; + while (ptVar6 = ptVar19->next, pcb_00 != ptVar19->next) { +LAB_23043d18: + ptVar19 = ptVar6; + if (ptVar19 == (tcp_pcb *)0x0) goto LAB_23043c9e; + } + goto LAB_23043c94; + while (ptVar6 = ptVar19->next, pcb_00 != ptVar19->next) { +LAB_23043c9c: + ptVar19 = ptVar6; + if (ptVar19 == (tcp_pcb *)0x0) goto LAB_23043c9e; + } +LAB_23043c94: + ptVar19->next = pcb_00->next; +LAB_23043c9e: + tcp_active_pcbs_changed = '\x01'; + pcb_00->state = TIME_WAIT; + ptVar6 = pcb_00; + pcb_00->next = tcp_tw_pcbs; + tcp_tw_pcbs = ptVar6; + tcp_timer_needed(); +switchD_23043a08_caseD_8: + if ((recv_flags & 8) == 0) { + if (recv_acked != 0) { + if ((pcb_00->sent != (tcp_sent_fn *)0x0) && + (eVar8 = (*pcb_00->sent)(pcb_00->callback_arg,pcb_00,recv_acked), + CONCAT31(extraout_var_04,eVar8) == -0xd)) goto aborted; + recv_acked = 0; + } + iVar11 = tcp_input_delayed_close(pcb_00); + if (iVar11 == 0) { + if (recv_data != (pbuf *)0x0) { + if ((pcb_00->flags & 0x10) != 0) { + pbuf_free(recv_data); +LAB_23043b68: + tcp_abort(pcb_00); + goto aborted; + } + if (pcb_00->recv == (tcp_recv_fn *)0x0) { + eVar8 = tcp_recv_null((void *)0x0,pcb_00,recv_data,'\0'); + iVar11 = CONCAT31(extraout_var_06,eVar8); + } + else { + eVar8 = (*pcb_00->recv)(pcb_00->callback_arg,pcb_00,recv_data,'\0'); + iVar11 = CONCAT31(extraout_var_05,eVar8); + } + if (iVar11 == -0xd) goto aborted; + if (iVar11 != 0) { + pcb_00->refused_data = recv_data; + } + } + if ((recv_flags & 0x20) != 0) { + p_00 = pcb_00->refused_data; + if (p_00 == (pbuf *)0x0) { + if (pcb_00->rcv_wnd != 0x810) { + pcb_00->rcv_wnd = pcb_00->rcv_wnd + 1; + } + if ((pcb_00->recv != (tcp_recv_fn *)0x0) && + (eVar8 = (*pcb_00->recv)(pcb_00->callback_arg,pcb_00,(pbuf *)0x0,'\0'), + CONCAT31(extraout_var_07,eVar8) == -0xd)) goto aborted; + } + else { + p_00->flags = p_00->flags | 0x20; + } + } + tcp_input_pcb = (tcp_pcb *)0x0; + iVar11 = tcp_input_delayed_close(pcb_00); + if (iVar11 == 0) { + tcp_output(pcb_00); + } + } + } + else { + if (pcb_00->errf != (tcp_err_fn *)0x0) { + (*pcb_00->errf)(pcb_00->callback_arg,-0xe); + } + tcp_pcb_remove(&tcp_active_pcbs,pcb_00); + tcp_free(pcb_00); + } +aborted: + tcp_input_pcb = (tcp_pcb *)0x0; + recv_data = (pbuf *)0x0; + if (inseg.p != (pbuf *)0x0) { + pbuf_free(inseg.p); + inseg.p = (pbuf *)0x0; + } + return; +} + + + +void tcp_trigger_input_pcb_close(void) + +{ + recv_flags = recv_flags | 0x10; + return; +} + + + +void tcp_seg_add_chksum(u16_t chksum,u16_t len,u16_t *seg_chksum,u8_t *seg_chksum_swapped) + +{ + ushort uVar1; + undefined2 in_register_0000202a; + uint uVar2; + + uVar2 = CONCAT22(in_register_0000202a,chksum) + (uint)*seg_chksum; + uVar2 = uVar2 + (uVar2 >> 0x10) & 0xffff; + uVar1 = (ushort)uVar2; + if ((len & 1) != 0) { + *seg_chksum_swapped = '\x01' - *seg_chksum_swapped; + uVar1 = (ushort)(uVar2 >> 8) | (ushort)(uVar2 << 8); + } + *seg_chksum = uVar1; + return; +} + + + +tcp_seg * tcp_create_segment(tcp_pcb *pcb,pbuf *p,u8_t hdrflags,u32_t seqno,u8_t optflags) + +{ + tcp_seg *seg; + u8_t uVar1; + u16_t uVar2; + undefined3 extraout_var; + u32_t uVar3; + undefined3 in_register_00002031; + tcp_hdr *ptVar4; + + seg = (tcp_seg *)memp_malloc(MEMP_TCP_SEG); + if (seg == (tcp_seg *)0x0) { + pbuf_free(p); + } + else { + seg->flags = optflags; + seg->next = (tcp_seg *)0x0; + seg->p = p; + uVar2 = p->tot_len; + seg->chksum = 0; + seg->len = uVar2 + ((ushort)optflags & 1) * -4; + seg->chksum_swapped = '\0'; + uVar1 = pbuf_add_header(p,0x14); + if (CONCAT31(extraout_var,uVar1) == 0) { + ptVar4 = (tcp_hdr *)seg->p->payload; + seg->tcphdr = ptVar4; + uVar2 = lwip_htons(pcb->local_port); + *(char *)&ptVar4->src = (char)uVar2; + *(undefined *)((int)&ptVar4->src + 1) = (char)(uVar2 >> 8); + ptVar4 = seg->tcphdr; + uVar2 = lwip_htons(pcb->remote_port); + *(char *)&ptVar4->dest = (char)uVar2; + *(undefined *)((int)&ptVar4->dest + 1) = (char)(uVar2 >> 8); + ptVar4 = seg->tcphdr; + uVar3 = lwip_htonl(seqno); + *(char *)&ptVar4->seqno = (char)uVar3; + *(undefined *)((int)&ptVar4->seqno + 1) = (char)(uVar3 >> 8); + *(undefined *)((int)&ptVar4->seqno + 3) = (char)(uVar3 >> 0x18); + *(undefined *)((int)&ptVar4->seqno + 2) = (char)(uVar3 >> 0x10); + ptVar4 = seg->tcphdr; + uVar2 = lwip_htons((((ushort)optflags & 1) + 5) * 0x1000 | + (ushort)CONCAT31(in_register_00002031,hdrflags)); + *(char *)&ptVar4->_hdrlen_rsvd_flags = (char)uVar2; + *(undefined *)((int)&ptVar4->_hdrlen_rsvd_flags + 1) = (char)(uVar2 >> 8); + ptVar4 = seg->tcphdr; + *(undefined *)&ptVar4->urgp = 0; + *(undefined *)((int)&ptVar4->urgp + 1) = 0; + } + else { + lwip_stats.tcp.err = lwip_stats.tcp.err + 1; + tcp_seg_free(seg); + seg = (tcp_seg *)0x0; + } + } + return seg; +} + + + +pbuf * tcp_output_alloc_header_common + (u32_t ackno,u16_t datalen,u32_t seqno_be,u16_t src_port,u16_t dst_port,u8_t flags, + u16_t wnd) + +{ + undefined *puVar1; + u16_t uVar2; + pbuf *ppVar3; + u32_t uVar4; + undefined2 in_register_0000202e; + undefined3 in_register_0000203d; + + ppVar3 = pbuf_alloc(PBUF_IP,(u16_t)((uint)((CONCAT22(in_register_0000202e,datalen) + 0x14) * + 0x10000) >> 0x10),PBUF_RAM); + if (ppVar3 != (pbuf *)0x0) { + puVar1 = (undefined *)ppVar3->payload; + uVar2 = lwip_htons(src_port); + *puVar1 = (char)uVar2; + puVar1[1] = (char)(uVar2 >> 8); + uVar2 = lwip_htons(dst_port); + puVar1[2] = (char)uVar2; + puVar1[4] = (char)seqno_be; + puVar1[5] = (char)(seqno_be >> 8); + puVar1[3] = (char)(uVar2 >> 8); + puVar1[6] = (char)(seqno_be >> 0x10); + puVar1[7] = (char)(seqno_be >> 0x18); + uVar4 = lwip_htonl(ackno); + puVar1[8] = (char)uVar4; + puVar1[9] = (char)(uVar4 >> 8); + puVar1[0xb] = (char)(uVar4 >> 0x18); + puVar1[10] = (char)(uVar4 >> 0x10); + uVar2 = lwip_htons((ushort)CONCAT31(in_register_0000203d,flags) | 0x5000); + puVar1[0xc] = (char)uVar2; + puVar1[0xd] = (char)(uVar2 >> 8); + uVar2 = lwip_htons(wnd); + puVar1[0xe] = (char)uVar2; + puVar1[0xf] = (char)(uVar2 >> 8); + puVar1[0x10] = 0; + puVar1[0x11] = 0; + puVar1[0x12] = 0; + puVar1[0x13] = 0; + } + return ppVar3; +} + + + +pbuf * tcp_output_alloc_header(tcp_pcb *pcb,u16_t datalen,u32_t seqno_be) + +{ + pbuf *ppVar1; + + ppVar1 = tcp_output_alloc_header_common + (pcb->rcv_nxt,datalen,seqno_be,pcb->local_port,pcb->remote_port,'\x10', + pcb->rcv_ann_wnd); + if (ppVar1 != (pbuf *)0x0) { + pcb->rcv_ann_right_edge = pcb->rcv_nxt + (uint)pcb->rcv_ann_wnd; + } + return ppVar1; +} + + + +err_t tcp_output_control_segment(tcp_pcb *pcb,pbuf *p,ip_addr_t *src,ip_addr_t *dst) + +{ + err_t eVar1; + u16_t uVar2; + netif *netif; + u8_t ttl; + u8_t tos; + void *pvVar3; + + if ((pcb == (tcp_pcb *)0x0) || (pcb->netif_idx == '\0')) { + netif = ip4_route((ip4_addr_t *)dst); + } + else { + netif = netif_get_by_index(pcb->netif_idx); + } + eVar1 = -4; + if (netif != (netif *)0x0) { + pvVar3 = p->payload; + uVar2 = ip_chksum_pseudo(p,'\x06',p->tot_len,(ip4_addr_t *)src,(ip4_addr_t *)dst); + *(undefined *)((int)pvVar3 + 0x10) = (char)uVar2; + *(undefined *)((int)pvVar3 + 0x11) = (char)(uVar2 >> 8); + if (pcb == (tcp_pcb *)0x0) { + tos = '\0'; + ttl = -1; + } + else { + ttl = pcb->ttl; + tos = pcb->tos; + } + lwip_stats.tcp.xmit = lwip_stats.tcp.xmit + 1; + eVar1 = ip4_output_if(p,(ip4_addr_t *)src,(ip4_addr_t *)dst,ttl,tos,'\x06',netif); + } + pbuf_free(p); + return eVar1; +} + + + +err_t tcp_write(tcp_pcb *pcb,void *arg,u16_t len,u8_t apiflags) + +{ + ushort uVar1; + tcp_seg *ptVar2; + u16_t chksum_00; + u16_t uVar3; + u16_t len_00; + undefined2 in_register_00002032; + uint uVar4; + uint uVar5; + uint uVar6; + uint uVar7; + tcp_hdr *ptVar8; + err_t eVar9; + err_t eVar10; + uint uVar11; + tcp_seg *ptVar12; + tcp_seg *seg; + tcp_seg *ptVar13; + uint uVar14; + pbuf *p; + tcp_seg *ptVar15; + u8_t uStack67; + u16_t uStack66; + u8_t chksum_swapped; + u16_t chksum; + + uVar4 = CONCAT22(in_register_00002032,len); + if (pcb == (tcp_pcb *)0x0) { + return -0x10; + } + uVar5 = (uint)pcb->mss; + uVar7 = (uint)(pcb->snd_wnd_max >> 1); + if (uVar5 < uVar7) { + uVar7 = uVar5; + } + if (uVar7 == 0) { + uVar7 = uVar5; + } + if (arg == (void *)0x0) { + return -0x10; + } + if ((pcb->state != CLOSE_WAIT) && (2 < (byte)(pcb->state + ~LISTEN))) { + return -0xb; + } + if (uVar4 == 0) { +LAB_23044268: + ptVar2 = pcb->unsent; + uVar3 = pcb->snd_queuelen; + if (ptVar2 == (tcp_seg *)0x0) { + ptVar15 = (tcp_seg *)0x0; + uVar5 = 0; + uVar11 = 0; + } + else { + do { + ptVar15 = ptVar2; + ptVar2 = ptVar15->next; + } while (ptVar2 != (tcp_seg *)0x0); + uVar5 = (uint)pcb->unsent_oversize; + uVar11 = 0; + if (pcb->unsent_oversize != 0) { + uVar11 = (uVar7 - ptVar15->len) + ((uint)ptVar15->flags & 1) * -4; + uVar14 = uVar5; + if (uVar4 < uVar5) { + uVar14 = uVar4; + } + if ((uVar14 & 0xffff) < (uVar11 & 0xffff)) { + uVar11 = uVar14; + } + uVar11 = uVar11 & 0xffff; + uVar5 = uVar5 - uVar11 & 0xffff; + ptVar2 = ptVar15; + } + } + seg = (tcp_seg *)0x0; + ptVar13 = (tcp_seg *)0x0; + uVar14 = uVar11; + while (uVar14 < uVar4) { + uVar6 = uVar4 - uVar14; + if (uVar7 < (uVar4 - uVar14 & 0xffff)) { + uVar6 = uVar7; + } + uStack66 = 0; + uStack67 = '\0'; + p = pbuf_alloc(PBUF_TRANSPORT,(u16_t)uVar7,PBUF_RAM); + if (p == (pbuf *)0x0) { +memerr: + pcb->flags = pcb->flags | 0x80; + lwip_stats.tcp.memerr = lwip_stats.tcp.memerr + 1; + if (seg != (tcp_seg *)0x0) { + tcp_segs_free(seg); + } + goto LAB_23044228; + } + uVar1 = p->len; + len_00 = (u16_t)uVar6; + p->tot_len = len_00; + p->len = len_00; + chksum_00 = lwip_chksum_copy(p->payload,(void *)((int)arg + uVar14),len_00); + tcp_seg_add_chksum(chksum_00,len_00,&uStack66,&uStack67); + chksum_00 = pbuf_clen(p); + uVar3 = uVar3 + chksum_00; + uVar5 = (uint)uVar1 - (uVar6 & 0xffff) & 0xffff; + if (0x10 < uVar3) { + pbuf_free(p); + goto memerr; + } + ptVar2 = tcp_create_segment(pcb,p,'\0',pcb->snd_lbb + uVar14,'\0'); + if (ptVar2 == (tcp_seg *)0x0) goto memerr; + ptVar2->chksum = uStack66; + ptVar2->chksum_swapped = uStack67; + ptVar2->flags = ptVar2->flags | 4; + ptVar12 = ptVar2; + if (seg != (tcp_seg *)0x0) { + ptVar13->next = ptVar2; + ptVar12 = seg; + } + uVar14 = uVar14 + (uVar6 & 0xffff) & 0xffff; + seg = ptVar12; + ptVar13 = ptVar2; + } + if (uVar11 != 0) { + p = ptVar15->p; + while (chksum_00 = (u16_t)uVar11, p != (pbuf *)0x0) { + p->tot_len = p->tot_len + chksum_00; + if (p->next == (pbuf *)0x0) { + len_00 = lwip_chksum_copy((void *)((int)p->payload + (uint)p->len),arg,chksum_00); + tcp_seg_add_chksum(len_00,chksum_00,&ptVar15->chksum,&ptVar15->chksum_swapped); + ptVar15->flags = ptVar15->flags | 4; + p->len = p->len + chksum_00; + } + p = p->next; + } + ptVar15->len = chksum_00 + ptVar15->len; + } + pcb->unsent_oversize = (u16_t)uVar5; + if (ptVar15 == (tcp_seg *)0x0) { + pcb->unsent = seg; + } + else { + ptVar15->next = seg; + } + pcb->snd_queuelen = uVar3; + pcb->snd_lbb = pcb->snd_lbb + uVar4; + pcb->snd_buf = pcb->snd_buf - len; + eVar10 = '\0'; + eVar9 = '\0'; + if (((ptVar2 != (tcp_seg *)0x0) && (eVar9 = eVar10, ptVar2->tcphdr != (tcp_hdr *)0x0)) && + ((apiflags & 2) == 0)) { + uVar1 = ptVar2->tcphdr->_hdrlen_rsvd_flags; + uVar3 = lwip_htons(8); + ptVar8 = ptVar2->tcphdr; + uVar1 = uVar3 | uVar1; + *(char *)&ptVar8->_hdrlen_rsvd_flags = (char)uVar1; + *(undefined *)((int)&ptVar8->_hdrlen_rsvd_flags + 1) = (char)((uint)uVar1 >> 8); + } + } + else { + if (uVar4 <= pcb->snd_buf) { + if (pcb->snd_queuelen < 0x10) goto LAB_23044268; + lwip_stats.tcp.memerr = lwip_stats.tcp.memerr + 1; + } + pcb->flags = pcb->flags | 0x80; +LAB_23044228: + eVar9 = -1; + } + return eVar9; +} + + + +err_t tcp_split_unsent_seg(tcp_pcb *pcb,u16_t split) + +{ + byte bVar1; + ushort *puVar2; + ushort uVar3; + tcp_seg *ptVar4; + uint uVar5; + u16_t len; + u16_t uVar6; + pbuf *p; + undefined2 extraout_var; + u32_t uVar7; + tcp_seg *ptVar8; + undefined2 in_register_0000202e; + byte hdrflags; + tcp_hdr *ptVar9; + int iVar10; + uint uVar11; + uint uVar12; + u8_t uStack51; + u16_t uStack50; + u8_t chksum_swapped; + u16_t chksum; + + uVar5 = CONCAT22(in_register_0000202e,split); + ptVar4 = pcb->unsent; + uStack50 = 0; + uStack51 = '\0'; + if (ptVar4 != (tcp_seg *)0x0) { + if (uVar5 == 0) { + return -6; + } + uVar11 = (uint)ptVar4->len; + if (uVar11 <= uVar5) { + return '\0'; + } + bVar1 = ptVar4->flags; + iVar10 = ((uint)bVar1 & 1) * 4; + uVar12 = uVar11 - uVar5 & 0xffff; + p = pbuf_alloc(PBUF_TRANSPORT,(u16_t)((uVar12 + iVar10) * 0x10000 >> 0x10),PBUF_RAM); + if ((p != (pbuf *)0x0) && + (len = pbuf_copy_partial(ptVar4->p,(void *)((int)p->payload + iVar10), + (u16_t)((uVar11 - uVar5) * 0x10000 >> 0x10), + (u16_t)((((uint)ptVar4->p->tot_len - (uint)ptVar4->len) + uVar5) * + 0x10000 >> 0x10)), CONCAT22(extraout_var,len) == uVar12)) { + uVar6 = inet_chksum((void *)((int)p->payload + iVar10),len); + tcp_seg_add_chksum(~uVar6,len,&uStack50,&uStack51); + len = lwip_htons(ptVar4->tcphdr->_hdrlen_rsvd_flags); + hdrflags = (byte)len & 8; + if ((len & 8) == 0) { + len = len & 0x3f; + } + else { + len = len & 0x37; + hdrflags = 8; + } + if ((len & 1) != 0) { + len = len & 0xfe; + hdrflags = hdrflags | 1; + } + uVar7 = lwip_htonl(ptVar4->tcphdr->seqno); + ptVar8 = tcp_create_segment(pcb,p,hdrflags,uVar5 + uVar7,bVar1 & 0xfb); + if (ptVar8 != (tcp_seg *)0x0) { + ptVar8->chksum = uStack50; + ptVar8->chksum_swapped = uStack51; + ptVar8->flags = ptVar8->flags | 4; + uVar6 = pbuf_clen(ptVar4->p); + pcb->snd_queuelen = pcb->snd_queuelen - uVar6; + pbuf_realloc(ptVar4->p, + (u16_t)(((uint)ptVar4->p->tot_len + (uVar5 - uVar11 & 0xffff)) * 0x10000 >> + 0x10)); + ptVar4->len = (short)((uVar5 - uVar11) * 0x10000 >> 0x10) + ptVar4->len; + uVar3 = ptVar4->tcphdr->_hdrlen_rsvd_flags; + len = lwip_htons(len); + ptVar9 = ptVar4->tcphdr; + uVar3 = uVar3 | len; + *(char *)&ptVar9->_hdrlen_rsvd_flags = (char)uVar3; + *(undefined *)((int)&ptVar9->_hdrlen_rsvd_flags + 1) = (char)((uint)uVar3 >> 8); + len = pbuf_clen(ptVar4->p); + pcb->snd_queuelen = len + pcb->snd_queuelen; + p = ptVar4->p; + ptVar4->chksum = 0; + ptVar4->chksum_swapped = '\0'; + uVar5 = (uint)p->tot_len - (uint)ptVar4->len; + while( true ) { + uVar5 = uVar5 & 0xffff; + puVar2 = &p->len; + if (uVar5 <= *puVar2) break; + p = p->next; + uVar5 = uVar5 - *puVar2; + if (p == (pbuf *)0x0) goto LAB_230446e4; + } + do { + len = inet_chksum((void *)((int)p->payload + uVar5), + (u16_t)((p->len - uVar5) * 0x10000 >> 0x10)); + tcp_seg_add_chksum(~len,(u16_t)((p->len - uVar5) * 0x10000 >> 0x10),&ptVar4->chksum, + &ptVar4->chksum_swapped); + p = p->next; + uVar5 = 0; + } while (p != (pbuf *)0x0); +LAB_230446e4: + len = pbuf_clen(ptVar8->p); + pcb->snd_queuelen = len + pcb->snd_queuelen; + ptVar8->next = ptVar4->next; + ptVar4->next = ptVar8; + ptVar4 = ptVar8->next; + if (ptVar4 != (tcp_seg *)0x0) { + return '\0'; + } + pcb->unsent_oversize = 0; + return (err_t)ptVar4; + } + } + lwip_stats.tcp.memerr = lwip_stats.tcp.memerr + 1; + if (p != (pbuf *)0x0) { + pbuf_free(p); + } + } + return -1; +} + + + +err_t tcp_enqueue_flags(tcp_pcb *pcb,u8_t flags) + +{ + err_t eVar1; + u16_t uVar2; + pbuf *p; + tcp_seg *ptVar3; + uint uVar4; + tcp_seg *ptVar5; + tcp_seg *ptVar6; + + uVar4 = ((uint)flags & 2) >> 1; + p = pbuf_alloc(PBUF_TRANSPORT,(u16_t)(uVar4 << 2),PBUF_RAM); + if ((p == (pbuf *)0x0) || + (ptVar3 = tcp_create_segment(pcb,p,flags,pcb->snd_lbb,(u8_t)uVar4), ptVar3 == (tcp_seg *)0x0)) + { + eVar1 = -1; + pcb->flags = pcb->flags | 0x80; + lwip_stats.tcp.memerr = lwip_stats.tcp.memerr + 1; + } + else { + ptVar5 = pcb->unsent; + if (pcb->unsent == (tcp_seg *)0x0) { + pcb->unsent = ptVar3; + } + else { + do { + ptVar6 = ptVar5; + ptVar5 = ptVar6->next; + } while (ptVar5 != (tcp_seg *)0x0); + ptVar6->next = ptVar3; + } + pcb->unsent_oversize = 0; + if ((flags & 3) != 0) { + pcb->snd_lbb = pcb->snd_lbb + 1; + } + if ((flags & 1) != 0) { + pcb->flags = pcb->flags | 0x20; + } + uVar2 = pbuf_clen(ptVar3->p); + pcb->snd_queuelen = uVar2 + pcb->snd_queuelen; + eVar1 = '\0'; + } + return eVar1; +} + + + +err_t tcp_send_fin(tcp_pcb *pcb) + +{ + ushort uVar1; + tcp_seg *ptVar2; + tcp_seg *ptVar3; + err_t eVar4; + u16_t uVar5; + tcp_hdr *ptVar6; + + ptVar2 = pcb->unsent; + if (pcb->unsent != (tcp_seg *)0x0) { + do { + ptVar3 = ptVar2; + ptVar2 = ptVar3->next; + } while (ptVar3->next != (tcp_seg *)0x0); + uVar5 = lwip_htons(ptVar3->tcphdr->_hdrlen_rsvd_flags); + if ((uVar5 & 7) == 0) { + uVar1 = ptVar3->tcphdr->_hdrlen_rsvd_flags; + uVar5 = lwip_htons(1); + ptVar6 = ptVar3->tcphdr; + uVar1 = uVar5 | uVar1; + *(char *)&ptVar6->_hdrlen_rsvd_flags = (char)uVar1; + *(undefined *)((int)&ptVar6->_hdrlen_rsvd_flags + 1) = (char)((uint)uVar1 >> 8); + pcb->flags = pcb->flags | 0x20; + return '\0'; + } + } + eVar4 = tcp_enqueue_flags(pcb,'\x01'); + return eVar4; +} + + + +err_t tcp_rexmit_rto_prepare(tcp_pcb *pcb) + +{ + u8_t uVar1; + ushort uVar2; + tcp_seg *ptVar3; + u16_t uVar4; + u32_t uVar5; + tcp_seg *ptVar6; + + ptVar3 = pcb->unacked; + if (pcb->unacked != (tcp_seg *)0x0) { + do { + uVar1 = ptVar3->p->ref; + if (ptVar3->next == (tcp_seg *)0x0) { + if (uVar1 != '\x01') { + return -6; + } + ptVar3->next = pcb->unsent; + ptVar6 = pcb->unacked; + pcb->unacked = (tcp_seg *)0x0; + pcb->unsent = ptVar6; + pcb->flags = pcb->flags | 0x800; + uVar5 = lwip_htonl(ptVar3->tcphdr->seqno); + uVar2 = ptVar3->len; + uVar4 = lwip_htons(ptVar3->tcphdr->_hdrlen_rsvd_flags); + pcb->rto_end = (uint)((uVar4 & 3) != 0) + uVar5 + uVar2; + pcb->rttest = 0; + return '\0'; + } + ptVar3 = ptVar3->next; + } while (uVar1 == '\x01'); + } + return -6; +} + + + +err_t tcp_rexmit(tcp_pcb *pcb) + +{ + tcp_seg *ptVar1; + u32_t uVar2; + u32_t uVar3; + err_t eVar4; + tcp_seg *ptVar5; + + ptVar1 = pcb->unacked; + eVar4 = -6; + if ((ptVar1 != (tcp_seg *)0x0) && (eVar4 = -6, ptVar1->p->ref == '\x01')) { + ptVar5 = (tcp_seg *)&pcb->unsent; + pcb->unacked = ptVar1->next; + while (ptVar5->next != (tcp_seg *)0x0) { + uVar2 = lwip_htonl(ptVar5->next->tcphdr->seqno); + uVar3 = lwip_htonl(ptVar1->tcphdr->seqno); + if (-1 < (int)(uVar2 - uVar3)) break; + ptVar5 = ptVar5->next; + } + ptVar1->next = ptVar5->next; + ptVar5->next = ptVar1; + if (ptVar1->next == (tcp_seg *)0x0) { + pcb->unsent_oversize = 0; + } + if (pcb->nrtx != -1) { + pcb->nrtx = pcb->nrtx + '\x01'; + } + pcb->rttest = 0; + eVar4 = '\0'; + } + return eVar4; +} + + + +void tcp_rexmit_fast(tcp_pcb *pcb) + +{ + err_t eVar1; + undefined3 extraout_var; + uint uVar2; + uint uVar3; + + if (pcb->unacked != (tcp_seg *)0x0) { + if (((pcb->flags & 4) == 0) && (eVar1 = tcp_rexmit(pcb), CONCAT31(extraout_var,eVar1) == 0)) { + uVar3 = (uint)pcb->snd_wnd; + if ((uint)pcb->cwnd < (uint)pcb->snd_wnd) { + uVar3 = (uint)pcb->cwnd; + } + pcb->ssthresh = (tcpwnd_size_t)((int)uVar3 >> 1); + uVar2 = (uint)pcb->mss << 1; + if ((uint)((int)uVar3 >> 1) < uVar2) { + pcb->ssthresh = (tcpwnd_size_t)uVar2; + } + pcb->rtime = 0; + pcb->cwnd = pcb->mss * 3 + pcb->ssthresh; + pcb->flags = pcb->flags | 4; + } + return; + } + return; +} + + + +void tcp_rst(tcp_pcb *pcb,u32_t seqno,u32_t ackno,ip_addr_t *param_4,ip_addr_t *remote_ip, + u16_t param_6,u16_t remote_port) + +{ + u32_t seqno_be; + pbuf *p; + + seqno_be = lwip_htonl(seqno); + p = tcp_output_alloc_header_common(ackno,0,seqno_be,param_6,remote_port,'\x14',0x1008); + if (p != (pbuf *)0x0) { + tcp_output_control_segment(pcb,p,param_4,remote_ip); + return; + } + return; +} + + + +err_t tcp_send_empty_ack(tcp_pcb *pcb) + +{ + err_t eVar1; + u32_t seqno_be; + pbuf *p; + undefined3 extraout_var; + tcpflags_t tVar2; + + seqno_be = lwip_htonl(pcb->snd_nxt); + p = tcp_output_alloc_header(pcb,0,seqno_be); + if (p == (pbuf *)0x0) { + eVar1 = -2; + pcb->flags = pcb->flags | 3; + } + else { + eVar1 = tcp_output_control_segment(pcb,p,(ip_addr_t *)pcb,&pcb->remote_ip); + if (CONCAT31(extraout_var,eVar1) == 0) { + tVar2 = pcb->flags & 0xfffc; + } + else { + tVar2 = pcb->flags | 3; + } + pcb->flags = tVar2; + } + return eVar1; +} + + + +err_t tcp_output(tcp_pcb *pcb) + +{ + ushort uVar1; + ushort uVar2; + bool bVar3; + short sVar4; + tcp_seg *ptVar5; + tcp_seg *seg; + err_t eVar6; + u16_t proto_len; + u16_t uVar7; + netif *outif; + u32_t uVar8; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + uint uVar9; + undefined3 extraout_var; + u32_t uVar10; + tcp_hdr *ptVar11; + pbuf *p; + tcp_seg *ptVar12; + tcp_seg *ptVar13; + uint uVar14; + ip4_addr_t *dest; + + if (tcp_input_pcb == pcb) { + return '\0'; + } + seg = pcb->unsent; + if (seg == (tcp_seg *)0x0) { + uVar1 = pcb->flags; + } + else { + uVar1 = pcb->cwnd; + uVar2 = pcb->snd_wnd; + dest = (ip4_addr_t *)&pcb->remote_ip; + if (pcb->netif_idx == '\0') { + outif = ip4_route(dest); + } + else { + outif = netif_get_by_index(pcb->netif_idx); + } + if (outif == (netif *)0x0) { + return -4; + } + if ((pcb->local_ip).addr == 0) { + (pcb->local_ip).addr = (outif->ip_addr).addr; + } + uVar14 = (uint)uVar1; + if ((uint)uVar2 < (uint)uVar1) { + uVar14 = (uint)uVar2; + } + uVar8 = lwip_htonl(seg->tcphdr->seqno); + if (uVar8 + ((uint)seg->len - pcb->lastack) <= uVar14) { + pcb->persist_backoff = '\0'; + ptVar12 = pcb->unacked; + ptVar13 = pcb->unacked; + while (ptVar5 = ptVar12, ptVar5 != (tcp_seg *)0x0) { + ptVar12 = ptVar5->next; + ptVar13 = ptVar5; + } + do { + uVar8 = lwip_htonl(seg->tcphdr->seqno); + if ((uVar14 < (uVar8 - pcb->lastack) + (uint)seg->len) || + (((((lwip_htons(seg->tcphdr->_hdrlen_rsvd_flags), pcb->unacked != (tcp_seg *)0x0 && + ((pcb->flags & 0x44) == 0)) && + ((ptVar12 = pcb->unsent, ptVar12 == (tcp_seg *)0x0 || + ((ptVar12->next == (tcp_seg *)0x0 && (ptVar12->len < pcb->mss)))))) && + (pcb->snd_buf != 0)) && ((pcb->snd_queuelen < 0x10 && ((pcb->flags & 0xa0) == 0)))))) { + if (pcb->unsent != (tcp_seg *)0x0) goto output_done; + break; + } + if (pcb->state != SYN_SENT) { + uVar1 = seg->tcphdr->_hdrlen_rsvd_flags; + proto_len = lwip_htons(0x10); + ptVar11 = seg->tcphdr; + uVar1 = proto_len | uVar1; + *(char *)&ptVar11->_hdrlen_rsvd_flags = (char)uVar1; + *(undefined *)((int)&ptVar11->_hdrlen_rsvd_flags + 1) = (char)((uint)uVar1 >> 8); + } + if (seg->p->ref == '\x01') { + ptVar11 = seg->tcphdr; + uVar8 = lwip_htonl(pcb->rcv_nxt); + *(char *)&ptVar11->ackno = (char)uVar8; + *(undefined *)((int)&ptVar11->ackno + 1) = (char)(uVar8 >> 8); + *(undefined *)((int)&ptVar11->ackno + 2) = (char)(uVar8 >> 0x10); + *(undefined *)((int)&ptVar11->ackno + 3) = (char)(uVar8 >> 0x18); + ptVar11 = seg->tcphdr; + proto_len = lwip_htons(pcb->rcv_ann_wnd); + *(char *)&ptVar11->wnd = (char)proto_len; + *(undefined *)((int)&ptVar11->wnd + 1) = (char)(proto_len >> 8); + pcb->rcv_ann_right_edge = pcb->rcv_nxt + (uint)pcb->rcv_ann_wnd; + if ((seg->flags & 1) != 0) { + ptVar11 = seg->tcphdr; + proto_len = tcp_eff_send_mss_netif(0x2b0,outif,(ip_addr_t *)dest); + uVar8 = lwip_htonl(CONCAT22(extraout_var_00,proto_len) | 0x2040000); + *(u32_t *)(ptVar11 + 1) = uVar8; + } + if (pcb->rtime < 0) { + pcb->rtime = 0; + } + if (pcb->rttest == 0) { + pcb->rttest = tcp_ticks; + uVar8 = lwip_htonl(seg->tcphdr->seqno); + pcb->rtseq = uVar8; + } + p = seg->p; + sVar4 = (short)((uint)((int)((int)seg->tcphdr - (int)p->payload) * 0x10000) >> 0x10); + p->len = p->len - sVar4; + seg->p->tot_len = seg->p->tot_len - sVar4; + ptVar11 = seg->tcphdr; + *(tcp_hdr **)&seg->p->payload = ptVar11; + *(undefined *)&ptVar11->chksum = 0; + *(undefined *)((int)&ptVar11->chksum + 1) = 0; + if ((seg->flags & 4) == 0) { + lwip_htons(seg->tcphdr->_hdrlen_rsvd_flags); + } + p = seg->p; + proto_len = p->tot_len; + uVar7 = lwip_htons(seg->tcphdr->_hdrlen_rsvd_flags); + proto_len = ip_chksum_pseudo_partial + (p,'\x06',proto_len, + (ushort)(CONCAT22(extraout_var_01,uVar7) >> 10) & 0xfc, + (ip4_addr_t *)pcb,dest); + bVar3 = seg->chksum_swapped != '\0'; + if (bVar3) { + seg->chksum_swapped = '\0'; + seg->chksum = seg->chksum >> 8 | seg->chksum << 8; + } + ptVar11 = seg->tcphdr; + uVar9 = (uint)seg->chksum + (~(uint)proto_len & 0xffff); + uVar9 = ~((uVar9 >> 0x10) + uVar9); + *(char *)&ptVar11->chksum = (char)uVar9; + *(undefined *)((int)&ptVar11->chksum + 1) = (char)(uVar9 >> 8); + lwip_stats.tcp.xmit = lwip_stats.tcp.xmit + 1; + eVar6 = ip4_output_if(seg->p,(ip4_addr_t *)pcb,dest,pcb->ttl,pcb->tos,'\x06',outif); + if (bVar3) { + seg->chksum_swapped = '\x01'; + seg->chksum = seg->chksum >> 8 | seg->chksum << 8; + } + if (CONCAT31(extraout_var,eVar6) != 0) { + pcb->flags = pcb->flags | 0x80; + return eVar6; + } + } + pcb->unsent = seg->next; + if (pcb->state != SYN_SENT) { + pcb->flags = pcb->flags & 0xfffc; + } + uVar8 = lwip_htonl(seg->tcphdr->seqno); + uVar1 = seg->len; + proto_len = lwip_htons(seg->tcphdr->_hdrlen_rsvd_flags); + uVar8 = (uint)((proto_len & 3) != 0) + uVar8 + uVar1; + if ((int)(pcb->snd_nxt - uVar8) < 0) { + pcb->snd_nxt = uVar8; + } + uVar1 = seg->len; + proto_len = lwip_htons(seg->tcphdr->_hdrlen_rsvd_flags); + if ((uint)((proto_len & 3) != 0) + (uint)uVar1 == 0) { + tcp_seg_free(seg); + } + else { + seg->next = (tcp_seg *)0x0; + if (pcb->unacked == (tcp_seg *)0x0) { + pcb->unacked = seg; + ptVar13 = seg; + } + else { + uVar8 = lwip_htonl(seg->tcphdr->seqno); + uVar10 = lwip_htonl(ptVar13->tcphdr->seqno); + ptVar12 = (tcp_seg *)&pcb->unacked; + if ((int)(uVar8 - uVar10) < 0) { + while (ptVar12->next != (tcp_seg *)0x0) { + uVar8 = lwip_htonl(ptVar12->next->tcphdr->seqno); + uVar10 = lwip_htonl(seg->tcphdr->seqno); + if (-1 < (int)(uVar8 - uVar10)) break; + ptVar12 = ptVar12->next; + } + seg->next = ptVar12->next; + ptVar12->next = seg; + } + else { + ptVar13->next = seg; + ptVar13 = seg; + } + } + } + seg = pcb->unsent; + } while (seg != (tcp_seg *)0x0); + pcb->unsent_oversize = 0; + goto output_done; + } + if ((((uint)pcb->snd_wnd == uVar14) && (pcb->unacked == (tcp_seg *)0x0)) && + (pcb->persist_backoff == '\0')) { + *(undefined2 *)&pcb->persist_cnt = 0x100; + pcb->persist_probe = '\0'; + } + uVar1 = pcb->flags; + } + if ((uVar1 & 2) != 0) { + eVar6 = tcp_send_empty_ack(pcb); + return eVar6; + } +output_done: + pcb->flags = pcb->flags & 0xff7f; + return '\0'; +} + + + +void tcp_rexmit_rto_commit(tcp_pcb *pcb) + +{ + if (pcb->nrtx != -1) { + pcb->nrtx = pcb->nrtx + '\x01'; + } + tcp_output(pcb); + return; +} + + + +void tcp_rexmit_rto(tcp_pcb *pcb) + +{ + err_t eVar1; + undefined3 extraout_var; + + eVar1 = tcp_rexmit_rto_prepare(pcb); + if (CONCAT31(extraout_var,eVar1) == 0) { + tcp_rexmit_rto_commit(pcb); + return; + } + return; +} + + + +err_t tcp_keepalive(tcp_pcb *pcb) + +{ + err_t eVar1; + u32_t seqno_be; + pbuf *p; + + seqno_be = lwip_htonl(pcb->snd_nxt - 1); + p = tcp_output_alloc_header(pcb,0,seqno_be); + if (p != (pbuf *)0x0) { + eVar1 = tcp_output_control_segment(pcb,p,(ip_addr_t *)pcb,&pcb->remote_ip); + return eVar1; + } + return -1; +} + + + +err_t tcp_zero_window_probe(tcp_pcb *pcb) + +{ + ushort uVar1; + uint uVar2; + err_t eVar3; + u16_t uVar4; + pbuf *p; + u32_t uVar5; + tcp_seg *ptVar6; + void *pvVar7; + + ptVar6 = pcb->unsent; + if (ptVar6 == (tcp_seg *)0x0) { + eVar3 = '\0'; + } + else { + if (pcb->persist_probe != -1) { + pcb->persist_probe = pcb->persist_probe + '\x01'; + } + uVar2 = 0; + uVar4 = lwip_htons(ptVar6->tcphdr->_hdrlen_rsvd_flags); + if ((uVar4 & 1) != 0) { + uVar2 = (uint)(ptVar6->len == 0); + } + p = tcp_output_alloc_header(pcb,(ushort)uVar2 ^ 1,ptVar6->tcphdr->seqno); + if (p != (pbuf *)0x0) { + pvVar7 = p->payload; + if (uVar2 == 0) { + pbuf_copy_partial(ptVar6->p,(void *)((int)pvVar7 + 0x14),1, + (u16_t)(((uint)ptVar6->p->tot_len - (uint)ptVar6->len) * 0x10000 >> 0x10)) + ; + } + else { + uVar1 = *(ushort *)((int)pvVar7 + 0xc); + uVar4 = lwip_htons(0x11); + uVar2 = (int)(short)(uVar1 & 0xc0ff) | (uint)uVar4; + *(undefined *)((int)pvVar7 + 0xc) = (char)uVar2; + *(undefined *)((int)pvVar7 + 0xd) = (char)(uVar2 >> 8); + } + uVar5 = lwip_htonl(ptVar6->tcphdr->seqno); + if ((int)(pcb->snd_nxt - (uVar5 + 1)) < 0) { + pcb->snd_nxt = uVar5 + 1; + } + eVar3 = tcp_output_control_segment(pcb,p,(ip_addr_t *)pcb,&pcb->remote_ip); + return eVar3; + } + eVar3 = -1; + } + return eVar3; +} + + + +void sys_timeout_abs(u32_t abs_time,sys_timeout_handler *handler,void *arg) + +{ + sys_timeo *psVar1; + sys_timeo *psVar2; + sys_timeo *psVar3; + + psVar1 = (sys_timeo *)memp_malloc(MEMP_SYS_TIMEOUT); + psVar2 = next_timeout; + psVar3 = next_timeout; + if (psVar1 != (sys_timeo *)0x0) { + psVar1->next = (sys_timeo *)0x0; + psVar1->h = handler; + psVar1->arg = arg; + psVar1->time = abs_time; + psVar3 = psVar1; + if (psVar2 != (sys_timeo *)0x0) { + if ((int)(abs_time - psVar2->time) < 0) { + psVar1->next = psVar2; + } + else { + do { + psVar3 = psVar2; + psVar2 = psVar3->next; + if (psVar2 == (sys_timeo *)0x0) break; + } while (-1 < (int)(abs_time - psVar2->time)); + psVar1->next = psVar2; + psVar3->next = psVar1; + psVar3 = next_timeout; + } + } + } + next_timeout = psVar3; + return; +} + + + +void lwip_cyclic_timer(void *arg) + +{ + TickType_t TVar1; + u32_t abs_time; + u32_t uVar2; + + (**(code **)((int)arg + 4))(*(code **)((int)arg + 4)); + TVar1 = sys_now(); + uVar2 = current_timeout_due_time + *(int *)arg; + abs_time = TVar1 + *(int *)arg; + if (-1 < (int)(uVar2 - TVar1)) { + abs_time = uVar2; + } + sys_timeout_abs(abs_time,lwip_cyclic_timer,arg); + return; +} + + + +void sys_timeout(u32_t msecs,sys_timeout_handler *handler,void *arg) + +{ + TickType_t TVar1; + + TVar1 = sys_now(); + sys_timeout_abs(TVar1 + msecs,handler,arg); + return; +} + + + +void tcp_timer_needed(void) + +{ + if ((tcpip_tcp_timer_active == 0) && + ((tcp_active_pcbs != (tcp_pcb *)0x0 || (tcp_tw_pcbs != (tcp_pcb *)0x0)))) { + tcpip_tcp_timer_active = 1; + sys_timeout(0xfa,tcpip_tcp_timer,(void *)0x0); + return; + } + return; +} + + + +void tcpip_tcp_timer(void *arg) + +{ + tcp_tmr(); + if ((tcp_active_pcbs == (tcp_pcb *)0x0) && (tcp_tw_pcbs == (tcp_pcb *)0x0)) { + tcpip_tcp_timer_active = 0; + return; + } + sys_timeout(0xfa,tcpip_tcp_timer,(void *)0x0); + return; +} + + + +void sys_timeouts_init(void) + +{ + u32_t *arg; + u32_t *puVar1; + + arg = &DAT_23086494; + do { + puVar1 = arg + 2; + sys_timeout(*arg,lwip_cyclic_timer,arg); + arg = puVar1; + } while (puVar1 != (u32_t *)CSWTCH_13); + return; +} + + + +void sys_untimeout(sys_timeout_handler *handler,void *arg) + +{ + sys_timeo *psVar1; + sys_timeo *psVar2; + sys_timeo *mem; + + psVar1 = (sys_timeo *)0x0; + mem = next_timeout; + if (next_timeout != (sys_timeo *)0x0) { + do { + psVar2 = mem->next; + if ((mem->h == handler) && (mem->arg == arg)) { + if (psVar1 != (sys_timeo *)0x0) { + psVar1->next = psVar2; + psVar2 = next_timeout; + } + next_timeout = psVar2; + memp_free(MEMP_SYS_TIMEOUT,mem); + return; + } + psVar1 = mem; + mem = psVar2; + } while (psVar2 != (sys_timeo *)0x0); + } + return; +} + + + +void sys_check_timeouts(void) + +{ + sys_timeo *mem; + sys_timeout_handler *psVar1; + void *pvVar2; + TickType_t TVar3; + + TVar3 = sys_now(); + while ((mem = next_timeout, next_timeout != (sys_timeo *)0x0 && + (-1 < (int)(TVar3 - next_timeout->time)))) { + psVar1 = next_timeout->h; + pvVar2 = next_timeout->arg; + current_timeout_due_time = next_timeout->time; + next_timeout = next_timeout->next; + memp_free(MEMP_SYS_TIMEOUT,mem); + if (psVar1 != (sys_timeout_handler *)0x0) { + (*psVar1)(pvVar2); + } + } + return; +} + + + +u32_t sys_timeouts_sleeptime(void) + +{ + u32_t uVar1; + TickType_t TVar2; + + uVar1 = 0xffffffff; + if (next_timeout != (sys_timeo *)0x0) { + TVar2 = sys_now(); + uVar1 = next_timeout->time - TVar2; + if ((int)uVar1 < 0) { + uVar1 = 0; + } + } + return uVar1; +} + + + +void udp_init(void) + +{ + int iVar1; + + iVar1 = bl_rand(); + udp_port = (ushort)((uint)(iVar1 << 0x12) >> 0x12) + 0xc000; + return; +} + + + +void udp_input(pbuf *p,netif *inp) + +{ + udp_pcb *puVar1; + udp_pcb *puVar2; + u8_t uVar3; + u16_t uVar4; + u16_t uVar5; + undefined3 extraout_var; + undefined2 extraout_var_01; + undefined2 extraout_var_02; + undefined2 extraout_var_03; + undefined3 extraout_var_00; + u32_t uVar6; + uint uVar7; + udp_pcb *puVar8; + udp_pcb *puVar9; + udp_pcb *puVar10; + u16_t *puVar11; + + lwip_stats.udp.recv = lwip_stats.udp.recv + 1; + if (p->len < 8) { + lwip_stats.udp.lenerr = lwip_stats.udp.lenerr + 1; + lwip_stats.udp.drop = lwip_stats.udp.drop + 1; + } + else { + puVar11 = (u16_t *)p->payload; + uVar3 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_dest,ip_data.current_netif); + _uVar3 = CONCAT31(extraout_var,uVar3); + uVar4 = lwip_htons(*puVar11); + uVar5 = lwip_htons(puVar11[1]); + puVar1 = udp_pcbs; + puVar9 = (udp_pcb *)0x0; + puVar2 = udp_pcbs; + puVar8 = (udp_pcb *)0x0; + while (puVar10 = puVar2, puVar10 != (udp_pcb *)0x0) { + if (((uint)puVar10->local_port == CONCAT22(extraout_var_02,uVar5)) && + ((puVar10->netif_idx == '\0' || + (puVar10->netif_idx == (u8_t)((ip_data.current_input_netif)->num + '\x01'))))) { + uVar7 = (puVar10->local_ip).addr; + if (_uVar3 == 0) { + if ((uVar7 == 0) || (uVar7 == ip_data.current_iphdr_dest)) goto LAB_230454fc; + } + else { + if ((uVar7 == 0) || + ((ip_data.current_iphdr_dest == 0xffffffff || + (((uVar7 ^ ip_data.current_iphdr_dest) & (inp->netmask).addr) == 0)))) { +LAB_230454fc: + if ((puVar10->flags & 4) != 0) goto LAB_23045532; + if (puVar9 == (udp_pcb *)0x0) { +LAB_23045520: + puVar9 = puVar10; + } + else { + if ((_uVar3 == 0) || (ip_data.current_iphdr_dest != 0xffffffff)) { + if (uVar7 != 0) goto LAB_23045520; + } + else { + uVar6 = (inp->ip_addr).addr; + if (((puVar9->local_ip).addr != uVar6) && (uVar6 == uVar7)) goto LAB_23045520; + } + } +LAB_23045532: + if (((uint)puVar10->remote_port == CONCAT22(extraout_var_01,uVar4)) && + ((uVar6 = (puVar10->remote_ip).addr, uVar6 == 0 || + (uVar6 == ip_data.current_iphdr_src)))) { + if (puVar8 == (udp_pcb *)0x0) { + lwip_stats.udp.cachehit = lwip_stats.udp.cachehit + 1; + } + else { + udp_pcbs = puVar10; + puVar8->next = puVar10->next; + puVar10->next = puVar1; + } + goto LAB_23045556; + } + } + } + } + puVar2 = puVar10->next; + puVar8 = puVar10; + } + puVar10 = puVar9; + if ((puVar9 != (udp_pcb *)0x0) || ((inp->ip_addr).addr == ip_data.current_iphdr_dest)) { +LAB_23045556: + if ((puVar11[3] == 0) || + (uVar5 = ip_chksum_pseudo(p,'\x11',p->tot_len,(ip4_addr_t *)&ip_data.current_iphdr_src, + (ip4_addr_t *)&ip_data.current_iphdr_dest), + CONCAT22(extraout_var_03,uVar5) == 0)) { + uVar3 = pbuf_remove_header(p,8); + if (CONCAT31(extraout_var_00,uVar3) == 0) { + if (puVar10 != (udp_pcb *)0x0) { + if (puVar10->recv != (udp_recv_fn *)0x0) { + // WARNING: Could not recover jumptable at 0x230455e0. Too many branches + // WARNING: Treating indirect jump as call + (*puVar10->recv)(puVar10->recv_arg,puVar10,p,(ip_addr_t *)0x4201fed0,uVar4); + return; + } + goto LAB_23045438; + } + if ((_uVar3 == 0) && ((ip_data.current_iphdr_dest & 0xf0) != 0xe0)) { + pbuf_header_force(p,(s16_t)(((uint)ip_data.current_ip_header_tot_len + 8) * 0x10000 >> + 0x10)); + icmp_dest_unreach(p,ICMP_DUR_PORT); + } + lwip_stats.udp.proterr = lwip_stats.udp.proterr + 1; + } + } + else { + lwip_stats.udp.chkerr = lwip_stats.udp.chkerr + 1; + } + lwip_stats.udp.drop = lwip_stats.udp.drop + 1; + } + } +LAB_23045438: + pbuf_free(p); + return; +} + + + +err_t udp_bind(udp_pcb *pcb,ip_addr_t *ipaddr,u16_t port) + +{ + bool bVar1; + err_t eVar2; + undefined2 in_register_00002032; + u32_t uVar3; + udp_pcb *puVar4; + short sVar5; + + if (ipaddr == (ip_addr_t *)0x0) { + ipaddr = &ip_addr_any; + } + eVar2 = -0x10; + puVar4 = udp_pcbs; + if (pcb != (udp_pcb *)0x0) { + while (puVar4 != (udp_pcb *)0x0) { + if (puVar4 == pcb) { + bVar1 = true; + goto LAB_23045638; + } + puVar4 = puVar4->next; + } + bVar1 = false; +LAB_23045638: + puVar4 = udp_pcbs; + if (CONCAT22(in_register_00002032,port) == 0) { + sVar5 = 0x4000; + do { + puVar4 = udp_pcbs; + if (udp_port == 0xffff) { + port = 0xc000; + } + else { + port = udp_port + 1; + } + while( true ) { + udp_port = port; + if (puVar4 == (udp_pcb *)0x0) goto LAB_23045660; + if (puVar4->local_port == port) break; + puVar4 = puVar4->next; + } + sVar5 = sVar5 + -1; + if (sVar5 == 0) { + return -8; + } + } while( true ); + } + while (puVar4 != (udp_pcb *)0x0) { + if ((puVar4 != pcb) && + ((((pcb->so_options & 4) == 0 || ((puVar4->so_options & 4) == 0)) && + ((uint)puVar4->local_port == CONCAT22(in_register_00002032,port))))) { + uVar3 = (puVar4->local_ip).addr; + if (uVar3 == ipaddr->addr) { + return -8; + } + if (ipaddr->addr == 0) { + return -8; + } + if (uVar3 == 0) { + return -8; + } + } + puVar4 = puVar4->next; + } +LAB_23045660: + uVar3 = ipaddr->addr; + pcb->local_port = port; + (pcb->local_ip).addr = uVar3; + if (!bVar1) { + puVar4 = pcb; + pcb->next = udp_pcbs; + udp_pcbs = puVar4; + } + eVar2 = '\0'; + } + return eVar2; +} + + + +err_t udp_sendto_if_src_chksum + (udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif,u8_t have_chksum + ,u16_t chksum,ip_addr_t *src_ip) + +{ + u8_t ttl; + err_t eVar1; + u16_t uVar2; + undefined2 uVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + pbuf *h; + undefined2 extraout_var_01; + uint uVar4; + undefined2 extraout_var_02; + undefined3 in_register_0000203d; + undefined *puVar5; + + if (pcb == (udp_pcb *)0x0) { + return -0x10; + } + if (p == (pbuf *)0x0) { + return -0x10; + } + if (dst_ip == (ip_addr_t *)0x0) { + return -0x10; + } + if (src_ip == (ip_addr_t *)0x0) { + return -0x10; + } + if (netif == (netif *)0x0) { + return -0x10; + } + if ((pcb->local_port == 0) && + (eVar1 = udp_bind(pcb,(ip_addr_t *)pcb,0), CONCAT31(extraout_var,eVar1) != 0)) { + return eVar1; + } + if (p->tot_len < 0xfff8) { + ttl = pbuf_add_header(p,8); + h = p; + if (CONCAT31(extraout_var_00,ttl) != 0) { + h = pbuf_alloc(PBUF_IP,8,PBUF_RAM); + if (h == (pbuf *)0x0) goto LAB_23045726; + if (p->tot_len != 0) { + pbuf_chain(h,p); + } + } + puVar5 = (undefined *)h->payload; + uVar2 = lwip_htons(pcb->local_port); + *puVar5 = (char)uVar2; + puVar5[1] = (char)(uVar2 >> 8); + uVar2 = lwip_htons(dst_port); + puVar5[2] = (char)uVar2; + puVar5[3] = (char)(uVar2 >> 8); + puVar5[6] = 0; + puVar5[7] = 0; + if (((pcb->flags & 8) != 0) && ((dst_ip->addr & 0xf0) == 0xe0)) { + h->flags = h->flags | 4; + } + uVar2 = lwip_htons(h->tot_len); + puVar5[4] = (char)uVar2; + puVar5[5] = (char)(uVar2 >> 8); + if ((pcb->flags & 1) == 0) { + if (CONCAT31(in_register_0000203d,have_chksum) == 0) { + uVar2 = ip_chksum_pseudo(h,'\x11',h->tot_len,(ip4_addr_t *)src_ip,(ip4_addr_t *)dst_ip); + uVar4 = CONCAT22(extraout_var_02,uVar2); + } + else { + uVar2 = ip_chksum_pseudo_partial + (h,'\x11',h->tot_len,8,(ip4_addr_t *)src_ip,(ip4_addr_t *)dst_ip); + uVar4 = CONCAT22(extraout_var_01,uVar2) + (~(uint)chksum & 0xffff); + uVar4 = uVar4 + (uVar4 >> 0x10) & 0xffff; + } + uVar3 = (undefined2)uVar4; + if (uVar4 == 0) { + uVar3 = 0xffff; + } + puVar5[6] = (char)uVar3; + puVar5[7] = (char)((ushort)uVar3 >> 8); + } + if ((dst_ip->addr & 0xf0) == 0xe0) { + ttl = pcb->mcast_ttl; + } + else { + ttl = pcb->ttl; + } + eVar1 = ip4_output_if_src(h,(ip4_addr_t *)src_ip,(ip4_addr_t *)dst_ip,ttl,pcb->tos,'\x11',netif) + ; + if (h != p) { + pbuf_free(h); + } + lwip_stats.udp.xmit = lwip_stats.udp.xmit + 1; + } + else { +LAB_23045726: + eVar1 = -1; + } + return eVar1; +} + + + +err_t udp_sendto_if_chksum + (udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif,u8_t have_chksum + ,u16_t chksum) + +{ + err_t eVar1; + uint uVar2; + udp_pcb *src_ip; + + if ((((pcb != (udp_pcb *)0x0) && (p != (pbuf *)0x0)) && (dst_ip != (ip_addr_t *)0x0)) && + (netif != (netif *)0x0)) { + uVar2 = (pcb->local_ip).addr; + if ((uVar2 == 0) || ((uVar2 & 0xf0) == 0xe0)) { + src_ip = (udp_pcb *)&netif->ip_addr; + } + else { + src_ip = pcb; + if (uVar2 != (netif->ip_addr).addr) { + return -4; + } + } + eVar1 = udp_sendto_if_src_chksum + (pcb,p,dst_ip,dst_port,netif,have_chksum,chksum,(ip_addr_t *)src_ip); + return eVar1; + } + return -0x10; +} + + + +err_t udp_sendto_chksum(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,u8_t have_chksum, + u16_t chksum) + +{ + err_t eVar1; + netif *netif; + u32_t uVar2; + + if (((pcb == (udp_pcb *)0x0) || (p == (pbuf *)0x0)) || (dst_ip == (ip_addr_t *)0x0)) { + return -0x10; + } + if (pcb->netif_idx == '\0') { + if ((dst_ip->addr & 0xf0) == 0xe0) { + if (pcb->mcast_ifindex == '\0') { + uVar2 = (pcb->mcast_ip4).addr; + if ((uVar2 == 0) || (uVar2 == 0xffffffff)) goto LAB_2304591a; + netif = ip4_route(&pcb->mcast_ip4); + } + else { + netif = netif_get_by_index(pcb->mcast_ifindex); + } + if (netif != (netif *)0x0) goto LAB_2304592e; + } +LAB_2304591a: + netif = ip4_route((ip4_addr_t *)dst_ip); + } + else { + netif = netif_get_by_index(pcb->netif_idx); + } + if (netif == (netif *)0x0) { + lwip_stats.udp.rterr = lwip_stats.udp.rterr + 1; + return -4; + } +LAB_2304592e: + eVar1 = udp_sendto_if_chksum(pcb,p,dst_ip,dst_port,netif,have_chksum,chksum); + return eVar1; +} + + + +err_t udp_send_chksum(udp_pcb *pcb,pbuf *p,u8_t have_chksum,u16_t chksum) + +{ + err_t eVar1; + + if ((pcb != (udp_pcb *)0x0) && (p != (pbuf *)0x0)) { + eVar1 = udp_sendto_chksum(pcb,p,&pcb->remote_ip,pcb->remote_port,have_chksum,chksum); + return eVar1; + } + return -0x10; +} + + + +err_t udp_sendto(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port) + +{ + err_t eVar1; + + eVar1 = udp_sendto_chksum(pcb,p,dst_ip,dst_port,'\0',0); + return eVar1; +} + + + +err_t udp_sendto_if(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif) + +{ + err_t eVar1; + + eVar1 = udp_sendto_if_chksum(pcb,p,dst_ip,dst_port,netif,'\0',0); + return eVar1; +} + + + +err_t udp_sendto_if_src(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif, + ip_addr_t *src_ip) + +{ + err_t eVar1; + + eVar1 = udp_sendto_if_src_chksum(pcb,p,dst_ip,dst_port,netif,'\0',0,src_ip); + return eVar1; +} + + + +void udp_bind_netif(udp_pcb *pcb,netif *netif) + +{ + u8_t uVar1; + + uVar1 = '\0'; + if (netif != (netif *)0x0) { + uVar1 = netif->num + '\x01'; + } + pcb->netif_idx = uVar1; + return; +} + + + +err_t udp_connect(udp_pcb *pcb,ip_addr_t *ipaddr,u16_t port) + +{ + err_t eVar1; + undefined3 extraout_var; + udp_pcb *puVar2; + u32_t uVar3; + + if ((pcb == (udp_pcb *)0x0) || (ipaddr == (ip_addr_t *)0x0)) { + return -0x10; + } + if ((pcb->local_port != 0) || + (eVar1 = udp_bind(pcb,(ip_addr_t *)pcb,0), CONCAT31(extraout_var,eVar1) == 0)) { + uVar3 = ipaddr->addr; + pcb->remote_port = port; + (pcb->remote_ip).addr = uVar3; + pcb->flags = pcb->flags | 4; + puVar2 = udp_pcbs; + while (puVar2 != (udp_pcb *)0x0) { + if (puVar2 == pcb) goto LAB_230459f6; + puVar2 = puVar2->next; + } + pcb->next = udp_pcbs; + udp_pcbs = pcb; +LAB_230459f6: + eVar1 = '\0'; + } + return eVar1; +} + + + +void udp_disconnect(udp_pcb *pcb) + +{ + byte bVar1; + + if (pcb != (udp_pcb *)0x0) { + bVar1 = pcb->flags; + (pcb->remote_ip).addr = 0; + pcb->remote_port = 0; + pcb->netif_idx = '\0'; + pcb->flags = bVar1 & 0xfb; + } + return; +} + + + +void udp_recv(udp_pcb *pcb,udp_recv_fn *recv,void *recv_arg) + +{ + if (pcb != (udp_pcb *)0x0) { + pcb->recv = recv; + pcb->recv_arg = recv_arg; + } + return; +} + + + +void udp_remove(udp_pcb *pcb) + +{ + udp_pcb *puVar1; + udp_pcb *puVar2; + + if (pcb == (udp_pcb *)0x0) { + return; + } + puVar1 = udp_pcbs; + if (udp_pcbs == pcb) { + udp_pcbs = pcb->next; + } + else { + do { + puVar2 = puVar1; + if ((puVar2 == (udp_pcb *)0x0) || (puVar1 = puVar2->next, puVar1 == (udp_pcb *)0x0)) + goto LAB_23045a58; + } while (puVar1 != pcb); + puVar2->next = pcb->next; + } +LAB_23045a58: + memp_free(MEMP_UDP_PCB,pcb); + return; +} + + + +udp_pcb * udp_new(void) + +{ + udp_pcb *__s; + + __s = (udp_pcb *)memp_malloc(MEMP_UDP_PCB); + if (__s != (udp_pcb *)0x0) { + memset(__s,0,0x28); + __s->ttl = -1; + __s->mcast_ttl = -1; + } + return __s; +} + + + +udp_pcb * udp_new_ip_type(void) + +{ + udp_pcb *__s; + + __s = (udp_pcb *)memp_malloc(MEMP_UDP_PCB); + if (__s != (udp_pcb *)0x0) { + memset(__s,0,0x28); + __s->ttl = -1; + __s->mcast_ttl = -1; + } + return __s; +} + + + +void udp_netif_ip_addr_changed(ip_addr_t *old_addr,ip_addr_t *new_addr) + +{ + udp_pcb *puVar1; + + if ((((old_addr != (ip_addr_t *)0x0) && (old_addr->addr != 0)) && (new_addr != (ip_addr_t *)0x0)) + && (puVar1 = udp_pcbs, new_addr->addr != 0)) { + while (puVar1 != (udp_pcb *)0x0) { + if ((puVar1->local_ip).addr == old_addr->addr) { + (puVar1->local_ip).addr = new_addr->addr; + } + puVar1 = puVar1->next; + } + } + return; +} + + + +udp_pcb * udp_get_pcbs(void) + +{ + return udp_pcbs; +} + + + +err_t ethernet_input(pbuf *p,netif *netif) + +{ + short sVar1; + u8_t uVar2; + byte *__s1; + undefined3 extraout_var; + int iVar3; + undefined3 extraout_var_00; + byte bVar4; + + if (p->len < 0xf) { +LAB_23045aec: + lwip_stats.etharp.proterr = lwip_stats.etharp.proterr + 1; + } + else { + if (p->if_idx == '\0') { + p->if_idx = netif->num + '\x01'; + } + __s1 = (byte *)p->payload; + sVar1 = *(short *)(__s1 + 0xc); + if ((*__s1 & 1) != 0) { + if (*__s1 == 1) { + if ((__s1[1] == 0) && (__s1[2] == 0x5e)) { + bVar4 = p->flags | 0x10; +LAB_23045b4a: + p->flags = bVar4; + } + } + else { + iVar3 = memcmp(__s1,ðbroadcast,6); + if (iVar3 == 0) { + bVar4 = p->flags | 8; + goto LAB_23045b4a; + } + } + } + if (sVar1 == 8) { + if (((netif->flags & 8) != 0) && + (uVar2 = pbuf_remove_header(p,0xe), CONCAT31(extraout_var_00,uVar2) == 0)) { + ip4_input(p,netif); + return '\0'; + } + goto free_and_return; + } + if (sVar1 != 0x608) goto LAB_23045aec; + if ((netif->flags & 8) == 0) goto free_and_return; + uVar2 = pbuf_remove_header(p,0xe); + if (CONCAT31(extraout_var,uVar2) == 0) { + etharp_input(p,netif); + return '\0'; + } + lwip_stats.etharp.lenerr = lwip_stats.etharp.lenerr + 1; + } + lwip_stats.etharp.drop = lwip_stats.etharp.drop + 1; +free_and_return: + pbuf_free(p); + return '\0'; +} + + + +err_t ethernet_output(netif *netif,pbuf *p,eth_addr *src,eth_addr *dst,u16_t eth_type) + +{ + void *__dest; + u8_t uVar1; + err_t eVar2; + u16_t uVar3; + undefined3 extraout_var; + + uVar3 = lwip_htons(eth_type); + uVar1 = pbuf_add_header(p,0xe); + if (CONCAT31(extraout_var,uVar1) == 0) { + __dest = p->payload; + *(undefined *)((int)__dest + 0xc) = (char)uVar3; + *(undefined *)((int)__dest + 0xd) = (char)(uVar3 >> 8); + memcpy(__dest,dst,6); + memcpy((void *)((int)__dest + 6),src,6); + // WARNING: Could not recover jumptable at 0x23045c42. Too many branches + // WARNING: Treating indirect jump as call + eVar2 = (*netif->linkoutput)(netif,p); + return eVar2; + } + lwip_stats.link.lenerr = lwip_stats.link.lenerr + 1; + return -2; +} + + + +err_t netconn_apimsg(tcpip_callback_fn_conflict *fn,api_msg *apimsg) + +{ + err_t eVar1; + undefined3 extraout_var; + + eVar1 = tcpip_send_msg_wait_sem((tcpip_callback_fn)fn,apimsg,&apimsg->conn->op_completed); + if (CONCAT31(extraout_var,eVar1) == 0) { + eVar1 = apimsg->err; + } + return eVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_close_shutdown(netconn *conn,u8_t how) + +{ + err_t eVar1; + netconn *pnStack52; + api_msg msg; + + if (conn != (netconn *)0x0) { + pnStack52 = conn; + msg.err = how; + msg.msg._0_4_ = sys_now(); + eVar1 = netconn_apimsg(lwip_netconn_do_close,(api_msg *)&pnStack52); + return eVar1; + } + return -0x10; +} + + + +// WARNING: Variable defined which should be unmapped: msg + +netconn * netconn_new_with_proto_and_callback(netconn_type t,u8_t proto,netconn_callback *callback) + +{ + err_t eVar1; + netconn *mem; + undefined3 extraout_var; + netconn *pnStack52; + api_msg msg; + + mem = netconn_alloc(t,callback); + if (mem != (netconn *)0x0) { + pnStack52 = mem; + msg.err = proto; + eVar1 = netconn_apimsg(lwip_netconn_do_newconn,(api_msg *)&pnStack52); + if (CONCAT31(extraout_var,eVar1) != 0) { + sys_mbox_valid(&mem->recvmbox); + sys_mbox_valid(&mem->acceptmbox); + sys_sem_valid(&mem->op_completed); + sys_sem_free(&mem->op_completed); + sys_mbox_free(&mem->recvmbox); + memp_free(MEMP_NETCONN,mem); + mem = (netconn *)0x0; + } + } + return mem; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_prepare_delete(netconn *conn) + +{ + err_t eVar1; + netconn *pnStack52; + api_msg msg; + + if (conn != (netconn *)0x0) { + pnStack52 = conn; + msg.msg._0_4_ = sys_now(); + eVar1 = netconn_apimsg(lwip_netconn_do_delconn,(api_msg *)&pnStack52); + return eVar1; + } + return '\0'; +} + + + +err_t netconn_delete(netconn *conn) + +{ + err_t eVar1; + undefined3 extraout_var; + + eVar1 = '\0'; + if ((conn != (netconn *)0x0) && + (eVar1 = netconn_prepare_delete(conn), CONCAT31(extraout_var,eVar1) == 0)) { + netconn_free(conn); + } + return eVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_getaddr(netconn *conn,ip_addr_t *addr,u16_t *port,u8_t local) + +{ + err_t eVar1; + netconn *pnStack52; + api_msg msg; + + if (conn == (netconn *)0x0) { + return -0x10; + } + if ((addr != (ip_addr_t *)0x0) && (port != (u16_t *)0x0)) { + pnStack52 = conn; + msg._4_4_ = addr; + msg.msg._0_4_ = port; + msg.msg[4] = local; + eVar1 = netconn_apimsg(lwip_netconn_do_getaddr,(api_msg *)&pnStack52); + return eVar1; + } + return -0x10; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_bind(netconn *conn,ip_addr_t *addr,u16_t port) + +{ + err_t eVar1; + netconn *pnStack52; + api_msg msg; + + if (conn != (netconn *)0x0) { + if (addr == (ip_addr_t *)0x0) { + addr = &ip_addr_any; + } + pnStack52 = conn; + msg._4_4_ = addr; + msg.msg._0_2_ = port; + eVar1 = netconn_apimsg(lwip_netconn_do_bind,(api_msg *)&pnStack52); + return eVar1; + } + return -0x10; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_connect(netconn *conn,ip_addr_t *addr,u16_t port) + +{ + err_t eVar1; + netconn *pnStack52; + api_msg msg; + + if (conn != (netconn *)0x0) { + if (addr == (ip_addr_t *)0x0) { + addr = &ip_addr_any; + } + pnStack52 = conn; + msg._4_4_ = addr; + msg.msg._0_2_ = port; + eVar1 = netconn_apimsg(lwip_netconn_do_connect,(api_msg *)&pnStack52); + return eVar1; + } + return -0x10; +} + + + +err_t netconn_disconnect(netconn *conn) + +{ + err_t eVar1; + netconn *pnStack52; + api_msg msg; + + if (conn != (netconn *)0x0) { + pnStack52 = conn; + eVar1 = netconn_apimsg(lwip_netconn_do_disconnect,(api_msg *)&pnStack52); + return eVar1; + } + return -0x10; +} + + + +err_t netconn_listen_with_backlog(netconn *conn,u8_t backlog) + +{ + err_t eVar1; + netconn *pnStack52; + api_msg msg; + + if (conn != (netconn *)0x0) { + pnStack52 = conn; + eVar1 = netconn_apimsg(lwip_netconn_do_listen,(api_msg *)&pnStack52); + return eVar1; + } + return -0x10; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_tcp_recvd(netconn *conn,size_t len) + +{ + err_t eVar1; + netconn *pnStack52; + api_msg msg; + + if (conn == (netconn *)0x0) { + return -0x10; + } + if ((conn->type & 0xf0) == NETCONN_TCP) { + pnStack52 = conn; + msg._4_4_ = len; + eVar1 = netconn_apimsg(lwip_netconn_do_recv,(api_msg *)&pnStack52); + return eVar1; + } + return -0x10; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_send(netconn *conn,netbuf *buf) + +{ + err_t eVar1; + netconn *pnStack52; + api_msg msg; + + if (conn != (netconn *)0x0) { + pnStack52 = conn; + msg._4_4_ = buf; + eVar1 = netconn_apimsg(lwip_netconn_do_send,(api_msg *)&pnStack52); + return eVar1; + } + return -0x10; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_write_vectors_partly + (netconn *conn,netvector *vectors,u16_t vectorcnt,u8_t apiflags, + size_t *bytes_written) + +{ + err_t eVar1; + int iVar2; + undefined3 extraout_var; + undefined2 in_register_00002032; + size_t *psVar3; + uint uVar4; + netconn *pnStack52; + api_msg msg; + + if (conn == (netconn *)0x0) { + return -0x10; + } + eVar1 = -6; + if ((conn->type & 0xf0) == NETCONN_TCP) { + if ((((uint)((conn->flags & 2 | apiflags & 4) != 0) | conn->send_timeout) != 0) && + (bytes_written == (size_t *)0x0)) { + return -6; + } + psVar3 = &vectors->len; + iVar2 = 0; + msg.msg._8_4_ = 0; + while (iVar2 < CONCAT22(in_register_00002032,vectorcnt)) { + uVar4 = *psVar3; + psVar3 = psVar3 + 2; + msg.msg._8_4_ = msg.msg._8_4_ + uVar4; + if (msg.msg._8_4_ < uVar4) { + return -6; + } + iVar2 = iVar2 + 1; + } + if (msg.msg._8_4_ != 0) { + if ((int)msg.msg._8_4_ < 0) { + if (bytes_written == (size_t *)0x0) { + return -6; + } + msg.msg._8_4_ = 0x7fffffff; + } + msg.msg._4_4_ = 0; + msg.msg._12_4_ = 0; + pnStack52 = conn; + msg._4_4_ = vectors; + msg.msg._0_2_ = vectorcnt; + msg.msg[16] = apiflags; + if (conn->send_timeout == 0) { + msg.msg._20_4_ = 0; + } + else { + msg.msg._20_4_ = sys_now(); + } + eVar1 = netconn_apimsg(lwip_netconn_do_write,(api_msg *)&pnStack52); + if (CONCAT31(extraout_var,eVar1) == 0) { + if (bytes_written == (size_t *)0x0) { + eVar1 = '\0'; + } + else { + *bytes_written = msg.msg._12_4_; + } + } + return eVar1; + } + eVar1 = '\0'; + } + return eVar1; +} + + + +err_t netconn_write_partly + (netconn *conn,void *dataptr,size_t size,u8_t apiflags,size_t *bytes_written) + +{ + err_t eVar1; + void *pvStack24; + netvector vector; + + pvStack24 = dataptr; + vector.ptr = (void *)size; + eVar1 = netconn_write_vectors_partly(conn,(netvector *)&pvStack24,1,apiflags,bytes_written); + return eVar1; +} + + + +err_t netconn_err(netconn *conn) + +{ + err_t eVar1; + + eVar1 = '\0'; + if (conn != (netconn *)0x0) { + sys_arch_protect(); + eVar1 = conn->pending_err; + conn->pending_err = '\0'; + sys_arch_unprotect(); + } + return eVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_accept(netconn *conn,netconn **new_conn) + +{ + err_t eVar1; + undefined3 extraout_var; + int iVar2; + u32_t uVar3; + sys_mbox_t *mbox; + err_t eStack37; + err_t err; + netconn *pnStack36; + void *accept_ptr; + + if ((new_conn == (netconn **)0x0) || (*new_conn = (netconn *)0x0, conn == (netconn *)0x0)) { + eVar1 = -0x10; + } + else { + eVar1 = netconn_err(conn); + if (CONCAT31(extraout_var,eVar1) == 0) { + mbox = &conn->acceptmbox; + eStack37 = eVar1; + iVar2 = sys_mbox_valid(mbox); + if ((iVar2 != 0) && ((conn->flags & 1) == 0)) { + if ((conn->flags & 2) == 0) { + uVar3 = sys_arch_mbox_fetch(mbox,(void **)&stack0xffffffdc,conn->recv_timeout); + if (uVar3 == 0xffffffff) { + return -3; + } + } + else { + uVar3 = sys_arch_mbox_tryfetch(mbox,(void **)&stack0xffffffdc); + if (uVar3 == 0xffffffff) { + return -7; + } + } + if (conn->callback != (netconn_callback *)0x0) { + (*conn->callback)(conn,NETCONN_EVT_RCVMINUS,0); + } + iVar2 = lwip_netconn_is_err_msg(pnStack36,&eStack37); + if (iVar2 != 0) { + return eStack37; + } + if (pnStack36 != (netconn *)0x0) { + *new_conn = pnStack36; + return eVar1; + } + } + eVar1 = -0xf; + } + } + return eVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_recv_data(netconn *conn,void **new_buf,u8_t apiflags) + +{ + err_t eVar1; + int iVar2; + undefined3 extraout_var; + u32_t uVar3; + undefined3 extraout_var_00; + void **ppvVar4; + sys_mbox_t *mbox; + err_t eStack37; + err_t err; + void **msg; + void *buf; + + msg = (void **)0x0; + if ((new_buf == (void **)0x0) || (*new_buf = (void *)0x0, conn == (netconn *)0x0)) { + return -0x10; + } + mbox = &conn->recvmbox; + iVar2 = sys_mbox_valid(mbox); + if (iVar2 == 0) { + eVar1 = netconn_err(conn); + if (CONCAT31(extraout_var,eVar1) == 0) { + return -0xb; + } + return eVar1; + } + if (((apiflags & 4 | conn->flags & 3) == 0) && (conn->pending_err == '\0')) { + uVar3 = sys_arch_mbox_fetch(mbox,(void **)&stack0xffffffdc,conn->recv_timeout); + if (uVar3 == 0xffffffff) { + return -3; + } + } + else { + uVar3 = sys_arch_mbox_tryfetch(mbox,(void **)&stack0xffffffdc); + if (uVar3 == 0xffffffff) { + eVar1 = netconn_err(conn); + if (CONCAT31(extraout_var_00,eVar1) != 0) { + return eVar1; + } + if ((conn->flags & 1) != 0) { + return -0xb; + } + return -7; + } + } + if ((conn->type & 0xf0) == NETCONN_TCP) { + iVar2 = lwip_netconn_is_err_msg(msg,&eStack37); + ppvVar4 = msg; + if (iVar2 != 0) { + if (eStack37 == -0xf) { + return '\0'; + } + return eStack37; + } + } + else { + ppvVar4 = (void **)*msg; + } + if (conn->callback != (netconn_callback *)0x0) { + (*conn->callback)(conn,NETCONN_EVT_RCVMINUS,*(u16_t *)(ppvVar4 + 2)); + } + *(void ***)new_buf = msg; + return '\0'; +} + + + +err_t netconn_recv_udp_raw_netbuf_flags(netconn *conn,netbuf **new_buf,u8_t apiflags) + +{ + err_t eVar1; + + if ((conn != (netconn *)0x0) && ((conn->type & 0xf0) != NETCONN_TCP)) { + eVar1 = netconn_recv_data(conn,new_buf,apiflags); + return eVar1; + } + return -0x10; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_recv_data_tcp(netconn *conn,pbuf **new_buf,u8_t apiflags) + +{ + err_t eVar1; + int iVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint uVar3; + pbuf *ppVar4; + netconn *pnStack68; + api_msg msg; + + iVar2 = sys_mbox_valid(&conn->recvmbox); + if (iVar2 == 0) { + return -0xb; + } + if ((char)conn->flags < '\0') { + conn->flags = conn->flags & 0x7f; + } + else { + eVar1 = netconn_recv_data(conn,new_buf,apiflags); + if (CONCAT31(extraout_var_00,eVar1) != 0) { + return eVar1; + } + ppVar4 = *new_buf; + if ((apiflags & 8) == 0) { + uVar3 = 1; + if (ppVar4 != (pbuf *)0x0) { + uVar3 = (uint)ppVar4->tot_len; + } + if ((conn->type & 0xf0) == NETCONN_TCP) { + pnStack68 = conn; + msg._4_4_ = uVar3; + netconn_apimsg(lwip_netconn_do_recv,(api_msg *)&pnStack68); + } + } + if (ppVar4 != (pbuf *)0x0) { + return eVar1; + } + if ((apiflags & 0x10) != 0) { + conn->flags = conn->flags | 0x80; + return -7; + } + } + if (conn->callback != (netconn_callback *)0x0) { + (*conn->callback)(conn,NETCONN_EVT_RCVMINUS,0); + } + if (conn->pcb == 0) { + eVar1 = netconn_err(conn); + if (CONCAT31(extraout_var,eVar1) == 0) { + eVar1 = -0xe; + } + } + else { + netconn_close_shutdown(conn,'\x01'); + eVar1 = -0xf; + } + return eVar1; +} + + + +err_t netconn_recv_tcp_pbuf_flags(netconn *conn,pbuf **new_buf,u8_t apiflags) + +{ + err_t eVar1; + + if ((conn != (netconn *)0x0) && ((conn->type & 0xf0) == NETCONN_TCP)) { + eVar1 = netconn_recv_data_tcp(conn,new_buf,apiflags); + return eVar1; + } + return -0x10; +} + + + +err_t netconn_shutdown(netconn *conn,u8_t shut_rx,u8_t shut_tx) + +{ + err_t eVar1; + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + + eVar1 = netconn_close_shutdown + (conn,CONCAT31(in_register_0000202d,shut_rx) != 0 | + (CONCAT31(in_register_00002031,shut_tx) != 0) << 1); + return eVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netconn_join_leave_group + (netconn *conn,ip_addr_t *multiaddr,ip_addr_t *netif_addr,netconn_igmp join_or_leave + ) + +{ + err_t eVar1; + netconn *pnStack52; + api_msg msg; + + if (conn != (netconn *)0x0) { + if (multiaddr == (ip_addr_t *)0x0) { + multiaddr = &ip_addr_any; + } + if (netif_addr == (ip_addr_t *)0x0) { + netif_addr = &ip_addr_any; + } + pnStack52 = conn; + msg._4_4_ = multiaddr; + msg.msg._0_4_ = netif_addr; + msg.msg[5] = join_or_leave; + eVar1 = netconn_apimsg(lwip_netconn_do_join_leave_group,(api_msg *)&pnStack52); + return eVar1; + } + return -0x10; +} + + + +err_t netconn_gethostbyname(char *name,ip_addr_t *addr) + +{ + err_t eVar1; + err_t eVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined auStack36 [3]; + err_t err; + sys_sem_t sem; + dns_api_msg msg; + + eVar2 = -0x10; + if ((name != (char *)0x0) && (addr != (ip_addr_t *)0x0)) { + sem = (sys_sem_t)name; + eVar1 = sys_sem_new((sys_sem_t *)auStack36,'\0'); + eVar2 = eVar1; + if (CONCAT31(extraout_var,eVar1) == 0) { + eVar2 = tcpip_send_msg_wait_sem(lwip_netconn_do_gethostbyname,&sem,(sys_sem_t *)auStack36); + sys_sem_free((sys_sem_t *)auStack36); + if (CONCAT31(extraout_var_00,eVar2) == 0) { + eVar2 = eVar1; + } + } + } + return eVar2; +} + + + +void lwip_netconn_do_dns_found(char *name,ip_addr_t *ipaddr,void *arg) + +{ + if (ipaddr == (ip_addr_t *)0x0) { + **(undefined **)((int)arg + 0xc) = 0xfa; + } + else { + **(undefined **)((int)arg + 0xc) = 0; + **(u32_t **)((int)arg + 4) = ipaddr->addr; + } + sys_sem_signal((sys_mutex_t *)*(sys_mutex_t *)((int)arg + 8)); + return; +} + + + +void recv_udp(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port) + +{ + ushort uVar1; + err_t eVar2; + int iVar3; + netbuf *buf; + undefined3 extraout_var; + u32_t uVar4; + + if (arg != (void *)0x0) { + iVar3 = sys_mbox_valid((sys_mbox_t *)((int)arg + 0x10)); + if ((iVar3 != 0) && (buf = (netbuf *)memp_malloc(MEMP_NETBUF), buf != (netbuf *)0x0)) { + buf->p = p; + buf->ptr = p; + uVar4 = 0; + if (addr != (ip_addr_t *)0x0) { + uVar4 = addr->addr; + } + (buf->addr).addr = uVar4; + buf->port = port; + uVar1 = p->tot_len; + eVar2 = sys_mbox_trypost((sys_mbox_t *)((int)arg + 0x10),buf); + if (CONCAT31(extraout_var,eVar2) != 0) { + netbuf_delete(buf); + return; + } + if (*(code **)((int)arg + 0x2c) != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x2304635c. Too many branches + // WARNING: Treating indirect jump as call + (**(code **)((int)arg + 0x2c))(arg,0,(uint)uVar1); + return; + } + return; + } + } + pbuf_free(p); + return; +} + + + +void setup_tcp(netconn *conn) + +{ + tcp_pcb *pcb; + + pcb = (tcp_pcb *)conn->pcb; + tcp_arg(pcb,conn); + tcp_recv(pcb,recv_tcp); + tcp_sent(pcb,sent_tcp); + tcp_poll(pcb,poll_tcp,'\x02'); + tcp_err(pcb,err_tcp); + return; +} + + + +err_t lwip_netconn_do_connected(void *arg,tcp_pcb *pcb,err_t err) + +{ + byte bVar1; + err_t eVar2; + sys_mutex_t mutex; + undefined3 in_register_00002031; + + eVar2 = -6; + if (arg != (void *)0x0) { + mutex = *(sys_mutex_t *)((int)arg + 0x28); + if (mutex != (sys_mutex_t)0x0) { + *(err_t *)&mutex->pcWriteTo = err; + mutex = (sys_mutex_t)(**(int **)((int)arg + 0x28) + 0xc); + } + if (((*(byte *)arg & 0xf0) == 0x10) && (CONCAT31(in_register_00002031,err) == 0)) { + setup_tcp((netconn *)arg); + } + bVar1 = *(byte *)((int)arg + 0x24); + *(undefined4 *)((int)arg + 0x28) = 0; + *(undefined *)((int)arg + 1) = 0; + *(byte *)((int)arg + 0x24) = bVar1 & 0xfb; + if (*(code **)((int)arg + 0x2c) != (code *)0x0) { + (**(code **)((int)arg + 0x2c))(arg,2,0); + } + eVar2 = '\0'; + if ((bVar1 & 4) == 0) { + sys_sem_signal((sys_mutex_t *)mutex); + } + } + return eVar2; +} + + + +void err_tcp(void *arg,err_t err) + +{ + char cVar1; + byte bVar2; + sys_sem_t *sem; + int iVar3; + uint uVar4; + void *msg; + + sys_arch_protect(); + cVar1 = *(char *)((int)arg + 1); + *(undefined4 *)((int)arg + 4) = 0; + *(byte *)((int)arg + 0x24) = *(byte *)((int)arg + 0x24) | 1; + *(err_t *)((int)arg + 8) = err; + *(undefined *)((int)arg + 1) = 0; + sys_arch_unprotect(); + if (*(code **)((int)arg + 0x2c) != (code *)0x0) { + (**(code **)((int)arg + 0x2c))(arg,4,0); + } + if (*(code **)((int)arg + 0x2c) != (code *)0x0) { + (**(code **)((int)arg + 0x2c))(arg,0,0); + } + if (*(code **)((int)arg + 0x2c) != (code *)0x0) { + (**(code **)((int)arg + 0x2c))(arg,2,0); + } + uVar4 = (uint)(byte)err + 0xf & 0xff; + msg = (void *)0x0; + if (uVar4 < 3) { + msg = *(void **)(CSWTCH_13 + uVar4 * 4); + } + iVar3 = sys_mbox_valid((sys_mbox_t *)((int)arg + 0x10)); + if (iVar3 != 0) { + sys_mbox_trypost((sys_mbox_t *)((int)arg + 0x10),msg); + } + iVar3 = sys_mbox_valid((sys_mbox_t *)((int)arg + 0x14)); + if (iVar3 != 0) { + sys_mbox_trypost((sys_mbox_t *)((int)arg + 0x14),msg); + } + if (((cVar1 == '\x01') || ((byte)(cVar1 - 3U) < 2)) && + (bVar2 = *(byte *)((int)arg + 0x24), *(byte *)((int)arg + 0x24) = bVar2 & 0xfb, + (bVar2 & 4) == 0)) { + if (cVar1 == '\x04') { + err = '\0'; + } + *(err_t *)(*(int *)((int)arg + 0x28) + 4) = err; + sem = (sys_sem_t *)(**(int **)((int)arg + 0x28) + 0xc); + sys_sem_valid(sem); + *(undefined4 *)((int)arg + 0x28) = 0; + sys_sem_signal((sys_mutex_t *)sem); + return; + } + return; +} + + + +err_t lwip_netconn_do_writemore(netconn *conn) + +{ + ushort uVar1; + bool bVar2; + err_t eVar3; + TickType_t TVar4; + netconn *pnVar5; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + uint uVar6; + api_msg *paVar7; + int iVar8; + uint uVar9; + int iVar10; + uint uVar11; + byte apiflags; + byte bVar12; + + apiflags = conn->current_msg->msg[0x14]; + bVar12 = conn->flags & 2 | apiflags & 4; + if (conn->send_timeout == 0) { +LAB_23046596: + do { + paVar7 = conn->current_msg; + uVar9 = (*(int **)paVar7->msg)[1] - *(int *)(paVar7->msg + 8); + if (uVar9 < 0x10000) { + uVar11 = uVar9 & 0xffff; + } + else { + apiflags = apiflags | 2; + uVar11 = 0xffff; + } + uVar1 = ((tcp_pcb *)conn->pcb)->snd_buf; + uVar6 = (uint)uVar1; + if (uVar6 < uVar11) { + if (bVar12 == 0) { + apiflags = apiflags | 2; + } + else { + if (uVar1 == 0) { + iVar8 = -7; + if (*(int *)(paVar7->msg + 0x10) != 0) { + iVar8 = 0; + } + goto LAB_230465ce; + } + } +LAB_2304662c: + bVar2 = false; + if (((uVar9 & 0xffff) == uVar6) && (1 < *(ushort *)(paVar7->msg + 4))) goto LAB_2304663e; + } + else { + uVar6 = uVar11; + if ((uVar11 != 0xffff) || (uVar9 < 0x10000)) goto LAB_2304662c; +LAB_2304663e: + apiflags = apiflags | 2; + bVar2 = true; + } + eVar3 = tcp_write((tcp_pcb *)conn->pcb, + (void *)(**(int **)paVar7->msg + *(int *)(paVar7->msg + 8)),(u16_t)uVar6, + apiflags); + iVar8 = CONCAT31(extraout_var_00,eVar3); + if (iVar8 != 0) { + if (1 < (iVar8 + 1U & 0xff)) goto LAB_2304657e; + iVar8 = -1; + break; + } + *(uint *)(conn->current_msg->msg + 0x10) = *(int *)(conn->current_msg->msg + 0x10) + uVar6; + *(uint *)(conn->current_msg->msg + 8) = uVar6 + *(int *)(conn->current_msg->msg + 8); + paVar7 = conn->current_msg; + if (*(int *)(paVar7->msg + 8) == *(int *)(*(int *)paVar7->msg + 4)) { + *(short *)(paVar7->msg + 4) = *(short *)(paVar7->msg + 4) + -1; + paVar7 = conn->current_msg; + if (*(short *)(paVar7->msg + 4) != 0) { + *(int *)paVar7->msg = *(int *)paVar7->msg + 8; + *(undefined4 *)(conn->current_msg->msg + 8) = 0; + } + } + } while (bVar2); + if (bVar12 == 0) { +LAB_230466a6: + if (((*(ushort *)(conn->pcb + 100) < 0xac1) || (7 < *(ushort *)(conn->pcb + 0x66))) && + (conn->callback != (netconn_callback *)0x0)) { + (*conn->callback)(conn,NETCONN_EVT_SENDMINUS,0); + } + } + else { +LAB_230465ce: + if (*(uint *)(conn->current_msg->msg + 0xc) <= *(uint *)(conn->current_msg->msg + 0x10)) + goto LAB_230466a6; + if (conn->callback != (netconn_callback *)0x0) { + (*conn->callback)(conn,NETCONN_EVT_SENDMINUS,0); + } + conn->flags = conn->flags | 0x10; + } + eVar3 = (err_t)iVar8; + if (iVar8 != 0) { + if (iVar8 != -1) goto LAB_2304657e; + eVar3 = tcp_output((tcp_pcb *)conn->pcb); + if (CONCAT31(extraout_var_01,eVar3) == -4) goto LAB_2304660e; + if (bVar12 == 0) { + return '\0'; + } + iVar8 = *(int *)(conn->current_msg->msg + 0x10); + goto LAB_23046578; + } + iVar8 = *(int *)(conn->current_msg->msg + 0x10); + iVar10 = *(int *)(conn->current_msg->msg + 0xc); + eVar3 = tcp_output((tcp_pcb *)conn->pcb); + if (CONCAT31(extraout_var,eVar3) == -4) { +LAB_2304660e: + eVar3 = -4; + goto LAB_2304657e; + } + if (iVar8 != iVar10 && bVar12 == 0) { + return '\0'; + } + } + else { + TVar4 = sys_now(); + if ((int)(TVar4 - *(int *)(conn->current_msg->msg + 0x18)) < conn->send_timeout) + goto LAB_23046596; + iVar8 = *(int *)(conn->current_msg->msg + 0x10); +LAB_23046578: + eVar3 = -7; + if (iVar8 == 0) goto LAB_2304657e; + } + eVar3 = '\0'; +LAB_2304657e: + pnVar5 = conn->current_msg->conn; + conn->current_msg->err = eVar3; + conn->current_msg = (api_msg *)0x0; + conn->state = NETCONN_NONE; + sys_sem_signal((sys_mutex_t *)&pnVar5->op_completed); + return '\0'; +} + + + +err_t lwip_netconn_do_close_internal(netconn *conn) + +{ + byte bVar1; + bool bVar2; + tcp_pcb *pcb; + netconn *pnVar3; + err_t eVar4; + undefined3 extraout_var; + undefined3 extraout_var_00; + TickType_t TVar5; + int iVar6; + int iVar7; + + bVar1 = conn->current_msg->msg[0]; + pcb = (tcp_pcb *)conn->pcb; + if (((bVar1 == 3) || + (((bVar1 & 1) != 0 && (((byte)(pcb->state + ~ESTABLISHED) < 2 || (pcb->state == CLOSING)))))) + || ((bVar2 = false, (bVar1 & 2) != 0 && ((pcb->flags & 0x10) != 0)))) { + tcp_arg(pcb,(void *)0x0); + bVar2 = true; + } + if (pcb->state == LISTEN) { + tcp_accept(pcb,(tcp_accept_fn)0x0); + if (!bVar2) { +LAB_2304677c: + eVar4 = tcp_shutdown(pcb,(uint)bVar1 & 1,(uint)bVar1 & 2); + iVar6 = CONCAT31(extraout_var,eVar4); + goto LAB_230467c4; + } + } + else { + if ((bVar1 & 1) != 0) { + tcp_recv(pcb,(tcp_recv_fn *)0x0); + tcp_accept(pcb,(tcp_accept_fn)0x0); + } + if ((bVar1 & 2) != 0) { + tcp_sent(pcb,(tcp_sent_fn *)0x0); + } + if (!bVar2) goto LAB_2304677c; + tcp_poll(pcb,(tcp_poll_fn *)0x0,'\0'); + tcp_err(pcb,(tcp_err_fn *)0x0); + } + eVar4 = tcp_close(pcb); + iVar6 = CONCAT31(extraout_var_00,eVar4); +LAB_230467c4: + if ((iVar6 != 0) && (iVar6 == -1)) { + iVar7 = conn->send_timeout; + if (iVar7 < 1) { + iVar7 = 5000; + } + TVar5 = sys_now(); + if ((int)(TVar5 - *(int *)(conn->current_msg->msg + 4)) < iVar7) { + if ((bVar1 & 2) != 0) { + tcp_sent(pcb,sent_tcp); + } + tcp_poll(pcb,poll_tcp,'\x01'); + tcp_err(pcb,err_tcp); + tcp_arg(pcb,conn); + return (err_t)iVar6; + } + if (bVar2) { + tcp_abort(pcb); + iVar6 = 0; + } + } + pnVar3 = conn->current_msg->conn; + conn->current_msg->err = (err_t)iVar6; + conn->current_msg = (api_msg *)0x0; + conn->state = NETCONN_NONE; + if (iVar6 == 0) { + if (bVar2) { + conn->pcb = 0; + if (conn->callback != (netconn_callback *)0x0) { + (*conn->callback)(conn,NETCONN_EVT_ERROR,0); + } + } + if (((bVar1 & 1) != 0) && (conn->callback != (netconn_callback *)0x0)) { + (*conn->callback)(conn,NETCONN_EVT_RCVPLUS,0); + } + if (((bVar1 & 2) != 0) && (conn->callback != (netconn_callback *)0x0)) { + (*conn->callback)(conn,NETCONN_EVT_SENDPLUS,0); + } + } + sys_sem_signal((sys_mutex_t *)&pnVar3->op_completed); + return '\0'; +} + + + +err_t poll_tcp(void *arg,tcp_pcb *pcb) + +{ + int iVar1; + + if (*(char *)((int)arg + 1) == '\x01') { + lwip_netconn_do_writemore((netconn *)arg); + } + else { + if (*(char *)((int)arg + 1) == '\x04') { + lwip_netconn_do_close_internal((netconn *)arg); + } + } + if (((((*(byte *)((int)arg + 0x24) & 0x10) != 0) && (iVar1 = *(int *)((int)arg + 4), iVar1 != 0)) + && (0xac0 < *(ushort *)(iVar1 + 100))) && (*(ushort *)(iVar1 + 0x66) < 8)) { + *(byte *)((int)arg + 0x24) = *(byte *)((int)arg + 0x24) & 0xef; + if (*(code **)((int)arg + 0x2c) != (code *)0x0) { + (**(code **)((int)arg + 0x2c))(arg,2,0); + } + } + return '\0'; +} + + + +u8_t recv_raw(void *arg,raw_pcb *pcb,pbuf *p,ip_addr_t *addr) + +{ + ushort uVar1; + err_t eVar2; + int iVar3; + pbuf *p_00; + netbuf *buf; + undefined3 extraout_var; + u16_t len; + + if (arg != (void *)0x0) { + iVar3 = sys_mbox_valid((sys_mbox_t *)((int)arg + 0x10)); + if ((iVar3 != 0) && (p_00 = pbuf_clone(PBUF_RAW,PBUF_RAM,p), p_00 != (pbuf *)0x0)) { + buf = (netbuf *)memp_malloc(MEMP_NETBUF); + if (buf == (netbuf *)0x0) { + pbuf_free(p_00); + } + else { + buf->p = p_00; + buf->ptr = p_00; + (buf->addr).addr = ip_data.current_iphdr_src; + buf->port = (ushort)pcb->protocol; + uVar1 = p_00->tot_len; + eVar2 = sys_mbox_trypost((sys_mbox_t *)((int)arg + 0x10),buf); + if (CONCAT31(extraout_var,eVar2) == 0) { + if (*(code **)((int)arg + 0x2c) != (code *)0x0) { + (**(code **)((int)arg + 0x2c))(arg,0,(uint)uVar1); + } + } + else { + netbuf_delete(buf); + } + } + } + return '\0'; + } + return '\0'; +} + + + +err_t sent_tcp(void *arg,tcp_pcb *pcb,u16_t len) + +{ + undefined2 in_register_00002032; + int iVar1; + + if (arg != (void *)0x0) { + if (*(char *)((int)arg + 1) == '\x01') { + lwip_netconn_do_writemore((netconn *)arg); + } + else { + if (*(char *)((int)arg + 1) == '\x04') { + lwip_netconn_do_close_internal((netconn *)arg); + } + } + iVar1 = *(int *)((int)arg + 4); + if (((iVar1 != 0) && (0xac0 < *(ushort *)(iVar1 + 100))) && (*(ushort *)(iVar1 + 0x66) < 8)) { + *(byte *)((int)arg + 0x24) = *(byte *)((int)arg + 0x24) & 0xef; + if (*(code **)((int)arg + 0x2c) != (code *)0x0) { + (**(code **)((int)arg + 0x2c))(arg,2,CONCAT22(in_register_00002032,len)); + } + } + return '\0'; + } + return '\0'; +} + + + +err_t recv_tcp(void *arg,tcp_pcb *pcb,pbuf *p,err_t err) + +{ + err_t eVar1; + int iVar2; + undefined3 extraout_var; + uint uVar3; + + if (arg == (void *)0x0) { + return -6; + } + iVar2 = sys_mbox_valid((sys_mbox_t *)((int)arg + 0x10)); + if (iVar2 == 0) { + if (p != (pbuf *)0x0) { + tcp_recved(pcb,p->tot_len); + pbuf_free(p); + } + } + else { + if (p == (pbuf *)0x0) { + uVar3 = 0; + p = (pbuf *)""; + } + else { + uVar3 = (uint)p->tot_len; + } + eVar1 = sys_mbox_trypost((sys_mbox_t *)((int)arg + 0x10),p); + if (CONCAT31(extraout_var,eVar1) != 0) { + return -1; + } + if (*(code **)((int)arg + 0x2c) != (code *)0x0) { + (**(code **)((int)arg + 0x2c))(arg,0,uVar3); + return eVar1; + } + } + return '\0'; +} + + + +int lwip_netconn_is_err_msg(void *msg,err_t *err) + +{ + err_t eVar1; + + if ((u8_t *)msg == "") { + eVar1 = -0xd; + } + else { + if ((u8_t *)msg == "") { + eVar1 = -0xe; + } + else { + if ((u8_t *)msg != "") { + return 0; + } + eVar1 = -0xf; + } + } + *err = eVar1; + return 1; +} + + + +void lwip_netconn_do_newconn(void *m) + +{ + byte *pbVar1; + tcp_pcb *ptVar2; + raw_pcb *pcb; + udp_pcb *puVar3; + byte bVar4; + undefined uVar5; + int iVar6; + + pbVar1 = *(byte **)m; + *(undefined *)((int)m + 4) = 0; + if (*(int *)(pbVar1 + 4) != 0) goto LAB_23046b1c; + bVar4 = *pbVar1 & 0xf0; + if (bVar4 == 0x20) { + puVar3 = udp_new_ip_type(); + *(udp_pcb **)(pbVar1 + 4) = puVar3; + iVar6 = *(int *)(*(char **)m + 4); + if (iVar6 != 0) { + if (**(char **)m == '\"') { + *(undefined *)(iVar6 + 0x10) = 1; + } + udp_recv(*(udp_pcb **)((int)*(void **)m + 4),recv_udp,*(void **)m); +LAB_23046b16: + if (*(int *)(*(int *)m + 4) != 0) goto LAB_23046b1c; + } +LAB_23046b66: + uVar5 = 0xff; + } + else { + if (bVar4 == 0x40) { + pcb = raw_new_ip_type('\0',*(u8_t *)((int)m + 8)); + *(raw_pcb **)(pbVar1 + 4) = pcb; + pcb = *(raw_pcb **)((int)*(void **)m + 4); + if (pcb != (raw_pcb *)0x0) { + raw_recv(pcb,recv_raw,*(void **)m); + goto LAB_23046b16; + } + goto LAB_23046b66; + } + if (bVar4 == 0x10) { + ptVar2 = tcp_new_ip_type('\0'); + *(tcp_pcb **)(pbVar1 + 4) = ptVar2; + if ((*(netconn **)m)->pcb != 0) { + setup_tcp(*(netconn **)m); + goto LAB_23046b16; + } + goto LAB_23046b66; + } + uVar5 = 0xfa; + } + *(undefined *)((int)m + 4) = uVar5; +LAB_23046b1c: + sys_sem_signal((sys_mutex_t *)(*(int *)m + 0xc)); + return; +} + + + +netconn * netconn_alloc(netconn_type t,netconn_callback *callback) + +{ + err_t eVar1; + netconn *mem; + undefined3 extraout_var; + undefined3 extraout_var_00; + int size; + + mem = (netconn *)memp_malloc(MEMP_NETCONN); + if (mem == (netconn *)0x0) { + return (netconn *)0x0; + } + mem->pending_err = '\0'; + mem->type = t; + mem->pcb = 0; + t = t & 0xf0; + if (t == NETCONN_UDP) { +LAB_23046ba8: + size = 2000; + } + else { + if (t != NETCONN_RAW) { + if (t != NETCONN_TCP) goto free_and_return; + goto LAB_23046ba8; + } + size = 0; + } + eVar1 = sys_mbox_new(&mem->recvmbox,size); + if (CONCAT31(extraout_var,eVar1) == 0) { + eVar1 = sys_sem_new(&mem->op_completed,'\0'); + if (CONCAT31(extraout_var_00,eVar1) == 0) { + sys_mbox_set_invalid(&mem->acceptmbox); + mem->state = NETCONN_NONE; + mem->socket = -1; + mem->callback = callback; + mem->current_msg = (api_msg *)0x0; + mem->send_timeout = 0; + mem->recv_timeout = 0; + mem->flags = '\0'; + return mem; + } + sys_mbox_free(&mem->recvmbox); + } +free_and_return: + memp_free(MEMP_NETCONN,mem); + return (netconn *)0x0; +} + + + +void netconn_free(netconn *conn) + +{ + sys_mbox_valid(&conn->recvmbox); + sys_mbox_valid(&conn->acceptmbox); + sys_sem_free(&conn->op_completed); + sys_sem_set_invalid(&conn->op_completed); + memp_free(MEMP_NETCONN,conn); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void netconn_drain(netconn *conn) + +{ + netconn *conn_00; + sys_mbox_t *mbox; + int iVar1; + u32_t uVar2; + err_t eStack37; + err_t err; + netconn *pnStack36; + void *mem; + + mbox = &conn->recvmbox; + iVar1 = sys_mbox_valid(mbox); + if (iVar1 != 0) { + while (uVar2 = sys_arch_mbox_tryfetch(mbox,(void **)&stack0xffffffdc), uVar2 != 0xffffffff) { + if ((conn->type & 0xf0) == NETCONN_TCP) { + iVar1 = lwip_netconn_is_err_msg(pnStack36,&eStack37); + if (iVar1 == 0) { + pbuf_free((pbuf *)pnStack36); + } + } + else { + netbuf_delete((netbuf *)pnStack36); + } + } + sys_mbox_free(mbox); + sys_mbox_set_invalid(mbox); + } + mbox = &conn->acceptmbox; + iVar1 = sys_mbox_valid(mbox); + if (iVar1 != 0) { + while (uVar2 = sys_arch_mbox_tryfetch(mbox,(void **)&stack0xffffffdc), uVar2 != 0xffffffff) { + iVar1 = lwip_netconn_is_err_msg(pnStack36,&eStack37); + conn_00 = pnStack36; + if (iVar1 == 0) { + netconn_drain(pnStack36); + if ((tcp_pcb *)conn_00->pcb != (tcp_pcb *)0x0) { + tcp_abort((tcp_pcb *)conn_00->pcb); + conn_00->pcb = 0; + } + netconn_free(conn_00); + } + } + sys_mbox_free(mbox); + sys_mbox_set_invalid(mbox); + } + return; +} + + + +err_t accept_function(void *arg,tcp_pcb *newpcb,err_t err) + +{ + tcp_pcb *pcb; + err_t eVar1; + err_t eVar2; + int iVar3; + undefined3 extraout_var; + netconn *conn; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 in_register_00002031; + sys_mbox_t *mbox; + + if (arg != (void *)0x0) { + mbox = (sys_mbox_t *)((int)arg + 0x14); + iVar3 = sys_mbox_valid(mbox,CONCAT31(in_register_00002031,err)); + if (iVar3 != 0) { + if (newpcb != (tcp_pcb *)0x0) { + conn = netconn_alloc(*(netconn_type *)arg,*(netconn_callback **)((int)arg + 0x2c)); + if (conn == (netconn *)0x0) { + eVar2 = sys_mbox_trypost(mbox,""); + eVar1 = -1; + if (CONCAT31(extraout_var_00,eVar2) != 0) { + return -1; + } + } + else { + *(tcp_pcb **)&conn->pcb = newpcb; + setup_tcp(conn); + eVar1 = sys_mbox_trypost(mbox,conn); + if (CONCAT31(extraout_var_01,eVar1) != 0) { + pcb = (tcp_pcb *)conn->pcb; + tcp_arg(pcb,(void *)0x0); + tcp_recv(pcb,(tcp_recv_fn *)0x0); + tcp_sent(pcb,(tcp_sent_fn *)0x0); + tcp_poll(pcb,(tcp_poll_fn *)0x0,'\0'); + tcp_err(pcb,(tcp_err_fn *)0x0); + conn->pcb = 0; + sys_mbox_free(&conn->recvmbox); + sys_mbox_set_invalid(&conn->recvmbox); + netconn_free(conn); + return -1; + } + } + if (*(code **)((int)arg + 0x2c) == (code *)0x0) { + return eVar1; + } + (**(code **)((int)arg + 0x2c))(arg,0,0); + return eVar1; + } + eVar1 = sys_mbox_trypost(mbox,""); + if ((CONCAT31(extraout_var,eVar1) == 0) && (*(code **)((int)arg + 0x2c) != (code *)0x0)) { + (**(code **)((int)arg + 0x2c))(arg,0,0); + } + } + } + return -6; +} + + + +void lwip_netconn_do_delconn(void *m) + +{ + netconn *conn; + int iVar1; + raw_pcb *pcb; + byte *pbVar2; + byte bVar3; + + conn = *(netconn **)m; + if (((conn->state & ~NETCONN_LISTEN) == NETCONN_NONE) || + ((conn->state == NETCONN_CONNECT && ((conn->flags & 4) != 0)))) { + *(undefined *)((int)m + 4) = 0; + netconn_drain(conn); + pbVar2 = *(byte **)m; + pcb = *(raw_pcb **)(pbVar2 + 4); + if (pcb != (raw_pcb *)0x0) { + bVar3 = *pbVar2 & 0xf0; + if (bVar3 == 0x20) { + *(undefined4 *)&pcb[1].netif_idx = 0; + udp_remove(*(udp_pcb **)(*(int *)m + 4)); + } + else { + if (bVar3 == 0x40) { + raw_remove(pcb); + } + else { + if (bVar3 == 0x10) { + pbVar2[1] = 4; + *(undefined *)((int)m + 8) = 3; + *(void **)(*(int *)m + 0x28) = m; + lwip_netconn_do_close_internal(*(netconn **)m); + return; + } + } + } + *(undefined4 *)(*(int *)m + 4) = 0; + } + if (*(code **)(*(int *)m + 0x2c) != (code *)0x0) { + (**(code **)(*(int *)m + 0x2c))(0,0); + } + if (*(code **)(*(int *)m + 0x2c) != (code *)0x0) { + (**(code **)(*(int *)m + 0x2c))(2,0); + } + } + else { + *(undefined *)((int)m + 4) = 0xfb; + } + iVar1 = sys_sem_valid((sys_sem_t *)(*(int *)m + 0xc)); + if (iVar1 != 0) { + sys_sem_signal((sys_mutex_t *)(*(int *)m + 0xc)); + return; + } + return; +} + + + +void lwip_netconn_do_bind(void *m) + +{ + err_t eVar1; + tcp_pcb *pcb; + byte bVar2; + + eVar1 = -6; + pcb = *(tcp_pcb **)(*(byte **)m + 4); + if (pcb != (tcp_pcb *)0x0) { + bVar2 = **(byte **)m & 0xf0; + if (bVar2 == 0x20) { + eVar1 = udp_bind((udp_pcb *)pcb,*(ip_addr_t **)((int)m + 8),*(u16_t *)((int)m + 0xc)); + } + else { + if (bVar2 == 0x40) { + eVar1 = raw_bind((raw_pcb *)pcb,*(ip_addr_t **)((int)m + 8)); + } + else { + if (bVar2 == 0x10) { + eVar1 = tcp_bind(pcb,*(ip_addr_t **)((int)m + 8),*(u16_t *)((int)m + 0xc)); + } + else { + eVar1 = -6; + } + } + } + } + *(err_t *)((int)m + 4) = eVar1; + sys_sem_signal((sys_mutex_t *)(*(int *)m + 0xc)); + return; +} + + + +void lwip_netconn_do_connect(void *m) + +{ + err_t eVar1; + udp_pcb *pcb; + undefined3 extraout_var; + netconn *conn; + netconn_type nVar2; + int iVar3; + int iVar4; + + conn = *(netconn **)m; + pcb = (udp_pcb *)conn->pcb; + if (pcb == (udp_pcb *)0x0) { + eVar1 = -0xf; + } + else { + nVar2 = conn->type & 0xf0; + if (nVar2 == NETCONN_UDP) { + eVar1 = udp_connect(pcb,*(ip_addr_t **)((int)m + 8),*(u16_t *)((int)m + 0xc)); + } + else { + if (nVar2 == NETCONN_RAW) { + eVar1 = raw_connect((raw_pcb *)pcb,*(ip_addr_t **)((int)m + 8)); + } + else { + eVar1 = -6; + if (nVar2 == NETCONN_TCP) { + if (conn->state == NETCONN_CONNECT) { + eVar1 = -9; + } + else { + eVar1 = -10; + if (conn->state == NETCONN_NONE) { + setup_tcp(conn); + eVar1 = tcp_connect(*(tcp_pcb **)(*(int *)m + 4),*(ip_addr_t **)((int)m + 8), + *(u16_t *)((int)m + 0xc),lwip_netconn_do_connected); + if (CONCAT31(extraout_var,eVar1) == 0) { + iVar3 = *(int *)m; + *(undefined *)(iVar3 + 1) = 3; + iVar4 = *(int *)m; + if ((*(byte *)(iVar3 + 0x24) & 2) == 0) { + *(byte *)(iVar4 + 0x24) = *(byte *)(iVar4 + 0x24) & 0xfb; + *(void **)(*(int *)m + 0x28) = m; + return; + } + eVar1 = -5; + *(byte *)(iVar4 + 0x24) = *(byte *)(iVar4 + 0x24) | 4; + } + } + } + } + } + } + } + *(err_t *)((int)m + 4) = eVar1; + sys_sem_signal((sys_mutex_t *)(*(int *)m + 0xc)); + return; +} + + + +void lwip_netconn_do_disconnect(void *m) + +{ + if ((**(byte **)m & 0xf0) == 0x20) { + udp_disconnect(*(udp_pcb **)(*(byte **)m + 4)); + *(undefined *)((int)m + 4) = 0; + } + else { + *(undefined *)((int)m + 4) = 0xfa; + } + sys_sem_signal((sys_mutex_t *)(*(int *)m + 0xc)); + return; +} + + + +void lwip_netconn_do_listen(void *m) + +{ + tcp_pcb *pcb; + int iVar1; + byte *pbVar2; + err_t aeStack17 [4]; + err_t err; + + pbVar2 = *(byte **)m; + pcb = *(tcp_pcb **)(pbVar2 + 4); + if (pcb != (tcp_pcb *)0x0) { + if ((*pbVar2 & 0xf0) != 0x10) { + aeStack17[0] = -0x10; + goto LAB_2304709c; + } + if (pbVar2[1] == 0) { + if (pcb->state == CLOSED) { + pcb = tcp_listen_with_backlog_and_err(pcb,-1,aeStack17); + if (pcb != (tcp_pcb *)0x0) { + iVar1 = sys_mbox_valid(*(int *)m + 0x10); + if (iVar1 != 0) { + sys_mbox_free((sys_mbox_t *)(*(int *)m + 0x10)); + sys_mbox_set_invalid(*(int *)m + 0x10); + } + aeStack17[0] = '\0'; + iVar1 = sys_mbox_valid(*(int *)m + 0x14); + if (iVar1 == 0) { + aeStack17[0] = sys_mbox_new((sys_mbox_t *)(*(int *)m + 0x14),2000); + } + if (aeStack17[0] == '\0') { + *(undefined *)(*(int *)m + 1) = 2; + *(tcp_pcb **)(*(int *)m + 4) = pcb; + tcp_arg(*(tcp_pcb **)((int)*(void **)m + 4),*(void **)m); + tcp_accept(*(tcp_pcb **)(*(int *)m + 4),accept_function); + } + else { + tcp_close(pcb); + *(undefined4 *)(*(int *)m + 4) = 0; + } + } + } + else { + aeStack17[0] = -6; + } + goto LAB_2304709c; + } + if (pbVar2[1] == 2) { + aeStack17[0] = '\0'; + goto LAB_2304709c; + } + } + aeStack17[0] = -0xb; +LAB_2304709c: + *(char *)((int)m + 4) = aeStack17[0]; + sys_sem_signal((sys_mutex_t *)(*(int *)m + 0xc)); + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void lwip_netconn_do_send(void *m) + +{ + err_t eVar1; + undefined3 extraout_var; + byte have_chksum; + pbuf *ppVar2; + udp_pcb *pcb; + + eVar1 = netconn_err(*(netconn **)m); + if (CONCAT31(extraout_var,eVar1) == 0) { + eVar1 = -0xb; + pcb = *(udp_pcb **)(*(byte **)m + 4); + if (pcb != (udp_pcb *)0x0) { + have_chksum = **(byte **)m & 0xf0; + if (have_chksum == 0x20) { + ppVar2 = *(pbuf **)((int)m + 8); + have_chksum = ppVar2->ref & 2; + if (((ip_addr_t *)&ppVar2->tot_len == (ip_addr_t *)0x0) || + (*(pbuf **)&ppVar2->tot_len == (pbuf *)0x0)) { + eVar1 = udp_send_chksum(pcb,ppVar2->next,have_chksum,*(u16_t *)&ppVar2[1].next); + } + else { + eVar1 = udp_sendto_chksum(pcb,ppVar2->next,(ip_addr_t *)&ppVar2->tot_len, + *(u16_t *)&ppVar2->type_internal,have_chksum, + *(u16_t *)&ppVar2[1].next); + } + } + else { + if (have_chksum == 0x40) { + ppVar2 = *(pbuf **)((int)m + 8); + if (((ip_addr_t *)&ppVar2->tot_len == (ip_addr_t *)0x0) || + (*(pbuf **)&ppVar2->tot_len == (pbuf *)0x0)) { + eVar1 = raw_send((raw_pcb *)pcb,ppVar2->next); + } + else { + eVar1 = raw_sendto((raw_pcb *)pcb,ppVar2->next,(ip_addr_t *)&ppVar2->tot_len); + } + } + } + } + } + *(err_t *)((int)m + 4) = eVar1; + sys_sem_signal((sys_mutex_t *)(*(int *)m + 0xc)); + return; +} + + + +void lwip_netconn_do_recv(void *m) + +{ + uint uVar1; + uint uVar2; + + *(undefined *)((int)m + 4) = 0; + if ((*(int *)(*(byte **)m + 4) != 0) && ((**(byte **)m & 0xf0) == 0x10)) { + uVar1 = *(uint *)((int)m + 8); + do { + uVar2 = uVar1; + if (0xffff < uVar1) { + uVar2 = 0xffff; + } + uVar1 = uVar1 - uVar2; + tcp_recved(*(tcp_pcb **)(*(int *)m + 4),(u16_t)uVar2); + } while (uVar1 != 0); + } + sys_sem_signal((sys_mutex_t *)(*(int *)m + 0xc)); + return; +} + + + +void lwip_netconn_do_write(void *m) + +{ + err_t eVar1; + undefined3 extraout_var; + byte *pbVar2; + + eVar1 = netconn_err(*(netconn **)m); + pbVar2 = *(byte **)m; + if ((CONCAT31(extraout_var,eVar1) == 0) && (eVar1 = -6, (*pbVar2 & 0xf0) == 0x10)) { + if (pbVar2[1] == 0) { + eVar1 = -0xb; + if (*(int *)(pbVar2 + 4) != 0) { + pbVar2[1] = 1; + *(void **)(*(int *)m + 0x28) = m; + lwip_netconn_do_writemore(*(netconn **)m); + return; + } + } + else { + eVar1 = -5; + } + } + *(err_t *)((int)m + 4) = eVar1; + sys_sem_signal((sys_mutex_t *)(pbVar2 + 0xc)); + return; +} + + + +void lwip_netconn_do_getaddr(void *m) + +{ + byte *pbVar1; + undefined2 *puVar2; + byte bVar3; + undefined2 uVar4; + undefined4 *puVar5; + undefined4 uVar6; + int iVar7; + + puVar5 = *(undefined4 **)(*(int *)m + 4); + if (puVar5 == (undefined4 *)0x0) { +LAB_23047272: + *(undefined *)((int)m + 4) = 0xf5; + } + else { + if (*(char *)((int)m + 0x10) == '\0') { + uVar6 = puVar5[1]; + } + else { + uVar6 = *puVar5; + } + **(undefined4 **)((int)m + 8) = uVar6; + pbVar1 = *(byte **)m; + *(undefined *)((int)m + 4) = 0; + bVar3 = *pbVar1 & 0xf0; + if (bVar3 == 0x20) { + iVar7 = *(int *)(pbVar1 + 4); + if (*(char *)((int)m + 0x10) == '\0') { + if ((*(byte *)(iVar7 + 0x10) & 4) == 0) goto LAB_23047272; + puVar2 = *(undefined2 **)((int)m + 0xc); + uVar4 = *(undefined2 *)(iVar7 + 0x14); + } + else { + puVar2 = *(undefined2 **)((int)m + 0xc); + uVar4 = *(undefined2 *)(iVar7 + 0x12); + } + } + else { + if (bVar3 == 0x40) { + if (*(char *)((int)m + 0x10) != '\0') { + **(ushort **)((int)m + 0xc) = (ushort)*(byte *)(*(int *)(pbVar1 + 4) + 0x10); + goto LAB_23047290; + } + goto LAB_23047272; + } + if (bVar3 != 0x10) goto LAB_23047290; + iVar7 = *(int *)(pbVar1 + 4); + if (*(char *)((int)m + 0x10) == '\0') { + if (*(byte *)(iVar7 + 0x14) < 2) goto LAB_23047272; + uVar4 = *(undefined2 *)(iVar7 + 0x18); + } + else { + uVar4 = *(undefined2 *)(iVar7 + 0x16); + } + puVar2 = *(undefined2 **)((int)m + 0xc); + } + *puVar2 = uVar4; + } +LAB_23047290: + sys_sem_signal((sys_mutex_t *)(*(int *)m + 0xc)); + return; +} + + + +void lwip_netconn_do_close(void *m) + +{ + netconn_state nVar1; + netconn *conn; + undefined uVar2; + + conn = *(netconn **)m; + if ((conn->pcb != 0) && ((conn->type & 0xf0) == NETCONN_TCP)) { + nVar1 = conn->state; + if (((*(byte *)((int)m + 8) == 3) || (nVar1 != NETCONN_LISTEN)) && (nVar1 != NETCONN_CONNECT)) { + if (nVar1 != NETCONN_WRITE) { + if ((*(byte *)((int)m + 8) & 1) != 0) { + netconn_drain(conn); + } + *(undefined *)(*(int *)m + 1) = 4; + *(void **)(*(int *)m + 0x28) = m; + lwip_netconn_do_close_internal(*(netconn **)m); + return; + } + uVar2 = 0xfb; + goto LAB_23047302; + } + } + uVar2 = 0xf5; +LAB_23047302: + *(undefined *)((int)m + 4) = uVar2; + sys_sem_signal((sys_mutex_t *)&conn->op_completed); + return; +} + + + +void lwip_netconn_do_join_leave_group(void *m) + +{ + err_t eVar1; + + *(undefined *)((int)m + 4) = 0xf5; + if (*(int *)(*(byte **)m + 4) != 0) { + if ((**(byte **)m & 0xf0) == 0x20) { + if (*(char *)((int)m + 0x11) == '\0') { + eVar1 = igmp_joingroup(*(ip4_addr_t **)((int)m + 0xc),*(ip4_addr_t **)((int)m + 8)); + } + else { + eVar1 = igmp_leavegroup(*(ip4_addr_t **)((int)m + 0xc),*(ip4_addr_t **)((int)m + 8)); + } + *(err_t *)((int)m + 4) = eVar1; + } + else { + *(undefined *)((int)m + 4) = 0xfa; + } + } + sys_sem_signal((sys_mutex_t *)(*(int *)m + 0xc)); + return; +} + + + +void lwip_netconn_do_gethostbyname(void *arg) + +{ + err_t *peVar1; + err_t eVar2; + + peVar1 = *(err_t **)((int)arg + 0xc); + eVar2 = dns_gethostbyname_addrtype + (*(char **)arg,*(ip_addr_t **)((int)arg + 4),lwip_netconn_do_dns_found,arg,'\0') + ; + *peVar1 = eVar2; + if (**(char **)((int)arg + 0xc) != -5) { + sys_sem_signal((sys_mutex_t *)*(sys_mutex_t *)((int)arg + 8)); + return; + } + return; +} + + + +int err_to_errno(err_t err) + +{ + undefined3 in_register_00002029; + + if ((CONCAT31(in_register_00002029,err) + 0x10U & 0xff) < 0x11) { + return err_to_errno_table[CONCAT31(in_register_00002029,err) * 0x3fffffff]; + } + return 5; +} + + + +void netbuf_delete(netbuf *buf) + +{ + if (buf == (netbuf *)0x0) { + return; + } + if (buf->p != (pbuf *)0x0) { + pbuf_free(buf->p); + buf->ptr = (pbuf *)0x0; + buf->p = (pbuf *)0x0; + } + memp_free(MEMP_NETBUF,buf); + return; +} + + + +void * netbuf_alloc(netbuf *buf,u16_t size) + +{ + pbuf *ppVar1; + void *pvVar2; + + if (buf == (netbuf *)0x0) { + return (void *)0x0; + } + if (buf->p != (pbuf *)0x0) { + pbuf_free(buf->p); + } + ppVar1 = pbuf_alloc(PBUF_TRANSPORT,size,PBUF_RAM); + buf->p = ppVar1; + if (ppVar1 == (pbuf *)0x0) { + pvVar2 = (void *)0x0; + } + else { + buf->ptr = ppVar1; + pvVar2 = ppVar1->payload; + } + return pvVar2; +} + + + +void netbuf_free(netbuf *buf) + +{ + if (buf != (netbuf *)0x0) { + if (buf->p != (pbuf *)0x0) { + pbuf_free(buf->p); + } + buf->ptr = (pbuf *)0x0; + buf->p = (pbuf *)0x0; + buf->flags = '\0'; + buf->toport_chksum = 0; + return; + } + return; +} + + + +void icmp_input(pbuf *p,netif *inp) + +{ + ip_hdr *__src; + u32_t uVar1; + uint uVar2; + uint __n; + void *dataptr; + u8_t uVar3; + err_t eVar4; + u16_t uVar5; + undefined3 extraout_var; + undefined2 extraout_var_05; + undefined3 extraout_var_00; + pbuf *p_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + uint uVar6; + short sVar7; + undefined *puVar8; + + __src = ip_data.current_ip4_header; + lwip_stats.icmp.recv = lwip_stats.icmp.recv + 1; + uVar2 = (uint)(ip_data.current_ip4_header)->_v_hl & 0xf; + __n = uVar2 * 4; + if ((__n < 0x14) || (p->len < 4)) { +lenerr: + pbuf_free(p); + lwip_stats.icmp.lenerr = lwip_stats.icmp.lenerr + 1; + } + else { + if (*(char *)p->payload == '\0') goto LAB_2304767c; + if (*(char *)p->payload != '\b') { + lwip_stats.icmp.proterr = lwip_stats.icmp.proterr + 1; + lwip_stats.icmp.drop = lwip_stats.icmp.drop + 1; + goto LAB_2304767c; + } + if (((ip_data.current_iphdr_dest & 0xf0) != 0xe0) && + (uVar3 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_dest,ip_data.current_netif), + CONCAT31(extraout_var,uVar3) == 0)) { + if (p->tot_len < 8) goto lenerr; + uVar5 = inet_chksum_pbuf(p); + if (CONCAT22(extraout_var_05,uVar5) != 0) { + pbuf_free(p); + lwip_stats.icmp.chkerr = lwip_stats.icmp.chkerr + 1; + return; + } + uVar2 = uVar2 << 0x12; + uVar3 = pbuf_add_header(p,__n + 0x8e); + if (CONCAT31(extraout_var_00,uVar3) == 0) { + uVar3 = pbuf_remove_header(p,__n + 0x8e); + if (CONCAT31(extraout_var_04,uVar3) == 0) { +LAB_230475c4: + puVar8 = (undefined *)p->payload; + uVar3 = pbuf_add_header(p,__n); + uVar1 = ip_data.current_iphdr_dest; + if (CONCAT31(extraout_var_03,uVar3) == 0) { + dataptr = p->payload; + *(undefined *)((int)dataptr + 0xc) = (char)ip_data.current_iphdr_dest; + *(undefined *)((int)dataptr + 0xd) = (char)(uVar1 >> 8); + *(undefined *)((int)dataptr + 0xe) = (char)(uVar1 >> 0x10); + *(undefined *)((int)dataptr + 0xf) = (char)(uVar1 >> 0x18); + uVar1 = ip_data.current_iphdr_src; + *(undefined *)((int)dataptr + 0x10) = (char)ip_data.current_iphdr_src; + *(undefined *)((int)dataptr + 0x11) = (char)(uVar1 >> 8); + *(undefined *)((int)dataptr + 0x12) = (char)(uVar1 >> 0x10); + *(undefined *)((int)dataptr + 0x13) = (char)(uVar1 >> 0x18); + *puVar8 = 0; + if (*(ushort *)(puVar8 + 2) < 0xfff8) { + sVar7 = 8; + } + else { + sVar7 = 9; + } + sVar7 = *(ushort *)(puVar8 + 2) + sVar7; + puVar8[2] = (char)sVar7; + puVar8[3] = (char)((ushort)sVar7 >> 8); + *(undefined *)((int)dataptr + 8) = 0xff; + *(undefined *)((int)dataptr + 10) = 0; + *(undefined *)((int)dataptr + 0xb) = 0; + uVar5 = inet_chksum(dataptr,(u16_t)(uVar2 >> 0x10)); + *(undefined *)((int)dataptr + 10) = (char)uVar5; + *(undefined *)((int)dataptr + 0xb) = (char)(uVar5 >> 8); + lwip_stats.icmp.xmit = lwip_stats.icmp.xmit + 1; + ip4_output_if(p,(ip4_addr_t *)&ip_data.current_iphdr_dest,(ip4_addr_t *)0x0,-1,'\0', + '\x01',inp); + } +LAB_2304767c: + pbuf_free(p); + return; + } + } + else { + uVar6 = (uint)p->tot_len + (uVar2 >> 0x10); + if (((uint)p->tot_len <= (uVar6 & 0xffff)) && + (p_00 = pbuf_alloc(PBUF_LINK,(u16_t)(uVar6 * 0x10000 >> 0x10),PBUF_RAM), + p_00 != (pbuf *)0x0)) { + if (__n + 8 <= (uint)p_00->len) { + memcpy(p_00->payload,__src,__n); + uVar3 = pbuf_remove_header(p_00,__n); + if ((CONCAT31(extraout_var_01,uVar3) == 0) && + (eVar4 = pbuf_copy(p_00,p), CONCAT31(extraout_var_02,eVar4) == 0)) { + pbuf_free(p); + p = p_00; + goto LAB_230475c4; + } + } + pbuf_free(p_00); + } + } + } + pbuf_free(p); + lwip_stats.icmp.err = lwip_stats.icmp.err + 1; + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void icmp_dest_unreach(pbuf *p,icmp_dur_type t) + +{ + undefined *dataptr; + u16_t uVar1; + pbuf *p_00; + netif *netif; + void *pvVar2; + ip4_addr_t iStack36; + ip4_addr_t iphdr_src; + + p_00 = pbuf_alloc(PBUF_IP,0x24,PBUF_RAM); + if (p_00 != (pbuf *)0x0) { + dataptr = (undefined *)p_00->payload; + pvVar2 = p->payload; + *dataptr = 3; + dataptr[1] = t; + dataptr[4] = 0; + dataptr[5] = 0; + dataptr[6] = 0; + dataptr[7] = 0; + memcpy((void *)((int)p_00->payload + 8),p->payload,0x1c); + iStack36 = (ip4_addr_t)((ip4_addr_t *)((int)pvVar2 + 0xc))->addr; + netif = ip4_route(&iStack36); + if (netif != (netif *)0x0) { + dataptr[2] = 0; + dataptr[3] = 0; + uVar1 = inet_chksum(dataptr,p_00->len); + dataptr[2] = (char)uVar1; + dataptr[3] = (char)(uVar1 >> 8); + lwip_stats.icmp.xmit = lwip_stats.icmp.xmit + 1; + ip4_output_if(p_00,(ip4_addr_t *)0x0,&iStack36,-1,'\0','\x01',netif); + } + pbuf_free(p_00); + } + return; +} + + + +u8_t * dhcp_server_option_find(u8_t *buf,u16_t len,u8_t option) + +{ + undefined2 in_register_0000202e; + byte *pbVar1; + undefined3 in_register_00002031; + + pbVar1 = buf + CONCAT22(in_register_0000202e,len); + while ((buf < pbVar1 && (*buf != 0xff))) { + if ((uint)*buf == CONCAT31(in_register_00002031,option)) { + return buf; + } + buf = buf + (uint)buf[1] + 2; + } + return (u8_t *)0x0; +} + + + +// WARNING: Type propagation algorithm not settling + +dhcp_client_node * dhcp_client_find_by_ip(uint8_t *ip) + +{ + dhcp_client_node *pdVar1; + void *in_a1; + ip4_addr_t iStack20; + uint32_t ipval; + + memcpy(&iStack20,in_a1,4); + pdVar1 = *(dhcp_client_node **)ip; + while ((pdVar1 != (dhcp_client_node *)0x0 && (iStack20 != (ip4_addr_t)(pdVar1->ipaddr).addr))) { + pdVar1 = pdVar1->next; + } + return pdVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +void dhcp_server_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *recv_addr,u16_t port) + +{ + byte bVar1; + u8_t uVar2; + char *pcVar3; + pbuf *p_to; + u8_t *puVar4; + u32_t n; + u32_t uVar5; + int iVar6; + u16_t len; + undefined4 *puVar7; + dhcp_client_node *pdVar8; + undefined4 *puVar9; + undefined4 *puVar10; + u8_t *buf; + ip_addr_t iStack56; + ip_addr_t addr; + u32_t tmp; + + iStack56 = (ip_addr_t)recv_addr->addr; + if (((p->len < 0x2c) || (p_to = pbuf_alloc(PBUF_TRANSPORT,0x5dc,PBUF_RAM), p_to == (pbuf *)0x0)) + || (p_to->tot_len < p->tot_len)) goto LAB_2304781c; + pbuf_copy(p_to,p); + pbuf_free(p); + pcVar3 = (char *)p_to->payload; + p = p_to; + if (((*pcVar3 != '\x01') || (*(int *)(pcVar3 + 0xec) != 0x63538263)) || + (bVar1 = pcVar3[2], 6 < bVar1)) goto LAB_2304781c; + buf = (u8_t *)(pcVar3 + 0xf0); + len = (u16_t)(((uint)p_to->tot_len - 0xf0) * 0x10000 >> 0x10); + puVar4 = dhcp_server_option_find(buf,len,'5'); + if (puVar4 == (u8_t *)0x0) goto LAB_2304781c; + uVar2 = puVar4[2]; + if (uVar2 == '\x01') { + pdVar8 = *(dhcp_client_node **)((int)arg + 0xc); + while (pdVar8 != (dhcp_client_node *)0x0) { + iVar6 = memcmp(pdVar8->chaddr,pcVar3 + 0x1c,(uint)bVar1); + if (iVar6 == 0) goto LAB_23047970; + pdVar8 = pdVar8->next; + } + puVar4 = dhcp_server_option_find(buf,len,'2'); + if ((puVar4 == (u8_t *)0x0) || + (pdVar8 = dhcp_client_find_by_ip((uint8_t *)((int)arg + 0xc)), + pdVar8 == (dhcp_client_node *)0x0)) { + while (pdVar8 = dhcp_client_find_by_ip((uint8_t *)((int)arg + 0xc)), + pdVar8 != (dhcp_client_node *)0x0) { + n = lwip_htonl(*(u32_t *)((int)arg + 0x18)); + n = n + 1; + uVar5 = lwip_htonl(*(u32_t *)((int)arg + 0x14)); + if (uVar5 < n) { + n = lwip_htonl(*(u32_t *)((int)arg + 0x10)); + } + uVar5 = lwip_htonl(n); + *(u32_t *)((int)arg + 0x18) = uVar5; + } + pdVar8 = (dhcp_client_node *)mem_malloc(0x14); + if (pdVar8 == (dhcp_client_node *)0x0) goto LAB_2304781c; + memcpy(pdVar8->chaddr,pcVar3 + 0x1c,(uint)(byte)pcVar3[2]); + (pdVar8->ipaddr).addr = *(u32_t *)((int)arg + 0x18); + pdVar8->next = *(dhcp_client_node **)((int)arg + 0xc); + *(dhcp_client_node **)((int)arg + 0xc) = pdVar8; + } +LAB_23047970: + pdVar8->lease_end = 0x80510100; + *pcVar3 = '\x02'; + pcVar3[3] = '\0'; + pcVar3[8] = '\0'; + pcVar3[9] = '\0'; + memcpy(pcVar3 + 0x14,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0xed] = -0x7e; + pcVar3[0xec] = 'c'; + pcVar3[0xef] = 'c'; + pcVar3[0x2c] = '\0'; + pcVar3[0x6c] = '\0'; + pcVar3[0xee] = 'S'; + memcpy(pcVar3 + 0x10,&pdVar8->ipaddr,4); + pcVar3[0xf0] = '5'; + pcVar3[0xf1] = '\x01'; + pcVar3[0xf2] = '\x02'; +LAB_230479e0: + pcVar3[0xf3] = '6'; + pcVar3[0xf4] = '\x04'; + memcpy(pcVar3 + 0xf5,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0xf9] = '3'; + pcVar3[0xfa] = '\x04'; + addr = 0x15180; + memcpy(pcVar3 + 0xfb,&addr,4); + pcVar3[0xff] = '\x01'; + pcVar3[0x100] = '\x04'; + memcpy(pcVar3 + 0x101,(void *)(*(int *)((int)arg + 4) + 8),4); + pcVar3[0x105] = '\x06'; + pcVar3[0x106] = '\x04'; + memcpy(pcVar3 + 0x107,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0x10b] = '\x03'; + pcVar3[0x10c] = '\x04'; + memcpy(pcVar3 + 0x10d,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0x111] = -1; + if (0x112 < p_to->tot_len) { + len = 0x112; +LAB_23047a78: + pbuf_realloc(p_to,len); + } + } + else { + if (uVar2 != '\x03') { + if (uVar2 == '\a') { + puVar7 = *(undefined4 **)((int)arg + 0xc); + puVar10 = (undefined4 *)0x0; + while (puVar9 = puVar7, puVar9 != (undefined4 *)0x0) { + iVar6 = memcmp(puVar9 + 1,pcVar3 + 0x1c,(uint)(byte)pcVar3[2]); + puVar7 = (undefined4 *)*puVar9; + if (iVar6 == 0) { + if (*(undefined4 **)((int)arg + 0xc) == puVar9) { + *(undefined4 **)((int)arg + 0xc) = puVar7; + } + else { + *(undefined4 **)puVar10 = puVar7; + } + mem_free(puVar9); + break; + } + puVar7 = (undefined4 *)*puVar7; + puVar10 = puVar9; + } + } + goto LAB_2304781c; + } + pdVar8 = *(dhcp_client_node **)((int)arg + 0xc); + while (pdVar8 != (dhcp_client_node *)0x0) { + iVar6 = memcmp(pdVar8->chaddr,pcVar3 + 0x1c,(uint)bVar1); + if (iVar6 == 0) goto LAB_23047bd2; + pdVar8 = pdVar8->next; + } + puVar4 = dhcp_server_option_find(buf,len,'2'); + if ((puVar4 != (u8_t *)0x0) && + (pdVar8 = dhcp_client_find_by_ip((uint8_t *)((int)arg + 0xc)), + pdVar8 != (dhcp_client_node *)0x0)) { + iVar6 = memcmp(pdVar8->chaddr,pcVar3 + 0x1c,(uint)(byte)pcVar3[2]); + if (iVar6 == 0) { +LAB_23047bd2: + pdVar8->lease_end = 0x80510100; + *pcVar3 = '\x02'; + pcVar3[3] = '\0'; + pcVar3[8] = '\0'; + pcVar3[9] = '\0'; + memcpy(pcVar3 + 0x14,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0xed] = -0x7e; + pcVar3[0xec] = 'c'; + pcVar3[0xef] = 'c'; + pcVar3[0x2c] = '\0'; + pcVar3[0x6c] = '\0'; + pcVar3[0xee] = 'S'; + memcpy(pcVar3 + 0x10,&pdVar8->ipaddr,4); + pcVar3[0xf0] = '5'; + pcVar3[0xf1] = '\x01'; + pcVar3[0xf2] = '\x05'; + goto LAB_230479e0; + } + puts("IP Found, but MAC address is NOT the same\r\n"); + } + *pcVar3 = '\x02'; + pcVar3[3] = '\0'; + pcVar3[8] = '\0'; + pcVar3[9] = '\0'; + memcpy(pcVar3 + 0x14,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0xed] = -0x7e; + pcVar3[0xee] = 'S'; + pcVar3[0xec] = 'c'; + pcVar3[0xef] = 'c'; + pcVar3[0x2c] = '\0'; + pcVar3[0x6c] = '\0'; + memset(pcVar3 + 0x10,0,4); + pcVar3[0xf0] = '5'; + pcVar3[0xf1] = '\x01'; + pcVar3[0xf2] = '\x06'; + pcVar3[0xf3] = '6'; + pcVar3[0xf4] = '\x04'; + memcpy(pcVar3 + 0xf5,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0xf9] = -1; + if (0xfa < p_to->tot_len) { + len = 0xfa; + goto LAB_23047a78; + } + } + iStack56 = (ip_addr_t)0xffffffff; + udp_sendto_if(pcb,p_to,&iStack56,port,*(netif **)((int)arg + 4)); +LAB_2304781c: + pbuf_free(p); + return; +} + + + +err_t dhcp_server_start(netif *netif,ip4_addr_t *start,ip4_addr_t *end) + +{ + udp_pcb *puVar1; + dhcp_server *__s; + + __s = lw_dhcp_server; + while (__s != (dhcp_server *)0x0) { + if (__s->netif == netif) { + (__s->start).addr = start->addr; + (__s->end).addr = end->addr; + (__s->current).addr = start->addr; + return '\0'; + } + __s = __s->next; + } + __s = (dhcp_server *)mem_malloc(0x1c); + if (__s != (dhcp_server *)0x0) { + memset(__s,0,0x1c); + __s->netif = netif; + __s->node_list = (dhcp_client_node *)0x0; + __s->next = lw_dhcp_server; + lw_dhcp_server = __s; + (__s->start).addr = start->addr; + (__s->end).addr = end->addr; + (__s->current).addr = start->addr; + puVar1 = udp_new(); + __s->pcb = puVar1; + if (puVar1 != (udp_pcb *)0x0) { + puVar1->so_options = puVar1->so_options | 0x20; + udp_bind(__s->pcb,&ip_addr_any,0x43); + udp_recv(__s->pcb,dhcp_server_recv,__s); + return '\0'; + } + } + return -1; +} + + + +err_t dhcp_server_stop(netif *netif) + +{ + dhcp_server *pdVar1; + + pdVar1 = lw_dhcp_server; + while( true ) { + if (pdVar1 == (dhcp_server *)0x0) { + printf("[DHCP] [DHCPD] CRITICAL: no dhcp_server instance found\r\n"); + return -6; + } + if (pdVar1->netif == netif) break; + pdVar1 = pdVar1->next; + } + if (pdVar1->pcb != (udp_pcb *)0x0) { + udp_remove(pdVar1->pcb); + } + lw_dhcp_server = (dhcp_server *)0x0; + mem_free(pdVar1); + return '\0'; +} + + + +void dhcpd_start(netif *netif) + +{ + err_t eVar1; + char *__format; + undefined3 extraout_var; + ip4_addr_t *piVar2; + ip4_addr_t iStack60; + ip4_addr_t ip_start; + ip4_addr_t ip_end; + char str_tmp [20]; + + dhcp_stop(netif); + set_if(netif,"192.168.169.1","0.0.0.0","255.255.255.0"); + netif_set_up(netif); + memcpy(&ip_end,"192.168.169.1",0xe); + __format = strchr((char *)&ip_end,0x2e); + if (((__format == (char *)0x0) || (__format = strchr(__format + 1,0x2e), __format == (char *)0x0)) + || (__format = strchr(__format + 1,0x2e), __format == (char *)0x0)) { + piVar2 = &ip_end; + __format = "[DHCP] DHCPD_SERVER_IP: %s error!\r\n"; + } + else { + sprintf(__format + 1,"%d",2); + ip4addr_aton((char *)&ip_end,&iStack60); + printf("[DHCP] ip_start: [%s]\r\n",&ip_end); + sprintf(__format + 1,"%d",0xfe); + ip4addr_aton((char *)&ip_end,&ip_start); + printf("[DHCP] ip_start: [%s]\r\n",&ip_end); + eVar1 = dhcp_server_start(netif,&iStack60,&ip_start); + piVar2 = (ip4_addr_t *)CONCAT31(extraout_var,eVar1); + if (piVar2 == (ip4_addr_t *)0x0) { + return; + } + __format = "[DHCP] dhcp_server_start res: %d.\r\n"; + } + printf(__format,piVar2); + return; +} + + + +void tcpc_entry(void *arg) + +{ + int iVar1; + int counter_shared; + char *__s; + int s; + int iVar2; + ssize_t sVar3; + char *__format; + undefined4 uStack68; + int flag; + sockaddr_in addr; + + iVar1 = counter_shared; + counter_shared = counter_shared + 1; + printf("[TCPC] [THREAD] [%d] host is %s, counter is %d\r\n",iVar1,arg,iVar1); + __s = (char *)pvPortMalloc(0x400); + if (__s == (char *)0x0) { + printf("[TCPC] [THREAD] [%d] [%d] NO mem for holding data\r\n",iVar1,counter_shared); + } + else { + s = lwip_socket(2,1,6); + if (s < 0) { + printf("[TCPC] [THREAD] [%d] [%d] create socket failed, ret is sock %d!\r\n",iVar1, + counter_shared,s); + } + else { + flag._1_1_ = '\x02'; + flag._2_2_ = lwip_htons(7000); + ipaddr_addr((char *)arg); + iVar2 = lwip_connect(s,(sockaddr *)&flag,0x10); + if (iVar2 < 0) { + printf("[TCPC] [THREAD] [%d] [%d] Connect failed!\n",iVar1,counter_shared); + } + else { + printf("[TCPC] [THREAD] [%d] [%d] Connect to iperf server successful!\n",iVar1, + counter_shared); + uStack68 = 1; + lwip_setsockopt(s,6,1,&uStack68,4); + memset(__s,0,0x400); + iVar2 = 0; + while( true ) { + snprintf(__s,0x400,"Data Seq %d",iVar2); + sVar3 = lwip_write(s,__s,0x400); + if (sVar3 < 0) break; + printf("[TCPC] [THREAD] [%d] [%d] send success with ret %d, %s\r\n",iVar1,counter_shared, + sVar3,__s); + sVar3 = lwip_read(s,__s,0x400); + if (sVar3 < 0) { + __format = "[TCPC] [THREAD] [%d] [%d] recv failed with ret %d\r\n"; + goto LAB_23047f9a; + } + printf("[TCPC] [THREAD] [%d] [%d] recv success with ret %d, %s\r\n",iVar1,counter_shared, + sVar3,__s); + vTaskDelay(1000); + iVar2 = iVar2 + 1; + } + __format = "[TCPC] [THREAD] [%d] [%d] send failed with ret %d\r\n"; +LAB_23047f9a: + printf(__format,iVar1,counter_shared,sVar3); + } + lwip_close(s); + } + vPortFree(__s); + } + vPortFree(arg); + return; +} + + + +void tcpclient_cmd(char *buf,int len,int argc,char **argv) + +{ + size_t sVar1; + char *__dest; + char acStack48 [4]; + char names [32]; + + if (argc == 2) { + sVar1 = strlen(argv[1]); + __dest = (char *)pvPortMalloc(sVar1 + 4); + if (__dest == (char *)0x0) { + printf("[TCPC] run out of mem for host alloc\r\n"); + } + strcpy(__dest,argv[1]); + counter_4093 = counter_4093 + '\x01'; + snprintf(acStack48,0x20,"tcp%u"); + aos_task_new(acStack48,tcpc_entry,__dest,0x800); + } + else { + printf("[TCPC] host IP address is required. Ex. 192.168.1.1\r\n"); + } + return; +} + + + +int network_netutils_tcpclinet_cli_register(void) + +{ + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void TCP_Server(void *pvParameters) + +{ + uint *puVar1; + u16_t uVar2; + void *__s; + uint uVar3; + int iVar4; + char *__format; + TickType_t TVar5; + int iVar6; + size_t size; + ssize_t sVar7; + undefined2 extraout_var; + TickType_t *pTVar8; + int *piVar9; + uint s; + int iVar10; + uint uVar11; + uint s_00; + uint *puVar12; + socklen_t sStack208; + uint32_t client_addrlen; + int yes; + _types_fd_set fdsr; + timeval tv; + sockaddr_in server_addr; + sockaddr_in client_addr; + int connect_time [5]; + int time_diff [5]; + int time_last [5]; + int client_fd [5]; + + client_addrlen = 1; + __s = pvPortMalloc(0x2800); + memset(__s,0,0x2800); + memset(time_last + 4,0,0x14); + memset(connect_time + 4,0,0x14); + memset(time_diff + 4,0,0x14); + memset(client_addr.sin_zero + 4,0,0x14); + uVar3 = lwip_socket(2,1,6); + s_00 = uVar3 >> 0x1f; + if ((int)uVar3 < 0) { + printf("socket creat failed\r\n"); + vPortFree(__s); + vTaskDelete((TaskHandle_t)0x0); + } + else { + printf("socket:%d\r\n",0); + } + iVar4 = lwip_setsockopt(s_00,0xfff,4,&client_addrlen,4); + if (iVar4 == -1) { + __format = "setsockopt failed\r\n"; + } + else { + tv._13_1_ = 2; + tv._14_2_ = lwip_htons(0x141e); + server_addr._0_4_ = lwip_htonl(0); + iVar4 = lwip_bind(s_00,(sockaddr *)&tv.field_0xc,0x10); + if (iVar4 < 0) { + __format = "bind failed\r\n"; + } + else { + iVar4 = lwip_listen(s_00,5); + if (iVar4 < 0) { + __format = "listen failed\r\n"; + } + else { + printf("We are waiting a connection on port 5150.\r\n"); + printf("Listen(正在监听)...\r\n"); + sStack208 = 0x10; + TVar5 = xTaskGetTickCount(); + iVar4 = 0; + do { + *(TickType_t *)((int)time_diff + iVar4 + 0x10) = TVar5; + iVar6 = atoi((char *)pvParameters); + *(int *)(client_addr.sin_zero + iVar4 + 4) = iVar6; + iVar4 = iVar4 + 4; + } while (iVar4 != 0x14); + iVar4 = 0; + uVar3 = s_00; +LAB_23048202: + iVar6 = 0; + do { + *(undefined *)((int)&yes + iVar6) = 0; + iVar6 = iVar6 + 1; + } while (iVar6 != 8); + fdsr.fds_bits[1] = 1; + tv.tv_sec._0_4_ = 0; + yes = yes | 1 << s_00; + tv.tv_sec._4_4_ = 0; + iVar6 = 0; + do { + puVar1 = (uint *)((int)time_last + iVar6 + 0x10); + s = *puVar1; + if (s != 0) { + (&yes)[s >> 5] = 1 << (s & 0x1f) | (&yes)[s >> 5]; + TVar5 = xTaskGetTickCount(); + pTVar8 = (TickType_t *)((int)time_diff + iVar6 + 0x10); + s = TVar5 - *pTVar8; + *(uint *)((int)connect_time + iVar6 + 0x10) = s; + if (999 < s) { + *pTVar8 = TVar5; + piVar9 = (int *)(client_addr.sin_zero + iVar6 + 4); + iVar10 = *piVar9; + *piVar9 = iVar10 + -1; + if (iVar10 + -1 < 1) { + iVar4 = iVar4 + -1; + lwip_close(*puVar1); + iVar10 = atoi((char *)pvParameters); + uVar11 = *puVar1; + *puVar1 = 0; + *piVar9 = iVar10; + s = uVar11 >> 5; + (&yes)[s] = ~(1 << (uVar11 & 0x1f)) & (&yes)[s]; + printf("disconnect becase time out\r\n"); + } + } + } + iVar6 = iVar6 + 4; + } while (iVar6 != 0x14); + iVar6 = lwip_select(uVar3 + 1,(_types_fd_set *)&yes,(_types_fd_set *)0x0, + (_types_fd_set *)0x0,(timeval *)(fdsr.fds_bits + 1)); + if (-1 < iVar6) { + if (iVar6 != 0) { + puVar12 = (uint *)(time_last + 4); + iVar6 = 0; + puVar1 = puVar12; + do { + s = *puVar1; + if ((s != s_00) && ((1 << (s & 0x1f) & (&yes)[s >> 5]) != 0)) { + TVar5 = xTaskGetTickCount(); + memset(__s,0,0x2800); + size = lwip_recv(*puVar1,__s,0x2800,0); + if ((int)size < 1) { + printf("recv failed:%d\r\n",size); + lwip_close(*puVar1); + iVar10 = atoi((char *)pvParameters); + *(int *)(client_addr.sin_zero + iVar6 * 4 + 4) = iVar10; + s = *puVar1 >> 5; + (&yes)[s] = ~(1 << (*puVar1 & 0x1f)) & (&yes)[s]; + } + else { + iVar10 = atoi((char *)pvParameters); + *(int *)(client_addr.sin_zero + iVar6 * 4 + 4) = iVar10; + time_diff[iVar6 + 4] = TVar5; + printf("We successfully received %d bytes from %d client\r\n",size,iVar6); + printf("%s\r\n",__s); + sVar7 = lwip_send(*puVar1,__s,size,0); + if (0 < sVar7) { + printf("We successfully send %d bytes to %d client\r\n",sVar7,iVar6); + printf("\r\n"); + goto LAB_2304837e; + } + printf("send failed\r\n",sVar7); + lwip_close(*puVar1); + iVar10 = atoi((char *)pvParameters); + s = *puVar1; + *(int *)(client_addr.sin_zero + iVar6 * 4 + 4) = iVar10; + uVar11 = s >> 5; + (&yes)[uVar11] = ~(1 << (s & 0x1f)) & (&yes)[uVar11]; + } + *puVar1 = 0; + iVar4 = iVar4 + -1; + } +LAB_2304837e: + iVar6 = iVar6 + 1; + puVar1 = puVar1 + 1; + } while (iVar6 != 5); + if ((yes & 1 << s_00) != 0) { + s = lwip_accept(s_00,(sockaddr *)(server_addr.sin_zero + 4),&sStack208); + if ((int)s < 1) { + printf("accept failed\r\n"); + } + else { + printf("new_sock:%d\r\n",s); + __format = ip4addr_ntoa((ip4_addr_t *)&client_addr); + uVar2 = lwip_htons(server_addr.sin_zero._6_2_); + printf("We successfully got a connection from %s:%d\r\n",__format, + CONCAT22(extraout_var,uVar2)); + printf("We are waiting to receive data\r\n"); + if (iVar4 < 5) { + iVar6 = 0; + do { + if (*puVar12 == 0) { + TVar5 = xTaskGetTickCount(); + time_diff[iVar6 + 4] = TVar5; + iVar10 = atoi((char *)pvParameters); + *(int *)(client_addr.sin_zero + iVar6 * 4 + 4) = iVar10; + time_last[iVar6 + 4] = s; + if ((int)uVar3 < (int)s) { + uVar3 = s; + } + iVar4 = iVar4 + 1; + printf("amount:%d\r\n",iVar4); + break; + } + iVar6 = iVar6 + 1; + puVar12 = puVar12 + 1; + } while (iVar6 != 5); + } + else { + printf("Max connections arrived!\r\n"); + lwip_send(s,&DAT_23086a6c,4,0); + lwip_close(s); + } + } + } + } + goto LAB_23048202; + } + __format = "select failed\r\n"; + } + } + } + printf(__format); + vPortFree(__s); + lwip_close(s_00); + vTaskDelete((TaskHandle_t)0x0); + return; +} + + + +void cmd_tcp_server(char *buf,int len,int argc,char **argv) + +{ + if (argc != 2) { + printf("Please Input Parameter!\r\n"); + return; + } + xTaskCreate(TCP_Server,"TCP Server",0x400,argv[1],0x14,(TaskHandle_t *)0x0); + return; +} + + + +int network_netutils_tcpserver_cli_register(void) + +{ + return 0; +} + + + +void iperf_server_udp_entry(char *name) + +{ + size_t sVar1; + char *__dest; + + sVar1 = strlen(name); + __dest = (char *)pvPortMalloc(sVar1 + 1); + strcpy(__dest,name); + aos_task_new("ipus",iperf_server_udp,__dest,0x1000); + return; +} + + + +void iperf_client_udp_entry(char *name) + +{ + size_t sVar1; + char *__dest; + + sVar1 = strlen(name); + __dest = (char *)pvPortMalloc(sVar1 + 4); + strcpy(__dest,name); + aos_task_new("ipu",iperf_client_udp,__dest,0x1000); + return; +} + + + +void iperf_server_entry(char *name) + +{ + size_t sVar1; + char *__dest; + + sVar1 = strlen(name); + __dest = (char *)pvPortMalloc(sVar1 + 4); + strcpy(__dest,name); + aos_task_new("ips",iperf_server,__dest,0x1000); + return; +} + + + +void iperf_client_tcp_entry(char *name) + +{ + size_t sVar1; + char *__dest; + + sVar1 = strlen(name); + __dest = (char *)pvPortMalloc(sVar1 + 4); + strcpy(__dest,name); + aos_task_new("ipc",iperf_client_tcp,__dest,0x1000); + return; +} + + + +// WARNING: Control flow encountered bad instruction data + +void iperf_server_udp(void *arg) + +{ + err_t eVar1; + udp_pcb *pcb; + undefined3 extraout_var; + ip_addr_t iStack84; + ip_addr_t source_ip; + iperf_server_udp_ctx context; + + if (arg == (void *)0x0) { + vAssertCalled(); + } + pcb = udp_new(); + if (pcb == (udp_pcb *)0x0) { + printf("Create UDP Control block failed!\r\n"); + } + else { + iStack84 = (ip_addr_t)ipaddr_addr((char *)arg); + eVar1 = udp_bind(pcb,&iStack84,0x1389); + if (CONCAT31(extraout_var,eVar1) == 0) { + printf("bind UDP socket successfully!\r\n"); + memset(&source_ip,0,0x40); + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); + } + printf("Bind failed!\r\n"); + udp_remove(pcb); + } + vPortFree(arg); + return; +} + + + +// WARNING: Control flow encountered bad instruction data + +void iperf_server_udp_recv_fn(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port) + +{ + char speed [32]; + + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +// WARNING: Control flow encountered bad instruction data + +void iperf_client_udp(void *arg) + +{ + sockaddr_in laddr; + sockaddr_in raddr; + char speed [64]; + + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +// WARNING: Control flow encountered bad instruction data + +void iperf_server(void *arg) + +{ + uint32_t sin_size; + int flag; + sockaddr_in server_addr; + sockaddr_in client_addr; + char speed [32]; + + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +// WARNING: Control flow encountered bad instruction data + +void iperf_client_tcp(void *arg) + +{ + int flag; + sockaddr_in addr; + char speed [32]; + + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +void ipus_test_cmd(char *buf,int len,int argc,char **argv) + +{ + char *name; + + if (argc == 1) { + printf("[NET] [IPC] [IPUS] Connecting with default address 0.0.0.0\r\n"); + name = "0.0.0.0"; + } + else { + if (argc != 2) { + printf("[NET] [IPC] [IPUS] illegal address\r\n"); + return; + } + name = argv[1]; + } + iperf_server_udp_entry(name); + return; +} + + + +void ipu_test_cmd(char *buf,int len,int argc,char **argv) + +{ + char *name; + + if (argc == 1) { + printf("[NET] [IPC] [IPU] Connecting with default address 192.168.11.1\r\n"); + name = "192.168.11.1"; + } + else { + if (argc != 2) { + printf("[NET] [IPC] [IPU] illegal address\r\n"); + return; + } + name = argv[1]; + } + iperf_client_udp_entry(name); + return; +} + + + +void ipc_test_cmd(char *buf,int len,int argc,char **argv) + +{ + char *name; + + if (argc == 1) { + printf("[NET] [IPC] [IPC] Connecting with default address 192.168.11.1\r\n"); + name = "192.168.11.1"; + } + else { + if (argc != 2) { + printf("[NET] [IPC] [IPC] illegal address\r\n"); + return; + } + name = argv[1]; + } + iperf_client_tcp_entry(name); + return; +} + + + +void ips_test_cmd(char *buf,int len,int argc,char **argv) + +{ + char *name; + + if (argc == 1) { + puts("[NET] [IPC] [IPS] Starting iperf server on 0.0.0.0\r\n"); + name = "192.168.11.1"; + } + else { + if (argc != 2) { + printf("[NET] [IPC] [IPS] illegal address\r\n"); + return; + } + name = argv[1]; + } + iperf_server_entry(name); + return; +} + + + +int network_netutils_iperf_cli_register(void) + +{ + return 0; +} + + + +void cmd_netstat(char *buf,int len,int argc,char **argv) + +{ + tcpip_callback(stats_netstat,(void *)0x0); + return; +} + + + +int network_netutils_netstat_cli_register(void) + +{ + return 0; +} + + + +void ping_usage(void) + +{ + printf("%s"); + return; +} + + + +void ping_free(void *arg) + +{ + u16_t uVar1; + undefined2 extraout_var; + utils_list_hdr *node; + utils_memp_pool_t *pool; + + while (*(int *)((int)arg + 0x20) != 0) { + uVar1 = lwip_htons(*(u16_t *)(*(int *)((int)arg + 0x20) + 4)); + printf("The sequence number %d timed out\r\n",CONCAT22(extraout_var,uVar1)); + pool = *(utils_memp_pool_t **)((int)arg + 0x18); + node = utils_list_pop_front((utils_list *)((int)arg + 0x20)); + utils_memp_free(pool,node); + *(char *)((int)arg + 0x12) = *(char *)((int)arg + 0x12) + -1; + } + raw_remove(*(raw_pcb **)((int)arg + 0x1c)); + utils_memp_deinit(*(utils_memp_pool_t **)((int)arg + 0x18)); + vPortFree(arg); + return; +} + + + +void ping_timeout(void *arg) + +{ + undefined2 uVar1; + utils_memp_pool_t *pool; + undefined *dataptr; + u16_t n; + u16_t length; + utils_list_hdr *list_hdr; + pbuf *p; + utils_list_hdr *puVar2; + TickType_t TVar3; + undefined2 extraout_var; + uint uVar4; + uint uVar5; + + while (*(int *)((int)arg + 0x20) != 0) { + TVar3 = sys_now(); + if (TVar3 - *(int *)(*(int *)((int)arg + 0x20) + 8) <= (uint)*(ushort *)((int)arg + 0x10)) + break; + length = lwip_htons(*(u16_t *)(*(int *)((int)arg + 0x20) + 4)); + printf("The sequence number %d timed out\r\n",CONCAT22(extraout_var,length)); + pool = *(utils_memp_pool_t **)((int)arg + 0x18); + list_hdr = utils_list_pop_front((utils_list *)((int)arg + 0x20)); + utils_memp_free(pool,list_hdr); + *(char *)((int)arg + 0x12) = *(char *)((int)arg + 0x12) + -1; + } + if (*(char *)((int)arg + 0x12) == '\n') { + pool = *(utils_memp_pool_t **)((int)arg + 0x18); + list_hdr = utils_list_pop_front((utils_list *)((int)arg + 0x20)); + utils_memp_free(pool,list_hdr); + *(char *)((int)arg + 0x12) = *(char *)((int)arg + 0x12) + -1; + } + uVar5 = (uint)*(ushort *)((int)arg + 10) + 8; + length = (u16_t)(uVar5 * 0x10000 >> 0x10); + p = pbuf_alloc(PBUF_IP,length,PBUF_RAM); + if (p != (pbuf *)0x0) { + if ((p->len == p->tot_len) && (p->next == (pbuf *)0x0)) { + dataptr = (undefined *)p->payload; + list_hdr = (utils_list_hdr *)utils_memp_malloc(*(utils_memp_pool_t **)((int)arg + 0x18)); + if (list_hdr != (utils_list_hdr *)0x0) { + *dataptr = 8; + dataptr[1] = 0; + dataptr[2] = 0; + dataptr[3] = 0; + uVar1 = *(undefined2 *)((int)arg + 0xe); + dataptr[4] = (char)uVar1; + dataptr[5] = (char)((ushort)uVar1 >> 8); + n = (u16_t)(((uint)*(ushort *)((int)arg + 0xc) + 1) * 0x10000 >> 0x10); + *(u16_t *)((int)arg + 0xc) = n; + n = lwip_htons(n); + dataptr[6] = (char)n; + dataptr[7] = (char)(n >> 8); + uVar4 = 0; + while (uVar4 < (uVar5 & 0xffff) - 8) { + dataptr[uVar4 + 8] = (char)uVar4; + uVar4 = uVar4 + 1; + } + length = inet_chksum(dataptr,length); + dataptr[2] = (char)length; + dataptr[3] = (char)(length >> 8); + *(undefined2 *)&list_hdr[1].next = *(undefined2 *)(dataptr + 6); + raw_sendto(*(raw_pcb **)((int)arg + 0x1c),p,(ip_addr_t *)((int)arg + 0x14)); + puVar2 = (utils_list_hdr *)sys_now(); + list_hdr[2].next = puVar2; + utils_list_push_back((utils_list *)((int)arg + 0x20),list_hdr); + *(char *)((int)arg + 0x12) = *(char *)((int)arg + 0x12) + '\x01'; + *(int *)((int)arg + 4) = *(int *)((int)arg + 4) + 1; + } + } + pbuf_free(p); + } + sys_timeout((uint)*(ushort *)((int)arg + 8),ping_timeout,arg); + if (*(int *)((int)arg + 4) == *(int *)arg) { + sys_untimeout(ping_timeout,arg); + sys_timeout((uint)*(ushort *)((int)arg + 0x10),ping_free,arg); + return; + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: echo_hdr +// WARNING: Could not reconcile some variable overlaps + +u8_t ping_recv(void *arg,raw_pcb *pcb,pbuf *p,ip_addr_t *addr) + +{ + byte bVar1; + ushort uVar2; + void **node; + void **ppvVar3; + u16_t uVar4; + char *pcVar5; + undefined2 extraout_var; + TickType_t TVar6; + byte bStack24; + byte bStack23; + icmp_echo_hdr echo_hdr; + + if (((uint)p->tot_len != (uint)*(ushort *)((int)arg + 10) + 0x1c) || + (*(u32_t *)((int)arg + 0x14) != addr->addr)) { + return '\0'; + } + memcpy(&bStack24,(void *)((int)p->payload + 0x14),8); + bStack24 = bStack24 | bStack23; + if (bStack24 == 0) { + if ((((echo_hdr._0_2_ == *(short *)((int)arg + 0xe)) && (*(char *)((int)arg + 0x12) != '\0')) && + (node = *(void ***)((int)arg + 0x20), node != (void **)0x0)) && + (*(ushort *)(node + 1) <= echo_hdr.chksum)) { + if (echo_hdr.chksum == *(ushort *)(node + 1)) { + *(void **)((int)arg + 0x20) = *node; + } + else { + do { + ppvVar3 = node; + node = (void **)*ppvVar3; + if (node == (void **)0x0) { + return '\0'; + } + } while (*(ushort *)(node + 1) < echo_hdr.chksum); + if (echo_hdr.chksum != *(ushort *)(node + 1)) { + return '\0'; + } + if (node == *(void ***)((int)arg + 0x24)) { + *(void ***)((int)arg + 0x24) = ppvVar3; + } + node = (void **)*ppvVar3; + *ppvVar3 = *node; + } + uVar2 = p->tot_len; + pcVar5 = ip4addr_ntoa((ip4_addr_t *)((int)arg + 0x14)); + uVar4 = lwip_htons(echo_hdr.chksum); + bVar1 = *(byte *)((int)p->payload + 8); + TVar6 = sys_now(); + printf("%d bytes from %s: icmp_seq=%d ttl=%d time=%lu ms\r\n ",(uint)uVar2,pcVar5, + CONCAT22(extraout_var,uVar4),(uint)bVar1,TVar6 - (int)node[2]); + utils_memp_free(*(utils_memp_pool_t **)((int)arg + 0x18),node); + *(char *)((int)arg + 0x12) = *(char *)((int)arg + 0x12) + -1; + pbuf_free(p); + bStack24 = 1; + } + } + else { + bStack24 = 0; + } + return (u8_t)bStack24; +} + + + +ping_var * ping_api_init(u16_t interval,u16_t size,u32_t count,u16_t timeout,ip_addr_t *dest) + +{ + ping_var *recv_arg; + int iVar1; + char *__format; + raw_pcb *pcb; + + recv_arg = (ping_var *)pvPortMalloc(0x28); + if (recv_arg == (ping_var *)0x0) { + printf("mem malloc failed!\r\n"); + } + else { + recv_arg->total_count = count; + recv_arg->data_size = size; + recv_arg->requests_count = 0; + recv_arg->interval = interval; + recv_arg->seq_num = 0; + iVar1 = bl_rand(); + recv_arg->id = (u16_t)iVar1; + recv_arg->timeout = timeout; + recv_arg->node_num = '\0'; + (recv_arg->dest).addr = dest->addr; + iVar1 = utils_memp_init(&recv_arg->pool,0xc,10,'\x04'); + if (iVar1 == 0) { + utils_list_init(&recv_arg->req_list); + pcb = raw_new('\x01'); + if (pcb != (raw_pcb *)0x0) { + recv_arg->pcb = pcb; + raw_recv(pcb,ping_recv,recv_arg); + raw_bind(pcb,&ip_addr_any); + sys_timeout(0,ping_timeout,recv_arg); + return recv_arg; + } + __format = "pcb null, maybe the pcb pool or sys_timeout pool is empty\r\n"; + } + else { + __format = "pool_alloc failed\n"; + } + printf(__format); + printf("ping_init failed\r\n"); + vPortFree(recv_arg); + } + return recv_arg; +} + + + +// WARNING: Type propagation algorithm not settling + +void ping_cmd(char *buf,int len,int argc,char **argv) + +{ + uint uVar1; + int iVar2; + hostent *phVar3; + char *__format; + char *pcVar4; + uint uVar5; + uint uVar6; + u32_t count; + char *pcStack84; + getopt_env_t getopt_env; + + uVar1 = 5000; + utils_getopt_init((getopt_env_t *)&pcStack84,0); + count = 0; + uVar6 = 0x20; + uVar5 = 1000; + do { + while( true ) { + while( true ) { + while( true ) { + iVar2 = utils_getopt((getopt_env_t *)&pcStack84,argc,argv,":i:s:c:W:h"); + if (iVar2 == -1) { + if (getopt_env.optarg + 1 == (char *)argc) { + phVar3 = lwip_gethostbyname(argv[(int)getopt_env.optarg]); + if (phVar3 == (hostent *)0x0) { + printf("Failed to resolve domain name\r\n"); + return; + } + ping_api_init((u16_t)uVar5,(u16_t)uVar6,count,(u16_t)uVar1, + (ip_addr_t *)((ip_addr_t *)phVar3->h_addr_list)->addr); + return; + } + printf("Need target address\r\n"); + goto LAB_23049676; + } + if (iVar2 != 99) break; + count = atoi(pcStack84); + } + if (iVar2 < 100) break; + if (iVar2 == 0x69) { + uVar5 = atoi(pcStack84); + uVar5 = uVar5 & 0xffff; + } + else { + if (iVar2 == 0x73) { + uVar6 = atoi(pcStack84); + uVar6 = uVar6 & 0xffff; + } + else { + if (iVar2 == 0x68) goto LAB_23049676; + } + } + } + if (iVar2 == 0x3f) { + pcVar4 = *argv; + __format = "%s: unknown option %c\r\n"; + goto LAB_23049664; + } + if (iVar2 != 0x57) break; + uVar1 = atoi(pcStack84); + uVar1 = uVar1 & 0xffff; + } + } while (iVar2 != 0x3a); + pcVar4 = *argv; + __format = "%s: %c requires an argument\r\n"; +LAB_23049664: + printf(__format,pcVar4,getopt_env.opterr); +LAB_23049676: + ping_usage(); + return; +} + + + +int network_netutils_ping_cli_register(void) + +{ + return 0; +} + + + +int dirent_type(void *addr) + +{ + int iVar1; + byte bVar2; + + bVar2 = *(byte *)((int)addr + 3) & 7; + if ((*(byte *)((int)addr + 3) & 7) == 0) { + iVar1 = 0; + } + else { + iVar1 = 2; + if ((bVar2 != 2) && (iVar1 = 3, bVar2 == 1)) { + return 1; + } + } + return iVar1; +} + + + +uint32_t dirent_hardfh(void *addr) + +{ + uint uVar1; + + uVar1 = *(uint *)addr; + return uVar1 << 0x18 | uVar1 >> 0x18 & 0xfffffff0 | (uVar1 & 0xff00) << 8 | uVar1 >> 8 & 0xff00; +} + + + +uint32_t dirent_childaddr(void *addr) + +{ + uint uVar1; + + uVar1 = *(uint *)((int)addr + 4); + return uVar1 << 0x18 | uVar1 >> 0x18 & 0xfffffff0 | (uVar1 & 0xff00) << 8 | uVar1 >> 8 & 0xff00; +} + + + +uint32_t dirent_size(void *addr) + +{ + uint uVar1; + + uVar1 = *(uint *)((int)addr + 8); + return uVar1 << 0x18 | uVar1 >> 0x18 | (uVar1 & 0xff00) << 8 | uVar1 >> 8 & 0xff00; +} + + + +int romfs_close(file_t *fp) + +{ + fp->f_arg = (void *)0x0; + fp->offset = 0; + return -1; +} + + + +int romfs_ioctl(file_t *fp,int cmd,ulong arg) + +{ + size_t sVar1; + uint32_t uVar2; + int iVar3; + void *pvVar4; + + iVar3 = -2; + if (((fp != (file_t *)0x0) && (arg != 0)) && (iVar3 = -3, cmd == 1)) { + pvVar4 = fp->f_arg; + sVar1 = strlen((char *)((int)pvVar4 + 0x10)); + *(size_t *)arg = (sVar1 + 0x10 & 0xfffffff0) + 0x10 + (int)pvVar4; + uVar2 = dirent_size(fp->f_arg); + *(uint32_t *)(arg + 4) = uVar2; + return 0; + } + return iVar3; +} + + + +ssize_t romfs_read(file_t *fp,char *buf,size_t length) + +{ + size_t sVar1; + uint32_t uVar2; + uint uVar3; + void *__src; + + __src = fp->f_arg; + sVar1 = strlen((char *)((int)__src + 0x10)); + uVar2 = dirent_size(fp->f_arg); + uVar3 = fp->offset; + if (uVar3 < uVar2) { + __src = (void *)((sVar1 + 0x10 & 0xfffffff0) + 0x10 + uVar3 + (int)__src); + if (uVar3 + length < uVar2) { + memcpy(buf,__src,length); + fp->offset = fp->offset + length; + } + else { + length = uVar2 - uVar3; + memcpy(buf,__src,length); + fp->offset = uVar2; + } + } + else { + length = 0; + } + return length; +} + + + +undefined4 file_info(char *param_1,char **param_2,char **param_3) + +{ + char *addr; + char *pcVar1; + char *pcVar2; + size_t __n; + int iVar3; + uint32_t uVar4; + TickType_t TVar5; + + addr = *param_2; + pcVar1 = *param_3; + __n = strlen(param_1); + if (__n < 0x41) { + if (romfs_root == addr) { + __n = strlen(addr + 0x10); + addr = addr + (__n + 0x10 & 0xfffffff0) + 0x50; + } + do { + iVar3 = dirent_type(addr); + if (iVar3 == 1) { + __n = strlen(param_1); + iVar3 = memcmp(param_1,addr + 0x10,__n); + if ((iVar3 == 0) && (__n = strlen(param_1), addr[__n + 0x10] == '\0')) { + uVar4 = dirent_hardfh(addr); + pcVar2 = romfs_root; + if (uVar4 == 0) goto LAB_230498ec; +LAB_230498ea: + pcVar1 = pcVar2 + uVar4; +LAB_230498ec: + *param_2 = addr; + *param_3 = pcVar1; + return 0; + } + } + else { + if (iVar3 == 2) { + __n = strlen(param_1); + iVar3 = memcmp(param_1,addr + 0x10,__n); + if ((iVar3 == 0) && (__n = strlen(param_1), pcVar2 = romfs_root, addr[__n + 0x10] == '\0') + ) { + uVar4 = dirent_hardfh(addr); + goto LAB_230498ea; + } + } + else { + if (iVar3 != 0) { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + iVar3 = dirent_type(addr); + bl_printk("[%10u][%s: %s:%4d] addr_start = %p, dirent_type(addr_start) = %d\r\n",TVar5, + &DAT_23072bcc,"bl_romfs.c",0xe6,addr,iVar3); + log_buf_out("bl_romfs.c",0xe7,addr,8,LOG_BUF_OUT_DATA_TYPE_HEX); + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] unknow the dirent_type.\r\n",&DAT_23072bcc,"bl_romfs.c", + 0xe8); + return 0xffffffff; + } + } + } + pcVar2 = romfs_root; + uVar4 = dirent_hardfh(addr); + addr = pcVar2 + uVar4; + } while (addr < pcVar1); + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] start >= end, not found path = %s, addr_start = %p, addr_end = %p\r\n" + ,&DAT_23081ce8,"bl_romfs.c",0xef,param_1,addr,pcVar1); + } + return 0xffffffff; +} + + + +int romfs_closedir(file_t *fp,aos_dir_t *dir) + +{ + if (dir != (aos_dir_t *)0x0) { + aos_free(dir); + return 0; + } + return -1; +} + + + +off_t romfs_lseek(file_t *fp,off_t off,int whence) + +{ + size_t sVar1; + uint32_t uVar2; + + if (fp == (file_t *)0x0) { + return -1; + } + uVar2 = dirent_size(fp->f_arg); + if (whence == 0) { + if (off < 0) { + printf("not support whence.\r\n"); + return -2; + } + } + else { + if (whence == 2) { + sVar1 = uVar2; + if (0 < off) { + printf("not support whence.\r\n"); + return -3; + } + } + else { + if (whence != 1) { + printf("not support whence.\r\n"); + return -4; + } + sVar1 = fp->offset; + } + off = off + sVar1; + if (off < 0) goto LAB_23049a8a; + } + if ((uint)off <= uVar2) { + fp->offset = off; + return off; + } +LAB_23049a8a: + printf("not support whence.\r\n"); + return -5; +} + + + +aos_dirent_t * romfs_readdir(file_t *fp,aos_dir_t *dir) + +{ + uint32_t uVar1; + int iVar2; + char *pcVar3; + uint uVar4; + void *addr; + void *addr_00; + + if (dir == (aos_dir_t *)0x0) { + return (aos_dirent_t *)0x0; + } +LAB_23049af6: + do { + pcVar3 = romfs_root; + if ((void *)dir[2].dd_vfs_fd == (void *)0x0) { + dir[2].dd_vfs_fd = dir[1].dd_vfs_fd; + } + else { + addr_00 = (void *)dir[1].dd_rsv; + if (addr_00 <= (void *)dir[2].dd_vfs_fd) { + return (aos_dirent_t *)0x0; + } + while( true ) { + addr = (void *)dir[2].dd_vfs_fd; + if (addr_00 <= addr) { + return (aos_dirent_t *)0x0; + } + uVar1 = dirent_hardfh(addr); + if (uVar1 == 0) break; + if (addr == (void *)0x0) { + return (aos_dirent_t *)0x0; + } + iVar2 = dirent_type(addr); + if (iVar2 - 1U < 2) break; + *(char **)&dir[2].dd_vfs_fd = pcVar3 + uVar1; + } + } + strncpy((char *)((int)&dir[3].dd_vfs_fd + 1),(char *)(dir[2].dd_vfs_fd + 0x10),0x40); + addr_00 = (void *)dir[2].dd_vfs_fd; + *(undefined *)((int)&dir[0xb].dd_vfs_fd + 1) = 0; + uVar1 = dirent_hardfh(addr_00); + if (uVar1 == 0) { + pcVar3 = (char *)dir[1].dd_rsv; + } + else { + pcVar3 = romfs_root + uVar1; + } + *(char **)&dir[2].dd_vfs_fd = pcVar3; + uVar4 = dir[3].dd_vfs_fd & 0xffff00; + if (uVar4 == 0x2e2e00) { + if (*(char *)((int)&dir[3].dd_vfs_fd + 3) != '\0') goto LAB_23049b2c; + goto LAB_23049af6; + } + if (uVar4 != 0x2e00) { +LAB_23049b2c: + return (aos_dirent_t *)&dir[2].dd_rsv; + } + } while( true ); +} + + + +uint32_t dirent_file(char *path,void **p_addr_start_input,void **p_addr_end_input) + +{ + bool bVar1; + char *pcVar2; + size_t __n; + size_t sVar3; + int iVar4; + TickType_t TVar5; + char *format; + char *pcVar6; + uint32_t uVar7; + undefined4 uVar8; + uint uVar9; + char *pcStack124; + char *addr_start; + char *addr_end; + char name [65]; + + __n = strlen(path); + sVar3 = strlen("/romfs"); + if (sVar3 <= __n) { + __n = strlen("/romfs"); + iVar4 = memcmp(path,"/romfs",__n); + if (iVar4 == 0) { + __n = strlen("/romfs"); + path = path + __n; + if (*path == '/') { + path = path + 1; +LAB_23049c4c: + bVar1 = false; + uVar9 = *(uint *)(romfs_root + 8); + pcStack124 = romfs_root; + addr_start = romfs_root + + (uVar9 >> 8 & 0xff00 | uVar9 << 0x18 | uVar9 >> 0x18 | (uVar9 & 0xff00) << 8); + do { + if (*path == '\0') { +LAB_23049da2: + *(char **)p_addr_start_input = pcStack124; + *(char **)p_addr_end_input = addr_start; + return 0; + } + pcVar6 = strchr(path,0x2f); + pcVar2 = pcStack124; + format = romfs_root; + if (bVar1) { + uVar7 = dirent_childaddr(pcStack124); + pcStack124 = format + uVar7; + if (pcVar2 == pcStack124) { + return 0xfffffffe; + } + } + if (pcVar6 == (char *)0x0) { + __n = strlen(path); + if (0x40 < __n) { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + uVar8 = 0x138; + format = "[%10u][%s: %s:%4d] name too long!\r\n"; + goto LAB_23049c0a; + } + iVar4 = file_info(path,&pcStack124,&addr_start); + if (iVar4 != 0) { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] file info error, p_name = %s, addr_start = %p, addr_end = %p\r\n" + ,TVar5,&DAT_23081ce8,"bl_romfs.c",0x13c,path,pcStack124,addr_start); + return 0xffffffff; + } + goto LAB_23049da2; + } + memset(&addr_end,0,0x41); + memcpy(&addr_end,path,(size_t)(pcVar6 + -(int)path)); + iVar4 = file_info(&addr_end,&pcStack124,&addr_start); + if (iVar4 != 0) { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + uVar8 = 0x147; + format = "[%10u][%s: %s:%4d] file info error.\r\n"; + goto LAB_23049c0a; + } + path = pcVar6 + 1; + bVar1 = true; + } while( true ); + } + if (*path == '\0') goto LAB_23049c4c; + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + uVar8 = 0x11a; + } + else { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + uVar8 = 0x115; + } + format = "[%10u][%s: %s:%4d] not support path.\r\n"; +LAB_23049c0a: + bl_printk(format,TVar5,&DAT_23072bcc,"bl_romfs.c",uVar8); + } + return 0xffffffff; +} + + + +// WARNING: Variable defined which should be unmapped: end_addr + +aos_dir_t * romfs_opendir(file_t *fp,char *path) + +{ + char *pcVar1; + TickType_t TVar2; + aos_dir_t *__s; + uint32_t uVar3; + size_t sVar4; + char *pcStack24; + char *start_addr; + char *end_addr; + + if (romfs_root == (char *)0x0) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] romfs_root is null.\r\n",TVar2,&DAT_23072bcc,"bl_romfs.c",0x20d); + return (aos_dir_t *)0x0; + } + __s = (aos_dir_t *)aos_malloc(0x5d); + if (__s != (aos_dir_t *)0x0) { + memset(__s,0,0x5d); + uVar3 = dirent_file(path,&pcStack24,&start_addr); + pcVar1 = romfs_root; + if (uVar3 == 0) { + if (pcStack24 == romfs_root) { + sVar4 = strlen(pcStack24 + 0x10); + *(char **)&__s[1].dd_vfs_fd = pcStack24 + (sVar4 + 0x10 & 0xfffffff0) + 0x50; + } + else { + uVar3 = dirent_childaddr(pcStack24); + if (uVar3 == 0) { + return (aos_dir_t *)0x0; + } + *(char **)&__s[1].dd_vfs_fd = pcVar1 + uVar3; + } + __s[2].dd_vfs_fd = 0; + *(char **)&__s[1].dd_rsv = start_addr; + return __s; + } + aos_free(__s); + } + return (aos_dir_t *)0x0; +} + + + +// WARNING: Variable defined which should be unmapped: end_addr + +int romfs_stat(file_t *fp,char *path,stat *st) + +{ + char *addr; + uint32_t uVar1; + TickType_t TVar2; + int iVar3; + uint32_t uVar4; + mode_t mVar5; + char *pcStack24; + char *start_addr; + char *end_addr; + + pcStack24 = (char *)0x0; + start_addr = (char *)0x0; + uVar1 = dirent_file(path,&pcStack24,&start_addr); + addr = pcStack24; + if (uVar1 == 0) { + if (pcStack24 == romfs_root) { + st->st_size = 0; + } + else { + iVar3 = dirent_type(pcStack24); + if (iVar3 == 1) { + st->st_size = 0; + mVar5 = 0x4000; + } + else { + if (iVar3 != 2) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] dirent_type err.\r\n",TVar2,&DAT_23081ce8,"bl_romfs.c",0x1fa + ); + return -2; + } + uVar4 = dirent_size(addr); + st->st_size = uVar4; + mVar5 = 0x8000; + } + st->st_mode = mVar5; + } + } + else { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] dirent_file res = %d\r\n",TVar2,&DAT_23081ce8,"bl_romfs.c",0x1ea, + uVar1); + uVar1 = 0xffffffff; + } + return uVar1; +} + + + +int romfs_open(file_t *fp,char *path,int flags) + +{ + bool bVar1; + char cVar2; + TickType_t TVar3; + char *format; + size_t sVar4; + size_t __n; + int iVar5; + uint32_t uVar6; + undefined4 uVar7; + size_t unaff_s4; + void *pvStack40; + char *start_addr; + char *end_addr; + + if (romfs_root == (char *)0x0) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar7 = 0x162; + format = "[%10u][%s: %s:%4d] romfs_root is null.\r\n"; + } + else { + sVar4 = strlen(path); + __n = strlen("/romfs"); + iVar5 = strncmp(path,"/romfs",__n); + if (iVar5 == 0) { + __n = 0; + do { + if (sVar4 == __n) { + uVar6 = dirent_file(path,&pvStack40,&start_addr); + if (uVar6 != 0) { + return -2; + } + fp->offset = 0; + fp->f_arg = pvStack40; + return 0; + } + cVar2 = path[__n]; + if (0x19 < (byte)(cVar2 + 0x9fU)) { + if (((byte)(cVar2 + 0xbfU) < 0x1a) || ((byte)(cVar2 - 0x30U) < 10)) { + if (cVar2 == '/') goto LAB_2304a102; + } + else { + if (cVar2 == '/') { +LAB_2304a102: + if (__n == 0) { + unaff_s4 = 0; + } + else { + bVar1 = __n == unaff_s4; + unaff_s4 = __n; + if (bVar1) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar7 = 0x73; + format = "[%10u][%s: %s:%4d] format error.\r\n"; + goto LAB_2304a048; + } + } + } + else { + if ((cVar2 != '_') && (1 < (byte)(cVar2 - 0x2dU))) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] is_path_ch. i = %d\r\n",TVar3,&DAT_23072bcc, + "bl_romfs.c",0x69,__n); + goto LAB_2304a0d4; + } + } + } + } + __n = __n + 1; + } while( true ); + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar7 = 0x61; + format = "[%10u][%s: %s:%4d] format is error.\r\n"; +LAB_2304a048: + bl_printk(format,TVar3,&DAT_23072bcc,"bl_romfs.c",uVar7); +LAB_2304a0d4: + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar7 = 0x168; + format = "[%10u][%s: %s:%4d] path format is error.\r\n"; + } + bl_printk(format,TVar3,&DAT_23072bcc,"bl_romfs.c",uVar7); + return -1; +} + + + +// WARNING: Variable defined which should be unmapped: info + +int romfs_register(void) + +{ + uint __s1; + int iVar1; + TickType_t TVar2; + char *format; + size_t __n; + undefined4 uVar3; + undefined auStack44 [4]; + bl_mtd_info_t info; + + iVar1 = bl_mtd_open("media",&handle_romfs,2); + if (iVar1 == 0) { + memset(auStack44,0,0x1c); + bl_mtd_info(handle_romfs,(bl_mtd_info_t *)auStack44); + __s1 = info.size; + if ((void *)info.size == (void *)0x0) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar3 = 0x8d; + format = "[%10u][%s: %s:%4d] romfs has no XIP-Addr\r\n"; + } + else { + __n = strlen("-rom1fs-"); + iVar1 = memcmp((void *)__s1,"-rom1fs-",__n); + if (iVar1 == 0) { + romfs_root = (char *)info.size; + log_buf_out("bl_romfs.c",0x98,(void *)info.size,0x40,LOG_BUF_OUT_DATA_TYPE_HEX); + iVar1 = aos_register_fs("/romfs",&romfs_ops,(void *)0x0); + return iVar1; + } + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar3 = 0x92; + format = "[%10u][%s: %s:%4d] romfs magic is NOT correct\r\n"; + } + bl_printk(format,TVar2,&DAT_23072bcc,"bl_romfs.c",uVar3); + } + else { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [EF] [PART] [XIP] error when get romfs partition %d\r\n",TVar2, + &DAT_23072bcc,"bl_romfs.c",0x86,iVar1); + } + return -1; +} + + + +void _startup_sntp(void *arg) + +{ + puts("--------------------------------------- Start NTP now\r\n"); + sntp_setoperatingmode('\0'); + sntp_setservername('\0',"0.asia.pool.ntp.org"); + sntp_init(); + puts("--------------------------------------- Start NTP Done\r\n"); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void cmd_sntp_date(char *buf,int len,int argc,char **argv) + +{ + uint32_t uStack44; + uint32_t seconds; + uint32_t frags; + utils_time_date_t date; + + uStack44 = 0; + seconds = 0; + puts("test epoch from 1581863713 --->>>\r\n"); + puts("Should be Sunday, February 16, 2020 2:35:13 PM\r\n"); + utils_time_date_from_epoch(0x5e495321,&frags); + printf("Date & time is: %u-%02u-%02u %02u:%02u:%02u (Day %u of week, Day %u of Year)\r\n", + date._4_4_,(uint)date.ntp_minute,(uint)date.ntp_hour,(uint)(byte)frags,(uint)frags._1_1_, + (uint)frags._2_1_,(uint)frags._3_1_); + puts("SNTP GMT time is\r\n"); + sntp_get_time(&uStack44,&seconds); + utils_time_date_from_epoch(uStack44,&frags); + printf("Date & time is: %u-%02u-%02u %02u:%02u:%02u (Day %u of week, Day %u of Year)\r\n", + date._4_4_,(uint)date.ntp_minute,(uint)date.ntp_hour,(uint)(byte)frags,(uint)frags._1_1_, + (uint)frags._2_1_,(uint)frags._3_1_); + return; +} + + + +void cmd_sntp_time(char *buf,int len,int argc,char **argv) + +{ + uint32_t uStack24; + uint32_t seconds; + uint32_t frags; + + uStack24 = 0; + seconds = 0; + sntp_get_time(&uStack24,&seconds); + printf("[NTP] time is %lu:%lu\r\n",uStack24,seconds); + return; +} + + + +void cmd_sntp_start(char *buf,int len,int argc,char **argv) + +{ + tcpip_callback(_startup_sntp,(void *)0x0); + return; +} + + + +int sntp_cli_init(void) + +{ + return 0; +} + + + +void sntp_retry(void *arg) + +{ + uint uVar1; + + sys_timeout(sntp_retry_timeout,sntp_request,(void *)0x0); + uVar1 = sntp_retry_timeout << 1; + if ((uVar1 < 0x249f1) && (sntp_retry_timeout < uVar1)) { + sntp_retry_timeout = uVar1; + } + return; +} + + + +void sntp_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port) + +{ + int iVar1; + byte bVar2; + u8_t uVar3; + undefined3 extraout_var; + u32_t uVar4; + u32_t uVar5; + uint uVar6; + undefined2 in_register_0000203a; + u32_t uStack40; + sntp_timestamps timestamps; + + printf("SNTP time now\r\n",CONCAT22(in_register_0000203a,port)); + iVar1 = -0x10; + if (p->tot_len == 0x30) { + bVar2 = pbuf_get_at(p,0); + if (sntp_opmode == '\0') { + iVar1 = -3; + if ((bVar2 & 7) != 4) goto LAB_2304a444; + } + else { + iVar1 = -3; + if ((sntp_opmode != '\x01') || ((bVar2 & 7) != 5)) goto LAB_2304a444; + } + uVar3 = pbuf_get_at(p,1); + if (CONCAT31(extraout_var,uVar3) == 0) { + printf("sntp_recv: Received Kiss-of-Death\r\n"); + iVar1 = 1; + } + else { + pbuf_copy_partial(p,&uStack40,8,0x28); + iVar1 = 0; + } + } +LAB_2304a444: + pbuf_free(p); + printf("Try process\r\n"); + if (iVar1 == 0) { + uVar4 = lwip_htonl(uStack40); + uVar5 = lwip_htonl(timestamps.xmit.sec); + printf("Processing...\r\n"); + vTaskEnterCritical(); + ntp_frag = uVar5; + ntp_sec = uVar4 + 0x7c558180; + time_obtained = xTaskGetTickCount(); + uVar6 = ntp_frag / 1000 + ntp_sec * 1000; + bl_sys_time_update(uVar6,(int)((ulonglong)ntp_sec * 1000 >> 0x20) + + (uint)(uVar6 < ntp_sec * 1000)); + vTaskExitCritical(); + printf("sntp_process: %ld, %lu us\r\n",uVar4 + 0x7c558180, + (int)((ulonglong)uVar5 * 1000000 >> 0x20)); + sntp_servers[0].reachability = sntp_servers[0].reachability | 1; + if (sntp_opmode == '\0') { + sys_untimeout(sntp_retry,(void *)0x0); + sys_untimeout(sntp_request,(void *)0x0); + sntp_retry_timeout = 15000; + sys_timeout(3600000,sntp_request,(void *)0x0); + } + } + else { + if ((iVar1 == 1) && (sntp_opmode == '\0')) { + sntp_retry((void *)0x0); + } + } + return; +} + + + +void sntp_send_request(ip_addr_t *server_addr) + +{ + undefined *__s; + pbuf *p; + code *handler; + + p = pbuf_alloc(PBUF_TRANSPORT,0x30,PBUF_RAM); + if (p == (pbuf *)0x0) { + handler = sntp_request; + } + else { + __s = (undefined *)p->payload; + memset(__s,0,0x30); + *__s = 0x23; + udp_sendto(sntp_pcb,p,server_addr,0x7b); + pbuf_free(p); + sntp_servers[0].reachability = sntp_servers[0].reachability << 1; + handler = sntp_retry; + } + sys_timeout(15000,handler,(void *)0x0); + return; +} + + + +void sntp_request(void *arg) + +{ + err_t eVar1; + undefined3 extraout_var; + ip_addr_t iStack20; + ip_addr_t sntp_server_address; + + if (sntp_servers[0].name == (char *)0x0) { + iStack20 = (ip_addr_t)sntp_servers[0].addr; + if (sntp_servers[0].addr == 0) goto LAB_2304a64e; + } + else { + sntp_servers[0].addr = 0; + eVar1 = dns_gethostbyname(sntp_servers[0].name,&iStack20,sntp_dns_found,(void *)0x0); + if (CONCAT31(extraout_var,eVar1) == -5) { + return; + } + if (CONCAT31(extraout_var,eVar1) != 0) { +LAB_2304a64e: + sys_timeout(15000,sntp_retry,(void *)0x0); + return; + } + } + sntp_servers[0].addr = (u32_t)iStack20; + sntp_send_request(&iStack20); + return; +} + + + +void sntp_dns_found(char *hostname,ip_addr_t *ipaddr,void *arg) + +{ + if (ipaddr != (ip_addr_t *)0x0) { + sntp_servers[0].addr = ipaddr->addr; + sntp_send_request(ipaddr); + return; + } + sntp_retry((void *)0x0); + return; +} + + + +void sntp_init(void) + +{ + udp_pcb *pcb; + uint uVar1; + + if (sntp_pcb == (udp_pcb *)0x0) { + sntp_pcb = udp_new_ip_type(); + printf("[SNTP] pcb isready, %p\r\n"); + if (sntp_pcb != (udp_pcb *)0x0) { + udp_recv(sntp_pcb,sntp_recv,(void *)0x0); + pcb = sntp_pcb; + if (sntp_opmode == '\0') { + sntp_retry_timeout = 15000; + uVar1 = bl_rand(); + sys_timeout(uVar1 % 5000,sntp_request,(void *)0x0); + return; + } + if (sntp_opmode == '\x01') { + sntp_pcb->so_options = sntp_pcb->so_options | 0x20; + udp_bind(pcb,&ip_addr_any,0x7b); + return; + } + } + } + return; +} + + + +void sntp_setoperatingmode(u8_t operating_mode) + +{ + sntp_opmode = operating_mode; + return; +} + + + +int sntp_get_time(uint32_t *seconds,uint32_t *frags) + +{ + TickType_t TVar1; + int iVar2; + uint uVar3; + + vTaskEnterCritical(); + if (ntp_sec == 0) { + *seconds = 0; + *frags = 0; + } + else { + TVar1 = xTaskGetTickCount(); + iVar2 = TVar1 - time_obtained; + uVar3 = ntp_frag / 1000; + *seconds = iVar2 / 1000 + ntp_sec; + *frags = iVar2 % 1000 + uVar3; + } + vTaskExitCritical(); + return 0; +} + + + +void sntp_setservername(u8_t idx,char *server) + +{ + undefined3 in_register_00002029; + + if (CONCAT31(in_register_00002029,idx) == 0) { + sntp_servers[0].name = server; + } + return; +} + + + +char * utils_bin2hex(char *dst,void *src,size_t count) + +{ + char cVar1; + byte *pbVar2; + char *pcVar3; + + pbVar2 = (byte *)src; + pcVar3 = dst; + while (pbVar2 != (byte *)((int)src + count)) { + cVar1 = "0123456789ABCDEF"[(uint)*pbVar2 & 0xf]; + *pcVar3 = "0123456789ABCDEF"[*pbVar2 >> 4]; + pcVar3[1] = cVar1; + pbVar2 = pbVar2 + 1; + pcVar3 = pcVar3 + 2; + } + return dst + count * 2; +} + + + +void utils_sha256_init(iot_sha256_context *ctx) + +{ + memset(ctx,0,0x6c); + return; +} + + + +void utils_sha256_free(iot_sha256_context *ctx) + +{ + iot_sha256_context *piVar1; + + piVar1 = ctx + 1; + if (ctx != (iot_sha256_context *)0x0) { + while (ctx != piVar1) { + *(undefined *)ctx->total = 0; + ctx = (iot_sha256_context *)((int)ctx->total + 1); + } + } + return; +} + + + +void utils_sha256_starts(iot_sha256_context *ctx) + +{ + ctx->state[0] = 0x6a09e667; + ctx->state[1] = 0xbb67ae85; + ctx->state[2] = 0x3c6ef372; + ctx->state[3] = 0xa54ff53a; + ctx->state[4] = 0x510e527f; + ctx->state[5] = 0x9b05688c; + ctx->state[6] = 0x1f83d9ab; + ctx->total[0] = 0; + ctx->total[1] = 0; + ctx->state[7] = 0x5be0cd19; + ctx->is224 = 0; + return; +} + + + +void utils_sha256_process(iot_sha256_context *ctx,uchar *data) + +{ + uint uVar1; + uint32_t *puVar2; + byte *pbVar3; + byte *pbVar4; + uint uVar5; + uint uVar6; + uint32_t uVar7; + uint uVar8; + uint32_t *puVar9; + uint uVar10; + uint32_t *puVar11; + uint uVar12; + int iVar13; + uint uVar14; + uint uVar15; + uint uVar16; + uint uVar17; + uint32_t *puVar18; + uint uVar19; + uint uVar20; + uint uVar21; + uint32_t *puVar22; + uint uVar23; + uint32_t uVar24; + uint uVar25; + uint32_t *puVar26; + uint32_t uVar27; + uint32_t local_150; + uint32_t A [8]; + uint32_t W [64]; + + puVar18 = &local_150; + puVar9 = &local_150; + puVar11 = ctx->state; + do { + uVar7 = *puVar11; + puVar11 = puVar11 + 1; + *puVar9 = uVar7; + puVar9 = puVar9 + 1; + } while ((uint32_t *)ctx->buffer != puVar11); + puVar11 = A + 7; + pbVar3 = data; + puVar9 = puVar11; + do { + pbVar4 = pbVar3 + 4; + *puVar9 = (uint)*pbVar3 << 0x18 | (uint)pbVar3[1] << 0x10 | (uint)pbVar3[3] | + (uint)pbVar3[2] << 8; + pbVar3 = pbVar4; + puVar9 = puVar9 + 1; + } while (data + 0x40 != pbVar4); + puVar2 = K; + puVar9 = K; + puVar26 = puVar11; + do { + puVar22 = puVar9 + 8; + iVar13 = A[6] + ((A[3] >> 6 | A[3] << 0x1a) ^ (A[3] >> 0xb | A[3] << 0x15) ^ + (A[3] << 7 | A[3] >> 0x19)) + *puVar9 + *puVar26 + ((A[5] ^ A[4]) & A[3] ^ A[5]) + ; + uVar12 = A[2] + iVar13; + uVar14 = iVar13 + ((local_150 >> 2 | local_150 << 0x1e) ^ (local_150 >> 0xd | local_150 << 0x13) + ^ (local_150 << 10 | local_150 >> 0x16)) + + ((local_150 | A[0]) & A[1] | local_150 & A[0]); + iVar13 = ((uVar12 >> 6 | uVar12 * 0x4000000) ^ (uVar12 >> 0xb | uVar12 * 0x200000) ^ + (uVar12 * 0x80 | uVar12 >> 0x19)) + + A[5] + puVar9[1] + puVar26[1] + ((A[3] ^ A[4]) & uVar12 ^ A[4]); + uVar1 = ((uVar14 >> 2 | uVar14 * 0x40000000) ^ (uVar14 >> 0xd | uVar14 * 0x80000) ^ + (uVar14 * 0x400 | uVar14 >> 0x16)) + ((uVar14 | local_150) & A[0] | uVar14 & local_150) + + iVar13; + uVar10 = A[1] + iVar13; + iVar13 = ((uVar10 >> 6 | uVar10 * 0x4000000) ^ (uVar10 >> 0xb | uVar10 * 0x200000) ^ + (uVar10 * 0x80 | uVar10 >> 0x19)) + + A[4] + puVar9[2] + puVar26[2] + ((uVar12 ^ A[3]) & uVar10 ^ A[3]); + uVar5 = ((uVar1 >> 2 | uVar1 * 0x40000000) ^ (uVar1 >> 0xd | uVar1 * 0x80000) ^ + (uVar1 * 0x400 | uVar1 >> 0x16)) + ((uVar14 | uVar1) & local_150 | uVar14 & uVar1) + + iVar13; + uVar8 = A[0] + iVar13; + iVar13 = ((uVar8 >> 6 | uVar8 * 0x4000000) ^ (uVar8 >> 0xb | uVar8 * 0x200000) ^ + (uVar8 * 0x80 | uVar8 >> 0x19)) + + A[3] + puVar9[3] + puVar26[3] + ((uVar12 ^ uVar10) & uVar8 ^ uVar12); + uVar16 = ((uVar5 >> 2 | uVar5 * 0x40000000) ^ (uVar5 >> 0xd | uVar5 * 0x80000) ^ + (uVar5 * 0x400 | uVar5 >> 0x16)) + ((uVar1 | uVar5) & uVar14 | uVar1 & uVar5) + iVar13; + uVar6 = local_150 + iVar13; + iVar13 = ((uVar6 >> 6 | uVar6 * 0x4000000) ^ (uVar6 >> 0xb | uVar6 * 0x200000) ^ + (uVar6 * 0x80 | uVar6 >> 0x19)) + + uVar12 + puVar9[4] + puVar26[4] + ((uVar10 ^ uVar8) & uVar6 ^ uVar10); + A[2] = ((uVar16 >> 2 | uVar16 * 0x40000000) ^ (uVar16 >> 0xd | uVar16 * 0x80000) ^ + (uVar16 * 0x400 | uVar16 >> 0x16)) + ((uVar5 | uVar16) & uVar1 | uVar5 & uVar16) + iVar13 + ; + A[6] = uVar14 + iVar13; + iVar13 = ((A[6] >> 6 | A[6] * 0x4000000) ^ (A[6] >> 0xb | A[6] * 0x200000) ^ + (A[6] * 0x80 | A[6] >> 0x19)) + + uVar10 + puVar9[5] + puVar26[5] + ((uVar8 ^ uVar6) & A[6] ^ uVar8); + A[1] = ((A[2] >> 2 | A[2] * 0x40000000) ^ (A[2] >> 0xd | A[2] * 0x80000) ^ + (A[2] * 0x400 | A[2] >> 0x16)) + ((uVar16 | A[2]) & uVar5 | uVar16 & A[2]) + iVar13; + A[5] = uVar1 + iVar13; + iVar13 = ((A[5] >> 6 | A[5] * 0x4000000) ^ (A[5] >> 0xb | A[5] * 0x200000) ^ + (A[5] * 0x80 | A[5] >> 0x19)) + + uVar8 + puVar9[6] + puVar26[6] + ((uVar6 ^ A[6]) & A[5] ^ uVar6); + A[0] = ((A[1] >> 2 | A[1] * 0x40000000) ^ (A[1] >> 0xd | A[1] * 0x80000) ^ + (A[1] * 0x400 | A[1] >> 0x16)) + ((A[2] | A[1]) & uVar16 | A[2] & A[1]) + iVar13; + A[4] = uVar5 + iVar13; + iVar13 = ((A[4] >> 6 | A[4] * 0x4000000) ^ (A[4] >> 0xb | A[4] * 0x200000) ^ + (A[4] * 0x80 | A[4] >> 0x19)) + + uVar6 + puVar9[7] + puVar26[7] + ((A[6] ^ A[5]) & A[4] ^ A[6]); + A[3] = uVar16 + iVar13; + local_150 = ((A[0] >> 2 | A[0] * 0x40000000) ^ (A[0] >> 0xd | A[0] * 0x80000) ^ + (A[0] * 0x400 | A[0] >> 0x16)) + ((A[1] | A[0]) & A[2] | A[1] & A[0]) + iVar13; + puVar9 = puVar22; + puVar26 = puVar26 + 8; + } while (puVar22 != K + 0x10); + do { + uVar19 = puVar11[0xe]; + uVar1 = puVar11[1]; + uVar20 = puVar11[0xf]; + uVar23 = ((uVar19 << 0xf | uVar19 >> 0x11) ^ (uVar19 << 0xd | uVar19 >> 0x13) ^ uVar19 >> 10) + + puVar11[9] + *puVar11 + + ((uVar1 >> 7 | uVar1 << 0x19) ^ (uVar1 << 0xe | uVar1 >> 0x12) ^ uVar1 >> 3); + uVar10 = puVar11[3]; + iVar13 = A[6] + ((A[3] >> 6 | A[3] << 0x1a) ^ (A[3] >> 0xb | A[3] << 0x15) ^ + (A[3] << 7 | A[3] >> 0x19)) + ((A[5] ^ A[4]) & A[3] ^ A[5]) + puVar2[0x10] + + uVar23; + uVar16 = A[2] + iVar13; + uVar15 = iVar13 + ((local_150 >> 2 | local_150 << 0x1e) ^ (local_150 >> 0xd | local_150 << 0x13) + ^ (local_150 << 10 | local_150 >> 0x16)) + + ((local_150 | A[0]) & A[1] | local_150 & A[0]); + uVar6 = puVar11[2]; + uVar1 = ((uVar20 << 0xf | uVar20 >> 0x11) ^ (uVar20 << 0xd | uVar20 >> 0x13) ^ uVar20 >> 10) + + uVar1 + puVar11[10] + + ((uVar6 >> 7 | uVar6 << 0x19) ^ (uVar6 << 0xe | uVar6 >> 0x12) ^ uVar6 >> 3); + iVar13 = ((A[3] ^ A[4]) & uVar16 ^ A[4]) + A[5] + puVar2[0x11] + uVar1 + + ((uVar16 >> 6 | uVar16 * 0x4000000) ^ (uVar16 >> 0xb | uVar16 * 0x200000) ^ + (uVar16 * 0x80 | uVar16 >> 0x19)); + uVar5 = ((uVar15 >> 2 | uVar15 * 0x40000000) ^ (uVar15 >> 0xd | uVar15 * 0x80000) ^ + (uVar15 * 0x400 | uVar15 >> 0x16)) + ((local_150 | uVar15) & A[0] | local_150 & uVar15) + + iVar13; + uVar14 = A[1] + iVar13; + uVar6 = ((uVar23 * 0x8000 | uVar23 >> 0x11) ^ (uVar23 * 0x2000 | uVar23 >> 0x13) ^ uVar23 >> 10) + + uVar6 + puVar11[0xb] + + ((uVar10 >> 7 | uVar10 << 0x19) ^ (uVar10 << 0xe | uVar10 >> 0x12) ^ uVar10 >> 3); + iVar13 = ((A[3] ^ uVar16) & uVar14 ^ A[3]) + A[4] + puVar2[0x12] + uVar6 + + ((uVar14 >> 6 | uVar14 * 0x4000000) ^ (uVar14 >> 0xb | uVar14 * 0x200000) ^ + (uVar14 * 0x80 | uVar14 >> 0x19)); + puVar11[0x11] = uVar1; + uVar8 = ((uVar5 >> 2 | uVar5 * 0x40000000) ^ (uVar5 >> 0xd | uVar5 * 0x80000) ^ + (uVar5 * 0x400 | uVar5 >> 0x16)) + ((uVar15 | uVar5) & local_150 | uVar15 & uVar5) + + iVar13; + uVar12 = A[0] + iVar13; + uVar25 = puVar11[4]; + uVar1 = ((uVar1 * 0x8000 | uVar1 >> 0x11) ^ (uVar1 * 0x2000 | uVar1 >> 0x13) ^ uVar1 >> 10) + + uVar10 + puVar11[0xc] + + ((uVar25 >> 7 | uVar25 << 0x19) ^ (uVar25 << 0xe | uVar25 >> 0x12) ^ uVar25 >> 3); + iVar13 = ((uVar16 ^ uVar14) & uVar12 ^ uVar16) + A[3] + puVar2[0x13] + uVar1 + + ((uVar12 >> 6 | uVar12 * 0x4000000) ^ (uVar12 >> 0xb | uVar12 * 0x200000) ^ + (uVar12 * 0x80 | uVar12 >> 0x19)); + uVar17 = ((uVar8 >> 2 | uVar8 * 0x40000000) ^ (uVar8 >> 0xd | uVar8 * 0x80000) ^ + (uVar8 * 0x400 | uVar8 >> 0x16)) + ((uVar5 | uVar8) & uVar15 | uVar5 & uVar8) + iVar13; + uVar10 = local_150 + iVar13; + puVar11[0x12] = uVar6; + uVar21 = puVar11[5]; + uVar25 = ((uVar6 * 0x8000 | uVar6 >> 0x11) ^ (uVar6 * 0x2000 | uVar6 >> 0x13) ^ uVar6 >> 10) + + uVar25 + puVar11[0xd] + + ((uVar21 >> 7 | uVar21 << 0x19) ^ (uVar21 << 0xe | uVar21 >> 0x12) ^ uVar21 >> 3); + iVar13 = ((uVar10 >> 6 | uVar10 * 0x4000000) ^ (uVar10 >> 0xb | uVar10 * 0x200000) ^ + (uVar10 * 0x80 | uVar10 >> 0x19)) + + ((uVar14 ^ uVar12) & uVar10 ^ uVar14) + uVar16 + puVar2[0x14] + uVar25; + A[2] = ((uVar17 >> 2 | uVar17 * 0x40000000) ^ (uVar17 >> 0xd | uVar17 * 0x80000) ^ + (uVar17 * 0x400 | uVar17 >> 0x16)) + ((uVar8 | uVar17) & uVar5 | uVar8 & uVar17) + iVar13 + ; + A[6] = uVar15 + iVar13; + uVar6 = puVar11[6]; + puVar11[0x13] = uVar1; + uVar16 = ((uVar1 * 0x8000 | uVar1 >> 0x11) ^ (uVar1 * 0x2000 | uVar1 >> 0x13) ^ uVar1 >> 10) + + uVar19 + uVar21 + + ((uVar6 >> 7 | uVar6 << 0x19) ^ (uVar6 << 0xe | uVar6 >> 0x12) ^ uVar6 >> 3); + iVar13 = ((A[6] >> 6 | A[6] * 0x4000000) ^ (A[6] >> 0xb | A[6] * 0x200000) ^ + (A[6] * 0x80 | A[6] >> 0x19)) + + ((uVar12 ^ uVar10) & A[6] ^ uVar12) + uVar14 + puVar2[0x15] + uVar16; + A[1] = ((A[2] >> 2 | A[2] * 0x40000000) ^ (A[2] >> 0xd | A[2] * 0x80000) ^ + (A[2] * 0x400 | A[2] >> 0x16)) + ((uVar17 | A[2]) & uVar8 | uVar17 & A[2]) + iVar13; + A[5] = uVar5 + iVar13; + uVar1 = puVar11[7]; + puVar11[0x14] = uVar25; + uVar7 = uVar20 + uVar6 + + ((uVar25 * 0x8000 | uVar25 >> 0x11) ^ (uVar25 * 0x2000 | uVar25 >> 0x13) ^ uVar25 >> 10) + + ((uVar1 >> 7 | uVar1 << 0x19) ^ (uVar1 << 0xe | uVar1 >> 0x12) ^ uVar1 >> 3); + iVar13 = ((A[5] >> 6 | A[5] * 0x4000000) ^ (A[5] >> 0xb | A[5] * 0x200000) ^ + (A[5] * 0x80 | A[5] >> 0x19)) + + ((uVar10 ^ A[6]) & A[5] ^ uVar10) + uVar12 + puVar2[0x16] + uVar7; + A[0] = ((A[1] >> 2 | A[1] * 0x40000000) ^ (A[1] >> 0xd | A[1] * 0x80000) ^ + (A[1] * 0x400 | A[1] >> 0x16)) + ((A[2] | A[1]) & uVar17 | A[2] & A[1]) + iVar13; + A[4] = uVar8 + iVar13; + uVar5 = puVar11[8]; + puVar11[0x15] = uVar16; + puVar11[0x10] = uVar23; + uVar27 = puVar2[0x17]; + uVar24 = uVar23 + uVar1 + + ((uVar16 * 0x8000 | uVar16 >> 0x11) ^ (uVar16 * 0x2000 | uVar16 >> 0x13) ^ uVar16 >> 10 + ) + ((uVar5 >> 7 | uVar5 << 0x19) ^ (uVar5 << 0xe | uVar5 >> 0x12) ^ uVar5 >> 3); + puVar11[0x17] = uVar24; + iVar13 = ((A[4] >> 6 | A[4] * 0x4000000) ^ (A[4] >> 0xb | A[4] * 0x200000) ^ + (A[4] * 0x80 | A[4] >> 0x19)) + + uVar10 + uVar27 + uVar24 + ((A[6] ^ A[5]) & A[4] ^ A[6]); + puVar11[0x16] = uVar7; + puVar11 = puVar11 + 8; + A[3] = uVar17 + iVar13; + local_150 = ((A[0] >> 2 | A[0] * 0x40000000) ^ (A[0] >> 0xd | A[0] * 0x80000) ^ + (A[0] * 0x400 | A[0] >> 0x16)) + ((A[1] | A[0]) & A[2] | A[1] & A[0]) + iVar13; + puVar2 = puVar2 + 8; + } while (W + 0x2f != puVar11); + puVar9 = ctx->state; + do { + iVar13 = *puVar18; + puVar11 = puVar9 + 1; + puVar18 = (uint32_t *)((int *)puVar18 + 1); + *puVar9 = *puVar9 + iVar13; + puVar9 = puVar11; + } while ((uint32_t *)ctx->buffer != puVar11); + return; +} + + + +void utils_sha256_update(iot_sha256_context *ctx,uchar *input,uint32_t ilen) + +{ + size_t __n; + uint uVar1; + uint uVar2; + uint __n_00; + + uVar2 = ctx->total[0] & 0x3f; + uVar1 = ctx->total[0] + ilen; + ctx->total[0] = uVar1; + if (uVar1 < ilen) { + ctx->total[1] = ctx->total[1] + 1; + } + uVar1 = ilen; + if ((uVar2 != 0) && (__n_00 = 0x40 - uVar2, __n_00 <= ilen)) { + memcpy(ctx->buffer + uVar2,input,__n_00); + ilen = (ilen - 0x40) + uVar2; + utils_sha256_process(ctx,ctx->buffer); + input = input + __n_00; + uVar2 = 0; + uVar1 = ilen; + } + while (0x3f < ilen) { + utils_sha256_process(ctx,input + (uVar1 - ilen)); + ilen = ilen - 0x40; + } + __n = (uVar1 >> 6) * -0x40 + uVar1; + if (__n == 0) { + return; + } + memcpy(ctx->buffer + uVar2,input + (uVar1 & 0xffffffc0),__n); + return; +} + + + +void utils_sha256_update(iot_sha256_context *ctx,uchar *input,uint32_t ilen) + +{ + if (ilen != 0) { + utils_sha256_update(ctx,input,ilen); + return; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void utils_sha256_finish(iot_sha256_context *ctx,uint8_t *output) + +{ + uint uVar1; + uint uVar2; + int iVar3; + uchar uStack24; + undefined uStack23; + ushort uStack22; + uchar msglen [8]; + + uVar1 = ctx->total[0]; + uVar2 = ctx->total[1] << 3; + uStack24 = (uchar)(uVar2 >> 0x18); + uStack23 = (undefined)(uVar2 >> 0x10); + uStack22 = (ushort)(uVar2 >> 8) & 0xff | (ushort)((uVar2 | uVar1 >> 0x1d) << 8); + msglen[0] = (uchar)((uVar1 << 3) >> 0x18); + msglen[1] = (uchar)((uVar1 << 3) >> 0x10); + msglen._2_2_ = (ushort)((uVar1 << 0x13) >> 0x18) | (ushort)(uVar1 << 0xb); + if ((uVar1 & 0x3f) < 0x38) { + iVar3 = 0x38; + } + else { + iVar3 = 0x78; + } + utils_sha256_update(ctx,sha256_padding,iVar3 - (uVar1 & 0x3f)); + utils_sha256_update(ctx,&uStack24,8); + *output = *(uint8_t *)((int)ctx->state + 3); + output[1] = (uint8_t)*(undefined2 *)((int)ctx->state + 2); + output[2] = (uint8_t)(ctx->state[0] >> 8); + output[3] = (uint8_t)ctx->state[0]; + output[4] = *(uint8_t *)((int)ctx->state + 7); + output[5] = (uint8_t)*(undefined2 *)((int)ctx->state + 6); + output[6] = (uint8_t)(ctx->state[1] >> 8); + output[7] = (uint8_t)ctx->state[1]; + output[8] = *(uint8_t *)((int)ctx->state + 0xb); + output[9] = (uint8_t)*(undefined2 *)((int)ctx->state + 10); + output[10] = (uint8_t)(ctx->state[2] >> 8); + output[0xb] = (uint8_t)ctx->state[2]; + output[0xc] = *(uint8_t *)((int)ctx->state + 0xf); + output[0xd] = (uint8_t)*(undefined2 *)((int)ctx->state + 0xe); + output[0xe] = (uint8_t)(ctx->state[3] >> 8); + output[0xf] = (uint8_t)ctx->state[3]; + output[0x10] = *(uint8_t *)((int)ctx->state + 0x13); + output[0x11] = (uint8_t)*(undefined2 *)((int)ctx->state + 0x12); + output[0x12] = (uint8_t)(ctx->state[4] >> 8); + output[0x13] = (uint8_t)ctx->state[4]; + output[0x14] = *(uint8_t *)((int)ctx->state + 0x17); + output[0x15] = (uint8_t)*(undefined2 *)((int)ctx->state + 0x16); + output[0x16] = (uint8_t)(ctx->state[5] >> 8); + output[0x17] = (uint8_t)ctx->state[5]; + output[0x18] = *(uint8_t *)((int)ctx->state + 0x1b); + output[0x19] = (uint8_t)*(undefined2 *)((int)ctx->state + 0x1a); + output[0x1a] = (uint8_t)(ctx->state[6] >> 8); + output[0x1b] = (uint8_t)ctx->state[6]; + if (ctx->is224 == 0) { + output[0x1c] = *(uint8_t *)((int)ctx->state + 0x1f); + output[0x1d] = (uint8_t)*(undefined2 *)((int)ctx->state + 0x1e); + output[0x1e] = (uint8_t)(ctx->state[7] >> 8); + output[0x1f] = (uint8_t)ctx->state[7]; + } + return; +} + + + +void bl_printk(char *format,...) + +{ + undefined4 in_a1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list args; + undefined4 uStack28; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + if (sys_log_all_enable != false) { + uStack28 = in_a1; + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + vprint(format,&uStack28); + } + return; +} + + + +int log_buf_out(char *file,int line,void *inbuf,int len,LOG_BUF_OUT_DATA_TYPE_T type) + +{ + bool bVar1; + int iVar2; + int iVar3; + TickType_t TVar4; + char *__format; + uint uVar5; + undefined3 in_register_00002039; + int iVar6; + int iVar7; + int iVar8; + int iVar9; + void *pvVar10; + + iVar6 = CONCAT31(in_register_00002039,type); + if (len < 1) { + return -1; + } + iVar9 = len / 0x32; + if (len % 0x32 == 0) { + pvVar10 = (void *)(iVar9 * 0x32 + (int)inbuf); + while (pvVar10 != inbuf) { + iVar7 = 0; + iVar9 = 0; + do { + uVar5 = (uint)*(byte *)((int)inbuf + iVar9); + if (iVar6 == 1) { + uVar5 = SEXT14((char)*(byte *)((int)inbuf + iVar9)); + __format = "%3d "; + } + else { + __format = "%3u "; + if (iVar6 != 2) { + __format = "%02x "; + } + } + iVar3 = sprintf(log_buf + iVar7,__format,uVar5); + iVar9 = iVar9 + 1; + iVar7 = iVar7 + iVar3; + } while (iVar9 != 0x32); + if (TrapNetCounter == 0) { + TVar4 = xTaskGetTickCount(); + } + else { + TVar4 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %.*s\r\n",TVar4,&UNK_2308789c,file,line,iVar7,log_buf); + inbuf = (void *)((int)inbuf + 0x32); + } + } + else { + iVar7 = 0; + do { + iVar3 = 0; + iVar8 = 0; + if (iVar9 == iVar7) { + do { + uVar5 = (uint)*(byte *)((int)inbuf + iVar8); + if (iVar6 == 1) { + uVar5 = SEXT14((char)*(byte *)((int)inbuf + iVar8)); + __format = "%3d "; + } + else { + __format = "%3u "; + if (iVar6 != 2) { + __format = "%02x "; + } + } + iVar2 = sprintf(log_buf + iVar3,__format,uVar5); + iVar8 = iVar8 + 1; + iVar3 = iVar3 + iVar2; + } while (len % 0x32 != iVar8); + } + else { + do { + uVar5 = (uint)*(byte *)((int)inbuf + iVar8); + if (iVar6 == 1) { + uVar5 = SEXT14((char)*(byte *)((int)inbuf + iVar8)); + __format = "%3d "; + } + else { + __format = "%3u "; + if (iVar6 != 2) { + __format = "%02x "; + } + } + iVar2 = sprintf(log_buf + iVar3,__format,uVar5); + iVar8 = iVar8 + 1; + iVar3 = iVar3 + iVar2; + } while (iVar8 != 0x32); + } + if (TrapNetCounter == 0) { + TVar4 = xTaskGetTickCount(); + } + else { + TVar4 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %.*s\r\n",TVar4,&UNK_2308789c,file,line,iVar3,log_buf); + inbuf = (void *)((int)inbuf + 0x32); + bVar1 = iVar7 < iVar9; + iVar7 = iVar7 + 1; + } while (bVar1); + } + return 0; +} + + + +int utils_dns_domain_get(uint8_t *records,uint8_t *buf,int *len) + +{ + int iVar1; + int iVar2; + uint uVar3; + int iVar4; + int iVar5; + int iVar6; + + iVar6 = *len; + uVar3 = (uint)*records; + iVar2 = 1; + iVar5 = 0; + while ((iVar4 = iVar5, iVar1 = iVar2, uVar3 != 0 && (0 < iVar6))) { + uVar3 = uVar3 - 1; + buf[iVar4] = records[iVar1]; + iVar2 = iVar1 + 1; + iVar5 = iVar4 + 1; + iVar6 = iVar6 + -1; + if ((uVar3 == 0) && (iVar6 != 0)) { + buf[iVar5] = '.'; + uVar3 = (uint)records[iVar2]; + iVar2 = iVar1 + 2; + iVar5 = iVar4 + 2; + } + } + *len = iVar4; + return 0; +} + + + +void utils_list_init(utils_list *list) + +{ + list->first = (utils_list_hdr *)0x0; + list->last = (utils_list_hdr *)0x0; + return; +} + + + +void utils_list_push_back(utils_list *list,utils_list_hdr *list_hdr) + +{ + if (list->first == (utils_list_hdr *)0x0) { + list->first = list_hdr; + } + else { + list->last->next = list_hdr; + } + list->last = list_hdr; + list_hdr->next = (utils_list_hdr *)0x0; + return; +} + + + +utils_list_hdr * utils_list_pop_front(utils_list *list) + +{ + utils_list_hdr *puVar1; + + puVar1 = list->first; + if (puVar1 != (utils_list_hdr *)0x0) { + list->first = puVar1->next; + } + return puVar1; +} + + + +void utils_hexdump(void *mem,uint len) + +{ + uint uVar1; + int iVar2; + uint c; + int iVar3; + uint uVar4; + uint uVar5; + + iVar2 = 0; + if ((len & 0xf) != 0) { + iVar2 = 0x10 - (len & 0xf); + } + uVar4 = 0; + while (uVar1 = uVar4, iVar2 + len != uVar1) { + if ((uVar1 & 0xf) == 0) { + printf("0x%06x: ",uVar1); + } + if (uVar1 < len) { + printf("%02x ",(uint)*(byte *)((int)mem + uVar1)); + } + else { + printf(" "); + } + uVar4 = uVar1 + 1; + if ((uVar1 & 0xf) == 0xf) { + uVar5 = uVar1 - 0xf; + iVar3 = 0x11; + if (uVar4 < uVar5) { + iVar3 = 1; + } + while (uVar5 != (uVar1 - 0x10) + iVar3) { + c = 0x20; + if ((uVar5 < len) && (c = (uint)*(byte *)((int)mem + uVar5), (_ctype_[c + 1] & 0x97) == 0)) + { + c = 0x2e; + } + bl_putchar(c); + uVar5 = uVar5 + 1; + } + puts("\r\n"); + } + } + return; +} + + + +undefined4 utils_time_date_from_epoch(uint param_1,undefined *param_2) + +{ + byte bVar1; + byte bVar2; + uint uVar3; + uint uVar4; + uint uVar5; + undefined4 uStack20; + undefined2 uStack16; + undefined uStack14; + char cStack13; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack12 = 0x1e1f1c1f; + uStack8 = 0x1f1f1e1f; + uStack4 = 0x1f1e1f1e; + uStack20 = 0x60504; + uStack16 = 0x201; + uStack14 = 3; + *(undefined2 *)(param_2 + 6) = 0; + param_2[2] = (char)(param_1 % 0x3c); + param_2[1] = (char)((param_1 / 0x3c) % 0x3c); + *param_2 = (char)((param_1 / 0xe10) % 0x18); + uVar5 = param_1 / 0x15180; + *(uint *)(param_2 + 0xc) = uVar5; + param_2[3] = *(undefined *)((int)&uStack20 + uVar5 % 7); + uVar4 = 0x7b4; + uVar3 = param_1 / 0x1e13380 + 0x7b2; + *(uint *)(param_2 + 8) = uVar3; + while (uVar4 < uVar3) { + if (((int)uVar4 % 100 != 0) || ((int)uVar4 % 400 == 0)) { + param_2[6] = param_2[6] + '\x01'; + } + uVar4 = uVar4 + 4; + } + uVar3 = (uVar5 - (byte)param_2[6]) / 0x16d + 0x7b2; + *(uint *)(param_2 + 8) = uVar3; + uVar4 = (uVar5 - (byte)param_2[6]) % 0x16d + 1; + *(uint *)(param_2 + 0x10) = uVar4; + if ((((uVar3 & 3) == 0) && (uVar3 % 100 != 0)) || (uVar3 % 400 == 0)) { + uStack12 = 0x1e1f1d1f; + param_2[7] = 1; + } + param_2[5] = 0; + uVar3 = 0; + while( true ) { + bVar1 = param_2[5]; + if ((0xb < bVar1) || (uVar4 <= uVar3)) break; + bVar2 = *(byte *)((int)&uStack12 + (uint)bVar1); + param_2[5] = bVar1 + 1; + uVar3 = uVar3 + bVar2 & 0xffff; + } + param_2[4] = (char)uVar4 - ((char)uVar3 - (&cStack13)[(uint)bVar1]); + return 0; +} + + + +int utils_getopt_init(getopt_env_t *env,int opterr) + +{ + if (env != (getopt_env_t *)0x0) { + env->optarg = (char *)0x0; + env->optind = 1; + env->opterr = opterr; + env->optopt = 0; + env->__optpos = 0; + return 0; + } + return -1; +} + + + +int utils_getopt(getopt_env_t *env,int argc,char **argv,char *optstring) + +{ + byte bVar1; + byte bVar2; + int iVar3; + uint uVar4; + char **ppcVar5; + int iVar6; + byte *pbVar7; + char *pcVar8; + byte *pbVar9; + + if (env == (getopt_env_t *)0x0) { + return -1; + } + iVar6 = env->optind; + if (argc <= iVar6) { + return -1; + } + ppcVar5 = argv + iVar6; + pcVar8 = *ppcVar5; + if (pcVar8 == (char *)0x0) { + return -1; + } + if (*pcVar8 != '-') { + if (*optstring == '-') { + env->optind = iVar6 + 1; + env->optarg = *ppcVar5; + return 1; + } + return -1; + } + if (pcVar8[1] == '\0') { + return -1; + } + if ((pcVar8[1] == '-') && (pcVar8[2] == '\0')) { + env->optind = iVar6 + 1; + return -1; + } + if (env->__optpos == 0) { + env->__optpos = 1; + } + pbVar9 = (byte *)(*ppcVar5 + env->__optpos); + bVar1 = *pbVar9; + uVar4 = (uint)bVar1; + iVar3 = (uint)(bVar1 != 0) + env->__optpos; + env->__optpos = iVar3; + if ((*ppcVar5)[iVar3] == '\0') { + env->optind = iVar6 + 1; + env->__optpos = 0; + } + if ((*optstring - 0x2bU & 0xfd) == 0) { + optstring = optstring + 1; + } + iVar6 = 0; + do { + iVar3 = iVar6 + 1; + pbVar7 = (byte *)(optstring + iVar6); + bVar2 = *pbVar7; + if (bVar2 == 0) { + if (bVar1 == 0) goto LAB_2304bcb4; + goto LAB_2304bc96; + } + iVar6 = iVar3; + } while (uVar4 != (uint)bVar2); + if (bVar1 == 0x3a) { +LAB_2304bc96: + env->optopt = uVar4; + if (*optstring == ':') { + return 0x3f; + } + if (env->opterr == 0) { + return 0x3f; + } + bVar1 = *pbVar9; + pcVar8 = *argv; + iVar6 = -0x728; + } + else { +LAB_2304bcb4: + if (optstring[iVar3] != ':') { + return uVar4; + } + env->optarg = (char *)0x0; + iVar6 = env->__optpos; + if ((pbVar7[2] != 0x3a) || (iVar6 != 0)) { + iVar3 = env->optind; + env->optind = iVar3 + 1; + pcVar8 = argv[iVar3]; + env->__optpos = 0; + env->optarg = pcVar8 + iVar6; + } + if (env->optind <= argc) { + return uVar4; + } + env->optopt = uVar4; + if (*optstring == ':') { + return 0x3a; + } + if (env->opterr == 0) { + return 0x3f; + } + bVar1 = *pbVar9; + pcVar8 = *argv; + iVar6 = -0x708; + } + printf("ERROR failed! net_set_(non)block() returned -0x%x\r\n" + iVar6 + 0x14,pcVar8,(uint)bVar1); + return 0x3f; +} + + + +// WARNING: Variable defined which should be unmapped: pTemp + +void Bl_F_fast(uchar *digest,uchar *digest1,char *password,uchar *ssid,int ssidlength,int count, + uchar *output) + +{ + int iVar1; + size_t key_len; + byte *pbVar2; + uchar *puVar3; + byte *pbVar4; + int iVar5; + int iStack40; + int tmpLen; + uchar *pTemp; + + key_len = strlen(password); + iStack40 = ssidlength + 4; + tmpLen = (int)digest; + memcpy(digest,ssid,ssidlength); + puVar3 = digest + ssidlength; + *puVar3 = '\0'; + puVar3[3] = (uchar)count; + puVar3[1] = '\0'; + puVar3[2] = '\0'; + bl_sha_mutex_take(); + utils_hmac_sha1_fast((uchar **)&tmpLen,&iStack40,1,(uchar *)password,key_len,digest1,0x14); + memcpy(output,digest1,0x14); + iVar1 = 0xfff; + tmpLen = (int)digest1; + do { + iStack40 = 0x14; + utils_hmac_sha1_fast((uchar **)&tmpLen,&iStack40,1,(uchar *)password,key_len,digest,0x14); + memcpy(digest1,digest,0x14); + iVar5 = 0; + do { + pbVar2 = output + iVar5; + pbVar4 = digest + iVar5; + iVar5 = iVar5 + 1; + *pbVar2 = *pbVar4 ^ *pbVar2; + } while (iVar5 != 0x14); + iVar1 = iVar1 + -1; + } while (iVar1 != 0); + bl_sha_mutex_give(); + return; +} + + + +int utils_wifi_psk_cal_fast_bin(char *password,uchar *ssid,int ssidlength,uchar *output) + +{ + size_t sVar1; + int iVar2; + uchar auStack88 [4]; + uchar digest1 [20]; + uchar digest [36]; + + sVar1 = strlen(password); + if (sVar1 < 0x40) { + iVar2 = -1; + if (ssidlength < 0x21) { + Bl_F_fast(digest1 + 0x10,auStack88,password,ssid,ssidlength,2,output); + memcpy(output + 0x14,output,0xc); + Bl_F_fast(digest1 + 0x10,auStack88,password,ssid,ssidlength,1,output); + iVar2 = 0; + } + } + else { + iVar2 = -1; + } + return iVar2; +} + + + +// WARNING: Type propagation algorithm not settling + +int utils_memp_init(utils_memp_pool_t **pool,uint16_t node_size,uint16_t pool_cap,uint8_t align_req) + +{ + uint uVar1; + uint uVar2; + utils_memp_pool_t *puVar3; + int iVar4; + undefined2 in_register_0000202e; + undefined2 in_register_00002032; + uint32_t uVar5; + utils_memp_node uVar6; + uint32_t uVar7; + utils_memp_node uVar8; + uint uVar9; + + uVar5 = CONCAT22(in_register_00002032,pool_cap); + uVar9 = (uint)align_req + 3 & 0xfc; + uVar2 = CONCAT22(in_register_0000202e,node_size) + 3 + uVar9 & -uVar9 & 0xffff; + uVar1 = -uVar9 & uVar9 + 0x1f; + puVar3 = (utils_memp_pool_t *)pvPortMalloc(uVar2 * uVar5 + uVar1); + if (puVar3 == (utils_memp_pool_t *)0x0) { + iVar4 = -1; + } + else { + uVar8 = (utils_memp_node)((int)&puVar3->node_size + uVar1); + *(utils_memp_node *)&((utils_memp_node *)&puVar3->first_node)->next = uVar8; + puVar3->node_size = CONCAT22(in_register_0000202e,node_size); + puVar3->pool_cap = uVar5; + puVar3->pool_size = 0; + puVar3->align_req = (uint8_t)uVar9; + puVar3->padded_node_size = uVar2; + puVar3->mem = (utils_memp_node *)0x0; + uVar7 = 0; + uVar6 = (utils_memp_node)0x0; + while (uVar7 != uVar5) { + *(utils_memp_node *)uVar8 = uVar6; + uVar7 = uVar7 + 1 & 0xffff; + uVar6 = uVar8; + uVar8 = (utils_memp_node)((int)uVar8 + uVar2); + } + *(utils_memp_node *)&((utils_memp_node *)&puVar3->mem)->next = uVar6; + *(utils_memp_node *)&((utils_memp_node *)&puVar3->last_node)->next = uVar6; + *pool = puVar3; + iVar4 = 0; + } + return iVar4; +} + + + +int utils_memp_deinit(utils_memp_pool_t *pool) + +{ + if (pool != (utils_memp_pool_t *)0x0) { + vPortFree(pool); + return 0; + } + return -1; +} + + + +void * utils_memp_malloc(utils_memp_pool_t *pool) + +{ + utils_memp_node *puVar1; + utils_memp_node *puVar2; + + puVar2 = (utils_memp_node *)0x0; + if (pool != (utils_memp_pool_t *)0x0) { + puVar2 = (utils_memp_node *)0x0; + if ((pool->pool_size != pool->pool_cap) && + (puVar2 = pool->mem, puVar2 != (utils_memp_node *)0x0)) { + puVar1 = puVar2->next; + pool->pool_size = pool->pool_size + 1; + pool->mem = puVar1; + puVar2->next = (utils_memp_node *)0xa5; + puVar2 = puVar2 + 1; + } + } + return puVar2; +} + + + +int utils_memp_free(utils_memp_pool_t *pool,void *node) + +{ + utils_memp_node *puVar1; + + puVar1 = (utils_memp_node *)((int)node + -4); + if ((((pool != (utils_memp_pool_t *)0x0) && (puVar1 != (utils_memp_node *)0x0)) && + (pool->pool_size != 0)) && + ((((utils_memp_node *)pool->first_node <= puVar1 && + (puVar1 <= (utils_memp_node *)pool->last_node)) && + (((uint)((int)puVar1 - (int)(utils_memp_node *)pool->first_node) % pool->padded_node_size == 0 + && (*(int *)((int)node + -4) == 0xa5)))))) { + *(utils_memp_node **)((int)node + -4) = pool->mem; + pool->mem = puVar1; + pool->pool_size = pool->pool_size - 1; + return 0; + } + return -1; +} + + + +int utils_tlv_bl_pack_auto(uint32_t *buf,int buf_sz,uint16_t type,void *arg1) + +{ + undefined2 in_register_00002032; + uint32_t uVar1; + int iVar2; + + if (CONCAT22(in_register_00002032,type) == 1) { + uVar1 = (uint32_t)*(byte *)arg1; + } + else { + if (CONCAT22(in_register_00002032,type) != 7) { + return -2; + } + uVar1 = *(uint32_t *)arg1; + } + iVar2 = -1; + if (3 < buf_sz) { + *buf = uVar1; + iVar2 = 4; + } + return iVar2; +} + + + +int utils_tlv_bl_unpack_auto(uint32_t *buf,int buf_sz,uint16_t type,void *arg1) + +{ + int iVar1; + undefined2 in_register_00002032; + bool bVar2; + uint32_t uVar3; + + if (CONCAT22(in_register_00002032,type) == 1) { + if (buf_sz < 4) { + bVar2 = true; + iVar1 = -1; + } + else { + iVar1 = 4; + bVar2 = *buf != 0; + } + *(bool *)arg1 = bVar2; + return iVar1; + } + if (CONCAT22(in_register_00002032,type) != 7) { + return -2; + } + if (buf_sz < 4) { + uVar3 = 0; + iVar1 = -1; + } + else { + uVar3 = *buf; + iVar1 = 4; + } + *(uint32_t *)arg1 = uVar3; + return iVar1; +} + + + +void utils_hmac_sha1_fast + (uchar **ppText,int *pTextLen,int textNum,uchar *key,int key_len,uchar *output, + int outputLen) + +{ + uint *puVar1; + uint32_t *puVar2; + uint *__src; + uchar **ppuVar3; + int iVar4; + uint *hash; + uint local_120; + uint64_t pBuf [11]; + undefined auStack196 [4]; + bl_sha_ctx_t sha_ctx; + + if (0x40 < key_len) { + bl_sha_init((bl_sha_ctx_t *)auStack196,BL_SHA1); + bl_sha_update((bl_sha_ctx_t *)auStack196,key,key_len); + bl_sha_finish((bl_sha_ctx_t *)auStack196,key); + key_len = 0x14; + } + memset(&local_120,0,0x40); + memcpy(&local_120,key,key_len); + hash = (uint *)((int)pBuf + 0x3c); + puVar1 = &local_120; + do { + __src = puVar1 + 2; + *puVar1 = *puVar1 ^ 0x36363636; + puVar1[1] = puVar1[1] ^ 0x36363636; + puVar1 = __src; + } while (__src != hash); + bl_sha_init((bl_sha_ctx_t *)auStack196,BL_SHA1); + bl_sha_update((bl_sha_ctx_t *)auStack196,(uint8_t *)&local_120,0x40); + iVar4 = 0; + while (iVar4 < textNum) { + puVar2 = (uint32_t *)(pTextLen + iVar4); + ppuVar3 = ppText + iVar4; + iVar4 = iVar4 + 1; + bl_sha_update((bl_sha_ctx_t *)auStack196,*ppuVar3,*puVar2); + } + bl_sha_finish((bl_sha_ctx_t *)auStack196,(uint8_t *)hash); + memset(&local_120,0,0x40); + memcpy(&local_120,key,key_len); + puVar1 = &local_120; + do { + __src = puVar1 + 2; + *puVar1 = *puVar1 ^ 0x5c5c5c5c; + puVar1[1] = puVar1[1] ^ 0x5c5c5c5c; + puVar1 = __src; + } while (__src != hash); + bl_sha_init((bl_sha_ctx_t *)auStack196,BL_SHA1); + bl_sha_update((bl_sha_ctx_t *)auStack196,(uint8_t *)&local_120,0x40); + bl_sha_update((bl_sha_ctx_t *)auStack196,(uint8_t *)__src,0x14); + bl_sha_finish((bl_sha_ctx_t *)auStack196,(uint8_t *)__src); + memcpy(output,__src,outputLen); + return; +} + + + +int vfs_init(void) + +{ + int iVar1; + + iVar1 = 0; + if (g_vfs_init != '\x01') { + g_vfs_mutex = (SemaphoreHandle_t)xQueueCreateMutexStatic('\x01',(StaticQueue_t *)&xMutexBuffer); + iVar1 = -1; + if (g_vfs_mutex != (SemaphoreHandle_t)0x0) { + inode_init(); + iVar1 = 0; + g_vfs_init = '\x01'; + } + } + return iVar1; +} + + + +int aos_open(char *path,int flags) + +{ + size_t sVar1; + BaseType_t BVar2; + inode_t *node; + file_t *file; + int iVar3; + code *pcVar4; + + if (path == (char *)0x0) { + iVar3 = -0x16; + } + else { + sVar1 = strlen(path); + if (0x400 < sVar1) { + return -0x5b; + } + BVar2 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar2 != 1) { + return -1; + } + node = inode_open(path); + if (node == (inode_t *)0x0) { + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + return -2; + } + node->i_flags = flags; + file = new_file(node); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + if (file == (file_t *)0x0) { + return -0x17; + } + pcVar4 = *(code **)node->ops; + if (node->type == '\x03') { + if (pcVar4 == (code *)0x0) goto LAB_2304c23a; + iVar3 = (*pcVar4)(file,path,flags); + } + else { + if (pcVar4 == (code *)0x0) goto LAB_2304c23a; + iVar3 = (*pcVar4)(node,file); + } + if (iVar3 == 0) { +LAB_2304c23a: + iVar3 = get_fd(file); + return iVar3; + } + del_file(file); + } + return iVar3; +} + + + +int aos_close(int fd) + +{ + int iVar1; + file_t *file; + BaseType_t BVar2; + code *pcVar3; + + file = get_file(fd); + iVar1 = -2; + if (file != (file_t *)0x0) { + iVar1 = 0; + pcVar3 = *(code **)(file->node->ops + 4); + if (pcVar3 != (code *)0x0) { + iVar1 = (*pcVar3)(); + } + BVar2 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar2 == 1) { + del_file(file); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + } + else { + iVar1 = -1; + } + } + return iVar1; +} + + + +ssize_t aos_read(int fd,void *buf,size_t nbytes) + +{ + code *UNRECOVERED_JUMPTABLE; + file_t *pfVar1; + ssize_t sVar2; + + pfVar1 = get_file(fd); + if (pfVar1 == (file_t *)0x0) { + sVar2 = -2; + } + else { + UNRECOVERED_JUMPTABLE = *(code **)(pfVar1->node->ops + 8); + if (UNRECOVERED_JUMPTABLE != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x2304c2d6. Too many branches + // WARNING: Treating indirect jump as call + sVar2 = (*UNRECOVERED_JUMPTABLE)(buf,nbytes); + return sVar2; + } + sVar2 = -1; + } + return sVar2; +} + + + +ssize_t aos_write(int fd,void *buf,size_t nbytes) + +{ + code *UNRECOVERED_JUMPTABLE; + file_t *pfVar1; + ssize_t sVar2; + + pfVar1 = get_file(fd); + if (pfVar1 == (file_t *)0x0) { + sVar2 = -2; + } + else { + UNRECOVERED_JUMPTABLE = *(code **)(pfVar1->node->ops + 0xc); + if (UNRECOVERED_JUMPTABLE != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x2304c304. Too many branches + // WARNING: Treating indirect jump as call + sVar2 = (*UNRECOVERED_JUMPTABLE)(buf,nbytes); + return sVar2; + } + sVar2 = -1; + } + return sVar2; +} + + + +int aos_ioctl(int fd,int cmd,ulong arg) + +{ + code *UNRECOVERED_JUMPTABLE; + file_t *pfVar1; + int iVar2; + + if (fd < 0) { + return -0x16; + } + pfVar1 = get_file(fd); + if (pfVar1 == (file_t *)0x0) { + iVar2 = -2; + } + else { + iVar2 = pfVar1->node->ops; + if (pfVar1->node->type == '\x03') { + UNRECOVERED_JUMPTABLE = *(code **)(iVar2 + 0x44); + } + else { + UNRECOVERED_JUMPTABLE = *(code **)(iVar2 + 0x10); + } + if (UNRECOVERED_JUMPTABLE != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x2304c340. Too many branches + // WARNING: Treating indirect jump as call + iVar2 = (*UNRECOVERED_JUMPTABLE)(cmd,arg); + return iVar2; + } + iVar2 = -0x58; + } + return iVar2; +} + + + +off_t aos_lseek(int fd,off_t offset,int whence) + +{ + code *UNRECOVERED_JUMPTABLE; + file_t *pfVar1; + off_t oVar2; + + pfVar1 = get_file(fd); + if (pfVar1 == (file_t *)0x0) { + oVar2 = -2; + } + else { + if (pfVar1->node->type == '\x03') { + UNRECOVERED_JUMPTABLE = *(code **)(pfVar1->node->ops + 0x10); + if (UNRECOVERED_JUMPTABLE != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x2304c384. Too many branches + // WARNING: Treating indirect jump as call + oVar2 = (*UNRECOVERED_JUMPTABLE)(offset,whence); + return oVar2; + } + } + oVar2 = -0x58; + } + return oVar2; +} + + + +int aos_stat(char *path,stat *st) + +{ + int iVar1; + BaseType_t BVar2; + inode_t *node; + file_t *file; + code *pcVar3; + + if (path == (char *)0x0) { + return -0x16; + } + BVar2 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar2 == 1) { + node = inode_open(path); + if (node == (inode_t *)0x0) { + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + return -0x13; + } + file = new_file(node); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + if (file == (file_t *)0x0) { + return -2; + } + iVar1 = -0x58; + if ((node->type == '\x03') && (pcVar3 = *(code **)(node->ops + 0x18), pcVar3 != (code *)0x0)) { + iVar1 = (*pcVar3)(file,path,st); + } + BVar2 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar2 == 1) { + del_file(file); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + return iVar1; + } + } + return -1; +} + + + +aos_dir_t * aos_opendir(char *path) + +{ + BaseType_t BVar1; + inode_t *node; + file_t *file; + aos_dir_t *paVar2; + int iVar3; + code *pcVar4; + + if ((path != (char *)0x0) && + (BVar1 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff), BVar1 == 1)) { + node = inode_open(path); + if (node == (inode_t *)0x0) { + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + return (aos_dir_t *)0x0; + } + file = new_file(node); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + if (file != (file_t *)0x0) { + if (((node->type == '\x03') && (pcVar4 = *(code **)(node->ops + 0x24), pcVar4 != (code *)0x0)) + && (paVar2 = (aos_dir_t *)(*pcVar4)(file,path), paVar2 != (aos_dir_t *)0x0)) { + iVar3 = get_fd(file); + paVar2->dd_vfs_fd = iVar3; + return paVar2; + } + BVar1 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar1 == 1) { + del_file(file); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + } + } + } + return (aos_dir_t *)0x0; +} + + + +int aos_closedir(aos_dir_t *dir) + +{ + int iVar1; + file_t *file; + BaseType_t BVar2; + code *pcVar3; + + iVar1 = -0x16; + if (dir != (aos_dir_t *)0x0) { + iVar1 = -2; + file = get_file(dir->dd_vfs_fd); + if (file != (file_t *)0x0) { + iVar1 = -0x58; + if ((file->node->type == '\x03') && + (pcVar3 = *(code **)(file->node->ops + 0x2c), pcVar3 != (code *)0x0)) { + iVar1 = (*pcVar3)(dir); + } + BVar2 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar2 == 1) { + del_file(file); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + } + else { + iVar1 = -1; + } + } + } + return iVar1; +} + + + +aos_dirent_t * aos_readdir(aos_dir_t *dir) + +{ + code *UNRECOVERED_JUMPTABLE; + file_t *pfVar1; + aos_dirent_t *paVar2; + + if (dir == (aos_dir_t *)0x0) { + return (aos_dirent_t *)0x0; + } + pfVar1 = get_file(dir->dd_vfs_fd); + if (pfVar1 != (file_t *)0x0) { + if (pfVar1->node->type == '\x03') { + UNRECOVERED_JUMPTABLE = *(code **)(pfVar1->node->ops + 0x28); + if (UNRECOVERED_JUMPTABLE != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x2304c59a. Too many branches + // WARNING: Treating indirect jump as call + paVar2 = (aos_dirent_t *)(*UNRECOVERED_JUMPTABLE)(dir); + return paVar2; + } + } + } + return (aos_dirent_t *)0x0; +} + + + +file_t * new_file(inode_t *node) + +{ + file_t *pfVar1; + int iVar2; + + pfVar1 = files; + iVar2 = 0; + do { + if (pfVar1->node == (inode_t *)0x0) { + files[iVar2].node = node; + files[iVar2].f_arg = (void *)0x0; + files[iVar2].offset = 0; + inode_ref(node); + return files + iVar2; + } + iVar2 = iVar2 + 1; + pfVar1 = pfVar1 + 1; + } while (iVar2 != 0x3c); + return (file_t *)0x0; +} + + + +void del_file(file_t *file) + +{ + inode_unref(file->node); + file->node = (inode_t *)0x0; + return; +} + + + +int get_fd(file_t *file) + +{ + return ((int)(file + -0x5801c68) >> 2) * -0x55555555 + 2; +} + + + +file_t * get_file(int fd) + +{ + inode_t *piVar1; + + if (fd - 2U < 0x3c) { + piVar1 = files[fd - 2U].node; + if (piVar1 != (inode_t *)0x0) { + return files + (fd - 2U); + } + } + else { + piVar1 = (inode_t *)0x0; + } + return (file_t *)piVar1; +} + + + +int inode_init(void) + +{ + memset(g_vfs_dev_nodes,0,600); + return 0; +} + + + +int inode_alloc(void) + +{ + int iVar1; + inode_t *piVar2; + + piVar2 = g_vfs_dev_nodes; + iVar1 = 0; + do { + if (piVar2->type == '\0') { + return iVar1; + } + iVar1 = iVar1 + 1; + piVar2 = piVar2 + 1; + } while (iVar1 != 0x1e); + return -0xc; +} + + + +inode_t * inode_open(char *path) + +{ + inode_t *piVar1; + int iVar2; + size_t __n; + char *__s; + + piVar1 = g_vfs_dev_nodes; + do { + __s = piVar1->i_name; + if (__s != (char *)0x0) { + if (piVar1->type == '\x03') { + __n = strlen(__s); + iVar2 = strncmp(__s,path,__n); + if ((iVar2 == 0) && (__n = strlen(piVar1->i_name), path[__n] == '/')) { + return piVar1; + } + } + iVar2 = strcmp(piVar1->i_name,path); + if (iVar2 == 0) { + return piVar1; + } + } + piVar1 = piVar1 + 1; + if (piVar1 == (inode_t *)deleteAcceptedTopic) { + return (inode_t *)0x0; + } + } while( true ); +} + + + +int inode_forearch_name(anon_subr_int_void_ptr_inode_t_ptr *cb,void *arg) + +{ + inode_t *piVar1; + int iVar2; + int iVar3; + + piVar1 = g_vfs_dev_nodes; + iVar2 = 0; + do { + if (piVar1->i_name != (char *)0x0) { + iVar2 = iVar2 + 1; + iVar3 = (*cb)(arg,piVar1); + if (iVar3 != 0) { + return iVar2; + } + } + piVar1 = piVar1 + 1; + } while (piVar1 != (inode_t *)deleteAcceptedTopic); + return iVar2; +} + + + +void inode_ref(inode_t *node) + +{ + node->refs = node->refs + '\x01'; + return; +} + + + +void inode_unref(inode_t *node) + +{ + if (node->refs != '\0') { + node->refs = node->refs + -1; + } + return; +} + + + +int inode_reserve(char *path,inode_t **inode) + +{ + inode_t *piVar1; + int iVar2; + size_t __n; + char *__dest; + + if (((path != (char *)0x0) && (inode != (inode_t **)0x0)) && + (*inode = (inode_t *)0x0, *path == '/')) { + iVar2 = inode_alloc(); + if (-1 < iVar2) { + piVar1 = (inode_t *)0x0; + if (iVar2 < 0x1e) { + piVar1 = g_vfs_dev_nodes + iVar2; + } + __n = strlen(path); + __dest = (char *)pvPortMalloc(__n + 1); + iVar2 = -0xc; + if (__dest != (char *)0x0) { + memcpy(__dest,path,__n); + piVar1->i_name = __dest; + __dest[__n] = '\0'; + *inode = piVar1; + iVar2 = 0; + } + } + return iVar2; + } + return -0x16; +} + + + +int aos_register_driver(char *path,file_ops_t *ops,void *arg) + +{ + BaseType_t BVar1; + int iVar2; + inode_t *piStack36; + inode_t *node; + + piStack36 = (inode_t *)0x0; + BVar1 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar1 == 1) { + iVar2 = inode_reserve(path,&piStack36); + if (iVar2 == 0) { + *(file_ops_t **)&piStack36->ops = ops; + piStack36->type = '\x01'; + piStack36->i_arg = arg; + } + BVar1 = xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + if (BVar1 == 1) { + return iVar2; + } + if (piStack36->i_name != (char *)0x0) { + vPortFree(piStack36->i_name); + } + memset(piStack36,0,0x14); + } + return -1; +} + + + +int aos_register_fs(char *path,fs_ops_t *ops,void *arg) + +{ + BaseType_t BVar1; + int iVar2; + inode_t *piStack36; + inode_t *node; + + piStack36 = (inode_t *)0x0; + BVar1 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar1 == 1) { + iVar2 = inode_reserve(path,&piStack36); + if (iVar2 == 0) { + *(fs_ops_t **)&piStack36->ops = ops; + piStack36->type = '\x03'; + piStack36->i_arg = arg; + } + BVar1 = xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + if (BVar1 == 1) { + return iVar2; + } + if (piStack36->i_name != (char *)0x0) { + vPortFree(piStack36->i_name); + } + memset(piStack36,0,0x14); + } + return -1; +} + + + +int vfs_uart_open(inode_t *inode,file_t *fp) + +{ + uart_dev_t *uart; + int iVar1; + StreamBufferHandle_t pSVar2; + int32_t iVar3; + inode_t *piVar4; + + if ((fp == (file_t *)0x0) || (piVar4 = fp->node, piVar4 == (inode_t *)0x0)) { + iVar1 = -0x16; + } + else { + iVar1 = 0; + if (piVar4->refs == '\x01') { + uart = (uart_dev_t *)piVar4->i_arg; + aos_mutex_new((aos_mutex_t *)&uart->mutex); + pSVar2 = xStreamBufferGenericCreate(uart->rx_buf_size,1,0); + *(StreamBufferHandle_t *)&uart->rx_ringbuf_handle = pSVar2; + pSVar2 = xStreamBufferGenericCreate(uart->tx_buf_size,1,0); + *(StreamBufferHandle_t *)&uart->tx_ringbuf_handle = pSVar2; + if ((uart->rx_ringbuf_handle != (void *)0x0) && (pSVar2 != (StreamBufferHandle_t)0x0)) { + hal_uart_notify_register(uart,UART_TX_INT,__uart_tx_irq); + hal_uart_notify_register(uart,UART_RX_INT,__uart_rx_irq); + iVar3 = hal_uart_init(uart); + return iVar3; + } + return -0x16; + } + } + return iVar1; +} + + + +void __uart_rx_irq(void *p_arg) + +{ + uint32_t uStack88; + uint32_t length; + BaseType_t xHigherPriorityTaskWoken; + uint8_t tmp_buf [64]; + + uStack88 = 0; + length = 0; + hal_uart_recv_II((uart_dev_t *)p_arg,&xHigherPriorityTaskWoken,0x40,&uStack88,0); + if (uStack88 != 0) { + xStreamBufferSendFromISR + (*(StreamBufferHandle_t *)((int)p_arg + 0x10),&xHigherPriorityTaskWoken,uStack88, + (BaseType_t *)&length); + if (length != 0) { + vTaskSwitchContext(); + } + } + if (*(int *)((int)p_arg + 0x24) != 0) { + *(ushort *)(*(int *)((int)p_arg + 0x28) + 6) = *(ushort *)(*(int *)((int)p_arg + 0x28) + 6) | 1; + (**(code **)((int)p_arg + 0x24)) + (*(undefined4 *)((int)p_arg + 0x28),*(undefined4 *)((int)p_arg + 0x2c), + *(code **)((int)p_arg + 0x24)); + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void __uart_tx_irq(void *p_arg) + +{ + size_t sVar1; + undefined uStack21; + uint8_t ch; + int iStack20; + BaseType_t xHigherPriorityTaskWoken; + + iStack20 = 0; + sVar1 = xStreamBufferReceiveFromISR + (*(StreamBufferHandle_t *)((int)p_arg + 0x14),&uStack21,1, + (BaseType_t *)&stack0xffffffec); + if (iStack20 != 0) { + vTaskSwitchContext(); + } + if (sVar1 == 1) { + hal_uart_send((uart_dev_t *)p_arg,&uStack21,1,0); + } + else { + hal_uart_send_trigger_off((uart_dev_t *)p_arg); + } + return; +} + + + +int vfs_uart_close(file_t *fp) + +{ + uart_dev_t *uart; + int32_t iVar1; + inode_t *piVar2; + + if ((fp == (file_t *)0x0) || (piVar2 = fp->node, piVar2 == (inode_t *)0x0)) { + return -0x16; + } + if (piVar2->refs != '\x01') { + return 0; + } + uart = (uart_dev_t *)piVar2->i_arg; + if (uart != (uart_dev_t *)0x0) { + aos_mutex_free((aos_mutex_t *)&uart->mutex); + vStreamBufferDelete((StreamBufferHandle_t)uart->rx_ringbuf_handle); + vStreamBufferDelete((StreamBufferHandle_t)uart->tx_ringbuf_handle); + iVar1 = hal_uart_finalize(uart); + return iVar1; + } + return -0x16; +} + + + +ssize_t vfs_uart_read(file_t *fp,void *buf,size_t nbytes) + +{ + size_t sVar1; + TickType_t xTicksToWait; + size_t sVar2; + void *pvVar3; + + sVar1 = 0xffffffea; + if (fp != (file_t *)0x0) { + sVar1 = 0xffffffea; + if (((fp->node != (inode_t *)0x0) && (pvVar3 = fp->node->i_arg, nbytes != 0)) && + (pvVar3 != (void *)0x0)) { + aos_mutex_lock((aos_mutex_t *)((int)pvVar3 + 0x20),0xffffffff); + sVar1 = 0; + xTicksToWait = -(uint)(*(char *)((int)pvVar3 + 0x34) == '\x01'); + do { + sVar2 = xStreamBufferReceive + (*(StreamBufferHandle_t *)((int)pvVar3 + 0x10),(void *)((int)buf + sVar1), + nbytes - sVar1,xTicksToWait); + sVar1 = sVar1 + sVar2; + if (sVar1 == nbytes) break; + } while (xTicksToWait != 0); + aos_mutex_unlock((aos_mutex_t *)((int)pvVar3 + 0x20)); + } + } + return sVar1; +} + + + +ssize_t vfs_uart_write(file_t *fp,void *buf,size_t nbytes) + +{ + size_t sVar1; + uart_dev_t *uart; + + sVar1 = 0xffffffea; + if (fp != (file_t *)0x0) { + sVar1 = 0xffffffea; + if (((fp->node != (inode_t *)0x0) && + (uart = (uart_dev_t *)fp->node->i_arg, uart != (uart_dev_t *)0x0)) && + (sVar1 = xStreamBufferSend((StreamBufferHandle_t)uart->tx_ringbuf_handle,buf,nbytes,0), + 0 < (int)sVar1)) { + hal_uart_send_trigger(uart); + } + } + return sVar1; +} + + + +int vfs_uart_poll(file_t *fp,_Bool setup,poll_notify_t *notify,pollfd *fd,void *opa) + +{ + void *pvVar1; + BaseType_t BVar2; + undefined3 in_register_0000202d; + + pvVar1 = fp->node->i_arg; + aos_mutex_lock((aos_mutex_t *)((int)pvVar1 + 0x20),0xffffffff); + if (CONCAT31(in_register_0000202d,setup) == 0) { + vTaskEnterCritical(); + *(undefined4 *)((int)pvVar1 + 0x24) = 0; + *(undefined4 *)((int)pvVar1 + 0x2c) = 0; + vTaskExitCritical(); + } + else { + vTaskEnterCritical(); + *(poll_notify_t **)((int)pvVar1 + 0x24) = notify; + *(pollfd **)((int)pvVar1 + 0x28) = fd; + *(void **)((int)pvVar1 + 0x2c) = opa; + vTaskExitCritical(); + BVar2 = xStreamBufferIsEmpty(*(StreamBufferHandle_t *)((int)pvVar1 + 0x10)); + if (BVar2 != 1) { + *(ushort *)(*(int *)((int)pvVar1 + 0x28) + 6) = + *(ushort *)(*(int *)((int)pvVar1 + 0x28) + 6) | 1; + (*notify)(fd,opa); + } + } + aos_mutex_unlock((aos_mutex_t *)((int)pvVar1 + 0x20)); + return 0; +} + + + +int vfs_uart_sync(file_t *fp) + +{ + uart_dev_t *uart; + int iVar1; + + if (fp == (file_t *)0x0) { + return -0x16; + } + iVar1 = -0x16; + if (fp->node != (inode_t *)0x0) { + uart = (uart_dev_t *)fp->node->i_arg; + if (uart != (uart_dev_t *)0x0) { + aos_mutex_lock((aos_mutex_t *)&uart->mutex,0xffffffff); + hal_uart_send_flush(uart,0); + aos_mutex_unlock((aos_mutex_t *)&uart->mutex); + iVar1 = 0; + } + return iVar1; + } + return iVar1; +} + + + +int uart_ioctl_cmd_waimode(uart_dev_t *uart_dev,int cmd,ulong arg) + +{ + int iVar1; + size_t sVar2; + uint uVar3; + int iVar4; + + iVar1 = -0x16; + if (arg != 0) { + iVar4 = *(int *)(arg + 4); + uVar3 = *(int *)(arg + 8) * 1000; + iVar1 = 0; + do { + sVar2 = xStreamBufferReceive + ((StreamBufferHandle_t)uart_dev->rx_ringbuf_handle, + (void *)(*(int *)arg + iVar1),iVar4 - iVar1,uVar3 / 1000); + iVar1 = iVar1 + sVar2; + if (iVar4 == iVar1) { + return iVar1; + } + if (uVar3 < 1000) { + return iVar1; + } + } while ((cmd != 4) || (iVar1 < 1)); + } + return iVar1; +} + + + +int uart_ioctl_cmd_setconfig(uart_dev_t *uart_dev,ulong arg) + +{ + hal_uart_parity_t parity; + + if (arg != 0) { + parity = *(hal_uart_parity_t *)(arg + 4); + if ((parity != ODD_PARITY) && (parity != EVEN_PARITY)) { + parity = NO_PARITY; + } + hal_uart_setconfig(uart_dev,*(uint32_t *)arg,parity); + return 0; + } + return -0x16; +} + + + +int vfs_uart_ioctl(file_t *fp,int cmd,ulong arg) + +{ + int iVar1; + uart_dev_t *uart_dev; + uint8_t uVar2; + + if (fp == (file_t *)0x0) { + return -0x16; + } + iVar1 = -0x16; + if (fp->node == (inode_t *)0x0) { + return -0x16; + } + uart_dev = (uart_dev_t *)fp->node->i_arg; + if (uart_dev == (uart_dev_t *)0x0) { + return -0x16; + } + aos_mutex_lock((aos_mutex_t *)&uart_dev->mutex,0xffffffff); + switch(cmd) { + case 2: + hal_uart_send_flush(uart_dev,0); + break; + case 3: + hal_uart_setbaud(uart_dev,arg); + break; + case 4: + case 5: + iVar1 = uart_ioctl_cmd_waimode(uart_dev,cmd,arg); + goto switchD_2304ccc2_caseD_7; + case 6: + uVar2 = '\x01'; + goto LAB_2304cd04; + case 7: + uVar2 = '\x02'; +LAB_2304cd04: + uart_dev->read_block_flag = uVar2; + break; + case 8: + iVar1 = uart_ioctl_cmd_setconfig(uart_dev,arg); + default: + goto switchD_2304ccc2_caseD_7; + } + iVar1 = -1; +switchD_2304ccc2_caseD_7: + aos_mutex_unlock((aos_mutex_t *)&uart_dev->mutex); + return iVar1; +} + + + +yloop_ctx_t * get_context(void) + +{ + yloop_ctx_t *pyVar1; + + pyVar1 = (yloop_ctx_t *)aos_task_getspecific(g_loop_key); + if (pyVar1 == (yloop_ctx_t *)0x0) { + aos_task_setspecific(g_loop_key,g_main_ctx); + pyVar1 = g_main_ctx; + } + return pyVar1; +} + + + +void aos_loop_set_eventfd(int fd) + +{ + yloop_ctx_t *pyVar1; + + pyVar1 = get_context(); + pyVar1->eventfd = fd; + return; +} + + + +aos_loop_t aos_loop_init(void) + +{ + aos_task_key_t key; + void *pvVar1; + yloop_ctx_t *__s; + + pvVar1 = aos_task_getspecific(g_loop_key); + if (g_main_ctx == (yloop_ctx_t *)0x0) { + aos_task_key_create(&g_loop_key); + } + else { + if (pvVar1 != (void *)0x0) { + printf("yloopyloop already inited"); + return pvVar1; + } + } + __s = (yloop_ctx_t *)pvPortMalloc(0x1c); + if (__s != (yloop_ctx_t *)0x0) { + memset(__s,0,0x1c); + } + if (g_main_ctx == (yloop_ctx_t *)0x0) { + g_main_ctx = __s; + } + *(yloop_ctx_t **)&(__s->timeouts).prev = __s; + key = g_loop_key; + __s->eventfd = -1; + *(yloop_ctx_t **)&(__s->timeouts).next = __s; + aos_task_setspecific(key,__s); + aos_event_service_init(); + return __s; +} + + + +int aos_poll_read_fd(int sock,aos_poll_call_t *cb,void *private_data) + +{ + yloop_sock_t *__dest; + yloop_ctx_t *pyVar1; + pollfd *__dest_00; + uint uVar2; + int iVar3; + uint uVar4; + + pyVar1 = get_context(); + if (sock < 0) { + iVar3 = -0x16; + } + else { + uVar4 = (uint)pyVar1->reader_count; + __dest = (yloop_sock_t *)pvPortMalloc((uVar4 + 1) * 0xc); + __dest_00 = (pollfd *)pvPortMalloc((uVar4 + 1) * 8); + if ((__dest == (yloop_sock_t *)0x0) || (__dest_00 == (pollfd *)0x0)) { + printf("yloopout of memory"); + vPortFree(__dest); + vPortFree(__dest_00); + iVar3 = -0xc; + } + else { + uVar2 = aos_fcntl(sock,3,0); + aos_fcntl(sock,4,uVar2 | 0x4000); + pyVar1->reader_count = pyVar1->reader_count + '\x01'; + memcpy(__dest,pyVar1->readers,uVar4 * 0xc); + vPortFree(pyVar1->readers); + pyVar1->readers = __dest; + memcpy(__dest_00,pyVar1->pollfds,uVar4 << 3); + __dest = __dest + uVar4; + vPortFree(pyVar1->pollfds); + pyVar1->pollfds = __dest_00; + __dest->sock = sock; + __dest->private_data = private_data; + __dest->cb = cb; + iVar3 = 0; + if ((int)(uint)pyVar1->max_sock < sock) { + pyVar1->max_sock = (uint16_t)sock; + iVar3 = 0; + } + } + } + return iVar3; +} + + + +int aos_post_delayed_action(int ms,aos_call_t *action,void *param) + +{ + yloop_ctx_t *pyVar1; + dlist_s *pdVar2; + int iVar3; + pollfd *ppVar4; + aos_call_t *paVar5; + yloop_sock_t *pyVar6; + dlist_s *pdVar7; + yloop_ctx_t *pyVar8; + + if (action != (aos_call_t *)0x0) { + paVar5 = action; + pyVar1 = get_context(); + pdVar2 = (dlist_s *)pvPortMalloc(0x20); + iVar3 = -0xc; + if (pdVar2 != (dlist_s *)0x0) { + aos_now_ms(); + ppVar4 = (pollfd *)(iVar3 + ms); + pyVar6 = (yloop_sock_t *)(paVar5 + (uint)(ppVar4 < (uint)ms) + (ms >> 0x1f)); + *(pollfd **)&pdVar2[1].prev = ppVar4; + *(yloop_sock_t **)&pdVar2[1].next = pyVar6; + pdVar2[2].prev = param; + *(aos_call_t **)&pdVar2[2].next = action; + *(int *)&pdVar2[3].prev = ms; + pyVar8 = (yloop_ctx_t *)(pyVar1->timeouts).next; + while (((pyVar8 != pyVar1 && ((int)pyVar8->readers <= (int)pyVar6)) && + ((pyVar8->readers != pyVar6 || (pyVar8->pollfds <= ppVar4))))) { + pyVar8 = (yloop_ctx_t *)(pyVar8->timeouts).next; + } + pdVar7 = (pyVar8->timeouts).prev; + *(yloop_ctx_t **)&pdVar2->next = pyVar8; + iVar3 = 0; + pdVar2->prev = pdVar7; + pdVar7->next = pdVar2; + (pyVar8->timeouts).prev = pdVar2; + } + return iVar3; + } + return -0x16; +} + + + +void aos_loop_run(yloop_sock_t *param_1) + +{ + yloop_ctx_t *pyVar1; + yloop_sock_t *pyVar2; + yloop_ctx_t *pyVar3; + yloop_ctx_t *pyVar4; + yloop_sock_t *extraout_a1; + yloop_sock_t *extraout_a1_00; + yloop_ctx_t *pv; + dlist_s *pdVar5; + int iVar6; + dlist_s *pdVar7; + yloop_sock_t *pyVar8; + yloop_sock_t *nfds; + undefined4 extraout_fa0; + longlong lVar9; + + pyVar3 = get_context(); + pyVar4 = pyVar3; + while (pyVar3->terminate == false) { + pyVar1 = (yloop_ctx_t *)(pyVar3->timeouts).next; + nfds = (yloop_sock_t *)(uint)pyVar3->reader_count; + if ((pyVar3 == pyVar1) && (pyVar3->reader_count == 0)) break; + pv = (yloop_ctx_t *)0xffffffff; + if (pyVar3 != pyVar1) { + aos_now_ms(); + if (((int)param_1 < (int)pyVar1->readers) || + ((pyVar1->readers == param_1 && (pyVar4 < (yloop_ctx_t *)pyVar1->pollfds)))) { + pv = (yloop_ctx_t *)((int)(yloop_ctx_t *)pyVar1->pollfds - (int)pyVar4); + } + else { + pv = (yloop_ctx_t *)0x0; + } + } + iVar6 = 0; + while (iVar6 < (int)nfds) { + pyVar3->pollfds[iVar6].fd = pyVar3->readers[iVar6].sock; + pyVar3->pollfds[iVar6].events = 1; + iVar6 = iVar6 + 1; + } + param_1 = nfds; + pyVar1 = (yloop_ctx_t *)aos_poll(pyVar3->pollfds,(int)nfds,(int)pv); + pyVar4 = pyVar1; + if ((int)pyVar1 < 0) { + pyVar4 = (yloop_ctx_t *)__errno(); + param_1 = extraout_a1; + if ((pyVar4->timeouts).prev != (dlist_s *)0x4) { + printf("yloopaos_poll",extraout_fa0); + return; + } + } + pv = (yloop_ctx_t *)(pyVar3->timeouts).next; + if (pyVar3 != pv) { + lVar9 = aos_now_ms(); + if (((int)pv->readers <= (int)param_1) && + ((pv->readers != param_1 || ((yloop_ctx_t *)pv->pollfds <= pyVar4)))) { + pdVar7 = (pv->timeouts).next; + pdVar5 = (pv->timeouts).prev; + pdVar5->next = pdVar7; + pdVar7->prev = pdVar5; + param_1 = (yloop_sock_t *) + (**(code **)&pv->max_sock)(pv->eventfd,*(code **)&pv->max_sock,(int)lVar9); + vPortFree(pv); + pyVar4 = pv; + } + } + pyVar2 = (yloop_sock_t *)0x0; + if (0 < (int)pyVar1) { + while (pyVar2 != nfds) { + if ((pyVar3->pollfds[(int)pyVar2].revents & 1U) != 0) { + pyVar8 = pyVar3->readers + (int)pyVar2; + pyVar4 = (yloop_ctx_t *)(*pyVar8->cb)(pyVar8->sock,pyVar8->private_data); + param_1 = extraout_a1_00; + } + pyVar2 = (yloop_sock_t *)((int)&pyVar2->sock + 1); + } + } + } + pyVar3->terminate = false; + return; +} + + + +void vfs_poll_notify(pollfd *fd,void *arg) + +{ + aos_sem_signal((aos_sem_t *)arg); + return; +} + + + +int aos_poll(pollfd *fds,int nfds,int timeout) + +{ + ushort *puVar1; + int iVar2; + uint fd; + file_t *pfVar3; + ushort *puVar4; + int iVar5; + code *pcVar6; + int iVar7; + pollfd *ppVar8; + aos_sem_t aStack60; + poll_arg parg; + _types_fd_set rfds; + + aos_sem_new(&aStack60,0); + iVar5 = 0; + do { + *(undefined *)((int)&parg.sem.hdl + iVar5) = 0; + iVar5 = iVar5 + 1; + } while (iVar5 != 8); + puVar1 = (ushort *)&fds->revents; + iVar5 = 0; + puVar4 = puVar1; + while (iVar5 < nfds) { + *puVar4 = 0; + iVar5 = iVar5 + 1; + puVar4 = puVar4 + 4; + } + iVar5 = 0; + ppVar8 = fds; + do { + if (nfds <= iVar5) { + if (timeout < 0) { + timeout = 0xffffffff; + } + aos_sem_wait(&aStack60,timeout); + iVar5 = 0; + while (iVar5 < nfds) { + if ((1 << (*(uint *)(puVar1 + -3) & 0x1f) & + (uint)(&parg)[*(uint *)(puVar1 + -3) >> 5].sem.hdl) != 0) { + *puVar1 = *puVar1 | 1; + } + iVar5 = iVar5 + 1; + puVar1 = puVar1 + 4; + } + iVar5 = 0; +check_poll: + iVar2 = 0; + iVar7 = 0; + while (iVar7 < nfds) { + if (((1 < fds->fd) && (pfVar3 = get_file(fds->fd), pfVar3 != (file_t *)0x0)) && + (pcVar6 = *(code **)(pfVar3->node->ops + 0x14), (*pcVar6)(0,0,0,0,pcVar6), + fds->revents != 0)) { + iVar2 = iVar2 + 1; + } + iVar7 = iVar7 + 1; + fds = fds + 1; + } + aos_sem_free(&aStack60); + if (iVar5 != 0) { + iVar2 = 0; + } + return iVar2; + } + fd = ppVar8->fd; + if ((int)fd < 2) { + (&parg)[fd >> 5].sem.hdl = (void *)(1 << (fd & 0x1f) | (uint)(&parg)[fd >> 5].sem.hdl); + } + else { + pfVar3 = get_file(fd); + if (pfVar3 == (file_t *)0x0) { + iVar5 = -1; + goto check_poll; + } + pcVar6 = *(code **)(pfVar3->node->ops + 0x14); + (*pcVar6)(1,vfs_poll_notify,ppVar8,&aStack60,pcVar6); + } + iVar5 = iVar5 + 1; + ppVar8 = ppVar8 + 1; + } while( true ); +} + + + +int aos_fcntl(int fd,int cmd,int val) + +{ + int iVar1; + + iVar1 = -0x16; + if ((-1 < fd) && (iVar1 = 0, fd < 2)) { + iVar1 = -2; + } + return iVar1; +} + + + +void dfl_entry(void *arg) + +{ + code *pcVar1; + undefined4 uVar2; + + uVar2 = *(undefined4 *)((int)arg + 8); + pcVar1 = *(code **)((int)arg + 4); + vPortFree(arg); + (*pcVar1)(uVar2); + vTaskDelete((TaskHandle_t)0x0); + return; +} + + + +int aos_task_new(char *name,anon_subr_void_void_ptr *fn,void *arg,int stack_size) + +{ + StaticTask_t *pxTaskBuffer; + StaticTask_t **pvParameters; + StackType_t *puxStackBuffer; + TaskHandle_t ptVar1; + int iVar2; + + pxTaskBuffer = (StaticTask_t *)pvPortMalloc(0x9c); + pvParameters = (StaticTask_t **)pvPortMalloc(0xc); + puxStackBuffer = (StackType_t *)pvPortMalloc(stack_size); + memset(puxStackBuffer,0,stack_size); + memset(pxTaskBuffer,0,0x9c); + pxTaskBuffer[1].pxDummy1 = (void *)0xfffffff0; + *(StackType_t **)(pxTaskBuffer[1].xDummy3[0].pvDummy3 + 3) = puxStackBuffer; + strncpy((char *)(pxTaskBuffer[1].xDummy3 + 1),name,0x1f); + *(undefined4 *)(pxTaskBuffer[1].ucDummy7 + 4) = 0x20171020; + *pvParameters = pxTaskBuffer; + *(anon_subr_void_void_ptr **)(pvParameters + 1) = fn; + pvParameters[2] = arg; + ptVar1 = xTaskCreateStatic(dfl_entry,name,(uint)stack_size >> 2,pvParameters,10,puxStackBuffer, + pxTaskBuffer); + if (ptVar1 == (TaskHandle_t)0x0) { + vPortFree(pxTaskBuffer); + vPortFree(puxStackBuffer); + vPortFree(pvParameters); + iVar2 = -1; + } + else { + iVar2 = 0; + } + return iVar2; +} + + + +void aos_task_exit(int code) + +{ + vTaskDelete((TaskHandle_t)0x0); + return; +} + + + +int aos_task_key_create(aos_task_key_t *key) + +{ + TaskHandle_t ptVar1; + uint uVar2; + aos_task_key_t aVar3; + int iVar4; + StackType_t *pSVar5; + + ptVar1 = xTaskGetCurrentTaskHandle(); + if (*(int *)(ptVar1[1].pcTaskName + 4) == 0x20171020) { + pSVar5 = ptVar1[1].pxTopOfStack; + if (((uint)pSVar5 & 1) == 0) { + aVar3 = 0; + uVar2 = 1; + } + else { + if (((uint)pSVar5 & 2) == 0) { + aVar3 = 1; + uVar2 = 2; + } + else { + if (((uint)pSVar5 & 4) == 0) { + aVar3 = 2; + uVar2 = 4; + } + else { + if (((uint)pSVar5 & 8) != 0) { + return -1; + } + aVar3 = 3; + uVar2 = 8; + } + } + } + ptVar1[1].pxTopOfStack = (StackType_t *)((uint)pSVar5 | uVar2); + *key = aVar3; + iVar4 = 0; + } + else { + iVar4 = -1; + } + return iVar4; +} + + + +int aos_task_setspecific(aos_task_key_t key,void *vp) + +{ + TaskHandle_t ptVar1; + int iVar2; + + ptVar1 = xTaskGetCurrentTaskHandle(); + if (key < 4) { + iVar2 = -1; + if (*(int *)(ptVar1[1].pcTaskName + 4) == 0x20171020) { + *(void **)(&(ptVar1->xStateListItem).xItemValue + key + 0x18) = vp; + iVar2 = 0; + } + } + else { + iVar2 = -1; + } + return iVar2; +} + + + +void * aos_task_getspecific(aos_task_key_t key) + +{ + TaskHandle_t ptVar1; + void *pvVar2; + + ptVar1 = xTaskGetCurrentTaskHandle(); + if (key < 4) { + pvVar2 = (void *)0x0; + if (*(int *)(ptVar1[1].pcTaskName + 4) == 0x20171020) { + pvVar2 = (void *)(&(ptVar1->xStateListItem).xItemValue)[key + 0x18]; + } + } + else { + pvVar2 = (void *)0x0; + } + return pvVar2; +} + + + +int aos_mutex_new(aos_mutex_t *mutex) + +{ + QueueHandle_t pQVar1; + + pQVar1 = xQueueCreateMutex('\x01'); + *(QueueHandle_t *)&mutex->hdl = pQVar1; + return -(uint)(pQVar1 == (QueueHandle_t)0x0); +} + + + +void aos_mutex_free(aos_mutex_t *mutex) + +{ + vQueueDelete((QueueHandle_t)mutex->hdl); + return; +} + + + +int aos_mutex_lock(aos_mutex_t *mutex,uint ms) + +{ + if (mutex != (aos_mutex_t *)0x0) { + xQueueSemaphoreTake((QueueHandle_t)mutex->hdl,ms); + return 0; + } + return 0; +} + + + +int aos_mutex_unlock(aos_mutex_t *mutex) + +{ + if (mutex != (aos_mutex_t *)0x0) { + xQueueGenericSend((QueueHandle_t)mutex->hdl,(void *)0x0,0,0); + return 0; + } + return 0; +} + + + +int aos_sem_new(aos_sem_t *sem,int count) + +{ + QueueHandle_t pQVar1; + + pQVar1 = xQueueCreateCountingSemaphore(0x80,count); + *(QueueHandle_t *)&sem->hdl = pQVar1; + return 0; +} + + + +void aos_sem_free(aos_sem_t *sem) + +{ + if (sem != (aos_sem_t *)0x0) { + vQueueDelete((QueueHandle_t)sem->hdl); + return; + } + return; +} + + + +int aos_sem_wait(aos_sem_t *sem,uint ms) + +{ + BaseType_t BVar1; + + if (sem != (aos_sem_t *)0x0) { + BVar1 = xQueueSemaphoreTake((QueueHandle_t)sem->hdl,ms); + return -(uint)(BVar1 != 1); + } + return -1; +} + + + +void aos_sem_signal(aos_sem_t *sem) + +{ + BaseType_t BStack20; + BaseType_t xHigherPriorityTaskWoken; + + BStack20 = 0; + if (sem != (aos_sem_t *)0x0) { + if (TrapNetCounter == 0) { + xQueueGenericSend((QueueHandle_t)sem->hdl,(void *)0x0,0,0); + } + else { + xQueueGiveFromISR((QueueHandle_t)sem->hdl,&BStack20); + if (BStack20 != 0) { + vTaskSwitchContext(); + } + } + } + return; +} + + + +void * aos_malloc(size_t xWantedSize) + +{ + size_t sVar1; + size_t sVar2; + BlockLink_t *pBVar3; + A_BLOCK_LINK *pAVar4; + BlockLink_t *pxBlockToInsert; + uint uVar5; + uint uVar6; + + if (pxEnd == (BlockLink_t *)0x0) { + vAssertCalled(); + } + vTaskSuspendAll(); + sVar2 = xFreeBytesRemaining; + sVar1 = xBlockAllocatedBit; + if (((xBlockAllocatedBit & xWantedSize) == 0) && (xWantedSize != 0)) { + uVar6 = xWantedSize + 8; + if ((uVar6 & 7) != 0) { + uVar6 = (uVar6 & 0xfffffff8) + 8; + } + if ((uVar6 != 0) && (uVar6 <= xFreeBytesRemaining)) { + pAVar4 = xStart.pxNextFreeBlock; + pBVar3 = &xStart; + do { + pxBlockToInsert = pBVar3; + pBVar3 = (BlockLink_t *)pAVar4; + if (uVar6 <= pBVar3->xBlockSize) break; + pAVar4 = pBVar3->pxNextFreeBlock; + } while (pBVar3->pxNextFreeBlock != (A_BLOCK_LINK *)0x0); + if (pxEnd != pBVar3) { + pAVar4 = pxBlockToInsert->pxNextFreeBlock; + pxBlockToInsert->pxNextFreeBlock = pBVar3->pxNextFreeBlock; + uVar5 = pBVar3->xBlockSize; + pAVar4 = pAVar4 + 1; + if (0x10 < uVar5 - uVar6) { + pxBlockToInsert = (BlockLink_t *)((int)&pBVar3->pxNextFreeBlock + uVar6); + pxBlockToInsert->xBlockSize = uVar5 - uVar6; + pBVar3->xBlockSize = uVar6; + prvInsertBlockIntoFreeList(pxBlockToInsert); + uVar5 = pBVar3->xBlockSize; + } + xFreeBytesRemaining = sVar2 - uVar5; + if (xFreeBytesRemaining < xMinimumEverFreeBytesRemaining) { + xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; + } + pBVar3->xBlockSize = sVar1 | uVar5; + pBVar3->pxNextFreeBlock = (A_BLOCK_LINK *)0x0; + xTaskResumeAll(); + if (pAVar4 != (A_BLOCK_LINK *)0x0) { + return pAVar4; + } + goto LAB_230321be; + } + } + } + xTaskResumeAll(); +LAB_230321be: + vApplicationMallocFailedHook(); + return (void *)0x0; +} + + + +void aos_free(void *pv) + +{ + uint uVar1; + + if (pv == (void *)0x0) { + return; + } + uVar1 = *(uint *)((int)pv + -4); + if ((uVar1 & xBlockAllocatedBit) == 0) { + vAssertCalled(); + if (*(int *)((int)pv + -8) == 0) { + uVar1 = *(uint *)((int)pv + -4); + if ((uVar1 & xBlockAllocatedBit) == 0) { + return; + } + goto LAB_230322ce; + } + } + else { + if (*(int *)((int)pv + -8) == 0) goto LAB_230322ce; + } + vAssertCalled(); + uVar1 = *(uint *)((int)pv + -4); + if (((uVar1 & xBlockAllocatedBit) == 0) || (*(int *)((int)pv + -8) != 0)) { + return; + } +LAB_230322ce: + *(uint *)((int)pv + -4) = ~xBlockAllocatedBit & uVar1; + vTaskSuspendAll(); + xFreeBytesRemaining = *(int *)((int)pv + -4) + xFreeBytesRemaining; + prvInsertBlockIntoFreeList((BlockLink_t *)((int)pv + -8)); + xTaskResumeAll(); + return; +} + + + +longlong aos_now_ms(void) + +{ + BaseType_t BVar1; + longlong in_fa0; + TickType_t TStack24; + TickType_t ticks; + BaseType_t overflow_count; + + TStack24 = 0; + ticks = 0; + BVar1 = xTaskGetTickCount2(&TStack24,(BaseType_t *)&ticks); + if (BVar1 != 1) { + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + return in_fa0; +} + + + +int event_poll(file_t *f,_Bool setup,poll_notify_t *notify,pollfd *fd,void *opa) + +{ + aos_mutex_t *mutex; + undefined3 in_register_0000202d; + + mutex = (aos_mutex_t *)f->f_arg; + aos_mutex_lock(mutex,0xffffffff); + if (CONCAT31(in_register_0000202d,setup) == 0) { + mutex[1].hdl = (void *)0x0; + mutex[3].hdl = (void *)0x0; + } + else { + *(poll_notify_t **)&mutex[1].hdl = notify; + *(pollfd **)&mutex[2].hdl = fd; + mutex[3].hdl = opa; + if (mutex[4].hdl != (void *)0x0) { + fd->revents = fd->revents | 1; + (*notify)(fd,opa); + } + } + aos_mutex_unlock(mutex); + return 0; +} + + + +int event_open(inode_t *node,file_t *file) + +{ + aos_mutex_t *mutex; + + mutex = (aos_mutex_t *)aos_malloc(0x28); + memset(mutex,0,0x28); + aos_mutex_new(mutex); + *(aos_mutex_t **)&mutex[5].hdl = mutex + 5; + *(aos_mutex_t **)&mutex[6].hdl = mutex + 5; + *(aos_mutex_t **)&mutex[8].hdl = mutex + 8; + *(aos_mutex_t **)&mutex[9].hdl = mutex + 8; + *(aos_mutex_t **)&file->f_arg = mutex; + return 0; +} + + + +ssize_t _event_write(void *buf,size_t len,_Bool urgent) + +{ + int *piVar1; + undefined3 in_register_00002031; + int in_a3; + int iVar2; + int *piVar3; + int **ppiVar4; + size_t __n; + + __n = CONCAT31(in_register_00002031,urgent); + aos_mutex_lock((aos_mutex_t *)buf,0xffffffff); + if ((*(int *)((int)buf + 0x1c) < 1) || (piVar1 = *(int **)((int)buf + 0x24), __n != piVar1[2])) { + piVar1 = (int *)aos_malloc(__n + 0xc); + if (piVar1 == (int *)0x0) { + __n = 0xffffffff; + goto out; + } + } + else { + piVar3 = (int *)piVar1[1]; + iVar2 = *piVar1; + *(int **)(iVar2 + 4) = piVar3; + *piVar3 = iVar2; + *(int *)((int)buf + 0x1c) = *(int *)((int)buf + 0x1c) + -1; + } + *(int *)((int)buf + 0x10) = *(int *)((int)buf + 0x10) + 1; + piVar1[2] = __n; + memcpy(piVar1 + 3,(void *)len,__n); + if (in_a3 == 0) { + iVar2 = *(int *)((int)buf + 0x14); + piVar1[1] = (int)buf + 0x14; + *piVar1 = iVar2; + *(int **)(iVar2 + 4) = piVar1; + *(int **)((int)buf + 0x14) = piVar1; + } + else { + ppiVar4 = *(int ***)((int)buf + 0x18); + *piVar1 = (int)buf + 0x14; + *(int ***)(piVar1 + 1) = ppiVar4; + *(int **)((int)buf + 0x18) = piVar1; + *ppiVar4 = piVar1; + } + if (*(int *)((int)buf + 4) != 0) { + *(ushort *)(*(int *)((int)buf + 8) + 6) = *(ushort *)(*(int *)((int)buf + 8) + 6) | 1; + (**(code **)((int)buf + 4)) + (*(undefined4 *)((int)buf + 8),*(undefined4 *)((int)buf + 0xc), + *(code **)((int)buf + 4)); + } +out: + aos_mutex_unlock((aos_mutex_t *)buf); + return __n; +} + + + +int event_ioctl(file_t *f,int cmd,ulong arg) + +{ + ssize_t sVar1; + + if (((cmd & 0xfU) != 1) && ((cmd & 0xfU) != 2)) { + return -1; + } + sVar1 = _event_write(f->f_arg,arg,SUB41(cmd >> 4,0)); + return sVar1; +} + + + +ssize_t event_write(file_t *f,void *buf,size_t len) + +{ + ssize_t sVar1; + + sVar1 = _event_write(f->f_arg,(size_t)buf,SUB41(len,0)); + return sVar1; +} + + + +int event_close(file_t *file) + +{ + aos_mutex_t *mutex; + aos_mutex_t *pv; + void *pvVar1; + void **ppvVar2; + + mutex = (aos_mutex_t *)file->f_arg; + aos_mutex_free(mutex); + while (pv = (aos_mutex_t *)mutex[6].hdl, pv != mutex + 5) { + pvVar1 = pv->hdl; + ppvVar2 = (void **)pv[1].hdl; + *(void ***)((int)pvVar1 + 4) = ppvVar2; + *ppvVar2 = pvVar1; + aos_free(pv); + } + while (pv = (aos_mutex_t *)mutex[9].hdl, pv != mutex + 8) { + pvVar1 = pv->hdl; + ppvVar2 = (void **)pv[1].hdl; + *(void ***)((int)pvVar1 + 4) = ppvVar2; + *ppvVar2 = pvVar1; + aos_free(pv); + } + aos_free(mutex); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling + +ssize_t event_read(file_t *f,void *buf,size_t len) + +{ + aos_mutex_t *mutex; + void *pv; + int iVar1; + int *piVar2; + void **ppvVar3; + uint __n; + + mutex = (aos_mutex_t *)f->f_arg; + __n = (uint)mutex[4].hdl; + if (__n != 0) { + aos_mutex_lock(mutex,0xffffffff); + pv = mutex[6].hdl; + iVar1 = *(int *)pv; + piVar2 = *(int **)((int)pv + 4); + *(int **)(iVar1 + 4) = piVar2; + *piVar2 = iVar1; + __n = *(uint *)((int)pv + 8); + if (len < *(uint *)((int)pv + 8)) { + __n = len; + } + memcpy(buf,(void *)((int)pv + 0xc),__n); + if ((int)mutex[7].hdl < 4) { + ppvVar3 = (void **)mutex[9].hdl; + *(aos_mutex_t **)pv = mutex + 8; + *(void ***)((int)pv + 4) = ppvVar3; + mutex[9].hdl = pv; + *ppvVar3 = pv; + mutex[7].hdl = (void *)((int)mutex[7].hdl + 1); + } + else { + aos_free(pv); + } + mutex[4].hdl = (void *)((int)mutex[4].hdl + -1); + aos_mutex_unlock(mutex); + } + return __n; +} + + + +int vfs_device_init(void) + +{ + int iVar1; + + iVar1 = 0; + if ((inited != 1) && + (iVar1 = aos_register_driver("/dev/event",(file_ops_t *)&event_fops,(void *)0x0), iVar1 == 0)) + { + inited = 1; + } + return iVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void event_read_cb(int fd,void *param) + +{ + dlist_s *pdVar1; + ssize_t sVar2; + undefined auStack32 [4]; + input_event_t event; + + sVar2 = aos_read(fd,auStack32,0x10); + if (sVar2 == 0x10) { + pdVar1 = g_local_event_list.next; + if ((short)event.time == 0x100) { + (*event._4_4_)(event.value,event._4_4_); + } + else { + while (pdVar1 != (dlist_s *)&g_local_event_list) { + if ((*(short *)&((dlist_t *)pdVar1)[2].prev == 0) || + ((short)event.time == *(short *)&((dlist_t *)pdVar1)[2].prev)) { + (*(code *)((dlist_t *)pdVar1)[1].prev) + (auStack32,((dlist_t *)pdVar1)[1].next,((dlist_t *)pdVar1)[1].prev); + } + pdVar1 = ((dlist_t *)pdVar1)->next; + } + } + } + return; +} + + + +int aos_event_service_init(void) + +{ + int sock; + + sock = aos_open("/dev/event",0); + if (local_event.fd < 0) { + local_event.fd = sock; + } + aos_poll_read_fd(sock,event_read_cb,(void *)0x0); + aos_loop_set_eventfd(sock); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int aos_post_event(uint16_t type,uint16_t code,ulong value) + +{ + undefined2 in_register_0000202a; + int iVar1; + undefined4 local_20; + input_event_t event; + + event.time._0_2_ = (ushort)((CONCAT22(in_register_0000202a,type) << 0x11) >> 0x11); + local_20 = 0; + event.value = 0; + event.time._2_2_ = code; + event._4_4_ = value; + iVar1 = aos_ioctl(local_event.fd,(CONCAT22(in_register_0000202a,type) >> 0xf) + 0x101, + (ulong)&local_20); + return iVar1; +} + + + +int aos_register_event_filter(uint16_t type,aos_event_cb *cb,void *priv) + +{ + dlist_s *pdVar1; + int iVar2; + + if (cb != (aos_event_cb *)0x0) { + pdVar1 = (dlist_s *)aos_malloc(0x14); + iVar2 = -0xc; + if (pdVar1 != (dlist_s *)0x0) { + *(aos_event_cb **)&pdVar1[1].prev = cb; + *(uint16_t *)&pdVar1[2].prev = type; + pdVar1->prev = g_local_event_list.prev; + pdVar1[1].next = priv; + *(dlist_t **)&pdVar1->next = &g_local_event_list; + (g_local_event_list.prev)->next = pdVar1; + iVar2 = 0; + g_local_event_list.prev = pdVar1; + } + return iVar2; + } + return -0x16; +} + + + +// WARNING: Could not reconcile some variable overlaps + +IoT_Error_t aws_iot_shadow_init(AWS_IoT_Client *pClient,ShadowInitParameters_t *pParams) + +{ + IoT_Error_t IVar1; + undefined3 extraout_var; + _Bool a_Stack68 [4]; + IoT_Client_Init_Params mqttInitParams; + + memcpy(a_Stack68,&DAT_230879c0,0x34); + IVar1 = NULL_VALUE_ERROR; + if ((pClient != (AWS_IoT_Client *)0x0) && (pParams != (ShadowInitParameters_t *)0x0)) { + a_Stack68[0] = pParams->enableAutoReconnect; + mqttInitParams._0_4_ = pParams->pHost; + mqttInitParams.pHostURL._0_2_ = pParams->port; + mqttInitParams._8_4_ = pParams->pRootCA; + mqttInitParams.pRootCALocation = pParams->pClientCRT; + mqttInitParams.pDeviceCertLocation = pParams->pClientKey; + mqttInitParams.pDevicePrivateKeyLocation = (char *)0x1388; + mqttInitParams.tlsHandshakeTimeout_ms._0_1_ = true; + mqttInitParams._36_4_ = pParams->disconnectHandler; + IVar1 = aws_iot_mqtt_init(pClient,(IoT_Client_Init_Params *)a_Stack68); + if (CONCAT31(extraout_var,IVar1) == 0) { + resetClientTokenSequenceNum(); + shadowJsonVersionNum = 0; + initDeltaTokens(); + } + } + return IVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +IoT_Error_t +aws_iot_shadow_connect(AWS_IoT_Client *pClient,ShadowConnectParameters_t_conflict6 *pParams) + +{ + IoT_Error_t IVar1; + undefined3 extraout_var; + size_t sVar2; + undefined auStack88 [4]; + IoT_Client_Connect_Params ConnectParams; + + IVar1 = NULL_VALUE_ERROR; + memcpy(auStack88,&iotClientConnectParamsDefault,0x38); + if (((pClient != (AWS_IoT_Client *)0x0) && (pParams != (ShadowConnectParameters_t_conflict6 *)0x0) + ) && (pParams->pMqttClientId != (char *)0x0)) { + snprintf(myThingName,0x14,"%s",pParams->pMyThingName); + snprintf(mqttClientID,0x50,"%s",pParams->pMqttClientId); + ConnectParams.struct_id[0] = MQTT_3_1_1; + ConnectParams.pClientID._2_2_ = 600; + ConnectParams.clientIDLen = 1; + ConnectParams._4_4_ = pParams->pMqttClientId; + ConnectParams.pClientID._0_2_ = pParams->mqttClientIdLen; + ConnectParams._44_4_ = (char *)0x0; + ConnectParams.will._16_4_ = (char *)0x0; + IVar1 = aws_iot_mqtt_connect(pClient,(IoT_Client_Connect_Params *)auStack88); + if (CONCAT31(extraout_var,IVar1) == 0) { + initializeRecords(pClient); + if (pParams->deleteActionHandler != (pApplicationHandler_t *)0x0) { + snprintf(deleteAcceptedTopic,0x50,"$aws/things/%s/shadow/delete/accepted",myThingName); + sVar2 = strlen(deleteAcceptedTopic); + IVar1 = aws_iot_mqtt_subscribe + (pClient,deleteAcceptedTopic,(uint16_t)sVar2,QOS1, + pParams->deleteActionHandler,myThingName); + } + } + } + return IVar1; +} + + + +IoT_Error_t aws_iot_shadow_register_delta(AWS_IoT_Client *pMqttClient,jsonStruct_t *pStruct) + +{ + _Bool _Var1; + IoT_Error_t IVar2; + undefined3 extraout_var; + + if ((pMqttClient != (AWS_IoT_Client *)0x0) && (pStruct != (jsonStruct_t *)0x0)) { + _Var1 = aws_iot_mqtt_is_client_connected(pMqttClient); + if (CONCAT31(extraout_var,_Var1) != 0) { + IVar2 = registerJsonTokenOnDelta(pStruct); + return IVar2; + } + return MQTT_CONNECTION_ERROR; + } + return NULL_VALUE_ERROR; +} + + + +IoT_Error_t aws_iot_shadow_yield(AWS_IoT_Client *pClient,uint32_t timeout) + +{ + IoT_Error_t IVar1; + + if (pClient != (AWS_IoT_Client *)0x0) { + HandleExpiredResponseCallbacks(); + IVar1 = aws_iot_mqtt_yield(pClient,timeout); + return IVar1; + } + return NULL_VALUE_ERROR; +} + + + +IoT_Error_t aws_iot_shadow_disconnect(AWS_IoT_Client *pClient) + +{ + ClientState CVar1; + _Bool _Var2; + IoT_Error_t IVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + int iVar4; + undefined3 extraout_var_01; + + if (pClient != (AWS_IoT_Client *)0x0) { + CVar1 = aws_iot_mqtt_get_client_state(pClient); + _Var2 = aws_iot_mqtt_is_client_connected(pClient); + IVar3 = NETWORK_DISCONNECTED_ERROR; + if (CONCAT31(extraout_var_00,_Var2) != 0) { + iVar4 = aws_iot_mqtt_set_client_state(pClient,CONCAT31(extraout_var,CVar1),10); + IVar3 = (IoT_Error_t)iVar4; + if (iVar4 == 0) { + IVar3 = _aws_iot_mqtt_internal_disconnect(pClient); + if (CONCAT31(extraout_var_01,IVar3) == 0) { + (pClient->clientStatus).clientState = CLIENT_STATE_DISCONNECTED_MANUALLY; + } + else { + (pClient->clientStatus).clientState = CVar1; + } + } + } + return IVar3; + } + return NULL_VALUE_ERROR; +} + + + +IoT_Error_t +aws_iot_shadow_update + (AWS_IoT_Client *pClient,char *pThingName,char *pJsonString,fpActionCallback_t *callback, + void *pContextData,uint8_t timeout_seconds,_Bool isPersistentSubscribe) + +{ + _Bool _Var1; + IoT_Error_t IVar2; + undefined3 extraout_var; + size_t jsonSize; + undefined3 in_register_0000203d; + + if (pClient == (AWS_IoT_Client *)0x0) { + return NULL_VALUE_ERROR; + } + _Var1 = aws_iot_mqtt_is_client_connected(pClient); + if (CONCAT31(extraout_var,_Var1) != 0) { + jsonSize = strlen(pJsonString); + IVar2 = aws_iot_shadow_internal_action + (pThingName,SHADOW_UPDATE,pJsonString,jsonSize,callback,pContextData, + CONCAT31(in_register_0000203d,timeout_seconds),isPersistentSubscribe); + return IVar2; + } + return MQTT_CONNECTION_ERROR; +} + + + +IoT_Error_t aws_iot_shadow_set_autoreconnect_status(AWS_IoT_Client *pClient,_Bool newStatus) + +{ + if (pClient != (AWS_IoT_Client *)0x0) { + (pClient->clientStatus).isAutoReconnectEnabled = newStatus; + return SUCCESS; + } + return NULL_VALUE_ERROR; +} + + + +IoT_Error_t +aws_iot_shadow_internal_action + (char *pThingName,ShadowActions_t action,char *pJsonDocumentToBeSent,size_t jsonSize, + fpActionCallback_t *callback,void *pCallbackContext,uint32_t timeout_seconds, + _Bool isSticky) + +{ + _Bool _Var1; + _Bool _Var2; + _Bool _Var3; + IoT_Error_t IVar4; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + int iVar5; + uint8_t uStack141; + char acStack140 [3]; + uint8_t indexAckWaitList; + char extractedClientToken [90]; + + IVar4 = NULL_VALUE_ERROR; + if ((pThingName != (char *)0x0) && (pJsonDocumentToBeSent != (char *)0x0)) { + _Var1 = extractClientToken(pJsonDocumentToBeSent,jsonSize,acStack140,0x5a); + if ((CONCAT31(extraout_var,_Var1) == 0) || (callback == (fpActionCallback_t *)0x0)) { + iVar5 = 0; + } + else { + _Var2 = getNextFreeIndexOfAckWaitList(&uStack141); + if (CONCAT31(extraout_var_00,_Var2) == 0) { + return FAILURE; + } + _Var3 = isSubscriptionPresent(pThingName,action); + iVar5 = CONCAT31(extraout_var_01,_Var3); + if (iVar5 == 0) { + IVar4 = subscribeToShadowActionAcks(pThingName,action,isSticky); + iVar5 = CONCAT31(extraout_var_00,_Var2); + if (CONCAT31(extraout_var_02,IVar4) != 0) { + return IVar4; + } + } + else { + incrementSubscriptionCnt(pThingName,action,isSticky); + } + } + IVar4 = publishToShadowAction(pThingName,action,pJsonDocumentToBeSent); + if ((((CONCAT31(extraout_var,_Var1) != 0) && (callback != (fpActionCallback_t *)0x0)) && + (CONCAT31(extraout_var_03,IVar4) == 0)) && (iVar5 != 0)) { + addToAckWaitList(uStack141,pThingName,action,acStack140,callback,pCallbackContext, + timeout_seconds); + } + } + return IVar4; +} + + + +IoT_Error_t +convertDataToString(char *pStringBuffer,size_t maxSizoStringBuffer,JsonPrimitiveType type, + void *pData) + +{ + uint uVar1; + undefined3 in_register_00002031; + int iVar2; + char *__format; + char *pcVar3; + IoT_Error_t IVar4; + size_t sVar5; + + iVar2 = CONCAT31(in_register_00002031,type); + if (maxSizoStringBuffer == 0) { + return SHADOW_JSON_ERROR; + } + if (iVar2 == 0) { + pcVar3 = *(char **)pData; + __format = "%li,"; +LAB_2304db20: + uVar1 = snprintf(pStringBuffer,maxSizoStringBuffer,__format,pcVar3); + } + else { + if (iVar2 == 1) { + pcVar3 = (char *)(int)*(short *)pData; + __format = "%hi,"; + goto LAB_2304db20; + } + if (iVar2 == 2) { + pcVar3 = (char *)(int)*(char *)pData; + __format = "%hhi,"; + goto LAB_2304db20; + } + if (iVar2 == 3) { + pcVar3 = *(char **)pData; + __format = "%lu,"; + goto LAB_2304db20; + } + if (iVar2 == 4) { + pcVar3 = (char *)(uint)*(ushort *)pData; + __format = "%hu,"; + goto LAB_2304db20; + } + if (iVar2 == 5) { + pcVar3 = (char *)(uint)*(byte *)pData; + __format = "%hhu,"; + goto LAB_2304db20; + } + if (iVar2 == 7) { + pcVar3 = *(char **)pData; + sVar5 = *(size_t *)((int)pData + 4); + } + else { + if (iVar2 != 6) { + if (iVar2 == 8) { + if (*(char *)pData == '\0') { + pcVar3 = "false"; + } + else { + pcVar3 = "true"; + } +LAB_2304dbe6: + iVar2 = -0x538; + } + else { + pcVar3 = (char *)pData; + if (iVar2 != 9) { + uVar1 = 0; + if (iVar2 != 10) goto LAB_2304dc16; + goto LAB_2304dbe6; + } + iVar2 = -0x534; + } + __format = "ERROR failed! net_set_(non)block() returned -0x%x\r\n" + iVar2 + 0x14; + goto LAB_2304db20; + } + pcVar3 = pStringBuffer; + sVar5 = maxSizoStringBuffer; + __extendsfdf2((SFtype)pStringBuffer); + } + uVar1 = snprintf(pStringBuffer,maxSizoStringBuffer,"%f,",pcVar3,sVar5); + } + if ((int)uVar1 < 0) { + return SHADOW_JSON_ERROR; + } +LAB_2304dc16: + IVar4 = SUCCESS; + if (maxSizoStringBuffer <= uVar1) { + IVar4 = SHADOW_JSON_BUFFER_TRUNCATED; + } + return IVar4; +} + + + +void resetClientTokenSequenceNum(void) + +{ + clientTokenNum = 0; + return; +} + + + +IoT_Error_t aws_iot_shadow_init_json_document(char *pJsonDocument,size_t maxSizeOfJsonDocument) + +{ + uint uVar1; + IoT_Error_t IVar2; + + if (pJsonDocument != (char *)0x0) { + uVar1 = snprintf(pJsonDocument,maxSizeOfJsonDocument,"{\"state\":{"); + IVar2 = SHADOW_JSON_ERROR; + if ((-1 < (int)uVar1) && (IVar2 = SUCCESS, maxSizeOfJsonDocument <= uVar1)) { + IVar2 = SHADOW_JSON_BUFFER_TRUNCATED; + } + return IVar2; + } + return NULL_VALUE_ERROR; +} + + + +IoT_Error_t +aws_iot_shadow_add_reported(char *pJsonDocument,size_t maxSizeOfJsonDocument,uint8_t count,...) + +{ + int *piVar1; + IoT_Error_t IVar2; + size_t sVar3; + uint uVar4; + undefined3 extraout_var; + int *in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + int iVar5; + uint __maxlen; + int **ppiStack84; + va_list pArgs; + int *piStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + ppiStack84 = &piStack20; + if (pJsonDocument == (char *)0x0) { +LAB_2304dc88: + IVar2 = NULL_VALUE_ERROR; + } + else { + piStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + sVar3 = strlen(pJsonDocument); + __maxlen = maxSizeOfJsonDocument - sVar3; + if (__maxlen < 2) { +LAB_2304dcb6: + IVar2 = SHADOW_JSON_ERROR; + } + else { + sVar3 = strlen(pJsonDocument); + uVar4 = snprintf(pJsonDocument + sVar3,__maxlen,"\"reported\":{"); + IVar2 = SHADOW_JSON_ERROR; + if (-1 < (int)uVar4) { + iVar5 = 0; + if (uVar4 < __maxlen) { + while (iVar5 < _count) { + sVar3 = strlen(pJsonDocument); + __maxlen = maxSizeOfJsonDocument - sVar3; + if (__maxlen < 2) goto LAB_2304dcb6; + piVar1 = *ppiStack84; + ppiStack84 = ppiStack84 + 1; + if (piVar1 == (int *)0x0) goto LAB_2304dc88; + sVar3 = strlen(pJsonDocument); + uVar4 = snprintf(pJsonDocument + sVar3,__maxlen,"\"%s\":",*piVar1); + if ((int)uVar4 < 0) goto LAB_2304dcb6; + if (__maxlen <= uVar4) goto LAB_2304dd10; + if ((*piVar1 == 0) || (piVar1[1] == 0)) goto LAB_2304dc88; + sVar3 = strlen(pJsonDocument); + IVar2 = convertDataToString(pJsonDocument + sVar3,__maxlen, + *(JsonPrimitiveType *)(piVar1 + 3),(void *)piVar1[1]); + if (CONCAT31(extraout_var,IVar2) != 0) { + return IVar2; + } + iVar5 = (iVar5 + 1) * 0x1000000 >> 0x18; + } + sVar3 = strlen(pJsonDocument); + uVar4 = snprintf(pJsonDocument + (sVar3 - 1),__maxlen,"},"); + if ((int)uVar4 < 0) { + return SHADOW_JSON_ERROR; + } + if (uVar4 < __maxlen) { + return SUCCESS; + } + } +LAB_2304dd10: + IVar2 = SHADOW_JSON_BUFFER_TRUNCATED; + } + } + } + return IVar2; +} + + + +int32_t FillWithClientTokenSize + (char *pBufferToBeUpdatedWithClientToken,size_t maxSizeOfJsonDocument) + +{ + int iVar1; + + clientTokenNum = clientTokenNum + 1; + iVar1 = snprintf(pBufferToBeUpdatedWithClientToken,maxSizeOfJsonDocument,"%s-%d",mqttClientID); + return iVar1; +} + + + +IoT_Error_t aws_iot_finalize_json_document(char *pJsonDocument,size_t maxSizeOfJsonDocument) + +{ + size_t sVar1; + uint uVar2; + uint __maxlen; + + if (pJsonDocument == (char *)0x0) { + return NULL_VALUE_ERROR; + } + sVar1 = strlen(pJsonDocument); + __maxlen = maxSizeOfJsonDocument - sVar1; + if (1 < __maxlen) { + sVar1 = strlen(pJsonDocument); + uVar2 = snprintf(pJsonDocument + (sVar1 - 1),__maxlen,"}, \"%s\":\"","clientToken"); + if (-1 < (int)uVar2) { + if (__maxlen <= uVar2) { + return SHADOW_JSON_BUFFER_TRUNCATED; + } + sVar1 = strlen(pJsonDocument); + __maxlen = maxSizeOfJsonDocument - sVar1; + if (1 < __maxlen) { + sVar1 = strlen(pJsonDocument); + uVar2 = FillWithClientTokenSize(pJsonDocument + sVar1,__maxlen); + if (-1 < (int)uVar2) { + if (__maxlen <= uVar2) { + return SHADOW_JSON_BUFFER_TRUNCATED; + } + sVar1 = strlen(pJsonDocument); + __maxlen = maxSizeOfJsonDocument - sVar1; + if (1 < __maxlen) { + sVar1 = strlen(pJsonDocument); + uVar2 = snprintf(pJsonDocument + sVar1,__maxlen,"\"}"); + if (-1 < (int)uVar2) { + if (__maxlen <= uVar2) { + return SHADOW_JSON_BUFFER_TRUNCATED; + } + return SUCCESS; + } + } + } + } + } + } + return SHADOW_JSON_ERROR; +} + + + +_Bool isJsonValidAndParse(char *pJsonDocument,size_t jsonSize,void *pJsonHandler, + int32_t *pTokenCount) + +{ + int iVar1; + undefined uVar2; + + jsmn_init(&shadowJsonParser); + iVar1 = jsmn_parse(&shadowJsonParser,pJsonDocument,jsonSize,jsonTokenStruct,0x78); + uVar2 = 0; + if ((0 < iVar1) && (uVar2 = 0, jsonTokenStruct[0].type == JSMN_OBJECT)) { + *pTokenCount = iVar1; + uVar2 = 1; + } + return (_Bool)uVar2; +} + + + +_Bool isJsonKeyMatchingAndUpdateValue + (char *pJsonDocument,void *pJsonHandler,int32_t tokenCount,jsonStruct_t *pDataStruct + ,uint32_t *pDataLength,int32_t *pDataPosition) + +{ + JsonPrimitiveType JVar1; + int8_t iVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint uVar3; + int iVar4; + uint32_t uVar5; + undefined auStack80 [4]; + int iStack76; + int iStack72; + jsmntok_t jStack64; + + iVar4 = 1; + while( true ) { + if (tokenCount <= iVar4) { + return false; + } + iVar2 = jsoneq(pJsonDocument,jsonTokenStruct + iVar4,pDataStruct->pKey); + if (CONCAT31(extraout_var,iVar2) == 0) break; + iVar2 = jsoneq(pJsonDocument,jsonTokenStruct + iVar4,"metadata"); + if (CONCAT31(extraout_var_00,iVar2) == 0) { + return false; + } + iVar4 = iVar4 + 1; + } + iVar4 = iVar4 + 1; + memcpy(auStack80,jsonTokenStruct + iVar4,0x10); + iStack72 = jsonTokenStruct[iVar4].end; + iVar4 = jsonTokenStruct[iVar4].start; + uVar5 = iStack72 - iVar4; + iStack76 = iVar4; + memcpy(&jStack64,auStack80,0x10); + JVar1 = pDataStruct->type; + uVar3 = (uint)JVar1; + if (JVar1 == SHADOW_JSON_BOOL) { + if (pDataStruct->dataLength != 0) { + parseBooleanValue((_Bool *)pDataStruct->pData,pJsonDocument,&jStack64); + } + } + else { + if (JVar1 == SHADOW_JSON_INT32) { + if (3 < pDataStruct->dataLength) { + parseInteger32Value((int32_t *)pDataStruct->pData,pJsonDocument,&jStack64); + } + } + else { + if (JVar1 == SHADOW_JSON_INT16) { + if (uVar3 < pDataStruct->dataLength) { + parseInteger16Value((int16_t *)pDataStruct->pData,pJsonDocument,&jStack64); + } + } + else { + if (JVar1 == SHADOW_JSON_INT8) { + if (pDataStruct->dataLength != 0) { + parseInteger8Value((int8_t *)pDataStruct->pData,pJsonDocument,&jStack64); + } + } + else { + if (JVar1 == SHADOW_JSON_UINT32) { + if (uVar3 < pDataStruct->dataLength) { + parseUnsignedInteger32Value((uint32_t *)pDataStruct->pData,pJsonDocument,&jStack64); + } + } + else { + if (JVar1 == SHADOW_JSON_UINT16) { + if (1 < pDataStruct->dataLength) { + parseUnsignedInteger16Value((uint16_t *)pDataStruct->pData,pJsonDocument,&jStack64); + } + } + else { + if (JVar1 == SHADOW_JSON_UINT8) { + if (pDataStruct->dataLength != 0) { + parseUnsignedInteger8Value((uint8_t *)pDataStruct->pData,pJsonDocument,&jStack64); + } + } + else { + if (JVar1 == SHADOW_JSON_FLOAT) { + if (3 < pDataStruct->dataLength) { + parseFloatValue((float *)pDataStruct->pData,pJsonDocument,&jStack64); + } + } + else { + if (JVar1 == SHADOW_JSON_DOUBLE) { + if (uVar3 < pDataStruct->dataLength) { + parseDoubleValue((double *)pDataStruct->pData,pJsonDocument,&jStack64); + } + } + else { + if (JVar1 == SHADOW_JSON_STRING) { + parseStringValue((char *)pDataStruct->pData,pDataStruct->dataLength, + pJsonDocument,&jStack64); + } + } + } + } + } + } + } + } + } + } + *pDataPosition = iVar4; + *pDataLength = uVar5; + return true; +} + + + +_Bool extractClientToken(char *pJsonDocument,size_t jsonSize,char *pExtractedClientToken, + size_t clientTokenSize) + +{ + uint __n; + int iVar1; + int8_t iVar2; + int iVar3; + undefined3 extraout_var; + + jsmn_init(&shadowJsonParser); + iVar3 = jsmn_parse(&shadowJsonParser,pJsonDocument,jsonSize,jsonTokenStruct,0x78); + if ((0 < iVar3) && (jsonTokenStruct[0].type == JSMN_OBJECT)) { + iVar1 = 1; + do { + if (iVar1 == iVar3) { + return false; + } + iVar2 = jsoneq(pJsonDocument,jsonTokenStruct + iVar1,"clientToken"); + iVar1 = iVar1 + 1; + } while (CONCAT31(extraout_var,iVar2) != 0); + __n = jsonTokenStruct[iVar1].end - jsonTokenStruct[iVar1].start & 0xff; + if (__n + 1 <= clientTokenSize) { + strncpy(pExtractedClientToken,pJsonDocument + jsonTokenStruct[iVar1].start,__n); + pExtractedClientToken[__n] = '\0'; + return true; + } + } + return false; +} + + + +_Bool extractVersionNumber + (char *pJsonDocument,void *pJsonHandler,int32_t tokenCount,uint32_t *pVersionNumber) + +{ + int iVar1; + int iVar2; + int8_t iVar3; + IoT_Error_t IVar4; + undefined3 extraout_var; + undefined3 extraout_var_00; + + iVar1 = 1; + do { + iVar2 = iVar1; + if (tokenCount <= iVar2) { + return false; + } + iVar3 = jsoneq(pJsonDocument,jsonTokenStruct + iVar2,"version"); + iVar1 = iVar2 + 1; + } while ((CONCAT31(extraout_var,iVar3) != 0) || + (IVar4 = parseUnsignedInteger32Value + (pVersionNumber,pJsonDocument,jsonTokenStruct + iVar2 + 1), + CONCAT31(extraout_var_00,IVar4) != 0)); + return true; +} + + + +void shadow_delta_callback + (AWS_IoT_Client *pClient,char *topicName,uint16_t topicNameLen, + IoT_Publish_Message_Params *params,void *pData) + +{ + JsonTokenTable_t *pJVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + uint uVar3; + int32_t local_30; + int32_t tokenCount; + int32_t DataPosition; + uint32_t dataLength; + uint32_t tempVersionNumber; + + dataLength = 0; + if (params->payloadLen < 0x201) { + memcpy(shadowRxBuf,params->payload,params->payloadLen); + shadowRxBuf[params->payloadLen] = '\0'; + _Var2 = isJsonValidAndParse(shadowRxBuf,0x201,(void *)0x0,&local_30); + if (CONCAT31(extraout_var,_Var2) != 0) { + if ((shadowDiscardOldDeltaFlag != false) && + (_Var2 = extractVersionNumber(shadowRxBuf,(void *)0x0,local_30,&dataLength), + CONCAT31(extraout_var_00,_Var2) != 0)) { + if (dataLength <= shadowJsonVersionNum) { + return; + } + shadowJsonVersionNum = dataLength; + } + pJVar1 = tokenTable; + uVar3 = 0; + while (uVar3 < tokenTableIndex) { + if (((pJVar1->isFree == false) && + (_Var2 = isJsonKeyMatchingAndUpdateValue + (shadowRxBuf,(void *)0x0,local_30,(jsonStruct_t *)pJVar1->pStruct, + (uint32_t *)&DataPosition,&tokenCount), + CONCAT31(extraout_var_01,_Var2) != 0)) && + (pJVar1->callback != (jsonStructCallback_t *)0x0)) { + (*pJVar1->callback)(shadowRxBuf + tokenCount,DataPosition,(jsonStruct_t *)pJVar1->pStruct) + ; + } + uVar3 = uVar3 + 1; + pJVar1 = pJVar1 + 1; + } + } + } + return; +} + + + +int16_t findIndexOfSubscriptionList(char *pTopic) + +{ + ushort uVar1; + SubscriptionRecord_t *__s2; + int iVar2; + + __s2 = SubscriptionList; + uVar1 = 0; + while ((__s2->isFree != false || (iVar2 = strcmp(pTopic,(char *)__s2), iVar2 != 0))) { + uVar1 = uVar1 + 1 & 0xff; + __s2 = __s2 + 1; + if (uVar1 == 0x14) { + return -1; + } + } + return uVar1; +} + + + +// WARNING: Variable defined which should be unmapped: ackTypeBuf + +void topicNameFromThingAndAction + (char *pTopic,char *pThingName,ShadowActions_t action,ShadowAckTopicTypes_t ackType) + +{ + char *__src; + undefined3 in_register_00002031; + int iVar1; + undefined3 in_register_00002035; + char acStack40 [4]; + char actionBuf [10]; + char ackTypeBuf [10]; + + iVar1 = CONCAT31(in_register_00002031,action); + if (iVar1 == 0) { + __src = "get"; + } + else { + if (iVar1 == 1) { + __src = "update"; + } + else { + if (iVar1 != 2) goto LAB_2304e29c; + __src = "delete"; + } + } + strncpy(acStack40,__src,10); +LAB_2304e29c: + if (CONCAT31(in_register_00002035,ackType) == 0) { + __src = "accepted"; + } + else { + if (CONCAT31(in_register_00002035,ackType) != 1) { + snprintf(pTopic,0x50,"$aws/things/%s/shadow/%s",pThingName,acStack40); + return; + } + __src = "rejected"; + } + strncpy(actionBuf + 8,__src,10); + snprintf(pTopic,0x50,"$aws/things/%s/shadow/%s/%s",pThingName,acStack40,actionBuf + 8); + return; +} + + + +// WARNING: Variable defined which should be unmapped: TemporaryTopicNameRejected + +void unsubscribeFromAcceptedAndRejected(uint8_t index) + +{ + byte bVar1; + AWS_IoT_Client *pClient; + IoT_Error_t IVar2; + int16_t iVar3; + undefined3 in_register_00002029; + int iVar4; + short extraout_var_01; + size_t sVar5; + undefined3 extraout_var; + short extraout_var_02; + undefined3 extraout_var_00; + char acStack176 [4]; + char TemporaryTopicNameAccepted [80]; + char TemporaryTopicNameRejected [80]; + + iVar4 = CONCAT31(in_register_00002029,index); + topicNameFromThingAndAction + (acStack176,AckWaitList[iVar4].thingName,AckWaitList[iVar4].action,SHADOW_ACCEPTED); + topicNameFromThingAndAction + (TemporaryTopicNameAccepted + 0x4c,AckWaitList[iVar4].thingName, + AckWaitList[iVar4].action,SHADOW_REJECTED); + iVar3 = findIndexOfSubscriptionList(acStack176); + pClient = pMqttClient; + iVar4 = CONCAT22(extraout_var_01,iVar3); + if (-1 < extraout_var_01) { + bVar1 = SubscriptionList[iVar4].count; + if ((SubscriptionList[iVar4].isSticky == false) && (bVar1 == 1)) { + sVar5 = strlen(acStack176); + IVar2 = aws_iot_mqtt_unsubscribe(pClient,acStack176,(uint16_t)sVar5); + if (CONCAT31(extraout_var,IVar2) == 0) { + SubscriptionList[iVar4].isFree = true; + } + } + else { + if (1 < bVar1) { + SubscriptionList[iVar4].count = bVar1 - 1; + } + } + } + iVar3 = findIndexOfSubscriptionList(TemporaryTopicNameAccepted + 0x4c); + pClient = pMqttClient; + iVar4 = CONCAT22(extraout_var_02,iVar3); + if (-1 < extraout_var_02) { + bVar1 = SubscriptionList[iVar4].count; + if ((SubscriptionList[iVar4].isSticky == false) && (bVar1 == 1)) { + sVar5 = strlen(TemporaryTopicNameAccepted + 0x4c); + IVar2 = aws_iot_mqtt_unsubscribe(pClient,TemporaryTopicNameAccepted + 0x4c,(uint16_t)sVar5); + if (CONCAT31(extraout_var_00,IVar2) == 0) { + SubscriptionList[iVar4].isFree = true; + } + } + else { + if (1 < bVar1) { + SubscriptionList[iVar4].count = bVar1 - 1; + } + } + } + return; +} + + + +void AckStatusCallback(AWS_IoT_Client *pClient,char *topicName,uint16_t topicNameLen, + IoT_Publish_Message_Params *params,void *pData) + +{ + int iVar1; + _Bool _Var2; + undefined3 extraout_var; + char *pcVar3; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + int iVar4; + Shadow_Ack_Status_t SVar5; + ToBeReceivedAckRecord_t *__s1; + int32_t iStack164; + int32_t tokenCount; + char temporaryClientToken [110]; + + if (0x200 < params->payloadLen) { + return; + } + memcpy(shadowRxBuf,params->payload,params->payloadLen); + shadowRxBuf[params->payloadLen] = '\0'; + _Var2 = isJsonValidAndParse(shadowRxBuf,0x201,(void *)0x0,&iStack164); + if (CONCAT31(extraout_var,_Var2) != 0) { + pcVar3 = strstr(topicName,myThingName); + if ((pcVar3 != (char *)0x0) && + ((pcVar3 = strstr(topicName,"get/accepted"), pcVar3 != (char *)0x0 || + (pcVar3 = strstr(topicName,"delta"), pcVar3 != (char *)0x0)))) { + tokenCount = 0; + _Var2 = extractVersionNumber(shadowRxBuf,(void *)0x0,iStack164,(uint32_t *)&tokenCount); + if ((CONCAT31(extraout_var_00,_Var2) != 0) && (shadowJsonVersionNum < (uint)tokenCount)) { + shadowJsonVersionNum = tokenCount; + } + } + _Var2 = extractClientToken(shadowRxBuf,0x201,(char *)&tokenCount,0x6e); + if (CONCAT31(extraout_var_01,_Var2) != 0) { + __s1 = AckWaitList; + iVar1 = 0; + do { + if (__s1->isFree == false) { + iVar4 = strcmp((char *)__s1,(char *)&tokenCount); + if (iVar4 == 0) { + pcVar3 = strstr(topicName,"accepted"); + SVar5 = SHADOW_ACK_ACCEPTED; + if (pcVar3 == (char *)0x0) { + strstr(topicName,"rejected"); + SVar5 = SHADOW_ACK_REJECTED; + } + if (AckWaitList[iVar1].callback != (fpActionCallback_t *)0x0) { + (*AckWaitList[iVar1].callback) + ((char *)(iVar1 * 0x88 + 0x4202086e),AckWaitList[iVar1].action,SVar5, + shadowRxBuf,AckWaitList[iVar1].pCallbackContext); + } + unsubscribeFromAcceptedAndRejected((uint8_t)iVar1); + AckWaitList[iVar1].isFree = true; + return; + } + } + iVar1 = iVar1 + 1; + __s1 = __s1 + 1; + } while (iVar1 != 10); + } + } + return; +} + + + +void initDeltaTokens(void) + +{ + JsonTokenTable_t *pJVar1; + + pJVar1 = tokenTable; + do { + pJVar1->isFree = true; + pJVar1 = pJVar1 + 1; + } while (pJVar1 != (JsonTokenTable_t *)pUsernameTemp); + deltaTopicSubscribedFlag = false; + tokenTableIndex = 0; + return; +} + + + +IoT_Error_t registerJsonTokenOnDelta(jsonStruct_t *pStruct) + +{ + AWS_IoT_Client *pClient; + IoT_Error_t IVar1; + size_t sVar2; + jsonStructCallback_t *pjVar3; + + IVar1 = SUCCESS; + if (deltaTopicSubscribedFlag == false) { + snprintf(shadowDeltaTopic,0x50,"$aws/things/%s/shadow/update/delta",myThingName); + pClient = pMqttClient; + sVar2 = strlen(shadowDeltaTopic); + IVar1 = aws_iot_mqtt_subscribe + (pClient,shadowDeltaTopic,(uint16_t)sVar2,QOS0,shadow_delta_callback, + (void *)0x0); + deltaTopicSubscribedFlag = true; + } + if (tokenTableIndex < 0x78) { + tokenTable[tokenTableIndex].pKey = pStruct->pKey; + pjVar3 = pStruct->cb; + *(jsonStruct_t **)&tokenTable[tokenTableIndex].pStruct = pStruct; + tokenTable[tokenTableIndex].callback = pjVar3; + tokenTable[tokenTableIndex].isFree = false; + tokenTableIndex = tokenTableIndex + 1; + } + else { + IVar1 = FAILURE; + } + return IVar1; +} + + + +void initializeRecords(AWS_IoT_Client *pClient) + +{ + ToBeReceivedAckRecord_t *pTVar1; + SubscriptionRecord_t *pSVar2; + + pTVar1 = AckWaitList; + do { + pTVar1->isFree = true; + pTVar1 = pTVar1 + 1; + } while (pTVar1 != (ToBeReceivedAckRecord_t *)&_fsymc_level_bloop); + pSVar2 = SubscriptionList; + do { + pSVar2->isFree = true; + pSVar2->count = '\0'; + pSVar2->isSticky = false; + pSVar2 = pSVar2 + 1; + } while (pSVar2 != (SubscriptionRecord_t *)&pMqttClient); + pMqttClient = pClient; + return; +} + + + +_Bool isSubscriptionPresent(char *pThingName,ShadowActions_t action) + +{ + bool bVar1; + bool bVar2; + SubscriptionRecord_t *__s2; + int iVar3; + char acStack192 [4]; + char TemporaryTopicNameAccepted [80]; + char TemporaryTopicNameRejected [80]; + + topicNameFromThingAndAction(acStack192,pThingName,action,SHADOW_ACCEPTED); + __s2 = SubscriptionList; + topicNameFromThingAndAction(TemporaryTopicNameAccepted + 0x4c,pThingName,action,SHADOW_REJECTED); + bVar1 = false; + bVar2 = false; + do { + if (__s2->isFree == false) { + iVar3 = strcmp(acStack192,(char *)__s2); + if (iVar3 == 0) { + bVar2 = true; + } + else { + iVar3 = strcmp(TemporaryTopicNameAccepted + 0x4c,(char *)__s2); + if (iVar3 == 0) { + bVar1 = true; + } + } + } + __s2 = __s2 + 1; + } while (__s2 != (SubscriptionRecord_t *)&pMqttClient); + if (bVar1) { + bVar1 = bVar2; + } + return (_Bool)bVar1; +} + + + +IoT_Error_t subscribeToShadowActionAcks(char *pThingName,ShadowActions_t action,_Bool isSticky) + +{ + uint8_t uVar1; + AWS_IoT_Client *pClient; + IoT_Error_t IVar2; + _Bool _Var3; + size_t sVar4; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + SubscriptionRecord_t *pTopic; + SubscriptionRecord_t *pTopic_00; + int iVar5; + int iVar6; + int iVar7; + undefined auStack76 [4]; + Timer subSettlingtimer; + + pTopic_00 = SubscriptionList; + pTopic = SubscriptionList; + iVar5 = 0; + do { + if (pTopic->isFree != false) { + iVar6 = (int)(short)((ushort)iVar5 & 0xff); + SubscriptionList[iVar5].isFree = false; + goto LAB_2304e79a; + } + iVar5 = iVar5 + 1; + pTopic = pTopic + 1; + } while (iVar5 != 0x14); + iVar6 = -1; +LAB_2304e79a: + iVar5 = 0; +LAB_2304e79e: + if (pTopic_00->isFree == false) goto LAB_2304e886; + iVar7 = (int)(short)((ushort)iVar5 & 0xff); + IVar2 = SUCCESS; + pTopic = SubscriptionList + iVar5; + SubscriptionList[iVar5].isFree = false; + if (iVar6 == -1) goto LAB_2304e8d6; + pTopic_00 = SubscriptionList + iVar6; + topicNameFromThingAndAction((char *)pTopic_00,pThingName,action,SHADOW_ACCEPTED); + pClient = pMqttClient; + sVar4 = strlen((char *)pTopic_00); + IVar2 = aws_iot_mqtt_subscribe + (pClient,(char *)pTopic_00,(uint16_t)sVar4,QOS0,AckStatusCallback,(void *)0x0); + if (CONCAT31(extraout_var,IVar2) == 0) { + SubscriptionList[iVar6].count = '\x01'; + *(_Bool *)(iVar6 * 0x53 + 0x420201d2) = isSticky; + topicNameFromThingAndAction((char *)pTopic,pThingName,action,SHADOW_REJECTED); + pClient = pMqttClient; + sVar4 = strlen((char *)pTopic); + IVar2 = aws_iot_mqtt_subscribe + (pClient,(char *)pTopic,(uint16_t)sVar4,QOS0,AckStatusCallback,(void *)0x0); + if (CONCAT31(extraout_var_00,IVar2) == 0) { + SubscriptionList[iVar5].count = '\x01'; + *(_Bool *)(iVar5 * 0x53 + 0x420201d2) = isSticky; + init_timer((Timer *)auStack76); + countdown_sec((Timer *)auStack76,2); + do { + _Var3 = has_timer_expired((Timer *)auStack76); + } while (CONCAT31(extraout_var_01,_Var3) == 0); + goto LAB_2304e856; + } + } + goto LAB_2304e89a; +LAB_2304e886: + iVar5 = iVar5 + 1; + pTopic_00 = pTopic_00 + 1; + if (iVar5 == 0x14) { + if (iVar6 == -1) { +LAB_2304e856: + IVar2 = SUCCESS; + } + else { + iVar7 = -1; + IVar2 = SUCCESS; +LAB_2304e89a: + uVar1 = SubscriptionList[iVar6].count; + SubscriptionList[iVar6].isFree = true; + pClient = pMqttClient; + if (uVar1 == '\x01') { + sVar4 = strlen((char *)(SubscriptionList + iVar6)); + aws_iot_mqtt_unsubscribe(pClient,(char *)(SubscriptionList + iVar6),(uint16_t)sVar4); + } + if (iVar7 != -1) { +LAB_2304e8d6: + SubscriptionList[iVar7].isFree = true; + } + } + return IVar2; + } + goto LAB_2304e79e; +} + + + +// WARNING: Variable defined which should be unmapped: TemporaryTopicNameRejected + +void incrementSubscriptionCnt(char *pThingName,ShadowActions_t action,_Bool isSticky) + +{ + SubscriptionRecord_t *__s2; + int iVar1; + char acStack176 [4]; + char TemporaryTopicNameAccepted [80]; + char TemporaryTopicNameRejected [80]; + + topicNameFromThingAndAction(acStack176,pThingName,action,SHADOW_ACCEPTED); + __s2 = SubscriptionList; + topicNameFromThingAndAction(TemporaryTopicNameAccepted + 0x4c,pThingName,action,SHADOW_REJECTED); + do { + if ((__s2->isFree == false) && + ((iVar1 = strcmp(acStack176,(char *)__s2), iVar1 == 0 || + (iVar1 = strcmp(TemporaryTopicNameAccepted + 0x4c,(char *)__s2), iVar1 == 0)))) { + __s2->isSticky = isSticky; + __s2->count = __s2->count + '\x01'; + } + __s2 = __s2 + 1; + } while (__s2 != (SubscriptionRecord_t *)&pMqttClient); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +IoT_Error_t +publishToShadowAction(char *pThingName,ShadowActions_t action,char *pJsonDocumentToBeSent) + +{ + AWS_IoT_Client *pClient; + IoT_Error_t IVar1; + size_t sVar2; + undefined2 local_70 [2]; + IoT_Publish_Message_Params msgParams; + char TemporaryTopicName [80]; + + if (pThingName == (char *)0x0) { + return NULL_VALUE_ERROR; + } + if (pJsonDocumentToBeSent != (char *)0x0) { + topicNameFromThingAndAction((char *)&msgParams.payloadLen,pThingName,action,SHADOW_ACTION); + local_70[0] = 0; + msgParams.payload = (void *)strlen(pJsonDocumentToBeSent); + pClient = pMqttClient; + msgParams._4_4_ = pJsonDocumentToBeSent; + sVar2 = strlen((char *)&msgParams.payloadLen); + IVar1 = aws_iot_mqtt_publish + (pClient,(char *)&msgParams.payloadLen,(uint16_t)sVar2, + (IoT_Publish_Message_Params *)local_70); + return IVar1; + } + return NULL_VALUE_ERROR; +} + + + +_Bool getNextFreeIndexOfAckWaitList(uint8_t *pIndex) + +{ + _Bool _Var1; + ToBeReceivedAckRecord_t *pTVar2; + uint8_t uVar3; + + _Var1 = false; + if (pIndex != (uint8_t *)0x0) { + pTVar2 = AckWaitList; + uVar3 = '\0'; + do { + _Var1 = pTVar2->isFree; + if (_Var1 != false) { + *pIndex = uVar3; + return _Var1; + } + uVar3 = uVar3 + '\x01'; + pTVar2 = pTVar2 + 1; + } while (uVar3 != '\n'); + } + return _Var1; +} + + + +void addToAckWaitList(uint8_t indexAckWaitList,char *pThingName,ShadowActions_t action, + char *pExtractedClientToken,fpActionCallback_t *callback,void *pCallbackContext + ,uint32_t timeout_seconds) + +{ + undefined3 in_register_00002029; + int iVar1; + + iVar1 = CONCAT31(in_register_00002029,indexAckWaitList); + AckWaitList[iVar1].callback = callback; + memcpy(AckWaitList + iVar1,pExtractedClientToken,0x5a); + memcpy(AckWaitList[iVar1].thingName,pThingName,0x14); + AckWaitList[iVar1].pCallbackContext = pCallbackContext; + AckWaitList[iVar1].action = action; + init_timer(&AckWaitList[iVar1].timer); + countdown_sec(&AckWaitList[iVar1].timer,timeout_seconds); + AckWaitList[iVar1].isFree = false; + return; +} + + + +void HandleExpiredResponseCallbacks(void) + +{ + ToBeReceivedAckRecord_t *pTVar1; + uint8_t index; + _Bool _Var2; + undefined3 extraout_var; + + pTVar1 = AckWaitList; + index = '\0'; + do { + if ((pTVar1->isFree == false) && + (_Var2 = has_timer_expired(&pTVar1->timer), CONCAT31(extraout_var,_Var2) != 0)) { + if (pTVar1->callback != (fpActionCallback_t *)0x0) { + (*pTVar1->callback)(pTVar1->thingName,pTVar1->action,SHADOW_ACK_TIMEOUT,shadowRxBuf, + pTVar1->pCallbackContext); + } + pTVar1->isFree = true; + unsubscribeFromAcceptedAndRejected(index); + } + index = index + '\x01'; + pTVar1 = pTVar1 + 1; + } while (index != '\n'); + return; +} + + + +_Bool has_timer_expired(Timer *timer) + +{ + TickType_t TVar1; + uint uVar2; + uint uVar3; + + TVar1 = xTaskGetTickCount(); + uVar2 = timer->timeout_ticks; + uVar3 = TVar1 - timer->start_ticks; + if ((uVar3 < uVar2) && (timer->last_polled_ticks == TVar1)) { + vTaskDelay(1); + } + timer->last_polled_ticks = TVar1; + return (_Bool)(uVar2 <= uVar3); +} + + + +void countdown_ms(Timer *timer,uint32_t timeout) + +{ + TickType_t TVar1; + + TVar1 = xTaskGetTickCount(); + timer->start_ticks = TVar1; + timer->last_polled_ticks = 0; + timer->timeout_ticks = timeout; + return; +} + + + +uint32_t left_ms(Timer *timer) + +{ + TickType_t TVar1; + uint32_t uVar2; + + TVar1 = xTaskGetTickCount(); + if (TVar1 - timer->start_ticks < timer->timeout_ticks) { + uVar2 = (timer->start_ticks + timer->timeout_ticks) - TVar1; + } + else { + uVar2 = 0; + } + return uVar2; +} + + + +void countdown_sec(Timer *timer,uint32_t timeout) + +{ + if (0x418937 < timeout) { + puts("aws_timer"); + printf("ERRORtimeout is out of range: %lus\r\n",timeout); + } + countdown_ms(timer,timeout * 1000); + return; +} + + + +void init_timer(Timer *timer) + +{ + timer->start_ticks = 0; + timer->timeout_ticks = 0; + timer->last_polled_ticks = 0; + return; +} + + + +int jsmn_parse(jsmn_parser *parser,char *js,size_t len,jsmntok_t *tokens,uint num_tokens) + +{ + byte bVar1; + char cVar2; + uint uVar3; + int iVar4; + uint uVar5; + uint uVar6; + jsmntok_t *pjVar7; + jsmntype_t jVar8; + jsmntok_t *pjVar9; + uint uVar10; + + uVar5 = parser->toknext; +LAB_2304ebda: + uVar6 = parser->pos; + if ((len <= uVar6) || (bVar1 = js[uVar6], bVar1 == 0)) { + if (tokens != (jsmntok_t *)0x0) { + uVar6 = parser->toknext; + tokens = tokens + uVar6; + while (uVar6 = uVar6 - 1, -1 < (int)uVar6) { + if ((tokens[-1].start != -1) && (tokens[-1].end == -1)) { + return -3; + } + tokens = tokens + -1; + } + } + return uVar5; + } + if (bVar1 != 0x2c) { + if (0x2c < bVar1) { + if (bVar1 == 0x5d) { +LAB_2304ed06: + if (tokens != (jsmntok_t *)0x0) { + jVar8 = JSMN_OBJECT; + if (bVar1 != 0x7d) { + jVar8 = JSMN_ARRAY; + } + uVar10 = parser->toknext; + pjVar7 = tokens + uVar10; + do { + pjVar9 = pjVar7; + uVar10 = uVar10 - 1; + if ((int)uVar10 < 0) { + if (uVar10 == 0xffffffff) { + return -2; + } + goto LAB_2304ed68; + } + pjVar7 = pjVar9 + -1; + } while ((pjVar9[-1].start == -1) || (pjVar9[-1].end != -1)); + if (pjVar7->type != jVar8) { + return -2; + } + parser->toksuper = -1; + pjVar9[-1].end = uVar6 + 1; + pjVar7 = tokens + uVar10; + do { + if ((pjVar7->start != -1) && (pjVar7->end == -1)) { + parser->toksuper = uVar10; + break; + } + uVar10 = uVar10 - 1; + pjVar7 = pjVar7 + -1; + } while (uVar10 != 0xffffffff); + } + } + else { + if (bVar1 < 0x5e) { + if (bVar1 != 0x3a) { + if (bVar1 != 0x5b) goto LAB_2304ef0c; + goto LAB_2304ec9c; + } + } + else { + if (bVar1 != 0x7b) { + if (bVar1 != 0x7d) goto LAB_2304ef0c; + goto LAB_2304ed06; + } +LAB_2304ec9c: + uVar5 = uVar5 + 1; + if (tokens == (jsmntok_t *)0x0) goto LAB_2304ed68; + uVar6 = parser->toknext; + if (num_tokens <= uVar6) { + return -1; + } + parser->toknext = uVar6 + 1; + pjVar7 = tokens + uVar6; + pjVar7->end = -1; + pjVar7->start = -1; + pjVar7->size = 0; + if (parser->toksuper != -1) { + tokens[parser->toksuper].size = tokens[parser->toksuper].size + 1; + } + jVar8 = JSMN_OBJECT; + if (bVar1 != 0x7b) { + jVar8 = JSMN_ARRAY; + } + pjVar7->type = jVar8; + pjVar7->start = parser->pos; + } + parser->toksuper = parser->toknext - 1; + } + goto LAB_2304ed68; + } + if (bVar1 == 0xd) goto LAB_2304ed68; + if (bVar1 < 0xe) { + if (1 < (byte)(bVar1 - 9)) { +LAB_2304ef0c: + do { + uVar10 = parser->pos; + if (((len <= uVar10) || (bVar1 = js[uVar10], bVar1 == 0)) || (bVar1 == 0x20)) goto found; + if (bVar1 < 0x21) { + if ((8 < bVar1) && ((bVar1 < 0xb || (bVar1 == 0xd)))) goto found; + } + else { + if (bVar1 == 0x3a) goto found; + if (bVar1 < 0x3b) { + if (bVar1 == 0x2c) goto found; + } + else { + if ((bVar1 == 0x5d) || (bVar1 == 0x7d)) goto found; + } + } + if (0x5e < (byte)(bVar1 - 0x20)) goto LAB_2304ee20; + parser->pos = uVar10 + 1; + } while( true ); + } + goto LAB_2304ed68; + } + if (bVar1 == 0x20) goto LAB_2304ed68; + if (bVar1 != 0x22) goto LAB_2304ef0c; + parser->pos = uVar6 + 1; + while( true ) { + uVar10 = parser->pos; + if ((len <= uVar10) || (cVar2 = js[uVar10], cVar2 == '\0')) { + parser->pos = uVar6; + return -3; + } + if (cVar2 == '\"') break; + if ((cVar2 == '\\') && (uVar3 = uVar10 + 1, uVar3 < len)) { + parser->pos = uVar3; + bVar1 = js[uVar3]; + if (bVar1 != 0x66) { + if (bVar1 < 0x67) { + if (bVar1 != 0x2f) { + if (bVar1 < 0x30) { + if (bVar1 != 0x22) goto LAB_2304ee20; + } + else { + if ((bVar1 != 0x5c) && (bVar1 != 0x62)) goto LAB_2304ee20; + } + } + } + else { + if (bVar1 != 0x72) { + if (bVar1 < 0x73) { + if (bVar1 != 0x6e) goto LAB_2304ee20; + } + else { + if (bVar1 != 0x74) { + if (bVar1 != 0x75) { +LAB_2304ee20: + parser->pos = uVar6; + return -2; + } + parser->pos = uVar10 + 2; + iVar4 = 4; + do { + uVar10 = parser->pos; + if ((len <= uVar10) || (bVar1 = js[uVar10], bVar1 == 0)) break; + if ((9 < (byte)(bVar1 - 0x30)) && (5 < (byte)((bVar1 & 0xdf) + 0xbf))) + goto LAB_2304ee20; + parser->pos = uVar10 + 1; + iVar4 = iVar4 + -1; + } while (iVar4 != 0); + parser->pos = parser->pos - 1; + } + } + } + } + } + } + parser->pos = parser->pos + 1; + } + if (tokens != (jsmntok_t *)0x0) { + uVar10 = parser->toknext; + if (num_tokens <= uVar10) goto LAB_2304ed92; + parser->toknext = uVar10 + 1; + pjVar7 = tokens + uVar10; + pjVar7->end = -1; + pjVar7->start = -1; + pjVar7->size = 0; + uVar10 = parser->pos; + pjVar7->type = JSMN_STRING; + pjVar7->start = uVar6 + 1; + pjVar7->end = uVar10; + } + goto LAB_2304edc6; + } + if (((tokens != (jsmntok_t *)0x0) && (parser->toksuper != -1)) && + (1 < (byte)(tokens[parser->toksuper].type + ~JSMN_UNDEFINED))) { + uVar6 = parser->toknext; + pjVar7 = tokens + uVar6; + while (uVar6 = uVar6 - 1, -1 < (int)uVar6) { + if ((((byte)(pjVar7[-1].type + ~JSMN_UNDEFINED) < 2) && (pjVar7[-1].start != -1)) && + (pjVar7[-1].end == -1)) { + parser->toksuper = uVar6; + break; + } + pjVar7 = pjVar7 + -1; + } + } + goto LAB_2304ed68; +found: + if (tokens == (jsmntok_t *)0x0) { + parser->pos = uVar10 - 1; + } + else { + uVar10 = parser->toknext; + if (num_tokens <= uVar10) { +LAB_2304ed92: + parser->pos = uVar6; + return -1; + } + parser->toknext = uVar10 + 1; + pjVar7 = tokens + uVar10; + pjVar7->end = -1; + pjVar7->start = -1; + pjVar7->size = 0; + uVar10 = parser->pos; + pjVar7->type = JSMN_PRIMITIVE; + pjVar7->start = uVar6; + pjVar7->end = uVar10; + parser->pos = parser->pos - 1; + } +LAB_2304edc6: + uVar5 = uVar5 + 1; + if ((parser->toksuper != -1) && (tokens != (jsmntok_t *)0x0)) { + tokens[parser->toksuper].size = tokens[parser->toksuper].size + 1; + } +LAB_2304ed68: + parser->pos = parser->pos + 1; + goto LAB_2304ebda; +} + + + +void jsmn_init(jsmn_parser *parser) + +{ + parser->pos = 0; + parser->toknext = 0; + parser->toksuper = -1; + return; +} + + + +int8_t jsoneq(char *json,jsmntok_t *tok,char *s) + +{ + int8_t iVar1; + size_t __n; + int iVar2; + + if (tok->type != JSMN_STRING) { + return -1; + } + __n = strlen(s); + if (__n == tok->end - tok->start) { + iVar2 = strncmp(json + tok->start,s,__n); + iVar1 = -(iVar2 != 0); + } + else { + iVar1 = -1; + } + return iVar1; +} + + + +IoT_Error_t parseUnsignedInteger32Value(uint32_t *i,char *jsonString,jsmntok_t *token) + +{ + int iVar1; + IoT_Error_t IVar2; + + if (token->type == JSMN_PRIMITIVE) { + if (jsonString[token->start] != '-') { + iVar1 = sscanf(jsonString + token->start,"%lu",i); + IVar2 = SUCCESS; + if (iVar1 != 1) { + IVar2 = JSON_PARSE_ERROR; + } + return IVar2; + } + } + return JSON_PARSE_ERROR; +} + + + +IoT_Error_t parseUnsignedInteger16Value(uint16_t *i,char *jsonString,jsmntok_t *token) + +{ + int iVar1; + IoT_Error_t IVar2; + + if (token->type == JSMN_PRIMITIVE) { + if (jsonString[token->start] != '-') { + iVar1 = sscanf(jsonString + token->start,"%hu",i); + IVar2 = SUCCESS; + if (iVar1 != 1) { + IVar2 = JSON_PARSE_ERROR; + } + return IVar2; + } + } + return JSON_PARSE_ERROR; +} + + + +IoT_Error_t parseUnsignedInteger8Value(uint8_t *i,char *jsonString,jsmntok_t *token) + +{ + IoT_Error_t IVar1; + int iVar2; + uint uStack20; + uint32_t i_word; + + if (token->type == JSMN_PRIMITIVE) { + if (jsonString[token->start] != '-') { + iVar2 = sscanf(jsonString + token->start,"%lu",&uStack20); + if ((iVar2 == 1) && (uStack20 < 0x100)) { + *i = (uint8_t)uStack20; + IVar1 = SUCCESS; + } + else { + IVar1 = JSON_PARSE_ERROR; + } + return IVar1; + } + } + return JSON_PARSE_ERROR; +} + + + +IoT_Error_t parseInteger32Value(int32_t *i,char *jsonString,jsmntok_t *token) + +{ + int iVar1; + IoT_Error_t IVar2; + + if (token->type == JSMN_PRIMITIVE) { + iVar1 = sscanf(jsonString + token->start,"%ld",i); + IVar2 = SUCCESS; + if (iVar1 != 1) { + IVar2 = JSON_PARSE_ERROR; + } + return IVar2; + } + return JSON_PARSE_ERROR; +} + + + +IoT_Error_t parseInteger16Value(int16_t *i,char *jsonString,jsmntok_t *token) + +{ + IoT_Error_t IVar1; + int iVar2; + int iStack20; + int32_t i_word; + + if (token->type != JSMN_PRIMITIVE) { + return JSON_PARSE_ERROR; + } + iVar2 = sscanf(jsonString + token->start,"%li",&iStack20); + if ((iVar2 == 1) && (iStack20 + 0x8000U < 0x10000)) { + *i = (int16_t)iStack20; + IVar1 = SUCCESS; + } + else { + IVar1 = JSON_PARSE_ERROR; + } + return IVar1; +} + + + +IoT_Error_t parseInteger8Value(int8_t *i,char *jsonString,jsmntok_t *token) + +{ + IoT_Error_t IVar1; + int iVar2; + int iStack20; + int32_t i_word; + + if (token->type != JSMN_PRIMITIVE) { + return JSON_PARSE_ERROR; + } + iVar2 = sscanf(jsonString + token->start,"%li",&iStack20); + if ((iVar2 == 1) && (iStack20 + 0x80U < 0x100)) { + *i = (int8_t)iStack20; + IVar1 = SUCCESS; + } + else { + IVar1 = JSON_PARSE_ERROR; + } + return IVar1; +} + + + +IoT_Error_t parseFloatValue(float *f,char *jsonString,jsmntok_t *token) + +{ + int iVar1; + IoT_Error_t IVar2; + + if (token->type == JSMN_PRIMITIVE) { + iVar1 = sscanf(jsonString + token->start,"%f",f); + IVar2 = SUCCESS; + if (iVar1 != 1) { + IVar2 = JSON_PARSE_ERROR; + } + return IVar2; + } + return JSON_PARSE_ERROR; +} + + + +IoT_Error_t parseDoubleValue(double *d,char *jsonString,jsmntok_t *token) + +{ + int iVar1; + IoT_Error_t IVar2; + + if (token->type == JSMN_PRIMITIVE) { + iVar1 = sscanf(jsonString + token->start,"%lf",d); + IVar2 = SUCCESS; + if (iVar1 != 1) { + IVar2 = JSON_PARSE_ERROR; + } + return IVar2; + } + return JSON_PARSE_ERROR; +} + + + +IoT_Error_t parseBooleanValue(_Bool *b,char *jsonString,jsmntok_t *token) + +{ + IoT_Error_t IVar1; + + if (token->type != JSMN_PRIMITIVE) { + return JSON_PARSE_ERROR; + } + _IVar1 = strncmp(jsonString + token->start,"true",4); + IVar1 = (IoT_Error_t)_IVar1; + if (_IVar1 == 0) { + *b = true; + } + else { + _IVar1 = strncmp(jsonString + token->start,"false",5); + IVar1 = (IoT_Error_t)_IVar1; + if (_IVar1 == 0) { + *b = false; + } + else { + IVar1 = JSON_PARSE_ERROR; + } + } + return IVar1; +} + + + +IoT_Error_t parseStringValue(char *buf,size_t bufLen,char *jsonString,jsmntok_t *token) + +{ + size_t __n; + IoT_Error_t IVar1; + + __n = token->end - token->start; + if (token->type == JSMN_STRING) { + IVar1 = SHADOW_JSON_ERROR; + if (__n + 1 <= bufLen) { + strncpy(buf,jsonString + token->start,__n); + buf[__n] = '\0'; + IVar1 = SUCCESS; + } + } + else { + IVar1 = JSON_PARSE_ERROR; + } + return IVar1; +} + + + +ClientState aws_iot_mqtt_get_client_state(AWS_IoT_Client *pClient) + +{ + if (pClient != (AWS_IoT_Client *)0x0) { + return (pClient->clientStatus).clientState; + } + return CLIENT_STATE_INVALID; +} + + + +IoT_Error_t aws_iot_mqtt_client_lock_mutex(AWS_IoT_Client *pClient,IoT_Mutex_t *pMutex) + +{ + IoT_Error_t IVar1; + + if ((pClient != (AWS_IoT_Client *)0x0) && (pMutex != (IoT_Mutex_t *)0x0)) { + if ((pClient->clientData).isBlockOnThreadLockEnabled == false) { + IVar1 = aws_iot_thread_mutex_trylock(pMutex); + return IVar1; + } + IVar1 = aws_iot_thread_mutex_lock(pMutex); + return IVar1; + } + return NULL_VALUE_ERROR; +} + + + +IoT_Error_t aws_iot_mqtt_client_unlock_mutex(AWS_IoT_Client *pClient,IoT_Mutex_t *pMutex) + +{ + IoT_Error_t IVar1; + + if ((pClient != (AWS_IoT_Client *)0x0) && (pMutex != (IoT_Mutex_t *)0x0)) { + IVar1 = aws_iot_thread_mutex_unlock(pMutex); + return IVar1; + } + return NULL_VALUE_ERROR; +} + + + +int aws_iot_mqtt_set_client_state(AWS_IoT_Client *param_1,uint param_2,ClientState param_3) + +{ + int iVar1; + IoT_Error_t IVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + int iVar3; + IoT_Mutex_t *pMutex; + + if (param_1 != (AWS_IoT_Client *)0x0) { + pMutex = &(param_1->clientData).state_change_mutex; + IVar2 = aws_iot_mqtt_client_lock_mutex(param_1,pMutex); + iVar3 = CONCAT31(extraout_var,IVar2); + if (CONCAT31(extraout_var,IVar2) == 0) { + iVar1 = -0x1d; + if ((uint)(param_1->clientStatus).clientState == param_2) { + (param_1->clientStatus).clientState = param_3; + iVar1 = 0; + } + IVar2 = aws_iot_mqtt_client_unlock_mutex(param_1,pMutex); + iVar3 = CONCAT31(extraout_var_00,IVar2); + if (iVar1 != 0) { + iVar3 = iVar1; + } + } + return iVar3; + } + return 0xfffffffe; +} + + + +IoT_Error_t +aws_iot_mqtt_set_connect_params + (AWS_IoT_Client *pClient,IoT_Client_Connect_Params *pNewConnectParams) + +{ + IoT_Error_t IVar1; + size_t sVar2; + + if (pClient != (AWS_IoT_Client *)0x0) { + IVar1 = NULL_VALUE_ERROR; + if (pNewConnectParams != (IoT_Client_Connect_Params *)0x0) { + (pClient->clientData).options.isWillMsgPresent = pNewConnectParams->isWillMsgPresent; + (pClient->clientData).options.MQTTVersion = pNewConnectParams->MQTTVersion; + (pClient->clientData).options.pClientID = pNewConnectParams->pClientID; + (pClient->clientData).options.clientIDLen = pNewConnectParams->clientIDLen; + sVar2 = strlen(pUsernameTemp); + if (sVar2 == 0) { + snprintf(pUsernameTemp,0x19,"?SDK=C&Version=%d.%d.%d",3,0,1); + } + (pClient->clientData).options.pUsername = pUsernameTemp; + sVar2 = strlen(pUsernameTemp); + (pClient->clientData).options.usernameLen = (uint16_t)sVar2; + IVar1 = SUCCESS; + (pClient->clientData).options.pPassword = pNewConnectParams->pPassword; + (pClient->clientData).options.passwordLen = pNewConnectParams->passwordLen; + (pClient->clientData).options.will.pTopicName = (pNewConnectParams->will).pTopicName; + (pClient->clientData).options.will.topicNameLen = (pNewConnectParams->will).topicNameLen; + (pClient->clientData).options.will.pMessage = (pNewConnectParams->will).pMessage; + (pClient->clientData).options.will.msgLen = (pNewConnectParams->will).msgLen; + (pClient->clientData).options.will.qos = (pNewConnectParams->will).qos; + (pClient->clientData).options.will.isRetained = (pNewConnectParams->will).isRetained; + (pClient->clientData).options.keepAliveIntervalInSec = + pNewConnectParams->keepAliveIntervalInSec; + (pClient->clientData).options.isCleanSession = pNewConnectParams->isCleanSession; + } + return IVar1; + } + return NULL_VALUE_ERROR; +} + + + +// WARNING: Variable defined which should be unmapped: default_options + +IoT_Error_t aws_iot_mqtt_init(AWS_IoT_Client *pClient,IoT_Client_Init_Params *pInitParams) + +{ + IoT_Error_t IVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + MessageHandlers_conflict40 *pMVar2; + uint32_t uVar3; + void *pvVar4; + IoT_Mutex_t *pMutex; + IoT_Mutex_t *pMutex_00; + IoT_Mutex_t *pMutex_01; + undefined auStack88 [4]; + IoT_Client_Connect_Params default_options; + + IVar1 = NULL_VALUE_ERROR; + memcpy(auStack88,&DAT_23087bdc,0x38); + if ((((pClient != (AWS_IoT_Client *)0x0) && (pInitParams != (IoT_Client_Init_Params *)0x0)) && + (pInitParams->pHostURL != (char *)0x0)) && + (((pInitParams->port != 0 && (pInitParams->pRootCALocation != (char *)0x0)) && + ((pInitParams->pDevicePrivateKeyLocation != (char *)0x0 && + (pInitParams->pDeviceCertLocation != (char *)0x0)))))) { + pMVar2 = (pClient->clientData).messageHandlers; + do { + pMVar2->topicName = (char *)0x0; + pMVar2->pApplicationHandler = (pApplicationHandler_t *)0x0; + pMVar2->pApplicationHandlerData = (void *)0x0; + pMVar2->qos = QOS0; + pMVar2 = pMVar2 + 1; + } while (pMVar2 != (MessageHandlers_conflict40 *)&(pClient->clientData).disconnectHandler); + (pClient->clientData).packetTimeoutMs = pInitParams->mqttPacketTimeout_ms; + uVar3 = pInitParams->mqttCommandTimeout_ms; + (pClient->clientData).counterNetworkDisconnected = 0; + (pClient->clientData).commandTimeoutMs = uVar3; + (pClient->clientData).writeBufSize = 0x200; + (pClient->clientData).readBufSize = 0x200; + (pClient->clientData).disconnectHandler = pInitParams->disconnectHandler; + pvVar4 = pInitParams->disconnectHandlerData; + (pClient->clientData).nextPacketId = 1; + (pClient->clientData).disconnectHandlerData = pvVar4; + IVar1 = aws_iot_mqtt_set_connect_params(pClient,(IoT_Client_Connect_Params *)auStack88); + if (CONCAT31(extraout_var,IVar1) == 0) { + pMutex = &(pClient->clientData).state_change_mutex; + (pClient->clientData).isBlockOnThreadLockEnabled = pInitParams->isBlockOnThreadLockEnabled; + IVar1 = aws_iot_thread_mutex_init(pMutex); + if (CONCAT31(extraout_var_00,IVar1) == 0) { + pMutex_00 = &(pClient->clientData).tls_read_mutex; + IVar1 = aws_iot_thread_mutex_init(pMutex_00); + if (CONCAT31(extraout_var_01,IVar1) == 0) { + pMutex_01 = &(pClient->clientData).tls_write_mutex; + IVar1 = aws_iot_thread_mutex_init(pMutex_01); + if (CONCAT31(extraout_var_02,IVar1) == 0) { + (pClient->clientStatus).isPingOutstanding = false; + (pClient->clientStatus).isAutoReconnectEnabled = pInitParams->enableAutoReconnect; + IVar1 = iot_tls_init((Network *)&pClient->networkStack,pInitParams->pRootCALocation, + pInitParams->pDeviceCertLocation, + pInitParams->pDevicePrivateKeyLocation,pInitParams->pHostURL, + pInitParams->port,pInitParams->tlsHandshakeTimeout_ms, + pInitParams->isSSLHostnameVerify); + if (CONCAT31(extraout_var_03,IVar1) != 0) { + aws_iot_thread_mutex_destroy(pMutex_00); + aws_iot_thread_mutex_destroy(pMutex); + aws_iot_thread_mutex_destroy(pMutex_01); + (pClient->clientStatus).clientState = CLIENT_STATE_INVALID; + return IVar1; + } + init_timer((Timer *)pClient); + init_timer(&pClient->reconnectDelayTimer); + (pClient->clientStatus).clientState = CLIENT_STATE_INITIALIZED; + return IVar1; + } + aws_iot_thread_mutex_destroy(pMutex_00); + } + aws_iot_thread_mutex_destroy(pMutex); + } + } + } + return IVar1; +} + + + +uint16_t aws_iot_mqtt_get_next_packet_id(AWS_IoT_Client *pClient) + +{ + uint16_t uVar1; + + uVar1 = (pClient->clientData).nextPacketId; + if (uVar1 == 0xffff) { + uVar1 = 1; + } + else { + uVar1 = uVar1 + 1; + } + (pClient->clientData).nextPacketId = uVar1; + return uVar1; +} + + + +_Bool aws_iot_mqtt_is_client_connected(AWS_IoT_Client *pClient) + +{ + if (pClient != (AWS_IoT_Client *)0x0) { + return (_Bool)((uint)(pClient->clientStatus).clientState - 3 < 7); + } + return false; +} + + + +IoT_Error_t aws_iot_mqtt_autoreconnect_set_status(AWS_IoT_Client *pClient,_Bool newStatus) + +{ + if (pClient != (AWS_IoT_Client *)0x0) { + (pClient->clientStatus).isAutoReconnectEnabled = newStatus; + return SUCCESS; + } + return NULL_VALUE_ERROR; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +IoT_Error_t aws_iot_mqtt_connect(AWS_IoT_Client *pClient,IoT_Client_Connect_Params *pConnectParams) + +{ + ushort uVar1; + uint uVar2; + ClientState CVar3; + IoT_Error_t IVar4; + IoT_Error_t IVar5; + uchar uVar6; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + uint32_t uVar7; + undefined3 extraout_var_02; + size_t sVar8; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + undefined3 extraout_var_05; + undefined3 extraout_var_06; + undefined3 extraout_var_07; + undefined3 extraout_var_08; + byte c; + char *string; + undefined4 uVar9; + uint32_t rem_len; + Network *pNVar10; + uchar *puVar11; + uchar *puStack56; + uchar *curdata; + MQTTHeader header; + uchar *ptr; + Timer connect_timer; + + if (pClient == (AWS_IoT_Client *)0x0) { + return NULL_VALUE_ERROR; + } + aws_iot_mqtt_internal_flushBuffers(pClient); + CVar3 = aws_iot_mqtt_get_client_state(pClient); + _CVar3 = CONCAT31(extraout_var,CVar3); + if (_CVar3 != 1) { + if (CVar3 == CLIENT_STATE_INVALID) { + return NETWORK_ALREADY_CONNECTED_ERROR; + } + if (2 < (_CVar3 - 0xbU & 0xff)) { + return NETWORK_ALREADY_CONNECTED_ERROR; + } + } + aws_iot_mqtt_set_client_state(pClient,_CVar3,2); + pNVar10 = (Network *)&pClient->networkStack; + if ((pConnectParams == (IoT_Client_Connect_Params *)0x0) || + (IVar4 = aws_iot_mqtt_set_connect_params(pClient,pConnectParams), + CONCAT31(extraout_var_01,IVar4) == 0)) { + IVar4 = (*(pClient->networkStack).connect)(pNVar10,(TLSConnectParams *)0x0); + if (CONCAT31(extraout_var_00,IVar4) == 0) { + init_timer((Timer *)&ptr); + puVar11 = (pClient->clientData).writeBuf; + countdown_ms((Timer *)&ptr,(pClient->clientData).commandTimeoutMs); + curdata = (uchar *)((uint)curdata & 0xffffff00); + uVar2 = (pClient->clientData).writeBufSize; + (pClient->clientData).keepAliveInterval = (pClient->clientData).options.keepAliveIntervalInSec + ; + uVar1 = (pClient->clientData).options.clientIDLen; + if (uVar1 == 0) { + IVar4 = NULL_VALUE_ERROR; + } + else { + IVar4 = MQTT_CONNACK_UNACCEPTABLE_PROTOCOL_VERSION_ERROR; + if ((pClient->clientData).options.MQTTVersion == MQTT_3_1_1) { + rem_len = (uint)uVar1 + 0xc; + if ((pClient->clientData).options.isWillMsgPresent != false) { + rem_len = rem_len + (uint)(pClient->clientData).options.will.topicNameLen + + (uint)(pClient->clientData).options.will.msgLen + 4; + } + if ((pClient->clientData).options.pUsername != (char *)0x0) { + rem_len = rem_len + (uint)(pClient->clientData).options.usernameLen + 2; + } + if ((pClient->clientData).options.pPassword != (char *)0x0) { + rem_len = rem_len + (uint)(pClient->clientData).options.passwordLen + 2; + } + _header = puVar11; + uVar7 = aws_iot_mqtt_internal_get_final_packet_length_from_remaining_length(rem_len); + if (uVar2 < uVar7) { + IVar4 = MQTT_TX_BUFFER_TOO_SHORT_ERROR; + } + else { + IVar5 = aws_iot_mqtt_internal_init_header((MQTTHeader *)&curdata,CONNECT,QOS0,'\0','\0') + ; + IVar4 = IVar5; + if (CONCAT31(extraout_var_02,IVar5) == 0) { + aws_iot_mqtt_internal_write_char((uchar **)&header,(uchar)curdata); + sVar8 = aws_iot_mqtt_internal_write_len_to_buffer(_header,rem_len); + _header = _header + sVar8; + aws_iot_mqtt_internal_write_utf8_string((uchar **)&header,"MQTT",4); + aws_iot_mqtt_internal_write_char + ((uchar **)&header,(pClient->clientData).options.MQTTVersion); + c = ((pClient->clientData).options.isCleanSession != false) << 1; + if ((pClient->clientData).options.isWillMsgPresent != false) { + c = c | 4 | (pClient->clientData).options.will.qos << 3 | + (pClient->clientData).options.will.isRetained << 5; + } + if ((pClient->clientData).options.pPassword != (char *)0x0) { + c = c | 0x40; + } + if ((pClient->clientData).options.pUsername != (char *)0x0) { + c = c | 0x80; + } + aws_iot_mqtt_internal_write_char((uchar **)&header,c); + aws_iot_mqtt_internal_write_uint_16 + ((uchar **)&header,(pClient->clientData).options.keepAliveIntervalInSec); + string = (pClient->clientData).options.pClientID; + if (string == (char *)0x0) { + aws_iot_mqtt_internal_write_uint_16((uchar **)&header,0); + } + else { + aws_iot_mqtt_internal_write_utf8_string + ((uchar **)&header,string,(pClient->clientData).options.clientIDLen); + } + if ((pClient->clientData).options.isWillMsgPresent != false) { + aws_iot_mqtt_internal_write_utf8_string + ((uchar **)&header,(pClient->clientData).options.will.pTopicName, + (pClient->clientData).options.will.topicNameLen); + aws_iot_mqtt_internal_write_utf8_string + ((uchar **)&header,(pClient->clientData).options.will.pMessage, + (pClient->clientData).options.will.msgLen); + } + string = (pClient->clientData).options.pUsername; + if (string != (char *)0x0) { + aws_iot_mqtt_internal_write_utf8_string + ((uchar **)&header,string,(pClient->clientData).options.usernameLen); + } + string = (pClient->clientData).options.pPassword; + if (string != (char *)0x0) { + aws_iot_mqtt_internal_write_utf8_string + ((uchar **)&header,string,(pClient->clientData).options.passwordLen); + } + if (_header + -(int)puVar11 == (uchar *)0x0) { +LAB_2304f84e: + uVar9 = 3; + goto LAB_2304f850; + } + IVar4 = aws_iot_mqtt_internal_send_packet + (pClient,(size_t)(_header + -(int)puVar11),(Timer *)&ptr); + if ((CONCAT31(extraout_var_03,IVar4) == 0) && + (IVar4 = aws_iot_mqtt_internal_wait_for_read(pClient,'\x02',(Timer *)&ptr), + CONCAT31(extraout_var_04,IVar4) == 0)) { + IVar4 = MQTT_RX_BUFFER_TOO_SHORT_ERROR; + if (3 < (pClient->clientData).readBufSize) { + curdata = (uchar *)0x0; + _header = (uchar *)0x0; + puStack56 = (pClient->clientData).readBuf; + uVar6 = aws_iot_mqtt_internal_read_char(&puStack56); + IVar4 = FAILURE; + if (((CONCAT31(extraout_var_05,uVar6) >> 4 & 0xff) == 2) && + (IVar4 = aws_iot_mqtt_internal_decode_remaining_length_from_buffer + (puStack56,(uint32_t *)&curdata,(uint32_t *)&header), + CONCAT31(extraout_var_06,IVar4) == 0)) { + puStack56 = puStack56 + (int)_header; + IVar4 = MQTT_DECODE_REMAINING_LENGTH_ERROR; + if (curdata == (uchar *)0x2) { + aws_iot_mqtt_internal_read_char(&puStack56); + uVar6 = aws_iot_mqtt_internal_read_char(&puStack56); + switch(CONCAT31(extraout_var_07,uVar6)) { + case 0: + uVar1 = (pClient->clientData).keepAliveInterval; + (pClient->clientStatus).isPingOutstanding = false; + countdown_sec((Timer *)pClient,(uint)uVar1); + goto LAB_2304f84e; + case 1: + IVar4 = MQTT_CONNACK_UNACCEPTABLE_PROTOCOL_VERSION_ERROR; + break; + case 2: + IVar4 = MQTT_CONNACK_IDENTIFIER_REJECTED_ERROR; + break; + case 3: + IVar4 = MQTT_CONNACK_SERVER_UNAVAILABLE_ERROR; + break; + case 4: + IVar4 = MQTT_CONNACK_BAD_USERDATA_ERROR; + break; + case 5: + IVar4 = MQTT_CONNACK_NOT_AUTHORIZED_ERROR; + break; + default: + IVar4 = MQTT_CONNACK_UNKNOWN_ERROR; + } + } + } + } + } + } + } + } + } + } + } + else { + IVar4 = MQTT_CONNECTION_ERROR; + } + IVar5 = IVar4; + (*(pClient->networkStack).disconnect)(pNVar10); + IVar4 = (*(pClient->networkStack).destroy)(pNVar10); + uVar9 = 0xb; + if (CONCAT31(extraout_var_08,IVar4) != 0) { + return NETWORK_DISCONNECTED_ERROR; + } +LAB_2304f850: + aws_iot_mqtt_set_client_state(pClient,2,uVar9); + return IVar5; +} + + + +IoT_Error_t _aws_iot_mqtt_internal_disconnect(AWS_IoT_Client *pClient) + +{ + IoT_Error_t IVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + size_t local_20; + size_t serialized_len; + Timer timer; + + local_20 = 0; + IVar1 = aws_iot_mqtt_internal_serialize_zero + ((pClient->clientData).writeBuf,(pClient->clientData).writeBufSize,DISCONNECT, + &local_20); + if (CONCAT31(extraout_var,IVar1) == 0) { + init_timer((Timer *)&serialized_len); + countdown_ms((Timer *)&serialized_len,(pClient->clientData).commandTimeoutMs); + if (local_20 != 0) { + aws_iot_mqtt_internal_send_packet(pClient,local_20,(Timer *)&serialized_len); + } + (*(pClient->networkStack).disconnect)((Network *)&pClient->networkStack); + IVar1 = (*(pClient->networkStack).destroy)((Network *)&pClient->networkStack); + IVar1 = -(CONCAT31(extraout_var_00,IVar1) != 0); + } + return IVar1; +} + + + +IoT_Error_t aws_iot_mqtt_disconnect(AWS_IoT_Client *pClient) + +{ + ClientState CVar1; + _Bool _Var2; + IoT_Error_t IVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + int iVar4; + undefined3 extraout_var_01; + + if (pClient != (AWS_IoT_Client *)0x0) { + CVar1 = aws_iot_mqtt_get_client_state(pClient); + _Var2 = aws_iot_mqtt_is_client_connected(pClient); + IVar3 = NETWORK_DISCONNECTED_ERROR; + if (CONCAT31(extraout_var_00,_Var2) != 0) { + iVar4 = aws_iot_mqtt_set_client_state(pClient,CONCAT31(extraout_var,CVar1),10); + IVar3 = (IoT_Error_t)iVar4; + if (iVar4 == 0) { + IVar3 = _aws_iot_mqtt_internal_disconnect(pClient); + if (CONCAT31(extraout_var_01,IVar3) == 0) { + (pClient->clientStatus).clientState = CLIENT_STATE_DISCONNECTED_MANUALLY; + } + else { + (pClient->clientStatus).clientState = CVar1; + } + } + } + return IVar3; + } + return NULL_VALUE_ERROR; +} + + + +IoT_Error_t aws_iot_mqtt_attempt_reconnect(AWS_IoT_Client *pClient) + +{ + _Bool _Var1; + ClientState CVar2; + IoT_Error_t IVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + + if (pClient != (AWS_IoT_Client *)0x0) { + _Var1 = aws_iot_mqtt_is_client_connected(pClient); + IVar3 = NETWORK_ALREADY_CONNECTED_ERROR; + if (CONCAT31(extraout_var,_Var1) == 0) { + aws_iot_mqtt_connect(pClient,(IoT_Client_Connect_Params *)0x0); + CVar2 = aws_iot_mqtt_get_client_state(pClient); + if (CONCAT31(extraout_var_00,CVar2) == 3) { + IVar3 = aws_iot_mqtt_resubscribe(pClient); + if (CONCAT31(extraout_var_01,IVar3) == 0) { + IVar3 = NETWORK_RECONNECTED; + } + } + else { + aws_iot_mqtt_set_client_state(pClient,0xb,0xd); + IVar3 = NETWORK_ATTEMPTING_RECONNECT; + } + } + return IVar3; + } + return NULL_VALUE_ERROR; +} + + + +IoT_Error_t +aws_iot_mqtt_internal_serialize_ack + (uchar *pTxBuf,size_t txBufLen,MessageTypes msgType,uint8_t dup,uint16_t packetId, + uint32_t *pSerializedLen) + +{ + IoT_Error_t IVar1; + undefined3 extraout_var; + size_t sVar2; + undefined3 in_register_00002031; + uchar auStack40 [4]; + MQTTHeader header; + uchar *ptr; + + auStack40[0] = '\0'; + IVar1 = NULL_VALUE_ERROR; + if ((pTxBuf != (uchar *)0x0) && (pSerializedLen != (uint32_t *)0x0)) { + IVar1 = MQTT_TX_BUFFER_TOO_SHORT_ERROR; + if ((3 < txBufLen) && + (_header = pTxBuf, + IVar1 = aws_iot_mqtt_internal_init_header + (auStack40,msgType,CONCAT31(in_register_00002031,msgType) == 6,dup,'\0'), + CONCAT31(extraout_var,IVar1) == 0)) { + aws_iot_mqtt_internal_write_char((uchar **)&header,auStack40[0]); + sVar2 = aws_iot_mqtt_internal_write_len_to_buffer(_header,2); + _header = _header + sVar2; + aws_iot_mqtt_internal_write_uint_16((uchar **)&header,packetId); + *(uchar **)pSerializedLen = _header + -(int)pTxBuf; + } + } + return IVar1; +} + + + +IoT_Error_t +aws_iot_mqtt_internal_deserialize_publish + (uint8_t *dup,QoS *qos,uint8_t *retained,uint16_t *pPacketId,char **pTopicName, + uint16_t *topicNameLen,uchar **payload,size_t *payloadLen,uchar *pRxBuf,size_t rxBufLen) + +{ + uchar *puVar1; + byte bVar2; + IoT_Error_t IVar3; + uint16_t uVar4; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined2 extraout_var_01; + uchar *in_stack_00000000; + uint in_stack_00000004; + uchar *puStack60; + uchar *curData; + uint32_t decodedLen; + uint32_t readBytesLen; + + puStack60 = in_stack_00000000; + curData = (uchar *)0x0; + decodedLen = 0; + if ((((dup != (uint8_t *)0x0) && (qos != (QoS *)0x0)) && (retained != (uint8_t *)0x0)) && + (pPacketId != (uint16_t *)0x0)) { + if (in_stack_00000004 < 4) { + return MQTT_RX_BUFFER_TOO_SHORT_ERROR; + } + bVar2 = aws_iot_mqtt_internal_read_char(&puStack60); + _bVar2 = CONCAT31(extraout_var,bVar2); + if ((_bVar2 >> 4 & 0xff) == 3) { + *dup = (byte)((int)_bVar2 >> 3) & 1; + *qos = (byte)((int)_bVar2 >> 1) & 3; + *retained = bVar2 & 1; + IVar3 = aws_iot_mqtt_internal_decode_remaining_length_from_buffer + (puStack60,(uint32_t *)&curData,&decodedLen); + if (CONCAT31(extraout_var_00,IVar3) != 0) { + return IVar3; + } + puStack60 = puStack60 + decodedLen; + puVar1 = puStack60 + (int)curData; + if (1 < (int)curData) { + uVar4 = aws_iot_mqtt_internal_read_uint16_t(&puStack60); + *topicNameLen = uVar4; + if (puStack60 + CONCAT22(extraout_var_01,uVar4) <= puVar1) { + *(uchar **)pTopicName = puStack60; + puStack60 = puStack60 + *topicNameLen; + if (-1 < (int)(puVar1 + -(int)puStack60)) { + if (*qos != QOS0) { + uVar4 = aws_iot_mqtt_internal_read_uint16_t(&puStack60); + *pPacketId = uVar4; + } + *(uchar **)payloadLen = puVar1 + -(int)puStack60; + *payload = puStack60; + return IVar3; + } + } + } + } + } + return FAILURE; +} + + + +// WARNING: Variable defined which should be unmapped: readBytesLen + +IoT_Error_t +aws_iot_mqtt_internal_deserialize_ack + (uchar *pPacketType,uchar *dup,uint16_t *pPacketId,uchar *pRxBuf,size_t rxBuflen) + +{ + uchar uVar1; + IoT_Error_t IVar2; + uint16_t uVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + uchar *puStack28; + uchar *curdata; + uint32_t decodedLen; + uint32_t readBytesLen; + + curdata = (uchar *)0x0; + decodedLen = 0; + IVar2 = NULL_VALUE_ERROR; + if ((((pPacketType != (uchar *)0x0) && (dup != (uchar *)0x0)) && (pPacketId != (uint16_t *)0x0)) + && ((pRxBuf != (uchar *)0x0 && (IVar2 = MQTT_RX_BUFFER_TOO_SHORT_ERROR, 3 < rxBuflen)))) { + puStack28 = pRxBuf; + uVar1 = aws_iot_mqtt_internal_read_char(&puStack28); + *dup = (byte)((int)CONCAT31(extraout_var,uVar1) >> 3) & 1; + *pPacketType = (uchar)(CONCAT31(extraout_var,uVar1) >> 4); + IVar2 = aws_iot_mqtt_internal_decode_remaining_length_from_buffer + (puStack28,(uint32_t *)&curdata,&decodedLen); + if (CONCAT31(extraout_var_00,IVar2) == 0) { + puStack28 = puStack28 + decodedLen; + if ((int)curdata < 2) { + IVar2 = FAILURE; + } + else { + uVar3 = aws_iot_mqtt_internal_read_uint16_t(&puStack28); + *pPacketId = uVar3; + } + } + } + return IVar2; +} + + + +IoT_Error_t +aws_iot_mqtt_publish + (AWS_IoT_Client *pClient,char *pTopicName,uint16_t topicNameLen, + IoT_Publish_Message_Params *pParams) + +{ + QoS qos; + uint8_t retained; + _Bool _Var1; + ClientState CVar2; + IoT_Error_t IVar3; + uint16_t anInt; + undefined3 extraout_var; + undefined3 extraout_var_00; + int iVar4; + uint32_t uVar5; + undefined3 extraout_var_01; + size_t sVar6; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + undefined2 in_register_00002032; + uint uVar7; + size_t __n; + uchar *puVar8; + void *__src; + uint32_t rem_len; + uchar uStack85; + uchar auStack84 [3]; + uchar dup; + uchar type; + uint16_t packet_id; + Timer timer; + + if ((((pClient != (AWS_IoT_Client *)0x0) && (pTopicName != (char *)0x0)) && + (CONCAT22(in_register_00002032,topicNameLen) != 0)) && + (pParams != (IoT_Publish_Message_Params *)0x0)) { + _Var1 = aws_iot_mqtt_is_client_connected(pClient); + IVar3 = NETWORK_DISCONNECTED_ERROR; + if (CONCAT31(extraout_var,_Var1) != 0) { + CVar2 = aws_iot_mqtt_get_client_state(pClient); + _CVar2 = CONCAT31(extraout_var_00,CVar2); + if ((_CVar2 != 3) && (_CVar2 != 9)) { + return MQTT_CLIENT_NOT_IDLE_ERROR; + } + iVar4 = aws_iot_mqtt_set_client_state(pClient,_CVar2,5); + IVar3 = (IoT_Error_t)iVar4; + if (iVar4 == 0) { + init_timer((Timer *)&packet_id); + countdown_ms((Timer *)&packet_id,(pClient->clientData).commandTimeoutMs); + if (pParams->qos == QOS1) { + anInt = aws_iot_mqtt_get_next_packet_id(pClient); + pParams->id = anInt; + } + __src = pParams->payload; + auStack84[0] = '\0'; + puVar8 = (pClient->clientData).writeBuf; + uVar7 = (pClient->clientData).writeBufSize; + qos = pParams->qos; + retained = pParams->isRetained; + anInt = pParams->id; + __n = pParams->payloadLen; + iVar4 = -2; + if (__src != (void *)0x0) { + iVar4 = CONCAT22(in_register_00002032,topicNameLen) + __n; + rem_len = iVar4 + 4; + if (qos == QOS0) { + rem_len = iVar4 + 2; + } + _type = puVar8; + uVar5 = aws_iot_mqtt_internal_get_final_packet_length_from_remaining_length(rem_len); + iVar4 = -0x21; + if (uVar5 <= uVar7) { + IVar3 = aws_iot_mqtt_internal_init_header(auStack84,PUBLISH,qos,'\0',retained); + iVar4 = CONCAT31(extraout_var_01,IVar3); + if (iVar4 == 0) { + aws_iot_mqtt_internal_write_char((uchar **)&type,auStack84[0]); + sVar6 = aws_iot_mqtt_internal_write_len_to_buffer(_type,rem_len); + _type = _type + sVar6; + aws_iot_mqtt_internal_write_utf8_string((uchar **)&type,pTopicName,topicNameLen); + if (qos != QOS0) { + aws_iot_mqtt_internal_write_uint_16((uchar **)&type,anInt); + } + memcpy(_type,__src,__n); + IVar3 = aws_iot_mqtt_internal_send_packet + (pClient,(size_t)(_type + (__n - (int)puVar8)),(Timer *)&packet_id); + iVar4 = CONCAT31(extraout_var_02,IVar3); + if ((iVar4 == 0) && (pParams->qos == QOS1)) { + IVar3 = aws_iot_mqtt_internal_wait_for_read(pClient,'\x04',(Timer *)&packet_id); + iVar4 = CONCAT31(extraout_var_03,IVar3); + if (iVar4 == 0) { + IVar3 = aws_iot_mqtt_internal_deserialize_ack + (auStack84,&uStack85,(uint16_t *)&type, + (pClient->clientData).readBuf,(pClient->clientData).readBufSize + ); + iVar4 = CONCAT31(extraout_var_04,IVar3); + } + } + } + } + } + IVar3 = aws_iot_mqtt_set_client_state(pClient,5,_CVar2); + if (iVar4 != 0) { + IVar3 = (IoT_Error_t)iVar4; + } + } + } + return IVar3; + } + return NULL_VALUE_ERROR; +} + + + +IoT_Error_t +_aws_iot_mqtt_deserialize_suback + (uint16_t *pPacketId,uint32_t *pGrantedQoSCount,QoS *pGrantedQoSs,uchar *pRxBuf, + size_t rxBufLen) + +{ + uchar *puVar1; + uchar uVar2; + IoT_Error_t IVar3; + QoS QVar4; + uint16_t uVar5; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint uVar6; + uchar *puStack44; + uchar *curData; + uint32_t decodedLen; + uint32_t readBytesLen; + + curData = (uchar *)0x0; + decodedLen = 0; + if (rxBufLen < 5) { + return MQTT_RX_BUFFER_TOO_SHORT_ERROR; + } + puStack44 = pRxBuf; + uVar2 = aws_iot_mqtt_internal_read_char(&puStack44); + if ((CONCAT31(extraout_var,uVar2) >> 4 & 0xff) == 9) { + IVar3 = aws_iot_mqtt_internal_decode_remaining_length_from_buffer + (puStack44,(uint32_t *)&curData,&decodedLen); + if (CONCAT31(extraout_var_00,IVar3) != 0) { + return IVar3; + } + puStack44 = puStack44 + decodedLen; + puVar1 = puStack44 + (int)curData; + if (1 < (int)curData) { + uVar5 = aws_iot_mqtt_internal_read_uint16_t(&puStack44); + *pPacketId = uVar5; + *pGrantedQoSCount = 0; + while( true ) { + if (puVar1 <= puStack44) { + return IVar3; + } + uVar6 = *pGrantedQoSCount; + if (1 < uVar6) break; + *pGrantedQoSCount = uVar6 + 1; + QVar4 = aws_iot_mqtt_internal_read_char(&puStack44); + pGrantedQoSs[uVar6] = QVar4; + } + } + } + return FAILURE; +} + + + +IoT_Error_t +_aws_iot_mqtt_serialize_subscribe + (uchar *pTxBuf,size_t txBufLen,uint16_t packetId,char **pTopicNameList, + uint16_t *pTopicNameLenList,QoS *pRequestedQoSs,uint32_t *pSerializedLen) + +{ + ushort uVar1; + IoT_Error_t IVar2; + uint32_t uVar3; + undefined3 extraout_var; + size_t sVar4; + uchar auStack56 [4]; + MQTTHeader header; + uchar *ptr; + + uVar1 = *pTopicNameLenList; + auStack56[0] = '\0'; + _header = pTxBuf; + uVar3 = aws_iot_mqtt_internal_get_final_packet_length_from_remaining_length((uint)uVar1 + 5); + IVar2 = MQTT_TX_BUFFER_TOO_SHORT_ERROR; + if ((uVar3 <= txBufLen) && + (IVar2 = aws_iot_mqtt_internal_init_header(auStack56,SUBSCRIBE,QOS1,'\0','\0'), + CONCAT31(extraout_var,IVar2) == 0)) { + aws_iot_mqtt_internal_write_char((uchar **)&header,auStack56[0]); + sVar4 = aws_iot_mqtt_internal_write_len_to_buffer(_header,(uint)uVar1 + 5); + _header = _header + sVar4; + aws_iot_mqtt_internal_write_uint_16((uchar **)&header,packetId); + aws_iot_mqtt_internal_write_utf8_string((uchar **)&header,*pTopicNameList,*pTopicNameLenList); + aws_iot_mqtt_internal_write_char((uchar **)&header,*pRequestedQoSs); + *(uchar **)pSerializedLen = _header + -(int)pTxBuf; + } + return IVar2; +} + + + +// WARNING: Variable defined which should be unmapped: timer +// WARNING: Could not reconcile some variable overlaps + +IoT_Error_t +aws_iot_mqtt_subscribe + (AWS_IoT_Client *pClient,char *pTopicName,uint16_t topicNameLen,QoS qos, + pApplicationHandler_t *pApplicationHandler,void *pApplicationHandlerData) + +{ + int iVar1; + _Bool _Var2; + ClientState CVar3; + IoT_Error_t IVar4; + uint16_t packetId; + undefined3 extraout_var; + undefined3 extraout_var_00; + int iVar5; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + Timer *pTVar6; + MessageHandlers_conflict40 *pMVar7; + QoS QStack65; + uint16_t uStack64; + uint16_t uStack62; + undefined2 uStack60; + uint16_t rxPacketId; + QoS grantedQoS [3]; + uint32_t uStack52; + uint32_t serializedLen; + uint32_t count; + Timer timer; + + if (((pClient == (AWS_IoT_Client *)0x0) || (pTopicName == (char *)0x0)) || + (pApplicationHandler == (pApplicationHandler_t *)0x0)) { + return NULL_VALUE_ERROR; + } + _Var2 = aws_iot_mqtt_is_client_connected(pClient); + IVar4 = NETWORK_DISCONNECTED_ERROR; + if (CONCAT31(extraout_var,_Var2) != 0) { + CVar3 = aws_iot_mqtt_get_client_state(pClient); + _CVar3 = CONCAT31(extraout_var_00,CVar3); + if ((_CVar3 != 3) && (_CVar3 != 9)) { + return MQTT_CLIENT_NOT_IDLE_ERROR; + } + iVar5 = aws_iot_mqtt_set_client_state(pClient,_CVar3,6); + IVar4 = (IoT_Error_t)iVar5; + if (iVar5 == 0) { + uStack60 = 0; + rxPacketId._0_1_ = 0; + QStack65 = qos; + uStack64 = topicNameLen; + _grantedQoS = pTopicName; + init_timer((Timer *)&count); + countdown_ms((Timer *)&count,(pClient->clientData).commandTimeoutMs); + uStack52 = 0; + serializedLen = 0; + packetId = aws_iot_mqtt_get_next_packet_id(pClient); + uStack62 = 0; + IVar4 = _aws_iot_mqtt_serialize_subscribe + ((pClient->clientData).writeBuf,(pClient->clientData).writeBufSize,packetId, + (char **)grantedQoS,&uStack64,&QStack65,&uStack52); + iVar5 = CONCAT31(extraout_var_01,IVar4); + if (iVar5 == 0) { + pMVar7 = (pClient->clientData).messageHandlers; + iVar1 = 0; + do { + if (pMVar7->topicName == (char *)0x0) { + IVar4 = aws_iot_mqtt_internal_send_packet(pClient,uStack52,(Timer *)&count); + iVar5 = CONCAT31(extraout_var_02,IVar4); + if (iVar5 == 0) { + IVar4 = aws_iot_mqtt_internal_wait_for_read(pClient,'\t',(Timer *)&count); + iVar5 = CONCAT31(extraout_var_03,IVar4); + if (iVar5 == 0) { + IVar4 = _aws_iot_mqtt_deserialize_suback + (&uStack62,&serializedLen,(QoS *)&uStack60, + (pClient->clientData).readBuf,(pClient->clientData).readBufSize); + iVar5 = CONCAT31(extraout_var_04,IVar4); + if (iVar5 == 0) { + pTVar6 = (Timer *)((int)&pClient->pingTimer + iVar1 * 0x10); + *(char **)&pTVar6[0x60].last_polled_ticks = _grantedQoS; + *(pApplicationHandler_t **)&pTVar6[0x61].timeout_ticks = pApplicationHandler; + *(void **)&pTVar6[0x61].last_polled_ticks = pApplicationHandlerData; + *(uint16_t *)&pTVar6[0x61].start_ticks = uStack64; + *(QoS *)((int)&pTVar6[0x61].start_ticks + 2) = QStack65; + } + } + } + goto LAB_2304ff0e; + } + iVar1 = iVar1 + 1; + pMVar7 = pMVar7 + 1; + } while (iVar1 != 5); + iVar5 = -0x22; + } +LAB_2304ff0e: + IVar4 = aws_iot_mqtt_set_client_state(pClient,6,_CVar3); + if (iVar5 != 0) { + IVar4 = (IoT_Error_t)iVar5; + } + } + } + return IVar4; +} + + + +// WARNING: Variable defined which should be unmapped: timer +// WARNING: Could not reconcile some variable overlaps + +IoT_Error_t aws_iot_mqtt_resubscribe(AWS_IoT_Client *pClient) + +{ + int iVar1; + _Bool _Var2; + ClientState CVar3; + IoT_Error_t IVar4; + uint16_t packetId_00; + undefined3 extraout_var; + undefined3 extraout_var_00; + int iVar5; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + size_t txBufLen; + MessageHandlers_conflict40 *pMVar6; + MessageHandlers_conflict40 *pTopicNameList; + int iVar7; + uint16_t uStack58; + undefined2 uStack56; + uint16_t packetId; + QoS grantedQoS [3]; + uint32_t len; + uint32_t count; + Timer timer; + + if (pClient == (AWS_IoT_Client *)0x0) { + return NULL_VALUE_ERROR; + } + _Var2 = aws_iot_mqtt_is_client_connected(pClient); + IVar4 = NETWORK_DISCONNECTED_ERROR; + if (CONCAT31(extraout_var,_Var2) != 0) { + CVar3 = aws_iot_mqtt_get_client_state(pClient); + IVar4 = MQTT_CLIENT_NOT_IDLE_ERROR; + if (CONCAT31(extraout_var_00,CVar3) == 3) { + iVar5 = aws_iot_mqtt_set_client_state(pClient,3,8); + IVar4 = (IoT_Error_t)iVar5; + if (iVar5 == 0) { + pTopicNameList = (pClient->clientData).messageHandlers; + uStack56 = 0; + packetId._0_1_ = 0; + uStack58 = 0; + _grantedQoS = 0; + len = 0; + iVar5 = 0; + pMVar6 = pTopicNameList; + do { + if (pMVar6->topicName == (char *)0x0) break; + iVar5 = iVar5 + 1; + pMVar6 = pMVar6 + 1; + } while (iVar5 != 5); + iVar7 = 0; + while (iVar5 != iVar7) { + if (pTopicNameList->topicName != (char *)0x0) { + init_timer((Timer *)&count); + countdown_ms((Timer *)&count,(pClient->clientData).commandTimeoutMs); + txBufLen = (pClient->clientData).writeBufSize; + packetId_00 = aws_iot_mqtt_get_next_packet_id(pClient); + IVar4 = _aws_iot_mqtt_serialize_subscribe + ((pClient->clientData).writeBuf,txBufLen,packetId_00, + (char **)pTopicNameList,&pTopicNameList->topicNameLen, + &pTopicNameList->qos,(uint32_t *)grantedQoS); + iVar1 = CONCAT31(extraout_var_01,IVar4); + if (iVar1 != 0) goto LAB_23050076; + IVar4 = aws_iot_mqtt_internal_send_packet(pClient,_grantedQoS,(Timer *)&count); + iVar1 = CONCAT31(extraout_var_02,IVar4); + if (iVar1 != 0) goto LAB_23050076; + IVar4 = aws_iot_mqtt_internal_wait_for_read(pClient,'\t',(Timer *)&count); + iVar1 = CONCAT31(extraout_var_03,IVar4); + if (iVar1 != 0) goto LAB_23050076; + IVar4 = _aws_iot_mqtt_deserialize_suback + (&uStack58,&len,(QoS *)&uStack56,(pClient->clientData).readBuf, + (pClient->clientData).readBufSize); + iVar1 = CONCAT31(extraout_var_04,IVar4); + if (iVar1 != 0) goto LAB_23050076; + } + iVar7 = iVar7 + 1; + pTopicNameList = pTopicNameList + 1; + } + iVar1 = 0; +LAB_23050076: + IVar4 = aws_iot_mqtt_set_client_state(pClient,8,3); + if (iVar1 != 0) { + IVar4 = (IoT_Error_t)iVar1; + } + } + } + } + return IVar4; +} + + + +// WARNING: Variable defined which should be unmapped: timer + +IoT_Error_t +aws_iot_mqtt_unsubscribe(AWS_IoT_Client *pClient,char *pTopicFilter,uint16_t topicFilterLen) + +{ + MessageHandlers_conflict40 *pMVar1; + _Bool _Var2; + ClientState CVar3; + IoT_Error_t IVar4; + uint16_t anInt; + undefined3 extraout_var; + undefined3 extraout_var_00; + int iVar5; + uint32_t uVar6; + undefined3 extraout_var_01; + size_t sVar7; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + int iVar8; + undefined2 in_register_00002032; + MessageHandlers_conflict40 *pMVar9; + uint32_t rem_len; + uchar *puVar10; + MessageHandlers_conflict40 *pMVar11; + uint uVar12; + uchar uStack69; + uchar auStack68 [3]; + uchar type; + uchar dup; + uint16_t packet_id; + Timer timer; + + if ((pClient == (AWS_IoT_Client *)0x0) || (pTopicFilter == (char *)0x0)) { + return NULL_VALUE_ERROR; + } + _Var2 = aws_iot_mqtt_is_client_connected(pClient); + if (CONCAT31(extraout_var,_Var2) == 0) { + return NETWORK_DISCONNECTED_ERROR; + } + CVar3 = aws_iot_mqtt_get_client_state(pClient); + _CVar3 = CONCAT31(extraout_var_00,CVar3); + if ((_CVar3 != 3) && (_CVar3 != 9)) { + return MQTT_CLIENT_NOT_IDLE_ERROR; + } + iVar5 = aws_iot_mqtt_set_client_state(pClient,_CVar3,7); + if (iVar5 != 0) { + IVar4 = aws_iot_mqtt_set_client_state(pClient,7,_CVar3); + return IVar4; + } + pMVar9 = (pClient->clientData).messageHandlers; + pMVar11 = (MessageHandlers_conflict40 *)&(pClient->clientData).disconnectHandler; + pMVar1 = pMVar9; + do { + if ((pMVar1->topicName != (char *)0x0) && + (iVar5 = strcmp(pMVar1->topicName,pTopicFilter), iVar5 == 0)) { + init_timer((Timer *)&packet_id); + rem_len = CONCAT22(in_register_00002032,topicFilterLen) + 4; + countdown_ms((Timer *)&packet_id,(pClient->clientData).commandTimeoutMs); + uVar12 = (pClient->clientData).writeBufSize; + anInt = aws_iot_mqtt_get_next_packet_id(pClient); + puVar10 = (pClient->clientData).writeBuf; + auStack68[0] = '\0'; + _dup = puVar10; + uVar6 = aws_iot_mqtt_internal_get_final_packet_length_from_remaining_length(rem_len); + iVar5 = -0x21; + if (uVar12 < uVar6) goto LAB_23050136; + IVar4 = aws_iot_mqtt_internal_init_header(auStack68,UNSUBSCRIBE,QOS1,'\0','\0'); + iVar5 = CONCAT31(extraout_var_01,IVar4); + if (iVar5 != 0) goto LAB_23050136; + aws_iot_mqtt_internal_write_char((uchar **)&dup,auStack68[0]); + sVar7 = aws_iot_mqtt_internal_write_len_to_buffer(_dup,rem_len); + _dup = _dup + sVar7; + aws_iot_mqtt_internal_write_uint_16((uchar **)&dup,anInt); + aws_iot_mqtt_internal_write_utf8_string((uchar **)&dup,pTopicFilter,topicFilterLen); + IVar4 = aws_iot_mqtt_internal_send_packet + (pClient,(size_t)(_dup + -(int)puVar10),(Timer *)&packet_id); + iVar5 = CONCAT31(extraout_var_02,IVar4); + if (iVar5 != 0) goto LAB_23050136; + IVar4 = aws_iot_mqtt_internal_wait_for_read(pClient,'\v',(Timer *)&packet_id); + iVar5 = CONCAT31(extraout_var_03,IVar4); + if (iVar5 != 0) goto LAB_23050136; + uStack69 = '\0'; + auStack68[0] = '\0'; + IVar4 = aws_iot_mqtt_internal_deserialize_ack + (&uStack69,auStack68,(uint16_t *)&dup,(pClient->clientData).readBuf, + (pClient->clientData).readBufSize); + iVar5 = CONCAT31(extraout_var_04,IVar4); + if (iVar5 != 0) goto LAB_23050136; + if (uStack69 == '\v') goto LAB_2305020a; + break; + } + pMVar1 = pMVar1 + 1; + } while (pMVar1 != pMVar11); + iVar5 = -1; +LAB_23050136: + IVar4 = aws_iot_mqtt_set_client_state(pClient,7,_CVar3); + if (iVar5 != 0) { + IVar4 = (IoT_Error_t)iVar5; + } + return IVar4; +LAB_2305020a: + do { + if ((pMVar9->topicName != (char *)0x0) && + (iVar8 = strcmp(pMVar9->topicName,pTopicFilter), iVar8 == 0)) { + pMVar9->topicName = (char *)0x0; + } + pMVar9 = pMVar9 + 1; + } while (pMVar9 != pMVar11); + goto LAB_23050136; +} + + + +IoT_Error_t _aws_iot_mqtt_handle_disconnect(AWS_IoT_Client *pClient) + +{ + IoT_Error_t IVar1; + undefined3 extraout_var; + iot_disconnect_handler *piVar2; + + IVar1 = aws_iot_mqtt_disconnect(pClient); + if (CONCAT31(extraout_var,IVar1) != 0) { + (pClient->clientStatus).clientState = CLIENT_STATE_DISCONNECTED_ERROR; + (*(pClient->networkStack).disconnect)((Network *)&pClient->networkStack); + (*(pClient->networkStack).destroy)((Network *)&pClient->networkStack); + } + piVar2 = (pClient->clientData).disconnectHandler; + if (piVar2 != (iot_disconnect_handler *)0x0) { + (*piVar2)(pClient,(pClient->clientData).disconnectHandlerData); + } + (pClient->clientStatus).clientState = CLIENT_STATE_DISCONNECTED_ERROR; + return NETWORK_DISCONNECTED_ERROR; +} + + + +// WARNING: Variable defined which should be unmapped: timer_1 +// WARNING: Could not reconcile some variable overlaps + +IoT_Error_t aws_iot_mqtt_yield(AWS_IoT_Client *pClient,uint32_t timeout_ms) + +{ + ushort uVar1; + ClientState CVar2; + _Bool _Var3; + IoT_Error_t IVar4; + byte bVar5; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + int iVar6; + undefined3 extraout_var_04; + undefined3 extraout_var_05; + undefined3 extraout_var_06; + undefined3 extraout_var_07; + undefined3 extraout_var_08; + undefined3 extraout_var_09; + undefined3 extraout_var_10; + uint timeout; + anon_subr_IoT_Error_t_Network_ptr_for_isConnected *paVar7; + int iVar8; + Timer *timer_00; + uint8_t uStack61; + uint8_t packet_type; + size_t sStack60; + size_t serialized_len; + Timer timer; + Timer timer_1; + + if (pClient == (AWS_IoT_Client *)0x0) { + return NULL_VALUE_ERROR; + } + if (timeout_ms == 0) { + return NULL_VALUE_ERROR; + } + CVar2 = aws_iot_mqtt_get_client_state(pClient); + iVar6 = CONCAT31(extraout_var,CVar2); + if (iVar6 == 0xc) { + return NETWORK_MANUALLY_DISCONNECTED; + } + if (iVar6 != 0xd) { + _Var3 = aws_iot_mqtt_is_client_connected(pClient); + if (CONCAT31(extraout_var_05,_Var3) == 0) { + return NETWORK_DISCONNECTED_ERROR; + } + if (iVar6 != 3) { + return MQTT_CLIENT_NOT_IDLE_ERROR; + } + iVar6 = aws_iot_mqtt_set_client_state(pClient,3,4); + if (iVar6 != 0) { + return (IoT_Error_t)iVar6; + } + } + init_timer((Timer *)&serialized_len); + countdown_ms((Timer *)&serialized_len,timeout_ms); + timer_00 = &pClient->reconnectDelayTimer; + do { + CVar2 = aws_iot_mqtt_get_client_state(pClient); + if (CONCAT31(extraout_var_00,CVar2) == 0xd) { + if (0x1f400 < (pClient->clientData).currentReconnectWaitInterval) { + iVar6 = -0xe; + goto LAB_2305042e; + } + _Var3 = has_timer_expired(timer_00); + iVar6 = 4; + if (CONCAT31(extraout_var_01,_Var3) != 0) { + paVar7 = (pClient->networkStack).isConnected; + if (paVar7 == (anon_subr_IoT_Error_t_Network_ptr_for_isConnected *)0x0) { + iVar8 = -0x12; + } + else { + IVar4 = (*paVar7)((Network *)&pClient->networkStack); + iVar8 = CONCAT31(extraout_var_02,IVar4); + if (iVar8 == 6) { + IVar4 = aws_iot_mqtt_attempt_reconnect(pClient); + iVar8 = CONCAT31(extraout_var_03,IVar4); + if (iVar8 == 3) { + iVar6 = aws_iot_mqtt_set_client_state(pClient,3,4); + if (iVar6 == 0) { + iVar6 = 3; + } + goto LAB_2305030e; + } + } + } + timeout = (pClient->clientData).currentReconnectWaitInterval << 1; + (pClient->clientData).currentReconnectWaitInterval = timeout; + iVar6 = -0xe; + if (timeout < 0x1f401) { + countdown_ms(timer_00,timeout); + iVar6 = iVar8; + } + } + } + else { + bVar5 = aws_iot_mqtt_internal_cycle_read(pClient,(Timer *)&serialized_len,&uStack61); + iVar6 = CONCAT31(extraout_var_06,bVar5); + if (iVar6 == 0) { + if (((pClient->clientData).keepAliveInterval == 0) || + (_Var3 = has_timer_expired((Timer *)pClient), CONCAT31(extraout_var_07,_Var3) == 0)) + goto LAB_2305030e; + if ((pClient->clientStatus).isPingOutstanding == false) { + init_timer((Timer *)&timer.last_polled_ticks); + countdown_ms((Timer *)&timer.last_polled_ticks,(pClient->clientData).commandTimeoutMs); + sStack60 = 0; + IVar4 = aws_iot_mqtt_internal_serialize_zero + ((pClient->clientData).writeBuf,(pClient->clientData).writeBufSize, + PINGREQ,(size_t *)&stack0xffffffc4); + iVar6 = CONCAT31(extraout_var_09,IVar4); + if (iVar6 == 0) { + IVar4 = aws_iot_mqtt_internal_send_packet + (pClient,sStack60,(Timer *)&timer.last_polled_ticks); + iVar6 = CONCAT31(extraout_var_10,IVar4); + if (iVar6 == 0) { + uVar1 = (pClient->clientData).keepAliveInterval; + (pClient->clientStatus).isPingOutstanding = true; + countdown_sec((Timer *)pClient,(uint)uVar1); + goto LAB_2305030e; + } + goto LAB_23050392; + } + } + else { +LAB_23050392: + IVar4 = _aws_iot_mqtt_handle_disconnect(pClient); + iVar6 = CONCAT31(extraout_var_08,IVar4); + } + if (iVar6 != -0xd) { + if (iVar6 == 0) goto LAB_2305030e; + goto LAB_2305042e; + } + } + else { + if (((bVar5 & 0xfd) == 0xf4) || (iVar6 == -7)) goto LAB_23050392; + if (iVar6 != -0xd) goto LAB_2305042e; + } + (pClient->clientData).counterNetworkDisconnected = + (pClient->clientData).counterNetworkDisconnected + 1; + if ((pClient->clientStatus).isAutoReconnectEnabled == false) { + return NETWORK_DISCONNECTED_ERROR; + } + iVar6 = aws_iot_mqtt_set_client_state(pClient,0xb,0xd); + if (iVar6 != 0) break; + (pClient->clientData).currentReconnectWaitInterval = 1000; + countdown_ms(timer_00,1000); + iVar6 = 4; + } +LAB_2305030e: + _Var3 = has_timer_expired((Timer *)&serialized_len); + } while (CONCAT31(extraout_var_04,_Var3) == 0); + if (iVar6 == -0xd) { + return NETWORK_DISCONNECTED_ERROR; + } +LAB_2305042e: + if (iVar6 == 4) { + return (IoT_Error_t)iVar6; + } + IVar4 = aws_iot_mqtt_set_client_state(pClient,4,3); + if (iVar6 == 0) { + return IVar4; + } + return (IoT_Error_t)iVar6; +} + + + +IoT_Error_t iot_tls_is_connected(Network *pNetwork) + +{ + return NETWORK_PHYSICAL_LAYER_CONNECTED; +} + + + +// WARNING: Variable defined which should be unmapped: info_buf + +IoT_Error_t iot_tls_connect(Network *pNetwork,TLSConnectParams *params) + +{ + _Bool _Var1; + mbedtls_ssl_context *ssl; + size_t len; + int authmode; + uint uVar2; + mbedtls_x509_crt *crt; + uchar *buf; + char *__format; + char *pcVar3; + uint32_t uVar4; + char *pcVar5; + char *pcVar6; + IoT_Error_t IVar7; + mbedtls_ssl_config *conf; + mbedtls_net_context *ctx; + mbedtls_pk_context *ctx_00; + mbedtls_x509_crt *crt_00; + mbedtls_ctr_drbg_context_conflict *ctx_01; + char acStack312 [4]; + char portBuffer [6]; + char info_buf [256]; + + if (pNetwork == (Network *)0x0) { + return NULL_VALUE_ERROR; + } + if (params != (TLSConnectParams *)0x0) { + pcVar3 = params->pRootCALocation; + pcVar5 = params->pDeviceCertLocation; + __format = params->pDevicePrivateKeyLocation; + pcVar6 = params->pDestinationURL; + uVar4 = params->timeout_ms; + _Var1 = params->ServerVerificationFlag; + (pNetwork->tlsConnectParams).DestinationPort = params->DestinationPort; + (pNetwork->tlsConnectParams).pDestinationURL = pcVar6; + (pNetwork->tlsConnectParams).pDeviceCertLocation = pcVar5; + (pNetwork->tlsConnectParams).pDevicePrivateKeyLocation = __format; + (pNetwork->tlsConnectParams).pRootCALocation = pcVar3; + (pNetwork->tlsConnectParams).timeout_ms = uVar4; + (pNetwork->tlsConnectParams).ServerVerificationFlag = _Var1; + } + ctx = &(pNetwork->tlsDataParams).server_fd; + mbedtls_net_init(ctx); + ssl = (mbedtls_ssl_context *)&(pNetwork->tlsDataParams).ssl; + mbedtls_ssl_init(ssl); + conf = (mbedtls_ssl_config *)&(pNetwork->tlsDataParams).conf; + mbedtls_ssl_config_init(conf); + ctx_01 = (mbedtls_ctr_drbg_context_conflict *)&(pNetwork->tlsDataParams).ctr_drbg; + mbedtls_ctr_drbg_init(ctx_01); + crt_00 = &(pNetwork->tlsDataParams).cacert; + mbedtls_x509_crt_init(crt_00); + crt = &(pNetwork->tlsDataParams).clicert; + mbedtls_x509_crt_init(crt); + ctx_00 = &(pNetwork->tlsDataParams).pkey; + mbedtls_pk_init(ctx_00); + printf("DEBUG Seeding the random number generator...\r\n"); + mbedtls_entropy_init((mbedtls_entropy_context *)&pNetwork->tlsDataParams); + __format = TAG; + len = strlen(TAG); + authmode = mbedtls_ctr_drbg_seed + (ctx_01,mbedtls_entropy_func,&pNetwork->tlsDataParams,(uchar *)__format,len); + if (authmode != 0) { + printf("ERROR failed! mbedtls_ctr_drbg_seed returned -0x%x\r\n",-authmode); + return NETWORK_MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED; + } + if (*(pNetwork->tlsConnectParams).pRootCALocation == '/') { + printf("DEBUG Loading CA root certificate from file ...\r\n"); + authmode = mbedtls_x509_crt_parse_file(crt_00,(pNetwork->tlsConnectParams).pRootCALocation); + } + else { + printf("DEBUG Loading embedded CA root certificate ...\r\n"); + buf = (uchar *)(pNetwork->tlsConnectParams).pRootCALocation; + len = strlen((char *)buf); + authmode = mbedtls_x509_crt_parse(crt_00,buf,len + 1); + } + if (authmode < 0) { + printf("ERROR failed! mbedtls_x509_crt_parse returned -0x%x while parsing root cert\r\n", + -authmode); + return NETWORK_X509_ROOT_CRT_PARSE_ERROR; + } + printf("DEBUG ok (%d skipped)\r\n",authmode); + if (*(pNetwork->tlsConnectParams).pDeviceCertLocation == '/') { + printf("DEBUG Loading client cert from file...\r\n"); + authmode = mbedtls_x509_crt_parse_file(crt,(pNetwork->tlsConnectParams).pDeviceCertLocation); + } + else { + printf("DEBUG Loading embedded client certificate...\r\n"); + buf = (uchar *)(pNetwork->tlsConnectParams).pDeviceCertLocation; + len = strlen((char *)buf); + authmode = mbedtls_x509_crt_parse(crt,buf,len + 1); + } + if (authmode != 0) { + printf("ERROR failed! mbedtls_x509_crt_parse returned -0x%x while parsing device cert\r\n", + -authmode); + return NETWORK_X509_DEVICE_CRT_PARSE_ERROR; + } + if (*(pNetwork->tlsConnectParams).pDevicePrivateKeyLocation == '/') { + printf("DEBUG Loading client private key from file...\r\n"); + authmode = mbedtls_pk_parse_keyfile + (ctx_00,(pNetwork->tlsConnectParams).pDevicePrivateKeyLocation,""); + } + else { + printf("DEBUG Loading embedded client private key...\r\n"); + buf = (uchar *)(pNetwork->tlsConnectParams).pDevicePrivateKeyLocation; + len = strlen((char *)buf); + authmode = mbedtls_pk_parse_key(ctx_00,buf,len + 1,"",0); + } + if (authmode != 0) { + printf("ERROR failed! mbedtls_pk_parse_key returned -0x%x while parsing private key\r\n", + -authmode); + return NETWORK_PK_PRIVATE_KEY_PARSE_ERROR; + } + printf("DEBUG ok\r\n"); + snprintf(acStack312,6,"%d",(uint)(pNetwork->tlsConnectParams).DestinationPort); + printf("DEBUG Connecting to %s/%s...\r\n",(pNetwork->tlsConnectParams).pDestinationURL,acStack312) + ; + authmode = mbedtls_net_connect(ctx,(pNetwork->tlsConnectParams).pDestinationURL,acStack312,0); + if (authmode != 0) { + printf("ERROR failed! mbedtls_net_connect returned -0x%x\r\n",-authmode); + if (authmode == -0x52) { + return NETWORK_ERR_NET_UNKNOWN_HOST; + } + if (authmode == -0x42) { + return NETWORK_ERR_NET_SOCKET_FAILED; + } + return NETWORK_ERR_NET_CONNECT_FAILED; + } + authmode = mbedtls_net_set_block(ctx); + if (authmode != 0) { + authmode = -authmode; + __format = "ERROR failed! net_set_(non)block() returned -0x%x\r\n"; +LAB_2305072e: + printf(__format,authmode); + return SSL_CONNECTION_ERROR; + } + printf("DEBUG ok\r\n"); + printf("DEBUG Setting up the SSL/TLS structure...\r\n"); + authmode = mbedtls_ssl_config_defaults(conf,0,0,0); + if (authmode != 0) { + authmode = -authmode; + __format = "ERROR failed! mbedtls_ssl_config_defaults returned -0x%x\r\n"; + goto LAB_2305072e; + } + mbedtls_ssl_conf_verify(conf,_iot_tls_verify_cert,(void *)0x0); + authmode = 2; + if ((pNetwork->tlsConnectParams).ServerVerificationFlag == false) { + authmode = 1; + } + mbedtls_ssl_conf_authmode(conf,authmode); + mbedtls_ssl_conf_rng(conf,mbedtls_ctr_drbg_random,ctx_01); + mbedtls_ssl_conf_ca_chain(conf,crt_00,(mbedtls_x509_crl *)0x0); + authmode = mbedtls_ssl_conf_own_cert(conf,crt,ctx_00); + if (authmode != 0) { + __format = "ERROR failed! mbedtls_ssl_conf_own_cert returned %d\r\n"; + goto LAB_2305072e; + } + mbedtls_ssl_conf_read_timeout(conf,(pNetwork->tlsConnectParams).timeout_ms); + if ((pNetwork->tlsConnectParams).DestinationPort == 0x1bb) { + stack0xfffffed0 = "x-amzn-mqtt-ca"; + authmode = mbedtls_ssl_conf_alpn_protocols(conf,(char **)(portBuffer + 4)); + if (authmode != 0) { + authmode = -authmode; + __format = "ERROR failed! mbedtls_ssl_conf_alpn_protocols returned -0x%x\r\n"; + goto LAB_2305072e; + } + } + authmode = mbedtls_ssl_setup(ssl,conf); + if (authmode != 0) { + authmode = -authmode; + __format = "ERROR failed! mbedtls_ssl_setup returned -0x%x\r\n"; + goto LAB_2305072e; + } + authmode = mbedtls_ssl_set_hostname(ssl,(pNetwork->tlsConnectParams).pDestinationURL); + if (authmode != 0) { + __format = "ERROR failed! mbedtls_ssl_set_hostname returned %d\r\n"; + goto LAB_2305072e; + } + printf("DEBUG SSL state connect : %d \r\n",(pNetwork->tlsDataParams).ssl.state); + mbedtls_ssl_set_bio(ssl,ctx,mbedtls_net_send,(mbedtls_ssl_recv_t *)0x0,mbedtls_net_recv_timeout); + printf("DEBUG ok\r\n"); + printf("DEBUG SSL state connect : %d \r\n",(pNetwork->tlsDataParams).ssl.state); + printf("DEBUG Performing the SSL/TLS handshake...\r\n"); + while( true ) { + uVar2 = mbedtls_ssl_handshake(ssl); + IVar7 = (IoT_Error_t)uVar2; + if (uVar2 == 0) break; + if ((uVar2 & 0xffffff7f) != 0xffff9700) { + printf("ERROR failed! mbedtls_ssl_handshake returned -0x%x\r\n",-uVar2); + if (uVar2 != 0xffffd900) { + return SSL_CONNECTION_ERROR; + } + printf("ERROR Unable to verify the server\'s certificate. \r\n"); + return SSL_CONNECTION_ERROR; + } + } + __format = mbedtls_ssl_get_version(ssl); + pcVar3 = mbedtls_ssl_get_ciphersuite(ssl); + printf("DEBUG ok [ Protocol is %s ] [ Ciphersuite is %s ]\r\n",__format,pcVar3); + authmode = mbedtls_ssl_get_record_expansion(ssl); + if (authmode < 0) { + printf("DEBUG [ Record expansion is unknown (compression) ]\r\n",authmode); + } + else { + printf("DEBUG [ Record expansion is %d ]\r\n",authmode); + } + printf("DEBUG Verifying peer X.509 certificate...\r\n"); + if ((pNetwork->tlsConnectParams).ServerVerificationFlag == false) { + __format = "WARNN Server Verification skipped\r\n"; + } + else { + uVar4 = mbedtls_ssl_get_verify_result(ssl); + (pNetwork->tlsDataParams).flags = uVar4; + if (uVar4 != 0) { + printf("ERROR failed\r\n"); + mbedtls_x509_crt_verify_info(portBuffer + 4,0x100," ! ",(pNetwork->tlsDataParams).flags); + printf("ERROR %s\r\n",portBuffer + 4); + IVar7 = SSL_CONNECTION_ERROR; + goto LAB_23050902; + } + __format = "DEBUG ok\r\n"; + } + printf(__format); +LAB_23050902: + crt = mbedtls_ssl_get_peer_cert(ssl); + if (crt == (mbedtls_x509_crt *)0x0) { + return IVar7; + } + printf("DEBUG Peer certificate information:\r\n"); + crt = mbedtls_ssl_get_peer_cert(ssl); + mbedtls_x509_crt_info(portBuffer + 4,0xff," ",crt); + printf("DEBUG %s\r\n",portBuffer + 4); + return IVar7; +} + + + +int _iot_tls_verify_cert(void *data,mbedtls_x509_crt *crt,int depth,uint32_t *flags) + +{ + char acStack272 [4]; + char buf [256]; + + printf("DEBUG Verify requested for (Depth %d):\r\n",depth); + mbedtls_x509_crt_info(acStack272,0xff,"",crt); + printf("DEBUG %s\r\n",acStack272); + if (*flags == 0) { + printf("DEBUG This certificate has no flags\r\n"); + } + else { + printf("DEBUG Verify result:%s\r\n",acStack272); + } + return 0; +} + + + +IoT_Error_t iot_tls_write(Network *pNetwork,uchar *pMsg,size_t len,Timer *timer,size_t *written_len) + +{ + uint uVar1; + int iVar2; + _Bool _Var3; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + IoT_Error_t IVar4; + + iVar2 = 0; + uVar1 = 0; + do { + if ((len <= uVar1) || (_Var3 = has_timer_expired(timer), CONCAT31(extraout_var,_Var3) != 0)) { + *written_len = uVar1; + _Var3 = has_timer_expired(timer); + IVar4 = SUCCESS; + if ((CONCAT31(extraout_var_01,_Var3) != 0) && (IVar4 = SUCCESS, uVar1 != len)) { + IVar4 = NETWORK_SSL_WRITE_TIMEOUT_ERROR; + } + return IVar4; + } + while ((_Var3 = has_timer_expired(timer), CONCAT31(extraout_var_00,_Var3) == 0 && + (iVar2 = mbedtls_ssl_write((mbedtls_ssl_context *)&(pNetwork->tlsDataParams).ssl, + pMsg + uVar1,len - uVar1), iVar2 < 1))) { + if ((iVar2 != -0x6900) && (iVar2 != -0x6880)) { + printf("ERROR failed! mbedtls_ssl_write returned -0x%x\r\n",-iVar2); + *written_len = uVar1; + return NETWORK_SSL_WRITE_ERROR; + } + } + uVar1 = uVar1 + iVar2; + } while( true ); +} + + + +IoT_Error_t iot_tls_read(Network *pNetwork,uchar *pMsg,size_t len,Timer *timer,size_t *read_len) + +{ + IoT_Error_t IVar1; + _Bool _Var2; + uint32_t timeout; + uint32_t uVar3; + uint uVar4; + undefined3 extraout_var; + uint timeout_00; + size_t sVar5; + mbedtls_ssl_config *conf; + + timeout_00 = (pNetwork->tlsDataParams).conf.read_timeout; + conf = (mbedtls_ssl_config *)&(pNetwork->tlsDataParams).conf; + sVar5 = 0; + do { + if (len == 0) goto LAB_23050b08; + timeout = left_ms(timer); + uVar3 = timeout_00; + if (timeout <= timeout_00) { + uVar3 = left_ms(timer); + } + timeout = 1; + if ((uVar3 != 0) && (uVar3 = left_ms(timer), timeout = timeout_00, uVar3 <= timeout_00)) { + timeout = left_ms(timer); + } + mbedtls_ssl_conf_read_timeout(conf,timeout); + uVar4 = mbedtls_ssl_read((mbedtls_ssl_context *)&(pNetwork->tlsDataParams).ssl,pMsg,len); + mbedtls_ssl_conf_read_timeout(conf,timeout_00); + if ((int)uVar4 < 1) { + if ((uVar4 == 0) || (((uVar4 & 0xffffff7f) != 0xffff9700 && (uVar4 != 0xffff9800)))) { + return NETWORK_SSL_READ_ERROR; + } + } + else { + sVar5 = sVar5 + uVar4; + pMsg = pMsg + uVar4; + len = len - uVar4; + } + _Var2 = has_timer_expired(timer); + } while (CONCAT31(extraout_var,_Var2) == 0); + if (len == 0) { +LAB_23050b08: + *read_len = sVar5; + IVar1 = SUCCESS; + } + else { + IVar1 = NETWORK_SSL_NOTHING_TO_READ; + if (sVar5 != 0) { + IVar1 = NETWORK_SSL_READ_TIMEOUT_ERROR; + } + } + return IVar1; +} + + + +IoT_Error_t iot_tls_disconnect(Network *pNetwork) + +{ + int iVar1; + + do { + iVar1 = mbedtls_ssl_close_notify((mbedtls_ssl_context *)&(pNetwork->tlsDataParams).ssl); + } while (iVar1 == -0x6880); + return SUCCESS; +} + + + +IoT_Error_t iot_tls_destroy(Network *pNetwork) + +{ + mbedtls_net_free(&(pNetwork->tlsDataParams).server_fd); + mbedtls_x509_crt_free(&(pNetwork->tlsDataParams).clicert); + mbedtls_x509_crt_free(&(pNetwork->tlsDataParams).cacert); + mbedtls_pk_free(&(pNetwork->tlsDataParams).pkey); + mbedtls_ssl_free((mbedtls_ssl_context *)&(pNetwork->tlsDataParams).ssl); + mbedtls_ssl_config_free((mbedtls_ssl_config *)&(pNetwork->tlsDataParams).conf); + mbedtls_ctr_drbg_free((mbedtls_ctr_drbg_context_conflict *)&(pNetwork->tlsDataParams).ctr_drbg); + mbedtls_entropy_free((mbedtls_entropy_context *)&pNetwork->tlsDataParams); + return SUCCESS; +} + + + +IoT_Error_t +iot_tls_init(Network *pNetwork,char *pRootCALocation,char *pDeviceCertLocation, + char *pDevicePrivateKeyLocation,char *pDestinationURL,uint16_t destinationPort, + uint32_t timeout_ms,_Bool ServerVerificationFlag) + +{ + (pNetwork->tlsConnectParams).DestinationPort = destinationPort; + pNetwork->connect = iot_tls_connect; + pNetwork->read = iot_tls_read; + pNetwork->write = iot_tls_write; + pNetwork->disconnect = iot_tls_disconnect; + pNetwork->isConnected = iot_tls_is_connected; + (pNetwork->tlsConnectParams).pDestinationURL = pDestinationURL; + (pNetwork->tlsConnectParams).pDeviceCertLocation = pDeviceCertLocation; + (pNetwork->tlsConnectParams).pDevicePrivateKeyLocation = pDevicePrivateKeyLocation; + (pNetwork->tlsConnectParams).pRootCALocation = pRootCALocation; + (pNetwork->tlsConnectParams).timeout_ms = timeout_ms; + (pNetwork->tlsConnectParams).ServerVerificationFlag = ServerVerificationFlag; + pNetwork->destroy = iot_tls_destroy; + (pNetwork->tlsDataParams).flags = 0; + return SUCCESS; +} + + + +IoT_Error_t aws_iot_thread_mutex_init(IoT_Mutex_t *pMutex) + +{ + IoT_Error_t IVar1; + QueueHandle_t pQVar2; + + pQVar2 = xQueueCreateMutex('\x04'); + *(QueueHandle_t *)&pMutex->mutex = pQVar2; + if (pQVar2 == (QueueHandle_t)0x0) { + IVar1 = MUTEX_INIT_ERROR; + } + else { + IVar1 = SUCCESS; + } + return IVar1; +} + + + +IoT_Error_t aws_iot_thread_mutex_lock(IoT_Mutex_t *pMutex) + +{ + xQueueTakeMutexRecursive((QueueHandle_t)pMutex->mutex,0xffffffff); + return SUCCESS; +} + + + +IoT_Error_t aws_iot_thread_mutex_trylock(IoT_Mutex_t *pMutex) + +{ + IoT_Error_t IVar1; + BaseType_t BVar2; + + BVar2 = xQueueTakeMutexRecursive((QueueHandle_t)pMutex->mutex,0); + if (BVar2 == 0) { + IVar1 = MUTEX_LOCK_ERROR; + } + else { + IVar1 = SUCCESS; + } + return IVar1; +} + + + +IoT_Error_t aws_iot_thread_mutex_unlock(IoT_Mutex_t *pMutex) + +{ + IoT_Error_t IVar1; + BaseType_t BVar2; + + BVar2 = xQueueGiveMutexRecursive((QueueHandle_t)pMutex->mutex); + if (BVar2 == 0) { + IVar1 = MUTEX_UNLOCK_ERROR; + } + else { + IVar1 = SUCCESS; + } + return IVar1; +} + + + +IoT_Error_t aws_iot_thread_mutex_destroy(IoT_Mutex_t *pMutex) + +{ + vQueueDelete((QueueHandle_t)pMutex->mutex); + return SUCCESS; +} + + + +// WARNING: Variable defined which should be unmapped: byteRead + +IoT_Error_t +_aws_iot_mqtt_internal_readWrapper + (AWS_IoT_Client *pClient,size_t offset,size_t size,Timer *pTimer,size_t *read_len) + +{ + IoT_Error_t IVar1; + size_t sVar2; + size_t sVar3; + size_t sStack20; + size_t byteRead; + + sVar3 = (pClient->clientData).readBufIndex; + sStack20 = 0; + sVar2 = (offset - sVar3) + size; + if ((int)sVar2 < 1) { + *read_len = size; + IVar1 = SUCCESS; + } + else { + IVar1 = (*(pClient->networkStack).read) + ((Network *)&pClient->networkStack,(pClient->clientData).readBuf + sVar3,sVar2 + ,pTimer,&sStack20); + sStack20 = sStack20 + (pClient->clientData).readBufIndex; + (pClient->clientData).readBufIndex = sStack20; + *read_len = sStack20 - offset; + } + return IVar1; +} + + + +size_t aws_iot_mqtt_internal_write_len_to_buffer(uchar *buf,uint32_t length) + +{ + bool bVar1; + byte bVar2; + size_t sVar3; + size_t sVar4; + + sVar3 = 0; + do { + bVar2 = (byte)length & 0x7f; + if (0x7f < length) { + bVar2 = bVar2 | 0x80; + } + sVar4 = sVar3 + 1; + buf[sVar3] = bVar2; + bVar1 = 0x7f < length; + length = length >> 7; + sVar3 = sVar4; + } while (bVar1); + return sVar4; +} + + + +IoT_Error_t +aws_iot_mqtt_internal_decode_remaining_length_from_buffer + (uchar *buf,uint32_t *decodedLen,uint32_t *readBytesLen) + +{ + byte bVar1; + int iVar2; + uint32_t uVar3; + int iVar4; + + *decodedLen = 0; + iVar2 = 1; + uVar3 = 0; + do { + uVar3 = uVar3 + 1; + if (uVar3 == 5) { + return MQTT_DECODE_REMAINING_LENGTH_ERROR; + } + bVar1 = buf[uVar3]; + iVar4 = ((uint)bVar1 & 0x7f) * iVar2; + iVar2 = iVar2 << 7; + *decodedLen = *decodedLen + iVar4; + uVar3 = uVar3; + } while ((char)bVar1 < '\0'); + *readBytesLen = uVar3; + return SUCCESS; +} + + + +uint32_t aws_iot_mqtt_internal_get_final_packet_length_from_remaining_length(uint32_t rem_len) + +{ + uint32_t uVar1; + uint uVar2; + + uVar2 = rem_len + 1; + if (uVar2 < 0x80) { + return rem_len + 2; + } + if (uVar2 < 0x4000) { + return rem_len + 3; + } + uVar1 = rem_len + 5; + if (uVar2 < 0x200000) { + uVar1 = rem_len + 4; + } + return uVar1; +} + + + +uint16_t aws_iot_mqtt_internal_read_uint16_t(uchar **pptr) + +{ + uchar uVar1; + uchar uVar2; + uchar *puVar3; + + puVar3 = *pptr; + uVar1 = *puVar3; + uVar2 = puVar3[1]; + *pptr = puVar3 + 2; + return CONCAT11(uVar1,uVar2); +} + + + +void aws_iot_mqtt_internal_write_uint_16(uchar **pptr,uint16_t anInt) + +{ + uchar *puVar1; + + **pptr = (uchar)(anInt >> 8); + puVar1 = *pptr; + *pptr = puVar1 + 1; + puVar1[1] = (uchar)anInt; + *pptr = *pptr + 1; + return; +} + + + +uchar aws_iot_mqtt_internal_read_char(uchar **pptr) + +{ + uchar uVar1; + + uVar1 = **pptr; + *pptr = *pptr + 1; + return uVar1; +} + + + +void aws_iot_mqtt_internal_write_char(uchar **pptr,uchar c) + +{ + **pptr = c; + *pptr = *pptr + 1; + return; +} + + + +void aws_iot_mqtt_internal_write_utf8_string(uchar **pptr,char *string,uint16_t stringLen) + +{ + undefined2 in_register_00002032; + size_t __n; + + __n = CONCAT22(in_register_00002032,stringLen); + aws_iot_mqtt_internal_write_uint_16(pptr,stringLen); + if (__n != 0) { + memcpy(*pptr,string,__n); + *pptr = *pptr + __n; + } + return; +} + + + +IoT_Error_t +aws_iot_mqtt_internal_init_header + (MQTTHeader *pHeader,MessageTypes message_type,QoS qos,uint8_t dup,uint8_t retained) + +{ + uint uVar1; + undefined3 in_register_00002031; + byte bVar2; + undefined3 in_register_00002039; + IoT_Error_t IVar3; + + IVar3 = NULL_VALUE_ERROR; + if (pHeader != (MQTTHeader *)0x0) { + *pHeader = 0; + uVar1 = (uint)(byte)message_type - 1 & 0xff; + IVar3 = FAILURE; + if (uVar1 < 0xe) { + bVar2 = dup << 3 | CSWTCH_27[uVar1] << 4; + if (CONCAT31(in_register_00002031,qos) == 1) { + bVar2 = bVar2 | 2; + } + *pHeader = bVar2; + *pHeader = CONCAT31(in_register_00002039,retained) == 1 | *pHeader; + IVar3 = SUCCESS; + } + } + return IVar3; +} + + + +IoT_Error_t aws_iot_mqtt_internal_send_packet(AWS_IoT_Client *pClient,size_t length,Timer *pTimer) + +{ + IoT_Error_t IVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + uint uVar3; + IoT_Mutex_t *pMutex; + size_t sStack36; + size_t sentLen; + + if ((pClient != (AWS_IoT_Client *)0x0) && (pTimer != (Timer *)0x0)) { + IVar1 = MQTT_TX_BUFFER_TOO_SHORT_ERROR; + if (length < (pClient->clientData).writeBufSize) { + pMutex = &(pClient->clientData).tls_write_mutex; + IVar1 = aws_iot_mqtt_client_lock_mutex(pClient,pMutex); + if (CONCAT31(extraout_var,IVar1) == 0) { + sStack36 = 0; + uVar3 = 0; + while (((uVar3 < length && + (_Var2 = has_timer_expired(pTimer), CONCAT31(extraout_var_00,_Var2) == 0)) && + (IVar1 = (*(pClient->networkStack).write) + ((Network *)&pClient->networkStack, + (pClient->clientData).writeBuf + uVar3,length - uVar3,pTimer, + &sStack36), CONCAT31(extraout_var_01,IVar1) == 0))) { + uVar3 = uVar3 + sStack36; + } + IVar1 = aws_iot_mqtt_client_unlock_mutex(pClient,pMutex); + } + } + return IVar1; + } + return NULL_VALUE_ERROR; +} + + + +// WARNING: Could not reconcile some variable overlaps + +IoT_Error_t +aws_iot_mqtt_internal_cycle_read(AWS_IoT_Client *pClient,Timer *pTimer,uint8_t *pPacketType) + +{ + byte bVar1; + char cVar2; + ushort uVar3; + char *pcVar4; + IoT_Error_t IVar5; + uint __n; + MessageHandlers_conflict40 *pMVar6; + IoT_Error_t IVar7; + ClientState CVar8; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + undefined3 extraout_var_05; + undefined3 extraout_var_06; + undefined3 extraout_var_07; + char *pcVar9; + int iVar10; + char *__s1; + size_t sVar11; + char *pcVar12; + char *pcVar13; + IoT_Mutex_t *pMutex; + size_t offset; + int iVar14; + uchar *in_fa0; + uchar *extraout_fa0; + size_t in_fa1; + size_t extraout_fa1; + uint16_t uStack74; + uint16_t topicNameLen; + char *pcStack72; + size_t read_len; + size_t read_len_1; + Timer packetTimer; + + IVar7 = NULL_VALUE_ERROR; + if ((pClient != (AWS_IoT_Client *)0x0) && (pTimer != (Timer *)0x0)) { + pMutex = &(pClient->clientData).tls_read_mutex; + IVar7 = aws_iot_mqtt_client_lock_mutex(pClient,pMutex); + if (CONCAT31(extraout_var,IVar7) == 0) { + init_timer((Timer *)&read_len_1); + countdown_ms((Timer *)&read_len_1,(pClient->clientData).packetTimeoutMs); + pcStack72 = (char *)0x0; + IVar7 = _aws_iot_mqtt_internal_readWrapper(pClient,0,1,pTimer,(size_t *)&stack0xffffffb8); + __n = CONCAT31(extraout_var_00,IVar7); + if (__n == 0xffffffe7) { + __n = 2; + } + else { + if (__n == 0) { + __s1 = (char *)0x0; + iVar14 = 1; + offset = 0; + do { + sVar11 = offset; + offset = sVar11 + 1; + if (offset == 5) { + __n = 0xffffffdd; + goto LAB_2305102e; + } + IVar7 = _aws_iot_mqtt_internal_readWrapper(pClient,offset,1,pTimer,&read_len); + __n = CONCAT31(extraout_var_01,IVar7); + if (__n != 0) goto LAB_2305102e; + bVar1 = (pClient->clientData).readBuf[sVar11 + 1]; + iVar10 = ((uint)bVar1 & 0x7f) * iVar14; + iVar14 = iVar14 << 7; + __s1 = __s1 + iVar10; + } while ((char)bVar1 < '\0'); + pcVar13 = (char *)(pClient->clientData).readBufSize; + if (__s1 + sVar11 + 2 < pcVar13) { + if ((__s1 == (char *)0x0) || + ((IVar7 = _aws_iot_mqtt_internal_readWrapper + (pClient,sVar11 + 2,(size_t)__s1,pTimer, + (size_t *)&stack0xffffffb8), + CONCAT31(extraout_var_04,IVar7) == 0 && (pcStack72 == __s1)))) { + (pClient->clientData).readBufIndex = 0; + *pPacketType = (pClient->clientData).readBuf[0] >> 4; + } + else { + __n = 0xffffffff; + } + } + else { + pcVar12 = (char *)0x0; + do { + IVar7 = (*(pClient->networkStack).read) + ((Network *)&pClient->networkStack,(pClient->clientData).readBuf, + (size_t)pcVar13,pTimer,(size_t *)&stack0xffffffb8); + __n = CONCAT31(extraout_var_02,IVar7); + in_fa0 = extraout_fa0; + in_fa1 = extraout_fa1; + if (__n != 0) { + if (pcVar12 < __s1) goto LAB_2305102e; + break; + } + pcVar12 = pcVar12 + (int)pcStack72; + pcVar9 = (char *)(pClient->clientData).readBufSize; + pcVar13 = __s1 + -(int)pcVar12; + if (pcVar9 < __s1 + -(int)pcVar12) { + pcVar13 = pcVar9; + } + } while (pcVar12 < __s1); + if (__s1 == pcVar12) { + (pClient->clientData).readBufIndex = 0; + __n = 0xffffffe0; + } + } + } + } +LAB_2305102e: + IVar5 = (IoT_Error_t)__n; + IVar7 = aws_iot_mqtt_client_unlock_mutex(pClient,pMutex); + if (CONCAT31(extraout_var_03,IVar7) == 0) { + if (__n == 2) { + return SUCCESS; + } + if (__n != 0) { + return IVar5; + } + if (0xb < ((uint)*pPacketType - 2 & 0xff)) { + return MQTT_RX_MESSAGE_PACKET_TYPE_INVALID_ERROR; + } + __n = 1 << ((uint)*pPacketType - 2 & 0x1f); + if ((__n & 0x2ad) != 0) { + return IVar5; + } + if ((int)(__n << 0x14) < 0) { + uVar3 = (pClient->clientData).keepAliveInterval; + (pClient->clientStatus).isPingOutstanding = false; + countdown_sec((Timer *)pClient,(uint)uVar3); + return IVar5; + } + if ((__n & 2) == 0) { + return MQTT_RX_MESSAGE_PACKET_TYPE_INVALID_ERROR; + } + pcStack72 = (char *)0x0; + uStack74 = 0; + read_len = 0; + IVar7 = aws_iot_mqtt_internal_deserialize_publish + ((uint8_t *)((int)&read_len_1 + 2),(QoS *)&read_len_1, + (uint8_t *)((int)&read_len_1 + 1),(uint16_t *)&packetTimer, + (char **)&stack0xffffffb8,&uStack74,(uchar **)&packetTimer.timeout_ticks, + &packetTimer.last_polled_ticks,in_fa0,in_fa1); + __s1 = pcStack72; + uVar3 = uStack74; + if (CONCAT31(extraout_var_05,IVar7) != 0) { + return IVar7; + } + __n = (uint)uStack74; + if (pcStack72 == (char *)0x0) { + return NULL_VALUE_ERROR; + } + CVar8 = aws_iot_mqtt_get_client_state(pClient); + aws_iot_mqtt_set_client_state(pClient,CONCAT31(extraout_var_06,CVar8),9); + pMVar6 = (pClient->clientData).messageHandlers; + pcVar13 = __s1 + __n; + do { + if (pMVar6->topicName != (char *)0x0) { + if (((uint)pMVar6->topicNameLen == __n) && + (iVar14 = strncmp(__s1,pMVar6->topicName,__n), iVar14 == 0)) { +LAB_2305118e: + if (pMVar6->pApplicationHandler != (pApplicationHandler_t *)0x0) { + (*pMVar6->pApplicationHandler) + (pClient,__s1,uVar3,(IoT_Publish_Message_Params *)&read_len_1, + pMVar6->pApplicationHandlerData); + } + } + else { + pcVar9 = pMVar6->topicName; + pcVar12 = __s1; + if (pcVar9 != (char *)0x0) { + while (cVar2 = *pcVar9, cVar2 != '\0') { + if (pcVar13 <= pcVar12) goto LAB_23051140; + if (*pcVar12 == '/') { + if (cVar2 != '/') goto LAB_23051140; + } + else { + pcVar4 = pcVar12; + if (cVar2 == '+') { + do { + pcVar12 = pcVar4; + if (pcVar13 == pcVar12 + 1) break; + pcVar4 = pcVar12 + 1; + } while (pcVar12[1] != '/'); + } + else { + if (cVar2 == '#') { + pcVar12 = pcVar13 + -1; + } + else { + if (*pcVar12 != cVar2) goto LAB_23051140; + } + } + } + pcVar9 = pcVar9 + 1; + pcVar12 = pcVar12 + 1; + } + if (pcVar13 == pcVar12) goto LAB_2305118e; + } + } + } +LAB_23051140: + pMVar6 = pMVar6 + 1; + } while ((MessageHandlers_conflict40 *)&(pClient->clientData).disconnectHandler != pMVar6); + iVar14 = aws_iot_mqtt_set_client_state(pClient,9,CONCAT31(extraout_var_06,CVar8)); + if (iVar14 != 0) { + return (IoT_Error_t)iVar14; + } + if ((QoS)read_len_1 == QOS0) { + return (IoT_Error_t)iVar14; + } + IVar7 = aws_iot_mqtt_internal_serialize_ack + ((pClient->clientData).writeBuf,(pClient->clientData).writeBufSize,PUBACK, + '\0',(uint16_t)packetTimer.start_ticks,&read_len); + if (CONCAT31(extraout_var_07,IVar7) != 0) { + return IVar7; + } + IVar7 = aws_iot_mqtt_internal_send_packet(pClient,read_len,pTimer); + } + else { + if ((__n & 0xfd) != 0) { + return IVar5; + } + } + } + } + return IVar7; +} + + + +IoT_Error_t aws_iot_mqtt_internal_flushBuffers(AWS_IoT_Client *pClient) + +{ + (pClient->clientData).readBufIndex = 0; + return SUCCESS; +} + + + +// WARNING: Variable defined which should be unmapped: read_packet_type + +IoT_Error_t +aws_iot_mqtt_internal_wait_for_read(AWS_IoT_Client *pClient,uint8_t packetType,Timer *pTimer) + +{ + IoT_Error_t IVar1; + _Bool _Var2; + byte bVar3; + undefined3 extraout_var; + undefined3 in_register_0000202d; + byte abStack17 [4]; + uint8_t read_packet_type; + + if (pClient == (AWS_IoT_Client *)0x0) { + return NULL_VALUE_ERROR; + } + IVar1 = NULL_VALUE_ERROR; + if (pTimer != (Timer *)0x0) { + abStack17[0] = 0; + while (_Var2 = has_timer_expired(pTimer), CONCAT31(extraout_var,_Var2) == 0) { + bVar3 = aws_iot_mqtt_internal_cycle_read(pClient,pTimer,abStack17); + if ((bVar3 & 0xfd) != 0) { + return bVar3; + } + if ((uint)abStack17[0] == CONCAT31(in_register_0000202d,packetType)) { + return bVar3; + } + } + IVar1 = MQTT_REQUEST_TIMEOUT_ERROR; + } + return IVar1; +} + + + +// WARNING: Variable defined which should be unmapped: ptr + +IoT_Error_t +aws_iot_mqtt_internal_serialize_zero + (uchar *pTxBuf,size_t txBufLen,MessageTypes packetType,size_t *pSerializedLength) + +{ + IoT_Error_t IVar1; + undefined3 extraout_var; + size_t sVar2; + uchar auStack24 [4]; + MQTTHeader header; + uchar *ptr; + + auStack24[0] = '\0'; + IVar1 = NULL_VALUE_ERROR; + if (((pTxBuf != (uchar *)0x0) && (pSerializedLength != (size_t *)0x0)) && + (IVar1 = MQTT_TX_BUFFER_TOO_SHORT_ERROR, 3 < txBufLen)) { + _header = pTxBuf; + IVar1 = aws_iot_mqtt_internal_init_header(auStack24,packetType,QOS0,'\0','\0'); + if (CONCAT31(extraout_var,IVar1) == 0) { + aws_iot_mqtt_internal_write_char((uchar **)&header,auStack24[0]); + sVar2 = aws_iot_mqtt_internal_write_len_to_buffer(_header,0); + *(uchar **)pSerializedLength = _header + (sVar2 - (int)pTxBuf); + } + } + return IVar1; +} + + + +size_t format_int(char *q,size_t n,uint flags,int base,int width,int prec) + +{ + char "0123456789abcdef" [17]; + char "0123456789ABCDEF" [17]; + int iVar1; + uint uVar2; + uint uVar3; + char cVar4; + uint uVar5; + uint uVar6; + int in_a6; + int in_a7; + int iVar7; + int iVar8; + uint uVar9; + char *pcVar10; + int iVar11; + char *pcStack84; + + if ((width & 0x80U) == 0) { + pcStack84 = "0123456789abcdef"; + } + else { + pcStack84 = "0123456789ABCDEF"; + } + uVar9 = 0; + if (((width & 0x40U) != 0) && (base < 0)) { + flags = -flags; + base = -(uint)(flags != 0) - base; + uVar9 = 1; + } + iVar7 = 0; + uVar2 = flags; + uVar6 = base; + while ((uVar2 | uVar6) != 0) { + __udivdi3(); + iVar7 = iVar7 + 1; + } + uVar2 = width & 0x20; + if ((uVar2 == 0) || (prec != 8)) { +LAB_23051346: + if ((in_a7 <= iVar7) && (in_a7 = iVar7, (flags | base) == 0)) { + in_a7 = 1; + } + } + else { + if (in_a7 <= iVar7) { + in_a7 = iVar7 + 1; + goto LAB_23051346; + } + } + iVar7 = in_a7; + if (((width & 8U) != 0) && (iVar7 = 4, prec != 0x10)) { + iVar7 = 3; + } + iVar8 = (in_a7 + -1) / iVar7 + in_a7; + iVar1 = (uint)((width & 0x14U | uVar9) != 0) + iVar8; + if ((uVar2 != 0) && (prec == 0x10)) { + iVar1 = iVar1 + 2; + } + uVar3 = width & 3; + uVar6 = 0; + if ((uVar3 == 0) && (uVar6 = uVar3, iVar1 < in_a6)) { + uVar6 = in_a6 - iVar1; + uVar5 = 0; + do { + if (uVar5 < n) { + *q = ' '; + q = q + 1; + } + uVar5 = uVar5 + 1; + in_a6 = iVar1; + } while (uVar5 != uVar6); + } + if (uVar9 == 0) { + if ((width & 4U) == 0) { + if ((width & 0x10U) == 0) goto LAB_230513c8; + if (uVar6 < n) { + *q = ' '; + q = q + 1; + } + } + else { + if (uVar6 < n) { + *q = '+'; + q = q + 1; + } + } + } + else { + if (uVar6 < n) { + *q = '-'; + q = q + 1; + } + } + uVar6 = uVar6 + 1; +LAB_230513c8: + if ((uVar2 != 0) && (prec == 0x10)) { + if (uVar6 < n) { + *q = '0'; + q = q + 1; + } + if (uVar6 + 1 < n) { + cVar4 = 'X'; + if ((width & 0x80U) == 0) { + cVar4 = 'x'; + } + *q = cVar4; + q = q + 1; + } + uVar6 = uVar6 + 2; + } + if ((uVar3 == 1) && (iVar8 < in_a6)) { + while (iVar1 < in_a6) { + if (uVar6 < n) { + *q = '0'; + q = q + 1; + } + uVar6 = uVar6 + 1; + in_a6 = in_a6 + -1; + } + } + uVar6 = iVar8 + uVar6; + q = q + iVar8; + pcVar10 = q; + uVar9 = uVar6; + iVar11 = iVar7; + while (0 < iVar8) { + if (iVar11 == 0) { + uVar9 = uVar9 - 1; + if (uVar9 < n) { + pcVar10[-1] = '_'; + } + pcVar10 = pcVar10 + -1; + iVar8 = iVar8 + -1; + iVar11 = iVar7; + } + iVar11 = iVar11 + -1; + uVar9 = uVar9 - 1; + iVar8 = iVar8 + -1; + if (uVar9 < n) { + uVar2 = flags; + __umoddi3(); + pcVar10[-1] = pcStack84[uVar2]; + } + __udivdi3(); + pcVar10 = pcVar10 + -1; + } + iVar7 = in_a6 + uVar6; + while (((width & 2U) != 0 && (iVar1 < (int)(iVar7 - uVar6)))) { + if (uVar6 < n) { + *q = ' '; + q = q + 1; + } + uVar6 = uVar6 + 1; + } + return uVar6; +} + + + +char * cvt(int ndigits,int *decpt,int *sign,char *buf,int eflag) + +{ + int *piVar1; + byte *pbVar2; + __gcc_CMPtype _Var3; + double *__iptr; + SItype SVar4; + byte *in_a5; + byte *pbVar5; + int in_a6; + byte *pbVar6; + byte *pbVar7; + double in_fa1; + double *pdStack80; + double fi; + double fj; + + piVar1 = (int *)0x4e; + if (((int)sign < 0x4f) && (piVar1 = sign, (int)sign < 0)) { + piVar1 = (int *)0x0; + } + _Var3 = __ledf2(); + if (_Var3 < 0) { + *(undefined4 *)eflag = 1; + } + else { + *(undefined4 *)eflag = 0; + } + modf(in_fa1,(double *)ndigits); + pbVar6 = in_a5 + 0x50; + _Var3 = __eqdf2(); + pbVar2 = pbVar6; + pbVar5 = in_a5; + if (_Var3 == 0) { + _Var3 = __gedf2(); + pbVar7 = (byte *)0x0; + if (0 < _Var3) { + while( true ) { + __iptr = (double *)ndigits; + __muldf3(); + _Var3 = __ledf2(); + if (-1 < _Var3) break; + pbVar7 = pbVar7 + -1; + ndigits = (int)__iptr; + } + } + } + else { + while( true ) { + _Var3 = __eqdf2(); + pbVar7 = pbVar6 + -(int)pbVar2; + if (_Var3 == 0) break; + __iptr = pdStack80; + __divdf3(); + modf(in_fa1,__iptr); + __adddf3(); + __muldf3(); + SVar4 = __fixdfsi(); + pbVar2[-1] = (char)SVar4 + 0x30; + pbVar2 = pbVar2 + -1; + } + while (pbVar2 < pbVar6) { + *pbVar5 = *pbVar2; + pbVar5 = pbVar5 + 1; + pbVar2 = pbVar2 + 1; + } + } + pbVar2 = (byte *)((int)piVar1 + (int)in_a5); + if (in_a6 == 0) { + pbVar2 = pbVar2 + (int)pbVar7; + } + *(byte **)buf = pbVar7; + if (pbVar2 < in_a5) { + *in_a5 = 0; + } + else { + while ((pbVar5 <= pbVar2 && (pbVar5 < pbVar6))) { + __muldf3(); + modf(in_fa1,(double *)ndigits); + SVar4 = __fixdfsi(); + *pbVar5 = (char)SVar4 + 0x30; + pbVar5 = pbVar5 + 1; + } + if (pbVar2 < pbVar6) { + *pbVar2 = *pbVar2 + 5; + pbVar5 = pbVar2; + while (0x39 < *pbVar5) { + *pbVar5 = 0x30; + if (in_a5 < pbVar5) { + pbVar6 = pbVar5 + -1; + pbVar5 = pbVar5 + -1; + *pbVar5 = *pbVar6 + 1; + } + else { + *pbVar5 = 0x31; + *(int *)buf = *(int *)buf + 1; + if (in_a6 == 0) { + if (in_a5 < pbVar2) { + *pbVar2 = 0x30; + } + pbVar2 = pbVar2 + 1; + } + } + } + *pbVar2 = 0; + } + else { + in_a5[0x4f] = 0; + } + } + return (char *)in_a5; +} + + + +char * ecvtbuf(int ndigits,int *decpt,int *sign,char *buf) + +{ + char *pcVar1; + int in_a4; + + pcVar1 = cvt(ndigits,decpt,sign,buf,in_a4); + return pcVar1; +} + + + +char * fcvtbuf(int ndigits,int *decpt,int *sign,char *buf) + +{ + char *pcVar1; + int in_a4; + + pcVar1 = cvt(ndigits,decpt,sign,buf,in_a4); + return pcVar1; +} + + + +char * flt(char *str,int size,int precision,char fmt,int flags) + +{ + bool bVar1; + byte bVar2; + int iVar3; + __gcc_CMPtype _Var4; + char *pcVar5; + undefined *puVar6; + size_t sVar7; + int *sign_00; + undefined3 in_register_00002035; + char *pcVar8; + int *piVar9; + uint uVar10; + int *__string; + char cVar11; + uint in_a5; + uint uVar12; + char *pcVar13; + int iVar14; + uint in_a6; + char cVar15; + char cVar16; + char *pcVar17; + char *pcStack232; + int decpt; + int sign; + char tmp [80]; + char cvtbuf [80]; + + iVar3 = CONCAT31(in_register_00002035,fmt); + uVar12 = in_a6 & 0x10; + if (uVar12 == 0) { + cVar16 = '0'; + if ((in_a6 & 1) == 0) { + cVar16 = ' '; + } + } + else { + in_a6 = in_a6 & 0xfffffffe; + cVar16 = ' '; + } + cVar15 = '\0'; + if ((in_a6 & 2) != 0) { + _Var4 = __ledf2(); + if (_Var4 < 0) { + precision = precision ^ 0x80000000; + iVar3 = iVar3 + -1; + cVar15 = '-'; + } + else { + if ((in_a6 & 4) == 0) { + if ((in_a6 & 8) != 0) { + iVar3 = iVar3 + -1; + cVar15 = ' '; + } + } + else { + iVar3 = iVar3 + -1; + cVar15 = '+'; + } + } + } + if (flags < 0) { + flags = 6; + } + bVar1 = (in_a5 & 0xfd) != 0x45; + uVar10 = in_a5; + if (!bVar1) { + uVar10 = in_a5 + 0x20 & 0xff; + } + if (uVar10 == 0x67) { + ecvtbuf(size,(int *)precision,(int *)flags,(char *)&pcStack232); + if ((-5 < (int)(pcStack232 + -1)) && ((int)(pcStack232 + -1) < flags)) { + sign_00 = (int *)(flags - (int)pcStack232); +LAB_23051924: + pcVar5 = fcvtbuf(size,(int *)precision,sign_00,(char *)&pcStack232); + __string = &sign; + if (decpt != 0) { + sign._0_1_ = 0x2d; + __string = (int *)((int)&sign + 1); + } + if (*pcVar5 == '\0') { + *(char *)__string = '0'; + if ((int)sign_00 < 1) { + __string = (int *)((int)__string + 1); + } + else { + *(char *)((int)__string + 1) = '.'; + pcVar5 = (char *)((int)__string + 2); + piVar9 = (int *)((int)__string + (int)sign_00); + do { + *(char *)((int)__string + 2) = '0'; + __string = (int *)((int)__string + 1); + } while (piVar9 != __string); + __string = (int *)(pcVar5 + (int)sign_00); + } + } + else { + pcVar17 = pcVar5; + if ((int)pcStack232 < 1) { + *(char *)__string = '0'; + *(char *)((int)__string + 1) = '.'; + sign_00 = __string; + while ((int *)((int)__string - (int)pcStack232) != sign_00) { + *(char *)((int)sign_00 + 2) = '0'; + sign_00 = (int *)((int)sign_00 + 1); + } + __string = (int *)((int)__string + (2 - (int)pcStack232)); + while (cVar11 = *pcVar5, cVar11 != '\0') { + pcVar5 = pcVar5 + 1; + *(char *)__string = cVar11; + __string = (int *)((int)__string + 1); + } + } + else { + do { + sign_00 = __string; + if (pcStack232 == pcVar17 + -(int)pcVar5) { + sign_00 = (int *)((int)__string + 1); + *(char *)__string = '.'; + } + pcVar8 = pcVar17 + 1; + __string = (int *)((int)sign_00 + 1); + *(char *)sign_00 = *pcVar17; + pcVar17 = pcVar8; + } while (*pcVar8 != '\0'); + } + } + goto LAB_230518cc; + } + __string = (int *)(flags + -1); + } + else { + __string = (int *)flags; + if (uVar10 != 0x65) { + __string = &sign; + sign_00 = (int *)flags; + if (uVar10 != 0x66) goto LAB_230518cc; + goto LAB_23051924; + } + } + pcVar5 = ecvtbuf(size,(int *)precision,(int *)((int)__string + 1),(char *)&pcStack232); + sign_00 = &sign; + if (decpt != 0) { + sign._0_1_ = 0x2d; + sign_00 = (int *)((int)&sign + 1); + } + pcVar17 = (char *)((int)sign_00 + 1); + *(char *)sign_00 = *pcVar5; + if (0 < (int)__string) { + pcVar17 = (char *)((int)sign_00 + 2); + *(undefined *)((int)sign_00 + 1) = 0x2e; + } + pcVar8 = pcVar5 + 1; + pcVar13 = pcVar17; + while (pcVar5 + 1 + (int)__string != pcVar8) { + *pcVar13 = *pcVar8; + pcVar8 = pcVar8 + 1; + pcVar13 = pcVar13 + 1; + } + pcVar17 = pcVar17 + (int)__string; + cVar11 = 'E'; + if (bVar1) { + cVar11 = 'e'; + } + *pcVar17 = cVar11; + if (pcStack232 == (char *)0x0) { + _Var4 = __eqdf2(); + if (_Var4 != 0) { + pcStack232 = (char *)0xffffffff; + goto LAB_2305188a; + } +LAB_230519b0: + cVar11 = '+'; + } + else { + pcStack232 = pcStack232 + -1; + if (-1 < (int)pcStack232) goto LAB_230519b0; +LAB_2305188a: + pcStack232 = (char *)-(int)pcStack232; + cVar11 = '-'; + } + pcVar17[1] = cVar11; + pcVar17[4] = (char)((int)pcStack232 % 10) + '0'; + pcVar17[2] = (char)(((int)pcStack232 / 100) % 10) + '0'; + pcVar17[3] = (char)(((int)pcStack232 / 10) % 10) + '0'; + __string = (int *)(pcVar17 + 5); +LAB_230518cc: + *(char *)__string = '\0'; + if ((in_a6 & 0x20) == 0) { + if (in_a5 == 0x67) { + __string = &sign; + do { + bVar2 = *(byte *)__string; + __string = (int *)((int)__string + 1); + if (bVar2 == 0) goto LAB_23051a64; + } while (bVar2 != 0x2e); + while ((sign_00 = __string, *(byte *)__string != 0 && ((*(byte *)__string & 0xdf) != 0x45))) { + __string = (int *)((int)__string + 1); + } + do { + piVar9 = sign_00; + sign_00 = (int *)((int)piVar9 + -1); + } while (*(byte *)sign_00 == 0x30); + if (*(byte *)sign_00 == 0x2e) { + sign_00 = (int *)((int)piVar9 + -2); + } + while (__string != sign_00) { + sign_00 = (int *)((int)sign_00 + 1); + *(byte *)sign_00 = 0; + } + } + } + else { + if ((int *)flags == (int *)0x0) { + __string = &sign; + while (bVar2 = *(byte *)__string, bVar2 != 0) { + if (bVar2 == 0x2e) goto LAB_23051a64; + if ((bVar2 & 0xdf) == 0x45) { + sVar7 = strnlen((char *)__string,0x100); + puVar6 = (undefined *)(sVar7 + (int)__string); + while (0 < (int)(puVar6 + -(int)__string)) { + puVar6[1] = *puVar6; + puVar6 = puVar6 + -1; + } + *(byte *)__string = 0x2e; + goto LAB_23051a64; + } + __string = (int *)((int)__string + 1); + } + *(byte *)__string = 0x2e; + *(byte *)((int)__string + 1) = 0; + } + } +LAB_23051a64: + sVar7 = strnlen((char *)&sign,0x100); + iVar3 = iVar3 - sVar7; + pcVar5 = str; + if ((in_a6 & 0x11) == 0) { + while (0 < (int)(str + (iVar3 - (int)pcVar5))) { + *pcVar5 = ' '; + pcVar5 = pcVar5 + 1; + } + iVar14 = iVar3; + if (iVar3 < 0) { + iVar14 = 0; + } + str = str + iVar14; + iVar3 = (iVar3 + -1) - iVar14; + } + if (cVar15 != '\0') { + *str = cVar15; + str = str + 1; + } + pcVar5 = str; + if (uVar12 == 0) { + while (0 < (int)(str + (iVar3 - (int)pcVar5))) { + *pcVar5 = cVar16; + pcVar5 = pcVar5 + 1; + } + iVar14 = iVar3; + if (iVar3 < 0) { + iVar14 = 0; + } + str = str + iVar14; + iVar3 = (iVar3 + -1) - iVar14; + } + iVar14 = 0; + while (iVar14 < (int)sVar7) { + pcVar5 = (char *)((int)&sign + iVar14); + pcVar17 = str + iVar14; + iVar14 = iVar14 + 1; + *pcVar17 = *pcVar5; + } + if ((int)sVar7 < 0) { + sVar7 = 0; + } + str = str + sVar7; + pcVar5 = str; + while (0 < (int)(str + (iVar3 - (int)pcVar5))) { + *pcVar5 = ' '; + pcVar5 = pcVar5 + 1; + } + if (iVar3 < 0) { + iVar3 = 0; + } + return str + iVar3; +} + + + +int vsnprintf(char *__s,size_t __maxlen,char *__format,__gnuc_va_list __arg) + +{ + char *pcVar1; + size_t n; + byte *pbVar2; + int *piVar3; + undefined4 uVar4; + char *pcVar5; + byte bVar6; + uint uVar7; + char **ppcVar8; + int prec; + char *pcVar9; + char *pcVar10; + int iVar11; + uint width; + char *flags; + byte *str; + char *pcVar12; + char *pcStack104; + char *pcStack100; + char *pcStack88; + char acStack65 [4]; + char carg; + + uVar4 = 0; + width = 0; + flags = (char *)0xffffffff; + iVar11 = 0; + pcStack104 = (char *)0x0; + pcStack100 = (char *)0x0; + pcVar5 = (char *)0x0; + str = (byte *)__s; + pcVar12 = (char *)0x0; +switchD_23051c14_caseD_5: + do { + pbVar2 = (byte *)__format; + __format = (char *)(pbVar2 + 1); + bVar6 = *pbVar2; + uVar7 = (uint)bVar6; + if (bVar6 == 0) { + if (pcVar5 < __maxlen) { + *str = 0; + } + else { + if (__maxlen != 0) { + __s[__maxlen - 1] = '\0'; + } + } + return (int)pcVar5; + } + switch(uVar4) { + case 0: + if (bVar6 == 0x25) { + uVar4 = 1; + width = 0; + flags = (char *)0xffffffff; + iVar11 = 0; + pcVar12 = (char *)0x0; + } + else { + if (pcVar5 < __maxlen) { + *str = bVar6; + str = str + 1; + } + pcVar5 = pcVar5 + 1; + } + break; + case 1: + switch(uVar7 - 0x20 & 0xff) { + case 0: + width = width | 0x10; + break; + default: + uVar4 = 2; + __format = (char *)pbVar2; + break; + case 3: + width = width | 0x20; + break; + case 7: + width = width | 8; + break; + case 0xb: + width = width | 4; + break; + case 0xd: + width = width | 2; + break; + case 0x10: + width = width | 1; + } + break; + case 2: + if ((uVar7 - 0x30 & 0xff) < 10) { + pcVar12 = (char *)((int)pcVar12 * 10 + (uVar7 - 0x30)); + } + else { + if (bVar6 == 0x2a) { + ppcVar8 = (char **)__arg + 1; + pcVar12 = *(char **)__arg; + __arg = ppcVar8; + if ((int)pcVar12 < 0) { + width = width | 2; + pcVar12 = (char *)-(int)pcVar12; + } + } + else { + if (bVar6 == 0x2e) { + uVar4 = 3; + flags = (char *)0x0; + } + else { + uVar4 = 4; + __format = (char *)pbVar2; + } + } + } + break; + case 3: + if ((uVar7 - 0x30 & 0xff) < 10) { + flags = (char *)((int)flags * 10 + (uVar7 - 0x30)); + } + else { + if (bVar6 == 0x2a) { + ppcVar8 = (char **)__arg + 1; + flags = *(char **)__arg; + __arg = ppcVar8; + if ((int)flags < 0) { + flags = (char *)0xffffffff; + } + } + else { + uVar4 = 4; + __format = (char *)pbVar2; + } + } + break; + case 4: + switch(uVar7 - 0x4c & 0xff) { + case 0: + case 0x25: + iVar11 = iVar11 + 2; + break; + default: + if (2 < iVar11) { + iVar11 = 2; + } + if (iVar11 < -2) { + iVar11 = -2; + } + switch(uVar7 - 0x50 & 0xff) { + case 0: + width = width | 0x80; + goto switchD_23051d70_caseD_20; + default: + if (pcVar5 < __maxlen) { + *str = bVar6; + str = str + 1; + } + uVar4 = 0; + pcVar5 = pcVar5 + 1; + goto switchD_23051c14_caseD_5; + case 8: + width = width | 0x80; + prec = 0x10; + break; + case 0x13: + acStack65[0] = (char)*(char **)__arg; + pcVar1 = (char *)0x1; + pcStack88 = acStack65; + goto is_string; + case 0x14: + case 0x19: + width = width | 0x40; + // WARNING: Could not find normalized switch variable to match jumptable + switch(iVar11) { + case -2: + pcStack104 = (char *)(int)*(char *)__arg; + pcStack100 = (char *)((int)pcStack104 >> 0x1f); + __arg = (char **)__arg + 1; + prec = 10; + break; + case 0: + pcStack104 = *(char **)__arg; + pcStack100 = (char *)((int)pcStack104 >> 0x1f); + __arg = (char **)__arg + 1; + prec = 10; + break; + case 2: + ppcVar8 = (char **)((int)__arg + 7U & 0xfffffff8); + __arg = ppcVar8 + 2; + pcStack104 = *ppcVar8; + pcStack100 = ppcVar8[1]; + prec = 10; + break; + default: + prec = 10; + } + goto is_integer; + case 0x16: + piVar3 = (int *)((int)__arg + 7U & 0xfffffff8); + str = (byte *)flt((char *)str,*piVar3,piVar3[1],(char)pcVar12,(int)flags); + uVar4 = 0; + __arg = piVar3 + 2; + goto switchD_23051c14_caseD_5; + case 0x1e: + if (iVar11 + 2U < 5) { + // WARNING: Could not recover jumptable at 0x23051f80. Too many branches + // WARNING: Treating indirect jump as call + iVar11 = (*(code *)(&PTR_LAB_230885a4)[iVar11 + 2U])((&PTR_LAB_230885a4)[iVar11 + 2U]); + return iVar11; + } + uVar4 = 0; + goto switchD_23051c14_caseD_5; + case 0x1f: + prec = 8; + break; + case 0x20: +switchD_23051d70_caseD_20: + width = width | 0x20; + pcStack104 = *(char **)__arg; + pcStack100 = (char *)0x0; + __arg = (char **)__arg + 1; + prec = 0x10; + flags = &DAT_00000008; + goto is_integer; + case 0x23: + pcStack88 = *(char **)__arg; + if (pcStack88 == (char *)0x0) { + pcStack88 = "(null)"; + } + pcVar1 = (char *)strlen(pcStack88); +is_string: + __arg = (char **)__arg + 1; + if ((flags != (char *)0xffffffff) && ((int)flags < (int)pcVar1)) { + pcVar1 = flags; + } + pcVar9 = pcVar5; + if (((int)pcVar1 < (int)pcVar12) && ((width & 2) == 0)) { + if ((width & 1) == 0) { + bVar6 = 0x20; + } + else { + bVar6 = 0x30; + } + pcVar9 = pcVar12 + (int)(pcVar5 + -(int)pcVar1); + do { + if (pcVar5 < __maxlen) { + *str = bVar6; + str = str + 1; + } + pcVar5 = pcVar5 + 1; + pcVar12 = pcVar1; + } while (pcVar5 != pcVar9); + } + pcVar5 = pcVar9; + if (pcVar1 != (char *)0x0) { + pcVar10 = pcVar9; + do { + if (pcVar10 < __maxlen) { + *str = pcStack88[(int)(pcVar10 + -(int)pcVar9)]; + str = str + 1; + } + pcVar10 = pcVar10 + 1; + pcVar5 = pcVar1 + (int)pcVar9; + } while (pcVar10 != pcVar1 + (int)pcVar9); + } + if ((int)pcVar1 < (int)pcVar12) { + if ((width & 2) == 0) { + uVar4 = 0; + } + else { + pcVar9 = pcVar5 + -(int)pcVar1; + do { + if (pcVar5 < __maxlen) { + *str = 0x20; + str = str + 1; + } + pcVar5 = pcVar5 + 1; + } while (pcVar5 != pcVar12 + (int)pcVar9); + uVar4 = 0; + pcVar5 = pcVar12 + (int)pcVar9; + pcVar12 = pcVar1; + } + } + else { + uVar4 = 0; + } + goto switchD_23051c14_caseD_5; + case 0x25: + prec = 10; + break; + case 0x28: + prec = 0x10; + } + // WARNING: Could not find normalized switch variable to match jumptable + switch(iVar11) { + case -2: + pcStack104 = (char *)(uint)*(byte *)__arg; + pcStack100 = (char *)0x0; + __arg = (char **)__arg + 1; + break; + case 0: + pcStack104 = *(char **)__arg; + pcStack100 = (char *)0x0; + __arg = (char **)__arg + 1; + break; + case 2: + ppcVar8 = (char **)((int)__arg + 7U & 0xfffffff8); + __arg = ppcVar8 + 2; + pcStack104 = *ppcVar8; + pcStack100 = ppcVar8[1]; + } +is_integer: + if (pcVar5 < __maxlen) { + n = __maxlen - (int)pcVar5; + } + else { + n = 0; + } + n = format_int((char *)str,n,(uint)pcStack104,(int)pcStack100,width,prec); + str = str + n; + uVar4 = 0; + pcVar5 = pcVar5 + n; + break; + case 0x1c: + iVar11 = iVar11 + -1; + break; + case 0x1e: + iVar11 = 2; + break; + case 0x20: + iVar11 = iVar11 + 1; + break; + case 0x28: + case 0x2e: + iVar11 = 1; + } + } + } while( true ); +} + + + +int vsprintf(char *__s,char *__format,__gnuc_va_list __arg) + +{ + int iVar1; + + iVar1 = vsnprintf(__s,0x1e0,__format,__arg); + return iVar1; +} + + + +void vprint(char *fmt,va_list argp) + +{ + uint8_t *puVar1; + int iVar2; + + if (sys_log_all_enable == false) { + return; + } + iVar2 = vsprintf(string,fmt,argp); + puVar1 = (uint8_t *)string; + if (0 < iVar2) { + while( true ) { + if (*puVar1 == '\0') break; + bl_uart_data_send('\0',*puVar1); + puVar1 = puVar1 + 1; + } + } + return; +} + + + +int bl_putchar(int c) + +{ + bl_uart_data_send('\0',(uint8_t)c); + return 0; +} + + + +int puts(char *__s) + +{ + int iVar1; + + iVar1 = 0; + if (sys_log_all_enable != false) { + iVar1 = 0; + while (__s[iVar1] != '\0') { + bl_uart_data_send('\0',__s[iVar1]); + iVar1 = iVar1 + 1; + } + } + return iVar1; +} + + + +int printf(char *__format,...) + +{ + undefined4 in_a1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list argp; + undefined4 uStack28; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + if (sys_log_all_enable != false) { + uStack28 = in_a1; + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + vprint(__format,&uStack28); + } + return 0; +} + + + +int sprintf(char *__s,char *__format,...) + +{ + int iVar1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list ap; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + iVar1 = vsnprintf(__s,0xffffffff,__format,&uStack24); + return iVar1; +} + + + +int snprintf(char *__s,size_t __maxlen,char *__format,...) + +{ + int iVar1; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list ap; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + iVar1 = vsnprintf(__s,__maxlen,__format,&uStack20); + return iVar1; +} + + + +int sscanf(char *__s,char *__format,...) + +{ + int iVar1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list ap; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + iVar1 = vsscanf(__s,__format,&uStack24); + return iVar1; +} + + + +void set_bit(ulong *bitmap,uint bit) + +{ + bitmap[bit >> 5] = bitmap[bit >> 5] | 1 << (bit & 0x1f); + return; +} + + + +int vsscanf(char *__s,char *__format,__gnuc_va_list __arg) + +{ + byte bVar1; + bool bVar2; + bool bVar3; + size_t sVar4; + uint uVar5; + uint bit; + byte *pbVar6; + int base; + uint uVar7; + byte **endptr; + byte **ppbVar8; + uint bit_00; + int iVar9; + byte *nptr; + byte *pbVar10; + size_t n; + byte *pbVar11; + int iVar12; + uint uVar13; + uint uStack132; + uint uStack128; + byte *pbStack100; + char *qq; + ulong matchmap [8]; + + uStack128 = 0; + uStack132 = 0; + iVar12 = 0; + pbVar11 = (byte *)0x0; + bVar2 = false; + bVar3 = false; + iVar9 = 0; + uVar5 = 0; + pbVar10 = (byte *)__s; + n = 0xffffffff; + uVar13 = 0; +switchD_23052248_caseD_7: + nptr = pbVar10; + pbVar6 = (byte *)__format; + uVar7 = uVar5; + bVar1 = *pbVar6; + bit = (uint)bVar1; + __format = (char *)(pbVar6 + 1); + if ((bVar1 == 0) || (uVar13 != 0)) { + if ((uVar13 == 1) && (iVar12 == 0)) { + iVar12 = -1; + } + return iVar12; + } + uVar5 = uVar7; + pbVar10 = nptr; + switch(uVar7) { + case 0: + if (bVar1 == 0x25) { + bVar2 = false; + bVar3 = false; + iVar9 = 0; + uVar5 = 1; + n = 0xffffffff; + uVar13 = uVar7; + goto switchD_23052248_caseD_7; + } + uVar5 = (uint)(byte)_ctype_[bit + 1] & 8; + if ((_ctype_[bit + 1] & 8) == 0) { + uVar13 = 2; + if ((uint)*nptr != bit) goto switchD_23052248_caseD_7; + nptr = nptr + 1; + } + else { + while (uVar5 = (uint)(byte)_ctype_[(uint)*nptr + 1] & 8, (_ctype_[(uint)*nptr + 1] & 8) != 0) + { + nptr = nptr + 1; + } + } + pbVar10 = nptr; + uVar13 = 0; + goto switchD_23052248_caseD_7; + case 1: + if (bVar1 == 0x2a) { + bVar3 = true; + goto switchD_23052248_caseD_7; + } + if ((0x29 < bVar1) && ((bit - 0x30 & 0xff) < 10)) { + bVar2 = true; + uVar5 = 2; + n = bit - 0x30; + goto switchD_23052248_caseD_7; + } + break; + case 2: + if ((bit - 0x30 & 0xff) < 10) { + n = n * 10 + -0x30 + bit; + goto switchD_23052248_caseD_7; + } + break; + case 3: + if (bVar1 == 0x6c) { + iVar9 = iVar9 + 1; + } + else { + if (0x6c < bVar1) { + if ((bVar1 == 0x74) || (bVar1 == 0x7a)) { + iVar9 = 1; + goto switchD_23052248_caseD_7; + } + uVar7 = 0x71; +LAB_230522f0: + if (bit == uVar7) goto LAB_230522f4; + if (2 < iVar9) { + iVar9 = 2; + } + if (iVar9 < -2) { + iVar9 = -2; + } + if (bVar1 == 0x69) { + base = 0; +LAB_230523aa: + while( true ) { + uVar7 = (uint)*nptr; + if ((_ctype_[uVar7 + 1] & 8) == 0) break; + nptr = nptr + 1; + } + pbVar10 = nptr; + if (*nptr == 0) goto LAB_230525ca; + endptr = &pbStack100; + pbVar6 = nptr; + strntoumax((char *)nptr,(char **)endptr,base,n); + if (pbStack100 == nptr) goto LAB_2305234e; + nptr = pbStack100; + if (!bVar3) { + iVar12 = iVar12 + 1; + } +set_integer: + uVar5 = 0; + pbVar10 = nptr; + if (!bVar3) { + if (iVar9 == 0) { + endptr = *(byte ***)__arg; + __arg = (byte **)__arg + 1; + *endptr = pbVar6; +LAB_230524ba: + uVar5 = 0; + pbVar10 = nptr; + goto switchD_23052248_caseD_7; + } + if (iVar9 < 1) { + if (iVar9 == -2) { + **(byte **)__arg = (byte)pbVar6; + } + else { + if (iVar9 != -1) goto switchD_23052248_caseD_7; + **(undefined2 **)__arg = (short)pbVar6; + } + } + else { + if (iVar9 == 2) { + ppbVar8 = *(byte ***)__arg; + *ppbVar8 = pbVar6; + *(byte ***)(ppbVar8 + 1) = endptr; + } + else { + if ((1 < iVar9) && (iVar9 != 0x7fffffff)) goto switchD_23052248_caseD_7; + **(byte ***)__arg = pbVar6; + } + } + __arg = (byte **)__arg + 1; + } + goto switchD_23052248_caseD_7; + } + if (bVar1 < 0x6a) { + if (bVar1 == 0x58) { +scan_int: + base = 0x10; + goto LAB_230523aa; + } + if (0x58 < bVar1) { + if (bVar1 == 99) { + if (!bVar2) { + n = 1; + } + sVar4 = n - 1; + if (!bVar3) { + pbVar11 = *(byte **)__arg; + __arg = (byte **)__arg + 1; + n = n - 1; + while (n != 0xffffffff) { + bVar1 = *nptr; + uVar7 = (uint)bVar1; + pbVar10 = nptr; + if (bVar1 == 0) goto LAB_230525ca; + nptr = nptr + 1; + *pbVar11 = bVar1; + n = n - 1; + pbVar11 = pbVar11 + 1; + } + iVar12 = iVar12 + 1; + goto LAB_230524ba; + } + do { + n = sVar4; + if (n == 0xffffffff) goto LAB_230524ba; + uVar7 = (uint)*nptr; + sVar4 = n - 1; + } while (*nptr != 0); + goto LAB_230525ca; + } + if (bVar1 == 100) goto LAB_2305247c; + if (bVar1 != 0x5b) goto LAB_2305234e; + pbVar11 = (byte *)0x0; + if (!bVar3) { + pbVar11 = *(byte **)__arg; + __arg = (byte **)__arg + 1; + } + memset(&qq,0,0x20); + uStack132 = 0; + uVar5 = 4; + goto switchD_23052248_caseD_7; + } + if (bVar1 == 0x25) { + if ((uint)*nptr == bit) { + nptr = nptr + 1; + goto LAB_230524ba; + } + } + else { + if (bVar1 == 0x50) goto LAB_23052470; + } + } + else { + if (bVar1 == 0x70) { +LAB_23052470: + base = 0; + iVar9 = 0x7fffffff; + goto LAB_230523aa; + } + if (bVar1 < 0x71) { + if (bVar1 == 0x6e) { + pbVar6 = nptr + -(int)__s; + endptr = (byte **)((int)pbVar6 >> 0x1f); + goto set_integer; + } + base = 8; + if (bVar1 == 0x6f) goto LAB_230523aa; + } + else { + if (bVar1 == 0x75) { +LAB_2305247c: + base = 10; + goto LAB_230523aa; + } + if (bVar1 == 0x78) goto scan_int; + if (bVar1 == 0x73) { + n = n - 1; + if (bVar3) { + while (n != 0xffffffff) { + uVar7 = (uint)*nptr; + pbVar10 = nptr; + if (*nptr == 0) goto LAB_230525ca; + if ((_ctype_[uVar7 + 1] & 8) != 0) break; + nptr = nptr + 1; + n = n - 1; + } + goto LAB_230524ba; + } + pbVar11 = *(byte **)__arg; + __arg = (byte **)__arg + 1; + uVar13 = 1; + pbVar10 = pbVar11; + while (n != 0xffffffff) { + bVar1 = *nptr; + uVar13 = (uint)bVar1; + if ((bVar1 == 0) || ((_ctype_[uVar13 + 1] & 8) != 0)) break; + *pbVar10 = bVar1; + nptr = nptr + 1; + pbVar10 = pbVar10 + 1; + n = n - 1; + } + if (pbVar10 != pbVar11) { + *pbVar10 = 0; + iVar12 = iVar12 + 1; + } + uVar13 = (uint)(uVar13 == 0); + uVar5 = 0; + pbVar10 = nptr; + goto switchD_23052248_caseD_7; + } + } + } +LAB_2305234e: + uVar13 = 2; + uVar5 = 0; + pbVar10 = nptr; + goto switchD_23052248_caseD_7; + } + if (bVar1 == 0x68) { + iVar9 = iVar9 + -1; + } + else { + if (bVar1 != 0x6a) { + uVar7 = 0x4c; + goto LAB_230522f0; + } +LAB_230522f4: + iVar9 = 2; + } + } + goto switchD_23052248_caseD_7; + case 4: + if (bVar1 != 0x5e) { + set_bit((ulong *)&qq,bit); + goto LAB_2305255e; + } + uStack132 = 1; + goto switchD_23052248_caseD_7; + case 5: + if (bVar1 == 0x5d) { +match_run: + bit = 1; + while (n != 0) { + bVar1 = *pbVar10; + bit = (uint)bVar1; + if ((bVar1 == 0) || (uStack132 == ((uint)(&qq)[bVar1 >> 5] >> (bit & 0x1f) & 1))) break; + if (pbVar11 != (byte *)0x0) { + *pbVar11 = bVar1; + pbVar11 = pbVar11 + 1; + } + pbVar10 = pbVar10 + 1; + } + if ((nptr == pbVar10) || (pbVar11 == (byte *)0x0)) { + uVar13 = 2; + } + else { + *pbVar11 = 0; + iVar12 = iVar12 + 1; + } + pbStack100 = nptr; + if (bit == 0) { +LAB_230525ca: + uVar13 = 1; + uVar5 = uVar7; + } + } + else { + if (bVar1 == 0x2d) { + uStack128 = 0x2d; + uVar5 = 6; + } + else { + set_bit((ulong *)&qq,bit); + } + } + goto switchD_23052248_caseD_7; + case 6: + bit_00 = uStack128; + if (bVar1 == 0x5d) goto match_run; + while ((int)bit_00 < (int)bit) { + set_bit((ulong *)&qq,bit_00); + bit_00 = bit_00 + 1; + } +LAB_2305255e: + uVar5 = 5; + default: + goto switchD_23052248_caseD_7; + } + uVar5 = 3; + __format = (char *)pbVar6; + goto switchD_23052248_caseD_7; +} + + + +uintmax_t strntoumax(char *nptr,char **endptr,int base,size_t n) + +{ + byte *pbVar1; + uint uVar2; + uint uVar3; + uintmax_t in_fa0; + + while (n != 0) { + if ((_ctype_[(uint)(byte)*nptr + 1] & 8) == 0) { + if (((uint)(byte)*nptr - 0x2b & 0xfd) == 0) { + nptr = (char *)((byte *)nptr + 1); + n = n - 1; + } + if (base != 0) { + if ((((base == 0x10) && (1 < n)) && (*nptr == 0x30)) && ((((byte *)nptr)[1] & 0xdf) == 0x58) + ) { + n = n - 2; + nptr = (char *)((byte *)nptr + 2); + } + goto LAB_2305267a; + } + if (n < 2) { + if (n == 0) goto joined_r0x23052722; + if (*nptr != 0x30) { + n = 1; + base = 10; + goto LAB_2305267a; + } + } + else { + base = 10; + if (*nptr != 0x30) goto LAB_2305267a; + if ((((byte *)nptr)[1] & 0xdf) == 0x58) { + n = n - 2; + nptr = (char *)((byte *)nptr + 2); + base = 0x10; + goto LAB_2305267a; + } + } + n = n - 1; + nptr = (char *)((byte *)nptr + 1); + base = 8; + goto LAB_2305267a; + } + nptr = (char *)((byte *)nptr + 1); + n = n - 1; + } + if (base != 0) { +LAB_2305267a: + pbVar1 = (byte *)nptr + n; + while ((byte *)nptr != pbVar1) { + uVar3 = (uint)(byte)*nptr; + uVar2 = uVar3 - 0x30; + if (9 < uVar2) { + if (uVar3 - 0x41 < 0x1a) { + uVar2 = uVar3 - 0x37; + } + else { + if (0x19 < uVar3 - 0x61) break; + uVar2 = uVar3 - 0x57; + } + } + if (((int)uVar2 < 0) || (base <= (int)uVar2)) break; + nptr = (char *)((byte *)nptr + 1); + } + } +joined_r0x23052722: + if (endptr != (char **)0x0) { + *endptr = nptr; + } + return in_fa0; +} + + + +BL_Err_Type UART_Init(UART_ID_Type uartId,UART_CFG_Type *uartCfg) + +{ + UART_Parity_Type UVar1; + undefined3 in_register_00002029; + uint *puVar2; + uint uVar3; + uint uVar4; + uint uVar5; + uint uVar6; + + puVar2 = (uint *)uartAddr[CONCAT31(in_register_00002029,uartId)]; + uVar5 = uartCfg->uartClk / uartCfg->baudRate; + if (4 < ((uartCfg->uartClk * 10) / uartCfg->baudRate) % 10) { + uVar5 = uVar5 + 1; + } + puVar2[2] = uVar5 - 1 & 0xffff | (uVar5 - 1) * 0x10000; + UVar1 = uartCfg->parity; + uVar5 = *puVar2; + uVar6 = puVar2[1]; + if (UVar1 == UART_PARITY_ODD) { + uVar5 = uVar5 | 0x30; + uVar6 = uVar6 | 0x30; + } + else { + if (UVar1 == UART_PARITY_NONE) { + uVar5 = uVar5 & 0xffffffef; + uVar6 = uVar6 & 0xffffffef; + } + else { + if (UVar1 == UART_PARITY_EVEN) { + uVar5 = uVar5 & 0xffffffdf | 0x10; + uVar6 = uVar6 & 0xffffffdf | 0x10; + } + } + } + uVar3 = ((uint)uartCfg->dataBits + 4) * 0x100; + uVar4 = uVar5 & 0xfffff8ff | uVar3; + uVar3 = uVar6 & 0xfffff8ff | uVar3; + uVar5 = ((uint)uartCfg->stopBits + 1) * 0x1000; + uVar6 = uVar4 & 0xffffcffd | uVar5; + if (uartCfg->ctsFlowControl == ENABLE) { + uVar6 = uVar4 & 0xffffcfff | uVar5 | 2; + } + if (uartCfg->rxDeglitch == ENABLE) { + uVar3 = uVar3 | 0x800; + } + else { + uVar3 = uVar3 & 0xfffff7ff; + } + uVar5 = uVar3 & 0xfffffffd; + if (uartCfg->rtsSoftwareControl == ENABLE) { + uVar5 = uVar3 | 2; + } + *puVar2 = uVar6; + puVar2[1] = uVar5; + uVar5 = puVar2[3] & 0xfffffffe; + if (uartCfg->byteBitInverse == UART_MSB_FIRST) { + uVar5 = puVar2[3] | 1; + } + puVar2[3] = uVar5; + return SUCCESS; +} + + + +BL_Err_Type UART_FifoConfig(UART_ID_Type uartId,UART_FifoCfg_Type *fifoCfg) + +{ + undefined3 in_register_00002029; + uint32_t uVar1; + uint uVar2; + uint uVar3; + + uVar1 = uartAddr[CONCAT31(in_register_00002029,uartId)]; + *(uint *)(uVar1 + 0x84) = + (((uint)fifoCfg->txFifoDmaThreshold - 1) * 0x10000 | *(uint *)(uVar1 + 0x84) & 0xffe0ffff) & + 0xe0ffffff | ((uint)fifoCfg->rxFifoDmaThreshold - 1) * 0x1000000; + uVar3 = *(uint *)(uVar1 + 0x80) & 0xfffffffe; + if (fifoCfg->txFifoDmaEnable == ENABLE) { + uVar3 = *(uint *)(uVar1 + 0x80) | 1; + } + uVar2 = uVar3 & 0xfffffffd; + if (fifoCfg->rxFifoDmaEnable == ENABLE) { + uVar2 = uVar3 | 2; + } + *(uint *)(uVar1 + 0x80) = uVar2; + return SUCCESS; +} + + + +BL_Err_Type UART_Enable(UART_ID_Type uartId,UART_Direction_Type direct) + +{ + undefined3 in_register_00002029; + uint *puVar1; + + puVar1 = (uint *)uartAddr[CONCAT31(in_register_00002029,uartId)]; + if ((direct & ~UART_TXRX) == UART_TX) { + *puVar1 = *puVar1 | 1; + } + if ((byte)(direct + ~UART_TX) < 2) { + puVar1[1] = puVar1[1] | 1; + } + return SUCCESS; +} + + + +BL_Err_Type UART_Disable(UART_ID_Type uartId,UART_Direction_Type direct) + +{ + undefined3 in_register_00002029; + uint *puVar1; + + puVar1 = (uint *)uartAddr[CONCAT31(in_register_00002029,uartId)]; + if ((direct & ~UART_TXRX) == UART_TX) { + *puVar1 = *puVar1 & 0xfffffffe; + } + if ((byte)(direct + ~UART_TX) < 2) { + puVar1[1] = puVar1[1] & 0xfffffffe; + } + return SUCCESS; +} + + + +BL_Err_Type UART_SetRxTimeoutValue(UART_ID_Type uartId,uint8_t time) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + + *(uint *)(uartAddr[CONCAT31(in_register_00002029,uartId)] + 0x18) = + CONCAT31(in_register_0000202d,time) - 1U | + *(uint *)(uartAddr[CONCAT31(in_register_00002029,uartId)] + 0x18) & 0xffffff00; + return SUCCESS; +} + + + +BL_Err_Type UART_TxFreeRun(UART_ID_Type uartId,BL_Fun_Type txFreeRun) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + uint uVar1; + + uVar1 = *(uint *)uartAddr[CONCAT31(in_register_00002029,uartId)]; + if (CONCAT31(in_register_0000202d,txFreeRun) == 1) { + uVar1 = uVar1 | 4; + } + else { + uVar1 = uVar1 & 0xfffffffb; + } + *(uint *)uartAddr[CONCAT31(in_register_00002029,uartId)] = uVar1; + return SUCCESS; +} + + + +BL_Err_Type UART_IntMask(UART_ID_Type uartId,UART_INT_Type intType,BL_Mask_Type intMask) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + uint uVar1; + undefined3 in_register_00002031; + uint uVar2; + + uVar2 = *(uint *)(uartAddr[CONCAT31(in_register_00002029,uartId)] + 0x24); + if (CONCAT31(in_register_0000202d,intType) == 8) { + uVar1 = 0; + if (CONCAT31(in_register_00002031,intMask) == 1) { + uVar1 = uVar2 | 0xff; + } + } + else { + uVar1 = 1 << ((uint)intType & 0x1f); + if (CONCAT31(in_register_00002031,intMask) == 1) { + uVar1 = uVar1 | uVar2; + } + else { + uVar1 = ~uVar1 & uVar2; + } + } + *(uint *)(uartAddr[CONCAT31(in_register_00002029,uartId)] + 0x24) = uVar1; + return SUCCESS; +} + + + +uint8_t UART_GetTxFifoCount(UART_ID_Type uartId) + +{ + undefined3 in_register_00002029; + + return (uint8_t)((byte)*(undefined4 *)(uartAddr[CONCAT31(in_register_00002029,uartId)] + 0x84) & + 0x3f); +} + + + +BL_Err_Type UART_SendData(UART_ID_Type uartId,uint8_t *data,uint32_t len) + +{ + int iVar1; + uint uVar2; + uint8_t uVar3; + undefined3 in_register_00002029; + undefined3 extraout_var; + uint8_t *puVar4; + uint32_t uVar5; + + uVar5 = uartAddr[CONCAT31(in_register_00002029,uartId)]; + iVar1 = 160000; + uVar2 = 0; + do { + while( true ) { + if (len <= uVar2) { + return SUCCESS; + } + uVar3 = UART_GetTxFifoCount(uartId); + if (CONCAT31(extraout_var,uVar3) == 0) break; + puVar4 = data + uVar2; + uVar2 = uVar2 + 1; + iVar1 = 160000; + *(uint8_t *)(uVar5 + 0x88) = *puVar4; + } + iVar1 = iVar1 + -1; + } while (iVar1 != 0); + return TIMEOUT; +} + + + +uint8_t UART_GetRxFifoCount(UART_ID_Type uartId) + +{ + undefined3 in_register_00002029; + + return (uint8_t)((byte)((uint)*(undefined4 *) + (uartAddr[CONCAT31(in_register_00002029,uartId)] + 0x84) >> 8) & + 0x3f); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Reset(void) + +{ + _DAT_4000f90c = _DAT_4000f90c & 0xfffffffb; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Enable(void) + +{ + _DAT_4000f90c = _DAT_4000f90c | 1; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Disable(void) + +{ + _DAT_4000f90c = _DAT_4000f90c & 0xfffffffe; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Channel_Config(ADC_Chan_Type posCh,ADC_Chan_Type negCh,BL_Fun_Type contEn) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + + _DAT_4000f90c = + CONCAT31(in_register_00002029,posCh) << 8 | _DAT_4000f90c & 0xffffe007 | + CONCAT31(in_register_0000202d,negCh) << 3; + _DAT_4000f910 = + (CONCAT31(in_register_00002031,contEn) << 1 | _DAT_4000f910 & 0xfffffffd) & 0xfdffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Start(void) + +{ + _DAT_4000f90c = _DAT_4000f90c & 0xfffffffd; + BL602_Delay_US(100); + _DAT_4000f90c = _DAT_4000f90c | 2; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_FIFO_Cfg(ADC_FIFO_Cfg_Type *fifoCfg) + +{ + _DAT_40002000 = + (uint)fifoCfg->fifoThreshold << 0x16 | _DAT_40002000 & 0xff3ffffe | (uint)fifoCfg->dmaEn | 2; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t ADC_Get_FIFO_Count(void) + +{ + return (uint8_t)((byte)((uint)_DAT_40002000 >> 0x10) & 0x3f); +} + + + +// WARNING: Control flow encountered bad instruction data + +void ADC_Parse_Result(uint32_t *orgVal,uint32_t len,ADC_Result_Type *result) + +{ + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Tsen_Init(ADC_TSEN_MOD_Type tsenMod) + +{ + undefined3 in_register_00002029; + + _DAT_4000f90c = _DAT_4000f90c & 0x87ffffff | 0xc0000; + _DAT_4000f910 = _DAT_4000f910 | 0x4000000; + _DAT_4000f914 = + (_DAT_4000f914 & 0xfc3ffdf | CONCAT31(in_register_00002029,tsenMod) << 5) & 0xffffa07f | + 0x20000140; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_SET_TSVBE_LOW(void) + +{ + _DAT_4000f914 = _DAT_4000f914 & 0x7fffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_SET_TSVBE_HIGH(void) + +{ + _DAT_4000f914 = _DAT_4000f914 | 0x80000000; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t TSEN_Get_V_Error(void) + +{ + BL_Fun_Type BVar1; + uint8_t uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint uVar3; + uint32_t uStack44; + uint32_t regVal; + ADC_Result_Type result; + + uStack44 = 0; + _DAT_40002000 = _DAT_40002000 | 2; + ADC_SET_TSVBE_LOW(); + ADC_Start(); + do { + uVar2 = ADC_Get_FIFO_Count(); + BVar1 = adcGainCoeffCal.adcGainCoeffEnable; + } while (CONCAT31(extraout_var,uVar2) == 0); + uStack44 = _DAT_40002004; + adcGainCoeffCal.adcGainCoeffEnable = DISABLE; + ADC_Parse_Result(&uStack44,1,(ADC_Result_Type *)®Val); + uVar3 = (uint)regVal._2_2_; + _DAT_40002000 = _DAT_40002000 | 2; + adcGainCoeffCal.adcGainCoeffEnable = BVar1; + ADC_SET_TSVBE_HIGH(); + ADC_Start(); + do { + uVar2 = ADC_Get_FIFO_Count(); + BVar1 = adcGainCoeffCal.adcGainCoeffEnable; + } while (CONCAT31(extraout_var_00,uVar2) == 0); + uStack44 = _DAT_40002004; + adcGainCoeffCal.adcGainCoeffEnable = DISABLE; + ADC_Parse_Result(&uStack44,1,(ADC_Result_Type *)®Val); + adcGainCoeffCal.adcGainCoeffEnable = BVar1; + return uVar3 - regVal._2_2_; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +float TSEN_Get_Temp(uint32_t tsen_offset) + +{ + BL_Fun_Type BVar1; + uint8_t uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint32_t *orgVal; + SFtype SVar3; + undefined4 uVar4; + uint32_t uStack44; + uint32_t regVal; + ADC_Result_Type result; + + uStack44 = 0; + _DAT_40002000 = _DAT_40002000 | 2; + uVar4 = ADC_SET_TSVBE_LOW(); + ADC_Start(uVar4); + do { + uVar2 = ADC_Get_FIFO_Count(); + BVar1 = adcGainCoeffCal.adcGainCoeffEnable; + } while (CONCAT31(extraout_var,uVar2) == 0); + uStack44 = _DAT_40002004; + adcGainCoeffCal.adcGainCoeffEnable = DISABLE; + ADC_Parse_Result(&uStack44,1,(ADC_Result_Type *)®Val); + _DAT_40002000 = _DAT_40002000 | 2; + adcGainCoeffCal.adcGainCoeffEnable = BVar1; + uVar4 = ADC_SET_TSVBE_HIGH(); + ADC_Start(uVar4); + do { + uVar2 = ADC_Get_FIFO_Count(); + BVar1 = adcGainCoeffCal.adcGainCoeffEnable; + } while (CONCAT31(extraout_var_00,uVar2) == 0); + orgVal = &uStack44; + uStack44 = _DAT_40002004; + adcGainCoeffCal.adcGainCoeffEnable = DISABLE; + ADC_Parse_Result(orgVal,1,(ADC_Result_Type *)®Val); + adcGainCoeffCal.adcGainCoeffEnable = BVar1; + __extendsfdf2((SFtype)orgVal); + __divdf3(); + SVar3 = __truncdfsf2(); + return (float)SVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Init(ADC_CFG_Type *cfg) + +{ + uint uVar1; + uint uVar2; + + _DAT_4000f910 = + (uint)cfg->resWidth << 2 | + ((uint)cfg->clkDiv << 0x12 | + (uint)cfg->v11Sel << 0x1b | (uint)cfg->v18Sel << 0x1d | _DAT_4000f910 & 0x8001fffe | + (uint)cfg->offsetCalibEn) & 0xffffffe3; + if ((cfg->gain1 | cfg->gain2) == 0) { + uVar1 = 0xfffe1fff; + uVar2 = 0x8000; + } + else { + uVar1 = 0xfffe3fff; + uVar2 = 0x12000; + } + _DAT_4000f914 = + ((uint)cfg->biasSel << 0x11 | + (uint)cfg->gain2 << 0x16 | (uint)cfg->gain1 << 0x19 | _DAT_4000f914 & 0x803dffff) & uVar1 & + 0xffffe073 | uVar2 | (uint)cfg->vcm << 7 | (uint)cfg->vref << 3 | 0x1000 | + (uint)cfg->inputMode << 2; + _DAT_4000f938 = (int)cfg->offsetCalibVal | _DAT_4000f938 & 0xffff0000; + // WARNING: Treating indirect jump as call + ADC_Gain_Trim(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_PKA_Write_Common_OP_First_Cfg + (uint8_t s0RegIndex,uint8_t s0RegType,uint8_t dRegIndex,uint8_t dRegType,uint8_t op, + uint8_t lastOp) + +{ + undefined3 in_register_00002029; + uint uVar1; + undefined3 in_register_00002031; + undefined3 in_register_00002039; + + uVar1 = CONCAT31(in_register_00002029,s0RegIndex) | ((uint)s0RegType & 0xf) << 8; + if (CONCAT31(in_register_00002039,op) != 0x19) { + uVar1 = uVar1 | CONCAT31(in_register_00002031,dRegIndex) << 0xc | ((uint)dRegType & 0xf) << 0x14 + ; + } + _DAT_40004340 = uVar1 & 0xffffff | ((uint)op & 0x7f) << 0x18 | (uint)lastOp << 0x1f; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type Sec_Eng_PKA_Wait_ISR(void) + +{ + int iVar1; + + iVar1 = 16000000; + do { + iVar1 = iVar1 + -1; + if (iVar1 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004300 & 0x100) == 0); + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type Sec_Eng_SHA256_Update(SEC_Eng_SHA256_Ctx *shaCtx,uint8_t *input,uint32_t len) + +{ + byte bVar1; + uint uVar2; + int iVar3; + uint n; + uint32_t *psrc; + uint uVar4; + + uVar2 = _DAT_40004000; + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + bVar1 = shaCtx->shaFeed; + uVar4 = shaCtx->total[0] & 0x3f; + n = shaCtx->total[0] + len; + shaCtx->total[0] = n; + if (n < len) { + shaCtx->total[1] = shaCtx->total[1] + 1; + } + if ((uVar4 != 0) && (n = 0x40 - uVar4, n <= len)) { + BL602_MemCpy_Fast((void *)((int)shaCtx->shaBuf + uVar4),input,n); + _DAT_40004004 = shaCtx->shaBuf; + _DAT_40004000 = (uint)bVar1 << 6 | uVar2 & 0xffbf | 0x10002; + len = (len - 0x40) + uVar4; + shaCtx->shaFeed = '\x01'; + input = input + n; + uVar4 = 0; + } + psrc = (uint32_t *)input; + if (0x3f < len) { + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + _DAT_40004000 = (len >> 6) << 0x10 | (uint)shaCtx->shaFeed << 6 | _DAT_40004000 & 0xffbf | 2; + psrc = (uint32_t *)((int)input + (len & 0xffffffc0)); + _DAT_40004004 = (uint32_t *)input; + shaCtx->shaFeed = '\x01'; + } + if ((len & 0x3f) != 0) { + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + BL602_MemCpy_Fast((void *)((int)shaCtx->shaBuf + uVar4),psrc,len & 0x3f); + } + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_SHA256_Init(SEC_Eng_SHA256_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo, + SEC_ENG_SHA_Type shaType,uint32_t *shaTmpBuf,uint32_t *padding) + +{ + undefined3 in_register_00002031; + + _DAT_40004000 = CONCAT31(in_register_00002031,shaType) << 2 | _DAT_40004000 & 0xffffffe3; + memset(shaCtx,0,0x14); + shaCtx->shaPadding = padding; + shaCtx->shaBuf = shaTmpBuf; + BL602_MemSet(padding,'\0',0x40); + // WARNING: Treating indirect jump as call + BL602_MemSet(shaCtx->shaPadding,-0x80,1); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_SHA_Start(SEC_ENG_SHA_ID_Type shaNo) + +{ + _DAT_40004000 = _DAT_40004000 & 0xffffffbf | 0x20; + return; +} + + + +BL_Err_Type +Sec_Eng_SHA256_Update + (SEC_Eng_SHA256_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,uint8_t *input,uint32_t len) + +{ + BL_Err_Type BVar1; + + if (len != 0) { + BVar1 = Sec_Eng_SHA256_Update(shaCtx,input,len); + return BVar1; + } + return SUCCESS; +} + + + +// WARNING: Could not reconcile some variable overlaps +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +Sec_Eng_SHA256_Finish(SEC_Eng_SHA256_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,uint8_t *hash) + +{ + undefined4 uVar1; + uint uVar2; + int iVar3; + uint uVar4; + undefined uStack24; + undefined uStack23; + ushort uStack22; + uint8_t msgLen [8]; + + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + uVar2 = shaCtx->total[0]; + uVar4 = shaCtx->total[1] << 3; + uStack24 = (undefined)(uVar4 >> 0x18); + uStack23 = (undefined)(uVar4 >> 0x10); + uStack22 = (ushort)((uVar4 | uVar2 >> 0x1d) << 8) | (ushort)(uVar4 >> 8) & 0xff; + msgLen[0] = (uint8_t)((uVar2 << 3) >> 0x18); + msgLen[1] = (uint8_t)((uVar2 << 3) >> 0x10); + msgLen._2_2_ = (ushort)((uVar2 << 0x13) >> 0x18) | (ushort)(uVar2 << 0xb); + if ((uVar2 & 0x3f) < 0x38) { + iVar3 = 0x38; + } + else { + iVar3 = 0x78; + } + Sec_Eng_SHA256_Update(shaCtx,shaNo,(uint8_t *)shaCtx->shaPadding,iVar3 - (uVar2 & 0x3f)); + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + BL602_MemCpy_Fast(shaCtx->shaPadding,&uStack24,8); + Sec_Eng_SHA256_Update(shaCtx,(uint8_t *)shaCtx->shaPadding,8); + uVar1 = _DAT_40004010; + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + uVar2 = _DAT_40004000 >> 2; + *hash = (uint8_t)_DAT_40004010; + hash[1] = (uint8_t)((uint)uVar1 >> 8); + hash[2] = (uint8_t)((uint)uVar1 >> 0x10); + hash[3] = (uint8_t)((uint)uVar1 >> 0x18); + uVar1 = _DAT_40004014; + hash[4] = (uint8_t)_DAT_40004014; + hash[5] = (uint8_t)((uint)uVar1 >> 8); + hash[6] = (uint8_t)((uint)uVar1 >> 0x10); + hash[7] = (uint8_t)((uint)uVar1 >> 0x18); + uVar1 = _DAT_40004018; + hash[8] = (uint8_t)_DAT_40004018; + hash[9] = (uint8_t)((uint)uVar1 >> 8); + hash[10] = (uint8_t)((uint)uVar1 >> 0x10); + hash[0xb] = (uint8_t)((uint)uVar1 >> 0x18); + uVar1 = _DAT_4000401c; + hash[0xc] = (uint8_t)_DAT_4000401c; + hash[0xd] = (uint8_t)((uint)uVar1 >> 8); + hash[0xe] = (uint8_t)((uint)uVar1 >> 0x10); + hash[0xf] = (uint8_t)((uint)uVar1 >> 0x18); + uVar1 = _DAT_40004020; + hash[0x10] = (uint8_t)_DAT_40004020; + hash[0x11] = (uint8_t)((uint)uVar1 >> 8); + hash[0x13] = (uint8_t)((uint)uVar1 >> 0x18); + hash[0x12] = (uint8_t)((uint)uVar1 >> 0x10); + uVar1 = _DAT_40004024; + if ((uVar2 & 6) == 0) { + hash[0x14] = (uint8_t)_DAT_40004024; + hash[0x15] = (uint8_t)((uint)uVar1 >> 8); + hash[0x16] = (uint8_t)((uint)uVar1 >> 0x10); + hash[0x17] = (uint8_t)((uint)uVar1 >> 0x18); + uVar1 = _DAT_40004028; + hash[0x18] = (uint8_t)_DAT_40004028; + hash[0x19] = (uint8_t)((uint)uVar1 >> 8); + hash[0x1a] = (uint8_t)((uint)uVar1 >> 0x10); + hash[0x1b] = (uint8_t)((uint)uVar1 >> 0x18); + uVar1 = _DAT_4000402c; + if ((uVar2 & 7) == 0) { + hash[0x1c] = (uint8_t)_DAT_4000402c; + hash[0x1d] = (uint8_t)((uint)uVar1 >> 8); + hash[0x1e] = (uint8_t)((uint)uVar1 >> 0x10); + hash[0x1f] = (uint8_t)((uint)uVar1 >> 0x18); + } + } + _DAT_40004000 = _DAT_40004000 & 0xffffff9f; + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_SHA_Enable_Link(SEC_ENG_SHA_ID_Type shaNo) + +{ + _DAT_40004000 = _DAT_40004000 | 0x8020; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_SHA_Disable_Link(SEC_ENG_SHA_ID_Type shaNo) + +{ + _DAT_40004000 = _DAT_40004000 & 0xffff7fdf; + return; +} + + + +void Sec_Eng_SHA256_Link_Init + (SEC_Eng_SHA256_Link_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,uint32_t linkAddr, + uint32_t *shaTmpBuf,uint32_t *padding) + +{ + memset(shaCtx,0,0x14); + shaCtx->shaPadding = padding; + shaCtx->shaBuf = shaTmpBuf; + BL602_MemSet(padding,'\0',0x40); + BL602_MemSet(shaCtx->shaPadding,-0x80,1); + shaCtx->linkAddr = linkAddr; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +Sec_Eng_SHA256_Link_Update + (SEC_Eng_SHA256_Link_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,uint8_t *input,uint32_t len) + +{ + int iVar1; + uint n; + uint uVar2; + + if (len == 0) { + return SUCCESS; + } + iVar1 = 16000000; + do { + iVar1 = iVar1 + -1; + if (iVar1 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + _DAT_40004050 = shaCtx->linkAddr; + uVar2 = shaCtx->total[0] & 0x3f; + n = shaCtx->total[0] + len; + shaCtx->total[0] = n; + if (n < len) { + shaCtx->total[1] = shaCtx->total[1] + 1; + } + if ((uVar2 != 0) && (n = 0x40 - uVar2, n <= len)) { + BL602_MemCpy_Fast((void *)((int)shaCtx->shaBuf + uVar2),input,n); + input = input + n; + *(uint32_t **)(shaCtx->linkAddr + 4) = shaCtx->shaBuf; + *(undefined2 *)(shaCtx->linkAddr + 2) = 1; + _DAT_40004000 = _DAT_40004000 | 2; + len = (len + uVar2) - 0x40; + *(uint *)shaCtx->linkAddr = *(uint *)shaCtx->linkAddr | 0x40; + uVar2 = 0; + } + if (0x3f < len) { + iVar1 = 16000000; + do { + iVar1 = iVar1 + -1; + if (iVar1 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + *(uint8_t **)(shaCtx->linkAddr + 4) = input; + input = input + (len & 0xffffffc0); + *(undefined2 *)(shaCtx->linkAddr + 2) = (short)(len >> 6); + _DAT_40004000 = _DAT_40004000 | 2; + *(uint *)shaCtx->linkAddr = *(uint *)shaCtx->linkAddr | 0x40; + } + if ((len & 0x3f) != 0) { + iVar1 = 16000000; + do { + iVar1 = iVar1 + -1; + if (iVar1 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + BL602_MemCpy_Fast((void *)((int)shaCtx->shaBuf + uVar2),input,len & 0x3f); + } + iVar1 = 16000000; + do { + iVar1 = iVar1 + -1; + if (iVar1 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + return SUCCESS; +} + + + +// WARNING: Could not reconcile some variable overlaps +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +Sec_Eng_SHA256_Link_Finish(SEC_Eng_SHA256_Link_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,uint8_t *hash) + +{ + uint uVar1; + uint32_t n; + uint uVar2; + int iVar3; + uint uVar4; + uint8_t uStack40; + undefined uStack39; + ushort uStack38; + uint8_t msgLen [8]; + + iVar3 = 16000000; + uVar1 = *(uint *)shaCtx->linkAddr; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + uVar2 = shaCtx->total[0]; + uVar4 = shaCtx->total[1] << 3; + uStack40 = (uint8_t)(uVar4 >> 0x18); + uStack39 = (undefined)(uVar4 >> 0x10); + uStack38 = (ushort)((uVar4 | uVar2 >> 0x1d) << 8) | (ushort)(uVar4 >> 8) & 0xff; + msgLen[0] = (uint8_t)((uVar2 << 3) >> 0x18); + msgLen[1] = (uint8_t)((uVar2 << 3) >> 0x10); + msgLen._2_2_ = (ushort)((uVar2 << 0x13) >> 0x18) | (ushort)(uVar2 << 0xb); + if ((uVar2 & 0x3f) < 0x38) { + iVar3 = 0x38; + } + else { + iVar3 = 0x78; + } + _DAT_40004050 = (uint *)shaCtx->linkAddr; + Sec_Eng_SHA256_Link_Update(shaCtx,shaNo,(uint8_t *)shaCtx->shaPadding,iVar3 - (uVar2 & 0x3f)); + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + Sec_Eng_SHA256_Link_Update(shaCtx,shaNo,&uStack40,8); + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + uVar1 = uVar1 >> 2 & 7; + if (uVar1 == 1) { + n = 0x1c; + } + else { + if (uVar1 == 0) { + n = 0x20; + } + else { + n = 0x14; + if (3 < uVar1) goto LAB_230537a0; + } + } + BL602_MemCpy_Fast(hash,(void *)(shaCtx->linkAddr + 8),n); +LAB_230537a0: + *(uint *)shaCtx->linkAddr = *(uint *)shaCtx->linkAddr & 0xffffffbf; + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_AES_Enable_Link(SEC_ENG_AES_ID_Type aesNo) + +{ + _DAT_40004100 = _DAT_40004100 | 0x8000; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_AES_Disable_Link(SEC_ENG_AES_ID_Type aesNo) + +{ + _DAT_40004100 = _DAT_40004100 & 0xffff7fff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +Sec_Eng_AES_Link_Work + (SEC_ENG_AES_ID_Type aesNo,uint32_t linkAddr,uint8_t *in,uint32_t len,uint8_t *out) + +{ + BL_Err_Type BVar1; + int iVar2; + + BVar1 = ERROR; + if ((linkAddr & 3 | len & 0xf) == 0) { + iVar2 = 16000000; + do { + iVar2 = iVar2 + -1; + if (iVar2 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004100 & 1) != 0); + _DAT_40004150 = linkAddr; + *(uint8_t **)(linkAddr + 4) = in; + *(uint8_t **)(linkAddr + 8) = out; + *(undefined2 *)(linkAddr + 2) = (short)(len >> 4); + iVar2 = 16000000; + do { + iVar2 = iVar2 + -1; + if (iVar2 == 0) { + _DAT_40004100 = _DAT_40004100 | 6; + return TIMEOUT; + } + } while ((_DAT_40004100 & 1) != 0); + _DAT_40004100 = (_DAT_40004100 | 6) & 0xfffffffb; + BVar1 = SUCCESS; + } + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_PKA_Reset(void) + +{ + _DAT_40004300 = 8; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_PKA_BigEndian_Enable(void) + +{ + _DAT_40004300 = _DAT_40004300 | 0x1000; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_PKA_Clear_Int(void) + +{ + _DAT_40004300 = _DAT_40004300 & 0xfffffdff; + return; +} + + + +void Sec_Eng_PKA_Read_Block(uint32_t *dest,uint32_t *src,uint32_t len) + +{ + uint uVar1; + + uVar1 = 0; + while (uVar1 != (len & 0xfffffffc)) { + dest[uVar1] = *src; + uVar1 = uVar1 + 1; + } + return; +} + + + +void Sec_Eng_PKA_Write_Block(uint32_t *dest,uint32_t *src,uint32_t len) + +{ + uint32_t *puVar1; + uint uVar2; + + uVar2 = 0; + while (uVar2 != (len & 0xfffffffc)) { + puVar1 = src + uVar2; + uVar2 = uVar2 + 1; + *dest = *puVar1; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_PKA_Write_Data + (SEC_ENG_PKA_REG_SIZE_Type regType,uint8_t regIndex,uint32_t *data,uint16_t size, + uint8_t lastOp) + +{ + undefined3 in_register_0000202d; + uint uVar1; + undefined2 in_register_00002036; + uint uVar2; + + uVar1 = (uint)regType - 1 & 0xff; + uVar2 = 0; + if (uVar1 < 10) { + uVar2 = (uint)*(ushort *)(CSWTCH_116 + uVar1 * 2); + } + _DAT_40004340 = + (uint)size & 0xfff | CONCAT31(in_register_0000202d,regIndex) << 0xc | + ((uint)regType & 0xf) << 0x14 | 0x39000000 | (uint)lastOp << 0x1f; + uVar1 = uVar2 >> 2; + if (CONCAT22(in_register_00002036,size) < uVar2 >> 2) { + uVar1 = CONCAT22(in_register_00002036,size); + } + Sec_Eng_PKA_Write_Block((uint32_t *)&DAT_40004340,data,uVar1 & 0xffff); + uVar2 = uVar1 & 0xfffc; + while ((int)uVar2 < (int)(uVar1 & 0xffff)) { + _DAT_40004340 = data[uVar2]; + uVar2 = uVar2 + 1; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_PKA_Read_Data + (SEC_ENG_PKA_REG_SIZE_Type regType,uint8_t regIdx,uint32_t *result,uint8_t retSize) + +{ + undefined3 in_register_00002035; + uint len; + uint uVar1; + uint uVar2; + + len = CONCAT31(in_register_00002035,retSize); + uVar2 = (uint)regType - 1 & 0xff; + uVar1 = 0; + if (uVar2 < 10) { + uVar1 = (uint)*(ushort *)(CSWTCH_116 + uVar2 * 2); + } + if (len <= uVar1 >> 2) { + _DAT_40004340 = 0; + Sec_Eng_PKA_Wait_ISR(); + Sec_Eng_PKA_Clear_Int(); + Sec_Eng_PKA_Read_Block(result,(uint32_t *)&DAT_40004340,len); + uVar1 = len & 0xfffffffc; + while ((int)uVar1 < (int)len) { + result[uVar1] = _DAT_40004340; + uVar1 = uVar1 + 1; + } + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_PKA_CREG(SEC_ENG_PKA_REG_SIZE_Type dRegType,uint8_t dRegIdx,uint8_t size,uint8_t lastOp + ) + +{ + undefined3 in_register_00002035; + + _DAT_40004340 = 0; + if (CONCAT31(in_register_00002035,lastOp) != 0) { + Sec_Eng_PKA_Wait_ISR(); + Sec_Eng_PKA_Clear_Int(); + return; + } + _DAT_40004340 = 0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_PKA_Move_Data + (uint8_t dRegType,uint8_t dRegIdx,uint8_t s0RegType,uint8_t s0RegIdx,uint8_t lastOp) + +{ + undefined3 in_register_00002039; + + Sec_Eng_PKA_Write_Common_OP_First_Cfg(s0RegIdx,s0RegType,dRegIdx,dRegType,'2',lastOp); + _DAT_40004340 = 0; + if (CONCAT31(in_register_00002039,lastOp) != 0) { + Sec_Eng_PKA_Wait_ISR(); + Sec_Eng_PKA_Clear_Int(); + return; + } + _DAT_40004340 = 0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_PKA_MREM(uint8_t dRegType,uint8_t dRegIdx,uint8_t s0RegType,uint8_t s0RegIdx, + uint8_t s2RegType,uint8_t s2RegIdx,uint8_t lastOp) + +{ + undefined3 in_register_0000203d; + undefined3 in_register_00002041; + + Sec_Eng_PKA_Write_Common_OP_First_Cfg(s0RegIdx,s0RegType,dRegIdx,dRegType,'&',lastOp); + _DAT_40004340 = ((uint)s2RegType & 0xf) << 8 | CONCAT31(in_register_0000203d,s2RegIdx); + if (CONCAT31(in_register_00002041,lastOp) != 0) { + Sec_Eng_PKA_Wait_ISR(); + Sec_Eng_PKA_Clear_Int(); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_PKA_MEXP(uint8_t dRegType,uint8_t dRegIdx,uint8_t s0RegType,uint8_t s0RegIdx, + uint8_t s1RegType,uint8_t s1RegIdx,uint8_t s2RegType,uint8_t s2RegIdx, + uint8_t lastOp) + +{ + undefined3 in_register_0000203d; + undefined3 in_register_00002045; + uint8_t in_stack_00000000; + + Sec_Eng_PKA_Write_Common_OP_First_Cfg(s0RegIdx,s0RegType,dRegIdx,dRegType,'#',in_stack_00000000); + _DAT_40004340 = + CONCAT31(in_register_0000203d,s1RegIdx) << 0xc | ((uint)s1RegType & 0xf) << 0x14 | + CONCAT31(in_register_00002045,s2RegIdx) | ((uint)s2RegType & 0xf) << 8; + if (in_stack_00000000 != '\0') { + Sec_Eng_PKA_Wait_ISR(); + Sec_Eng_PKA_Clear_Int(); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_PKA_LCMP(uint8_t *cout,uint8_t s0RegType,uint8_t s0RegIdx,uint8_t s1RegType, + uint8_t s1RegIdx) + +{ + undefined3 in_register_00002039; + + _DAT_40004340 = CONCAT31(in_register_00002039,s1RegIdx) << 0xc | ((uint)s1RegType & 0xf) << 0x14; + Sec_Eng_PKA_Wait_ISR(); + Sec_Eng_PKA_Clear_Int(); + *cout = (byte)((uint)_DAT_40004300 >> 0x18) & 1; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_PKA_LSUB(uint8_t dRegType,uint8_t dRegIdx,uint8_t s0RegType,uint8_t s0RegIdx, + uint8_t s1RegType,uint8_t s1RegIdx,uint8_t lastOp) + +{ + undefined3 in_register_0000203d; + undefined3 in_register_00002041; + + Sec_Eng_PKA_Write_Common_OP_First_Cfg(s0RegIdx,s0RegType,dRegIdx,dRegType,'\x17',lastOp); + _DAT_40004340 = CONCAT31(in_register_0000203d,s1RegIdx) << 0xc | ((uint)s1RegType & 0xf) << 0x14; + if (CONCAT31(in_register_00002041,lastOp) != 0) { + Sec_Eng_PKA_Wait_ISR(); + Sec_Eng_PKA_Clear_Int(); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_PKA_LMUL(uint8_t dRegType,uint8_t dRegIdx,uint8_t s0RegType,uint8_t s0RegIdx, + uint8_t s1RegType,uint8_t s1RegIdx,uint8_t lastOp) + +{ + undefined3 in_register_0000203d; + undefined3 in_register_00002041; + + Sec_Eng_PKA_Write_Common_OP_First_Cfg(s0RegIdx,s0RegType,dRegIdx,dRegType,'\x16',lastOp); + _DAT_40004340 = CONCAT31(in_register_0000203d,s1RegIdx) << 0xc | ((uint)s1RegType & 0xf) << 0x14; + if (CONCAT31(in_register_00002041,lastOp) != 0) { + Sec_Eng_PKA_Wait_ISR(); + Sec_Eng_PKA_Clear_Int(); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_PKA_LDIV(uint8_t dRegType,uint8_t dRegIdx,uint8_t s0RegType,uint8_t s0RegIdx, + uint8_t s2RegType,uint8_t s2RegIdx,uint8_t lastOp) + +{ + undefined3 in_register_0000203d; + undefined3 in_register_00002041; + + Sec_Eng_PKA_Write_Common_OP_First_Cfg(s0RegIdx,s0RegType,dRegIdx,dRegType,'\x14',lastOp); + _DAT_40004340 = ((uint)s2RegType & 0xf) << 8 | CONCAT31(in_register_0000203d,s2RegIdx); + if (CONCAT31(in_register_00002041,lastOp) != 0) { + Sec_Eng_PKA_Wait_ISR(); + Sec_Eng_PKA_Clear_Int(); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_PKA_LMUL2N(uint8_t dRegType,uint8_t dRegIdx,uint8_t s0RegType,uint8_t s0RegIdx, + uint16_t bit_shift,uint8_t lastOp) + +{ + undefined3 in_register_0000203d; + + Sec_Eng_PKA_Write_Common_OP_First_Cfg(s0RegIdx,s0RegType,dRegIdx,dRegType,'\x13','\0'); + _DAT_40004340 = (uint)bit_shift & 0x7fff; + if (CONCAT31(in_register_0000203d,lastOp) != 0) { + Sec_Eng_PKA_Wait_ISR(); + Sec_Eng_PKA_Clear_Int(); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SEC_Eng_IntMask(SEC_ENG_INT_Type intType,BL_Mask_Type intMask) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + int iVar1; + + iVar1 = CONCAT31(in_register_0000202d,intMask); + switch(CONCAT31(in_register_00002029,intType)) { + case 0: + if (iVar1 == 0) { + _DAT_40004200 = _DAT_40004200 & 0xfffff7ff; + } + else { + _DAT_40004200 = _DAT_40004200 | 0x800; + } + return; + case 1: + if (iVar1 == 0) { + _DAT_40004100 = _DAT_40004100 & 0xfffff7ff; + } + else { + _DAT_40004100 = _DAT_40004100 | 0x800; + } + return; + case 2: + if (iVar1 == 0) { + _DAT_40004000 = _DAT_40004000 & 0xfffff7ff; + } + else { + _DAT_40004000 = _DAT_40004000 | 0x800; + } + return; + case 3: + if (iVar1 == 0) { + _DAT_40004300 = _DAT_40004300 & 0xfffff7ff; + } + else { + _DAT_40004300 = _DAT_40004300 | 0x800; + } + return; + case 5: + if (iVar1 == 0) { + _DAT_40004500 = _DAT_40004500 & 0xfffff7ff; + } + else { + _DAT_40004500 = _DAT_40004500 | 0x800; + } + return; + case 6: + if (iVar1 == 0) { + _DAT_40004200 = _DAT_40004200 & 0xfffff7ff; + _DAT_40004100 = _DAT_40004100 & 0xfffff7ff; + _DAT_40004000 = _DAT_40004000 & 0xfffff7ff; + _DAT_40004300 = _DAT_40004300 & 0xfffff7ff; + _DAT_40004500 = _DAT_40004500 & 0xfffff7ff; + } + else { + _DAT_40004200 = _DAT_40004200 | 0x800; + _DAT_40004100 = _DAT_40004100 | 0x800; + _DAT_40004000 = _DAT_40004000 | 0x800; + _DAT_40004300 = _DAT_40004300 | 0x800; + _DAT_40004500 = _DAT_40004500 | 0x800; + } + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void DMA_Enable(void) + +{ + _DAT_4000c030 = _DAT_4000c030 | 1; + return; +} + + + +void DMA_Channel_Enable(uint8_t ch) + +{ + undefined3 in_register_00002029; + uint *puVar1; + + puVar1 = (uint *)(CONCAT31(in_register_00002029,ch) * 0x100 + 0x4000c110); + *puVar1 = *puVar1 | 1; + return; +} + + + +void DMA_LLI_Init(uint8_t ch,DMA_LLI_Cfg_Type *lliCfg) + +{ + undefined3 in_register_00002029; + uint *puVar1; + + puVar1 = (uint *)(CONCAT31(in_register_00002029,ch) * 0x100 + 0x4000c110); + *puVar1 = (uint)lliCfg->dir << 0xb | *puVar1 & 0xffffc001 | (uint)lliCfg->dstPeriph << 6 | + (uint)lliCfg->srcPeriph << 1; + return; +} + + + +void DMA_LLI_Update(uint8_t ch,uint32_t LLI) + +{ + undefined3 in_register_00002029; + + // WARNING: Treating indirect jump as call + BL602_MemCpy4((uint32_t *)(CONCAT31(in_register_00002029,ch) * 0x100 + 0x4000c100),(uint32_t *)LLI + ,4); + return; +} + + + +void DMA_IntMask(uint8_t ch,DMA_INT_Type intType,BL_Mask_Type intMask) + +{ + undefined3 in_register_00002029; + int iVar1; + uint *puVar2; + undefined3 in_register_0000202d; + int iVar3; + undefined3 in_register_00002031; + int iVar4; + uint uVar5; + uint uVar6; + + iVar4 = CONCAT31(in_register_00002031,intMask); + iVar3 = CONCAT31(in_register_0000202d,intType); + iVar1 = CONCAT31(in_register_00002029,ch) * 0x100; + if (iVar3 == 1) { + puVar2 = (uint *)(iVar1 + 0x4000c110); + uVar6 = *puVar2; + if (iVar4 == 0) { + uVar6 = uVar6 & 0xffffbfff; + goto LAB_23053e98; + } + uVar5 = 0x4000; + } + else { + if (iVar3 == 0) { + uVar6 = *(uint *)(iVar1 + 0x4000c110); + iVar3 = -0x8000; + if (iVar4 != 0) { + uVar5 = 0x8000; + goto LAB_23053e78; + } + } + else { + if (iVar3 != 2) { + return; + } + uVar6 = *(uint *)(iVar1 + 0x4000c110); + if (iVar4 != 0) { + uVar5 = 0xc000; +LAB_23053e78: + puVar2 = (uint *)(iVar1 + 0x4000c10c); + *(uint *)(iVar1 + 0x4000c110) = uVar6 | uVar5; + uVar6 = *puVar2 & 0x7fffffff; + goto LAB_23053e98; + } + iVar3 = -0xc000; + } + puVar2 = (uint *)(iVar1 + 0x4000c10c); + *(uint *)(iVar1 + 0x4000c110) = uVar6 & iVar3 - 1U; + uVar6 = *puVar2; + uVar5 = 0x80000000; + } + uVar6 = uVar6 | uVar5; +LAB_23053e98: + *puVar2 = uVar6; + return; +} + + + +void Default_Handler(void) + +{ + bflb_platform_printf("Default_Handler\r\n"); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Set_UART_CLK(uint8_t enable,HBN_UART_CLK_Type clkSel,uint8_t div) + +{ + undefined3 in_register_00002029; + undefined3 in_register_00002031; + uint uVar1; + + _DAT_40000008 = CONCAT31(in_register_00002031,div) | _DAT_40000008 & 0xffffffe8; + HBN_Set_UART_CLK_Sel(clkSel); + uVar1 = _DAT_40000008 | 0x10; + if (CONCAT31(in_register_00002029,enable) == 0) { + uVar1 = _DAT_40000008 & 0xffffffef; + } + _DAT_40000008 = uVar1; + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Set_ADC_CLK(uint8_t enable,GLB_ADC_CLK_Type clkSel,uint8_t div) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + uint uVar1; + + uVar1 = (CONCAT31(in_register_00002031,div) | _DAT_400000a4 & 0xfffffec0) & 0xffffff7f | + CONCAT31(in_register_0000202d,clkSel) << 7; + _DAT_400000a4 = uVar1 & 0xfffffeff; + if (CONCAT31(in_register_00002029,enable) != 0) { + _DAT_400000a4 = uVar1 | 0x100; + } + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_UART_Fun_Sel(GLB_UART_SIG_Type sig,GLB_UART_SIG_FUN_Type fun) + +{ + undefined3 in_register_0000202d; + + _DAT_400000c0 = + ~(0xf << (((uint)sig & 7) << 2)) & _DAT_400000c0 | + CONCAT31(in_register_0000202d,fun) << (((uint)sig & 7) << 2); + return SUCCESS; +} + + + +BL_Err_Type GLB_GPIO_Write(GLB_GPIO_Type gpioPin,uint32_t val) + +{ + undefined3 in_register_00002029; + uint uVar1; + uint uVar2; + uint *puVar3; + + puVar3 = (uint *)((CONCAT31(in_register_00002029,gpioPin) >> 5) * 4 + 0x40000188); + uVar2 = *puVar3; + uVar1 = 1 << ((uint)gpioPin & 0x1f); + if (val == 0) { + uVar1 = ~uVar1 & uVar2; + } + else { + uVar1 = uVar1 | uVar2; + } + *puVar3 = uVar1; + return SUCCESS; +} + + + +uint32_t GLB_GPIO_Read(GLB_GPIO_Type gpioPin) + +{ + undefined3 in_register_00002029; + + return (uint)((1 << ((uint)gpioPin & 0x1f) & + *(uint *)((CONCAT31(in_register_00002029,gpioPin) >> 5) * 4 + 0x40000180)) != 0); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Set_UART_CLK_Sel(HBN_UART_CLK_Type clkSel) + +{ + undefined3 in_register_00002029; + + _DAT_4000f030 = CONCAT31(in_register_00002029,clkSel) << 2 | _DAT_4000f030 & 0xfffffffb; + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Get_RTC_Timer_Val(uint32_t *valLow,uint32_t *valHigh) + +{ + _DAT_4000f010 = _DAT_4000f010 & 0x7fffffff; + *valLow = _DAT_4000f00c; + *valHigh = _DAT_4000f010 & 0xff; + return SUCCESS; +} + + + +void TIMER_SetCompValue(TIMER_Chan_Type timerCh,TIMER_Comp_ID_Type cmpNo,uint32_t val) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + + *(uint32_t *) + ((CONCAT31(in_register_00002029,timerCh) * 3 + CONCAT31(in_register_0000202d,cmpNo)) * 4 + + 0x4000a510) = val; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void TIMER_SetCountMode(TIMER_Chan_Type timerCh,TIMER_CountMode_Type countMode) + +{ + undefined3 in_register_0000202d; + + _DAT_4000a588 = + ~(1 << ((uint)timerCh + 1 & 0x1f)) & _DAT_4000a588 | + CONCAT31(in_register_0000202d,countMode) << ((uint)timerCh + 1 & 0x1f); + return; +} + + + +void TIMER_ClearIntStatus(TIMER_Chan_Type timerCh,TIMER_Comp_ID_Type cmpNo) + +{ + undefined3 in_register_00002029; + uint *puVar1; + + puVar1 = (uint *)(CONCAT31(in_register_00002029,timerCh) * 4 + 0x4000a578); + *puVar1 = 1 << ((uint)cmpNo & 0x1f) | *puVar1; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type TIMER_Init(TIMER_CFG_Type *timerCfg) + +{ + TIMER_Chan_Type timerCh; + uint uVar1; + uint uVar2; + + timerCh = timerCfg->timerCh; + if (timerCh == TIMER_CH0) { + _DAT_4000a500 = _DAT_4000a500 & 0xfffffff3; + uVar1 = (uint)timerCfg->clkSrc << 2; + } + else { + _DAT_4000a500 = _DAT_4000a500 & 0xffffff9f; + uVar1 = (uint)timerCfg->clkSrc << 5; + } + _DAT_4000a500 = uVar1 | _DAT_4000a500; + if (timerCh == TIMER_CH0) { + uVar1 = 0xffff00ff; + uVar2 = (uint)timerCfg->clockDivision << 8; + } + else { + uVar1 = 0xff00ffff; + uVar2 = (uint)timerCfg->clockDivision << 0x10; + } + _DAT_4000a5bc = uVar2 | uVar1 & _DAT_4000a5bc; + TIMER_SetCountMode(timerCh,timerCfg->countMode); + *(uint *)((uint)timerCh * 4 + 0x4000a55c) = (uint)timerCfg->plTrigSrc; + if (timerCfg->countMode == TIMER_COUNT_PRELOAD) { + *(uint32_t *)((uint)timerCh * 4 + 0x4000a550) = timerCfg->preLoadVal; + } + TIMER_SetCompValue(timerCh,TIMER_COMP_ID_0,timerCfg->matchVal0); + TIMER_SetCompValue(timerCh,TIMER_COMP_ID_1,timerCfg->matchVal1); + TIMER_SetCompValue(timerCh,TIMER_COMP_ID_2,timerCfg->matchVal2); + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void TIMER_Enable(TIMER_Chan_Type timerCh) + +{ + _DAT_4000a584 = 1 << ((uint)timerCh + 1 & 0x1f) | _DAT_4000a584; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void TIMER_Disable(TIMER_Chan_Type timerCh) + +{ + _DAT_4000a584 = ~(1 << ((uint)timerCh + 1 & 0x1f)) & _DAT_4000a584; + return; +} + + + +void TIMER_IntMask(TIMER_Chan_Type timerCh,TIMER_INT_Type intType,BL_Mask_Type intMask) + +{ + undefined3 in_register_00002029; + uint *puVar1; + undefined3 in_register_0000202d; + int iVar2; + undefined3 in_register_00002031; + int iVar3; + uint uVar4; + + iVar3 = CONCAT31(in_register_00002031,intMask); + iVar2 = CONCAT31(in_register_0000202d,intType); + puVar1 = (uint *)(CONCAT31(in_register_00002029,timerCh) * 4 + 0x4000a544); + uVar4 = *puVar1; + if (iVar2 == 1) { + if (iVar3 == 0) { + uVar4 = uVar4 | 2; + } + else { + uVar4 = uVar4 & 0xfffffffd; + } + goto LAB_2305416e; + } + if (iVar2 == 0) { + if (iVar3 == 0) { + uVar4 = uVar4 | 1; + } + else { + uVar4 = uVar4 & 0xfffffffe; + } + goto LAB_2305416e; + } + if (iVar2 == 2) { + if (iVar3 != 0) goto LAB_230541a6; + } + else { + if (iVar2 != 3) { + return; + } + if (iVar3 != 0) { + *puVar1 = uVar4 & 0xfffffffe; + *puVar1 = uVar4 & 0xfffffffd; +LAB_230541a6: + uVar4 = uVar4 & 0xfffffffb; + goto LAB_2305416e; + } + *puVar1 = uVar4 | 1; + *puVar1 = uVar4 | 2; + } + uVar4 = uVar4 | 4; +LAB_2305416e: + *puVar1 = uVar4; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void WDT_Set_Clock(TIMER_ClkSrc_Type clkSrc,uint8_t div) + +{ + undefined3 in_register_00002029; + + _DAT_4000a500 = CONCAT31(in_register_00002029,clkSrc) << 8 | _DAT_4000a500 & 0xfffffcff; + _DAT_4000a5bc = _DAT_4000a5bc & 0xffffff | (uint)div << 0x18; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void WDT_SetCompValue(uint16_t val) + +{ + undefined2 in_register_0000202a; + + _DAT_4000a568 = CONCAT22(in_register_0000202a,val); + _DAT_4000a59c = _DAT_4000a59c & 0xffff0000 | 0xbaba; + _DAT_4000a5a0 = _DAT_4000a5a0 & 0xffff0000 | 0xeb10; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void WDT_ResetCounterValue(void) + +{ + _DAT_4000a598 = _DAT_4000a598 | 1; + _DAT_4000a59c = _DAT_4000a59c & 0xffff0000 | 0xbaba; + _DAT_4000a5a0 = _DAT_4000a5a0 & 0xffff0000 | 0xeb10; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void WDT_Enable(void) + +{ + _DAT_4000a564 = _DAT_4000a564 | 1; + _DAT_4000a59c = _DAT_4000a59c & 0xffff0000 | 0xbaba; + _DAT_4000a5a0 = _DAT_4000a5a0 & 0xffff0000 | 0xeb10; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void WDT_Disable(void) + +{ + _DAT_4000a564 = _DAT_4000a564 & 0xfffffffe; + _DAT_4000a59c = _DAT_4000a59c & 0xffff0000 | 0xbaba; + _DAT_4000a5a0 = _DAT_4000a5a0 & 0xffff0000 | 0xeb10; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void WDT_IntMask(WDT_INT_Type intType,BL_Mask_Type intMask) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + + if (CONCAT31(in_register_00002029,intType) == 0) { + if (CONCAT31(in_register_0000202d,intMask) == 0) { + _DAT_4000a564 = _DAT_4000a564 & 0xfffffffd; + } + else { + _DAT_4000a564 = _DAT_4000a564 | 2; + } + } + _DAT_4000a59c = _DAT_4000a59c & 0xffff0000 | 0xbaba; + _DAT_4000a5a0 = _DAT_4000a5a0 & 0xffff0000 | 0xeb10; + return; +} + + + +uint32_t EF_Ctrl_Get_Byte_Zero_Cnt(uint8_t val) + +{ + undefined3 in_register_00002029; + uint32_t uVar1; + uint uVar2; + + uVar2 = 0; + uVar1 = 0; + do { + if ((CONCAT31(in_register_00002029,val) >> (uVar2 & 0x1f) & 1U) == 0) { + uVar1 = uVar1 + 1; + } + uVar2 = uVar2 + 1; + } while (uVar2 != 8); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type EF_Ctrl_Read_MAC_Address(uint8_t *mac) + +{ + uint8_t uVar1; + undefined4 uVar2; + uint uVar3; + BL_Err_Type BVar4; + uint32_t uVar5; + uint8_t *puVar6; + uint8_t *puVar7; + uint8_t *puVar8; + int iVar9; + uint uVar10; + + EF_Ctrl_Load_Efuse_R0(); + uVar2 = _DAT_40007014; + uVar10 = 0; + iVar9 = 0; + *mac = (uint8_t)_DAT_40007014; + mac[1] = (uint8_t)((uint)uVar2 >> 8); + mac[3] = (uint8_t)((uint)uVar2 >> 0x18); + mac[2] = (uint8_t)((uint)uVar2 >> 0x10); + uVar3 = _DAT_40007018; + mac[4] = (uint8_t)_DAT_40007018; + mac[5] = (uint8_t)(uVar3 >> 8); + do { + puVar7 = mac + iVar9; + iVar9 = iVar9 + 1; + uVar5 = EF_Ctrl_Get_Byte_Zero_Cnt(*puVar7); + uVar10 = uVar10 + uVar5; + } while (iVar9 != 6); + BVar4 = ERROR; + if (((uVar3 >> 0x10 ^ uVar10) & 0x3f) == 0) { + puVar6 = mac + 2; + puVar7 = mac + 5; + do { + uVar1 = *mac; + puVar8 = puVar7 + -1; + *mac = *puVar7; + *puVar7 = uVar1; + mac = mac + 1; + puVar7 = puVar8; + } while (puVar8 != puVar6); + BVar4 = SUCCESS; + } + return BVar4; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t EF_Ctrl_Is_MAC_Address_Slot_Empty(uint8_t slot,uint8_t reload) + +{ + undefined3 in_register_00002029; + int iVar1; + undefined3 in_register_0000202d; + int iVar2; + uint uVar3; + uint uVar4; + + iVar2 = CONCAT31(in_register_0000202d,reload); + iVar1 = CONCAT31(in_register_00002029,slot); + if (iVar1 == 0) { + EF_Ctrl_Sw_AHB_Clk_0(); + uVar3 = _DAT_40007014; + uVar4 = _DAT_40007018; + if (iVar2 != 0) { + EF_Ctrl_Load_Efuse_R0(); + uVar3 = _DAT_40007014; + uVar4 = _DAT_40007018; + } + } + else { + if (iVar1 == 1) { + EF_Ctrl_Sw_AHB_Clk_0(); + uVar3 = _DAT_4000706c; + uVar4 = _DAT_40007070; + if (iVar2 != 0) { + EF_Ctrl_Load_Efuse_R0(); + uVar3 = _DAT_4000706c; + uVar4 = _DAT_40007070; + } + } + else { + if (iVar1 != 2) { + return '\0'; + } + EF_Ctrl_Sw_AHB_Clk_0(); + uVar3 = _DAT_40007004; + uVar4 = _DAT_40007008; + if (iVar2 != 0) { + EF_Ctrl_Load_Efuse_R0(); + uVar3 = _DAT_40007004; + uVar4 = _DAT_40007008; + } + } + } + if ((uVar4 & 0x3fffff | uVar3) != 0) { + return '\0'; + } + return '\x01'; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type EF_Ctrl_Read_MAC_Address_Opt(uint8_t slot,uint8_t *mac,uint8_t reload) + +{ + uint8_t uVar1; + uint uVar2; + BL_Err_Type BVar3; + undefined3 in_register_00002029; + uint32_t uVar4; + undefined3 in_register_00002031; + uint8_t *puVar5; + undefined4 uVar6; + uint8_t *puVar7; + uint8_t *puVar8; + int iVar9; + uint uVar10; + + uVar10 = CONCAT31(in_register_00002029,slot); + if (2 < uVar10) { + return ERROR; + } + if (CONCAT31(in_register_00002031,reload) == 0) { +LAB_23054456: + uVar6 = _DAT_40007014; + if ((uVar10 == 0) || (uVar6 = _DAT_4000706c, uVar10 == 1)) goto LAB_2305445e; + } + else { + if (uVar10 != 2) { + EF_Ctrl_Load_Efuse_R0(); + goto LAB_23054456; + } + EF_Ctrl_Load_Efuse_R0(); + } + uVar6 = _DAT_40007004; +LAB_2305445e: + *mac = (uint8_t)uVar6; + mac[1] = (uint8_t)((uint)uVar6 >> 8); + mac[2] = (uint8_t)((uint)uVar6 >> 0x10); + mac[3] = (uint8_t)((uint)uVar6 >> 0x18); + uVar2 = _DAT_40007018; + if ((uVar10 != 0) && (uVar2 = _DAT_40007008, uVar10 == 1)) { + uVar2 = _DAT_40007070; + } + mac[4] = (uint8_t)uVar2; + mac[5] = (uint8_t)(uVar2 >> 8); + uVar10 = 0; + iVar9 = 0; + do { + puVar7 = mac + iVar9; + iVar9 = iVar9 + 1; + uVar4 = EF_Ctrl_Get_Byte_Zero_Cnt(*puVar7); + uVar10 = uVar10 + uVar4; + } while (iVar9 != 6); + BVar3 = ERROR; + if (((uVar2 >> 0x10 ^ uVar10) & 0x3f) == 0) { + puVar5 = mac + 2; + puVar7 = mac + 5; + do { + uVar1 = *mac; + puVar8 = puVar7 + -1; + *mac = *puVar7; + *puVar7 = uVar1; + mac = mac + 1; + puVar7 = puVar8; + } while (puVar5 != puVar8); + BVar3 = SUCCESS; + } + return BVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint EF_Ctrl_Is_CapCode_Slot_Empty(int param_1,int param_2) + +{ + uint uVar1; + + EF_Ctrl_Sw_AHB_Clk_0(); + if (param_2 != 0) { + EF_Ctrl_Load_Efuse_R0(); + } + if (param_1 == 0) { + uVar1 = _DAT_4000700c >> 2; + } + else { + uVar1 = _DAT_40007070; + if ((param_1 != 1) && (uVar1 = _DAT_40007008, param_1 != 2)) { + return 0; + } + uVar1 = uVar1 >> 0x16; + } + return (uint)((uVar1 & 0xff) == 0); +} + + + +// WARNING: Variable defined which should be unmapped: tmp +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type EF_Ctrl_Read_CapCode_Opt(uint8_t slot,uint8_t *code,uint8_t reload) + +{ + uint8_t uVar1; + undefined3 in_register_00002029; + uint uVar2; + undefined3 extraout_var; + undefined3 in_register_00002031; + uint uVar3; + uint32_t tmp; + + uVar2 = CONCAT31(in_register_00002029,slot); + if (2 < uVar2) { + return ERROR; + } + EF_Ctrl_Sw_AHB_Clk_0(); + if (CONCAT31(in_register_00002031,reload) != 0) { + EF_Ctrl_Load_Efuse_R0(); + } + if (uVar2 == 0) { + uVar3 = _DAT_4000700c >> 2; + } + else { + uVar3 = _DAT_40007008; + if (uVar2 == 1) { + uVar3 = _DAT_40007070; + } + uVar3 = uVar3 >> 0x16; + } + if ((uVar3 & 0x80) != 0) { + uVar1 = EF_Ctrl_Get_Trim_Parity(uVar3 & 0x3f,'\x06'); + if ((uVar3 >> 6 & 1) == CONCAT31(extraout_var,uVar1)) { + *code = (uint8_t)(uVar3 & 0x3f); + return SUCCESS; + } + } + return ERROR; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t EF_Ctrl_Is_PowerOffset_Slot_Empty(uint8_t slot,uint8_t reload) + +{ + byte bVar1; + undefined3 in_register_00002029; + int iVar2; + undefined3 in_register_0000202d; + byte bVar3; + uint uVar4; + + iVar2 = CONCAT31(in_register_00002029,slot); + EF_Ctrl_Sw_AHB_Clk_0(); + if (CONCAT31(in_register_0000202d,reload) != 0) { + EF_Ctrl_Load_Efuse_R0(); + } + if (iVar2 == 0) { + bVar3 = 1; + uVar4 = _DAT_40007078 >> 0xf; + } + else { + if (iVar2 == 1) { + bVar3 = (byte)_DAT_4000700c; + uVar4 = _DAT_40007074 & 0xffff; + } + else { + if (iVar2 != 2) { + return '\0'; + } + uVar4 = _DAT_40007074 >> 0x10; + bVar3 = (byte)(_DAT_4000700c >> 1); + } + bVar3 = ~bVar3 & 1; + } + bVar1 = 0; + if (uVar4 == 0) { + bVar1 = bVar3; + } + return (uint8_t)bVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type EF_Ctrl_Read_PowerOffset_Opt(uint8_t slot,int8_t *pwrOffset,uint8_t reload) + +{ + uint uVar1; + int iVar2; + uint32_t val; + uint8_t uVar3; + undefined3 in_register_00002029; + undefined3 extraout_var; + uint32_t uVar4; + undefined3 in_register_00002031; + byte bVar5; + uint uVar6; + undefined4 uVar7; + + iVar2 = CONCAT31(in_register_00002029,slot); + uVar7 = EF_Ctrl_Sw_AHB_Clk_0(); + if (CONCAT31(in_register_00002031,reload) != 0) { + EF_Ctrl_Load_Efuse_R0(uVar7); + } + if (iVar2 == 0) { + val = (_DAT_40007078 << 1) >> 0x11; + uVar1 = _DAT_40007078 >> 0x1f; + uVar6 = _DAT_40007078 >> 0xf; + } + else { + if (iVar2 == 1) { + val = _DAT_40007074 & 0x7fff; + uVar1 = _DAT_40007074 >> 0xf & 1; + uVar6 = _DAT_4000700c; + } + else { + if (iVar2 != 2) { + return ERROR; + } + val = (_DAT_40007074 << 1) >> 0x11; + uVar1 = _DAT_40007074 >> 0x1f; + uVar6 = _DAT_4000700c >> 1; + } + } + if (((uVar6 & 1) != 0) && + (uVar3 = EF_Ctrl_Get_Trim_Parity(val,'\x0f'), CONCAT31(extraout_var,uVar3) == uVar1)) { + iVar2 = 0; + do { + uVar4 = val; + __lshrdi3(val); + bVar5 = (byte)uVar4 & 0x1f; + if ((uVar4 & 0x10) != 0) { + bVar5 = bVar5 - 0x20; + } + pwrOffset[iVar2] = bVar5; + iVar2 = iVar2 + 1; + } while (iVar2 != 3); + return SUCCESS; + } + return ERROR; +} + + + +int8_t mfg_media_read_xtal_capcode(uint8_t *capcode,uint8_t reload) + +{ + int8_t iVar1; + + if (rf_para_on_flash != '\0') { + iVar1 = mfg_flash_read_xtal_capcode(capcode,reload); + return iVar1; + } + iVar1 = mfg_efuse_read_xtal_capcode(capcode,reload); + return iVar1; +} + + + +int8_t mfg_media_read_poweroffset(int8_t *pwrOffset,uint8_t reload) + +{ + int8_t iVar1; + + if (rf_para_on_flash != '\0') { + iVar1 = mfg_flash_read_poweroffset(pwrOffset,reload); + return iVar1; + } + iVar1 = mfg_efuse_read_poweroffset(pwrOffset,reload); + return iVar1; +} + + + +int8_t mfg_media_read_macaddr(uint8_t *mac,uint8_t reload) + +{ + int8_t iVar1; + + if (rf_para_on_flash != '\0') { + iVar1 = mfg_flash_read_macaddr(mac,reload); + return iVar1; + } + iVar1 = mfg_efuse_read_macaddr(mac,reload); + return iVar1; +} + + + +void bflb_platform_usart_dbg_send(uint8_t *data,uint32_t len) + +{ + UART_SendData(UART0_ID,data,len); + return; +} + + + +void bflb_platform_printf(char *fmt,...) + +{ + char print_buf [128]; + size_t len; + undefined4 in_a1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list ap; + undefined4 uStack28; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + if (uart_dbg_disable == '\0') { + uStack28 = in_a1; + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + vsnprintf((char *)&ram0x42016b80,0x7f,fmt,&uStack28); + len = strlen((char *)0x42016b80); + bflb_platform_usart_dbg_send((uint8_t *)0x42016b80,len); + } + return; +} + + + +// WARNING: Control flow encountered bad instruction data + +void Default_Handler_Stub(void) + +{ + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +int8_t mfg_efuse_read_xtal_capcode(uint8_t *capcode,uint8_t reload) + +{ + uint8_t bclkDiv; + uint8_t hclkDiv; + BL_Err_Type BVar1; + int iVar2; + undefined3 extraout_var; + undefined3 in_register_0000202d; + undefined4 uVar3; + + uVar3 = CONCAT31(in_register_0000202d,reload); + bclkDiv = GLB_Get_BCLK_Div(); + hclkDiv = GLB_Get_HCLK_Div(); + HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_XTAL); + if ((rf_cal_slots < 3) || (iVar2 = EF_Ctrl_Is_CapCode_Slot_Empty(2,uVar3), iVar2 != 0)) { + if ((rf_cal_slots < 2) || (iVar2 = EF_Ctrl_Is_CapCode_Slot_Empty(1,uVar3), iVar2 != 0)) { + if ((rf_cal_slots == '\0') || (iVar2 = EF_Ctrl_Is_CapCode_Slot_Empty(0,uVar3), iVar2 != 0)) { + printf("No written slot found\r\n"); + iVar2 = 1; + goto LAB_230548ee; + } + } + else { + iVar2 = 1; + } + } + else { + iVar2 = 2; + } + printf("Read slot:%d\r\n",iVar2); + BVar1 = EF_Ctrl_Read_CapCode_Opt((uint8_t)iVar2,capcode,reload); + iVar2 = CONCAT31(extraout_var,BVar1); +LAB_230548ee: + GLB_Set_System_CLK_Div(hclkDiv,bclkDiv); + HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_PLL); + return (int8_t)-(iVar2 != 0); +} + + + +int8_t mfg_efuse_read_poweroffset(int8_t *pwrOffset,uint8_t reload) + +{ + int iVar1; + uint8_t bclkDiv; + uint8_t hclkDiv; + uint8_t uVar2; + BL_Err_Type BVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + int iVar4; + int iVar5; + int8_t iStack36; + char cStack35; + char cStack34; + int8_t pwrOffsetTmp [3]; + + bclkDiv = GLB_Get_BCLK_Div(); + hclkDiv = GLB_Get_HCLK_Div(); + HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_XTAL); + if ((rf_cal_slots < 3) || + (uVar2 = EF_Ctrl_Is_PowerOffset_Slot_Empty('\x02',reload), CONCAT31(extraout_var_00,uVar2) != 0 + )) { + if ((rf_cal_slots < 2) || + (uVar2 = EF_Ctrl_Is_PowerOffset_Slot_Empty('\x01',reload), CONCAT31(extraout_var,uVar2) != 0) + ) { + if (rf_cal_slots != '\0') { + uVar2 = EF_Ctrl_Is_PowerOffset_Slot_Empty('\0',reload); + iVar1 = CONCAT31(extraout_var_01,uVar2); + if (iVar1 == 0) goto LAB_230549a8; + } + printf("No written slot found\r\n"); + iVar1 = 1; + goto LAB_23054aca; + } + iVar1 = 1; + } + else { + iVar1 = 2; + } +LAB_230549a8: + printf("Read slot:%d\r\n",iVar1); + BVar3 = EF_Ctrl_Read_PowerOffset_Opt((uint8_t)iVar1,&iStack36,reload); + iVar1 = CONCAT31(extraout_var_02,BVar3); + memset(pwrOffset,0,0xe); + *pwrOffset = iStack36; + pwrOffset[6] = cStack35; + pwrOffset[0xc] = cStack34; + iVar4 = (((int)cStack35 - (int)iStack36) * 100) / 6; + pwrOffset[2] = (char)((iVar4 + 0x19) / 0x32) + iStack36; + pwrOffset[3] = (char)((iVar4 * 3 + 0x32) / 100) + iStack36; + pwrOffset[4] = (char)((iVar4 * 4 + 0x32) / 100) + iStack36; + pwrOffset[1] = (char)((iVar4 + 0x32) / 100) + iStack36; + iVar5 = (((int)cStack34 - (int)cStack35) * 100) / 6; + pwrOffset[5] = (char)((iVar4 * 5 + 0x32) / 100) + iStack36; + pwrOffset[8] = (char)((iVar5 + 0x19) / 0x32) + cStack35; + pwrOffset[0xb] = (char)((iVar5 * 5 + 0x32) / 100) + cStack35; + pwrOffset[9] = (char)((iVar5 * 3 + 0x32) / 100) + cStack35; + pwrOffset[7] = (char)((iVar5 + 0x32) / 100) + cStack35; + pwrOffset[10] = (char)((iVar5 * 4 + 0x32) / 100) + cStack35; + pwrOffset[0xd] = (char)((iVar5 * 7 + 0x32) / 100) + cStack35; +LAB_23054aca: + GLB_Set_System_CLK_Div(hclkDiv,bclkDiv); + HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_PLL); + return (int8_t)-(iVar1 != 0); +} + + + +int8_t mfg_efuse_read_macaddr(uint8_t *mac,uint8_t reload) + +{ + int iVar1; + uint8_t bclkDiv; + uint8_t hclkDiv; + uint8_t uVar2; + BL_Err_Type BVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + + bclkDiv = GLB_Get_BCLK_Div(); + hclkDiv = GLB_Get_HCLK_Div(); + HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_XTAL); + if ((rf_cal_slots < 3) || + (uVar2 = EF_Ctrl_Is_MAC_Address_Slot_Empty('\x02',reload), CONCAT31(extraout_var_00,uVar2) != 0 + )) { + if ((rf_cal_slots < 2) || + (uVar2 = EF_Ctrl_Is_MAC_Address_Slot_Empty('\x01',reload), CONCAT31(extraout_var,uVar2) != 0) + ) { + if (rf_cal_slots != '\0') { + uVar2 = EF_Ctrl_Is_MAC_Address_Slot_Empty('\0',reload); + iVar1 = CONCAT31(extraout_var_01,uVar2); + if (iVar1 == 0) goto LAB_23054b82; + } + printf("No written slot found\r\n"); + iVar1 = 1; + goto LAB_23054b9c; + } + iVar1 = 1; + } + else { + iVar1 = 2; + } +LAB_23054b82: + printf("Read slot:%d\r\n",iVar1); + BVar3 = EF_Ctrl_Read_MAC_Address_Opt((uint8_t)iVar1,mac,reload); + iVar1 = CONCAT31(extraout_var_02,BVar3); +LAB_23054b9c: + GLB_Set_System_CLK_Div(hclkDiv,bclkDiv); + HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_PLL); + return (int8_t)-(iVar1 != 0); +} + + +/* +Unable to decompile 'mfg_flash_read' +Cause: Exception while decompiling 23054bce: Decompiler process died + +*/ + + +int8_t mfg_flash_read_xtal_capcode(uint8_t *capcode,uint8_t reload) + +{ + uint32_t uVar1; + int8_t iVar2; + undefined3 extraout_var; + uint32_t uVar3; + undefined3 in_register_0000202d; + + if ((((CONCAT31(in_register_0000202d,reload) == 0) || + (iVar2 = mfg_flash_read(), CONCAT31(extraout_var,iVar2) == 0)) && + (uVar1 = rf_para.crc32, rf_para.magic == 0x41)) && + ((uVar3 = BFLB_Soft_CRC32(&rf_para.capcode_valid,0x10), uVar1 == uVar3 && + (rf_para.capcode_valid == 'Z')))) { + iVar2 = '\0'; + *capcode = rf_para.capcode; + } + else { + iVar2 = -1; + } + return iVar2; +} + + + +int8_t mfg_flash_read_poweroffset(int8_t *pwrOffset,uint8_t reload) + +{ + int8_t iVar1; + int8_t iVar2; + uint32_t uVar3; + int8_t iVar4; + undefined3 extraout_var; + uint32_t uVar5; + undefined3 in_register_0000202d; + int iVar6; + int iVar7; + int iVar8; + + if ((((CONCAT31(in_register_0000202d,reload) == 0) || + (iVar4 = mfg_flash_read(), CONCAT31(extraout_var,iVar4) == 0)) && + (uVar3 = rf_para.crc32, rf_para.magic == 0x41)) && + ((uVar5 = BFLB_Soft_CRC32(&rf_para.capcode_valid,0x10), uVar3 == uVar5 && + (rf_para.poweroffset_valid == 'Z')))) { + memset(pwrOffset,0,0xe); + iVar2 = rf_para.poweroffset[2]; + iVar1 = rf_para.poweroffset[1]; + iVar4 = rf_para.poweroffset[0]; + iVar8 = (int)rf_para.poweroffset[1]; + iVar6 = (int)rf_para.poweroffset[0]; + iVar7 = (int)rf_para.poweroffset[2]; + *pwrOffset = rf_para.poweroffset[0]; + pwrOffset[6] = iVar1; + pwrOffset[0xc] = iVar2; + iVar6 = ((iVar8 - iVar6) * 100) / 6; + pwrOffset[2] = (char)((iVar6 + 0x19) / 0x32) + iVar4; + pwrOffset[3] = (char)((iVar6 * 3 + 0x32) / 100) + iVar4; + pwrOffset[4] = (char)((iVar6 * 4 + 0x32) / 100) + iVar4; + pwrOffset[1] = (char)((iVar6 + 0x32) / 100) + iVar4; + iVar7 = ((iVar7 - iVar8) * 100) / 6; + pwrOffset[5] = iVar4 + (char)((iVar6 * 5 + 0x32) / 100); + pwrOffset[8] = (char)((iVar7 + 0x19) / 0x32) + iVar1; + pwrOffset[10] = (char)((iVar7 * 4 + 0x32) / 100) + iVar1; + pwrOffset[7] = (char)((iVar7 + 0x32) / 100) + iVar1; + pwrOffset[9] = (char)((iVar7 * 3 + 0x32) / 100) + iVar1; + pwrOffset[0xb] = (char)((iVar7 * 5 + 0x32) / 100) + iVar1; + iVar4 = '\0'; + pwrOffset[0xd] = (char)((iVar7 * 7 + 0x32) / 100) + iVar1; + } + else { + iVar4 = -1; + } + return iVar4; +} + + + +int8_t mfg_flash_read_macaddr(uint8_t *mac,uint8_t reload) + +{ + uint32_t uVar1; + int8_t iVar2; + undefined3 extraout_var; + uint32_t uVar3; + undefined3 in_register_0000202d; + + if ((CONCAT31(in_register_0000202d,reload) == 0) || + (iVar2 = mfg_flash_read(), CONCAT31(extraout_var,iVar2) == 0)) { + uVar1 = rf_para.crc32; + if ((rf_para.magic == 0x41) && + ((uVar3 = BFLB_Soft_CRC32(&rf_para.capcode_valid,0x10), uVar1 == uVar3 && + (rf_para.mac_valid == 'Z')))) { + memcpy(mac,rf_para.mac,6); + return '\0'; + } + } + else { + printf("mfg_flash_read fail\r\n"); + } + return -1; +} + + + +void Bl_F(uchar *digest,uchar *digest1,char *password,uchar *ssid,int ssidlength,int iterations, + int count,uchar *output) + +{ + int iVar1; + size_t key_len; + byte *pbVar2; + uchar *puVar3; + byte *pbVar4; + int iVar5; + int iStack56; + int tmpLen; + uchar *pTemp; + + key_len = strlen(password); + iStack56 = ssidlength + 4; + tmpLen = (int)digest; + memcpy(digest,ssid,ssidlength); + puVar3 = digest + ssidlength; + *puVar3 = (uchar)((uint)count >> 0x18); + puVar3[1] = (uchar)((uint)count >> 0x10); + puVar3[2] = (uchar)((uint)count >> 8); + puVar3[3] = (uchar)count; + Bl_hmac_sha1((uchar **)&tmpLen,&iStack56,1,(uchar *)password,key_len,digest1,0x14); + memcpy(output,digest1,0x14); + iVar1 = 1; + tmpLen = (int)digest1; + while (iVar1 < iterations) { + iStack56 = 0x14; + Bl_hmac_sha1((uchar **)&tmpLen,&iStack56,1,(uchar *)password,key_len,digest,0x14); + memcpy(digest1,digest,0x14); + iVar5 = 0; + do { + pbVar2 = output + iVar5; + pbVar4 = digest + iVar5; + iVar5 = iVar5 + 1; + *pbVar2 = *pbVar4 ^ *pbVar2; + } while (iVar5 != 0x14); + iVar1 = iVar1 + 1; + } + return; +} + + + +int Bl_PasswordHash(char *password,uchar *ssid,int ssidlength,uchar *output) + +{ + size_t sVar1; + int iVar2; + uchar auStack88 [4]; + uchar digest1 [20]; + uchar digest [36]; + + sVar1 = strlen(password); + if (sVar1 < 0x40) { + iVar2 = -1; + if (ssidlength < 0x21) { + Bl_F(digest1 + 0x10,auStack88,password,ssid,ssidlength,0x1000,2,output); + memcpy(output + 0x14,output,0xc); + Bl_F(digest1 + 0x10,auStack88,password,ssid,ssidlength,0x1000,1,output); + iVar2 = 0; + } + } + else { + iVar2 = -1; + } + return iVar2; +} + + + +int bl60x_fw_password_hash(char *password,uchar *ssid,int ssidlength,uchar *output) + +{ + size_t sVar1; + int iVar2; + uchar auStack88 [20]; + uchar auStack68 [48]; + + sVar1 = strlen(password); + if (sVar1 < 0x40) { + iVar2 = -1; + if (ssidlength < 0x21) { + Bl_F(auStack68,auStack88,password,ssid,ssidlength,0x1000,2,output); + memcpy(output + 0x14,output,0xc); + Bl_F(auStack68,auStack88,password,ssid,ssidlength,0x1000,1,output); + iVar2 = 0; + } + } + else { + iVar2 = -1; + } + return iVar2; +} + + + +int bl_mtd_open(char *name,bl_mtd_handle_t *handle,uint flags) + +{ + char *__dest; + int iVar1; + uint32_t uStack40; + uint32_t addr; + uint32_t size; + + uStack40 = 0; + addr = 0; + __dest = (char *)pvPortMalloc(0x20); + if (__dest == (char *)0x0) { + iVar1 = -1; + } + else { + memset(__dest,0,0x20); + strncpy(__dest,name,0x10); + if ((flags & 1) == 0) { + if ((flags & 2) == 0) { + *(undefined4 *)(__dest + 0x1c) = 0; + } + else { + iVar1 = hal_boot2_partition_bus_addr_active(name,&uStack40,&addr); + if ((iVar1 != 0) || (uStack40 == 0)) { + printf("[MTD] [PART] [XIP] error when get %s partition %d\r\n",name,iVar1); + printf("[MTD] [PART] [XIP] Dead Loop. Reason: no Valid %s partition found\r\n",name); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + *(uint32_t *)(__dest + 0x1c) = uStack40; + } + iVar1 = hal_boot2_partition_addr_active(name,&uStack40,&addr); + if ((iVar1 != 0) || (uStack40 == 0)) { + printf("[MTD] [PART] [XIP] error when get %s partition %d\r\n",name,iVar1); + printf("[MTD] [PART] [XIP] Dead Loop. Reason: no Valid %s partition found\r\n",name); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + } + else { + if ((flags & 2) == 0) { + *(undefined4 *)(__dest + 0x1c) = 0; + } + else { + iVar1 = hal_boot2_partition_bus_addr_inactive(name,&uStack40,&addr); + if ((iVar1 != 0) || (uStack40 == 0)) { + printf("[MTD] [PART] [XIP] error when get %s partition %d\r\n",name,iVar1); + printf("[MTD] [PART] [XIP] Dead Loop. Reason: no Valid %s partition found\r\n",name); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + *(uint32_t *)(__dest + 0x1c) = uStack40; + } + iVar1 = hal_boot2_partition_addr_inactive(name,&uStack40,&addr); + if ((iVar1 != 0) || (uStack40 == 0)) { + printf("[MTD] [PART] [XIP] error when get %s partition %d\r\n",name,iVar1); + printf("[MTD] [PART] [XIP] Dead Loop. Reason: no Valid %s partition found\r\n",name); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + } + *(uint32_t *)(__dest + 0x14) = uStack40; + *(uint32_t *)(__dest + 0x18) = addr; + puts("[MTD] >>>>>> Hanlde info Dump >>>>>>\r\n"); + printf(" name %s\r\n",__dest); + printf(" id %d\r\n",*(undefined4 *)(__dest + 0x10)); + printf(" offset %p(%u)\r\n",*(undefined4 *)(__dest + 0x14)); + printf(" size %p(%uKbytes)\r\n",*(uint *)(__dest + 0x18),*(uint *)(__dest + 0x18) >> 10); + printf(" xip_addr %p\r\n",*(undefined4 *)(__dest + 0x1c)); + puts("[MTD] <<<<<< Hanlde info End <<<<<<\r\n"); + iVar1 = 0; + *(char **)handle = __dest; + } + return iVar1; +} + + + +int bl_mtd_close(bl_mtd_handle_t handle) + +{ + vPortFree(handle); + return 0; +} + + + +int bl_mtd_info(bl_mtd_handle_t handle,bl_mtd_info_t *info) + +{ + strcpy((char *)info,(char *)handle); + info->offset = *(uint *)((int)handle + 0x14); + info->size = *(uint *)((int)handle + 0x18); + info->xip_addr = *(void **)((int)handle + 0x1c); + return 0; +} + + + +int bl_mtd_erase(bl_mtd_handle_t handle,uint addr,uint size) + +{ + bl_flash_erase(*(int *)((int)handle + 0x14) + addr,size); + return 0; +} + + + +int bl_mtd_erase_all(bl_mtd_handle_t handle) + +{ + bl_flash_erase(*(uint32_t *)((int)handle + 0x14),*(int *)((int)handle + 0x18)); + return 0; +} + + + +int bl_mtd_write(bl_mtd_handle_t handle,uint addr,uint size,uint8_t *data) + +{ + uint32_t addr_00; + int iVar1; + TickType_t TVar2; + uint __n; + uint8_t auStack96 [4]; + uint8_t buf_tmp [64]; + + addr_00 = *(int *)((int)handle + 0x14) + addr; + iVar1 = bl_sys_isxipaddr((uint32_t)data); + if (iVar1 == 0) { + bl_flash_write(addr_00,data,size); + } + else { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] addr@%p is xip flash, size %d\r\n",TVar2,&DAT_23081ce8,"bl_mtd.c", + 0xc9,data,size); + while (size != 0) { + __n = size; + if (0x40 < size) { + __n = 0x40; + } + memcpy(auStack96,data,__n); + bl_flash_write(addr_00,auStack96,__n); + addr_00 = addr_00 + __n; + data = data + __n; + size = size - __n; + } + } + return 0; +} + + + +int bl_mtd_read(bl_mtd_handle_t handle,uint addr,uint size,uint8_t *data) + +{ + bl_flash_read(*(int *)((int)handle + 0x14) + addr,data,size); + return 0; +} + + + +int bloop_init(loop_ctx *loop) + +{ + loop_evt_handler_statistic *list; + loop_evt_handler_statistic *plVar1; + + memset(loop,0,0x4a0); + list = (loop_evt_handler_statistic *)loop->list; + do { + plVar1 = (loop_evt_handler_statistic *)&list->time_accumulated; + utils_list_init((utils_list *)list); + list = plVar1; + } while (plVar1 != loop->statistic); + *(utils_dlist_t **)&(loop->timer_dlist).next = &loop->timer_dlist; + *(utils_dlist_t **)&(loop->timer_dlist).prev = &loop->timer_dlist; + *(utils_dlist_t **)&(loop->timer_dued).next = &loop->timer_dued; + *(utils_dlist_t **)&(loop->timer_dued).prev = &loop->timer_dued; + printf("=== %d task inited\r\n",0x20); + return 0; +} + + + +int bloop_handler_register(loop_ctx *loop,loop_evt_handler *handler,int priority) + +{ + if (((uint)priority < 0x20) && ((&loop->looper + priority)[0x104] == (TaskHandle_t)0x0)) { + *(loop_evt_handler **)(&loop->looper + priority + 0x104) = handler; + return 0; + } + return -1; +} + + + +void bloop_timer_init(loop_timer *timer,int use_auto_free) + +{ + memset(timer,0,0x24); + *(loop_timer **)&(timer->dlist_item).prev = timer; + *(loop_timer **)&(timer->dlist_item).next = timer; + timer->flags = (use_auto_free != 0) << 1; + return; +} + + + +void bloop_timer_configure + (loop_timer *timer,uint delay_ms, + anon_subr_void_loop_ctx_ptr_loop_timer_ptr_void_ptr *cb,void *arg,int idx_task, + uint32_t evt_type_map) + +{ + TickType_t TVar1; + + TVar1 = xTaskGetTickCount(); + timer->time_added = TVar1; + timer->time_target = TVar1 + delay_ms; + *(anon_subr_void_loop_ctx_ptr_loop_timer_ptr_void_ptr **)&timer->cb = cb; + timer->arg = arg; + timer->idx_task = idx_task; + timer->evt_type_map = evt_type_map; + return; +} + + + +void bloop_timer_repeat_enable(loop_timer *timer) + +{ + timer->flags = timer->flags | 1; + return; +} + + + +void bloop_timer_repeat_reconfigure(loop_timer *timer) + +{ + uint uVar1; + uint uVar2; + TickType_t TVar3; + + uVar1 = timer->time_target; + uVar2 = timer->time_added; + TVar3 = xTaskGetTickCount(); + timer->time_target = (uVar1 - uVar2) + TVar3; + timer->time_added = TVar3; + return; +} + + + +void bloop_timer_register(loop_ctx *loop,loop_timer *timer) + +{ + utils_dlist_s *puVar1; + utils_dlist_s *puVar2; + utils_dlist_s *puVar3; + utils_dlist_s *puVar4; + utils_dlist_s *puVar5; + + puVar2 = (loop->timer_dlist).next; + puVar3 = (utils_dlist_s *)&loop->timer_dlist; + if (puVar3 == puVar2) { + (timer->dlist_item).next = puVar3; + (timer->dlist_item).prev = puVar3; + *(loop_timer **)&(loop->timer_dlist).next = timer; + *(loop_timer **)&(loop->timer_dlist).prev = timer; + return; + } + puVar1 = puVar2; + puVar5 = (utils_dlist_s *)0x0; + do { + puVar4 = puVar1; + if (puVar3 == puVar4) { +LAB_230553be: + puVar2 = puVar5->next; + (timer->dlist_item).prev = puVar5; + (timer->dlist_item).next = puVar2; + *(loop_timer **)&puVar5->next = timer; + *(loop_timer **)&puVar2->prev = timer; + return; + } + if ((int)(timer->time_target - (int)puVar4[2].prev) < 1) { + if (puVar5 == (utils_dlist_s *)0x0) { + (timer->dlist_item).next = puVar2; + (timer->dlist_item).prev = puVar3; + *(loop_timer **)&(loop->timer_dlist).next = timer; + *(loop_timer **)&puVar2->prev = timer; + return; + } + goto LAB_230553be; + } + puVar1 = puVar4->next; + puVar5 = puVar4; + } while( true ); +} + + + +void bloop_wait_startup(loop_ctx *loop) + +{ + while (loop->looper == (TaskHandle_t)0x0) { + vTaskDelay(1); + } + return; +} + + + +void bloop_evt_set_async(loop_ctx *loop,uint evt,uint32_t evt_map) + +{ + if (0x1f < evt) { + printf("[ASSERT] [ERR] %s:%d\r\n","bloop_base.c",0x15a); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + vTaskEnterCritical(); + loop->bitmap_evt_async = loop->bitmap_evt_async | 1 << (evt & 0x1f); + (&loop->looper + evt)[4] = (TaskHandle_t)((uint)(&loop->looper + evt)[4] | evt_map); + vTaskExitCritical(); + xTaskGenericNotify(loop->looper,0,eIncrement,(uint32_t *)0x0); + return; +} + + + +void bloop_evt_set_sync(loop_ctx *loop,uint evt,uint32_t evt_map) + +{ + if (0x1f < evt) { + printf("[ASSERT] [ERR] %s:%d\r\n","bloop_base.c",0x177); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + loop->bitmap_evt_sync = loop->bitmap_evt_sync | 1 << (evt & 0x1f); + (&loop->looper + evt)[4] = (TaskHandle_t)((uint)(&loop->looper + evt)[4] | evt_map); + return; +} + + + +void bloop_evt_unset_sync(loop_ctx *loop,uint evt) + +{ + if (0x1f < evt) { + printf("[ASSERT] [ERR] %s:%d\r\n","bloop_base.c",0x17f); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + loop->bitmap_evt_sync = ~(1 << (evt & 0x1f)) & loop->bitmap_evt_sync; + return; +} + + + +void bloop_run(loop_ctx *param_1) + +{ + loop_timer *plVar1; + utils_dlist_t *puVar2; + loop_timer *timer; + TaskHandle_t ptVar3; + TickType_t TVar4; + uint32_t uVar5; + uint32_t uVar6; + int iVar7; + int iVar8; + utils_list_hdr *puVar9; + utils_dlist_s *xTicksToWait; + uint evt; + TaskHandle_t ptVar10; + utils_dlist_s *puVar11; + utils_dlist_s *puVar12; + TaskHandle_t *pptVar13; + loop_timer *plVar14; + utils_dlist_t *puVar15; + + ptVar3 = xTaskGetCurrentTaskHandle(); + param_1->looper = ptVar3; +LAB_230554f2: + do { + puVar15 = ¶m_1->timer_dlist; + while( true ) { + vTaskEnterCritical(); + evt = param_1->bitmap_evt_async; + param_1->bitmap_evt_async = 0; + param_1->bitmap_evt_sync = param_1->bitmap_evt_sync | evt; + vTaskExitCritical(); + if (param_1->bitmap_evt_sync != 0) break; + puVar2 = (utils_dlist_t *)(param_1->timer_dlist).next; + xTicksToWait = (utils_dlist_s *)0xffffffff; + if (puVar2 != puVar15) { + xTicksToWait = puVar2[2].prev; + TVar4 = xTaskGetTickCount(); + xTicksToWait = (utils_dlist_s *)((int)xTicksToWait - TVar4); + if ((int)xTicksToWait < 1) break; + } + ulTaskNotifyTake(1,(TickType_t)xTicksToWait); + } + if ((utils_dlist_t *)(param_1->timer_dlist).next != puVar15) { + TVar4 = xTaskGetTickCount(); + puVar2 = (utils_dlist_t *)(param_1->timer_dlist).next; + xTicksToWait = (utils_dlist_s *)0x0; + if (puVar2 != (utils_dlist_t *)0x0) { + xTicksToWait = (&puVar2->prev)[1]; + } + while ((puVar11 = xTicksToWait, puVar2 != puVar15 && (-1 < (int)(TVar4 - (int)puVar2[2].prev)) + )) { + bloop_evt_set_sync(param_1,(uint)puVar2[2].next,(uint32_t)puVar2[3].prev); + if (puVar2[3].next != (utils_dlist_s *)0x0) { + (*(code *)puVar2[3].next)(param_1,puVar2,puVar2[4].prev); + } + puVar12 = (&puVar2->prev)[1]; + xTicksToWait = puVar2->prev; + xTicksToWait->next = puVar12; + puVar12->prev = xTicksToWait; + xTicksToWait = (param_1->timer_dued).next; + *(loop_timer **)&puVar2->prev = (loop_timer *)¶m_1->timer_dued; + (&puVar2->prev)[1] = xTicksToWait; + *(utils_dlist_t **)&(param_1->timer_dued).next = puVar2; + *(utils_dlist_t **)&xTicksToWait->prev = puVar2; + puVar2 = (utils_dlist_t *)puVar11; + xTicksToWait = (utils_dlist_s *)0x0; + if (puVar11 != (utils_dlist_s *)0x0) { + xTicksToWait = (&puVar11->prev)[1]; + } + } + timer = (loop_timer *)(param_1->timer_dued).next; + plVar1 = (loop_timer *)0x0; + if (timer != (loop_timer *)0x0) { + plVar1 = (loop_timer *)(timer->dlist_item).next; + } + while (plVar14 = plVar1, timer != (loop_timer *)¶m_1->timer_dued) { + xTicksToWait = (timer->dlist_item).prev; + puVar11 = (timer->dlist_item).next; + xTicksToWait->next = puVar11; + puVar11->prev = xTicksToWait; + if ((timer->flags & 2) == 0) { + if ((timer->flags & 1) != 0) { + if ((_fsymc_level_bloop < BLOG_LEVEL_INFO) && + (_fsymf_level_bloopbloop_base < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar4 = xTaskGetTickCount(); + } + else { + TVar4 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Repeat timer\r\n",TVar4,"DEBUG ","bloop_base.c",0xbb); + } + bloop_timer_repeat_reconfigure(timer); + bloop_timer_register(param_1,timer); + } + } + else { + if ((_fsymc_level_bloop < BLOG_LEVEL_INFO) && + (_fsymf_level_bloopbloop_base < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar4 = xTaskGetTickCount(); + } + else { + TVar4 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Free now\r\n",TVar4,"DEBUG ","bloop_base.c",0xb8); + } + vPortFree(timer); + } + timer = plVar14; + plVar1 = (loop_timer *)0x0; + if (plVar14 != (loop_timer *)0x0) { + plVar1 = (loop_timer *)(plVar14->dlist_item).next; + } + } + } + iVar7 = __clzsi2(param_1->bitmap_evt_sync); + iVar8 = __clzsi2(param_1->bitmap_msg); + if (iVar7 <= iVar8) { + evt = -iVar7 + 0x1f; + if (evt != 0xffffffff) { + pptVar13 = ¶m_1->looper + evt; + ptVar3 = pptVar13[0x104]; + if (ptVar3 == (TaskHandle_t)0x0) { + printf("[ASSERT] [ERR] %s:%d\r\n","bloop_base.c",0x105); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + vTaskEnterCritical(); + ptVar10 = pptVar13[4]; + pptVar13[4] = (TaskHandle_t)0x0; + pptVar13[0x24] = (TaskHandle_t)((uint)pptVar13[0x24] | (uint)ptVar10); + vTaskExitCritical(); + uVar5 = bl_timer_now_us(); + (*(code *)(ptVar3->xStateListItem).xItemValue) + (param_1,(loop_evt_handler *)ptVar3,¶m_1->bitmap_evt_sync, + (uint32_t *)(¶m_1->looper + -iVar7 + 0x43)); + uVar6 = bl_timer_now_us(); + pptVar13 = ¶m_1->looper + evt * 4; + ptVar3 = (TaskHandle_t)(uVar6 - uVar5); + pptVar13[0x85] = ptVar3; + pptVar13[0x86] = (TaskHandle_t)((int)pptVar13[0x86] + (int)ptVar3); + if (pptVar13[0x84] < ptVar3) { + pptVar13[0x84] = ptVar3; + } + pptVar13[0x87] = (TaskHandle_t)((int)&pptVar13[0x87]->pxTopOfStack + 1); + bloop_evt_unset_sync(param_1,evt); + goto LAB_230554f2; + } + } + if ((-iVar8 != -0x20) && + (puVar9 = utils_list_pop_front((utils_list *)(¶m_1->looper + (-iVar8 + 0x41) * 2)), + puVar9 == (utils_list_hdr *)0x0)) { + printf("[ASSERT] [ERR] %s:%d\r\n","bloop_base.c",0x124); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + } while( true ); +} + + + +int bloop_status_dump(loop_ctx *loop) + +{ + loop_evt_handler_statistic *plVar1; + utils_dlist_s *puVar2; + uint32_t *puVar3; + TickType_t TVar4; + char *pcVar5; + uint32_t uVar6; + int iVar7; + uint32_t uVar8; + uint32_t uVar9; + + puts("====== bloop dump ======\r\n"); + printf(" bitmap_evt %lx\r\n",loop->bitmap_evt_sync); + printf(" bitmap_msg %lx\r\n",loop->bitmap_msg); + TVar4 = xTaskGetTickCount(); + puts("--->>> timer list:\r\n"); + puVar2 = (loop->timer_dlist).next; + iVar7 = 0; + while ((utils_dlist_s *)&loop->timer_dlist != puVar2) { + printf(" timer[%02d]: %u(diff %d)ms, \t\t task idx %02d, evt map %08lx, ptr %p\r\n",iVar7, + puVar2[2].prev,TVar4 - (int)puVar2[2].prev,puVar2[2].next,puVar2[3].prev,puVar2[3].next); + iVar7 = iVar7 + 1; + puVar2 = puVar2->next; + } + puVar3 = loop->evt_type_map_async + 0x1f; + printf(" %d task:\r\n",0x20); + plVar1 = loop->statistic + 0x1f; + iVar7 = 0x1f; + do { + pcVar5 = "empty"; + if ((char **)puVar3[0x100] != (char **)0x0) { + pcVar5 = *(char **)puVar3[0x100]; + } + printf(" task[%02d] : %s\r\n",iVar7,pcVar5); + uVar8 = puVar3[0x100]; + if (uVar8 != 0) { + uVar6 = puVar3[0x20]; + uVar9 = *puVar3; + printf(" evt handler %p,",*(undefined4 *)(uVar8 + 4)); + printf(" msg handler %p,",*(undefined4 *)(uVar8 + 8)); + printf(" trigged cnt %u,",plVar1->count_triggered); + printf(" bitmap async %lx sync %lx,",uVar9,uVar6); + printf(" time consumed %dus acc %dms, max %uus\r\n",plVar1->time_consumed, + plVar1->time_accumulated / 1000,plVar1->time_max); + } + iVar7 = iVar7 + -1; + puVar3 = puVar3 + -1; + plVar1 = plVar1 + -1; + } while (iVar7 != -1); + return 0; +} + + + +int loop_evt_entity_sys_handler(loop_ctx *loop,loop_evt_handler *handler,loop_msg *msg) + +{ + printf( + "[SYS] [MSG] called with msg info\r\n priority %u\r\n dst %u\r\n msgid %u\r\n src %u\r\n arg1 %p\r\n arg2 %p\r\n" + ,(uint)*(byte *)&msg->u,(uint)*(byte *)((int)&msg->u + 1),(uint)*(byte *)((int)&msg->u + 2) + ,(uint)*(byte *)((int)&msg->u + 3),msg->arg1,msg->arg2); + return 0; +} + + + +int loop_evt_entity_sys_evt + (loop_ctx *loop,loop_evt_handler *handler,uint32_t *bitmap_evt,uint32_t *evt_type_map) + +{ + uint uVar1; + + uVar1 = *evt_type_map; + printf("[SYS] [EVT] called with bitmap_evt %08lx, bitmap_task %08lx\r\n",*bitmap_evt,uVar1); + do { + if ((uVar1 & 1) == 0) { + if (uVar1 != 0) { + printf("[ASSERT] [ERR] %s:%d\r\n","bloop_handler_sys.c",0x2e); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + break; + } + uVar1 = uVar1 & 0xfffffffe; + bloop_status_dump(loop); + } while (uVar1 != 0); + *evt_type_map = 0; + return 0; +} + + +/* +Unable to decompile 'misaligned_load_trap' +Cause: Exception while decompiling 23055930: Decompiler process died + +*/ + +/* +Unable to decompile 'misaligned_store_trap' +Cause: Exception while decompiling 23055a82: Decompiler process died + +*/ + + +void get_f32_reg(void) + +{ + uint in_t0; + + // WARNING: Could not recover jumptable at 0x23055bd2. Too many branches + // WARNING: Treating indirect jump as call + (*(code *)(in_t0 & 0xfffffffe))(); + return; +} + + + +void put_f32_reg(void) + +{ + uint in_t0; + + // WARNING: Could not recover jumptable at 0x23055cd2. Too many branches + // WARNING: Treating indirect jump as call + (*(code *)(in_t0 & 0xfffffffe))(); + return; +} + + + +int backtrace_riscv(anon_subr_int_char_ptr *print_func,uintptr_t *regs) + +{ + return -1; +} + + + +// WARNING: Variable defined which should be unmapped: addr + +void set_if(netif *netif,char *ip_addr,char *gw_addr,char *nm_addr) + +{ + int iVar1; + ip4_addr_t iStack20; + ip4_addr_t addr; + + if ((ip_addr != (char *)0x0) && (iVar1 = ip4addr_aton(ip_addr,&iStack20), iVar1 != 0)) { + netif_set_ipaddr(netif,&iStack20); + } + if ((gw_addr != (char *)0x0) && (iVar1 = ip4addr_aton(gw_addr,&iStack20), iVar1 != 0)) { + netif_set_gw(netif,&iStack20); + } + if ((nm_addr != (char *)0x0) && (iVar1 = ip4addr_aton(nm_addr,&iStack20), iVar1 != 0)) { + netif_set_netmask(netif,&iStack20); + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: buf +// WARNING: Could not reconcile some variable overlaps + +int block_cipher_df(uchar *output,uchar *data,size_t data_len) + +{ + uchar *__dest; + uchar *puVar1; + byte *pbVar2; + byte *pbVar3; + int iVar4; + int iVar5; + uint uVar6; + uint uVar7; + uint32_t *puVar8; + byte local_338 [4]; + uchar chain [16]; + uchar key [32]; + uchar tmp [48]; + mbedtls_aes_context aes_ctx; + uchar buf [416]; + + if (data_len < 0x181) { + memset(aes_ctx.buf + 0x43,0,0x1a0); + mbedtls_aes_init((mbedtls_aes_context *)(tmp + 0x2c)); + buf._14_2_ = (ushort)(data_len << 8) | (ushort)(data_len >> 8) & 0xff; + buf[19] = '0'; + buf._12_2_ = 0; + memcpy(buf + 0x14,data,data_len); + buf[data_len + 0x14] = -0x80; + iVar4 = 0; + do { + chain[iVar4 + 0xc] = (uchar)iVar4; + iVar4 = iVar4 + 1; + } while (iVar4 != 0x20); + mbedtls_aes_setkey_enc((mbedtls_aes_context *)(tmp + 0x2c),chain + 0xc,0x100); + iVar4 = 0; + do { + memset(local_338,0,0x10); + puVar8 = aes_ctx.buf + 0x43; + uVar7 = data_len + 0x19; + do { + iVar5 = 0; + pbVar3 = local_338; + do { + pbVar2 = (byte *)((int)puVar8 + iVar5); + iVar5 = iVar5 + 1; + *pbVar3 = *pbVar2 ^ *pbVar3; + pbVar3 = pbVar3 + 1; + } while (iVar5 != 0x10); + puVar8 = puVar8 + 4; + uVar6 = uVar7; + if (0x10 < uVar7) { + uVar6 = 0x10; + } + uVar7 = uVar7 - uVar6; + mbedtls_aes_crypt_ecb((mbedtls_aes_context *)(tmp + 0x2c),1,local_338,local_338); + } while (uVar7 != 0); + memcpy(key + iVar4 + 0x1c,local_338,0x10); + iVar4 = iVar4 + 0x10; + aes_ctx.buf[67]._3_1_ = aes_ctx.buf[67]._3_1_ + '\x01'; + } while (iVar4 != 0x30); + mbedtls_aes_setkey_enc((mbedtls_aes_context *)(tmp + 0x2c),key + 0x1c,0x100); + __dest = output; + do { + mbedtls_aes_crypt_ecb((mbedtls_aes_context *)(tmp + 0x2c),1,tmp + 0x1c,tmp + 0x1c); + puVar1 = __dest + 0x10; + memcpy(__dest,tmp + 0x1c,0x10); + __dest = puVar1; + } while (output + 0x30 != puVar1); + mbedtls_aes_free((mbedtls_aes_context *)(tmp + 0x2c)); + return 0; + } + return -0x38; +} + + + +// WARNING: Variable defined which should be unmapped: tmp + +int ctr_drbg_update_internal(mbedtls_ctr_drbg_context_conflict *ctx,uchar *data) + +{ + bool bVar1; + byte *output; + mbedtls_ctr_drbg_context_conflict *pmVar2; + byte *pbVar3; + uchar uVar4; + int iVar5; + byte local_50 [4]; + uchar tmp [48]; + + iVar5 = 0; + memset(local_50,0,0x30); + do { + output = local_50 + iVar5; + pmVar2 = (mbedtls_ctr_drbg_context_conflict *)(ctx->counter + 0xf); + do { + uVar4 = pmVar2->counter[0] + '\x01'; + pmVar2->counter[0] = uVar4; + if (uVar4 != '\0') break; + bVar1 = ctx != pmVar2; + pmVar2 = (mbedtls_ctr_drbg_context_conflict *)((int)&pmVar2[-1].p_entropy + 3); + } while (bVar1); + iVar5 = iVar5 + 0x10; + mbedtls_aes_crypt_ecb(&ctx->aes_ctx,1,(uchar *)ctx,output); + if (iVar5 == 0x30) { + iVar5 = 0; + output = local_50; + do { + pbVar3 = data + iVar5; + iVar5 = iVar5 + 1; + *output = *pbVar3 ^ *output; + output = output + 1; + } while (iVar5 != 0x30); + mbedtls_aes_setkey_enc(&ctx->aes_ctx,local_50,0x100); + memcpy(ctx,tmp + 0x1c,0x10); + return 0; + } + } while( true ); +} + + + +void mbedtls_ctr_drbg_init(mbedtls_ctr_drbg_context_conflict *ctx) + +{ + memset(ctx,0,0x140); + return; +} + + + +void mbedtls_ctr_drbg_free(mbedtls_ctr_drbg_context_conflict *ctx) + +{ + mbedtls_ctr_drbg_context_conflict *pmVar1; + + if (ctx != (mbedtls_ctr_drbg_context_conflict *)0x0) { + mbedtls_aes_free(&ctx->aes_ctx); + pmVar1 = ctx + 1; + while (ctx != pmVar1) { + ctx->counter[0] = '\0'; + ctx = (mbedtls_ctr_drbg_context_conflict *)(ctx->counter + 1); + } + return; + } + return; +} + + + +int mbedtls_ctr_drbg_reseed(mbedtls_ctr_drbg_context_conflict *ctx,uchar *additional,size_t len) + +{ + int iVar1; + size_t data_len; + uchar auStack416 [4]; + uchar seed [384]; + + iVar1 = -0x38; + if ((ctx->entropy_len < 0x181) && (iVar1 = -0x38, len <= 0x180 - ctx->entropy_len)) { + memset(auStack416,0,0x180); + iVar1 = (*ctx->f_entropy)(ctx->p_entropy,auStack416,ctx->entropy_len); + if (iVar1 == 0) { + data_len = ctx->entropy_len; + if ((additional != (uchar *)0x0) && (len != 0)) { + memcpy(auStack416 + data_len,additional,len); + data_len = data_len + len; + } + block_cipher_df(auStack416,auStack416,data_len); + ctr_drbg_update_internal(ctx,auStack416); + ctx->reseed_counter = 1; + } + else { + iVar1 = -0x34; + } + } + return iVar1; +} + + + +int mbedtls_ctr_drbg_seed_entropy_len + (mbedtls_ctr_drbg_context_conflict *ctx, + anon_subr_int_void_ptr_uchar_ptr_size_t *f_entropy,void *p_entropy,uchar *custom, + size_t len,size_t entropy_len) + +{ + int iVar1; + uchar auStack64 [4]; + uchar key [32]; + + memset(auStack64,0,0x20); + mbedtls_aes_init(&ctx->aes_ctx); + *(anon_subr_int_void_ptr_uchar_ptr_size_t **)&ctx->f_entropy = f_entropy; + ctx->p_entropy = p_entropy; + ctx->entropy_len = entropy_len; + ctx->reseed_interval = 10000; + mbedtls_aes_setkey_enc(&ctx->aes_ctx,auStack64,0x100); + iVar1 = mbedtls_ctr_drbg_reseed(ctx,custom,len); + return iVar1; +} + + + +int mbedtls_ctr_drbg_seed + (mbedtls_ctr_drbg_context_conflict *ctx, + anon_subr_int_void_ptr_uchar_ptr_size_t *f_entropy,void *p_entropy,uchar *custom, + size_t len) + +{ + int iVar1; + + iVar1 = mbedtls_ctr_drbg_seed_entropy_len(ctx,f_entropy,p_entropy,custom,len,0x20); + return iVar1; +} + + + +// WARNING: Variable defined which should be unmapped: add_input + +int mbedtls_ctr_drbg_random_with_add + (void *p_rng,uchar *output,size_t output_len,uchar *additional,size_t add_len) + +{ + bool bVar1; + char cVar2; + int iVar3; + char *pcVar4; + uint __n; + uchar auStack96 [4]; + uchar tmp [16]; + uchar add_input [48]; + + if (output_len < 0x401) { + iVar3 = -0x38; + if (add_len < 0x101) { + memset(tmp + 0xc,0,0x30); + if ((*(int *)((int)p_rng + 0x1c) < *(int *)((int)p_rng + 0x10)) || + (*(int *)((int)p_rng + 0x14) != 0)) { + iVar3 = mbedtls_ctr_drbg_reseed + ((mbedtls_ctr_drbg_context_conflict *)p_rng,additional,add_len); + if (iVar3 != 0) { + return iVar3; + } + } + else { + if (add_len != 0) { + block_cipher_df(tmp + 0xc,additional,add_len); + ctr_drbg_update_internal((mbedtls_ctr_drbg_context_conflict *)p_rng,tmp + 0xc); + } + } + while (pcVar4 = (char *)((int)p_rng + 0xf), output_len != 0) { + do { + cVar2 = *pcVar4; + *pcVar4 = cVar2 + '\x01'; + if ((char)(cVar2 + '\x01') != '\0') break; + bVar1 = (char *)p_rng != pcVar4; + pcVar4 = pcVar4 + -1; + } while (bVar1); + mbedtls_aes_crypt_ecb((mbedtls_aes_context *)((int)p_rng + 0x20),1,(uchar *)p_rng,auStack96) + ; + __n = output_len; + if (0x10 < output_len) { + __n = 0x10; + } + memcpy(output,auStack96,__n); + output = output + __n; + output_len = output_len - __n; + } + ctr_drbg_update_internal((mbedtls_ctr_drbg_context_conflict *)p_rng,tmp + 0xc); + iVar3 = 0; + *(int *)((int)p_rng + 0x10) = *(int *)((int)p_rng + 0x10) + 1; + } + } + else { + iVar3 = -0x36; + } + return iVar3; +} + + + +int mbedtls_ctr_drbg_random(void *p_rng,uchar *output,size_t output_len) + +{ + int iVar1; + + iVar1 = mbedtls_ctr_drbg_random_with_add(p_rng,output,output_len,(uchar *)0x0,0); + return iVar1; +} + + + +int entropy_update(mbedtls_entropy_context *ctx,uchar source_id,uchar *data,size_t len) + +{ + uchar uStack68; + undefined uStack67; + uchar header [2]; + uchar tmp [32]; + + if (0x20 < len) { + mbedtls_sha256(data,len,header,0); + data = header; + len = 0x20; + } + uStack67 = (undefined)len; + uStack68 = source_id; + mbedtls_sha256_update((mbedtls_sha256_context *)ctx,&uStack68,2); + mbedtls_sha256_update((mbedtls_sha256_context *)ctx,data,len); + return 0; +} + + + +int entropy_gather_internal(mbedtls_entropy_context *ctx) + +{ + bool bVar1; + mbedtls_entropy_source_state *pmVar2; + int iVar3; + int iVar4; + size_t local_a4; + size_t olen; + uchar buf [128]; + + pmVar2 = ctx->source; + bVar1 = false; + iVar3 = 0; + while( true ) { + if (ctx->source_count <= iVar3) { + iVar3 = 0; + if (!bVar1) { + iVar3 = -0x3d; + } + return iVar3; + } + if (pmVar2->strong == 1) { + bVar1 = true; + } + local_a4 = 0; + iVar4 = (*pmVar2->f_source)(pmVar2->p_source,(uchar *)&olen,0x80,&local_a4); + if (iVar4 != 0) break; + if (local_a4 != 0) { + entropy_update(ctx,(uchar)iVar3,(uchar *)&olen,local_a4); + pmVar2->size = pmVar2->size + local_a4; + } + iVar3 = iVar3 + 1; + pmVar2 = pmVar2 + 1; + } + return iVar4; +} + + + +void mbedtls_entropy_init(mbedtls_entropy_context *ctx) + +{ + int iVar1; + uint32_t *puVar2; + + memset(ctx,0,0x208); + mbedtls_sha256_starts((mbedtls_sha256_context *)ctx,0); + iVar1 = ctx->source_count; + if (iVar1 < 0x14) { + puVar2 = (ctx->accumulator).total + iVar1 * 5; + puVar2[0x1e] = 0x23056490; + puVar2[0x21] = 0x20; + puVar2[0x1f] = 0; + puVar2[0x22] = 1; + ctx->source_count = iVar1 + 1; + } + return; +} + + + +void mbedtls_entropy_free(mbedtls_entropy_context *ctx) + +{ + mbedtls_entropy_context *pmVar1; + + pmVar1 = ctx + 1; + while (ctx != pmVar1) { + *(undefined *)(ctx->accumulator).total = 0; + ctx = (mbedtls_entropy_context *)((int)(ctx->accumulator).total + 1); + } + return; +} + + + +int mbedtls_entropy_func(void *data,uchar *output,size_t len) + +{ + bool bVar1; + int iVar2; + int iVar3; + uint *puVar4; + uint *puVar5; + int iVar6; + uchar auStack64 [4]; + uchar buf [32]; + + if (len < 0x21) { + iVar6 = 0x102; + do { + iVar6 = iVar6 + -1; + if (iVar6 == 0) goto LAB_230563d2; + if (*(int *)((int)data + 0x74) == 0) { + return -0x40; + } + iVar2 = entropy_gather_internal((mbedtls_entropy_context *)data); + if (iVar2 != 0) { + return iVar2; + } + puVar5 = (uint *)((int)data + 0x80); + iVar3 = 0; + bVar1 = true; + puVar4 = puVar5; + while (iVar3 < *(int *)((int)data + 0x74)) { + if (*puVar4 < puVar4[1]) { + bVar1 = false; + } + iVar3 = iVar3 + 1; + puVar4 = puVar4 + 5; + } + } while (!bVar1); + memset(auStack64,0,0x20); + mbedtls_sha256_finish((mbedtls_sha256_context *)data,auStack64); + memset(data,0,0x74); + mbedtls_sha256_starts((mbedtls_sha256_context *)data,0); + mbedtls_sha256_update((mbedtls_sha256_context *)data,auStack64,0x20); + mbedtls_sha256(auStack64,0x20,auStack64,0); + iVar6 = *(int *)((int)data + 0x74); + iVar3 = 0; + while (iVar3 < iVar6) { + *puVar5 = 0; + iVar3 = iVar3 + 1; + puVar5 = puVar5 + 5; + } + memcpy(output,auStack64,len); + } + else { +LAB_230563d2: + iVar2 = -0x3c; + } + return iVar2; +} + + + +int mbedtls_platform_entropy_poll(void *data,uchar *output,size_t len,size_t *olen) + +{ + uint uVar1; + uint uVar2; + + *olen = 0; + uVar2 = 0; + uVar1 = 0; + while (uVar1 != len) { + if ((uVar1 & 3) == 0) { + uVar2 = bl_rand(); + } + output[uVar1] = (uchar)uVar2; + uVar1 = uVar1 + 1; + uVar2 = uVar2 >> 8; + } + *olen = uVar1; + return 0; +} + + + +void mbedtls_pk_init(mbedtls_pk_context *ctx) + +{ + if (ctx != (mbedtls_pk_context *)0x0) { + ctx->pk_info = (mbedtls_pk_info_t *)0x0; + ctx->pk_ctx = (void *)0x0; + } + return; +} + + + +void mbedtls_pk_free(mbedtls_pk_context *ctx) + +{ + mbedtls_pk_context *pmVar1; + + if (ctx != (mbedtls_pk_context *)0x0) { + if (ctx->pk_info != (mbedtls_pk_info_t *)0x0) { + (*ctx->pk_info->ctx_free_func)(ctx->pk_ctx); + pmVar1 = ctx + 1; + while (ctx != pmVar1) { + *(undefined *)&ctx->pk_info = 0; + ctx = (mbedtls_pk_context *)((int)&ctx->pk_info + 1); + } + } + return; + } + return; +} + + + +mbedtls_pk_info_t * mbedtls_pk_info_from_type(mbedtls_pk_type_t pk_type) + +{ + uint uVar1; + + uVar1 = (uint)pk_type - 1 & 0xff; + if (uVar1 < 3) { + return *(mbedtls_pk_info_t **)(&CSWTCH_5 + uVar1 * 4); + } + return (mbedtls_pk_info_t *)0x0; +} + + + +int mbedtls_pk_setup(mbedtls_pk_context *ctx,mbedtls_pk_info_t *info) + +{ + void *pvVar1; + int iVar2; + + if (((ctx != (mbedtls_pk_context *)0x0) && (info != (mbedtls_pk_info_t *)0x0)) && + (ctx->pk_info == (mbedtls_pk_info_t *)0x0)) { + pvVar1 = (*info->ctx_alloc_func)(info->ctx_alloc_func); + ctx->pk_ctx = pvVar1; + if (pvVar1 == (void *)0x0) { + iVar2 = -0x3f80; + } + else { + ctx->pk_info = info; + iVar2 = 0; + } + return iVar2; + } + return -16000; +} + + + +int mbedtls_pk_can_do(mbedtls_pk_context *ctx,mbedtls_pk_type_t type) + +{ + int iVar1; + + if ((ctx != (mbedtls_pk_context *)0x0) && (ctx->pk_info != (mbedtls_pk_info_t *)0x0)) { + // WARNING: Could not recover jumptable at 0x23056572. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*ctx->pk_info->can_do)(type); + return iVar1; + } + return 0; +} + + + +int mbedtls_pk_verify(mbedtls_pk_context *ctx,mbedtls_md_type_t md_alg,uchar *hash,size_t hash_len, + uchar *sig,size_t sig_len) + +{ + anon_subr_int_void_ptr_mbedtls_md_type_t_uchar_ptr_size_t_uchar_ptr_size_t_for_verify_func + *UNRECOVERED_JUMPTABLE; + uchar uVar1; + mbedtls_md_info_t *md_info; + undefined3 extraout_var; + int iVar2; + + if (ctx == (mbedtls_pk_context *)0x0) { + return -16000; + } + if (ctx->pk_info == (mbedtls_pk_info_t *)0x0) { +LAB_23056582: + iVar2 = -16000; + } + else { + if (hash_len == 0) { + md_info = mbedtls_md_info_from_type(md_alg); + if (md_info == (mbedtls_md_info_t *)0x0) goto LAB_23056582; + uVar1 = mbedtls_md_get_size(md_info); + hash_len = CONCAT31(extraout_var,uVar1); + } + UNRECOVERED_JUMPTABLE = ctx->pk_info->verify_func; + if (UNRECOVERED_JUMPTABLE != + (anon_subr_int_void_ptr_mbedtls_md_type_t_uchar_ptr_size_t_uchar_ptr_size_t_for_verify_func + *)0x0) { + // WARNING: Could not recover jumptable at 0x230565ce. Too many branches + // WARNING: Treating indirect jump as call + iVar2 = (*UNRECOVERED_JUMPTABLE)(ctx->pk_ctx,md_alg,hash,hash_len,sig,sig_len); + return iVar2; + } + iVar2 = -0x3f00; + } + return iVar2; +} + + + +int mbedtls_pk_sign(mbedtls_pk_context *ctx,mbedtls_md_type_t md_alg,uchar *hash,size_t hash_len, + uchar *sig,size_t *sig_len,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng, + void *p_rng) + +{ + + anon_subr_int_void_ptr_mbedtls_md_type_t_uchar_ptr_size_t_uchar_ptr_size_t_ptr_anon_subr_int_void_ptr_uchar_ptr_size_t_ptr_void_ptr_for_sign_func + *UNRECOVERED_JUMPTABLE; + uchar uVar1; + mbedtls_md_info_t *md_info; + undefined3 extraout_var; + int iVar2; + + if (ctx == (mbedtls_pk_context *)0x0) { + return -16000; + } + if (ctx->pk_info == (mbedtls_pk_info_t *)0x0) { +LAB_230565e2: + iVar2 = -16000; + } + else { + if (hash_len == 0) { + md_info = mbedtls_md_info_from_type(md_alg); + if (md_info == (mbedtls_md_info_t *)0x0) goto LAB_230565e2; + uVar1 = mbedtls_md_get_size(md_info); + hash_len = CONCAT31(extraout_var,uVar1); + } + UNRECOVERED_JUMPTABLE = ctx->pk_info->sign_func; + if (UNRECOVERED_JUMPTABLE != + ( + anon_subr_int_void_ptr_mbedtls_md_type_t_uchar_ptr_size_t_uchar_ptr_size_t_ptr_anon_subr_int_void_ptr_uchar_ptr_size_t_ptr_void_ptr_for_sign_func + *)0x0) { + // WARNING: Could not recover jumptable at 0x23056636. Too many branches + // WARNING: Treating indirect jump as call + iVar2 = (*UNRECOVERED_JUMPTABLE)(ctx->pk_ctx,md_alg,hash,hash_len,sig,sig_len,f_rng,p_rng); + return iVar2; + } + iVar2 = -0x3f00; + } + return iVar2; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +int mbedtls_pk_decrypt(mbedtls_pk_context *ctx,uchar *input,size_t ilen,uchar *output,size_t *olen, + size_t osize,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng) + +{ + + anon_subr_int_void_ptr_uchar_ptr_size_t_uchar_ptr_size_t_ptr_size_t_anon_subr_int_void_ptr_uchar_ptr_size_t_ptr_void_ptr_for_decrypt_func + *UNRECOVERED_JUMPTABLE; + int iVar1; + + if ((ctx != (mbedtls_pk_context *)0x0) && (ctx->pk_info != (mbedtls_pk_info_t *)0x0)) { + UNRECOVERED_JUMPTABLE = ctx->pk_info->decrypt_func; + if (UNRECOVERED_JUMPTABLE != + ( + anon_subr_int_void_ptr_uchar_ptr_size_t_uchar_ptr_size_t_ptr_size_t_anon_subr_int_void_ptr_uchar_ptr_size_t_ptr_void_ptr_for_decrypt_func + *)0x0) { + // WARNING: Could not recover jumptable at 0x23056654. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*UNRECOVERED_JUMPTABLE)(ctx->pk_ctx); + return iVar1; + } + return -0x3f00; + } + return -16000; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +int mbedtls_pk_encrypt(mbedtls_pk_context *ctx,uchar *input,size_t ilen,uchar *output,size_t *olen, + size_t osize,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng) + +{ + + anon_subr_int_void_ptr_uchar_ptr_size_t_uchar_ptr_size_t_ptr_size_t_anon_subr_int_void_ptr_uchar_ptr_size_t_ptr_void_ptr_for_encrypt_func + *UNRECOVERED_JUMPTABLE; + int iVar1; + + if ((ctx != (mbedtls_pk_context *)0x0) && (ctx->pk_info != (mbedtls_pk_info_t *)0x0)) { + UNRECOVERED_JUMPTABLE = ctx->pk_info->encrypt_func; + if (UNRECOVERED_JUMPTABLE != + ( + anon_subr_int_void_ptr_uchar_ptr_size_t_uchar_ptr_size_t_ptr_size_t_anon_subr_int_void_ptr_uchar_ptr_size_t_ptr_void_ptr_for_encrypt_func + *)0x0) { + // WARNING: Could not recover jumptable at 0x2305667a. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*UNRECOVERED_JUMPTABLE)(ctx->pk_ctx); + return iVar1; + } + return -0x3f00; + } + return -16000; +} + + + +size_t mbedtls_pk_get_bitlen(mbedtls_pk_context *ctx) + +{ + size_t sVar1; + + if ((ctx != (mbedtls_pk_context *)0x0) && (ctx->pk_info != (mbedtls_pk_info_t *)0x0)) { + // WARNING: Could not recover jumptable at 0x23056698. Too many branches + // WARNING: Treating indirect jump as call + sVar1 = (*ctx->pk_info->get_bitlen)(ctx->pk_ctx); + return sVar1; + } + return 0; +} + + + +int mbedtls_pk_verify_ext + (mbedtls_pk_type_t type,void *options,mbedtls_pk_context *ctx,mbedtls_md_type_t md_alg + ,uchar *hash,size_t hash_len,uchar *sig,size_t sig_len) + +{ + undefined3 in_register_00002029; + int iVar1; + size_t sVar2; + int in_fa0; + uchar *in_fa1; + + if ((ctx != (mbedtls_pk_context *)0x0) && (ctx->pk_info != (mbedtls_pk_info_t *)0x0)) { + iVar1 = mbedtls_pk_can_do(ctx,type); + if (iVar1 == 0) { + return -0x3f00; + } + if (CONCAT31(in_register_00002029,type) == 6) { + if (options != (void *)0x0) { + sVar2 = mbedtls_pk_get_bitlen(ctx); + if (sig_len < sVar2 + 7 >> 3) { + return -0x4380; + } + iVar1 = mbedtls_rsa_rsassa_pss_verify_ext + ((mbedtls_rsa_context *)ctx->pk_ctx, + (anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0,(void *)0x0,0,md_alg, + hash_len,hash,*(mbedtls_md_type_t *)options,in_fa0,in_fa1); + if (iVar1 != 0) { + return iVar1; + } + sVar2 = mbedtls_pk_get_bitlen(ctx); + if (sig_len <= sVar2 + 7 >> 3) { + return 0; + } + return -0x3900; + } + } + else { + if (options == (void *)0x0) { + iVar1 = mbedtls_pk_verify(ctx,md_alg,hash,hash_len,sig,sig_len); + return iVar1; + } + } + } + return -16000; +} + + + +int mbedtls_pk_debug(mbedtls_pk_context *ctx,mbedtls_pk_debug_item *items) + +{ + anon_subr_void_void_ptr_mbedtls_pk_debug_item_ptr_for_debug_func *paVar1; + + if ((ctx != (mbedtls_pk_context *)0x0) && (ctx->pk_info != (mbedtls_pk_info_t *)0x0)) { + paVar1 = ctx->pk_info->debug_func; + if (paVar1 != (anon_subr_void_void_ptr_mbedtls_pk_debug_item_ptr_for_debug_func *)0x0) { + (*paVar1)(ctx->pk_ctx,items); + return 0; + } + return -0x3f00; + } + return -16000; +} + + + +char * mbedtls_pk_get_name(mbedtls_pk_context *ctx) + +{ + if ((ctx != (mbedtls_pk_context *)0x0) && (ctx->pk_info != (mbedtls_pk_info_t *)0x0)) { + return ctx->pk_info->name; + } + return "invalid PK"; +} + + + +mbedtls_pk_type_t mbedtls_pk_get_type(mbedtls_pk_context *ctx) + +{ + if ((ctx != (mbedtls_pk_context *)0x0) && (ctx->pk_info != (mbedtls_pk_info_t *)0x0)) { + return ctx->pk_info->type; + } + return MBEDTLS_PK_NONE; +} + + + +int pk_use_ecparams(mbedtls_asn1_buf *params,mbedtls_ecp_group *grp) + +{ + int iVar1; + mbedtls_ecp_group_id local_11 [4]; + mbedtls_ecp_group_id grp_id; + + if (params->tag != 6) { + return -0x3d00; + } + iVar1 = mbedtls_oid_get_ec_grp(params,local_11); + if (iVar1 == 0) { + if ((grp->id == MBEDTLS_ECP_DP_NONE) || (grp->id == local_11[0])) { + iVar1 = mbedtls_ecp_group_load(grp,local_11[0]); + } + else { + iVar1 = -0x3d00; + } + } + else { + iVar1 = -0x3a00; + } + return iVar1; +} + + + +int pk_parse_key_pkcs1_der(mbedtls_rsa_context *rsa,uchar *key,size_t keylen) + +{ + int iVar1; + int iVar2; + size_t sVar3; + uchar *end; + size_t sStack40; + size_t len; + uchar *p; + + len = (size_t)key; + iVar2 = mbedtls_asn1_get_tag((uchar **)&len,key + keylen,&sStack40,0x30); + if (iVar2 == 0) { + end = (uchar *)(len + sStack40); + iVar2 = mbedtls_asn1_get_int((uchar **)&len,end,(int *)rsa); + if (iVar2 == 0) { + if (rsa->ver != 0) { + return -0x3d80; + } + iVar1 = mbedtls_asn1_get_mpi((uchar **)&len,end,&rsa->N); + if (((((iVar1 == 0) && (iVar1 = mbedtls_asn1_get_mpi((uchar **)&len,end,&rsa->E), iVar1 == 0)) + && (iVar1 = mbedtls_asn1_get_mpi((uchar **)&len,end,&rsa->D), iVar1 == 0)) && + ((iVar1 = mbedtls_asn1_get_mpi((uchar **)&len,end,&rsa->P), iVar1 == 0 && + (iVar1 = mbedtls_asn1_get_mpi((uchar **)&len,end,&rsa->Q), iVar1 == 0)))) && + ((iVar1 = mbedtls_asn1_get_mpi((uchar **)&len,end,&rsa->DP), iVar1 == 0 && + ((iVar1 = mbedtls_asn1_get_mpi((uchar **)&len,end,&rsa->DQ), iVar1 == 0 && + (iVar1 = mbedtls_asn1_get_mpi((uchar **)&len,end,&rsa->QP), iVar1 == 0)))))) { + sVar3 = mbedtls_mpi_size(&rsa->N); + rsa->len = sVar3; + if ((uchar *)len != end) { + mbedtls_rsa_free(rsa); + return -0x3d66; + } + iVar2 = mbedtls_rsa_check_privkey(rsa); + if (iVar2 == 0) { + return 0; + } + mbedtls_rsa_free(rsa); + return iVar2; + } + mbedtls_rsa_free(rsa); + iVar2 = -0x3d00; + goto LAB_2305683a; + } + } + iVar1 = -0x3d00; +LAB_2305683a: + return iVar1 + iVar2; +} + + + +int pk_parse_key_sec1_der(mbedtls_ecp_keypair *eck,uchar *key,size_t keylen) + +{ + int iVar1; + uchar *end; + int iVar2; + uchar *end_00; + mbedtls_mpi *X; + int iStack56; + int version; + size_t len; + uchar *p; + mbedtls_asn1_buf params; + + len = (size_t)key; + iVar2 = mbedtls_asn1_get_tag((uchar **)&len,key + keylen,(size_t *)&version,0x30); + if (iVar2 == 0) { + end_00 = (uchar *)(len + version); + iVar2 = mbedtls_asn1_get_int((uchar **)&len,end_00,&iStack56); + if (iVar2 == 0) { + if (iStack56 != 1) { + return -0x3d80; + } + iVar2 = mbedtls_asn1_get_tag((uchar **)&len,end_00,(size_t *)&version,4); + if (iVar2 == 0) { + X = &eck->d; + iVar1 = mbedtls_mpi_read_binary(X,(uchar *)len,version); + if (iVar1 == 0) { + len = len + version; + if ((uchar *)len == end_00) { +LAB_23056a92: + iVar1 = mbedtls_ecp_mul((mbedtls_ecp_group *)eck,&eck->Q,X,&(eck->grp).G, + (anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0,(void *)0x0); + if (iVar1 != 0) goto LAB_2305698a; + } + else { + iVar1 = mbedtls_asn1_get_tag((uchar **)&len,end_00,(size_t *)&version,0xa0); + if (iVar1 == 0) { + end = (uchar *)(version + len); + p = (uchar *)(uint)*(byte *)len; + if (*(byte *)len != 6) { + iVar2 = -0x3d62; + goto LAB_230569fc; + } + iVar2 = mbedtls_asn1_get_tag((uchar **)&len,end,(size_t *)¶ms,6); + if (iVar2 == 0) { + params.len = len; + len = len + params.tag; + if (end != (uchar *)len) { + iVar2 = -0x3d66; + goto LAB_230569fc; + } + } + else { + iVar2 = iVar2 + -0x3d00; + if (iVar2 != 0) goto LAB_230569fc; + } + iVar2 = pk_use_ecparams((mbedtls_asn1_buf *)&p,(mbedtls_ecp_group *)eck); + if (iVar2 != 0) goto LAB_230569fc; + } + else { + if (iVar1 != -0x62) goto LAB_2305698a; + } + iVar1 = mbedtls_asn1_get_tag((uchar **)&len,end_00,(size_t *)&version,0xa1); + if (iVar1 != 0) { + if (iVar1 != -0x62) goto LAB_2305698a; + goto LAB_23056a92; + } + end_00 = (uchar *)(len + version); + iVar2 = mbedtls_asn1_get_bitstring_null((uchar **)&len,end_00,(size_t *)&version); + if (iVar2 != 0) goto LAB_23056948; + if (end_00 != (uchar *)(version + len)) { + return -0x3d66; + } + iVar2 = mbedtls_ecp_point_read_binary + ((mbedtls_ecp_group *)eck,&eck->Q,(uchar *)len,(size_t)(end_00 + -len) + ); + if (iVar2 == 0) { + iVar2 = mbedtls_ecp_check_pubkey((mbedtls_ecp_group *)eck,&eck->Q); + } + len = (size_t)end_00; + if (iVar2 != 0) { + if (iVar2 != -0x4e80) { + return -0x3d00; + } + goto LAB_23056a92; + } + } + iVar2 = mbedtls_ecp_check_privkey((mbedtls_ecp_group *)eck,X); + if (iVar2 == 0) { + return 0; + } +LAB_230569fc: + mbedtls_ecp_keypair_free(eck); + return iVar2; + } +LAB_2305698a: + mbedtls_ecp_keypair_free(eck); + iVar2 = -0x3d00; + goto LAB_23056996; + } + } + } +LAB_23056948: + iVar1 = -0x3d00; +LAB_23056996: + return iVar1 + iVar2; +} + + + +int pk_get_pk_alg(uchar **p,uchar *end,mbedtls_pk_type_t *pk_alg,mbedtls_asn1_buf *params) + +{ + int iVar1; + undefined auStack44 [4]; + mbedtls_asn1_buf alg_oid; + + memset(params,0,0xc); + iVar1 = mbedtls_asn1_get_alg(p,end,(mbedtls_asn1_buf *)auStack44,params); + if (iVar1 == 0) { + iVar1 = mbedtls_oid_get_pk_alg((mbedtls_asn1_buf *)auStack44,pk_alg); + if (iVar1 == 0) { + if ((*pk_alg == MBEDTLS_PK_RSA) && + (((params->tag != 5 && (params->tag != 0)) || (params->len != 0)))) { + iVar1 = -0x3a80; + } + } + else { + iVar1 = -0x3c80; + } + } + else { + iVar1 = iVar1 + -0x3a80; + } + return iVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int pk_parse_key_pkcs8_unencrypted_der(mbedtls_pk_context *pk,uchar *key,size_t keylen) + +{ + uchar *end; + int iVar1; + mbedtls_pk_info_t *info; + mbedtls_pk_type_t mStack41; + mbedtls_pk_type_t pk_alg; + int iStack40; + int version; + size_t len; + uchar *p; + mbedtls_asn1_buf params; + + mStack41 = MBEDTLS_PK_NONE; + len = (size_t)key; + iVar1 = mbedtls_asn1_get_tag((uchar **)&len,key + keylen,(size_t *)&version,0x30); + if (iVar1 != 0) { +LAB_23056b60: + return iVar1 + -0x3d00; + } + end = (uchar *)(len + version); + iVar1 = mbedtls_asn1_get_int((uchar **)&len,end,(int *)&stack0xffffffd8); + if (iVar1 != 0) goto LAB_23056b60; + if (iStack40 != 0) { + return -0x3d80; + } + iVar1 = pk_get_pk_alg((uchar **)&len,end,&mStack41,(mbedtls_asn1_buf *)&p); + if ((iVar1 != 0) || + (iVar1 = mbedtls_asn1_get_tag((uchar **)&len,end,(size_t *)&version,4), iVar1 != 0)) + goto LAB_23056b60; + if (version == 0) { + return -0x3d60; + } + info = mbedtls_pk_info_from_type(mStack41); + if (info == (mbedtls_pk_info_t *)0x0) { + return -0x3c80; + } + iVar1 = mbedtls_pk_setup(pk,info); + if (iVar1 != 0) { + return iVar1; + } + if (mStack41 == MBEDTLS_PK_RSA) { + iVar1 = pk_parse_key_pkcs1_der((mbedtls_rsa_context *)pk->pk_ctx,(uchar *)len,version); + } + else { + if (1 < (byte)(mStack41 + ~MBEDTLS_PK_RSA)) { + return -0x3c80; + } + iVar1 = pk_use_ecparams((mbedtls_asn1_buf *)&p,(mbedtls_ecp_group *)pk->pk_ctx); + if (iVar1 != 0) goto LAB_23056be2; + iVar1 = pk_parse_key_sec1_der((mbedtls_ecp_keypair *)pk->pk_ctx,(uchar *)len,version); + } + if (iVar1 == 0) { + return 0; + } +LAB_23056be2: + mbedtls_pk_free(pk); + return iVar1; +} + + + +int mbedtls_pk_load_file(char *path,uchar **buf,size_t *n) + +{ + char "mbedtls_pk_load_file" [21]; + int fd; + size_t sVar1; + uchar *buf_00; + char *pcVar2; + undefined4 uVar3; + + printf("Open path %s\r\n",path); + fd = aos_open(path,0); + uVar3 = 0x7f; + if (-1 < fd) { + sVar1 = aos_lseek(fd,0,2); + if (sVar1 != 0xffffffff) { + aos_lseek(fd,0,0); + *n = sVar1; + printf("Cert size is %d\r\n",sVar1); + if (*n != 0xffffffff) { + buf_00 = (uchar *)mycalloc(1,*n + 1); + *buf = buf_00; + if (buf_00 != (uchar *)0x0) { + sVar1 = aos_read(fd,buf_00,*n); + if (sVar1 == *n) { + aos_close(fd); + (*buf)[*n] = '\0'; + pcVar2 = strstr((char *)*buf,"-----BEGIN "); + if (pcVar2 == (char *)0x0) { + return 0; + } + *n = *n + 1; + return 0; + } + aos_close(fd); + vPortFree(*buf); + uVar3 = 0x96; + goto LAB_23056c6a; + } + } + aos_close(fd); + printf("%s:%d\r\n",0x23088b4c,0x90); + return -0x3f80; + } + aos_close(fd); + uVar3 = 0x86; + } +LAB_23056c6a: + printf("%s:%d\r\n","mbedtls_pk_load_file",uVar3); + return -0x3e00; +} + + + +// WARNING: Variable defined which should be unmapped: alg_params +// WARNING: Could not reconcile some variable overlaps + +int mbedtls_pk_parse_subpubkey(uchar **p,uchar *end,mbedtls_pk_context *pk) + +{ + mbedtls_rsa_context *ctx; + int iVar1; + mbedtls_pk_info_t *info; + size_t sVar2; + int iVar3; + uchar *end_00; + mbedtls_ecp_group *grp; + mbedtls_ecp_point *pt; + mbedtls_pk_type_t mStack53; + mbedtls_pk_type_t pk_alg; + size_t sStack52; + size_t len; + size_t len_1; + mbedtls_asn1_buf alg_params; + + mStack53 = MBEDTLS_PK_NONE; + iVar1 = mbedtls_asn1_get_tag(p,end,(size_t *)&stack0xffffffcc,0x30); + if (iVar1 != 0) { + iVar3 = -0x3d00; +LAB_23056d6c: + return iVar1 + iVar3; + } + end_00 = *p + sStack52; + iVar1 = pk_get_pk_alg(p,end_00,&mStack53,(mbedtls_asn1_buf *)&len_1); + if (iVar1 != 0) { + return iVar1; + } + iVar1 = mbedtls_asn1_get_bitstring_null(p,end_00,(size_t *)&stack0xffffffcc); + if (iVar1 != 0) { + iVar3 = -0x3b00; + goto LAB_23056d6c; + } + if (end_00 != *p + sStack52) { + return -0x3b66; + } + info = mbedtls_pk_info_from_type(mStack53); + if (info == (mbedtls_pk_info_t *)0x0) { + return -0x3c80; + } + iVar1 = mbedtls_pk_setup(pk,info); + if (iVar1 != 0) { + return iVar1; + } + if (mStack53 != MBEDTLS_PK_RSA) { + if ((byte)(mStack53 + ~MBEDTLS_PK_RSA) < 2) { + iVar1 = pk_use_ecparams((mbedtls_asn1_buf *)&len_1,(mbedtls_ecp_group *)pk->pk_ctx); + if (iVar1 == 0) { + grp = (mbedtls_ecp_group *)pk->pk_ctx; + pt = (mbedtls_ecp_point *)&grp[1].P.p; + iVar1 = mbedtls_ecp_point_read_binary(grp,pt,*p,(size_t)(end_00 + -(int)*p)); + if (iVar1 == 0) { + iVar1 = mbedtls_ecp_check_pubkey(grp,pt); + } + *p = end_00; + if (iVar1 == 0) { + return 0; + } + } + } + else { + iVar1 = -0x3c80; + } + goto LAB_23056e00; + } + ctx = (mbedtls_rsa_context *)pk->pk_ctx; + iVar1 = mbedtls_asn1_get_tag(p,end_00,&len,0x30); + if (iVar1 == 0) { + if (end_00 == *p + len) { + iVar1 = mbedtls_asn1_get_mpi(p,end_00,&ctx->N); + if ((iVar1 != 0) || (iVar1 = mbedtls_asn1_get_mpi(p,end_00,&ctx->E), iVar1 != 0)) + goto LAB_23056df6; + if (end_00 != *p) goto LAB_23056e16; + iVar1 = mbedtls_rsa_check_pubkey(ctx); + if (iVar1 != 0) { + iVar1 = -0x3b00; + goto LAB_23056e00; + } + sVar2 = mbedtls_mpi_size(&ctx->N); + ctx->len = sVar2; + goto LAB_23056e52; + } + } + else { +LAB_23056df6: + iVar1 = iVar1 + -0x3b00; + if (iVar1 != 0) goto LAB_23056e00; +LAB_23056e52: + if (*p == end_00) { + return 0; + } + } +LAB_23056e16: + iVar1 = -0x3b66; +LAB_23056e00: + mbedtls_pk_free(pk); + return iVar1; +} + + + +int mbedtls_pk_parse_key(mbedtls_pk_context *pk,uchar *key,size_t keylen,uchar *pwd,size_t pwdlen) + +{ + int iVar1; + mbedtls_pk_info_t *info; + uchar *puVar2; + size_t sStack64; + size_t len; + mbedtls_pem_context pem; + + mbedtls_pem_init((mbedtls_pem_context *)&len); + if ((keylen == 0) || (puVar2 = key + (keylen - 1), *puVar2 != '\0')) { +LAB_23056eee: + iVar1 = pk_parse_key_pkcs8_unencrypted_der(pk,key,keylen); + if (iVar1 != 0) { + mbedtls_pk_free(pk); + info = mbedtls_pk_info_from_type(MBEDTLS_PK_RSA); + if (info == (mbedtls_pk_info_t *)0x0) goto LAB_23056f92; + iVar1 = mbedtls_pk_setup(pk,info); + if ((iVar1 == 0) && + (iVar1 = pk_parse_key_pkcs1_der((mbedtls_rsa_context *)pk->pk_ctx,key,keylen), iVar1 != 0)) + { + mbedtls_pk_free(pk); + info = mbedtls_pk_info_from_type(MBEDTLS_PK_ECKEY); + if (info == (mbedtls_pk_info_t *)0x0) goto LAB_23056f92; + iVar1 = mbedtls_pk_setup(pk,info); + if ((iVar1 == 0) && + (iVar1 = pk_parse_key_sec1_der((mbedtls_ecp_keypair *)pk->pk_ctx,key,keylen), iVar1 != 0) + ) { + mbedtls_pk_free(pk); + return -0x3d00; + } + } + } + iVar1 = 0; + } + else { + iVar1 = mbedtls_pem_read_buffer + ((mbedtls_pem_context *)&len,"-----BEGIN RSA PRIVATE KEY-----", + "-----END RSA PRIVATE KEY-----",key,pwd,pwdlen,&sStack64); + if (iVar1 != 0) { + if (iVar1 == -0x1380) { + return -0x3b80; + } + if (iVar1 == -0x1300) { + return -0x3c00; + } + if (iVar1 != -0x1080) { + return iVar1; + } + if (*puVar2 == '\0') { + iVar1 = mbedtls_pem_read_buffer + ((mbedtls_pem_context *)&len,"-----BEGIN EC PRIVATE KEY-----", + "-----END EC PRIVATE KEY-----",key,pwd,pwdlen,&sStack64); + if (iVar1 == 0) { + info = mbedtls_pk_info_from_type(MBEDTLS_PK_ECKEY); + if (info == (mbedtls_pk_info_t *)0x0) goto LAB_23056f92; + iVar1 = mbedtls_pk_setup(pk,info); + if (iVar1 != 0) goto LAB_23056fca; + iVar1 = pk_parse_key_sec1_der + ((mbedtls_ecp_keypair *)pk->pk_ctx,(uchar *)len,(size_t)pem.buf); +LAB_23056fc6: + if (iVar1 == 0) goto LAB_23056fd0; + goto LAB_23056fca; + } + if (iVar1 == -0x1380) { + return -0x3b80; + } + if (iVar1 == -0x1300) { + return -0x3c00; + } + if (iVar1 != -0x1080) { + return iVar1; + } + if (*puVar2 == '\0') { + iVar1 = mbedtls_pem_read_buffer + ((mbedtls_pem_context *)&len,"-----BEGIN PRIVATE KEY-----", + "-----END PRIVATE KEY-----",key,(uchar *)0x0,0,&sStack64); + if (iVar1 == 0) { + iVar1 = pk_parse_key_pkcs8_unencrypted_der(pk,(uchar *)len,(size_t)pem.buf); + goto LAB_23056fc6; + } + if (iVar1 != -0x1080) { + return iVar1; + } + } + } + goto LAB_23056eee; + } + info = mbedtls_pk_info_from_type(MBEDTLS_PK_RSA); + if (info != (mbedtls_pk_info_t *)0x0) { + iVar1 = mbedtls_pk_setup(pk,info); + if (iVar1 == 0) { + iVar1 = pk_parse_key_pkcs1_der + ((mbedtls_rsa_context *)pk->pk_ctx,(uchar *)len,(size_t)pem.buf); + goto LAB_23056fc6; + } +LAB_23056fca: + mbedtls_pk_free(pk); +LAB_23056fd0: + mbedtls_pem_free((mbedtls_pem_context *)&len); + return iVar1; + } +LAB_23056f92: + iVar1 = -0x3c80; + } + return iVar1; +} + + + +// WARNING: Variable defined which should be unmapped: buf + +int mbedtls_pk_parse_keyfile(mbedtls_pk_context *ctx,char *path,char *pwd) + +{ + size_t keylen; + size_t key; + int iVar1; + size_t pwdlen; + uchar *puVar2; + size_t local_18; + size_t n; + uchar *buf; + + iVar1 = mbedtls_pk_load_file(path,(uchar **)&n,&local_18); + key = n; + keylen = local_18; + if (iVar1 == 0) { + if (pwd == (char *)0x0) { + pwdlen = 0; + pwd = (char *)0x0; + } + else { + pwdlen = strlen(pwd); + } + iVar1 = mbedtls_pk_parse_key(ctx,(uchar *)key,keylen,(uchar *)pwd,pwdlen); + puVar2 = (uchar *)n; + while (puVar2 != (uchar *)(local_18 + n)) { + *puVar2 = '\0'; + puVar2 = puVar2 + 1; + } + vPortFree((void *)n); + } + return iVar1; +} + + + +int rsa_can_do(mbedtls_pk_type_t type) + +{ + undefined3 in_register_00002029; + + if (CONCAT31(in_register_00002029,type) != 1) { + return (uint)(CONCAT31(in_register_00002029,type) == 6); + } + return 1; +} + + + +size_t rsa_get_bitlen(void *ctx) + +{ + return *(int *)((int)ctx + 4) << 3; +} + + + +void rsa_debug(void *ctx,mbedtls_pk_debug_item *items) + +{ + items->name = "rsa.N"; + items->value = (void *)((int)ctx + 8); + items->type = MBEDTLS_PK_DEBUG_MPI; + items[1].type = MBEDTLS_PK_DEBUG_MPI; + items[1].name = "rsa.E"; + items[1].value = (void *)((int)ctx + 0x14); + return; +} + + + +int eckey_can_do(mbedtls_pk_type_t type) + +{ + undefined3 in_register_00002029; + + return (uint)(CONCAT31(in_register_00002029,type) - 2U < 3); +} + + + +size_t eckey_get_bitlen(void *ctx) + +{ + return *(size_t *)((int)ctx + 0x58); +} + + + +void eckey_debug(void *ctx,mbedtls_pk_debug_item *items) + +{ + items->type = MBEDTLS_PK_DEBUG_ECP; + items->name = "eckey.Q"; + items->value = (void *)((int)ctx + 0x88); + return; +} + + + +int eckeydh_can_do(mbedtls_pk_type_t type) + +{ + undefined3 in_register_00002029; + + return (uint)(CONCAT31(in_register_00002029,type) - 2U < 2); +} + + + +void rsa_free_wrap(void *ctx) + +{ + mbedtls_rsa_free((mbedtls_rsa_context *)ctx); + vPortFree(ctx); + return; +} + + + +void * rsa_alloc_wrap(void) + +{ + mbedtls_rsa_context *ctx; + + ctx = (mbedtls_rsa_context *)mycalloc(1,0xac); + if (ctx != (mbedtls_rsa_context *)0x0) { + mbedtls_rsa_init(ctx,0,0); + } + return ctx; +} + + + +int rsa_check_pair_wrap(mbedtls_rsa_context *pub,mbedtls_rsa_context *prv) + +{ + int iVar1; + + iVar1 = mbedtls_rsa_check_pubkey(pub); + if ((((iVar1 != 0) || (iVar1 = mbedtls_rsa_check_privkey(prv), iVar1 != 0)) || + (iVar1 = mbedtls_mpi_cmp_mpi(&pub->N,&prv->N), iVar1 != 0)) || + (iVar1 = mbedtls_mpi_cmp_mpi(&pub->E,&prv->E), iVar1 != 0)) { + iVar1 = -0x4200; + } + return iVar1; +} + + + +int rsa_encrypt_wrap(void *ctx,uchar *input,size_t ilen,uchar *output,size_t *olen,size_t osize, + anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng) + +{ + int iVar1; + uint uVar2; + + uVar2 = *(uint *)((int)ctx + 4); + *olen = uVar2; + if (uVar2 <= osize) { + iVar1 = mbedtls_rsa_pkcs1_encrypt((mbedtls_rsa_context *)ctx,f_rng,p_rng,0,ilen,input,output); + return iVar1; + } + return -0x4400; +} + + + +int rsa_decrypt_wrap(void *ctx,uchar *input,size_t ilen,uchar *output,size_t *olen,size_t osize, + anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng) + +{ + int iVar1; + + if (*(size_t *)((int)ctx + 4) == ilen) { + iVar1 = mbedtls_rsa_pkcs1_decrypt + ((mbedtls_rsa_context *)ctx,f_rng,p_rng,1,olen,input,output,osize); + return iVar1; + } + return -0x4080; +} + + + +int rsa_sign_wrap(void *ctx,mbedtls_md_type_t md_alg,uchar *hash,size_t hash_len,uchar *sig, + size_t *sig_len,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng) + +{ + int iVar1; + + *sig_len = *(size_t *)((int)ctx + 4); + iVar1 = mbedtls_rsa_pkcs1_sign((mbedtls_rsa_context *)ctx,f_rng,p_rng,1,md_alg,hash_len,hash,sig); + return iVar1; +} + + + +int rsa_verify_wrap(void *ctx,mbedtls_md_type_t md_alg,uchar *hash,size_t hash_len,uchar *sig, + size_t sig_len) + +{ + int iVar1; + + if (*(uint *)((int)ctx + 4) <= sig_len) { + iVar1 = mbedtls_rsa_pkcs1_verify + ((mbedtls_rsa_context *)ctx,(anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0, + (void *)0x0,0,md_alg,hash_len,hash,sig); + if ((iVar1 == 0) && (*(uint *)((int)ctx + 4) < sig_len)) { + iVar1 = -0x3900; + } + return iVar1; + } + return -0x4380; +} + + + +void eckey_free_wrap(void *ctx) + +{ + mbedtls_ecp_keypair_free((mbedtls_ecp_keypair *)ctx); + vPortFree(ctx); + return; +} + + + +void * eckey_alloc_wrap(void) + +{ + mbedtls_ecp_keypair *key; + + key = (mbedtls_ecp_keypair *)mycalloc(1,0xac); + if (key != (mbedtls_ecp_keypair *)0x0) { + mbedtls_ecp_keypair_init(key); + } + return key; +} + + + +int eckey_check_pair(mbedtls_ecp_keypair *pub,mbedtls_ecp_keypair *prv) + +{ + mbedtls_ecp_group_id mVar1; + int iVar2; + mbedtls_mpi *Y; + mbedtls_mpi *Y_00; + mbedtls_ecp_point mStack192; + mbedtls_ecp_group mStack156; + + mVar1 = (pub->grp).id; + if ((mVar1 != MBEDTLS_ECP_DP_NONE) && ((prv->grp).id == mVar1)) { + iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&pub->Q,(mbedtls_mpi *)&prv->Q); + if (iVar2 == 0) { + Y_00 = &(prv->Q).Y; + iVar2 = mbedtls_mpi_cmp_mpi(&(pub->Q).Y,Y_00); + if (iVar2 == 0) { + Y = &(prv->Q).Z; + iVar2 = mbedtls_mpi_cmp_mpi(&(pub->Q).Z,Y); + if (iVar2 == 0) { + mbedtls_ecp_point_init(&mStack192); + memset(&mStack156,0,0x7c); + mbedtls_ecp_group_copy(&mStack156,(mbedtls_ecp_group *)prv); + iVar2 = mbedtls_ecp_mul(&mStack156,&mStack192,&prv->d,&(prv->grp).G, + (anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0,(void *)0x0); + if ((iVar2 == 0) && + (((iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&mStack192,(mbedtls_mpi *)&prv->Q), + iVar2 != 0 || (iVar2 = mbedtls_mpi_cmp_mpi(&mStack192.Y,Y_00), iVar2 != 0)) || + (iVar2 = mbedtls_mpi_cmp_mpi(&mStack192.Z,Y), iVar2 != 0)))) { + iVar2 = -0x4f80; + } + mbedtls_ecp_point_free(&mStack192); + mbedtls_ecp_group_free(&mStack156); + return iVar2; + } + } + } + } + return -0x4f80; +} + + + +// WARNING: Variable defined which should be unmapped: mask + +void mgf_mask(uchar *dst,size_t dlen,uchar *src,size_t slen,mbedtls_md_context_t *md_ctx) + +{ + uchar uVar1; + undefined3 extraout_var; + byte *pbVar2; + byte *pbVar3; + uint uVar4; + uint uVar5; + uchar auStack68 [3]; + char cStack65; + uchar counter [4]; + uchar mask [32]; + + memset(counter,0,0x20); + memset(auStack68,0,4); + uVar1 = mbedtls_md_get_size(md_ctx->md_info); + while (dlen != 0) { + uVar5 = dlen; + if (CONCAT31(extraout_var,uVar1) < dlen) { + uVar5 = CONCAT31(extraout_var,uVar1); + } + mbedtls_md_starts(md_ctx); + mbedtls_md_update(md_ctx,src,slen); + mbedtls_md_update(md_ctx,auStack68,4); + mbedtls_md_finish(md_ctx,counter); + uVar4 = 0; + while (pbVar3 = dst + uVar4, uVar4 != uVar5) { + pbVar2 = counter + uVar4; + uVar4 = uVar4 + 1; + *pbVar3 = *pbVar2 ^ *pbVar3; + } + dlen = dlen - uVar4; + cStack65 = cStack65 + '\x01'; + dst = pbVar3; + } + return; +} + + + +void mbedtls_rsa_init(mbedtls_rsa_context *ctx,int padding,int hash_id) + +{ + memset(ctx,0,0xac); + ctx->padding = padding; + ctx->hash_id = hash_id; + return; +} + + + +int mbedtls_rsa_check_pubkey(mbedtls_rsa_context *ctx) + +{ + mbedtls_mpi *X; + size_t sVar1; + int iVar2; + mbedtls_mpi_uint *pmVar3; + mbedtls_mpi_uint *pmVar4; + + pmVar4 = (ctx->N).p; + if ((((pmVar4 != (mbedtls_mpi_uint *)0x0) && + (pmVar3 = (ctx->E).p, pmVar3 != (mbedtls_mpi_uint *)0x0)) && ((*pmVar4 & 1) != 0)) && + ((*pmVar3 & 1) != 0)) { + X = &ctx->N; + sVar1 = mbedtls_mpi_bitlen(X); + if ((0x7f < sVar1) && (sVar1 = mbedtls_mpi_bitlen(X), sVar1 < 0x2001)) { + sVar1 = mbedtls_mpi_bitlen(&ctx->E); + if ((1 < sVar1) && (iVar2 = mbedtls_mpi_cmp_mpi(&ctx->E,X), iVar2 < 0)) { + return 0; + } + } + return -0x4200; + } + return -0x4200; +} + + + +int mbedtls_rsa_check_privkey(mbedtls_rsa_context *ctx) + +{ + int iVar1; + mbedtls_mpi *B; + mbedtls_mpi *A; + mbedtls_mpi *A_00; + undefined auStack188 [4]; + mbedtls_mpi PQ; + mbedtls_mpi DE; + mbedtls_mpi P1; + mbedtls_mpi Q1; + mbedtls_mpi H; + mbedtls_mpi I; + mbedtls_mpi G; + mbedtls_mpi G2; + mbedtls_mpi L1; + mbedtls_mpi L2; + mbedtls_mpi DP; + mbedtls_mpi DQ; + mbedtls_mpi QP; + + iVar1 = mbedtls_rsa_check_pubkey(ctx); + if (iVar1 == 0) { + iVar1 = -0x4200; + if ((((ctx->P).p != (mbedtls_mpi_uint *)0x0) && ((ctx->Q).p != (mbedtls_mpi_uint *)0x0)) && + (iVar1 = -0x4200, (ctx->D).p != (mbedtls_mpi_uint *)0x0)) { + mbedtls_mpi_init((mbedtls_mpi *)auStack188); + mbedtls_mpi_init((mbedtls_mpi *)&PQ.p); + mbedtls_mpi_init((mbedtls_mpi *)&DE.p); + mbedtls_mpi_init((mbedtls_mpi *)&P1.p); + mbedtls_mpi_init((mbedtls_mpi *)&Q1.p); + mbedtls_mpi_init((mbedtls_mpi *)&H.p); + mbedtls_mpi_init((mbedtls_mpi *)&I.p); + mbedtls_mpi_init((mbedtls_mpi *)&G.p); + mbedtls_mpi_init((mbedtls_mpi *)&G2.p); + mbedtls_mpi_init((mbedtls_mpi *)&L1.p); + mbedtls_mpi_init((mbedtls_mpi *)&L2.p); + mbedtls_mpi_init((mbedtls_mpi *)&DP.p); + mbedtls_mpi_init((mbedtls_mpi *)&DQ.p); + A = &ctx->P; + B = &ctx->Q; + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)auStack188,A,B); + if (iVar1 == 0) { + A_00 = &ctx->D; + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&PQ.p,A_00,&ctx->E); + if (((((iVar1 == 0) && (iVar1 = mbedtls_mpi_sub_int((mbedtls_mpi *)&DE.p,A,1), iVar1 == 0)) + && ((iVar1 = mbedtls_mpi_sub_int((mbedtls_mpi *)&P1.p,B,1), iVar1 == 0 && + ((iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&Q1.p,(mbedtls_mpi *)&DE.p, + (mbedtls_mpi *)&P1.p), iVar1 == 0 && + (iVar1 = mbedtls_mpi_gcd((mbedtls_mpi *)&I.p,&ctx->E,(mbedtls_mpi *)&Q1.p), + iVar1 == 0)))))) && + ((iVar1 = mbedtls_mpi_gcd((mbedtls_mpi *)&G.p,(mbedtls_mpi *)&DE.p,(mbedtls_mpi *)&P1.p) + , iVar1 == 0 && + ((((iVar1 = mbedtls_mpi_div_mpi((mbedtls_mpi *)&G2.p,(mbedtls_mpi *)&L1.p, + (mbedtls_mpi *)&Q1.p,(mbedtls_mpi *)&G.p), iVar1 == 0 + && (iVar1 = mbedtls_mpi_mod_mpi((mbedtls_mpi *)&H.p,(mbedtls_mpi *)&PQ.p, + (mbedtls_mpi *)&G2.p), iVar1 == 0)) && + (iVar1 = mbedtls_mpi_mod_mpi((mbedtls_mpi *)&L2.p,A_00,(mbedtls_mpi *)&DE.p), + iVar1 == 0)) && + ((iVar1 = mbedtls_mpi_mod_mpi((mbedtls_mpi *)&DP.p,A_00,(mbedtls_mpi *)&P1.p), + iVar1 == 0 && (iVar1 = mbedtls_mpi_inv_mod((mbedtls_mpi *)&DQ.p,B,A), iVar1 == 0))))) + ))) && ((((iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)auStack188,&ctx->N), iVar1 != 0 + || ((iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&L2.p,&ctx->DP), iVar1 != 0 + || (iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&DP.p,&ctx->DQ), + iVar1 != 0)))) || + (iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&DQ.p,&ctx->QP), iVar1 != 0)) || + (((iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&L1.p,0), iVar1 != 0 || + (iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&H.p,1), iVar1 != 0)) || + (iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&I.p,1), iVar1 != 0)))))) { + iVar1 = -0x4200; + } + } + mbedtls_mpi_free((mbedtls_mpi *)auStack188); + mbedtls_mpi_free((mbedtls_mpi *)&PQ.p); + mbedtls_mpi_free((mbedtls_mpi *)&DE.p); + mbedtls_mpi_free((mbedtls_mpi *)&P1.p); + mbedtls_mpi_free((mbedtls_mpi *)&Q1.p); + mbedtls_mpi_free((mbedtls_mpi *)&H.p); + mbedtls_mpi_free((mbedtls_mpi *)&I.p); + mbedtls_mpi_free((mbedtls_mpi *)&G.p); + mbedtls_mpi_free((mbedtls_mpi *)&G2.p); + mbedtls_mpi_free((mbedtls_mpi *)&L1.p); + mbedtls_mpi_free((mbedtls_mpi *)&L2.p); + mbedtls_mpi_free((mbedtls_mpi *)&DP.p); + mbedtls_mpi_free((mbedtls_mpi *)&DQ.p); + if ((iVar1 != -0x4200) && (iVar1 != 0)) { + iVar1 = iVar1 + -0x4200; + } + } + } + return iVar1; +} + + + +int mbedtls_rsa_check_pub_priv(mbedtls_rsa_context *pub,mbedtls_rsa_context *prv) + +{ + int iVar1; + + iVar1 = mbedtls_rsa_check_pubkey(pub); + if ((((iVar1 != 0) || (iVar1 = mbedtls_rsa_check_privkey(prv), iVar1 != 0)) || + (iVar1 = mbedtls_mpi_cmp_mpi(&pub->N,&prv->N), iVar1 != 0)) || + (iVar1 = mbedtls_mpi_cmp_mpi(&pub->E,&prv->E), iVar1 != 0)) { + iVar1 = -0x4200; + } + return iVar1; +} + + + +int mbedtls_rsa_public(mbedtls_rsa_context *ctx,uchar *input,uchar *output) + +{ + int iVar1; + int iVar2; + size_t buflen; + undefined auStack44 [4]; + mbedtls_mpi T; + + mbedtls_mpi_init((mbedtls_mpi *)auStack44); + iVar1 = mbedtls_mpi_read_binary((mbedtls_mpi *)auStack44,input,ctx->len); + if (iVar1 == 0) { + iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)auStack44,&ctx->N); + iVar1 = -4; + if (iVar2 < 0) { + buflen = ctx->len; + iVar1 = mbedtls_mpi_exp_mod((mbedtls_mpi *)auStack44,(mbedtls_mpi *)auStack44,&ctx->E,&ctx->N, + &ctx->RN); + if (iVar1 == 0) { + iVar1 = mbedtls_mpi_write_binary((mbedtls_mpi *)auStack44,output,buflen); + } + } + } + mbedtls_mpi_free((mbedtls_mpi *)auStack44); + if (iVar1 != 0) { + iVar1 = iVar1 + -0x4280; + } + return iVar1; +} + + + +int mbedtls_rsa_private(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng, + void *p_rng,uchar *input,uchar *output) + +{ + int iVar1; + int iVar2; + mbedtls_mpi *Y; + mbedtls_mpi *G; + mbedtls_mpi *X; + undefined auStack84 [4]; + mbedtls_mpi T; + mbedtls_mpi T1; + mbedtls_mpi T2; + + if ((((ctx->P).p == (mbedtls_mpi_uint *)0x0) || ((ctx->Q).p == (mbedtls_mpi_uint *)0x0)) || + ((ctx->D).p == (mbedtls_mpi_uint *)0x0)) { + return -0x4080; + } + mbedtls_mpi_init((mbedtls_mpi *)auStack84); + mbedtls_mpi_init((mbedtls_mpi *)&T.p); + mbedtls_mpi_init((mbedtls_mpi *)&T1.p); + iVar1 = mbedtls_mpi_read_binary((mbedtls_mpi *)auStack84,input,ctx->len); + if (iVar1 == 0) { + Y = &ctx->N; + iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)auStack84,Y); + iVar1 = -4; + if (iVar2 < 0) { + if (f_rng != (anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0) { + if ((ctx->Vf).p == (mbedtls_mpi_uint *)0x0) { + iVar2 = 0xc; + X = &ctx->Vf; + G = &ctx->Vi; + do { + iVar2 = iVar2 + -1; + if (iVar2 == 0) { + iVar1 = -0x4480; + goto cleanup; + } + iVar1 = mbedtls_mpi_fill_random(X,ctx->len - 1,f_rng,p_rng); + if ((iVar1 != 0) || (iVar1 = mbedtls_mpi_gcd(G,X,Y), iVar1 != 0)) goto cleanup; + iVar1 = mbedtls_mpi_cmp_int(G,1); + } while (iVar1 != 0); + iVar1 = mbedtls_mpi_inv_mod(G,X,Y); + if (iVar1 != 0) goto cleanup; + iVar1 = mbedtls_mpi_exp_mod(G,G,&ctx->E,Y,&ctx->RN); + } + else { + G = &ctx->Vi; + iVar1 = mbedtls_mpi_mul_mpi(G,G,G); + if ((iVar1 != 0) || (iVar1 = mbedtls_mpi_mod_mpi(G,G,Y), iVar1 != 0)) goto cleanup; + G = &ctx->Vf; + iVar1 = mbedtls_mpi_mul_mpi(G,G,G); + if (iVar1 != 0) goto cleanup; + iVar1 = mbedtls_mpi_mod_mpi(G,G,Y); + } + if (((iVar1 != 0) || + (iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)auStack84,(mbedtls_mpi *)auStack84,&ctx->Vi) + , iVar1 != 0)) || + (iVar1 = mbedtls_mpi_mod_mpi((mbedtls_mpi *)auStack84,(mbedtls_mpi *)auStack84,Y), + iVar1 != 0)) goto cleanup; + } + iVar1 = mbedtls_mpi_exp_mod((mbedtls_mpi *)&T.p,(mbedtls_mpi *)auStack84,&ctx->DP,&ctx->P, + &ctx->RP); + if (iVar1 == 0) { + iVar1 = mbedtls_mpi_exp_mod((mbedtls_mpi *)&T1.p,(mbedtls_mpi *)auStack84,&ctx->DQ,&ctx->Q, + &ctx->RQ); + if (((((iVar1 == 0) && + (iVar1 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)auStack84,(mbedtls_mpi *)&T.p, + (mbedtls_mpi *)&T1.p), iVar1 == 0)) && + ((iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T.p,(mbedtls_mpi *)auStack84,&ctx->QP), + iVar1 == 0 && + ((iVar1 = mbedtls_mpi_mod_mpi((mbedtls_mpi *)auStack84,(mbedtls_mpi *)&T.p,&ctx->P), + iVar1 == 0 && + (iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T.p,(mbedtls_mpi *)auStack84,&ctx->Q), + iVar1 == 0)))))) && + (iVar1 = mbedtls_mpi_add_mpi((mbedtls_mpi *)auStack84,(mbedtls_mpi *)&T1.p, + (mbedtls_mpi *)&T.p), iVar1 == 0)) && + ((f_rng == (anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0 || + ((iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)auStack84,(mbedtls_mpi *)auStack84,&ctx->Vf + ), iVar1 == 0 && + (iVar1 = mbedtls_mpi_mod_mpi((mbedtls_mpi *)auStack84,(mbedtls_mpi *)auStack84,Y), + iVar1 == 0)))))) { + iVar1 = mbedtls_mpi_write_binary((mbedtls_mpi *)auStack84,output,ctx->len); + } + } + } + } +cleanup: + mbedtls_mpi_free((mbedtls_mpi *)auStack84); + mbedtls_mpi_free((mbedtls_mpi *)&T.p); + mbedtls_mpi_free((mbedtls_mpi *)&T1.p); + if (iVar1 != 0) { + iVar1 = iVar1 + -0x4300; + } + return iVar1; +} + + + +int mbedtls_rsa_rsaes_oaep_encrypt + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,uchar *label,size_t label_len,size_t ilen,uchar *input,uchar *output) + +{ + uint __n; + size_t dlen; + uchar slen; + mbedtls_md_info_t *md_info; + undefined3 extraout_var; + int iVar1; + uint uVar2; + uchar *output_00; + uchar *src; + uchar *in_stack_00000000; + undefined auStack76 [4]; + mbedtls_md_context_t md_ctx; + + if ((((mode != 1) || (ctx->padding == 1)) && + (f_rng != (anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0)) && + (md_info = mbedtls_md_info_from_type(*(mbedtls_md_type_t *)&ctx->hash_id), + md_info != (mbedtls_md_info_t *)0x0)) { + __n = ctx->len; + slen = mbedtls_md_get_size(md_info); + _slen = CONCAT31(extraout_var,slen); + uVar2 = ilen + 2 + _slen * 2; + if ((ilen <= uVar2) && (uVar2 <= __n)) { + memset(in_stack_00000000,0,__n); + src = in_stack_00000000 + 1; + *in_stack_00000000 = '\0'; + iVar1 = (*f_rng)(p_rng,src,_slen); + if (iVar1 != 0) { + return iVar1 + -0x4480; + } + output_00 = src + _slen; + mbedtls_md(md_info,label,label_len,output_00); + output_00[((__n - ilen) + -2) - _slen] = '\x01'; + memcpy(output_00 + (((__n - ilen) + -2) - _slen) + 1,input,ilen); + mbedtls_md_init((mbedtls_md_context_t *)auStack76); + iVar1 = mbedtls_md_setup((mbedtls_md_context_t *)auStack76,md_info,0); + if (iVar1 != 0) { + mbedtls_md_free((mbedtls_md_context_t *)auStack76); + return iVar1; + } + dlen = (__n - 1) - _slen; + mgf_mask(in_stack_00000000 + _slen + 1,dlen,src,_slen,(mbedtls_md_context_t *)auStack76); + mgf_mask(src,_slen,in_stack_00000000 + _slen + 1,dlen,(mbedtls_md_context_t *)auStack76); + mbedtls_md_free((mbedtls_md_context_t *)auStack76); + if (mode == 0) { + iVar1 = mbedtls_rsa_public(ctx,in_stack_00000000,in_stack_00000000); + return iVar1; + } + iVar1 = mbedtls_rsa_private(ctx,f_rng,p_rng,in_stack_00000000,in_stack_00000000); + return iVar1; + } + } + return -0x4080; +} + + + +int mbedtls_rsa_rsaes_pkcs1_v15_encrypt + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,size_t ilen,uchar *input,uchar *output) + +{ + int iVar1; + int iVar2; + uchar *puVar3; + uchar *puVar4; + + if ((((mode == 1) && (ctx->padding != 0)) || + (f_rng == (anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0)) || + ((input == (uchar *)0x0 || (output == (uchar *)0x0)))) { + return -0x4080; + } + if ((0xfffffff4 < ilen) || (ctx->len < ilen + 0xb)) { + return -0x4080; + } + iVar1 = ctx->len - ilen; + *output = '\0'; + iVar2 = iVar1 + -3; + puVar4 = output + 2; + if (mode == 0) { + output[1] = '\x02'; + puVar3 = output + iVar1 + -1; + while (puVar4 != puVar3) { + iVar1 = 100; + while (iVar2 = (*f_rng)(p_rng,puVar4,1), *puVar4 == '\0') { + iVar1 = iVar1 + -1; + if ((iVar1 == 0) || (iVar2 != 0)) goto LAB_23057aec; + } + if (iVar2 != 0) { +LAB_23057aec: + return iVar2 + -0x4480; + } + puVar4 = puVar4 + 1; + } + } + else { + output[1] = '\x01'; + puVar3 = output; + while (output + iVar2 != puVar3) { + puVar3[2] = -1; + puVar3 = puVar3 + 1; + } + puVar3 = puVar4 + iVar2; + } + *puVar3 = '\0'; + memcpy(puVar3 + 1,input,ilen); + if (mode != 0) { + iVar1 = mbedtls_rsa_private(ctx,f_rng,p_rng,output,output); + return iVar1; + } + iVar1 = mbedtls_rsa_public(ctx,output,output); + return iVar1; +} + + + +int mbedtls_rsa_pkcs1_encrypt + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,size_t ilen,uchar *input,uchar *output) + +{ + int iVar1; + uchar *in_fa0; + + if (ctx->padding == 0) { + iVar1 = mbedtls_rsa_rsaes_pkcs1_v15_encrypt(ctx,f_rng,p_rng,mode,ilen,input,output); + return iVar1; + } + if (ctx->padding != 1) { + return -0x4100; + } + iVar1 = mbedtls_rsa_rsaes_oaep_encrypt(ctx,f_rng,p_rng,mode,(uchar *)0x0,0,ilen,input,in_fa0); + return iVar1; +} + + + +int mbedtls_rsa_rsaes_oaep_decrypt + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,uchar *label,size_t label_len,size_t *olen,uchar *input,uchar *output, + size_t output_max_len) + +{ + uint __n; + uchar dlen; + mbedtls_md_info_t *md_info; + undefined3 extraout_var; + int iVar1; + uchar *puVar2; + uint uVar3; + int iVar4; + byte *pbVar5; + byte *pbVar6; + uchar *output_00; + int iVar7; + size_t slen; + void *in_stack_00000000; + uint in_stack_00000004; + undefined auStack1132 [4]; + mbedtls_md_context_t md_ctx; + uchar lhash [32]; + uchar buf [1024]; + + if ((((mode != 1) || (ctx->padding == 1)) && (__n = ctx->len, __n - 0x10 < 0x3f1)) && + (md_info = mbedtls_md_info_from_type(*(mbedtls_md_type_t *)&ctx->hash_id), + md_info != (mbedtls_md_info_t *)0x0)) { + dlen = mbedtls_md_get_size(md_info); + _dlen = CONCAT31(extraout_var,dlen); + iVar7 = _dlen + 1; + if ((uint)(iVar7 * 2) <= __n) { + output_00 = lhash + 0x1c; + if (mode == 0) { + iVar1 = mbedtls_rsa_public(ctx,input,output_00); + } + else { + iVar1 = mbedtls_rsa_private(ctx,f_rng,p_rng,input,output_00); + } + if (iVar1 != 0) { + return iVar1; + } + mbedtls_md_init((mbedtls_md_context_t *)auStack1132); + iVar1 = mbedtls_md_setup((mbedtls_md_context_t *)auStack1132,md_info,0); + if (iVar1 != 0) { + mbedtls_md_free((mbedtls_md_context_t *)auStack1132); + return iVar1; + } + mbedtls_md(md_info,label,label_len,(uchar *)&md_ctx.hmac_ctx); + slen = (__n - 1) - _dlen; + mgf_mask(lhash + 0x1d,_dlen,output_00 + iVar7,slen,(mbedtls_md_context_t *)auStack1132); + mgf_mask(output_00 + iVar7,slen,lhash + 0x1d,_dlen,(mbedtls_md_context_t *)auStack1132); + mbedtls_md_free((mbedtls_md_context_t *)auStack1132); + uVar3 = 0; + while (uVar3 < _dlen) { + pbVar5 = (byte *)((int)&md_ctx.hmac_ctx + uVar3); + pbVar6 = lhash + _dlen + 0x1d + uVar3; + uVar3 = uVar3 + 1; + lhash[28] = *pbVar5 ^ *pbVar6 | lhash[28]; + } + puVar2 = lhash + _dlen + 0x1d + _dlen; + uVar3 = 0; + iVar4 = 0; + iVar1 = 0; + while (__n + iVar7 * -2 != iVar1) { + pbVar6 = puVar2 + iVar1; + iVar1 = iVar1 + 1; + uVar3 = uVar3 | *pbVar6; + iVar4 = iVar4 + ((-uVar3 & 0xff | uVar3) >> 7 ^ 1); + } + if ((byte)(puVar2[iVar4] ^ 1 | lhash[28]) == 0) { + __n = __n - (int)(puVar2 + iVar4 + 1 + -(int)output_00); + if (__n <= in_stack_00000004) { + *olen = __n; + memcpy(in_stack_00000000,puVar2 + iVar4 + 1,__n); + return 0; + } + return -0x4400; + } + return -0x4100; + } + } + return -0x4080; +} + + + +// WARNING: Variable defined which should be unmapped: buf + +int mbedtls_rsa_rsaes_pkcs1_v15_decrypt + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,size_t *olen,uchar *input,uchar *output,size_t output_max_len) + +{ + char *pcVar1; + int iVar2; + uint __n; + byte *pbVar3; + uint uVar4; + uint uVar5; + byte *pbVar6; + size_t sVar7; + byte local_420; + byte bStack1055; + byte abStack1054 [2]; + uchar buf [1024]; + + pbVar6 = &local_420; + pbVar3 = &local_420; + if (((mode == 1) && (ctx->padding != 0)) || (sVar7 = ctx->len, 0x3f0 < sVar7 - 0x10)) { + iVar2 = -0x4080; + } + else { + if (mode == 0) { + iVar2 = mbedtls_rsa_public(ctx,input,&local_420); + } + else { + iVar2 = mbedtls_rsa_private(ctx,f_rng,p_rng,input,&local_420); + } + if (iVar2 == 0) { + if (mode == 1) { + bStack1055 = bStack1055 ^ 2; + uVar4 = 0; + __n = 0; + uVar5 = 0; + do { + pbVar3 = pbVar6 + 2; + __n = __n + 1; + pbVar6 = pbVar6 + 1; + uVar4 = uVar4 | ((uint)*pbVar3 | -(uint)*pbVar3 & 0xff) >> 7 ^ 1; + uVar5 = uVar5 + ((-uVar4 & 0xff) >> 7 ^ 1); + } while (__n < sVar7 - 3); + } + else { + bStack1055 = bStack1055 ^ 1; + uVar4 = 0; + __n = 0; + uVar5 = 0; + do { + pcVar1 = (char *)(pbVar3 + 2); + __n = __n + 1; + pbVar3 = pbVar3 + 1; + uVar4 = *pcVar1 != -1 | uVar4; + uVar5 = uVar5 + (uVar4 ^ 1); + } while (__n < sVar7 - 3); + } + if ((byte)(uVar5 < 8 | bStack1055 | local_420 | abStack1054[uVar5]) == 0) { + __n = sVar7 - (int)(abStack1054 + uVar5 + 1 + -(int)&local_420); + if (output_max_len < __n) { + iVar2 = -0x4400; + } + else { + *olen = __n; + memcpy(output,abStack1054 + uVar5 + 1,__n); + } + } + else { + iVar2 = -0x4100; + } + } + } + return iVar2; +} + + + +int mbedtls_rsa_pkcs1_decrypt + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,size_t *olen,uchar *input,uchar *output,size_t output_max_len) + +{ + int iVar1; + uchar *in_fa0; + size_t in_fa1; + + if (ctx->padding == 0) { + iVar1 = mbedtls_rsa_rsaes_pkcs1_v15_decrypt + (ctx,f_rng,p_rng,mode,olen,input,output,output_max_len); + return iVar1; + } + if (ctx->padding != 1) { + return -0x4100; + } + iVar1 = mbedtls_rsa_rsaes_oaep_decrypt + (ctx,f_rng,p_rng,mode,(uchar *)0x0,0,olen,input,in_fa0,in_fa1); + return iVar1; +} + + + +int mbedtls_rsa_rsassa_pss_sign + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig) + +{ + uint __n; + uchar uVar1; + mbedtls_md_info_t *md_info; + undefined3 extraout_var; + size_t __n_00; + int iVar2; + size_t sVar3; + uint uVar4; + undefined3 in_register_00002039; + uchar *input; + undefined auStack108 [4]; + mbedtls_md_context_t md_ctx; + uchar salt [32]; + + if (((mode != 1) || (ctx->padding == 1)) && + (f_rng != (anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0)) { + __n = ctx->len; + if (CONCAT31(in_register_00002039,md_alg) != 0) { + md_info = mbedtls_md_info_from_type(md_alg); + if (md_info == (mbedtls_md_info_t *)0x0) { + return -0x4080; + } + uVar1 = mbedtls_md_get_size(md_info); + hashlen = CONCAT31(extraout_var,uVar1); + } + md_info = mbedtls_md_info_from_type(*(mbedtls_md_type_t *)&ctx->hash_id); + if (md_info != (mbedtls_md_info_t *)0x0) { + uVar1 = mbedtls_md_get_size(md_info); + __n_00 = CONCAT31(__n_00._1_3_,uVar1); + if ((__n_00 + 1) * 2 <= __n) { + memset(sig,0,__n); + iVar2 = (*f_rng)(p_rng,(uchar *)&md_ctx.hmac_ctx,__n_00); + if (iVar2 != 0) { + return iVar2 + -0x4480; + } + sVar3 = mbedtls_mpi_bitlen(&ctx->N); + input = sig + __n + (__n_00 + 1) * -2; + *input = '\x01'; + memcpy(input + 1,&md_ctx.hmac_ctx,__n_00); + mbedtls_md_init((mbedtls_md_context_t *)auStack108); + iVar2 = mbedtls_md_setup((mbedtls_md_context_t *)auStack108,md_info,0); + if (iVar2 == 0) { + input = input + 1 + __n_00; + mbedtls_md_starts((mbedtls_md_context_t *)auStack108); + mbedtls_md_update((mbedtls_md_context_t *)auStack108,input,8); + mbedtls_md_update((mbedtls_md_context_t *)auStack108,hash,hashlen); + mbedtls_md_update((mbedtls_md_context_t *)auStack108,(uchar *)&md_ctx.hmac_ctx,__n_00); + mbedtls_md_finish((mbedtls_md_context_t *)auStack108,input); + uVar4 = (uint)((sVar3 - 1 & 7) == 0); + mgf_mask(sig + uVar4,((__n - 1) - __n_00) - uVar4,input,__n_00, + (mbedtls_md_context_t *)auStack108); + mbedtls_md_free((mbedtls_md_context_t *)auStack108); + sVar3 = mbedtls_mpi_bitlen(&ctx->N); + *sig = (byte)(0xff >> ((__n * 8 + 1) - sVar3 & 0x1f)) & *sig; + input[__n_00] = -0x44; + if (mode != 0) { + iVar2 = mbedtls_rsa_private(ctx,f_rng,p_rng,sig,sig); + return iVar2; + } + iVar2 = mbedtls_rsa_public(ctx,sig,sig); + return iVar2; + } + mbedtls_md_free((mbedtls_md_context_t *)auStack108); + return iVar2; + } + } + } + return -0x4080; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int mbedtls_rsa_rsassa_pkcs1_v15_sign + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig) + +{ + uint uVar1; + int iVar2; + uint __n; + uchar uVar3; + mbedtls_md_info_t *md_info; + int iVar4; + undefined3 extraout_var; + uchar *output; + uchar *output_00; + byte *pbVar5; + byte *pbVar6; + byte bVar7; + undefined3 in_register_00002039; + size_t sVar8; + uchar diff_no_optimize; + size_t __n_00; + size_t oid_size; + char *oid; + + __n_00 = 0; + oid_size = 0; + if ((mode != 1) || (ctx->padding == 0)) { + uVar1 = ctx->len; + iVar2 = uVar1 - 3; + if (CONCAT31(in_register_00002039,md_alg) != 0) { + md_info = mbedtls_md_info_from_type(md_alg); + if (md_info == (mbedtls_md_info_t *)0x0) { + return -0x4080; + } + iVar4 = mbedtls_oid_get_oid_by_md(md_alg,(char **)&oid_size,(size_t *)&stack0xffffffc8); + if (iVar4 != 0) { + return -0x4080; + } + iVar2 = iVar2 - __n_00; + uVar3 = mbedtls_md_get_size(md_info); + hashlen = CONCAT31(extraout_var,uVar3); + iVar2 = iVar2 + -10; + } + __n = iVar2 - hashlen; + if ((7 < __n) && (__n <= uVar1)) { + *sig = '\0'; + sig[1] = '\x01'; + memset(sig + 2,0xff,__n); + output = sig + 2 + __n; + *output = '\0'; + if (CONCAT31(in_register_00002039,md_alg) == 0) { + output = output + 1; + } + else { + uVar3 = (uchar)__n_00; + output[2] = uVar3 + '\b' + (uchar)hashlen; + output[4] = uVar3 + '\x04'; + output[6] = uVar3; + output[1] = '0'; + output[3] = '0'; + output[5] = '\x06'; + memcpy(output + 7,(void *)oid_size,__n_00); + output = output + 7 + __n_00; + *output = '\x05'; + output[1] = '\0'; + output[2] = '\x04'; + output[3] = (uchar)hashlen; + output = output + 4; + } + memcpy(output,hash,hashlen); + if (mode != 0) { + iVar2 = -0x10; + output = (uchar *)mycalloc(1,ctx->len); + if (output != (uchar *)0x0) { + output_00 = (uchar *)mycalloc(1,ctx->len); + if (output_00 != (uchar *)0x0) { + iVar2 = mbedtls_rsa_private(ctx,f_rng,p_rng,sig,output); + if ((iVar2 == 0) && (iVar2 = mbedtls_rsa_public(ctx,output,output_00), iVar2 == 0)) { + bVar7 = 0; + sVar8 = 0; + while (ctx->len != sVar8) { + pbVar6 = output_00 + sVar8; + pbVar5 = sig + sVar8; + sVar8 = sVar8 + 1; + bVar7 = bVar7 | *pbVar6 ^ *pbVar5; + } + if (bVar7 == 0) { + memcpy(sig,output,ctx->len); + } + else { + iVar2 = -0x4300; + } + } + vPortFree(output); + output = output_00; + } + vPortFree(output); + return iVar2; + } + return -0x10; + } + iVar2 = mbedtls_rsa_public(ctx,sig,sig); + return iVar2; + } + } + return -0x4080; +} + + + +int mbedtls_rsa_pkcs1_sign + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig) + +{ + int iVar1; + + if (ctx->padding == 0) { + iVar1 = mbedtls_rsa_rsassa_pkcs1_v15_sign(ctx,f_rng,p_rng,mode,md_alg,hashlen,hash,sig); + return iVar1; + } + if (ctx->padding != 1) { + return -0x4100; + } + iVar1 = mbedtls_rsa_rsassa_pss_sign(ctx,f_rng,p_rng,mode,md_alg,hashlen,hash,sig); + return iVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +int mbedtls_rsa_rsassa_pss_verify_ext + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash, + mbedtls_md_type_t mgf1_hash_id,int expected_salt_len,uchar *sig) + +{ + uchar *dst; + uchar *puVar1; + uchar uVar2; + int iVar3; + mbedtls_md_info_t *md_info; + undefined3 extraout_var; + uint slen; + size_t sVar4; + undefined3 in_register_00002039; + size_t ilen; + size_t sVar5; + uchar *output; + size_t in_stack_00000000; + uchar *in_stack_00000004; + uchar auStack1124 [4]; + uchar zeros [8]; + mbedtls_md_context_t md_ctx; + uchar result [32]; + uchar buf [1024]; + + if (((mode != 1) || (ctx->padding == 1)) && (ilen = ctx->len, ilen - 0x10 < 0x3f1)) { + output = result + 0x1c; + if (mode == 0) { + iVar3 = mbedtls_rsa_public(ctx,in_stack_00000004,output); + } + else { + iVar3 = mbedtls_rsa_private(ctx,f_rng,p_rng,in_stack_00000004,output); + } + if (iVar3 != 0) { + return iVar3; + } + if (result[ilen + 0x1b] != -0x44) { + return -0x4100; + } + if (CONCAT31(in_register_00002039,md_alg) != 0) { + md_info = mbedtls_md_info_from_type(md_alg); + if (md_info == (mbedtls_md_info_t *)0x0) { + return -0x4080; + } + uVar2 = mbedtls_md_get_size(md_info); + hashlen = CONCAT31(extraout_var,uVar2); + } + md_info = mbedtls_md_info_from_type(mgf1_hash_id); + if (md_info != (mbedtls_md_info_t *)0x0) { + uVar2 = mbedtls_md_get_size(md_info); + slen = CONCAT31(slen._1_3_,uVar2); + memset(auStack1124,0,8); + sVar4 = mbedtls_mpi_bitlen(&ctx->N); + dst = output; + sVar5 = ilen; + if ((sVar4 - 1 & 7) == 0) { + dst = result + 0x1d; + sVar5 = ilen - 1; + } + if ((int)(uint)result[28] >> (sVar5 * -8 + sVar4 + 7 & 0x1f) == 0) { + mbedtls_md_init((mbedtls_md_context_t *)(zeros + 4)); + iVar3 = mbedtls_md_setup((mbedtls_md_context_t *)(zeros + 4),md_info,0); + if (iVar3 != 0) { + mbedtls_md_free((mbedtls_md_context_t *)(zeros + 4)); + return iVar3; + } + mgf_mask(dst,~slen + sVar5,dst + ~slen + sVar5,slen,(mbedtls_md_context_t *)(zeros + 4)); + result[28] = (byte)(0xff >> (sVar5 * 8 - (sVar4 - 1) & 0x1f)) & result[28]; + do { + puVar1 = dst; + if (output + sVar5 <= puVar1) { + if (output + sVar5 == puVar1) goto LAB_230584a6; + break; + } + dst = puVar1 + 1; + } while (*puVar1 == '\0'); + dst = puVar1 + 1; + if ((*puVar1 == '\x01') && + ((ilen = ((ilen - 1) - slen) - (int)(dst + -(int)output), in_stack_00000000 == 0xffffffff + || (in_stack_00000000 == ilen)))) { + mbedtls_md_starts((mbedtls_md_context_t *)(zeros + 4)); + mbedtls_md_update((mbedtls_md_context_t *)(zeros + 4),auStack1124,8); + mbedtls_md_update((mbedtls_md_context_t *)(zeros + 4),hash,hashlen); + mbedtls_md_update((mbedtls_md_context_t *)(zeros + 4),dst,ilen); + mbedtls_md_finish((mbedtls_md_context_t *)(zeros + 4),(uchar *)&md_ctx.hmac_ctx); + mbedtls_md_free((mbedtls_md_context_t *)(zeros + 4)); + iVar3 = memcmp(dst + ilen,&md_ctx.hmac_ctx,slen); + if (iVar3 == 0) { + return 0; + } + return -0x4380; + } +LAB_230584a6: + mbedtls_md_free((mbedtls_md_context_t *)(zeros + 4)); + return -0x4100; + } + } + } + return -0x4080; +} + + + +int mbedtls_rsa_rsassa_pss_verify + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig) + +{ + int iVar1; + mbedtls_md_type_t mgf1_hash_id; + int in_fa0; + uchar *in_fa1; + + mgf1_hash_id = (mbedtls_md_type_t)ctx->hash_id; + if (ctx->hash_id == 0) { + mgf1_hash_id = md_alg; + } + iVar1 = mbedtls_rsa_rsassa_pss_verify_ext + (ctx,f_rng,p_rng,mode,md_alg,hashlen,hash,mgf1_hash_id,in_fa0,in_fa1); + return iVar1; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +int mbedtls_rsa_rsassa_pkcs1_v15_verify + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig) + +{ + uchar **output; + uint uVar1; + uchar *end; + uchar __n; + int iVar2; + mbedtls_md_info_t *md_info; + undefined3 extraout_var; + undefined3 in_register_00002039; + size_t sVar3; + mbedtls_md_type_t mStack1077; + mbedtls_md_type_t msg_md_alg; + size_t sStack1076; + size_t asn1_len; + uchar *p; + mbedtls_asn1_buf oid; + uchar buf [1024]; + + if ((mode == 1) && (ctx->padding != 0)) { + return -0x4080; + } + sVar3 = ctx->len; + if (sVar3 - 0x10 < 0x3f1) { + output = &oid.p; + if (mode == 0) { + iVar2 = mbedtls_rsa_public(ctx,sig,(uchar *)output); + } + else { + iVar2 = mbedtls_rsa_private(ctx,f_rng,p_rng,sig,(uchar *)output); + } + if (iVar2 != 0) { + return iVar2; + } + if (((char)oid.p != '\0') || (asn1_len = (int)&oid.p + 2, oid.p._1_1_ != '\x01')) { + return -0x4100; + } + while (*(uchar *)asn1_len != '\0') { + if ((uchar *)((int)output + (sVar3 - 1)) <= asn1_len) { + return -0x4100; + } + if (*(uchar *)asn1_len != -1) { + return -0x4100; + } + asn1_len = asn1_len + 1; + } + asn1_len = asn1_len + 1; + uVar1 = sVar3 - (int)((uchar *)asn1_len + -(int)output); + if ((uVar1 == hashlen) && (CONCAT31(in_register_00002039,md_alg) == 0)) { + iVar2 = memcmp((void *)asn1_len,hash,hashlen); + if (iVar2 == 0) { + return 0; + } + } + else { + md_info = mbedtls_md_info_from_type(md_alg); + if (md_info == (mbedtls_md_info_t *)0x0) goto LAB_230584ee; + __n = mbedtls_md_get_size(md_info); + ___n = CONCAT31(extraout_var,__n); + end = (uchar *)(asn1_len + uVar1); + iVar2 = mbedtls_asn1_get_tag((uchar **)&asn1_len,end,(size_t *)&stack0xfffffbcc,0x30); + if ((((iVar2 == 0) && (sStack1076 + 2 == uVar1)) && + (iVar2 = mbedtls_asn1_get_tag((uchar **)&asn1_len,end,(size_t *)&stack0xfffffbcc,0x30), + iVar2 == 0)) && + ((sStack1076 + 6 + ___n == uVar1 && + (iVar2 = mbedtls_asn1_get_tag((uchar **)&asn1_len,end,(size_t *)&oid,6), iVar2 == 0)))) { + oid.len = asn1_len; + asn1_len = asn1_len + oid.tag; + iVar2 = mbedtls_oid_get_md_alg((mbedtls_asn1_buf *)&p,&mStack1077); + if (((iVar2 == 0) && + (((uint)mStack1077 == CONCAT31(in_register_00002039,md_alg) && + (iVar2 = mbedtls_asn1_get_tag((uchar **)&asn1_len,end,(size_t *)&stack0xfffffbcc,5), + iVar2 == 0)))) && + ((iVar2 = mbedtls_asn1_get_tag((uchar **)&asn1_len,end,(size_t *)&stack0xfffffbcc,4), + iVar2 == 0 && + (((sStack1076 == ___n && (iVar2 = memcmp((void *)asn1_len,hash,___n), iVar2 == 0)) && + (end == (uchar *)(___n + asn1_len))))))) { + return 0; + } + } + } + iVar2 = -0x4380; + } + else { +LAB_230584ee: + iVar2 = -0x4080; + } + return iVar2; +} + + + +int mbedtls_rsa_pkcs1_verify + (mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng, + int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig) + +{ + int iVar1; + + if (ctx->padding == 0) { + iVar1 = mbedtls_rsa_rsassa_pkcs1_v15_verify(ctx,f_rng,p_rng,mode,md_alg,hashlen,hash,sig); + return iVar1; + } + if (ctx->padding != 1) { + return -0x4100; + } + iVar1 = mbedtls_rsa_rsassa_pss_verify(ctx,f_rng,p_rng,mode,md_alg,hashlen,hash,sig); + return iVar1; +} + + + +void mbedtls_rsa_free(mbedtls_rsa_context *ctx) + +{ + mbedtls_mpi_free(&ctx->Vi); + mbedtls_mpi_free(&ctx->Vf); + mbedtls_mpi_free(&ctx->RQ); + mbedtls_mpi_free(&ctx->RP); + mbedtls_mpi_free(&ctx->RN); + mbedtls_mpi_free(&ctx->QP); + mbedtls_mpi_free(&ctx->DQ); + mbedtls_mpi_free(&ctx->DP); + mbedtls_mpi_free(&ctx->Q); + mbedtls_mpi_free(&ctx->P); + mbedtls_mpi_free(&ctx->D); + mbedtls_mpi_free(&ctx->E); + mbedtls_mpi_free(&ctx->N); + return; +} + + + +void mbedtls_sha256_init(mbedtls_sha256_context *ctx) + +{ + memset(ctx,0,0x74); + return; +} + + + +void mbedtls_sha256_free(mbedtls_sha256_context *ctx) + +{ + mbedtls_sha256_context *pmVar1; + + pmVar1 = ctx + 1; + if (ctx != (mbedtls_sha256_context *)0x0) { + while (ctx != pmVar1) { + *(undefined *)ctx->total = 0; + ctx = (mbedtls_sha256_context *)((int)ctx->total + 1); + } + } + return; +} + + + +void mbedtls_sha256_clone(mbedtls_sha256_context *dst,mbedtls_sha256_context *src) + +{ + memcpy(dst,src,0x74); + return; +} + + + +void mbedtls_sha256_starts(mbedtls_sha256_context *ctx,int is224) + +{ + uint32_t uVar1; + + ctx->total[0] = 0; + ctx->total[1] = 0; + if (is224 == 0) { + ctx->state[0] = 0x6a09e667; + ctx->state[1] = 0xbb67ae85; + ctx->state[2] = 0x3c6ef372; + ctx->state[3] = 0xa54ff53a; + ctx->state[4] = 0x510e527f; + ctx->state[5] = 0x9b05688c; + ctx->state[6] = 0x1f83d9ab; + uVar1 = 0x5be0cd19; + } + else { + ctx->state[0] = 0xc1059ed8; + ctx->state[1] = 0x367cd507; + ctx->state[2] = 0x3070dd17; + ctx->state[3] = 0xf70e5939; + ctx->state[4] = 0xffc00b31; + ctx->state[5] = 0x68581511; + ctx->state[6] = 0x64f98fa7; + uVar1 = 0xbefa4fa4; + } + ctx->state[7] = uVar1; + ctx->is224 = is224; + return; +} + + + +void mbedtls_sha256_process(mbedtls_sha256_context *ctx,uchar *data) + +{ + uint uVar1; + uint32_t *puVar2; + byte *pbVar3; + byte *pbVar4; + uint uVar5; + uint uVar6; + uint32_t uVar7; + uint uVar8; + uint32_t *puVar9; + uint uVar10; + uint32_t *puVar11; + uint uVar12; + int iVar13; + uint uVar14; + uint uVar15; + uint uVar16; + uint uVar17; + uint32_t *puVar18; + uint uVar19; + uint uVar20; + uint uVar21; + uint32_t *puVar22; + uint uVar23; + uint32_t uVar24; + uint uVar25; + uint32_t *puVar26; + uint32_t uVar27; + uint32_t local_150; + uint32_t A [8]; + uint32_t W [64]; + + puVar18 = &local_150; + puVar9 = &local_150; + puVar11 = ctx->state; + do { + uVar7 = *puVar11; + puVar11 = puVar11 + 1; + *puVar9 = uVar7; + puVar9 = puVar9 + 1; + } while ((uint32_t *)ctx->buffer != puVar11); + puVar11 = A + 7; + pbVar3 = data; + puVar9 = puVar11; + do { + pbVar4 = pbVar3 + 4; + *puVar9 = (uint)*pbVar3 << 0x18 | (uint)pbVar3[1] << 0x10 | (uint)pbVar3[3] | + (uint)pbVar3[2] << 8; + pbVar3 = pbVar4; + puVar9 = puVar9 + 1; + } while (data + 0x40 != pbVar4); + puVar2 = K; + puVar9 = K; + puVar26 = puVar11; + do { + puVar22 = puVar9 + 8; + iVar13 = A[6] + ((A[3] >> 6 | A[3] << 0x1a) ^ (A[3] >> 0xb | A[3] << 0x15) ^ + (A[3] << 7 | A[3] >> 0x19)) + *puVar9 + *puVar26 + ((A[5] ^ A[4]) & A[3] ^ A[5]) + ; + uVar12 = A[2] + iVar13; + uVar14 = iVar13 + ((local_150 >> 2 | local_150 << 0x1e) ^ (local_150 >> 0xd | local_150 << 0x13) + ^ (local_150 << 10 | local_150 >> 0x16)) + + ((local_150 | A[0]) & A[1] | local_150 & A[0]); + iVar13 = ((uVar12 >> 6 | uVar12 * 0x4000000) ^ (uVar12 >> 0xb | uVar12 * 0x200000) ^ + (uVar12 * 0x80 | uVar12 >> 0x19)) + + A[5] + puVar9[1] + puVar26[1] + ((A[3] ^ A[4]) & uVar12 ^ A[4]); + uVar1 = ((uVar14 >> 2 | uVar14 * 0x40000000) ^ (uVar14 >> 0xd | uVar14 * 0x80000) ^ + (uVar14 * 0x400 | uVar14 >> 0x16)) + ((uVar14 | local_150) & A[0] | uVar14 & local_150) + + iVar13; + uVar10 = A[1] + iVar13; + iVar13 = ((uVar10 >> 6 | uVar10 * 0x4000000) ^ (uVar10 >> 0xb | uVar10 * 0x200000) ^ + (uVar10 * 0x80 | uVar10 >> 0x19)) + + A[4] + puVar9[2] + puVar26[2] + ((uVar12 ^ A[3]) & uVar10 ^ A[3]); + uVar5 = ((uVar1 >> 2 | uVar1 * 0x40000000) ^ (uVar1 >> 0xd | uVar1 * 0x80000) ^ + (uVar1 * 0x400 | uVar1 >> 0x16)) + ((uVar14 | uVar1) & local_150 | uVar14 & uVar1) + + iVar13; + uVar8 = A[0] + iVar13; + iVar13 = ((uVar8 >> 6 | uVar8 * 0x4000000) ^ (uVar8 >> 0xb | uVar8 * 0x200000) ^ + (uVar8 * 0x80 | uVar8 >> 0x19)) + + A[3] + puVar9[3] + puVar26[3] + ((uVar12 ^ uVar10) & uVar8 ^ uVar12); + uVar16 = ((uVar5 >> 2 | uVar5 * 0x40000000) ^ (uVar5 >> 0xd | uVar5 * 0x80000) ^ + (uVar5 * 0x400 | uVar5 >> 0x16)) + ((uVar1 | uVar5) & uVar14 | uVar1 & uVar5) + iVar13; + uVar6 = local_150 + iVar13; + iVar13 = ((uVar6 >> 6 | uVar6 * 0x4000000) ^ (uVar6 >> 0xb | uVar6 * 0x200000) ^ + (uVar6 * 0x80 | uVar6 >> 0x19)) + + uVar12 + puVar9[4] + puVar26[4] + ((uVar10 ^ uVar8) & uVar6 ^ uVar10); + A[2] = ((uVar16 >> 2 | uVar16 * 0x40000000) ^ (uVar16 >> 0xd | uVar16 * 0x80000) ^ + (uVar16 * 0x400 | uVar16 >> 0x16)) + ((uVar5 | uVar16) & uVar1 | uVar5 & uVar16) + iVar13 + ; + A[6] = uVar14 + iVar13; + iVar13 = ((A[6] >> 6 | A[6] * 0x4000000) ^ (A[6] >> 0xb | A[6] * 0x200000) ^ + (A[6] * 0x80 | A[6] >> 0x19)) + + uVar10 + puVar9[5] + puVar26[5] + ((uVar8 ^ uVar6) & A[6] ^ uVar8); + A[1] = ((A[2] >> 2 | A[2] * 0x40000000) ^ (A[2] >> 0xd | A[2] * 0x80000) ^ + (A[2] * 0x400 | A[2] >> 0x16)) + ((uVar16 | A[2]) & uVar5 | uVar16 & A[2]) + iVar13; + A[5] = uVar1 + iVar13; + iVar13 = ((A[5] >> 6 | A[5] * 0x4000000) ^ (A[5] >> 0xb | A[5] * 0x200000) ^ + (A[5] * 0x80 | A[5] >> 0x19)) + + uVar8 + puVar9[6] + puVar26[6] + ((uVar6 ^ A[6]) & A[5] ^ uVar6); + A[0] = ((A[1] >> 2 | A[1] * 0x40000000) ^ (A[1] >> 0xd | A[1] * 0x80000) ^ + (A[1] * 0x400 | A[1] >> 0x16)) + ((A[2] | A[1]) & uVar16 | A[2] & A[1]) + iVar13; + A[4] = uVar5 + iVar13; + iVar13 = ((A[4] >> 6 | A[4] * 0x4000000) ^ (A[4] >> 0xb | A[4] * 0x200000) ^ + (A[4] * 0x80 | A[4] >> 0x19)) + + uVar6 + puVar9[7] + puVar26[7] + ((A[6] ^ A[5]) & A[4] ^ A[6]); + A[3] = uVar16 + iVar13; + local_150 = ((A[0] >> 2 | A[0] * 0x40000000) ^ (A[0] >> 0xd | A[0] * 0x80000) ^ + (A[0] * 0x400 | A[0] >> 0x16)) + ((A[1] | A[0]) & A[2] | A[1] & A[0]) + iVar13; + puVar9 = puVar22; + puVar26 = puVar26 + 8; + } while (puVar22 != K + 0x10); + do { + uVar19 = puVar11[0xe]; + uVar1 = puVar11[1]; + uVar20 = puVar11[0xf]; + uVar23 = ((uVar19 << 0xf | uVar19 >> 0x11) ^ (uVar19 << 0xd | uVar19 >> 0x13) ^ uVar19 >> 10) + + puVar11[9] + *puVar11 + + ((uVar1 >> 7 | uVar1 << 0x19) ^ (uVar1 << 0xe | uVar1 >> 0x12) ^ uVar1 >> 3); + uVar10 = puVar11[3]; + iVar13 = A[6] + ((A[3] >> 6 | A[3] << 0x1a) ^ (A[3] >> 0xb | A[3] << 0x15) ^ + (A[3] << 7 | A[3] >> 0x19)) + ((A[5] ^ A[4]) & A[3] ^ A[5]) + puVar2[0x10] + + uVar23; + uVar16 = A[2] + iVar13; + uVar15 = iVar13 + ((local_150 >> 2 | local_150 << 0x1e) ^ (local_150 >> 0xd | local_150 << 0x13) + ^ (local_150 << 10 | local_150 >> 0x16)) + + ((local_150 | A[0]) & A[1] | local_150 & A[0]); + uVar6 = puVar11[2]; + uVar1 = ((uVar20 << 0xf | uVar20 >> 0x11) ^ (uVar20 << 0xd | uVar20 >> 0x13) ^ uVar20 >> 10) + + uVar1 + puVar11[10] + + ((uVar6 >> 7 | uVar6 << 0x19) ^ (uVar6 << 0xe | uVar6 >> 0x12) ^ uVar6 >> 3); + iVar13 = ((A[3] ^ A[4]) & uVar16 ^ A[4]) + A[5] + puVar2[0x11] + uVar1 + + ((uVar16 >> 6 | uVar16 * 0x4000000) ^ (uVar16 >> 0xb | uVar16 * 0x200000) ^ + (uVar16 * 0x80 | uVar16 >> 0x19)); + uVar5 = ((uVar15 >> 2 | uVar15 * 0x40000000) ^ (uVar15 >> 0xd | uVar15 * 0x80000) ^ + (uVar15 * 0x400 | uVar15 >> 0x16)) + ((local_150 | uVar15) & A[0] | local_150 & uVar15) + + iVar13; + uVar14 = A[1] + iVar13; + uVar6 = ((uVar23 * 0x8000 | uVar23 >> 0x11) ^ (uVar23 * 0x2000 | uVar23 >> 0x13) ^ uVar23 >> 10) + + uVar6 + puVar11[0xb] + + ((uVar10 >> 7 | uVar10 << 0x19) ^ (uVar10 << 0xe | uVar10 >> 0x12) ^ uVar10 >> 3); + iVar13 = ((A[3] ^ uVar16) & uVar14 ^ A[3]) + A[4] + puVar2[0x12] + uVar6 + + ((uVar14 >> 6 | uVar14 * 0x4000000) ^ (uVar14 >> 0xb | uVar14 * 0x200000) ^ + (uVar14 * 0x80 | uVar14 >> 0x19)); + puVar11[0x11] = uVar1; + uVar8 = ((uVar5 >> 2 | uVar5 * 0x40000000) ^ (uVar5 >> 0xd | uVar5 * 0x80000) ^ + (uVar5 * 0x400 | uVar5 >> 0x16)) + ((uVar15 | uVar5) & local_150 | uVar15 & uVar5) + + iVar13; + uVar12 = A[0] + iVar13; + uVar25 = puVar11[4]; + uVar1 = ((uVar1 * 0x8000 | uVar1 >> 0x11) ^ (uVar1 * 0x2000 | uVar1 >> 0x13) ^ uVar1 >> 10) + + uVar10 + puVar11[0xc] + + ((uVar25 >> 7 | uVar25 << 0x19) ^ (uVar25 << 0xe | uVar25 >> 0x12) ^ uVar25 >> 3); + iVar13 = ((uVar16 ^ uVar14) & uVar12 ^ uVar16) + A[3] + puVar2[0x13] + uVar1 + + ((uVar12 >> 6 | uVar12 * 0x4000000) ^ (uVar12 >> 0xb | uVar12 * 0x200000) ^ + (uVar12 * 0x80 | uVar12 >> 0x19)); + uVar17 = ((uVar8 >> 2 | uVar8 * 0x40000000) ^ (uVar8 >> 0xd | uVar8 * 0x80000) ^ + (uVar8 * 0x400 | uVar8 >> 0x16)) + ((uVar5 | uVar8) & uVar15 | uVar5 & uVar8) + iVar13; + uVar10 = local_150 + iVar13; + puVar11[0x12] = uVar6; + uVar21 = puVar11[5]; + uVar25 = ((uVar6 * 0x8000 | uVar6 >> 0x11) ^ (uVar6 * 0x2000 | uVar6 >> 0x13) ^ uVar6 >> 10) + + uVar25 + puVar11[0xd] + + ((uVar21 >> 7 | uVar21 << 0x19) ^ (uVar21 << 0xe | uVar21 >> 0x12) ^ uVar21 >> 3); + iVar13 = ((uVar10 >> 6 | uVar10 * 0x4000000) ^ (uVar10 >> 0xb | uVar10 * 0x200000) ^ + (uVar10 * 0x80 | uVar10 >> 0x19)) + + ((uVar14 ^ uVar12) & uVar10 ^ uVar14) + uVar16 + puVar2[0x14] + uVar25; + A[2] = ((uVar17 >> 2 | uVar17 * 0x40000000) ^ (uVar17 >> 0xd | uVar17 * 0x80000) ^ + (uVar17 * 0x400 | uVar17 >> 0x16)) + ((uVar8 | uVar17) & uVar5 | uVar8 & uVar17) + iVar13 + ; + A[6] = uVar15 + iVar13; + uVar6 = puVar11[6]; + puVar11[0x13] = uVar1; + uVar16 = ((uVar1 * 0x8000 | uVar1 >> 0x11) ^ (uVar1 * 0x2000 | uVar1 >> 0x13) ^ uVar1 >> 10) + + uVar19 + uVar21 + + ((uVar6 >> 7 | uVar6 << 0x19) ^ (uVar6 << 0xe | uVar6 >> 0x12) ^ uVar6 >> 3); + iVar13 = ((A[6] >> 6 | A[6] * 0x4000000) ^ (A[6] >> 0xb | A[6] * 0x200000) ^ + (A[6] * 0x80 | A[6] >> 0x19)) + + ((uVar12 ^ uVar10) & A[6] ^ uVar12) + uVar14 + puVar2[0x15] + uVar16; + A[1] = ((A[2] >> 2 | A[2] * 0x40000000) ^ (A[2] >> 0xd | A[2] * 0x80000) ^ + (A[2] * 0x400 | A[2] >> 0x16)) + ((uVar17 | A[2]) & uVar8 | uVar17 & A[2]) + iVar13; + A[5] = uVar5 + iVar13; + uVar1 = puVar11[7]; + puVar11[0x14] = uVar25; + uVar7 = uVar20 + uVar6 + + ((uVar25 * 0x8000 | uVar25 >> 0x11) ^ (uVar25 * 0x2000 | uVar25 >> 0x13) ^ uVar25 >> 10) + + ((uVar1 >> 7 | uVar1 << 0x19) ^ (uVar1 << 0xe | uVar1 >> 0x12) ^ uVar1 >> 3); + iVar13 = ((A[5] >> 6 | A[5] * 0x4000000) ^ (A[5] >> 0xb | A[5] * 0x200000) ^ + (A[5] * 0x80 | A[5] >> 0x19)) + + ((uVar10 ^ A[6]) & A[5] ^ uVar10) + uVar12 + puVar2[0x16] + uVar7; + A[0] = ((A[1] >> 2 | A[1] * 0x40000000) ^ (A[1] >> 0xd | A[1] * 0x80000) ^ + (A[1] * 0x400 | A[1] >> 0x16)) + ((A[2] | A[1]) & uVar17 | A[2] & A[1]) + iVar13; + A[4] = uVar8 + iVar13; + uVar5 = puVar11[8]; + puVar11[0x15] = uVar16; + puVar11[0x10] = uVar23; + uVar27 = puVar2[0x17]; + uVar24 = uVar23 + uVar1 + + ((uVar16 * 0x8000 | uVar16 >> 0x11) ^ (uVar16 * 0x2000 | uVar16 >> 0x13) ^ uVar16 >> 10 + ) + ((uVar5 >> 7 | uVar5 << 0x19) ^ (uVar5 << 0xe | uVar5 >> 0x12) ^ uVar5 >> 3); + puVar11[0x17] = uVar24; + iVar13 = ((A[4] >> 6 | A[4] * 0x4000000) ^ (A[4] >> 0xb | A[4] * 0x200000) ^ + (A[4] * 0x80 | A[4] >> 0x19)) + + uVar10 + uVar27 + uVar24 + ((A[6] ^ A[5]) & A[4] ^ A[6]); + puVar11[0x16] = uVar7; + puVar11 = puVar11 + 8; + A[3] = uVar17 + iVar13; + local_150 = ((A[0] >> 2 | A[0] * 0x40000000) ^ (A[0] >> 0xd | A[0] * 0x80000) ^ + (A[0] * 0x400 | A[0] >> 0x16)) + ((A[1] | A[0]) & A[2] | A[1] & A[0]) + iVar13; + puVar2 = puVar2 + 8; + } while (W + 0x2f != puVar11); + puVar9 = ctx->state; + do { + iVar13 = *puVar18; + puVar11 = puVar9 + 1; + puVar18 = (uint32_t *)((int *)puVar18 + 1); + *puVar9 = *puVar9 + iVar13; + puVar9 = puVar11; + } while ((uint32_t *)ctx->buffer != puVar11); + return; +} + + + +void mbedtls_sha256_update(mbedtls_sha256_context *ctx,uchar *input,size_t ilen) + +{ + size_t __n; + uint uVar1; + uint uVar2; + uint __n_00; + + uVar2 = ctx->total[0] & 0x3f; + uVar1 = ctx->total[0] + ilen; + ctx->total[0] = uVar1; + if (uVar1 < ilen) { + ctx->total[1] = ctx->total[1] + 1; + } + uVar1 = ilen; + if ((uVar2 != 0) && (__n_00 = 0x40 - uVar2, __n_00 <= ilen)) { + memcpy(ctx->buffer + uVar2,input,__n_00); + ilen = (ilen - 0x40) + uVar2; + mbedtls_sha256_process(ctx,ctx->buffer); + input = input + __n_00; + uVar2 = 0; + uVar1 = ilen; + } + while (0x3f < ilen) { + mbedtls_sha256_process(ctx,input + (uVar1 - ilen)); + ilen = ilen - 0x40; + } + __n = (uVar1 >> 6) * -0x40 + uVar1; + if (__n == 0) { + return; + } + memcpy(ctx->buffer + uVar2,input + (uVar1 & 0xffffffc0),__n); + return; +} + + + +void mbedtls_sha256_update(mbedtls_sha256_context *ctx,uchar *input,size_t ilen) + +{ + if (ilen != 0) { + mbedtls_sha256_update(ctx,input,ilen); + return; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void mbedtls_sha256_finish(mbedtls_sha256_context *ctx,uchar *output) + +{ + uint uVar1; + uint uVar2; + int iVar3; + uchar uStack24; + undefined uStack23; + ushort uStack22; + uchar msglen [8]; + + uVar1 = ctx->total[0]; + uVar2 = ctx->total[1] << 3; + uStack24 = (uchar)(uVar2 >> 0x18); + uStack23 = (undefined)(uVar2 >> 0x10); + uStack22 = (ushort)(uVar2 >> 8) & 0xff | (ushort)((uVar2 | uVar1 >> 0x1d) << 8); + msglen[0] = (uchar)((uVar1 << 3) >> 0x18); + msglen[1] = (uchar)((uVar1 << 3) >> 0x10); + msglen._2_2_ = (ushort)((uVar1 << 0x13) >> 0x18) | (ushort)(uVar1 << 0xb); + if ((uVar1 & 0x3f) < 0x38) { + iVar3 = 0x38; + } + else { + iVar3 = 0x78; + } + mbedtls_sha256_update(ctx,sha256_padding,iVar3 - (uVar1 & 0x3f)); + mbedtls_sha256_update(ctx,&uStack24,8); + *output = *(uchar *)((int)ctx->state + 3); + output[1] = (uchar)*(undefined2 *)((int)ctx->state + 2); + output[2] = (uchar)(ctx->state[0] >> 8); + output[3] = (uchar)ctx->state[0]; + output[4] = *(uchar *)((int)ctx->state + 7); + output[5] = (uchar)*(undefined2 *)((int)ctx->state + 6); + output[6] = (uchar)(ctx->state[1] >> 8); + output[7] = (uchar)ctx->state[1]; + output[8] = *(uchar *)((int)ctx->state + 0xb); + output[9] = (uchar)*(undefined2 *)((int)ctx->state + 10); + output[10] = (uchar)(ctx->state[2] >> 8); + output[0xb] = (uchar)ctx->state[2]; + output[0xc] = *(uchar *)((int)ctx->state + 0xf); + output[0xd] = (uchar)*(undefined2 *)((int)ctx->state + 0xe); + output[0xe] = (uchar)(ctx->state[3] >> 8); + output[0xf] = (uchar)ctx->state[3]; + output[0x10] = *(uchar *)((int)ctx->state + 0x13); + output[0x11] = (uchar)*(undefined2 *)((int)ctx->state + 0x12); + output[0x12] = (uchar)(ctx->state[4] >> 8); + output[0x13] = (uchar)ctx->state[4]; + output[0x14] = *(uchar *)((int)ctx->state + 0x17); + output[0x15] = (uchar)*(undefined2 *)((int)ctx->state + 0x16); + output[0x16] = (uchar)(ctx->state[5] >> 8); + output[0x17] = (uchar)ctx->state[5]; + output[0x18] = *(uchar *)((int)ctx->state + 0x1b); + output[0x19] = (uchar)*(undefined2 *)((int)ctx->state + 0x1a); + output[0x1a] = (uchar)(ctx->state[6] >> 8); + output[0x1b] = (uchar)ctx->state[6]; + if (ctx->is224 == 0) { + output[0x1c] = *(uchar *)((int)ctx->state + 0x1f); + output[0x1d] = (uchar)*(undefined2 *)((int)ctx->state + 0x1e); + output[0x1e] = (uchar)(ctx->state[7] >> 8); + output[0x1f] = (uchar)ctx->state[7]; + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: ctx + +void mbedtls_sha256(uchar *input,size_t ilen,uchar *output,int is224) + +{ + undefined auStack132 [4]; + mbedtls_sha256_context ctx; + + mbedtls_sha256_init((mbedtls_sha256_context *)auStack132); + mbedtls_sha256_starts((mbedtls_sha256_context *)auStack132,is224); + mbedtls_sha256_update((mbedtls_sha256_context *)auStack132,input,ilen); + mbedtls_sha256_finish((mbedtls_sha256_context *)auStack132,output); + mbedtls_sha256_free((mbedtls_sha256_context *)auStack132); + return; +} + + + +mbedtls_x509_crt * mbedtls_ssl_own_cert(mbedtls_ssl_context *ssl) + +{ + mbedtls_x509_crt *pmVar1; + + if (((ssl->handshake != (mbedtls_ssl_handshake_params *)0x0) && + (pmVar1 = (mbedtls_x509_crt *)ssl->handshake->key_cert, pmVar1 != (mbedtls_x509_crt *)0x0)) || + (pmVar1 = (mbedtls_x509_crt *)ssl->conf->key_cert, pmVar1 != (mbedtls_x509_crt *)0x0)) { + pmVar1 = (mbedtls_x509_crt *)(pmVar1->raw).tag; + } + return pmVar1; +} + + + +void mbedtls_zeroize(void *v,size_t n) + +{ + undefined *puVar1; + + puVar1 = (undefined *)(n + (int)v); + while ((undefined *)v != puVar1) { + *(undefined *)v = 0; + v = (undefined *)v + 1; + } + return; +} + + + +void ssl_swap_epochs(mbedtls_ssl_context *ssl) + +{ + mbedtls_ssl_transform *pmVar1; + uchar *puVar2; + undefined auStack24 [4]; + uchar tmp_out_ctr [8]; + + if (ssl->transform_out == ssl->handshake->alt_transform_out) { + mbedtls_debug_print_msg(ssl,3,"file1",0xa0a,"skip swap epochs"); + } + else { + mbedtls_debug_print_msg(ssl,3,"file1",0xa0e,"swap epochs"); + pmVar1 = ssl->transform_out; + ssl->transform_out = ssl->handshake->alt_transform_out; + ssl->handshake->alt_transform_out = pmVar1; + memcpy(auStack24,ssl->out_ctr,8); + memcpy(ssl->out_ctr,ssl->handshake->alt_out_ctr,8); + memcpy(ssl->handshake->alt_out_ctr,auStack24,8); + pmVar1 = ssl->transform_out; + puVar2 = ssl->out_iv; + if ((pmVar1 != (mbedtls_ssl_transform *)0x0) && (1 < ssl->minor_ver)) { + puVar2 = puVar2 + (pmVar1->ivlen - pmVar1->fixed_ivlen); + } + ssl->out_msg = puVar2; + } + return; +} + + + +void ssl_calc_finished_tls_sha256(mbedtls_ssl_context *ssl,uchar *buf,int from) + +{ + mbedtls_ssl_session *pmVar1; + char *pcVar2; + uchar auStack180 [4]; + uchar padbuf [32]; + mbedtls_sha256_context sha256; + + pmVar1 = ssl->session_negotiate; + if (pmVar1 == (mbedtls_ssl_session *)0x0) { + pmVar1 = ssl->session; + } + mbedtls_sha256_init((mbedtls_sha256_context *)(padbuf + 0x1c)); + mbedtls_debug_print_msg(ssl,2,"file1",0x1356,"=> calc finished tls sha256"); + mbedtls_sha256_clone((mbedtls_sha256_context *)(padbuf + 0x1c),&ssl->handshake->fin_sha256); + mbedtls_debug_print_buf + (ssl,4,"file1",0x1362,"finished sha2 state",(uchar *)(sha256.total + 1),0x20); + if (from == 0) { + pcVar2 = "client finished"; + } + else { + pcVar2 = "server finished"; + } + mbedtls_sha256_finish((mbedtls_sha256_context *)(padbuf + 0x1c),auStack180); + (*ssl->handshake->tls_prf)(pmVar1->master,0x30,pcVar2,auStack180,0x20,buf,0xc); + mbedtls_debug_print_buf(ssl,3,"file1",0x136e,"calc finished result",buf,0xc); + mbedtls_sha256_free((mbedtls_sha256_context *)(padbuf + 0x1c)); + mbedtls_zeroize(auStack180,0x20); + mbedtls_debug_print_msg(ssl,2,"file1",0x1374,"<= calc finished"); + return; +} + + + +// WARNING: Variable defined which should be unmapped: sha256 + +void ssl_calc_verify_tls_sha256(mbedtls_ssl_context *ssl,uchar *hash) + +{ + undefined auStack132 [4]; + mbedtls_sha256_context sha256; + + mbedtls_sha256_init((mbedtls_sha256_context *)auStack132); + mbedtls_debug_print_msg(ssl,2,"file1",0x42d,"=> calc verify sha256"); + mbedtls_sha256_clone((mbedtls_sha256_context *)auStack132,&ssl->handshake->fin_sha256); + mbedtls_sha256_finish((mbedtls_sha256_context *)auStack132,hash); + mbedtls_debug_print_buf(ssl,3,"file1",0x432,"calculated verify result",hash,0x20); + mbedtls_debug_print_msg(ssl,2,"file1",0x433,"<= calc verify"); + mbedtls_sha256_free((mbedtls_sha256_context *)auStack132); + return; +} + + + +void ssl_flight_free(mbedtls_ssl_flight_item *flight) + +{ + mbedtls_ssl_flight_item *pmVar1; + + while (flight != (mbedtls_ssl_flight_item *)0x0) { + pmVar1 = flight->next; + vPortFree(flight->p); + vPortFree(flight); + flight = pmVar1; + } + return; +} + + + +int ssl_append_key_cert(mbedtls_ssl_key_cert **head,mbedtls_x509_crt *cert,mbedtls_pk_context *key) + +{ + mbedtls_ssl_key_cert *pmVar1; + int iVar2; + mbedtls_ssl_key_cert *pmVar3; + mbedtls_ssl_key_cert *pmVar4; + + pmVar1 = (mbedtls_ssl_key_cert *)mycalloc(1,0xc); + if (pmVar1 == (mbedtls_ssl_key_cert *)0x0) { + iVar2 = -0x7f00; + } + else { + pmVar1->cert = cert; + pmVar1->next = (mbedtls_ssl_key_cert *)0x0; + pmVar1->key = key; + pmVar3 = *head; + if (*head == (mbedtls_ssl_key_cert *)0x0) { + *head = pmVar1; + } + else { + do { + pmVar4 = pmVar3; + pmVar3 = pmVar4->next; + } while (pmVar3 != (mbedtls_ssl_key_cert *)0x0); + pmVar4->next = pmVar1; + } + iVar2 = 0; + } + return iVar2; +} + + + +void ssl_update_checksum_start(mbedtls_ssl_context *ssl,uchar *buf,size_t len) + +{ + mbedtls_sha256_update(&ssl->handshake->fin_sha256,buf,len); + return; +} + + + +void ssl_update_checksum_sha256(mbedtls_ssl_context *ssl,uchar *buf,size_t len) + +{ + mbedtls_sha256_update(&ssl->handshake->fin_sha256,buf,len); + return; +} + + + +size_t mbedtls_ssl_hdr_len(void) + +{ + int in_a0; + + if ((*(ushort *)(in_a0 + 0x74) & 2) != 0) { + return 0xd; + } + return 5; +} + + + +void ssl_set_timer(mbedtls_ssl_context *ssl,uint32_t millisecs) + +{ + if (ssl->f_set_timer != (mbedtls_ssl_set_timer_t_conflict1 *)0x0) { + mbedtls_debug_print_msg(ssl,3,"file1",0x52,"set_timer to %d ms",millisecs); + // WARNING: Could not recover jumptable at 0x230599f4. Too many branches + // WARNING: Treating indirect jump as call + (*ssl->f_set_timer)(ssl->p_timer,millisecs >> 2,millisecs); + return; + } + return; +} + + + +int ssl_check_timer(mbedtls_ssl_context *ssl) + +{ + int iVar1; + + if (ssl->f_get_timer == (mbedtls_ssl_get_timer_t *)0x0) { + return 0; + } + iVar1 = (*ssl->f_get_timer)(ssl->p_timer); + if (iVar1 == 2) { + mbedtls_debug_print_msg(ssl,3,"file1",0x60,"timer expired"); + iVar1 = -1; + } + else { + iVar1 = 0; + } + return iVar1; +} + + + +// WARNING: Variable defined which should be unmapped: tmp + +int tls_prf_sha256(uchar *secret,size_t slen,char *label,uchar *random,size_t rlen,uchar *dstbuf, + size_t dlen) + +{ + int iVar1; + uint uVar2; + uchar ilen; + mbedtls_md_info_t *md_info; + undefined3 extraout_var; + size_t __n; + int iVar3; + uchar *puVar4; + size_t sVar5; + size_t sVar6; + uint uVar7; + undefined auStack220 [4]; + mbedtls_md_context_t md_ctx; + uchar h_i [32]; + uchar tmp [128]; + + mbedtls_md_init((mbedtls_md_context_t *)auStack220); + md_info = mbedtls_md_info_from_type(MBEDTLS_MD_SHA256); + if (md_info == (mbedtls_md_info_t *)0x0) { + iVar3 = -0x6c00; + } + else { + ilen = mbedtls_md_get_size(md_info); + _ilen = CONCAT31(extraout_var,ilen); + __n = strlen(label); + if (__n + rlen + _ilen < 0x81) { + __n = strlen(label); + memcpy(h_i + _ilen + 0x1c,label,__n); + memcpy(h_i + _ilen + __n + 0x1c,random,rlen); + iVar3 = mbedtls_md_setup((mbedtls_md_context_t *)auStack220,md_info,1); + if (iVar3 == 0) { + mbedtls_md_hmac_starts((mbedtls_md_context_t *)auStack220,secret,slen); + mbedtls_md_hmac_update((mbedtls_md_context_t *)auStack220,h_i + _ilen + 0x1c,rlen + __n); + mbedtls_md_hmac_finish((mbedtls_md_context_t *)auStack220,h_i + 0x1c); + uVar2 = 0; + while (uVar7 = uVar2, uVar7 < dlen) { + mbedtls_md_hmac_reset((mbedtls_md_context_t *)auStack220); + mbedtls_md_hmac_update((mbedtls_md_context_t *)auStack220,h_i + 0x1c,rlen + __n + _ilen); + mbedtls_md_hmac_finish((mbedtls_md_context_t *)auStack220,(uchar *)&md_ctx.hmac_ctx); + mbedtls_md_hmac_reset((mbedtls_md_context_t *)auStack220); + mbedtls_md_hmac_update((mbedtls_md_context_t *)auStack220,h_i + 0x1c,_ilen); + mbedtls_md_hmac_finish((mbedtls_md_context_t *)auStack220,h_i + 0x1c); + sVar5 = _ilen; + if (dlen < _ilen + uVar7) { + sVar5 = dlen % _ilen; + } + sVar6 = 0; + while (uVar2 = _ilen + uVar7, sVar6 != sVar5) { + puVar4 = (uchar *)((int)&md_ctx.hmac_ctx + sVar6); + iVar1 = sVar6 + uVar7; + sVar6 = sVar6 + 1; + dstbuf[iVar1] = *puVar4; + } + } + mbedtls_md_free((mbedtls_md_context_t *)auStack220); + mbedtls_zeroize(h_i + 0x1c,0x80); + mbedtls_zeroize(&md_ctx.hmac_ctx,0x20); + } + } + else { + iVar3 = -0x7100; + } + } + return iVar3; +} + + + +int mbedtls_ssl_derive_keys(mbedtls_ssl_context *ssl) + +{ + mbedtls_cipher_type_t mVar1; + size_t __n; + mbedtls_ssl_transform *pmVar2; + mbedtls_cipher_context_t *ctx; + uchar uVar3; + mbedtls_cipher_info_t *cipher_info; + mbedtls_md_info_t *md_info; + undefined3 extraout_var; + size_t sVar4; + uint uVar5; + int line; + int line_00; + char *text; + size_t sVar6; + mbedtls_ssl_handshake_params *pmVar7; + uchar *buf; + uchar *buf_00; + mbedtls_cipher_context_t *ctx_00; + uchar *buf_01; + uchar *key; + mbedtls_ssl_session *pmVar8; + undefined auStack384 [4]; + uchar tmp [64]; + uchar keyblk [256]; + + pmVar2 = ssl->transform_negotiate; + pmVar8 = ssl->session_negotiate; + pmVar7 = ssl->handshake; + mbedtls_debug_print_msg(ssl,2,"file1",0x1f5,"=> derive keys"); + cipher_info = mbedtls_cipher_info_from_type(pmVar2->ciphersuite_info->cipher); + if (cipher_info == (mbedtls_cipher_info_t *)0x0) { + mVar1 = pmVar2->ciphersuite_info->cipher; + text = "cipher info for %d not found"; + line = 0x1fb; +LAB_23059c08: + mbedtls_debug_print_msg(ssl,1,"file1",line,text,(uint)mVar1); + return -0x7100; + } + md_info = mbedtls_md_info_from_type(pmVar2->ciphersuite_info->mac); + if (md_info == (mbedtls_md_info_t *)0x0) { + text = "mbedtls_md info for %d not found"; + mVar1 = pmVar2->ciphersuite_info->mac; + line = 0x203; + goto LAB_23059c08; + } + if (ssl->minor_ver != 3) { + line = 0x232; + goto LAB_23059cde; + } + pmVar7->tls_prf = tls_prf_sha256; + pmVar7->calc_verify = ssl_calc_verify_tls_sha256; + pmVar7->calc_finished = ssl_calc_finished_tls_sha256; + buf_01 = pmVar7->randbytes; + buf = pmVar8->master; + if (pmVar7->resume == 0) { + buf_00 = pmVar7->premaster; + mbedtls_debug_print_buf(ssl,3,"file1",0x243,"premaster secret",buf_00,pmVar7->pmslen); + line = (*pmVar7->tls_prf)(buf_00,pmVar7->pmslen,"master secret",buf_01,0x40,buf,0x30); + if (line != 0) { + text = "prf"; + line_00 = 0x275; + goto LAB_23059d46; + } + mbedtls_zeroize(buf_00,0x30); + } + else { + mbedtls_debug_print_msg(ssl,3,"file1",0x27c,"no premaster (session resumed)"); + } + memcpy(auStack384,buf_01,0x40); + memcpy(buf_01,tmp + 0x1c,0x20); + memcpy(pmVar7->randbytes + 0x20,auStack384,0x20); + mbedtls_zeroize(auStack384,0x40); + line = (*pmVar7->tls_prf)(buf,0x30,"key expansion",buf_01,0x40,tmp + 0x3c,0x100); + if (line != 0) { + text = "prf"; + line_00 = 0x296; + goto LAB_23059d46; + } + text = mbedtls_ssl_get_ciphersuite_name(pmVar8->ciphersuite); + mbedtls_debug_print_msg(ssl,3,"file1",0x29b,"ciphersuite = %s",text); + mbedtls_debug_print_buf(ssl,3,"file1",0x29c,"master secret",buf,0x30); + mbedtls_debug_print_buf(ssl,4,"file1",0x29d,"random bytes",buf_01,0x40); + mbedtls_debug_print_buf(ssl,4,"file1",0x29e,"key block",tmp + 0x3c,0x100); + mbedtls_zeroize(buf_01,0x40); + pmVar2->keylen = cipher_info->key_bitlen >> 3; + if ((cipher_info->mode + ~MBEDTLS_MODE_CTR & 0xfd) == 0) { + pmVar2->ivlen = 0xc; + pmVar2->fixed_ivlen = 4; + pmVar2->maclen = 0; + line = 8; + if ((pmVar2->ciphersuite_info->flags & 2) == 0) { + line = 0x10; + } + sVar6 = line + 8; +LAB_23059e78: + pmVar2->minlen = sVar6; + } + else { + line = mbedtls_md_setup(&pmVar2->md_ctx_enc,md_info,1); + if ((line != 0) || (line = mbedtls_md_setup(&pmVar2->md_ctx_dec,md_info,1), line != 0)) { + text = "mbedtls_md_setup"; + line_00 = 699; + goto LAB_23059d46; + } + uVar3 = mbedtls_md_get_size(md_info); + uVar5 = CONCAT31(extraout_var,uVar3); + pmVar2->maclen = uVar5; + sVar6 = cipher_info->iv_size; + pmVar2->ivlen = sVar6; + if (cipher_info->mode != MBEDTLS_MODE_STREAM) { + sVar4 = (uVar5 + cipher_info->block_size) - uVar5 % cipher_info->block_size; + pmVar2->minlen = sVar4; + if (1 < ssl->minor_ver - 2U) { + line = 0x2f7; + goto LAB_23059cde; + } + sVar6 = sVar6 + sVar4; + goto LAB_23059e78; + } + pmVar2->minlen = uVar5; + } + mbedtls_debug_print_msg + (ssl,3,"file1",0x2ff,"keylen: %d, minlen: %d, ivlen: %d, maclen: %d",pmVar2->keylen, + pmVar2->minlen,pmVar2->ivlen); + uVar5 = pmVar2->keylen; + __n = pmVar2->fixed_ivlen; + sVar6 = pmVar2->maclen; + line = sVar6 * 2; + if ((*(ushort *)&ssl->conf->field_0x74 & 1) == 0) { + key = tmp + 0x3c; + buf_00 = key + line; + buf = key + line + uVar5; + key = key + sVar6; + if (__n == 0) { + __n = pmVar2->ivlen; + } + memcpy(pmVar2->iv_enc,buf + uVar5,__n); + memcpy(pmVar2->iv_dec,buf + pmVar2->keylen + __n,__n); + buf_01 = tmp + 0x3c; + } + else { + buf_01 = tmp + 0x3c; + buf_00 = buf_01 + line + uVar5; + buf = buf_01 + line; + buf_01 = buf_01 + sVar6; + if (__n == 0) { + __n = pmVar2->ivlen; + } + memcpy(pmVar2->iv_dec,buf_00 + uVar5,__n); + memcpy(pmVar2->iv_enc,buf_00 + pmVar2->keylen + __n,__n); + key = tmp + 0x3c; + } + if (0 < ssl->minor_ver) { + mbedtls_md_hmac_starts(&pmVar2->md_ctx_enc,buf_01,pmVar2->maclen); + mbedtls_md_hmac_starts(&pmVar2->md_ctx_dec,key,pmVar2->maclen); + ctx_00 = &pmVar2->cipher_ctx_enc; + line = mbedtls_cipher_setup(ctx_00,cipher_info); + if (line == 0) { + ctx = &pmVar2->cipher_ctx_dec; + line = mbedtls_cipher_setup(ctx,cipher_info); + if (line == 0) { + line = mbedtls_cipher_setkey(ctx_00,buf_00,cipher_info->key_bitlen,MBEDTLS_ENCRYPT); + if (line == 0) { + line = mbedtls_cipher_setkey(ctx,buf,cipher_info->key_bitlen,MBEDTLS_DECRYPT); + if (line == 0) { + if (cipher_info->mode == MBEDTLS_MODE_CBC) { + line = mbedtls_cipher_set_padding_mode(ctx_00,MBEDTLS_PADDING_NONE); + if (line != 0) { + mbedtls_debug_print_ret(ssl,1,"file1",0x38e,"mbedtls_cipher_set_padding_mode",line); + return line; + } + line = mbedtls_cipher_set_padding_mode(ctx,MBEDTLS_PADDING_NONE); + if (line != 0) { + mbedtls_debug_print_ret(ssl,1,"file1",0x395,"mbedtls_cipher_set_padding_mode",line); + return line; + } + } + mbedtls_zeroize(tmp + 0x3c,0x100); + mbedtls_debug_print_msg(ssl,2,"file1",0x3bd,"<= derive keys"); + return 0; + } + text = "mbedtls_cipher_setkey"; + line_00 = 900; + } + else { + text = "mbedtls_cipher_setkey"; + line_00 = 0x37c; + } + } + else { + text = "mbedtls_cipher_setup"; + line_00 = 0x374; + } + } + else { + text = "mbedtls_cipher_setup"; + line_00 = 0x36d; + } +LAB_23059d46: + mbedtls_debug_print_ret(ssl,1,"file1",line_00,text,line); + return line; + } + line = 0x349; +LAB_23059cde: + mbedtls_debug_print_msg(ssl,1,"file1",line,"should never happen"); + return -0x6c00; +} + + + +int mbedtls_ssl_flush_output(mbedtls_ssl_context *ssl) + +{ + int ret; + size_t sVar1; + uint uVar2; + uchar uVar3; + size_t sVar4; + + mbedtls_debug_print_msg(ssl,2,"file1",0x98a,"=> flush output"); + if (ssl->f_send == (mbedtls_ssl_send_t *)0x0) { + mbedtls_debug_print_msg + (ssl,1,"file1",0x98f,"Bad usage of mbedtls_ssl_set_bio() or mbedtls_ssl_set_bio()"); + ret = -0x7100; + } + else { + if (ssl->out_left == 0) { + ret = 0x996; + } + else { + while (sVar4 = ssl->out_left, sVar4 != 0) { + sVar1 = mbedtls_ssl_hdr_len(); + mbedtls_debug_print_msg + (ssl,2,"file1",0x99d,"message length: %d, out_left: %d",ssl->out_msglen + sVar1, + sVar4); + sVar4 = mbedtls_ssl_hdr_len(); + ret = (*ssl->f_send)(ssl->p_bio,ssl->out_hdr + sVar4 + (ssl->out_msglen - ssl->out_left), + ssl->out_left); + mbedtls_debug_print_ret(ssl,2,"file1",0x9a3,"ssl->f_send",ret); + if (ret < 1) { + return ret; + } + ssl->out_left = ssl->out_left - ret; + } + uVar2 = 8; + while (((uint)*(ushort *)&ssl->conf->field_0x74 & 2) < uVar2) { + uVar3 = ssl->out_ctr[uVar2 - 1] + '\x01'; + ssl->out_ctr[uVar2 - 1] = uVar3; + if (uVar3 != '\0') break; + uVar2 = uVar2 - 1 & 0xff; + } + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + sVar4 = 2; + } + if (uVar2 == sVar4) { + mbedtls_debug_print_msg(ssl,1,"file1",0x9b2,"outgoing message counter would wrap"); + return -0x6b80; + } + ret = 0x9b6; + } + mbedtls_debug_print_msg(ssl,2,"file1",ret,"<= flush output"); + ret = 0; + } + return ret; +} + + + +void mbedtls_ssl_recv_flight_completed(mbedtls_ssl_context *ssl) + +{ + ssl_flight_free(ssl->handshake->flight); + ssl->handshake->flight = (mbedtls_ssl_flight_item *)0x0; + ssl->handshake->cur_msg = (mbedtls_ssl_flight_item *)0x0; + ssl->handshake->in_flight_start_seq = ssl->handshake->in_msg_seq; + ssl_set_timer(ssl,0); + if ((ssl->in_msgtype == 0x16) && (*ssl->in_msg == '\x14')) { + ssl->handshake->retransmit_state = '\x03'; + } + else { + ssl->handshake->retransmit_state = '\0'; + } + return; +} + + + +void mbedtls_ssl_send_flight_completed(mbedtls_ssl_context *ssl) + +{ + uchar uVar1; + + ssl->handshake->retransmit_timeout = ssl->conf->hs_timeout_min; + mbedtls_debug_print_msg + (ssl,3,"file1",0x87,"update timeout value to %d millisecs", + ssl->handshake->retransmit_timeout); + ssl_set_timer(ssl,ssl->handshake->retransmit_timeout); + if ((ssl->in_msgtype == 0x16) && (*ssl->in_msg == '\x14')) { + uVar1 = '\x03'; + } + else { + uVar1 = '\x02'; + } + ssl->handshake->retransmit_state = uVar1; + return; +} + + + +void mbedtls_ssl_update_handshake_status(mbedtls_ssl_context *ssl) + +{ + mbedtls_ssl_handshake_params *pmVar1; + + if ((ssl->state != 0x10) && (ssl->handshake != (mbedtls_ssl_handshake_params *)0x0)) { + (*ssl->handshake->update_checksum)(ssl,ssl->in_msg,ssl->in_hslen); + } + if (((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) && + (pmVar1 = ssl->handshake, pmVar1 != (mbedtls_ssl_handshake_params *)0x0)) { + pmVar1->in_msg_seq = pmVar1->in_msg_seq + 1; + } + return; +} + + + +void mbedtls_ssl_optimize_checksum + (mbedtls_ssl_context *ssl,mbedtls_ssl_ciphersuite_t *ciphersuite_info) + +{ + if (ciphersuite_info->mac != MBEDTLS_MD_SHA384) { + ssl->handshake->update_checksum = ssl_update_checksum_sha256; + return; + } + mbedtls_debug_print_msg(ssl,1,"file1",0x122e,"should never happen"); + return; +} + + + +void mbedtls_ssl_reset_checksum(mbedtls_ssl_context *ssl) + +{ + mbedtls_sha256_starts(&ssl->handshake->fin_sha256,0); + return; +} + + + +void mbedtls_ssl_session_init(mbedtls_ssl_session *session) + +{ + memset(session,0,0x74); + return; +} + + + +void mbedtls_ssl_init(mbedtls_ssl_context *ssl) + +{ + memset(ssl,0,0xc0); + return; +} + + + +void mbedtls_ssl_conf_authmode(mbedtls_ssl_config *conf,int authmode) + +{ + *(ushort *)&conf->field_0x74 = + *(ushort *)&conf->field_0x74 & 0xfff3 | (ushort)((authmode & 3U) << 2); + return; +} + + + +void mbedtls_ssl_conf_verify + (mbedtls_ssl_config *conf, + anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *f_vrfy,void *p_vrfy) + +{ + *(anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr **)&conf->f_vrfy = f_vrfy; + conf->p_vrfy = p_vrfy; + return; +} + + + +void mbedtls_ssl_conf_rng(mbedtls_ssl_config *conf,mbedtls_ssl_recv_t *f_rng,void *p_rng) + +{ + conf->f_rng = f_rng; + conf->p_rng = p_rng; + return; +} + + + +void mbedtls_ssl_set_bio(mbedtls_ssl_context *ssl,void *p_bio,mbedtls_ssl_send_t *f_send, + mbedtls_ssl_recv_t *f_recv, + mbedtls_ssl_recv_timeout_t_conflict1 *f_recv_timeout) + +{ + ssl->p_bio = p_bio; + ssl->f_send = f_send; + ssl->f_recv = f_recv; + ssl->f_recv_timeout = f_recv_timeout; + return; +} + + + +void mbedtls_ssl_conf_read_timeout(mbedtls_ssl_config *conf,uint32_t timeout) + +{ + conf->read_timeout = timeout; + return; +} + + + +int mbedtls_ssl_conf_own_cert + (mbedtls_ssl_config *conf,mbedtls_x509_crt *own_cert,mbedtls_pk_context *pk_key) + +{ + int iVar1; + + iVar1 = ssl_append_key_cert(&conf->key_cert,own_cert,pk_key); + return iVar1; +} + + + +void mbedtls_ssl_conf_ca_chain + (mbedtls_ssl_config *conf,mbedtls_x509_crt *ca_chain,mbedtls_x509_crl *ca_crl) + +{ + conf->ca_chain = ca_chain; + conf->ca_crl = ca_crl; + return; +} + + + +int mbedtls_ssl_set_hostname(mbedtls_ssl_context *ssl,char *hostname) + +{ + size_t __n; + char *__dest; + int iVar1; + + if (hostname == (char *)0x0) { + return -0x7100; + } + __n = strlen(hostname); + if (__n < 0x100) { + __dest = (char *)mycalloc(1,__n + 1); + ssl->hostname = __dest; + if (__dest == (char *)0x0) { + iVar1 = -0x7f00; + } + else { + memcpy(__dest,hostname,__n); + iVar1 = 0; + ssl->hostname[__n] = '\0'; + } + } + else { + iVar1 = -0x7100; + } + return iVar1; +} + + + +int mbedtls_ssl_conf_alpn_protocols(mbedtls_ssl_config *conf,char **protos) + +{ + char **ppcVar1; + uint uVar2; + size_t sVar3; + + uVar2 = 0; + ppcVar1 = protos; + while( true ) { + if (*ppcVar1 == (char *)0x0) { + conf->alpn_list = protos; + return 0; + } + sVar3 = strlen(*ppcVar1); + uVar2 = uVar2 + sVar3; + if ((0xfe < sVar3 - 1) || (0xffff < uVar2)) break; + ppcVar1 = ppcVar1 + 1; + } + return -0x7100; +} + + + +uint32_t mbedtls_ssl_get_verify_result(mbedtls_ssl_context *ssl) + +{ + mbedtls_ssl_session *pmVar1; + + pmVar1 = ssl->session; + if ((pmVar1 == (mbedtls_ssl_session *)0x0) && + (pmVar1 = ssl->session_negotiate, pmVar1 == (mbedtls_ssl_session *)0x0)) { + return 0xffffffff; + } + return pmVar1->verify_result; +} + + + +char * mbedtls_ssl_get_ciphersuite(mbedtls_ssl_context *ssl) + +{ + char *pcVar1; + + if ((ssl != (mbedtls_ssl_context *)0x0) && (ssl->session != (mbedtls_ssl_session *)0x0)) { + pcVar1 = mbedtls_ssl_get_ciphersuite_name(ssl->session->ciphersuite); + return pcVar1; + } + return (char *)0x0; +} + + + +char * mbedtls_ssl_get_version(mbedtls_ssl_context *ssl) + +{ + uint uVar1; + + uVar1 = ssl->minor_ver; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + if (uVar1 < 4) { + return *(char **)(CSWTCH_34 + uVar1 * 4); + } + return "unknown"; + } + if (uVar1 != 2) { + if (uVar1 != 3) { + return "unknown (DTLS)"; + } + return "DTLSv1.2"; + } + return "DTLSv1.0"; +} + + + +size_t mbedtls_ssl_get_record_expansion(mbedtls_ssl_context *param_1) + +{ + mbedtls_cipher_mode_t mVar1; + size_t sVar2; + size_t sVar3; + int iVar4; + mbedtls_cipher_info_t *pmVar5; + mbedtls_ssl_transform *pmVar6; + + pmVar6 = param_1->transform_out; + if (pmVar6 == (mbedtls_ssl_transform *)0x0) { + sVar2 = mbedtls_ssl_hdr_len(); + return sVar2; + } + pmVar5 = (pmVar6->cipher_ctx_enc).cipher_info; + if (pmVar5 == (mbedtls_cipher_info_t *)0x0) { +LAB_2305a542: + mbedtls_debug_print_msg(param_1,1,"file1",0x18cf,"should never happen"); + iVar4 = -0x6c00; + } + else { + mVar1 = pmVar5->mode; + if (mVar1 == MBEDTLS_MODE_CBC) { + sVar2 = pmVar6->maclen + pmVar5->block_size; + } + else { + if ((mVar1 < MBEDTLS_MODE_CBC) || (2 < (byte)(mVar1 + ~MBEDTLS_MODE_CTR))) goto LAB_2305a542; + sVar2 = pmVar6->minlen; + } + sVar3 = mbedtls_ssl_hdr_len(); + iVar4 = sVar3 + sVar2; + } + return iVar4; +} + + + +size_t mbedtls_ssl_get_max_frag_len(mbedtls_ssl_context *ssl) + +{ + uint uVar1; + + uVar1 = *(uint *)((int)mfl_code_to_length + (*(uint *)&ssl->conf->field_0x74 >> 4 & 0x1c)); + if ((ssl->session_out != (mbedtls_ssl_session *)0x0) && + (mfl_code_to_length[ssl->session_out->mfl_code] < uVar1)) { + uVar1 = mfl_code_to_length[ssl->session_out->mfl_code]; + } + return uVar1; +} + + + +mbedtls_x509_crt * mbedtls_ssl_get_peer_cert(mbedtls_ssl_context *ssl) + +{ + if ((ssl != (mbedtls_ssl_context *)0x0) && + (ssl = (mbedtls_ssl_context *)ssl->session, (mbedtls_x509_crt *)ssl != (mbedtls_x509_crt *)0x0) + ) { + ssl = (mbedtls_ssl_context *)(((mbedtls_x509_crt *)ssl)->issuer).val.len; + } + return (mbedtls_x509_crt *)ssl; +} + + + +int mbedtls_ssl_handshake_step(mbedtls_ssl_context *ssl) + +{ + int iVar1; + + if (ssl == (mbedtls_ssl_context *)0x0) { + return -0x7100; + } + if (ssl->conf == (mbedtls_ssl_config *)0x0) { + iVar1 = -0x7100; + } + else { + if (((*(ushort *)&ssl->conf->field_0x74 & 1) != 0) || + (iVar1 = mbedtls_ssl_handshake_client_step(ssl), (*(ushort *)&ssl->conf->field_0x74 & 1) != 0 + )) { + iVar1 = mbedtls_ssl_handshake_server_step(ssl); + return iVar1; + } + } + return iVar1; +} + + + +int mbedtls_ssl_handshake(mbedtls_ssl_context *ssl) + +{ + int iVar1; + + if ((ssl == (mbedtls_ssl_context *)0x0) || (ssl->conf == (mbedtls_ssl_config *)0x0)) { + iVar1 = -0x7100; + } + else { + mbedtls_debug_print_msg(ssl,2,"file1",0x1926,"=> handshake"); + do { + if (ssl->state == 0x10) { + iVar1 = 0; + break; + } + iVar1 = mbedtls_ssl_handshake_step(ssl); + } while (iVar1 == 0); + mbedtls_debug_print_msg(ssl,2,"file1",0x1930,"<= handshake"); + } + return iVar1; +} + + + +void mbedtls_ssl_transform_free(mbedtls_ssl_transform *transform) + +{ + if (transform != (mbedtls_ssl_transform *)0x0) { + mbedtls_cipher_free(&transform->cipher_ctx_enc); + mbedtls_cipher_free(&transform->cipher_ctx_dec); + mbedtls_md_free(&transform->md_ctx_enc); + mbedtls_md_free(&transform->md_ctx_dec); + mbedtls_zeroize(transform,0xd0); + return; + } + return; +} + + + +void mbedtls_ssl_handshake_free(mbedtls_ssl_handshake_params *handshake) + +{ + mbedtls_ssl_key_cert *pmVar1; + mbedtls_ssl_key_cert *pv; + + if (handshake != (mbedtls_ssl_handshake_params *)0x0) { + mbedtls_sha256_free(&handshake->fin_sha256); + pv = handshake->sni_key_cert; + while (pv != (mbedtls_ssl_key_cert *)0x0) { + pmVar1 = pv->next; + vPortFree(pv); + pv = pmVar1; + } + vPortFree(handshake->verify_cookie); + vPortFree(handshake->hs_msg); + ssl_flight_free(handshake->flight); + mbedtls_zeroize(handshake,0x15c); + return; + } + return; +} + + + +void ssl_handshake_wrapup_free_hs_transform(mbedtls_ssl_context *ssl) + +{ + mbedtls_ssl_transform *pmVar1; + + mbedtls_debug_print_msg(ssl,3,"file1",0x13af,"=> handshake wrapup: final free"); + mbedtls_ssl_handshake_free(ssl->handshake); + vPortFree(ssl->handshake); + ssl->handshake = (mbedtls_ssl_handshake_params *)0x0; + if (ssl->transform != (mbedtls_ssl_transform *)0x0) { + mbedtls_ssl_transform_free(ssl->transform); + vPortFree(ssl->transform); + } + pmVar1 = ssl->transform_negotiate; + ssl->transform_negotiate = (mbedtls_ssl_transform *)0x0; + ssl->transform = pmVar1; + mbedtls_debug_print_msg(ssl,3,"file1",0x13c3,"<= handshake wrapup: final free"); + return; +} + + + +void mbedtls_ssl_session_free(mbedtls_ssl_session *session) + +{ + if (session != (mbedtls_ssl_session *)0x0) { + if (session->peer_cert != (mbedtls_x509_crt *)0x0) { + mbedtls_x509_crt_free(session->peer_cert); + vPortFree(session->peer_cert); + } + vPortFree(session->ticket); + mbedtls_zeroize(session,0x74); + return; + } + return; +} + + + +void mbedtls_ssl_handshake_wrapup(mbedtls_ssl_context *ssl) + +{ + mbedtls_ssl_session *pmVar1; + anon_subr_int_void_ptr_mbedtls_ssl_session_ptr_for_f_set_cache *paVar2; + int iVar3; + + iVar3 = ssl->handshake->resume; + mbedtls_debug_print_msg(ssl,3,"file1",0x13ca,"=> handshake wrapup"); + if (ssl->session != (mbedtls_ssl_session *)0x0) { + mbedtls_ssl_session_free(ssl->session); + vPortFree(ssl->session); + } + pmVar1 = ssl->session_negotiate; + ssl->session_negotiate = (mbedtls_ssl_session *)0x0; + ssl->session = pmVar1; + paVar2 = ssl->conf->f_set_cache; + if ((((paVar2 != (anon_subr_int_void_ptr_mbedtls_ssl_session_ptr_for_f_set_cache *)0x0) && + (pmVar1->id_len != 0)) && (iVar3 == 0)) && + (iVar3 = (*paVar2)(ssl->conf->p_cache,pmVar1), iVar3 != 0)) { + mbedtls_debug_print_msg(ssl,1,"file1",0x13ed,"cache did not store session"); + } + if (((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) || + (ssl->handshake->flight == (mbedtls_ssl_flight_item *)0x0)) { + ssl_handshake_wrapup_free_hs_transform(ssl); + } + else { + ssl_set_timer(ssl,0); + mbedtls_debug_print_msg(ssl,3,"file1",0x13f9,"skip freeing handshake and transform"); + } + ssl->state = ssl->state + 1; + mbedtls_debug_print_msg(ssl,3,"file1",0x1401,"<= handshake wrapup"); + return; +} + + + +int ssl_handshake_init(mbedtls_ssl_context *ssl) + +{ + mbedtls_ssl_transform *__s; + mbedtls_ssl_handshake_params *__s_00; + mbedtls_ssl_session *pmVar1; + + if (ssl->transform_negotiate != (mbedtls_ssl_transform *)0x0) { + mbedtls_ssl_transform_free(ssl->transform_negotiate); + } + if (ssl->session_negotiate != (mbedtls_ssl_session *)0x0) { + mbedtls_ssl_session_free(ssl->session_negotiate); + } + if (ssl->handshake != (mbedtls_ssl_handshake_params *)0x0) { + mbedtls_ssl_handshake_free(ssl->handshake); + } + if (ssl->transform_negotiate == (mbedtls_ssl_transform *)0x0) { + __s = (mbedtls_ssl_transform *)mycalloc(1,0xd0); + ssl->transform_negotiate = __s; + } + if (ssl->session_negotiate == (mbedtls_ssl_session *)0x0) { + pmVar1 = (mbedtls_ssl_session *)mycalloc(1,0x74); + ssl->session_negotiate = pmVar1; + } + if (ssl->handshake == (mbedtls_ssl_handshake_params *)0x0) { + __s_00 = (mbedtls_ssl_handshake_params *)mycalloc(1,0x15c); + ssl->handshake = __s_00; + if (__s_00 == (mbedtls_ssl_handshake_params *)0x0) goto LAB_2305a8a6; + } + if ((ssl->transform_negotiate != (mbedtls_ssl_transform *)0x0) && + (ssl->session_negotiate != (mbedtls_ssl_session *)0x0)) { + mbedtls_ssl_session_init(ssl->session_negotiate); + __s = ssl->transform_negotiate; + memset(__s,0,0xd0); + mbedtls_cipher_init(&__s->cipher_ctx_enc); + mbedtls_cipher_init(&__s->cipher_ctx_dec); + mbedtls_md_init(&__s->md_ctx_enc); + mbedtls_md_init(&__s->md_ctx_dec); + __s_00 = ssl->handshake; + memset(__s_00,0,0x15c); + mbedtls_sha256_init(&__s_00->fin_sha256); + mbedtls_sha256_starts(&__s_00->fin_sha256,0); + __s_00->update_checksum = ssl_update_checksum_start; + __s_00->sig_alg = 2; + __s_00->sni_authmode = 3; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + return 0; + } + ssl->handshake->alt_transform_out = ssl->transform_out; + if ((*(ushort *)&ssl->conf->field_0x74 & 1) == 0) { + ssl->handshake->retransmit_state = '\0'; + } + else { + ssl->handshake->retransmit_state = '\x02'; + } + ssl_set_timer(ssl,0); + return 0; + } +LAB_2305a8a6: + mbedtls_debug_print_msg(ssl,1,"file1",0x152c,"alloc() of ssl sub-contexts failed"); + vPortFree(ssl->handshake); + vPortFree(ssl->transform_negotiate); + vPortFree(ssl->session_negotiate); + ssl->handshake = (mbedtls_ssl_handshake_params *)0x0; + ssl->transform_negotiate = (mbedtls_ssl_transform *)0x0; + ssl->session_negotiate = (mbedtls_ssl_session *)0x0; + return -0x7f00; +} + + + +int mbedtls_ssl_setup(mbedtls_ssl_context *ssl,mbedtls_ssl_config *conf) + +{ + uchar *puVar1; + int iVar2; + uchar *puVar3; + uchar *puVar4; + + ssl->conf = conf; + puVar1 = (uchar *)mycalloc(1,0x413d); + ssl->in_buf = puVar1; + if (puVar1 != (uchar *)0x0) { + puVar1 = (uchar *)mycalloc(1,0x413d); + ssl->out_buf = puVar1; + if (puVar1 != (uchar *)0x0) { + puVar4 = ssl->in_buf; + puVar3 = puVar1 + 0xd; + if ((*(ushort *)&conf->field_0x74 & 2) == 0) { + ssl->out_ctr = puVar1; + ssl->in_ctr = puVar4; + ssl->out_hdr = puVar1 + 8; + ssl->out_len = puVar1 + 0xb; + ssl->out_iv = puVar3; + ssl->out_msg = puVar3; + ssl->in_hdr = puVar4 + 8; + } + else { + ssl->out_hdr = puVar1; + ssl->in_hdr = puVar4; + ssl->out_ctr = puVar1 + 3; + ssl->out_len = puVar1 + 0xb; + ssl->out_iv = puVar3; + ssl->out_msg = puVar3; + ssl->in_ctr = puVar4 + 3; + } + ssl->in_len = puVar4 + 0xb; + ssl->in_iv = puVar4 + 0xd; + ssl->in_msg = puVar4 + 0xd; + iVar2 = ssl_handshake_init(ssl); + return iVar2; + } + } + mbedtls_debug_print_msg(ssl,1,"file1",0x1585,"alloc(%d bytes) failed",0x413d); + vPortFree(ssl->in_buf); + ssl->in_buf = (uchar *)0x0; + return -0x7f00; +} + + + +void mbedtls_ssl_free(mbedtls_ssl_context *ssl) + +{ + size_t n; + char *__s; + + if (ssl != (mbedtls_ssl_context *)0x0) { + mbedtls_debug_print_msg(ssl,2,"file1",0x1c0a,"=> free"); + if (ssl->out_buf != (uchar *)0x0) { + mbedtls_zeroize(ssl->out_buf,0x413d); + vPortFree(ssl->out_buf); + } + if (ssl->in_buf != (uchar *)0x0) { + mbedtls_zeroize(ssl->in_buf,0x413d); + vPortFree(ssl->in_buf); + } + if (ssl->transform != (mbedtls_ssl_transform *)0x0) { + mbedtls_ssl_transform_free(ssl->transform); + vPortFree(ssl->transform); + } + if (ssl->handshake != (mbedtls_ssl_handshake_params *)0x0) { + mbedtls_ssl_handshake_free(ssl->handshake); + mbedtls_ssl_transform_free(ssl->transform_negotiate); + mbedtls_ssl_session_free(ssl->session_negotiate); + vPortFree(ssl->handshake); + vPortFree(ssl->transform_negotiate); + vPortFree(ssl->session_negotiate); + } + if (ssl->session != (mbedtls_ssl_session *)0x0) { + mbedtls_ssl_session_free(ssl->session); + vPortFree(ssl->session); + } + __s = ssl->hostname; + if (__s != (char *)0x0) { + n = strlen(__s); + mbedtls_zeroize(__s,n); + vPortFree(ssl->hostname); + } + mbedtls_debug_print_msg(ssl,2,"file1",0x1c4b,"<= free"); + mbedtls_zeroize(ssl,0xc0); + return; + } + return; +} + + + +void mbedtls_ssl_config_init(mbedtls_ssl_config *conf) + +{ + memset(conf,0,0x78); + return; +} + + + +int mbedtls_ssl_config_defaults(mbedtls_ssl_config *conf,int endpoint,int transport,int preset) + +{ + ushort uVar1; + ushort uVar2; + ushort uVar3; + int *piVar4; + mbedtls_ecp_group_id *pmVar5; + + uVar1 = *(ushort *)&conf->field_0x74; + uVar3 = (ushort)endpoint & 1; + uVar2 = (ushort)((transport & 1U) << 1); + *(ushort *)&conf->field_0x74 = uVar1 & 0xfffc | uVar3 | uVar2; + if (endpoint == 0) { + *(ushort *)&conf->field_0x74 = uVar1 & 0xfdf0 | uVar3 | uVar2 | 0x208; + } + conf->hs_timeout_min = 1000; + conf->hs_timeout_max = 60000; + if (preset == 2) { + *(undefined4 *)&conf->max_major_ver = 0x3030303; + conf->ciphersuite_list[3] = (int *)0x4200d4a8; + conf->ciphersuite_list[2] = (int *)0x4200d4a8; + conf->ciphersuite_list[1] = (int *)0x4200d4a8; + conf->ciphersuite_list[0] = (int *)0x4200d4a8; + conf->cert_profile = &mbedtls_x509_crt_profile_suiteb; + conf->sig_hashes = ssl_preset_suiteb_hashes; + conf->curve_list = ssl_preset_suiteb_curves; + return 0; + } + *(undefined4 *)&conf->max_major_ver = 0x3030303; + if (transport == 1) { + conf->min_minor_ver = '\x02'; + } + piVar4 = mbedtls_ssl_list_ciphersuites(); + conf->cert_profile = &mbedtls_x509_crt_profile_default; + conf->ciphersuite_list[3] = piVar4; + conf->ciphersuite_list[2] = piVar4; + conf->ciphersuite_list[1] = piVar4; + conf->ciphersuite_list[0] = piVar4; + conf->sig_hashes = ssl_preset_default_hashes; + pmVar5 = mbedtls_ecp_grp_id_list(); + conf->curve_list = pmVar5; + return 0; +} + + + +void mbedtls_ssl_config_free(mbedtls_ssl_config *conf) + +{ + mbedtls_ssl_key_cert *pmVar1; + mbedtls_ssl_key_cert *pv; + + pv = conf->key_cert; + while (pv != (mbedtls_ssl_key_cert *)0x0) { + pmVar1 = pv->next; + vPortFree(pv); + pv = pmVar1; + } + mbedtls_zeroize(conf,0x78); + return; +} + + + +uchar mbedtls_ssl_sig_from_pk(mbedtls_pk_context *pk) + +{ + int iVar1; + + iVar1 = mbedtls_pk_can_do(pk,MBEDTLS_PK_RSA); + return (uchar)(iVar1 != 0); +} + + + +mbedtls_pk_type_t mbedtls_ssl_pk_alg_from_sig(uchar sig) + +{ + undefined3 in_register_00002029; + + return (mbedtls_pk_type_t)(CONCAT31(in_register_00002029,sig) == 1); +} + + + +mbedtls_md_type_t mbedtls_ssl_md_alg_from_hash(uchar hash) + +{ + uint uVar1; + + uVar1 = (uint)hash - 1 & 0xff; + if (uVar1 < 4) { + return *(mbedtls_md_type_t *)((int)&CSWTCH_35 + uVar1); + } + return MBEDTLS_MD_NONE; +} + + + +uchar mbedtls_ssl_hash_from_md_alg(int md) + +{ + if (md - 3U < 4) { + return *(uchar *)((int)&CSWTCH_35 + md + 1); + } + return '\0'; +} + + + +int mbedtls_ssl_check_curve(mbedtls_ssl_context *ssl,mbedtls_ecp_group_id grp_id) + +{ + undefined3 in_register_0000202d; + mbedtls_ecp_group_id *pmVar1; + + pmVar1 = ssl->conf->curve_list; + if (pmVar1 != (mbedtls_ecp_group_id *)0x0) { + while (*pmVar1 != MBEDTLS_ECP_DP_NONE) { + if ((uint)*pmVar1 == CONCAT31(in_register_0000202d,grp_id)) { + return 0; + } + pmVar1 = pmVar1 + 1; + } + } + return -1; +} + + + +int mbedtls_ssl_check_cert_usage + (mbedtls_x509_crt *cert,mbedtls_ssl_ciphersuite_t *ciphersuite,int cert_endpoint, + uint32_t *flags) + +{ + int iVar1; + int iVar2; + uint usage; + char *usage_oid; + uint uVar3; + + usage = 0x80; + if (cert_endpoint == 1) { + usage = 0; + if (ciphersuite->key_exchange < MBEDTLS_KEY_EXCHANGE_ECJPAKE) { + uVar3 = 1 << ((uint)ciphersuite->key_exchange & 0x1f); + usage = 0x20; + if (((uVar3 & 0x82) == 0) && (usage = 8, (uVar3 & 0x600) == 0)) { + usage = (uint)((uVar3 & 0x1c) != 0) << 7; + } + } + } + iVar1 = mbedtls_x509_crt_check_key_usage(cert,usage); + if (iVar1 != 0) { + *flags = *flags | 0x800; + iVar1 = -1; + } + if (cert_endpoint == 1) { + usage_oid = "+\x06\x01\x05\x05\a\x03\x01"; + } + else { + usage_oid = "+\x06\x01\x05\x05\a\x03\x02"; + } + iVar2 = mbedtls_x509_crt_check_extended_key_usage(cert,usage_oid,8); + if (iVar2 != 0) { + iVar1 = -1; + *flags = *flags | 0x1000; + } + return iVar1; +} + + + +void mbedtls_ssl_write_version(int major,int minor,int transport,uchar *ver) + +{ + uchar uVar1; + + uVar1 = (uchar)minor; + if (transport == 1) { + if (minor == 2) { + uVar1 = '\x01'; + } + *ver = ~((uchar)major - 2); + uVar1 = -uVar1; + } + else { + *ver = (uchar)major; + } + ver[1] = uVar1; + return; +} + + + +// WARNING: Variable defined which should be unmapped: add_data + +int mbedtls_ssl_write_record(mbedtls_ssl_context *ssl) + +{ + uchar uVar1; + mbedtls_cipher_mode_t mVar2; + int ret; + mbedtls_ssl_flight_item *pv; + size_t __n; + char *text; + int line; + mbedtls_ssl_flight_item *pmVar3; + mbedtls_ssl_flight_item *pmVar4; + mbedtls_cipher_info_t *pmVar5; + mbedtls_ssl_transform *pmVar6; + uint uVar7; + byte *pbVar8; + uchar *input; + undefined2 ilen; + uint uVar9; + size_t ilen_00; + size_t *in_fa0; + uchar *in_fa1; + uchar *extraout_fa1; + size_t in_fa2; + size_t sStack52; + size_t olen; + uchar add_data [13]; + + _ilen = ssl->out_msglen; + ilen = (undefined2)_ilen; + mbedtls_debug_print_msg(ssl,2,"file1",0xaa7,"=> write record"); + if (((((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) || + (ssl->handshake == (mbedtls_ssl_handshake_params *)0x0)) || + (ssl->handshake->retransmit_state != '\x01')) && (ssl->out_msgtype == 0x16)) { + uVar1 = *ssl->out_msg; + if ((uVar1 != '\0') && (ssl->handshake == (mbedtls_ssl_handshake_params *)0x0)) { + mbedtls_debug_print_msg(ssl,1,"file1",0xab9,"should never happen"); + return -0x6c00; + } + __n = _ilen - 4; + ssl->out_msg[1] = (uchar)(__n >> 0x10); + ssl->out_msg[2] = (uchar)(__n >> 8); + ssl->out_msg[3] = (uchar)__n; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + _ilen = _ilen + 8; + memmove(ssl->out_msg + 0xc,ssl->out_msg + 4,__n); + ssl->out_msglen = ssl->out_msglen + 8; + if (uVar1 == '\0') { + ssl->out_msg[4] = '\0'; + ssl->out_msg[5] = '\0'; + } + else { + ssl->out_msg[4] = (uchar)(ssl->handshake->out_msg_seq >> 8); + ssl->out_msg[5] = (uchar)ssl->handshake->out_msg_seq; + ssl->handshake->out_msg_seq = ssl->handshake->out_msg_seq + 1; + } + memset(ssl->out_msg + 6,0,3); + memcpy(ssl->out_msg + 9,ssl->out_msg + 1,3); + } + ilen = (undefined2)_ilen; + if (uVar1 != '\0') { + in_fa0 = (size_t *)(*ssl->handshake->update_checksum)(ssl,ssl->out_msg,_ilen); + in_fa1 = extraout_fa1; + } + } + if ((((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) && + (ssl->handshake != (mbedtls_ssl_handshake_params *)0x0)) && + ((ssl->handshake->retransmit_state != '\x01' && ((ssl->out_msgtype & 0xfffffffdU) == 0x14)))) { + pv = (mbedtls_ssl_flight_item *)mycalloc(1,0x10); + if (pv == (mbedtls_ssl_flight_item *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x9ca,"alloc %d bytes failed",0x10); +LAB_2305af0c: + mbedtls_debug_print_ret(ssl,1,"file1",0xaf1,"ssl_flight_append",-0x7f00); + return -0x7f00; + } + input = (uchar *)mycalloc(1,ssl->out_msglen); + pv->p = input; + if (input == (uchar *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x9d0,"alloc %d bytes failed"); + vPortFree(pv); + goto LAB_2305af0c; + } + memcpy(input,ssl->out_msg,ssl->out_msglen); + pv->len = ssl->out_msglen; + line = ssl->out_msgtype; + pv->next = (mbedtls_ssl_flight_item *)0x0; + pv->type = (uchar)line; + pmVar3 = ssl->handshake->flight; + if (pmVar3 == (mbedtls_ssl_flight_item *)0x0) { + ssl->handshake->flight = pv; + } + else { + do { + pmVar4 = pmVar3; + pmVar3 = pmVar4->next; + } while (pmVar3 != (mbedtls_ssl_flight_item *)0x0); + pmVar4->next = pv; + } + } + *ssl->out_hdr = (uchar)ssl->out_msgtype; + mbedtls_ssl_write_version + (ssl->major_ver,ssl->minor_ver,*(uint *)&ssl->conf->field_0x74 >> 1 & 1,ssl->out_hdr + 1 + ); + *ssl->out_len = (uchar)((ushort)ilen >> 8); + ssl->out_len[1] = (uchar)ilen; + if (ssl->transform_out == (mbedtls_ssl_transform *)0x0) { +LAB_2305b3e0: + _ilen = mbedtls_ssl_hdr_len(); + ssl->out_left = _ilen + ssl->out_msglen; + pbVar8 = ssl->out_hdr; + mbedtls_debug_print_msg + (ssl,3,"file1",0xb30,"output record: msgtype = %d, version = [%d:%d], msglen = %d", + (uint)*pbVar8,(uint)pbVar8[1],(uint)pbVar8[2]); + _ilen = mbedtls_ssl_hdr_len(); + mbedtls_debug_print_buf + (ssl,4,"file1",0xb33,"output record sent to network",ssl->out_hdr, + ssl->out_msglen + _ilen); + ret = mbedtls_ssl_flush_output(ssl); + if (ret == 0) { + mbedtls_debug_print_msg(ssl,2,"file1",0xb3c,"<= write record"); + return 0; + } + text = "mbedtls_ssl_flush_output"; + line = 0xb38; + goto LAB_2305b256; + } + mbedtls_debug_print_msg(ssl,2,"file1",0x504,"=> encrypt buf"); + if ((ssl->session_out == (mbedtls_ssl_session *)0x0) || + (ssl->transform_out == (mbedtls_ssl_transform *)0x0)) { + line = 0x508; +LAB_2305b000: + mbedtls_debug_print_msg(ssl,1,"file1",line,"should never happen"); + ret = -0x6c00; + } + else { + pmVar5 = (ssl->transform_out->cipher_ctx_enc).cipher_info; + mVar2 = MBEDTLS_MODE_NONE; + if (pmVar5 != (mbedtls_cipher_info_t *)0x0) { + mVar2 = pmVar5->mode; + } + mbedtls_debug_print_buf + (ssl,4,"file1",0x50f,"before encrypt: output payload",ssl->out_msg,ssl->out_msglen); + if ((mVar2 == MBEDTLS_MODE_STREAM) || (line = 0, mVar2 == MBEDTLS_MODE_CBC)) { + if (ssl->minor_ver < 1) { + line = 0x536; + goto LAB_2305b000; + } + mbedtls_md_hmac_update(&ssl->transform_out->md_ctx_enc,ssl->out_ctr,8); + mbedtls_md_hmac_update(&ssl->transform_out->md_ctx_enc,ssl->out_hdr,3); + mbedtls_md_hmac_update(&ssl->transform_out->md_ctx_enc,ssl->out_len,2); + line = 1; + mbedtls_md_hmac_update(&ssl->transform_out->md_ctx_enc,ssl->out_msg,ssl->out_msglen); + mbedtls_md_hmac_finish(&ssl->transform_out->md_ctx_enc,ssl->out_msg + ssl->out_msglen); + mbedtls_md_hmac_reset(&ssl->transform_out->md_ctx_enc); + mbedtls_debug_print_buf + (ssl,4,"file1",0x53c,"computed mac",ssl->out_msg + ssl->out_msglen, + ssl->transform_out->maclen); + ssl->out_msglen = ssl->out_msglen + ssl->transform_out->maclen; + } + if ((mVar2 + ~MBEDTLS_MODE_CTR & 0xfd) != 0) { + if (mVar2 != MBEDTLS_MODE_CBC) { + line = 0x627; + goto LAB_2305b000; + } + olen = 0; + uVar7 = ssl->transform_out->ivlen; + uVar9 = uVar7 - (ssl->out_msglen + 1) % uVar7; + if (uVar7 == uVar9) { + uVar9 = 0; + } + uVar7 = 0; + do { + ssl->out_msg[ssl->out_msglen + uVar7] = (uchar)uVar9; + uVar7 = uVar7 + 1; + } while (uVar7 <= uVar9); + _ilen = ssl->out_msglen + 1 + uVar9; + ssl->out_msglen = _ilen; + if (1 < ssl->minor_ver) { + ret = (*ssl->conf->f_rng)(ssl->conf->p_rng,ssl->transform_out->iv_enc, + ssl->transform_out->ivlen); + if (ret == 0) { + memcpy(ssl->out_iv,ssl->transform_out->iv_enc,ssl->transform_out->ivlen); + _ilen = ssl->out_msglen; + input = ssl->out_msg; + ssl->out_msglen = ssl->transform_out->ivlen + _ilen; + goto LAB_2305b304; + } + goto LAB_2305b246; + } + input = ssl->out_msg; +LAB_2305b304: + mbedtls_debug_print_msg + (ssl,3,"file1",0x5e3, + "before encrypt: msglen = %d, including %d bytes of IV and %d bytes of padding", + ssl->out_msglen,ssl->transform_out->ivlen,uVar9 + 1); + pmVar6 = ssl->transform_out; + ret = mbedtls_cipher_crypt + (&pmVar6->cipher_ctx_enc,pmVar6->iv_enc,pmVar6->ivlen,input,_ilen,input,&olen) + ; + if (ret != 0) { + text = "mbedtls_cipher_crypt"; + line = 0x5eb; + goto LAB_2305b23a; + } + if (_ilen == olen) goto LAB_2305b2a0; + line = 0x5f1; + goto LAB_2305b000; + } + _ilen = 8; + if ((ssl->transform_out->ciphersuite_info->flags & 2) == 0) { + _ilen = 0x10; + } + memcpy(&olen,ssl->out_ctr,8); + add_data[4] = (uchar)ssl->out_msgtype; + mbedtls_ssl_write_version + (ssl->major_ver,ssl->minor_ver,*(uint *)&ssl->conf->field_0x74 >> 1 & 1,add_data + 5); + add_data[7] = (uchar)(ssl->out_msglen >> 8); + add_data[8] = (uchar)ssl->out_msglen; + mbedtls_debug_print_buf(ssl,4,"file1",0x575,"additional data used for AEAD",(uchar *)&olen,0xd); + pmVar6 = ssl->transform_out; + if (pmVar6->ivlen - 8 != pmVar6->fixed_ivlen) { + line = 0x57d; + goto LAB_2305b000; + } + memcpy(pmVar6->iv_enc + pmVar6->fixed_ivlen,ssl->out_ctr,8); + memcpy(ssl->out_iv,ssl->out_ctr,8); + mbedtls_debug_print_buf + (ssl,4,"file1",0x586,"IV used",ssl->out_iv, + ssl->transform_out->ivlen - ssl->transform_out->fixed_ivlen); + ilen_00 = ssl->out_msglen; + input = ssl->out_msg; + ssl->out_msglen = (ssl->transform_out->ivlen + ilen_00) - ssl->transform_out->fixed_ivlen; + mbedtls_debug_print_msg + (ssl,3,"file1",0x592,"before encrypt: msglen = %d, including %d bytes of padding",0); + pmVar6 = ssl->transform_out; + ret = mbedtls_cipher_auth_encrypt + (&pmVar6->cipher_ctx_enc,pmVar6->iv_enc,pmVar6->ivlen,(uchar *)&olen,0xd,input, + ilen_00,input,in_fa0,in_fa1,in_fa2); + if (ret == 0) { + if (ilen_00 != sStack52) { + line = 0x5a5; + goto LAB_2305b000; + } + ssl->out_msglen = ssl->out_msglen + _ilen; + line = line + 1; + mbedtls_debug_print_buf(ssl,4,"file1",0x5ac,"after encrypt: tag",input + ilen_00,_ilen); +LAB_2305b2a0: + if (line == 1) { + mbedtls_debug_print_msg(ssl,2,"file1",0x632,"<= encrypt buf"); + _ilen = ssl->out_msglen; + *ssl->out_len = (uchar)(_ilen >> 8); + ssl->out_len[1] = (uchar)_ilen; + goto LAB_2305b3e0; + } + line = 0x62e; + goto LAB_2305b000; + } + text = "mbedtls_cipher_auth_encrypt"; + line = 0x59f; +LAB_2305b23a: + mbedtls_debug_print_ret(ssl,1,"file1",line,text,ret); + } +LAB_2305b246: + text = "ssl_encrypt_buf"; + line = 0xb22; +LAB_2305b256: + mbedtls_debug_print_ret(ssl,1,"file1",line,text,ret); + return ret; +} + + + +int mbedtls_ssl_resend(mbedtls_ssl_context *ssl) + +{ + mbedtls_ssl_flight_item *pmVar1; + int ret; + mbedtls_ssl_handshake_params *pmVar2; + + mbedtls_debug_print_msg(ssl,2,"file1",0xa39,"=> mbedtls_ssl_resend"); + if (ssl->handshake->retransmit_state != '\x01') { + mbedtls_debug_print_msg(ssl,2,"file1",0xa3d,"initialise resending"); + ssl->handshake->cur_msg = ssl->handshake->flight; + ssl_swap_epochs(ssl); + ssl->handshake->retransmit_state = '\x01'; + } + do { + pmVar2 = ssl->handshake; + pmVar1 = pmVar2->cur_msg; + if (pmVar1 == (mbedtls_ssl_flight_item *)0x0) { + if (ssl->state == 0x10) { + pmVar2->retransmit_state = '\x03'; + } + else { + pmVar2->retransmit_state = '\x02'; + ssl_set_timer(ssl,ssl->handshake->retransmit_timeout); + } + mbedtls_debug_print_msg(ssl,2,"file1",0xa6a,"<= mbedtls_ssl_resend"); + return 0; + } + if ((pmVar1->type == '\x16') && (*pmVar1->p == '\x14')) { + ssl_swap_epochs(ssl); + } + memcpy(ssl->out_msg,pmVar1->p,pmVar1->len); + ssl->out_msglen = pmVar1->len; + ssl->out_msgtype = (uint)pmVar1->type; + ssl->handshake->cur_msg = pmVar1->next; + mbedtls_debug_print_buf(ssl,3,"file1",0xa59,"resent handshake message header",ssl->out_msg,0xc); + ret = mbedtls_ssl_write_record(ssl); + } while (ret == 0); + mbedtls_debug_print_ret(ssl,1,"file1",0xa5d,"mbedtls_ssl_write_record",ret); + return ret; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +int mbedtls_ssl_fetch_input(mbedtls_ssl_context *ssl,size_t nb_want) + +{ + void *pvVar1; + int iVar2; + int ret; + uint uVar3; + char *format; + size_t ret_00; + uint uVar4; + uint uVar5; + uint32_t uVar6; + + mbedtls_debug_print_msg(ssl,2,"file1",0x8ba,"=> fetch input"); + if ((ssl->f_recv == (mbedtls_ssl_recv_t *)0x0) && + (ssl->f_recv_timeout == (mbedtls_ssl_recv_timeout_t_conflict1 *)0x0)) { + format = "Bad usage of mbedtls_ssl_set_bio() or mbedtls_ssl_set_bio()"; + ret = 0x8bf; +LAB_2305b62c: + mbedtls_debug_print_msg(ssl,1,"file1",ret,format); + return -0x7100; + } + if (0x413dU - (int)(ssl->in_hdr + -(int)ssl->in_buf) < nb_want) { + format = "requesting more data than fits"; + ret = 0x8c5; + goto LAB_2305b62c; + } + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + mbedtls_debug_print_msg(ssl,2,"file1",0x958,"in_left: %d, nb_want: %d",ssl->in_left,nb_want); + while (uVar5 = ssl->in_left, uVar5 < nb_want) { + iVar2 = ssl_check_timer(ssl); + ret = -0x6800; + if (iVar2 == 0) { + if (ssl->f_recv_timeout == (mbedtls_ssl_recv_timeout_t_conflict1 *)0x0) { + ret = (*ssl->f_recv)(ssl->f_recv); + } + else { + ret = (*ssl->f_recv_timeout) + (ssl->p_bio,ssl->in_hdr + ssl->in_left,nb_want - uVar5, + ssl->conf->read_timeout); + } + } + mbedtls_debug_print_msg(ssl,2,"file1",0x970,"in_left: %d, nb_want: %d",ssl->in_left,nb_want); + mbedtls_debug_print_ret(ssl,2,"file1",0x971,"ssl->f_recv(_timeout)",ret); + if (ret == 0) { + return -0x7280; + } + if (ret < 0) { + return ret; + } + ssl->in_left = ret + ssl->in_left; + } + } + else { + if ((ssl->f_set_timer == (mbedtls_ssl_set_timer_t_conflict1 *)0x0) || + (ssl->f_get_timer == (mbedtls_ssl_get_timer_t *)0x0)) { + format = "You must use mbedtls_ssl_set_timer_cb() for DTLS"; + ret = 0x8d2; + goto LAB_2305b62c; + } + uVar5 = ssl->next_record_offset; + if (uVar5 != 0) { + if (ssl->in_left < uVar5) { + ret = 0x8e4; + goto LAB_2305b6ba; + } + ret_00 = ssl->in_left - uVar5; + ssl->in_left = ret_00; + if (ret_00 != 0) { + mbedtls_debug_print_msg(ssl,2,"file1",0x8ed,"next record in same datagram, offset: %d"); + memmove(ssl->in_hdr,ssl->in_hdr + ssl->next_record_offset,ssl->in_left); + } + ssl->next_record_offset = 0; + } + mbedtls_debug_print_msg(ssl,2,"file1",0x8f7,"in_left: %d, nb_want: %d",ssl->in_left,nb_want); + if (nb_want <= ssl->in_left) { + ret = 0x8fe; + goto LAB_2305b72e; + } + if (ssl->in_left != 0) { + ret = 0x909; +LAB_2305b6ba: + mbedtls_debug_print_msg(ssl,1,"file1",ret,"should never happen"); + return -0x6c00; + } + ret = ssl_check_timer(ssl); + if (ret != 0) { +LAB_2305b756: + mbedtls_debug_print_msg(ssl,2,"file1",0x92d,"timeout"); + ssl_set_timer(ssl,0); + if (ssl->state != 0x10) { + uVar3 = ssl->handshake->retransmit_timeout; + uVar5 = ssl->conf->hs_timeout_max; + if (uVar3 < uVar5) { + uVar4 = uVar3 << 1; + if ((uVar3 <= uVar4) && (uVar4 < uVar5)) { + uVar5 = uVar4; + } + ssl->handshake->retransmit_timeout = uVar5; + mbedtls_debug_print_msg + (ssl,3,"file1",0x7e,"update timeout value to %d millisecs", + ssl->handshake->retransmit_timeout); + ret = mbedtls_ssl_resend(ssl); + if (ret == 0) { + return -0x6900; + } + mbedtls_debug_print_ret(ssl,1,"file1",0x93a,"mbedtls_ssl_resend",ret); + return ret; + } + mbedtls_debug_print_msg(ssl,1,"file1",0x934,"handshake timeout"); + } + return -0x6800; + } + pvVar1 = (void *)(0x413d - (int)(ssl->in_hdr + -(int)ssl->in_buf)); + if (ssl->state == 0x10) { + uVar6 = ssl->conf->read_timeout; + } + else { + uVar6 = ssl->handshake->retransmit_timeout; + } + mbedtls_debug_print_msg(ssl,3,"file1",0x91d,"f_recv_timeout: %u ms",uVar6); + if (ssl->f_recv_timeout == (mbedtls_ssl_recv_timeout_t_conflict1 *)0x0) { + ret_00 = (*ssl->f_recv)(pvVar1,(uchar *)ssl->f_recv); + } + else { + ret_00 = (*ssl->f_recv_timeout)(ssl->p_bio,ssl->in_hdr,(size_t)pvVar1,uVar6); + } + mbedtls_debug_print_ret(ssl,2,"file1",0x925,"ssl->f_recv(_timeout)",ret_00); + if (ret_00 == 0) { + return -0x7280; + } + if (ret_00 == 0xffff9800) goto LAB_2305b756; + if ((int)ret_00 < 0) { + return ret_00; + } + ssl->in_left = ret_00; + } + ret = 0x97d; +LAB_2305b72e: + mbedtls_debug_print_msg(ssl,2,"file1",ret,"<= fetch input"); + return 0; +} + + + +int mbedtls_ssl_prepare_handshake_record(mbedtls_ssl_context *ssl) + +{ + byte bVar1; + uint uVar2; + uchar *__s1; + int line; + size_t __n; + uint uVar3; + mbedtls_ssl_handshake_params *pmVar4; + uint __n_00; + int line_00; + uint uVar5; + byte *pbVar6; + char *format; + uint uVar7; + size_t size; + uint uVar8; + uint uVar9; + size_t sVar10; + uchar *puVar11; + uint uVar12; + uchar *puVar13; + + uVar3 = 0xc; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + uVar3 = 4; + } + if (ssl->in_msglen < uVar3) { + mbedtls_debug_print_msg(ssl,1,"file1",0xc20,"handshake message too short: %d"); + return -0x7200; + } + pbVar6 = ssl->in_msg; + ssl->in_hslen = ((uint)pbVar6[1] << 0x10 | (uint)pbVar6[2] << 8 | (uint)pbVar6[3]) + uVar3; + mbedtls_debug_print_msg + (ssl,3,"file1",0xc2b,"handshake message: msglen = %d, type = %d, hslen = %d", + (uint)*pbVar6); + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + if (ssl->in_hslen <= ssl->in_msglen) { + return 0; + } + mbedtls_debug_print_msg(ssl,1,"file1",0xc69,"TLS handshake fragmentation not supported"); + return -0x7080; + } + pmVar4 = ssl->handshake; + __s1 = ssl->in_msg; + if (pmVar4 != (mbedtls_ssl_handshake_params *)0x0) { + uVar3 = (uint)(*(ushort *)(__s1 + 4) >> 8) | ((uint)*(ushort *)(__s1 + 4) & 0xff) << 8; + if (pmVar4->in_msg_seq != uVar3) { + __n_00 = pmVar4->in_flight_start_seq - 1; + if ((__n_00 != uVar3) || (*__s1 == '\x03')) { + mbedtls_debug_print_msg + (ssl,2,"file1",0xc4d, + "dropping out-of-sequence message: message_seq = %d, expected = %d", + pmVar4->in_msg_seq); + return -0x6900; + } + mbedtls_debug_print_msg + (ssl,2,"file1",0xc40, + "received message from last flight, message_seq = %d, start_of_flight = %d",__n_00) + ; + line = mbedtls_ssl_resend(ssl); + if (line == 0) { + return -0x6900; + } + format = "mbedtls_ssl_resend"; + line_00 = 0xc44; + goto LAB_2305ba60; + } + } + if (((ssl->in_hslen <= ssl->in_msglen) && (line = memcmp(__s1 + 6,&DAT_23088e44,3), line == 0)) && + (line = memcmp(ssl->in_msg + 9,ssl->in_msg + 1,3), line == 0)) { + if (ssl->handshake == (mbedtls_ssl_handshake_params *)0x0) { + return 0; + } + if (ssl->handshake->hs_msg == (uchar *)0x0) { + return 0; + } + } + mbedtls_debug_print_msg(ssl,2,"file1",0xc5b,"found fragmented DTLS handshake message"); + sVar10 = ssl->in_hslen; + uVar3 = sVar10 - 0xc; + if (ssl->handshake == (mbedtls_ssl_handshake_params *)0x0) { + format = "not supported outside handshake (for now)"; + line = 0xb8f; +LAB_2305bace: + mbedtls_debug_print_msg(ssl,1,"file1",line,format); + line = -0x7080; + } + else { + __s1 = ssl->handshake->hs_msg; + if (__s1 != (uchar *)0x0) { + line = memcmp(__s1,ssl->in_msg,4); + if (line == 0) goto LAB_2305bbca; + mbedtls_debug_print_msg(ssl,1,"file1",0xbb9,"fragment header mismatch"); + goto LAB_2305bc4c; + } + mbedtls_debug_print_msg(ssl,2,"file1",0xb9b,"initialize reassembly, total length = %d",uVar3); + if (0x4000 < ssl->in_hslen) { + format = "handshake message too large"; + line = 0xb9f; + goto LAB_2305bace; + } + size = (uint)((uVar3 & 7) != 0) + (uVar3 >> 3) + sVar10; + pmVar4 = ssl->handshake; + __s1 = (uchar *)mycalloc(1,size); + pmVar4->hs_msg = __s1; + __s1 = ssl->handshake->hs_msg; + if (__s1 == (uchar *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0xba9,"alloc failed (%d bytes)",size); + line = -0x7f00; + goto LAB_2305bae0; + } + memcpy(__s1,ssl->in_msg,6); + memset(ssl->handshake->hs_msg + 6,0,3); + __s1 = ssl->handshake->hs_msg; + memcpy(__s1 + 9,__s1 + 1,3); +LAB_2305bbca: + puVar13 = ssl->handshake->hs_msg; + __s1 = ssl->in_msg; + puVar11 = puVar13 + sVar10; + bVar1 = __s1[8]; + uVar9 = (uint)__s1[6] << 0x10 | (uint)__s1[7] << 8 | (uint)bVar1; + __n_00 = (uint)__s1[9] << 0x10 | (uint)__s1[10] << 8 | (uint)__s1[0xb]; + if (uVar3 < uVar9 + __n_00) { + mbedtls_debug_print_msg + (ssl,1,"file1",0xbce,"invalid fragment offset/len: %d + %d > %d",uVar9,__n_00,uVar3) + ; + } + else { + uVar12 = __n_00 + 0xc; + if (uVar12 <= ssl->in_msglen) { + mbedtls_debug_print_msg + (ssl,2,"file1",0xbda,"adding fragment, offset = %d, length = %d",uVar9,__n_00); + memcpy(puVar13 + uVar9 + 0xc,ssl->in_msg + 0xc,__n_00); + uVar5 = (uint)bVar1 & 7; + uVar8 = 8 - uVar5; + if (uVar8 == 8) { +LAB_2305bd4a: + uVar5 = __n_00 & 7; + if (uVar5 != 0) { + uVar7 = __n_00 + uVar9; + uVar8 = (uint)puVar11[uVar7 >> 3]; + __n_00 = __n_00 - uVar5; + uVar5 = 8 - uVar5; + do { + uVar2 = uVar5 & 0x1f; + uVar5 = uVar5 + 1; + uVar8 = uVar8 | 1 << uVar2 & 0xffU; + } while (uVar5 != 8); + puVar11[uVar7 >> 3] = (byte)uVar8; + } + memset(puVar11 + (uVar9 >> 3),0xff,__n_00 >> 3); + } + else { + uVar7 = uVar9 >> 3; + if (uVar8 < __n_00) { + __n_00 = (__n_00 - 8) + uVar5; + uVar5 = (uint)puVar11[uVar7]; + uVar9 = uVar9 + uVar8; + do { + uVar8 = uVar8 - 1; + uVar5 = uVar5 | 1 << (uVar8 & 0x1f) & 0xffU; + } while (uVar8 != 0); + puVar11[uVar7] = (byte)uVar5; + goto LAB_2305bd4a; + } + __n_00 = uVar8 - __n_00; + while (__n_00 != uVar8) { + uVar9 = __n_00 & 0x1f; + __n_00 = __n_00 + 1; + puVar11[uVar7] = (byte)(1 << uVar9) | puVar11[uVar7]; + } + } + __n_00 = 0; + while (__n_00 != uVar3 >> 3) { + if (puVar11[__n_00] != -1) goto LAB_2305be72; + __n_00 = __n_00 + 1; + } + uVar9 = 0; + while (uVar9 < (uVar3 & 7)) { + if (((int)(uint)puVar11[__n_00] >> (7 - uVar9 & 0x1f) & 1U) == 0) goto LAB_2305be72; + uVar9 = uVar9 + 1; + } + mbedtls_debug_print_msg(ssl,2,"file1",0xbe9,"handshake message completed"); + if (ssl->in_msglen <= uVar12) { + uVar3 = ssl->next_record_offset; + if (ssl->in_left <= uVar3) { +LAB_2305be0a: + memcpy(ssl->in_msg,ssl->handshake->hs_msg,ssl->in_hslen); + vPortFree(ssl->handshake->hs_msg); + ssl->handshake->hs_msg = (uchar *)0x0; + mbedtls_debug_print_buf + (ssl,3,"file1",0xc15,"reassembled handshake message",ssl->in_msg,ssl->in_hslen + ); + return 0; + } + puVar13 = ssl->in_hdr; + __n = ssl->in_left - uVar3; + __s1 = ssl->in_msg + ssl->in_hslen; + puVar11 = __s1 + -(int)puVar13; + *(uchar **)&ssl->next_record_offset = puVar11; + *(uchar **)&ssl->in_left = puVar11 + __n; + if (puVar11 + __n <= (uchar *)(0x413d - (int)(puVar13 + -(int)ssl->in_buf))) { + memmove(__s1,puVar13 + uVar3,__n); + goto LAB_2305be0a; + } + mbedtls_debug_print_msg(ssl,1,"file1",0xc08,"reassembled message too large for buffer"); + line = -0x6a00; + goto LAB_2305bae0; + } + format = "last fragment not alone in its record"; + line = 0xbf2; + goto LAB_2305bace; + } + mbedtls_debug_print_msg(ssl,1,"file1",0xbd5,"invalid fragment length: %d + 12 > %d",__n_00); + } +LAB_2305bc4c: + line = -0x7200; + } +LAB_2305bae0: + format = "ssl_reassemble_dtls_handshake"; + line_00 = 0xc5f; +LAB_2305ba60: + mbedtls_debug_print_ret(ssl,1,"file1",line_00,format,line); + return line; +LAB_2305be72: + mbedtls_debug_print_msg(ssl,2,"file1",0xbe5,"message is not complete yet"); + line = -0x6900; + goto LAB_2305bae0; +} + + + +int mbedtls_ssl_handle_message_type(mbedtls_ssl_context *ssl) + +{ + int iVar1; + uchar *puVar2; + + if ((ssl->in_msgtype == 0x16) && (iVar1 = mbedtls_ssl_prepare_handshake_record(ssl), iVar1 != 0)) + { + return iVar1; + } + if (ssl->in_msgtype == 0x15) { + mbedtls_debug_print_msg + (ssl,2,"file1",0xf93,"got an alert message, type: [%d:%d]",(uint)*ssl->in_msg, + (uint)ssl->in_msg[1]); + puVar2 = ssl->in_msg; + if (*puVar2 == '\x02') { + mbedtls_debug_print_msg + (ssl,1,"file1",0xf9b,"is a fatal alert message (msg %d)",(uint)puVar2[1]); + return -0x7780; + } + if (*puVar2 == '\x01') { + if (puVar2[1] == '\0') { + mbedtls_debug_print_msg(ssl,2,"file1",0xfa2,"is a close notify message"); + return -0x7880; + } + if (puVar2[1] == 'd') { + mbedtls_debug_print_msg(ssl,2,"file1",0xfaa,"is a SSLv3 no_cert"); + goto LAB_2305beb0; + } + } + iVar1 = -0x6680; + } + else { +LAB_2305beb0: + iVar1 = 0; + } + return iVar1; +} + + + +int mbedtls_ssl_send_alert_message(mbedtls_ssl_context *ssl,uchar level,uchar message) + +{ + int ret; + + if ((ssl == (mbedtls_ssl_context *)0x0) || (ssl->conf == (mbedtls_ssl_config *)0x0)) { + ret = -0x7100; + } + else { + mbedtls_debug_print_msg(ssl,2,"file1",0xfda,"=> send alert message"); + ssl->out_msgtype = 0x15; + ssl->out_msglen = 2; + *ssl->out_msg = level; + ssl->out_msg[1] = message; + ret = mbedtls_ssl_write_record(ssl); + if (ret == 0) { + mbedtls_debug_print_msg(ssl,2,"file1",0xfe7,"<= send alert message"); + } + else { + mbedtls_debug_print_ret(ssl,1,"file1",0xfe3,"mbedtls_ssl_write_record",ret); + } + } + return ret; +} + + + +int mbedtls_ssl_send_fatal_handshake_failure(mbedtls_ssl_context *ssl) + +{ + int iVar1; + + iVar1 = mbedtls_ssl_send_alert_message(ssl,'\x02','('); + return iVar1; +} + + + +int mbedtls_ssl_close_notify(mbedtls_ssl_context *ssl) + +{ + int ret; + + if ((ssl == (mbedtls_ssl_context *)0x0) || (ssl->conf == (mbedtls_ssl_config *)0x0)) { + ret = -0x7100; + } + else { + mbedtls_debug_print_msg(ssl,2,"file1",0x1b68,"=> write close notify"); + if (ssl->out_left != 0) { + ret = mbedtls_ssl_flush_output(ssl); + return ret; + } + if ((ssl->state == 0x10) && (ret = mbedtls_ssl_send_alert_message(ssl,'\x01','\0'), ret != 0)) { + mbedtls_debug_print_ret(ssl,1,"file1",0x1b73,"mbedtls_ssl_send_alert_message",ret); + } + else { + mbedtls_debug_print_msg(ssl,2,"file1",0x1b78,"<= write close notify"); + ret = 0; + } + } + return ret; +} + + + +int mbedtls_ssl_write_certificate(mbedtls_ssl_context *ssl) + +{ + int ret; + mbedtls_x509_crt *crt; + size_t sVar1; + uint __n; + mbedtls_ssl_ciphersuite_t *pmVar2; + + pmVar2 = ssl->transform_negotiate->ciphersuite_info; + mbedtls_debug_print_msg(ssl,2,"file1",0x1025,"=> write certificate"); + __n = (uint)pmVar2->key_exchange - 5; + if (((__n & 0xff) < 7) && ((0x4bU >> (__n & 0x1f) & 1) != 0)) { + mbedtls_debug_print_msg(ssl,2,"file1",0x102c,"<= skip write certificate"); + ret = 0; + ssl->state = ssl->state + 1; + } + else { + if ((*(ushort *)&ssl->conf->field_0x74 & 1) == 0) { + if (ssl->client_auth == 0) { + mbedtls_debug_print_msg(ssl,2,"file1",0x1036,"<= skip write certificate"); + ssl->state = ssl->state + 1; + return 0; + } + } + else { + crt = mbedtls_ssl_own_cert(ssl); + if (crt == (mbedtls_x509_crt *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x1053,"got no certificate to send"); + return -0x7580; + } + } + crt = mbedtls_ssl_own_cert(ssl); + mbedtls_debug_print_crt(ssl,3,"file1",0x1059,"own certificate",crt); + crt = mbedtls_ssl_own_cert(ssl); + sVar1 = 7; + while (crt != (mbedtls_x509_crt *)0x0) { + __n = (crt->raw).len; + if (0x3ffd - sVar1 < __n) { + mbedtls_debug_print_msg(ssl,1,"file1",0x106d,"certificate too large, %d > %d",0x4000); + return -0x7500; + } + ssl->out_msg[sVar1] = (uchar)(__n >> 0x10); + ssl->out_msg[sVar1 + 1] = (uchar)(__n >> 8); + ssl->out_msg[sVar1 + 2] = (uchar)__n; + memcpy(ssl->out_msg + sVar1 + 3,(crt->raw).p,__n); + crt = crt->next; + sVar1 = sVar1 + 3 + __n; + } + ret = sVar1 - 7; + ssl->out_msg[4] = (uchar)((uint)ret >> 0x10); + ssl->out_msg[5] = (uchar)((uint)ret >> 8); + ssl->out_msg[6] = (uchar)ret; + ssl->out_msgtype = 0x16; + ssl->out_msglen = sVar1; + *ssl->out_msg = '\v'; + ssl->state = ssl->state + 1; + ret = mbedtls_ssl_write_record(ssl); + if (ret == 0) { + mbedtls_debug_print_msg(ssl,2,"file1",0x108d,"<= write certificate"); + } + else { + mbedtls_debug_print_ret(ssl,1,"file1",0x1089,"mbedtls_ssl_write_record",ret); + } + } + return ret; +} + + + +int mbedtls_ssl_write_change_cipher_spec(mbedtls_ssl_context *ssl) + +{ + int ret; + + mbedtls_debug_print_msg(ssl,2,"file1",0x11b4,"=> write change cipher spec"); + ssl->out_msgtype = 0x14; + ssl->out_msglen = 1; + *ssl->out_msg = '\x01'; + ssl->state = ssl->state + 1; + ret = mbedtls_ssl_write_record(ssl); + if (ret == 0) { + mbedtls_debug_print_msg(ssl,2,"file1",0x11c2,"<= write change cipher spec"); + } + else { + mbedtls_debug_print_ret(ssl,1,"file1",0x11be,"mbedtls_ssl_write_record",ret); + } + return ret; +} + + + +int mbedtls_ssl_write_finished(mbedtls_ssl_context *ssl) + +{ + uchar *puVar1; + uchar uVar2; + int ret; + + mbedtls_debug_print_msg(ssl,2,"file1",0x1408,"=> write finished"); + puVar1 = ssl->out_iv; + if (1 < ssl->minor_ver) { + puVar1 = puVar1 + (ssl->transform_negotiate->ivlen - ssl->transform_negotiate->fixed_ivlen); + } + ssl->out_msg = puVar1; + (*ssl->handshake->calc_finished)(ssl,puVar1 + 4,*(uint *)&ssl->conf->field_0x74 & 1); + ret = 0x24; + if (ssl->minor_ver != 0) { + ret = 0xc; + } + ssl->out_msglen = ret + 4; + ssl->out_msgtype = 0x16; + *ssl->out_msg = '\x14'; + if (ssl->handshake->resume == 0) { + ret = ssl->state + 1; + } + else { + if (((*(ushort *)&ssl->conf->field_0x74 & 1) == 0) && + (ssl->state = 0xf, (*(ushort *)&ssl->conf->field_0x74 & 1) == 0)) goto LAB_2305c40a; + ret = 10; + } + ssl->state = ret; +LAB_2305c40a: + mbedtls_debug_print_msg(ssl,3,"file1",0x143e,"switching to new transform spec for outbound data"); + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + memset(ssl->out_ctr,0,8); + } + else { + ssl->handshake->alt_transform_out = ssl->transform_out; + memcpy(ssl->handshake->alt_out_ctr,ssl->out_ctr,8); + memset(ssl->out_ctr + 2,0,6); + uVar2 = ssl->out_ctr[1] + '\x01'; + ssl->out_ctr[1] = uVar2; + if ((uVar2 == '\0') && (uVar2 = *ssl->out_ctr + '\x01', *ssl->out_ctr = uVar2, uVar2 == '\0')) { + mbedtls_debug_print_msg(ssl,1,"file1",0x1454,"DTLS epoch would wrap"); + return -0x6b80; + } + } + ssl->transform_out = ssl->transform_negotiate; + ssl->session_out = ssl->session_negotiate; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + mbedtls_ssl_send_flight_completed(ssl); + } + ret = mbedtls_ssl_write_record(ssl); + if (ret == 0) { + mbedtls_debug_print_msg(ssl,2,"file1",0x1475,"<= write finished"); + } + else { + mbedtls_debug_print_ret(ssl,1,"file1",0x1471,"mbedtls_ssl_write_record",ret); + } + return ret; +} + + + +int mbedtls_ssl_write(mbedtls_ssl_context *ssl,uchar *buf,size_t len) + +{ + size_t sVar1; + int line; + size_t sVar2; + uint uVar3; + char *text; + + mbedtls_debug_print_msg(ssl,2,"file1",0x1b3d,"=> write"); + if ((ssl == (mbedtls_ssl_context *)0x0) || (ssl->conf == (mbedtls_ssl_config *)0x0)) { + return -0x7100; + } + if ((ssl->state != 0x10) && (line = mbedtls_ssl_handshake(ssl), line != 0)) { + mbedtls_debug_print_ret(ssl,1,"file1",0x1b4e,"mbedtls_ssl_handshake",line); + return line; + } + sVar2 = mbedtls_ssl_get_max_frag_len(ssl); + sVar1 = len; + if ((sVar2 < len) && (sVar1 = sVar2, (*(ushort *)&ssl->conf->field_0x74 & 2) != 0)) { + text = "fragment larger than the (negotiated) maximum fragment length: %d > %d"; + line = 0x1ae7; +LAB_2305c5bc: + mbedtls_debug_print_msg(ssl,1,"file1",line,text,len,sVar2); + len = 0xffff8f00; + } + else { + len = sVar1; + if (ssl->out_left == 0) { + sVar2 = 0x4130; + if (0x4130 < len) { + text = "input larger than the out msg maximum length: 0x%x > 0x%x"; + line = 0x1afe; + goto LAB_2305c5bc; + } + ssl->out_msgtype = 0x17; + ssl->out_msglen = len; + memcpy(ssl->out_msg,buf,len); + uVar3 = mbedtls_ssl_write_record(ssl); + if (uVar3 == 0) goto LAB_2305c5ce; + text = "mbedtls_ssl_write_record"; + line = 0x1b08; + len = uVar3; + } + else { + uVar3 = mbedtls_ssl_flush_output(ssl); + if (uVar3 == 0) goto LAB_2305c5ce; + text = "mbedtls_ssl_flush_output"; + line = 0x1af4; + len = uVar3; + } + mbedtls_debug_print_ret(ssl,1,"file1",line,text,len); + } +LAB_2305c5ce: + mbedtls_debug_print_msg(ssl,2,"file1",0x1b59,"<= write"); + return len; +} + + + +void mbedtls_ssl_read_version(int *major,int *minor,int transport,uchar *ver) + +{ + uint uVar1; + + if (transport == 1) { + *major = 0x101 - (uint)*ver; + uVar1 = 0x100 - (uint)ver[1]; + if (uVar1 == 1) { + uVar1 = 2; + } + } + else { + *major = (uint)*ver; + uVar1 = (uint)ver[1]; + } + *minor = uVar1; + return; +} + + + +int mbedtls_ssl_read_record_layer(mbedtls_ssl_context *ssl) + +{ + bool bVar1; + size_t nb_want; + size_t len; + uint uVar2; + uint uVar3; + uint uVar4; + size_t __n; + uint uVar5; + int line; + mbedtls_cipher_info_t *pmVar6; + mbedtls_cipher_mode_t mVar7; + byte bVar8; + char *format; + uchar uVar9; + mbedtls_ssl_transform *pmVar10; + byte *pbVar11; + uint uVar12; + uint uVar13; + int line_00; + uint ret; + uchar *input; + uint uVar14; + size_t *in_fa0; + uchar *in_fa1; + size_t in_fa2; + size_t sStack116; + int major_ver; + int minor_ver; + uchar auStack103 [2]; + undefined uStack101; + undefined uStack100; + + uVar4 = ssl->in_hslen; + if ((uVar4 == 0) || (ssl->in_msglen <= uVar4)) { + ssl->in_hslen = 0; + while( true ) { + nb_want = mbedtls_ssl_hdr_len(); + line_00 = mbedtls_ssl_fetch_input(ssl,nb_want); + if (line_00 != 0) break; + nb_want = mbedtls_ssl_hdr_len(); + mbedtls_debug_print_buf(ssl,4,"file1",0xdb1,"input record header",ssl->in_hdr,nb_want); + ssl->in_msgtype = (uint)*ssl->in_hdr; + ssl->in_msglen = + (uint)(*(ushort *)ssl->in_len >> 8) | ((uint)*(ushort *)ssl->in_len & 0xff) << 8; + mbedtls_ssl_read_version + ((int *)&sStack116,&major_ver,*(uint *)&ssl->conf->field_0x74 >> 1 & 1, + ssl->in_hdr + 1); + mbedtls_debug_print_msg + (ssl,3,"file1",0xdba,"input record: msgtype = %d, version = [%d:%d], msglen = %d", + ssl->in_msgtype,sStack116,major_ver); + line_00 = ssl->in_msgtype; + if (line_00 - 0x14U < 4) { + if (ssl->major_ver != sStack116) { + format = "major version mismatch"; + line_00 = 0xdd1; +LAB_2305c86e: + mbedtls_debug_print_msg(ssl,1,"file1",line_00,format); + goto LAB_2305c81a; + } + if ((int)(uint)ssl->conf->max_minor_ver < major_ver) { + format = "minor version mismatch"; + line_00 = 0xdd7; + goto LAB_2305c86e; + } + uVar4 = ssl->in_msglen; + if (0x413dU - (int)(ssl->in_msg + -(int)ssl->in_buf) < uVar4) { + format = "bad message length"; + line_00 = 0xddf; + goto LAB_2305c86e; + } + if (ssl->transform_in != (mbedtls_ssl_transform *)0x0) { + ret = ssl->transform_in->minlen; + if (uVar4 < ret) { + format = "bad message length"; + line_00 = 0xdf1; + } + else { + if ((ssl->minor_ver < 1) || (uVar4 <= ret + 0x4100)) goto LAB_2305c902; + format = "bad message length"; + line_00 = 0xe06; + } + goto LAB_2305c86e; + } + if (0x3fff < uVar4 - 1) { + format = "bad message length"; + line_00 = 0xde9; + goto LAB_2305c86e; + } +LAB_2305c902: + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + if (line_00 == 0x14) { + if ((ssl->state - 10U & 0xfffffffd) != 0) { + format = "dropping unexpected ChangeCipherSpec"; + line_00 = 0xe1c; + goto LAB_2305c948; + } +LAB_2305c978: + if ((((uint)*(ushort *)ssl->in_ctr & 0xff) << 8 | (uint)(*(ushort *)ssl->in_ctr >> 8)) + == (uint)ssl->in_epoch) goto LAB_2305c99c; + mbedtls_debug_print_msg + (ssl,1,"file1",0xe33,"record from another epoch: expected %d, received %d"); + } + else { + if ((line_00 != 0x17) || (ssl->state == 0x10)) goto LAB_2305c978; + format = "dropping unexpected ApplicationData"; + line_00 = 0xe2a; +LAB_2305c948: + mbedtls_debug_print_msg(ssl,1,"file1",line_00,format); + } + line_00 = -0x6700; + goto LAB_2305c820; + } +LAB_2305c99c: + nb_want = mbedtls_ssl_hdr_len(); + line_00 = mbedtls_ssl_fetch_input(ssl,nb_want + uVar4); + if (line_00 != 0) { + format = "mbedtls_ssl_fetch_input"; + line = 0xf11; + goto LAB_2305c75a; + } + nb_want = ssl->in_msglen; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + ssl->in_left = 0; + } + else { + len = mbedtls_ssl_hdr_len(); + ssl->next_record_offset = len + nb_want; + } + len = mbedtls_ssl_hdr_len(); + mbedtls_debug_print_buf + (ssl,4,"file1",0xe63,"input record from network",ssl->in_hdr,len + nb_want); + if (ssl->transform_in == (mbedtls_ssl_transform *)0x0) { +LAB_2305d038: + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + return 0; + } + if (ssl->handshake == (mbedtls_ssl_handshake_params *)0x0) { + return 0; + } + if (ssl->state != 0x10) { + return 0; + } + if ((ssl->in_msgtype != 0x16) || (*ssl->in_msg != '\x14')) { + ssl_handshake_wrapup_free_hs_transform(ssl); + return 0; + } + mbedtls_debug_print_msg(ssl,2,"file1",0xf6d,"received retransmit of last flight"); + line_00 = mbedtls_ssl_resend(ssl); + if (line_00 == 0) { + return -0x6900; + } + format = "mbedtls_ssl_resend"; + line = 0xf71; + goto LAB_2305c75a; + } + mbedtls_debug_print_msg(ssl,2,"file1",0x642,"=> decrypt buf"); + if ((ssl->session_in == (mbedtls_ssl_session *)0x0) || + (pmVar10 = ssl->transform_in, pmVar10 == (mbedtls_ssl_transform *)0x0)) { + line_00 = 0x646; +LAB_2305ca46: + mbedtls_debug_print_msg(ssl,1,"file1",line_00,"should never happen"); + ret = 0xffff9400; +LAB_2305ce16: + mbedtls_debug_print_ret(ssl,1,"file1",0xe79,"ssl_decrypt_buf",ret); + } + else { + pmVar6 = (pmVar10->cipher_ctx_dec).cipher_info; + mVar7 = MBEDTLS_MODE_NONE; + if (pmVar6 != (mbedtls_cipher_info_t *)0x0) { + mVar7 = pmVar6->mode; + } + nb_want = ssl->in_msglen; + if (nb_want < pmVar10->minlen) { + format = "in_msglen (%d) < minlen (%d)"; + line_00 = 0x64f; +LAB_2305ca86: + mbedtls_debug_print_msg(ssl,1,"file1",line_00,format,nb_want); +LAB_2305cbe4: + ret = 0xffff8e80; + goto LAB_2305ce16; + } + if ((mVar7 + ~MBEDTLS_MODE_CTR & 0xfd) != 0) { + if (mVar7 == MBEDTLS_MODE_CBC) { + major_ver = 0; + ret = pmVar10->ivlen; + uVar4 = ret; + if (ssl->minor_ver < 2) { + uVar4 = 0; + } + if ((nb_want < uVar4 + ret) || (nb_want < pmVar10->maclen + 1 + uVar4)) { + format = "msglen (%d) < max( ivlen(%d), maclen (%d) + 1 ) ( + expl IV )"; + line_00 = 0x6d2; + goto LAB_2305cacc; + } + uVar4 = nb_want % ret; + if (uVar4 != 0) { + format = "msglen (%d) %% ivlen (%d) != 0"; + line_00 = 0x70b; + goto LAB_2305ca86; + } + input = ssl->in_msg; + if (1 < ssl->minor_ver) { + nb_want = nb_want - ret; + ssl->in_msglen = nb_want; + ret = 0; + while (ret < ssl->transform_in->ivlen) { + ssl->transform_in->iv_dec[ret] = ssl->in_iv[ret]; + ret = ret + 1; + } + } + pmVar10 = ssl->transform_in; + ret = mbedtls_cipher_crypt + (&pmVar10->cipher_ctx_dec,pmVar10->iv_dec,pmVar10->ivlen,input,nb_want + ,input,(size_t *)&major_ver); + if (ret != 0) { + mbedtls_debug_print_ret(ssl,1,"file1",0x723,"mbedtls_cipher_crypt",ret); + goto LAB_2305ce16; + } + if (nb_want == major_ver) { + uVar5 = ssl->in_msglen; + nb_want = ssl->transform_in->maclen; + uVar13 = (uint)ssl->in_msg[uVar5 - 1] + 1; + bVar1 = uVar13 + nb_want <= uVar5; + if (!bVar1) { + uVar13 = 0; + } + if (0 < ssl->minor_ver) { + uVar2 = (uVar5 - 1) - uVar13; + uVar12 = ((uint)(uVar5 < uVar13 + 1) ^ 1) & (uint)(uVar2 < nb_want + 0x4000) & + (uint)bVar1; + uVar14 = 1; + uVar3 = 1; + do { + uVar14 = uVar14 & ((uint)(uVar13 < uVar3) ^ 1); + line_00 = uVar2 * uVar12 + uVar3; + uVar3 = uVar3 + 1; + uVar4 = uVar4 + ((uint)ssl->in_msg[line_00] == uVar13 - 1) * uVar14; + } while (uVar3 != 0x101); + uVar12 = uVar13 == uVar4 & uVar12; + uVar13 = uVar12 * 0x1ff & uVar13; + ssl->in_msglen = uVar5 - uVar13; + goto LAB_2305cc06; + } + line_00 = 0x783; + } + else { + line_00 = 0x729; + } + } + else { + line_00 = 0x78d; + } + goto LAB_2305ca46; + } + len = 8; + if ((pmVar10->ciphersuite_info->flags & 2) == 0) { + len = 0x10; + } + if (nb_want < (pmVar10->ivlen - pmVar10->fixed_ivlen) + len) { + format = "msglen (%d) < explicit_iv_len (%d) + taglen (%d)"; + line_00 = 0x67f; +LAB_2305cacc: + mbedtls_debug_print_msg(ssl,1,"file1",line_00,format,nb_want); + goto LAB_2305cbe4; + } + nb_want = ((nb_want + pmVar10->fixed_ivlen) - pmVar10->ivlen) - len; + ssl->in_msglen = nb_want; + input = ssl->in_msg; + memcpy(&major_ver,ssl->in_ctr,8); + mbedtls_ssl_write_version + (ssl->major_ver,ssl->minor_ver,*(uint *)&ssl->conf->field_0x74 >> 1 & 1, + auStack103); + uStack101 = (undefined)(ssl->in_msglen >> 8); + uStack100 = (undefined)ssl->in_msglen; + mbedtls_debug_print_buf + (ssl,4,"file1",0x690,"additional data used for AEAD",(uchar *)&major_ver,0xd); + pmVar10 = ssl->transform_in; + memcpy(pmVar10->iv_dec + pmVar10->fixed_ivlen,ssl->in_iv, + pmVar10->ivlen - pmVar10->fixed_ivlen); + mbedtls_debug_print_buf + (ssl,4,"file1",0x697,"IV used",ssl->transform_in->iv_dec, + ssl->transform_in->ivlen); + mbedtls_debug_print_buf(ssl,4,"file1",0x698,"TAG used",input + nb_want,len); + pmVar10 = ssl->transform_in; + ret = mbedtls_cipher_auth_decrypt + (&pmVar10->cipher_ctx_dec,pmVar10->iv_dec,pmVar10->ivlen, + (uchar *)&major_ver,0xd,input,nb_want,input,in_fa0,in_fa1,in_fa2); + if (ret != 0) { + mbedtls_debug_print_ret(ssl,1,"file1",0x6a5,"mbedtls_cipher_auth_decrypt",ret); + if (ret == 0xffff9d00) goto LAB_2305cbe4; + goto LAB_2305ce16; + } + if (nb_want != sStack116) { + line_00 = 0x6b0; + goto LAB_2305ca46; + } + uVar12 = 1; + uVar13 = 0; + ret = 1; +LAB_2305cc06: + mbedtls_debug_print_buf + (ssl,4,"file1",0x792,"raw buffer after decryption",ssl->in_msg,ssl->in_msglen); + if (ret == 0) { + nb_want = ssl->in_msglen - ssl->transform_in->maclen; + ssl->in_msglen = nb_want; + *ssl->in_len = (uchar)(nb_want >> 8); + ssl->in_len[1] = (uchar)ssl->in_msglen; + memcpy(&major_ver,ssl->in_msg + ssl->in_msglen,ssl->transform_in->maclen); + if (ssl->minor_ver < 1) { + line_00 = 0x7d6; + goto LAB_2305ca46; + } + uVar4 = ssl->in_msglen + 0x15; + mbedtls_md_hmac_update(&ssl->transform_in->md_ctx_dec,ssl->in_ctr,8); + mbedtls_md_hmac_update(&ssl->transform_in->md_ctx_dec,ssl->in_hdr,3); + mbedtls_md_hmac_update(&ssl->transform_in->md_ctx_dec,ssl->in_len,2); + mbedtls_md_hmac_update(&ssl->transform_in->md_ctx_dec,ssl->in_msg,ssl->in_msglen); + mbedtls_md_hmac_finish(&ssl->transform_in->md_ctx_dec,ssl->in_msg + ssl->in_msglen); + ret = 0; + do { + mbedtls_md_process(&ssl->transform_in->md_ctx_dec,ssl->in_msg); + ret = ret + 1; + } while (ret < (uVar12 * 0xff & (uVar13 + uVar4 >> 6) - (uVar4 >> 6)) + 1); + mbedtls_md_hmac_reset(&ssl->transform_in->md_ctx_dec); + mbedtls_debug_print_buf + (ssl,4,"file1",0x7da,"message mac",(uchar *)&major_ver, + ssl->transform_in->maclen); + mbedtls_debug_print_buf + (ssl,4,"file1",0x7dc,"computed mac",ssl->in_msg + ssl->in_msglen, + ssl->transform_in->maclen); + bVar8 = 0; + nb_want = 0; + while (ssl->transform_in->maclen != nb_want) { + line_00 = ssl->in_msglen + nb_want; + pbVar11 = (byte *)((int)&major_ver + nb_want); + nb_want = nb_want + 1; + bVar8 = bVar8 | ssl->in_msg[line_00] ^ *pbVar11; + } + if ((bVar8 != 0) || (uVar12 == 0)) goto LAB_2305cbe4; + } + if (ssl->in_msglen == 0) { + line_00 = ssl->nb_zero + 1; + ssl->nb_zero = line_00; + if (3 < line_00) { + mbedtls_debug_print_msg + (ssl,1,"file1",0x802, + "received four consecutive empty messages, possible DoS attack"); + goto LAB_2305cbe4; + } + } + else { + ssl->nb_zero = 0; + } + uVar4 = 8; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + do { + ret = uVar4; + if (ret <= ((uint)*(ushort *)&ssl->conf->field_0x74 & 2)) break; + uVar9 = ssl->in_ctr[ret - 1] + '\x01'; + ssl->in_ctr[ret - 1] = uVar9; + uVar4 = ret - 1; + } while (uVar9 == '\0'); + if (ret == ((uint)*(ushort *)&ssl->conf->field_0x74 & 2)) { + mbedtls_debug_print_msg(ssl,1,"file1",0x818,"incoming message counter would wrap"); + ret = 0xffff9480; + goto LAB_2305ce16; + } + } + mbedtls_debug_print_msg(ssl,2,"file1",0x81d,"<= decrypt buf"); + mbedtls_debug_print_buf + (ssl,4,"file1",0xe7e,"input payload after decrypt",ssl->in_msg,ssl->in_msglen); + if (ssl->in_msglen < 0x4001) goto LAB_2305d038; + mbedtls_debug_print_msg(ssl,1,"file1",0xe82,"bad message length"); + ret = 0xffff8e00; + } + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + return ret; + } + if ((ret & 0xffffff7f) != 0xffff8e00) { + return ret; + } + if ((ssl->state - 0xbU & 0xfffffffd) == 0) { + return ret; + } + format = "discarding invalid record (mac)"; + line_00 = 0xf40; + } + else { + mbedtls_debug_print_msg(ssl,1,"file1",0xdc2,"unknown record type"); + line_00 = mbedtls_ssl_send_alert_message(ssl,'\x02','\n'); + if (line_00 == 0) { +LAB_2305c81a: + line_00 = -0x7200; + } +LAB_2305c820: + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + return line_00; + } + if (line_00 == -0x6780) { + return -0x6780; + } + if (line_00 == -0x6700) { + nb_want = mbedtls_ssl_hdr_len(); + format = "discarding unexpected record (header)"; + ssl->next_record_offset = nb_want + ssl->in_msglen; + line_00 = 0xef8; + } + else { + ssl->next_record_offset = 0; + ssl->in_left = 0; + format = "discarding invalid record (header)"; + line_00 = 0xf01; + } + } + mbedtls_debug_print_msg(ssl,1,"file1",line_00,format); + } + format = "mbedtls_ssl_fetch_input"; + line = 0xee7; +LAB_2305c75a: + mbedtls_debug_print_ret(ssl,1,"file1",line,format,line_00); + } + else { + __n = ssl->in_msglen - uVar4; + ssl->in_msglen = __n; + line_00 = 0; + memmove(ssl->in_msg,ssl->in_msg + uVar4,__n); + mbedtls_debug_print_buf + (ssl,4,"file1",0xed7,"remaining content in record",ssl->in_msg,ssl->in_msglen); + } + return line_00; +} + + + +int mbedtls_ssl_read_record(mbedtls_ssl_context *ssl) + +{ + int ret; + int line; + char *text; + + mbedtls_debug_print_msg(ssl,2,"file1",0xeaa,"=> read record"); + do { + ret = mbedtls_ssl_read_record_layer(ssl); + if (ret != 0) { + text = "mbedtls_ssl_read_record_layer"; + line = 0xeb0; + goto LAB_2305d0fa; + } + ret = mbedtls_ssl_handle_message_type(ssl); + } while (ret == -0x6680); + if (ret == 0) { + if (ssl->in_msgtype == 0x16) { + mbedtls_ssl_update_handshake_status(ssl); + } + mbedtls_debug_print_msg(ssl,2,"file1",0xec3,"<= read record"); + } + else { + text = "mbedtls_ssl_handle_message_type"; + line = 0xeba; +LAB_2305d0fa: + mbedtls_debug_print_ret(ssl,1,"file1",line,text,ret); + } + return ret; +} + + + +int mbedtls_ssl_parse_certificate(mbedtls_ssl_context *ssl) + +{ + mbedtls_key_exchange_type_t mVar1; + ushort uVar2; + uint uVar3; + mbedtls_ssl_session *pmVar4; + mbedtls_x509_crt *crt; + mbedtls_x509_crl *ca_crl; + int ret; + int line; + mbedtls_ssl_config *pmVar5; + char *text; + uchar *puVar6; + uint uVar7; + mbedtls_ssl_ciphersuite_t *ciphersuite; + + ciphersuite = ssl->transform_negotiate->ciphersuite_info; + uVar3 = *(uint *)&ssl->conf->field_0x74; + mbedtls_debug_print_msg(ssl,2,"file1",0x1099,"=> parse certificate"); + mVar1 = ciphersuite->key_exchange; + uVar7 = (uint)mVar1 - 5; + if (((uVar7 & 0xff) < 7) && ((0x4bU >> (uVar7 & 0x1f) & 1) != 0)) { + ret = 0x10a0; +LAB_2305d1d0: + mbedtls_debug_print_msg(ssl,2,"file1",ret,"<= skip parse certificate"); + ssl->state = ssl->state + 1; + return 0; + } + uVar2 = *(ushort *)&ssl->conf->field_0x74; + if (((uVar2 & 1) != 0) && (mVar1 == MBEDTLS_KEY_EXCHANGE_RSA_PSK)) { + ret = 0x10a9; + goto LAB_2305d1d0; + } + uVar7 = ssl->handshake->sni_authmode; + if (uVar7 == 3) { + uVar7 = uVar3 >> 2 & 3; + } + if (((uVar2 & 1) != 0) && (uVar7 == 0)) { + ssl->session_negotiate->verify_result = 0x80; + ret = 0x10b7; + goto LAB_2305d1d0; + } + ret = mbedtls_ssl_read_record(ssl); + if (ret != 0) { + text = "mbedtls_ssl_read_record"; + line = 0x10bf; + goto LAB_2305d262; + } + ssl->state = ssl->state + 1; + uVar2 = *(ushort *)&ssl->conf->field_0x74; + if (((uVar2 & 1) == 0) || (ssl->minor_ver == 0)) { +LAB_2305d314: + if (ssl->in_msgtype != 0x16) { +LAB_2305d2a2: + mbedtls_debug_print_msg(ssl,1,"file1",0x10f6,"bad certificate message"); + return -0x7700; + } + } + else { + ret = 4; + if ((uVar2 & 2) != 0) { + ret = 0xc; + } + if (ssl->in_hslen != ret + 3U) goto LAB_2305d314; + if (ssl->in_msgtype != 0x16) goto LAB_2305d2a2; + if (*ssl->in_msg == '\v') { + ret = memcmp(ssl->in_msg + ret,&DAT_23088e44,3); + if (ret == 0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x10e7,"TLSv1 client has no certificate"); + ssl->session_negotiate->verify_result = 0x40; + if (uVar7 == 1) { + return 0; + } + return -0x7480; + } + goto LAB_2305d314; + } + } + if (*ssl->in_msg == '\v') { + ret = 4; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + ret = 0xc; + } + if (ret + 6U <= ssl->in_hslen) { + puVar6 = ssl->in_msg + ret; + if ((*puVar6 == '\0') && + (uVar3 = ret + 3, ssl->in_hslen == CONCAT11(puVar6[1],puVar6[2]) + uVar3)) { + crt = ssl->session_negotiate->peer_cert; + if (crt != (mbedtls_x509_crt *)0x0) { + mbedtls_x509_crt_free(crt); + vPortFree(ssl->session_negotiate->peer_cert); + } + pmVar4 = ssl->session_negotiate; + crt = (mbedtls_x509_crt *)mycalloc(1,0x134); + pmVar4->peer_cert = crt; + if (crt == (mbedtls_x509_crt *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x111a,"alloc(%d bytes) failed",0x134); + return -0x7f00; + } + ret = 0; + mbedtls_x509_crt_init(ssl->session_negotiate->peer_cert); + do { + if (ssl->in_hslen <= uVar3) { + mbedtls_debug_print_crt + (ssl,3,"file1",0x113f,"peer certificate",ssl->session_negotiate->peer_cert); + if (uVar7 != 0) { + pmVar5 = ssl->conf; + crt = ssl->handshake->sni_ca_chain; + if (crt == (mbedtls_x509_crt *)0x0) { + crt = pmVar5->ca_chain; + ca_crl = pmVar5->ca_crl; + if (crt == (mbedtls_x509_crt *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x116f,"got no CA chain"); + return -0x7680; + } + } + else { + ca_crl = ssl->handshake->sni_ca_crl; + } + ret = mbedtls_x509_crt_verify_with_profile + (ssl->session_negotiate->peer_cert,crt,ca_crl,pmVar5->cert_profile, + ssl->hostname,&ssl->session_negotiate->verify_result, + (anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *) + pmVar5->f_vrfy,pmVar5->p_vrfy); + if (ret != 0) { + mbedtls_debug_print_ret(ssl,1,"file1",0x1180,"x509_verify_cert",ret); + } + crt = ssl->session_negotiate->peer_cert; + line = mbedtls_pk_can_do(&crt->pk,MBEDTLS_PK_ECKEY); + if (((line != 0) && + (line = mbedtls_ssl_check_curve(ssl,*(mbedtls_ecp_group_id *)(crt->pk).pk_ctx), + line != 0)) && + (mbedtls_debug_print_msg(ssl,1,"file1",0x118f,"bad certificate (EC key curve)"), + ret == 0)) { + ret = -0x7a00; + } + line = mbedtls_ssl_check_cert_usage + (ssl->session_negotiate->peer_cert,ciphersuite, + ~(uint)*(ushort *)&ssl->conf->field_0x74 & 1, + &ssl->session_negotiate->verify_result); + if ((line != 0) && + (mbedtls_debug_print_msg(ssl,1,"file1",0x119b,"bad certificate (usage extensions)") + , ret == 0)) { + ret = -0x7a00; + } + if (uVar7 == 1) { + ret = 0; + } + } + mbedtls_debug_print_msg(ssl,2,"file1",0x11a4,"<= parse certificate"); + return ret; + } + puVar6 = ssl->in_msg + uVar3; + if (*puVar6 != '\0') { + ret = 0x1126; + goto LAB_2305d350; + } + uVar2 = CONCAT11(puVar6[1],puVar6[2]); + ret = uVar3 + 3; + if ((uVar2 < 0x80) || (uVar3 = (uint)uVar2 + ret, ssl->in_hslen < uVar3)) { + ret = 0x1130; + goto LAB_2305d350; + } + ret = mbedtls_x509_crt_parse_der + (ssl->session_negotiate->peer_cert,ssl->in_msg + ret,(uint)uVar2); + } while ((ret == 0) || (ret == -0x262e)); + text = " mbedtls_x509_crt_parse_der"; + line = 0x1138; +LAB_2305d262: + mbedtls_debug_print_ret(ssl,1,"file1",line,text,ret); + return ret; + } + ret = 0x110b; + goto LAB_2305d350; + } + } + ret = 0x10fd; +LAB_2305d350: + mbedtls_debug_print_msg(ssl,1,"file1",ret,"bad certificate message"); + return -0x7a00; +} + + + +int mbedtls_ssl_parse_change_cipher_spec(mbedtls_ssl_context *ssl) + +{ + int ret; + uint uVar1; + uchar *puVar2; + + mbedtls_debug_print_msg(ssl,2,"file1",0x11cb,"=> parse change cipher spec"); + ret = mbedtls_ssl_read_record(ssl); + if (ret == 0) { + if (ssl->in_msgtype == 0x14) { + if ((ssl->in_msglen == 1) && (*ssl->in_msg == '\x01')) { + mbedtls_debug_print_msg + (ssl,3,"file1",0x11e3,"switching to new transform spec for inbound data"); + ssl->transform_in = ssl->transform_negotiate; + ssl->session_in = ssl->session_negotiate; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + memset(ssl->in_ctr,0,8); + } + else { + uVar1 = (uint)ssl->in_epoch + 1; + ssl->in_epoch = (uint16_t)(uVar1 * 0x10000 >> 0x10); + if ((uVar1 & 0xffff) == 0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x11f1,"DTLS epoch would wrap"); + return -0x6b80; + } + } + puVar2 = ssl->in_iv; + if (1 < ssl->minor_ver) { + puVar2 = puVar2 + (ssl->transform_negotiate->ivlen - ssl->transform_negotiate->fixed_ivlen + ); + } + ssl->in_msg = puVar2; + ssl->state = ssl->state + 1; + mbedtls_debug_print_msg(ssl,2,"file1",0x1211,"<= parse change cipher spec"); + } + else { + mbedtls_debug_print_msg(ssl,1,"file1",0x11db,"bad change cipher spec message"); + ret = -0x7e00; + } + } + else { + mbedtls_debug_print_msg(ssl,1,"file1",0x11d5,"bad change cipher spec message"); + ret = -0x7700; + } + } + else { + mbedtls_debug_print_ret(ssl,1,"file1",0x11cf,"mbedtls_ssl_read_record",ret); + } + return ret; +} + + + +int mbedtls_ssl_parse_finished(mbedtls_ssl_context *ssl) + +{ + byte *pbVar1; + int line; + int iVar2; + byte bVar3; + mbedtls_ssl_config *pmVar4; + int iVar5; + byte local_2c [4]; + uchar buf [12]; + + mbedtls_debug_print_msg(ssl,2,"file1",0x1486,"=> parse finished"); + (*ssl->handshake->calc_finished)(ssl,local_2c,*(uint *)&ssl->conf->field_0x74 & 1 ^ 1); + line = mbedtls_ssl_read_record(ssl); + if (line != 0) { + mbedtls_debug_print_ret(ssl,1,"file1",0x148c,"mbedtls_ssl_read_record",line); + return line; + } + if (ssl->in_msgtype != 0x16) { + mbedtls_debug_print_msg(ssl,1,"file1",0x1492,"bad finished message"); + return -0x7700; + } + if (*ssl->in_msg == '\x14') { + pmVar4 = ssl->conf; + line = 4; + if ((*(ushort *)&pmVar4->field_0x74 & 2) != 0) { + line = 0xc; + } + bVar3 = 0; + iVar5 = 0; + if (ssl->in_hslen == line + 0xcU) { + do { + iVar2 = line + iVar5; + pbVar1 = local_2c + iVar5; + iVar5 = iVar5 + 1; + bVar3 = bVar3 | ssl->in_msg[iVar2] ^ *pbVar1; + } while (iVar5 != 0xc); + if (bVar3 == 0) { + if (ssl->handshake->resume == 0) { + line = ssl->state + 1; + } + else { + if (((*(ushort *)&pmVar4->field_0x74 & 1) == 0) && + (ssl->state = 10, (*(ushort *)&pmVar4->field_0x74 & 1) == 0)) goto LAB_2305d838; + line = 0xf; + } + ssl->state = line; +LAB_2305d838: + if ((*(ushort *)&pmVar4->field_0x74 & 2) != 0) { + mbedtls_ssl_recv_flight_completed(ssl); + } + mbedtls_debug_print_msg(ssl,2,"file1",0x14c4,"<= parse finished"); + return 0; + } + line = 0x14a8; + goto LAB_2305d7d4; + } + } + line = 0x14a1; +LAB_2305d7d4: + mbedtls_debug_print_msg(ssl,1,"file1",line,"bad finished message"); + return -0x7e80; +} + + + +int mbedtls_ssl_read(mbedtls_ssl_context *ssl,uchar *buf,size_t len) + +{ + bool bVar1; + uint __n; + int ret; + int line; + char *text; + size_t sVar2; + uchar *puVar3; + + if ((ssl == (mbedtls_ssl_context *)0x0) || (ssl->conf == (mbedtls_ssl_config *)0x0)) { + return -0x7100; + } + mbedtls_debug_print_msg(ssl,2,"file1",0x19e0,"=> read"); + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + ret = mbedtls_ssl_flush_output(ssl); + if (ret != 0) { + return ret; + } + if (((ssl->handshake != (mbedtls_ssl_handshake_params *)0x0) && + (ssl->handshake->retransmit_state == '\x01')) && (ret = mbedtls_ssl_resend(ssl), ret != 0)) + { + return ret; + } + } + if (ssl->state == 0x10) { +LAB_2305d91a: + bVar1 = false; + } + else { + ret = mbedtls_ssl_handshake(ssl); + if (ret != -0x6b00) { + if (ret != 0) { + text = "mbedtls_ssl_handshake"; + line = 0x1a02; + goto LAB_2305d8d8; + } + goto LAB_2305d91a; + } + bVar1 = true; + } + if (ssl->in_offt != (uchar *)0x0) { +LAB_2305da00: + __n = ssl->in_msglen; + if (len < ssl->in_msglen) { + __n = len; + } + memcpy(buf,ssl->in_offt,__n); + puVar3 = (uchar *)0x0; + sVar2 = ssl->in_msglen - __n; + ssl->in_msglen = sVar2; + if (sVar2 != 0) { + puVar3 = ssl->in_offt + __n; + } + ssl->in_offt = puVar3; + mbedtls_debug_print_msg(ssl,2,"file1",0x1ad0,"<= read"); + return __n; + } + if ((ssl->f_get_timer != (mbedtls_ssl_get_timer_t *)0x0) && + (ret = (*ssl->f_get_timer)(ssl->p_timer), ret == -1)) { + ssl_set_timer(ssl,ssl->conf->read_timeout); + } + if ((bVar1) || (ret = mbedtls_ssl_read_record(ssl), ret == 0)) { + if ((ssl->in_msglen != 0) || + ((ssl->in_msgtype != 0x17 || (ret = mbedtls_ssl_read_record(ssl), ret == 0)))) { + if (ssl->in_msgtype == 0x15) { + mbedtls_debug_print_msg(ssl,2,"file1",0x1aa0,"ignoring non-fatal non-closure alert"); + return -0x6900; + } + if (ssl->in_msgtype != 0x17) { + mbedtls_debug_print_msg(ssl,1,"file1",0x1aa6,"bad application data message"); + return -0x7700; + } + ssl->in_offt = ssl->in_msg; + if (ssl->state == 0x10) { + ssl_set_timer(ssl,0); + } + goto LAB_2305da00; + } + if (ret == -0x7280) { + return 0; + } + text = "mbedtls_ssl_read_record"; + line = 0x1a27; + } + else { + if (ret == -0x7280) { + return 0; + } + text = "mbedtls_ssl_read_record"; + line = 0x1a17; + } +LAB_2305d8d8: + mbedtls_debug_print_ret(ssl,1,"file1",line,text,ret); + return ret; +} + + + +int mbedtls_ssl_set_calc_verify_md(mbedtls_ssl_context *ssl,int md) + +{ + if ((ssl->minor_ver == 3) && (md == 4)) { + ssl->handshake->calc_verify = ssl_calc_verify_tls_sha256; + return 0; + } + return -0x6600; +} + + + +void mbedtls_zeroize(void *v,size_t n) + +{ + undefined *puVar1; + + puVar1 = (undefined *)(n + (int)v); + while ((undefined *)v != puVar1) { + *(undefined *)v = 0; + v = (undefined *)v + 1; + } + return; +} + + + +int x509_memcasecmp(void *s1,void *s2,size_t len) + +{ + byte bVar1; + size_t sVar2; + + sVar2 = 0; + while( true ) { + if (sVar2 == len) { + return 0; + } + bVar1 = *(byte *)((int)s1 + sVar2); + if ((bVar1 != *(byte *)((int)s2 + sVar2)) && + (((bVar1 ^ *(byte *)((int)s2 + sVar2)) != 0x20 || (0x19 < (byte)((bVar1 & 0xdf) + 0xbf))))) + break; + sVar2 = sVar2 + 1; + } + return -1; +} + + + +int x509_name_cmp(mbedtls_x509_name *a,mbedtls_x509_name *b) + +{ + int iVar1; + size_t __n; + size_t len; + + while( true ) { + if (a == (mbedtls_x509_name *)0x0) { + return -(uint)(b != (mbedtls_x509_name *)0x0); + } + if ((((((b == (mbedtls_x509_name *)0x0) || ((a->oid).tag != (b->oid).tag)) || + (__n = (a->oid).len, __n != (b->oid).len)) || + (iVar1 = memcmp((a->oid).p,(b->oid).p,__n), iVar1 != 0)) || + (((((a->val).tag != (b->val).tag || (__n = (a->val).len, __n != (b->val).len)) || + (iVar1 = memcmp((a->val).p,(b->val).p,__n), iVar1 != 0)) && + (((iVar1 = (a->val).tag, iVar1 != 0xc && (iVar1 != 0x13)) || + (((iVar1 = (b->val).tag, iVar1 != 0xc && (iVar1 != 0x13)) || + ((len = (a->val).len, len != (b->val).len || + (iVar1 = x509_memcasecmp((a->val).p,(b->val).p,len), iVar1 != 0)))))))))) || + (a->next_merged != b->next_merged)) break; + a = (mbedtls_x509_name *)a->next; + b = (mbedtls_x509_name *)b->next; + } + return -1; +} + + + +int x509_check_wildcard(char *cn,mbedtls_x509_buf *name) + +{ + size_t sVar1; + size_t sVar2; + uchar *puVar3; + int iVar4; + + sVar1 = strlen(cn); + if (name->len < 3) { + iVar4 = 0; + } + else { + puVar3 = name->p; + iVar4 = 0; + if ((*puVar3 == '*') && (puVar3[1] == '.')) { + sVar2 = 0; + while (sVar2 != sVar1) { + if (cn[sVar2] == '.') { + if (sVar2 == 0) { + return -1; + } + if (sVar1 - sVar2 != name->len - 1) { + return -1; + } + iVar4 = x509_memcasecmp(puVar3 + 1,cn + sVar2,sVar1 - sVar2); + return -(uint)(iVar4 != 0); + } + sVar2 = sVar2 + 1; + } + iVar4 = -1; + } + } + return iVar4; +} + + + +int x509_profile_check_key + (mbedtls_x509_crt_profile *profile,mbedtls_pk_type_t pk_alg,mbedtls_pk_context *pk) + +{ + bool bVar1; + size_t sVar2; + undefined3 in_register_0000202d; + int iVar3; + + iVar3 = CONCAT31(in_register_0000202d,pk_alg); + if ((iVar3 == 1) || (iVar3 == 6)) { + sVar2 = mbedtls_pk_get_bitlen(pk); + bVar1 = sVar2 < profile->rsa_min_bitlen; + } + else { + if (2 < (iVar3 - 2U & 0xff)) { + return -1; + } + bVar1 = (1 << ((uint)*(byte *)pk->pk_ctx - 1 & 0x1f) & profile->allowed_curves) == 0; + } + return -(uint)bVar1; +} + + + +// WARNING: Variable defined which should be unmapped: key_size_str + +int mbedtls_x509_crt_info(char *buf,size_t size,char *prefix,mbedtls_x509_crt *crt) + +{ + byte bVar1; + uint __maxlen; + uchar *__s; + uint uVar2; + char *name; + int iVar3; + size_t sVar4; + uint uVar5; + uchar *puVar6; + undefined *puVar7; + uchar *puVar8; + int iVar9; + mbedtls_x509_sequence *oid; + char *pcStack56; + char *desc; + char key_size_str [18]; + + if (crt == (mbedtls_x509_crt *)0x0) { + uVar2 = snprintf(buf,size,"\nCertificate is uninitialised!\n"); + if ((-1 < (int)uVar2) && (uVar2 < size)) { + return uVar2; + } + } + else { + uVar2 = snprintf(buf,size,"%scert. version : %d\r\n",prefix,crt->version); + if ((-1 < (int)uVar2) && (uVar2 < size)) { + __maxlen = size - uVar2; + buf = buf + uVar2; + uVar2 = snprintf(buf,__maxlen,"%sserial number : ",prefix); + if ((-1 < (int)uVar2) && (uVar2 < __maxlen)) { + __maxlen = __maxlen - uVar2; + buf = buf + uVar2; + uVar2 = mbedtls_x509_serial_gets(buf,__maxlen,&crt->serial); + if ((-1 < (int)uVar2) && (uVar2 < __maxlen)) { + __maxlen = __maxlen - uVar2; + buf = buf + uVar2; + uVar2 = snprintf(buf,__maxlen,"\r\n%sissuer name : ",prefix); + if ((-1 < (int)uVar2) && (uVar2 < __maxlen)) { + __maxlen = __maxlen - uVar2; + buf = buf + uVar2; + uVar2 = mbedtls_x509_dn_gets(buf,__maxlen,&crt->issuer); + if ((-1 < (int)uVar2) && (uVar2 < __maxlen)) { + __maxlen = __maxlen - uVar2; + buf = buf + uVar2; + uVar2 = snprintf(buf,__maxlen,"\r\n%ssubject name : ",prefix); + if ((-1 < (int)uVar2) && (uVar2 < __maxlen)) { + __maxlen = __maxlen - uVar2; + buf = buf + uVar2; + uVar2 = mbedtls_x509_dn_gets(buf,__maxlen,&crt->subject); + if ((-1 < (int)uVar2) && (uVar2 < __maxlen)) { + __maxlen = __maxlen - uVar2; + buf = buf + uVar2; + uVar2 = snprintf(buf,__maxlen, + "\r\n%sissued on : %04d-%02d-%02d %02d:%02d:%02d",prefix, + (crt->valid_from).year,(crt->valid_from).mon, + (crt->valid_from).day,(crt->valid_from).hour); + if ((-1 < (int)uVar2) && (uVar2 < __maxlen)) { + __maxlen = __maxlen - uVar2; + buf = buf + uVar2; + uVar2 = snprintf(buf,__maxlen, + "\r\n%sexpires on : %04d-%02d-%02d %02d:%02d:%02d", + prefix,(crt->valid_to).year,(crt->valid_to).mon, + (crt->valid_to).day,(crt->valid_to).hour); + if ((-1 < (int)uVar2) && (uVar2 < __maxlen)) { + __maxlen = __maxlen - uVar2; + buf = buf + uVar2; + uVar2 = snprintf(buf,__maxlen,"\r\n%ssigned using : ",prefix); + if ((-1 < (int)uVar2) && (uVar2 < __maxlen)) { + __maxlen = __maxlen - uVar2; + buf = buf + uVar2; + uVar2 = mbedtls_x509_sig_alg_gets + (buf,__maxlen,&crt->sig_oid,crt->sig_pk,crt->sig_md, + crt->sig_opts); + if ((-1 < (int)uVar2) && (uVar2 < __maxlen)) { + name = mbedtls_pk_get_name(&crt->pk); + iVar3 = mbedtls_x509_key_size_helper((char *)&desc,0x12,name); + if (iVar3 != 0) { + return iVar3; + } + sVar4 = mbedtls_pk_get_bitlen(&crt->pk); + __maxlen = __maxlen - uVar2; + uVar5 = snprintf(buf + uVar2,__maxlen,"\r\n%s%-18s: %d bits",prefix,&desc, + sVar4); + if ((-1 < (int)uVar5) && (uVar5 < __maxlen)) { + __maxlen = __maxlen - uVar5; + __s = (uchar *)(buf + uVar2 + uVar5); + if ((crt->ext_types & 0x100U) != 0) { + if (crt->ca_istrue == 0) { + name = "false"; + } + else { + name = "true"; + } + uVar2 = snprintf((char *)__s,__maxlen, + "\r\n%sbasic constraints : CA=%s",prefix,name); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + if (0 < crt->max_pathlen) { + uVar2 = snprintf((char *)__s,__maxlen,", max_pathlen=%d", + crt->max_pathlen + -1); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + } + } + if ((crt->ext_types & 0x20U) != 0) { + uVar2 = snprintf((char *)__s,__maxlen,"\r\n%ssubject alt name : ", + prefix); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + oid = &crt->subject_alt_names; + iVar3 = 0; + puVar7 = &DAT_23088e60; + do { + uVar2 = (oid->buf).len + iVar3; + if (__maxlen <= uVar2) { + *__s = '\0'; + return -0x2980; + } + __maxlen = __maxlen - uVar2; + iVar9 = 0; + while (puVar6 = __s + iVar9, iVar9 != iVar3) { + puVar8 = puVar7 + iVar9; + iVar9 = iVar9 + 1; + *puVar6 = *puVar8; + } + uVar2 = 0; + while (__s = puVar6 + uVar2, uVar2 < (oid->buf).len) { + puVar8 = (oid->buf).p + uVar2; + uVar2 = uVar2 + 1; + *__s = *puVar8; + } + oid = (mbedtls_x509_sequence *)oid->next; + iVar3 = 2; + puVar7 = &DAT_23080648; + } while (oid != (mbedtls_x509_sequence *)0x0); + *__s = '\0'; + } + if (crt->ext_types << 0xf < 0) { + uVar2 = snprintf((char *)__s,__maxlen,"\r\n%scert. type : ", + prefix); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + bVar1 = crt->ns_cert_type; + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + puVar7 = &DAT_23088e60; + if ((char)bVar1 < '\0') { + uVar2 = snprintf((char *)__s,__maxlen,"%sSSL Client",&DAT_23088e60); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + puVar7 = &DAT_23080648; + } + if ((bVar1 & 0x40) != 0) { + uVar2 = snprintf((char *)__s,__maxlen,"%sSSL Server",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + puVar7 = &DAT_23080648; + } + if ((bVar1 & 0x20) != 0) { + uVar2 = snprintf((char *)__s,__maxlen,"%sEmail",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + puVar7 = &DAT_23080648; + } + if ((bVar1 & 0x10) != 0) { + uVar2 = snprintf((char *)__s,__maxlen,"%sObject Signing",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + puVar7 = &DAT_23080648; + } + if ((bVar1 & 8) != 0) { + uVar2 = snprintf((char *)__s,__maxlen,"%sReserved",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + puVar7 = &DAT_23080648; + } + if ((bVar1 & 4) != 0) { + uVar2 = snprintf((char *)__s,__maxlen,"%sSSL CA",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + puVar7 = &DAT_23080648; + } + if ((bVar1 & 2) != 0) { + uVar2 = snprintf((char *)__s,__maxlen,"%sEmail CA",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + puVar7 = &DAT_23080648; + } + if ((bVar1 & 1) != 0) { + uVar2 = snprintf((char *)__s,__maxlen,"%sObject Signing CA",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + } + } + if ((crt->ext_types & 4U) != 0) { + uVar2 = snprintf((char *)__s,__maxlen,"\r\n%skey usage : ", + prefix); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + uVar5 = crt->key_usage; + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + puVar7 = &DAT_23088e60; + if ((uVar5 & 0x80) != 0) { + uVar2 = snprintf((char *)__s,__maxlen,"%sDigital Signature", + &DAT_23088e60); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + puVar7 = &DAT_23080648; + } + if ((uVar5 & 0x40) != 0) { + uVar2 = snprintf((char *)__s,__maxlen,"%sNon Repudiation",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + puVar7 = &DAT_23080648; + } + if ((uVar5 & 0x20) != 0) { + uVar2 = snprintf((char *)__s,__maxlen,"%sKey Encipherment",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + puVar7 = &DAT_23080648; + } + if ((uVar5 & 0x10) != 0) { + uVar2 = snprintf((char *)__s,__maxlen,"%sData Encipherment",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + puVar7 = &DAT_23080648; + } + if ((uVar5 & 8) != 0) { + uVar2 = snprintf((char *)__s,__maxlen,"%sKey Agreement",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + puVar7 = &DAT_23080648; + } + if ((uVar5 & 4) != 0) { + uVar2 = snprintf((char *)__s,__maxlen,"%sKey Cert Sign",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + puVar7 = &DAT_23080648; + } + if ((uVar5 & 2) != 0) { + uVar2 = snprintf((char *)__s,__maxlen,"%sCRL Sign",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + puVar7 = &DAT_23080648; + } + if ((uVar5 & 1) != 0) { + uVar2 = snprintf((char *)__s,__maxlen,"%sEncipher Only",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + puVar7 = &DAT_23080648; + } + if ((int)(uVar5 << 0x10) < 0) { + uVar2 = snprintf((char *)__s,__maxlen,"%sDecipher Only",puVar7); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + } + } + if (crt->ext_types << 0x14 < 0) { + uVar2 = snprintf((char *)__s,__maxlen,"\r\n%sext key usage : ", + prefix); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + oid = &crt->ext_key_usage; + puVar7 = &DAT_23088e60; + do { + iVar3 = mbedtls_oid_get_extended_key_usage + ((mbedtls_asn1_buf *)oid,&pcStack56); + if (iVar3 != 0) { + pcStack56 = "???"; + } + uVar2 = snprintf((char *)__s,__maxlen,"%s%s",puVar7,pcStack56); + if ((int)uVar2 < 0) { + return -0x2980; + } + if (__maxlen <= uVar2) { + return -0x2980; + } + oid = (mbedtls_x509_sequence *)oid->next; + __maxlen = __maxlen - uVar2; + __s = __s + uVar2; + puVar7 = &DAT_23080648; + } while (oid != (mbedtls_x509_sequence *)0x0); + } + uVar2 = snprintf((char *)__s,__maxlen,"\r\n"); + if ((-1 < (int)uVar2) && (uVar2 < __maxlen)) { + return (uVar2 - __maxlen) + size; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + return -0x2980; +} + + + +int mbedtls_x509_crt_verify_info(char *buf,size_t size,char *prefix,uint32_t flags) + +{ + size_t __maxlen; + uint uVar1; + x509_crt_verify_string *pxVar2; + + pxVar2 = x509_crt_verify_strings; + __maxlen = size; + do { + if (pxVar2->string == (char *)0x0) { + if (flags != 0) { + uVar1 = snprintf(buf,__maxlen,"%sUnknown reason (this should not happen)\n",prefix); + if (((int)uVar1 < 0) || (__maxlen <= uVar1)) { + return -0x2980; + } + __maxlen = __maxlen - uVar1; + } + return size - __maxlen; + } + if ((flags & pxVar2->code) != 0) { + uVar1 = snprintf(buf,__maxlen,"%s%s\n",prefix); + if ((int)uVar1 < 0) { + return -0x2980; + } + if (__maxlen <= uVar1) { + return -0x2980; + } + __maxlen = __maxlen - uVar1; + buf = buf + uVar1; + flags = flags ^ pxVar2->code; + } + pxVar2 = pxVar2 + 1; + } while( true ); +} + + + +int mbedtls_x509_crt_check_key_usage(mbedtls_x509_crt *crt,uint usage) + +{ + uint uVar1; + + uVar1 = crt->ext_types & 4; + if ((uVar1 != 0) && + (((usage & 0xffff7ffe) != (usage & 0xffff7ffe & crt->key_usage) || + (uVar1 = 0, (usage & 0x8001) != ((usage | crt->key_usage) & 0x8001))))) { + uVar1 = 0xffffd800; + } + return uVar1; +} + + + +int x509_crt_check_parent(mbedtls_x509_crt *child,mbedtls_x509_crt *parent,int top,int bottom) + +{ + int iVar1; + int iVar2; + size_t __n; + + iVar1 = x509_name_cmp(&child->issuer,&parent->subject); + if (iVar1 == 0) { + if (top != 0) { + iVar1 = parent->version; + if (((bottom != 0) && (__n = (child->raw).len, __n == (parent->raw).len)) && + (iVar2 = memcmp((child->raw).p,(parent->raw).p,__n), iVar2 == 0)) { + return 0; + } + if (iVar1 < 3) { + return 0; + } + } + if (parent->ca_istrue != 0) { + iVar1 = mbedtls_x509_crt_check_key_usage(parent,4); + return -(uint)(iVar1 != 0); + } + } + return -1; +} + + + +int x509_crt_verify_top(mbedtls_x509_crt *child,mbedtls_x509_crt *trust_ca, + mbedtls_x509_crt_profile *profile,int path_cnt,int self_cnt,uint32_t *flags, + anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *f_vrfy, + void *p_vrfy) + +{ + mbedtls_pk_type_t type; + mbedtls_md_type_t md_alg; + uchar uVar1; + int iVar2; + mbedtls_md_info_t *md_info; + int iVar3; + undefined3 extraout_var; + void *options; + mbedtls_x509_crt *pmVar4; + uint32_t uStack100; + uint32_t ca_flags; + uchar hash [32]; + + uStack100 = 0; + iVar2 = mbedtls_x509_time_is_past(&child->valid_to); + if (iVar2 != 0) { + *flags = *flags | 1; + } + iVar2 = mbedtls_x509_time_is_future(&child->valid_from); + if (iVar2 != 0) { + *flags = *flags | 0x200; + } + if ((1 << ((uint)child->sig_md - 1 & 0x1f) & profile->allowed_mds) == 0) { + *flags = *flags | 0x4000; + } + if ((1 << ((uint)child->sig_pk - 1 & 0x1f) & profile->allowed_pks) == 0) { + *flags = *flags | 0x8000; + } + *flags = *flags | 8; + md_info = mbedtls_md_info_from_type(child->sig_md); + if (md_info == (mbedtls_md_info_t *)0x0) { +LAB_2305e504: + if (f_vrfy == (anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *)0x0) + goto LAB_2305e5fe; + } + else { + pmVar4 = (mbedtls_x509_crt *)0x0; + mbedtls_md(md_info,(child->tbs).p,(child->tbs).len,(uchar *)&ca_flags); + while (trust_ca != (mbedtls_x509_crt *)0x0) { + iVar2 = x509_crt_check_parent(child,trust_ca,1,(uint)(path_cnt == 0)); + if (iVar2 == 0) { + iVar2 = path_cnt + 1; + if (((child->subject_raw).len == (trust_ca->subject_raw).len) && + (iVar3 = memcmp((child->subject_raw).p,(trust_ca->subject_raw).p,(child->issuer_raw).len) + , iVar3 == 0)) { + iVar2 = path_cnt; + } + if ((trust_ca->max_pathlen < 1) || (iVar2 - self_cnt <= trust_ca->max_pathlen)) { + type = child->sig_pk; + options = child->sig_opts; + md_alg = child->sig_md; + uVar1 = mbedtls_md_get_size(md_info); + iVar2 = mbedtls_pk_verify_ext + (type,options,&trust_ca->pk,md_alg,(uchar *)&ca_flags, + CONCAT31(extraout_var,uVar1),(child->sig).p,(child->sig).len); + if (iVar2 == 0) { + iVar2 = mbedtls_x509_time_is_past(&trust_ca->valid_to); + if ((iVar2 == 0) && + (iVar2 = mbedtls_x509_time_is_future(&trust_ca->valid_from), iVar2 == 0)) + goto LAB_2305e5a0; + if (pmVar4 == (mbedtls_x509_crt *)0x0) { + pmVar4 = trust_ca; + } + } + } + } + trust_ca = trust_ca->next; + } + trust_ca = pmVar4; + if (pmVar4 == (mbedtls_x509_crt *)0x0) goto LAB_2305e504; +LAB_2305e5a0: + *flags = *flags & 0xfffffff7; + iVar2 = x509_profile_check_key(profile,child->sig_pk,&trust_ca->pk); + if (iVar2 != 0) { + *flags = *flags | 0x10000; + } + if (((child->subject_raw).len == (trust_ca->subject_raw).len) && + (iVar2 = memcmp((child->subject_raw).p,(trust_ca->subject_raw).p,(child->issuer_raw).len), + iVar2 == 0)) goto LAB_2305e504; + iVar2 = mbedtls_x509_time_is_past(&trust_ca->valid_to); + if (iVar2 != 0) { + uStack100 = uStack100 | 1; + } + iVar2 = mbedtls_x509_time_is_future(&trust_ca->valid_from); + if (iVar2 != 0) { + uStack100 = uStack100 | 0x200; + } + if (f_vrfy == (anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *)0x0) + goto LAB_2305e5fe; + iVar2 = (*f_vrfy)(p_vrfy,trust_ca,path_cnt + 1,&uStack100); + if (iVar2 != 0) { + return iVar2; + } + } + iVar2 = (*f_vrfy)(p_vrfy,child,path_cnt,flags); + if (iVar2 != 0) { + return iVar2; + } +LAB_2305e5fe: + *flags = *flags | uStack100; + return 0; +} + + + +int x509_crt_verify_child + (mbedtls_x509_crt *child,mbedtls_x509_crt *parent,mbedtls_x509_crt *trust_ca, + mbedtls_x509_crl *ca_crl,mbedtls_x509_crt_profile *profile,int path_cnt,int self_cnt, + uint32_t *flags,anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *f_vrfy, + void *p_vrfy) + +{ + mbedtls_pk_type_t type; + mbedtls_md_type_t md_alg; + uchar uVar1; + int iVar2; + mbedtls_md_info_t *md_info; + undefined3 extraout_var; + void *options; + mbedtls_x509_crt *parent_00; + mbedtls_x509_crt *parent_01; + anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *extraout_fa0; + anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *f_vrfy_00; + void *extraout_fa1; + void *p_vrfy_00; + anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *in_stack_00000000; + void *in_stack_00000004; + uint32_t uStack100; + uint32_t parent_flags; + uchar hash [32]; + + uStack100 = 0; + if (path_cnt != 0) { + iVar2 = x509_name_cmp(&child->issuer,&child->subject); + if (iVar2 == 0) { + self_cnt = self_cnt + 1; + } + if (path_cnt == 8) { + *flags = *flags | 8; + return -0x2700; + } + } + iVar2 = mbedtls_x509_time_is_past(&child->valid_to); + if (iVar2 != 0) { + *flags = *flags | 1; + } + iVar2 = mbedtls_x509_time_is_future(&child->valid_from); + if (iVar2 != 0) { + *flags = *flags | 0x200; + } + if ((1 << ((uint)child->sig_md - 1 & 0x1f) & profile->allowed_mds) == 0) { + *flags = *flags | 0x4000; + } + if ((1 << ((uint)child->sig_pk - 1 & 0x1f) & profile->allowed_pks) == 0) { + *flags = *flags | 0x8000; + } + f_vrfy_00 = extraout_fa0; + p_vrfy_00 = extraout_fa1; + md_info = mbedtls_md_info_from_type(child->sig_md); + if (md_info != (mbedtls_md_info_t *)0x0) { + mbedtls_md(md_info,(child->tbs).p,(child->tbs).len,(uchar *)&parent_flags); + iVar2 = x509_profile_check_key(profile,child->sig_pk,&parent->pk); + if (iVar2 != 0) { + *flags = *flags | 0x10000; + } + type = child->sig_pk; + options = child->sig_opts; + md_alg = child->sig_md; + uVar1 = mbedtls_md_get_size(md_info); + iVar2 = mbedtls_pk_verify_ext + (type,options,&parent->pk,md_alg,(uchar *)&parent_flags, + CONCAT31(extraout_var,uVar1),(child->sig).p,(child->sig).len); + if (iVar2 == 0) goto LAB_2305e786; + } + *flags = *flags | 8; +LAB_2305e786: + parent_01 = trust_ca; + while (parent_01 != (mbedtls_x509_crt *)0x0) { + iVar2 = x509_crt_check_parent(parent,parent_01,0,(uint)(path_cnt == 0)); + if (iVar2 == 0) goto LAB_2305e7da; + parent_01 = parent_01->next; + } + parent_00 = parent->next; + do { + parent_01 = trust_ca; + if (parent_00 == (mbedtls_x509_crt *)0x0) { +LAB_2305e7da: + iVar2 = x509_crt_verify_top(parent,parent_01,profile,path_cnt + 1,self_cnt,&uStack100, + in_stack_00000000,in_stack_00000004); +LAB_2305e80e: + if ((iVar2 == 0) && + ((in_stack_00000000 == (anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *)0x0 + || (iVar2 = (*in_stack_00000000)(in_stack_00000004,child,path_cnt,flags), iVar2 == 0)))) { + iVar2 = 0; + *flags = *flags | uStack100; + } + return iVar2; + } + if (((parent_00->max_pathlen < 1) || ((path_cnt + 2) - self_cnt <= parent_00->max_pathlen)) && + (iVar2 = x509_crt_check_parent(parent,parent_00,0,(uint)(path_cnt == 0)), iVar2 == 0)) { + iVar2 = x509_crt_verify_child + (parent,parent_00,trust_ca,ca_crl,profile,path_cnt + 1,self_cnt,&uStack100, + f_vrfy_00,p_vrfy_00); + goto LAB_2305e80e; + } + parent_00 = parent_00->next; + } while( true ); +} + + + +int mbedtls_x509_crt_check_extended_key_usage + (mbedtls_x509_crt *crt,char *usage_oid,size_t usage_len) + +{ + mbedtls_x509_sequence *pmVar1; + int iVar2; + + if (-1 < crt->ext_types << 0x14) { + return 0; + } + pmVar1 = &crt->ext_key_usage; + while ((((pmVar1->buf).len != usage_len || + (iVar2 = memcmp((pmVar1->buf).p,usage_oid,usage_len), iVar2 != 0)) && + (((pmVar1->buf).len != 4 || (iVar2 = memcmp(&DAT_2308a3ac,(pmVar1->buf).p,4), iVar2 != 0))) + )) { + pmVar1 = (mbedtls_x509_sequence *)pmVar1->next; + if (pmVar1 == (mbedtls_x509_sequence *)0x0) { + return -0x2800; + } + } + return 0; +} + + + +int mbedtls_x509_crt_verify_with_profile + (mbedtls_x509_crt *crt,mbedtls_x509_crt *trust_ca,mbedtls_x509_crl *ca_crl, + mbedtls_x509_crt_profile *profile,char *cn,uint32_t *flags, + anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *f_vrfy,void *p_vrfy) + +{ + mbedtls_pk_type_t pk_alg; + size_t len; + int iVar1; + mbedtls_x509_crt *parent; + uint uVar2; + mbedtls_x509_crt *parent_00; + mbedtls_x509_name *pmVar3; + mbedtls_x509_sequence *name; + anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *in_fa0; + void *in_fa1; + + if (profile == (mbedtls_x509_crt_profile *)0x0) { + return -0x2800; + } + *flags = 0; + if (cn != (char *)0x0) { + len = strlen(cn); + if ((crt->ext_types & 0x20U) == 0) { + pmVar3 = &crt->subject; + do { + if ((((pmVar3->oid).len == 3) && + (iVar1 = memcmp(&DAT_2308a724,(pmVar3->oid).p,3), iVar1 == 0)) && + (((uVar2 = (pmVar3->val).len, uVar2 == len && + (iVar1 = x509_memcasecmp((pmVar3->val).p,cn,len), iVar1 == 0)) || + (((2 < uVar2 && (iVar1 = memcmp((pmVar3->val).p,&DAT_2308a720,2), iVar1 == 0)) && + (iVar1 = x509_check_wildcard(cn,(mbedtls_x509_buf *)&pmVar3->val), iVar1 == 0)))))) + goto LAB_2305e96c; + pmVar3 = (mbedtls_x509_name *)pmVar3->next; + } while (pmVar3 != (mbedtls_x509_name *)0x0); + } + else { + name = &crt->subject_alt_names; + do { + uVar2 = (name->buf).len; + if (((uVar2 == len) && (iVar1 = x509_memcasecmp(cn,(name->buf).p,len), iVar1 == 0)) || + ((2 < uVar2 && + ((iVar1 = memcmp((name->buf).p,&DAT_2308a720,2), iVar1 == 0 && + (iVar1 = x509_check_wildcard(cn,(mbedtls_x509_buf *)name), iVar1 == 0)))))) + goto LAB_2305e96c; + name = (mbedtls_x509_sequence *)name->next; + } while (name != (mbedtls_x509_sequence *)0x0); + } + *flags = *flags | 4; + } +LAB_2305e96c: + pk_alg = mbedtls_pk_get_type(&crt->pk); + if ((1 << ((uint)pk_alg - 1 & 0x1f) & profile->allowed_pks) == 0) { + *flags = *flags | 0x8000; + } + iVar1 = x509_profile_check_key(profile,pk_alg,&crt->pk); + parent = trust_ca; + if (iVar1 != 0) { + *flags = *flags | 0x10000; + } + while (parent != (mbedtls_x509_crt *)0x0) { + iVar1 = x509_crt_check_parent(crt,parent,0,1); + if (iVar1 == 0) goto LAB_2305ea38; + parent = parent->next; + } + parent_00 = crt->next; + do { + parent = trust_ca; + if (parent_00 == (mbedtls_x509_crt *)0x0) { +LAB_2305ea38: + iVar1 = x509_crt_verify_top(crt,parent,profile,0,0,flags,f_vrfy,p_vrfy); +LAB_2305ea60: + if ((iVar1 == 0) && (iVar1 = 0, *flags != 0)) { + iVar1 = -0x2700; + } + return iVar1; + } + iVar1 = x509_crt_check_parent(crt,parent_00,0,1); + if (iVar1 == 0) { + iVar1 = x509_crt_verify_child(crt,parent_00,trust_ca,ca_crl,profile,0,0,flags,in_fa0,in_fa1); + goto LAB_2305ea60; + } + parent_00 = parent_00->next; + } while( true ); +} + + + +void mbedtls_x509_crt_init(mbedtls_x509_crt *crt) + +{ + memset(crt,0,0x134); + return; +} + + + +void mbedtls_x509_crt_free(mbedtls_x509_crt *crt) + +{ + mbedtls_x509_crt **ppmVar1; + mbedtls_x509_crt *v; + uchar *v_00; + mbedtls_asn1_named_data *v_01; + mbedtls_asn1_sequence *v_02; + mbedtls_x509_crt *pmVar2; + mbedtls_asn1_named_data *pmVar3; + mbedtls_asn1_sequence *pmVar4; + + pmVar2 = crt; + if (crt == (mbedtls_x509_crt *)0x0) { + return; + } + do { + mbedtls_pk_free(&pmVar2->pk); + v_01 = (pmVar2->issuer).next; + while (v_01 != (mbedtls_asn1_named_data *)0x0) { + pmVar3 = v_01->next; + mbedtls_zeroize(v_01,0x20); + vPortFree(v_01); + v_01 = pmVar3; + } + v_01 = (pmVar2->subject).next; + while (v_01 != (mbedtls_asn1_named_data *)0x0) { + pmVar3 = v_01->next; + mbedtls_zeroize(v_01,0x20); + vPortFree(v_01); + v_01 = pmVar3; + } + v_02 = (pmVar2->ext_key_usage).next; + while (v_02 != (mbedtls_asn1_sequence *)0x0) { + pmVar4 = v_02->next; + mbedtls_zeroize(v_02,0x10); + vPortFree(v_02); + v_02 = pmVar4; + } + v_02 = (pmVar2->subject_alt_names).next; + while (v_02 != (mbedtls_asn1_sequence *)0x0) { + pmVar4 = v_02->next; + mbedtls_zeroize(v_02,0x10); + vPortFree(v_02); + v_02 = pmVar4; + } + v_00 = (pmVar2->raw).p; + if (v_00 != (uchar *)0x0) { + mbedtls_zeroize(v_00,(pmVar2->raw).len); + vPortFree((pmVar2->raw).p); + } + ppmVar1 = &pmVar2->next; + v = crt; + pmVar2 = *ppmVar1; + } while (*ppmVar1 != (mbedtls_x509_crt *)0x0); + do { + pmVar2 = v->next; + mbedtls_zeroize(v,0x134); + if (crt != v) { + vPortFree(v); + } + v = pmVar2; + } while (pmVar2 != (mbedtls_x509_crt *)0x0); + return; +} + + + +int mbedtls_x509_crt_parse_der(mbedtls_x509_crt *chain,uchar *buf,size_t buflen) + +{ + uchar uVar1; + uchar *end; + mbedtls_x509_crt *crt; + mbedtls_x509_crt *crt_00; + int iVar2; + size_t __n; + size_t sVar3; + byte *pbVar4; + byte *pbVar5; + uchar *end_00; + mbedtls_x509_crt *pmVar6; + uchar *end_01; + uchar *end_02; + mbedtls_x509_sequence *pmVar7; + mbedtls_x509_sequence *pmVar8; + uchar *puStack132; + size_t len; + uchar *p; + size_t len_2; + int is_critical; + int ext_type; + size_t len_3; + mbedtls_x509_buf sig_params1; + mbedtls_x509_buf sig_params2; + mbedtls_x509_buf sig_oid2; + mbedtls_x509_buf extn_oid; + size_t len_1; + + if ((chain == (mbedtls_x509_crt *)0x0) || (buf == (uchar *)0x0)) { + return -0x2800; + } + crt_00 = chain; + pmVar6 = (mbedtls_x509_crt *)0x0; + do { + crt = crt_00; + if (crt->version == 0) goto LAB_2305ebe0; + crt_00 = crt->next; + pmVar6 = crt; + } while (crt->next != (mbedtls_x509_crt *)0x0); + crt_00 = (mbedtls_x509_crt *)mycalloc(1,0x134); + crt->next = crt_00; + if (crt_00 == (mbedtls_x509_crt *)0x0) { + return -0x2880; + } + mbedtls_x509_crt_init(crt_00); + crt = crt->next; +LAB_2305ebe0: + memset(&len_3,0,0xc); + memset(&sig_params1.p,0,0xc); + memset(&sig_params2.p,0,0xc); + if (crt == (mbedtls_x509_crt *)0x0) { + iVar2 = -0x2800; + if (pmVar6 == (mbedtls_x509_crt *)0x0) goto LAB_2305f1cc; +LAB_2305ec28: + pmVar6->next = (mbedtls_x509_crt *)0x0; + } + else { + puStack132 = (uchar *)buflen; + len = (size_t)buf; + iVar2 = mbedtls_asn1_get_tag((uchar **)&len,buf + buflen,(size_t *)&puStack132,0x30); + if (iVar2 == 0) { + if (buf + buflen + -len < puStack132) goto LAB_2305ec3c; + *(uchar **)&(crt->raw).len = puStack132 + (int)(len - (int)buf); + len = (size_t)mycalloc(1,(size_t)(puStack132 + (int)(len - (int)buf))); + *(size_t *)&(crt->raw).p = len; + if ((uchar *)len == (uchar *)0x0) { + iVar2 = -0x2880; + } + else { + memcpy((void *)len,buf,(crt->raw).len); + sVar3 = (crt->raw).len; + end_01 = (uchar *)((sVar3 - (int)puStack132) + len); + end_00 = (uchar *)(len + sVar3); + (crt->tbs).p = end_01; + len = (size_t)end_01; + iVar2 = mbedtls_asn1_get_tag((uchar **)&len,end_00,(size_t *)&puStack132,0x30); + if (iVar2 == 0) { + end_01 = puStack132 + len; + *(uchar **)&(crt->tbs).len = end_01 + -(int)(crt->tbs).p; + iVar2 = mbedtls_asn1_get_tag((uchar **)&len,end_01,(size_t *)&extn_oid.p,0xa0); + if (iVar2 == 0) { + end_02 = extn_oid.p + len; + iVar2 = mbedtls_asn1_get_int((uchar **)&len,end_02,&crt->version); + if (iVar2 == 0) { + if (end_02 == (uchar *)len) goto LAB_2305ecea; + iVar2 = -0x2266; + } + else { + iVar2 = iVar2 + -0x2200; + if (iVar2 == 0) { +LAB_2305ecea: + iVar2 = mbedtls_x509_get_serial((uchar **)&len,end_01,&crt->serial); + if (iVar2 == 0) { + iVar2 = mbedtls_x509_get_alg + ((uchar **)&len,end_01,&crt->sig_oid,(mbedtls_x509_buf *)&len_3) + ; + if (iVar2 == 0) { + iVar2 = crt->version + 1; + crt->version = iVar2; + if (3 < iVar2) { + mbedtls_x509_crt_free(crt); + iVar2 = -0x2580; + goto LAB_2305ec24; + } + iVar2 = mbedtls_x509_get_sig_alg + (&crt->sig_oid,(mbedtls_x509_buf *)&len_3,&crt->sig_md, + &crt->sig_pk,&crt->sig_opts); + if (iVar2 == 0) { + *(size_t *)&(crt->issuer_raw).p = len; + iVar2 = mbedtls_asn1_get_tag((uchar **)&len,end_01,(size_t *)&puStack132,0x30) + ; + if (iVar2 != 0) goto LAB_2305ec92; + iVar2 = mbedtls_x509_get_name((uchar **)&len,puStack132 + len,&crt->issuer); + if (iVar2 == 0) { + *(uchar **)&(crt->issuer_raw).len = + (uchar *)(len - (int)(crt->issuer_raw).p); + iVar2 = mbedtls_asn1_get_tag + ((uchar **)&len,end_01,(size_t *)&extn_oid.p,0x30); + if (iVar2 == 0) { + len = (size_t)(extn_oid.p + len); + } + else { + if (iVar2 != -0x62) goto LAB_2305ed46; + } + *(size_t *)&(crt->subject_raw).p = len; + iVar2 = mbedtls_asn1_get_tag + ((uchar **)&len,end_01,(size_t *)&puStack132,0x30); + if (iVar2 != 0) goto LAB_2305ec92; + if ((puStack132 == (uchar *)0x0) || + (iVar2 = mbedtls_x509_get_name + ((uchar **)&len,puStack132 + len,&crt->subject), + iVar2 == 0)) { + *(uchar **)&(crt->subject_raw).len = + (uchar *)(len - (int)(crt->subject_raw).p); + iVar2 = mbedtls_pk_parse_subpubkey((uchar **)&len,end_01,&crt->pk); + if (iVar2 == 0) { + if (crt->version - 2U < 2) { + if (end_01 != (uchar *)len) { + (crt->issuer_id).tag = (uint)*(byte *)len; + iVar2 = mbedtls_asn1_get_tag + ((uchar **)&len,end_01,&(crt->issuer_id).len,0xa1) + ; + if (iVar2 == 0) { + *(size_t *)&(crt->issuer_id).p = len; + len = len + (crt->issuer_id).len; + } + else { + if (iVar2 != -0x62) goto LAB_2305ed46; + } + if (1 < crt->version - 2U) goto LAB_2305ee1e; + } + if (end_01 != (uchar *)len) { + (crt->subject_id).tag = (uint)*(byte *)len; + iVar2 = mbedtls_asn1_get_tag + ((uchar **)&len,end_01,&(crt->subject_id).len,0xa2 + ); + if (iVar2 == 0) { + *(size_t *)&(crt->subject_id).p = len; + len = len + (crt->subject_id).len; + } + else { + if (iVar2 != -0x62) goto LAB_2305ed46; + } + } + } +LAB_2305ee1e: + if (crt->version == 3) { + iVar2 = mbedtls_x509_get_ext((uchar **)&len,end_01,&crt->v3_ext,3); + if (iVar2 == 0) { +LAB_2305ee3e: + if (end_01 <= len) { + if (end_01 == (uchar *)len) goto LAB_2305ee48; +LAB_2305f11c: + iVar2 = -0x2566; + goto LAB_2305ed46; + } + sig_oid2.p = (uchar *)0x0; + extn_oid.tag = 0; + extn_oid.len = 0; + len_2 = 0; + is_critical = 0; + iVar2 = mbedtls_asn1_get_tag + ((uchar **)&len,end_01,(size_t *)&p,0x30); + if (iVar2 != 0) { +LAB_2305ef1a: + iVar2 = iVar2 + -0x2500; + if (iVar2 == 0) goto LAB_2305eef8; + goto LAB_2305ed46; + } + end_02 = p + len; + sig_oid2.p = (uchar *)(uint)*(byte *)len; + iVar2 = mbedtls_asn1_get_tag + ((uchar **)&len,end_01,(size_t *)&extn_oid,6); + if (iVar2 != 0) goto LAB_2305ef1a; + extn_oid.len = len; + len = len + extn_oid.tag; + if ((int)(end_01 + -len) < 1) { +LAB_2305f1e4: + iVar2 = -0x2560; + goto LAB_2305ed46; + } + iVar2 = mbedtls_asn1_get_bool((uchar **)&len,end_02,(int *)&len_2); + if (((iVar2 != 0) && (iVar2 != -0x62)) || + (iVar2 = mbedtls_asn1_get_tag + ((uchar **)&len,end_02,(size_t *)&p,4), + iVar2 != 0)) goto LAB_2305ef1a; + end = p + len; + if (end_02 != end) goto LAB_2305f11c; + iVar2 = mbedtls_oid_get_x509_ext_type + ((mbedtls_asn1_buf *)&sig_oid2.p,&is_critical); + if (iVar2 != 0) { + len = (size_t)end_02; + if (len_2 != 0) goto LAB_2305ef90; + goto LAB_2305ee3e; + } + if ((crt->ext_types & is_critical) != 0) { +LAB_2305f1ec: + iVar2 = -0x2500; + goto LAB_2305ed46; + } + crt->ext_types = crt->ext_types | is_critical; + if (is_critical == 0x100) { + crt->ca_istrue = 0; + crt->max_pathlen = 0; + iVar2 = mbedtls_asn1_get_tag + ((uchar **)&len,end_02,(size_t *)&extn_oid.p, + 0x30); + if (iVar2 == 0) { + if (end == (uchar *)len) goto LAB_2305ee3e; + iVar2 = mbedtls_asn1_get_bool + ((uchar **)&len,end,&crt->ca_istrue); + if (iVar2 != 0) { + if ((iVar2 != -0x62) || + (iVar2 = mbedtls_asn1_get_int + ((uchar **)&len,end,&crt->ca_istrue), + iVar2 != 0)) goto LAB_2305f01c; + if (crt->ca_istrue != 0) { + crt->ca_istrue = 1; + } + } + if (end == (uchar *)len) goto LAB_2305ee3e; + iVar2 = mbedtls_asn1_get_int + ((uchar **)&len,end,&crt->max_pathlen); + if (iVar2 == 0) { + if (end != (uchar *)len) goto LAB_2305f11c; + crt->max_pathlen = crt->max_pathlen + 1; + goto LAB_2305ee3e; + } + } + } + else { + if (is_critical < 0x101) { + if (is_critical == 4) { + extn_oid.p = (uchar *)0x0; + iVar2 = mbedtls_asn1_get_bitstring + ((uchar **)&len,end_02, + (mbedtls_asn1_bitstring *)&extn_oid.p); + if (iVar2 == 0) { + if (extn_oid.p == (uchar *)0x0) goto LAB_2305f09a; + crt->key_usage = 0; + pbVar4 = (byte *)0x0; + do { + pbVar5 = pbVar4 + 1; + crt->key_usage = + crt->key_usage | + (uint)*pbVar4 << (((uint)pbVar4 & 3) << 3); + if (extn_oid.p == pbVar5) break; + pbVar4 = pbVar5; + } while (pbVar5 != &DAT_00000004); + goto LAB_2305ee3e; + } + } + else { + if (is_critical != 0x20) { +LAB_2305efc6: + iVar2 = -0x2080; + goto LAB_2305ed46; + } + iVar2 = mbedtls_asn1_get_tag + ((uchar **)&len,end_02,(size_t *)&ext_type, + 0x30); + if (iVar2 == 0) { + if (end == (uchar *)(len + ext_type)) { + pmVar7 = &crt->subject_alt_names; + while (len < end) { + if ((int)(end + -len) < 1) goto LAB_2305f1e4; + uVar1 = *(uchar *)len; + len = len + 1; + iVar2 = mbedtls_asn1_get_len + ((uchar **)&len,end, + (size_t *)&extn_oid.p); + if (iVar2 != 0) goto LAB_2305f01c; + if (-1 < (char)uVar1) goto LAB_2305ef90; + if (uVar1 == -0x7e) { + pmVar8 = pmVar7; + if ((pmVar7->buf).p != (uchar *)0x0) { + if (pmVar7->next != (mbedtls_asn1_sequence *)0x0) + goto LAB_2305f1ec; + pmVar8 = (mbedtls_x509_sequence *)mycalloc(1,0x10); + *(mbedtls_x509_sequence **)&pmVar7->next = pmVar8; + if (pmVar8 == (mbedtls_x509_sequence *)0x0) { + iVar2 = -0x256a; + goto LAB_2305ed46; + } + } + (pmVar8->buf).tag = 0x82; + *(size_t *)&(pmVar8->buf).p = len; + *(uchar **)&(pmVar8->buf).len = extn_oid.p; + pmVar7 = pmVar8; + } + len = (size_t)((uchar *)len + (int)extn_oid.p); + } + pmVar7->next = (mbedtls_asn1_sequence *)0x0; + if (end != (uchar *)len) goto LAB_2305f11c; + goto LAB_2305ee3e; + } + goto LAB_2305f11c; + } + } + } + else { + if (is_critical == 0x800) { + iVar2 = mbedtls_asn1_get_sequence_of + ((uchar **)&len,end_02, + (mbedtls_asn1_sequence *) + &crt->ext_key_usage,6); + if (iVar2 == 0) { + if ((crt->ext_key_usage).buf.p == (uchar *)0x0) { +LAB_2305f09a: + iVar2 = -0x2564; + goto LAB_2305ed46; + } + goto LAB_2305ee3e; + } + } + else { + if (is_critical != 0x10000) goto LAB_2305efc6; + extn_oid.p = (uchar *)0x0; + iVar2 = mbedtls_asn1_get_bitstring + ((uchar **)&len,end_02, + (mbedtls_asn1_bitstring *)&extn_oid.p); + if (iVar2 == 0) { + if (extn_oid.p != (uchar *)0x1) goto LAB_2305f09a; + crt->ns_cert_type = __EM_SIZE; + goto LAB_2305ee3e; + } + } + } + } +LAB_2305f01c: + iVar2 = iVar2 + -0x2500; + if (iVar2 != 0) goto LAB_2305ed46; + goto LAB_2305ee3e; + } + if (iVar2 != -0x62) goto LAB_2305ed46; + } +LAB_2305eef8: + if (end_01 != (uchar *)len) { +LAB_2305ec3c: + mbedtls_x509_crt_free(crt); + iVar2 = -0x21e6; + goto LAB_2305ec24; + } +LAB_2305ee48: + iVar2 = mbedtls_x509_get_alg + ((uchar **)&len,end_00, + (mbedtls_x509_buf *)&sig_params2.p, + (mbedtls_x509_buf *)&sig_params1.p); + if (iVar2 == 0) { + __n = (crt->sig_oid).len; + if (((__n != sig_oid2.tag) || + (iVar2 = memcmp((crt->sig_oid).p,(void *)sig_oid2.len,__n), + iVar2 != 0)) || + ((sig_params1.tag != sig_params2.tag || + ((sig_params1.tag != 0 && + (iVar2 = memcmp((void *)sig_params1.len,(void *)sig_params2.len, + sig_params1.tag), iVar2 != 0)))))) { + mbedtls_x509_crt_free(crt); + iVar2 = -0x2680; + goto LAB_2305ec24; + } + iVar2 = mbedtls_x509_get_sig((uchar **)&len,end_00,&crt->sig); + if (iVar2 == 0) { + if (end_00 == (uchar *)len) { + return 0; + } + goto LAB_2305ec3c; + } + } + } + } + } + } + } + } + } + } + } + else { + if (iVar2 == -0x62) { + crt->version = 0; + goto LAB_2305ecea; + } + } +LAB_2305ed46: + mbedtls_x509_crt_free(crt); + } + else { +LAB_2305ec92: + mbedtls_x509_crt_free(crt); + iVar2 = iVar2 + -0x2180; + if (iVar2 == 0) { + return 0; + } + } + } + } + else { + mbedtls_x509_crt_free(crt); + iVar2 = -0x2180; + } +LAB_2305ec24: + if (pmVar6 != (mbedtls_x509_crt *)0x0) goto LAB_2305ec28; + } + if (chain == crt) { + return iVar2; + } +LAB_2305f1cc: + vPortFree(crt); + return iVar2; +LAB_2305ef90: + iVar2 = -0x2562; + goto LAB_2305ed46; +} + + + +int mbedtls_x509_crt_parse(mbedtls_x509_crt *chain,uchar *buf,size_t buflen) + +{ + bool bVar1; + int iVar2; + char *pcVar3; + int iVar4; + int iVar5; + size_t local_50; + size_t use_len; + mbedtls_pem_context pem; + + if ((chain == (mbedtls_x509_crt *)0x0) || (buf == (uchar *)0x0)) { + iVar4 = -0x2800; + } + else { + if (((buflen != 0) && (buf[buflen - 1] == '\0')) && + (pcVar3 = strstr((char *)buf,"-----BEGIN CERTIFICATE-----"), pcVar3 != (char *)0x0)) { + iVar4 = 0; + iVar2 = 0; + bVar1 = false; + while (1 < buflen) { + mbedtls_pem_init((mbedtls_pem_context *)&use_len); + iVar5 = mbedtls_pem_read_buffer + ((mbedtls_pem_context *)&use_len,"-----BEGIN CERTIFICATE-----", + "-----END CERTIFICATE-----",buf,(uchar *)0x0,0,&local_50); + if (iVar5 == 0) { + buflen = buflen - local_50; + buf = buf + local_50; + iVar5 = mbedtls_x509_crt_parse_der(chain,(uchar *)use_len,(size_t)pem.buf); + mbedtls_pem_free((mbedtls_pem_context *)&use_len); + if (iVar5 != 0) { + if (iVar5 == -0x2880) { + return -0x2880; + } + goto LAB_2305f2be; + } + bVar1 = true; + } + else { + if (iVar5 == -0x1480) { + return -0x1480; + } + if (iVar5 == -0x1080) break; + mbedtls_pem_free((mbedtls_pem_context *)&use_len); + buflen = buflen - local_50; + buf = buf + local_50; +LAB_2305f2be: + if (iVar2 == 0) { + iVar2 = iVar5; + } + iVar4 = iVar4 + 1; + } + } + if (bVar1) { + return iVar4; + } + if (iVar2 != 0) { + return iVar2; + } + return -0x2780; + } + iVar4 = mbedtls_x509_crt_parse_der(chain,buf,buflen); + } + return iVar4; +} + + + +int mbedtls_x509_crt_parse_file(mbedtls_x509_crt *chain,char *path) + +{ + int iVar1; + size_t local_18; + size_t n; + uchar *buf; + + iVar1 = mbedtls_pk_load_file(path,(uchar **)&n,&local_18); + if (iVar1 == 0) { + iVar1 = mbedtls_x509_crt_parse(chain,(uchar *)n,local_18); + mbedtls_zeroize((void *)n,local_18); + vPortFree((void *)n); + } + return iVar1; +} + + + +int net_would_block(void) + +{ + int in_a0; + uint uVar1; + + uVar1 = lwip_fcntl(in_a0,3,0); + uVar1 = uVar1 & 1; + if (uVar1 != 0) { + uVar1 = (uint)(errno == 0xb); + } + return uVar1; +} + + + +void mbedtls_net_init(mbedtls_net_context *ctx) + +{ + ctx->fd = -1; + return; +} + + + +int mbedtls_net_connect(mbedtls_net_context *ctx,char *host,char *port,int proto) + +{ + char "mbedtls_net_connect" [20]; + addrinfo *paVar1; + int iVar2; + addrinfo *paStack68; + addrinfo *addr_list; + addrinfo hints; + + memset(&addr_list,0,0x20); + iVar2 = lwip_getaddrinfo(host,port,(addrinfo *)&addr_list,&paStack68); + if (iVar2 == 0) { + iVar2 = -0x52; + paVar1 = paStack68; + while (paVar1 != (addrinfo *)0x0) { + iVar2 = lwip_socket(paVar1->ai_family,paVar1->ai_socktype,paVar1->ai_protocol); + ctx->fd = iVar2; + if (iVar2 < 0) { + iVar2 = -0x42; + } + else { + do { + iVar2 = lwip_connect(ctx->fd,paVar1->ai_addr,paVar1->ai_addrlen); + if (iVar2 == 0) goto _out; + } while (errno == 4); + iVar2 = -0x44; + lwip_close(ctx->fd); + } + paVar1 = paVar1->ai_next; + } +_out: + lwip_freeaddrinfo(paStack68); + } + else { + printf("%s %d: getaddrinfo fail- errno: %d\n","mbedtls_net_connect",0xf6,errno); + iVar2 = -0x52; + } + return iVar2; +} + + + +int mbedtls_net_set_block(mbedtls_net_context *ctx) + +{ + uint uVar1; + int iVar2; + + uVar1 = lwip_fcntl(ctx->fd,3,0); + iVar2 = lwip_fcntl(ctx->fd,4,uVar1 & 0xfffffffe); + return iVar2; +} + + + +int mbedtls_net_recv(void *ctx,uchar *buf,size_t len) + +{ + int iVar1; + + if (*(int *)ctx < 0) { + printf("%s %d: invalid socket fd\n","mbedtls_net_recv",0x141); + iVar1 = -0x45; + } + else { + iVar1 = lwip_read(*(int *)ctx,buf,len); + if (iVar1 < 0) { + iVar1 = net_would_block(); + if (iVar1 == 0) { + if ((errno == 0x20) || (errno == 0x68)) { + printf("%s %d: net reset - errno: %d\n","mbedtls_net_recv",0x14d); + return -0x50; + } + if (errno != 4) { + printf("%s %d: net recv failed - errno: %d\n","mbedtls_net_recv",0x155); + return -0x4c; + } + } + iVar1 = -0x6900; + } + } + return iVar1; +} + + + +int mbedtls_net_send(void *ctx,uchar *buf,size_t len) + +{ + char "mbedtls_net_send" [17]; + ssize_t sVar1; + int iVar2; + + if (*(int *)ctx < 0) { + return -0x45; + } + sVar1 = lwip_write(*(int *)ctx,buf,len); + if (sVar1 < 0) { + iVar2 = net_would_block(); + if (iVar2 == 0) { + if ((errno == 0x20) || (errno == 0x68)) { + printf("%s %d: net reset - errno: %d\n","mbedtls_net_send",0x16d); + return -0x50; + } + if (errno != 4) { + printf("%s %d: net send failed - errno: %d\n",0x2308ac00,0x175); + return -0x4e; + } + } + return -0x6880; + } + return sVar1; +} + + + +// WARNING: Variable defined which should be unmapped: tv + +int mbedtls_net_recv_timeout(void *ctx,uchar *buf,size_t len,uint32_t timeout) + +{ + int iVar1; + timeval *timeout_00; + uint uVar2; + undefined local_28 [4]; + _types_fd_set read_fds; + timeval tv; + + uVar2 = *(uint *)ctx; + if (-1 < (int)uVar2) { + iVar1 = 0; + do { + local_28[iVar1] = 0; + iVar1 = iVar1 + 1; + } while (iVar1 != 8); + iVar1 = (uVar2 >> 5) * 4; + *(uint *)(local_28 + iVar1) = 1 << (uVar2 & 0x1f) | *(uint *)(local_28 + iVar1); + read_fds.fds_bits[1] = timeout / 1000; + timeout_00 = (timeval *)(read_fds.fds_bits + 1); + if (timeout == 0) { + timeout_00 = (timeval *)0x0; + } + iVar1 = lwip_select(uVar2 + 1,(_types_fd_set *)local_28,(_types_fd_set *)0x0, + (_types_fd_set *)0x0,timeout_00); + if (iVar1 == 0) { + iVar1 = -0x6800; + } + else { + if (iVar1 < 0) { + iVar1 = -0x4c; + if (errno == 4) { + iVar1 = -0x6900; + } + } + else { + iVar1 = mbedtls_net_recv(ctx,buf,len); + } + } + return iVar1; + } + return -0x45; +} + + + +void mbedtls_net_free(mbedtls_net_context *ctx) + +{ + if (ctx->fd != -1) { + lwip_shutdown(ctx->fd,2); + lwip_close(ctx->fd); + ctx->fd = -1; + } + return; +} + + + +void * mycalloc(size_t numitems,size_t size) + +{ + void *__s; + + __s = pvPortMalloc(numitems * size); + memset(__s,0,numitems * size); + return __s; +} + + + +void aes_gen_tables(void) + +{ + byte bVar1; + int *piVar2; + uint uVar3; + uchar *puVar4; + uint *puVar5; + uchar *puVar6; + int iVar7; + uint32_t *puVar8; + uint uVar9; + uint uVar10; + uint uVar11; + uint uVar12; + uint uVar13; + uint local_820; + int pow [256]; + int log [256]; + + puVar5 = &local_820; + uVar9 = 1; + iVar7 = 0; + do { + pow[uVar9 + 0xff] = iVar7; + *puVar5 = uVar9; + uVar3 = uVar9 & 0x80; + if (uVar3 != 0) { + uVar3 = 0x1b; + } + iVar7 = iVar7 + 1; + uVar9 = (uVar9 ^ uVar9 << 1 ^ uVar3) & 0xff; + puVar5 = puVar5 + 1; + } while (iVar7 != 0x100); + puVar8 = RCON; + uVar9 = 1; + do { + *puVar8 = uVar9; + uVar3 = uVar9 & 0x80; + if (uVar3 != 0) { + uVar3 = 0x1b; + } + puVar8 = puVar8 + 1; + uVar9 = (uVar3 ^ uVar9 << 1) & 0xff; + } while (puVar8 != (uint32_t *)RSb); + FSb[0] = 'c'; + RSb[99] = '\0'; + piVar2 = pow + 0xff; + iVar7 = 1; + puVar4 = FSb; + puVar6 = RSb; + do { + uVar13 = (&local_820)[0xff - piVar2[1]]; + piVar2 = piVar2 + 1; + uVar9 = uVar13 << 1 | (int)uVar13 >> 7; + uVar12 = uVar9 & 0xff; + uVar10 = (int)uVar12 >> 7; + uVar9 = (uVar9 & 0x7f) << 1; + uVar11 = (int)(uVar9 | uVar10) >> 7; + uVar3 = (uVar9 & 0x7f | uVar10) << 1 | uVar11; + uVar9 = ((int)uVar3 >> 7 | ((uVar9 & 0x3f | uVar10) << 1 | uVar11) << 1) ^ uVar13 ^ uVar12 ^ + (uVar9 | uVar10) ^ uVar3 ^ 99; + FSb[iVar7] = (uchar)uVar9; + RSb[uVar9] = (uchar)iVar7; + iVar7 = iVar7 + 1; + } while (iVar7 != 0x100); + iVar7 = 0; + do { + uVar9 = (uint)*puVar4; + uVar11 = (uVar9 << 1 ^ (int)(char)*puVar4 >> 0x1f & 0x1bU) & 0xff; + uVar3 = uVar9 << 8 ^ uVar9 << 0x10 ^ uVar11; + uVar10 = uVar3 ^ (uVar9 ^ uVar11) << 0x18; + *(uint *)((int)FT0 + iVar7) = uVar10; + *(uint *)((int)FT1 + iVar7) = uVar3 << 8 | uVar9 ^ uVar11; + *(uint *)((int)FT2 + iVar7) = uVar3 << 0x10 | uVar10 >> 0x10; + *(uint *)((int)FT3 + iVar7) = uVar11 << 0x18 | uVar10 >> 8; + bVar1 = *puVar6; + uVar9 = (uint)bVar1; + if (bVar1 == 0) { + uVar3 = 0; + uVar10 = 0; + } + else { + uVar3 = (&local_820)[(log[13] + pow[uVar9 + 0xff]) % 0xff]; + uVar10 = (&local_820)[(pow[uVar9 + 0xff] + log[8]) % 0xff] << 8; + } + uVar11 = 0; + if (bVar1 != 0) { + uVar11 = (&local_820)[(pow[uVar9 + 0xff] + log[12]) % 0xff] << 0x10; + } + uVar11 = uVar10 ^ uVar3 ^ uVar11; + uVar12 = 0; + if (bVar1 != 0) { + uVar12 = (&local_820)[(pow[uVar9 + 0xff] + log[10]) % 0xff] << 0x18; + } + uVar12 = uVar11 ^ uVar12; + *(uint *)((int)RT0 + iVar7) = uVar12; + *(uint *)((int)RT1 + iVar7) = uVar11 << 8 | uVar12 >> 0x18; + *(uint *)((int)RT2 + iVar7) = (uVar10 ^ uVar3) << 0x10 | uVar12 >> 0x10; + *(uint *)((int)RT3 + iVar7) = uVar3 << 0x18 | uVar12 >> 8; + iVar7 = iVar7 + 4; + puVar4 = puVar4 + 1; + puVar6 = puVar6 + 1; + } while (iVar7 != 0x400); + return; +} + + + +void mbedtls_aes_init(mbedtls_aes_context *ctx) + +{ + memset(ctx,0,0x118); + return; +} + + + +void mbedtls_aes_free(mbedtls_aes_context *ctx) + +{ + mbedtls_aes_context *pmVar1; + + pmVar1 = ctx + 1; + if (ctx != (mbedtls_aes_context *)0x0) { + while (ctx != pmVar1) { + *(undefined *)&ctx->nr = 0; + ctx = (mbedtls_aes_context *)((int)&ctx->nr + 1); + } + } + return; +} + + + +int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx,uchar *key,uint keybits) + +{ + byte *pbVar1; + uint32_t *puVar2; + uint uVar3; + int iVar4; + uint32_t *puVar5; + uint32_t *puVar6; + uint uVar7; + + if (aes_init_done == 0) { + aes_gen_tables(); + aes_init_done = 1; + } + if (keybits == 0xc0) { + iVar4 = 0xc; + } + else { + if (keybits == 0x100) { + iVar4 = 0xe; + } + else { + if (keybits != 0x80) { + return -0x20; + } + iVar4 = 10; + } + } + ctx->nr = iVar4; + puVar5 = ctx->buf; + ctx->rk = puVar5; + pbVar1 = key; + puVar2 = puVar5; + while (key + (keybits >> 5) * 4 != pbVar1) { + *puVar2 = (uint)pbVar1[1] << 8 | (uint)pbVar1[2] << 0x10 | (uint)*pbVar1 | + (uint)pbVar1[3] << 0x18; + pbVar1 = pbVar1 + 4; + puVar2 = puVar2 + 1; + } + iVar4 = ctx->nr; + if (iVar4 == 0xc) { + puVar2 = RCON; + do { + uVar3 = puVar5[5]; + uVar7 = *puVar2; + puVar6 = puVar5 + 6; + puVar2 = puVar2 + 1; + uVar7 = (uint)FSb[uVar3 >> 8 & 0xff] ^ *puVar5 ^ uVar7 ^ (uint)FSb[uVar3 >> 0x18] << 0x10 ^ + (uint)FSb[uVar3 & 0xff] << 0x18 ^ (uint)FSb[uVar3 >> 0x10 & 0xff] << 8; + *puVar6 = uVar7; + uVar7 = uVar7 ^ puVar5[1]; + puVar5[7] = uVar7; + uVar7 = uVar7 ^ puVar5[2]; + puVar5[8] = uVar7; + uVar7 = uVar7 ^ puVar5[3]; + puVar5[9] = uVar7; + uVar7 = uVar7 ^ puVar5[4]; + puVar5[10] = uVar7; + puVar5[0xb] = uVar7 ^ uVar3; + puVar5 = puVar6; + } while (puVar6 != ctx->buf + 0x30); + } + else { + if (iVar4 == 0xe) { + puVar2 = RCON; + do { + uVar3 = puVar5[7]; + uVar7 = *puVar2; + puVar6 = puVar5 + 8; + puVar2 = puVar2 + 1; + uVar7 = (uint)FSb[uVar3 >> 8 & 0xff] ^ *puVar5 ^ uVar7 ^ (uint)FSb[uVar3 >> 0x18] << 0x10 ^ + (uint)FSb[uVar3 & 0xff] << 0x18 ^ (uint)FSb[uVar3 >> 0x10 & 0xff] << 8; + *puVar6 = uVar7; + uVar7 = uVar7 ^ puVar5[1]; + puVar5[9] = uVar7; + uVar7 = uVar7 ^ puVar5[2]; + puVar5[10] = uVar7; + uVar7 = uVar7 ^ puVar5[3]; + puVar5[0xb] = uVar7; + uVar7 = (uint)FSb[uVar7 >> 0x10 & 0xff] << 0x10 ^ + (uint)FSb[uVar7 & 0xff] ^ puVar5[4] ^ (uint)FSb[uVar7 >> 0x18] << 0x18 ^ + (uint)FSb[uVar7 >> 8 & 0xff] << 8; + puVar5[0xc] = uVar7; + uVar7 = uVar7 ^ puVar5[5]; + puVar5[0xd] = uVar7; + uVar7 = uVar7 ^ puVar5[6]; + puVar5[0xe] = uVar7; + puVar5[0xf] = uVar7 ^ uVar3; + puVar5 = puVar6; + } while (puVar6 != ctx->buf + 0x38); + } + else { + if (iVar4 != 10) { + return 0; + } + puVar2 = RCON; + do { + uVar3 = puVar5[3]; + uVar7 = *puVar2; + puVar6 = puVar5 + 4; + puVar2 = puVar2 + 1; + uVar7 = (uint)FSb[uVar3 >> 8 & 0xff] ^ *puVar5 ^ uVar7 ^ (uint)FSb[uVar3 >> 0x18] << 0x10 ^ + (uint)FSb[uVar3 & 0xff] << 0x18 ^ (uint)FSb[uVar3 >> 0x10 & 0xff] << 8; + *puVar6 = uVar7; + uVar7 = uVar7 ^ puVar5[1]; + puVar5[5] = uVar7; + uVar7 = uVar7 ^ puVar5[2]; + puVar5[6] = uVar7; + puVar5[7] = uVar7 ^ uVar3; + puVar5 = puVar6; + } while (puVar6 != ctx->buf + 0x28); + } + } + return 0; +} + + + +int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx,uchar *key,uint keybits) + +{ + uint *puVar1; + int iVar2; + uint32_t *puVar3; + uint uVar4; + uint32_t *puVar5; + uint32_t *puVar6; + int iVar7; + int iStack296; + mbedtls_aes_context cty; + + mbedtls_aes_init((mbedtls_aes_context *)&iStack296); + ctx->rk = ctx->buf; + iVar2 = mbedtls_aes_setkey_enc((mbedtls_aes_context *)&iStack296,key,keybits); + if (iVar2 == 0) { + ctx->nr = iStack296; + puVar6 = (uint32_t *)(cty.nr + iStack296 * 0x10); + ctx->buf[0] = *puVar6; + ctx->buf[1] = puVar6[1]; + puVar3 = ctx->buf; + ctx->buf[2] = puVar6[2]; + ctx->buf[3] = puVar6[3]; + while( true ) { + puVar3 = puVar3 + 4; + puVar5 = puVar6 + -4; + iStack296 = iStack296 + -1; + if (iStack296 < 1) break; + iVar7 = 0; + do { + uVar4 = *(uint *)((int)puVar5 + iVar7); + puVar1 = (uint *)((int)puVar3 + iVar7); + iVar7 = iVar7 + 4; + *puVar1 = RT2[FSb[uVar4 >> 0x10 & 0xff]] ^ + RT0[FSb[uVar4 & 0xff]] ^ RT3[FSb[uVar4 >> 0x18]] ^ RT1[FSb[uVar4 >> 8 & 0xff]]; + puVar6 = puVar5; + } while (iVar7 != 0x10); + } + *puVar3 = *puVar5; + puVar3[1] = puVar6[-3]; + puVar3[2] = puVar6[-2]; + puVar3[3] = puVar6[-1]; + } + mbedtls_aes_free((mbedtls_aes_context *)&iStack296); + return iVar2; +} + + + +void mbedtls_aes_encrypt(mbedtls_aes_context *ctx,uchar *input,uchar *output) + +{ + byte bVar1; + byte bVar2; + byte bVar3; + byte bVar4; + byte bVar5; + byte bVar6; + byte bVar7; + byte bVar8; + byte bVar9; + byte bVar10; + byte bVar11; + byte bVar12; + byte bVar13; + byte bVar14; + byte bVar15; + uint uVar16; + uint uVar17; + uint uVar18; + uint uVar19; + uint uVar20; + uint32_t *puVar21; + uint uVar22; + uint uVar23; + uint uVar24; + int iVar25; + uint uVar26; + uint uVar27; + uint uVar28; + uint uVar29; + uint uVar30; + uint uVar31; + uint uVar32; + uint uVar33; + uint32_t *puVar34; + + puVar21 = ctx->rk; + puVar34 = puVar21 + 4; + uVar23 = *(uint *)input ^ *puVar21; + uVar30 = *(uint *)(input + 4) ^ puVar21[1]; + uVar28 = *(uint *)(input + 8) ^ puVar21[2]; + iVar25 = ctx->nr >> 1; + uVar26 = *(uint *)(input + 0xc) ^ puVar21[3]; + while( true ) { + iVar25 = iVar25 + -1; + uVar17 = FT0[uVar23 & 0xff] ^ FT3[uVar26 >> 0x18] ^ *puVar34 ^ + *(uint *)((int)FT1 + (uVar30 >> 6 & 0x3fc)) ^ + *(uint *)((int)FT2 + (uVar28 >> 0xe & 0x3fc)); + uVar31 = puVar34[4]; + uVar19 = FT0[uVar30 & 0xff] ^ FT3[uVar23 >> 0x18] ^ puVar34[1] ^ + *(uint *)((int)FT1 + (uVar28 >> 6 & 0x3fc)) ^ + *(uint *)((int)FT2 + (uVar26 >> 0xe & 0x3fc)); + uVar16 = FT0[uVar28 & 0xff] ^ FT3[uVar30 >> 0x18] ^ puVar34[2] ^ + *(uint *)((int)FT1 + (uVar26 >> 6 & 0x3fc)) ^ + *(uint *)((int)FT2 + (uVar23 >> 0xe & 0x3fc)); + uVar22 = FT0[uVar26 & 0xff] ^ FT3[uVar28 >> 0x18] ^ puVar34[3] ^ + *(uint *)((int)FT1 + (uVar23 >> 6 & 0x3fc)) ^ + *(uint *)((int)FT2 + (uVar30 >> 0xe & 0x3fc)); + uVar33 = uVar19 >> 8 & 0xff; + uVar23 = uVar16 >> 0x10 & 0xff; + uVar30 = puVar34[5]; + uVar32 = uVar16 >> 8 & 0xff; + uVar26 = uVar22 >> 0x10 & 0xff; + uVar29 = puVar34[6]; + uVar24 = uVar22 >> 8 & 0xff; + uVar28 = uVar17 >> 0x10 & 0xff; + uVar27 = puVar34[7]; + uVar18 = uVar17 >> 8 & 0xff; + uVar20 = uVar19 >> 0x10 & 0xff; + if (iVar25 < 1) break; + uVar23 = FT0[uVar17 & 0xff] ^ FT3[uVar22 >> 0x18] ^ uVar31 ^ FT1[uVar33] ^ FT2[uVar23]; + uVar30 = FT0[uVar19 & 0xff] ^ FT3[uVar17 >> 0x18] ^ uVar30 ^ FT1[uVar32] ^ FT2[uVar26]; + uVar28 = FT0[uVar16 & 0xff] ^ FT3[uVar19 >> 0x18] ^ uVar29 ^ FT1[uVar24] ^ FT2[uVar28]; + puVar34 = puVar34 + 8; + uVar26 = FT0[uVar22 & 0xff] ^ FT3[uVar16 >> 0x18] ^ uVar27 ^ FT1[uVar18] ^ FT2[uVar20]; + } + bVar1 = FSb[uVar33]; + bVar2 = FSb[uVar23]; + bVar3 = FSb[uVar22 >> 0x18]; + bVar4 = FSb[uVar32]; + bVar5 = FSb[uVar19 & 0xff]; + bVar6 = FSb[uVar26]; + bVar7 = FSb[uVar17 >> 0x18]; + bVar8 = FSb[uVar24]; + bVar9 = FSb[uVar16 & 0xff]; + bVar10 = FSb[uVar28]; + bVar11 = FSb[uVar19 >> 0x18]; + bVar12 = FSb[uVar22 & 0xff]; + bVar13 = FSb[uVar18]; + bVar14 = FSb[uVar20]; + bVar15 = FSb[uVar16 >> 0x18]; + *output = FSb[uVar17 & 0xff] ^ (byte)uVar31; + output[4] = bVar5 ^ (byte)uVar30; + output[1] = bVar1 ^ (byte)(uVar31 >> 8); + output[2] = (byte)(uVar31 >> 0x10) ^ bVar2; + output[5] = bVar4 ^ (byte)(uVar30 >> 8); + output[6] = (byte)(uVar30 >> 0x10) ^ bVar6; + output[9] = bVar8 ^ (byte)(uVar29 >> 8); + output[10] = (byte)(uVar29 >> 0x10) ^ bVar10; + output[8] = bVar9 ^ (byte)uVar29; + output[0xc] = bVar12 ^ (byte)uVar27; + output[0xd] = (byte)(uVar27 >> 8) ^ bVar13; + output[3] = (byte)(uVar31 >> 0x18) ^ bVar3; + output[7] = (byte)(uVar30 >> 0x18) ^ bVar7; + output[0xb] = (byte)(uVar29 >> 0x18) ^ bVar11; + output[0xf] = (byte)(uVar27 >> 0x18) ^ bVar15; + output[0xe] = (byte)(uVar27 >> 0x10) ^ bVar14; + return; +} + + + +void mbedtls_aes_decrypt(mbedtls_aes_context *ctx,uchar *input,uchar *output) + +{ + byte bVar1; + byte bVar2; + byte bVar3; + byte bVar4; + byte bVar5; + byte bVar6; + byte bVar7; + byte bVar8; + byte bVar9; + byte bVar10; + byte bVar11; + byte bVar12; + byte bVar13; + byte bVar14; + byte bVar15; + uint uVar16; + uint uVar17; + uint uVar18; + uint uVar19; + uint uVar20; + uint32_t *puVar21; + uint uVar22; + uint uVar23; + int iVar24; + uint uVar25; + uint uVar26; + uint uVar27; + uint uVar28; + uint uVar29; + uint uVar30; + uint uVar31; + uint uVar32; + uint uVar33; + uint32_t *puVar34; + + puVar21 = ctx->rk; + uVar29 = *(uint *)(input + 4) ^ puVar21[1]; + puVar34 = puVar21 + 4; + uVar27 = *(uint *)(input + 8) ^ puVar21[2]; + iVar24 = ctx->nr >> 1; + uVar23 = *(uint *)input ^ *puVar21; + uVar25 = *(uint *)(input + 0xc) ^ puVar21[3]; + while( true ) { + iVar24 = iVar24 + -1; + uVar17 = RT0[uVar23 & 0xff] ^ RT3[uVar29 >> 0x18] ^ *puVar34 ^ + *(uint *)((int)RT1 + (uVar25 >> 6 & 0x3fc)) ^ + *(uint *)((int)RT2 + (uVar27 >> 0xe & 0x3fc)); + uVar31 = puVar34[4]; + uVar16 = uVar17 >> 8 & 0xff; + uVar22 = RT0[uVar25 & 0xff] ^ RT3[uVar23 >> 0x18] ^ puVar34[3] ^ + *(uint *)((int)RT1 + (uVar27 >> 6 & 0x3fc)) ^ + *(uint *)((int)RT2 + (uVar29 >> 0xe & 0x3fc)); + uVar18 = RT0[uVar27 & 0xff] ^ RT3[uVar25 >> 0x18] ^ puVar34[2] ^ + *(uint *)((int)RT1 + (uVar29 >> 6 & 0x3fc)) ^ + *(uint *)((int)RT2 + (uVar23 >> 0xe & 0x3fc)); + uVar23 = RT0[uVar29 & 0xff] ^ RT3[uVar27 >> 0x18] ^ puVar34[1] ^ + *(uint *)((int)RT1 + (uVar23 >> 6 & 0x3fc)) ^ + *(uint *)((int)RT2 + (uVar25 >> 0xe & 0x3fc)); + uVar33 = uVar22 >> 8 & 0xff; + uVar32 = uVar18 >> 0x10 & 0xff; + uVar30 = puVar34[5]; + uVar29 = uVar22 >> 0x10 & 0xff; + uVar28 = puVar34[6]; + uVar27 = uVar23 >> 8 & 0xff; + uVar25 = uVar17 >> 0x10 & 0xff; + uVar26 = puVar34[7]; + uVar19 = uVar18 >> 8 & 0xff; + uVar20 = uVar23 >> 0x10 & 0xff; + if (iVar24 < 1) break; + uVar29 = RT0[uVar23 & 0xff] ^ RT3[uVar18 >> 0x18] ^ uVar30 ^ RT1[uVar16] ^ RT2[uVar29]; + uVar23 = RT0[uVar17 & 0xff] ^ RT3[uVar23 >> 0x18] ^ uVar31 ^ RT1[uVar33] ^ RT2[uVar32]; + uVar27 = RT0[uVar18 & 0xff] ^ RT3[uVar22 >> 0x18] ^ uVar28 ^ RT1[uVar27] ^ RT2[uVar25]; + puVar34 = puVar34 + 8; + uVar25 = RT0[uVar22 & 0xff] ^ RT3[uVar17 >> 0x18] ^ uVar26 ^ RT1[uVar19] ^ RT2[uVar20]; + } + bVar1 = RSb[uVar17 & 0xff]; + bVar2 = RSb[uVar32]; + bVar3 = RSb[uVar23 >> 0x18]; + bVar4 = RSb[uVar22 & 0xff]; + bVar5 = RSb[uVar16]; + bVar6 = RSb[uVar23 & 0xff]; + bVar7 = RSb[uVar29]; + bVar8 = RSb[uVar19]; + bVar9 = RSb[uVar18 >> 0x18]; + bVar10 = RSb[uVar20]; + bVar11 = RSb[uVar27]; + bVar12 = RSb[uVar18 & 0xff]; + bVar13 = RSb[uVar25]; + bVar14 = RSb[uVar17 >> 0x18]; + bVar15 = RSb[uVar22 >> 0x18]; + output[1] = RSb[uVar33] ^ (byte)(uVar31 >> 8); + output[2] = (byte)(uVar31 >> 0x10) ^ bVar2; + output[5] = bVar5 ^ (byte)(uVar30 >> 8); + output[6] = (byte)(uVar30 >> 0x10) ^ bVar7; + output[9] = bVar11 ^ (byte)(uVar28 >> 8); + output[10] = (byte)(uVar28 >> 0x10) ^ bVar13; + *output = bVar1 ^ (byte)uVar31; + output[4] = bVar6 ^ (byte)uVar30; + output[8] = bVar12 ^ (byte)uVar28; + output[0xc] = bVar4 ^ (byte)uVar26; + output[0xd] = (byte)(uVar26 >> 8) ^ bVar8; + output[3] = (byte)(uVar31 >> 0x18) ^ bVar3; + output[7] = (byte)(uVar30 >> 0x18) ^ bVar9; + output[0xb] = (byte)(uVar28 >> 0x18) ^ bVar15; + output[0xf] = (byte)(uVar26 >> 0x18) ^ bVar14; + output[0xe] = (byte)(uVar26 >> 0x10) ^ bVar10; + return; +} + + + +int mbedtls_aes_crypt_ecb(mbedtls_aes_context *ctx,int mode,uchar *input,uchar *output) + +{ + if (mode == 1) { + mbedtls_aes_encrypt(ctx,input,output); + } + else { + mbedtls_aes_decrypt(ctx,input,output); + } + return 0; +} + + + +int mbedtls_aes_crypt_cbc + (mbedtls_aes_context *ctx,int mode,size_t length,uchar *iv,uchar *input,uchar *output) + +{ + uint uVar1; + int iVar2; + byte *pbVar3; + byte *pbVar4; + byte *pbVar5; + uchar *input_00; + undefined auStack64 [4]; + uchar temp [16]; + + uVar1 = length & 0xf; + if (uVar1 == 0) { + if (mode == 0) { + while( true ) { + input_00 = output + -uVar1; + if (uVar1 + length == 0) break; + memcpy(auStack64,input + -uVar1,0x10); + mbedtls_aes_decrypt(ctx,input + -uVar1,input_00); + iVar2 = 0; + do { + pbVar3 = input_00 + iVar2; + pbVar4 = iv + iVar2; + iVar2 = iVar2 + 1; + *pbVar3 = *pbVar4 ^ *pbVar3; + } while (iVar2 != 0x10); + memcpy(iv,auStack64,0x10); + uVar1 = uVar1 - 0x10; + } + } + else { + while( true ) { + input_00 = output + -uVar1; + if (length + uVar1 == 0) break; + iVar2 = 0; + do { + pbVar5 = input + -uVar1 + iVar2; + pbVar3 = iv + iVar2; + pbVar4 = input_00 + iVar2; + iVar2 = iVar2 + 1; + *pbVar4 = *pbVar5 ^ *pbVar3; + } while (iVar2 != 0x10); + mbedtls_aes_crypt_ecb(ctx,mode,input_00,input_00); + memcpy(iv,input_00,0x10); + uVar1 = uVar1 - 0x10; + } + } + iVar2 = 0; + } + else { + iVar2 = -0x22; + } + return iVar2; +} + + + +int mbedtls_aes_crypt_cfb128 + (mbedtls_aes_context *ctx,int mode,size_t length,size_t *iv_off,uchar *iv,uchar *input + ,uchar *output) + +{ + uint uVar1; + byte *pbVar2; + byte bVar3; + + uVar1 = *iv_off; + pbVar2 = output; + if (mode == 0) { + while (pbVar2 != output + length) { + if (uVar1 == 0) { + mbedtls_aes_encrypt(ctx,iv,iv); + } + bVar3 = *input; + *pbVar2 = iv[uVar1] ^ bVar3; + iv[uVar1] = bVar3; + uVar1 = uVar1 + 1 & 0xf; + pbVar2 = pbVar2 + 1; + input = input + 1; + } + } + else { + while (pbVar2 != output + length) { + if (uVar1 == 0) { + mbedtls_aes_encrypt(ctx,iv,iv); + } + bVar3 = iv[uVar1] ^ *input; + *pbVar2 = bVar3; + iv[uVar1] = bVar3; + uVar1 = uVar1 + 1 & 0xf; + pbVar2 = pbVar2 + 1; + input = input + 1; + } + } + *iv_off = uVar1; + return 0; +} + + + +int mbedtls_aes_crypt_ctr + (mbedtls_aes_context *ctx,size_t length,size_t *nc_off,uchar *nonce_counter, + uchar *stream_block,uchar *input,uchar *output) + +{ + bool bVar1; + uchar uVar2; + uint uVar3; + uchar *puVar4; + byte *pbVar5; + + uVar3 = *nc_off; + pbVar5 = output; + do { + if (pbVar5 == output + length) { + *nc_off = uVar3; + return 0; + } + if (uVar3 == 0) { + mbedtls_aes_encrypt(ctx,nonce_counter,stream_block); + puVar4 = nonce_counter + 0xf; + do { + uVar2 = *puVar4; + *puVar4 = uVar2 + '\x01'; + if ((uchar)(uVar2 + '\x01') != '\0') break; + bVar1 = nonce_counter != puVar4; + puVar4 = puVar4 + -1; + } while (bVar1); + } + *pbVar5 = stream_block[uVar3] ^ *input; + uVar3 = uVar3 + 1 & 0xf; + input = input + 1; + pbVar5 = pbVar5 + 1; + } while( true ); +} + + + +int mbedtls_asn1_get_len(uchar **p,uchar *end,size_t *len) + +{ + uchar *puVar1; + byte bVar2; + byte *pbVar3; + + pbVar3 = *p; + puVar1 = end + -(int)pbVar3; + if ((int)puVar1 < 1) { + return -0x60; + } + if ((char)*pbVar3 < '\0') { + bVar2 = *pbVar3 & 0x7f; + if (bVar2 == 2) { + if ((int)puVar1 < 3) { + return -0x60; + } + *len = (uint)(*(ushort *)(pbVar3 + 1) >> 8) | ((uint)*(ushort *)(pbVar3 + 1) & 0xff) << 8; + puVar1 = *p + 3; + } + else { + if (bVar2 < 3) { + if (bVar2 != 1) { + return -100; + } + if (puVar1 == (uchar *)0x1) { + return -0x60; + } + *len = (uint)pbVar3[1]; + puVar1 = *p + 2; + } + else { + if (bVar2 == 3) { + if ((int)puVar1 < 4) { + return -0x60; + } + *len = (uint)pbVar3[3] | (uint)pbVar3[1] << 0x10 | (uint)pbVar3[2] << 8; + puVar1 = *p + 4; + } + else { + if (bVar2 != 4) { + return -100; + } + if ((int)puVar1 < 5) { + return -0x60; + } + *len = (uint)pbVar3[3] << 8 | + (uint)pbVar3[1] << 0x18 | (uint)pbVar3[2] << 0x10 | (uint)pbVar3[4]; + puVar1 = *p + 5; + } + } + } + *p = puVar1; + } + else { + *p = pbVar3 + 1; + *len = (uint)*pbVar3; + } + if (end + -(int)*p < (uchar *)*len) { + return -0x60; + } + return 0; +} + + + +int mbedtls_asn1_get_tag(uchar **p,uchar *end,size_t *len,int tag) + +{ + int iVar1; + byte *pbVar2; + + pbVar2 = *p; + if ((int)(end + -(int)pbVar2) < 1) { + return -0x60; + } + if ((uint)*pbVar2 == tag) { + *p = pbVar2 + 1; + iVar1 = mbedtls_asn1_get_len(p,end,len); + return iVar1; + } + return -0x62; +} + + + +int mbedtls_asn1_get_bool(uchar **p,uchar *end,int *val) + +{ + int iVar1; + size_t sStack20; + size_t len; + + iVar1 = mbedtls_asn1_get_tag(p,end,&sStack20,1); + if (iVar1 == 0) { + if (sStack20 == 1) { + *val = (uint)(**p != '\0'); + *p = *p + 1; + } + else { + iVar1 = -100; + } + } + return iVar1; +} + + + +int mbedtls_asn1_get_int(uchar **p,uchar *end,int *val) + +{ + int iVar1; + size_t sStack20; + size_t len; + + iVar1 = mbedtls_asn1_get_tag(p,end,&sStack20,2); + if (iVar1 == 0) { + if ((sStack20 - 1 < 4) && (-1 < (char)**p)) { + *val = 0; + while (sStack20 != 0) { + *val = *val << 8 | (uint)**p; + *p = *p + 1; + sStack20 = sStack20 - 1; + } + } + else { + iVar1 = -100; + } + } + return iVar1; +} + + + +int mbedtls_asn1_get_mpi(uchar **p,uchar *end,mbedtls_mpi *X) + +{ + int iVar1; + size_t local_14; + size_t len; + + iVar1 = mbedtls_asn1_get_tag(p,end,&local_14,2); + if (iVar1 == 0) { + iVar1 = mbedtls_mpi_read_binary(X,*p,local_14); + *p = *p + local_14; + } + return iVar1; +} + + + +int mbedtls_asn1_get_bitstring(uchar **p,uchar *end,mbedtls_asn1_bitstring *bs) + +{ + byte bVar1; + int iVar2; + size_t sVar3; + uchar *puVar4; + + iVar2 = mbedtls_asn1_get_tag(p,end,(size_t *)bs,3); + if (iVar2 == 0) { + if (bs->len == 0) { + iVar2 = -0x60; + } + else { + bs->len = bs->len - 1; + bVar1 = **p; + bs->unused_bits = bVar1; + if (bVar1 < 8) { + puVar4 = *p + 1; + *p = puVar4; + sVar3 = bs->len; + bs->p = puVar4; + *p = puVar4 + sVar3; + if (puVar4 + sVar3 != end) { + iVar2 = -0x66; + } + } + else { + iVar2 = -100; + } + } + } + return iVar2; +} + + + +int mbedtls_asn1_get_bitstring_null(uchar **p,uchar *end,size_t *len) + +{ + int iVar1; + uint uVar2; + uchar *puVar3; + + iVar1 = mbedtls_asn1_get_tag(p,end,len,3); + if ((iVar1 == 0) && + ((uVar2 = *len, *len = uVar2 - 1, uVar2 < 2 || (puVar3 = *p, *p = puVar3 + 1, *puVar3 != '\0')) + )) { + iVar1 = -0x68; + } + return iVar1; +} + + + +int mbedtls_asn1_get_sequence_of(uchar **p,uchar *end,mbedtls_asn1_sequence *cur,int tag) + +{ + int iVar1; + mbedtls_asn1_sequence *pmVar2; + uchar *puVar3; + size_t sStack36; + size_t len; + + iVar1 = mbedtls_asn1_get_tag(p,end,&sStack36,0x30); + if (iVar1 == 0) { + if (end == *p + sStack36) { + do { + do { + if (end <= *p) { + cur->next = (mbedtls_asn1_sequence *)0x0; + if (*p == end) { + return 0; + } + goto LAB_23060ab6; + } + (cur->buf).tag = (uint)**p; + iVar1 = mbedtls_asn1_get_tag(p,end,&(cur->buf).len,tag); + if (iVar1 != 0) { + return iVar1; + } + puVar3 = *p; + (cur->buf).p = puVar3; + puVar3 = puVar3 + (cur->buf).len; + *p = puVar3; + } while (end <= puVar3); + pmVar2 = (mbedtls_asn1_sequence *)mycalloc(1,0x10); + cur->next = pmVar2; + cur = pmVar2; + } while (pmVar2 != (mbedtls_asn1_sequence *)0x0); + iVar1 = -0x6a; + } + else { +LAB_23060ab6: + iVar1 = -0x66; + } + } + return iVar1; +} + + + +int mbedtls_asn1_get_alg(uchar **p,uchar *end,mbedtls_asn1_buf *alg,mbedtls_asn1_buf *params) + +{ + int iVar1; + int iVar2; + uchar *puVar3; + byte *pbVar4; + mbedtls_asn1_buf *pmVar5; + byte *end_00; + size_t sStack36; + size_t len; + + iVar1 = mbedtls_asn1_get_tag(p,end,&sStack36,0x30); + if (iVar1 == 0) { + iVar1 = -0x60; + if (0 < (int)(end + -(int)*p)) { + alg->tag = (uint)**p; + end_00 = *p + sStack36; + iVar2 = mbedtls_asn1_get_tag(p,end_00,&alg->len,6); + iVar1 = iVar2; + if (iVar2 == 0) { + puVar3 = *p; + alg->p = puVar3; + pbVar4 = puVar3 + alg->len; + *p = pbVar4; + if (pbVar4 == end_00) { + pmVar5 = params + 1; + while (params != pmVar5) { + *(undefined *)¶ms->tag = 0; + params = (mbedtls_asn1_buf *)((int)¶ms->tag + 1); + } + } + else { + params->tag = (uint)*pbVar4; + *p = *p + 1; + iVar1 = mbedtls_asn1_get_len(p,end_00,¶ms->len); + if (iVar1 == 0) { + puVar3 = *p; + params->p = puVar3; + pbVar4 = puVar3 + params->len; + *p = pbVar4; + iVar1 = iVar2; + if (pbVar4 != end_00) { + iVar1 = -0x66; + } + } + } + } + } + } + return iVar1; +} + + + +void mpi_sub_hlp(size_t n,mbedtls_mpi_uint *s,mbedtls_mpi_uint *d) + +{ + mbedtls_mpi_uint *pmVar1; + uint uVar2; + uint uVar3; + uint uVar4; + mbedtls_mpi_uint *pmVar5; + uint uVar6; + size_t sVar7; + + uVar4 = 0; + sVar7 = 0; + pmVar1 = d; + while (sVar7 != n) { + uVar3 = *pmVar1; + pmVar5 = s + sVar7; + sVar7 = sVar7 + 1; + uVar2 = uVar3 - uVar4; + *pmVar1 = uVar2; + uVar6 = *pmVar5; + *pmVar1 = uVar2 - uVar6; + uVar4 = (uint)(uVar2 < uVar6) + (uint)(uVar3 < uVar4); + pmVar1 = pmVar1 + 1; + } + pmVar1 = d + sVar7; + while (uVar4 != 0) { + uVar3 = *pmVar1; + *pmVar1 = uVar3 - uVar4; + uVar4 = (uint)(uVar3 < uVar4); + pmVar1 = pmVar1 + 1; + } + return; +} + + + +void mpi_mul_hlp(size_t i,mbedtls_mpi_uint *s,mbedtls_mpi_uint *d,mbedtls_mpi_uint b) + +{ + size_t sVar1; + uint uVar2; + uint *puVar3; + uint *puVar4; + mbedtls_mpi_uint *pmVar5; + uint uVar6; + uint uVar7; + mbedtls_mpi_uint mVar8; + uint uVar9; + uint uVar10; + uint uVar11; + mbedtls_mpi_uint *pmVar12; + uint uVar13; + + uVar9 = 0; + sVar1 = i; + pmVar5 = d; + pmVar12 = s; + while (uVar11 = *pmVar5, 0xf < sVar1) { + uVar10 = *pmVar12; + sVar1 = sVar1 - 0x10; + uVar6 = b * uVar10 + uVar9; + uVar7 = uVar6 + uVar11; + *pmVar5 = uVar7; + uVar2 = pmVar12[1]; + uVar11 = (uint)(uVar7 < uVar11) + + (int)((ulonglong)b * (ulonglong)uVar10 >> 0x20) + (uint)(uVar6 < uVar9); + uVar6 = b * uVar2 + uVar11; + uVar9 = pmVar5[1]; + uVar7 = uVar6 + uVar9; + pmVar5[1] = uVar7; + uVar9 = (uint)(uVar7 < uVar9) + + (uint)(uVar6 < uVar11) + (int)((ulonglong)b * (ulonglong)uVar2 >> 0x20); + uVar11 = pmVar12[2]; + uVar6 = b * uVar11 + uVar9; + uVar2 = pmVar5[2]; + uVar7 = uVar6 + uVar2; + pmVar5[2] = uVar7; + uVar2 = (uint)(uVar7 < uVar2) + + (uint)(uVar6 < uVar9) + (int)((ulonglong)b * (ulonglong)uVar11 >> 0x20); + uVar9 = pmVar12[3]; + uVar6 = b * uVar9 + uVar2; + uVar11 = pmVar5[3]; + uVar7 = uVar6 + uVar11; + pmVar5[3] = uVar7; + uVar9 = (uint)(uVar7 < uVar11) + + (uint)(uVar6 < uVar2) + (int)((ulonglong)b * (ulonglong)uVar9 >> 0x20); + uVar11 = pmVar12[4]; + uVar6 = b * uVar11 + uVar9; + uVar2 = pmVar5[4]; + uVar7 = uVar6 + uVar2; + pmVar5[4] = uVar7; + uVar2 = (uint)(uVar7 < uVar2) + + (uint)(uVar6 < uVar9) + (int)((ulonglong)b * (ulonglong)uVar11 >> 0x20); + uVar9 = pmVar12[5]; + uVar6 = b * uVar9 + uVar2; + uVar11 = pmVar5[5]; + uVar7 = uVar6 + uVar11; + pmVar5[5] = uVar7; + uVar9 = (uint)(uVar7 < uVar11) + + (uint)(uVar6 < uVar2) + (int)((ulonglong)b * (ulonglong)uVar9 >> 0x20); + uVar11 = pmVar12[6]; + uVar6 = b * uVar11 + uVar9; + uVar2 = pmVar5[6]; + uVar7 = uVar6 + uVar2; + pmVar5[6] = uVar7; + uVar2 = (uint)(uVar7 < uVar2) + + (uint)(uVar6 < uVar9) + (int)((ulonglong)b * (ulonglong)uVar11 >> 0x20); + uVar9 = pmVar12[7]; + uVar6 = b * uVar9 + uVar2; + uVar11 = pmVar5[7]; + uVar7 = uVar6 + uVar11; + pmVar5[7] = uVar7; + uVar9 = (uint)(uVar7 < uVar11) + + (uint)(uVar6 < uVar2) + (int)((ulonglong)b * (ulonglong)uVar9 >> 0x20); + uVar11 = pmVar12[8]; + uVar6 = b * uVar11 + uVar9; + uVar2 = pmVar5[8]; + uVar7 = uVar6 + uVar2; + pmVar5[8] = uVar7; + uVar2 = (uint)(uVar7 < uVar2) + + (uint)(uVar6 < uVar9) + (int)((ulonglong)b * (ulonglong)uVar11 >> 0x20); + uVar9 = pmVar12[9]; + uVar6 = b * uVar9 + uVar2; + uVar11 = pmVar5[9]; + uVar7 = uVar6 + uVar11; + pmVar5[9] = uVar7; + uVar9 = (uint)(uVar7 < uVar11) + + (uint)(uVar6 < uVar2) + (int)((ulonglong)b * (ulonglong)uVar9 >> 0x20); + uVar11 = pmVar12[10]; + uVar6 = b * uVar11 + uVar9; + uVar2 = pmVar5[10]; + uVar7 = uVar6 + uVar2; + pmVar5[10] = uVar7; + uVar2 = (uint)(uVar7 < uVar2) + + (uint)(uVar6 < uVar9) + (int)((ulonglong)b * (ulonglong)uVar11 >> 0x20); + uVar9 = pmVar12[0xb]; + uVar6 = b * uVar9 + uVar2; + uVar11 = pmVar5[0xb]; + uVar7 = uVar6 + uVar11; + pmVar5[0xb] = uVar7; + uVar9 = (uint)(uVar7 < uVar11) + + (uint)(uVar6 < uVar2) + (int)((ulonglong)b * (ulonglong)uVar9 >> 0x20); + uVar11 = pmVar12[0xc]; + uVar6 = b * uVar11 + uVar9; + uVar2 = pmVar5[0xc]; + uVar7 = uVar6 + uVar2; + pmVar5[0xc] = uVar7; + uVar2 = (uint)(uVar7 < uVar2) + + (uint)(uVar6 < uVar9) + (int)((ulonglong)b * (ulonglong)uVar11 >> 0x20); + uVar9 = pmVar12[0xd]; + uVar6 = b * uVar9 + uVar2; + uVar11 = pmVar5[0xd]; + uVar7 = uVar6 + uVar11; + pmVar5[0xd] = uVar7; + uVar9 = (uint)(uVar7 < uVar11) + + (uint)(uVar6 < uVar2) + (int)((ulonglong)b * (ulonglong)uVar9 >> 0x20); + uVar11 = pmVar12[0xe]; + uVar6 = b * uVar11 + uVar9; + uVar2 = pmVar5[0xe]; + uVar7 = uVar6 + uVar2; + pmVar5[0xe] = uVar7; + uVar10 = pmVar12[0xf]; + uVar2 = (uint)(uVar7 < uVar2) + + (uint)(uVar6 < uVar9) + (int)((ulonglong)b * (ulonglong)uVar11 >> 0x20); + uVar9 = b * uVar10 + uVar2; + uVar6 = pmVar5[0xf]; + uVar11 = uVar9 + uVar6; + pmVar5[0xf] = uVar11; + uVar9 = (uint)(uVar11 < uVar6) + + (uint)(uVar9 < uVar2) + (int)((ulonglong)b * (ulonglong)uVar10 >> 0x20); + pmVar5 = pmVar5 + 0x10; + pmVar12 = pmVar12 + 0x10; + } + puVar4 = s + (i & 0xfffffff0); + d = d + (i & 0xfffffff0); + uVar2 = i + (i >> 4) * -0x10; + puVar3 = puVar4; + pmVar5 = d; + if (7 < uVar2) { + uVar13 = *puVar4; + uVar2 = uVar2 - 8; + pmVar5 = d + 8; + puVar3 = puVar4 + 8; + uVar6 = b * uVar13 + uVar9; + uVar7 = uVar6 + uVar11; + *d = uVar7; + uVar10 = puVar4[1]; + uVar13 = (uint)(uVar7 < uVar11) + + (int)((ulonglong)b * (ulonglong)uVar13 >> 0x20) + (uint)(uVar6 < uVar9); + uVar9 = b * uVar10 + uVar13; + uVar7 = d[1]; + uVar11 = uVar9 + uVar7; + d[1] = uVar11; + uVar6 = puVar4[2]; + uVar7 = (uint)(uVar9 < uVar13) + (int)((ulonglong)b * (ulonglong)uVar10 >> 0x20) + + (uint)(uVar11 < uVar7); + uVar9 = b * uVar6 + uVar7; + uVar10 = d[2]; + uVar11 = uVar9 + uVar10; + d[2] = uVar11; + uVar7 = (uint)(uVar11 < uVar10) + + (int)((ulonglong)b * (ulonglong)uVar6 >> 0x20) + (uint)(uVar9 < uVar7); + uVar9 = puVar4[3]; + uVar10 = b * uVar9 + uVar7; + uVar11 = d[3]; + uVar13 = uVar10 + uVar11; + d[3] = uVar13; + uVar6 = puVar4[4]; + uVar9 = (uint)(uVar13 < uVar11) + + (uint)(uVar10 < uVar7) + (int)((ulonglong)b * (ulonglong)uVar9 >> 0x20); + uVar10 = b * uVar6 + uVar9; + uVar11 = d[4]; + uVar13 = uVar10 + uVar11; + d[4] = uVar13; + uVar7 = puVar4[5]; + uVar11 = (uint)(uVar13 < uVar11) + + (uint)(uVar10 < uVar9) + (int)((ulonglong)b * (ulonglong)uVar6 >> 0x20); + uVar10 = b * uVar7 + uVar11; + uVar6 = d[5]; + uVar13 = uVar10 + uVar6; + d[5] = uVar13; + uVar9 = puVar4[6]; + uVar7 = (uint)(uVar13 < uVar6) + + (uint)(uVar10 < uVar11) + (int)((ulonglong)b * (ulonglong)uVar7 >> 0x20); + uVar10 = b * uVar9 + uVar7; + uVar11 = d[6]; + uVar13 = uVar10 + uVar11; + d[6] = uVar13; + uVar6 = puVar4[7]; + uVar9 = (uint)(uVar13 < uVar11) + + (uint)(uVar10 < uVar7) + (int)((ulonglong)b * (ulonglong)uVar9 >> 0x20); + uVar7 = b * uVar6 + uVar9; + uVar11 = d[7]; + uVar10 = uVar7 + uVar11; + d[7] = uVar10; + uVar9 = (uint)(uVar10 < uVar11) + + (uint)(uVar7 < uVar9) + (int)((ulonglong)b * (ulonglong)uVar6 >> 0x20); + } + puVar4 = puVar3; + pmVar12 = pmVar5; + while( true ) { + uVar11 = *pmVar12; + if (puVar4 == puVar3 + uVar2) break; + uVar6 = *puVar4; + uVar7 = b * uVar6 + uVar9; + uVar10 = uVar7 + uVar11; + *pmVar12 = uVar10; + uVar9 = (uint)(uVar10 < uVar11) + + (int)((ulonglong)b * (ulonglong)uVar6 >> 0x20) + (uint)(uVar7 < uVar9); + puVar4 = puVar4 + 1; + pmVar12 = pmVar12 + 1; + } + pmVar5 = pmVar5 + uVar2; + while( true ) { + mVar8 = *pmVar5; + *pmVar5 = mVar8 + uVar9; + if (uVar9 <= mVar8 + uVar9) break; + uVar9 = 1; + pmVar5 = pmVar5 + 1; + } + return; +} + + + +void mbedtls_mpi_init(mbedtls_mpi *X) + +{ + if (X != (mbedtls_mpi *)0x0) { + X->s = 1; + X->n = 0; + X->p = (mbedtls_mpi_uint *)0x0; + } + return; +} + + + +void mbedtls_mpi_free(mbedtls_mpi *X) + +{ + size_t sVar1; + mbedtls_mpi_uint *pmVar2; + + if (X != (mbedtls_mpi *)0x0) { + pmVar2 = X->p; + if (pmVar2 != (mbedtls_mpi_uint *)0x0) { + sVar1 = X->n; + while (sVar1 = sVar1 - 1, sVar1 != 0xffffffff) { + *pmVar2 = 0; + pmVar2 = pmVar2 + 1; + } + vPortFree(X->p); + } + X->s = 1; + X->n = 0; + X->p = (mbedtls_mpi_uint *)0x0; + return; + } + return; +} + + + +int mbedtls_mpi_grow(mbedtls_mpi *X,size_t nblimbs) + +{ + mbedtls_mpi_uint *__dest; + int iVar1; + mbedtls_mpi_uint *pmVar2; + size_t sVar3; + + if (10000 < nblimbs) { + return -0x10; + } + iVar1 = 0; + if (X->n < nblimbs) { + __dest = (mbedtls_mpi_uint *)mycalloc(nblimbs,4); + if (__dest == (mbedtls_mpi_uint *)0x0) { + iVar1 = -0x10; + } + else { + if (X->p != (mbedtls_mpi_uint *)0x0) { + memcpy(__dest,X->p,X->n << 2); + pmVar2 = X->p; + sVar3 = X->n; + while (sVar3 = sVar3 - 1, sVar3 != 0xffffffff) { + *pmVar2 = 0; + pmVar2 = pmVar2 + 1; + } + vPortFree(X->p); + } + X->n = nblimbs; + X->p = __dest; + iVar1 = 0; + } + } + return iVar1; +} + + + +int mbedtls_mpi_shrink(mbedtls_mpi *X,size_t nblimbs) + +{ + uint uVar1; + int iVar2; + mbedtls_mpi_uint *__dest; + mbedtls_mpi_uint *pmVar3; + size_t sVar4; + uint uVar5; + + uVar5 = X->n; + if (X->n <= nblimbs) { + iVar2 = mbedtls_mpi_grow(X,nblimbs); + return iVar2; + } + do { + uVar1 = uVar5; + uVar5 = uVar1 - 1; + if (uVar5 == 0) break; + } while (X->p[uVar5] == 0); + if (nblimbs < uVar1) { + nblimbs = uVar1; + } + __dest = (mbedtls_mpi_uint *)mycalloc(nblimbs,4); + iVar2 = -0x10; + if (__dest != (mbedtls_mpi_uint *)0x0) { + if (X->p != (mbedtls_mpi_uint *)0x0) { + memcpy(__dest,X->p,nblimbs << 2); + pmVar3 = X->p; + sVar4 = X->n; + while (sVar4 = sVar4 - 1, sVar4 != 0xffffffff) { + *pmVar3 = 0; + pmVar3 = pmVar3 + 1; + } + vPortFree(X->p); + } + X->n = nblimbs; + X->p = __dest; + iVar2 = 0; + } + return iVar2; +} + + + +int mbedtls_mpi_copy(mbedtls_mpi *X,mbedtls_mpi *Y) + +{ + int iVar1; + size_t nblimbs; + + if (X != Y) { + if (Y->p != (mbedtls_mpi_uint *)0x0) { + nblimbs = Y->n; + do { + nblimbs = nblimbs; + nblimbs = nblimbs - 1; + if (nblimbs == 0) break; + } while (Y->p[nblimbs] == 0); + X->s = Y->s; + iVar1 = mbedtls_mpi_grow(X,nblimbs); + if (iVar1 != 0) { + return iVar1; + } + memset(X->p,0,X->n << 2); + memcpy(X->p,Y->p,nblimbs << 2); + return 0; + } + mbedtls_mpi_free(X); + } + return 0; +} + + + +int mbedtls_mpi_safe_cond_assign(mbedtls_mpi *X,mbedtls_mpi *Y,uchar assign) + +{ + int iVar1; + mbedtls_mpi_uint *pmVar2; + uint uVar3; + mbedtls_mpi_uint *pmVar4; + int iVar5; + uint uVar6; + + iVar1 = mbedtls_mpi_grow(X,Y->n); + if (iVar1 == 0) { + uVar3 = ((uint)assign | -(uint)assign & 0xff) >> 7; + iVar5 = 1 - uVar3; + X->s = iVar5 * X->s + uVar3 * Y->s; + uVar6 = 0; + while (uVar6 < Y->n) { + pmVar2 = X->p + uVar6; + pmVar4 = Y->p + uVar6; + uVar6 = uVar6 + 1; + *pmVar2 = uVar3 * *pmVar4 + iVar5 * *pmVar2; + } + while (uVar6 < X->n) { + X->p[uVar6] = X->p[uVar6] * iVar5; + uVar6 = uVar6 + 1; + } + } + return iVar1; +} + + + +int mbedtls_mpi_lset(mbedtls_mpi *X,mbedtls_mpi_sint z) + +{ + int iVar1; + int iVar2; + + iVar1 = mbedtls_mpi_grow(X,1); + if (iVar1 == 0) { + memset(X->p,0,X->n << 2); + *X->p = (z >> 0x1f ^ z) - (z >> 0x1f); + iVar2 = -1; + if (-1 < z) { + iVar2 = 1; + } + X->s = iVar2; + } + return iVar1; +} + + + +int mbedtls_mpi_get_bit(mbedtls_mpi *X,size_t pos) + +{ + if (pos < X->n << 5) { + return X->p[pos >> 5] >> (pos & 0x1f) & 1; + } + return 0; +} + + + +size_t mbedtls_mpi_lsb(mbedtls_mpi *X) + +{ + int iVar1; + size_t sVar2; + uint uVar3; + + sVar2 = 0; + iVar1 = 0; + do { + if (X->n == sVar2) { + return 0; + } + uVar3 = 0; + do { + if ((X->p[sVar2] >> (uVar3 & 0x1f) & 1) != 0) { + return iVar1 + uVar3; + } + uVar3 = uVar3 + 1; + } while (uVar3 != 0x20); + sVar2 = sVar2 + 1; + iVar1 = iVar1 + uVar3; + } while( true ); +} + + + +size_t mbedtls_mpi_bitlen(mbedtls_mpi *X) + +{ + int iVar1; + uint uVar2; + size_t sVar3; + size_t sVar4; + + sVar3 = X->n; + if (sVar3 != 0) { + do { + sVar4 = sVar3; + sVar3 = sVar4 - 1; + if (sVar3 == 0) break; + } while (X->p[sVar3] == 0); + iVar1 = 0; + uVar2 = 0x80000000; + do { + if ((X->p[sVar3] & uVar2) != 0) break; + iVar1 = iVar1 + 1; + uVar2 = uVar2 >> 1; + } while (iVar1 != 0x20); + sVar3 = sVar4 * 0x20 - iVar1; + } + return sVar3; +} + + + +size_t mbedtls_mpi_size(mbedtls_mpi *X) + +{ + size_t sVar1; + + sVar1 = mbedtls_mpi_bitlen(X); + return sVar1 + 7 >> 3; +} + + + +int mbedtls_mpi_read_binary(mbedtls_mpi *X,uchar *buf,size_t buflen) + +{ + uint uVar1; + uint uVar2; + int iVar3; + uint *puVar4; + uint uVar5; + + uVar2 = 0; + while ((uVar2 != buflen && (buf[uVar2] == '\0'))) { + uVar2 = uVar2 + 1; + } + iVar3 = mbedtls_mpi_grow(X,(uint)((buflen - uVar2 & 3) != 0) + (buflen - uVar2 >> 2)); + if (iVar3 == 0) { + iVar3 = mbedtls_mpi_lset(X,0); + uVar5 = 0; + if (iVar3 == 0) { + while (uVar2 < buflen) { + buflen = buflen - 1; + puVar4 = (uint *)((int)X->p + (uVar5 & 0xfffffffc)); + uVar1 = uVar5 & 3; + uVar5 = uVar5 + 1; + *puVar4 = *puVar4 | (uint)buf[buflen] << (uVar1 << 3); + } + } + } + return iVar3; +} + + + +int mbedtls_mpi_write_binary(mbedtls_mpi *X,uchar *buf,size_t buflen) + +{ + uint uVar1; + size_t sVar2; + int iVar3; + uint uVar4; + uint uVar5; + + sVar2 = mbedtls_mpi_size(X); + if (buflen < sVar2) { + iVar3 = -8; + } + else { + memset(buf,0,buflen); + buf = buf + buflen; + uVar5 = 0; + while (buf = buf + -1, uVar5 != sVar2) { + uVar4 = uVar5 & 0xfffffffc; + uVar1 = uVar5 & 3; + uVar5 = uVar5 + 1; + *buf = (uchar)(*(uint *)((int)X->p + uVar4) >> (uVar1 << 3)); + } + iVar3 = 0; + } + return iVar3; +} + + + +int mbedtls_mpi_shift_l(mbedtls_mpi *X,size_t count) + +{ + uint uVar1; + size_t sVar2; + uint uVar3; + int iVar4; + uint uVar5; + uint uVar6; + + uVar1 = count >> 5; + uVar6 = count & 0x1f; + sVar2 = mbedtls_mpi_bitlen(X); + uVar3 = sVar2 + count; + if ((uVar3 <= X->n << 5) || + (iVar4 = mbedtls_mpi_grow(X,(uint)((uVar3 & 0x1f) != 0) + (uVar3 >> 5)), iVar4 == 0)) { + if (0x1f < count) { + uVar3 = X->n; + iVar4 = uVar3 << 2; + while (iVar4 = iVar4 + -4, uVar1 < uVar3) { + uVar3 = uVar3 - 1; + *(undefined4 *)((int)X->p + iVar4) = *(undefined4 *)((int)X->p + iVar4 + uVar1 * -4); + } + iVar4 = uVar3 << 2; + while (iVar4 = iVar4 + -4, iVar4 != -4) { + *(undefined4 *)((int)X->p + iVar4) = 0; + } + } + if (uVar6 != 0) { + uVar3 = 0; + while (uVar1 < X->n) { + uVar5 = X->p[uVar1]; + X->p[uVar1] = uVar5 << uVar6; + X->p[uVar1] = X->p[uVar1] | uVar3; + uVar3 = uVar5 >> (0x20 - uVar6 & 0x1f); + uVar1 = uVar1 + 1; + } + } + iVar4 = 0; + } + return iVar4; +} + + + +int mbedtls_mpi_shift_r(mbedtls_mpi *X,size_t count) + +{ + int iVar1; + uint uVar2; + uint uVar3; + uint uVar4; + size_t sVar5; + mbedtls_mpi_uint *pmVar6; + + uVar3 = count >> 5; + uVar4 = count & 0x1f; + if (X->n < uVar3) { +LAB_230614f4: + iVar1 = mbedtls_mpi_lset(X,0); + return iVar1; + } + if (X->n == uVar3) { + if (uVar4 != 0) goto LAB_230614f4; + if (count < 0x20) { + return 0; + } + uVar2 = 0; + } + else { + if (count < 0x20) goto LAB_23061514; + iVar1 = uVar3 << 2; + uVar2 = 0; + while (uVar2 < X->n - uVar3) { + pmVar6 = (mbedtls_mpi_uint *)((int)X->p + iVar1); + iVar1 = iVar1 + 4; + X->p[uVar2] = *pmVar6; + uVar2 = uVar2 + 1; + } + } + while (uVar2 < X->n) { + X->p[uVar2] = 0; + uVar2 = uVar2 + 1; + } +LAB_23061514: + if (uVar4 != 0) { + sVar5 = X->n; + uVar3 = 0; + while (sVar5 = sVar5 - 1, sVar5 != 0xffffffff) { + uVar2 = X->p[sVar5]; + X->p[sVar5] = uVar2 >> uVar4; + X->p[sVar5] = X->p[sVar5] | uVar3; + uVar3 = uVar2 << (0x20 - uVar4 & 0x1f); + } + } + return 0; +} + + + +int mbedtls_mpi_cmp_abs(mbedtls_mpi *X,mbedtls_mpi *Y) + +{ + uint uVar1; + uint uVar2; + + uVar2 = X->n; + while ((uVar2 != 0 && (X->p[uVar2 - 1] == 0))) { + uVar2 = uVar2 - 1; + } + uVar1 = Y->n; + while( true ) { + if (uVar1 == 0) { + return (uint)(uVar2 != 0); + } + if (Y->p[uVar1 - 1] != 0) break; + uVar1 = uVar1 - 1; + } + if (uVar2 <= uVar1) { + if (uVar2 < uVar1) { + return -1; + } + while( true ) { + uVar2 = uVar2 - 1; + if (uVar2 == 0xffffffff) { + return 0; + } + uVar1 = Y->p[uVar2]; + if (uVar1 < X->p[uVar2]) break; + if (X->p[uVar2] < uVar1) { + return -1; + } + } + return 1; + } + return 1; +} + + + +int mpi_montmul(mbedtls_mpi *A,mbedtls_mpi *B,mbedtls_mpi *N,mbedtls_mpi_uint mm,mbedtls_mpi *T) + +{ + int iVar1; + mbedtls_mpi_uint *d; + mbedtls_mpi_uint mVar2; + mbedtls_mpi_uint *s; + mbedtls_mpi_uint mVar3; + size_t n; + uint i; + uint i_00; + mbedtls_mpi_uint b; + + if ((N->n + 1 <= T->n) && (T->p != (mbedtls_mpi_uint *)0x0)) { + memset(T->p,0,T->n << 2); + i = N->n; + s = T->p; + i_00 = B->n; + if (i < B->n) { + i_00 = i; + } + n = 0; + d = s; + while (n != i) { + b = A->p[n]; + mVar3 = *B->p; + mVar2 = *d; + n = n + 1; + mpi_mul_hlp(i_00,B->p,d,b); + mpi_mul_hlp(i,N->p,d,(b * mVar3 + mVar2) * mm); + *d = b; + (d + 1)[i + 1] = 0; + d = d + 1; + } + memcpy(A->p,s + i,(i + 1) * 4); + iVar1 = mbedtls_mpi_cmp_abs(A,N); + if (iVar1 < 0) { + d = T->p; + s = A->p; + } + else { + s = N->p; + d = A->p; + } + mpi_sub_hlp(n,s,d); + return 0; + } + return -4; +} + + + +int mbedtls_mpi_cmp_mpi(mbedtls_mpi *X,mbedtls_mpi *Y) + +{ + int iVar1; + uint uVar2; + int iVar3; + uint uVar4; + + uVar4 = X->n; + while ((uVar4 != 0 && (X->p[uVar4 - 1] == 0))) { + uVar4 = uVar4 - 1; + } + uVar2 = Y->n; + do { + if (uVar2 == 0) { + if (uVar4 == 0) { + return 0; + } +LAB_23061736: + return X->s; + } + if (Y->p[uVar2 - 1] != 0) { + if (uVar4 <= uVar2) { + iVar1 = Y->s; + if (uVar4 < uVar2) { + return -iVar1; + } + iVar3 = X->s; + if (iVar3 < 1) { + if ((0 < iVar1) && (iVar3 != 0)) { + return -1; + } + } + else { + if (iVar1 < 0) { + return 1; + } + } + while( true ) { + uVar4 = uVar4 - 1; + if (uVar4 == 0xffffffff) { + return 0; + } + uVar2 = Y->p[uVar4]; + if (uVar2 < X->p[uVar4]) break; + if (X->p[uVar4] < uVar2) { + return -iVar3; + } + } + return iVar3; + } + goto LAB_23061736; + } + uVar2 = uVar2 - 1; + } while( true ); +} + + + +int mbedtls_mpi_cmp_int(mbedtls_mpi *X,mbedtls_mpi_sint z) + +{ + int iVar1; + mbedtls_mpi_uint p [1]; + mbedtls_mpi Y; + + p = 1; + if (z < 0) { + p = 0xffffffff; + } + iVar1 = mbedtls_mpi_cmp_mpi(X,(mbedtls_mpi *)p); + return iVar1; +} + + + +int mbedtls_mpi_add_abs(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *B) + +{ + size_t nblimbs; + mbedtls_mpi *pmVar1; + uint uVar2; + int iVar3; + mbedtls_mpi_uint *pmVar4; + int iVar5; + uint uVar6; + mbedtls_mpi_uint *pmVar7; + size_t sVar8; + mbedtls_mpi_uint mVar9; + uint uVar10; + mbedtls_mpi_uint *pmVar11; + + pmVar1 = A; + if (((X == B) || (pmVar1 = B, X == A)) || (iVar3 = mbedtls_mpi_copy(X,A), iVar3 == 0)) { + X->s = 1; + nblimbs = pmVar1->n; + while ((nblimbs != 0 && (pmVar1->p[nblimbs - 1] == 0))) { + nblimbs = nblimbs - 1; + } + iVar3 = mbedtls_mpi_grow(X,nblimbs); + if (iVar3 == 0) { + pmVar11 = X->p; + pmVar4 = pmVar1->p; + sVar8 = 0; + uVar2 = 0; + pmVar7 = pmVar11; + while (nblimbs != sVar8) { + uVar6 = pmVar4[sVar8]; + mVar9 = *pmVar7; + sVar8 = sVar8 + 1; + uVar10 = mVar9 + uVar2 + uVar6; + *pmVar7 = uVar10; + uVar2 = (uint)(mVar9 + uVar2 < uVar2) + (uint)(uVar10 < uVar6); + pmVar7 = pmVar7 + 1; + } + pmVar7 = pmVar11 + nblimbs; + while (uVar2 != 0) { + if (X->n <= nblimbs) { + iVar5 = mbedtls_mpi_grow(X,nblimbs + 1); + if (iVar5 != 0) { + return iVar5; + } + pmVar7 = X->p + nblimbs; + } + mVar9 = *pmVar7; + *pmVar7 = mVar9 + uVar2; + uVar2 = (uint)(mVar9 + uVar2 < uVar2); + nblimbs = nblimbs + 1; + pmVar7 = pmVar7 + 1; + } + } + } + return iVar3; +} + + + +int mbedtls_mpi_sub_abs(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *B) + +{ + int iVar1; + size_t n; + int iStack44; + mbedtls_mpi TB; + + iVar1 = mbedtls_mpi_cmp_abs(A,B); + if (iVar1 < 0) { + return -10; + } + iStack44 = 1; + TB.s = 0; + TB.n = 0; + if (B == X) { + iVar1 = mbedtls_mpi_copy((mbedtls_mpi *)&iStack44,B); + if (iVar1 != 0) goto cleanup; + B = (mbedtls_mpi *)&iStack44; + } + if ((A == X) || (iVar1 = mbedtls_mpi_copy(X,A), iVar1 == 0)) { + X->s = 1; + n = B->n; + while ((n != 0 && (B->p[n - 1] == 0))) { + n = n - 1; + } + iVar1 = 0; + mpi_sub_hlp(n,B->p,X->p); + } +cleanup: + mbedtls_mpi_free((mbedtls_mpi *)&iStack44); + return iVar1; +} + + + +int mbedtls_mpi_add_mpi(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *B) + +{ + int iVar1; + int iVar2; + + iVar1 = A->s; + if (iVar1 * B->s < 0) { + iVar2 = mbedtls_mpi_cmp_abs(A,B); + if (iVar2 < 0) { + iVar2 = mbedtls_mpi_sub_abs(X,B,A); + iVar1 = -iVar1; + } + else { + iVar2 = mbedtls_mpi_sub_abs(X,A,B); + } + } + else { + iVar2 = mbedtls_mpi_add_abs(X,A,B); + } + if (iVar2 == 0) { + X->s = iVar1; + } + return iVar2; +} + + + +int mbedtls_mpi_sub_mpi(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *B) + +{ + int iVar1; + int iVar2; + + iVar1 = A->s; + if (iVar1 * B->s < 1) { + iVar2 = mbedtls_mpi_add_abs(X,A,B); + } + else { + iVar2 = mbedtls_mpi_cmp_abs(A,B); + if (iVar2 < 0) { + iVar2 = mbedtls_mpi_sub_abs(X,B,A); + iVar1 = -iVar1; + } + else { + iVar2 = mbedtls_mpi_sub_abs(X,A,B); + } + } + if (iVar2 == 0) { + X->s = iVar1; + } + return iVar2; +} + + + +int mbedtls_mpi_sub_int(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi_sint b) + +{ + int iVar1; + mbedtls_mpi_uint p [1]; + mbedtls_mpi _B; + + p = 1; + if (b < 0) { + p = 0xffffffff; + } + iVar1 = mbedtls_mpi_sub_mpi(X,A,(mbedtls_mpi *)p); + return iVar1; +} + + + +// WARNING: Variable defined which should be unmapped: TB + +int mbedtls_mpi_mul_mpi(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *B) + +{ + int iVar1; + size_t sVar2; + size_t i; + int local_38; + mbedtls_mpi TA; + mbedtls_mpi TB; + + local_38 = 1; + TA.s = 0; + TA.n = 0; + TA.p = (mbedtls_mpi_uint *)0x1; + if (X == A) { + iVar1 = mbedtls_mpi_copy((mbedtls_mpi *)&local_38,A); + A = (mbedtls_mpi *)&local_38; + if (iVar1 != 0) goto cleanup; + } + if (X == B) { + iVar1 = mbedtls_mpi_copy((mbedtls_mpi *)&TA.p,X); + if (iVar1 != 0) goto cleanup; + B = (mbedtls_mpi *)&TA.p; + } + i = A->n; + while ((i != 0 && (A->p[i - 1] == 0))) { + i = i - 1; + } + sVar2 = B->n; + while ((sVar2 != 0 && (B->p[sVar2 - 1] == 0))) { + sVar2 = sVar2 - 1; + } + iVar1 = mbedtls_mpi_grow(X,i + sVar2); + if ((iVar1 == 0) && (iVar1 = mbedtls_mpi_lset(X,0), iVar1 == 0)) { + while (sVar2 = sVar2 - 1, sVar2 != 0xffffffff) { + mpi_mul_hlp(i,A->p,X->p + sVar2,B->p[sVar2]); + } + X->s = A->s * B->s; + } +cleanup: + mbedtls_mpi_free((mbedtls_mpi *)&TA.p); + mbedtls_mpi_free((mbedtls_mpi *)&local_38); + return iVar1; +} + + + +int mbedtls_mpi_mul_int(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi_uint b) + +{ + int iVar1; + mbedtls_mpi_uint p [1]; + mbedtls_mpi _B; + + p = 1; + iVar1 = mbedtls_mpi_mul_mpi(X,A,(mbedtls_mpi *)p); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mbedtls_mpi_div_mpi(mbedtls_mpi *Q,mbedtls_mpi *R,mbedtls_mpi *A,mbedtls_mpi *B) + +{ + int iVar1; + int iVar2; + int iVar3; + size_t count; + int iVar4; + undefined4 uVar5; + uint uVar6; + uint uVar7; + undefined4 uVar8; + int *piVar9; + size_t count_00; + uint uVar10; + int iVar11; + uint uVar12; + undefined4 *puVar13; + int iStack124; + mbedtls_mpi X; + mbedtls_mpi Y; + mbedtls_mpi Z; + mbedtls_mpi T1; + mbedtls_mpi T2; + + iVar3 = mbedtls_mpi_cmp_int(B,0); + if (iVar3 == 0) { + return -0xc; + } + iStack124 = 1; + X.s = 0; + X.n = 0; + X.p = (mbedtls_mpi_uint *)0x1; + Y.s = 0; + Y.n = 0; + Y.p = (mbedtls_mpi_uint *)0x1; + Z.s = 0; + Z.n = 0; + Z.p = (mbedtls_mpi_uint *)0x1; + T1.s = 0; + T1.n = 0; + T1.p = (mbedtls_mpi_uint *)0x1; + iVar3 = mbedtls_mpi_cmp_abs(A,B); + if (iVar3 < 0) { + if (((Q == (mbedtls_mpi *)0x0) || (iVar3 = mbedtls_mpi_lset(Q,0), iVar3 == 0)) && + ((R == (mbedtls_mpi *)0x0 || (iVar3 = mbedtls_mpi_copy(R,A), iVar3 == 0)))) { + return 0; + } + } + else { + iVar3 = mbedtls_mpi_copy((mbedtls_mpi *)&iStack124,A); + if ((iVar3 == 0) && (iVar3 = mbedtls_mpi_copy((mbedtls_mpi *)&X.p,B), iVar3 == 0)) { + X.p = (mbedtls_mpi_uint *)0x1; + iStack124 = 1; + iVar3 = mbedtls_mpi_grow((mbedtls_mpi *)&Y.p,A->n + 2); + if ((iVar3 == 0) && + (((iVar3 = mbedtls_mpi_lset((mbedtls_mpi *)&Y.p,0), iVar3 == 0 && + (iVar3 = mbedtls_mpi_grow((mbedtls_mpi *)&Z.p,2), iVar3 == 0)) && + (iVar3 = mbedtls_mpi_grow((mbedtls_mpi *)&T1.p,3), iVar3 == 0)))) { + count = mbedtls_mpi_bitlen((mbedtls_mpi *)&X.p); + if ((count & 0x1f) == 0x1f) { + count = 0; + } + else { + count = 0x1f - (count & 0x1f); + iVar3 = mbedtls_mpi_shift_l((mbedtls_mpi *)&iStack124,count); + if ((iVar3 != 0) || (iVar3 = mbedtls_mpi_shift_l((mbedtls_mpi *)&X.p,count), iVar3 != 0)) + goto cleanup; + } + iVar4 = Y.s; + uVar10 = X.s; + iVar1 = X.s - Y.s; + count_00 = iVar1 * 0x20; + iVar3 = mbedtls_mpi_shift_l((mbedtls_mpi *)&X.p,count_00); + while (iVar3 == 0) { + iVar3 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&iStack124,(mbedtls_mpi *)&X.p); + if (iVar3 < 0) { + iVar1 = mbedtls_mpi_shift_r((mbedtls_mpi *)&X.p,count_00); + iVar3 = iVar1; + if (iVar1 == 0) { + uVar12 = iVar4 - 1; + iVar2 = ((uVar10 + 0x3fffffff) - iVar4) * 4; + goto LAB_23061c8a; + } + break; + } + piVar9 = (int *)(Z.n + iVar1 * 4); + *piVar9 = *piVar9 + 1; + iVar3 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&iStack124,(mbedtls_mpi *)&iStack124, + (mbedtls_mpi *)&X.p); + } + } + } + } +cleanup: + mbedtls_mpi_free((mbedtls_mpi *)&iStack124); + mbedtls_mpi_free((mbedtls_mpi *)&X.p); + mbedtls_mpi_free((mbedtls_mpi *)&Y.p); + mbedtls_mpi_free((mbedtls_mpi *)&Z.p); + mbedtls_mpi_free((mbedtls_mpi *)&T1.p); + return iVar3; +LAB_23061c8a: + uVar10 = uVar10 - 1; + if (uVar10 <= uVar12) goto code_r0x23061c8e; + iVar11 = uVar10 * 4; + uVar6 = *(uint *)(X.n + iVar11); + uVar7 = *(uint *)(Y.n + uVar12 * 4); + puVar13 = (undefined4 *)(Z.n + iVar2); + if (uVar6 < uVar7) { + uVar5 = *(undefined4 *)(X.n + iVar11 + -4); + uVar8 = 0xffffffff; + if ((uVar7 != 0) && (__udivdi3(), uVar8 = uVar5, uVar6 != 0)) { + uVar8 = 0xffffffff; + } + *puVar13 = uVar8; + } + else { + *puVar13 = 0xffffffff; + } + *(int *)(Z.n + iVar2) = *(int *)(Z.n + iVar2) + 1; + do { + *(int *)(Z.n + iVar2) = *(int *)(Z.n + iVar2) + -1; + iVar3 = mbedtls_mpi_lset((mbedtls_mpi *)&Z.p,0); + if (iVar3 != 0) goto cleanup; + uVar8 = 0; + if (uVar12 != 0) { + uVar8 = *(undefined4 *)(Y.n + iVar4 * 4 + -8); + } + *(undefined4 *)T1.n = uVar8; + *(undefined4 *)(T1.n + 4) = *(undefined4 *)(Y.n + uVar12 * 4); + iVar3 = mbedtls_mpi_mul_int((mbedtls_mpi *)&Z.p,(mbedtls_mpi *)&Z.p, + *(mbedtls_mpi_uint *)(Z.n + iVar2)); + if ((iVar3 != 0) || (iVar3 = mbedtls_mpi_lset((mbedtls_mpi *)&T1.p,0), iVar3 != 0)) + goto cleanup; + ___EM_SIZE = 0; + if (uVar10 != 1) { + ___EM_SIZE = *(undefined4 *)(X.n + iVar11 + -8); + } + _DAT_00000004 = *(undefined4 *)(X.n + iVar11 + -4); + _DAT_00000008 = *(mbedtls_mpi_uint *)(X.n + iVar11); + iVar3 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&Z.p,(mbedtls_mpi *)&T1.p); + } while (0 < iVar3); + iVar3 = mbedtls_mpi_mul_int((mbedtls_mpi *)&Z.p,(mbedtls_mpi *)&X.p, + *(mbedtls_mpi_uint *)(Z.n + iVar2)); + if (iVar3 != 0) goto cleanup; + iVar3 = mbedtls_mpi_shift_l((mbedtls_mpi *)&Z.p,iVar2 << 3); + if ((iVar3 != 0) || + (iVar3 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&iStack124,(mbedtls_mpi *)&iStack124, + (mbedtls_mpi *)&Z.p), iVar3 != 0)) goto cleanup; + iVar3 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&iStack124,0); + if (iVar3 < 0) { + iVar3 = mbedtls_mpi_copy((mbedtls_mpi *)&Z.p,(mbedtls_mpi *)&X.p); + if (((iVar3 != 0) || (iVar3 = mbedtls_mpi_shift_l((mbedtls_mpi *)&Z.p,iVar2 << 3), iVar3 != 0)) + || (iVar3 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&iStack124,(mbedtls_mpi *)&iStack124, + (mbedtls_mpi *)&Z.p), iVar3 != 0)) goto cleanup; + *(int *)(Z.n + iVar2) = *(int *)(Z.n + iVar2) + -1; + } + iVar2 = iVar2 + -4; + goto LAB_23061c8a; +code_r0x23061c8e: + if (Q != (mbedtls_mpi *)0x0) { + iVar3 = mbedtls_mpi_copy(Q,(mbedtls_mpi *)&Y.p); + if (iVar3 != 0) goto cleanup; + Q->s = A->s * B->s; + } + iVar3 = iVar1; + if ((R != (mbedtls_mpi *)0x0) && + (iVar3 = mbedtls_mpi_shift_r((mbedtls_mpi *)&iStack124,count), iVar3 == 0)) { + iStack124 = A->s; + iVar3 = mbedtls_mpi_copy(R,(mbedtls_mpi *)&iStack124); + if ((iVar3 == 0) && (iVar4 = mbedtls_mpi_cmp_int(R,0), iVar3 = iVar1, iVar4 == 0)) { + R->s = 1; + iVar3 = 0; + } + } + goto cleanup; +} + + + +int mbedtls_mpi_mod_mpi(mbedtls_mpi *R,mbedtls_mpi *A,mbedtls_mpi *B) + +{ + int iVar1; + int iVar2; + + iVar1 = mbedtls_mpi_cmp_int(B,0); + if (iVar1 < 0) { + return -10; + } + iVar2 = mbedtls_mpi_div_mpi((mbedtls_mpi *)0x0,R,A,B); + iVar1 = iVar2; + while( true ) { + if (iVar1 != 0) { + return iVar1; + } + iVar1 = mbedtls_mpi_cmp_int(R,0); + if (-1 < iVar1) break; + iVar1 = mbedtls_mpi_add_mpi(R,R,B); + } + do { + iVar1 = mbedtls_mpi_cmp_mpi(R,B); + if (iVar1 < 0) { + return iVar2; + } + iVar1 = mbedtls_mpi_sub_mpi(R,R,B); + } while (iVar1 == 0); + return iVar1; +} + + + +int mbedtls_mpi_exp_mod(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *E,mbedtls_mpi *N,mbedtls_mpi *_RR + ) + +{ + uint uVar1; + mbedtls_mpi_uint mm; + int iVar2; + size_t nblimbs; + mbedtls_mpi *X_00; + mbedtls_mpi *X_01; + uint uVar3; + int iVar4; + int iVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint uVar9; + size_t sVar10; + mbedtls_mpi_uint mStack1652; + mbedtls_mpi_uint z; + mbedtls_mpi RR; + mbedtls_mpi T; + mbedtls_mpi Apos; + mbedtls_mpi U; + mbedtls_mpi W [128]; + + iVar2 = mbedtls_mpi_cmp_int(N,0); + if (iVar2 < 0) { + return -4; + } + uVar6 = *N->p; + uVar9 = uVar6 & 1; + if (uVar9 == 0) { + return -4; + } + iVar2 = mbedtls_mpi_cmp_int(E,0); + if (iVar2 < 0) { + return -4; + } + iVar2 = ((uVar6 + 2) * 2 & 8) + uVar6; + iVar4 = 3; + do { + iVar4 = iVar4 + -1; + iVar2 = iVar2 * (2 - uVar6 * iVar2); + } while (iVar4 != 0); + z = 1; + RR.p = (mbedtls_mpi_uint *)0x1; + T.p = (mbedtls_mpi_uint *)0x1; + RR.s = 0; + RR.n = 0; + T.s = 0; + T.n = 0; + Apos.s = 0; + Apos.n = 0; + memset(&U.p,0,0x600); + nblimbs = mbedtls_mpi_bitlen(E); + uVar6 = 6; + if ((((nblimbs < 0x2a0) && (uVar6 = 5, nblimbs < 0xf0)) && (uVar6 = 4, nblimbs < 0x50)) && + (uVar6 = 3, nblimbs < 0x18)) { + uVar6 = uVar9; + } + nblimbs = N->n + 1; + iVar4 = mbedtls_mpi_grow(X,nblimbs); + if (((iVar4 != 0) || (iVar4 = mbedtls_mpi_grow((mbedtls_mpi *)&W[0].p,nblimbs), iVar4 != 0)) || + (iVar4 = mbedtls_mpi_grow((mbedtls_mpi *)&RR.p,nblimbs * 2), iVar4 != 0)) goto cleanup; + iVar5 = A->s; + if (iVar5 == -1) { + iVar4 = mbedtls_mpi_copy((mbedtls_mpi *)&T.p,A); + if (iVar4 != 0) goto cleanup; + T.p = (mbedtls_mpi_uint *)0x1; + A = (mbedtls_mpi *)&T.p; + } + if ((_RR == (mbedtls_mpi *)0x0) || (_RR->p == (mbedtls_mpi_uint *)0x0)) { + iVar4 = mbedtls_mpi_lset((mbedtls_mpi *)&z,1); + if ((iVar4 != 0) || + ((iVar4 = mbedtls_mpi_shift_l((mbedtls_mpi *)&z,N->n << 6), iVar4 != 0 || + (iVar4 = mbedtls_mpi_mod_mpi((mbedtls_mpi *)&z,(mbedtls_mpi *)&z,N), iVar4 != 0)))) + goto cleanup; + if (_RR != (mbedtls_mpi *)0x0) { + X_00 = _RR; + X_01 = (mbedtls_mpi *)&z; + goto LAB_23062022; + } + } + else { + X_00 = (mbedtls_mpi *)&z; + X_01 = _RR; +LAB_23062022: + memcpy(X_00,X_01,0xc); + } + iVar4 = mbedtls_mpi_cmp_mpi(A,N); + if (iVar4 < 0) { + iVar4 = mbedtls_mpi_copy((mbedtls_mpi *)&W[0].p,A); + } + else { + iVar4 = mbedtls_mpi_mod_mpi((mbedtls_mpi *)&W[0].p,A,N); + } + if (iVar4 == 0) { + mm = -iVar2; + iVar4 = mpi_montmul((mbedtls_mpi *)&W[0].p,(mbedtls_mpi *)&z,N,mm,(mbedtls_mpi *)&RR.p); + if ((iVar4 == 0) && (iVar4 = mbedtls_mpi_copy(X,(mbedtls_mpi *)&z), iVar4 == 0)) { + U.n = (size_t)&mStack1652; + mStack1652 = 1; + Apos.p = (mbedtls_mpi_uint *)0x1; + U.s = 1; + iVar4 = mpi_montmul(X,(mbedtls_mpi *)&Apos.p,N,mm,(mbedtls_mpi *)&RR.p); + if (iVar4 == 0) { + if (uVar6 == 1) { +LAB_2306208c: + nblimbs = E->n; + uVar7 = 0; + uVar1 = 0; + do { + sVar10 = 0; + uVar8 = 0; +LAB_23062182: + do { + if (uVar7 == 0) { + if (nblimbs == 0) { + goto LAB_23062190; + } + nblimbs = nblimbs - 1; + uVar7 = 0x20; + } + uVar7 = uVar7 - 1; + uVar3 = E->p[nblimbs] >> (uVar7 & 0x1f) & 1; + if (uVar3 == 0) { + if (uVar1 == 0) goto LAB_23062182; + if (uVar1 == 1) { + iVar4 = mpi_montmul(X,X,N,mm,(mbedtls_mpi *)&RR.p); + if (iVar4 != 0) goto cleanup; + goto LAB_23062182; + } + } + sVar10 = sVar10 + 1; + uVar8 = uVar8 | uVar3 << (uVar6 - sVar10 & 0x1f); + uVar1 = 2; + } while (uVar6 != sVar10); + uVar1 = 0; + do { + iVar4 = mpi_montmul(X,X,N,mm,(mbedtls_mpi *)&RR.p); + if (iVar4 != 0) goto cleanup; + uVar1 = uVar1 + 1; + } while (uVar1 < sVar10); + iVar4 = mpi_montmul(X,(mbedtls_mpi *)&(&U)[uVar8].p,N,mm,(mbedtls_mpi *)&RR.p); + uVar1 = uVar9; + } while (iVar4 == 0); + } + else { + uVar7 = uVar6 - 1; + X_00 = (mbedtls_mpi *)((int)&U.p + (0xc << (uVar7 & 0x1f))); + iVar4 = mbedtls_mpi_grow(X_00,N->n + 1); + uVar1 = 1 << (uVar7 & 0x1f); + if ((iVar4 == 0) && (iVar4 = mbedtls_mpi_copy(X_00,(mbedtls_mpi *)&W[0].p), iVar4 == 0)) { + uVar8 = 0; + do { + iVar4 = mpi_montmul(X_00,X_00,N,mm,(mbedtls_mpi *)&RR.p); + if (iVar4 != 0) goto cleanup; + uVar8 = uVar8 + 1; + } while (uVar8 < uVar7); + do { + uVar1 = uVar1 + 1; + if ((uint)(1 << uVar6) <= uVar1) goto LAB_2306208c; + X_01 = X_00 + 1; + iVar4 = mbedtls_mpi_grow(X_01,N->n + 1); + } while (((iVar4 == 0) && (iVar4 = mbedtls_mpi_copy(X_01,X_00), iVar4 == 0)) && + (iVar4 = mpi_montmul(X_01,(mbedtls_mpi *)&W[0].p,N,mm,(mbedtls_mpi *)&RR.p), + X_00 = X_01, iVar4 == 0)); + } + } + } + } + } +cleanup: + uVar9 = 1 << (uVar6 - 1 & 0x1f); + while (uVar9 < (uint)(1 << uVar6)) { + mbedtls_mpi_free((mbedtls_mpi *)&(&U)[uVar9].p); + uVar9 = uVar9 + 1; + } + mbedtls_mpi_free((mbedtls_mpi *)&W[0].p); + mbedtls_mpi_free((mbedtls_mpi *)&RR.p); + mbedtls_mpi_free((mbedtls_mpi *)&T.p); + if ((_RR == (mbedtls_mpi *)0x0) || (_RR->p == (mbedtls_mpi_uint *)0x0)) { + mbedtls_mpi_free((mbedtls_mpi *)&z); + } + return iVar4; +LAB_23062190: + if (nblimbs == sVar10) goto code_r0x23062194; + iVar4 = mpi_montmul(X,X,N,mm,(mbedtls_mpi *)&RR.p); + if ((iVar4 != 0) || + ((uVar8 = uVar8 << 1, (1 << uVar6 & uVar8) != 0 && + (iVar4 = mpi_montmul(X,(mbedtls_mpi *)&W[0].p,N,mm,(mbedtls_mpi *)&RR.p), iVar4 != 0)))) + goto cleanup; + nblimbs = nblimbs + 1; + goto LAB_23062190; +code_r0x23062194: + mStack1652 = 1; + Apos.p = (mbedtls_mpi_uint *)0x1; + U.s = 1; + U.n = (size_t)&mStack1652; + iVar4 = mpi_montmul(X,(mbedtls_mpi *)&Apos.p,N,mm,(mbedtls_mpi *)&RR.p); + if ((iVar4 == 0) && (iVar5 == -1)) { + X->s = -1; + iVar4 = mbedtls_mpi_add_mpi(X,N,X); + } + goto cleanup; +} + + + +// WARNING: Variable defined which should be unmapped: TB + +int mbedtls_mpi_gcd(mbedtls_mpi *G,mbedtls_mpi *A,mbedtls_mpi *B) + +{ + mbedtls_mpi *pmVar1; + int iVar2; + size_t count; + size_t count_00; + int iStack52; + mbedtls_mpi TG; + mbedtls_mpi TA; + mbedtls_mpi TB; + + iStack52 = 1; + TG.s = 0; + TG.n = 0; + TG.p = (mbedtls_mpi_uint *)0x1; + TA.s = 0; + TA.n = 0; + TA.p = (mbedtls_mpi_uint *)0x1; + iVar2 = mbedtls_mpi_copy((mbedtls_mpi *)&TG.p,A); + if ((iVar2 == 0) && (iVar2 = mbedtls_mpi_copy((mbedtls_mpi *)&TA.p,B), iVar2 == 0)) { + count = mbedtls_mpi_lsb((mbedtls_mpi *)&TG.p); + count_00 = mbedtls_mpi_lsb((mbedtls_mpi *)&TA.p); + if (count_00 < count) { + count = count_00; + } + iVar2 = mbedtls_mpi_shift_r((mbedtls_mpi *)&TG.p,count); + if ((iVar2 == 0) && (iVar2 = mbedtls_mpi_shift_r((mbedtls_mpi *)&TA.p,count), iVar2 == 0)) { + TA.p = (mbedtls_mpi_uint *)0x1; + TG.p = (mbedtls_mpi_uint *)0x1; + do { + iVar2 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&TG.p,0); + if (iVar2 == 0) { + iVar2 = mbedtls_mpi_shift_l((mbedtls_mpi *)&TA.p,count); + if (iVar2 == 0) { + iVar2 = mbedtls_mpi_copy(G,(mbedtls_mpi *)&TA.p); + } + break; + } + count_00 = mbedtls_mpi_lsb((mbedtls_mpi *)&TG.p); + iVar2 = mbedtls_mpi_shift_r((mbedtls_mpi *)&TG.p,count_00); + if (iVar2 != 0) break; + count_00 = mbedtls_mpi_lsb((mbedtls_mpi *)&TA.p); + iVar2 = mbedtls_mpi_shift_r((mbedtls_mpi *)&TA.p,count_00); + if (iVar2 != 0) break; + iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&TG.p,(mbedtls_mpi *)&TA.p); + if (iVar2 < 0) { + iVar2 = mbedtls_mpi_sub_abs((mbedtls_mpi *)&TA.p,(mbedtls_mpi *)&TA.p,(mbedtls_mpi *)&TG.p + ); + if (iVar2 != 0) break; + pmVar1 = &TA; + } + else { + iVar2 = mbedtls_mpi_sub_abs((mbedtls_mpi *)&TG.p,(mbedtls_mpi *)&TG.p,(mbedtls_mpi *)&TA.p + ); + if (iVar2 != 0) break; + pmVar1 = &TG; + } + iVar2 = mbedtls_mpi_shift_r((mbedtls_mpi *)&pmVar1->p,1); + } while (iVar2 == 0); + } + } + mbedtls_mpi_free((mbedtls_mpi *)&iStack52); + mbedtls_mpi_free((mbedtls_mpi *)&TG.p); + mbedtls_mpi_free((mbedtls_mpi *)&TA.p); + return iVar2; +} + + + +int mbedtls_mpi_fill_random + (mbedtls_mpi *X,size_t size,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng + ) + +{ + int iVar1; + uchar auStack1040 [4]; + uchar buf [1024]; + + if (size < 0x401) { + iVar1 = (*f_rng)(p_rng,auStack1040,size); + if (iVar1 == 0) { + iVar1 = mbedtls_mpi_read_binary(X,auStack1040,size); + } + return iVar1; + } + return -4; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mbedtls_mpi_inv_mod(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *N) + +{ + mbedtls_mpi *pmVar1; + mbedtls_mpi *pmVar2; + int iVar3; + int iVar4; + int iStack140; + mbedtls_mpi G; + mbedtls_mpi TA; + mbedtls_mpi TU; + mbedtls_mpi U1; + mbedtls_mpi U2; + mbedtls_mpi TB; + mbedtls_mpi TV; + mbedtls_mpi V1; + mbedtls_mpi V2; + + iVar3 = mbedtls_mpi_cmp_int(N,0); + if (iVar3 < 1) { + return -4; + } + G.p = (mbedtls_mpi_uint *)0x1; + TA.s = 0; + TA.n = 0; + TA.p = (mbedtls_mpi_uint *)0x1; + TU.s = 0; + TU.n = 0; + TU.p = (mbedtls_mpi_uint *)0x1; + U1.s = 0; + U1.n = 0; + U1.p = (mbedtls_mpi_uint *)0x1; + U2.s = 0; + U2.n = 0; + iStack140 = 1; + G.s = 0; + G.n = 0; + U2.p = (mbedtls_mpi_uint *)0x1; + TB.s = 0; + TB.n = 0; + TB.p = (mbedtls_mpi_uint *)0x1; + TV.s = 0; + TV.n = 0; + TV.p = (mbedtls_mpi_uint *)0x1; + V1.s = 0; + V1.n = 0; + V1.p = (mbedtls_mpi_uint *)0x1; + iVar3 = mbedtls_mpi_gcd((mbedtls_mpi *)&iStack140,A,N); + if (iVar3 == 0) { + iVar4 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&iStack140,1); + iVar3 = -0xe; + if (((((iVar4 == 0) && (iVar3 = mbedtls_mpi_mod_mpi((mbedtls_mpi *)&G.p,A,N), iVar3 == 0)) && + (iVar3 = mbedtls_mpi_copy((mbedtls_mpi *)&TA.p,(mbedtls_mpi *)&G.p), iVar3 == 0)) && + ((iVar3 = mbedtls_mpi_copy((mbedtls_mpi *)&U2.p,N), iVar3 == 0 && + (iVar3 = mbedtls_mpi_copy((mbedtls_mpi *)&TB.p,N), iVar3 == 0)))) && + ((iVar3 = mbedtls_mpi_lset((mbedtls_mpi *)&TU.p,1), iVar3 == 0 && + ((iVar3 = mbedtls_mpi_lset((mbedtls_mpi *)&U1.p,0), iVar3 == 0 && + (iVar3 = mbedtls_mpi_lset((mbedtls_mpi *)&TV.p,0), iVar3 == 0)))))) { + iVar3 = mbedtls_mpi_lset((mbedtls_mpi *)&V1.p,1); + while (iVar3 == 0) { + while ((*(uint *)TU.n & 1) != 0) { + while ((*(uint *)TV.n & 1) == 0) { + iVar3 = mbedtls_mpi_shift_r((mbedtls_mpi *)&TB.p,1); + if ((iVar3 != 0) || + (((((*(uint *)V1.n & 1) != 0 || ((___EM_SIZE & 1) != 0)) && + ((iVar3 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&TV.p,(mbedtls_mpi *)&TV.p, + (mbedtls_mpi *)&U2.p), iVar3 != 0 || + (iVar3 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&V1.p,(mbedtls_mpi *)&V1.p, + (mbedtls_mpi *)&G.p), iVar3 != 0)))) || + ((iVar3 = mbedtls_mpi_shift_r((mbedtls_mpi *)&TV.p,1), iVar3 != 0 || + (iVar3 = mbedtls_mpi_shift_r((mbedtls_mpi *)&V1.p,1), iVar3 != 0)))))) + goto cleanup; + } + iVar3 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&TA.p,(mbedtls_mpi *)&TB.p); + if (iVar3 < 0) { + iVar3 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&TB.p,(mbedtls_mpi *)&TB.p, + (mbedtls_mpi *)&TA.p); + if ((iVar3 != 0) || + (iVar3 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&TV.p,(mbedtls_mpi *)&TV.p, + (mbedtls_mpi *)&TU.p), iVar3 != 0)) goto cleanup; + pmVar1 = &U1; + pmVar2 = &V1; + } + else { + iVar3 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&TA.p,(mbedtls_mpi *)&TA.p, + (mbedtls_mpi *)&TB.p); + if ((iVar3 != 0) || + (iVar3 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&TU.p,(mbedtls_mpi *)&TU.p, + (mbedtls_mpi *)&TV.p), iVar3 != 0)) goto cleanup; + pmVar1 = &V1; + pmVar2 = &U1; + } + iVar3 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&pmVar2->p,(mbedtls_mpi *)&pmVar2->p, + (mbedtls_mpi *)&pmVar1->p); + if (iVar3 != 0) goto cleanup; + iVar3 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&TA.p,0); + if (iVar3 == 0) goto LAB_23062556; + } + iVar3 = mbedtls_mpi_shift_r((mbedtls_mpi *)&TA.p,1); + if (((iVar3 != 0) || + ((((*(uint *)U1.n & 1) != 0 || ((*(uint *)U2.n & 1) != 0)) && + ((iVar3 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&TU.p,(mbedtls_mpi *)&TU.p, + (mbedtls_mpi *)&U2.p), iVar3 != 0 || + (iVar3 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&U1.p,(mbedtls_mpi *)&U1.p, + (mbedtls_mpi *)&G.p), iVar3 != 0)))))) || + (iVar3 = mbedtls_mpi_shift_r((mbedtls_mpi *)&TU.p,1), iVar3 != 0)) break; + iVar3 = mbedtls_mpi_shift_r((mbedtls_mpi *)&U1.p,1); + } + } + } + goto cleanup; + while (iVar3 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&TV.p,(mbedtls_mpi *)&TV.p,N), iVar3 == 0) { +LAB_23062556: + iVar3 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&TV.p,0); + if (-1 < iVar3) goto LAB_23062562; + } + goto cleanup; + while (iVar3 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&TV.p,(mbedtls_mpi *)&TV.p,N), iVar3 == 0) { +LAB_23062562: + iVar3 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&TV.p,N); + if (iVar3 < 0) { + iVar3 = mbedtls_mpi_copy(X,(mbedtls_mpi *)&TV.p); + break; + } + } +cleanup: + mbedtls_mpi_free((mbedtls_mpi *)&G.p); + mbedtls_mpi_free((mbedtls_mpi *)&TA.p); + mbedtls_mpi_free((mbedtls_mpi *)&TU.p); + mbedtls_mpi_free((mbedtls_mpi *)&U1.p); + mbedtls_mpi_free((mbedtls_mpi *)&iStack140); + mbedtls_mpi_free((mbedtls_mpi *)&U2.p); + mbedtls_mpi_free((mbedtls_mpi *)&TB.p); + mbedtls_mpi_free((mbedtls_mpi *)&TV.p); + mbedtls_mpi_free((mbedtls_mpi *)&V1.p); + return iVar3; +} + + + +uint mbedtls_cipher_get_block_size(mbedtls_cipher_context_t *ctx) + +{ + if ((ctx != (mbedtls_cipher_context_t *)0x0) && (ctx->cipher_info != (mbedtls_cipher_info_t *)0x0) + ) { + return ctx->cipher_info->block_size; + } + return 0; +} + + + +void add_pkcs_padding(uchar *output,size_t output_len,size_t data_len) + +{ + uint uVar1; + + uVar1 = 0; + while (uVar1 < output_len - data_len) { + output[data_len + uVar1] = (uchar)(output_len - data_len); + uVar1 = uVar1 + 1 & 0xff; + } + return; +} + + + +int get_pkcs_padding(uchar *input,size_t input_len,size_t *data_len) + +{ + byte bVar1; + bool bVar2; + byte *pbVar3; + uint uVar4; + bool bVar5; + uint uVar6; + + if ((input == (uchar *)0x0) || (data_len == (size_t *)0x0)) { + return -0x6100; + } + bVar1 = input[input_len - 1]; + uVar6 = input_len - bVar1; + bVar5 = input_len < bVar1 || bVar1 == 0; + *data_len = uVar6; + uVar4 = 0; + while (uVar4 != input_len) { + pbVar3 = input + uVar4; + bVar2 = uVar6 <= uVar4; + uVar4 = uVar4 + 1; + bVar5 = (bool)(bVar5 | bVar2 * (bVar1 ^ *pbVar3)); + } + if (bVar5 == false) { + return 0; + } + return -0x6200; +} + + + +void add_zeros_padding(uchar *output,size_t output_len,size_t data_len) + +{ + if (output_len <= data_len) { + return; + } + output[data_len] = '\0'; + add_zeros_padding(output,output_len,data_len + 1); + return; +} + + + +int get_no_padding(uchar *input,size_t input_len,size_t *data_len) + +{ + if ((input != (uchar *)0x0) && (data_len != (size_t *)0x0)) { + *data_len = input_len; + return 0; + } + return -0x6100; +} + + + +int get_zeros_padding(uchar *input,size_t input_len,size_t *data_len) + +{ + uint uVar1; + uint uVar2; + + if ((input != (uchar *)0x0) && (data_len != (size_t *)0x0)) { + *data_len = 0; + uVar2 = 0; + while (input_len != 0) { + uVar1 = input[input_len - 1] != '\0' | uVar2; + *data_len = (uVar2 ^ uVar1) * input_len | *data_len; + input_len = input_len - 1; + uVar2 = uVar1; + } + return 0; + } + return -0x6100; +} + + + +mbedtls_cipher_info_t * mbedtls_cipher_info_from_type(mbedtls_cipher_type_t cipher_type) + +{ + undefined3 in_register_00002029; + mbedtls_cipher_definition_t *pmVar1; + + pmVar1 = mbedtls_cipher_definitions; + while ((pmVar1->info != (mbedtls_cipher_info_t *)0x0 && + ((uint)pmVar1->type != CONCAT31(in_register_00002029,cipher_type)))) { + pmVar1 = pmVar1 + 1; + } + return pmVar1->info; +} + + + +mbedtls_cipher_info_t * +mbedtls_cipher_info_from_values + (mbedtls_cipher_id_t cipher_id,int key_bitlen,mbedtls_cipher_mode_t mode) + +{ + undefined3 in_register_00002029; + undefined3 in_register_00002031; + mbedtls_cipher_definition_t *pmVar1; + mbedtls_cipher_info_t *pmVar2; + + pmVar1 = mbedtls_cipher_definitions; + while ((pmVar2 = pmVar1->info, pmVar2 != (mbedtls_cipher_info_t *)0x0 && + ((((uint)pmVar2->base->cipher != CONCAT31(in_register_00002029,cipher_id) || + (pmVar2->key_bitlen != key_bitlen)) || + ((uint)pmVar2->mode != CONCAT31(in_register_00002031,mode)))))) { + pmVar1 = pmVar1 + 1; + } + return pmVar2; +} + + + +void mbedtls_cipher_init(mbedtls_cipher_context_t *ctx) + +{ + memset(ctx,0,0x40); + return; +} + + + +void mbedtls_cipher_free(mbedtls_cipher_context_t *ctx) + +{ + mbedtls_cipher_context_t *pmVar1; + + if (ctx != (mbedtls_cipher_context_t *)0x0) { + if (ctx->cipher_ctx != (void *)0x0) { + (*ctx->cipher_info->base->ctx_free_func)(ctx->cipher_ctx); + } + pmVar1 = ctx + 1; + while (ctx != pmVar1) { + *(undefined *)&ctx->cipher_info = 0; + ctx = (mbedtls_cipher_context_t *)((int)&ctx->cipher_info + 1); + } + return; + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +int mbedtls_cipher_setkey + (mbedtls_cipher_context_t *ctx,uchar *key,int key_bitlen,mbedtls_operation_t operation + ) + +{ + anon_subr_int_void_ptr_uchar_ptr_uint_for_setkey_enc_func *UNRECOVERED_JUMPTABLE; + int iVar1; + undefined3 in_register_00002035; + mbedtls_cipher_info_t *pmVar2; + + if (((ctx != (mbedtls_cipher_context_t *)0x0) && + (pmVar2 = ctx->cipher_info, pmVar2 != (mbedtls_cipher_info_t *)0x0)) && + (((pmVar2->flags & 2U) != 0 || (pmVar2->key_bitlen == key_bitlen)))) { + ctx->key_bitlen = key_bitlen; + ctx->operation = operation; + if ((CONCAT31(in_register_00002035,operation) == 1) || + ((pmVar2->mode + ~MBEDTLS_MODE_CBC & 0xfd) == 0)) { + UNRECOVERED_JUMPTABLE = pmVar2->base->setkey_enc_func; + } + else { + if (CONCAT31(in_register_00002035,operation) != 0) { + return -0x6100; + } + UNRECOVERED_JUMPTABLE = + (anon_subr_int_void_ptr_uchar_ptr_uint_for_setkey_enc_func *) + pmVar2->base->setkey_dec_func; + } + // WARNING: Could not recover jumptable at 0x2306284c. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*UNRECOVERED_JUMPTABLE)(ctx->cipher_ctx); + return iVar1; + } + return -0x6100; +} + + + +int mbedtls_cipher_set_iv(mbedtls_cipher_context_t *ctx,uchar *iv,size_t iv_len) + +{ + mbedtls_cipher_info_t *pmVar1; + size_t __n; + + if (ctx == (mbedtls_cipher_context_t *)0x0) { + return -0x6100; + } + pmVar1 = ctx->cipher_info; + if ((pmVar1 != (mbedtls_cipher_info_t *)0x0) && (iv != (uchar *)0x0)) { + if (0x10 < iv_len) { + return -0x6080; + } + __n = iv_len; + if (((pmVar1->flags & 1U) != 0) || (__n = pmVar1->iv_size, __n <= iv_len)) { + memcpy(ctx->iv,iv,__n); + ctx->iv_size = __n; + return 0; + } + } + return -0x6100; +} + + + +int mbedtls_cipher_reset(mbedtls_cipher_context_t *ctx) + +{ + if ((ctx != (mbedtls_cipher_context_t *)0x0) && (ctx->cipher_info != (mbedtls_cipher_info_t *)0x0) + ) { + ctx->unprocessed_len = 0; + return 0; + } + return -0x6100; +} + + + +int mbedtls_cipher_update + (mbedtls_cipher_context_t *ctx,uchar *input,size_t ilen,uchar *output,size_t *olen) + +{ + mbedtls_cipher_mode_t mVar1; + uint uVar2; + int iVar3; + mbedtls_cipher_info_t *pmVar4; + size_t sVar5; + uint __n; + + if (ctx == (mbedtls_cipher_context_t *)0x0) { + return -0x6100; + } + if ((ctx->cipher_info == (mbedtls_cipher_info_t *)0x0) || (olen == (size_t *)0x0)) { + return -0x6100; + } + *olen = 0; + uVar2 = mbedtls_cipher_get_block_size(ctx); + pmVar4 = ctx->cipher_info; + mVar1 = pmVar4->mode; + if (mVar1 == MBEDTLS_MODE_ECB) { + if (uVar2 != ilen) { + return -0x6280; + } + *olen = uVar2; + // WARNING: Could not recover jumptable at 0x2306295c. Too many branches + // WARNING: Treating indirect jump as call + iVar3 = (*ctx->cipher_info->base->ecb_func)(ctx->cipher_ctx,ctx->operation,input,output); + return iVar3; + } + if (mVar1 == MBEDTLS_MODE_GCM) { + *olen = ilen; + iVar3 = mbedtls_gcm_update((mbedtls_gcm_context *)ctx->cipher_ctx,ilen,input,output); + return iVar3; + } + if (uVar2 == 0) { + return -0x6380; + } + if (input == output) { + if (ctx->unprocessed_len != 0) { + return -0x6100; + } + if (ilen % uVar2 != 0) { + return -0x6100; + } + } + if (mVar1 == MBEDTLS_MODE_CBC) { + sVar5 = ctx->unprocessed_len; + if (ctx->operation == MBEDTLS_DECRYPT) { + if (ilen <= uVar2 - sVar5) { +LAB_230629b2: + memcpy(ctx->unprocessed_data + sVar5,input,ilen); + ctx->unprocessed_len = ilen + ctx->unprocessed_len; + return 0; + } + } + else { + if ((ctx->operation == MBEDTLS_ENCRYPT) && (ilen < uVar2 - sVar5)) goto LAB_230629b2; + } + if (sVar5 != 0) { + memcpy(ctx->unprocessed_data + sVar5,input,uVar2 - sVar5); + iVar3 = (*ctx->cipher_info->base->cbc_func) + (ctx->cipher_ctx,ctx->operation,uVar2,ctx->iv,ctx->unprocessed_data,output); + if (iVar3 != 0) { + return iVar3; + } + output = output + uVar2; + *olen = *olen + uVar2; + ctx->unprocessed_len = 0; + input = input + (uVar2 - sVar5); + ilen = (ilen + sVar5) - uVar2; + } + if (ilen != 0) { + __n = ilen % uVar2; + if ((__n == 0) && (ctx->operation == MBEDTLS_DECRYPT)) { + __n = uVar2; + } + ilen = ilen - __n; + memcpy(ctx->unprocessed_data,input + ilen,__n); + ctx->unprocessed_len = __n + ctx->unprocessed_len; + if (ilen != 0) { + iVar3 = (*ctx->cipher_info->base->cbc_func) + (ctx->cipher_ctx,ctx->operation,ilen,ctx->iv,input,output); + if (iVar3 != 0) { + return iVar3; + } + ilen = ilen + *olen; + goto LAB_23062a78; + } + } + return 0; + } + if (mVar1 == MBEDTLS_MODE_CFB) { + iVar3 = (*pmVar4->base->cfb_func) + (ctx->cipher_ctx,ctx->operation,ilen,&ctx->unprocessed_len,ctx->iv,input, + output); + } + else { + if (mVar1 != MBEDTLS_MODE_CTR) { + return -0x6080; + } + iVar3 = (*pmVar4->base->ctr_func) + (ctx->cipher_ctx,ilen,&ctx->unprocessed_len,ctx->iv,ctx->unprocessed_data, + input,output); + } + if (iVar3 != 0) { + return iVar3; + } +LAB_23062a78: + *olen = ilen; + return iVar3; +} + + + +int mbedtls_cipher_finish(mbedtls_cipher_context_t *ctx,uchar *output,size_t *olen) + +{ + mbedtls_cipher_mode_t mVar1; + int iVar2; + uint uVar3; + size_t sVar4; + size_t sVar5; + + if (((ctx == (mbedtls_cipher_context_t *)0x0) || + (ctx->cipher_info == (mbedtls_cipher_info_t *)0x0)) || (olen == (size_t *)0x0)) { + return -0x6100; + } + *olen = 0; + mVar1 = ctx->cipher_info->mode; + if ((mVar1 == MBEDTLS_MODE_CFB) || ((byte)(mVar1 + ~MBEDTLS_MODE_OFB) < 3)) { + return 0; + } + if (mVar1 == MBEDTLS_MODE_ECB) { + sVar5 = ctx->unprocessed_len; +joined_r0x23062b46: + if (sVar5 == 0) { + return 0; + } +LAB_23062b24: + iVar2 = -0x6280; + } + else { + if (mVar1 != MBEDTLS_MODE_CBC) { + return -0x6080; + } + sVar5 = ctx->unprocessed_len; + if (ctx->operation == MBEDTLS_ENCRYPT) { + if (ctx->add_padding == (anon_subr_void_uchar_ptr_size_t_size_t_for_add_padding *)0x0) + goto joined_r0x23062b46; + sVar4 = ctx->iv_size; + if (sVar4 == 0) { + sVar4 = ctx->cipher_info->iv_size; + } + (*ctx->add_padding)(ctx->unprocessed_data,sVar4,sVar5); + } + else { + uVar3 = mbedtls_cipher_get_block_size(ctx); + if (uVar3 != sVar5) { + if ((ctx->add_padding == (anon_subr_void_uchar_ptr_size_t_size_t_for_add_padding *)0x0) && + (sVar5 == 0)) { + return 0; + } + goto LAB_23062b24; + } + } + uVar3 = mbedtls_cipher_get_block_size(ctx); + iVar2 = (*ctx->cipher_info->base->cbc_func) + (ctx->cipher_ctx,ctx->operation,uVar3,ctx->iv,ctx->unprocessed_data,output); + if (iVar2 == 0) { + uVar3 = mbedtls_cipher_get_block_size(ctx); + if (ctx->operation == MBEDTLS_DECRYPT) { + // WARNING: Could not recover jumptable at 0x23062bb2. Too many branches + // WARNING: Treating indirect jump as call + iVar2 = (*ctx->get_padding)(output,uVar3,olen); + return iVar2; + } + *olen = uVar3; + } + } + return iVar2; +} + + + +int mbedtls_cipher_set_padding_mode(mbedtls_cipher_context_t *ctx,mbedtls_cipher_padding_t mode) + +{ + undefined3 in_register_0000202d; + int iVar1; + code *pcVar2; + + iVar1 = CONCAT31(in_register_0000202d,mode); + if ((ctx != (mbedtls_cipher_context_t *)0x0) && (ctx->cipher_info->mode == MBEDTLS_MODE_CBC)) { + if (iVar1 == 3) { + ctx->add_padding = add_zeros_padding; + pcVar2 = get_zeros_padding; + } + else { + if (iVar1 == 4) { + ctx->add_padding = (anon_subr_void_uchar_ptr_size_t_size_t_for_add_padding *)0x0; + pcVar2 = get_no_padding; + } + else { + if (iVar1 != 0) { + return -0x6080; + } + ctx->add_padding = add_pkcs_padding; + pcVar2 = get_pkcs_padding; + } + } + ctx->get_padding = pcVar2; + return 0; + } + return -0x6100; +} + + + +int mbedtls_cipher_setup(mbedtls_cipher_context_t *ctx,mbedtls_cipher_info_t *cipher_info) + +{ + void *pvVar1; + int iVar2; + anon_subr_void_ptr_for_ctx_alloc_func *paVar3; + + if (cipher_info != (mbedtls_cipher_info_t *)0x0) { + if (ctx == (mbedtls_cipher_context_t *)0x0) { + iVar2 = -0x6100; + } + else { + memset(ctx,0,0x40); + paVar3 = cipher_info->base->ctx_alloc_func; + pvVar1 = (*paVar3)(paVar3); + ctx->cipher_ctx = pvVar1; + if (pvVar1 == (void *)0x0) { + iVar2 = -0x6180; + } + else { + ctx->cipher_info = cipher_info; + mbedtls_cipher_set_padding_mode(ctx,MBEDTLS_PADDING_PKCS7); + iVar2 = 0; + } + } + return iVar2; + } + return -0x6100; +} + + + +int mbedtls_cipher_crypt + (mbedtls_cipher_context_t *ctx,uchar *iv,size_t iv_len,uchar *input,size_t ilen, + uchar *output,size_t *olen) + +{ + int iVar1; + size_t sStack36; + size_t finish_olen; + + iVar1 = mbedtls_cipher_set_iv(ctx,iv,iv_len); + if ((((iVar1 == 0) && (iVar1 = mbedtls_cipher_reset(ctx), iVar1 == 0)) && + (iVar1 = mbedtls_cipher_update(ctx,input,ilen,output,olen), iVar1 == 0)) && + (iVar1 = mbedtls_cipher_finish(ctx,output + *olen,&sStack36), iVar1 == 0)) { + *olen = *olen + sStack36; + } + return iVar1; +} + + + +int mbedtls_cipher_auth_encrypt + (mbedtls_cipher_context_t *ctx,uchar *iv,size_t iv_len,uchar *ad,size_t ad_len, + uchar *input,size_t ilen,uchar *output,size_t *olen,uchar *tag,size_t tag_len) + +{ + int iVar1; + size_t *in_stack_00000000; + + if (ctx->cipher_info->mode == MBEDTLS_MODE_GCM) { + *in_stack_00000000 = ilen; + iVar1 = mbedtls_gcm_crypt_and_tag + ((mbedtls_gcm_context *)ctx->cipher_ctx,1,ilen,iv,iv_len,ad,ad_len,input, + (uchar *)olen,(size_t)tag,(uchar *)tag_len); + return iVar1; + } + return -0x6080; +} + + + +int mbedtls_cipher_auth_decrypt + (mbedtls_cipher_context_t *ctx,uchar *iv,size_t iv_len,uchar *ad,size_t ad_len, + uchar *input,size_t ilen,uchar *output,size_t *olen,uchar *tag,size_t tag_len) + +{ + int iVar1; + size_t *in_stack_00000000; + uchar *in_stack_00000004; + size_t in_stack_00000008; + + if (ctx->cipher_info->mode == MBEDTLS_MODE_GCM) { + *in_stack_00000000 = ilen; + iVar1 = mbedtls_gcm_auth_decrypt + ((mbedtls_gcm_context *)ctx->cipher_ctx,ilen,iv,iv_len,ad,ad_len, + in_stack_00000004,in_stack_00000008,(uchar *)olen,tag); + if (iVar1 == -0x12) { + iVar1 = -0x6300; + } + return iVar1; + } + return -0x6080; +} + + + +void gcm_ctx_free(void *ctx) + +{ + mbedtls_gcm_free((mbedtls_gcm_context *)ctx); + vPortFree(ctx); + return; +} + + + +void * gcm_ctx_alloc(void) + +{ + mbedtls_gcm_context *ctx; + + ctx = (mbedtls_gcm_context *)mycalloc(1,0x188); + if (ctx != (mbedtls_gcm_context *)0x0) { + mbedtls_gcm_init(ctx); + } + return ctx; +} + + + +int gcm_aes_setkey_wrap(void *ctx,uchar *key,uint key_bitlen) + +{ + int iVar1; + + iVar1 = mbedtls_gcm_setkey((mbedtls_gcm_context *)ctx,MBEDTLS_CIPHER_ID_AES,key,key_bitlen); + return iVar1; +} + + + +void aes_ctx_free(void *ctx) + +{ + mbedtls_aes_free((mbedtls_aes_context *)ctx); + vPortFree(ctx); + return; +} + + + +void * aes_ctx_alloc(void) + +{ + mbedtls_aes_context *ctx; + + ctx = (mbedtls_aes_context *)mycalloc(1,0x118); + if (ctx != (mbedtls_aes_context *)0x0) { + mbedtls_aes_init(ctx); + } + return ctx; +} + + + +int aes_setkey_dec_wrap(mbedtls_aes_context *ctx,uchar *key,uint keybits) + +{ + uint *puVar1; + int iVar2; + uint32_t *puVar3; + uint uVar4; + uint32_t *puVar5; + int iVar6; + mbedtls_aes_context mStack296; + + mbedtls_aes_init(&mStack296); + ctx->rk = ctx->buf; + iVar2 = mbedtls_aes_setkey_enc(&mStack296,key,keybits); + if (iVar2 == 0) { + ctx->nr = mStack296.nr; + mStack296.rk = mStack296.rk + mStack296.nr * 4; + ctx->buf[0] = *mStack296.rk; + ctx->buf[1] = mStack296.rk[1]; + puVar3 = ctx->buf; + ctx->buf[2] = mStack296.rk[2]; + ctx->buf[3] = mStack296.rk[3]; + while( true ) { + puVar3 = puVar3 + 4; + puVar5 = mStack296.rk + -4; + mStack296.nr = mStack296.nr + -1; + if (mStack296.nr < 1) break; + iVar6 = 0; + do { + uVar4 = *(uint *)((int)puVar5 + iVar6); + puVar1 = (uint *)((int)puVar3 + iVar6); + iVar6 = iVar6 + 4; + *puVar1 = RT2[FSb[uVar4 >> 0x10 & 0xff]] ^ + RT0[FSb[uVar4 & 0xff]] ^ RT3[FSb[uVar4 >> 0x18]] ^ RT1[FSb[uVar4 >> 8 & 0xff]]; + mStack296.rk = puVar5; + } while (iVar6 != 0x10); + } + *puVar3 = *puVar5; + puVar3[1] = mStack296.rk[-3]; + puVar3[2] = mStack296.rk[-2]; + puVar3[3] = mStack296.rk[-1]; + } + mbedtls_aes_free(&mStack296); + return iVar2; +} + + + +int aes_setkey_enc_wrap(mbedtls_aes_context *ctx,uchar *key,uint keybits) + +{ + byte *pbVar1; + uint32_t *puVar2; + uint uVar3; + int iVar4; + uint32_t *puVar5; + uint32_t *puVar6; + uint uVar7; + + if (aes_init_done == 0) { + aes_gen_tables(); + aes_init_done = 1; + } + if (keybits == 0xc0) { + iVar4 = 0xc; + } + else { + if (keybits == 0x100) { + iVar4 = 0xe; + } + else { + if (keybits != 0x80) { + return -0x20; + } + iVar4 = 10; + } + } + ctx->nr = iVar4; + puVar5 = ctx->buf; + ctx->rk = puVar5; + pbVar1 = key; + puVar2 = puVar5; + while (key + (keybits >> 5) * 4 != pbVar1) { + *puVar2 = (uint)pbVar1[1] << 8 | (uint)pbVar1[2] << 0x10 | (uint)*pbVar1 | + (uint)pbVar1[3] << 0x18; + pbVar1 = pbVar1 + 4; + puVar2 = puVar2 + 1; + } + iVar4 = ctx->nr; + if (iVar4 == 0xc) { + puVar2 = RCON; + do { + uVar3 = puVar5[5]; + uVar7 = *puVar2; + puVar6 = puVar5 + 6; + puVar2 = puVar2 + 1; + uVar7 = (uint)FSb[uVar3 >> 8 & 0xff] ^ *puVar5 ^ uVar7 ^ (uint)FSb[uVar3 >> 0x18] << 0x10 ^ + (uint)FSb[uVar3 & 0xff] << 0x18 ^ (uint)FSb[uVar3 >> 0x10 & 0xff] << 8; + *puVar6 = uVar7; + uVar7 = uVar7 ^ puVar5[1]; + puVar5[7] = uVar7; + uVar7 = uVar7 ^ puVar5[2]; + puVar5[8] = uVar7; + uVar7 = uVar7 ^ puVar5[3]; + puVar5[9] = uVar7; + uVar7 = uVar7 ^ puVar5[4]; + puVar5[10] = uVar7; + puVar5[0xb] = uVar7 ^ uVar3; + puVar5 = puVar6; + } while (puVar6 != ctx->buf + 0x30); + } + else { + if (iVar4 == 0xe) { + puVar2 = RCON; + do { + uVar3 = puVar5[7]; + uVar7 = *puVar2; + puVar6 = puVar5 + 8; + puVar2 = puVar2 + 1; + uVar7 = (uint)FSb[uVar3 >> 8 & 0xff] ^ *puVar5 ^ uVar7 ^ (uint)FSb[uVar3 >> 0x18] << 0x10 ^ + (uint)FSb[uVar3 & 0xff] << 0x18 ^ (uint)FSb[uVar3 >> 0x10 & 0xff] << 8; + *puVar6 = uVar7; + uVar7 = uVar7 ^ puVar5[1]; + puVar5[9] = uVar7; + uVar7 = uVar7 ^ puVar5[2]; + puVar5[10] = uVar7; + uVar7 = uVar7 ^ puVar5[3]; + puVar5[0xb] = uVar7; + uVar7 = (uint)FSb[uVar7 >> 0x10 & 0xff] << 0x10 ^ + (uint)FSb[uVar7 & 0xff] ^ puVar5[4] ^ (uint)FSb[uVar7 >> 0x18] << 0x18 ^ + (uint)FSb[uVar7 >> 8 & 0xff] << 8; + puVar5[0xc] = uVar7; + uVar7 = uVar7 ^ puVar5[5]; + puVar5[0xd] = uVar7; + uVar7 = uVar7 ^ puVar5[6]; + puVar5[0xe] = uVar7; + puVar5[0xf] = uVar7 ^ uVar3; + puVar5 = puVar6; + } while (puVar6 != ctx->buf + 0x38); + } + else { + if (iVar4 != 10) { + return 0; + } + puVar2 = RCON; + do { + uVar3 = puVar5[3]; + uVar7 = *puVar2; + puVar6 = puVar5 + 4; + puVar2 = puVar2 + 1; + uVar7 = (uint)FSb[uVar3 >> 8 & 0xff] ^ *puVar5 ^ uVar7 ^ (uint)FSb[uVar3 >> 0x18] << 0x10 ^ + (uint)FSb[uVar3 & 0xff] << 0x18 ^ (uint)FSb[uVar3 >> 0x10 & 0xff] << 8; + *puVar6 = uVar7; + uVar7 = uVar7 ^ puVar5[1]; + puVar5[5] = uVar7; + uVar7 = uVar7 ^ puVar5[2]; + puVar5[6] = uVar7; + puVar5[7] = uVar7 ^ uVar3; + puVar5 = puVar6; + } while (puVar6 != ctx->buf + 0x28); + } + } + return 0; +} + + + +int aes_crypt_ctr_wrap(mbedtls_aes_context *ctx,size_t length,size_t *nc_off,uchar *nonce_counter, + uchar *stream_block,uchar *input,uchar *output) + +{ + bool bVar1; + uchar uVar2; + uint uVar3; + uchar *puVar4; + byte *pbVar5; + + uVar3 = *nc_off; + pbVar5 = output; + do { + if (pbVar5 == output + length) { + *nc_off = uVar3; + return 0; + } + if (uVar3 == 0) { + mbedtls_aes_encrypt(ctx,nonce_counter,stream_block); + puVar4 = nonce_counter + 0xf; + do { + uVar2 = *puVar4; + *puVar4 = uVar2 + '\x01'; + if ((uchar)(uVar2 + '\x01') != '\0') break; + bVar1 = nonce_counter != puVar4; + puVar4 = puVar4 + -1; + } while (bVar1); + } + *pbVar5 = stream_block[uVar3] ^ *input; + uVar3 = uVar3 + 1 & 0xf; + input = input + 1; + pbVar5 = pbVar5 + 1; + } while( true ); +} + + + +int aes_crypt_cfb128_wrap + (mbedtls_aes_context *ctx,int mode,size_t length,size_t *iv_off,uchar *iv,uchar *input + ,uchar *output) + +{ + uint uVar1; + byte *pbVar2; + byte bVar3; + + uVar1 = *iv_off; + pbVar2 = output; + if (mode == 0) { + while (pbVar2 != output + length) { + if (uVar1 == 0) { + mbedtls_aes_encrypt(ctx,iv,iv); + } + bVar3 = *input; + *pbVar2 = iv[uVar1] ^ bVar3; + iv[uVar1] = bVar3; + uVar1 = uVar1 + 1 & 0xf; + pbVar2 = pbVar2 + 1; + input = input + 1; + } + } + else { + while (pbVar2 != output + length) { + if (uVar1 == 0) { + mbedtls_aes_encrypt(ctx,iv,iv); + } + bVar3 = iv[uVar1] ^ *input; + *pbVar2 = bVar3; + iv[uVar1] = bVar3; + uVar1 = uVar1 + 1 & 0xf; + pbVar2 = pbVar2 + 1; + input = input + 1; + } + } + *iv_off = uVar1; + return 0; +} + + + +int aes_crypt_cbc_wrap(mbedtls_aes_context *ctx,int mode,size_t length,uchar *iv,uchar *input, + uchar *output) + +{ + uint uVar1; + int iVar2; + byte *pbVar3; + byte *pbVar4; + byte *pbVar5; + uchar *input_00; + undefined auStack64 [24]; + + uVar1 = length & 0xf; + if (uVar1 == 0) { + if (mode == 0) { + while( true ) { + input_00 = output + -uVar1; + if (uVar1 + length == 0) break; + memcpy(auStack64,input + -uVar1,0x10); + mbedtls_aes_decrypt(ctx,input + -uVar1,input_00); + iVar2 = 0; + do { + pbVar3 = input_00 + iVar2; + pbVar4 = iv + iVar2; + iVar2 = iVar2 + 1; + *pbVar3 = *pbVar4 ^ *pbVar3; + } while (iVar2 != 0x10); + memcpy(iv,auStack64,0x10); + uVar1 = uVar1 - 0x10; + } + } + else { + while( true ) { + input_00 = output + -uVar1; + if (length + uVar1 == 0) break; + iVar2 = 0; + do { + pbVar5 = input + -uVar1 + iVar2; + pbVar3 = iv + iVar2; + pbVar4 = input_00 + iVar2; + iVar2 = iVar2 + 1; + *pbVar4 = *pbVar5 ^ *pbVar3; + } while (iVar2 != 0x10); + mbedtls_aes_crypt_ecb(ctx,mode,input_00,input_00); + memcpy(iv,input_00,0x10); + uVar1 = uVar1 - 0x10; + } + } + iVar2 = 0; + } + else { + iVar2 = -0x22; + } + return iVar2; +} + + + +int aes_crypt_ecb_wrap(mbedtls_aes_context *ctx,int mode,uchar *input,uchar *output) + +{ + if (mode == 1) { + mbedtls_aes_encrypt(ctx,input,output); + } + else { + mbedtls_aes_decrypt(ctx,input,output); + } + return 0; +} + + + +void debug_send_line(int level,char *file,int line,char *str) + +{ + // WARNING: Could not recover jumptable at 0x23062e18. Too many branches + // WARNING: Treating indirect jump as call + (**(code **)(level + 0x10))(*(undefined4 *)(level + 0x14)); + return; +} + + + +void mbedtls_debug_print_mpi + (mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,mbedtls_mpi *X) + +{ + int iVar1; + size_t sVar2; + int iVar3; + bool bVar4; + uint uVar5; + uint uVar6; + char acStack576 [4]; + char str [512]; + + sVar2 = X->n; + do { + sVar2 = sVar2 - 1; + if (sVar2 == 0) break; + } while (X->p[sVar2] == 0); + uVar5 = 0x1f; + do { + if ((X->p[sVar2] >> (uVar5 & 0x1f) & 1) != 0) break; + uVar5 = uVar5 - 1; + } while (uVar5 != 0xffffffff); + snprintf(acStack576,0x200,"value of \'%s\' (%d bits) is:\n",text,sVar2 * 0x20 + 1 + uVar5); + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + iVar1 = 0; + bVar4 = true; + uVar5 = 0; + while (sVar2 != 0xffffffff) { + if ((!bVar4) || (X->p[sVar2] != 0)) { + uVar6 = 0x18; + do { + if ((!bVar4) || ((X->p[sVar2] >> (uVar6 & 0x1f) & 0xff) != 0)) { + if (((uVar5 & 0xf) == 0) && (uVar5 != 0)) { + snprintf(acStack576 + iVar1,0x200 - iVar1,"\n"); + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + iVar1 = 0; + } + iVar3 = snprintf(acStack576 + iVar1,0x200 - iVar1," %02x", + X->p[sVar2] >> (uVar6 & 0x1f) & 0xff); + iVar1 = iVar1 + iVar3; + uVar5 = uVar5 + 1; + bVar4 = false; + } + uVar6 = uVar6 - 8; + } while (uVar6 != 0xfffffff8); + } + sVar2 = sVar2 - 1; + } + if (bVar4) { + iVar3 = snprintf(acStack576 + iVar1,0x200 - iVar1," 00"); + iVar1 = iVar1 + iVar3; + } + snprintf(acStack576 + iVar1,0x200 - iVar1,"\n"); + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + return; +} + + + +void mbedtls_debug_print_msg + (mbedtls_ssl_context *ssl,int level,char *file,int line,char *format,...) + +{ + uint uVar1; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list argp; + char str [512]; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + if ((((ssl != (mbedtls_ssl_context *)0x0) && (ssl->conf != (mbedtls_ssl_config *)0x0)) && + (ssl->conf->f_dbg != (anon_subr_void_void_ptr_int_char_ptr_int_char_ptr_for_f_dbg *)0x0)) && + (level <= debug_threshold)) { + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + uVar1 = vsnprintf((char *)&argp,0x200,format,&uStack12); + if (uVar1 < 0x1ff) { + *(undefined *)((int)&argp + uVar1) = 10; + *(undefined *)((int)&argp + uVar1 + 1) = 0; + } + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + } + return; +} + + + +void mbedtls_debug_print_ret + (mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,int ret) + +{ + char acStack544 [4]; + char str [512]; + + if ((((ssl->conf != (mbedtls_ssl_config *)0x0) && + (ssl->conf->f_dbg != (anon_subr_void_void_ptr_int_char_ptr_int_char_ptr_for_f_dbg *)0x0)) && + (level <= debug_threshold)) && (ret != -0x6900)) { + snprintf(acStack544,0x200,"%s() returned %d (-0x%04x)\n",text,ret,-ret); + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + } + return; +} + + + +void mbedtls_debug_print_buf + (mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,uchar *buf, + size_t len) + +{ + int iVar1; + byte bVar2; + int iVar3; + uint uVar4; + byte abStack596 [4]; + char txt [17]; + char str [512]; + + if (((ssl->conf != (mbedtls_ssl_config *)0x0) && + (ssl->conf->f_dbg != (anon_subr_void_void_ptr_int_char_ptr_int_char_ptr_for_f_dbg *)0x0)) && + (level <= debug_threshold)) { + snprintf(txt + 0x10,0x200,"dumping \'%s\' (%u bytes)\n",text,len); + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + memset(abStack596,0,0x11); + iVar3 = 0; + uVar4 = 0; + while (uVar4 != len) { + if (uVar4 == 0x1000) goto LAB_23063198; + if ((uVar4 & 0xf) == 0) { + if (uVar4 != 0) { + snprintf(txt + iVar3 + 0x10,0x200 - iVar3," %s\n",abStack596); + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + memset(abStack596,0,0x11); + iVar3 = 0; + } + iVar1 = snprintf(txt + iVar3 + 0x10,0x200 - iVar3,"%04x: ",uVar4); + iVar3 = iVar3 + iVar1; + } + iVar1 = snprintf(txt + iVar3 + 0x10,0x200 - iVar3," %02x",(uint)buf[uVar4]); + iVar3 = iVar3 + iVar1; + bVar2 = buf[uVar4]; + if (0x5e < (byte)(bVar2 - 0x20)) { + bVar2 = 0x2e; + } + abStack596[uVar4 & 0xf] = bVar2; + uVar4 = uVar4 + 1; + } + if (len != 0) { + while( true ) { + if ((len & 0xf) == 0) break; + iVar1 = snprintf(txt + iVar3 + 0x10,0x200 - iVar3," "); + iVar3 = iVar3 + iVar1; + len = len + 1; + } +LAB_23063198: + snprintf(txt + iVar3 + 0x10,0x200 - iVar3," %s\n",abStack596); + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + } + } + return; +} + + + +void mbedtls_debug_print_mpi + (mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,mbedtls_mpi *X) + +{ + if ((((ssl->conf != (mbedtls_ssl_config *)0x0) && + (ssl->conf->f_dbg != (anon_subr_void_void_ptr_int_char_ptr_int_char_ptr_for_f_dbg *)0x0)) && + (X != (mbedtls_mpi *)0x0)) && (level <= debug_threshold)) { + mbedtls_debug_print_mpi(ssl,level,file,line,text,X); + return; + } + return; +} + + + +void mbedtls_debug_print_ecp + (mbedtls_ssl_context *ssl,int level,char *file,int line,char *text, + mbedtls_ecp_point *X) + +{ + char acStack544 [4]; + char str [512]; + + snprintf(acStack544,0x200,"%s(X)",text); + mbedtls_debug_print_mpi(ssl,level,file,line,acStack544,(mbedtls_mpi *)X); + snprintf(acStack544,0x200,"%s(Y)",text); + mbedtls_debug_print_mpi(ssl,level,file,line,acStack544,&X->Y); + return; +} + + + +void mbedtls_debug_print_ecp + (mbedtls_ssl_context *ssl,int level,char *file,int line,char *text, + mbedtls_ecp_point *X) + +{ + if (((ssl->conf != (mbedtls_ssl_config *)0x0) && + (ssl->conf->f_dbg != (anon_subr_void_void_ptr_int_char_ptr_int_char_ptr_for_f_dbg *)0x0)) && + (level <= debug_threshold)) { + mbedtls_debug_print_ecp(ssl,level,file,line,text,X); + return; + } + return; +} + + + +void mbedtls_debug_print_crt + (mbedtls_ssl_context *ssl,int level,char *file,int line,char *text, + mbedtls_x509_crt *crt) + +{ + int iVar1; + mbedtls_ssl_config *level_00; + char *__src; + int iVar2; + void **ppvVar3; + char *__n; + char *pcVar4; + char *pcStack2132; + char acStack2128 [4]; + char name [16]; + char str [512]; + mbedtls_pk_debug_item items [3]; + char local_440 [4]; + char buf [1024]; + + if ((((ssl->conf != (mbedtls_ssl_config *)0x0) && + (ssl->conf->f_dbg != (anon_subr_void_void_ptr_int_char_ptr_int_char_ptr_for_f_dbg *)0x0)) && + (crt != (mbedtls_x509_crt *)0x0)) && (iVar2 = 0, level <= debug_threshold)) { + pcStack2132 = text; + do { + iVar2 = iVar2 + 1; + snprintf(name + 0xc,0x200,"%s #%d:\n",pcStack2132,iVar2); + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + mbedtls_x509_crt_info(local_440,0x3ff,"",crt); + __src = local_440; + pcVar4 = local_440; + while (__n = pcVar4, *__n != '\0') { + pcVar4 = __n + 1; + if (*__n == '\n') { + __n = __n + (1 - (int)__src); + if ((char *)0x1ff < __n) { + __n = (char *)0x1ff; + } + memcpy(str + 0x1fc,__src,(size_t)__n); + level_00 = ssl->conf; + *(undefined *)((int)__n + (int)register0x00002008 + -0x640) = 0; + debug_send_line((int)level_00,(char *)level,(int)file,(char *)line); + __src = pcVar4; + } + } + memset(str + 0x1fc,0,0x24); + iVar1 = mbedtls_pk_debug(&crt->pk,(mbedtls_pk_debug_item *)(str + 0x1fc)); + if (iVar1 == 0) { + ppvVar3 = (void **)(str + 0x1fc); + do { + if (*(char *)ppvVar3 == '\0') break; + snprintf(acStack2128,0x10,"%s%s",&UNK_2308b034,ppvVar3[1]); + name[11] = '\0'; + if (*(char *)ppvVar3 == '\x01') { + mbedtls_debug_print_mpi(ssl,level,file,line,acStack2128,(mbedtls_mpi *)ppvVar3[2]); + } + else { + if (*(char *)ppvVar3 == '\x02') { + mbedtls_debug_print_ecp + (ssl,level,file,line,acStack2128,(mbedtls_ecp_point *)ppvVar3[2]); + } + else { + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + } + } + ppvVar3 = ppvVar3 + 3; + } while (ppvVar3 != &items[2].value); + } + else { + debug_send_line((int)ssl->conf,(char *)level,(int)file,(char *)line); + } + crt = crt->next; + } while (crt != (mbedtls_x509_crt *)0x0); + } + return; +} + + + +ecp_curve_type ecp_get_type(mbedtls_ecp_group *grp) + +{ + if ((grp->G).X.p != (mbedtls_mpi_uint *)0x0) { + return ((grp->G).Y.p == (mbedtls_mpi_uint *)0x0) + ECP_TYPE_SHORT_WEIERSTRASS; + } + return ECP_TYPE_NONE; +} + + + +// WARNING: Variable defined which should be unmapped: mQY + +int ecp_safe_invert_jac(mbedtls_ecp_group *grp,mbedtls_ecp_point *Q,uchar inv) + +{ + mbedtls_mpi *B; + int iVar1; + undefined auStack28 [4]; + mbedtls_mpi mQY; + + B = &Q->Y; + mbedtls_mpi_init((mbedtls_mpi *)auStack28); + iVar1 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)auStack28,&grp->P,B); + if (iVar1 == 0) { + iVar1 = mbedtls_mpi_cmp_int(B,0); + iVar1 = mbedtls_mpi_safe_cond_assign(B,(mbedtls_mpi *)auStack28,inv & iVar1 != 0); + } + mbedtls_mpi_free((mbedtls_mpi *)auStack28); + return iVar1; +} + + + +int ecp_select_comb(mbedtls_ecp_group *grp,mbedtls_ecp_point *R,mbedtls_ecp_point *T,uchar t_len, + uchar i) + +{ + bool assign; + uint uVar1; + int iVar2; + undefined3 in_register_00002035; + undefined3 in_register_00002039; + + uVar1 = 0; + while( true ) { + assign = ((uint)i & 0x7e) >> 1 == uVar1; + iVar2 = mbedtls_mpi_safe_cond_assign((mbedtls_mpi *)R,(mbedtls_mpi *)T,assign); + if ((iVar2 != 0) || (iVar2 = mbedtls_mpi_safe_cond_assign(&R->Y,&T->Y,assign), iVar2 != 0)) + break; + uVar1 = uVar1 + 1 & 0xff; + T = T + 1; + if (CONCAT31(in_register_00002035,t_len) == uVar1) { + iVar2 = ecp_safe_invert_jac(grp,R,(uchar)(CONCAT31(in_register_00002039,i) >> 7)); + return iVar2; + } + } + return iVar2; +} + + + +int ecp_modp(mbedtls_mpi *N,mbedtls_ecp_group *grp) + +{ + mbedtls_mpi *B; + int iVar1; + size_t sVar2; + int iVar3; + + if (grp->modp == (anon_subr_int_mbedtls_mpi_ptr_for_modp *)0x0) { + iVar1 = mbedtls_mpi_mod_mpi(N,N,&grp->P); + return iVar1; + } + if (((-1 < N->s) || (iVar1 = mbedtls_mpi_cmp_int(N,0), iVar1 == 0)) && + (sVar2 = mbedtls_mpi_bitlen(N), sVar2 <= grp->pbits << 1)) { + B = &grp->P; + iVar3 = (*grp->modp)(N); + iVar1 = iVar3; + while( true ) { + if (iVar1 != 0) { + return iVar1; + } + if ((-1 < N->s) || (iVar1 = mbedtls_mpi_cmp_int(N,0), iVar1 == 0)) break; + iVar1 = mbedtls_mpi_add_mpi(N,N,B); + } + do { + iVar1 = mbedtls_mpi_cmp_mpi(N,B); + if (iVar1 < 0) { + return iVar3; + } + iVar1 = mbedtls_mpi_sub_abs(N,N,B); + } while (iVar1 == 0); + return iVar1; + } + return -0x4f80; +} + + + +int ecp_double_jac(mbedtls_ecp_group *grp,mbedtls_ecp_point *R,mbedtls_ecp_point *P) + +{ + mbedtls_mpi *X; + int iVar1; + mbedtls_mpi *Y; + mbedtls_mpi *Y_00; + undefined auStack96 [4]; + mbedtls_mpi M; + mbedtls_mpi S; + mbedtls_mpi T; + mbedtls_mpi U; + + X = (mbedtls_mpi *)&M.p; + mbedtls_mpi_init((mbedtls_mpi *)auStack96); + mbedtls_mpi_init(X); + mbedtls_mpi_init((mbedtls_mpi *)&S.p); + mbedtls_mpi_init((mbedtls_mpi *)&T.p); + if ((grp->A).p == (mbedtls_mpi_uint *)0x0) { + iVar1 = mbedtls_mpi_mul_mpi(X,&P->Z,&P->Z); + if ((iVar1 == 0) && (iVar1 = ecp_modp(X,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&S.p,(mbedtls_mpi *)P,X); + Y = &grp->P; + while (iVar1 == 0) { + iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&S.p,Y); + if (iVar1 < 0) { + iVar1 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&T.p,(mbedtls_mpi *)P,X); + goto LAB_230637aa; + } + iVar1 = mbedtls_mpi_sub_abs((mbedtls_mpi *)&S.p,(mbedtls_mpi *)&S.p,Y); + } + } + } + else { + iVar1 = mbedtls_mpi_mul_mpi(X,(mbedtls_mpi *)P,(mbedtls_mpi *)P); + if ((iVar1 == 0) && (iVar1 = ecp_modp(X,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_mul_int((mbedtls_mpi *)auStack96,X,3); + Y = &grp->P; + while (iVar1 == 0) { + iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)auStack96,Y); + if (iVar1 < 0) { + iVar1 = mbedtls_mpi_cmp_int(&grp->A,0); + if (iVar1 == 0) goto LAB_230637e8; + iVar1 = mbedtls_mpi_mul_mpi(X,&P->Z,&P->Z); + if (((((iVar1 == 0) && (iVar1 = ecp_modp(X,grp), iVar1 == 0)) && + (iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&S.p,X,X), iVar1 == 0)) && + ((iVar1 = ecp_modp((mbedtls_mpi *)&S.p,grp), iVar1 == 0 && + (iVar1 = mbedtls_mpi_mul_mpi(X,(mbedtls_mpi *)&S.p,&grp->A), iVar1 == 0)))) && + (iVar1 = ecp_modp(X,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_add_mpi((mbedtls_mpi *)auStack96,(mbedtls_mpi *)auStack96,X); + goto LAB_23063a66; + } + break; + } + iVar1 = mbedtls_mpi_sub_abs((mbedtls_mpi *)auStack96,(mbedtls_mpi *)auStack96,Y); + } + } + } + goto cleanup; +LAB_23063a66: + if (iVar1 != 0) goto cleanup; + iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)auStack96,Y); + if (iVar1 < 0) goto LAB_230637e8; + iVar1 = mbedtls_mpi_sub_abs((mbedtls_mpi *)auStack96,(mbedtls_mpi *)auStack96,Y); + goto LAB_23063a66; +LAB_230637aa: + if (iVar1 != 0) goto cleanup; + if ((-1 < (int)T.p) || (iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&T.p,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_mul_mpi(X,(mbedtls_mpi *)&S.p,(mbedtls_mpi *)&T.p); + if ((iVar1 == 0) && (iVar1 = ecp_modp(X,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_mul_int((mbedtls_mpi *)auStack96,X,3); + goto LAB_230637d8; + } + goto cleanup; + } + iVar1 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&T.p,(mbedtls_mpi *)&T.p,Y); + goto LAB_230637aa; +LAB_230637d8: + if (iVar1 != 0) goto cleanup; + iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)auStack96,Y); + if (iVar1 < 0) goto LAB_230637e8; + iVar1 = mbedtls_mpi_sub_abs((mbedtls_mpi *)auStack96,(mbedtls_mpi *)auStack96,Y); + goto LAB_230637d8; +LAB_23063848: + if (iVar1 != 0) goto cleanup; + iVar1 = mbedtls_mpi_cmp_mpi(X,Y_00); + if (iVar1 < 0) { + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T.p,(mbedtls_mpi *)&S.p,(mbedtls_mpi *)&S.p); + if ((iVar1 == 0) && (iVar1 = ecp_modp((mbedtls_mpi *)&T.p,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_shift_l((mbedtls_mpi *)&T.p,1); + goto LAB_23063880; + } + goto cleanup; + } + iVar1 = mbedtls_mpi_sub_abs(X,X,Y_00); + goto LAB_23063848; +LAB_23063880: + if (iVar1 != 0) goto cleanup; + iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&T.p,Y_00); + if (iVar1 < 0) { + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&S.p,(mbedtls_mpi *)auStack96, + (mbedtls_mpi *)auStack96); + if ((iVar1 == 0) && (iVar1 = ecp_modp((mbedtls_mpi *)&S.p,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&S.p,(mbedtls_mpi *)&S.p,X); + goto LAB_230638ba; + } + goto cleanup; + } + iVar1 = mbedtls_mpi_sub_abs((mbedtls_mpi *)&T.p,(mbedtls_mpi *)&T.p,Y_00); + goto LAB_23063880; +LAB_230638ba: + if (iVar1 != 0) goto cleanup; + if ((-1 < (int)S.p) || (iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&S.p,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&S.p,(mbedtls_mpi *)&S.p,X); + goto LAB_230638d0; + } + iVar1 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&S.p,(mbedtls_mpi *)&S.p,Y_00); + goto LAB_230638ba; +LAB_230638d0: + if (iVar1 != 0) goto cleanup; + if ((-1 < (int)S.p) || (iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&S.p,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_sub_mpi(X,X,(mbedtls_mpi *)&S.p); + goto LAB_230638e6; + } + iVar1 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&S.p,(mbedtls_mpi *)&S.p,Y_00); + goto LAB_230638d0; +LAB_230638e6: + if (iVar1 != 0) goto cleanup; + if ((-1 < (int)M.p) || (iVar1 = mbedtls_mpi_cmp_int(X,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_mul_mpi(X,X,(mbedtls_mpi *)auStack96); + if ((iVar1 == 0) && (iVar1 = ecp_modp(X,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_sub_mpi(X,X,(mbedtls_mpi *)&T.p); + goto joined_r0x2306391e; + } + goto cleanup; + } + iVar1 = mbedtls_mpi_add_mpi(X,X,Y_00); + goto LAB_230638e6; +joined_r0x2306391e: + if (iVar1 != 0) goto cleanup; + if ((-1 < (int)M.p) || (iVar1 = mbedtls_mpi_cmp_int(X,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T.p,Y,&P->Z); + if ((iVar1 == 0) && (iVar1 = ecp_modp((mbedtls_mpi *)&T.p,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_shift_l((mbedtls_mpi *)&T.p,1); + goto LAB_23063950; + } + goto cleanup; + } + iVar1 = mbedtls_mpi_add_mpi(X,X,Y_00); + goto joined_r0x2306391e; +LAB_23063950: + if (iVar1 != 0) goto cleanup; + iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&T.p,Y_00); + if (iVar1 < 0) { + iVar1 = mbedtls_mpi_copy((mbedtls_mpi *)R,(mbedtls_mpi *)&S.p); + if ((iVar1 == 0) && (iVar1 = mbedtls_mpi_copy(&R->Y,(mbedtls_mpi *)&M.p), iVar1 == 0)) { + iVar1 = mbedtls_mpi_copy(&R->Z,(mbedtls_mpi *)&T.p); + } + goto cleanup; + } + iVar1 = mbedtls_mpi_sub_abs((mbedtls_mpi *)&T.p,(mbedtls_mpi *)&T.p,Y_00); + goto LAB_23063950; +LAB_230637e8: + Y = &P->Y; + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&S.p,Y,Y); + if ((iVar1 == 0) && (iVar1 = ecp_modp((mbedtls_mpi *)&S.p,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_shift_l((mbedtls_mpi *)&S.p,1); + Y_00 = &grp->P; + while (iVar1 == 0) { + iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&S.p,Y_00); + if (iVar1 < 0) { + iVar1 = mbedtls_mpi_mul_mpi(X,(mbedtls_mpi *)P,(mbedtls_mpi *)&S.p); + if ((iVar1 == 0) && (iVar1 = ecp_modp(X,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_shift_l(X,1); + goto LAB_23063848; + } + break; + } + iVar1 = mbedtls_mpi_sub_abs((mbedtls_mpi *)&S.p,(mbedtls_mpi *)&S.p,Y_00); + } + } +cleanup: + mbedtls_mpi_free((mbedtls_mpi *)auStack96); + mbedtls_mpi_free(X); + mbedtls_mpi_free((mbedtls_mpi *)&S.p); + mbedtls_mpi_free((mbedtls_mpi *)&T.p); + return iVar1; +} + + + +int ecp_normalize_jac(mbedtls_ecp_group *grp,mbedtls_ecp_point *pt) + +{ + mbedtls_mpi *X; + int iVar1; + mbedtls_mpi *X_00; + undefined auStack56 [4]; + mbedtls_mpi Zi; + mbedtls_mpi ZZi; + + X_00 = &pt->Z; + iVar1 = mbedtls_mpi_cmp_int(X_00,0); + if (iVar1 != 0) { + mbedtls_mpi_init((mbedtls_mpi *)auStack56); + mbedtls_mpi_init((mbedtls_mpi *)&Zi.p); + iVar1 = mbedtls_mpi_inv_mod((mbedtls_mpi *)auStack56,X_00,&grp->P); + if ((((iVar1 == 0) && + (iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&Zi.p,(mbedtls_mpi *)auStack56, + (mbedtls_mpi *)auStack56), iVar1 == 0)) && + (iVar1 = ecp_modp((mbedtls_mpi *)&Zi.p,grp), iVar1 == 0)) && + ((iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)pt,(mbedtls_mpi *)pt,(mbedtls_mpi *)&Zi.p), + iVar1 == 0 && (iVar1 = ecp_modp((mbedtls_mpi *)pt,grp), iVar1 == 0)))) { + X = &pt->Y; + iVar1 = mbedtls_mpi_mul_mpi(X,X,(mbedtls_mpi *)&Zi.p); + if (((iVar1 == 0) && + ((iVar1 = ecp_modp(X,grp), iVar1 == 0 && + (iVar1 = mbedtls_mpi_mul_mpi(X,X,(mbedtls_mpi *)auStack56), iVar1 == 0)))) && + (iVar1 = ecp_modp(X,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_lset(X_00,1); + } + } + mbedtls_mpi_free((mbedtls_mpi *)auStack56); + mbedtls_mpi_free((mbedtls_mpi *)&Zi.p); + } + return iVar1; +} + + + +int ecp_normalize_jac_many(mbedtls_ecp_group *grp,mbedtls_ecp_point **T,size_t t_len) + +{ + mbedtls_ecp_point **ppmVar1; + size_t sVar2; + mbedtls_mpi *A; + int iVar3; + mbedtls_mpi *X; + size_t sVar4; + mbedtls_mpi *X_00; + undefined auStack84 [4]; + mbedtls_mpi u; + mbedtls_mpi Zi; + mbedtls_mpi ZZi; + + if (t_len < 2) { + iVar3 = ecp_normalize_jac(grp,*T); + } + else { + X = (mbedtls_mpi *)mycalloc(t_len,0xc); + if (X == (mbedtls_mpi *)0x0) { + iVar3 = -0x4d80; + } + else { + mbedtls_mpi_init((mbedtls_mpi *)auStack84); + mbedtls_mpi_init((mbedtls_mpi *)&u.p); + mbedtls_mpi_init((mbedtls_mpi *)&Zi.p); + iVar3 = mbedtls_mpi_copy(X,&(*T)->Z); + if (iVar3 == 0) { + sVar2 = 1; + A = X; + do { + sVar4 = sVar2; + X_00 = A + 1; + iVar3 = mbedtls_mpi_mul_mpi(X_00,A,&T[sVar4]->Z); + if ((iVar3 != 0) || (iVar3 = ecp_modp(X_00,grp), iVar3 != 0)) goto cleanup; + sVar2 = sVar4 + 1; + A = X_00; + } while (t_len != sVar4 + 1); + iVar3 = mbedtls_mpi_inv_mod((mbedtls_mpi *)auStack84,X + (t_len - 1),&grp->P); + if (iVar3 == 0) { + T = T + t_len; + do { + if (sVar4 == 0) { + iVar3 = mbedtls_mpi_copy((mbedtls_mpi *)&u.p,(mbedtls_mpi *)auStack84); + } + else { + iVar3 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&u.p,(mbedtls_mpi *)auStack84, + X + (sVar4 - 1)); + if (((iVar3 != 0) || (iVar3 = ecp_modp((mbedtls_mpi *)&u.p,grp), iVar3 != 0)) || + (iVar3 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)auStack84,(mbedtls_mpi *)auStack84, + &T[-1]->Z), iVar3 != 0)) break; + iVar3 = ecp_modp((mbedtls_mpi *)auStack84,grp); + } + if (((((iVar3 != 0) || + (iVar3 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&Zi.p,(mbedtls_mpi *)&u.p, + (mbedtls_mpi *)&u.p), iVar3 != 0)) || + ((iVar3 = ecp_modp((mbedtls_mpi *)&Zi.p,grp), iVar3 != 0 || + ((iVar3 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)T[-1],(mbedtls_mpi *)T[-1], + (mbedtls_mpi *)&Zi.p), iVar3 != 0 || + (iVar3 = ecp_modp((mbedtls_mpi *)T[-1],grp), iVar3 != 0)))))) || + (iVar3 = mbedtls_mpi_mul_mpi(&T[-1]->Y,&T[-1]->Y,(mbedtls_mpi *)&Zi.p), iVar3 != 0)) + || ((((iVar3 = ecp_modp(&T[-1]->Y,grp), iVar3 != 0 || + (iVar3 = mbedtls_mpi_mul_mpi(&T[-1]->Y,&T[-1]->Y,(mbedtls_mpi *)&u.p), + iVar3 != 0)) || (iVar3 = ecp_modp(&T[-1]->Y,grp), iVar3 != 0)) || + ((iVar3 = mbedtls_mpi_shrink((mbedtls_mpi *)T[-1],(grp->P).n), iVar3 != 0 || + (iVar3 = mbedtls_mpi_shrink(&T[-1]->Y,(grp->P).n), iVar3 != 0)))))) break; + ppmVar1 = T + -1; + T = T + -1; + mbedtls_mpi_free(&(*ppmVar1)->Z); + if (sVar4 == 0) break; + sVar4 = sVar4 - 1; + } while( true ); + } + } +cleanup: + mbedtls_mpi_free((mbedtls_mpi *)auStack84); + mbedtls_mpi_free((mbedtls_mpi *)&u.p); + mbedtls_mpi_free((mbedtls_mpi *)&Zi.p); + A = X; + do { + X_00 = A + 1; + mbedtls_mpi_free(A); + A = X_00; + } while (X + t_len != X_00); + vPortFree(X); + } + } + return iVar3; +} + + + +void mbedtls_ecp_point_init(mbedtls_ecp_point *pt) + +{ + mbedtls_mpi_init((mbedtls_mpi *)pt); + mbedtls_mpi_init(&pt->Y); + mbedtls_mpi_init(&pt->Z); + return; +} + + + +void mbedtls_ecp_point_free(mbedtls_ecp_point *pt) + +{ + mbedtls_mpi_free((mbedtls_mpi *)pt); + mbedtls_mpi_free(&pt->Y); + mbedtls_mpi_free(&pt->Z); + return; +} + + + +mbedtls_ecp_group_id * mbedtls_ecp_grp_id_list(void) + +{ + int init_done; + int iVar1; + mbedtls_ecp_curve_info *pmVar2; + + if (init_done == 0) { + iVar1 = 0; + pmVar2 = ecp_supported_curves; + while (pmVar2->grp_id != MBEDTLS_ECP_DP_NONE) { + ecp_supported_grp_id[iVar1] = pmVar2->grp_id; + pmVar2 = pmVar2 + 1; + iVar1 = iVar1 + 1; + } + ecp_supported_grp_id[iVar1] = MBEDTLS_ECP_DP_NONE; + } + return ecp_supported_grp_id; +} + + + +void mbedtls_ecp_point_init(mbedtls_ecp_point *pt) + +{ + if (pt != (mbedtls_ecp_point *)0x0) { + mbedtls_ecp_point_init(pt); + return; + } + return; +} + + + +void mbedtls_ecp_group_init(mbedtls_ecp_group *grp) + +{ + if (grp != (mbedtls_ecp_group *)0x0) { + memset(grp,0,0x7c); + return; + } + return; +} + + + +void mbedtls_ecp_keypair_init(mbedtls_ecp_keypair *key) + +{ + if (key != (mbedtls_ecp_keypair *)0x0) { + mbedtls_ecp_group_init((mbedtls_ecp_group *)key); + mbedtls_mpi_init(&key->d); + mbedtls_ecp_point_init(&key->Q); + return; + } + return; +} + + + +void mbedtls_ecp_point_free(mbedtls_ecp_point *pt) + +{ + if (pt != (mbedtls_ecp_point *)0x0) { + mbedtls_ecp_point_free(pt); + return; + } + return; +} + + + +void mbedtls_ecp_group_free(mbedtls_ecp_group *grp) + +{ + uint uVar1; + mbedtls_ecp_group *pmVar2; + + if (grp != (mbedtls_ecp_group *)0x0) { + if (grp->h != 1) { + mbedtls_mpi_free(&grp->P); + mbedtls_mpi_free(&grp->A); + mbedtls_mpi_free(&grp->B); + mbedtls_ecp_point_free(&grp->G); + mbedtls_mpi_free(&grp->N); + } + uVar1 = 0; + if (grp->T != (mbedtls_ecp_point *)0x0) { + while (uVar1 < grp->T_size) { + mbedtls_ecp_point_free(grp->T + uVar1); + uVar1 = uVar1 + 1; + } + vPortFree(grp->T); + } + pmVar2 = grp + 1; + while (grp != pmVar2) { + grp->id = MBEDTLS_ECP_DP_NONE; + grp = (mbedtls_ecp_group *)&grp->field_0x1; + } + return; + } + return; +} + + + +void mbedtls_ecp_keypair_free(mbedtls_ecp_keypair *key) + +{ + if (key != (mbedtls_ecp_keypair *)0x0) { + mbedtls_ecp_group_free((mbedtls_ecp_group *)key); + mbedtls_mpi_free(&key->d); + mbedtls_ecp_point_free(&key->Q); + return; + } + return; +} + + + +int mbedtls_ecp_copy(mbedtls_ecp_point *P,mbedtls_ecp_point *Q) + +{ + int iVar1; + + iVar1 = mbedtls_mpi_copy((mbedtls_mpi *)P,(mbedtls_mpi *)Q); + if ((iVar1 == 0) && (iVar1 = mbedtls_mpi_copy(&P->Y,&Q->Y), iVar1 == 0)) { + iVar1 = mbedtls_mpi_copy(&P->Z,&Q->Z); + return iVar1; + } + return iVar1; +} + + + +int mbedtls_ecp_group_copy(mbedtls_ecp_group *dst,mbedtls_ecp_group *src) + +{ + int iVar1; + + iVar1 = mbedtls_ecp_group_load(dst,src->id); + return iVar1; +} + + + +int mbedtls_ecp_set_zero(mbedtls_ecp_point *pt) + +{ + int iVar1; + + iVar1 = mbedtls_mpi_lset((mbedtls_mpi *)pt,1); + if ((iVar1 == 0) && (iVar1 = mbedtls_mpi_lset(&pt->Y,1), iVar1 == 0)) { + iVar1 = mbedtls_mpi_lset(&pt->Z,0); + return iVar1; + } + return iVar1; +} + + + +int ecp_add_mixed(mbedtls_ecp_group *grp,mbedtls_ecp_point *R,mbedtls_ecp_point *P, + mbedtls_ecp_point *Q) + +{ + int iVar1; + mbedtls_ecp_point *Q_00; + mbedtls_mpi *X_00; + mbedtls_mpi *X_01; + int iStack132; + mbedtls_mpi T1; + mbedtls_mpi T2; + mbedtls_mpi T3; + mbedtls_mpi T4; + mbedtls_mpi X; + mbedtls_mpi Y; + mbedtls_mpi Z; + + X_01 = &P->Z; + iVar1 = mbedtls_mpi_cmp_int(X_01,0); + Q_00 = Q; + if (iVar1 == 0) { +LAB_2306410a: + iVar1 = mbedtls_ecp_copy(R,Q_00); + } + else { + if ((Q->Z).p != (mbedtls_mpi_uint *)0x0) { + iVar1 = mbedtls_mpi_cmp_int(&Q->Z,0); + Q_00 = P; + if (iVar1 == 0) goto LAB_2306410a; + if (((Q->Z).p != (mbedtls_mpi_uint *)0x0) && + (iVar1 = mbedtls_mpi_cmp_int(&Q->Z,1), iVar1 != 0)) { + return -0x4f80; + } + } + mbedtls_mpi_init((mbedtls_mpi *)&iStack132); + mbedtls_mpi_init((mbedtls_mpi *)&T1.p); + mbedtls_mpi_init((mbedtls_mpi *)&T2.p); + mbedtls_mpi_init((mbedtls_mpi *)&T3.p); + X_00 = (mbedtls_mpi *)&T4.p; + mbedtls_mpi_init(X_00); + mbedtls_mpi_init((mbedtls_mpi *)&X.p); + mbedtls_mpi_init((mbedtls_mpi *)&Y.p); + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&iStack132,X_01,X_01); + if ((((iVar1 == 0) && (iVar1 = ecp_modp((mbedtls_mpi *)&iStack132,grp), iVar1 == 0)) && + (iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T1.p,(mbedtls_mpi *)&iStack132,X_01), + iVar1 == 0)) && + (((iVar1 = ecp_modp((mbedtls_mpi *)&T1.p,grp), iVar1 == 0 && + (iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&iStack132,(mbedtls_mpi *)&iStack132, + (mbedtls_mpi *)Q), iVar1 == 0)) && + ((iVar1 = ecp_modp((mbedtls_mpi *)&iStack132,grp), iVar1 == 0 && + ((iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T1.p,(mbedtls_mpi *)&T1.p,&Q->Y), iVar1 == 0 + && (iVar1 = ecp_modp((mbedtls_mpi *)&T1.p,grp), iVar1 == 0)))))))) { + iVar1 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&iStack132,(mbedtls_mpi *)&iStack132, + (mbedtls_mpi *)P); + while (iVar1 == 0) { + if ((-1 < iStack132) || + (iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&iStack132,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&T1.p,(mbedtls_mpi *)&T1.p,&P->Y); + goto joined_r0x23064178; + } + iVar1 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&iStack132,(mbedtls_mpi *)&iStack132,&grp->P); + } + } +cleanup: + mbedtls_mpi_free((mbedtls_mpi *)&iStack132); + mbedtls_mpi_free((mbedtls_mpi *)&T1.p); + mbedtls_mpi_free((mbedtls_mpi *)&T2.p); + mbedtls_mpi_free((mbedtls_mpi *)&T3.p); + mbedtls_mpi_free(X_00); + mbedtls_mpi_free((mbedtls_mpi *)&X.p); + mbedtls_mpi_free((mbedtls_mpi *)&Y.p); + } + return iVar1; +joined_r0x23064178: + if (iVar1 != 0) goto cleanup; + if ((-1 < (int)T1.p) || (iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&T1.p,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&iStack132,0); + if (iVar1 == 0) { + iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&T1.p,0); + if (iVar1 == 0) { + iVar1 = ecp_double_jac(grp,R,P); + } + else { + iVar1 = mbedtls_ecp_set_zero(R); + } + } + else { + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&Y.p,X_01,(mbedtls_mpi *)&iStack132); + if (((((iVar1 == 0) && (iVar1 = ecp_modp((mbedtls_mpi *)&Y.p,grp), iVar1 == 0)) && + (iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T2.p,(mbedtls_mpi *)&iStack132, + (mbedtls_mpi *)&iStack132), iVar1 == 0)) && + ((iVar1 = ecp_modp((mbedtls_mpi *)&T2.p,grp), iVar1 == 0 && + (iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T3.p,(mbedtls_mpi *)&T2.p, + (mbedtls_mpi *)&iStack132), iVar1 == 0)))) && + ((iVar1 = ecp_modp((mbedtls_mpi *)&T3.p,grp), iVar1 == 0 && + ((iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T2.p,(mbedtls_mpi *)&T2.p,(mbedtls_mpi *)P), + iVar1 == 0 && (iVar1 = ecp_modp((mbedtls_mpi *)&T2.p,grp), iVar1 == 0)))))) { + iVar1 = mbedtls_mpi_mul_int((mbedtls_mpi *)&iStack132,(mbedtls_mpi *)&T2.p,2); + X_01 = &grp->P; + goto joined_r0x23064214; + } + } + goto cleanup; + } + iVar1 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&T1.p,(mbedtls_mpi *)&T1.p,&grp->P); + goto joined_r0x23064178; +joined_r0x23064214: + if (iVar1 != 0) goto cleanup; + iVar1 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&iStack132,X_01); + if (iVar1 < 0) { + iVar1 = mbedtls_mpi_mul_mpi(X_00,(mbedtls_mpi *)&T1.p,(mbedtls_mpi *)&T1.p); + if ((iVar1 == 0) && (iVar1 = ecp_modp(X_00,grp), iVar1 == 0)) { + iVar1 = mbedtls_mpi_sub_mpi(X_00,X_00,(mbedtls_mpi *)&iStack132); + goto joined_r0x23064250; + } + goto cleanup; + } + iVar1 = mbedtls_mpi_sub_abs((mbedtls_mpi *)&iStack132,(mbedtls_mpi *)&iStack132,X_01); + goto joined_r0x23064214; +joined_r0x23064250: + if (iVar1 != 0) goto cleanup; + if ((-1 < (int)T4.p) || (iVar1 = mbedtls_mpi_cmp_int(X_00,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_sub_mpi(X_00,X_00,(mbedtls_mpi *)&T3.p); + goto LAB_23064264; + } + iVar1 = mbedtls_mpi_add_mpi(X_00,X_00,X_01); + goto joined_r0x23064250; +LAB_23064264: + if (iVar1 != 0) goto cleanup; + if ((-1 < (int)T4.p) || (iVar1 = mbedtls_mpi_cmp_int(X_00,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&T2.p,(mbedtls_mpi *)&T2.p,X_00); + goto LAB_2306427a; + } + iVar1 = mbedtls_mpi_add_mpi(X_00,X_00,X_01); + goto LAB_23064264; +LAB_2306427a: + if (iVar1 != 0) goto cleanup; + if ((-1 < (int)T2.p) || (iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&T2.p,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T2.p,(mbedtls_mpi *)&T2.p,(mbedtls_mpi *)&T1.p); + if ((iVar1 == 0) && + (((iVar1 = ecp_modp((mbedtls_mpi *)&T2.p,grp), iVar1 == 0 && + (iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&T3.p,(mbedtls_mpi *)&T3.p,&P->Y), iVar1 == 0)) + && (iVar1 = ecp_modp((mbedtls_mpi *)&T3.p,grp), iVar1 == 0)))) { + iVar1 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&X.p,(mbedtls_mpi *)&T2.p,(mbedtls_mpi *)&T3.p); + goto LAB_230642cc; + } + goto cleanup; + } + iVar1 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&T2.p,(mbedtls_mpi *)&T2.p,X_01); + goto LAB_2306427a; +LAB_230642cc: + if (iVar1 != 0) goto cleanup; + if ((-1 < (int)X.p) || (iVar1 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&X.p,0), iVar1 == 0)) { + iVar1 = mbedtls_mpi_copy((mbedtls_mpi *)R,X_00); + if ((iVar1 == 0) && (iVar1 = mbedtls_mpi_copy(&R->Y,(mbedtls_mpi *)&X.p), iVar1 == 0)) { + iVar1 = mbedtls_mpi_copy(&R->Z,(mbedtls_mpi *)&Y.p); + } + goto cleanup; + } + iVar1 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&X.p,(mbedtls_mpi *)&X.p,X_01); + goto LAB_230642cc; +} + + + +int ecp_mul_comb(mbedtls_ecp_group *grp,mbedtls_ecp_point *R,mbedtls_mpi *m,mbedtls_ecp_point *P, + anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng) + +{ + byte bVar1; + byte bVar2; + byte bVar3; + uint uVar4; + mbedtls_mpi_uint **ppmVar5; + int iVar6; + int iVar7; + int iVar8; + int iVar9; + uint uVar10; + uchar t_len; + uint uVar11; + uint uVar12; + mbedtls_ecp_point *P_00; + mbedtls_ecp_point *P_01; + uint uVar13; + uint uVar14; + size_t pos; + mbedtls_mpi *X; + uint numitems; + uint uVar15; + mbedtls_mpi_uint **ppmVar16; + int iVar17; + size_t t_len_00; + undefined auStack412 [4]; + mbedtls_mpi M; + mbedtls_mpi mm; + mbedtls_mpi l; + mbedtls_mpi ll; + mbedtls_ecp_point Txi; + uchar k [262]; + + mbedtls_mpi_init((mbedtls_mpi *)auStack412); + mbedtls_mpi_init((mbedtls_mpi *)&M.p); + iVar6 = mbedtls_mpi_get_bit(&grp->N,0); + if (iVar6 != 1) { + return -0x4f80; + } + uVar13 = (uint)(0x17f < grp->nbits); + iVar6 = mbedtls_mpi_cmp_mpi(&P->Y,&(grp->G).Y); + uVar14 = uVar13 + 4; + if (iVar6 == 0) { + iVar7 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)P,(mbedtls_mpi *)&grp->G); + if (iVar7 == 0) { + uVar14 = uVar13 + 5; + iVar6 = 1; + } + } + else { + iVar6 = 0; + } + if (grp->nbits <= uVar14) { + uVar14 = 2; + } + uVar15 = uVar14 - 1; + numitems = 1 << (uVar15 & 0x1f); + uVar13 = ((grp->nbits - 1) + uVar14) / uVar14; + if ((iVar6 == 0) || (P_01 = grp->T, P_01 == (mbedtls_ecp_point *)0x0)) { + P_01 = (mbedtls_ecp_point *)mycalloc(numitems,0x24); + if (P_01 == (mbedtls_ecp_point *)0x0) { + iVar7 = -0x4d80; + goto LAB_2306451a; + } + iVar7 = mbedtls_ecp_copy(P_01,P); + if (iVar7 == 0) { + t_len_00 = 0; + uVar11 = 1; + while (uVar12 = uVar11 >> (uVar15 & 0x1f), uVar12 == 0) { + P_00 = P_01 + uVar11; + iVar7 = mbedtls_ecp_copy(P_00,P_01 + (uVar11 >> 1)); + if (iVar7 != 0) goto LAB_230644f6; + while (uVar13 != uVar12) { + iVar7 = ecp_double_jac(grp,P_00,P_00); + if (iVar7 != 0) goto LAB_230644f6; + uVar12 = uVar12 + 1; + } + *(mbedtls_ecp_point **)(&Txi.Z.p + t_len_00) = P_00; + uVar11 = (uVar11 & 0x7f) << 1; + t_len_00 = t_len_00 + 1 & 0xff; + } + iVar7 = ecp_normalize_jac_many(grp,(mbedtls_ecp_point **)&Txi.Z.p,t_len_00); + if (iVar7 == 0) { + t_len_00 = 0; + uVar11 = 1; + while (uVar11 >> (uVar15 & 0x1f) == 0) { + uVar10 = t_len_00 + uVar11; + P_00 = P_01 + uVar11; + uVar12 = uVar11; + while( true ) { + t_len_00 = (uVar10 & 0xff) - uVar12 & 0xff; + uVar4 = uVar12 - 1; + if (uVar12 == 0) break; + iVar7 = ecp_add_mixed(grp,P_00 + uVar4,P_01 + uVar4,P_00); + if (iVar7 != 0) goto LAB_230644f6; + *(mbedtls_ecp_point **)(&Txi.Z.p + t_len_00) = P_00 + uVar4; + uVar12 = uVar4; + } + uVar11 = (uVar11 & 0x7f) << 1; + } + iVar7 = ecp_normalize_jac_many(grp,(mbedtls_ecp_point **)&Txi.Z.p,t_len_00); + if (iVar7 == 0) { + if (iVar6 != 0) { + grp->T = P_01; + grp->T_size = numitems; + } + goto LAB_23064618; + } + } + } + } + else { +LAB_23064618: + iVar8 = mbedtls_mpi_get_bit(m,0); + iVar7 = mbedtls_mpi_copy((mbedtls_mpi *)auStack412,m); + if ((iVar7 == 0) && (iVar7 = mbedtls_mpi_sub_mpi((mbedtls_mpi *)&M.p,&grp->N,m), iVar7 == 0)) { + iVar7 = mbedtls_mpi_safe_cond_assign((mbedtls_mpi *)auStack412,(mbedtls_mpi *)&M.p,iVar8 != 1) + ; + if (iVar7 == 0) { + ppmVar5 = &Txi.Z.p; + memset(&Txi.Z.p,0,uVar13 + 1); + t_len_00 = 0; + ppmVar16 = ppmVar5; + while (uVar13 != t_len_00) { + uVar15 = 0; + pos = t_len_00; + do { + iVar7 = mbedtls_mpi_get_bit((mbedtls_mpi *)auStack412,pos); + *(byte *)ppmVar16 = (byte)(iVar7 << (uVar15 & 0x1f)) | *(byte *)ppmVar16; + uVar15 = uVar15 + 1; + pos = pos + uVar13; + } while (uVar15 < uVar14); + t_len_00 = t_len_00 + 1; + ppmVar16 = (mbedtls_mpi_uint **)((int)ppmVar16 + 1); + } + uVar13 = 0; + while (ppmVar5 != (mbedtls_mpi_uint **)((int)&Txi.Z.p + t_len_00)) { + bVar1 = *(byte *)((int)ppmVar5 + 1); + uVar14 = bVar1 ^ uVar13; + uVar15 = ~uVar14 & 1; + bVar3 = *(byte *)ppmVar5 * (char)uVar15; + *(byte *)ppmVar5 = (byte)(uVar15 << 7) | *(byte *)ppmVar5; + bVar2 = (byte)uVar14; + *(byte *)(mbedtls_mpi_uint **)((int)ppmVar5 + 1) = bVar2 ^ bVar3; + uVar13 = bVar1 & uVar13 | (int)(char)(bVar2 & bVar3) & 0xffU; + ppmVar5 = (mbedtls_mpi_uint **)((int)ppmVar5 + 1); + } + mbedtls_ecp_point_init((mbedtls_ecp_point *)&ll.p); + t_len = (uchar)(numitems & 0xff); + iVar7 = ecp_select_comb(grp,R,P_01,t_len,*(uchar *)((int)&Txi.Z.p + t_len_00)); + if (iVar7 == 0) { + X = &R->Z; + iVar9 = mbedtls_mpi_lset(X,1); + iVar7 = iVar9; + if (iVar9 == 0) { + if (f_rng != (anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0) { + pos = grp->pbits; + mbedtls_mpi_init((mbedtls_mpi *)&mm.p); + mbedtls_mpi_init((mbedtls_mpi *)&l.p); + iVar17 = 0xc; + do { + mbedtls_mpi_fill_random((mbedtls_mpi *)&mm.p,pos + 7 >> 3,f_rng,p_rng); + while (iVar7 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&mm.p,&grp->P), -1 < iVar7) { + iVar7 = mbedtls_mpi_shift_r((mbedtls_mpi *)&mm.p,1); + if (iVar7 != 0) goto cleanup; + } + iVar17 = iVar17 + -1; + if (iVar17 == 0) { + iVar7 = -0x4d00; + goto cleanup; + } + iVar7 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&mm.p,1); + } while (iVar7 < 1); + iVar7 = mbedtls_mpi_mul_mpi(X,X,(mbedtls_mpi *)&mm.p); + if ((((iVar7 == 0) && (iVar7 = ecp_modp(X,grp), iVar7 == 0)) && + (iVar7 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&l.p,(mbedtls_mpi *)&mm.p, + (mbedtls_mpi *)&mm.p), iVar7 == 0)) && + (((iVar7 = ecp_modp((mbedtls_mpi *)&l.p,grp), iVar7 == 0 && + (iVar7 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)R,(mbedtls_mpi *)R, + (mbedtls_mpi *)&l.p), iVar7 == 0)) && + ((iVar7 = ecp_modp((mbedtls_mpi *)R,grp), iVar7 == 0 && + ((iVar7 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&l.p,(mbedtls_mpi *)&l.p, + (mbedtls_mpi *)&mm.p), iVar7 == 0 && + (iVar7 = ecp_modp((mbedtls_mpi *)&l.p,grp), iVar7 == 0)))))))) { + X = &R->Y; + iVar7 = mbedtls_mpi_mul_mpi(X,X,(mbedtls_mpi *)&l.p); + if (iVar7 == 0) { + iVar7 = ecp_modp(X,grp); + } + } +cleanup: + mbedtls_mpi_free((mbedtls_mpi *)&mm.p); + mbedtls_mpi_free((mbedtls_mpi *)&l.p); + if (iVar7 != 0) goto cleanup; + } + do { + iVar7 = iVar9; + if (((t_len_00 - 1 == 0xffffffff) || (iVar7 = ecp_double_jac(grp,R,R), iVar7 != 0)) || + (iVar7 = ecp_select_comb(grp,(mbedtls_ecp_point *)&ll.p,P_01,t_len, + *(uchar *)((int)&Txi.Z.n + t_len_00 + 3)), iVar7 != 0)) + break; + iVar7 = ecp_add_mixed(grp,R,R,(mbedtls_ecp_point *)&ll.p); + t_len_00 = t_len_00 - 1; + } while (iVar7 == 0); + } + } +cleanup: + mbedtls_ecp_point_free((mbedtls_ecp_point *)&ll.p); + if ((iVar7 == 0) && (iVar7 = ecp_safe_invert_jac(grp,R,iVar8 != 1), iVar7 == 0)) { + iVar7 = ecp_normalize_jac(grp,R); + } + } + } + } +LAB_230644f6: + if (iVar6 == 0) { + uVar13 = 0; + do { + uVar14 = uVar13 + 1; + mbedtls_ecp_point_free(P_01 + uVar13); + uVar13 = uVar14; + } while ((uVar14 & 0xff) < (numitems & 0xff)); + vPortFree(P_01); + } +LAB_2306451a: + mbedtls_mpi_free((mbedtls_mpi *)auStack412); + mbedtls_mpi_free((mbedtls_mpi *)&M.p); + if (iVar7 != 0) { + mbedtls_ecp_point_free(R); + } + return iVar7; +} + + + +int mbedtls_ecp_point_read_binary + (mbedtls_ecp_group *grp,mbedtls_ecp_point *pt,uchar *buf,size_t ilen) + +{ + int iVar1; + size_t buflen; + + if (ilen != 0) { + if (*buf != '\0') { + buflen = mbedtls_mpi_size(&grp->P); + if (*buf == '\x04') { + if (ilen == buflen * 2 + 1) { + iVar1 = mbedtls_mpi_read_binary((mbedtls_mpi *)pt,buf + 1,buflen); + if ((iVar1 == 0) && + (iVar1 = mbedtls_mpi_read_binary(&pt->Y,buf + buflen + 1,buflen), iVar1 == 0)) { + iVar1 = mbedtls_mpi_lset(&pt->Z,1); + return iVar1; + } + } + else { + iVar1 = -0x4f80; + } + } + else { + iVar1 = -0x4e80; + } + return iVar1; + } + if (ilen == 1) { + iVar1 = mbedtls_ecp_set_zero(pt); + return iVar1; + } + } + return -0x4f80; +} + + + +int mbedtls_ecp_check_pubkey(mbedtls_ecp_group *grp,mbedtls_ecp_point *pt) + +{ + mbedtls_mpi *X; + ecp_curve_type eVar1; + int iVar2; + undefined3 extraout_var; + mbedtls_mpi *Y; + undefined auStack56 [4]; + mbedtls_mpi YY; + mbedtls_mpi RHS; + + iVar2 = mbedtls_mpi_cmp_int(&pt->Z,1); + if (iVar2 == 0) { + eVar1 = ecp_get_type(grp); + if (CONCAT31(extraout_var,eVar1) != 1) { + return -0x4f80; + } + iVar2 = mbedtls_mpi_cmp_int((mbedtls_mpi *)pt,0); + if (-1 < iVar2) { + X = &pt->Y; + iVar2 = mbedtls_mpi_cmp_int(X,0); + if (-1 < iVar2) { + Y = &grp->P; + iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)pt,Y); + if ((iVar2 < 0) && (iVar2 = mbedtls_mpi_cmp_mpi(X,Y), iVar2 < 0)) { + mbedtls_mpi_init((mbedtls_mpi *)auStack56); + mbedtls_mpi_init((mbedtls_mpi *)&YY.p); + iVar2 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)auStack56,X,X); + if ((iVar2 == 0) && + (((iVar2 = ecp_modp((mbedtls_mpi *)auStack56,grp), iVar2 == 0 && + (iVar2 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&YY.p,(mbedtls_mpi *)pt,(mbedtls_mpi *)pt + ), iVar2 == 0)) && + (iVar2 = ecp_modp((mbedtls_mpi *)&YY.p,grp), iVar2 == 0)))) { + if ((grp->A).p == (mbedtls_mpi_uint *)0x0) { + iVar2 = mbedtls_mpi_sub_int((mbedtls_mpi *)&YY.p,(mbedtls_mpi *)&YY.p,3); + while (iVar2 == 0) { + if ((-1 < (int)YY.p) || + (iVar2 = mbedtls_mpi_cmp_int((mbedtls_mpi *)&YY.p,0), iVar2 == 0)) + goto LAB_230649e4; + iVar2 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&YY.p,(mbedtls_mpi *)&YY.p,Y); + } + } + else { + iVar2 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&YY.p,(mbedtls_mpi *)&YY.p,&grp->A); + while (iVar2 == 0) { + iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&YY.p,Y); + if (iVar2 < 0) goto LAB_230649e4; + iVar2 = mbedtls_mpi_sub_abs((mbedtls_mpi *)&YY.p,(mbedtls_mpi *)&YY.p,Y); + } + } + } + goto cleanup; + } + } + } + } + return -0x4c80; +LAB_230649e4: + iVar2 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&YY.p,(mbedtls_mpi *)&YY.p,(mbedtls_mpi *)pt); + if ((iVar2 == 0) && (iVar2 = ecp_modp((mbedtls_mpi *)&YY.p,grp), iVar2 == 0)) { + iVar2 = mbedtls_mpi_add_mpi((mbedtls_mpi *)&YY.p,(mbedtls_mpi *)&YY.p,&grp->B); + while (iVar2 == 0) { + iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&YY.p,Y); + if (iVar2 < 0) { + iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)auStack56,(mbedtls_mpi *)&YY.p); + if (iVar2 != 0) { + iVar2 = -0x4c80; + } + break; + } + iVar2 = mbedtls_mpi_sub_abs((mbedtls_mpi *)&YY.p,(mbedtls_mpi *)&YY.p,Y); + } + } +cleanup: + mbedtls_mpi_free((mbedtls_mpi *)auStack56); + mbedtls_mpi_free((mbedtls_mpi *)&YY.p); + return iVar2; +} + + + +int mbedtls_ecp_check_privkey(mbedtls_ecp_group *grp,mbedtls_mpi *d) + +{ + ecp_curve_type eVar1; + undefined3 extraout_var; + int iVar2; + + eVar1 = ecp_get_type(grp); + if (CONCAT31(extraout_var,eVar1) == 1) { + iVar2 = mbedtls_mpi_cmp_int(d,1); + if ((-1 < iVar2) && (iVar2 = mbedtls_mpi_cmp_mpi(d,&grp->N), iVar2 < 0)) { + return 0; + } + iVar2 = -0x4c80; + } + else { + iVar2 = -0x4f80; + } + return iVar2; +} + + + +int mbedtls_ecp_mul(mbedtls_ecp_group *grp,mbedtls_ecp_point *R,mbedtls_mpi *m,mbedtls_ecp_point *P, + anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng) + +{ + ecp_curve_type eVar1; + int iVar2; + undefined3 extraout_var; + + iVar2 = mbedtls_mpi_cmp_int(&P->Z,1); + if (iVar2 == 0) { + iVar2 = mbedtls_ecp_check_privkey(grp,m); + if (((iVar2 == 0) && (iVar2 = mbedtls_ecp_check_pubkey(grp,P), iVar2 == 0)) && + (eVar1 = ecp_get_type(grp), CONCAT31(extraout_var,eVar1) == 1)) { + iVar2 = ecp_mul_comb(grp,R,m,P,f_rng,p_rng); + return iVar2; + } + } + else { + iVar2 = -0x4f80; + } + return iVar2; +} + + + +int mbedtls_ecp_check_pub_priv(mbedtls_ecp_keypair *pub,mbedtls_ecp_keypair *prv) + +{ + mbedtls_ecp_group_id mVar1; + int iVar2; + mbedtls_mpi *Y; + mbedtls_mpi *Y_00; + undefined auStack192 [4]; + mbedtls_ecp_point Q; + mbedtls_ecp_group grp; + + mVar1 = (pub->grp).id; + if ((mVar1 != MBEDTLS_ECP_DP_NONE) && ((prv->grp).id == mVar1)) { + iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&pub->Q,(mbedtls_mpi *)&prv->Q); + if (iVar2 == 0) { + Y_00 = &(prv->Q).Y; + iVar2 = mbedtls_mpi_cmp_mpi(&(pub->Q).Y,Y_00); + if (iVar2 == 0) { + Y = &(prv->Q).Z; + iVar2 = mbedtls_mpi_cmp_mpi(&(pub->Q).Z,Y); + if (iVar2 == 0) { + mbedtls_ecp_point_init((mbedtls_ecp_point *)auStack192); + memset(&Q.Z.p,0,0x7c); + mbedtls_ecp_group_copy((mbedtls_ecp_group *)&Q.Z.p,(mbedtls_ecp_group *)prv); + iVar2 = mbedtls_ecp_mul((mbedtls_ecp_group *)&Q.Z.p,(mbedtls_ecp_point *)auStack192, + &prv->d,&(prv->grp).G, + (anon_subr_int_void_ptr_uchar_ptr_size_t *)0x0,(void *)0x0); + if ((iVar2 == 0) && + (((iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)auStack192,(mbedtls_mpi *)&prv->Q), + iVar2 != 0 || (iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&Q.X.p,Y_00), iVar2 != 0)) + || (iVar2 = mbedtls_mpi_cmp_mpi((mbedtls_mpi *)&Q.Y.p,Y), iVar2 != 0)))) { + iVar2 = -0x4f80; + } + mbedtls_ecp_point_free((mbedtls_ecp_point *)auStack192); + mbedtls_ecp_group_free((mbedtls_ecp_group *)&Q.Z.p); + return iVar2; + } + } + } + } + return -0x4f80; +} + + + +int ecp_mod_koblitz(mbedtls_mpi *N,mbedtls_mpi_uint *Rp,size_t p_limbs) + +{ + int iVar1; + uint uVar2; + size_t sVar3; + mbedtls_mpi_uint **__s; + int iStack100; + mbedtls_mpi M; + mbedtls_mpi R; + mbedtls_mpi_uint Mp [11]; + + if (N->n < p_limbs) { + return 0; + } + __s = &R.p; + M.p = (mbedtls_mpi_uint *)0x1; + R.s = 2; + iStack100 = 1; + uVar2 = N->n - p_limbs; + M.s = p_limbs; + if (uVar2 <= p_limbs) { + M.s = uVar2; + } + M.n = (size_t)__s; + R.n = (size_t)Rp; + memset(__s,0,0x2c); + memcpy(__s,N->p + p_limbs,M.s << 2); + M.s = M.s + R.s; + sVar3 = p_limbs; + while (sVar3 < N->n) { + N->p[sVar3] = 0; + sVar3 = sVar3 + 1; + } + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&iStack100,(mbedtls_mpi *)&iStack100, + (mbedtls_mpi *)&M.p); + if ((iVar1 == 0) && (iVar1 = mbedtls_mpi_add_abs(N,N,(mbedtls_mpi *)&iStack100), iVar1 == 0)) { + uVar2 = N->n - p_limbs; + M.s = p_limbs; + if (uVar2 <= p_limbs) { + M.s = uVar2; + } + memset(__s,0,0x2c); + memcpy(__s,N->p + p_limbs,M.s << 2); + M.s = M.s + R.s; + while (p_limbs < N->n) { + N->p[p_limbs] = 0; + p_limbs = p_limbs + 1; + } + iVar1 = mbedtls_mpi_mul_mpi((mbedtls_mpi *)&iStack100,(mbedtls_mpi *)&iStack100, + (mbedtls_mpi *)&M.p); + if (iVar1 == 0) { + iVar1 = mbedtls_mpi_add_abs(N,N,(mbedtls_mpi *)&iStack100); + } + } + return iVar1; +} + + + +int ecp_mod_p224k1(mbedtls_mpi *N) + +{ + mbedtls_mpi_uint Rp [2]; + int iVar1; + + iVar1 = ecp_mod_koblitz(N,(mbedtls_mpi_uint *)&ram0x4200d980,7); + return iVar1; +} + + + +int ecp_mod_p256k1(mbedtls_mpi *N) + +{ + mbedtls_mpi_uint Rp [2]; + int iVar1; + + iVar1 = ecp_mod_koblitz(N,(mbedtls_mpi_uint *)&ram0x4200d988,8); + return iVar1; +} + + + +int mbedtls_ecp_group_load(mbedtls_ecp_group *grp,mbedtls_ecp_group_id id) + +{ + size_t sVar1; + undefined3 in_register_0000202d; + int iVar2; + mbedtls_mpi_uint *pmVar3; + + iVar2 = CONCAT31(in_register_0000202d,id); + mbedtls_ecp_group_free(grp); + grp->id = id; + if (iVar2 == 0xb) { + (grp->P).p = secp224k1_p; + (grp->A).p = secp224k1_a; + (grp->B).p = secp224k1_b; + (grp->N).n = 8; + grp->modp = ecp_mod_p224k1; + (grp->N).p = secp224k1_n; + (grp->P).n = 7; + (grp->G).X.n = 7; + (grp->G).Y.n = 7; + (grp->P).s = 1; + (grp->A).s = 1; + (grp->A).n = 1; + (grp->B).s = 1; + (grp->B).n = 1; + (grp->N).s = 1; + (grp->G).X.s = 1; + (grp->G).X.p = secp224k1_gx; + (grp->G).Y.s = 1; + pmVar3 = secp224k1_gy; + } + else { + if (iVar2 == 0xc) { + (grp->P).p = secp256k1_p; + (grp->A).p = secp256k1_a; + (grp->B).p = secp256k1_b; + grp->modp = ecp_mod_p256k1; + (grp->N).p = secp256k1_n; + (grp->P).n = 8; + (grp->N).n = 8; + (grp->G).X.n = 8; + (grp->G).Y.n = 8; + (grp->P).s = 1; + (grp->A).s = 1; + (grp->A).n = 1; + (grp->B).s = 1; + (grp->B).n = 1; + (grp->N).s = 1; + (grp->G).X.s = 1; + (grp->G).X.p = secp256k1_gx; + (grp->G).Y.s = 1; + pmVar3 = secp256k1_gy; + } + else { + if (iVar2 != 3) { + mbedtls_ecp_group_free(grp); + return -0x4e80; + } + (grp->P).p = secp256r1_p; + (grp->B).p = secp256r1_b; + (grp->N).p = secp256r1_n; + (grp->P).n = 8; + (grp->B).n = 8; + (grp->N).n = 8; + (grp->G).X.n = 8; + (grp->G).Y.n = 8; + (grp->P).s = 1; + (grp->B).s = 1; + (grp->N).s = 1; + (grp->G).X.s = 1; + (grp->G).X.p = secp256r1_gx; + (grp->G).Y.s = 1; + pmVar3 = secp256r1_gy; + } + } + (grp->G).Y.p = pmVar3; + (grp->G).Z.p = &one_2614; + (grp->G).Z.s = 1; + (grp->G).Z.n = 1; + sVar1 = mbedtls_mpi_bitlen(&grp->P); + grp->pbits = sVar1; + sVar1 = mbedtls_mpi_bitlen(&grp->N); + grp->nbits = sVar1; + grp->h = 1; + return 0; +} + + + +void gcm_mult(mbedtls_gcm_context *ctx,uchar *x,uchar *output) + +{ + mbedtls_cipher_info_t *pmVar1; + mbedtls_cipher_info_t **ppmVar2; + mbedtls_cipher_info_t *pmVar3; + mbedtls_cipher_info_t *pmVar4; + mbedtls_cipher_info_t *pmVar5; + uint uVar6; + int iVar7; + uint uVar8; + uint uVar9; + + iVar7 = 0xf; + ppmVar2 = &(ctx->cipher_ctx).cipher_info + ((uint)x[0xf] & 0xf) * 2; + pmVar1 = ppmVar2[0x30]; + pmVar4 = ppmVar2[0x31]; + pmVar5 = ppmVar2[0x10]; + pmVar3 = ppmVar2[0x11]; + do { + uVar8 = (int)pmVar1 << 0x1c; + uVar6 = (int)pmVar4 << 0x1c; + if (iVar7 != 0xf) { + ppmVar2 = &(ctx->cipher_ctx).cipher_info + ((uint)x[iVar7] & 0xf) * 2; + pmVar4 = (mbedtls_cipher_info_t *) + ((uint)ppmVar2[0x31] ^ + *(int *)(last4 + ((uint)pmVar5 & 0xf)) << 0x10 ^ (uint)pmVar4 >> 4); + pmVar1 = (mbedtls_cipher_info_t *)((uint)ppmVar2[0x30] ^ (uVar6 | (uint)pmVar1 >> 4)); + pmVar5 = (mbedtls_cipher_info_t *) + ((uint)ppmVar2[0x10] ^ ((uint)pmVar5 >> 4 | (int)pmVar3 << 0x1c)); + pmVar3 = (mbedtls_cipher_info_t *)((uint)ppmVar2[0x11] ^ (uVar8 | (uint)pmVar3 >> 4)); + } + ppmVar2 = &(ctx->cipher_ctx).cipher_info + (uint)(x[iVar7] >> 4) * 2; + uVar8 = (int)pmVar1 << 0x1c; + uVar9 = (int)pmVar4 << 0x1c; + uVar6 = (uint)ppmVar2[0x31] ^ (uint)pmVar4 >> 4; + pmVar4 = (mbedtls_cipher_info_t *)(uVar6 ^ *(int *)(last4 + ((uint)pmVar5 & 0xf)) << 0x10); + iVar7 = iVar7 + -1; + pmVar1 = (mbedtls_cipher_info_t *)((uint)ppmVar2[0x30] ^ (uVar9 | (uint)pmVar1 >> 4)); + pmVar5 = (mbedtls_cipher_info_t *) + ((uint)ppmVar2[0x10] ^ ((int)pmVar3 << 0x1c | (uint)pmVar5 >> 4)); + pmVar3 = (mbedtls_cipher_info_t *)((uint)ppmVar2[0x11] ^ (uVar8 | (uint)pmVar3 >> 4)); + } while (iVar7 != -1); + *output = (uchar)((uint)pmVar4 >> 0x18); + output[1] = (uchar)((uint)pmVar4 >> 0x10); + output[3] = (uchar)uVar6; + output[4] = (uchar)((uint)pmVar1 >> 0x18); + output[5] = (uchar)((uint)pmVar1 >> 0x10); + output[6] = (uchar)((uint)pmVar1 >> 8); + output[8] = (uchar)((uint)pmVar3 >> 0x18); + output[9] = (uchar)((uint)pmVar3 >> 0x10); + output[10] = (uchar)((uint)pmVar3 >> 8); + output[0xc] = (uchar)((uint)pmVar5 >> 0x18); + output[0xd] = (uchar)((uint)pmVar5 >> 0x10); + output[2] = (uchar)(uVar6 >> 8); + output[7] = (uchar)pmVar1; + output[0xb] = (uchar)pmVar3; + output[0xe] = (uchar)((uint)pmVar5 >> 8); + output[0xf] = (uchar)pmVar5; + return; +} + + + +void mbedtls_gcm_init(mbedtls_gcm_context *ctx) + +{ + memset(ctx,0,0x188); + return; +} + + + +// WARNING: Variable defined which should be unmapped: h +// WARNING: Could not reconcile some variable overlaps + +int mbedtls_gcm_setkey(mbedtls_gcm_context *ctx,mbedtls_cipher_id_t cipher,uchar *key,uint keybits) + +{ + uint64_t *puVar1; + uint uVar2; + uint64_t *puVar3; + mbedtls_cipher_info_t *cipher_info; + int iVar4; + uint uVar5; + mbedtls_cipher_info_t **ppmVar6; + mbedtls_cipher_info_t *pmVar7; + mbedtls_cipher_info_t *pmVar8; + int iVar9; + mbedtls_cipher_info_t *pmVar10; + uint64_t *puVar11; + int iVar12; + int iVar13; + uint64_t *puVar14; + uint uVar15; + uint *puVar16; + uint uVar17; + size_t sStack36; + size_t olen; + uchar h [16]; + + cipher_info = mbedtls_cipher_info_from_values(cipher,keybits,MBEDTLS_MODE_ECB); + if (cipher_info == (mbedtls_cipher_info_t *)0x0) { + iVar4 = -0x14; + } + else { + iVar4 = -0x14; + if (cipher_info->block_size == 0x10) { + mbedtls_cipher_free((mbedtls_cipher_context_t *)ctx); + iVar4 = mbedtls_cipher_setup((mbedtls_cipher_context_t *)ctx,cipher_info); + if ((iVar4 == 0) && + (iVar4 = mbedtls_cipher_setkey((mbedtls_cipher_context_t *)ctx,key,keybits,MBEDTLS_ENCRYPT) + , iVar4 == 0)) { + sStack36 = 0; + memset(&olen,0,0x10); + iVar4 = mbedtls_cipher_update + ((mbedtls_cipher_context_t *)ctx,(uchar *)&olen,0x10,(uchar *)&olen, + &sStack36); + if (iVar4 == 0) { + cipher_info = (mbedtls_cipher_info_t *) + ((uint)h[0] << 0x18 | (uint)h[1] << 0x10 | (uint)h[3] | (uint)h[2] << 8); + pmVar10 = (mbedtls_cipher_info_t *) + ((uint)(byte)olen << 0x18 | (uint)olen._1_1_ << 0x10 | (uint)olen._3_1_ | + (uint)olen._2_1_ << 8); + pmVar8 = (mbedtls_cipher_info_t *) + ((uint)h[4] << 0x18 | (uint)h[5] << 0x10 | (uint)h[7] | (uint)h[6] << 8); + *(undefined4 *)((int)ctx->HH + 4) = 0; + *(undefined4 *)((int)ctx->HL + 4) = 0; + *(mbedtls_cipher_info_t **)((int)ctx->HL + 0x44) = pmVar8; + *(mbedtls_cipher_info_t **)(ctx->HH + 8) = cipher_info; + *(mbedtls_cipher_info_t **)((int)ctx->HH + 0x44) = pmVar10; + pmVar7 = (mbedtls_cipher_info_t *) + ((uint)h[8] << 0x18 | (uint)h[9] << 0x10 | (uint)h[11] | (uint)h[10] << 8); + *(undefined4 *)ctx->HH = 0; + *(undefined4 *)ctx->HL = 0; + *(mbedtls_cipher_info_t **)(ctx->HL + 8) = pmVar7; + iVar12 = 3; + iVar13 = 4; + do { + uVar5 = (uint)pmVar7 & 1; + uVar15 = (int)pmVar8 << 0x1f; + pmVar8 = (mbedtls_cipher_info_t *)((int)cipher_info << 0x1f | (uint)pmVar8 >> 1); + uVar2 = (int)pmVar10 << 0x1f; + pmVar7 = (mbedtls_cipher_info_t *)(uVar15 | (uint)pmVar7 >> 1); + pmVar10 = (mbedtls_cipher_info_t *)((uint)pmVar10 >> 1 ^ uVar5 * -0x1f000000); + ppmVar6 = &(ctx->cipher_ctx).cipher_info + iVar13 * 2; + cipher_info = (mbedtls_cipher_info_t *)(uVar2 | (uint)cipher_info >> 1); + ppmVar6[0x10] = pmVar7; + ppmVar6[0x11] = pmVar8; + ppmVar6[0x30] = cipher_info; + ppmVar6[0x31] = pmVar10; + iVar12 = iVar12 + -1; + iVar13 = iVar13 >> 1; + } while (iVar12 != 0); + iVar13 = 3; + iVar12 = 2; + do { + puVar14 = ctx->HL + iVar12; + puVar3 = ctx->HH + iVar12; + uVar15 = *(uint *)puVar3; + uVar5 = *(uint *)((int)puVar3 + 4); + uVar2 = *(uint *)puVar14; + uVar17 = *(uint *)((int)puVar14 + 4); + iVar9 = 8; + puVar1 = ctx->HL; + do { + puVar11 = puVar1 + 1; + *(uint *)((int)puVar3 + iVar9) = *(uint *)(puVar11 + 0x10) ^ uVar15; + ((uint *)((int)puVar3 + iVar9))[1] = *(uint *)((int)puVar1 + 0x8c) ^ uVar5; + puVar16 = (uint *)((int)puVar14 + iVar9); + iVar9 = iVar9 + 8; + *puVar16 = *(uint *)puVar11 ^ uVar2; + puVar16[1] = *(uint *)((int)puVar1 + 0xc) ^ uVar17; + puVar1 = puVar11; + } while (iVar12 * 8 != iVar9); + iVar13 = iVar13 + -1; + iVar12 = iVar12 << 1; + } while (iVar13 != 0); + } + } + } + } + return iVar4; +} + + + +int mbedtls_gcm_starts(mbedtls_gcm_context *ctx,int mode,uchar *iv,size_t iv_len,uchar *add, + size_t add_len) + +{ + byte bVar1; + uint uVar2; + int iVar3; + byte *pbVar4; + byte *pbVar5; + byte *x; + size_t *psVar6; + uint uVar7; + byte *x_00; + size_t sStack68; + size_t olen; + uchar work_buf [16]; + + x = ctx->y; + sStack68 = 0; + x_00 = ctx->buf; + memset(x,0,0x10); + memset(x_00,0,0x10); + *(undefined4 *)&ctx->len = 0; + *(undefined4 *)&ctx->add_len = 0; + ctx->mode = mode; + *(undefined4 *)((int)&ctx->len + 4) = 0; + *(undefined4 *)((int)&ctx->add_len + 4) = 0; + if (iv_len == 0xc) { + memcpy(x,iv,0xc); + ctx->y[0xf] = '\x01'; + } + else { + memset(&olen,0,0x10); + while (iv_len != 0) { + uVar2 = iv_len; + if (0x10 < iv_len) { + uVar2 = 0x10; + } + uVar7 = 0; + pbVar4 = x; + do { + pbVar5 = iv + uVar7; + uVar7 = uVar7 + 1; + *pbVar4 = *pbVar5 ^ *pbVar4; + pbVar4 = pbVar4 + 1; + } while (uVar2 != uVar7); + gcm_mult(ctx,x,x); + iv_len = iv_len - uVar2; + iv = iv + uVar2; + } + psVar6 = &olen; + pbVar4 = x; + do { + bVar1 = *(byte *)psVar6; + pbVar5 = pbVar4 + 1; + psVar6 = (size_t *)((int)psVar6 + 1); + *pbVar4 = *pbVar4 ^ bVar1; + pbVar4 = pbVar5; + } while (x_00 != pbVar5); + gcm_mult(ctx,x,x); + } + iVar3 = mbedtls_cipher_update((mbedtls_cipher_context_t *)ctx,x,0x10,ctx->base_ectr,&sStack68); + if (iVar3 == 0) { + *(size_t *)&ctx->add_len = add_len; + *(undefined4 *)((int)&ctx->add_len + 4) = 0; + while (add_len != 0) { + uVar2 = add_len; + if (0x10 < add_len) { + uVar2 = 0x10; + } + uVar7 = 0; + x = x_00; + do { + pbVar4 = add + uVar7; + uVar7 = uVar7 + 1; + *x = *pbVar4 ^ *x; + x = x + 1; + } while (uVar2 != uVar7); + gcm_mult(ctx,x_00,x_00); + add_len = add_len - uVar2; + add = add + uVar2; + } + } + return iVar3; +} + + + +int mbedtls_gcm_update(mbedtls_gcm_context *ctx,size_t length,uchar *input,uchar *output) + +{ + uchar uVar1; + int iVar2; + byte bVar3; + uint uVar4; + uint uVar5; + uchar *puVar6; + uint uVar7; + byte *x; + byte *pbVar8; + size_t sStack68; + size_t olen; + uchar ectr [16]; + + sStack68 = 0; + if ((output <= input) || (iVar2 = -0x14, length <= output + -(int)input)) { + uVar4 = *(uint *)((int)&ctx->len + 4); + uVar5 = length + *(uint *)&ctx->len; + uVar7 = (uVar5 < length) + uVar4; + if (((uVar7 < uVar4) || (((uVar4 == uVar7 && (uVar5 < *(uint *)&ctx->len)) || (0xf < uVar7)))) + || ((uVar7 == 0xf && (0xffffffe0 < uVar5)))) { + iVar2 = -0x14; + } + else { + *(uint *)&ctx->len = uVar5; + *(uint *)((int)&ctx->len + 4) = uVar7; + while (length != 0) { + uVar4 = length; + if (0x10 < length) { + uVar4 = 0x10; + } + puVar6 = ctx->y + 0xf; + do { + uVar1 = *puVar6; + *puVar6 = uVar1 + '\x01'; + if ((uchar)(uVar1 + '\x01') != '\0') break; + puVar6 = puVar6 + -1; + } while (puVar6 != ctx->y + 0xb); + iVar2 = mbedtls_cipher_update + ((mbedtls_cipher_context_t *)ctx,ctx->y,0x10,(uchar *)&olen,&sStack68); + if (iVar2 != 0) { + return iVar2; + } + x = ctx->buf; + uVar5 = 0; + pbVar8 = x; + do { + if (ctx->mode == 0) { + *pbVar8 = input[uVar5] ^ *pbVar8; + } + bVar3 = *(byte *)((int)&olen + uVar5) ^ input[uVar5]; + output[uVar5] = bVar3; + if (ctx->mode == 1) { + *pbVar8 = bVar3 ^ *pbVar8; + } + uVar5 = uVar5 + 1; + pbVar8 = pbVar8 + 1; + } while (uVar4 != uVar5); + gcm_mult(ctx,x,x); + length = length - uVar4; + input = input + uVar4; + output = output + uVar4; + } + iVar2 = 0; + } + } + return iVar2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int mbedtls_gcm_finish(mbedtls_gcm_context *ctx,uchar *tag,size_t tag_len) + +{ + byte bVar1; + uint uVar2; + uint uVar3; + int *x; + int iVar4; + byte *pbVar5; + int *piVar6; + int *piVar7; + byte *pbVar8; + uint uVar9; + uint uVar10; + uint uVar11; + uint uVar12; + byte local_40 [4]; + uchar work_buf [16]; + + pbVar8 = local_40; + uVar11 = *(uint *)&ctx->len; + uVar12 = *(uint *)&ctx->add_len; + uVar2 = *(int *)((int)&ctx->len + 4) << 3; + uVar3 = uVar2 | uVar11 >> 0x1d; + uVar9 = *(int *)((int)&ctx->add_len + 4) << 3; + uVar10 = uVar12 >> 0x1d | uVar9; + if (tag_len - 4 < 0xd) { + memcpy(tag,ctx->base_ectr,tag_len); + if (((uVar11 | uVar12) << 3 | uVar3 | uVar10) != 0) { + memset(local_40,0,0x10); + local_40[0] = (byte)(uVar9 >> 0x18); + local_40[1] = (char)(uVar9 >> 0x10); + local_40[2] = (char)(uVar9 >> 8); + work_buf[0] = (uchar)((uVar12 << 3) >> 0x18); + work_buf[1] = (uchar)((uVar12 << 3) >> 0x10); + work_buf[4] = (uchar)(uVar2 >> 0x18); + work_buf[5] = (uchar)(uVar2 >> 0x10); + work_buf[6] = (uchar)(uVar2 >> 8); + work_buf[8] = (uchar)((uVar11 << 3) >> 0x18); + work_buf[7] = (uchar)uVar3; + x = (int *)ctx->buf; + work_buf[9] = (uchar)((uVar11 << 3) >> 0x10); + local_40[3] = (char)uVar10; + work_buf._2_2_ = (ushort)(uVar12 << 0xb) | (ushort)((uVar12 << 0x13) >> 0x18); + work_buf._10_2_ = (ushort)(uVar11 << 0xb) | (ushort)((uVar11 << 0x13) >> 0x18); + piVar6 = x; + do { + bVar1 = *pbVar8; + piVar7 = (int *)((int)piVar6 + 1); + pbVar8 = pbVar8 + 1; + *(byte *)piVar6 = *(byte *)piVar6 ^ bVar1; + piVar6 = piVar7; + } while (piVar7 != &ctx->mode); + gcm_mult(ctx,(uchar *)x,(uchar *)x); + pbVar8 = tag; + do { + bVar1 = *(byte *)x; + pbVar5 = pbVar8 + 1; + x = (int *)((int)x + 1); + *pbVar8 = *pbVar8 ^ bVar1; + pbVar8 = pbVar5; + } while (tag + tag_len != pbVar5); + } + iVar4 = 0; + } + else { + iVar4 = -0x14; + } + return iVar4; +} + + + +int mbedtls_gcm_crypt_and_tag + (mbedtls_gcm_context *ctx,int mode,size_t length,uchar *iv,size_t iv_len,uchar *add, + size_t add_len,uchar *input,uchar *output,size_t tag_len,uchar *tag) + +{ + int iVar1; + uchar *in_stack_00000000; + size_t in_stack_00000004; + uchar *in_stack_00000008; + + iVar1 = mbedtls_gcm_starts(ctx,mode,iv,iv_len,add,add_len); + if ((iVar1 == 0) && (iVar1 = mbedtls_gcm_update(ctx,length,input,in_stack_00000000), iVar1 == 0)) + { + iVar1 = mbedtls_gcm_finish(ctx,in_stack_00000008,in_stack_00000004); + return iVar1; + } + return iVar1; +} + + + +int mbedtls_gcm_auth_decrypt + (mbedtls_gcm_context *ctx,size_t length,uchar *iv,size_t iv_len,uchar *add, + size_t add_len,uchar *tag,size_t tag_len,uchar *input,uchar *output) + +{ + undefined *puVar1; + uint uVar2; + byte *pbVar3; + byte *pbVar4; + size_t sVar5; + uchar *in_fa2; + uchar *in_stack_00000000; + undefined *in_stack_00000004; + byte local_30 [4]; + uchar check_tag [16]; + + uVar2 = mbedtls_gcm_crypt_and_tag + (ctx,0,length,iv,iv_len,add,add_len,in_stack_00000000,input,(size_t)output, + in_fa2); + sVar5 = 0; + if (uVar2 == 0) { + while (sVar5 != tag_len) { + pbVar4 = tag + sVar5; + pbVar3 = local_30 + sVar5; + sVar5 = sVar5 + 1; + uVar2 = uVar2 | *pbVar4 ^ *pbVar3; + } + puVar1 = in_stack_00000004 + length; + if (uVar2 != 0) { + while (in_stack_00000004 != puVar1) { + *in_stack_00000004 = 0; + in_stack_00000004 = in_stack_00000004 + 1; + } + uVar2 = 0xffffffee; + } + } + return uVar2; +} + + + +void mbedtls_gcm_free(mbedtls_gcm_context *ctx) + +{ + mbedtls_gcm_context *pmVar1; + + mbedtls_cipher_free((mbedtls_cipher_context_t *)ctx); + pmVar1 = ctx + 1; + while (ctx != pmVar1) { + *(undefined *)&(ctx->cipher_ctx).cipher_info = 0; + ctx = (mbedtls_gcm_context *)((int)&(ctx->cipher_ctx).cipher_info + 1); + } + return; +} + + + +mbedtls_md_info_t * mbedtls_md_info_from_type(mbedtls_md_type_t md_type) + +{ + uint uVar1; + + uVar1 = (uint)md_type - 3 & 0xff; + if (uVar1 < 4) { + return *(mbedtls_md_info_t **)(CSWTCH_2 + uVar1 * 4); + } + return (mbedtls_md_info_t *)0x0; +} + + + +void mbedtls_md_init(mbedtls_md_context_t *ctx) + +{ + memset(ctx,0,0xc); + return; +} + + + +void mbedtls_md_free(mbedtls_md_context_t *ctx) + +{ + undefined *puVar1; + mbedtls_md_context_t *pmVar2; + undefined *puVar3; + + if (ctx != (mbedtls_md_context_t *)0x0) { + if (ctx->md_info != (mbedtls_md_info_t *)0x0) { + if (ctx->md_ctx != (void *)0x0) { + (*ctx->md_info->ctx_free_func)(ctx->md_ctx); + } + puVar3 = (undefined *)ctx->hmac_ctx; + if (puVar3 != (undefined *)0x0) { + puVar1 = puVar3 + ctx->md_info->block_size * 2; + while (puVar3 != puVar1) { + *puVar3 = 0; + puVar3 = puVar3 + 1; + } + vPortFree(ctx->hmac_ctx); + } + pmVar2 = ctx + 1; + while (ctx != pmVar2) { + *(undefined *)&ctx->md_info = 0; + ctx = (mbedtls_md_context_t *)((int)&ctx->md_info + 1); + } + } + return; + } + return; +} + + + +int mbedtls_md_setup(mbedtls_md_context_t *ctx,mbedtls_md_info_t *md_info,int hmac) + +{ + void *pvVar1; + int iVar2; + + if ((md_info == (mbedtls_md_info_t *)0x0) || (ctx == (mbedtls_md_context_t *)0x0)) { + return -0x5100; + } + pvVar1 = (*md_info->ctx_alloc_func)(md_info->ctx_alloc_func); + ctx->md_ctx = pvVar1; + if (pvVar1 == (void *)0x0) { +LAB_230657a0: + iVar2 = -0x5180; + } + else { + if (hmac != 0) { + pvVar1 = mycalloc(2,md_info->block_size); + ctx->hmac_ctx = pvVar1; + if (pvVar1 == (void *)0x0) { + (*md_info->ctx_free_func)(ctx->md_ctx); + goto LAB_230657a0; + } + } + ctx->md_info = md_info; + iVar2 = 0; + } + return iVar2; +} + + + +int mbedtls_md_starts(mbedtls_md_context_t *ctx) + +{ + if ((ctx != (mbedtls_md_context_t *)0x0) && (ctx->md_info != (mbedtls_md_info_t *)0x0)) { + (*ctx->md_info->starts_func)(ctx->md_ctx); + return 0; + } + return -0x5100; +} + + + +int mbedtls_md_update(mbedtls_md_context_t *ctx,uchar *input,size_t ilen) + +{ + if ((ctx != (mbedtls_md_context_t *)0x0) && (ctx->md_info != (mbedtls_md_info_t *)0x0)) { + (*ctx->md_info->update_func)(ctx->md_ctx,input,ilen); + return 0; + } + return -0x5100; +} + + + +int mbedtls_md_finish(mbedtls_md_context_t *ctx,uchar *output) + +{ + if ((ctx != (mbedtls_md_context_t *)0x0) && (ctx->md_info != (mbedtls_md_info_t *)0x0)) { + (*ctx->md_info->finish_func)(ctx->md_ctx,output); + return 0; + } + return -0x5100; +} + + + +int mbedtls_md(mbedtls_md_info_t *md_info,uchar *input,size_t ilen,uchar *output) + +{ + if (md_info != (mbedtls_md_info_t *)0x0) { + (*md_info->digest_func)(input,ilen,output); + return 0; + } + return -0x5100; +} + + + +int mbedtls_md_hmac_starts(mbedtls_md_context_t *ctx,uchar *key,size_t keylen) + +{ + int iVar1; + size_t __n; + byte *pbVar2; + byte *pbVar3; + mbedtls_md_info_t *pmVar4; + size_t sVar5; + uchar *puVar6; + uchar *__s; + uchar *__s_00; + uchar local_40 [4]; + uchar sum [32]; + + if (ctx == (mbedtls_md_context_t *)0x0) { + return -0x5100; + } + puVar6 = local_40; + pmVar4 = ctx->md_info; + if ((pmVar4 == (mbedtls_md_info_t *)0x0) || (ctx->hmac_ctx == (void *)0x0)) { + iVar1 = -0x5100; + } + else { + if ((uint)pmVar4->block_size < keylen) { + (*pmVar4->starts_func)(ctx->md_ctx); + (*ctx->md_info->update_func)(ctx->md_ctx,key,keylen); + (*ctx->md_info->finish_func)(ctx->md_ctx,local_40); + keylen = ctx->md_info->size; + key = local_40; + } + __s = (uchar *)ctx->hmac_ctx; + __n = ctx->md_info->block_size; + __s_00 = __s + __n; + memset(__s,0x36,__n); + memset(__s_00,0x5c,ctx->md_info->block_size); + sVar5 = 0; + while (keylen != sVar5) { + pbVar2 = key + sVar5; + __s[sVar5] = __s[sVar5] ^ *pbVar2; + pbVar3 = __s_00 + sVar5; + sVar5 = sVar5 + 1; + *pbVar3 = *pbVar3 ^ *pbVar2; + } + do { + *puVar6 = '\0'; + puVar6 = puVar6 + 1; + } while (puVar6 != sum + 0x1c); + (*ctx->md_info->starts_func)(ctx->md_ctx); + (*ctx->md_info->update_func)(ctx->md_ctx,__s,ctx->md_info->block_size); + iVar1 = 0; + } + return iVar1; +} + + + +int mbedtls_md_hmac_update(mbedtls_md_context_t *ctx,uchar *input,size_t ilen) + +{ + if (((ctx != (mbedtls_md_context_t *)0x0) && (ctx->md_info != (mbedtls_md_info_t *)0x0)) && + (ctx->hmac_ctx != (void *)0x0)) { + (*ctx->md_info->update_func)(ctx->md_ctx,input,ilen); + return 0; + } + return -0x5100; +} + + + +// WARNING: Variable defined which should be unmapped: tmp + +int mbedtls_md_hmac_finish(mbedtls_md_context_t *ctx,uchar *output) + +{ + int iVar1; + mbedtls_md_info_t *pmVar2; + void *pvVar3; + uchar auStack48 [4]; + uchar tmp [32]; + + if (((ctx != (mbedtls_md_context_t *)0x0) && + (pmVar2 = ctx->md_info, pmVar2 != (mbedtls_md_info_t *)0x0)) && + (pvVar3 = ctx->hmac_ctx, pvVar3 != (void *)0x0)) { + iVar1 = pmVar2->block_size; + (*pmVar2->finish_func)(ctx->md_ctx,auStack48); + (*ctx->md_info->starts_func)(ctx->md_ctx); + (*ctx->md_info->update_func) + (ctx->md_ctx,(uchar *)(iVar1 + (int)pvVar3),ctx->md_info->block_size); + (*ctx->md_info->update_func)(ctx->md_ctx,auStack48,ctx->md_info->size); + (*ctx->md_info->finish_func)(ctx->md_ctx,output); + return 0; + } + return -0x5100; +} + + + +int mbedtls_md_hmac_reset(mbedtls_md_context_t *ctx) + +{ + int iVar1; + uchar *puVar2; + + if ((ctx != (mbedtls_md_context_t *)0x0) && (ctx->md_info != (mbedtls_md_info_t *)0x0)) { + puVar2 = (uchar *)ctx->hmac_ctx; + if (puVar2 == (uchar *)0x0) { + iVar1 = -0x5100; + } + else { + (*ctx->md_info->starts_func)(ctx->md_ctx); + (*ctx->md_info->update_func)(ctx->md_ctx,puVar2,ctx->md_info->block_size); + iVar1 = 0; + } + return iVar1; + } + return -0x5100; +} + + + +int mbedtls_md_process(mbedtls_md_context_t *ctx,uchar *data) + +{ + if ((ctx != (mbedtls_md_context_t *)0x0) && (ctx->md_info != (mbedtls_md_info_t *)0x0)) { + (*ctx->md_info->process_func)(ctx->md_ctx,data); + return 0; + } + return -0x5100; +} + + + +uchar mbedtls_md_get_size(mbedtls_md_info_t *md_info) + +{ + if (md_info != (mbedtls_md_info_t *)0x0) { + return *(uchar *)&md_info->size; + } + return '\0'; +} + + + +void md5_process_wrap(mbedtls_md5_context *ctx,uchar *data) + +{ + int iVar1; + int iVar2; + int iVar3; + int iVar4; + int iVar5; + int iVar6; + int iVar7; + int iVar8; + int iVar9; + int iVar10; + int iVar11; + int iVar12; + int iVar13; + int iVar14; + int iVar15; + int iVar16; + uint uVar17; + uint uVar18; + uint uVar19; + uint uVar20; + uint uVar21; + uint uVar22; + uint uVar23; + uint uVar24; + uint uVar25; + + iVar1 = *(int *)data; + iVar2 = *(int *)(data + 4); + iVar3 = *(int *)(data + 0x10); + iVar4 = *(int *)(data + 8); + iVar5 = *(int *)(data + 0xc); + iVar6 = *(int *)(data + 0x14); + iVar7 = *(int *)(data + 0x18); + iVar8 = *(int *)(data + 0x24); + iVar9 = *(int *)(data + 0x1c); + iVar10 = *(int *)(data + 0x20); + iVar11 = *(int *)(data + 0x2c); + iVar12 = *(int *)(data + 0x28); + iVar13 = *(int *)(data + 0x30); + uVar19 = ctx->state[3]; + iVar14 = *(int *)(data + 0x34); + iVar15 = *(int *)(data + 0x38); + iVar16 = *(int *)(data + 0x3c); + uVar17 = ctx->state[2]; + uVar18 = ctx->state[1]; + uVar20 = ((uVar17 ^ uVar19) & uVar18 ^ uVar19) + ctx->state[0] + 0xd76aa478 + iVar1; + uVar21 = (uVar20 >> 0x19 | uVar20 * 0x80) + uVar18; + uVar20 = ((uVar18 ^ uVar17) & uVar21 ^ uVar17) + uVar19 + 0xe8c7b756 + iVar2; + uVar23 = (uVar20 >> 0x14 | uVar20 * 0x1000) + uVar21; + uVar20 = ((uVar18 ^ uVar21) & uVar23 ^ uVar18) + uVar17 + 0x242070db + iVar4; + uVar22 = (uVar20 * 0x20000 | uVar20 >> 0xf) + uVar23; + uVar20 = ((uVar21 ^ uVar23) & uVar22 ^ uVar21) + uVar18 + 0xc1bdceee + iVar5; + uVar20 = (uVar20 * 0x400000 | uVar20 >> 10) + uVar22; + uVar21 = ((uVar23 ^ uVar22) & uVar20 ^ uVar23) + iVar3 + -0xa83f051 + uVar21; + uVar21 = (uVar21 >> 0x19 | uVar21 * 0x80) + uVar20; + uVar23 = ((uVar22 ^ uVar20) & uVar21 ^ uVar22) + iVar6 + 0x4787c62a + uVar23; + uVar23 = (uVar23 >> 0x14 | uVar23 * 0x1000) + uVar21; + uVar22 = ((uVar20 ^ uVar21) & uVar23 ^ uVar20) + iVar7 + -0x57cfb9ed + uVar22; + uVar22 = (uVar22 * 0x20000 | uVar22 >> 0xf) + uVar23; + uVar20 = ((uVar21 ^ uVar23) & uVar22 ^ uVar21) + iVar9 + -0x2b96aff + uVar20; + uVar20 = (uVar20 * 0x400000 | uVar20 >> 10) + uVar22; + uVar21 = ((uVar23 ^ uVar22) & uVar20 ^ uVar23) + iVar10 + 0x698098d8 + uVar21; + uVar21 = (uVar21 >> 0x19 | uVar21 * 0x80) + uVar20; + uVar23 = ((uVar22 ^ uVar20) & uVar21 ^ uVar22) + iVar8 + -0x74bb0851 + uVar23; + uVar23 = (uVar23 >> 0x14 | uVar23 * 0x1000) + uVar21; + uVar22 = ((uVar20 ^ uVar21) & uVar23 ^ uVar20) + iVar12 + -0xa44f + uVar22; + uVar22 = (uVar22 * 0x20000 | uVar22 >> 0xf) + uVar23; + uVar20 = ((uVar21 ^ uVar23) & uVar22 ^ uVar21) + iVar11 + -0x76a32842 + uVar20; + uVar20 = (uVar20 * 0x400000 | uVar20 >> 10) + uVar22; + uVar21 = ((uVar23 ^ uVar22) & uVar20 ^ uVar23) + iVar13 + 0x6b901122 + uVar21; + uVar21 = (uVar21 >> 0x19 | uVar21 * 0x80) + uVar20; + uVar23 = ((uVar22 ^ uVar20) & uVar21 ^ uVar22) + iVar14 + -0x2678e6d + uVar23; + uVar23 = (uVar23 >> 0x14 | uVar23 * 0x1000) + uVar21; + uVar22 = ((uVar20 ^ uVar21) & uVar23 ^ uVar20) + iVar15 + -0x5986bc72 + uVar22; + uVar22 = (uVar22 * 0x20000 | uVar22 >> 0xf) + uVar23; + uVar20 = ((uVar21 ^ uVar23) & uVar22 ^ uVar21) + iVar16 + 0x49b40821 + uVar20; + uVar20 = (uVar20 * 0x400000 | uVar20 >> 10) + uVar22; + uVar21 = ((uVar22 ^ uVar20) & uVar23 ^ uVar22) + iVar2 + -0x9e1da9e + uVar21; + uVar21 = (uVar21 >> 0x1b | uVar21 * 0x20) + uVar20; + uVar23 = ((uVar20 ^ uVar21) & uVar22 ^ uVar20) + iVar7 + -0x3fbf4cc0 + uVar23; + uVar23 = (uVar23 >> 0x17 | uVar23 * 0x200) + uVar21; + uVar22 = ((uVar21 ^ uVar23) & uVar20 ^ uVar21) + iVar11 + 0x265e5a51 + uVar22; + uVar22 = (uVar22 >> 0x12 | uVar22 * 0x4000) + uVar23; + uVar20 = ((uVar23 ^ uVar22) & uVar21 ^ uVar23) + iVar1 + -0x16493856 + uVar20; + uVar20 = (uVar20 * 0x100000 | uVar20 >> 0xc) + uVar22; + uVar21 = ((uVar22 ^ uVar20) & uVar23 ^ uVar22) + iVar6 + -0x29d0efa3 + uVar21; + uVar21 = (uVar21 >> 0x1b | uVar21 * 0x20) + uVar20; + uVar23 = ((uVar20 ^ uVar21) & uVar22 ^ uVar20) + iVar12 + 0x2441453 + uVar23; + uVar23 = (uVar23 >> 0x17 | uVar23 * 0x200) + uVar21; + uVar22 = ((uVar21 ^ uVar23) & uVar20 ^ uVar21) + iVar16 + -0x275e197f + uVar22; + uVar22 = (uVar22 >> 0x12 | uVar22 * 0x4000) + uVar23; + uVar20 = ((uVar23 ^ uVar22) & uVar21 ^ uVar23) + iVar3 + -0x182c0438 + uVar20; + uVar20 = (uVar20 * 0x100000 | uVar20 >> 0xc) + uVar22; + uVar21 = ((uVar22 ^ uVar20) & uVar23 ^ uVar22) + iVar8 + 0x21e1cde6 + uVar21; + uVar21 = (uVar21 >> 0x1b | uVar21 * 0x20) + uVar20; + uVar23 = ((uVar20 ^ uVar21) & uVar22 ^ uVar20) + iVar15 + -0x3cc8f82a + uVar23; + uVar23 = (uVar23 >> 0x17 | uVar23 * 0x200) + uVar21; + uVar22 = ((uVar21 ^ uVar23) & uVar20 ^ uVar21) + iVar5 + -0xb2af279 + uVar22; + uVar22 = (uVar22 >> 0x12 | uVar22 * 0x4000) + uVar23; + uVar20 = ((uVar23 ^ uVar22) & uVar21 ^ uVar23) + iVar10 + 0x455a14ed + uVar20; + uVar20 = (uVar20 * 0x100000 | uVar20 >> 0xc) + uVar22; + uVar21 = ((uVar22 ^ uVar20) & uVar23 ^ uVar22) + iVar14 + -0x561c16fb + uVar21; + uVar21 = (uVar21 >> 0x1b | uVar21 * 0x20) + uVar20; + uVar23 = ((uVar20 ^ uVar21) & uVar22 ^ uVar20) + iVar4 + -0x3105c08 + uVar23; + uVar24 = (uVar23 >> 0x17 | uVar23 * 0x200) + uVar21; + uVar22 = ((uVar21 ^ uVar24) & uVar20 ^ uVar21) + iVar9 + 0x676f02d9 + uVar22; + uVar23 = (uVar22 >> 0x12 | uVar22 * 0x4000) + uVar24; + uVar20 = ((uVar24 ^ uVar23) & uVar21 ^ uVar24) + iVar13 + -0x72d5b376 + uVar20; + uVar20 = (uVar20 * 0x100000 | uVar20 >> 0xc) + uVar23; + uVar21 = (uVar24 ^ uVar23 ^ uVar20) + iVar6 + -0x5c6be + uVar21; + uVar21 = (uVar21 >> 0x1c | uVar21 * 0x10) + uVar20; + uVar22 = (uVar23 ^ uVar20 ^ uVar21) + uVar24 + iVar10 + -0x788e097f; + uVar22 = (uVar22 >> 0x15 | uVar22 * 0x800) + uVar21; + uVar23 = (uVar20 ^ uVar21 ^ uVar22) + uVar23 + iVar11 + 0x6d9d6122; + uVar24 = (uVar23 >> 0x10 | uVar23 * 0x10000) + uVar22; + uVar20 = (uVar21 ^ uVar22 ^ uVar24) + uVar20 + iVar15 + -0x21ac7f4; + uVar23 = (uVar20 * 0x800000 | uVar20 >> 9) + uVar24; + uVar20 = (uVar22 ^ uVar24 ^ uVar23) + iVar2 + -0x5b4115bc + uVar21; + uVar21 = (uVar20 >> 0x1c | uVar20 * 0x10) + uVar23; + uVar20 = (uVar24 ^ uVar23 ^ uVar21) + uVar22 + iVar3 + 0x4bdecfa9; + uVar20 = (uVar20 >> 0x15 | uVar20 * 0x800) + uVar21; + uVar22 = (uVar23 ^ uVar21 ^ uVar20) + iVar9 + -0x944b4a0 + uVar24; + uVar24 = (uVar22 >> 0x10 | uVar22 * 0x10000) + uVar20; + uVar22 = (uVar21 ^ uVar20 ^ uVar24) + uVar23 + iVar12 + -0x41404390; + uVar22 = (uVar22 * 0x800000 | uVar22 >> 9) + uVar24; + uVar21 = (uVar20 ^ uVar24 ^ uVar22) + uVar21 + iVar14 + 0x289b7ec6; + uVar23 = (uVar21 >> 0x1c | uVar21 * 0x10) + uVar22; + uVar20 = (uVar24 ^ uVar22 ^ uVar23) + iVar1 + -0x155ed806 + uVar20; + uVar20 = (uVar20 >> 0x15 | uVar20 * 0x800) + uVar23; + uVar21 = (uVar22 ^ uVar23 ^ uVar20) + iVar5 + -0x2b10cf7b + uVar24; + uVar24 = (uVar21 >> 0x10 | uVar21 * 0x10000) + uVar20; + uVar21 = (uVar23 ^ uVar20 ^ uVar24) + uVar22 + iVar7 + 0x4881d05; + uVar21 = (uVar21 * 0x800000 | uVar21 >> 9) + uVar24; + uVar22 = (uVar20 ^ uVar24 ^ uVar21) + iVar8 + -0x262b2fc7 + uVar23; + uVar23 = (uVar22 >> 0x1c | uVar22 * 0x10) + uVar21; + uVar20 = (uVar24 ^ uVar21 ^ uVar23) + uVar20 + iVar13 + -0x1924661b; + uVar22 = (uVar20 >> 0x15 | uVar20 * 0x800) + uVar23; + uVar20 = (uVar21 ^ uVar23 ^ uVar22) + uVar24 + iVar16 + 0x1fa27cf8; + uVar20 = (uVar20 >> 0x10 | uVar20 * 0x10000) + uVar22; + uVar21 = (uVar23 ^ uVar22 ^ uVar20) + iVar4 + -0x3b53a99b + uVar21; + uVar21 = (uVar21 * 0x800000 | uVar21 >> 9) + uVar20; + uVar23 = ((~uVar22 | uVar21) ^ uVar20) + uVar23 + iVar1 + -0xbd6ddbc; + uVar24 = (uVar23 >> 0x1a | uVar23 * 0x40) + uVar21; + uVar22 = ((~uVar20 | uVar24) ^ uVar21) + uVar22 + iVar9 + 0x432aff97; + uVar23 = (uVar22 >> 0x16 | uVar22 * 0x400) + uVar24; + uVar20 = ((~uVar21 | uVar23) ^ uVar24) + iVar15 + -0x546bdc59 + uVar20; + uVar20 = (uVar20 >> 0x11 | uVar20 * 0x8000) + uVar23; + uVar21 = ((~uVar24 | uVar20) ^ uVar23) + iVar6 + -0x36c5fc7 + uVar21; + uVar22 = (uVar21 * 0x200000 | uVar21 >> 0xb) + uVar20; + uVar21 = ((~uVar23 | uVar22) ^ uVar20) + iVar13 + 0x655b59c3 + uVar24; + uVar24 = (uVar21 >> 0x1a | uVar21 * 0x40) + uVar22; + uVar21 = ((~uVar20 | uVar24) ^ uVar22) + uVar23 + iVar5 + -0x70f3336e; + uVar21 = (uVar21 >> 0x16 | uVar21 * 0x400) + uVar24; + uVar20 = ((~uVar22 | uVar21) ^ uVar24) + iVar12 + -0x100b83 + uVar20; + uVar20 = (uVar20 >> 0x11 | uVar20 * 0x8000) + uVar21; + uVar22 = ((~uVar24 | uVar20) ^ uVar21) + iVar2 + -0x7a7ba22f + uVar22; + uVar22 = (uVar22 * 0x200000 | uVar22 >> 0xb) + uVar20; + uVar23 = ((~uVar21 | uVar22) ^ uVar20) + iVar10 + 0x6fa87e4f + uVar24; + uVar25 = (uVar23 >> 0x1a | uVar23 * 0x40) + uVar22; + uVar21 = ((~uVar20 | uVar25) ^ uVar22) + uVar21 + iVar16 + -0x1d31920; + uVar24 = (uVar21 >> 0x16 | uVar21 * 0x400) + uVar25; + uVar20 = ((~uVar22 | uVar24) ^ uVar25) + iVar7 + -0x5cfebcec + uVar20; + uVar20 = (uVar20 >> 0x11 | uVar20 * 0x8000) + uVar24; + uVar21 = ((~uVar25 | uVar20) ^ uVar24) + iVar14 + 0x4e0811a1 + uVar22; + uVar23 = (uVar21 * 0x200000 | uVar21 >> 0xb) + uVar20; + uVar21 = ((~uVar24 | uVar23) ^ uVar20) + uVar25 + iVar3 + -0x8ac817e; + uVar22 = (uVar21 >> 0x1a | uVar21 * 0x40) + uVar23; + uVar21 = ((~uVar20 | uVar22) ^ uVar23) + uVar24 + iVar11 + -0x42c50dcb; + uVar21 = (uVar21 >> 0x16 | uVar21 * 0x400) + uVar22; + uVar20 = ((~uVar23 | uVar21) ^ uVar22) + uVar20 + iVar4 + 0x2ad7d2bb; + uVar20 = (uVar20 >> 0x11 | uVar20 * 0x8000) + uVar21; + uVar23 = ((~uVar22 | uVar20) ^ uVar21) + uVar23 + iVar8 + -0x14792c6f; + ctx->state[0] = ctx->state[0] + uVar22; + ctx->state[1] = uVar18 + uVar20 + (uVar23 >> 0xb | uVar23 * 0x200000); + ctx->state[2] = uVar20 + uVar17; + ctx->state[3] = uVar21 + uVar19; + return; +} + + + +void md5_clone_wrap(mbedtls_md5_context *dst,mbedtls_md5_context *src) + +{ + memcpy(dst,src,0x58); + return; +} + + + +void md5_ctx_free(void *ctx) + +{ + mbedtls_md5_free((mbedtls_md5_context *)ctx); + vPortFree(ctx); + return; +} + + + +void * md5_ctx_alloc(void) + +{ + mbedtls_md5_context *ctx; + + ctx = (mbedtls_md5_context *)mycalloc(1,0x58); + if (ctx != (mbedtls_md5_context *)0x0) { + mbedtls_md5_init(ctx); + } + return ctx; +} + + + +void md5_finish_wrap(mbedtls_md5_context *ctx,uchar *output) + +{ + uint uVar1; + int iVar2; + int iStack24; + uint uStack20; + + uVar1 = ctx->total[0]; + uStack20 = ctx->total[1] << 3 | uVar1 >> 0x1d; + iStack24 = uVar1 << 3; + if ((uVar1 & 0x3f) < 0x38) { + iVar2 = 0x38; + } + else { + iVar2 = 0x78; + } + mbedtls_md5_update(ctx,md5_padding,iVar2 - (uVar1 & 0x3f)); + mbedtls_md5_update(ctx,(uchar *)&iStack24,8); + *output = (uchar)ctx->state[0]; + output[1] = (uchar)(ctx->state[0] >> 8); + output[2] = (uchar)*(undefined2 *)((int)ctx->state + 2); + output[3] = *(uchar *)((int)ctx->state + 3); + output[4] = (uchar)ctx->state[1]; + output[5] = (uchar)(ctx->state[1] >> 8); + output[6] = (uchar)*(undefined2 *)((int)ctx->state + 6); + output[7] = *(uchar *)((int)ctx->state + 7); + output[8] = (uchar)ctx->state[2]; + output[9] = (uchar)(ctx->state[2] >> 8); + output[10] = (uchar)*(undefined2 *)((int)ctx->state + 10); + output[0xb] = *(uchar *)((int)ctx->state + 0xb); + output[0xc] = (uchar)ctx->state[3]; + output[0xd] = (uchar)(ctx->state[3] >> 8); + output[0xe] = (uchar)*(undefined2 *)((int)ctx->state + 0xe); + output[0xf] = *(uchar *)((int)ctx->state + 0xf); + return; +} + + + +void md5_update_wrap(mbedtls_md5_context *ctx,uchar *input,size_t ilen) + +{ + if (ilen != 0) { + mbedtls_md5_update(ctx,input,ilen); + return; + } + return; +} + + + +void md5_starts_wrap(mbedtls_md5_context *ctx) + +{ + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xefcdab89; + ctx->state[2] = 0x98badcfe; + ctx->total[0] = 0; + ctx->total[1] = 0; + ctx->state[3] = 0x10325476; + return; +} + + + +void sha1_process_wrap(mbedtls_sha1_context *ctx,uchar *data) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + uint uVar4; + uint uVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint uVar9; + uint uVar10; + uint uVar11; + uint32_t uVar12; + uint uVar13; + uint uVar14; + uint uVar15; + uint uVar16; + uint uVar17; + uint uVar18; + uint uVar19; + uint uVar20; + uint uVar21; + uint uVar22; + uint uVar23; + uint uVar24; + uint uVar25; + uint uVar26; + uint uVar27; + uint uVar28; + + uVar8 = (uint)*data << 0x18 | (uint)data[1] << 0x10 | (uint)data[3] | (uint)data[2] << 8; + uVar10 = (uint)data[4] << 0x18 | (uint)data[5] << 0x10 | (uint)data[7] | (uint)data[6] << 8; + uVar9 = (uint)data[8] << 0x18 | (uint)data[9] << 0x10 | (uint)data[0xb] | (uint)data[10] << 8; + uVar1 = (uint)data[0xc] << 0x18 | (uint)data[0xd] << 0x10 | (uint)data[0xf] | (uint)data[0xe] << 8 + ; + uVar27 = (uint)data[0x10] << 0x18 | (uint)data[0x11] << 0x10 | (uint)data[0x13] | + (uint)data[0x12] << 8; + uVar25 = (uint)data[0x14] << 0x18 | (uint)data[0x15] << 0x10 | (uint)data[0x17] | + (uint)data[0x16] << 8; + uVar14 = (uint)data[0x18] << 0x18 | (uint)data[0x19] << 0x10 | (uint)data[0x1b] | + (uint)data[0x1a] << 8; + uVar20 = (uint)data[0x1c] << 0x18 | (uint)data[0x1d] << 0x10 | (uint)data[0x1f] | + (uint)data[0x1e] << 8; + uVar28 = (uint)data[0x20] << 0x18 | (uint)data[0x21] << 0x10 | (uint)data[0x23] | + (uint)data[0x22] << 8; + uVar26 = (uint)data[0x24] << 0x18 | (uint)data[0x25] << 0x10 | (uint)data[0x27] | + (uint)data[0x26] << 8; + uVar2 = (uint)data[0x28] << 0x18 | (uint)data[0x29] << 0x10 | (uint)data[0x2b] | + (uint)data[0x2a] << 8; + uVar13 = (uint)data[0x2c] << 0x18 | (uint)data[0x2d] << 0x10 | (uint)data[0x2f] | + (uint)data[0x2e] << 8; + uVar11 = (uint)data[0x30] << 0x18 | (uint)data[0x31] << 0x10 | (uint)data[0x33] | + (uint)data[0x32] << 8; + uVar16 = ctx->state[2]; + uVar15 = ctx->state[0]; + uVar5 = (uint)data[0x34] << 0x18 | (uint)data[0x35] << 0x10 | (uint)data[0x37] | + (uint)data[0x36] << 8; + uVar4 = (uint)data[0x38] << 0x18 | (uint)data[0x39] << 0x10 | (uint)data[0x3b] | + (uint)data[0x3a] << 8; + uVar3 = (uint)data[0x3c] << 0x18 | (uint)data[0x3d] << 0x10 | (uint)data[0x3f] | + (uint)data[0x3e] << 8; + uVar6 = (uVar15 << 5 | uVar15 >> 0x1b) + ctx->state[4] + 0x5a827999 + + ((uVar16 ^ ctx->state[3]) & ctx->state[1] ^ ctx->state[3]) + uVar8; + uVar17 = ctx->state[1] << 0x1e | ctx->state[1] >> 2; + uVar18 = (uVar6 * 0x20 | uVar6 >> 0x1b) + + ((uVar16 ^ uVar17) & uVar15 ^ uVar16) + ctx->state[3] + 0x5a827999 + uVar10; + uVar23 = uVar15 << 0x1e | uVar15 >> 2; + uVar7 = uVar6 * 0x40000000 | uVar6 >> 2; + uVar6 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar17 ^ uVar23) & uVar6 ^ uVar17) + uVar16 + 0x5a827999 + uVar9; + uVar19 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar18 = (uVar6 * 0x20 | uVar6 >> 0x1b) + + ((uVar23 ^ uVar7) & uVar18 ^ uVar23) + uVar17 + 0x5a827999 + uVar1; + uVar21 = uVar6 * 0x40000000 | uVar6 >> 2; + uVar17 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar7 ^ uVar19) & uVar6 ^ uVar7) + uVar23 + 0x5a827999 + uVar27; + uVar23 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + ((uVar19 ^ uVar21) & uVar18 ^ uVar19) + uVar25 + 0x5a827999 + uVar7; + uVar6 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar7 = (uVar23 * 0x20 | uVar23 >> 0x1b) + + ((uVar21 ^ uVar6) & uVar17 ^ uVar21) + uVar14 + 0x5a827999 + uVar19; + uVar24 = uVar23 * 0x40000000 | uVar23 >> 2; + uVar19 = (uVar7 * 0x20 | uVar7 >> 0x1b) + + ((uVar6 ^ uVar18) & uVar23 ^ uVar6) + uVar21 + uVar20 + 0x5a827999; + uVar17 = uVar7 * 0x40000000 | uVar7 >> 2; + uVar7 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + ((uVar18 ^ uVar24) & uVar7 ^ uVar18) + uVar28 + 0x5a827999 + uVar6; + uVar23 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar6 = (uVar7 * 0x20 | uVar7 >> 0x1b) + + ((uVar24 ^ uVar17) & uVar19 ^ uVar24) + uVar18 + uVar26 + 0x5a827999; + uVar22 = uVar7 * 0x40000000 | uVar7 >> 2; + uVar19 = (uVar6 * 0x20 | uVar6 >> 0x1b) + + ((uVar17 ^ uVar23) & uVar7 ^ uVar17) + uVar2 + 0x5a827999 + uVar24; + uVar18 = uVar6 * 0x40000000 | uVar6 >> 2; + uVar7 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + ((uVar23 ^ uVar22) & uVar6 ^ uVar23) + uVar17 + uVar13 + 0x5a827999; + uVar21 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar6 = (uVar7 * 0x20 | uVar7 >> 0x1b) + + ((uVar22 ^ uVar18) & uVar19 ^ uVar22) + uVar11 + 0x5a827999 + uVar23; + uVar17 = uVar7 * 0x40000000 | uVar7 >> 2; + uVar19 = (uVar6 * 0x20 | uVar6 >> 0x1b) + + ((uVar18 ^ uVar21) & uVar7 ^ uVar18) + uVar22 + uVar5 + 0x5a827999; + uVar7 = uVar6 * 0x40000000 | uVar6 >> 2; + uVar23 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + ((uVar21 ^ uVar17) & uVar6 ^ uVar21) + uVar4 + 0x5a827999 + uVar18; + uVar22 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar6 = uVar8 ^ uVar9 ^ uVar28 ^ uVar5; + uVar18 = (uVar23 * 0x20 | uVar23 >> 0x1b) + + ((uVar17 ^ uVar7) & uVar19 ^ uVar17) + uVar21 + uVar3 + 0x5a827999; + uVar8 = uVar6 >> 0x1f | uVar6 << 1; + uVar6 = uVar10 ^ uVar1 ^ uVar26 ^ uVar4; + uVar19 = uVar23 * 0x40000000 | uVar23 >> 2; + uVar10 = uVar6 >> 0x1f | uVar6 << 1; + uVar17 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar7 ^ uVar22) & uVar23 ^ uVar7) + uVar8 + 0x5a827999 + uVar17; + uVar21 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar9 = uVar9 ^ uVar27 ^ uVar2 ^ uVar3; + uVar6 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + ((uVar22 ^ uVar19) & uVar18 ^ uVar22) + uVar7 + uVar10 + 0x5a827999; + uVar9 = uVar9 >> 0x1f | uVar9 << 1; + uVar1 = uVar1 ^ uVar25 ^ uVar13 ^ uVar8; + uVar23 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar1 = uVar1 >> 0x1f | uVar1 << 1; + uVar18 = (uVar6 * 0x20 | uVar6 >> 0x1b) + + ((uVar19 ^ uVar21) & uVar17 ^ uVar19) + uVar9 + 0x5a827999 + uVar22; + uVar17 = uVar27 ^ uVar14 ^ uVar11 ^ uVar10; + uVar7 = uVar6 * 0x40000000 | uVar6 >> 2; + uVar27 = uVar17 >> 0x1f | uVar17 << 1; + uVar17 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar21 ^ uVar23) & uVar6 ^ uVar21) + uVar1 + 0x5a827999 + uVar19; + uVar6 = uVar25 ^ uVar20 ^ uVar5 ^ uVar9; + uVar19 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar24 = uVar6 >> 0x1f | uVar6 << 1; + uVar21 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar23 ^ uVar7 ^ uVar18) + uVar21 + uVar27 + 0x6ed9eba1; + uVar6 = uVar14 ^ uVar28 ^ uVar4 ^ uVar1; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar17 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar7 ^ uVar19 ^ uVar17) + uVar24 + 0x6ed9eba1 + uVar23; + uVar14 = uVar6 >> 0x1f | uVar6 << 1; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar6 = uVar20 ^ uVar26 ^ uVar3 ^ uVar27; + uVar6 = uVar6 >> 0x1f | uVar6 << 1; + uVar21 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar19 ^ uVar18 ^ uVar21) + uVar14 + 0x6ed9eba1 + uVar7; + uVar7 = uVar28 ^ uVar2 ^ uVar8 ^ uVar24; + uVar20 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar28 = uVar7 >> 0x1f | uVar7 << 1; + uVar7 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar18 ^ uVar23 ^ uVar17) + uVar19 + uVar6 + 0x6ed9eba1; + uVar17 = uVar26 ^ uVar13 ^ uVar10 ^ uVar14; + uVar22 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar26 = uVar17 >> 0x1f | uVar17 << 1; + uVar17 = (uVar7 * 0x20 | uVar7 >> 0x1b) + + (uVar23 ^ uVar20 ^ uVar21) + uVar18 + uVar28 + 0x6ed9eba1; + uVar2 = uVar2 ^ uVar11 ^ uVar9 ^ uVar6; + uVar19 = uVar7 * 0x40000000 | uVar7 >> 2; + uVar21 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar20 ^ uVar22 ^ uVar7) + uVar23 + uVar26 + 0x6ed9eba1; + uVar2 = uVar2 >> 0x1f | uVar2 << 1; + uVar7 = uVar13 ^ uVar5 ^ uVar1 ^ uVar28; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar13 = uVar7 >> 0x1f | uVar7 << 1; + uVar20 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar22 ^ uVar19 ^ uVar17) + uVar2 + 0x6ed9eba1 + uVar20; + uVar7 = uVar11 ^ uVar4 ^ uVar27 ^ uVar26; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar11 = uVar7 >> 0x1f | uVar7 << 1; + uVar17 = (uVar20 * 0x20 | uVar20 >> 0x1b) + + (uVar19 ^ uVar18 ^ uVar21) + uVar13 + 0x6ed9eba1 + uVar22; + uVar5 = uVar5 ^ uVar3 ^ uVar24 ^ uVar2; + uVar22 = uVar20 * 0x40000000 | uVar20 >> 2; + uVar5 = uVar5 >> 0x1f | uVar5 << 1; + uVar7 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar18 ^ uVar23 ^ uVar20) + uVar19 + uVar11 + 0x6ed9eba1; + uVar4 = uVar4 ^ uVar8 ^ uVar14 ^ uVar13; + uVar20 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar4 = uVar4 >> 0x1f | uVar4 << 1; + uVar17 = (uVar7 * 0x20 | uVar7 >> 0x1b) + (uVar23 ^ uVar22 ^ uVar17) + uVar18 + uVar5 + 0x6ed9eba1 + ; + uVar3 = uVar3 ^ uVar10 ^ uVar6 ^ uVar11; + uVar19 = uVar7 * 0x40000000 | uVar7 >> 2; + uVar3 = uVar3 >> 0x1f | uVar3 << 1; + uVar21 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar22 ^ uVar20 ^ uVar7) + uVar23 + uVar4 + 0x6ed9eba1; + uVar7 = uVar8 ^ uVar9 ^ uVar28 ^ uVar5; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar17 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar20 ^ uVar19 ^ uVar17) + uVar3 + 0x6ed9eba1 + uVar22; + uVar7 = uVar7 >> 0x1f | uVar7 << 1; + uVar8 = uVar10 ^ uVar1 ^ uVar26 ^ uVar4; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar10 = uVar8 >> 0x1f | uVar8 << 1; + uVar21 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar19 ^ uVar18 ^ uVar21) + uVar7 + 0x6ed9eba1 + uVar20; + uVar8 = uVar9 ^ uVar27 ^ uVar2 ^ uVar3; + uVar20 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar8 = uVar8 >> 0x1f | uVar8 << 1; + uVar17 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar18 ^ uVar23 ^ uVar17) + uVar19 + uVar10 + 0x6ed9eba1; + uVar1 = uVar1 ^ uVar24 ^ uVar13 ^ uVar7; + uVar22 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar9 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar23 ^ uVar20 ^ uVar21) + uVar18 + uVar8 + 0x6ed9eba1; + uVar1 = uVar1 >> 0x1f | uVar1 << 1; + uVar19 = uVar27 ^ uVar14 ^ uVar11 ^ uVar10; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar21 = (uVar9 * 0x20 | uVar9 >> 0x1b) + (uVar20 ^ uVar22 ^ uVar17) + uVar1 + 0x6ed9eba1 + uVar23 + ; + uVar27 = uVar19 >> 0x1f | uVar19 << 1; + uVar19 = uVar24 ^ uVar6 ^ uVar5 ^ uVar8; + uVar17 = uVar9 * 0x40000000 | uVar9 >> 2; + uVar25 = uVar19 >> 0x1f | uVar19 << 1; + uVar19 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar22 ^ uVar18 ^ uVar9) + uVar27 + 0x6ed9eba1 + uVar20; + uVar9 = uVar14 ^ uVar28 ^ uVar4 ^ uVar1; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar14 = uVar9 >> 0x1f | uVar9 << 1; + uVar20 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar18 ^ uVar17 ^ uVar21) + uVar22 + uVar25 + 0x6ed9eba1; + uVar6 = uVar6 ^ uVar26 ^ uVar3 ^ uVar27; + uVar21 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar6 = uVar6 >> 0x1f | uVar6 << 1; + uVar9 = (uVar20 * 0x20 | uVar20 >> 0x1b) + + (uVar17 ^ uVar23 ^ uVar19) + uVar14 + 0x6ed9eba1 + uVar18; + uVar18 = uVar28 ^ uVar2 ^ uVar7 ^ uVar25; + uVar22 = uVar20 * 0x40000000 | uVar20 >> 2; + uVar28 = uVar18 >> 0x1f | uVar18 << 1; + uVar17 = (uVar9 * 0x20 | uVar9 >> 0x1b) + (uVar23 ^ uVar21 ^ uVar20) + uVar6 + 0x6ed9eba1 + uVar17 + ; + uVar19 = uVar9 * 0x40000000 | uVar9 >> 2; + uVar20 = uVar26 ^ uVar13 ^ uVar10 ^ uVar14; + uVar18 = ((uVar9 | uVar22) & uVar21 | uVar9 & uVar22) + + uVar28 + 0x8f1bbcdc + uVar23 + (uVar17 * 0x20 | uVar17 >> 0x1b); + uVar26 = uVar20 >> 0x1f | uVar20 << 1; + uVar2 = uVar2 ^ uVar11 ^ uVar8 ^ uVar6; + uVar23 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar2 = uVar2 >> 0x1f | uVar2 << 1; + uVar17 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar17 | uVar19) & uVar22 | uVar17 & uVar19) + uVar26 + 0x8f1bbcdc + uVar21; + uVar9 = uVar13 ^ uVar5 ^ uVar1 ^ uVar28; + uVar21 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar13 = uVar9 >> 0x1f | uVar9 << 1; + uVar20 = ((uVar18 | uVar23) & uVar19 | uVar18 & uVar23) + + uVar2 + 0x8f1bbcdc + uVar22 + (uVar17 * 0x20 | uVar17 >> 0x1b); + uVar9 = uVar11 ^ uVar4 ^ uVar27 ^ uVar26; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar11 = uVar9 >> 0x1f | uVar9 << 1; + uVar9 = (uVar20 * 0x20 | uVar20 >> 0x1b) + + ((uVar17 | uVar21) & uVar23 | uVar17 & uVar21) + uVar13 + 0x8f1bbcdc + uVar19; + uVar24 = uVar20 * 0x40000000 | uVar20 >> 2; + uVar5 = uVar5 ^ uVar3 ^ uVar25 ^ uVar2; + uVar19 = ((uVar20 | uVar18) & uVar21 | uVar20 & uVar18) + + uVar11 + 0x8f1bbcdc + uVar23 + (uVar9 * 0x20 | uVar9 >> 0x1b); + uVar5 = uVar5 >> 0x1f | uVar5 << 1; + uVar4 = uVar4 ^ uVar7 ^ uVar14 ^ uVar13; + uVar17 = uVar9 * 0x40000000 | uVar9 >> 2; + uVar4 = uVar4 >> 0x1f | uVar4 << 1; + uVar9 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + ((uVar9 | uVar24) & uVar18 | uVar9 & uVar24) + uVar5 + 0x8f1bbcdc + uVar21; + uVar3 = uVar3 ^ uVar10 ^ uVar6 ^ uVar11; + uVar22 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar3 = uVar3 >> 0x1f | uVar3 << 1; + uVar18 = ((uVar19 | uVar17) & uVar24 | uVar19 & uVar17) + + uVar4 + 0x8f1bbcdc + uVar18 + (uVar9 * 0x20 | uVar9 >> 0x1b); + uVar7 = uVar7 ^ uVar8 ^ uVar28 ^ uVar5; + uVar20 = uVar9 * 0x40000000 | uVar9 >> 2; + uVar7 = uVar7 >> 0x1f | uVar7 << 1; + uVar21 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar9 | uVar22) & uVar17 | uVar9 & uVar22) + uVar3 + 0x8f1bbcdc + uVar24; + uVar9 = uVar10 ^ uVar1 ^ uVar26 ^ uVar4; + uVar19 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar9 = uVar9 >> 0x1f | uVar9 << 1; + uVar10 = ((uVar18 | uVar20) & uVar22 | uVar18 & uVar20) + + uVar7 + 0x8f1bbcdc + uVar17 + (uVar21 * 0x20 | uVar21 >> 0x1b); + uVar8 = uVar8 ^ uVar27 ^ uVar2 ^ uVar3; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar8 = uVar8 >> 0x1f | uVar8 << 1; + uVar18 = (uVar10 * 0x20 | uVar10 >> 0x1b) + + ((uVar21 | uVar19) & uVar20 | uVar21 & uVar19) + uVar9 + 0x8f1bbcdc + uVar22; + uVar1 = uVar1 ^ uVar25 ^ uVar13 ^ uVar7; + uVar17 = uVar10 * 0x40000000 | uVar10 >> 2; + uVar1 = uVar1 >> 0x1f | uVar1 << 1; + uVar10 = ((uVar10 | uVar23) & uVar19 | uVar10 & uVar23) + + uVar8 + 0x8f1bbcdc + uVar20 + (uVar18 * 0x20 | uVar18 >> 0x1b); + uVar21 = uVar27 ^ uVar14 ^ uVar11 ^ uVar9; + uVar22 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar27 = uVar21 >> 0x1f | uVar21 << 1; + uVar18 = (uVar10 * 0x20 | uVar10 >> 0x1b) + + ((uVar18 | uVar17) & uVar23 | uVar18 & uVar17) + uVar19 + uVar1 + 0x8f1bbcdc; + uVar19 = uVar25 ^ uVar6 ^ uVar5 ^ uVar8; + uVar20 = uVar10 * 0x40000000 | uVar10 >> 2; + uVar24 = uVar19 >> 0x1f | uVar19 << 1; + uVar21 = ((uVar10 | uVar22) & uVar17 | uVar10 & uVar22) + + uVar27 + 0x8f1bbcdc + uVar23 + (uVar18 * 0x20 | uVar18 >> 0x1b); + uVar10 = uVar14 ^ uVar28 ^ uVar4 ^ uVar1; + uVar19 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar14 = uVar10 >> 0x1f | uVar10 << 1; + uVar10 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + ((uVar18 | uVar20) & uVar22 | uVar18 & uVar20) + uVar17 + uVar24 + 0x8f1bbcdc; + uVar6 = uVar6 ^ uVar26 ^ uVar3 ^ uVar27; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar6 = uVar6 >> 0x1f | uVar6 << 1; + uVar18 = ((uVar21 | uVar19) & uVar20 | uVar21 & uVar19) + + uVar14 + 0x8f1bbcdc + uVar22 + (uVar10 * 0x20 | uVar10 >> 0x1b); + uVar21 = uVar28 ^ uVar2 ^ uVar7 ^ uVar24; + uVar17 = uVar10 * 0x40000000 | uVar10 >> 2; + uVar28 = uVar21 >> 0x1f | uVar21 << 1; + uVar10 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar10 | uVar23) & uVar19 | uVar10 & uVar23) + uVar20 + uVar6 + 0x8f1bbcdc; + uVar21 = uVar26 ^ uVar13 ^ uVar9 ^ uVar14; + uVar22 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar25 = uVar21 >> 0x1f | uVar21 << 1; + uVar18 = ((uVar18 | uVar17) & uVar23 | uVar18 & uVar17) + + uVar28 + 0x8f1bbcdc + uVar19 + (uVar10 * 0x20 | uVar10 >> 0x1b); + uVar2 = uVar2 ^ uVar11 ^ uVar8 ^ uVar6; + uVar20 = uVar10 * 0x40000000 | uVar10 >> 2; + uVar2 = uVar2 >> 0x1f | uVar2 << 1; + uVar21 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar10 | uVar22) & uVar17 | uVar10 & uVar22) + uVar23 + uVar25 + 0x8f1bbcdc; + uVar10 = uVar13 ^ uVar5 ^ uVar1 ^ uVar28; + uVar19 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar13 = uVar10 >> 0x1f | uVar10 << 1; + uVar17 = ((uVar18 | uVar20) & uVar22 | uVar18 & uVar20) + + uVar2 + 0x8f1bbcdc + uVar17 + (uVar21 * 0x20 | uVar21 >> 0x1b); + uVar10 = uVar11 ^ uVar4 ^ uVar27 ^ uVar25; + uVar18 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar10 = uVar10 >> 0x1f | uVar10 << 1; + uVar23 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + ((uVar21 | uVar19) & uVar20 | uVar21 & uVar19) + uVar22 + uVar13 + 0x8f1bbcdc; + uVar5 = uVar5 ^ uVar3 ^ uVar24 ^ uVar2; + uVar11 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar5 = uVar5 >> 0x1f | uVar5 << 1; + uVar21 = (uVar23 * 0x20 | uVar23 >> 0x1b) + + (uVar19 ^ uVar18 ^ uVar17) + uVar20 + uVar10 + 0xca62c1d6; + uVar4 = uVar4 ^ uVar7 ^ uVar14 ^ uVar13; + uVar20 = uVar23 * 0x40000000 | uVar23 >> 2; + uVar4 = uVar4 >> 0x1f | uVar4 << 1; + uVar17 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar18 ^ uVar11 ^ uVar23) + uVar19 + uVar5 + 0xca62c1d6; + uVar3 = uVar3 ^ uVar9 ^ uVar6 ^ uVar10; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar3 = uVar3 >> 0x1f | uVar3 << 1; + uVar19 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar11 ^ uVar20 ^ uVar21) + uVar18 + uVar4 + 0xca62c1d6; + uVar7 = uVar7 ^ uVar8 ^ uVar28 ^ uVar5; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar7 = uVar7 >> 0x1f | uVar7 << 1; + uVar11 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar20 ^ uVar23 ^ uVar17) + uVar11 + uVar3 + 0xca62c1d6; + uVar9 = uVar9 ^ uVar1 ^ uVar25 ^ uVar4; + uVar21 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar9 = uVar9 >> 0x1f | uVar9 << 1; + uVar20 = (uVar11 * 0x20 | uVar11 >> 0x1b) + + (uVar23 ^ uVar18 ^ uVar19) + uVar20 + uVar7 + 0xca62c1d6; + uVar8 = uVar8 ^ uVar27 ^ uVar2 ^ uVar3; + uVar17 = uVar11 * 0x40000000 | uVar11 >> 2; + uVar8 = uVar8 >> 0x1f | uVar8 << 1; + uVar19 = (uVar20 * 0x20 | uVar20 >> 0x1b) + + (uVar18 ^ uVar21 ^ uVar11) + uVar23 + uVar9 + 0xca62c1d6; + uVar1 = uVar1 ^ uVar24 ^ uVar13 ^ uVar7; + uVar22 = uVar20 * 0x40000000 | uVar20 >> 2; + uVar1 = uVar1 >> 0x1f | uVar1 << 1; + uVar11 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar21 ^ uVar17 ^ uVar20) + uVar18 + uVar8 + 0xca62c1d6; + uVar18 = uVar27 ^ uVar14 ^ uVar10 ^ uVar9; + uVar23 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar26 = uVar18 >> 0x1f | uVar18 << 1; + uVar19 = (uVar11 * 0x20 | uVar11 >> 0x1b) + + (uVar17 ^ uVar22 ^ uVar19) + uVar21 + uVar1 + 0xca62c1d6; + uVar21 = uVar24 ^ uVar6 ^ uVar5 ^ uVar8; + uVar18 = uVar11 * 0x40000000 | uVar11 >> 2; + uVar24 = uVar21 >> 0x1f | uVar21 << 1; + uVar17 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar22 ^ uVar23 ^ uVar11) + uVar17 + uVar26 + 0xca62c1d6; + uVar11 = uVar14 ^ uVar28 ^ uVar4 ^ uVar1; + uVar21 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar11 = uVar11 >> 0x1f | uVar11 << 1; + uVar20 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar23 ^ uVar18 ^ uVar19) + uVar22 + uVar24 + 0xca62c1d6; + uVar6 = uVar6 ^ uVar25 ^ uVar3 ^ uVar26; + uVar14 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar6 = uVar6 >> 0x1f | uVar6 << 1; + uVar19 = (uVar20 * 0x20 | uVar20 >> 0x1b) + + (uVar18 ^ uVar21 ^ uVar17) + uVar23 + uVar11 + 0xca62c1d6; + uVar17 = uVar28 ^ uVar2 ^ uVar7 ^ uVar24; + uVar22 = uVar20 * 0x40000000 | uVar20 >> 2; + uVar27 = uVar17 >> 0x1f | uVar17 << 1; + uVar17 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar21 ^ uVar14 ^ uVar20) + uVar18 + uVar6 + 0xca62c1d6; + uVar18 = uVar25 ^ uVar13 ^ uVar9 ^ uVar11; + uVar23 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar20 = uVar18 >> 0x1f | uVar18 << 1; + uVar19 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar14 ^ uVar22 ^ uVar19) + uVar21 + uVar27 + 0xca62c1d6; + uVar2 = uVar2 ^ uVar10 ^ uVar8 ^ uVar6; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar2 = uVar2 >> 0x1f | uVar2 << 1; + uVar8 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar22 ^ uVar23 ^ uVar17) + uVar14 + uVar20 + 0xca62c1d6; + uVar27 = uVar13 ^ uVar5 ^ uVar1 ^ uVar27; + uVar13 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar21 = uVar27 >> 0x1f | uVar27 << 1; + uVar14 = uVar22 + uVar2 + 0xca62c1d6 + (uVar23 ^ uVar18 ^ uVar19) + (uVar8 * 0x20 | uVar8 >> 0x1b) + ; + uVar20 = uVar10 ^ uVar4 ^ uVar26 ^ uVar20; + uVar10 = (uVar14 * 0x20 | uVar14 >> 0x1b) + + (uVar18 ^ uVar13 ^ uVar8) + uVar23 + uVar21 + 0xca62c1d6; + uVar1 = uVar8 * 0x40000000 | uVar8 >> 2; + uVar17 = uVar20 >> 0x1f | uVar20 << 1; + uVar2 = uVar5 ^ uVar3 ^ uVar24 ^ uVar2; + uVar5 = uVar18 + uVar17 + 0xca62c1d6 + (uVar13 ^ uVar1 ^ uVar14) + + (uVar10 * 0x20 | uVar10 >> 0x1b); + uVar8 = uVar14 * 0x40000000 | uVar14 >> 2; + uVar21 = uVar4 ^ uVar7 ^ uVar11 ^ uVar21; + uVar4 = uVar13 + (uVar2 << 1 | uVar2 >> 0x1f) + 0xca62c1d6 + (uVar1 ^ uVar8 ^ uVar10) + + (uVar5 * 0x20 | uVar5 >> 0x1b); + uVar7 = uVar10 * 0x40000000 | uVar10 >> 2; + uVar17 = uVar3 ^ uVar9 ^ uVar6 ^ uVar17; + uVar1 = uVar1 + (uVar21 << 1 | uVar21 >> 0x1f) + 0xca62c1d6 + (uVar8 ^ uVar7 ^ uVar5) + + (uVar4 * 0x20 | uVar4 >> 0x1b); + uVar2 = uVar5 * 0x40000000 | uVar5 >> 2; + uVar12 = ctx->state[1]; + ctx->state[0] = + uVar8 + (uVar17 << 1 | uVar17 >> 0x1f) + uVar15 + 0xca62c1d6 + (uVar7 ^ uVar2 ^ uVar4) + + (uVar1 * 0x20 | uVar1 >> 0x1b); + ctx->state[1] = uVar1 + uVar12; + ctx->state[2] = uVar16 + (uVar4 >> 2 | uVar4 * 0x40000000); + ctx->state[3] = uVar2 + ctx->state[3]; + ctx->state[4] = uVar7 + ctx->state[4]; + return; +} + + + +void sha1_clone_wrap(mbedtls_sha1_context *dst,mbedtls_sha1_context *src) + +{ + memcpy(dst,src,0x5c); + return; +} + + + +void sha1_ctx_free(void *ctx) + +{ + mbedtls_sha1_free((mbedtls_sha1_context *)ctx); + vPortFree(ctx); + return; +} + + + +void * sha1_ctx_alloc(void) + +{ + mbedtls_sha1_context *ctx; + + ctx = (mbedtls_sha1_context *)mycalloc(1,0x5c); + if (ctx != (mbedtls_sha1_context *)0x0) { + mbedtls_sha1_init(ctx); + } + return ctx; +} + + + +void sha1_finish_wrap(mbedtls_sha1_context *ctx,uchar *output) + +{ + uint uVar1; + uint uVar2; + int iVar3; + uchar uStack24; + undefined uStack23; + ushort uStack22; + undefined uStack20; + undefined uStack19; + ushort uStack18; + + uVar1 = ctx->total[0]; + uVar2 = ctx->total[1] << 3; + uStack24 = (uchar)(uVar2 >> 0x18); + uStack23 = (undefined)(uVar2 >> 0x10); + uStack22 = (ushort)(uVar2 >> 8) & 0xff | (ushort)((uVar2 | uVar1 >> 0x1d) << 8); + uStack20 = (undefined)((uVar1 << 3) >> 0x18); + uStack19 = (undefined)((uVar1 << 3) >> 0x10); + uStack18 = (ushort)((uVar1 << 0x13) >> 0x18) | (ushort)(uVar1 << 0xb); + if ((uVar1 & 0x3f) < 0x38) { + iVar3 = 0x38; + } + else { + iVar3 = 0x78; + } + mbedtls_sha1_update(ctx,sha1_padding,iVar3 - (uVar1 & 0x3f)); + mbedtls_sha1_update(ctx,&uStack24,8); + *output = *(uchar *)((int)ctx->state + 3); + output[1] = (uchar)*(undefined2 *)((int)ctx->state + 2); + output[2] = (uchar)(ctx->state[0] >> 8); + output[3] = (uchar)ctx->state[0]; + output[4] = *(uchar *)((int)ctx->state + 7); + output[5] = (uchar)*(undefined2 *)((int)ctx->state + 6); + output[6] = (uchar)(ctx->state[1] >> 8); + output[7] = (uchar)ctx->state[1]; + output[8] = *(uchar *)((int)ctx->state + 0xb); + output[9] = (uchar)*(undefined2 *)((int)ctx->state + 10); + output[10] = (uchar)(ctx->state[2] >> 8); + output[0xb] = (uchar)ctx->state[2]; + output[0xc] = *(uchar *)((int)ctx->state + 0xf); + output[0xd] = (uchar)*(undefined2 *)((int)ctx->state + 0xe); + output[0xe] = (uchar)(ctx->state[3] >> 8); + output[0xf] = (uchar)ctx->state[3]; + output[0x10] = *(uchar *)((int)ctx->state + 0x13); + output[0x11] = (uchar)*(undefined2 *)((int)ctx->state + 0x12); + output[0x12] = (uchar)(ctx->state[4] >> 8); + output[0x13] = (uchar)ctx->state[4]; + return; +} + + + +void sha1_update_wrap(mbedtls_sha1_context *ctx,uchar *input,size_t ilen) + +{ + if (ilen != 0) { + mbedtls_sha1_update(ctx,input,ilen); + return; + } + return; +} + + + +void sha1_starts_wrap(mbedtls_sha1_context *ctx) + +{ + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xefcdab89; + ctx->state[2] = 0x98badcfe; + ctx->state[3] = 0x10325476; + ctx->total[0] = 0; + ctx->total[1] = 0; + ctx->state[4] = 0xc3d2e1f0; + return; +} + + + +void sha224_process_wrap(mbedtls_sha256_context *ctx,uchar *data) + +{ + uint uVar1; + uint32_t *puVar2; + byte *pbVar3; + byte *pbVar4; + uint uVar5; + uint uVar6; + uint32_t uVar7; + uint uVar8; + uint32_t *puVar9; + uint *puVar10; + uint uVar11; + uint uVar12; + int iVar13; + uint uVar14; + uint uVar15; + uint uVar16; + uint uVar17; + uint32_t *puVar18; + uint uVar19; + uint uVar20; + uint uVar21; + uint *puVar22; + uint32_t *puVar23; + uint uVar24; + uint uVar25; + uint32_t uStack336; + uint uStack332; + uint uStack328; + uint uStack324; + uint uStack320; + uint uStack316; + uint uStack312; + uint uStack308; + uint auStack304 [67]; + + puVar18 = &uStack336; + puVar9 = &uStack336; + puVar2 = ctx->state; + do { + uVar7 = *puVar2; + puVar2 = puVar2 + 1; + *puVar9 = uVar7; + puVar9 = puVar9 + 1; + } while ((uint32_t *)ctx->buffer != puVar2); + puVar22 = auStack304; + pbVar3 = data; + puVar10 = puVar22; + do { + pbVar4 = pbVar3 + 4; + *puVar10 = (uint)*pbVar3 << 0x18 | (uint)pbVar3[1] << 0x10 | (uint)pbVar3[3] | + (uint)pbVar3[2] << 8; + pbVar3 = pbVar4; + puVar10 = puVar10 + 1; + } while (data + 0x40 != pbVar4); + puVar2 = K; + puVar9 = K; + puVar10 = puVar22; + do { + puVar23 = puVar9 + 8; + iVar13 = uStack308 + + ((uStack320 >> 6 | uStack320 << 0x1a) ^ (uStack320 >> 0xb | uStack320 << 0x15) ^ + (uStack320 << 7 | uStack320 >> 0x19)) + *puVar9 + *puVar10 + + ((uStack312 ^ uStack316) & uStack320 ^ uStack312); + uVar12 = uStack324 + iVar13; + uVar14 = iVar13 + ((uStack336 >> 2 | uStack336 << 0x1e) ^ (uStack336 >> 0xd | uStack336 << 0x13) + ^ (uStack336 << 10 | uStack336 >> 0x16)) + + ((uStack336 | uStack332) & uStack328 | uStack336 & uStack332); + iVar13 = ((uVar12 >> 6 | uVar12 * 0x4000000) ^ (uVar12 >> 0xb | uVar12 * 0x200000) ^ + (uVar12 * 0x80 | uVar12 >> 0x19)) + + uStack312 + puVar9[1] + puVar10[1] + ((uStack320 ^ uStack316) & uVar12 ^ uStack316); + uVar1 = ((uVar14 >> 2 | uVar14 * 0x40000000) ^ (uVar14 >> 0xd | uVar14 * 0x80000) ^ + (uVar14 * 0x400 | uVar14 >> 0x16)) + + ((uVar14 | uStack336) & uStack332 | uVar14 & uStack336) + iVar13; + uVar11 = uStack328 + iVar13; + iVar13 = ((uVar11 >> 6 | uVar11 * 0x4000000) ^ (uVar11 >> 0xb | uVar11 * 0x200000) ^ + (uVar11 * 0x80 | uVar11 >> 0x19)) + + uStack316 + puVar9[2] + puVar10[2] + ((uVar12 ^ uStack320) & uVar11 ^ uStack320); + uVar5 = ((uVar1 >> 2 | uVar1 * 0x40000000) ^ (uVar1 >> 0xd | uVar1 * 0x80000) ^ + (uVar1 * 0x400 | uVar1 >> 0x16)) + ((uVar14 | uVar1) & uStack336 | uVar14 & uVar1) + + iVar13; + uVar8 = uStack332 + iVar13; + iVar13 = ((uVar8 >> 6 | uVar8 * 0x4000000) ^ (uVar8 >> 0xb | uVar8 * 0x200000) ^ + (uVar8 * 0x80 | uVar8 >> 0x19)) + + uStack320 + puVar9[3] + puVar10[3] + ((uVar12 ^ uVar11) & uVar8 ^ uVar12); + uVar16 = ((uVar5 >> 2 | uVar5 * 0x40000000) ^ (uVar5 >> 0xd | uVar5 * 0x80000) ^ + (uVar5 * 0x400 | uVar5 >> 0x16)) + ((uVar1 | uVar5) & uVar14 | uVar1 & uVar5) + iVar13; + uVar6 = uStack336 + iVar13; + iVar13 = ((uVar6 >> 6 | uVar6 * 0x4000000) ^ (uVar6 >> 0xb | uVar6 * 0x200000) ^ + (uVar6 * 0x80 | uVar6 >> 0x19)) + + uVar12 + puVar9[4] + puVar10[4] + ((uVar11 ^ uVar8) & uVar6 ^ uVar11); + uStack324 = ((uVar16 >> 2 | uVar16 * 0x40000000) ^ (uVar16 >> 0xd | uVar16 * 0x80000) ^ + (uVar16 * 0x400 | uVar16 >> 0x16)) + ((uVar5 | uVar16) & uVar1 | uVar5 & uVar16) + + iVar13; + uStack308 = uVar14 + iVar13; + iVar13 = ((uStack308 >> 6 | uStack308 * 0x4000000) ^ (uStack308 >> 0xb | uStack308 * 0x200000) ^ + (uStack308 * 0x80 | uStack308 >> 0x19)) + + uVar11 + puVar9[5] + puVar10[5] + ((uVar8 ^ uVar6) & uStack308 ^ uVar8); + uStack328 = ((uStack324 >> 2 | uStack324 * 0x40000000) ^ + (uStack324 >> 0xd | uStack324 * 0x80000) ^ (uStack324 * 0x400 | uStack324 >> 0x16)) + + ((uVar16 | uStack324) & uVar5 | uVar16 & uStack324) + iVar13; + uStack312 = uVar1 + iVar13; + iVar13 = ((uStack312 >> 6 | uStack312 * 0x4000000) ^ (uStack312 >> 0xb | uStack312 * 0x200000) ^ + (uStack312 * 0x80 | uStack312 >> 0x19)) + + uVar8 + puVar9[6] + puVar10[6] + ((uVar6 ^ uStack308) & uStack312 ^ uVar6); + uStack332 = ((uStack328 >> 2 | uStack328 * 0x40000000) ^ + (uStack328 >> 0xd | uStack328 * 0x80000) ^ (uStack328 * 0x400 | uStack328 >> 0x16)) + + ((uStack324 | uStack328) & uVar16 | uStack324 & uStack328) + iVar13; + uStack316 = uVar5 + iVar13; + iVar13 = ((uStack316 >> 6 | uStack316 * 0x4000000) ^ (uStack316 >> 0xb | uStack316 * 0x200000) ^ + (uStack316 * 0x80 | uStack316 >> 0x19)) + + uVar6 + puVar9[7] + puVar10[7] + ((uStack308 ^ uStack312) & uStack316 ^ uStack308); + uStack320 = uVar16 + iVar13; + uStack336 = ((uStack332 >> 2 | uStack332 * 0x40000000) ^ + (uStack332 >> 0xd | uStack332 * 0x80000) ^ (uStack332 * 0x400 | uStack332 >> 0x16)) + + ((uStack328 | uStack332) & uStack324 | uStack328 & uStack332) + iVar13; + puVar9 = puVar23; + puVar10 = puVar10 + 8; + } while (puVar23 != K + 0x10); + do { + uVar19 = puVar22[0xe]; + uVar1 = puVar22[1]; + uVar20 = puVar22[0xf]; + uVar24 = ((uVar19 << 0xf | uVar19 >> 0x11) ^ (uVar19 << 0xd | uVar19 >> 0x13) ^ uVar19 >> 10) + + puVar22[9] + *puVar22 + + ((uVar1 >> 7 | uVar1 << 0x19) ^ (uVar1 << 0xe | uVar1 >> 0x12) ^ uVar1 >> 3); + uVar11 = puVar22[3]; + iVar13 = uStack308 + + ((uStack320 >> 6 | uStack320 << 0x1a) ^ (uStack320 >> 0xb | uStack320 << 0x15) ^ + (uStack320 << 7 | uStack320 >> 0x19)) + + ((uStack312 ^ uStack316) & uStack320 ^ uStack312) + puVar2[0x10] + uVar24; + uVar16 = uStack324 + iVar13; + uVar15 = iVar13 + ((uStack336 >> 2 | uStack336 << 0x1e) ^ (uStack336 >> 0xd | uStack336 << 0x13) + ^ (uStack336 << 10 | uStack336 >> 0x16)) + + ((uStack336 | uStack332) & uStack328 | uStack336 & uStack332); + uVar6 = puVar22[2]; + uVar1 = ((uVar20 << 0xf | uVar20 >> 0x11) ^ (uVar20 << 0xd | uVar20 >> 0x13) ^ uVar20 >> 10) + + uVar1 + puVar22[10] + + ((uVar6 >> 7 | uVar6 << 0x19) ^ (uVar6 << 0xe | uVar6 >> 0x12) ^ uVar6 >> 3); + iVar13 = ((uStack320 ^ uStack316) & uVar16 ^ uStack316) + uStack312 + puVar2[0x11] + uVar1 + + ((uVar16 >> 6 | uVar16 * 0x4000000) ^ (uVar16 >> 0xb | uVar16 * 0x200000) ^ + (uVar16 * 0x80 | uVar16 >> 0x19)); + uVar5 = ((uVar15 >> 2 | uVar15 * 0x40000000) ^ (uVar15 >> 0xd | uVar15 * 0x80000) ^ + (uVar15 * 0x400 | uVar15 >> 0x16)) + + ((uStack336 | uVar15) & uStack332 | uStack336 & uVar15) + iVar13; + uVar14 = uStack328 + iVar13; + uVar6 = ((uVar24 * 0x8000 | uVar24 >> 0x11) ^ (uVar24 * 0x2000 | uVar24 >> 0x13) ^ uVar24 >> 10) + + uVar6 + puVar22[0xb] + + ((uVar11 >> 7 | uVar11 << 0x19) ^ (uVar11 << 0xe | uVar11 >> 0x12) ^ uVar11 >> 3); + iVar13 = ((uStack320 ^ uVar16) & uVar14 ^ uStack320) + uStack316 + puVar2[0x12] + uVar6 + + ((uVar14 >> 6 | uVar14 * 0x4000000) ^ (uVar14 >> 0xb | uVar14 * 0x200000) ^ + (uVar14 * 0x80 | uVar14 >> 0x19)); + puVar22[0x11] = uVar1; + uVar8 = ((uVar5 >> 2 | uVar5 * 0x40000000) ^ (uVar5 >> 0xd | uVar5 * 0x80000) ^ + (uVar5 * 0x400 | uVar5 >> 0x16)) + ((uVar15 | uVar5) & uStack336 | uVar15 & uVar5) + + iVar13; + uVar12 = uStack332 + iVar13; + uVar25 = puVar22[4]; + uVar1 = ((uVar1 * 0x8000 | uVar1 >> 0x11) ^ (uVar1 * 0x2000 | uVar1 >> 0x13) ^ uVar1 >> 10) + + uVar11 + puVar22[0xc] + + ((uVar25 >> 7 | uVar25 << 0x19) ^ (uVar25 << 0xe | uVar25 >> 0x12) ^ uVar25 >> 3); + iVar13 = ((uVar16 ^ uVar14) & uVar12 ^ uVar16) + uStack320 + puVar2[0x13] + uVar1 + + ((uVar12 >> 6 | uVar12 * 0x4000000) ^ (uVar12 >> 0xb | uVar12 * 0x200000) ^ + (uVar12 * 0x80 | uVar12 >> 0x19)); + uVar17 = ((uVar8 >> 2 | uVar8 * 0x40000000) ^ (uVar8 >> 0xd | uVar8 * 0x80000) ^ + (uVar8 * 0x400 | uVar8 >> 0x16)) + ((uVar5 | uVar8) & uVar15 | uVar5 & uVar8) + iVar13; + uVar11 = uStack336 + iVar13; + puVar22[0x12] = uVar6; + uVar21 = puVar22[5]; + uVar25 = ((uVar6 * 0x8000 | uVar6 >> 0x11) ^ (uVar6 * 0x2000 | uVar6 >> 0x13) ^ uVar6 >> 10) + + uVar25 + puVar22[0xd] + + ((uVar21 >> 7 | uVar21 << 0x19) ^ (uVar21 << 0xe | uVar21 >> 0x12) ^ uVar21 >> 3); + iVar13 = ((uVar11 >> 6 | uVar11 * 0x4000000) ^ (uVar11 >> 0xb | uVar11 * 0x200000) ^ + (uVar11 * 0x80 | uVar11 >> 0x19)) + + ((uVar14 ^ uVar12) & uVar11 ^ uVar14) + uVar16 + puVar2[0x14] + uVar25; + uStack324 = ((uVar17 >> 2 | uVar17 * 0x40000000) ^ (uVar17 >> 0xd | uVar17 * 0x80000) ^ + (uVar17 * 0x400 | uVar17 >> 0x16)) + ((uVar8 | uVar17) & uVar5 | uVar8 & uVar17) + + iVar13; + uStack308 = uVar15 + iVar13; + uVar6 = puVar22[6]; + puVar22[0x13] = uVar1; + uVar16 = ((uVar1 * 0x8000 | uVar1 >> 0x11) ^ (uVar1 * 0x2000 | uVar1 >> 0x13) ^ uVar1 >> 10) + + uVar19 + uVar21 + + ((uVar6 >> 7 | uVar6 << 0x19) ^ (uVar6 << 0xe | uVar6 >> 0x12) ^ uVar6 >> 3); + iVar13 = ((uStack308 >> 6 | uStack308 * 0x4000000) ^ (uStack308 >> 0xb | uStack308 * 0x200000) ^ + (uStack308 * 0x80 | uStack308 >> 0x19)) + + ((uVar12 ^ uVar11) & uStack308 ^ uVar12) + uVar14 + puVar2[0x15] + uVar16; + uStack328 = ((uStack324 >> 2 | uStack324 * 0x40000000) ^ + (uStack324 >> 0xd | uStack324 * 0x80000) ^ (uStack324 * 0x400 | uStack324 >> 0x16)) + + ((uVar17 | uStack324) & uVar8 | uVar17 & uStack324) + iVar13; + uStack312 = uVar5 + iVar13; + uVar1 = puVar22[7]; + puVar22[0x14] = uVar25; + uVar6 = uVar20 + uVar6 + + ((uVar25 * 0x8000 | uVar25 >> 0x11) ^ (uVar25 * 0x2000 | uVar25 >> 0x13) ^ uVar25 >> 10) + + ((uVar1 >> 7 | uVar1 << 0x19) ^ (uVar1 << 0xe | uVar1 >> 0x12) ^ uVar1 >> 3); + iVar13 = ((uStack312 >> 6 | uStack312 * 0x4000000) ^ (uStack312 >> 0xb | uStack312 * 0x200000) ^ + (uStack312 * 0x80 | uStack312 >> 0x19)) + + ((uVar11 ^ uStack308) & uStack312 ^ uVar11) + uVar12 + puVar2[0x16] + uVar6; + uStack332 = ((uStack328 >> 2 | uStack328 * 0x40000000) ^ + (uStack328 >> 0xd | uStack328 * 0x80000) ^ (uStack328 * 0x400 | uStack328 >> 0x16)) + + ((uStack324 | uStack328) & uVar17 | uStack324 & uStack328) + iVar13; + uStack316 = uVar8 + iVar13; + uVar5 = puVar22[8]; + puVar22[0x15] = uVar16; + puVar22[0x10] = uVar24; + uVar7 = puVar2[0x17]; + uVar1 = uVar24 + uVar1 + + ((uVar16 * 0x8000 | uVar16 >> 0x11) ^ (uVar16 * 0x2000 | uVar16 >> 0x13) ^ uVar16 >> 10) + + ((uVar5 >> 7 | uVar5 << 0x19) ^ (uVar5 << 0xe | uVar5 >> 0x12) ^ uVar5 >> 3); + puVar22[0x17] = uVar1; + iVar13 = ((uStack316 >> 6 | uStack316 * 0x4000000) ^ (uStack316 >> 0xb | uStack316 * 0x200000) ^ + (uStack316 * 0x80 | uStack316 >> 0x19)) + + uVar11 + uVar7 + uVar1 + ((uStack308 ^ uStack312) & uStack316 ^ uStack308); + puVar22[0x16] = uVar6; + puVar22 = puVar22 + 8; + uStack320 = uVar17 + iVar13; + uStack336 = ((uStack332 >> 2 | uStack332 * 0x40000000) ^ + (uStack332 >> 0xd | uStack332 * 0x80000) ^ (uStack332 * 0x400 | uStack332 >> 0x16)) + + ((uStack328 | uStack332) & uStack324 | uStack328 & uStack332) + iVar13; + puVar2 = puVar2 + 8; + } while (auStack304 + 0x30 != puVar22); + puVar9 = ctx->state; + do { + iVar13 = *puVar18; + puVar2 = puVar9 + 1; + puVar18 = (uint32_t *)((int *)puVar18 + 1); + *puVar9 = *puVar9 + iVar13; + puVar9 = puVar2; + } while ((uint32_t *)ctx->buffer != puVar2); + return; +} + + + +void sha224_clone_wrap(mbedtls_sha256_context *dst,mbedtls_sha256_context *src) + +{ + memcpy(dst,src,0x74); + return; +} + + + +void sha224_ctx_free(void *ctx) + +{ + mbedtls_sha256_free((mbedtls_sha256_context *)ctx); + vPortFree(ctx); + return; +} + + + +void * sha224_ctx_alloc(void) + +{ + mbedtls_sha256_context *ctx; + + ctx = (mbedtls_sha256_context *)mycalloc(1,0x74); + if (ctx != (mbedtls_sha256_context *)0x0) { + mbedtls_sha256_init(ctx); + } + return ctx; +} + + + +void sha224_wrap(uchar *input,size_t ilen,uchar *output) + +{ + mbedtls_sha256(input,ilen,output,1); + return; +} + + + +void sha256_wrap(uchar *input,size_t ilen,uchar *output) + +{ + mbedtls_sha256(input,ilen,output,0); + return; +} + + + +void sha224_finish_wrap(mbedtls_sha256_context *ctx,uchar *output) + +{ + uint uVar1; + uint uVar2; + int iVar3; + uchar uStack24; + undefined uStack23; + ushort uStack22; + undefined uStack20; + undefined uStack19; + ushort uStack18; + + uVar1 = ctx->total[0]; + uVar2 = ctx->total[1] << 3; + uStack24 = (uchar)(uVar2 >> 0x18); + uStack23 = (undefined)(uVar2 >> 0x10); + uStack22 = (ushort)(uVar2 >> 8) & 0xff | (ushort)((uVar2 | uVar1 >> 0x1d) << 8); + uStack20 = (undefined)((uVar1 << 3) >> 0x18); + uStack19 = (undefined)((uVar1 << 3) >> 0x10); + uStack18 = (ushort)((uVar1 << 0x13) >> 0x18) | (ushort)(uVar1 << 0xb); + if ((uVar1 & 0x3f) < 0x38) { + iVar3 = 0x38; + } + else { + iVar3 = 0x78; + } + mbedtls_sha256_update(ctx,sha256_padding,iVar3 - (uVar1 & 0x3f)); + mbedtls_sha256_update(ctx,&uStack24,8); + *output = *(uchar *)((int)ctx->state + 3); + output[1] = (uchar)*(undefined2 *)((int)ctx->state + 2); + output[2] = (uchar)(ctx->state[0] >> 8); + output[3] = (uchar)ctx->state[0]; + output[4] = *(uchar *)((int)ctx->state + 7); + output[5] = (uchar)*(undefined2 *)((int)ctx->state + 6); + output[6] = (uchar)(ctx->state[1] >> 8); + output[7] = (uchar)ctx->state[1]; + output[8] = *(uchar *)((int)ctx->state + 0xb); + output[9] = (uchar)*(undefined2 *)((int)ctx->state + 10); + output[10] = (uchar)(ctx->state[2] >> 8); + output[0xb] = (uchar)ctx->state[2]; + output[0xc] = *(uchar *)((int)ctx->state + 0xf); + output[0xd] = (uchar)*(undefined2 *)((int)ctx->state + 0xe); + output[0xe] = (uchar)(ctx->state[3] >> 8); + output[0xf] = (uchar)ctx->state[3]; + output[0x10] = *(uchar *)((int)ctx->state + 0x13); + output[0x11] = (uchar)*(undefined2 *)((int)ctx->state + 0x12); + output[0x12] = (uchar)(ctx->state[4] >> 8); + output[0x13] = (uchar)ctx->state[4]; + output[0x14] = *(uchar *)((int)ctx->state + 0x17); + output[0x15] = (uchar)*(undefined2 *)((int)ctx->state + 0x16); + output[0x16] = (uchar)(ctx->state[5] >> 8); + output[0x17] = (uchar)ctx->state[5]; + output[0x18] = *(uchar *)((int)ctx->state + 0x1b); + output[0x19] = (uchar)*(undefined2 *)((int)ctx->state + 0x1a); + output[0x1a] = (uchar)(ctx->state[6] >> 8); + output[0x1b] = (uchar)ctx->state[6]; + if (ctx->is224 == 0) { + output[0x1c] = *(uchar *)((int)ctx->state + 0x1f); + output[0x1d] = (uchar)*(undefined2 *)((int)ctx->state + 0x1e); + output[0x1e] = (uchar)(ctx->state[7] >> 8); + output[0x1f] = (uchar)ctx->state[7]; + } + return; +} + + + +void sha224_update_wrap(mbedtls_sha256_context *ctx,uchar *input,size_t ilen) + +{ + if (ilen != 0) { + mbedtls_sha256_update(ctx,input,ilen); + return; + } + return; +} + + + +void sha224_starts_wrap(void *ctx) + +{ + mbedtls_sha256_starts((mbedtls_sha256_context *)ctx,1); + return; +} + + + +void sha256_starts_wrap(void *ctx) + +{ + mbedtls_sha256_starts((mbedtls_sha256_context *)ctx,0); + return; +} + + + +oid_sig_alg_t * oid_sig_alg_from_asn1(mbedtls_asn1_buf *oid) + +{ + oid_sig_alg_t *poVar1; + char *__s1; + int iVar2; + size_t __n; + + poVar1 = oid_sig_alg; + while( true ) { + __s1 = (poVar1->descriptor).asn1; + if (__s1 == (char *)0x0) { + return (oid_sig_alg_t *)0x0; + } + __n = (poVar1->descriptor).asn1_len; + if ((__n == oid->len) && (iVar2 = memcmp(__s1,oid->p,__n), iVar2 == 0)) break; + poVar1 = poVar1 + 1; + } + return poVar1; +} + + + +int mbedtls_oid_get_attr_short_name(mbedtls_asn1_buf *oid,char **short_name) + +{ + oid_x520_attr_t *poVar1; + char *__s1; + int iVar2; + size_t __n; + + if (oid == (mbedtls_asn1_buf *)0x0) { + return -0x2e; + } + poVar1 = oid_x520_attr_type; + while( true ) { + __s1 = (poVar1->descriptor).asn1; + if (__s1 == (char *)0x0) { + return -0x2e; + } + __n = (poVar1->descriptor).asn1_len; + if ((__n == oid->len) && (iVar2 = memcmp(__s1,oid->p,__n), iVar2 == 0)) break; + poVar1 = poVar1 + 1; + } + *short_name = poVar1->short_name; + return 0; +} + + + +int mbedtls_oid_get_x509_ext_type(mbedtls_asn1_buf *oid,int *ext_type) + +{ + oid_x509_ext_t *poVar1; + char *__s1; + int iVar2; + size_t __n; + + if (oid == (mbedtls_asn1_buf *)0x0) { + return -0x2e; + } + poVar1 = oid_x509_ext; + while( true ) { + __s1 = (poVar1->descriptor).asn1; + if (__s1 == (char *)0x0) { + return -0x2e; + } + __n = (poVar1->descriptor).asn1_len; + if ((__n == oid->len) && (iVar2 = memcmp(__s1,oid->p,__n), iVar2 == 0)) break; + poVar1 = poVar1 + 1; + } + *ext_type = poVar1->ext_type; + return 0; +} + + + +int mbedtls_oid_get_extended_key_usage(mbedtls_asn1_buf *oid,char **description) + +{ + mbedtls_oid_descriptor_t *pmVar1; + int iVar2; + + if (oid == (mbedtls_asn1_buf *)0x0) { + return -0x2e; + } + pmVar1 = oid_ext_key_usage; + while( true ) { + if (pmVar1->asn1 == (char *)0x0) { + return -0x2e; + } + if ((pmVar1->asn1_len == oid->len) && + (iVar2 = memcmp(pmVar1->asn1,oid->p,pmVar1->asn1_len), iVar2 == 0)) break; + pmVar1 = pmVar1 + 1; + } + *description = pmVar1->description; + return 0; +} + + + +int mbedtls_oid_get_sig_alg_desc(mbedtls_asn1_buf *oid,char **description) + +{ + int iVar1; + oid_sig_alg_t *poVar2; + + if (oid == (mbedtls_asn1_buf *)0x0) { + return -0x2e; + } + poVar2 = oid_sig_alg_from_asn1(oid); + if (poVar2 == (oid_sig_alg_t *)0x0) { + iVar1 = -0x2e; + } + else { + iVar1 = 0; + *description = (poVar2->descriptor).description; + } + return iVar1; +} + + + +int mbedtls_oid_get_sig_alg + (mbedtls_asn1_buf *oid,mbedtls_md_type_t *md_alg,mbedtls_pk_type_t *pk_alg) + +{ + int iVar1; + oid_sig_alg_t *poVar2; + + if (oid == (mbedtls_asn1_buf *)0x0) { + return -0x2e; + } + poVar2 = oid_sig_alg_from_asn1(oid); + if (poVar2 == (oid_sig_alg_t *)0x0) { + iVar1 = -0x2e; + } + else { + *md_alg = poVar2->md_alg; + iVar1 = 0; + *pk_alg = poVar2->pk_alg; + } + return iVar1; +} + + + +int mbedtls_oid_get_pk_alg(mbedtls_asn1_buf *oid,mbedtls_pk_type_t *pk_alg) + +{ + oid_pk_alg_t *poVar1; + char *__s1; + int iVar2; + size_t __n; + + if (oid == (mbedtls_asn1_buf *)0x0) { + return -0x2e; + } + poVar1 = oid_pk_alg; + while( true ) { + __s1 = (poVar1->descriptor).asn1; + if (__s1 == (char *)0x0) { + return -0x2e; + } + __n = (poVar1->descriptor).asn1_len; + if ((__n == oid->len) && (iVar2 = memcmp(__s1,oid->p,__n), iVar2 == 0)) break; + poVar1 = poVar1 + 1; + } + *pk_alg = poVar1->pk_alg; + return 0; +} + + + +int mbedtls_oid_get_ec_grp(mbedtls_asn1_buf *oid,mbedtls_ecp_group_id *grp_id) + +{ + oid_ecp_grp_t *poVar1; + char *__s1; + int iVar2; + size_t __n; + + if (oid == (mbedtls_asn1_buf *)0x0) { + return -0x2e; + } + poVar1 = oid_ecp_grp; + while( true ) { + __s1 = (poVar1->descriptor).asn1; + if (__s1 == (char *)0x0) { + return -0x2e; + } + __n = (poVar1->descriptor).asn1_len; + if ((__n == oid->len) && (iVar2 = memcmp(__s1,oid->p,__n), iVar2 == 0)) break; + poVar1 = poVar1 + 1; + } + *grp_id = poVar1->grp_id; + return 0; +} + + + +int mbedtls_oid_get_md_alg(mbedtls_asn1_buf *oid,mbedtls_md_type_t *md_alg) + +{ + oid_md_alg_t *poVar1; + char *__s1; + int iVar2; + size_t __n; + + if (oid == (mbedtls_asn1_buf *)0x0) { + return -0x2e; + } + poVar1 = oid_md_alg; + while( true ) { + __s1 = (poVar1->descriptor).asn1; + if (__s1 == (char *)0x0) { + return -0x2e; + } + __n = (poVar1->descriptor).asn1_len; + if ((__n == oid->len) && (iVar2 = memcmp(__s1,oid->p,__n), iVar2 == 0)) break; + poVar1 = poVar1 + 1; + } + *md_alg = poVar1->md_alg; + return 0; +} + + + +int mbedtls_oid_get_oid_by_md(mbedtls_md_type_t md_alg,char **oid,size_t *olen) + +{ + undefined3 in_register_00002029; + char *pcVar1; + oid_md_alg_t *poVar2; + + poVar2 = oid_md_alg; + while( true ) { + pcVar1 = (poVar2->descriptor).asn1; + if (pcVar1 == (char *)0x0) { + return -0x2e; + } + if ((uint)poVar2->md_alg == CONCAT31(in_register_00002029,md_alg)) break; + poVar2 = poVar2 + 1; + } + *oid = pcVar1; + *olen = (poVar2->descriptor).asn1_len; + return 0; +} + + + +// WARNING: Variable defined which should be unmapped: aes_ctx + +void pem_aes_decrypt(uchar *aes_iv,uint keylen,uchar *buf,size_t buflen,uchar *pwd,size_t pwdlen) + +{ + uchar *key; + size_t __n; + uchar *puVar1; + uchar *puVar2; + uchar local_1c0 [4]; + uchar md5sum [16]; + uchar aes_key [32]; + mbedtls_md5_context md5_ctx; + mbedtls_aes_context aes_ctx; + + puVar1 = local_1c0; + puVar2 = local_1c0; + mbedtls_aes_init((mbedtls_aes_context *)(md5_ctx.buffer + 0x3c)); + mbedtls_md5_init((mbedtls_md5_context *)(aes_key + 0x1c)); + mbedtls_md5_starts((mbedtls_md5_context *)(aes_key + 0x1c)); + mbedtls_md5_update((mbedtls_md5_context *)(aes_key + 0x1c),pwd,pwdlen); + mbedtls_md5_update((mbedtls_md5_context *)(aes_key + 0x1c),aes_iv,8); + mbedtls_md5_finish((mbedtls_md5_context *)(aes_key + 0x1c),local_1c0); + key = md5sum + 0xc; + if (keylen == 0x10) { + memcpy(key,local_1c0,0x10); + mbedtls_md5_free((mbedtls_md5_context *)(aes_key + 0x1c)); + do { + *puVar1 = '\0'; + puVar1 = puVar1 + 1; + } while (puVar1 != key); + } + else { + memcpy(key,local_1c0,0x10); + mbedtls_md5_starts((mbedtls_md5_context *)(aes_key + 0x1c)); + mbedtls_md5_update((mbedtls_md5_context *)(aes_key + 0x1c),local_1c0,0x10); + mbedtls_md5_update((mbedtls_md5_context *)(aes_key + 0x1c),pwd,pwdlen); + mbedtls_md5_update((mbedtls_md5_context *)(aes_key + 0x1c),aes_iv,8); + mbedtls_md5_finish((mbedtls_md5_context *)(aes_key + 0x1c),local_1c0); + __n = 0x10; + if (keylen != 0x20) { + __n = keylen - 0x10; + } + memcpy(aes_key + 0xc,local_1c0,__n); + mbedtls_md5_free((mbedtls_md5_context *)(aes_key + 0x1c)); + do { + *puVar2 = '\0'; + puVar2 = puVar2 + 1; + } while (puVar2 != key); + } + mbedtls_aes_setkey_dec((mbedtls_aes_context *)(md5_ctx.buffer + 0x3c),key,keylen << 3); + mbedtls_aes_crypt_cbc((mbedtls_aes_context *)(md5_ctx.buffer + 0x3c),0,buflen,aes_iv,buf,buf); + mbedtls_aes_free((mbedtls_aes_context *)(md5_ctx.buffer + 0x3c)); + while (keylen = keylen - 1, keylen != 0xffffffff) { + *key = '\0'; + key = key + 1; + } + return; +} + + + +void mbedtls_pem_init(mbedtls_pem_context *ctx) + +{ + memset(ctx,0,0xc); + return; +} + + + +int mbedtls_pem_read_buffer + (mbedtls_pem_context *ctx,char *header,char *footer,uchar *data,uchar *pwd, + size_t pwdlen,size_t *use_len) + +{ + uchar uVar1; + bool bVar2; + uchar *dst; + uchar *puVar3; + size_t sVar4; + int iVar5; + int iVar6; + uchar *puVar7; + byte bVar8; + uint uVar9; + uint uVar10; + byte *pbVar11; + uint keylen; + uchar *src; + size_t sStack68; + size_t len; + uchar pem_iv [16]; + + if (ctx == (mbedtls_pem_context *)0x0) { + return -0x1480; + } + dst = (uchar *)strstr((char *)data,header); + if (((dst == (uchar *)0x0) || + (puVar3 = (uchar *)strstr((char *)data,footer), puVar3 == (uchar *)0x0)) || (puVar3 <= dst)) { + return -0x1080; + } + sVar4 = strlen(header); + dst = dst + sVar4; + if (*dst == ' ') { + dst = dst + 1; + } + if (*dst == '\r') { + dst = dst + 1; + } + if (*dst != '\n') { + return -0x1080; + } + sVar4 = strlen(footer); + puVar7 = puVar3 + sVar4; + src = dst + 1; + if (*puVar7 == ' ') { + puVar7 = puVar7 + 1; + } + if (*puVar7 == '\r') { + puVar7 = puVar7 + 1; + } + if (*puVar7 == '\n') { + puVar7 = puVar7 + 1; + } + *(uchar **)use_len = puVar7 + -(int)data; + if (((int)(puVar3 + -(int)src) < 0x16) || + (iVar5 = memcmp(src,"Proc-Type: 4,ENCRYPTED",0x16), iVar5 != 0)) { + iVar5 = 0; + bVar2 = false; + } + else { + uVar1 = dst[0x17]; + puVar7 = dst + 0x17; + if (uVar1 == '\r') { + uVar1 = dst[0x18]; + puVar7 = dst + 0x18; + } + if (uVar1 != '\n') { + return -0x1100; + } + dst = puVar7 + 1; + if ((((int)(puVar3 + -(int)dst) < 0xe) || (iVar5 = memcmp(dst,"DEK-Info: AES-",0xe), iVar5 != 0) + ) || ((int)(puVar3 + -(int)dst) < 0x16)) { + return -0x1280; + } + iVar6 = memcmp(dst,"DEK-Info: AES-128-CBC,",0x16); + iVar5 = 5; + if (iVar6 != 0) { + iVar6 = memcmp(dst,"DEK-Info: AES-192-CBC,",0x16); + iVar5 = 6; + if (iVar6 != 0) { + iVar5 = memcmp(dst,"DEK-Info: AES-256-CBC,",0x16); + if (iVar5 != 0) { + return -0x1280; + } + iVar5 = 7; + } + } + if ((int)(puVar3 + -(int)(puVar7 + 0x17)) < 0x20) { + return -0x1200; + } + memset(&len,0,0x10); + keylen = 0; + do { + uVar10 = (uint)puVar7[keylen + 0x17]; + uVar9 = uVar10 - 0x30; + if (9 < (uVar9 & 0xff)) { + if ((uVar10 - 0x41 & 0xff) < 6) { + uVar9 = uVar10 - 0x37; + } + else { + if (5 < (uVar10 - 0x61 & 0xff)) { + return -0x1200; + } + uVar9 = uVar10 - 0x57; + } + } + bVar8 = (byte)uVar9; + if ((keylen & 1) == 0) { + bVar8 = (byte)(uVar9 << 4); + } + pbVar11 = (byte *)((int)&len + (keylen >> 1)); + keylen = keylen + 1; + *pbVar11 = bVar8 | *pbVar11; + } while (keylen != 0x20); + src = puVar7 + 0x38; + if (puVar7[0x37] != '\r') { + src = puVar7 + 0x37; + } + if (*src != '\n') { + return -0x1100; + } + src = src + 1; + bVar2 = true; + } + if (puVar3 <= src) { + return -0x1100; + } + iVar6 = mbedtls_base64_decode((uchar *)0x0,0,&sStack68,src,(size_t)(puVar3 + -(int)src)); + if (iVar6 == -0x2c) { + return -0x112c; + } + dst = (uchar *)mycalloc(1,sStack68); + if (dst == (uchar *)0x0) { + return -0x1180; + } + iVar6 = mbedtls_base64_decode(dst,sStack68,&sStack68,src,(size_t)(puVar3 + -(int)src)); + if (iVar6 != 0) { + vPortFree(dst); + return iVar6 + -0x1100; + } + if (!bVar2) goto LAB_230661ca; + if (pwd == (uchar *)0x0) { + vPortFree(dst); + return -0x1300; + } + if (iVar5 == 5) { + keylen = 0x10; +LAB_23066174: + pem_aes_decrypt((uchar *)&len,keylen,dst,sStack68,pwd,pwdlen); + } + else { + if (iVar5 == 6) { + keylen = 0x18; + goto LAB_23066174; + } + if (iVar5 == 7) { + keylen = 0x20; + goto LAB_23066174; + } + } + if (((sStack68 < 3) || (*dst != '0')) || (0x83 < dst[1])) { + vPortFree(dst); + return -0x1380; + } +LAB_230661ca: + ctx->buf = dst; + ctx->buflen = sStack68; + return 0; +} + + + +void mbedtls_pem_free(mbedtls_pem_context *ctx) + +{ + mbedtls_pem_context *pmVar1; + + vPortFree(ctx->buf); + vPortFree(ctx->info); + pmVar1 = ctx + 1; + while (ctx != pmVar1) { + *(undefined *)&ctx->buf = 0; + ctx = (mbedtls_pem_context *)((int)&ctx->buf + 1); + } + return; +} + + + +void mbedtls_md5_init(mbedtls_md5_context *ctx) + +{ + memset(ctx,0,0x58); + return; +} + + + +void mbedtls_md5_free(mbedtls_md5_context *ctx) + +{ + mbedtls_md5_context *pmVar1; + + pmVar1 = ctx + 1; + if (ctx != (mbedtls_md5_context *)0x0) { + while (ctx != pmVar1) { + *(undefined *)ctx->total = 0; + ctx = (mbedtls_md5_context *)((int)ctx->total + 1); + } + } + return; +} + + + +void mbedtls_md5_clone(mbedtls_md5_context *dst,mbedtls_md5_context *src) + +{ + memcpy(dst,src,0x58); + return; +} + + + +void mbedtls_md5_starts(mbedtls_md5_context *ctx) + +{ + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xefcdab89; + ctx->state[2] = 0x98badcfe; + ctx->total[0] = 0; + ctx->total[1] = 0; + ctx->state[3] = 0x10325476; + return; +} + + + +void mbedtls_md5_process(mbedtls_md5_context *ctx,uchar *data) + +{ + int iVar1; + int iVar2; + int iVar3; + int iVar4; + int iVar5; + int iVar6; + int iVar7; + int iVar8; + int iVar9; + int iVar10; + int iVar11; + int iVar12; + int iVar13; + int iVar14; + int iVar15; + int iVar16; + uint uVar17; + uint uVar18; + uint uVar19; + uint uVar20; + uint uVar21; + uint uVar22; + uint uVar23; + uint uVar24; + uint uVar25; + + iVar1 = *(int *)data; + iVar2 = *(int *)(data + 4); + iVar3 = *(int *)(data + 0x10); + iVar4 = *(int *)(data + 8); + iVar5 = *(int *)(data + 0xc); + iVar6 = *(int *)(data + 0x14); + iVar7 = *(int *)(data + 0x18); + iVar8 = *(int *)(data + 0x24); + iVar9 = *(int *)(data + 0x1c); + iVar10 = *(int *)(data + 0x20); + iVar11 = *(int *)(data + 0x2c); + iVar12 = *(int *)(data + 0x28); + iVar13 = *(int *)(data + 0x30); + uVar19 = ctx->state[3]; + iVar14 = *(int *)(data + 0x34); + iVar15 = *(int *)(data + 0x38); + iVar16 = *(int *)(data + 0x3c); + uVar17 = ctx->state[2]; + uVar18 = ctx->state[1]; + uVar20 = ((uVar17 ^ uVar19) & uVar18 ^ uVar19) + ctx->state[0] + 0xd76aa478 + iVar1; + uVar21 = (uVar20 >> 0x19 | uVar20 * 0x80) + uVar18; + uVar20 = ((uVar18 ^ uVar17) & uVar21 ^ uVar17) + uVar19 + 0xe8c7b756 + iVar2; + uVar23 = (uVar20 >> 0x14 | uVar20 * 0x1000) + uVar21; + uVar20 = ((uVar18 ^ uVar21) & uVar23 ^ uVar18) + uVar17 + 0x242070db + iVar4; + uVar22 = (uVar20 * 0x20000 | uVar20 >> 0xf) + uVar23; + uVar20 = ((uVar21 ^ uVar23) & uVar22 ^ uVar21) + uVar18 + 0xc1bdceee + iVar5; + uVar20 = (uVar20 * 0x400000 | uVar20 >> 10) + uVar22; + uVar21 = ((uVar23 ^ uVar22) & uVar20 ^ uVar23) + iVar3 + -0xa83f051 + uVar21; + uVar21 = (uVar21 >> 0x19 | uVar21 * 0x80) + uVar20; + uVar23 = ((uVar22 ^ uVar20) & uVar21 ^ uVar22) + iVar6 + 0x4787c62a + uVar23; + uVar23 = (uVar23 >> 0x14 | uVar23 * 0x1000) + uVar21; + uVar22 = ((uVar20 ^ uVar21) & uVar23 ^ uVar20) + iVar7 + -0x57cfb9ed + uVar22; + uVar22 = (uVar22 * 0x20000 | uVar22 >> 0xf) + uVar23; + uVar20 = ((uVar21 ^ uVar23) & uVar22 ^ uVar21) + iVar9 + -0x2b96aff + uVar20; + uVar20 = (uVar20 * 0x400000 | uVar20 >> 10) + uVar22; + uVar21 = ((uVar23 ^ uVar22) & uVar20 ^ uVar23) + iVar10 + 0x698098d8 + uVar21; + uVar21 = (uVar21 >> 0x19 | uVar21 * 0x80) + uVar20; + uVar23 = ((uVar22 ^ uVar20) & uVar21 ^ uVar22) + iVar8 + -0x74bb0851 + uVar23; + uVar23 = (uVar23 >> 0x14 | uVar23 * 0x1000) + uVar21; + uVar22 = ((uVar20 ^ uVar21) & uVar23 ^ uVar20) + iVar12 + -0xa44f + uVar22; + uVar22 = (uVar22 * 0x20000 | uVar22 >> 0xf) + uVar23; + uVar20 = ((uVar21 ^ uVar23) & uVar22 ^ uVar21) + iVar11 + -0x76a32842 + uVar20; + uVar20 = (uVar20 * 0x400000 | uVar20 >> 10) + uVar22; + uVar21 = ((uVar23 ^ uVar22) & uVar20 ^ uVar23) + iVar13 + 0x6b901122 + uVar21; + uVar21 = (uVar21 >> 0x19 | uVar21 * 0x80) + uVar20; + uVar23 = ((uVar22 ^ uVar20) & uVar21 ^ uVar22) + iVar14 + -0x2678e6d + uVar23; + uVar23 = (uVar23 >> 0x14 | uVar23 * 0x1000) + uVar21; + uVar22 = ((uVar20 ^ uVar21) & uVar23 ^ uVar20) + iVar15 + -0x5986bc72 + uVar22; + uVar22 = (uVar22 * 0x20000 | uVar22 >> 0xf) + uVar23; + uVar20 = ((uVar21 ^ uVar23) & uVar22 ^ uVar21) + iVar16 + 0x49b40821 + uVar20; + uVar20 = (uVar20 * 0x400000 | uVar20 >> 10) + uVar22; + uVar21 = ((uVar22 ^ uVar20) & uVar23 ^ uVar22) + iVar2 + -0x9e1da9e + uVar21; + uVar21 = (uVar21 >> 0x1b | uVar21 * 0x20) + uVar20; + uVar23 = ((uVar20 ^ uVar21) & uVar22 ^ uVar20) + iVar7 + -0x3fbf4cc0 + uVar23; + uVar23 = (uVar23 >> 0x17 | uVar23 * 0x200) + uVar21; + uVar22 = ((uVar21 ^ uVar23) & uVar20 ^ uVar21) + iVar11 + 0x265e5a51 + uVar22; + uVar22 = (uVar22 >> 0x12 | uVar22 * 0x4000) + uVar23; + uVar20 = ((uVar23 ^ uVar22) & uVar21 ^ uVar23) + iVar1 + -0x16493856 + uVar20; + uVar20 = (uVar20 * 0x100000 | uVar20 >> 0xc) + uVar22; + uVar21 = ((uVar22 ^ uVar20) & uVar23 ^ uVar22) + iVar6 + -0x29d0efa3 + uVar21; + uVar21 = (uVar21 >> 0x1b | uVar21 * 0x20) + uVar20; + uVar23 = ((uVar20 ^ uVar21) & uVar22 ^ uVar20) + iVar12 + 0x2441453 + uVar23; + uVar23 = (uVar23 >> 0x17 | uVar23 * 0x200) + uVar21; + uVar22 = ((uVar21 ^ uVar23) & uVar20 ^ uVar21) + iVar16 + -0x275e197f + uVar22; + uVar22 = (uVar22 >> 0x12 | uVar22 * 0x4000) + uVar23; + uVar20 = ((uVar23 ^ uVar22) & uVar21 ^ uVar23) + iVar3 + -0x182c0438 + uVar20; + uVar20 = (uVar20 * 0x100000 | uVar20 >> 0xc) + uVar22; + uVar21 = ((uVar22 ^ uVar20) & uVar23 ^ uVar22) + iVar8 + 0x21e1cde6 + uVar21; + uVar21 = (uVar21 >> 0x1b | uVar21 * 0x20) + uVar20; + uVar23 = ((uVar20 ^ uVar21) & uVar22 ^ uVar20) + iVar15 + -0x3cc8f82a + uVar23; + uVar23 = (uVar23 >> 0x17 | uVar23 * 0x200) + uVar21; + uVar22 = ((uVar21 ^ uVar23) & uVar20 ^ uVar21) + iVar5 + -0xb2af279 + uVar22; + uVar22 = (uVar22 >> 0x12 | uVar22 * 0x4000) + uVar23; + uVar20 = ((uVar23 ^ uVar22) & uVar21 ^ uVar23) + iVar10 + 0x455a14ed + uVar20; + uVar20 = (uVar20 * 0x100000 | uVar20 >> 0xc) + uVar22; + uVar21 = ((uVar22 ^ uVar20) & uVar23 ^ uVar22) + iVar14 + -0x561c16fb + uVar21; + uVar21 = (uVar21 >> 0x1b | uVar21 * 0x20) + uVar20; + uVar23 = ((uVar20 ^ uVar21) & uVar22 ^ uVar20) + iVar4 + -0x3105c08 + uVar23; + uVar24 = (uVar23 >> 0x17 | uVar23 * 0x200) + uVar21; + uVar22 = ((uVar21 ^ uVar24) & uVar20 ^ uVar21) + iVar9 + 0x676f02d9 + uVar22; + uVar23 = (uVar22 >> 0x12 | uVar22 * 0x4000) + uVar24; + uVar20 = ((uVar24 ^ uVar23) & uVar21 ^ uVar24) + iVar13 + -0x72d5b376 + uVar20; + uVar20 = (uVar20 * 0x100000 | uVar20 >> 0xc) + uVar23; + uVar21 = (uVar24 ^ uVar23 ^ uVar20) + iVar6 + -0x5c6be + uVar21; + uVar21 = (uVar21 >> 0x1c | uVar21 * 0x10) + uVar20; + uVar22 = (uVar23 ^ uVar20 ^ uVar21) + uVar24 + iVar10 + -0x788e097f; + uVar22 = (uVar22 >> 0x15 | uVar22 * 0x800) + uVar21; + uVar23 = (uVar20 ^ uVar21 ^ uVar22) + uVar23 + iVar11 + 0x6d9d6122; + uVar24 = (uVar23 >> 0x10 | uVar23 * 0x10000) + uVar22; + uVar20 = (uVar21 ^ uVar22 ^ uVar24) + uVar20 + iVar15 + -0x21ac7f4; + uVar23 = (uVar20 * 0x800000 | uVar20 >> 9) + uVar24; + uVar20 = (uVar22 ^ uVar24 ^ uVar23) + iVar2 + -0x5b4115bc + uVar21; + uVar21 = (uVar20 >> 0x1c | uVar20 * 0x10) + uVar23; + uVar20 = (uVar24 ^ uVar23 ^ uVar21) + uVar22 + iVar3 + 0x4bdecfa9; + uVar20 = (uVar20 >> 0x15 | uVar20 * 0x800) + uVar21; + uVar22 = (uVar23 ^ uVar21 ^ uVar20) + iVar9 + -0x944b4a0 + uVar24; + uVar24 = (uVar22 >> 0x10 | uVar22 * 0x10000) + uVar20; + uVar22 = (uVar21 ^ uVar20 ^ uVar24) + uVar23 + iVar12 + -0x41404390; + uVar22 = (uVar22 * 0x800000 | uVar22 >> 9) + uVar24; + uVar21 = (uVar20 ^ uVar24 ^ uVar22) + uVar21 + iVar14 + 0x289b7ec6; + uVar23 = (uVar21 >> 0x1c | uVar21 * 0x10) + uVar22; + uVar20 = (uVar24 ^ uVar22 ^ uVar23) + iVar1 + -0x155ed806 + uVar20; + uVar20 = (uVar20 >> 0x15 | uVar20 * 0x800) + uVar23; + uVar21 = (uVar22 ^ uVar23 ^ uVar20) + iVar5 + -0x2b10cf7b + uVar24; + uVar24 = (uVar21 >> 0x10 | uVar21 * 0x10000) + uVar20; + uVar21 = (uVar23 ^ uVar20 ^ uVar24) + uVar22 + iVar7 + 0x4881d05; + uVar21 = (uVar21 * 0x800000 | uVar21 >> 9) + uVar24; + uVar22 = (uVar20 ^ uVar24 ^ uVar21) + iVar8 + -0x262b2fc7 + uVar23; + uVar23 = (uVar22 >> 0x1c | uVar22 * 0x10) + uVar21; + uVar20 = (uVar24 ^ uVar21 ^ uVar23) + uVar20 + iVar13 + -0x1924661b; + uVar22 = (uVar20 >> 0x15 | uVar20 * 0x800) + uVar23; + uVar20 = (uVar21 ^ uVar23 ^ uVar22) + uVar24 + iVar16 + 0x1fa27cf8; + uVar20 = (uVar20 >> 0x10 | uVar20 * 0x10000) + uVar22; + uVar21 = (uVar23 ^ uVar22 ^ uVar20) + iVar4 + -0x3b53a99b + uVar21; + uVar21 = (uVar21 * 0x800000 | uVar21 >> 9) + uVar20; + uVar23 = ((~uVar22 | uVar21) ^ uVar20) + uVar23 + iVar1 + -0xbd6ddbc; + uVar24 = (uVar23 >> 0x1a | uVar23 * 0x40) + uVar21; + uVar22 = ((~uVar20 | uVar24) ^ uVar21) + uVar22 + iVar9 + 0x432aff97; + uVar23 = (uVar22 >> 0x16 | uVar22 * 0x400) + uVar24; + uVar20 = ((~uVar21 | uVar23) ^ uVar24) + iVar15 + -0x546bdc59 + uVar20; + uVar20 = (uVar20 >> 0x11 | uVar20 * 0x8000) + uVar23; + uVar21 = ((~uVar24 | uVar20) ^ uVar23) + iVar6 + -0x36c5fc7 + uVar21; + uVar22 = (uVar21 * 0x200000 | uVar21 >> 0xb) + uVar20; + uVar21 = ((~uVar23 | uVar22) ^ uVar20) + iVar13 + 0x655b59c3 + uVar24; + uVar24 = (uVar21 >> 0x1a | uVar21 * 0x40) + uVar22; + uVar21 = ((~uVar20 | uVar24) ^ uVar22) + uVar23 + iVar5 + -0x70f3336e; + uVar21 = (uVar21 >> 0x16 | uVar21 * 0x400) + uVar24; + uVar20 = ((~uVar22 | uVar21) ^ uVar24) + iVar12 + -0x100b83 + uVar20; + uVar20 = (uVar20 >> 0x11 | uVar20 * 0x8000) + uVar21; + uVar22 = ((~uVar24 | uVar20) ^ uVar21) + iVar2 + -0x7a7ba22f + uVar22; + uVar22 = (uVar22 * 0x200000 | uVar22 >> 0xb) + uVar20; + uVar23 = ((~uVar21 | uVar22) ^ uVar20) + iVar10 + 0x6fa87e4f + uVar24; + uVar25 = (uVar23 >> 0x1a | uVar23 * 0x40) + uVar22; + uVar21 = ((~uVar20 | uVar25) ^ uVar22) + uVar21 + iVar16 + -0x1d31920; + uVar24 = (uVar21 >> 0x16 | uVar21 * 0x400) + uVar25; + uVar20 = ((~uVar22 | uVar24) ^ uVar25) + iVar7 + -0x5cfebcec + uVar20; + uVar20 = (uVar20 >> 0x11 | uVar20 * 0x8000) + uVar24; + uVar21 = ((~uVar25 | uVar20) ^ uVar24) + iVar14 + 0x4e0811a1 + uVar22; + uVar23 = (uVar21 * 0x200000 | uVar21 >> 0xb) + uVar20; + uVar21 = ((~uVar24 | uVar23) ^ uVar20) + uVar25 + iVar3 + -0x8ac817e; + uVar22 = (uVar21 >> 0x1a | uVar21 * 0x40) + uVar23; + uVar21 = ((~uVar20 | uVar22) ^ uVar23) + uVar24 + iVar11 + -0x42c50dcb; + uVar21 = (uVar21 >> 0x16 | uVar21 * 0x400) + uVar22; + uVar20 = ((~uVar23 | uVar21) ^ uVar22) + uVar20 + iVar4 + 0x2ad7d2bb; + uVar20 = (uVar20 >> 0x11 | uVar20 * 0x8000) + uVar21; + uVar23 = ((~uVar22 | uVar20) ^ uVar21) + uVar23 + iVar8 + -0x14792c6f; + ctx->state[0] = ctx->state[0] + uVar22; + ctx->state[1] = uVar18 + uVar20 + (uVar23 >> 0xb | uVar23 * 0x200000); + ctx->state[2] = uVar20 + uVar17; + ctx->state[3] = uVar21 + uVar19; + return; +} + + + +void mbedtls_md5_update(mbedtls_md5_context *ctx,uchar *input,size_t ilen) + +{ + size_t __n; + uint uVar1; + uint uVar2; + uint __n_00; + + uVar2 = ctx->total[0] & 0x3f; + uVar1 = ctx->total[0] + ilen; + ctx->total[0] = uVar1; + if (uVar1 < ilen) { + ctx->total[1] = ctx->total[1] + 1; + } + uVar1 = ilen; + if ((uVar2 != 0) && (__n_00 = 0x40 - uVar2, __n_00 <= ilen)) { + memcpy(ctx->buffer + uVar2,input,__n_00); + ilen = (ilen - 0x40) + uVar2; + mbedtls_md5_process(ctx,ctx->buffer); + input = input + __n_00; + uVar2 = 0; + uVar1 = ilen; + } + while (0x3f < ilen) { + mbedtls_md5_process(ctx,input + (uVar1 - ilen)); + ilen = ilen - 0x40; + } + __n = (uVar1 >> 6) * -0x40 + uVar1; + if (__n == 0) { + return; + } + memcpy(ctx->buffer + uVar2,input + (uVar1 & 0xffffffc0),__n); + return; +} + + + +void mbedtls_md5_update(mbedtls_md5_context *ctx,uchar *input,size_t ilen) + +{ + if (ilen != 0) { + mbedtls_md5_update(ctx,input,ilen); + return; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void mbedtls_md5_finish(mbedtls_md5_context *ctx,uchar *output) + +{ + uint uVar1; + int iVar2; + int iStack24; + uchar msglen [8]; + + uVar1 = ctx->total[0]; + msglen._0_4_ = ctx->total[1] << 3 | uVar1 >> 0x1d; + iStack24 = uVar1 << 3; + if ((uVar1 & 0x3f) < 0x38) { + iVar2 = 0x38; + } + else { + iVar2 = 0x78; + } + mbedtls_md5_update(ctx,md5_padding,iVar2 - (uVar1 & 0x3f)); + mbedtls_md5_update(ctx,(uchar *)&iStack24,8); + *output = (uchar)ctx->state[0]; + output[1] = (uchar)(ctx->state[0] >> 8); + output[2] = (uchar)*(undefined2 *)((int)ctx->state + 2); + output[3] = *(uchar *)((int)ctx->state + 3); + output[4] = (uchar)ctx->state[1]; + output[5] = (uchar)(ctx->state[1] >> 8); + output[6] = (uchar)*(undefined2 *)((int)ctx->state + 6); + output[7] = *(uchar *)((int)ctx->state + 7); + output[8] = (uchar)ctx->state[2]; + output[9] = (uchar)(ctx->state[2] >> 8); + output[10] = (uchar)*(undefined2 *)((int)ctx->state + 10); + output[0xb] = *(uchar *)((int)ctx->state + 0xb); + output[0xc] = (uchar)ctx->state[3]; + output[0xd] = (uchar)(ctx->state[3] >> 8); + output[0xe] = (uchar)*(undefined2 *)((int)ctx->state + 0xe); + output[0xf] = *(uchar *)((int)ctx->state + 0xf); + return; +} + + + +void mbedtls_md5(uchar *input,size_t ilen,uchar *output) + +{ + undefined auStack104 [4]; + mbedtls_md5_context ctx; + + mbedtls_md5_init((mbedtls_md5_context *)auStack104); + mbedtls_md5_starts((mbedtls_md5_context *)auStack104); + mbedtls_md5_update((mbedtls_md5_context *)auStack104,input,ilen); + mbedtls_md5_finish((mbedtls_md5_context *)auStack104,output); + mbedtls_md5_free((mbedtls_md5_context *)auStack104); + return; +} + + + +void mbedtls_sha1_init(mbedtls_sha1_context *ctx) + +{ + memset(ctx,0,0x5c); + return; +} + + + +void mbedtls_sha1_free(mbedtls_sha1_context *ctx) + +{ + mbedtls_sha1_context *pmVar1; + + pmVar1 = ctx + 1; + if (ctx != (mbedtls_sha1_context *)0x0) { + while (ctx != pmVar1) { + *(undefined *)ctx->total = 0; + ctx = (mbedtls_sha1_context *)((int)ctx->total + 1); + } + } + return; +} + + + +void mbedtls_sha1_clone(mbedtls_sha1_context *dst,mbedtls_sha1_context *src) + +{ + memcpy(dst,src,0x5c); + return; +} + + + +void mbedtls_sha1_starts(mbedtls_sha1_context *ctx) + +{ + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xefcdab89; + ctx->state[2] = 0x98badcfe; + ctx->state[3] = 0x10325476; + ctx->total[0] = 0; + ctx->total[1] = 0; + ctx->state[4] = 0xc3d2e1f0; + return; +} + + + +void mbedtls_sha1_process(mbedtls_sha1_context *ctx,uchar *data) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + uint uVar4; + uint uVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint uVar9; + uint uVar10; + uint uVar11; + uint32_t uVar12; + uint uVar13; + uint uVar14; + uint uVar15; + uint uVar16; + uint uVar17; + uint uVar18; + uint uVar19; + uint uVar20; + uint uVar21; + uint uVar22; + uint uVar23; + uint uVar24; + uint uVar25; + uint uVar26; + uint uVar27; + uint uVar28; + + uVar8 = (uint)*data << 0x18 | (uint)data[1] << 0x10 | (uint)data[3] | (uint)data[2] << 8; + uVar10 = (uint)data[4] << 0x18 | (uint)data[5] << 0x10 | (uint)data[7] | (uint)data[6] << 8; + uVar9 = (uint)data[8] << 0x18 | (uint)data[9] << 0x10 | (uint)data[0xb] | (uint)data[10] << 8; + uVar1 = (uint)data[0xc] << 0x18 | (uint)data[0xd] << 0x10 | (uint)data[0xf] | (uint)data[0xe] << 8 + ; + uVar27 = (uint)data[0x10] << 0x18 | (uint)data[0x11] << 0x10 | (uint)data[0x13] | + (uint)data[0x12] << 8; + uVar25 = (uint)data[0x14] << 0x18 | (uint)data[0x15] << 0x10 | (uint)data[0x17] | + (uint)data[0x16] << 8; + uVar14 = (uint)data[0x18] << 0x18 | (uint)data[0x19] << 0x10 | (uint)data[0x1b] | + (uint)data[0x1a] << 8; + uVar20 = (uint)data[0x1c] << 0x18 | (uint)data[0x1d] << 0x10 | (uint)data[0x1f] | + (uint)data[0x1e] << 8; + uVar28 = (uint)data[0x20] << 0x18 | (uint)data[0x21] << 0x10 | (uint)data[0x23] | + (uint)data[0x22] << 8; + uVar26 = (uint)data[0x24] << 0x18 | (uint)data[0x25] << 0x10 | (uint)data[0x27] | + (uint)data[0x26] << 8; + uVar2 = (uint)data[0x28] << 0x18 | (uint)data[0x29] << 0x10 | (uint)data[0x2b] | + (uint)data[0x2a] << 8; + uVar13 = (uint)data[0x2c] << 0x18 | (uint)data[0x2d] << 0x10 | (uint)data[0x2f] | + (uint)data[0x2e] << 8; + uVar11 = (uint)data[0x30] << 0x18 | (uint)data[0x31] << 0x10 | (uint)data[0x33] | + (uint)data[0x32] << 8; + uVar16 = ctx->state[2]; + uVar15 = ctx->state[0]; + uVar5 = (uint)data[0x34] << 0x18 | (uint)data[0x35] << 0x10 | (uint)data[0x37] | + (uint)data[0x36] << 8; + uVar4 = (uint)data[0x38] << 0x18 | (uint)data[0x39] << 0x10 | (uint)data[0x3b] | + (uint)data[0x3a] << 8; + uVar3 = (uint)data[0x3c] << 0x18 | (uint)data[0x3d] << 0x10 | (uint)data[0x3f] | + (uint)data[0x3e] << 8; + uVar6 = (uVar15 << 5 | uVar15 >> 0x1b) + ctx->state[4] + 0x5a827999 + + ((uVar16 ^ ctx->state[3]) & ctx->state[1] ^ ctx->state[3]) + uVar8; + uVar17 = ctx->state[1] << 0x1e | ctx->state[1] >> 2; + uVar18 = (uVar6 * 0x20 | uVar6 >> 0x1b) + + ((uVar16 ^ uVar17) & uVar15 ^ uVar16) + ctx->state[3] + 0x5a827999 + uVar10; + uVar23 = uVar15 << 0x1e | uVar15 >> 2; + uVar7 = uVar6 * 0x40000000 | uVar6 >> 2; + uVar6 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar17 ^ uVar23) & uVar6 ^ uVar17) + uVar16 + 0x5a827999 + uVar9; + uVar19 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar18 = (uVar6 * 0x20 | uVar6 >> 0x1b) + + ((uVar23 ^ uVar7) & uVar18 ^ uVar23) + uVar17 + 0x5a827999 + uVar1; + uVar21 = uVar6 * 0x40000000 | uVar6 >> 2; + uVar17 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar7 ^ uVar19) & uVar6 ^ uVar7) + uVar23 + 0x5a827999 + uVar27; + uVar23 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + ((uVar19 ^ uVar21) & uVar18 ^ uVar19) + uVar25 + 0x5a827999 + uVar7; + uVar6 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar7 = (uVar23 * 0x20 | uVar23 >> 0x1b) + + ((uVar21 ^ uVar6) & uVar17 ^ uVar21) + uVar14 + 0x5a827999 + uVar19; + uVar24 = uVar23 * 0x40000000 | uVar23 >> 2; + uVar19 = (uVar7 * 0x20 | uVar7 >> 0x1b) + + ((uVar6 ^ uVar18) & uVar23 ^ uVar6) + uVar21 + uVar20 + 0x5a827999; + uVar17 = uVar7 * 0x40000000 | uVar7 >> 2; + uVar7 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + ((uVar18 ^ uVar24) & uVar7 ^ uVar18) + uVar28 + 0x5a827999 + uVar6; + uVar23 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar6 = (uVar7 * 0x20 | uVar7 >> 0x1b) + + ((uVar24 ^ uVar17) & uVar19 ^ uVar24) + uVar18 + uVar26 + 0x5a827999; + uVar22 = uVar7 * 0x40000000 | uVar7 >> 2; + uVar19 = (uVar6 * 0x20 | uVar6 >> 0x1b) + + ((uVar17 ^ uVar23) & uVar7 ^ uVar17) + uVar2 + 0x5a827999 + uVar24; + uVar18 = uVar6 * 0x40000000 | uVar6 >> 2; + uVar7 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + ((uVar23 ^ uVar22) & uVar6 ^ uVar23) + uVar17 + uVar13 + 0x5a827999; + uVar21 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar6 = (uVar7 * 0x20 | uVar7 >> 0x1b) + + ((uVar22 ^ uVar18) & uVar19 ^ uVar22) + uVar11 + 0x5a827999 + uVar23; + uVar17 = uVar7 * 0x40000000 | uVar7 >> 2; + uVar19 = (uVar6 * 0x20 | uVar6 >> 0x1b) + + ((uVar18 ^ uVar21) & uVar7 ^ uVar18) + uVar22 + uVar5 + 0x5a827999; + uVar7 = uVar6 * 0x40000000 | uVar6 >> 2; + uVar23 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + ((uVar21 ^ uVar17) & uVar6 ^ uVar21) + uVar4 + 0x5a827999 + uVar18; + uVar22 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar6 = uVar8 ^ uVar9 ^ uVar28 ^ uVar5; + uVar18 = (uVar23 * 0x20 | uVar23 >> 0x1b) + + ((uVar17 ^ uVar7) & uVar19 ^ uVar17) + uVar21 + uVar3 + 0x5a827999; + uVar8 = uVar6 >> 0x1f | uVar6 << 1; + uVar6 = uVar10 ^ uVar1 ^ uVar26 ^ uVar4; + uVar19 = uVar23 * 0x40000000 | uVar23 >> 2; + uVar10 = uVar6 >> 0x1f | uVar6 << 1; + uVar17 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar7 ^ uVar22) & uVar23 ^ uVar7) + uVar8 + 0x5a827999 + uVar17; + uVar21 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar9 = uVar9 ^ uVar27 ^ uVar2 ^ uVar3; + uVar6 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + ((uVar22 ^ uVar19) & uVar18 ^ uVar22) + uVar7 + uVar10 + 0x5a827999; + uVar9 = uVar9 >> 0x1f | uVar9 << 1; + uVar1 = uVar1 ^ uVar25 ^ uVar13 ^ uVar8; + uVar23 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar1 = uVar1 >> 0x1f | uVar1 << 1; + uVar18 = (uVar6 * 0x20 | uVar6 >> 0x1b) + + ((uVar19 ^ uVar21) & uVar17 ^ uVar19) + uVar9 + 0x5a827999 + uVar22; + uVar17 = uVar27 ^ uVar14 ^ uVar11 ^ uVar10; + uVar7 = uVar6 * 0x40000000 | uVar6 >> 2; + uVar27 = uVar17 >> 0x1f | uVar17 << 1; + uVar17 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar21 ^ uVar23) & uVar6 ^ uVar21) + uVar1 + 0x5a827999 + uVar19; + uVar6 = uVar25 ^ uVar20 ^ uVar5 ^ uVar9; + uVar19 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar24 = uVar6 >> 0x1f | uVar6 << 1; + uVar21 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar23 ^ uVar7 ^ uVar18) + uVar21 + uVar27 + 0x6ed9eba1; + uVar6 = uVar14 ^ uVar28 ^ uVar4 ^ uVar1; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar17 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar7 ^ uVar19 ^ uVar17) + uVar24 + 0x6ed9eba1 + uVar23; + uVar14 = uVar6 >> 0x1f | uVar6 << 1; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar6 = uVar20 ^ uVar26 ^ uVar3 ^ uVar27; + uVar6 = uVar6 >> 0x1f | uVar6 << 1; + uVar21 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar19 ^ uVar18 ^ uVar21) + uVar14 + 0x6ed9eba1 + uVar7; + uVar7 = uVar28 ^ uVar2 ^ uVar8 ^ uVar24; + uVar20 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar28 = uVar7 >> 0x1f | uVar7 << 1; + uVar7 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar18 ^ uVar23 ^ uVar17) + uVar19 + uVar6 + 0x6ed9eba1; + uVar17 = uVar26 ^ uVar13 ^ uVar10 ^ uVar14; + uVar22 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar26 = uVar17 >> 0x1f | uVar17 << 1; + uVar17 = (uVar7 * 0x20 | uVar7 >> 0x1b) + + (uVar23 ^ uVar20 ^ uVar21) + uVar18 + uVar28 + 0x6ed9eba1; + uVar2 = uVar2 ^ uVar11 ^ uVar9 ^ uVar6; + uVar19 = uVar7 * 0x40000000 | uVar7 >> 2; + uVar21 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar20 ^ uVar22 ^ uVar7) + uVar23 + uVar26 + 0x6ed9eba1; + uVar2 = uVar2 >> 0x1f | uVar2 << 1; + uVar7 = uVar13 ^ uVar5 ^ uVar1 ^ uVar28; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar13 = uVar7 >> 0x1f | uVar7 << 1; + uVar20 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar22 ^ uVar19 ^ uVar17) + uVar2 + 0x6ed9eba1 + uVar20; + uVar7 = uVar11 ^ uVar4 ^ uVar27 ^ uVar26; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar11 = uVar7 >> 0x1f | uVar7 << 1; + uVar17 = (uVar20 * 0x20 | uVar20 >> 0x1b) + + (uVar19 ^ uVar18 ^ uVar21) + uVar13 + 0x6ed9eba1 + uVar22; + uVar5 = uVar5 ^ uVar3 ^ uVar24 ^ uVar2; + uVar22 = uVar20 * 0x40000000 | uVar20 >> 2; + uVar5 = uVar5 >> 0x1f | uVar5 << 1; + uVar7 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar18 ^ uVar23 ^ uVar20) + uVar19 + uVar11 + 0x6ed9eba1; + uVar4 = uVar4 ^ uVar8 ^ uVar14 ^ uVar13; + uVar20 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar4 = uVar4 >> 0x1f | uVar4 << 1; + uVar17 = (uVar7 * 0x20 | uVar7 >> 0x1b) + (uVar23 ^ uVar22 ^ uVar17) + uVar18 + uVar5 + 0x6ed9eba1 + ; + uVar3 = uVar3 ^ uVar10 ^ uVar6 ^ uVar11; + uVar19 = uVar7 * 0x40000000 | uVar7 >> 2; + uVar3 = uVar3 >> 0x1f | uVar3 << 1; + uVar21 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar22 ^ uVar20 ^ uVar7) + uVar23 + uVar4 + 0x6ed9eba1; + uVar7 = uVar8 ^ uVar9 ^ uVar28 ^ uVar5; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar17 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar20 ^ uVar19 ^ uVar17) + uVar3 + 0x6ed9eba1 + uVar22; + uVar7 = uVar7 >> 0x1f | uVar7 << 1; + uVar8 = uVar10 ^ uVar1 ^ uVar26 ^ uVar4; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar10 = uVar8 >> 0x1f | uVar8 << 1; + uVar21 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar19 ^ uVar18 ^ uVar21) + uVar7 + 0x6ed9eba1 + uVar20; + uVar8 = uVar9 ^ uVar27 ^ uVar2 ^ uVar3; + uVar20 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar8 = uVar8 >> 0x1f | uVar8 << 1; + uVar17 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar18 ^ uVar23 ^ uVar17) + uVar19 + uVar10 + 0x6ed9eba1; + uVar1 = uVar1 ^ uVar24 ^ uVar13 ^ uVar7; + uVar22 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar9 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar23 ^ uVar20 ^ uVar21) + uVar18 + uVar8 + 0x6ed9eba1; + uVar1 = uVar1 >> 0x1f | uVar1 << 1; + uVar19 = uVar27 ^ uVar14 ^ uVar11 ^ uVar10; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar21 = (uVar9 * 0x20 | uVar9 >> 0x1b) + (uVar20 ^ uVar22 ^ uVar17) + uVar1 + 0x6ed9eba1 + uVar23 + ; + uVar27 = uVar19 >> 0x1f | uVar19 << 1; + uVar19 = uVar24 ^ uVar6 ^ uVar5 ^ uVar8; + uVar17 = uVar9 * 0x40000000 | uVar9 >> 2; + uVar25 = uVar19 >> 0x1f | uVar19 << 1; + uVar19 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar22 ^ uVar18 ^ uVar9) + uVar27 + 0x6ed9eba1 + uVar20; + uVar9 = uVar14 ^ uVar28 ^ uVar4 ^ uVar1; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar14 = uVar9 >> 0x1f | uVar9 << 1; + uVar20 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar18 ^ uVar17 ^ uVar21) + uVar22 + uVar25 + 0x6ed9eba1; + uVar6 = uVar6 ^ uVar26 ^ uVar3 ^ uVar27; + uVar21 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar6 = uVar6 >> 0x1f | uVar6 << 1; + uVar9 = (uVar20 * 0x20 | uVar20 >> 0x1b) + + (uVar17 ^ uVar23 ^ uVar19) + uVar14 + 0x6ed9eba1 + uVar18; + uVar18 = uVar28 ^ uVar2 ^ uVar7 ^ uVar25; + uVar22 = uVar20 * 0x40000000 | uVar20 >> 2; + uVar28 = uVar18 >> 0x1f | uVar18 << 1; + uVar17 = (uVar9 * 0x20 | uVar9 >> 0x1b) + (uVar23 ^ uVar21 ^ uVar20) + uVar6 + 0x6ed9eba1 + uVar17 + ; + uVar19 = uVar9 * 0x40000000 | uVar9 >> 2; + uVar20 = uVar26 ^ uVar13 ^ uVar10 ^ uVar14; + uVar18 = ((uVar9 | uVar22) & uVar21 | uVar9 & uVar22) + + uVar28 + 0x8f1bbcdc + uVar23 + (uVar17 * 0x20 | uVar17 >> 0x1b); + uVar26 = uVar20 >> 0x1f | uVar20 << 1; + uVar2 = uVar2 ^ uVar11 ^ uVar8 ^ uVar6; + uVar23 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar2 = uVar2 >> 0x1f | uVar2 << 1; + uVar17 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar17 | uVar19) & uVar22 | uVar17 & uVar19) + uVar26 + 0x8f1bbcdc + uVar21; + uVar9 = uVar13 ^ uVar5 ^ uVar1 ^ uVar28; + uVar21 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar13 = uVar9 >> 0x1f | uVar9 << 1; + uVar20 = ((uVar18 | uVar23) & uVar19 | uVar18 & uVar23) + + uVar2 + 0x8f1bbcdc + uVar22 + (uVar17 * 0x20 | uVar17 >> 0x1b); + uVar9 = uVar11 ^ uVar4 ^ uVar27 ^ uVar26; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar11 = uVar9 >> 0x1f | uVar9 << 1; + uVar9 = (uVar20 * 0x20 | uVar20 >> 0x1b) + + ((uVar17 | uVar21) & uVar23 | uVar17 & uVar21) + uVar13 + 0x8f1bbcdc + uVar19; + uVar24 = uVar20 * 0x40000000 | uVar20 >> 2; + uVar5 = uVar5 ^ uVar3 ^ uVar25 ^ uVar2; + uVar19 = ((uVar20 | uVar18) & uVar21 | uVar20 & uVar18) + + uVar11 + 0x8f1bbcdc + uVar23 + (uVar9 * 0x20 | uVar9 >> 0x1b); + uVar5 = uVar5 >> 0x1f | uVar5 << 1; + uVar4 = uVar4 ^ uVar7 ^ uVar14 ^ uVar13; + uVar17 = uVar9 * 0x40000000 | uVar9 >> 2; + uVar4 = uVar4 >> 0x1f | uVar4 << 1; + uVar9 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + ((uVar9 | uVar24) & uVar18 | uVar9 & uVar24) + uVar5 + 0x8f1bbcdc + uVar21; + uVar3 = uVar3 ^ uVar10 ^ uVar6 ^ uVar11; + uVar22 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar3 = uVar3 >> 0x1f | uVar3 << 1; + uVar18 = ((uVar19 | uVar17) & uVar24 | uVar19 & uVar17) + + uVar4 + 0x8f1bbcdc + uVar18 + (uVar9 * 0x20 | uVar9 >> 0x1b); + uVar7 = uVar7 ^ uVar8 ^ uVar28 ^ uVar5; + uVar20 = uVar9 * 0x40000000 | uVar9 >> 2; + uVar7 = uVar7 >> 0x1f | uVar7 << 1; + uVar21 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar9 | uVar22) & uVar17 | uVar9 & uVar22) + uVar3 + 0x8f1bbcdc + uVar24; + uVar9 = uVar10 ^ uVar1 ^ uVar26 ^ uVar4; + uVar19 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar9 = uVar9 >> 0x1f | uVar9 << 1; + uVar10 = ((uVar18 | uVar20) & uVar22 | uVar18 & uVar20) + + uVar7 + 0x8f1bbcdc + uVar17 + (uVar21 * 0x20 | uVar21 >> 0x1b); + uVar8 = uVar8 ^ uVar27 ^ uVar2 ^ uVar3; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar8 = uVar8 >> 0x1f | uVar8 << 1; + uVar18 = (uVar10 * 0x20 | uVar10 >> 0x1b) + + ((uVar21 | uVar19) & uVar20 | uVar21 & uVar19) + uVar9 + 0x8f1bbcdc + uVar22; + uVar1 = uVar1 ^ uVar25 ^ uVar13 ^ uVar7; + uVar17 = uVar10 * 0x40000000 | uVar10 >> 2; + uVar1 = uVar1 >> 0x1f | uVar1 << 1; + uVar10 = ((uVar10 | uVar23) & uVar19 | uVar10 & uVar23) + + uVar8 + 0x8f1bbcdc + uVar20 + (uVar18 * 0x20 | uVar18 >> 0x1b); + uVar21 = uVar27 ^ uVar14 ^ uVar11 ^ uVar9; + uVar22 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar27 = uVar21 >> 0x1f | uVar21 << 1; + uVar18 = (uVar10 * 0x20 | uVar10 >> 0x1b) + + ((uVar18 | uVar17) & uVar23 | uVar18 & uVar17) + uVar19 + uVar1 + 0x8f1bbcdc; + uVar19 = uVar25 ^ uVar6 ^ uVar5 ^ uVar8; + uVar20 = uVar10 * 0x40000000 | uVar10 >> 2; + uVar24 = uVar19 >> 0x1f | uVar19 << 1; + uVar21 = ((uVar10 | uVar22) & uVar17 | uVar10 & uVar22) + + uVar27 + 0x8f1bbcdc + uVar23 + (uVar18 * 0x20 | uVar18 >> 0x1b); + uVar10 = uVar14 ^ uVar28 ^ uVar4 ^ uVar1; + uVar19 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar14 = uVar10 >> 0x1f | uVar10 << 1; + uVar10 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + ((uVar18 | uVar20) & uVar22 | uVar18 & uVar20) + uVar17 + uVar24 + 0x8f1bbcdc; + uVar6 = uVar6 ^ uVar26 ^ uVar3 ^ uVar27; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar6 = uVar6 >> 0x1f | uVar6 << 1; + uVar18 = ((uVar21 | uVar19) & uVar20 | uVar21 & uVar19) + + uVar14 + 0x8f1bbcdc + uVar22 + (uVar10 * 0x20 | uVar10 >> 0x1b); + uVar21 = uVar28 ^ uVar2 ^ uVar7 ^ uVar24; + uVar17 = uVar10 * 0x40000000 | uVar10 >> 2; + uVar28 = uVar21 >> 0x1f | uVar21 << 1; + uVar10 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar10 | uVar23) & uVar19 | uVar10 & uVar23) + uVar20 + uVar6 + 0x8f1bbcdc; + uVar21 = uVar26 ^ uVar13 ^ uVar9 ^ uVar14; + uVar22 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar25 = uVar21 >> 0x1f | uVar21 << 1; + uVar18 = ((uVar18 | uVar17) & uVar23 | uVar18 & uVar17) + + uVar28 + 0x8f1bbcdc + uVar19 + (uVar10 * 0x20 | uVar10 >> 0x1b); + uVar2 = uVar2 ^ uVar11 ^ uVar8 ^ uVar6; + uVar20 = uVar10 * 0x40000000 | uVar10 >> 2; + uVar2 = uVar2 >> 0x1f | uVar2 << 1; + uVar21 = (uVar18 * 0x20 | uVar18 >> 0x1b) + + ((uVar10 | uVar22) & uVar17 | uVar10 & uVar22) + uVar23 + uVar25 + 0x8f1bbcdc; + uVar10 = uVar13 ^ uVar5 ^ uVar1 ^ uVar28; + uVar19 = uVar18 * 0x40000000 | uVar18 >> 2; + uVar13 = uVar10 >> 0x1f | uVar10 << 1; + uVar17 = ((uVar18 | uVar20) & uVar22 | uVar18 & uVar20) + + uVar2 + 0x8f1bbcdc + uVar17 + (uVar21 * 0x20 | uVar21 >> 0x1b); + uVar10 = uVar11 ^ uVar4 ^ uVar27 ^ uVar25; + uVar18 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar10 = uVar10 >> 0x1f | uVar10 << 1; + uVar23 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + ((uVar21 | uVar19) & uVar20 | uVar21 & uVar19) + uVar22 + uVar13 + 0x8f1bbcdc; + uVar5 = uVar5 ^ uVar3 ^ uVar24 ^ uVar2; + uVar11 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar5 = uVar5 >> 0x1f | uVar5 << 1; + uVar21 = (uVar23 * 0x20 | uVar23 >> 0x1b) + + (uVar19 ^ uVar18 ^ uVar17) + uVar20 + uVar10 + 0xca62c1d6; + uVar4 = uVar4 ^ uVar7 ^ uVar14 ^ uVar13; + uVar20 = uVar23 * 0x40000000 | uVar23 >> 2; + uVar4 = uVar4 >> 0x1f | uVar4 << 1; + uVar17 = (uVar21 * 0x20 | uVar21 >> 0x1b) + + (uVar18 ^ uVar11 ^ uVar23) + uVar19 + uVar5 + 0xca62c1d6; + uVar3 = uVar3 ^ uVar9 ^ uVar6 ^ uVar10; + uVar23 = uVar21 * 0x40000000 | uVar21 >> 2; + uVar3 = uVar3 >> 0x1f | uVar3 << 1; + uVar19 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar11 ^ uVar20 ^ uVar21) + uVar18 + uVar4 + 0xca62c1d6; + uVar7 = uVar7 ^ uVar8 ^ uVar28 ^ uVar5; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar7 = uVar7 >> 0x1f | uVar7 << 1; + uVar11 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar20 ^ uVar23 ^ uVar17) + uVar11 + uVar3 + 0xca62c1d6; + uVar9 = uVar9 ^ uVar1 ^ uVar25 ^ uVar4; + uVar21 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar9 = uVar9 >> 0x1f | uVar9 << 1; + uVar20 = (uVar11 * 0x20 | uVar11 >> 0x1b) + + (uVar23 ^ uVar18 ^ uVar19) + uVar20 + uVar7 + 0xca62c1d6; + uVar8 = uVar8 ^ uVar27 ^ uVar2 ^ uVar3; + uVar17 = uVar11 * 0x40000000 | uVar11 >> 2; + uVar8 = uVar8 >> 0x1f | uVar8 << 1; + uVar19 = (uVar20 * 0x20 | uVar20 >> 0x1b) + + (uVar18 ^ uVar21 ^ uVar11) + uVar23 + uVar9 + 0xca62c1d6; + uVar1 = uVar1 ^ uVar24 ^ uVar13 ^ uVar7; + uVar22 = uVar20 * 0x40000000 | uVar20 >> 2; + uVar1 = uVar1 >> 0x1f | uVar1 << 1; + uVar11 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar21 ^ uVar17 ^ uVar20) + uVar18 + uVar8 + 0xca62c1d6; + uVar18 = uVar27 ^ uVar14 ^ uVar10 ^ uVar9; + uVar23 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar26 = uVar18 >> 0x1f | uVar18 << 1; + uVar19 = (uVar11 * 0x20 | uVar11 >> 0x1b) + + (uVar17 ^ uVar22 ^ uVar19) + uVar21 + uVar1 + 0xca62c1d6; + uVar21 = uVar24 ^ uVar6 ^ uVar5 ^ uVar8; + uVar18 = uVar11 * 0x40000000 | uVar11 >> 2; + uVar24 = uVar21 >> 0x1f | uVar21 << 1; + uVar17 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar22 ^ uVar23 ^ uVar11) + uVar17 + uVar26 + 0xca62c1d6; + uVar11 = uVar14 ^ uVar28 ^ uVar4 ^ uVar1; + uVar21 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar11 = uVar11 >> 0x1f | uVar11 << 1; + uVar20 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar23 ^ uVar18 ^ uVar19) + uVar22 + uVar24 + 0xca62c1d6; + uVar6 = uVar6 ^ uVar25 ^ uVar3 ^ uVar26; + uVar14 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar6 = uVar6 >> 0x1f | uVar6 << 1; + uVar19 = (uVar20 * 0x20 | uVar20 >> 0x1b) + + (uVar18 ^ uVar21 ^ uVar17) + uVar23 + uVar11 + 0xca62c1d6; + uVar17 = uVar28 ^ uVar2 ^ uVar7 ^ uVar24; + uVar22 = uVar20 * 0x40000000 | uVar20 >> 2; + uVar27 = uVar17 >> 0x1f | uVar17 << 1; + uVar17 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar21 ^ uVar14 ^ uVar20) + uVar18 + uVar6 + 0xca62c1d6; + uVar18 = uVar25 ^ uVar13 ^ uVar9 ^ uVar11; + uVar23 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar20 = uVar18 >> 0x1f | uVar18 << 1; + uVar19 = (uVar17 * 0x20 | uVar17 >> 0x1b) + + (uVar14 ^ uVar22 ^ uVar19) + uVar21 + uVar27 + 0xca62c1d6; + uVar2 = uVar2 ^ uVar10 ^ uVar8 ^ uVar6; + uVar18 = uVar17 * 0x40000000 | uVar17 >> 2; + uVar2 = uVar2 >> 0x1f | uVar2 << 1; + uVar8 = (uVar19 * 0x20 | uVar19 >> 0x1b) + + (uVar22 ^ uVar23 ^ uVar17) + uVar14 + uVar20 + 0xca62c1d6; + uVar27 = uVar13 ^ uVar5 ^ uVar1 ^ uVar27; + uVar13 = uVar19 * 0x40000000 | uVar19 >> 2; + uVar21 = uVar27 >> 0x1f | uVar27 << 1; + uVar14 = uVar22 + uVar2 + 0xca62c1d6 + (uVar23 ^ uVar18 ^ uVar19) + (uVar8 * 0x20 | uVar8 >> 0x1b) + ; + uVar20 = uVar10 ^ uVar4 ^ uVar26 ^ uVar20; + uVar10 = (uVar14 * 0x20 | uVar14 >> 0x1b) + + (uVar18 ^ uVar13 ^ uVar8) + uVar23 + uVar21 + 0xca62c1d6; + uVar1 = uVar8 * 0x40000000 | uVar8 >> 2; + uVar17 = uVar20 >> 0x1f | uVar20 << 1; + uVar2 = uVar5 ^ uVar3 ^ uVar24 ^ uVar2; + uVar5 = uVar18 + uVar17 + 0xca62c1d6 + (uVar13 ^ uVar1 ^ uVar14) + + (uVar10 * 0x20 | uVar10 >> 0x1b); + uVar8 = uVar14 * 0x40000000 | uVar14 >> 2; + uVar21 = uVar4 ^ uVar7 ^ uVar11 ^ uVar21; + uVar4 = uVar13 + (uVar2 << 1 | uVar2 >> 0x1f) + 0xca62c1d6 + (uVar1 ^ uVar8 ^ uVar10) + + (uVar5 * 0x20 | uVar5 >> 0x1b); + uVar7 = uVar10 * 0x40000000 | uVar10 >> 2; + uVar17 = uVar3 ^ uVar9 ^ uVar6 ^ uVar17; + uVar1 = uVar1 + (uVar21 << 1 | uVar21 >> 0x1f) + 0xca62c1d6 + (uVar8 ^ uVar7 ^ uVar5) + + (uVar4 * 0x20 | uVar4 >> 0x1b); + uVar2 = uVar5 * 0x40000000 | uVar5 >> 2; + uVar12 = ctx->state[1]; + ctx->state[0] = + uVar8 + (uVar17 << 1 | uVar17 >> 0x1f) + uVar15 + 0xca62c1d6 + (uVar7 ^ uVar2 ^ uVar4) + + (uVar1 * 0x20 | uVar1 >> 0x1b); + ctx->state[1] = uVar1 + uVar12; + ctx->state[2] = uVar16 + (uVar4 >> 2 | uVar4 * 0x40000000); + ctx->state[3] = uVar2 + ctx->state[3]; + ctx->state[4] = uVar7 + ctx->state[4]; + return; +} + + + +void mbedtls_sha1_update(mbedtls_sha1_context *ctx,uchar *input,size_t ilen) + +{ + size_t __n; + uint uVar1; + uint uVar2; + uint __n_00; + + uVar2 = ctx->total[0] & 0x3f; + uVar1 = ctx->total[0] + ilen; + ctx->total[0] = uVar1; + if (uVar1 < ilen) { + ctx->total[1] = ctx->total[1] + 1; + } + uVar1 = ilen; + if ((uVar2 != 0) && (__n_00 = 0x40 - uVar2, __n_00 <= ilen)) { + memcpy(ctx->buffer + uVar2,input,__n_00); + ilen = (ilen - 0x40) + uVar2; + mbedtls_sha1_process(ctx,ctx->buffer); + input = input + __n_00; + uVar2 = 0; + uVar1 = ilen; + } + while (0x3f < ilen) { + mbedtls_sha1_process(ctx,input + (uVar1 - ilen)); + ilen = ilen - 0x40; + } + __n = (uVar1 >> 6) * -0x40 + uVar1; + if (__n == 0) { + return; + } + memcpy(ctx->buffer + uVar2,input + (uVar1 & 0xffffffc0),__n); + return; +} + + + +void mbedtls_sha1_update(mbedtls_sha1_context *ctx,uchar *input,size_t ilen) + +{ + if (ilen != 0) { + mbedtls_sha1_update(ctx,input,ilen); + return; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void mbedtls_sha1_finish(mbedtls_sha1_context *ctx,uchar *output) + +{ + uint uVar1; + uint uVar2; + int iVar3; + uchar uStack24; + undefined uStack23; + ushort uStack22; + uchar msglen [8]; + + uVar1 = ctx->total[0]; + uVar2 = ctx->total[1] << 3; + uStack24 = (uchar)(uVar2 >> 0x18); + uStack23 = (undefined)(uVar2 >> 0x10); + uStack22 = (ushort)(uVar2 >> 8) & 0xff | (ushort)((uVar2 | uVar1 >> 0x1d) << 8); + msglen[0] = (uchar)((uVar1 << 3) >> 0x18); + msglen[1] = (uchar)((uVar1 << 3) >> 0x10); + msglen._2_2_ = (ushort)((uVar1 << 0x13) >> 0x18) | (ushort)(uVar1 << 0xb); + if ((uVar1 & 0x3f) < 0x38) { + iVar3 = 0x38; + } + else { + iVar3 = 0x78; + } + mbedtls_sha1_update(ctx,sha1_padding,iVar3 - (uVar1 & 0x3f)); + mbedtls_sha1_update(ctx,&uStack24,8); + *output = *(uchar *)((int)ctx->state + 3); + output[1] = (uchar)*(undefined2 *)((int)ctx->state + 2); + output[2] = (uchar)(ctx->state[0] >> 8); + output[3] = (uchar)ctx->state[0]; + output[4] = *(uchar *)((int)ctx->state + 7); + output[5] = (uchar)*(undefined2 *)((int)ctx->state + 6); + output[6] = (uchar)(ctx->state[1] >> 8); + output[7] = (uchar)ctx->state[1]; + output[8] = *(uchar *)((int)ctx->state + 0xb); + output[9] = (uchar)*(undefined2 *)((int)ctx->state + 10); + output[10] = (uchar)(ctx->state[2] >> 8); + output[0xb] = (uchar)ctx->state[2]; + output[0xc] = *(uchar *)((int)ctx->state + 0xf); + output[0xd] = (uchar)*(undefined2 *)((int)ctx->state + 0xe); + output[0xe] = (uchar)(ctx->state[3] >> 8); + output[0xf] = (uchar)ctx->state[3]; + output[0x10] = *(uchar *)((int)ctx->state + 0x13); + output[0x11] = (uchar)*(undefined2 *)((int)ctx->state + 0x12); + output[0x12] = (uchar)(ctx->state[4] >> 8); + output[0x13] = (uchar)ctx->state[4]; + return; +} + + + +void mbedtls_sha1(uchar *input,size_t ilen,uchar *output) + +{ + undefined auStack108 [4]; + mbedtls_sha1_context ctx; + + mbedtls_sha1_init((mbedtls_sha1_context *)auStack108); + mbedtls_sha1_starts((mbedtls_sha1_context *)auStack108); + mbedtls_sha1_update((mbedtls_sha1_context *)auStack108,input,ilen); + mbedtls_sha1_finish((mbedtls_sha1_context *)auStack108,output); + mbedtls_sha1_free((mbedtls_sha1_context *)auStack108); + return; +} + + + +mbedtls_ssl_ciphersuite_t * mbedtls_ssl_ciphersuite_from_id(int ciphersuite) + +{ + mbedtls_ssl_ciphersuite_t *pmVar1; + + pmVar1 = ciphersuite_definitions; + while( true ) { + if (pmVar1->id == 0) { + return (mbedtls_ssl_ciphersuite_t *)0x0; + } + if (pmVar1->id == ciphersuite) break; + pmVar1 = pmVar1 + 1; + } + return pmVar1; +} + + + +int * mbedtls_ssl_list_ciphersuites(void) + +{ + int *piVar1; + int *piVar2; + mbedtls_ssl_ciphersuite_t *pmVar3; + int ciphersuite; + + if (supported_init == 0) { + piVar1 = supported_ciphersuites; + piVar2 = ciphersuite_preference; + while ((ciphersuite = *piVar2, ciphersuite != 0 && (piVar1 < supported_ciphersuites + 5))) { + pmVar3 = mbedtls_ssl_ciphersuite_from_id(ciphersuite); + if (pmVar3 != (mbedtls_ssl_ciphersuite_t *)0x0) { + *piVar1 = ciphersuite; + piVar1 = piVar1 + 1; + } + piVar2 = piVar2 + 1; + } + *piVar1 = 0; + supported_init = 1; + } + return supported_ciphersuites; +} + + + +char * mbedtls_ssl_get_ciphersuite_name(int ciphersuite_id) + +{ + mbedtls_ssl_ciphersuite_t *pmVar1; + char *pcVar2; + + pmVar1 = mbedtls_ssl_ciphersuite_from_id(ciphersuite_id); + if (pmVar1 == (mbedtls_ssl_ciphersuite_t *)0x0) { + pcVar2 = "unknown"; + } + else { + pcVar2 = pmVar1->name; + } + return pcVar2; +} + + + +mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_pk_alg(mbedtls_ssl_ciphersuite_t *info) + +{ + mbedtls_pk_type_t mVar1; + uint uVar2; + + if (info->key_exchange < MBEDTLS_KEY_EXCHANGE_ECJPAKE) { + uVar2 = 1 << ((uint)info->key_exchange & 0x1f); + mVar1 = MBEDTLS_PK_RSA; + if (((uVar2 & 0x8e) == 0) && (mVar1 = MBEDTLS_PK_ECKEY, (uVar2 & 0x600) == 0)) { + return (mbedtls_pk_type_t)(((uVar2 & 0x10) != 0) << 2); + } + } + else { + mVar1 = MBEDTLS_PK_NONE; + } + return mVar1; +} + + + +mbedtls_pk_context * mbedtls_ssl_own_key(mbedtls_ssl_context *ssl) + +{ + mbedtls_ssl_key_cert *pmVar1; + + if (((ssl->handshake != (mbedtls_ssl_handshake_params *)0x0) && + (pmVar1 = ssl->handshake->key_cert, pmVar1 != (mbedtls_ssl_key_cert *)0x0)) || + (pmVar1 = ssl->conf->key_cert, pmVar1 != (mbedtls_ssl_key_cert *)0x0)) { + pmVar1 = (mbedtls_ssl_key_cert *)pmVar1->key; + } + return (mbedtls_pk_context *)pmVar1; +} + + + +size_t mbedtls_ssl_hs_hdr_len(void) + +{ + int in_a0; + + if ((*(ushort *)(in_a0 + 0x74) & 2) != 0) { + return 0xc; + } + return 4; +} + + + +// WARNING: Type propagation algorithm not settling + +int mbedtls_ssl_handshake_client_step(mbedtls_ssl_context *ssl) + +{ + uchar uVar1; + mbedtls_key_exchange_type_t mVar2; + byte bVar3; + byte bVar4; + byte bVar5; + byte bVar6; + bool bVar7; + uchar *puVar8; + uchar *puVar9; + uchar uVar10; + uint ret; + mbedtls_ssl_session *pmVar11; + size_t __n; + mbedtls_x509_crt *pmVar12; + mbedtls_pk_context *pk; + size_t len; + mbedtls_md_type_t md_alg; + int line; + int line_00; + char *format; + uint __n_00; + size_t sVar13; + uchar *buf; + int *piVar14; + undefined *puVar15; + mbedtls_ssl_config *pmVar16; + mbedtls_ssl_key_cert *pmVar17; + uchar *buf_00; + ushort *puVar18; + byte *buf_01; + mbedtls_ssl_handshake_params *pmVar19; + uint size; + mbedtls_ssl_ciphersuite_t *ciphersuite_info; + uchar *puVar20; + uint uVar21; + byte *pbVar22; + uchar *puVar23; + mbedtls_ssl_transform *pmVar24; + char **ppcVar25; + uchar *ver; + byte *buf_02; + uchar *puVar26; + size_t local_74; + int major_ver; + int minor_ver; + + if (ssl->state == 0x10) { + return -0x7100; + } + if (ssl->handshake == (mbedtls_ssl_handshake_params *)0x0) { + return -0x7100; + } + mbedtls_debug_print_msg(ssl,2,"file1",0xccf,"client state: %d"); + ret = mbedtls_ssl_flush_output(ssl); + if (ret != 0) { + return ret; + } + if ((((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) && + (ssl->handshake->retransmit_state == '\x01')) && + (line_00 = mbedtls_ssl_resend(ssl), line_00 != 0)) { + return line_00; + } + if ((ssl->state == 0xc) && (ssl->handshake->new_session_ticket != 0)) { + ssl->state = 0x11; + } + __n_00 = ssl->state; + switch(__n_00) { + case 0: + ssl->state = 1; + break; + case 1: + mbedtls_debug_print_msg(ssl,2,"file1",0x2cd,"=> write client hello"); + pmVar16 = ssl->conf; + if (pmVar16->f_rng == (mbedtls_ssl_recv_t *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x2d1,"no RNG provided"); + return -0x7400; + } + ssl->major_ver = (uint)pmVar16->min_major_ver; + ssl->minor_ver = (uint)pmVar16->min_minor_ver; + if (pmVar16->max_major_ver == 0) { + mbedtls_debug_print_msg + (ssl,1,"file1",0x2e0, + + "configured max major version is invalid, consider using mbedtls_ssl_config_defaults()" + ); + return -0x7100; + } + ver = ssl->out_msg; + mbedtls_ssl_write_version + ((uint)pmVar16->max_major_ver,(uint)pmVar16->max_minor_ver, + *(uint *)&pmVar16->field_0x74 >> 1 & 1,ver + 4); + mbedtls_debug_print_msg + (ssl,3,"file1",0x2f3,"client hello, max version: [%d:%d]",(uint)ver[4],(uint)ver[5]); + pmVar16 = ssl->conf; + pmVar19 = ssl->handshake; + if ((((*(ushort *)&pmVar16->field_0x74 & 2) == 0) || (pmVar19->verify_cookie == (uchar *)0x0)) + && ((ret = (*pmVar16->f_rng)(pmVar16->p_rng,pmVar19->randbytes,4), ret != 0 || + (ret = (*ssl->conf->f_rng)(ssl->conf->p_rng,pmVar19->randbytes + 4,0x1c), ret != 0)))) { + format = "ssl_generate_random"; + line_00 = 0x2f7; + } + else { + memcpy(ver + 6,ssl->handshake->randbytes,0x20); + mbedtls_debug_print_buf(ssl,3,"file1",0x2fc,"client hello, random bytes",ver + 6,0x20); + pmVar11 = ssl->session_negotiate; + len = pmVar11->id_len; + if ((0x10 < len - 0x10) || (ssl->handshake->resume == 0)) { + len = 0; + } + if ((pmVar11->ticket != (uchar *)0x0) && (pmVar11->ticket_len != 0)) { + line_00 = (*ssl->conf->f_rng)(ssl->conf->p_rng,pmVar11->id,0x20); + if (line_00 != 0) { + return line_00; + } + len = 0x20; + ssl->session_negotiate->id_len = 0x20; + } + ver[0x26] = (uchar)len; + sVar13 = 0; + while (len != sVar13) { + ver[sVar13 + 0x27] = ssl->session_negotiate->id[sVar13]; + sVar13 = sVar13 + 1; + } + puVar20 = ver + 0x27 + len; + mbedtls_debug_print_msg(ssl,3,"file1",0x331,"client hello, session id len.: %d",len); + mbedtls_debug_print_buf(ssl,3,"file1",0x332,"client hello, session id",ver + 0x27,len); + buf_00 = puVar20; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + buf_00 = puVar20 + 1; + buf = ssl->handshake->verify_cookie; + if (buf == (uchar *)0x0) { + mbedtls_debug_print_msg(ssl,3,"file1",0x33c,"no verify cookie to send"); + *puVar20 = '\0'; + } + else { + mbedtls_debug_print_buf + (ssl,3,"file1",0x343,"client hello, cookie",buf, + (uint)ssl->handshake->verify_cookie_len); + *puVar20 = ssl->handshake->verify_cookie_len; + memcpy(buf_00,ssl->handshake->verify_cookie,(uint)ssl->handshake->verify_cookie_len); + buf_00 = buf_00 + ssl->handshake->verify_cookie_len; + } + } + piVar14 = ssl->conf->ciphersuite_list[ssl->minor_ver]; + line_00 = 0; + puVar20 = buf_00 + 2; + while (*piVar14 != 0) { + ciphersuite_info = mbedtls_ssl_ciphersuite_from_id(*piVar14); + buf = puVar20; + if ((((ciphersuite_info != (mbedtls_ssl_ciphersuite_t *)0x0) && + (pmVar16 = ssl->conf, + ciphersuite_info->min_minor_ver <= (int)(uint)pmVar16->max_minor_ver)) && + ((int)(uint)pmVar16->min_minor_ver <= ciphersuite_info->max_minor_ver)) && + (((*(ushort *)&pmVar16->field_0x74 & 2) == 0 || ((ciphersuite_info->flags & 4) == 0)))) { + mbedtls_debug_print_msg + (ssl,3,"file1",0x375,"client hello, add ciphersuite: %04x",*piVar14); + line_00 = line_00 + 1; + buf = puVar20 + 2; + *puVar20 = (uchar)((uint)*piVar14 >> 8); + puVar20[1] = (uchar)*piVar14; + } + piVar14 = piVar14 + 1; + puVar20 = buf; + } + puVar20[1] = -1; + *puVar20 = '\0'; + *buf_00 = (uchar)(line_00 + 1U >> 7); + buf_00[1] = (char)(line_00 + 1U) * '\x02'; + mbedtls_debug_print_msg(ssl,3,"file1",0x396,"client hello, got %d ciphersuites"); + mbedtls_debug_print_msg(ssl,3,"file1",0x3b5,"client hello, compress len.: %d",1); + mbedtls_debug_print_msg(ssl,3,"file1",0x3b7,"client hello, compress alg.: %d",0); + puVar20[2] = '\x01'; + puVar20[3] = '\0'; + buf_00 = puVar20 + 4; + buf = puVar20 + 6; + puVar23 = (uchar *)0x0; + if (ssl->hostname != (char *)0x0) { + puVar8 = ssl->out_msg; + mbedtls_debug_print_msg(ssl,3,"file1",0x48,"client hello, adding server name extension: %s") + ; + __n = strlen(ssl->hostname); + if ((puVar8 + 0x4000 < buf) || + (puVar23 = (uchar *)(__n + 9), puVar8 + 0x4000 + -(int)buf < puVar23)) { + mbedtls_debug_print_msg(ssl,1,"file1",0x4e,"buffer too small"); + puVar23 = (uchar *)0x0; + } + else { + puVar20[8] = (uchar)(__n + 5 >> 8); + uVar10 = (uchar)__n; + puVar20[9] = uVar10 + '\x05'; + puVar20[10] = (uchar)(__n + 3 >> 8); + puVar20[0xb] = uVar10 + '\x03'; + puVar20[6] = '\0'; + puVar20[7] = '\0'; + puVar20[0xc] = '\0'; + puVar20[0xd] = (uchar)(__n >> 8); + puVar20[0xe] = uVar10; + memcpy(puVar20 + 0xf,ssl->hostname,__n); + } + } + line_00 = 0; + if (ssl->conf->max_minor_ver == '\x03') { + puVar8 = ssl->out_msg; + mbedtls_debug_print_msg + (ssl,3,"file1",0xb2,"client hello, adding signature_algorithms extension"); + piVar14 = ssl->conf->sig_hashes; + line_00 = 0; + while (*(int *)(line_00 * 2 + (int)piVar14) != 0) { + line_00 = line_00 + 2; + } + puVar9 = puVar23 + 2 + (int)buf_00; + if ((puVar8 + 0x4000 < puVar9) || (puVar8 + 0x4000 + -(int)puVar9 < (uchar *)(line_00 + 6))) + { + mbedtls_debug_print_msg(ssl,1,"file1",0xc0,"buffer too small"); + line_00 = 0; + } + else { + puVar8 = puVar9 + 6; + line_00 = 0; + while( true ) { + line = *(int *)(line_00 * 2 + (int)piVar14); + if (line == 0) break; + uVar10 = mbedtls_ssl_hash_from_md_alg(line); + *puVar8 = uVar10; + puVar8[1] = '\x01'; + puVar8 = puVar8 + 2; + line_00 = line_00 + 2; + } + puVar9[1] = '\r'; + puVar9[3] = (uchar)line_00 + '\x02'; + *puVar9 = '\0'; + puVar9[2] = (uchar)((uint)(line_00 + 2) >> 8); + puVar9[4] = (uchar)((uint)line_00 >> 8); + puVar9[5] = (uchar)line_00; + line_00 = line_00 + 6; + } + } + puVar23 = puVar23 + line_00; + line_00 = 0; + if ((*(ushort *)&ssl->conf->field_0x74 & 0x1c0) != 0) { + puVar9 = ssl->out_msg; + puVar8 = buf_00 + (int)(puVar23 + 2); + mbedtls_debug_print_msg + (ssl,3,"file1",0x1b8,"client hello, adding max_fragment_length extension"); + if ((puVar9 + 0x4000 < puVar8) || (puVar9 + 0x4000 + -(int)puVar8 < &DAT_00000005)) { + mbedtls_debug_print_msg(ssl,1,"file1",0x1bc,"buffer too small"); + line_00 = 0; + } + else { + *puVar8 = '\0'; + puVar8[1] = '\x01'; + puVar8[2] = '\0'; + puVar8[3] = '\x01'; + puVar8[4] = (byte)(*(uint *)&ssl->conf->field_0x74 >> 6) & 7; + line_00 = 5; + } + } + puVar23 = puVar23 + line_00; + buf_02 = (byte *)0x0; + if (ssl->conf->alpn_list != (char **)0x0) { + puVar8 = ssl->out_msg; + mbedtls_debug_print_msg(ssl,3,"file1",0x26c,"client hello, adding alpn extension"); + ppcVar25 = ssl->conf->alpn_list; + while (*ppcVar25 != (char *)0x0) { + __n = strlen(*ppcVar25); + buf_02 = buf_02 + (__n & 0xff) + 1; + ppcVar25 = ppcVar25 + 1; + } + puVar9 = buf_00 + (int)(puVar23 + 2); + if ((puVar8 + 0x4000 < puVar9) || (puVar8 + 0x4000 + -(int)puVar9 < buf_02 + 6)) { + mbedtls_debug_print_msg(ssl,1,"file1",0x273,"buffer too small"); + buf_02 = (byte *)0x0; + } + else { + *puVar9 = '\0'; + puVar9[1] = '\x10'; + buf_02 = puVar9 + 6; + ppcVar25 = ssl->conf->alpn_list; + while (*ppcVar25 != (char *)0x0) { + __n = strlen(*ppcVar25); + *buf_02 = (byte)__n; + memcpy(buf_02 + 1,*ppcVar25,__n & 0xff); + ppcVar25 = ppcVar25 + 1; + buf_02 = buf_02 + (uint)*buf_02 + 1; + } + buf_02 = buf_02 + -(int)puVar9; + puVar9[4] = (uchar)((uint)(buf_02 + -6) >> 8); + puVar9[5] = (char)buf_02 + -6; + puVar9[2] = (uchar)((uint)(buf_02 + -4) >> 8); + puVar9[3] = (char)buf_02 + -4; + } + } + puVar8 = (uchar *)0x0; + if ((*(ushort *)&ssl->conf->field_0x74 & 0x200) != 0) { + puVar26 = ssl->out_msg; + puVar9 = buf_00 + (int)(buf_02 + (int)puVar23 + 2); + __n = ssl->session_negotiate->ticket_len; + mbedtls_debug_print_msg(ssl,3,"file1",0x23f,"client hello, adding session ticket extension") + ; + if ((puVar26 + 0x4000 < puVar9) || + (puVar8 = (uchar *)(__n + 4), puVar26 + 0x4000 + -(int)puVar9 < puVar8)) { + mbedtls_debug_print_msg(ssl,1,"file1",0x243,"buffer too small"); + puVar8 = (uchar *)0x0; + } + else { + puVar9[1] = '#'; + *puVar9 = '\0'; + puVar9[2] = (uchar)(__n >> 8); + puVar9[3] = (uchar)__n; + if ((ssl->session_negotiate->ticket == (uchar *)0x0) || (__n == 0)) { + puVar8 = &DAT_00000004; + } + else { + mbedtls_debug_print_msg(ssl,3,"file1",0x254,"sending session ticket of length %d",__n); + memcpy(puVar9 + 4,ssl->session_negotiate->ticket,__n); + } + } + } + puVar8 = puVar8 + (int)(buf_02 + (int)puVar23); + mbedtls_debug_print_msg(ssl,3,"file1",0x3ff,"client hello, total extension length: %d",puVar8) + ; + if (puVar8 != (uchar *)0x0) { + puVar20[4] = (uchar)((uint)puVar8 >> 8); + puVar20[5] = (uchar)puVar8; + buf_00 = buf + (int)puVar8; + } + ssl->out_msgtype = 0x16; + *(uchar **)&ssl->out_msglen = buf_00 + -(int)ver; + *ssl->out_msg = '\x01'; + ssl->state = ssl->state + 1; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + mbedtls_ssl_send_flight_completed(ssl); + } + ret = mbedtls_ssl_write_record(ssl); + if (ret == 0) { + format = "<= write client hello"; + line_00 = 0x419; + goto LAB_2306920e; + } + format = "mbedtls_ssl_write_record"; + line_00 = 0x415; + } + goto LAB_230690ee; + case 2: + mbedtls_debug_print_msg(ssl,2,"file1",0x582,"=> parse server hello"); + buf_02 = ssl->in_msg; + ret = mbedtls_ssl_read_record(ssl); + if (ret == 0) { + if (ssl->in_msgtype == 0x16) { + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + if (*buf_02 == 3) { + mbedtls_debug_print_msg(ssl,2,"file1",0x5a9,"received hello verify request"); + mbedtls_debug_print_msg(ssl,2,"file1",0x5aa,"<= parse server hello"); + len = mbedtls_ssl_hs_hdr_len(); + ver = ssl->in_msg + len; + mbedtls_debug_print_msg(ssl,2,"file1",0x52e,"=> parse hello verify request"); + mbedtls_debug_print_buf(ssl,3,"file1",0x536,"server version",ver,2); + mbedtls_ssl_read_version + ((int *)&local_74,&major_ver,*(uint *)&ssl->conf->field_0x74 >> 1 & 1,ver); + if (((((int)local_74 < 3) || (major_ver < 2)) || + ((int)(uint)ssl->conf->max_major_ver < (int)local_74)) || + ((int)(uint)ssl->conf->max_minor_ver < major_ver)) { + mbedtls_debug_print_msg(ssl,1,"file1",0x543,"bad server version"); + goto LAB_2306935a; + } + buf_00 = ver + 3; + bVar3 = ver[2]; + __n_00 = (uint)bVar3; + mbedtls_debug_print_buf(ssl,3,"file1",0x54c,"cookie",buf_00,__n_00); + if ((int)(ssl->in_msg + (ssl->in_msglen - (int)buf_00)) < (int)__n_00) { + mbedtls_debug_print_msg + (ssl,1,"file1",0x551,"cookie length does not match incoming message size"); + mbedtls_ssl_send_alert_message(ssl,'\x02','2'); + return -0x7980; + } + vPortFree(ssl->handshake->verify_cookie); + pmVar19 = ssl->handshake; + ver = (uchar *)mycalloc(1,__n_00); + pmVar19->verify_cookie = ver; + ver = ssl->handshake->verify_cookie; + if (ver == (uchar *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x55c,"alloc failed (%d bytes)",__n_00); + return -0x7f00; + } + memcpy(ver,buf_00,__n_00); + ssl->handshake->verify_cookie_len = bVar3; + ssl->state = 1; + mbedtls_ssl_reset_checksum(ssl); + mbedtls_ssl_recv_flight_completed(ssl); + format = "<= parse hello verify request"; + line_00 = 0x569; + goto LAB_2306920e; + } + vPortFree(ssl->handshake->verify_cookie); + ssl->handshake->verify_cookie = (uchar *)0x0; + ssl->handshake->verify_cookie_len = '\0'; + } + len = mbedtls_ssl_hs_hdr_len(); + if ((ssl->in_hslen < len + 0x26) || (bVar3 = *buf_02, bVar3 != 2)) { + line_00 = 0x5ba; + } + else { + buf_02 = buf_02 + len; + mbedtls_debug_print_buf(ssl,3,"file1",0x5cb,"server hello, version",buf_02,2); + mbedtls_ssl_read_version + (&ssl->major_ver,&ssl->minor_ver,*(uint *)&ssl->conf->field_0x74 >> 1 & 1,buf_02 + ); + pmVar16 = ssl->conf; + if (((ssl->major_ver < (int)(uint)pmVar16->min_major_ver) || + (ssl->minor_ver < (int)(uint)pmVar16->min_minor_ver)) || + (((int)(uint)pmVar16->max_major_ver < ssl->major_ver || + ((int)(uint)pmVar16->max_minor_ver < ssl->minor_ver)))) { + mbedtls_debug_print_msg + (ssl,1,"file1",0x5d8, + "server version out of bounds - min: [%d:%d], server: [%d:%d], max: [%d:%d]" + ); +LAB_2306935a: + mbedtls_ssl_send_alert_message(ssl,'\x02','F'); + return -0x6e80; + } + mbedtls_debug_print_msg + (ssl,3,"file1",0x5e5,"server hello, current time: %lu", + (uint)buf_02[4] << 8 | + (uint)buf_02[2] << 0x18 | (uint)buf_02[3] << 0x10 | (uint)buf_02[5]); + memcpy(ssl->handshake->randbytes + 0x20,buf_02 + 2,0x20); + bVar4 = buf_02[0x22]; + size = (uint)bVar4; + mbedtls_debug_print_buf(ssl,3,"file1",0x5ec,"server hello, random bytes",buf_02 + 2,0x20); + if (bVar4 < 0x21) { + __n_00 = ssl->in_hslen; + len = mbedtls_ssl_hs_hdr_len(); + line_00 = len + size; + if (line_00 + 0x27U < __n_00) { + uVar21 = (uint)CONCAT11((buf_02 + size)[0x26],(buf_02 + size)[0x27]); + if ((uVar21 - 1 <= (uint)bVar3) || (__n_00 != line_00 + uVar21 + 0x28)) { + line_00 = 0x5fc; + goto LAB_2306948e; + } + } + else { + uVar21 = 0; + if (__n_00 != line_00 + 0x26U) { + line_00 = 0x606; + goto LAB_2306948e; + } + } + __n_00 = (uint)CONCAT11((buf_02 + size)[0x23],(buf_02 + size)[0x24]); + if (buf_02[size + 0x25] != 0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x621,"server hello, bad compression: %d"); + return -0x7080; + } + pmVar24 = ssl->transform_negotiate; + ciphersuite_info = mbedtls_ssl_ciphersuite_from_id(__n_00); + pmVar24->ciphersuite_info = ciphersuite_info; + ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + if (ciphersuite_info == (mbedtls_ssl_ciphersuite_t *)0x0) { + format = "ciphersuite info for %04x not found"; + line_00 = 0x62c; +LAB_2306966a: + mbedtls_debug_print_msg(ssl,1,"file1",line_00,format,__n_00); + return -0x7100; + } + mbedtls_ssl_optimize_checksum(ssl,ciphersuite_info); + mbedtls_debug_print_msg(ssl,3,"file1",0x632,"server hello, session id len.: %d",size); + buf_01 = buf_02 + 0x23; + mbedtls_debug_print_buf(ssl,3,"file1",0x633,"server hello, session id",buf_01,size); + if ((((ssl->handshake->resume == 0) || (bVar4 == 0)) || + (pmVar11 = ssl->session_negotiate, __n_00 != pmVar11->ciphersuite)) || + (((pmVar11->compression != 0 || (size != pmVar11->id_len)) || + (line_00 = memcmp(pmVar11->id,buf_01,size), line_00 != 0)))) { + ssl->state = ssl->state + 1; + ssl->handshake->resume = 0; + ssl->session_negotiate->ciphersuite = __n_00; + ssl->session_negotiate->compression = 0; + ssl->session_negotiate->id_len = size; + memcpy(ssl->session_negotiate->id,buf_01,size); + } + else { + ssl->state = 0xc; + line_00 = mbedtls_ssl_derive_keys(ssl); + if (line_00 != 0) { + mbedtls_debug_print_ret(ssl,1,"file1",0x651,"mbedtls_ssl_derive_keys",line_00); + return line_00; + } + } + if (ssl->handshake->resume == 0) { + puVar15 = &UNK_2308c4d8; + } + else { + puVar15 = (undefined *)0x230873f4; + } + mbedtls_debug_print_msg(ssl,3,"file1",0x657,"%s session has been resumed",puVar15); + mbedtls_debug_print_msg + (ssl,3,"file1",0x659,"server hello, chosen ciphersuite: %04x",__n_00); + mbedtls_debug_print_msg + (ssl,3,"file1",0x65a,"server hello, compress alg.: %d", + (uint)buf_02[size + 0x25]); + ciphersuite_info = mbedtls_ssl_ciphersuite_from_id(ssl->session_negotiate->ciphersuite); + if (ciphersuite_info == (mbedtls_ssl_ciphersuite_t *)0x0) { + line_00 = 0x664; + } + else { + mbedtls_debug_print_msg + (ssl,3,"file1",0x668,"server hello, chosen ciphersuite: %s", + ciphersuite_info->name); + piVar14 = ssl->conf->ciphersuite_list[ssl->minor_ver]; + do { + line_00 = *piVar14; + if (line_00 == 0) { + line_00 = 0x66f; + goto LAB_2306948e; + } + piVar14 = piVar14 + 1; + } while (line_00 != ssl->session_negotiate->ciphersuite); + ssl->session_negotiate->compression = 0; + puVar18 = (ushort *)(buf_02 + size + 0x28); + mbedtls_debug_print_msg + (ssl,2,"file1",0x687,"server hello, total extension length: %d",uVar21); + do { + if (uVar21 == 0) { + if ((ssl->secure_renegotiation == 0) && + ((*(ushort *)&ssl->conf->field_0x74 & 0x30) == 0x20)) { + line_00 = -0x430; + line = 0x720; +LAB_23069934: + mbedtls_debug_print_msg + (ssl,1,"file1",line,(char *)((int)&PTR_caseD_e_2308d000 + line_00)); + line_00 = mbedtls_ssl_send_fatal_handshake_failure(ssl); + if (line_00 == 0) { + return -0x7980; + } + return line_00; + } + format = "<= parse server hello"; + line_00 = 0x743; + goto LAB_2306920e; + } + __n_00 = (uint)(*puVar18 >> 8) | ((uint)*puVar18 & 0xff) << 8; + size = ((uint)puVar18[1] & 0xff) << 8 | (uint)(puVar18[1] >> 8); + if (uVar21 < size + 4) { + line_00 = 0x692; + goto LAB_2306948e; + } + if (__n_00 == 0x10) { + mbedtls_debug_print_msg(ssl,3,"file1",0x703,"found alpn extension"); + ppcVar25 = ssl->conf->alpn_list; + if (ppcVar25 == (char **)0x0) { + return -0x7980; + } + if (size < 4) { + return -0x7980; + } + if (((uint)(puVar18[2] >> 8) | ((uint)puVar18[2] & 0xff) << 8) != size - 2) { + return -0x7980; + } + __n_00 = (uint)*(byte *)(puVar18 + 3); + if (__n_00 != size - 3) { + return -0x7980; + } + while( true ) { + if (*ppcVar25 == (char *)0x0) { + return -0x7980; + } + __n = strlen(*ppcVar25); + if ((__n_00 == __n) && + (line_00 = memcmp((byte *)((int)puVar18 + 7),*ppcVar25,__n_00), line_00 == 0) + ) break; + ppcVar25 = ppcVar25 + 1; + } + ssl->alpn_chosen = *ppcVar25; + } + else { + if (__n_00 < 0x11) { + if (__n_00 == 1) { + mbedtls_debug_print_msg + (ssl,3,"file1",0x6a6,"found max_fragment_length extension"); + if ((*(ushort *)&ssl->conf->field_0x74 & 0x1c0) == 0) { + return -0x7980; + } + if (size != 1) { + return -0x7980; + } + if ((uint)*(byte *)(puVar18 + 2) != (*(uint *)&ssl->conf->field_0x74 >> 6 & 7) + ) { + return -0x7980; + } + } + else { +LAB_230698de: + mbedtls_debug_print_msg + (ssl,3,"file1",0x70d,"unknown extension found: %d (ignoring)"); + } + } + else { + if (__n_00 == 0x23) { + mbedtls_debug_print_msg(ssl,3,"file1",0x6da,"found session_ticket extension"); + if ((*(ushort *)&ssl->conf->field_0x74 & 0x200) == 0) { + return -0x7980; + } + if (size != 0) { + return -0x7980; + } + ssl->handshake->new_session_ticket = 1; + } + else { + if (__n_00 != 0xff01) goto LAB_230698de; + mbedtls_debug_print_msg(ssl,3,"file1",0x699,"found renegotiation extension"); + if ((size != 1) || (*(byte *)(puVar18 + 2) != 0)) { + line_00 = -0x4d8; + line = 0x43c; + goto LAB_23069934; + } + ssl->secure_renegotiation = 1; + } + } + } + line_00 = uVar21 - size; + uVar21 = line_00 - 4; + puVar18 = (ushort *)((int)puVar18 + size + 4); + } while (2 < line_00 - 5U); + line_00 = 0x715; + } + } + else { + line_00 = 0x5f0; + } + } +LAB_2306948e: + mbedtls_debug_print_msg(ssl,1,"file1",line_00,"bad server hello message"); + return -0x7980; + } + format = "bad server hello message"; + line_00 = 0x5a0; +LAB_2306926a: + line = 1; +LAB_23069270: + mbedtls_debug_print_msg(ssl,line,"file1",line_00,format); + return -0x7700; + } + format = "mbedtls_ssl_read_record"; + line_00 = 0x588; + goto LAB_230690ee; + case 3: + __n_00 = mbedtls_ssl_parse_certificate(ssl); + break; + case 4: + ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + mbedtls_debug_print_msg(ssl,2,"file1",0x896,"=> parse server key exchange"); + if (ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA) { + format = "<= skip parse server key exchange"; + line_00 = 0x89b; +LAB_23069ac2: + mbedtls_debug_print_msg(ssl,2,"file1",line_00,format); + line_00 = ssl->state + 1; + __n_00 = ret; + goto LAB_23069ad4; + } + ret = mbedtls_ssl_read_record(ssl); + if (ret == 0) { + if (ssl->in_msgtype == 0x16) { + ver = ssl->in_msg; + if (*ver == '\f') { + len = mbedtls_ssl_hs_hdr_len(); + mbedtls_debug_print_buf + (ssl,3,"file1",0x8d6,"server key exchange",ver + len,ssl->in_hslen - len); + line_00 = 0x91b; + goto LAB_23069b94; + } + if ((ciphersuite_info->key_exchange & 0xfd) == 5) { + ssl->record_read = 1; + ssl->state = ssl->state + 1; + format = "<= parse server key exchange"; + line_00 = 0x9d4; + goto LAB_2306920e; + } + format = "bad server key exchange message"; + line_00 = 0x8d0; + } + else { + format = "bad server key exchange message"; + line_00 = 0x8bf; + } + goto LAB_2306926a; + } + format = "mbedtls_ssl_read_record"; + line_00 = 0x8b9; + goto LAB_230690ee; + case 5: + ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + mbedtls_debug_print_msg(ssl,2,"file1",0x9fc,"=> parse certificate request"); + mVar2 = ciphersuite_info->key_exchange; + if (((byte)(mVar2 + ~MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA) < 4) || + (mVar2 == MBEDTLS_KEY_EXCHANGE_ECJPAKE)) { + format = "<= skip parse certificate request"; + line_00 = 0xa04; + goto LAB_23069ac2; + } + if (ssl->record_read == 0) { + line_00 = mbedtls_ssl_read_record(ssl); + if (line_00 != 0) { + line = 0xa0d; + goto LAB_23069c12; + } + if (ssl->in_msgtype != 0x16) { + format = "bad certificate request message"; + line_00 = 0xa13; + goto LAB_2306926a; + } + ssl->record_read = 1; + } + ssl->client_auth = 0; + ssl->state = ssl->state + 1; + if (*ssl->in_msg == '\r') { + ssl->client_auth = 1; + puVar15 = (undefined *)0x230873f4; + } + else { + puVar15 = &UNK_2308c4d8; + } + mbedtls_debug_print_msg(ssl,3,"file1",0xa21,"got %s certificate request",puVar15); + if (ssl->client_auth != 0) { + ver = ssl->in_msg; + ssl->record_read = 0; + len = mbedtls_ssl_hs_hdr_len(); + buf_01 = (byte *)(uint)ver[len]; + buf_02 = buf_01 + len; + if ((byte *)ssl->in_hslen < buf_02 + 2) { + line_00 = 0xa48; +LAB_23069cc2: + mbedtls_debug_print_msg(ssl,1,"file1",line_00,"bad certificate request message"); + return -0x7a80; + } + if (ssl->minor_ver == 3) { + uVar10 = ver[(int)(buf_02 + 1)]; + uVar1 = ver[(int)(buf_02 + 2)]; + pbVar22 = ver + (int)(buf_02 + 3); + while (pbVar22 + -(int)(ver + (int)(buf_02 + 3)) < (byte *)(uint)CONCAT11(uVar10,uVar1)) { + mbedtls_debug_print_msg + (ssl,3,"file1",0xa58,"Supported Signature Algorithm found: %d,%d",(uint)*pbVar22 + ,(uint)pbVar22[1]); + pbVar22 = pbVar22 + 2; + } + buf_01 = (byte *)(uint)CONCAT11(uVar10,uVar1) + (int)(buf_01 + 2); + len = mbedtls_ssl_hs_hdr_len(); + if ((byte *)ssl->in_hslen < buf_01 + len + 2) { + line_00 = 0xa60; + goto LAB_23069cc2; + } + } + len = mbedtls_ssl_hs_hdr_len(); + buf_01 = buf_01 + len; + if ((byte *)ssl->in_hslen != + buf_01 + (uint)CONCAT11((ver + (int)buf_01)[1],(ver + (int)buf_01)[2]) + 3) { + line_00 = 0xa6d; + goto LAB_23069cc2; + } + } + format = "<= parse certificate request"; + line_00 = 0xa72; + goto LAB_2306920e; + case 6: + mbedtls_debug_print_msg(ssl,2,"file1",0xa81,"=> parse server hello done"); + if (ssl->record_read == 0) { + line_00 = mbedtls_ssl_read_record(ssl); + if (line_00 != 0) { + line = 0xa87; +LAB_23069c12: + mbedtls_debug_print_ret(ssl,1,"file1",line,"mbedtls_ssl_read_record",line_00); + return line_00; + } + if (ssl->in_msgtype != 0x16) { + format = "bad server hello done message"; + line_00 = 0xa8d; + goto LAB_2306926a; + } + } + pmVar16 = ssl->conf; + ssl->record_read = 0; + len = mbedtls_ssl_hs_hdr_len(); + if ((ssl->in_hslen != len) || (*ssl->in_msg != '\x0e')) { + mbedtls_debug_print_msg(ssl,1,"file1",0xa96,"bad server hello done message"); + return -0x7b80; + } + ssl->state = ssl->state + 1; + if ((*(ushort *)&pmVar16->field_0x74 & 2) != 0) { + mbedtls_ssl_recv_flight_completed(ssl); + } + format = "<= parse server hello done"; + line_00 = 0xaa1; +LAB_2306920e: + mbedtls_debug_print_msg(ssl,2,"file1",line_00,format); + __n_00 = ret; + break; + case 7: + __n_00 = mbedtls_ssl_write_certificate(ssl); + break; + case 8: + ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + mbedtls_debug_print_msg(ssl,2,"file1",0xaac,"=> write client key exchange"); + if (ciphersuite_info->key_exchange != MBEDTLS_KEY_EXCHANGE_RSA) { + line_00 = 0xb91; +LAB_23069b94: + mbedtls_debug_print_msg(ssl,1,"file1",line_00,"should never happen"); + return -0x6c00; + } + pmVar16 = ssl->conf; + pmVar19 = ssl->handshake; + line_00 = ssl->minor_ver; + ver = pmVar19->premaster; + mbedtls_ssl_write_version + ((uint)pmVar16->max_major_ver,(uint)pmVar16->max_minor_ver, + *(uint *)&pmVar16->field_0x74 >> 1 & 1,ver); + bVar7 = line_00 != 0; + ret = (*ssl->conf->f_rng)(ssl->conf->p_rng,pmVar19->premaster + 2,0x2e); + line_00 = (uint)bVar7 * 2 + 4; + if (ret == 0) { + ssl->handshake->pmslen = 0x30; + pmVar12 = ssl->session_negotiate->peer_cert; + if (pmVar12 == (mbedtls_x509_crt *)0x0) { + format = "certificate required"; + line_00 = 0x801; + line = 2; + goto LAB_23069270; + } + line = mbedtls_pk_can_do(&pmVar12->pk,MBEDTLS_PK_RSA); + if (line == 0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x80b,"certificate key type mismatch"); + return -0x6d00; + } + ret = mbedtls_pk_encrypt(&ssl->session_negotiate->peer_cert->pk,ver,ssl->handshake->pmslen, + ssl->out_msg + line_00,(size_t *)&major_ver,0x4000 - line_00, + (anon_subr_int_void_ptr_uchar_ptr_size_t *)ssl->conf->f_rng, + ssl->conf->p_rng); + if (ret == 0) { + if (bVar7) { + ssl->out_msg[4] = (uchar)((uint)major_ver >> 8); + ssl->out_msg[5] = (uchar)major_ver; + major_ver = major_ver + 2; + } + ssl->out_msglen = major_ver + 4; + ssl->out_msgtype = 0x16; + *ssl->out_msg = '\x10'; + ssl->state = ssl->state + 1; + ret = mbedtls_ssl_write_record(ssl); + if (ret == 0) { + format = "<= write client key exchange"; + line_00 = 0xba1; + goto LAB_2306920e; + } + format = "mbedtls_ssl_write_record"; + line_00 = 0xb9d; + } + else { + format = "mbedtls_rsa_pkcs1_encrypt"; + line_00 = 0x815; + } + } + else { + format = "f_rng"; + line_00 = 0x7f9; + } + goto LAB_230690ee; + case 9: + ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; + local_74 = 0; + mbedtls_debug_print_msg(ssl,2,"file1",0xbd2,"=> write certificate verify"); + ret = mbedtls_ssl_derive_keys(ssl); + if (ret == 0) { + mVar2 = ciphersuite_info->key_exchange; + if (((byte)(mVar2 + ~MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA) < 4) || + (mVar2 == MBEDTLS_KEY_EXCHANGE_ECJPAKE)) { + format = "<= skip write certificate verify"; + line_00 = 0xbe0; + } + else { + if ((ssl->client_auth != 0) && + ((((pmVar19 = ssl->handshake, pmVar19 != (mbedtls_ssl_handshake_params *)0x0 && + (pmVar17 = pmVar19->key_cert, pmVar17 != (mbedtls_ssl_key_cert *)0x0)) || + (pmVar17 = ssl->conf->key_cert, pmVar17 != (mbedtls_ssl_key_cert *)0x0)) && + (pmVar17->cert != (mbedtls_x509_crt *)0x0)))) { + pk = mbedtls_ssl_own_key(ssl); + if (pk == (mbedtls_pk_context *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0xbee,"got no private key for certificate"); + return -0x7600; + } + (*pmVar19->calc_verify)(ssl,(uchar *)&major_ver); + if (ssl->minor_ver != 3) { + line_00 = 0xc3d; + goto LAB_23069b94; + } + md_alg = ssl->transform_negotiate->ciphersuite_info->mac; + if (md_alg == MBEDTLS_MD_SHA384) { + ssl->out_msg[4] = '\x05'; + } + else { + ssl->out_msg[4] = '\x04'; + md_alg = MBEDTLS_MD_SHA256; + } + pk = mbedtls_ssl_own_key(ssl); + ver = ssl->out_msg; + uVar10 = mbedtls_ssl_sig_from_pk(pk); + ver[5] = uVar10; + pk = mbedtls_ssl_own_key(ssl); + ret = mbedtls_pk_sign(pk,md_alg,(uchar *)&major_ver,0,ssl->out_msg + 8,&local_74, + (anon_subr_int_void_ptr_uchar_ptr_size_t *)ssl->conf->f_rng, + ssl->conf->p_rng); + if (ret == 0) { + ssl->out_msg[6] = (uchar)(local_74 >> 8); + ssl->out_msg[7] = (uchar)local_74; + ssl->out_msglen = local_74 + 8; + ssl->out_msgtype = 0x16; + *ssl->out_msg = '\x0f'; + ssl->state = ssl->state + 1; + ret = mbedtls_ssl_write_record(ssl); + if (ret == 0) { + format = "<= write certificate verify"; + line_00 = 0xc58; + goto LAB_2306920e; + } + format = "mbedtls_ssl_write_record"; + line_00 = 0xc54; + } + else { + format = "mbedtls_pk_sign"; + line_00 = 0xc45; + } + goto LAB_230690ee; + } + format = "<= skip write certificate verify"; + line_00 = 0xbe7; + } + goto LAB_23069ac2; + } + format = "mbedtls_ssl_derive_keys"; + line_00 = 0xbd6; + goto LAB_230690ee; + case 10: + __n_00 = mbedtls_ssl_write_change_cipher_spec(ssl); + break; + case 0xb: + __n_00 = mbedtls_ssl_write_finished(ssl); + break; + case 0xc: + __n_00 = mbedtls_ssl_parse_change_cipher_spec(ssl); + break; + case 0xd: + __n_00 = mbedtls_ssl_parse_finished(ssl); + break; + case 0xe: + mbedtls_debug_print_msg(ssl,2,"file1",0xd3e,"handshake: done"); + line_00 = 0xf; + __n_00 = ret; +LAB_23069ad4: + ssl->state = line_00; + break; + case 0xf: + mbedtls_ssl_handshake_wrapup(ssl); + __n_00 = ret; + break; + default: + format = "invalid state %d"; + line_00 = 0xd47; + goto LAB_2306966a; + case 0x11: + mbedtls_debug_print_msg(ssl,2,"file1",0xc6c,"=> parse new session ticket"); + ret = mbedtls_ssl_read_record(ssl); + if (ret == 0) { + if (ssl->in_msgtype == 0x16) { + ver = ssl->in_msg; + if (*ver == '\x04') { + __n_00 = ssl->in_hslen; + len = mbedtls_ssl_hs_hdr_len(); + if (len + 6 <= __n_00) { + buf_02 = ver + len; + bVar3 = *buf_02; + size = ((uint)*(ushort *)(buf_02 + 4) & 0xff) << 8 | + (uint)(*(ushort *)(buf_02 + 4) >> 8); + bVar4 = buf_02[1]; + bVar5 = buf_02[2]; + bVar6 = buf_02[3]; + if (__n_00 != len + 6 + size) { + line_00 = 0xc94; + goto LAB_2306a270; + } + mbedtls_debug_print_msg(ssl,3,"file1",0xc98,"ticket length: %d",size); + ssl->handshake->new_session_ticket = 0; + ssl->state = 0xc; + if (size == 0) { + return 0; + } + buf_00 = ssl->session_negotiate->ticket; + ver = buf_00 + ssl->session_negotiate->ticket_len; + while (buf_00 != ver) { + *buf_00 = '\0'; + buf_00 = buf_00 + 1; + } + vPortFree(ssl->session_negotiate->ticket); + ssl->session_negotiate->ticket = (uchar *)0x0; + ssl->session_negotiate->ticket_len = 0; + ver = (uchar *)mycalloc(1,size); + if (ver == (uchar *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0xcad,"ticket alloc failed"); + return -0x7f00; + } + memcpy(ver,buf_02 + 6,size); + ssl->session_negotiate->ticket = ver; + ssl->session_negotiate->ticket_len = size; + ssl->session_negotiate->ticket_lifetime = + (uint)bVar3 << 0x18 | (uint)bVar4 << 0x10 | (uint)bVar6 | (uint)bVar5 << 8; + mbedtls_debug_print_msg(ssl,3,"file1",0xcbc,"ticket in use, discarding session id"); + format = "<= parse new session ticket"; + ssl->session_negotiate->id_len = 0; + line_00 = 0xcbf; + goto LAB_2306920e; + } + } + line_00 = 0xc87; +LAB_2306a270: + mbedtls_debug_print_msg(ssl,1,"file1",line_00,"bad new session ticket message"); + return -0x6e00; + } + format = "bad new session ticket message"; + line_00 = 0xc76; + goto LAB_2306926a; + } + format = "mbedtls_ssl_read_record"; + line_00 = 0xc70; +LAB_230690ee: + mbedtls_debug_print_ret(ssl,1,"file1",line_00,format,ret); + __n_00 = ret; + } + return __n_00; +} + + + +mbedtls_pk_context * mbedtls_ssl_own_key(mbedtls_ssl_context *ssl) + +{ + mbedtls_ssl_key_cert *pmVar1; + + if (((ssl->handshake != (mbedtls_ssl_handshake_params *)0x0) && + (pmVar1 = ssl->handshake->key_cert, pmVar1 != (mbedtls_ssl_key_cert *)0x0)) || + (pmVar1 = ssl->conf->key_cert, pmVar1 != (mbedtls_ssl_key_cert *)0x0)) { + pmVar1 = (mbedtls_ssl_key_cert *)pmVar1->key; + } + return (mbedtls_pk_context *)pmVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int mbedtls_ssl_handshake_server_step(mbedtls_ssl_context *ssl) + +{ + byte bVar1; + mbedtls_key_exchange_type_t mVar2; + ushort uVar3; + char cVar4; + mbedtls_x509_crt *pmVar5; + ushort *buf; + uchar *__n; + uchar *puVar6; + mbedtls_ssl_handshake_params *pmVar7; + mbedtls_ssl_ciphersuite_t *info; + uchar message; + mbedtls_md_type_t md_alg; + mbedtls_pk_type_t type; + int ret; + int iVar8; + undefined3 extraout_var; + undefined3 extraout_var_00; + size_t __n_00; + undefined3 extraout_var_01; + mbedtls_pk_context *ctx; + size_t sVar9; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + ushort *puVar10; + uint uVar11; + int line; + mbedtls_ssl_config *pmVar12; + char *format; + anon_subr_int_void_ptr_mbedtls_ssl_session_ptr_for_f_get_cache *paVar13; + mbedtls_ssl_session *pmVar14; + undefined *puVar15; + uchar *buf_00; + uchar *hash; + uint sig_len; + byte *pbVar16; + byte *input; + uint ilen; + byte *buf_01; + uint uVar17; + byte *len; + uint *puVar18; + uchar *puVar19; + size_t len_00; + int *piVar20; + int line_00; + byte *pbVar21; + uint uVar22; + mbedtls_ssl_key_cert *pmVar23; + uchar *puVar24; + byte *pbVar25; + byte *pbVar26; + char **ppcVar27; + mbedtls_ssl_key_cert *pmVar28; + byte bStack236; + byte bStack235; + uchar ver [2]; + int major; + int minor; + undefined4 local_b4; + mbedtls_ssl_session session; + + if ((ssl->state == 0x10) || (ssl->handshake == (mbedtls_ssl_handshake_params *)0x0)) { + return -0x7100; + } + mbedtls_debug_print_msg(ssl,2,"file1",0xede,"server state: %d"); + ret = mbedtls_ssl_flush_output(ssl); + if (ret != 0) { + return ret; + } + if ((((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) && + (ssl->handshake->retransmit_state == '\x01')) && + (line_00 = mbedtls_ssl_resend(ssl), line_00 != 0)) { + return line_00; + } + line_00 = ssl->state; + switch(line_00) { + case 0: + ssl->state = 1; + break; + case 1: + mbedtls_debug_print_msg(ssl,2,"file1",0x440,"=> parse client hello"); + line = mbedtls_ssl_fetch_input(ssl,5); + if (line == 0) { + input = ssl->in_hdr; + len_00 = 5; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + len_00 = 0xd; + } + mbedtls_debug_print_buf(ssl,4,"file1",0x45f,"record header",input,len_00); + mbedtls_debug_print_msg(ssl,3,"file1",0x46b,"client hello v3, message type: %d",(uint)*input); + if (*input != 0x16) { + ret = 0x46f; + goto LAB_2306a59a; + } + mbedtls_debug_print_msg + (ssl,3,"file1",0x474,"client hello v3, message len.: %d", + ((uint)*(ushort *)ssl->in_len & 0xff) << 8 | (uint)(*(ushort *)ssl->in_len >> 8)); + mbedtls_debug_print_msg + (ssl,3,"file1",0x477,"client hello v3, protocol version: [%d:%d]",(uint)input[1], + (uint)input[2]); + mbedtls_ssl_read_version((int *)ver,&major,*(uint *)&ssl->conf->field_0x74 >> 1 & 1,input + 1) + ; + if ((int)_ver < 3) { + ret = 0x481; + goto LAB_2306a59a; + } + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + hash = ssl->in_ctr; + if ((*hash != '\0') || (hash[1] != '\0')) { + ret = 0x491; + goto LAB_2306a59a; + } + memcpy(ssl->out_ctr + 2,hash + 2,6); + } + ilen = ((uint)*(ushort *)ssl->in_len & 0xff) << 8 | (uint)(*(ushort *)ssl->in_len >> 8); + if (0x4000 < ilen) { + ret = 0x4b3; + goto LAB_2306a59a; + } + ret = 5; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + ret = 0xd; + } + iVar8 = mbedtls_ssl_fetch_input(ssl,ret + ilen); + if (iVar8 != 0) { + format = "mbedtls_ssl_fetch_input"; + ret = 0x4b9; + line_00 = iVar8; + goto LAB_2306a528; + } + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) { + ssl->in_left = 0; + } + else { + ssl->next_record_offset = ilen + 0xd; + } + input = ssl->in_msg; + mbedtls_debug_print_buf(ssl,4,"file1",0x4c8,"record contents",input,ilen); + (*ssl->handshake->update_checksum)(ssl,input,ilen); + sig_len = 4; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + sig_len = 0xc; + } + if (ilen < sig_len) { + ret = 0x4d6; + goto LAB_2306a59a; + } + mbedtls_debug_print_msg + (ssl,3,"file1",0x4da,"client hello v3, handshake type: %d",(uint)*input); + if (*input != 1) { + ret = 0x4de; + goto LAB_2306a59a; + } + mbedtls_debug_print_msg + (ssl,3,"file1",0x4e3,"client hello v3, handshake len.: %d", + (uint)input[1] << 0x10 | (uint)input[2] << 8 | (uint)input[3]); + if (input[1] == 0) { + ret = 4; + uVar3 = *(ushort *)&ssl->conf->field_0x74; + if ((uVar3 & 2) != 0) { + ret = 0xc; + } + if (ilen == ((uint)(*(ushort *)(input + 2) >> 8) | + ((uint)*(ushort *)(input + 2) & 0xff) << 8) + ret) { + if ((uVar3 & 2) == 0) { +LAB_2306a850: + ret = 4; + } + else { + sig_len = ((uint)*(ushort *)(ssl->in_msg + 4) & 0xff) << 8 | + (uint)(*(ushort *)(ssl->in_msg + 4) >> 8); + ssl->handshake->out_msg_seq = sig_len; + ssl->handshake->in_msg_seq = sig_len + 1; + hash = ssl->in_msg; + if ((((hash[6] != '\0') || (hash[7] != '\0')) || (hash[8] != '\0')) || + (ret = memcmp(hash + 1,hash + 9,3), ret != 0)) { + mbedtls_debug_print_msg(ssl,1,"file1",0x515,"ClientHello fragmentation not supported") + ; + return -0x7080; + } + ret = 0xc; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) == 0) goto LAB_2306a850; + } + input = input + ret; + pbVar21 = (byte *)(ilen - ret); + if (pbVar21 < (byte *)0x26) { + ret = 0x535; + goto LAB_2306a59a; + } + mbedtls_debug_print_buf(ssl,3,"file1",0x53c,"client hello, version",input,2); + mbedtls_ssl_read_version + (&ssl->major_ver,&ssl->minor_ver,*(uint *)&ssl->conf->field_0x74 >> 1 & 1,input) + ; + ssl->handshake->max_major_ver = ssl->major_ver; + ret = ssl->minor_ver; + ssl->handshake->max_minor_ver = ret; + pmVar12 = ssl->conf; + if ((ssl->major_ver < (int)(uint)pmVar12->min_major_ver) || + (ret < (int)(uint)pmVar12->min_minor_ver)) { + mbedtls_debug_print_msg + (ssl,1,"file1",0x54a, + "client only supports ssl smaller than minimum [%d:%d] < [%d:%d]"); + mbedtls_ssl_send_alert_message(ssl,'\x02','F'); + return -0x6e80; + } + if ((int)(uint)pmVar12->max_major_ver < ssl->major_ver) { + ssl->major_ver = (uint)pmVar12->max_major_ver; + ilen = (uint)pmVar12->max_minor_ver; +LAB_2306a910: + ssl->minor_ver = ilen; + } + else { + ilen = (uint)pmVar12->max_minor_ver; + if ((int)ilen < ret) goto LAB_2306a910; + } + mbedtls_debug_print_buf(ssl,3,"file1",0x55d,"client hello, random bytes",input + 2,0x20); + memcpy(ssl->handshake->randbytes,input + 2,0x20); + ilen = (uint)input[0x22]; + if ((0x20 < input[0x22]) || (len = (byte *)(ilen + 0x24), pbVar21 < len)) { + ret = 0x569; + goto LAB_2306a59a; + } + mbedtls_debug_print_buf(ssl,3,"file1",0x56d,"client hello, session id",input + 0x23,ilen); + ssl->session_negotiate->id_len = ilen; + buf_01 = (byte *)(ilen + 0x23); + memset(ssl->session_negotiate->id,0,0x20); + memcpy(ssl->session_negotiate->id,input + 0x23,ssl->session_negotiate->id_len); + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + bVar1 = input[(int)buf_01]; + if (pbVar21 < buf_01 + (uint)bVar1 + 3) { + ret = 0x580; + goto LAB_2306a59a; + } + mbedtls_debug_print_buf + (ssl,3,"file1",0x585,"client hello, cookie",input + (int)len,(uint)bVar1); + if (bVar1 != 0) { + ret = 0x5a1; + goto LAB_2306a59a; + } + mbedtls_debug_print_msg(ssl,2,"file1",0x5a5,"cookie verification skipped"); + buf_01 = len; + } + bVar1 = (input + (int)buf_01)[1]; + uVar3 = CONCAT11(input[(int)buf_01],bVar1); + len = (byte *)(uint)uVar3; + if (1 < uVar3) { + pbVar25 = len + (int)buf_01; + if ((pbVar25 + 3 <= pbVar21) && (ilen = (uint)len & 1, (bVar1 & 1) == 0)) { + buf_01 = input + (int)(buf_01 + 2); + mbedtls_debug_print_buf + (ssl,3,"file1",0x5bd,"client hello, ciphersuitelist",buf_01,(size_t)len); + sig_len = (uint)input[(int)(pbVar25 + 2)]; + if (sig_len - 1 < 0x10) { + pbVar26 = pbVar25 + 2 + sig_len; + pbVar16 = pbVar26 + 1; + if (pbVar16 <= pbVar21) { + mbedtls_debug_print_buf + (ssl,3,"file1",0x5cf,"client hello, compression", + input + (int)(pbVar25 + 3),sig_len); + ssl->session_negotiate->compression = 0; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + ssl->session_negotiate->compression = 0; + } + pbVar25 = pbVar26 + 3; + if (pbVar16 < pbVar21) { + if (pbVar21 < pbVar25) { + ret = 0x5f0; + goto LAB_2306a59a; + } + ilen = (uint)CONCAT11(input[(int)pbVar16],input[(int)(pbVar26 + 2)]); + if ((ilen - 1 < 3) || (pbVar21 != pbVar25 + ilen)) { + ret = 0x5fa; + goto LAB_2306a59a; + } + } + buf = (ushort *)(input + (int)pbVar25); + mbedtls_debug_print_buf + (ssl,3,"file1",0x602,"client hello extensions",(uchar *)buf,ilen); + do { + input = buf_01; + if (ilen == 0) goto LAB_2306ab72; + sig_len = (uint)(*buf >> 8) | ((uint)*buf & 0xff) << 8; + uVar17 = ((uint)buf[1] & 0xff) << 8 | (uint)(buf[1] >> 8); + uVar22 = uVar17 + 4; + if (ilen < uVar22) { + ret = 0x60d; + goto LAB_2306a59a; + } + if (sig_len == 0xd) { + mbedtls_debug_print_msg + (ssl,3,"file1",0x62c,"found signature_algorithms extension"); + uVar3 = buf[2] >> 8; + if ((uVar17 == (((uint)buf[2] & 0xff) << 8 | (uint)uVar3) + 2) && + ((uVar3 & 1) == 0)) { + piVar20 = ssl->conf->sig_hashes; + while (*piVar20 != 0) { + puVar10 = buf + 3; + while (puVar10 < (ushort *)((int)buf + uVar22)) { + ret = *piVar20; + md_alg = mbedtls_ssl_md_alg_from_hash(*(byte *)puVar10); + if (ret == CONCAT31(extraout_var,md_alg)) { + line = 0xe4; + ssl->handshake->sig_alg = (uint)*(byte *)puVar10; + ret = 0x298; + sig_len = ssl->handshake->sig_alg; + goto LAB_2306aeda; + } + puVar10 = puVar10 + 1; + } + piVar20 = piVar20 + 1; + } + format = "no signature_algorithm in common"; + ret = 0xdf; + goto LAB_2306ae8c; + } + ret = 0xcb; + goto LAB_2306a59a; + } + if (sig_len < 0xe) { + if (sig_len == 0) { + mbedtls_debug_print_msg(ssl,3,"file1",0x614,"found ServerName extension"); + if (ssl->conf->f_sni != + ( + anon_subr_int_void_ptr_mbedtls_ssl_context_ptr_uchar_ptr_size_t_for_f_sni + *)0x0) { + mbedtls_debug_print_msg(ssl,3,"file1",0x62,"parse ServerName extension"); + sig_len = ((uint)buf[2] & 0xff) << 8 | (uint)(buf[2] >> 8); + if (uVar17 != sig_len + 2) { + ret = 0x67; + goto LAB_2306a59a; + } + puVar10 = buf + 3; + while (sig_len != 0) { + uVar11 = ((uint)*(ushort *)((int)puVar10 + 1) & 0xff) << 8 | + (uint)(*(ushort *)((int)puVar10 + 1) >> 8); + if (sig_len < uVar11 + 3) { + ret = 0x71; + goto LAB_2306a59a; + } + if (*(byte *)puVar10 == 0) { + ret = (*ssl->conf->f_sni)(ssl->conf->p_sni,ssl, + (byte *)((int)puVar10 + 3),uVar11); + if (ret != 0) { + mbedtls_debug_print_ret(ssl,1,"file1",0x7b,"ssl_sni_wrapper",ret); + message = 'p'; + goto LAB_2306adbc; + } + break; + } + sig_len = sig_len + (-3 - uVar11); + puVar10 = (ushort *)((int)puVar10 + uVar11 + 3); + } + } + } + else { + if (sig_len == 1) { + mbedtls_debug_print_msg + (ssl,3,"file1",0x65a,"found max fragment length extension"); + if ((uVar17 != 1) || (4 < *(byte *)(buf + 2))) { + ret = 0x16a; + goto LAB_2306a59a; + } + ssl->session_negotiate->mfl_code = *(byte *)(buf + 2); + } + else { +LAB_2306ac44: + ret = -0x458; + line = 0x696; +LAB_2306aeda: + mbedtls_debug_print_msg + (ssl,3,"file1",line,(char *)((int)&PTR_caseD_e_2308d000 + ret), + sig_len); + } + } + } + else { + if (sig_len == 0x23) { + mbedtls_debug_print_msg + (ssl,3,"file1",0x682,"found session ticket extension"); + mbedtls_ssl_session_init((mbedtls_ssl_session *)&local_b4); + if ((ssl->conf->f_ticket_parse != + ( + anon_subr_int_void_ptr_mbedtls_ssl_session_ptr_uchar_ptr_size_t_for_f_ticket_parse + *)0x0) && + (ssl->conf->f_ticket_write != + ( + anon_subr_int_void_ptr_mbedtls_ssl_session_ptr_uchar_ptr_uchar_ptr_size_t_ptr_uint32_t_ptr_for_f_ticket_write + *)0x0)) { + ssl->handshake->new_session_ticket = 1; + mbedtls_debug_print_msg(ssl,3,"file1",0x1c9,"ticket length: %d",uVar17); + if (uVar17 != 0) { + ret = (*ssl->conf->f_ticket_parse) + (ssl->conf->p_ticket,(mbedtls_ssl_session *)&local_b4, + (uchar *)(buf + 2),uVar17); + if (ret == 0) { + session.compression = ssl->session_negotiate->id_len; + memcpy(&session.id_len,ssl->session_negotiate->id,session.compression) + ; + mbedtls_ssl_session_free(ssl->session_negotiate); + memcpy(ssl->session_negotiate,&local_b4,0x74); + hash = &local_b4; + do { + *hash = '\0'; + hash = hash + 1; + } while (hash != &session.mfl_code); + mbedtls_debug_print_msg + (ssl,3,"file1",0x1f5, + "session successfully restored from ticket"); + ssl->handshake->resume = 1; + ssl->handshake->new_session_ticket = 0; + } + else { + mbedtls_ssl_session_free((mbedtls_ssl_session *)&local_b4); + if (ret == -0x7180) { + format = "ticket is not authentic"; + ret = 0x1df; + } + else { + if (ret != -0x6d80) { + mbedtls_debug_print_ret + (ssl,1,"file1",0x1e3,"mbedtls_ssl_ticket_parse",ret); + goto LAB_2306ad3a; + } + format = "ticket is expired"; + ret = 0x1e1; + } +LAB_2306ae8c: + mbedtls_debug_print_msg(ssl,3,"file1",ret,format); + } + } + } + } + else { + if (sig_len == 0xff01) { + mbedtls_debug_print_msg + (ssl,3,"file1",0x61f,"found renegotiation extension"); + if ((uVar17 != 1) || (*(byte *)(buf + 2) != 0)) { + format = "non-zero length renegotiation info"; + ret = 0xad; + goto LAB_2306ae02; + } + ssl->secure_renegotiation = 1; + } + else { + if (sig_len != 0x10) goto LAB_2306ac44; + mbedtls_debug_print_msg(ssl,3,"file1",0x68c,"found alpn extension"); + ppcVar27 = ssl->conf->alpn_list; + if (ppcVar27 != (char **)0x0) { + if (uVar17 < 4) { + return -0x7900; + } + if (((uint)(buf[2] >> 8) | ((uint)buf[2] & 0xff) << 8) != uVar17 - 2) { + return -0x7900; + } + while (*ppcVar27 != (char *)0x0) { + __n_00 = strlen(*ppcVar27); + puVar10 = buf + 3; + while ((ushort *)((int)buf + uVar22) != puVar10) { + if ((ushort *)((int)buf + uVar22) < puVar10) { + return -0x7900; + } + bVar1 = *(byte *)puVar10; + if (bVar1 == 0) { + return -0x7900; + } + if ((__n_00 == (uint)bVar1) && + (ret = memcmp((byte *)((int)puVar10 + 1),*ppcVar27,__n_00), + ret == 0)) { + ssl->alpn_chosen = *ppcVar27; + goto LAB_2306ad3a; + } + puVar10 = (ushort *)((byte *)((int)puVar10 + 1) + (uint)bVar1); + } + ppcVar27 = ppcVar27 + 1; + } + message = 'x'; +LAB_2306adbc: + mbedtls_ssl_send_alert_message(ssl,'\x02',message); + return -0x7900; + } + } + } + } +LAB_2306ad3a: + ret = ilen - uVar17; + ilen = ret - 4; + buf = (ushort *)((int)buf + uVar22); + } while (2 < ret - 5U); + ret = 0x69e; + goto LAB_2306a59a; + } + } + ret = 0x5ca; + goto LAB_2306a59a; + } + } + ret = 0x5b8; + goto LAB_2306a59a; + } + } + ret = 0x4e9; +LAB_2306a59a: + mbedtls_debug_print_msg(ssl,1,"file1",ret,"bad client hello message"); + return -0x7900; + } + format = "mbedtls_ssl_fetch_input"; + ret = 0x450; + line_00 = line; + goto LAB_2306a528; + case 2: + mbedtls_debug_print_msg(ssl,2,"file1",0x8b1,"=> write server hello"); + if (ssl->conf->f_rng == (mbedtls_ssl_recv_t *)0x0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x8c0,"no RNG provided"); + return -0x7400; + } + puVar24 = ssl->out_msg; + mbedtls_ssl_write_version + (ssl->major_ver,ssl->minor_ver,*(uint *)&ssl->conf->field_0x74 >> 1 & 1,puVar24 + 4); + mbedtls_debug_print_msg + (ssl,3,"file1",0x8d3,"server hello, chosen version: [%d:%d]",(uint)puVar24[4], + (uint)puVar24[5]); + hash = puVar24 + 6; + ret = (*ssl->conf->f_rng)(ssl->conf->p_rng,hash,4); + if (ret != 0) { + return ret; + } + ret = (*ssl->conf->f_rng)(ssl->conf->p_rng,puVar24 + 10,0x1c); + if (ret != 0) { + return ret; + } + memcpy(ssl->handshake->randbytes + 0x20,hash,0x20); + mbedtls_debug_print_buf(ssl,3,"file1",0x8eb,"server hello, random bytes",hash,0x20); + if ((ssl->handshake->resume == 0) && (ssl->session_negotiate->id_len != 0)) { + paVar13 = ssl->conf->f_get_cache; + if ((paVar13 != (anon_subr_int_void_ptr_mbedtls_ssl_session_ptr_for_f_get_cache *)0x0) && + (ret = (*paVar13)(ssl->conf->p_cache,ssl->session_negotiate), ret == 0)) { + mbedtls_debug_print_msg(ssl,3,"file1",0x8fa,"session successfully restored from cache"); + ssl->handshake->resume = 1; + } + } + pmVar14 = ssl->session_negotiate; + if (ssl->handshake->resume == 0) { + ssl->state = ssl->state + 1; + if (ssl->handshake->new_session_ticket == 0) { + pmVar14->id_len = 0x20; + len_00 = 0x20; + ret = (*ssl->conf->f_rng)(ssl->conf->p_rng,ssl->session_negotiate->id,0x20); + if (ret != 0) { + return ret; + } + } + else { + pmVar14->id_len = 0; + memset(ssl->session_negotiate->id,0,0x20); + len_00 = 0; + } + } + else { + len_00 = pmVar14->id_len; + ssl->state = 0xc; + line_00 = mbedtls_ssl_derive_keys(ssl); + if (line_00 != 0) { + format = "mbedtls_ssl_derive_keys"; + ret = 0x923; + goto LAB_2306a528; + } + } + hash = puVar24 + 0x27; + puVar24[0x26] = (uchar)ssl->session_negotiate->id_len; + memcpy(hash,ssl->session_negotiate->id,ssl->session_negotiate->id_len); + sVar9 = ssl->session_negotiate->id_len; + mbedtls_debug_print_msg(ssl,3,"file1",0x934,"server hello, session id len.: %d",len_00); + mbedtls_debug_print_buf(ssl,3,"file1",0x935,"server hello, session id",hash,len_00); + hash = hash + sVar9; + if (ssl->handshake->resume == 0) { + puVar15 = &UNK_2308c4d8; + } + else { + puVar15 = (undefined *)0x230873f4; + } + mbedtls_debug_print_msg(ssl,3,"file1",0x937,"%s session has been resumed",puVar15); + puVar19 = hash + 3; + *hash = (uchar)((uint)ssl->session_negotiate->ciphersuite >> 8); + hash[1] = (uchar)ssl->session_negotiate->ciphersuite; + hash[2] = (uchar)ssl->session_negotiate->compression; + format = mbedtls_ssl_get_ciphersuite_name(ssl->session_negotiate->ciphersuite); + mbedtls_debug_print_msg(ssl,3,"file1",0x93e,"server hello, chosen ciphersuite: %s",format); + mbedtls_debug_print_msg + (ssl,3,"file1",0x940,"server hello, compress alg.: 0x%02X", + ssl->session_negotiate->compression); + puVar6 = (uchar *)0x0; + if (ssl->secure_renegotiation == 1) { + mbedtls_debug_print_msg(ssl,3,"file1",0x7c3,"server hello, secure renegotiation extension"); + hash[5] = -1; + hash[6] = '\x01'; + hash[7] = '\0'; + hash[8] = '\x01'; + hash[9] = '\0'; + puVar6 = hash + (10 - (int)(hash + 5)); + } + ret = 0; + if (ssl->session_negotiate->mfl_code != '\0') { + mbedtls_debug_print_msg(ssl,3,"file1",0x7ec,"server hello, max_fragment_length extension"); + __n = puVar6 + 2 + (int)puVar19; + *__n = '\0'; + __n[1] = '\x01'; + __n[2] = '\0'; + __n[3] = '\x01'; + __n[4] = ssl->session_negotiate->mfl_code; + ret = 5; + } + puVar6 = puVar6 + ret; + ret = 0; + if (ssl->handshake->new_session_ticket != 0) { + mbedtls_debug_print_msg(ssl,3,"file1",0x7ab,"server hello, adding session ticket extension"); + __n = puVar19 + (int)(puVar6 + 2); + *__n = '\0'; + __n[1] = '#'; + __n[2] = '\0'; + __n[3] = '\0'; + ret = 4; + } + line_00 = 0; + if (ssl->alpn_chosen != (char *)0x0) { + mbedtls_debug_print_msg(ssl,3,"file1",0x84f,"server hello, adding alpn extension"); + __n = puVar19 + (int)(puVar6 + ret + 2); + __n[1] = '\x10'; + *__n = '\0'; + __n_00 = strlen(ssl->alpn_chosen); + line_00 = __n_00 + 7; + __n[2] = (uchar)(__n_00 + 3 >> 8); + cVar4 = (char)line_00; + __n[3] = cVar4 + -4; + __n[4] = (uchar)(__n_00 + 1 >> 8); + __n[5] = cVar4 + -6; + __n[6] = cVar4 + -7; + memcpy(__n + 7,ssl->alpn_chosen,__n_00); + } + puVar6 = puVar6 + ret + line_00; + mbedtls_debug_print_msg(ssl,3,"file1",0x977,"server hello, total extension length: %d",puVar6); + if (puVar6 != (uchar *)0x0) { + hash[3] = (uchar)((uint)puVar6 >> 8); + hash[4] = (uchar)puVar6; + puVar19 = hash + 5 + (int)puVar6; + } + ssl->out_msgtype = 0x16; + *(uchar **)&ssl->out_msglen = puVar19 + -(int)puVar24; + *ssl->out_msg = '\x02'; + line_00 = mbedtls_ssl_write_record(ssl); + format = "<= write server hello"; + line = 0x98a; + goto LAB_2306b2ac; + case 3: + line_00 = mbedtls_ssl_write_certificate(ssl); + break; + case 4: + info = ssl->transform_negotiate->ciphersuite_info; + mbedtls_debug_print_msg(ssl,2,"file1",0xa7f,"=> write server key exchange"); + mVar2 = info->key_exchange; + if (((mVar2 & 0xfb) == 1) || (mVar2 == MBEDTLS_KEY_EXCHANGE_RSA_PSK)) { + format = "<= skip write server key exchange"; + line_00 = 0xa88; +LAB_2306b7d0: + mbedtls_debug_print_msg(ssl,2,"file1",line_00,format); + line_00 = ssl->state + 1; + goto LAB_2306b7e2; + } + ssl->out_msglen = 4; + ssl->out_msgtype = 0x16; + *ssl->out_msg = '\f'; + ssl->state = ssl->state + 1; + line_00 = mbedtls_ssl_write_record(ssl); + if (line_00 != 0) { + format = "mbedtls_ssl_write_record"; + ret = 0xbd4; + goto LAB_2306a528; + } + format = "<= write server key exchange"; + line = 0xbd8; + goto LAB_2306b2ac; + case 5: + info = ssl->transform_negotiate->ciphersuite_info; + hash = ssl->out_msg; + mbedtls_debug_print_msg(ssl,2,"file1",0x9b5,"=> write certificate request"); + ssl->state = ssl->state + 1; + ilen = ssl->handshake->sni_authmode; + if (ilen == 3) { + ilen = *(uint *)&ssl->conf->field_0x74 >> 2 & 3; + } + mVar2 = info->key_exchange; + if ((((byte)(mVar2 + ~MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA) < 4) || + (mVar2 == MBEDTLS_KEY_EXCHANGE_ECJPAKE)) || (ilen == 0)) { + format = "<= skip write certificate request"; + line = 0x9c7; + line_00 = ret; + } + else { + puVar19 = ssl->out_msg; + ret = 0; + puVar19[5] = '\x01'; + puVar19[4] = '\x01'; + puVar6 = puVar19 + 6; + puVar24 = puVar6; + if (ssl->minor_ver == 3) { + line_00 = 0; + piVar20 = ssl->conf->sig_hashes; + while( true ) { + ret = line_00 + 2; + puVar24 = puVar6 + ret; + if (*piVar20 == 0) break; + message = mbedtls_ssl_hash_from_md_alg(*piVar20); + if ((CONCAT31(extraout_var_01,message) != 0) && + (line = mbedtls_ssl_set_calc_verify_md(ssl,CONCAT31(extraout_var_01,message)), + line == 0)) { + *puVar24 = message; + puVar6[line_00 + 3] = '\x01'; + line_00 = ret; + } + piVar20 = piVar20 + 1; + } + puVar19[6] = (uchar)((uint)line_00 >> 8); + puVar19[7] = (uchar)line_00; + } + puVar24 = puVar24 + 2; + pmVar5 = ssl->handshake->sni_ca_chain; + if (pmVar5 == (mbedtls_x509_crt *)0x0) { + pmVar5 = ssl->conf->ca_chain; + } + hash = hash + 0x4000; + puVar6 = (uchar *)0x0; + while( true ) { + if ((pmVar5 == (mbedtls_x509_crt *)0x0) || (pmVar5->version == 0)) goto LAB_2306b93e; + __n = (uchar *)(pmVar5->subject_raw).len; + if ((hash < puVar24) || ((hash + -(int)puVar24 < __n || (hash + -(int)puVar24 < __n + 2)))) + break; + *puVar24 = (uchar)((uint)__n >> 8); + puVar24[1] = (uchar)__n; + buf_00 = puVar24 + 2; + memcpy(buf_00,(pmVar5->subject_raw).p,(size_t)__n); + puVar24 = buf_00 + (int)__n; + puVar6 = __n + 2 + (int)puVar6; + mbedtls_debug_print_buf(ssl,3,"file1",0xa38,"requested DN",buf_00,(size_t)__n); + pmVar5 = pmVar5->next; + } + mbedtls_debug_print_msg(ssl,1,"file1",0xa2f,"skipping CAs: buffer too short"); +LAB_2306b93e: + *(uchar **)&ssl->out_msglen = puVar24 + -(int)puVar19; + ssl->out_msgtype = 0x16; + *ssl->out_msg = '\r'; + ssl->out_msg[ret + 6] = (uchar)((uint)puVar6 >> 8); + ssl->out_msg[ret + 7] = (uchar)puVar6; + line_00 = mbedtls_ssl_write_record(ssl); + format = "<= write certificate request"; + line = 0xa46; + } +LAB_2306b2ac: + mbedtls_debug_print_msg(ssl,2,"file1",line,format); + break; + case 6: + mbedtls_debug_print_msg(ssl,2,"file1",0xbe1,"=> write server hello done"); + ssl->out_msglen = 4; + ssl->out_msgtype = 0x16; + *ssl->out_msg = '\x0e'; + ssl->state = ssl->state + 1; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + mbedtls_ssl_send_flight_completed(ssl); + } + line_00 = mbedtls_ssl_write_record(ssl); + if (line_00 == 0) { + format = "<= write server hello done"; + line = 0xbf4; + goto LAB_2306b2ac; + } + format = "mbedtls_ssl_write_record"; + ret = 0xbf0; + goto LAB_2306a528; + case 7: + line_00 = mbedtls_ssl_parse_certificate(ssl); + break; + case 8: + info = ssl->transform_negotiate->ciphersuite_info; + mbedtls_debug_print_msg(ssl,2,"file1",0xcd4,"=> parse client key exchange"); + line_00 = mbedtls_ssl_read_record(ssl); + if (line_00 == 0) { + hash = ssl->in_msg; + ret = 4; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + ret = 0xc; + } + len_00 = ssl->in_hslen; + input = hash + ret; + if (ssl->in_msgtype == 0x16) { + if (*hash == '\x10') { + if (info->key_exchange != MBEDTLS_KEY_EXCHANGE_RSA) { + ret = 0xdb5; +LAB_2306b108: + mbedtls_debug_print_msg(ssl,1,"file1",ret,"should never happen"); + ret = -0x7000; + goto LAB_2306baec; + } + ctx = mbedtls_ssl_own_key(ssl); + sVar9 = mbedtls_pk_get_bitlen(ctx); + ctx = mbedtls_ssl_own_key(ssl); + ilen = sVar9 + 7 >> 3; + pmVar7 = ssl->handshake; + ret = mbedtls_pk_can_do(ctx,MBEDTLS_PK_RSA); + if (ret == 0) { + mbedtls_debug_print_msg(ssl,1,"file1",0xc34,"got no RSA private key"); + line_00 = -0x7600; + } + else { + if ((ssl->minor_ver == 0) || + (((uint)*input == (sVar9 + 7 >> 0xb & 0xff) && + (pbVar21 = input + 1, input = input + 2, (uint)*pbVar21 == (ilen & 0xff))))) { + if (hash + len_00 == input + ilen) { + mbedtls_ssl_write_version + (ssl->handshake->max_major_ver,ssl->handshake->max_minor_ver, + *(uint *)&ssl->conf->field_0x74 >> 1 & 1,&bStack236); + line_00 = (*ssl->conf->f_rng)(ssl->conf->p_rng,(uchar *)&major,0x30); + if (line_00 == 0) { + ctx = mbedtls_ssl_own_key(ssl); + ilen = mbedtls_pk_decrypt(ctx,input,ilen,&local_b4,(size_t *)ver,0x30, + (anon_subr_int_void_ptr_uchar_ptr_size_t *) + ssl->conf->f_rng,ssl->conf->p_rng); + ilen = ilen | (uint)(byte)((byte)local_b4 ^ bStack236 | local_b4._1_1_ ^ bStack235 + ) | _ver ^ 0x30; + ssl->handshake->pmslen = 0x30; + bVar1 = (char)((byte)(ilen >> 0x18) | (byte)(-ilen >> 0x18)) >> 7; + ilen = 0; + while (ilen < ssl->handshake->pmslen) { + pmVar7->premaster[ilen] = + (&local_b4)[ilen] & ~bVar1 | *(byte *)((int)&major + ilen) & bVar1; + ilen = ilen + 1; + } + line_00 = mbedtls_ssl_derive_keys(ssl); + if (line_00 == 0) { + ssl->state = ssl->state + 1; + format = "<= parse client key exchange"; + line = 0xdc1; + goto LAB_2306b2ac; + } + format = "mbedtls_ssl_derive_keys"; + ret = 0xdbb; + goto LAB_2306a528; + } + goto LAB_2306bb5c; + } + ret = 0xc4a; + } + else { + ret = 0xc42; + } + mbedtls_debug_print_msg(ssl,1,"file1",ret,"bad client key exchange message"); + line_00 = -0x7c00; + } +LAB_2306bb5c: + format = "ssl_parse_parse_encrypted_pms_secret"; + ret = 0xd98; + goto LAB_2306a528; + } + ret = 0xce7; + } + else { + ret = 0xce1; + } + mbedtls_debug_print_msg(ssl,1,"file1",ret,"bad client key exchange message"); + ret = -0x8000; +LAB_2306baec: + return ret + 0x400; + } + format = "mbedtls_ssl_read_record"; + ret = 0xcd8; + goto LAB_2306a528; + case 9: + info = ssl->transform_negotiate->ciphersuite_info; + mbedtls_debug_print_msg(ssl,2,"file1",0xdee,"=> parse certificate verify"); + mVar2 = info->key_exchange; + if ((((byte)(mVar2 + ~MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA) < 4) || + (mVar2 == MBEDTLS_KEY_EXCHANGE_ECJPAKE)) || + (ssl->session_negotiate->peer_cert == (mbedtls_x509_crt *)0x0)) { + format = "<= skip parse certificate verify"; + line_00 = 0xdf7; + goto LAB_2306b7d0; + } + do { + line_00 = mbedtls_ssl_read_record_layer(ssl); + if (line_00 != 0) { + format = "mbedtls_ssl_read_record_layer"; + ret = 0xe01; + goto LAB_2306a528; + } + line_00 = mbedtls_ssl_handle_message_type(ssl); + } while (line_00 == -0x6680); + if (line_00 == 0) { + ssl->state = ssl->state + 1; + if ((ssl->in_msgtype != 0x16) || (*ssl->in_msg != '\x0f')) { + format = "bad certificate verify message"; + ret = 0xe15; + goto LAB_2306bd9e; + } + ret = 4; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + ret = 0xc; + } + if (ssl->minor_ver != 3) { + ret = 0xe6c; + goto LAB_2306b108; + } + if (ssl->in_hslen < ret + 2U) { + format = "bad certificate verify message"; + ret = 0xe39; +LAB_2306bd9e: + mbedtls_debug_print_msg(ssl,1,"file1",ret,format); + return -0x7d80; + } + md_alg = mbedtls_ssl_md_alg_from_hash(ssl->in_msg[ret]); + if ((CONCAT31(extraout_var_02,md_alg) == 0) || + (line_00 = mbedtls_ssl_set_calc_verify_md(ssl,(uint)ssl->in_msg[ret]), line_00 != 0)) { + format = "peer not adhering to requested sig_alg for verify message"; + ret = 0xe45; + goto LAB_2306bd9e; + } + hash = &local_b4; + if (CONCAT31(extraout_var_02,md_alg) == 4) { + hash = session.id; + } + type = mbedtls_ssl_pk_alg_from_sig(ssl->in_msg[ret + 1]); + if (CONCAT31(extraout_var_03,type) == 0) { + format = "peer not adhering to requested sig_alg for verify message"; + ret = 0xe5a; + goto LAB_2306bd9e; + } + line_00 = mbedtls_pk_can_do(&ssl->session_negotiate->peer_cert->pk,type); + if (line_00 == 0) { + format = "sig_alg doesn\'t match cert key"; + ret = 0xe63; + goto LAB_2306bd9e; + } + ilen = ret + 4; + if (ssl->in_hslen < ilen) { + format = "bad certificate verify message"; + ret = 0xe72; + goto LAB_2306bd9e; + } + sig_len = (uint)CONCAT11(ssl->in_msg[ret + 2U],ssl->in_msg[ret + 3]); + if (ssl->in_hslen != ilen + sig_len) { + format = "bad certificate verify message"; + ret = 0xe7b; + goto LAB_2306bd9e; + } + (*ssl->handshake->calc_verify)(ssl,&local_b4); + line_00 = mbedtls_pk_verify(&ssl->session_negotiate->peer_cert->pk,md_alg,hash,0, + ssl->in_msg + ilen,sig_len); + if (line_00 == 0) { + mbedtls_ssl_update_handshake_status(ssl); + format = "<= parse certificate verify"; + line = 0xe8c; + goto LAB_2306b2ac; + } + format = "mbedtls_pk_verify"; + ret = 0xe86; + } + else { + format = "mbedtls_ssl_handle_message_type"; + ret = 0xe0b; + } + goto LAB_2306a528; + case 10: + line_00 = mbedtls_ssl_parse_change_cipher_spec(ssl); + break; + case 0xb: + line_00 = mbedtls_ssl_parse_finished(ssl); + break; + case 0xc: + if (ssl->handshake->new_session_ticket == 0) { + ret = mbedtls_ssl_write_change_cipher_spec(ssl); + return ret; + } + mbedtls_debug_print_msg(ssl,2,"file1",0xe9e,"=> write new session ticket"); + ssl->out_msgtype = 0x16; + *ssl->out_msg = '\x04'; + ret = (*ssl->conf->f_ticket_write) + (ssl->conf->p_ticket,ssl->session_negotiate,ssl->out_msg + 10, + ssl->out_msg + 0x4000,(size_t *)&major,(uint32_t *)&local_b4); + if (ret != 0) { + mbedtls_debug_print_ret(ssl,1,"file1",0xeb4,"mbedtls_ssl_ticket_write",ret); + major = 0; + } + ssl->out_msg[4] = (uchar)(local_b4 >> 0x18); + ssl->out_msg[5] = (uchar)(local_b4 >> 0x10); + ssl->out_msg[6] = (uchar)(local_b4 >> 8); + ssl->out_msg[7] = (uchar)local_b4; + ssl->out_msg[8] = (uchar)((uint)major >> 8); + ssl->out_msg[9] = (uchar)major; + ssl->out_msglen = major + 10; + ssl->handshake->new_session_ticket = 0; + line_00 = mbedtls_ssl_write_record(ssl); + if (line_00 == 0) { + format = "<= write new session ticket"; + line = 0xece; + goto LAB_2306b2ac; + } + format = "mbedtls_ssl_write_record"; + ret = 0xeca; +LAB_2306a528: + mbedtls_debug_print_ret(ssl,1,"file1",ret,format,line_00); + break; + case 0xd: + line_00 = mbedtls_ssl_write_finished(ssl); + break; + case 0xe: + mbedtls_debug_print_msg(ssl,2,"file1",0xf47,"handshake: done"); + line_00 = 0xf; +LAB_2306b7e2: + ssl->state = line_00; + line_00 = ret; + break; + case 0xf: + mbedtls_ssl_handshake_wrapup(ssl); + line_00 = ret; + break; + default: + mbedtls_debug_print_msg(ssl,1,"file1",0xf50,"invalid state %d",line_00); + return -0x7100; + case 0x12: + line_00 = -0x6a80; + } + return line_00; +LAB_2306ab72: + if ((*input == 0) && (input[1] == 0xff)) { + mbedtls_debug_print_msg(ssl,3,"file1",0x6c4,"received TLS_EMPTY_RENEGOTIATION_INFO "); + ssl->secure_renegotiation = 1; + goto LAB_2306aba0; + } + input = input + 2; + if (len <= input + -(int)buf_01) { + if ((ssl->secure_renegotiation != 1) && ((*(ushort *)&ssl->conf->field_0x74 & 0x30) == 0x20)) { + format = "legacy renegotiation, breaking off handshake"; + ret = 0x6db; +LAB_2306ae02: + mbedtls_debug_print_msg(ssl,1,"file1",ret,format); + ret = mbedtls_ssl_send_fatal_handshake_failure(ssl); + if (ret == 0) { + return -0x7900; + } + return ret; + } +LAB_2306aba0: + puVar18 = (uint *)ssl->conf->ciphersuite_list[ssl->minor_ver]; + ret = 0; + do { + input = buf_01; + if (*puVar18 == 0) { + if (ret == 0) { + mbedtls_debug_print_msg(ssl,1,"file1",0x728,"got no ciphersuites in common"); + mbedtls_ssl_send_fatal_handshake_failure(ssl); + return -0x7380; + } + mbedtls_debug_print_msg + (ssl,1,"file1",0x722,"got ciphersuites in common, but none of them usable"); + mbedtls_ssl_send_fatal_handshake_failure(ssl); + return -0x6980; + } + do { + ilen = *puVar18; + if (((uint)*input == ((int)ilen >> 8 & 0xffU)) && ((uint)input[1] == (ilen & 0xff))) { + info = mbedtls_ssl_ciphersuite_from_id(ilen); + if (info == (mbedtls_ssl_ciphersuite_t *)0x0) { + ret = 0x2cc; + goto LAB_2306b108; + } + mbedtls_debug_print_msg(ssl,3,"file1",0x2d0,"trying ciphersuite: %s",info->name); + ret = line_00; + if ((ssl->minor_ver < info->min_minor_ver) || (info->max_minor_ver < ssl->minor_ver)) { + format = "ciphersuite mismatch: version"; + line = 0x2d5; + } + else { + if (((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) && ((info->flags & 4) != 0)) + goto LAB_2306b15a; + type = mbedtls_ssl_get_ciphersuite_sig_pk_alg(info); + pmVar28 = ssl->handshake->sni_key_cert; + if (pmVar28 == (mbedtls_ssl_key_cert *)0x0) { + pmVar28 = ssl->conf->key_cert; + } + if (CONCAT31(extraout_var_00,type) == 0) { +have_ciphersuite: + mbedtls_debug_print_msg(ssl,2,"file1",0x72e,"selected ciphersuite: %s",info->name); + ssl->session_negotiate->ciphersuite = *puVar18; + ssl->transform_negotiate->ciphersuite_info = info; + ssl->state = ssl->state + 1; + if ((*(ushort *)&ssl->conf->field_0x74 & 2) != 0) { + mbedtls_ssl_recv_flight_completed(ssl); + } + format = "<= parse client hello"; + line = 0x73a; + line_00 = iVar8; + goto LAB_2306b2ac; + } + mbedtls_debug_print_msg(ssl,3,"file1",0x26f,"ciphersuite requires certificate"); + pmVar23 = (mbedtls_ssl_key_cert *)0x0; + if (pmVar28 == (mbedtls_ssl_key_cert *)0x0) { + mbedtls_debug_print_msg(ssl,3,"file1",0x273,"server has no certificate"); + } + else { + do { + mbedtls_debug_print_crt + (ssl,3,"file1",0x27a,"candidate certificate chain, certificate", + pmVar28->cert); + line = mbedtls_pk_can_do(pmVar28->key,type); + if (line == 0) { + format = "certificate mismatch: key type"; + line = 0x27e; + } + else { + line = mbedtls_ssl_check_cert_usage(pmVar28->cert,info,1,(uint32_t *)&local_b4); + if (line == 0) { + if ((2 < ssl->minor_ver) || (pmVar28->cert->sig_md == MBEDTLS_MD_SHA1)) + goto LAB_2306b22e; + if (pmVar23 == (mbedtls_ssl_key_cert *)0x0) { + pmVar23 = pmVar28; + } + format = "certificate not preferred: sha-2 with pre-TLS 1.2 client"; + line = 0x2a7; + } + else { + format = "certificate mismatch: (extended) key usage extension"; + line = 0x28e; + } + } + mbedtls_debug_print_msg(ssl,3,"file1",line,format); + pmVar28 = pmVar28->next; + } while (pmVar28 != (mbedtls_ssl_key_cert *)0x0); + pmVar28 = pmVar23; + if (pmVar23 != (mbedtls_ssl_key_cert *)0x0) { +LAB_2306b22e: + ssl->handshake->key_cert = pmVar28; + mbedtls_debug_print_crt + (ssl,3,"file1",0x2b8,"selected certificate chain, certificate", + ssl->handshake->key_cert->cert); + goto have_ciphersuite; + } + } + format = "ciphersuite mismatch: no suitable certificate"; + line = 0x316; + } + mbedtls_debug_print_msg(ssl,3,"file1",line,format); + } +LAB_2306b15a: + input = input + 2; + } while (input + -(int)buf_01 < len); + puVar18 = puVar18 + 1; + } while( true ); + } + goto LAB_2306ab72; +} + + + +int mbedtls_x509_get_serial(uchar **p,uchar *end,mbedtls_x509_buf *serial) + +{ + int iVar1; + byte *pbVar2; + uchar *puVar3; + + pbVar2 = *p; + if ((int)(end + -(int)pbVar2) < 1) { + return -0x22e0; + } + if ((*pbVar2 & 0x7f) == 2) { + *p = pbVar2 + 1; + serial->tag = (uint)*pbVar2; + iVar1 = mbedtls_asn1_get_len(p,end,&serial->len); + if (iVar1 == 0) { + puVar3 = *p; + serial->p = puVar3; + *p = puVar3 + serial->len; + } + else { + iVar1 = iVar1 + -0x2280; + } + return iVar1; + } + return -0x22e2; +} + + + +int mbedtls_x509_get_alg(uchar **p,uchar *end,mbedtls_x509_buf *alg,mbedtls_x509_buf *params) + +{ + int iVar1; + + iVar1 = mbedtls_asn1_get_alg(p,end,(mbedtls_asn1_buf *)alg,(mbedtls_asn1_buf *)params); + if (iVar1 != 0) { + iVar1 = iVar1 + -0x2300; + } + return iVar1; +} + + + +int mbedtls_x509_get_name(uchar **p,uchar *end,mbedtls_x509_name *cur) + +{ + mbedtls_x509_name *pmVar1; + int iVar2; + mbedtls_asn1_named_data *pmVar3; + uchar *puVar4; + byte *pbVar5; + uchar *end_00; + size_t sStack56; + size_t set_len; + size_t len; + +LAB_2306c13a: + iVar2 = mbedtls_asn1_get_tag(p,end,&sStack56,0x31); + if (iVar2 != 0) { + return iVar2 + -0x2380; + } + end_00 = *p + sStack56; + pmVar1 = cur; + do { + iVar2 = mbedtls_asn1_get_tag(p,end_00,&set_len,0x30); + if (iVar2 == 0) { + if ((int)(end_00 + -(int)*p) < 1) { + return -0x23e0; + } + (pmVar1->oid).tag = (uint)**p; + iVar2 = mbedtls_asn1_get_tag(p,end_00,&(pmVar1->oid).len,6); + if (iVar2 != 0) goto LAB_2306c186; + puVar4 = *p; + (pmVar1->oid).p = puVar4; + pbVar5 = puVar4 + (pmVar1->oid).len; + *p = pbVar5; + if ((int)(end_00 + -(int)pbVar5) < 1) { + return -0x23e0; + } + if ((0x1e < *pbVar5) || ((0x50581008U >> ((uint)*pbVar5 & 0x1f) & 1) == 0)) { + return -0x23e2; + } + *p = pbVar5 + 1; + (pmVar1->val).tag = (uint)*pbVar5; + iVar2 = mbedtls_asn1_get_len(p,end_00,&(pmVar1->val).len); + if (iVar2 != 0) goto LAB_2306c186; + puVar4 = *p; + (pmVar1->val).p = puVar4; + *p = puVar4 + (pmVar1->val).len; + pmVar1->next = (mbedtls_asn1_named_data *)0x0; + } + else { +LAB_2306c186: + if (iVar2 + -0x2380 != 0) { + return iVar2 + -0x2380; + } + } + if (*p == end_00) break; + pmVar1->next_merged = '\x01'; + pmVar3 = (mbedtls_asn1_named_data *)mycalloc(1,0x20); + pmVar1->next = pmVar3; + pmVar1 = (mbedtls_x509_name *)pmVar3; + if (pmVar3 == (mbedtls_asn1_named_data *)0x0) { + return -0x2880; + } + } while( true ); + if (end == end_00) { + return 0; + } + cur = (mbedtls_x509_name *)mycalloc(1,0x20); + *(mbedtls_x509_name **)&pmVar1->next = cur; + if (cur == (mbedtls_x509_name *)0x0) { + return -0x2880; + } + goto LAB_2306c13a; +} + + + +// WARNING: Variable defined which should be unmapped: len + +int mbedtls_x509_get_sig(uchar **p,uchar *end,mbedtls_x509_buf *sig) + +{ + byte bVar1; + int iVar2; + uchar *puVar3; + size_t sStack20; + size_t len; + + if (0 < (int)(end + -(int)*p)) { + bVar1 = **p; + iVar2 = mbedtls_asn1_get_bitstring_null(p,end,&sStack20); + if (iVar2 == 0) { + sig->tag = (uint)bVar1; + sig->len = sStack20; + puVar3 = *p; + sig->p = puVar3; + *p = puVar3 + sStack20; + } + else { + iVar2 = iVar2 + -0x2480; + } + return iVar2; + } + return -0x24e0; +} + + + +int mbedtls_x509_get_sig_alg + (mbedtls_x509_buf *sig_oid,mbedtls_x509_buf *sig_params,mbedtls_md_type_t *md_alg, + mbedtls_pk_type_t *pk_alg,void **sig_opts) + +{ + int iVar1; + + if (*sig_opts == (void *)0x0) { + iVar1 = mbedtls_oid_get_sig_alg((mbedtls_asn1_buf *)sig_oid,md_alg,pk_alg); + if (iVar1 == 0) { + if (((sig_params->tag != 5) && (sig_params->tag != 0)) || (sig_params->len != 0)) { + iVar1 = -0x2300; + } + } + else { + iVar1 = iVar1 + -0x2600; + } + return iVar1; + } + return -0x2800; +} + + + +int mbedtls_x509_get_ext(uchar **p,uchar *end,mbedtls_x509_buf *ext,int tag) + +{ + int iVar1; + uchar *end_00; + size_t sStack20; + size_t len; + + if (*p == end) { + return 0; + } + ext->tag = (uint)**p; + iVar1 = mbedtls_asn1_get_tag(p,end,&ext->len,tag | 0xa0); + if (iVar1 == 0) { + end_00 = *p; + ext->p = end_00; + end_00 = end_00 + ext->len; + iVar1 = mbedtls_asn1_get_tag(p,end_00,&sStack20,0x30); + if (iVar1 == 0) { + iVar1 = 0; + if (end_00 != *p + sStack20) { + iVar1 = -0x2566; + } + } + else { + iVar1 = iVar1 + -0x2500; + } + } + return iVar1; +} + + + +int mbedtls_x509_dn_gets(char *buf,size_t size,mbedtls_x509_name *dn) + +{ + size_t __maxlen; + uint __maxlen_00; + uint uVar1; + int iVar2; + char *__format; + byte bVar3; + uchar uVar4; + uint uVar5; + mbedtls_x509_name *oid; + char *pcStack308; + char *short_name; + char s [256]; + + pcStack308 = (char *)0x0; + memset(&short_name,0,0x100); + uVar4 = '\0'; + __maxlen = size; + oid = dn; + do { + if (oid == (mbedtls_x509_name *)0x0) { + return size - __maxlen; + } + if ((oid->oid).p != (uchar *)0x0) { + if (oid != dn) { + __format = " + "; + if (uVar4 == '\0') { + __format = ", "; + } + uVar1 = snprintf(buf,__maxlen,__format); + if ((int)uVar1 < 0) { + return -0x2980; + } + if (__maxlen <= uVar1) { + return -0x2980; + } + __maxlen = __maxlen - uVar1; + buf = buf + uVar1; + } + iVar2 = mbedtls_oid_get_attr_short_name((mbedtls_asn1_buf *)oid,&pcStack308); + if (iVar2 == 0) { + uVar1 = snprintf(buf,__maxlen,"%s=",pcStack308); + } + else { + uVar1 = snprintf(buf,__maxlen,"??="); + } + if (((int)uVar1 < 0) || (__maxlen <= uVar1)) { + return -0x2980; + } + __maxlen_00 = __maxlen - uVar1; + uVar5 = 0; + while ((uVar5 < (oid->val).len && (uVar5 != 0xff))) { + bVar3 = (oid->val).p[uVar5]; + if ((bVar3 < 0x20) || ((bVar3 == 0x7f || ((byte)(bVar3 + 0x7f) < 0x1f)))) { + bVar3 = 0x3f; + } + *(byte *)((int)&short_name + uVar5) = bVar3; + uVar5 = uVar5 + 1; + } + *(undefined *)((int)&short_name + uVar5) = 0; + uVar5 = snprintf(buf + uVar1,__maxlen_00,"%s",&short_name); + if ((int)uVar5 < 0) { + return -0x2980; + } + if (__maxlen_00 <= uVar5) { + return -0x2980; + } + __maxlen = __maxlen_00 - uVar5; + buf = buf + uVar1 + uVar5; + uVar4 = oid->next_merged; + } + oid = (mbedtls_x509_name *)oid->next; + } while( true ); +} + + + +int mbedtls_x509_serial_gets(char *buf,size_t size,mbedtls_x509_buf *serial) + +{ + size_t __maxlen; + uint uVar1; + undefined1 *puVar2; + uint uVar3; + uint uVar4; + + uVar4 = serial->len; + if (0x20 < uVar4) { + uVar4 = 0x1c; + } + uVar3 = 0; + __maxlen = size; + do { + if (uVar3 == uVar4) { + if (serial->len != uVar3) { + uVar4 = snprintf(buf,__maxlen,"...."); + if (((int)uVar4 < 0) || (__maxlen <= uVar4)) { + return -0x2980; + } + __maxlen = __maxlen - uVar4; + } + return size - __maxlen; + } + if (((uVar3 != 0) || (uVar4 == 1)) || (*serial->p != '\0')) { + puVar2 = (undefined1 *)0x23087a70; + if (uVar4 - 1 <= uVar3) { + puVar2 = &DAT_23088e60; + } + uVar1 = snprintf(buf,__maxlen,"%02X%s",(uint)serial->p[uVar3],puVar2); + if ((int)uVar1 < 0) { + return -0x2980; + } + if (__maxlen <= uVar1) { + return -0x2980; + } + __maxlen = __maxlen - uVar1; + buf = buf + uVar1; + } + uVar3 = uVar3 + 1; + } while( true ); +} + + + +int mbedtls_x509_sig_alg_gets + (char *buf,size_t size,mbedtls_x509_buf *sig_oid,mbedtls_pk_type_t pk_alg, + mbedtls_md_type_t md_alg,void *sig_opts) + +{ + int iVar1; + uint uVar2; + char *pcStack20; + char *desc; + + pcStack20 = (char *)0x0; + iVar1 = mbedtls_oid_get_sig_alg_desc((mbedtls_asn1_buf *)sig_oid,&pcStack20); + if (iVar1 == 0) { + uVar2 = snprintf(buf,size,"%s",pcStack20); + } + else { + uVar2 = snprintf(buf,size,"???"); + } + if (((int)uVar2 < 0) || (size <= uVar2)) { + uVar2 = 0xffffd680; + } + return uVar2; +} + + + +int mbedtls_x509_key_size_helper(char *buf,size_t buf_size,char *name) + +{ + uint uVar1; + int iVar2; + + uVar1 = snprintf(buf,buf_size,"%s key size",name); + if (((int)uVar1 < 0) || (buf_size <= uVar1)) { + iVar2 = -0x2980; + } + else { + iVar2 = 0; + } + return iVar2; +} + + + +int mbedtls_x509_time_is_past(mbedtls_x509_time *to) + +{ + return 0; +} + + + +undefined4 mbedtls_x509_time_is_future(void) + +{ + return 0; +} + + + +int mbedtls_base64_decode(uchar *dst,size_t dlen,size_t *olen,uchar *src,size_t slen) + +{ + byte bVar1; + byte bVar2; + int iVar3; + byte *pbVar4; + uint uVar5; + uchar *puVar6; + uint uVar7; + size_t sVar8; + uint uVar9; + int iVar10; + + uVar5 = 0; + uVar7 = 0; + sVar8 = 0; + while (sVar8 < slen) { + iVar3 = 0; + uVar9 = sVar8; + while( true ) { + bVar1 = src[uVar9]; + sVar8 = slen; + if (bVar1 != 0x20) break; + uVar9 = uVar9 + 1; + iVar3 = iVar3 + 1; + if (slen == uVar9) goto LAB_2306c656; + } + if (slen == uVar9) break; + bVar2 = bVar1; + if ((1 < slen - uVar9) && (bVar1 == 0xd)) { + bVar2 = (src + uVar9)[1]; + } + if (bVar2 != 10) { + if (iVar3 != 0) { + return -0x2c; + } + if (bVar1 == 0x3d) { + uVar5 = uVar5 + 1; + if (2 < uVar5) { + return -0x2c; + } + } + else { + if ((char)bVar1 < '\0') { + return -0x2c; + } + } + if ( + "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f>\x7f\x7f\x7f?456789:;<=\x7f\x7f\x7f@\x7f\x7f\x7f" + [bVar1] == 0x7f) { + return -0x2c; + } + if (( + "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f>\x7f\x7f\x7f?456789:;<=\x7f\x7f\x7f@\x7f\x7f\x7f" + [bVar1] < 0x40) && (uVar5 != 0)) { + return -0x2c; + } + uVar7 = uVar7 + 1; + } + sVar8 = uVar9 + 1; + } +LAB_2306c656: + if (uVar7 == 0) { + *olen = 0; + } + else { + uVar5 = ((uVar7 >> 3) * 6 - uVar5) + ((uVar7 & 7) * 6 + 7 >> 3); + if ((dst == (uchar *)0x0) || (dlen < uVar5)) { + *olen = uVar5; + return -0x2a; + } + pbVar4 = src + sVar8; + uVar5 = 0; + iVar10 = 3; + iVar3 = 0; + puVar6 = dst; + while (pbVar4 != src) { + uVar7 = (uint)*src - 10; + if ((0x16 < (uVar7 & 0xff)) || ((0x400009U >> (uVar7 & 0x1f) & 1) == 0)) { + uVar7 = uVar5 << 6; + iVar3 = iVar3 + 1; + iVar10 = iVar10 - (uint)( + "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f>\x7f\x7f\x7f?456789:;<=\x7f\x7f\x7f@\x7f\x7f\x7f" + [(uint)*src] == 0x40); + uVar5 = (uint) + "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f>\x7f\x7f\x7f?456789:;<=\x7f\x7f\x7f@\x7f\x7f\x7f" + [(uint)*src] & 0x3f | uVar7; + if ((iVar3 == 4) && (iVar3 = 0, iVar10 != 0)) { + *puVar6 = (uchar)(uVar7 >> 0x10); + if (iVar10 == 1) { + puVar6 = puVar6 + 1; + } + else { + puVar6[1] = (uchar)(uVar7 >> 8); + if (iVar10 == 2) { + puVar6 = puVar6 + 2; + } + else { + puVar6[2] = (uchar)uVar5; + puVar6 = puVar6 + 3; + } + } + } + } + src = src + 1; + } + *(uchar **)olen = puVar6 + -(int)dst; + } + return 0; +} + + + +double modf(double __x,double *__iptr) + +{ + double *in_a1; + double **in_a2; + uint uVar1; + uint uVar2; + double in_fa0; + DFtype DVar3; + + uVar1 = (int)in_a1 >> 0x14 & 0x7ff; + uVar2 = uVar1 - 0x3ff; + if ((int)uVar2 < 0x14) { + if ((int)uVar2 < 0) { + *in_a2 = (double *)0x0; + in_a2[1] = (double *)((uint)in_a1 & 0x80000000); + return in_fa0; + } + uVar1 = 0xfffff >> (uVar2 & 0x1f); + if ((uVar1 & (uint)in_a1 | (uint)__iptr) != 0) { + in_a1 = (double *)(~uVar1 & (uint)in_a1); + __iptr = (double *)0x0; +LAB_2306c840: + *in_a2 = __iptr; + in_a2[1] = in_a1; + DVar3 = __subdf3(); + return (double)DVar3; + } + } + else { + if (((int)uVar2 < 0x34) && + (uVar1 = 0xffffffff >> (uVar1 - 0x413 & 0x1f), (uVar1 & (uint)__iptr) != 0)) { + __iptr = (double *)(~uVar1 & (uint)__iptr); + goto LAB_2306c840; + } + } + in_a2[1] = in_a1; + *in_a2 = __iptr; + return in_fa0; +} + + + +DItype __lshrdi3(shift_count_type b) + +{ + DItype in_fa0; + + return in_fa0; +} + + + +int __clzsi2(USItype x) + +{ + int iVar1; + + if (x < 0x10000) { + iVar1 = (uint)(0xff < x) << 3; + } + else { + iVar1 = 0x10; + if (0xffffff < x) { + iVar1 = 0x18; + } + } + return (0x20 - iVar1) - (uint)""[x >> iVar1]; +} + + + +SFtype __floatundisf(void) + +{ + USItype in_a0; + SFtype SVar1; + uint in_a1; + + if ((0x1fffff < in_a1) && ((in_a0 & 0x7ff) != 0)) { + in_a0 = in_a0 & 0xfffff800 | 0x800; + } + __floatunsidf(in_a1); + __muldf3(); + __floatunsidf(in_a0); + __adddf3(); + SVar1 = __truncdfsf2(); + return SVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +DItype __divdi3(void) + +{ + DItype in_fa0; + + return in_fa0; +} + + + +// WARNING: Type propagation algorithm not settling + +DItype __moddi3(void) + +{ + DItype in_fa0; + + return in_fa0; +} + + + +// WARNING: Type propagation algorithm not settling + +UDItype __udivdi3(void) + +{ + UDItype in_fa0; + + return in_fa0; +} + + + +// WARNING: Type propagation algorithm not settling + +UDItype __umoddi3(void) + +{ + UDItype in_fa0; + + return in_fa0; +} + + +/* +Unable to decompile '__adddf3' +Cause: Exception while decompiling 2306daa4: Decompiler process died + +*/ + +/* +Unable to decompile '__divdf3' +Cause: +Low-level Error: Assignment to constant at r0x2306ec28 +*/ + + +__gcc_CMPtype __eqdf2(void) + +{ + uint in_a0; + uint in_a1; + uint in_a2; + uint in_a3; + uint uVar1; + uint uVar2; + uint uVar3; + + uVar1 = in_a1 >> 0x14 & 0x7ff; + uVar2 = in_a1 & 0xfffff; + uVar3 = in_a3 >> 0x14 & 0x7ff; + if (uVar1 == 0x7ff) { + if ((uVar2 | in_a0) != 0) { + return 1; + } + if (uVar3 != 0x7ff) { + return 1; + } + } + else { + if (uVar3 != 0x7ff) goto LAB_2306eef8; + } + if ((in_a3 & 0xfffff | in_a2) != 0) { + return 1; + } +LAB_2306eef8: + if (((uVar1 == uVar3) && (uVar2 == (in_a3 & 0xfffff))) && (in_a2 == in_a0)) { + if (in_a1 >> 0x1f == in_a3 >> 0x1f) { + return 0; + } + if (uVar1 == 0) { + return (uint)((uVar2 | in_a2) != 0); + } + } + return 1; +} + + + +__gcc_CMPtype __gedf2(void) + +{ + bool bVar1; + uint in_a0; + uint in_a1; + int iVar2; + uint in_a2; + uint in_a3; + int iVar3; + uint uVar4; + uint uVar5; + uint uVar6; + uint uVar7; + + uVar6 = in_a1 >> 0x14 & 0x7ff; + uVar7 = in_a1 & 0xfffff; + uVar5 = in_a3 & 0xfffff; + iVar2 = -((int)in_a1 >> 0x1f); + uVar4 = in_a3 >> 0x14 & 0x7ff; + iVar3 = -((int)in_a3 >> 0x1f); + if (uVar6 == 0x7ff) { + if ((uVar7 | in_a0) != 0) { + return -2; + } + if (uVar4 == 0x7ff) { +LAB_2306efbc: + if ((uVar5 | in_a2) != 0) { + return -2; + } + goto LAB_2306efc4; + } +LAB_2306f048: + if (uVar4 == 0) { + bVar1 = false; +LAB_2306efd4: + if ((uVar5 | in_a2) == 0) { + if (bVar1) { + return 0; + } + goto LAB_2306efe8; + } + goto LAB_2306efdc; + } + } + else { + if (uVar4 == 0x7ff) goto LAB_2306efbc; +LAB_2306efc4: + if (uVar6 != 0) goto LAB_2306f048; + bVar1 = (uVar7 | in_a0) == 0; + if (uVar4 == 0) goto LAB_2306efd4; +LAB_2306efdc: + if (bVar1) { + if (iVar3 != 0) { + return iVar3; + } + return -1; + } + } + if ((iVar2 == iVar3) && (uVar6 <= uVar4)) { + if (uVar4 <= uVar6) { + if (uVar5 < uVar7) goto LAB_2306efe8; + if (uVar7 == uVar5) { + if (in_a2 < in_a0) goto LAB_2306efe8; + if (in_a2 <= in_a0) { + return 0; + } + } + else { + if (uVar5 <= uVar7) { + return 0; + } + } + } + if (iVar2 == 0) { + return -1; + } + return iVar2; + } +LAB_2306efe8: + if (iVar2 != 0) { + return -1; + } + return 1; +} + + + +__gcc_CMPtype __ledf2(void) + +{ + bool bVar1; + uint in_a0; + uint in_a1; + int iVar2; + uint in_a2; + uint in_a3; + int iVar3; + uint uVar4; + uint uVar5; + uint uVar6; + uint uVar7; + + uVar6 = in_a1 >> 0x14 & 0x7ff; + uVar7 = in_a1 & 0xfffff; + uVar5 = in_a3 & 0xfffff; + iVar2 = -((int)in_a1 >> 0x1f); + uVar4 = in_a3 >> 0x14 & 0x7ff; + iVar3 = -((int)in_a3 >> 0x1f); + if (uVar6 == 0x7ff) { + if ((uVar7 | in_a0) != 0) { + return 2; + } + if (uVar4 == 0x7ff) { +LAB_2306f0a8: + if ((uVar5 | in_a2) != 0) { + return 2; + } + goto LAB_2306f0b0; + } +LAB_2306f134: + if (uVar4 == 0) { + bVar1 = false; +LAB_2306f0c0: + if ((uVar5 | in_a2) == 0) { + if (bVar1) { + return 0; + } + goto LAB_2306f0d4; + } + goto LAB_2306f0c8; + } + } + else { + if (uVar4 == 0x7ff) goto LAB_2306f0a8; +LAB_2306f0b0: + if (uVar6 != 0) goto LAB_2306f134; + bVar1 = (uVar7 | in_a0) == 0; + if (uVar4 == 0) goto LAB_2306f0c0; +LAB_2306f0c8: + if (bVar1) { + if (iVar3 != 0) { + return iVar3; + } + return -1; + } + } + if ((iVar2 == iVar3) && (uVar6 <= uVar4)) { + if (uVar4 <= uVar6) { + if (uVar5 < uVar7) goto LAB_2306f0d4; + if (uVar7 == uVar5) { + if (in_a2 < in_a0) goto LAB_2306f0d4; + if (in_a2 <= in_a0) { + return 0; + } + } + else { + if (uVar5 <= uVar7) { + return 0; + } + } + } + if (iVar2 == 0) { + return -1; + } + return iVar2; + } +LAB_2306f0d4: + if (iVar2 != 0) { + return -1; + } + return 1; +} + + +/* +Unable to decompile '__muldf3' +Cause: +Low-level Error: Assignment to constant at r0x2306f3e8 +*/ + +/* +Unable to decompile '__subdf3' +Cause: Exception while decompiling 2306f8dc: Decompiler process died + +*/ + + +SItype __fixdfsi(void) + +{ + uint in_a0; + uint in_a1; + uint uVar1; + uint uVar2; + + uVar1 = in_a1 >> 0x14 & 0x7ff; + if (uVar1 < 0x3ff) { + if ((uVar1 != 0) || (uVar2 = in_a1 & 0xfffff | in_a0, uVar2 != 0)) { + uVar2 = 0; + } + } + else { + if (uVar1 < 0x41e) { + uVar2 = in_a1 & 0xfffff | 0x100000; + if ((int)(0x433 - uVar1) < 0x20) { + uVar2 = uVar2 << (uVar1 - 0x413 & 0x1f) | in_a0 >> (0x433 - uVar1 & 0x1f); + } + else { + uVar2 = uVar2 >> (0x413 - uVar1 & 0x1f); + } + if (-((int)in_a1 >> 0x1f) != 0) { + uVar2 = -uVar2; + } + } + else { + uVar2 = -((int)in_a1 >> 0x1f) + 0x7fffffff; + } + } + return uVar2; +} + + + +USItype __fixunsdfsi(void) + +{ + uint in_a0; + USItype UVar1; + uint in_a1; + uint uVar2; + uint uVar3; + uint uVar4; + uint uVar5; + + uVar3 = in_a1 >> 0x14 & 0x7ff; + if (uVar3 < 0x3ff) { + if ((uVar3 == 0) && ((in_a1 & 0xfffff | in_a0) == 0)) { + return 0; + } + UVar1 = 0; + } + else { + if ((int)in_a1 < 0) { + UVar1 = 0; + } + else { + if (uVar3 < 0x41f) { + uVar5 = in_a1 & 0xfffff | 0x100000; + uVar2 = 0x433 - uVar3; + if ((int)uVar2 < 0x20) { + uVar4 = in_a0 << (uVar3 - 0x413 & 0x1f); + UVar1 = uVar5 << (uVar3 - 0x413 & 0x1f) | in_a0 >> (uVar2 & 0x1f); + } + else { + uVar4 = 0; + if (uVar2 != 0x20) { + uVar4 = uVar5 << (uVar3 - 0x3f3 & 0x1f); + } + uVar4 = uVar4 | in_a0; + UVar1 = uVar5 >> (0x413 - uVar3 & 0x1f); + } + if (uVar4 == 0) { + return UVar1; + } + } + else { + UVar1 = 0xffffffff; + } + } + } + return UVar1; +} + + + +DFtype __floatsidf(SItype i) + +{ + DFtype in_fa0; + + if (i != 0) { + __clzsi2((i >> 0x1f ^ i) - (i >> 0x1f)); + } + return in_fa0; +} + + + +DFtype __floatunsidf(USItype i) + +{ + DFtype in_fa0; + + if (i != 0) { + __clzsi2(i); + } + return in_fa0; +} + + +/* +Unable to decompile '__extendsfdf2' +Cause: Exception while decompiling 23070708: Decompiler process died + +*/ + + +SFtype __truncdfsf2(void) + +{ + uint uVar1; + SFtype in_a0; + uint in_a1; + uint uVar2; + uint uVar3; + uint uVar4; + uint uVar5; + int iVar6; + int in_frm; + + uVar1 = in_a1 >> 0x14 & 0x7ff; + uVar3 = (uint)in_a0 >> 0x1d | (in_a1 & 0xfffff) << 3; + uVar5 = (int)in_a0 << 3; + if ((uVar1 + 1 & 0x7fe) == 0) { + uVar3 = uVar3 | uVar5; + if (uVar1 == 0) { + uVar1 = (uint)(uVar3 != 0); +LAB_23070968: + if (uVar1 == 0) { + return in_a0; + } +LAB_2307096c: + if (((((uVar1 * 2 & 7) != 0) && (in_frm != 2)) && (in_frm != 3)) && (in_frm == 0)) { + in_a0 = 0.00000000; + } + } + else { + if (uVar3 == 0) { + return in_a0; + } + uVar1 = 0; + } + } + else { + iVar6 = uVar1 - 0x380; + if (0xfe < iVar6) { + if (in_frm == 0) { + return in_a0; + } + if (in_frm == 3) { + if (-1 < (int)in_a1) { + return in_a0; + } + } + else { + if ((in_frm == 2) && ((int)in_a1 < 0)) { + return in_a0; + } + } + goto LAB_23070878; + } + if (iVar6 < 1) { + if (-0x18 < iVar6) { + uVar3 = uVar3 | 0x800000; + uVar2 = 0x1e - iVar6; + if ((int)uVar2 < 0x20) { + uVar1 = uVar5 >> (uVar2 & 0x1f) | + (uint)(uVar5 << (uVar1 - 0x37e & 0x1f) != 0) | uVar3 << (uVar1 - 0x37e & 0x1f); + } + else { + in_a0 = 0.00000000; + uVar4 = 0; + if (uVar2 != 0x20) { + uVar4 = uVar3 << (uVar1 - 0x35e & 0x1f); + } + uVar1 = uVar3 >> (-iVar6 - 2U & 0x1f) | (uint)((uVar4 | uVar5) != 0); + } + goto LAB_23070968; + } + uVar1 = 1; + goto LAB_2307096c; + } + in_a0 = (SFtype)(uint)(((uint)in_a0 & 0x3ffffff) != 0); + uVar1 = (uint)in_a0 | uVar5 >> 0x1d; + } + if ((uVar1 & 7) == 0) { + return in_a0; + } +LAB_23070878: + if (((in_frm != 2) && (in_frm != 3)) && (in_frm == 0)) { + in_a0 = 0.00000000; + } + return in_a0; +} + + + +int atoi(char *__nptr) + +{ + long lVar1; + + lVar1 = strtol(__nptr,(char **)0x0,10); + return lVar1; +} + + + +void _atoi_r(void) + +{ + _strtol_r(0,10); + return; +} + + + +undefined * __errno(void) + +{ + return _impure_ptr; +} + + + +void * memchr(void *__s,int __c,size_t __n) + +{ + byte bVar1; + uint uVar2; + uint uVar3; + uint *puVar4; + uint uVar5; + + uVar5 = __c & 0xff; + if (((uint)__s & 3) != 0) { + if (__n == 0) { + return (void *)0x0; + } + bVar1 = *(byte *)__s; + __n = __n - 1; + while( true ) { + if ((uint)bVar1 == uVar5) { + return (uint *)__s; + } + __s = (void *)((int)__s + 1); + if (((uint)__s & 3) == 0) break; + __n = __n - 1; + if (__n == 0xffffffff) { + return (void *)0x0; + } + bVar1 = *(byte *)__s; + } + } + if (3 < __n) { + uVar2 = (__c & 0xffU) << 8 | __c & 0xffU; + do { + uVar3 = (uVar2 << 0x10 | uVar2) ^ *(uint *)__s; + if ((uVar3 + 0xfefefeff & ~uVar3 & 0x80808080) != 0) goto LAB_23070b64; + __n = __n - 4; + __s = (uint *)__s + 1; + } while (3 < __n); + } + if (__n != 0) { +LAB_23070b64: + if ((uint)*(byte *)__s == uVar5) { + return (uint *)__s; + } + puVar4 = (uint *)((int)__s + __n); + while (__s = (void *)((int)__s + 1), puVar4 != (uint *)__s) { + if ((uint)*(byte *)__s == uVar5) { + return (uint *)__s; + } + } + } + return (void *)0x0; +} + + + +int memcmp(void *__s1,void *__s2,size_t __n) + +{ + int *piVar1; + uint uVar2; + uint uVar3; + + if (3 < __n) { + if ((((uint)__s1 | (uint)__s2) & 3) != 0) goto LAB_23070c30; + do { + if (*(int *)__s1 != *(int *)__s2) goto LAB_23070c30; + __n = __n - 4; + __s1 = (int *)__s1 + 1; + __s2 = (int *)__s2 + 1; + } while (3 < __n); + } + if (__n == 0) { + return 0; + } +LAB_23070c30: + uVar3 = (uint)*(byte *)__s1; + uVar2 = (uint)*(byte *)__s2; + if (uVar3 == uVar2) { + piVar1 = (int *)((int)__s1 + __n); + do { + __s1 = (void *)((int)__s1 + 1); + __s2 = (void *)((int)__s2 + 1); + if ((int *)__s1 == piVar1) { + return 0; + } + uVar3 = (uint)*(byte *)__s1; + uVar2 = (uint)*(byte *)__s2; + } while (uVar3 == uVar2); + } + return uVar3 - uVar2; +} + + + +void * memcpy(void *__dest,void *__src,size_t __n) + +{ + undefined uVar1; + undefined4 uVar2; + undefined4 uVar3; + undefined4 *puVar4; + undefined4 *puVar5; + undefined4 uVar6; + undefined4 *puVar7; + uint uVar8; + undefined4 *puVar9; + undefined4 *puVar10; + int iVar11; + undefined4 uVar12; + undefined4 *puVar13; + undefined4 uVar14; + undefined4 uVar15; + undefined4 uVar16; + undefined4 uVar17; + + puVar13 = (undefined4 *)((int)__dest + __n); + if (((((uint)__src ^ (uint)__dest) & 3) == 0) && (3 < __n)) { + uVar8 = (uint)__dest & 3; + puVar5 = (undefined4 *)__dest; + while (puVar4 = (undefined4 *)__src, puVar7 = puVar5, uVar8 != 0) { + puVar7 = (undefined4 *)((int)puVar5 + 1); + *(undefined *)puVar5 = *(undefined *)__src; + puVar4 = (undefined4 *)((int)__src + 1); + if (((uint)puVar7 & 3) == 0) break; + uVar8 = (uint)(undefined4 *)((int)puVar5 + 2) & 3; + *(undefined *)((int)puVar5 + 1) = *(undefined *)puVar4; + __src = (void *)((int)__src + 2); + puVar5 = (undefined4 *)((int)puVar5 + 2); + } + puVar5 = (undefined4 *)((uint)puVar13 & 0xfffffffc); + __src = puVar4; + while (puVar7 < puVar5 + -8) { + uVar2 = ((undefined4 *)__src)[1]; + uVar17 = ((undefined4 *)__src)[2]; + uVar16 = ((undefined4 *)__src)[3]; + uVar15 = ((undefined4 *)__src)[4]; + uVar14 = ((undefined4 *)__src)[5]; + uVar3 = ((undefined4 *)__src)[6]; + uVar12 = ((undefined4 *)__src)[7]; + *puVar7 = *(undefined4 *)__src; + uVar6 = ((undefined4 *)__src)[8]; + puVar7[1] = uVar2; + puVar7[2] = uVar17; + puVar7[3] = uVar16; + puVar7[4] = uVar15; + puVar7[5] = uVar14; + puVar7[6] = uVar3; + puVar7[7] = uVar12; + puVar7[8] = uVar6; + __src = (undefined4 *)__src + 9; + puVar7 = puVar7 + 9; + } + puVar4 = (undefined4 *)__src; + puVar9 = puVar7; + if (puVar7 < puVar5) { + do { + puVar10 = puVar9 + 1; + *puVar9 = *puVar4; + puVar4 = puVar4 + 1; + puVar9 = puVar10; + } while (puVar10 < puVar5); + iVar11 = ((int)puVar5 + (-1 - (int)puVar7) & 0xfffffffcU) + 4; + puVar7 = (undefined4 *)((int)puVar7 + iVar11); + __src = (void *)((int)__src + iVar11); + } + if (puVar7 < puVar13) { +LAB_23070cf4: + do { + uVar1 = *(undefined *)__src; + puVar5 = (undefined4 *)((int)puVar7 + 1); + __src = (void *)((int)__src + 1); + *(undefined *)puVar7 = uVar1; + puVar7 = puVar5; + } while (puVar5 < puVar13); + return __dest; + } + } + else { + puVar7 = (undefined4 *)__dest; + if (__dest < puVar13) goto LAB_23070cf4; + } + return __dest; +} + + + +void * memmove(void *__dest,void *__src,size_t __n) + +{ + int iVar1; + undefined *puVar2; + undefined4 *puVar3; + undefined *puVar4; + undefined4 *puVar5; + undefined4 *puVar6; + uint uVar7; + + if ((__src < __dest) && (puVar4 = (undefined *)((int)__src + __n), __dest < puVar4)) { + puVar2 = (undefined *)((int)__dest + __n); + if (__n == 0) { + return __dest; + } + do { + puVar4 = puVar4 + -1; + puVar2 = puVar2 + -1; + *puVar2 = *puVar4; + } while ((undefined *)__src != puVar4); + return __dest; + } + uVar7 = __n; + puVar5 = (undefined4 *)__dest; + if (0xf < __n) { + if ((((uint)__src | (uint)__dest) & 3) != 0) { + iVar1 = __n - 1; + goto LAB_23070dd8; + } + iVar1 = (__n - 0x10 & 0xfffffff0) + 0x10; + puVar3 = (undefined4 *)__src; + puVar6 = (undefined4 *)__dest; + do { + puVar5 = puVar6 + 4; + *puVar6 = *puVar3; + puVar6[1] = puVar3[1]; + puVar6[2] = puVar3[2]; + puVar6[3] = puVar3[3]; + puVar3 = puVar3 + 4; + puVar6 = puVar5; + } while ((undefined4 *)((int)__dest + iVar1) != puVar5); + __src = (void *)((int)__src + iVar1); + uVar7 = __n & 0xf; + puVar3 = (undefined4 *)__src; + if ((__n & 0xc) != 0) { + do { + puVar3 = puVar3 + 1; + *puVar6 = *puVar3; + puVar3 = puVar3; + puVar6 = puVar6 + 1; + } while (3 < (int)__src + (uVar7 - (int)puVar3)); + iVar1 = (uVar7 - 4 & 0xfffffffc) + 4; + __src = (void *)((int)__src + iVar1); + uVar7 = __n & 3; + puVar5 = (undefined4 *)((int)puVar5 + iVar1); + } + } + iVar1 = uVar7 - 1; + if (uVar7 == 0) { + return __dest; + } +LAB_23070dd8: + puVar3 = puVar5; + do { + puVar6 = (undefined4 *)((int)puVar3 + 1); + *(undefined *)puVar3 = *(undefined *)__src; + __src = (undefined4 *)((int)__src + 1); + puVar3 = puVar6; + } while (puVar6 != (undefined4 *)((int)puVar5 + iVar1 + 1)); + return __dest; +} + + + +void * memset(void *__s,int __c,size_t __n) + +{ + uint uVar1; + uint extraout_a1; + uint *puVar2; + uint *puVar3; + void *pvVar4; + uint uVar5; + + uVar1 = 0xf; + if (0xf < __n) { + uVar5 = (uint)__s & 0xf; + puVar3 = (uint *)__s; + if (uVar5 != 0) { + pvVar4 = __s; + __s = (void *)(*(code *)(uVar5 * 4 + 0x23070f0c))(); + puVar3 = (uint *)((int)pvVar4 - (uVar5 - 0x10)); + __n = __n + (uVar5 - 0x10); + __c = extraout_a1; + if (__n <= uVar1) goto LAB_23070efc; + } + if (__c != 0) { + uVar5 = __c & 0xffU | (__c & 0xffU) << 8; + __c = uVar5 | uVar5 << 0x10; + } + uVar5 = __n & 0xfffffff0; + __n = __n & 0xf; + puVar2 = (uint *)(uVar5 + (int)puVar3); + do { + *puVar3 = __c; + puVar3[1] = __c; + puVar3[2] = __c; + puVar3[3] = __c; + puVar3 = puVar3 + 4; + } while (puVar3 < puVar2); + if (__n == 0) { + return __s; + } + } +LAB_23070efc: + // WARNING: Could not recover jumptable at 0x23070f0c. Too many branches + // WARNING: Treating indirect jump as call + pvVar4 = (void *)(*(code *)(&UNK_23070f10 + (uVar1 - __n) * 4))(); + return pvVar4; +} + + + +char * strchr(char *__s,int __c) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + uint uVar4; + + uVar3 = __c & 0xff; + if (uVar3 == 0) { + if (((uint)__s & 3) != 0) { + if (*__s == '\0') { + return __s; + } + while (__s = (char *)((int)__s + 1), ((uint)__s & 3) != 0) { + if (*__s == '\0') { + return (char *)(uint *)__s; + } + } + } + uVar3 = *(uint *)__s + 0xfefefeff & ~*(uint *)__s; + while ((uVar3 & 0x80808080) == 0) { + __s = (char *)((uint *)__s + 1); + uVar3 = *(uint *)__s + 0xfefefeff & ~*(uint *)__s; + } + if (*__s != '\0') { + do { + __s = (char *)((int)__s + 1); + } while (*__s != '\0'); + return __s; + } + return (char *)(uint *)__s; + } + if (((uint)__s & 3) != 0) { + if (*__s == 0) { + return (char *)0x0; + } + if (uVar3 == (uint)(byte)*__s) { + return __s; + } + while (__s = (char *)((int)__s + 1), ((uint)__s & 3) != 0) { + if (*__s == 0) { + return (char *)0x0; + } + if ((uint)(byte)*__s == uVar3) { + return (char *)(uint *)__s; + } + } + } + uVar1 = __c & 0xffU | (__c & 0xffU) << 8; + uVar4 = *(uint *)__s; + uVar1 = uVar1 << 0x10 | uVar1; + uVar2 = uVar1 ^ uVar4; + uVar2 = ~uVar4 & uVar4 + 0xfefefeff | ~uVar2 & uVar2 + 0xfefefeff; + while ((uVar2 & 0x80808080) == 0) { + __s = (char *)((uint *)__s + 1); + uVar4 = *(uint *)__s; + uVar2 = uVar4 ^ uVar1; + uVar2 = uVar4 + 0xfefefeff & ~uVar4 | uVar2 + 0xfefefeff & ~uVar2; + } + if (*__s != 0) { + if (uVar3 == (uint)(byte)*__s) { + return (char *)(uint *)__s; + } + while( true ) { + __s = (char *)((int)__s + 1); + if (*__s == 0) break; + if ((uint)(byte)*__s == uVar3) { + return __s; + } + } + } + return (char *)0x0; +} + + + +int strcmp(char *__s1,char *__s2) + +{ + byte bVar1; + byte bVar2; + uint uVar3; + uint uVar4; + + if ((((uint)__s1 | (uint)__s2) & 3) == 0) { + do { + uVar3 = *(uint *)__s1; + uVar4 = *(uint *)__s2; + if (((uVar3 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar3 | 0x7f7f7f7f) != 0xffffffff) { +LAB_23071234: + if (uVar3 == uVar4) { + return 0; + } + goto LAB_2307120c; + } + if (uVar3 != uVar4) break; + uVar3 = ((uint *)__s1)[1]; + uVar4 = ((uint *)__s2)[1]; + if (((uVar3 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar3 | 0x7f7f7f7f) != 0xffffffff) { + __s1 = (char *)((uint *)__s1 + 1); + __s2 = (char *)((uint *)__s2 + 1); + goto LAB_23071234; + } + if (uVar3 != uVar4) break; + uVar3 = ((uint *)__s1)[2]; + uVar4 = ((uint *)__s2)[2]; + if (((uVar3 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar3 | 0x7f7f7f7f) != 0xffffffff) { + __s1 = (char *)((uint *)__s1 + 2); + __s2 = (char *)((uint *)__s2 + 2); + if (uVar3 == uVar4) { + return 0; + } + goto LAB_2307120c; + } + if (uVar3 != uVar4) break; + uVar3 = ((uint *)__s1)[3]; + uVar4 = ((uint *)__s2)[3]; + if (((uVar3 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar3 | 0x7f7f7f7f) != 0xffffffff) { + __s1 = (char *)((uint *)__s1 + 3); + __s2 = (char *)((uint *)__s2 + 3); + if (uVar3 == uVar4) { + return 0; + } + goto LAB_2307120c; + } + if (uVar3 != uVar4) break; + uVar3 = ((uint *)__s1)[4]; + uVar4 = ((uint *)__s2)[4]; + if (((uVar3 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar3 | 0x7f7f7f7f) != 0xffffffff) { + __s1 = (char *)((uint *)__s1 + 4); + __s2 = (char *)((uint *)__s2 + 4); + if (uVar3 == uVar4) { + return 0; + } + goto LAB_2307120c; + } + __s1 = (char *)((uint *)__s1 + 5); + __s2 = (char *)((uint *)__s2 + 5); + } while (uVar3 == uVar4); + if (uVar3 << 0x10 == uVar4 << 0x10) { + uVar3 = uVar3 >> 0x10; + uVar4 = uVar4 >> 0x10; + if ((uVar3 - uVar4 & 0xff) == 0) { + return uVar3 - uVar4; + } + } + else { + uVar3 = uVar3 & 0xffff; + uVar4 = uVar4 & 0xffff; + if ((uVar3 - uVar4 & 0xff) == 0) { + return uVar3 - uVar4; + } + } + return (uVar3 & 0xff) - (uVar4 & 0xff); + } +LAB_2307120c: + do { + bVar1 = *__s1; + bVar2 = *__s2; + __s1 = (char *)((int)__s1 + 1); + __s2 = (char *)((int)__s2 + 1); + if ((uint)bVar1 != (uint)bVar2) break; + } while (bVar1 != 0); + return (uint)bVar1 - (uint)bVar2; +} + + + +char * strcpy(char *__dest,char *__src) + +{ + char cVar1; + char cVar2; + char cVar3; + uint *puVar4; + uint uVar5; + uint uVar6; + char *pcVar7; + + pcVar7 = __dest; + if ((((uint)__dest | (uint)__src) & 3) != 0) { + do { + cVar1 = *__src; + __src = __src + 1; + *pcVar7 = cVar1; + pcVar7 = pcVar7 + 1; + } while (cVar1 != '\0'); + return __dest; + } + uVar5 = *(uint *)__src; + uVar6 = (uVar5 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar5; + puVar4 = (uint *)__dest; + while ((uVar6 | 0x7f7f7f7f) == 0xffffffff) { + __src = (char *)((uint *)__src + 1); + *puVar4 = uVar5; + uVar5 = *(uint *)__src; + uVar6 = (uVar5 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar5; + puVar4 = puVar4 + 1; + } + cVar1 = *__src; + cVar2 = *(char *)((int)__src + 1); + cVar3 = *(char *)((int)__src + 2); + *(char *)puVar4 = cVar1; + if (((cVar1 != '\0') && (*(char *)((int)puVar4 + 1) = cVar2, cVar2 != '\0')) && + (*(char *)((int)puVar4 + 2) = cVar3, cVar3 != '\0')) { + *(char *)((int)puVar4 + 3) = '\0'; + return __dest; + } + return __dest; +} + + + +size_t strlen(char *__s) + +{ + char cVar1; + uint *puVar2; + uint *puVar3; + uint uVar4; + + uVar4 = (uint)__s & 3; + puVar3 = (uint *)__s; + while (uVar4 != 0) { + cVar1 = *(char *)puVar3; + puVar3 = (uint *)((int)puVar3 + 1); + uVar4 = (uint)puVar3 & 3; + if (cVar1 == '\0') { + return (int)puVar3 + (-1 - (int)__s); + } + } + do { + puVar2 = puVar3; + puVar3 = puVar2 + 1; + } while (((*puVar2 & 0x7f7f7f7f) + 0x7f7f7f7f | *puVar2 | 0x7f7f7f7f) == 0xffffffff); + puVar3 = (uint *)((int)(puVar2 + 1) - (int)__s); + if (*(char *)puVar2 != '\0') { + if (*(char *)((int)puVar2 + 1) != '\0') { + return (int)puVar3 + ((uint)(*(char *)((int)puVar2 + 2) != '\0') - 2); + } + return (size_t)((int)puVar3 + -3); + } + return (size_t)(puVar3 + -1); +} + + + +int strncmp(char *__s1,char *__s2,size_t __n) + +{ + int iVar1; + uint *puVar2; + uint uVar3; + uint uVar4; + + if (__n == 0) { + return 0; + } + if (((((uint)__s1 | (uint)__s2) & 3) == 0) && (3 < __n)) { + uVar4 = *(uint *)__s1; + if (uVar4 != *(uint *)__s2) { +LAB_23071494: + uVar3 = (uint)(byte)*__s1; + uVar4 = (uint)(byte)*__s2; + iVar1 = __n - 1; + if (uVar4 == uVar3) goto LAB_23071458; + goto LAB_23071484; + } + __n = __n - 4; + if (__n == 0) { + return 0; + } + uVar4 = uVar4 + 0xfefefeff & ~uVar4; + while( true ) { + if ((uVar4 & 0x80808080) != 0) { + return 0; + } + __s1 = (char *)((uint *)__s1 + 1); + __s2 = (char *)((uint *)__s2 + 1); + if (__n < 4) break; + uVar3 = *(uint *)__s1; + uVar4 = uVar3 + 0xfefefeff & ~uVar3; + if (uVar3 != *(uint *)__s2) goto LAB_23071494; + __n = __n - 4; + if (__n == 0) { + return 0; + } + } + } + uVar3 = (uint)(byte)*__s1; + uVar4 = (uint)(byte)*__s2; + iVar1 = __n - 1; + if (uVar4 == uVar3) { + if (iVar1 == 0) { + return 0; + } +LAB_23071458: + if (uVar3 != 0) { + puVar2 = (uint *)((int)__s1 + iVar1); + do { + __s1 = (char *)((int)__s1 + 1); + __s2 = (char *)((int)__s2 + 1); + uVar3 = (uint)(byte)*__s1; + uVar4 = (uint)(byte)*__s2; + if (uVar3 != uVar4) goto LAB_23071484; + } while ((puVar2 != (uint *)__s1) && (*__s1 != 0)); + } + return 0; + } +LAB_23071484: + return uVar3 - uVar4; +} + + + +char * strncpy(char *__dest,char *__src,size_t __n) + +{ + char cVar1; + uint uVar2; + uint *puVar3; + uint *puVar4; + char *pcVar5; + char *pcVar6; + char *pcVar7; + int iVar8; + + puVar3 = (uint *)__dest; + if (((((uint)__src | (uint)__dest) & 3) == 0) && (puVar4 = (uint *)__dest, 3 < __n)) { + do { + uVar2 = *(uint *)__src; + if ((uVar2 + 0xfefefeff & ~uVar2 & 0x80808080) != 0) goto LAB_230714c4; + puVar3 = puVar4 + 1; + __n = __n - 4; + *puVar4 = uVar2; + __src = (char *)((uint *)__src + 1); + puVar4 = puVar3; + } while (3 < __n); + } + puVar4 = puVar3; + if (__n != 0) { +LAB_230714c4: + cVar1 = *__src; + *(char *)puVar4 = cVar1; + pcVar5 = (char *)((int)puVar4 + 1); + iVar8 = __n - 1; + if (cVar1 != '\0') { + pcVar6 = pcVar5; + do { + __src = (char *)((int)__src + 1); + iVar8 = (__n - 1) - (int)pcVar6; + if (pcVar6 == (char *)((int)puVar4 + __n)) { + return __dest; + } + cVar1 = *__src; + pcVar5 = pcVar6 + 1; + *pcVar6 = cVar1; + pcVar6 = pcVar5; + iVar8 = (int)puVar4 + iVar8; + } while (cVar1 != '\0'); + } + pcVar6 = pcVar5; + if (iVar8 == 0) { + return __dest; + } + do { + pcVar7 = pcVar6 + 1; + *pcVar6 = '\0'; + pcVar6 = pcVar7; + } while (pcVar7 != pcVar5 + iVar8); + } + return __dest; +} + + + +size_t strnlen(char *__string,size_t __maxlen) + +{ + char *pcVar1; + + if (__maxlen != 0) { + if (*__string == '\0') { + __maxlen = 0; + } + else { + pcVar1 = __string; + while (pcVar1 = pcVar1 + 1, pcVar1 != __string + __maxlen) { + if (*pcVar1 == '\0') { + return (size_t)(pcVar1 + -(int)__string); + } + } + } + } + return __maxlen; +} + + + +char * strrchr(char *__s,int __c) + +{ + char *pcVar1; + char *pcVar2; + + if (__c != 0) { + pcVar2 = (char *)0x0; + while (pcVar1 = strchr(__s,__c), pcVar1 != (char *)0x0) { + __s = pcVar1 + 1; + pcVar2 = pcVar1; + } + return pcVar2; + } + pcVar2 = strchr(__s,0); + return pcVar2; +} + + + +byte * two_way_long_needle(int param_1,int param_2,byte *param_3,byte *param_4) + +{ + byte bVar1; + byte bVar2; + int iVar3; + size_t sVar4; + byte *pbVar5; + byte *pbVar6; + byte *__n; + byte *pbVar7; + byte *pbVar8; + byte **ppbVar9; + byte *pbVar10; + byte *pbVar11; + byte *pbVar12; + byte *pbVar13; + byte *pbVar14; + byte *local_440 [256]; + byte *apbStack64 [3]; + + pbVar13 = (byte *)0x1; + pbVar6 = (byte *)0x1; + __n = (byte *)0x0; + pbVar11 = (byte *)0xffffffff; + do { + pbVar14 = pbVar6 + (int)pbVar11; + pbVar10 = pbVar6 + (int)__n; + pbVar12 = __n; + while( true ) { + __n = pbVar10; + if (param_4 <= __n) { + pbVar6 = (byte *)0x1; + __n = (byte *)0x1; + pbVar14 = (byte *)0xffffffff; + pbVar12 = (byte *)0x0; + goto LAB_230716b8; + } + if (param_3[(int)pbVar14] <= param_3[(int)__n]) break; + pbVar6 = (byte *)0x1; + pbVar13 = __n + -(int)pbVar11; + pbVar14 = pbVar11 + 1; + pbVar10 = __n + 1; + pbVar12 = __n; + } + if (param_3[(int)__n] == param_3[(int)pbVar14]) { + if (pbVar6 == pbVar13) { + pbVar6 = (byte *)0x1; + } + else { + pbVar6 = pbVar6 + 1; + __n = pbVar12; + } + } + else { + pbVar13 = (byte *)0x1; + pbVar6 = (byte *)0x1; + __n = pbVar12 + 1; + pbVar11 = pbVar12; + } + } while( true ); +LAB_230716b8: + pbVar5 = __n + (int)pbVar14; + pbVar7 = __n + (int)pbVar12; + pbVar10 = pbVar12; + while (pbVar12 = pbVar7, pbVar12 < param_4) { + if (param_3[(int)pbVar12] <= param_3[(int)pbVar5]) goto LAB_2307188c; + __n = (byte *)0x1; + pbVar6 = pbVar12 + -(int)pbVar14; + pbVar5 = pbVar14 + 1; + pbVar7 = pbVar12 + 1; + pbVar10 = pbVar12; + } + __n = pbVar11 + 1; + if (pbVar11 + 1 <= pbVar14 + 1) { + pbVar13 = pbVar6; + __n = pbVar14 + 1; + } + ppbVar9 = local_440; + do { + *ppbVar9 = param_4; + ppbVar9 = ppbVar9 + 1; + } while (apbStack64 != ppbVar9); + pbVar11 = param_4 + -1; + pbVar6 = param_3; + if (param_4 != (byte *)0x0) { + do { + bVar1 = *pbVar6; + iVar3 = -(int)pbVar6; + pbVar6 = pbVar6 + 1; + local_440[bVar1] = param_3 + (int)(pbVar11 + iVar3); + } while (pbVar6 != param_3 + (int)param_4); + } + iVar3 = memcmp(param_3,param_3 + (int)pbVar13,(size_t)__n); + if (iVar3 != 0) { + pbVar13 = param_4 + -(int)__n; + if (param_4 + -(int)__n < __n) { + pbVar13 = __n; + } + pbVar6 = __n + -1; + pbVar12 = (byte *)0x0; +LAB_2307194c: + pbVar14 = pbVar12 + param_1; + pbVar10 = local_440[pbVar11[(int)pbVar14]]; + if (pbVar10 == (byte *)0x0) goto LAB_230719b0; + do { + pbVar12 = pbVar10 + (int)pbVar12; + while( true ) { + if (pbVar12 <= (byte *)(param_2 - (int)param_4)) goto LAB_2307194c; + sVar4 = strnlen((char *)(param_1 + param_2),(uint)param_4 | 0x800); + param_2 = param_2 + sVar4; + if ((byte *)(param_2 - (int)param_4) < pbVar12) { + return (byte *)0; + } + pbVar14 = pbVar12 + param_1; + pbVar10 = local_440[pbVar11[(int)pbVar14]]; + if (pbVar10 != (byte *)0x0) break; +LAB_230719b0: + if (__n < pbVar11) { + pbVar10 = __n; + if (__n[(int)pbVar14] == param_3[(int)__n]) { + do { + pbVar10 = pbVar10 + 1; + if (pbVar11 <= pbVar10) goto LAB_230719f0; + } while (param_3[(int)pbVar10] == pbVar10[(int)(pbVar12 + param_1)]); + } + pbVar12 = pbVar10 + (int)(pbVar12 + (1 - (int)__n)); + } + else { +LAB_230719f0: + if (pbVar6 == (byte *)0xffffffff) { + return pbVar14; + } + if (pbVar6[(int)pbVar14] == param_3[(int)pbVar6]) { + pbVar5 = param_3 + (int)(__n + -2); + pbVar10 = __n + -2 + (int)(pbVar12 + param_1); + do { + if (pbVar5 == param_3 + -1) { + return pbVar14; + } + bVar1 = *pbVar5; + bVar2 = *pbVar10; + pbVar5 = pbVar5 + -1; + pbVar10 = pbVar10 + -1; + } while (bVar1 == bVar2); + } + pbVar12 = pbVar13 + (int)(pbVar12 + 1); + } + } + } while( true ); + } + pbVar6 = __n + -1; + pbVar12 = (byte *)0x0; + pbVar14 = (byte *)0x0; + do { + pbVar5 = pbVar14 + param_1; + pbVar10 = local_440[pbVar11[(int)pbVar5]]; + if (pbVar10 == (byte *)0x0) { + pbVar10 = pbVar12; + if (pbVar12 < __n) { + pbVar10 = __n; + } + if (pbVar10 < pbVar11) { + pbVar7 = pbVar10 + (int)(pbVar14 + param_1); + pbVar8 = param_3 + (int)pbVar10; + do { + if (*pbVar7 != *pbVar8) { + pbVar14 = pbVar14 + (1 - (int)__n); + goto LAB_230717c4; + } + pbVar10 = pbVar10 + 1; + pbVar7 = param_3 + (int)pbVar10; + pbVar8 = pbVar10 + (int)(pbVar14 + param_1); + } while (pbVar10 < pbVar11); + } + if ((pbVar12 < __n) && + (pbVar10 = pbVar6, pbVar6[(int)(pbVar14 + param_1)] == param_3[(int)pbVar6])) { + do { + pbVar7 = pbVar10; + pbVar10 = pbVar7 + -1; + if (pbVar12 == pbVar7) break; + } while (param_3[(int)pbVar10] == pbVar10[(int)(pbVar14 + param_1)]); + if (pbVar7 < pbVar12 + 1) { + return pbVar5; + } + } + else { + if (__n < pbVar12 + 1) { + return pbVar5; + } + } + pbVar14 = pbVar13 + (int)pbVar14; + pbVar12 = param_4 + -(int)pbVar13; + } + else { + if ((pbVar12 != (byte *)0x0) && (pbVar10 < pbVar13)) { + pbVar10 = param_4 + -(int)pbVar13; + } +LAB_230717c4: + pbVar14 = pbVar10 + (int)pbVar14; + pbVar12 = (byte *)0x0; + } + if ((byte *)(param_2 - (int)param_4) < pbVar14) { + sVar4 = strnlen((char *)(param_1 + param_2),(uint)param_4 | 0x800); + param_2 = param_2 + sVar4; + if ((byte *)(param_2 - (int)param_4) < pbVar14) { + return (byte *)0; + } + } + } while( true ); +LAB_2307188c: + if (param_3[(int)pbVar12] == param_3[(int)pbVar5]) { + if (__n == pbVar6) { + __n = (byte *)0x1; + } + else { + __n = __n + 1; + pbVar12 = pbVar10; + } + } + else { + pbVar6 = (byte *)0x1; + __n = (byte *)0x1; + pbVar14 = pbVar10; + pbVar12 = pbVar10 + 1; + } + goto LAB_230716b8; +} + + + +char * strstr(char *__haystack,char *__needle) + +{ + byte bVar1; + byte bVar2; + char cVar3; + size_t __n; + size_t sVar4; + int iVar5; + uint __c; + char *pcVar6; + uint uVar7; + byte *pbVar8; + uint uVar9; + char *pcVar10; + byte abStack96 [68]; + + __c = (uint)(byte)*__needle; + if (*__needle != 0) { + uVar7 = (uint)(byte)__needle[1]; + if (__needle[1] == 0) { + __haystack = strchr(__haystack,__c); + } + else { + bVar1 = __needle[2]; + if (bVar1 == 0) { + uVar9 = (uint)(byte)*__haystack; + if (*__haystack != 0) { + bVar1 = __haystack[1]; + pcVar10 = __haystack + 1; + while (pcVar6 = pcVar10, uVar9 = (uint)bVar1 | uVar9 << 0x10, bVar1 != 0) { + bVar1 = pcVar6[1]; + pcVar10 = pcVar6 + 1; + if ((__c << 0x10 | uVar7) == uVar9) { + return pcVar6 + -1; + } + } + } + } + else { + if (__needle[3] == 0) { + if (*__haystack != 0) { + uVar9 = (uint)(byte)*__haystack << 8; + bVar2 = __haystack[1]; + pcVar10 = __haystack + 1; + while (pcVar6 = pcVar10, uVar9 = (bVar2 | uVar9) << 8, bVar2 != 0) { + bVar2 = pcVar6[1]; + pcVar10 = pcVar6 + 1; + if ((__c << 0x18 | uVar7 << 0x10 | (uint)bVar1 << 8) == uVar9) { + return pcVar6 + -2; + } + } + } + } + else { + if (__needle[4] == '\0') { + bVar2 = *__haystack; + __c = __c << 0x18 | uVar7 << 0x10 | (uint)(byte)__needle[3] | (uint)bVar1 << 8; + if (bVar2 != 0) { + uVar7 = 0; + do { + pcVar10 = __haystack; + uVar7 = (uint)bVar2 | uVar7 << 8; + bVar2 = pcVar10[1]; + if (bVar2 == 0) { + if (__c != uVar7) goto LAB_23071c58; + break; + } + __haystack = pcVar10 + 1; + } while (__c != uVar7); + return pcVar10 + -3; + } + } + else { + __n = strlen(__needle); + sVar4 = strnlen(__haystack,__n | 0x200); + if (__n <= sVar4) { + if (0xfe < __n) { + pcVar10 = (char *)two_way_long_needle(__haystack,sVar4,__needle,__n); + return pcVar10; + } + pcVar10 = __haystack + (sVar4 - __n); + memset(abStack96,__n + 1,0x40); + if (__n != 0) { + pbVar8 = (byte *)__needle; + do { + bVar1 = *pbVar8; + cVar3 = (char)pbVar8; + pbVar8 = pbVar8 + 1; + abStack96[(uint)bVar1 & 0x3f] = ((char)__needle + (char)__n) - cVar3; + } while ((byte *)(__needle + __n) != pbVar8); + } + while( true ) { + __haystack = __haystack + -1 + abStack96[(uint)(byte)(__haystack + -1)[__n] & 0x3f]; + while (__haystack <= pcVar10) { + bVar1 = abStack96[(uint)(byte)__haystack[__n] & 0x3f]; + iVar5 = memcmp(__haystack,__needle,__n); + if (iVar5 == 0) { + return __haystack; + } + __haystack = __haystack + bVar1; + } + if (pcVar10[__n] == '\0') break; + sVar4 = strnlen(pcVar10 + __n,0x800); + pcVar10 = pcVar10 + sVar4; + if (pcVar10 < __haystack) { + return (char *)0x0; + } + } + } + } + } + } +LAB_23071c58: + __haystack = (char *)0x0; + } + } + return __haystack; +} + + + +uint _strtol_l_isra_0(undefined4 *param_1,byte *param_2,byte **param_3,uint param_4) + +{ + byte bVar1; + bool bVar2; + uint uVar3; + byte *pbVar4; + uint uVar5; + byte *pbVar6; + uint uVar7; + uint uVar8; + int iVar9; + uint uVar10; + + pbVar6 = param_2; + do { + pbVar4 = pbVar6; + pbVar6 = pbVar4 + 1; + bVar1 = *pbVar4; + uVar7 = (uint)bVar1; + } while ((_ctype_[uVar7 + 1] & 8) != 0); + if (bVar1 == 0x2d) { + uVar7 = (uint)*pbVar6; + bVar2 = true; + pbVar6 = pbVar4 + 2; +LAB_23071d58: + if (param_4 != 0) goto LAB_23071d5c; +LAB_23071de0: + if (uVar7 != 0x30) { + uVar10 = 10; + param_4 = 10; + goto LAB_23071d68; + } + if ((*pbVar6 & 0xdf) != 0x58) { + uVar10 = 8; + param_4 = 8; + goto LAB_23071d68; + } + } + else { + if (bVar1 != 0x2b) { + bVar2 = false; + goto LAB_23071d58; + } + uVar7 = (uint)*pbVar6; + bVar2 = false; + pbVar6 = pbVar4 + 2; + if (param_4 == 0) goto LAB_23071de0; +LAB_23071d5c: + uVar10 = param_4; + if (param_4 != 0x10) goto LAB_23071d68; + if ((uVar7 != 0x30) || ((*pbVar6 & 0xdf) != 0x58)) { + uVar10 = 0x10; + goto LAB_23071d68; + } + } + uVar7 = (uint)pbVar6[1]; + uVar10 = 0x10; + pbVar6 = pbVar6 + 2; + param_4 = 0x10; +LAB_23071d68: + uVar3 = 0x80000000; + if (!bVar2) { + uVar3 = 0x7fffffff; + } + iVar9 = 0; + uVar5 = 0; + do { + uVar8 = uVar7 - 0x30; + if (9 < uVar8) { + if (uVar7 - 0x41 < 0x1a) { + uVar8 = uVar7 - 0x37; + } + else { + if (0x19 < uVar7 - 0x61) break; + uVar8 = uVar7 - 0x57; + } + } + if ((int)param_4 <= (int)uVar8) break; + if (((iVar9 != -1) && (iVar9 = -1, uVar5 <= uVar3 / uVar10)) && + ((uVar3 / uVar10 != uVar5 || ((int)uVar8 <= (int)(uVar3 % uVar10))))) { + iVar9 = 1; + uVar5 = uVar8 + uVar10 * uVar5; + } + uVar7 = (uint)*pbVar6; + pbVar6 = pbVar6 + 1; + } while( true ); + if (iVar9 == -1) { + *param_1 = 0x22; + if (param_3 == (byte **)0x0) { + return uVar3; + } + } + else { + uVar3 = uVar5; + if (bVar2) { + uVar3 = -uVar5; + } + if (param_3 == (byte **)0x0) { + return uVar3; + } + if (iVar9 == 0) goto LAB_23071e1c; + } + param_2 = pbVar6 + -1; +LAB_23071e1c: + *param_3 = param_2; + return uVar3; +} + + + +uint _strtol_r(undefined4 *param_1,byte *param_2,byte **param_3,uint param_4) + +{ + byte bVar1; + bool bVar2; + uint uVar3; + byte *pbVar4; + uint uVar5; + byte *pbVar6; + uint uVar7; + uint uVar8; + int iVar9; + uint uVar10; + + pbVar6 = param_2; + do { + pbVar4 = pbVar6; + pbVar6 = pbVar4 + 1; + bVar1 = *pbVar4; + uVar7 = (uint)bVar1; + } while ((_ctype_[uVar7 + 1] & 8) != 0); + if (bVar1 == 0x2d) { + uVar7 = (uint)*pbVar6; + bVar2 = true; + pbVar6 = pbVar4 + 2; +LAB_23071d58: + if (param_4 != 0) goto LAB_23071d5c; +LAB_23071de0: + if (uVar7 != 0x30) { + uVar10 = 10; + param_4 = 10; + goto LAB_23071d68; + } + if ((*pbVar6 & 0xdf) != 0x58) { + uVar10 = 8; + param_4 = 8; + goto LAB_23071d68; + } + } + else { + if (bVar1 != 0x2b) { + bVar2 = false; + goto LAB_23071d58; + } + uVar7 = (uint)*pbVar6; + bVar2 = false; + pbVar6 = pbVar4 + 2; + if (param_4 == 0) goto LAB_23071de0; +LAB_23071d5c: + uVar10 = param_4; + if (param_4 != 0x10) goto LAB_23071d68; + if ((uVar7 != 0x30) || ((*pbVar6 & 0xdf) != 0x58)) { + uVar10 = 0x10; + goto LAB_23071d68; + } + } + uVar7 = (uint)pbVar6[1]; + uVar10 = 0x10; + pbVar6 = pbVar6 + 2; + param_4 = 0x10; +LAB_23071d68: + uVar3 = 0x80000000; + if (!bVar2) { + uVar3 = 0x7fffffff; + } + iVar9 = 0; + uVar5 = 0; + do { + uVar8 = uVar7 - 0x30; + if (9 < uVar8) { + if (uVar7 - 0x41 < 0x1a) { + uVar8 = uVar7 - 0x37; + } + else { + if (0x19 < uVar7 - 0x61) break; + uVar8 = uVar7 - 0x57; + } + } + if ((int)param_4 <= (int)uVar8) break; + if (((iVar9 != -1) && (iVar9 = -1, uVar5 <= uVar3 / uVar10)) && + ((uVar3 / uVar10 != uVar5 || ((int)uVar8 <= (int)(uVar3 % uVar10))))) { + iVar9 = 1; + uVar5 = uVar8 + uVar10 * uVar5; + } + uVar7 = (uint)*pbVar6; + pbVar6 = pbVar6 + 1; + } while( true ); + if (iVar9 == -1) { + *param_1 = 0x22; + if (param_3 == (byte **)0x0) { + return uVar3; + } + } + else { + uVar3 = uVar5; + if (bVar2) { + uVar3 = -uVar5; + } + if (param_3 == (byte **)0x0) { + return uVar3; + } + if (iVar9 == 0) goto LAB_23071e1c; + } + param_2 = pbVar6 + -1; +LAB_23071e1c: + *param_3 = param_2; + return uVar3; +} + + + +long strtol_l(char *__nptr,char **__endptr,int __base,__locale_t __loc) + +{ + long lVar1; + + lVar1 = _strtol_l_isra_0(_impure_ptr,__nptr,__endptr,__base); + return lVar1; +} + + + +long strtol(char *__nptr,char **__endptr,int __base) + +{ + long lVar1; + + lVar1 = _strtol_l_isra_0(_impure_ptr,__nptr,__endptr,__base); + return lVar1; +} + + + +int stat(char *__file,stat *__buf) + +{ + int iVar1; + + iVar1 = _stat_r(_impure_ptr,__file,__buf); + return iVar1; +} + + + +void _stat_r(int *param_1,undefined4 param_2,undefined4 param_3) + +{ + int iVar1; + + errno = 0; + iVar1 = _stat(param_2,param_3); + if ((iVar1 == -1) && (errno != 0)) { + *param_1 = errno; + return; + } + return; +} + + + +int _stat(int param_1,undefined4 param_2) + +{ + int *piVar1; + undefined auStack144 [132]; + + ecall(); + if (param_1 < 0) { + piVar1 = (int *)__errno(auStack144,0,0,0,0,0x40e); + *piVar1 = -param_1; + param_1 = -1; + } + _conv_stat(param_2,auStack144); + return param_1; +} + + + +void _conv_stat(undefined2 *param_1,undefined4 *param_2) + +{ + undefined4 uVar1; + undefined4 uVar2; + undefined4 uVar3; + undefined4 uVar4; + undefined4 uVar5; + undefined4 uVar6; + undefined4 uVar7; + undefined4 uVar8; + undefined4 uVar9; + undefined4 uVar10; + undefined4 uVar11; + undefined4 uVar12; + undefined4 uVar13; + undefined4 uVar14; + undefined4 uVar15; + + uVar3 = param_2[5]; + uVar1 = param_2[6]; + uVar15 = param_2[7]; + uVar14 = param_2[8]; + uVar13 = param_2[0xc]; + uVar12 = param_2[0x10]; + uVar2 = param_2[0xe]; + uVar10 = param_2[0x12]; + uVar11 = param_2[0x13]; + uVar6 = param_2[0x16]; + uVar4 = param_2[4]; + uVar5 = param_2[2]; + uVar7 = param_2[0x17]; + uVar8 = param_2[0x1a]; + uVar9 = param_2[0x1b]; + *param_1 = (short)*param_2; + param_1[1] = (short)uVar5; + *(undefined4 *)(param_1 + 2) = uVar4; + param_1[4] = (short)uVar3; + param_1[5] = (short)uVar1; + param_1[6] = (short)uVar15; + param_1[7] = (short)uVar14; + *(undefined4 *)(param_1 + 8) = uVar13; + *(undefined4 *)(param_1 + 0x24) = uVar12; + *(undefined4 *)(param_1 + 0x22) = uVar2; + *(undefined4 *)(param_1 + 0xc) = uVar10; + *(undefined4 *)(param_1 + 0xe) = uVar11; + *(undefined4 *)(param_1 + 0x14) = uVar6; + *(undefined4 *)(param_1 + 0x16) = uVar7; + *(undefined4 *)(param_1 + 0x1c) = uVar8; + *(undefined4 *)(param_1 + 0x1e) = uVar9; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_On_BG(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4a0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010828)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_Off_BG(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4aa. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101082c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_On_LDO11_SOC(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4b4. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010830)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_Off_LDO11_SOC(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4be. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010834)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_On_LDO15_RF(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4c8. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010838)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_Off_LDO15_RF(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4d2. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101083c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_On_SFReg(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4dc. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010840)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_Off_SFReg(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4e6. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010844)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_LowPower_Enter_PDS0(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4f0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010848)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_LowPower_Exit_PDS0(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4fa. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101084c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ASM_Delay_Us(uint32_t core,uint32_t cnt) + +{ + // WARNING: Could not recover jumptable at 0x4200c504. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010850)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void BL602_Delay_US(uint32_t cnt) + +{ + // WARNING: Could not recover jumptable at 0x4200c50e. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010854)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void BL602_Delay_MS(uint32_t cnt) + +{ + // WARNING: Could not recover jumptable at 0x4200c518. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010858)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void * BL602_MemCpy(void *dst,void *src,uint32_t n) + +{ + void *pvVar1; + + // WARNING: Could not recover jumptable at 0x4200c522. Too many branches + // WARNING: Treating indirect jump as call + pvVar1 = (void *)(*_DAT_2101085c)(); + return pvVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t * BL602_MemCpy4(uint32_t *dst,uint32_t *src,uint32_t n) + +{ + uint32_t *puVar1; + + // WARNING: Could not recover jumptable at 0x4200c52c. Too many branches + // WARNING: Treating indirect jump as call + puVar1 = (uint32_t *)(*_DAT_21010860)(); + return puVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void * BL602_MemCpy_Fast(void *pdst,void *psrc,uint32_t n) + +{ + void *pvVar1; + + // WARNING: Could not recover jumptable at 0x4200c536. Too many branches + // WARNING: Treating indirect jump as call + pvVar1 = (void *)(*_DAT_21010864)(); + return pvVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void * BL602_MemSet(void *s,uint8_t c,uint32_t n) + +{ + void *pvVar1; + + // WARNING: Could not recover jumptable at 0x4200c540. Too many branches + // WARNING: Treating indirect jump as call + pvVar1 = (void *)(*_DAT_21010868)(); + return pvVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t * BL602_MemSet4(uint32_t *dst,uint32_t val,uint32_t n) + +{ + uint32_t *puVar1; + + // WARNING: Could not recover jumptable at 0x4200c54a. Too many branches + // WARNING: Treating indirect jump as call + puVar1 = (uint32_t *)(*_DAT_2101086c)(); + return puVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int BL602_MemCmp(void *s1,void *s2,uint32_t n) + +{ + int iVar1; + + // WARNING: Could not recover jumptable at 0x4200c554. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*_DAT_21010870)(); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Sw_AHB_Clk_0(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c55e. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010874)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Program_Efuse_0(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c568. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010878)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Load_Efuse_R0(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c572. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_2101087c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Sts_Type EF_Ctrl_Busy(void) + +{ + BL_Sts_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c57c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010880)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Sts_Type EF_Ctrl_AutoLoad_Done(void) + +{ + BL_Sts_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c586. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010884)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Clear(uint32_t index,uint32_t len) + +{ + // WARNING: Could not recover jumptable at 0x4200c590. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010894)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_SW_System_Reset(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c59a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108bc)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_SW_CPU_Reset(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5a4. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108c0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_SW_POR_Reset(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5ae. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108c4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Select_Internal_Flash(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5b8. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108c8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Select_External_Flash(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5c2. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108cc)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Deswap_Flash_Pin(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5cc. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108d0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Swap_Flash_Pin(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5d6. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108d4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_GPIO_Init(GLB_GPIO_Cfg_Type *cfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5e0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108d8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_GPIO_OUTPUT_Enable(GLB_GPIO_Type gpioPin) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5ea. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108dc)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_GPIO_OUTPUT_Disable(GLB_GPIO_Type gpioPin) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5f4. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108e0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_GPIO_Set_HZ(GLB_GPIO_Type gpioPin) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5fe. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108e4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t GLB_GPIO_Get_Fun(GLB_GPIO_Type gpioPin) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c608. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_210108e8)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void HBN_Mode_Enter(HBN_APP_CFG_Type *cfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c612. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210108ec)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void HBN_Power_Down_Flash(SPI_Flash_Cfg_Type *flashCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c61c. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210108f0)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void HBN_Enable(uint8_t aGPIOIeCfg,HBN_LDO_LEVEL_Type ldoLevel,HBN_LEVEL_Type hbnLevel) + +{ + // WARNING: Could not recover jumptable at 0x4200c626. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210108f4)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Reset(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c630. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108f8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Set_Ldo11_Aon_Vout(HBN_LDO_LEVEL_Type ldoLevel) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c63a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108fc)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Set_Ldo11_Rt_Vout(HBN_LDO_LEVEL_Type ldoLevel) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c644. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010900)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Set_Ldo11_Soc_Vout(HBN_LDO_LEVEL_Type ldoLevel) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c64e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010904)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Hw_Pu_Pd_Cfg(uint8_t enable) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c658. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010924)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Pin_WakeUp_Mask(uint8_t maskVal) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c662. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010928)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +HBN_GPIO7_Dbg_Pull_Cfg(BL_Fun_Type pupdEn,BL_Fun_Type iesmtEn,BL_Fun_Type dlyEn,uint8_t dlySec) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c66c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101092c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Set_Embedded_Flash_Pullup(uint8_t enable) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c676. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010930)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type L1C_Set_Wrap(BL_Fun_Type wrap) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c680. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010934)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type L1C_Set_Way_Disable(uint8_t disableVal) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c68a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010938)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type L1C_IROM_2T_Access_Set(uint8_t enable) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c694. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101093c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Reset(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c69e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010940)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Force_Config(PDS_CTL2_Type *cfg2,PDS_CTL3_Type *cfg3) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c6a8. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010948)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_RAM_Config(PDS_RAM_CFG_Type *ramCfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c6b2. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101094c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +PDS_Default_Level_Config + (PDS_DEFAULT_LV_CFG_Type *defaultLvCfg,PDS_RAM_CFG_Type *ramCfg,uint32_t pdsSleepCnt) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c6bc. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010950)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SEC_Eng_Turn_On_Sec_Ring(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c6c6. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010978)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SEC_Eng_Turn_Off_Sec_Ring(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c6d0. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_2101097c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Init(SF_Ctrl_Cfg_Type *pSfCtrlCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c6da. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010980)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_SetSPIMode(SF_Ctrl_Mode_Type mode) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c6e4. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010984)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Read_Reg(SPI_Flash_Cfg_Type *flashCfg,uint8_t regIndex,uint8_t *regValue,uint8_t regLen) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c6ee. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010988)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Write_Reg(SPI_Flash_Cfg_Type *flashCfg,uint8_t regIndex,uint8_t *regValue,uint8_t regLen) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c6f8. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101098c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Sts_Type SFlash_Busy(SPI_Flash_Cfg_Type *flashCfg) + +{ + BL_Sts_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c702. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010990)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Write_Enable(SPI_Flash_Cfg_Type *flashCfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c70c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010994)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Qspi_Enable(SPI_Flash_Cfg_Type *flashCfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c716. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010998)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Volatile_Reg_Write_Enable(SPI_Flash_Cfg_Type *flashCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c720. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_2101099c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Chip_Erase(SPI_Flash_Cfg_Type *flashCfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c72a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109a0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Sector_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t secNum) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c734. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109a4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Blk32_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t blkNum) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c73e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109a8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Blk64_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t blkNum) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c748. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109ac)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t startaddr,uint32_t endaddr) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c752. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109b0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Program(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint32_t addr,uint8_t *data, + uint32_t len) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c75c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109b4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_GetUniqueId(uint8_t *data,uint8_t idLen) + +{ + // WARNING: Could not recover jumptable at 0x4200c766. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109b8)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_GetJedecId(SPI_Flash_Cfg_Type *flashCfg,uint8_t *data) + +{ + // WARNING: Could not recover jumptable at 0x4200c770. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109bc)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_GetDeviceId(uint8_t *data) + +{ + // WARNING: Could not recover jumptable at 0x4200c77a. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109c0)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Powerdown(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c784. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109c4)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Releae_Powerdown(SPI_Flash_Cfg_Type *flashCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c78e. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109c8)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_SetBurstWrap(SPI_Flash_Cfg_Type *flashCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c798. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109cc)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_DisableBurstWrap(SPI_Flash_Cfg_Type *flashCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c7a2. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109d0)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Software_Reset(SPI_Flash_Cfg_Type *flashCfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c7ac. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109d4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Reset_Continue_Read(SPI_Flash_Cfg_Type *flashCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c7b6. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109d8)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Set_IDbus_Cfg + (SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead,uint32_t addr, + uint32_t len) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c7c0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109dc)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_IDbus_Read_Enable(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c7ca. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109e0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Cache_Enable_Set(uint8_t wayDisable) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c7d4. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109e4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Cache_Flush(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c7de. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109e8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Cache_Read_Enable + (SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead,uint8_t wayDisable) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c7e8. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109ec)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Cache_Hit_Count_Get(uint32_t *hitCountLow,uint32_t *hitCountHigh) + +{ + // WARNING: Could not recover jumptable at 0x4200c7f2. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109f0)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t SFlash_Cache_Miss_Count_Get(void) + +{ + uint32_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c7fc. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_210109f4)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Cache_Read_Disable(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c806. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109f8)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Read(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead,uint32_t addr, + uint8_t *data,uint32_t len) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c810. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109fc)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Read_Reg_With_Cmd + (SPI_Flash_Cfg_Type *flashCfg,uint8_t readRegCmd,uint8_t *regValue,uint8_t regLen) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c81a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a00)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Write_Reg_With_Cmd + (SPI_Flash_Cfg_Type *flashCfg,uint8_t writeRegCmd,uint8_t *regValue,uint8_t regLen) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c824. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a04)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Cfg_Init_Ext_Flash_Gpio(uint8_t extFlashPin) + +{ + // WARNING: Could not recover jumptable at 0x4200c82e. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a0c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Cfg_Init_Internal_Flash_Gpio(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c838. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a10)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Cfg_Deinit_Ext_Flash_Gpio(uint8_t extFlashPin) + +{ + // WARNING: Could not recover jumptable at 0x4200c842. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a14)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Cfg_Restore_GPIO17_Fun(uint8_t fun) + +{ + // WARNING: Could not recover jumptable at 0x4200c84c. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a18)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SF_Cfg_Get_Flash_Cfg_Need_Lock(uint32_t flashID,SPI_Flash_Cfg_Type *pFlashCfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c856. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a1c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Cfg_Init_Flash_Gpio(uint8_t flashPinCfg,uint8_t restoreDefault) + +{ + // WARNING: Could not recover jumptable at 0x4200c860. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a20)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t SF_Cfg_Flash_Identify + (uint8_t callFromFlash,uint32_t autoScan,uint32_t flashPinCfg, + uint8_t restoreDefault,SPI_Flash_Cfg_Type *pFlashCfg) + +{ + undefined3 in_register_00002029; + uint32_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c86a. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010a24)(CONCAT31(in_register_00002029,callFromFlash)); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Enable(SF_Ctrl_Cfg_Type *cfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c874. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a28)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Select_Pad(SF_Ctrl_Pad_Sel sel) + +{ + // WARNING: Could not recover jumptable at 0x4200c87e. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a2c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Set_Owner(SF_Ctrl_Owner_Type owner) + +{ + // WARNING: Could not recover jumptable at 0x4200c888. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a30)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Disable(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c892. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a34)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Enable_BE(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c89c. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a38)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Enable_LE(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c8a6. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a3c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Set_Region + (uint8_t region,uint8_t enable,uint8_t hwKey,uint32_t startAddr,uint32_t endAddr, + uint8_t locked) + +{ + // WARNING: Could not recover jumptable at 0x4200c8b0. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a40)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Set_Key(uint8_t region,uint8_t *key,SF_Ctrl_AES_Key_Type keyType) + +{ + // WARNING: Could not recover jumptable at 0x4200c8ba. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a44)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Set_Key_BE(uint8_t region,uint8_t *key,SF_Ctrl_AES_Key_Type keyType) + +{ + // WARNING: Could not recover jumptable at 0x4200c8c4. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a48)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Set_IV(uint8_t region,uint8_t *iv,uint32_t addrOffset) + +{ + // WARNING: Could not recover jumptable at 0x4200c8ce. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a4c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Set_IV_BE(uint8_t region,uint8_t *iv,uint32_t addrOffset) + +{ + // WARNING: Could not recover jumptable at 0x4200c8d8. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a50)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Enable(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c8e2. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a54)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Disable(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c8ec. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a58)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Set_Flash_Image_Offset(uint32_t addrOffset) + +{ + // WARNING: Could not recover jumptable at 0x4200c8f6. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a5c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t SF_Ctrl_Get_Flash_Image_Offset(void) + +{ + uint32_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c900. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010a60)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Select_Clock(SF_Ctrl_Sahb_Type sahbType) + +{ + // WARNING: Could not recover jumptable at 0x4200c90a. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a64)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_SendCmd(SF_Ctrl_Cmd_Cfg_Type *cfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c914. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a68)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Icache_Set(SF_Ctrl_Cmd_Cfg_Type *cfg,uint8_t cmdValid) + +{ + // WARNING: Could not recover jumptable at 0x4200c91e. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a6c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Icache2_Set(SF_Ctrl_Cmd_Cfg_Type *cfg,uint8_t cmdValid) + +{ + // WARNING: Could not recover jumptable at 0x4200c928. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a70)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Sts_Type SF_Ctrl_GetBusyState(void) + +{ + BL_Sts_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c932. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a74)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t SF_Ctrl_Is_AES_Enable(void) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c93c. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010a78)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t SF_Ctrl_Get_Clock_Delay(void) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c946. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010a7c)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Set_Clock_Delay(uint8_t delay) + +{ + // WARNING: Could not recover jumptable at 0x4200c950. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a80)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type XIP_SFlash_State_Save(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t *offset) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c95a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a84)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type XIP_SFlash_State_Restore(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t offset) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c964. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a88)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +XIP_SFlash_Erase_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t startaddr,uint32_t endaddr) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c96e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a8c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +XIP_SFlash_Write_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *data,uint32_t len) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c978. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a90)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +XIP_SFlash_Read_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *data,uint32_t len) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c982. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a94)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type XIP_SFlash_GetJedecId_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint8_t *data) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c98c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a98)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type XIP_SFlash_GetDeviceId_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint8_t *data) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c996. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a9c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +XIP_SFlash_GetUniqueId_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint8_t *data,uint8_t idLen) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c9a0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010aa0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type XIP_SFlash_Read_Via_Cache_Need_Lock(uint32_t addr,uint8_t *data,uint32_t len) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c9aa. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010aa4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int XIP_SFlash_Read_With_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *dst,int len) + +{ + int iVar1; + + // WARNING: Could not recover jumptable at 0x4200c9b4. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*_DAT_21010aa8)(); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int XIP_SFlash_Write_With_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *src,int len) + +{ + int iVar1; + + // WARNING: Could not recover jumptable at 0x4200c9be. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*_DAT_21010aac)(); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int XIP_SFlash_Erase_With_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,int len) + +{ + int iVar1; + + // WARNING: Could not recover jumptable at 0x4200c9c8. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*_DAT_21010ab0)(); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void XIP_SFlash_Opt_Enter(uint8_t *aesEnable) + +{ + // WARNING: Could not recover jumptable at 0x4200c9d2. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010ab4)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void XIP_SFlash_Opt_Exit(uint8_t aesEnable) + +{ + // WARNING: Could not recover jumptable at 0x4200c9dc. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010ab8)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t BFLB_Soft_CRC32(void *dataIn,uint32_t len) + +{ + uint32_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c9e6. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010abc)(); + return uVar1; +} + + + +// WARNING: Control flow encountered bad instruction data + +BL_Err_Type ADC_Trim_TSEN(uint16_t *tsen_offset) + +{ + Efuse_TSEN_Refcode_Corner_Type trim; + + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +// WARNING: Control flow encountered bad instruction data + +BL_Err_Type ADC_Gain_Trim(void) + +{ + uint uVar1; + uint8_t a; + undefined3 extraout_var; + Efuse_ADC_Gain_Coeff_Type EStack36; + Efuse_ADC_Gain_Coeff_Type trim; + + EF_Ctrl_Read_ADC_Gain_Trim(&EStack36); + if ((int)EStack36 << 0x12 < 0) { + uVar1 = (uint)EStack36 >> 0xc; + a = EF_Ctrl_Get_Trim_Parity((uint)EStack36 & 0xfff,'\f'); + _a = (SFtype)CONCAT31(extraout_var,a); + if ((SFtype)(uVar1 & 1) == _a) { + adcGainCoeffCal.adcGainCoeffEnable = ENABLE; + adcGainCoeffCal.adcgainCoeffVal = SUB42(EStack36,0) & 0xfff; + if (((uint)EStack36 & 0x800) == 0) { + __extendsfdf2(_a); + __muldf3(); + __subdf3(); + } + else { + __extendsfdf2(_a); + __muldf3(); + __adddf3(); + } + __truncdfsf2(); + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); + } + } + return ERROR; +} + + + +uint8_t EF_Ctrl_Get_Trim_Parity(uint32_t val,uint8_t len) + +{ + undefined3 in_register_0000202d; + uint uVar1; + byte bVar2; + + uVar1 = 0; + bVar2 = 0; + while ((uVar1 & 0xff) < CONCAT31(in_register_0000202d,len)) { + if ((1 << (uVar1 & 0x1f) & val) != 0) { + bVar2 = bVar2 + 1; + } + uVar1 = uVar1 + 1; + } + return (uint8_t)(bVar2 & 1); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Read_RC32M_Trim(Efuse_Ana_RC32M_Trim_Type *trim) + +{ + uint uVar1; + uint uVar2; + + EF_Ctrl_Sw_AHB_Clk_0(); + EF_Ctrl_Load_Efuse_R0(); + uVar1 = _DAT_4000700c; + uVar2 = _DAT_4000700c >> 10; + *(char *)trim = (char)uVar2; + *(uint *)trim = (uint)*trim & 0xfffffcff | uVar2 & 0x100 | uVar1 >> 10 & 0x200; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Read_RC32K_Trim(Efuse_Ana_RC32K_Trim_Type *trim) + +{ + EF_Ctrl_Sw_AHB_Clk_0(); + EF_Ctrl_Load_Efuse_R0(); + *(uint *)trim = + (uint)*trim & 0xfffff000 | _DAT_4000700c >> 0x14 & 0x3ff | _DAT_4000700c >> 0x14 & 0x400 | + (_DAT_4000700c >> 0x1f) << 0xb; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Read_TSEN_Trim(Efuse_TSEN_Refcode_Corner_Type *trim) + +{ + uint uVar1; + Efuse_TSEN_Refcode_Corner_Type EVar2; + uint uVar3; + uint uVar4; + + EF_Ctrl_Sw_AHB_Clk_0(); + EF_Ctrl_Load_Efuse_R0(); + uVar3 = (_DAT_40007078 & 1) << 0xd; + EVar2 = *trim; + *(uint *)trim = (uint)EVar2 & 0xffffdfff | uVar3; + uVar4 = _DAT_4000707c & 0xfff; + uVar1 = _DAT_4000707c & 0x1000; + *(uint *)trim = (uint)EVar2 & 0xffffc000 | uVar3 | uVar4 | uVar1; + *(uint *)trim = + (uint)EVar2 & 0xffff8000 | uVar3 | uVar4 | uVar1 | (_DAT_40007070 >> 0x1e & 1) << 0xe; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Read_ADC_Gain_Trim(Efuse_ADC_Gain_Coeff_Type *trim) + +{ + EF_Ctrl_Sw_AHB_Clk_0(); + EF_Ctrl_Load_Efuse_R0(); + *(uint *)trim = + (uint)*trim & 0xffffc000 | (_DAT_40007078 << 0x13) >> 0x14 | + (_DAT_40007078 >> 0xd & 1) << 0xc | (_DAT_40007078 >> 0xe & 1) << 0xd; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_On_MBG(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cd8e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010810)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_Off_MBG(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cd98. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010814)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_On_XTAL(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cda2. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010818)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Set_Xtal_CapCode(uint8_t capIn,uint8_t capOut) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cdac. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101081c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t AON_Get_Xtal_CapCode(void) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200cdb6. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010820)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_Off_XTAL(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cdc0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010824)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t EF_Ctrl_Get_Trim_Parity(uint32_t val,uint8_t len) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200cdca. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010888)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Read_RC32M_Trim(Efuse_Ana_RC32M_Trim_Type *trim) + +{ + // WARNING: Could not recover jumptable at 0x4200cdd4. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_2101088c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Read_RC32K_Trim(Efuse_Ana_RC32K_Trim_Type *trim) + +{ + // WARNING: Could not recover jumptable at 0x4200cdde. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010890)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +GLB_ROOT_CLK_Type GLB_Get_Root_CLK_Sel(void) + +{ + GLB_ROOT_CLK_Type GVar1; + + // WARNING: Could not recover jumptable at 0x4200cde8. Too many branches + // WARNING: Treating indirect jump as call + GVar1 = (*_DAT_21010898)(); + return GVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Set_System_CLK_Div(uint8_t hclkDiv,uint8_t bclkDiv) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cdf2. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101089c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t GLB_Get_BCLK_Div(void) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200cdfc. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_210108a0)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t GLB_Get_HCLK_Div(void) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200ce06. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_210108a4)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type Update_SystemCoreClockWith_XTAL(GLB_PLL_XTAL_Type xtalType) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce10. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108a8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Set_System_CLK(GLB_PLL_XTAL_Type xtalType,GLB_SYS_CLK_Type clkFreq) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce1a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108ac)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type System_Core_Clock_Update_From_RC32M(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce24. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108b0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Set_SF_CLK(uint8_t enable,GLB_SFLASH_CLK_Type clkSel,uint8_t div) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce2e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108b4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Set_PKA_CLK_Sel(GLB_PKA_CLK_Type clkSel) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce38. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108b8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_32K_Sel(HBN_32K_CLK_Type clkType) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce42. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010908)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_Type rootClk) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce4c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101090c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Power_On_Xtal_32K(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce56. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010910)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Power_Off_Xtal_32K(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce60. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010914)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Power_On_RC32K(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce6a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010918)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Power_Off_RC32K(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce74. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101091c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Trim_RC32K(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce7e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010920)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Trim_RC32M(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce88. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010954)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Select_RC32M_As_PLL_Ref(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce92. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010958)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Select_XTAL_As_PLL_Ref(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce9c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101095c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Power_On_PLL(PDS_PLL_XTAL_Type xtalType) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cea6. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010960)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Enable_PLL_All_Clks(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ceb0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010964)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Disable_PLL_All_Clks(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ceba. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010968)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Enable_PLL_Clk(PDS_PLL_CLK_Type pllClk) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cec4. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101096c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Disable_PLL_Clk(PDS_PLL_CLK_Type pllClk) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cece. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010970)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Power_Off_PLL(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ced8. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010974)(); + return BVar1; +} + + diff --git a/blobs/bl602_demo_wifi.ghidra.h b/blobs/bl602_demo_wifi.ghidra.h new file mode 100755 index 0000000..fa8dadb --- /dev/null +++ b/blobs/bl602_demo_wifi.ghidra.h @@ -0,0 +1,41930 @@ +typedef unsigned char undefined; + +typedef unsigned char bool; +typedef unsigned char byte; +typedef unsigned int dword; +typedef long long longlong; +typedef unsigned long long qword; +typedef unsigned char uchar; +typedef unsigned int uint; +typedef unsigned long ulong; +typedef unsigned long long ulonglong; +typedef unsigned char undefined1; +typedef unsigned short undefined2; +typedef unsigned int undefined3; +typedef unsigned int undefined4; +typedef unsigned long long undefined5; +typedef unsigned long long undefined6; +typedef unsigned long long undefined7; +typedef unsigned long long undefined8; +typedef unsigned short ushort; +typedef unsigned short word; +#define unkbyte9 unsigned long long +#define unkbyte10 unsigned long long +#define unkbyte11 unsigned long long +#define unkbyte12 unsigned long long +#define unkbyte13 unsigned long long +#define unkbyte14 unsigned long long +#define unkbyte15 unsigned long long +#define unkbyte16 unsigned long long + +#define unkuint9 unsigned long long +#define unkuint10 unsigned long long +#define unkuint11 unsigned long long +#define unkuint12 unsigned long long +#define unkuint13 unsigned long long +#define unkuint14 unsigned long long +#define unkuint15 unsigned long long +#define unkuint16 unsigned long long + +#define unkint9 long long +#define unkint10 long long +#define unkint11 long long +#define unkint12 long long +#define unkint13 long long +#define unkint14 long long +#define unkint15 long long +#define unkint16 long long + +#define unkfloat1 float +#define unkfloat2 float +#define unkfloat3 float +#define unkfloat5 double +#define unkfloat6 double +#define unkfloat7 double +#define unkfloat9 long double +#define unkfloat11 long double +#define unkfloat12 long double +#define unkfloat13 long double +#define unkfloat14 long double +#define unkfloat15 long double +#define unkfloat16 long double + +#define BADSPACEBASE void +#define code void + +typedef struct stat stat, *Pstat; + +typedef ulonglong __u_quad_t; + +typedef __u_quad_t __dev_t; + +typedef ulong __ino_t; + +typedef uint __mode_t; + +typedef uint __nlink_t; + +typedef uint __uid_t; + +typedef uint __gid_t; + +typedef long __off_t; + +typedef long __blksize_t; + +typedef long __blkcnt_t; + +typedef struct timespec timespec, *Ptimespec; + +typedef long __time_t; + +struct timespec { + __time_t tv_sec; + long tv_nsec; +}; + +struct stat { + __dev_t st_dev; + ushort __pad1; + __ino_t st_ino; + __mode_t st_mode; + __nlink_t st_nlink; + __uid_t st_uid; + __gid_t st_gid; + __dev_t st_rdev; + ushort __pad2; + __off_t st_size; + __blksize_t st_blksize; + __blkcnt_t st_blocks; + struct timespec st_atim; + struct timespec st_mtim; + struct timespec st_ctim; + ulong __unused4; + ulong __unused5; +}; + +typedef undefined complex long double[32]; + +typedef qword complex float; + +typedef undefined complex double[16]; + +typedef bool _Bool; + +typedef struct trpc_env_tag trpc_env_tag, *Ptrpc_env_tag; + +typedef char int8_t; + +typedef short __int16_t; + +typedef __int16_t int16_t; + +struct trpc_env_tag { + int8_t power_dbm_max_rf; + int8_t power_dbm_min_rf; + int8_t power_dbm_lim_reg; + undefined field_0x3; + int16_t channel_freq; + int8_t temperature; + int8_t temperature_compensate; +}; + +typedef struct cfg80211_bss_select_adjust cfg80211_bss_select_adjust, *Pcfg80211_bss_select_adjust; + +typedef enum nl80211_band { + NL80211_BAND_2GHZ=0, + NL80211_BAND_5GHZ=1, + NL80211_BAND_60GHZ=2, + NUM_NL80211_BANDS=3 +} nl80211_band; + +typedef int8_t s8; + +struct cfg80211_bss_select_adjust { + enum nl80211_band band; + s8 delta; +}; + +typedef enum ieee80211_channel_flags { + IEEE80211_CHAN_DISABLED=1, + IEEE80211_CHAN_INDOOR_ONLY=512, + IEEE80211_CHAN_IR_CONCURRENT=1024, + IEEE80211_CHAN_NO_10MHZ=4096, + IEEE80211_CHAN_NO_160MHZ=256, + IEEE80211_CHAN_NO_20MHZ=2048, + IEEE80211_CHAN_NO_80MHZ=-128, + IEEE80211_CHAN_NO_HT40MINUS=32, + IEEE80211_CHAN_NO_HT40PLUS=16, + IEEE80211_CHAN_NO_IR=2, + IEEE80211_CHAN_NO_OFDM=64, + IEEE80211_CHAN_RADAR=8 +} ieee80211_channel_flags; + +typedef struct ieee80211_channel ieee80211_channel, *Pieee80211_channel; + +typedef ushort uint16_t; + +typedef uint16_t u16; + +typedef ulong uint32_t; + +typedef uint32_t u32.conflict10; + +typedef uint32_t u32.conflict11; + +typedef enum nl80211_dfs_state { + NL80211_DFS_AVAILABLE=2, + NL80211_DFS_UNAVAILABLE=1, + NL80211_DFS_USABLE=0 +} nl80211_dfs_state; + +struct ieee80211_channel { + enum nl80211_band band; + undefined field_0x1; + u16 center_freq; + u16 hw_value; + undefined field_0x6; + undefined field_0x7; + u32.conflict10 flags; + int max_antenna_gain; + int max_power; + int max_reg_power; + _Bool beacon_found; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; + u32.conflict11 orig_flags; + int orig_mag; + int orig_mpwr; + enum nl80211_dfs_state dfs_state; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; + ulong dfs_state_entered; + uint dfs_cac_ms; +}; + +typedef struct ieee80211_dot_d ieee80211_dot_d, *Pieee80211_dot_d; + +struct ieee80211_dot_d { + char * code; + int channel_num; + struct ieee80211_channel * channels; +}; + +typedef struct cfg80211_connect_params cfg80211_connect_params, *Pcfg80211_connect_params; + +typedef uchar u8; + +typedef uint size_t; + +typedef enum nl80211_auth_type { + NL80211_AUTHTYPE_AUTOMATIC=8, + NL80211_AUTHTYPE_FILS_PK=7, + NL80211_AUTHTYPE_FILS_SK=5, + NL80211_AUTHTYPE_FILS_SK_PFS=6, + NL80211_AUTHTYPE_FT=2, + NL80211_AUTHTYPE_MAX=7, + NL80211_AUTHTYPE_NETWORK_EAP=3, + NL80211_AUTHTYPE_OPEN_SYSTEM=0, + NL80211_AUTHTYPE_SAE=4, + NL80211_AUTHTYPE_SHARED_KEY=1, + __NL80211_AUTHTYPE_NUM=8 +} nl80211_auth_type; + +typedef enum nl80211_mfp { + NL80211_MFP_NO=0, + NL80211_MFP_REQUIRED=1 +} nl80211_mfp; + +typedef struct cfg80211_crypto_settings cfg80211_crypto_settings, *Pcfg80211_crypto_settings; + +typedef uint32_t u32.conflict19; + +typedef struct ieee80211_ht_cap ieee80211_ht_cap, *Pieee80211_ht_cap; + +typedef struct cfg80211_bss_selection cfg80211_bss_selection, *Pcfg80211_bss_selection; + +typedef uint32_t u32.conflict13; + +typedef uint32_t u32.conflict14; + +typedef uint32_t u32.conflict15; + +typedef uint32_t u32.conflict16; + +typedef uint16_t __be16; + +typedef struct key_params key_params, *Pkey_params; + +typedef uint16_t __le16; + +typedef struct ieee80211_mcs_info ieee80211_mcs_info, *Pieee80211_mcs_info; + +typedef uint32_t __le32; + +typedef enum nl80211_bss_select_attr { + NL80211_BSS_SELECT_ATTR_BAND_PREF=2, + NL80211_BSS_SELECT_ATTR_MAX=3, + NL80211_BSS_SELECT_ATTR_RSSI=1, + NL80211_BSS_SELECT_ATTR_RSSI_ADJUST=3, + __NL80211_BSS_SELECT_ATTR_AFTER_LAST=4, + __NL80211_BSS_SELECT_ATTR_INVALID=0 +} nl80211_bss_select_attr; + +typedef union anon_union_for_param anon_union_for_param, *Panon_union_for_param; + +typedef uint32_t u32.conflict12; + +union anon_union_for_param { + enum nl80211_band band_pref; + struct cfg80211_bss_select_adjust adjust; +}; + +struct cfg80211_bss_selection { + enum nl80211_bss_select_attr behaviour; + union anon_union_for_param param; +}; + +struct cfg80211_crypto_settings { + u32.conflict13 wpa_versions; + u32.conflict14 cipher_group; + int n_ciphers_pairwise; + u32.conflict15 ciphers_pairwise[5]; + int n_akm_suites; + u32.conflict16 akm_suites[2]; + _Bool control_port; + undefined field_0x2d; + __be16 control_port_ethertype; + _Bool control_port_no_encrypt; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct key_params * wep_keys; + int wep_tx_key; +}; + +struct ieee80211_mcs_info { + u8 rx_mask[10]; + __le16 rx_highest; + u8 tx_params; + u8 reserved[3]; +}; + +struct ieee80211_ht_cap { + __le16 cap_info; + u8 ampdu_params_info; + undefined field_0x3; + struct ieee80211_mcs_info mcs; + __le16 extended_ht_cap_info; + undefined field_0x16; + undefined field_0x17; + __le32 tx_BF_cap_info; + u8 antenna_selection_info; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +struct cfg80211_connect_params { + struct ieee80211_channel channel; + struct ieee80211_channel * channel_hint; + u8 * bssid; + u8 * bssid_hint; + u8 * ssid; + size_t ssid_len; + enum nl80211_auth_type auth_type; + undefined field_0x49; + undefined field_0x4a; + undefined field_0x4b; + u8 * ie; + size_t ie_len; + _Bool privacy; + enum nl80211_mfp mfp; + undefined field_0x56; + undefined field_0x57; + struct cfg80211_crypto_settings crypto; + u8 * key; + u8 * pmk; + u8 key_len; + u8 pmk_len; + u8 key_idx; + undefined field_0x9f; + u32.conflict19 flags; + int bg_scan_period; + struct ieee80211_ht_cap ht_capa; + struct ieee80211_ht_cap ht_capa_mask; + _Bool pbss; + struct cfg80211_bss_selection bss_select; + u8 * prev_bssid; +}; + +struct key_params { + u8 * key; + u8 * seq; + int key_len; + int seq_len; + u32.conflict12 cipher; +}; + +typedef struct ieee80211_sta_ht_cap ieee80211_sta_ht_cap, *Pieee80211_sta_ht_cap; + +struct ieee80211_sta_ht_cap { + u16 cap; + _Bool ht_supported; + u8 ampdu_factor; + u8 ampdu_density; + undefined field_0x5; + struct ieee80211_mcs_info mcs; +}; + +typedef enum wiphy_flags { + WIPHY_FLAG_4ADDR_AP=32, + WIPHY_FLAG_4ADDR_STATION=64, + WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD=524288, + WIPHY_FLAG_AP_UAPSD=16384, + WIPHY_FLAG_CONTROL_PORT_PROTOCOL=-128, + WIPHY_FLAG_HAS_CHANNEL_SWITCH=8388608, + WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL=2097152, + WIPHY_FLAG_HAS_STATIC_WEP=16777216, + WIPHY_FLAG_HAVE_AP_SME=131072, + WIPHY_FLAG_IBSS_RSN=256, + WIPHY_FLAG_MESH_AUTH=1024, + WIPHY_FLAG_NETNS_OK=8, + WIPHY_FLAG_OFFCHAN_TX=1048576, + WIPHY_FLAG_PS_ON_BY_DEFAULT=16, + WIPHY_FLAG_REPORTS_OBSS=262144, + WIPHY_FLAG_SUPPORTS_5_10_MHZ=4194304, + WIPHY_FLAG_SUPPORTS_FW_ROAM=8192, + WIPHY_FLAG_SUPPORTS_SCHED_SCAN=2048, + WIPHY_FLAG_SUPPORTS_TDLS=-32768, + WIPHY_FLAG_TDLS_EXTERNAL_SETUP=65536 +} wiphy_flags; + +typedef union anon_union.conflict185 anon_union.conflict185, *Panon_union.conflict185; + +union anon_union.conflict185 { + enum nl80211_band band_pref; + struct cfg80211_bss_select_adjust adjust; +}; + +typedef union anon_union.conflict182 anon_union.conflict182, *Panon_union.conflict182; + +union anon_union.conflict182 { + enum nl80211_band band_pref; + struct cfg80211_bss_select_adjust adjust; +}; + +typedef struct ke_evt_tag ke_evt_tag, *Pke_evt_tag; + +struct ke_evt_tag { + void (* func)(int); + int param; +}; + +typedef union MQTT_Connect_Header_Flags MQTT_Connect_Header_Flags, *PMQTT_Connect_Header_Flags; + +typedef uchar uint8_t; + +typedef struct anon_struct.conflict403 anon_struct.conflict403, *Panon_struct.conflict403; + +struct anon_struct.conflict403 { + uint cleansession:1; + uint will:1; + uint willQoS:2; + uint willRetain:1; + uint password:1; + uint username:1; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; +}; + +union MQTT_Connect_Header_Flags { + uint8_t all; + struct anon_struct.conflict403 bits; +}; + +typedef union MQTT_Connack_Header_Flags MQTT_Connack_Header_Flags, *PMQTT_Connack_Header_Flags; + +typedef struct anon_struct.conflict404 anon_struct.conflict404, *Panon_struct.conflict404; + +struct anon_struct.conflict404 { + uint sessionpresent:1; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; +}; + +union MQTT_Connack_Header_Flags { + uint8_t all; + struct anon_struct.conflict404 bits; +}; + +typedef struct cipher_key_buf cipher_key_buf, *Pcipher_key_buf; + +typedef struct cipher_key_buf cipher_key_buf_t; + +typedef struct cipher_key_t cipher_key_t, *Pcipher_key_t; + +typedef union ckd ckd, *Pckd; + +typedef struct eapolHskData_t eapolHskData_t, *PeapolHskData_t; + +typedef uchar UINT8; + +typedef struct KeyData_t KeyData_t, *PKeyData_t; + +typedef ulong UINT32; + +typedef ushort UINT16; + +struct KeyData_t { + UINT8 Key[16]; + UINT8 RxMICKey[8]; + UINT8 TxMICKey[8]; + UINT32 TxIV32; + UINT16 TxIV16; + UINT16 KeyIndex; +}; + +struct eapolHskData_t { + UINT8 ANonce[32]; + struct KeyData_t pwsKeyData; +}; + +union ckd { + struct eapolHskData_t hskData; +}; + +struct cipher_key_t { + union ckd ckd; +}; + +struct cipher_key_buf { + struct cipher_key_t cipher_key; +}; + +typedef void * __gnuc_va_list; + +typedef __gnuc_va_list va_list; + +typedef struct _TLSDataParams.conflict8 _TLSDataParams.conflict8, *P_TLSDataParams.conflict8; + +typedef struct _TLSDataParams.conflict8 TLSDataParams.conflict6; + +typedef struct mbedtls_entropy_context mbedtls_entropy_context, *Pmbedtls_entropy_context; + +typedef struct mbedtls_ctr_drbg_context mbedtls_ctr_drbg_context, *Pmbedtls_ctr_drbg_context; + +typedef struct mbedtls_ssl_context.conflict12 mbedtls_ssl_context.conflict12, *Pmbedtls_ssl_context.conflict12; + +typedef struct mbedtls_ssl_config.conflict15 mbedtls_ssl_config.conflict15, *Pmbedtls_ssl_config.conflict15; + +typedef struct mbedtls_ssl_session mbedtls_ssl_session, *Pmbedtls_ssl_session; + +typedef struct mbedtls_ssl_context mbedtls_ssl_context, *Pmbedtls_ssl_context; + +typedef struct mbedtls_x509_crt mbedtls_x509_crt, *Pmbedtls_x509_crt; + +typedef struct mbedtls_pk_context mbedtls_pk_context, *Pmbedtls_pk_context; + +typedef struct mbedtls_net_context mbedtls_net_context, *Pmbedtls_net_context; + +typedef struct mbedtls_sha256_context mbedtls_sha256_context, *Pmbedtls_sha256_context; + +typedef struct mbedtls_entropy_source_state mbedtls_entropy_source_state, *Pmbedtls_entropy_source_state; + +typedef struct mbedtls_aes_context mbedtls_aes_context, *Pmbedtls_aes_context; + +typedef struct mbedtls_ssl_config mbedtls_ssl_config, *Pmbedtls_ssl_config; + +typedef struct mbedtls_ssl_handshake_params mbedtls_ssl_handshake_params, *Pmbedtls_ssl_handshake_params; + +typedef struct mbedtls_ssl_transform mbedtls_ssl_transform, *Pmbedtls_ssl_transform; + +typedef struct mbedtls_asn1_buf mbedtls_asn1_buf, *Pmbedtls_asn1_buf; + +typedef struct mbedtls_asn1_buf mbedtls_x509_buf; + +typedef struct mbedtls_asn1_named_data mbedtls_asn1_named_data, *Pmbedtls_asn1_named_data; + +typedef struct mbedtls_asn1_named_data mbedtls_x509_name; + +typedef struct mbedtls_x509_time mbedtls_x509_time, *Pmbedtls_x509_time; + +typedef struct mbedtls_asn1_sequence mbedtls_asn1_sequence, *Pmbedtls_asn1_sequence; + +typedef struct mbedtls_asn1_sequence mbedtls_x509_sequence; + +typedef enum mbedtls_md_type_t { + MBEDTLS_MD_MD2=1, + MBEDTLS_MD_MD4=2, + MBEDTLS_MD_MD5=3, + MBEDTLS_MD_NONE=0, + MBEDTLS_MD_RIPEMD160=9, + MBEDTLS_MD_SHA1=4, + MBEDTLS_MD_SHA224=5, + MBEDTLS_MD_SHA256=6, + MBEDTLS_MD_SHA384=7, + MBEDTLS_MD_SHA512=8 +} mbedtls_md_type_t; + +typedef enum mbedtls_pk_type_t { + MBEDTLS_PK_ECDSA=4, + MBEDTLS_PK_ECKEY=2, + MBEDTLS_PK_ECKEY_DH=3, + MBEDTLS_PK_NONE=0, + MBEDTLS_PK_RSA=1, + MBEDTLS_PK_RSASSA_PSS=6, + MBEDTLS_PK_RSA_ALT=5 +} mbedtls_pk_type_t; + +typedef struct mbedtls_x509_crt_profile mbedtls_x509_crt_profile, *Pmbedtls_x509_crt_profile; + +typedef struct mbedtls_ssl_key_cert mbedtls_ssl_key_cert, *Pmbedtls_ssl_key_cert; + +typedef struct mbedtls_x509_crl mbedtls_x509_crl, *Pmbedtls_x509_crl; + +typedef enum mbedtls_ecp_group_id { + MBEDTLS_ECP_DP_BP256R1=6, + MBEDTLS_ECP_DP_BP384R1=7, + MBEDTLS_ECP_DP_BP512R1=8, + MBEDTLS_ECP_DP_CURVE25519=9, + MBEDTLS_ECP_DP_NONE=0, + MBEDTLS_ECP_DP_SECP192K1=10, + MBEDTLS_ECP_DP_SECP192R1=1, + MBEDTLS_ECP_DP_SECP224K1=11, + MBEDTLS_ECP_DP_SECP224R1=2, + MBEDTLS_ECP_DP_SECP256K1=12, + MBEDTLS_ECP_DP_SECP256R1=3, + MBEDTLS_ECP_DP_SECP384R1=4, + MBEDTLS_ECP_DP_SECP521R1=5 +} mbedtls_ecp_group_id; + +typedef struct mbedtls_pk_info_t mbedtls_pk_info_t, *Pmbedtls_pk_info_t; + +typedef struct mbedtls_pk_debug_item mbedtls_pk_debug_item, *Pmbedtls_pk_debug_item; + +typedef struct mbedtls_ssl_flight_item mbedtls_ssl_flight_item, *Pmbedtls_ssl_flight_item; + +typedef struct mbedtls_ssl_ciphersuite_t mbedtls_ssl_ciphersuite_t, *Pmbedtls_ssl_ciphersuite_t; + +typedef struct mbedtls_md_context_t mbedtls_md_context_t, *Pmbedtls_md_context_t; + +typedef struct mbedtls_cipher_context_t mbedtls_cipher_context_t, *Pmbedtls_cipher_context_t; + +typedef struct mbedtls_x509_crl_entry mbedtls_x509_crl_entry, *Pmbedtls_x509_crl_entry; + +typedef enum mbedtls_pk_debug_type { + MBEDTLS_PK_DEBUG_ECP=2, + MBEDTLS_PK_DEBUG_MPI=1, + MBEDTLS_PK_DEBUG_NONE=0 +} mbedtls_pk_debug_type; + +typedef enum mbedtls_cipher_type_t { + MBEDTLS_CIPHER_AES_128_CBC=5, + MBEDTLS_CIPHER_AES_128_CCM=43, + MBEDTLS_CIPHER_AES_128_CFB128=8, + MBEDTLS_CIPHER_AES_128_CTR=11, + MBEDTLS_CIPHER_AES_128_ECB=2, + MBEDTLS_CIPHER_AES_128_GCM=14, + MBEDTLS_CIPHER_AES_192_CBC=6, + MBEDTLS_CIPHER_AES_192_CCM=44, + MBEDTLS_CIPHER_AES_192_CFB128=9, + MBEDTLS_CIPHER_AES_192_CTR=12, + MBEDTLS_CIPHER_AES_192_ECB=3, + MBEDTLS_CIPHER_AES_192_GCM=15, + MBEDTLS_CIPHER_AES_256_CBC=7, + MBEDTLS_CIPHER_AES_256_CCM=45, + MBEDTLS_CIPHER_AES_256_CFB128=10, + MBEDTLS_CIPHER_AES_256_CTR=13, + MBEDTLS_CIPHER_AES_256_ECB=4, + MBEDTLS_CIPHER_AES_256_GCM=16, + MBEDTLS_CIPHER_ARC4_128=42, + MBEDTLS_CIPHER_BLOWFISH_CBC=39, + MBEDTLS_CIPHER_BLOWFISH_CFB64=40, + MBEDTLS_CIPHER_BLOWFISH_CTR=41, + MBEDTLS_CIPHER_BLOWFISH_ECB=38, + MBEDTLS_CIPHER_CAMELLIA_128_CBC=20, + MBEDTLS_CIPHER_CAMELLIA_128_CCM=46, + MBEDTLS_CIPHER_CAMELLIA_128_CFB128=23, + MBEDTLS_CIPHER_CAMELLIA_128_CTR=26, + MBEDTLS_CIPHER_CAMELLIA_128_ECB=17, + MBEDTLS_CIPHER_CAMELLIA_128_GCM=29, + MBEDTLS_CIPHER_CAMELLIA_192_CBC=21, + MBEDTLS_CIPHER_CAMELLIA_192_CCM=47, + MBEDTLS_CIPHER_CAMELLIA_192_CFB128=24, + MBEDTLS_CIPHER_CAMELLIA_192_CTR=27, + MBEDTLS_CIPHER_CAMELLIA_192_ECB=18, + MBEDTLS_CIPHER_CAMELLIA_192_GCM=30, + MBEDTLS_CIPHER_CAMELLIA_256_CBC=22, + MBEDTLS_CIPHER_CAMELLIA_256_CCM=48, + MBEDTLS_CIPHER_CAMELLIA_256_CFB128=25, + MBEDTLS_CIPHER_CAMELLIA_256_CTR=28, + MBEDTLS_CIPHER_CAMELLIA_256_ECB=19, + MBEDTLS_CIPHER_CAMELLIA_256_GCM=31, + MBEDTLS_CIPHER_DES_CBC=33, + MBEDTLS_CIPHER_DES_ECB=32, + MBEDTLS_CIPHER_DES_EDE3_CBC=37, + MBEDTLS_CIPHER_DES_EDE3_ECB=36, + MBEDTLS_CIPHER_DES_EDE_CBC=35, + MBEDTLS_CIPHER_DES_EDE_ECB=34, + MBEDTLS_CIPHER_NONE=0, + MBEDTLS_CIPHER_NULL=1 +} mbedtls_cipher_type_t; + +typedef enum mbedtls_key_exchange_type_t { + MBEDTLS_KEY_EXCHANGE_DHE_PSK=6, + MBEDTLS_KEY_EXCHANGE_DHE_RSA=2, + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=4, + MBEDTLS_KEY_EXCHANGE_ECDHE_PSK=8, + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=3, + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=10, + MBEDTLS_KEY_EXCHANGE_ECDH_RSA=9, + MBEDTLS_KEY_EXCHANGE_ECJPAKE=11, + MBEDTLS_KEY_EXCHANGE_NONE=0, + MBEDTLS_KEY_EXCHANGE_PSK=5, + MBEDTLS_KEY_EXCHANGE_RSA=1, + MBEDTLS_KEY_EXCHANGE_RSA_PSK=7 +} mbedtls_key_exchange_type_t; + +typedef struct mbedtls_md_info_t mbedtls_md_info_t, *Pmbedtls_md_info_t; + +typedef struct mbedtls_cipher_info_t mbedtls_cipher_info_t, *Pmbedtls_cipher_info_t; + +typedef enum mbedtls_operation_t { + MBEDTLS_DECRYPT=0, + MBEDTLS_ENCRYPT=1, + MBEDTLS_OPERATION_NONE=-1 +} mbedtls_operation_t; + +typedef enum mbedtls_cipher_mode_t { + MBEDTLS_MODE_CBC=2, + MBEDTLS_MODE_CCM=8, + MBEDTLS_MODE_CFB=3, + MBEDTLS_MODE_CTR=5, + MBEDTLS_MODE_ECB=1, + MBEDTLS_MODE_GCM=6, + MBEDTLS_MODE_NONE=0, + MBEDTLS_MODE_OFB=4, + MBEDTLS_MODE_STREAM=7 +} mbedtls_cipher_mode_t; + +typedef struct mbedtls_cipher_base_t mbedtls_cipher_base_t, *Pmbedtls_cipher_base_t; + +typedef enum mbedtls_cipher_id_t { + MBEDTLS_CIPHER_ID_3DES=4, + MBEDTLS_CIPHER_ID_AES=2, + MBEDTLS_CIPHER_ID_ARC4=7, + MBEDTLS_CIPHER_ID_BLOWFISH=6, + MBEDTLS_CIPHER_ID_CAMELLIA=5, + MBEDTLS_CIPHER_ID_DES=3, + MBEDTLS_CIPHER_ID_NONE=0, + MBEDTLS_CIPHER_ID_NULL=1 +} mbedtls_cipher_id_t; + +struct mbedtls_asn1_buf { + int tag; + size_t len; + uchar * p; +}; + +struct mbedtls_asn1_named_data { + struct mbedtls_asn1_buf oid; + struct mbedtls_asn1_buf val; + struct mbedtls_asn1_named_data * next; + uchar next_merged; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +struct mbedtls_aes_context { + int nr; + uint32_t * rk; + uint32_t buf[68]; +}; + +struct mbedtls_ssl_session { + int ciphersuite; + int compression; + size_t id_len; + uchar id[32]; + uchar master[48]; + struct mbedtls_x509_crt * peer_cert; + uint32_t verify_result; + uchar * ticket; + size_t ticket_len; + uint32_t ticket_lifetime; + uchar mfl_code; + undefined field_0x71; + undefined field_0x72; + undefined field_0x73; +}; + +struct mbedtls_x509_time { + int year; + int mon; + int day; + int hour; + int min; + int sec; +}; + +struct mbedtls_x509_crl_entry { + mbedtls_x509_buf raw; + mbedtls_x509_buf serial; + struct mbedtls_x509_time revocation_date; + mbedtls_x509_buf entry_ext; + struct mbedtls_x509_crl_entry * next; +}; + +struct mbedtls_x509_crl { + mbedtls_x509_buf raw; + mbedtls_x509_buf tbs; + int version; + mbedtls_x509_buf sig_oid; + mbedtls_x509_buf issuer_raw; + mbedtls_x509_name issuer; + struct mbedtls_x509_time this_update; + struct mbedtls_x509_time next_update; + struct mbedtls_x509_crl_entry entry; + mbedtls_x509_buf crl_ext; + mbedtls_x509_buf sig_oid2; + mbedtls_x509_buf sig; + enum mbedtls_md_type_t sig_md; + enum mbedtls_pk_type_t sig_pk; + undefined field_0xea; + undefined field_0xeb; + void * sig_opts; + struct mbedtls_x509_crl * next; +}; + +struct mbedtls_ctr_drbg_context { + uchar counter[16]; + int reseed_counter; + int prediction_resistance; + size_t entropy_len; + int reseed_interval; + struct mbedtls_aes_context aes_ctx; + int (* f_entropy)(void *, uchar *, size_t); + void * p_entropy; +}; + +struct mbedtls_ssl_context { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct mbedtls_md_info_t { + enum mbedtls_md_type_t type; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + char * name; + int size; + int block_size; + void (* starts_func)(void *); + void (* update_func)(void *, uchar *, size_t); + void (* finish_func)(void *, uchar *); + void (* digest_func)(uchar *, size_t, uchar *); + void * (* ctx_alloc_func)(void); + void (* ctx_free_func)(void *); + void (* clone_func)(void *, void *); + void (* process_func)(void *, uchar *); +}; + +struct mbedtls_ssl_config { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_cipher_context_t { + struct mbedtls_cipher_info_t * cipher_info; + int key_bitlen; + enum mbedtls_operation_t operation; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + void (* add_padding)(uchar *, size_t, size_t); + int (* get_padding)(uchar *, size_t, size_t *); + uchar unprocessed_data[16]; + size_t unprocessed_len; + uchar iv[16]; + size_t iv_size; + void * cipher_ctx; +}; + +struct mbedtls_md_context_t { + struct mbedtls_md_info_t * md_info; + void * md_ctx; + void * hmac_ctx; +}; + +struct mbedtls_ssl_transform { + struct mbedtls_ssl_ciphersuite_t * ciphersuite_info; + uint keylen; + size_t minlen; + size_t ivlen; + size_t fixed_ivlen; + size_t maclen; + uchar iv_enc[16]; + uchar iv_dec[16]; + struct mbedtls_md_context_t md_ctx_enc; + struct mbedtls_md_context_t md_ctx_dec; + struct mbedtls_cipher_context_t cipher_ctx_enc; + struct mbedtls_cipher_context_t cipher_ctx_dec; +}; + +struct mbedtls_sha256_context { + uint32_t total[2]; + uint32_t state[8]; + uchar buffer[64]; + int is224; + size_t size; + void * ali_ctx; +}; + +struct mbedtls_entropy_source_state { + int (* f_source)(void *, uchar *, size_t, size_t *); + void * p_source; + size_t size; + size_t threshold; + int strong; +}; + +struct mbedtls_entropy_context { + struct mbedtls_sha256_context accumulator; + int source_count; + struct mbedtls_entropy_source_state source[20]; +}; + +struct mbedtls_pk_context { + struct mbedtls_pk_info_t * pk_info; + void * pk_ctx; +}; + +struct mbedtls_ssl_config.conflict15 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict12 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct mbedtls_net_context { + int fd; +}; + +struct mbedtls_asn1_sequence { + struct mbedtls_asn1_buf buf; + struct mbedtls_asn1_sequence * next; +}; + +struct mbedtls_x509_crt { + mbedtls_x509_buf raw; + mbedtls_x509_buf tbs; + int version; + mbedtls_x509_buf serial; + mbedtls_x509_buf sig_oid; + mbedtls_x509_buf issuer_raw; + mbedtls_x509_buf subject_raw; + mbedtls_x509_name issuer; + mbedtls_x509_name subject; + struct mbedtls_x509_time valid_from; + struct mbedtls_x509_time valid_to; + struct mbedtls_pk_context pk; + mbedtls_x509_buf issuer_id; + mbedtls_x509_buf subject_id; + mbedtls_x509_buf v3_ext; + mbedtls_x509_sequence subject_alt_names; + int ext_types; + int ca_istrue; + int max_pathlen; + uint key_usage; + mbedtls_x509_sequence ext_key_usage; + uchar ns_cert_type; + undefined field_0x119; + undefined field_0x11a; + undefined field_0x11b; + mbedtls_x509_buf sig; + enum mbedtls_md_type_t sig_md; + enum mbedtls_pk_type_t sig_pk; + undefined field_0x12a; + undefined field_0x12b; + void * sig_opts; + struct mbedtls_x509_crt * next; +}; + +struct _TLSDataParams.conflict8 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict12 ssl; + struct mbedtls_ssl_config.conflict15 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +struct mbedtls_cipher_base_t { + enum mbedtls_cipher_id_t cipher; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + int (* ecb_func)(void *, enum mbedtls_operation_t, uchar *, uchar *); + int (* cbc_func)(void *, enum mbedtls_operation_t, size_t, uchar *, uchar *, uchar *); + int (* cfb_func)(void *, enum mbedtls_operation_t, size_t, size_t *, uchar *, uchar *, uchar *); + int (* ctr_func)(void *, size_t, size_t *, uchar *, uchar *, uchar *, uchar *); + int (* setkey_enc_func)(void *, uchar *, uint); + int (* setkey_dec_func)(void *, uchar *, uint); + void * (* ctx_alloc_func)(void); + void (* ctx_free_func)(void *); +}; + +struct mbedtls_ssl_ciphersuite_t { + int id; + char * name; + enum mbedtls_cipher_type_t cipher; + enum mbedtls_md_type_t mac; + enum mbedtls_key_exchange_type_t key_exchange; + undefined field_0xb; + int min_major_ver; + int min_minor_ver; + int max_major_ver; + int max_minor_ver; + uchar flags; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +struct mbedtls_cipher_info_t { + enum mbedtls_cipher_type_t type; + enum mbedtls_cipher_mode_t mode; + undefined field_0x2; + undefined field_0x3; + uint key_bitlen; + char * name; + uint iv_size; + int flags; + uint block_size; + struct mbedtls_cipher_base_t * base; +}; + +struct mbedtls_pk_debug_item { + enum mbedtls_pk_debug_type type; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + char * name; + void * value; +}; + +struct mbedtls_ssl_flight_item { + uchar * p; + size_t len; + uchar type; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + struct mbedtls_ssl_flight_item * next; +}; + +struct mbedtls_ssl_key_cert { + struct mbedtls_x509_crt * cert; + struct mbedtls_pk_context * key; + struct mbedtls_ssl_key_cert * next; +}; + +struct mbedtls_pk_info_t { + enum mbedtls_pk_type_t type; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + char * name; + size_t (* get_bitlen)(void *); + int (* can_do)(enum mbedtls_pk_type_t); + int (* verify_func)(void *, enum mbedtls_md_type_t, uchar *, size_t, uchar *, size_t); + int (* sign_func)(void *, enum mbedtls_md_type_t, uchar *, size_t, uchar *, size_t *, int (* )(void *, uchar *, size_t), void *); + int (* decrypt_func)(void *, uchar *, size_t, uchar *, size_t *, size_t, int (* )(void *, uchar *, size_t), void *); + int (* encrypt_func)(void *, uchar *, size_t, uchar *, size_t *, size_t, int (* )(void *, uchar *, size_t), void *); + int (* check_pair_func)(void *, void *); + void * (* ctx_alloc_func)(void); + void (* ctx_free_func)(void *); + void (* debug_func)(void *, struct mbedtls_pk_debug_item *); +}; + +struct mbedtls_x509_crt_profile { + uint32_t allowed_mds; + uint32_t allowed_pks; + uint32_t allowed_curves; + uint32_t rsa_min_bitlen; +}; + +struct mbedtls_ssl_handshake_params { + int sig_alg; + int verify_sig_alg; + struct mbedtls_ssl_key_cert * key_cert; + int sni_authmode; + struct mbedtls_ssl_key_cert * sni_key_cert; + struct mbedtls_x509_crt * sni_ca_chain; + struct mbedtls_x509_crl * sni_ca_crl; + uint out_msg_seq; + uint in_msg_seq; + uchar * verify_cookie; + uchar verify_cookie_len; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; + uchar * hs_msg; + uint32_t retransmit_timeout; + uchar retransmit_state; + undefined field_0x35; + undefined field_0x36; + undefined field_0x37; + struct mbedtls_ssl_flight_item * flight; + struct mbedtls_ssl_flight_item * cur_msg; + uint in_flight_start_seq; + struct mbedtls_ssl_transform * alt_transform_out; + uchar alt_out_ctr[8]; + struct mbedtls_sha256_context fin_sha256; + void (* update_checksum)(struct mbedtls_ssl_context *, uchar *, size_t); + void (* calc_verify)(struct mbedtls_ssl_context *, uchar *); + void (* calc_finished)(struct mbedtls_ssl_context *, uchar *, int); + int (* tls_prf)(uchar *, size_t, char *, uchar *, size_t, uchar *, size_t); + size_t pmslen; + uchar randbytes[64]; + uchar premaster[48]; + int resume; + int max_major_ver; + int max_minor_ver; + int cli_exts; + int new_session_ticket; +}; + +typedef struct _TLSDataParams.conflict7 _TLSDataParams.conflict7, *P_TLSDataParams.conflict7; + +typedef struct _TLSDataParams.conflict7 TLSDataParams.conflict5; + +typedef struct mbedtls_ssl_context.conflict11 mbedtls_ssl_context.conflict11, *Pmbedtls_ssl_context.conflict11; + +typedef struct mbedtls_ssl_config.conflict14 mbedtls_ssl_config.conflict14, *Pmbedtls_ssl_config.conflict14; + +struct mbedtls_ssl_config.conflict14 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict11 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict7 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict11 ssl; + struct mbedtls_ssl_config.conflict14 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict10 _TLSDataParams.conflict10, *P_TLSDataParams.conflict10; + +typedef struct _TLSDataParams.conflict10 TLSDataParams.conflict8; + +typedef struct mbedtls_ssl_context.conflict14 mbedtls_ssl_context.conflict14, *Pmbedtls_ssl_context.conflict14; + +typedef struct mbedtls_ssl_config.conflict17 mbedtls_ssl_config.conflict17, *Pmbedtls_ssl_config.conflict17; + +struct mbedtls_ssl_config.conflict17 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict14 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict10 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict14 ssl; + struct mbedtls_ssl_config.conflict17 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict9 _TLSDataParams.conflict9, *P_TLSDataParams.conflict9; + +typedef struct _TLSDataParams.conflict9 TLSDataParams.conflict7; + +typedef struct mbedtls_ssl_context.conflict13 mbedtls_ssl_context.conflict13, *Pmbedtls_ssl_context.conflict13; + +typedef struct mbedtls_ssl_config.conflict16 mbedtls_ssl_config.conflict16, *Pmbedtls_ssl_config.conflict16; + +struct mbedtls_ssl_config.conflict16 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict13 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict9 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict13 ssl; + struct mbedtls_ssl_config.conflict16 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict12 _TLSDataParams.conflict12, *P_TLSDataParams.conflict12; + +typedef struct _TLSDataParams.conflict12 TLSDataParams.conflict9; + +typedef struct mbedtls_ssl_context.conflict18 mbedtls_ssl_context.conflict18, *Pmbedtls_ssl_context.conflict18; + +typedef struct mbedtls_ssl_config.conflict22 mbedtls_ssl_config.conflict22, *Pmbedtls_ssl_config.conflict22; + +struct mbedtls_ssl_config.conflict22 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict18 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict12 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict18 ssl; + struct mbedtls_ssl_config.conflict22 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict19 _TLSDataParams.conflict19, *P_TLSDataParams.conflict19; + +typedef struct mbedtls_ssl_context.conflict27 mbedtls_ssl_context.conflict27, *Pmbedtls_ssl_context.conflict27; + +typedef struct mbedtls_ssl_config.conflict32 mbedtls_ssl_config.conflict32, *Pmbedtls_ssl_config.conflict32; + +struct mbedtls_ssl_context.conflict27 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct mbedtls_ssl_config.conflict32 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct _TLSDataParams.conflict19 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict27 ssl; + struct mbedtls_ssl_config.conflict32 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict15 _TLSDataParams.conflict15, *P_TLSDataParams.conflict15; + +typedef struct mbedtls_ssl_context.conflict21 mbedtls_ssl_context.conflict21, *Pmbedtls_ssl_context.conflict21; + +typedef struct mbedtls_ssl_config.conflict25 mbedtls_ssl_config.conflict25, *Pmbedtls_ssl_config.conflict25; + +struct mbedtls_ssl_context.conflict21 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct mbedtls_ssl_config.conflict25 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct _TLSDataParams.conflict15 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict21 ssl; + struct mbedtls_ssl_config.conflict25 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict16 _TLSDataParams.conflict16, *P_TLSDataParams.conflict16; + +typedef struct mbedtls_ssl_context.conflict22 mbedtls_ssl_context.conflict22, *Pmbedtls_ssl_context.conflict22; + +typedef struct mbedtls_ssl_config.conflict26 mbedtls_ssl_config.conflict26, *Pmbedtls_ssl_config.conflict26; + +struct mbedtls_ssl_context.conflict22 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct mbedtls_ssl_config.conflict26 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct _TLSDataParams.conflict16 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict22 ssl; + struct mbedtls_ssl_config.conflict26 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict17 _TLSDataParams.conflict17, *P_TLSDataParams.conflict17; + +typedef struct mbedtls_ssl_context.conflict25 mbedtls_ssl_context.conflict25, *Pmbedtls_ssl_context.conflict25; + +typedef struct mbedtls_ssl_config.conflict30 mbedtls_ssl_config.conflict30, *Pmbedtls_ssl_config.conflict30; + +struct mbedtls_ssl_context.conflict25 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct mbedtls_ssl_config.conflict30 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct _TLSDataParams.conflict17 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict25 ssl; + struct mbedtls_ssl_config.conflict30 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict18 _TLSDataParams.conflict18, *P_TLSDataParams.conflict18; + +typedef struct mbedtls_ssl_context.conflict26 mbedtls_ssl_context.conflict26, *Pmbedtls_ssl_context.conflict26; + +typedef struct mbedtls_ssl_config.conflict31 mbedtls_ssl_config.conflict31, *Pmbedtls_ssl_config.conflict31; + +struct mbedtls_ssl_context.conflict26 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct mbedtls_ssl_config.conflict31 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct _TLSDataParams.conflict18 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict26 ssl; + struct mbedtls_ssl_config.conflict31 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict11 _TLSDataParams.conflict11, *P_TLSDataParams.conflict11; + +typedef struct mbedtls_ssl_context.conflict17 mbedtls_ssl_context.conflict17, *Pmbedtls_ssl_context.conflict17; + +typedef struct mbedtls_ssl_config.conflict21 mbedtls_ssl_config.conflict21, *Pmbedtls_ssl_config.conflict21; + +struct mbedtls_ssl_config.conflict21 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict17 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict11 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict17 ssl; + struct mbedtls_ssl_config.conflict21 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict13 _TLSDataParams.conflict13, *P_TLSDataParams.conflict13; + +typedef struct mbedtls_ssl_context.conflict19 mbedtls_ssl_context.conflict19, *Pmbedtls_ssl_context.conflict19; + +typedef struct mbedtls_ssl_config.conflict23 mbedtls_ssl_config.conflict23, *Pmbedtls_ssl_config.conflict23; + +struct mbedtls_ssl_config.conflict23 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict19 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict13 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict19 ssl; + struct mbedtls_ssl_config.conflict23 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict14 _TLSDataParams.conflict14, *P_TLSDataParams.conflict14; + +typedef struct mbedtls_ssl_context.conflict20 mbedtls_ssl_context.conflict20, *Pmbedtls_ssl_context.conflict20; + +typedef struct mbedtls_ssl_config.conflict24 mbedtls_ssl_config.conflict24, *Pmbedtls_ssl_config.conflict24; + +struct mbedtls_ssl_context.conflict20 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct mbedtls_ssl_config.conflict24 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct _TLSDataParams.conflict14 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict20 ssl; + struct mbedtls_ssl_config.conflict24 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict1 _TLSDataParams.conflict1, *P_TLSDataParams.conflict1; + +typedef struct mbedtls_ssl_context.conflict3 mbedtls_ssl_context.conflict3, *Pmbedtls_ssl_context.conflict3; + +typedef struct mbedtls_ssl_config.conflict5 mbedtls_ssl_config.conflict5, *Pmbedtls_ssl_config.conflict5; + +struct mbedtls_ssl_config.conflict5 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict3 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict1 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict3 ssl; + struct mbedtls_ssl_config.conflict5 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict3 _TLSDataParams.conflict3, *P_TLSDataParams.conflict3; + +typedef struct mbedtls_ssl_context.conflict5 mbedtls_ssl_context.conflict5, *Pmbedtls_ssl_context.conflict5; + +typedef struct mbedtls_ssl_config.conflict7 mbedtls_ssl_config.conflict7, *Pmbedtls_ssl_config.conflict7; + +struct mbedtls_ssl_config.conflict7 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict5 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict3 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict5 ssl; + struct mbedtls_ssl_config.conflict7 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict2 _TLSDataParams.conflict2, *P_TLSDataParams.conflict2; + +typedef struct mbedtls_ssl_context.conflict4 mbedtls_ssl_context.conflict4, *Pmbedtls_ssl_context.conflict4; + +typedef struct mbedtls_ssl_config.conflict6 mbedtls_ssl_config.conflict6, *Pmbedtls_ssl_config.conflict6; + +struct mbedtls_ssl_config.conflict6 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict4 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict2 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict4 ssl; + struct mbedtls_ssl_config.conflict6 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict26 _TLSDataParams.conflict26, *P_TLSDataParams.conflict26; + +typedef struct mbedtls_ssl_context.conflict36 mbedtls_ssl_context.conflict36, *Pmbedtls_ssl_context.conflict36; + +typedef struct mbedtls_ssl_config.conflict42 mbedtls_ssl_config.conflict42, *Pmbedtls_ssl_config.conflict42; + +struct mbedtls_ssl_config.conflict42 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict36 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict26 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict36 ssl; + struct mbedtls_ssl_config.conflict42 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict27 _TLSDataParams.conflict27, *P_TLSDataParams.conflict27; + +typedef struct mbedtls_ssl_context.conflict37 mbedtls_ssl_context.conflict37, *Pmbedtls_ssl_context.conflict37; + +typedef struct mbedtls_ssl_config.conflict43 mbedtls_ssl_config.conflict43, *Pmbedtls_ssl_config.conflict43; + +struct mbedtls_ssl_config.conflict43 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict37 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict27 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict37 ssl; + struct mbedtls_ssl_config.conflict43 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict28 _TLSDataParams.conflict28, *P_TLSDataParams.conflict28; + +typedef struct mbedtls_ssl_context.conflict38 mbedtls_ssl_context.conflict38, *Pmbedtls_ssl_context.conflict38; + +typedef struct mbedtls_ssl_config.conflict44 mbedtls_ssl_config.conflict44, *Pmbedtls_ssl_config.conflict44; + +struct mbedtls_ssl_config.conflict44 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict38 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict28 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict38 ssl; + struct mbedtls_ssl_config.conflict44 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict29 _TLSDataParams.conflict29, *P_TLSDataParams.conflict29; + +typedef struct mbedtls_ssl_context.conflict41 mbedtls_ssl_context.conflict41, *Pmbedtls_ssl_context.conflict41; + +typedef struct mbedtls_ssl_config.conflict48 mbedtls_ssl_config.conflict48, *Pmbedtls_ssl_config.conflict48; + +struct mbedtls_ssl_context.conflict41 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct mbedtls_ssl_config.conflict48 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct _TLSDataParams.conflict29 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict41 ssl; + struct mbedtls_ssl_config.conflict48 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict22 _TLSDataParams.conflict22, *P_TLSDataParams.conflict22; + +typedef struct mbedtls_ssl_context.conflict30 mbedtls_ssl_context.conflict30, *Pmbedtls_ssl_context.conflict30; + +typedef struct mbedtls_ssl_config.conflict35 mbedtls_ssl_config.conflict35, *Pmbedtls_ssl_config.conflict35; + +struct mbedtls_ssl_context.conflict30 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct mbedtls_ssl_config.conflict35 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct _TLSDataParams.conflict22 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict30 ssl; + struct mbedtls_ssl_config.conflict35 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict23 _TLSDataParams.conflict23, *P_TLSDataParams.conflict23; + +typedef struct mbedtls_ssl_context.conflict33 mbedtls_ssl_context.conflict33, *Pmbedtls_ssl_context.conflict33; + +typedef struct mbedtls_ssl_config.conflict39 mbedtls_ssl_config.conflict39, *Pmbedtls_ssl_config.conflict39; + +struct mbedtls_ssl_context.conflict33 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct mbedtls_ssl_config.conflict39 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct _TLSDataParams.conflict23 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict33 ssl; + struct mbedtls_ssl_config.conflict39 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict24 _TLSDataParams.conflict24, *P_TLSDataParams.conflict24; + +typedef struct mbedtls_ssl_context.conflict34 mbedtls_ssl_context.conflict34, *Pmbedtls_ssl_context.conflict34; + +typedef struct mbedtls_ssl_config.conflict40 mbedtls_ssl_config.conflict40, *Pmbedtls_ssl_config.conflict40; + +struct mbedtls_ssl_config.conflict40 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict34 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict24 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict34 ssl; + struct mbedtls_ssl_config.conflict40 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict25 _TLSDataParams.conflict25, *P_TLSDataParams.conflict25; + +typedef struct mbedtls_ssl_context.conflict35 mbedtls_ssl_context.conflict35, *Pmbedtls_ssl_context.conflict35; + +typedef struct mbedtls_ssl_config.conflict41 mbedtls_ssl_config.conflict41, *Pmbedtls_ssl_config.conflict41; + +struct mbedtls_ssl_config.conflict41 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict35 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict25 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict35 ssl; + struct mbedtls_ssl_config.conflict41 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict20 _TLSDataParams.conflict20, *P_TLSDataParams.conflict20; + +typedef struct mbedtls_ssl_context.conflict28 mbedtls_ssl_context.conflict28, *Pmbedtls_ssl_context.conflict28; + +typedef struct mbedtls_ssl_config.conflict33 mbedtls_ssl_config.conflict33, *Pmbedtls_ssl_config.conflict33; + +struct mbedtls_ssl_config.conflict33 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict28 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict20 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict28 ssl; + struct mbedtls_ssl_config.conflict33 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict _TLSDataParams.conflict, *P_TLSDataParams.conflict; + +typedef struct mbedtls_ssl_context.conflict2 mbedtls_ssl_context.conflict2, *Pmbedtls_ssl_context.conflict2; + +typedef struct mbedtls_ssl_config.conflict4 mbedtls_ssl_config.conflict4, *Pmbedtls_ssl_config.conflict4; + +struct mbedtls_ssl_config.conflict4 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict2 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict2 ssl; + struct mbedtls_ssl_config.conflict4 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict21 _TLSDataParams.conflict21, *P_TLSDataParams.conflict21; + +typedef struct mbedtls_ssl_context.conflict29 mbedtls_ssl_context.conflict29, *Pmbedtls_ssl_context.conflict29; + +typedef struct mbedtls_ssl_config.conflict34 mbedtls_ssl_config.conflict34, *Pmbedtls_ssl_config.conflict34; + +struct mbedtls_ssl_config.conflict34 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict29 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict21 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict29 ssl; + struct mbedtls_ssl_config.conflict34 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict5 _TLSDataParams.conflict5, *P_TLSDataParams.conflict5; + +typedef struct mbedtls_ssl_context.conflict9 mbedtls_ssl_context.conflict9, *Pmbedtls_ssl_context.conflict9; + +typedef struct mbedtls_ssl_config.conflict12 mbedtls_ssl_config.conflict12, *Pmbedtls_ssl_config.conflict12; + +struct mbedtls_ssl_context.conflict9 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct mbedtls_ssl_config.conflict12 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct _TLSDataParams.conflict5 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict9 ssl; + struct mbedtls_ssl_config.conflict12 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict37 _TLSDataParams.conflict37, *P_TLSDataParams.conflict37; + +typedef struct mbedtls_ssl_context.conflict51 mbedtls_ssl_context.conflict51, *Pmbedtls_ssl_context.conflict51; + +typedef struct mbedtls_ssl_config.conflict59 mbedtls_ssl_config.conflict59, *Pmbedtls_ssl_config.conflict59; + +struct mbedtls_ssl_config.conflict59 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict51 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict37 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict51 ssl; + struct mbedtls_ssl_config.conflict59 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict4 _TLSDataParams.conflict4, *P_TLSDataParams.conflict4; + +typedef struct mbedtls_ssl_context.conflict6 mbedtls_ssl_context.conflict6, *Pmbedtls_ssl_context.conflict6; + +typedef struct mbedtls_ssl_config.conflict8 mbedtls_ssl_config.conflict8, *Pmbedtls_ssl_config.conflict8; + +struct mbedtls_ssl_config.conflict8 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict6 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict4 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict6 ssl; + struct mbedtls_ssl_config.conflict8 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict38 _TLSDataParams.conflict38, *P_TLSDataParams.conflict38; + +typedef struct mbedtls_ssl_context.conflict52 mbedtls_ssl_context.conflict52, *Pmbedtls_ssl_context.conflict52; + +typedef struct mbedtls_ssl_config.conflict60 mbedtls_ssl_config.conflict60, *Pmbedtls_ssl_config.conflict60; + +struct mbedtls_ssl_config.conflict60 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict52 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict38 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict52 ssl; + struct mbedtls_ssl_config.conflict60 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict39 _TLSDataParams.conflict39, *P_TLSDataParams.conflict39; + +typedef struct mbedtls_ssl_context.conflict53 mbedtls_ssl_context.conflict53, *Pmbedtls_ssl_context.conflict53; + +typedef struct mbedtls_ssl_config.conflict61 mbedtls_ssl_config.conflict61, *Pmbedtls_ssl_config.conflict61; + +struct mbedtls_ssl_config.conflict61 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict53 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict39 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict53 ssl; + struct mbedtls_ssl_config.conflict61 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict6 _TLSDataParams.conflict6, *P_TLSDataParams.conflict6; + +typedef struct mbedtls_ssl_context.conflict10 mbedtls_ssl_context.conflict10, *Pmbedtls_ssl_context.conflict10; + +typedef struct mbedtls_ssl_config.conflict13 mbedtls_ssl_config.conflict13, *Pmbedtls_ssl_config.conflict13; + +struct mbedtls_ssl_config.conflict13 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict10 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict6 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict10 ssl; + struct mbedtls_ssl_config.conflict13 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict33 _TLSDataParams.conflict33, *P_TLSDataParams.conflict33; + +typedef struct mbedtls_ssl_context.conflict45 mbedtls_ssl_context.conflict45, *Pmbedtls_ssl_context.conflict45; + +typedef struct mbedtls_ssl_config.conflict52 mbedtls_ssl_config.conflict52, *Pmbedtls_ssl_config.conflict52; + +struct mbedtls_ssl_context.conflict45 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct mbedtls_ssl_config.conflict52 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct _TLSDataParams.conflict33 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict45 ssl; + struct mbedtls_ssl_config.conflict52 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict34 _TLSDataParams.conflict34, *P_TLSDataParams.conflict34; + +typedef struct mbedtls_ssl_context.conflict46 mbedtls_ssl_context.conflict46, *Pmbedtls_ssl_context.conflict46; + +typedef struct mbedtls_ssl_config.conflict53 mbedtls_ssl_config.conflict53, *Pmbedtls_ssl_config.conflict53; + +struct mbedtls_ssl_context.conflict46 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct mbedtls_ssl_config.conflict53 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct _TLSDataParams.conflict34 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict46 ssl; + struct mbedtls_ssl_config.conflict53 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict35 _TLSDataParams.conflict35, *P_TLSDataParams.conflict35; + +typedef struct mbedtls_ssl_context.conflict49 mbedtls_ssl_context.conflict49, *Pmbedtls_ssl_context.conflict49; + +typedef struct mbedtls_ssl_config.conflict57 mbedtls_ssl_config.conflict57, *Pmbedtls_ssl_config.conflict57; + +struct mbedtls_ssl_context.conflict49 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct mbedtls_ssl_config.conflict57 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct _TLSDataParams.conflict35 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict49 ssl; + struct mbedtls_ssl_config.conflict57 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict36 _TLSDataParams.conflict36, *P_TLSDataParams.conflict36; + +typedef struct mbedtls_ssl_context.conflict50 mbedtls_ssl_context.conflict50, *Pmbedtls_ssl_context.conflict50; + +typedef struct mbedtls_ssl_config.conflict58 mbedtls_ssl_config.conflict58, *Pmbedtls_ssl_config.conflict58; + +struct mbedtls_ssl_config.conflict58 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict50 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict36 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict50 ssl; + struct mbedtls_ssl_config.conflict58 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict30 _TLSDataParams.conflict30, *P_TLSDataParams.conflict30; + +typedef struct mbedtls_ssl_context.conflict42 mbedtls_ssl_context.conflict42, *Pmbedtls_ssl_context.conflict42; + +typedef struct mbedtls_ssl_config.conflict49 mbedtls_ssl_config.conflict49, *Pmbedtls_ssl_config.conflict49; + +struct mbedtls_ssl_context.conflict42 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct mbedtls_ssl_config.conflict49 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct _TLSDataParams.conflict30 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict42 ssl; + struct mbedtls_ssl_config.conflict49 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict31 _TLSDataParams.conflict31, *P_TLSDataParams.conflict31; + +typedef struct mbedtls_ssl_context.conflict43 mbedtls_ssl_context.conflict43, *Pmbedtls_ssl_context.conflict43; + +typedef struct mbedtls_ssl_config.conflict50 mbedtls_ssl_config.conflict50, *Pmbedtls_ssl_config.conflict50; + +struct mbedtls_ssl_context.conflict43 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct mbedtls_ssl_config.conflict50 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct _TLSDataParams.conflict31 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict43 ssl; + struct mbedtls_ssl_config.conflict50 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict TLSDataParams; + +typedef struct _TLSDataParams.conflict32 _TLSDataParams.conflict32, *P_TLSDataParams.conflict32; + +typedef struct mbedtls_ssl_context.conflict44 mbedtls_ssl_context.conflict44, *Pmbedtls_ssl_context.conflict44; + +typedef struct mbedtls_ssl_config.conflict51 mbedtls_ssl_config.conflict51, *Pmbedtls_ssl_config.conflict51; + +struct mbedtls_ssl_context.conflict44 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct mbedtls_ssl_config.conflict51 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct _TLSDataParams.conflict32 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict44 ssl; + struct mbedtls_ssl_config.conflict51 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict40 _TLSDataParams.conflict40, *P_TLSDataParams.conflict40; + +typedef struct mbedtls_ssl_context.conflict54 mbedtls_ssl_context.conflict54, *Pmbedtls_ssl_context.conflict54; + +typedef struct mbedtls_ssl_config.conflict62 mbedtls_ssl_config.conflict62, *Pmbedtls_ssl_config.conflict62; + +struct mbedtls_ssl_config.conflict62 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict54 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams.conflict40 { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict54 ssl; + struct mbedtls_ssl_config.conflict62 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef struct _TLSDataParams.conflict13 TLSDataParams.conflict10; + +typedef struct _TLSDataParams.conflict14 TLSDataParams.conflict11; + +typedef struct _TLSDataParams.conflict15 TLSDataParams.conflict12; + +typedef struct _TLSDataParams.conflict16 TLSDataParams.conflict13; + +typedef struct _TLSDataParams.conflict18 TLSDataParams.conflict14; + +typedef struct _TLSDataParams.conflict19 TLSDataParams.conflict15; + +typedef struct _TLSDataParams.conflict20 TLSDataParams.conflict16; + +typedef struct _TLSDataParams.conflict21 TLSDataParams.conflict17; + +typedef struct _TLSDataParams.conflict22 TLSDataParams.conflict18; + +typedef struct _TLSDataParams.conflict24 TLSDataParams.conflict19; + +typedef struct _TLSDataParams.conflict1 TLSDataParams.conflict; + +typedef struct _TLSDataParams.conflict37 TLSDataParams.conflict30; + +typedef struct _TLSDataParams.conflict38 TLSDataParams.conflict31; + +typedef struct _TLSDataParams.conflict39 TLSDataParams.conflict32; + +typedef struct _TLSDataParams.conflict40 TLSDataParams.conflict33; + +typedef struct _TLSDataParams.conflict25 TLSDataParams.conflict20; + +typedef struct _TLSDataParams.conflict26 TLSDataParams.conflict21; + +typedef struct _TLSDataParams.conflict27 TLSDataParams.conflict22; + +typedef struct _TLSDataParams.conflict28 TLSDataParams.conflict23; + +typedef struct _TLSDataParams.conflict30 TLSDataParams.conflict24; + +typedef struct _TLSDataParams.conflict31 TLSDataParams.conflict25; + +typedef struct _TLSDataParams.conflict32 TLSDataParams.conflict26; + +typedef struct _TLSDataParams.conflict33 TLSDataParams.conflict27; + +typedef struct _TLSDataParams.conflict34 TLSDataParams.conflict28; + +typedef struct _TLSDataParams.conflict3 TLSDataParams.conflict2; + +typedef struct _TLSDataParams.conflict36 TLSDataParams.conflict29; + +typedef struct _TLSDataParams.conflict2 TLSDataParams.conflict1; + +typedef struct _TLSDataParams.conflict6 TLSDataParams.conflict4; + +typedef struct _TLSDataParams.conflict4 TLSDataParams.conflict3; + +typedef struct _TLSDataParams _TLSDataParams, *P_TLSDataParams; + +typedef struct mbedtls_ssl_context.conflict1 mbedtls_ssl_context.conflict1, *Pmbedtls_ssl_context.conflict1; + +typedef struct mbedtls_ssl_config.conflict3 mbedtls_ssl_config.conflict3, *Pmbedtls_ssl_config.conflict3; + +struct mbedtls_ssl_config.conflict3 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +struct mbedtls_ssl_context.conflict1 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +struct _TLSDataParams { + struct mbedtls_entropy_context entropy; + struct mbedtls_ctr_drbg_context ctr_drbg; + struct mbedtls_ssl_context.conflict1 ssl; + struct mbedtls_ssl_config.conflict3 conf; + uint32_t flags; + struct mbedtls_x509_crt cacert; + struct mbedtls_x509_crt clicert; + struct mbedtls_pk_context pkey; + struct mbedtls_net_context server_fd; +}; + +typedef enum anon_enum_16 { + HAL_AC0_TIMER_BIT=1, + HAL_AC1_TIMER_BIT=2, + HAL_AC2_TIMER_BIT=4, + HAL_AC3_TIMER_BIT=8, + HAL_BCN_TIMER_BIT=16, + HAL_IDLE_TIMER_BIT=32, + HAL_KE_TIMER_BIT=256, + HAL_MM_TIMER_BIT=-128, + HAL_RX_TIMER_BIT=64, + ME_CHAN_CONFIG_CFM=5123, + ME_CHAN_CONFIG_REQ=5122, + ME_CONFIG_CFM=5121, + ME_CONFIG_REQ=5120, + ME_MAX=5137, + ME_RC_SET_RATE_REQ=5136, + ME_RC_STATS_CFM=5135, + ME_RC_STATS_REQ=5134, + ME_SET_ACTIVE_CFM=5138, + ME_SET_ACTIVE_REQ=5137, + ME_SET_CONTROL_PORT_CFM=5125, + ME_SET_CONTROL_PORT_REQ=5124, + ME_SET_PS_DISABLE_CFM=5140, + ME_SET_PS_DISABLE_REQ=5139, + ME_STA_ADD_CFM=5128, + ME_STA_ADD_REQ=5127, + ME_STA_DEL_CFM=5130, + ME_STA_DEL_REQ=5129, + ME_TKIP_MIC_FAILURE_IND=5126, + ME_TRAFFIC_IND_CFM=5133, + ME_TRAFFIC_IND_REQ=5132, + ME_TX_CREDITS_UPDATE_IND=5131, + PBUF_POOL=386, + PBUF_RAM=640, + PBUF_REF=65, + PBUF_ROM=1, + ROM_API_INDEX_AON_Get_Xtal_CapCode=8, + ROM_API_INDEX_AON_LowPower_Enter_PDS0=18, + ROM_API_INDEX_AON_LowPower_Exit_PDS0=19, + ROM_API_INDEX_AON_Power_Off_BG=11, + ROM_API_INDEX_AON_Power_Off_LDO11_SOC=13, + ROM_API_INDEX_AON_Power_Off_LDO15_RF=15, + ROM_API_INDEX_AON_Power_Off_MBG=5, + ROM_API_INDEX_AON_Power_Off_SFReg=17, + ROM_API_INDEX_AON_Power_Off_XTAL=9, + ROM_API_INDEX_AON_Power_On_BG=10, + ROM_API_INDEX_AON_Power_On_LDO11_SOC=12, + ROM_API_INDEX_AON_Power_On_LDO15_RF=14, + ROM_API_INDEX_AON_Power_On_MBG=4, + ROM_API_INDEX_AON_Power_On_SFReg=16, + ROM_API_INDEX_AON_Power_On_XTAL=6, + ROM_API_INDEX_AON_Set_Xtal_CapCode=7, + ROM_API_INDEX_ASM_Delay_Us=20, + ROM_API_INDEX_BFLB_Soft_CRC32=-81, + ROM_API_INDEX_BL602_Delay_MS=22, + ROM_API_INDEX_BL602_Delay_US=21, + ROM_API_INDEX_BL602_MemCmp=28, + ROM_API_INDEX_BL602_MemCpy=23, + ROM_API_INDEX_BL602_MemCpy4=24, + ROM_API_INDEX_BL602_MemCpy_Fast=25, + ROM_API_INDEX_BL602_MemSet=26, + ROM_API_INDEX_BL602_MemSet4=27, + ROM_API_INDEX_EF_Ctrl_AutoLoad_Done=33, + ROM_API_INDEX_EF_Ctrl_Busy=32, + ROM_API_INDEX_EF_Ctrl_Clear=37, + ROM_API_INDEX_EF_Ctrl_Get_Trim_Parity=34, + ROM_API_INDEX_EF_Ctrl_Load_Efuse_R0=31, + ROM_API_INDEX_EF_Ctrl_Program_Efuse_0=30, + ROM_API_INDEX_EF_Ctrl_Read_RC32K_Trim=36, + ROM_API_INDEX_EF_Ctrl_Read_RC32M_Trim=35, + ROM_API_INDEX_EF_Ctrl_Sw_AHB_Clk_0=29, + ROM_API_INDEX_FUNC_EMPTY_END=511, + ROM_API_INDEX_FUNC_EMPTY_START=-80, + ROM_API_INDEX_GLB_Deswap_Flash_Pin=52, + ROM_API_INDEX_GLB_GPIO_Get_Fun=58, + ROM_API_INDEX_GLB_GPIO_Init=54, + ROM_API_INDEX_GLB_GPIO_OUTPUT_Disable=56, + ROM_API_INDEX_GLB_GPIO_OUTPUT_Enable=55, + ROM_API_INDEX_GLB_GPIO_Set_HZ=57, + ROM_API_INDEX_GLB_Get_BCLK_Div=40, + ROM_API_INDEX_GLB_Get_HCLK_Div=41, + ROM_API_INDEX_GLB_Get_Root_CLK_Sel=38, + ROM_API_INDEX_GLB_SW_CPU_Reset=48, + ROM_API_INDEX_GLB_SW_POR_Reset=49, + ROM_API_INDEX_GLB_SW_System_Reset=47, + ROM_API_INDEX_GLB_Select_External_Flash=51, + ROM_API_INDEX_GLB_Select_Internal_Flash=50, + ROM_API_INDEX_GLB_Set_PKA_CLK_Sel=46, + ROM_API_INDEX_GLB_Set_SF_CLK=45, + ROM_API_INDEX_GLB_Set_System_CLK=43, + ROM_API_INDEX_GLB_Set_System_CLK_Div=39, + ROM_API_INDEX_GLB_Swap_Flash_Pin=53, + ROM_API_INDEX_HBN_32K_Sel=66, + ROM_API_INDEX_HBN_Enable=61, + ROM_API_INDEX_HBN_GPIO7_Dbg_Pull_Cfg=75, + ROM_API_INDEX_HBN_Hw_Pu_Pd_Cfg=73, + ROM_API_INDEX_HBN_Mode_Enter=59, + ROM_API_INDEX_HBN_Pin_WakeUp_Mask=74, + ROM_API_INDEX_HBN_Power_Down_Flash=60, + ROM_API_INDEX_HBN_Power_Off_RC32K=71, + ROM_API_INDEX_HBN_Power_Off_Xtal_32K=69, + ROM_API_INDEX_HBN_Power_On_RC32K=70, + ROM_API_INDEX_HBN_Power_On_Xtal_32K=68, + ROM_API_INDEX_HBN_Reset=62, + ROM_API_INDEX_HBN_Set_Embedded_Flash_Pullup=76, + ROM_API_INDEX_HBN_Set_Ldo11_Aon_Vout=63, + ROM_API_INDEX_HBN_Set_Ldo11_Rt_Vout=64, + ROM_API_INDEX_HBN_Set_Ldo11_Soc_Vout=65, + ROM_API_INDEX_HBN_Set_ROOT_CLK_Sel=67, + ROM_API_INDEX_HBN_Trim_RC32K=72, + ROM_API_INDEX_L1C_IROM_2T_Access_Set=79, + ROM_API_INDEX_L1C_Set_Way_Disable=78, + ROM_API_INDEX_L1C_Set_Wrap=77, + ROM_API_INDEX_PDS_Default_Level_Config=84, + ROM_API_INDEX_PDS_Disable_PLL_All_Clks=90, + ROM_API_INDEX_PDS_Disable_PLL_Clk=92, + ROM_API_INDEX_PDS_Enable=81, + ROM_API_INDEX_PDS_Enable_PLL_All_Clks=89, + ROM_API_INDEX_PDS_Enable_PLL_Clk=91, + ROM_API_INDEX_PDS_Force_Config=82, + ROM_API_INDEX_PDS_Power_Off_PLL=93, + ROM_API_INDEX_PDS_Power_On_PLL=88, + ROM_API_INDEX_PDS_RAM_Config=83, + ROM_API_INDEX_PDS_Reset=80, + ROM_API_INDEX_PDS_Select_RC32M_As_PLL_Ref=86, + ROM_API_INDEX_PDS_Select_XTAL_As_PLL_Ref=87, + ROM_API_INDEX_PDS_Trim_RC32M=85, + ROM_API_INDEX_RSVD_0=1, + ROM_API_INDEX_RSVD_1=2, + ROM_API_INDEX_RSVD_LAST=3, + ROM_API_INDEX_SEC_Eng_Turn_Off_Sec_Ring=95, + ROM_API_INDEX_SEC_Eng_Turn_On_Sec_Ring=94, + ROM_API_INDEX_SF_Cfg_Deinit_Ext_Flash_Gpio=-123, + ROM_API_INDEX_SF_Cfg_Flash_Identify=-119, + ROM_API_INDEX_SF_Cfg_Get_Flash_Cfg_Need_Lock=-121, + ROM_API_INDEX_SF_Cfg_Init_Ext_Flash_Gpio=-125, + ROM_API_INDEX_SF_Cfg_Init_Flash_Gpio=-120, + ROM_API_INDEX_SF_Cfg_Init_Internal_Flash_Gpio=-124, + ROM_API_INDEX_SF_Cfg_Restore_GPIO17_Fun=-122, + ROM_API_INDEX_SF_Ctrl_AES_Disable=-106, + ROM_API_INDEX_SF_Ctrl_AES_Enable=-107, + ROM_API_INDEX_SF_Ctrl_AES_Enable_BE=-114, + ROM_API_INDEX_SF_Ctrl_AES_Enable_LE=-113, + ROM_API_INDEX_SF_Ctrl_AES_Set_IV=-109, + ROM_API_INDEX_SF_Ctrl_AES_Set_IV_BE=-108, + ROM_API_INDEX_SF_Ctrl_AES_Set_Key=-111, + ROM_API_INDEX_SF_Ctrl_AES_Set_Key_BE=-110, + ROM_API_INDEX_SF_Ctrl_AES_Set_Region=-112, + ROM_API_INDEX_SF_Ctrl_Disable=-115, + ROM_API_INDEX_SF_Ctrl_Enable=-118, + ROM_API_INDEX_SF_Ctrl_GetBusyState=-99, + ROM_API_INDEX_SF_Ctrl_Get_Clock_Delay=-97, + ROM_API_INDEX_SF_Ctrl_Get_Flash_Image_Offset=-104, + ROM_API_INDEX_SF_Ctrl_Icache2_Set=-100, + ROM_API_INDEX_SF_Ctrl_Icache_Set=-101, + ROM_API_INDEX_SF_Ctrl_Is_AES_Enable=-98, + ROM_API_INDEX_SF_Ctrl_Select_Clock=-103, + ROM_API_INDEX_SF_Ctrl_Select_Pad=-117, + ROM_API_INDEX_SF_Ctrl_SendCmd=-102, + ROM_API_INDEX_SF_Ctrl_Set_Clock_Delay=-96, + ROM_API_INDEX_SF_Ctrl_Set_Flash_Image_Offset=-105, + ROM_API_INDEX_SF_Ctrl_Set_Owner=-116, + ROM_API_INDEX_SFlash_Blk32_Erase=106, + ROM_API_INDEX_SFlash_Blk64_Erase=107, + ROM_API_INDEX_SFlash_Busy=100, + ROM_API_INDEX_SFlash_Cache_Enable_Set=121, + ROM_API_INDEX_SFlash_Cache_Flush=122, + ROM_API_INDEX_SFlash_Cache_Hit_Count_Get=124, + ROM_API_INDEX_SFlash_Cache_Miss_Count_Get=125, + ROM_API_INDEX_SFlash_Cache_Read_Disable=126, + ROM_API_INDEX_SFlash_Cache_Read_Enable=123, + ROM_API_INDEX_SFlash_Chip_Erase=104, + ROM_API_INDEX_SFlash_DisableBurstWrap=116, + ROM_API_INDEX_SFlash_Erase=108, + ROM_API_INDEX_SFlash_GetDeviceId=112, + ROM_API_INDEX_SFlash_GetJedecId=111, + ROM_API_INDEX_SFlash_GetUniqueId=110, + ROM_API_INDEX_SFlash_IDbus_Read_Enable=120, + ROM_API_INDEX_SFlash_Init=96, + ROM_API_INDEX_SFlash_Powerdown=113, + ROM_API_INDEX_SFlash_Program=109, + ROM_API_INDEX_SFlash_Qspi_Enable=102, + ROM_API_INDEX_SFlash_Read=127, + ROM_API_INDEX_SFlash_Read_Reg=98, + ROM_API_INDEX_SFlash_Read_Reg_With_Cmd=-128, + ROM_API_INDEX_SFlash_Releae_Powerdown=114, + ROM_API_INDEX_SFlash_Reset_Continue_Read=118, + ROM_API_INDEX_SFlash_Restore_From_Powerdown=-126, + ROM_API_INDEX_SFlash_Sector_Erase=105, + ROM_API_INDEX_SFlash_SetBurstWrap=115, + ROM_API_INDEX_SFlash_SetSPIMode=97, + ROM_API_INDEX_SFlash_Set_IDbus_Cfg=119, + ROM_API_INDEX_SFlash_Software_Reset=117, + ROM_API_INDEX_SFlash_Volatile_Reg_Write_Enable=103, + ROM_API_INDEX_SFlash_Write_Enable=101, + ROM_API_INDEX_SFlash_Write_Reg=99, + ROM_API_INDEX_SFlash_Write_Reg_With_Cmd=-127, + ROM_API_INDEX_System_Core_Clock_Update_From_RC32M=44, + ROM_API_INDEX_Update_SystemCoreClockWith_XTAL=42, + ROM_API_INDEX_VERSION=0, + ROM_API_INDEX_XIP_SFlash_Erase_Need_Lock=-93, + ROM_API_INDEX_XIP_SFlash_Erase_With_Lock=-84, + ROM_API_INDEX_XIP_SFlash_GetDeviceId_Need_Lock=-89, + ROM_API_INDEX_XIP_SFlash_GetJedecId_Need_Lock=-90, + ROM_API_INDEX_XIP_SFlash_GetUniqueId_Need_Lock=-88, + ROM_API_INDEX_XIP_SFlash_Opt_Enter=-83, + ROM_API_INDEX_XIP_SFlash_Opt_Exit=-82, + ROM_API_INDEX_XIP_SFlash_Read_Need_Lock=-91, + ROM_API_INDEX_XIP_SFlash_Read_Via_Cache_Need_Lock=-87, + ROM_API_INDEX_XIP_SFlash_Read_With_Lock=-86, + ROM_API_INDEX_XIP_SFlash_State_Restore=-94, + ROM_API_INDEX_XIP_SFlash_State_Save=-95, + ROM_API_INDEX_XIP_SFlash_Write_Need_Lock=-92, + ROM_API_INDEX_XIP_SFlash_Write_With_Lock=-85, + SCANU_JOIN_CFM=4099, + SCANU_JOIN_REQ=4098, + SCANU_MAX=4103, + SCANU_RAW_SEND_CFM=4102, + SCANU_RAW_SEND_REQ=4101, + SCANU_RESULT_IND=4100, + SCANU_START_CFM=4097, + SCANU_START_REQ=4096 +} anon_enum_16; + +typedef struct stats_mem stats_mem, *Pstats_mem; + +typedef uint16_t u16_t; + +typedef u16_t mem_size_t; + +struct stats_mem { + u16_t err; + mem_size_t avail; + mem_size_t used; + mem_size_t max; + u16_t illegal; +}; + +typedef struct stats_proto stats_proto, *Pstats_proto; + +struct stats_proto { + u16_t xmit; + u16_t recv; + u16_t fw; + u16_t drop; + u16_t chkerr; + u16_t lenerr; + u16_t memerr; + u16_t rterr; + u16_t proterr; + u16_t opterr; + u16_t err; + u16_t cachehit; +}; + +typedef struct stats_ stats_, *Pstats_; + +typedef struct stats_igmp stats_igmp, *Pstats_igmp; + +typedef struct stats_sys stats_sys, *Pstats_sys; + +typedef struct stats_syselem stats_syselem, *Pstats_syselem; + +struct stats_syselem { + u16_t used; + u16_t max; + u16_t err; +}; + +struct stats_sys { + struct stats_syselem sem; + struct stats_syselem mutex; + struct stats_syselem mbox; +}; + +struct stats_igmp { + u16_t xmit; + u16_t recv; + u16_t drop; + u16_t chkerr; + u16_t lenerr; + u16_t memerr; + u16_t proterr; + u16_t rx_v1; + u16_t rx_group; + u16_t rx_general; + u16_t rx_report; + u16_t tx_join; + u16_t tx_leave; + u16_t tx_report; +}; + +struct stats_ { + struct stats_proto link; + struct stats_proto etharp; + struct stats_proto ip; + struct stats_proto icmp; + struct stats_igmp igmp; + struct stats_proto udp; + struct stats_proto tcp; + struct stats_mem mem; + undefined field_0xb6; + undefined field_0xb7; + struct stats_mem * memp[15]; + struct stats_sys sys; + undefined field_0x106; + undefined field_0x107; +}; + +typedef uchar uint8; + +typedef short SINT16; + +typedef enum Status_e { + FAIL=1, + FW_SUCCESS=0 +} Status_e; + +typedef long SINT32; + +typedef enum wlan_security_type { + WLAN_SECURITY_EAP_TLS=6, + WLAN_SECURITY_NONE=0, + WLAN_SECURITY_WEP_OPEN=1, + WLAN_SECURITY_WEP_SHARED=2, + WLAN_SECURITY_WILDCARD=7, + WLAN_SECURITY_WPA=3, + WLAN_SECURITY_WPA2=4, + WLAN_SECURITY_WPA_WPA2_MIXED=5 +} wlan_security_type; + +typedef char CHAR; + +typedef ushort uint16; + +typedef char SINT8; + +typedef void mdev_t; + +typedef ulong uint32; + +typedef ulonglong UINT64; + +typedef int BOOLEAN; + +typedef struct hw_vect.conflict1 hw_vect.conflict1, *Phw_vect.conflict1; + +typedef uint32_t u32.conflict197; + +typedef uint32_t u32.conflict198; + +typedef uint32_t u32.conflict199; + +typedef uint32_t u32.conflict200; + +typedef uint32_t u32.conflict201; + +typedef uint32_t u32.conflict202; + +typedef uint32_t u32.conflict203; + +typedef uint32_t u32.conflict204; + +typedef uint32_t u32.conflict205; + +typedef uint32_t u32.conflict206; + +typedef uint32_t u32.conflict207; + +typedef uint32_t u32.conflict208; + +typedef uint32_t u32.conflict209; + +typedef uint32_t u32.conflict210; + +typedef uint32_t u32.conflict211; + +typedef uint32_t u32.conflict212; + +typedef uint32_t u32.conflict213; + +typedef uint32_t u32.conflict214; + +typedef uint32_t u32.conflict215; + +typedef uint32_t u32.conflict216; + +typedef uint32_t u32.conflict217; + +typedef uint32_t u32.conflict218; + +typedef uint32_t u32.conflict219; + +typedef uint32_t u32.conflict220; + +typedef uint32_t u32.conflict221; + +typedef uint32_t u32.conflict222; + +typedef uint32_t u32.conflict223; + +typedef long int32_t; + +typedef int32_t s32; + +typedef uint32_t u32.conflict224; + +typedef uint32_t u32.conflict225; + +typedef uint32_t u32.conflict226; + +typedef uint32_t u32.conflict227; + +typedef uint32_t u32.conflict228; + +typedef uint32_t u32.conflict229; + +typedef uint32_t u32.conflict230; + +typedef uint32_t u32.conflict231; + +typedef uint32_t u32.conflict232; + +typedef uint32_t u32.conflict233; + +typedef uint32_t u32.conflict234; + +typedef uint32_t u32.conflict235; + +typedef uint32_t u32.conflict236; + +typedef uint32_t u32.conflict237; + +typedef uint32_t u32.conflict238; + +typedef uint32_t u32.conflict239; + +typedef uint32_t u32.conflict240; + +typedef uint32_t u32.conflict241; + +typedef uint32_t u32.conflict242; + +typedef uint32_t u32.conflict243; + +typedef uint32_t u32.conflict244; + +typedef uint32_t u32.conflict245; + +typedef uint32_t u32.conflict246; + +typedef uint32_t u32.conflict247; + +typedef uint32_t u32.conflict248; + +struct hw_vect.conflict1 { + u32.conflict197 len:16; + u32.conflict198 reserved:8; + u32.conflict199 mpdu_cnt:6; + u32.conflict200 ampdu_cnt:2; + __le32 tsf_lo; + __le32 tsf_hi; + u32.conflict201 leg_length:12; + u32.conflict202 leg_rate:4; + u32.conflict203 ht_length:16; + u32.conflict204 _ht_length:4; + u32.conflict205 short_gi:1; + u32.conflict206 stbc:2; + u32.conflict207 smoothing:1; + u32.conflict208 mcs:7; + u32.conflict209 pre_type:1; + u32.conflict210 format_mod:3; + u32.conflict211 ch_bw:2; + u32.conflict212 n_sts:3; + u32.conflict213 lsig_valid:1; + u32.conflict214 sounding:1; + u32.conflict215 num_extn_ss:2; + u32.conflict216 aggregation:1; + u32.conflict217 fec_coding:1; + u32.conflict218 dyn_bw:1; + u32.conflict219 doze_not_allowed:1; + u32.conflict220 antenna_set:8; + u32.conflict221 partial_aid:9; + u32.conflict222 group_id:6; + u32.conflict223 reserved_1c:1; + s32 rssi1:8; + s32 rssi2:8; + s32 rssi3:8; + s32 rssi4:8; + u32.conflict224 reserved_1d:8; + u32.conflict225 rcpi:8; + u32.conflict226 evm1:8; + u32.conflict227 evm2:8; + u32.conflict228 evm3:8; + u32.conflict229 evm4:8; + u32.conflict230 reserved2b_1:8; + u32.conflict231 reserved2b_2:8; + u32.conflict232 reserved2b_3:8; + u32.conflict233 rx_vect2_valid:1; + u32.conflict234 resp_frame:1; + u32.conflict235 decr_status:3; + u32.conflict236 rx_fifo_oflow:1; + u32.conflict237 undef_err:1; + u32.conflict238 phy_err:1; + u32.conflict239 fcs_err:1; + u32.conflict240 addr_mismatch:1; + u32.conflict241 ga_frame:1; + u32.conflict242 current_ac:2; + u32.conflict243 frm_successful_rx:1; + u32.conflict244 desc_done_rx:1; + u32.conflict245 key_sram_index:10; + u32.conflict246 key_sram_v:1; + u32.conflict247 type:2; + u32.conflict248 subtype:4; +}; + +typedef struct hw_rxhdr.conflict hw_rxhdr.conflict, *Phw_rxhdr.conflict; + +typedef uint32_t u32.conflict249; + +typedef uint32_t u32.conflict250; + +typedef uint32_t u32.conflict251; + +typedef uint32_t u32.conflict252; + +typedef uint32_t u32.conflict253; + +typedef uint32_t u32.conflict254; + +typedef uint32_t u32.conflict255; + +typedef uint32_t u32.conflict256; + +typedef uint32_t u32.conflict257; + +typedef uint32_t u32.conflict258; + +typedef uint32_t u32.conflict259; + +typedef uint32_t u32.conflict260; + +typedef uint32_t u32.conflict261; + +typedef uint32_t u32.conflict262; + +typedef uint32_t u32.conflict263; + +typedef uint32_t u32.conflict264; + +typedef uint32_t u32.conflict265; + +typedef uint32_t u32.conflict266; + +struct hw_rxhdr.conflict { + struct hw_vect.conflict1 hwvect; + u32.conflict249 phy_band:8; + u32.conflict250 phy_channel_type:8; + u32.conflict251 phy_prim20_freq:16; + u32.conflict252 phy_center1_freq:16; + u32.conflict253 phy_center2_freq:16; + u32.conflict254 flags_is_amsdu:1; + u32.conflict255 flags_is_80211_mpdu:1; + u32.conflict256 flags_is_4addr:1; + u32.conflict257 flags_new_peer:1; + u32.conflict258 flags_user_prio:3; + u32.conflict259 flags_rsvd0:1; + u32.conflict260 flags_vif_idx:8; + u32.conflict261 flags_sta_idx:8; + u32.conflict262 flags_dst_idx:8; + u32.conflict263 pattern; + u32.conflict264 payl_offset; + u32.conflict265 reserved_pad[2]; + u32.conflict266 wild[8]; +}; + +typedef struct sm_reason_code sm_reason_code, *Psm_reason_code; + +struct sm_reason_code { + uint16_t reason_code; + undefined field_0x2; + undefined field_0x3; + char * action; +}; + +typedef struct hw_vect.conflict hw_vect.conflict, *Phw_vect.conflict; + +typedef uint32_t u32.conflict107; + +typedef uint32_t u32.conflict108; + +typedef uint32_t u32.conflict109; + +typedef uint32_t u32.conflict110; + +typedef uint32_t u32.conflict111; + +typedef uint32_t u32.conflict112; + +typedef uint32_t u32.conflict113; + +typedef uint32_t u32.conflict114; + +typedef uint32_t u32.conflict115; + +typedef uint32_t u32.conflict116; + +typedef uint32_t u32.conflict117; + +typedef uint32_t u32.conflict118; + +typedef uint32_t u32.conflict119; + +typedef uint32_t u32.conflict120; + +typedef uint32_t u32.conflict121; + +typedef uint32_t u32.conflict122; + +typedef uint32_t u32.conflict123; + +typedef uint32_t u32.conflict124; + +typedef uint32_t u32.conflict125; + +typedef uint32_t u32.conflict126; + +typedef uint32_t u32.conflict127; + +typedef uint32_t u32.conflict128; + +typedef uint32_t u32.conflict129; + +typedef uint32_t u32.conflict130; + +typedef uint32_t u32.conflict131; + +typedef uint32_t u32.conflict132; + +typedef uint32_t u32.conflict133; + +typedef uint32_t u32.conflict134; + +typedef uint32_t u32.conflict135; + +typedef uint32_t u32.conflict136; + +typedef uint32_t u32.conflict137; + +typedef uint32_t u32.conflict138; + +typedef uint32_t u32.conflict139; + +typedef uint32_t u32.conflict140; + +typedef uint32_t u32.conflict141; + +typedef uint32_t u32.conflict142; + +typedef uint32_t u32.conflict143; + +typedef uint32_t u32.conflict144; + +typedef uint32_t u32.conflict145; + +typedef uint32_t u32.conflict146; + +typedef uint32_t u32.conflict147; + +typedef uint32_t u32.conflict148; + +typedef uint32_t u32.conflict149; + +typedef uint32_t u32.conflict150; + +typedef uint32_t u32.conflict151; + +typedef uint32_t u32.conflict152; + +typedef uint32_t u32.conflict153; + +typedef uint32_t u32.conflict154; + +typedef uint32_t u32.conflict155; + +typedef uint32_t u32.conflict156; + +typedef uint32_t u32.conflict157; + +typedef uint32_t u32.conflict158; + +struct hw_vect.conflict { + u32.conflict107 len:16; + u32.conflict108 reserved:8; + u32.conflict109 mpdu_cnt:6; + u32.conflict110 ampdu_cnt:2; + __le32 tsf_lo; + __le32 tsf_hi; + u32.conflict111 leg_length:12; + u32.conflict112 leg_rate:4; + u32.conflict113 ht_length:16; + u32.conflict114 _ht_length:4; + u32.conflict115 short_gi:1; + u32.conflict116 stbc:2; + u32.conflict117 smoothing:1; + u32.conflict118 mcs:7; + u32.conflict119 pre_type:1; + u32.conflict120 format_mod:3; + u32.conflict121 ch_bw:2; + u32.conflict122 n_sts:3; + u32.conflict123 lsig_valid:1; + u32.conflict124 sounding:1; + u32.conflict125 num_extn_ss:2; + u32.conflict126 aggregation:1; + u32.conflict127 fec_coding:1; + u32.conflict128 dyn_bw:1; + u32.conflict129 doze_not_allowed:1; + u32.conflict130 antenna_set:8; + u32.conflict131 partial_aid:9; + u32.conflict132 group_id:6; + u32.conflict133 reserved_1c:1; + s32 rssi1:8; + s32 rssi2:8; + s32 rssi3:8; + s32 rssi4:8; + u32.conflict134 reserved_1d:8; + u32.conflict135 rcpi:8; + u32.conflict136 evm1:8; + u32.conflict137 evm2:8; + u32.conflict138 evm3:8; + u32.conflict139 evm4:8; + u32.conflict140 reserved2b_1:8; + u32.conflict141 reserved2b_2:8; + u32.conflict142 reserved2b_3:8; + u32.conflict143 rx_vect2_valid:1; + u32.conflict144 resp_frame:1; + u32.conflict145 decr_status:3; + u32.conflict146 rx_fifo_oflow:1; + u32.conflict147 undef_err:1; + u32.conflict148 phy_err:1; + u32.conflict149 fcs_err:1; + u32.conflict150 addr_mismatch:1; + u32.conflict151 ga_frame:1; + u32.conflict152 current_ac:2; + u32.conflict153 frm_successful_rx:1; + u32.conflict154 desc_done_rx:1; + u32.conflict155 key_sram_index:10; + u32.conflict156 key_sram_v:1; + u32.conflict157 type:2; + u32.conflict158 subtype:4; +}; + +typedef struct hw_vect hw_vect, *Phw_vect; + +typedef uint32_t u32.conflict55; + +typedef uint32_t u32.conflict56; + +typedef uint32_t u32.conflict57; + +typedef uint32_t u32.conflict58; + +typedef uint32_t u32.conflict59; + +typedef uint32_t u32.conflict60; + +typedef uint32_t u32.conflict61; + +typedef uint32_t u32.conflict62; + +typedef uint32_t u32.conflict63; + +typedef uint32_t u32.conflict64; + +typedef uint32_t u32.conflict65; + +typedef uint32_t u32.conflict66; + +typedef uint32_t u32.conflict67; + +typedef uint32_t u32.conflict68; + +typedef uint32_t u32.conflict69; + +typedef uint32_t u32.conflict70; + +typedef uint32_t u32.conflict71; + +typedef uint32_t u32.conflict72; + +typedef uint32_t u32.conflict73; + +typedef uint32_t u32.conflict74; + +typedef uint32_t u32.conflict75; + +typedef uint32_t u32.conflict76; + +typedef uint32_t u32.conflict77; + +typedef uint32_t u32.conflict78; + +typedef uint32_t u32.conflict79; + +typedef uint32_t u32.conflict80; + +typedef uint32_t u32.conflict81; + +typedef uint32_t u32.conflict82; + +typedef uint32_t u32.conflict83; + +typedef uint32_t u32.conflict84; + +typedef uint32_t u32.conflict85; + +typedef uint32_t u32.conflict86; + +typedef uint32_t u32.conflict87; + +typedef uint32_t u32.conflict88; + +typedef uint32_t u32.conflict89; + +typedef uint32_t u32.conflict90; + +typedef uint32_t u32.conflict91; + +typedef uint32_t u32.conflict92; + +typedef uint32_t u32.conflict93; + +typedef uint32_t u32.conflict94; + +typedef uint32_t u32.conflict95; + +typedef uint32_t u32.conflict96; + +typedef uint32_t u32.conflict97; + +typedef uint32_t u32.conflict98; + +typedef uint32_t u32.conflict99; + +typedef uint32_t u32.conflict100; + +typedef uint32_t u32.conflict101; + +typedef uint32_t u32.conflict102; + +typedef uint32_t u32.conflict103; + +typedef uint32_t u32.conflict104; + +typedef uint32_t u32.conflict105; + +typedef uint32_t u32.conflict106; + +struct hw_vect { + u32.conflict55 len:16; + u32.conflict56 reserved:8; + u32.conflict57 mpdu_cnt:6; + u32.conflict58 ampdu_cnt:2; + __le32 tsf_lo; + __le32 tsf_hi; + u32.conflict59 leg_length:12; + u32.conflict60 leg_rate:4; + u32.conflict61 ht_length:16; + u32.conflict62 _ht_length:4; + u32.conflict63 short_gi:1; + u32.conflict64 stbc:2; + u32.conflict65 smoothing:1; + u32.conflict66 mcs:7; + u32.conflict67 pre_type:1; + u32.conflict68 format_mod:3; + u32.conflict69 ch_bw:2; + u32.conflict70 n_sts:3; + u32.conflict71 lsig_valid:1; + u32.conflict72 sounding:1; + u32.conflict73 num_extn_ss:2; + u32.conflict74 aggregation:1; + u32.conflict75 fec_coding:1; + u32.conflict76 dyn_bw:1; + u32.conflict77 doze_not_allowed:1; + u32.conflict78 antenna_set:8; + u32.conflict79 partial_aid:9; + u32.conflict80 group_id:6; + u32.conflict81 reserved_1c:1; + s32 rssi1:8; + s32 rssi2:8; + s32 rssi3:8; + s32 rssi4:8; + u32.conflict82 reserved_1d:8; + u32.conflict83 rcpi:8; + u32.conflict84 evm1:8; + u32.conflict85 evm2:8; + u32.conflict86 evm3:8; + u32.conflict87 evm4:8; + u32.conflict88 reserved2b_1:8; + u32.conflict89 reserved2b_2:8; + u32.conflict90 reserved2b_3:8; + u32.conflict91 rx_vect2_valid:1; + u32.conflict92 resp_frame:1; + u32.conflict93 decr_status:3; + u32.conflict94 rx_fifo_oflow:1; + u32.conflict95 undef_err:1; + u32.conflict96 phy_err:1; + u32.conflict97 fcs_err:1; + u32.conflict98 addr_mismatch:1; + u32.conflict99 ga_frame:1; + u32.conflict100 current_ac:2; + u32.conflict101 frm_successful_rx:1; + u32.conflict102 desc_done_rx:1; + u32.conflict103 key_sram_index:10; + u32.conflict104 key_sram_v:1; + u32.conflict105 type:2; + u32.conflict106 subtype:4; +}; + +typedef struct hw_rxhdr hw_rxhdr, *Phw_rxhdr; + +typedef uint32_t u32.conflict159; + +typedef uint32_t u32.conflict160; + +typedef uint32_t u32.conflict161; + +typedef uint32_t u32.conflict162; + +typedef uint32_t u32.conflict163; + +typedef uint32_t u32.conflict164; + +typedef uint32_t u32.conflict165; + +typedef uint32_t u32.conflict166; + +typedef uint32_t u32.conflict167; + +typedef uint32_t u32.conflict168; + +typedef uint32_t u32.conflict169; + +typedef uint32_t u32.conflict170; + +typedef uint32_t u32.conflict171; + +typedef uint32_t u32.conflict172; + +typedef uint32_t u32.conflict173; + +typedef uint32_t u32.conflict174; + +typedef uint32_t u32.conflict175; + +typedef uint32_t u32.conflict176; + +struct hw_rxhdr { + struct hw_vect.conflict hwvect; + u32.conflict159 phy_band:8; + u32.conflict160 phy_channel_type:8; + u32.conflict161 phy_prim20_freq:16; + u32.conflict162 phy_center1_freq:16; + u32.conflict163 phy_center2_freq:16; + u32.conflict164 flags_is_amsdu:1; + u32.conflict165 flags_is_80211_mpdu:1; + u32.conflict166 flags_is_4addr:1; + u32.conflict167 flags_new_peer:1; + u32.conflict168 flags_user_prio:3; + u32.conflict169 flags_rsvd0:1; + u32.conflict170 flags_vif_idx:8; + u32.conflict171 flags_sta_idx:8; + u32.conflict172 flags_dst_idx:8; + u32.conflict173 pattern; + u32.conflict174 payl_offset; + u32.conflict175 reserved_pad[2]; + u32.conflict176 wild[8]; +}; + +typedef struct sha256_state sha256_state, *Psha256_state; + +struct sha256_state { + UINT64 length; + UINT32 state[8]; + UINT32 curlen; + UINT8 buf[64]; + undefined field_0x6c; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef enum nl80211_iftype { + NL80211_IFTYPE_ADHOC=1, + NL80211_IFTYPE_AP=3, + NL80211_IFTYPE_AP_VLAN=4, + NL80211_IFTYPE_MAX=12, + NL80211_IFTYPE_MESH_POINT=7, + NL80211_IFTYPE_MONITOR=6, + NL80211_IFTYPE_NAN=12, + NL80211_IFTYPE_OCB=11, + NL80211_IFTYPE_P2P_CLIENT=8, + NL80211_IFTYPE_P2P_DEVICE=10, + NL80211_IFTYPE_P2P_GO=9, + NL80211_IFTYPE_STATION=2, + NL80211_IFTYPE_UNSPECIFIED=0, + NL80211_IFTYPE_WDS=5, + NUM_NL80211_IFTYPES=13 +} nl80211_iftype; + +typedef enum td_status_bit { + TD_STATUS_RX=1, + TD_STATUS_RX_PS=3, + TD_STATUS_TX=0, + TD_STATUS_TX_PS=2 +} td_status_bit; + +typedef struct td_env_tag td_env_tag, *Ptd_env_tag; + +typedef struct mm_timer_tag mm_timer_tag, *Pmm_timer_tag; + +typedef struct co_list_hdr co_list_hdr, *Pco_list_hdr; + +struct co_list_hdr { + struct co_list_hdr * next; +}; + +struct mm_timer_tag { + struct co_list_hdr list_hdr; + void (* cb)(void *); + void * env; + uint32_t time; +}; + +struct td_env_tag { + struct mm_timer_tag td_timer; + uint32_t pck_cnt_tx; + uint32_t pck_cnt_rx; + uint32_t pck_cnt_tx_ps; + uint32_t pck_cnt_rx_ps; + uint8_t vif_index; + uint8_t status; + _Bool is_on; + _Bool has_active_chan; +}; + +typedef enum ranks { + rank_char=-2, + rank_int=0, + rank_long=1, + rank_longlong=2, + rank_short=-1 +} ranks; + +typedef enum flag { + FL_HASH=32, + FL_MINUS=2, + FL_PLUS=4, + FL_SIGNED=64, + FL_SPACE=16, + FL_TICK=8, + FL_UPPER=-128, + FL_ZERO=1 +} flag; + +typedef enum anon_enum_8 { + st_flags=1, + st_modifiers=4, + st_normal=0, + st_prec=3, + st_width=2 +} anon_enum_8; + +typedef struct tmrTimerControl tmrTimerControl, *PtmrTimerControl; + +typedef struct tmrTimerControl * TimerHandle_t; + +typedef struct xLIST_ITEM xLIST_ITEM, *PxLIST_ITEM; + +typedef struct xLIST_ITEM ListItem_t; + +typedef uint32_t TickType_t; + +typedef uint32_t UBaseType_t; + +typedef struct xLIST xLIST, *PxLIST; + +typedef struct xMINI_LIST_ITEM xMINI_LIST_ITEM, *PxMINI_LIST_ITEM; + +typedef struct xMINI_LIST_ITEM MiniListItem_t; + +struct xMINI_LIST_ITEM { + TickType_t xItemValue; + struct xLIST_ITEM * pxNext; + struct xLIST_ITEM * pxPrevious; +}; + +struct xLIST_ITEM { + TickType_t xItemValue; + struct xLIST_ITEM * pxNext; + struct xLIST_ITEM * pxPrevious; + void * pvOwner; + struct xLIST * pvContainer; +}; + +struct tmrTimerControl { + char * pcTimerName; + ListItem_t xTimerListItem; + TickType_t xTimerPeriodInTicks; + void * pvTimerID; + void (* pxCallbackFunction)(TimerHandle_t); + UBaseType_t uxTimerNumber; + uint8_t ucStatus; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +struct xLIST { + UBaseType_t uxNumberOfItems; + ListItem_t * pxIndex; + MiniListItem_t xListEnd; +}; + +typedef struct scanu_env_tag scanu_env_tag, *Pscanu_env_tag; + +typedef struct scanu_start_req scanu_start_req, *Pscanu_start_req; + +typedef struct hal_dma_desc_tag hal_dma_desc_tag, *Phal_dma_desc_tag; + +typedef struct mac_scan_result mac_scan_result, *Pmac_scan_result; + +typedef uint16_t ke_task_id_t; + +typedef struct mac_addr mac_addr, *Pmac_addr; + +typedef struct mac_ssid mac_ssid, *Pmac_ssid; + +typedef struct scan_chan_tag scan_chan_tag, *Pscan_chan_tag; + +typedef struct dma_desc dma_desc, *Pdma_desc; + +struct hal_dma_desc_tag { + struct co_list_hdr hdr; + struct dma_desc * dma_desc; + void (* cb)(void *, int); + void * env; +}; + +struct dma_desc { + uint32_t src; + uint32_t dest; + uint16_t length; + uint16_t ctrl; + uint32_t next; +}; + +struct mac_addr { + uint16_t array[3]; +}; + +struct mac_ssid { + uint8_t length; + uint8_t array[32]; + uint8_t array_tail[1]; +}; + +struct scan_chan_tag { + uint16_t freq; + uint8_t band; + uint8_t flags; + int8_t tx_power; + undefined field_0x5; +}; + +struct scanu_start_req { + struct scan_chan_tag chan[42]; + struct mac_ssid ssid[2]; + struct mac_addr bssid; + undefined field_0x146; + undefined field_0x147; + uint32_t add_ies; + uint16_t add_ie_len; + uint8_t vif_idx; + uint8_t chan_cnt; + uint8_t ssid_cnt; + _Bool no_cck; + undefined field_0x152; + undefined field_0x153; +}; + +struct mac_scan_result { + struct mac_addr bssid; + struct mac_ssid ssid; + uint16_t bsstype; + undefined field_0x2a; + undefined field_0x2b; + struct scan_chan_tag * chan; + uint16_t beacon_period; + uint16_t cap_info; + _Bool valid_flag; + int8_t rssi; + int8_t ppm_rel; + int8_t ppm_abs; +}; + +struct scanu_env_tag { + struct scanu_start_req * param; + struct hal_dma_desc_tag dma_desc; + uint16_t result_cnt; + undefined field_0x16; + undefined field_0x17; + struct mac_scan_result scan_result[6]; + ke_task_id_t src_id; + _Bool joining; + uint8_t band; + struct mac_addr bssid; + struct mac_ssid ssid; +}; + +typedef struct scanu_add_ie_tag scanu_add_ie_tag, *Pscanu_add_ie_tag; + +struct scanu_add_ie_tag { + struct dma_desc dma_desc; + uint32_t buf[50]; +}; + +typedef enum HBN_PIR_HPF_Type { + HBN_PIR_HPF_METHOD0=0, + HBN_PIR_HPF_METHOD1=1, + HBN_PIR_HPF_METHOD2=2 +} HBN_PIR_HPF_Type; + +typedef enum HBN_OUT0_INT_Type { + HBN_OUT0_INT_GPIO7=0, + HBN_OUT0_INT_GPIO8=1, + HBN_OUT0_INT_RTC=2 +} HBN_OUT0_INT_Type; + +typedef enum HBN_XCLK_CLK_Type { + HBN_XCLK_CLK_RC32M=0, + HBN_XCLK_CLK_XTAL=1 +} HBN_XCLK_CLK_Type; + +typedef enum HBN_BOR_THRES_Type { + HBN_BOR_THRES_2P0V=0, + HBN_BOR_THRES_2P4V=1 +} HBN_BOR_THRES_Type; + +typedef struct HBN_APP_CFG_Type HBN_APP_CFG_Type, *PHBN_APP_CFG_Type; + +typedef enum HBN_GPIO_INT_Trigger_Type { + HBN_GPIO_INT_TRIGGER_ASYNC_FALLING_EDGE=4, + HBN_GPIO_INT_TRIGGER_ASYNC_HIGH_LEVEL=7, + HBN_GPIO_INT_TRIGGER_ASYNC_LOW_LEVEL=6, + HBN_GPIO_INT_TRIGGER_ASYNC_RISING_EDGE=5, + HBN_GPIO_INT_TRIGGER_SYNC_FALLING_EDGE=0, + HBN_GPIO_INT_TRIGGER_SYNC_HIGH_LEVEL=3, + HBN_GPIO_INT_TRIGGER_SYNC_LOW_LEVEL=2, + HBN_GPIO_INT_TRIGGER_SYNC_RISING_EDGE=1 +} HBN_GPIO_INT_Trigger_Type; + +typedef struct SPI_Flash_Cfg_Type SPI_Flash_Cfg_Type, *PSPI_Flash_Cfg_Type; + +typedef enum HBN_LEVEL_Type { + HBN_LEVEL_0=0, + HBN_LEVEL_1=1, + HBN_LEVEL_2=2, + HBN_LEVEL_3=3 +} HBN_LEVEL_Type; + +typedef enum HBN_LDO_LEVEL_Type { + HBN_LDO_LEVEL_0P60V=0, + HBN_LDO_LEVEL_0P65V=1, + HBN_LDO_LEVEL_0P70V=2, + HBN_LDO_LEVEL_0P75V=3, + HBN_LDO_LEVEL_0P80V=4, + HBN_LDO_LEVEL_0P85V=5, + HBN_LDO_LEVEL_0P90V=6, + HBN_LDO_LEVEL_0P95V=7, + HBN_LDO_LEVEL_1P00V=8, + HBN_LDO_LEVEL_1P05V=9, + HBN_LDO_LEVEL_1P10V=10, + HBN_LDO_LEVEL_1P15V=11, + HBN_LDO_LEVEL_1P20V=12, + HBN_LDO_LEVEL_1P25V=13, + HBN_LDO_LEVEL_1P30V=14, + HBN_LDO_LEVEL_1P35V=15 +} HBN_LDO_LEVEL_Type; + +struct HBN_APP_CFG_Type { + uint8_t useXtal32k; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + uint32_t sleepTime; + uint8_t gpioWakeupSrc; + enum HBN_GPIO_INT_Trigger_Type gpioTrigType; + undefined field_0xa; + undefined field_0xb; + struct SPI_Flash_Cfg_Type * flashCfg; + enum HBN_LEVEL_Type hbnLevel; + enum HBN_LDO_LEVEL_Type ldoLevel; + undefined field_0x12; + undefined field_0x13; +}; + +struct SPI_Flash_Cfg_Type { + uint8_t ioMode; + uint8_t cReadSupport; + uint8_t clkDelay; + uint8_t clkInvert; + uint8_t resetEnCmd; + uint8_t resetCmd; + uint8_t resetCreadCmd; + uint8_t resetCreadCmdSize; + uint8_t jedecIdCmd; + uint8_t jedecIdCmdDmyClk; + uint8_t qpiJedecIdCmd; + uint8_t qpiJedecIdCmdDmyClk; + uint8_t sectorSize; + uint8_t mid; + uint16_t pageSize; + uint8_t chipEraseCmd; + uint8_t sectorEraseCmd; + uint8_t blk32EraseCmd; + uint8_t blk64EraseCmd; + uint8_t writeEnableCmd; + uint8_t pageProgramCmd; + uint8_t qpageProgramCmd; + uint8_t qppAddrMode; + uint8_t fastReadCmd; + uint8_t frDmyClk; + uint8_t qpiFastReadCmd; + uint8_t qpiFrDmyClk; + uint8_t fastReadDoCmd; + uint8_t frDoDmyClk; + uint8_t fastReadDioCmd; + uint8_t frDioDmyClk; + uint8_t fastReadQoCmd; + uint8_t frQoDmyClk; + uint8_t fastReadQioCmd; + uint8_t frQioDmyClk; + uint8_t qpiFastReadQioCmd; + uint8_t qpiFrQioDmyClk; + uint8_t qpiPageProgramCmd; + uint8_t writeVregEnableCmd; + uint8_t wrEnableIndex; + uint8_t qeIndex; + uint8_t busyIndex; + uint8_t wrEnableBit; + uint8_t qeBit; + uint8_t busyBit; + uint8_t wrEnableWriteRegLen; + uint8_t wrEnableReadRegLen; + uint8_t qeWriteRegLen; + uint8_t qeReadRegLen; + uint8_t releasePowerDown; + uint8_t busyReadRegLen; + uint8_t readRegCmd[4]; + uint8_t writeRegCmd[4]; + uint8_t enterQpi; + uint8_t exitQpi; + uint8_t cReadMode; + uint8_t cRExit; + uint8_t burstWrapCmd; + uint8_t burstWrapCmdDmyClk; + uint8_t burstWrapDataMode; + uint8_t burstWrapData; + uint8_t deBurstWrapCmd; + uint8_t deBurstWrapCmdDmyClk; + uint8_t deBurstWrapDataMode; + uint8_t deBurstWrapData; + uint16_t timeEsector; + uint16_t timeE32k; + uint16_t timeE64k; + uint16_t timePagePgm; + uint16_t timeCe; + uint8_t pdDelay; + uint8_t qeData; +}; + +typedef struct HBN_BOR_CFG_Type HBN_BOR_CFG_Type, *PHBN_BOR_CFG_Type; + +struct HBN_BOR_CFG_Type { + uint8_t enableBor; + uint8_t enableBorInt; + uint8_t borThreshold; + uint8_t enablePorInBor; +}; + +typedef enum HBN_PIR_LPF_Type { + HBN_PIR_LPF_DIV1=0, + HBN_PIR_LPF_DIV2=1 +} HBN_PIR_LPF_Type; + +typedef struct HBN_PIR_INT_CFG_Type HBN_PIR_INT_CFG_Type, *PHBN_PIR_INT_CFG_Type; + +typedef enum BL_Fun_Type { + DISABLE=0, + ENABLE=1 +} BL_Fun_Type; + +struct HBN_PIR_INT_CFG_Type { + enum BL_Fun_Type lowIntEn; + enum BL_Fun_Type highIntEn; +}; + +typedef enum HBN_32K_CLK_Type { + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1 +} HBN_32K_CLK_Type; + +typedef enum HBN_ROOT_CLK_Type { + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1 +} HBN_ROOT_CLK_Type; + +typedef enum HBN_UART_CLK_Type { + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0 +} HBN_UART_CLK_Type; + +typedef enum HBN_INT_Type { + HBN_INT_ACOMP0=20, + HBN_INT_ACOMP1=22, + HBN_INT_BOR=18, + HBN_INT_GPIO7=0, + HBN_INT_GPIO8=1, + HBN_INT_PIR=17, + HBN_INT_RTC=16 +} HBN_INT_Type; + +typedef enum HBN_OUT1_INT_Type { + HBN_OUT1_INT_ACOMP0=2, + HBN_OUT1_INT_ACOMP1=3, + HBN_OUT1_INT_BOR=1, + HBN_OUT1_INT_PIR=0 +} HBN_OUT1_INT_Type; + +typedef enum HBN_BOR_MODE_Type { + HBN_BOR_MODE_POR_INDEPENDENT=0, + HBN_BOR_MODE_POR_RELEVANT=1 +} HBN_BOR_MODE_Type; + +typedef enum HBN_RTC_INT_Delay_Type { + HBN_RTC_INT_DELAY_0T=1, + HBN_RTC_INT_DELAY_32T=0 +} HBN_RTC_INT_Delay_Type; + +typedef struct tmrTimerQueueMessage tmrTimerQueueMessage, *PtmrTimerQueueMessage; + +typedef struct tmrTimerQueueMessage DaemonTaskMessage_t; + +typedef int32_t BaseType_t; + +typedef union anon_union_for_u anon_union_for_u, *Panon_union_for_u; + +typedef struct tmrTimerParameters tmrTimerParameters, *PtmrTimerParameters; + +typedef struct tmrTimerParameters TimerParameter_t; + +typedef struct tmrCallbackParameters tmrCallbackParameters, *PtmrCallbackParameters; + +typedef struct tmrCallbackParameters CallbackParameters_t; + +typedef struct tmrTimerControl xTIMER; + +typedef xTIMER Timer_t; + +struct tmrTimerParameters { + TickType_t xMessageValue; + Timer_t * pxTimer; +}; + +struct tmrCallbackParameters { + void (* pxCallbackFunction)(void *, uint32_t); + void * pvParameter1; + uint32_t ulParameter2; +}; + +union anon_union_for_u { + TimerParameter_t xTimerParameters; + CallbackParameters_t xCallbackParameters; +}; + +struct tmrTimerQueueMessage { + BaseType_t xMessageID; + union anon_union_for_u u; +}; + +typedef enum flag.conflict { + FL_INV=2, + FL_MINUS=8, + FL_SPLAT=1, + FL_WIDTH=4 +} flag.conflict; + +typedef enum bail { + bail_eof=1, + bail_err=2, + bail_none=0 +} bail; + +typedef enum ranks.conflict { + rank_char=-2, + rank_int=0, + rank_long=1, + rank_longlong=2, + rank_ptr=2147483647, + rank_short=-1 +} ranks.conflict; + + +// WARNING! conflicting data type names: /DWARF/vsscanf.c/vsscanf/anon_enum_8 - /DWARF/debug.c/vsnprintf/anon_enum_8 + +typedef struct txdesc_host.conflict60 txdesc_host.conflict60, *Ptxdesc_host.conflict60; + +typedef uint32_t u32_l; + +typedef struct hostdesc.conflict75 hostdesc.conflict75, *Phostdesc.conflict75; + +typedef uint16_t u16_l; + +typedef struct mac_addr.conflict166 mac_addr.conflict166, *Pmac_addr.conflict166; + +typedef struct mac_addr.conflict167 mac_addr.conflict167, *Pmac_addr.conflict167; + +typedef uint8_t u8_l; + +struct mac_addr.conflict166 { + u8_l array[6]; +}; + +struct mac_addr.conflict167 { + u8_l array[6]; +}; + +struct hostdesc.conflict75 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict166 eth_dest_addr; + struct mac_addr.conflict167 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict60 { + u32_l ready; + struct hostdesc.conflict75 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict5 txdesc_host.conflict5, *Ptxdesc_host.conflict5; + +typedef struct hostdesc.conflict6 hostdesc.conflict6, *Phostdesc.conflict6; + +typedef struct mac_addr.conflict13 mac_addr.conflict13, *Pmac_addr.conflict13; + +typedef struct mac_addr.conflict14 mac_addr.conflict14, *Pmac_addr.conflict14; + +struct mac_addr.conflict14 { + u8_l array[6]; +}; + +struct mac_addr.conflict13 { + u8_l array[6]; +}; + +struct hostdesc.conflict6 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict13 eth_dest_addr; + struct mac_addr.conflict14 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict5 { + u32_l ready; + struct hostdesc.conflict6 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict31 ipc_shared_env_tag.conflict31, *Pipc_shared_env_tag.conflict31; + +typedef struct ipc_a2e_msg ipc_a2e_msg, *Pipc_a2e_msg; + +typedef struct txdesc_host.conflict61 txdesc_host.conflict61, *Ptxdesc_host.conflict61; + +typedef struct hostdesc.conflict76 hostdesc.conflict76, *Phostdesc.conflict76; + +typedef struct mac_addr.conflict168 mac_addr.conflict168, *Pmac_addr.conflict168; + +typedef struct mac_addr.conflict169 mac_addr.conflict169, *Pmac_addr.conflict169; + +struct mac_addr.conflict168 { + u8_l array[6]; +}; + +struct mac_addr.conflict169 { + u8_l array[6]; +}; + +struct hostdesc.conflict76 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict168 eth_dest_addr; + struct mac_addr.conflict169 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict61 { + u32_l ready; + struct hostdesc.conflict76 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_a2e_msg { + uint32_t dummy_word; + uint32_t msg[127]; +}; + +struct ipc_shared_env_tag.conflict31 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict61 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict59 txdesc_host.conflict59, *Ptxdesc_host.conflict59; + +typedef struct hostdesc.conflict74 hostdesc.conflict74, *Phostdesc.conflict74; + +typedef struct mac_addr.conflict164 mac_addr.conflict164, *Pmac_addr.conflict164; + +typedef struct mac_addr.conflict165 mac_addr.conflict165, *Pmac_addr.conflict165; + +struct mac_addr.conflict165 { + u8_l array[6]; +}; + +struct mac_addr.conflict164 { + u8_l array[6]; +}; + +struct hostdesc.conflict74 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict164 eth_dest_addr; + struct mac_addr.conflict165 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict59 { + u32_l ready; + struct hostdesc.conflict74 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict8 ipc_shared_env_tag.conflict8, *Pipc_shared_env_tag.conflict8; + +typedef struct txdesc_host.conflict8 txdesc_host.conflict8, *Ptxdesc_host.conflict8; + +typedef struct hostdesc.conflict10 hostdesc.conflict10, *Phostdesc.conflict10; + +typedef struct mac_addr.conflict22 mac_addr.conflict22, *Pmac_addr.conflict22; + +typedef struct mac_addr.conflict23 mac_addr.conflict23, *Pmac_addr.conflict23; + +struct mac_addr.conflict22 { + u8_l array[6]; +}; + +struct mac_addr.conflict23 { + u8_l array[6]; +}; + +struct hostdesc.conflict10 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict22 eth_dest_addr; + struct mac_addr.conflict23 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict8 { + u32_l ready; + struct hostdesc.conflict10 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag.conflict8 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict8 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict6 txdesc_host.conflict6, *Ptxdesc_host.conflict6; + +typedef struct hostdesc.conflict7 hostdesc.conflict7, *Phostdesc.conflict7; + +typedef struct mac_addr.conflict15 mac_addr.conflict15, *Pmac_addr.conflict15; + +typedef struct mac_addr.conflict16 mac_addr.conflict16, *Pmac_addr.conflict16; + +struct mac_addr.conflict16 { + u8_l array[6]; +}; + +struct mac_addr.conflict15 { + u8_l array[6]; +}; + +struct hostdesc.conflict7 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict15 eth_dest_addr; + struct mac_addr.conflict16 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict6 { + u32_l ready; + struct hostdesc.conflict7 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict9 txdesc_host.conflict9, *Ptxdesc_host.conflict9; + +typedef struct hostdesc.conflict11 hostdesc.conflict11, *Phostdesc.conflict11; + +typedef struct mac_addr.conflict24 mac_addr.conflict24, *Pmac_addr.conflict24; + +typedef struct mac_addr.conflict25 mac_addr.conflict25, *Pmac_addr.conflict25; + +struct mac_addr.conflict24 { + u8_l array[6]; +}; + +struct mac_addr.conflict25 { + u8_l array[6]; +}; + +struct hostdesc.conflict11 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict24 eth_dest_addr; + struct mac_addr.conflict25 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict9 { + u32_l ready; + struct hostdesc.conflict11 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict7 txdesc_host.conflict7, *Ptxdesc_host.conflict7; + +typedef struct hostdesc.conflict8 hostdesc.conflict8, *Phostdesc.conflict8; + +typedef struct mac_addr.conflict17 mac_addr.conflict17, *Pmac_addr.conflict17; + +typedef struct mac_addr.conflict18 mac_addr.conflict18, *Pmac_addr.conflict18; + +struct mac_addr.conflict18 { + u8_l array[6]; +}; + +struct mac_addr.conflict17 { + u8_l array[6]; +}; + +struct hostdesc.conflict8 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict17 eth_dest_addr; + struct mac_addr.conflict18 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict7 { + u32_l ready; + struct hostdesc.conflict8 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict4 txdesc_host.conflict4, *Ptxdesc_host.conflict4; + +typedef struct hostdesc.conflict5 hostdesc.conflict5, *Phostdesc.conflict5; + +typedef struct mac_addr.conflict11 mac_addr.conflict11, *Pmac_addr.conflict11; + +typedef struct mac_addr.conflict12 mac_addr.conflict12, *Pmac_addr.conflict12; + +struct mac_addr.conflict11 { + u8_l array[6]; +}; + +struct mac_addr.conflict12 { + u8_l array[6]; +}; + +struct hostdesc.conflict5 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict11 eth_dest_addr; + struct mac_addr.conflict12 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict4 { + u32_l ready; + struct hostdesc.conflict5 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict2 txdesc_host.conflict2, *Ptxdesc_host.conflict2; + +typedef struct hostdesc.conflict3 hostdesc.conflict3, *Phostdesc.conflict3; + +typedef struct mac_addr.conflict7 mac_addr.conflict7, *Pmac_addr.conflict7; + +typedef struct mac_addr.conflict8 mac_addr.conflict8, *Pmac_addr.conflict8; + +struct mac_addr.conflict7 { + u8_l array[6]; +}; + +struct mac_addr.conflict8 { + u8_l array[6]; +}; + +struct hostdesc.conflict3 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict7 eth_dest_addr; + struct mac_addr.conflict8 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict2 { + u32_l ready; + struct hostdesc.conflict3 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict14 txdesc_host.conflict14, *Ptxdesc_host.conflict14; + +typedef struct hostdesc.conflict16 hostdesc.conflict16, *Phostdesc.conflict16; + +typedef struct mac_addr.conflict34 mac_addr.conflict34, *Pmac_addr.conflict34; + +typedef struct mac_addr.conflict35 mac_addr.conflict35, *Pmac_addr.conflict35; + +struct mac_addr.conflict35 { + u8_l array[6]; +}; + +struct mac_addr.conflict34 { + u8_l array[6]; +}; + +struct hostdesc.conflict16 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict34 eth_dest_addr; + struct mac_addr.conflict35 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict14 { + u32_l ready; + struct hostdesc.conflict16 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict3 txdesc_host.conflict3, *Ptxdesc_host.conflict3; + +typedef struct hostdesc.conflict4 hostdesc.conflict4, *Phostdesc.conflict4; + +typedef struct mac_addr.conflict9 mac_addr.conflict9, *Pmac_addr.conflict9; + +typedef struct mac_addr.conflict10 mac_addr.conflict10, *Pmac_addr.conflict10; + +struct mac_addr.conflict10 { + u8_l array[6]; +}; + +struct mac_addr.conflict9 { + u8_l array[6]; +}; + +struct hostdesc.conflict4 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict9 eth_dest_addr; + struct mac_addr.conflict10 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict3 { + u32_l ready; + struct hostdesc.conflict4 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict1 txdesc_host.conflict1, *Ptxdesc_host.conflict1; + +typedef struct hostdesc.conflict2 hostdesc.conflict2, *Phostdesc.conflict2; + +typedef struct mac_addr.conflict5 mac_addr.conflict5, *Pmac_addr.conflict5; + +typedef struct mac_addr.conflict6 mac_addr.conflict6, *Pmac_addr.conflict6; + +struct mac_addr.conflict5 { + u8_l array[6]; +}; + +struct mac_addr.conflict6 { + u8_l array[6]; +}; + +struct hostdesc.conflict2 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict5 eth_dest_addr; + struct mac_addr.conflict6 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict1 { + u32_l ready; + struct hostdesc.conflict2 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict7 ipc_shared_env_tag.conflict7, *Pipc_shared_env_tag.conflict7; + +struct ipc_shared_env_tag.conflict7 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict8 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict9 ipc_shared_env_tag.conflict9, *Pipc_shared_env_tag.conflict9; + +typedef struct txdesc_host.conflict17 txdesc_host.conflict17, *Ptxdesc_host.conflict17; + +typedef struct hostdesc.conflict20 hostdesc.conflict20, *Phostdesc.conflict20; + +typedef struct mac_addr.conflict45 mac_addr.conflict45, *Pmac_addr.conflict45; + +typedef struct mac_addr.conflict46 mac_addr.conflict46, *Pmac_addr.conflict46; + +struct mac_addr.conflict45 { + u8_l array[6]; +}; + +struct mac_addr.conflict46 { + u8_l array[6]; +}; + +struct hostdesc.conflict20 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict45 eth_dest_addr; + struct mac_addr.conflict46 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict17 { + u32_l ready; + struct hostdesc.conflict20 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag.conflict9 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict17 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict30 ipc_shared_env_tag.conflict30, *Pipc_shared_env_tag.conflict30; + +struct ipc_shared_env_tag.conflict30 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict60 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict1 ipc_shared_env_tag.conflict1, *Pipc_shared_env_tag.conflict1; + +struct ipc_shared_env_tag.conflict1 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict5 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict2 ipc_shared_env_tag.conflict2, *Pipc_shared_env_tag.conflict2; + +struct ipc_shared_env_tag.conflict2 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict6 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict25 txdesc_host.conflict25, *Ptxdesc_host.conflict25; + +typedef struct hostdesc.conflict29 hostdesc.conflict29, *Phostdesc.conflict29; + +typedef struct mac_addr.conflict67 mac_addr.conflict67, *Pmac_addr.conflict67; + +typedef struct mac_addr.conflict68 mac_addr.conflict68, *Pmac_addr.conflict68; + +struct mac_addr.conflict67 { + u8_l array[6]; +}; + +struct mac_addr.conflict68 { + u8_l array[6]; +}; + +struct hostdesc.conflict29 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict67 eth_dest_addr; + struct mac_addr.conflict68 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict25 { + u32_l ready; + struct hostdesc.conflict29 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict3 ipc_shared_env_tag.conflict3, *Pipc_shared_env_tag.conflict3; + +struct ipc_shared_env_tag.conflict3 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict7 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict4 ipc_shared_env_tag.conflict4, *Pipc_shared_env_tag.conflict4; + +typedef struct txdesc_host.conflict10 txdesc_host.conflict10, *Ptxdesc_host.conflict10; + +typedef struct hostdesc.conflict12 hostdesc.conflict12, *Phostdesc.conflict12; + +typedef struct mac_addr.conflict26 mac_addr.conflict26, *Pmac_addr.conflict26; + +typedef struct mac_addr.conflict27 mac_addr.conflict27, *Pmac_addr.conflict27; + +struct mac_addr.conflict26 { + u8_l array[6]; +}; + +struct mac_addr.conflict27 { + u8_l array[6]; +}; + +struct hostdesc.conflict12 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict26 eth_dest_addr; + struct mac_addr.conflict27 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict10 { + u32_l ready; + struct hostdesc.conflict12 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag.conflict4 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict10 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict5 ipc_shared_env_tag.conflict5, *Pipc_shared_env_tag.conflict5; + +typedef struct txdesc_host.conflict13 txdesc_host.conflict13, *Ptxdesc_host.conflict13; + +typedef struct hostdesc.conflict15 hostdesc.conflict15, *Phostdesc.conflict15; + +typedef struct mac_addr.conflict32 mac_addr.conflict32, *Pmac_addr.conflict32; + +typedef struct mac_addr.conflict33 mac_addr.conflict33, *Pmac_addr.conflict33; + +struct mac_addr.conflict32 { + u8_l array[6]; +}; + +struct mac_addr.conflict33 { + u8_l array[6]; +}; + +struct hostdesc.conflict15 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict32 eth_dest_addr; + struct mac_addr.conflict33 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict13 { + u32_l ready; + struct hostdesc.conflict15 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag.conflict5 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict13 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict6 ipc_shared_env_tag.conflict6, *Pipc_shared_env_tag.conflict6; + +struct ipc_shared_env_tag.conflict6 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict14 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict38 txdesc_host.conflict38, *Ptxdesc_host.conflict38; + +typedef struct hostdesc.conflict48 hostdesc.conflict48, *Phostdesc.conflict48; + +typedef struct mac_addr.conflict109 mac_addr.conflict109, *Pmac_addr.conflict109; + +typedef struct mac_addr.conflict110 mac_addr.conflict110, *Pmac_addr.conflict110; + +struct mac_addr.conflict110 { + u8_l array[6]; +}; + +struct mac_addr.conflict109 { + u8_l array[6]; +}; + +struct hostdesc.conflict48 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict109 eth_dest_addr; + struct mac_addr.conflict110 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict38 { + u32_l ready; + struct hostdesc.conflict48 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict72 hostdesc.conflict72, *Phostdesc.conflict72; + +typedef struct mac_addr.conflict160 mac_addr.conflict160, *Pmac_addr.conflict160; + +typedef struct mac_addr.conflict161 mac_addr.conflict161, *Pmac_addr.conflict161; + +struct mac_addr.conflict161 { + u8_l array[6]; +}; + +struct mac_addr.conflict160 { + u8_l array[6]; +}; + +struct hostdesc.conflict72 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict160 eth_dest_addr; + struct mac_addr.conflict161 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict73 hostdesc.conflict73, *Phostdesc.conflict73; + +typedef struct mac_addr.conflict162 mac_addr.conflict162, *Pmac_addr.conflict162; + +typedef struct mac_addr.conflict163 mac_addr.conflict163, *Pmac_addr.conflict163; + +struct mac_addr.conflict163 { + u8_l array[6]; +}; + +struct mac_addr.conflict162 { + u8_l array[6]; +}; + +struct hostdesc.conflict73 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict162 eth_dest_addr; + struct mac_addr.conflict163 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict70 hostdesc.conflict70, *Phostdesc.conflict70; + +typedef struct mac_addr.conflict156 mac_addr.conflict156, *Pmac_addr.conflict156; + +typedef struct mac_addr.conflict157 mac_addr.conflict157, *Pmac_addr.conflict157; + +struct mac_addr.conflict156 { + u8_l array[6]; +}; + +struct mac_addr.conflict157 { + u8_l array[6]; +}; + +struct hostdesc.conflict70 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict156 eth_dest_addr; + struct mac_addr.conflict157 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict71 hostdesc.conflict71, *Phostdesc.conflict71; + +typedef struct mac_addr.conflict158 mac_addr.conflict158, *Pmac_addr.conflict158; + +typedef struct mac_addr.conflict159 mac_addr.conflict159, *Pmac_addr.conflict159; + +struct mac_addr.conflict159 { + u8_l array[6]; +}; + +struct mac_addr.conflict158 { + u8_l array[6]; +}; + +struct hostdesc.conflict71 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict158 eth_dest_addr; + struct mac_addr.conflict159 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct ipc_shared_env_tag.conflict21 ipc_shared_env_tag.conflict21, *Pipc_shared_env_tag.conflict21; + +typedef struct txdesc_host.conflict41 txdesc_host.conflict41, *Ptxdesc_host.conflict41; + +typedef struct hostdesc.conflict51 hostdesc.conflict51, *Phostdesc.conflict51; + +typedef struct mac_addr.conflict115 mac_addr.conflict115, *Pmac_addr.conflict115; + +typedef struct mac_addr.conflict116 mac_addr.conflict116, *Pmac_addr.conflict116; + +struct mac_addr.conflict115 { + u8_l array[6]; +}; + +struct mac_addr.conflict116 { + u8_l array[6]; +}; + +struct hostdesc.conflict51 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict115 eth_dest_addr; + struct mac_addr.conflict116 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict41 { + u32_l ready; + struct hostdesc.conflict51 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag.conflict21 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict41 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict50 txdesc_host.conflict50, *Ptxdesc_host.conflict50; + +typedef struct hostdesc.conflict64 hostdesc.conflict64, *Phostdesc.conflict64; + +typedef struct mac_addr.conflict143 mac_addr.conflict143, *Pmac_addr.conflict143; + +typedef struct mac_addr.conflict144 mac_addr.conflict144, *Pmac_addr.conflict144; + +struct mac_addr.conflict143 { + u8_l array[6]; +}; + +struct mac_addr.conflict144 { + u8_l array[6]; +}; + +struct hostdesc.conflict64 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict143 eth_dest_addr; + struct mac_addr.conflict144 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict50 { + u32_l ready; + struct hostdesc.conflict64 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict27 txdesc_host.conflict27, *Ptxdesc_host.conflict27; + +typedef struct hostdesc.conflict31 hostdesc.conflict31, *Phostdesc.conflict31; + +typedef struct mac_addr.conflict71 mac_addr.conflict71, *Pmac_addr.conflict71; + +typedef struct mac_addr.conflict72 mac_addr.conflict72, *Pmac_addr.conflict72; + +struct mac_addr.conflict72 { + u8_l array[6]; +}; + +struct mac_addr.conflict71 { + u8_l array[6]; +}; + +struct hostdesc.conflict31 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict71 eth_dest_addr; + struct mac_addr.conflict72 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict27 { + u32_l ready; + struct hostdesc.conflict31 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict10 ipc_shared_env_tag.conflict10, *Pipc_shared_env_tag.conflict10; + +typedef struct txdesc_host.conflict20 txdesc_host.conflict20, *Ptxdesc_host.conflict20; + +typedef struct hostdesc.conflict23 hostdesc.conflict23, *Phostdesc.conflict23; + +typedef struct mac_addr.conflict51 mac_addr.conflict51, *Pmac_addr.conflict51; + +typedef struct mac_addr.conflict52 mac_addr.conflict52, *Pmac_addr.conflict52; + +struct mac_addr.conflict52 { + u8_l array[6]; +}; + +struct mac_addr.conflict51 { + u8_l array[6]; +}; + +struct hostdesc.conflict23 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict51 eth_dest_addr; + struct mac_addr.conflict52 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict20 { + u32_l ready; + struct hostdesc.conflict23 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag.conflict10 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict20 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict ipc_shared_env_tag.conflict, *Pipc_shared_env_tag.conflict; + +struct ipc_shared_env_tag.conflict { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict2 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict26 txdesc_host.conflict26, *Ptxdesc_host.conflict26; + +typedef struct hostdesc.conflict30 hostdesc.conflict30, *Phostdesc.conflict30; + +typedef struct mac_addr.conflict69 mac_addr.conflict69, *Pmac_addr.conflict69; + +typedef struct mac_addr.conflict70 mac_addr.conflict70, *Pmac_addr.conflict70; + +struct mac_addr.conflict70 { + u8_l array[6]; +}; + +struct mac_addr.conflict69 { + u8_l array[6]; +}; + +struct hostdesc.conflict30 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict69 eth_dest_addr; + struct mac_addr.conflict70 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict26 { + u32_l ready; + struct hostdesc.conflict30 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict9 hostdesc.conflict9, *Phostdesc.conflict9; + +typedef struct mac_addr.conflict20 mac_addr.conflict20, *Pmac_addr.conflict20; + +typedef struct mac_addr.conflict21 mac_addr.conflict21, *Pmac_addr.conflict21; + +struct mac_addr.conflict21 { + u8_l array[6]; +}; + +struct mac_addr.conflict20 { + u8_l array[6]; +}; + +struct hostdesc.conflict9 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict20 eth_dest_addr; + struct mac_addr.conflict21 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict1 hostdesc.conflict1, *Phostdesc.conflict1; + +typedef struct mac_addr.conflict3 mac_addr.conflict3, *Pmac_addr.conflict3; + +typedef struct mac_addr.conflict4 mac_addr.conflict4, *Pmac_addr.conflict4; + +struct mac_addr.conflict4 { + u8_l array[6]; +}; + +struct mac_addr.conflict3 { + u8_l array[6]; +}; + +struct hostdesc.conflict1 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict3 eth_dest_addr; + struct mac_addr.conflict4 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict38 hostdesc.conflict38, *Phostdesc.conflict38; + +typedef struct mac_addr.conflict88 mac_addr.conflict88, *Pmac_addr.conflict88; + +typedef struct mac_addr.conflict89 mac_addr.conflict89, *Pmac_addr.conflict89; + +struct mac_addr.conflict88 { + u8_l array[6]; +}; + +struct mac_addr.conflict89 { + u8_l array[6]; +}; + +struct hostdesc.conflict38 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict88 eth_dest_addr; + struct mac_addr.conflict89 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict40 txdesc_host.conflict40, *Ptxdesc_host.conflict40; + +typedef struct hostdesc.conflict50 hostdesc.conflict50, *Phostdesc.conflict50; + +typedef struct mac_addr.conflict113 mac_addr.conflict113, *Pmac_addr.conflict113; + +typedef struct mac_addr.conflict114 mac_addr.conflict114, *Pmac_addr.conflict114; + +struct mac_addr.conflict113 { + u8_l array[6]; +}; + +struct mac_addr.conflict114 { + u8_l array[6]; +}; + +struct hostdesc.conflict50 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict113 eth_dest_addr; + struct mac_addr.conflict114 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict40 { + u32_l ready; + struct hostdesc.conflict50 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict39 hostdesc.conflict39, *Phostdesc.conflict39; + +typedef struct mac_addr.conflict90 mac_addr.conflict90, *Pmac_addr.conflict90; + +typedef struct mac_addr.conflict91 mac_addr.conflict91, *Pmac_addr.conflict91; + +struct mac_addr.conflict91 { + u8_l array[6]; +}; + +struct mac_addr.conflict90 { + u8_l array[6]; +}; + +struct hostdesc.conflict39 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict90 eth_dest_addr; + struct mac_addr.conflict91 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict36 hostdesc.conflict36, *Phostdesc.conflict36; + +typedef struct mac_addr.conflict84 mac_addr.conflict84, *Pmac_addr.conflict84; + +typedef struct mac_addr.conflict85 mac_addr.conflict85, *Pmac_addr.conflict85; + +struct mac_addr.conflict84 { + u8_l array[6]; +}; + +struct mac_addr.conflict85 { + u8_l array[6]; +}; + +struct hostdesc.conflict36 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict84 eth_dest_addr; + struct mac_addr.conflict85 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict42 txdesc_host.conflict42, *Ptxdesc_host.conflict42; + +typedef struct hostdesc.conflict52 hostdesc.conflict52, *Phostdesc.conflict52; + +typedef struct mac_addr.conflict117 mac_addr.conflict117, *Pmac_addr.conflict117; + +typedef struct mac_addr.conflict118 mac_addr.conflict118, *Pmac_addr.conflict118; + +struct mac_addr.conflict117 { + u8_l array[6]; +}; + +struct mac_addr.conflict118 { + u8_l array[6]; +}; + +struct hostdesc.conflict52 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict117 eth_dest_addr; + struct mac_addr.conflict118 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict42 { + u32_l ready; + struct hostdesc.conflict52 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict37 hostdesc.conflict37, *Phostdesc.conflict37; + +typedef struct mac_addr.conflict86 mac_addr.conflict86, *Pmac_addr.conflict86; + +typedef struct mac_addr.conflict87 mac_addr.conflict87, *Pmac_addr.conflict87; + +struct mac_addr.conflict86 { + u8_l array[6]; +}; + +struct mac_addr.conflict87 { + u8_l array[6]; +}; + +struct hostdesc.conflict37 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict86 eth_dest_addr; + struct mac_addr.conflict87 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict43 txdesc_host.conflict43, *Ptxdesc_host.conflict43; + +typedef struct hostdesc.conflict56 hostdesc.conflict56, *Phostdesc.conflict56; + +typedef struct mac_addr.conflict126 mac_addr.conflict126, *Pmac_addr.conflict126; + +typedef struct mac_addr.conflict127 mac_addr.conflict127, *Pmac_addr.conflict127; + +struct mac_addr.conflict126 { + u8_l array[6]; +}; + +struct mac_addr.conflict127 { + u8_l array[6]; +}; + +struct hostdesc.conflict56 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict126 eth_dest_addr; + struct mac_addr.conflict127 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict43 { + u32_l ready; + struct hostdesc.conflict56 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict34 hostdesc.conflict34, *Phostdesc.conflict34; + +typedef struct mac_addr.conflict80 mac_addr.conflict80, *Pmac_addr.conflict80; + +typedef struct mac_addr.conflict81 mac_addr.conflict81, *Pmac_addr.conflict81; + +struct mac_addr.conflict80 { + u8_l array[6]; +}; + +struct mac_addr.conflict81 { + u8_l array[6]; +}; + +struct hostdesc.conflict34 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict80 eth_dest_addr; + struct mac_addr.conflict81 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict44 txdesc_host.conflict44, *Ptxdesc_host.conflict44; + +typedef struct hostdesc.conflict57 hostdesc.conflict57, *Phostdesc.conflict57; + +typedef struct mac_addr.conflict128 mac_addr.conflict128, *Pmac_addr.conflict128; + +typedef struct mac_addr.conflict129 mac_addr.conflict129, *Pmac_addr.conflict129; + +struct mac_addr.conflict128 { + u8_l array[6]; +}; + +struct mac_addr.conflict129 { + u8_l array[6]; +}; + +struct hostdesc.conflict57 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict128 eth_dest_addr; + struct mac_addr.conflict129 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict44 { + u32_l ready; + struct hostdesc.conflict57 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict35 hostdesc.conflict35, *Phostdesc.conflict35; + +typedef struct mac_addr.conflict82 mac_addr.conflict82, *Pmac_addr.conflict82; + +typedef struct mac_addr.conflict83 mac_addr.conflict83, *Pmac_addr.conflict83; + +struct mac_addr.conflict82 { + u8_l array[6]; +}; + +struct mac_addr.conflict83 { + u8_l array[6]; +}; + +struct hostdesc.conflict35 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict82 eth_dest_addr; + struct mac_addr.conflict83 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict45 txdesc_host.conflict45, *Ptxdesc_host.conflict45; + +typedef struct hostdesc.conflict58 hostdesc.conflict58, *Phostdesc.conflict58; + +typedef struct mac_addr.conflict130 mac_addr.conflict130, *Pmac_addr.conflict130; + +typedef struct mac_addr.conflict131 mac_addr.conflict131, *Pmac_addr.conflict131; + +struct mac_addr.conflict130 { + u8_l array[6]; +}; + +struct mac_addr.conflict131 { + u8_l array[6]; +}; + +struct hostdesc.conflict58 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict130 eth_dest_addr; + struct mac_addr.conflict131 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict45 { + u32_l ready; + struct hostdesc.conflict58 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict32 hostdesc.conflict32, *Phostdesc.conflict32; + +typedef struct mac_addr.conflict73 mac_addr.conflict73, *Pmac_addr.conflict73; + +typedef struct mac_addr.conflict74 mac_addr.conflict74, *Pmac_addr.conflict74; + +struct mac_addr.conflict74 { + u8_l array[6]; +}; + +struct mac_addr.conflict73 { + u8_l array[6]; +}; + +struct hostdesc.conflict32 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict73 eth_dest_addr; + struct mac_addr.conflict74 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict33 hostdesc.conflict33, *Phostdesc.conflict33; + +typedef struct mac_addr.conflict78 mac_addr.conflict78, *Pmac_addr.conflict78; + +typedef struct mac_addr.conflict79 mac_addr.conflict79, *Pmac_addr.conflict79; + +struct mac_addr.conflict79 { + u8_l array[6]; +}; + +struct mac_addr.conflict78 { + u8_l array[6]; +}; + +struct hostdesc.conflict33 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict78 eth_dest_addr; + struct mac_addr.conflict79 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict46 txdesc_host.conflict46, *Ptxdesc_host.conflict46; + +typedef struct hostdesc.conflict59 hostdesc.conflict59, *Phostdesc.conflict59; + +typedef struct mac_addr.conflict132 mac_addr.conflict132, *Pmac_addr.conflict132; + +typedef struct mac_addr.conflict133 mac_addr.conflict133, *Pmac_addr.conflict133; + +struct mac_addr.conflict133 { + u8_l array[6]; +}; + +struct mac_addr.conflict132 { + u8_l array[6]; +}; + +struct hostdesc.conflict59 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict132 eth_dest_addr; + struct mac_addr.conflict133 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict46 { + u32_l ready; + struct hostdesc.conflict59 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict47 txdesc_host.conflict47, *Ptxdesc_host.conflict47; + +typedef struct hostdesc.conflict60 hostdesc.conflict60, *Phostdesc.conflict60; + +typedef struct mac_addr.conflict134 mac_addr.conflict134, *Pmac_addr.conflict134; + +typedef struct mac_addr.conflict135 mac_addr.conflict135, *Pmac_addr.conflict135; + +struct mac_addr.conflict135 { + u8_l array[6]; +}; + +struct mac_addr.conflict134 { + u8_l array[6]; +}; + +struct hostdesc.conflict60 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict134 eth_dest_addr; + struct mac_addr.conflict135 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict47 { + u32_l ready; + struct hostdesc.conflict60 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict28 txdesc_host.conflict28, *Ptxdesc_host.conflict28; + +struct txdesc_host.conflict28 { + u32_l ready; + struct hostdesc.conflict32 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict48 txdesc_host.conflict48, *Ptxdesc_host.conflict48; + +typedef struct hostdesc.conflict62 hostdesc.conflict62, *Phostdesc.conflict62; + +typedef struct mac_addr.conflict139 mac_addr.conflict139, *Pmac_addr.conflict139; + +typedef struct mac_addr.conflict140 mac_addr.conflict140, *Pmac_addr.conflict140; + +struct mac_addr.conflict139 { + u8_l array[6]; +}; + +struct mac_addr.conflict140 { + u8_l array[6]; +}; + +struct hostdesc.conflict62 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict139 eth_dest_addr; + struct mac_addr.conflict140 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict48 { + u32_l ready; + struct hostdesc.conflict62 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict49 txdesc_host.conflict49, *Ptxdesc_host.conflict49; + +typedef struct hostdesc.conflict63 hostdesc.conflict63, *Phostdesc.conflict63; + +typedef struct mac_addr.conflict141 mac_addr.conflict141, *Pmac_addr.conflict141; + +typedef struct mac_addr.conflict142 mac_addr.conflict142, *Pmac_addr.conflict142; + +struct mac_addr.conflict141 { + u8_l array[6]; +}; + +struct mac_addr.conflict142 { + u8_l array[6]; +}; + +struct hostdesc.conflict63 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict141 eth_dest_addr; + struct mac_addr.conflict142 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict49 { + u32_l ready; + struct hostdesc.conflict63 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict49 hostdesc.conflict49, *Phostdesc.conflict49; + +typedef struct mac_addr.conflict111 mac_addr.conflict111, *Pmac_addr.conflict111; + +typedef struct mac_addr.conflict112 mac_addr.conflict112, *Pmac_addr.conflict112; + +struct mac_addr.conflict111 { + u8_l array[6]; +}; + +struct mac_addr.conflict112 { + u8_l array[6]; +}; + +struct hostdesc.conflict49 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict111 eth_dest_addr; + struct mac_addr.conflict112 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict30 txdesc_host.conflict30, *Ptxdesc_host.conflict30; + +struct txdesc_host.conflict30 { + u32_l ready; + struct hostdesc.conflict36 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict31 txdesc_host.conflict31, *Ptxdesc_host.conflict31; + +struct txdesc_host.conflict31 { + u32_l ready; + struct hostdesc.conflict37 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict47 hostdesc.conflict47, *Phostdesc.conflict47; + +typedef struct mac_addr.conflict107 mac_addr.conflict107, *Pmac_addr.conflict107; + +typedef struct mac_addr.conflict108 mac_addr.conflict108, *Pmac_addr.conflict108; + +struct mac_addr.conflict108 { + u8_l array[6]; +}; + +struct mac_addr.conflict107 { + u8_l array[6]; +}; + +struct hostdesc.conflict47 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict107 eth_dest_addr; + struct mac_addr.conflict108 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict32 txdesc_host.conflict32, *Ptxdesc_host.conflict32; + +struct txdesc_host.conflict32 { + u32_l ready; + struct hostdesc.conflict38 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict33 txdesc_host.conflict33, *Ptxdesc_host.conflict33; + +struct txdesc_host.conflict33 { + u32_l ready; + struct hostdesc.conflict39 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict45 hostdesc.conflict45, *Phostdesc.conflict45; + +typedef struct mac_addr.conflict103 mac_addr.conflict103, *Pmac_addr.conflict103; + +typedef struct mac_addr.conflict104 mac_addr.conflict104, *Pmac_addr.conflict104; + +struct mac_addr.conflict104 { + u8_l array[6]; +}; + +struct mac_addr.conflict103 { + u8_l array[6]; +}; + +struct hostdesc.conflict45 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict103 eth_dest_addr; + struct mac_addr.conflict104 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict34 txdesc_host.conflict34, *Ptxdesc_host.conflict34; + +typedef struct hostdesc.conflict40 hostdesc.conflict40, *Phostdesc.conflict40; + +typedef struct mac_addr.conflict92 mac_addr.conflict92, *Pmac_addr.conflict92; + +typedef struct mac_addr.conflict93 mac_addr.conflict93, *Pmac_addr.conflict93; + +struct mac_addr.conflict92 { + u8_l array[6]; +}; + +struct mac_addr.conflict93 { + u8_l array[6]; +}; + +struct hostdesc.conflict40 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict92 eth_dest_addr; + struct mac_addr.conflict93 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict34 { + u32_l ready; + struct hostdesc.conflict40 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict46 hostdesc.conflict46, *Phostdesc.conflict46; + +typedef struct mac_addr.conflict105 mac_addr.conflict105, *Pmac_addr.conflict105; + +typedef struct mac_addr.conflict106 mac_addr.conflict106, *Pmac_addr.conflict106; + +struct mac_addr.conflict105 { + u8_l array[6]; +}; + +struct mac_addr.conflict106 { + u8_l array[6]; +}; + +struct hostdesc.conflict46 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict105 eth_dest_addr; + struct mac_addr.conflict106 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict43 hostdesc.conflict43, *Phostdesc.conflict43; + +typedef struct mac_addr.conflict98 mac_addr.conflict98, *Pmac_addr.conflict98; + +typedef struct mac_addr.conflict99 mac_addr.conflict99, *Pmac_addr.conflict99; + +struct mac_addr.conflict98 { + u8_l array[6]; +}; + +struct mac_addr.conflict99 { + u8_l array[6]; +}; + +struct hostdesc.conflict43 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict98 eth_dest_addr; + struct mac_addr.conflict99 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict44 hostdesc.conflict44, *Phostdesc.conflict44; + +typedef struct mac_addr.conflict100 mac_addr.conflict100, *Pmac_addr.conflict100; + +typedef struct mac_addr.conflict101 mac_addr.conflict101, *Pmac_addr.conflict101; + +struct mac_addr.conflict101 { + u8_l array[6]; +}; + +struct mac_addr.conflict100 { + u8_l array[6]; +}; + +struct hostdesc.conflict44 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict100 eth_dest_addr; + struct mac_addr.conflict101 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict41 hostdesc.conflict41, *Phostdesc.conflict41; + +typedef struct mac_addr.conflict94 mac_addr.conflict94, *Pmac_addr.conflict94; + +typedef struct mac_addr.conflict95 mac_addr.conflict95, *Pmac_addr.conflict95; + +struct mac_addr.conflict94 { + u8_l array[6]; +}; + +struct mac_addr.conflict95 { + u8_l array[6]; +}; + +struct hostdesc.conflict41 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict94 eth_dest_addr; + struct mac_addr.conflict95 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict42 hostdesc.conflict42, *Phostdesc.conflict42; + +typedef struct mac_addr.conflict96 mac_addr.conflict96, *Pmac_addr.conflict96; + +typedef struct mac_addr.conflict97 mac_addr.conflict97, *Pmac_addr.conflict97; + +struct mac_addr.conflict96 { + u8_l array[6]; +}; + +struct mac_addr.conflict97 { + u8_l array[6]; +}; + +struct hostdesc.conflict42 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict96 eth_dest_addr; + struct mac_addr.conflict97 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict35 txdesc_host.conflict35, *Ptxdesc_host.conflict35; + +struct txdesc_host.conflict35 { + u32_l ready; + struct hostdesc.conflict41 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict36 txdesc_host.conflict36, *Ptxdesc_host.conflict36; + +struct txdesc_host.conflict36 { + u32_l ready; + struct hostdesc.conflict46 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict37 txdesc_host.conflict37, *Ptxdesc_host.conflict37; + +struct txdesc_host.conflict37 { + u32_l ready; + struct hostdesc.conflict47 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict39 txdesc_host.conflict39, *Ptxdesc_host.conflict39; + +struct txdesc_host.conflict39 { + u32_l ready; + struct hostdesc.conflict49 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict19 ipc_shared_env_tag.conflict19, *Pipc_shared_env_tag.conflict19; + +struct ipc_shared_env_tag.conflict19 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict35 txdesc0[4]; +}; + +typedef struct hostdesc.conflict54 hostdesc.conflict54, *Phostdesc.conflict54; + +typedef struct mac_addr.conflict121 mac_addr.conflict121, *Pmac_addr.conflict121; + +typedef struct mac_addr.conflict122 mac_addr.conflict122, *Pmac_addr.conflict122; + +struct mac_addr.conflict122 { + u8_l array[6]; +}; + +struct mac_addr.conflict121 { + u8_l array[6]; +}; + +struct hostdesc.conflict54 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict121 eth_dest_addr; + struct mac_addr.conflict122 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict55 hostdesc.conflict55, *Phostdesc.conflict55; + +typedef struct mac_addr.conflict124 mac_addr.conflict124, *Pmac_addr.conflict124; + +typedef struct mac_addr.conflict125 mac_addr.conflict125, *Pmac_addr.conflict125; + +struct mac_addr.conflict125 { + u8_l array[6]; +}; + +struct mac_addr.conflict124 { + u8_l array[6]; +}; + +struct hostdesc.conflict55 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict124 eth_dest_addr; + struct mac_addr.conflict125 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict51 txdesc_host.conflict51, *Ptxdesc_host.conflict51; + +typedef struct hostdesc.conflict65 hostdesc.conflict65, *Phostdesc.conflict65; + +typedef struct mac_addr.conflict145 mac_addr.conflict145, *Pmac_addr.conflict145; + +typedef struct mac_addr.conflict146 mac_addr.conflict146, *Pmac_addr.conflict146; + +struct mac_addr.conflict146 { + u8_l array[6]; +}; + +struct mac_addr.conflict145 { + u8_l array[6]; +}; + +struct hostdesc.conflict65 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict145 eth_dest_addr; + struct mac_addr.conflict146 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict51 { + u32_l ready; + struct hostdesc.conflict65 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict53 hostdesc.conflict53, *Phostdesc.conflict53; + +typedef struct mac_addr.conflict119 mac_addr.conflict119, *Pmac_addr.conflict119; + +typedef struct mac_addr.conflict120 mac_addr.conflict120, *Pmac_addr.conflict120; + +struct mac_addr.conflict120 { + u8_l array[6]; +}; + +struct mac_addr.conflict119 { + u8_l array[6]; +}; + +struct hostdesc.conflict53 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict119 eth_dest_addr; + struct mac_addr.conflict120 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict52 txdesc_host.conflict52, *Ptxdesc_host.conflict52; + +typedef struct hostdesc.conflict66 hostdesc.conflict66, *Phostdesc.conflict66; + +typedef struct mac_addr.conflict147 mac_addr.conflict147, *Pmac_addr.conflict147; + +typedef struct mac_addr.conflict148 mac_addr.conflict148, *Pmac_addr.conflict148; + +struct mac_addr.conflict147 { + u8_l array[6]; +}; + +struct mac_addr.conflict148 { + u8_l array[6]; +}; + +struct hostdesc.conflict66 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict147 eth_dest_addr; + struct mac_addr.conflict148 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict52 { + u32_l ready; + struct hostdesc.conflict66 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict53 txdesc_host.conflict53, *Ptxdesc_host.conflict53; + +typedef struct hostdesc.conflict67 hostdesc.conflict67, *Phostdesc.conflict67; + +typedef struct mac_addr.conflict149 mac_addr.conflict149, *Pmac_addr.conflict149; + +typedef struct mac_addr.conflict150 mac_addr.conflict150, *Pmac_addr.conflict150; + +struct mac_addr.conflict150 { + u8_l array[6]; +}; + +struct mac_addr.conflict149 { + u8_l array[6]; +}; + +struct hostdesc.conflict67 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict149 eth_dest_addr; + struct mac_addr.conflict150 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict53 { + u32_l ready; + struct hostdesc.conflict67 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict69 hostdesc.conflict69, *Phostdesc.conflict69; + +typedef struct mac_addr.conflict154 mac_addr.conflict154, *Pmac_addr.conflict154; + +typedef struct mac_addr.conflict155 mac_addr.conflict155, *Pmac_addr.conflict155; + +struct mac_addr.conflict154 { + u8_l array[6]; +}; + +struct mac_addr.conflict155 { + u8_l array[6]; +}; + +struct hostdesc.conflict69 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict154 eth_dest_addr; + struct mac_addr.conflict155 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict54 txdesc_host.conflict54, *Ptxdesc_host.conflict54; + +typedef struct hostdesc.conflict68 hostdesc.conflict68, *Phostdesc.conflict68; + +typedef struct mac_addr.conflict151 mac_addr.conflict151, *Pmac_addr.conflict151; + +typedef struct mac_addr.conflict152 mac_addr.conflict152, *Pmac_addr.conflict152; + +struct mac_addr.conflict151 { + u8_l array[6]; +}; + +struct mac_addr.conflict152 { + u8_l array[6]; +}; + +struct hostdesc.conflict68 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict151 eth_dest_addr; + struct mac_addr.conflict152 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict54 { + u32_l ready; + struct hostdesc.conflict68 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict55 txdesc_host.conflict55, *Ptxdesc_host.conflict55; + +struct txdesc_host.conflict55 { + u32_l ready; + struct hostdesc.conflict70 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict56 txdesc_host.conflict56, *Ptxdesc_host.conflict56; + +struct txdesc_host.conflict56 { + u32_l ready; + struct hostdesc.conflict71 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict61 hostdesc.conflict61, *Phostdesc.conflict61; + +typedef struct mac_addr.conflict137 mac_addr.conflict137, *Pmac_addr.conflict137; + +typedef struct mac_addr.conflict138 mac_addr.conflict138, *Pmac_addr.conflict138; + +struct mac_addr.conflict137 { + u8_l array[6]; +}; + +struct mac_addr.conflict138 { + u8_l array[6]; +}; + +struct hostdesc.conflict61 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict137 eth_dest_addr; + struct mac_addr.conflict138 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict57 txdesc_host.conflict57, *Ptxdesc_host.conflict57; + +struct txdesc_host.conflict57 { + u32_l ready; + struct hostdesc.conflict72 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict58 txdesc_host.conflict58, *Ptxdesc_host.conflict58; + +struct txdesc_host.conflict58 { + u32_l ready; + struct hostdesc.conflict73 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict18 hostdesc.conflict18, *Phostdesc.conflict18; + +typedef struct mac_addr.conflict41 mac_addr.conflict41, *Pmac_addr.conflict41; + +typedef struct mac_addr.conflict42 mac_addr.conflict42, *Pmac_addr.conflict42; + +struct mac_addr.conflict42 { + u8_l array[6]; +}; + +struct mac_addr.conflict41 { + u8_l array[6]; +}; + +struct hostdesc.conflict18 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict41 eth_dest_addr; + struct mac_addr.conflict42 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict19 hostdesc.conflict19, *Phostdesc.conflict19; + +typedef struct mac_addr.conflict43 mac_addr.conflict43, *Pmac_addr.conflict43; + +typedef struct mac_addr.conflict44 mac_addr.conflict44, *Pmac_addr.conflict44; + +struct mac_addr.conflict44 { + u8_l array[6]; +}; + +struct mac_addr.conflict43 { + u8_l array[6]; +}; + +struct hostdesc.conflict19 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict43 eth_dest_addr; + struct mac_addr.conflict44 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict17 hostdesc.conflict17, *Phostdesc.conflict17; + +typedef struct mac_addr.conflict39 mac_addr.conflict39, *Pmac_addr.conflict39; + +typedef struct mac_addr.conflict40 mac_addr.conflict40, *Pmac_addr.conflict40; + +struct mac_addr.conflict39 { + u8_l array[6]; +}; + +struct mac_addr.conflict40 { + u8_l array[6]; +}; + +struct hostdesc.conflict17 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict39 eth_dest_addr; + struct mac_addr.conflict40 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict14 hostdesc.conflict14, *Phostdesc.conflict14; + +typedef struct mac_addr.conflict30 mac_addr.conflict30, *Pmac_addr.conflict30; + +typedef struct mac_addr.conflict31 mac_addr.conflict31, *Pmac_addr.conflict31; + +struct mac_addr.conflict30 { + u8_l array[6]; +}; + +struct mac_addr.conflict31 { + u8_l array[6]; +}; + +struct hostdesc.conflict14 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict30 eth_dest_addr; + struct mac_addr.conflict31 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct ipc_shared_env_tag.conflict22 ipc_shared_env_tag.conflict22, *Pipc_shared_env_tag.conflict22; + +struct ipc_shared_env_tag.conflict22 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict42 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict21 txdesc_host.conflict21, *Ptxdesc_host.conflict21; + +typedef struct hostdesc.conflict24 hostdesc.conflict24, *Phostdesc.conflict24; + +typedef struct mac_addr.conflict53 mac_addr.conflict53, *Pmac_addr.conflict53; + +typedef struct mac_addr.conflict54 mac_addr.conflict54, *Pmac_addr.conflict54; + +struct mac_addr.conflict54 { + u8_l array[6]; +}; + +struct mac_addr.conflict53 { + u8_l array[6]; +}; + +struct hostdesc.conflict24 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict53 eth_dest_addr; + struct mac_addr.conflict54 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict21 { + u32_l ready; + struct hostdesc.conflict24 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict22 txdesc_host.conflict22, *Ptxdesc_host.conflict22; + +typedef struct hostdesc.conflict26 hostdesc.conflict26, *Phostdesc.conflict26; + +typedef struct mac_addr.conflict61 mac_addr.conflict61, *Pmac_addr.conflict61; + +typedef struct mac_addr.conflict62 mac_addr.conflict62, *Pmac_addr.conflict62; + +struct mac_addr.conflict61 { + u8_l array[6]; +}; + +struct mac_addr.conflict62 { + u8_l array[6]; +}; + +struct hostdesc.conflict26 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict61 eth_dest_addr; + struct mac_addr.conflict62 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict22 { + u32_l ready; + struct hostdesc.conflict26 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict20 ipc_shared_env_tag.conflict20, *Pipc_shared_env_tag.conflict20; + +struct ipc_shared_env_tag.conflict20 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict38 txdesc0[4]; +}; + +typedef struct hostdesc.conflict13 hostdesc.conflict13, *Phostdesc.conflict13; + +typedef struct mac_addr.conflict28 mac_addr.conflict28, *Pmac_addr.conflict28; + +typedef struct mac_addr.conflict29 mac_addr.conflict29, *Pmac_addr.conflict29; + +struct mac_addr.conflict28 { + u8_l array[6]; +}; + +struct mac_addr.conflict29 { + u8_l array[6]; +}; + +struct hostdesc.conflict13 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict28 eth_dest_addr; + struct mac_addr.conflict29 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict23 txdesc_host.conflict23, *Ptxdesc_host.conflict23; + +typedef struct hostdesc.conflict27 hostdesc.conflict27, *Phostdesc.conflict27; + +typedef struct mac_addr.conflict63 mac_addr.conflict63, *Pmac_addr.conflict63; + +typedef struct mac_addr.conflict64 mac_addr.conflict64, *Pmac_addr.conflict64; + +struct mac_addr.conflict63 { + u8_l array[6]; +}; + +struct mac_addr.conflict64 { + u8_l array[6]; +}; + +struct hostdesc.conflict27 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict63 eth_dest_addr; + struct mac_addr.conflict64 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict23 { + u32_l ready; + struct hostdesc.conflict27 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_e2a_msg ipc_e2a_msg, *Pipc_e2a_msg; + +struct ipc_e2a_msg { + u16_l id; + u16_l dummy_dest_id; + u16_l dummy_src_id; + u16_l param_len; + u32_l param[245]; + u32_l pattern; +}; + +typedef struct txdesc_host.conflict24 txdesc_host.conflict24, *Ptxdesc_host.conflict24; + +typedef struct hostdesc.conflict28 hostdesc.conflict28, *Phostdesc.conflict28; + +typedef struct mac_addr.conflict65 mac_addr.conflict65, *Pmac_addr.conflict65; + +typedef struct mac_addr.conflict66 mac_addr.conflict66, *Pmac_addr.conflict66; + +struct mac_addr.conflict65 { + u8_l array[6]; +}; + +struct mac_addr.conflict66 { + u8_l array[6]; +}; + +struct hostdesc.conflict28 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict65 eth_dest_addr; + struct mac_addr.conflict66 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict24 { + u32_l ready; + struct hostdesc.conflict28 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict26 ipc_shared_env_tag.conflict26, *Pipc_shared_env_tag.conflict26; + +struct ipc_shared_env_tag.conflict26 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict54 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict25 ipc_shared_env_tag.conflict25, *Pipc_shared_env_tag.conflict25; + +struct ipc_shared_env_tag.conflict25 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict53 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict24 ipc_shared_env_tag.conflict24, *Pipc_shared_env_tag.conflict24; + +struct ipc_shared_env_tag.conflict24 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict50 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict23 ipc_shared_env_tag.conflict23, *Pipc_shared_env_tag.conflict23; + +struct ipc_shared_env_tag.conflict23 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict45 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict29 txdesc_host.conflict29, *Ptxdesc_host.conflict29; + +struct txdesc_host.conflict29 { + u32_l ready; + struct hostdesc.conflict35 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict29 ipc_shared_env_tag.conflict29, *Pipc_shared_env_tag.conflict29; + +struct ipc_shared_env_tag.conflict29 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict57 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict28 ipc_shared_env_tag.conflict28, *Pipc_shared_env_tag.conflict28; + +struct ipc_shared_env_tag.conflict28 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict8 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict27 ipc_shared_env_tag.conflict27, *Pipc_shared_env_tag.conflict27; + +struct ipc_shared_env_tag.conflict27 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict8 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict11 ipc_shared_env_tag.conflict11, *Pipc_shared_env_tag.conflict11; + +struct ipc_shared_env_tag.conflict11 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict21 txdesc0[4]; +}; + +typedef struct hostdesc.conflict25 hostdesc.conflict25, *Phostdesc.conflict25; + +typedef struct mac_addr.conflict59 mac_addr.conflict59, *Pmac_addr.conflict59; + +typedef struct mac_addr.conflict60 mac_addr.conflict60, *Pmac_addr.conflict60; + +struct mac_addr.conflict59 { + u8_l array[6]; +}; + +struct mac_addr.conflict60 { + u8_l array[6]; +}; + +struct hostdesc.conflict25 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict59 eth_dest_addr; + struct mac_addr.conflict60 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict11 txdesc_host.conflict11, *Ptxdesc_host.conflict11; + +struct txdesc_host.conflict11 { + u32_l ready; + struct hostdesc.conflict13 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict12 txdesc_host.conflict12, *Ptxdesc_host.conflict12; + +struct txdesc_host.conflict12 { + u32_l ready; + struct hostdesc.conflict14 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict21 hostdesc.conflict21, *Phostdesc.conflict21; + +typedef struct mac_addr.conflict47 mac_addr.conflict47, *Pmac_addr.conflict47; + +typedef struct mac_addr.conflict48 mac_addr.conflict48, *Pmac_addr.conflict48; + +struct mac_addr.conflict47 { + u8_l array[6]; +}; + +struct mac_addr.conflict48 { + u8_l array[6]; +}; + +struct hostdesc.conflict21 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict47 eth_dest_addr; + struct mac_addr.conflict48 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict22 hostdesc.conflict22, *Phostdesc.conflict22; + +typedef struct mac_addr.conflict49 mac_addr.conflict49, *Pmac_addr.conflict49; + +typedef struct mac_addr.conflict50 mac_addr.conflict50, *Pmac_addr.conflict50; + +struct mac_addr.conflict50 { + u8_l array[6]; +}; + +struct mac_addr.conflict49 { + u8_l array[6]; +}; + +struct hostdesc.conflict22 { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict49 eth_dest_addr; + struct mac_addr.conflict50 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict18 txdesc_host.conflict18, *Ptxdesc_host.conflict18; + +struct txdesc_host.conflict18 { + u32_l ready; + struct hostdesc.conflict21 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict15 ipc_shared_env_tag.conflict15, *Pipc_shared_env_tag.conflict15; + +struct ipc_shared_env_tag.conflict15 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict27 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict14 ipc_shared_env_tag.conflict14, *Pipc_shared_env_tag.conflict14; + +struct ipc_shared_env_tag.conflict14 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict24 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict15 txdesc_host.conflict15, *Ptxdesc_host.conflict15; + +struct txdesc_host.conflict15 { + u32_l ready; + struct hostdesc.conflict18 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict13 ipc_shared_env_tag.conflict13, *Pipc_shared_env_tag.conflict13; + +struct ipc_shared_env_tag.conflict13 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict8 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict16 txdesc_host.conflict16, *Ptxdesc_host.conflict16; + +struct txdesc_host.conflict16 { + u32_l ready; + struct hostdesc.conflict19 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict12 ipc_shared_env_tag.conflict12, *Pipc_shared_env_tag.conflict12; + +struct ipc_shared_env_tag.conflict12 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict8 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict18 ipc_shared_env_tag.conflict18, *Pipc_shared_env_tag.conflict18; + +struct ipc_shared_env_tag.conflict18 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict34 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict19 txdesc_host.conflict19, *Ptxdesc_host.conflict19; + +struct txdesc_host.conflict19 { + u32_l ready; + struct hostdesc.conflict22 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag.conflict17 ipc_shared_env_tag.conflict17, *Pipc_shared_env_tag.conflict17; + +struct ipc_shared_env_tag.conflict17 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict31 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict16 ipc_shared_env_tag.conflict16, *Pipc_shared_env_tag.conflict16; + +struct ipc_shared_env_tag.conflict16 { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host.conflict28 txdesc0[4]; +}; + +typedef struct txdesc_host.conflict txdesc_host.conflict, *Ptxdesc_host.conflict; + +struct txdesc_host.conflict { + u32_l ready; + struct hostdesc.conflict1 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct ipc_shared_env_tag ipc_shared_env_tag, *Pipc_shared_env_tag; + +typedef struct txdesc_host txdesc_host, *Ptxdesc_host; + +typedef struct hostdesc hostdesc, *Phostdesc; + +struct hostdesc { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr eth_dest_addr; + struct mac_addr eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host { + uint32_t ready; + struct hostdesc host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag { + struct ipc_a2e_msg msg_a2e_buf; + uint32_t pattern_addr; + struct txdesc_host txdesc0[4]; +}; + +typedef struct hostdesc.conflict hostdesc.conflict, *Phostdesc.conflict; + +typedef struct mac_addr.conflict1 mac_addr.conflict1, *Pmac_addr.conflict1; + +typedef struct mac_addr.conflict2 mac_addr.conflict2, *Pmac_addr.conflict2; + +struct mac_addr.conflict2 { + u8_l array[6]; +}; + +struct mac_addr.conflict1 { + u8_l array[6]; +}; + +struct hostdesc.conflict { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr.conflict1 eth_dest_addr; + struct mac_addr.conflict2 eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +typedef struct anon_struct.conflict414 anon_struct.conflict414, *Panon_struct.conflict414; + +struct anon_struct.conflict414 { + uint frac0:32; + uint frac1:20; + uint exp:11; + uint sign:1; +}; + +typedef union _FP_UNION_D _FP_UNION_D, *P_FP_UNION_D; + +typedef double DFtype; + +union _FP_UNION_D { + DFtype flt; + struct anon_struct.conflict414 bits; +}; + +typedef struct tcal_tag tcal_tag, *Ptcal_tag; + +struct tcal_tag { + int16_t prev_temperature; + undefined field_0x2; + undefined field_0x3; + uint32_t last_action_time[4]; + uint32_t last_action_temperature[4]; + int32_t last_action_out[4]; + _Bool enabled; + undefined field_0x35; + undefined field_0x36; + undefined field_0x37; +}; + +typedef union _reg_t _reg_t, *P_reg_t; + +union _reg_t { + uint8_t byte[4]; + uint32_t word; +}; + +typedef struct _romfs_file_buf _romfs_file_buf, *P_romfs_file_buf; + +struct _romfs_file_buf { + char * buf; + uint32_t bufsize; +}; + +typedef struct _romfs_file_buf romfs_filebuf_t; + +typedef struct BL_ENDECRYPT_t BL_ENDECRYPT_t, *PBL_ENDECRYPT_t; + +struct BL_ENDECRYPT_t { + UINT8 enDeAction; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + UINT8 * pData; +}; + +typedef struct sta_info_tag sta_info_tag, *Psta_info_tag; + +typedef enum sta_ps_traffic { + PS_TRAFFIC=3, + PS_TRAFFIC_HOST=1, + PS_TRAFFIC_INT=2, + UAPSD_TRAFFIC=12, + UAPSD_TRAFFIC_HOST=4, + UAPSD_TRAFFIC_INT=8 +} sta_ps_traffic; + +typedef int sta_ps_sp_t; + +typedef struct sta_mgmt_sec_info sta_mgmt_sec_info, *Psta_mgmt_sec_info; + +typedef struct mac_sta_info mac_sta_info, *Pmac_sta_info; + +typedef struct sta_pol_tbl_cntl sta_pol_tbl_cntl, *Psta_pol_tbl_cntl; + +typedef struct sta_mgmt_ba_info sta_mgmt_ba_info, *Psta_mgmt_ba_info; + +typedef struct co_list co_list, *Pco_list; + +typedef struct key_info_tag key_info_tag, *Pkey_info_tag; + +typedef struct mac_rateset mac_rateset, *Pmac_rateset; + +typedef struct mac_htcapability mac_htcapability, *Pmac_htcapability; + +typedef struct mac_vhtcapability mac_vhtcapability, *Pmac_vhtcapability; + +typedef struct txl_buffer_control txl_buffer_control, *Ptxl_buffer_control; + +typedef struct rc_sta_stats rc_sta_stats, *Prc_sta_stats; + +typedef ulonglong __uint64_t; + +typedef __uint64_t uint64_t; + + +// WARNING! conflicting data type names: /DWARF/mac.h/key_info_tag/anon_union_for_u - /DWARF/timers.c/tmrTimerQueueMessage/anon_union_for_u + +typedef union anon_union_for_field_0 anon_union_for_field_0, *Panon_union_for_field_0; + +typedef struct rc_rate_stats rc_rate_stats, *Prc_rate_stats; + +typedef struct step step, *Pstep; + +typedef union anon_union_for_rate_map anon_union_for_rate_map, *Panon_union_for_rate_map; + +typedef struct tx_policy_tbl tx_policy_tbl, *Ptx_policy_tbl; + +typedef struct tx_compressed_policy_tbl tx_compressed_policy_tbl, *Ptx_compressed_policy_tbl; + +struct sta_mgmt_ba_info { + uint32_t last_tx_time; + uint32_t last_ba_add_time; + uint8_t bam_idx_rx; + uint8_t bam_idx_tx; + int8_t credit_oft; + undefined field_0xb; +}; + +union anon_union_for_rate_map { + uint8_t ht[4]; +}; + +struct step { + uint32_t tp; + uint16_t idx; + undefined field_0x6; + undefined field_0x7; +}; + +struct rc_rate_stats { + uint16_t attempts; + uint16_t success; + uint16_t probability; + uint16_t rate_config; + uint8_t sample_skipped; + _Bool old_prob_available; + uint8_t n_retry; + _Bool rate_allowed; +}; + +struct rc_sta_stats { + uint32_t last_rc_time; + struct rc_rate_stats rate_stats[10]; + struct step retry[4]; + struct step max_tp_2_trial; + uint16_t ampdu_len; + uint16_t ampdu_packets; + uint32_t avg_ampdu_len; + uint8_t sample_wait; + uint8_t sample_slow; + uint8_t trial_status; + uint8_t info; + uint8_t sw_retry_step; + uint8_t format_mod; + union anon_union_for_rate_map rate_map; + uint16_t rate_map_l; + uint8_t mcs_max; + uint8_t r_idx_min; + uint8_t r_idx_max; + uint8_t bw_max; + uint8_t no_ss; + uint8_t short_gi; + uint8_t p_type; + undefined field_0xbf; + uint16_t no_samples; + uint16_t max_amsdu_len; + uint16_t curr_amsdu_len; + uint16_t fixed_rate_cfg; +}; + +struct sta_pol_tbl_cntl { + struct txl_buffer_control * buf_ctrl; + struct rc_sta_stats * sta_stats; + uint32_t prot_cfg; + uint16_t ppdu_tx_cfg; + uint8_t upd_field; + undefined field_0xf; +}; + +struct mac_rateset { + uint8_t length; + uint8_t array[12]; +}; + +struct key_info_tag { + uint64_t rx_pn[9]; + uint64_t tx_pn; + union anon_union_for_u u; + uint8_t cipher; + uint8_t key_idx; + uint8_t hw_key_idx; + _Bool valid; + undefined field_0x64; + undefined field_0x65; + undefined field_0x66; + undefined field_0x67; +}; + +struct sta_mgmt_sec_info { + struct key_info_tag key_info; + struct key_info_tag * pairwise_key; + struct key_info_tag * * cur_key; +}; + +struct co_list { + struct co_list_hdr * first; + struct co_list_hdr * last; +}; + +struct mac_vhtcapability { + uint32_t vht_capa_info; + uint16_t rx_mcs_map; + uint16_t rx_highest; + uint16_t tx_mcs_map; + uint16_t tx_highest; +}; + +struct mac_htcapability { + uint16_t ht_capa_info; + uint8_t a_mpdu_param; + uint8_t mcs_rate[16]; + undefined field_0x13; + uint16_t ht_extended_capa; + undefined field_0x16; + undefined field_0x17; + uint32_t tx_beamforming_capa; + uint8_t asel_capa; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +struct mac_sta_info { + struct mac_rateset rate_set; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + struct mac_htcapability ht_cap; + struct mac_vhtcapability vht_cap; + uint32_t capa_flags; + uint8_t phy_bw_max; + uint8_t bw_cur; + uint8_t uapsd_queues; + uint8_t max_sp_len; + uint8_t stbc_nss; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; +}; + +struct sta_info_tag { + struct co_list_hdr list_hdr; + uint32_t bcn_int; + uint32_t ampdu_size_max_vht; + uint16_t ampdu_size_max_ht; + undefined field_0xe; + undefined field_0xf; + uint32_t paid_gid; + uint8_t ampdu_spacing_min; + undefined field_0x15; + uint16_t drift; + uint16_t aid; + uint8_t inst_nbr; + uint8_t staid; + uint8_t ps_state; + _Bool valid; + struct mac_addr mac_addr; + int8_t rssi; + undefined field_0x25; + undefined field_0x26; + undefined field_0x27; + uint32_t tsflo; + uint32_t tsfhi; + uint8_t data_rate; + uint8_t ctrl_port_state; + enum sta_ps_traffic traffic_avail; + undefined field_0x33; + sta_ps_sp_t ps_service_period; + uint16_t ctrl_port_ethertype; + undefined field_0x3a; + undefined field_0x3b; + undefined field_0x3c; + undefined field_0x3d; + undefined field_0x3e; + undefined field_0x3f; + struct sta_mgmt_sec_info sta_sec_info; + struct mac_sta_info info; + uint16_t seq_nbr[9]; + undefined field_0x10a; + undefined field_0x10b; + struct sta_pol_tbl_cntl pol_tbl; + struct sta_mgmt_ba_info ba_info[9]; + uint16_t rx_nqos_last_seqcntl; + uint16_t rx_qos_last_seqcntl[9]; + struct co_list tx_desc_post; + void * suppData; + uint32_t time_last_seen; + undefined field_0x1ac; + undefined field_0x1ad; + undefined field_0x1ae; + undefined field_0x1af; +}; + +struct tx_policy_tbl { + uint32_t upatterntx; + uint32_t phycntrlinfo1; + uint32_t phycntrlinfo2; + uint32_t maccntrlinfo1; + uint32_t maccntrlinfo2; + uint32_t ratecntrlinfo[4]; + uint32_t powercntrlinfo[4]; +}; + +struct tx_compressed_policy_tbl { + uint32_t upatterntx; + uint32_t sec_user_control; +}; + +union anon_union_for_field_0 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +struct txl_buffer_control { + union anon_union_for_field_0 field_0; + uint32_t mac_control_info; + uint32_t phy_control_info; +}; + +typedef struct sta_info_env_tag sta_info_env_tag, *Psta_info_env_tag; + +struct sta_info_env_tag { + struct co_list free_sta_list; +}; + +typedef enum sta_mgmt_pol_upd { + STA_MGMT_POL_UPD_BW=3, + STA_MGMT_POL_UPD_MAX=5, + STA_MGMT_POL_UPD_PPDU_TX=2, + STA_MGMT_POL_UPD_PROT=1, + STA_MGMT_POL_UPD_RATE=0, + STA_MGMT_POL_UPD_TX_POWER=4 +} sta_mgmt_pol_upd; + +typedef enum sta_ps_sp { + ANY_SERVICE_PERIOD_INT=3, + BCN_SERVICE_PERIOD=8, + NO_SERVICE_PERIOD=0, + PS_SERVICE_PERIOD=1, + UAPSD_SERVICE_PERIOD=6, + UAPSD_SERVICE_PERIOD_HOST=4, + UAPSD_SERVICE_PERIOD_INT=2 +} sta_ps_sp; + +typedef struct machw_mib_tag machw_mib_tag, *Pmachw_mib_tag; + +struct machw_mib_tag { + uint32_t dot11_wep_excluded_count; + uint32_t dot11_fcs_error_count; + uint32_t nx_rx_phy_error_count; + uint32_t nx_rd_fifo_overflow_count; + uint32_t nx_tx_underun_count; + uint32_t reserved_1[7]; + uint32_t nx_qos_utransmitted_mpdu_count[8]; + uint32_t nx_qos_gtransmitted_mpdu_count[8]; + uint32_t dot11_qos_failed_count[8]; + uint32_t dot11_qos_retry_count[8]; + uint32_t dot11_qos_rts_success_count[8]; + uint32_t dot11_qos_rts_failure_count[8]; + uint32_t nx_qos_ack_failure_count[8]; + uint32_t nx_qos_ureceived_mpdu_count[8]; + uint32_t nx_qos_greceived_mpdu_count[8]; + uint32_t nx_qos_ureceived_other_mpdu[8]; + uint32_t dot11_qos_retries_received_count[8]; + uint32_t nx_utransmitted_amsdu_count[8]; + uint32_t nx_gtransmitted_amsdu_count[8]; + uint32_t dot11_failed_amsdu_count[8]; + uint32_t dot11_retry_amsdu_count[8]; + uint32_t dot11_transmitted_octets_in_amsdu[8]; + uint32_t dot11_amsdu_ack_failure_count[8]; + uint32_t nx_ureceived_amsdu_count[8]; + uint32_t nx_greceived_amsdu_count[8]; + uint32_t nx_ureceived_other_amsdu[8]; + uint32_t dot11_received_octets_in_amsdu_count[8]; + uint32_t reserved_2[24]; + uint32_t dot11_transmitted_ampdu_count; + uint32_t dot11_transmitted_mpdus_in_ampdu_count; + uint32_t dot11_transmitted_octets_in_ampdu_count; + uint32_t wnlu_ampdu_received_count; + uint32_t nx_gampdu_received_count; + uint32_t nx_other_ampdu_received_count; + uint32_t dot11_mpdu_in_received_ampdu_count; + uint32_t dot11_received_octets_in_ampdu_count; + uint32_t dot11_ampdu_delimiter_crc_error_count; + uint32_t dot11_implicit_bar_failure_count; + uint32_t dot11_explicit_bar_failure_count; + uint32_t reserved_3[5]; + uint32_t dot11_20mhz_frame_transmitted_count; + uint32_t dot11_40mhz_frame_transmitted_count; + uint32_t dot11_20mhz_frame_received_count; + uint32_t dot11_40mhz_frame_received_count; + uint32_t nx_failed_40mhz_txop; + uint32_t nx_successful_txops; + uint32_t reserved_4[4]; + uint32_t dot11_dualcts_success_count; + uint32_t dot11_stbc_cts_success_count; + uint32_t dot11_stbc_cts_failure_count; + uint32_t dot11_non_stbc_cts_success_count; + uint32_t dot11_non_stbc_cts_failure_count; +}; + +typedef struct scan_probe_req_ie_tag scan_probe_req_ie_tag, *Pscan_probe_req_ie_tag; + +typedef struct tx_pbd tx_pbd, *Ptx_pbd; + +struct tx_pbd { + uint32_t upatterntx; + uint32_t next; + uint32_t datastartptr; + uint32_t dataendptr; + uint32_t bufctrlinfo; +}; + +struct scan_probe_req_ie_tag { + struct dma_desc dma_desc; + struct tx_pbd pbd; + uint32_t buf[50]; +}; + +typedef struct scan_env_tag scan_env_tag, *Pscan_env_tag; + +typedef struct scan_start_req scan_start_req, *Pscan_start_req; + +struct scan_start_req { + struct scan_chan_tag chan[42]; + struct mac_ssid ssid[2]; + struct mac_addr bssid; + undefined field_0x146; + undefined field_0x147; + uint32_t add_ies; + uint16_t add_ie_len; + uint8_t vif_idx; + uint8_t chan_cnt; + uint8_t ssid_cnt; + _Bool no_cck; + undefined field_0x152; + undefined field_0x153; +}; + +struct scan_env_tag { + struct hal_dma_desc_tag dma_desc; + struct scan_start_req * param; + uint32_t ds_ie; + ke_task_id_t req_id; + uint8_t chan_idx; + _Bool abort; +}; + +typedef struct SEC_Eng_SHA_Link_Config_Type SEC_Eng_SHA_Link_Config_Type, *PSEC_Eng_SHA_Link_Config_Type; + +struct SEC_Eng_SHA_Link_Config_Type { + uint32_t shaMode:3; + uint32_t shaHashSel:1; + uint32_t shaIntClr:1; + uint32_t shaIntSet:1; + uint32_t shaMsgLen:16; + uint32_t shaSrcAddr; + uint32_t result[8]; +}; + +typedef struct SEC_Eng_SHA256_Ctx SEC_Eng_SHA256_Ctx, *PSEC_Eng_SHA256_Ctx; + +struct SEC_Eng_SHA256_Ctx { + uint32_t total[2]; + uint32_t * shaBuf; + uint32_t * shaPadding; + uint8_t shaFeed; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct SEC_Eng_AES_Link_Config_Type.conflict SEC_Eng_AES_Link_Config_Type.conflict, *PSEC_Eng_AES_Link_Config_Type.conflict; + +struct SEC_Eng_AES_Link_Config_Type.conflict { + uint32_t aesMode:2; + uint32_t aesDecEn:1; + uint32_t aesDecKeySel:1; + uint32_t aesHwKeyEn:1; + uint32_t aesIntClr:1; + uint32_t aesIntSet:1; + uint32_t aesBlockMode:2; + uint32_t aesIVSel:1; + uint32_t aesMsgLen:16; + uint32_t aesSrcAddr; + uint32_t aesDstAddr; + uint32_t aesIV0; + uint32_t aesIV1; + uint32_t aesIV2; + uint32_t aesIV3; + uint32_t aesKey0; + uint32_t aesKey1; + uint32_t aesKey2; + uint32_t aesKey3; + uint32_t aesKey4; + uint32_t aesKey5; + uint32_t aesKey6; + uint32_t aesKey7; +}; + +typedef struct SEC_Eng_AES_Link_Config_Type.conflict1 SEC_Eng_AES_Link_Config_Type.conflict1, *PSEC_Eng_AES_Link_Config_Type.conflict1; + +struct SEC_Eng_AES_Link_Config_Type.conflict1 { + uint32_t aesMode:2; + uint32_t aesDecEn:1; + uint32_t aesDecKeySel:1; + uint32_t aesHwKeyEn:1; + uint32_t aesIntClr:1; + uint32_t aesIntSet:1; + uint32_t aesBlockMode:2; + uint32_t aesIVSel:1; + uint32_t aesMsgLen:16; + uint32_t aesSrcAddr; + uint32_t aesDstAddr; + uint32_t aesIV0; + uint32_t aesIV1; + uint32_t aesIV2; + uint32_t aesIV3; + uint32_t aesKey0; + uint32_t aesKey1; + uint32_t aesKey2; + uint32_t aesKey3; + uint32_t aesKey4; + uint32_t aesKey5; + uint32_t aesKey6; + uint32_t aesKey7; +}; + +typedef struct SEC_Eng_AES_Ctx SEC_Eng_AES_Ctx, *PSEC_Eng_AES_Ctx; + +typedef enum SEC_ENG_AES_Type { + SEC_ENG_AES_CBC=2, + SEC_ENG_AES_CTR=1, + SEC_ENG_AES_ECB=0 +} SEC_ENG_AES_Type; + +struct SEC_Eng_AES_Ctx { + uint8_t aesFeed; + enum SEC_ENG_AES_Type mode; +}; + +typedef enum SEC_ENG_AES_EnDec_Type { + SEC_ENG_AES_DECRYPTION=1, + SEC_ENG_AES_ENCRYPTION=0 +} SEC_ENG_AES_EnDec_Type; + +typedef struct SEC_Eng_SHA_Link_Config_Type.conflict2 SEC_Eng_SHA_Link_Config_Type.conflict2, *PSEC_Eng_SHA_Link_Config_Type.conflict2; + +struct SEC_Eng_SHA_Link_Config_Type.conflict2 { + uint32_t shaMode:3; + uint32_t shaHashSel:1; + uint32_t shaIntClr:1; + uint32_t shaIntSet:1; + uint32_t shaMsgLen:16; + uint32_t shaSrcAddr; + uint32_t result[8]; +}; + +typedef struct SEC_Eng_SHA_Link_Config_Type.conflict1 SEC_Eng_SHA_Link_Config_Type.conflict1, *PSEC_Eng_SHA_Link_Config_Type.conflict1; + +struct SEC_Eng_SHA_Link_Config_Type.conflict1 { + uint32_t shaMode:3; + uint32_t shaHashSel:1; + uint32_t shaIntClr:1; + uint32_t shaIntSet:1; + uint32_t shaMsgLen:16; + uint32_t shaSrcAddr; + uint32_t result[8]; +}; + +typedef enum SEC_ENG_PKA_REG_SIZE_Type { + SEC_ENG_PKA_REG_SIZE_128=6, + SEC_ENG_PKA_REG_SIZE_16=2, + SEC_ENG_PKA_REG_SIZE_192=7, + SEC_ENG_PKA_REG_SIZE_256=8, + SEC_ENG_PKA_REG_SIZE_32=3, + SEC_ENG_PKA_REG_SIZE_384=9, + SEC_ENG_PKA_REG_SIZE_512=10, + SEC_ENG_PKA_REG_SIZE_64=4, + SEC_ENG_PKA_REG_SIZE_8=1, + SEC_ENG_PKA_REG_SIZE_96=5 +} SEC_ENG_PKA_REG_SIZE_Type; + +typedef enum SEC_ENG_AES_ID_Type { + SEC_ENG_AES_ID0=0 +} SEC_ENG_AES_ID_Type; + +typedef struct SEC_Eng_SHA256_Link_Ctx SEC_Eng_SHA256_Link_Ctx, *PSEC_Eng_SHA256_Link_Ctx; + +struct SEC_Eng_SHA256_Link_Ctx { + uint32_t total[2]; + uint32_t * shaBuf; + uint32_t * shaPadding; + uint32_t linkAddr; +}; + +typedef enum SEC_ENG_AES_Key_Type { + SEC_ENG_AES_DOUBLE_KEY_128BITS=3, + SEC_ENG_AES_KEY_128BITS=0, + SEC_ENG_AES_KEY_192BITS=2, + SEC_ENG_AES_KEY_256BITS=1 +} SEC_ENG_AES_Key_Type; + +typedef struct SEC_Eng_SHA_Link_Config_Type.conflict SEC_Eng_SHA_Link_Config_Type.conflict, *PSEC_Eng_SHA_Link_Config_Type.conflict; + +struct SEC_Eng_SHA_Link_Config_Type.conflict { + uint32_t shaMode:3; + uint32_t shaHashSel:1; + uint32_t shaIntClr:1; + uint32_t shaIntSet:1; + uint32_t shaMsgLen:16; + uint32_t shaSrcAddr; + uint32_t result[8]; +}; + +typedef enum SEC_ENG_SHA_Type { + SEC_ENG_SHA1=2, + SEC_ENG_SHA1_RSVD=3, + SEC_ENG_SHA224=1, + SEC_ENG_SHA256=0 +} SEC_ENG_SHA_Type; + +typedef enum SEC_ENG_PKA_OP_Type { + SEC_ENG_PKA_OP_CFLIRI_BUFFER=54, + SEC_ENG_PKA_OP_CFLIR_BUFFER=56, + SEC_ENG_PKA_OP_CLIR=53, + SEC_ENG_PKA_OP_CTLIRI_PLD=55, + SEC_ENG_PKA_OP_CTLIR_PLD=57, + SEC_ENG_PKA_OP_LADD=24, + SEC_ENG_PKA_OP_LCMP=25, + SEC_ENG_PKA_OP_LDIV=20, + SEC_ENG_PKA_OP_LDIV2N=18, + SEC_ENG_PKA_OP_LMUL=22, + SEC_ENG_PKA_OP_LMUL2N=19, + SEC_ENG_PKA_OP_LSQR=21, + SEC_ENG_PKA_OP_LSUB=23, + SEC_ENG_PKA_OP_MADD=40, + SEC_ENG_PKA_OP_MDIV2=33, + SEC_ENG_PKA_OP_MEXP=35, + SEC_ENG_PKA_OP_MINV=34, + SEC_ENG_PKA_OP_MMUL=37, + SEC_ENG_PKA_OP_MOD2N=17, + SEC_ENG_PKA_OP_MOVDAT=50, + SEC_ENG_PKA_OP_MREM=38, + SEC_ENG_PKA_OP_MSQR=36, + SEC_ENG_PKA_OP_MSUB=39, + SEC_ENG_PKA_OP_NLIR=51, + SEC_ENG_PKA_OP_PPSEL=0, + SEC_ENG_PKA_OP_RESIZE=49, + SEC_ENG_PKA_OP_SLIR=52 +} SEC_ENG_PKA_OP_Type; + +typedef enum SEC_ENG_AES_Key_Src_Type { + SEC_ENG_AES_KEY_HW=1, + SEC_ENG_AES_KEY_SW=0 +} SEC_ENG_AES_Key_Src_Type; + +typedef enum SEC_ENG_SHA_ID_Type { + SEC_ENG_SHA_ID0=0 +} SEC_ENG_SHA_ID_Type; + +typedef enum SEC_ENG_AES_Counter_Type { + SEC_ENG_AES_COUNTER_BYTE_1=1, + SEC_ENG_AES_COUNTER_BYTE_2=2, + SEC_ENG_AES_COUNTER_BYTE_3=3, + SEC_ENG_AES_COUNTER_BYTE_4=0 +} SEC_ENG_AES_Counter_Type; + +typedef struct SEC_Eng_AES_Link_Config_Type SEC_Eng_AES_Link_Config_Type, *PSEC_Eng_AES_Link_Config_Type; + +struct SEC_Eng_AES_Link_Config_Type { + uint32_t aesMode:2; + uint32_t aesDecEn:1; + uint32_t aesDecKeySel:1; + uint32_t aesHwKeyEn:1; + uint32_t aesIntClr:1; + uint32_t aesIntSet:1; + uint32_t aesBlockMode:2; + uint32_t aesIVSel:1; + uint32_t aesMsgLen:16; + uint32_t aesSrcAddr; + uint32_t aesDstAddr; + uint32_t aesIV0; + uint32_t aesIV1; + uint32_t aesIV2; + uint32_t aesIV3; + uint32_t aesKey0; + uint32_t aesKey1; + uint32_t aesKey2; + uint32_t aesKey3; + uint32_t aesKey4; + uint32_t aesKey5; + uint32_t aesKey6; + uint32_t aesKey7; +}; + +typedef enum SEC_ENG_INT_Type { + SEC_ENG_INT_AES=1, + SEC_ENG_INT_ALL=6, + SEC_ENG_INT_CDET=4, + SEC_ENG_INT_GMAC=5, + SEC_ENG_INT_PKA=3, + SEC_ENG_INT_SHA=2, + SEC_ENG_INT_TRNG=0 +} SEC_ENG_INT_Type; + +typedef struct ip4_addr ip4_addr, *Pip4_addr; + +typedef struct ip4_addr ip4_addr_t; + +typedef ip4_addr_t ip_addr_t; + +typedef uint32_t u32_t; + +struct ip4_addr { + u32_t addr; +}; + +typedef enum lwip_ip_addr_type { + IPADDR_TYPE_ANY=46, + IPADDR_TYPE_V4=0, + IPADDR_TYPE_V6=6 +} lwip_ip_addr_type; + +typedef struct pka0_bit_shift_op_cfg pka0_bit_shift_op_cfg, *Ppka0_bit_shift_op_cfg; + +typedef union anon_union_for_value anon_union_for_value, *Panon_union_for_value; + +typedef struct anon_struct.conflict411 anon_struct.conflict411, *Panon_struct.conflict411; + +struct anon_struct.conflict411 { + uint32_t bit_shift:15; + uint32_t reserved_24_31:17; +}; + +union anon_union_for_value { + struct anon_struct.conflict411 BF; + uint32_t WORD; +}; + +struct pka0_bit_shift_op_cfg { + union anon_union_for_value value; +}; + +typedef struct pka0_common_op_first_cfg pka0_common_op_first_cfg, *Ppka0_common_op_first_cfg; + + +// WARNING! conflicting data type names: /DWARF/bl602_sec_eng.c/pka0_common_op_first_cfg/anon_union_for_value - /DWARF/bl602_sec_eng.c/pka0_bit_shift_op_cfg/anon_union_for_value + +struct pka0_common_op_first_cfg { + union anon_union_for_value value; +}; + +typedef struct pka0_pld_cfg pka0_pld_cfg, *Ppka0_pld_cfg; + + +// WARNING! conflicting data type names: /DWARF/bl602_sec_eng.c/pka0_pld_cfg/anon_union_for_value - /DWARF/bl602_sec_eng.c/pka0_bit_shift_op_cfg/anon_union_for_value + +struct pka0_pld_cfg { + union anon_union_for_value value; +}; + +typedef struct pka0_common_op_snd_cfg_S1_only pka0_common_op_snd_cfg_S1_only, *Ppka0_common_op_snd_cfg_S1_only; + + +// WARNING! conflicting data type names: /DWARF/bl602_sec_eng.c/pka0_common_op_snd_cfg_S1_only/anon_union_for_value - /DWARF/bl602_sec_eng.c/pka0_bit_shift_op_cfg/anon_union_for_value + +struct pka0_common_op_snd_cfg_S1_only { + union anon_union_for_value value; +}; + +typedef struct anon_struct.conflict408 anon_struct.conflict408, *Panon_struct.conflict408; + +struct anon_struct.conflict408 { + uint32_t reserved_0_11:12; + uint32_t s1_reg_idx:8; + uint32_t s1_reg_type:4; + uint32_t reserved_24_31:8; +}; + +typedef struct anon_struct.conflict409 anon_struct.conflict409, *Panon_struct.conflict409; + +struct anon_struct.conflict409 { + uint32_t s2_reg_idx:8; + uint32_t s2_reg_type:4; + uint32_t reserved_12_31:20; +}; + +typedef struct anon_struct.conflict405 anon_struct.conflict405, *Panon_struct.conflict405; + +struct anon_struct.conflict405 { + uint32_t size:12; + uint32_t d_reg_index:8; + uint32_t d_reg_type:4; + uint32_t op:7; + uint32_t last_op:1; +}; + +typedef struct anon_struct.conflict406 anon_struct.conflict406, *Panon_struct.conflict406; + +struct anon_struct.conflict406 { + uint32_t rsvd:12; + uint32_t d_reg_index:8; + uint32_t d_reg_type:4; + uint32_t op:7; + uint32_t last_op:1; +}; + +typedef struct anon_struct.conflict407 anon_struct.conflict407, *Panon_struct.conflict407; + +struct anon_struct.conflict407 { + uint32_t s0_reg_idx:8; + uint32_t s0_reg_type:4; + uint32_t d_reg_idx:8; + uint32_t d_reg_type:4; + uint32_t op:7; + uint32_t last_op:1; +}; + +typedef struct anon_struct.conflict410 anon_struct.conflict410, *Panon_struct.conflict410; + +struct anon_struct.conflict410 { + uint32_t s2_reg_idx:8; + uint32_t s2_reg_type:4; + uint32_t s1_reg_idx:8; + uint32_t s1_reg_type:4; + uint32_t reserved_24_31:8; +}; + +typedef struct pka0_pldi_cfg pka0_pldi_cfg, *Ppka0_pldi_cfg; + + +// WARNING! conflicting data type names: /DWARF/bl602_sec_eng.c/pka0_pldi_cfg/anon_union_for_value - /DWARF/bl602_sec_eng.c/pka0_bit_shift_op_cfg/anon_union_for_value + +struct pka0_pldi_cfg { + union anon_union_for_value value; +}; + +typedef struct pka0_common_op_snd_cfg_S2_only pka0_common_op_snd_cfg_S2_only, *Ppka0_common_op_snd_cfg_S2_only; + + +// WARNING! conflicting data type names: /DWARF/bl602_sec_eng.c/pka0_common_op_snd_cfg_S2_only/anon_union_for_value - /DWARF/bl602_sec_eng.c/pka0_bit_shift_op_cfg/anon_union_for_value + +struct pka0_common_op_snd_cfg_S2_only { + union anon_union_for_value value; +}; + +typedef struct pka0_common_op_snd_cfg_S1_S2 pka0_common_op_snd_cfg_S1_S2, *Ppka0_common_op_snd_cfg_S1_S2; + + +// WARNING! conflicting data type names: /DWARF/bl602_sec_eng.c/pka0_common_op_snd_cfg_S1_S2/anon_union_for_value - /DWARF/bl602_sec_eng.c/pka0_bit_shift_op_cfg/anon_union_for_value + +struct pka0_common_op_snd_cfg_S1_S2 { + union anon_union_for_value value; +}; + +typedef struct _ef_env _ef_env, *P_ef_env; + +typedef struct _ef_env ef_env; + +struct _ef_env { + char * key; + void * value; + size_t value_len; +}; + +typedef enum env_status { + ENV_DELETED=4, + ENV_ERR_HDR=5, + ENV_PRE_DELETE=3, + ENV_PRE_WRITE=1, + ENV_STATUS_NUM=6, + ENV_UNUSED=0, + ENV_WRITE=2 +} env_status; + +typedef enum env_status env_status_t; + +typedef enum EfErrCode { + EF_ENV_ARG_ERR=8, + EF_ENV_FULL=6, + EF_ENV_INIT_FAILED=7, + EF_ENV_NAME_ERR=4, + EF_ENV_NAME_EXIST=5, + EF_ERASE_ERR=1, + EF_NO_ERR=0, + EF_READ_ERR=2, + EF_WRITE_ERR=3 +} EfErrCode; + +typedef struct anon_struct.conflict368 anon_struct.conflict368, *Panon_struct.conflict368; + +struct anon_struct.conflict368 { + uint32_t start; + uint32_t value; +}; + +typedef struct env_node_obj env_node_obj, *Penv_node_obj; + +typedef struct anon_struct_for_addr anon_struct_for_addr, *Panon_struct_for_addr; + +struct anon_struct_for_addr { + uint32_t start; + uint32_t value; +}; + +struct env_node_obj { + env_status_t status; + _Bool crc_is_ok; + uint8_t name_len; + undefined field_0x3; + uint32_t magic; + uint32_t len; + uint32_t value_len; + char name[64]; + struct anon_struct_for_addr addr; +}; + +typedef struct env_node_obj * env_node_obj_t; + +typedef struct dbg_mem_write_req dbg_mem_write_req, *Pdbg_mem_write_req; + +struct dbg_mem_write_req { + uint32_t memaddr; + uint32_t memdata; +}; + +typedef struct dbg_set_sev_filter_req dbg_set_sev_filter_req, *Pdbg_set_sev_filter_req; + +struct dbg_set_sev_filter_req { + uint32_t sev_filter; +}; + +typedef struct dbg_mem_read_req dbg_mem_read_req, *Pdbg_mem_read_req; + +struct dbg_mem_read_req { + uint32_t memaddr; +}; + +typedef struct dbg_mem_write_cfm dbg_mem_write_cfm, *Pdbg_mem_write_cfm; + +struct dbg_mem_write_cfm { + uint32_t memaddr; + uint32_t memdata; +}; + +typedef struct dbg_get_sys_stat_cfm dbg_get_sys_stat_cfm, *Pdbg_get_sys_stat_cfm; + +struct dbg_get_sys_stat_cfm { + uint32_t cpu_sleep_time; + uint32_t doze_time; + uint32_t stats_time; +}; + +typedef struct dbg_mem_read_cfm dbg_mem_read_cfm, *Pdbg_mem_read_cfm; + +struct dbg_mem_read_cfm { + uint32_t memaddr; + uint32_t memdata; +}; + +typedef struct dbg_set_mod_filter_req dbg_set_mod_filter_req, *Pdbg_set_mod_filter_req; + +struct dbg_set_mod_filter_req { + uint32_t mod_filter; +}; + +typedef enum dbg_msg_tag { + DBG_ERROR_IND=1032, + DBG_GET_SYS_STAT_CFM=1034, + DBG_GET_SYS_STAT_REQ=1033, + DBG_MAX=1035, + DBG_MEM_READ_CFM=1025, + DBG_MEM_READ_REQ=1024, + DBG_MEM_WRITE_CFM=1027, + DBG_MEM_WRITE_REQ=1026, + DBG_SET_MOD_FILTER_CFM=1029, + DBG_SET_MOD_FILTER_REQ=1028, + DBG_SET_SEV_FILTER_CFM=1031, + DBG_SET_SEV_FILTER_REQ=1030, + DBG_SYS_STAT_TIMER=1035 +} dbg_msg_tag; + +typedef struct mbedtls_pk_rsassa_pss_options mbedtls_pk_rsassa_pss_options, *Pmbedtls_pk_rsassa_pss_options; + +struct mbedtls_pk_rsassa_pss_options { + enum mbedtls_md_type_t mgf1_hash_id; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + int expected_salt_len; +}; + +typedef uint32_t u32.conflict18; + +typedef uint32_t u32.conflict17; + +typedef uint32_t u32.conflict23; + +typedef uint32_t u32.conflict6; + +typedef uint32_t u32.conflict22; + +typedef uint32_t u32.conflict26; + +typedef uint32_t u32.conflict270; + +typedef uint32_t u32.conflict21; + +typedef uint32_t u32.conflict20; + +typedef uint32_t u32.conflict25; + +typedef uint32_t u32.conflict; + +typedef uint32_t u32.conflict24; + +typedef uint32_t u32.conflict177; + +typedef uint32_t u32.conflict54; + +typedef uint32_t u32.conflict268; + +typedef uint32_t u32.conflict269; + +typedef uint32_t u32.conflict36; + +typedef uint32_t u32.conflict35; + +typedef uint64_t __le64; + +typedef uint32_t u32.conflict267; + +typedef uint32_t u32.conflict41; + +typedef uint32_t u32.conflict46; + +typedef uint32_t u32.conflict7; + +typedef uint32_t u32.conflict5; + +typedef uint32_t u32.conflict53; + +typedef uint32_t u32.conflict52; + +typedef uint32_t u32.conflict51; + +typedef uint32_t u32.conflict3; + +typedef uint32_t u32.conflict2; + +typedef uint32_t u32.conflict191; + +typedef uint32_t u32.conflict186; + +typedef _Bool bool_l; + +typedef int8_t s8_l; + +typedef uint32_t u32.conflict196; + +typedef struct work work, *Pwork; + +struct work { + void (* fn)(void *); + void * arg; + int dly; +}; + +typedef struct targ targ, *Ptarg; + +typedef struct AosStaticTask_t AosStaticTask_t, *PAosStaticTask_t; + +typedef struct xSTATIC_TCB xSTATIC_TCB, *PxSTATIC_TCB; + +typedef struct xSTATIC_TCB StaticTask_t; + +typedef struct xSTATIC_LIST_ITEM xSTATIC_LIST_ITEM, *PxSTATIC_LIST_ITEM; + +typedef struct xSTATIC_LIST_ITEM StaticListItem_t; + +struct xSTATIC_LIST_ITEM { + TickType_t xDummy2; + void * pvDummy3[4]; +}; + +struct xSTATIC_TCB { + void * pxDummy1; + StaticListItem_t xDummy3[2]; + UBaseType_t uxDummy5; + void * pxDummy6; + uint8_t ucDummy7[16]; + UBaseType_t uxDummy9; + UBaseType_t uxDummy10[2]; + UBaseType_t uxDummy12[2]; + uint32_t ulDummy18; + uint8_t ucDummy19; + uint8_t uxDummy20; + undefined field_0x5e; + undefined field_0x5f; +}; + +struct targ { + struct AosStaticTask_t * task; + void (* fn)(void *); + void * arg; +}; + +struct AosStaticTask_t { + StaticTask_t fTask; + uint32_t key_bitmap; + void * keys[4]; + void * stack; + char name[32]; + uint32_t magic; +}; + +typedef struct mbedtls_gcm_context mbedtls_gcm_context, *Pmbedtls_gcm_context; + +struct mbedtls_gcm_context { + struct mbedtls_cipher_context_t cipher_ctx; + uint64_t HL[16]; + uint64_t HH[16]; + uint64_t len; + uint64_t add_len; + uchar base_ectr[16]; + uchar y[16]; + uchar buf[16]; + int mode; + undefined field_0x184; + undefined field_0x185; + undefined field_0x186; + undefined field_0x187; +}; + +typedef int _ssize_t; + +typedef _ssize_t ssize_t; + +typedef __blkcnt_t blkcnt_t; + + +// WARNING! conflicting data type names: /DWARF/_types.h/__mode_t - /types.h/__mode_t + +typedef __mode_t mode_t; + +typedef ushort __uint16_t; + +typedef __uint16_t in_port_t; + + +// WARNING! conflicting data type names: /DWARF/_types.h/__ino_t - /types.h/__ino_t + +typedef __ino_t ino_t; + + +// WARNING! conflicting data type names: /DWARF/_types.h/__uid_t - /types.h/__uid_t + +typedef __uid_t uid_t; + + +// WARNING! conflicting data type names: /DWARF/_types.h/__off_t - /types.h/__off_t + +typedef __off_t off_t; + + +// WARNING! conflicting data type names: /DWARF/_types.h/__nlink_t - /types.h/__nlink_t + +typedef __nlink_t nlink_t; + + +// WARNING! conflicting data type names: /DWARF/_types.h/__gid_t - /types.h/__gid_t + +typedef __gid_t gid_t; + +typedef ulong __uint32_t; + +typedef __uint32_t in_addr_t; + + +// WARNING! conflicting data type names: /DWARF/_types.h/__dev_t - /types.h/__dev_t + +typedef __dev_t dev_t; + +typedef __blksize_t blksize_t; + +typedef struct netbuf netbuf, *Pnetbuf; + +typedef struct pbuf pbuf, *Ppbuf; + +typedef uint8_t u8_t; + +struct netbuf { + struct pbuf * p; + struct pbuf * ptr; + ip_addr_t addr; + u16_t port; + u8_t flags; + undefined field_0xf; + u16_t toport_chksum; + undefined field_0x12; + undefined field_0x13; +}; + +struct pbuf { + struct pbuf * next; + void * payload; + u16_t tot_len; + u16_t len; + u8_t type_internal; + u8_t flags; + u8_t ref; + u8_t if_idx; +}; + +typedef struct txl_list txl_list, *Ptxl_list; + +typedef struct tx_hd tx_hd, *Ptx_hd; + +typedef union anon_union_for_field_3 anon_union_for_field_3, *Panon_union_for_field_3; + +typedef union anon_union_for_field_4 anon_union_for_field_4, *Panon_union_for_field_4; + +typedef union anon_union_for_field_5 anon_union_for_field_5, *Panon_union_for_field_5; + +union anon_union_for_field_3 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +union anon_union_for_field_4 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +union anon_union_for_field_5 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +struct tx_hd { + uint32_t upatterntx; + uint32_t nextfrmexseq_ptr; + uint32_t nextmpdudesc_ptr; + union anon_union_for_field_3 field_3; + union anon_union_for_field_4 field_4; + union anon_union_for_field_5 field_5; + uint32_t frmlen; + uint32_t frmlifetime; + uint32_t phyctrlinfo; + uint32_t policyentryaddr; + uint32_t optlen[3]; + uint32_t macctrlinfo1; + uint32_t macctrlinfo2; + uint32_t statinfo; + uint32_t mediumtimeused; +}; + +struct txl_list { + struct tx_hd * last_frame_exch; + struct co_list transmitting; + uint16_t bridgedmacnt; + uint8_t chk_state; + undefined field_0xf; +}; + +typedef struct txl_cntrl_env_tag txl_cntrl_env_tag, *Ptxl_cntrl_env_tag; + +struct txl_cntrl_env_tag { + struct txl_list txlist[5]; + uint32_t pck_cnt; + uint16_t seqnbr; + _Bool reset; + undefined field_0x57; +}; + +typedef struct ipc_emb_env_tag ipc_emb_env_tag, *Pipc_emb_env_tag; + +struct ipc_emb_env_tag { + struct co_list rx_queue; + struct co_list cfm_queue; + uint8_t ipc_rxdesc_idx; + uint8_t ipc_rxbuf_idx; + uint8_t ipc_radar_buf_idx; + uint8_t ipc_msge2a_buf_idx; + uint8_t ipc_dbg_buf_idx; + uint8_t ipc_msgacke2a_cnt; + undefined field_0x16; + undefined field_0x17; + uint32_t txdesc_idx; + struct txdesc_host * txdesc; +}; + +typedef struct romapi_freertos_map romapi_freertos_map, *Promapi_freertos_map; + +struct romapi_freertos_map { + void * vApplicationIdleHook; + void * interrupt_entry_ptr; + void * vApplicationGetIdleTaskMemory; + void * vApplicationStackOverflowHook; + void * vApplicationGetTimerTaskMemory; + void * rtos_sprintf; + void * vApplicationMallocFailedHook; + void * rtos_memcpy_ptr; + void * vAssertCalled; + void * rtos_strlen_ptr; + void * rtos_memset_ptr; + void * rtos_clz; + void * exception_entry_ptr; + void * rtos_strcpy_ptr; + void * xISRStackTop; +}; + +typedef union byte_array byte_array, *Pbyte_array; + +typedef uint uintptr_t; + +union byte_array { + uint8_t bytes[8]; + uintptr_t intx; + uint64_t int64; +}; + +typedef struct mac_hdr_qos mac_hdr_qos, *Pmac_hdr_qos; + +struct mac_hdr_qos { + uint16_t fctl; + uint16_t durid; + struct mac_addr addr1; + struct mac_addr addr2; + struct mac_addr addr3; + uint16_t seq; + uint16_t qos; +}; + +typedef struct eth_hdr eth_hdr, *Peth_hdr; + +struct eth_hdr { + struct mac_addr da; + struct mac_addr sa; + uint16_t len; +}; + +typedef struct mac_hdr_long_qos mac_hdr_long_qos, *Pmac_hdr_long_qos; + +struct mac_hdr_long_qos { + uint16_t fctl; + uint16_t durid; + struct mac_addr addr1; + struct mac_addr addr2; + struct mac_addr addr3; + uint16_t seq; + struct mac_addr addr4; + uint16_t qos; +}; + +typedef struct mac_hdr mac_hdr, *Pmac_hdr; + +struct mac_hdr { + uint16_t fctl; + uint16_t durid; + struct mac_addr addr1; + struct mac_addr addr2; + struct mac_addr addr3; + uint16_t seq; +}; + +typedef struct bcn_frame bcn_frame, *Pbcn_frame; + +struct bcn_frame { + struct mac_hdr h; + uint64_t tsf; + uint16_t bcnint; + uint16_t capa; + uint8_t[0] variable; +}; + +typedef struct mac_hdr_long mac_hdr_long, *Pmac_hdr_long; + +struct mac_hdr_long { + uint16_t fctl; + uint16_t durid; + struct mac_addr addr1; + struct mac_addr addr2; + struct mac_addr addr3; + uint16_t seq; + struct mac_addr addr4; +}; + +typedef struct preq_frame preq_frame, *Ppreq_frame; + +struct preq_frame { + struct mac_hdr h; + uint8_t[0] payload; +}; + +typedef struct mac_hdr_ctrl mac_hdr_ctrl, *Pmac_hdr_ctrl; + +struct mac_hdr_ctrl { + uint16_t fctl; + uint16_t durid; + struct mac_addr addr1; + struct mac_addr addr2; +}; + +typedef enum BL_IRQ_EXCEPTION_TYPE_T { + BL_IRQ_EXCEPTION_TYPE_ACCESS_ILLEGAL=2, + BL_IRQ_EXCEPTION_TYPE_ILLEGAL_INSTRUCTION=3, + BL_IRQ_EXCEPTION_TYPE_LOAD_MISALIGN=0, + BL_IRQ_EXCEPTION_TYPE_STORE_MISALIGN=1 +} BL_IRQ_EXCEPTION_TYPE_T; + +typedef struct dma_env_tag dma_env_tag, *Pdma_env_tag; + +struct dma_env_tag { + struct dma_desc * last_dma[4]; +}; + +typedef struct sm_disconnect_req sm_disconnect_req, *Psm_disconnect_req; + +struct sm_disconnect_req { + uint16_t reason_code; + uint8_t vif_idx; + undefined field_0x3; +}; + +typedef struct sm_disconnect_ind sm_disconnect_ind, *Psm_disconnect_ind; + +struct sm_disconnect_ind { + uint16_t reason_code; + uint8_t vif_idx; + _Bool ft_over_ds; +}; + +typedef struct sm_connect_req sm_connect_req, *Psm_connect_req; + +struct sm_connect_req { + struct mac_ssid ssid; + struct mac_addr bssid; + struct scan_chan_tag chan; + undefined field_0x2e; + undefined field_0x2f; + uint32_t flags; + uint16_t ctrl_port_ethertype; + uint16_t ie_len; + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t auth_type; + uint8_t uapsd_queues; + uint8_t vif_idx; + undefined field_0x3e; + undefined field_0x3f; + uint32_t ie_buf[64]; + _Bool is_supplicant_enabled; + uint8_t phrase[64]; + uint8_t phrase_pmk[64]; + undefined field_0x1c1; + undefined field_0x1c2; + undefined field_0x1c3; +}; + +typedef struct sm_connect_cfm sm_connect_cfm, *Psm_connect_cfm; + +struct sm_connect_cfm { + uint8_t status; +}; + +typedef enum sm_state_tag { + SM_ACTIVATING=7, + SM_ASSOCIATING=6, + SM_AUTHENTICATING=5, + SM_BSS_PARAM_SETTING=4, + SM_DISCONNECTING=8, + SM_IDLE=0, + SM_JOINING=2, + SM_SCANNING=1, + SM_STATE_MAX=9, + SM_STA_ADDING=3 +} sm_state_tag; + +typedef struct sm_connect_ind sm_connect_ind, *Psm_connect_ind; + +struct sm_connect_ind { + uint16_t status_code; + struct mac_addr bssid; + _Bool roamed; + uint8_t vif_idx; + uint8_t ap_idx; + uint8_t ch_idx; + _Bool qos; + uint8_t acm; + uint16_t assoc_req_ie_len; + uint16_t assoc_rsp_ie_len; + undefined field_0x12; + undefined field_0x13; + uint32_t assoc_ie_buf[200]; + uint16_t aid; + uint8_t band; + undefined field_0x337; + uint16_t center_freq; + uint8_t width; + undefined field_0x33b; + uint32_t center_freq1; + uint32_t center_freq2; + uint32_t ac_param[4]; +}; + +typedef enum sm_msg_tag { + SM_CONNECT_CFM=6145, + SM_CONNECT_IND=6146, + SM_CONNECT_REQ=6144, + SM_DISCONNECT_CFM=6148, + SM_DISCONNECT_IND=6149, + SM_DISCONNECT_REQ=6147, + SM_MAX=6151, + SM_RSP_TIMEOUT_IND=6150 +} sm_msg_tag; + +typedef enum msgTypes { + CONNACK=2, + CONNECT=1, + DISCONNECT=14, + PINGREQ=12, + PINGRESP=13, + PUBACK=4, + PUBCOMP=7, + PUBLISH=3, + PUBREC=5, + PUBREL=6, + SUBACK=9, + SUBSCRIBE=8, + UNKNOWN=-1, + UNSUBACK=11, + UNSUBSCRIBE=10 +} msgTypes; + +typedef union MQTTHeader MQTTHeader, *PMQTTHeader; + +union MQTTHeader { + uchar byte; +}; + +typedef enum msgTypes MessageTypes; + +typedef struct mm_csa_counter_ind mm_csa_counter_ind, *Pmm_csa_counter_ind; + +struct mm_csa_counter_ind { + uint8_t vif_index; + uint8_t csa_count; +}; + +typedef struct mm_force_idle_req mm_force_idle_req, *Pmm_force_idle_req; + +struct mm_force_idle_req { + void (* cb)(void); +}; + +typedef struct mm_set_bssid_req mm_set_bssid_req, *Pmm_set_bssid_req; + +struct mm_set_bssid_req { + struct mac_addr bssid; + uint8_t inst_nbr; +}; + +typedef struct mm_monitor_channel_cfm mm_monitor_channel_cfm, *Pmm_monitor_channel_cfm; + +struct mm_monitor_channel_cfm { + uint32_t status; + uint32_t freq; + uint32_t data[8]; +}; + +typedef struct mm_rssi_status_ind mm_rssi_status_ind, *Pmm_rssi_status_ind; + +struct mm_rssi_status_ind { + uint8_t vif_index; + _Bool rssi_status; + int8_t rssi; +}; + +typedef struct mm_sta_del_req mm_sta_del_req, *Pmm_sta_del_req; + +struct mm_sta_del_req { + uint8_t sta_idx; +}; + +typedef struct mm_set_channel_req mm_set_channel_req, *Pmm_set_channel_req; + +struct mm_set_channel_req { + uint8_t band; + uint8_t type; + uint16_t prim20_freq; + uint16_t center1_freq; + uint16_t center2_freq; + uint8_t index; + int8_t tx_power; +}; + +typedef struct mm_sta_add_req mm_sta_add_req, *Pmm_sta_add_req; + +struct mm_sta_add_req { + uint32_t ampdu_size_max_vht; + uint32_t paid_gid; + uint16_t ampdu_size_max_ht; + struct mac_addr mac_addr; + uint8_t ampdu_spacing_min; + uint8_t inst_nbr; + _Bool tdls_sta; + int8_t rssi; + uint32_t tsflo; + uint32_t tsfhi; + uint8_t data_rate; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +typedef struct mm_set_power_cfm mm_set_power_cfm, *Pmm_set_power_cfm; + +struct mm_set_power_cfm { + uint8_t radio_idx; + int8_t power; +}; + +typedef struct mm_set_mode_req mm_set_mode_req, *Pmm_set_mode_req; + +struct mm_set_mode_req { + uint8_t abgnmode; +}; + +typedef struct mm_chan_ctxt_update_req mm_chan_ctxt_update_req, *Pmm_chan_ctxt_update_req; + +struct mm_chan_ctxt_update_req { + uint8_t chan_index; + uint8_t band; + uint8_t type; + undefined field_0x3; + uint16_t prim20_freq; + uint16_t center1_freq; + uint16_t center2_freq; + int8_t tx_power; + undefined field_0xb; +}; + +typedef struct mm_monitor_req mm_monitor_req, *Pmm_monitor_req; + +struct mm_monitor_req { + uint32_t enable; +}; + +typedef struct mm_cfg_rssi_req mm_cfg_rssi_req, *Pmm_cfg_rssi_req; + +struct mm_cfg_rssi_req { + uint8_t vif_index; + int8_t rssi_thold; + uint8_t rssi_hyst; +}; + +typedef struct mm_set_beacon_int_req mm_set_beacon_int_req, *Pmm_set_beacon_int_req; + +struct mm_set_beacon_int_req { + uint16_t beacon_int; + uint8_t inst_nbr; + undefined field_0x3; +}; + +typedef struct mm_traffic_req_ind mm_traffic_req_ind, *Pmm_traffic_req_ind; + +struct mm_traffic_req_ind { + uint8_t sta_idx; + uint8_t pkt_cnt; + _Bool uapsd; +}; + +typedef struct mm_set_power_req mm_set_power_req, *Pmm_set_power_req; + +struct mm_set_power_req { + uint8_t inst_nbr; + int8_t power; +}; + +typedef struct mm_set_dtim_req mm_set_dtim_req, *Pmm_set_dtim_req; + +struct mm_set_dtim_req { + uint8_t dtim_period; +}; + +typedef struct mm_bcn_change_req mm_bcn_change_req, *Pmm_bcn_change_req; + +struct mm_bcn_change_req { + uint32_t bcn_ptr; + uint16_t bcn_len; + uint16_t tim_oft; + uint8_t tim_len; + uint8_t inst_nbr; + uint8_t csa_oft[2]; + uint8_t[0] bcn_buf; +}; + +typedef struct mm_key_del_req mm_key_del_req, *Pmm_key_del_req; + +struct mm_key_del_req { + uint8_t hw_key_idx; +}; + +typedef struct mm_set_edca_req mm_set_edca_req, *Pmm_set_edca_req; + +struct mm_set_edca_req { + uint32_t ac_param; + _Bool uapsd; + uint8_t hw_queue; + uint8_t inst_nbr; + undefined field_0x7; +}; + +typedef struct mm_set_filter_req mm_set_filter_req, *Pmm_set_filter_req; + +struct mm_set_filter_req { + uint32_t filter; +}; + +typedef struct mm_set_channel_cfm mm_set_channel_cfm, *Pmm_set_channel_cfm; + +struct mm_set_channel_cfm { + uint8_t radio_idx; + int8_t power; +}; + +typedef struct mm_add_if_req mm_add_if_req, *Pmm_add_if_req; + +struct mm_add_if_req { + uint8_t type; + struct mac_addr addr; + _Bool p2p; +}; + +typedef struct mm_ba_add_req mm_ba_add_req, *Pmm_ba_add_req; + +struct mm_ba_add_req { + uint8_t type; + uint8_t sta_idx; + uint8_t tid; + uint8_t bufsz; + uint16_t ssn; +}; + +typedef struct mm_monitor_cfm mm_monitor_cfm, *Pmm_monitor_cfm; + +struct mm_monitor_cfm { + uint32_t status; + uint32_t enable; + uint32_t data[8]; +}; + +typedef struct mm_csa_finish_ind mm_csa_finish_ind, *Pmm_csa_finish_ind; + +struct mm_csa_finish_ind { + uint8_t vif_index; + uint8_t status; + uint8_t chan_idx; +}; + +typedef struct mm_chan_ctxt_add_req mm_chan_ctxt_add_req, *Pmm_chan_ctxt_add_req; + +struct mm_chan_ctxt_add_req { + uint8_t band; + uint8_t type; + uint16_t prim20_freq; + uint16_t center1_freq; + uint16_t center2_freq; + int8_t tx_power; + undefined field_0x9; +}; + +typedef struct mm_set_idle_req mm_set_idle_req, *Pmm_set_idle_req; + +struct mm_set_idle_req { + uint8_t hw_idle; +}; + +typedef struct mm_sta_add_cfm mm_sta_add_cfm, *Pmm_sta_add_cfm; + +struct mm_sta_add_cfm { + uint8_t status; + uint8_t sta_idx; + uint8_t hw_sta_idx; +}; + +typedef struct mm_set_ps_mode_req mm_set_ps_mode_req, *Pmm_set_ps_mode_req; + +struct mm_set_ps_mode_req { + uint8_t new_state; +}; + +typedef struct mm_ba_add_cfm mm_ba_add_cfm, *Pmm_ba_add_cfm; + +struct mm_ba_add_cfm { + uint8_t sta_idx; + uint8_t tid; + uint8_t status; +}; + +typedef struct mm_key_add_cfm mm_key_add_cfm, *Pmm_key_add_cfm; + +struct mm_key_add_cfm { + uint8_t status; + uint8_t hw_key_idx; +}; + +typedef struct mm_ps_change_ind mm_ps_change_ind, *Pmm_ps_change_ind; + +struct mm_ps_change_ind { + uint8_t sta_idx; + uint8_t ps_state; +}; + +typedef struct mm_remain_on_channel_req mm_remain_on_channel_req, *Pmm_remain_on_channel_req; + +struct mm_remain_on_channel_req { + uint8_t op_code; + uint8_t vif_index; + uint8_t band; + uint8_t type; + uint16_t prim20_freq; + uint16_t center1_freq; + uint16_t center2_freq; + undefined field_0xa; + undefined field_0xb; + uint32_t duration_ms; + int8_t tx_power; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct mm_remain_on_channel_cfm mm_remain_on_channel_cfm, *Pmm_remain_on_channel_cfm; + +struct mm_remain_on_channel_cfm { + uint8_t op_code; + uint8_t status; + uint8_t chan_ctxt_index; +}; + +typedef struct mm_tim_update_req mm_tim_update_req, *Pmm_tim_update_req; + +struct mm_tim_update_req { + uint16_t aid; + uint8_t tx_avail; + uint8_t inst_nbr; +}; + +typedef enum mm_msg_tag { + MM_ADD_IF_CFM=7, + MM_ADD_IF_REQ=6, + MM_BA_ADD_CFM=41, + MM_BA_ADD_REQ=40, + MM_BA_DEL_CFM=43, + MM_BA_DEL_REQ=42, + MM_BCN_CHANGE_CFM=64, + MM_BCN_CHANGE_REQ=63, + MM_BFMER_ENABLE_REQ=80, + MM_CFG_RSSI_REQ=86, + MM_CHANNEL_PRE_SWITCH_IND=69, + MM_CHANNEL_SURVEY_IND=79, + MM_CHANNEL_SWITCH_IND=68, + MM_CHAN_CTXT_ADD_CFM=52, + MM_CHAN_CTXT_ADD_REQ=51, + MM_CHAN_CTXT_DEL_CFM=54, + MM_CHAN_CTXT_DEL_REQ=53, + MM_CHAN_CTXT_LINK_CFM=56, + MM_CHAN_CTXT_LINK_REQ=55, + MM_CHAN_CTXT_SCHED_CFM=62, + MM_CHAN_CTXT_SCHED_REQ=61, + MM_CHAN_CTXT_UNLINK_CFM=58, + MM_CHAN_CTXT_UNLINK_REQ=57, + MM_CHAN_CTXT_UPDATE_CFM=60, + MM_CHAN_CTXT_UPDATE_REQ=59, + MM_CONNECTION_LOSS_IND=67, + MM_CSA_COUNTER_IND=78, + MM_CSA_FINISH_IND=88, + MM_CSA_TRAFFIC_IND=89, + MM_DENOISE_REQ=48, + MM_FORCE_IDLE_REQ=96, + MM_KEY_ADD_CFM=37, + MM_KEY_ADD_REQ=36, + MM_KEY_DEL_CFM=39, + MM_KEY_DEL_REQ=38, + MM_MAX=99, + MM_MONITOR_CFM=93, + MM_MONITOR_CHANNEL_CFM=95, + MM_MONITOR_CHANNEL_REQ=94, + MM_MONITOR_REQ=92, + MM_MU_GROUP_UPDATE_CFM=91, + MM_MU_GROUP_UPDATE_REQ=90, + MM_P2P_NOA_UPD_IND=85, + MM_P2P_VIF_PS_CHANGE_IND=77, + MM_PRIMARY_TBTT_IND=44, + MM_PS_CHANGE_IND=73, + MM_REMAIN_ON_CHANNEL_CFM=71, + MM_REMAIN_ON_CHANNEL_EXP_IND=72, + MM_REMAIN_ON_CHANNEL_REQ=70, + MM_REMOVE_IF_CFM=9, + MM_REMOVE_IF_REQ=8, + MM_RESET_CFM=1, + MM_RESET_REQ=0, + MM_RSSI_STATUS_IND=87, + MM_SCAN_CHANNEL_END_IND=98, + MM_SCAN_CHANNEL_START_IND=97, + MM_SECONDARY_TBTT_IND=45, + MM_SET_BASIC_RATES_CFM=23, + MM_SET_BASIC_RATES_REQ=22, + MM_SET_BEACON_INT_CFM=21, + MM_SET_BEACON_INT_REQ=20, + MM_SET_BSSID_CFM=25, + MM_SET_BSSID_REQ=24, + MM_SET_CHANNEL_CFM=17, + MM_SET_CHANNEL_REQ=16, + MM_SET_DTIM_CFM=19, + MM_SET_DTIM_REQ=18, + MM_SET_EDCA_CFM=27, + MM_SET_EDCA_REQ=26, + MM_SET_FILTER_CFM=15, + MM_SET_FILTER_REQ=14, + MM_SET_IDLE_CFM=35, + MM_SET_IDLE_REQ=34, + MM_SET_MODE_CFM=29, + MM_SET_MODE_REQ=28, + MM_SET_P2P_NOA_CFM=83, + MM_SET_P2P_NOA_REQ=81, + MM_SET_P2P_OPPPS_CFM=84, + MM_SET_P2P_OPPPS_REQ=82, + MM_SET_POWER_CFM=47, + MM_SET_POWER_REQ=46, + MM_SET_PS_MODE_CFM=50, + MM_SET_PS_MODE_REQ=49, + MM_SET_PS_OPTIONS_CFM=76, + MM_SET_PS_OPTIONS_REQ=75, + MM_SET_SLOTTIME_CFM=33, + MM_SET_SLOTTIME_REQ=32, + MM_SET_VIF_STATE_CFM=31, + MM_SET_VIF_STATE_REQ=30, + MM_START_CFM=3, + MM_START_REQ=2, + MM_STA_ADD_CFM=11, + MM_STA_ADD_REQ=10, + MM_STA_DEL_CFM=13, + MM_STA_DEL_REQ=12, + MM_TIM_UPDATE_CFM=66, + MM_TIM_UPDATE_REQ=65, + MM_TRAFFIC_REQ_IND=74, + MM_VERSION_CFM=5, + MM_VERSION_REQ=4 +} mm_msg_tag; + +typedef struct mm_monitor_channel_req mm_monitor_channel_req, *Pmm_monitor_channel_req; + +struct mm_monitor_channel_req { + uint32_t freq; + uint32_t use_40Mhz; + uint32_t higher_band; +}; + +typedef struct mm_key_add_req mm_key_add_req, *Pmm_key_add_req; + +typedef struct mac_sec_key mac_sec_key, *Pmac_sec_key; + +struct mac_sec_key { + uint8_t length; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + uint32_t array[8]; +}; + +struct mm_key_add_req { + uint8_t key_idx; + uint8_t sta_idx; + undefined field_0x2; + undefined field_0x3; + struct mac_sec_key key; + uint8_t cipher_suite; + uint8_t inst_nbr; + uint8_t spp; + _Bool pairwise; +}; + +typedef struct mm_set_vif_state_req mm_set_vif_state_req, *Pmm_set_vif_state_req; + +struct mm_set_vif_state_req { + uint16_t aid; + _Bool active; + uint8_t inst_nbr; +}; + +typedef struct mm_start_req mm_start_req, *Pmm_start_req; + +typedef struct phy_cfg_tag phy_cfg_tag, *Pphy_cfg_tag; + +struct phy_cfg_tag { + uint32_t parameters; + undefined field_0x4; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + undefined field_0x8; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + undefined field_0xc; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + undefined field_0x10; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + undefined field_0x18; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; + undefined field_0x1c; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; + undefined field_0x20; + undefined field_0x21; + undefined field_0x22; + undefined field_0x23; + undefined field_0x24; + undefined field_0x25; + undefined field_0x26; + undefined field_0x27; + undefined field_0x28; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; + undefined field_0x2c; + undefined field_0x2d; + undefined field_0x2e; + undefined field_0x2f; + undefined field_0x30; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + undefined field_0x34; + undefined field_0x35; + undefined field_0x36; + undefined field_0x37; + undefined field_0x38; + undefined field_0x39; + undefined field_0x3a; + undefined field_0x3b; + undefined field_0x3c; + undefined field_0x3d; + undefined field_0x3e; + undefined field_0x3f; +}; + +struct mm_start_req { + struct phy_cfg_tag phy_cfg; + uint32_t uapsd_timeout; + uint16_t lp_clk_accuracy; + undefined field_0x46; + undefined field_0x47; +}; + +typedef enum mm_remain_on_channel_op { + MM_ROC_OP_CANCEL=1, + MM_ROC_OP_MAX=2, + MM_ROC_OP_START=0 +} mm_remain_on_channel_op; + +typedef struct mm_remove_if_req mm_remove_if_req, *Pmm_remove_if_req; + +struct mm_remove_if_req { + uint8_t inst_nbr; +}; + +typedef struct mm_version_cfm mm_version_cfm, *Pmm_version_cfm; + +struct mm_version_cfm { + uint32_t version_lmac; + uint32_t version_machw_1; + uint32_t version_machw_2; + uint32_t version_phy_1; + uint32_t version_phy_2; + uint32_t features; +}; + +typedef struct mm_add_if_cfm mm_add_if_cfm, *Pmm_add_if_cfm; + +struct mm_add_if_cfm { + uint8_t status; + uint8_t inst_nbr; +}; + +typedef struct mm_set_ps_options_req mm_set_ps_options_req, *Pmm_set_ps_options_req; + +struct mm_set_ps_options_req { + uint8_t vif_index; + undefined field_0x1; + uint16_t listen_interval; + _Bool dont_listen_bc_mc; + undefined field_0x5; +}; + +typedef struct mm_connection_loss_ind mm_connection_loss_ind, *Pmm_connection_loss_ind; + +struct mm_connection_loss_ind { + uint8_t inst_nbr; +}; + +typedef struct mm_csa_traffic_ind mm_csa_traffic_ind, *Pmm_csa_traffic_ind; + +struct mm_csa_traffic_ind { + uint8_t vif_index; + _Bool enable; +}; + +typedef struct mm_set_basic_rates_req mm_set_basic_rates_req, *Pmm_set_basic_rates_req; + +struct mm_set_basic_rates_req { + uint32_t rates; + uint8_t inst_nbr; + uint8_t band; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct mm_set_slottime_req mm_set_slottime_req, *Pmm_set_slottime_req; + +struct mm_set_slottime_req { + uint8_t slottime; +}; + +typedef enum mm_state_tag { + MM_ACTIVE=1, + MM_GOING_TO_IDLE=2, + MM_HOST_BYPASSED=3, + MM_IDLE=0, + MM_STATE_MAX=4 +} mm_state_tag; + +typedef struct xLIST List_t; + +typedef struct list_head list_head, *Plist_head; + +struct list_head { + struct list_head * next; + struct list_head * prev; +}; + +typedef struct dlist_s dlist_s, *Pdlist_s; + +typedef struct dlist_s dlist_t; + +struct dlist_s { + struct dlist_s * prev; + struct dlist_s * next; +}; + +typedef struct hal_dma_env_tag hal_dma_env_tag, *Phal_dma_env_tag; + +struct hal_dma_env_tag { + struct co_list prog[2]; + struct co_list free_gp_dma_descs; + uint16_t lli_cnt[2]; +}; + +typedef struct dns_hdr dns_hdr, *Pdns_hdr; + +struct dns_hdr { + u16_t id; + u8_t flags1; + u8_t flags2; + u16_t numquestions; + u16_t numanswers; + u16_t numauthrr; + u16_t numextrarr; +}; + +typedef enum lwip_ieee_eth_type { + ETHTYPE_ARP=2054, + ETHTYPE_ETHERCAT=-30556, + ETHTYPE_IP=2048, + ETHTYPE_IPV6=-31011, + ETHTYPE_JUMBO=-30608, + ETHTYPE_LLDP=-30516, + ETHTYPE_MRP=-30493, + ETHTYPE_PPPOE=-30620, + ETHTYPE_PPPOEDISC=-30621, + ETHTYPE_PROFINET=-30574, + ETHTYPE_PTP=-30473, + ETHTYPE_QINQ=-28416, + ETHTYPE_RARP=-32715, + ETHTYPE_SERCOS=-30515, + ETHTYPE_VLAN=-32512, + ETHTYPE_WOL=2114 +} lwip_ieee_eth_type; + +typedef struct dns_table_entry.conflict dns_table_entry.conflict, *Pdns_table_entry.conflict; + +struct dns_table_entry.conflict { + u32_t ttl; + ip_addr_t ipaddr; + u16_t txid; + u8_t state; + u8_t server_idx; + u8_t tmr; + u8_t retries; + u8_t seqno; + char name[256]; + undefined field_0x10f; +}; + +typedef struct dns_req_entry dns_req_entry, *Pdns_req_entry; + +struct dns_req_entry { + void (* found)(char *, ip_addr_t *, void *); + void * arg; +}; + +typedef struct dns_table_entry.conflict1 dns_table_entry.conflict1, *Pdns_table_entry.conflict1; + +struct dns_table_entry.conflict1 { + u32_t ttl; + ip_addr_t ipaddr; + u16_t txid; + u8_t state; + u8_t server_idx; + u8_t tmr; + u8_t retries; + u8_t seqno; + char name[256]; + undefined field_0x10f; +}; + +typedef struct dns_query dns_query, *Pdns_query; + +struct dns_query { + u16_t type; + u16_t cls; +}; + +typedef struct dns_answer dns_answer, *Pdns_answer; + +struct dns_answer { + u16_t type; + u16_t cls; + u32_t ttl; + u16_t len; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct memp memp, *Pmemp; + +struct memp { + struct memp * next; +}; + +typedef struct memp_desc memp_desc, *Pmemp_desc; + +struct memp_desc { + struct stats_mem * stats; + u16_t size; + u16_t num; + u8_t * base; + struct memp * * tab; +}; + +typedef struct __sFILE __sFILE, *P__sFILE; + +typedef struct _reent _reent, *P_reent; + +typedef long _fpos_t; + +typedef struct __sFILE __FILE; + +typedef struct __sbuf __sbuf, *P__sbuf; + +typedef struct __locale_t __locale_t, *P__locale_t; + +typedef struct _Bigint _Bigint, *P_Bigint; + +typedef union anon_union_for__new anon_union_for__new, *Panon_union_for__new; + +typedef struct _atexit _atexit, *P_atexit; + +typedef struct _glue _glue, *P_glue; + +typedef long _off_t; + +typedef int _LOCK_RECURSIVE_T; + +typedef _LOCK_RECURSIVE_T _flock_t; + +typedef struct _mbstate_t _mbstate_t, *P_mbstate_t; + +typedef ulong __ULong; + +typedef struct anon_struct anon_struct, *Panon_struct; + +typedef struct anon_struct.conflict anon_struct.conflict, *Panon_struct.conflict; + +typedef struct _on_exit_args _on_exit_args, *P_on_exit_args; + +typedef union anon_union_for___value anon_union_for___value, *Panon_union_for___value; + +typedef struct __tm __tm, *P__tm; + +typedef struct _rand48 _rand48, *P_rand48; + +typedef uint wint_t; + +struct __tm { + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + +union anon_union_for___value { + wint_t __wch; + uchar __wchb[4]; +}; + +struct _mbstate_t { + int __count; + union anon_union_for___value __value; +}; + +struct _rand48 { + ushort _seed[3]; + ushort _mult[3]; + ushort _add; +}; + +struct anon_struct { + uint _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + undefined field_0x22; + undefined field_0x23; + struct __tm _localtime_buf; + int _gamma_signgam; + undefined field_0x4c; + undefined field_0x4d; + undefined field_0x4e; + undefined field_0x4f; + ulonglong _rand_next; + struct _rand48 _r48; + undefined field_0x66; + undefined field_0x67; + struct _mbstate_t _mblen_state; + struct _mbstate_t _mbtowc_state; + struct _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + struct _mbstate_t _mbrlen_state; + struct _mbstate_t _mbrtowc_state; + struct _mbstate_t _mbsrtowcs_state; + struct _mbstate_t _wcrtomb_state; + struct _mbstate_t _wcsrtombs_state; + int _h_errno; +}; + +struct anon_struct.conflict { + uchar * _nextf[30]; + uint _nmalloc[30]; +}; + +union anon_union_for__new { + struct anon_struct _reent; + struct anon_struct.conflict _unused; +}; + +struct _glue { + struct _glue * _next; + int _niobs; + __FILE * _iobs; +}; + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + __ULong _fntypes; + __ULong _is_cxa; +}; + +struct _atexit { + struct _atexit * _next; + int _ind; + void (* _fns[32])(void); + struct _on_exit_args _on_exit_args; +}; + +struct __sbuf { + uchar * _base; + int _size; +}; + +struct __sFILE { + uchar * _p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + void * _cookie; + _ssize_t (* _read)(struct _reent *, void *, char *, int); + _ssize_t (* _write)(struct _reent *, void *, char *, int); + _fpos_t (* _seek)(struct _reent *, void *, _fpos_t, int); + int (* _close)(struct _reent *, void *); + struct __sbuf _ub; + uchar * _up; + int _ur; + uchar _ubuf[3]; + uchar _nbuf[1]; + struct __sbuf _lb; + int _blksize; + _off_t _offset; + struct _reent * _data; + _flock_t _lock; + struct _mbstate_t _mbstate; + int _flags2; +}; + +struct _reent { + int _errno; + __FILE * _stdin; + __FILE * _stdout; + __FILE * _stderr; + int _inc; + char _emergency[25]; + undefined field_0x2d; + undefined field_0x2e; + undefined field_0x2f; + int _unspecified_locale_info; + struct __locale_t * _locale; + int __sdidinit; + void (* __cleanup)(struct _reent *); + struct _Bigint * _result; + int _result_k; + struct _Bigint * _p5s; + struct _Bigint * * _freelist; + int _cvtlen; + char * _cvtbuf; + union anon_union_for__new _new; + struct _atexit * _atexit; + struct _atexit _atexit0; + void (** _sig_func)(int); + struct _glue __sglue; + __FILE __sf[3]; + undefined field_0x424; + undefined field_0x425; + undefined field_0x426; + undefined field_0x427; +}; + +struct __locale_t { +}; + +struct _Bigint { + struct _Bigint * _next; + int _k; + int _maxwds; + int _sign; + int _wds; + __ULong _x[1]; +}; + +typedef union anon_union.conflict anon_union.conflict, *Panon_union.conflict; + +union anon_union.conflict { + struct anon_struct _reent; + struct anon_struct.conflict _unused; +}; + +typedef struct _atexit.conflict _atexit.conflict, *P_atexit.conflict; + +struct _atexit.conflict { + struct _atexit * _next; + int _ind; + void (* _fns[32])(void); + struct _on_exit_args _on_exit_args; +}; + +typedef struct _reent.conflict _reent.conflict, *P_reent.conflict; + +struct _reent.conflict { + int _errno; + __FILE * _stdin; + __FILE * _stdout; + __FILE * _stderr; + int _inc; + char _emergency[25]; + undefined field_0x2d; + undefined field_0x2e; + undefined field_0x2f; + int _unspecified_locale_info; + struct __locale_t * _locale; + int __sdidinit; + void (* __cleanup)(struct _reent *); + struct _Bigint * _result; + int _result_k; + struct _Bigint * _p5s; + struct _Bigint * * _freelist; + int _cvtlen; + char * _cvtbuf; + union anon_union_for__new _new; + struct _atexit * _atexit; + struct _atexit.conflict _atexit0; + void (** _sig_func)(int); + struct _glue __sglue; + __FILE __sf[3]; + undefined field_0x424; + undefined field_0x425; + undefined field_0x426; + undefined field_0x427; +}; + +typedef enum hal_uart_flow_control_t { + FLOW_CONTROL_CTS=1, + FLOW_CONTROL_CTS_RTS=3, + FLOW_CONTROL_DISABLED=0, + FLOW_CONTROL_RTS=2 +} hal_uart_flow_control_t; + +typedef enum hal_uart_mode_t { + MODE_RX=1, + MODE_TX=0, + MODE_TX_RX=2 +} hal_uart_mode_t; + +typedef enum hal_uart_stop_bits_t { + STOP_BITS_1=0, + STOP_BITS_2=1 +} hal_uart_stop_bits_t; + +typedef struct uart_dev_t uart_dev_t, *Puart_dev_t; + +typedef struct uart_config_t uart_config_t, *Puart_config_t; + +typedef enum hal_uart_data_width_t { + DATA_WIDTH_5BIT=0, + DATA_WIDTH_6BIT=1, + DATA_WIDTH_7BIT=2, + DATA_WIDTH_8BIT=3, + DATA_WIDTH_9BIT=4 +} hal_uart_data_width_t; + +typedef enum hal_uart_parity_t { + EVEN_PARITY=2, + NO_PARITY=0, + ODD_PARITY=1 +} hal_uart_parity_t; + +struct uart_config_t { + uint32_t baud_rate; + enum hal_uart_data_width_t data_width; + enum hal_uart_parity_t parity; + enum hal_uart_stop_bits_t stop_bits; + enum hal_uart_flow_control_t flow_control; + enum hal_uart_mode_t mode; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +struct uart_dev_t { + uint8_t port; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + struct uart_config_t config; + void * rx_ringbuf_handle; + void * tx_ringbuf_handle; + uint32_t rx_buf_size; + uint32_t tx_buf_size; + void * mutex; + void * poll_cb; + void * fd; + void * poll_data; + void * taskhdl; + uint8_t read_block_flag; + undefined field_0x35; + undefined field_0x36; + undefined field_0x37; + void * priv; +}; + +typedef enum hal_uart_int_t { + UART_RX_INT=1, + UART_TX_INT=0 +} hal_uart_int_t; + +typedef struct etharp_hdr etharp_hdr, *Petharp_hdr; + +typedef struct eth_addr eth_addr, *Peth_addr; + +typedef struct ip4_addr_wordaligned ip4_addr_wordaligned, *Pip4_addr_wordaligned; + +struct eth_addr { + u8_t addr[6]; +}; + +struct ip4_addr_wordaligned { + u16_t addrw[2]; +}; + +struct etharp_hdr { + u16_t hwtype; + u16_t proto; + u8_t hwlen; + u8_t protolen; + u16_t opcode; + struct eth_addr shwaddr; + struct ip4_addr_wordaligned sipaddr; + struct eth_addr dhwaddr; + struct ip4_addr_wordaligned dipaddr; +}; + +typedef enum etharp_opcode { + ARP_REPLY=2, + ARP_REQUEST=1 +} etharp_opcode; + +typedef struct bl_dma_item bl_dma_item, *Pbl_dma_item; + +typedef struct utils_list_hdr utils_list_hdr, *Putils_list_hdr; + +struct utils_list_hdr { + struct utils_list_hdr * next; +}; + +struct bl_dma_item { + struct utils_list_hdr item; + void (* cb)(void *); + void * arg; + uint32_t src; + uint32_t dst; + uint32_t next; + uint32_t ctrl; +}; + +typedef struct dma_ctx dma_ctx, *Pdma_ctx; + +typedef struct utils_dlist_s utils_dlist_s, *Putils_dlist_s; + +typedef struct utils_dlist_s utils_dlist_t; + +struct utils_dlist_s { + struct utils_dlist_s * prev; + struct utils_dlist_s * next; +}; + +struct dma_ctx { + utils_dlist_t * pstqueue; +}; + +typedef struct dma_node dma_node, *Pdma_node; + +struct dma_node { + utils_dlist_t dlist_item; + int channel; + void * tc_handler; + void * interr_handler; + void * ctx; +}; + +typedef struct aos_dir_t aos_dir_t, *Paos_dir_t; + +struct aos_dir_t { + int dd_vfs_fd; + int dd_rsv; +}; + +typedef struct aos_dirent_t aos_dirent_t, *Paos_dirent_t; + +struct aos_dirent_t { // Missing member d_name : char[1] at offset 0x5 [Unsupported interior flex array: char[1]] + int d_ino; + uint8_t d_type; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct statfs statfs, *Pstatfs; + +struct statfs { + long f_type; + long f_bsize; + long f_blocks; + long f_bfree; + long f_bavail; + long f_files; + long f_ffree; + long f_fsid; + long f_namelen; +}; + +typedef struct etharp_entry etharp_entry, *Petharp_entry; + +typedef struct netif netif, *Pnetif; + +typedef int8_t s8_t; + +typedef s8_t err_t; + +typedef enum netif_mac_filter_action { + NETIF_ADD_MAC_FILTER=1, + NETIF_DEL_MAC_FILTER=0 +} netif_mac_filter_action; + +struct etharp_entry { + struct pbuf * q; + ip4_addr_t ipaddr; + struct netif * netif; + struct eth_addr ethaddr; + u16_t ctime; + u8_t state; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct netif { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef enum etharp_state { + ETHARP_STATE_EMPTY=0, + ETHARP_STATE_PENDING=1, + ETHARP_STATE_STABLE=2, + ETHARP_STATE_STABLE_REREQUESTING_1=3, + ETHARP_STATE_STABLE_REREQUESTING_2=4 +} etharp_state; + +typedef ushort UHWtype; + +typedef struct bl_custom_pbuf bl_custom_pbuf, *Pbl_custom_pbuf; + +typedef struct bl_custom_pbuf bl_custom_pbuf_t; + +typedef struct pbuf_custom pbuf_custom, *Ppbuf_custom; + +struct pbuf_custom { + struct pbuf pbuf; + void (* custom_free_function)(struct pbuf *); +}; + +struct bl_custom_pbuf { + struct pbuf_custom p; + void * swdesc; +}; + +typedef struct la_mem_format la_mem_format, *Pla_mem_format; + +struct la_mem_format { + uint32_t word[4]; +}; + +typedef struct QueueDefinition QueueDefinition, *PQueueDefinition; + +typedef struct QueueDefinition * QueueHandle_t; + + +// WARNING! conflicting data type names: /DWARF/queue.c/QueueDefinition/anon_union_for_u - /DWARF/timers.c/tmrTimerQueueMessage/anon_union_for_u + +struct QueueDefinition { + int8_t * pcHead; + int8_t * pcWriteTo; + union anon_union_for_u u; + List_t xTasksWaitingToSend; + List_t xTasksWaitingToReceive; + UBaseType_t uxMessagesWaiting; + UBaseType_t uxLength; + UBaseType_t uxItemSize; + int8_t cRxLock; + int8_t cTxLock; + uint8_t ucStaticallyAllocated; + undefined field_0x47; + UBaseType_t uxQueueNumber; + uint8_t ucQueueType; + undefined field_0x4d; + undefined field_0x4e; + undefined field_0x4f; +}; + +typedef struct mbedtls_asn1_bitstring mbedtls_asn1_bitstring, *Pmbedtls_asn1_bitstring; + +typedef struct mbedtls_asn1_bitstring mbedtls_x509_bitstring; + +struct mbedtls_asn1_bitstring { + size_t len; + uchar unused_bits; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uchar * p; +}; + +typedef enum bl_dev_flag { + RWNX_DEV_RESTARTING=0, + RWNX_DEV_STACK_RESTARTING=1, + RWNX_DEV_STARTED=2 +} bl_dev_flag; + +typedef uchar UQItype; + +typedef int shift_count_type; + +typedef struct DWstruct DWstruct, *PDWstruct; + +typedef int SItype; + +struct DWstruct { + SItype low; + SItype high; +}; + +typedef union DWunion DWunion, *PDWunion; + +typedef longlong DItype; + +union DWunion { + struct DWstruct s; + DItype ll; +}; + +typedef ulonglong UDItype; + +typedef uint USItype; + +typedef float SFtype; + +typedef struct QueueDefinition xQUEUE; + +typedef struct QUEUE_REGISTRY_ITEM QUEUE_REGISTRY_ITEM, *PQUEUE_REGISTRY_ITEM; + +typedef struct QUEUE_REGISTRY_ITEM xQueueRegistryItem; + +typedef xQueueRegistryItem QueueRegistryItem_t; + +struct QUEUE_REGISTRY_ITEM { + char * pcQueueName; + QueueHandle_t xHandle; +}; + +typedef struct QueuePointers QueuePointers, *PQueuePointers; + +typedef struct QueuePointers QueuePointers_t; + +struct QueuePointers { + int8_t * pcTail; + int8_t * pcReadFrom; +}; + +typedef struct SemaphoreData SemaphoreData, *PSemaphoreData; + +typedef struct SemaphoreData SemaphoreData_t; + +typedef struct tskTaskControlBlock tskTaskControlBlock, *PtskTaskControlBlock; + +typedef struct tskTaskControlBlock * TaskHandle_t; + +typedef uint32_t StackType_t; + +struct SemaphoreData { + TaskHandle_t xMutexHolder; + UBaseType_t uxRecursiveCallCount; +}; + +struct tskTaskControlBlock { + StackType_t * pxTopOfStack; + ListItem_t xStateListItem; + ListItem_t xEventListItem; + UBaseType_t uxPriority; + StackType_t * pxStack; + char pcTaskName[16]; + UBaseType_t uxCriticalNesting; + UBaseType_t uxTCBNumber; + UBaseType_t uxTaskNumber; + UBaseType_t uxBasePriority; + UBaseType_t uxMutexesHeld; + uint32_t ulNotifiedValue; + uint8_t ucNotifyState; + uint8_t ucStaticallyAllocated; + undefined field_0x5e; + undefined field_0x5f; +}; + +typedef xQUEUE Queue_t; + +typedef struct _httpc_state.conflict _httpc_state.conflict, *P_httpc_state.conflict; + +typedef struct altcp_pcb altcp_pcb, *Paltcp_pcb; + +typedef struct altcp_functions altcp_functions, *Paltcp_functions; + +typedef err_t (* altcp_connected_fn)(void *, struct altcp_pcb *, err_t); + +typedef err_t (* altcp_accept_fn)(void *, struct altcp_pcb *, err_t); + +typedef struct _httpc_connection.conflict1 _httpc_connection.conflict1, *P_httpc_connection.conflict1; + +typedef enum ehttpc_result { + HTTPC_RESULT_ERR_CLOSED=4, + HTTPC_RESULT_ERR_CONNECT=2, + HTTPC_RESULT_ERR_CONTENT_LEN=9, + HTTPC_RESULT_ERR_HOSTNAME=3, + HTTPC_RESULT_ERR_MEM=7, + HTTPC_RESULT_ERR_SVR_RESP=6, + HTTPC_RESULT_ERR_TIMEOUT=5, + HTTPC_RESULT_ERR_UNKNOWN=1, + HTTPC_RESULT_LOCAL_ABORT=8, + HTTPC_RESULT_OK=0 +} ehttpc_result; + +typedef enum ehttpc_result httpc_result_t; + +typedef struct _httpc_state _httpc_state, *P_httpc_state; + +typedef struct _httpc_state httpc_state_t; + +typedef struct _httpc_connection.conflict1 httpc_connection_t.conflict1; + +typedef enum ehttpc_parse_state { + HTTPC_PARSE_RX_DATA=2, + HTTPC_PARSE_WAIT_FIRST_LINE=0, + HTTPC_PARSE_WAIT_HEADERS=1 +} ehttpc_parse_state; + +typedef enum ehttpc_parse_state httpc_parse_state_t; + +typedef void (* altcp_set_poll_fn)(struct altcp_pcb *, u8_t); + +typedef void (* altcp_abort_fn)(struct altcp_pcb *); + +typedef err_t (* altcp_close_fn)(struct altcp_pcb *); + +typedef err_t (* altcp_output_fn)(struct altcp_pcb *); + +typedef u16_t (* altcp_mss_fn)(struct altcp_pcb *); + +typedef u16_t (* altcp_sndbuf_fn)(struct altcp_pcb *); + +typedef u16_t (* altcp_sndqueuelen_fn)(struct altcp_pcb *); + +typedef void (* altcp_nagle_disable_fn)(struct altcp_pcb *); + +typedef void (* altcp_nagle_enable_fn)(struct altcp_pcb *); + +typedef void (* altcp_setprio_fn)(struct altcp_pcb *, u8_t); + +typedef void (* altcp_dealloc_fn)(struct altcp_pcb *); + +typedef struct altcp_allocator_s altcp_allocator_s, *Paltcp_allocator_s; + +typedef struct altcp_allocator_s altcp_allocator_t; + +typedef struct _httpc_connection.conflict _httpc_connection.conflict, *P_httpc_connection.conflict; + +typedef struct _httpc_connection.conflict httpc_connection_t.conflict; + +struct _httpc_connection.conflict { + ip_addr_t proxy_addr; + u16_t proxy_port; + u8_t use_proxy; + u8_t req_type; + u8_t * data; + u8_t content_type; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + altcp_allocator_t * altcp_allocator; + void (* result_fn)(void *, httpc_result_t, u32_t, u32_t, err_t); + err_t (* headers_done_fn)(httpc_state_t *, void *, struct pbuf *, u16_t, u32_t); +}; + +struct altcp_functions { + altcp_set_poll_fn set_poll; + void (* recved)(struct altcp_pcb *, u16_t); + err_t (* bind)(struct altcp_pcb *, ip_addr_t *, u16_t); + err_t (* connect)(struct altcp_pcb *, ip_addr_t *, u16_t, altcp_connected_fn); + altcp_pcb * (* listen)(struct altcp_pcb *, u8_t, err_t *); + altcp_abort_fn abort; + altcp_close_fn close; + err_t (* shutdown)(struct altcp_pcb *, int, int); + err_t (* write)(struct altcp_pcb *, void *, u16_t, u8_t); + altcp_output_fn output; + altcp_mss_fn mss; + altcp_sndbuf_fn sndbuf; + altcp_sndqueuelen_fn sndqueuelen; + altcp_nagle_disable_fn nagle_disable; + altcp_nagle_enable_fn nagle_enable; + int (* nagle_disabled)(struct altcp_pcb *); + altcp_setprio_fn setprio; + altcp_dealloc_fn dealloc; + err_t (* addrinfo)(struct altcp_pcb *, int, ip_addr_t *, u16_t *); + ip_addr_t * (* getip)(struct altcp_pcb *, int); + u16_t (* getport)(struct altcp_pcb *, int); +}; + +struct _httpc_state.conflict { + struct altcp_pcb * pcb; + ip_addr_t remote_addr; + u16_t remote_port; + undefined field_0xa; + undefined field_0xb; + int timeout_ticks; + struct pbuf * request; + struct pbuf * rx_hdrs; + u16_t rx_http_version; + u16_t rx_status; + err_t (* recv_fn)(void *, struct altcp_pcb *, struct pbuf *, err_t); + httpc_connection_t.conflict1 * conn_settings; + void * callback_arg; + u32_t rx_content_len; + u32_t hdr_content_len; + httpc_parse_state_t parse_state; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +struct altcp_pcb { + struct altcp_functions * fns; + struct altcp_pcb * inner_conn; + void * arg; + void * state; + altcp_accept_fn accept; + altcp_connected_fn connected; + err_t (* recv)(void *, struct altcp_pcb *, struct pbuf *, err_t); + err_t (* sent)(void *, struct altcp_pcb *, u16_t); + err_t (* poll)(void *, struct altcp_pcb *); + void (* err)(void *, err_t); + u8_t pollinterval; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +struct _httpc_connection.conflict1 { + ip_addr_t proxy_addr; + u16_t proxy_port; + u8_t use_proxy; + u8_t req_type; + u8_t * data; + u8_t content_type; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + altcp_allocator_t * altcp_allocator; + void (* result_fn)(void *, httpc_result_t, u32_t, u32_t, err_t); + err_t (* headers_done_fn)(httpc_state_t *, void *, struct pbuf *, u16_t, u32_t); +}; + +struct altcp_allocator_s { + altcp_pcb * (* alloc)(void *, u8_t); + void * arg; +}; + +struct _httpc_state { + struct altcp_pcb * pcb; + ip_addr_t remote_addr; + u16_t remote_port; + undefined field_0xa; + undefined field_0xb; + int timeout_ticks; + struct pbuf * request; + struct pbuf * rx_hdrs; + u16_t rx_http_version; + u16_t rx_status; + err_t (* recv_fn)(void *, struct altcp_pcb *, struct pbuf *, err_t); + httpc_connection_t.conflict * conn_settings; + void * callback_arg; + u32_t rx_content_len; + u32_t hdr_content_len; + httpc_parse_state_t parse_state; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef enum BL_AHB_Slave1_Type { + BL_AHB_SLAVE1_CCI=8, + BL_AHB_SLAVE1_CKS=23, + BL_AHB_SLAVE1_DBG=3, + BL_AHB_SLAVE1_DMA=12, + BL_AHB_SLAVE1_EFUSE=7, + BL_AHB_SLAVE1_GLB=0, + BL_AHB_SLAVE1_GPIP=2, + BL_AHB_SLAVE1_I2C=19, + BL_AHB_SLAVE1_IRR=22, + BL_AHB_SLAVE1_L1C=9, + BL_AHB_SLAVE1_MAX=24, + BL_AHB_SLAVE1_PDSHBN=14, + BL_AHB_SLAVE1_PWM=20, + BL_AHB_SLAVE1_RF=1, + BL_AHB_SLAVE1_SDU=13, + BL_AHB_SLAVE1_SEC=4, + BL_AHB_SLAVE1_SFC=11, + BL_AHB_SLAVE1_SPI=18, + BL_AHB_SLAVE1_TMR=21, + BL_AHB_SLAVE1_TZ1=5, + BL_AHB_SLAVE1_TZ2=6, + BL_AHB_SLAVE1_UART0=16, + BL_AHB_SLAVE1_UART1=17, + BL_AHB_SLAVE1_WRAM=15 +} BL_AHB_Slave1_Type; + +typedef struct _httpc_connection.conflict2 _httpc_connection.conflict2, *P_httpc_connection.conflict2; + +struct _httpc_connection.conflict2 { + ip_addr_t proxy_addr; + u16_t proxy_port; + u8_t use_proxy; + u8_t req_type; + u8_t * data; + u8_t content_type; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + altcp_allocator_t * altcp_allocator; + void (* result_fn)(void *, httpc_result_t, u32_t, u32_t, err_t); + err_t (* headers_done_fn)(httpc_state_t *, void *, struct pbuf *, u16_t, u32_t); +}; + +typedef struct _httpc_connection.conflict3 _httpc_connection.conflict3, *P_httpc_connection.conflict3; + +struct _httpc_connection.conflict3 { + ip_addr_t proxy_addr; + u16_t proxy_port; + u8_t use_proxy; + u8_t req_type; + u8_t * data; + u8_t content_type; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + altcp_allocator_t * altcp_allocator; + void (* result_fn)(void *, httpc_result_t, u32_t, u32_t, err_t); + err_t (* headers_done_fn)(httpc_state_t *, void *, struct pbuf *, u16_t, u32_t); +}; + +typedef struct _httpc_connection.conflict4 _httpc_connection.conflict4, *P_httpc_connection.conflict4; + +struct _httpc_connection.conflict4 { + ip_addr_t proxy_addr; + u16_t proxy_port; + u8_t use_proxy; + u8_t req_type; + u8_t * data; + u8_t content_type; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + altcp_allocator_t * altcp_allocator; + void (* result_fn)(void *, httpc_result_t, u32_t, u32_t, err_t); + err_t (* headers_done_fn)(httpc_state_t *, void *, struct pbuf *, u16_t, u32_t); +}; + +typedef struct _httpc_connection.conflict5 _httpc_connection.conflict5, *P_httpc_connection.conflict5; + +struct _httpc_connection.conflict5 { + ip_addr_t proxy_addr; + u16_t proxy_port; + u8_t use_proxy; + u8_t req_type; + u8_t * data; + u8_t content_type; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + altcp_allocator_t * altcp_allocator; + void (* result_fn)(void *, httpc_result_t, u32_t, u32_t, err_t); + err_t (* headers_done_fn)(httpc_state_t *, void *, struct pbuf *, u16_t, u32_t); +}; + +typedef struct _httpc_connection.conflict5 httpc_connection_t.conflict4; + +typedef struct _httpc_connection _httpc_connection, *P_httpc_connection; + +typedef struct _httpc_connection httpc_connection_t; + +struct _httpc_connection { + ip_addr_t proxy_addr; + u16_t proxy_port; + u8_t use_proxy; + u8_t req_type; + u8_t * data; + u8_t content_type; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + altcp_allocator_t * altcp_allocator; + void (* result_fn)(void *, httpc_result_t, u32_t, u32_t, err_t); + err_t (* headers_done_fn)(httpc_state_t *, void *, struct pbuf *, u16_t, u32_t); +}; + +typedef struct _httpc_connection.conflict4 httpc_connection_t.conflict3; + +typedef struct _httpc_connection.conflict3 httpc_connection_t.conflict2; + +typedef struct anon_struct.conflict383 anon_struct.conflict383, *Panon_struct.conflict383; + +struct anon_struct.conflict383 { + u8_t proto; +}; + +typedef struct api_msg api_msg, *Papi_msg; + +typedef struct netconn netconn, *Pnetconn; + +typedef enum netconn_evt { + NETCONN_EVT_ERROR=4, + NETCONN_EVT_RCVMINUS=1, + NETCONN_EVT_RCVPLUS=0, + NETCONN_EVT_SENDMINUS=3, + NETCONN_EVT_SENDPLUS=2 +} netconn_evt; + +typedef union anon_union_for_msg anon_union_for_msg, *Panon_union_for_msg; + +typedef enum netconn_type { + NETCONN_INVALID=0, + NETCONN_RAW=64, + NETCONN_TCP=16, + NETCONN_UDP=32, + NETCONN_UDPLITE=33, + NETCONN_UDPNOCHKSUM=34 +} netconn_type; + +typedef enum netconn_state { + NETCONN_CLOSE=4, + NETCONN_CONNECT=3, + NETCONN_LISTEN=2, + NETCONN_NONE=0, + NETCONN_WRITE=1 +} netconn_state; + +typedef union anon_union_for_pcb anon_union_for_pcb, *Panon_union_for_pcb; + +typedef QueueHandle_t SemaphoreHandle_t; + +typedef SemaphoreHandle_t sys_sem_t; + +typedef QueueHandle_t sys_mbox_t; + +typedef int32_t s32_t; + +typedef struct anon_struct.conflict384 anon_struct.conflict384, *Panon_struct.conflict384; + +typedef struct anon_struct.conflict385 anon_struct.conflict385, *Panon_struct.conflict385; + +typedef struct anon_struct.conflict386 anon_struct.conflict386, *Panon_struct.conflict386; + +typedef struct anon_struct.conflict387 anon_struct.conflict387, *Panon_struct.conflict387; + +typedef struct anon_struct.conflict388 anon_struct.conflict388, *Panon_struct.conflict388; + +typedef struct anon_struct.conflict389 anon_struct.conflict389, *Panon_struct.conflict389; + +typedef struct ip_pcb ip_pcb, *Pip_pcb; + +typedef struct tcp_pcb tcp_pcb, *Ptcp_pcb; + +typedef struct udp_pcb udp_pcb, *Pudp_pcb; + +typedef struct raw_pcb raw_pcb, *Praw_pcb; + +typedef struct netvector netvector, *Pnetvector; + +typedef enum netconn_igmp { + NETCONN_JOIN=0, + NETCONN_LEAVE=1 +} netconn_igmp; + +typedef enum tcp_state { + CLOSED=0, + CLOSE_WAIT=7, + CLOSING=8, + ESTABLISHED=4, + FIN_WAIT_1=5, + FIN_WAIT_2=6, + LAST_ACK=9, + LISTEN=1, + SYN_RCVD=3, + SYN_SENT=2, + TIME_WAIT=10 +} tcp_state; + +typedef u16_t tcpflags_t; + +typedef u16_t tcpwnd_size_t; + +typedef int16_t s16_t; + +typedef struct tcp_seg tcp_seg, *Ptcp_seg; + +typedef struct tcp_pcb_listen tcp_pcb_listen, *Ptcp_pcb_listen; + +typedef err_t (* tcp_connected_fn)(void *, struct tcp_pcb *, err_t); + +typedef struct tcp_hdr tcp_hdr, *Ptcp_hdr; + +typedef err_t (* tcp_accept_fn)(void *, struct tcp_pcb *, err_t); + +struct tcp_hdr { + u16_t src; + u16_t dest; + u32_t seqno; + u32_t ackno; + u16_t _hdrlen_rsvd_flags; + u16_t wnd; + u16_t chksum; + u16_t urgp; +}; + +struct netvector { + void * ptr; + size_t len; +}; + +union anon_union_for_pcb { + struct ip_pcb * ip; + struct tcp_pcb * tcp; + struct udp_pcb * udp; + struct raw_pcb * raw; +}; + +struct netconn { + enum netconn_type type; + enum netconn_state state; + undefined field_0x2; + undefined field_0x3; + union anon_union_for_pcb pcb; + err_t pending_err; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + sys_sem_t op_completed; + sys_mbox_t recvmbox; + sys_mbox_t acceptmbox; + int socket; + s32_t send_timeout; + u32_t recv_timeout; + u8_t flags; + undefined field_0x25; + undefined field_0x26; + undefined field_0x27; + struct api_msg * current_msg; + void (* callback)(struct netconn *, enum netconn_evt, u16_t); +}; + +struct anon_struct.conflict388 { + u8_t shut; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + u32_t time_started; +}; + +struct anon_struct.conflict386 { + struct netvector * vector; + u16_t vector_cnt; + undefined field_0x6; + undefined field_0x7; + size_t vector_off; + size_t len; + size_t offset; + u8_t apiflags; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + u32_t time_started; +}; + +struct anon_struct.conflict389 { + ip_addr_t * multiaddr; + ip_addr_t * netif_addr; + u8_t if_idx; + enum netconn_igmp join_or_leave; + undefined field_0xa; + undefined field_0xb; +}; + +struct anon_struct.conflict384 { + ip_addr_t * ipaddr; + u16_t port; + u8_t if_idx; + undefined field_0x7; +}; + +struct anon_struct.conflict387 { + size_t len; +}; + +struct anon_struct.conflict385 { + ip_addr_t * ipaddr; + u16_t * port; + u8_t local; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +union anon_union_for_msg { + struct netbuf * b; + struct anon_struct.conflict383 n; + struct anon_struct.conflict384 bc; + struct anon_struct.conflict385 ad; + struct anon_struct.conflict386 w; + struct anon_struct.conflict387 r; + struct anon_struct.conflict388 sd; + struct anon_struct.conflict389 jl; +}; + +struct api_msg { + struct netconn * conn; + err_t err; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + union anon_union_for_msg msg; +}; + +struct tcp_pcb_listen { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb_listen * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + tcp_accept_fn accept; +}; + +struct udp_pcb { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct udp_pcb * next; + u8_t flags; + undefined field_0x11; + u16_t local_port; + u16_t remote_port; + undefined field_0x16; + undefined field_0x17; + ip4_addr_t mcast_ip4; + u8_t mcast_ifindex; + u8_t mcast_ttl; + undefined field_0x1e; + undefined field_0x1f; + void (* recv)(void *, struct udp_pcb *, struct pbuf *, ip_addr_t *, u16_t); + void * recv_arg; +}; + +struct tcp_pcb { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +struct tcp_seg { + struct tcp_seg * next; + struct pbuf * p; + u16_t len; + u16_t chksum; + u8_t chksum_swapped; + u8_t flags; + undefined field_0xe; + undefined field_0xf; + struct tcp_hdr * tcphdr; +}; + +struct ip_pcb { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; +}; + +struct raw_pcb { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct raw_pcb * next; + u8_t protocol; + u8_t flags; + u8_t mcast_ifindex; + u8_t mcast_ttl; + u8_t (* recv)(void *, struct raw_pcb *, struct pbuf *, ip_addr_t *); + void * recv_arg; +}; + +typedef struct netifapi_msg netifapi_msg, *Pnetifapi_msg; + +typedef struct tcpip_api_call_data tcpip_api_call_data, *Ptcpip_api_call_data; + + +// WARNING! conflicting data type names: /DWARF/api_msg.h/netifapi_msg/anon_union_for_msg - /DWARF/api_msg.h/api_msg/anon_union_for_msg + +struct tcpip_api_call_data { + err_t err; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + sys_sem_t sem; +}; + +struct netifapi_msg { + struct tcpip_api_call_data call; + struct netif * netif; + union anon_union_for_msg msg; +}; + +typedef struct anon_struct.conflict392 anon_struct.conflict392, *Panon_struct.conflict392; + +struct anon_struct.conflict392 { + ip_addr_t * ipaddr; + u16_t * port; + u8_t local; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct anon_struct.conflict393 anon_struct.conflict393, *Panon_struct.conflict393; + +struct anon_struct.conflict393 { + struct netvector * vector; + u16_t vector_cnt; + undefined field_0x6; + undefined field_0x7; + size_t vector_off; + size_t len; + size_t offset; + u8_t apiflags; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + u32_t time_started; +}; + +typedef struct anon_struct.conflict394 anon_struct.conflict394, *Panon_struct.conflict394; + +struct anon_struct.conflict394 { + u8_t shut; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + u32_t time_started; +}; + +typedef struct anon_struct.conflict395 anon_struct.conflict395, *Panon_struct.conflict395; + +struct anon_struct.conflict395 { + ip_addr_t * multiaddr; + ip_addr_t * netif_addr; + u8_t if_idx; + enum netconn_igmp join_or_leave; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct anon_struct.conflict390 anon_struct.conflict390, *Panon_struct.conflict390; + +struct anon_struct.conflict390 { + u8_t proto; +}; + +typedef struct anon_struct.conflict391 anon_struct.conflict391, *Panon_struct.conflict391; + +struct anon_struct.conflict391 { + ip_addr_t * ipaddr; + u16_t port; + u8_t if_idx; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict396 anon_struct.conflict396, *Panon_struct.conflict396; + +struct anon_struct.conflict396 { + u8_t proto; +}; + +typedef struct anon_struct.conflict397 anon_struct.conflict397, *Panon_struct.conflict397; + +struct anon_struct.conflict397 { + ip_addr_t * ipaddr; + u16_t port; + u8_t if_idx; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict398 anon_struct.conflict398, *Panon_struct.conflict398; + +struct anon_struct.conflict398 { + ip_addr_t * ipaddr; + u16_t * port; + u8_t local; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct anon_struct.conflict399 anon_struct.conflict399, *Panon_struct.conflict399; + +struct anon_struct.conflict399 { + struct netvector * vector; + u16_t vector_cnt; + undefined field_0x6; + undefined field_0x7; + size_t vector_off; + size_t len; + size_t offset; + u8_t apiflags; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + u32_t time_started; +}; + +typedef struct dns_api_msg dns_api_msg, *Pdns_api_msg; + +struct dns_api_msg { + char * name; + ip_addr_t * addr; + sys_sem_t * sem; + err_t * err; +}; + +typedef struct anon_struct.conflict400 anon_struct.conflict400, *Panon_struct.conflict400; + +struct anon_struct.conflict400 { + u8_t shut; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + u32_t time_started; +}; + +typedef void (* netifapi_void_fn)(struct netif *); + +typedef struct anon_struct.conflict401 anon_struct.conflict401, *Panon_struct.conflict401; + +struct anon_struct.conflict401 { + ip_addr_t * multiaddr; + ip_addr_t * netif_addr; + u8_t if_idx; + enum netconn_igmp join_or_leave; + undefined field_0xa; + undefined field_0xb; +}; + +typedef err_t (* netifapi_errt_fn)(struct netif *); + +typedef struct anon_struct.conflict378 anon_struct.conflict378, *Panon_struct.conflict378; + +struct anon_struct.conflict378 { + char * name; + u8_t index; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict375 anon_struct.conflict375, *Panon_struct.conflict375; + +typedef err_t (* netif_init_fn)(struct netif *); + +struct anon_struct.conflict375 { + ip4_addr_t * ipaddr; + ip4_addr_t * netmask; + ip4_addr_t * gw; + void * state; + netif_init_fn init; + err_t (* input)(struct pbuf *, struct netif *); +}; + +typedef struct anon_struct.conflict376 anon_struct.conflict376, *Panon_struct.conflict376; + +struct anon_struct.conflict376 { + netifapi_void_fn voidfunc; + netifapi_errt_fn errtfunc; +}; + +typedef struct anon_struct.conflict377 anon_struct.conflict377, *Panon_struct.conflict377; + +struct anon_struct.conflict377 { + char * name; + u8_t index; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct jsonStruct jsonStruct, *PjsonStruct; + +typedef struct jsonStruct jsonStruct_t; + +typedef enum JsonPrimitiveType { + SHADOW_JSON_BOOL=8, + SHADOW_JSON_DOUBLE=7, + SHADOW_JSON_FLOAT=6, + SHADOW_JSON_INT16=1, + SHADOW_JSON_INT32=0, + SHADOW_JSON_INT8=2, + SHADOW_JSON_OBJECT=10, + SHADOW_JSON_STRING=9, + SHADOW_JSON_UINT16=4, + SHADOW_JSON_UINT32=3, + SHADOW_JSON_UINT8=5 +} JsonPrimitiveType; + +struct jsonStruct { + char * pKey; + void * pData; + size_t dataLength; + enum JsonPrimitiveType type; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + void (* cb)(char *, uint32_t, jsonStruct_t *); +}; + +typedef struct _rom_dir_t _rom_dir_t, *P_rom_dir_t; + +struct _rom_dir_t { + struct aos_dir_t dir; + char * dir_start_addr; + char * dir_end_addr; + char * dir_cur_addr; + struct aos_dirent_t cur_dirent; +}; + +typedef struct _rom_dir_t romfs_dir_t; + +typedef struct romfh romfh, *Promfh; + +struct romfh { + int32_t nextfh; + int32_t spec; + int32_t size; + int32_t checksum; +}; + +typedef struct StreamBufferDef_t StreamBufferDef_t, *PStreamBufferDef_t; + +typedef struct StreamBufferDef_t * StreamBufferHandle_t; + +struct StreamBufferDef_t { + size_t xTail; + size_t xHead; + size_t xLength; + size_t xTriggerLevelBytes; + TaskHandle_t xTaskWaitingToReceive; + TaskHandle_t xTaskWaitingToSend; + uint8_t * pucBuffer; + uint8_t ucFlags; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; + UBaseType_t uxStreamBufferNumber; +}; + +typedef long __suseconds_t; + +typedef __suseconds_t suseconds_t; + +typedef struct timeval timeval, *Ptimeval; + +typedef longlong __int_least64_t; + +typedef __int_least64_t time_t; + +struct timeval { + time_t tv_sec; + suseconds_t tv_usec; + undefined field_0xc; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; +}; + +typedef struct apInfo_t apInfo_t, *PapInfo_t; + +typedef struct BssConfig_t BssConfig_t, *PBssConfig_t; + +typedef struct BssData_t BssData_t, *PBssData_t; + +typedef struct apRsnConfig_t apRsnConfig_t, *PapRsnConfig_t; + +typedef struct CommonMlmeData_t CommonMlmeData_t, *PCommonMlmeData_t; + +typedef struct Cipher_t Cipher_t, *PCipher_t; + +typedef struct Operation_t Operation_t, *POperation_t; + +typedef UINT8 IEEEtypes_SsId_t[32]; + +typedef UINT8 IEEEtypes_Len_t; + +typedef UINT8 IEEEtypes_DtimPeriod_t; + +typedef UINT16 IEEEtypes_BcnInterval_t; + +typedef UINT8 IEEEtypes_Addr_t; + +typedef IEEEtypes_Addr_t IEEEtypes_MacAddr_t[6]; + +struct Cipher_t { + UINT8 wep40:1; + UINT8 wep104:1; + UINT8 tkip:1; + UINT8 ccmp:1; + UINT8 rsvd:4; +}; + +struct Operation_t { + UINT16 keyExchange:1; + UINT16 authenticate:1; + UINT16 reserved:14; +}; + +struct apRsnConfig_t { + struct Cipher_t mcstCipher; + UINT8 mcstCipherCount; + struct Cipher_t wpaUcstCipher; + UINT8 wpaUcstCipherCount; + struct Cipher_t wpa2UcstCipher; + UINT8 wpa2UcstCipherCount; + UINT16 AuthKey; + UINT16 AuthKeyCount; + struct Operation_t Akmp; + UINT32 GrpReKeyTime; + UINT8 PSKPassPhrase[64]; + UINT8 PSKPassPhraseLen; + UINT8 PSKValue[32]; + UINT8 MaxPwsHskRetries; + UINT8 MaxGrpHskRetries; + undefined field_0x73; + UINT32 PwsHskTimeOut; + UINT32 GrpHskTimeOut; +}; + +struct CommonMlmeData_t { + IEEEtypes_SsId_t SsId; + IEEEtypes_Len_t SsIdLen; + IEEEtypes_DtimPeriod_t DtimPeriod; + IEEEtypes_BcnInterval_t BcnPeriod; + IEEEtypes_MacAddr_t BssId; + UINT16 RtsThresh; + UINT16 FragThresh; + UINT8 ShortRetryLim; + UINT8 LongRetryLim; + UINT8 MbssBcnIntFac; + UINT8 MbssCurBcnIntCnt; + UINT16 Reserved; +}; + +struct BssConfig_t { + UINT32 StaAgeOutTime; + UINT32 PsStaAgeOutTime; + struct apRsnConfig_t RsnConfig; + struct CommonMlmeData_t comData; +}; + +struct BssData_t { + BOOLEAN updatePassPhrase; + struct mm_timer_tag apMicTimer; + struct KeyData_t grpKeyData; + UINT8 GNonce[32]; + UINT32 grpRekeyBcnCntConfigured; + UINT32 grpRekeyBcnCntRemaining; +}; + +struct apInfo_t { + struct BssConfig_t bssConfig; + struct BssData_t bssData; + UINT8 ApStop_Req_Pending; + undefined field_0x11d; + undefined field_0x11e; + undefined field_0x11f; +}; + +typedef struct _txQingInfo_t _txQingInfo_t, *P_txQingInfo_t; + +typedef enum IEEEtypes_PwrMgmtMode_e { + PWR_MODE_ACTIVE=0, + PWR_MODE_PWR_SAVE=1 +} IEEEtypes_PwrMgmtMode_e; + +struct _txQingInfo_t { + enum IEEEtypes_PwrMgmtMode_e mode; +}; + +typedef struct staData_t staData_t, *PstaData_t; + +typedef struct _txQingInfo_t txQingInfo_t; + +typedef struct apKeyMgmtInfoSta_t apKeyMgmtInfoSta_t, *PapKeyMgmtInfoSta_t; + +typedef struct apKeyMgmtInfoStaRom_t apKeyMgmtInfoStaRom_t, *PapKeyMgmtInfoStaRom_t; + +typedef struct SecurityMode_t SecurityMode_t, *PSecurityMode_t; + +typedef enum keyMgmtState_e { + GRPMSG1_PENDING=5, + GRP_REKEY_MSG1_PENDING=7, + HSK_DUMMY_STATE=9, + HSK_END=10, + HSK_NOT_STARTED=0, + MSG1_PENDING=1, + MSG3_PENDING=3, + WAITING_4_GRPMSG2=6, + WAITING_4_GRP_REKEY_MSG2=8, + WAITING_4_MSG2=2, + WAITING_4_MSG4=4 +} keyMgmtState_e; + +struct SecurityMode_t { + UINT16 noRsn:1; + UINT16 wepStatic:1; + UINT16 wepDynamic:1; + UINT16 wpa:1; + UINT16 wpaNone:1; + UINT16 wpa2:1; + UINT16 cckm:1; + UINT16 wapi:1; + UINT16 wpa3:1; + UINT16 rsvd:7; +}; + +struct apKeyMgmtInfoStaRom_t { + UINT16 staRsnCap; + struct SecurityMode_t staSecType; + struct Cipher_t staUcstCipher; + UINT8 staAkmType; + enum keyMgmtState_e keyMgmtState; + undefined field_0x7; +}; + +struct apKeyMgmtInfoSta_t { + struct apKeyMgmtInfoStaRom_t rom; + UINT8 numHskTries; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + UINT32 counterLo; + UINT32 counterHi; + struct mm_timer_tag HskTimer; + UINT8 EAPOL_MIC_Key[16]; + UINT8 EAPOL_Encr_Key[16]; + UINT8 EAPOLProtoVersion; + UINT8 rsvd[3]; +}; + +struct staData_t { + txQingInfo_t pwrSaveInfo; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + struct apKeyMgmtInfoSta_t keyMgmtInfo; +}; + +typedef struct StreamBufferDef_t StreamBuffer_t; + +typedef struct chan_env_tag chan_env_tag, *Pchan_env_tag; + +typedef struct chan_ctxt_tag chan_ctxt_tag, *Pchan_ctxt_tag; + +struct chan_env_tag { + struct co_list list_free_ctxt; + struct co_list list_sched_ctxt; + struct co_list list_tbtt; + struct co_list list_tbtt_delay; + struct chan_ctxt_tag * current_channel; + struct chan_ctxt_tag * chan_switch; + struct mm_timer_tag tmr_tbtt_switch; + struct mm_timer_tag tmr_cde; + struct mm_timer_tag tmr_ctxt_op; + struct mm_timer_tag tmr_conn_less; + uint32_t cde_dur_us; + uint32_t cde_time; + uint8_t status; + uint8_t cfm_cnt; + uint8_t nb_sched_ctxt; + uint8_t pm; +}; + +struct chan_ctxt_tag { + struct co_list_hdr list_hdr; + struct mm_chan_ctxt_add_req channel; + ke_task_id_t taskid; + uint16_t nb_slots; + uint16_t nb_rem_slots; + uint16_t nb_res_slots; + uint8_t status; + uint8_t idx; + uint8_t nb_linked_vif; + uint8_t vif_index; + undefined field_0x1a; + undefined field_0x1b; +}; + +typedef struct chan_tbtt_tag chan_tbtt_tag, *Pchan_tbtt_tag; + +struct chan_tbtt_tag { + struct co_list_hdr list_hdr; + uint32_t time; + uint8_t vif_index; + uint8_t priority; + uint8_t status; + undefined field_0xb; +}; + +typedef enum chan_tbtt_status { + CHAN_TBTT_NOT_PROG=0, + CHAN_TBTT_PRESENCE=2, + CHAN_TBTT_PROG=1, + CHAN_TBTT_STATUS_MAX=3 +} chan_tbtt_status; + +typedef enum chan_env_status_bit { + CHAN_ENV_BCN_DETECT_BIT=6, + CHAN_ENV_BIT_MAX=7, + CHAN_ENV_DELAY_PROG_BIT=4, + CHAN_ENV_ROC_BIT=2, + CHAN_ENV_ROC_WAIT_BIT=0, + CHAN_ENV_SCAN_BIT=3, + CHAN_ENV_SCAN_WAIT_BIT=1, + CHAN_ENV_TIMEOUT_BIT=5 +} chan_env_status_bit; + +typedef enum chan_ctxt_status { + CHAN_CTXT_STATUS_MAX=7, + CHAN_GOTO_IDLE=2, + CHAN_NOT_PROG=1, + CHAN_NOT_SCHEDULED=0, + CHAN_PRESENT=5, + CHAN_SENDING_NOA=6, + CHAN_WAITING_END=4, + CHAN_WAIT_NOA_CFM=3 +} chan_ctxt_status; + +typedef struct txl_cfm_env_tag txl_cfm_env_tag, *Ptxl_cfm_env_tag; + +struct txl_cfm_env_tag { + struct co_list cfmlist[5]; +}; + +typedef enum rxu_msg_tag { + RXU_MGT_IND=11264, + RXU_NULL_DATA=11265 +} rxu_msg_tag; + +typedef struct rxu_mgt_ind rxu_mgt_ind, *Prxu_mgt_ind; + +struct rxu_mgt_ind { + uint16_t length; + uint16_t framectrl; + uint16_t center_freq; + uint8_t band; + uint8_t sta_idx; + uint8_t inst_nbr; + uint8_t sa[6]; + undefined field_0xf; + uint32_t tsflo; + uint32_t tsfhi; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t data_rate; + uint32_t[0] payload; +}; + +typedef struct ota_header ota_header, *Pota_header; + + +// WARNING! conflicting data type names: /DWARF/bl_sys_ota_cli.c/ota_header/anon_union_for_u - /DWARF/timers.c/tmrTimerQueueMessage/anon_union_for_u + +struct ota_header { + union anon_union_for_u u; +}; + +typedef struct ota_header ota_header_t; + +typedef struct anon_struct.conflict367 anon_struct.conflict367, *Panon_struct.conflict367; + +struct anon_struct.conflict367 { + uint8_t header[16]; + uint8_t type[4]; + uint32_t len; + uint8_t pad0[8]; + uint8_t ver_hardware[16]; + uint8_t ver_software[16]; + uint8_t sha256[32]; +}; + +typedef struct anon_struct.conflict366 anon_struct.conflict366, *Panon_struct.conflict366; + +struct anon_struct.conflict366 { + uint8_t header[16]; + uint8_t type[4]; + uint32_t len; + uint8_t pad0[8]; + uint8_t ver_hardware[16]; + uint8_t ver_software[16]; + uint8_t sha256[32]; +}; + +typedef struct wifi_pkt wifi_pkt, *Pwifi_pkt; + +struct wifi_pkt { + uint32_t pkt[4]; + void * pbuf[4]; + uint16_t len[4]; +}; + +typedef struct llc_snap llc_snap, *Pllc_snap; + +struct llc_snap { + uint16_t dsap_ssap; + uint16_t control_oui0; + uint16_t oui1_2; + uint16_t proto_id; +}; + +typedef struct llc_snap_short llc_snap_short, *Pllc_snap_short; + +struct llc_snap_short { + uint16_t dsap_ssap; + uint16_t control_oui0; + uint16_t oui1_2; +}; + +typedef void * aos_loop_t; + +typedef struct yloop_sock_t yloop_sock_t, *Pyloop_sock_t; + +struct yloop_sock_t { + int sock; + void * private_data; + void (* cb)(int, void *); +}; + +typedef struct input_event_t input_event_t, *Pinput_event_t; + +struct input_event_t { + uint32_t time; + uint16_t type; + uint16_t code; + ulong value; + ulong extra; +}; + +typedef struct yloop_ctx_t yloop_ctx_t, *Pyloop_ctx_t; + +typedef struct pollfd pollfd, *Ppollfd; + +struct pollfd { + int fd; + short events; + short revents; +}; + +struct yloop_ctx_t { + dlist_t timeouts; + struct pollfd * pollfds; + struct yloop_sock_t * readers; + int eventfd; + uint16_t max_sock; + uint8_t reader_count; + _Bool pending_terminate; + _Bool terminate; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; +}; + +typedef struct wifi_mgmr_ap_item wifi_mgmr_ap_item, *Pwifi_mgmr_ap_item; + +typedef struct wifi_mgmr_ap_item wifi_mgmr_ap_item_t; + +struct wifi_mgmr_ap_item { + char ssid[32]; + char ssid_tail[1]; + undefined field_0x21; + undefined field_0x22; + undefined field_0x23; + uint32_t ssid_len; + uint8_t bssid[6]; + uint8_t channel; + uint8_t auth; + int8_t rssi; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef enum WIFI_STATE_ENUM_LIST { + WIFI_STATE_CONNECTED_IP_GETTING=3, + WIFI_STATE_CONNECTED_IP_GOT=4, + WIFI_STATE_CONNECTING=2, + WIFI_STATE_DISCONNECT=5, + WIFI_STATE_IDLE=1, + WIFI_STATE_IFDOWN=6, + WIFI_STATE_NO_AP_FOUND=9, + WIFI_STATE_PSK_ERROR=8, + WIFI_STATE_SNIFFER=7, + WIFI_STATE_UNKNOWN=0, + WIFI_STATE_WITH_AP_CONNECTED_IP_GETTING=19, + WIFI_STATE_WITH_AP_CONNECTED_IP_GOT=20, + WIFI_STATE_WITH_AP_CONNECTING=18, + WIFI_STATE_WITH_AP_DISCONNECT=21, + WIFI_STATE_WITH_AP_IDLE=17 +} WIFI_STATE_ENUM_LIST; + +typedef struct wifi_conf wifi_conf, *Pwifi_conf; + +typedef struct wifi_conf wifi_conf_t; + +struct wifi_conf { + char country_code[3]; + undefined field_0x3; + int channel_nums; +}; + +typedef struct wifi_sta_basic_info wifi_sta_basic_info, *Pwifi_sta_basic_info; + +struct wifi_sta_basic_info { + uint8_t sta_idx; + uint8_t is_used; + uint8_t sta_mac[6]; + uint32_t tsfhi; + uint32_t tsflo; + int rssi; + uint8_t data_rate; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct wifi_mgmr_sta_connect_ind_stat_info wifi_mgmr_sta_connect_ind_stat_info, *Pwifi_mgmr_sta_connect_ind_stat_info; + +typedef struct wifi_mgmr_sta_connect_ind_stat_info wifi_mgmr_sta_connect_ind_stat_info_t; + +struct wifi_mgmr_sta_connect_ind_stat_info { + uint16_t status_code; + uint8_t type_ind; + char ssid[32]; + char psk[65]; + char pmk[64]; + uint8_t bssid[6]; + uint16_t chan_freq; + uint8_t chan_band; + undefined field_0xad; +}; + +typedef void * wifi_interface_t; + +typedef enum WIFI_SCAN_DONE_EVENT_TYPE { + WIFI_SCAN_DONE_EVENT_BUSY=1, + WIFI_SCAN_DONE_EVENT_OK=0 +} WIFI_SCAN_DONE_EVENT_TYPE; + +typedef struct rx_cntrl_pm_mon rx_cntrl_pm_mon, *Prx_cntrl_pm_mon; + +struct rx_cntrl_pm_mon { + struct mac_addr addr; + uint8_t pm_state; + _Bool mon; +}; + +typedef struct rx_cntrl_ipcdesc rx_cntrl_ipcdesc, *Prx_cntrl_ipcdesc; + +struct rx_cntrl_ipcdesc { + uint32_t host_id; +}; + +typedef struct rxu_cntrl_env_tag rxu_cntrl_env_tag, *Prxu_cntrl_env_tag; + +typedef struct rx_cntrl_rx_status rx_cntrl_rx_status, *Prx_cntrl_rx_status; + +typedef struct rx_cntrl_dupli rx_cntrl_dupli, *Prx_cntrl_dupli; + +struct rx_cntrl_dupli { + struct mac_addr last_src_addr; + uint16_t last_seq_cntl; +}; + +struct rx_cntrl_rx_status { + uint16_t frame_cntl; + uint16_t seq_cntl; + uint16_t sn; + uint8_t fn; + uint8_t tid; + uint8_t machdr_len; + uint8_t sta_idx; + uint8_t vif_idx; + uint8_t dst_idx; + undefined field_0xc; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint64_t pn; + uint32_t statinfo; + uint32_t host_buf_addr; + struct key_info_tag * key; + struct mac_addr da; + struct mac_addr sa; + uint8_t frame_info; + _Bool eth_len_present; + uint8_t payl_offset; + undefined field_0x33; + undefined field_0x34; + undefined field_0x35; + undefined field_0x36; + undefined field_0x37; +}; + +struct rxu_cntrl_env_tag { + struct rx_cntrl_rx_status rx_status; + struct co_list rxdesc_pending; + struct co_list rxdesc_ready; + struct rx_cntrl_ipcdesc rx_ipcdesc_stat; + struct co_list rxu_defrag_free; + struct co_list rxu_defrag_used; + struct rx_cntrl_dupli rxu_dupli; + struct mac_addr * mac_addr_ptr; + struct rx_cntrl_pm_mon pm_mon; + uint32_t ttr; + undefined field_0x74; + undefined field_0x75; + undefined field_0x76; + undefined field_0x77; +}; + +typedef enum rx_status_bits { + RX_STAT_ALLOC=2, + RX_STAT_COPY=32, + RX_STAT_DELETE=4, + RX_STAT_ETH_LEN_UPDATE=16, + RX_STAT_FORWARD=1, + RX_STAT_LEN_UPDATE=8 +} rx_status_bits; + +typedef struct rxu_mic_calc rxu_mic_calc, *Prxu_mic_calc; + +typedef struct mic_calc mic_calc, *Pmic_calc; + +struct mic_calc { + uint32_t mic_key_least; + uint32_t mic_key_most; + uint32_t last_m_i; + uint8_t last_m_i_len; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; +}; + +struct rxu_mic_calc { + struct mic_calc mic_calc; + uint32_t last_bytes[2]; +}; + +typedef enum rxu_cntrl_frame_info_pos { + RXU_CNTRL_MIC_CHECK_NEEDED=1, + RXU_CNTRL_NEW_MESH_PEER=4, + RXU_CNTRL_PN_CHECK_NEEDED=2 +} rxu_cntrl_frame_info_pos; + +typedef struct A_BLOCK_LINK A_BLOCK_LINK, *PA_BLOCK_LINK; + +struct A_BLOCK_LINK { + struct A_BLOCK_LINK * pxNextFreeBlock; + size_t xBlockSize; +}; + +typedef struct A_BLOCK_LINK BlockLink_t; + +typedef struct yloop_timeout_s yloop_timeout_s, *Pyloop_timeout_s; + +typedef struct yloop_timeout_s yloop_timeout_t; + +struct yloop_timeout_s { + dlist_t next; + longlong timeout_ms; + void * private_data; + void (* cb)(void *); + int ms; + undefined field_0x1c; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +typedef void (* altcp_err_fn.conflict)(void *, err_t); + +typedef struct altcp_pcb.conflict altcp_pcb.conflict, *Paltcp_pcb.conflict; + +struct altcp_pcb.conflict { + struct altcp_functions * fns; + struct altcp_pcb * inner_conn; + void * arg; + void * state; + altcp_accept_fn accept; + altcp_connected_fn connected; + err_t (* recv)(void *, struct altcp_pcb *, struct pbuf *, err_t); + err_t (* sent)(void *, struct altcp_pcb *, u16_t); + err_t (* poll)(void *, struct altcp_pcb *); + void (* err)(void *, err_t); + u8_t pollinterval; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct altcp_pcb.conflict1 altcp_pcb.conflict1, *Paltcp_pcb.conflict1; + +struct altcp_pcb.conflict1 { + struct altcp_functions * fns; + struct altcp_pcb * inner_conn; + void * arg; + void * state; + altcp_accept_fn accept; + altcp_connected_fn connected; + err_t (* recv)(void *, struct altcp_pcb *, struct pbuf *, err_t); + err_t (* sent)(void *, struct altcp_pcb *, u16_t); + err_t (* poll)(void *, struct altcp_pcb *); + void (* err)(void *, err_t); + u8_t pollinterval; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct altcp_pcb.conflict2 altcp_pcb.conflict2, *Paltcp_pcb.conflict2; + +struct altcp_pcb.conflict2 { + struct altcp_functions * fns; + struct altcp_pcb * inner_conn; + void * arg; + void * state; + altcp_accept_fn accept; + altcp_connected_fn connected; + err_t (* recv)(void *, struct altcp_pcb *, struct pbuf *, err_t); + err_t (* sent)(void *, struct altcp_pcb *, u16_t); + err_t (* poll)(void *, struct altcp_pcb *); + altcp_err_fn.conflict err; + u8_t pollinterval; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef enum bam_state_tag { + BAM_ACTIVE=1, + BAM_CHECK_ADMISSION=3, + BAM_IDLE=0, + BAM_RESET=4, + BAM_STATE_MAX=5, + BAM_WAIT_RSP=2 +} bam_state_tag; + +typedef struct co_read16_struct co_read16_struct, *Pco_read16_struct; + +struct co_read16_struct { + uint16_t val; +}; + +typedef struct co_read32_struct co_read32_struct, *Pco_read32_struct; + +struct co_read32_struct { + uint32_t val; +}; + +typedef struct mbedtls_ctr_drbg_context.conflict mbedtls_ctr_drbg_context.conflict, *Pmbedtls_ctr_drbg_context.conflict; + +struct mbedtls_ctr_drbg_context.conflict { + uchar counter[16]; + int reseed_counter; + int prediction_resistance; + size_t entropy_len; + int reseed_interval; + struct mbedtls_aes_context aes_ctx; + int (* f_entropy)(void *, uchar *, size_t); + void * p_entropy; +}; + +typedef struct tskTaskControlBlock tskTCB; + +typedef tskTCB TCB_t; + +typedef int sys_prot_t; + +typedef struct ipc_host_cb_tag ipc_host_cb_tag, *Pipc_host_cb_tag; + +struct ipc_host_cb_tag { + int (* send_data_cfm)(void *, void *); + uint8_t (* recv_data_ind)(void *, void *); + uint8_t (* recv_radar_ind)(void *, void *); + uint8_t (* recv_msg_ind)(void *, void *); + uint8_t (* recv_msgack_ind)(void *, void *); + uint8_t (* recv_dbg_ind)(void *, void *); + void (* prim_tbtt_ind)(void *); + void (* sec_tbtt_ind)(void *); +}; + +typedef struct ipc_hostbuf ipc_hostbuf, *Pipc_hostbuf; + +struct ipc_hostbuf { + void * hostid; + uint32_t dma_addr; +}; + +typedef struct ipc_host_env_tag ipc_host_env_tag, *Pipc_host_env_tag; + +struct ipc_host_env_tag { + struct ipc_host_cb_tag cb; + struct ipc_shared_env_tag.conflict30 * shared; + struct ipc_hostbuf ipc_host_rxdesc_array[2]; + uint8_t ipc_host_rxdesc_idx; + uint8_t rxdesc_nb; + uint8_t ipc_host_rxbuf_idx; + undefined field_0x37; + uint32_t rx_bufnb; + uint32_t rx_bufsz; + uint32_t txdesc_free_idx; + uint32_t txdesc_used_idx; + void * tx_host_id0[4]; + void * * tx_host_id; + struct txdesc_host * txdesc; + struct ipc_hostbuf ipc_host_msgbuf_array[8]; + uint8_t ipc_host_msge2a_idx; + undefined field_0xa1; + undefined field_0xa2; + undefined field_0xa3; + uint32_t ipc_e2amsg_bufnb; + uint32_t ipc_e2amsg_bufsz; + uint8_t msga2e_cnt; + undefined field_0xad; + undefined field_0xae; + undefined field_0xaf; + void * msga2e_hostid; + struct ipc_hostbuf ipc_host_dbgbuf_array[4]; + uint8_t ipc_host_dbg_idx; + undefined field_0xd5; + undefined field_0xd6; + undefined field_0xd7; + uint32_t ipc_dbg_bufnb; + uint32_t ipc_dbg_bufsz; + void * pthis; +}; + +typedef struct rfc_status_tag.conflict rfc_status_tag.conflict, *Prfc_status_tag.conflict; + +struct rfc_status_tag.conflict { + uint32_t pkdet_out_raw:1; + uint32_t dig_xtal_clk_dbg:1; + uint32_t clk_ble_16m_dbg:1; + uint32_t clk_rc_dbg0:1; + uint32_t clk_adcpow_dbg:1; + uint32_t clk_fetx_dbg:1; + uint32_t clk_ferx_dbg:1; + uint32_t clkpll_postdiv_outclk_dbg:1; + uint32_t clk_soc_480m_dbg:1; + uint32_t clk_soc_240m_dbg:1; + uint32_t clk_soc_192m_dbg:1; + uint32_t clk_soc_160m_dbg:1; + uint32_t clk_soc_120m_dbg:1; + uint32_t clk_soc_96m_dbg:1; + uint32_t clk_soc_80m_dbg:1; + uint32_t clk_soc_48m_dbg:1; + uint32_t clk_soc_32m_dbg:1; + uint32_t pad_pkdet_out:1; + uint32_t pad_agc_ctrl:10; + uint32_t rf_pkdet_rst_hw:1; + uint32_t rf_cbw_wifi:2; + uint32_t lo_unlocked:1; + uint32_t fsm_pu_txbuf:1; + uint32_t fsm_pu_rxbuf:1; + uint32_t fsm_pu_tosdac:1; + uint32_t fsm_pu_dac:1; + uint32_t fsm_trsw_en:1; + uint32_t fsm_pu_adc:1; + uint32_t fsm_pu_pkdet:1; + uint32_t fsm_pu_rbb:1; + uint32_t fsm_pu_rmx:1; + uint32_t fsm_pu_rmxgm:1; + uint32_t fsm_pu_lna:1; + uint32_t clk_rc_dbg2:1; + uint32_t rf_lna_ind_hw:4; + uint32_t rf_rbb_ind_hw:4; + uint32_t rf_tx_pow_lvl_hw:4; + uint32_t rf_rc_lo_rdy:1; + uint32_t rf_fsm_state:3; + uint32_t rf_rc_state:3; + uint32_t clk_rc_dbg:1; +}; + +typedef struct rfc_status_tag rfc_status_tag, *Prfc_status_tag; + +struct rfc_status_tag { + uint32_t pkdet_out_raw:1; + uint32_t dig_xtal_clk_dbg:1; + uint32_t clk_ble_16m_dbg:1; + uint32_t clk_rc_dbg0:1; + uint32_t clk_adcpow_dbg:1; + uint32_t clk_fetx_dbg:1; + uint32_t clk_ferx_dbg:1; + uint32_t clkpll_postdiv_outclk_dbg:1; + uint32_t clk_soc_480m_dbg:1; + uint32_t clk_soc_240m_dbg:1; + uint32_t clk_soc_192m_dbg:1; + uint32_t clk_soc_160m_dbg:1; + uint32_t clk_soc_120m_dbg:1; + uint32_t clk_soc_96m_dbg:1; + uint32_t clk_soc_80m_dbg:1; + uint32_t clk_soc_48m_dbg:1; + uint32_t clk_soc_32m_dbg:1; + uint32_t pad_pkdet_out:1; + uint32_t pad_agc_ctrl:10; + uint32_t rf_pkdet_rst_hw:1; + uint32_t rf_cbw_wifi:2; + uint32_t lo_unlocked:1; + uint32_t fsm_pu_txbuf:1; + uint32_t fsm_pu_rxbuf:1; + uint32_t fsm_pu_tosdac:1; + uint32_t fsm_pu_dac:1; + uint32_t fsm_trsw_en:1; + uint32_t fsm_pu_adc:1; + uint32_t fsm_pu_pkdet:1; + uint32_t fsm_pu_rbb:1; + uint32_t fsm_pu_rmx:1; + uint32_t fsm_pu_rmxgm:1; + uint32_t fsm_pu_lna:1; + uint32_t clk_rc_dbg2:1; + uint32_t rf_lna_ind_hw:4; + uint32_t rf_rbb_ind_hw:4; + uint32_t rf_tx_pow_lvl_hw:4; + uint32_t rf_rc_lo_rdy:1; + uint32_t rf_fsm_state:3; + uint32_t rf_rc_state:3; + uint32_t clk_rc_dbg:1; +}; + +typedef struct sm_connect_req.conflict sm_connect_req.conflict, *Psm_connect_req.conflict; + +typedef struct mac_addr.conflict57 mac_addr.conflict57, *Pmac_addr.conflict57; + +struct mac_addr.conflict57 { + u8_l array[6]; +}; + +struct sm_connect_req.conflict { + struct mac_ssid ssid; + struct mac_addr.conflict57 bssid; + struct scan_chan_tag chan; + undefined field_0x2e; + undefined field_0x2f; + u32_l flags; + u16_l ctrl_port_ethertype; + u16_l ie_len; + u16_l listen_interval; + bool_l dont_wait_bcmc; + u8_l auth_type; + u8_l uapsd_queues; + u8_l vif_idx; + undefined field_0x3e; + undefined field_0x3f; + u32_l ie_buf[64]; + _Bool is_supplicant_enabled; + uint8_t phrase[64]; + uint8_t phrase_pmk[64]; + undefined field_0x1c1; + undefined field_0x1c2; + undefined field_0x1c3; +}; + +typedef struct mm_set_denoise_req mm_set_denoise_req, *Pmm_set_denoise_req; + +struct mm_set_denoise_req { + u8_l denoise_mode; +}; + +typedef struct scanu_result_ind scanu_result_ind, *Pscanu_result_ind; + +struct scanu_result_ind { + uint16_t length; + uint16_t framectrl; + uint16_t center_freq; + uint8_t band; + uint8_t sta_idx; + uint8_t inst_nbr; + uint8_t sa[6]; + undefined field_0xf; + uint32_t tsflo; + uint32_t tsfhi; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t data_rate; + uint32_t[0] payload; +}; + +typedef struct lmac_msg lmac_msg, *Plmac_msg; + +typedef u16 lmac_msg_id_t; + +typedef u16 lmac_task_id_t; + +typedef uint32_t u32.conflict1; + +struct lmac_msg { + lmac_msg_id_t id; + lmac_task_id_t dest_id; + lmac_task_id_t src_id; + u16 param_len; + u32.conflict1[0] param; +}; + +typedef struct Cipher_t.conflict1 Cipher_t.conflict1, *PCipher_t.conflict1; + +struct Cipher_t.conflict1 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct anon_struct.conflict224 anon_struct.conflict224, *Panon_struct.conflict224; + +struct anon_struct.conflict224 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct anon_struct.conflict225 anon_struct.conflict225, *Panon_struct.conflict225; + +struct anon_struct.conflict225 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct anon_struct.conflict239 anon_struct.conflict239, *Panon_struct.conflict239; + +struct anon_struct.conflict239 { + uint32_t task; + uint32_t element; + uint32_t type; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct mm_channel_switch_ind mm_channel_switch_ind, *Pmm_channel_switch_ind; + +struct mm_channel_switch_ind { + u8_l chan_index; + bool_l roc; + u8_l vif_index; + bool_l roc_tdls; +}; + +typedef struct Cipher_t.conflict Cipher_t.conflict, *PCipher_t.conflict; + +struct Cipher_t.conflict { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef enum tdls_msg_tag { + TDLS_CANCEL_CHAN_SWITCH_CFM=3077, + TDLS_CANCEL_CHAN_SWITCH_REQ=3076, + TDLS_CHAN_SWITCH_BASE_IND=3075, + TDLS_CHAN_SWITCH_CFM=3073, + TDLS_CHAN_SWITCH_IND=3074, + TDLS_CHAN_SWITCH_REQ=3072, + TDLS_MAX=3081, + TDLS_PEER_PS_IND=3078, + TDLS_PEER_TRAFFIC_IND_CFM=3080, + TDLS_PEER_TRAFFIC_IND_REQ=3079 +} tdls_msg_tag; + +typedef struct anon_struct.conflict235 anon_struct.conflict235, *Panon_struct.conflict235; + +struct anon_struct.conflict235 { + uint32_t task; + uint32_t element; +}; + +typedef struct anon_struct.conflict236 anon_struct.conflict236, *Panon_struct.conflict236; + +struct anon_struct.conflict236 { + uint32_t task; + uint32_t element; + uint32_t type; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct anon_struct.conflict237 anon_struct.conflict237, *Panon_struct.conflict237; + +struct anon_struct.conflict237 { + uint32_t task; + uint32_t element; +}; + +typedef struct anon_struct.conflict238 anon_struct.conflict238, *Panon_struct.conflict238; + +struct anon_struct.conflict238 { + uint32_t task; + uint32_t element; +}; + +typedef struct anon_struct.conflict359 anon_struct.conflict359, *Panon_struct.conflict359; + +struct anon_struct.conflict359 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct anon_struct.conflict352 anon_struct.conflict352, *Panon_struct.conflict352; + +struct anon_struct.conflict352 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct anon_struct.conflict233 anon_struct.conflict233, *Panon_struct.conflict233; + +struct anon_struct.conflict233 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct anon_struct.conflict234 anon_struct.conflict234, *Panon_struct.conflict234; + +struct anon_struct.conflict234 { + uint32_t task; + uint32_t element; +}; + +typedef struct anon_struct.conflict311 anon_struct.conflict311, *Panon_struct.conflict311; + +struct anon_struct.conflict311 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct anon_struct.conflict316 anon_struct.conflict316, *Panon_struct.conflict316; + +struct anon_struct.conflict316 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef enum mm_msg_tag.conflict { + MM_ADD_IF_CFM=7, + MM_ADD_IF_REQ=6, + MM_BA_ADD_CFM=41, + MM_BA_ADD_REQ=40, + MM_BA_DEL_CFM=43, + MM_BA_DEL_REQ=42, + MM_BCN_CHANGE_CFM=64, + MM_BCN_CHANGE_REQ=63, + MM_BFMER_ENABLE_REQ=80, + MM_CFG_RSSI_REQ=86, + MM_CHANNEL_PRE_SWITCH_IND=69, + MM_CHANNEL_SURVEY_IND=79, + MM_CHANNEL_SWITCH_IND=68, + MM_CHAN_CTXT_ADD_CFM=52, + MM_CHAN_CTXT_ADD_REQ=51, + MM_CHAN_CTXT_DEL_CFM=54, + MM_CHAN_CTXT_DEL_REQ=53, + MM_CHAN_CTXT_LINK_CFM=56, + MM_CHAN_CTXT_LINK_REQ=55, + MM_CHAN_CTXT_SCHED_CFM=62, + MM_CHAN_CTXT_SCHED_REQ=61, + MM_CHAN_CTXT_UNLINK_CFM=58, + MM_CHAN_CTXT_UNLINK_REQ=57, + MM_CHAN_CTXT_UPDATE_CFM=60, + MM_CHAN_CTXT_UPDATE_REQ=59, + MM_CONNECTION_LOSS_IND=67, + MM_CSA_COUNTER_IND=78, + MM_CSA_FINISH_IND=88, + MM_CSA_TRAFFIC_IND=89, + MM_DENOISE_REQ=48, + MM_KEY_ADD_CFM=37, + MM_KEY_ADD_REQ=36, + MM_KEY_DEL_CFM=39, + MM_KEY_DEL_REQ=38, + MM_MAX=96, + MM_MONITOR_CFM=93, + MM_MONITOR_CHANNEL_CFM=95, + MM_MONITOR_CHANNEL_REQ=94, + MM_MONITOR_REQ=92, + MM_MU_GROUP_UPDATE_CFM=91, + MM_MU_GROUP_UPDATE_REQ=90, + MM_P2P_NOA_UPD_IND=85, + MM_P2P_VIF_PS_CHANGE_IND=77, + MM_PRIMARY_TBTT_IND=44, + MM_PS_CHANGE_IND=73, + MM_REMAIN_ON_CHANNEL_CFM=71, + MM_REMAIN_ON_CHANNEL_EXP_IND=72, + MM_REMAIN_ON_CHANNEL_REQ=70, + MM_REMOVE_IF_CFM=9, + MM_REMOVE_IF_REQ=8, + MM_RESET_CFM=1, + MM_RESET_REQ=0, + MM_RSSI_STATUS_IND=87, + MM_SECONDARY_TBTT_IND=45, + MM_SET_BASIC_RATES_CFM=23, + MM_SET_BASIC_RATES_REQ=22, + MM_SET_BEACON_INT_CFM=21, + MM_SET_BEACON_INT_REQ=20, + MM_SET_BSSID_CFM=25, + MM_SET_BSSID_REQ=24, + MM_SET_CHANNEL_CFM=17, + MM_SET_CHANNEL_REQ=16, + MM_SET_DTIM_CFM=19, + MM_SET_DTIM_REQ=18, + MM_SET_EDCA_CFM=27, + MM_SET_EDCA_REQ=26, + MM_SET_FILTER_CFM=15, + MM_SET_FILTER_REQ=14, + MM_SET_IDLE_CFM=35, + MM_SET_IDLE_REQ=34, + MM_SET_MODE_CFM=29, + MM_SET_MODE_REQ=28, + MM_SET_P2P_NOA_CFM=83, + MM_SET_P2P_NOA_REQ=81, + MM_SET_P2P_OPPPS_CFM=84, + MM_SET_P2P_OPPPS_REQ=82, + MM_SET_POWER_CFM=47, + MM_SET_POWER_REQ=46, + MM_SET_PS_MODE_CFM=50, + MM_SET_PS_MODE_REQ=49, + MM_SET_PS_OPTIONS_CFM=76, + MM_SET_PS_OPTIONS_REQ=75, + MM_SET_SLOTTIME_CFM=33, + MM_SET_SLOTTIME_REQ=32, + MM_SET_VIF_STATE_CFM=31, + MM_SET_VIF_STATE_REQ=30, + MM_START_CFM=3, + MM_START_REQ=2, + MM_STA_ADD_CFM=11, + MM_STA_ADD_REQ=10, + MM_STA_DEL_CFM=13, + MM_STA_DEL_REQ=12, + MM_TIM_UPDATE_CFM=66, + MM_TIM_UPDATE_REQ=65, + MM_TRAFFIC_REQ_IND=74, + MM_VERSION_CFM=5, + MM_VERSION_REQ=4 +} mm_msg_tag.conflict; + +typedef struct anon_struct.conflict362 anon_struct.conflict362, *Panon_struct.conflict362; + +struct anon_struct.conflict362 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct sm_connect_ind.conflict sm_connect_ind.conflict, *Psm_connect_ind.conflict; + +typedef struct mac_addr.conflict75 mac_addr.conflict75, *Pmac_addr.conflict75; + +struct mac_addr.conflict75 { + u8_l array[6]; +}; + +struct sm_connect_ind.conflict { + u16_l status_code; + struct mac_addr.conflict75 bssid; + bool_l roamed; + u8_l vif_idx; + u8_l ap_idx; + u8_l ch_idx; + bool_l qos; + u8_l acm; + u16_l assoc_req_ie_len; + u16_l assoc_rsp_ie_len; + undefined field_0x12; + undefined field_0x13; + u32_l assoc_ie_buf[200]; + u16_l aid; + u8_l band; + undefined field_0x337; + u16_l center_freq; + u8_l width; + undefined field_0x33b; + u32_l center_freq1; + u32_l center_freq2; + u32_l ac_param[4]; +}; + +typedef struct mm_add_if_req.conflict mm_add_if_req.conflict, *Pmm_add_if_req.conflict; + +typedef struct mac_addr.conflict55 mac_addr.conflict55, *Pmac_addr.conflict55; + +struct mac_addr.conflict55 { + u8_l array[6]; +}; + +struct mm_add_if_req.conflict { + u8_l type; + struct mac_addr.conflict55 addr; + bool_l p2p; +}; + +typedef struct anon_struct.conflict244 anon_struct.conflict244, *Panon_struct.conflict244; + +struct anon_struct.conflict244 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef enum mesh_msg_tag { + MESH_MAX=9232, + MESH_PATH_CREATE_CFM=9225, + MESH_PATH_CREATE_REQ=9224, + MESH_PATH_UPDATE_CFM=9227, + MESH_PATH_UPDATE_IND=9230, + MESH_PATH_UPDATE_REQ=9226, + MESH_PEER_INFO_REQ=9222, + MESH_PEER_INFO_RSP=9223, + MESH_PEER_UPDATE_IND=9229, + MESH_PEER_UPDATE_NTF=9229, + MESH_PROXY_ADD_REQ=9228, + MESH_PROXY_UPDATE_IND=9231, + MESH_START_CFM=9217, + MESH_START_REQ=9216, + MESH_STOP_CFM=9219, + MESH_STOP_REQ=9218, + MESH_UPDATE_CFM=9221, + MESH_UPDATE_REQ=9220 +} mesh_msg_tag; + +typedef struct apm_sta_add_ind.conflict apm_sta_add_ind.conflict, *Papm_sta_add_ind.conflict; + +typedef struct mac_addr.conflict76 mac_addr.conflict76, *Pmac_addr.conflict76; + +struct mac_addr.conflict76 { + u8_l array[6]; +}; + +struct apm_sta_add_ind.conflict { + uint32_t flags; + struct mac_addr.conflict76 sta_addr; + uint8_t vif_idx; + uint8_t sta_idx; + int8_t rssi; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t tsflo; + uint32_t tsfhi; + uint8_t data_rate; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; +}; + +typedef struct scanu_start_req.conflict scanu_start_req.conflict, *Pscanu_start_req.conflict; + +typedef struct mac_addr.conflict56 mac_addr.conflict56, *Pmac_addr.conflict56; + +struct mac_addr.conflict56 { + u8_l array[6]; +}; + +struct scanu_start_req.conflict { + struct scan_chan_tag chan[42]; + struct mac_ssid ssid[2]; + struct mac_addr.conflict56 bssid; + undefined field_0x146; + undefined field_0x147; + u32_l add_ies; + u16_l add_ie_len; + u8_l vif_idx; + u8_l chan_cnt; + u8_l ssid_cnt; + _Bool no_cck; + undefined field_0x152; + undefined field_0x153; +}; + +typedef struct adc_ctx.conflict adc_ctx.conflict, *Padc_ctx.conflict; + +struct adc_ctx.conflict { + int mode; + uint32_t * channel_data; + void * adc_lli; + int lli_flag; + uint32_t chan_init_table; + uint32_t data_size; + void (* cb)(int, uint32_t *, uint32_t); +}; + +typedef struct adc_ctx adc_ctx, *Padc_ctx; + +struct adc_ctx { + int mode; + uint32_t * channel_data; + void * adc_lli; + int lli_flag; + uint32_t chan_init_table; + uint32_t data_size; + void (* cb)(int, uint32_t *, uint32_t); +}; + +typedef struct adc_ctx.conflict1 adc_ctx.conflict1, *Padc_ctx.conflict1; + +typedef struct adc_ctx.conflict1 adc_ctx_t.conflict; + +struct adc_ctx.conflict1 { + int mode; + uint32_t * channel_data; + void * adc_lli; + int lli_flag; + uint32_t chan_init_table; + uint32_t data_size; + void (* cb)(int, uint32_t *, uint32_t); +}; + +typedef struct adc_ctx.conflict adc_ctx_t; + + +// WARNING! conflicting data type names: /DWARF/cli.c/handle_input/anon_struct - /DWARF/reent.h/anon_struct + +typedef struct cli_command cli_command, *Pcli_command; + +struct cli_command { + char * name; + char * help; + void (* function)(char *, int, int, char * *); +}; + +typedef struct cli_st cli_st, *Pcli_st; + +struct cli_st { + int initialized; + int echo_disabled; + struct cli_command * static_cmds; + struct cli_command * dynamic_cmds[8]; + uint num_static_cmds; + uint num_commands; + uint bp; + char inbuf[256]; + char * outbuf; + int his_idx; + int his_cur; + char history[256]; +}; + +typedef struct pmkElement_t pmkElement_t, *PpmkElement_t; + +typedef union anon_union_for_key anon_union_for_key, *Panon_union_for_key; + +union anon_union_for_key { + IEEEtypes_MacAddr_t Bssid; + char Ssid[32]; +}; + +struct pmkElement_t { + union anon_union_for_key key; + UINT8 PMK[32]; + UINT8 length; + UINT8 psk_length; + SINT8 replacementRank; +}; + +typedef union anon_union.conflict12 anon_union.conflict12, *Panon_union.conflict12; + +union anon_union.conflict12 { + IEEEtypes_MacAddr_t Bssid; + char Ssid[32]; +}; + +typedef struct net_device net_device, *Pnet_device; + +typedef struct bl_hw bl_hw, *Pbl_hw; + +typedef struct bl_cmd_mgr bl_cmd_mgr, *Pbl_cmd_mgr; + +typedef struct bl_cmd bl_cmd, *Pbl_cmd; + +typedef struct bl_stats bl_stats, *Pbl_stats; + +typedef struct bl_vif bl_vif, *Pbl_vif; + +typedef struct bl_sta bl_sta, *Pbl_sta; + +typedef struct bl_mod_params bl_mod_params, *Pbl_mod_params; + +typedef enum RWNX_INTERFACE_STATUS { + RWNX_INTERFACE_STATUS_DOWN=0, + RWNX_INTERFACE_STATUS_UP=1 +} RWNX_INTERFACE_STATUS; + +typedef enum bl_cmd_mgr_state { + RWNX_CMD_MGR_STATE_CRASHED=2, + RWNX_CMD_MGR_STATE_DEINIT=0, + RWNX_CMD_MGR_STATE_INITED=1 +} bl_cmd_mgr_state; + +typedef uint32_t u32.conflict8; + +typedef uint32_t u32.conflict9; + +typedef SemaphoreHandle_t os_mutex_t; + +typedef struct xSTATIC_EVENT_GROUP xSTATIC_EVENT_GROUP, *PxSTATIC_EVENT_GROUP; + +typedef struct xSTATIC_EVENT_GROUP StaticEventGroup_t; + +typedef StaticEventGroup_t os_event_t; + +typedef uint32_t u32.conflict4; + +typedef struct net_device_stats net_device_stats, *Pnet_device_stats; + +typedef union anon_union_for_field_13 anon_union_for_field_13, *Panon_union_for_field_13; + +typedef struct mac_addr.conflict36 mac_addr.conflict36, *Pmac_addr.conflict36; + +typedef struct xSTATIC_LIST xSTATIC_LIST, *PxSTATIC_LIST; + +typedef struct xSTATIC_LIST StaticList_t; + +typedef struct anon_struct.conflict226 anon_struct.conflict226, *Panon_struct.conflict226; + +typedef struct anon_struct.conflict227 anon_struct.conflict227, *Panon_struct.conflict227; + +typedef struct anon_struct.conflict228 anon_struct.conflict228, *Panon_struct.conflict228; + +typedef struct xSTATIC_MINI_LIST_ITEM xSTATIC_MINI_LIST_ITEM, *PxSTATIC_MINI_LIST_ITEM; + +typedef struct xSTATIC_MINI_LIST_ITEM StaticMiniListItem_t; + +typedef struct bl_bcn bl_bcn, *Pbl_bcn; + +struct bl_bcn { + u8 * head; + u8 * tail; + u8 * ies; + size_t head_len; + size_t tail_len; + size_t ies_len; + size_t tim_len; + size_t len; + u8 dtim; + undefined field_0x21; + undefined field_0x22; + undefined field_0x23; +}; + +struct bl_mod_params { + _Bool ht_on; + _Bool vht_on; + undefined field_0x2; + undefined field_0x3; + int mcs_map; + _Bool ldpc_on; + _Bool vht_stbc; + undefined field_0xa; + undefined field_0xb; + int phy_cfg; + int uapsd_timeout; + _Bool ap_uapsd_on; + _Bool sgi; + _Bool sgi80; + _Bool use_2040; + _Bool use_80; + _Bool custregd; + undefined field_0x1a; + undefined field_0x1b; + int nss; + _Bool bfmee; + _Bool bfmer; + _Bool mesh; + _Bool murx; + _Bool mutx; + _Bool mutx_on; + undefined field_0x26; + undefined field_0x27; + uint roc_dur_max; + int listen_itv; + _Bool listen_bcmc; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + int lp_clk_ppm; + _Bool ps_on; + undefined field_0x39; + undefined field_0x3a; + undefined field_0x3b; + int tx_lft; + int amsdu_maxnb; + int uapsd_queues; + _Bool tdls; + undefined field_0x49; + undefined field_0x4a; + undefined field_0x4b; +}; + +struct anon_struct.conflict228 { + struct bl_vif * master; + struct bl_sta * sta_4a; +}; + +struct anon_struct.conflict226 { + struct bl_sta * ap; + struct bl_sta * tdls_sta; +}; + +struct anon_struct.conflict227 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +union anon_union_for_field_13 { + struct anon_struct.conflict226 sta; + struct anon_struct.conflict227 ap; + struct anon_struct.conflict228 ap_vlan; +}; + +struct net_device_stats { + ulong rx_packets; + ulong tx_packets; + ulong rx_bytes; + ulong tx_bytes; + ulong rx_errors; + ulong tx_errors; + ulong rx_dropped; + ulong tx_dropped; + ulong multicast; + ulong collisions; + ulong rx_length_errors; + ulong rx_over_errors; + ulong rx_crc_errors; + ulong rx_frame_errors; + ulong rx_fifo_errors; + ulong rx_missed_errors; + ulong tx_aborted_errors; + ulong tx_carrier_errors; + ulong tx_fifo_errors; + ulong tx_heartbeat_errors; + ulong tx_window_errors; + ulong rx_compressed; + ulong tx_compressed; +}; + +struct bl_vif { + struct list_head list; + struct netif * dev; + struct bl_hw * bl_hw; + struct net_device_stats net_stats; + u8 drv_vif_index; + u8 vif_index; + u8 ch_index; + _Bool up; + _Bool use_4addr; + _Bool is_resending; + _Bool user_mpm; + _Bool roc_tdls; + u8 tdls_status; + undefined field_0x75; + undefined field_0x76; + undefined field_0x77; + union anon_union_for_field_13 field_13; +}; + +struct net_device { + struct bl_hw * bl_hw; +}; + +struct bl_stats { + int cfm_balance; + ulong last_rx; + ulong last_tx; + int ampdus_tx[64]; + int ampdus_rx[64]; + int ampdus_rx_map[4]; + int ampdus_rx_miss; + int amsdus_rx[64]; +}; + +struct xSTATIC_MINI_LIST_ITEM { + TickType_t xDummy2; + void * pvDummy3[2]; +}; + +struct xSTATIC_LIST { + UBaseType_t uxDummy2; + void * pvDummy3; + StaticMiniListItem_t xDummy4; +}; + +struct xSTATIC_EVENT_GROUP { + TickType_t xDummy1; + StaticList_t xDummy2; + UBaseType_t uxDummy3; + uint8_t ucDummy4; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +struct bl_cmd { + struct list_head list; + lmac_msg_id_t id; + lmac_msg_id_t reqid; + struct lmac_msg * a2e_msg; + char * e2a_msg; + u32.conflict3 tkn; + u16 flags; + undefined field_0x1a; + undefined field_0x1b; + os_event_t complete; + u32.conflict4 result; +}; + +struct bl_cmd_mgr { + enum bl_cmd_mgr_state state; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + u32.conflict7 next_tkn; + u32.conflict8 queue_sz; + u32.conflict9 max_queue_sz; + struct list_head cmds; + os_mutex_t lock; + int (* queue)(struct bl_cmd_mgr *, struct bl_cmd *); + int (* llind)(struct bl_cmd_mgr *, struct bl_cmd *); + int (* msgind)(struct bl_cmd_mgr *, struct ipc_e2a_msg *, int (* )(struct bl_hw *, struct bl_cmd *, struct ipc_e2a_msg *)); + void (* print)(struct bl_cmd_mgr *); + void (* drain)(struct bl_cmd_mgr *); +}; + +struct mac_addr.conflict36 { + u8_l array[6]; +}; + +struct bl_sta { + struct mac_addr.conflict36 sta_addr; + u16 aid; + u8 is_used; + u8 sta_idx; + u8 vif_idx; + u8 vlan_idx; + int8_t rssi; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t tsflo; + uint32_t tsfhi; + uint8_t data_rate; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; +}; + +struct bl_hw { + int is_up; + struct bl_cmd_mgr cmd_mgr; + struct ipc_host_env_tag * ipc_env; + struct bl_stats stats; + struct list_head vifs; + struct bl_vif vif_table[12]; + struct bl_sta sta_table[12]; + ulong drv_flags; + struct mm_version_cfm version_cfm; + struct bl_mod_params * mod_params; + enum wiphy_flags flags; + struct ieee80211_sta_ht_cap ht_cap; + u8 vif_started; + undefined field_0xe1b; + int vif_index_sta; + int vif_index_ap; + int sta_idx; + int ap_bcmc_idx; + struct phy_cfg_tag phy_config; + enum RWNX_INTERFACE_STATUS status; + undefined field_0xe6d; + undefined field_0xe6e; + undefined field_0xe6f; +}; + +typedef struct bl_wifi_ap_info bl_wifi_ap_info, *Pbl_wifi_ap_info; + +struct bl_wifi_ap_info { + uint8_t ssid[33]; + uint8_t psk[65]; + uint8_t chan; +}; + +typedef struct bl_wifi_ap_info bl_wifi_ap_info_t; + +typedef enum ChanBand_e { + Band_2_4_GHz=0, + Band_4_GHz=2, + Band_5_GHz=1 +} ChanBand_e; + +typedef enum IEEEtypes_ElementId_e { + ELEM_ID_2040_BSS_COEXISTENCE=72, + ELEM_ID_2040_BSS_INTOL_CHRPT=73, + ELEM_ID_AID=-59, + ELEM_ID_ANTENNA_INFO=64, + ELEM_ID_AP_CHANNEL_REPORT=51, + ELEM_ID_BSS_ACCESS_DELAY=63, + ELEM_ID_BSS_AC_ACCESS_DELAY=68, + ELEM_ID_BSS_AVAIL_ADM_CAP=67, + ELEM_ID_BSS_LOAD=11, + ELEM_ID_BSS_MAX_IDLE_PERIOD=90, + ELEM_ID_CF_PARAM_SET=4, + ELEM_ID_CHALLENGE_TEXT=16, + ELEM_ID_CHANNEL_SWITCH_ANN=37, + ELEM_ID_CHANNEL_USAGE=97, + ELEM_ID_COLLOC_INTF_REPORT=96, + ELEM_ID_COUNTRY=7, + ELEM_ID_DIAG_REPORT=81, + ELEM_ID_DIAG_REQUEST=80, + ELEM_ID_DMS_REQUEST=99, + ELEM_ID_DMS_RESPONSE=100, + ELEM_ID_DSE_REGISTERED_LOC=58, + ELEM_ID_DS_PARAM_SET=3, + ELEM_ID_EDCA_PARAM_SET=12, + ELEM_ID_ERP_INFO=42, + ELEM_ID_EVENT_REPORT=79, + ELEM_ID_EVENT_REQUEST=78, + ELEM_ID_EXTENSION=-1, + ELEM_ID_EXT_ASSOC_DELAY_INFO=1, + ELEM_ID_EXT_CAPABILITIES=127, + ELEM_ID_EXT_CHAN_SWITCH_ANN=60, + ELEM_ID_EXT_ESTIMATED_SERVICE_PARAMS=11, + ELEM_ID_EXT_EXTENDED_REQUEST=10, + ELEM_ID_EXT_FILS_HLP_CONTAINER=5, + ELEM_ID_EXT_FILS_IP_ADDR_ASSIGN=6, + ELEM_ID_EXT_FILS_KEY_CONFIRM=3, + ELEM_ID_EXT_FILS_NONCE=13, + ELEM_ID_EXT_FILS_PUBLIC_KEY=12, + ELEM_ID_EXT_FILS_REQ_PARAMS=2, + ELEM_ID_EXT_FILS_SESSION=4, + ELEM_ID_EXT_FILS_WRAPPED_DATA=8, + ELEM_ID_EXT_FTM_SYNC_INFO=9, + ELEM_ID_EXT_FUTURE_CHANNEL_GUIDANCE=14, + ELEM_ID_EXT_HE_CAPABILITIES=35, + ELEM_ID_EXT_HE_OPERATION=36, + ELEM_ID_EXT_KEY_DELIVERY=7, + ELEM_ID_EXT_OWE_DH_PARAM=32, + ELEM_ID_EXT_PASSWORD_IDENTIFIER=33, + ELEM_ID_EXT_SUPPORTED_RATES=50, + ELEM_ID_FAST_BSS_TRANS=55, + ELEM_ID_FH_PARAM_SET=2, + ELEM_ID_FMS_DESCRIPTOR=86, + ELEM_ID_FMS_REQUEST=87, + ELEM_ID_FMS_RESPONSE=88, + ELEM_ID_HOP_PARAM=8, + ELEM_ID_HOP_TABLE=9, + ELEM_ID_HT_CAPABILITY=45, + ELEM_ID_HT_INFORMATION=61, + ELEM_ID_IBSS_DFS=41, + ELEM_ID_IBSS_PARAM_SET=6, + ELEM_ID_LINK_ID=101, + ELEM_ID_LOCATION_PARAM=82, + ELEM_ID_MANAGEMENT_MIC=76, + ELEM_ID_MBSSID_INDEX=85, + ELEM_ID_MEASUREMENT_REQ=38, + ELEM_ID_MEASUREMENT_RPT=39, + ELEM_ID_MEAS_PILOT_TX_INFO=66, + ELEM_ID_MOBILITY_DOMAIN=54, + ELEM_ID_MULTI_BSSID=71, + ELEM_ID_NEIGHBOR_REPORT=52, + ELEM_ID_NONTRANS_BSSID_CAP=83, + ELEM_ID_OBSS_SCAN_PARAM=74, + ELEM_ID_POWER_CAPABILITY=33, + ELEM_ID_POWER_CONSTRAINT=32, + ELEM_ID_PTI_CONTROL=105, + ELEM_ID_PU_BUFFER_STATUS=106, + ELEM_ID_QOS_CAPABILITY=46, + ELEM_ID_QOS_TRAFFIC_CAP=89, + ELEM_ID_QUIET=40, + ELEM_ID_RCPI=53, + ELEM_ID_REQUEST=10, + ELEM_ID_RIC_DATA=57, + ELEM_ID_RIC_DESCRIPTOR=75, + ELEM_ID_RRM_ENABLED_CAP=70, + ELEM_ID_RSN=48, + ELEM_ID_RSNI=65, + ELEM_ID_SCHEDULE=15, + ELEM_ID_SECONDARY_CHAN_OFFSET=62, + ELEM_ID_SSID=0, + ELEM_ID_SSID_LIST=84, + ELEM_ID_SUPPORTED_CHANNELS=36, + ELEM_ID_SUPPORTED_RATES=1, + ELEM_ID_SUPPORTED_REGCLASS=59, + ELEM_ID_TCLAS=14, + ELEM_ID_TCLAS_PROCESS=44, + ELEM_ID_TDLS_CS_TIMING=104, + ELEM_ID_TFS_REQUEST=91, + ELEM_ID_TFS_RESPONSE=92, + ELEM_ID_TIM=5, + ELEM_ID_TIMEOUT_INTERVAL=56, + ELEM_ID_TIME_ZONE=98, + ELEM_ID_TIM_BCAST_REQUEST=94, + ELEM_ID_TIM_BCAST_RESPONSE=95, + ELEM_ID_TPC_REPORT=35, + ELEM_ID_TPC_REQUEST=34, + ELEM_ID_TSPEC=13, + ELEM_ID_TS_DELAY=43, + ELEM_ID_VENDOR_SPECIFIC=-35, + ELEM_ID_VHT_CAPABILITIES=-65, + ELEM_ID_VHT_OPERATION=-64, + ELEM_ID_VHT_OP_MODE_NOTIFICATION=-57, + ELEM_ID_WAKEUP_SCHEDULE=102, + ELEM_ID_WAPI=68, + ELEM_ID_WIDE_BAND_CHAN_SW=-63, + ELEM_ID_WNM_SLEEP_MODE=93, + SUBELEM_ID_GTK=2, + SUBELEM_ID_IGTK=4, + SUBELEM_ID_PMK_R0_KEY_HOLDER_ID=3, + SUBELEM_ID_PMK_R1_KEY_HOLDER_ID=1, + SUBELEM_ID_REPORTED_FRAME_BODY=1, + SUBELEM_ID_REPORTING_DETAIL=2 +} IEEEtypes_ElementId_e; + +typedef enum Chan2Offset_e { + SECONDARY_CHAN_ABOVE=1, + SECONDARY_CHAN_BELOW=3, + SECONDARY_CHAN_NONE=0 +} Chan2Offset_e; + +typedef enum IEEEtypes_8021x_CodeType_e { + IEEE_8021X_CODE_TYPE_FAILURE=4, + IEEE_8021X_CODE_TYPE_REQUEST=1, + IEEE_8021X_CODE_TYPE_RESPONSE=2, + IEEE_8021X_CODE_TYPE_SUCCESS=3 +} IEEEtypes_8021x_CodeType_e; + +typedef struct IEEEtypes_WPAElement_t IEEEtypes_WPAElement_t, *PIEEEtypes_WPAElement_t; + +struct IEEEtypes_WPAElement_t { + enum IEEEtypes_ElementId_e ElementId; + IEEEtypes_Len_t Len; + UINT8 OuiType[4]; + UINT16 Ver; + UINT8 GrpKeyCipher[4]; + UINT16 PwsKeyCnt; + UINT8 PwsKeyCipherList[4]; + UINT16 AuthKeyCnt; + UINT8 AuthKeyList[4]; +}; + +typedef enum IEEEtypes_KDEDataType_e { + KDE_DATA_TYPE_ERROR=8, + KDE_DATA_TYPE_GTK=1, + KDE_DATA_TYPE_IGTK=9, + KDE_DATA_TYPE_LIFETIME=7, + KDE_DATA_TYPE_MACADDR=3, + KDE_DATA_TYPE_NONCE=6, + KDE_DATA_TYPE_PMKID=4, + KDE_DATA_TYPE_RESERVED=0, + KDE_DATA_TYPE_RESERVED2=2, + KDE_DATA_TYPE_SMK=5 +} IEEEtypes_KDEDataType_e; + +typedef struct IEEEtypes_RSNCapability_t IEEEtypes_RSNCapability_t, *PIEEEtypes_RSNCapability_t; + +struct IEEEtypes_RSNCapability_t { + UINT8 PreAuth:1; + UINT8 NoPairwise:1; + UINT8 PtksaReplayCtr:2; + UINT8 GtksaReplayCtr:2; + UINT8 MFPR:1; + UINT8 MFPC:1; + UINT8 Reserved_8:1; + UINT8 PeerkeyEnabled:1; + UINT8 SppAmsduCap:1; + UINT8 SppAmsduReq:1; + UINT8 PBAC:1; + UINT8 Reserved_13_15:3; +}; + +typedef struct BandConfig_t BandConfig_t, *PBandConfig_t; + +typedef enum ChanWidth_e { + ChanWidth_10_MHz=1, + ChanWidth_20_MHz=0, + ChanWidth_40_MHz=2, + ChanWidth_80_MHz=3 +} ChanWidth_e; + +typedef enum ScanMode_e { + ACS_MODE=1, + MANUAL_MODE=0 +} ScanMode_e; + +struct BandConfig_t { + enum ChanBand_e chanBand:2; + enum ChanWidth_e chanWidth:2; + enum Chan2Offset_e chan2Offset:2; + enum ScanMode_e scanMode:2; +}; + +typedef struct ether_hdr_t ether_hdr_t, *Pether_hdr_t; + +struct ether_hdr_t { + IEEEtypes_MacAddr_t da; + IEEEtypes_MacAddr_t sa; + UINT16 type; +}; + +typedef struct IEEEtypes_SsIdElement_t IEEEtypes_SsIdElement_t, *PIEEEtypes_SsIdElement_t; + +struct IEEEtypes_SsIdElement_t { + enum IEEEtypes_ElementId_e ElementId; + IEEEtypes_Len_t Len; + IEEEtypes_SsId_t SsId; +}; + +typedef enum IEEEtypes_8021x_PacketType_e { + IEEE_8021X_PACKET_TYPE_ASF_ALERT=4, + IEEE_8021X_PACKET_TYPE_EAPOL_KEY=3, + IEEE_8021X_PACKET_TYPE_EAPOL_LOGOFF=2, + IEEE_8021X_PACKET_TYPE_EAPOL_START=1, + IEEE_8021X_PACKET_TYPE_EAP_PACKET=0 +} IEEEtypes_8021x_PacketType_e; + +typedef struct IEEEtypes_InfoElementHdr_t IEEEtypes_InfoElementHdr_t, *PIEEEtypes_InfoElementHdr_t; + +struct IEEEtypes_InfoElementHdr_t { + enum IEEEtypes_ElementId_e ElementId; + IEEEtypes_Len_t Len; +}; + +typedef struct IEEEtypes_RSNElement_t IEEEtypes_RSNElement_t, *PIEEEtypes_RSNElement_t; + +struct IEEEtypes_RSNElement_t { + enum IEEEtypes_ElementId_e ElementId; + IEEEtypes_Len_t Len; + UINT16 Ver; + UINT8 GrpKeyCipher[4]; + UINT16 PwsKeyCnt; + UINT8 PwsKeyCipherList[4]; + UINT16 AuthKeyCnt; + UINT8 AuthKeyList[4]; + struct IEEEtypes_RSNCapability_t RsnCap; + UINT16 PMKIDCnt; + UINT8 PMKIDList[16]; + UINT8 GrpMgmtCipher[4]; +}; + +typedef struct ChanBandInfo_t ChanBandInfo_t, *PChanBandInfo_t; + +struct ChanBandInfo_t { + struct BandConfig_t bandConfig; + UINT8 chanNum; +}; + +typedef struct dns_ans_hdr dns_ans_hdr, *Pdns_ans_hdr; + +struct dns_ans_hdr { + uint16_t id; + uint16_t flag; + uint16_t numquestions; + uint16_t numanswers; + uint16_t numauthrr; + uint16_t numextrarr; +}; + +typedef struct dns_server_ctx dns_server_ctx, *Pdns_server_ctx; + +struct dns_server_ctx { + uint8_t name[256]; + uint16_t txid; + uint16_t nquestions; + uint16_t nanswers; + undefined field_0x106; + undefined field_0x107; + struct udp_pcb * upcb1; + ip_addr_t * addr1; + u16_t port1; + undefined field_0x112; + undefined field_0x113; +}; + +typedef struct dns_table_entry dns_table_entry, *Pdns_table_entry; + +struct dns_table_entry { + uint16_t txid; + uint16_t flags; + uint16_t numque; + uint16_t ansrrs; + uint16_t autrrs; + uint16_t addrrs; + uint16_t type; + uint16_t class; + uint16_t poiname; + uint16_t anstype; + uint16_t anstypee; + uint16_t datalen; + uint32_t anstime; + uint32_t adress; +}; + +typedef struct dns_ans_ans dns_ans_ans, *Pdns_ans_ans; + +struct dns_ans_ans { + uint16_t typ; + uint16_t cls; + uint16_t point; + uint16_t antyp; + uint16_t antypp; + uint16_t len; + uint32_t time; + uint32_t addr; +}; + +typedef struct _bl_wifi_env _bl_wifi_env, *P_bl_wifi_env; + +struct _bl_wifi_env { + uint8_t sta_mac_addr_board[6]; + uint8_t sta_mac_addr_usr[6]; + uint8_t ap_mac_addr_board[6]; + uint8_t ap_mac_addr_usr[6]; + uint8_t country_code; + bl_wifi_ap_info_t ap_info; + uint8_t ap_info_en; + bl_wifi_ap_info_t sta_info; + uint8_t sta_info_en; +}; + +typedef struct _bl_wifi_env bl_wifi_env_t; + +typedef struct tsen_reload_data tsen_reload_data, *Ptsen_reload_data; + +typedef struct tsen_reload_data tsen_reload_data_t; + +typedef struct xSTATIC_TIMER xSTATIC_TIMER, *PxSTATIC_TIMER; + +typedef struct xSTATIC_TIMER StaticTimer_t; + +typedef StaticTimer_t os_timer_t; + +struct xSTATIC_TIMER { + void * pvDummy1; + StaticListItem_t xDummy2; + TickType_t xDummy3; + void * pvDummy5; + void (* pvDummy6)(void *); + UBaseType_t uxDummy7; + uint8_t ucDummy8; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +struct tsen_reload_data { + char name[32]; + os_timer_t timer; +}; + +typedef struct connectedIPNoData connectedIPNoData, *PconnectedIPNoData; + +typedef struct connectedIPNoData connectedIPNoData_t; + +struct connectedIPNoData { + char name[32]; + os_timer_t timer; +}; + +typedef struct disconnectData disconnectData, *PdisconnectData; + +typedef struct wifi_mgmr_profile_msg wifi_mgmr_profile_msg, *Pwifi_mgmr_profile_msg; + +typedef struct wifi_mgmr_profile_msg wifi_mgmr_profile_msg_t; + +struct wifi_mgmr_profile_msg { + char ssid[32]; + char ssid_tail[1]; + uint32_t ssid_len; + char psk[64]; + char psk_tail[1]; + char pmk[64]; + char pmk_tail[1]; + uint32_t psk_len; + uint32_t pmk_len; + uint8_t mac[6]; + uint8_t band; + uint16_t freq; + uint8_t dhcp_use; +}; + +struct disconnectData { + char name[32]; + os_timer_t timer; + uint8_t timer_started; + wifi_mgmr_profile_msg_t profile_msg; + undefined field_0x106; + undefined field_0x107; +}; + +typedef struct disconnectData disconnectData_t; + +typedef struct bam_env_tag bam_env_tag, *Pbam_env_tag; + +typedef struct bam_baw bam_baw, *Pbam_baw; + +struct bam_baw { + uint (* idx_compute)(struct bam_baw *, uint); + uint16_t fsn; + uint8_t states[64]; + uint8_t fsn_idx; + uint8_t buf_size; + uint8_t mask; + undefined field_0x49; + undefined field_0x4a; + undefined field_0x4b; +}; + +struct bam_env_tag { + uint32_t pkt_cnt; + uint32_t last_activity_time; + uint16_t ssn; + uint16_t ba_timeout; + uint8_t sta_idx; + uint8_t dev_type; + uint8_t ba_policy; + uint8_t buffer_size; + uint8_t tid; + uint8_t dialog_token; + uint8_t amsdu; + uint8_t delba_count; + struct bam_baw baw; +}; + +typedef uintptr_t mem_ptr_t; + +typedef uint64_t u64_t; + +typedef struct me_rc_stats_cfm me_rc_stats_cfm, *Pme_rc_stats_cfm; + +struct me_rc_stats_cfm { + uint8_t sta_idx; + undefined field_0x1; + uint16_t no_samples; + uint16_t ampdu_len; + uint16_t ampdu_packets; + uint32_t avg_ampdu_len; + uint8_t sw_retry_step; + uint8_t sample_wait; + undefined field_0xe; + undefined field_0xf; + struct step retry[4]; + struct rc_rate_stats rate_stats[10]; + uint32_t tp[10]; +}; + +typedef struct me_set_control_port_req me_set_control_port_req, *Pme_set_control_port_req; + +struct me_set_control_port_req { + uint8_t sta_idx; + _Bool control_port_open; +}; + +typedef struct me_set_active_req me_set_active_req, *Pme_set_active_req; + +struct me_set_active_req { + _Bool active; + uint8_t vif_idx; +}; + +typedef struct me_sta_add_cfm me_sta_add_cfm, *Pme_sta_add_cfm; + +struct me_sta_add_cfm { + uint8_t sta_idx; + uint8_t status; + uint8_t pm_state; +}; + +typedef struct me_rc_stats_req me_rc_stats_req, *Pme_rc_stats_req; + +struct me_rc_stats_req { + uint8_t sta_idx; +}; + +typedef struct me_chan_config_req me_chan_config_req, *Pme_chan_config_req; + +struct me_chan_config_req { + struct scan_chan_tag chan2G4[14]; + struct scan_chan_tag chan5G[28]; + uint8_t chan2G4_cnt; + uint8_t chan5G_cnt; +}; + +typedef struct me_traffic_ind_req me_traffic_ind_req, *Pme_traffic_ind_req; + +struct me_traffic_ind_req { + uint8_t sta_idx; + uint8_t tx_avail; + _Bool uapsd; +}; + +typedef struct me_sta_add_req me_sta_add_req, *Pme_sta_add_req; + +struct me_sta_add_req { + struct mac_addr mac_addr; + struct mac_rateset rate_set; + undefined field_0x13; + struct mac_htcapability ht_cap; + struct mac_vhtcapability vht_cap; + uint32_t flags; + uint16_t aid; + uint8_t uapsd_queues; + uint8_t max_sp_len; + uint8_t opmode; + uint8_t vif_idx; + _Bool tdls_sta; + undefined field_0x4b; + uint32_t tsflo; + uint32_t tsfhi; + int8_t rssi; + uint8_t data_rate; + undefined field_0x56; + undefined field_0x57; +}; + +typedef struct me_sta_del_req me_sta_del_req, *Pme_sta_del_req; + +struct me_sta_del_req { + uint8_t sta_idx; + _Bool tdls_sta; +}; + +typedef struct me_set_ps_disable_req me_set_ps_disable_req, *Pme_set_ps_disable_req; + +struct me_set_ps_disable_req { + _Bool ps_disable; + uint8_t vif_idx; +}; + +typedef struct me_tkip_mic_failure_ind me_tkip_mic_failure_ind, *Pme_tkip_mic_failure_ind; + +struct me_tkip_mic_failure_ind { + struct mac_addr addr; + undefined field_0x6; + undefined field_0x7; + uint64_t tsc; + _Bool ga; + uint8_t keyid; + uint8_t vif_idx; + undefined field_0x13; + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct me_rc_set_rate_req me_rc_set_rate_req, *Pme_rc_set_rate_req; + +struct me_rc_set_rate_req { + uint8_t sta_idx; + undefined field_0x1; + uint16_t fixed_rate_cfg; +}; + +typedef struct me_config_req me_config_req, *Pme_config_req; + +struct me_config_req { + struct mac_htcapability ht_cap; + struct mac_vhtcapability vht_cap; + uint16_t tx_lft; + _Bool ht_supp; + _Bool vht_supp; + _Bool ps_on; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct wifi_mgmr wifi_mgmr, *Pwifi_mgmr; + +typedef struct wifi_mgmr wifi_mgmr_t; + +typedef struct wlan_netif.conflict25 wlan_netif.conflict25, *Pwlan_netif.conflict25; + +typedef struct wlan_netif.conflict26 wlan_netif.conflict26, *Pwlan_netif.conflict26; + +typedef enum WIFI_MGMR_CONNECTION_STATUS { + WIFI_MGMR_CONNECTION_STATUS_CONNECTED_IP_NO=3, + WIFI_MGMR_CONNECTION_STATUS_CONNECTED_IP_YES=2, + WIFI_MGMR_CONNECTION_STATUS_CONNECTING=1, + WIFI_MGMR_CONNECTION_STATUS_DISCONNECTED=4, + WIFI_MGMR_CONNECTION_STATUS_IDLE=0 +} WIFI_MGMR_CONNECTION_STATUS; + +typedef enum WIFI_MGMR_CONNECTION_STATUS WIFI_MGMR_CONNECTION_STATUS_T; + +typedef struct wifi_mgmr_profile wifi_mgmr_profile, *Pwifi_mgmr_profile; + +typedef struct wifi_mgmr_profile wifi_mgmr_profile_t; + +typedef struct wifi_mgmr_scan_item wifi_mgmr_scan_item, *Pwifi_mgmr_scan_item; + +typedef struct wifi_mgmr_scan_item wifi_mgmr_scan_item_t; + +typedef struct xSTATIC_STREAM_BUFFER xSTATIC_STREAM_BUFFER, *PxSTATIC_STREAM_BUFFER; + +typedef struct xSTATIC_STREAM_BUFFER StaticStreamBuffer_t; + +typedef StaticStreamBuffer_t StaticMessageBuffer_t; + +typedef StaticMessageBuffer_t os_messagequeue_t; + +typedef struct stateMachine stateMachine, *PstateMachine; + +typedef struct wifi_mgmr_connect_ind_stat_info wifi_mgmr_connect_ind_stat_info, *Pwifi_mgmr_connect_ind_stat_info; + +typedef struct wifi_mgmr_connect_ind_stat_info wifi_mgmr_connect_ind_stat_info_t; + +typedef struct anon_struct_for_ipv4 anon_struct_for_ipv4, *Panon_struct_for_ipv4; + +typedef struct netif.conflict34 netif.conflict34, *Pnetif.conflict34; + + +// WARNING! conflicting data type names: /DWARF/wifi_mgmr.h/wlan_netif/anon_union_for_field_5 - /DWARF/hal_desc.h/tx_hd/anon_union_for_field_5 + +typedef struct netif.conflict35 netif.conflict35, *Pnetif.conflict35; + +typedef struct state state, *Pstate; + +typedef struct event event, *Pevent; + +typedef struct transition transition, *Ptransition; + +struct wifi_mgmr_connect_ind_stat_info { + uint16_t status_code; + uint8_t type_ind; + char ssid[32]; + char psk[65]; + uint8_t bssid[6]; + uint16_t chan_freq; + uint8_t chan_band; + undefined field_0x6d; +}; + +struct wifi_mgmr_profile { + char ssid[33]; + uint8_t no_autoconnect; + undefined field_0x22; + undefined field_0x23; + uint32_t ssid_len; + char psk[65]; + undefined field_0x69; + undefined field_0x6a; + undefined field_0x6b; + uint32_t psk_len; + char pmk[65]; + undefined field_0xb1; + undefined field_0xb2; + undefined field_0xb3; + uint32_t pmk_len; + uint8_t mac[6]; + uint8_t dhcp_use; + uint8_t priority; + uint8_t isActive; + uint8_t isUsed; + undefined field_0xc2; + undefined field_0xc3; +}; + +struct netif.conflict35 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct netif.conflict34 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct anon_struct_for_ipv4 { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +struct state { + struct state * parentState; + struct state * entryState; + struct transition * transitions; + size_t numTransitions; + void * data; + void (* entryAction)(void *, struct event *); + void (* exitAction)(void *, struct event *); +}; + +struct event { + int type; + void * data; +}; + +struct xSTATIC_STREAM_BUFFER { + size_t uxDummy1[4]; + void * pvDummy2[3]; + uint8_t ucDummy3; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; + UBaseType_t uxDummy4; +}; + +struct stateMachine { + struct state * currentState; + struct state * previousState; + struct state * errorState; +}; + +struct wlan_netif.conflict25 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict34 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +struct wifi_mgmr_scan_item { + char ssid[32]; + char ssid_tail[1]; + undefined field_0x21; + undefined field_0x22; + undefined field_0x23; + uint32_t ssid_len; + uint8_t bssid[6]; + uint8_t channel; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t auth; + uint8_t cipher; + uint8_t is_used; + undefined field_0x35; + undefined field_0x36; + undefined field_0x37; + uint32_t timestamp_lastseen; +}; + +struct wlan_netif.conflict26 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict35 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +struct wifi_mgmr { + uint8_t ready; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + int channel; + int inf_ap_enabled; + struct wlan_netif.conflict25 wlan_sta; + struct wlan_netif.conflict26 wlan_ap; + WIFI_MGMR_CONNECTION_STATUS_T status; + undefined field_0xed; + undefined field_0xee; + undefined field_0xef; + wifi_mgmr_profile_t profiles[2]; + int profile_active_index; + wifi_mgmr_scan_item_t scan_items[50]; + os_messagequeue_t mq; + uint8_t mq_pool[2240]; + struct stateMachine m; + os_timer_t timer; + wifi_mgmr_connect_ind_stat_info_t wifi_mgmr_stat_info; + char country_code[3]; + uint8_t disable_autoreconnect; + undefined field_0x17c2; + undefined field_0x17c3; + int channel_nums; + uint32_t pending_task; + uint32_t features; + int scan_item_timeout; +}; + +struct transition { + int eventType; + void * condition; + _Bool (* guard)(void *, struct event *); + void (* action)(void *, struct event *, void *); + struct state * nextState; +}; + +typedef struct wifi_mgmr_cfg_element_msg wifi_mgmr_cfg_element_msg, *Pwifi_mgmr_cfg_element_msg; + +struct wifi_mgmr_cfg_element_msg { + uint32_t ops; + uint32_t task; + uint32_t element; + uint32_t type; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct anon_struct.conflict348 anon_struct.conflict348, *Panon_struct.conflict348; + +struct anon_struct.conflict348 { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +typedef struct wlan_netif.conflict27 wlan_netif.conflict27, *Pwlan_netif.conflict27; + +typedef struct netif.conflict36 netif.conflict36, *Pnetif.conflict36; + +struct netif.conflict36 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict27 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict36 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif wlan_netif, *Pwlan_netif; + +struct wlan_netif { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct anon_struct.conflict349 anon_struct.conflict349, *Panon_struct.conflict349; + +struct anon_struct.conflict349 { + int8_t rssi; +}; + +typedef struct wifi_mgmr_sta_basic_info wifi_mgmr_sta_basic_info, *Pwifi_mgmr_sta_basic_info; + +typedef struct wifi_mgmr_sta_basic_info wifi_mgmr_sta_basic_info_t; + +struct wifi_mgmr_sta_basic_info { + uint8_t sta_idx; + uint8_t is_used; + uint8_t sta_mac[6]; + uint32_t tsfhi; + uint32_t tsflo; + int rssi; + uint8_t data_rate; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct anon_struct.conflict350 anon_struct.conflict350, *Panon_struct.conflict350; + +struct anon_struct.conflict350 { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +typedef struct anon_struct.conflict351 anon_struct.conflict351, *Panon_struct.conflict351; + +struct anon_struct.conflict351 { + int8_t rssi; +}; + +typedef struct anon_struct.conflict356 anon_struct.conflict356, *Panon_struct.conflict356; + +struct anon_struct.conflict356 { + int8_t rssi; +}; + +typedef struct anon_struct.conflict357 anon_struct.conflict357, *Panon_struct.conflict357; + +struct anon_struct.conflict357 { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +typedef struct anon_struct.conflict358 anon_struct.conflict358, *Panon_struct.conflict358; + +struct anon_struct.conflict358 { + int8_t rssi; +}; + +typedef struct wifi_mgmr_ipgot_msg wifi_mgmr_ipgot_msg, *Pwifi_mgmr_ipgot_msg; + +struct wifi_mgmr_ipgot_msg { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +typedef struct anon_struct.conflict353 anon_struct.conflict353, *Panon_struct.conflict353; + +struct anon_struct.conflict353 { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +typedef struct anon_struct.conflict354 anon_struct.conflict354, *Panon_struct.conflict354; + +struct anon_struct.conflict354 { + int8_t rssi; +}; + +typedef struct anon_struct.conflict355 anon_struct.conflict355, *Panon_struct.conflict355; + +struct anon_struct.conflict355 { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +typedef struct wifi_mgmr_msg wifi_mgmr_msg, *Pwifi_mgmr_msg; + +typedef struct wifi_mgmr_msg wifi_mgmr_msg_t; + +typedef enum WIFI_MGMR_EVENT { + WIFI_MGMR_EVENT_APP_AP_START=8, + WIFI_MGMR_EVENT_APP_AP_STOP=9, + WIFI_MGMR_EVENT_APP_CONF_MAX_STA=10, + WIFI_MGMR_EVENT_APP_CONNECT=1, + WIFI_MGMR_EVENT_APP_CONNECTED=3, + WIFI_MGMR_EVENT_APP_DENOISE=12, + WIFI_MGMR_EVENT_APP_DISCONNECT=5, + WIFI_MGMR_EVENT_APP_IDLE=0, + WIFI_MGMR_EVENT_APP_IP_GOT=4, + WIFI_MGMR_EVENT_APP_PHY_UP=7, + WIFI_MGMR_EVENT_APP_RC_CONFIG=11, + WIFI_MGMR_EVENT_APP_RECONNECT=6, + WIFI_MGMR_EVENT_APP_RELOAD_TSEN=13, + WIFI_MGMR_EVENT_APP_SNIFFER=2, + WIFI_MGMR_EVENT_FW_CFG_REQ=22, + WIFI_MGMR_EVENT_FW_CHANNEL_SET=17, + WIFI_MGMR_EVENT_FW_DATA_RAW_SEND=21, + WIFI_MGMR_EVENT_FW_DISCONNECT=15, + WIFI_MGMR_EVENT_FW_IND_CONNECTED=20, + WIFI_MGMR_EVENT_FW_IND_DISCONNECT=19, + WIFI_MGMR_EVENT_FW_POWERSAVING=16, + WIFI_MGMR_EVENT_FW_SCAN=18, + WIFI_MGMR_EVENT_GLB_AP_IND_STA_DEL=27, + WIFI_MGMR_EVENT_GLB_AP_IND_STA_NEW=26, + WIFI_MGMR_EVENT_GLB_DISABLE_AUTORECONNECT=28, + WIFI_MGMR_EVENT_GLB_ENABLE_AUTORECONNECT=29, + WIFI_MGMR_EVENT_GLB_IP_UPDATE=30, + WIFI_MGMR_EVENT_GLB_SCAN_IND_BEACON=24, + WIFI_MGMR_EVENT_GLB_SCAN_IND_PROBE_RESP=25, + WIFI_MGMR_EVENT_MAXAPP_MINIFW=14, + WIFI_MGMR_EVENT_MAXFW_MINI_GLOBAL=23 +} WIFI_MGMR_EVENT; + +typedef enum WIFI_MGMR_EVENT WIFI_MGMR_EVENT_T; + +struct wifi_mgmr_msg { + WIFI_MGMR_EVENT_T ev; + void * data1; + void * data2; + uint32_t len; + uint8_t[0] data; +}; + +typedef struct anon_struct.conflict364 anon_struct.conflict364, *Panon_struct.conflict364; + +struct anon_struct.conflict364 { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +typedef struct anon_struct.conflict365 anon_struct.conflict365, *Panon_struct.conflict365; + +struct anon_struct.conflict365 { + int8_t rssi; +}; + +typedef struct wifi_mgmr_cfg_element_msg wifi_mgmr_cfg_element_msg_t; + +typedef struct wifi_mgmr_ipgot_msg wifi_mgmr_ipgot_msg_t; + +typedef enum EVENT_TYPE { + EVENT_TYPE_APP=1, + EVENT_TYPE_FW=0, + EVENT_TYPE_GLB=2 +} EVENT_TYPE; + +typedef struct wlan_netif.conflict12 wlan_netif.conflict12, *Pwlan_netif.conflict12; + +typedef struct netif.conflict19 netif.conflict19, *Pnetif.conflict19; + +struct netif.conflict19 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict12 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict19 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict13 wlan_netif.conflict13, *Pwlan_netif.conflict13; + +typedef struct netif.conflict20 netif.conflict20, *Pnetif.conflict20; + +struct netif.conflict20 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict13 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict20 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict15 wlan_netif.conflict15, *Pwlan_netif.conflict15; + +typedef struct netif.conflict22 netif.conflict22, *Pnetif.conflict22; + +struct netif.conflict22 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict15 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict22 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict10 wlan_netif.conflict10, *Pwlan_netif.conflict10; + +typedef struct netif.conflict16 netif.conflict16, *Pnetif.conflict16; + +struct netif.conflict16 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict10 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict16 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict17 wlan_netif.conflict17, *Pwlan_netif.conflict17; + +typedef struct netif.conflict25 netif.conflict25, *Pnetif.conflict25; + +struct netif.conflict25 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict17 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict25 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict18 wlan_netif.conflict18, *Pwlan_netif.conflict18; + +typedef struct netif.conflict26 netif.conflict26, *Pnetif.conflict26; + +struct netif.conflict26 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict18 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict26 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict wlan_netif.conflict, *Pwlan_netif.conflict; + +typedef struct netif.conflict5 netif.conflict5, *Pnetif.conflict5; + +struct netif.conflict5 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict5 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict1 wlan_netif.conflict1, *Pwlan_netif.conflict1; + +typedef struct netif.conflict6 netif.conflict6, *Pnetif.conflict6; + +struct netif.conflict6 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict1 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict6 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict23 wlan_netif.conflict23, *Pwlan_netif.conflict23; + +typedef struct netif.conflict32 netif.conflict32, *Pnetif.conflict32; + +struct netif.conflict32 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict23 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict32 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict20 wlan_netif.conflict20, *Pwlan_netif.conflict20; + +typedef struct netif.conflict28 netif.conflict28, *Pnetif.conflict28; + +struct netif.conflict28 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict20 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict28 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict22 wlan_netif.conflict22, *Pwlan_netif.conflict22; + +typedef struct netif.conflict31 netif.conflict31, *Pnetif.conflict31; + +struct netif.conflict31 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict22 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict31 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict8 wlan_netif.conflict8, *Pwlan_netif.conflict8; + +typedef struct netif.conflict14 netif.conflict14, *Pnetif.conflict14; + +struct netif.conflict14 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict8 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict14 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict6 wlan_netif.conflict6, *Pwlan_netif.conflict6; + +typedef struct netif.conflict12 netif.conflict12, *Pnetif.conflict12; + +struct netif.conflict12 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict6 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict12 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict5 wlan_netif.conflict5, *Pwlan_netif.conflict5; + +typedef struct netif.conflict11 netif.conflict11, *Pnetif.conflict11; + +struct netif.conflict11 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict5 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict11 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wifi_mgmr_ap_msg wifi_mgmr_ap_msg, *Pwifi_mgmr_ap_msg; + +struct wifi_mgmr_ap_msg { + int32_t channel; + char ssid[32]; + char ssid_tail[1]; + uint8_t hidden_ssid; + uint32_t ssid_len; + char psk[64]; + char psk_tail[1]; + uint32_t psk_len; +}; + +typedef struct wlan_netif.conflict3 wlan_netif.conflict3, *Pwlan_netif.conflict3; + +typedef struct netif.conflict8 netif.conflict8, *Pnetif.conflict8; + +struct netif.conflict8 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict3 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict8 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wifi_mgmr_ap_msg wifi_mgmr_ap_msg_t; + +typedef struct mm_bcn_env_tag mm_bcn_env_tag, *Pmm_bcn_env_tag; + +struct mm_bcn_env_tag { + struct mm_bcn_change_req * param; + int tx_cfm; + _Bool tx_pending; + _Bool update_ongoing; + _Bool update_pending; + undefined field_0xb; + struct hal_dma_desc_tag dma; + struct co_list tim_list; +}; + +typedef struct led_trigger_item led_trigger_item, *Pled_trigger_item; + +typedef struct loop_timer loop_timer, *Ploop_timer; + +typedef struct loop_ctx loop_ctx, *Ploop_ctx; + +typedef struct utils_list utils_list, *Putils_list; + +typedef struct loop_evt_handler_statistic loop_evt_handler_statistic, *Ploop_evt_handler_statistic; + +typedef struct loop_evt_handler loop_evt_handler, *Ploop_evt_handler; + +typedef struct loop_msg loop_msg, *Ploop_msg; + + +// WARNING! conflicting data type names: /DWARF/bloop.h/loop_msg/anon_union_for_u - /DWARF/timers.c/tmrTimerQueueMessage/anon_union_for_u + +struct loop_timer { + utils_dlist_t dlist_item; + uint8_t flags; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + uint time_added; + uint time_target; + int idx_task; + uint32_t evt_type_map; + void (* cb)(struct loop_ctx *, struct loop_timer *, void *); + void * arg; +}; + +struct led_trigger_item { + utils_dlist_t dlist_item; + struct loop_timer timer; + int type; + int pin; + int active; + int current_val; +}; + +struct utils_list { + struct utils_list_hdr * first; + struct utils_list_hdr * last; +}; + +struct loop_evt_handler { + char * name; + int (* evt)(struct loop_ctx *, struct loop_evt_handler *, uint32_t *, uint32_t *); + int (* handle)(struct loop_ctx *, struct loop_evt_handler *, struct loop_msg *); +}; + +struct loop_evt_handler_statistic { + uint time_max; + uint time_consumed; + uint time_accumulated; + uint count_triggered; +}; + +struct loop_ctx { + TaskHandle_t looper; + uint32_t bitmap_evt_async; + uint32_t bitmap_evt_sync; + uint32_t bitmap_msg; + uint32_t evt_type_map_async[32]; + uint32_t evt_type_map_sync[32]; + struct utils_list list[32]; + struct loop_evt_handler_statistic statistic[32]; + struct loop_evt_handler * handlers[32]; + utils_dlist_t timer_dlist; + utils_dlist_t timer_dued; +}; + +struct loop_msg { + struct utils_list_hdr item; + union anon_union_for_u u; + void * arg1; + void * arg2; + uint time_added; + uint time_consumed; +}; + +typedef struct led_trigger_ctx led_trigger_ctx, *Pled_trigger_ctx; + +struct led_trigger_ctx { + utils_dlist_t trigger_queue; + utils_dlist_t waiting_queue; +}; + +typedef struct loop_evt_handler_holder loop_evt_handler_holder, *Ploop_evt_handler_holder; + +struct loop_evt_handler_holder { + struct loop_evt_handler handler; + struct led_trigger_ctx * ctx; +}; + +typedef union anon_union anon_union, *Panon_union; + +union anon_union { + wint_t __wch; + uchar __wchb[4]; +}; + +typedef uint u32; + +typedef struct rijndael_ctx rijndael_ctx, *Prijndael_ctx; + +struct rijndael_ctx { + int decrypt; + int Nr; + u32 key[60]; +}; + +typedef struct rf_para_flash_tag rf_para_flash_tag, *Prf_para_flash_tag; + +struct rf_para_flash_tag { + uint32_t magic; + uint8_t capcode_valid; + uint8_t capcode; + uint8_t poweroffset_valid; + int8_t poweroffset[3]; + uint8_t mac_valid; + uint8_t mac[6]; + uint8_t rsvd[3]; + uint32_t crc32; +}; + +typedef struct rf_para_flash_tag rf_para_flash_t; + +typedef struct rf_calib2_tag.conflict9 rf_calib2_tag.conflict9, *Prf_calib2_tag.conflict9; + +struct rf_calib2_tag.conflict9 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib4_tag.conflict1 rf_calib4_tag.conflict1, *Prf_calib4_tag.conflict1; + +struct rf_calib4_tag.conflict1 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib2_tag rf_calib2_tag, *Prf_calib2_tag; + +struct rf_calib2_tag { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib3_tag.conflict12 rf_calib3_tag.conflict12, *Prf_calib3_tag.conflict12; + +struct rf_calib3_tag.conflict12 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib4_tag.conflict rf_calib4_tag.conflict, *Prf_calib4_tag.conflict; + +struct rf_calib4_tag.conflict { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib3_tag.conflict11 rf_calib3_tag.conflict11, *Prf_calib3_tag.conflict11; + +struct rf_calib3_tag.conflict11 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib3_tag.conflict10 rf_calib3_tag.conflict10, *Prf_calib3_tag.conflict10; + +struct rf_calib3_tag.conflict10 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib4_tag.conflict11 rf_calib4_tag.conflict11, *Prf_calib4_tag.conflict11; + +struct rf_calib4_tag.conflict11 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib2_tag.conflict12 rf_calib2_tag.conflict12, *Prf_calib2_tag.conflict12; + +struct rf_calib2_tag.conflict12 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib2_tag.conflict11 rf_calib2_tag.conflict11, *Prf_calib2_tag.conflict11; + +struct rf_calib2_tag.conflict11 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib2_tag.conflict10 rf_calib2_tag.conflict10, *Prf_calib2_tag.conflict10; + +struct rf_calib2_tag.conflict10 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib4_tag.conflict2 rf_calib4_tag.conflict2, *Prf_calib4_tag.conflict2; + +struct rf_calib4_tag.conflict2 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib4_tag.conflict4 rf_calib4_tag.conflict4, *Prf_calib4_tag.conflict4; + +struct rf_calib4_tag.conflict4 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib4_tag.conflict3 rf_calib4_tag.conflict3, *Prf_calib4_tag.conflict3; + +struct rf_calib4_tag.conflict3 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib4_tag.conflict6 rf_calib4_tag.conflict6, *Prf_calib4_tag.conflict6; + +struct rf_calib4_tag.conflict6 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib4_tag.conflict5 rf_calib4_tag.conflict5, *Prf_calib4_tag.conflict5; + +struct rf_calib4_tag.conflict5 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib4_tag.conflict8 rf_calib4_tag.conflict8, *Prf_calib4_tag.conflict8; + +struct rf_calib4_tag.conflict8 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib4_tag.conflict7 rf_calib4_tag.conflict7, *Prf_calib4_tag.conflict7; + +struct rf_calib4_tag.conflict7 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib4_tag.conflict9 rf_calib4_tag.conflict9, *Prf_calib4_tag.conflict9; + +struct rf_calib4_tag.conflict9 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib3_tag.conflict4 rf_calib3_tag.conflict4, *Prf_calib3_tag.conflict4; + +struct rf_calib3_tag.conflict4 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib3_tag.conflict5 rf_calib3_tag.conflict5, *Prf_calib3_tag.conflict5; + +struct rf_calib3_tag.conflict5 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib3_tag.conflict2 rf_calib3_tag.conflict2, *Prf_calib3_tag.conflict2; + +struct rf_calib3_tag.conflict2 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib3_tag.conflict3 rf_calib3_tag.conflict3, *Prf_calib3_tag.conflict3; + +struct rf_calib3_tag.conflict3 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib3_tag.conflict1 rf_calib3_tag.conflict1, *Prf_calib3_tag.conflict1; + +struct rf_calib3_tag.conflict1 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib3_tag.conflict8 rf_calib3_tag.conflict8, *Prf_calib3_tag.conflict8; + +struct rf_calib3_tag.conflict8 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib3_tag.conflict9 rf_calib3_tag.conflict9, *Prf_calib3_tag.conflict9; + +struct rf_calib3_tag.conflict9 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib3_tag.conflict6 rf_calib3_tag.conflict6, *Prf_calib3_tag.conflict6; + +struct rf_calib3_tag.conflict6 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib3_tag.conflict7 rf_calib3_tag.conflict7, *Prf_calib3_tag.conflict7; + +struct rf_calib3_tag.conflict7 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib2_tag.conflict2 rf_calib2_tag.conflict2, *Prf_calib2_tag.conflict2; + +struct rf_calib2_tag.conflict2 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib3_tag rf_calib3_tag, *Prf_calib3_tag; + +struct rf_calib3_tag { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict59 anon_struct.conflict59, *Panon_struct.conflict59; + +typedef struct rf_calib1_tag.conflict1 rf_calib1_tag.conflict1, *Prf_calib1_tag.conflict1; + +typedef struct rf_calib2_tag.conflict1 rf_calib2_tag.conflict1, *Prf_calib2_tag.conflict1; + +struct rf_calib2_tag.conflict1 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +struct rf_calib1_tag.conflict1 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +struct anon_struct.conflict59 { + uint32_t inited; + struct rf_calib1_tag.conflict1 cal; + struct rf_calib2_tag.conflict1 lo[21]; + undefined field_0x46; + undefined field_0x47; + struct rf_calib3_tag.conflict1 rxcal[4]; + struct rf_calib4_tag.conflict1 txcal[8]; +}; + +typedef struct rf_calib3_tag.conflict rf_calib3_tag.conflict, *Prf_calib3_tag.conflict; + +struct rf_calib3_tag.conflict { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib4_tag.conflict12 rf_calib4_tag.conflict12, *Prf_calib4_tag.conflict12; + +struct rf_calib4_tag.conflict12 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib2_tag.conflict5 rf_calib2_tag.conflict5, *Prf_calib2_tag.conflict5; + +struct rf_calib2_tag.conflict5 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib4_tag rf_calib4_tag, *Prf_calib4_tag; + +struct rf_calib4_tag { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib1_tag.conflict9 rf_calib1_tag.conflict9, *Prf_calib1_tag.conflict9; + +struct rf_calib1_tag.conflict9 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib1_tag.conflict8 rf_calib1_tag.conflict8, *Prf_calib1_tag.conflict8; + +struct rf_calib1_tag.conflict8 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib1_tag.conflict7 rf_calib1_tag.conflict7, *Prf_calib1_tag.conflict7; + +struct rf_calib1_tag.conflict7 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib1_tag.conflict6 rf_calib1_tag.conflict6, *Prf_calib1_tag.conflict6; + +struct rf_calib1_tag.conflict6 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib1_tag.conflict5 rf_calib1_tag.conflict5, *Prf_calib1_tag.conflict5; + +struct rf_calib1_tag.conflict5 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib1_tag.conflict4 rf_calib1_tag.conflict4, *Prf_calib1_tag.conflict4; + +struct rf_calib1_tag.conflict4 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib1_tag.conflict3 rf_calib1_tag.conflict3, *Prf_calib1_tag.conflict3; + +struct rf_calib1_tag.conflict3 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib1_tag.conflict2 rf_calib1_tag.conflict2, *Prf_calib1_tag.conflict2; + +struct rf_calib1_tag.conflict2 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib1_tag.conflict rf_calib1_tag.conflict, *Prf_calib1_tag.conflict; + +struct rf_calib1_tag.conflict { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib_data_tag rf_calib_data_tag, *Prf_calib_data_tag; + +typedef struct rf_calib2_tag.conflict4 rf_calib2_tag.conflict4, *Prf_calib2_tag.conflict4; + +struct rf_calib2_tag.conflict4 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +struct rf_calib_data_tag { + uint32_t inited; + struct rf_calib1_tag.conflict3 cal; + struct rf_calib2_tag.conflict4 lo[21]; + undefined field_0x46; + undefined field_0x47; + struct rf_calib3_tag.conflict4 rxcal[4]; + struct rf_calib4_tag.conflict4 txcal[8]; +}; + +typedef struct anon_struct.conflict60 anon_struct.conflict60, *Panon_struct.conflict60; + +struct anon_struct.conflict60 { + uint32_t inited; + struct rf_calib1_tag.conflict2 cal; + struct rf_calib2_tag.conflict2 lo[21]; + undefined field_0x46; + undefined field_0x47; + struct rf_calib3_tag.conflict2 rxcal[4]; + struct rf_calib4_tag.conflict2 txcal[8]; +}; + +typedef struct rf_calib2_tag.conflict7 rf_calib2_tag.conflict7, *Prf_calib2_tag.conflict7; + +struct rf_calib2_tag.conflict7 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib2_tag.conflict8 rf_calib2_tag.conflict8, *Prf_calib2_tag.conflict8; + +struct rf_calib2_tag.conflict8 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib2_tag.conflict6 rf_calib2_tag.conflict6, *Prf_calib2_tag.conflict6; + +struct rf_calib2_tag.conflict6 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib2_tag.conflict3 rf_calib2_tag.conflict3, *Prf_calib2_tag.conflict3; + +struct rf_calib2_tag.conflict3 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib4_tag.conflict10 rf_calib4_tag.conflict10, *Prf_calib4_tag.conflict10; + +struct rf_calib4_tag.conflict10 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib1_tag.conflict10 rf_calib1_tag.conflict10, *Prf_calib1_tag.conflict10; + +struct rf_calib1_tag.conflict10 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib_data_tag.conflict2 rf_calib_data_tag.conflict2, *Prf_calib_data_tag.conflict2; + +struct rf_calib_data_tag.conflict2 { + uint32_t inited; + struct rf_calib1_tag.conflict10 cal; + struct rf_calib2_tag.conflict12 lo[21]; + undefined field_0x46; + undefined field_0x47; + struct rf_calib3_tag.conflict12 rxcal[4]; + struct rf_calib4_tag.conflict12 txcal[8]; +}; + +typedef struct anon_struct.conflict145 anon_struct.conflict145, *Panon_struct.conflict145; + +struct anon_struct.conflict145 { + uint32_t inited; + struct rf_calib1_tag.conflict7 cal; + struct rf_calib2_tag.conflict8 lo[21]; + undefined field_0x46; + undefined field_0x47; + struct rf_calib3_tag.conflict8 rxcal[4]; + struct rf_calib4_tag.conflict8 txcal[8]; +}; + +typedef struct anon_struct.conflict146 anon_struct.conflict146, *Panon_struct.conflict146; + +struct anon_struct.conflict146 { + uint32_t inited; + struct rf_calib1_tag.conflict8 cal; + struct rf_calib2_tag.conflict9 lo[21]; + undefined field_0x46; + undefined field_0x47; + struct rf_calib3_tag.conflict9 rxcal[4]; + struct rf_calib4_tag.conflict9 txcal[8]; +}; + +typedef struct rf_calib_data_tag.conflict1 rf_calib_data_tag.conflict1, *Prf_calib_data_tag.conflict1; + +struct rf_calib_data_tag.conflict1 { + uint32_t inited; + struct rf_calib1_tag.conflict9 cal; + struct rf_calib2_tag.conflict11 lo[21]; + undefined field_0x46; + undefined field_0x47; + struct rf_calib3_tag.conflict11 rxcal[4]; + struct rf_calib4_tag.conflict11 txcal[8]; +}; + +typedef struct rf_calib1_tag rf_calib1_tag, *Prf_calib1_tag; + +struct rf_calib1_tag { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib2_tag.conflict rf_calib2_tag.conflict, *Prf_calib2_tag.conflict; + +struct rf_calib2_tag.conflict { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib_data_tag.conflict rf_calib_data_tag.conflict, *Prf_calib_data_tag.conflict; + +struct rf_calib_data_tag.conflict { + uint32_t inited; + struct rf_calib1_tag.conflict4 cal; + struct rf_calib2_tag.conflict5 lo[21]; + undefined field_0x46; + undefined field_0x47; + struct rf_calib3_tag.conflict5 rxcal[4]; + struct rf_calib4_tag.conflict5 txcal[8]; +}; + +typedef struct jsmntok_t jsmntok_t, *Pjsmntok_t; + +typedef enum jsmntype_t { + JSMN_ARRAY=2, + JSMN_OBJECT=1, + JSMN_PRIMITIVE=4, + JSMN_STRING=3, + JSMN_UNDEFINED=0 +} jsmntype_t; + +struct jsmntok_t { + enum jsmntype_t type; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + int start; + int end; + int size; +}; + +typedef struct jsmn_parser jsmn_parser, *Pjsmn_parser; + +struct jsmn_parser { + uint pos; + uint toknext; + int toksuper; +}; + +typedef enum jsmnerr { + JSMN_ERROR_INVAL=-2, + JSMN_ERROR_NOMEM=-1, + JSMN_ERROR_PART=-3 +} jsmnerr; + +typedef void * MessageBufferHandle_t; + +typedef enum hostapd_state_tag { + HOSTAPD_STATE_IDLE=0, + HOSTAPD_STATE_MAX=1 +} hostapd_state_tag; + +typedef struct ip4_addr_packed ip4_addr_packed, *Pip4_addr_packed; + +struct ip4_addr_packed { + u32_t addr; +}; + +typedef struct ip_hdr ip_hdr, *Pip_hdr; + +typedef struct ip4_addr_packed ip4_addr_p_t; + +struct ip_hdr { + u8_t _v_hl; + u8_t _tos; + u16_t _len; + u16_t _id; + u16_t _offset; + u8_t _ttl; + u8_t _proto; + u16_t _chksum; + ip4_addr_p_t src; + ip4_addr_p_t dest; +}; + +typedef void (* tcpip_init_done_fn)(void *); + +typedef void (* tcpip_callback_fn)(void *); + +typedef struct cfg_element_entry cfg_element_entry, *Pcfg_element_entry; + +typedef enum CFG_ELEMENT_TYPE_OPS { + CFG_ELEMENT_TYPE_OPS_DUMP_DEBUG=3, + CFG_ELEMENT_TYPE_OPS_GET=1, + CFG_ELEMENT_TYPE_OPS_RESET=2, + CFG_ELEMENT_TYPE_OPS_SET=0, + CFG_ELEMENT_TYPE_OPS_UNKNOWN=4 +} CFG_ELEMENT_TYPE_OPS; + +struct cfg_element_entry { + uint32_t task; + uint16_t element; + uint16_t type; + char * name; + void * val; + int (* set)(struct cfg_element_entry *, void *, void *); + int (* get)(struct cfg_element_entry *, void *, void *); + int (* notify)(struct cfg_element_entry *, void *, void *, enum CFG_ELEMENT_TYPE_OPS); +}; + +typedef struct bl_txhdr.conflict3 bl_txhdr.conflict3, *Pbl_txhdr.conflict3; + +typedef union bl_hw_txstatus.conflict5 bl_hw_txstatus.conflict5, *Pbl_hw_txstatus.conflict5; + +typedef struct anon_struct.conflict347 anon_struct.conflict347, *Panon_struct.conflict347; + +typedef uint32_t u32.conflict192; + +typedef uint32_t u32.conflict193; + +typedef uint32_t u32.conflict194; + +typedef uint32_t u32.conflict195; + +struct anon_struct.conflict347 { + u32.conflict192 tx_done:1; + u32.conflict193 retry_required:1; + u32.conflict194 sw_retry_required:1; + u32.conflict195 reserved:29; +}; + +union bl_hw_txstatus.conflict5 { + struct anon_struct.conflict347 field_0; + u32.conflict196 value; +}; + +struct bl_txhdr.conflict3 { + struct utils_list_hdr item; + union bl_hw_txstatus.conflict5 status; + uint32_t * p; + struct hostdesc.conflict54 host; +}; + +typedef struct bl_txhdr.conflict1 bl_txhdr.conflict1, *Pbl_txhdr.conflict1; + +typedef union bl_hw_txstatus.conflict2 bl_hw_txstatus.conflict2, *Pbl_hw_txstatus.conflict2; + +typedef struct anon_struct.conflict315 anon_struct.conflict315, *Panon_struct.conflict315; + +typedef uint32_t u32.conflict47; + +typedef uint32_t u32.conflict48; + +typedef uint32_t u32.conflict49; + +typedef uint32_t u32.conflict50; + +struct anon_struct.conflict315 { + u32.conflict47 tx_done:1; + u32.conflict48 retry_required:1; + u32.conflict49 sw_retry_required:1; + u32.conflict50 reserved:29; +}; + +union bl_hw_txstatus.conflict2 { + struct anon_struct.conflict315 field_0; + u32.conflict51 value; +}; + +struct bl_txhdr.conflict1 { + struct utils_list_hdr item; + union bl_hw_txstatus.conflict2 status; + uint32_t * p; + struct hostdesc.conflict44 host; +}; + +typedef struct bl_txhdr.conflict bl_txhdr.conflict, *Pbl_txhdr.conflict; + +typedef union bl_hw_txstatus.conflict1 bl_hw_txstatus.conflict1, *Pbl_hw_txstatus.conflict1; + +typedef struct anon_struct.conflict314 anon_struct.conflict314, *Panon_struct.conflict314; + +typedef uint32_t u32.conflict42; + +typedef uint32_t u32.conflict43; + +typedef uint32_t u32.conflict44; + +typedef uint32_t u32.conflict45; + +struct anon_struct.conflict314 { + u32.conflict42 tx_done:1; + u32.conflict43 retry_required:1; + u32.conflict44 sw_retry_required:1; + u32.conflict45 reserved:29; +}; + +union bl_hw_txstatus.conflict1 { + struct anon_struct.conflict314 field_0; + u32.conflict46 value; +}; + +struct bl_txhdr.conflict { + struct utils_list_hdr item; + union bl_hw_txstatus.conflict1 status; + uint32_t * p; + struct hostdesc.conflict43 host; +}; + +typedef struct bl_txhdr.conflict2 bl_txhdr.conflict2, *Pbl_txhdr.conflict2; + +typedef union bl_hw_txstatus.conflict4 bl_hw_txstatus.conflict4, *Pbl_hw_txstatus.conflict4; + +typedef struct anon_struct.conflict346 anon_struct.conflict346, *Panon_struct.conflict346; + +typedef uint32_t u32.conflict187; + +typedef uint32_t u32.conflict188; + +typedef uint32_t u32.conflict189; + +typedef uint32_t u32.conflict190; + +struct anon_struct.conflict346 { + u32.conflict187 tx_done:1; + u32.conflict188 retry_required:1; + u32.conflict189 sw_retry_required:1; + u32.conflict190 reserved:29; +}; + +union bl_hw_txstatus.conflict4 { + struct anon_struct.conflict346 field_0; + u32.conflict191 value; +}; + +struct bl_txhdr.conflict2 { + struct utils_list_hdr item; + union bl_hw_txstatus.conflict4 status; + uint32_t * p; + struct hostdesc.conflict53 host; +}; + +typedef struct bl_txhdr bl_txhdr, *Pbl_txhdr; + +typedef union bl_hw_txstatus.conflict bl_hw_txstatus.conflict, *Pbl_hw_txstatus.conflict; + +typedef struct anon_struct.conflict313 anon_struct.conflict313, *Panon_struct.conflict313; + +typedef uint32_t u32.conflict37; + +typedef uint32_t u32.conflict38; + +typedef uint32_t u32.conflict39; + +typedef uint32_t u32.conflict40; + +struct anon_struct.conflict313 { + u32.conflict37 tx_done:1; + u32.conflict38 retry_required:1; + u32.conflict39 sw_retry_required:1; + u32.conflict40 reserved:29; +}; + +union bl_hw_txstatus.conflict { + struct anon_struct.conflict313 field_0; + u32.conflict41 value; +}; + +struct bl_txhdr { + struct utils_list_hdr item; + union bl_hw_txstatus.conflict status; + uint32_t * p; + struct hostdesc.conflict42 host; +}; + +typedef struct lwip_socket_multicast_pair lwip_socket_multicast_pair, *Plwip_socket_multicast_pair; + +typedef struct lwip_sock lwip_sock, *Plwip_sock; + +typedef union lwip_sock_lastdata lwip_sock_lastdata, *Plwip_sock_lastdata; + +union lwip_sock_lastdata { + struct netbuf * netbuf; + struct pbuf * pbuf; +}; + +struct lwip_sock { + struct netconn * conn; + union lwip_sock_lastdata lastdata; + s16_t rcvevent; + u16_t sendevent; + u16_t errevent; + u8_t select_waiting; + undefined field_0xf; +}; + +struct lwip_socket_multicast_pair { + struct lwip_sock * sock; + ip4_addr_t if_addr; + ip4_addr_t multi_addr; +}; + +typedef enum lwip_pollscan_opts { + LWIP_POLLSCAN_CLEAR=1, + LWIP_POLLSCAN_DEC_WAIT=4, + LWIP_POLLSCAN_INC_WAIT=2 +} lwip_pollscan_opts; + +typedef union sockaddr_aligned sockaddr_aligned, *Psockaddr_aligned; + +typedef struct sockaddr sockaddr, *Psockaddr; + +typedef struct sockaddr_in sockaddr_in, *Psockaddr_in; + +typedef u8_t sa_family_t; + +typedef struct in_addr in_addr, *Pin_addr; + +struct in_addr { + in_addr_t s_addr; +}; + +struct sockaddr { + u8_t sa_len; + sa_family_t sa_family; + char sa_data[14]; +}; + +struct sockaddr_in { + u8_t sin_len; + sa_family_t sin_family; + in_port_t sin_port; + struct in_addr sin_addr; + char sin_zero[8]; +}; + +union sockaddr_aligned { + struct sockaddr sa; + struct sockaddr_in sin; +}; + +typedef struct scanu_raw_send_cfm scanu_raw_send_cfm, *Pscanu_raw_send_cfm; + +struct scanu_raw_send_cfm { + uint32_t status; +}; + +typedef struct scanu_raw_send_req scanu_raw_send_req, *Pscanu_raw_send_req; + +struct scanu_raw_send_req { + void * pkt; + uint32_t len; +}; + +typedef struct scanu_start_cfm scanu_start_cfm, *Pscanu_start_cfm; + +struct scanu_start_cfm { + uint8_t status; +}; + +typedef struct Bl_SHA1_CTX Bl_SHA1_CTX, *PBl_SHA1_CTX; + +struct Bl_SHA1_CTX { + UINT32 Intermediate_Hash[5]; + UINT32 Length_Low; + UINT32 Length_High; + UINT32 Scratch[16]; + UINT8 Message_Block[64]; + SINT16 Message_Block_Index; + UINT8 Computed; + UINT8 Corrupted; +}; + +typedef struct mbedtls_sha1_context mbedtls_sha1_context, *Pmbedtls_sha1_context; + +struct mbedtls_sha1_context { + uint32_t total[2]; + uint32_t state[5]; + uchar buffer[64]; +}; + +typedef struct wifi_cipher_t.conflict26 wifi_cipher_t.conflict26, *Pwifi_cipher_t.conflict26; + +struct wifi_cipher_t.conflict26 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict24 wifi_cipher_t.conflict24, *Pwifi_cipher_t.conflict24; + +struct wifi_cipher_t.conflict24 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict25 wifi_cipher_t.conflict25, *Pwifi_cipher_t.conflict25; + +struct wifi_cipher_t.conflict25 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict22 wifi_cipher_t.conflict22, *Pwifi_cipher_t.conflict22; + +struct wifi_cipher_t.conflict22 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict20 wifi_cipher_t.conflict20, *Pwifi_cipher_t.conflict20; + +struct wifi_cipher_t.conflict20 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict21 wifi_cipher_t.conflict21, *Pwifi_cipher_t.conflict21; + +struct wifi_cipher_t.conflict21 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct tcpip_callback_msg tcpip_callback_msg, *Ptcpip_callback_msg; + +struct tcpip_callback_msg { +}; + +typedef struct wifi_cipher_t.conflict15 wifi_cipher_t.conflict15, *Pwifi_cipher_t.conflict15; + +struct wifi_cipher_t.conflict15 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict16 wifi_cipher_t.conflict16, *Pwifi_cipher_t.conflict16; + +struct wifi_cipher_t.conflict16 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict14 wifi_cipher_t.conflict14, *Pwifi_cipher_t.conflict14; + +struct wifi_cipher_t.conflict14 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict11 wifi_cipher_t.conflict11, *Pwifi_cipher_t.conflict11; + +struct wifi_cipher_t.conflict11 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict12 wifi_cipher_t.conflict12, *Pwifi_cipher_t.conflict12; + +struct wifi_cipher_t.conflict12 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict10 wifi_cipher_t.conflict10, *Pwifi_cipher_t.conflict10; + +struct wifi_cipher_t.conflict10 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict2 wifi_cipher_t.conflict2, *Pwifi_cipher_t.conflict2; + +struct wifi_cipher_t.conflict2 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict3 wifi_cipher_t.conflict3, *Pwifi_cipher_t.conflict3; + +struct wifi_cipher_t.conflict3 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict4 wifi_cipher_t.conflict4, *Pwifi_cipher_t.conflict4; + +struct wifi_cipher_t.conflict4 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict6 wifi_cipher_t.conflict6, *Pwifi_cipher_t.conflict6; + +struct wifi_cipher_t.conflict6 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict7 wifi_cipher_t.conflict7, *Pwifi_cipher_t.conflict7; + +struct wifi_cipher_t.conflict7 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict8 wifi_cipher_t.conflict8, *Pwifi_cipher_t.conflict8; + +struct wifi_cipher_t.conflict8 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef uint32_t u32.conflict29; + +typedef uint32_t u32.conflict28; + +typedef uint32_t u32.conflict27; + +typedef struct netif.conflict17 netif.conflict17, *Pnetif.conflict17; + +struct netif.conflict17 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict13 netif.conflict13, *Pnetif.conflict13; + +struct netif.conflict13 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict15 netif.conflict15, *Pnetif.conflict15; + +struct netif.conflict15 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef uint32_t u32.conflict32; + +typedef uint32_t u32.conflict31; + +typedef uint32_t u32.conflict30; + +typedef uint32_t u32.conflict34; + +typedef uint32_t u32.conflict33; + +typedef struct netif.conflict33 netif.conflict33, *Pnetif.conflict33; + +struct netif.conflict33 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict29 netif.conflict29, *Pnetif.conflict29; + +struct netif.conflict29 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict27 netif.conflict27, *Pnetif.conflict27; + +struct netif.conflict27 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict21 netif.conflict21, *Pnetif.conflict21; + +struct netif.conflict21 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict23 netif.conflict23, *Pnetif.conflict23; + +struct netif.conflict23 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct wlan_netif.conflict2 wlan_netif.conflict2, *Pwlan_netif.conflict2; + +typedef struct netif.conflict7 netif.conflict7, *Pnetif.conflict7; + +struct netif.conflict7 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict2 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict7 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict9 wlan_netif.conflict9, *Pwlan_netif.conflict9; + +struct wlan_netif.conflict9 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict15 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict7 wlan_netif.conflict7, *Pwlan_netif.conflict7; + +struct wlan_netif.conflict7 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict13 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict4 wlan_netif.conflict4, *Pwlan_netif.conflict4; + +typedef struct netif.conflict9 netif.conflict9, *Pnetif.conflict9; + +struct netif.conflict9 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct wlan_netif.conflict4 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict9 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct cm_ConnectionInfo cm_ConnectionInfo, *Pcm_ConnectionInfo; + +typedef struct supplicantData supplicantData, *PsupplicantData; + +typedef union anon_union_for_specDat anon_union_for_specDat, *Panon_union_for_specDat; + +typedef struct customMIB_RSNStats_t customMIB_RSNStats_t, *PcustomMIB_RSNStats_t; + +typedef struct RSNConfig_t RSNConfig_t, *PRSNConfig_t; + +typedef struct keyMgmtInfoSta_t keyMgmtInfoSta_t, *PkeyMgmtInfoSta_t; + +typedef struct SecurityParams_t SecurityParams_t, *PSecurityParams_t; + +typedef struct apSpecificData_t apSpecificData_t, *PapSpecificData_t; + +typedef struct AkmSuite_t AkmSuite_t, *PAkmSuite_t; + +typedef struct MIC_Error_t MIC_Error_t, *PMIC_Error_t; + +typedef struct BufferDesc BufferDesc, *PBufferDesc; + +typedef struct BufferDesc BufferDesc_t; + +typedef enum AkmType_e { + AKM_1X=1, + AKM_CCKM=99, + AKM_FT_1X=3, + AKM_FT_PSK=4, + AKM_NONE=0, + AKM_PSK=2, + AKM_RSN_MAX=6, + AKM_SHA256_1X=5, + AKM_SHA256_PSK=6, + AKM_SUITE_MAX=5, + AKM_TDLS=7, + AKM_WPA_MAX=2 +} AkmType_e; + +typedef enum AkmType_e AkmTypePacked_e; + +typedef enum MIC_Fail_State_e { + FIRST_MIC_FAIL_IN_60_SEC=1, + NO_MIC_FAILURE=0, + SECOND_MIC_FAIL_IN_60_SEC=2 +} MIC_Fail_State_e; + +typedef union anon_union_for_intf anon_union_for_intf, *Panon_union_for_intf; + +struct MIC_Error_t { + enum MIC_Fail_State_e status; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + BOOLEAN MICCounterMeasureEnabled; + UINT32 disableStaAsso; +}; + +struct SecurityParams_t { + struct SecurityMode_t wpaType; + struct Cipher_t mcstCipher; + struct Cipher_t ucstCipher; +}; + +struct customMIB_RSNStats_t { + UINT8 TKIPICVErrors; + UINT8 TKIPLocalMICFailures; + UINT8 TKIPCounterMeasuresInvoked; +}; + +struct AkmSuite_t { + UINT8 akmOui[3]; + AkmTypePacked_e akmType; +}; + +struct apSpecificData_t { + struct apInfo_t * apInfo; + BufferDesc_t * apInfoBuffDesc; + struct ChanBandInfo_t chanBandInfo; + undefined field_0xa; + undefined field_0xb; + struct staData_t staData; +}; + +union anon_union_for_specDat { + struct apSpecificData_t apData; +}; + +struct keyMgmtInfoSta_t { + UINT8 ANonce[32]; + UINT8 SNonce[32]; + UINT8 EAPOL_MIC_Key[16]; + UINT8 EAPOL_Encr_Key[16]; + UINT32 apCounterLo; + UINT32 apCounterHi; + UINT32 apCounterZeroDone; + UINT32 staCounterLo; + UINT32 staCounterHi; + BOOLEAN RSNDataTrafficEnabled; + BOOLEAN RSNSecured; + BOOLEAN pwkHandshakeComplete; + struct cipher_key_t * pRxDecryptKey; + struct KeyData_t PWKey; + struct KeyData_t GRKey; + struct KeyData_t newPWKey; + struct MIC_Error_t sta_MIC_Error; + struct mm_timer_tag rsnTimer; + struct cm_ConnectionInfo * connPtr; + struct KeyData_t IGtk; +}; + +struct RSNConfig_t { + UINT8 RSNEnabled:1; + UINT8 pmkidValid:1; + UINT8 rsnCapValid:1; + UINT8 grpMgmtCipherValid:1; + UINT8 rsvd:4; + struct SecurityMode_t wpaType; + struct Cipher_t mcstCipher; + struct Cipher_t ucstCipher; + struct AkmSuite_t AKM; + UINT8 PMKID[16]; + struct IEEEtypes_RSNCapability_t rsnCap; + struct Cipher_t grpMgmtCipher; +}; + +struct supplicantData { + BOOLEAN inUse; + struct IEEEtypes_SsIdElement_t hashSsId; + IEEEtypes_MacAddr_t localBssid; + IEEEtypes_MacAddr_t localStaAddr; + struct customMIB_RSNStats_t customMIB_RSNStats; + struct RSNConfig_t customMIB_RSNConfig; + undefined field_0x51; + undefined field_0x52; + undefined field_0x53; + struct keyMgmtInfoSta_t keyMgmtInfoSta; + struct SecurityParams_t currParams; +}; + +struct cm_ConnectionInfo { + UINT8 conType; + UINT8 staId; + UINT8 instNbr; + UINT8 gtkHwKeyId; + UINT8 ptkHwKeyId; + UINT8 mfpHwKeyId; + undefined field_0x6; + undefined field_0x7; + struct supplicantData * suppData; + struct CommonMlmeData_t comData; + IEEEtypes_MacAddr_t peerMacAddr; + IEEEtypes_MacAddr_t localMacAddr; + union anon_union_for_specDat specDat; + cipher_key_buf_t TxRxCipherKeyBuf; +}; + +union anon_union_for_intf { + uint32 Interface; +}; + +struct BufferDesc { + union anon_union_for_intf intf; + uint16 DataLen; + undefined field_0x6; + undefined field_0x7; + void * Buffer; +}; + +typedef struct txl_buffer_tag txl_buffer_tag, *Ptxl_buffer_tag; + +typedef struct txdesc txdesc, *Ptxdesc; + +typedef struct umacdesc umacdesc, *Pumacdesc; + +typedef struct lmacdesc lmacdesc, *Plmacdesc; + +typedef struct tx_hw_desc tx_hw_desc, *Ptx_hw_desc; + +typedef struct tx_cfm_tag tx_cfm_tag, *Ptx_cfm_tag; + +typedef struct tx_agg_desc tx_agg_desc, *Ptx_agg_desc; + +struct txl_buffer_tag { + uint32_t length; + uint32_t lenheader; + uint32_t lenpad; + uint32_t flags; + struct txl_buffer_tag * next; + struct txdesc * txdesc; + struct dma_desc dma_desc[1]; + struct dma_desc dma_desc_pat; + struct tx_pbd tbd; + struct tx_pbd tbd_body[8]; + uint8_t user_idx; + undefined field_0xed; + undefined field_0xee; + undefined field_0xef; + struct txl_buffer_control buffer_control; + struct tx_pbd tkip_mic_icv_pbd; + uint8_t tkip_mic_icv[12]; + uint32_t[0] payload; +}; + +struct umacdesc { + struct txl_buffer_control * buf_control; + uint32_t buff_offset; + uint16_t payl_len; + uint8_t head_len; + uint8_t hdr_len_802_2; + uint8_t tail_len; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; +}; + +struct lmacdesc { + struct tx_agg_desc * agg_desc; + struct txl_buffer_tag * buffer; + struct tx_hw_desc * hw_desc; +}; + +struct tx_cfm_tag { + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + int8_t credits; + uint8_t ampdu_size; + uint8_t pad[2]; + uint32_t status; +}; + +struct tx_hw_desc { + struct tx_cfm_tag * cfm_ptr; + struct tx_hd thd; +}; + +struct txdesc { + struct co_list_hdr list_hdr; + struct hostdesc host; + struct umacdesc umac; + struct lmacdesc lmac; + struct tx_hw_desc hw_desc; + struct tx_cfm_tag hw_cfm; + uint32_t buf[128]; +}; + +struct tx_agg_desc { + uint8_t reserved; +}; + +typedef struct mblock_free mblock_free, *Pmblock_free; + +struct mblock_free { + struct mblock_free * next; + uint32_t size; +}; + +typedef struct inode_t inode_t, *Pinode_t; + +typedef union inode_ops_t inode_ops_t, *Pinode_ops_t; + +typedef struct file_ops file_ops, *Pfile_ops; + +typedef struct file_t file_t, *Pfile_t; + +typedef struct file_ops file_ops_t; + +typedef struct fs_ops fs_ops, *Pfs_ops; + + +// WARNING! conflicting data type names: /DWARF/stat.h/stat - /stat.h/stat + +typedef struct fs_ops fs_ops_t; + +struct file_ops { + int (* open)(struct inode_t *, struct file_t *); + int (* close)(struct file_t *); + ssize_t (* read)(struct file_t *, void *, size_t); + ssize_t (* write)(struct file_t *, void *, size_t); + int (* ioctl)(struct file_t *, int, ulong); + int (* poll)(struct file_t *, _Bool, void (* )(struct pollfd *, void *), struct pollfd *, void *); + int (* sync)(struct file_t *); +}; + +union inode_ops_t { + file_ops_t * i_ops; + fs_ops_t * i_fops; +}; + +struct inode_t { + union inode_ops_t ops; + void * i_arg; + char * i_name; + int i_flags; + uint8_t type; + uint8_t refs; + undefined field_0x12; + undefined field_0x13; +}; + +struct fs_ops { + int (* open)(struct file_t *, char *, int); + int (* close)(struct file_t *); + ssize_t (* read)(struct file_t *, char *, size_t); + ssize_t (* write)(struct file_t *, char *, size_t); + off_t (* lseek)(struct file_t *, off_t, int); + int (* sync)(struct file_t *); + int (* stat)(struct file_t *, char *, struct stat *); + int (* unlink)(struct file_t *, char *); + int (* rename)(struct file_t *, char *, char *); + aos_dir_t * (* opendir)(struct file_t *, char *); + aos_dirent_t * (* readdir)(struct file_t *, struct aos_dir_t *); + int (* closedir)(struct file_t *, struct aos_dir_t *); + int (* mkdir)(struct file_t *, char *); + int (* rmdir)(struct file_t *, char *); + void (* rewinddir)(struct file_t *, struct aos_dir_t *); + long (* telldir)(struct file_t *, struct aos_dir_t *); + void (* seekdir)(struct file_t *, struct aos_dir_t *, long); + int (* ioctl)(struct file_t *, int, ulong); + int (* statfs)(struct file_t *, char *, struct statfs *); + int (* access)(struct file_t *, char *, int); +}; + +struct file_t { + struct inode_t * node; + void * f_arg; + size_t offset; +}; + +typedef struct lwip_cyclic_timer.conflict3 lwip_cyclic_timer.conflict3, *Plwip_cyclic_timer.conflict3; + +struct lwip_cyclic_timer.conflict3 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef uint32_t u32.conflict180; + +typedef uint32_t u32.conflict181; + +typedef uint32_t u32.conflict182; + +typedef uint32_t u32.conflict178; + +typedef uint32_t u32.conflict179; + +typedef uint32_t u32.conflict183; + +typedef uint32_t u32.conflict184; + +typedef uint32_t u32.conflict185; + +typedef struct anon_struct.conflict287 anon_struct.conflict287, *Panon_struct.conflict287; + +struct anon_struct.conflict287 { + u8 category; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + undefined field_0x4; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + undefined field_0x8; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + undefined field_0xc; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + undefined field_0x10; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + undefined field_0x18; + undefined field_0x19; +}; + +typedef struct anon_struct.conflict292 anon_struct.conflict292, *Panon_struct.conflict292; + +struct anon_struct.conflict292 { + __le16 capab_info; + __le16 status_code; + __le16 aid; + u8[0] variable; +}; + +typedef struct anon_struct.conflict297 anon_struct.conflict297, *Panon_struct.conflict297; + +struct anon_struct.conflict297 { + u8 category; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + undefined field_0x4; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + undefined field_0x8; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + undefined field_0xc; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + undefined field_0x10; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + undefined field_0x18; + undefined field_0x19; +}; + +typedef struct anon_struct.conflict298 anon_struct.conflict298, *Panon_struct.conflict298; + +struct anon_struct.conflict298 { + __le16 auth_alg; + __le16 auth_transaction; + __le16 status_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict299 anon_struct.conflict299, *Panon_struct.conflict299; + +struct anon_struct.conflict299 { + __le16 reason_code; +}; + +typedef struct _Client _Client, *P_Client; + +typedef struct _Client AWS_IoT_Client; + +typedef struct Timer Timer, *PTimer; + +typedef struct _ClientStatus _ClientStatus, *P_ClientStatus; + +typedef struct _ClientStatus ClientStatus; + +typedef struct _ClientData _ClientData, *P_ClientData; + +typedef struct _ClientData ClientData; + +typedef struct Network.conflict1 Network.conflict1, *PNetwork.conflict1; + +typedef enum IoT_Error_t { + FAILURE=-1, + INVALID_TOPIC_TYPE_ERROR=-52, + JSON_PARSE_ERROR=-42, + LIMIT_EXCEEDED_ERROR=-51, + MAX_SIZE_ERROR=-50, + MQTT_CLIENT_NOT_IDLE_ERROR=-30, + MQTT_CONNACK_BAD_USERDATA_ERROR=-40, + MQTT_CONNACK_CONNECTION_ACCEPTED=1, + MQTT_CONNACK_IDENTIFIER_REJECTED_ERROR=-38, + MQTT_CONNACK_NOT_AUTHORIZED_ERROR=-41, + MQTT_CONNACK_SERVER_UNAVAILABLE_ERROR=-39, + MQTT_CONNACK_UNACCEPTABLE_PROTOCOL_VERSION_ERROR=-37, + MQTT_CONNACK_UNKNOWN_ERROR=-36, + MQTT_CONNECTION_ERROR=-26, + MQTT_CONNECT_TIMEOUT_ERROR=-27, + MQTT_DECODE_REMAINING_LENGTH_ERROR=-35, + MQTT_MAX_SUBSCRIPTIONS_REACHED_ERROR=-34, + MQTT_NOTHING_TO_READ=2, + MQTT_REQUEST_TIMEOUT_ERROR=-28, + MQTT_RX_BUFFER_TOO_SHORT_ERROR=-32, + MQTT_RX_MESSAGE_PACKET_TYPE_INVALID_ERROR=-31, + MQTT_TX_BUFFER_TOO_SHORT_ERROR=-33, + MQTT_UNEXPECTED_CLIENT_STATE_ERROR=-29, + MUTEX_DESTROY_ERROR=-49, + MUTEX_INIT_ERROR=-46, + MUTEX_LOCK_ERROR=-47, + MUTEX_UNLOCK_ERROR=-48, + NETWORK_ALREADY_CONNECTED_ERROR=-15, + NETWORK_ATTEMPTING_RECONNECT=4, + NETWORK_DISCONNECTED_ERROR=-13, + NETWORK_ERR_NET_CONNECT_FAILED=-24, + NETWORK_ERR_NET_SOCKET_FAILED=-22, + NETWORK_ERR_NET_UNKNOWN_HOST=-23, + NETWORK_MANUALLY_DISCONNECTED=5, + NETWORK_MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED=-16, + NETWORK_PHYSICAL_LAYER_CONNECTED=6, + NETWORK_PHYSICAL_LAYER_DISCONNECTED=-18, + NETWORK_PK_PRIVATE_KEY_PARSE_ERROR=-21, + NETWORK_RECONNECTED=3, + NETWORK_RECONNECT_TIMED_OUT_ERROR=-14, + NETWORK_SSL_CERT_ERROR=-9, + NETWORK_SSL_CONNECT_TIMEOUT_ERROR=-6, + NETWORK_SSL_INIT_ERROR=-8, + NETWORK_SSL_NOTHING_TO_READ=-25, + NETWORK_SSL_READ_ERROR=-12, + NETWORK_SSL_READ_TIMEOUT_ERROR=-11, + NETWORK_SSL_UNKNOWN_ERROR=-17, + NETWORK_SSL_WRITE_ERROR=-7, + NETWORK_SSL_WRITE_TIMEOUT_ERROR=-10, + NETWORK_X509_DEVICE_CRT_PARSE_ERROR=-20, + NETWORK_X509_ROOT_CRT_PARSE_ERROR=-19, + NULL_VALUE_ERROR=-2, + SHADOW_JSON_BUFFER_TRUNCATED=-44, + SHADOW_JSON_ERROR=-45, + SHADOW_WAIT_FOR_PUBLISH=-43, + SSL_CONNECTION_ERROR=-4, + SUCCESS=0, + TCP_CONNECTION_ERROR=-3, + TCP_SETUP_ERROR=-5 +} IoT_Error_t; + +typedef struct Network Network, *PNetwork; + +typedef struct TLSConnectParams TLSConnectParams, *PTLSConnectParams; + +typedef enum _ClientState { + CLIENT_STATE_CONNECTED_IDLE=3, + CLIENT_STATE_CONNECTED_PUBLISH_IN_PROGRESS=5, + CLIENT_STATE_CONNECTED_RESUBSCRIBE_IN_PROGRESS=8, + CLIENT_STATE_CONNECTED_SUBSCRIBE_IN_PROGRESS=6, + CLIENT_STATE_CONNECTED_UNSUBSCRIBE_IN_PROGRESS=7, + CLIENT_STATE_CONNECTED_WAIT_FOR_CB_RETURN=9, + CLIENT_STATE_CONNECTED_YIELD_IN_PROGRESS=4, + CLIENT_STATE_CONNECTING=2, + CLIENT_STATE_DISCONNECTED_ERROR=11, + CLIENT_STATE_DISCONNECTED_MANUALLY=12, + CLIENT_STATE_DISCONNECTING=10, + CLIENT_STATE_INITIALIZED=1, + CLIENT_STATE_INVALID=0, + CLIENT_STATE_PENDING_RECONNECT=13 +} _ClientState; + +typedef enum _ClientState ClientState; + +typedef struct _IoT_Mutex_t _IoT_Mutex_t, *P_IoT_Mutex_t; + +typedef struct _IoT_Mutex_t IoT_Mutex_t; + +typedef struct IoT_Client_Connect_Params IoT_Client_Connect_Params, *PIoT_Client_Connect_Params; + +typedef struct _MessageHandlers.conflict47 _MessageHandlers.conflict47, *P_MessageHandlers.conflict47; + +typedef struct IoT_Publish_Message_Params IoT_Publish_Message_Params, *PIoT_Publish_Message_Params; + +typedef struct _MessageHandlers.conflict47 MessageHandlers.conflict40; + +typedef enum MQTT_Ver_t { + MQTT_3_1_1=4 +} MQTT_Ver_t; + +typedef struct IoT_MQTT_Will_Options IoT_MQTT_Will_Options, *PIoT_MQTT_Will_Options; + +typedef enum QoS { + QOS0=0, + QOS1=1 +} QoS; + +struct TLSConnectParams { + char * pRootCALocation; + char * pDeviceCertLocation; + char * pDevicePrivateKeyLocation; + char * pDestinationURL; + uint16_t DestinationPort; + undefined field_0x12; + undefined field_0x13; + uint32_t timeout_ms; + _Bool ServerVerificationFlag; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; +}; + +struct Network.conflict1 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict2 tlsDataParams; +}; + +struct _MessageHandlers.conflict47 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +struct _IoT_Mutex_t { + SemaphoreHandle_t mutex; +}; + +struct IoT_MQTT_Will_Options { + char struct_id[4]; + char * pTopicName; + uint16_t topicNameLen; + undefined field_0xa; + undefined field_0xb; + char * pMessage; + uint16_t msgLen; + _Bool isRetained; + enum QoS qos; +}; + +struct IoT_Client_Connect_Params { + char struct_id[4]; + enum MQTT_Ver_t MQTTVersion; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + char * pClientID; + uint16_t clientIDLen; + uint16_t keepAliveIntervalInSec; + _Bool isCleanSession; + _Bool isWillMsgPresent; + undefined field_0x12; + undefined field_0x13; + struct IoT_MQTT_Will_Options will; + char * pUsername; + uint16_t usernameLen; + undefined field_0x2e; + undefined field_0x2f; + char * pPassword; + uint16_t passwordLen; + undefined field_0x36; + undefined field_0x37; +}; + +struct _ClientData { + uint16_t nextPacketId; + undefined field_0x2; + undefined field_0x3; + uint32_t packetTimeoutMs; + uint32_t commandTimeoutMs; + uint16_t keepAliveInterval; + undefined field_0xe; + undefined field_0xf; + uint32_t currentReconnectWaitInterval; + uint32_t counterNetworkDisconnected; + size_t writeBufSize; + size_t readBufSize; + size_t readBufIndex; + uchar writeBuf[512]; + uchar readBuf[512]; + _Bool isBlockOnThreadLockEnabled; + undefined field_0x425; + undefined field_0x426; + undefined field_0x427; + IoT_Mutex_t state_change_mutex; + IoT_Mutex_t tls_read_mutex; + IoT_Mutex_t tls_write_mutex; + struct IoT_Client_Connect_Params options; + MessageHandlers.conflict40 messageHandlers[5]; + void (* disconnectHandler)(AWS_IoT_Client *, void *); + void * disconnectHandlerData; +}; + +struct IoT_Publish_Message_Params { + enum QoS qos; + uint8_t isRetained; + uint8_t isDup; + undefined field_0x3; + uint16_t id; + undefined field_0x6; + undefined field_0x7; + void * payload; + size_t payloadLen; +}; + +struct Network { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict tlsDataParams; +}; + +struct _ClientStatus { + ClientState clientState; + _Bool isPingOutstanding; + _Bool isAutoReconnectEnabled; +}; + +struct Timer { + uint32_t start_ticks; + uint32_t timeout_ticks; + uint32_t last_polled_ticks; +}; + +struct _Client { + struct Timer pingTimer; + struct Timer reconnectDelayTimer; + ClientStatus clientStatus; + undefined field_0x1b; + ClientData clientData; + struct Network.conflict1 networkStack; +}; + +typedef struct anon_struct.conflict342 anon_struct.conflict342, *Panon_struct.conflict342; + +struct anon_struct.conflict342 { + u8 category; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + undefined field_0x4; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + undefined field_0x8; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + undefined field_0xc; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + undefined field_0x10; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + undefined field_0x18; + undefined field_0x19; +}; + +typedef struct ke_state_handler ke_state_handler, *Pke_state_handler; + +typedef struct ke_msg_handler ke_msg_handler, *Pke_msg_handler; + +typedef uint16_t ke_msg_id_t; + +struct ke_state_handler { + struct ke_msg_handler * msg_table; + uint16_t msg_cnt; + undefined field_0x6; + undefined field_0x7; +}; + +struct ke_msg_handler { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct wlan_netif.conflict14 wlan_netif.conflict14, *Pwlan_netif.conflict14; + +struct wlan_netif.conflict14 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict21 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict11 wlan_netif.conflict11, *Pwlan_netif.conflict11; + +struct wlan_netif.conflict11 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict17 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct anon_struct.conflict301 anon_struct.conflict301, *Panon_struct.conflict301; + +struct anon_struct.conflict301 { + __le16 capab_info; + __le16 status_code; + __le16 aid; + u8[0] variable; +}; + +typedef struct anon_struct.conflict302 anon_struct.conflict302, *Panon_struct.conflict302; + +struct anon_struct.conflict302 { + __le16 capab_info; + __le16 status_code; + __le16 aid; + u8[0] variable; +}; + +typedef struct anon_struct.conflict303 anon_struct.conflict303, *Panon_struct.conflict303; + +struct anon_struct.conflict303 { + __le16 capab_info; + __le16 listen_interval; + u8 current_ap[6]; + u8[0] variable; +}; + +typedef struct anon_struct.conflict304 anon_struct.conflict304, *Panon_struct.conflict304; + +struct anon_struct.conflict304 { + __le16 reason_code; +}; + +typedef struct wlan_netif.conflict16 wlan_netif.conflict16, *Pwlan_netif.conflict16; + +struct wlan_netif.conflict16 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict23 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct anon_struct.conflict300 anon_struct.conflict300, *Panon_struct.conflict300; + +struct anon_struct.conflict300 { + __le16 capab_info; + __le16 listen_interval; + u8[0] variable; +}; + +typedef struct wlan_netif.conflict19 wlan_netif.conflict19, *Pwlan_netif.conflict19; + +struct wlan_netif.conflict19 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict27 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct anon_struct.conflict305 anon_struct.conflict305, *Panon_struct.conflict305; + +struct anon_struct.conflict305 { + __le64 timestamp; + __le16 beacon_int; + __le16 capab_info; + u8[0] variable; +}; + +typedef struct anon_struct.conflict306 anon_struct.conflict306, *Panon_struct.conflict306; + +struct anon_struct.conflict306 { + __le64 timestamp; + __le16 beacon_int; + __le16 capab_info; + u8[0] variable; +}; + +typedef struct anon_struct.conflict307 anon_struct.conflict307, *Panon_struct.conflict307; + +struct anon_struct.conflict307 { + u8 category; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + undefined field_0x4; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + undefined field_0x8; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + undefined field_0xc; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + undefined field_0x10; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + undefined field_0x18; + undefined field_0x19; +}; + +typedef struct wlan_netif.conflict24 wlan_netif.conflict24, *Pwlan_netif.conflict24; + +struct wlan_netif.conflict24 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict33 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct wlan_netif.conflict21 wlan_netif.conflict21, *Pwlan_netif.conflict21; + +struct wlan_netif.conflict21 { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif.conflict29 netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef struct anon_struct.conflict16 anon_struct.conflict16, *Panon_struct.conflict16; + +struct anon_struct.conflict16 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef union anon_union_for_u.conflict2 anon_union_for_u.conflict2, *Panon_union_for_u.conflict2; + +union anon_union_for_u.conflict2 { + struct anon_struct.conflict342 wme_action; + struct anon_struct.conflict342 chan_switch; + struct anon_struct.conflict342 ext_chan_switch; + struct anon_struct.conflict342 measurement; + struct anon_struct.conflict342 addba_req; + struct anon_struct.conflict342 addba_resp; + struct anon_struct.conflict342 delba; + struct anon_struct.conflict342 self_prot; + struct anon_struct.conflict342 mesh_action; + struct anon_struct.conflict342 sa_query; + struct anon_struct.conflict342 ht_smps; + struct anon_struct.conflict342 ht_notify_cw; + struct anon_struct.conflict342 tdls_discover_resp; + struct anon_struct.conflict342 vht_opmode_notif; + struct anon_struct.conflict342 vht_group_notif; + struct anon_struct.conflict342 tpc_report; + struct anon_struct.conflict342 ftm; +}; + +typedef union anon_union_for_u.conflict1 anon_union_for_u.conflict1, *Panon_union_for_u.conflict1; + +union anon_union_for_u.conflict1 { + struct anon_struct.conflict307 wme_action; + struct anon_struct.conflict307 chan_switch; + struct anon_struct.conflict307 ext_chan_switch; + struct anon_struct.conflict307 measurement; + struct anon_struct.conflict307 addba_req; + struct anon_struct.conflict307 addba_resp; + struct anon_struct.conflict307 delba; + struct anon_struct.conflict307 self_prot; + struct anon_struct.conflict307 mesh_action; + struct anon_struct.conflict307 sa_query; + struct anon_struct.conflict307 ht_smps; + struct anon_struct.conflict307 ht_notify_cw; + struct anon_struct.conflict307 tdls_discover_resp; + struct anon_struct.conflict307 vht_opmode_notif; + struct anon_struct.conflict307 vht_group_notif; + struct anon_struct.conflict307 tpc_report; + struct anon_struct.conflict307 ftm; +}; + +typedef union anon_union_for_u.conflict anon_union_for_u.conflict, *Panon_union_for_u.conflict; + +union anon_union_for_u.conflict { + struct anon_struct.conflict297 wme_action; + struct anon_struct.conflict297 chan_switch; + struct anon_struct.conflict297 ext_chan_switch; + struct anon_struct.conflict297 measurement; + struct anon_struct.conflict297 addba_req; + struct anon_struct.conflict297 addba_resp; + struct anon_struct.conflict297 delba; + struct anon_struct.conflict297 self_prot; + struct anon_struct.conflict297 mesh_action; + struct anon_struct.conflict297 sa_query; + struct anon_struct.conflict297 ht_smps; + struct anon_struct.conflict297 ht_notify_cw; + struct anon_struct.conflict297 tdls_discover_resp; + struct anon_struct.conflict297 vht_opmode_notif; + struct anon_struct.conflict297 vht_group_notif; + struct anon_struct.conflict297 tpc_report; + struct anon_struct.conflict297 ftm; +}; + + +// WARNING! conflicting data type names: /DWARF/_UNCATEGORIZED_/anon_struct/anon_union_for_u - /DWARF/timers.c/tmrTimerQueueMessage/anon_union_for_u + + +// WARNING! conflicting data type names: /DWARF/_UNCATEGORIZED_/ieee80211_mgmt/anon_union_for_u - /DWARF/timers.c/tmrTimerQueueMessage/anon_union_for_u + +typedef struct ip_mreq ip_mreq, *Pip_mreq; + +struct ip_mreq { + struct in_addr imr_multiaddr; + struct in_addr imr_interface; +}; + +typedef struct ifreq ifreq, *Pifreq; + +struct ifreq { + char ifr_name[6]; +}; + +typedef struct sockaddr_storage sockaddr_storage, *Psockaddr_storage; + +struct sockaddr_storage { + u8_t s2_len; + sa_family_t ss_family; + char s2_data1[2]; + u32_t s2_data2[3]; +}; + +typedef u32_t socklen_t; + +typedef struct iovec iovec, *Piovec; + +struct iovec { + void * iov_base; + size_t iov_len; +}; + +typedef struct msghdr msghdr, *Pmsghdr; + +struct msghdr { + void * msg_name; + socklen_t msg_namelen; + struct iovec * msg_iov; + int msg_iovlen; + void * msg_control; + socklen_t msg_controllen; + int msg_flags; +}; + +typedef uint nfds_t; + +typedef TimerHandle_t timer_cb_arg_t; + +typedef struct mm_env_tag mm_env_tag, *Pmm_env_tag; + +struct mm_env_tag { + uint32_t rx_filter_umac; + uint32_t rx_filter_lmac_enable; + uint16_t ampdu_max_dur[5]; + uint8_t prev_mm_state; + uint8_t prev_hw_state; + uint32_t basic_rates[2]; + uint32_t uapsd_timeout; + uint16_t lp_clk_accuracy; + uint8_t host_idle; + _Bool keep_alive_status_enabled; + uint32_t keep_alive_packet_counter; + uint32_t keep_alive_time_last_received; +}; + +typedef enum mm_features { + MM_FEAT_AMPDU_BIT=9, + MM_FEAT_AMSDU_BIT=10, + MM_FEAT_AUTOBCN_BIT=1, + MM_FEAT_BCN_BIT=0, + MM_FEAT_BFMEE_BIT=17, + MM_FEAT_BFMER_BIT=18, + MM_FEAT_CHNL_CTXT_BIT=11, + MM_FEAT_CMON_BIT=3, + MM_FEAT_DPSM_BIT=8, + MM_FEAT_HWSCAN_BIT=2, + MM_FEAT_MESH_BIT=23, + MM_FEAT_MFP_BIT=20, + MM_FEAT_MROLE_BIT=4, + MM_FEAT_MU_MIMO_RX_BIT=21, + MM_FEAT_MU_MIMO_TX_BIT=22, + MM_FEAT_P2P_BIT=13, + MM_FEAT_P2P_GO_BIT=14, + MM_FEAT_PS_BIT=6, + MM_FEAT_RADAR_BIT=5, + MM_FEAT_REORD_BIT=12, + MM_FEAT_TDLS_BIT=24, + MM_FEAT_UAPSD_BIT=7, + MM_FEAT_UMAC_BIT=15, + MM_FEAT_VHT_BIT=16, + MM_FEAT_WAPI_BIT=19 +} mm_features; + +typedef TickType_t EventBits_t; + +typedef struct EventGroupDef_t EventGroupDef_t, *PEventGroupDef_t; + +typedef struct EventGroupDef_t * EventGroupHandle_t; + +struct EventGroupDef_t { + EventBits_t uxEventBits; + List_t xTasksWaitingForBits; + UBaseType_t uxEventGroupNumber; + uint8_t ucStaticallyAllocated; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +typedef struct gethostbyname_r_helper gethostbyname_r_helper, *Pgethostbyname_r_helper; + +struct gethostbyname_r_helper { + ip_addr_t * addr_list[2]; + ip_addr_t addr; + char * aliases; +}; + +typedef ulonglong uintmax_t; + +typedef longlong intmax_t; + +typedef struct addrinfo addrinfo, *Paddrinfo; + +struct addrinfo { + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + socklen_t ai_addrlen; + struct sockaddr * ai_addr; + char * ai_canonname; + struct addrinfo * ai_next; +}; + +typedef struct hostent hostent, *Phostent; + +struct hostent { + char * h_name; + char * * h_aliases; + int h_addrtype; + int h_length; + char * * h_addr_list; +}; + +typedef struct EventGroupDef_t EventGroup_t; + +typedef struct Ring_Buffer_Type Ring_Buffer_Type, *PRing_Buffer_Type; + +struct Ring_Buffer_Type { + uint8_t * pointer; + uint8_t readMirror; + undefined field_0x5; + uint16_t readIndex; + uint8_t writeMirror; + undefined field_0x9; + uint16_t writeIndex; + uint16_t size; + undefined field_0xe; + undefined field_0xf; + void (* lock)(void); + void (* unlock)(void); +}; + +typedef union anon_union.conflict60 anon_union.conflict60, *Panon_union.conflict60; + +union anon_union.conflict60 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict131 anon_union.conflict131, *Panon_union.conflict131; + +union anon_union.conflict131 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict53 anon_union.conflict53, *Panon_union.conflict53; + +union anon_union.conflict53 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict178 anon_union.conflict178, *Panon_union.conflict178; + +union anon_union.conflict178 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict170 anon_union.conflict170, *Panon_union.conflict170; + +union anon_union.conflict170 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict8 anon_union.conflict8, *Panon_union.conflict8; + +union anon_union.conflict8 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict164 anon_union.conflict164, *Panon_union.conflict164; + +union anon_union.conflict164 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict22 anon_union.conflict22, *Panon_union.conflict22; + +union anon_union.conflict22 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict67 anon_union.conflict67, *Panon_union.conflict67; + +union anon_union.conflict67 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict124 anon_union.conflict124, *Panon_union.conflict124; + +union anon_union.conflict124 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict82 anon_union.conflict82, *Panon_union.conflict82; + +union anon_union.conflict82 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict73 anon_union.conflict73, *Panon_union.conflict73; + +union anon_union.conflict73 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict150 anon_union.conflict150, *Panon_union.conflict150; + +union anon_union.conflict150 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict32 anon_union.conflict32, *Panon_union.conflict32; + +union anon_union.conflict32 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict157 anon_union.conflict157, *Panon_union.conflict157; + +union anon_union.conflict157 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict39 anon_union.conflict39, *Panon_union.conflict39; + +union anon_union.conflict39 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict89 anon_union.conflict89, *Panon_union.conflict89; + +union anon_union.conflict89 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict46 anon_union.conflict46, *Panon_union.conflict46; + +union anon_union.conflict46 { + uint8_t ht[4]; +}; + +typedef union anon_union.conflict143 anon_union.conflict143, *Panon_union.conflict143; + +union anon_union.conflict143 { + uint8_t ht[4]; +}; + +typedef struct udp_hdr udp_hdr, *Pudp_hdr; + +struct udp_hdr { + u16_t src; + u16_t dest; + u16_t len; + u16_t chksum; +}; + +typedef union anon_union.conflict14 anon_union.conflict14, *Panon_union.conflict14; + +union anon_union.conflict14 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict15 anon_union.conflict15, *Panon_union.conflict15; + +union anon_union.conflict15 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef struct anon_struct.conflict345 anon_struct.conflict345, *Panon_struct.conflict345; + +struct anon_struct.conflict345 { + u32.conflict182 tx_done:1; + u32.conflict183 retry_required:1; + u32.conflict184 sw_retry_required:1; + u32.conflict185 reserved:29; +}; + +typedef union anon_union.conflict16 anon_union.conflict16, *Panon_union.conflict16; + +union anon_union.conflict16 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict18 anon_union.conflict18, *Panon_union.conflict18; + +union anon_union.conflict18 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict19 anon_union.conflict19, *Panon_union.conflict19; + +union anon_union.conflict19 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef struct anon_struct.conflict344 anon_struct.conflict344, *Panon_struct.conflict344; + +struct anon_struct.conflict344 { + u32.conflict178 tx_done:1; + u32.conflict179 retry_required:1; + u32.conflict180 sw_retry_required:1; + u32.conflict181 reserved:29; +}; + +typedef union anon_union.conflict4 anon_union.conflict4, *Panon_union.conflict4; + +union anon_union.conflict4 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict5 anon_union.conflict5, *Panon_union.conflict5; + +union anon_union.conflict5 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict6 anon_union.conflict6, *Panon_union.conflict6; + +union anon_union.conflict6 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict20 anon_union.conflict20, *Panon_union.conflict20; + +union anon_union.conflict20 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict24 anon_union.conflict24, *Panon_union.conflict24; + +union anon_union.conflict24 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict25 anon_union.conflict25, *Panon_union.conflict25; + +union anon_union.conflict25 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict26 anon_union.conflict26, *Panon_union.conflict26; + +union anon_union.conflict26 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict28 anon_union.conflict28, *Panon_union.conflict28; + +union anon_union.conflict28 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef struct rx_dmadesc rx_dmadesc, *Prx_dmadesc; + +typedef struct rx_hd rx_hd, *Prx_hd; + +typedef struct phy_channel_info phy_channel_info, *Pphy_channel_info; + +typedef struct rx_swdesc rx_swdesc, *Prx_swdesc; + +typedef struct rx_payloaddesc rx_payloaddesc, *Prx_payloaddesc; + +typedef struct rx_pbd rx_pbd, *Prx_pbd; + +struct rx_hd { + uint32_t upatternrx; + uint32_t next; + uint32_t first_pbd_ptr; + struct rx_swdesc * swdesc; + uint32_t datastartptr; + uint32_t dataendptr; + uint32_t headerctrlinfo; + uint16_t frmlen; + uint16_t ampdu_stat_info; + uint32_t tsflo; + uint32_t tsfhi; + uint32_t recvec1a; + uint32_t recvec1b; + uint32_t recvec1c; + uint32_t recvec1d; + uint32_t recvec2a; + uint32_t recvec2b; + uint32_t statinfo; +}; + +struct phy_channel_info { + uint32_t info1; + uint32_t info2; +}; + +struct rx_dmadesc { + struct rx_hd hd; + struct phy_channel_info phy_info; + uint32_t flags; + uint32_t pattern; + uint32_t payl_offset; + uint32_t reserved_pad[2]; + uint32_t use_in_tcpip; +}; + +struct rx_swdesc { + struct co_list_hdr list_hdr; + struct rx_dmadesc * dma_hdrdesc; + struct rx_payloaddesc * pd; + struct rx_pbd * last_pbd; + struct rx_pbd * spare_pbd; + uint32_t host_id; + uint32_t frame_len; + uint8_t status; + uint8_t pbd_count; + uint8_t use_in_tcpip; + undefined field_0x1f; +}; + +struct rx_pbd { + uint32_t upattern; + uint32_t next; + uint32_t datastartptr; + uint32_t dataendptr; + uint16_t bufstatinfo; + uint16_t reserved; +}; + +struct rx_payloaddesc { + struct rx_pbd pbd; + uint32_t pd_status; + uint32_t * buffer_rx; + void * pbuf_holder[6]; +}; + +typedef union anon_union.conflict29 anon_union.conflict29, *Panon_union.conflict29; + +union anon_union.conflict29 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict30 anon_union.conflict30, *Panon_union.conflict30; + +union anon_union.conflict30 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict35 anon_union.conflict35, *Panon_union.conflict35; + +union anon_union.conflict35 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict36 anon_union.conflict36, *Panon_union.conflict36; + +union anon_union.conflict36 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict37 anon_union.conflict37, *Panon_union.conflict37; + +union anon_union.conflict37 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict50 anon_union.conflict50, *Panon_union.conflict50; + +union anon_union.conflict50 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict42 anon_union.conflict42, *Panon_union.conflict42; + +union anon_union.conflict42 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict43 anon_union.conflict43, *Panon_union.conflict43; + +union anon_union.conflict43 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict44 anon_union.conflict44, *Panon_union.conflict44; + +union anon_union.conflict44 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict49 anon_union.conflict49, *Panon_union.conflict49; + +union anon_union.conflict49 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union bl_hw_txstatus bl_hw_txstatus, *Pbl_hw_txstatus; + +typedef struct anon_struct.conflict310 anon_struct.conflict310, *Panon_struct.conflict310; + +struct anon_struct.conflict310 { + u32.conflict31 tx_done:1; + u32.conflict32 retry_required:1; + u32.conflict33 sw_retry_required:1; + u32.conflict34 reserved:29; +}; + +union bl_hw_txstatus { + struct anon_struct.conflict310 field_0; + u32.conflict35 value; +}; + +typedef union anon_union.conflict51 anon_union.conflict51, *Panon_union.conflict51; + +union anon_union.conflict51 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict174 anon_union.conflict174, *Panon_union.conflict174; + +union anon_union.conflict174 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict175 anon_union.conflict175, *Panon_union.conflict175; + +union anon_union.conflict175 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict56 anon_union.conflict56, *Panon_union.conflict56; + +union anon_union.conflict56 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict57 anon_union.conflict57, *Panon_union.conflict57; + +union anon_union.conflict57 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict176 anon_union.conflict176, *Panon_union.conflict176; + +union anon_union.conflict176 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict58 anon_union.conflict58, *Panon_union.conflict58; + +union anon_union.conflict58 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef struct anon_struct.conflict309 anon_struct.conflict309, *Panon_struct.conflict309; + +struct anon_struct.conflict309 { + u32.conflict27 tx_done:1; + u32.conflict28 retry_required:1; + u32.conflict29 sw_retry_required:1; + u32.conflict30 reserved:29; +}; + +typedef union anon_union.conflict169 anon_union.conflict169, *Panon_union.conflict169; + +union anon_union.conflict169 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict70 anon_union.conflict70, *Panon_union.conflict70; + +union anon_union.conflict70 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict71 anon_union.conflict71, *Panon_union.conflict71; + +union anon_union.conflict71 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict72 anon_union.conflict72, *Panon_union.conflict72; + +union anon_union.conflict72 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict63 anon_union.conflict63, *Panon_union.conflict63; + +union anon_union.conflict63 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict64 anon_union.conflict64, *Panon_union.conflict64; + +union anon_union.conflict64 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict161 anon_union.conflict161, *Panon_union.conflict161; + +union anon_union.conflict161 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict65 anon_union.conflict65, *Panon_union.conflict65; + +union anon_union.conflict65 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict162 anon_union.conflict162, *Panon_union.conflict162; + +union anon_union.conflict162 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict167 anon_union.conflict167, *Panon_union.conflict167; + +union anon_union.conflict167 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict168 anon_union.conflict168, *Panon_union.conflict168; + +union anon_union.conflict168 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict160 anon_union.conflict160, *Panon_union.conflict160; + +union anon_union.conflict160 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict80 anon_union.conflict80, *Panon_union.conflict80; + +union anon_union.conflict80 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict153 anon_union.conflict153, *Panon_union.conflict153; + +union anon_union.conflict153 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict78 anon_union.conflict78, *Panon_union.conflict78; + +union anon_union.conflict78 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict79 anon_union.conflict79, *Panon_union.conflict79; + +union anon_union.conflict79 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict154 anon_union.conflict154, *Panon_union.conflict154; + +union anon_union.conflict154 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict155 anon_union.conflict155, *Panon_union.conflict155; + +union anon_union.conflict155 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict147 anon_union.conflict147, *Panon_union.conflict147; + +union anon_union.conflict147 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict148 anon_union.conflict148, *Panon_union.conflict148; + +union anon_union.conflict148 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict92 anon_union.conflict92, *Panon_union.conflict92; + +union anon_union.conflict92 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict93 anon_union.conflict93, *Panon_union.conflict93; + +union anon_union.conflict93 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict94 anon_union.conflict94, *Panon_union.conflict94; + +union anon_union.conflict94 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict141 anon_union.conflict141, *Panon_union.conflict141; + +union anon_union.conflict141 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict85 anon_union.conflict85, *Panon_union.conflict85; + +union anon_union.conflict85 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict86 anon_union.conflict86, *Panon_union.conflict86; + +union anon_union.conflict86 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict87 anon_union.conflict87, *Panon_union.conflict87; + +union anon_union.conflict87 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict140 anon_union.conflict140, *Panon_union.conflict140; + +union anon_union.conflict140 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict146 anon_union.conflict146, *Panon_union.conflict146; + +union anon_union.conflict146 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict139 anon_union.conflict139, *Panon_union.conflict139; + +union anon_union.conflict139 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict136 anon_union.conflict136, *Panon_union.conflict136; + +union anon_union.conflict136 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union bl_hw_txstatus.conflict3 bl_hw_txstatus.conflict3, *Pbl_hw_txstatus.conflict3; + +union bl_hw_txstatus.conflict3 { + struct anon_struct.conflict345 field_0; + u32.conflict186 value; +}; + +typedef union anon_union.conflict97 anon_union.conflict97, *Panon_union.conflict97; + +union anon_union.conflict97 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict98 anon_union.conflict98, *Panon_union.conflict98; + +union anon_union.conflict98 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict99 anon_union.conflict99, *Panon_union.conflict99; + +union anon_union.conflict99 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict134 anon_union.conflict134, *Panon_union.conflict134; + +union anon_union.conflict134 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict135 anon_union.conflict135, *Panon_union.conflict135; + +union anon_union.conflict135 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict127 anon_union.conflict127, *Panon_union.conflict127; + +union anon_union.conflict127 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict128 anon_union.conflict128, *Panon_union.conflict128; + +union anon_union.conflict128 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict129 anon_union.conflict129, *Panon_union.conflict129; + +union anon_union.conflict129 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict120 anon_union.conflict120, *Panon_union.conflict120; + +union anon_union.conflict120 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict121 anon_union.conflict121, *Panon_union.conflict121; + +union anon_union.conflict121 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict122 anon_union.conflict122, *Panon_union.conflict122; + +union anon_union.conflict122 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict116 anon_union.conflict116, *Panon_union.conflict116; + +union anon_union.conflict116 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict117 anon_union.conflict117, *Panon_union.conflict117; + +union anon_union.conflict117 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict114 anon_union.conflict114, *Panon_union.conflict114; + +union anon_union.conflict114 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict118 anon_union.conflict118, *Panon_union.conflict118; + +union anon_union.conflict118 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict112 anon_union.conflict112, *Panon_union.conflict112; + +union anon_union.conflict112 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict113 anon_union.conflict113, *Panon_union.conflict113; + +union anon_union.conflict113 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict103 anon_union.conflict103, *Panon_union.conflict103; + +union anon_union.conflict103 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict104 anon_union.conflict104, *Panon_union.conflict104; + +union anon_union.conflict104 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict109 anon_union.conflict109, *Panon_union.conflict109; + +union anon_union.conflict109 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +typedef union anon_union.conflict107 anon_union.conflict107, *Panon_union.conflict107; + +union anon_union.conflict107 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef union anon_union.conflict108 anon_union.conflict108, *Panon_union.conflict108; + +union anon_union.conflict108 { + uint32_t datastartptr; + uint32_t sec_user2_ptr; +}; + +typedef union anon_union.conflict102 anon_union.conflict102, *Panon_union.conflict102; + +union anon_union.conflict102 { + uint32_t first_pbd_ptr; + uint32_t sec_user1_ptr; +}; + +typedef enum PtTable_ID_Type { + PT_TABLE_ID_0=0, + PT_TABLE_ID_1=1, + PT_TABLE_ID_INVALID=2 +} PtTable_ID_Type; + +typedef struct PtTable_Entry_Config PtTable_Entry_Config, *PPtTable_Entry_Config; + +struct PtTable_Entry_Config { + uint8_t type; + uint8_t device; + uint8_t activeIndex; + uint8_t name[9]; + uint32_t Address[2]; + uint32_t maxLen[2]; + uint32_t len; + uint32_t age; +}; + +typedef struct PtTable_Stuff_Config PtTable_Stuff_Config, *PPtTable_Stuff_Config; + +typedef struct PtTable_Config PtTable_Config, *PPtTable_Config; + +struct PtTable_Config { + uint32_t magicCode; + uint16_t version; + uint16_t entryCnt; + uint32_t age; + uint32_t crc32; +}; + +struct PtTable_Stuff_Config { + struct PtTable_Config ptTable; + struct PtTable_Entry_Config ptEntries[16]; + uint32_t crc32; +}; + +typedef enum PtTable_Error_Type { + PT_ERROR_CRC32=4, + PT_ERROR_ENTRY_NOT_FOUND=2, + PT_ERROR_ENTRY_UPDATE_FAIL=3, + PT_ERROR_FALSH_ERASE=8, + PT_ERROR_FALSH_READ=6, + PT_ERROR_FALSH_WRITE=7, + PT_ERROR_PARAMETER=5, + PT_ERROR_SUCCESS=0, + PT_ERROR_TABLE_NOT_VALID=1 +} PtTable_Error_Type; + +typedef enum PtTable_Entry_Type { + PT_ENTRY_FW_CPU0=0, + PT_ENTRY_FW_CPU1=1, + PT_ENTRY_MAX=16 +} PtTable_Entry_Type; + +typedef enum _blog_leve { + BLOG_LEVEL_ALL=0, + BLOG_LEVEL_ASSERT=5, + BLOG_LEVEL_DEBUG=1, + BLOG_LEVEL_ERROR=4, + BLOG_LEVEL_INFO=2, + BLOG_LEVEL_NEVER=6, + BLOG_LEVEL_WARN=3 +} _blog_leve; + +typedef enum _blog_leve blog_level_t; + +typedef struct _blog_info _blog_info, *P_blog_info; + +typedef struct _blog_info blog_info_t; + +struct _blog_info { + blog_level_t * level; + char * name; +}; + +typedef struct netconn.conflict netconn.conflict, *Pnetconn.conflict; + +struct netconn.conflict { + enum netconn_type type; + enum netconn_state state; + undefined field_0x2; + undefined field_0x3; + union anon_union_for_pcb pcb; + err_t pending_err; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + sys_sem_t op_completed; + sys_mbox_t recvmbox; + sys_mbox_t acceptmbox; + int socket; + s32_t send_timeout; + u32_t recv_timeout; + u8_t flags; + undefined field_0x25; + undefined field_0x26; + undefined field_0x27; + struct api_msg * current_msg; + void (* callback)(struct netconn *, enum netconn_evt, u16_t); +}; + +typedef struct netconn.conflict1 netconn.conflict1, *Pnetconn.conflict1; + +struct netconn.conflict1 { + enum netconn_type type; + enum netconn_state state; + undefined field_0x2; + undefined field_0x3; + union anon_union_for_pcb pcb; + err_t pending_err; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + sys_sem_t op_completed; + sys_mbox_t recvmbox; + sys_mbox_t acceptmbox; + int socket; + s32_t send_timeout; + u32_t recv_timeout; + u8_t flags; + undefined field_0x25; + undefined field_0x26; + undefined field_0x27; + struct api_msg * current_msg; + void (* callback)(struct netconn *, enum netconn_evt, u16_t); +}; + +typedef struct _bl_sha_SEC_Eng_SHA256_Ctx_t _bl_sha_SEC_Eng_SHA256_Ctx_t, *P_bl_sha_SEC_Eng_SHA256_Ctx_t; + +struct _bl_sha_SEC_Eng_SHA256_Ctx_t { + uint32_t total[2]; + uint32_t * shaBuf; + uint32_t * shaPadding; + uint8_t shaFeed; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; +}; + +typedef enum bl_sha_type_t { + BL_SHA1=2, + BL_SHA224=1, + BL_SHA256=0 +} bl_sha_type_t; + +typedef struct bl_sha_ctx bl_sha_ctx, *Pbl_sha_ctx; + +struct bl_sha_ctx { + struct _bl_sha_SEC_Eng_SHA256_Ctx_t sha_ctx; + uint32_t tmp[16]; + uint32_t pad[16]; +}; + +typedef struct bl_sha_ctx bl_sha_ctx_t; + +typedef struct Efuse_Ana_RC32M_Trim_Type Efuse_Ana_RC32M_Trim_Type, *PEfuse_Ana_RC32M_Trim_Type; + +struct Efuse_Ana_RC32M_Trim_Type { + uint32_t trimRc32mCodeFrExt:8; + uint32_t trimRc32mCodeFrExtParity:1; + uint32_t trimRc32mExtCodeEn:1; + uint32_t reserved:22; +}; + +typedef struct Efuse_Ana_RC32K_Trim_Type Efuse_Ana_RC32K_Trim_Type, *PEfuse_Ana_RC32K_Trim_Type; + +struct Efuse_Ana_RC32K_Trim_Type { + uint32_t trimRc32kCodeFrExt:10; + uint32_t trimRc32kCodeFrExtParity:1; + uint32_t trimRc32kExtCodeEn:1; + uint32_t reserved:20; +}; + +typedef struct Efuse_Capcode_Info_Type Efuse_Capcode_Info_Type, *PEfuse_Capcode_Info_Type; + +struct Efuse_Capcode_Info_Type { + uint32_t capCode:6; + uint32_t parity:1; + uint32_t en:1; + uint32_t rsvd:24; +}; + +typedef enum EF_Ctrl_Sign_Type { + EF_CTRL_SIGN_ECC=2, + EF_CTRL_SIGN_NONE=0, + EF_CTRL_SIGN_RSA=1 +} EF_Ctrl_Sign_Type; + +typedef struct Efuse_Device_Info_Type Efuse_Device_Info_Type, *PEfuse_Device_Info_Type; + +struct Efuse_Device_Info_Type { + uint32_t rsvd:22; + uint32_t customerID:2; + uint32_t rsvd_info:3; + uint32_t memoryInfo:2; + uint32_t coreInfo:1; + uint32_t mcuInfo:1; + uint32_t pinInfo:1; +}; + +typedef struct Efuse_TSEN_Refcode_Corner_Type Efuse_TSEN_Refcode_Corner_Type, *PEfuse_TSEN_Refcode_Corner_Type; + +struct Efuse_TSEN_Refcode_Corner_Type { + uint32_t tsenRefcodeCorner:12; + uint32_t tsenRefcodeCornerParity:1; + uint32_t tsenRefcodeCornerEn:1; + uint32_t tsenRefcodeCornerVersion:1; + uint32_t reserved:17; +}; + +typedef enum EF_Ctrl_SF_AES_Type { + EF_CTRL_SF_AES_128=1, + EF_CTRL_SF_AES_192=2, + EF_CTRL_SF_AES_256=3, + EF_CTRL_SF_AES_NONE=0 +} EF_Ctrl_SF_AES_Type; + +typedef struct Efuse_ADC_Gain_Coeff_Type Efuse_ADC_Gain_Coeff_Type, *PEfuse_ADC_Gain_Coeff_Type; + +struct Efuse_ADC_Gain_Coeff_Type { + uint32_t adcGainCoeff:12; + uint32_t adcGainCoeffParity:1; + uint32_t adcGainCoeffEn:1; + uint32_t reserved:18; +}; + +typedef struct EF_Ctrl_Sec_Param_Type EF_Ctrl_Sec_Param_Type, *PEF_Ctrl_Sec_Param_Type; + +typedef enum EF_Ctrl_Dbg_Mode_Type { + EF_CTRL_DBG_CLOSE=4, + EF_CTRL_DBG_OPEN=0, + EF_CTRL_DBG_PASSWORD=1 +} EF_Ctrl_Dbg_Mode_Type; + +struct EF_Ctrl_Sec_Param_Type { + enum EF_Ctrl_Dbg_Mode_Type ef_dbg_mode; + uint8_t ef_dbg_jtag_0_dis; + uint8_t ef_sboot_en; + uint8_t ef_no_hd_boot_en; +}; + +typedef struct anon_struct.conflict1 anon_struct.conflict1, *Panon_struct.conflict1; + +struct anon_struct.conflict1 { + uint8_t priority; + uint8_t id_dst; + uint8_t id_msg; + uint8_t id_src; +}; + +typedef union anon_union.conflict2 anon_union.conflict2, *Panon_union.conflict2; + +union anon_union.conflict2 { + void * container; + struct anon_struct.conflict1 header; +}; + +typedef struct anon_struct.conflict373 anon_struct.conflict373, *Panon_struct.conflict373; + +struct anon_struct.conflict373 { + uint8_t priority; + uint8_t id_dst; + uint8_t id_msg; + uint8_t id_src; +}; + +typedef struct anon_struct.conflict412 anon_struct.conflict412, *Panon_struct.conflict412; + +struct anon_struct.conflict412 { + uint8_t priority; + uint8_t id_dst; + uint8_t id_msg; + uint8_t id_src; +}; + +typedef struct anon_struct.conflict413 anon_struct.conflict413, *Panon_struct.conflict413; + +struct anon_struct.conflict413 { + uint8_t priority; + uint8_t id_dst; + uint8_t id_msg; + uint8_t id_src; +}; + +typedef struct anon_struct.conflict374 anon_struct.conflict374, *Panon_struct.conflict374; + +struct anon_struct.conflict374 { + uint8_t priority; + uint8_t id_dst; + uint8_t id_msg; + uint8_t id_src; +}; + +typedef struct xSTATIC_QUEUE xSTATIC_QUEUE, *PxSTATIC_QUEUE; + + +// WARNING! conflicting data type names: /DWARF/FreeRTOS.h/xSTATIC_QUEUE/anon_union_for_u - /DWARF/timers.c/tmrTimerQueueMessage/anon_union_for_u + +struct xSTATIC_QUEUE { + void * pvDummy1[3]; + union anon_union_for_u u; + StaticList_t xDummy3[2]; + UBaseType_t uxDummy4[3]; + uint8_t ucDummy5[2]; + uint8_t ucDummy6; + undefined field_0x47; + UBaseType_t uxDummy8; + uint8_t ucDummy9; + undefined field_0x4d; + undefined field_0x4e; + undefined field_0x4f; +}; + +typedef struct xSTATIC_QUEUE StaticQueue_t; + +typedef StaticQueue_t StaticSemaphore_t; + +typedef struct aos_hdl_t aos_hdl_t, *Paos_hdl_t; + +typedef struct aos_hdl_t aos_timer_t; + +struct aos_hdl_t { + void * hdl; +}; + +typedef struct aos_hdl_t aos_queue_t; + +typedef uint aos_task_key_t; + +typedef struct aos_hdl_t aos_sem_t; + +typedef struct aos_hdl_t aos_task_t; + +typedef struct aos_hdl_t aos_mutex_t; + +typedef struct aos_hdl_t aos_work_t; + +typedef struct aos_workqueue_t aos_workqueue_t, *Paos_workqueue_t; + +struct aos_workqueue_t { + void * hdl; + void * stk; +}; + +typedef uint16_t ke_state_t; + +typedef struct ke_msg ke_msg, *Pke_msg; + +struct ke_msg { + struct co_list_hdr hdr; + ke_msg_id_t id; + ke_task_id_t dest_id; + ke_task_id_t src_id; + uint16_t param_len; + uint32_t[0] param; +}; + +typedef enum ke_msg_status_tag { + KE_MSG_CONSUMED=0, + KE_MSG_NO_FREE=1, + KE_MSG_SAVED=2 +} ke_msg_status_tag; + +typedef enum CFG_ELEMENT_TYPE { + CFG_ELEMENT_TYPE_BOOLEAN=1, + CFG_ELEMENT_TYPE_SINT16=4, + CFG_ELEMENT_TYPE_SINT32=6, + CFG_ELEMENT_TYPE_SINT8=2, + CFG_ELEMENT_TYPE_STRING=8, + CFG_ELEMENT_TYPE_UINT16=5, + CFG_ELEMENT_TYPE_UINT32=7, + CFG_ELEMENT_TYPE_UINT8=3, + CFG_ELEMENT_TYPE_UNKNOWN=0 +} CFG_ELEMENT_TYPE; + +typedef struct mac_addr.conflict19 mac_addr.conflict19, *Pmac_addr.conflict19; + +struct mac_addr.conflict19 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict102 mac_addr.conflict102, *Pmac_addr.conflict102; + +struct mac_addr.conflict102 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict38 mac_addr.conflict38, *Pmac_addr.conflict38; + +struct mac_addr.conflict38 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict37 mac_addr.conflict37, *Pmac_addr.conflict37; + +struct mac_addr.conflict37 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict136 mac_addr.conflict136, *Pmac_addr.conflict136; + +struct mac_addr.conflict136 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict mac_addr.conflict, *Pmac_addr.conflict; + +struct mac_addr.conflict { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict58 mac_addr.conflict58, *Pmac_addr.conflict58; + +struct mac_addr.conflict58 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict123 mac_addr.conflict123, *Pmac_addr.conflict123; + +struct mac_addr.conflict123 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict77 mac_addr.conflict77, *Pmac_addr.conflict77; + +struct mac_addr.conflict77 { + u8_l array[6]; +}; + +typedef struct mac_addr.conflict153 mac_addr.conflict153, *Pmac_addr.conflict153; + +struct mac_addr.conflict153 { + u8_l array[6]; +}; + +typedef enum ADC_Data_Width_Type { + ADC_DATA_WIDTH_12=0, + ADC_DATA_WIDTH_14_WITH_16_AVERAGE=1, + ADC_DATA_WIDTH_16_WITH_128_AVERAGE=3, + ADC_DATA_WIDTH_16_WITH_256_AVERAGE=4, + ADC_DATA_WIDTH_16_WITH_64_AVERAGE=2 +} ADC_Data_Width_Type; + +typedef enum ADC_Chan_Type { + ADC_CHAN0=0, + ADC_CHAN1=1, + ADC_CHAN10=10, + ADC_CHAN11=11, + ADC_CHAN2=2, + ADC_CHAN3=3, + ADC_CHAN4=4, + ADC_CHAN5=5, + ADC_CHAN6=6, + ADC_CHAN7=7, + ADC_CHAN8=8, + ADC_CHAN9=9, + ADC_CHAN_DAC_OUTA=12, + ADC_CHAN_DAC_OUTB=13, + ADC_CHAN_DCTEST=17, + ADC_CHAN_GND=23, + ADC_CHAN_SENP0=22, + ADC_CHAN_SENP1=21, + ADC_CHAN_SENP2=20, + ADC_CHAN_SENP3=19, + ADC_CHAN_TSEN_N=15, + ADC_CHAN_TSEN_P=14, + ADC_CHAN_VABT_HALF=18, + ADC_CHAN_VREF=16 +} ADC_Chan_Type; + +typedef enum ADC_INT_Type { + ADC_INT_ADC_READY=4, + ADC_INT_ALL=5, + ADC_INT_FIFO_OVERRUN=3, + ADC_INT_FIFO_UNDERRUN=2, + ADC_INT_NEG_SATURATION=1, + ADC_INT_POS_SATURATION=0 +} ADC_INT_Type; + +typedef struct ADC_Result_Type ADC_Result_Type, *PADC_Result_Type; + +struct ADC_Result_Type { + int8_t posChan; + int8_t negChan; + uint16_t value; + float volt; +}; + +typedef enum ADC_V18_SEL_Type { + ADC_V18_SEL_1P62V=0, + ADC_V18_SEL_1P72V=1, + ADC_V18_SEL_1P82V=2, + ADC_V18_SEL_1P92V=3 +} ADC_V18_SEL_Type; + +typedef enum ADC_PGA_GAIN_Type { + ADC_PGA_GAIN_1=1, + ADC_PGA_GAIN_16=5, + ADC_PGA_GAIN_2=2, + ADC_PGA_GAIN_32=6, + ADC_PGA_GAIN_4=3, + ADC_PGA_GAIN_8=4, + ADC_PGA_GAIN_NONE=0 +} ADC_PGA_GAIN_Type; + +typedef struct ADC_CFG_Type ADC_CFG_Type, *PADC_CFG_Type; + +typedef enum ADC_V11_SEL_Type { + ADC_V11_SEL_1P0V=0, + ADC_V11_SEL_1P18V=2, + ADC_V11_SEL_1P1V=1, + ADC_V11_SEL_1P26V=3 +} ADC_V11_SEL_Type; + +typedef enum ADC_CLK_Type { + ADC_CLK_DIV_1=0, + ADC_CLK_DIV_12=3, + ADC_CLK_DIV_16=4, + ADC_CLK_DIV_20=5, + ADC_CLK_DIV_24=6, + ADC_CLK_DIV_32=7, + ADC_CLK_DIV_4=1, + ADC_CLK_DIV_8=2 +} ADC_CLK_Type; + +typedef enum ADC_CHOP_MOD_Type { + ADC_CHOP_MOD_ALL_OFF=0, + ADC_CHOP_MOD_AZ_ON=1, + ADC_CHOP_MOD_AZ_PGA_ON=2, + ADC_CHOP_MOD_AZ_PGA_RPC_ON=3 +} ADC_CHOP_MOD_Type; + +typedef enum ADC_BIAS_SEL_Type { + ADC_BIAS_SEL_AON_BANDGAP=1, + ADC_BIAS_SEL_MAIN_BANDGAP=0 +} ADC_BIAS_SEL_Type; + +typedef enum ADC_PGA_VCM_Type { + ADC_PGA_VCM_1P2V=1, + ADC_PGA_VCM_1P4V=2, + ADC_PGA_VCM_1P6V=3, + ADC_PGA_VCM_1V=0 +} ADC_PGA_VCM_Type; + +typedef enum ADC_VREF_Type { + ADC_VREF_2V=1, + ADC_VREF_3P2V=0 +} ADC_VREF_Type; + +typedef enum ADC_SIG_INPUT_Type { + ADC_INPUT_DIFF=1, + ADC_INPUT_SINGLE_END=0 +} ADC_SIG_INPUT_Type; + +struct ADC_CFG_Type { + enum ADC_V18_SEL_Type v18Sel; + enum ADC_V11_SEL_Type v11Sel; + enum ADC_CLK_Type clkDiv; + enum ADC_PGA_GAIN_Type gain1; + enum ADC_PGA_GAIN_Type gain2; + enum ADC_CHOP_MOD_Type chopMode; + enum ADC_BIAS_SEL_Type biasSel; + enum ADC_PGA_VCM_Type vcm; + enum ADC_VREF_Type vref; + enum ADC_SIG_INPUT_Type inputMode; + enum ADC_Data_Width_Type resWidth; + enum BL_Fun_Type offsetCalibEn; + int16_t offsetCalibVal; +}; + +typedef struct ADC_MIC_Type ADC_MIC_Type, *PADC_MIC_Type; + +typedef enum ADC_MICBOOST_DB_Type { + ADC_MICBOOST_DB_16DB=0, + ADC_MICBOOST_DB_32DB=1 +} ADC_MICBOOST_DB_Type; + +typedef enum ADC_PGA2_GAIN_Type { + ADC_PGA2_GAIN_0DB=0, + ADC_PGA2_GAIN_12DB=3, + ADC_PGA2_GAIN_6DB=1, + ADC_PGA2_GAIN_N6DB=2 +} ADC_PGA2_GAIN_Type; + +typedef enum ADC_MIC_MODE_Type { + ADC_MIC_MODE_DIFF=1, + ADC_MIC_MODE_SINGLE=0 +} ADC_MIC_MODE_Type; + +struct ADC_MIC_Type { + enum ADC_MICBOOST_DB_Type micboostDb; + enum ADC_PGA2_GAIN_Type micPga2Gain; + enum ADC_MIC_MODE_Type mic1Mode; + enum ADC_MIC_MODE_Type mic2Mode; + enum BL_Fun_Type dwaEn; + enum BL_Fun_Type micboostBypassEn; + enum BL_Fun_Type micPgaEn; + enum BL_Fun_Type micBiasEn; +}; + +typedef struct ADC_Gain_Coeff_Type ADC_Gain_Coeff_Type, *PADC_Gain_Coeff_Type; + +struct ADC_Gain_Coeff_Type { + enum BL_Fun_Type adcGainCoeffEnable; + undefined field_0x1; + uint16_t adcgainCoeffVal; + float coe; +}; + +typedef enum ADC_TSEN_MOD_Type { + ADC_TSEN_MOD_EXTERNAL_DIODE=1, + ADC_TSEN_MOD_INTERNAL_DIODE=0 +} ADC_TSEN_MOD_Type; + +typedef struct ADC_FIFO_Cfg_Type ADC_FIFO_Cfg_Type, *PADC_FIFO_Cfg_Type; + +typedef enum ADC_FIFO_Threshold_Type { + ADC_FIFO_THRESHOLD_1=0, + ADC_FIFO_THRESHOLD_16=3, + ADC_FIFO_THRESHOLD_4=1, + ADC_FIFO_THRESHOLD_8=2 +} ADC_FIFO_Threshold_Type; + +struct ADC_FIFO_Cfg_Type { + enum ADC_FIFO_Threshold_Type fifoThreshold; + enum BL_Fun_Type dmaEn; +}; + +typedef struct anon_struct.conflict54 anon_struct.conflict54, *Panon_struct.conflict54; + +struct anon_struct.conflict54 { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict53 anon_struct.conflict53, *Panon_struct.conflict53; + +struct anon_struct.conflict53 { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict58 anon_struct.conflict58, *Panon_struct.conflict58; + +struct anon_struct.conflict58 { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct anon_struct.conflict57 anon_struct.conflict57, *Panon_struct.conflict57; + +struct anon_struct.conflict57 { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct anon_struct.conflict56 anon_struct.conflict56, *Panon_struct.conflict56; + +struct anon_struct.conflict56 { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct anon_struct.conflict55 anon_struct.conflict55, *Panon_struct.conflict55; + +struct anon_struct.conflict55 { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct anon_struct.conflict140 anon_struct.conflict140, *Panon_struct.conflict140; + +struct anon_struct.conflict140 { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict141 anon_struct.conflict141, *Panon_struct.conflict141; + +struct anon_struct.conflict141 { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct anon_struct.conflict142 anon_struct.conflict142, *Panon_struct.conflict142; + +struct anon_struct.conflict142 { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct anon_struct.conflict143 anon_struct.conflict143, *Panon_struct.conflict143; + +struct anon_struct.conflict143 { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct anon_struct.conflict144 anon_struct.conflict144, *Panon_struct.conflict144; + +struct anon_struct.conflict144 { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct regs_to_opti regs_to_opti, *Pregs_to_opti; + +struct regs_to_opti { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct notch_param notch_param, *Pnotch_param; + +struct notch_param { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct tx_pwr_index tx_pwr_index, *Ptx_pwr_index; + +struct tx_pwr_index { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict136 anon_struct.conflict136, *Panon_struct.conflict136; + +struct anon_struct.conflict136 { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct anon_struct.conflict137 anon_struct.conflict137, *Panon_struct.conflict137; + +struct anon_struct.conflict137 { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct anon_struct.conflict138 anon_struct.conflict138, *Panon_struct.conflict138; + +struct anon_struct.conflict138 { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct anon_struct.conflict139 anon_struct.conflict139, *Panon_struct.conflict139; + +struct anon_struct.conflict139 { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict133 anon_struct.conflict133, *Panon_struct.conflict133; + +struct anon_struct.conflict133 { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict134 anon_struct.conflict134, *Panon_struct.conflict134; + +struct anon_struct.conflict134 { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict135 anon_struct.conflict135, *Panon_struct.conflict135; + +struct anon_struct.conflict135 { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef enum __fdlibm_version { + __fdlibm_ieee=-1, + __fdlibm_posix=0 +} __fdlibm_version; + +typedef struct HWStateMachineReg HWStateMachineReg, *PHWStateMachineReg; + +struct HWStateMachineReg { + uint32_t rxControl:6; + uint32_t reserved_7_6:2; + uint32_t txControl:9; + uint32_t reserved_23_17:7; + uint32_t macControl:8; +}; + +typedef struct dump_data_t dump_data_t, *Pdump_data_t; + +struct dump_data_t { + uint32_t time; + char * func_name; + uint32_t rc_state; + uint32_t rf_state; + uint32_t mac_debugRegHWSM1; + uint32_t mac_debugRegHWSM2; + uint16_t mac_debugPortCoex; + uint16_t mac_debugPortBackoff; + uint16_t mac_debugPortMacPhyIf; + uint16_t mac_debugPortMacPhyIf2; + uint16_t phy_debugPortMainFSM; + uint16_t phy_debugPortTDTX; + uint16_t phy_debugPortDSSSCCK1; + uint16_t phy_debugPortDSSSCCKTx; +}; + +typedef struct mem mem, *Pmem; + +struct mem { + mem_size_t next; + mem_size_t prev; + u8_t used; + undefined field_0x5; +}; + +typedef struct mbedtls_ecp_keypair mbedtls_ecp_keypair, *Pmbedtls_ecp_keypair; + +typedef struct mbedtls_ecp_group mbedtls_ecp_group, *Pmbedtls_ecp_group; + +typedef struct mbedtls_mpi mbedtls_mpi, *Pmbedtls_mpi; + +typedef struct mbedtls_ecp_point mbedtls_ecp_point, *Pmbedtls_ecp_point; + +typedef uint32_t mbedtls_mpi_uint; + +struct mbedtls_mpi { + int s; + size_t n; + mbedtls_mpi_uint * p; +}; + +struct mbedtls_ecp_point { + struct mbedtls_mpi X; + struct mbedtls_mpi Y; + struct mbedtls_mpi Z; +}; + +struct mbedtls_ecp_group { + enum mbedtls_ecp_group_id id; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + struct mbedtls_mpi P; + struct mbedtls_mpi A; + struct mbedtls_mpi B; + struct mbedtls_ecp_point G; + struct mbedtls_mpi N; + size_t pbits; + size_t nbits; + uint h; + int (* modp)(struct mbedtls_mpi *); + int (* t_pre)(struct mbedtls_ecp_point *, void *); + int (* t_post)(struct mbedtls_ecp_point *, void *); + void * t_data; + struct mbedtls_ecp_point * T; + size_t T_size; +}; + +struct mbedtls_ecp_keypair { + struct mbedtls_ecp_group grp; + struct mbedtls_mpi d; + struct mbedtls_ecp_point Q; +}; + +typedef struct mbedtls_ecp_curve_info mbedtls_ecp_curve_info, *Pmbedtls_ecp_curve_info; + +struct mbedtls_ecp_curve_info { + enum mbedtls_ecp_group_id grp_id; + undefined field_0x1; + uint16_t tls_id; + uint16_t bit_size; + undefined field_0x6; + undefined field_0x7; + char * name; +}; + +typedef enum lwip_iana_hwtype { + LWIP_IANA_HWTYPE_ETHERNET=1 +} lwip_iana_hwtype; + +typedef enum lwip_iana_port_number { + LWIP_IANA_PORT_DHCP_CLIENT=68, + LWIP_IANA_PORT_DHCP_SERVER=67, + LWIP_IANA_PORT_HTTP=80, + LWIP_IANA_PORT_HTTPS=443, + LWIP_IANA_PORT_MDNS=5353, + LWIP_IANA_PORT_MQTT=1883, + LWIP_IANA_PORT_NETBIOS=-119, + LWIP_IANA_PORT_SECURE_MQTT=8883, + LWIP_IANA_PORT_SMTP=25, + LWIP_IANA_PORT_SMTPS=465, + LWIP_IANA_PORT_SNMP=-95, + LWIP_IANA_PORT_SNMP_TRAP=-94, + LWIP_IANA_PORT_SNTP=123, + LWIP_IANA_PORT_TFTP=69 +} lwip_iana_port_number; + +typedef enum ecp_curve_type { + ECP_TYPE_MONTGOMERY=2, + ECP_TYPE_NONE=0, + ECP_TYPE_SHORT_WEIERSTRASS=1 +} ecp_curve_type; + +typedef enum stateM_handleEventRetVals { + stateM_errArg=-2, + stateM_errorStateReached=-1, + stateM_finalStateReached=3, + stateM_noStateChange=2, + stateM_stateChanged=0, + stateM_stateLoopSelf=1 +} stateM_handleEventRetVals; + +typedef enum netifapi_arp_entry { + NETIFAPI_ARP_PERM=0 +} netifapi_arp_entry; + +typedef struct rxl_hwdesc_env_tag rxl_hwdesc_env_tag, *Prxl_hwdesc_env_tag; + +struct rxl_hwdesc_env_tag { + struct rx_pbd * last; + struct rx_pbd * free; +}; + +typedef struct sntp_msg sntp_msg, *Psntp_msg; + +struct sntp_msg { + u8_t li_vn_mode; + u8_t stratum; + u8_t poll; + u8_t precision; + u32_t root_delay; + u32_t root_dispersion; + u32_t reference_identifier; + u32_t reference_timestamp[2]; + u32_t originate_timestamp[2]; + u32_t receive_timestamp[2]; + u32_t transmit_timestamp[2]; +}; + +typedef struct sntp_time sntp_time, *Psntp_time; + +struct sntp_time { + u32_t sec; + u32_t frac; +}; + +typedef struct sntp_server sntp_server, *Psntp_server; + +struct sntp_server { + char * name; + ip_addr_t addr; + u8_t reachability; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct sntp_timestamps sntp_timestamps, *Psntp_timestamps; + +struct sntp_timestamps { + struct sntp_time xmit; +}; + +typedef struct KDE_t KDE_t, *PKDE_t; + +struct KDE_t { + UINT8 type; + UINT8 length; + UINT8 OUI[3]; + UINT8 dataType; + UINT8 data[1]; +}; + +typedef struct Hdr_8021x_t Hdr_8021x_t, *PHdr_8021x_t; + +struct Hdr_8021x_t { + UINT8 protocol_ver; + enum IEEEtypes_8021x_PacketType_e pckt_type; + UINT16 pckt_body_len; +}; + +typedef struct EAPOL_KeyMsg_t EAPOL_KeyMsg_t, *PEAPOL_KeyMsg_t; + +typedef struct key_info_t key_info_t, *Pkey_info_t; + +struct key_info_t { + UINT16 KeyMIC:1; + UINT16 Secure:1; + UINT16 Error:1; + UINT16 Request:1; + UINT16 EncryptedKeyData:1; + UINT16 Reserved:3; + UINT16 KeyDescriptorVersion:3; + UINT16 KeyType:1; + UINT16 KeyIndex:2; + UINT16 Install:1; + UINT16 KeyAck:1; +}; + +struct EAPOL_KeyMsg_t { + struct Hdr_8021x_t hdr_8021x; + UINT8 desc_type; + struct key_info_t key_info; + UINT16 key_length; + UINT32 replay_cnt[2]; + UINT8 key_nonce[32]; + UINT8 EAPOL_key_IV[16]; + UINT8 key_RSC[8]; + UINT8 key_ID[8]; + UINT8 key_MIC[16]; + UINT16 key_material_len; + UINT8 key_data[1]; +}; + +typedef struct EAPOL_KeyMsg_Tx_t EAPOL_KeyMsg_Tx_t, *PEAPOL_KeyMsg_Tx_t; + +struct EAPOL_KeyMsg_Tx_t { + struct ether_hdr_t ethHdr; + struct EAPOL_KeyMsg_t keyMsg; +}; + +typedef struct EAP_PacketMsg_t EAP_PacketMsg_t, *PEAP_PacketMsg_t; + +struct EAP_PacketMsg_t { + struct Hdr_8021x_t hdr_8021x; + enum IEEEtypes_8021x_CodeType_e code; + UINT8 identifier; + UINT16 length; + UINT8 data[1]; +}; + +typedef struct GTK_KDE_t GTK_KDE_t, *PGTK_KDE_t; + +struct GTK_KDE_t { + UINT8 KeyID:2; + UINT8 Tx:1; + UINT8 rsvd:5; + UINT8 rsvd1; + UINT8 GTK[1]; +}; + +typedef struct event_dev_t event_dev_t, *Pevent_dev_t; + +struct event_dev_t { + aos_mutex_t mutex; + void (* poll_cb)(struct pollfd *, void *); + struct pollfd * fd; + void * poll_data; + int counter; + dlist_t bufs; + int cache_count; + dlist_t buf_cache; +}; + +typedef struct dev_event_t dev_event_t, *Pdev_event_t; + +struct dev_event_t { + dlist_t node; + size_t len; + char[0] buf; +}; + +typedef union anon_union.conflict188 anon_union.conflict188, *Panon_union.conflict188; + +union anon_union.conflict188 { + u32_t u32_addr[4]; + u8_t u8_addr[16]; +}; + +typedef struct in6_addr in6_addr, *Pin6_addr; + +typedef union anon_union_for_un anon_union_for_un, *Panon_union_for_un; + +union anon_union_for_un { + u32_t u32_addr[4]; + u8_t u8_addr[16]; +}; + +struct in6_addr { + union anon_union_for_un un; +}; + +typedef union anon_union.conflict1 anon_union.conflict1, *Panon_union.conflict1; + +union anon_union.conflict1 { + u32_t u32_addr[4]; + u8_t u8_addr[16]; +}; + +typedef uint64_t fdt64_t; + +typedef uint32_t fdt32_t; + +typedef ulong fd_mask; + +typedef struct _types_fd_set _types_fd_set, *P_types_fd_set; + +struct _types_fd_set { + fd_mask fds_bits[2]; +}; + +typedef struct poll_arg poll_arg, *Ppoll_arg; + +struct poll_arg { + aos_sem_t sem; +}; + +typedef struct TkipPtk_t TkipPtk_t, *PTkipPtk_t; + +struct TkipPtk_t { + UINT8 kck[16]; + UINT8 kek[16]; + UINT8 tk[16]; + UINT8 rxMicKey[8]; + UINT8 txMicKey[8]; +}; + +typedef struct getopt_env getopt_env, *Pgetopt_env; + +typedef struct getopt_env getopt_env_t; + +struct getopt_env { + char * optarg; + int optind; + int opterr; + int optopt; + int __optpos; +}; + +typedef struct Network.conflict Network.conflict, *PNetwork.conflict; + +struct Network.conflict { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict1 tlsDataParams; +}; + +typedef struct Network.conflict23 Network.conflict23, *PNetwork.conflict23; + +struct Network.conflict23 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict30 tlsDataParams; +}; + +typedef struct Network.conflict22 Network.conflict22, *PNetwork.conflict22; + +struct Network.conflict22 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict28 tlsDataParams; +}; + +typedef struct Network.conflict21 Network.conflict21, *PNetwork.conflict21; + +struct Network.conflict21 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict27 tlsDataParams; +}; + +typedef struct Network.conflict20 Network.conflict20, *PNetwork.conflict20; + +struct Network.conflict20 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict26 tlsDataParams; +}; + +typedef struct Network.conflict26 Network.conflict26, *PNetwork.conflict26; + +struct Network.conflict26 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict33 tlsDataParams; +}; + +typedef struct Network.conflict25 Network.conflict25, *PNetwork.conflict25; + +struct Network.conflict25 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict32 tlsDataParams; +}; + +typedef struct Network.conflict24 Network.conflict24, *PNetwork.conflict24; + +struct Network.conflict24 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict31 tlsDataParams; +}; + +typedef struct Network.conflict19 Network.conflict19, *PNetwork.conflict19; + +struct Network.conflict19 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict25 tlsDataParams; +}; + +typedef struct Network.conflict18 Network.conflict18, *PNetwork.conflict18; + +struct Network.conflict18 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict23 tlsDataParams; +}; + +typedef struct Network.conflict17 Network.conflict17, *PNetwork.conflict17; + +struct Network.conflict17 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict22 tlsDataParams; +}; + +typedef struct Network.conflict12 Network.conflict12, *PNetwork.conflict12; + +struct Network.conflict12 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict16 tlsDataParams; +}; + +typedef struct Network.conflict11 Network.conflict11, *PNetwork.conflict11; + +struct Network.conflict11 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict15 tlsDataParams; +}; + +typedef struct Network.conflict10 Network.conflict10, *PNetwork.conflict10; + +struct Network.conflict10 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict13 tlsDataParams; +}; + +typedef struct Network.conflict16 Network.conflict16, *PNetwork.conflict16; + +struct Network.conflict16 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict21 tlsDataParams; +}; + +typedef struct Network.conflict15 Network.conflict15, *PNetwork.conflict15; + +struct Network.conflict15 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict20 tlsDataParams; +}; + +typedef struct Network.conflict14 Network.conflict14, *PNetwork.conflict14; + +struct Network.conflict14 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict18 tlsDataParams; +}; + +typedef struct Network.conflict13 Network.conflict13, *PNetwork.conflict13; + +struct Network.conflict13 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict17 tlsDataParams; +}; + +typedef struct Network.conflict9 Network.conflict9, *PNetwork.conflict9; + +struct Network.conflict9 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict12 tlsDataParams; +}; + +typedef struct Network.conflict8 Network.conflict8, *PNetwork.conflict8; + +struct Network.conflict8 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict11 tlsDataParams; +}; + +typedef struct Network.conflict7 Network.conflict7, *PNetwork.conflict7; + +struct Network.conflict7 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict10 tlsDataParams; +}; + +typedef struct Network.conflict6 Network.conflict6, *PNetwork.conflict6; + +struct Network.conflict6 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict8 tlsDataParams; +}; + +typedef struct Network.conflict5 Network.conflict5, *PNetwork.conflict5; + +struct Network.conflict5 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict7 tlsDataParams; +}; + +typedef struct Network.conflict4 Network.conflict4, *PNetwork.conflict4; + +struct Network.conflict4 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict6 tlsDataParams; +}; + +typedef struct Network.conflict3 Network.conflict3, *PNetwork.conflict3; + +struct Network.conflict3 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict5 tlsDataParams; +}; + +typedef struct Network.conflict2 Network.conflict2, *PNetwork.conflict2; + +struct Network.conflict2 { + IoT_Error_t (* connect)(struct Network *, struct TLSConnectParams *); + IoT_Error_t (* read)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* write)(struct Network *, uchar *, size_t, struct Timer *, size_t *); + IoT_Error_t (* disconnect)(struct Network *); + IoT_Error_t (* isConnected)(struct Network *); + IoT_Error_t (* destroy)(struct Network *); + struct TLSConnectParams tlsConnectParams; + TLSDataParams.conflict3 tlsDataParams; +}; + +typedef struct anon_struct.conflict96 anon_struct.conflict96, *Panon_struct.conflict96; + +struct anon_struct.conflict96 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict95 anon_struct.conflict95, *Panon_struct.conflict95; + +struct anon_struct.conflict95 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict26 anon_struct.conflict26, *Panon_struct.conflict26; + +struct anon_struct.conflict26 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict15 anon_struct.conflict15, *Panon_struct.conflict15; + +struct anon_struct.conflict15 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict14 anon_struct.conflict14, *Panon_struct.conflict14; + +struct anon_struct.conflict14 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct apm apm, *Papm; + +typedef struct apm_start_req apm_start_req, *Papm_start_req; + +struct apm { + struct apm_start_req * param; + struct co_list bss_config; + uint8_t aging_sta_idx; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint8_t * bcn_buf; + _Bool apm_emb_enabled; + uint8_t hidden_ssid; + uint8_t assoc_sta_count; + uint8_t max_sta_supported; + struct anon_struct.conflict15 aid_list[10]; + undefined field_0x5e; + undefined field_0x5f; +}; + +struct apm_start_req { // Missing member bcn_buf : uint8_t[1] at offset 0xa7 [Unsupported interior flex array: uint8_t[1]] + struct mac_rateset basic_rates; + undefined field_0xd; + struct scan_chan_tag chan; + uint32_t center_freq1; + uint32_t center_freq2; + uint8_t ch_width; + uint8_t hidden_ssid; + undefined field_0x1e; + undefined field_0x1f; + uint32_t bcn_addr; + uint16_t bcn_len; + uint16_t tim_oft; + uint16_t bcn_int; + undefined field_0x2a; + undefined field_0x2b; + uint32_t flags; + uint16_t ctrl_port_ethertype; + uint8_t tim_len; + uint8_t vif_idx; + _Bool apm_emb_enabled; + struct mac_rateset rate_set; + uint8_t beacon_period; + uint8_t qos_supported; + struct mac_ssid ssid; + uint8_t ap_sec_type; + uint8_t phrase[64]; + undefined field_0xa7; +}; + +typedef struct anon_struct.conflict36 anon_struct.conflict36, *Panon_struct.conflict36; + +struct anon_struct.conflict36 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict70 anon_struct.conflict70, *Panon_struct.conflict70; + +struct anon_struct.conflict70 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict35 anon_struct.conflict35, *Panon_struct.conflict35; + +struct anon_struct.conflict35 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict212 anon_struct.conflict212, *Panon_struct.conflict212; + +struct anon_struct.conflict212 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict25 anon_struct.conflict25, *Panon_struct.conflict25; + +struct anon_struct.conflict25 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict69 anon_struct.conflict69, *Panon_struct.conflict69; + +struct anon_struct.conflict69 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict211 anon_struct.conflict211, *Panon_struct.conflict211; + +struct anon_struct.conflict211 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct supplicantData supplicantData_t; + +typedef struct wifi_secmode_t.conflict wifi_secmode_t.conflict, *Pwifi_secmode_t.conflict; + +struct wifi_secmode_t.conflict { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +typedef struct wifi_event_data_ind_scan_done wifi_event_data_ind_scan_done, *Pwifi_event_data_ind_scan_done; + +struct wifi_event_data_ind_scan_done { + uint32_t nothing; +}; + +typedef struct wifi_event_sm_connect_ind wifi_event_sm_connect_ind, *Pwifi_event_sm_connect_ind; + +struct wifi_event_sm_connect_ind { + uint16_t status_code; + uint8_t bssid[6]; + uint8_t vif_idx; + uint8_t ap_idx; + uint8_t ch_idx; + undefined field_0xb; + int qos; + uint16_t aid; + uint8_t band; + undefined field_0x13; + uint16_t center_freq; + uint8_t width; + undefined field_0x17; + uint32_t center_freq1; + uint32_t center_freq2; +}; + +typedef struct wifi_cipher_t.conflict23 wifi_cipher_t.conflict23, *Pwifi_cipher_t.conflict23; + +struct wifi_cipher_t.conflict23 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_apm_sta_info wifi_apm_sta_info, *Pwifi_apm_sta_info; + +struct wifi_apm_sta_info { + uint8_t sta_idx; + uint8_t is_used; + uint8_t sta_mac[6]; + uint32_t tsfhi; + uint32_t tsflo; + int rssi; + uint8_t data_rate; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct wifi_event_beacon_ind wifi_event_beacon_ind, *Pwifi_event_beacon_ind; + +typedef struct wifi_cipher_t.conflict1 wifi_cipher_t.conflict1, *Pwifi_cipher_t.conflict1; + +typedef struct wifi_secmode_t.conflict1 wifi_secmode_t.conflict1, *Pwifi_secmode_t.conflict1; + +struct wifi_secmode_t.conflict1 { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +struct wifi_cipher_t.conflict1 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +struct wifi_event_beacon_ind { + uint8_t bssid[6]; + uint8_t ssid[33]; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t channel; + uint8_t auth; + uint8_t cipher; + struct wifi_cipher_t.conflict1 wpa_mcstCipher; + struct wifi_cipher_t.conflict2 wpa_ucstCipher; + struct wifi_cipher_t.conflict3 rsn_mcstCipher; + struct wifi_cipher_t.conflict4 rsn_ucstCipher; + struct wifi_secmode_t.conflict1 sec_mode; + undefined field_0x33; + int ssid_len; +}; + +typedef struct wifi_secmode_t wifi_secmode_t, *Pwifi_secmode_t; + +struct wifi_secmode_t { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +typedef struct wifi_event_sm_disconnect_ind wifi_event_sm_disconnect_ind, *Pwifi_event_sm_disconnect_ind; + +struct wifi_event_sm_disconnect_ind { + uint16_t reason_code; + uint8_t vif_idx; + undefined field_0x3; + int ft_over_ds; +}; + +typedef struct wifi_event_beacon_ind.conflict1 wifi_event_beacon_ind.conflict1, *Pwifi_event_beacon_ind.conflict1; + +typedef struct wifi_cipher_t.conflict9 wifi_cipher_t.conflict9, *Pwifi_cipher_t.conflict9; + +typedef struct wifi_secmode_t.conflict3 wifi_secmode_t.conflict3, *Pwifi_secmode_t.conflict3; + +struct wifi_cipher_t.conflict9 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +struct wifi_secmode_t.conflict3 { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +struct wifi_event_beacon_ind.conflict1 { + uint8_t bssid[6]; + uint8_t ssid[33]; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t channel; + uint8_t auth; + uint8_t cipher; + struct wifi_cipher_t.conflict9 wpa_mcstCipher; + struct wifi_cipher_t.conflict10 wpa_ucstCipher; + struct wifi_cipher_t.conflict11 rsn_mcstCipher; + struct wifi_cipher_t.conflict12 rsn_ucstCipher; + struct wifi_secmode_t.conflict3 sec_mode; + undefined field_0x33; + int ssid_len; +}; + +typedef struct wifi_event_beacon_ind.conflict4 wifi_event_beacon_ind.conflict4, *Pwifi_event_beacon_ind.conflict4; + +typedef struct wifi_secmode_t.conflict8 wifi_secmode_t.conflict8, *Pwifi_secmode_t.conflict8; + +struct wifi_secmode_t.conflict8 { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +struct wifi_event_beacon_ind.conflict4 { + uint8_t bssid[6]; + uint8_t ssid[33]; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t channel; + uint8_t auth; + uint8_t cipher; + struct wifi_cipher_t.conflict23 wpa_mcstCipher; + struct wifi_cipher_t.conflict24 wpa_ucstCipher; + struct wifi_cipher_t.conflict25 rsn_mcstCipher; + struct wifi_cipher_t.conflict26 rsn_ucstCipher; + struct wifi_secmode_t.conflict8 sec_mode; + undefined field_0x33; + int ssid_len; +}; + +typedef struct wifi_event_beacon_ind.conflict3 wifi_event_beacon_ind.conflict3, *Pwifi_event_beacon_ind.conflict3; + +typedef struct wifi_cipher_t.conflict19 wifi_cipher_t.conflict19, *Pwifi_cipher_t.conflict19; + +typedef struct wifi_secmode_t.conflict7 wifi_secmode_t.conflict7, *Pwifi_secmode_t.conflict7; + +struct wifi_cipher_t.conflict19 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +struct wifi_secmode_t.conflict7 { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +struct wifi_event_beacon_ind.conflict3 { + uint8_t bssid[6]; + uint8_t ssid[33]; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t channel; + uint8_t auth; + uint8_t cipher; + struct wifi_cipher_t.conflict19 wpa_mcstCipher; + struct wifi_cipher_t.conflict20 wpa_ucstCipher; + struct wifi_cipher_t.conflict21 rsn_mcstCipher; + struct wifi_cipher_t.conflict22 rsn_ucstCipher; + struct wifi_secmode_t.conflict7 sec_mode; + undefined field_0x33; + int ssid_len; +}; + +typedef struct wifi_event_beacon_ind.conflict2 wifi_event_beacon_ind.conflict2, *Pwifi_event_beacon_ind.conflict2; + +typedef struct wifi_cipher_t.conflict13 wifi_cipher_t.conflict13, *Pwifi_cipher_t.conflict13; + +typedef struct wifi_secmode_t.conflict4 wifi_secmode_t.conflict4, *Pwifi_secmode_t.conflict4; + +struct wifi_cipher_t.conflict13 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +struct wifi_secmode_t.conflict4 { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +struct wifi_event_beacon_ind.conflict2 { + uint8_t bssid[6]; + uint8_t ssid[33]; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t channel; + uint8_t auth; + uint8_t cipher; + struct wifi_cipher_t.conflict13 wpa_mcstCipher; + struct wifi_cipher_t.conflict14 wpa_ucstCipher; + struct wifi_cipher_t.conflict15 rsn_mcstCipher; + struct wifi_cipher_t.conflict16 rsn_ucstCipher; + struct wifi_secmode_t.conflict4 sec_mode; + undefined field_0x33; + int ssid_len; +}; + +typedef struct wifi_secmode_t.conflict2 wifi_secmode_t.conflict2, *Pwifi_secmode_t.conflict2; + +struct wifi_secmode_t.conflict2 { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +typedef struct wifi_secmode_t.conflict5 wifi_secmode_t.conflict5, *Pwifi_secmode_t.conflict5; + +struct wifi_secmode_t.conflict5 { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +typedef struct wifi_secmode_t.conflict6 wifi_secmode_t.conflict6, *Pwifi_secmode_t.conflict6; + +struct wifi_secmode_t.conflict6 { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +typedef struct wifi_cipher_t.conflict17 wifi_cipher_t.conflict17, *Pwifi_cipher_t.conflict17; + +struct wifi_cipher_t.conflict17 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict18 wifi_cipher_t.conflict18, *Pwifi_cipher_t.conflict18; + +struct wifi_cipher_t.conflict18 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_event_data_ind_channel_switch wifi_event_data_ind_channel_switch, *Pwifi_event_data_ind_channel_switch; + +struct wifi_event_data_ind_channel_switch { + int channel; +}; + +typedef struct wifi_cipher_t.conflict5 wifi_cipher_t.conflict5, *Pwifi_cipher_t.conflict5; + +struct wifi_cipher_t.conflict5 { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_cipher_t.conflict wifi_cipher_t.conflict, *Pwifi_cipher_t.conflict; + +struct wifi_cipher_t.conflict { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct wifi_event_beacon_ind.conflict wifi_event_beacon_ind.conflict, *Pwifi_event_beacon_ind.conflict; + +struct wifi_event_beacon_ind.conflict { + uint8_t bssid[6]; + uint8_t ssid[33]; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t channel; + uint8_t auth; + uint8_t cipher; + struct wifi_cipher_t.conflict5 wpa_mcstCipher; + struct wifi_cipher_t.conflict6 wpa_ucstCipher; + struct wifi_cipher_t.conflict7 rsn_mcstCipher; + struct wifi_cipher_t.conflict8 rsn_ucstCipher; + struct wifi_secmode_t.conflict2 sec_mode; + undefined field_0x33; + int ssid_len; +}; + +typedef struct wifi_event wifi_event, *Pwifi_event; + +struct wifi_event { + uint32_t id; + uint8_t[0] data; +}; + +typedef struct wifi_cipher_t wifi_cipher_t, *Pwifi_cipher_t; + +struct wifi_cipher_t { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct phyif_utils_recvtable_t phyif_utils_recvtable_t, *Pphyif_utils_recvtable_t; + +struct phyif_utils_recvtable_t { + uint32_t recvtable1; + uint32_t recvtable2; + uint32_t recvtable3; + uint32_t recvtable4; + uint32_t recvtable5; + uint32_t recvtable6; +}; + +typedef struct dhcp_msg dhcp_msg, *Pdhcp_msg; + +struct dhcp_msg { + u8_t op; + u8_t htype; + u8_t hlen; + u8_t hops; + u32_t xid; + u16_t secs; + u16_t flags; + ip4_addr_p_t ciaddr; + ip4_addr_p_t yiaddr; + ip4_addr_p_t siaddr; + ip4_addr_p_t giaddr; + u8_t chaddr[16]; + u8_t sname[64]; + u8_t file[128]; + u32_t cookie; + u8_t options[68]; +}; + +typedef struct dhcp dhcp, *Pdhcp; + +struct dhcp { + u32_t xid; + u8_t pcb_allocated; + u8_t state; + u8_t tries; + u8_t subnet_mask_given; + u16_t request_timeout; + u16_t t1_timeout; + u16_t t2_timeout; + u16_t t1_renew_time; + u16_t t2_rebind_time; + u16_t lease_used; + u16_t t0_timeout; + undefined field_0x16; + undefined field_0x17; + ip_addr_t server_ip_addr; + ip4_addr_t offered_ip_addr; + ip4_addr_t offered_sn_mask; + ip4_addr_t offered_gw_addr; + u32_t offered_t0_lease; + u32_t offered_t1_renew; + u32_t offered_t2_rebind; +}; + +typedef enum dhcp_option_idx { + DHCP_OPTION_IDX_DNS_SERVER=8, + DHCP_OPTION_IDX_DNS_SERVER_LAST=9, + DHCP_OPTION_IDX_LEASE_TIME=3, + DHCP_OPTION_IDX_MAX=10, + DHCP_OPTION_IDX_MSG_TYPE=1, + DHCP_OPTION_IDX_OVERLOAD=0, + DHCP_OPTION_IDX_ROUTER=7, + DHCP_OPTION_IDX_SERVER_ID=2, + DHCP_OPTION_IDX_SUBNET_MASK=6, + DHCP_OPTION_IDX_T1=4, + DHCP_OPTION_IDX_T2=5 +} dhcp_option_idx; + +typedef struct phyif_utils_recvtable_priv_t.conflict phyif_utils_recvtable_priv_t.conflict, *Pphyif_utils_recvtable_priv_t.conflict; + +struct phyif_utils_recvtable_priv_t.conflict { + uint32_t leg_length:12; + uint32_t leg_rate:4; + uint32_t ht_length:16; + uint32_t _ht_length:4; + uint32_t short_gi:1; + uint32_t stbc:2; + uint32_t smoothing:1; + uint32_t mcs:7; + uint32_t pre_type:1; + uint32_t format_mod:3; + uint32_t ch_bw:2; + uint32_t n_sts:3; + uint32_t lsig_valid:1; + uint32_t sounding:1; + uint32_t num_extn_ss:2; + uint32_t aggregation:1; + uint32_t fec_coding:1; + uint32_t dyn_bw:1; + uint32_t doze_not_allowed:1; + uint32_t antenna_set:8; + uint32_t partial_aid:9; + uint32_t group_id:6; + uint32_t reserved_1c:1; + int32_t rssi1:8; + int32_t rssi2:8; + int32_t rssi3:8; + int32_t rssi4:8; + uint32_t reserved_1d:8; + uint32_t rcpi:8; + uint32_t evm1:8; + uint32_t evm2:8; + uint32_t evm3:8; + uint32_t evm4:8; + uint32_t reserved2b_1:8; + uint32_t reserved2b_2:8; + uint32_t reserved2b_3:8; +}; + +typedef struct phyif_utils_recvtable_priv_t.conflict1 phyif_utils_recvtable_priv_t.conflict1, *Pphyif_utils_recvtable_priv_t.conflict1; + +struct phyif_utils_recvtable_priv_t.conflict1 { + uint32_t leg_length:12; + uint32_t leg_rate:4; + uint32_t ht_length:16; + uint32_t _ht_length:4; + uint32_t short_gi:1; + uint32_t stbc:2; + uint32_t smoothing:1; + uint32_t mcs:7; + uint32_t pre_type:1; + uint32_t format_mod:3; + uint32_t ch_bw:2; + uint32_t n_sts:3; + uint32_t lsig_valid:1; + uint32_t sounding:1; + uint32_t num_extn_ss:2; + uint32_t aggregation:1; + uint32_t fec_coding:1; + uint32_t dyn_bw:1; + uint32_t doze_not_allowed:1; + uint32_t antenna_set:8; + uint32_t partial_aid:9; + uint32_t group_id:6; + uint32_t reserved_1c:1; + int32_t rssi1:8; + int32_t rssi2:8; + int32_t rssi3:8; + int32_t rssi4:8; + uint32_t reserved_1d:8; + uint32_t rcpi:8; + uint32_t evm1:8; + uint32_t evm2:8; + uint32_t evm3:8; + uint32_t evm4:8; + uint32_t reserved2b_1:8; + uint32_t reserved2b_2:8; + uint32_t reserved2b_3:8; +}; + +typedef struct phyif_utils_recvtable_priv_t phyif_utils_recvtable_priv_t, *Pphyif_utils_recvtable_priv_t; + +struct phyif_utils_recvtable_priv_t { + uint32_t leg_length:12; + uint32_t leg_rate:4; + uint32_t ht_length:16; + uint32_t _ht_length:4; + uint32_t short_gi:1; + uint32_t stbc:2; + uint32_t smoothing:1; + uint32_t mcs:7; + uint32_t pre_type:1; + uint32_t format_mod:3; + uint32_t ch_bw:2; + uint32_t n_sts:3; + uint32_t lsig_valid:1; + uint32_t sounding:1; + uint32_t num_extn_ss:2; + uint32_t aggregation:1; + uint32_t fec_coding:1; + uint32_t dyn_bw:1; + uint32_t doze_not_allowed:1; + uint32_t antenna_set:8; + uint32_t partial_aid:9; + uint32_t group_id:6; + uint32_t reserved_1c:1; + int32_t rssi1:8; + int32_t rssi2:8; + int32_t rssi3:8; + int32_t rssi4:8; + uint32_t reserved_1d:8; + uint32_t rcpi:8; + uint32_t evm1:8; + uint32_t evm2:8; + uint32_t evm3:8; + uint32_t evm4:8; + uint32_t reserved2b_1:8; + uint32_t reserved2b_2:8; + uint32_t reserved2b_3:8; +}; + +typedef struct xTIME_OUT xTIME_OUT, *PxTIME_OUT; + +typedef struct xTIME_OUT TimeOut_t; + +struct xTIME_OUT { + BaseType_t xOverflowCount; + TickType_t xTimeOnEntering; +}; + +typedef struct xMEMORY_REGION xMEMORY_REGION, *PxMEMORY_REGION; + +struct xMEMORY_REGION { + void * pvBaseAddress; + uint32_t ulLengthInBytes; + uint32_t ulParameters; +}; + +typedef struct xTASK_STATUS xTASK_STATUS, *PxTASK_STATUS; + +typedef struct xTASK_STATUS TaskStatus_t; + +typedef enum eTaskState { + eBlocked=2, + eDeleted=4, + eInvalid=5, + eReady=1, + eRunning=0, + eSuspended=3 +} eTaskState; + +struct xTASK_STATUS { + TaskHandle_t xHandle; + char * pcTaskName; + UBaseType_t xTaskNumber; + enum eTaskState eCurrentState; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + UBaseType_t uxCurrentPriority; + UBaseType_t uxBasePriority; + uint32_t ulRunTimeCounter; + StackType_t * pxStackBase; + uint16_t usStackHighWaterMark; + undefined field_0x22; + undefined field_0x23; +}; + +typedef enum eNotifyAction { + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4 +} eNotifyAction; + +typedef struct xMEMORY_REGION MemoryRegion_t; + +typedef struct lwip_setgetsockopt_data lwip_setgetsockopt_data, *Plwip_setgetsockopt_data; + +typedef union anon_union_for_optval anon_union_for_optval, *Panon_union_for_optval; + +union anon_union_for_optval { + void * p; + void * pc; +}; + +struct lwip_setgetsockopt_data { + int s; + int level; + int optname; + union anon_union_for_optval optval; + socklen_t optlen; + int err; + void * completed_sem; +}; + +typedef struct lwip_select_cb lwip_select_cb, *Plwip_select_cb; + +struct lwip_select_cb { + struct lwip_select_cb * next; + struct lwip_select_cb * prev; + struct _types_fd_set * readset; + struct _types_fd_set * writeset; + struct _types_fd_set * exceptset; + struct pollfd * poll_fds; + nfds_t poll_nfds; + int sem_signalled; + sys_sem_t sem; +}; + +typedef struct ip_globals ip_globals, *Pip_globals; + +struct ip_globals { + struct netif * current_netif; + struct netif * current_input_netif; + struct ip_hdr * current_ip4_header; + u16_t current_ip_header_tot_len; + undefined field_0xe; + undefined field_0xf; + ip_addr_t current_iphdr_src; + ip_addr_t current_iphdr_dest; +}; + +typedef uint32_t evt_field_t; + +typedef struct ke_env_tag ke_env_tag, *Pke_env_tag; + +struct ke_env_tag { + evt_field_t evt_field; + struct co_list queue_sent; + struct co_list queue_saved; + struct co_list queue_timer; + struct mblock_free * mblock_first; +}; + +typedef struct mbedtls_cipher_definition_t mbedtls_cipher_definition_t, *Pmbedtls_cipher_definition_t; + +struct mbedtls_cipher_definition_t { + enum mbedtls_cipher_type_t type; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + struct mbedtls_cipher_info_t * info; +}; + +typedef struct mblock_used mblock_used, *Pmblock_used; + +struct mblock_used { + uint32_t size; +}; + +typedef struct sha256_link_item.conflict sha256_link_item.conflict, *Psha256_link_item.conflict; + +struct sha256_link_item.conflict { + struct SEC_Eng_SHA256_Link_Ctx ctx; + struct SEC_Eng_SHA_Link_Config_Type.conflict2 linkCfg; + uint32_t tmp[16]; + uint32_t pad[16]; +}; + +typedef struct sha256_link_item sha256_link_item, *Psha256_link_item; + +struct sha256_link_item { + struct SEC_Eng_SHA256_Link_Ctx ctx; + struct SEC_Eng_SHA_Link_Config_Type.conflict1 linkCfg; + uint32_t tmp[16]; + uint32_t pad[16]; +}; + +typedef struct sha256_link_item.conflict sha256_link_item_t; + +typedef struct pbuf_rom pbuf_rom, *Ppbuf_rom; + +struct pbuf_rom { + struct pbuf * next; + void * payload; +}; + +typedef enum pbuf_layer { + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74 +} pbuf_layer; + +typedef enum pbuf_type { + PBUF_POOL=386, + PBUF_RAM=640, + PBUF_REF=65, + PBUF_ROM=1 +} pbuf_type; + +typedef enum SF_Ctrl_Sahb_Type { + SF_CTRL_FLASH_CLOCK=1, + SF_CTRL_SAHB_CLOCK=0 +} SF_Ctrl_Sahb_Type; + +typedef enum SF_Ctrl_Dmy_Mode_Type { + SF_CTRL_DUMMY_1_LINE=0, + SF_CTRL_DUMMY_2_LINES=1, + SF_CTRL_DUMMY_4_LINES=2 +} SF_Ctrl_Dmy_Mode_Type; + +typedef enum SF_Ctrl_Mode_Type { + SF_CTRL_QPI_MODE=1, + SF_CTRL_SPI_MODE=0 +} SF_Ctrl_Mode_Type; + +typedef enum SF_Ctrl_IO_Type { + SF_CTRL_DIO_MODE=3, + SF_CTRL_DO_MODE=1, + SF_CTRL_NIO_MODE=0, + SF_CTRL_QIO_MODE=4, + SF_CTRL_QO_MODE=2 +} SF_Ctrl_IO_Type; + +typedef enum SF_Ctrl_Data_Mode_Type { + SF_CTRL_DATA_1_LINE=0, + SF_CTRL_DATA_2_LINES=1, + SF_CTRL_DATA_4_LINES=2 +} SF_Ctrl_Data_Mode_Type; + +typedef struct SF_Ctrl_Cmd_Cfg_Type SF_Ctrl_Cmd_Cfg_Type, *PSF_Ctrl_Cmd_Cfg_Type; + +typedef enum SF_Ctrl_Cmd_Mode_Type { + SF_CTRL_CMD_1_LINE=0, + SF_CTRL_CMD_4_LINES=1 +} SF_Ctrl_Cmd_Mode_Type; + +typedef enum SF_Ctrl_Addr_Mode_Type { + SF_CTRL_ADDR_1_LINE=0, + SF_CTRL_ADDR_2_LINES=1, + SF_CTRL_ADDR_4_LINES=2 +} SF_Ctrl_Addr_Mode_Type; + +struct SF_Ctrl_Cmd_Cfg_Type { + uint8_t rwFlag; + enum SF_Ctrl_Cmd_Mode_Type cmdMode; + enum SF_Ctrl_Addr_Mode_Type addrMode; + uint8_t addrSize; + uint8_t dummyClks; + enum SF_Ctrl_Dmy_Mode_Type dummyMode; + enum SF_Ctrl_Data_Mode_Type dataMode; + uint8_t rsv[1]; + uint32_t nbData; + uint32_t cmdBuf[2]; +}; + +typedef struct SF_Ctrl_Cfg_Type SF_Ctrl_Cfg_Type, *PSF_Ctrl_Cfg_Type; + +typedef enum SF_Ctrl_Owner_Type { + SF_CTRL_OWNER_IAHB=1, + SF_CTRL_OWNER_SAHB=0 +} SF_Ctrl_Owner_Type; + +typedef enum SF_Ctrl_Ahb2sif_Type { + HIGH_SPEED_MODE_CLOCK=0, + REMOVE_CLOCK_CONSTRAIN=1 +} SF_Ctrl_Ahb2sif_Type; + +struct SF_Ctrl_Cfg_Type { + enum SF_Ctrl_Owner_Type owner; + enum SF_Ctrl_Sahb_Type sahbClock; + enum SF_Ctrl_Ahb2sif_Type ahb2sifMode; + uint8_t clkDelay; + uint8_t clkInvert; + uint8_t rxClkInvert; + uint8_t doDelay; + uint8_t diDelay; + uint8_t oeDelay; +}; + +typedef enum SF_Ctrl_Pad_Sel { + SF_CTRL_EMBEDDED_SEL=0, + SF_CTRL_EXTERNAL_0TO2_20TO22_SEL=2, + SF_CTRL_EXTERNAL_17TO22_SEL=1 +} SF_Ctrl_Pad_Sel; + +typedef enum SF_Ctrl_AES_Key_Type { + SF_CTRL_AES_128BITS=0, + SF_CTRL_AES_128BITS_DOUBLE_KEY=3, + SF_CTRL_AES_192BITS=2, + SF_CTRL_AES_256BITS=1 +} SF_Ctrl_AES_Key_Type; + +typedef struct mac_bss_info mac_bss_info, *Pmac_bss_info; + +typedef struct mac_edca_param_set mac_edca_param_set, *Pmac_edca_param_set; + +typedef struct mobility_domain mobility_domain, *Pmobility_domain; + +struct mac_edca_param_set { + uint8_t qos_info; + uint8_t acm; + undefined field_0x2; + undefined field_0x3; + uint32_t ac_param[4]; +}; + +struct mobility_domain { + uint16_t mdid; + uint8_t ft_capability_policy; + undefined field_0x3; +}; + +struct mac_bss_info { + struct mac_htcapability ht_cap; + struct mac_addr bssid; + struct mac_ssid ssid; + uint16_t bsstype; + undefined field_0x4a; + undefined field_0x4b; + struct scan_chan_tag * chan; + uint16_t center_freq1; + uint16_t center_freq2; + uint16_t beacon_period; + uint16_t cap_info; + struct mac_rateset rate_set; + undefined field_0x65; + undefined field_0x66; + undefined field_0x67; + struct mac_edca_param_set edca_param; + int8_t rssi; + int8_t ppm_rel; + int8_t ppm_abs; + uint8_t high_11b_rate; + uint16_t prot_status; + uint8_t bw; + uint8_t phy_bw; + uint8_t power_constraint; + undefined field_0x85; + undefined field_0x86; + undefined field_0x87; + uint32_t valid_flags; + struct mobility_domain mde; + _Bool is_supplicant_enabled; + struct SecurityMode_t wpa_wpa2_wep; + struct Cipher_t wpa_mcstCipher; + struct Cipher_t wpa_ucstCipher; + struct Cipher_t rsn_mcstCipher; + struct Cipher_t rsn_ucstCipher; + _Bool is_pmf_required; + _Bool is_wpa2_prefered; + uint8_t rsn_wpa_ie[32]; + uint8_t rsn_wpa_ie_len; + uint16_t beacon_interval; + uint16_t aid_bitmap; + uint16_t max_listen_interval; + uint8_t sec_type; + undefined field_0xc1; + undefined field_0xc2; + undefined field_0xc3; +}; + +typedef struct me_env_tag me_env_tag, *Pme_env_tag; + +struct me_env_tag { + uint32_t active_vifs; + uint32_t ps_disable_vifs; + ke_task_id_t requester_id; + undefined field_0xa; + undefined field_0xb; + struct mac_htcapability ht_cap; + uint16_t tx_lft; + _Bool ht_supported; + undefined field_0x2f; + struct me_chan_config_req chan; + uint8_t stbc_nss; + uint8_t phy_bw_max; + _Bool ps_on; + undefined field_0x131; + undefined field_0x132; + undefined field_0x133; +}; + +typedef struct anon_struct.conflict338 anon_struct.conflict338, *Panon_struct.conflict338; + +struct anon_struct.conflict338 { + u8 action_code; + u8 operating_mode; +}; + +typedef struct anon_struct.conflict339 anon_struct.conflict339, *Panon_struct.conflict339; + +struct anon_struct.conflict339 { + u8 action_code; + u8 membership[8]; + u8 position[16]; +}; + +typedef struct anon_struct.conflict340 anon_struct.conflict340, *Panon_struct.conflict340; + +struct anon_struct.conflict340 { + u8 action_code; + u8 dialog_token; + u8 tpc_elem_id; + u8 tpc_elem_length; +}; + +typedef struct anon_struct.conflict341 anon_struct.conflict341, *Panon_struct.conflict341; + +struct anon_struct.conflict341 { + u8 action_code; + u8 dialog_token; + u8 follow_up; + u8 tod[6]; + u8 toa[6]; + __le16 tod_error; + __le16 toa_error; + u8[0] variable; +}; + +typedef struct ieee80211_mgmt ieee80211_mgmt, *Pieee80211_mgmt; + +struct ieee80211_mgmt { + __le16 frame_control; + __le16 duration; + u8 da[6]; + u8 sa[6]; + u8 bssid[6]; + __le16 seq_ctrl; + undefined field_0x18; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; + undefined field_0x1c; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; + undefined field_0x20; + undefined field_0x21; + undefined field_0x22; + undefined field_0x23; + undefined field_0x24; + undefined field_0x25; + undefined field_0x26; + undefined field_0x27; + undefined field_0x28; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; + undefined field_0x2c; + undefined field_0x2d; + undefined field_0x2e; + undefined field_0x2f; + undefined field_0x30; + undefined field_0x31; +}; + +typedef struct anon_struct.conflict246 anon_struct.conflict246, *Panon_struct.conflict246; + +struct anon_struct.conflict246 { + __le16 reason_code; +}; + +typedef struct anon_struct.conflict247 anon_struct.conflict247, *Panon_struct.conflict247; + +struct anon_struct.conflict247 { + __le16 capab_info; + __le16 listen_interval; + u8[0] variable; +}; + +typedef struct anon_struct.conflict248 anon_struct.conflict248, *Panon_struct.conflict248; + +struct anon_struct.conflict248 { + __le16 capab_info; + __le16 status_code; + __le16 aid; + u8[0] variable; +}; + +typedef struct anon_struct.conflict249 anon_struct.conflict249, *Panon_struct.conflict249; + +struct anon_struct.conflict249 { + __le16 capab_info; + __le16 listen_interval; + u8 current_ap[6]; + u8[0] variable; +}; + +typedef struct anon_struct.conflict245 anon_struct.conflict245, *Panon_struct.conflict245; + +struct anon_struct.conflict245 { + __le16 auth_alg; + __le16 auth_transaction; + __le16 status_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict250 anon_struct.conflict250, *Panon_struct.conflict250; + +struct anon_struct.conflict250 { + __le16 reason_code; +}; + +typedef struct anon_struct.conflict251 anon_struct.conflict251, *Panon_struct.conflict251; + +struct anon_struct.conflict251 { + __le64 timestamp; + __le16 beacon_int; + __le16 capab_info; + u8[0] variable; +}; + +typedef struct anon_struct.conflict252 anon_struct.conflict252, *Panon_struct.conflict252; + +struct anon_struct.conflict252 { + __le64 timestamp; + __le16 beacon_int; + __le16 capab_info; + u8[0] variable; +}; + +typedef union anon_union.conflict189 anon_union.conflict189, *Panon_union.conflict189; + +typedef struct anon_struct.conflict270 anon_struct.conflict270, *Panon_struct.conflict270; + +typedef struct anon_struct.conflict271 anon_struct.conflict271, *Panon_struct.conflict271; + +typedef struct anon_struct.conflict272 anon_struct.conflict272, *Panon_struct.conflict272; + +typedef struct anon_struct.conflict273 anon_struct.conflict273, *Panon_struct.conflict273; + +typedef struct anon_struct.conflict274 anon_struct.conflict274, *Panon_struct.conflict274; + +typedef struct anon_struct.conflict275 anon_struct.conflict275, *Panon_struct.conflict275; + +typedef struct anon_struct.conflict276 anon_struct.conflict276, *Panon_struct.conflict276; + +typedef struct anon_struct.conflict277 anon_struct.conflict277, *Panon_struct.conflict277; + +typedef struct anon_struct.conflict278 anon_struct.conflict278, *Panon_struct.conflict278; + +typedef struct anon_struct.conflict279 anon_struct.conflict279, *Panon_struct.conflict279; + +typedef struct anon_struct.conflict280 anon_struct.conflict280, *Panon_struct.conflict280; + +typedef struct anon_struct.conflict281 anon_struct.conflict281, *Panon_struct.conflict281; + +typedef struct anon_struct.conflict282 anon_struct.conflict282, *Panon_struct.conflict282; + +typedef struct anon_struct.conflict283 anon_struct.conflict283, *Panon_struct.conflict283; + +typedef struct anon_struct.conflict284 anon_struct.conflict284, *Panon_struct.conflict284; + +typedef struct anon_struct.conflict285 anon_struct.conflict285, *Panon_struct.conflict285; + +typedef struct anon_struct.conflict286 anon_struct.conflict286, *Panon_struct.conflict286; + +struct anon_struct.conflict282 { + u8 action_code; + u8 dialog_token; + __le16 capability; + u8[0] variable; +}; + +struct anon_struct.conflict283 { + u8 action_code; + u8 operating_mode; +}; + +struct anon_struct.conflict284 { + u8 action_code; + u8 membership[8]; + u8 position[16]; +}; + +struct anon_struct.conflict285 { + u8 action_code; + u8 dialog_token; + u8 tpc_elem_id; + u8 tpc_elem_length; +}; + +struct anon_struct.conflict280 { + u8 action; + u8 smps_control; +}; + +struct anon_struct.conflict281 { + u8 action_code; + u8 chanwidth; +}; + +struct anon_struct.conflict286 { + u8 action_code; + u8 dialog_token; + u8 follow_up; + u8 tod[6]; + u8 toa[6]; + __le16 tod_error; + __le16 toa_error; + u8[0] variable; +}; + +struct anon_struct.conflict271 { + u8 action_code; + u8[0] variable; +}; + +struct anon_struct.conflict272 { + u8 action_code; + u8[0] variable; +}; + +struct anon_struct.conflict273 { + u8 action_code; + u8 dialog_token; + u8 element_id; + u8 length; +}; + +struct anon_struct.conflict274 { + u8 action_code; + u8 dialog_token; + __le16 capab; + __le16 timeout; + __le16 start_seq_num; +}; + +struct anon_struct.conflict278 { + u8 action_code; + u8[0] variable; +}; + +struct anon_struct.conflict276 { + u8 action_code; + __le16 params; + __le16 reason_code; +}; + +struct anon_struct.conflict279 { + u8 action; + u8 trans_id[2]; +}; + +struct anon_struct.conflict277 { + u8 action_code; + u8[0] variable; +}; + +struct anon_struct.conflict270 { + u8 action_code; + u8 dialog_token; + u8 status_code; + u8[0] variable; +}; + +struct anon_struct.conflict275 { + u8 action_code; + u8 dialog_token; + __le16 status; + __le16 capab; + __le16 timeout; +}; + +union anon_union.conflict189 { + struct anon_struct.conflict270 wme_action; + struct anon_struct.conflict271 chan_switch; + struct anon_struct.conflict272 ext_chan_switch; + struct anon_struct.conflict273 measurement; + struct anon_struct.conflict274 addba_req; + struct anon_struct.conflict275 addba_resp; + struct anon_struct.conflict276 delba; + struct anon_struct.conflict277 self_prot; + struct anon_struct.conflict278 mesh_action; + struct anon_struct.conflict279 sa_query; + struct anon_struct.conflict280 ht_smps; + struct anon_struct.conflict281 ht_notify_cw; + struct anon_struct.conflict282 tdls_discover_resp; + struct anon_struct.conflict283 vht_opmode_notif; + struct anon_struct.conflict284 vht_group_notif; + struct anon_struct.conflict285 tpc_report; + struct anon_struct.conflict286 ftm; +}; + +typedef struct anon_struct.conflict257 anon_struct.conflict257, *Panon_struct.conflict257; + +struct anon_struct.conflict257 { + u8 action_code; + u8 dialog_token; + __le16 capab; + __le16 timeout; + __le16 start_seq_num; +}; + +typedef struct anon_struct.conflict258 anon_struct.conflict258, *Panon_struct.conflict258; + +struct anon_struct.conflict258 { + u8 action_code; + u8 dialog_token; + __le16 status; + __le16 capab; + __le16 timeout; +}; + +typedef struct anon_struct.conflict259 anon_struct.conflict259, *Panon_struct.conflict259; + +struct anon_struct.conflict259 { + u8 action_code; + __le16 params; + __le16 reason_code; +}; + +typedef struct anon_struct.conflict253 anon_struct.conflict253, *Panon_struct.conflict253; + +struct anon_struct.conflict253 { + u8 action_code; + u8 dialog_token; + u8 status_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict254 anon_struct.conflict254, *Panon_struct.conflict254; + +struct anon_struct.conflict254 { + u8 action_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict255 anon_struct.conflict255, *Panon_struct.conflict255; + +struct anon_struct.conflict255 { + u8 action_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict256 anon_struct.conflict256, *Panon_struct.conflict256; + +struct anon_struct.conflict256 { + u8 action_code; + u8 dialog_token; + u8 element_id; + u8 length; +}; + +typedef struct anon_struct.conflict260 anon_struct.conflict260, *Panon_struct.conflict260; + +struct anon_struct.conflict260 { + u8 action_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict261 anon_struct.conflict261, *Panon_struct.conflict261; + +struct anon_struct.conflict261 { + u8 action_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict262 anon_struct.conflict262, *Panon_struct.conflict262; + +struct anon_struct.conflict262 { + u8 action; + u8 trans_id[2]; +}; + +typedef struct anon_struct.conflict263 anon_struct.conflict263, *Panon_struct.conflict263; + +struct anon_struct.conflict263 { + u8 action; + u8 smps_control; +}; + +typedef struct anon_struct.conflict268 anon_struct.conflict268, *Panon_struct.conflict268; + +struct anon_struct.conflict268 { + u8 action_code; + u8 dialog_token; + u8 tpc_elem_id; + u8 tpc_elem_length; +}; + +typedef struct anon_struct.conflict269 anon_struct.conflict269, *Panon_struct.conflict269; + +struct anon_struct.conflict269 { + u8 action_code; + u8 dialog_token; + u8 follow_up; + u8 tod[6]; + u8 toa[6]; + __le16 tod_error; + __le16 toa_error; + u8[0] variable; +}; + +typedef struct anon_struct.conflict264 anon_struct.conflict264, *Panon_struct.conflict264; + +struct anon_struct.conflict264 { + u8 action_code; + u8 chanwidth; +}; + +typedef struct anon_struct.conflict265 anon_struct.conflict265, *Panon_struct.conflict265; + +struct anon_struct.conflict265 { + u8 action_code; + u8 dialog_token; + __le16 capability; + u8[0] variable; +}; + +typedef struct anon_struct.conflict266 anon_struct.conflict266, *Panon_struct.conflict266; + +struct anon_struct.conflict266 { + u8 action_code; + u8 operating_mode; +}; + +typedef struct anon_struct.conflict267 anon_struct.conflict267, *Panon_struct.conflict267; + +struct anon_struct.conflict267 { + u8 action_code; + u8 membership[8]; + u8 position[16]; +}; + +typedef struct anon_struct.conflict317 anon_struct.conflict317, *Panon_struct.conflict317; + +struct anon_struct.conflict317 { + __le16 auth_alg; + __le16 auth_transaction; + __le16 status_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict318 anon_struct.conflict318, *Panon_struct.conflict318; + +struct anon_struct.conflict318 { + __le16 reason_code; +}; + +typedef struct anon_struct.conflict319 anon_struct.conflict319, *Panon_struct.conflict319; + +struct anon_struct.conflict319 { + __le16 capab_info; + __le16 listen_interval; + u8[0] variable; +}; + +typedef struct anon_struct.conflict323 anon_struct.conflict323, *Panon_struct.conflict323; + +struct anon_struct.conflict323 { + __le64 timestamp; + __le16 beacon_int; + __le16 capab_info; + u8[0] variable; +}; + +typedef struct anon_struct.conflict324 anon_struct.conflict324, *Panon_struct.conflict324; + +struct anon_struct.conflict324 { + __le64 timestamp; + __le16 beacon_int; + __le16 capab_info; + u8[0] variable; +}; + +typedef struct anon_struct.conflict325 anon_struct.conflict325, *Panon_struct.conflict325; + +struct anon_struct.conflict325 { + u8 action_code; + u8 dialog_token; + u8 status_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict326 anon_struct.conflict326, *Panon_struct.conflict326; + +struct anon_struct.conflict326 { + u8 action_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict320 anon_struct.conflict320, *Panon_struct.conflict320; + +struct anon_struct.conflict320 { + __le16 capab_info; + __le16 status_code; + __le16 aid; + u8[0] variable; +}; + +typedef struct anon_struct.conflict288 anon_struct.conflict288, *Panon_struct.conflict288; + +struct anon_struct.conflict288 { + __le16 auth_alg; + __le16 auth_transaction; + __le16 status_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict321 anon_struct.conflict321, *Panon_struct.conflict321; + +struct anon_struct.conflict321 { + __le16 capab_info; + __le16 listen_interval; + u8 current_ap[6]; + u8[0] variable; +}; + +typedef struct anon_struct.conflict289 anon_struct.conflict289, *Panon_struct.conflict289; + +struct anon_struct.conflict289 { + __le16 reason_code; +}; + +typedef struct anon_struct.conflict322 anon_struct.conflict322, *Panon_struct.conflict322; + +struct anon_struct.conflict322 { + __le16 reason_code; +}; + +typedef struct anon_struct.conflict327 anon_struct.conflict327, *Panon_struct.conflict327; + +struct anon_struct.conflict327 { + u8 action_code; + u8[0] variable; +}; + +typedef enum ieee80211_reasoncode { + WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT=15, + WLAN_REASON_CIPHER_SUITE_REJECTED=24, + WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA=6, + WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA=7, + WLAN_REASON_DEAUTH_LEAVING=3, + WLAN_REASON_DISASSOC_AP_BUSY=5, + WLAN_REASON_DISASSOC_BAD_POWER=10, + WLAN_REASON_DISASSOC_BAD_SUPP_CHAN=11, + WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY=4, + WLAN_REASON_DISASSOC_LOW_ACK=34, + WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP=35, + WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH=33, + WLAN_REASON_DISASSOC_STA_HAS_LEFT=8, + WLAN_REASON_DISASSOC_UNSPECIFIED_QOS=32, + WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT=16, + WLAN_REASON_IEEE8021X_FAILED=23, + WLAN_REASON_IE_DIFFERENT=17, + WLAN_REASON_INVALID_AKMP=20, + WLAN_REASON_INVALID_GROUP_CIPHER=18, + WLAN_REASON_INVALID_IE=13, + WLAN_REASON_INVALID_PAIRWISE_CIPHER=19, + WLAN_REASON_INVALID_RSN_IE_CAP=22, + WLAN_REASON_MAC_EXISTS_IN_MBSS=64, + WLAN_REASON_MESH_CHAN=66, + WLAN_REASON_MESH_CHAN_REGULATORY=65, + WLAN_REASON_MESH_CLOSE=55, + WLAN_REASON_MESH_CONFIG=54, + WLAN_REASON_MESH_CONFIRM_TIMEOUT=57, + WLAN_REASON_MESH_INCONSISTENT_PARAM=59, + WLAN_REASON_MESH_INVALID_GTK=58, + WLAN_REASON_MESH_INVALID_SECURITY=60, + WLAN_REASON_MESH_MAX_PEERS=53, + WLAN_REASON_MESH_MAX_RETRIES=56, + WLAN_REASON_MESH_PATH_DEST_UNREACHABLE=63, + WLAN_REASON_MESH_PATH_ERROR=61, + WLAN_REASON_MESH_PATH_NOFORWARD=62, + WLAN_REASON_MESH_PEER_CANCELED=52, + WLAN_REASON_MIC_FAILURE=14, + WLAN_REASON_PREV_AUTH_NOT_VALID=2, + WLAN_REASON_QSTA_CIPHER_NOT_SUPP=45, + WLAN_REASON_QSTA_LEAVE_QBSS=36, + WLAN_REASON_QSTA_NOT_USE=37, + WLAN_REASON_QSTA_REQUIRE_SETUP=38, + WLAN_REASON_QSTA_TIMEOUT=39, + WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH=9, + WLAN_REASON_TDLS_TEARDOWN_UNREACHABLE=25, + WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED=26, + WLAN_REASON_UNSPECIFIED=1, + WLAN_REASON_UNSUPP_RSN_VERSION=21 +} ieee80211_reasoncode; + +typedef struct anon_struct.conflict328 anon_struct.conflict328, *Panon_struct.conflict328; + +struct anon_struct.conflict328 { + u8 action_code; + u8 dialog_token; + u8 element_id; + u8 length; +}; + +typedef struct anon_struct.conflict329 anon_struct.conflict329, *Panon_struct.conflict329; + +struct anon_struct.conflict329 { + u8 action_code; + u8 dialog_token; + __le16 capab; + __le16 timeout; + __le16 start_seq_num; +}; + +typedef struct anon_struct.conflict293 anon_struct.conflict293, *Panon_struct.conflict293; + +struct anon_struct.conflict293 { + __le16 capab_info; + __le16 listen_interval; + u8 current_ap[6]; + u8[0] variable; +}; + +typedef struct anon_struct.conflict294 anon_struct.conflict294, *Panon_struct.conflict294; + +struct anon_struct.conflict294 { + __le16 reason_code; +}; + +typedef struct anon_struct.conflict295 anon_struct.conflict295, *Panon_struct.conflict295; + +struct anon_struct.conflict295 { + __le64 timestamp; + __le16 beacon_int; + __le16 capab_info; + u8[0] variable; +}; + +typedef struct anon_struct.conflict296 anon_struct.conflict296, *Panon_struct.conflict296; + +struct anon_struct.conflict296 { + __le64 timestamp; + __le16 beacon_int; + __le16 capab_info; + u8[0] variable; +}; + +typedef struct anon_struct.conflict290 anon_struct.conflict290, *Panon_struct.conflict290; + +struct anon_struct.conflict290 { + __le16 capab_info; + __le16 listen_interval; + u8[0] variable; +}; + +typedef struct anon_struct.conflict291 anon_struct.conflict291, *Panon_struct.conflict291; + +struct anon_struct.conflict291 { + __le16 capab_info; + __le16 status_code; + __le16 aid; + u8[0] variable; +}; + +typedef struct anon_struct.conflict334 anon_struct.conflict334, *Panon_struct.conflict334; + +struct anon_struct.conflict334 { + u8 action; + u8 trans_id[2]; +}; + +typedef struct anon_struct.conflict335 anon_struct.conflict335, *Panon_struct.conflict335; + +struct anon_struct.conflict335 { + u8 action; + u8 smps_control; +}; + +typedef struct anon_struct.conflict336 anon_struct.conflict336, *Panon_struct.conflict336; + +struct anon_struct.conflict336 { + u8 action_code; + u8 chanwidth; +}; + +typedef struct anon_struct.conflict337 anon_struct.conflict337, *Panon_struct.conflict337; + +struct anon_struct.conflict337 { + u8 action_code; + u8 dialog_token; + __le16 capability; + u8[0] variable; +}; + +typedef struct anon_struct.conflict330 anon_struct.conflict330, *Panon_struct.conflict330; + +struct anon_struct.conflict330 { + u8 action_code; + u8 dialog_token; + __le16 status; + __le16 capab; + __le16 timeout; +}; + +typedef struct anon_struct.conflict331 anon_struct.conflict331, *Panon_struct.conflict331; + +struct anon_struct.conflict331 { + u8 action_code; + __le16 params; + __le16 reason_code; +}; + +typedef struct anon_struct.conflict332 anon_struct.conflict332, *Panon_struct.conflict332; + +struct anon_struct.conflict332 { + u8 action_code; + u8[0] variable; +}; + +typedef struct anon_struct.conflict333 anon_struct.conflict333, *Panon_struct.conflict333; + +struct anon_struct.conflict333 { + u8 action_code; + u8[0] variable; +}; + +typedef struct ke_msg_handler.conflict2 ke_msg_handler.conflict2, *Pke_msg_handler.conflict2; + +struct ke_msg_handler.conflict2 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict41 ke_msg_handler.conflict41, *Pke_msg_handler.conflict41; + +struct ke_msg_handler.conflict41 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_task_desc ke_task_desc, *Pke_task_desc; + +struct ke_task_desc { + struct ke_state_handler * state_handler; + struct ke_state_handler * default_handler; + ke_state_t * state; + uint16_t state_max; + uint16_t idx_max; +}; + +typedef struct ke_msg_handler.conflict67 ke_msg_handler.conflict67, *Pke_msg_handler.conflict67; + +struct ke_msg_handler.conflict67 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict66 ke_msg_handler.conflict66, *Pke_msg_handler.conflict66; + +struct ke_msg_handler.conflict66 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict65 ke_msg_handler.conflict65, *Pke_msg_handler.conflict65; + +struct ke_msg_handler.conflict65 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict62 ke_msg_handler.conflict62, *Pke_msg_handler.conflict62; + +struct ke_msg_handler.conflict62 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict64 ke_msg_handler.conflict64, *Pke_msg_handler.conflict64; + +struct ke_msg_handler.conflict64 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict63 ke_msg_handler.conflict63, *Pke_msg_handler.conflict63; + +struct ke_msg_handler.conflict63 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict3 ke_msg_handler.conflict3, *Pke_msg_handler.conflict3; + +struct ke_msg_handler.conflict3 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict61 ke_msg_handler.conflict61, *Pke_msg_handler.conflict61; + +struct ke_msg_handler.conflict61 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict60 ke_msg_handler.conflict60, *Pke_msg_handler.conflict60; + +struct ke_msg_handler.conflict60 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict ke_msg_handler.conflict, *Pke_msg_handler.conflict; + +struct ke_msg_handler.conflict { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict59 ke_msg_handler.conflict59, *Pke_msg_handler.conflict59; + +struct ke_msg_handler.conflict59 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict58 ke_msg_handler.conflict58, *Pke_msg_handler.conflict58; + +struct ke_msg_handler.conflict58 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict57 ke_msg_handler.conflict57, *Pke_msg_handler.conflict57; + +struct ke_msg_handler.conflict57 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict56 ke_msg_handler.conflict56, *Pke_msg_handler.conflict56; + +struct ke_msg_handler.conflict56 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict55 ke_msg_handler.conflict55, *Pke_msg_handler.conflict55; + +struct ke_msg_handler.conflict55 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict54 ke_msg_handler.conflict54, *Pke_msg_handler.conflict54; + +struct ke_msg_handler.conflict54 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict48 ke_msg_handler.conflict48, *Pke_msg_handler.conflict48; + +struct ke_msg_handler.conflict48 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict53 ke_msg_handler.conflict53, *Pke_msg_handler.conflict53; + +struct ke_msg_handler.conflict53 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict52 ke_msg_handler.conflict52, *Pke_msg_handler.conflict52; + +struct ke_msg_handler.conflict52 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict51 ke_msg_handler.conflict51, *Pke_msg_handler.conflict51; + +struct ke_msg_handler.conflict51 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict50 ke_msg_handler.conflict50, *Pke_msg_handler.conflict50; + +struct ke_msg_handler.conflict50 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict9 ke_msg_handler.conflict9, *Pke_msg_handler.conflict9; + +struct ke_msg_handler.conflict9 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict6 ke_msg_handler.conflict6, *Pke_msg_handler.conflict6; + +struct ke_msg_handler.conflict6 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict5 ke_msg_handler.conflict5, *Pke_msg_handler.conflict5; + +struct ke_msg_handler.conflict5 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict8 ke_msg_handler.conflict8, *Pke_msg_handler.conflict8; + +struct ke_msg_handler.conflict8 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict7 ke_msg_handler.conflict7, *Pke_msg_handler.conflict7; + +struct ke_msg_handler.conflict7 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict1 ke_msg_handler.conflict1, *Pke_msg_handler.conflict1; + +struct ke_msg_handler.conflict1 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict4 ke_msg_handler.conflict4, *Pke_msg_handler.conflict4; + +struct ke_msg_handler.conflict4 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict49 ke_msg_handler.conflict49, *Pke_msg_handler.conflict49; + +struct ke_msg_handler.conflict49 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict47 ke_msg_handler.conflict47, *Pke_msg_handler.conflict47; + +struct ke_msg_handler.conflict47 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict46 ke_msg_handler.conflict46, *Pke_msg_handler.conflict46; + +struct ke_msg_handler.conflict46 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict45 ke_msg_handler.conflict45, *Pke_msg_handler.conflict45; + +struct ke_msg_handler.conflict45 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict44 ke_msg_handler.conflict44, *Pke_msg_handler.conflict44; + +struct ke_msg_handler.conflict44 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict43 ke_msg_handler.conflict43, *Pke_msg_handler.conflict43; + +struct ke_msg_handler.conflict43 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict42 ke_msg_handler.conflict42, *Pke_msg_handler.conflict42; + +struct ke_msg_handler.conflict42 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict40 ke_msg_handler.conflict40, *Pke_msg_handler.conflict40; + +struct ke_msg_handler.conflict40 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict39 ke_msg_handler.conflict39, *Pke_msg_handler.conflict39; + +struct ke_msg_handler.conflict39 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict38 ke_msg_handler.conflict38, *Pke_msg_handler.conflict38; + +struct ke_msg_handler.conflict38 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict37 ke_msg_handler.conflict37, *Pke_msg_handler.conflict37; + +struct ke_msg_handler.conflict37 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict36 ke_msg_handler.conflict36, *Pke_msg_handler.conflict36; + +struct ke_msg_handler.conflict36 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict35 ke_msg_handler.conflict35, *Pke_msg_handler.conflict35; + +struct ke_msg_handler.conflict35 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict34 ke_msg_handler.conflict34, *Pke_msg_handler.conflict34; + +struct ke_msg_handler.conflict34 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict33 ke_msg_handler.conflict33, *Pke_msg_handler.conflict33; + +struct ke_msg_handler.conflict33 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict32 ke_msg_handler.conflict32, *Pke_msg_handler.conflict32; + +struct ke_msg_handler.conflict32 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict31 ke_msg_handler.conflict31, *Pke_msg_handler.conflict31; + +struct ke_msg_handler.conflict31 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict30 ke_msg_handler.conflict30, *Pke_msg_handler.conflict30; + +struct ke_msg_handler.conflict30 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict29 ke_msg_handler.conflict29, *Pke_msg_handler.conflict29; + +struct ke_msg_handler.conflict29 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict28 ke_msg_handler.conflict28, *Pke_msg_handler.conflict28; + +struct ke_msg_handler.conflict28 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict27 ke_msg_handler.conflict27, *Pke_msg_handler.conflict27; + +struct ke_msg_handler.conflict27 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict26 ke_msg_handler.conflict26, *Pke_msg_handler.conflict26; + +struct ke_msg_handler.conflict26 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict25 ke_msg_handler.conflict25, *Pke_msg_handler.conflict25; + +struct ke_msg_handler.conflict25 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict24 ke_msg_handler.conflict24, *Pke_msg_handler.conflict24; + +struct ke_msg_handler.conflict24 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict23 ke_msg_handler.conflict23, *Pke_msg_handler.conflict23; + +struct ke_msg_handler.conflict23 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict22 ke_msg_handler.conflict22, *Pke_msg_handler.conflict22; + +struct ke_msg_handler.conflict22 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict21 ke_msg_handler.conflict21, *Pke_msg_handler.conflict21; + +struct ke_msg_handler.conflict21 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict20 ke_msg_handler.conflict20, *Pke_msg_handler.conflict20; + +struct ke_msg_handler.conflict20 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict19 ke_msg_handler.conflict19, *Pke_msg_handler.conflict19; + +struct ke_msg_handler.conflict19 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict18 ke_msg_handler.conflict18, *Pke_msg_handler.conflict18; + +struct ke_msg_handler.conflict18 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict17 ke_msg_handler.conflict17, *Pke_msg_handler.conflict17; + +struct ke_msg_handler.conflict17 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict16 ke_msg_handler.conflict16, *Pke_msg_handler.conflict16; + +struct ke_msg_handler.conflict16 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict15 ke_msg_handler.conflict15, *Pke_msg_handler.conflict15; + +struct ke_msg_handler.conflict15 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict14 ke_msg_handler.conflict14, *Pke_msg_handler.conflict14; + +struct ke_msg_handler.conflict14 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict13 ke_msg_handler.conflict13, *Pke_msg_handler.conflict13; + +struct ke_msg_handler.conflict13 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict12 ke_msg_handler.conflict12, *Pke_msg_handler.conflict12; + +struct ke_msg_handler.conflict12 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict11 ke_msg_handler.conflict11, *Pke_msg_handler.conflict11; + +struct ke_msg_handler.conflict11 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict10 ke_msg_handler.conflict10, *Pke_msg_handler.conflict10; + +struct ke_msg_handler.conflict10 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct anon_struct.conflict18 anon_struct.conflict18, *Panon_struct.conflict18; + +struct anon_struct.conflict18 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict17 anon_struct.conflict17, *Panon_struct.conflict17; + +struct anon_struct.conflict17 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict17 anon_union.conflict17, *Panon_union.conflict17; + +typedef struct anon_struct.conflict19 anon_struct.conflict19, *Panon_struct.conflict19; + +typedef struct anon_struct.conflict20 anon_struct.conflict20, *Panon_struct.conflict20; + +struct anon_struct.conflict19 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +struct anon_struct.conflict20 { + uint32_t key[4]; +}; + +union anon_union.conflict17 { + struct anon_struct.conflict19 mic; + struct anon_struct.conflict20 mfp; +}; + +typedef struct anon_struct.conflict105 anon_struct.conflict105, *Panon_struct.conflict105; + +struct anon_struct.conflict105 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict106 anon_struct.conflict106, *Panon_struct.conflict106; + +struct anon_struct.conflict106 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict100 anon_struct.conflict100, *Panon_struct.conflict100; + +struct anon_struct.conflict100 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict107 anon_struct.conflict107, *Panon_struct.conflict107; + +struct anon_struct.conflict107 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict108 anon_struct.conflict108, *Panon_struct.conflict108; + +struct anon_struct.conflict108 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict114 anon_struct.conflict114, *Panon_struct.conflict114; + +struct anon_struct.conflict114 { + uint32_t key[4]; +}; + +typedef union anon_union.conflict27 anon_union.conflict27, *Panon_union.conflict27; + +typedef struct anon_struct.conflict29 anon_struct.conflict29, *Panon_struct.conflict29; + +typedef struct anon_struct.conflict30 anon_struct.conflict30, *Panon_struct.conflict30; + +struct anon_struct.conflict30 { + uint32_t key[4]; +}; + +struct anon_struct.conflict29 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict27 { + struct anon_struct.conflict29 mic; + struct anon_struct.conflict30 mfp; +}; + +typedef struct anon_struct.conflict115 anon_struct.conflict115, *Panon_struct.conflict115; + +struct anon_struct.conflict115 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict116 anon_struct.conflict116, *Panon_struct.conflict116; + +struct anon_struct.conflict116 { + uint32_t key[4]; +}; + +typedef union anon_union.conflict3 anon_union.conflict3, *Panon_union.conflict3; + +typedef struct anon_struct.conflict4 anon_struct.conflict4, *Panon_struct.conflict4; + +typedef struct anon_struct.conflict5 anon_struct.conflict5, *Panon_struct.conflict5; + +struct anon_struct.conflict5 { + uint32_t key[4]; +}; + +struct anon_struct.conflict4 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict3 { + struct anon_struct.conflict4 mic; + struct anon_struct.conflict5 mfp; +}; + +typedef struct anon_struct.conflict113 anon_struct.conflict113, *Panon_struct.conflict113; + +struct anon_struct.conflict113 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict118 anon_struct.conflict118, *Panon_struct.conflict118; + +struct anon_struct.conflict118 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict119 anon_struct.conflict119, *Panon_struct.conflict119; + +struct anon_struct.conflict119 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict120 anon_struct.conflict120, *Panon_struct.conflict120; + +struct anon_struct.conflict120 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict34 anon_union.conflict34, *Panon_union.conflict34; + +typedef struct anon_struct.conflict39 anon_struct.conflict39, *Panon_struct.conflict39; + +typedef struct anon_struct.conflict40 anon_struct.conflict40, *Panon_struct.conflict40; + +struct anon_struct.conflict39 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +struct anon_struct.conflict40 { + uint32_t key[4]; +}; + +union anon_union.conflict34 { + struct anon_struct.conflict39 mic; + struct anon_struct.conflict40 mfp; +}; + +typedef struct anon_struct.conflict125 anon_struct.conflict125, *Panon_struct.conflict125; + +struct anon_struct.conflict125 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict126 anon_struct.conflict126, *Panon_struct.conflict126; + +struct anon_struct.conflict126 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict127 anon_struct.conflict127, *Panon_struct.conflict127; + +struct anon_struct.conflict127 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict128 anon_struct.conflict128, *Panon_struct.conflict128; + +struct anon_struct.conflict128 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict121 anon_struct.conflict121, *Panon_struct.conflict121; + +struct anon_struct.conflict121 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict129 anon_struct.conflict129, *Panon_struct.conflict129; + +struct anon_struct.conflict129 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict41 anon_union.conflict41, *Panon_union.conflict41; + +typedef struct anon_struct.conflict47 anon_struct.conflict47, *Panon_struct.conflict47; + +typedef struct anon_struct.conflict48 anon_struct.conflict48, *Panon_struct.conflict48; + +struct anon_struct.conflict48 { + uint32_t key[4]; +}; + +struct anon_struct.conflict47 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict41 { + struct anon_struct.conflict47 mic; + struct anon_struct.conflict48 mfp; +}; + +typedef struct anon_struct.conflict130 anon_struct.conflict130, *Panon_struct.conflict130; + +struct anon_struct.conflict130 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict131 anon_struct.conflict131, *Panon_struct.conflict131; + +struct anon_struct.conflict131 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict48 anon_union.conflict48, *Panon_union.conflict48; + +typedef struct anon_struct.conflict63 anon_struct.conflict63, *Panon_struct.conflict63; + +typedef struct anon_struct.conflict64 anon_struct.conflict64, *Panon_struct.conflict64; + +struct anon_struct.conflict64 { + uint32_t key[4]; +}; + +struct anon_struct.conflict63 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict48 { + struct anon_struct.conflict63 mic; + struct anon_struct.conflict64 mfp; +}; + +typedef struct anon_struct.conflict132 anon_struct.conflict132, *Panon_struct.conflict132; + +struct anon_struct.conflict132 { + uint32_t key[4]; +}; + +typedef union anon_union.conflict173 anon_union.conflict173, *Panon_union.conflict173; + +typedef struct anon_struct.conflict209 anon_struct.conflict209, *Panon_struct.conflict209; + +typedef struct anon_struct.conflict210 anon_struct.conflict210, *Panon_struct.conflict210; + +struct anon_struct.conflict210 { + uint32_t key[4]; +}; + +struct anon_struct.conflict209 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict173 { + struct anon_struct.conflict209 mic; + struct anon_struct.conflict210 mfp; +}; + +typedef union anon_union.conflict55 anon_union.conflict55, *Panon_union.conflict55; + +typedef struct anon_struct.conflict73 anon_struct.conflict73, *Panon_struct.conflict73; + +typedef struct anon_struct.conflict74 anon_struct.conflict74, *Panon_struct.conflict74; + +struct anon_struct.conflict74 { + uint32_t key[4]; +}; + +struct anon_struct.conflict73 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict55 { + struct anon_struct.conflict73 mic; + struct anon_struct.conflict74 mfp; +}; + +typedef struct anon_struct.conflict46 anon_struct.conflict46, *Panon_struct.conflict46; + +struct anon_struct.conflict46 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict45 anon_struct.conflict45, *Panon_struct.conflict45; + +struct anon_struct.conflict45 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict62 anon_union.conflict62, *Panon_union.conflict62; + +typedef struct anon_struct.conflict81 anon_struct.conflict81, *Panon_struct.conflict81; + +typedef struct anon_struct.conflict82 anon_struct.conflict82, *Panon_struct.conflict82; + +struct anon_struct.conflict82 { + uint32_t key[4]; +}; + +struct anon_struct.conflict81 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict62 { + struct anon_struct.conflict81 mic; + struct anon_struct.conflict82 mfp; +}; + +typedef union anon_union.conflict69 anon_union.conflict69, *Panon_union.conflict69; + +typedef struct anon_struct.conflict89 anon_struct.conflict89, *Panon_struct.conflict89; + +typedef struct anon_struct.conflict90 anon_struct.conflict90, *Panon_struct.conflict90; + +struct anon_struct.conflict90 { + uint32_t key[4]; +}; + +struct anon_struct.conflict89 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict69 { + struct anon_struct.conflict89 mic; + struct anon_struct.conflict90 mfp; +}; + +typedef union anon_union.conflict166 anon_union.conflict166, *Panon_union.conflict166; + +typedef struct anon_struct.conflict201 anon_struct.conflict201, *Panon_struct.conflict201; + +typedef struct anon_struct.conflict202 anon_struct.conflict202, *Panon_struct.conflict202; + +struct anon_struct.conflict202 { + uint32_t key[4]; +}; + +struct anon_struct.conflict201 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict166 { + struct anon_struct.conflict201 mic; + struct anon_struct.conflict202 mfp; +}; + +typedef struct anon_struct.conflict38 anon_struct.conflict38, *Panon_struct.conflict38; + +struct anon_struct.conflict38 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict37 anon_struct.conflict37, *Panon_struct.conflict37; + +struct anon_struct.conflict37 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict159 anon_union.conflict159, *Panon_union.conflict159; + +typedef struct anon_struct.conflict193 anon_struct.conflict193, *Panon_struct.conflict193; + +typedef struct anon_struct.conflict194 anon_struct.conflict194, *Panon_struct.conflict194; + +struct anon_struct.conflict193 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +struct anon_struct.conflict194 { + uint32_t key[4]; +}; + +union anon_union.conflict159 { + struct anon_struct.conflict193 mic; + struct anon_struct.conflict194 mfp; +}; + +typedef union anon_union.conflict152 anon_union.conflict152, *Panon_union.conflict152; + +typedef struct anon_struct.conflict185 anon_struct.conflict185, *Panon_struct.conflict185; + +typedef struct anon_struct.conflict186 anon_struct.conflict186, *Panon_struct.conflict186; + +struct anon_struct.conflict186 { + uint32_t key[4]; +}; + +struct anon_struct.conflict185 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict152 { + struct anon_struct.conflict185 mic; + struct anon_struct.conflict186 mfp; +}; + +typedef union anon_union.conflict77 anon_union.conflict77, *Panon_union.conflict77; + +typedef struct anon_struct.conflict99 anon_struct.conflict99, *Panon_struct.conflict99; + +struct anon_struct.conflict99 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict77 { + struct anon_struct.conflict99 mic; + struct anon_struct.conflict100 mfp; +}; + +typedef struct anon_struct.conflict200 anon_struct.conflict200, *Panon_struct.conflict200; + +struct anon_struct.conflict200 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict207 anon_struct.conflict207, *Panon_struct.conflict207; + +struct anon_struct.conflict207 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict208 anon_struct.conflict208, *Panon_struct.conflict208; + +struct anon_struct.conflict208 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict28 anon_struct.conflict28, *Panon_struct.conflict28; + +struct anon_struct.conflict28 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict27 anon_struct.conflict27, *Panon_struct.conflict27; + +struct anon_struct.conflict27 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict91 anon_union.conflict91, *Panon_union.conflict91; + +union anon_union.conflict91 { + struct anon_struct.conflict115 mic; + struct anon_struct.conflict116 mfp; +}; + +typedef union anon_union.conflict84 anon_union.conflict84, *Panon_union.conflict84; + +union anon_union.conflict84 { + struct anon_struct.conflict107 mic; + struct anon_struct.conflict108 mfp; +}; + +typedef union anon_union.conflict145 anon_union.conflict145, *Panon_union.conflict145; + +typedef struct anon_struct.conflict177 anon_struct.conflict177, *Panon_struct.conflict177; + +typedef struct anon_struct.conflict178 anon_struct.conflict178, *Panon_struct.conflict178; + +struct anon_struct.conflict178 { + uint32_t key[4]; +}; + +struct anon_struct.conflict177 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict145 { + struct anon_struct.conflict177 mic; + struct anon_struct.conflict178 mfp; +}; + +typedef struct anon_struct.conflict98 anon_struct.conflict98, *Panon_struct.conflict98; + +struct anon_struct.conflict98 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict97 anon_struct.conflict97, *Panon_struct.conflict97; + +struct anon_struct.conflict97 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict138 anon_union.conflict138, *Panon_union.conflict138; + +typedef struct anon_struct.conflict169 anon_struct.conflict169, *Panon_struct.conflict169; + +typedef struct anon_struct.conflict170 anon_struct.conflict170, *Panon_struct.conflict170; + +struct anon_struct.conflict170 { + uint32_t key[4]; +}; + +struct anon_struct.conflict169 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict138 { + struct anon_struct.conflict169 mic; + struct anon_struct.conflict170 mfp; +}; + +typedef struct anon_struct.conflict183 anon_struct.conflict183, *Panon_struct.conflict183; + +struct anon_struct.conflict183 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict96 anon_union.conflict96, *Panon_union.conflict96; + +union anon_union.conflict96 { + struct anon_struct.conflict120 mic; + struct anon_struct.conflict121 mfp; +}; + +typedef struct anon_struct.conflict184 anon_struct.conflict184, *Panon_struct.conflict184; + +struct anon_struct.conflict184 { + uint32_t key[4]; +}; + +typedef union anon_union.conflict133 anon_union.conflict133, *Panon_union.conflict133; + +typedef struct anon_struct.conflict165 anon_struct.conflict165, *Panon_struct.conflict165; + +typedef struct anon_struct.conflict166 anon_struct.conflict166, *Panon_struct.conflict166; + +struct anon_struct.conflict166 { + uint32_t key[4]; +}; + +struct anon_struct.conflict165 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict133 { + struct anon_struct.conflict165 mic; + struct anon_struct.conflict166 mfp; +}; + +typedef struct anon_struct.conflict87 anon_struct.conflict87, *Panon_struct.conflict87; + +struct anon_struct.conflict87 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict80 anon_struct.conflict80, *Panon_struct.conflict80; + +struct anon_struct.conflict80 { + uint32_t key[4]; +}; + +typedef union anon_union.conflict126 anon_union.conflict126, *Panon_union.conflict126; + +typedef struct anon_struct.conflict157 anon_struct.conflict157, *Panon_struct.conflict157; + +typedef struct anon_struct.conflict158 anon_struct.conflict158, *Panon_struct.conflict158; + +struct anon_struct.conflict157 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +struct anon_struct.conflict158 { + uint32_t key[4]; +}; + +union anon_union.conflict126 { + struct anon_struct.conflict157 mic; + struct anon_struct.conflict158 mfp; +}; + +typedef struct anon_struct.conflict88 anon_struct.conflict88, *Panon_struct.conflict88; + +struct anon_struct.conflict88 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict191 anon_struct.conflict191, *Panon_struct.conflict191; + +struct anon_struct.conflict191 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict192 anon_struct.conflict192, *Panon_struct.conflict192; + +struct anon_struct.conflict192 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict199 anon_struct.conflict199, *Panon_struct.conflict199; + +struct anon_struct.conflict199 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict72 anon_struct.conflict72, *Panon_struct.conflict72; + +struct anon_struct.conflict72 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict71 anon_struct.conflict71, *Panon_struct.conflict71; + +struct anon_struct.conflict71 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict79 anon_struct.conflict79, *Panon_struct.conflict79; + +struct anon_struct.conflict79 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict119 anon_union.conflict119, *Panon_union.conflict119; + +typedef struct anon_struct.conflict149 anon_struct.conflict149, *Panon_struct.conflict149; + +typedef struct anon_struct.conflict150 anon_struct.conflict150, *Panon_struct.conflict150; + +struct anon_struct.conflict150 { + uint32_t key[4]; +}; + +struct anon_struct.conflict149 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +union anon_union.conflict119 { + struct anon_struct.conflict149 mic; + struct anon_struct.conflict150 mfp; +}; + +typedef union anon_union.conflict111 anon_union.conflict111, *Panon_union.conflict111; + +union anon_union.conflict111 { + struct anon_struct.conflict131 mic; + struct anon_struct.conflict132 mfp; +}; + +typedef struct anon_struct.conflict62 anon_struct.conflict62, *Panon_struct.conflict62; + +struct anon_struct.conflict62 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict61 anon_struct.conflict61, *Panon_struct.conflict61; + +struct anon_struct.conflict61 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef union anon_union.conflict106 anon_union.conflict106, *Panon_union.conflict106; + +union anon_union.conflict106 { + struct anon_struct.conflict127 mic; + struct anon_struct.conflict128 mfp; +}; + +typedef struct anon_struct.conflict147 anon_struct.conflict147, *Panon_struct.conflict147; + +struct anon_struct.conflict147 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict148 anon_struct.conflict148, *Panon_struct.conflict148; + +struct anon_struct.conflict148 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict7 anon_struct.conflict7, *Panon_struct.conflict7; + +struct anon_struct.conflict7 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict6 anon_struct.conflict6, *Panon_struct.conflict6; + +struct anon_struct.conflict6 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict3 anon_struct.conflict3, *Panon_struct.conflict3; + +struct anon_struct.conflict3 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict2 anon_struct.conflict2, *Panon_struct.conflict2; + +struct anon_struct.conflict2 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict155 anon_struct.conflict155, *Panon_struct.conflict155; + +struct anon_struct.conflict155 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict156 anon_struct.conflict156, *Panon_struct.conflict156; + +struct anon_struct.conflict156 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict163 anon_struct.conflict163, *Panon_struct.conflict163; + +struct anon_struct.conflict163 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict164 anon_struct.conflict164, *Panon_struct.conflict164; + +struct anon_struct.conflict164 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict167 anon_struct.conflict167, *Panon_struct.conflict167; + +struct anon_struct.conflict167 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict168 anon_struct.conflict168, *Panon_struct.conflict168; + +struct anon_struct.conflict168 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict175 anon_struct.conflict175, *Panon_struct.conflict175; + +struct anon_struct.conflict175 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict176 anon_struct.conflict176, *Panon_struct.conflict176; + +struct anon_struct.conflict176 { + uint32_t key[4]; +}; + +typedef struct _uart_ioctrl_wait_read _uart_ioctrl_wait_read, *P_uart_ioctrl_wait_read; + +struct _uart_ioctrl_wait_read { + char * buf; + int read_size; + uint32_t timeout; +}; + +typedef struct _uart_ioctrl_config _uart_ioctrl_config, *P_uart_ioctrl_config; + +typedef struct _uart_ioctrl_config uart_ioc_config_t; + +typedef enum ioc_uart_parity_t { + IO_UART_PARITY_EVEN=2, + IO_UART_PARITY_NONE=0, + IO_UART_PARITY_ODD=1 +} ioc_uart_parity_t; + +struct _uart_ioctrl_config { + uint32_t baud; + enum ioc_uart_parity_t parity; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct _uart_ioctrl_wait_read uart_ioc_waitread_t; + +typedef struct anon_struct.conflict371 anon_struct.conflict371, *Panon_struct.conflict371; + +struct anon_struct.conflict371 { + uint8_t partition_active_idx; + uint8_t pad[3]; + struct PtTable_Stuff_Config table; +}; + +typedef struct HALPartition_Entry_Config HALPartition_Entry_Config, *PHALPartition_Entry_Config; + +struct HALPartition_Entry_Config { + uint8_t type; + uint8_t device; + uint8_t activeIndex; + uint8_t name[9]; + uint32_t Address[2]; + uint32_t maxLen[2]; + uint32_t len; + uint32_t age; +}; + +typedef enum HAL_Err_Type { + HAL_ERROR=1, + HAL_SUCCESS=0 +} HAL_Err_Type; + +typedef struct NoHostSecurityParams_t NoHostSecurityParams_t, *PNoHostSecurityParams_t; + +struct NoHostSecurityParams_t { + UINT8 CipherType; + UINT8 MulticastCipher; + UINT8 UnicastCipher; + char PSKPassPhrase[64]; +}; + +typedef struct phy_hal_tag phy_hal_tag, *Pphy_hal_tag; + +struct phy_hal_tag { + int16_t temperature; + uint8_t capcode; + undefined field_0x3; +}; + +typedef struct anon_struct.conflict402 anon_struct.conflict402, *Panon_struct.conflict402; + +struct anon_struct.conflict402 { + void * handle; + int fd; +}; + +typedef struct event_list_node_t event_list_node_t, *Pevent_list_node_t; + +struct event_list_node_t { + dlist_t node; + void (* cb)(struct input_event_t *, void *); + void * priv; + uint16_t type_filter; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct Bl_MD5_CTX Bl_MD5_CTX, *PBl_MD5_CTX; + +struct Bl_MD5_CTX { + ulong state[4]; + ulong count[2]; + ulong scratch[16]; + uchar buffer[64]; +}; + +typedef struct mbedtls_md5_context mbedtls_md5_context, *Pmbedtls_md5_context; + +struct mbedtls_md5_context { + uint32_t total[2]; + uint32_t state[4]; + uchar buffer[64]; +}; + +typedef struct input_t input_t, *Pinput_t; + +struct input_t { + int8_t rssi; + int8_t lna; + undefined field_0x2; + undefined field_0x3; + float ppm; + uint8_t new; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct pa_state_t pa_state_t, *Ppa_state_t; + +struct pa_state_t { + uint8_t used; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + uint32_t vif_tag; + struct input_t input_buffer[8]; + int8_t input_buffer_ptr; + undefined field_0x69; + undefined field_0x6a; + undefined field_0x6b; + uint32_t last_update; + int8_t rss; + int8_t rss_acq; + int8_t rss_trk; + int8_t rss_state; + uint8_t rss_hit_count; + undefined field_0x75; + undefined field_0x76; + undefined field_0x77; + uint32_t rss_count; + int8_t ris; + undefined field_0x7d; + undefined field_0x7e; + undefined field_0x7f; + float ce; + int8_t ce_in; + int8_t ce_acq; + int8_t ce_trk; + int8_t ce_state; + int8_t ce_num_up_cmds; + int8_t ce_num_dn_cmds; + undefined field_0x8a; + undefined field_0x8b; +}; + +typedef struct rvec_t rvec_t, *Prvec_t; + +struct rvec_t { + uint32_t leg_length:12; + uint32_t leg_rate:4; + uint32_t ht_length:16; + uint32_t _ht_length:4; + uint32_t short_gi:1; + uint32_t stbc:2; + uint32_t smoothing:1; + uint32_t mcs:7; + uint32_t pre_type:1; + uint32_t format_mod:3; + uint32_t ch_bw:2; + uint32_t n_sts:3; + uint32_t lsig_valid:1; + uint32_t sounding:1; + uint32_t num_extn_ss:2; + uint32_t aggregation:1; + uint32_t fec_coding:1; + uint32_t dyn_bw:1; + uint32_t doze_not_allowed:1; + uint32_t antenna_set:8; + uint32_t partial_aid:9; + uint32_t group_id:6; + uint32_t reserved_1c:1; + int32_t rssi1:8; + int32_t rssi2:8; + int32_t agc_lna:4; + int32_t agc_rbb1:5; + int32_t agc_dg:7; + uint32_t reserved_1d:8; + uint32_t rcpi:8; + uint32_t evm1:8; + uint32_t evm2:8; + uint32_t freqoff_lo:8; + uint32_t freqoff_hi:8; + uint32_t reserved2b_1:8; + uint32_t reserved2b_2:8; + uint32_t reserved2b_3:8; +}; + +typedef struct sm_env_tag sm_env_tag, *Psm_env_tag; + +struct sm_env_tag { + struct sm_connect_req * connect_param; + struct sm_connect_ind * connect_ind; + struct co_list bss_config; + _Bool join_passive; + _Bool ft_over_ds; + undefined field_0x12; + undefined field_0x13; + int exist_ssid_idx; + struct mac_addr ft_old_bssid; + undefined field_0x1e; + undefined field_0x1f; +}; + +typedef struct utils_memp_node utils_memp_node, *Putils_memp_node; + +struct utils_memp_node { + struct utils_memp_node * next; +}; + +typedef struct pool pool, *Ppool; + +typedef struct pool utils_memp_pool_t; + +struct pool { + uint32_t node_size; + uint32_t pool_cap; + uint32_t pool_size; + uint8_t align_req; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t padded_node_size; + void * first_node; + void * last_node; + struct utils_memp_node * mem; +}; + +typedef struct ke_timer ke_timer, *Pke_timer; + +struct ke_timer { + struct ke_timer * next; + ke_msg_id_t id; + ke_task_id_t task; + uint32_t time; +}; + +typedef struct anon_struct.conflict372 anon_struct.conflict372, *Panon_struct.conflict372; + +struct anon_struct.conflict372 { + uint32_t magic; + struct SPI_Flash_Cfg_Type flashCfg; +}; + +typedef struct igmp_msg igmp_msg, *Pigmp_msg; + +struct igmp_msg { + u8_t igmp_msgtype; + u8_t igmp_maxresp; + u16_t igmp_checksum; + ip4_addr_p_t igmp_group_address; +}; + +typedef struct igmp_group igmp_group, *Pigmp_group; + +struct igmp_group { + struct igmp_group * next; + ip4_addr_t group_address; + u8_t last_reporter_flag; + u8_t group_state; + u16_t timer; + u8_t use; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; +}; + +typedef struct env_hdr_data env_hdr_data, *Penv_hdr_data; + +typedef struct env_hdr_data * env_hdr_data_t; + +struct env_hdr_data { + uint8_t status_table[5]; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t magic; + uint32_t len; + uint32_t crc32; + uint8_t name_len; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + uint32_t value_len; +}; + +typedef enum sector_dirty_status { + SECTOR_DIRTY_FALSE=1, + SECTOR_DIRTY_GC=3, + SECTOR_DIRTY_STATUS_NUM=4, + SECTOR_DIRTY_TRUE=2, + SECTOR_DIRTY_UNUSED=0 +} sector_dirty_status; + +typedef enum sector_dirty_status sector_dirty_status_t; + +typedef struct sector_cache_node sector_cache_node, *Psector_cache_node; + +struct sector_cache_node { + uint32_t addr; + uint32_t empty_addr; +}; + +typedef struct anon_struct.conflict369 anon_struct.conflict369, *Panon_struct.conflict369; + +struct anon_struct.conflict369 { + uint8_t store[3]; + uint8_t dirty[3]; +}; + +typedef struct sector_meta_data sector_meta_data, *Psector_meta_data; + +typedef struct sector_meta_data * sector_meta_data_t; + +typedef struct anon_struct_for_status anon_struct_for_status, *Panon_struct_for_status; + +typedef enum sector_store_status { + SECTOR_STORE_EMPTY=1, + SECTOR_STORE_FULL=3, + SECTOR_STORE_STATUS_NUM=4, + SECTOR_STORE_UNUSED=0, + SECTOR_STORE_USING=2 +} sector_store_status; + +typedef enum sector_store_status sector_store_status_t; + +struct anon_struct_for_status { + sector_store_status_t store; + sector_dirty_status_t dirty; +}; + +struct sector_meta_data { + _Bool check_ok; + struct anon_struct_for_status status; + undefined field_0x3; + uint32_t addr; + uint32_t magic; + uint32_t combined; + size_t remain; + uint32_t empty_env; +}; + +typedef struct anon_struct.conflict370 anon_struct.conflict370, *Panon_struct.conflict370; + +struct anon_struct.conflict370 { + sector_store_status_t store; + sector_dirty_status_t dirty; +}; + +typedef struct env_cache_node env_cache_node, *Penv_cache_node; + +struct env_cache_node { + uint16_t name_crc; + uint16_t active; + uint32_t addr; +}; + +typedef struct sector_hdr_data sector_hdr_data, *Psector_hdr_data; + +typedef struct anon_struct_for_status_table anon_struct_for_status_table, *Panon_struct_for_status_table; + +struct anon_struct_for_status_table { + uint8_t store[3]; + uint8_t dirty[3]; +}; + +struct sector_hdr_data { + struct anon_struct_for_status_table status_table; + undefined field_0x6; + undefined field_0x7; + uint32_t magic; + uint32_t combined; + uint32_t reserved; +}; + +typedef struct uart_priv_data uart_priv_data, *Puart_priv_data; + +typedef struct uart_priv_data uart_priv_data_t; + +struct uart_priv_data { + aos_mutex_t mutex; +}; + +typedef struct _feature_pin _feature_pin, *P_feature_pin; + +struct _feature_pin { + char * featue_name; + char * pin_name; + uint8_t value; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct bl_uart_notify bl_uart_notify, *Pbl_uart_notify; + +struct bl_uart_notify { + void (* rx_cb)(void *); + void * rx_cb_arg; + void (* tx_cb)(void *); + void * tx_cb_arg; +}; + +typedef struct bl_uart_notify bl_uart_notify_t; + +typedef struct apm_start_cac_req apm_start_cac_req, *Papm_start_cac_req; + +struct apm_start_cac_req { + struct scan_chan_tag chan; + undefined field_0x6; + undefined field_0x7; + uint32_t center_freq1; + uint32_t center_freq2; + uint8_t ch_width; + uint8_t vif_idx; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct apm_start_cfm apm_start_cfm, *Papm_start_cfm; + +struct apm_start_cfm { + uint8_t status; + uint8_t vif_idx; + uint8_t ch_idx; + uint8_t bcmc_idx; +}; + +typedef struct apm_sta_del_cfm apm_sta_del_cfm, *Papm_sta_del_cfm; + +struct apm_sta_del_cfm { + uint8_t status; + uint8_t vif_idx; + uint8_t sta_idx; +}; + +typedef struct apm_stop_req apm_stop_req, *Papm_stop_req; + +struct apm_stop_req { + uint8_t vif_idx; +}; + +typedef struct apm_sta_del_ind apm_sta_del_ind, *Papm_sta_del_ind; + +struct apm_sta_del_ind { + uint8_t sta_idx; +}; + +typedef enum apm_msg_tag { + APM_CONF_MAX_STA_CFM=7182, + APM_CONF_MAX_STA_REQ=7181, + APM_MAX=7183, + APM_START_CAC_CFM=7173, + APM_START_CAC_REQ=7172, + APM_START_CFM=7169, + APM_START_REQ=7168, + APM_STA_ADD_IND=7176, + APM_STA_CONNECT_TIMEOUT_IND=7178, + APM_STA_DEL_CFM=7180, + APM_STA_DEL_IND=7177, + APM_STA_DEL_REQ=7179, + APM_STOP_CAC_CFM=7175, + APM_STOP_CAC_REQ=7174, + APM_STOP_CFM=7171, + APM_STOP_REQ=7170 +} apm_msg_tag; + +typedef enum apm_state_tag { + APM_BCN_SETTING=2, + APM_BSS_PARAM_SETTING=1, + APM_IDLE=0, + APM_STATE_MAX=3 +} apm_state_tag; + +typedef struct apm_start_cac_cfm apm_start_cac_cfm, *Papm_start_cac_cfm; + +struct apm_start_cac_cfm { + uint8_t status; + uint8_t ch_idx; +}; + +typedef struct apm_stop_cac_req apm_stop_cac_req, *Papm_stop_cac_req; + +struct apm_stop_cac_req { + uint8_t vif_idx; +}; + +typedef struct apm_conf_max_sta_req apm_conf_max_sta_req, *Papm_conf_max_sta_req; + +struct apm_conf_max_sta_req { + uint8_t max_sta_supported; +}; + +typedef struct apm_sta_del_req apm_sta_del_req, *Papm_sta_del_req; + +struct apm_sta_del_req { + uint8_t vif_idx; + uint8_t sta_idx; +}; + +typedef struct apm_sta_add_ind apm_sta_add_ind, *Papm_sta_add_ind; + +struct apm_sta_add_ind { + uint32_t flags; + struct mac_addr sta_addr; + uint8_t vif_idx; + uint8_t sta_idx; + int8_t rssi; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t tsflo; + uint32_t tsfhi; + uint8_t data_rate; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; +}; + +typedef struct UART_CFG_Type UART_CFG_Type, *PUART_CFG_Type; + +typedef enum UART_DataBits_Type { + UART_DATABITS_5=0, + UART_DATABITS_6=1, + UART_DATABITS_7=2, + UART_DATABITS_8=3 +} UART_DataBits_Type; + +typedef enum UART_StopBits_Type { + UART_STOPBITS_1=0, + UART_STOPBITS_1_5=1, + UART_STOPBITS_2=2 +} UART_StopBits_Type; + +typedef enum UART_Parity_Type { + UART_PARITY_EVEN=2, + UART_PARITY_NONE=0, + UART_PARITY_ODD=1 +} UART_Parity_Type; + +typedef enum UART_ByteBitInverse_Type { + UART_LSB_FIRST=0, + UART_MSB_FIRST=1 +} UART_ByteBitInverse_Type; + +struct UART_CFG_Type { + uint32_t uartClk; + uint32_t baudRate; + enum UART_DataBits_Type dataBits; + enum UART_StopBits_Type stopBits; + enum UART_Parity_Type parity; + enum BL_Fun_Type ctsFlowControl; + enum BL_Fun_Type rxDeglitch; + enum BL_Fun_Type rtsSoftwareControl; + enum UART_ByteBitInverse_Type byteBitInverse; + undefined field_0xf; +}; + +typedef struct UART_FifoCfg_Type UART_FifoCfg_Type, *PUART_FifoCfg_Type; + +struct UART_FifoCfg_Type { + uint8_t txFifoDmaThreshold; + uint8_t rxFifoDmaThreshold; + enum BL_Fun_Type txFifoDmaEnable; + enum BL_Fun_Type rxFifoDmaEnable; +}; + +typedef enum UART_ID_Type { + UART0_ID=0, + UART1_ID=1, + UART_ID_MAX=2 +} UART_ID_Type; + +typedef enum UART_AutoBaudDetection_Type { + UART_AUTOBAUD_0X55=0, + UART_AUTOBAUD_STARTBIT=1 +} UART_AutoBaudDetection_Type; + +typedef enum UART_Direction_Type { + UART_RX=1, + UART_TX=0, + UART_TXRX=2 +} UART_Direction_Type; + +typedef enum UART_Overflow_Type { + UART_RX_OVERFLOW=2, + UART_RX_UNDERFLOW=3, + UART_TX_OVERFLOW=0, + UART_TX_UNDERFLOW=1 +} UART_Overflow_Type; + +typedef struct UART_IrCfg_Type UART_IrCfg_Type, *PUART_IrCfg_Type; + +struct UART_IrCfg_Type { + enum BL_Fun_Type txIrEnable; + enum BL_Fun_Type rxIrEnable; + enum BL_Fun_Type txIrInverse; + enum BL_Fun_Type rxIrInverse; + uint16_t txIrPulseStart; + uint16_t txIrPulseStop; + uint16_t rxIrPulseStart; +}; + +typedef enum UART_INT_Type { + UART_INT_ALL=8, + UART_INT_PCE=5, + UART_INT_RTO=4, + UART_INT_RX_END=1, + UART_INT_RX_FER=7, + UART_INT_RX_FIFO_REQ=3, + UART_INT_TX_END=0, + UART_INT_TX_FER=6, + UART_INT_TX_FIFO_REQ=2 +} UART_INT_Type; + +typedef struct ethhdr ethhdr, *Pethhdr; + +struct ethhdr { + uchar h_dest[6]; + uchar h_source[6]; + __be16 h_proto; +}; + +typedef struct anon_struct.conflict343 anon_struct.conflict343, *Panon_struct.conflict343; + +struct anon_struct.conflict343 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict229 anon_struct.conflict229, *Panon_struct.conflict229; + +struct anon_struct.conflict229 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict308 anon_struct.conflict308, *Panon_struct.conflict308; + +struct anon_struct.conflict308 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict230 anon_struct.conflict230, *Panon_struct.conflict230; + +struct anon_struct.conflict230 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict312 anon_struct.conflict312, *Panon_struct.conflict312; + +struct anon_struct.conflict312 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef enum ieee80211_vht_mcs_support { + IEEE80211_VHT_MCS_NOT_SUPPORTED=3, + IEEE80211_VHT_MCS_SUPPORT_0_7=0, + IEEE80211_VHT_MCS_SUPPORT_0_8=1, + IEEE80211_VHT_MCS_SUPPORT_0_9=2 +} ieee80211_vht_mcs_support; + +typedef struct anon_struct.conflict231 anon_struct.conflict231, *Panon_struct.conflict231; + +struct anon_struct.conflict231 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict232 anon_struct.conflict232, *Panon_struct.conflict232; + +struct anon_struct.conflict232 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict360 anon_struct.conflict360, *Panon_struct.conflict360; + +struct anon_struct.conflict360 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict240 anon_struct.conflict240, *Panon_struct.conflict240; + +struct anon_struct.conflict240 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict361 anon_struct.conflict361, *Panon_struct.conflict361; + +struct anon_struct.conflict361 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict241 anon_struct.conflict241, *Panon_struct.conflict241; + +struct anon_struct.conflict241 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict242 anon_struct.conflict242, *Panon_struct.conflict242; + +struct anon_struct.conflict242 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict363 anon_struct.conflict363, *Panon_struct.conflict363; + +struct anon_struct.conflict363 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict243 anon_struct.conflict243, *Panon_struct.conflict243; + +struct anon_struct.conflict243 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef union anon_union.conflict190 anon_union.conflict190, *Panon_union.conflict190; + +union anon_union.conflict190 { + struct anon_struct.conflict288 auth; + struct anon_struct.conflict289 deauth; + struct anon_struct.conflict290 assoc_req; + struct anon_struct.conflict291 assoc_resp; + struct anon_struct.conflict292 reassoc_resp; + struct anon_struct.conflict293 reassoc_req; + struct anon_struct.conflict294 disassoc; + struct anon_struct.conflict295 beacon; + struct anon_struct probe_req; + struct anon_struct.conflict296 probe_resp; +}; + +typedef union anon_union.conflict186 anon_union.conflict186, *Panon_union.conflict186; + +union anon_union.conflict186 { + struct anon_struct.conflict226 sta; + struct anon_struct.conflict241 ap; + struct anon_struct.conflict228 ap_vlan; +}; + +typedef union anon_union.conflict183 anon_union.conflict183, *Panon_union.conflict183; + +union anon_union.conflict183 { + struct anon_struct.conflict226 sta; + struct anon_struct.conflict230 ap; + struct anon_struct.conflict228 ap_vlan; +}; + +typedef union anon_union.conflict184 anon_union.conflict184, *Panon_union.conflict184; + +union anon_union.conflict184 { + struct anon_struct.conflict226 sta; + struct anon_struct.conflict232 ap; + struct anon_struct.conflict228 ap_vlan; +}; + +typedef union anon_union.conflict187 anon_union.conflict187, *Panon_union.conflict187; + +union anon_union.conflict187 { + struct anon_struct.conflict226 sta; + struct anon_struct.conflict243 ap; + struct anon_struct.conflict228 ap_vlan; +}; + +typedef struct txl_frame_desc_tag txl_frame_desc_tag, *Ptxl_frame_desc_tag; + +typedef struct txl_frame_cfm_tag txl_frame_cfm_tag, *Ptxl_frame_cfm_tag; + +struct txl_frame_cfm_tag { + void (* cfm_func)(void *, uint32_t); + void * env; +}; + +struct txl_frame_desc_tag { + struct txdesc txdesc; + struct txl_frame_cfm_tag cfm; + uint8_t type; + _Bool postponed; + _Bool keep_desc; + undefined field_0x2d7; +}; + +typedef struct txl_frame_env_tag txl_frame_env_tag, *Ptxl_frame_env_tag; + +struct txl_frame_env_tag { + struct co_list desc_free; + struct co_list desc_done; +}; + +typedef enum icmp_dur_type { + ICMP_DUR_FRAG=4, + ICMP_DUR_HOST=1, + ICMP_DUR_NET=0, + ICMP_DUR_PORT=3, + ICMP_DUR_PROTO=2, + ICMP_DUR_SR=5 +} icmp_dur_type; + +typedef struct icmp_echo_hdr icmp_echo_hdr, *Picmp_echo_hdr; + +struct icmp_echo_hdr { + u8_t type; + u8_t code; + u16_t chksum; + u16_t id; + u16_t seqno; +}; + +typedef struct fdt_property fdt_property, *Pfdt_property; + +struct fdt_property { + fdt32_t tag; + fdt32_t len; + fdt32_t nameoff; + char[0] data; +}; + +typedef struct fdt_reserve_entry fdt_reserve_entry, *Pfdt_reserve_entry; + +struct fdt_reserve_entry { + fdt64_t address; + fdt64_t size; +}; + +typedef struct fdt_node_header fdt_node_header, *Pfdt_node_header; + +struct fdt_node_header { + fdt32_t tag; + char[0] name; +}; + +typedef struct fdt_header fdt_header, *Pfdt_header; + +struct fdt_header { + fdt32_t magic; + fdt32_t totalsize; + fdt32_t off_dt_struct; + fdt32_t off_dt_strings; + fdt32_t off_mem_rsvmap; + fdt32_t version; + fdt32_t last_comp_version; + fdt32_t boot_cpuid_phys; + fdt32_t size_dt_strings; + fdt32_t size_dt_struct; +}; + +typedef struct mbedtls_rsa_context mbedtls_rsa_context, *Pmbedtls_rsa_context; + +struct mbedtls_rsa_context { + int ver; + size_t len; + struct mbedtls_mpi N; + struct mbedtls_mpi E; + struct mbedtls_mpi D; + struct mbedtls_mpi P; + struct mbedtls_mpi Q; + struct mbedtls_mpi DP; + struct mbedtls_mpi DQ; + struct mbedtls_mpi QP; + struct mbedtls_mpi RN; + struct mbedtls_mpi RP; + struct mbedtls_mpi RQ; + struct mbedtls_mpi Vi; + struct mbedtls_mpi Vf; + int padding; + int hash_id; +}; + +typedef struct anon_struct.conflict223 anon_struct.conflict223, *Panon_struct.conflict223; + +struct anon_struct.conflict223 { + uint32_t task; + uint32_t element; + uint32_t type; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct anon_struct.conflict221 anon_struct.conflict221, *Panon_struct.conflict221; + +struct anon_struct.conflict221 { + uint32_t task; + uint32_t element; +}; + +typedef struct anon_struct.conflict217 anon_struct.conflict217, *Panon_struct.conflict217; + +struct anon_struct.conflict217 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct anon_struct.conflict218 anon_struct.conflict218, *Panon_struct.conflict218; + +struct anon_struct.conflict218 { + uint32_t task; + uint32_t element; +}; + +typedef struct anon_struct.conflict219 anon_struct.conflict219, *Panon_struct.conflict219; + +struct anon_struct.conflict219 { + uint32_t task; + uint32_t element; +}; + +typedef struct cfg_start_req cfg_start_req, *Pcfg_start_req; + +struct cfg_start_req { // Missing member u : anon_union_for_u at offset 0x4 [exceeds parent struct len] + uint32_t ops; +}; + +typedef struct cfg_start_cfm cfg_start_cfm, *Pcfg_start_cfm; + +struct cfg_start_cfm { + uint8_t status; +}; + +typedef struct anon_struct.conflict220 anon_struct.conflict220, *Panon_struct.conflict220; + +struct anon_struct.conflict220 { + uint32_t task; + uint32_t element; + uint32_t type; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct anon_struct.conflict222 anon_struct.conflict222, *Panon_struct.conflict222; + +struct anon_struct.conflict222 { + uint32_t task; + uint32_t element; +}; + +typedef enum cfg_msg_tag { + CFG_MAX=12290, + CFG_START_CFM=12289, + CFG_START_REQ=12288 +} cfg_msg_tag; + +typedef enum cfg_state_tag { + CFG_IDLE=0, + CFG_STATE_MAX=1 +} cfg_state_tag; + +typedef struct anon_struct.conflict117 anon_struct.conflict117, *Panon_struct.conflict117; + +struct anon_struct.conflict117 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef union anon_union.conflict181 anon_union.conflict181, *Panon_union.conflict181; + +union anon_union.conflict181 { + undefined1 get; // Data type larger than union's declared size: anon_struct[1] + undefined1 reset; // Data type larger than union's declared size: anon_struct[1] + undefined1 set; // Data type larger than union's declared size: anon_struct[1] +}; + +typedef union tcp_listen_pcbs_t tcp_listen_pcbs_t, *Ptcp_listen_pcbs_t; + +union tcp_listen_pcbs_t { + struct tcp_pcb_listen * listen_pcbs; + struct tcp_pcb * pcbs; +}; + +typedef union anon_union.conflict10 anon_union.conflict10, *Panon_union.conflict10; + +union anon_union.conflict10 { + uint32 Interface; + struct cm_ConnectionInfo * connPtr; +}; + +typedef struct TIMER_CFG_Type TIMER_CFG_Type, *PTIMER_CFG_Type; + +typedef enum TIMER_Chan_Type { + TIMER_CH0=0, + TIMER_CH1=1, + TIMER_CH_MAX=2 +} TIMER_Chan_Type; + +typedef enum TIMER_ClkSrc_Type { + TIMER_CLKSRC_1K=2, + TIMER_CLKSRC_32K=1, + TIMER_CLKSRC_FCLK=0, + TIMER_CLKSRC_XTAL=3 +} TIMER_ClkSrc_Type; + +typedef enum TIMER_PreLoad_Trig_Type { + TIMER_PRELOAD_TRIG_COMP0=1, + TIMER_PRELOAD_TRIG_COMP1=2, + TIMER_PRELOAD_TRIG_COMP2=3, + TIMER_PRELOAD_TRIG_NONE=0 +} TIMER_PreLoad_Trig_Type; + +typedef enum TIMER_CountMode_Type { + TIMER_COUNT_FREERUN=1, + TIMER_COUNT_PRELOAD=0 +} TIMER_CountMode_Type; + +struct TIMER_CFG_Type { + enum TIMER_Chan_Type timerCh; + enum TIMER_ClkSrc_Type clkSrc; + enum TIMER_PreLoad_Trig_Type plTrigSrc; + enum TIMER_CountMode_Type countMode; + uint8_t clockDivision; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t matchVal0; + uint32_t matchVal1; + uint32_t matchVal2; + uint32_t preLoadVal; +}; + +typedef enum WDT_INT_Type { + WDT_INT=0, + WDT_INT_ALL=1 +} WDT_INT_Type; + +typedef enum TIMER_INT_Type { + TIMER_INT_ALL=3, + TIMER_INT_COMP_0=0, + TIMER_INT_COMP_1=1, + TIMER_INT_COMP_2=2 +} TIMER_INT_Type; + +typedef enum TIMER_Comp_ID_Type { + TIMER_COMP_ID_0=0, + TIMER_COMP_ID_1=1, + TIMER_COMP_ID_2=2 +} TIMER_Comp_ID_Type; + +typedef struct DMA_LLI_Ctrl_Type DMA_LLI_Ctrl_Type, *PDMA_LLI_Ctrl_Type; + +typedef struct DMA_Control_Reg.conflict DMA_Control_Reg.conflict, *PDMA_Control_Reg.conflict; + +struct DMA_Control_Reg.conflict { + uint32_t TransferSize:12; + uint32_t SBSize:3; + uint32_t DBSize:3; + uint32_t SWidth:3; + uint32_t DWidth:3; + uint32_t SLargerD:1; + uint32_t reserved_25:1; + uint32_t SI:1; + uint32_t DI:1; + uint32_t Prot:3; + uint32_t I:1; +}; + +struct DMA_LLI_Ctrl_Type { + uint32_t srcDmaAddr; + uint32_t destDmaAddr; + uint32_t nextLLI; + struct DMA_Control_Reg.conflict dmaCtrl; +}; + +typedef enum DMA_Trans_Dir_Type { + DMA_TRNS_M2M=0, + DMA_TRNS_M2P=1, + DMA_TRNS_P2M=2, + DMA_TRNS_P2P=3 +} DMA_Trans_Dir_Type; + +typedef enum DMA_Burst_Size_Type { + DMA_BURST_SIZE_1=0, + DMA_BURST_SIZE_16=3, + DMA_BURST_SIZE_4=1, + DMA_BURST_SIZE_8=2 +} DMA_Burst_Size_Type; + +typedef struct DMA_LLI_Ctrl_Type.conflict DMA_LLI_Ctrl_Type.conflict, *PDMA_LLI_Ctrl_Type.conflict; + +typedef struct DMA_Control_Reg.conflict1 DMA_Control_Reg.conflict1, *PDMA_Control_Reg.conflict1; + +struct DMA_Control_Reg.conflict1 { + uint32_t TransferSize:12; + uint32_t SBSize:3; + uint32_t DBSize:3; + uint32_t SWidth:3; + uint32_t DWidth:3; + uint32_t SLargerD:1; + uint32_t reserved_25:1; + uint32_t SI:1; + uint32_t DI:1; + uint32_t Prot:3; + uint32_t I:1; +}; + +struct DMA_LLI_Ctrl_Type.conflict { + uint32_t srcDmaAddr; + uint32_t destDmaAddr; + uint32_t nextLLI; + struct DMA_Control_Reg.conflict1 dmaCtrl; +}; + +typedef struct DMA_LLI_Ctrl_Type.conflict1 DMA_LLI_Ctrl_Type.conflict1, *PDMA_LLI_Ctrl_Type.conflict1; + +typedef struct DMA_Control_Reg.conflict2 DMA_Control_Reg.conflict2, *PDMA_Control_Reg.conflict2; + +struct DMA_Control_Reg.conflict2 { + uint32_t TransferSize:12; + uint32_t SBSize:3; + uint32_t DBSize:3; + uint32_t SWidth:3; + uint32_t DWidth:3; + uint32_t SLargerD:1; + uint32_t reserved_25:1; + uint32_t SI:1; + uint32_t DI:1; + uint32_t Prot:3; + uint32_t I:1; +}; + +struct DMA_LLI_Ctrl_Type.conflict1 { + uint32_t srcDmaAddr; + uint32_t destDmaAddr; + uint32_t nextLLI; + struct DMA_Control_Reg.conflict2 dmaCtrl; +}; + +typedef enum DMA_Chan_Type { + DMA_CH0=0, + DMA_CH1=1, + DMA_CH2=2, + DMA_CH3=3, + DMA_CH_MAX=4 +} DMA_Chan_Type; + +typedef struct DMA_LLI_PP_Buf DMA_LLI_PP_Buf, *PDMA_LLI_PP_Buf; + +struct DMA_LLI_PP_Buf { + uint8_t idleIndex; + uint8_t dmaChan; + undefined field_0x2; + undefined field_0x3; + struct DMA_LLI_Ctrl_Type * lliListHeader[2]; + void (* onTransCompleted)(struct DMA_LLI_Ctrl_Type *); +}; + +typedef struct DMA_LLI_PP_Struct DMA_LLI_PP_Struct, *PDMA_LLI_PP_Struct; + +typedef struct DMA_Control_Reg DMA_Control_Reg, *PDMA_Control_Reg; + +typedef struct DMA_LLI_Cfg_Type DMA_LLI_Cfg_Type, *PDMA_LLI_Cfg_Type; + +typedef enum DMA_Periph_Req_Type { + DMA_REQ_GPADC0=22, + DMA_REQ_GPADC1=23, + DMA_REQ_I2C_RX=6, + DMA_REQ_I2C_TX=7, + DMA_REQ_NONE=0, + DMA_REQ_SPI_RX=10, + DMA_REQ_SPI_TX=11, + DMA_REQ_UART0_RX=0, + DMA_REQ_UART0_TX=1, + DMA_REQ_UART1_RX=2, + DMA_REQ_UART1_TX=3 +} DMA_Periph_Req_Type; + +struct DMA_LLI_Cfg_Type { + enum DMA_Trans_Dir_Type dir; + enum DMA_Periph_Req_Type srcPeriph; + enum DMA_Periph_Req_Type dstPeriph; +}; + +struct DMA_Control_Reg { + uint32_t TransferSize:12; + uint32_t SBSize:3; + uint32_t DBSize:3; + uint32_t SWidth:3; + uint32_t DWidth:3; + uint32_t SLargerD:1; + uint32_t reserved_25:1; + uint32_t SI:1; + uint32_t DI:1; + uint32_t Prot:3; + uint32_t I:1; +}; + +struct DMA_LLI_PP_Struct { + uint8_t trans_index; + uint8_t dmaChan; + undefined field_0x2; + undefined field_0x3; + struct DMA_Control_Reg dmaCtrlRegVal; + struct DMA_LLI_Cfg_Type * DMA_LLI_Cfg; + uint32_t operatePeriphAddr; + uint32_t chache_buf_addr[2]; + enum BL_Fun_Type is_single_mode; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; +}; + +typedef enum DMA_INT_Type { + DMA_INT_ALL=2, + DMA_INT_ERR=1, + DMA_INT_TCOMPLETED=0 +} DMA_INT_Type; + +typedef struct DMA_Channel_Cfg_Type DMA_Channel_Cfg_Type, *PDMA_Channel_Cfg_Type; + +typedef enum DMA_Trans_Width_Type { + DMA_TRNS_WIDTH_16BITS=1, + DMA_TRNS_WIDTH_32BITS=2, + DMA_TRNS_WIDTH_8BITS=0 +} DMA_Trans_Width_Type; + +struct DMA_Channel_Cfg_Type { + uint32_t srcDmaAddr; + uint32_t destDmaAddr; + uint32_t transfLength; + enum DMA_Trans_Dir_Type dir; + enum DMA_Chan_Type ch; + enum DMA_Trans_Width_Type srcTransfWidth; + enum DMA_Trans_Width_Type dstTransfWidth; + enum DMA_Burst_Size_Type srcBurstSzie; + enum DMA_Burst_Size_Type dstBurstSzie; + uint8_t srcAddrInc; + uint8_t destAddrInc; + enum DMA_Periph_Req_Type srcPeriph; + enum DMA_Periph_Req_Type dstPeriph; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct anon_struct.conflict415 anon_struct.conflict415, *Panon_struct.conflict415; + +struct anon_struct.conflict415 { + uint frac:23; + uint exp:8; + uint sign:1; +}; + +typedef union _FP_UNION_S _FP_UNION_S, *P_FP_UNION_S; + +union _FP_UNION_S { + SFtype flt; + struct anon_struct.conflict415 bits; +}; + +typedef SemaphoreHandle_t sys_mutex_t; + +typedef TaskHandle_t sys_thread_t; + +typedef enum BL_Sts_Type { + RESET=0, + SET=1 +} BL_Sts_Type; + +typedef enum BL_Err_Type { + ERROR=1, + SUCCESS=0, + TIMEOUT=2 +} BL_Err_Type; + +typedef enum BL_Mask_Type { + MASK=1, + UNMASK=0 +} BL_Mask_Type; + +typedef struct scan_cancel_cfm scan_cancel_cfm, *Pscan_cancel_cfm; + +struct scan_cancel_cfm { + uint8_t status; +}; + +typedef struct scan_start_cfm scan_start_cfm, *Pscan_start_cfm; + +struct scan_start_cfm { + uint8_t status; +}; + +typedef enum scan_state_tag { + SCAN_IDLE=0, + SCAN_STATE_MAX=4, + SCAN_WAIT_BEACON_PROBE_RSP=3, + SCAN_WAIT_CHANNEL=2, + SCAN_WAIT_IE_DWNLD=1 +} scan_state_tag; + +typedef enum scan_msg_tag { + SCAN_CANCEL_CFM=2052, + SCAN_CANCEL_REQ=2051, + SCAN_DONE_IND=2050, + SCAN_MAX=2054, + SCAN_START_CFM=2049, + SCAN_START_REQ=2048, + SCAN_TIMER=2053 +} scan_msg_tag; + +typedef struct utils_time_date_t utils_time_date_t, *Putils_time_date_t; + +struct utils_time_date_t { + uchar ntp_hour; + uchar ntp_minute; + uchar ntp_second; + uchar ntp_week_day; + uchar ntp_date; + uchar ntp_month; + uchar leap_days; + uchar leap_year_ind; + uint ntp_year; + uint days_since_epoch; + uint day_of_year; +}; + +typedef struct _MessageHandlers.conflict24 _MessageHandlers.conflict24, *P_MessageHandlers.conflict24; + +typedef struct _MessageHandlers.conflict24 MessageHandlers.conflict20; + +struct _MessageHandlers.conflict24 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict25 _MessageHandlers.conflict25, *P_MessageHandlers.conflict25; + +typedef struct _MessageHandlers.conflict25 MessageHandlers.conflict21; + +struct _MessageHandlers.conflict25 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict17 _MessageHandlers.conflict17, *P_MessageHandlers.conflict17; + +typedef struct _MessageHandlers.conflict17 MessageHandlers.conflict14; + +struct _MessageHandlers.conflict17 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict28 _MessageHandlers.conflict28, *P_MessageHandlers.conflict28; + +typedef struct _MessageHandlers.conflict28 MessageHandlers.conflict24; + +struct _MessageHandlers.conflict28 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict30 _MessageHandlers.conflict30, *P_MessageHandlers.conflict30; + +typedef struct _MessageHandlers.conflict30 MessageHandlers.conflict25; + +struct _MessageHandlers.conflict30 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict26 _MessageHandlers.conflict26, *P_MessageHandlers.conflict26; + +typedef struct _MessageHandlers.conflict26 MessageHandlers.conflict22; + +struct _MessageHandlers.conflict26 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict27 _MessageHandlers.conflict27, *P_MessageHandlers.conflict27; + +typedef struct _MessageHandlers.conflict27 MessageHandlers.conflict23; + +struct _MessageHandlers.conflict27 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict33 _MessageHandlers.conflict33, *P_MessageHandlers.conflict33; + +typedef struct _MessageHandlers.conflict33 MessageHandlers.conflict28; + +struct _MessageHandlers.conflict33 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict34 _MessageHandlers.conflict34, *P_MessageHandlers.conflict34; + +typedef struct _MessageHandlers.conflict34 MessageHandlers.conflict29; + +struct _MessageHandlers.conflict34 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict31 _MessageHandlers.conflict31, *P_MessageHandlers.conflict31; + +typedef struct _MessageHandlers.conflict31 MessageHandlers.conflict26; + +struct _MessageHandlers.conflict31 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict32 _MessageHandlers.conflict32, *P_MessageHandlers.conflict32; + +typedef struct _MessageHandlers.conflict32 MessageHandlers.conflict27; + +struct _MessageHandlers.conflict32 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict10 _MessageHandlers.conflict10, *P_MessageHandlers.conflict10; + +typedef struct _MessageHandlers.conflict10 MessageHandlers.conflict8; + +struct _MessageHandlers.conflict10 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict3 _MessageHandlers.conflict3, *P_MessageHandlers.conflict3; + +typedef struct _MessageHandlers.conflict3 MessageHandlers.conflict2; + +struct _MessageHandlers.conflict3 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict37 _MessageHandlers.conflict37, *P_MessageHandlers.conflict37; + +typedef struct _MessageHandlers.conflict37 MessageHandlers.conflict31; + +struct _MessageHandlers.conflict37 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict38 _MessageHandlers.conflict38, *P_MessageHandlers.conflict38; + +typedef struct _MessageHandlers.conflict38 MessageHandlers.conflict32; + +struct _MessageHandlers.conflict38 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict35 _MessageHandlers.conflict35, *P_MessageHandlers.conflict35; + +typedef struct _MessageHandlers.conflict35 MessageHandlers.conflict30; + +struct _MessageHandlers.conflict35 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict41 _MessageHandlers.conflict41, *P_MessageHandlers.conflict41; + +typedef struct _MessageHandlers.conflict41 MessageHandlers.conflict35; + +struct _MessageHandlers.conflict41 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict42 _MessageHandlers.conflict42, *P_MessageHandlers.conflict42; + +typedef struct _MessageHandlers.conflict42 MessageHandlers.conflict36; + +struct _MessageHandlers.conflict42 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict39 _MessageHandlers.conflict39, *P_MessageHandlers.conflict39; + +typedef struct _MessageHandlers.conflict39 MessageHandlers.conflict33; + +struct _MessageHandlers.conflict39 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict40 _MessageHandlers.conflict40, *P_MessageHandlers.conflict40; + +typedef struct _MessageHandlers.conflict40 MessageHandlers.conflict34; + +struct _MessageHandlers.conflict40 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict46 _MessageHandlers.conflict46, *P_MessageHandlers.conflict46; + +typedef struct _MessageHandlers.conflict46 MessageHandlers.conflict39; + +struct _MessageHandlers.conflict46 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict44 _MessageHandlers.conflict44, *P_MessageHandlers.conflict44; + +typedef struct _MessageHandlers.conflict44 MessageHandlers.conflict37; + +struct _MessageHandlers.conflict44 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict45 _MessageHandlers.conflict45, *P_MessageHandlers.conflict45; + +typedef struct _MessageHandlers.conflict45 MessageHandlers.conflict38; + +struct _MessageHandlers.conflict45 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict4 _MessageHandlers.conflict4, *P_MessageHandlers.conflict4; + +typedef struct _MessageHandlers.conflict4 MessageHandlers.conflict3; + +struct _MessageHandlers.conflict4 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers _MessageHandlers, *P_MessageHandlers; + +struct _MessageHandlers { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict _MessageHandlers.conflict, *P_MessageHandlers.conflict; + +typedef struct _MessageHandlers.conflict MessageHandlers.conflict; + +struct _MessageHandlers.conflict { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict12 _MessageHandlers.conflict12, *P_MessageHandlers.conflict12; + +typedef struct _MessageHandlers.conflict12 MessageHandlers.conflict10; + +struct _MessageHandlers.conflict12 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict16 _MessageHandlers.conflict16, *P_MessageHandlers.conflict16; + +typedef struct _MessageHandlers.conflict16 MessageHandlers.conflict13; + +struct _MessageHandlers.conflict16 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict13 _MessageHandlers.conflict13, *P_MessageHandlers.conflict13; + +typedef struct _MessageHandlers.conflict13 MessageHandlers.conflict11; + +struct _MessageHandlers.conflict13 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict14 _MessageHandlers.conflict14, *P_MessageHandlers.conflict14; + +typedef struct _MessageHandlers.conflict14 MessageHandlers.conflict12; + +struct _MessageHandlers.conflict14 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict20 _MessageHandlers.conflict20, *P_MessageHandlers.conflict20; + +typedef struct _MessageHandlers.conflict20 MessageHandlers.conflict17; + +struct _MessageHandlers.conflict20 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict21 _MessageHandlers.conflict21, *P_MessageHandlers.conflict21; + +typedef struct _MessageHandlers.conflict21 MessageHandlers.conflict18; + +struct _MessageHandlers.conflict21 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict18 _MessageHandlers.conflict18, *P_MessageHandlers.conflict18; + +typedef struct _MessageHandlers.conflict18 MessageHandlers.conflict15; + +struct _MessageHandlers.conflict18 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict19 _MessageHandlers.conflict19, *P_MessageHandlers.conflict19; + +typedef struct _MessageHandlers.conflict19 MessageHandlers.conflict16; + +struct _MessageHandlers.conflict19 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict23 _MessageHandlers.conflict23, *P_MessageHandlers.conflict23; + +typedef struct _MessageHandlers.conflict23 MessageHandlers.conflict19; + +struct _MessageHandlers.conflict23 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _Client.conflict11 _Client.conflict11, *P_Client.conflict11; + +struct _Client.conflict11 { + struct Timer pingTimer; + struct Timer reconnectDelayTimer; + ClientStatus clientStatus; + undefined field_0x1b; + ClientData clientData; + struct Network.conflict25 networkStack; +}; + +typedef struct _Client.conflict12 _Client.conflict12, *P_Client.conflict12; + +struct _Client.conflict12 { + struct Timer pingTimer; + struct Timer reconnectDelayTimer; + ClientStatus clientStatus; + undefined field_0x1b; + ClientData clientData; + struct Network.conflict26 networkStack; +}; + +typedef struct _Client.conflict10 _Client.conflict10, *P_Client.conflict10; + +struct _Client.conflict10 { + struct Timer pingTimer; + struct Timer reconnectDelayTimer; + ClientStatus clientStatus; + undefined field_0x1b; + ClientData clientData; + struct Network.conflict22 networkStack; +}; + +typedef struct IoT_Client_Init_Params IoT_Client_Init_Params, *PIoT_Client_Init_Params; + +struct IoT_Client_Init_Params { + _Bool enableAutoReconnect; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + char * pHostURL; + uint16_t port; + undefined field_0xa; + undefined field_0xb; + char * pRootCALocation; + char * pDeviceCertLocation; + char * pDevicePrivateKeyLocation; + uint32_t mqttPacketTimeout_ms; + uint32_t mqttCommandTimeout_ms; + uint32_t tlsHandshakeTimeout_ms; + _Bool isSSLHostnameVerify; + undefined field_0x25; + undefined field_0x26; + undefined field_0x27; + void (* disconnectHandler)(AWS_IoT_Client *, void *); + void * disconnectHandlerData; + _Bool isBlockOnThreadLockEnabled; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct _Client.conflict _Client.conflict, *P_Client.conflict; + +struct _Client.conflict { + struct Timer pingTimer; + struct Timer reconnectDelayTimer; + ClientStatus clientStatus; + undefined field_0x1b; + ClientData clientData; + struct Network.conflict2 networkStack; +}; + +typedef struct _Client.conflict7 _Client.conflict7, *P_Client.conflict7; + +struct _Client.conflict7 { + struct Timer pingTimer; + struct Timer reconnectDelayTimer; + ClientStatus clientStatus; + undefined field_0x1b; + ClientData clientData; + struct Network.conflict17 networkStack; +}; + +typedef struct _Client.conflict6 _Client.conflict6, *P_Client.conflict6; + +struct _Client.conflict6 { + struct Timer pingTimer; + struct Timer reconnectDelayTimer; + ClientStatus clientStatus; + undefined field_0x1b; + ClientData clientData; + struct Network.conflict14 networkStack; +}; + +typedef struct _Client.conflict9 _Client.conflict9, *P_Client.conflict9; + +struct _Client.conflict9 { + struct Timer pingTimer; + struct Timer reconnectDelayTimer; + ClientStatus clientStatus; + undefined field_0x1b; + ClientData clientData; + struct Network.conflict21 networkStack; +}; + +typedef struct _Client.conflict8 _Client.conflict8, *P_Client.conflict8; + +struct _Client.conflict8 { + struct Timer pingTimer; + struct Timer reconnectDelayTimer; + ClientStatus clientStatus; + undefined field_0x1b; + ClientData clientData; + struct Network.conflict18 networkStack; +}; + +typedef struct _MessageHandlers MessageHandlers; + +typedef struct _MessageHandlers.conflict6 _MessageHandlers.conflict6, *P_MessageHandlers.conflict6; + +typedef struct _MessageHandlers.conflict6 MessageHandlers.conflict5; + +struct _MessageHandlers.conflict6 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict36 _MessageHandlers.conflict36, *P_MessageHandlers.conflict36; + +struct _MessageHandlers.conflict36 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict7 _MessageHandlers.conflict7, *P_MessageHandlers.conflict7; + +typedef struct _MessageHandlers.conflict7 MessageHandlers.conflict6; + +struct _MessageHandlers.conflict7 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _Client.conflict1 _Client.conflict1, *P_Client.conflict1; + +struct _Client.conflict1 { + struct Timer pingTimer; + struct Timer reconnectDelayTimer; + ClientStatus clientStatus; + undefined field_0x1b; + ClientData clientData; + struct Network.conflict5 networkStack; +}; + +typedef struct _Client.conflict3 _Client.conflict3, *P_Client.conflict3; + +struct _Client.conflict3 { + struct Timer pingTimer; + struct Timer reconnectDelayTimer; + ClientStatus clientStatus; + undefined field_0x1b; + ClientData clientData; + struct Network.conflict9 networkStack; +}; + +typedef struct _Client.conflict2 _Client.conflict2, *P_Client.conflict2; + +struct _Client.conflict2 { + struct Timer pingTimer; + struct Timer reconnectDelayTimer; + ClientStatus clientStatus; + undefined field_0x1b; + ClientData clientData; + struct Network.conflict6 networkStack; +}; + +typedef struct _Client.conflict5 _Client.conflict5, *P_Client.conflict5; + +struct _Client.conflict5 { + struct Timer pingTimer; + struct Timer reconnectDelayTimer; + ClientStatus clientStatus; + undefined field_0x1b; + ClientData clientData; + struct Network.conflict13 networkStack; +}; + +typedef struct _Client.conflict4 _Client.conflict4, *P_Client.conflict4; + +struct _Client.conflict4 { + struct Timer pingTimer; + struct Timer reconnectDelayTimer; + ClientStatus clientStatus; + undefined field_0x1b; + ClientData clientData; + struct Network.conflict10 networkStack; +}; + +typedef struct _MessageHandlers.conflict43 _MessageHandlers.conflict43, *P_MessageHandlers.conflict43; + +struct _MessageHandlers.conflict43 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict15 _MessageHandlers.conflict15, *P_MessageHandlers.conflict15; + +struct _MessageHandlers.conflict15 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict8 _MessageHandlers.conflict8, *P_MessageHandlers.conflict8; + +struct _MessageHandlers.conflict8 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict9 _MessageHandlers.conflict9, *P_MessageHandlers.conflict9; + +struct _MessageHandlers.conflict9 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict11 _MessageHandlers.conflict11, *P_MessageHandlers.conflict11; + +struct _MessageHandlers.conflict11 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict5 _MessageHandlers.conflict5, *P_MessageHandlers.conflict5; + +struct _MessageHandlers.conflict5 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict5 MessageHandlers.conflict4; + +typedef struct _MessageHandlers.conflict1 _MessageHandlers.conflict1, *P_MessageHandlers.conflict1; + +struct _MessageHandlers.conflict1 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict2 _MessageHandlers.conflict2, *P_MessageHandlers.conflict2; + +struct _MessageHandlers.conflict2 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict29 _MessageHandlers.conflict29, *P_MessageHandlers.conflict29; + +struct _MessageHandlers.conflict29 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _MessageHandlers.conflict9 MessageHandlers.conflict7; + +typedef struct _MessageHandlers.conflict11 MessageHandlers.conflict9; + +typedef struct _MessageHandlers.conflict2 MessageHandlers.conflict1; + +typedef struct _MessageHandlers.conflict22 _MessageHandlers.conflict22, *P_MessageHandlers.conflict22; + +struct _MessageHandlers.conflict22 { + char * topicName; + uint16_t topicNameLen; + enum QoS qos; + undefined field_0x7; + void (* pApplicationHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); + void * pApplicationHandlerData; +}; + +typedef struct _Client.conflict5 AWS_IoT_Client.conflict2; + +typedef struct _Client.conflict7 AWS_IoT_Client.conflict3; + +typedef struct _Client.conflict9 AWS_IoT_Client.conflict4; + +typedef struct _Client.conflict11 AWS_IoT_Client.conflict5; + +typedef struct _Client.conflict3 AWS_IoT_Client.conflict1; + +typedef struct _Client.conflict1 AWS_IoT_Client.conflict; + +typedef struct iot_sha256_context iot_sha256_context, *Piot_sha256_context; + +struct iot_sha256_context { + uint32_t total[2]; + uint32_t state[8]; + uchar buffer[64]; + int is224; +}; + +typedef enum task_mm_cfg { + TASK_MM_CFG_KEEP_ALIVE_PACKET_COUNTER=2, + TASK_MM_CFG_KEEP_ALIVE_STATUS_ENABLED=0, + TASK_MM_CFG_KEEP_ALIVE_TIME_LAST_RECEIVED=1 +} task_mm_cfg; + +typedef int ptrdiff_t; + +typedef struct mm_timer_env_tag mm_timer_env_tag, *Pmm_timer_env_tag; + +struct mm_timer_env_tag { + struct co_list prog; +}; + +typedef enum dbg_sev_tag { + DBG_SEV_ALL=7, + DBG_SEV_IDX_CRT=1, + DBG_SEV_IDX_ERR=2, + DBG_SEV_IDX_INF=4, + DBG_SEV_IDX_MAX=6, + DBG_SEV_IDX_NONE=0, + DBG_SEV_IDX_VRB=5, + DBG_SEV_IDX_WRN=3 +} dbg_sev_tag; + +typedef struct debug_env_tag debug_env_tag, *Pdebug_env_tag; + +struct debug_env_tag { + uint32_t filter_module; + uint32_t filter_severity; +}; + +typedef enum dbg_mod_tag { + DBG_MOD_IDX_DBG=1, + DBG_MOD_IDX_DMA=3, + DBG_MOD_IDX_IPC=2, + DBG_MOD_IDX_KE=0, + DBG_MOD_IDX_MAX=8, + DBG_MOD_IDX_MM=4, + DBG_MOD_IDX_PHY=7, + DBG_MOD_IDX_RX=6, + DBG_MOD_IDX_TX=5 +} dbg_mod_tag; + +typedef enum mbedtls_cipher_padding_t { + MBEDTLS_PADDING_NONE=4, + MBEDTLS_PADDING_ONE_AND_ZEROS=1, + MBEDTLS_PADDING_PKCS7=0, + MBEDTLS_PADDING_ZEROS=3, + MBEDTLS_PADDING_ZEROS_AND_LEN=2 +} mbedtls_cipher_padding_t; + +typedef enum ShadowActions_t { + SHADOW_DELETE=2, + SHADOW_GET=0, + SHADOW_UPDATE=1 +} ShadowActions_t; + +typedef struct ShadowInitParameters_t ShadowInitParameters_t, *PShadowInitParameters_t; + +struct ShadowInitParameters_t { + char * pHost; + uint16_t port; + undefined field_0x6; + undefined field_0x7; + char * pRootCA; + char * pClientCRT; + char * pClientKey; + _Bool enableAutoReconnect; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + void (* disconnectHandler)(AWS_IoT_Client *, void *); +}; + +typedef struct ShadowConnectParameters_t.conflict9 ShadowConnectParameters_t.conflict9, *PShadowConnectParameters_t.conflict9; + +struct ShadowConnectParameters_t.conflict9 { + char * pMyThingName; + char * pMqttClientId; + uint16_t mqttClientIdLen; + undefined field_0xa; + undefined field_0xb; + void (* deleteActionHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); +}; + +typedef struct ShadowConnectParameters_t.conflict7 ShadowConnectParameters_t.conflict7, *PShadowConnectParameters_t.conflict7; + +struct ShadowConnectParameters_t.conflict7 { + char * pMyThingName; + char * pMqttClientId; + uint16_t mqttClientIdLen; + undefined field_0xa; + undefined field_0xb; + void (* deleteActionHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); +}; + +typedef struct ShadowConnectParameters_t.conflict8 ShadowConnectParameters_t.conflict8, *PShadowConnectParameters_t.conflict8; + +struct ShadowConnectParameters_t.conflict8 { + char * pMyThingName; + char * pMqttClientId; + uint16_t mqttClientIdLen; + undefined field_0xa; + undefined field_0xb; + void (* deleteActionHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); +}; + +typedef struct ShadowConnectParameters_t.conflict6 ShadowConnectParameters_t.conflict6, *PShadowConnectParameters_t.conflict6; + +struct ShadowConnectParameters_t.conflict6 { + char * pMyThingName; + char * pMqttClientId; + uint16_t mqttClientIdLen; + undefined field_0xa; + undefined field_0xb; + void (* deleteActionHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); +}; + +typedef struct ShadowConnectParameters_t.conflict ShadowConnectParameters_t.conflict, *PShadowConnectParameters_t.conflict; + +struct ShadowConnectParameters_t.conflict { + char * pMyThingName; + char * pMqttClientId; + uint16_t mqttClientIdLen; + undefined field_0xa; + undefined field_0xb; + void (* deleteActionHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); +}; + +typedef struct ShadowConnectParameters_t.conflict2 ShadowConnectParameters_t.conflict2, *PShadowConnectParameters_t.conflict2; + +struct ShadowConnectParameters_t.conflict2 { + char * pMyThingName; + char * pMqttClientId; + uint16_t mqttClientIdLen; + undefined field_0xa; + undefined field_0xb; + void (* deleteActionHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); +}; + +typedef struct ShadowConnectParameters_t.conflict11 ShadowConnectParameters_t.conflict11, *PShadowConnectParameters_t.conflict11; + +struct ShadowConnectParameters_t.conflict11 { + char * pMyThingName; + char * pMqttClientId; + uint16_t mqttClientIdLen; + undefined field_0xa; + undefined field_0xb; + void (* deleteActionHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); +}; + +typedef struct ShadowConnectParameters_t.conflict10 ShadowConnectParameters_t.conflict10, *PShadowConnectParameters_t.conflict10; + +struct ShadowConnectParameters_t.conflict10 { + char * pMyThingName; + char * pMqttClientId; + uint16_t mqttClientIdLen; + undefined field_0xa; + undefined field_0xb; + void (* deleteActionHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); +}; + +typedef struct ShadowConnectParameters_t.conflict12 ShadowConnectParameters_t.conflict12, *PShadowConnectParameters_t.conflict12; + +struct ShadowConnectParameters_t.conflict12 { + char * pMyThingName; + char * pMqttClientId; + uint16_t mqttClientIdLen; + undefined field_0xa; + undefined field_0xb; + void (* deleteActionHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); +}; + +typedef struct ShadowConnectParameters_t ShadowConnectParameters_t, *PShadowConnectParameters_t; + +struct ShadowConnectParameters_t { + char * pMyThingName; + char * pMqttClientId; + uint16_t mqttClientIdLen; + undefined field_0xa; + undefined field_0xb; + void (* deleteActionHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); +}; + +typedef struct ShadowConnectParameters_t.conflict5 ShadowConnectParameters_t.conflict5, *PShadowConnectParameters_t.conflict5; + +struct ShadowConnectParameters_t.conflict5 { + char * pMyThingName; + char * pMqttClientId; + uint16_t mqttClientIdLen; + undefined field_0xa; + undefined field_0xb; + void (* deleteActionHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); +}; + +typedef struct ShadowConnectParameters_t.conflict3 ShadowConnectParameters_t.conflict3, *PShadowConnectParameters_t.conflict3; + +struct ShadowConnectParameters_t.conflict3 { + char * pMyThingName; + char * pMqttClientId; + uint16_t mqttClientIdLen; + undefined field_0xa; + undefined field_0xb; + void (* deleteActionHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); +}; + +typedef struct ShadowConnectParameters_t.conflict4 ShadowConnectParameters_t.conflict4, *PShadowConnectParameters_t.conflict4; + +struct ShadowConnectParameters_t.conflict4 { + char * pMyThingName; + char * pMqttClientId; + uint16_t mqttClientIdLen; + undefined field_0xa; + undefined field_0xb; + void (* deleteActionHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); +}; + +typedef struct ShadowConnectParameters_t.conflict1 ShadowConnectParameters_t.conflict1, *PShadowConnectParameters_t.conflict1; + +struct ShadowConnectParameters_t.conflict1 { + char * pMyThingName; + char * pMqttClientId; + uint16_t mqttClientIdLen; + undefined field_0xa; + undefined field_0xb; + void (* deleteActionHandler)(AWS_IoT_Client *, char *, uint16_t, struct IoT_Publish_Message_Params *, void *); +}; + +typedef enum Shadow_Ack_Status_t { + SHADOW_ACK_ACCEPTED=2, + SHADOW_ACK_REJECTED=1, + SHADOW_ACK_TIMEOUT=0 +} Shadow_Ack_Status_t; + +typedef struct anon_struct.conflict10 anon_struct.conflict10, *Panon_struct.conflict10; + +struct anon_struct.conflict10 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict13 anon_struct.conflict13, *Panon_struct.conflict13; + +struct anon_struct.conflict13 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict12 anon_struct.conflict12, *Panon_struct.conflict12; + +struct anon_struct.conflict12 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict11 anon_struct.conflict11, *Panon_struct.conflict11; + +struct anon_struct.conflict11 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict103 anon_struct.conflict103, *Panon_struct.conflict103; + +struct anon_struct.conflict103 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict104 anon_struct.conflict104, *Panon_struct.conflict104; + +struct anon_struct.conflict104 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict101 anon_struct.conflict101, *Panon_struct.conflict101; + +struct anon_struct.conflict101 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict102 anon_struct.conflict102, *Panon_struct.conflict102; + +struct anon_struct.conflict102 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef union anon_union.conflict9 anon_union.conflict9, *Panon_union.conflict9; + +union anon_union.conflict9 { + struct anon_struct.conflict10 sta; + struct anon_struct.conflict11 ap; +}; + +typedef enum VIF_AP_BCMC_STATUS { + VIF_AP_BCMC_BUFFERED=1, + VIF_AP_BCMC_MOREDATA=2 +} VIF_AP_BCMC_STATUS; + +typedef struct anon_struct.conflict109 anon_struct.conflict109, *Panon_struct.conflict109; + +struct anon_struct.conflict109 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef union anon_union.conflict23 anon_union.conflict23, *Panon_union.conflict23; + +typedef struct anon_struct.conflict23 anon_struct.conflict23, *Panon_struct.conflict23; + +typedef struct anon_struct.conflict24 anon_struct.conflict24, *Panon_struct.conflict24; + +struct anon_struct.conflict24 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +struct anon_struct.conflict23 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +union anon_union.conflict23 { + struct anon_struct.conflict23 sta; + struct anon_struct.conflict24 ap; +}; + +typedef struct anon_struct.conflict110 anon_struct.conflict110, *Panon_struct.conflict110; + +struct anon_struct.conflict110 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict111 anon_struct.conflict111, *Panon_struct.conflict111; + +struct anon_struct.conflict111 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict112 anon_struct.conflict112, *Panon_struct.conflict112; + +struct anon_struct.conflict112 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef union anon_union.conflict33 anon_union.conflict33, *Panon_union.conflict33; + +typedef struct anon_struct.conflict33 anon_struct.conflict33, *Panon_struct.conflict33; + +typedef struct anon_struct.conflict34 anon_struct.conflict34, *Panon_struct.conflict34; + +struct anon_struct.conflict34 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +struct anon_struct.conflict33 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +union anon_union.conflict33 { + struct anon_struct.conflict33 sta; + struct anon_struct.conflict34 ap; +}; + +typedef union anon_union.conflict40 anon_union.conflict40, *Panon_union.conflict40; + +typedef struct anon_struct.conflict43 anon_struct.conflict43, *Panon_struct.conflict43; + +typedef struct anon_struct.conflict44 anon_struct.conflict44, *Panon_struct.conflict44; + +struct anon_struct.conflict43 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +struct anon_struct.conflict44 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +union anon_union.conflict40 { + struct anon_struct.conflict43 sta; + struct anon_struct.conflict44 ap; +}; + +typedef union anon_union.conflict47 anon_union.conflict47, *Panon_union.conflict47; + +typedef struct anon_struct.conflict51 anon_struct.conflict51, *Panon_struct.conflict51; + +typedef struct anon_struct.conflict52 anon_struct.conflict52, *Panon_struct.conflict52; + +struct anon_struct.conflict52 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +struct anon_struct.conflict51 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +union anon_union.conflict47 { + struct anon_struct.conflict51 sta; + struct anon_struct.conflict52 ap; +}; + +typedef struct anon_struct.conflict50 anon_struct.conflict50, *Panon_struct.conflict50; + +struct anon_struct.conflict50 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef union anon_union.conflict61 anon_union.conflict61, *Panon_union.conflict61; + +typedef struct anon_struct.conflict77 anon_struct.conflict77, *Panon_struct.conflict77; + +typedef struct anon_struct.conflict78 anon_struct.conflict78, *Panon_struct.conflict78; + +struct anon_struct.conflict78 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +struct anon_struct.conflict77 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +union anon_union.conflict61 { + struct anon_struct.conflict77 sta; + struct anon_struct.conflict78 ap; +}; + +typedef union anon_union.conflict172 anon_union.conflict172, *Panon_union.conflict172; + +typedef struct anon_struct.conflict205 anon_struct.conflict205, *Panon_struct.conflict205; + +typedef struct anon_struct.conflict206 anon_struct.conflict206, *Panon_struct.conflict206; + +struct anon_struct.conflict206 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +struct anon_struct.conflict205 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +union anon_union.conflict172 { + struct anon_struct.conflict205 sta; + struct anon_struct.conflict206 ap; +}; + +typedef union anon_union.conflict54 anon_union.conflict54, *Panon_union.conflict54; + +typedef struct anon_struct.conflict67 anon_struct.conflict67, *Panon_struct.conflict67; + +typedef struct anon_struct.conflict68 anon_struct.conflict68, *Panon_struct.conflict68; + +struct anon_struct.conflict67 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +struct anon_struct.conflict68 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +union anon_union.conflict54 { + struct anon_struct.conflict67 sta; + struct anon_struct.conflict68 ap; +}; + +typedef union anon_union.conflict179 anon_union.conflict179, *Panon_union.conflict179; + +typedef struct anon_struct.conflict215 anon_struct.conflict215, *Panon_struct.conflict215; + +typedef struct anon_struct.conflict216 anon_struct.conflict216, *Panon_struct.conflict216; + +struct anon_struct.conflict216 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +struct anon_struct.conflict215 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +union anon_union.conflict179 { + struct anon_struct.conflict215 sta; + struct anon_struct.conflict216 ap; +}; + +typedef struct anon_struct.conflict42 anon_struct.conflict42, *Panon_struct.conflict42; + +struct anon_struct.conflict42 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct vif_info_tag vif_info_tag, *Pvif_info_tag; + + +// WARNING! conflicting data type names: /DWARF/vif_mgmt.h/vif_info_tag/anon_union_for_u - /DWARF/timers.c/tmrTimerQueueMessage/anon_union_for_u + +struct vif_info_tag { + struct co_list_hdr list_hdr; + uint32_t prevent_sleep; + uint32_t txq_params[4]; + struct mm_timer_tag tbtt_timer; + struct mm_timer_tag tmr_bcn_to; + struct mac_addr bssid; + undefined field_0x3e; + undefined field_0x3f; + struct chan_ctxt_tag * chan_ctxt; + struct chan_tbtt_tag tbtt_switch; + struct mac_addr mac_addr; + uint8_t type; + uint8_t index; + _Bool active; + int8_t tx_power; + int8_t user_tx_power; + undefined field_0x5b; + union anon_union_for_u u; + struct co_list sta_list; + struct mac_bss_info bss_info; + undefined field_0x41c; + undefined field_0x41d; + undefined field_0x41e; + undefined field_0x41f; + struct key_info_tag key_info[4]; + struct key_info_tag * default_key; + uint32_t flags; + struct mm_chan_ctxt_add_req csa_channel; + undefined field_0x5d2; + undefined field_0x5d3; + undefined field_0x5d4; + undefined field_0x5d5; + undefined field_0x5d6; + undefined field_0x5d7; +}; + +typedef struct anon_struct.conflict41 anon_struct.conflict41, *Panon_struct.conflict41; + +struct anon_struct.conflict41 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict49 anon_struct.conflict49, *Panon_struct.conflict49; + +struct anon_struct.conflict49 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef union anon_union.conflict68 anon_union.conflict68, *Panon_union.conflict68; + +typedef struct anon_struct.conflict85 anon_struct.conflict85, *Panon_struct.conflict85; + +typedef struct anon_struct.conflict86 anon_struct.conflict86, *Panon_struct.conflict86; + +struct anon_struct.conflict86 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +struct anon_struct.conflict85 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +union anon_union.conflict68 { + struct anon_struct.conflict85 sta; + struct anon_struct.conflict86 ap; +}; + +typedef union anon_union.conflict165 anon_union.conflict165, *Panon_union.conflict165; + +typedef struct anon_struct.conflict197 anon_struct.conflict197, *Panon_struct.conflict197; + +typedef struct anon_struct.conflict198 anon_struct.conflict198, *Panon_struct.conflict198; + +struct anon_struct.conflict197 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +struct anon_struct.conflict198 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +union anon_union.conflict165 { + struct anon_struct.conflict197 sta; + struct anon_struct.conflict198 ap; +}; + +typedef struct anon_struct.conflict32 anon_struct.conflict32, *Panon_struct.conflict32; + +struct anon_struct.conflict32 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict31 anon_struct.conflict31, *Panon_struct.conflict31; + +struct anon_struct.conflict31 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef union anon_union.conflict158 anon_union.conflict158, *Panon_union.conflict158; + +typedef struct anon_struct.conflict189 anon_struct.conflict189, *Panon_struct.conflict189; + +typedef struct anon_struct.conflict190 anon_struct.conflict190, *Panon_struct.conflict190; + +struct anon_struct.conflict190 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +struct anon_struct.conflict189 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +union anon_union.conflict158 { + struct anon_struct.conflict189 sta; + struct anon_struct.conflict190 ap; +}; + +typedef union anon_union.conflict83 anon_union.conflict83, *Panon_union.conflict83; + +union anon_union.conflict83 { + struct anon_struct.conflict103 sta; + struct anon_struct.conflict104 ap; +}; + +typedef union anon_union.conflict75 anon_union.conflict75, *Panon_union.conflict75; + +typedef struct anon_struct.conflict93 anon_struct.conflict93, *Panon_struct.conflict93; + +typedef struct anon_struct.conflict94 anon_struct.conflict94, *Panon_struct.conflict94; + +struct anon_struct.conflict94 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +struct anon_struct.conflict93 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +union anon_union.conflict75 { + struct anon_struct.conflict93 sta; + struct anon_struct.conflict94 ap; +}; + +typedef union anon_union.conflict151 anon_union.conflict151, *Panon_union.conflict151; + +typedef struct anon_struct.conflict181 anon_struct.conflict181, *Panon_struct.conflict181; + +typedef struct anon_struct.conflict182 anon_struct.conflict182, *Panon_struct.conflict182; + +struct anon_struct.conflict182 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +struct anon_struct.conflict181 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +union anon_union.conflict151 { + struct anon_struct.conflict181 sta; + struct anon_struct.conflict182 ap; +}; + +typedef struct anon_struct.conflict203 anon_struct.conflict203, *Panon_struct.conflict203; + +struct anon_struct.conflict203 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict204 anon_struct.conflict204, *Panon_struct.conflict204; + +struct anon_struct.conflict204 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict21 anon_struct.conflict21, *Panon_struct.conflict21; + +struct anon_struct.conflict21 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef union anon_union.conflict90 anon_union.conflict90, *Panon_union.conflict90; + +union anon_union.conflict90 { + struct anon_struct.conflict111 sta; + struct anon_struct.conflict112 ap; +}; + +typedef struct anon_struct.conflict22 anon_struct.conflict22, *Panon_struct.conflict22; + +struct anon_struct.conflict22 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef union anon_union.conflict144 anon_union.conflict144, *Panon_union.conflict144; + +typedef struct anon_struct.conflict173 anon_struct.conflict173, *Panon_struct.conflict173; + +typedef struct anon_struct.conflict174 anon_struct.conflict174, *Panon_struct.conflict174; + +struct anon_struct.conflict173 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +struct anon_struct.conflict174 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +union anon_union.conflict144 { + struct anon_struct.conflict173 sta; + struct anon_struct.conflict174 ap; +}; + +typedef struct anon_struct.conflict213 anon_struct.conflict213, *Panon_struct.conflict213; + +struct anon_struct.conflict213 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict214 anon_struct.conflict214, *Panon_struct.conflict214; + +struct anon_struct.conflict214 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict92 anon_struct.conflict92, *Panon_struct.conflict92; + +struct anon_struct.conflict92 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict91 anon_struct.conflict91, *Panon_struct.conflict91; + +struct anon_struct.conflict91 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict180 anon_struct.conflict180, *Panon_struct.conflict180; + +struct anon_struct.conflict180 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef union anon_union.conflict132 anon_union.conflict132, *Panon_union.conflict132; + +typedef struct anon_struct.conflict161 anon_struct.conflict161, *Panon_struct.conflict161; + +typedef struct anon_struct.conflict162 anon_struct.conflict162, *Panon_struct.conflict162; + +struct anon_struct.conflict161 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +struct anon_struct.conflict162 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +union anon_union.conflict132 { + struct anon_struct.conflict161 sta; + struct anon_struct.conflict162 ap; +}; + +typedef struct anon_struct.conflict187 anon_struct.conflict187, *Panon_struct.conflict187; + +struct anon_struct.conflict187 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict188 anon_struct.conflict188, *Panon_struct.conflict188; + +struct anon_struct.conflict188 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict84 anon_struct.conflict84, *Panon_struct.conflict84; + +struct anon_struct.conflict84 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict83 anon_struct.conflict83, *Panon_struct.conflict83; + +struct anon_struct.conflict83 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef union anon_union.conflict125 anon_union.conflict125, *Panon_union.conflict125; + +typedef struct anon_struct.conflict153 anon_struct.conflict153, *Panon_struct.conflict153; + +typedef struct anon_struct.conflict154 anon_struct.conflict154, *Panon_struct.conflict154; + +struct anon_struct.conflict154 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +struct anon_struct.conflict153 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +union anon_union.conflict125 { + struct anon_struct.conflict153 sta; + struct anon_struct.conflict154 ap; +}; + +typedef struct anon_struct.conflict195 anon_struct.conflict195, *Panon_struct.conflict195; + +struct anon_struct.conflict195 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict196 anon_struct.conflict196, *Panon_struct.conflict196; + +struct anon_struct.conflict196 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict76 anon_struct.conflict76, *Panon_struct.conflict76; + +struct anon_struct.conflict76 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict75 anon_struct.conflict75, *Panon_struct.conflict75; + +struct anon_struct.conflict75 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict65 anon_struct.conflict65, *Panon_struct.conflict65; + +struct anon_struct.conflict65 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict66 anon_struct.conflict66, *Panon_struct.conflict66; + +struct anon_struct.conflict66 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict9 anon_struct.conflict9, *Panon_struct.conflict9; + +struct anon_struct.conflict9 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict8 anon_struct.conflict8, *Panon_struct.conflict8; + +struct anon_struct.conflict8 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct vif_mgmt_env_tag vif_mgmt_env_tag, *Pvif_mgmt_env_tag; + +struct vif_mgmt_env_tag { + struct co_list free_list; + struct co_list used_list; + uint8_t vif_sta_cnt; + uint8_t vif_ap_cnt; + uint8_t low_bcn_int_idx; + undefined field_0x13; +}; + +typedef struct anon_struct.conflict151 anon_struct.conflict151, *Panon_struct.conflict151; + +struct anon_struct.conflict151 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict152 anon_struct.conflict152, *Panon_struct.conflict152; + +struct anon_struct.conflict152 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict159 anon_struct.conflict159, *Panon_struct.conflict159; + +struct anon_struct.conflict159 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict160 anon_struct.conflict160, *Panon_struct.conflict160; + +struct anon_struct.conflict160 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict172 anon_struct.conflict172, *Panon_struct.conflict172; + +struct anon_struct.conflict172 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict171 anon_struct.conflict171, *Panon_struct.conflict171; + +struct anon_struct.conflict171 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict179 anon_struct.conflict179, *Panon_struct.conflict179; + +struct anon_struct.conflict179 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct tcpip_msg tcpip_msg, *Ptcpip_msg; + +typedef enum tcpip_msg_type { + TCPIP_MSG_API=0, + TCPIP_MSG_API_CALL=1, + TCPIP_MSG_CALLBACK=3, + TCPIP_MSG_CALLBACK_STATIC=4, + TCPIP_MSG_INPKT=2 +} tcpip_msg_type; + + +// WARNING! conflicting data type names: /DWARF/tcpip_priv.h/tcpip_msg/anon_union_for_msg - /DWARF/api_msg.h/api_msg/anon_union_for_msg + +struct tcpip_msg { + enum tcpip_msg_type type; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + union anon_union_for_msg msg; +}; + +typedef struct anon_struct.conflict381 anon_struct.conflict381, *Panon_struct.conflict381; + +struct anon_struct.conflict381 { + struct pbuf * p; + struct netif * netif; + err_t (* input_fn)(struct pbuf *, struct netif *); +}; + +typedef struct anon_struct.conflict382 anon_struct.conflict382, *Panon_struct.conflict382; + +struct anon_struct.conflict382 { + tcpip_callback_fn function; + void * ctx; +}; + +typedef struct anon_struct.conflict380 anon_struct.conflict380, *Panon_struct.conflict380; + +struct anon_struct.conflict380 { + err_t (* function)(struct tcpip_api_call_data *); + struct tcpip_api_call_data * arg; + sys_sem_t * sem; +}; + +typedef struct anon_struct.conflict379 anon_struct.conflict379, *Panon_struct.conflict379; + +struct anon_struct.conflict379 { + tcpip_callback_fn function; + void * msg; +}; + +typedef struct dhcp_server dhcp_server, *Pdhcp_server; + +typedef struct dhcp_client_node dhcp_client_node, *Pdhcp_client_node; + +struct dhcp_server { + struct dhcp_server * next; + struct netif * netif; + struct udp_pcb * pcb; + struct dhcp_client_node * node_list; + ip4_addr_t start; + ip4_addr_t end; + ip4_addr_t current; +}; + +struct dhcp_client_node { + struct dhcp_client_node * next; + u8_t chaddr[6]; + undefined field_0xa; + undefined field_0xb; + ip4_addr_t ipaddr; + u32_t lease_end; +}; + +typedef struct eth_hdr.conflict eth_hdr.conflict, *Peth_hdr.conflict; + +struct eth_hdr.conflict { + struct eth_addr dest; + struct eth_addr src; + u16_t type; +}; + +typedef enum ps_dpsm_state_bit_pos { + PS_DPSM_STATE_ON=0, + PS_DPSM_STATE_PAUSE=3, + PS_DPSM_STATE_PAUSING=1, + PS_DPSM_STATE_RESUMING=2, + PS_DPSM_STATE_SET_MODE_REQ=4 +} ps_dpsm_state_bit_pos; + +typedef struct ps_env_tag ps_env_tag, *Pps_env_tag; + +struct ps_env_tag { + _Bool ps_on; + undefined field_0x1; + ke_task_id_t taskid; + uint32_t prevent_sleep; + uint8_t cfm_cnt; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + struct mm_timer_tag uapsd_timer; + _Bool uapsd_tmr_on; + _Bool uapsd_on; + undefined field_0x1e; + undefined field_0x1f; + uint32_t uapsd_timeout; + uint8_t dpsm_state; + uint8_t next_mode; + undefined field_0x26; + undefined field_0x27; +}; + +typedef struct mbedtls_oid_descriptor_t mbedtls_oid_descriptor_t, *Pmbedtls_oid_descriptor_t; + +struct mbedtls_oid_descriptor_t { + char * asn1; + size_t asn1_len; + char * name; + char * description; +}; + +typedef void (* tcp_err_fn.conflict)(void *, err_t); + +typedef struct tcp_pcb.conflict tcp_pcb.conflict, *Ptcp_pcb.conflict; + +struct tcp_pcb.conflict { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict11 tcp_pcb.conflict11, *Ptcp_pcb.conflict11; + +struct tcp_pcb.conflict11 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict10 tcp_pcb.conflict10, *Ptcp_pcb.conflict10; + +struct tcp_pcb.conflict10 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict14 tcp_pcb.conflict14, *Ptcp_pcb.conflict14; + +struct tcp_pcb.conflict14 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict13 tcp_pcb.conflict13, *Ptcp_pcb.conflict13; + +struct tcp_pcb.conflict13 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict12 tcp_pcb.conflict12, *Ptcp_pcb.conflict12; + +struct tcp_pcb.conflict12 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict9 tcp_pcb.conflict9, *Ptcp_pcb.conflict9; + +struct tcp_pcb.conflict9 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict7 tcp_pcb.conflict7, *Ptcp_pcb.conflict7; + +struct tcp_pcb.conflict7 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict8 tcp_pcb.conflict8, *Ptcp_pcb.conflict8; + +struct tcp_pcb.conflict8 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict1 tcp_pcb.conflict1, *Ptcp_pcb.conflict1; + +struct tcp_pcb.conflict1 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + tcp_err_fn.conflict errf; + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict2 tcp_pcb.conflict2, *Ptcp_pcb.conflict2; + +struct tcp_pcb.conflict2 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict5 tcp_pcb.conflict5, *Ptcp_pcb.conflict5; + +struct tcp_pcb.conflict5 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict6 tcp_pcb.conflict6, *Ptcp_pcb.conflict6; + +struct tcp_pcb.conflict6 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict3 tcp_pcb.conflict3, *Ptcp_pcb.conflict3; + +struct tcp_pcb.conflict3 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict4 tcp_pcb.conflict4, *Ptcp_pcb.conflict4; + +struct tcp_pcb.conflict4 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct HeapRegion HeapRegion, *PHeapRegion; + +struct HeapRegion { + uint8_t * pucStartAddress; + size_t xSizeInBytes; +}; + +typedef struct HeapRegion HeapRegion_t; + +typedef struct anon_struct.conflict123 anon_struct.conflict123, *Panon_struct.conflict123; + +typedef struct anon_struct.conflict123 wpa_suite_ucast_t; + +typedef struct _wpa_suite_t _wpa_suite_t, *P_wpa_suite_t; + +typedef struct _wpa_suite_t wpa_suite; + +struct _wpa_suite_t { + uint8_t oui[3]; + uint8_t type; +}; + +struct anon_struct.conflict123 { + uint16_t count; + wpa_suite list[2]; +}; + +typedef struct anon_struct.conflict124 anon_struct.conflict124, *Panon_struct.conflict124; + +typedef struct anon_struct.conflict124 wpa_suite_auth_key_mgmt_t; + +struct anon_struct.conflict124 { + uint16_t count; + wpa_suite list[2]; +}; + +typedef struct _IEEEtypes_Rsn_t _IEEEtypes_Rsn_t, *P_IEEEtypes_Rsn_t; + +typedef struct _wpa_suite_t wpa_suite_mcast_t; + +struct _IEEEtypes_Rsn_t { + uint8_t element_id; + uint8_t len; + uint16_t version; + wpa_suite_mcast_t group_cipher; + wpa_suite_ucast_t pairwise_cipher; + wpa_suite_auth_key_mgmt_t auth_key_mgmt; +}; + +typedef struct anon_struct.conflict122 anon_struct.conflict122, *Panon_struct.conflict122; + +struct anon_struct.conflict122 { + uint16_t count; + wpa_suite list[2]; +}; + +typedef struct _IEEEtypes_Wpa_t _IEEEtypes_Wpa_t, *P_IEEEtypes_Wpa_t; + +typedef struct _IEEEtypes_Wpa_t IEEEtypes_Wpa_t; + +struct _IEEEtypes_Wpa_t { + uint8_t element_id; + uint8_t len; + uint8_t oui[4]; + uint16_t version; + wpa_suite_mcast_t group_cipher; + wpa_suite_ucast_t pairwise_cipher; + wpa_suite_auth_key_mgmt_t auth_key_mgmt; +}; + +typedef struct _IEEEtypes_Rsn_t IEEEtypes_Rsn_t; + +typedef struct iperf_server_udp_ctx iperf_server_udp_ctx, *Piperf_server_udp_ctx; + +struct iperf_server_udp_ctx { + int exit_flag; + uint32_t datagram_cnt; + int32_t packet_id; + uint32_t out_of_order_cnt; + uint32_t error_cnt; + uint32_t out_of_order_curr; + uint32_t receive_start; + uint32_t period_start; + uint32_t current; + undefined field_0x24; + undefined field_0x25; + undefined field_0x26; + undefined field_0x27; + uint64_t recv_total_len; + uint64_t recv_now; + float f_min; + float f_max; +}; + +typedef struct UDP_datagram UDP_datagram, *PUDP_datagram; + +struct UDP_datagram { + uint32_t id; + uint32_t tv_sec; + uint32_t tv_usec; +}; + +typedef struct server_hdr_v1 server_hdr_v1, *Pserver_hdr_v1; + +typedef struct server_hdr_v1 server_hdr; + +struct server_hdr_v1 { + int32_t flags; + int32_t total_len1; + int32_t total_len2; + int32_t stop_sec; + int32_t stop_usec; + int32_t error_cnt; + int32_t outorder_cnt; + int32_t datagrams; + int32_t jitter1; + int32_t jitter2; +}; + +typedef struct cm_ConnectionInfo cm_ConnectionInfo_t; + +typedef union anon_union.conflict76 anon_union.conflict76, *Panon_union.conflict76; + +union anon_union.conflict76 { + struct apSpecificData_t apData; +}; + +typedef union anon_union.conflict13 anon_union.conflict13, *Panon_union.conflict13; + +union anon_union.conflict13 { + struct apSpecificData_t apData; +}; + +typedef union anon_union.conflict110 anon_union.conflict110, *Panon_union.conflict110; + +union anon_union.conflict110 { + struct apSpecificData_t apData; +}; + +typedef union anon_union.conflict105 anon_union.conflict105, *Panon_union.conflict105; + +union anon_union.conflict105 { + struct apSpecificData_t apData; +}; + +typedef union anon_union.conflict101 anon_union.conflict101, *Panon_union.conflict101; + +union anon_union.conflict101 { + struct apSpecificData_t apData; +}; + +typedef union anon_union.conflict180 anon_union.conflict180, *Panon_union.conflict180; + +union anon_union.conflict180 { + struct apSpecificData_t apData; +}; + +typedef struct wifi_ap_data_rate wifi_ap_data_rate, *Pwifi_ap_data_rate; + +struct wifi_ap_data_rate { + uint8_t data_rate; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + char * val; +}; + +typedef struct rc4_key rc4_key, *Prc4_key; + +struct rc4_key { + uchar state[256]; + uchar x; + uchar y; +}; + +typedef struct netif.conflict75 netif.conflict75, *Pnetif.conflict75; + +struct netif.conflict75 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict76 netif.conflict76, *Pnetif.conflict76; + +struct netif.conflict76 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict71 netif.conflict71, *Pnetif.conflict71; + +struct netif.conflict71 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict72 netif.conflict72, *Pnetif.conflict72; + +struct netif.conflict72 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict73 netif.conflict73, *Pnetif.conflict73; + +struct netif.conflict73 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict74 netif.conflict74, *Pnetif.conflict74; + +struct netif.conflict74 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict68 netif.conflict68, *Pnetif.conflict68; + +struct netif.conflict68 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict69 netif.conflict69, *Pnetif.conflict69; + +struct netif.conflict69 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict64 netif.conflict64, *Pnetif.conflict64; + +struct netif.conflict64 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict65 netif.conflict65, *Pnetif.conflict65; + +struct netif.conflict65 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict66 netif.conflict66, *Pnetif.conflict66; + +struct netif.conflict66 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict67 netif.conflict67, *Pnetif.conflict67; + +struct netif.conflict67 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict60 netif.conflict60, *Pnetif.conflict60; + +struct netif.conflict60 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict61 netif.conflict61, *Pnetif.conflict61; + +struct netif.conflict61 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict62 netif.conflict62, *Pnetif.conflict62; + +struct netif.conflict62 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict63 netif.conflict63, *Pnetif.conflict63; + +struct netif.conflict63 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict70 netif.conflict70, *Pnetif.conflict70; + +struct netif.conflict70 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef u8_t netif_addr_idx_t; + +typedef void (* netif_status_callback_fn.conflict)(struct netif *); + +typedef struct netif.conflict18 netif.conflict18, *Pnetif.conflict18; + +struct netif.conflict18 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict10 netif.conflict10, *Pnetif.conflict10; + +struct netif.conflict10 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef enum lwip_internal_netif_client_data_index { + LWIP_NETIF_CLIENT_DATA_INDEX_DHCP=0, + LWIP_NETIF_CLIENT_DATA_INDEX_IGMP=1, + LWIP_NETIF_CLIENT_DATA_INDEX_MAX=2 +} lwip_internal_netif_client_data_index; + +typedef struct netif.conflict netif.conflict, *Pnetif.conflict; + +struct netif.conflict { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict39 netif.conflict39, *Pnetif.conflict39; + +struct netif.conflict39 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict37 netif.conflict37, *Pnetif.conflict37; + +struct netif.conflict37 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict38 netif.conflict38, *Pnetif.conflict38; + +struct netif.conflict38 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict30 netif.conflict30, *Pnetif.conflict30; + +struct netif.conflict30 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict3 netif.conflict3, *Pnetif.conflict3; + +struct netif.conflict3 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict2 netif.conflict2, *Pnetif.conflict2; + +struct netif.conflict2 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict4 netif.conflict4, *Pnetif.conflict4; + +struct netif.conflict4 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict24 netif.conflict24, *Pnetif.conflict24; + +struct netif.conflict24 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict1 netif.conflict1, *Pnetif.conflict1; + +struct netif.conflict1 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict57 netif.conflict57, *Pnetif.conflict57; + +struct netif.conflict57 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict58 netif.conflict58, *Pnetif.conflict58; + +struct netif.conflict58 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict59 netif.conflict59, *Pnetif.conflict59; + +struct netif.conflict59 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict53 netif.conflict53, *Pnetif.conflict53; + +struct netif.conflict53 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict54 netif.conflict54, *Pnetif.conflict54; + +struct netif.conflict54 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict55 netif.conflict55, *Pnetif.conflict55; + +struct netif.conflict55 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict56 netif.conflict56, *Pnetif.conflict56; + +struct netif.conflict56 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict50 netif.conflict50, *Pnetif.conflict50; + +struct netif.conflict50 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict51 netif.conflict51, *Pnetif.conflict51; + +struct netif.conflict51 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict52 netif.conflict52, *Pnetif.conflict52; + +struct netif.conflict52 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict46 netif.conflict46, *Pnetif.conflict46; + +struct netif.conflict46 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict47 netif.conflict47, *Pnetif.conflict47; + +struct netif.conflict47 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict48 netif.conflict48, *Pnetif.conflict48; + +struct netif.conflict48 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict49 netif.conflict49, *Pnetif.conflict49; + +struct netif.conflict49 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict42 netif.conflict42, *Pnetif.conflict42; + +struct netif.conflict42 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict43 netif.conflict43, *Pnetif.conflict43; + +struct netif.conflict43 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict44 netif.conflict44, *Pnetif.conflict44; + +struct netif.conflict44 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict45 netif.conflict45, *Pnetif.conflict45; + +struct netif.conflict45 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict40 netif.conflict40, *Pnetif.conflict40; + +struct netif.conflict40 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + netif_status_callback_fn.conflict status_callback; + netif_status_callback_fn.conflict link_callback; + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef struct netif.conflict41 netif.conflict41, *Pnetif.conflict41; + +struct netif.conflict41 { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef int __intptr_t; + +typedef __intptr_t intptr_t; + +typedef longlong __int64_t; + +typedef __int64_t int64_t; + +typedef struct mbedtls_pem_context mbedtls_pem_context, *Pmbedtls_pem_context; + +struct mbedtls_pem_context { + uchar * buf; + size_t buflen; + uchar * info; +}; + +typedef struct rxl_cntrl_env_tag rxl_cntrl_env_tag, *Prxl_cntrl_env_tag; + +struct rxl_cntrl_env_tag { + struct co_list ready; + struct rx_dmadesc * first; + struct rx_dmadesc * last; + struct rx_dmadesc * free; + uint32_t packet_stack_cnt; +}; + +typedef struct _gpio_ctx_desc _gpio_ctx_desc, *P_gpio_ctx_desc; + +struct _gpio_ctx_desc { + struct _gpio_ctx_desc * next; + void (* gpio_handler)(void *); + void * arg; + uint8_t gpioPin; + uint8_t intCtrlMod; + uint8_t intTrgMod; + undefined field_0xf; +}; + +typedef struct _gpio_ctx_desc gpio_ctx_t; + +typedef struct gpio_feature_config gpio_feature_config, *Pgpio_feature_config; + +struct gpio_feature_config { + int pin; + uint8_t valid; + uint8_t feature; + uint8_t active; + uint8_t mode; + uint time; +}; + +typedef struct GLB_GPIO_Cfg_Type GLB_GPIO_Cfg_Type, *PGLB_GPIO_Cfg_Type; + +struct GLB_GPIO_Cfg_Type { + uint8_t gpioPin; + uint8_t gpioFun; + uint8_t gpioMode; + uint8_t pullType; + uint8_t drive; + uint8_t smtCtrl; +}; + +typedef enum GLB_GPIO_FUNC_Type { + GPIO_FUN_ANALOG=10, + GPIO_FUN_EXT_PA=9, + GPIO_FUN_FLASH=2, + GPIO_FUN_I2C=6, + GPIO_FUN_JTAG=14, + GPIO_FUN_PWM=8, + GPIO_FUN_SDIO=1, + GPIO_FUN_SPI=4, + GPIO_FUN_SWGPIO=11, + GPIO_FUN_UART=7 +} GLB_GPIO_FUNC_Type; + +typedef enum GLB_GPIO_Type { + GLB_GPIO_PIN_0=0, + GLB_GPIO_PIN_1=1, + GLB_GPIO_PIN_10=10, + GLB_GPIO_PIN_11=11, + GLB_GPIO_PIN_12=12, + GLB_GPIO_PIN_13=13, + GLB_GPIO_PIN_14=14, + GLB_GPIO_PIN_15=15, + GLB_GPIO_PIN_16=16, + GLB_GPIO_PIN_17=17, + GLB_GPIO_PIN_18=18, + GLB_GPIO_PIN_19=19, + GLB_GPIO_PIN_2=2, + GLB_GPIO_PIN_20=20, + GLB_GPIO_PIN_21=21, + GLB_GPIO_PIN_22=22, + GLB_GPIO_PIN_3=3, + GLB_GPIO_PIN_4=4, + GLB_GPIO_PIN_5=5, + GLB_GPIO_PIN_6=6, + GLB_GPIO_PIN_7=7, + GLB_GPIO_PIN_8=8, + GLB_GPIO_PIN_9=9, + GLB_GPIO_PIN_MAX=23 +} GLB_GPIO_Type; + +typedef struct txl_buffer_list_tag txl_buffer_list_tag, *Ptxl_buffer_list_tag; + +struct txl_buffer_list_tag { + struct txl_buffer_tag * first; + struct txl_buffer_tag * last; +}; + +typedef union anon_union.conflict137 anon_union.conflict137, *Panon_union.conflict137; + +union anon_union.conflict137 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict95 anon_union.conflict95, *Panon_union.conflict95; + +union anon_union.conflict95 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict130 anon_union.conflict130, *Panon_union.conflict130; + +union anon_union.conflict130 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict7 anon_union.conflict7, *Panon_union.conflict7; + +union anon_union.conflict7 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict21 anon_union.conflict21, *Panon_union.conflict21; + +union anon_union.conflict21 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict123 anon_union.conflict123, *Panon_union.conflict123; + +union anon_union.conflict123 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef struct txl_buffer_idx_tag txl_buffer_idx_tag, *Ptxl_buffer_idx_tag; + +typedef struct txl_buffer_hw_desc_tag txl_buffer_hw_desc_tag, *Ptxl_buffer_hw_desc_tag; + +struct txl_buffer_hw_desc_tag { + struct dma_desc dma_desc; + struct tx_pbd pbd; +}; + +struct txl_buffer_idx_tag { + uint32_t used_area; + uint32_t free; + uint32_t free_size; + uint32_t last; + uint32_t next_needed; + uint32_t buf_size; + uint32_t * pool; + struct txl_buffer_hw_desc_tag * desc; + uint8_t count; + undefined field_0x21; + undefined field_0x22; + undefined field_0x23; +}; + +typedef union anon_union.conflict115 anon_union.conflict115, *Panon_union.conflict115; + +union anon_union.conflict115 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict31 anon_union.conflict31, *Panon_union.conflict31; + +union anon_union.conflict31 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict38 anon_union.conflict38, *Panon_union.conflict38; + +union anon_union.conflict38 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict45 anon_union.conflict45, *Panon_union.conflict45; + +union anon_union.conflict45 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict100 anon_union.conflict100, *Panon_union.conflict100; + +union anon_union.conflict100 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict52 anon_union.conflict52, *Panon_union.conflict52; + +union anon_union.conflict52 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict177 anon_union.conflict177, *Panon_union.conflict177; + +union anon_union.conflict177 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict59 anon_union.conflict59, *Panon_union.conflict59; + +union anon_union.conflict59 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef struct txl_buffer_env_tag txl_buffer_env_tag, *Ptxl_buffer_env_tag; + +struct txl_buffer_env_tag { + struct txl_buffer_idx_tag buf_idx[5][1]; + struct txl_buffer_list_tag list[5]; +}; + +typedef union anon_union.conflict171 anon_union.conflict171, *Panon_union.conflict171; + +union anon_union.conflict171 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict163 anon_union.conflict163, *Panon_union.conflict163; + +union anon_union.conflict163 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict66 anon_union.conflict66, *Panon_union.conflict66; + +union anon_union.conflict66 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict81 anon_union.conflict81, *Panon_union.conflict81; + +union anon_union.conflict81 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict74 anon_union.conflict74, *Panon_union.conflict74; + +union anon_union.conflict74 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict156 anon_union.conflict156, *Panon_union.conflict156; + +union anon_union.conflict156 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict149 anon_union.conflict149, *Panon_union.conflict149; + +union anon_union.conflict149 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict142 anon_union.conflict142, *Panon_union.conflict142; + +union anon_union.conflict142 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef union anon_union.conflict88 anon_union.conflict88, *Panon_union.conflict88; + +union anon_union.conflict88 { + struct tx_policy_tbl policy_tbl; + struct tx_compressed_policy_tbl comp_pol_tbl; +}; + +typedef struct oid_x520_attr_t oid_x520_attr_t, *Poid_x520_attr_t; + +struct oid_x520_attr_t { + struct mbedtls_oid_descriptor_t descriptor; + char * short_name; +}; + +typedef struct oid_x509_ext_t oid_x509_ext_t, *Poid_x509_ext_t; + +struct oid_x509_ext_t { + struct mbedtls_oid_descriptor_t descriptor; + int ext_type; +}; + +typedef struct oid_md_alg_t oid_md_alg_t, *Poid_md_alg_t; + +struct oid_md_alg_t { + struct mbedtls_oid_descriptor_t descriptor; + enum mbedtls_md_type_t md_alg; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct oid_sig_alg_t oid_sig_alg_t, *Poid_sig_alg_t; + +struct oid_sig_alg_t { + struct mbedtls_oid_descriptor_t descriptor; + enum mbedtls_md_type_t md_alg; + enum mbedtls_pk_type_t pk_alg; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct oid_cipher_alg_t oid_cipher_alg_t, *Poid_cipher_alg_t; + +struct oid_cipher_alg_t { + struct mbedtls_oid_descriptor_t descriptor; + enum mbedtls_cipher_type_t cipher_alg; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct oid_ecp_grp_t oid_ecp_grp_t, *Poid_ecp_grp_t; + +struct oid_ecp_grp_t { + struct mbedtls_oid_descriptor_t descriptor; + enum mbedtls_ecp_group_id grp_id; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct oid_pk_alg_t oid_pk_alg_t, *Poid_pk_alg_t; + +struct oid_pk_alg_t { + struct mbedtls_oid_descriptor_t descriptor; + enum mbedtls_pk_type_t pk_alg; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; +}; + +typedef enum riscv_abi_type { + ABI_ILP32=0, + ABI_ILP32D=3, + ABI_ILP32E=1, + ABI_ILP32F=2, + ABI_LP64=4, + ABI_LP64D=6, + ABI_LP64F=5 +} riscv_abi_type; + +typedef enum riscv_microarchitecture_type { + generic=0, + sifive_7=1 +} riscv_microarchitecture_type; + +typedef enum riscv_code_model { + CM_MEDANY=1, + CM_MEDLOW=0, + CM_PIC=2 +} riscv_code_model; + +typedef struct PDS_CTL2_Type PDS_CTL2_Type, *PPDS_CTL2_Type; + +struct PDS_CTL2_Type { + uint32_t forceCpuPwrOff:1; + uint32_t rsv1:1; + uint32_t forceWbPwrOff:1; + uint32_t rsv3:1; + uint32_t forceCpuIsoPwrOff:1; + uint32_t rsv5:1; + uint32_t forceWbIsoPwrOff:1; + uint32_t rsv7:1; + uint32_t forceCpuPdsRst:1; + uint32_t rsv9:1; + uint32_t forceWbPdsRst:1; + uint32_t rsv11:1; + uint32_t forceCpuMemStby:1; + uint32_t rsv13:1; + uint32_t forceWbMemStby:1; + uint32_t rsv15:1; + uint32_t forceCpuGateClk:1; + uint32_t rsv17:1; + uint32_t forceWbGateClk:1; + uint32_t rsv19_31:12; +}; + +typedef enum PDS_PLL_CLK_Type { + PDS_PLL_CLK_120M=4, + PDS_PLL_CLK_160M=3, + PDS_PLL_CLK_192M=2, + PDS_PLL_CLK_240M=1, + PDS_PLL_CLK_32M=8, + PDS_PLL_CLK_480M=0, + PDS_PLL_CLK_48M=7, + PDS_PLL_CLK_80M=6, + PDS_PLL_CLK_96M=5 +} PDS_PLL_CLK_Type; + +typedef struct PDS_DEFAULT_LV_CFG_Type PDS_DEFAULT_LV_CFG_Type, *PPDS_DEFAULT_LV_CFG_Type; + +typedef struct PDS_CTL_Type PDS_CTL_Type, *PPDS_CTL_Type; + +typedef struct PDS_CTL3_Type PDS_CTL3_Type, *PPDS_CTL3_Type; + +typedef struct PDS_CTL4_Type PDS_CTL4_Type, *PPDS_CTL4_Type; + +struct PDS_CTL3_Type { + uint32_t rsv0:1; + uint32_t forceMiscPwrOff:1; + uint32_t rsv2_3:2; + uint32_t forceMiscIsoEn:1; + uint32_t rsv5_6:2; + uint32_t forceMiscPdsRst:1; + uint32_t rsv8_9:2; + uint32_t forceMiscMemStby:1; + uint32_t rsv11_12:2; + uint32_t forceMiscGateClk:1; + uint32_t rsv14_23:10; + uint32_t CpuIsoEn:1; + uint32_t rsv25_26:2; + uint32_t WbIsoEn:1; + uint32_t rsv28_29:2; + uint32_t MiscIsoEn:1; + uint32_t rsv31:1; +}; + +struct PDS_CTL4_Type { + uint32_t cpuPwrOff:1; + uint32_t cpuRst:1; + uint32_t cpuMemStby:1; + uint32_t cpuGateClk:1; + uint32_t rsv4_11:8; + uint32_t WbPwrOff:1; + uint32_t WbRst:1; + uint32_t WbMemStby:1; + uint32_t WbGateClk:1; + uint32_t rsv16_23:8; + uint32_t MiscPwrOff:1; + uint32_t MiscRst:1; + uint32_t MiscMemStby:1; + uint32_t MiscGateClk:1; + uint32_t rsv28_31:4; +}; + +struct PDS_CTL_Type { + uint32_t pdsStart:1; + uint32_t sleepForever:1; + uint32_t xtalForceOff:1; + uint32_t saveWiFiState:1; + uint32_t dcdc18Off:1; + uint32_t bgSysOff:1; + uint32_t rsv6_7:2; + uint32_t clkOff:1; + uint32_t memStby:1; + uint32_t rsv10:1; + uint32_t isolation:1; + uint32_t waitXtalRdy:1; + uint32_t pdsPwrOff:1; + uint32_t xtalOff:1; + uint32_t socEnbForceOn:1; + uint32_t pdsRstSocEn:1; + uint32_t pdsRC32mOn:1; + uint32_t pdsLdoVselEn:1; + uint32_t rsv19_20:2; + uint32_t wfiMask:1; + uint32_t ldo11Off:1; + uint32_t rsv23:1; + uint32_t pdsLdoVol:4; + uint32_t pdsCtlRfSel:2; + uint32_t pdsCtlPllSel:2; +}; + +struct PDS_DEFAULT_LV_CFG_Type { + struct PDS_CTL_Type pdsCtl; + struct PDS_CTL2_Type pdsCtl2; + struct PDS_CTL3_Type pdsCtl3; + struct PDS_CTL4_Type pdsCtl4; +}; + +typedef struct PDS_RAM_CFG_Type PDS_RAM_CFG_Type, *PPDS_RAM_CFG_Type; + +struct PDS_RAM_CFG_Type { + uint32_t PDS_RAM_CFG_0KB_16KB_CPU_RAM_RET:1; + uint32_t PDS_RAM_CFG_16KB_32KB_CPU_RAM_RET:1; + uint32_t PDS_RAM_CFG_32KB_48KB_CPU_RAM_RET:1; + uint32_t PDS_RAM_CFG_48KB_64KB_CPU_RAM_RET:1; + uint32_t PDS_RAM_CFG_0KB_16KB_CPU_RAM_SLP:1; + uint32_t PDS_RAM_CFG_16KB_32KB_CPU_RAM_SLP:1; + uint32_t PDS_RAM_CFG_32KB_48KB_CPU_RAM_SLP:1; + uint32_t PDS_RAM_CFG_48KB_64KB_CPU_RAM_SLP:1; + uint32_t PDS_RAM_CFG_RSV:24; +}; + +typedef enum PDS_PLL_XTAL_Type { + PDS_PLL_XTAL_24M=1, + PDS_PLL_XTAL_26M=5, + PDS_PLL_XTAL_32M=2, + PDS_PLL_XTAL_38P4M=3, + PDS_PLL_XTAL_40M=4, + PDS_PLL_XTAL_NONE=0, + PDS_PLL_XTAL_RC32M=6 +} PDS_PLL_XTAL_Type; + +typedef struct x509_crt_verify_string x509_crt_verify_string, *Px509_crt_verify_string; + +struct x509_crt_verify_string { + int code; + char * string; +}; + +typedef uintptr_t insn_t; + +typedef struct bl_mtd_info_t bl_mtd_info_t, *Pbl_mtd_info_t; + +struct bl_mtd_info_t { + char name[16]; + uint offset; + uint size; + void * xip_addr; +}; + +typedef void * bl_mtd_handle_t; + +typedef struct mbedtls_ssl_config.conflict mbedtls_ssl_config.conflict, *Pmbedtls_ssl_config.conflict; + +struct mbedtls_ssl_config.conflict { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict1 mbedtls_ssl_config.conflict1, *Pmbedtls_ssl_config.conflict1; + +struct mbedtls_ssl_config.conflict1 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict2 mbedtls_ssl_config.conflict2, *Pmbedtls_ssl_config.conflict2; + +struct mbedtls_ssl_config.conflict2 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict64 mbedtls_ssl_config.conflict64, *Pmbedtls_ssl_config.conflict64; + +struct mbedtls_ssl_config.conflict64 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict63 mbedtls_ssl_config.conflict63, *Pmbedtls_ssl_config.conflict63; + +struct mbedtls_ssl_config.conflict63 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict66 mbedtls_ssl_config.conflict66, *Pmbedtls_ssl_config.conflict66; + +struct mbedtls_ssl_config.conflict66 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict65 mbedtls_ssl_config.conflict65, *Pmbedtls_ssl_config.conflict65; + +struct mbedtls_ssl_config.conflict65 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict68 mbedtls_ssl_config.conflict68, *Pmbedtls_ssl_config.conflict68; + +struct mbedtls_ssl_config.conflict68 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict67 mbedtls_ssl_config.conflict67, *Pmbedtls_ssl_config.conflict67; + +struct mbedtls_ssl_config.conflict67 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict69 mbedtls_ssl_config.conflict69, *Pmbedtls_ssl_config.conflict69; + +struct mbedtls_ssl_config.conflict69 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict71 mbedtls_ssl_config.conflict71, *Pmbedtls_ssl_config.conflict71; + +struct mbedtls_ssl_config.conflict71 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict70 mbedtls_ssl_config.conflict70, *Pmbedtls_ssl_config.conflict70; + +struct mbedtls_ssl_config.conflict70 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict73 mbedtls_ssl_config.conflict73, *Pmbedtls_ssl_config.conflict73; + +struct mbedtls_ssl_config.conflict73 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict72 mbedtls_ssl_config.conflict72, *Pmbedtls_ssl_config.conflict72; + +struct mbedtls_ssl_config.conflict72 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict74 mbedtls_ssl_config.conflict74, *Pmbedtls_ssl_config.conflict74; + +struct mbedtls_ssl_config.conflict74 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict9 mbedtls_ssl_config.conflict9, *Pmbedtls_ssl_config.conflict9; + +struct mbedtls_ssl_config.conflict9 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_context.conflict24 mbedtls_ssl_context.conflict24, *Pmbedtls_ssl_context.conflict24; + +struct mbedtls_ssl_context.conflict24 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict23 mbedtls_ssl_context.conflict23, *Pmbedtls_ssl_context.conflict23; + +struct mbedtls_ssl_context.conflict23 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict16 mbedtls_ssl_context.conflict16, *Pmbedtls_ssl_context.conflict16; + +struct mbedtls_ssl_context.conflict16 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict15 mbedtls_ssl_context.conflict15, *Pmbedtls_ssl_context.conflict15; + +struct mbedtls_ssl_context.conflict15 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_config.conflict20 mbedtls_ssl_config.conflict20, *Pmbedtls_ssl_config.conflict20; + +struct mbedtls_ssl_config.conflict20 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict28 mbedtls_ssl_config.conflict28, *Pmbedtls_ssl_config.conflict28; + +struct mbedtls_ssl_config.conflict28 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict27 mbedtls_ssl_config.conflict27, *Pmbedtls_ssl_config.conflict27; + +struct mbedtls_ssl_config.conflict27 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict29 mbedtls_ssl_config.conflict29, *Pmbedtls_ssl_config.conflict29; + +struct mbedtls_ssl_config.conflict29 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict37 mbedtls_ssl_config.conflict37, *Pmbedtls_ssl_config.conflict37; + +struct mbedtls_ssl_config.conflict37 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict36 mbedtls_ssl_config.conflict36, *Pmbedtls_ssl_config.conflict36; + +struct mbedtls_ssl_config.conflict36 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict38 mbedtls_ssl_config.conflict38, *Pmbedtls_ssl_config.conflict38; + +struct mbedtls_ssl_config.conflict38 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict46 mbedtls_ssl_config.conflict46, *Pmbedtls_ssl_config.conflict46; + +struct mbedtls_ssl_config.conflict46 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict45 mbedtls_ssl_config.conflict45, *Pmbedtls_ssl_config.conflict45; + +struct mbedtls_ssl_config.conflict45 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict47 mbedtls_ssl_config.conflict47, *Pmbedtls_ssl_config.conflict47; + +struct mbedtls_ssl_config.conflict47 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict55 mbedtls_ssl_config.conflict55, *Pmbedtls_ssl_config.conflict55; + +struct mbedtls_ssl_config.conflict55 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict54 mbedtls_ssl_config.conflict54, *Pmbedtls_ssl_config.conflict54; + +struct mbedtls_ssl_config.conflict54 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict56 mbedtls_ssl_config.conflict56, *Pmbedtls_ssl_config.conflict56; + +struct mbedtls_ssl_config.conflict56 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_context.conflict mbedtls_ssl_context.conflict, *Pmbedtls_ssl_context.conflict; + +struct mbedtls_ssl_context.conflict { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_config.conflict11 mbedtls_ssl_config.conflict11, *Pmbedtls_ssl_config.conflict11; + +struct mbedtls_ssl_config.conflict11 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict10 mbedtls_ssl_config.conflict10, *Pmbedtls_ssl_config.conflict10; + +struct mbedtls_ssl_config.conflict10 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict19 mbedtls_ssl_config.conflict19, *Pmbedtls_ssl_config.conflict19; + +struct mbedtls_ssl_config.conflict19 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_config.conflict18 mbedtls_ssl_config.conflict18, *Pmbedtls_ssl_config.conflict18; + +struct mbedtls_ssl_config.conflict18 { + int * ciphersuite_list[4]; + void (* f_dbg)(void *, int, char *, int, char *); + void * p_dbg; + int (* f_rng)(void *, uchar *, size_t); + void * p_rng; + int (* f_get_cache)(void *, struct mbedtls_ssl_session *); + int (* f_set_cache)(void *, struct mbedtls_ssl_session *); + void * p_cache; + int (* f_sni)(void *, struct mbedtls_ssl_context *, uchar *, size_t); + void * p_sni; + int (* f_vrfy)(void *, struct mbedtls_x509_crt *, int, uint32_t *); + void * p_vrfy; + int (* f_ticket_write)(void *, struct mbedtls_ssl_session *, uchar *, uchar *, size_t *, uint32_t *); + int (* f_ticket_parse)(void *, struct mbedtls_ssl_session *, uchar *, size_t); + void * p_ticket; + struct mbedtls_x509_crt_profile * cert_profile; + struct mbedtls_ssl_key_cert * key_cert; + struct mbedtls_x509_crt * ca_chain; + struct mbedtls_x509_crl * ca_crl; + int * sig_hashes; + enum mbedtls_ecp_group_id * curve_list; + char * * alpn_list; + uint32_t read_timeout; + uint32_t hs_timeout_min; + uint32_t hs_timeout_max; + uchar max_major_ver; + uchar max_minor_ver; + uchar min_major_ver; + uchar min_minor_ver; + uint endpoint:1; + uint transport:1; + uint authmode:2; + uint allow_legacy_renegotiation:2; + uint mfl_code:3; + uint session_tickets:1; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct mbedtls_ssl_context.conflict7 mbedtls_ssl_context.conflict7, *Pmbedtls_ssl_context.conflict7; + +struct mbedtls_ssl_context.conflict7 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict8 mbedtls_ssl_context.conflict8, *Pmbedtls_ssl_context.conflict8; + +struct mbedtls_ssl_context.conflict8 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict65 mbedtls_ssl_context.conflict65, *Pmbedtls_ssl_context.conflict65; + +struct mbedtls_ssl_context.conflict65 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict64 mbedtls_ssl_context.conflict64, *Pmbedtls_ssl_context.conflict64; + +struct mbedtls_ssl_context.conflict64 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict63 mbedtls_ssl_context.conflict63, *Pmbedtls_ssl_context.conflict63; + +struct mbedtls_ssl_context.conflict63 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict62 mbedtls_ssl_context.conflict62, *Pmbedtls_ssl_context.conflict62; + +struct mbedtls_ssl_context.conflict62 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict66 mbedtls_ssl_context.conflict66, *Pmbedtls_ssl_context.conflict66; + +struct mbedtls_ssl_context.conflict66 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict61 mbedtls_ssl_context.conflict61, *Pmbedtls_ssl_context.conflict61; + +struct mbedtls_ssl_context.conflict61 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict60 mbedtls_ssl_context.conflict60, *Pmbedtls_ssl_context.conflict60; + +struct mbedtls_ssl_context.conflict60 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict59 mbedtls_ssl_context.conflict59, *Pmbedtls_ssl_context.conflict59; + +struct mbedtls_ssl_context.conflict59 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict58 mbedtls_ssl_context.conflict58, *Pmbedtls_ssl_context.conflict58; + +struct mbedtls_ssl_context.conflict58 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict57 mbedtls_ssl_context.conflict57, *Pmbedtls_ssl_context.conflict57; + +struct mbedtls_ssl_context.conflict57 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict56 mbedtls_ssl_context.conflict56, *Pmbedtls_ssl_context.conflict56; + +struct mbedtls_ssl_context.conflict56 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict55 mbedtls_ssl_context.conflict55, *Pmbedtls_ssl_context.conflict55; + +struct mbedtls_ssl_context.conflict55 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict48 mbedtls_ssl_context.conflict48, *Pmbedtls_ssl_context.conflict48; + +struct mbedtls_ssl_context.conflict48 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict40 mbedtls_ssl_context.conflict40, *Pmbedtls_ssl_context.conflict40; + +struct mbedtls_ssl_context.conflict40 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict47 mbedtls_ssl_context.conflict47, *Pmbedtls_ssl_context.conflict47; + +struct mbedtls_ssl_context.conflict47 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict39 mbedtls_ssl_context.conflict39, *Pmbedtls_ssl_context.conflict39; + +struct mbedtls_ssl_context.conflict39 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict32 mbedtls_ssl_context.conflict32, *Pmbedtls_ssl_context.conflict32; + +struct mbedtls_ssl_context.conflict32 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct mbedtls_ssl_context.conflict31 mbedtls_ssl_context.conflict31, *Pmbedtls_ssl_context.conflict31; + +struct mbedtls_ssl_context.conflict31 { + struct mbedtls_ssl_config * conf; + int state; + int major_ver; + int minor_ver; + int (* f_send)(void *, uchar *, size_t); + int (* f_recv)(void *, uchar *, size_t); + int (* f_recv_timeout)(void *, uchar *, size_t, uint32_t); + void * p_bio; + struct mbedtls_ssl_session * session_in; + struct mbedtls_ssl_session * session_out; + struct mbedtls_ssl_session * session; + struct mbedtls_ssl_session * session_negotiate; + struct mbedtls_ssl_handshake_params * handshake; + struct mbedtls_ssl_transform * transform_in; + struct mbedtls_ssl_transform * transform_out; + struct mbedtls_ssl_transform * transform; + struct mbedtls_ssl_transform * transform_negotiate; + void * p_timer; + void (* f_set_timer)(void *, uint32_t, uint32_t); + int (* f_get_timer)(void *); + uchar * in_buf; + uchar * in_ctr; + uchar * in_hdr; + uchar * in_len; + uchar * in_iv; + uchar * in_msg; + uchar * in_offt; + int in_msgtype; + size_t in_msglen; + size_t in_left; + uint16_t in_epoch; + undefined field_0x7a; + undefined field_0x7b; + size_t next_record_offset; + size_t in_hslen; + int nb_zero; + int record_read; + uchar * out_buf; + uchar * out_ctr; + uchar * out_hdr; + uchar * out_len; + uchar * out_iv; + uchar * out_msg; + int out_msgtype; + size_t out_msglen; + size_t out_left; + int client_auth; + char * hostname; + char * alpn_chosen; + int secure_renegotiation; +}; + +typedef struct key_MgtMaterial_t key_MgtMaterial_t, *Pkey_MgtMaterial_t; + +typedef union anon_union_for_keyEncypt anon_union_for_keyEncypt, *Panon_union_for_keyEncypt; + +typedef struct key_Type_TKIP_t key_Type_TKIP_t, *Pkey_Type_TKIP_t; + +typedef struct key_Type_AES_t key_Type_AES_t, *Pkey_Type_AES_t; + +typedef struct key_Type_WEP_t key_Type_WEP_t, *Pkey_Type_WEP_t; + +typedef struct key_Type_WAPI_t key_Type_WAPI_t, *Pkey_Type_WAPI_t; + +typedef struct key_Type_AES_CMAC_t key_Type_AES_CMAC_t, *Pkey_Type_AES_CMAC_t; + +struct key_Type_WEP_t { + UINT8 keyIndex; + UINT8 isDefaultTx; + UINT8 key[13]; +}; + +struct key_Type_WAPI_t { + UINT8 keyIndex; + UINT8 isDefKey; + UINT8 key[16]; + UINT8 mickey[16]; + UINT8 rxPN[16]; +}; + +struct key_Type_TKIP_t { + UINT8 key[16]; + UINT8 txMicKey[8]; + UINT8 rxMicKey[8]; +}; + +struct key_Type_AES_CMAC_t { + UINT8 ipn[6]; + UINT8 reserved[2]; + UINT8 key[16]; +}; + +struct key_Type_AES_t { + UINT8 key[16]; +}; + +union anon_union_for_keyEncypt { + struct key_Type_TKIP_t TKIP; + struct key_Type_AES_t AES1; + struct key_Type_WEP_t WEP; + struct key_Type_WAPI_t WAPI; + struct key_Type_AES_CMAC_t iGTK; +}; + +struct key_MgtMaterial_t { + UINT16 keyType; + UINT16 keyInfo; + UINT16 keyLen; + union anon_union_for_keyEncypt keyEncypt; +}; + +typedef union anon_union.conflict11 anon_union.conflict11, *Panon_union.conflict11; + +union anon_union.conflict11 { + struct key_Type_TKIP_t TKIP; + struct key_Type_AES_t AES1; + struct key_Type_WEP_t WEP; + struct key_Type_WAPI_t WAPI; + struct key_Type_AES_CMAC_t iGTK; +}; + +typedef uint hashval_t; + +typedef struct notifier_block notifier_block, *Pnotifier_block; + +struct notifier_block { + int (* cb)(struct notifier_block *, int, void *); + struct notifier_block * next; + int priority; +}; + +typedef struct rd_env_tag rd_env_tag, *Prd_env_tag; + +struct rd_env_tag { + struct co_list event_free_list; +}; + +typedef enum GLB_DIG_CLK_Type { + GLB_DIG_CLK_PLL_32M=0, + GLB_DIG_CLK_XCLK=1 +} GLB_DIG_CLK_Type; + +typedef enum BMX_BUS_ERR_Type { + BMX_BUS_ERR_ADDR_DECODE=1, + BMX_BUS_ERR_TRUSTZONE_DECODE=0 +} BMX_BUS_ERR_Type; + +typedef enum GLB_SPI_PAD_ACT_AS_Type { + GLB_SPI_PAD_ACT_AS_MASTER=1, + GLB_SPI_PAD_ACT_AS_SLAVE=0 +} GLB_SPI_PAD_ACT_AS_Type; + +typedef enum GLB_EM_Type { + GLB_EM_0KB=0, + GLB_EM_16KB=15, + GLB_EM_8KB=3 +} GLB_EM_Type; + +typedef enum BMX_ERR_INT_Type { + BMX_ERR_INT_ALL=1, + BMX_ERR_INT_ERR=0 +} BMX_ERR_INT_Type; + +typedef struct BMX_Cfg_Type BMX_Cfg_Type, *PBMX_Cfg_Type; + +typedef enum BMX_ARB_Type { + BMX_ARB_FIX=0, + BMX_ARB_RANDOM=2, + BMX_ARB_ROUND_ROBIN=1 +} BMX_ARB_Type; + +struct BMX_Cfg_Type { + uint8_t timeoutEn; + enum BL_Fun_Type errEn; + enum BMX_ARB_Type arbMod; +}; + +typedef enum GLB_PLL_XTAL_Type { + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6 +} GLB_PLL_XTAL_Type; + +typedef enum GLB_SYS_CLK_Type { + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1 +} GLB_SYS_CLK_Type; + +typedef enum GLB_BT_BANDWIDTH_Type { + GLB_BT_BANDWIDTH_1M=0, + GLB_BT_BANDWIDTH_2M=1 +} GLB_BT_BANDWIDTH_Type; + +typedef enum GLB_GPIO_INT_TRIG_Type { + GLB_GPIO_INT_TRIG_NEG_LEVEL=2, + GLB_GPIO_INT_TRIG_NEG_PULSE=0, + GLB_GPIO_INT_TRIG_POS_LEVEL=3, + GLB_GPIO_INT_TRIG_POS_PULSE=1 +} GLB_GPIO_INT_TRIG_Type; + +typedef enum GLB_DMA_CLK_ID_Type { + GLB_DMA_CLK_DMA0_CH0=0, + GLB_DMA_CLK_DMA0_CH1=1, + GLB_DMA_CLK_DMA0_CH2=2, + GLB_DMA_CLK_DMA0_CH3=3 +} GLB_DMA_CLK_ID_Type; + +typedef enum GLB_UART_SIG_FUN_Type { + GLB_UART_SIG_FUN_UART0_CTS=1, + GLB_UART_SIG_FUN_UART0_RTS=0, + GLB_UART_SIG_FUN_UART0_RXD=3, + GLB_UART_SIG_FUN_UART0_TXD=2, + GLB_UART_SIG_FUN_UART1_CTS=5, + GLB_UART_SIG_FUN_UART1_RTS=4, + GLB_UART_SIG_FUN_UART1_RXD=7, + GLB_UART_SIG_FUN_UART1_TXD=6 +} GLB_UART_SIG_FUN_Type; + +typedef enum GLB_PLL_CLK_Type { + GLB_PLL_CLK_120M=4, + GLB_PLL_CLK_160M=3, + GLB_PLL_CLK_192M=2, + GLB_PLL_CLK_240M=1, + GLB_PLL_CLK_32M=8, + GLB_PLL_CLK_480M=0, + GLB_PLL_CLK_48M=7, + GLB_PLL_CLK_80M=6, + GLB_PLL_CLK_96M=5 +} GLB_PLL_CLK_Type; + +typedef enum GLB_ROOT_CLK_Type { + GLB_ROOT_CLK_PLL=2, + GLB_ROOT_CLK_RC32M=0, + GLB_ROOT_CLK_XTAL=1 +} GLB_ROOT_CLK_Type; + +typedef enum GLB_SFLASH_CLK_Type { + GLB_SFLASH_CLK_120M=0, + GLB_SFLASH_CLK_48M=2, + GLB_SFLASH_CLK_80M=3, + GLB_SFLASH_CLK_96M=5, + GLB_SFLASH_CLK_BCLK=4, + GLB_SFLASH_CLK_XTAL=1 +} GLB_SFLASH_CLK_Type; + +typedef enum BMX_TO_INT_Type { + BMX_TO_INT_ALL=1, + BMX_TO_INT_TIMEOUT=0 +} BMX_TO_INT_Type; + +typedef enum GLB_DAC_CLK_Type { + GLB_DAC_CLK_32M=0, + GLB_DAC_CLK_XCLK=1 +} GLB_DAC_CLK_Type; + +typedef enum GLB_IR_CLK_SRC_Type { + GLB_IR_CLK_SRC_XCLK=0 +} GLB_IR_CLK_SRC_Type; + +typedef enum GLB_ADC_CLK_Type { + GLB_ADC_CLK_96M=0, + GLB_ADC_CLK_XCLK=1 +} GLB_ADC_CLK_Type; + +typedef enum GLB_GPIO_INT_CONTROL_Type { + GLB_GPIO_INT_CONTROL_ASYNC=1, + GLB_GPIO_INT_CONTROL_SYNC=0 +} GLB_GPIO_INT_CONTROL_Type; + +typedef enum GLB_MTIMER_CLK_Type { + GLB_MTIMER_CLK_32K=1, + GLB_MTIMER_CLK_BCLK=0 +} GLB_MTIMER_CLK_Type; + +typedef enum GLB_GPIO_REAL_MODE_Type { + GLB_GPIO_REAL_MODE_CCI=15, + GLB_GPIO_REAL_MODE_JTAG=14, + GLB_GPIO_REAL_MODE_REG=0, + GLB_GPIO_REAL_MODE_RF=12, + GLB_GPIO_REAL_MODE_SDIO=1 +} GLB_GPIO_REAL_MODE_Type; + +typedef enum GLB_PKA_CLK_Type { + GLB_PKA_CLK_HCLK=0, + GLB_PKA_CLK_PLL120M=1 +} GLB_PKA_CLK_Type; + +typedef enum GLB_UART_SIG_Type { + GLB_UART_SIG_0=0, + GLB_UART_SIG_1=1, + GLB_UART_SIG_2=2, + GLB_UART_SIG_3=3, + GLB_UART_SIG_4=4, + GLB_UART_SIG_5=5, + GLB_UART_SIG_6=6, + GLB_UART_SIG_7=7 +} GLB_UART_SIG_Type; + +typedef int32_t mbedtls_mpi_sint; + +typedef uint64_t mbedtls_t_udbl; + +typedef struct phy_env_tag phy_env_tag, *Pphy_env_tag; + +typedef struct phy_bl602_cfg_tag phy_bl602_cfg_tag, *Pphy_bl602_cfg_tag; + +struct phy_bl602_cfg_tag { + uint32_t reserved; +}; + +struct phy_env_tag { + struct phy_bl602_cfg_tag cfg; + uint16_t chnl_prim20_freq; + uint16_t chnl_center1_freq; + uint16_t chnl_center2_freq; + uint8_t band; + uint8_t chnl_type; +}; + +typedef struct lwip_cyclic_timer.conflict59 lwip_cyclic_timer.conflict59, *Plwip_cyclic_timer.conflict59; + +struct lwip_cyclic_timer.conflict59 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer lwip_cyclic_timer, *Plwip_cyclic_timer; + +typedef void (* lwip_cyclic_timer_handler)(void); + +struct lwip_cyclic_timer { + u32_t interval_ms; + lwip_cyclic_timer_handler handler; +}; + +typedef struct lwip_cyclic_timer.conflict lwip_cyclic_timer.conflict, *Plwip_cyclic_timer.conflict; + +struct lwip_cyclic_timer.conflict { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict2 lwip_cyclic_timer.conflict2, *Plwip_cyclic_timer.conflict2; + +struct lwip_cyclic_timer.conflict2 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict18 lwip_cyclic_timer.conflict18, *Plwip_cyclic_timer.conflict18; + +struct lwip_cyclic_timer.conflict18 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict31 lwip_cyclic_timer.conflict31, *Plwip_cyclic_timer.conflict31; + +struct lwip_cyclic_timer.conflict31 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict48 lwip_cyclic_timer.conflict48, *Plwip_cyclic_timer.conflict48; + +struct lwip_cyclic_timer.conflict48 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict1 lwip_cyclic_timer.conflict1, *Plwip_cyclic_timer.conflict1; + +struct lwip_cyclic_timer.conflict1 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict9 lwip_cyclic_timer.conflict9, *Plwip_cyclic_timer.conflict9; + +struct lwip_cyclic_timer.conflict9 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict8 lwip_cyclic_timer.conflict8, *Plwip_cyclic_timer.conflict8; + +struct lwip_cyclic_timer.conflict8 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict7 lwip_cyclic_timer.conflict7, *Plwip_cyclic_timer.conflict7; + +struct lwip_cyclic_timer.conflict7 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict6 lwip_cyclic_timer.conflict6, *Plwip_cyclic_timer.conflict6; + +struct lwip_cyclic_timer.conflict6 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict5 lwip_cyclic_timer.conflict5, *Plwip_cyclic_timer.conflict5; + +struct lwip_cyclic_timer.conflict5 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict4 lwip_cyclic_timer.conflict4, *Plwip_cyclic_timer.conflict4; + +struct lwip_cyclic_timer.conflict4 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict43 lwip_cyclic_timer.conflict43, *Plwip_cyclic_timer.conflict43; + +struct lwip_cyclic_timer.conflict43 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict60 lwip_cyclic_timer.conflict60, *Plwip_cyclic_timer.conflict60; + +struct lwip_cyclic_timer.conflict60 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict23 lwip_cyclic_timer.conflict23, *Plwip_cyclic_timer.conflict23; + +struct lwip_cyclic_timer.conflict23 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict55 lwip_cyclic_timer.conflict55, *Plwip_cyclic_timer.conflict55; + +struct lwip_cyclic_timer.conflict55 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict38 lwip_cyclic_timer.conflict38, *Plwip_cyclic_timer.conflict38; + +struct lwip_cyclic_timer.conflict38 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict44 lwip_cyclic_timer.conflict44, *Plwip_cyclic_timer.conflict44; + +struct lwip_cyclic_timer.conflict44 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict11 lwip_cyclic_timer.conflict11, *Plwip_cyclic_timer.conflict11; + +struct lwip_cyclic_timer.conflict11 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict22 lwip_cyclic_timer.conflict22, *Plwip_cyclic_timer.conflict22; + +struct lwip_cyclic_timer.conflict22 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict27 lwip_cyclic_timer.conflict27, *Plwip_cyclic_timer.conflict27; + +struct lwip_cyclic_timer.conflict27 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict51 lwip_cyclic_timer.conflict51, *Plwip_cyclic_timer.conflict51; + +struct lwip_cyclic_timer.conflict51 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct sys_timeo sys_timeo, *Psys_timeo; + +struct sys_timeo { + struct sys_timeo * next; + u32_t time; + void (* h)(void *); + void * arg; +}; + +typedef struct lwip_cyclic_timer.conflict17 lwip_cyclic_timer.conflict17, *Plwip_cyclic_timer.conflict17; + +struct lwip_cyclic_timer.conflict17 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict39 lwip_cyclic_timer.conflict39, *Plwip_cyclic_timer.conflict39; + +struct lwip_cyclic_timer.conflict39 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict15 lwip_cyclic_timer.conflict15, *Plwip_cyclic_timer.conflict15; + +struct lwip_cyclic_timer.conflict15 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict16 lwip_cyclic_timer.conflict16, *Plwip_cyclic_timer.conflict16; + +struct lwip_cyclic_timer.conflict16 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict19 lwip_cyclic_timer.conflict19, *Plwip_cyclic_timer.conflict19; + +struct lwip_cyclic_timer.conflict19 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict10 lwip_cyclic_timer.conflict10, *Plwip_cyclic_timer.conflict10; + +struct lwip_cyclic_timer.conflict10 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict13 lwip_cyclic_timer.conflict13, *Plwip_cyclic_timer.conflict13; + +struct lwip_cyclic_timer.conflict13 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict14 lwip_cyclic_timer.conflict14, *Plwip_cyclic_timer.conflict14; + +struct lwip_cyclic_timer.conflict14 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict12 lwip_cyclic_timer.conflict12, *Plwip_cyclic_timer.conflict12; + +struct lwip_cyclic_timer.conflict12 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict40 lwip_cyclic_timer.conflict40, *Plwip_cyclic_timer.conflict40; + +struct lwip_cyclic_timer.conflict40 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict56 lwip_cyclic_timer.conflict56, *Plwip_cyclic_timer.conflict56; + +struct lwip_cyclic_timer.conflict56 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict28 lwip_cyclic_timer.conflict28, *Plwip_cyclic_timer.conflict28; + +struct lwip_cyclic_timer.conflict28 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict29 lwip_cyclic_timer.conflict29, *Plwip_cyclic_timer.conflict29; + +struct lwip_cyclic_timer.conflict29 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict26 lwip_cyclic_timer.conflict26, *Plwip_cyclic_timer.conflict26; + +struct lwip_cyclic_timer.conflict26 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict20 lwip_cyclic_timer.conflict20, *Plwip_cyclic_timer.conflict20; + +struct lwip_cyclic_timer.conflict20 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict21 lwip_cyclic_timer.conflict21, *Plwip_cyclic_timer.conflict21; + +struct lwip_cyclic_timer.conflict21 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict24 lwip_cyclic_timer.conflict24, *Plwip_cyclic_timer.conflict24; + +struct lwip_cyclic_timer.conflict24 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict25 lwip_cyclic_timer.conflict25, *Plwip_cyclic_timer.conflict25; + +struct lwip_cyclic_timer.conflict25 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict34 lwip_cyclic_timer.conflict34, *Plwip_cyclic_timer.conflict34; + +struct lwip_cyclic_timer.conflict34 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict37 lwip_cyclic_timer.conflict37, *Plwip_cyclic_timer.conflict37; + +struct lwip_cyclic_timer.conflict37 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict32 lwip_cyclic_timer.conflict32, *Plwip_cyclic_timer.conflict32; + +struct lwip_cyclic_timer.conflict32 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict30 lwip_cyclic_timer.conflict30, *Plwip_cyclic_timer.conflict30; + +struct lwip_cyclic_timer.conflict30 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict35 lwip_cyclic_timer.conflict35, *Plwip_cyclic_timer.conflict35; + +struct lwip_cyclic_timer.conflict35 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict36 lwip_cyclic_timer.conflict36, *Plwip_cyclic_timer.conflict36; + +struct lwip_cyclic_timer.conflict36 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict33 lwip_cyclic_timer.conflict33, *Plwip_cyclic_timer.conflict33; + +struct lwip_cyclic_timer.conflict33 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict49 lwip_cyclic_timer.conflict49, *Plwip_cyclic_timer.conflict49; + +struct lwip_cyclic_timer.conflict49 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict42 lwip_cyclic_timer.conflict42, *Plwip_cyclic_timer.conflict42; + +struct lwip_cyclic_timer.conflict42 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict41 lwip_cyclic_timer.conflict41, *Plwip_cyclic_timer.conflict41; + +struct lwip_cyclic_timer.conflict41 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict46 lwip_cyclic_timer.conflict46, *Plwip_cyclic_timer.conflict46; + +struct lwip_cyclic_timer.conflict46 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict47 lwip_cyclic_timer.conflict47, *Plwip_cyclic_timer.conflict47; + +struct lwip_cyclic_timer.conflict47 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict45 lwip_cyclic_timer.conflict45, *Plwip_cyclic_timer.conflict45; + +struct lwip_cyclic_timer.conflict45 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict53 lwip_cyclic_timer.conflict53, *Plwip_cyclic_timer.conflict53; + +struct lwip_cyclic_timer.conflict53 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict54 lwip_cyclic_timer.conflict54, *Plwip_cyclic_timer.conflict54; + +struct lwip_cyclic_timer.conflict54 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict52 lwip_cyclic_timer.conflict52, *Plwip_cyclic_timer.conflict52; + +struct lwip_cyclic_timer.conflict52 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict57 lwip_cyclic_timer.conflict57, *Plwip_cyclic_timer.conflict57; + +struct lwip_cyclic_timer.conflict57 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict58 lwip_cyclic_timer.conflict58, *Plwip_cyclic_timer.conflict58; + +struct lwip_cyclic_timer.conflict58 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict50 lwip_cyclic_timer.conflict50, *Plwip_cyclic_timer.conflict50; + +struct lwip_cyclic_timer.conflict50 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef enum raw_input_state { + RAW_INPUT_DELIVERED=2, + RAW_INPUT_EATEN=1, + RAW_INPUT_NONE=0 +} raw_input_state; + +typedef enum raw_input_state raw_input_state_t; + +typedef enum memp_t { + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1 +} memp_t; + +typedef struct bl_mtd_handle_priv bl_mtd_handle_priv, *Pbl_mtd_handle_priv; + +struct bl_mtd_handle_priv { + char name[16]; + int id; + uint offset; + uint size; + void * xip_addr; +}; + +typedef struct bl_mtd_handle_priv * bl_mtd_handle_priv_t; + +typedef enum LOG_BUF_OUT_DATA_TYPE { + LOG_BUF_OUT_DATA_TYPE_HEX=0, + LOG_BUF_OUT_DATA_TYPE_INT8=1, + LOG_BUF_OUT_DATA_TYPE_UNT8=2 +} LOG_BUF_OUT_DATA_TYPE; + +typedef enum LOG_BUF_OUT_DATA_TYPE LOG_BUF_OUT_DATA_TYPE_T; + +typedef int __gcc_CMPtype; + + +// WARNING! conflicting data type names: /DWARF/err.h/anon_enum_8 - /DWARF/debug.c/vsnprintf/anon_enum_8 + +typedef uint __uintptr_t; + +typedef uchar __uint8_t; + +typedef char __int8_t; + +typedef long __int32_t; + +typedef struct bl_env_tag bl_env_tag, *Pbl_env_tag; + +struct bl_env_tag { + uint8_t prev_hw_state; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + int hw_in_doze; +}; + +typedef struct t_hdr t_hdr, *Pt_hdr; + +struct t_hdr { + struct t_hdr * next; + u16_t ping_seq; + undefined field_0x6; + undefined field_0x7; + u32_t send_time; +}; + +typedef struct ping_var ping_var, *Pping_var; + +struct ping_var { + u32_t total_count; + u32_t requests_count; + u16_t interval; + u16_t data_size; + u16_t seq_num; + u16_t id; + u16_t timeout; + u8_t node_num; + undefined field_0x13; + ip_addr_t dest; + utils_memp_pool_t * pool; + struct raw_pcb * pcb; + struct utils_list req_list; +}; + +typedef struct SubscriptionRecord_t SubscriptionRecord_t, *PSubscriptionRecord_t; + +struct SubscriptionRecord_t { + char Topic[80]; + uint8_t count; + _Bool isFree; + _Bool isSticky; +}; + +typedef struct JsonTokenTable_t JsonTokenTable_t, *PJsonTokenTable_t; + +struct JsonTokenTable_t { + char * pKey; + void * pStruct; + void (* callback)(char *, uint32_t, jsonStruct_t *); + _Bool isFree; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; +}; + +typedef struct ToBeReceivedAckRecord_t ToBeReceivedAckRecord_t, *PToBeReceivedAckRecord_t; + +struct ToBeReceivedAckRecord_t { + char clientTokenID[90]; + char thingName[20]; + enum ShadowActions_t action; + undefined field_0x6f; + void (* callback)(char *, enum ShadowActions_t, enum Shadow_Ack_Status_t, char *, void *); + void * pCallbackContext; + _Bool isFree; + undefined field_0x79; + undefined field_0x7a; + undefined field_0x7b; + struct Timer timer; +}; + +typedef enum ShadowAckTopicTypes_t { + SHADOW_ACCEPTED=0, + SHADOW_ACTION=2, + SHADOW_REJECTED=1 +} ShadowAckTopicTypes_t; + + +// WARNING! conflicting data type names: /stddef.h/size_t - /DWARF/stddef.h/size_t + +typedef struct __locale_data __locale_data, *P__locale_data; + +struct __locale_data { +}; + +typedef struct __locale_struct __locale_struct, *P__locale_struct; + +struct __locale_struct { + struct __locale_data * __locales[13]; + ushort * __ctype_b; + int * __ctype_tolower; + int * __ctype_toupper; + char * __names[13]; +}; + + +// WARNING! conflicting data type names: /xlocale.h/__locale_t - /DWARF/_UNCATEGORIZED_/__locale_t + +typedef struct astruct astruct, *Pastruct; + +struct astruct { +}; + +typedef struct astruct_1 astruct_1, *Pastruct_1; + +struct astruct_1 { +}; + +typedef enum Elf_ProgramHeaderType { + PT_DYNAMIC=2, + PT_GNU_EH_FRAME=1685382480, + PT_GNU_RELRO=1685382482, + PT_GNU_STACK=1685382481, + PT_INTERP=3, + PT_LOAD=1, + PT_NOTE=4, + PT_NULL=0, + PT_PHDR=6, + PT_SHLIB=5, + PT_TLS=7 +} Elf_ProgramHeaderType; + +typedef struct Elf32_Shdr Elf32_Shdr, *PElf32_Shdr; + +typedef enum Elf_SectionHeaderType { + SHT_CHECKSUM=1879048184, + SHT_DYNAMIC=6, + SHT_DYNSYM=11, + SHT_FINI_ARRAY=15, + SHT_GNU_ATTRIBUTES=1879048181, + SHT_GNU_HASH=1879048182, + SHT_GNU_LIBLIST=1879048183, + SHT_GNU_verdef=1879048189, + SHT_GNU_verneed=1879048190, + SHT_GNU_versym=1879048191, + SHT_GROUP=17, + SHT_HASH=5, + SHT_INIT_ARRAY=14, + SHT_NOBITS=8, + SHT_NOTE=7, + SHT_NULL=0, + SHT_PREINIT_ARRAY=16, + SHT_PROGBITS=1, + SHT_REL=9, + SHT_RELA=4, + SHT_SHLIB=10, + SHT_STRTAB=3, + SHT_SUNW_COMDAT=1879048187, + SHT_SUNW_move=1879048186, + SHT_SUNW_syminfo=1879048188, + SHT_SYMTAB=2, + SHT_SYMTAB_SHNDX=18 +} Elf_SectionHeaderType; + +struct Elf32_Shdr { + dword sh_name; + enum Elf_SectionHeaderType sh_type; + dword sh_flags; + dword sh_addr; + dword sh_offset; + dword sh_size; + dword sh_link; + dword sh_info; + dword sh_addralign; + dword sh_entsize; +}; + +typedef struct Elf32_Sym Elf32_Sym, *PElf32_Sym; + +struct Elf32_Sym { + dword st_name; + dword st_value; + dword st_size; + byte st_info; + byte st_other; + word st_shndx; +}; + +typedef struct Elf32_Phdr Elf32_Phdr, *PElf32_Phdr; + +struct Elf32_Phdr { + enum Elf_ProgramHeaderType p_type; + dword p_offset; + dword p_vaddr; + dword p_paddr; + dword p_filesz; + dword p_memsz; + dword p_flags; + dword p_align; +}; + +typedef struct Elf32_Ehdr Elf32_Ehdr, *PElf32_Ehdr; + +struct Elf32_Ehdr { + byte e_ident_magic_num; + char e_ident_magic_str[3]; + byte e_ident_class; + byte e_ident_data; + byte e_ident_version; + byte e_ident_pad[9]; + word e_type; + word e_machine; + dword e_version; + dword e_entry; + dword e_phoff; + dword e_shoff; + dword e_flags; + word e_ehsize; + word e_phentsize; + word e_phnum; + word e_shentsize; + word e_shnum; + word e_shstrndx; +}; + + + + +void bl602_start(void); +err_t cb_httpc_headers_done_fn(httpc_state_t *connection,void *arg,pbuf *hdr,u16_t hdr_len,u32_t content_len); +void cb_httpc_result(void *arg,httpc_result_t httpc_result,u32_t rx_content_len,u32_t srv_res,err_t err); +err_t cb_altcp_recv_fn(void *arg,altcp_pcb *conn,pbuf *p,err_t err); +void cmd_stack_wifi(char *buf,int len,int argc,char **argv); +void cmd_exception_illegal_ins(char *buf,int len,int argc,char **argv); +void cmd_exception_store(char *buf,int len,int argc,char **argv); +void cmd_exception_l_illegal(char *buf,int len,int argc,char **argv); +void cmd_exception_load(char *buf,int len,int argc,char **argv); +void cmd_dma(void); +undefined4 cmd_cks(void); +int cmd_aes(void); +int cmd_trng(void); +int cmd_sha(void); +void cmd_wifi(void); +int cmd_pka(void); +void cmd_aws(char *buf,int len,int argc,char **argv); +void proc_hellow_entry(void *pvParameters); +uchar char_to_hex(char asccode); +void cmd_httpc_test(char *buf,int len,int argc,char **argv); +int get_dts_addr(char *name); +int client_demo(void); +int http_test_cmd(void); +void aos_loop_proc(void *pvParameters); +void vApplicationStackOverflowHook(TaskHandle_t xTask,char *pcTaskName); +void vApplicationMallocFailedHook(void); +void vApplicationIdleHook(void); +int check_dts_config(char *ssid,char *password); +void _connect_wifi(undefined4 param_1); +void event_cb_wifi_event(input_event_t *event,void *private_data); +void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,StackType_t **ppxIdleTaskStackBuffer,uint32_t *pulIdleTaskStackSize); +void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer,StackType_t **ppxTimerTaskStackBuffer,uint32_t *pulTimerTaskStackSize); +void vAssertCalled(void); +void bfl_main(void); +void ShadowUpdateStatusCallback(char *pThingName,ShadowActions_t action,Shadow_Ack_Status_t status,char *pReceivedJsonDocument,void *pContextData); +void windowActuate_Callback(char *pJsonString,uint32_t JsonStringDataLen,jsonStruct_t *pContext); +void cmd_coex_dump(char *buf,int len,int argc,char **argv); +int codex_debug_cli_init(void); +void mm_rx_filter_set(void); +int element_notify_status_enabled(cfg_element_entry *entry,void *arg1,void *arg2,CFG_ELEMENT_TYPE_OPS ops); +void blmac_ap_setf(uint8_t ap); +uchar ascii_to_hex(char asccode); +undefined4 element_notify_time_last_received_set(void); +void blmac_encr_cntrl_pack(uint8_t newread,uint8_t newwrite,uint16_t keyindexram,uint8_t ctyperam,uint8_t vlanidram,uint8_t sppram,uint8_t usedefkeyram,uint8_t clenram); +undefined4 element_notify_keepalive_received(void); +uint32_t hal_machw_rx_duration(rx_hd *rhd,uint16_t len); +void mm_env_max_ampdu_duration_set(void); +void mm_env_init(void); +void mm_init(void); +void mm_active(void); +void mm_reset(void); +uint8_t mm_sec_machwaddr_wr(uint8_t sta_idx,uint8_t inst_nbr); +void mm_sec_keydump(void); +uint8_t mm_sec_machwkey_wr(mm_key_add_req *param); +void mm_sec_machwkey_del(uint8_t hw_key_idx); +void mm_sec_machwaddr_del(uint8_t sta_idx); +void mm_hw_idle_evt(int dummy); +void mm_hw_info_set(mac_addr *mac_addr); +void mm_hw_ap_info_set(void); +void mm_hw_ap_info_reset(void); +void mm_back_to_host_idle(void); +uint8_t mm_sta_add(mm_sta_add_req *param,uint8_t *sta_idx,uint8_t *hw_sta_idx); +void mm_sta_del(uint8_t sta_idx); +void mm_cfg_element_keepalive_timestamp_update(void); +void mm_send_connection_loss_ind(vif_info_tag *p_vif_entry); +void mm_ap_probe_cfm(void *env,uint32_t status); +void mm_check_rssi(vif_info_tag *vif_entry,int8_t rssi); +void mm_send_csa_traffic_ind(uint8_t vif_index,_Bool enable); +uint mm_check_beacon(rx_hd *param_1,vif_info_tag *param_2,int param_3,char **param_4); +void mm_sta_tbtt(void *env); +uint16_t mm_get_rsn_wpa_ie(uint8_t sta_id,uint8_t *wpa_ie); +void mm_tim_update_proceed(ushort *param_1); +void mm_bcn_init(void); +void mm_bcn_init_vif(vif_info_tag *vif_entry); +void mm_tim_update(mm_tim_update_req *param); +void mm_bcn_transmit(void); +void mm_bcn_updated(void *env,int dma_queue); +void mm_bcn_update(mm_bcn_change_req *param); +void mm_bcn_transmitted(vif_info_tag *param_1); +void mm_bcn_change(mm_bcn_change_req *param); +_Bool cmp_abs_time(co_list_hdr *timerA,co_list_hdr *timerB); +void mm_timer_init(void); +void mm_timer_set(mm_timer_tag *timer,uint32_t value); +void mm_timer_clear(mm_timer_tag *timer); +void mm_timer_schedule(int dummy); +void ps_uapsd_timer_handle(void *env); +void blmac_pwr_mgt_setf(uint8_t pwrmgt); +void ps_dpsm_update(_Bool pause); +uint8_t ps_send_pspoll(vif_info_tag *vif_entry); +void ps_init(void); +void ps_set_mode(uint8_t mode,ke_task_id_t taskid); +void ps_enable_cfm(void *env,uint32_t status); +void ps_disable_cfm(void *env,uint32_t status); +uint8_t ps_polling_frame(vif_info_tag *vif_entry); +void ps_check_beacon(int param_1,vif_info_tag *param_2); +void ps_check_frame(uint8_t *frame,uint32_t statinfo,vif_info_tag *vif_entry); +void ps_check_tx_frame(uint8_t staid,uint8_t tid); +void ps_uapsd_set(vif_info_tag *vif_entry,uint8_t hw_queue,_Bool uapsd); +void ps_traffic_status_update(uint8_t vif_index,uint8_t new_status); +void mm_ps_change_ind(uint8_t sta_idx,uint8_t ps_state); +void rxl_mpdu_transfer(rx_swdesc *swdesc); +void rxl_init(void); +void rxl_cntrl_dump(void); +void rxl_timer_int_handler(void); +void rxl_timeout_int_handler(void); +void rxl_dma_int_handler(void); +void rxl_dma_evt(int dummy); +void rxl_frame_release(rx_swdesc *swdesc); +void rxl_mpdu_free(rx_swdesc *swdesc); +void bl60x_firmwre_mpdu_free(void *swdesc_ptr); +void rxl_reset(void); +void rxl_hwdesc_dump(void); +void rxl_hwdesc_init(int init); +void rxl_hd_append(rx_dmadesc *desc); +void rxl_pd_append(rx_pbd *first,rx_pbd *last,rx_pbd *spare); +void scan_search_ds(void); +void scan_init(void); +void scan_set_channel_request(void); +void dma_cb(void *env,int dma_queue); +void scan_ie_download(scan_start_req *param); +void scan_probe_req_tx(void); +void scan_send_cancel_cfm(uint8_t status,ke_task_id_t dest_id); +void sta_mgmt_entry_init(sta_info_tag *sta_entry); +void sta_mgmt_init(void); +uint8_t sta_mgmt_register(mm_sta_add_req *param,uint8_t *sta_idx); +void sta_mgmt_unregister(uint8_t sta_idx); +void sta_mgmt_add_key(mm_key_add_req *param,uint8_t hw_key_idx); +void sta_mgmt_del_key(sta_info_tag *sta); +int sta_mgmt_send_postponed_frame(vif_info_tag *p_vif_entry,sta_info_tag *p_sta_entry,int limit); +void td_timer_end(void *env); +void td_reset(uint8_t vif_index); +void td_init(void); +void td_start(uint8_t vif_index); +void td_pck_ind(uint8_t vif_index,uint8_t sta_index,_Bool rx); +void td_pck_ps_ind(uint8_t vif_index,_Bool rx); +void bl_tpc_update_power_table(int8_t *power_table); +void bl_tpc_power_table_get(int8_t *power_table_config); +void bl_tpc_update_power_rate_11b(int8_t *power_rate_table); +void bl_tpc_update_power_rate_11g(int8_t *power_rate_table); +void bl_tpc_update_power_rate_11n(int8_t *power_rate_table); +void tpc_update_tx_power(int8_t pwr); +void tpc_update_vif_tx_power(vif_info_tag *vif,int8_t *pwr,uint8_t *idx); +uint8_t tpc_get_vif_tx_power_vs_rate(uint32_t rate_config); +void tpc_update_frame_tx_power(vif_info_tag *vif,txl_frame_desc_tag *frame); +void txl_int_fake_transfer(txdesc *txdesc,uint8_t access_category); +void blmac_abs_timer_set(int reg_idx,uint32_t value); +void txl_machdr_format(uint32_t machdrptr); +void txl_cntrl_init(void); +_Bool txl_cntrl_tx_check(vif_info_tag *p_vif_entry); +void txl_cntrl_halt_ac(uint8_t access_category); +void txl_cntrl_flush_ac(uint8_t access_category,uint32_t status); +void txl_cntrl_inc_pck_cnt(void); +void txl_payload_handle(void); +void txl_payload_handle_backup(void); +void txl_transmit_trigger(void); +void txl_reset(void); +void txl_cntrl_env_dump(void); +void txl_frame_init_desc(txl_frame_desc_tag *frame,txl_buffer_tag *buffer,tx_hw_desc *hwdesc,txl_buffer_control *bufctrl); +void txl_frame_init(_Bool reset); +txl_frame_desc_tag * txl_frame_get(int type,int len); +_Bool txl_frame_push(txl_frame_desc_tag *frame,uint8_t ac); +_Bool txl_frame_push_force(txl_frame_desc_tag *frame,uint8_t ac); +void txl_frame_cfm(txdesc *txdesc); +void txl_frame_release(txdesc *txdesc,_Bool postponed); +uint8_t txl_frame_send_null_frame(uint8_t sta_idx,cfm_func_ptr *cfm,void *env); +uint8_t txl_frame_send_qosnull_frame(uint8_t sta_idx,uint16_t qos,cfm_func_ptr *cfm,void *env); +uint8_t txl_frame_send_eapol_frame(uint8_t sta_idx,cfm_func_ptr *cfm,void *cfm_env,uint8_t *pBuf,uint32_t pBuf_len); +void txl_frame_dump(void); +void txl_hwdesc_init(void); +void txl_hwdesc_reset(void); +void vif_mgmt_bcn_to_evt(void *env); +void vif_mgmt_init(void); +uint8_t vif_mgmt_register(mac_addr *mac_addr,uint8_t vif_type,_Bool p2p,uint8_t *vif_idx); +void vif_mgmt_unregister(uint8_t vif_idx); +void vif_mgmt_add_key(mm_key_add_req *param,uint8_t hw_key_idx); +void vif_mgmt_del_key(vif_info_tag *vif,uint8_t keyid); +void vif_mgmt_send_postponed_frame(vif_info_tag *p_vif_entry); +void vif_mgmt_reset(void); +void vif_mgmt_bcn_to_prog(vif_info_tag *p_vif_entry); +void vif_mgmt_bcn_recv(vif_info_tag *p_vif_entry); +void vif_mgmt_switch_channel(vif_info_tag *p_vif_entry); +vif_info_tag * vif_mgmt_get_first_ap_inf(void); +void me_init(void); +scan_chan_tag * me_freq_to_chan_ptr(uint8_t band,uint16_t freq); +void michael_block(mic_calc *mic_calc_ptr,uint32_t block); +void me_mic_init(mic_calc *mic_calc_ptr,uint32_t *mic_key_ptr,mac_addr *da,mac_addr *sa,uint8_t tid); +void me_mic_calc(mic_calc *mic_calc_ptr,uint32_t start_ptr,uint32_t data_len); +void me_mic_end(mic_calc *mic_calc_ptr); +_Bool me_set_sta_ht_vht_param(sta_info_tag *sta,mac_bss_info *bss); +uint8_t me_11n_nss_max(uint8_t *mcs_set); +uint8_t me_legacy_ridx_min(uint16_t rate_map); +uint8_t me_legacy_ridx_max(uint16_t rate_map); +uint8_t me_rate_translate(uint8_t rate); +void me_get_basic_rates(mac_rateset *rateset,mac_rateset *basic_ratest); +uint16_t me_legacy_rate_bitfield_build(mac_rateset *rateset,_Bool basic_only); +uint16_t me_build_capability(uint8_t vif_idx); +void me_init_bcmc_rate(sta_info_tag *sta_entry); +void me_tx_cfm_singleton(txdesc *txdesc); +void me_check_rc(uint8_t sta_idx,_Bool *tx_ampdu); +void me_init_rate(sta_info_tag *sta_entry); +void me_bw_check(int param_1,int param_2); +void me_beacon_check(uint8_t vif_idx,uint16_t length,uint32_t bcn_addr); +void me_sta_bw_nss_max_upd(uint8_t sta_idx,uint8_t bw,uint8_t nss); +uint8_t me_add_chan_ctx(uint8_t *p_chan_idx,scan_chan_tag *p_chan,uint32_t center_freq1,uint32_t center_freq2,uint8_t ch_width); +uint8_t rc_get_nss(uint16_t rate_config); +uint8_t rc_get_mcs_index(uint16_t rate_config); +uint16_t rc_set_previous_mcs_index(rc_sta_stats *rc_ss,uint16_t rate_config); +uint16_t rc_set_next_mcs_index(rc_sta_stats *rc_ss,uint16_t rate_config); +_Bool is_cck_group(uint16_t rate_config); +void rc_update_retry_chain(rc_sta_stats *rc_ss,uint32_t *cur_tp); +uint16_t rc_get_lowest_rate_config(rc_sta_stats *rc_ss); +void rc_sort_samples_tp(rc_sta_stats *rc_ss,uint32_t *cur_tp); +uint16_t rc_get_initial_rate_config(rc_sta_stats *rc_ss); +void rc_calc_prob_ewma(rc_rate_stats *rc_rs); +_Bool rc_check_valid_rate(rc_sta_stats *rc_ss,uint16_t rate_config); +uint16_t rc_new_random_rate(rc_sta_stats *rc_ss); +void rc_update_counters(uint8_t sta_idx,uint32_t attempts,uint32_t failures,_Bool tx_ampdu,_Bool retry_required); +uint32_t rc_get_duration(uint param_1); +void rc_update_bw_nss_max(uint8_t sta_idx,uint8_t bw_max,uint8_t nss_max); +void rc_init_bcmc_rate(sta_info_tag *sta_entry,uint8_t basic_rate_idx); +_Bool rc_check_fixed_rate_config(rc_sta_stats *rc_ss,uint16_t fixed_rate_config); +uint32_t rc_calc_tp(rc_sta_stats *rc_ss,uint8_t sample_idx); +_Bool rc_update_stats(rc_sta_stats *rc_ss,_Bool init); +void rc_init(sta_info_tag *sta_entry); +void rc_check(uint8_t sta_idx,_Bool *tx_ampdu); +uint8_t rxu_cntrl_machdr_len_get(uint16_t frame_cntl); +_Bool rxu_cntrl_protected_handle(uint8_t *frame,uint32_t statinfo); +undefined4 rxu_mgt_frame_check(rx_swdesc *param_1,uint param_2); +void rxu_cntrl_init(void); +void rxu_cntrl_monitor_pm(mac_addr *addr); +uint8_t rxu_cntrl_get_pm(void); +void rxu_cntrl_evt(int dummy); +void rxu_swdesc_upload_evt(int arg); +void scanu_confirm(uint8_t status); +void scanu_raw_send_cfm(uint8_t status,ke_task_id_t dst_id); +void scanu_init(void); +mac_scan_result * scanu_find_result(mac_addr *bssid_ptr,_Bool allocate); +undefined4 scanu_frame_handler(ushort *param_1); +mac_scan_result * scanu_search_by_bssid(mac_addr *bssid); +mac_scan_result * scanu_search_by_ssid(mac_ssid *ssid,int *idx); +void scanu_rm_exist_ssid(mac_ssid *ssid,int index); +void scanu_scan_next(void); +void scanu_dma_cb(void); +void scanu_start(void); +uint16_t txl_get_seq_ctrl(void); +void sm_delete_resources(vif_info_tag *vif); +void sm_frame_tx_cfm_handler(void *env,uint32_t status); +void sm_init(void); +void sm_get_bss_params(mac_addr **bssid,scan_chan_tag **chan); +void sm_scan_bss(mac_addr *bssid,scan_chan_tag *chan_1); +void sm_join_bss(mac_addr *bssid,scan_chan_tag *chan,_Bool passive); +uint8_t sm_add_chan_ctx(uint8_t *p_chan_idx); +void sm_send_next_bss_param(void); +void sm_set_bss_param(void); +void sm_disconnect_process(vif_info_tag *vif,uint16_t reason); +void sm_deauth_cfm(void *env,uint32_t status); +void sm_disconnect(uint8_t vif_index,uint16_t reason_code); +void sm_connect_ind(uint16_t status); +void sm_supplicant_deauth_cfm(void *env,uint32_t status); +void sm_auth_send(uint16_t auth_seq,uint32_t *challenge); +void sm_assoc_req_send(void); +void sm_assoc_done(uint16_t aid); +void sm_auth_handler(rxu_mgt_ind *param); +void sm_assoc_rsp_handler(rxu_mgt_ind *param); +int sm_deauth_handler(rxu_mgt_ind *param); +void sm_handle_supplicant_result(uint8_t sta_id,uint16_t reason_code); +undefined2 * txu_cntrl_sec_hdr_append(int param_1,undefined2 *param_2,int param_3); +int txu_cntrl_sechdr_len_compute(txdesc *txdesc,int *tail_len); +void txu_cntrl_frame_build(txdesc *txdesc,uint32_t buf); +void txu_cntrl_tkip_mic_append(txdesc *txdesc,uint8_t ac); +void txu_cntrl_cfm(txdesc *txdesc); +void txu_cntrl_protect_mgmt_frame(txdesc *txdesc,uint32_t frame,uint16_t hdr_len); +int _aid_list_delete(uint8_t *mac); +void apm_sta_delete(uint8_t sta_idx,uint8_t *mac); +void apm_tx_cfm_handler(uint8_t *param_1,int param_2); +void apm_init(void); +void apm_start_cfm(int param_1); +void apm_send_next_bss_param(void); +void apm_set_bss_param(void); +void apm_stop(vif_info_tag *vif); +_Bool apm_tx_int_ps_check(txdesc *txdesc); +void apm_tx_int_ps_postpone(txdesc *txdesc,sta_info_tag *sta); +txdesc * apm_tx_int_ps_get_postpone(vif_info_tag *vif,sta_info_tag *sta,int *stop); +void apm_tx_int_ps_clear(vif_info_tag *vif,uint8_t sta_idx); +void apm_sta_fw_delete(uint8_t sta_idx); +void apm_sta_add(uint8_t sta_idx); +void apm_send_mlme(vif_info_tag *vif,uint16_t fctl,mac_addr *ra,cfm_func_ptr *cfm_func,void *env,uint16_t status_code); +_Bool apm_embedded_enabled(vif_info_tag *vif); +void apm_bcn_set(void); +void apm_probe_req_handler(ushort *param_1); +void apm_auth_handler(rxu_mgt_ind *param); +void apm_assoc_req_handler(ushort *param_1,int param_2); +void apm_deauth_handler(rxu_mgt_ind *param); +void apm_disassoc_handler(rxu_mgt_ind *param); +void apm_beacon_handler(rxu_mgt_ind *param); +void apm_sta_remove(uint8_t vif_idx,uint8_t sta_idx); +char * cfg_api_element_dump(void *val,CFG_ELEMENT_TYPE type,char *strs); +int cfg_api_element_general_set(cfg_element_entry *entry,void *arg1,void *arg2); +int cfg_api_element_general_get(cfg_element_entry *entry,void *arg1,void *arg2); +int cfg_api_element_set(uint32_t task,uint32_t element,uint32_t type,void *arg1,void *arg2); +void co_list_init(co_list *list); +void co_list_push_back(co_list *list,co_list_hdr *list_hdr); +void co_list_push_front(co_list *list,co_list_hdr *list_hdr); +co_list_hdr * co_list_pop_front(co_list *list); +void co_list_extract(co_list *list,co_list_hdr *list_hdr); +uint32_t co_list_cnt(co_list *list); +void co_list_insert(co_list *list,co_list_hdr *element,anon_subr__Bool_co_list_hdr_ptr_co_list_hdr_ptr *cmp); +void co_list_insert_after(co_list *list,co_list_hdr *prev_element,co_list_hdr *element); +void co_list_remove(co_list *list,co_list_hdr *prev_element,co_list_hdr *element); +uint32_t co_crc32(uint32_t addr,uint32_t len,uint32_t crc); +void bl_event_handle(int param); +void bl60x_fw_dump_statistic(int forced); +void ke_evt_schedule(void); +void ke_init(void); +void * ke_msg_alloc(ke_msg_id_t id,ke_task_id_t dest_id,ke_task_id_t src_id,uint16_t param_len); +void ke_msg_send(int param_1); +void ke_msg_send_basic(ke_msg_id_t id,ke_task_id_t dest_id,ke_task_id_t src_id); +void ke_msg_forward_and_change_id(void *param_ptr,ke_msg_id_t msg_id,ke_task_id_t dest_id,ke_task_id_t src_id); +_Bool cmp_dest_id(co_list_hdr *msg,uint32_t dest_id); +_Bool ke_task_local(ke_task_id_t id); +ke_msg_func_t * ke_handler_search(ke_msg_id_t msg_id,ke_state_handler *state_handler); +ke_state_t ke_state_get(ke_task_id_t id); +int ke_msg_discard(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int ke_msg_save(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +_Bool cmp_abs_time(co_list_hdr *timerA,co_list_hdr *timerB); +_Bool cmp_timer_id(co_list_hdr *timer,uint32_t timer_task); +void ke_timer_set(ke_msg_id_t timer_id,ke_task_id_t task_id,uint32_t delay); +void ke_timer_clear(ke_msg_id_t timer_id,ke_task_id_t task_id); +void ke_timer_schedule(int dummy); +void bl60x_current_time_us(longlong *time_now); +byte * mac_ie_find(byte *param_1,int param_2,uint param_3); +char * mac_vsie_find(char *param_1,int param_2,int param_3,int param_4); +BufferDesc_t *GetTxEAPOLBuffer(cm_ConnectionInfo_t *connPtr,EAPOL_KeyMsg_Tx_t **ppTxEapol,BufferDesc_t *pBufDesc); +void UpdateEAPOLWcbLenAndTransmit(BufferDesc_t *pBufDesc,UINT16 frameLen); +BOOLEAN keyMgmtProcessMsgExt(keyMgmtInfoSta_t *pKeyMgmtInfoSta,EAPOL_KeyMsg_t *pKeyMsg); +void KeyMgmtInitSta(cm_ConnectionInfo_t *connPtr); +void keyMgmtSta_StartSession(cm_ConnectionInfo_t *connPtr,CHAR *pBssid,UINT8 *pStaAddr); +void init_customApp_mibs(supplicantData_t *suppData); +UINT8 supplicantIsEnabled(void *connectionPtr); +void supplicantInitSession(cm_ConnectionInfo_t *connPtr,CHAR *pSsid,UINT16 len,CHAR *pBssid,UINT8 *pStaAddr); +void supplicantDisable(cm_ConnectionInfo_t *connPtr); +void supplicantEnable(void *connectionPtr,int security_mode,void *mcstCipher,void *ucstCipher,_Bool is_pmf_required); +UINT16 keyMgmtFormatWpaRsnIe(cm_ConnectionInfo_t *connPtr,UINT8 *pos,IEEEtypes_MacAddr_t *pBssid,IEEEtypes_MacAddr_t *pStaAddr,UINT8 *pPmkid,BOOLEAN addPmkid); +Status_e GeneratePWKMsg2(BufferDesc_t *pEAPoLBufDesc,UINT8 *pSNonce,UINT8 *pEAPOLMICKey,UINT8 forceKeyDescVersion); +BOOLEAN KeyMgmtStaHsk_Recvd_PWKMsg1(BufferDesc_t *pEAPoLBufDesc,IEEEtypes_MacAddr_t *sa,IEEEtypes_MacAddr_t *da); +void supplicantInit(supplicantData_t *suppData); +void allocSupplicantData(void *connectionPtr); +UINT16 keyMgmtGetKeySize(cm_ConnectionInfo_t *connPtr,UINT8 isPairwise); +uint8_t add_key_to_mac(cm_ConnectionInfo_t *connPtr,UINT8 pairwise); +BufferReturnNotify_t * keyMgmtKeyGroupTxDone(void); +Status_e GenerateGrpMsg2(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta); +EAPOL_KeyMsg_t * KeyMgmtStaHsk_Recvd_GrpMsg1(BufferDesc_t *pEAPoLBufDesc); +uint8_t add_mfp_key_to_mac(cm_ConnectionInfo_t *connPtr,UINT8 pairwise); +void keyMgmtPlumbPairwiseKey(cm_ConnectionInfo_t *connPtr); +BufferReturnNotify_t * keyMgmtKeyPairwiseTxDone(void); +Status_e GeneratePWKMsg4(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta,BOOLEAN groupKeyReceived); +EAPOL_KeyMsg_t * KeyMgmtStaHsk_Recvd_PWKMsg3(BufferDesc_t *pEAPoLBufDesc); +void ProcessKeyMgmtDataSta(BufferDesc_t *pBufDesc,IEEEtypes_MacAddr_t *sa,IEEEtypes_MacAddr_t *da); +UINT8 ProcessEAPoLPkt(BufferDesc_t *bufDesc,IEEEtypes_MacAddr_t *sa,IEEEtypes_MacAddr_t *da); +uchar process_rsn_ie(uint8_t *rsn_ie,Cipher_t *mcstCipher,Cipher_t *ucstCipher,_Bool *is_pmf_required,SecurityMode_t *security_mode,_Bool wpa2_prefered); +uchar process_wpa_ie(uint8_t *wpa_ie,Cipher_t *mcstCipher,Cipher_t *ucstCipher); +void keyMgmtStaRsnSecuredTimeoutHandler(void *env); +void supplicantGenerateRand(UINT8 *dataOut,UINT32 length); +void ComputeEAPOL_MIC(EAPOL_KeyMsg_t *pKeyMsg,UINT16 data_length,UINT8 *MIC_Key,UINT8 MIC_Key_length,UINT8 micKeyDescVersion); +UINT16 keyMgmtGetKeySize_internal(RSNConfig_t *pRsnConfig,UINT8 isPairwise); +int isApReplayCounterFresh(keyMgmtInfoSta_t *pKeyMgmtInfoSta,UINT8 *pRxReplayCount); +void updateApReplayCounter(keyMgmtInfoSta_t *pKeyMgmtStaInfo,UINT8 *pRxReplayCount); +void formEAPOLEthHdr(EAPOL_KeyMsg_Tx_t *pTxEapol,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa); +BOOLEAN IsEAPOL_MICValid(EAPOL_KeyMsg_t *pKeyMsg,UINT8 *pMICKey); +UINT16 KeyMgmtSta_PopulateEAPOLLengthMic(EAPOL_KeyMsg_Tx_t *pTxEapol,UINT8 *pEAPOLMICKey,UINT8 eapolProtocolVersion,UINT8 forceKeyDescVersion); +KDE_t * parseKeyKDE(IEEEtypes_InfoElementHdr_t *pIe); +KDE_t * parseKeyKDE_DataType(UINT8 *pData,SINT32 dataLen,IEEEtypes_KDEDataType_e KDEDataType); +KDE_t * parseKeyDataGTK(UINT8 *pKey,UINT16 len,KeyData_t *pGRKey); +void KeyMgmtSta_ApplyKEK(EAPOL_KeyMsg_t *pKeyMsg,KeyData_t *pGRKey,UINT8 *EAPOL_Encr_Key); +BOOLEAN KeyMgmtSta_IsRxEAPOLValid(keyMgmtInfoSta_t *pKeyMgmtInfoSta,EAPOL_KeyMsg_t *pKeyMsg); +void KeyMgmtSta_PrepareEAPOLFrame(EAPOL_KeyMsg_Tx_t *pTxEapol,EAPOL_KeyMsg_t *pRxEapol,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa,UINT8 *pSNonce); +BOOLEAN supplicantAkmIsWpaWpa2(AkmSuite_t *pAkm); +BOOLEAN supplicantAkmIsWpa2(AkmSuite_t *pAkm); +BOOLEAN supplicantAkmIsWpaWpa2Psk(AkmSuite_t *pAkm); +BOOLEAN supplicantAkmUsesKdf(AkmSuite_t *pAkm); +void supplicantConstructContext(IEEEtypes_MacAddr_t *pAddr1,IEEEtypes_MacAddr_t *pAddr2,UINT8 *pNonce1,UINT8 *pNonce2,UINT8 *pContext); +void KeyMgmt_DerivePTK(IEEEtypes_MacAddr_t *pAddr1,IEEEtypes_MacAddr_t *pAddr2,UINT8 *pNonce1,UINT8 *pNonce2,UINT8 *pPTK,UINT8 *pPMK,BOOLEAN use_kdf); +void KeyMgmtSta_DeriveKeys(UINT8 *pPMK,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa,UINT8 *ANonce,UINT8 *SNonce,UINT8 *EAPOL_MIC_Key,UINT8 *EAPOL_Encr_Key,KeyData_t *newPWKey,BOOLEAN use_kdf); +void SetEAPOLKeyDescTypeVersion(EAPOL_KeyMsg_Tx_t *pTxEapol,BOOLEAN isWPA2,BOOLEAN isKDF,BOOLEAN nonTKIP); +EAPOL_KeyMsg_t *GetKeyMsgNonceFromEAPOL(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta); +EAPOL_KeyMsg_t *ProcessRxEAPOL_PwkMsg3(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta); +EAPOL_KeyMsg_t *ProcessRxEAPOL_GrpMsg1(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta); +void KeyMgmtResetCounter(keyMgmtInfoSta_t *pKeyMgmtInfo); +void keyMgmtSta_StartSession_internal(keyMgmtInfoSta_t *pKeyMgmtInfoSta,UINT32 expiry); +void KeyMgmtSta_InitSession(keyMgmtInfoSta_t *pKeyMgmtInfoSta); +void set_psk(char *pSsid,UINT8 ssidLen,char *phrase); +void remove_psk(char *pSsid,UINT8 ssidLen); +void bl_sha256_crypto_kdf(UINT8 *pKey,UINT8 key_len,char *label,UINT8 label_len,UINT8 *pContext,UINT16 context_len,UINT8 *pOutput,UINT16 output_len); +UINT8 * pmkCacheFindPSK(UINT8 *pSsid,UINT8 ssidLen); +void pmkCacheSetPassphrase(UINT8 *pSsid,UINT8 ssidLen,UINT8 *pPassphrase,UINT8 PassphraseLen); +void pmkCacheInit(void); +void pmkCacheRomInit(void); +pmkElement_t * pmkCacheNewElement(void); +void pmkCacheUpdateReplacementRank(pmkElement_t *pPMKElement); +pmkElement_t * pmkCacheFindPSKElement(UINT8 *pSsid,UINT8 ssidLen); +void pmkCacheAddPSK(UINT8 *pSsid,UINT8 ssidLen,UINT8 *pPSK,UINT8 pPSKLen); +void pmkCacheDeletePSK(UINT8 *pSsid,UINT8 ssidLen); +UINT8 pmkCacheGetHexNibble(UINT8 nibble); +void pmkCacheGeneratePSK(UINT8 *pSsid,UINT8 ssidLen,UINT8 *pPassphrase,UINT8 PassphraseLen,UINT8 *pPSK); +void prepare_key(uchar *key_data_ptr,int key_data_len,rc4_key *key); +void rc4(uchar *buffer_ptr,int buffer_len,int skip,rc4_key *key); +void RC4_Encrypt(uchar *Encr_Key,uchar *IV,ushort iv_length,uchar *Data,ushort data_length,ushort skipBytes); +int sha256_compress(sha256_state *md,UINT8 *msgBuf,UINT8 *pScratchMem); +void sha256_init(sha256_state *md); +void sha256_vector(size_t num_elem,UINT8 **addr,size_t *len,UINT8 *mac,UINT8 *pScratchMem); +void hmac_sha256_vector(UINT8 *key,size_t key_len,size_t num_elem,UINT8 **addr,size_t *len,UINT8 *mac); +void KeyMgmtInit(cm_ConnectionInfo_t *connPtr); +BufferDesc_t *PrepDefaultEapolMsg(cm_ConnectionInfo_t *connPtr,EAPOL_KeyMsg_Tx_t **pTxEapolPtr,BufferDesc_t *pBufDesc); +Status_e GeneratePWKMsg1(cm_ConnectionInfo_t *connPtr,BufferDesc_t *pBufDesc); +Status_e GeneratePWKMsg3(cm_ConnectionInfo_t *connPtr,BufferDesc_t *pBufDesc); +Status_e ProcessPWKMsg4(BufferDesc_t *pBufDesc); +Status_e GenerateApEapolMsg(cm_ConnectionInfo_t *connPtr,keyMgmtState_e msgState,BufferDesc_t *pBufDesc); +Status_e ProcessPWKMsg2(BufferDesc_t *pBufDesc); +BOOLEAN SendEAPOLMsgUsingBufDesc(cm_ConnectionInfo_t *connPtr,BufferDesc_t *pBufDesc); +Status_e ProcessKeyMgmtDataAp(BufferDesc_t *pBufDesc); +void InitStaKeyInfo(void *pConn,SecurityMode_t *secType,Cipher_t *pwCipher,UINT16 staRsnCap,UINT8 akmType); +void RemoveAPKeyInfo(void *pConn); +void InitGroupKey(cm_ConnectionInfo_t *connPtr); +void GenerateGTK_internal(KeyData_t *grpKeyData,UINT8 *nonce,IEEEtypes_Addr_t *StaMacAddr); +void PopulateKeyMsg(EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,Cipher_t *Cipher,UINT16 Type,UINT32 *replay_cnt,UINT8 *Nonce); +void prepareKDE(EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,KeyData_t *grKey,Cipher_t *cipher); +BOOLEAN Encrypt_keyData(EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,UINT8 *EAPOL_Encr_Key,Cipher_t *cipher); +void KeyMgmtAp_DerivePTK(UINT8 *pPMK,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa,UINT8 *ANonce,UINT8 *SNonce,UINT8 *EAPOL_MIC_Key,UINT8 *EAPOL_Encr_Key,KeyData_t *newPWKey,BOOLEAN use_kdf); +BOOLEAN KeyData_CopyWPAWP2(EAPOL_KeyMsg_Tx_t *pTxEAPOL,void *pIe); +BOOLEAN KeyData_UpdateKeyMaterial(EAPOL_KeyMsg_Tx_t *pTxEAPOL,SecurityMode_t *pSecType,void *pWPA,void *pWPA2); +void ROM_InitGTK(KeyData_t *grpKeyData,UINT8 *nonce,IEEEtypes_Addr_t *StaMacAddr); +void InitKeyMgmtInfo(apKeyMgmtInfoStaRom_t *pKeyMgmtInfo,SecurityMode_t *secType,Cipher_t *pwCipher,UINT16 staRsnCap,UINT8 akmType); +apInfo_t * cm_GetApInfo(cm_ConnectionInfo_t *connPtr); +apSpecificData_t * cm_GetApData(cm_ConnectionInfo_t *connPtr); +Status_e cm_AllocAPResources(cm_ConnectionInfo_t *connPtr); +Status_e cm_AllocResources(cm_ConnectionInfo_t *connPtr); +cm_ConnectionInfo_t *cm_InitConnection(UINT8 conType,UINT8 bssType,UINT8 bssNum,IEEEtypes_MacAddr_t *bssId,IEEEtypes_MacAddr_t *peerMacAddr,UINT8 channel,unkbyte0 *hostMdev); +void cm_DeleteConnection(cm_ConnectionInfo_t *connPtr); +void cm_SetPeerAddr(cm_ConnectionInfo_t *connPtr,IEEEtypes_MacAddr_t *bssId,IEEEtypes_MacAddr_t *peerMacAddr); +void cm_SetComData(cm_ConnectionInfo_t *connPtr,char *ssid); +void assert_err(char *condition,char *file,int line); +void assert_warn(char *condition,char *file,int line); +void coex_dump_pta(void); +void coex_dump_wifi(void); +void coex_wifi_rf_forece_enable(int enable); +void coex_wifi_pti_forece_enable(int enable); +void wifi_main(void); +void ipc_emb_notify(void); +void ipc_emb_wait(void); +void ipc_emb_init(void); +void ipc_emb_tx_irq(void); +void ipc_emb_tx_evt(int queue_idx); +void ipc_emb_cfmback_irq(void); +void ipc_emb_txcfm_ind(uint32_t queue_bits); +void ipc_emb_msg_irq(void); +void ipc_emb_msg_evt(void); +void ipc_emb_msg_dma_int_handler(void); +void ipc_emb_dbg_dma_int_handler(void); +void ipc_emb_dump(void); +void rf_set_channel(uint8_t bandwidth,uint16_t channel_freq); +void rf_dump_status(void); +void mdm_txcbwmax_setf(uint8_t txcbwmax); +void phy_config_rxgain(int offset); +void agc_config(void); +void mdm_reset(void); +void phy_powroffset_set(int8_t *power_offset); +void phy_hw_set_channel(uint8_t band,uint16_t freq,uint16_t freq1,uint8_t chantype); +void phy_get_channel(phy_channel_info *info,uint8_t index); +void phy_set_channel(uint8_t band,uint8_t type,uint16_t prim20_freq,uint16_t center1_freq,uint16_t center2_freq,uint8_t index); +void phy_get_version(uint32_t *version_1,uint32_t *version_2); +_Bool phy_vht_supported(void); +void phy_init(phy_cfg_tag *config); +uint8_t phy_get_nss(void); +uint8_t phy_get_ntx(void); +void phy_stop(void); +_Bool phy_ldpc_tx_supported(void); +uint8_t phy_get_mac_freq(void); +void phy_get_rf_gain_idx(int8_t *power,uint8_t *idx); +void phy_get_rf_gain_capab(int8_t *max,int8_t *min); +void mpif_clk_init(void); +void phy_mdm_isr(void); +void phy_rc_isr(void); +void pa_init(void); +void pa_input(uint8_t id,rx_hd *rhd); +uint8_t hal_get_capcode(void); +void hal_set_capcode(uint32_t capcode); +_Bool hal_get_temperature(int16_t *temperature); +void hal_set_temperature(int16_t temperature); +void trpc_update_power(int8_t (*power_rate_table) [8]); +void trpc_power_get(int8_t *power_rate_table); +void trpc_update_power_11b(int8_t *power_rate_table); +void trpc_update_power_11g(int8_t *power_rate_table); +void trpc_update_power_11n(int8_t *power_rate_table); +void trpc_init(void); +int8_t trpc_get_rf_max_power(void); +int8_t trpc_get_rf_min_power(void); +uint8_t trpc_get_power_idx(uint8_t formatmod,uint8_t mcs,int8_t pwr_dbm); +uint8_t trpc_get_default_power_idx(uint8_t formatmod,uint8_t mcs); +void trpc_update_vs_channel(int8_t channel_MHz); +void trpc_update_vs_temperature(int8_t temperature); +void phy_tcal_reset(void); +void phy_tcal_start(void); +void phy_tcal_txpwr(int16_t curr_temperature); +void phy_tcal_callback(int16_t temperature); +void rf_fsm_ctrl_en_setf(uint32_t x); +void rf_fsm_st_dbg_en_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc3_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc2_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc1_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc0_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc7_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc6_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc5_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc4_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc11_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc10_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc9_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc8_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc15_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc14_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc13_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc12_setf(uint32_t x); +void wait_us(uint32_t us); +void _print_channel_info(void); +void rfc_init(uint32_t xtalfreq_hz); +void rfc_rxdfe_set_notch0(uint8_t en,uint8_t alpha,int8_t nrmfc); +void rfc_config_channel(uint32_t channel_freq); +void rfc_coex_force_to(uint32_t force_enable,uint32_t bbmode); +uint32_t rfc_get_power_level(uint32_t formatmod,int32_t power); +void rfc_apply_tx_dvga(int8_t *dvga_qdb); +void rfc_apply_tx_power_offset(uint8_t channel,int8_t *power_offset); +void rf_pri_set_gain_table_regs(void); +void rf_pri_manu_pu(uint32_t mode); +void rf_pri_save_state_for_cal(void); +void rf_pri_restore_state_for_cal(void); +void rf_pri_singen_start(void); +uint32_t rf_pri_pm_pwr(void); +void rf_pri_start_txdfe(void); +int32_t rf_pri_pm_pwr_avg(uint32_t iq,uint32_t acc_len); +void rf_pri_txcal_config_hw(void); +uint16_t rf_pri_fcal_meas(uint32_t cw); +void rf_pri_rccal_config(uint32_t rbb_fc); +void rf_pri_rccal_config(uint32_t iq,uint32_t rbb_fc); +void rf_pri_txcal_config(uint32_t param_ind,int32_t val); +int32_t rf_pri_txcal_search_core(uint32_t param_ind,uint32_t center,uint32_t delta,uint32_t meas_freq); +void rf_pri_singen_config(uint32_t fcw); +uint32_t rf_pri_rccal_iq(uint32_t iq); +void rf_pri_config_channel(void); +uint32_t rf_pri_roscal_iq(uint32_t iq); +void rf_pri_chipv(uint8_t chipv); +void rf_pri_update_tx_power_offset(uint8_t channel,int8_t *power_offset); +void rf_pri_get_notch_param(uint32_t chanfreq_MHz,uint8_t *ncf_on,int32_t *ncf_freq_Hz); +void rf_pri_update_param(uint32_t chanfreq_MHz); +void rf_pri_xtalfreq(uint32_t xtalfreq); +uint32_t rf_pri_get_vco_freq_cw(uint32_t chanfreq_MHz); +uint32_t rf_pri_get_vco_idac_cw(uint32_t chanfreq_MHz); +int32_t rf_pri_get_txgain_max(void); +int32_t rf_pri_get_txgain_min(void); +uint32_t rf_pri_get_txgain_index(int32_t pwr,uint32_t mode); +void rf_pri_query_txgain_table(uint32_t index,uint32_t *rfg_index,uint32_t *dg); +void rf_pri_update_dvga_os(int8_t dvga_os); +void rf_pri_tx_gain_comp(int32_t Tsens); +void rf_pri_txcal(void); +void rf_pri_roscal(void); +void rf_pri_rccal(void); +void rf_pri_lo_acal(void); +void rf_pri_fcal(void); +void rf_pri_full_cal(void); +void rf_pri_restore_cal_reg(void); +void rf_pri_init(uint8_t reset,uint8_t chipv); +void rf_pri_update_power_offset(int32_t *power_offset); +int phyif_utils_decode(phyif_utils_recvtable_t *vec,int8_t *ppm); +void sysctrl_init(void); +void intc_spurious(void); +void intc_enable_irq(int index); +void intc_init(void); +void mac_irq(void); +void bl_irq_handler(void); +void blmac_pwr_mgt_setf(uint8_t pwrmgt); +chan_ctxt_tag * chan_get_next_chan(void); +void chan_conn_less_delay_prog(void); +void chan_upd_nb_rem_slots(uint32_t current_time); +_Bool chan_tbtt_detect_conflict(void); +void chan_tbtt_insert(chan_tbtt_tag *p_tbtt_entry); +void chan_upd_ctxt_status(chan_ctxt_tag *p_chan_entry,uint8_t next_status); +void chan_switch_start(chan_ctxt_tag *p_chan_entry); +void chan_conn_less_delay_evt(void *env); +void chan_tbtt_switch_evt(void *env); +void chan_tbtt_schedule(chan_tbtt_tag *p_tbtt_entry); +void chan_cde_evt(void *env); +void chan_goto_idle_cb(void); +void chan_tx_cfm(void *dummy,uint32_t status); +void chan_init(void); +void chan_scan_req(uint8_t band,uint16_t freq,int8_t pwr,uint32_t duration_us,uint8_t vif_index); +uint8_t chan_roc_req(mm_remain_on_channel_req *req,ke_task_id_t taskid); +uint8_t chan_ctxt_add(mm_chan_ctxt_add_req *p_add_req,uint8_t *idx); +void chan_ctxt_del(uint8_t chan_idx); +void chan_tbtt_switch_update(vif_info_tag *p_vif_entry,uint32_t tbtt_time); +void chan_bcn_to_evt(vif_info_tag *p_vif_entry); +void chan_bcn_detect_start(vif_info_tag *p_vif_entry); +_Bool chan_is_on_channel(vif_info_tag *p_vif_entry); +_Bool chan_is_tx_allowed(vif_info_tag *p_vif_entry); +_Bool chan_is_on_operational_channel(vif_info_tag *p_vif_entry); +void chan_update_tx_power(chan_ctxt_tag *p_chan_entry); +void chan_ctxt_link(uint8_t vif_idx,uint8_t chan_idx); +void chan_ctxt_unlink(uint8_t vif_idx); +void hal_dma_init(void); +uint8_t blmac_soft_reset_getf(void); +void blmac_wt_2_crypt_clk_ratio_setf(uint8_t wt2cryptclkratio); +void blmac_rx_flow_cntrl_en_setf(void); +void blmac_key_sto_ram_reset_setf(void); +void hal_machw_stop(void); +void hal_machw_init(void); +void hal_machw_disable_int(void); +void hal_machw_reset(void); +uint8_t hal_machw_search_addr(mac_addr *addr); +void hal_machw_monitor_mode(void); +_Bool hal_machw_sleep_check(void); +void hal_machw_gen_handler(void); +void hal_mib_dump(void); +int mm_monitor_channel_req_handler(ke_msg_id_t msgid,mm_monitor_channel_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_monitor_enable_req_handler(ke_msg_id_t msgid,mm_monitor_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_cfg_rssi_req_handler(ke_msg_id_t msgid,mm_cfg_rssi_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_ps_options_req_handler(ke_msg_id_t msgid,mm_set_ps_options_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_tim_update_req_handler(ke_msg_id_t msgid,mm_tim_update_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_bcn_change_req_handler(ke_msg_id_t msgid,mm_bcn_change_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_remain_on_channel_req_handler(ke_msg_id_t msgid,mm_remain_on_channel_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_sta_del_req_handler(ke_msg_id_t msgid,mm_sta_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_sta_add_req_handler(ke_msg_id_t msgid,mm_sta_add_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_key_del_req_handler(ke_msg_id_t msgid,mm_key_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_key_add_req_handler(ke_msg_id_t msgid,mm_key_add_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_power_req_handler(ke_msg_id_t msgid,mm_set_power_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_idle_req_handler(ke_msg_id_t msgid,mm_set_idle_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_version_req_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_start_req_handler(ke_msg_id_t msgid,mm_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_ps_mode_req_handler(ke_msg_id_t msgid,mm_set_ps_mode_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_force_idle_req_handler(ke_msg_id_t msgid,mm_force_idle_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_hw_config_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int bl60x_edca_get(int ac,uint8_t *aifs,uint8_t *cwmin,uint8_t *cwmax,uint16_t *txop); +void bl_init(void); +int bl_sleep(void); +uint32_t bl_nap_calculate(void); +void rx_swdesc_init(void); +int scan_cancel_req_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scan_start_req_handler(ke_msg_id_t msgid,scan_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +undefined4 mm_scan_channel_end_ind_handler(void); +int mm_scan_channel_start_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +void txl_buffer_reinit(void); +void txl_buffer_init(void); +void txl_buffer_reset(void); +txl_buffer_tag * txl_buffer_alloc(txdesc *txdesc,uint8_t access_category,uint8_t user_idx); +void txl_buffer_update_thd(txdesc *txdesc); +void txl_cfm_init(void); +void txl_cfm_push(txdesc *txdesc,uint32_t status,uint8_t access_category); +void txl_cfm_flush(uint8_t access_category,co_list *list,uint32_t status); +void txl_cfm_dma_int_handler(void); +void txl_cfm_dump(void); +void bam_init(void); +void bam_send_air_action_frame(int param_1,bam_env_tag *param_2,int param_3,uint8_t param_4,int param_5,uint16_t param_6,cfm_func_ptr *param_7); +undefined4 rxu_mgt_ind_handler(int param_1); +void co_pack8p(uint32_t dst,uint8_t *src,uint32_t len); +int phy_freq_to_channel(uint8_t band,uint16_t freq); +uint16_t phy_channel_to_freq(uint8_t band,int channel); +uint32_t me_add_ie_ssid(uint32_t *frame_addr,uint8_t ssid_len,uint8_t *p_ssid); +uint32_t me_add_ie_supp_rates(uint32_t *frame_addr,mac_rateset *p_rateset); +uint32_t me_add_ie_ext_supp_rates(uint32_t *frame_addr,mac_rateset *p_rateset); +uint32_t me_add_ie_ds(uint32_t *frame_addr,uint8_t channel); +uint32_t me_add_ie_erp(uint32_t *frame_addr,uint8_t erp_info); +uint32_t me_add_ie_rsn(uint32_t *frame_addr,uint8_t enc_type); +uint32_t me_add_ie_wpa(uint32_t *frame_addr,uint8_t enc_type); +uint32_t me_add_ie_tim(uint32_t *frame_addr,uint8_t dtim_period); +uint32_t me_add_ie_ht_capa(uint32_t *frame_addr); +uint32_t me_add_ie_ht_oper(uint32_t *frame_addr,vif_info_tag *p_vif_entry); +uint16_t me_build_authenticate(uint32_t frame,uint16_t algo_type,uint16_t seq_nbr,uint16_t status_code,uint32_t *challenge_array_ptr); +uint16_t me_build_deauthenticate(uint32_t frame,uint16_t reason_code); +uint16_t me_build_associate_req(uint32_t frame,mac_bss_info *bss,mac_addr *old_ap_addr_ptr,uint8_t vif_idx,uint32_t *ie_addr,uint16_t *ie_len,sm_connect_req *con_par); +uint16_t me_build_add_ba_req(uint32_t frame,bam_env_tag *bam_env); +uint16_t me_build_add_ba_rsp(uint32_t frame,bam_env_tag *bam_env,uint16_t param,uint8_t dialog_token,uint16_t status_code); +uint16_t me_build_del_ba(uint32_t frame,bam_env_tag *bam_env,uint16_t reason_code); +void me_extract_rate_set(uint32_t buffer,uint16_t buflen,mac_rateset *mac_rate_set_ptr); +void me_extract_power_constraint(uint32_t buffer,uint16_t buflen,mac_bss_info *bss); +void me_extract_country_reg(int param_1); +void me_extract_mobility_domain(uint32_t buffer,uint16_t buflen,mac_bss_info *bss); +uint me_extract_csa(undefined4 param_1,undefined4 param_2,undefined *param_3,int param_4); +uint16_t me_build_beacon(uint32_t frame,uint8_t vif_idx,uint16_t *tim_oft,uint8_t *tim_len,uint8_t hidden_ssid); +uint16_t me_build_probe_rsp(uint32_t frame,uint8_t vif_idx); +uint16_t me_build_associate_rsp(uint32_t frame,uint8_t vif_idx,uint16_t status_code,me_sta_add_req *req); +int me_rc_set_rate_req_handler(ke_msg_id_t msgid,me_rc_set_rate_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_rc_stats_req_handler(ke_msg_id_t msgid,me_rc_stats_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_traffic_ind_req_handler(ke_msg_id_t msgid,me_traffic_ind_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_sta_del_req_handler(ke_msg_id_t msgid,me_sta_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_control_port_req_handler(ke_msg_id_t msgid,me_set_control_port_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_chan_config_req_handler(ke_msg_id_t msgid,me_chan_config_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_ps_mode_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_idle_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_config_req_handler(ke_msg_id_t msgid,me_config_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_ps_disable_req_handler(ke_msg_id_t msgid,me_set_ps_disable_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_active_req_handler(ke_msg_id_t msgid,me_set_active_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_sta_add_req_handler(ke_msg_id_t msgid,me_sta_add_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +void cfm_raw_send(void *env,uint32_t status); +int scanu_raw_send_req_handler(ke_msg_id_t msgid,scanu_raw_send_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scanu_join_req_handler(ke_msg_id_t msgid,scanu_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scanu_start_req_handler(ke_msg_id_t msgid,scanu_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int rxu_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scan_done_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scan_start_cfm_handler(ke_msg_id_t msgid,scan_start_cfm *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_ps_disable_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_bss_param_setting_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int sm_rsp_timeout_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scanu_start_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_connection_loss_ind_handler(ke_msg_id_t msgid,mm_connection_loss_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scanu_join_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int sm_connect_req_handler(ke_msg_id_t msgid,sm_connect_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int rxu_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_vif_state_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_active_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_sta_add_cfm_handler(ke_msg_id_t msgid,mm_sta_add_cfm *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int sm_disconnect_req_handler(ke_msg_id_t msgid,sm_disconnect_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int apm_sta_connect_timeout_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int rxu_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int apm_sta_add_cfm_handler(ke_msg_id_t msgid,me_sta_add_cfm *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int apm_sta_del_req_handler(ke_msg_id_t msgid,apm_sta_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int apm_conf_max_sta_req_handler(ke_msg_id_t msgid,apm_conf_max_sta_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_ps_disable_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_bss_param_setting_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_bcn_change_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int apm_stop_req_handler(ke_msg_id_t msgid,apm_stop_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int apm_start_req_handler(ke_msg_id_t msgid,apm_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_active_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hostapd_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id); +void dump_cfg_entries(void); +int cfg_start_req_handler(ke_msg_id_t msgid,cfg_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +void dbg_init(void); +void dbg_test_print(char *fmt,...); +int dbg_get_sys_stat_req_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int dbg_mem_write_req_handler(ke_msg_id_t msgid,dbg_mem_write_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int dbg_mem_read_req_handler(ke_msg_id_t msgid,dbg_mem_read_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int dbg_set_sev_filter_req_handler(ke_msg_id_t msgid,dbg_set_sev_filter_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int dbg_set_mod_filter_req_handler(ke_msg_id_t msgid,dbg_set_mod_filter_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +co_list_hdr *ke_queue_extract(co_list *queue,anon_subr__Bool_co_list_hdr_ptr_uint32_t *func,uint32_t arg); +void bl_aes_128(UINT8 *key,UINT8 *input,UINT8 *output); +void xor_128(UINT8 *a,UINT8 *b,UINT8 *out); +void leftshift_onebit(UINT8 *input,UINT8 *output); +void generate_subkey(UINT8 *key,UINT8 *K1,UINT8 *K2); +void padding(UINT8 *lastb,UINT8 *pad,int length); +void bl_aes_cmac(UINT8 *key,UINT8 *input,int length,UINT8 *mac); +int BL_AES_MEMCMP(UINT8 *dst,UINT8 *src,int len); +void BL_AES_MEMSET(UINT8 *dst,UINT8 val,int size); +void BL_AES_MEMCPY(UINT8 *dst,UINT8 *src,int size); +int BL_AesEncrypt(UINT8 *kek,UINT8 kekLen,UINT8 *data,UINT8 *ret); +int BL_AesWrap(UINT8 *kek,UINT8 kekLen,UINT32 n,UINT8 *plain,UINT8 *keyIv,UINT8 *cipher); +int BL_AesUnWrap(UINT8 *kek,UINT8 kekLen,UINT32 n,UINT8 *cipher,UINT8 *keyIv,UINT8 *plain); +void Bl_hmac_md5(UINT8 *text_data,int text_len,UINT8 *key,int key_len,void *digest); +void Bl_hmac_sha1(uchar **ppText,int *pTextLen,int textNum,uchar *key,int key_len,uchar *output,int outputLen); +void Bl_PRF(uchar *key,int key_len,uchar *prefix,int prefix_len,uchar *data,int data_len,uchar *output,int len); +void wpa_MD5Transform(UINT32 *state,ulong *block); +void wpa_MD5Init(Bl_MD5_CTX *context); +void wpa_MD5Update(Bl_MD5_CTX *context,UINT8 *input,UINT32 inputLen); +void wpa_MD5Final(uchar *digest,Bl_MD5_CTX *context); +int rijndaelKeySetupEnc(u32 *rk,u8 *cipherKey,int keyBits); +void rijndael_set_key(rijndael_ctx *ctx,u8 *key,int bits,int encrypt); +void rijndael_decrypt(rijndael_ctx *ctx,u8 *src,u8 *dst); +void rijndael_encrypt(rijndael_ctx *ctx,u8 *src,u8 *dst); +void Bl_SHA1ProcessMessageBlock(Bl_SHA1_CTX *context); +int Bl_SHA1Init(Bl_SHA1_CTX *context); +int Bl_SHA1Final(Bl_SHA1_CTX *context,UINT8 *Message_Digest); +int Bl_SHA1Update(Bl_SHA1_CTX *context,UINT8 *message_array,uint length); +Status_e supplicantRestoreDefaults(void); +void supplicantFuncInit(void); +void ap_setpsk(cm_ConnectionInfo_t *connPtr,CHAR *ssid,CHAR *passphrase); +void ap_resetConfiguration(cm_ConnectionInfo_t *connPtr); +void InitializeAp(cm_ConnectionInfo_t *connPtr); +int bl60x_check_mac_status(int *is_ok); +void helper_record_dump(void); +void helper_record_rc_rf_states(uint *param_1,uint *param_2); +void helper_record_all_states(char *func_name); +u32.conflict3 ipc_emb2app_rawstatus_get(void); +void ipc_host_init(ipc_host_env_tag *env,ipc_host_cb_tag *cb,ipc_shared_env_tag.conflict3 *shared_env_ptr,void *pthis); +int ipc_host_msg_push(ipc_host_env_tag *env,void *msg_buf,uint16_t len); +uint32_t ipc_host_get_rawstatus(ipc_host_env_tag *env); +txdesc_host * ipc_host_txdesc_get(ipc_host_env_tag *env); +void ipc_host_txdesc_push(ipc_host_env_tag *env,void *host_id); +void ipc_host_irq(ipc_host_env_tag *env,uint32_t status); +void ipc_host_enable_irq(ipc_host_env_tag *env,uint32_t value); +void ipc_host_disable_irq_e2a(void); +int bl_main_disconnect(void); +int bl_main_powersaving(int mode); +int bl_main_denoise(int mode); +int bl_main_monitor(void); +int bl_main_phy_up(void); +int bl_main_monitor_channel_set(int channel,int use_40MHZ); +int bl_main_if_remove(uint8_t vif_index); +int bl_main_raw_send(uint8_t *pkt,int len); +int bl_main_rate_config(uint8_t sta_idx,uint16_t fixed_rate_cfg); +int bl_main_set_country_code(char *country_code); +int bl_main_get_channel_nums(void); +int bl_main_if_add(int is_sta,netif *netif,uint8_t *vif_index); +int bl_main_apm_start(char *ssid,char *password,int channel,uint8_t vif_index,uint8_t hidden_ssid); +int bl_main_apm_stop(uint8_t vif_index); +int bl_main_apm_sta_cnt_get(uint8_t *sta_cnt); +int bl_main_apm_sta_info_get(wifi_apm_sta_info *apm_sta_info,uint8_t idx); +int bl_main_apm_sta_delete(uint8_t sta_idx); +int bl_main_apm_remove_all_sta(void); +int bl_main_conf_max_sta(uint8_t max_sta_supported); +int bl_main_cfg_task_req(uint32_t ops,uint32_t task,uint32_t element,uint32_t type,void *arg1,void *arg2); +int bl_main_scan(void); +int bl_cfg80211_connect(bl_hw *bl_hw,cfg80211_connect_params *sme); +int bl_main_connect(uint8_t *ssid,int ssid_len,uint8_t *psk,int psk_len,uint8_t *pmk,int pmk_len,uint8_t *mac,uint8_t band,uint16_t freq); +void bl_main_event_handle(void); +void bl_main_lowlevel_init(void); +int bl_main_rtthread_start(bl_hw **bl_hw); +int bl_handle_dynparams(bl_hw *bl_hw); +int bl_send_msg(bl_hw *bl_hw,void *msg_params,int reqcfm,lmac_msg_id_t reqid,void *cfm); +void * bl_msg_zalloc(lmac_msg_id_t id,lmac_task_id_t dest_id,uint16_t param_len); +void bl_msg_update_channel_cfg(char *code); +int bl_msg_get_channel_nums(void); +int bl_send_reset(bl_hw *bl_hw); +int bl_send_monitor_enable(bl_hw *bl_hw,mm_monitor_cfm *cfm); +int bl_send_monitor_channel_set(bl_hw *bl_hw,mm_monitor_channel_cfm *cfm,int channel,int use_40Mhz); +int bl_send_version_req(bl_hw *bl_hw,mm_version_cfm *cfm); +int bl_send_me_config_req(bl_hw *bl_hw); +int bl_send_me_chan_config_req(bl_hw *bl_hw); +int bl_send_me_rate_config_req(bl_hw *bl_hw,uchar sta_idx,uint16_t fixed_rate_cfg); +int bl_send_start(bl_hw *bl_hw); +int bl_send_add_if(bl_hw *bl_hw,uchar *mac,nl80211_iftype iftype,_Bool p2p,mm_add_if_cfm *cfm); +int bl_send_remove_if(bl_hw *bl_hw,uchar inst_nbr); +int bl_send_scanu_req(bl_hw *bl_hw); +int bl_send_scanu_raw_send(bl_hw *bl_hw,uint8_t *pkt,int len); +int bl_send_sm_connect_req(bl_hw *bl_hw,cfg80211_connect_params *sme,sm_connect_cfm *cfm); +int bl_send_sm_disconnect_req(bl_hw *bl_hw,u16 reason); +int bl_send_mm_powersaving_req(bl_hw *bl_hw,int mode); +int bl_send_mm_denoise_req(bl_hw *bl_hw,int mode); +int bl_send_apm_start_req(bl_hw *bl_hw,apm_start_cfm *cfm,char *ssid,char *password,int channel,uchar vif_index,uchar hidden_ssid); +int bl_send_apm_stop_req(bl_hw *bl_hw,uchar vif_idx); +int bl_send_apm_sta_del_req(bl_hw *bl_hw,apm_sta_del_cfm *cfm,uchar sta_idx,uchar vif_idx); +int bl_send_apm_conf_max_sta_req(bl_hw *bl_hw,uchar max_sta_supported); +int bl_send_cfg_task_req(bl_hw *bl_hw,uint32_t ops,uint32_t task,uint32_t element,uint32_t type,void *arg1,void *arg2); +int bl_platform_on(bl_hw *bl_hw); +int bl_rx_chan_pre_switch_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_rssi_status_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_apm_sta_del_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_apm_sta_add_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +void notify_event_scan_done(int join_scan); +int bl_rx_scanu_join_cfm(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_scanu_start_cfm(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_chan_switch_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_sm_connect_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_sm_disconnect_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +undefined4 bl_rx_scanu_result_ind(int param_1,longlong param_2); +undefined4 bl_rx_mesh_path_update_ind(void); +undefined4 bl_rx_mesh_proxy_update_ind(void); +undefined4 bl_rx_remain_on_channel_exp_ind(void); +undefined4 bl_rx_ps_change_ind(void); +undefined4 bl_rx_traffic_req_ind(void); +undefined4 bl_rx_csa_counter_ind(void); +undefined4 bl_rx_csa_finish_ind(void); +undefined4 bl_rx_csa_traffic_ind(void); +undefined4 bl_rx_channel_survey_ind(void); +undefined4 bl_rx_dbg_error_ind(void); +undefined4 bl_rx_tdls_chan_switch_cfm(void); +undefined4 bl_rx_tdls_chan_switch_ind(void); +undefined4 bl_rx_tdls_chan_switch_base_ind(void); +undefined4 bl_rx_tdls_peer_ps_ind(void); +undefined4 bl_rx_me_tkip_mic_failure_ind(void); +undefined4 bl_rx_me_tx_credits_update_ind(void); +undefined4 bl_rx_mesh_path_create_cfm(void); +undefined4 bl_rx_mesh_peer_update_ind(void); +int bl_rx_sm_connect_ind_cb_register(void *env,wifi_event_sm_connect_ind_cb_t *cb); +int bl_rx_sm_disconnect_ind_cb_register(void *env,wifi_event_sm_disconnect_ind_cb_t *cb); +int bl_rx_beacon_ind_cb_register(void *env,wifi_event_beacon_ind_cb_t *cb); +int bl_rx_probe_resp_ind_cb_register(void *env,wifi_event_probe_resp_ind_cb_t *cb); +int bl_rx_pkt_cb_register(void *env,wifi_event_pkt_cb_t *cb); +int bl_rx_pkt_cb_unregister(void *env); +int bl_rx_rssi_cb_register(void *env,wifi_event_rssi_cb_t *cb); +int bl_rx_event_register(void *env,wifi_event_cb_t *cb); +void bl_rx_e2a_handler(void *arg); +void bl_rx_pkt_cb(uint8_t *pkt,int len); +void bl_tx_push(bl_hw *bl_hw,bl_txhdr.conflict1 *txhdr); +void bl_tx_resend(void); +void bl_tx_try_flush(void); +int bl_txdatacfm(void *pthis,void *host_id); +void bl_tx_notify(void); +err_t bl_output(bl_hw *bl_hw,netif *netif,pbuf *p,int is_sta); +u8 bl_radarind(void *pthis,void *hostid); +u8 bl_msgackind(bl_hw *pthis,void *hostid); +void bl_prim_tbtt_ind(void *pthis); +void my_pbuf_free_custom(pbuf *p); +undefined4 bl_dbgind(void); +void bl_sec_tbtt_ind(void); +void my_pbuf_free_custom_fake(void); +int tcpip_stack_input(void *swdesc,uchar status,void *hwhdr,uint msdu_offset,wifi_pkt *pkt); +int bl_utils_idx_lookup(bl_hw *bl_hw,uint8_t *mac); +int bl_ipc_init(bl_hw *bl_hw,ipc_shared_env_tag.conflict21 *ipc_shared_mem); +void bl_utils_dump(void); +_Bool stateSnifferGuard(void *ch,event *event); +_Bool stateConnectedIPYesGuard_ip_update(void *ch,event *event); +void printErrMsg(void *stateData,event *event); +void stateSnifferExit(void *stateData,event *event); +void stateSnifferAction(void *oldStateData,event *event,void *newStateData); +void stateConnectedIPNoAction_ipgot(void *oldStateData,event *event,void *newStateData); +void stateGlobalEnter(void *stateData,event *event); +void stateGlobalAction(void *oldStateData,event *event,void *newStateData); +void stateConnectingEnter(void *stateData,event *event); +_Bool stateSnifferGuard_ChannelSet(void *ch,event *event); +_Bool stateIdleGuard_sniffer(void *ev,event *event); +void stateConnectedIPNoExit(void *stateData,event *event); +void stateDisconnect_action_idle(void *oldStateData,event *event,void *newStateData); +void stateDisconnect_action_reconnect(void *oldStateData,event *event,void *newStateData); +void ip_obtaining_timeout(timer_cb_arg_t data); +void stateConnectedIPNoEnter(void *stateData,event *event); +_Bool stateConnectedIPNoGuard_disconnect(void *ch,event *event); +_Bool stateConnectedIPYesGuard_disconnect(void *ch,event *event); +_Bool stateConnectedIPYesGuard_rcconfig(void *ch,event *event); +void stateIdleAction_connect(void *oldStateData,event *event,void *newStateData); +_Bool stateGlobal_cfg_req(void *ch,event *event); +_Bool stateGlobalGuard_fw_powersaving(void *ch,event *event); +_Bool stateGlobalGuard_conf_max_sta(void *ev,event *event); +_Bool stateGlobalGuard_AP(void *ev,event *event); +_Bool stateGlobalGuard_scan_beacon(void *ch,event *event); +void __reload_tsen(timer_cb_arg_t data); +void event_cb_wifi_event_mgmr(input_event_t *event,void *private_data); +void trigger_auto_denoise(void *arg); +void stateDisconnect_exit(void *stateData,event *event); +void disconnect_retry(timer_cb_arg_t data); +_Bool stateGlobalGuard_fw_disconnect(void *ch,event *event); +void stateConnectedIPYes_exit(void *stateData,event *event); +_Bool stateGlobalGuard_denoise(void *ev,event *event); +_Bool stateIdleGuard_connect(void *ev,event *event); +_Bool stateIfaceDownGuard_phyup(void *ev,event *event); +_Bool stateSnifferGuard_raw_send(void *ch,event *event); +_Bool stateGlobalGuard_stop(void *ev,event *event); +_Bool stateGlobalGuard_enable_autoreconnect(void *ch,event *event); +_Bool stateGlobalGuard_disable_autoreconnect(void *ch,event *event); +void stateDisconnect_enter(void *stateData,event *event); +_Bool stateGlobalGuard_fw_scan(void *ch,event *event); +uint stateDisconnect_guard(uint param_1,int param_2); +void stateGlobalExit(void); +void stateSnifferEnter(void); +uint stateConnectingGuard(uint param_1,int param_2); +void stateConnectingAction_connected(void); +void stateConnectingAction_disconnect(void); +void stateConnectingExit(void); +void stateIdleAction_sniffer(void); +void stateIdleEnter(void); +void stateIdleExit(void); +void stateIfaceDownAction_phyup(void); +void stateIfaceDownEnter(void); +void stateIfaceDownExit(void); +uint stateConnectedIPNoGuard(uint param_1,int param_2); +void stateConnectedIPNoAction_disconnect(void); +uint stateConnectedIPYesGuard(uint param_1,int param_2); +void stateConnectedIPYes_action(void); +void stateConnectedIPYes_enter(void *stateData,event *event); +char * wifi_mgmr_auth_to_str(uint8_t auth); +char * wifi_mgmr_cipher_to_str(uint8_t cipher); +int wifi_mgmr_event_notify(wifi_mgmr_msg_t *msg); +void wifi_mgmr_start(void); +void _wifi_mgmr_entry(void *pvParameters); +void wifi_mgmr_start_background(wifi_conf_t *conf); +int wifi_mgmr_init(void); +int wifi_mgmr_state_get_internal(int *state); +void wifi_mgmr_set_connect_stat_info(wifi_event_sm_connect_ind *ind,uint8_t type_ind); +int wifi_mgmr_set_country_code_internal(char *country_code); +int wifi_mgmr_ap_sta_cnt_get_internal(uint8_t *sta_cnt); +int wifi_mgmr_ap_sta_info_get_internal(wifi_mgmr_sta_basic_info_t *sta_info_internal,uint8_t idx); +int wifi_mgmr_ap_sta_delete_internal(uint8_t sta_idx); +int wifi_mgmr_scan_complete_notify(void); +int wifi_mgmr_api_connect(char *ssid,char *psk,char *pmk,uint8_t *mac,uint8_t band,uint16_t freq); +int wifi_mgmr_api_cfg_req(uint32_t ops,uint32_t task,uint32_t element,uint32_t type,uint32_t length,uint32_t *buf); +int wifi_mgmr_api_ip_got(uint32_t ip,uint32_t mask,uint32_t gw,uint32_t dns1,uint32_t dns2); +int wifi_mgmr_api_ip_update(void); +int wifi_mgmr_api_reconnect(void); +int wifi_mgmr_api_disable_autoreconnect(void); +int wifi_mgmr_api_enable_autoreconnect(void); +int wifi_mgmr_api_disconnect(void); +int wifi_mgmr_api_rate_config(uint16_t config); +int wifi_mgmr_api_conf_max_sta(uint8_t max_sta_supported); +int wifi_mgmr_api_ifaceup(void); +int wifi_mgmr_api_sniffer_enable(void); +int wifi_mgmr_api_scan_item_beacon(uint8_t channel,int8_t rssi,uint8_t auth,uint8_t *mac,uint8_t *ssid,int len,int8_t ppm_abs,int8_t ppm_rel,uint8_t cipher); +int wifi_mgmr_api_fw_disconnect(void); +int wifi_mgmr_api_fw_tsen_reload(void); +int wifi_mgmr_api_fw_scan(void); +int wifi_mgmr_api_fw_powersaving(int mode); +int wifi_mgmr_api_ap_start(char *ssid,char *passwd,int channel,uint8_t hidden_ssid); +int wifi_mgmr_api_ap_stop(void); +int wifi_mgmr_api_idle(void); +int wifi_mgmr_api_denoise_enable(void); +int wifi_mgmr_api_denoise_disable(void); +int wifi_mgmr_api_raw_send(uint8_t *pkt,int len); +int wifi_mgmr_api_set_country_code(char *country_code); +void cmd_rf_dump(char *buf,int len,int argc,char **argv); +void cmd_dump_reset(char *buf,int len,int argc,char **argv); +void cmd_wifi_power_table_update(char *buf,int len,int argc,char **argv); +void cmd_wifi_state_get(char *buf,int len,int argc,char **argv); +void wifi_sta_get_state_cmd(char *buf,int len,int argc,char **argv); +void wifi_edca_dump_cmd(char *buf,int len,int argc,char **argv); +void wifi_ap_sta_list_get_cmd(char *buf,int len,int argc,char **argv); +void wifi_ap_sta_delete_cmd(char *buf,int len,int argc,char **argv); +void cmd_wifi_coex_pta_force_off(char *buf,int len,int argc,char **argv); +void cmd_wifi_coex_pta_force_on(char *buf,int len,int argc,char **argv); +void cmd_wifi_coex_pti_force_off(char *buf,int len,int argc,char **argv); +void cmd_wifi_coex_pti_force_on(char *buf,int len,int argc,char **argv); +void cmd_wifi_coex_rf_force_off(char *buf,int len,int argc,char **argv); +void cmd_wifi_coex_rf_force_on(char *buf,int len,int argc,char **argv); +void cmd_wifi_mib(char *buf,int len,int argc,char **argv); +void cmd_wifi_cfg(char *buf,int len,int argc,char **argv); +void cmd_wifi_ap_stop(char *buf,int len,int argc,char **argv); +void cmd_wifi_ap_start(char *buf,int len,int argc,char **argv); +void wifi_sniffer_off_cmd(char *buf,int len,int argc,char **argv); +void wifi_sniffer_on_cmd(char *buf,int len,int argc,char **argv); +int wifi_denoise_disable_cmd(void); +int wifi_denoise_enable_cmd(void); +void wifi_power_saving_off_cmd(char *buf,int len,int argc,char **argv); +void wifi_power_saving_on_cmd(char *buf,int len,int argc,char **argv); +void wifi_rc_fixed_disable(char *buf,int len,int argc,char **argv); +int wifi_disable_autoreconnect_cmd(void); +int wifi_enable_autoreconnect_cmd(void); +void wifi_disconnect_cmd(char *buf,int len,int argc,char **argv); +int wifi_sta_ip_unset_cmd(void); +void wifi_sta_ip_info(char *buf,int len,int argc,char **argv); +void cmd_wifi_raw_send(char *buf,int len,int argc,char **argv); +void wifi_scan_cmd(char *buf,int len,int argc,char **argv); +void sniffer_cb(void *env,uint8_t *pkt,int len); +void cmd_wifi_dump(char *buf,int len,int argc,char **argv); +void cmd_wifi_ap_conf_max_sta(char *buf,int len,int argc,char **argv); +void wifi_mon_cmd(char *buf,int len,int argc,char **argv); +void wifi_rc_fixed_enable(char *buf,int len,int argc,char **argv); +void wifi_connect_cmd(char *buf,int len,int argc,char **argv); +void wifi_sta_ip_set_cmd(char *buf,int len,int argc,char **argv); +void wifi_scan_filter_cmd(char *buf,int len,int argc,char **argv); +void wifi_capcode_cmd(char *buf,int len,int argc,char **argv); +int wifi_mgmr_cli_scanlist(void); +int wifi_mgmr_ext_dump_needed(void); +int wifi_mgmr_cli_init(void); +int mac_is_unvalid(uint8_t *mac); +int wifi_mgmr_psk_cal(char *password,char *ssid,int ssid_len,char *output); +int wifi_mgmr_drv_init(wifi_conf_t *conf); +wifi_interface_t wifi_mgmr_sta_enable(void); +int wifi_mgmr_sta_disable(wifi_interface_t *interface); +int wifi_mgmr_sta_ip_get(uint32_t *ip,uint32_t *gw,uint32_t *mask); +int wifi_mgmr_sta_dns_get(uint32_t *dns1,uint32_t *dns2); +int wifi_mgmr_sta_ip_set(uint32_t ip,uint32_t mask,uint32_t gw,uint32_t dns1,uint32_t dns2); +int wifi_mgmr_sta_ip_unset(void); +int wifi_mgmr_sta_disconnect(void); +int wifi_mgmr_sta_powersaving(int ps); +int wifi_mgmr_sta_autoconnect_enable(void); +int wifi_mgmr_sta_autoconnect_disable(void); +void wifi_mgmr_sta_ssid_set(char *ssid); +void wifi_mgmr_sta_psk_set(char *psk); +int wifi_mgmr_sta_connect(wifi_interface_t *wifi_interface,char *ssid,char *psk,char *pmk,uint8_t *mac,uint8_t band,uint16_t freq); +wifi_interface_t wifi_mgmr_ap_enable(void); +int wifi_mgmr_ap_start(wifi_interface_t *interface,char *ssid,int hidden_ssid,char *passwd,int channel); +int wifi_mgmr_ap_stop(wifi_interface_t *interface); +int wifi_mgmr_ap_sta_cnt_get(uint8_t *sta_cnt); +int wifi_mgmr_ap_sta_info_get(wifi_sta_basic_info *sta_info,uint8_t idx); +int wifi_mgmr_ap_sta_delete(uint8_t sta_idx); +int wifi_mgmr_sniffer_register(void *env,sniffer_cb_t *cb); +int wifi_mgmr_sniffer_unregister(void *env); +int wifi_mgmr_sniffer_enable(void); +int wifi_mgmr_sniffer_disable(void); +int wifi_mgmr_rate_config(uint16_t config); +int wifi_mgmr_conf_max_sta(uint8_t max_sta_supported); +int wifi_mgmr_state_get(int *state); +int wifi_mgmr_rssi_get(int *rssi); +int wifi_mgmr_raw_80211_send(uint8_t *pkt,int len); +int wifi_mgmr_scan(void *data,scan_complete_cb_t *cb); +int wifi_mgmr_cfg_req(uint32_t ops,uint32_t task,uint32_t element,uint32_t type,uint32_t length,uint32_t *buf); +int wifi_mgmr_scan_filter_hidden_ssid(int filter); +int wifi_mgmr_scan_complete_callback(void); +char * wifi_mgmr_status_code_str(uint16_t status_code); +int wifi_mgmr_profile_add(wifi_mgmr_t *mgmr,wifi_mgmr_profile_msg_t *profile_msg,int index); +int wifi_mgmr_profile_get(wifi_mgmr_t *mgmr,wifi_mgmr_profile_msg_t *profile_msg); +int wifi_mgmr_profile_autoreconnect_is_enabled(wifi_mgmr_t *mgmr,int index); +int wifi_mgmr_profile_autoreconnect_disable(wifi_mgmr_t *mgmr,int index); +int wifi_mgmr_profile_autoreconnect_enable(wifi_mgmr_t *mgmr,int index); +int wifi_netif_dhcp_start(netif *netif); +void cb_rssi_ind(void *env,int8_t rssi); +void cb_probe_resp_ind(void *env); +void cb_beacon_ind(void *env,wifi_event_beacon_ind.conflict4 *ind); +void cb_disconnect_ind(void *env,wifi_event_sm_disconnect_ind *ind); +void cb_connect_ind(void *env,wifi_event_sm_connect_ind *ind); +void cb_event_ind(void *env,wifi_event *event); +int wifi_mgmr_event_init(void); +void cmd_mgr_print(bl_cmd_mgr *cmd_mgr); +void cmd_complete(bl_cmd *cmd); +int cmd_mgr_msgind(bl_cmd_mgr *cmd_mgr,ipc_e2a_msg *msg,msg_cb_fct *cb); +int cmd_mgr_llind(bl_cmd_mgr *cmd_mgr,bl_cmd *cmd); +undefined4 cmd_mgr_queue(char *param_1,char **param_2); +void cmd_mgr_drain(bl_cmd_mgr *cmd_mgr); +void bl_cmd_mgr_init(bl_cmd_mgr *cmd_mgr); +int bl_irqs_init(bl_hw *bl_hw); +void bl_irq_bottomhalf(bl_hw *bl_hw); +void goToErrorState(stateMachine *fsm,event *event); +void stateM_init(stateMachine *fsm,state *initialState,state *errorState); +int stateM_handleEvent(stateMachine *fsm,event *event); +void netif_status_callback(netif *netif); +err_t wifi_tx(netif *netif,pbuf *p); +err_t bl606a0_wifi_netif_init(netif *netif); +int bl606a0_wifi_init(wifi_conf_t *conf); +uint32_t fdt32_ld(fdt32_t *p); +int nextprop_(void *fdt,int offset); +fdt_property * fdt_get_property_by_offset_(void *fdt,int offset,int *lenp); +char * fdt_get_string(void *fdt,int stroffset,int *lenp); +char * fdt_get_name(void *fdt,int nodeoffset,int *len); +int fdt_subnode_offset_namelen(void *fdt,int offset,char *name,int namelen); +int fdt_subnode_offset(void *fdt,int parentoffset,char *name); +int fdt_first_property_offset(void *fdt,int nodeoffset); +int fdt_next_property_offset(void *fdt,int offset); +fdt_property *fdt_get_property_namelen_(void *fdt,int offset,char *name,int namelen,int *lenp,int *poffset); +void * fdt_getprop_namelen(void *fdt,int nodeoffset,char *name,int namelen,int *lenp); +void * fdt_getprop(void *fdt,int nodeoffset,char *name,int *lenp); +int fdt_stringlist_count(void *fdt,int nodeoffset,char *property); +char * fdt_stringlist_get(void *fdt,int nodeoffset,char *property,int idx,int *lenp); +void blfdt(char *buf,int len,int argc,char **argv); +int blfdt_cli_init(void); +uint32_t fdt32_ld(fdt32_t *p); +int fdt_ro_probe_(void *fdt); +void * fdt_offset_ptr(void *fdt,int offset,uint len); +uint32_t fdt_next_tag(void *fdt,int startoffset,int *nextoffset); +int fdt_check_node_offset_(void *fdt,int offset); +int fdt_check_prop_offset_(void *fdt,int offset); +int fdt_next_node(void *fdt,int offset,int *depth); +uint32_t fdt32_to_cpu(fdt32_t x); +uint64_t fdt64_to_cpu(void); +uint32_t fdt32_ld(fdt32_t *p); +_Bool util_is_printable_string(void *data,int len); +void utilfdt_print_data(char *data,int len); +undefined4 tc_blfdtdump(void); +undefined4 tc_fdt_wifi_module(void); +int tc_fdt_wifi(void); +void cmd_blog_info_dump(char *buf,int len,int argc,char **argv); +void cmd_blog_set_level(char *buf,int len,int argc,char **argv); +void blog_init(void); +int ota_dump_cmd(void); +void ota_tcp_cmd(char **argv); +void ota_tcp_cmd(char *buf,int len,int argc,char **argv); +int bl_sys_ota_cli_init(void); +void cmd_sys_time_now(char *buf,int len,int argc,char **argv); +int bl_sys_time_cli_init(void); +void bl_sys_time_update(undefined4 param_1,undefined4 param_2); +int bl_sys_time_get(uint64_t *epoch); +int bl_sys_time_sync_state(uint32_t *xTicksToJump); +cli_command * cli_command_get(int idx,int *is_static_cmd); +void exit_cmd(char *buf,int len,int argc,char **argv); +int cb_idnoe(void *arg,inode_t *node); +void ota_cmd(char *buf,int len,int argc,char **argv); +void tftp_ota_thread(void *arg); +void cat_cmd(char *buf,int len,int argc,char **argv); +void hexdump_cmd(char *buf,int len,int argc,char **argv); +int aos_cli_init(int use_thread); +void * aos_cli_event_cb_read_get(void); +int cli_putstr(char *msg); +void ps_cmd(char *buf,int len,int argc,char **argv); +int aos_cli_printf(char *msg,...); +int proc_onecmd(int argc,char **argv); +void ls_cmd(char *buf,int len,int argc,char **argv); +void uptime_cmd(char *buf,int len,int argc,char **argv); +void reset_cmd(char *buf,int len,int argc,char **argv); +void poweroff_cmd(char *buf,int len,int argc,char **argv); +void reboot_cmd(char *buf,int len,int argc,char **argv); +void version_cmd(char *buf,int len,int argc,char **argv); +void devname_cmd(char *buf,int len,int argc,char **argv); +void echo_cmd(char *buf,int len,int argc,char **argv); +void mmem_cmd(char *buf,int len,int argc,char **argv); +void pmem_cmd(char *buf,int len,int argc,char **argv); +void help_cmd(char *buf,int len,int argc,char **argv); +int cli_getchar(char *inbuf); +void cli_main_input(char *buffer,int count); +void console_cb_read(int fd,void *param); +void get_dns_request(void *arg,udp_pcb *upcb,pbuf *p,ip_addr_t *addr,u16_t port); +void dns_server_init(void); +EfErrCode easyflash_init(void); +size_t get_status(uint8_t *status_table,size_t status_num); +void update_sector_cache(uint32_t sec_addr,uint32_t empty_addr); +uint32_t get_next_sector_addr(sector_meta_data_t pre_sec); +_Bool gc_check_cb(sector_meta_data_t sector,void *arg1,void *arg2); +void update_env_cache(char *name,size_t name_len,uint32_t addr); +_Bool find_env_cb(env_node_obj_t env,void *arg1,void *arg2); +_Bool sector_statistics_cb(sector_meta_data_t sector,void *arg1,void *arg2); +_Bool alloc_env_cb(sector_meta_data_t sector,void *arg1,void *arg2); +EfErrCode write_status(uint32_t addr,uint8_t *status_table,size_t status_num,size_t status_index); +EfErrCode read_env(env_node_obj_t env); +EfErrCode update_sec_status(sector_meta_data_t sector,size_t new_env_len,_Bool *is_full); +EfErrCode format_sector(uint32_t addr); +_Bool check_sec_hdr_cb(sector_meta_data_t sector,void *arg1,void *arg2); +_Bool print_env_cb(env_node_obj_t env,void *arg1,void *arg2); +uint32_t get_next_env_addr(sector_meta_data_t sector,env_node_obj_t pre_env); +EfErrCode read_sector_meta_data(uint32_t addr,sector_meta_data_t sector,_Bool traversal); +void sector_iterator(sector_meta_data_t sector,sector_store_status_t status,void *arg1,void *arg2,anon_subr__Bool_sector_meta_data_t_void_ptr_void_ptr *callback,_Bool traversal_env); +uint32_t alloc_env(sector_meta_data_t sector,size_t env_size); +void gc_collect(void); +uint32_t new_env(sector_meta_data_t sector,size_t env_size); +_Bool check_and_recovery_gc_cb(sector_meta_data_t sector,void *arg1,void *arg2); +void env_iterator(env_node_obj_t env,void *arg1,void *arg2,anon_subr__Bool_env_node_obj_t_void_ptr_void_ptr *callback); +_Bool find_env(char *key,env_node_obj_t env); +EfErrCode del_env(char *key,env_node_obj_t old_env,_Bool complete_del); +EfErrCode move_env(env_node_obj_t env); +_Bool check_and_recovery_env_cb(env_node_obj_t env,void *arg1,void *arg2); +_Bool do_gc(sector_meta_data_t sector,void *arg1,void *arg2); +EfErrCode create_env_blob(sector_meta_data_t sector,char *key,void *value,size_t len); +size_t ef_get_env_blob(char *key,void *value_buf,size_t buf_len,size_t *saved_value_len); +EfErrCode ef_del_env(char *key); +EfErrCode ef_set_env_blob(char *key,void *value_buf,size_t buf_len); +EfErrCode ef_set_env(char *key,char *value); +EfErrCode ef_save_env(void); +EfErrCode ef_env_set_default(void); +void ef_print_env(void); +EfErrCode ef_load_env(void); +EfErrCode ef_env_init(ef_env *default_env,size_t default_env_size); +EfErrCode ef_port_read(uint32_t addr,uint32_t *buf,size_t size); +EfErrCode ef_port_write(uint32_t addr,uint32_t *buf,size_t size); +void ef_port_env_lock(void); +void ef_port_env_unlock(void); +void ef_log_debug(char *file,long line,char *format,...); +EfErrCode ef_port_erase(uint32_t addr,size_t size); +void ef_log_info(char *format,...); +EfErrCode ef_port_init(ef_env **default_env,size_t *default_env_size); +void ef_print(char *format,...); +uint32_t ef_calc_crc32(uint32_t crc,void *buf,size_t size); +void psm_get_cmd(char *buf,int len,int argc,char **argv); +void psm_test_cmd(void); +EfErrCode psm_erase_cmd(void); +void psm_dump_cmd(void); +void psm_unset_cmd(char *buf,int len,int argc,char **argv); +void psm_set_cmd(char *buf,int len,int argc,char **argv); +int easyflash_cli_init(void); +EventGroupHandle_t xEventGroupCreateStatic(StaticEventGroup_t *pxEventGroupBuffer); +EventBits_t xEventGroupWaitBits(EventGroupHandle_t xEventGroup,EventBits_t uxBitsToWaitFor,BaseType_t xClearOnExit,BaseType_t xWaitForAllBits,TickType_t xTicksToWait); +EventBits_t xEventGroupSetBits(EventGroupHandle_t xEventGroup,EventBits_t uxBitsToSet); +void vEventGroupDelete(EventGroupHandle_t xEventGroup); +void vListInitialise(List_t *pxList); +void vListInitialiseItem(ListItem_t *pxItem); +void vListInsertEnd(List_t *pxList,ListItem_t *pxNewListItem); +void vListInsert(List_t *pxList,ListItem_t *pxNewListItem); +UBaseType_t uxListRemove(ListItem_t *pxItemToRemove); +BaseType_t prvCopyDataToQueue(Queue_t *pxQueue,void *pvItemToQueue,BaseType_t xPosition); +void prvCopyDataFromQueue(Queue_t *pxQueue,void *pvBuffer); +void prvUnlockQueue(Queue_t *pxQueue); +BaseType_t xQueueGenericReset(QueueHandle_t xQueue,BaseType_t xNewQueue); +QueueHandle_t xQueueGenericCreateStatic(UBaseType_t uxQueueLength,UBaseType_t uxItemSize,uint8_t *pucQueueStorage,StaticQueue_t *pxStaticQueue,uint8_t ucQueueType); +QueueHandle_t xQueueGenericCreate(UBaseType_t uxQueueLength,UBaseType_t uxItemSize,uint8_t ucQueueType); +QueueHandle_t xQueueCreateCountingSemaphore(UBaseType_t uxMaxCount,UBaseType_t uxInitialCount); +BaseType_t xQueueGenericSend(QueueHandle_t xQueue,void *pvItemToQueue,TickType_t xTicksToWait,BaseType_t xCopyPosition); +QueueHandle_t xQueueCreateMutexStatic(uint8_t ucQueueType,StaticQueue_t *pxStaticQueue); +BaseType_t xQueueGiveMutexRecursive(QueueHandle_t xMutex); +QueueHandle_t xQueueCreateMutex(uint8_t ucQueueType); +BaseType_t xQueueGenericSendFromISR(QueueHandle_t xQueue,void *pvItemToQueue,BaseType_t *pxHigherPriorityTaskWoken,BaseType_t xCopyPosition); +BaseType_t xQueueGiveFromISR(QueueHandle_t xQueue,BaseType_t *pxHigherPriorityTaskWoken); +BaseType_t xQueueReceive(QueueHandle_t xQueue,void *pvBuffer,TickType_t xTicksToWait); +BaseType_t xQueueSemaphoreTake(QueueHandle_t xQueue,TickType_t xTicksToWait); +BaseType_t xQueueTakeMutexRecursive(QueueHandle_t xMutex,TickType_t xTicksToWait); +UBaseType_t uxQueueMessagesWaiting(QueueHandle_t xQueue); +void vQueueDelete(QueueHandle_t xQueue); +void vQueueAddToRegistry(QueueHandle_t xQueue,char *pcQueueName); +void vQueueWaitForMessageRestricted(QueueHandle_t xQueue,TickType_t xTicksToWait,BaseType_t xWaitIndefinitely); +void prvInitialiseNewStreamBuffer(StreamBuffer_t *pxStreamBuffer,uint8_t *pucBuffer,size_t xBufferSizeBytes,size_t xTriggerLevelBytes,uint8_t ucFlags); +size_t prvWriteBytesToBuffer(StreamBuffer_t *pxStreamBuffer,uint8_t *pucData,size_t xCount); +size_t prvReadBytesFromBuffer(StreamBuffer_t *pxStreamBuffer,uint8_t *pucData,size_t xMaxCount,size_t xBytesAvailable); +StreamBufferHandle_t xStreamBufferGenericCreate(size_t xBufferSizeBytes,size_t xTriggerLevelBytes,BaseType_t xIsMessageBuffer); +StreamBufferHandle_t xStreamBufferGenericCreateStatic(size_t xBufferSizeBytes,size_t xTriggerLevelBytes,BaseType_t xIsMessageBuffer,uint8_t *pucStreamBufferStorageArea,StaticStreamBuffer_t *pxStaticStreamBuffer); +void vStreamBufferDelete(StreamBufferHandle_t xStreamBuffer); +size_t xStreamBufferSpacesAvailable(StreamBufferHandle_t xStreamBuffer); +size_t xStreamBufferSend(StreamBufferHandle_t xStreamBuffer,void *pvTxData,size_t xDataLengthBytes,TickType_t xTicksToWait); +size_t xStreamBufferSendFromISR(StreamBufferHandle_t xStreamBuffer,void *pvTxData,size_t xDataLengthBytes,BaseType_t *pxHigherPriorityTaskWoken); +size_t xStreamBufferReceive(StreamBufferHandle_t xStreamBuffer,void *pvRxData,size_t xBufferLengthBytes,TickType_t xTicksToWait); +size_t xStreamBufferReceiveFromISR(StreamBufferHandle_t xStreamBuffer,void *pvRxData,size_t xBufferLengthBytes,BaseType_t *pxHigherPriorityTaskWoken); +BaseType_t xStreamBufferIsEmpty(StreamBufferHandle_t xStreamBuffer); +void prvResetNextTaskUnblockTime(void); +void prvInitialiseNewTask(TaskFunction_t *pxTaskCode,char *pcName,uint32_t ulStackDepth,void *pvParameters,UBaseType_t uxPriority,TaskHandle_t *pxCreatedTask,TCB_t *pxNewTCB); +void prvDeleteTCB(TCB_t *pxTCB); +void prvAddCurrentTaskToDelayedList(TickType_t xTicksToWait,BaseType_t xCanBlockIndefinitely); +void vTaskEnterCritical(void); +void vTaskExitCritical(void); +void prvAddNewTaskToReadyList(TCB_t *pxNewTCB); +TaskHandle_t xTaskCreateStatic(TaskFunction_t *pxTaskCode,char *pcName,uint32_t ulStackDepth,void *pvParameters,UBaseType_t uxPriority,StackType_t *puxStackBuffer,StaticTask_t *pxTaskBuffer); +BaseType_t xTaskCreate(TaskFunction_t *pxTaskCode,char *pcName,uint16_t usStackDepth,void *pvParameters,UBaseType_t uxPriority,TaskHandle_t *pxCreatedTask); +void vTaskDelete(TaskHandle_t xTaskToDelete); +void vTaskSuspendAll(void); +TickType_t xTaskGetTickCount(void); +BaseType_t xTaskGetTickCount2(TickType_t *ticks,BaseType_t *overflow); +TickType_t xTaskGetTickCountFromISR(void); +char * pcTaskGetName(TaskHandle_t xTaskToQuery); +BaseType_t xTaskIncrementTick(void); +void vTaskDelay(TickType_t xTicksToDelay); +void vTaskSwitchContext(void); +void vTaskPlaceOnEventList(List_t *pxEventList,TickType_t xTicksToWait); +void vTaskPlaceOnUnorderedEventList(List_t *pxEventList,TickType_t xItemValue,TickType_t xTicksToWait); +void vTaskPlaceOnEventListRestricted(List_t *pxEventList,TickType_t xTicksToWait,BaseType_t xWaitIndefinitely); +BaseType_t xTaskRemoveFromEventList(List_t *pxEventList); +void vTaskRemoveFromUnorderedEventList(ListItem_t *pxEventListItem,TickType_t xItemValue); +void vTaskInternalSetTimeOutState(TimeOut_t *pxTimeOut); +void vTaskMissedYield(void); +void vTaskGetInfo(TaskHandle_t xTask,TaskStatus_t *pxTaskStatus,BaseType_t xGetFreeStackSpace,eTaskState eState); +UBaseType_t prvListTasksWithinSingleList(TaskStatus_t *pxTaskStatusArray,List_t *pxList,eTaskState eState); +UBaseType_t uxTaskGetSystemState(TaskStatus_t *pxTaskStatusArray,UBaseType_t uxArraySize,uint32_t *pulTotalRunTime); +UBaseType_t uxTaskGetStackHighWaterMark(TaskHandle_t xTask); +TaskHandle_t xTaskGetCurrentTaskHandle(void); +BaseType_t xTaskGetSchedulerState(void); +BaseType_t xTaskPriorityInherit(TaskHandle_t pxMutexHolder); +BaseType_t xTaskPriorityDisinherit(TaskHandle_t pxMutexHolder); +void vTaskPriorityDisinheritAfterTimeout(TaskHandle_t pxMutexHolder,UBaseType_t uxHighestPriorityWaitingTask); +void vTaskEnterCritical(void); +void vTaskExitCritical(void); +void vTaskList(char *pcWriteBuffer); +TickType_t uxTaskResetEventItemValue(void); +TaskHandle_t pvTaskIncrementMutexHeldCount(void); +BaseType_t xTaskGenericNotifyFromISR(TaskHandle_t xTaskToNotify,uint32_t ulValue,eNotifyAction eAction,uint32_t *pulPreviousNotificationValue,BaseType_t *pxHigherPriorityTaskWoken); +void vTaskNotifyGiveFromISR(TaskHandle_t xTaskToNotify,BaseType_t *pxHigherPriorityTaskWoken); +BaseType_t xTaskNotifyStateClear(TaskHandle_t xTask); +void prvCheckForValidListAndQueue(void); +BaseType_t prvInsertTimerInActiveList(Timer_t *pxTimer,TickType_t xNextExpiryTime,TickType_t xTimeNow,TickType_t xCommandTime); +BaseType_t xTimerCreateTimerTask(void); +TimerHandle_t xTimerCreateStatic(char *pcTimerName,TickType_t xTimerPeriodInTicks,UBaseType_t uxAutoReload,void *pvTimerID,TimerCallbackFunction_t *pxCallbackFunction,StaticTimer_t *pxTimerBuffer); +BaseType_t xTimerGenericCommand(TimerHandle_t xTimer,BaseType_t xCommandID,TickType_t xOptionalValue,BaseType_t *pxHigherPriorityTaskWoken,TickType_t xTicksToWait); +void prvSwitchTimerLists(void); +void prvTimerTask(void *pvParameters); +void * pvTimerGetTimerID(TimerHandle_t xTimer); +void vPortSetupTimerInterrupt(void); +void pxPortInitialiseStack(int param_1,undefined4 param_2,undefined4 param_3); +void prvInsertBlockIntoFreeList(BlockLink_t *pxBlockToInsert); +void * pvPortMalloc(size_t xWantedSize); +void vPortFree(void *pv); +size_t xPortGetFreeHeapSize(void); +void vPortDefineHeapRegions(HeapRegion_t *pxHeapRegions); +void uart_generic_notify_handler(uint8_t id); +void UART0_IRQHandler(void); +void UART1_IRQHandler(void); +int bl_uart_init(uint8_t id,uint8_t tx_pin,uint8_t rx_pin,uint8_t cts_pin,uint8_t rts_pin,uint32_t baudrate); +int bl_uart_data_send(uint8_t id,uint8_t data); +int bl_uart_data_recv(uint8_t id); +int bl_uart_int_rx_enable(uint8_t id); +int bl_uart_int_rx_disable(uint8_t id); +int bl_uart_int_tx_enable(uint8_t id); +int bl_uart_int_tx_disable(uint8_t id); +int bl_uart_flush(uint8_t id); +void bl_uart_getdefconfig(uint8_t id,uint8_t *parity); +void bl_uart_setconfig(uint8_t id,uint32_t baudrate,UART_Parity_Type parity); +void bl_uart_setbaud(uint8_t id,uint32_t baud); +int bl_uart_int_enable(uint8_t id); +int bl_uart_int_disable(uint8_t id); +int bl_uart_int_rx_notify_register(uint8_t id,cb_uart_notify_t *cb,void *arg); +int bl_uart_int_tx_notify_register(uint8_t id,cb_uart_notify_t *cb,void *arg); +int bl_chip_info(char *info); +int bl_chip_banner(char **banner); +int bl_chip_memory_ram(int *num,uint *addr,uint *size,char (*desc) [6]); +void _cb_cmd(void *arg); +undefined4 bl_cks_test(void); +void _cb_cmd(void *arg); +void bl_dma_int_process(void); +int bl_dma_int_clear(int ch); +void bl_dma_IRQHandler(void); +void bl_dma_copy(bl_dma_item *first); +int bl_dma_irq_register(int channel,void *tc_handler,void *interr_handler,void *ctx); +void bl_dma_init(void); +void bl_dma_test(void); +void _irq_num_check(int irqnum); +void bl_irq_enable(uint source); +void bl_irq_disable(uint source); +void bl_irq_exception_trigger(BL_IRQ_EXCEPTION_TYPE_T type,void *ptr); +void bl_irq_register_with_ctx(int irqnum,void *handler,void *ctx); +void bl_irq_ctx_get(int irqnum,void **ctx); +void bl_irq_register(int irqnum,void *handler); +void bl_irq_unregister(int irqnum,void *handler); +void interrupt_entry(uint32_t mcause); +void exception_entry(uint32_t mcause,uint32_t mepc,uint32_t mtval,uintptr_t *regs); +void bl_irq_init(void); +void _trng_trigger(void); +void wait_trng4feed(void); +void sec_trng_IRQHandler(uint param_1,int param_2); +void bl_sec_pka_IRQHandler(void); +uint32_t bl_sec_get_random_word(void); +void bl_rand_stream(uint8_t *buf,int len); +int bl_rand(void); +int bl_sec_init(void); +int bl_sec_test(void); +void _dump_rsa_data(uint8_t *data,int size); +void _pka_test_case_xgcd(void); +void _pka_test_case2(uint8_t param_1); +int bl_pka_test(void); +void int_timer_cb(void); +uint32_t bl_timer_now_us(void); +int bl_timer_tick_enable(void); +void cmd_gpio_get(char *buf,int len,int argc,char **argv); +void cmd_gpio_set(char *buf,int len,int argc,char **argv); +void cmd_gpio_func(char *buf,int len,int argc,char **argv); +int bl_gpio_cli_init(void); +int bl_efuse_read_mac(uint8_t *mac); +int bl_efuse_read_mac_factory(uint8_t *mac); +int bl_efuse_read_capcode(uint8_t *capcode); +int bl_efuse_read_pwroft(int8_t *poweroffset); +void Aes_Compare_Data(uint8_t *expected,uint8_t *input,uint32_t len); +void _dump_iv_status(SEC_Eng_AES_Link_Config_Type.conflict1 *linkCfg); +void bl_sec_aes_IRQHandler(void); +void Sec_Eng_AES_Link_Case_CBC_128(SEC_ENG_AES_ID_Type aesId); +void Sec_Eng_AES_Link_Case_CTR_128(SEC_ENG_AES_ID_Type aesId); +void Sec_Eng_AES_Link_Case_ECB_128(SEC_ENG_AES_ID_Type aesId); +int bl_sec_aes_test(void); +void bl_sec_sha_IRQHandler(void); +int bl_sha_mutex_take(void); +int bl_sha_mutex_give(void); +void bl_sha_init(bl_sha_ctx_t *ctx,bl_sha_type_t type); +int bl_sha_update(bl_sha_ctx_t *ctx,uint8_t *input,uint32_t len); +int bl_sha_finish(bl_sha_ctx_t *ctx,uint8_t *hash); +void sha256_test_case0(void); +int bl_sec_sha_test(void); +int bl_wifi_clock_enable(void); +int bl_wifi_enable_irq(void); +int bl_wifi_sta_mac_addr_set(uint8_t *mac); +int bl_wifi_ap_mac_addr_set(uint8_t *mac); +int bl_wifi_mac_addr_get(uint8_t *mac); +int bl_wifi_country_code_set(uint8_t country_code); +int bl_wifi_ap_info_set(uint8_t *ssid,uint8_t ssid_len,uint8_t *psk,uint8_t psk_len,uint8_t chan); +int bl_wifi_sta_info_set(uint8_t *ssid,uint8_t ssid_len,uint8_t *psk,uint8_t psk_len,int autoconnect); +int bl_wifi_sta_info_get(bl_wifi_ap_info_t *sta_info); +int cmd_timer_start(void); +void cmd_wdt_disable(void); +void cmd_wdt_feed(void); +void cmd_wdt_init(int param_1,undefined4 *param_2); +int bl_wdt_cli_init(void); +uint32_t fdt32_to_cpu(fdt32_t x); +int dev_uart_init(uint8_t id,char *path,uint32_t rx_buf_size,uint32_t tx_buf_size); +int32_t hal_uart_send_trigger(uart_dev_t *uart); +int32_t hal_uart_send_trigger_off(uart_dev_t *uart); +int32_t hal_uart_init(uart_dev_t *uart); +int32_t hal_uart_recv_II(uart_dev_t *uart,void *data,uint32_t expect_size,uint32_t *recv_size,uint32_t timeout); +int32_t hal_uart_send(uart_dev_t *uart,void *data,uint32_t size,uint32_t timeout); +int32_t hal_uart_finalize(uart_dev_t *uart); +int32_t hal_uart_notify_register(uart_dev_t *uart,hal_uart_int_t type,anon_subr_void_void_ptr *cb); +undefined4 vfs_uart_init(void *param_1,int param_2); +int32_t hal_uart_send_flush(uart_dev_t *uart,uint32_t timeout); +void hal_uart_setbaud(uart_dev_t *uart,uint32_t baud); +void hal_uart_setconfig(uart_dev_t *uart,uint32_t baud,hal_uart_parity_t parity); +undefined4 hal_gpio_init_from_dts(void *param_1,int param_2); +void _dump_partition(void); +int hal_boot2_update_ptable(HALPartition_Entry_Config *ptEntry_hal); +uint32_t hal_boot2_get_flash_addr(void); +int hal_boot2_partition_bus_addr(char *name,uint32_t *addr0,uint32_t *addr1,uint32_t *size0,uint32_t *size1,int *active); +int hal_boot2_partition_bus_addr_active(char *name,uint32_t *addr,uint32_t *size); +int hal_boot2_partition_bus_addr_inactive(char *name,uint32_t *addr,uint32_t *size); +int hal_boot2_partition_addr(char *name,uint32_t *addr0,uint32_t *addr1,uint32_t *size0,uint32_t *size1,int *active); +int hal_boot2_partition_addr_active(char *name,uint32_t *addr,uint32_t *size); +int hal_boot2_partition_addr_inactive(char *name,uint32_t *addr,uint32_t *size); +uint8_t hal_boot2_get_active_partition(void); +int hal_boot2_get_active_entries(int type,HALPartition_Entry_Config *ptEntry_hal); +int hal_boot2_dump(void); +int hal_boot2_init(void); +int hal_reboot(void); +void hal_sys_reset(void); +void hal_poweroff(void); +void hal_sys_capcode_update(uint8_t capin,uint8_t capout); +uint8_t hal_sys_capcode_get(void); +uint32_t fdt32_to_cpu(fdt32_t x); +uint32_t hal_board_get_factory_addr(void); +undefined4 hal_board_cfg(void); +void bl_tsen_adc_get(void); +uint64_t bl_rtc_get_counter(void); +uint64_t bl_rtc_get_timestamp_ms(void); +int hal_wifi_start_firmware_task(void); +int bl_sys_reset_por(void); +void bl_sys_reset_system(void); +int bl_sys_isxipaddr(uint32_t addr); +PtTable_Error_Type PtTable_Update_Entry(SPI_Flash_Cfg_Type *pFlashCfg,PtTable_ID_Type targetTableID,PtTable_Stuff_Config *ptStuff,PtTable_Entry_Config *ptEntry); +PtTable_Error_Type PtTable_Get_Active_Entries(PtTable_Stuff_Config *ptStuff,PtTable_Entry_Type type,PtTable_Entry_Config *ptEntry); +int bl_gpio_enable_output(uint8_t pin,uint8_t pullup,uint8_t pulldown); +int bl_gpio_enable_input(uint8_t pin,uint8_t pullup,uint8_t pulldown); +int bl_gpio_output_set(uint8_t pin,uint8_t value); +int bl_gpio_input_get(uint8_t pin,uint8_t *value); +int bl_flash_erase(uint32_t addr,int len); +int bl_flash_write(uint32_t addr,uint8_t *src,int len); +int bl_flash_read(uint32_t addr,uint8_t *dst,int len); +undefined4 bl_flash_config_update(void); +void bl_wdt_feed(void); +void bl_wdt_disable(void); +int bl_wdt_init(int ms); +err_t httpc_tcp_sent(void *arg,altcp_pcb *pcb,u16_t len); +err_t httpc_get_internal_addr(httpc_state_t *req,ip_addr_t *ipaddr); +err_t httpc_free_state(httpc_state_t *req); +err_t httpc_close(httpc_state_t *req,httpc_result_t result,u32_t server_response,err_t err); +err_t httpc_tcp_recv(void *arg,altcp_pcb *pcb,pbuf *p,err_t r); +void httpc_dns_found(char *hostname,ip_addr_t *ipaddr,void *arg); +err_t httpc_tcp_poll(void *arg,altcp_pcb *pcb); +void httpc_tcp_err(void *arg,err_t err); +err_t httpc_tcp_connected(void *arg,altcp_pcb *pcb,err_t err); +int httpc_create_request_string(httpc_connection_t.conflict *settings,char *server_name,int server_port,char *uri,char *buffer,size_t buffer_size); +err_t httpc_init_connection_common(httpc_state_t **connection,httpc_connection_t.conflict *settings,char *server_name,u16_t server_port,char *uri,altcp_recv_fn *recv_fn,void *callback_arg); +err_t httpc_get_file_dns(char *server_name,u16_t port,char *uri,httpc_connection_t.conflict *settings,altcp_recv_fn *recv_fn,void *callback_arg,httpc_state_t **connection); +void proc_entry_looprt(void *pvParameters); +void looprt_evt_notify_async(uint task,uint32_t evt_map); +void looprt_evt_status_dump(void); +void looprt_evt_schedule(int task,uint32_t evt_map,int delay_ms); +int looprt_start(StackType_t *proc_stack_looprt,int stack_count,StaticTask_t *proc_task_looprt); +int looprt_start_auto(void); +int looprt_handler_register(loop_evt_handler *handler,int priority); +int looprt_timer_register(loop_timer *timer); +void cmd_looprt_test(char *buf,int len,int argc,char **argv); +void cmd_looprt_test_status(char *buf,int len,int argc,char **argv); +void cmd_looprt_test_evt(char *buf,int len,int argc,char **argv); +void cmd_looprt_test_evt_dump(char *buf,int len,int argc,char **argv); +void cmd_looprt_test_schedule_evt1(char *buf,int len,int argc,char **argv); +void cmd_looprt_test_schedule_evt2(char *buf,int len,int argc,char **argv); +int looprt_test_cli_init(void); +void _cb_led_trigger(loop_ctx *loop,loop_timer *timer,void *arg); +int _led_bloop_msg(loop_ctx *loop,loop_evt_handler *handler,loop_msg *msg); +int _led_bloop_evt(loop_ctx *loop,loop_evt_handler *handler,uint32_t *bitmap_evt,uint32_t *evt_type_map); +int loopset_led_hook_on_looprt(void); +void loopset_led_trigger(int pin,uint timeon_ms); +err_t sys_mbox_new(sys_mbox_t *mbox,int size); +void sys_mbox_free(sys_mbox_t *mbox); +void sys_mbox_post(sys_mbox_t *mbox,void *data); +err_t sys_mbox_trypost(sys_mbox_t *mbox,void *msg); +u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox,void **msg,u32_t timeout); +u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox,void **msg); +uint sys_mbox_valid(int *param_1); +void sys_mbox_set_invalid(undefined4 *param_1); +err_t sys_sem_new(sys_sem_t *sem,u8_t count); +u32_t sys_arch_sem_wait(sys_sem_t *sem,u32_t timeout); +void sys_sem_free(sys_sem_t *sem); +int sys_sem_valid(sys_sem_t *sem); +void sys_sem_set_invalid(sys_sem_t *sem); +void sys_init(void); +err_t sys_mutex_new(sys_mutex_t *mutex); +void sys_mutex_lock(sys_mutex_t *mutex); +void sys_mutex_unlock(sys_mutex_t *mutex); +void sys_sem_signal(sys_mutex_t *mutex); +sys_thread_t sys_thread_new(char *name,lwip_thread_fn *thread,void *arg,int stacksize,int prio); +sys_prot_t sys_arch_protect(void); +void sys_arch_unprotect(void); +TickType_t sys_now(void); +hostent * lwip_gethostbyname(char *name); +void lwip_freeaddrinfo(addrinfo *ai); +int lwip_getaddrinfo(char *nodename,char *servname,addrinfo *hints,addrinfo **res); +err_t netifapi_do_netif_add(tcpip_api_call_data *m); +err_t netifapi_do_netif_set_addr(tcpip_api_call_data *m); +err_t netifapi_do_netif_common(tcpip_api_call_data *m); +err_t netifapi_netif_add(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw,void *state,netif_init_fn init,netif_input_fn *input); +err_t netifapi_netif_set_addr(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw); +err_t netifapi_netif_common(netif *netif,netifapi_void_fn voidfunc,netifapi_errt_fn errtfunc); +int alloc_socket(netconn *newconn,int accepted); +void lwip_link_select_cb(lwip_select_cb *select_cb); +void lwip_unlink_select_cb(lwip_select_cb *select_cb); +int lwip_selscan(int maxfdp1,_types_fd_set *readset_in,_types_fd_set *writeset_in,_types_fd_set *exceptset_in,_types_fd_set *readset_out,_types_fd_set *writeset_out,_types_fd_set *exceptset_out); +ssize_t lwip_recv_tcp(lwip_sock *sock,void *mem,size_t len,int flags); +int lwip_sock_make_addr(u16_t port,sockaddr *from,socklen_t *fromlen); +void free_socket(lwip_sock *sock,int is_tcp); +err_t lwip_recvfrom_udp_raw(lwip_sock *sock,int flags,msghdr *msg,u16_t *datagram_len); +lwip_sock * get_socket(int fd); +void lwip_setsockopt_callback(void *arg); +void event_callback(netconn *conn,netconn_evt evt,u16_t len); +int lwip_accept(int s,sockaddr *addr,socklen_t *addrlen); +int lwip_bind(int s,sockaddr *name,socklen_t namelen); +int lwip_close(int s); +int lwip_connect(int s,sockaddr *name,socklen_t namelen); +int lwip_listen(int s,int backlog); +ssize_t lwip_recvfrom(int s,void *mem,size_t len,int flags,sockaddr *from,socklen_t *fromlen); +ssize_t lwip_read(int s,void *mem,size_t len); +ssize_t lwip_recv(int s,void *mem,size_t len,int flags); +ssize_t lwip_sendto(int s,void *data,size_t size,int flags,sockaddr *to,socklen_t tolen); +ssize_t lwip_send(int s,void *data,size_t size,int flags); +int lwip_socket(int domain,int type,int protocol); +ssize_t lwip_write(int s,void *data,size_t size); +int lwip_select(int maxfdp1,_types_fd_set *readset,_types_fd_set *writeset,_types_fd_set *exceptset,timeval *timeout); +int lwip_shutdown(int s,int how); +int lwip_setsockopt(int s,int level,int optname,void *optval,socklen_t optlen); +int lwip_fcntl(int s,int cmd,int val); +void tcpip_thread(void *arg); +err_t tcpip_inpkt(pbuf *p,netif *inp,netif_input_fn *input_fn); +err_t tcpip_input(pbuf *p,netif *inp); +err_t tcpip_callback(tcpip_callback_fn function,void *ctx); +err_t tcpip_try_callback(tcpip_callback_fn function,void *ctx); +err_t tcpip_send_msg_wait_sem(tcpip_callback_fn fn,void *apimsg,sys_sem_t *sem); +err_t tcpip_api_call(tcpip_api_call_fn *fn,tcpip_api_call_data *call); +void tcpip_init(tcpip_init_done_fn initfunc,void *arg); +altcp_pcb * altcp_alloc(void); +void altcp_free(altcp_pcb *conn); +altcp_pcb * altcp_new_ip_type(altcp_allocator_t *allocator,u8_t ip_type); +altcp_pcb * altcp_new(altcp_allocator_t *allocator); +void altcp_arg(altcp_pcb *conn,void *arg); +void altcp_recv(altcp_pcb *conn,altcp_recv_fn *recv); +void altcp_sent(altcp_pcb *conn,altcp_sent_fn *sent); +void altcp_poll(altcp_pcb *conn,altcp_poll_fn *poll,u8_t interval); +void altcp_err(altcp_pcb *conn,altcp_err_fn *err); +void altcp_recved(altcp_pcb *conn,u16_t len); +err_t altcp_connect(altcp_pcb *conn,ip_addr_t *ipaddr,u16_t port,altcp_connected_fn connected); +void altcp_abort(altcp_pcb *conn); +err_t altcp_close(altcp_pcb *conn); +err_t altcp_write(altcp_pcb *conn,void *dataptr,u16_t len,u8_t apiflags); +err_t altcp_output(altcp_pcb *conn); +err_t altcp_tcp_connected(void *arg,tcp_pcb *tpcb,err_t err); +err_t altcp_tcp_sent(void *arg,tcp_pcb *tpcb,u16_t len); +err_t altcp_tcp_poll(void *arg,tcp_pcb *tpcb); +u16_t altcp_tcp_mss(altcp_pcb *conn); +u16_t altcp_tcp_sndbuf(altcp_pcb *conn); +u16_t altcp_tcp_sndqueuelen(altcp_pcb *conn); +void altcp_tcp_nagle_disable(altcp_pcb *conn); +void altcp_tcp_nagle_enable(altcp_pcb *conn); +int altcp_tcp_nagle_disabled(altcp_pcb *conn); +void altcp_tcp_dealloc(altcp_pcb *conn); +ip_addr_t * altcp_tcp_get_ip(altcp_pcb *conn,int local); +u16_t altcp_tcp_get_port(altcp_pcb *conn,int local); +void altcp_tcp_setup_callbacks(altcp_pcb *conn,tcp_pcb *tpcb); +void altcp_tcp_err(void *arg,err_t err); +err_t altcp_tcp_get_tcp_addrinfo(altcp_pcb *conn,int local,ip_addr_t *addr,u16_t *port); +void altcp_tcp_setprio(altcp_pcb *conn,u8_t prio); +err_t altcp_tcp_output(altcp_pcb *conn); +err_t altcp_tcp_write(altcp_pcb *conn,void *dataptr,u16_t len,u8_t apiflags); +err_t altcp_tcp_shutdown(altcp_pcb *conn,int shut_rx,int shut_tx); +err_t altcp_tcp_close(altcp_pcb *conn); +void altcp_tcp_abort(altcp_pcb *conn); +altcp_pcb * altcp_tcp_listen(altcp_pcb *conn,u8_t backlog,err_t *err); +err_t altcp_tcp_connect(altcp_pcb *conn,ip_addr_t *ipaddr,u16_t port,altcp_connected_fn connected); +err_t altcp_tcp_bind(altcp_pcb *conn,ip_addr_t *ipaddr,u16_t port); +void altcp_tcp_recved(altcp_pcb *conn,u16_t len); +err_t altcp_tcp_recv(void *arg,tcp_pcb *tpcb,pbuf *p,err_t err); +void altcp_tcp_set_poll(altcp_pcb *conn,u8_t interval); +err_t altcp_tcp_accept(void *arg,tcp_pcb *new_tpcb,err_t err); +altcp_pcb * altcp_tcp_new_ip_type(u8_t ip_type); +u16_t lwip_htons(u16_t n); +u32_t lwip_htonl(u32_t n); +int lwip_strnicmp(char *str1,char *str2,size_t len); +void dns_call_found(u8_t idx,ip_addr_t *addr); +err_t dns_send(u8_t idx); +void dns_check_entry(u8_t i); +void dns_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port); +void dns_init(void); +void dns_setserver(u8_t numdns,ip_addr_t *dnsserver); +ip_addr_t * dns_getserver(u8_t numdns); +void dns_tmr(void); +err_t dns_gethostbyname_addrtype(char *hostname,ip_addr_t *addr,dns_found_callback *found,void *callback_arg,u8_t dns_addrtype); +err_t dns_gethostbyname(char *hostname,ip_addr_t *addr,dns_found_callback *found,void *callback_arg); +u16_t lwip_standard_chksum(void *dataptr,int len); +u16_t inet_chksum_pseudo(pbuf *p,u8_t proto,u16_t proto_len,ip4_addr_t *src,ip4_addr_t *dest); +u16_t ip_chksum_pseudo(pbuf *p,u8_t proto,u16_t proto_len,ip4_addr_t *src,ip4_addr_t *dest); +u16_t inet_chksum_pseudo_partial(pbuf *p,u8_t proto,u16_t proto_len,u16_t chksum_len,ip4_addr_t *src,ip4_addr_t *dest); +u16_t ip_chksum_pseudo_partial(pbuf *p,u8_t proto,u16_t proto_len,u16_t chksum_len,ip4_addr_t *src,ip4_addr_t *dest); +u16_t inet_chksum(void *dataptr,u16_t len); +u16_t inet_chksum_pbuf(pbuf *p); +u16_t lwip_chksum_copy(void *dst,void *src,u16_t len); +void lwip_init(void); +void dhcp_set_state(dhcp *dhcp,u8_t new_state); +u16_t dhcp_option_short(u16_t options_out_len,u8_t *options,u16_t value); +u16_t dhcp_option_long(u16_t options_out_len,u8_t *options,u32_t value); +pbuf * dhcp_create_msg(netif *netif,dhcp *dhcp,u8_t message_type,u16_t *options_out_len); +void dhcp_option_trailer(u16_t options_out_len,u8_t *options,pbuf *p_out); +err_t dhcp_discover(netif *netif); +void dhcp_check(netif *netif); +void dhcp_bind(netif *netif); +err_t dhcp_inc_pcb_refcount(void); +u16_t dhcp_option_hostname(u16_t options_out_len,u8_t *options); +err_t dhcp_reboot(netif *netif); +err_t dhcp_select(netif *netif); +void dhcp_dec_pcb_refcount(void); +void dhcp_handle_ack(dhcp_msg *msg_in); +void dhcp_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port); +void dhcp_network_changed(netif *netif); +void dhcp_arp_reply(netif *netif,ip4_addr_t *addr); +err_t dhcp_renew(netif *netif); +u8_t dhcp_supplied_address(netif *netif); +void dhcp_release_and_stop(netif *netif); +err_t dhcp_start(netif *netif); +void dhcp_coarse_tmr(void); +void dhcp_fine_tmr(void); +void dhcp_stop(netif *netif); +void etharp_free_entry(int i); +s16_t etharp_find_entry(ip4_addr_t *ipaddr,u8_t flags,netif *netif); +err_t etharp_raw(netif *netif,eth_addr *ethsrc_addr,eth_addr *ethdst_addr,eth_addr *hwsrc_addr,ip4_addr_t *ipsrc_addr,eth_addr *hwdst_addr,ip4_addr_t *ipdst_addr,u16_t opcode); +void etharp_cleanup_netif(netif *netif); +void etharp_input(pbuf *p,netif *netif); +err_t etharp_request(netif *netif,ip4_addr_t *ipaddr); +void etharp_tmr(void); +err_t etharp_output_to_arp_index(netif *netif,pbuf *q,netif_addr_idx_t arp_idx); +err_t etharp_query(netif *netif,ip4_addr_t *ipaddr,pbuf *q); +err_t etharp_output(netif *netif,pbuf *q,ip4_addr_t *ipaddr); +void igmp_send(netif *netif,igmp_group *group,u8_t type); +void igmp_delaying_member(igmp_group *group,u8_t maxresp); +void igmp_init(void); +err_t igmp_stop(netif *netif); +void igmp_report_groups(netif *netif); +igmp_group * igmp_lookfor_group(netif *ifp,ip4_addr_t *addr); +igmp_group * igmp_lookup_group(netif *ifp,ip4_addr_t *addr); +err_t igmp_start(netif *netif); +void igmp_input(pbuf *p,netif *inp,ip4_addr_t *dest); +err_t igmp_joingroup_netif(netif *netif,ip4_addr_t *groupaddr); +err_t igmp_joingroup(ip4_addr_t *ifaddr,ip4_addr_t *groupaddr); +err_t igmp_leavegroup_netif(netif *netif,ip4_addr_t *groupaddr); +err_t igmp_leavegroup(ip4_addr_t *ifaddr,ip4_addr_t *groupaddr); +void igmp_tmr(void); +int ip4_input_accept(netif *netif); +netif * ip4_route(ip4_addr_t *dest); +err_t ip4_input(pbuf *p,netif *inp); +err_t ip4_output_if_opt_src(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto,netif *netif,void *ip_options,u16_t optlen); +err_t ip4_output_if_opt(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto,netif *netif,void *ip_options,u16_t optlen); +err_t ip4_output_if(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto,netif *netif); +err_t ip4_output_if_src(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto,netif *netif); +u8_t ip4_addr_isbroadcast_u32(u32_t addr,netif *netif); +int ip4addr_aton(char *cp,ip4_addr_t *addr); +u32_t ipaddr_addr(char *cp); +char * ip4addr_ntoa_r(ip4_addr_t *addr,char *buf,int buflen); +char * ip4addr_ntoa(ip4_addr_t *addr); +void mem_init(void); +void mem_free(uint param_1); +mem * mem_trim(mem *param_1,uint param_2); +mem_size_t * mem_malloc(uint param_1); +void * do_memp_malloc_pool(memp_desc *desc); +void memp_init_pool(memp_desc *desc); +void memp_init(void); +void * memp_malloc(memp_t type); +void memp_free(memp_t type,void *mem); +err_t netif_null_output_ip4(netif *netif,pbuf *p,ip4_addr_t *ipaddr); +void netif_issue_reports(netif *netif,u8_t report_type); +int netif_do_set_ipaddr(netif *netif,ip4_addr_t *ipaddr,ip_addr_t *old_addr); +void netif_init(void); +void netif_set_ipaddr(netif *netif,ip4_addr_t *ipaddr); +void netif_set_netmask(netif *netif,ip4_addr_t *netmask); +void netif_set_gw(netif *netif,ip4_addr_t *gw); +void netif_set_addr(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw); +netif * netif_add(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw,void *state,netif_init_fn.conflict *init,netif_input_fn *input); +void netif_set_default(netif *netif); +void netif_set_up(netif *netif); +void netif_set_down(netif *netif); +void netif_remove(netif *netif); +void netif_set_status_callback(netif *netif,netif_status_callback_fn *status_callback); +void netif_set_link_up(netif *netif); +void netif_set_link_down(netif *netif); +netif * netif_get_by_index(u8_t idx); +netif * netif_find(char *name); +pbuf * pbuf_skip_const(pbuf *in,u16_t in_offset,u16_t *out_offset); +void pbuf_free_ooseq_callback(void *arg); +u8_t pbuf_add_header_impl(pbuf *p,size_t header_size_increment,u8_t force); +pbuf * pbuf_alloc_reference(void *payload,u16_t length,pbuf_type type); +pbuf * pbuf_alloced_custom(pbuf_layer l,u16_t length,pbuf_type type,pbuf_custom *p,void *payload_mem,u16_t payload_mem_len); +u8_t pbuf_add_header(pbuf *p,size_t header_size_increment); +u8_t pbuf_remove_header(pbuf *p,size_t header_size_decrement); +u8_t pbuf_header(pbuf *p,s16_t header_size_increment); +u8_t pbuf_header_force(pbuf *p,s16_t header_size_increment); +u8_t pbuf_free(pbuf *p); +pbuf * pbuf_alloc(pbuf_layer layer,u16_t length,pbuf_type type); +void pbuf_realloc(pbuf *p,u16_t new_len); +pbuf * pbuf_free_header(pbuf *q,u16_t size); +u16_t pbuf_clen(pbuf *p); +void pbuf_ref(pbuf *p); +void pbuf_cat(pbuf *h,pbuf *t); +void pbuf_chain(pbuf *h,pbuf *t); +err_t pbuf_copy(pbuf *p_to,pbuf *p_from); +u16_t pbuf_copy_partial(pbuf *buf,void *dataptr,u16_t len,u16_t offset); +err_t pbuf_take(pbuf *buf,void *dataptr,u16_t len); +err_t pbuf_take_at(pbuf *buf,void *dataptr,u16_t len,u16_t offset); +pbuf * pbuf_clone(pbuf_layer layer,pbuf_type type,pbuf *p); +int pbuf_try_get_at(pbuf *p,u16_t offset); +u8_t pbuf_get_at(pbuf *p,u16_t offset); +void pbuf_put_at(pbuf *p,u16_t offset,u8_t data); +u16_t pbuf_memcmp(pbuf *p,u16_t offset,void *s2,u16_t n); +u16_t pbuf_memfind(pbuf *p,void *mem,u16_t mem_len,u16_t start_offset); +raw_input_state_t raw_input(pbuf *p,netif *inp); +err_t raw_bind(raw_pcb *pcb,ip_addr_t *ipaddr); +void raw_bind_netif(raw_pcb *pcb,netif *netif); +err_t raw_connect(raw_pcb *pcb,ip_addr_t *ipaddr); +void raw_recv(raw_pcb *pcb,raw_recv_fn *recv,void *recv_arg); +err_t raw_sendto_if_src(raw_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,netif *netif,ip_addr_t *src_ip); +err_t raw_sendto(raw_pcb *pcb,pbuf *p,ip_addr_t *ipaddr); +err_t raw_send(raw_pcb *pcb,pbuf *p); +void raw_remove(raw_pcb *pcb); +raw_pcb * raw_new(u8_t proto); +raw_pcb * raw_new_ip_type(u8_t type,u8_t proto); +void raw_netif_ip_addr_changed(ip_addr_t *old_addr,ip_addr_t *new_addr); +raw_pcb * raw_get_pcbs(void); +void stats_init(void); +void stats_netstat(void *ctx); +u16_t tcp_new_port(void); +err_t tcp_close_shutdown_fin(tcp_pcb *pcb); +void tcp_init(void); +void tcp_free(tcp_pcb *pcb); +err_t tcp_bind(tcp_pcb *pcb,ip_addr_t *ipaddr,u16_t port); +void tcp_bind_netif(tcp_pcb *pcb,netif *netif); +tcp_pcb * tcp_listen_with_backlog_and_err(tcp_pcb *pcb,u8_t backlog,err_t *err); +u32_t tcp_update_rcv_ann_wnd(tcp_pcb *pcb); +void tcp_recved(tcp_pcb *pcb,u16_t len); +void tcp_seg_free(tcp_seg *seg); +void tcp_segs_free(tcp_seg *seg); +void tcp_setprio(tcp_pcb *pcb,u8_t prio); +tcp_seg * tcp_seg_copy(tcp_seg *seg); +void tcp_arg(tcp_pcb *pcb,void *arg); +void tcp_recv(tcp_pcb *pcb,tcp_recv_fn *recv); +void tcp_sent(tcp_pcb *pcb,tcp_sent_fn *sent); +void tcp_err(tcp_pcb *pcb,tcp_err_fn *err); +void tcp_accept(tcp_pcb *pcb,tcp_accept_fn accept); +void tcp_poll(tcp_pcb *pcb,tcp_poll_fn *poll,u8_t interval); +u32_t tcp_next_iss(tcp_pcb *pcb); +u16_t tcp_eff_send_mss_netif(u16_t sendmss,netif *outif,ip_addr_t *dest); +err_t tcp_connect(tcp_pcb *pcb,ip_addr_t *ipaddr,u16_t port,tcp_connected_fn connected); +char * tcp_debug_state_str(tcp_state s); +err_t tcp_tcp_get_tcp_addrinfo(tcp_pcb *pcb,int local,ip_addr_t *addr,u16_t *port); +void tcp_free_ooseq(tcp_pcb *pcb); +void tcp_pcb_purge(tcp_pcb *pcb); +void tcp_pcb_remove(tcp_pcb **pcblist,tcp_pcb *pcb); +void tcp_abandon(tcp_pcb *pcb,int reset); +void tcp_abort(tcp_pcb *pcb); +err_t tcp_accept_null(void *arg,tcp_pcb *pcb,err_t err); +void tcp_netif_ip_addr_changed_pcblist(tcp_pcb *pcb_list); +void tcp_netif_ip_addr_changed(ip_addr_t *old_addr,ip_addr_t *new_addr); +void tcp_kill_state(tcp_state state); +tcp_pcb * tcp_alloc(u8_t prio); +tcp_pcb * tcp_new_ip_type(u8_t type); +err_t tcp_close_shutdown(tcp_pcb *pcb,u8_t rst_on_unacked_data); +err_t tcp_close(tcp_pcb *pcb); +err_t tcp_recv_null(void *arg,tcp_pcb *pcb,pbuf *p,err_t err); +err_t tcp_process_refused_data(tcp_pcb *pcb); +void tcp_fasttmr(void); +err_t tcp_shutdown(tcp_pcb *pcb,int shut_rx,int shut_tx); +void tcp_slowtmr(void); +void tcp_tmr(void); +int tcp_get_pcbs(tcp_pcb ****list); +u8_t tcp_get_next_optbyte(void); +void tcp_oos_insert_segment(tcp_seg *cseg,tcp_seg *next); +void tcp_parseopt(undefined2 *param_1); +int tcp_input_delayed_close(tcp_pcb *pcb); +tcp_seg * tcp_free_acked_segments(tcp_seg *seg_list); +void tcp_receive(tcp_pcb *pcb); +void tcp_input(pbuf *p,netif *inp); +void tcp_trigger_input_pcb_close(void); +void tcp_seg_add_chksum(u16_t chksum,u16_t len,u16_t *seg_chksum,u8_t *seg_chksum_swapped); +tcp_seg * tcp_create_segment(tcp_pcb *pcb,pbuf *p,u8_t hdrflags,u32_t seqno,u8_t optflags); +pbuf * tcp_output_alloc_header_common(u32_t ackno,u16_t datalen,u32_t seqno_be,u16_t src_port,u16_t dst_port,u8_t flags,u16_t wnd); +pbuf * tcp_output_alloc_header(tcp_pcb *pcb,u16_t datalen,u32_t seqno_be); +err_t tcp_output_control_segment(tcp_pcb *pcb,pbuf *p,ip_addr_t *src,ip_addr_t *dst); +err_t tcp_write(tcp_pcb *pcb,void *arg,u16_t len,u8_t apiflags); +err_t tcp_split_unsent_seg(tcp_pcb *pcb,u16_t split); +err_t tcp_enqueue_flags(tcp_pcb *pcb,u8_t flags); +err_t tcp_send_fin(tcp_pcb *pcb); +err_t tcp_rexmit_rto_prepare(tcp_pcb *pcb); +err_t tcp_rexmit(tcp_pcb *pcb); +void tcp_rexmit_fast(tcp_pcb *pcb); +void tcp_rst(tcp_pcb *pcb,u32_t seqno,u32_t ackno,ip_addr_t *param_4,ip_addr_t *remote_ip,u16_t param_6,u16_t remote_port); +err_t tcp_send_empty_ack(tcp_pcb *pcb); +err_t tcp_output(tcp_pcb *pcb); +void tcp_rexmit_rto_commit(tcp_pcb *pcb); +void tcp_rexmit_rto(tcp_pcb *pcb); +err_t tcp_keepalive(tcp_pcb *pcb); +err_t tcp_zero_window_probe(tcp_pcb *pcb); +void sys_timeout_abs(u32_t abs_time,sys_timeout_handler *handler,void *arg); +void lwip_cyclic_timer(void *arg); +void sys_timeout(u32_t msecs,sys_timeout_handler *handler,void *arg); +void tcp_timer_needed(void); +void tcpip_tcp_timer(void *arg); +void sys_timeouts_init(void); +void sys_untimeout(sys_timeout_handler *handler,void *arg); +void sys_check_timeouts(void); +u32_t sys_timeouts_sleeptime(void); +void udp_init(void); +void udp_input(pbuf *p,netif *inp); +err_t udp_bind(udp_pcb *pcb,ip_addr_t *ipaddr,u16_t port); +err_t udp_sendto_if_src_chksum(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif,u8_t have_chksum,u16_t chksum,ip_addr_t *src_ip); +err_t udp_sendto_if_chksum(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif,u8_t have_chksum,u16_t chksum); +err_t udp_sendto_chksum(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,u8_t have_chksum,u16_t chksum); +err_t udp_send_chksum(udp_pcb *pcb,pbuf *p,u8_t have_chksum,u16_t chksum); +err_t udp_sendto(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port); +err_t udp_sendto_if(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif); +err_t udp_sendto_if_src(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif,ip_addr_t *src_ip); +void udp_bind_netif(udp_pcb *pcb,netif *netif); +err_t udp_connect(udp_pcb *pcb,ip_addr_t *ipaddr,u16_t port); +void udp_disconnect(udp_pcb *pcb); +void udp_recv(udp_pcb *pcb,udp_recv_fn *recv,void *recv_arg); +void udp_remove(udp_pcb *pcb); +udp_pcb * udp_new(void); +udp_pcb * udp_new_ip_type(void); +void udp_netif_ip_addr_changed(ip_addr_t *old_addr,ip_addr_t *new_addr); +udp_pcb * udp_get_pcbs(void); +err_t ethernet_input(pbuf *p,netif *netif); +err_t ethernet_output(netif *netif,pbuf *p,eth_addr *src,eth_addr *dst,u16_t eth_type); +err_t netconn_apimsg(tcpip_callback_fn.conflict *fn,api_msg *apimsg); +err_t netconn_close_shutdown(netconn *conn,u8_t how); +netconn * netconn_new_with_proto_and_callback(netconn_type t,u8_t proto,netconn_callback *callback); +err_t netconn_prepare_delete(netconn *conn); +err_t netconn_delete(netconn *conn); +err_t netconn_getaddr(netconn *conn,ip_addr_t *addr,u16_t *port,u8_t local); +err_t netconn_bind(netconn *conn,ip_addr_t *addr,u16_t port); +err_t netconn_connect(netconn *conn,ip_addr_t *addr,u16_t port); +err_t netconn_disconnect(netconn *conn); +err_t netconn_listen_with_backlog(netconn *conn,u8_t backlog); +err_t netconn_tcp_recvd(netconn *conn,size_t len); +err_t netconn_send(netconn *conn,netbuf *buf); +err_t netconn_write_vectors_partly(netconn *conn,netvector *vectors,u16_t vectorcnt,u8_t apiflags,size_t *bytes_written); +err_t netconn_write_partly(netconn *conn,void *dataptr,size_t size,u8_t apiflags,size_t *bytes_written); +err_t netconn_err(netconn *conn); +err_t netconn_accept(netconn *conn,netconn **new_conn); +err_t netconn_recv_data(netconn *conn,void **new_buf,u8_t apiflags); +err_t netconn_recv_udp_raw_netbuf_flags(netconn *conn,netbuf **new_buf,u8_t apiflags); +err_t netconn_recv_data_tcp(netconn *conn,pbuf **new_buf,u8_t apiflags); +err_t netconn_recv_tcp_pbuf_flags(netconn *conn,pbuf **new_buf,u8_t apiflags); +err_t netconn_shutdown(netconn *conn,u8_t shut_rx,u8_t shut_tx); +err_t netconn_join_leave_group(netconn *conn,ip_addr_t *multiaddr,ip_addr_t *netif_addr,netconn_igmp join_or_leave); +err_t netconn_gethostbyname(char *name,ip_addr_t *addr); +void lwip_netconn_do_dns_found(char *name,ip_addr_t *ipaddr,void *arg); +void recv_udp(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port); +void setup_tcp(netconn *conn); +err_t lwip_netconn_do_connected(void *arg,tcp_pcb *pcb,err_t err); +void err_tcp(void *arg,err_t err); +err_t lwip_netconn_do_writemore(netconn *conn); +err_t lwip_netconn_do_close_internal(netconn *conn); +err_t poll_tcp(void *arg,tcp_pcb *pcb); +u8_t recv_raw(void *arg,raw_pcb *pcb,pbuf *p,ip_addr_t *addr); +err_t sent_tcp(void *arg,tcp_pcb *pcb,u16_t len); +err_t recv_tcp(void *arg,tcp_pcb *pcb,pbuf *p,err_t err); +int lwip_netconn_is_err_msg(void *msg,err_t *err); +void lwip_netconn_do_newconn(void *m); +netconn * netconn_alloc(netconn_type t,netconn_callback *callback); +void netconn_free(netconn *conn); +void netconn_drain(netconn *conn); +err_t accept_function(void *arg,tcp_pcb *newpcb,err_t err); +void lwip_netconn_do_delconn(void *m); +void lwip_netconn_do_bind(void *m); +void lwip_netconn_do_connect(void *m); +void lwip_netconn_do_disconnect(void *m); +void lwip_netconn_do_listen(void *m); +void lwip_netconn_do_send(void *m); +void lwip_netconn_do_recv(void *m); +void lwip_netconn_do_write(void *m); +void lwip_netconn_do_getaddr(void *m); +void lwip_netconn_do_close(void *m); +void lwip_netconn_do_join_leave_group(void *m); +void lwip_netconn_do_gethostbyname(void *arg); +int err_to_errno(err_t err); +void netbuf_delete(netbuf *buf); +void * netbuf_alloc(netbuf *buf,u16_t size); +void netbuf_free(netbuf *buf); +void icmp_input(pbuf *p,netif *inp); +void icmp_dest_unreach(pbuf *p,icmp_dur_type t); +u8_t * dhcp_server_option_find(u8_t *buf,u16_t len,u8_t option); +dhcp_client_node * dhcp_client_find_by_ip(uint8_t *ip); +void dhcp_server_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *recv_addr,u16_t port); +err_t dhcp_server_start(netif *netif,ip4_addr_t *start,ip4_addr_t *end); +err_t dhcp_server_stop(netif *netif); +void dhcpd_start(netif *netif); +void tcpc_entry(void *arg); +void tcpclient_cmd(char *buf,int len,int argc,char **argv); +int network_netutils_tcpclinet_cli_register(void); +void TCP_Server(void *pvParameters); +void cmd_tcp_server(char *buf,int len,int argc,char **argv); +int network_netutils_tcpserver_cli_register(void); +void iperf_server_udp_entry(char *name); +void iperf_client_udp_entry(char *name); +void iperf_server_entry(char *name); +void iperf_client_tcp_entry(char *name); +void iperf_server_udp(void *arg); +void iperf_server_udp_recv_fn(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port); +void iperf_client_udp(void *arg); +void iperf_server(void *arg); +void iperf_client_tcp(void *arg); +void ipus_test_cmd(char *buf,int len,int argc,char **argv); +void ipu_test_cmd(char *buf,int len,int argc,char **argv); +void ipc_test_cmd(char *buf,int len,int argc,char **argv); +void ips_test_cmd(char *buf,int len,int argc,char **argv); +int network_netutils_iperf_cli_register(void); +void cmd_netstat(char *buf,int len,int argc,char **argv); +int network_netutils_netstat_cli_register(void); +void ping_usage(void); +void ping_free(void *arg); +void ping_timeout(void *arg); +u8_t ping_recv(void *arg,raw_pcb *pcb,pbuf *p,ip_addr_t *addr); +ping_var * ping_api_init(u16_t interval,u16_t size,u32_t count,u16_t timeout,ip_addr_t *dest); +void ping_cmd(char *buf,int len,int argc,char **argv); +int network_netutils_ping_cli_register(void); +int dirent_type(void *addr); +uint32_t dirent_hardfh(void *addr); +uint32_t dirent_childaddr(void *addr); +uint32_t dirent_size(void *addr); +int romfs_close(file_t *fp); +int romfs_ioctl(file_t *fp,int cmd,ulong arg); +ssize_t romfs_read(file_t *fp,char *buf,size_t length); +undefined4 file_info(char *param_1,char **param_2,char **param_3); +int romfs_closedir(file_t *fp,aos_dir_t *dir); +off_t romfs_lseek(file_t *fp,off_t off,int whence); +aos_dirent_t * romfs_readdir(file_t *fp,aos_dir_t *dir); +uint32_t dirent_file(char *path,void **p_addr_start_input,void **p_addr_end_input); +aos_dir_t * romfs_opendir(file_t *fp,char *path); +int romfs_stat(file_t *fp,char *path,stat *st); +int romfs_open(file_t *fp,char *path,int flags); +int romfs_register(void); +void _startup_sntp(void *arg); +void cmd_sntp_date(char *buf,int len,int argc,char **argv); +void cmd_sntp_time(char *buf,int len,int argc,char **argv); +void cmd_sntp_start(char *buf,int len,int argc,char **argv); +int sntp_cli_init(void); +void sntp_retry(void *arg); +void sntp_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port); +void sntp_send_request(ip_addr_t *server_addr); +void sntp_request(void *arg); +void sntp_dns_found(char *hostname,ip_addr_t *ipaddr,void *arg); +void sntp_init(void); +void sntp_setoperatingmode(u8_t operating_mode); +int sntp_get_time(uint32_t *seconds,uint32_t *frags); +void sntp_setservername(u8_t idx,char *server); +char * utils_bin2hex(char *dst,void *src,size_t count); +void utils_sha256_init(iot_sha256_context *ctx); +void utils_sha256_free(iot_sha256_context *ctx); +void utils_sha256_starts(iot_sha256_context *ctx); +void utils_sha256_process(iot_sha256_context *ctx,uchar *data); +void utils_sha256_update(iot_sha256_context *ctx,uchar *input,uint32_t ilen); +void utils_sha256_update(iot_sha256_context *ctx,uchar *input,uint32_t ilen); +void utils_sha256_finish(iot_sha256_context *ctx,uint8_t *output); +void bl_printk(char *format,...); +int log_buf_out(char *file,int line,void *inbuf,int len,LOG_BUF_OUT_DATA_TYPE_T type); +int utils_dns_domain_get(uint8_t *records,uint8_t *buf,int *len); +void utils_list_init(utils_list *list); +void utils_list_push_back(utils_list *list,utils_list_hdr *list_hdr); +utils_list_hdr * utils_list_pop_front(utils_list *list); +void utils_hexdump(void *mem,uint len); +undefined4 utils_time_date_from_epoch(uint param_1,undefined *param_2); +int utils_getopt_init(getopt_env_t *env,int opterr); +int utils_getopt(getopt_env_t *env,int argc,char **argv,char *optstring); +void Bl_F_fast(uchar *digest,uchar *digest1,char *password,uchar *ssid,int ssidlength,int count,uchar *output); +int utils_wifi_psk_cal_fast_bin(char *password,uchar *ssid,int ssidlength,uchar *output); +int utils_memp_init(utils_memp_pool_t **pool,uint16_t node_size,uint16_t pool_cap,uint8_t align_req); +int utils_memp_deinit(utils_memp_pool_t *pool); +void * utils_memp_malloc(utils_memp_pool_t *pool); +int utils_memp_free(utils_memp_pool_t *pool,void *node); +int utils_tlv_bl_pack_auto(uint32_t *buf,int buf_sz,uint16_t type,void *arg1); +int utils_tlv_bl_unpack_auto(uint32_t *buf,int buf_sz,uint16_t type,void *arg1); +void utils_hmac_sha1_fast(uchar **ppText,int *pTextLen,int textNum,uchar *key,int key_len,uchar *output,int outputLen); +int vfs_init(void); +int aos_open(char *path,int flags); +int aos_close(int fd); +ssize_t aos_read(int fd,void *buf,size_t nbytes); +ssize_t aos_write(int fd,void *buf,size_t nbytes); +int aos_ioctl(int fd,int cmd,ulong arg); +off_t aos_lseek(int fd,off_t offset,int whence); +int aos_stat(char *path,stat *st); +aos_dir_t * aos_opendir(char *path); +int aos_closedir(aos_dir_t *dir); +aos_dirent_t * aos_readdir(aos_dir_t *dir); +file_t * new_file(inode_t *node); +void del_file(file_t *file); +int get_fd(file_t *file); +file_t * get_file(int fd); +int inode_init(void); +int inode_alloc(void); +inode_t * inode_open(char *path); +int inode_forearch_name(anon_subr_int_void_ptr_inode_t_ptr *cb,void *arg); +void inode_ref(inode_t *node); +void inode_unref(inode_t *node); +int inode_reserve(char *path,inode_t **inode); +int aos_register_driver(char *path,file_ops_t *ops,void *arg); +int aos_register_fs(char *path,fs_ops_t *ops,void *arg); +int vfs_uart_open(inode_t *inode,file_t *fp); +void __uart_rx_irq(void *p_arg); +void __uart_tx_irq(void *p_arg); +int vfs_uart_close(file_t *fp); +ssize_t vfs_uart_read(file_t *fp,void *buf,size_t nbytes); +ssize_t vfs_uart_write(file_t *fp,void *buf,size_t nbytes); +int vfs_uart_poll(file_t *fp,_Bool setup,poll_notify_t *notify,pollfd *fd,void *opa); +int vfs_uart_sync(file_t *fp); +int uart_ioctl_cmd_waimode(uart_dev_t *uart_dev,int cmd,ulong arg); +int uart_ioctl_cmd_setconfig(uart_dev_t *uart_dev,ulong arg); +int vfs_uart_ioctl(file_t *fp,int cmd,ulong arg); +yloop_ctx_t * get_context(void); +void aos_loop_set_eventfd(int fd); +aos_loop_t aos_loop_init(void); +int aos_poll_read_fd(int sock,aos_poll_call_t *cb,void *private_data); +int aos_post_delayed_action(int ms,aos_call_t *action,void *param); +void aos_loop_run(yloop_sock_t *param_1); +void vfs_poll_notify(pollfd *fd,void *arg); +int aos_poll(pollfd *fds,int nfds,int timeout); +int aos_fcntl(int fd,int cmd,int val); +void dfl_entry(void *arg); +int aos_task_new(char *name,anon_subr_void_void_ptr *fn,void *arg,int stack_size); +void aos_task_exit(int code); +int aos_task_key_create(aos_task_key_t *key); +int aos_task_setspecific(aos_task_key_t key,void *vp); +void * aos_task_getspecific(aos_task_key_t key); +int aos_mutex_new(aos_mutex_t *mutex); +void aos_mutex_free(aos_mutex_t *mutex); +int aos_mutex_lock(aos_mutex_t *mutex,uint ms); +int aos_mutex_unlock(aos_mutex_t *mutex); +int aos_sem_new(aos_sem_t *sem,int count); +void aos_sem_free(aos_sem_t *sem); +int aos_sem_wait(aos_sem_t *sem,uint ms); +void aos_sem_signal(aos_sem_t *sem); +void * aos_malloc(size_t xWantedSize); +void aos_free(void *pv); +longlong aos_now_ms(void); +int event_poll(file_t *f,_Bool setup,poll_notify_t *notify,pollfd *fd,void *opa); +int event_open(inode_t *node,file_t *file); +ssize_t _event_write(void *buf,size_t len,_Bool urgent); +int event_ioctl(file_t *f,int cmd,ulong arg); +ssize_t event_write(file_t *f,void *buf,size_t len); +int event_close(file_t *file); +ssize_t event_read(file_t *f,void *buf,size_t len); +int vfs_device_init(void); +void event_read_cb(int fd,void *param); +int aos_event_service_init(void); +int aos_post_event(uint16_t type,uint16_t code,ulong value); +int aos_register_event_filter(uint16_t type,aos_event_cb *cb,void *priv); +IoT_Error_t aws_iot_shadow_init(AWS_IoT_Client *pClient,ShadowInitParameters_t *pParams); +IoT_Error_t aws_iot_shadow_connect(AWS_IoT_Client *pClient,ShadowConnectParameters_t.conflict6 *pParams); +IoT_Error_t aws_iot_shadow_register_delta(AWS_IoT_Client *pMqttClient,jsonStruct_t *pStruct); +IoT_Error_t aws_iot_shadow_yield(AWS_IoT_Client *pClient,uint32_t timeout); +IoT_Error_t aws_iot_shadow_disconnect(AWS_IoT_Client *pClient); +IoT_Error_t aws_iot_shadow_update(AWS_IoT_Client *pClient,char *pThingName,char *pJsonString,fpActionCallback_t *callback,void *pContextData,uint8_t timeout_seconds,_Bool isPersistentSubscribe); +IoT_Error_t aws_iot_shadow_set_autoreconnect_status(AWS_IoT_Client *pClient,_Bool newStatus); +IoT_Error_t aws_iot_shadow_internal_action(char *pThingName,ShadowActions_t action,char *pJsonDocumentToBeSent,size_t jsonSize,fpActionCallback_t *callback,void *pCallbackContext,uint32_t timeout_seconds,_Bool isSticky); +IoT_Error_t convertDataToString(char *pStringBuffer,size_t maxSizoStringBuffer,JsonPrimitiveType type,void *pData); +void resetClientTokenSequenceNum(void); +IoT_Error_t aws_iot_shadow_init_json_document(char *pJsonDocument,size_t maxSizeOfJsonDocument); +IoT_Error_t aws_iot_shadow_add_reported(char *pJsonDocument,size_t maxSizeOfJsonDocument,uint8_t count,...); +int32_t FillWithClientTokenSize(char *pBufferToBeUpdatedWithClientToken,size_t maxSizeOfJsonDocument); +IoT_Error_t aws_iot_finalize_json_document(char *pJsonDocument,size_t maxSizeOfJsonDocument); +_Bool isJsonValidAndParse(char *pJsonDocument,size_t jsonSize,void *pJsonHandler,int32_t *pTokenCount); +_Bool isJsonKeyMatchingAndUpdateValue(char *pJsonDocument,void *pJsonHandler,int32_t tokenCount,jsonStruct_t *pDataStruct,uint32_t *pDataLength,int32_t *pDataPosition); +_Bool extractClientToken(char *pJsonDocument,size_t jsonSize,char *pExtractedClientToken,size_t clientTokenSize); +_Bool extractVersionNumber(char *pJsonDocument,void *pJsonHandler,int32_t tokenCount,uint32_t *pVersionNumber); +void shadow_delta_callback(AWS_IoT_Client *pClient,char *topicName,uint16_t topicNameLen,IoT_Publish_Message_Params *params,void *pData); +int16_t findIndexOfSubscriptionList(char *pTopic); +void topicNameFromThingAndAction(char *pTopic,char *pThingName,ShadowActions_t action,ShadowAckTopicTypes_t ackType); +void unsubscribeFromAcceptedAndRejected(uint8_t index); +void AckStatusCallback(AWS_IoT_Client *pClient,char *topicName,uint16_t topicNameLen,IoT_Publish_Message_Params *params,void *pData); +void initDeltaTokens(void); +IoT_Error_t registerJsonTokenOnDelta(jsonStruct_t *pStruct); +void initializeRecords(AWS_IoT_Client *pClient); +_Bool isSubscriptionPresent(char *pThingName,ShadowActions_t action); +IoT_Error_t subscribeToShadowActionAcks(char *pThingName,ShadowActions_t action,_Bool isSticky); +void incrementSubscriptionCnt(char *pThingName,ShadowActions_t action,_Bool isSticky); +IoT_Error_t publishToShadowAction(char *pThingName,ShadowActions_t action,char *pJsonDocumentToBeSent); +_Bool getNextFreeIndexOfAckWaitList(uint8_t *pIndex); +void addToAckWaitList(uint8_t indexAckWaitList,char *pThingName,ShadowActions_t action,char *pExtractedClientToken,fpActionCallback_t *callback,void *pCallbackContext,uint32_t timeout_seconds); +void HandleExpiredResponseCallbacks(void); +_Bool has_timer_expired(Timer *timer); +void countdown_ms(Timer *timer,uint32_t timeout); +uint32_t left_ms(Timer *timer); +void countdown_sec(Timer *timer,uint32_t timeout); +void init_timer(Timer *timer); +int jsmn_parse(jsmn_parser *parser,char *js,size_t len,jsmntok_t *tokens,uint num_tokens); +void jsmn_init(jsmn_parser *parser); +int8_t jsoneq(char *json,jsmntok_t *tok,char *s); +IoT_Error_t parseUnsignedInteger32Value(uint32_t *i,char *jsonString,jsmntok_t *token); +IoT_Error_t parseUnsignedInteger16Value(uint16_t *i,char *jsonString,jsmntok_t *token); +IoT_Error_t parseUnsignedInteger8Value(uint8_t *i,char *jsonString,jsmntok_t *token); +IoT_Error_t parseInteger32Value(int32_t *i,char *jsonString,jsmntok_t *token); +IoT_Error_t parseInteger16Value(int16_t *i,char *jsonString,jsmntok_t *token); +IoT_Error_t parseInteger8Value(int8_t *i,char *jsonString,jsmntok_t *token); +IoT_Error_t parseFloatValue(float *f,char *jsonString,jsmntok_t *token); +IoT_Error_t parseDoubleValue(double *d,char *jsonString,jsmntok_t *token); +IoT_Error_t parseBooleanValue(_Bool *b,char *jsonString,jsmntok_t *token); +IoT_Error_t parseStringValue(char *buf,size_t bufLen,char *jsonString,jsmntok_t *token); +ClientState aws_iot_mqtt_get_client_state(AWS_IoT_Client *pClient); +IoT_Error_t aws_iot_mqtt_client_lock_mutex(AWS_IoT_Client *pClient,IoT_Mutex_t *pMutex); +IoT_Error_t aws_iot_mqtt_client_unlock_mutex(AWS_IoT_Client *pClient,IoT_Mutex_t *pMutex); +int aws_iot_mqtt_set_client_state(AWS_IoT_Client *param_1,uint param_2,ClientState param_3); +IoT_Error_t aws_iot_mqtt_set_connect_params(AWS_IoT_Client *pClient,IoT_Client_Connect_Params *pNewConnectParams); +IoT_Error_t aws_iot_mqtt_init(AWS_IoT_Client *pClient,IoT_Client_Init_Params *pInitParams); +uint16_t aws_iot_mqtt_get_next_packet_id(AWS_IoT_Client *pClient); +_Bool aws_iot_mqtt_is_client_connected(AWS_IoT_Client *pClient); +IoT_Error_t aws_iot_mqtt_autoreconnect_set_status(AWS_IoT_Client *pClient,_Bool newStatus); +IoT_Error_t aws_iot_mqtt_connect(AWS_IoT_Client *pClient,IoT_Client_Connect_Params *pConnectParams); +IoT_Error_t _aws_iot_mqtt_internal_disconnect(AWS_IoT_Client *pClient); +IoT_Error_t aws_iot_mqtt_disconnect(AWS_IoT_Client *pClient); +IoT_Error_t aws_iot_mqtt_attempt_reconnect(AWS_IoT_Client *pClient); +IoT_Error_t aws_iot_mqtt_internal_serialize_ack(uchar *pTxBuf,size_t txBufLen,MessageTypes msgType,uint8_t dup,uint16_t packetId,uint32_t *pSerializedLen); +IoT_Error_t aws_iot_mqtt_internal_deserialize_publish(uint8_t *dup,QoS *qos,uint8_t *retained,uint16_t *pPacketId,char **pTopicName,uint16_t *topicNameLen,uchar **payload,size_t *payloadLen,uchar *pRxBuf,size_t rxBufLen); +IoT_Error_t aws_iot_mqtt_internal_deserialize_ack(uchar *pPacketType,uchar *dup,uint16_t *pPacketId,uchar *pRxBuf,size_t rxBuflen); +IoT_Error_t aws_iot_mqtt_publish(AWS_IoT_Client *pClient,char *pTopicName,uint16_t topicNameLen,IoT_Publish_Message_Params *pParams); +IoT_Error_t _aws_iot_mqtt_deserialize_suback(uint16_t *pPacketId,uint32_t *pGrantedQoSCount,QoS *pGrantedQoSs,uchar *pRxBuf,size_t rxBufLen); +IoT_Error_t _aws_iot_mqtt_serialize_subscribe(uchar *pTxBuf,size_t txBufLen,uint16_t packetId,char **pTopicNameList,uint16_t *pTopicNameLenList,QoS *pRequestedQoSs,uint32_t *pSerializedLen); +IoT_Error_t aws_iot_mqtt_subscribe(AWS_IoT_Client *pClient,char *pTopicName,uint16_t topicNameLen,QoS qos,pApplicationHandler_t *pApplicationHandler,void *pApplicationHandlerData); +IoT_Error_t aws_iot_mqtt_resubscribe(AWS_IoT_Client *pClient); +IoT_Error_t aws_iot_mqtt_unsubscribe(AWS_IoT_Client *pClient,char *pTopicFilter,uint16_t topicFilterLen); +IoT_Error_t _aws_iot_mqtt_handle_disconnect(AWS_IoT_Client *pClient); +IoT_Error_t aws_iot_mqtt_yield(AWS_IoT_Client *pClient,uint32_t timeout_ms); +IoT_Error_t iot_tls_is_connected(Network *pNetwork); +IoT_Error_t iot_tls_connect(Network *pNetwork,TLSConnectParams *params); +int _iot_tls_verify_cert(void *data,mbedtls_x509_crt *crt,int depth,uint32_t *flags); +IoT_Error_t iot_tls_write(Network *pNetwork,uchar *pMsg,size_t len,Timer *timer,size_t *written_len); +IoT_Error_t iot_tls_read(Network *pNetwork,uchar *pMsg,size_t len,Timer *timer,size_t *read_len); +IoT_Error_t iot_tls_disconnect(Network *pNetwork); +IoT_Error_t iot_tls_destroy(Network *pNetwork); +IoT_Error_t iot_tls_init(Network *pNetwork,char *pRootCALocation,char *pDeviceCertLocation,char *pDevicePrivateKeyLocation,char *pDestinationURL,uint16_t destinationPort,uint32_t timeout_ms,_Bool ServerVerificationFlag); +IoT_Error_t aws_iot_thread_mutex_init(IoT_Mutex_t *pMutex); +IoT_Error_t aws_iot_thread_mutex_lock(IoT_Mutex_t *pMutex); +IoT_Error_t aws_iot_thread_mutex_trylock(IoT_Mutex_t *pMutex); +IoT_Error_t aws_iot_thread_mutex_unlock(IoT_Mutex_t *pMutex); +IoT_Error_t aws_iot_thread_mutex_destroy(IoT_Mutex_t *pMutex); +IoT_Error_t _aws_iot_mqtt_internal_readWrapper(AWS_IoT_Client *pClient,size_t offset,size_t size,Timer *pTimer,size_t *read_len); +size_t aws_iot_mqtt_internal_write_len_to_buffer(uchar *buf,uint32_t length); +IoT_Error_t aws_iot_mqtt_internal_decode_remaining_length_from_buffer(uchar *buf,uint32_t *decodedLen,uint32_t *readBytesLen); +uint32_t aws_iot_mqtt_internal_get_final_packet_length_from_remaining_length(uint32_t rem_len); +uint16_t aws_iot_mqtt_internal_read_uint16_t(uchar **pptr); +void aws_iot_mqtt_internal_write_uint_16(uchar **pptr,uint16_t anInt); +uchar aws_iot_mqtt_internal_read_char(uchar **pptr); +void aws_iot_mqtt_internal_write_char(uchar **pptr,uchar c); +void aws_iot_mqtt_internal_write_utf8_string(uchar **pptr,char *string,uint16_t stringLen); +IoT_Error_t aws_iot_mqtt_internal_init_header(MQTTHeader *pHeader,MessageTypes message_type,QoS qos,uint8_t dup,uint8_t retained); +IoT_Error_t aws_iot_mqtt_internal_send_packet(AWS_IoT_Client *pClient,size_t length,Timer *pTimer); +IoT_Error_t aws_iot_mqtt_internal_cycle_read(AWS_IoT_Client *pClient,Timer *pTimer,uint8_t *pPacketType); +IoT_Error_t aws_iot_mqtt_internal_flushBuffers(AWS_IoT_Client *pClient); +IoT_Error_t aws_iot_mqtt_internal_wait_for_read(AWS_IoT_Client *pClient,uint8_t packetType,Timer *pTimer); +IoT_Error_t aws_iot_mqtt_internal_serialize_zero(uchar *pTxBuf,size_t txBufLen,MessageTypes packetType,size_t *pSerializedLength); +size_t format_int(char *q,size_t n,uint flags,int base,int width,int prec); +char * cvt(int ndigits,int *decpt,int *sign,char *buf,int eflag); +char * ecvtbuf(int ndigits,int *decpt,int *sign,char *buf); +char * fcvtbuf(int ndigits,int *decpt,int *sign,char *buf); +char * flt(char *str,int size,int precision,char fmt,int flags); +int vsnprintf(char *__s,size_t __maxlen,char *__format,__gnuc_va_list __arg); +int vsprintf(char *__s,char *__format,__gnuc_va_list __arg); +void vprint(char *fmt,va_list argp); +int bl_putchar(int c); +int puts(char *__s); +int printf(char *__format,...); +int sprintf(char *__s,char *__format,...); +int snprintf(char *__s,size_t __maxlen,char *__format,...); +int sscanf(char *__s,char *__format,...); +void set_bit(ulong *bitmap,uint bit); +int vsscanf(char *__s,char *__format,__gnuc_va_list __arg); +uintmax_t strntoumax(char *nptr,char **endptr,int base,size_t n); +BL_Err_Type UART_Init(UART_ID_Type uartId,UART_CFG_Type *uartCfg); +BL_Err_Type UART_FifoConfig(UART_ID_Type uartId,UART_FifoCfg_Type *fifoCfg); +BL_Err_Type UART_Enable(UART_ID_Type uartId,UART_Direction_Type direct); +BL_Err_Type UART_Disable(UART_ID_Type uartId,UART_Direction_Type direct); +BL_Err_Type UART_SetRxTimeoutValue(UART_ID_Type uartId,uint8_t time); +BL_Err_Type UART_TxFreeRun(UART_ID_Type uartId,BL_Fun_Type txFreeRun); +BL_Err_Type UART_IntMask(UART_ID_Type uartId,UART_INT_Type intType,BL_Mask_Type intMask); +uint8_t UART_GetTxFifoCount(UART_ID_Type uartId); +BL_Err_Type UART_SendData(UART_ID_Type uartId,uint8_t *data,uint32_t len); +uint8_t UART_GetRxFifoCount(UART_ID_Type uartId); +void ADC_Reset(void); +void ADC_Enable(void); +void ADC_Disable(void); +void ADC_Channel_Config(ADC_Chan_Type posCh,ADC_Chan_Type negCh,BL_Fun_Type contEn); +void ADC_Start(void); +void ADC_FIFO_Cfg(ADC_FIFO_Cfg_Type *fifoCfg); +uint8_t ADC_Get_FIFO_Count(void); +void ADC_Parse_Result(uint32_t *orgVal,uint32_t len,ADC_Result_Type *result); +void ADC_Tsen_Init(ADC_TSEN_MOD_Type tsenMod); +void ADC_SET_TSVBE_LOW(void); +void ADC_SET_TSVBE_HIGH(void); +uint32_t TSEN_Get_V_Error(void); +float TSEN_Get_Temp(uint32_t tsen_offset); +void ADC_Init(ADC_CFG_Type *cfg); +void Sec_Eng_PKA_Write_Common_OP_First_Cfg(uint8_t s0RegIndex,uint8_t s0RegType,uint8_t dRegIndex,uint8_t dRegType,uint8_t op,uint8_t lastOp); +BL_Err_Type Sec_Eng_PKA_Wait_ISR(void); +BL_Err_Type Sec_Eng_SHA256_Update(SEC_Eng_SHA256_Ctx *shaCtx,uint8_t *input,uint32_t len); +void Sec_Eng_SHA256_Init(SEC_Eng_SHA256_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,SEC_ENG_SHA_Type shaType,uint32_t *shaTmpBuf,uint32_t *padding); +void Sec_Eng_SHA_Start(SEC_ENG_SHA_ID_Type shaNo); +BL_Err_Type Sec_Eng_SHA256_Update(SEC_Eng_SHA256_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,uint8_t *input,uint32_t len); +BL_Err_Type Sec_Eng_SHA256_Finish(SEC_Eng_SHA256_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,uint8_t *hash); +void Sec_Eng_SHA_Enable_Link(SEC_ENG_SHA_ID_Type shaNo); +void Sec_Eng_SHA_Disable_Link(SEC_ENG_SHA_ID_Type shaNo); +void Sec_Eng_SHA256_Link_Init(SEC_Eng_SHA256_Link_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,uint32_t linkAddr,uint32_t *shaTmpBuf,uint32_t *padding); +BL_Err_Type Sec_Eng_SHA256_Link_Update(SEC_Eng_SHA256_Link_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,uint8_t *input,uint32_t len); +BL_Err_Type Sec_Eng_SHA256_Link_Finish(SEC_Eng_SHA256_Link_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,uint8_t *hash); +void Sec_Eng_AES_Enable_Link(SEC_ENG_AES_ID_Type aesNo); +void Sec_Eng_AES_Disable_Link(SEC_ENG_AES_ID_Type aesNo); +BL_Err_Type Sec_Eng_AES_Link_Work(SEC_ENG_AES_ID_Type aesNo,uint32_t linkAddr,uint8_t *in,uint32_t len,uint8_t *out); +void Sec_Eng_PKA_Reset(void); +void Sec_Eng_PKA_BigEndian_Enable(void); +void Sec_Eng_PKA_Clear_Int(void); +void Sec_Eng_PKA_Read_Block(uint32_t *dest,uint32_t *src,uint32_t len); +void Sec_Eng_PKA_Write_Block(uint32_t *dest,uint32_t *src,uint32_t len); +void Sec_Eng_PKA_Write_Data(SEC_ENG_PKA_REG_SIZE_Type regType,uint8_t regIndex,uint32_t *data,uint16_t size,uint8_t lastOp); +void Sec_Eng_PKA_Read_Data(SEC_ENG_PKA_REG_SIZE_Type regType,uint8_t regIdx,uint32_t *result,uint8_t retSize); +void Sec_Eng_PKA_CREG(SEC_ENG_PKA_REG_SIZE_Type dRegType,uint8_t dRegIdx,uint8_t size,uint8_t lastOp); +void Sec_Eng_PKA_Move_Data(uint8_t dRegType,uint8_t dRegIdx,uint8_t s0RegType,uint8_t s0RegIdx,uint8_t lastOp); +void Sec_Eng_PKA_MREM(uint8_t dRegType,uint8_t dRegIdx,uint8_t s0RegType,uint8_t s0RegIdx,uint8_t s2RegType,uint8_t s2RegIdx,uint8_t lastOp); +void Sec_Eng_PKA_MEXP(uint8_t dRegType,uint8_t dRegIdx,uint8_t s0RegType,uint8_t s0RegIdx,uint8_t s1RegType,uint8_t s1RegIdx,uint8_t s2RegType,uint8_t s2RegIdx,uint8_t lastOp); +void Sec_Eng_PKA_LCMP(uint8_t *cout,uint8_t s0RegType,uint8_t s0RegIdx,uint8_t s1RegType,uint8_t s1RegIdx); +void Sec_Eng_PKA_LSUB(uint8_t dRegType,uint8_t dRegIdx,uint8_t s0RegType,uint8_t s0RegIdx,uint8_t s1RegType,uint8_t s1RegIdx,uint8_t lastOp); +void Sec_Eng_PKA_LMUL(uint8_t dRegType,uint8_t dRegIdx,uint8_t s0RegType,uint8_t s0RegIdx,uint8_t s1RegType,uint8_t s1RegIdx,uint8_t lastOp); +void Sec_Eng_PKA_LDIV(uint8_t dRegType,uint8_t dRegIdx,uint8_t s0RegType,uint8_t s0RegIdx,uint8_t s2RegType,uint8_t s2RegIdx,uint8_t lastOp); +void Sec_Eng_PKA_LMUL2N(uint8_t dRegType,uint8_t dRegIdx,uint8_t s0RegType,uint8_t s0RegIdx,uint16_t bit_shift,uint8_t lastOp); +void SEC_Eng_IntMask(SEC_ENG_INT_Type intType,BL_Mask_Type intMask); +void DMA_Enable(void); +void DMA_Channel_Enable(uint8_t ch); +void DMA_LLI_Init(uint8_t ch,DMA_LLI_Cfg_Type *lliCfg); +void DMA_LLI_Update(uint8_t ch,uint32_t LLI); +void DMA_IntMask(uint8_t ch,DMA_INT_Type intType,BL_Mask_Type intMask); +void Default_Handler(void); +BL_Err_Type GLB_Set_UART_CLK(uint8_t enable,HBN_UART_CLK_Type clkSel,uint8_t div); +BL_Err_Type GLB_Set_ADC_CLK(uint8_t enable,GLB_ADC_CLK_Type clkSel,uint8_t div); +BL_Err_Type GLB_UART_Fun_Sel(GLB_UART_SIG_Type sig,GLB_UART_SIG_FUN_Type fun); +BL_Err_Type GLB_GPIO_Write(GLB_GPIO_Type gpioPin,uint32_t val); +uint32_t GLB_GPIO_Read(GLB_GPIO_Type gpioPin); +BL_Err_Type HBN_Set_UART_CLK_Sel(HBN_UART_CLK_Type clkSel); +BL_Err_Type HBN_Get_RTC_Timer_Val(uint32_t *valLow,uint32_t *valHigh); +void TIMER_SetCompValue(TIMER_Chan_Type timerCh,TIMER_Comp_ID_Type cmpNo,uint32_t val); +void TIMER_SetCountMode(TIMER_Chan_Type timerCh,TIMER_CountMode_Type countMode); +void TIMER_ClearIntStatus(TIMER_Chan_Type timerCh,TIMER_Comp_ID_Type cmpNo); +BL_Err_Type TIMER_Init(TIMER_CFG_Type *timerCfg); +void TIMER_Enable(TIMER_Chan_Type timerCh); +void TIMER_Disable(TIMER_Chan_Type timerCh); +void TIMER_IntMask(TIMER_Chan_Type timerCh,TIMER_INT_Type intType,BL_Mask_Type intMask); +void WDT_Set_Clock(TIMER_ClkSrc_Type clkSrc,uint8_t div); +void WDT_SetCompValue(uint16_t val); +void WDT_ResetCounterValue(void); +void WDT_Enable(void); +void WDT_Disable(void); +void WDT_IntMask(WDT_INT_Type intType,BL_Mask_Type intMask); +uint32_t EF_Ctrl_Get_Byte_Zero_Cnt(uint8_t val); +BL_Err_Type EF_Ctrl_Read_MAC_Address(uint8_t *mac); +uint8_t EF_Ctrl_Is_MAC_Address_Slot_Empty(uint8_t slot,uint8_t reload); +BL_Err_Type EF_Ctrl_Read_MAC_Address_Opt(uint8_t slot,uint8_t *mac,uint8_t reload); +uint EF_Ctrl_Is_CapCode_Slot_Empty(int param_1,int param_2); +BL_Err_Type EF_Ctrl_Read_CapCode_Opt(uint8_t slot,uint8_t *code,uint8_t reload); +uint8_t EF_Ctrl_Is_PowerOffset_Slot_Empty(uint8_t slot,uint8_t reload); +BL_Err_Type EF_Ctrl_Read_PowerOffset_Opt(uint8_t slot,int8_t *pwrOffset,uint8_t reload); +int8_t mfg_media_read_xtal_capcode(uint8_t *capcode,uint8_t reload); +int8_t mfg_media_read_poweroffset(int8_t *pwrOffset,uint8_t reload); +int8_t mfg_media_read_macaddr(uint8_t *mac,uint8_t reload); +void bflb_platform_usart_dbg_send(uint8_t *data,uint32_t len); +void bflb_platform_printf(char *fmt,...); +void Default_Handler_Stub(void); +int8_t mfg_efuse_read_xtal_capcode(uint8_t *capcode,uint8_t reload); +int8_t mfg_efuse_read_poweroffset(int8_t *pwrOffset,uint8_t reload); +int8_t mfg_efuse_read_macaddr(uint8_t *mac,uint8_t reload); +int8_t mfg_flash_read_xtal_capcode(uint8_t *capcode,uint8_t reload); +int8_t mfg_flash_read_poweroffset(int8_t *pwrOffset,uint8_t reload); +int8_t mfg_flash_read_macaddr(uint8_t *mac,uint8_t reload); +void Bl_F(uchar *digest,uchar *digest1,char *password,uchar *ssid,int ssidlength,int iterations,int count,uchar *output); +int Bl_PasswordHash(char *password,uchar *ssid,int ssidlength,uchar *output); +int bl60x_fw_password_hash(char *password,uchar *ssid,int ssidlength,uchar *output); +int bl_mtd_open(char *name,bl_mtd_handle_t *handle,uint flags); +int bl_mtd_close(bl_mtd_handle_t handle); +int bl_mtd_info(bl_mtd_handle_t handle,bl_mtd_info_t *info); +int bl_mtd_erase(bl_mtd_handle_t handle,uint addr,uint size); +int bl_mtd_erase_all(bl_mtd_handle_t handle); +int bl_mtd_write(bl_mtd_handle_t handle,uint addr,uint size,uint8_t *data); +int bl_mtd_read(bl_mtd_handle_t handle,uint addr,uint size,uint8_t *data); +int bloop_init(loop_ctx *loop); +int bloop_handler_register(loop_ctx *loop,loop_evt_handler *handler,int priority); +void bloop_timer_init(loop_timer *timer,int use_auto_free); +void bloop_timer_configure(loop_timer *timer,uint delay_ms,anon_subr_void_loop_ctx_ptr_loop_timer_ptr_void_ptr *cb,void *arg,int idx_task,uint32_t evt_type_map); +void bloop_timer_repeat_enable(loop_timer *timer); +void bloop_timer_repeat_reconfigure(loop_timer *timer); +void bloop_timer_register(loop_ctx *loop,loop_timer *timer); +void bloop_wait_startup(loop_ctx *loop); +void bloop_evt_set_async(loop_ctx *loop,uint evt,uint32_t evt_map); +void bloop_evt_set_sync(loop_ctx *loop,uint evt,uint32_t evt_map); +void bloop_evt_unset_sync(loop_ctx *loop,uint evt); +void bloop_run(loop_ctx *param_1); +int bloop_status_dump(loop_ctx *loop); +int loop_evt_entity_sys_handler(loop_ctx *loop,loop_evt_handler *handler,loop_msg *msg); +int loop_evt_entity_sys_evt(loop_ctx *loop,loop_evt_handler *handler,uint32_t *bitmap_evt,uint32_t *evt_type_map); +void get_f32_reg(void); +void put_f32_reg(void); +int backtrace_riscv(anon_subr_int_char_ptr *print_func,uintptr_t *regs); +void set_if(netif *netif,char *ip_addr,char *gw_addr,char *nm_addr); +int block_cipher_df(uchar *output,uchar *data,size_t data_len); +int ctr_drbg_update_internal(mbedtls_ctr_drbg_context.conflict *ctx,uchar *data); +void mbedtls_ctr_drbg_init(mbedtls_ctr_drbg_context.conflict *ctx); +void mbedtls_ctr_drbg_free(mbedtls_ctr_drbg_context.conflict *ctx); +int mbedtls_ctr_drbg_reseed(mbedtls_ctr_drbg_context.conflict *ctx,uchar *additional,size_t len); +int mbedtls_ctr_drbg_seed_entropy_len(mbedtls_ctr_drbg_context.conflict *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_entropy,void *p_entropy,uchar *custom,size_t len,size_t entropy_len); +int mbedtls_ctr_drbg_seed(mbedtls_ctr_drbg_context.conflict *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_entropy,void *p_entropy,uchar *custom,size_t len); +int mbedtls_ctr_drbg_random_with_add(void *p_rng,uchar *output,size_t output_len,uchar *additional,size_t add_len); +int mbedtls_ctr_drbg_random(void *p_rng,uchar *output,size_t output_len); +int entropy_update(mbedtls_entropy_context *ctx,uchar source_id,uchar *data,size_t len); +int entropy_gather_internal(mbedtls_entropy_context *ctx); +void mbedtls_entropy_init(mbedtls_entropy_context *ctx); +void mbedtls_entropy_free(mbedtls_entropy_context *ctx); +int mbedtls_entropy_func(void *data,uchar *output,size_t len); +int mbedtls_platform_entropy_poll(void *data,uchar *output,size_t len,size_t *olen); +void mbedtls_pk_init(mbedtls_pk_context *ctx); +void mbedtls_pk_free(mbedtls_pk_context *ctx); +mbedtls_pk_info_t * mbedtls_pk_info_from_type(mbedtls_pk_type_t pk_type); +int mbedtls_pk_setup(mbedtls_pk_context *ctx,mbedtls_pk_info_t *info); +int mbedtls_pk_can_do(mbedtls_pk_context *ctx,mbedtls_pk_type_t type); +int mbedtls_pk_verify(mbedtls_pk_context *ctx,mbedtls_md_type_t md_alg,uchar *hash,size_t hash_len,uchar *sig,size_t sig_len); +int mbedtls_pk_sign(mbedtls_pk_context *ctx,mbedtls_md_type_t md_alg,uchar *hash,size_t hash_len,uchar *sig,size_t *sig_len,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng); +int mbedtls_pk_decrypt(mbedtls_pk_context *ctx,uchar *input,size_t ilen,uchar *output,size_t *olen,size_t osize,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng); +int mbedtls_pk_encrypt(mbedtls_pk_context *ctx,uchar *input,size_t ilen,uchar *output,size_t *olen,size_t osize,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng); +size_t mbedtls_pk_get_bitlen(mbedtls_pk_context *ctx); +int mbedtls_pk_verify_ext(mbedtls_pk_type_t type,void *options,mbedtls_pk_context *ctx,mbedtls_md_type_t md_alg,uchar *hash,size_t hash_len,uchar *sig,size_t sig_len); +int mbedtls_pk_debug(mbedtls_pk_context *ctx,mbedtls_pk_debug_item *items); +char * mbedtls_pk_get_name(mbedtls_pk_context *ctx); +mbedtls_pk_type_t mbedtls_pk_get_type(mbedtls_pk_context *ctx); +int pk_use_ecparams(mbedtls_asn1_buf *params,mbedtls_ecp_group *grp); +int pk_parse_key_pkcs1_der(mbedtls_rsa_context *rsa,uchar *key,size_t keylen); +int pk_parse_key_sec1_der(mbedtls_ecp_keypair *eck,uchar *key,size_t keylen); +int pk_get_pk_alg(uchar **p,uchar *end,mbedtls_pk_type_t *pk_alg,mbedtls_asn1_buf *params); +int pk_parse_key_pkcs8_unencrypted_der(mbedtls_pk_context *pk,uchar *key,size_t keylen); +int mbedtls_pk_load_file(char *path,uchar **buf,size_t *n); +int mbedtls_pk_parse_subpubkey(uchar **p,uchar *end,mbedtls_pk_context *pk); +int mbedtls_pk_parse_key(mbedtls_pk_context *pk,uchar *key,size_t keylen,uchar *pwd,size_t pwdlen); +int mbedtls_pk_parse_keyfile(mbedtls_pk_context *ctx,char *path,char *pwd); +int rsa_can_do(mbedtls_pk_type_t type); +size_t rsa_get_bitlen(void *ctx); +void rsa_debug(void *ctx,mbedtls_pk_debug_item *items); +int eckey_can_do(mbedtls_pk_type_t type); +size_t eckey_get_bitlen(void *ctx); +void eckey_debug(void *ctx,mbedtls_pk_debug_item *items); +int eckeydh_can_do(mbedtls_pk_type_t type); +void rsa_free_wrap(void *ctx); +void * rsa_alloc_wrap(void); +int rsa_check_pair_wrap(mbedtls_rsa_context *pub,mbedtls_rsa_context *prv); +int rsa_encrypt_wrap(void *ctx,uchar *input,size_t ilen,uchar *output,size_t *olen,size_t osize,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng); +int rsa_decrypt_wrap(void *ctx,uchar *input,size_t ilen,uchar *output,size_t *olen,size_t osize,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng); +int rsa_sign_wrap(void *ctx,mbedtls_md_type_t md_alg,uchar *hash,size_t hash_len,uchar *sig,size_t *sig_len,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng); +int rsa_verify_wrap(void *ctx,mbedtls_md_type_t md_alg,uchar *hash,size_t hash_len,uchar *sig,size_t sig_len); +void eckey_free_wrap(void *ctx); +void * eckey_alloc_wrap(void); +int eckey_check_pair(mbedtls_ecp_keypair *pub,mbedtls_ecp_keypair *prv); +void mgf_mask(uchar *dst,size_t dlen,uchar *src,size_t slen,mbedtls_md_context_t *md_ctx); +void mbedtls_rsa_init(mbedtls_rsa_context *ctx,int padding,int hash_id); +int mbedtls_rsa_check_pubkey(mbedtls_rsa_context *ctx); +int mbedtls_rsa_check_privkey(mbedtls_rsa_context *ctx); +int mbedtls_rsa_check_pub_priv(mbedtls_rsa_context *pub,mbedtls_rsa_context *prv); +int mbedtls_rsa_public(mbedtls_rsa_context *ctx,uchar *input,uchar *output); +int mbedtls_rsa_private(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,uchar *input,uchar *output); +int mbedtls_rsa_rsaes_oaep_encrypt(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,uchar *label,size_t label_len,size_t ilen,uchar *input,uchar *output); +int mbedtls_rsa_rsaes_pkcs1_v15_encrypt(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,size_t ilen,uchar *input,uchar *output); +int mbedtls_rsa_pkcs1_encrypt(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,size_t ilen,uchar *input,uchar *output); +int mbedtls_rsa_rsaes_oaep_decrypt(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,uchar *label,size_t label_len,size_t *olen,uchar *input,uchar *output,size_t output_max_len); +int mbedtls_rsa_rsaes_pkcs1_v15_decrypt(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,size_t *olen,uchar *input,uchar *output,size_t output_max_len); +int mbedtls_rsa_pkcs1_decrypt(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,size_t *olen,uchar *input,uchar *output,size_t output_max_len); +int mbedtls_rsa_rsassa_pss_sign(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig); +int mbedtls_rsa_rsassa_pkcs1_v15_sign(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig); +int mbedtls_rsa_pkcs1_sign(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig); +int mbedtls_rsa_rsassa_pss_verify_ext(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,mbedtls_md_type_t mgf1_hash_id,int expected_salt_len,uchar *sig); +int mbedtls_rsa_rsassa_pss_verify(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig); +int mbedtls_rsa_rsassa_pkcs1_v15_verify(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig); +int mbedtls_rsa_pkcs1_verify(mbedtls_rsa_context *ctx,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng,int mode,mbedtls_md_type_t md_alg,uint hashlen,uchar *hash,uchar *sig); +void mbedtls_rsa_free(mbedtls_rsa_context *ctx); +void mbedtls_sha256_init(mbedtls_sha256_context *ctx); +void mbedtls_sha256_free(mbedtls_sha256_context *ctx); +void mbedtls_sha256_clone(mbedtls_sha256_context *dst,mbedtls_sha256_context *src); +void mbedtls_sha256_starts(mbedtls_sha256_context *ctx,int is224); +void mbedtls_sha256_process(mbedtls_sha256_context *ctx,uchar *data); +void mbedtls_sha256_update(mbedtls_sha256_context *ctx,uchar *input,size_t ilen); +void mbedtls_sha256_update(mbedtls_sha256_context *ctx,uchar *input,size_t ilen); +void mbedtls_sha256_finish(mbedtls_sha256_context *ctx,uchar *output); +void mbedtls_sha256(uchar *input,size_t ilen,uchar *output,int is224); +mbedtls_x509_crt * mbedtls_ssl_own_cert(mbedtls_ssl_context *ssl); +void mbedtls_zeroize(void *v,size_t n); +void ssl_swap_epochs(mbedtls_ssl_context *ssl); +void ssl_calc_finished_tls_sha256(mbedtls_ssl_context *ssl,uchar *buf,int from); +void ssl_calc_verify_tls_sha256(mbedtls_ssl_context *ssl,uchar *hash); +void ssl_flight_free(mbedtls_ssl_flight_item *flight); +int ssl_append_key_cert(mbedtls_ssl_key_cert **head,mbedtls_x509_crt *cert,mbedtls_pk_context *key); +void ssl_update_checksum_start(mbedtls_ssl_context *ssl,uchar *buf,size_t len); +void ssl_update_checksum_sha256(mbedtls_ssl_context *ssl,uchar *buf,size_t len); +size_t mbedtls_ssl_hdr_len(void); +void ssl_set_timer(mbedtls_ssl_context *ssl,uint32_t millisecs); +int ssl_check_timer(mbedtls_ssl_context *ssl); +int tls_prf_sha256(uchar *secret,size_t slen,char *label,uchar *random,size_t rlen,uchar *dstbuf,size_t dlen); +int mbedtls_ssl_derive_keys(mbedtls_ssl_context *ssl); +int mbedtls_ssl_flush_output(mbedtls_ssl_context *ssl); +void mbedtls_ssl_recv_flight_completed(mbedtls_ssl_context *ssl); +void mbedtls_ssl_send_flight_completed(mbedtls_ssl_context *ssl); +void mbedtls_ssl_update_handshake_status(mbedtls_ssl_context *ssl); +void mbedtls_ssl_optimize_checksum(mbedtls_ssl_context *ssl,mbedtls_ssl_ciphersuite_t *ciphersuite_info); +void mbedtls_ssl_reset_checksum(mbedtls_ssl_context *ssl); +void mbedtls_ssl_session_init(mbedtls_ssl_session *session); +void mbedtls_ssl_init(mbedtls_ssl_context *ssl); +void mbedtls_ssl_conf_authmode(mbedtls_ssl_config *conf,int authmode); +void mbedtls_ssl_conf_verify(mbedtls_ssl_config *conf,anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *f_vrfy,void *p_vrfy); +void mbedtls_ssl_conf_rng(mbedtls_ssl_config *conf,mbedtls_ssl_recv_t *f_rng,void *p_rng); +void mbedtls_ssl_set_bio(mbedtls_ssl_context *ssl,void *p_bio,mbedtls_ssl_send_t *f_send,mbedtls_ssl_recv_t *f_recv,mbedtls_ssl_recv_timeout_t.conflict1 *f_recv_timeout); +void mbedtls_ssl_conf_read_timeout(mbedtls_ssl_config *conf,uint32_t timeout); +int mbedtls_ssl_conf_own_cert(mbedtls_ssl_config *conf,mbedtls_x509_crt *own_cert,mbedtls_pk_context *pk_key); +void mbedtls_ssl_conf_ca_chain(mbedtls_ssl_config *conf,mbedtls_x509_crt *ca_chain,mbedtls_x509_crl *ca_crl); +int mbedtls_ssl_set_hostname(mbedtls_ssl_context *ssl,char *hostname); +int mbedtls_ssl_conf_alpn_protocols(mbedtls_ssl_config *conf,char **protos); +uint32_t mbedtls_ssl_get_verify_result(mbedtls_ssl_context *ssl); +char * mbedtls_ssl_get_ciphersuite(mbedtls_ssl_context *ssl); +char * mbedtls_ssl_get_version(mbedtls_ssl_context *ssl); +size_t mbedtls_ssl_get_record_expansion(mbedtls_ssl_context *param_1); +size_t mbedtls_ssl_get_max_frag_len(mbedtls_ssl_context *ssl); +mbedtls_x509_crt * mbedtls_ssl_get_peer_cert(mbedtls_ssl_context *ssl); +int mbedtls_ssl_handshake_step(mbedtls_ssl_context *ssl); +int mbedtls_ssl_handshake(mbedtls_ssl_context *ssl); +void mbedtls_ssl_transform_free(mbedtls_ssl_transform *transform); +void mbedtls_ssl_handshake_free(mbedtls_ssl_handshake_params *handshake); +void ssl_handshake_wrapup_free_hs_transform(mbedtls_ssl_context *ssl); +void mbedtls_ssl_session_free(mbedtls_ssl_session *session); +void mbedtls_ssl_handshake_wrapup(mbedtls_ssl_context *ssl); +int ssl_handshake_init(mbedtls_ssl_context *ssl); +int mbedtls_ssl_setup(mbedtls_ssl_context *ssl,mbedtls_ssl_config *conf); +void mbedtls_ssl_free(mbedtls_ssl_context *ssl); +void mbedtls_ssl_config_init(mbedtls_ssl_config *conf); +int mbedtls_ssl_config_defaults(mbedtls_ssl_config *conf,int endpoint,int transport,int preset); +void mbedtls_ssl_config_free(mbedtls_ssl_config *conf); +uchar mbedtls_ssl_sig_from_pk(mbedtls_pk_context *pk); +mbedtls_pk_type_t mbedtls_ssl_pk_alg_from_sig(uchar sig); +mbedtls_md_type_t mbedtls_ssl_md_alg_from_hash(uchar hash); +uchar mbedtls_ssl_hash_from_md_alg(int md); +int mbedtls_ssl_check_curve(mbedtls_ssl_context *ssl,mbedtls_ecp_group_id grp_id); +int mbedtls_ssl_check_cert_usage(mbedtls_x509_crt *cert,mbedtls_ssl_ciphersuite_t *ciphersuite,int cert_endpoint,uint32_t *flags); +void mbedtls_ssl_write_version(int major,int minor,int transport,uchar *ver); +int mbedtls_ssl_write_record(mbedtls_ssl_context *ssl); +int mbedtls_ssl_resend(mbedtls_ssl_context *ssl); +int mbedtls_ssl_fetch_input(mbedtls_ssl_context *ssl,size_t nb_want); +int mbedtls_ssl_prepare_handshake_record(mbedtls_ssl_context *ssl); +int mbedtls_ssl_handle_message_type(mbedtls_ssl_context *ssl); +int mbedtls_ssl_send_alert_message(mbedtls_ssl_context *ssl,uchar level,uchar message); +int mbedtls_ssl_send_fatal_handshake_failure(mbedtls_ssl_context *ssl); +int mbedtls_ssl_close_notify(mbedtls_ssl_context *ssl); +int mbedtls_ssl_write_certificate(mbedtls_ssl_context *ssl); +int mbedtls_ssl_write_change_cipher_spec(mbedtls_ssl_context *ssl); +int mbedtls_ssl_write_finished(mbedtls_ssl_context *ssl); +int mbedtls_ssl_write(mbedtls_ssl_context *ssl,uchar *buf,size_t len); +void mbedtls_ssl_read_version(int *major,int *minor,int transport,uchar *ver); +int mbedtls_ssl_read_record_layer(mbedtls_ssl_context *ssl); +int mbedtls_ssl_read_record(mbedtls_ssl_context *ssl); +int mbedtls_ssl_parse_certificate(mbedtls_ssl_context *ssl); +int mbedtls_ssl_parse_change_cipher_spec(mbedtls_ssl_context *ssl); +int mbedtls_ssl_parse_finished(mbedtls_ssl_context *ssl); +int mbedtls_ssl_read(mbedtls_ssl_context *ssl,uchar *buf,size_t len); +int mbedtls_ssl_set_calc_verify_md(mbedtls_ssl_context *ssl,int md); +void mbedtls_zeroize(void *v,size_t n); +int x509_memcasecmp(void *s1,void *s2,size_t len); +int x509_name_cmp(mbedtls_x509_name *a,mbedtls_x509_name *b); +int x509_check_wildcard(char *cn,mbedtls_x509_buf *name); +int x509_profile_check_key(mbedtls_x509_crt_profile *profile,mbedtls_pk_type_t pk_alg,mbedtls_pk_context *pk); +int mbedtls_x509_crt_info(char *buf,size_t size,char *prefix,mbedtls_x509_crt *crt); +int mbedtls_x509_crt_verify_info(char *buf,size_t size,char *prefix,uint32_t flags); +int mbedtls_x509_crt_check_key_usage(mbedtls_x509_crt *crt,uint usage); +int x509_crt_check_parent(mbedtls_x509_crt *child,mbedtls_x509_crt *parent,int top,int bottom); +int x509_crt_verify_top(mbedtls_x509_crt *child,mbedtls_x509_crt *trust_ca,mbedtls_x509_crt_profile *profile,int path_cnt,int self_cnt,uint32_t *flags,anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *f_vrfy,void *p_vrfy); +int x509_crt_verify_child(mbedtls_x509_crt *child,mbedtls_x509_crt *parent,mbedtls_x509_crt *trust_ca,mbedtls_x509_crl *ca_crl,mbedtls_x509_crt_profile *profile,int path_cnt,int self_cnt,uint32_t *flags,anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *f_vrfy,void *p_vrfy); +int mbedtls_x509_crt_check_extended_key_usage(mbedtls_x509_crt *crt,char *usage_oid,size_t usage_len); +int mbedtls_x509_crt_verify_with_profile(mbedtls_x509_crt *crt,mbedtls_x509_crt *trust_ca,mbedtls_x509_crl *ca_crl,mbedtls_x509_crt_profile *profile,char *cn,uint32_t *flags,anon_subr_int_void_ptr_mbedtls_x509_crt_ptr_int_uint32_t_ptr *f_vrfy,void *p_vrfy); +void mbedtls_x509_crt_init(mbedtls_x509_crt *crt); +void mbedtls_x509_crt_free(mbedtls_x509_crt *crt); +int mbedtls_x509_crt_parse_der(mbedtls_x509_crt *chain,uchar *buf,size_t buflen); +int mbedtls_x509_crt_parse(mbedtls_x509_crt *chain,uchar *buf,size_t buflen); +int mbedtls_x509_crt_parse_file(mbedtls_x509_crt *chain,char *path); +int net_would_block(void); +void mbedtls_net_init(mbedtls_net_context *ctx); +int mbedtls_net_connect(mbedtls_net_context *ctx,char *host,char *port,int proto); +int mbedtls_net_set_block(mbedtls_net_context *ctx); +int mbedtls_net_recv(void *ctx,uchar *buf,size_t len); +int mbedtls_net_send(void *ctx,uchar *buf,size_t len); +int mbedtls_net_recv_timeout(void *ctx,uchar *buf,size_t len,uint32_t timeout); +void mbedtls_net_free(mbedtls_net_context *ctx); +void * mycalloc(size_t numitems,size_t size); +void aes_gen_tables(void); +void mbedtls_aes_init(mbedtls_aes_context *ctx); +void mbedtls_aes_free(mbedtls_aes_context *ctx); +int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx,uchar *key,uint keybits); +int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx,uchar *key,uint keybits); +void mbedtls_aes_encrypt(mbedtls_aes_context *ctx,uchar *input,uchar *output); +void mbedtls_aes_decrypt(mbedtls_aes_context *ctx,uchar *input,uchar *output); +int mbedtls_aes_crypt_ecb(mbedtls_aes_context *ctx,int mode,uchar *input,uchar *output); +int mbedtls_aes_crypt_cbc(mbedtls_aes_context *ctx,int mode,size_t length,uchar *iv,uchar *input,uchar *output); +int mbedtls_aes_crypt_cfb128(mbedtls_aes_context *ctx,int mode,size_t length,size_t *iv_off,uchar *iv,uchar *input,uchar *output); +int mbedtls_aes_crypt_ctr(mbedtls_aes_context *ctx,size_t length,size_t *nc_off,uchar *nonce_counter,uchar *stream_block,uchar *input,uchar *output); +int mbedtls_asn1_get_len(uchar **p,uchar *end,size_t *len); +int mbedtls_asn1_get_tag(uchar **p,uchar *end,size_t *len,int tag); +int mbedtls_asn1_get_bool(uchar **p,uchar *end,int *val); +int mbedtls_asn1_get_int(uchar **p,uchar *end,int *val); +int mbedtls_asn1_get_mpi(uchar **p,uchar *end,mbedtls_mpi *X); +int mbedtls_asn1_get_bitstring(uchar **p,uchar *end,mbedtls_asn1_bitstring *bs); +int mbedtls_asn1_get_bitstring_null(uchar **p,uchar *end,size_t *len); +int mbedtls_asn1_get_sequence_of(uchar **p,uchar *end,mbedtls_asn1_sequence *cur,int tag); +int mbedtls_asn1_get_alg(uchar **p,uchar *end,mbedtls_asn1_buf *alg,mbedtls_asn1_buf *params); +void mpi_sub_hlp(size_t n,mbedtls_mpi_uint *s,mbedtls_mpi_uint *d); +void mpi_mul_hlp(size_t i,mbedtls_mpi_uint *s,mbedtls_mpi_uint *d,mbedtls_mpi_uint b); +void mbedtls_mpi_init(mbedtls_mpi *X); +void mbedtls_mpi_free(mbedtls_mpi *X); +int mbedtls_mpi_grow(mbedtls_mpi *X,size_t nblimbs); +int mbedtls_mpi_shrink(mbedtls_mpi *X,size_t nblimbs); +int mbedtls_mpi_copy(mbedtls_mpi *X,mbedtls_mpi *Y); +int mbedtls_mpi_safe_cond_assign(mbedtls_mpi *X,mbedtls_mpi *Y,uchar assign); +int mbedtls_mpi_lset(mbedtls_mpi *X,mbedtls_mpi_sint z); +int mbedtls_mpi_get_bit(mbedtls_mpi *X,size_t pos); +size_t mbedtls_mpi_lsb(mbedtls_mpi *X); +size_t mbedtls_mpi_bitlen(mbedtls_mpi *X); +size_t mbedtls_mpi_size(mbedtls_mpi *X); +int mbedtls_mpi_read_binary(mbedtls_mpi *X,uchar *buf,size_t buflen); +int mbedtls_mpi_write_binary(mbedtls_mpi *X,uchar *buf,size_t buflen); +int mbedtls_mpi_shift_l(mbedtls_mpi *X,size_t count); +int mbedtls_mpi_shift_r(mbedtls_mpi *X,size_t count); +int mbedtls_mpi_cmp_abs(mbedtls_mpi *X,mbedtls_mpi *Y); +int mpi_montmul(mbedtls_mpi *A,mbedtls_mpi *B,mbedtls_mpi *N,mbedtls_mpi_uint mm,mbedtls_mpi *T); +int mbedtls_mpi_cmp_mpi(mbedtls_mpi *X,mbedtls_mpi *Y); +int mbedtls_mpi_cmp_int(mbedtls_mpi *X,mbedtls_mpi_sint z); +int mbedtls_mpi_add_abs(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *B); +int mbedtls_mpi_sub_abs(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *B); +int mbedtls_mpi_add_mpi(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *B); +int mbedtls_mpi_sub_mpi(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *B); +int mbedtls_mpi_sub_int(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi_sint b); +int mbedtls_mpi_mul_mpi(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *B); +int mbedtls_mpi_mul_int(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi_uint b); +int mbedtls_mpi_div_mpi(mbedtls_mpi *Q,mbedtls_mpi *R,mbedtls_mpi *A,mbedtls_mpi *B); +int mbedtls_mpi_mod_mpi(mbedtls_mpi *R,mbedtls_mpi *A,mbedtls_mpi *B); +int mbedtls_mpi_exp_mod(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *E,mbedtls_mpi *N,mbedtls_mpi *_RR); +int mbedtls_mpi_gcd(mbedtls_mpi *G,mbedtls_mpi *A,mbedtls_mpi *B); +int mbedtls_mpi_fill_random(mbedtls_mpi *X,size_t size,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng); +int mbedtls_mpi_inv_mod(mbedtls_mpi *X,mbedtls_mpi *A,mbedtls_mpi *N); +uint mbedtls_cipher_get_block_size(mbedtls_cipher_context_t *ctx); +void add_pkcs_padding(uchar *output,size_t output_len,size_t data_len); +int get_pkcs_padding(uchar *input,size_t input_len,size_t *data_len); +void add_zeros_padding(uchar *output,size_t output_len,size_t data_len); +int get_no_padding(uchar *input,size_t input_len,size_t *data_len); +int get_zeros_padding(uchar *input,size_t input_len,size_t *data_len); +mbedtls_cipher_info_t * mbedtls_cipher_info_from_type(mbedtls_cipher_type_t cipher_type); +mbedtls_cipher_info_t *mbedtls_cipher_info_from_values(mbedtls_cipher_id_t cipher_id,int key_bitlen,mbedtls_cipher_mode_t mode); +void mbedtls_cipher_init(mbedtls_cipher_context_t *ctx); +void mbedtls_cipher_free(mbedtls_cipher_context_t *ctx); +int mbedtls_cipher_setkey(mbedtls_cipher_context_t *ctx,uchar *key,int key_bitlen,mbedtls_operation_t operation); +int mbedtls_cipher_set_iv(mbedtls_cipher_context_t *ctx,uchar *iv,size_t iv_len); +int mbedtls_cipher_reset(mbedtls_cipher_context_t *ctx); +int mbedtls_cipher_update(mbedtls_cipher_context_t *ctx,uchar *input,size_t ilen,uchar *output,size_t *olen); +int mbedtls_cipher_finish(mbedtls_cipher_context_t *ctx,uchar *output,size_t *olen); +int mbedtls_cipher_set_padding_mode(mbedtls_cipher_context_t *ctx,mbedtls_cipher_padding_t mode); +int mbedtls_cipher_setup(mbedtls_cipher_context_t *ctx,mbedtls_cipher_info_t *cipher_info); +int mbedtls_cipher_crypt(mbedtls_cipher_context_t *ctx,uchar *iv,size_t iv_len,uchar *input,size_t ilen,uchar *output,size_t *olen); +int mbedtls_cipher_auth_encrypt(mbedtls_cipher_context_t *ctx,uchar *iv,size_t iv_len,uchar *ad,size_t ad_len,uchar *input,size_t ilen,uchar *output,size_t *olen,uchar *tag,size_t tag_len); +int mbedtls_cipher_auth_decrypt(mbedtls_cipher_context_t *ctx,uchar *iv,size_t iv_len,uchar *ad,size_t ad_len,uchar *input,size_t ilen,uchar *output,size_t *olen,uchar *tag,size_t tag_len); +void gcm_ctx_free(void *ctx); +void * gcm_ctx_alloc(void); +int gcm_aes_setkey_wrap(void *ctx,uchar *key,uint key_bitlen); +void aes_ctx_free(void *ctx); +void * aes_ctx_alloc(void); +int aes_setkey_dec_wrap(mbedtls_aes_context *ctx,uchar *key,uint keybits); +int aes_setkey_enc_wrap(mbedtls_aes_context *ctx,uchar *key,uint keybits); +int aes_crypt_ctr_wrap(mbedtls_aes_context *ctx,size_t length,size_t *nc_off,uchar *nonce_counter,uchar *stream_block,uchar *input,uchar *output); +int aes_crypt_cfb128_wrap(mbedtls_aes_context *ctx,int mode,size_t length,size_t *iv_off,uchar *iv,uchar *input,uchar *output); +int aes_crypt_cbc_wrap(mbedtls_aes_context *ctx,int mode,size_t length,uchar *iv,uchar *input,uchar *output); +int aes_crypt_ecb_wrap(mbedtls_aes_context *ctx,int mode,uchar *input,uchar *output); +void debug_send_line(int level,char *file,int line,char *str); +void mbedtls_debug_print_mpi(mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,mbedtls_mpi *X); +void mbedtls_debug_print_msg(mbedtls_ssl_context *ssl,int level,char *file,int line,char *format,...); +void mbedtls_debug_print_ret(mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,int ret); +void mbedtls_debug_print_buf(mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,uchar *buf,size_t len); +void mbedtls_debug_print_mpi(mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,mbedtls_mpi *X); +void mbedtls_debug_print_ecp(mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,mbedtls_ecp_point *X); +void mbedtls_debug_print_ecp(mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,mbedtls_ecp_point *X); +void mbedtls_debug_print_crt(mbedtls_ssl_context *ssl,int level,char *file,int line,char *text,mbedtls_x509_crt *crt); +ecp_curve_type ecp_get_type(mbedtls_ecp_group *grp); +int ecp_safe_invert_jac(mbedtls_ecp_group *grp,mbedtls_ecp_point *Q,uchar inv); +int ecp_select_comb(mbedtls_ecp_group *grp,mbedtls_ecp_point *R,mbedtls_ecp_point *T,uchar t_len,uchar i); +int ecp_modp(mbedtls_mpi *N,mbedtls_ecp_group *grp); +int ecp_double_jac(mbedtls_ecp_group *grp,mbedtls_ecp_point *R,mbedtls_ecp_point *P); +int ecp_normalize_jac(mbedtls_ecp_group *grp,mbedtls_ecp_point *pt); +int ecp_normalize_jac_many(mbedtls_ecp_group *grp,mbedtls_ecp_point **T,size_t t_len); +void mbedtls_ecp_point_init(mbedtls_ecp_point *pt); +void mbedtls_ecp_point_free(mbedtls_ecp_point *pt); +mbedtls_ecp_group_id * mbedtls_ecp_grp_id_list(void); +void mbedtls_ecp_point_init(mbedtls_ecp_point *pt); +void mbedtls_ecp_group_init(mbedtls_ecp_group *grp); +void mbedtls_ecp_keypair_init(mbedtls_ecp_keypair *key); +void mbedtls_ecp_point_free(mbedtls_ecp_point *pt); +void mbedtls_ecp_group_free(mbedtls_ecp_group *grp); +void mbedtls_ecp_keypair_free(mbedtls_ecp_keypair *key); +int mbedtls_ecp_copy(mbedtls_ecp_point *P,mbedtls_ecp_point *Q); +int mbedtls_ecp_group_copy(mbedtls_ecp_group *dst,mbedtls_ecp_group *src); +int mbedtls_ecp_set_zero(mbedtls_ecp_point *pt); +int ecp_add_mixed(mbedtls_ecp_group *grp,mbedtls_ecp_point *R,mbedtls_ecp_point *P,mbedtls_ecp_point *Q); +int ecp_mul_comb(mbedtls_ecp_group *grp,mbedtls_ecp_point *R,mbedtls_mpi *m,mbedtls_ecp_point *P,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng); +int mbedtls_ecp_point_read_binary(mbedtls_ecp_group *grp,mbedtls_ecp_point *pt,uchar *buf,size_t ilen); +int mbedtls_ecp_check_pubkey(mbedtls_ecp_group *grp,mbedtls_ecp_point *pt); +int mbedtls_ecp_check_privkey(mbedtls_ecp_group *grp,mbedtls_mpi *d); +int mbedtls_ecp_mul(mbedtls_ecp_group *grp,mbedtls_ecp_point *R,mbedtls_mpi *m,mbedtls_ecp_point *P,anon_subr_int_void_ptr_uchar_ptr_size_t *f_rng,void *p_rng); +int mbedtls_ecp_check_pub_priv(mbedtls_ecp_keypair *pub,mbedtls_ecp_keypair *prv); +int ecp_mod_koblitz(mbedtls_mpi *N,mbedtls_mpi_uint *Rp,size_t p_limbs); +int ecp_mod_p224k1(mbedtls_mpi *N); +int ecp_mod_p256k1(mbedtls_mpi *N); +int mbedtls_ecp_group_load(mbedtls_ecp_group *grp,mbedtls_ecp_group_id id); +void gcm_mult(mbedtls_gcm_context *ctx,uchar *x,uchar *output); +void mbedtls_gcm_init(mbedtls_gcm_context *ctx); +int mbedtls_gcm_setkey(mbedtls_gcm_context *ctx,mbedtls_cipher_id_t cipher,uchar *key,uint keybits); +int mbedtls_gcm_starts(mbedtls_gcm_context *ctx,int mode,uchar *iv,size_t iv_len,uchar *add,size_t add_len); +int mbedtls_gcm_update(mbedtls_gcm_context *ctx,size_t length,uchar *input,uchar *output); +int mbedtls_gcm_finish(mbedtls_gcm_context *ctx,uchar *tag,size_t tag_len); +int mbedtls_gcm_crypt_and_tag(mbedtls_gcm_context *ctx,int mode,size_t length,uchar *iv,size_t iv_len,uchar *add,size_t add_len,uchar *input,uchar *output,size_t tag_len,uchar *tag); +int mbedtls_gcm_auth_decrypt(mbedtls_gcm_context *ctx,size_t length,uchar *iv,size_t iv_len,uchar *add,size_t add_len,uchar *tag,size_t tag_len,uchar *input,uchar *output); +void mbedtls_gcm_free(mbedtls_gcm_context *ctx); +mbedtls_md_info_t * mbedtls_md_info_from_type(mbedtls_md_type_t md_type); +void mbedtls_md_init(mbedtls_md_context_t *ctx); +void mbedtls_md_free(mbedtls_md_context_t *ctx); +int mbedtls_md_setup(mbedtls_md_context_t *ctx,mbedtls_md_info_t *md_info,int hmac); +int mbedtls_md_starts(mbedtls_md_context_t *ctx); +int mbedtls_md_update(mbedtls_md_context_t *ctx,uchar *input,size_t ilen); +int mbedtls_md_finish(mbedtls_md_context_t *ctx,uchar *output); +int mbedtls_md(mbedtls_md_info_t *md_info,uchar *input,size_t ilen,uchar *output); +int mbedtls_md_hmac_starts(mbedtls_md_context_t *ctx,uchar *key,size_t keylen); +int mbedtls_md_hmac_update(mbedtls_md_context_t *ctx,uchar *input,size_t ilen); +int mbedtls_md_hmac_finish(mbedtls_md_context_t *ctx,uchar *output); +int mbedtls_md_hmac_reset(mbedtls_md_context_t *ctx); +int mbedtls_md_process(mbedtls_md_context_t *ctx,uchar *data); +uchar mbedtls_md_get_size(mbedtls_md_info_t *md_info); +void md5_process_wrap(mbedtls_md5_context *ctx,uchar *data); +void md5_clone_wrap(mbedtls_md5_context *dst,mbedtls_md5_context *src); +void md5_ctx_free(void *ctx); +void * md5_ctx_alloc(void); +void md5_finish_wrap(mbedtls_md5_context *ctx,uchar *output); +void md5_update_wrap(mbedtls_md5_context *ctx,uchar *input,size_t ilen); +void md5_starts_wrap(mbedtls_md5_context *ctx); +void sha1_process_wrap(mbedtls_sha1_context *ctx,uchar *data); +void sha1_clone_wrap(mbedtls_sha1_context *dst,mbedtls_sha1_context *src); +void sha1_ctx_free(void *ctx); +void * sha1_ctx_alloc(void); +void sha1_finish_wrap(mbedtls_sha1_context *ctx,uchar *output); +void sha1_update_wrap(mbedtls_sha1_context *ctx,uchar *input,size_t ilen); +void sha1_starts_wrap(mbedtls_sha1_context *ctx); +void sha224_process_wrap(mbedtls_sha256_context *ctx,uchar *data); +void sha224_clone_wrap(mbedtls_sha256_context *dst,mbedtls_sha256_context *src); +void sha224_ctx_free(void *ctx); +void * sha224_ctx_alloc(void); +void sha224_wrap(uchar *input,size_t ilen,uchar *output); +void sha256_wrap(uchar *input,size_t ilen,uchar *output); +void sha224_finish_wrap(mbedtls_sha256_context *ctx,uchar *output); +void sha224_update_wrap(mbedtls_sha256_context *ctx,uchar *input,size_t ilen); +void sha224_starts_wrap(void *ctx); +void sha256_starts_wrap(void *ctx); +oid_sig_alg_t * oid_sig_alg_from_asn1(mbedtls_asn1_buf *oid); +int mbedtls_oid_get_attr_short_name(mbedtls_asn1_buf *oid,char **short_name); +int mbedtls_oid_get_x509_ext_type(mbedtls_asn1_buf *oid,int *ext_type); +int mbedtls_oid_get_extended_key_usage(mbedtls_asn1_buf *oid,char **description); +int mbedtls_oid_get_sig_alg_desc(mbedtls_asn1_buf *oid,char **description); +int mbedtls_oid_get_sig_alg(mbedtls_asn1_buf *oid,mbedtls_md_type_t *md_alg,mbedtls_pk_type_t *pk_alg); +int mbedtls_oid_get_pk_alg(mbedtls_asn1_buf *oid,mbedtls_pk_type_t *pk_alg); +int mbedtls_oid_get_ec_grp(mbedtls_asn1_buf *oid,mbedtls_ecp_group_id *grp_id); +int mbedtls_oid_get_md_alg(mbedtls_asn1_buf *oid,mbedtls_md_type_t *md_alg); +int mbedtls_oid_get_oid_by_md(mbedtls_md_type_t md_alg,char **oid,size_t *olen); +void pem_aes_decrypt(uchar *aes_iv,uint keylen,uchar *buf,size_t buflen,uchar *pwd,size_t pwdlen); +void mbedtls_pem_init(mbedtls_pem_context *ctx); +int mbedtls_pem_read_buffer(mbedtls_pem_context *ctx,char *header,char *footer,uchar *data,uchar *pwd,size_t pwdlen,size_t *use_len); +void mbedtls_pem_free(mbedtls_pem_context *ctx); +void mbedtls_md5_init(mbedtls_md5_context *ctx); +void mbedtls_md5_free(mbedtls_md5_context *ctx); +void mbedtls_md5_clone(mbedtls_md5_context *dst,mbedtls_md5_context *src); +void mbedtls_md5_starts(mbedtls_md5_context *ctx); +void mbedtls_md5_process(mbedtls_md5_context *ctx,uchar *data); +void mbedtls_md5_update(mbedtls_md5_context *ctx,uchar *input,size_t ilen); +void mbedtls_md5_update(mbedtls_md5_context *ctx,uchar *input,size_t ilen); +void mbedtls_md5_finish(mbedtls_md5_context *ctx,uchar *output); +void mbedtls_md5(uchar *input,size_t ilen,uchar *output); +void mbedtls_sha1_init(mbedtls_sha1_context *ctx); +void mbedtls_sha1_free(mbedtls_sha1_context *ctx); +void mbedtls_sha1_clone(mbedtls_sha1_context *dst,mbedtls_sha1_context *src); +void mbedtls_sha1_starts(mbedtls_sha1_context *ctx); +void mbedtls_sha1_process(mbedtls_sha1_context *ctx,uchar *data); +void mbedtls_sha1_update(mbedtls_sha1_context *ctx,uchar *input,size_t ilen); +void mbedtls_sha1_update(mbedtls_sha1_context *ctx,uchar *input,size_t ilen); +void mbedtls_sha1_finish(mbedtls_sha1_context *ctx,uchar *output); +void mbedtls_sha1(uchar *input,size_t ilen,uchar *output); +mbedtls_ssl_ciphersuite_t * mbedtls_ssl_ciphersuite_from_id(int ciphersuite); +int * mbedtls_ssl_list_ciphersuites(void); +char * mbedtls_ssl_get_ciphersuite_name(int ciphersuite_id); +mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_pk_alg(mbedtls_ssl_ciphersuite_t *info); +mbedtls_pk_context * mbedtls_ssl_own_key(mbedtls_ssl_context *ssl); +size_t mbedtls_ssl_hs_hdr_len(void); +int mbedtls_ssl_handshake_client_step(mbedtls_ssl_context *ssl); +mbedtls_pk_context * mbedtls_ssl_own_key(mbedtls_ssl_context *ssl); +int mbedtls_ssl_handshake_server_step(mbedtls_ssl_context *ssl); +int mbedtls_x509_get_serial(uchar **p,uchar *end,mbedtls_x509_buf *serial); +int mbedtls_x509_get_alg(uchar **p,uchar *end,mbedtls_x509_buf *alg,mbedtls_x509_buf *params); +int mbedtls_x509_get_name(uchar **p,uchar *end,mbedtls_x509_name *cur); +int mbedtls_x509_get_sig(uchar **p,uchar *end,mbedtls_x509_buf *sig); +int mbedtls_x509_get_sig_alg(mbedtls_x509_buf *sig_oid,mbedtls_x509_buf *sig_params,mbedtls_md_type_t *md_alg,mbedtls_pk_type_t *pk_alg,void **sig_opts); +int mbedtls_x509_get_ext(uchar **p,uchar *end,mbedtls_x509_buf *ext,int tag); +int mbedtls_x509_dn_gets(char *buf,size_t size,mbedtls_x509_name *dn); +int mbedtls_x509_serial_gets(char *buf,size_t size,mbedtls_x509_buf *serial); +int mbedtls_x509_sig_alg_gets(char *buf,size_t size,mbedtls_x509_buf *sig_oid,mbedtls_pk_type_t pk_alg,mbedtls_md_type_t md_alg,void *sig_opts); +int mbedtls_x509_key_size_helper(char *buf,size_t buf_size,char *name); +int mbedtls_x509_time_is_past(mbedtls_x509_time *to); +undefined4 mbedtls_x509_time_is_future(void); +int mbedtls_base64_decode(uchar *dst,size_t dlen,size_t *olen,uchar *src,size_t slen); +double modf(double __x,double *__iptr); +DItype __lshrdi3(shift_count_type b); +int __clzsi2(USItype x); +SFtype __floatundisf(void); +DItype __divdi3(void); +DItype __moddi3(void); +UDItype __udivdi3(void); +UDItype __umoddi3(void); +__gcc_CMPtype __eqdf2(void); +__gcc_CMPtype __gedf2(void); +__gcc_CMPtype __ledf2(void); +SItype __fixdfsi(void); +USItype __fixunsdfsi(void); +DFtype __floatsidf(SItype i); +DFtype __floatunsidf(USItype i); +SFtype __truncdfsf2(void); +int atoi(char *__nptr); +void _atoi_r(void); +undefined * __errno(void); +void * memchr(void *__s,int __c,size_t __n); +int memcmp(void *__s1,void *__s2,size_t __n); +void * memcpy(void *__dest,void *__src,size_t __n); +void * memmove(void *__dest,void *__src,size_t __n); +void * memset(void *__s,int __c,size_t __n); +char * strchr(char *__s,int __c); +int strcmp(char *__s1,char *__s2); +char * strcpy(char *__dest,char *__src); +size_t strlen(char *__s); +int strncmp(char *__s1,char *__s2,size_t __n); +char * strncpy(char *__dest,char *__src,size_t __n); +size_t strnlen(char *__string,size_t __maxlen); +char * strrchr(char *__s,int __c); +byte * two_way_long_needle(int param_1,int param_2,byte *param_3,byte *param_4); +char * strstr(char *__haystack,char *__needle); +uint _strtol_l.isra.0(undefined4 *param_1,byte *param_2,byte **param_3,uint param_4); +uint _strtol_r(undefined4 *param_1,byte *param_2,byte **param_3,uint param_4); +long strtol_l(char *__nptr,char **__endptr,int __base,__locale_t __loc); +long strtol(char *__nptr,char **__endptr,int __base); +int stat(char *__file,stat *__buf); +void _stat_r(int *param_1,undefined4 param_2,undefined4 param_3); +int _stat(int param_1,undefined4 param_2); +void _conv_stat(undefined2 *param_1,undefined4 *param_2); +BL_Err_Type AON_Power_On_BG(void); +BL_Err_Type AON_Power_Off_BG(void); +BL_Err_Type AON_Power_On_LDO11_SOC(void); +BL_Err_Type AON_Power_Off_LDO11_SOC(void); +BL_Err_Type AON_Power_On_LDO15_RF(void); +BL_Err_Type AON_Power_Off_LDO15_RF(void); +BL_Err_Type AON_Power_On_SFReg(void); +BL_Err_Type AON_Power_Off_SFReg(void); +BL_Err_Type AON_LowPower_Enter_PDS0(void); +BL_Err_Type AON_LowPower_Exit_PDS0(void); +void ASM_Delay_Us(uint32_t core,uint32_t cnt); +void BL602_Delay_US(uint32_t cnt); +void BL602_Delay_MS(uint32_t cnt); +void * BL602_MemCpy(void *dst,void *src,uint32_t n); +uint32_t * BL602_MemCpy4(uint32_t *dst,uint32_t *src,uint32_t n); +void * BL602_MemCpy_Fast(void *pdst,void *psrc,uint32_t n); +void * BL602_MemSet(void *s,uint8_t c,uint32_t n); +uint32_t * BL602_MemSet4(uint32_t *dst,uint32_t val,uint32_t n); +int BL602_MemCmp(void *s1,void *s2,uint32_t n); +void EF_Ctrl_Sw_AHB_Clk_0(void); +void EF_Ctrl_Program_Efuse_0(void); +void EF_Ctrl_Load_Efuse_R0(void); +BL_Sts_Type EF_Ctrl_Busy(void); +BL_Sts_Type EF_Ctrl_AutoLoad_Done(void); +void EF_Ctrl_Clear(uint32_t index,uint32_t len); +BL_Err_Type GLB_SW_System_Reset(void); +BL_Err_Type GLB_SW_CPU_Reset(void); +BL_Err_Type GLB_SW_POR_Reset(void); +BL_Err_Type GLB_Select_Internal_Flash(void); +BL_Err_Type GLB_Select_External_Flash(void); +BL_Err_Type GLB_Deswap_Flash_Pin(void); +BL_Err_Type GLB_Swap_Flash_Pin(void); +BL_Err_Type GLB_GPIO_Init(GLB_GPIO_Cfg_Type *cfg); +BL_Err_Type GLB_GPIO_OUTPUT_Enable(GLB_GPIO_Type gpioPin); +BL_Err_Type GLB_GPIO_OUTPUT_Disable(GLB_GPIO_Type gpioPin); +BL_Err_Type GLB_GPIO_Set_HZ(GLB_GPIO_Type gpioPin); +uint8_t GLB_GPIO_Get_Fun(GLB_GPIO_Type gpioPin); +void HBN_Mode_Enter(HBN_APP_CFG_Type *cfg); +void HBN_Power_Down_Flash(SPI_Flash_Cfg_Type *flashCfg); +void HBN_Enable(uint8_t aGPIOIeCfg,HBN_LDO_LEVEL_Type ldoLevel,HBN_LEVEL_Type hbnLevel); +BL_Err_Type HBN_Reset(void); +BL_Err_Type HBN_Set_Ldo11_Aon_Vout(HBN_LDO_LEVEL_Type ldoLevel); +BL_Err_Type HBN_Set_Ldo11_Rt_Vout(HBN_LDO_LEVEL_Type ldoLevel); +BL_Err_Type HBN_Set_Ldo11_Soc_Vout(HBN_LDO_LEVEL_Type ldoLevel); +BL_Err_Type HBN_Hw_Pu_Pd_Cfg(uint8_t enable); +BL_Err_Type HBN_Pin_WakeUp_Mask(uint8_t maskVal); +BL_Err_Type HBN_GPIO7_Dbg_Pull_Cfg(BL_Fun_Type pupdEn,BL_Fun_Type iesmtEn,BL_Fun_Type dlyEn,uint8_t dlySec); +BL_Err_Type HBN_Set_Embedded_Flash_Pullup(uint8_t enable); +BL_Err_Type L1C_Set_Wrap(BL_Fun_Type wrap); +BL_Err_Type L1C_Set_Way_Disable(uint8_t disableVal); +BL_Err_Type L1C_IROM_2T_Access_Set(uint8_t enable); +BL_Err_Type PDS_Reset(void); +BL_Err_Type PDS_Force_Config(PDS_CTL2_Type *cfg2,PDS_CTL3_Type *cfg3); +BL_Err_Type PDS_RAM_Config(PDS_RAM_CFG_Type *ramCfg); +BL_Err_Type PDS_Default_Level_Config(PDS_DEFAULT_LV_CFG_Type *defaultLvCfg,PDS_RAM_CFG_Type *ramCfg,uint32_t pdsSleepCnt); +void SEC_Eng_Turn_On_Sec_Ring(void); +void SEC_Eng_Turn_Off_Sec_Ring(void); +void SFlash_Init(SF_Ctrl_Cfg_Type *pSfCtrlCfg); +BL_Err_Type SFlash_SetSPIMode(SF_Ctrl_Mode_Type mode); +BL_Err_Type SFlash_Read_Reg(SPI_Flash_Cfg_Type *flashCfg,uint8_t regIndex,uint8_t *regValue,uint8_t regLen); +BL_Err_Type SFlash_Write_Reg(SPI_Flash_Cfg_Type *flashCfg,uint8_t regIndex,uint8_t *regValue,uint8_t regLen); +BL_Sts_Type SFlash_Busy(SPI_Flash_Cfg_Type *flashCfg); +BL_Err_Type SFlash_Write_Enable(SPI_Flash_Cfg_Type *flashCfg); +BL_Err_Type SFlash_Qspi_Enable(SPI_Flash_Cfg_Type *flashCfg); +void SFlash_Volatile_Reg_Write_Enable(SPI_Flash_Cfg_Type *flashCfg); +BL_Err_Type SFlash_Chip_Erase(SPI_Flash_Cfg_Type *flashCfg); +BL_Err_Type SFlash_Sector_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t secNum); +BL_Err_Type SFlash_Blk32_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t blkNum); +BL_Err_Type SFlash_Blk64_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t blkNum); +BL_Err_Type SFlash_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t startaddr,uint32_t endaddr); +BL_Err_Type SFlash_Program(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint32_t addr,uint8_t *data,uint32_t len); +void SFlash_GetUniqueId(uint8_t *data,uint8_t idLen); +void SFlash_GetJedecId(SPI_Flash_Cfg_Type *flashCfg,uint8_t *data); +void SFlash_GetDeviceId(uint8_t *data); +void SFlash_Powerdown(void); +void SFlash_Releae_Powerdown(SPI_Flash_Cfg_Type *flashCfg); +void SFlash_SetBurstWrap(SPI_Flash_Cfg_Type *flashCfg); +void SFlash_DisableBurstWrap(SPI_Flash_Cfg_Type *flashCfg); +BL_Err_Type SFlash_Software_Reset(SPI_Flash_Cfg_Type *flashCfg); +void SFlash_Reset_Continue_Read(SPI_Flash_Cfg_Type *flashCfg); +BL_Err_Type SFlash_Set_IDbus_Cfg(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead,uint32_t addr,uint32_t len); +BL_Err_Type SFlash_IDbus_Read_Enable(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead); +BL_Err_Type SFlash_Cache_Enable_Set(uint8_t wayDisable); +BL_Err_Type SFlash_Cache_Flush(void); +BL_Err_Type SFlash_Cache_Read_Enable(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead,uint8_t wayDisable); +void SFlash_Cache_Hit_Count_Get(uint32_t *hitCountLow,uint32_t *hitCountHigh); +uint32_t SFlash_Cache_Miss_Count_Get(void); +void SFlash_Cache_Read_Disable(void); +BL_Err_Type SFlash_Read(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead,uint32_t addr,uint8_t *data,uint32_t len); +BL_Err_Type SFlash_Read_Reg_With_Cmd(SPI_Flash_Cfg_Type *flashCfg,uint8_t readRegCmd,uint8_t *regValue,uint8_t regLen); +BL_Err_Type SFlash_Write_Reg_With_Cmd(SPI_Flash_Cfg_Type *flashCfg,uint8_t writeRegCmd,uint8_t *regValue,uint8_t regLen); +void SF_Cfg_Init_Ext_Flash_Gpio(uint8_t extFlashPin); +void SF_Cfg_Init_Internal_Flash_Gpio(void); +void SF_Cfg_Deinit_Ext_Flash_Gpio(uint8_t extFlashPin); +void SF_Cfg_Restore_GPIO17_Fun(uint8_t fun); +BL_Err_Type SF_Cfg_Get_Flash_Cfg_Need_Lock(uint32_t flashID,SPI_Flash_Cfg_Type *pFlashCfg); +void SF_Cfg_Init_Flash_Gpio(uint8_t flashPinCfg,uint8_t restoreDefault); +uint32_t SF_Cfg_Flash_Identify(uint8_t callFromFlash,uint32_t autoScan,uint32_t flashPinCfg,uint8_t restoreDefault,SPI_Flash_Cfg_Type *pFlashCfg); +void SF_Ctrl_Enable(SF_Ctrl_Cfg_Type *cfg); +void SF_Ctrl_Select_Pad(SF_Ctrl_Pad_Sel sel); +void SF_Ctrl_Set_Owner(SF_Ctrl_Owner_Type owner); +void SF_Ctrl_Disable(void); +void SF_Ctrl_AES_Enable_BE(void); +void SF_Ctrl_AES_Enable_LE(void); +void SF_Ctrl_AES_Set_Region(uint8_t region,uint8_t enable,uint8_t hwKey,uint32_t startAddr,uint32_t endAddr,uint8_t locked); +void SF_Ctrl_AES_Set_Key(uint8_t region,uint8_t *key,SF_Ctrl_AES_Key_Type keyType); +void SF_Ctrl_AES_Set_Key_BE(uint8_t region,uint8_t *key,SF_Ctrl_AES_Key_Type keyType); +void SF_Ctrl_AES_Set_IV(uint8_t region,uint8_t *iv,uint32_t addrOffset); +void SF_Ctrl_AES_Set_IV_BE(uint8_t region,uint8_t *iv,uint32_t addrOffset); +void SF_Ctrl_AES_Enable(void); +void SF_Ctrl_AES_Disable(void); +void SF_Ctrl_Set_Flash_Image_Offset(uint32_t addrOffset); +uint32_t SF_Ctrl_Get_Flash_Image_Offset(void); +void SF_Ctrl_Select_Clock(SF_Ctrl_Sahb_Type sahbType); +void SF_Ctrl_SendCmd(SF_Ctrl_Cmd_Cfg_Type *cfg); +void SF_Ctrl_Icache_Set(SF_Ctrl_Cmd_Cfg_Type *cfg,uint8_t cmdValid); +void SF_Ctrl_Icache2_Set(SF_Ctrl_Cmd_Cfg_Type *cfg,uint8_t cmdValid); +BL_Sts_Type SF_Ctrl_GetBusyState(void); +uint8_t SF_Ctrl_Is_AES_Enable(void); +uint8_t SF_Ctrl_Get_Clock_Delay(void); +void SF_Ctrl_Set_Clock_Delay(uint8_t delay); +BL_Err_Type XIP_SFlash_State_Save(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t *offset); +BL_Err_Type XIP_SFlash_State_Restore(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t offset); +BL_Err_Type XIP_SFlash_Erase_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t startaddr,uint32_t endaddr); +BL_Err_Type XIP_SFlash_Write_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *data,uint32_t len); +BL_Err_Type XIP_SFlash_Read_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *data,uint32_t len); +BL_Err_Type XIP_SFlash_GetJedecId_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint8_t *data); +BL_Err_Type XIP_SFlash_GetDeviceId_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint8_t *data); +BL_Err_Type XIP_SFlash_GetUniqueId_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint8_t *data,uint8_t idLen); +BL_Err_Type XIP_SFlash_Read_Via_Cache_Need_Lock(uint32_t addr,uint8_t *data,uint32_t len); +int XIP_SFlash_Read_With_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *dst,int len); +int XIP_SFlash_Write_With_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *src,int len); +int XIP_SFlash_Erase_With_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,int len); +void XIP_SFlash_Opt_Enter(uint8_t *aesEnable); +void XIP_SFlash_Opt_Exit(uint8_t aesEnable); +uint32_t BFLB_Soft_CRC32(void *dataIn,uint32_t len); +BL_Err_Type ADC_Trim_TSEN(uint16_t *tsen_offset); +BL_Err_Type ADC_Gain_Trim(void); +uint8_t EF_Ctrl_Get_Trim_Parity(uint32_t val,uint8_t len); +void EF_Ctrl_Read_RC32M_Trim(Efuse_Ana_RC32M_Trim_Type *trim); +void EF_Ctrl_Read_RC32K_Trim(Efuse_Ana_RC32K_Trim_Type *trim); +void EF_Ctrl_Read_TSEN_Trim(Efuse_TSEN_Refcode_Corner_Type *trim); +void EF_Ctrl_Read_ADC_Gain_Trim(Efuse_ADC_Gain_Coeff_Type *trim); +BL_Err_Type AON_Power_On_MBG(void); +BL_Err_Type AON_Power_Off_MBG(void); +BL_Err_Type AON_Power_On_XTAL(void); +BL_Err_Type AON_Set_Xtal_CapCode(uint8_t capIn,uint8_t capOut); +uint8_t AON_Get_Xtal_CapCode(void); +BL_Err_Type AON_Power_Off_XTAL(void); +uint8_t EF_Ctrl_Get_Trim_Parity(uint32_t val,uint8_t len); +void EF_Ctrl_Read_RC32M_Trim(Efuse_Ana_RC32M_Trim_Type *trim); +void EF_Ctrl_Read_RC32K_Trim(Efuse_Ana_RC32K_Trim_Type *trim); +GLB_ROOT_CLK_Type GLB_Get_Root_CLK_Sel(void); +BL_Err_Type GLB_Set_System_CLK_Div(uint8_t hclkDiv,uint8_t bclkDiv); +uint8_t GLB_Get_BCLK_Div(void); +uint8_t GLB_Get_HCLK_Div(void); +BL_Err_Type Update_SystemCoreClockWith_XTAL(GLB_PLL_XTAL_Type xtalType); +BL_Err_Type GLB_Set_System_CLK(GLB_PLL_XTAL_Type xtalType,GLB_SYS_CLK_Type clkFreq); +BL_Err_Type System_Core_Clock_Update_From_RC32M(void); +BL_Err_Type GLB_Set_SF_CLK(uint8_t enable,GLB_SFLASH_CLK_Type clkSel,uint8_t div); +BL_Err_Type GLB_Set_PKA_CLK_Sel(GLB_PKA_CLK_Type clkSel); +BL_Err_Type HBN_32K_Sel(HBN_32K_CLK_Type clkType); +BL_Err_Type HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_Type rootClk); +BL_Err_Type HBN_Power_On_Xtal_32K(void); +BL_Err_Type HBN_Power_Off_Xtal_32K(void); +BL_Err_Type HBN_Power_On_RC32K(void); +BL_Err_Type HBN_Power_Off_RC32K(void); +BL_Err_Type HBN_Trim_RC32K(void); +BL_Err_Type PDS_Trim_RC32M(void); +BL_Err_Type PDS_Select_RC32M_As_PLL_Ref(void); +BL_Err_Type PDS_Select_XTAL_As_PLL_Ref(void); +BL_Err_Type PDS_Power_On_PLL(PDS_PLL_XTAL_Type xtalType); +BL_Err_Type PDS_Enable_PLL_All_Clks(void); +BL_Err_Type PDS_Disable_PLL_All_Clks(void); +BL_Err_Type PDS_Enable_PLL_Clk(PDS_PLL_CLK_Type pllClk); +BL_Err_Type PDS_Disable_PLL_Clk(PDS_PLL_CLK_Type pllClk); +BL_Err_Type PDS_Power_Off_PLL(void); + diff --git a/blobs/sdk_app_ble_sync.ghidra.c b/blobs/sdk_app_ble_sync.ghidra.c new file mode 100755 index 0000000..fe3a554 --- /dev/null +++ b/blobs/sdk_app_ble_sync.ghidra.c @@ -0,0 +1,100977 @@ +#include "sdk_app_ble_sync.ghidra.h" + + + +// WARNING: Removing unreachable block (ram,0x230000d8) + +void bl602_start(void) + +{ + uint32_t *puVar1; + undefined4 *puVar2; + uint8_t *puVar3; + ipc_shared_env_tag_conflict7 *piVar4; + anon_struct_conflict1 *paVar5; + anon_struct_conflict2 *paVar6; + code *pcVar7; + + puVar2 = (undefined4 *)&__boot2_pt_addr_src; + paVar5 = &boot2_partition_table; + do { + *(undefined4 *)paVar5 = *puVar2; + puVar2 = puVar2 + 1; + paVar5 = (anon_struct_conflict1 *)&paVar5->table; + } while (paVar5 < &boot2_flashCfg); + puVar1 = (uint32_t *)hal_boot2_get_flash_addr(); + paVar6 = &boot2_flashCfg; + do { + paVar6->magic = *puVar1; + puVar1 = puVar1 + 1; + paVar6 = (anon_struct_conflict2 *)&paVar6->flashCfg; + } while (paVar6 < (anon_struct_conflict2 *)&__boot2_flashCfg_end); + puVar2 = (undefined4 *)&_bl_static_blogfile_code_end; + pcVar7 = AON_Power_On_BG; + do { + *(undefined4 *)pcVar7 = *puVar2; + puVar2 = puVar2 + 1; + pcVar7 = (code *)&((anon_struct_conflict1 *)pcVar7)->table; + } while (pcVar7 < &boot2_partition_table); + puVar3 = &stack_wifi_init; + do { + *(undefined4 *)puVar3 = 0; + puVar3 = (uint8_t *)((undefined4 *)puVar3 + 1); + } while (puVar3 < &__bss_end); + piVar4 = &ipc_shared_env; + do { + (piVar4->msg_a2e_buf).dummy_word = 0; + piVar4 = (ipc_shared_env_tag_conflict7 *)(piVar4->msg_a2e_buf).msg; + } while (piVar4 < (ipc_shared_env_tag_conflict7 *)&_heap_wifi_start); + DAT_4203fff8 = 0x230000e8; + bfl_main(0,0); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void _dump_partition(void) + +{ + int iVar1; + anon_struct_conflict1 *paVar2; + + bl_printk("======= PtTable_Config @%p=======\r\n",0x4200ddd8); + bl_printk("magicCode 0x%08X;",boot2_partition_table.table.ptTable.magicCode); + bl_printk(" version 0x%04X;",(uint)boot2_partition_table.table.ptTable.version); + bl_printk(" entryCnt %u;",(uint)boot2_partition_table.table.ptTable.entryCnt); + bl_printk(" age %lu;",boot2_partition_table.table.ptTable.age); + bl_printk(" crc32 0x%08X\r\n"); + bl_printk( + "idx type device activeIndex name Address[0] Address[1] Length[0] Length[1] age\r\n" + ); + iVar1 = 0; + paVar2 = &boot2_partition_table; + while( true ) { + if ((int)(uint)boot2_partition_table.table.ptTable.entryCnt <= iVar1) break; + bl_printk("[%02d] ",iVar1); + iVar1 = iVar1 + 1; + bl_printk(" %02u",(uint)(paVar2->table).ptEntries[0].type); + bl_printk(" %u",(uint)(paVar2->table).ptEntries[0].device); + bl_printk(" %u",(uint)(paVar2->table).ptEntries[0].activeIndex); + bl_printk(" %8s",(paVar2->table).ptEntries[0].name); + bl_printk(" %p",(paVar2->table).ptEntries[0].Address[0]); + bl_printk(" %p",(paVar2->table).ptEntries[0].Address[1]); + bl_printk(" %p",(paVar2->table).ptEntries[0].maxLen[0]); + bl_printk(" %p",(paVar2->table).ptEntries[0].maxLen[1]); + bl_printk(" %lu\r\n"); + paVar2 = (anon_struct_conflict1 *)((paVar2->table).ptEntries[0].Address + 1); + } + return; +} + + + +uint32_t hal_boot2_get_flash_addr(void) + +{ + return (uint32_t) + (&__boot2_flashCfg_src + (uint)boot2_partition_table.table.ptTable.entryCnt * 0x24); +} + + + +int hal_boot2_partition_bus_addr + (char *name,uint32_t *addr0,uint32_t *addr1,uint32_t *size0,uint32_t *size1, + int *active) + +{ + byte bVar1; + uint uVar2; + uint uVar3; + int iVar4; + anon_struct_conflict1 *paVar5; + uint uVar6; + uint uVar7; + anon_struct_conflict1 *paVar8; + + if (boot2_partition_table.table.ptTable.magicCode != 0x54504642) { + return -5; + } + paVar8 = &boot2_partition_table; + paVar5 = &boot2_partition_table; + uVar2 = 0; + while ((int)uVar2 < (int)(uint)boot2_partition_table.table.ptTable.entryCnt) { + iVar4 = strcmp((char *)(paVar5->table).ptEntries[0].name,name); + paVar5 = (anon_struct_conflict1 *)((paVar5->table).ptEntries[0].Address + 1); + if (iVar4 == 0) break; + uVar2 = uVar2 + 1; + } + iVar4 = -2; + if (uVar2 != (uint)boot2_partition_table.table.ptTable.entryCnt) { + uVar7 = boot2_partition_table.table.ptEntries[uVar2].Address[0]; + uVar6 = boot2_partition_table.table.ptEntries[uVar2].Address[1]; + *active = (uint)boot2_partition_table.table.ptEntries[uVar2].activeIndex; + *size0 = boot2_partition_table.table.ptEntries[uVar2].maxLen[0]; + uVar3 = 0; + *size1 = *(uint32_t *)((int)&boot2_partition_table.table.ptTable + (uVar2 + 1) * 0x24 + 4); + while ((int)uVar3 < (int)(uint)boot2_partition_table.table.ptTable.entryCnt) { + iVar4 = strcmp((char *)(paVar8->table).ptEntries[0].name,"FW"); + paVar8 = (anon_struct_conflict1 *)((paVar8->table).ptEntries[0].Address + 1); + if (iVar4 == 0) break; + uVar3 = uVar3 + 1; + } + iVar4 = -0x48; + if (uVar3 != (uint)boot2_partition_table.table.ptTable.entryCnt) { + if (uVar7 != 0) { + if (uVar7 < boot2_partition_table.table.ptEntries[uVar3].Address[0]) { + return -0x16; + } + if (uVar7 < boot2_partition_table.table.ptEntries[uVar3].Address[1]) { + return -0x16; + } + } + if (uVar6 != 0) { + if (uVar6 < boot2_partition_table.table.ptEntries[uVar3].Address[0]) { + return -0x16; + } + if (uVar6 < boot2_partition_table.table.ptEntries[uVar3].Address[1]) { + return -0x16; + } + } + iVar4 = -0xe; + bVar1 = boot2_partition_table.table.ptEntries[uVar3].activeIndex; + if (bVar1 < 2) { + iVar4 = 0; + *addr0 = (uVar7 + 0x22fff000) - + (&boot2_partition_table.table.ptTable.crc32)[(uint)bVar1 + uVar3 * 9 + 4]; + *addr1 = (uVar6 + 0x22fff000) - + (&boot2_partition_table.table.ptTable.crc32) + [uVar3 * 9 + (uint)boot2_partition_table.table.ptEntries[uVar3].activeIndex + 4]; + } + } + } + return iVar4; +} + + + +int hal_boot2_partition_bus_addr_active(char *name,uint32_t *addr,uint32_t *size) + +{ + int iVar1; + uint32_t uStack36; + uint32_t addr0; + uint32_t addr1; + uint32_t size0; + uint32_t size1; + int active; + + iVar1 = hal_boot2_partition_bus_addr(name,&uStack36,&addr0,&addr1,&size0,(int *)&size1); + if (iVar1 == 0) { + if (size1 != 0) { + uStack36 = addr0; + } + *addr = uStack36; + if (size1 != 0) { + addr1 = size0; + } + *size = addr1; + } + return iVar1; +} + + + +int hal_boot2_partition_bus_addr_inactive(char *name,uint32_t *addr,uint32_t *size) + +{ + int iVar1; + uint32_t uStack36; + uint32_t addr0; + uint32_t addr1; + uint32_t size0; + uint32_t size1; + int active; + + iVar1 = hal_boot2_partition_bus_addr(name,&uStack36,&addr0,&addr1,&size0,(int *)&size1); + if (iVar1 == 0) { + if (size1 != 0) { + addr0 = uStack36; + } + *addr = addr0; + if (size1 != 0) { + size0 = addr1; + } + *size = size0; + } + return iVar1; +} + + + +int hal_boot2_partition_addr + (char *name,uint32_t *addr0,uint32_t *addr1,uint32_t *size0,uint32_t *size1, + int *active) + +{ + uint uVar1; + anon_struct_conflict1 *paVar2; + int iVar3; + + if (boot2_partition_table.table.ptTable.magicCode == 0x54504642) { + paVar2 = &boot2_partition_table; + uVar1 = 0; + while ((int)uVar1 < (int)(uint)boot2_partition_table.table.ptTable.entryCnt) { + iVar3 = strcmp((char *)(paVar2->table).ptEntries[0].name,name); + paVar2 = (anon_struct_conflict1 *)((paVar2->table).ptEntries[0].Address + 1); + if (iVar3 == 0) break; + uVar1 = uVar1 + 1; + } + iVar3 = -2; + if (uVar1 != (uint)boot2_partition_table.table.ptTable.entryCnt) { + *addr0 = boot2_partition_table.table.ptEntries[uVar1].Address[0]; + *addr1 = boot2_partition_table.table.ptEntries[uVar1].Address[1]; + *size0 = boot2_partition_table.table.ptEntries[uVar1].maxLen[0]; + *size1 = *(uint32_t *)((int)&boot2_partition_table.table.ptTable + (uVar1 + 1) * 0x24 + 4); + iVar3 = 0; + *active = (uint)boot2_partition_table.table.ptEntries[uVar1].activeIndex; + } + } + else { + iVar3 = -5; + } + return iVar3; +} + + + +int hal_boot2_partition_addr_active(char *name,uint32_t *addr,uint32_t *size) + +{ + int iVar1; + uint32_t uStack36; + uint32_t addr0; + uint32_t addr1; + uint32_t size0; + uint32_t size1; + int active; + + iVar1 = hal_boot2_partition_addr(name,&uStack36,&addr0,&addr1,&size0,(int *)&size1); + if (iVar1 == 0) { + if (size1 != 0) { + uStack36 = addr0; + } + *addr = uStack36; + if (size1 != 0) { + addr1 = size0; + } + *size = addr1; + } + return iVar1; +} + + + +int hal_boot2_partition_addr_inactive(char *name,uint32_t *addr,uint32_t *size) + +{ + int iVar1; + uint32_t uStack36; + uint32_t addr0; + uint32_t addr1; + uint32_t size0; + uint32_t size1; + int active; + + iVar1 = hal_boot2_partition_addr(name,&uStack36,&addr0,&addr1,&size0,(int *)&size1); + if (iVar1 == 0) { + if (size1 != 0) { + addr0 = uStack36; + } + *addr = addr0; + if (size1 != 0) { + size0 = addr1; + } + *size = size0; + } + return iVar1; +} + + + +int hal_boot2_init(void) + +{ + TickType_t TVar1; + + boot2_partition_table.partition_active_idx = __boot2_pt_addr_src; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvhal_boot2 < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [HAL] [BOOT2] Active Partition[%u] consumed %d Bytes\r\n",TVar1, + &DAT_2306e4ac,"hal_boot2.c",0x114,(uint)boot2_partition_table.partition_active_idx, + 0x254); + } + _dump_partition(); + bl_flash_config_update(); + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int bl_flash_erase(uint32_t addr,int len) + +{ + if (boot2_flashCfg.flashCfg.mid != '\0') { + (*_DAT_21010ab0)(0x4200e030,addr,len,_DAT_21010ab0); + return 0; + } + return -1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int bl_flash_write(uint32_t addr,uint8_t *src,int len) + +{ + if (boot2_flashCfg.flashCfg.mid != '\0') { + (*_DAT_21010aac)(0x4200e030,addr,src,len,_DAT_21010aac); + return 0; + } + return -1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int bl_flash_read(uint32_t addr,uint8_t *dst,int len) + +{ + if (boot2_flashCfg.flashCfg.mid != '\0') { + (*_DAT_21010aa8)(0x4200e030,addr,dst,len,_DAT_21010aa8); + return 0; + } + return -1; +} + + + +undefined4 bl_flash_config_update(void) + +{ + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ======= FlashCfg magiccode @%p, code 0x%08lX =======\r\n", + &DAT_2306e4ac,"bl_flash.c",0x60,&__boot2_flashCfg_src,boot2_flashCfg.magic); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN) + ) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] mid \t\t0x%X\r\n",&DAT_2306e4ac,"bl_flash.c",0x61, + (uint)boot2_flashCfg.flashCfg.mid); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] clkDelay \t0x%X\r\n",&DAT_2306e4ac,"bl_flash.c",0x62, + (uint)boot2_flashCfg.flashCfg.clkDelay); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] clkInvert \t0x%X\r\n",&DAT_2306e4ac,"bl_flash.c",99, + (uint)boot2_flashCfg.flashCfg.clkInvert); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] sector size\t%uKBytes\r\n",&DAT_2306e4ac,"bl_flash.c",100, + (uint)boot2_flashCfg.flashCfg.sectorSize); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] page size\t%uBytes\r\n",&DAT_2306e4ac,"bl_flash.c",0x65, + (uint)boot2_flashCfg.flashCfg.pageSize); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvbl_flash < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] ---------------------------------------------------------------\r\n" + ,&DAT_2306e4ac,"bl_flash.c",0x66); + } + } + } + } + } + } + } + return 0; +} + + + +void cmd_blsync_ble_stop(char *buf,int len,int argc,char **argv) + +{ + aos_post_event(5,2,0); + return; +} + + + +void stack_wifi(void) + +{ + uint8_t stack_wifi_init; + + if (stack_wifi_init == '\x01') { + puts("Wi-Fi Stack Started already!!!\r\n"); + return; + } + stack_wifi_init = '\x01'; + hal_wifi_start_firmware_task(); + aos_post_event(2,1,0); + return; +} + + + +void cmd_blsync_ble_start(char *buf,int len,int argc,char **argv) + +{ + stack_wifi(); + vTaskDelay(1000); + blsync_ble_start(); + vTaskDelay(1000); + aos_post_event(5,1,0); + return; +} + + + +void app_delayed_action_ble(void *arg) + +{ + blsync_ble_start(); + aos_post_delayed_action(1000,app_delayed_action_wifi,(void *)0x0); + return; +} + + + +void app_delayed_action_wifi(void *arg) + +{ + stack_wifi(); + aos_post_delayed_action(1000,app_delayed_action_bleadv,(void *)0x0); + return; +} + + + +void app_delayed_action_bleadv(void *arg) + +{ + size_t count; + + count = strlen("ble_init\r\n"); + aos_cli_input_direct("ble_init\r\n",count); + count = strlen("ble_start_adv 0 0 0x100 0x100\r\n"); + aos_cli_input_direct("ble_start_adv 0 0 0x100 0x100\r\n",count); + return; +} + + + +void scan_complete_cb(void *p_arg,void *param) + +{ + wifi_mgmr_scan_ap_all((wifi_mgmr_ap_item_t *)0x0,(uint32_t *)p_arg,scan_item_cb); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void scan_item_cb(wifi_mgmr_ap_item_t *env,uint32_t *param1,wifi_mgmr_ap_item_t *item) + +{ + undefined auStack64 [4]; + _wifi_item_t wifi_item; + + wifi_item.bssid[4] = item->rssi; + wifi_item.bssid._2_2_ = *(undefined2 *)&item->channel; + wifi_item.ssid._28_4_ = item->ssid_len; + memcpy(auStack64,item,0x20); + memcpy(&wifi_item.ssid_len,item->bssid,6); + if (param1 != (uint32_t *)0x0) { + (*(code *)param1)(auStack64); + } + return; +} + + + +void wifiprov_wifi_state_get(void *p_arg) + +{ + char *__src; + int iStack296; + int tmp_state; + ip4_addr_t ip; + ip4_addr_t gw; + ip4_addr_t mask; + _wifi_state state; + wifi_mgmr_sta_connect_ind_stat_info_t info; + + memset(&mask,0,0x58); + memset(state.bssid + 3,0,0xae); + wifi_mgmr_state_get(&iStack296); + wifi_mgmr_sta_ip_get((uint32_t *)&tmp_state,(uint32_t *)&ip,(uint32_t *)&gw); + wifi_mgmr_sta_connect_ind_stat_get((wifi_mgmr_sta_connect_ind_stat_info_t *)(state.bssid + 3)); + __src = ip4addr_ntoa((ip4_addr_t *)&tmp_state); + strcpy((char *)&mask,__src); + __src = ip4addr_ntoa(&gw); + strcpy(state.gw + 0xc,__src); + __src = ip4addr_ntoa(&ip); + strcpy(state.ip + 0xc,__src); + memcpy(state.mask + 0xc,&state.state,0x20); + memcpy(state.ssid + 0x1d,info.pmk + 0x3c,6); + state.ssid[28] = '\0'; + printf("IP :%s \r\n",&mask); + printf("GW :%s \r\n",state.ip + 0xc); + printf("MASK:%s \r\n",state.gw + 0xc); + if (p_arg != (void *)0x0) { + (*(code *)p_arg)(&mask); + } + return; +} + + + +__uint8_t char_to_hex(char asccode) + +{ + char cVar1; + byte bVar2; + + bVar2 = asccode - 0x30; + if (9 < bVar2) { + if ((byte)(asccode + 0x9fU) < 6) { + cVar1 = -0x57; + } + else { + if (5 < (byte)(asccode + 0xbfU)) { + return '\0'; + } + cVar1 = -0x37; + } + bVar2 = asccode + cVar1; + } + return (__uint8_t)bVar2; +} + + + +void _connect_wifi(undefined4 param_1) + +{ + int iVar1; + uint8_t *puVar2; + char *__dest; + __uint8_t band; + __uint8_t _Var3; + __uint8_t _Var4; + wifi_interface_t pvVar5; + char *value_buf; + size_t ssid_len; + size_t sVar6; + size_t sVar7; + undefined3 extraout_var; + char *__src; + uint16_t freq; + int iVar8; + uint uVar9; + int iVar10; + char *__dest_00; + longlong lVar11; + byte abStack340 [4]; + uint8_t mac [6]; + char chan [10]; + char bssid [32]; + char ssid [33]; + char pmk [66]; + char password [66]; + char val_buf [66]; + + pvVar5 = wifi_mgmr_sta_enable(); + wifi_interface = pvVar5; + lVar11 = aos_now_ms(); + __dest = ssid + 0x20; + printf( + "[APP] [WIFI] [T] %lld\r\n[APP] Get STA %p from Wi-Fi Mgmr, pmk ptr %p, ssid ptr %p, password %p\r\n" + ,pvVar5,param_1,wifi_interface,__dest,bssid + 0x1c,pmk + 0x40,(int)lVar11); + memset(__dest,0,0x42); + memset(bssid + 0x1c,0,0x21); + memset(pmk + 0x40,0,0x42); + __dest_00 = chan + 8; + memset(__dest_00,0,0x20); + memset(abStack340,0,6); + memset(mac + 4,0,10); + memset(password + 0x40,0,0x42); + ef_get_env_blob("conf_ap_ssid",password + 0x40,0x41,(size_t *)0x0); + if (password[64] == '\0') { + puts("[APP] Empty Config\r\n"); + puts("[APP] Try to set the following ENV with psm_set command, then reboot\r\n"); + puts("[APP] NOTE: conf_ap_pmk MUST be psm_unset when conf is changed\r\n"); + puts("[APP] env: conf_ap_ssid\r\n"); + puts("[APP] env: conf_ap_psk\r\n"); + puts("[APP] env(optinal): conf_ap_pmk\r\n"); + return; + } + strncpy(bssid + 0x1c,password + 0x40,0x20); + memset(password + 0x40,0,0x42); + ef_get_env_blob("conf_ap_psk",password + 0x40,0x41,(size_t *)0x0); + if (password[64] != '\0') { + strncpy(pmk + 0x40,password + 0x40,0x41); + } + memset(password + 0x40,0,0x42); + __src = password + 0x40; + value_buf = (char *)ef_get_env_blob("conf_ap_pmk",__src,0x41,(size_t *)0x0); + if (password[64] != '\0') { + __src = password + 0x40; + value_buf = strncpy(__dest,__src,0x41); + } + if (ssid[32] == '\0') { + lVar11 = aos_now_ms(); + printf("[APP] [WIFI] [T] %lld\r\n",value_buf,__src,(int)lVar11); + puts("[APP] Re-cal pmk\r\n"); + ssid_len = strlen(bssid + 0x1c); + wifi_mgmr_psk_cal(pmk + 0x40,bssid + 0x1c,ssid_len,__dest); + ef_set_env("conf_ap_pmk",__dest); + ef_save_env(); + } + memset(password + 0x40,0,0x42); + ef_get_env_blob("conf_ap_channel",password + 0x40,0x41,(size_t *)0x0); + if (password[64] != '\0') { + strncpy((char *)(mac + 4),password + 0x40,9); + printf("connect wifi channel = %s\r\n",mac + 4); + value_buf = strchr((char *)(mac + 4),0x7c); + if (value_buf + 1 != (char *)0x0) { + iVar10 = 1; + iVar8 = 0; + band = char_to_hex(value_buf[1]); + ssid_len = strlen((char *)(mac + 4)); + sVar7 = strlen(value_buf + 1); + iVar1 = ssid_len - sVar7; + mac[iVar1 + 3] = '\0'; + uVar9 = 0; + puVar2 = mac + iVar1 + 4; + while( true ) { + freq = (uint16_t)uVar9; + if (iVar1 + -1 <= iVar8) break; + iVar8 = iVar8 + 1; + _Var3 = char_to_hex(puVar2[-2]); + uVar9 = uVar9 + CONCAT31(extraout_var,_Var3) * iVar10 & 0xffff; + iVar10 = iVar10 * 10; + puVar2 = puVar2 + -1; + } + goto LAB_23000e8a; + } + } + freq = 0; + band = '\0'; +LAB_23000e8a: + memset(password + 0x40,0,0x42); + value_buf = password + 0x40; + sVar6 = ef_get_env_blob("conf_ap_bssid",value_buf,0x41,(size_t *)0x0); + if (password[64] != '\0') { + strncpy(__dest_00,password + 0x40,0x1f); + printf("connect wifi bssid = %s\r\n",__dest_00); + ssid_len = strlen(__dest_00); + if ((ssid_len & 1) != 0) { + ssid_len = ssid_len - (int)ssid_len % 2; + } + if (ssid_len != 0) { + uVar9 = 0; + while ((int)uVar9 < (int)ssid_len) { + _Var3 = char_to_hex(*__dest_00); + _Var4 = char_to_hex(__dest_00[1]); + abStack340[uVar9 >> 1] = _Var3 * '\x10' + _Var4; + uVar9 = uVar9 + 2; + __dest_00 = __dest_00 + 2; + } + } + value_buf = (char *)(uint)abStack340[0]; + sVar6 = printf("mac = %02X:%02X:%02X:%02X:%02X:%02X\r\n",(uint)abStack340[1],(uint)abStack340[2] + ,(uint)abStack340[3],(uint)mac[0],(uint)mac[1]); + } + aos_now_ms(); + ssid_len = strlen(bssid + 0x1c); + sVar7 = strlen(pmk + 0x40); + printf( + "[APP] [WIFI] [T] %lld\r\n[APP] SSID %s\r\n[APP] SSID len %d\r\n[APP] password %s\r\n[APP] password len %d\r\n[APP] pmk %s\r\n[APP] bssid %s\r\n[APP] channel band %d\r\n[APP] channel freq %d\r\n" + ,sVar6,value_buf,bssid + 0x1c,ssid_len,pmk + 0x40,sVar7); + wifi_mgmr_sta_connect + ((wifi_interface_t *)wifi_interface,bssid + 0x1c,pmk + 0x40,__dest,abStack340,band,freq) + ; + return; +} + + + +void event_cb_wifi_event(input_event_t *event,void *private_data) + +{ + ushort uVar1; + size_t sVar2; + wifi_interface_t *wifi_interface; + input_event_t *piVar3; + char *ssid; + undefined4 uVar4; + longlong lVar5; + + uVar1 = event->code; + switch((uint)uVar1 - 1 & 0xffff) { + case 0: + lVar5 = aos_now_ms(); + printf("[APP] [EVT] INIT DONE %lld\r\n",event,private_data,(int)lVar5); + wifi_mgmr_start_background(&conf); + return; + case 1: + lVar5 = aos_now_ms(); + printf("[APP] [EVT] MGMR DONE %lld\r\n",event,private_data,(int)lVar5); + _connect_wifi(); + return; + case 2: + lVar5 = aos_now_ms(); + uVar4 = (undefined4)lVar5; + ssid = "[APP] [EVT] Reconnect %lld\r\n"; + break; + case 3: + case 5: + lVar5 = aos_now_ms(); + uVar4 = (undefined4)lVar5; + ssid = "[APP] [EVT] connected %lld\r\n"; + break; + case 4: + piVar3 = event; + aos_now_ms(); + ssid = wifi_mgmr_status_code_str(*(uint16_t *)&event->value); + printf("[APP] [EVT] disconnect %lld, Reason: %s\r\n",piVar3,private_data,ssid); + goto LAB_2300113c; + case 6: + lVar5 = aos_now_ms(); + printf("[APP] [EVT] GOT IP %lld\r\n",event,private_data,(int)lVar5); + sVar2 = xPortGetFreeHeapSize(); + printf("[SYS] Memory left is %d Bytes\r\n",sVar2); + return; + case 7: + lVar5 = aos_now_ms(); + uVar4 = (undefined4)lVar5; + ssid = "[APP] [EVT] Connecting %lld\r\n"; + break; + case 8: + piVar3 = event; + lVar5 = aos_now_ms(); + if (event->value == 0) { + ssid = "OK"; + } + else { + ssid = "Busy now"; + } + printf("[APP] [EVT] SCAN Done %lld, SCAN Result: %s\r\n",piVar3,private_data,ssid,(int)lVar5); + wifi_mgmr_cli_scanlist(); + return; + default: + lVar5 = aos_now_ms(); + printf("[APP] [EVT] Unknown code %u, %lld\r\n",(uint)uVar1,event,private_data,(int)lVar5); + return; + case 0xf: + piVar3 = event; + lVar5 = aos_now_ms(); + printf("[APP] [EVT] [PROV] [CONNECT] %lld\r\n",piVar3,private_data,(int)lVar5); + ssid = (char *)event->value; + wifi_interface = (wifi_interface_t *)wifi_mgmr_sta_enable(); + wifi_mgmr_sta_connect(wifi_interface,ssid,ssid + 0x21,(char *)0x0,(uint8_t *)0x0,'\0',0); + return; + case 0x10: + lVar5 = aos_now_ms(); + printf("[APP] [EVT] [PROV] [DISCONNECT] %lld\r\n",event,private_data,(int)lVar5); + wifi_mgmr_sta_disconnect(); +LAB_2300113c: + vTaskDelay(1000); + wifi_mgmr_sta_disable((wifi_interface_t *)0x0); + return; + case 0x11: + piVar3 = event; + lVar5 = aos_now_ms(); + printf("[APP] [EVT] [PROV] [SCAN] %lld\r\n",piVar3,private_data,(int)lVar5); + wifi_mgmr_scan((void *)event->value,scan_complete_cb); + return; + case 0x12: + piVar3 = event; + lVar5 = aos_now_ms(); + printf("[APP] [EVT] [PROV] [STATE] %lld\r\n",piVar3,private_data,(int)lVar5); + wifiprov_wifi_state_get((void *)event->value); + return; + } + printf(ssid,event,private_data,uVar4); + return; +} + + + +void event_cb_cli(input_event_t *event,void *p_arg) + +{ + size_t count; + + if (event->code == 1) { + count = strlen("ble_init\r\n"); + aos_cli_input_direct("ble_init\r\n",count); + count = strlen("ble_start_adv 0 0 0x100 0x100\r\n"); + aos_cli_input_direct("ble_start_adv 0 0 0x100 0x100\r\n",count); + return; + } + if (event->code != 2) { + return; + } + count = strlen("ble_stop_adv\r\n"); + aos_cli_input_direct("ble_stop_adv\r\n",count); + blsync_ble_stop(); + printf("blsync ble stop\r\n"); + return; +} + + + +void aos_loop_proc(void *pvParameters) + +{ + StackType_t proc_stack_looprt [512]; + StaticTask_t proc_task_looprt; + void *fdt; + int sock; + aos_poll_call_t *cb; + + looprt_start((StackType_t *)&ram0x4200f4ac,0x200,(StaticTask_t *)&ram0x4200fcac); + loopset_led_hook_on_looprt(); + easyflash_init(); + vfs_init(); + vfs_device_init(); + fdt = (void *)hal_board_get_factory_addr(); + sock = fdt_subnode_offset(fdt,0,"uart"); + if (sock == 0) { + printf("%s NULL.\r\n",0x230794f8); + } + else { + vfs_uart_init(fdt,sock); + } + fdt = (void *)hal_board_get_factory_addr(); + sock = fdt_subnode_offset(fdt,0,"gpio"); + if (sock == 0) { + printf("%s NULL.\r\n",0x23079a94); + } + else { + hal_gpio_init_from_dts(fdt,sock); + } + romfs_register(); + aos_loop_init(); + sock = aos_open("/dev/ttyS0",0); + if (-1 < sock) { + printf("Init CLI with event Driven\r\n"); + aos_cli_init(0); + cb = (aos_poll_call_t *)aos_cli_event_cb_read_get(); + aos_poll_read_fd(sock,cb,(void *)0x12345678); + wifi_mgmr_cli_init(); + } + aos_register_event_filter(2,event_cb_wifi_event,(void *)0x0); + aos_register_event_filter(5,event_cb_cli,(void *)0x0); + aos_post_delayed_action(1000,app_delayed_action_ble,(void *)0x0); + aos_loop_run(); + puts("------------------------------------------\r\n"); + puts("+++++++++Critical Exit From Loop++++++++++\r\n"); + puts("******************************************\r\n"); + vTaskDelete((TaskHandle_t)0x0); + return; +} + + + +void vApplicationStackOverflowHook(TaskHandle_t xTask,char *pcTaskName) + +{ + puts("Stack Overflow checked\r\n"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void vApplicationMallocFailedHook(void) + +{ + size_t sVar1; + + sVar1 = xPortGetFreeHeapSize(); + printf("Memory Allocate Failed. Current left size is %d bytes\r\n",sVar1); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void vApplicationIdleHook(void) + +{ + wfi(); + return; +} + + + +void vApplicationGetIdleTaskMemory + (StaticTask_t **ppxIdleTaskTCBBuffer,StackType_t **ppxIdleTaskStackBuffer, + uint32_t *pulIdleTaskStackSize) + +{ + StackType_t uxIdleTaskStack [96]; + StaticTask_t xIdleTaskTCB; + + *ppxIdleTaskTCBBuffer = (StaticTask_t *)&ram0x420104cc; + *ppxIdleTaskStackBuffer = (StackType_t *)&ram0x4200fd0c; + *pulIdleTaskStackSize = 0x60; + return; +} + + + +void vApplicationGetTimerTaskMemory + (StaticTask_t **ppxTimerTaskTCBBuffer,StackType_t **ppxTimerTaskStackBuffer, + uint32_t *pulTimerTaskStackSize) + +{ + StackType_t uxTimerTaskStack [400]; + StaticTask_t xTimerTaskTCB; + + *ppxTimerTaskTCBBuffer = (StaticTask_t *)&ram0x4201052c; + *ppxTimerTaskStackBuffer = (StackType_t *)&ram0x4200fe8c; + *pulTimerTaskStackSize = 400; + return; +} + + + +// WARNING: Removing unreachable block (ram,0x230014ae) + +void vAssertCalled(void) + +{ + uint32_t ulSetTo1ToExitFunction; + + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void bfl_main(void) + +{ + StackType_t aos_loop_proc_stack [1024]; + StaticTask_t aos_loop_proc_task; + int iVar1; + char *pcStack76; + char *banner; + char chip_feature [40]; + + bl_sys_early_init(); + bl_uart_init('\0','\x10','\a',-1,-1,(uint32_t)&DAT_001e8480); + puts("Starting bl602 now....\r\n"); + bl_sys_init(); + puts("Booting BL602 Chip...\r\n"); + iVar1 = bl_chip_banner(&pcStack76); + if (iVar1 == 0) { + puts(pcStack76); + } + puts("\r\n"); + puts("\r\n"); + puts("------------------------------------------------------------\r\n"); + puts("RISC-V Core Feature:"); + bl_chip_info((char *)&banner); + puts((char *)&banner); + puts("\r\n"); + puts("Build Version: "); + puts("release_bl_iot_sdk_1.6.11-1-g66bb28da-dirty"); + puts("\r\n"); + puts("Build Version: "); + puts("release_bl_iot_sdk_1.6.11-1-g66bb28da-dirty"); + puts("\r\n"); + puts("PHY Version: "); + puts("a0_final-44-geb7fadd"); + puts("\r\n"); + puts("RF Version: "); + puts("f76e39a"); + puts("\r\n"); + puts("Build Date: "); + puts("Oct 30 2020"); + puts("\r\n"); + puts("Build Time: "); + puts("01:04:04"); + puts("\r\n"); + puts("------------------------------------------------------------\r\n"); + vPortDefineHeapRegions(xHeapRegions); + printf("Heap %u@%p, %u@%p\r\n",&_heap_size,&__bss_end,0x860,&_heap_wifi_start); + blog_init(); + bl_irq_init(); + bl_sec_init(); + bl_sec_test(); + bl_dma_init(); + hal_boot2_init(); + hal_board_cfg(0); + puts("[OS] Starting aos_loop_proc task...\r\n"); + xTaskCreateStatic(aos_loop_proc,"event_loop",0x400,(void *)0x0,0xf,(StackType_t *)&ram0x4200e44c, + (StaticTask_t *)&ram0x4200f44c); + puts("[OS] Starting TCP/IP Stack...\r\n"); + tcpip_init((tcpip_init_done_fn)0x0,(void *)0x0); + puts("[OS] Starting OS Scheduler...\r\n"); + vTaskStartScheduler(); + return; +} + + + +void blesync_complete_cb(void *p_arg) + +{ + bl_ble_sync_stop((bl_ble_sync_t *)p_arg); + vPortFree(p_arg); + return; +} + + + +void wifiprov_api_state_get(anon_subr_void_void_ptr *state_get) + +{ + printf("Recevied indication to wifi state get\r\n"); + wifi_prov_api_event_state_get(state_get); + return; +} + + + +void wifiprov_wifi_scan(anon_subr_void_void_ptr *complete) + +{ + printf("Recevied indication to wifi scan\r\n"); + wifi_prov_api_event_trigger_scan(complete); + return; +} + + + +void wifiprov_disc_from_ap_ind(void) + +{ + printf("Recevied indication to disconnect to AP\r\n"); + wifi_prov_api_event_trigger_disconnect(); + return; +} + + + +void wifiprov_connect_ap_ind(wifi_conn *info) + +{ + wifi_mgmr_status_code_clean_internal(); + printf("Recevied indication to connect to AP\r\n"); + wifi_prov_api_event_trigger_connect(info); + return; +} + + + +void blsync_init(int err) + +{ + if (err != 0) { + return; + } + if (gp_index != (bl_ble_sync_t *)0x0) { + printf("blsync already started\r\n"); + return; + } + ble_cli_register(); + gp_index = (bl_ble_sync_t *)pvPortMalloc(0x1908); + if (gp_index != (bl_ble_sync_t *)0x0) { + bl_ble_sync_start(gp_index,&WifiProv_conn_callback,blesync_complete_cb,gp_index); + return; + } + return; +} + + + +void blsync_ble_start(void) + +{ + uint8_t stack_started; + + if (stack_started == '\x01') { + blsync_init(0); + return; + } + ble_controller_init('\x1f'); + hci_driver_init(); + bt_enable(blsync_init); + return; +} + + + +void blsync_ble_stop(void) + +{ + bl_ble_sync_stop(gp_index); + vPortFree(gp_index); + gp_index = (bl_ble_sync_t *)0x0; + return; +} + + + +int wifi_prov_api_event_trigger_connect(wifi_conn *info) + +{ + int iVar1; + + iVar1 = aos_post_event(2,0x10,(ulong)info); + if (iVar1 < 0) { + puts("[APP] [PROV] trigger CONNECT event failed\r\n"); + iVar1 = -1; + } + else { + puts("[APP] [PROV] trigger CONNECT event OK\r\n"); + iVar1 = 0; + } + return iVar1; +} + + + +int wifi_prov_api_event_trigger_disconnect(void) + +{ + int iVar1; + + iVar1 = aos_post_event(2,0x11,0); + if (iVar1 < 0) { + puts("[APP] [PROV] trigger DISCONNECT event failed\r\n"); + iVar1 = -1; + } + else { + puts("[APP] [PROV] trigger DISCONNECT event OK\r\n"); + iVar1 = 0; + } + return iVar1; +} + + + +int wifi_prov_api_event_trigger_scan(anon_subr_void_void_ptr *complete) + +{ + int iVar1; + + iVar1 = aos_post_event(2,0x12,(ulong)complete); + if (iVar1 < 0) { + puts("[APP] [PROV] trigger scan event failed\r\n"); + iVar1 = -1; + } + else { + puts("[APP] [PROV] trigger scan event OK\r\n"); + iVar1 = 0; + } + return iVar1; +} + + + +int wifi_prov_api_event_state_get(anon_subr_void_void_ptr *state_get) + +{ + int iVar1; + + iVar1 = aos_post_event(2,0x13,(ulong)state_get); + if (iVar1 < 0) { + puts("[APP] [PROV] trigger scan event failed\r\n"); + iVar1 = -1; + } + else { + puts("[APP] [PROV] trigger scan event OK\r\n"); + iVar1 = 0; + } + return iVar1; +} + + + +void bl_printk(char *format,...) + +{ + undefined4 in_a1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list args; + undefined4 uStack28; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + if (sys_log_all_enable != false) { + uStack28 = in_a1; + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + vprint(format,&uStack28); + } + return; +} + + + +int log_buf_out(char *file,int line,void *inbuf,int len,LOG_BUF_OUT_DATA_TYPE_T type) + +{ + bool bVar1; + int iVar2; + int iVar3; + TickType_t TVar4; + char *format; + uint uVar5; + undefined3 in_register_00002039; + int iVar6; + int iVar7; + int iVar8; + int iVar9; + void *pvVar10; + + iVar6 = CONCAT31(in_register_00002039,type); + if (len < 1) { + return -1; + } + iVar9 = len / 0x32; + if (len % 0x32 == 0) { + pvVar10 = (void *)(iVar9 * 0x32 + (int)inbuf); + while (pvVar10 != inbuf) { + iVar7 = 0; + iVar9 = 0; + do { + uVar5 = (uint)*(byte *)((int)inbuf + iVar9); + if (iVar6 == 1) { + uVar5 = SEXT14((char)*(byte *)((int)inbuf + iVar9)); + format = "%3d "; + } + else { + format = "%3u "; + if (iVar6 != 2) { + format = "%02x "; + } + } + iVar3 = sprintf(log_buf + iVar7,format,uVar5); + iVar9 = iVar9 + 1; + iVar7 = iVar7 + iVar3; + } while (iVar9 != 0x32); + if (TrapNetCounter == 0) { + TVar4 = xTaskGetTickCount(); + } + else { + TVar4 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %.*s\r\n",TVar4,&UNK_2306f124,file,line,iVar7,log_buf); + inbuf = (void *)((int)inbuf + 0x32); + } + } + else { + iVar7 = 0; + do { + iVar3 = 0; + iVar8 = 0; + if (iVar9 == iVar7) { + do { + uVar5 = (uint)*(byte *)((int)inbuf + iVar8); + if (iVar6 == 1) { + uVar5 = SEXT14((char)*(byte *)((int)inbuf + iVar8)); + format = "%3d "; + } + else { + format = "%3u "; + if (iVar6 != 2) { + format = "%02x "; + } + } + iVar2 = sprintf(log_buf + iVar3,format,uVar5); + iVar8 = iVar8 + 1; + iVar3 = iVar3 + iVar2; + } while (len % 0x32 != iVar8); + } + else { + do { + uVar5 = (uint)*(byte *)((int)inbuf + iVar8); + if (iVar6 == 1) { + uVar5 = SEXT14((char)*(byte *)((int)inbuf + iVar8)); + format = "%3d "; + } + else { + format = "%3u "; + if (iVar6 != 2) { + format = "%02x "; + } + } + iVar2 = sprintf(log_buf + iVar3,format,uVar5); + iVar8 = iVar8 + 1; + iVar3 = iVar3 + iVar2; + } while (iVar8 != 0x32); + } + if (TrapNetCounter == 0) { + TVar4 = xTaskGetTickCount(); + } + else { + TVar4 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %.*s\r\n",TVar4,&UNK_2306f124,file,line,iVar3,log_buf); + inbuf = (void *)((int)inbuf + 0x32); + bVar1 = iVar7 < iVar9; + iVar7 = iVar7 + 1; + } while (bVar1); + } + return 0; +} + + + +int vfs_init(void) + +{ + int iVar1; + + iVar1 = 0; + if (g_vfs_init != '\x01') { + g_vfs_mutex = (SemaphoreHandle_t)xQueueCreateMutexStatic('\x01',(StaticQueue_t *)&xMutexBuffer); + iVar1 = -1; + if (g_vfs_mutex != (SemaphoreHandle_t)0x0) { + inode_init(); + iVar1 = 0; + g_vfs_init = '\x01'; + } + } + return iVar1; +} + + + +int aos_open(char *path,int flags) + +{ + size_t sVar1; + BaseType_t BVar2; + inode_t *node; + file_t *file; + int iVar3; + code *pcVar4; + + if (path == (char *)0x0) { + iVar3 = -0x16; + } + else { + sVar1 = strlen(path); + if (0x400 < sVar1) { + return -0x1a; + } + BVar2 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar2 != 1) { + return -1; + } + node = inode_open(path); + if (node == (inode_t *)0x0) { + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + return -2; + } + node->i_flags = flags; + file = new_file(node); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + if (file == (file_t *)0x0) { + return -0x17; + } + pcVar4 = *(code **)node->ops; + if (node->type == '\x03') { + if (pcVar4 == (code *)0x0) goto LAB_23001bd8; + iVar3 = (*pcVar4)(file,path,flags); + } + else { + if (pcVar4 == (code *)0x0) goto LAB_23001bd8; + iVar3 = (*pcVar4)(node,file); + } + if (iVar3 == 0) { +LAB_23001bd8: + iVar3 = get_fd(file); + return iVar3; + } + del_file(file); + } + return iVar3; +} + + + +int aos_close(int fd) + +{ + int iVar1; + file_t *file; + BaseType_t BVar2; + code *pcVar3; + + file = get_file(fd); + iVar1 = -2; + if (file != (file_t *)0x0) { + iVar1 = 0; + pcVar3 = *(code **)(file->node->ops + 4); + if (pcVar3 != (code *)0x0) { + iVar1 = (*pcVar3)(); + } + BVar2 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar2 == 1) { + del_file(file); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + } + else { + iVar1 = -1; + } + } + return iVar1; +} + + + +ssize_t aos_read(int fd,void *buf,size_t nbytes) + +{ + code *UNRECOVERED_JUMPTABLE; + file_t *pfVar1; + ssize_t sVar2; + + pfVar1 = get_file(fd); + if (pfVar1 == (file_t *)0x0) { + sVar2 = -2; + } + else { + UNRECOVERED_JUMPTABLE = *(code **)(pfVar1->node->ops + 8); + if (UNRECOVERED_JUMPTABLE != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x23001c72. Too many branches + // WARNING: Treating indirect jump as call + sVar2 = (*UNRECOVERED_JUMPTABLE)(buf,nbytes); + return sVar2; + } + sVar2 = -1; + } + return sVar2; +} + + + +ssize_t aos_write(int fd,void *buf,size_t nbytes) + +{ + code *UNRECOVERED_JUMPTABLE; + file_t *pfVar1; + ssize_t sVar2; + + pfVar1 = get_file(fd); + if (pfVar1 == (file_t *)0x0) { + sVar2 = -2; + } + else { + UNRECOVERED_JUMPTABLE = *(code **)(pfVar1->node->ops + 0xc); + if (UNRECOVERED_JUMPTABLE != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x23001ca0. Too many branches + // WARNING: Treating indirect jump as call + sVar2 = (*UNRECOVERED_JUMPTABLE)(buf,nbytes); + return sVar2; + } + sVar2 = -1; + } + return sVar2; +} + + + +int aos_ioctl(int fd,int cmd,ulong arg) + +{ + code *UNRECOVERED_JUMPTABLE; + file_t *pfVar1; + int iVar2; + + if (fd < 0) { + return -0x16; + } + pfVar1 = get_file(fd); + if (pfVar1 == (file_t *)0x0) { + iVar2 = -2; + } + else { + iVar2 = pfVar1->node->ops; + if (pfVar1->node->type == '\x03') { + UNRECOVERED_JUMPTABLE = *(code **)(iVar2 + 0x44); + } + else { + UNRECOVERED_JUMPTABLE = *(code **)(iVar2 + 0x10); + } + if (UNRECOVERED_JUMPTABLE != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x23001cdc. Too many branches + // WARNING: Treating indirect jump as call + iVar2 = (*UNRECOVERED_JUMPTABLE)(cmd,arg); + return iVar2; + } + iVar2 = -0x47; + } + return iVar2; +} + + + +int aos_stat(char *path,stat *st) + +{ + int iVar1; + BaseType_t BVar2; + inode_t *node; + file_t *file; + code *pcVar3; + + if (path == (char *)0x0) { + return -0x16; + } + BVar2 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar2 == 1) { + node = inode_open(path); + if (node == (inode_t *)0x0) { + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + return -0x13; + } + file = new_file(node); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + if (file == (file_t *)0x0) { + return -2; + } + iVar1 = -0x47; + if ((node->type == '\x03') && (pcVar3 = *(code **)(node->ops + 0x18), pcVar3 != (code *)0x0)) { + iVar1 = (*pcVar3)(file,path,st); + } + BVar2 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar2 == 1) { + del_file(file); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + return iVar1; + } + } + return -1; +} + + + +aos_dir_t * aos_opendir(char *path) + +{ + BaseType_t BVar1; + inode_t *node; + file_t *file; + aos_dir_t *paVar2; + int iVar3; + code *pcVar4; + + if ((path != (char *)0x0) && + (BVar1 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff), BVar1 == 1)) { + node = inode_open(path); + if (node == (inode_t *)0x0) { + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + return (aos_dir_t *)0x0; + } + file = new_file(node); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + if (file != (file_t *)0x0) { + if (((node->type == '\x03') && (pcVar4 = *(code **)(node->ops + 0x24), pcVar4 != (code *)0x0)) + && (paVar2 = (aos_dir_t *)(*pcVar4)(file,path), paVar2 != (aos_dir_t *)0x0)) { + iVar3 = get_fd(file); + paVar2->dd_vfs_fd = iVar3; + return paVar2; + } + BVar1 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar1 == 1) { + del_file(file); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + } + } + } + return (aos_dir_t *)0x0; +} + + + +int aos_closedir(aos_dir_t *dir) + +{ + int iVar1; + file_t *file; + BaseType_t BVar2; + code *pcVar3; + + iVar1 = -0x16; + if (dir != (aos_dir_t *)0x0) { + iVar1 = -2; + file = get_file(dir->dd_vfs_fd); + if (file != (file_t *)0x0) { + iVar1 = -0x47; + if ((file->node->type == '\x03') && + (pcVar3 = *(code **)(file->node->ops + 0x2c), pcVar3 != (code *)0x0)) { + iVar1 = (*pcVar3)(dir); + } + BVar2 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar2 == 1) { + del_file(file); + xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + } + else { + iVar1 = -1; + } + } + } + return iVar1; +} + + + +aos_dirent_t * aos_readdir(aos_dir_t *dir) + +{ + code *UNRECOVERED_JUMPTABLE; + file_t *pfVar1; + aos_dirent_t *paVar2; + + if (dir == (aos_dir_t *)0x0) { + return (aos_dirent_t *)0x0; + } + pfVar1 = get_file(dir->dd_vfs_fd); + if (pfVar1 != (file_t *)0x0) { + if (pfVar1->node->type == '\x03') { + UNRECOVERED_JUMPTABLE = *(code **)(pfVar1->node->ops + 0x28); + if (UNRECOVERED_JUMPTABLE != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x23001efc. Too many branches + // WARNING: Treating indirect jump as call + paVar2 = (aos_dirent_t *)(*UNRECOVERED_JUMPTABLE)(dir); + return paVar2; + } + } + } + return (aos_dirent_t *)0x0; +} + + + +file_t * new_file(inode_t *node) + +{ + file_t *pfVar1; + int iVar2; + + pfVar1 = files; + iVar2 = 0; + do { + if (pfVar1->node == (inode_t *)0x0) { + files[iVar2].node = node; + files[iVar2].f_arg = (void *)0x0; + files[iVar2].offset = 0; + inode_ref(node); + return files + iVar2; + } + iVar2 = iVar2 + 1; + pfVar1 = pfVar1 + 1; + } while (iVar2 != 0x3c); + return (file_t *)0x0; +} + + + +void del_file(file_t *file) + +{ + inode_unref(file->node); + file->node = (inode_t *)0x0; + return; +} + + + +int get_fd(file_t *file) + +{ + return ((int)(file + -0x58015fd) >> 2) * -0x55555555 + 2; +} + + + +file_t * get_file(int fd) + +{ + inode_t *piVar1; + + if (fd - 2U < 0x3c) { + piVar1 = files[fd - 2U].node; + if (piVar1 != (inode_t *)0x0) { + return files + (fd - 2U); + } + } + else { + piVar1 = (inode_t *)0x0; + } + return (file_t *)piVar1; +} + + + +int inode_init(void) + +{ + memset(g_vfs_dev_nodes,0,600); + return 0; +} + + + +int inode_alloc(void) + +{ + int iVar1; + inode_t *piVar2; + + piVar2 = g_vfs_dev_nodes; + iVar1 = 0; + do { + if (piVar2->type == '\0') { + return iVar1; + } + iVar1 = iVar1 + 1; + piVar2 = piVar2 + 1; + } while (iVar1 != 0x1e); + return -0xc; +} + + + +inode_t * inode_open(char *path) + +{ + inode_t *piVar1; + int iVar2; + size_t __n; + char *__s; + + piVar1 = g_vfs_dev_nodes; + do { + __s = piVar1->i_name; + if (__s != (char *)0x0) { + if (piVar1->type == '\x03') { + __n = strlen(__s); + iVar2 = strncmp(__s,path,__n); + if ((iVar2 == 0) && (__n = strlen(piVar1->i_name), path[__n] == '/')) { + return piVar1; + } + } + iVar2 = strcmp(piVar1->i_name,path); + if (iVar2 == 0) { + return piVar1; + } + } + piVar1 = piVar1 + 1; + if (piVar1 == (inode_t *)string) { + return (inode_t *)0x0; + } + } while( true ); +} + + + +int inode_forearch_name(anon_subr_int_void_ptr_inode_t_ptr *cb,void *arg) + +{ + inode_t *piVar1; + int iVar2; + int iVar3; + + piVar1 = g_vfs_dev_nodes; + iVar2 = 0; + do { + if (piVar1->i_name != (char *)0x0) { + iVar2 = iVar2 + 1; + iVar3 = (*cb)(arg,piVar1); + if (iVar3 != 0) { + return iVar2; + } + } + piVar1 = piVar1 + 1; + } while (piVar1 != (inode_t *)string); + return iVar2; +} + + + +void inode_ref(inode_t *node) + +{ + node->refs = node->refs + '\x01'; + return; +} + + + +void inode_unref(inode_t *node) + +{ + if (node->refs != '\0') { + node->refs = node->refs + -1; + } + return; +} + + + +int inode_reserve(char *path,inode_t **inode) + +{ + inode_t *piVar1; + int iVar2; + size_t __n; + char *__dest; + + if (((path != (char *)0x0) && (inode != (inode_t **)0x0)) && + (*inode = (inode_t *)0x0, *path == '/')) { + iVar2 = inode_alloc(); + if (-1 < iVar2) { + piVar1 = (inode_t *)0x0; + if (iVar2 < 0x1e) { + piVar1 = g_vfs_dev_nodes + iVar2; + } + __n = strlen(path); + __dest = (char *)pvPortMalloc(__n + 1); + iVar2 = -0xc; + if (__dest != (char *)0x0) { + memcpy(__dest,path,__n); + piVar1->i_name = __dest; + __dest[__n] = '\0'; + *inode = piVar1; + iVar2 = 0; + } + } + return iVar2; + } + return -0x16; +} + + + +yloop_ctx_t * get_context(void) + +{ + yloop_ctx_t *pyVar1; + + pyVar1 = (yloop_ctx_t *)aos_task_getspecific(g_loop_key); + if (pyVar1 == (yloop_ctx_t *)0x0) { + aos_task_setspecific(g_loop_key,g_main_ctx); + pyVar1 = g_main_ctx; + } + return pyVar1; +} + + + +void aos_loop_set_eventfd(int fd) + +{ + yloop_ctx_t *pyVar1; + + pyVar1 = get_context(); + pyVar1->eventfd = fd; + return; +} + + + +aos_loop_t aos_loop_init(void) + +{ + aos_task_key_t key; + void *pvVar1; + yloop_ctx_t *__s; + + pvVar1 = aos_task_getspecific(g_loop_key); + if (g_main_ctx == (yloop_ctx_t *)0x0) { + aos_task_key_create(&g_loop_key); + } + else { + if (pvVar1 != (void *)0x0) { + printf("yloopyloop already inited"); + return pvVar1; + } + } + __s = (yloop_ctx_t *)pvPortMalloc(0x1c); + if (__s != (yloop_ctx_t *)0x0) { + memset(__s,0,0x1c); + } + if (g_main_ctx == (yloop_ctx_t *)0x0) { + g_main_ctx = __s; + } + *(yloop_ctx_t **)&(__s->timeouts).prev = __s; + key = g_loop_key; + __s->eventfd = -1; + *(yloop_ctx_t **)&(__s->timeouts).next = __s; + aos_task_setspecific(key,__s); + aos_event_service_init(); + return __s; +} + + + +int aos_poll_read_fd(int sock,aos_poll_call_t *cb,void *private_data) + +{ + yloop_sock_t *__dest; + yloop_ctx_t *pyVar1; + pollfd *__dest_00; + uint uVar2; + int iVar3; + uint uVar4; + + pyVar1 = get_context(); + if (sock < 0) { + iVar3 = -0x16; + } + else { + uVar4 = (uint)pyVar1->reader_count; + __dest = (yloop_sock_t *)pvPortMalloc((uVar4 + 1) * 0xc); + __dest_00 = (pollfd *)pvPortMalloc((uVar4 + 1) * 8); + if ((__dest == (yloop_sock_t *)0x0) || (__dest_00 == (pollfd *)0x0)) { + printf("yloopout of memory"); + vPortFree(__dest); + vPortFree(__dest_00); + iVar3 = -0xc; + } + else { + uVar2 = aos_fcntl(sock,3,0); + aos_fcntl(sock,4,uVar2 | 0x4000); + pyVar1->reader_count = pyVar1->reader_count + '\x01'; + memcpy(__dest,pyVar1->readers,uVar4 * 0xc); + vPortFree(pyVar1->readers); + pyVar1->readers = __dest; + memcpy(__dest_00,pyVar1->pollfds,uVar4 << 3); + __dest = __dest + uVar4; + vPortFree(pyVar1->pollfds); + pyVar1->pollfds = __dest_00; + __dest->sock = sock; + __dest->private_data = private_data; + __dest->cb = cb; + iVar3 = 0; + if ((int)(uint)pyVar1->max_sock < sock) { + pyVar1->max_sock = (uint16_t)sock; + iVar3 = 0; + } + } + } + return iVar3; +} + + + +int aos_post_delayed_action(int ms,aos_call_t *action,void *param) + +{ + yloop_ctx_t *pyVar1; + dlist_s *pdVar2; + int iVar3; + pollfd *ppVar4; + aos_call_t *paVar5; + yloop_sock_t *pyVar6; + dlist_s *pdVar7; + yloop_ctx_t *pyVar8; + + if (action != (aos_call_t *)0x0) { + paVar5 = action; + pyVar1 = get_context(); + pdVar2 = (dlist_s *)pvPortMalloc(0x20); + iVar3 = -0xc; + if (pdVar2 != (dlist_s *)0x0) { + aos_now_ms(); + ppVar4 = (pollfd *)(iVar3 + ms); + pyVar6 = (yloop_sock_t *)(paVar5 + (uint)(ppVar4 < (uint)ms) + (ms >> 0x1f)); + *(pollfd **)&pdVar2[1].prev = ppVar4; + *(yloop_sock_t **)&pdVar2[1].next = pyVar6; + pdVar2[2].prev = param; + *(aos_call_t **)&pdVar2[2].next = action; + *(int *)&pdVar2[3].prev = ms; + pyVar8 = (yloop_ctx_t *)(pyVar1->timeouts).next; + while (((pyVar8 != pyVar1 && ((int)pyVar8->readers <= (int)pyVar6)) && + ((pyVar8->readers != pyVar6 || (pyVar8->pollfds <= ppVar4))))) { + pyVar8 = (yloop_ctx_t *)(pyVar8->timeouts).next; + } + pdVar7 = (pyVar8->timeouts).prev; + *(yloop_ctx_t **)&pdVar2->next = pyVar8; + iVar3 = 0; + pdVar2->prev = pdVar7; + pdVar7->next = pdVar2; + (pyVar8->timeouts).prev = pdVar2; + } + return iVar3; + } + return -0x16; +} + + + +void aos_loop_run(yloop_sock_t *param_1) + +{ + yloop_ctx_t *pyVar1; + yloop_sock_t *pyVar2; + yloop_ctx_t *pyVar3; + yloop_ctx_t *pyVar4; + yloop_sock_t *extraout_a1; + yloop_sock_t *extraout_a1_00; + yloop_ctx_t *pv; + dlist_s *pdVar5; + int iVar6; + dlist_s *pdVar7; + yloop_sock_t *pyVar8; + yloop_sock_t *nfds; + undefined4 extraout_fa0; + longlong lVar9; + + pyVar3 = get_context(); + pyVar4 = pyVar3; + while (pyVar3->terminate == false) { + pyVar1 = (yloop_ctx_t *)(pyVar3->timeouts).next; + nfds = (yloop_sock_t *)(uint)pyVar3->reader_count; + if ((pyVar3 == pyVar1) && (pyVar3->reader_count == 0)) break; + pv = (yloop_ctx_t *)0xffffffff; + if (pyVar3 != pyVar1) { + aos_now_ms(); + if (((int)param_1 < (int)pyVar1->readers) || + ((pyVar1->readers == param_1 && (pyVar4 < (yloop_ctx_t *)pyVar1->pollfds)))) { + pv = (yloop_ctx_t *)((int)(yloop_ctx_t *)pyVar1->pollfds - (int)pyVar4); + } + else { + pv = (yloop_ctx_t *)0x0; + } + } + iVar6 = 0; + while (iVar6 < (int)nfds) { + pyVar3->pollfds[iVar6].fd = pyVar3->readers[iVar6].sock; + pyVar3->pollfds[iVar6].events = 1; + iVar6 = iVar6 + 1; + } + param_1 = nfds; + pyVar1 = (yloop_ctx_t *)aos_poll(pyVar3->pollfds,(int)nfds,(int)pv); + pyVar4 = pyVar1; + if ((int)pyVar1 < 0) { + pyVar4 = (yloop_ctx_t *)__errno(); + param_1 = extraout_a1; + if ((pyVar4->timeouts).prev != (dlist_s *)0x4) { + printf("yloopaos_poll",extraout_fa0); + return; + } + } + pv = (yloop_ctx_t *)(pyVar3->timeouts).next; + if (pyVar3 != pv) { + lVar9 = aos_now_ms(); + if (((int)pv->readers <= (int)param_1) && + ((pv->readers != param_1 || ((yloop_ctx_t *)pv->pollfds <= pyVar4)))) { + pdVar7 = (pv->timeouts).next; + pdVar5 = (pv->timeouts).prev; + pdVar5->next = pdVar7; + pdVar7->prev = pdVar5; + param_1 = (yloop_sock_t *) + (**(code **)&pv->max_sock)(pv->eventfd,*(code **)&pv->max_sock,(int)lVar9); + vPortFree(pv); + pyVar4 = pv; + } + } + pyVar2 = (yloop_sock_t *)0x0; + if (0 < (int)pyVar1) { + while (pyVar2 != nfds) { + if ((pyVar3->pollfds[(int)pyVar2].revents & 1U) != 0) { + pyVar8 = pyVar3->readers + (int)pyVar2; + pyVar4 = (yloop_ctx_t *)(*pyVar8->cb)(pyVar8->sock,pyVar8->private_data); + param_1 = extraout_a1_00; + } + pyVar2 = (yloop_sock_t *)((int)&pyVar2->sock + 1); + } + } + } + pyVar3->terminate = false; + return; +} + + + +void vfs_poll_notify(pollfd *fd,void *arg) + +{ + aos_sem_signal((aos_sem_t *)arg); + return; +} + + + +int aos_poll(pollfd *fds,int nfds,int timeout) + +{ + ushort *puVar1; + int iVar2; + uint fd; + file_t *pfVar3; + ushort *puVar4; + int iVar5; + code *pcVar6; + int iVar7; + pollfd *ppVar8; + aos_sem_t aStack60; + poll_arg parg; + _types_fd_set rfds; + + aos_sem_new(&aStack60,0); + iVar5 = 0; + do { + *(undefined *)((int)&parg.sem.hdl + iVar5) = 0; + iVar5 = iVar5 + 1; + } while (iVar5 != 8); + puVar1 = (ushort *)&fds->revents; + iVar5 = 0; + puVar4 = puVar1; + while (iVar5 < nfds) { + *puVar4 = 0; + iVar5 = iVar5 + 1; + puVar4 = puVar4 + 4; + } + iVar5 = 0; + ppVar8 = fds; + do { + if (nfds <= iVar5) { + if (timeout < 0) { + timeout = 0xffffffff; + } + aos_sem_wait(&aStack60,timeout); + iVar5 = 0; + while (iVar5 < nfds) { + if ((1 << (*(uint *)(puVar1 + -3) & 0x1f) & + (uint)(&parg)[*(uint *)(puVar1 + -3) >> 5].sem.hdl) != 0) { + *puVar1 = *puVar1 | 1; + } + iVar5 = iVar5 + 1; + puVar1 = puVar1 + 4; + } + iVar5 = 0; +check_poll: + iVar2 = 0; + iVar7 = 0; + while (iVar7 < nfds) { + if (((1 < fds->fd) && (pfVar3 = get_file(fds->fd), pfVar3 != (file_t *)0x0)) && + (pcVar6 = *(code **)(pfVar3->node->ops + 0x14), (*pcVar6)(0,0,0,0,pcVar6), + fds->revents != 0)) { + iVar2 = iVar2 + 1; + } + iVar7 = iVar7 + 1; + fds = fds + 1; + } + aos_sem_free(&aStack60); + if (iVar5 != 0) { + iVar2 = 0; + } + return iVar2; + } + fd = ppVar8->fd; + if ((int)fd < 2) { + (&parg)[fd >> 5].sem.hdl = (void *)(1 << (fd & 0x1f) | (uint)(&parg)[fd >> 5].sem.hdl); + } + else { + pfVar3 = get_file(fd); + if (pfVar3 == (file_t *)0x0) { + iVar5 = -1; + goto check_poll; + } + pcVar6 = *(code **)(pfVar3->node->ops + 0x14); + (*pcVar6)(1,vfs_poll_notify,ppVar8,&aStack60,pcVar6); + } + iVar5 = iVar5 + 1; + ppVar8 = ppVar8 + 1; + } while( true ); +} + + + +int aos_fcntl(int fd,int cmd,int val) + +{ + int iVar1; + + iVar1 = -0x16; + if ((-1 < fd) && (iVar1 = 0, fd < 2)) { + iVar1 = -2; + } + return iVar1; +} + + + +void dfl_entry(void *arg) + +{ + code *pcVar1; + undefined4 uVar2; + + uVar2 = *(undefined4 *)((int)arg + 8); + pcVar1 = *(code **)((int)arg + 4); + vPortFree(arg); + (*pcVar1)(uVar2); + vTaskDelete((TaskHandle_t)0x0); + return; +} + + + +int aos_task_new(char *name,anon_subr_void_void_ptr *fn,void *arg,int stack_size) + +{ + StaticTask_t *pxTaskBuffer; + StaticTask_t **pvParameters; + StackType_t *puxStackBuffer; + TaskHandle_t ptVar1; + int iVar2; + + pxTaskBuffer = (StaticTask_t *)pvPortMalloc(0x9c); + pvParameters = (StaticTask_t **)pvPortMalloc(0xc); + puxStackBuffer = (StackType_t *)pvPortMalloc(stack_size); + memset(puxStackBuffer,0,stack_size); + memset(pxTaskBuffer,0,0x9c); + pxTaskBuffer[1].pxDummy1 = (void *)0xfffffff0; + *(StackType_t **)(pxTaskBuffer[1].xDummy3[0].pvDummy3 + 3) = puxStackBuffer; + strncpy((char *)(pxTaskBuffer[1].xDummy3 + 1),name,0x1f); + *(undefined4 *)(pxTaskBuffer[1].ucDummy7 + 4) = 0x20171020; + *pvParameters = pxTaskBuffer; + *(anon_subr_void_void_ptr **)(pvParameters + 1) = fn; + pvParameters[2] = arg; + ptVar1 = xTaskCreateStatic(dfl_entry,name,(uint)stack_size >> 2,pvParameters,10,puxStackBuffer, + pxTaskBuffer); + if (ptVar1 == (TaskHandle_t)0x0) { + vPortFree(pxTaskBuffer); + vPortFree(puxStackBuffer); + vPortFree(pvParameters); + iVar2 = -1; + } + else { + iVar2 = 0; + } + return iVar2; +} + + + +void aos_task_exit(int code) + +{ + vTaskDelete((TaskHandle_t)0x0); + return; +} + + + +int aos_task_key_create(aos_task_key_t *key) + +{ + TaskHandle_t ptVar1; + uint uVar2; + aos_task_key_t aVar3; + int iVar4; + StackType_t *pSVar5; + + ptVar1 = xTaskGetCurrentTaskHandle(); + if (*(int *)(ptVar1[1].pcTaskName + 4) == 0x20171020) { + pSVar5 = ptVar1[1].pxTopOfStack; + if (((uint)pSVar5 & 1) == 0) { + aVar3 = 0; + uVar2 = 1; + } + else { + if (((uint)pSVar5 & 2) == 0) { + aVar3 = 1; + uVar2 = 2; + } + else { + if (((uint)pSVar5 & 4) == 0) { + aVar3 = 2; + uVar2 = 4; + } + else { + if (((uint)pSVar5 & 8) != 0) { + return -1; + } + aVar3 = 3; + uVar2 = 8; + } + } + } + ptVar1[1].pxTopOfStack = (StackType_t *)((uint)pSVar5 | uVar2); + *key = aVar3; + iVar4 = 0; + } + else { + iVar4 = -1; + } + return iVar4; +} + + + +int aos_task_setspecific(aos_task_key_t key,void *vp) + +{ + TaskHandle_t ptVar1; + int iVar2; + + ptVar1 = xTaskGetCurrentTaskHandle(); + if (key < 4) { + iVar2 = -1; + if (*(int *)(ptVar1[1].pcTaskName + 4) == 0x20171020) { + *(void **)(&(ptVar1->xStateListItem).xItemValue + key + 0x18) = vp; + iVar2 = 0; + } + } + else { + iVar2 = -1; + } + return iVar2; +} + + + +void * aos_task_getspecific(aos_task_key_t key) + +{ + TaskHandle_t ptVar1; + void *pvVar2; + + ptVar1 = xTaskGetCurrentTaskHandle(); + if (key < 4) { + pvVar2 = (void *)0x0; + if (*(int *)(ptVar1[1].pcTaskName + 4) == 0x20171020) { + pvVar2 = (void *)(&(ptVar1->xStateListItem).xItemValue)[key + 0x18]; + } + } + else { + pvVar2 = (void *)0x0; + } + return pvVar2; +} + + + +int aos_mutex_new(aos_mutex_t *mutex) + +{ + QueueHandle_t pQVar1; + + pQVar1 = xQueueCreateMutex('\x01'); + *(QueueHandle_t *)&mutex->hdl = pQVar1; + return -(uint)(pQVar1 == (QueueHandle_t)0x0); +} + + + +void aos_mutex_free(aos_mutex_t *mutex) + +{ + vQueueDelete((QueueHandle_t)mutex->hdl); + return; +} + + + +int aos_mutex_lock(aos_mutex_t *mutex,uint ms) + +{ + if (mutex != (aos_mutex_t *)0x0) { + xQueueSemaphoreTake((QueueHandle_t)mutex->hdl,ms); + return 0; + } + return 0; +} + + + +int aos_mutex_unlock(aos_mutex_t *mutex) + +{ + if (mutex != (aos_mutex_t *)0x0) { + xQueueGenericSend((QueueHandle_t)mutex->hdl,(void *)0x0,0,0); + return 0; + } + return 0; +} + + + +int aos_sem_new(aos_sem_t *sem,int count) + +{ + QueueHandle_t pQVar1; + + pQVar1 = xQueueCreateCountingSemaphore(0x80,count); + *(QueueHandle_t *)&sem->hdl = pQVar1; + return 0; +} + + + +void aos_sem_free(aos_sem_t *sem) + +{ + if (sem != (aos_sem_t *)0x0) { + vQueueDelete((QueueHandle_t)sem->hdl); + return; + } + return; +} + + + +int aos_sem_wait(aos_sem_t *sem,uint ms) + +{ + BaseType_t BVar1; + + if (sem != (aos_sem_t *)0x0) { + BVar1 = xQueueSemaphoreTake((QueueHandle_t)sem->hdl,ms); + return -(uint)(BVar1 != 1); + } + return -1; +} + + + +void aos_sem_signal(aos_sem_t *sem) + +{ + BaseType_t BStack20; + BaseType_t xHigherPriorityTaskWoken; + + BStack20 = 0; + if (sem != (aos_sem_t *)0x0) { + if (TrapNetCounter == 0) { + xQueueGenericSend((QueueHandle_t)sem->hdl,(void *)0x0,0,0); + } + else { + xQueueGiveFromISR((QueueHandle_t)sem->hdl,&BStack20); + if (BStack20 != 0) { + vTaskSwitchContext(); + } + } + } + return; +} + + + +void * aos_malloc(size_t xWantedSize) + +{ + size_t sVar1; + size_t sVar2; + BlockLink_t *pBVar3; + A_BLOCK_LINK *pAVar4; + BlockLink_t *pxBlockToInsert; + uint uVar5; + uint uVar6; + + if (pxEnd == (BlockLink_t *)0x0) { + vAssertCalled(); + } + vTaskSuspendAll(); + sVar2 = xFreeBytesRemaining; + sVar1 = xBlockAllocatedBit; + if (((xBlockAllocatedBit & xWantedSize) == 0) && (xWantedSize != 0)) { + uVar6 = xWantedSize + 8; + if ((uVar6 & 7) != 0) { + uVar6 = (uVar6 & 0xfffffff8) + 8; + } + if ((uVar6 != 0) && (uVar6 <= xFreeBytesRemaining)) { + pAVar4 = xStart.pxNextFreeBlock; + pBVar3 = &xStart; + do { + pxBlockToInsert = pBVar3; + pBVar3 = (BlockLink_t *)pAVar4; + if (uVar6 <= pBVar3->xBlockSize) break; + pAVar4 = pBVar3->pxNextFreeBlock; + } while (pBVar3->pxNextFreeBlock != (A_BLOCK_LINK *)0x0); + if (pxEnd != pBVar3) { + pAVar4 = pxBlockToInsert->pxNextFreeBlock; + pxBlockToInsert->pxNextFreeBlock = pBVar3->pxNextFreeBlock; + uVar5 = pBVar3->xBlockSize; + pAVar4 = pAVar4 + 1; + if (0x10 < uVar5 - uVar6) { + pxBlockToInsert = (BlockLink_t *)((int)&pBVar3->pxNextFreeBlock + uVar6); + pxBlockToInsert->xBlockSize = uVar5 - uVar6; + pBVar3->xBlockSize = uVar6; + prvInsertBlockIntoFreeList(pxBlockToInsert); + uVar5 = pBVar3->xBlockSize; + } + xFreeBytesRemaining = sVar2 - uVar5; + if (xFreeBytesRemaining < xMinimumEverFreeBytesRemaining) { + xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; + } + pBVar3->xBlockSize = sVar1 | uVar5; + pBVar3->pxNextFreeBlock = (A_BLOCK_LINK *)0x0; + xTaskResumeAll(); + if (pAVar4 != (A_BLOCK_LINK *)0x0) { + return pAVar4; + } + goto LAB_230359be; + } + } + } + xTaskResumeAll(); +LAB_230359be: + vApplicationMallocFailedHook(); + return (void *)0x0; +} + + + +void free(void *pv) + +{ + uint uVar1; + + if (pv == (void *)0x0) { + return; + } + uVar1 = *(uint *)((int)pv + -4); + if ((uVar1 & xBlockAllocatedBit) == 0) { + vAssertCalled(); + if (*(int *)((int)pv + -8) == 0) { + uVar1 = *(uint *)((int)pv + -4); + if ((uVar1 & xBlockAllocatedBit) == 0) { + return; + } + goto LAB_23035ace; + } + } + else { + if (*(int *)((int)pv + -8) == 0) goto LAB_23035ace; + } + vAssertCalled(); + uVar1 = *(uint *)((int)pv + -4); + if (((uVar1 & xBlockAllocatedBit) == 0) || (*(int *)((int)pv + -8) != 0)) { + return; + } +LAB_23035ace: + *(uint *)((int)pv + -4) = ~xBlockAllocatedBit & uVar1; + vTaskSuspendAll(); + xFreeBytesRemaining = *(int *)((int)pv + -4) + xFreeBytesRemaining; + prvInsertBlockIntoFreeList((BlockLink_t *)((int)pv + -8)); + xTaskResumeAll(); + return; +} + + + +void aos_free(void *pv) + +{ + uint uVar1; + + if (pv == (void *)0x0) { + return; + } + uVar1 = *(uint *)((int)pv + -4); + if ((uVar1 & xBlockAllocatedBit) == 0) { + vAssertCalled(); + if (*(int *)((int)pv + -8) == 0) { + uVar1 = *(uint *)((int)pv + -4); + if ((uVar1 & xBlockAllocatedBit) == 0) { + return; + } + goto LAB_23035ace; + } + } + else { + if (*(int *)((int)pv + -8) == 0) goto LAB_23035ace; + } + vAssertCalled(); + uVar1 = *(uint *)((int)pv + -4); + if (((uVar1 & xBlockAllocatedBit) == 0) || (*(int *)((int)pv + -8) != 0)) { + return; + } +LAB_23035ace: + *(uint *)((int)pv + -4) = ~xBlockAllocatedBit & uVar1; + vTaskSuspendAll(); + xFreeBytesRemaining = *(int *)((int)pv + -4) + xFreeBytesRemaining; + prvInsertBlockIntoFreeList((BlockLink_t *)((int)pv + -8)); + xTaskResumeAll(); + return; +} + + + +void * malloc(size_t xWantedSize) + +{ + size_t sVar1; + size_t sVar2; + BlockLink_t *pBVar3; + A_BLOCK_LINK *pAVar4; + BlockLink_t *pxBlockToInsert; + uint uVar5; + uint uVar6; + + if (pxEnd == (BlockLink_t *)0x0) { + vAssertCalled(); + } + vTaskSuspendAll(); + sVar2 = xFreeBytesRemaining; + sVar1 = xBlockAllocatedBit; + if (((xBlockAllocatedBit & xWantedSize) == 0) && (xWantedSize != 0)) { + uVar6 = xWantedSize + 8; + if ((uVar6 & 7) != 0) { + uVar6 = (uVar6 & 0xfffffff8) + 8; + } + if ((uVar6 != 0) && (uVar6 <= xFreeBytesRemaining)) { + pAVar4 = xStart.pxNextFreeBlock; + pBVar3 = &xStart; + do { + pxBlockToInsert = pBVar3; + pBVar3 = (BlockLink_t *)pAVar4; + if (uVar6 <= pBVar3->xBlockSize) break; + pAVar4 = pBVar3->pxNextFreeBlock; + } while (pBVar3->pxNextFreeBlock != (A_BLOCK_LINK *)0x0); + if (pxEnd != pBVar3) { + pAVar4 = pxBlockToInsert->pxNextFreeBlock; + pxBlockToInsert->pxNextFreeBlock = pBVar3->pxNextFreeBlock; + uVar5 = pBVar3->xBlockSize; + pAVar4 = pAVar4 + 1; + if (0x10 < uVar5 - uVar6) { + pxBlockToInsert = (BlockLink_t *)((int)&pBVar3->pxNextFreeBlock + uVar6); + pxBlockToInsert->xBlockSize = uVar5 - uVar6; + pBVar3->xBlockSize = uVar6; + prvInsertBlockIntoFreeList(pxBlockToInsert); + uVar5 = pBVar3->xBlockSize; + } + xFreeBytesRemaining = sVar2 - uVar5; + if (xFreeBytesRemaining < xMinimumEverFreeBytesRemaining) { + xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; + } + pBVar3->xBlockSize = sVar1 | uVar5; + pBVar3->pxNextFreeBlock = (A_BLOCK_LINK *)0x0; + xTaskResumeAll(); + if (pAVar4 != (A_BLOCK_LINK *)0x0) { + return pAVar4; + } + goto LAB_230359be; + } + } + } + xTaskResumeAll(); +LAB_230359be: + vApplicationMallocFailedHook(); + return (void *)0x0; +} + + + +longlong aos_now_ms(void) + +{ + BaseType_t BVar1; + longlong in_fa0; + TickType_t TStack24; + TickType_t ticks; + BaseType_t overflow_count; + + TStack24 = 0; + ticks = 0; + BVar1 = xTaskGetTickCount2(&TStack24,(BaseType_t *)&ticks); + if (BVar1 != 1) { + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + return in_fa0; +} + + + +int event_poll(file_t *f,_Bool setup,poll_notify_t *notify,pollfd *fd,void *opa) + +{ + aos_mutex_t *mutex; + undefined3 in_register_0000202d; + + mutex = (aos_mutex_t *)f->f_arg; + aos_mutex_lock(mutex,0xffffffff); + if (CONCAT31(in_register_0000202d,setup) == 0) { + mutex[1].hdl = (void *)0x0; + mutex[3].hdl = (void *)0x0; + } + else { + *(poll_notify_t **)&mutex[1].hdl = notify; + *(pollfd **)&mutex[2].hdl = fd; + mutex[3].hdl = opa; + if (mutex[4].hdl != (void *)0x0) { + fd->revents = fd->revents | 1; + (*notify)(fd,opa); + } + } + aos_mutex_unlock(mutex); + return 0; +} + + + +int event_open(inode_t *node,file_t *file) + +{ + aos_mutex_t *mutex; + + mutex = (aos_mutex_t *)aos_malloc(0x28); + memset(mutex,0,0x28); + aos_mutex_new(mutex); + *(aos_mutex_t **)&mutex[5].hdl = mutex + 5; + *(aos_mutex_t **)&mutex[6].hdl = mutex + 5; + *(aos_mutex_t **)&mutex[8].hdl = mutex + 8; + *(aos_mutex_t **)&mutex[9].hdl = mutex + 8; + *(aos_mutex_t **)&file->f_arg = mutex; + return 0; +} + + + +ssize_t _event_write(void *buf,size_t len,_Bool urgent) + +{ + int *piVar1; + undefined3 in_register_00002031; + int in_a3; + int iVar2; + int *piVar3; + int **ppiVar4; + size_t __n; + + __n = CONCAT31(in_register_00002031,urgent); + aos_mutex_lock((aos_mutex_t *)buf,0xffffffff); + if ((*(int *)((int)buf + 0x1c) < 1) || (piVar1 = *(int **)((int)buf + 0x24), __n != piVar1[2])) { + piVar1 = (int *)aos_malloc(__n + 0xc); + if (piVar1 == (int *)0x0) { + __n = 0xffffffff; + goto out; + } + } + else { + piVar3 = (int *)piVar1[1]; + iVar2 = *piVar1; + *(int **)(iVar2 + 4) = piVar3; + *piVar3 = iVar2; + *(int *)((int)buf + 0x1c) = *(int *)((int)buf + 0x1c) + -1; + } + *(int *)((int)buf + 0x10) = *(int *)((int)buf + 0x10) + 1; + piVar1[2] = __n; + memcpy(piVar1 + 3,(void *)len,__n); + if (in_a3 == 0) { + iVar2 = *(int *)((int)buf + 0x14); + piVar1[1] = (int)buf + 0x14; + *piVar1 = iVar2; + *(int **)(iVar2 + 4) = piVar1; + *(int **)((int)buf + 0x14) = piVar1; + } + else { + ppiVar4 = *(int ***)((int)buf + 0x18); + *piVar1 = (int)buf + 0x14; + *(int ***)(piVar1 + 1) = ppiVar4; + *(int **)((int)buf + 0x18) = piVar1; + *ppiVar4 = piVar1; + } + if (*(int *)((int)buf + 4) != 0) { + *(ushort *)(*(int *)((int)buf + 8) + 6) = *(ushort *)(*(int *)((int)buf + 8) + 6) | 1; + (**(code **)((int)buf + 4)) + (*(undefined4 *)((int)buf + 8),*(undefined4 *)((int)buf + 0xc), + *(code **)((int)buf + 4)); + } +out: + aos_mutex_unlock((aos_mutex_t *)buf); + return __n; +} + + + +int event_ioctl(file_t *f,int cmd,ulong arg) + +{ + ssize_t sVar1; + + if (((cmd & 0xfU) != 1) && ((cmd & 0xfU) != 2)) { + return -1; + } + sVar1 = _event_write(f->f_arg,arg,SUB41(cmd >> 4,0)); + return sVar1; +} + + + +ssize_t event_write(file_t *f,void *buf,size_t len) + +{ + ssize_t sVar1; + + sVar1 = _event_write(f->f_arg,(size_t)buf,SUB41(len,0)); + return sVar1; +} + + + +int event_close(file_t *file) + +{ + aos_mutex_t *mutex; + aos_mutex_t *pv; + void *pvVar1; + void **ppvVar2; + + mutex = (aos_mutex_t *)file->f_arg; + aos_mutex_free(mutex); + while (pv = (aos_mutex_t *)mutex[6].hdl, pv != mutex + 5) { + pvVar1 = pv->hdl; + ppvVar2 = (void **)pv[1].hdl; + *(void ***)((int)pvVar1 + 4) = ppvVar2; + *ppvVar2 = pvVar1; + aos_free(pv); + } + while (pv = (aos_mutex_t *)mutex[9].hdl, pv != mutex + 8) { + pvVar1 = pv->hdl; + ppvVar2 = (void **)pv[1].hdl; + *(void ***)((int)pvVar1 + 4) = ppvVar2; + *ppvVar2 = pvVar1; + aos_free(pv); + } + aos_free(mutex); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling + +ssize_t event_read(file_t *f,void *buf,size_t len) + +{ + aos_mutex_t *mutex; + void *pv; + int iVar1; + int *piVar2; + void **ppvVar3; + uint __n; + + mutex = (aos_mutex_t *)f->f_arg; + __n = (uint)mutex[4].hdl; + if (__n != 0) { + aos_mutex_lock(mutex,0xffffffff); + pv = mutex[6].hdl; + iVar1 = *(int *)pv; + piVar2 = *(int **)((int)pv + 4); + *(int **)(iVar1 + 4) = piVar2; + *piVar2 = iVar1; + __n = *(uint *)((int)pv + 8); + if (len < *(uint *)((int)pv + 8)) { + __n = len; + } + memcpy(buf,(void *)((int)pv + 0xc),__n); + if ((int)mutex[7].hdl < 4) { + ppvVar3 = (void **)mutex[9].hdl; + *(aos_mutex_t **)pv = mutex + 8; + *(void ***)((int)pv + 4) = ppvVar3; + mutex[9].hdl = pv; + *ppvVar3 = pv; + mutex[7].hdl = (void *)((int)mutex[7].hdl + 1); + } + else { + aos_free(pv); + } + mutex[4].hdl = (void *)((int)mutex[4].hdl + -1); + aos_mutex_unlock(mutex); + } + return __n; +} + + + +int vfs_device_init(void) + +{ + int iVar1; + + iVar1 = 0; + if ((inited != 1) && + (iVar1 = aos_register_driver("/dev/event",(file_ops_t *)&event_fops,(void *)0x0), iVar1 == 0)) + { + inited = 1; + } + return iVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void event_read_cb(int fd,void *param) + +{ + dlist_s *pdVar1; + ssize_t sVar2; + undefined auStack32 [4]; + input_event_t event; + + sVar2 = aos_read(fd,auStack32,0x10); + if (sVar2 == 0x10) { + pdVar1 = g_local_event_list.next; + if ((short)event.time == 0x100) { + (*event._4_4_)(event.value,event._4_4_); + } + else { + while (pdVar1 != (dlist_s *)&g_local_event_list) { + if ((*(short *)&((dlist_t *)pdVar1)[2].prev == 0) || + ((short)event.time == *(short *)&((dlist_t *)pdVar1)[2].prev)) { + (*(code *)((dlist_t *)pdVar1)[1].prev) + (auStack32,((dlist_t *)pdVar1)[1].next,((dlist_t *)pdVar1)[1].prev); + } + pdVar1 = ((dlist_t *)pdVar1)->next; + } + } + } + return; +} + + + +int aos_event_service_init(void) + +{ + int sock; + + sock = aos_open("/dev/event",0); + if (local_event.fd < 0) { + local_event.fd = sock; + } + aos_poll_read_fd(sock,event_read_cb,(void *)0x0); + aos_loop_set_eventfd(sock); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int aos_post_event(uint16_t type,uint16_t code,ulong value) + +{ + undefined2 in_register_0000202a; + int iVar1; + undefined4 local_20; + input_event_t event; + + event.time._0_2_ = (ushort)((CONCAT22(in_register_0000202a,type) << 0x11) >> 0x11); + local_20 = 0; + event.value = 0; + event.time._2_2_ = code; + event._4_4_ = value; + iVar1 = aos_ioctl(local_event.fd,(CONCAT22(in_register_0000202a,type) >> 0xf) + 0x101, + (ulong)&local_20); + return iVar1; +} + + + +int aos_register_event_filter(uint16_t type,aos_event_cb *cb,void *priv) + +{ + dlist_s *pdVar1; + int iVar2; + + if (cb != (aos_event_cb *)0x0) { + pdVar1 = (dlist_s *)aos_malloc(0x14); + iVar2 = -0xc; + if (pdVar1 != (dlist_s *)0x0) { + *(aos_event_cb **)&pdVar1[1].prev = cb; + *(uint16_t *)&pdVar1[2].prev = type; + pdVar1->prev = g_local_event_list.prev; + pdVar1[1].next = priv; + *(dlist_t **)&pdVar1->next = &g_local_event_list; + (g_local_event_list.prev)->next = pdVar1; + iVar2 = 0; + g_local_event_list.prev = pdVar1; + } + return iVar2; + } + return -0x16; +} + + + +size_t format_int(char *q,size_t n,uint flags,int base,int width,int prec) + +{ + char "0123456789abcdef" [17]; + char "0123456789ABCDEF" [17]; + int iVar1; + uint uVar2; + uint uVar3; + char cVar4; + uint uVar5; + uint uVar6; + int in_a6; + int in_a7; + int iVar7; + int iVar8; + uint uVar9; + char *pcVar10; + int iVar11; + char *pcStack84; + + if ((width & 0x80U) == 0) { + pcStack84 = "0123456789abcdef"; + } + else { + pcStack84 = "0123456789ABCDEF"; + } + uVar9 = 0; + if (((width & 0x40U) != 0) && (base < 0)) { + flags = -flags; + base = -(uint)(flags != 0) - base; + uVar9 = 1; + } + iVar7 = 0; + uVar2 = flags; + uVar6 = base; + while ((uVar2 | uVar6) != 0) { + __udivdi3(); + iVar7 = iVar7 + 1; + } + uVar2 = width & 0x20; + if ((uVar2 == 0) || (prec != 8)) { +LAB_23002cf4: + if ((in_a7 <= iVar7) && (in_a7 = iVar7, (flags | base) == 0)) { + in_a7 = 1; + } + } + else { + if (in_a7 <= iVar7) { + in_a7 = iVar7 + 1; + goto LAB_23002cf4; + } + } + iVar7 = in_a7; + if (((width & 8U) != 0) && (iVar7 = 4, prec != 0x10)) { + iVar7 = 3; + } + iVar8 = (in_a7 + -1) / iVar7 + in_a7; + iVar1 = (uint)((width & 0x14U | uVar9) != 0) + iVar8; + if ((uVar2 != 0) && (prec == 0x10)) { + iVar1 = iVar1 + 2; + } + uVar3 = width & 3; + uVar6 = 0; + if ((uVar3 == 0) && (uVar6 = uVar3, iVar1 < in_a6)) { + uVar6 = in_a6 - iVar1; + uVar5 = 0; + do { + if (uVar5 < n) { + *q = ' '; + q = q + 1; + } + uVar5 = uVar5 + 1; + in_a6 = iVar1; + } while (uVar5 != uVar6); + } + if (uVar9 == 0) { + if ((width & 4U) == 0) { + if ((width & 0x10U) == 0) goto LAB_23002d76; + if (uVar6 < n) { + *q = ' '; + q = q + 1; + } + } + else { + if (uVar6 < n) { + *q = '+'; + q = q + 1; + } + } + } + else { + if (uVar6 < n) { + *q = '-'; + q = q + 1; + } + } + uVar6 = uVar6 + 1; +LAB_23002d76: + if ((uVar2 != 0) && (prec == 0x10)) { + if (uVar6 < n) { + *q = '0'; + q = q + 1; + } + if (uVar6 + 1 < n) { + cVar4 = 'X'; + if ((width & 0x80U) == 0) { + cVar4 = 'x'; + } + *q = cVar4; + q = q + 1; + } + uVar6 = uVar6 + 2; + } + if ((uVar3 == 1) && (iVar8 < in_a6)) { + while (iVar1 < in_a6) { + if (uVar6 < n) { + *q = '0'; + q = q + 1; + } + uVar6 = uVar6 + 1; + in_a6 = in_a6 + -1; + } + } + uVar6 = iVar8 + uVar6; + q = q + iVar8; + pcVar10 = q; + uVar9 = uVar6; + iVar11 = iVar7; + while (0 < iVar8) { + if (iVar11 == 0) { + uVar9 = uVar9 - 1; + if (uVar9 < n) { + pcVar10[-1] = '_'; + } + pcVar10 = pcVar10 + -1; + iVar8 = iVar8 + -1; + iVar11 = iVar7; + } + iVar11 = iVar11 + -1; + uVar9 = uVar9 - 1; + iVar8 = iVar8 + -1; + if (uVar9 < n) { + uVar2 = flags; + __umoddi3(); + pcVar10[-1] = pcStack84[uVar2]; + } + __udivdi3(); + pcVar10 = pcVar10 + -1; + } + iVar7 = in_a6 + uVar6; + while (((width & 2U) != 0 && (iVar1 < (int)(iVar7 - uVar6)))) { + if (uVar6 < n) { + *q = ' '; + q = q + 1; + } + uVar6 = uVar6 + 1; + } + return uVar6; +} + + + +char * cvt(int ndigits,int *decpt,int *sign,char *buf,int eflag) + +{ + int *piVar1; + byte *pbVar2; + __gcc_CMPtype _Var3; + double *__iptr; + SItype SVar4; + byte *in_a5; + byte *pbVar5; + int in_a6; + byte *pbVar6; + byte *pbVar7; + double in_fa1; + double *pdStack80; + double fi; + double fj; + + piVar1 = (int *)0x4e; + if (((int)sign < 0x4f) && (piVar1 = sign, (int)sign < 0)) { + piVar1 = (int *)0x0; + } + _Var3 = __ledf2(); + if (_Var3 < 0) { + *(undefined4 *)eflag = 1; + } + else { + *(undefined4 *)eflag = 0; + } + modf(in_fa1,(double *)ndigits); + pbVar6 = in_a5 + 0x50; + _Var3 = __eqdf2(); + pbVar2 = pbVar6; + pbVar5 = in_a5; + if (_Var3 == 0) { + _Var3 = __gedf2(); + pbVar7 = (byte *)0x0; + if (0 < _Var3) { + while( true ) { + __iptr = (double *)ndigits; + __muldf3(); + _Var3 = __ledf2(); + if (-1 < _Var3) break; + pbVar7 = pbVar7 + -1; + ndigits = (int)__iptr; + } + } + } + else { + while( true ) { + _Var3 = __eqdf2(); + pbVar7 = pbVar6 + -(int)pbVar2; + if (_Var3 == 0) break; + __iptr = pdStack80; + __divdf3(); + modf(in_fa1,__iptr); + __adddf3(); + __muldf3(); + SVar4 = __fixdfsi(); + pbVar2[-1] = (char)SVar4 + 0x30; + pbVar2 = pbVar2 + -1; + } + while (pbVar2 < pbVar6) { + *pbVar5 = *pbVar2; + pbVar5 = pbVar5 + 1; + pbVar2 = pbVar2 + 1; + } + } + pbVar2 = (byte *)((int)piVar1 + (int)in_a5); + if (in_a6 == 0) { + pbVar2 = pbVar2 + (int)pbVar7; + } + *(byte **)buf = pbVar7; + if (pbVar2 < in_a5) { + *in_a5 = 0; + } + else { + while ((pbVar5 <= pbVar2 && (pbVar5 < pbVar6))) { + __muldf3(); + modf(in_fa1,(double *)ndigits); + SVar4 = __fixdfsi(); + *pbVar5 = (char)SVar4 + 0x30; + pbVar5 = pbVar5 + 1; + } + if (pbVar2 < pbVar6) { + *pbVar2 = *pbVar2 + 5; + pbVar5 = pbVar2; + while (0x39 < *pbVar5) { + *pbVar5 = 0x30; + if (in_a5 < pbVar5) { + pbVar6 = pbVar5 + -1; + pbVar5 = pbVar5 + -1; + *pbVar5 = *pbVar6 + 1; + } + else { + *pbVar5 = 0x31; + *(int *)buf = *(int *)buf + 1; + if (in_a6 == 0) { + if (in_a5 < pbVar2) { + *pbVar2 = 0x30; + } + pbVar2 = pbVar2 + 1; + } + } + } + *pbVar2 = 0; + } + else { + in_a5[0x4f] = 0; + } + } + return (char *)in_a5; +} + + + +char * ecvtbuf(int ndigits,int *decpt,int *sign,char *buf) + +{ + char *pcVar1; + int in_a4; + + pcVar1 = cvt(ndigits,decpt,sign,buf,in_a4); + return pcVar1; +} + + + +char * fcvtbuf(int ndigits,int *decpt,int *sign,char *buf) + +{ + char *pcVar1; + int in_a4; + + pcVar1 = cvt(ndigits,decpt,sign,buf,in_a4); + return pcVar1; +} + + + +char * flt(char *str,int size,int precision,char fmt,int flags) + +{ + bool bVar1; + byte bVar2; + int iVar3; + __gcc_CMPtype _Var4; + char *pcVar5; + undefined *puVar6; + size_t sVar7; + int *sign_00; + undefined3 in_register_00002035; + char *pcVar8; + int *piVar9; + uint uVar10; + int *__string; + char cVar11; + uint in_a5; + uint uVar12; + char *pcVar13; + int iVar14; + uint in_a6; + char cVar15; + char cVar16; + char *pcVar17; + char *pcStack232; + int decpt; + int sign; + char tmp [80]; + char cvtbuf [80]; + + iVar3 = CONCAT31(in_register_00002035,fmt); + uVar12 = in_a6 & 0x10; + if (uVar12 == 0) { + cVar16 = '0'; + if ((in_a6 & 1) == 0) { + cVar16 = ' '; + } + } + else { + in_a6 = in_a6 & 0xfffffffe; + cVar16 = ' '; + } + cVar15 = '\0'; + if ((in_a6 & 2) != 0) { + _Var4 = __ledf2(); + if (_Var4 < 0) { + precision = precision ^ 0x80000000; + iVar3 = iVar3 + -1; + cVar15 = '-'; + } + else { + if ((in_a6 & 4) == 0) { + if ((in_a6 & 8) != 0) { + iVar3 = iVar3 + -1; + cVar15 = ' '; + } + } + else { + iVar3 = iVar3 + -1; + cVar15 = '+'; + } + } + } + if (flags < 0) { + flags = 6; + } + bVar1 = (in_a5 & 0xfd) != 0x45; + uVar10 = in_a5; + if (!bVar1) { + uVar10 = in_a5 + 0x20 & 0xff; + } + if (uVar10 == 0x67) { + ecvtbuf(size,(int *)precision,(int *)flags,(char *)&pcStack232); + if ((-5 < (int)(pcStack232 + -1)) && ((int)(pcStack232 + -1) < flags)) { + sign_00 = (int *)(flags - (int)pcStack232); +LAB_230032d2: + pcVar5 = fcvtbuf(size,(int *)precision,sign_00,(char *)&pcStack232); + __string = &sign; + if (decpt != 0) { + sign._0_1_ = 0x2d; + __string = (int *)((int)&sign + 1); + } + if (*pcVar5 == '\0') { + *(char *)__string = '0'; + if ((int)sign_00 < 1) { + __string = (int *)((int)__string + 1); + } + else { + *(char *)((int)__string + 1) = '.'; + pcVar5 = (char *)((int)__string + 2); + piVar9 = (int *)((int)__string + (int)sign_00); + do { + *(char *)((int)__string + 2) = '0'; + __string = (int *)((int)__string + 1); + } while (piVar9 != __string); + __string = (int *)(pcVar5 + (int)sign_00); + } + } + else { + pcVar17 = pcVar5; + if ((int)pcStack232 < 1) { + *(char *)__string = '0'; + *(char *)((int)__string + 1) = '.'; + sign_00 = __string; + while ((int *)((int)__string - (int)pcStack232) != sign_00) { + *(char *)((int)sign_00 + 2) = '0'; + sign_00 = (int *)((int)sign_00 + 1); + } + __string = (int *)((int)__string + (2 - (int)pcStack232)); + while (cVar11 = *pcVar5, cVar11 != '\0') { + pcVar5 = pcVar5 + 1; + *(char *)__string = cVar11; + __string = (int *)((int)__string + 1); + } + } + else { + do { + sign_00 = __string; + if (pcStack232 == pcVar17 + -(int)pcVar5) { + sign_00 = (int *)((int)__string + 1); + *(char *)__string = '.'; + } + pcVar8 = pcVar17 + 1; + __string = (int *)((int)sign_00 + 1); + *(char *)sign_00 = *pcVar17; + pcVar17 = pcVar8; + } while (*pcVar8 != '\0'); + } + } + goto LAB_2300327a; + } + __string = (int *)(flags + -1); + } + else { + __string = (int *)flags; + if (uVar10 != 0x65) { + __string = &sign; + sign_00 = (int *)flags; + if (uVar10 != 0x66) goto LAB_2300327a; + goto LAB_230032d2; + } + } + pcVar5 = ecvtbuf(size,(int *)precision,(int *)((int)__string + 1),(char *)&pcStack232); + sign_00 = &sign; + if (decpt != 0) { + sign._0_1_ = 0x2d; + sign_00 = (int *)((int)&sign + 1); + } + pcVar17 = (char *)((int)sign_00 + 1); + *(char *)sign_00 = *pcVar5; + if (0 < (int)__string) { + pcVar17 = (char *)((int)sign_00 + 2); + *(undefined *)((int)sign_00 + 1) = 0x2e; + } + pcVar8 = pcVar5 + 1; + pcVar13 = pcVar17; + while (pcVar5 + 1 + (int)__string != pcVar8) { + *pcVar13 = *pcVar8; + pcVar8 = pcVar8 + 1; + pcVar13 = pcVar13 + 1; + } + pcVar17 = pcVar17 + (int)__string; + cVar11 = 'E'; + if (bVar1) { + cVar11 = 'e'; + } + *pcVar17 = cVar11; + if (pcStack232 == (char *)0x0) { + _Var4 = __eqdf2(); + if (_Var4 != 0) { + pcStack232 = (char *)0xffffffff; + goto LAB_23003238; + } +LAB_2300335e: + cVar11 = '+'; + } + else { + pcStack232 = pcStack232 + -1; + if (-1 < (int)pcStack232) goto LAB_2300335e; +LAB_23003238: + pcStack232 = (char *)-(int)pcStack232; + cVar11 = '-'; + } + pcVar17[1] = cVar11; + pcVar17[4] = (char)((int)pcStack232 % 10) + '0'; + pcVar17[2] = (char)(((int)pcStack232 / 100) % 10) + '0'; + pcVar17[3] = (char)(((int)pcStack232 / 10) % 10) + '0'; + __string = (int *)(pcVar17 + 5); +LAB_2300327a: + *(char *)__string = '\0'; + if ((in_a6 & 0x20) == 0) { + if (in_a5 == 0x67) { + __string = &sign; + do { + bVar2 = *(byte *)__string; + __string = (int *)((int)__string + 1); + if (bVar2 == 0) goto LAB_23003412; + } while (bVar2 != 0x2e); + while ((sign_00 = __string, *(byte *)__string != 0 && ((*(byte *)__string & 0xdf) != 0x45))) { + __string = (int *)((int)__string + 1); + } + do { + piVar9 = sign_00; + sign_00 = (int *)((int)piVar9 + -1); + } while (*(byte *)sign_00 == 0x30); + if (*(byte *)sign_00 == 0x2e) { + sign_00 = (int *)((int)piVar9 + -2); + } + while (__string != sign_00) { + sign_00 = (int *)((int)sign_00 + 1); + *(byte *)sign_00 = 0; + } + } + } + else { + if ((int *)flags == (int *)0x0) { + __string = &sign; + while (bVar2 = *(byte *)__string, bVar2 != 0) { + if (bVar2 == 0x2e) goto LAB_23003412; + if ((bVar2 & 0xdf) == 0x45) { + sVar7 = strnlen((char *)__string,0x100); + puVar6 = (undefined *)(sVar7 + (int)__string); + while (0 < (int)(puVar6 + -(int)__string)) { + puVar6[1] = *puVar6; + puVar6 = puVar6 + -1; + } + *(byte *)__string = 0x2e; + goto LAB_23003412; + } + __string = (int *)((int)__string + 1); + } + *(byte *)__string = 0x2e; + *(byte *)((int)__string + 1) = 0; + } + } +LAB_23003412: + sVar7 = strnlen((char *)&sign,0x100); + iVar3 = iVar3 - sVar7; + pcVar5 = str; + if ((in_a6 & 0x11) == 0) { + while (0 < (int)(str + (iVar3 - (int)pcVar5))) { + *pcVar5 = ' '; + pcVar5 = pcVar5 + 1; + } + iVar14 = iVar3; + if (iVar3 < 0) { + iVar14 = 0; + } + str = str + iVar14; + iVar3 = (iVar3 + -1) - iVar14; + } + if (cVar15 != '\0') { + *str = cVar15; + str = str + 1; + } + pcVar5 = str; + if (uVar12 == 0) { + while (0 < (int)(str + (iVar3 - (int)pcVar5))) { + *pcVar5 = cVar16; + pcVar5 = pcVar5 + 1; + } + iVar14 = iVar3; + if (iVar3 < 0) { + iVar14 = 0; + } + str = str + iVar14; + iVar3 = (iVar3 + -1) - iVar14; + } + iVar14 = 0; + while (iVar14 < (int)sVar7) { + pcVar5 = (char *)((int)&sign + iVar14); + pcVar17 = str + iVar14; + iVar14 = iVar14 + 1; + *pcVar17 = *pcVar5; + } + if ((int)sVar7 < 0) { + sVar7 = 0; + } + str = str + sVar7; + pcVar5 = str; + while (0 < (int)(str + (iVar3 - (int)pcVar5))) { + *pcVar5 = ' '; + pcVar5 = pcVar5 + 1; + } + if (iVar3 < 0) { + iVar3 = 0; + } + return str + iVar3; +} + + + +int vsnprintf(char *buffer,size_t n,char *format,va_list ap) + +{ + char *pcVar1; + size_t n_00; + byte *pbVar2; + int *piVar3; + undefined4 uVar4; + char *pcVar5; + byte bVar6; + uint uVar7; + char **ppcVar8; + int prec; + char *pcVar9; + char *pcVar10; + int iVar11; + uint width; + char *flags; + byte *str; + char *pcVar12; + char *pcStack104; + char *pcStack100; + char *pcStack88; + char acStack65 [4]; + char carg; + + uVar4 = 0; + width = 0; + flags = (char *)0xffffffff; + iVar11 = 0; + pcStack104 = (char *)0x0; + pcStack100 = (char *)0x0; + pcVar5 = (char *)0x0; + str = (byte *)buffer; + pcVar12 = (char *)0x0; +switchD_230035c2_caseD_5: + do { + pbVar2 = (byte *)format; + format = (char *)(pbVar2 + 1); + bVar6 = *pbVar2; + uVar7 = (uint)bVar6; + if (bVar6 == 0) { + if (pcVar5 < n) { + *str = 0; + } + else { + if (n != 0) { + buffer[n - 1] = '\0'; + } + } + return (int)pcVar5; + } + switch(uVar4) { + case 0: + if (bVar6 == 0x25) { + uVar4 = 1; + width = 0; + flags = (char *)0xffffffff; + iVar11 = 0; + pcVar12 = (char *)0x0; + } + else { + if (pcVar5 < n) { + *str = bVar6; + str = str + 1; + } + pcVar5 = pcVar5 + 1; + } + break; + case 1: + switch(uVar7 - 0x20 & 0xff) { + case 0: + width = width | 0x10; + break; + default: + uVar4 = 2; + format = (char *)pbVar2; + break; + case 3: + width = width | 0x20; + break; + case 7: + width = width | 8; + break; + case 0xb: + width = width | 4; + break; + case 0xd: + width = width | 2; + break; + case 0x10: + width = width | 1; + } + break; + case 2: + if ((uVar7 - 0x30 & 0xff) < 10) { + pcVar12 = (char *)((int)pcVar12 * 10 + (uVar7 - 0x30)); + } + else { + if (bVar6 == 0x2a) { + ppcVar8 = (char **)ap + 1; + pcVar12 = *(char **)ap; + ap = ppcVar8; + if ((int)pcVar12 < 0) { + width = width | 2; + pcVar12 = (char *)-(int)pcVar12; + } + } + else { + if (bVar6 == 0x2e) { + uVar4 = 3; + flags = (char *)0x0; + } + else { + uVar4 = 4; + format = (char *)pbVar2; + } + } + } + break; + case 3: + if ((uVar7 - 0x30 & 0xff) < 10) { + flags = (char *)((int)flags * 10 + (uVar7 - 0x30)); + } + else { + if (bVar6 == 0x2a) { + ppcVar8 = (char **)ap + 1; + flags = *(char **)ap; + ap = ppcVar8; + if ((int)flags < 0) { + flags = (char *)0xffffffff; + } + } + else { + uVar4 = 4; + format = (char *)pbVar2; + } + } + break; + case 4: + switch(uVar7 - 0x4c & 0xff) { + case 0: + case 0x25: + iVar11 = iVar11 + 2; + break; + default: + if (2 < iVar11) { + iVar11 = 2; + } + if (iVar11 < -2) { + iVar11 = -2; + } + switch(uVar7 - 0x50 & 0xff) { + case 0: + width = width | 0x80; + goto switchD_2300371e_caseD_20; + default: + if (pcVar5 < n) { + *str = bVar6; + str = str + 1; + } + uVar4 = 0; + pcVar5 = pcVar5 + 1; + goto switchD_230035c2_caseD_5; + case 8: + width = width | 0x80; + prec = 0x10; + break; + case 0x13: + acStack65[0] = (char)*(char **)ap; + pcVar1 = (char *)0x1; + pcStack88 = acStack65; + goto is_string; + case 0x14: + case 0x19: + width = width | 0x40; + // WARNING: Could not find normalized switch variable to match jumptable + switch(iVar11) { + case -2: + pcStack104 = (char *)(int)*(char *)ap; + pcStack100 = (char *)((int)pcStack104 >> 0x1f); + ap = (char **)ap + 1; + prec = 10; + break; + case 0: + pcStack104 = *(char **)ap; + pcStack100 = (char *)((int)pcStack104 >> 0x1f); + ap = (char **)ap + 1; + prec = 10; + break; + case 2: + ppcVar8 = (char **)((int)ap + 7U & 0xfffffff8); + ap = ppcVar8 + 2; + pcStack104 = *ppcVar8; + pcStack100 = ppcVar8[1]; + prec = 10; + break; + default: + prec = 10; + } + goto is_integer; + case 0x16: + piVar3 = (int *)((int)ap + 7U & 0xfffffff8); + str = (byte *)flt((char *)str,*piVar3,piVar3[1],(char)pcVar12,(int)flags); + uVar4 = 0; + ap = piVar3 + 2; + goto switchD_230035c2_caseD_5; + case 0x1e: + if (iVar11 + 2U < 5) { + // WARNING: Could not recover jumptable at 0x2300392e. Too many branches + // WARNING: Treating indirect jump as call + iVar11 = (*(code *)(&PTR_LAB_2306f398)[iVar11 + 2U])((&PTR_LAB_2306f398)[iVar11 + 2U]); + return iVar11; + } + uVar4 = 0; + goto switchD_230035c2_caseD_5; + case 0x1f: + prec = 8; + break; + case 0x20: +switchD_2300371e_caseD_20: + width = width | 0x20; + pcStack104 = *(char **)ap; + pcStack100 = (char *)0x0; + ap = (char **)ap + 1; + prec = 0x10; + flags = &DAT_00000008; + goto is_integer; + case 0x23: + pcStack88 = *(char **)ap; + if (pcStack88 == (char *)0x0) { + pcStack88 = "(null)"; + } + pcVar1 = (char *)strlen(pcStack88); +is_string: + ap = (char **)ap + 1; + if ((flags != (char *)0xffffffff) && ((int)flags < (int)pcVar1)) { + pcVar1 = flags; + } + pcVar9 = pcVar5; + if (((int)pcVar1 < (int)pcVar12) && ((width & 2) == 0)) { + if ((width & 1) == 0) { + bVar6 = 0x20; + } + else { + bVar6 = 0x30; + } + pcVar9 = pcVar12 + (int)(pcVar5 + -(int)pcVar1); + do { + if (pcVar5 < n) { + *str = bVar6; + str = str + 1; + } + pcVar5 = pcVar5 + 1; + pcVar12 = pcVar1; + } while (pcVar5 != pcVar9); + } + pcVar5 = pcVar9; + if (pcVar1 != (char *)0x0) { + pcVar10 = pcVar9; + do { + if (pcVar10 < n) { + *str = pcStack88[(int)(pcVar10 + -(int)pcVar9)]; + str = str + 1; + } + pcVar10 = pcVar10 + 1; + pcVar5 = pcVar1 + (int)pcVar9; + } while (pcVar10 != pcVar1 + (int)pcVar9); + } + if ((int)pcVar1 < (int)pcVar12) { + if ((width & 2) == 0) { + uVar4 = 0; + } + else { + pcVar9 = pcVar5 + -(int)pcVar1; + do { + if (pcVar5 < n) { + *str = 0x20; + str = str + 1; + } + pcVar5 = pcVar5 + 1; + } while (pcVar5 != pcVar12 + (int)pcVar9); + uVar4 = 0; + pcVar5 = pcVar12 + (int)pcVar9; + pcVar12 = pcVar1; + } + } + else { + uVar4 = 0; + } + goto switchD_230035c2_caseD_5; + case 0x25: + prec = 10; + break; + case 0x28: + prec = 0x10; + } + // WARNING: Could not find normalized switch variable to match jumptable + switch(iVar11) { + case -2: + pcStack104 = (char *)(uint)*(byte *)ap; + pcStack100 = (char *)0x0; + ap = (char **)ap + 1; + break; + case 0: + pcStack104 = *(char **)ap; + pcStack100 = (char *)0x0; + ap = (char **)ap + 1; + break; + case 2: + ppcVar8 = (char **)((int)ap + 7U & 0xfffffff8); + ap = ppcVar8 + 2; + pcStack104 = *ppcVar8; + pcStack100 = ppcVar8[1]; + } +is_integer: + if (pcVar5 < n) { + n_00 = n - (int)pcVar5; + } + else { + n_00 = 0; + } + n_00 = format_int((char *)str,n_00,(uint)pcStack104,(int)pcStack100,width,prec); + str = str + n_00; + uVar4 = 0; + pcVar5 = pcVar5 + n_00; + break; + case 0x1c: + iVar11 = iVar11 + -1; + break; + case 0x1e: + iVar11 = 2; + break; + case 0x20: + iVar11 = iVar11 + 1; + break; + case 0x28: + case 0x2e: + iVar11 = 1; + } + } + } while( true ); +} + + + +int vsprintf(char *buffer,char *format,va_list ap) + +{ + int iVar1; + + iVar1 = vsnprintf(buffer,0x1e0,format,ap); + return iVar1; +} + + + +void vprint(char *fmt,va_list argp) + +{ + uint8_t *puVar1; + int iVar2; + + if (sys_log_all_enable == false) { + return; + } + iVar2 = vsprintf(string,fmt,argp); + puVar1 = (uint8_t *)string; + if (0 < iVar2) { + while( true ) { + if (*puVar1 == '\0') break; + bl_uart_data_send('\0',*puVar1); + puVar1 = puVar1 + 1; + } + } + return; +} + + + +int bl_putchar(int c) + +{ + bl_uart_data_send('\0',(uint8_t)c); + return 0; +} + + + +int puts(char *s) + +{ + int iVar1; + + iVar1 = 0; + if (sys_log_all_enable != false) { + iVar1 = 0; + while (s[iVar1] != '\0') { + bl_uart_data_send('\0',s[iVar1]); + iVar1 = iVar1 + 1; + } + } + return iVar1; +} + + + +int printf(char *fmt,...) + +{ + undefined4 in_a1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list argp; + undefined4 uStack28; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + if (sys_log_all_enable != false) { + uStack28 = in_a1; + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + vprint(fmt,&uStack28); + } + return 0; +} + + + +int sprintf(char *buffer,char *format,...) + +{ + int iVar1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list ap; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + iVar1 = vsnprintf(buffer,0xffffffff,format,&uStack24); + return iVar1; +} + + + +int snprintf(char *buffer,size_t n,char *format,...) + +{ + int iVar1; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list ap; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + iVar1 = vsnprintf(buffer,n,format,&uStack20); + return iVar1; +} + + + +_Bool stateSnifferGuard(void *ch,event *event) + +{ + return (_Bool)(ch == (void *)(uint)*(byte *)event->data); +} + + + +_Bool stateConnectedIPYesGuard_ip_update(void *ch,event *event) + +{ + return (_Bool)(ch == (void *)(uint)*(byte *)event->data); +} + + + +void printErrMsg(void *stateData,event *event) + +{ + printf("ENTERED ERROR STATE!"); + return; +} + + + +void stateSnifferExit(void *stateData,event *event) + +{ + printf("[WF][SM] Exiting %s state\r\n",stateData); + return; +} + + + +void stateSnifferAction(void *oldStateData,event *event,void *newStateData) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n",oldStateData); + return; +} + + + +void stateConnectedIPNoAction_ipgot(void *oldStateData,event *event,void *newStateData) + +{ + uint *puVar1; + uint *puVar2; + uint uVar3; + uint uVar4; + + puVar1 = (uint *)((int)event->data + 0xd); + puVar2 = (uint *)((int)event->data + 0x11); + uVar4 = *puVar1; + uVar3 = *puVar2; + printf( + "[WF][SM] IP GOT IP:%u.%u.%u.%u, MASK: %u.%u.%u.%u, Gateway: %u.%u.%u.%u, dns1: %u.%u.%u.%u, dns2: %u.%u.%u.%u\r\n" + ,uVar4 & 0xff,uVar4 >> 8 & 0xff,(uint)(*(uint3 *)puVar1 >> 0x10),uVar4 >> 0x18,uVar3 & 0xff + ,uVar3 >> 8 & 0xff,(uint)(*(uint3 *)puVar2 >> 0x10)); + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n",oldStateData,newStateData); + return; +} + + + +void stateGlobalEnter(void *stateData,event *event) + +{ + printf("[WF][SM] Entering %s state\r\n",stateData); + return; +} + + + +void stateGlobalAction(void *oldStateData,event *event,void *newStateData) + +{ + printf("[WF][SM] Global Action\r\n"); + return; +} + + + +void stateConnectingEnter(void *stateData,event *event) + +{ + printf("[WF][SM] Entering %s state\r\n",stateData); + aos_post_event(2,8,0); + return; +} + + + +_Bool stateSnifferGuard_ChannelSet(void *ch,event *event) + +{ + byte *pbVar1; + + pbVar1 = (byte *)event->data; + if (ch == (void *)(uint)*pbVar1) { + bl_main_monitor_channel_set(*(int *)(pbVar1 + 1),*(int *)(pbVar1 + 5)); + return false; + } + return false; +} + + + +_Bool stateIdleGuard_sniffer(void *ev,event *event) + +{ + if (ev == (void *)(uint)*(byte *)event->data) { + bl_main_monitor(); + return true; + } + return false; +} + + + +void stateConnectedIPNoExit(void *stateData,event *event) + +{ + printf("[WF][SM] Exiting %s state\r\n",stateData); + xTimerGenericCommand((TimerHandle_t)((int)stateData + 0x20),3,0,(BaseType_t *)0x0,0); + xTimerGenericCommand((TimerHandle_t)((int)stateData + 0x20),5,0,(BaseType_t *)0x0,0); + return; +} + + + +void stateDisconnect_action_idle(void *oldStateData,event *event,void *newStateData) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n",oldStateData); + printf("[WF][SM] Removing STA interface...\r\n"); + bl_main_if_remove(wifiMgmr.wlan_sta.vif_index); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void stateDisconnect_action_reconnect(void *oldStateData,event *event,void *newStateData) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n",oldStateData); + printf("[WF][SM] Action Connect\r\n"); + printf(" ssid %s\r\n",(uint8_t *)((int)oldStateData + 0x4d)); + printf(" ssid len %u\r\n",*(undefined4 *)((int)oldStateData + 0x6e)); + printf(" psk %s\r\n",(uint8_t *)((int)oldStateData + 0x72)); + printf(" psk len %u\r\n",*(undefined4 *)((int)oldStateData + 0xf4)); + printf(" pmk %s\r\n",(uint8_t *)((int)oldStateData + 0xb3)); + printf(" pmk len %u\r\n",*(undefined4 *)((int)oldStateData + 0xf8)); + printf(" mac %02X:%02X:%02X:%02X:%02X:%02X\r\n", + (uint)*(byte *)((int)oldStateData + 0x101),(uint)*(byte *)((int)oldStateData + 0x100), + (uint)*(byte *)((int)oldStateData + 0xff),(uint)*(byte *)((int)oldStateData + 0xfe), + (uint)*(byte *)((int)oldStateData + 0xfd),(uint)*(byte *)((int)oldStateData + 0xfc)); + bl_main_connect((uint8_t *)((int)oldStateData + 0x4d),*(int *)((int)oldStateData + 0x6e), + (uint8_t *)((int)oldStateData + 0x72),*(int *)((int)oldStateData + 0xf4), + (uint8_t *)((int)oldStateData + 0xb3),*(int *)((int)oldStateData + 0xf8), + (uint8_t *)((int)oldStateData + 0xfc),'\0',_DAT_00000010); + aos_post_event(2,3,0); + return; +} + + + +void ip_obtaining_timeout(timer_cb_arg_t data) + +{ + pvTimerGetTimerID((TimerHandle_t)data); + printf("[WF][SM] IP obtaining timeout\r\n"); + wifi_mgmr_api_fw_disconnect(); + return; +} + + + +void stateConnectedIPNoEnter(void *stateData,event *event) + +{ + uint32_t uVar1; + uint32_t uVar2; + uint32_t uVar3; + uint32_t uVar4; + uint32_t uVar5; + TickType_t xOptionalValue; + ip4_addr_t iStack44; + ip4_addr_t addr_ipaddr; + ip4_addr_t addr_netmask; + ip4_addr_t addr_gw; + + printf("[WF][SM] Entering %s state\r\n",stateData); + xTimerCreateStatic("wifi IP obtaining",15000,0,stateData,ip_obtaining_timeout, + (StaticTimer_t *)(TimerHandle_t)((int)stateData + 0x20)); + xOptionalValue = xTaskGetTickCount(); + xTimerGenericCommand + ((TimerHandle_t)((int)stateData + 0x20),1,xOptionalValue,(BaseType_t *)0x0,0xffffffff); + vTaskEnterCritical(); + uVar5 = wifiMgmr.wlan_sta.ipv4.dns2; + uVar4 = wifiMgmr.wlan_sta.ipv4.dns1; + uVar3 = wifiMgmr.wlan_sta.ipv4.gw; + uVar2 = wifiMgmr.wlan_sta.ipv4.mask; + uVar1 = wifiMgmr.wlan_sta.ipv4.ip; + vTaskExitCritical(); + if (uVar1 == 0) { + printf("[WF][SM] DHCP Starting...%p\r\n",0x42016fc8); + wifi_netif_dhcp_start(&wifiMgmr.wlan_sta.netif); + } + else { + printf("[WF][SM] Static IP Starting...%p\r\n",0x42016fc8); + iStack44 = (ip_addr_t)uVar4; + dns_setserver('\0',(ip_addr_t *)&iStack44); + iStack44 = (ip_addr_t)uVar5; + dns_setserver('\x01',(ip_addr_t *)&iStack44); + iStack44 = (ip_addr_t)uVar1; + addr_ipaddr = uVar2; + addr_netmask = uVar3; + netifapi_netif_common(&wifiMgmr.wlan_sta.netif,dhcp_stop,(netifapi_errt_fn)0x0); + netifapi_netif_set_addr(&wifiMgmr.wlan_sta.netif,&iStack44,&addr_ipaddr,&addr_netmask); + } + aos_post_event(2,4,0); + return; +} + + + +_Bool stateConnectedIPNoGuard_disconnect(void *ch,event *event) + +{ + if (ch == (void *)(uint)*(byte *)event->data) { + bl_main_disconnect(); + return false; + } + return false; +} + + + +_Bool stateConnectedIPYesGuard_disconnect(void *ch,event *event) + +{ + if (ch == (void *)(uint)*(byte *)event->data) { + bl_main_disconnect(); + return false; + } + return false; +} + + + +_Bool stateConnectedIPYesGuard_rcconfig(void *ch,event *event) + +{ + byte *pbVar1; + + pbVar1 = (byte *)event->data; + if (ch == (void *)(uint)*pbVar1) { + printf("[WF][SM] rate config, use sta_idx 0, rate_config %04X\r\n",*(undefined4 *)(pbVar1 + 1)); + bl_main_rate_config('\0',*(uint16_t *)(pbVar1 + 1)); + } + return false; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void stateIdleAction_connect(void *oldStateData,event *event,void *newStateData) + +{ + void *pvVar1; + wifi_mgmr_profile_msg_t *profile_msg; + char *pcVar2; + + pvVar1 = event->data; + *(undefined *)((int)pvVar1 + 0x2d) = 0; + *(undefined *)((int)pvVar1 + 0x72) = 0; + printf("[WF][SM] Action Connect\r\n"); + profile_msg = (wifi_mgmr_profile_msg_t *)((int)pvVar1 + 0xd); + printf(" ssid %s\r\n",profile_msg); + printf(" ssid len %u\r\n",*(undefined4 *)((int)pvVar1 + 0x2e)); + printf(" psk %s\r\n",(uint8_t *)((int)pvVar1 + 0x32)); + printf(" psk len %u\r\n",*(undefined4 *)((int)pvVar1 + 0xb4)); + printf(" pmk %s\r\n",(uint8_t *)((int)pvVar1 + 0x73)); + printf(" pmk len %u\r\n",*(undefined4 *)((int)pvVar1 + 0xb8)); + printf(" channel band %d\r\n",(uint)*(byte *)((int)pvVar1 + 0xc2)); + printf(" channel freq %d\r\n",(uint)*(ushort *)((int)pvVar1 + 0xc3)); + printf(" mac %02X:%02X:%02X:%02X:%02X:%02X\r\n",(uint)*(byte *)((int)pvVar1 + 0xc1), + (uint)*(byte *)((int)pvVar1 + 0xc0),(uint)*(byte *)((int)pvVar1 + 0xbf), + (uint)*(byte *)((int)pvVar1 + 0xbe),(uint)*(byte *)((int)pvVar1 + 0xbd), + (uint)*(byte *)((int)pvVar1 + 0xbc)); + if (*(char *)((int)pvVar1 + 0xc5) == '\0') { + pcVar2 = "false"; + } + else { + pcVar2 = "true"; + } + printf(" dhcp status: %s\r\n",pcVar2); + wifi_mgmr_profile_add(&wifiMgmr,profile_msg,-1); + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n",oldStateData,newStateData); + bl_main_connect((uint8_t *)profile_msg,*(int *)((int)pvVar1 + 0x2e), + (uint8_t *)((int)pvVar1 + 0x32),*(int *)((int)pvVar1 + 0xb4), + (uint8_t *)((int)pvVar1 + 0x73),*(int *)((int)pvVar1 + 0xb8), + (uint8_t *)((int)pvVar1 + 0xbc),*(uint8_t *)((int)pvVar1 + 0xc2),_DAT_00000010); + return; +} + + + +_Bool stateGlobal_cfg_req(void *ch,event *event) + +{ + char *pcVar1; + + pcVar1 = (char *)event->data; + if (*pcVar1 == '\x16') { + bl_main_cfg_task_req + (*(uint32_t *)(pcVar1 + 0xd),*(uint32_t *)(pcVar1 + 0x11),*(uint32_t *)(pcVar1 + 0x15) + ,*(uint32_t *)(pcVar1 + 0x19),pcVar1 + 0x21,(void *)0x0); + return false; + } + return false; +} + + + +_Bool stateGlobalGuard_fw_powersaving(void *ch,event *event) + +{ + char *pcVar1; + + pcVar1 = (char *)event->data; + if (*pcVar1 == '\x10') { + printf("------>>>>>> Powersaving CMD, mode: %u\r\n",*(undefined4 *)(pcVar1 + 1)); + bl_main_powersaving(*(int *)(pcVar1 + 1)); + } + return false; +} + + + +_Bool stateGlobalGuard_conf_max_sta(void *ev,event *event) + +{ + char *pcVar1; + + pcVar1 = (char *)event->data; + if (*pcVar1 == '\n') { + printf("[WF][SM] Conf max sta supported %lu...\r\n",*(undefined4 *)(pcVar1 + 1)); + bl_main_conf_max_sta(pcVar1[1]); + } + return false; +} + + + +_Bool stateGlobalGuard_AP(void *ev,event *event) + +{ + char "stateGlobalGuard_AP" [20]; + char *pcVar1; + int iVar2; + + pcVar1 = (char *)event->data; + if (*pcVar1 == '\b') { + iVar2 = bl_main_if_add(0,&wifiMgmr.wlan_ap.netif,&wifiMgmr.wlan_ap.vif_index); + if (iVar2 == 0) { + netifapi_netif_common(&wifiMgmr.wlan_ap.netif,netif_set_link_up,(netifapi_errt_fn)0x0); + netifapi_netif_common(&wifiMgmr.wlan_ap.netif,dhcpd_start,(netifapi_errt_fn)0x0); + printf("[WF][SM] start AP with ssid %s;\r\n",pcVar1 + 0x11); + printf("[WF][SM] pwd %s;\r\n",pcVar1 + 0x37); + printf("[WF][SM] channel %ld;\r\n",*(undefined4 *)(pcVar1 + 0xd)); + bl_main_apm_start(pcVar1 + 0x11,pcVar1 + 0x37,*(int *)(pcVar1 + 0xd), + wifiMgmr.wlan_ap.vif_index,pcVar1[0x32]); + wifiMgmr.inf_ap_enabled = 1; + dns_server_init(); + aos_post_event(2,0xb,0); + } + else { + printf("[WF][SM] %s: add AP iface failed\r\n","stateGlobalGuard_AP"); + } + } + return false; +} + + + +_Bool stateGlobalGuard_scan_beacon(void *ch,event *event) + +{ + byte bVar1; + bool bVar2; + byte *pbVar3; + int iVar4; + int iVar5; + TickType_t TVar6; + size_t sVar7; + int iVar8; + int iVar9; + TickType_t TVar10; + uint32_t uVar11; + wifi_mgmr_t *pwVar12; + int iVar13; + wifi_mgmr_scan_item_t *__s; + uint32_t uVar14; + + pbVar3 = (byte *)event->data; + if (ch == (void *)(uint)*pbVar3) { + pwVar12 = &wifiMgmr; + if ((((int)(uint)pbVar3[0x3b] <= wifiMgmr.channel_nums) && (pbVar3[0x3b] != 0)) && + ((pbVar3[0xd] != 0 || ((wifiMgmr.features & 1) != 0)))) { + TVar6 = xTaskGetTickCount(); + bVar2 = false; + uVar14 = 0xffffffff; + iVar4 = -1; + iVar13 = 0; + iVar9 = -1; + do { + iVar5 = iVar13; + if (wifiMgmr.channel_nums < (int)(uint)pwVar12->scan_items[0].channel) { + memset(pwVar12->scan_items,0,0x3c); + pwVar12->scan_items[0].is_used = '\0'; + } + else { + if (pwVar12->scan_items[0].is_used != '\0') { + uVar11 = pwVar12->scan_items[0].timestamp_lastseen; + if ((!bVar2) || ((int)(uVar11 - uVar14) < 0)) { + iVar4 = iVar13; + uVar14 = uVar11; + } + iVar8 = memcmp(pwVar12->scan_items[0].bssid,pbVar3 + 0x35,6); + iVar5 = iVar9; + bVar2 = true; + if ((iVar8 == 0) && + (iVar9 = strcmp((char *)(pbVar3 + 0xd),(char *)pwVar12->scan_items), bVar2 = true, + iVar9 == 0)) { + if (((char)pbVar3[0x3c] < wifiMgmr.scan_items[iVar13].rssi) && + (TVar10 = xTaskGetTickCount(), + (int)(TVar10 - wifiMgmr.scan_items[iVar13].timestamp_lastseen) < 3000)) { + return false; + } + wifiMgmr.scan_items[iVar13].channel = pbVar3[0x3b]; + wifiMgmr.scan_items[iVar13].rssi = pbVar3[0x3c]; + wifiMgmr.scan_items[iVar13].ppm_abs = pbVar3[0x3d]; + bVar1 = pbVar3[0x3e]; + wifiMgmr.scan_items[iVar13].timestamp_lastseen = TVar6; + wifiMgmr.scan_items[iVar13].ppm_rel = bVar1; + wifiMgmr.scan_items[iVar13].auth = pbVar3[0x3f]; + wifiMgmr.scan_items[iVar13].cipher = pbVar3[0x40]; + return false; + } + } + } + iVar13 = iVar13 + 1; + pwVar12 = (wifi_mgmr_t *)&(pwVar12->wlan_sta).netif.input; + iVar9 = iVar5; + } while (iVar13 != 0x32); + if ((iVar5 != -1) || (iVar5 = iVar4, iVar4 != -1)) { + __s = wifiMgmr.scan_items + iVar5; + memset(__s,0,0x3c); + strncpy((char *)__s,(char *)(pbVar3 + 0xd),0x20); + wifiMgmr.scan_items[iVar5].ssid_tail[0] = '\0'; + sVar7 = strlen((char *)__s); + wifiMgmr.scan_items[iVar5].ssid_len = sVar7; + memcpy(wifiMgmr.scan_items[iVar5].bssid,pbVar3 + 0x35,6); + wifiMgmr.scan_items[iVar5].channel = pbVar3[0x3b]; + bVar1 = pbVar3[0x3c]; + wifiMgmr.scan_items[iVar5].timestamp_lastseen = TVar6; + wifiMgmr.scan_items[iVar5].rssi = bVar1; + wifiMgmr.scan_items[iVar5].auth = pbVar3[0x3f]; + wifiMgmr.scan_items[iVar5].cipher = pbVar3[0x40]; + wifiMgmr.scan_items[iVar5].is_used = '\x01'; + } + } + } + return false; +} + + + +void __reload_tsen(timer_cb_arg_t data) + +{ + pvTimerGetTimerID((TimerHandle_t)data); + wifi_mgmr_api_fw_tsen_reload(); + return; +} + + + +void event_cb_wifi_event_mgmr(input_event_t *event,void *private_data) + +{ + if (event->code == 0x14) { + aos_post_delayed_action(0x55,trigger_auto_denoise,(void *)0x0); + return; + } + return; +} + + + +void trigger_auto_denoise(void *arg) + +{ + if (auto_repeat != 0) { + wifi_mgmr_api_denoise_enable(); + aos_post_delayed_action(0x55,trigger_auto_denoise,(void *)0x0); + return; + } + return; +} + + + +void stateDisconnect_exit(void *stateData,event *event) + +{ + printf("[WF][SM] Exiting %s state\r\n",stateData); + if (*(char *)((int)stateData + 0x4c) != '\0') { + printf("Delete Timer.\r\n"); + xTimerGenericCommand((TimerHandle_t)((int)stateData + 0x20),3,0,(BaseType_t *)0x0,0); + xTimerGenericCommand((TimerHandle_t)((int)stateData + 0x20),5,0,(BaseType_t *)0x0,0); + *(undefined *)((int)stateData + 0x4c) = 0; + return; + } + printf("Delete Timer Skipped\r\n"); + return; +} + + + +void disconnect_retry(timer_cb_arg_t data) + +{ + void *pvVar1; + int iVar2; + + pvVar1 = pvTimerGetTimerID((TimerHandle_t)data); + iVar2 = wifi_mgmr_profile_get(&wifiMgmr,(wifi_mgmr_profile_msg_t *)((int)pvVar1 + 0x4d)); + if (iVar2 != 0) { + printf("[WF][SM] Retry Again --->>> retry Abort, since profile copy failed\r\n"); + return; + } + printf("[WF][SM] Retry Again --->>> retry connect\r\n"); + wifi_mgmr_api_reconnect(); + return; +} + + + +_Bool stateGlobalGuard_fw_disconnect(void *ch,event *event) + +{ + if (*(char *)event->data == '\x0f') { + printf("Disconnect CMD\r\n"); + bl_main_disconnect(); + return false; + } + return false; +} + + + +void stateConnectedIPYes_exit(void *stateData,event *event) + +{ + ip4_addr_t iStack20; + ip4_addr_t addr_ipaddr; + + iStack20 = (ip4_addr_t)0x0; + printf("[WF][SM] Exiting %s state\r\n",stateData); + netifapi_netif_common(&wifiMgmr.wlan_sta.netif,dhcp_stop,(netifapi_errt_fn)0x0); + netifapi_netif_set_addr(&wifiMgmr.wlan_sta.netif,&iStack20,&iStack20,&iStack20); + if (auto_repeat != 0) { + auto_repeat = 0; + bl_main_denoise(0); + } + return; +} + + + +_Bool stateGlobalGuard_denoise(void *ev,event *event) + +{ + int mode; + + if (*(char *)event->data != '\f') { + return false; + } + if (*(int *)(event->data + 1) == 0) { + auto_repeat = 0; + mode = 0; + } + else { + if (wifiMgmr.m.currentState != &stateConnectedIPYes) { + return false; + } + mode = 3; + if (auto_repeat == 0) { + auto_repeat = 1; + bl_main_denoise(1); + aos_post_event(2,0x14,0); + return false; + } + } + bl_main_denoise(mode); + return false; +} + + + +_Bool stateIdleGuard_connect(void *ev,event *event) + +{ + int iVar1; + + if (ev == (void *)(uint)*(byte *)event->data) { + iVar1 = bl_main_if_add(1,&wifiMgmr.wlan_sta.netif,&wifiMgmr.wlan_sta.vif_index); + if (iVar1 != 0) { + printf("[WF][SM] %s: add STA iface failed\r\n","stateIdleGuard_connect"); + } + return (_Bool)(iVar1 == 0); + } + return false; +} + + + +_Bool stateIfaceDownGuard_phyup(void *ev,event *event) + +{ + bool bVar1; + int iVar2; + + if (ev == (void *)(uint)*(byte *)event->data) { + iVar2 = bl_main_phy_up(); + bVar1 = iVar2 == 0; + } + else { + printf("[WF][SM] state mismatch\r\n"); + bVar1 = false; + } + return (_Bool)bVar1; +} + + + +_Bool stateSnifferGuard_raw_send(void *ch,event *event) + +{ + char *pcVar1; + + if (((wifiMgmr.m.currentState != &stateIdle) && (wifiMgmr.m.currentState != &stateIfaceDown)) && + (pcVar1 = (char *)event->data, *pcVar1 == '\x15')) { + bl_main_raw_send(*(uint8_t **)(pcVar1 + 1),*(int *)(pcVar1 + 5)); + return false; + } + return false; +} + + + +_Bool stateGlobalGuard_stop(void *ev,event *event) + +{ + if (*(char *)event->data == '\t') { + printf("[WF][SM] Stoping AP interface...\r\n"); + bl_main_apm_stop(wifiMgmr.wlan_ap.vif_index); + printf("[WF][SM] Removing and deauth all sta client...\r\n"); + bl_main_apm_remove_all_sta(); + printf("[WF][SM] Removing AP interface...\r\n"); + bl_main_if_remove(wifiMgmr.wlan_ap.vif_index); + printf("[WF][SM] Stopping DHCP on AP interface...\r\n"); + netifapi_netif_common(&wifiMgmr.wlan_ap.netif,(netifapi_void_fn)0x0,dhcp_server_stop); + printf("[WF][SM] Removing ETH interface ...\r\n"); + netifapi_netif_common(&wifiMgmr.wlan_ap.netif,netif_remove,(netifapi_errt_fn)0x0); + wifiMgmr.inf_ap_enabled = 0; + aos_post_event(2,0xc,0); + return false; + } + return false; +} + + + +_Bool stateGlobalGuard_enable_autoreconnect(void *ch,event *event) + +{ + if (ch == (void *)(uint)*(byte *)event->data) { + printf("Enable Auto Reconnect\r\n"); + wifi_mgmr_profile_autoreconnect_enable(&wifiMgmr,-1); + return false; + } + return false; +} + + + +_Bool stateGlobalGuard_disable_autoreconnect(void *ch,event *event) + +{ + bool bVar1; + + if (ch == (void *)(uint)*(byte *)event->data) { + bVar1 = wifiMgmr.m.currentState != &stateDisconnect; + if (bVar1) { + printf("Disable Auto Reconnect\r\n"); + wifi_mgmr_profile_autoreconnect_disable(&wifiMgmr,-1); + } + else { + printf("Disable Autoreconnect in Disconnec State\r\n"); + printf("[WF][SM] Removing STA interface...\r\n"); + bl_main_if_remove(wifiMgmr.wlan_sta.vif_index); + } + return (_Bool)!bVar1; + } + return false; +} + + + +// WARNING: Variable defined which should be unmapped: is_ok + +void stateDisconnect_enter(void *stateData,event *event) + +{ + int iVar1; + TickType_t xOptionalValue; + uint uVar2; + uint uStack20; + int is_ok; + + uStack20 = 0; + printf("[WF][SM] Entering %s state\r\n",stateData); + iVar1 = wifi_mgmr_profile_autoreconnect_is_enabled(&wifiMgmr,-1); + if (iVar1 == 0) { + printf("[WF][SM] Will NOT retry connect\r\n"); + } + else { + xTimerCreateStatic("wifi disconnect",2000,0,stateData,disconnect_retry, + (StaticTimer_t *)(TimerHandle_t)((int)stateData + 0x20)); + printf("[WF][SM] Will retry in 2000 ticks\r\n"); + xOptionalValue = xTaskGetTickCount(); + xTimerGenericCommand + ((TimerHandle_t)((int)stateData + 0x20),1,xOptionalValue,(BaseType_t *)0x0,0xffffffff) + ; + *(undefined *)((int)stateData + 0x4c) = 1; + } + aos_post_event(2,5,(uint)wifiMgmr.wifi_mgmr_stat_info.status_code); + uVar2 = bl60x_check_mac_status((int *)&uStack20); + if ((uVar2 | uStack20) == 0) { + aos_post_event(2,0x17,0); + helper_record_dump(); + } + if ((wifiMgmr.pending_task & 1) != 0) { + printf("[WF][SM] Pending Scan Sent\r\n"); + bl_main_scan(); + wifiMgmr.pending_task = wifiMgmr.pending_task & 0xfffffffe; + } + return; +} + + + +_Bool stateGlobalGuard_fw_scan(void *ch,event *event) + +{ + if (*(char *)event->data == '\x12') { + if (((wifiMgmr.m.currentState == &stateConnecting) || + (wifiMgmr.m.currentState == &stateConnectedIPNo)) || + (wifiMgmr.m.currentState == &stateDisconnect)) { + printf("------>>>>>> Scan CMD Pending\r\n"); + wifiMgmr.pending_task = wifiMgmr.pending_task | 1; + } + else { + if (((wifiMgmr.m.currentState == &stateIdle) || + (wifiMgmr.m.currentState == &stateConnectedIPYes)) || + (wifiMgmr.m.currentState == &stateSniffer)) { + printf("------>>>>>> Scan CMD\r\n"); + bl_main_scan(); + } + else { + printf("------>>>>>> FW busy\r\n"); + aos_post_event(2,9,1); + } + } + return false; + } + return false; +} + + + +uint stateDisconnect_guard(uint param_1,int param_2) + +{ + return (uint)(param_1 == (uint)**(byte **)(param_2 + 4)); +} + + + +void stateGlobalExit(void) + +{ + printf("[WF][SM] Entering %s state\r\n"); + return; +} + + + +void stateSnifferEnter(void) + +{ + printf("[WF][SM] Entering %s state\r\n"); + return; +} + + + +uint stateConnectingGuard(uint param_1,int param_2) + +{ + return (uint)(param_1 == (uint)**(byte **)(param_2 + 4)); +} + + + +void stateConnectingAction_connected(void) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n"); + return; +} + + + +void stateConnectingAction_disconnect(void) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n"); + return; +} + + + +void stateConnectingExit(void) + +{ + printf("[WF][SM] Exiting %s state\r\n"); + return; +} + + + +void stateIdleAction_sniffer(void) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n"); + return; +} + + + +void stateIdleEnter(void) + +{ + printf("[WF][SM] Entering %s state\r\n"); + return; +} + + + +void stateIdleExit(void) + +{ + printf("[WF][SM] Entering %s state\r\n"); + return; +} + + + +void stateIfaceDownAction_phyup(void) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n"); + return; +} + + + +void stateIfaceDownEnter(void) + +{ + printf("[WF][SM] Entering %s state\r\n"); + return; +} + + + +void stateIfaceDownExit(void) + +{ + printf("[WF][SM] Exiting %s state\r\n"); + return; +} + + + +uint stateConnectedIPNoGuard(uint param_1,int param_2) + +{ + return (uint)(param_1 == (uint)**(byte **)(param_2 + 4)); +} + + + +void stateConnectedIPNoAction_disconnect(void) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n"); + return; +} + + + +uint stateConnectedIPYesGuard(uint param_1,int param_2) + +{ + return (uint)(param_1 == (uint)**(byte **)(param_2 + 4)); +} + + + +void stateConnectedIPYes_action(void) + +{ + printf("[WF][SM] State Action ###%s### --->>> ###%s###\r\n"); + return; +} + + + +void stateConnectedIPYes_enter(void *stateData,event *event) + +{ + printf("[WF][SM] Entering %s state\r\n",stateData); + aos_post_event(2,7,0); + if ((wifiMgmr.pending_task & 1) != 0) { + printf("[WF][SM] Pending Scan Sent\r\n"); + bl_main_scan(); + wifiMgmr.pending_task = wifiMgmr.pending_task & 0xfffffffe; + } + return; +} + + + +char * wifi_mgmr_auth_to_str(uint8_t auth) + +{ + undefined3 in_register_00002029; + + switch(CONCAT31(in_register_00002029,auth)) { + case 0: + return "Open"; + case 1: + return "WEP"; + case 2: + return "WPA-PSK"; + case 3: + return "WPA2-PSK"; + case 4: + return "WPA2-PSK/WPA-PSK"; + case 5: + return "WPA/WPA2-Enterprise"; + default: + return "Unknown"; + } +} + + + +char * wifi_mgmr_cipher_to_str(uint8_t cipher) + +{ + undefined3 in_register_00002029; + int iVar1; + + iVar1 = CONCAT31(in_register_00002029,cipher); + if (iVar1 == 0) { + return "NONE"; + } + if (iVar1 == 1) { + return "WEP"; + } + if (iVar1 == 2) { + return "AES"; + } + if (iVar1 != 3) { + if (iVar1 != 4) { + return "Unknown"; + } + return "TKIP/AES"; + } + return "TKIP"; +} + + + +int wifi_mgmr_event_notify(wifi_mgmr_msg_t *msg) + +{ + size_t sVar1; + int iVar2; + + while (wifiMgmr.ready == '\0') { + printf("Wait Wi-Fi Mgmr Start up...\r\n"); + vTaskDelay(0x14); + } + sVar1 = xStreamBufferSend((StreamBufferHandle_t)&wifiMgmr.mq,msg,msg->len,0xffffffff); + iVar2 = 0; + if (sVar1 == 0) { + printf("Failed when send msg 0x%p, len dec:%u\r\n",msg,msg->len); + iVar2 = -1; + } + return iVar2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void wifi_mgmr_start(void) + +{ + TickType_t xOptionalValue; + size_t sVar1; + void *pvRxData; + int16_t iStack274; + int16_t temp; + int iStack272; + event ev; + uint8_t buffer [232]; + + pvRxData = (void *)((int)&ev.data + 1); + iStack272 = 1; + ev.type = (int)pvRxData; + stateM_init(&wifiMgmr.m,&stateIfaceDown,&stateError); + wifi_mgmr_event_init(); + aos_register_event_filter(2,event_cb_wifi_event_mgmr,(void *)0x0); + aos_post_event(2,2,0); + hal_sys_capcode_update(-1,-1); + printf("[WF][SM] reload tsen \r\n"); + xTimerCreateStatic("wifi reload tsen",10000,1,&state_tsen_reload_data,__reload_tsen, + (StaticTimer_t *)&state_tsen_reload_data.timer); + xOptionalValue = xTaskGetTickCount(); + xTimerGenericCommand + ((TimerHandle_t)&state_tsen_reload_data.timer,1,xOptionalValue,(BaseType_t *)0x0, + 0xffffffff); + do { + while( true ) { + do { + sVar1 = xStreamBufferReceive((StreamBufferHandle_t)&wifiMgmr.mq,pvRxData,0xe0,0xffffffff); + } while (sVar1 == 0); + if (ev.data._1_1_ != 0xd) break; + iStack274 = 0; + if ((((wifiMgmr.m.currentState == &stateConnecting) || + (wifiMgmr.m.currentState == &stateDisconnect)) || + (wifiMgmr.m.currentState == &stateConnectedIPYes)) || + ((wifiMgmr.m.currentState == &stateSniffer || + (wifiMgmr.m.currentState == &stateConnectedIPNo)))) { + bl_tsen_adc_get(&iStack274,0); + phy_tcal_callback(iStack274); + } + } + iStack272 = 1; + if (0xd < ev.data._1_1_) { + iStack272 = (uint)(0x16 < ev.data._1_1_) << 1; + } + stateM_handleEvent(&wifiMgmr.m,(event *)&stack0xfffffef0); + } while( true ); +} + + + +void _wifi_mgmr_entry(void *pvParameters) + +{ + wifi_conf_t *conf; + TaskHandle_t aptStack36 [4]; + code *pcStack20; + + pcStack20 = wifi_mgmr_start_background; + conf = (wifi_conf_t *)wifi_mgmr_start(); + wifi_mgmr_drv_init(conf); + aptStack36[0] = (TaskHandle_t)0x0; + xTaskCreate(_wifi_mgmr_entry,"wifi_mgmr",0x300,(void *)0x0,0x1c,aptStack36); + return; +} + + + +void wifi_mgmr_start_background(wifi_conf_t *conf) + +{ + TaskHandle_t ptStack20; + TaskHandle_t xHandle; + + wifi_mgmr_drv_init(conf); + ptStack20 = (TaskHandle_t)0x0; + xTaskCreate(_wifi_mgmr_entry,"wifi_mgmr",0x300,(void *)0x0,0x1c,&ptStack20); + return; +} + + + +int wifi_mgmr_init(void) + +{ + StreamBufferHandle_t pSVar1; + + pSVar1 = xStreamBufferGenericCreateStatic + (0x8c0,0,1,wifiMgmr.mq_pool,(StaticStreamBuffer_t *)&wifiMgmr.mq); + wifiMgmr.ready = '\x01'; + wifiMgmr.scan_item_timeout = 15000; + return (uint)(pSVar1 == (StreamBufferHandle_t)0x0); +} + + + +int wifi_mgmr_status_code_clean_internal(void) + +{ + wifiMgmr.wifi_mgmr_stat_info.status_code = 0; + return 0; +} + + + +int wifi_mgmr_state_get_internal(int *state) + +{ + uint16_t uVar1; + int iVar2; + + uVar1 = wifiMgmr.wifi_mgmr_stat_info.status_code; + if (wifiMgmr.m.currentState == &stateIdle) { + if (wifiMgmr.inf_ap_enabled != 0) { + iVar2 = 0x11; + goto LAB_230051bc; + } + iVar2 = 1; + } + else { + if (wifiMgmr.m.currentState == &stateConnecting) { + if (wifiMgmr.inf_ap_enabled != 0) { + iVar2 = 0x12; + goto LAB_230051bc; + } + iVar2 = 2; + } + else { + if (wifiMgmr.m.currentState == &stateConnectedIPNo) { + if (wifiMgmr.inf_ap_enabled == 0) { + iVar2 = 3; + } + else { + iVar2 = 0x13; + } + goto LAB_230051bc; + } + if (wifiMgmr.m.currentState == &stateConnectedIPYes) { + if (wifiMgmr.inf_ap_enabled == 0) { + iVar2 = 4; + } + else { + iVar2 = 0x14; + } + goto LAB_230051bc; + } + if (wifiMgmr.m.currentState != &stateDisconnect) { + if (wifiMgmr.m.currentState == &stateIfaceDown) { + iVar2 = 6; + } + else { + if (wifiMgmr.m.currentState != &stateSniffer) { + *state = 0; + return 0; + } + iVar2 = 7; + } + goto LAB_230051bc; + } + if (wifiMgmr.inf_ap_enabled != 0) { + iVar2 = 0x15; + goto LAB_230051bc; + } + iVar2 = 5; + } + } + *state = iVar2; + if (uVar1 == 8) { + iVar2 = 8; + } + else { + if (uVar1 != 0xc) { + return 0; + } + iVar2 = 9; + } +LAB_230051bc: + *state = iVar2; + return 0; +} + + + +void wifi_mgmr_set_connect_stat_info(wifi_event_sm_connect_ind *ind,uint8_t type_ind) + +{ + uint8_t uVar1; + uint8_t *puVar2; + uint8_t *puVar3; + + wifiMgmr.wifi_mgmr_stat_info.status_code = ind->status_code; + puVar2 = ind->bssid; + puVar3 = wifiMgmr.wifi_mgmr_stat_info.bssid; + do { + uVar1 = *puVar2; + puVar2 = puVar2 + 1; + *puVar3 = uVar1; + puVar3 = puVar3 + 1; + } while (puVar2 != &ind->vif_idx); + wifiMgmr.wifi_mgmr_stat_info.type_ind = type_ind; + wifiMgmr.wifi_mgmr_stat_info.chan_freq = ind->center_freq; + wifiMgmr.wifi_mgmr_stat_info.chan_band = ind->band; + return; +} + + + +int wifi_mgmr_set_country_code_internal(char *country_code) + +{ + bl_main_set_country_code(country_code); + strncpy(wifiMgmr.country_code,country_code,3); + wifiMgmr.country_code[2] = '\0'; + wifiMgmr.channel_nums = bl_main_get_channel_nums(); + return 0; +} + + + +int wifi_mgmr_ap_sta_cnt_get_internal(uint8_t *sta_cnt) + +{ + bl_main_apm_sta_cnt_get(sta_cnt); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +int wifi_mgmr_ap_sta_info_get_internal(wifi_mgmr_sta_basic_info_t *sta_info_internal,uint8_t idx) + +{ + undefined2 uStack40; + wifi_apm_sta_info apm_sta_info; + + memset(&uStack40,0,0x18); + bl_main_apm_sta_info_get((wifi_apm_sta_info *)&uStack40,idx); + *(undefined2 *)sta_info_internal = uStack40; + sta_info_internal->rssi = apm_sta_info.tsflo; + sta_info_internal->tsflo = apm_sta_info.tsfhi; + sta_info_internal->tsfhi = apm_sta_info.sta_mac._2_4_; + sta_info_internal->data_rate = (uint8_t)apm_sta_info.rssi; + memcpy(sta_info_internal->sta_mac,&uStack40 + 1,6); + return 0; +} + + + +int wifi_mgmr_ap_sta_delete_internal(uint8_t sta_idx) + +{ + bl_main_apm_sta_delete(sta_idx); + return 0; +} + + + +int wifi_mgmr_scan_complete_notify(void) + +{ + wifi_mgmr_scan_complete_callback(); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int wifi_mgmr_api_connect(char *ssid,char *psk,char *pmk,uint8_t *mac,uint8_t band,uint16_t freq) + +{ + size_t __n; + int iVar1; + undefined3 in_register_00002039; + undefined2 in_register_0000203e; + WIFI_MGMR_EVENT_T WStack232; + undefined uStack231; + undefined uStack230; + undefined uStack229; + uint8_t buffer [198]; + + memset(&WStack232,0,0xc6); + WStack232 = WIFI_MGMR_EVENT_APP_CONNECT; + uStack231 = 0x44; + uStack230 = 0x33; + uStack229 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = -0x3a; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + __n = strlen(ssid); + buffer._42_2_ = (undefined2)__n; + buffer._44_2_ = (undefined2)(__n >> 0x10); + memcpy(buffer + 9,ssid,__n); + buffer[41] = '\0'; + if (psk == (char *)0x0) { + buffer._176_4_ = 0; +LAB_23005414: + buffer[110] = '\0'; + if (pmk == (char *)0x0) { + buffer._180_4_ = 0; + } + else { + buffer._180_4_ = strlen(pmk); + if (buffer._180_4_ != 0) { + if (buffer._180_4_ != 0x40) goto LAB_23005472; + memcpy(buffer + 0x6f,pmk,0x40); + } + } + buffer[175] = '\0'; + if (mac != (uint8_t *)0x0) { + memcpy(buffer + 0xb8,mac,6); + } + if (CONCAT22(in_register_0000203e,freq) != 0) { + buffer[191] = (uint8_t)freq; + buffer[192] = (uint8_t)(freq >> 8); + buffer[190] = band; + printf("wifi mgmr band:%d freq: %d\r\n",CONCAT31(in_register_00002039,band), + CONCAT22(in_register_0000203e,freq)); + } + buffer[193] = '\x01'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack232); + iVar1 = 0; + } + else { + buffer._176_4_ = strlen(psk); + if (buffer._176_4_ < 0x41) { + if (buffer._176_4_ != 0) { + memcpy(buffer + 0x2e,psk,buffer._176_4_); + } + goto LAB_23005414; + } +LAB_23005472: + iVar1 = -1; + } + return iVar1; +} + + + +int wifi_mgmr_api_cfg_req + (uint32_t ops,uint32_t task,uint32_t element,uint32_t type,uint32_t length, + uint32_t *buf) + +{ + int iVar1; + WIFI_MGMR_EVENT_T WStack100; + undefined uStack99; + undefined uStack98; + undefined uStack97; + uint8_t buffer [65]; + + if (length < 0x21) { + memset(&WStack100,0,0x41); + WStack100 = WIFI_MGMR_EVENT_FW_CFG_REQ; + uStack99 = 0x44; + uStack98 = 0x33; + uStack97 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + iVar1 = length + 0xc6; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[6] = (uint8_t)((uint)iVar1 >> 8); + buffer[7] = (uint8_t)((uint)iVar1 >> 0x10); + buffer[10] = (uint8_t)(ops >> 8); + buffer[11] = (uint8_t)(ops >> 0x10); + buffer[14] = (uint8_t)(task >> 8); + buffer[15] = (uint8_t)(task >> 0x10); + buffer[18] = (uint8_t)(element >> 8); + buffer[19] = (uint8_t)(element >> 0x10); + buffer[22] = (uint8_t)(type >> 8); + buffer[23] = (uint8_t)(type >> 0x10); + buffer[5] = (uint8_t)iVar1; + buffer[9] = (uint8_t)ops; + buffer[13] = (uint8_t)task; + buffer[17] = (uint8_t)element; + buffer[21] = (uint8_t)type; + buffer[26] = (uint8_t)(length >> 8); + buffer[27] = (uint8_t)(length >> 0x10); + buffer[8] = (uint8_t)((uint)iVar1 >> 0x18); + buffer[12] = (uint8_t)(ops >> 0x18); + buffer[16] = (uint8_t)(task >> 0x18); + buffer[20] = (uint8_t)(element >> 0x18); + buffer[24] = (uint8_t)(type >> 0x18); + buffer[25] = (uint8_t)length; + buffer[28] = (uint8_t)(length >> 0x18); + if (length != 0) { + memcpy(buffer + 0x1d,buf,length); + } + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack100); + return 0; + } + return -1; +} + + + +// WARNING: Variable defined which should be unmapped: buffer + +int wifi_mgmr_api_ip_got(uint32_t ip,uint32_t mask,uint32_t gw,uint32_t dns1,uint32_t dns2) + +{ + WIFI_MGMR_EVENT_T WStack52; + undefined uStack51; + undefined uStack50; + undefined uStack49; + uint8_t buffer [33]; + + memset(&WStack52,0,0x21); + WStack52 = WIFI_MGMR_EVENT_APP_IP_GOT; + uStack51 = 0x44; + uStack50 = 0x33; + uStack49 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '!'; + buffer[10] = (uint8_t)(ip >> 8); + buffer[11] = (uint8_t)(ip >> 0x10); + buffer[14] = (uint8_t)(mask >> 8); + buffer[15] = (uint8_t)(mask >> 0x10); + buffer[18] = (uint8_t)(gw >> 8); + buffer[19] = (uint8_t)(gw >> 0x10); + buffer[9] = (uint8_t)ip; + buffer[13] = (uint8_t)mask; + buffer[17] = (uint8_t)gw; + buffer[21] = (uint8_t)dns1; + buffer[22] = (uint8_t)(dns1 >> 8); + buffer[12] = (uint8_t)(ip >> 0x18); + buffer[16] = (uint8_t)(mask >> 0x18); + buffer[20] = (uint8_t)(gw >> 0x18); + buffer[23] = (uint8_t)(dns1 >> 0x10); + buffer[24] = (uint8_t)(dns1 >> 0x18); + buffer[25] = (uint8_t)dns2; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + buffer[26] = (uint8_t)(dns2 >> 8); + buffer[27] = (uint8_t)(dns2 >> 0x10); + buffer[28] = (uint8_t)(dns2 >> 0x18); + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack52); + return 0; +} + + + +int wifi_mgmr_api_ip_update(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_GLB_IP_UPDATE; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_reconnect(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_RECONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_disable_autoreconnect(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_GLB_DISABLE_AUTORECONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_enable_autoreconnect(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_GLB_ENABLE_AUTORECONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_disconnect(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_DISCONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_rate_config(uint16_t config) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_RC_CONFIG; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + uStack31 = (undefined)config; + buffer[4] = 'U'; + uStack30 = (undefined)(config >> 8); + uStack29 = 0; + buffer[0] = '\0'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_conf_max_sta(uint8_t max_sta_supported) + +{ + WIFI_MGMR_EVENT_T local_20; + uint8_t uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_CONF_MAX_STA; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + uStack30 = 0; + uStack29 = 0; + buffer[0] = '\0'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + uStack31 = max_sta_supported; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_ifaceup(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_PHY_UP; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_sniffer_enable(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_SNIFFER; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_scan_item_beacon + (uint8_t channel,int8_t rssi,uint8_t auth,uint8_t *mac,uint8_t *ssid,int len, + int8_t ppm_abs,int8_t ppm_rel,uint8_t cipher) + +{ + WIFI_MGMR_EVENT_T WStack108; + undefined uStack107; + undefined uStack106; + undefined uStack105; + uint8_t buffer [73]; + + memset(&WStack108,0,0x49); + WStack108 = WIFI_MGMR_EVENT_GLB_SCAN_IND_BEACON; + uStack107 = 0x44; + uStack106 = 0x33; + uStack105 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = 'I'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + memcpy(buffer + 9,ssid,len); + buffer[45] = (uint8_t)len; + buffer[46] = (uint8_t)((uint)len >> 8); + buffer[47] = (uint8_t)((uint)len >> 0x10); + buffer[48] = (uint8_t)((uint)len >> 0x18); + buffer[41] = '\0'; + memcpy(buffer + 0x31,mac,6); + buffer[55] = channel; + buffer[56] = rssi; + buffer[57] = ppm_abs; + buffer[58] = ppm_rel; + buffer[59] = auth; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack108); + return 0; +} + + + +int wifi_mgmr_api_fw_disconnect(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_FW_DISCONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_fw_tsen_reload(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + local_20 = WIFI_MGMR_EVENT_APP_RELOAD_TSEN; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_fw_scan(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_FW_SCAN; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_fw_powersaving(int mode) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_FW_POWERSAVING; + uStack30 = (undefined)((uint)mode >> 8); + uStack29 = (undefined)((uint)mode >> 0x10); + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + uStack31 = (undefined)mode; + buffer[4] = 'U'; + buffer[0] = (uint8_t)((uint)mode >> 0x18); + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int wifi_mgmr_api_ap_start(char *ssid,char *passwd,int channel,uint8_t hidden_ssid) + +{ + size_t sVar1; + int iVar2; + undefined3 in_register_00002035; + WIFI_MGMR_EVENT_T WStack156; + undefined uStack155; + undefined uStack154; + undefined uStack153; + uint8_t buffer [124]; + + if (ssid == (char *)0x0) { + return -1; + } + memset(&WStack156,0,0x7c); + sVar1 = strlen(ssid); + buffer[47] = (uint8_t)sVar1; + buffer._48_4_ = buffer._48_4_ & 0xff000000 | sVar1 >> 8; + if (sVar1 < 0x21) { + if (passwd != (char *)0x0) { + buffer._116_4_ = strlen(passwd); + if (0x20 < buffer._116_4_) goto LAB_23005e90; + } + WStack156 = WIFI_MGMR_EVENT_APP_AP_START; + uStack155 = 0x44; + uStack154 = 0x33; + uStack153 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '|'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + memcpy(buffer + 0xd,ssid,(uint)buffer[47] | buffer._48_4_ << 8); + if (passwd == (char *)0x0) { + buffer._116_4_ = 0; + } + else { + memcpy(buffer + 0x33,passwd,buffer._116_4_); + } + buffer[9] = (uint8_t)channel; + buffer[10] = (uint8_t)((uint)channel >> 8); + buffer[46] = CONCAT31(in_register_00002035,hidden_ssid) != 0; + buffer[11] = (uint8_t)((uint)channel >> 0x10); + buffer[12] = (uint8_t)((uint)channel >> 0x18); + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack156); + iVar2 = 0; + } + else { +LAB_23005e90: + iVar2 = -1; + } + return iVar2; +} + + + +int wifi_mgmr_api_ap_stop(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_AP_STOP; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_idle(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + buffer[0] = '\x11'; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + local_20 = WIFI_MGMR_EVENT_APP_IDLE; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_denoise_enable(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_DENOISE; + uStack31 = 1; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + uStack30 = 0; + uStack29 = 0; + buffer[0] = '\0'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_denoise_disable(void) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_APP_DENOISE; + buffer[1] = -0x78; + buffer[2] = 'w'; + buffer[3] = 'f'; + buffer[4] = 'U'; + uStack31 = 0; + uStack30 = 0; + uStack29 = 0; + buffer[0] = '\0'; + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_raw_send(uint8_t *pkt,int len) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + uint8_t buffer [13]; + + memset(&local_20,0,0xd); + local_20 = WIFI_MGMR_EVENT_FW_DATA_RAW_SEND; + uStack30 = (undefined)((uint)pkt >> 8); + uStack29 = (undefined)((uint)pkt >> 0x10); + buffer[2] = (uint8_t)((uint)len >> 8); + uStack31 = SUB41(pkt,0); + buffer[1] = (uint8_t)len; + buffer[3] = (uint8_t)((uint)len >> 0x10); + buffer[0] = (uint8_t)((uint)pkt >> 0x18); + buffer[4] = (uint8_t)((uint)len >> 0x18); + buffer[5] = '\r'; + buffer[6] = '\0'; + buffer[7] = '\0'; + buffer[8] = '\0'; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return 0; +} + + + +int wifi_mgmr_api_set_country_code(char *country_code) + +{ + wifi_mgmr_set_country_code_internal(country_code); + return 0; +} + + + +void cmd_rf_dump(char *buf,int len,int argc,char **argv) + +{ + return; +} + + + +void cmd_dump_reset(char *buf,int len,int argc,char **argv) + +{ + pkt_counter = 10; + return; +} + + + +void cmd_wifi_power_table_update(char *buf,int len,int argc,char **argv) + +{ + int8_t aiStack56 [4]; + int8_t power_table_test [38]; + + memcpy(aiStack56,&DAT_2306fe08,0x26); + bl_tpc_update_power_table(aiStack56); + return; +} + + + +void cmd_wifi_state_get(char *buf,int len,int argc,char **argv) + +{ + char *fmt; + int iStack20; + int state; + + iStack20 = 0; + wifi_mgmr_state_get(&iStack20); + switch(iStack20) { + case 0: + fmt = "wifi state unknown\r\n"; + break; + case 1: + fmt = "wifi state idle\r\n"; + break; + case 2: + fmt = "wifi state connecting\r\n"; + break; + case 3: + fmt = "wifi state connected ip getting\r\n"; + break; + case 4: + fmt = "wifi state connected ip got\r\n"; + break; + case 5: + fmt = "wifi state disconnect\r\n"; + break; + case 6: + fmt = "wifi state ifdown\r\n"; + break; + case 7: + fmt = "wifi state sniffer\r\n"; + break; + case 8: + fmt = "wifi state psk error\r\n"; + break; + case 9: + fmt = "wifi state no ap found\r\n"; + break; + default: + goto switchD_2300615c_caseD_a; + case 0x11: + fmt = "wifi state with ap idle\r\n"; + break; + case 0x12: + fmt = "wifi state with ap connecting\r\n"; + break; + case 0x13: + fmt = "wifi state with ap connected ip getting\r\n"; + break; + case 0x14: + fmt = "wifi state with ap connected ip got\r\n"; + break; + case 0x15: + fmt = "wifi state with ap disconnect\r\n"; + } + printf(fmt); +switchD_2300615c_caseD_a: + return; +} + + + +void wifi_sta_get_state_cmd(char *buf,int len,int argc,char **argv) + +{ + char "wifi_sta_get_state_cmd" [23]; + char *fmt; + int iStack20; + int state; + + iStack20 = 0; + wifi_mgmr_state_get(&iStack20); + printf("%s:wifi state = 0x%x\r\n","wifi_sta_get_state_cmd",iStack20); + if (iStack20 == 0) { + fmt = "wifi current state: WIFI_STATE_UNKNOWN\r\n"; + } + else { + if (iStack20 == 1) { + fmt = "wifi current state: WIFI_STATE_IDLE\r\n"; + } + else { + if (iStack20 == 2) { + fmt = "wifi current state: WIFI_STATE_CONNECTING\r\n"; + } + else { + if (iStack20 == 3) { + fmt = "wifi current state: WIFI_STATE_CONNECTED_IP_GETTING\r\n"; + } + else { + if (iStack20 == 4) { + fmt = "wifi current state: WIFI_STATE_CONNECTED_IP_GOT\r\n"; + } + else { + if (iStack20 == 5) { + fmt = "wifi current state: WIFI_STATE_DISCONNECT\r\n"; + } + else { + if (iStack20 == 0x11) { + fmt = "wifi current state: WIFI_STATE_WITH_AP_IDLE\r\n"; + } + else { + if (iStack20 == 0x12) { + fmt = "wifi current state: WIFI_STATE_WITH_AP_CONNECTING\r\n"; + } + else { + if (iStack20 == 0x13) { + fmt = "wifi current state: WIFI_STATE_WITH_AP_CONNECTED_IP_GETTING\r\n"; + } + else { + if (iStack20 == 0x14) { + fmt = "wifi current state: WIFI_STATE_WITH_AP_CONNECTED_IP_GOT\r\n"; + } + else { + if (iStack20 == 0x15) { + fmt = "wifi current state: WIFI_STATE_WITH_AP_DISCONNECT\r\n"; + } + else { + if (iStack20 == 6) { + fmt = "wifi current state: WIFI_STATE_IFDOWN\r\n"; + } + else { + if (iStack20 == 7) { + fmt = "wifi current state: WIFI_STATE_SNIFFER\r\n"; + } + else { + if (iStack20 == 8) { + fmt = "wifi current state: WIFI_STATE_PSK_ERROR\r\n"; + } + else { + if (iStack20 == 9) { + fmt = "wifi current state: WIFI_STATE_NO_AP_FOUND\r\n"; + } + else { + fmt = "wifi current state: invalid\r\n"; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + printf(fmt); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void wifi_edca_dump_cmd(char *buf,int len,int argc,char **argv) + +{ + byte local_15; + byte local_14; + byte local_13; + uint8_t aifs; + ushort uStack18; + uint8_t cwmin; + uint8_t cwmax; + uint16_t txop; + + local_15 = 0; + local_14 = 0; + local_13 = 0; + uStack18 = 0; + puts("EDCA Statistic:\r\n"); + bl60x_edca_get(0,&local_15,&local_14,&local_13,(uint16_t *)&stack0xffffffee); + puts(" AC_BK:"); + printf("aifs %3u, cwmin %3u, cwmax %3u, txop %4u\r\n",(uint)local_15,(uint)local_14,(uint)local_13 + ,(uint)uStack18); + bl60x_edca_get(1,&local_15,&local_14,&local_13,(uint16_t *)&stack0xffffffee); + puts(" AC_BE:"); + printf("aifs %3u, cwmin %3u, cwmax %3u, txop %4u\r\n",(uint)local_15,(uint)local_14,(uint)local_13 + ,(uint)uStack18); + bl60x_edca_get(2,&local_15,&local_14,&local_13,(uint16_t *)&stack0xffffffee); + puts(" AC_VI:"); + printf("aifs %3u, cwmin %3u, cwmax %3u, txop %4u\r\n",(uint)local_15,(uint)local_14,(uint)local_13 + ,(uint)uStack18); + bl60x_edca_get(3,&local_15,&local_14,&local_13,(uint16_t *)&stack0xffffffee); + puts(" AC_VO:"); + printf("aifs %3u, cwmin %3u, cwmax %3u, txop %4u\r\n",(uint)local_15,(uint)local_14,(uint)local_13 + ,(uint)uStack18); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void wifi_ap_sta_list_get_cmd(char *buf,int len,int argc,char **argv) + +{ + char cVar1; + uint uVar2; + char *fmt; + wifi_ap_data_rate *pwVar3; + byte bStack77; + uint8_t sta_cnt; + uint uStack76; + int state; + wifi_sta_basic_info sta_info; + + uStack76 = 0; + bStack77 = 0; + wifi_mgmr_state_get((int *)&stack0xffffffb4); + if ((uStack76 & 0x10) == 0) { + fmt = "wifi AP is not enabled, state = %d\r\n"; + uVar2 = uStack76; + } + else { + wifi_mgmr_ap_sta_cnt_get(&bStack77); + if (bStack77 != 0) { + memset(&state,0,0x18); + printf("sta list:\r\n"); + printf( + "-----------------------------------------------------------------------------------\r\n" + ); + printf( + "No. StaIndex Mac-Address Signal DateRate TimeStamp\r\n" + ); + printf( + "-----------------------------------------------------------------------------------\r\n" + ); + uVar2 = 0; + do { + if (bStack77 <= uVar2) { + return; + } + wifi_mgmr_ap_sta_info_get((wifi_sta_basic_info *)&state,(uint8_t)uVar2); + if ((state._1_1_ != '\0') && ((uint8_t)state != -0x11)) { + pwVar3 = data_rate_list; + cVar1 = '\0'; + do { + if (pwVar3->data_rate == (uint8_t)sta_info.rssi) break; + cVar1 = cVar1 + '\x01'; + pwVar3 = pwVar3 + 1; + } while (cVar1 != '\f'); + printf( + " %u %u %02X:%02X:%02X:%02X:%02X:%02X %d %s 0x%llx\r\n" + ,uVar2,(uint)state._2_1_,(uint)state._3_1_,(uint)sta_info.sta_idx, + (uint)sta_info.is_used,(uint)sta_info.sta_mac[0]); + } + uVar2 = uVar2 + 1 & 0xff; + } while( true ); + } + uVar2 = 0; + fmt = "no sta connect current AP, sta_cnt = %d\r\n"; + } + printf(fmt,uVar2); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void wifi_ap_sta_delete_cmd(char *buf,int len,int argc,char **argv) + +{ + char cVar1; + byte idx; + char *fmt; + size_t sVar2; + char *pcVar3; + char *__s; + byte bVar4; + char cVar5; + byte bStack45; + uint8_t sta_cnt; + char *pcStack44; + int state; + wifi_sta_basic_info sta_info; + + pcStack44 = (char *)0x0; + bStack45 = 0; + if (argc == 2) { + wifi_mgmr_state_get((int *)&stack0xffffffd4); + if (((uint)pcStack44 & 0x10) == 0) { + fmt = "wifi AP is not enabled, state = %d\r\n"; + pcVar3 = pcStack44; + } + else { + printf("Delete Sta No.%s \r\n",argv[1]); + __s = argv[1]; + idx = 0; + sVar2 = strlen(__s); + cVar5 = '\x01'; + fmt = __s + sVar2; + *fmt = '\0'; + pcVar3 = fmt; + while ((int)(fmt + -(int)pcVar3) < (int)sVar2) { + cVar1 = pcVar3[-1]; + bVar4 = cVar1 - 0x30; + if (9 < bVar4) { + if ((byte)(cVar1 + 0x9fU) < 6) { + bVar4 = cVar1 + 0xa9; + } + else { + bVar4 = 0; + if ((byte)(cVar1 + 0xbfU) < 6) { + bVar4 = cVar1 - 0x37; + } + } + } + pcVar3 = pcVar3 + -1; + idx = idx + bVar4 * cVar5; + cVar5 = cVar5 * '\n'; + } + pcVar3 = (char *)(uint)idx; + printf("sta_str: %s, str_len: %d, sta_num: %d, q: %s\r\n",__s,pcVar3); + printf("sta num = %d \r\n",pcVar3); + wifi_mgmr_ap_sta_cnt_get(&bStack45); + if ((bStack45 == 0) || ((char *)(uint)bStack45 < pcVar3)) { + fmt = "no valid sta in list or sta idx(%d) is invalid\r\n"; + pcVar3 = (char *)(uint)bStack45; + } + else { + memset(&state,0,0x18); + wifi_mgmr_ap_sta_info_get((wifi_sta_basic_info *)&state,idx); + if ((state._1_1_ != '\0') && ((uint8_t)state != -0x11)) { + printf("sta info: No.%u,sta_idx = %u,mac = %02X:%02X:%02X:%02X:%02X:%02X,rssi = %d\r\n", + pcVar3,(uint)state._2_1_,(uint)state._3_1_,(uint)sta_info.sta_idx, + (uint)sta_info.is_used,(uint)sta_info.sta_mac[0]); + wifi_mgmr_ap_sta_delete((uint8_t)state); + return; + } + fmt = "No.%d sta is invalid\r\n"; + } + } + } + else { + fmt = "[USAGE]: %s sta_num\r\n"; + pcVar3 = *argv; + } + printf(fmt,pcVar3); + return; +} + + + +void cmd_wifi_coex_pta_force_off(char *buf,int len,int argc,char **argv) + +{ + coex_wifi_pta_forece_enable(0); + return; +} + + + +void cmd_wifi_coex_pta_force_on(char *buf,int len,int argc,char **argv) + +{ + coex_wifi_pta_forece_enable(1); + return; +} + + + +void cmd_wifi_coex_pti_force_off(char *buf,int len,int argc,char **argv) + +{ + coex_wifi_pti_forece_enable(0); + return; +} + + + +void cmd_wifi_coex_pti_force_on(char *buf,int len,int argc,char **argv) + +{ + coex_wifi_pti_forece_enable(1); + return; +} + + + +void cmd_wifi_coex_rf_force_off(char *buf,int len,int argc,char **argv) + +{ + coex_wifi_rf_forece_enable(0); + return; +} + + + +void cmd_wifi_coex_rf_force_on(char *buf,int len,int argc,char **argv) + +{ + coex_wifi_rf_forece_enable(1); + return; +} + + + +void cmd_wifi_mib(char *buf,int len,int argc,char **argv) + +{ + hal_mib_dump(); + utils_hexdump(*argv,0x1e); + return; +} + + + +void cmd_wifi_cfg(char *buf,int len,int argc,char **argv) + +{ + uint uVar1; + uint32_t task; + int iVar2; + uint32_t ops; + uint32_t length; + uint32_t *buf_00; + uint32_t element; + uint32_t type; + uint32_t uStack88; + uint32_t val [1]; + getopt_env_t getopt_env; + + type = 0; + utils_getopt_init((getopt_env_t *)val,0); + element = 0; + task = 0; + uVar1 = 4; + while (iVar2 = utils_getopt((getopt_env_t *)val,argc,argv,":c:T:e:t:v:"), iVar2 != -1) { + if (iVar2 == 99) { + iVar2 = strcmp("dump",(char *)val); + if (iVar2 == 0) { + uVar1 = 3; + } + else { + iVar2 = strcmp("set",(char *)val); + if (iVar2 == 0) { + uVar1 = 0; + } + else { + iVar2 = strcmp("get",(char *)val); + if (iVar2 == 0) { + uVar1 = 1; + } + else { + iVar2 = strcmp("reset",(char *)val); + if (iVar2 == 0) { + uVar1 = 2; + } + } + } + } + } + else { + if (iVar2 < 100) { + if (iVar2 == 0x3f) { + printf("%s: unknown option %c\r\n",*argv,getopt_env.opterr); + return; + } + if (iVar2 == 0x54) { + type = atoi((char *)val); + } + } + else { + if (iVar2 == 0x74) { + task = atoi((char *)val); + } + else { + if (iVar2 == 0x76) { + uStack88 = atoi((char *)val); + } + else { + if (iVar2 == 0x65) { + element = atoi((char *)val); + } + } + } + } + } + } + printf("Target CFG Element Info, task: %lu, element %lu, type %lu, val %lu\r\n",task,element,type, + uStack88); + if (uVar1 == 2) { + printf(" OPS: %s\r\n","reset"); + buf_00 = (uint32_t *)0x0; + length = 0; + type = 0; + ops = 2; + } + else { + if (uVar1 < 3) { + if (uVar1 == 1) { + printf(" OPS: %s\r\n",&DAT_2306fec0); + buf_00 = &uStack88; + length = 4; + ops = 1; + goto LAB_230067b4; + } + } + else { + if (uVar1 == 3) { + printf(" OPS: %s\r\n",0x23077238); + buf_00 = (uint32_t *)0x0; + length = 0; + type = 0; + element = 0; + task = 0; + ops = 3; + goto LAB_230067b4; + } + if (uVar1 == 4) { + printf("UNKNOWN OPS\r\n"); + return; + } + } + printf(" OPS: %s\r\n",0x230702a8); + buf_00 = &uStack88; + length = 4; + ops = 0; + } +LAB_230067b4: + wifi_mgmr_cfg_req(ops,task,element,type,length,buf_00); + return; +} + + + +void cmd_wifi_ap_stop(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_ap_stop((wifi_interface_t *)0x0); + printf("--->>> cmd_wifi_ap_stop\r\n"); + return; +} + + + +// WARNING: Variable defined which should be unmapped: ssid_name + +void cmd_wifi_ap_start(char *buf,int len,int argc,char **argv) + +{ + wifi_interface_t *interface; + uint hidden_ssid; + char *passwd; + int channel; + uint8_t auStack56 [3]; + byte bStack53; + uint8_t mac [6]; + char ssid_name [32]; + + memset(auStack56,0,6); + bl_wifi_mac_addr_get(auStack56); + memset(mac + 4,0,0x20); + snprintf((char *)(mac + 4),0x20,"BL60X_uAP_%02X%02X%02X",(uint)bStack53,(uint)mac[0],(uint)mac[1]) + ; + interface = (wifi_interface_t *)wifi_mgmr_ap_enable(); + if (argc == 1) { + channel = 1; + passwd = (char *)0x0; + hidden_ssid = 0; + } + else { + channel = atoi(argv[1]); + if (10 < channel - 1U) { + return; + } + passwd = "12345678"; + hidden_ssid = (uint)(argc == 3); + } + wifi_mgmr_ap_start(interface,(char *)(mac + 4),hidden_ssid,passwd,channel); + return; +} + + + +void wifi_sniffer_off_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_sniffer_disable(); + wifi_mgmr_sniffer_unregister((void *)0x0); + return; +} + + + +void wifi_sniffer_on_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_sniffer_enable(); + wifi_mgmr_sniffer_register((void *)0x0,sniffer_cb); + return; +} + + + +int wifi_denoise_disable_cmd(void) + +{ + WIFI_MGMR_EVENT_T WStack32; + undefined uStack31; + undefined uStack30; + undefined uStack29; + undefined uStack28; + undefined uStack27; + undefined uStack26; + undefined uStack25; + undefined uStack24; + undefined uStack23; + undefined uStack22; + undefined uStack21; + undefined uStack20; + + memset(&WStack32,0,0xd); + WStack32 = WIFI_MGMR_EVENT_APP_DENOISE; + uStack27 = 0x88; + uStack26 = 0x77; + uStack25 = 0x66; + uStack24 = 0x55; + uStack31 = 0; + uStack30 = 0; + uStack29 = 0; + uStack28 = 0; + uStack23 = 0xd; + uStack22 = 0; + uStack21 = 0; + uStack20 = 0; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack32); + return 0; +} + + + +int wifi_denoise_enable_cmd(void) + +{ + WIFI_MGMR_EVENT_T WStack32; + undefined uStack31; + undefined uStack30; + undefined uStack29; + undefined uStack28; + undefined uStack27; + undefined uStack26; + undefined uStack25; + undefined uStack24; + undefined uStack23; + undefined uStack22; + undefined uStack21; + undefined uStack20; + + memset(&WStack32,0,0xd); + WStack32 = WIFI_MGMR_EVENT_APP_DENOISE; + uStack31 = 1; + uStack27 = 0x88; + uStack26 = 0x77; + uStack25 = 0x66; + uStack24 = 0x55; + uStack30 = 0; + uStack29 = 0; + uStack28 = 0; + uStack23 = 0xd; + uStack22 = 0; + uStack21 = 0; + uStack20 = 0; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack32); + return 0; +} + + + +void wifi_power_saving_off_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_sta_powersaving(0); + return; +} + + + +void wifi_power_saving_on_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_sta_powersaving(2); + return; +} + + + +void wifi_rc_fixed_disable(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_rate_config(0xffff); + return; +} + + + +int wifi_disable_autoreconnect_cmd(void) + +{ + wifi_mgmr_api_disable_autoreconnect(); + return 0; +} + + + +int wifi_enable_autoreconnect_cmd(void) + +{ + wifi_mgmr_api_enable_autoreconnect(); + return 0; +} + + + +void wifi_disconnect_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_sta_disconnect(); + vTaskDelay(1000); + wifi_mgmr_sta_disable((wifi_interface_t *)0x0); + return; +} + + + +int wifi_sta_ip_unset_cmd(void) + +{ + int iVar1; + + iVar1 = wifi_mgmr_sta_ip_set(0,0,0,0,0); + return iVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void wifi_sta_ip_info(char *buf,int len,int argc,char **argv) + +{ + char *pcVar1; + ip4_addr_t iStack80; + ip4_addr_t ip; + ip4_addr_t gw; + ip4_addr_t mask; + ip4_addr_t dns1; + ip4_addr_t dns2; + int rssi; + int8_t power_rate_table [38]; + + wifi_mgmr_sta_ip_get((uint32_t *)&iStack80,(uint32_t *)&ip,(uint32_t *)&gw); + wifi_mgmr_sta_dns_get((uint32_t *)&mask,(uint32_t *)&dns1); + wifi_mgmr_rssi_get((int *)&dns2); + bl_tpc_power_table_get((int8_t *)&rssi); + printf("RSSI: %ddbm\r\n",dns2); + pcVar1 = ip4addr_ntoa(&iStack80); + printf("IP : %s \r\n",pcVar1); + pcVar1 = ip4addr_ntoa(&gw); + printf("MASK: %s \r\n",pcVar1); + pcVar1 = ip4addr_ntoa(&ip); + printf("GW : %s \r\n",pcVar1); + pcVar1 = ip4addr_ntoa(&mask); + printf("DNS1: %s \r\n",pcVar1); + pcVar1 = ip4addr_ntoa(&dns1); + printf("DNS2: %s \r\n",pcVar1); + puts("Power Table (dbm):\r\n"); + puts("--------------------------------\r\n"); + printf(" 11b: %u %u %u %u (1Mbps 2Mbps 5.5Mbps 11Mbps)\r\n",(int)(char)rssi, + (int)rssi._1_1_,(int)rssi._2_1_,(int)rssi._3_1_); + printf( + " 11g: %u %u %u %u %u %u %u %u (6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps)\r\n" + ,(int)power_rate_table[4],(int)power_rate_table[5],(int)power_rate_table[6], + (int)power_rate_table[7],(int)power_rate_table[8],(int)power_rate_table[9], + (int)power_rate_table[10]); + printf(" 11n: %u %u %u %u %u %u %u %u (MCS0 ~ MCS7)\r\n",(int)power_rate_table[12], + (int)power_rate_table[13],(int)power_rate_table[14],(int)power_rate_table[15], + (int)power_rate_table[16],(int)power_rate_table[17],(int)power_rate_table[18]); + puts("--------------------------------\r\n"); + return; +} + + + +void cmd_wifi_raw_send(char *buf,int len,int argc,char **argv) + +{ + uint32_t seq; + char *s; + int iVar1; + + iVar1 = seq << 4; + packet_raw[22] = (uint8_t)iVar1; + seq = seq + 1; + packet_raw[23] = (uint8_t)((uint)iVar1 >> 8); + iVar1 = wifi_mgmr_raw_80211_send(packet_raw,0x18); + if (iVar1 == 0) { + s = "Raw send succeed\r\n"; + } + else { + s = "Raw send failed\r\n"; + } + puts(s); + return; +} + + + +void wifi_scan_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_mgmr_scan((void *)0x0,(scan_complete_cb_t *)0x0); + return; +} + + + +void sniffer_cb(void *env,uint8_t *pkt,int len) + +{ + TickType_t TVar1; + + sniffer_counter_5067 = sniffer_counter_5067 + 1; + TVar1 = xTaskGetTickCount(); + if (10000 < (int)(TVar1 - last_tick_5069)) { + last_tick_5069 = xTaskGetTickCount(); + } + return; +} + + + +void cmd_wifi_dump(char *buf,int len,int argc,char **argv) + +{ + if (argc < 2) { + puts("[CLI] Dump statistic use normal mode\r\n"); + vTaskEnterCritical(); + } + else { + puts("[CLI] Dump statistic use forced mode\r\n"); + vTaskEnterCritical(); + } + bl60x_fw_dump_statistic((uint)(argc >= 2)); + vTaskExitCritical(); + return; +} + + + +void cmd_wifi_ap_conf_max_sta(char *buf,int len,int argc,char **argv) + +{ + int iVar1; + + if (argc != 2) { + printf("Usage: wifi_ap_max_sta [num]\r\n"); + return; + } + iVar1 = atoi(argv[1]); + printf("Conf Max Sta to %d\r\n",iVar1); + wifi_mgmr_conf_max_sta((uint8_t)iVar1); + return; +} + + + +void wifi_mon_cmd(char *buf,int len,int argc,char **argv) + +{ + if (1 < argc) { + wifi_mgmr_sniffer_enable(); + return; + } + wifi_mgmr_sniffer_register((void *)0x0,sniffer_cb); + return; +} + + + +void wifi_rc_fixed_enable(char *buf,int len,int argc,char **argv) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + char *pcVar4; + uint uVar5; + + if (argc != 4) { + printf("rc_fix_en [b/g/n] [MCS] [GI]"); + return; + } + uVar1 = atoi(argv[1]); + uVar5 = uVar1 & 0xff; + uVar2 = atoi(argv[2]); + uVar3 = atoi(argv[3]); + if (uVar5 == 1) { + pcVar4 = "n mode"; + } + else { + pcVar4 = "b/g mdoe"; + } + printf("wifi set mode:%s, mcs:%d, gi:%d\r\n",pcVar4,uVar2 & 0xff,uVar3 & 0xff); + if (uVar5 == 1) { + uVar1 = ((uVar1 & 0xff) << 0xc | (uVar3 & 0xff) << 9) & 0xffff | uVar2 & 0xff; + } + else { + uVar1 = 0; + if (uVar5 == 0) { + uVar1 = uVar2 & 0xff | 0x600; + } + } + printf("wifi rc:0x%x\r\n",uVar1); + wifi_mgmr_rate_config((uint16_t)uVar1); + return; +} + + + +void wifi_connect_cmd(char *buf,int len,int argc,char **argv) + +{ + wifi_interface_t *wifi_interface; + + if (argc != 3) { + printf("[USAGE]: %s [ssid] [password]\r\n",*argv); + return; + } + wifi_interface = (wifi_interface_t *)wifi_mgmr_sta_enable(); + wifi_mgmr_sta_connect(wifi_interface,argv[1],argv[2],(char *)0x0,(uint8_t *)0x0,'\0',0); + return; +} + + + +void wifi_sta_ip_set_cmd(char *buf,int len,int argc,char **argv) + +{ + ip4_addr_t ip; + ip4_addr_t mask; + ip4_addr_t gw; + ip4_addr_t dns1; + ip4_addr_t dns2; + ip4_addr_t iStack56; + ip4_addr_t addr; + char addr_str [20]; + + if (argc == 6) { + ip = (ip4_addr_t)ipaddr_addr(argv[1]); + mask = (ip4_addr_t)ipaddr_addr(argv[2]); + gw = (ip4_addr_t)ipaddr_addr(argv[3]); + dns1 = (ip4_addr_t)ipaddr_addr(argv[4]); + dns2 = (ip4_addr_t)ipaddr_addr(argv[5]); + iStack56 = ip; + ip4addr_ntoa_r(&iStack56,(char *)&addr,0x14); + puts("IP : "); + puts((char *)&addr); + puts("\r\n"); + iStack56 = mask; + ip4addr_ntoa_r(&iStack56,(char *)&addr,0x14); + puts("MASK: "); + puts((char *)&addr); + puts("\r\n"); + iStack56 = gw; + ip4addr_ntoa_r(&iStack56,(char *)&addr,0x14); + puts("GW : "); + puts((char *)&addr); + puts("\r\n"); + iStack56 = dns1; + ip4addr_ntoa_r(&iStack56,(char *)&addr,0x14); + puts("DNS1: "); + puts((char *)&addr); + puts("\r\n"); + iStack56 = dns2; + ip4addr_ntoa_r(&iStack56,(char *)&addr,0x14); + puts("DNS2: "); + puts((char *)&addr); + puts("\r\n"); + wifi_mgmr_sta_ip_set((uint32_t)ip,(uint32_t)mask,(uint32_t)gw,(uint32_t)dns1,(uint32_t)dns2); + } + else { + puts("Illegal CMD format\r\n"); + } + return; +} + + + +void wifi_scan_filter_cmd(char *buf,int len,int argc,char **argv) + +{ + if (argc == 2) { + wifi_mgmr_scan_filter_hidden_ssid((uint)(*argv[1] == '1')); + return; + } + return; +} + + + +void wifi_capcode_cmd(char *buf,int len,int argc,char **argv) + +{ + uint8_t uVar1; + char *fmt; + undefined3 extraout_var; + int iVar2; + char *pcVar3; + + if (argc - 1U < 2) { + if (argc != 1) { + iVar2 = atoi(argv[1]); + printf("Setting capcode to %d\r\n",iVar2); + if (0 < iVar2) { + hal_sys_capcode_update((uint8_t)iVar2,(uint8_t)iVar2); + return; + } + return; + } + uVar1 = hal_sys_capcode_get(); + pcVar3 = (char *)CONCAT31(extraout_var,uVar1); + fmt = "Capcode %u is being used\r\n"; + } + else { + pcVar3 = *argv; + fmt = "Usage: %s capcode\r\n"; + } + printf(fmt,pcVar3); + return; +} + + + +int wifi_mgmr_cli_scanlist(void) + +{ + byte bVar1; + byte bVar2; + byte bVar3; + byte bVar4; + byte bVar5; + byte bVar6; + wifi_mgmr_t *pwVar7; + int iVar8; + TickType_t TVar9; + + printf("cached scan list\r\n"); + pwVar7 = &wifiMgmr; + printf( + "****************************************************************************************************\r\n" + ); + iVar8 = 0; + do { + if (pwVar7->scan_items[0].is_used == '\0') { +LAB_23007022: + printf("index[%02d]: empty\r\n",iVar8); + } + else { + TVar9 = xTaskGetTickCount(); + if ((uint)wifiMgmr.scan_item_timeout <= TVar9 - pwVar7->scan_items[0].timestamp_lastseen) + goto LAB_23007022; + bVar1 = pwVar7->scan_items[0].channel; + bVar2 = pwVar7->scan_items[0].bssid[0]; + bVar3 = pwVar7->scan_items[0].bssid[1]; + bVar4 = pwVar7->scan_items[0].bssid[2]; + bVar5 = pwVar7->scan_items[0].bssid[3]; + bVar6 = pwVar7->scan_items[0].bssid[4]; + wifi_mgmr_auth_to_str(pwVar7->scan_items[0].auth); + wifi_mgmr_cipher_to_str(pwVar7->scan_items[0].cipher); + printf( + "index[%02d]: channel %02u, bssid %02X:%02X:%02X:%02X:%02X:%02X, rssi %3d, ppm abs:rel %3d : %3d, auth %20s, cipher:%12s, SSID %s\r\n" + ,iVar8,(uint)bVar1,(uint)bVar2,(uint)bVar3,(uint)bVar4,(uint)bVar5,(uint)bVar6); + } + iVar8 = iVar8 + 1; + pwVar7 = (wifi_mgmr_t *)&(pwVar7->wlan_sta).netif.input; + if (iVar8 == 0x32) { + printf( + "----------------------------------------------------------------------------------------------------\r\n" + ); + return 0; + } + } while( true ); +} + + + +int wifi_mgmr_ext_dump_needed(void) + +{ + bool bVar1; + + bVar1 = 0 < pkt_counter; + if (bVar1) { + pkt_counter = pkt_counter + -1; + } + return (uint)bVar1; +} + + + +int wifi_mgmr_cli_init(void) + +{ + return 0; +} + + + +int mac_is_unvalid(uint8_t *mac) + +{ + int iVar1; + + iVar1 = 1; + do { + if (mac[iVar1] != *mac) { + return 0; + } + iVar1 = iVar1 + 1; + } while (iVar1 != 6); + return (uint)((byte)(*mac - 1) < 0xfe) ^ 1; +} + + + +int wifi_mgmr_psk_cal(char *password,char *ssid,int ssid_len,char *output) + +{ + int iVar1; + uchar auStack48 [4]; + char psk [32]; + + iVar1 = bl60x_fw_password_hash(password,(uchar *)ssid,ssid_len,auStack48); + if (iVar1 == 0) { + utils_bin2hex(output,auStack48,0x20); + } + return iVar1; +} + + + +int wifi_mgmr_drv_init(wifi_conf_t *conf) + +{ + bl606a0_wifi_init(conf); + wifi_mgmr_api_set_country_code((char *)conf); + wifi_mgmr_init(); + wifi_mgmr_api_ifaceup(); + return 0; +} + + + +// WARNING: Variable defined which should be unmapped: gw + +wifi_interface_t wifi_mgmr_sta_enable(void) + +{ + int done; + int iVar1; + ip4_addr_t iStack28; + ip4_addr_t ipaddr; + ip4_addr_t netmask; + ip4_addr_t gw; + + if (done == 1) { + printf("----- BUG FIXME? NOT do STA enable again\r\n"); + } + else { + done = 1; + printf("---------STA enable\r\n"); + wifiMgmr.wlan_sta.mode = 0; + iStack28 = (ip4_addr_t)0x0; + ipaddr = 0; + netmask = 0; + memcpy(wifiMgmr.wlan_sta.netif.hwaddr,wifiMgmr.wlan_sta.mac,6); + iVar1 = mac_is_unvalid(wifiMgmr.wlan_sta.netif.hwaddr); + if (iVar1 != 0) { + bl_wifi_mac_addr_get(wifiMgmr.wlan_sta.netif.hwaddr); + iVar1 = mac_is_unvalid(wifiMgmr.wlan_sta.netif.hwaddr); + if (iVar1 != 0) { + wifiMgmr.wlan_sta.netif.hwaddr._0_2_ = 0x50c0; + wifiMgmr.wlan_sta.netif.hwaddr._2_4_ = 0x100c943; + } + memcpy(wifiMgmr.wlan_sta.mac,wifiMgmr.wlan_sta.netif.hwaddr,6); + } + netifapi_netif_add(&wifiMgmr.wlan_sta.netif,&iStack28,&ipaddr,&netmask,(void *)0x0, + bl606a0_wifi_netif_init,tcpip_input); + wifiMgmr.wlan_sta.netif.name = 0x7473; + wifiMgmr.wlan_sta.netif.flags = wifiMgmr.wlan_sta.netif.flags | 0x24; + netif_set_default(&wifiMgmr.wlan_sta.netif); + netif_set_up(&wifiMgmr.wlan_sta.netif); + } + return &wifiMgmr.wlan_sta; +} + + + +int wifi_mgmr_sta_disable(wifi_interface_t *interface) + +{ + wifi_mgmr_api_idle(); + return 0; +} + + + +int wifi_mgmr_sta_ip_get(uint32_t *ip,uint32_t *gw,uint32_t *mask) + +{ + *ip = wifiMgmr.wlan_sta.netif.ip_addr; + *mask = wifiMgmr.wlan_sta.netif.netmask; + *gw = wifiMgmr.wlan_sta.netif.gw; + return 0; +} + + + +int wifi_mgmr_sta_dns_get(uint32_t *dns1,uint32_t *dns2) + +{ + ip_addr_t *piVar1; + + piVar1 = dns_getserver('\0'); + *dns1 = piVar1->addr; + piVar1 = dns_getserver('\x01'); + *dns2 = piVar1->addr; + return 0; +} + + + +int wifi_mgmr_sta_ip_set(uint32_t ip,uint32_t mask,uint32_t gw,uint32_t dns1,uint32_t dns2) + +{ + vTaskEnterCritical(); + wifiMgmr.wlan_sta.ipv4.ip = ip; + wifiMgmr.wlan_sta.ipv4.mask = mask; + wifiMgmr.wlan_sta.ipv4.gw = gw; + wifiMgmr.wlan_sta.ipv4.dns1 = dns1; + wifiMgmr.wlan_sta.ipv4.dns2 = dns2; + vTaskExitCritical(); + wifi_mgmr_api_ip_update(); + return 0; +} + + + +int wifi_mgmr_sta_ip_unset(void) + +{ + int iVar1; + + iVar1 = wifi_mgmr_sta_ip_set(0,0,0,0,0); + return iVar1; +} + + + +int wifi_mgmr_sta_disconnect(void) + +{ + wifi_mgmr_api_disconnect(); + return 0; +} + + + +int wifi_mgmr_sta_powersaving(int ps) + +{ + if ((ps == 1) || (ps == 2)) { + wifi_mgmr_api_fw_powersaving(ps); + ps = 0; + } + else { + if (ps == 0) { + wifi_mgmr_api_fw_powersaving(0); + } + else { + ps = -1; + } + } + return ps; +} + + + +int wifi_mgmr_sta_autoconnect_enable(void) + +{ + wifi_mgmr_api_enable_autoreconnect(); + return 0; +} + + + +int wifi_mgmr_sta_autoconnect_disable(void) + +{ + wifi_mgmr_api_disable_autoreconnect(); + return 0; +} + + + +void wifi_mgmr_sta_connect_ind_stat_get(wifi_mgmr_sta_connect_ind_stat_info_t *wifi_mgmr_ind_stat) + +{ + size_t __n; + + __n = strlen(wifiMgmr.wifi_mgmr_stat_info.ssid); + if (0 < (int)__n) { + memcpy(wifi_mgmr_ind_stat->ssid,wifiMgmr.wifi_mgmr_stat_info.ssid,__n); + wifi_mgmr_ind_stat->ssid[__n] = '\0'; + } + __n = strlen(wifiMgmr.wifi_mgmr_stat_info.psk); + if (0 < (int)__n) { + memcpy(wifi_mgmr_ind_stat->psk,wifiMgmr.wifi_mgmr_stat_info.psk,__n); + wifi_mgmr_ind_stat->psk[__n] = '\0'; + } + memcpy(wifi_mgmr_ind_stat->bssid,wifiMgmr.wifi_mgmr_stat_info.bssid,6); + wifi_mgmr_ind_stat->status_code = wifiMgmr.wifi_mgmr_stat_info.status_code; + wifi_mgmr_ind_stat->chan_band = wifiMgmr.wifi_mgmr_stat_info.chan_band; + wifi_mgmr_ind_stat->chan_freq = wifiMgmr.wifi_mgmr_stat_info.chan_freq; + wifi_mgmr_ind_stat->type_ind = wifiMgmr.wifi_mgmr_stat_info.type_ind; + printf("wifi mgmr ind status code = %d\r\n"); + printf("ssid: %s, psk: %s, band: %d, freq: %d, type_ind: %d\r\n",wifi_mgmr_ind_stat->ssid, + wifi_mgmr_ind_stat->psk,(uint)wifi_mgmr_ind_stat->chan_band, + (uint)wifi_mgmr_ind_stat->chan_freq,(uint)wifi_mgmr_ind_stat->type_ind); + printf("bssid: %02x%02x%02x%02x%02x%02x\r\n",(uint)wifi_mgmr_ind_stat->bssid[0], + (uint)wifi_mgmr_ind_stat->bssid[1],(uint)wifi_mgmr_ind_stat->bssid[2], + (uint)wifi_mgmr_ind_stat->bssid[3],(uint)wifi_mgmr_ind_stat->bssid[4], + (uint)wifi_mgmr_ind_stat->bssid[5]); + return; +} + + + +void wifi_mgmr_sta_ssid_set(char *ssid) + +{ + size_t __n; + + __n = strlen(ssid); + if (__n != 0) { + __n = strlen(ssid); + memcpy(wifiMgmr.wifi_mgmr_stat_info.ssid,ssid,__n); + return; + } + return; +} + + + +void wifi_mgmr_sta_psk_set(char *psk) + +{ + size_t __n; + + __n = strlen(psk); + if (__n != 0) { + __n = strlen(psk); + memcpy(wifiMgmr.wifi_mgmr_stat_info.psk,psk,__n); + return; + } + return; +} + + + +int wifi_mgmr_sta_connect + (wifi_interface_t *wifi_interface,char *ssid,char *psk,char *pmk,uint8_t *mac, + uint8_t band,uint16_t freq) + +{ + int iVar1; + + wifi_mgmr_sta_ssid_set(ssid); + wifi_mgmr_sta_psk_set(psk); + iVar1 = wifi_mgmr_api_connect(ssid,psk,pmk,mac,band,freq); + return iVar1; +} + + + +// WARNING: Variable defined which should be unmapped: gw + +wifi_interface_t wifi_mgmr_ap_enable(void) + +{ + int iVar1; + ip4_addr_t iStack28; + ip4_addr_t ipaddr; + ip4_addr_t netmask; + ip4_addr_t gw; + + wifiMgmr.wlan_ap.mode = 1; + iStack28 = (ip4_addr_t)0x10ba8c0; + ipaddr = 0xffffff; + netmask = 0; + memcpy(wifiMgmr.wlan_ap.netif.hwaddr,wifiMgmr.wlan_ap.mac,6); + iVar1 = mac_is_unvalid(wifiMgmr.wlan_ap.netif.hwaddr); + if (iVar1 != 0) { + bl_wifi_mac_addr_get(wifiMgmr.wlan_ap.netif.hwaddr); + iVar1 = mac_is_unvalid(wifiMgmr.wlan_ap.netif.hwaddr); + if (iVar1 != 0) { + wifiMgmr.wlan_ap.netif.hwaddr._0_2_ = 0x50c0; + wifiMgmr.wlan_ap.netif.hwaddr._2_4_ = 0x100c943; + } + memcpy(wifiMgmr.wlan_ap.mac,wifiMgmr.wlan_ap.netif.hwaddr,6); + } + netifapi_netif_add(&wifiMgmr.wlan_ap.netif,&iStack28,&ipaddr,&netmask,(void *)0x0, + bl606a0_wifi_netif_init,tcpip_input); + wifiMgmr.wlan_ap.netif.name = 0x7061; + netif_set_default(&wifiMgmr.wlan_ap.netif); + netif_set_up(&wifiMgmr.wlan_ap.netif); + return &wifiMgmr.wlan_ap; +} + + + +int wifi_mgmr_ap_start(wifi_interface_t *interface,char *ssid,int hidden_ssid,char *passwd, + int channel) + +{ + wifi_mgmr_api_ap_start(ssid,passwd,channel,(uint8_t)hidden_ssid); + return 0; +} + + + +int wifi_mgmr_ap_stop(wifi_interface_t *interface) + +{ + wifi_mgmr_api_ap_stop(); + return 0; +} + + + +int wifi_mgmr_ap_sta_cnt_get(uint8_t *sta_cnt) + +{ + wifi_mgmr_ap_sta_cnt_get_internal(sta_cnt); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +int wifi_mgmr_ap_sta_info_get(wifi_sta_basic_info *sta_info,uint8_t idx) + +{ + undefined2 uStack40; + wifi_mgmr_sta_basic_info sta_info_internal; + + memset(&uStack40,0,0x18); + wifi_mgmr_ap_sta_info_get_internal((wifi_mgmr_sta_basic_info_t *)&uStack40,idx); + *(undefined2 *)sta_info = uStack40; + sta_info->rssi = sta_info_internal.tsflo; + sta_info->tsflo = sta_info_internal.tsfhi; + sta_info->tsfhi = sta_info_internal.sta_mac._2_4_; + sta_info->data_rate = (uint8_t)sta_info_internal.rssi; + memcpy(sta_info->sta_mac,&uStack40 + 1,6); + return 0; +} + + + +int wifi_mgmr_ap_sta_delete(uint8_t sta_idx) + +{ + wifi_mgmr_ap_sta_delete_internal(sta_idx); + return 0; +} + + + +int wifi_mgmr_sniffer_register(void *env,sniffer_cb_t *cb) + +{ + bl_rx_pkt_cb_register(env,(wifi_event_pkt_cb_t *)cb); + return 0; +} + + + +int wifi_mgmr_sniffer_unregister(void *env) + +{ + bl_rx_pkt_cb_unregister(env); + return 0; +} + + + +int wifi_mgmr_sniffer_enable(void) + +{ + wifi_mgmr_api_sniffer_enable(); + return 0; +} + + + +int wifi_mgmr_sniffer_disable(void) + +{ + wifi_mgmr_api_idle(); + return 0; +} + + + +int wifi_mgmr_rate_config(uint16_t config) + +{ + WIFI_MGMR_EVENT_T WStack32; + undefined uStack31; + undefined uStack30; + undefined uStack29; + undefined uStack28; + undefined uStack27; + undefined uStack26; + undefined uStack25; + undefined uStack24; + undefined uStack23; + undefined uStack22; + undefined uStack21; + undefined uStack20; + + memset(&WStack32,0,0xd); + WStack32 = WIFI_MGMR_EVENT_APP_RC_CONFIG; + uStack27 = 0x88; + uStack26 = 0x77; + uStack25 = 0x66; + uStack31 = (undefined)config; + uStack24 = 0x55; + uStack30 = (undefined)(config >> 8); + uStack29 = 0; + uStack28 = 0; + uStack23 = 0xd; + uStack22 = 0; + uStack21 = 0; + uStack20 = 0; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack32); + return 0; +} + + + +int wifi_mgmr_conf_max_sta(uint8_t max_sta_supported) + +{ + WIFI_MGMR_EVENT_T WStack32; + uint8_t uStack31; + undefined uStack30; + undefined uStack29; + undefined uStack28; + undefined uStack27; + undefined uStack26; + undefined uStack25; + undefined uStack24; + undefined uStack23; + undefined uStack22; + undefined uStack21; + undefined uStack20; + + memset(&WStack32,0,0xd); + WStack32 = WIFI_MGMR_EVENT_APP_CONF_MAX_STA; + uStack27 = 0x88; + uStack26 = 0x77; + uStack25 = 0x66; + uStack24 = 0x55; + uStack30 = 0; + uStack29 = 0; + uStack28 = 0; + uStack23 = 0xd; + uStack22 = 0; + uStack21 = 0; + uStack20 = 0; + uStack31 = max_sta_supported; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack32); + return 0; +} + + + +int wifi_mgmr_state_get(int *state) + +{ + uint16_t uVar1; + int iVar2; + + uVar1 = wifiMgmr.wifi_mgmr_stat_info.status_code; + if (wifiMgmr.m.currentState == &stateIdle) { + if (wifiMgmr.inf_ap_enabled != 0) { + iVar2 = 0x11; + goto LAB_230051bc; + } + iVar2 = 1; + } + else { + if (wifiMgmr.m.currentState == &stateConnecting) { + if (wifiMgmr.inf_ap_enabled != 0) { + iVar2 = 0x12; + goto LAB_230051bc; + } + iVar2 = 2; + } + else { + if (wifiMgmr.m.currentState == &stateConnectedIPNo) { + if (wifiMgmr.inf_ap_enabled == 0) { + iVar2 = 3; + } + else { + iVar2 = 0x13; + } + goto LAB_230051bc; + } + if (wifiMgmr.m.currentState == &stateConnectedIPYes) { + if (wifiMgmr.inf_ap_enabled == 0) { + iVar2 = 4; + } + else { + iVar2 = 0x14; + } + goto LAB_230051bc; + } + if (wifiMgmr.m.currentState != &stateDisconnect) { + if (wifiMgmr.m.currentState == &stateIfaceDown) { + iVar2 = 6; + } + else { + if (wifiMgmr.m.currentState != &stateSniffer) { + *state = 0; + return 0; + } + iVar2 = 7; + } + goto LAB_230051bc; + } + if (wifiMgmr.inf_ap_enabled != 0) { + iVar2 = 0x15; + goto LAB_230051bc; + } + iVar2 = 5; + } + } + *state = iVar2; + if (uVar1 == 8) { + iVar2 = 8; + } + else { + if (uVar1 != 0xc) { + return 0; + } + iVar2 = 9; + } +LAB_230051bc: + *state = iVar2; + return 0; +} + + + +int wifi_mgmr_rssi_get(int *rssi) + +{ + *rssi = (int)wifiMgmr.wlan_sta.field_5; + return 0; +} + + + +int wifi_mgmr_raw_80211_send(uint8_t *pkt,int len) + +{ + if (len < 0x1e1) { + wifi_mgmr_api_raw_send(pkt,len); + return 0; + } + return -1; +} + + + +int wifi_mgmr_scan(void *data,scan_complete_cb_t *cb) + +{ + scan_cb = cb; + scan_data = data; + wifi_mgmr_api_fw_scan(); + return 0; +} + + + +int wifi_mgmr_cfg_req(uint32_t ops,uint32_t task,uint32_t element,uint32_t type,uint32_t length, + uint32_t *buf) + +{ + int iVar1; + WIFI_MGMR_EVENT_T WStack100; + undefined uStack99; + undefined uStack98; + undefined uStack97; + undefined uStack96; + undefined uStack95; + undefined uStack94; + undefined uStack93; + undefined uStack92; + undefined uStack91; + undefined uStack90; + undefined uStack89; + undefined uStack88; + undefined uStack87; + undefined uStack86; + undefined uStack85; + undefined uStack84; + undefined uStack83; + undefined uStack82; + undefined uStack81; + undefined uStack80; + undefined uStack79; + undefined uStack78; + undefined uStack77; + undefined uStack76; + undefined uStack75; + undefined uStack74; + undefined uStack73; + undefined uStack72; + undefined uStack71; + undefined uStack70; + undefined uStack69; + undefined uStack68; + undefined auStack67 [39]; + + if (length < 0x21) { + memset(&WStack100,0,0x41); + WStack100 = WIFI_MGMR_EVENT_FW_CFG_REQ; + uStack99 = 0x44; + uStack98 = 0x33; + uStack97 = 0x22; + uStack96 = 0x11; + uStack95 = 0x88; + uStack94 = 0x77; + iVar1 = length + 0xc6; + uStack93 = 0x66; + uStack92 = 0x55; + uStack90 = (undefined)((uint)iVar1 >> 8); + uStack89 = (undefined)((uint)iVar1 >> 0x10); + uStack86 = (undefined)(ops >> 8); + uStack85 = (undefined)(ops >> 0x10); + uStack82 = (undefined)(task >> 8); + uStack81 = (undefined)(task >> 0x10); + uStack78 = (undefined)(element >> 8); + uStack77 = (undefined)(element >> 0x10); + uStack74 = (undefined)(type >> 8); + uStack73 = (undefined)(type >> 0x10); + uStack91 = (undefined)iVar1; + uStack87 = (undefined)ops; + uStack83 = (undefined)task; + uStack79 = (undefined)element; + uStack75 = (undefined)type; + uStack70 = (undefined)(length >> 8); + uStack69 = (undefined)(length >> 0x10); + uStack88 = (undefined)((uint)iVar1 >> 0x18); + uStack84 = (undefined)(ops >> 0x18); + uStack80 = (undefined)(task >> 0x18); + uStack76 = (undefined)(element >> 0x18); + uStack72 = (undefined)(type >> 0x18); + uStack71 = (undefined)length; + uStack68 = (undefined)(length >> 0x18); + if (length != 0) { + memcpy(auStack67,buf,length); + } + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&WStack100); + return 0; + } + return -1; +} + + + +int wifi_mgmr_scan_filter_hidden_ssid(int filter) + +{ + vTaskEnterCritical(); + if (filter == 0) { + wifiMgmr.features = wifiMgmr.features | 1; + } + else { + wifiMgmr.features = wifiMgmr.features & 0xfffffffe; + } + vTaskExitCritical(); + return 0; +} + + + +int wifi_mgmr_scan_complete_callback(void) + +{ + char "wifi_mgmr_scan_complete_callback" [33]; + undefined4 uStack20; + int status; + + uStack20 = 0; + printf("%s: scan complete\r\n","wifi_mgmr_scan_complete_callback"); + if (scan_cb != (scan_complete_cb_t *)0x0) { + uStack20 = 1; + (*scan_cb)(scan_data,&uStack20); + } + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int wifi_mgmr_scan_ap_all(wifi_mgmr_ap_item_t *env,uint32_t *param1,scan_item_cb_t *cb) + +{ + wifi_mgmr_t *pwVar1; + TickType_t TVar2; + undefined auStack84 [4]; + wifi_mgmr_ap_item_t item; + + pwVar1 = &wifiMgmr; + do { + if (pwVar1->scan_items[0].is_used != '\0') { + TVar2 = xTaskGetTickCount(); + if (TVar2 - pwVar1->scan_items[0].timestamp_lastseen < (uint)wifiMgmr.scan_item_timeout) { + memcpy(auStack84,pwVar1->scan_items,0x20); + item.ssid[28] = '\0'; + item._32_4_ = strlen(auStack84); + memcpy(&item.ssid_len,pwVar1->scan_items[0].bssid,6); + item.bssid[2] = pwVar1->scan_items[0].channel; + item.bssid[4] = pwVar1->scan_items[0].rssi; + item.bssid[3] = pwVar1->scan_items[0].auth; + (*cb)(env,param1,(wifi_mgmr_ap_item_t *)auStack84); + } + } + pwVar1 = (wifi_mgmr_t *)&(pwVar1->wlan_sta).netif.input; + } while (pwVar1 != (wifi_mgmr_t *)0x42017b54); + return 0; +} + + + +char * wifi_mgmr_status_code_str(uint16_t status_code) + +{ + undefined2 in_register_0000202a; + + if (CONCAT22(in_register_0000202a,status_code) < 0x11) { + return *(char **)(CSWTCH_17 + CONCAT22(in_register_0000202a,status_code) * 4); + } + return "Unknown Status Code"; +} + + + +int wifi_mgmr_profile_add(wifi_mgmr_t *mgmr,wifi_mgmr_profile_msg_t *profile_msg,int index) + +{ + wifi_mgmr_profile_t *__s; + int iVar1; + + if (index == -1) { + __s = mgmr->profiles; + if (__s == (wifi_mgmr_profile_t *)0x0) { + return -1; + } + } + else { + if (mgmr->profiles[0].isUsed == '\0') { + iVar1 = 0; + } + else { + if (mgmr->profiles[1].isUsed != '\0') { + return -1; + } + iVar1 = 1; + } + mgmr->profile_active_index = iVar1; + __s = mgmr->profiles + iVar1; + printf("[WF][PF] Using free profile, idx is @%d\r\n"); + } + memset(__s,0,0xc4); + *(undefined2 *)&__s->isActive = 0x100; + __s->ssid_len = profile_msg->ssid_len; + __s->psk_len = profile_msg->psk_len; + __s->pmk_len = profile_msg->pmk_len; + __s->priority = -1; + memcpy(__s,profile_msg,0x21); + memcpy(__s->psk,profile_msg->psk,0x41); + memcpy(__s->pmk,profile_msg->pmk,0x41); + memcpy(__s->mac,profile_msg->mac,6); + __s->dhcp_use = profile_msg->dhcp_use; + return 0; +} + + + +int wifi_mgmr_profile_get(wifi_mgmr_t *mgmr,wifi_mgmr_profile_msg_t *profile_msg) + +{ + int iVar1; + uint8_t *puVar2; + undefined4 uVar3; + + if (mgmr->profiles[0].isUsed == '\x01') { + iVar1 = 0; + } + else { + iVar1 = 1; + if (mgmr->profiles[1].isUsed != '\x01') { + return -1; + } + } + printf("[WF][PF] Using profile, idx is @%d\r\n",iVar1); + memset(profile_msg,0,0xb9); + puVar2 = &mgmr->ready + iVar1 * 0xc4; + uVar3 = *(undefined4 *)(puVar2 + 0x114); + *(char *)&profile_msg->ssid_len = (char)uVar3; + *(undefined *)((int)&profile_msg->ssid_len + 1) = (char)((uint)uVar3 >> 8); + *(undefined *)((int)&profile_msg->ssid_len + 2) = (char)((uint)uVar3 >> 0x10); + *(undefined *)((int)&profile_msg->ssid_len + 3) = (char)((uint)uVar3 >> 0x18); + uVar3 = *(undefined4 *)(puVar2 + 0x15c); + *(char *)&profile_msg->psk_len = (char)uVar3; + *(undefined *)((int)&profile_msg->psk_len + 1) = (char)((uint)uVar3 >> 8); + *(undefined *)((int)&profile_msg->psk_len + 2) = (char)((uint)uVar3 >> 0x10); + *(undefined *)((int)&profile_msg->psk_len + 3) = (char)((uint)uVar3 >> 0x18); + uVar3 = *(undefined4 *)(puVar2 + 0x1a4); + *(char *)&profile_msg->pmk_len = (char)uVar3; + *(undefined *)((int)&profile_msg->pmk_len + 1) = (char)((uint)uVar3 >> 8); + *(undefined *)((int)&profile_msg->pmk_len + 2) = (char)((uint)uVar3 >> 0x10); + *(undefined *)((int)&profile_msg->pmk_len + 3) = (char)((uint)uVar3 >> 0x18); + profile_msg->dhcp_use = puVar2[0x1ae]; + memcpy(profile_msg,mgmr->profiles + iVar1,0x21); + memcpy(profile_msg->psk,mgmr->profiles[iVar1].psk,0x41); + memcpy(profile_msg->pmk,mgmr->profiles[iVar1].pmk,0x41); + memcpy(profile_msg->mac,mgmr->profiles[iVar1].mac,6); + return 0; +} + + + +int wifi_mgmr_profile_autoreconnect_is_enabled(wifi_mgmr_t *mgmr,int index) + +{ + return (uint)(mgmr->disable_autoreconnect == '\0'); +} + + + +int wifi_mgmr_profile_autoreconnect_disable(wifi_mgmr_t *mgmr,int index) + +{ + mgmr->disable_autoreconnect = '\x01'; + return 0; +} + + + +int wifi_mgmr_profile_autoreconnect_enable(wifi_mgmr_t *mgmr,int index) + +{ + mgmr->disable_autoreconnect = '\0'; + return 0; +} + + + +int wifi_netif_dhcp_start(netif *netif) + +{ + netifapi_netif_common(netif,(netifapi_void_fn)0x0,dhcp_start); + return 0; +} + + + +void cb_rssi_ind(void *env,int8_t rssi) + +{ + wifiMgmr.wlan_sta.field_5 = rssi; + return; +} + + + +void cb_probe_resp_ind(void *env) + +{ + printf("timestamp = 0x%llx\r\n"); + return; +} + + + +void cb_beacon_ind(void *env,wifi_event_beacon_ind *ind) + +{ + wifi_mgmr_api_scan_item_beacon + (ind->channel,ind->rssi,ind->auth,(uint8_t *)ind,ind->ssid,ind->ssid_len,ind->ppm_abs, + ind->ppm_rel,DAT_00000010); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void cb_disconnect_ind(void *env,wifi_event_sm_disconnect_ind *ind) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + wifi_mgmr_msg_t msg_wifi; + + memset(&local_20,0,0xd); + printf("sending disconnect\r\n"); + local_20 = WIFI_MGMR_EVENT_FW_IND_DISCONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + msg_wifi.ev = WIFI_MGMR_EVENT_FW_CHANNEL_SET; + msg_wifi.data1._0_1_ = 0x88; + msg_wifi.data1._1_1_ = 0x77; + msg_wifi.data1._2_1_ = 0x66; + msg_wifi.data1._3_1_ = 0x55; + msg_wifi.data2._0_1_ = 0xd; + wifiMgmr.wifi_mgmr_stat_info.type_ind = '\x02'; + wifiMgmr.wifi_mgmr_stat_info.status_code = ind->reason_code; + msg_wifi.data2._1_1_ = 0; + msg_wifi.data2._2_1_ = 0; + msg_wifi.data2._3_1_ = 0; + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void cb_connect_ind(void *env,wifi_event_sm_connect_ind *ind) + +{ + WIFI_MGMR_EVENT_T local_20; + undefined uStack31; + undefined uStack30; + undefined uStack29; + wifi_mgmr_msg_t msg_wifi; + + memset(&local_20,0,0xd); + local_20 = (ind->status_code == 0) + WIFI_MGMR_EVENT_FW_IND_DISCONNECT; + uStack31 = 0x44; + uStack30 = 0x33; + uStack29 = 0x22; + msg_wifi.ev = WIFI_MGMR_EVENT_FW_CHANNEL_SET; + msg_wifi.data1._0_1_ = 0x88; + msg_wifi.data1._1_1_ = 0x77; + msg_wifi.data1._2_1_ = 0x66; + msg_wifi.data1._3_1_ = 0x55; + msg_wifi.data2._0_1_ = 0xd; + msg_wifi.data2._1_1_ = 0; + msg_wifi.data2._2_1_ = 0; + msg_wifi.data2._3_1_ = 0; + wifi_mgmr_set_connect_stat_info(ind,'\x01'); + wifi_mgmr_event_notify((wifi_mgmr_msg_t *)&local_20); + return; +} + + + +void cb_event_ind(void *env,wifi_event *event) + +{ + int iVar1; + uint16_t code; + uint32_t uVar2; + + uVar2 = event->id; + if (uVar2 == 1) { + puts("[WIFI] [IND] SCAN Done\r\n"); + wifi_mgmr_scan_complete_notify(); + code = 9; +LAB_23007bdc: + aos_post_event(2,code,0); + return; + } + if (uVar2 == 0) { + uVar2 = event[1].id; + iVar1 = 0x6bc; + wifiMgmr.channel = uVar2; + } + else { + if (uVar2 == 2) { + code = 10; + goto LAB_23007bdc; + } + iVar1 = 0x6f8; + } + printf("wifi current state: WIFI_STATE_WITH_AP_CONNECTED_IP_GETTING\r\n" + iVar1 + 0x28,uVar2); + return; +} + + + +int wifi_mgmr_event_init(void) + +{ + bl_rx_sm_connect_ind_cb_register((void *)0x0,cb_connect_ind); + bl_rx_sm_disconnect_ind_cb_register((void *)0x0,cb_disconnect_ind); + bl_rx_beacon_ind_cb_register((void *)0x0,cb_beacon_ind); + bl_rx_probe_resp_ind_cb_register((void *)0x0,cb_probe_resp_ind); + bl_rx_rssi_cb_register((void *)0x0,cb_rssi_ind); + bl_rx_event_register((void *)0x0,cb_event_ind); + return 0; +} + + + +int bl_main_disconnect(void) + +{ + bl_send_sm_disconnect_req(&wifi_hw,0x34); + return 0; +} + + + +int bl_main_powersaving(int mode) + +{ + int iVar1; + + iVar1 = bl_send_mm_powersaving_req(&wifi_hw,mode); + return iVar1; +} + + + +int bl_main_denoise(int mode) + +{ + int iVar1; + + iVar1 = bl_send_mm_denoise_req(&wifi_hw,mode); + return iVar1; +} + + + +int bl_main_monitor(void) + +{ + undefined auStack56 [4]; + mm_monitor_cfm cfm; + + memset(auStack56,0,0x28); + bl_send_monitor_enable(&wifi_hw,(mm_monitor_cfm *)auStack56); + return 0; +} + + + +int bl_main_phy_up(void) + +{ + int iVar1; + + iVar1 = bl_send_start(&wifi_hw); + if (iVar1 == 0) { + wifi_hw.drv_flags = wifi_hw.drv_flags | 4; + } + else { + iVar1 = -1; + } + return iVar1; +} + + + +int bl_main_monitor_channel_set(int channel,int use_40MHZ) + +{ + undefined auStack56 [4]; + mm_monitor_channel_cfm cfm; + + bl_send_monitor_channel_set(&wifi_hw,(mm_monitor_channel_cfm *)auStack56,channel,use_40MHZ); + return 0; +} + + + +int bl_main_if_remove(uint8_t vif_index) + +{ + undefined3 in_register_00002029; + + printf("[WF] MM_REMOVE_IF_REQ Sending with vif_index %u...\r\n", + CONCAT31(in_register_00002029,vif_index)); + bl_send_remove_if(&wifi_hw,vif_index); + printf("[WF] MM_REMOVE_IF_REQ Done\r\n"); + return 0; +} + + + +int bl_main_raw_send(uint8_t *pkt,int len) + +{ + int iVar1; + + iVar1 = bl_send_scanu_raw_send(&wifi_hw,pkt,len); + return iVar1; +} + + + +int bl_main_rate_config(uint8_t sta_idx,uint16_t fixed_rate_cfg) + +{ + int iVar1; + + iVar1 = bl_send_me_rate_config_req(&wifi_hw,sta_idx,fixed_rate_cfg); + return iVar1; +} + + + +int bl_main_set_country_code(char *country_code) + +{ + bl_msg_update_channel_cfg(country_code); + bl_send_me_chan_config_req(&wifi_hw); + return 0; +} + + + +int bl_main_get_channel_nums(void) + +{ + return channel_num_default; +} + + + +int bl_main_if_add(int is_sta,netif *netif,uint8_t *vif_index) + +{ + uint uVar1; + int iVar2; + undefined *puVar3; + mm_add_if_cfm amStack36 [2]; + mm_add_if_cfm add_if_cfm; + + if (is_sta == 0) { + puVar3 = &UNK_23071888; + } + else { + puVar3 = &UNK_23071884; + } + printf("[WF] MM_ADD_IF_REQ Sending: %s\r\n",puVar3); + iVar2 = bl_send_add_if(&wifi_hw,netif->hwaddr,(is_sta == 0) + NL80211_IFTYPE_STATION,false, + amStack36); + printf("[WF] MM_ADD_IF_REQ Done\r\n"); + if (iVar2 == 0) { + if (amStack36[0].status == '\0') { + uVar1 = (uint)amStack36[0].inst_nbr; + if (is_sta != 0) { + wifi_hw.vif_index_sta = (uint)amStack36[0].inst_nbr; + uVar1 = wifi_hw.vif_index_ap; + } + wifi_hw.vif_index_ap = uVar1; + *vif_index = amStack36[0].inst_nbr; + printf("[WF] vif_index from LAMC is %d\r\n"); + wifi_hw.vif_table[amStack36[0].inst_nbr].dev = netif; + wifi_hw.vif_table[amStack36[0].inst_nbr].up = true; + } + else { + printf("%s: Status Error(%d)\n",&UNK_230718cc); + iVar2 = -5; + } + } + return iVar2; +} + + + +int bl_main_apm_start(char *ssid,char *password,int channel,uint8_t vif_index,uint8_t hidden_ssid) + +{ + int iVar1; + undefined3 in_register_00002035; + apm_start_cfm local_24; + apm_start_cfm start_ap_cfm; + + memset(&local_24,0,4); + printf("[WF] APM_START_REQ Sending with vif_index %u\r\n",CONCAT31(in_register_00002035,vif_index) + ); + iVar1 = bl_send_apm_start_req(&wifi_hw,&local_24,ssid,password,channel,vif_index,hidden_ssid); + printf("[WF] APM_START_REQ Done\r\n"); + printf("[WF] status is %02X\r\n",(uint)local_24.status); + printf("[WF] vif_idx is %02X\r\n",(uint)local_24.vif_idx); + printf("[WF] ch_idx is %02X\r\n",(uint)local_24.ch_idx); + printf("[WF] bcmc_idx is %02X\r\n",(uint)local_24.bcmc_idx); + wifi_hw.ap_bcmc_idx = (uint)local_24.bcmc_idx; + return iVar1; +} + + + +int bl_main_apm_stop(uint8_t vif_index) + +{ + undefined3 in_register_00002029; + int iVar1; + + printf("[WF] APM_STOP_REQ Sending with vif_index %u\r\n",CONCAT31(in_register_00002029,vif_index)) + ; + iVar1 = bl_send_apm_stop_req(&wifi_hw,vif_index); + printf("[WF] APM_STOP_REQ Done\r\n"); + return iVar1; +} + + + +int bl_main_apm_sta_cnt_get(uint8_t *sta_cnt) + +{ + *sta_cnt = '\f'; + return 0; +} + + + +int bl_main_apm_sta_info_get(wifi_apm_sta_info *apm_sta_info,uint8_t idx) + +{ + undefined3 in_register_0000202d; + int iVar1; + + iVar1 = CONCAT31(in_register_0000202d,idx); + if (wifi_hw.sta_table[iVar1].is_used != '\0') { + apm_sta_info->sta_idx = wifi_hw.sta_table[iVar1].sta_idx; + apm_sta_info->is_used = wifi_hw.sta_table[iVar1].is_used; + apm_sta_info->rssi = (int)wifi_hw.sta_table[iVar1].rssi; + apm_sta_info->tsflo = wifi_hw.sta_table[iVar1].tsflo; + apm_sta_info->tsfhi = wifi_hw.sta_table[iVar1].tsfhi; + apm_sta_info->data_rate = wifi_hw.sta_table[iVar1].data_rate; + memcpy(apm_sta_info->sta_mac,wifi_hw.sta_table + iVar1,6); + return 0; + } + return 0; +} + + + +int bl_main_apm_sta_delete(uint8_t sta_idx) + +{ + byte vif_idx; + undefined3 in_register_00002029; + int iVar1; + int iVar2; + apm_sta_del_cfm aStack36; + apm_sta_del_cfm sta_del_cfm; + + iVar1 = CONCAT31(in_register_00002029,sta_idx); + memset(&aStack36,0,3); + vif_idx = wifi_hw.sta_table[iVar1].vif_idx; + printf("[WF] APM_STA_DEL_REQ: sta_idx = %u, vif_idx = %u\r\n",iVar1,(uint)vif_idx); + bl_send_apm_sta_del_req(&wifi_hw,&aStack36,sta_idx,vif_idx); + iVar2 = -1; + if (aStack36.status == '\0') { + memset(wifi_hw.sta_table + iVar1,0,0x1c); + iVar2 = 0; + } + return iVar2; +} + + + +int bl_main_apm_remove_all_sta(void) + +{ + uint8_t sta_idx; + u8 *puVar1; + + puVar1 = &wifi_hw.sta_table[0].is_used; + sta_idx = '\0'; + do { + if (*puVar1 == '\x01') { + bl_main_apm_sta_delete(sta_idx); + } + sta_idx = sta_idx + '\x01'; + puVar1 = puVar1 + 0x1c; + } while (sta_idx != '\f'); + return 0; +} + + + +int bl_main_conf_max_sta(uint8_t max_sta_supported) + +{ + int iVar1; + + iVar1 = bl_send_apm_conf_max_sta_req(&wifi_hw,max_sta_supported); + return iVar1; +} + + + +int bl_main_cfg_task_req + (uint32_t ops,uint32_t task,uint32_t element,uint32_t type,void *arg1,void *arg2) + +{ + int iVar1; + + iVar1 = bl_send_cfg_task_req(&wifi_hw,ops,task,element,type,arg1,arg2); + return iVar1; +} + + + +int bl_main_scan(void) + +{ + bl_send_scanu_req(&wifi_hw); + return 0; +} + + + +int bl_cfg80211_connect(bl_hw *bl_hw,cfg80211_connect_params *sme) + +{ + int iVar1; + sm_connect_cfm asStack20 [4]; + sm_connect_cfm sm_connect_cfm; + + iVar1 = bl_send_sm_connect_req(bl_hw,sme,asStack20); + if (iVar1 == 0) { + iVar1 = -5; + if ((byte)asStack20[0] < 10) { + iVar1 = (int)(char)CSWTCH_6[(byte)asStack20[0]]; + } + } + return iVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bl_main_connect(uint8_t *ssid,int ssid_len,uint8_t *psk,int psk_len,uint8_t *pmk,int pmk_len, + uint8_t *mac,uint8_t band,uint16_t freq) + +{ + short in_stack_00000000; + nl80211_band anStack272 [4]; + cfg80211_connect_params sme; + + memset(anStack272,0,0xf0); + sme.crypto.cipher_group = 0; + sme.ssid_len._0_1_ = __NL80211_AUTHTYPE_NUM; + sme.pmk._0_1_ = (u8)psk_len; + sme.pmk._1_1_ = (u8)pmk_len; + if (mac != (uint8_t *)0x0) { + sme.channel_hint = (ieee80211_channel *)mac; + } + if (in_stack_00000000 != 0) { + sme.channel._4_4_ = 0; + anStack272[0] = band; + } + sme.bssid_hint = ssid; + sme.ssid = (u8 *)ssid_len; + sme.crypto.wep_tx_key = (int)psk; + sme.key = pmk; + bl_cfg80211_connect(&wifi_hw,(cfg80211_connect_params *)anStack272); + return 0; +} + + + +void bl_main_event_handle(void) + +{ + bl_irq_bottomhalf(&wifi_hw); + bl_tx_try_flush(); + return; +} + + + +void bl_main_lowlevel_init(void) + +{ + bl_irqs_init(&wifi_hw); + return; +} + + + +int bl_main_rtthread_start(bl_hw **bl_hw) + +{ + int iVar1; + char *fmt; + + bl_main_lowlevel_init(); + *bl_hw = &wifi_hw; + wifi_hw.vifs.next = &wifi_hw.vifs; + wifi_hw.vifs.prev = &wifi_hw.vifs; + wifi_hw.mod_params = &bl_mod_params; + iVar1 = bl_platform_on(&wifi_hw); + if (iVar1 == 0) { + ipc_host_enable_irq(wifi_hw.ipc_env,0x7ff); + bl_wifi_enable_irq(); + iVar1 = bl_send_reset(&wifi_hw); + if (iVar1 == 0) { + vTaskDelay(5); + iVar1 = bl_send_version_req(&wifi_hw,&wifi_hw.version_cfm); + if (iVar1 != 0) { + return 0; + } + printf("[version] lmac %u.%u.%u.%u\r\n",wifi_hw.version_cfm.version_lmac >> 0x18, + wifi_hw.version_cfm.version_lmac >> 0x10 & 0xff, + wifi_hw.version_cfm.version_lmac >> 8 & 0xff,wifi_hw.version_cfm.version_lmac & 0xff); + printf("[version] version_machw_1 %08X\r\n",wifi_hw.version_cfm.version_machw_1); + printf("[version] version_machw_2 %08X\r\n",wifi_hw.version_cfm.version_machw_2); + printf("[version] version_phy_1 %08X\r\n",wifi_hw.version_cfm.version_phy_1); + printf("[version] version_phy_2 %08X\r\n",wifi_hw.version_cfm.version_phy_2); + printf("[version] features %08X\r\n",wifi_hw.version_cfm.features); + iVar1 = bl_handle_dynparams(&wifi_hw); + if (iVar1 == 0) { + bl_send_me_config_req(&wifi_hw); + bl_send_me_chan_config_req(&wifi_hw); + wifi_hw.status = RWNX_INTERFACE_STATUS_UP; + return 0; + } + fmt = "bl_handle_dynparams Error\r\n"; + } + else { + fmt = "bl_send_reset Error\r\n"; + } + } + else { + fmt = "bl_platform_on Error\r\n"; + } + printf(fmt); + return 0; +} + + + +int bl_handle_dynparams(bl_hw *bl_hw) + +{ + ushort uVar1; + short sVar2; + char "bl_handle_dynparams" [20]; + int iVar3; + short sVar4; + uint uVar5; + bl_mod_params *pbVar6; + + uVar5 = bl_hw->flags; + bl_hw->flags = uVar5 | 0x40000; + pbVar6 = bl_hw->mod_params; + if (pbVar6->tdls != false) { + bl_hw->flags = uVar5 | 0x58000; + } + if (pbVar6->ap_uapsd_on != false) { + bl_hw->flags = bl_hw->flags | 0x4000; + } + if (5 < (uint)pbVar6->phy_cfg) { + pbVar6->phy_cfg = 2; + } + if (2 < (uint)bl_hw->mod_params->mcs_map) { + bl_hw->mod_params->mcs_map = 0; + } + uVar1 = (bl_hw->ht_cap).cap; + pbVar6 = bl_hw->mod_params; + iVar3 = pbVar6->nss; + (bl_hw->ht_cap).cap = uVar1 | 0x100; + if (pbVar6->ldpc_on != false) { + (bl_hw->ht_cap).cap = uVar1 | 0x101; + } + sVar2 = (short)iVar3; + if (pbVar6->use_2040 == false) { + (bl_hw->ht_cap).mcs.rx_highest = sVar2 * 0x41; + (bl_hw->ht_cap).mcs.rx_mask[0] = -1; + } + else { + uVar1 = (bl_hw->ht_cap).cap; + (bl_hw->ht_cap).mcs.rx_mask[4] = '\x01'; + (bl_hw->ht_cap).cap = uVar1 | 2; + (bl_hw->ht_cap).mcs.rx_highest = sVar2 * 0x87; + } + if (1 < iVar3) { + (bl_hw->ht_cap).cap = (bl_hw->ht_cap).cap | 0x80; + } + if (pbVar6->sgi != false) { + uVar1 = (bl_hw->ht_cap).cap; + (bl_hw->ht_cap).cap = uVar1 | 0x20; + if (pbVar6->use_2040 == false) { + sVar4 = 0x48; + } + else { + (bl_hw->ht_cap).cap = uVar1 | 0x60; + sVar4 = 0x96; + } + (bl_hw->ht_cap).mcs.rx_highest = sVar2 * sVar4; + } + (bl_hw->ht_cap).cap = (bl_hw->ht_cap).cap | 0xc; + if (pbVar6->ht_on == false) { + (bl_hw->ht_cap).ht_supported = false; + } + if (pbVar6->custregd != false) { + printf("\n\n%s: CAUTION: USING PERMISSIVE CUSTOM REGULATORY RULES\n\n","bl_handle_dynparams"); + return 0; + } + return 0; +} + + + +int bl_send_msg(bl_hw *bl_hw,void *msg_params,int reqcfm,lmac_msg_id_t reqid,void *cfm) + +{ + ushort uVar1; + lmac_msg_id_t lVar2; + bool bVar3; + char "bl_send_msg" [12]; + bl_cmd *__s; + int iVar4; + undefined2 in_register_00002036; + lmac_msg *pv; + + iVar4 = CONCAT22(in_register_00002036,reqid); + pv = (lmac_msg *)((int)msg_params + -8); + if ((((((bl_hw->drv_flags >> 2 & 1) == 0) && ((reqid & 0xfffd) != 1)) && (iVar4 != 5)) && + ((iVar4 != 0x23 && ((reqid & 0xfffd) != 0x1401)))) && (iVar4 != 0x32)) { + printf("%s: bypassing (RWNX_DEV_RESTARTING set) 0x%02x\n","bl_send_msg",iVar4); + } + else { + if (bl_hw->ipc_env != (ipc_host_env_tag *)0x0) { + uVar1 = *(ushort *)((int)msg_params + -8); + bVar3 = true; + if (((uVar1 != 0x41) && (uVar1 != 0x50)) && ((uVar1 + 0xebf4 & 0xfffb) != 0)) { + bVar3 = (uVar1 & 0xfffb) == 0x2408; + } + __s = (bl_cmd *)pvPortMalloc(0x40); + if (__s == (bl_cmd *)0x0) { + vPortFree(pv); + printf("%s: failed to allocate mem for cmd, size is %d\r\n",0x23071b08,0x40); + return -0xc; + } + memset(__s,0,0x40); + __s->result = 4; + lVar2 = *(lmac_msg_id_t *)((int)msg_params + -8); + __s->reqid = reqid; + __s->a2e_msg = pv; + __s->id = lVar2; + __s->e2a_msg = cfm; + if (bVar3) { + __s->flags = 1; + } + if (reqcfm != 0) { + __s->flags = __s->flags | 2; + } + iVar4 = (*(bl_hw->cmd_mgr).queue)(&bl_hw->cmd_mgr,__s); + if (!bVar3) { + vPortFree(__s); + return iVar4; + } + return __s->result; + } + printf("%s: bypassing (restart must have failed)\r\n",0x23071b08); + } + vPortFree(pv); + return -0x10; +} + + + +void * bl_msg_zalloc(lmac_msg_id_t id,lmac_task_id_t dest_id,uint16_t param_len) + +{ + lmac_msg_id_t *__s; + undefined2 in_register_00002032; + size_t xWantedSize; + + xWantedSize = CONCAT22(in_register_00002032,param_len) + 8; + __s = (lmac_msg_id_t *)pvPortMalloc(xWantedSize); + if (__s == (lmac_msg_id_t *)0x0) { + printf("%s: msg allocation failed\n",0x23071af8); + } + else { + memset(__s,0,xWantedSize); + *__s = id; + __s[1] = dest_id; + __s[2] = 100; + __s[3] = param_len; + __s = __s + 4; + } + return __s; +} + + + +void bl_msg_update_channel_cfg(char *code) + +{ + int iVar1; + int iVar2; + char *fmt; + ieee80211_dot_d *piVar3; + + piVar3 = country_list; + iVar1 = 0; + do { + iVar2 = strcmp(piVar3->code,code); + if (iVar2 == 0) { + fmt = "[WF] country code %s used, num of channel %d\r\n"; + channel_num_default = country_list[iVar1].channel_num; + channels_default = country_list[iVar1].channels; + goto LAB_23008642; + } + iVar1 = iVar1 + 1; + piVar3 = piVar3 + 1; + } while (iVar1 != 4); + channel_num_default = 0xe; + channels_default = bl_channels_24_JP; + fmt = "[WF] %s NOT found, using JP instead, num of channel %d\r\n"; +LAB_23008642: + printf(fmt,code,channel_num_default); + return; +} + + + +int bl_msg_get_channel_nums(void) + +{ + return channel_num_default; +} + + + +int bl_send_reset(bl_hw *bl_hw) + +{ + void *msg_params; + int iVar1; + + msg_params = bl_msg_zalloc(0,0,0); + if (msg_params != (void *)0x0) { + iVar1 = bl_send_msg(bl_hw,msg_params,1,1,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_monitor_enable(bl_hw *bl_hw,mm_monitor_cfm *cfm) + +{ + undefined4 *msg_params; + int iVar1; + + msg_params = (undefined4 *)bl_msg_zalloc(0x5c,0,4); + if (msg_params != (undefined4 *)0x0) { + *msg_params = 1; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x5d,cfm); + return iVar1; + } + return -0xc; +} + + + +int bl_send_monitor_channel_set(bl_hw *bl_hw,mm_monitor_channel_cfm *cfm,int channel,int use_40Mhz) + +{ + uint uVar1; + uint *msg_params; + int iVar2; + + msg_params = (uint *)bl_msg_zalloc(0x5e,0,0xc); + if (msg_params == (uint *)0x0) { + return -0xc; + } + if (channel - 1U < 0xe) { + if (channel == 0xe) { + uVar1 = 0x9b4; + } + else { + uVar1 = channel * 5 + 0x967U & 0xffff; + } + } + else { + uVar1 = 0xffff; + } + *msg_params = uVar1; + if (use_40Mhz == 0) { + msg_params[1] = 0; + } + else { + msg_params[1] = 1; + if (use_40Mhz != 1) { + msg_params[2] = 1; + goto LAB_23008764; + } + } + msg_params[2] = 0; +LAB_23008764: + iVar2 = bl_send_msg(bl_hw,msg_params,1,0x5f,cfm); + return iVar2; +} + + + +int bl_send_version_req(bl_hw *bl_hw,mm_version_cfm *cfm) + +{ + void *msg_params; + int iVar1; + + msg_params = bl_msg_zalloc(4,0,0); + if (msg_params != (void *)0x0) { + iVar1 = bl_send_msg(bl_hw,msg_params,1,5,cfm); + return iVar1; + } + return -0xc; +} + + + +int bl_send_me_config_req(bl_hw *bl_hw) + +{ + u8 *puVar1; + u16 *msg_params; + int iVar2; + u8 *puVar3; + ieee80211_mcs_info *piVar4; + + msg_params = (u16 *)bl_msg_zalloc(0x1400,5,0x34); + if (msg_params != (u16 *)0x0) { + printf("[ME] HT supp %d, VHT supp %d\r\n",1,0); + msg_params[0x17] = 1; + *msg_params = (bl_hw->ht_cap).cap; + *(u8 *)(msg_params + 1) = (bl_hw->ht_cap).ampdu_density << 2 | (bl_hw->ht_cap).ampdu_factor; + piVar4 = &(bl_hw->ht_cap).mcs; + puVar3 = (u8 *)((int)msg_params + 3); + while (piVar4 != (ieee80211_mcs_info *)&bl_hw->vif_started) { + puVar1 = piVar4->rx_mask; + piVar4 = (ieee80211_mcs_info *)(piVar4->rx_mask + 1); + *puVar3 = *puVar1; + puVar3 = puVar3 + 1; + } + msg_params[10] = 0; + *(undefined4 *)(msg_params + 0xc) = 0; + *(undefined *)(msg_params + 0xe) = 0; + *(_Bool *)(msg_params + 0x18) = bl_hw->mod_params->ps_on; + msg_params[0x16] = (u16)bl_hw->mod_params->tx_lft; + iVar2 = bl_send_msg(bl_hw,msg_params,1,0x1401,(void *)0x0); + return iVar2; + } + return -0xc; +} + + + +int bl_send_me_chan_config_req(bl_hw *bl_hw) + +{ + byte bVar1; + void *msg_params; + int iVar2; + uint uVar3; + u16 *puVar4; + + msg_params = bl_msg_zalloc(0x1402,5,0xfe); + if (msg_params == (void *)0x0) { + return -0xc; + } + *(undefined *)((int)msg_params + 0xfc) = 0; + iVar2 = 0; + while (iVar2 < channel_num_default) { + bVar1 = *(byte *)((int)msg_params + 0xfc); + puVar4 = (u16 *)((uint)bVar1 * 6 + (int)msg_params); + *(undefined *)((int)puVar4 + 3) = 0; + if ((channels_default[iVar2].flags & 1) != 0) { + *(undefined *)((int)puVar4 + 3) = 2; + } + uVar3 = channels_default[iVar2].flags; + *(undefined *)(puVar4 + 1) = 0; + *(byte *)((int)puVar4 + 3) = (uVar3 & 10) != 0 | *(byte *)((int)puVar4 + 3); + *puVar4 = channels_default[iVar2].center_freq; + *(char *)(puVar4 + 2) = (char)channels_default[iVar2].max_power; + uVar3 = (uint)bVar1 + 1 & 0xff; + *(undefined *)((int)msg_params + 0xfc) = (char)uVar3; + if (uVar3 == 0xe) break; + iVar2 = iVar2 + 1; + } + *(undefined *)((int)msg_params + 0xfd) = 0; + iVar2 = bl_send_msg(bl_hw,msg_params,1,0x1403,(void *)0x0); + return iVar2; +} + + + +int bl_send_me_rate_config_req(bl_hw *bl_hw,uint8_t sta_idx,uint16_t fixed_rate_cfg) + +{ + uint8_t *msg_params; + int iVar1; + + msg_params = (uint8_t *)bl_msg_zalloc(0x1410,5,4); + if (msg_params != (uint8_t *)0x0) { + *msg_params = sta_idx; + *(uint16_t *)(msg_params + 2) = fixed_rate_cfg; + iVar1 = bl_send_msg(bl_hw,msg_params,0,0,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_start(bl_hw *bl_hw) + +{ + void *__dest; + int iVar1; + + __dest = bl_msg_zalloc(2,0,0x48); + if (__dest != (void *)0x0) { + (bl_hw->phy_config).parameters[0] = 1; + memcpy(__dest,&bl_hw->phy_config,0x40); + *(int *)((int)__dest + 0x40) = bl_hw->mod_params->uapsd_timeout; + *(undefined2 *)((int)__dest + 0x44) = (short)bl_hw->mod_params->lp_clk_ppm; + iVar1 = bl_send_msg(bl_hw,__dest,1,3,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_add_if(bl_hw *bl_hw,uchar *mac,nl80211_iftype iftype,_Bool p2p,mm_add_if_cfm *cfm) + +{ + undefined *msg_params; + int iVar1; + undefined uVar2; + + msg_params = (undefined *)bl_msg_zalloc(6,0,8); + if (msg_params == (undefined *)0x0) { + return -0xc; + } + memcpy(msg_params + 1,mac,6); + switch((uint)iftype - 1 & 0xff) { + case 0: + uVar2 = 1; + break; + case 3: + return -1; + case 6: + uVar2 = 3; + break; + case 7: + msg_params[7] = 1; + default: + *msg_params = 0; + goto LAB_23008a6e; + case 8: + msg_params[7] = 1; + case 2: + uVar2 = 2; + } + *msg_params = uVar2; +LAB_23008a6e: + iVar1 = bl_send_msg(bl_hw,msg_params,1,7,cfm); + return iVar1; +} + + + +int bl_send_remove_if(bl_hw *bl_hw,uint8_t inst_nbr) + +{ + uint8_t *msg_params; + int iVar1; + + msg_params = (uint8_t *)bl_msg_zalloc(8,0,1); + if (msg_params != (uint8_t *)0x0) { + *msg_params = inst_nbr; + iVar1 = bl_send_msg(bl_hw,msg_params,1,9,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_scanu_req(bl_hw *bl_hw) + +{ + u16 uVar1; + u16 *msg_params; + int iVar2; + ieee80211_channel *piVar3; + int iVar4; + u16 *puVar5; + + msg_params = (u16 *)bl_msg_zalloc(0x1000,4,0x154); + if (msg_params != (u16 *)0x0) { + iVar4 = bl_hw->vif_index_sta; + msg_params[0xa6] = 0; + *(char *)(msg_params + 0xa7) = (char)iVar4; + iVar4 = channel_num_default; + *(undefined *)((int)msg_params + 0x14f) = (char)channel_num_default; + *(undefined4 *)(msg_params + 0xa0) = 0xffffffff; + msg_params[0xa2] = 0xffff; + msg_params[0xa8] = 0x100; + *(undefined4 *)(msg_params + 0xa4) = 0; + iVar2 = 0; + puVar5 = msg_params; + while (iVar2 < (int)(iVar4 & 0xffU)) { + piVar3 = channels_default + iVar2; + *(nl80211_band *)(puVar5 + 1) = piVar3->band; + uVar1 = piVar3->center_freq; + *(undefined *)((int)puVar5 + 3) = 1; + *puVar5 = uVar1; + *(char *)(puVar5 + 2) = (char)piVar3->max_reg_power; + iVar2 = iVar2 + 1; + puVar5 = puVar5 + 3; + } + iVar4 = bl_send_msg(bl_hw,msg_params,0,0,(void *)0x0); + return iVar4; + } + return -0xc; +} + + + +int bl_send_scanu_raw_send(bl_hw *bl_hw,uint8_t *pkt,int len) + +{ + uint8_t **msg_params; + int iVar1; + undefined auStack36 [4]; + scanu_raw_send_cfm cfm; + + msg_params = (uint8_t **)bl_msg_zalloc(0x1005,4,8); + if (msg_params == (uint8_t **)0x0) { + iVar1 = -0xc; + } + else { + *msg_params = pkt; + *(int *)(msg_params + 1) = len; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x1006,auStack36); + } + return iVar1; +} + + + +int bl_send_sm_connect_req(bl_hw *bl_hw,cfg80211_connect_params *sme,sm_connect_cfm *cfm) + +{ + _Bool _Var1; + char "bl_send_sm_connect_req" [23]; + undefined *msg_params; + int iVar2; + nl80211_auth_type nVar3; + u32 uVar4; + uint uVar5; + uint uVar6; + __be16 _Var7; + u8 *puVar8; + uint __n; + + msg_params = (undefined *)bl_msg_zalloc(0x1800,6,0x1c4); + if (msg_params == (undefined *)0x0) { + return -0xc; + } + __n = 0; + if ((sme->crypto).n_ciphers_pairwise != 0) { + uVar4 = (sme->crypto).ciphers_pairwise[0]; + __n = 4; + if ((1 < uVar4 - 0xfac01) && (__n = 0, uVar4 == 0xfac05)) { + __n = 4; + } + } + if ((sme->crypto).control_port != false) { + __n = __n | 1; + } + if ((sme->crypto).control_port_no_encrypt != false) { + __n = __n | 2; + } + if (((sme->crypto).cipher_group & 0xfffffffb) != 0xfac01) { + __n = __n | 8; + } + if (sme->mfp == NL80211_MFP_REQUIRED) { + __n = __n | 0x10; + } + _Var7 = (sme->crypto).control_port_ethertype; + if (_Var7 == 0) { + _Var7 = 0x888e; + } + *(__be16 *)(msg_params + 0x34) = _Var7; + puVar8 = sme->bssid; + if (puVar8 == (u8 *)0x0) { +LAB_23008cb8: + memcpy(msg_params + 0x22,&mac_addr_bcst,6); + } + else { + if (*puVar8 == -1) { + uVar5 = 0; + if (((puVar8[1] == -1) && (puVar8[2] == -1)) && + ((puVar8[3] == -1 && ((puVar8[4] == -1 && (puVar8[5] == -1)))))) goto LAB_23008cb8; + } + else { + if ((((*puVar8 == '\0') && (puVar8[1] == '\0')) && (puVar8[2] == '\0')) && + ((puVar8[3] == '\0' && (uVar5 = (uint)puVar8[4], puVar8[4] == 0)))) { + if (puVar8[5] == '\0') goto LAB_23008cb8; + } + else { + uVar5 = 0; + } + } + do { + uVar6 = uVar5 + 1; + msg_params[uVar5 + 0x22] = sme->bssid[uVar5]; + uVar5 = uVar6; + } while (uVar6 != 6); + } + msg_params[0x3d] = (char)bl_hw->vif_index_sta; + if ((sme->channel).center_freq == 0) { + *(undefined2 *)(msg_params + 0x28) = 0xffff; + } + else { + msg_params[0x2a] = (sme->channel).band; + *(u16 *)(msg_params + 0x28) = (sme->channel).center_freq; + *(bool *)(msg_params + 0x2b) = ((sme->channel).flags & 10) != 0; + } + uVar5 = 0; + while (uVar5 < sme->ssid_len) { + msg_params[uVar5 + 1] = sme->ssid[uVar5]; + uVar5 = uVar5 + 1; + } + *msg_params = (char)sme->ssid_len; + *(uint *)(msg_params + 0x30) = __n; + __n = sme->ie_len; + if (0x100 < __n) { + printf("%s:%d\r\n","bl_send_sm_connect_req",0x30a); + return -0x16; + } + if (__n != 0) { + memcpy(msg_params + 0x40,sme->ie,__n); + } + *(short *)(msg_params + 0x36) = (short)sme->ie_len; + _Var1 = bl_mod_params.listen_bcmc; + *(short *)(msg_params + 0x38) = (short)bl_mod_params.listen_itv; + msg_params[0x3a] = _Var1 ^ 1; + nVar3 = sme->auth_type; + if (nVar3 == __NL80211_AUTHTYPE_NUM) { + nVar3 = NL80211_AUTHTYPE_OPEN_SYSTEM; + } + msg_params[0x3b] = nVar3; + msg_params[0x3c] = (char)bl_mod_params.uapsd_queues; + msg_params[0x140] = 1; + if (sme->key_len != 0) { + memcpy(msg_params + 0x141,sme->key,(uint)sme->key_len); + } + if (sme->pmk_len != 0) { + memcpy(msg_params + 0x181,sme->pmk,(uint)sme->pmk_len); + } + iVar2 = bl_send_msg(bl_hw,msg_params,1,0x1801,cfm); + return iVar2; +} + + + +int bl_send_sm_disconnect_req(bl_hw *bl_hw,u16 reason) + +{ + u16 *msg_params; + int iVar1; + + msg_params = (u16 *)bl_msg_zalloc(0x1803,6,4); + if (msg_params != (u16 *)0x0) { + *msg_params = reason; + *(char *)(msg_params + 1) = (char)bl_hw->vif_index_sta; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x1804,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_mm_powersaving_req(bl_hw *bl_hw,int mode) + +{ + undefined *msg_params; + int iVar1; + + msg_params = (undefined *)bl_msg_zalloc(0x31,0,1); + if (msg_params != (undefined *)0x0) { + *msg_params = (char)mode; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x32,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_mm_denoise_req(bl_hw *bl_hw,int mode) + +{ + undefined *msg_params; + int iVar1; + + msg_params = (undefined *)bl_msg_zalloc(0x30,0,1); + if (msg_params != (undefined *)0x0) { + *msg_params = (char)mode; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x32,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_apm_start_req + (bl_hw *bl_hw,apm_start_cfm *cfm,char *ssid,char *password,int channel, + uint8_t vif_index,uint8_t hidden_ssid) + +{ + void *msg_params; + size_t __n; + int iVar1; + uint uVar2; + undefined auStack44 [4]; + uint8_t rate [12]; + + memcpy(auStack44,&DAT_23071aec,0xc); + msg_params = bl_msg_zalloc(0x1c00,7,0xa8); + if (msg_params == (void *)0x0) { + iVar1 = -0xc; + } + else { + *(undefined *)((int)msg_params + 0x10) = 0; + if (channel - 1U < 0xe) { + if (channel == 0xe) { + uVar2 = 0x9b4; + } + else { + uVar2 = channel * 5 + 0x967U & 0xffff; + } + } + else { + uVar2 = 0xffff; + } + *(undefined2 *)((int)msg_params + 0xe) = (short)uVar2; + *(uint *)((int)msg_params + 0x14) = uVar2; + *(undefined2 *)((int)msg_params + 0x28) = 100; + *(undefined4 *)((int)msg_params + 0x2c) = 8; + *(undefined2 *)((int)msg_params + 0x30) = 0x8e88; + *(undefined *)((int)msg_params + 0x32) = 6; + *(uint8_t *)((int)msg_params + 0x1d) = hidden_ssid; + *(uint8_t *)((int)msg_params + 0x33) = vif_index; + *(undefined *)((int)msg_params + 0x11) = 0; + *(undefined *)((int)msg_params + 0x12) = 0; + *(undefined4 *)((int)msg_params + 0x18) = 0; + *(undefined *)((int)msg_params + 0x1c) = 0; + *(undefined4 *)((int)msg_params + 0x20) = 0; + *(undefined4 *)((int)msg_params + 0x24) = 0; + __n = strlen(password); + *(undefined *)((int)msg_params + 0x34) = 1; + *(bool *)((int)msg_params + 0x66) = __n != 0; + __n = strlen(ssid); + memcpy((void *)((int)msg_params + 0x45),ssid,__n); + __n = strlen(password); + memcpy((void *)((int)msg_params + 0x67),password,__n); + __n = strlen(ssid); + *(undefined *)((int)msg_params + 0x44) = (char)__n; + *(undefined *)((int)msg_params + 0x35) = 0xc; + memcpy((void *)((int)msg_params + 0x36),auStack44,0xc); + *(undefined2 *)((int)msg_params + 0x42) = 0x101; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x1c01,cfm); + } + return iVar1; +} + + + +int bl_send_apm_stop_req(bl_hw *bl_hw,uint8_t vif_idx) + +{ + uint8_t *msg_params; + int iVar1; + + msg_params = (uint8_t *)bl_msg_zalloc(0x1c02,7,1); + if (msg_params != (uint8_t *)0x0) { + *msg_params = vif_idx; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x1c03,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_apm_sta_del_req(bl_hw *bl_hw,apm_sta_del_cfm *cfm,uint8_t sta_idx,uint8_t vif_idx) + +{ + uint8_t *msg_params; + int iVar1; + + msg_params = (uint8_t *)bl_msg_zalloc(0x1c0b,7,2); + if (msg_params != (uint8_t *)0x0) { + msg_params[1] = sta_idx; + *msg_params = vif_idx; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x1c0c,cfm); + return iVar1; + } + return -0xc; +} + + + +int bl_send_apm_conf_max_sta_req(bl_hw *bl_hw,uint8_t max_sta_supported) + +{ + uint8_t *msg_params; + int iVar1; + + msg_params = (uint8_t *)bl_msg_zalloc(0x1c0d,7,1); + if (msg_params != (uint8_t *)0x0) { + *msg_params = max_sta_supported; + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x1c0e,(void *)0x0); + return iVar1; + } + return -0xc; +} + + + +int bl_send_cfg_task_req + (bl_hw *bl_hw,uint32_t ops,uint32_t task,uint32_t element,uint32_t type,void *arg1, + void *arg2) + +{ + uint32_t *msg_params; + int iVar1; + TickType_t TVar2; + uint32_t uVar3; + + msg_params = (uint32_t *)bl_msg_zalloc(0x3000,0xc,0x24); + if (msg_params == (uint32_t *)0x0) { + return -0xc; + } + *msg_params = ops; + if (ops < 3) { + if (ops == 0) { + msg_params[1] = task; + msg_params[2] = element; + msg_params[3] = type; + uVar3 = utils_tlv_bl_pack_auto(msg_params + 5,8,(uint16_t)type,arg1); + msg_params[4] = uVar3; + } + } + else { + if (ops != 3) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ASSERT: %s:%d\r\n",TVar2,&UNK_2307261c,&UNK_23072610,0x40f, + &UNK_23072610,0x40f); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + msg_params[1] = task; + msg_params[2] = element; + msg_params[4] = 0; + } + iVar1 = bl_send_msg(bl_hw,msg_params,1,0x3001,(void *)0x0); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int bl_platform_on(bl_hw *bl_hw) + +{ + int iVar1; + + ipc_shenv = &ipc_shared_env; + iVar1 = bl_ipc_init(bl_hw,(ipc_shared_env_tag *)&ipc_shared_env); + if (iVar1 == 0) { + _DAT_44800008 = 0xffffffff; + } + return iVar1; +} + + + +int bl_rx_chan_pre_switch_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + return 0; +} + + + +int bl_rx_rssi_status_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + if (cb_rssi != (wifi_event_rssi_cb_t *)0x0) { + (*cb_rssi)(cb_rssi_env,*(int8_t *)((int)msg->param + 2)); + return 0; + } + return 0; +} + + + +int bl_rx_apm_sta_del_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + printf("[WF] APM_STA_DEL_IND\r\n"); + printf("[WF] sta_idx %u\r\n",(uint)*(byte *)msg->param); + if (*(byte *)msg->param < 0xc) { + bl_hw->sta_table[*(byte *)msg->param].is_used = '\0'; + } + else { + printf("[WF] --------- Potential illegal sta_idx\r\n"); + } + aos_post_event(2,0x16,(uint)*(byte *)msg->param); + return 0; +} + + + +int bl_rx_apm_sta_add_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + byte bVar1; + int *piVar2; + + printf("[WF] APM_STA_ADD_IND\r\n"); + printf("[WF] flags %08X\r\n",msg->param[0]); + printf("[WF] MAC %02X:%02X:%02X:%02X:%02X:%02X\r\n",(uint)*(byte *)(msg->param + 1), + (uint)*(byte *)((int)msg->param + 5),(uint)*(byte *)((int)msg->param + 6), + (uint)*(byte *)((int)msg->param + 7),(uint)*(byte *)(msg->param + 2), + (uint)*(byte *)((int)msg->param + 9)); + printf("[WF] vif_idx %u\r\n",(uint)*(byte *)((int)msg->param + 10)); + printf("[WF] sta_idx %u\r\n",(uint)*(byte *)((int)msg->param + 0xb)); + bVar1 = *(byte *)((int)msg->param + 0xb); + if (bVar1 < 0xc) { + memcpy(bl_hw->sta_table + (uint)bVar1,msg->param + 1,6); + piVar2 = &bl_hw->is_up + (uint)bVar1 * 7; + *(undefined *)((int)piVar2 + 0xc99) = *(undefined *)((int)msg->param + 0xb); + *(undefined *)((int)piVar2 + 0xc9a) = *(undefined *)((int)msg->param + 10); + *(undefined *)(piVar2 + 0x326) = 1; + *(undefined *)(piVar2 + 0x327) = *(undefined *)(msg->param + 3); + piVar2[0x328] = msg->param[4]; + piVar2[0x329] = msg->param[5]; + *(undefined *)(piVar2 + 0x32a) = *(undefined *)(msg->param + 6); + } + else { + printf("[WF] ------ Potential illegal sta_idx\r\n"); + } + aos_post_event(2,0x15,(uint)*(byte *)((int)msg->param + 0xb)); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void notify_event_scan_done(int join_scan) + +{ + wifi_event wStack24; + uint8_t buffer [8]; + + memset(&wStack24,0,4); + memset(buffer,0,4); + buffer._0_4_ = 0xec; + wStack24 = (wifi_event)((uint)(join_scan != 0) + 1); + if (cb_event != (wifi_event_cb_t *)0x0) { + (*cb_event)(cb_event_env,&wStack24); + } + return; +} + + + +int bl_rx_scanu_join_cfm(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + notify_event_scan_done(1); + return 0; +} + + + +int bl_rx_scanu_start_cfm(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + notify_event_scan_done(0); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bl_rx_chan_switch_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + wifi_event wStack24; + uint8_t buffer [8]; + + buffer._0_4_ = (uint)*(byte *)msg->param; + memset(&wStack24,0,4); + memset(buffer,0,4); + wStack24 = (wifi_event)0x0; + if (cb_event != (wifi_event_cb_t *)0x0) { + (*cb_event)(cb_event_env,&wStack24); + } + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bl_rx_sm_connect_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + netif *netif; + sm_reason_code *psVar1; + uint uVar2; + int iVar3; + u32_l local_40; + wifi_event_sm_connect_ind ind_new; + + psVar1 = reason_list; + iVar3 = 0; + do { + if (psVar1->reason_code == *(uint16_t *)msg->param) goto LAB_2300949e; + iVar3 = iVar3 + 1; + psVar1 = psVar1 + 1; + } while (iVar3 != 0x10); + iVar3 = 0; +LAB_2300949e: + printf("[RX] Connection Status\r\n"); + printf("[RX] status_code %u\r\n",(uint)*(ushort *)msg->param); + printf("[RX] connect result: %s\r\n",reason_list[iVar3].action); + printf("[RX] MAC %02X:%02X:%02X:%02X:%02X:%02X\r\n",(uint)*(byte *)((int)msg->param + 2), + (uint)*(byte *)((int)msg->param + 3),(uint)*(byte *)(msg->param + 1), + (uint)*(byte *)((int)msg->param + 5),(uint)*(byte *)((int)msg->param + 6), + (uint)*(byte *)((int)msg->param + 7)); + printf("[RX] vif_idx %u\r\n",(uint)*(byte *)((int)msg->param + 9)); + printf("[RX] ap_idx %u\r\n",(uint)*(byte *)((int)msg->param + 10)); + printf("[RX] ch_idx %u\r\n",(uint)*(byte *)((int)msg->param + 0xb)); + printf("[RX] qos %u\r\n",(uint)*(byte *)(msg->param + 3)); + printf("[RX] acm %u\r\n",(uint)*(byte *)((int)msg->param + 0xd)); + printf("[RX] assoc_req_ie_len %u\r\n",(uint)*(ushort *)((int)msg->param + 0xe)); + printf("[RX] assoc_rsp_ie_len %u\r\n",(uint)*(ushort *)(msg->param + 4)); + printf("[RX] aid %u\r\n",(uint)*(ushort *)(msg->param + 0xcd)); + printf("[RX] band %u\r\n",(uint)*(byte *)((int)msg->param + 0x336)); + printf("[RX] center_freq %u\r\n",(uint)*(ushort *)(msg->param + 0xce)); + printf("[RX] width %u\r\n",(uint)*(byte *)((int)msg->param + 0x33a)); + printf("[RX] center_freq1 %u\r\n",msg->param[0xcf]); + printf("[RX] center_freq2 %u\r\n",msg->param[0xd0]); + if (*(short *)msg->param == 0) { + bl_hw->sta_idx = (uint)*(byte *)((int)msg->param + 10); + bl_hw->is_up = 1; + } + else { + bl_hw->is_up = 0; + } + memset(&local_40,0,0x20); + local_40 = msg->param[0]; + ind_new._0_4_ = msg->param[1]; + ind_new.bssid[2] = *(uint8_t *)((int)msg->param + 9); + ind_new.bssid[3] = *(uint8_t *)((int)msg->param + 10); + ind_new.bssid[4] = *(uint8_t *)((int)msg->param + 0xb); + ind_new._8_4_ = (uint)*(byte *)(msg->param + 3); + ind_new.qos._0_2_ = *(uint16_t *)(msg->param + 0xcd); + ind_new.qos._2_1_ = *(uint8_t *)((int)msg->param + 0x336); + ind_new.aid = *(uint16_t *)(msg->param + 0xce); + ind_new.band = *(uint8_t *)((int)msg->param + 0x33a); + ind_new._20_4_ = msg->param[0xcf]; + ind_new.center_freq1 = msg->param[0xd0]; + if (cb_sm_connect_ind != (wifi_event_sm_connect_ind_cb_t *)0x0) { + (*cb_sm_connect_ind)(cb_sm_connect_ind_env,(wifi_event_sm_connect_ind *)&local_40); + } + if (*(short *)msg->param == 0) { + uVar2 = (uint)*(byte *)((int)msg->param + 9); + if (bl_hw->vif_table + uVar2 != (bl_vif *)0x0) { + netif = (netif *)(&bl_hw->is_up + uVar2 * 0x31)[0xda]; + if (netif != (netif *)0x0) { + netifapi_netif_common(netif,netif_set_link_up,(netifapi_errt_fn)0x0); + netifapi_netif_common + ((netif *)(&bl_hw->is_up + uVar2 * 0x31)[0xda],netif_set_default, + (netifapi_errt_fn)0x0); + return 0; + } + } + printf("[RX] -------- CRITICAL when check netif. ptr is %p:%p\r\n"); + } + return 0; +} + + + +// WARNING: Variable defined which should be unmapped: ind_new +// WARNING: Could not reconcile some variable overlaps + +int bl_rx_sm_disconnect_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg) + +{ + netif *netif; + uint uVar1; + ip4_addr_t iStack28; + ip4_addr_t addr_any; + wifi_event_sm_disconnect_ind ind_new; + + iStack28 = (ip4_addr_t)ipaddr_addr("0.0.0.0"); + printf("[RX] sm_disconnect_ind\r\n reason_code %u\r\n",(uint)*(ushort *)msg->param); + printf("[RX] vif_idx %u\r\n",(uint)*(byte *)((int)msg->param + 2)); + printf("[RX] ft_over_ds %u\r\n",(uint)*(byte *)((int)msg->param + 3)); + if (cb_sm_disconnect_ind != (wifi_event_sm_disconnect_ind_cb_t *)0x0) { + memset(&addr_any,0,8); + addr_any.addr._0_2_ = *(uint16_t *)msg->param; + addr_any.addr._2_1_ = *(uint8_t *)((int)msg->param + 2); + (*cb_sm_disconnect_ind)(cb_sm_disconnect_ind_env,(wifi_event_sm_disconnect_ind *)&addr_any); + } + uVar1 = (uint)*(byte *)((int)msg->param + 2); + if (bl_hw->vif_table + uVar1 != (bl_vif *)0x0) { + netif = (netif *)(&bl_hw->is_up + uVar1 * 0x31)[0xda]; + if (netif != (netif *)0x0) { + netifapi_netif_common(netif,netif_set_link_down,(netifapi_errt_fn)0x0); + netifapi_netif_set_addr + ((netif *)(&bl_hw->is_up + uVar1 * 0x31)[0xda],&iStack28,&iStack28,&iStack28); + } + } + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +undefined4 bl_rx_scanu_result_ind(int param_1,longlong param_2) + +{ + uchar uVar1; + void *__src; + undefined3 extraout_var; + uint __n; + SecurityMode_t *security_mode; + _Bool wpa2_prefered; + byte bVar2; + ushort uVar3; + int iVar4; + byte *pbVar5; + byte *pbVar6; + _Bool _Stack121; + uint8_t auStack120 [32]; + undefined2 uStack88; + undefined2 uStack86; + undefined2 uStack84; + undefined auStack82 [33]; + int8_t iStack49; + int8_t iStack48; + int8_t iStack47; + byte bStack46; + uint8_t uStack45; + undefined4 uStack44; + undefined4 uStack40; + uint uStack36; + SecurityMode_t aSStack32 [4]; + + _Stack121 = false; + memset(auStack120,0,0x20); + security_mode = (SecurityMode_t *)0x80; + uVar3 = *(ushort *)(param_1 + 0x24) & 0xfc; + if (uVar3 != 0x80) { + if (uVar3 != 0x50) { + printf("Bug Scan IND?\r\n"); + return 0; + } + printf("Probe Response\r\n"); + if (cb_probe_resp_ind == (wifi_event_probe_resp_ind_cb_t *)0x0) { + return 0; + } + (*cb_probe_resp_ind)((void *)0x0,param_2); + return 0; + } + if (cb_beacon_ind == (wifi_event_beacon_ind_cb_t *)0x0) { + return 0; + } + memset(&uStack88,0,0x38); + uVar3 = *(ushort *)(param_1 + 8); + pbVar6 = (byte *)(param_1 + 0x48); + iVar4 = 0; + pbVar5 = pbVar6; + while (iVar4 < (int)(uint)uVar3) { + security_mode = (SecurityMode_t *)(uint)*pbVar5; + __n = (uint)pbVar5[1]; + if (*pbVar5 == 0) { + if (pbVar5[1] < 0x21) { + uStack36 = __n; + memcpy(auStack82,pbVar5 + 2,__n); + security_mode = aSStack32; + auStack82[pbVar5[1]] = 0; + } + break; + } + iVar4 = iVar4 + __n + 2; + pbVar5 = pbVar5 + __n + 2; + } + iVar4 = 0; + pbVar5 = pbVar6; + while (iVar4 < (int)(uint)*(ushort *)(param_1 + 8)) { + security_mode = (SecurityMode_t *)(uint)pbVar5[1]; + if (*pbVar5 == 3) { + if (pbVar5[1] < 0x21) { + bStack46 = pbVar5[2]; + } + break; + } + security_mode = security_mode + 1; + iVar4 = &security_mode->field_0x0 + iVar4; + pbVar5 = pbVar5 + (int)security_mode; + } + if ((*(ushort *)(param_1 + 0x46) & 0x10) == 0) { + uStack45 = '\0'; + goto LAB_23009906; + } + __n = (uint)uVar3 - 0x24 & 0xffff; + __src = (void *)mac_ie_find(pbVar6,__n,0x30); + iVar4 = 0; + if (__src != (void *)0x0) { + wpa2_prefered = (_Bool)(uStack40._1_1_ | 0x20); + uStack40 = uStack40 | 0x2000; + memcpy(auStack120,__src,(uint)*(byte *)((int)__src + 1) + 2 & 0xff); + uVar1 = process_rsn_ie(auStack120,(Cipher_t_conflict *)((int)&uStack44 + 3), + (Cipher_t_conflict *)&uStack40,&_Stack121,security_mode,wpa2_prefered); + iVar4 = CONCAT31(extraout_var,uVar1); + } + __src = (void *)mac_vsie_find(pbVar6,__n,&DAT_23072740,4); + if ((__src != (void *)0x0) && (uStack40 = uStack40 | 0x800, iVar4 == 0)) { + memcpy(auStack120,__src,(uint)*(byte *)((int)__src + 1) + 2 & 0xff); + process_wpa_ie(auStack120,(Cipher_t_conflict *)((int)&uStack44 + 1), + (Cipher_t_conflict *)((int)&uStack44 + 2)); + } + if ((uStack40 & 0x2800) == 0x2800) { + bVar2 = (byte)uStack40._0_1_ | (byte)uStack44._2_1_; + __n = (uint)bVar2 & 8; + if ((bVar2 & 4) == 0) { + if ((bVar2 & 8) != 0) { + if (((uStack44 & 0x8000800) == 0) && ((uStack44 & 0x4000400) != 0)) goto LAB_230098f0; +LAB_23009978: + bVar2 = 2; + goto next; + } + } + else { +LAB_230098ec: + bVar2 = 3; + if (__n != 0) { +LAB_230098f0: + bVar2 = 4; + } +next: + uStack44 = uStack44 & 0xffffff00 | (uint)bVar2; + if ((uStack40 & 0x2800) != 0x2800) goto LAB_230099d2; + } + uStack45 = '\x04'; + } + else { + if ((uStack40 & 0x800) == 0) { + if ((uStack40 & 0x2000) == 0) { + uStack44 = CONCAT31(uStack44._1_3_,1); + } + else { + __n = uStack40 & 8; + if ((uStack40 & 4) != 0) goto LAB_230098ec; + if ((uStack40 & 8) != 0) { + uStack44._1_1_ = uStack44._3_1_; + goto LAB_230099a6; + } + } + } + else { + __n = (uint)(byte)uStack44._2_1_ & 8; + if ((uStack44 & 0x40000) != 0) goto LAB_230098ec; + if ((uStack44 & 0x80000) != 0) { +LAB_230099a6: + if ((((byte)uStack44._1_1_ & 8) != 0) || (((byte)uStack44._1_1_ & 4) == 0)) + goto LAB_23009978; + goto LAB_230098f0; + } + } +LAB_230099d2: + if ((uStack40 & 0x2000) == 0) { + if ((uStack40 & 0x800) == 0) { + uStack45 = '\x01'; + } + else { + uStack45 = '\x02'; + } + } + else { + uStack45 = '\x03'; + } + } +LAB_23009906: + iStack49 = *(int8_t *)(param_1 + 0x20); + iStack48 = *(int8_t *)(param_1 + 0x21); + iStack47 = *(int8_t *)(param_1 + 0x22); + uStack88 = *(undefined2 *)(param_1 + 0x34); + uStack86 = *(undefined2 *)(param_1 + 0x36); + uStack84 = *(undefined2 *)(param_1 + 0x38); + (*cb_beacon_ind)(cb_beacon_ind_env,(wifi_event_beacon_ind *)&uStack88); + return 0; +} + + + +undefined4 bl_rx_mesh_path_update_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_mesh_proxy_update_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_remain_on_channel_exp_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_ps_change_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_traffic_req_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_csa_counter_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_csa_finish_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_csa_traffic_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_channel_survey_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_dbg_error_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_tdls_chan_switch_cfm(void) + +{ + return 0; +} + + + +undefined4 bl_rx_tdls_chan_switch_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_tdls_chan_switch_base_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_tdls_peer_ps_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_me_tkip_mic_failure_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_me_tx_credits_update_ind(void) + +{ + return 0; +} + + + +undefined4 bl_rx_mesh_path_create_cfm(void) + +{ + return 0; +} + + + +undefined4 bl_rx_mesh_peer_update_ind(void) + +{ + return 0; +} + + + +int bl_rx_sm_connect_ind_cb_register(void *env,wifi_event_sm_connect_ind_cb_t *cb) + +{ + cb_sm_connect_ind = cb; + cb_sm_connect_ind_env = env; + return 0; +} + + + +int bl_rx_sm_disconnect_ind_cb_register(void *env,wifi_event_sm_disconnect_ind_cb_t *cb) + +{ + cb_sm_disconnect_ind = cb; + cb_sm_disconnect_ind_env = env; + return 0; +} + + + +int bl_rx_beacon_ind_cb_register(void *env,wifi_event_beacon_ind_cb_t *cb) + +{ + cb_beacon_ind = cb; + cb_beacon_ind_env = env; + return 0; +} + + + +int bl_rx_probe_resp_ind_cb_register(void *env,wifi_event_probe_resp_ind_cb_t *cb) + +{ + cb_probe_resp_ind = cb; + return 0; +} + + + +int bl_rx_pkt_cb_register(void *env,wifi_event_pkt_cb_t *cb) + +{ + cb_pkt = cb; + cb_pkt_env = env; + return 0; +} + + + +int bl_rx_pkt_cb_unregister(void *env) + +{ + cb_pkt = (wifi_event_pkt_cb_t *)0x0; + cb_pkt_env = (void *)0x0; + return 0; +} + + + +int bl_rx_rssi_cb_register(void *env,wifi_event_rssi_cb_t *cb) + +{ + cb_rssi = cb; + cb_rssi_env = env; + return 0; +} + + + +int bl_rx_event_register(void *env,wifi_event_cb_t *cb) + +{ + cb_event = cb; + cb_event_env = env; + return 0; +} + + + +void bl_rx_e2a_handler(void *arg) + +{ + // WARNING: Could not recover jumptable at 0x23009b50. Too many branches + // WARNING: Treating indirect jump as call + (*wifi_hw.cmd_mgr.msgind) + ((bl_cmd_mgr *)0x42018774,(ipc_e2a_msg *)arg, + (msg_cb_fct *)msg_hdlrs[*(ushort *)arg >> 10][(uint)*(ushort *)arg & 0x3ff]); + return; +} + + + +void bl_rx_pkt_cb(uint8_t *pkt,int len) + +{ + if (cb_pkt != (wifi_event_pkt_cb_t *)0x0) { + // WARNING: Could not recover jumptable at 0x23009b6a. Too many branches + // WARNING: Treating indirect jump as call + (*cb_pkt)(cb_pkt_env,pkt,len); + return; + } + return; +} + + + +void bl_tx_push(bl_hw *bl_hw,bl_txhdr *txhdr) + +{ + hostdesc *phVar1; + hostdesc *phVar2; + txdesc_host *ptVar3; + hostdesc *phVar4; + uint32_t *host_id; + + host_id = txhdr->p; + ptVar3 = ipc_host_txdesc_get(bl_hw->ipc_env); + if (&ptVar3->host == (hostdesc *)0x0) { + printf("%d:ASSERT_ERR(host)\n",0x37); + } + phVar1 = &ptVar3->host; + phVar4 = &txhdr->host; + do { + phVar2 = (hostdesc *)((int)&phVar1->pbuf_addr + 1); + *(undefined *)&phVar1->pbuf_addr = *(undefined *)&phVar4->pbuf_addr; + phVar1 = phVar2; + phVar4 = (hostdesc *)((int)&phVar4->pbuf_addr + 1); + } while ((hostdesc *)ptVar3->pad_txdesc != phVar2); + ipc_host_txdesc_push(bl_hw->ipc_env,host_id); + (bl_hw->stats).cfm_balance = (bl_hw->stats).cfm_balance + 1; + return; +} + + + +void bl_tx_resend(void) + +{ + bl_hw *bl_hw; + txdesc_host *ptVar1; + uint uVar2; + + vTaskEnterCritical(); + while ((txhdr_pos_r != txhdr_pos_w && + (ptVar1 = ipc_host_txdesc_get(bl_hw_static->ipc_env), bl_hw = bl_hw_static, + ptVar1 != (txdesc_host *)0x0))) { + uVar2 = txhdr_pos_r & 7; + txhdr_hodler[uVar2]->status = 0; + bl_tx_push(bl_hw,txhdr_hodler[uVar2]); + txhdr_pos_r = txhdr_pos_r + 1; + } + vTaskExitCritical(); + return; +} + + + +void bl_tx_try_flush(void) + +{ + txdesc_host *ptVar1; + bl_txhdr *txhdr; + + vTaskEnterCritical(); + while ((ptVar1 = ipc_host_txdesc_get(bl_hw_static->ipc_env), ptVar1 != (txdesc_host *)0x0 && + (txhdr = (bl_txhdr *)utils_list_pop_front(&tx_list_bl), txhdr != (bl_txhdr *)0x0))) { + bl_tx_push(bl_hw_static,txhdr); + } + vTaskExitCritical(); + return; +} + + + +int bl_txdatacfm(void *pthis,void *host_id) + +{ + bl_txhdr *pbVar1; + int iVar2; + + pbVar1 = (bl_txhdr *)((-*(int *)((int)host_id + 4) & 3U) + *(int *)((int)host_id + 4)); + iVar2 = pbVar1->status; + if (iVar2 == 0) { + return -1; + } + if (iVar2 << 0xf < 0) { + if (((txhdr_pos_w + 1 ^ txhdr_pos_r) & 7) != 0) { + puts(" push back\r\n"); + txhdr_hodler[txhdr_pos_w & 7] = pbVar1; + txhdr_pos_w = txhdr_pos_w + 1; + return 0; + } + puts(" NOT push back when no mem\r\n"); + } + pbuf_free((pbuf *)host_id); + return 0; +} + + + +void bl_tx_notify(void) + +{ + if (taskHandle_output != (TaskHandle_t)0x0) { + xTaskGenericNotify(taskHandle_output,0,eIncrement,(uint32_t *)0x0); + return; + } + return; +} + + + +err_t bl_output(bl_hw *bl_hw,netif *netif,pbuf *p,int is_sta) + +{ + u16_t uVar1; + undefined2 uVar2; + utils_list_hdr *list_hdr; + err_t eVar3; + u8_t uVar4; + undefined3 extraout_var; + undefined uVar5; + pbuf *ppVar6; + uint8_t *mac; + int iVar7; + utils_list_hdr *puVar8; + + if ((bl_hw == (bl_hw *)0x0) || ((netif->flags & 4) == 0)) { + printf("[TX] wifi is down, return now\r\n"); + eVar3 = -0xb; + } + else { + if (taskHandle_output == (TaskHandle_t)0x0) { + taskHandle_output = xTaskGetCurrentTaskHandle(); + } + mac = (uint8_t *)p->payload; + uVar1 = p->tot_len; + bl_hw_static = bl_hw; + uVar4 = pbuf_header(p,0x80); + if (CONCAT31(extraout_var,uVar4) == 0) { + list_hdr = (utils_list_hdr *)((-(int)p->payload & 3U) + (int)p->payload); + memset(list_hdr,0,0x5c); + *(pbuf **)&list_hdr[2].next = p; + memcpy(list_hdr + 7,mac,6); + memcpy((void *)((int)&list_hdr[8].next + 2),mac + 6,6); + *(pbuf **)&list_hdr[3].next = p; + uVar2 = *(undefined2 *)(mac + 0xc); + *(undefined *)((int)&list_hdr[0xd].next + 2) = 0; + *(undefined2 *)&list_hdr[10].next = uVar2; + if (is_sta == 0) { + uVar5 = *(undefined *)&bl_hw->vif_index_ap; + } + else { + uVar5 = *(undefined *)&bl_hw->vif_index_sta; + } + *(undefined *)((int)&list_hdr[0xd].next + 3) = uVar5; + *(undefined2 *)((int)&list_hdr[0xe].next + 2) = 0; + *(u16_t *)&list_hdr[5].next = uVar1 - 0xe; + if (is_sta == 0) { + iVar7 = bl_utils_idx_lookup(bl_hw,mac); + *(char *)&list_hdr[0xe].next = (char)iVar7; + } + else { + *(char *)&list_hdr[0xe].next = (char)bl_hw->sta_idx; + } + puVar8 = list_hdr + 0xf; + iVar7 = 0; + ppVar6 = p; + do { + if (iVar7 == 0) { + list_hdr[0xf].next = (utils_list_hdr *)((int)ppVar6->payload + 0x8e); + list_hdr[0x13].next = (utils_list_hdr *)((uint)ppVar6->len - 0x8e); + } + else { + if (iVar7 == 4) { + printf("[TX] [PBUF] Please fix for bigger chained pbuf, total_len %d\r\n", + (uint)p->tot_len); + } + puVar8->next = (utils_list_hdr *)ppVar6->payload; + puVar8[4].next = (utils_list_hdr *)(uint)ppVar6->len; + } + ppVar6 = ppVar6->next; + iVar7 = iVar7 + 1; + puVar8 = puVar8 + 1; + } while (ppVar6 != (pbuf *)0x0); + if (2 < iVar7) { + printf("[TX] [LOOP] Chain Used %d\r\n",iVar7); + } + list_hdr[4].next = (utils_list_hdr *)0x11111111; + list_hdr[6].next = list_hdr + 1; + list_hdr[1].next = (utils_list_hdr *)0x0; + pbuf_ref(p); + vTaskEnterCritical(); + utils_list_push_back(&tx_list_bl,list_hdr); + vTaskExitCritical(); + bl_irq_handler(); + eVar3 = '\0'; + } + else { + printf("[TX] Reserve room failed for header\r\n"); + eVar3 = -0xc; + } + } + return eVar3; +} + + + +u8 bl_radarind(void *pthis,void *hostid) + +{ + return '\0'; +} + + + +u8 bl_msgackind(void *pthis,void *hostid) + +{ + (**(code **)((int)pthis + 0x24))((int)pthis + 4,*(code **)((int)pthis + 0x24)); + return '\0'; +} + + + +void bl_prim_tbtt_ind(void *pthis) + +{ + return; +} + + + +void my_pbuf_free_custom(pbuf *p) + +{ + bl60x_firmwre_mpdu_free(p[1].payload); + return; +} + + + +undefined4 bl_dbgind(void) + +{ + return 0; +} + + + +void bl_sec_tbtt_ind(void) + +{ + return; +} + + + +void my_pbuf_free_custom_fake(void) + +{ + return; +} + + + +// WARNING: Control flow encountered bad instruction data + +int tcpip_stack_input(void *swdesc,uint8_t status,void *hwhdr,uint msdu_offset,wifi_pkt *pkt) + +{ + if ((status & 1) == 0) { + return -1; + } + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +int bl_utils_idx_lookup(bl_hw *bl_hw,uint8_t *mac) + +{ + bl_sta *__s1; + int iVar1; + int iVar2; + + __s1 = bl_hw->sta_table; + iVar1 = 0; + while ((__s1->is_used == '\0' || (iVar2 = memcmp(__s1,mac,6), iVar2 != 0))) { + iVar1 = iVar1 + 1; + __s1 = __s1 + 1; + if (iVar1 == 0xc) { + return wifi_hw.ap_bcmc_idx; + } + } + return iVar1; +} + + + +int bl_ipc_init(bl_hw *bl_hw,ipc_shared_env_tag *ipc_shared_mem) + +{ + code *local_30; + ipc_host_cb_tag cb; + + memset(&local_30,0,0x20); + cb.recv_data_ind = bl_radarind; + cb.recv_msg_ind = bl_msgackind; + cb.recv_msgack_ind = bl_dbgind; + local_30 = bl_txdatacfm; + cb.recv_dbg_ind = bl_prim_tbtt_ind; + cb.prim_tbtt_ind = bl_sec_tbtt_ind; + cb.send_data_cfm = (anon_subr_int_void_ptr_void_ptr_for_send_data_cfm *)0x0; + cb.recv_radar_ind = (anon_subr_uint8_t_void_ptr_void_ptr_for_recv_radar_ind *)0x0; + ipc_env = (ipc_host_env_tag *)pvPortMalloc(0xe4); + bl_hw->ipc_env = ipc_env; + ipc_host_init(ipc_env,(ipc_host_cb_tag *)&local_30,ipc_shared_mem,bl_hw); + bl_cmd_mgr_init(&bl_hw->cmd_mgr); + return 0; +} + + + +void bl_utils_dump(void) + +{ + int iVar1; + uint uVar2; + int iVar3; + + puts("---------- bl_utils_dump -----------\r\n"); + printf("txdesc_free_idx: %lu(%lu)\r\n",ipc_env->txdesc_free_idx,ipc_env->txdesc_free_idx & 3); + printf("txdesc_used_idx: %lu(%lu)\r\n",ipc_env->txdesc_used_idx,ipc_env->txdesc_used_idx & 3); + iVar1 = 0; + printf("tx_host_id0 cnt: %d(used %ld)\r\n",4,ipc_env->txdesc_free_idx - ipc_env->txdesc_used_idx); + puts(" list: pbuf status ptr status\r\n"); + do { + uVar2 = ipc_env->txdesc_used_idx + iVar1; + if (uVar2 == ipc_env->txdesc_free_idx) break; + iVar1 = iVar1 + 1; + iVar3 = *(int *)((&(ipc_env->cb).recv_radar_ind)[(uVar2 & 3) + 0x10] + 4); + iVar3 = (-iVar3 & 3U) + iVar3; + printf(" [%lu]%p(%p:%08lX)\r\n",*(undefined4 *)(iVar3 + 0x18),*(undefined4 *)(iVar3 + 4)); + } while (iVar1 != 4); + puts("========== bl_utils_dump End =======\r\n"); + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void goToErrorState(stateMachine *fsm,event *event) + +{ + state *psVar1; + + fsm->previousState = fsm->currentState; + psVar1 = fsm->errorState; + fsm->currentState = psVar1; + if ((psVar1 != (state *)0x0) && + (psVar1->entryAction != (anon_subr_void_void_ptr_event_ptr_for_entryAction *)0x0)) { + // WARNING: Could not recover jumptable at 0x2300a4a6. Too many branches + // WARNING: Treating indirect jump as call + (*psVar1->entryAction)(psVar1->data); + return; + } + return; +} + + + +void stateM_init(stateMachine *fsm,state *initialState,state *errorState) + +{ + if (fsm != (stateMachine *)0x0) { + fsm->currentState = initialState; + fsm->previousState = (state *)0x0; + fsm->errorState = errorState; + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +int stateM_handleEvent(stateMachine *fsm,event *event) + +{ + state *psVar1; + state *psVar2; + int iVar3; + int *piVar4; + uint uVar5; + + if (fsm == (stateMachine *)0x0) { + return -2; + } + iVar3 = -2; + if (event != (event *)0x0) { + psVar1 = fsm->currentState; + if (psVar1 == (state *)0x0) { +LAB_2300a4d4: + goToErrorState(fsm,event); + iVar3 = -1; + } + else { + psVar2 = (state *)psVar1->numTransitions; + while (psVar2 != (state *)0x0) { + uVar5 = 0; + while (uVar5 < psVar1->numTransitions) { + piVar4 = &psVar1->transitions->eventType + uVar5 * 5; + if ((*piVar4 == event->type) && + (((code *)piVar4[2] == (code *)0x0 || + (iVar3 = (*(code *)piVar4[2])(piVar4[1],event), iVar3 != 0)))) { + psVar1 = (state *)piVar4[4]; + if ((state *)piVar4[4] != (state *)0x0) { + do { + psVar2 = psVar1; + psVar1 = psVar2->entryState; + } while (psVar2->entryState != (state *)0x0); + psVar1 = fsm->currentState; + if ((psVar1 != psVar2) && + (psVar1->exitAction != (anon_subr_void_void_ptr_event_ptr_for_exitAction *)0x0)) { + (*psVar1->exitAction)(psVar1->data,event); + } + if ((code *)piVar4[3] != (code *)0x0) { + (*(code *)piVar4[3])(fsm->currentState->data,event,psVar2->data); + } + if ((fsm->currentState != psVar2) && + (psVar2->entryAction != (anon_subr_void_void_ptr_event_ptr_for_entryAction *)0x0)) + { + (*psVar2->entryAction)(psVar2->data,event); + } + psVar1 = fsm->currentState; + fsm->currentState = psVar2; + fsm->previousState = psVar1; + if (psVar1 == psVar2) { + return 1; + } + if (fsm->errorState == psVar2) { + return -1; + } + if (psVar2->numTransitions == 0) { + return 3; + } + return 0; + } + goto LAB_2300a4d4; + } + uVar5 = uVar5 + 1; + } + psVar1 = psVar1->parentState; + psVar2 = psVar1; + } + iVar3 = 2; + } + } + return iVar3; +} + + + +void netif_status_callback(netif *netif) + +{ + uint32_t ip; + char *pcVar1; + ip_addr_t *piVar2; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + + pcVar1 = ip4addr_ntoa((ip4_addr_t *)&netif->ip_addr); + printf("[lwip] netif status callback\r\n IP: %s\r\n",pcVar1); + pcVar1 = ip4addr_ntoa((ip4_addr_t *)&netif->netmask); + printf(" MK: %s\r\n",pcVar1); + pcVar1 = ip4addr_ntoa((ip4_addr_t *)&netif->gw); + printf(" GW: %s\r\n",pcVar1); + if (((ip4_addr_t *)&netif->ip_addr != (ip4_addr_t *)0x0) && ((netif->ip_addr).addr != 0)) { + wifi_mgmr_api_ip_update(); + mask = (netif->netmask).addr; + gw = (netif->gw).addr; + ip = (netif->ip_addr).addr; + piVar2 = dns_getserver('\0'); + dns1 = piVar2->addr; + piVar2 = dns_getserver('\x01'); + wifi_mgmr_api_ip_got(ip,mask,gw,dns1,piVar2->addr); + return; + } + printf(" SKIP Notify for set Empty Address\r\n"); + return; +} + + + +err_t wifi_tx(netif *netif,pbuf *p) + +{ + err_t eVar1; + TickType_t TVar2; + pbuf *ppVar3; + + ppVar3 = p; + if (p->tot_len < 0x5eb) { + do { + ppVar3 = ppVar3->next; + } while (ppVar3 != (pbuf *)0x0); + eVar1 = '\0'; + bl_output(bl606a0_sta,netif,p,(uint)(netif[-1].client_data[1] == (void *)0x0)); + } + else { + TVar2 = xTaskGetTickCount(); + eVar1 = -0xc; + if (2000 < TVar2 - ticks_7281) { + printf("[TX] %s, TX size too big: %u bytes\r\n",&__func___7282,(uint)p->tot_len); + ticks_7281 = xTaskGetTickCount(); + } + } + return eVar1; +} + + + +err_t bl606a0_wifi_netif_init(netif *netif) + +{ + netif->hostname = "bl606a0"; + netif->mtu = 0x5dc; + *(undefined2 *)&netif->hwaddr_len = 0xa06; + netif->output = etharp_output; + netif->linkoutput = wifi_tx; + netif_set_status_callback(netif,netif_status_callback); + return '\0'; +} + + + +int bl606a0_wifi_init(wifi_conf_t *conf) + +{ + int iVar1; + byte bStack24; + byte bStack23; + byte bStack22; + byte bStack21; + uint8_t mac [6]; + + printf("\r\n\r\n[BL] Initi Wi-Fi"); + memset(&bStack24,0,6); + bl_wifi_mac_addr_get(&bStack24); + printf(" with MAC #### %02X:%02X:%02X:%02X:%02X:%02X ####\r\n",(uint)bStack24,(uint)bStack23, + (uint)bStack22,(uint)bStack21,(uint)mac[0],(uint)mac[1]); + bl_msg_update_channel_cfg((char *)conf); + printf("-----------------------------------------------------\r\n"); + bl_wifi_clock_enable(); + memset(&bl606a0_sta,0,4); + iVar1 = bl_main_rtthread_start((bl_hw **)&bl606a0_sta); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +u32 ipc_emb2app_rawstatus_get(void) + +{ + return _DAT_44800004; +} + + + +void ipc_host_init(ipc_host_env_tag *env,ipc_host_cb_tag *cb,ipc_shared_env_tag *shared_env_ptr, + void *pthis) + +{ + printf("[IPC] [TX] Low level size %d, driver size %d, total size %d\r\n",internel_cal_size_tx_desc + ,internel_cal_size_tx_hdr,internel_cal_size_tx_desc + internel_cal_size_tx_hdr); + utils_list_init(&tx_list_bl); + memset(env,0,0xe4); + env->shared = shared_env_ptr; + memcpy(env,cb,0x20); + env->rx_bufnb = 2; + env->rxdesc_nb = '\x02'; + env->ipc_e2amsg_bufnb = 8; + env->ipc_e2amsg_bufsz = 0x3e0; + env->pthis = pthis; + env->rx_bufsz = 0x800; + env->tx_host_id = env->tx_host_id0; + env->txdesc = shared_env_ptr->txdesc0; + memset(shared_env_ptr->txdesc0,0,0xcc0); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int ipc_host_msg_push(ipc_host_env_tag *env,void *msg_buf,uint16_t len) + +{ + undefined2 in_register_00002032; + int iVar1; + ipc_shared_env_tag *piVar2; + int iVar3; + + iVar1 = *(int *)((int)msg_buf + 0xc); + piVar2 = env->shared; + iVar3 = 0; + while (iVar3 < CONCAT22(in_register_00002032,len)) { + *(undefined4 *)((int)(piVar2->msg_a2e_buf).msg + iVar3) = *(undefined4 *)(iVar1 + iVar3); + iVar3 = iVar3 + 4; + } + env->msga2e_hostid = msg_buf; + _DAT_44800000 = 2; + return 0; +} + + + +uint32_t ipc_host_get_rawstatus(ipc_host_env_tag *env) + +{ + u32 uVar1; + + uVar1 = ipc_emb2app_rawstatus_get(); + return uVar1; +} + + + +txdesc_host * ipc_host_txdesc_get(ipc_host_env_tag *env) + +{ + uint uVar1; + uint uVar2; + + uVar1 = env->txdesc_used_idx; + uVar2 = env->txdesc_free_idx; + if (uVar2 < uVar1) { + used_issue = used_issue + 1; + } + if (uVar1 + 4 != uVar2) { + if (uVar2 - uVar1 < 5) { + return env->txdesc + (uVar2 & 3); + } + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + return (txdesc_host *)0x0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_host_txdesc_push(ipc_host_env_tag *env,void *host_id) + +{ + uint uVar1; + + uVar1 = env->txdesc_free_idx & 3; + env->txdesc[uVar1].ready = 0xffffffff; + env->tx_host_id[uVar1] = host_id; + env->txdesc_free_idx = env->txdesc_free_idx + 1; + _DAT_44800000 = 0x100; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_host_irq(ipc_host_env_tag *env,uint32_t status) + +{ + uint uVar1; + uint8_t uVar2; + int iVar3; + undefined3 extraout_var; + void *pvVar4; + anon_subr_uint8_t_void_ptr_void_ptr_for_recv_msgack_ind *paVar5; + uint uVar6; + int *piVar7; + uint uVar8; + + uVar1 = _DAT_4480001c | status; + _DAT_44800008 = status; + if ((uVar1 & 0x780) != 0) { + piVar7 = nx_txdesc_cnt_msk; + uVar8 = 7; + do { + if ((1 << (uVar8 & 0x1f) & uVar1) != 0) { + while( true ) { + uVar6 = env->txdesc_used_idx & *piVar7; + if ((env->tx_host_id[uVar6] == (void *)0x0) || + (iVar3 = (*(env->cb).send_data_cfm)(env->pthis,env->tx_host_id[uVar6]), iVar3 != 0)) + break; + env->tx_host_id[uVar6] = (void *)0x0; + env->txdesc_used_idx = env->txdesc_used_idx + 1; + bl_tx_notify(); + } + } + uVar8 = uVar8 + 1; + piVar7 = (int *)((uint *)piVar7 + 1); + } while (uVar8 != 0xb); + } + bl_tx_resend(); + if ((uVar1 & 4) != 0) { + pvVar4 = env->msga2e_hostid; + env->msga2e_cnt = env->msga2e_cnt + '\x01'; + paVar5 = (env->cb).recv_msgack_ind; + env->msga2e_hostid = (void *)0x0; + (*paVar5)(env->pthis,pvVar4); + } + if ((uVar1 & 1) != 0) { + do { + uVar2 = (*(env->cb).recv_dbg_ind) + (env->pthis, + (&(env->cb).recv_data_ind)[((uint)env->ipc_host_dbg_idx + 0x16) * 2]); + } while (CONCAT31(extraout_var,uVar2) == 0); + } + if ((uVar1 & 0x10) != 0) { + (*(env->cb).prim_tbtt_ind)(env->pthis); + } + if ((uVar1 & 0x20) != 0) { + // WARNING: Could not recover jumptable at 0x2300a99a. Too many branches + // WARNING: Treating indirect jump as call + (*(env->cb).sec_tbtt_ind)(env->pthis); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_host_enable_irq(ipc_host_env_tag *env,uint32_t value) + +{ + _DAT_4480000c = value; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_host_disable_irq_e2a(void) + +{ + _DAT_44800010 = 0x7ff; + return; +} + + + +void cmd_mgr_print(bl_cmd_mgr *cmd_mgr) + +{ + list_head *plVar1; + + xQueueSemaphoreTake((QueueHandle_t)cmd_mgr->lock,0xffffffff); + plVar1 = (cmd_mgr->cmds).next; + while (plVar1 != &cmd_mgr->cmds) { + plVar1 = plVar1->next; + } + xQueueGenericSend((QueueHandle_t)cmd_mgr->lock,(void *)0x0,0,0); + return; +} + + + +void cmd_complete(bl_cmd *cmd) + +{ + ushort uVar1; + int *in_a1; + int iVar2; + int *piVar3; + + (cmd->list).next = (list_head *)((int)&(cmd->list).next[-1].prev + 3); + piVar3 = (int *)in_a1[1]; + iVar2 = *in_a1; + *(int **)(iVar2 + 4) = piVar3; + *piVar3 = iVar2; + *in_a1 = 0x100100; + in_a1[1] = 0x200200; + uVar1 = *(ushort *)(in_a1 + 6); + *(ushort *)(in_a1 + 6) = uVar1 | 0x20; + if ((uVar1 & 1) != 0) { + vPortFree(in_a1); + return; + } + if ((uVar1 & 0x18) == 0) { + in_a1[0xf] = 0; + xEventGroupSetBits((EventGroupHandle_t)(in_a1 + 7),1); + return; + } + return; +} + + + +int cmd_mgr_msgind(bl_cmd_mgr *cmd_mgr,ipc_e2a_msg *msg,msg_cb_fct *cb) + +{ + bool bVar1; + bl_cmd *pbVar2; + int iVar3; + + xQueueSemaphoreTake((QueueHandle_t)cmd_mgr->lock,0xffffffff); + pbVar2 = (bl_cmd *)(cmd_mgr->cmds).next; + do { + if (pbVar2 == (bl_cmd *)&cmd_mgr->cmds) { + bVar1 = false; +LAB_2300aaac: + xQueueGenericSend((QueueHandle_t)cmd_mgr->lock,(void *)0x0,0,0); + if ((!bVar1) && (cb != (msg_cb_fct *)0x0)) { + (*cb)((bl_hw *)&cmd_mgr[-1].drain,(bl_cmd *)0x0,msg); + } + return 0; + } + if (((pbVar2->reqid == msg->id) && ((pbVar2->flags & 0x10) != 0)) && + ((cb == (msg_cb_fct *)0x0 || + (iVar3 = (*cb)((bl_hw *)&cmd_mgr[-1].drain,pbVar2,msg), iVar3 == 0)))) { + pbVar2->flags = pbVar2->flags & 0xffef; + if ((pbVar2->e2a_msg != (char *)0x0) && (msg->param_len != 0)) { + memcpy(pbVar2->e2a_msg,msg->param,(uint)msg->param_len); + } + bVar1 = true; + if ((pbVar2->flags & 0x18) == 0) { + cmd_complete((bl_cmd *)&cmd_mgr->queue_sz); + } + goto LAB_2300aaac; + } + pbVar2 = (bl_cmd *)(pbVar2->list).next; + } while( true ); +} + + + +int cmd_mgr_llind(bl_cmd_mgr *cmd_mgr,bl_cmd *cmd) + +{ + ushort uVar1; + char "cmd_mgr_llind" [14]; + bl_cmd *msg_buf; + bl_cmd *pbVar2; + _Bool __warned; + + xQueueSemaphoreTake((QueueHandle_t)cmd_mgr->lock,0xffffffff); + msg_buf = (bl_cmd *)(cmd_mgr->cmds).next; + pbVar2 = (bl_cmd *)0x0; + do { + if (msg_buf == (bl_cmd *)&cmd_mgr->cmds) { + msg_buf = (bl_cmd *)0x0; + if (pbVar2 != (bl_cmd *)0x0) { +LAB_2300ab7c: + uVar1 = cmd->flags; + cmd->flags = uVar1 & 0xfff7; + if ((uVar1 & 0x10) == 0) { + cmd_complete((bl_cmd *)&cmd_mgr->queue_sz); + } + if (msg_buf != (bl_cmd *)0x0) { +LAB_2300ab98: + msg_buf->flags = msg_buf->flags & 0xfffb; + ipc_host_msg_push(*(ipc_host_env_tag **)(cmd_mgr + 1),msg_buf, + (uint16_t)(((uint)msg_buf->a2e_msg->param_len + 8) * 0x10000 >> 0x10)); + vPortFree(msg_buf->a2e_msg); + } + } + xQueueGenericSend((QueueHandle_t)cmd_mgr->lock,(void *)0x0,0,0); + return 0; + } + if ((pbVar2 == (bl_cmd *)0x0) && ((list_head *)msg_buf->tkn == (list_head *)cmd->tkn)) { + pbVar2 = msg_buf; + if ((msg_buf != cmd) && (__warned == false)) { + printf("%s:%d\r\n","cmd_mgr_llind",0xcf); + __warned = true; + } + } + else { + if ((msg_buf->flags & 4) != 0) { + if (pbVar2 == (bl_cmd *)0x0) goto LAB_2300ab98; + goto LAB_2300ab7c; + } + } + msg_buf = (bl_cmd *)(msg_buf->list).next; + } while( true ); +} + + + +undefined4 cmd_mgr_queue(char *param_1,char **param_2) + +{ + bool bVar1; + ushort uVar2; + undefined4 uVar3; + EventBits_t EVar4; + char *pcVar5; + char **ppcVar6; + int iVar7; + + xQueueSemaphoreTake(*(QueueHandle_t *)(param_1 + 0x18),0xffffffff); + if (*param_1 == '\x02') { + param_2[0xf] = &DAT_00000020; + xQueueGenericSend(*(QueueHandle_t *)(param_1 + 0x18),(void *)0x0,0,0); + uVar3 = 0xffffffe0; + } + else { + if (param_1 + 0x10 == *(char **)(param_1 + 0x10)) { + bVar1 = false; + } + else { + if (*(int *)(param_1 + 8) == *(int *)(param_1 + 0xc)) { + param_2[0xf] = &DAT_0000000c; + xQueueGenericSend(*(QueueHandle_t *)(param_1 + 0x18),(void *)0x0,0,0); + return 0xfffffff4; + } + bVar1 = false; + if ((*(ushort *)(*(int *)(param_1 + 0x14) + 0x18) & 0xc) != 0) { + bVar1 = true; + *(ushort *)(param_2 + 6) = *(ushort *)(param_2 + 6) | 4; + } + } + if ((*(ushort *)(param_2 + 6) & 2) == 0) { + uVar2 = 8; + } + else { + uVar2 = 0x18; + } + *(ushort *)(param_2 + 6) = *(ushort *)(param_2 + 6) | uVar2; + pcVar5 = *(char **)(param_1 + 4); + *(char **)(param_1 + 4) = pcVar5 + 1; + param_2[5] = pcVar5; + param_2[0xf] = &DAT_00000004; + if ((*(ushort *)(param_2 + 6) & 1) == 0) { + xEventGroupCreateStatic((StaticEventGroup_t *)(param_2 + 7)); + } + ppcVar6 = *(char ***)(param_1 + 0x14); + *(char ***)(param_1 + 0x14) = param_2; + *param_2 = param_1 + 0x10; + *(char ***)(param_2 + 1) = ppcVar6; + *(char ***)ppcVar6 = param_2; + iVar7 = *(int *)(param_1 + 8); + *(int *)(param_1 + 8) = iVar7 + 1; + xQueueGenericSend(*(QueueHandle_t *)(param_1 + 0x18),(void *)0x0,0,0); + if (!bVar1) { + ipc_host_msg_push(*(ipc_host_env_tag **)(param_1 + 0x30),param_2, + (uint16_t)(((uint)*(ushort *)(param_2[3] + 6) + 8) * 0x10000 >> 0x10)); + vPortFree(param_2[3]); + } + if ((*(ushort *)(param_2 + 6) & 1) == 0) { + EVar4 = xEventGroupWaitBits((EventGroupHandle_t)(param_2 + 7),1,1,0,(iVar7 + 1) * 1000000); + if ((EVar4 & 1) == 0) { + xQueueSemaphoreTake(*(QueueHandle_t *)(param_1 + 0x18),0xffffffff); + *param_1 = '\x02'; + if ((*(ushort *)(param_2 + 6) & 0x20) == 0) { + param_2[0xf] = (char *)0x6e; + cmd_complete((bl_cmd *)(param_1 + 8)); + } + xQueueGenericSend(*(QueueHandle_t *)(param_1 + 0x18),(void *)0x0,0,0); + } + vEventGroupDelete((EventGroupHandle_t)(param_2 + 7)); + } + else { + param_2[0xf] = (char *)0x0; + } + uVar3 = 0; + } + return uVar3; +} + + + +void cmd_mgr_drain(bl_cmd_mgr *cmd_mgr) + +{ + list_head *plVar1; + list_head *plVar2; + list_head *plVar3; + list_head *plVar4; + + xQueueSemaphoreTake((QueueHandle_t)cmd_mgr->lock,0xffffffff); + plVar2 = (cmd_mgr->cmds).next; + plVar3 = plVar2->next; + while (plVar1 = plVar3, plVar2 != &cmd_mgr->cmds) { + plVar4 = plVar2->prev; + plVar3 = plVar2->next; + plVar3->prev = plVar4; + plVar4->next = plVar3; + plVar2->next = (list_head *)0x100100; + plVar2->prev = (list_head *)0x200200; + cmd_mgr->queue_sz = cmd_mgr->queue_sz - 1; + if ((*(ushort *)&plVar2[3].next & 1) == 0) { + xEventGroupSetBits((EventGroupHandle_t)&plVar2[3].prev,1); + } + plVar3 = plVar1->next; + plVar2 = plVar1; + } + xQueueGenericSend((QueueHandle_t)cmd_mgr->lock,(void *)0x0,0,0); + return; +} + + + +void bl_cmd_mgr_init(bl_cmd_mgr *cmd_mgr) + +{ + QueueHandle_t pQVar1; + + (cmd_mgr->cmds).next = &cmd_mgr->cmds; + (cmd_mgr->cmds).prev = &cmd_mgr->cmds; + pQVar1 = xQueueCreateMutex('\x01'); + cmd_mgr->max_queue_sz = 8; + cmd_mgr->queue = cmd_mgr_queue; + cmd_mgr->print = cmd_mgr_print; + cmd_mgr->drain = cmd_mgr_drain; + cmd_mgr->llind = cmd_mgr_llind; + *(QueueHandle_t *)&cmd_mgr->lock = pQVar1; + cmd_mgr->msgind = cmd_mgr_msgind; + return; +} + + + +int bl_irqs_init(bl_hw *bl_hw) + +{ + return 0; +} + + + +void bl_irq_bottomhalf(bl_hw *bl_hw) + +{ + uint uVar1; + uint status; + TickType_t TVar2; + + xTaskGetTickCount(); + uVar1 = 0; + status = ipc_host_get_rawstatus(bl_hw->ipc_env); + do { + while (status != 0) { + uVar1 = uVar1 | status; + ipc_host_irq(bl_hw->ipc_env,status); + status = ipc_host_get_rawstatus(bl_hw->ipc_env); + } + TVar2 = xTaskGetTickCount(); + if ((uVar1 & 8) != 0) { + (bl_hw->stats).last_rx = TVar2; + } + if ((uVar1 & 0x780) != 0) { + (bl_hw->stats).last_tx = TVar2; + } + ipc_host_enable_irq(bl_hw->ipc_env,0x7ff); + status = ipc_host_get_rawstatus(bl_hw->ipc_env); + } while (status != 0); + return; +} + + + +uint32_t BLE_ROM_patch(void *pRet,...) + +{ + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void blecontroller_main(void *pvParameters) + +{ + BaseType_t BVar1; + char acStack24 [4]; + rw_task_msg_t msg; + + (*ble_memset_ptr)(acStack24,0,8); + do { + BVar1 = xQueueReceive(xRwmainQueue,acStack24,0xffffffff); + if ((BVar1 == 1) && (acStack24[0] == '\x01')) { + hci_send_2_controller(msg._0_4_); + } + rwip_schedule(); + } while( true ); +} + + + +void BLE_ROM_hook_init(void) + +{ + _rom_patch_hook = BLE_ROM_patch; + ble_memcmp_ptr = memcmp; + ble_memcpy_ptr = memcpy; + ble_memset_ptr = memset; + ble_post_task_ptr = rw_main_task_post_from_fw; + return; +} + + + +_Bool rw_main_task_post(void *msg,uint32_t timeout) + +{ + BaseType_t BVar1; + + if (msg != (void *)0x0) { + BVar1 = xQueueGenericSend(xRwmainQueue,msg,timeout,0); + return (_Bool)(BVar1 == 1); + } + return false; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void rw_main_task_post_from_fw(void) + +{ + BaseType_t BStack28; + BaseType_t xHigherPriorityTaskWoken; + rw_task_msg_t msg; + + xHigherPriorityTaskWoken._0_1_ = 2; + if (TrapNetCounter == 0) { + rw_main_task_post(&xHigherPriorityTaskWoken,0xffffffff); + } + else { + BStack28 = 0; + xQueueGenericSendFromISR(xRwmainQueue,&xHigherPriorityTaskWoken,&BStack28,0); + if (BStack28 == 1) { + vTaskSwitchContext(); + } + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void bdaddr_init(void) + +{ + uint8_t uVar1; + uint8_t uVar2; + byte bStack24; + byte bStack23; + undefined2 uStack22; + uint8_t addr [6]; + + bl_wifi_mac_addr_get(&bStack24); + uVar2 = addr[1]; + uVar1 = addr[0]; + addr[1] = bStack24; + addr[0] = bStack23; + bStack23 = uVar1; + uStack22 = uStack22 >> 8 | uStack22 << 8; + if (uVar2 == -1) { + bStack23 = uVar1 + 1; + bStack24 = 0; + } + else { + bStack24 = uVar2 + 1; + } + co_bdaddr_set(&bStack24); + printf("BD_ADDR:%02x:%02x:%02x:%02x:%02x:%02x\r\n",(uint)addr[0],(uint)uStack22._1_1_, + (uint)(byte)uStack22,(uint)bStack23,(uint)bStack24); + return; +} + + + +void ble_controller_init(uint8_t task_priority) + +{ + undefined3 in_register_00002029; + + BLE_ROM_hook_init(); + rfc_init(40000000); + Is_ext_scan_enable = '\0'; + Is_ready_to_rec_auxpacket = '\0'; + rwble_isr_clear(); + bl_irq_pending_clear(0x48); + bl_irq_register(0x48,rwble_isr); + bl_irq_enable(0x48); + bdaddr_init(); + rwip_init(error); + xRwmainQueue = xQueueGenericCreate(0x14,8,'\0'); + xTaskCreate(blecontroller_main,"blecontroller",0x200,(void *)0x0, + CONCAT31(in_register_00002029,task_priority),(TaskHandle_t *)&rw_main_task_hdl); + return; +} + + + +void ble_controller_deinit(void) + +{ + BaseType_t BVar1; + undefined auStack24 [4]; + int iStack20; + + (*ble_memset_ptr)(auStack24,0,8); + bl_irq_disable(0x48); + vTaskDelete((TaskHandle_t)rw_main_task_hdl); + rw_main_task_hdl = 0; + while (BVar1 = xQueueReceive(xRwmainQueue,auStack24,0), BVar1 == 1) { + if (iStack20 != 0) { + ble_ke_msg_free((ke_msg *)(iStack20 + -0xc)); + } + } + vQueueDelete(xRwmainQueue); + xRwmainQueue = (QueueHandle_t)0x0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rwble_init(void) + +{ + em_buf_init(); + lld_init(false); + llc_init(); + llm_init(false); + _DAT_28000050 = 0; + return; +} + + +/* +Unable to decompile 'rwble_reset' +Cause: Exception while decompiling 2300b132: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rwble_isr_clear(void) + +{ + if (_DAT_28000010 != 0) { + _DAT_28000018 = 0xffffffff; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rwble_isr(void) + +{ + uint uVar1; + + while (uVar1 = _DAT_28000010, _DAT_28000010 != 0) { + if ((_DAT_28000010 & 4) != 0) { + _DAT_28000018 = 4; + rwip_wakeup(); + } + if ((uVar1 & 1) != 0) { + _DAT_28000018 = 1; + rwip_wakeup_end(); + ea_finetimer_isr(); + } + if ((uVar1 & 0x80) != 0) { + _DAT_28000018 = 0x80; + ea_finetimer_isr(); + } + if ((uVar1 & 8) != 0) { + _DAT_28000018 = 8; + if ((uVar1 & 2) != 0) { + _DAT_28000018 = 2; + uVar1 = uVar1 & 0xfffffffd; + } + if ((int)(uVar1 << 0xf) < 0) { + if (Is_ready_to_rec_auxpacket == '\0') { + Is_ready_to_rec_auxpacket = '\x01'; + } + _DAT_28000018 = 0x10000; + } + lld_evt_end_isr(false); + } + if ((uVar1 & 0x10008) == 0x10000) { + if (Is_ready_to_rec_auxpacket == '\0') { + Is_ready_to_rec_auxpacket = '\x01'; + Rec_sync_basecnt = _DAT_280000a8; + Rec_sync_fnt = _DAT_280000ac; + } + _DAT_28000018 = 0x10000; + if ((uVar1 & 2) != 0) { + _DAT_28000018 = 2; + uVar1 = uVar1 & 0xfffffffd; + } + lld_evt_afs_isr((uint8_t)(Rec_sync_fnt >> 0x10)); + } + if ((uVar1 & 0x100) != 0) { + _DAT_28000018 = 0x100; + if ((uVar1 & 2) != 0) { + _DAT_28000018 = 2; + uVar1 = uVar1 & 0xfffffffd; + } + lld_evt_end_isr(true); + } + if ((uVar1 & 2) != 0) { + _DAT_28000018 = 2; + lld_evt_rx_isr(); + } + if ((uVar1 & 0x200) != 0) { + _DAT_28000018 = 0x200; + ea_sw_isr(); + } + if ((uVar1 & 0x40) != 0) { + _DAT_28000018 = 0x40; + lld_evt_timer_isr(); + } + if ((uVar1 & 0x10) != 0) { + _DAT_28000018 = 0x10; + lld_crypt_isr(); + } + if ((uVar1 & 0x20) != 0) { + _DAT_28000018 = 0x20; + } + } + return; +} + + + +uint8_t ea_conflict_check(ea_elt_tag *evt_a,ea_elt_tag *evt_b) + +{ + uint8_t uVar1; + uint uVar2; + uint uVar3; + int iVar4; + uint uVar5; + + uVar2 = evt_b->timestamp - evt_a->timestamp & 0x7ffffff; + uVar5 = (uint)evt_a->delay; + uVar3 = (uint)evt_b->delay; + if (uVar2 < 0x4000001) { + if (uVar2 == 0) goto LAB_2300b31e; +LAB_2300b36a: + iVar4 = (uVar5 + evt_a->duration_min) - uVar3; + uVar1 = '\0'; + if ((0 < iVar4) && (uVar1 = '\0', (int)((iVar4 + -1) / -0x271 + uVar2) < 1)) { + uVar1 = '\x01'; + iVar4 = iVar4 - (uint)evt_b->duration_min; + if (0 < iVar4) { + return ((int)((iVar4 + -1) / -0x271 + uVar2) < 1) + '\x01'; + } + } + } + else { + uVar2 = -(evt_a->timestamp - evt_b->timestamp & 0x7ffffff); + if (uVar2 == 0) { +LAB_2300b31e: + if (uVar5 < uVar3) goto LAB_2300b36a; + } + iVar4 = (uVar3 + (uint)evt_b->duration_min) - uVar5; + uVar1 = '\x05'; + if ((0 < iVar4) && (-1 < (int)((iVar4 + -1) / 0x271 + uVar2))) { + iVar4 = ((uVar5 + evt_a->duration_min) - uVar3) - (uint)evt_b->duration_min; + uVar1 = '\x04'; + if (iVar4 < 1) { + uVar1 = ((int)(iVar4 / -0x271 + uVar2) < 0) + '\x03'; + } + } + } + return uVar1; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ea_elt_cancel(ea_elt_tag *param_1) + +{ + ushort uVar1; + ea_elt_tag *peVar2; + uint8_t uVar3; + undefined3 extraout_var; + uint uVar4; + uint uVar5; + ea_elt_tag *evt_b; + uint uVar6; + uint uVar7; + ea_elt_tag *peVar8; + ea_elt_tag *evt_a; + ea_elt_tag *elt_ref_hdr; + ea_elt_tag *elt_ref_hdr_00; + + peVar8 = (ea_elt_tag *)ea_env.elt_canceled.first; + evt_a = (ea_elt_tag *)0; +LAB_2300b3e6: + do { + do { + elt_ref_hdr = evt_a; + evt_a = peVar8; + if (evt_a == (ea_elt_tag *)0x0) { + if (ea_env.elt_canceled.first != (co_list_hdr *)0x0) { + _DAT_28000000 = _DAT_28000000 & 0xefffffff | 0x10000000; + } + return; + } + uVar1 = evt_a->asap_settings; + peVar8 = *(ea_elt_tag **)&evt_a->hdr; + } while ((uVar1 >> 0xe == 0) || (uVar5 = (int)(uint)uVar1 >> 4 & 0x3f, uVar5 == 0)); + uVar4 = (uint)uVar1 & 0xfffffc0f; + evt_a->current_prio = ((byte)uVar1 & 0xf) + evt_a->current_prio; + uVar5 = (uVar5 - 1) * 0x10; + uVar6 = uVar5 & 0xffff | uVar4; + evt_a->asap_settings = (ushort)uVar5 | (ushort)uVar4; + uVar5 = (int)uVar6 >> 0xc & 3; + peVar2 = param_1; + elt_ref_hdr_00 = (ea_elt_tag *)0x0; + while (evt_b = peVar2, evt_b != (ea_elt_tag *)0x0) { + uVar3 = ea_conflict_check(evt_a,evt_b); + if (CONCAT31(extraout_var,uVar3) == 0) break; + if (CONCAT31(extraout_var,uVar3) != 5) { + uVar4 = (uint)evt_b->delay + (uint)evt_b->duration_min; + uVar7 = uVar4 / 0x271 + evt_b->timestamp; + if ((uint)evt_a->delay < uVar4 % 0x271) { + uVar7 = uVar7 + 1; + } + if (uVar5 == 1) { + uVar7 = uVar7 | 1; + } + else { + if (uVar5 == 0) { + uVar7 = uVar7 + 1 & 0xfffffffe; + } + } + uVar7 = uVar7 & 0x7ffffff; + evt_a->timestamp = uVar7; + if (1 < uVar6 >> 0xe) { + uVar4 = evt_a->asap_limit - uVar7 & 0x7ffffff; + if (0x4000000 < uVar4) { + uVar4 = -(uVar7 - evt_a->asap_limit & 0x7ffffff); + } + if ((int)uVar4 < (int)((uint)evt_a->duration_min / 0x271)) goto LAB_2300b3e6; + } + } + peVar2 = *(ea_elt_tag **)&evt_b->hdr; + elt_ref_hdr_00 = evt_b; + } + ble_co_list_extract_after(&ea_env.elt_canceled,(co_list_hdr *)elt_ref_hdr,(co_list_hdr *)evt_a); + ble_co_list_insert_after((co_list *)&ea_env,(co_list_hdr *)elt_ref_hdr_00,(co_list_hdr *)evt_a); + evt_a = elt_ref_hdr; + } while( true ); +} + + + +void ea_init(_Bool reset) + +{ + ble_co_list_init((co_list *)&ea_env); + ble_co_list_init(&ea_env.elt_canceled); + ble_co_list_init(&ea_env.interval_list); + ea_env.elt_prog = (ea_elt_tag *)0x0; + ea_env.finetarget_time = 0xffffffff; + return; +} + + + +ea_elt_tag * ea_elt_create(uint16_t size_of_env) + +{ + undefined2 in_register_0000202a; + ea_elt_tag *peVar1; + uint32_t size; + + size = CONCAT22(in_register_0000202a,size_of_env) + 0x2c; + peVar1 = (ea_elt_tag *)ble_ke_malloc(size,'\0'); + if (peVar1 != (ea_elt_tag *)0x0) { + (*ble_memset_ptr)(peVar1,0,size); + } + return peVar1; +} + + + +ea_interval_tag * ea_interval_create(void) + +{ + ea_interval_tag *peVar1; + + peVar1 = (ea_interval_tag *)ble_ke_malloc(0x10,'\0'); + (*ble_memset_ptr)(peVar1,0,0x10); + return peVar1; +} + + + +void ea_interval_insert(ea_interval_tag *interval_to_add) + +{ + ble_co_list_push_back(0x42010f18,interval_to_add); + return; +} + + + +void ea_interval_remove(ea_interval_tag *interval_to_remove) + +{ + ble_co_list_extract(&ea_env.interval_list,(co_list_hdr *)interval_to_remove,'\0'); + return; +} + + + +void ea_sw_isr(void) + +{ + co_list_hdr *pcVar1; + + while (ea_env.elt_canceled.first != (co_list_hdr *)0x0) { + pcVar1 = ble_co_list_pop_front(&ea_env.elt_canceled); + if (pcVar1[9].next != (co_list_hdr *)0x0) { + (*(code *)pcVar1[9].next)(); + } + } + return; +} + + + +uint8_t ea_offset_req(ea_param_input *input_param,ea_param_output *output_param) + +{ + uint16_t uVar1; + ushort uVar2; + uint uVar3; + uint uVar4; + co_list_hdr cVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint8_t uVar9; + uint uVar10; + int iVar11; + uint uVar12; + uint uVar13; + uint uVar14; + + uVar13 = (uint)output_param->interval; + if (output_param->interval != 0) { + uVar14 = output_param->duration & 0xffff; + if (uVar14 != 0) { + if (input_param->action == '\x01') { + uVar6 = (uint)input_param->offset; + } + else { + uVar6 = (uint)input_param->odd_offset; + } + uVar3 = output_param->duration & 0xffff; + cVar5 = (co_list_hdr)ea_env.interval_list.first; +LAB_2300b634: + do { + uVar7 = uVar6; + if (cVar5 == (co_list_hdr)0x0) { + uVar9 = '\x03'; + if (uVar7 < uVar13) { +LAB_2300b644: + output_param->offset = (uint16_t)uVar7; + uVar9 = '\0'; + } + return uVar9; + } + if (uVar13 <= uVar7) { + return '\x03'; + } + uVar1 = input_param->role; + if (uVar1 == 0xff) goto LAB_2300b644; + uVar2 = *(ushort *)&((co_list_hdr *)((int)cVar5 + 4))->next; + uVar6 = (uint)uVar2; + if (((uVar2 != 0) && + (uVar2 = *(ushort *)&((co_list_hdr *)((int)cVar5 + 8))->next, uVar10 = (uint)uVar2, + uVar2 != 0)) && (*(uint16_t *)((int)cVar5 + 10) != input_param->conhdl)) { + uVar4 = uVar6; + if (uVar13 < uVar6) { + uVar4 = uVar13; + } + if ((*(uint16_t *)&((co_list_hdr *)((int)cVar5 + 0xc))->next == uVar1) && + ((uVar1 != 1 || (*(uint16_t *)((int)cVar5 + 0xe) == input_param->linkid)))) { + if (uVar4 < uVar3 + uVar10) { + return '\x03'; + } + iVar11 = uVar10 - 1; + uVar10 = (uint)*(ushort *)((int)cVar5 + 6) % uVar4; + } + else { + if (uVar4 < uVar3 + uVar10) { + return '\x03'; + } + iVar11 = uVar10 + 1; + uVar10 = (int)(*(ushort *)((int)cVar5 + 6) + uVar4 + -1) % uVar4 & 0xffff; + } + uVar12 = iVar11 + uVar10 & 0xffff; + if ((uVar13 % uVar4 == 0) && (uVar6 % uVar4 == 0)) { + uVar6 = uVar7 % uVar4; + uVar8 = uVar6 + (uVar14 - 1) & 0xffff; + if (uVar6 < uVar10) { + if (uVar8 < uVar10) { +LAB_2300b716: + if (uVar8 < uVar12) goto LAB_2300b71a; + } + } + else { + if (uVar12 < uVar6) { + if (uVar8 < uVar10) { + if (uVar10 == uVar6) goto LAB_2300b716; + } + else { + if ((uVar8 <= uVar12) || (uVar6 <= uVar10)) goto LAB_2300b6f4; + } +LAB_2300b71a: + if (((uVar12 < uVar4) || (uVar12 % uVar4 < uVar6)) && + ((uVar8 < uVar4 || (uVar8 % uVar4 < uVar10)))) goto LAB_2300b6bc; + } + } +LAB_2300b6f4: + cVar5 = (co_list_hdr)ea_env.interval_list.first; + uVar6 = uVar13; + if (input_param->action != '\x01') { + uVar6 = (int)(uVar12 + 1) % uVar4; + while (uVar6 <= uVar7) { + uVar6 = uVar6 + uVar4 & 0xffff; + } + if (input_param->odd_offset == false) { + if ((uVar6 & 1) == 0) goto LAB_2300b634; + } + else { + if ((uVar6 & 1) != 0) goto LAB_2300b634; + } + uVar6 = uVar6 + 1 & 0xffff; + } + goto LAB_2300b634; + } + } +LAB_2300b6bc: + cVar5 = *(co_list_hdr *)cVar5; + uVar6 = uVar7; + } while( true ); + } + } + return '\x01'; +} + + + +// WARNING: Removing unreachable block (ram,0x2300b784) + +uint32_t ea_time_get_halfslot_rounded(void) + +{ + // WARNING: Do nothing block with infinite loop + do { + } while( true ); +} + + + +// WARNING: Removing unreachable block (ram,0x2300b7a4) + +uint32_t ea_time_get_slot_rounded(void) + +{ + // WARNING: Do nothing block with infinite loop + do { + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ea_prog_timer(void) + +{ + byte bVar1; + _Bool time_msb; + uint32_t uVar2; + uint uVar3; + co_list_hdr cVar4; + + ea_env.finetarget_time = 0xffffffff; + uVar2 = ea_time_get_slot_rounded(); + if (ea_env.elt_wait.first == (co_list_hdr *)0x0) { + if (ea_env.finetarget_time == 0xffffffff) { + _DAT_2800000c = _DAT_2800000c & 0xffffff7f; + _DAT_28000018 = 0x80; + goto LAB_2300b898; + } + } + else { + ea_env.finetarget_time = + (uint)((int)ea_env.elt_wait.first[2].next - + (uint)*(byte *)((int)&ea_env.elt_wait.first[6].next + 1)) & 0x7ffffff; + if (ea_env.elt_prog != (ea_elt_tag *)0x0) { + if (((ea_env.elt_prog)->current_prio < *(byte *)((int)&ea_env.elt_wait.first[5].next + 2)) && + ((int)((uint)*(ushort *)&ea_env.elt_wait.first[4].next << 0x14) < 0)) { + bVar1 = (ea_env.elt_prog)->stop_latency2; + } + else { + bVar1 = (ea_env.elt_prog)->stop_latency1; + } + if ((uint)*(byte *)((int)&ea_env.elt_wait.first[6].next + 1) < (uint)bVar1) { + ea_env.finetarget_time = + (uint)((int)ea_env.elt_wait.first[2].next - (uint)bVar1) & 0x7ffffff; + uVar3 = ea_env.finetarget_time - uVar2 & 0x7ffffff; + if ((0x4000000 < uVar3) || (uVar3 == 0)) { + ea_env.finetarget_time = uVar2 + 1 & 0x7ffffff; + } + } + } + } + uVar2 = ea_time_get_slot_rounded(); + if (uVar2 - ea_env.finetarget_time < 0x3ffffff) { + ea_env.finetarget_time = uVar2 + 1 & 0x7ffffff; + } + _DAT_280000f8 = ea_env.finetarget_time; + if ((_DAT_2800000c >> 7 & 1) == 0) { + _DAT_28000018 = 0x80; + _DAT_2800000c = _DAT_2800000c | 0x80; + } +LAB_2300b898: + if ((time_msb != false) && + (cVar4 = (co_list_hdr)ea_env.interval_list.first, -1 < (int)(uVar2 << 5))) { + while (cVar4 != (co_list_hdr)0x0) { + uVar3 = (uint)*(ushort *)&((co_list_hdr *)((int)cVar4 + 4))->next; + *(undefined2 *)((int)cVar4 + 6) = + (short)((int)((uVar3 - 0x8000000 % uVar3) + (uint)*(ushort *)((int)cVar4 + 6)) % uVar3); + cVar4 = *(co_list_hdr *)cVar4; + } + } + return; +} + + +/* +Unable to decompile 'ea_elt_insert' +Cause: Exception while decompiling 2300b8e8: Decompiler process died + +*/ + +/* +Unable to decompile 'ea_elt_remove' +Cause: Exception while decompiling 2300bb56: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ea_finetimer_isr(void) + +{ + byte bVar1; + ea_elt_tag *peVar2; + uint32_t uVar3; + co_list_hdr *pcVar4; + ea_elt_tag *peVar5; + uint uVar6; + + peVar2 = ea_env.elt_prog; + pcVar4 = ea_env.elt_wait.first; + uVar3 = ea_time_get_halfslot_rounded(); + if (peVar2 != (ea_elt_tag *)0x0) { + if (pcVar4 == (co_list_hdr *)0x0) goto LAB_2300bc68; + if ((peVar2->current_prio < *(byte *)((int)&pcVar4[5].next + 2)) && + ((int)((uint)*(ushort *)&pcVar4[4].next << 0x14) < 0)) { + bVar1 = peVar2->stop_latency2; + } + else { + bVar1 = peVar2->stop_latency1; + } + uVar6 = (uint)((int)pcVar4[2].next - uVar3) & 0x7ffffff; + if ((0x4000000 < uVar6) || (uVar6 <= bVar1)) { + if (peVar2->ea_cb_stop != (anon_subr_void_ea_elt_tag_ptr_for_ea_cb_stop *)0x0) { + (*peVar2->ea_cb_stop)(peVar2); + } + ea_env.elt_prog = (ea_elt_tag *)0x0; + } + } + if (pcVar4 != (co_list_hdr *)0x0) { + do { + uVar6 = (uint)((int)pcVar4[2].next - (uint)*(byte *)((int)&pcVar4[6].next + 1)) & 0x7ffffff; + if ((uVar6 - uVar3 & 0x7ffffff) < 0x3ffffff) { + if (uVar6 == uVar3) { + peVar5 = (ea_elt_tag *)ble_co_list_pop_front((co_list *)&ea_env); + if ((ea_env.elt_prog != (ea_elt_tag *)0x0) && + ((ea_env.elt_prog)->ea_cb_stop != (anon_subr_void_ea_elt_tag_ptr_for_ea_cb_stop *)0x0)) + { + (*(ea_env.elt_prog)->ea_cb_stop)(peVar2); + } + ea_env.elt_prog = peVar5; + if (peVar5->ea_cb_start != (anon_subr_void_ea_elt_tag_ptr_for_ea_cb_start *)0x0) { + (*peVar5->ea_cb_start)(peVar5); + } + } + break; + } + pcVar4 = ble_co_list_pop_front((co_list *)&ea_env); + ble_co_list_push_back(0x42010f10,pcVar4); + pcVar4 = ea_env.elt_wait.first; + } while (ea_env.elt_wait.first != (co_list_hdr *)0x0); + } +LAB_2300bc68: + if (ea_env.elt_canceled.first != (co_list_hdr *)0x0) { + _DAT_28000000 = _DAT_28000000 & 0xefffffff | 0x10000000; + } + ea_prog_timer(); + return; +} + + + +void ea_interval_duration_req(ea_param_input *input_param,ea_param_output *output_param) + +{ + bool bVar1; + co_list_hdr cVar2; + uint uVar3; + uint uVar4; + byte bVar5; + uint uVar6; + uint uVar7; + uint32_t uVar8; + uint uVar9; + + uVar3 = (uint)input_param->interval_max; + output_param->interval = input_param->interval_max; + uVar9 = (uint)input_param->interval_min; + if (uVar3 <= uVar9) goto LAB_2300bd0e; + bVar5 = 0; + cVar2 = (co_list_hdr)ea_env.interval_list.first; + uVar4 = 0xffff; + while (cVar2 != (co_list_hdr)0x0) { + bVar5 = bVar5 + 1; + uVar6 = uVar4; + if ((*(uint16_t *)((int)cVar2 + 10) != input_param->conhdl) && + (uVar6 = (uint)*(ushort *)&((co_list_hdr *)((int)cVar2 + 4))->next, uVar4 < uVar6)) { + uVar6 = uVar4; + } + cVar2 = *(co_list_hdr *)cVar2; + uVar4 = uVar6; + } + if (bVar5 < 2) { + uVar4 = (uint)input_param->pref_period; + if (input_param->pref_period != 0) { + uVar6 = (int)uVar3 / (int)uVar4; +LAB_2300bcfa: + uVar7 = uVar4 * uVar6 & 0xffff; + goto LAB_2300bd02; + } + uVar7 = 0xffff; + } + else { + if (uVar4 <= uVar3) { + uVar6 = uVar3 / uVar4; + goto LAB_2300bcfa; + } + uVar7 = 0xffff; + uVar6 = uVar3; + do { + bVar1 = uVar4 % uVar6 != 0; + if (!bVar1) { + uVar7 = uVar6; + } + uVar6 = uVar6 - 2 & 0xffff; + } while ((uVar9 <= uVar6) && (bVar1)); +LAB_2300bd02: + if (uVar7 < uVar9) goto LAB_2300bd0e; + } + if (uVar7 <= uVar3) { + output_param->interval = (uint16_t)uVar7; + } +LAB_2300bd0e: + uVar8 = input_param->duration_min; + if (uVar8 < 2) { + uVar8 = 2; + } + output_param->duration = uVar8; + return; +} + + + +void hci_send_2_host(void *param) + +{ + byte bVar1; + ushort uVar2; + ke_msg *msg; + void *pvVar3; + uint uVar4; + uint uVar5; + + uVar2 = *(ushort *)((int)param + -8); + msg = (ke_msg *)((int)param + -0xc); + if (uVar2 == 0x803) { + bVar1 = *(byte *)((int)param + -4); + uVar4 = (uint)bVar1; + if (bVar1 < 0x40) goto LAB_2300bdca; + if ((bVar1 < 0x58) && + (uVar5 = uVar4 - 0x40 & 0xff, + ((int)(uint)hci_env.evt_msk_page_2.mask[uVar5 >> 3] >> (uVar5 - (uVar4 - 0x40 & 0xf8) & 0x1f) + & 1U) == 0)) goto switchD_2300bdbc_caseD_4; +switchD_2300bdbc_caseD_2: + hci_build_evt(msg); + } + else { + if (uVar2 == 0x804) { + uVar4 = 0x3e; +LAB_2300bdca: + uVar5 = uVar4 - 1 & 0xff; + if (((int)(uint)hci_env.evt_msk.mask[uVar5 >> 3] >> (uVar5 - (uVar4 - 1 & 0xf8) & 0x1f) & 1U) + == 0) goto switchD_2300bdbc_caseD_4; + } + switch((uint)uVar2 - 0x801 & 0xffff) { + case 0: + case 1: + if (uVar2 == 0x801) { + hci_build_cc_evt(msg,'\0'); + } + break; + case 2: + goto switchD_2300bdbc_caseD_2; + case 3: + hci_build_le_evt(msg); + break; + default: +switchD_2300bdbc_caseD_4: + ble_ke_msg_free(msg); + return; + case 5: + pvVar3 = ble_ke_msg_alloc(0x806,*(ke_task_id_t *)((int)param + -6), + *(ke_task_id_t *)((int)param + -4),8); + (*ble_memcpy_ptr)(pvVar3,param,8); + ble_ke_msg_free(msg); + msg = (ke_msg *)((int)pvVar3 + -0xc); + param = pvVar3; + } + } + msg->dest_id = 4; + ble_ke_msg_send(param); + return; +} + + + +void hci_send_2_controller(int param_1) + +{ + hci_cmd_desc_tag *phVar1; + ushort uVar2; + + if (*(short *)(param_1 + -8) == 0x805) { + phVar1 = hci_look_for_cmd_desc(*(uint16_t *)(param_1 + -4)); + if (phVar1 == (hci_cmd_desc_tag *)0x0) goto switchD_2300bef4_caseD_4; + switch((uint)phVar1->dest_field & 0xf) { + case 0: + case 2: + uVar2 = 0; + break; + case 1: + case 3: + goto switchD_2300bef4_caseD_1; + default: + goto switchD_2300bef4_caseD_4; + case 8: + uVar2 = 3; + } + } + else { + if (*(short *)(param_1 + -8) != 0x807) goto switchD_2300bef4_caseD_4; +switchD_2300bef4_caseD_1: + if (1 < *(ushort *)(param_1 + -6)) { +switchD_2300bef4_caseD_4: + ble_ke_msg_free((ke_msg *)(param_1 + -0xc)); + return; + } + uVar2 = (ushort)(((uint)*(ushort *)(param_1 + -6) & 0xff) << 8) | 1; + } + *(ushort *)(param_1 + -6) = uVar2; + ble_ke_msg_send(param_1); + return; +} + + + +uint8_t hci_evt_mask_set(evt_mask *evt_msk,uint8_t page) + +{ + undefined3 in_register_0000202d; + byte *pbVar1; + int iVar2; + hci_env_tag *phVar3; + + if (CONCAT31(in_register_0000202d,page) == 2) { + (*ble_memcpy_ptr)((void *)0x4201961c,evt_msk,8); + } + else { + if (CONCAT31(in_register_0000202d,page) == 3) { + (*ble_memcpy_ptr)(&hci_env,evt_msk,8); + iVar2 = 0; + phVar3 = &hci_env; + do { + pbVar1 = hci_rsvd_evt_msk.mask + iVar2; + iVar2 = iVar2 + 1; + (phVar3->evt_msk).mask[0] = *pbVar1 | (phVar3->evt_msk).mask[0]; + phVar3 = (hci_env_tag *)((phVar3->evt_msk).mask + 1); + } while (iVar2 != 8); + } + } + return '\0'; +} + + + +void hci_init(void) + +{ + (*ble_memset_ptr)(&hci_env,0,0x10); + hci_evt_mask_set(&hci_def_evt_msk,'\x03'); + hci_tl_init(false); + hci_fc_init(); + return; +} + + + +void hci_reset(void) + +{ + (*ble_memset_ptr)(&hci_env,0,0x10); + hci_evt_mask_set(&hci_def_evt_msk,'\x03'); + hci_tl_init(true); + hci_fc_init(); + return; +} + + +/* +Unable to decompile 'rwip_reset' +Cause: Exception while decompiling 2300bffc: Decompiler process died + +*/ + + +void rwip_init(uint32_t error) + +{ + (*ble_memset_ptr)(&rwip_env,0,0x10); + ble_ke_init(); + ble_ke_mem_init('\0',(uint8_t *)rwip_heap_ram,0xaff); + ble_ke_mem_init('\x01',rwip_heap_em,0x10b6); + ble_rf_init((rwip_rf_api_conflict5 *)&rwip_rf); + ecc_init(0); + hci_init(); + rwble_init(); + ea_init(false); + rwip_env._8_4_ = 200; + rwip_env.sleep_acc_error = 0; + rwip_env._12_2_ = 0x101; + rwip_reset(); + return; +} + + + +void rwip_schedule(void) + +{ + if ((rwip_env.prevent_sleep & 1) == 0) { + ble_ke_event_schedule(); + return; + } + return; +} + + + +void rwip_wakeup_delay_set(uint16_t wakeup_delay) + +{ + undefined2 in_register_0000202a; + + rwip_env.lp_cycle_wakeup_delay = + (uint)(CONCAT22(in_register_0000202a,wakeup_delay) << 0xf) / 1000000; + return; +} + + +/* +Unable to decompile 'rwip_prevent_sleep_set' +Cause: Exception while decompiling 2300c106: Decompiler process died + +*/ + + +void rwip_wakeup(void) + +{ + rwip_prevent_sleep_set(1); + lld_sleep_wakeup(); + return; +} + + +/* +Unable to decompile 'rwip_prevent_sleep_clear' +Cause: Exception while decompiling 2300c138: Decompiler process died + +*/ + + +void rwip_wakeup_end(void) + +{ + if ((rwip_env.prevent_sleep & 1) != 0) { + lld_sleep_wakeup_end(); + ble_ke_event_set('\x03'); + rwip_prevent_sleep_clear(1); + return; + } + return; +} + + + +uint32_t rwip_sleep_lpcycles_2_us(uint32_t lpcycles) + +{ + uint uVar1; + + uVar1 = rwip_env.sleep_acc_error + lpcycles * 0x109; + rwip_env.sleep_acc_error = uVar1 & 0x1ff; + return lpcycles * 0x1e + (uVar1 >> 9); +} + + + +uint32_t rwip_us_2_lpcycles(uint32_t us) + +{ + return (us << 0xf) / 1000000; +} + + + +void ble_co_list_init(co_list *list) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,list,_rom_patch_hook); + if (uVar1 == 0) { + list->first = (co_list_hdr *)0x0; + list->last = (co_list_hdr *)0x0; + } + return; +} + + + +void ble_co_list_push_back(int *param_1,undefined4 *param_2) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,param_2,_rom_patch_hook); + if (uVar1 == 0) { + if (*param_1 == 0) { + *(undefined4 **)param_1 = param_2; + } + else { + *(undefined4 **)param_1[1] = param_2; + } + *(undefined4 **)(param_1 + 1) = param_2; + *param_2 = 0; + } + return; +} + + + +void ble_co_list_push_front(co_list *list,co_list_hdr *list_hdr) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,list,list_hdr,_rom_patch_hook); + if (uVar1 == 0) { + if (list->first == (co_list_hdr *)0x0) { + list->last = list_hdr; + } + list_hdr->next = list->first; + list->first = list_hdr; + } + return; +} + + + +co_list_hdr * ble_co_list_pop_front(co_list *list) + +{ + uint32_t uVar1; + co_list_hdr *pcVar2; + co_list_hdr *pcStack20; + co_list_hdr *element; + + uVar1 = (*_rom_patch_hook)(&pcStack20,list,_rom_patch_hook); + if (((uVar1 == 0) && (pcStack20 = list->first, pcStack20 != (co_list_hdr *)0x0)) && + (pcVar2 = pcStack20->next, list->first = pcVar2, pcVar2 == (co_list_hdr *)0x0)) { + list->last = (co_list_hdr *)0x0; + } + return pcStack20; +} + + + +// WARNING: Variable defined which should be unmapped: found +// WARNING: Type propagation algorithm not settling + +_Bool ble_co_list_extract(co_list *list,co_list_hdr *list_hdr,uint8_t nb_following) + +{ + int iVar1; + uint32_t uVar2; + undefined3 in_register_00002031; + co_list_hdr cVar3; + co_list_hdr cVar4; + co_list_hdr cVar5; + char acStack17 [4]; + _Bool found; + + iVar1 = CONCAT31(in_register_00002031,nb_following); + acStack17[0] = '\0'; + uVar2 = (*_rom_patch_hook)(acStack17,list,list_hdr,iVar1,_rom_patch_hook); + if (uVar2 == 0) { + cVar4 = (co_list_hdr)0x0; + cVar5 = (co_list_hdr)list->first; + while (cVar5 != (co_list_hdr)0x0) { + if (cVar5 == (co_list_hdr)list_hdr) { + acStack17[0] = '\x01'; + goto LAB_2300c2d8; + } + cVar4 = cVar5; + cVar5 = *(co_list_hdr *)cVar5; + } + if (acStack17[0] != '\0') { +LAB_2300c2d8: + while (cVar3 = *(co_list_hdr *)cVar5, iVar1 != 0) { + iVar1 = iVar1 + -1; + cVar5 = cVar3; + } + if (cVar4 == (co_list_hdr)0x0) { + *(co_list_hdr *)&list->first = cVar3; + } + else { + *(co_list_hdr *)cVar4 = cVar3; + } + if ((co_list_hdr)((co_list_hdr *)&list->last)->next == cVar5) { + *(co_list_hdr *)&((co_list_hdr *)&list->last)->next = cVar4; + } + } + } + return (_Bool)acStack17[0]; +} + + + +void ble_co_list_extract_after(co_list *list,co_list_hdr *elt_ref_hdr,co_list_hdr *elt_to_rem_hdr) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,list,elt_ref_hdr,elt_to_rem_hdr,_rom_patch_hook); + if (uVar1 == 0) { + if (elt_ref_hdr == (co_list_hdr *)0x0) { + list->first = list->first->next; + } + else { + elt_ref_hdr->next = elt_to_rem_hdr->next; + } + if (list->last == elt_to_rem_hdr) { + list->last = elt_ref_hdr; + } + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +_Bool ble_co_list_find(co_list *list,co_list_hdr *list_hdr) + +{ + uint32_t uVar1; + co_list_hdr cVar2; + bool abStack17 [4]; + _Bool ret; + + uVar1 = (*_rom_patch_hook)(abStack17,list,list_hdr,_rom_patch_hook); + if (uVar1 == 0) { + cVar2 = (co_list_hdr)list->first; + while ((cVar2 != (co_list_hdr)list_hdr && (cVar2 != (co_list_hdr)0x0))) { + cVar2 = *(co_list_hdr *)cVar2; + } + abStack17[0] = (co_list_hdr)list_hdr == cVar2; + } + return (_Bool)abStack17[0]; +} + + + +void ble_co_list_merge(int *param_1,int *param_2) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,param_2,_rom_patch_hook); + if (uVar1 == 0) { + if (*param_1 == 0) { + *param_1 = *param_2; + } + else { + *(int *)param_1[1] = *param_2; + } + param_1[1] = param_2[1]; + *param_2 = 0; + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void ble_co_list_insert_after(co_list *list,co_list_hdr *elt_ref_hdr,co_list_hdr *elt_to_add_hdr) + +{ + uint32_t uVar1; + co_list_hdr cVar2; + + uVar1 = (*_rom_patch_hook)((void *)0x0,list,elt_ref_hdr,elt_to_add_hdr,_rom_patch_hook); + if (uVar1 == 0) { + if (elt_ref_hdr == (co_list_hdr *)0x0) { +LAB_2300c3ea: + ble_co_list_push_back(list,elt_to_add_hdr); + return; + } + cVar2 = (co_list_hdr)list->first; + while (cVar2 != (co_list_hdr)elt_ref_hdr) { + if (cVar2 == (co_list_hdr)0x0) goto LAB_2300c3ea; + cVar2 = *(co_list_hdr *)cVar2; + } + if (elt_ref_hdr->next == (co_list_hdr *)0x0) { + list->last = elt_to_add_hdr; + } + elt_to_add_hdr->next = elt_ref_hdr->next; + elt_ref_hdr->next = elt_to_add_hdr; + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +uint16_t ble_co_list_size(co_list *list) + +{ + uint32_t uVar1; + int *piVar2; + uint16_t auStack18 [2]; + uint16_t count; + + auStack18[0] = 0; + uVar1 = (*_rom_patch_hook)(auStack18,list,_rom_patch_hook); + if (uVar1 == 0) { + piVar2 = (int *)list->first; + while (piVar2 != (int *)0x0) { + auStack18[0] = auStack18[0] + 1; + piVar2 = (int *)*piVar2; + } + } + return auStack18[0]; +} + + + +void co_bdaddr_set(uint8_t *bdaddr) + +{ + // WARNING: Could not recover jumptable at 0x2300c474. Too many branches + // WARNING: Treating indirect jump as call + (*ble_memcpy_ptr)(&co_default_bdaddr,bdaddr,6); + return; +} + + + +_Bool co_bdaddr_compare(bd_addr *bd_address1,bd_addr *bd_address2) + +{ + int iVar1; + + iVar1 = 0; + do { + if (bd_address1->addr[iVar1] != bd_address2->addr[iVar1]) { + return false; + } + iVar1 = iVar1 + 1; + } while (iVar1 != 6); + return true; +} + + + +void Mont2GF(uint8_t reg_idx) + +{ + sec_eng_pka0_pld(8,Inv_r,'\r','\x03','9',false); + sec_eng_pka0_clir('\x01','\x03','\x06','\0'); + sec_eng_pka0_clir('\x01','\x03','\a','\0'); + sec_eng_pka0_lmul('\0','\x04','\x03','\x03',reg_idx,'\x03','\r'); + sec_eng_pka0_mrem('\0','\x03',reg_idx,'\x04','\x03','\x03','\0'); + sec_eng_pka0_clir('\x01','\x04','\x03','\0'); + return; +} + + + +void getFinalPoint(uint8_t reg_idx) + +{ + sec_eng_pka0_clir('\x01','\x03','\x06','\0'); + sec_eng_pka0_clir('\x01','\x03','\a','\0'); + sec_eng_pka0_lmul('\0','\x04','\x03','\x03',reg_idx,'\x03','\x0e'); + sec_eng_pka0_mrem('\0','\x03',reg_idx,'\x04','\x03','\x03','\0'); + sec_eng_pka0_clir('\x01','\x04','\x03','\0'); + return; +} + + + +void pka_point_addition(uint8_t x1_idx,uint8_t x2_idx,uint8_t ret_idx) + +{ + uint8_t s0_reg_idx; + uint8_t s1_reg_idx; + uint8_t s1_reg_idx_00; + + s1_reg_idx = x1_idx + '\x02'; + s0_reg_idx = x1_idx + '\x01'; + sec_eng_pka0_mmul('\0','\x03','\r','\x03',x2_idx + '\x01','\x03',s1_reg_idx,'\x03',DAT_00000010); + s1_reg_idx_00 = x2_idx + '\x02'; + sec_eng_pka0_mmul('\0','\x03','\x0e','\x03',s0_reg_idx,'\x03',s1_reg_idx_00,'\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x0f','\x03',x2_idx,'\x03',s1_reg_idx,'\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x10','\x03',x1_idx,'\x03',s1_reg_idx_00,'\x03',DAT_00000010); + sec_eng_pka0_msub('\0','\x03','\r','\x03','\r','\x03','\x0e','\x03',DAT_00000010); + sec_eng_pka0_msub('\0','\x03','\x0f','\x03','\x0f','\x03','\x10','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',x1_idx,'\x03',s1_reg_idx,'\x03',s1_reg_idx_00,'\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',s0_reg_idx,'\x03','\x0f','\x03','\x0f','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',s1_reg_idx,'\x03',s0_reg_idx,'\x03','\x0f','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x11','\x03','\r','\x03','\r','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x11','\x03','\x11','\x03',x1_idx,'\x03',DAT_00000010); + sec_eng_pka0_msub('\0','\x03','\x11','\x03','\x11','\x03',s1_reg_idx,'\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x12','\x03','\t','\x03',s0_reg_idx,'\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x12','\x03','\x12','\x03','\x10','\x03',DAT_00000010); + sec_eng_pka0_msub('\0','\x03','\x12','\x03','\x11','\x03','\x12','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',s0_reg_idx,'\x03',s0_reg_idx,'\x03','\x10','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x0e','\x03',s1_reg_idx,'\x03','\x0e','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',ret_idx + '\x02','\x03',s1_reg_idx,'\x03',x1_idx,'\x03',DAT_00000010 + ); + sec_eng_pka0_mmul('\0','\x03',ret_idx,'\x03','\x0f','\x03','\x12','\x03',DAT_00000010); + sec_eng_pka0_msub('\0','\x03',s0_reg_idx,'\x03',s0_reg_idx,'\x03','\x12','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',s0_reg_idx,'\x03','\r','\x03',s0_reg_idx,'\x03',DAT_00000010); + sec_eng_pka0_msub('\x01','\x03',ret_idx + '\x01','\x03',s0_reg_idx,'\x03','\x0e','\x03', + DAT_00000010); + sec_eng_pka0_wait_4_isr(); + sec_eng_pka0_clear_int(); + return; +} + + + +void pka_read_result(ECC_Jacobian_Point256 *point,uint8_t idx) + +{ + sec_eng_pka0_read_data('\x03',idx,(uint32_t *)point,'\b'); + sec_eng_pka0_read_data('\x03',idx + '\x01',(uint32_t *)&point->y,'\b'); + sec_eng_pka0_read_data('\x03',idx + '\x02',(uint32_t *)&point->z,'\b'); + return; +} + + + +void pka_cp_x2_to_x1(uint8_t x1_idx,uint8_t x2_idx) + +{ + sec_eng_pka0_movdat('\0','\x03',x1_idx,'\x03',x2_idx); + sec_eng_pka0_movdat('\0','\x03',x1_idx + '\x01','\x03',x2_idx + '\x01'); + sec_eng_pka0_movdat('\0','\x03',x1_idx + '\x02','\x03',x2_idx + '\x02'); + return; +} + + + +void pka_point_inf_check(uint8_t x1_idx,uint8_t *p1_eq_inf) + +{ + byte bVar1; + byte bVar2; + uint uVar3; + byte abStack33 [4]; + uint8_t bitval; + + sec_eng_pka0_lcmp(abStack33,'\x03',x1_idx,'\x03','\b'); + bVar1 = abStack33[0]; + sec_eng_pka0_lcmp(abStack33,'\x03',x1_idx + '\x01','\x03','\x13'); + uVar3 = (uint)abStack33[0]; + sec_eng_pka0_lcmp(abStack33,'\x03','\x14','\x03',x1_idx + '\x01'); + bVar2 = abStack33[0]; + sec_eng_pka0_lcmp(abStack33,'\x03',x1_idx + '\x02','\x03','\b'); + *(bool *)p1_eq_inf = + (byte)(bVar2 << 2 | (byte)((uVar3 << 0x19) >> 0x18) | bVar1 | abStack33[0] << 3) == 0xf; + return; +} + + + +void GF2Mont(u_int32 *numA,u_int32 *result) + +{ + sec_eng_pka0_pld(8,(uint32_t *)&bigHexP256,'\0','\x03','9',false); + sec_eng_pka0_pld(8,numA,'\x01','\x03','9',false); + sec_eng_pka0_lmul2n('\0','\x04','\x01','\x03','\x01',0x100); + sec_eng_pka0_mrem('\0','\x03','\x04','\x04','\x01','\x03','\0'); + sec_eng_pka0_read_data('\x03','\x04',result,'\b'); + sec_eng_pka0_clir('\x01','\x04','\x01','\0'); + return; +} + + + +// WARNING: Variable defined which should be unmapped: pka_p1_eq_inf + +void pka_point_double(uint8_t x_idx) + +{ + uint8_t s0_reg_idx; + uint8_t s0_reg_idx_00; + uint8_t auStack17 [4]; + uint8_t pka_p1_eq_inf; + + pka_point_inf_check(x_idx,auStack17); + if (auStack17[0] == '\0') { + s0_reg_idx = x_idx + '\x02'; + sec_eng_pka0_mmul('\0','\x03','\r','\x03',x_idx,'\x03',x_idx,'\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x0e','\x03',s0_reg_idx,'\x03',s0_reg_idx,'\x03',DAT_00000010); + sec_eng_pka0_msub('\0','\x03','\r','\x03','\r','\x03','\x0e','\x03',DAT_00000010); + s0_reg_idx_00 = x_idx + '\x01'; + sec_eng_pka0_mmul('\0','\x03','\r','\x03','\n','\x03','\r','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x0e','\x03',s0_reg_idx_00,'\x03',s0_reg_idx,'\x03',DAT_00000010) + ; + sec_eng_pka0_mmul('\0','\x03','\x0f','\x03',x_idx,'\x03',s0_reg_idx_00,'\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',s0_reg_idx,'\x03','\r','\x03','\r','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x0f','\x03','\x0f','\x03','\x0e','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',x_idx,'\x03','\f','\x03','\x0f','\x03',DAT_00000010); + sec_eng_pka0_msub('\0','\x03',s0_reg_idx,'\x03',s0_reg_idx,'\x03',x_idx,'\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',x_idx,'\x03','\t','\x03',s0_reg_idx,'\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',x_idx,'\x03',x_idx,'\x03','\x0e','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x0f','\x03','\v','\x03','\x0f','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x10','\x03','\x0e','\x03','\x0e','\x03',DAT_00000010); + sec_eng_pka0_msub('\0','\x03','\x0f','\x03','\x0f','\x03',s0_reg_idx,'\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',s0_reg_idx_00,'\x03',s0_reg_idx_00,'\x03',s0_reg_idx_00,'\x03', + DAT_00000010); + sec_eng_pka0_mmul('\0','\x03','\x0f','\x03','\x0f','\x03','\r','\x03',DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',s0_reg_idx_00,'\x03','\f','\x03',s0_reg_idx_00,'\x03',DAT_00000010 + ); + sec_eng_pka0_mmul('\0','\x03',s0_reg_idx_00,'\x03',s0_reg_idx_00,'\x03','\x10','\x03', + DAT_00000010); + sec_eng_pka0_msub('\0','\x03',s0_reg_idx_00,'\x03','\x0f','\x03',s0_reg_idx_00,'\x03', + DAT_00000010); + sec_eng_pka0_mmul('\0','\x03',s0_reg_idx,'\x03','\x0e','\x03','\x10','\x03',DAT_00000010); + sec_eng_pka0_mmul('\x01','\x03',s0_reg_idx,'\x03','\f','\x03',s0_reg_idx,'\x03',DAT_00000010); + sec_eng_pka0_wait_4_isr(); + sec_eng_pka0_clear_int(); + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: pka_p1_eq_inf + +void pka_addition_win(ECC_Jacobian_Point256 *src1,ECC_Jacobian_Point256 *src2, + ECC_Jacobian_Point256 *ret) + +{ + uint8_t x2_idx; + byte bStack18; + byte abStack17 [3]; + uint8_t pka_p1_eq_inf; + uint8_t pka_p2_eq_inf; + + sec_eng_pka0_pld(8,(uint32_t *)src1,'\x15','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)&src1->y,'\x16','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)&src1->z,'\x17','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)src2,'\x18','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)&src2->y,'\x19','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)&src2->z,'\x1a','\x03','9',false); + pka_point_inf_check('\x15',&bStack18); + pka_point_inf_check('\x18',abStack17); + if (bStack18 == 1) { + x2_idx = '\x18'; + if (abStack17[0] != 0) goto LAB_2300cc28; + } + else { + if ((bStack18 | abStack17[0]) == 0) { + pka_point_addition('\x15','\x18','\x1b'); + goto LAB_2300cc44; + } +LAB_2300cc28: + x2_idx = '\x02'; + } + pka_cp_x2_to_x1('\x1b',x2_idx); +LAB_2300cc44: + pka_read_result(ret,'\x1b'); + return; +} + + + +void ecc_multiplication_event_handler(uint8_t param_1) + +{ + bool bVar1; + byte bVar2; + ke_task_id_t dest_id; + co_list_hdr *mem_ptr; + co_list_hdr *pcVar3; + undefined *puVar4; + ECC_Jacobian_Point256 *src1; + uint uVar5; + co_list_hdr *pcVar6; + undefined *puVar7; + undefined *puVar8; + int iVar9; + undefined4 *puVar10; + byte bStack113; + byte bStack112; + undefined2 uStack110; + undefined4 uStack84; + undefined4 uStack80; + undefined4 uStack76; + undefined4 uStack72; + undefined4 uStack40; + undefined4 uStack36; + + ble_ke_event_clear('\0'); + mem_ptr = ble_co_list_pop_front((co_list *)&ecc_env); + if (mem_ptr == (co_list_hdr *)0x0) goto LAB_2300cdce; + if (mem_ptr[1].next == (co_list_hdr *)0x0) { + dest_id = *(ke_task_id_t *)((int)&mem_ptr[0x48].next + 2); + if (dest_id != 0xff) { + puVar4 = (undefined *)ble_ke_msg_alloc(*(ke_msg_id_t *)&mem_ptr[0x48].next,dest_id,0xff,0x40); + Mont2GF('\x02'); + Mont2GF('\x03'); + (*ble_memset_ptr)(&bStack112,0,0x20); + uStack84 = 2; + sec_eng_pka0_pld(8,&bStack112,'\r','\x03','9',false); + sec_eng_pka0_lsub('\0','\x03','\r','\x03','\0','\x03','\r'); + sec_eng_pka0_mexp('\x01','\x03','\x0e','\x03','\x04','\x03','\r','\x03',DAT_00000010); + sec_eng_pka0_wait_4_isr(); + sec_eng_pka0_clear_int(); + Mont2GF('\x0e'); + getFinalPoint('\x02'); + getFinalPoint('\x03'); + (*ble_memset_ptr)(&bStack112,0,0x20); + uStack80 = 0; + uStack76 = 0; + (*ble_memset_ptr)(&uStack72,0,0x20); + uStack40 = 0; + uStack36 = 0; + sec_eng_pka0_read_data('\x03','\x02',&bStack112,'\b'); + sec_eng_pka0_read_data('\x03','\x03',&uStack72,'\b'); + if (*(char *)&mem_ptr[0x4b].next == '\x02') { + ble_ke_free(mem_ptr[0x4c].next); + mem_ptr[0x4c].next = (co_list_hdr *)0x0; + } + ble_ke_free(mem_ptr); + puVar7 = puVar4 + 0x1c; + puVar10 = &bStack112; + do { + puVar7[3] = *(undefined *)((int)puVar10 + 3); + puVar7[2] = (char)*(undefined2 *)((int)puVar10 + 2); + puVar7[1] = (char)((uint)*puVar10 >> 8); + *puVar7 = (char)*puVar10; + bVar1 = puVar4 != puVar7; + puVar7 = puVar7 + -4; + puVar10 = puVar10 + 1; + } while (bVar1); + puVar7 = puVar4 + 0x3c; + puVar10 = &uStack72; + do { + puVar8 = puVar7 + -4; + puVar7[3] = *(undefined *)((int)puVar10 + 3); + puVar7[2] = (char)*(undefined2 *)((int)puVar10 + 2); + puVar7[1] = (char)((uint)*puVar10 >> 8); + *puVar7 = (char)*puVar10; + puVar7 = puVar8; + puVar10 = puVar10 + 1; + } while (puVar8 != puVar4 + 0x1c); + ble_ke_msg_send(puVar4); + } + goto LAB_2300cdce; + } + bVar2 = *(byte *)&mem_ptr[0x4b].next; + pcVar6 = mem_ptr[0x4a].next; + if (((int)&((co_list_hdr *)(uint)bVar2)[-1].next + 3U & 0xff) < 2) { + if (bVar2 == 1) { + src1 = ECC_4Win_Look_up_table; + } + else { + src1 = (ECC_Jacobian_Point256 *)mem_ptr[0x4c].next; + } + uVar5 = (uint)pcVar6 & 0x1f; + iVar9 = ((((uint)mem_ptr[(0x3fU - (int)pcVar6 >> 5) + 0x3e].next >> uVar5 & 1) * 2 + + ((uint)mem_ptr[(0x7fU - (int)pcVar6 >> 5) + 0x3e].next >> uVar5 & 1)) * 2 + + ((uint)mem_ptr[(0xbfU - (int)pcVar6 >> 5) + 0x3e].next >> uVar5 & 1)) * 2 + + ((uint)mem_ptr[(0xffU - (int)pcVar6 >> 5) + 0x3e].next >> uVar5 & 1); + if (iVar9 != 0) { + src1 = src1 + iVar9 + -1; + sec_eng_pka0_pld(8,(uint32_t *)src1,'\x15','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)&src1->y,'\x16','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)&src1->z,'\x17','\x03','9',false); + pka_point_inf_check('\x02',&bStack113); + pka_point_inf_check('\x15',(uint8_t *)&bStack112); + if (bStack113 == 1) { + if (bStack112 == 0) { + pka_cp_x2_to_x1('\x02','\x15'); + } + } + else { + if ((bStack113 | bStack112) == 0) { + pka_point_addition('\x02','\x15','\x02'); + } + } + } + if (mem_ptr[0x4a].next == (co_list_hdr *)0x0) { + mem_ptr[1].next = (co_list_hdr *)0x0; + } + else { + pka_point_double('\x02'); + pcVar6 = (co_list_hdr *)((int)&mem_ptr[0x4a].next[-1].next + 3); +LAB_2300cd9c: + mem_ptr[0x4a].next = pcVar6; + } + } + else { + if (bVar2 == 3) { + pka_point_double('\x05'); + pcVar6 = (co_list_hdr *)((int)&(mem_ptr[0x4a].next)->next + 1); + mem_ptr[0x4a].next = pcVar6; + if (pcVar6 == (co_list_hdr *)0x40) { + src1 = (ECC_Jacobian_Point256 *)(mem_ptr[0x4c].next + 0x1e); + } + else { + if (pcVar6 != (co_list_hdr *)0x80) { + if (pcVar6 == (co_list_hdr *)0xc0) { + pka_read_result((ECC_Jacobian_Point256 *)(mem_ptr[0x4c].next + 0xd2),'\x05'); + *(undefined *)&mem_ptr[0x4b].next = 4; + mem_ptr[0x4a].next = (co_list_hdr *)(uint)bVar2; + } + goto LAB_2300cdc4; + } + src1 = (ECC_Jacobian_Point256 *)(mem_ptr[0x4c].next + 0x5a); + } + pka_read_result(src1,'\x05'); + } + else { + if (bVar2 == 4) { + if (pcVar6 == (co_list_hdr *)0x3) { + src1 = (ECC_Jacobian_Point256 *)mem_ptr[0x4c].next; + pka_addition_win(src1,src1 + 1,src1 + 2); + pcVar6 = (co_list_hdr *)0x5; + } + else { + if (pcVar6 == (co_list_hdr *)0x5) { + src1 = (ECC_Jacobian_Point256 *)mem_ptr[0x4c].next; + pka_addition_win(src1,src1 + 3,src1 + 4); + pcVar6 = (co_list_hdr *)0x6; + } + else { + if (pcVar6 == (co_list_hdr *)0x6) { + pcVar6 = mem_ptr[0x4c].next; + pka_addition_win((ECC_Jacobian_Point256 *)(pcVar6 + 0x1e), + (ECC_Jacobian_Point256 *)(pcVar6 + 0x5a), + (ECC_Jacobian_Point256 *)(pcVar6 + 0x96)); + pcVar6 = (co_list_hdr *)0x7; + } + else { + if (pcVar6 == (co_list_hdr *)0x7) { + src1 = (ECC_Jacobian_Point256 *)mem_ptr[0x4c].next; + pka_addition_win(src1,src1 + 5,src1 + 6); + pcVar6 = (co_list_hdr *)0x9; + } + else { + if (6 < (int)&pcVar6[-3].next + 3U) goto LAB_2300cdc4; + pcVar3 = mem_ptr[0x4c].next; + pka_addition_win((ECC_Jacobian_Point256 *)(pcVar3 + 0xd2), + (ECC_Jacobian_Point256 *)(pcVar3 + (int)pcVar6 * 0x1e + -0x10e), + (ECC_Jacobian_Point256 *)(pcVar3 + (int)pcVar6 * 0x1e + -0x1e)); + if (mem_ptr[0x4a].next == (co_list_hdr *)0xf) { + *(undefined *)&mem_ptr[0x4b].next = 2; + pcVar6 = (co_list_hdr *)0x3f; + } + else { + pcVar6 = (co_list_hdr *)((int)&(mem_ptr[0x4a].next)->next + 1); + } + } + } + } + } + goto LAB_2300cd9c; + } + } + } +LAB_2300cdc4: + ble_co_list_push_back(&ecc_env,mem_ptr); +LAB_2300cdce: + if (ecc_env.ongoing_mul.first != (co_list_hdr *)0x0) { + ble_ke_event_set('\0'); + } + return; +} + + + +void ecc_init(int param_1) + +{ + co_list_hdr *mem_ptr; + + if (param_1 != 0) { + while (ecc_env.ongoing_mul.first != (co_list_hdr *)0x0) { + mem_ptr = ble_co_list_pop_front((co_list *)&ecc_env); + ble_ke_free(mem_ptr); + } + } + ble_co_list_init((co_list *)&ecc_env); + ble_ke_event_callback_set('\0',ecc_multiplication_event_handler); + return; +} + + + +// WARNING: Variable defined which should be unmapped: PointP_Jacobian + +uint8_t ecc_generate_key256(u_int8 key_type,u_int8 *secret_key,u_int8 *public_key_x, + u_int8 *public_key_y,ke_msg_id_t msg_id,ke_task_id_t task_id) + +{ + bool bVar1; + u_int32 *numA; + void *pvVar2; + ECC_Jacobian_Point256 *point; + byte *pbVar3; + byte *pbVar4; + byte *pbVar5; + int iVar6; + u_int32 *numA_00; + int *piVar7; + int local_148; + bigHex256 PrivateKey256; + bigHex256 BigHex_1; + ECC_Point256 PublicKey256; + ECC_Jacobian_Point256 PointP_Jacobian; + + sec_eng_pka0_reset(); + numA_00 = &BigHex_1.sign; + local_148 = 0; + BigHex_1.sign = 0; + PublicKey256.x.sign = 0; + numA = numA_00; + pbVar3 = public_key_x + 0x1c; + pbVar4 = public_key_y + 0x1c; + pbVar5 = secret_key + 0x1c; + piVar7 = &local_148; + do { + *piVar7 = (uint)pbVar5[3] * 0x1000000 + (uint)pbVar5[2] * 0x10000 + (uint)*pbVar5 + + (uint)pbVar5[1] * 0x100; + *numA = (uint)pbVar3[3] * 0x1000000 + (uint)pbVar3[2] * 0x10000 + (uint)*pbVar3 + + (uint)pbVar3[1] * 0x100; + numA[10] = (uint)pbVar4[3] * 0x1000000 + (uint)pbVar4[2] * 0x10000 + (uint)*pbVar4 + + (uint)pbVar4[1] * 0x100; + bVar1 = secret_key != pbVar5; + numA = numA + 1; + pbVar3 = pbVar3 + -4; + pbVar4 = pbVar4 + -4; + pbVar5 = pbVar5 + -4; + piVar7 = piVar7 + 1; + } while (bVar1); + iVar6 = 0; + piVar7 = &local_148; + do { + if (*piVar7 != 0) break; + iVar6 = iVar6 + 1; + piVar7 = piVar7 + 1; + } while (iVar6 != 8); + PrivateKey256.num[7] = 8 - iVar6; + iVar6 = 0; + numA = numA_00; + do { + if (*numA != 0) break; + iVar6 = iVar6 + 1; + numA = numA + 1; + } while (iVar6 != 8); + PublicKey256.x.num[7] = 8 - iVar6; + iVar6 = 0; + numA = numA_00; + do { + if (numA[10] != 0) break; + iVar6 = iVar6 + 1; + numA = numA + 1; + } while (iVar6 != 8); + PublicKey256.y.num[7] = 8 - iVar6; + PublicKey256.x.len = 0; + PublicKey256.y.len = 0; + pvVar2 = ble_ke_malloc(0x134,'\0'); + *(u_int8 *)((int)pvVar2 + 300) = key_type; + *(ke_msg_id_t *)((int)pvVar2 + 0x120) = msg_id; + *(ke_task_id_t *)((int)pvVar2 + 0x122) = task_id; + GF2Mont(numA_00,numA_00); + numA = &PublicKey256.x.sign; + GF2Mont(numA,numA); + BigHex_1.num[7] = 1; + BigHex_1.len = 0; + (*ble_memset_ptr)(&PrivateKey256.sign,0,0x20); + (*ble_memcpy_ptr)(&PrivateKey256.sign,Bar_1,0x20); + (*ble_memcpy_ptr)(&PublicKey256.y.sign,numA_00,0x20); + PointP_Jacobian.x.num[7] = PublicKey256.x.num[7]; + PointP_Jacobian.x.len = PublicKey256.x.len; + (*ble_memcpy_ptr)(&PointP_Jacobian.x.sign,&PublicKey256.x.sign,0x20); + PointP_Jacobian.y.num[7] = PublicKey256.y.num[7]; + PointP_Jacobian.y.len = PublicKey256.y.len; + (*ble_memcpy_ptr)(&PointP_Jacobian.y.sign,&PrivateKey256.sign,0x20); + PointP_Jacobian.z.num[7] = BigHex_1.num[7]; + PointP_Jacobian.z.len = BigHex_1.len; + (*ble_memcpy_ptr)((uint32_t *)((int)pvVar2 + 0x80),&PublicKey256.y.sign,0x20); + *(u_int32 *)((int)pvVar2 + 0xa0) = PointP_Jacobian.x.num[7]; + *(u_int32 *)((int)pvVar2 + 0xa4) = PointP_Jacobian.x.len; + (*ble_memcpy_ptr)((uint32_t *)((int)pvVar2 + 0xa8),&PointP_Jacobian.x.sign,0x20); + *(u_int32 *)((int)pvVar2 + 200) = PointP_Jacobian.y.num[7]; + *(u_int32 *)((int)pvVar2 + 0xcc) = PointP_Jacobian.y.len; + (*ble_memcpy_ptr)((uint32_t *)((int)pvVar2 + 0xd0),&PointP_Jacobian.y.sign,0x20); + *(u_int32 *)((int)pvVar2 + 0xf0) = PointP_Jacobian.z.num[7]; + *(u_int32 *)((int)pvVar2 + 0xf4) = PointP_Jacobian.z.len; + (*ble_memcpy_ptr)((void *)((int)pvVar2 + 0xf8),&local_148,0x20); + *(u_int32 *)((int)pvVar2 + 0x118) = PrivateKey256.num[7]; + *(u_int32 *)((int)pvVar2 + 0x11c) = PrivateKey256.len; + BigHex_1.num[7] = 1; + BigHex_1.len = 0; + (*ble_memset_ptr)(&PrivateKey256.sign,0,0x20); + BigHex_1.num[6] = 0; + (*ble_memcpy_ptr)((uint32_t *)((int)pvVar2 + 8),&PrivateKey256.sign,0x20); + *(u_int32 *)((int)pvVar2 + 0x28) = BigHex_1.num[7]; + *(u_int32 *)((int)pvVar2 + 0x2c) = BigHex_1.len; + (*ble_memcpy_ptr)(&PrivateKey256.sign,Bar_1,0x20); + (*ble_memcpy_ptr)((uint32_t *)((int)pvVar2 + 0x30),&PrivateKey256.sign,0x20); + *(u_int32 *)((int)pvVar2 + 0x50) = BigHex_1.num[7]; + *(u_int32 *)((int)pvVar2 + 0x54) = BigHex_1.len; + (*ble_memset_ptr)(&PrivateKey256.sign,0,0x20); + BigHex_1.num[6] = 0; + (*ble_memcpy_ptr)((uint32_t *)((int)pvVar2 + 0x58),&PrivateKey256.sign,0x20); + *(u_int32 *)((int)pvVar2 + 0x78) = BigHex_1.num[7]; + *(u_int32 *)((int)pvVar2 + 0x7c) = BigHex_1.len; + (*ble_memset_ptr)(&PrivateKey256.sign,0,0x20); + BigHex_1.num[6] = 1; + sec_eng_pka0_pld(8,(uint32_t *)&bigHexP256,'\0','\x03','9',false); + sec_eng_pka0_pld(8,Nprime,'\x01','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)((int)pvVar2 + 8),'\x02','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)((int)pvVar2 + 0x30),'\x03','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)((int)pvVar2 + 0x58),'\x04','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)((int)pvVar2 + 0x80),'\x05','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)((int)pvVar2 + 0xa8),'\x06','\x03','9',false); + sec_eng_pka0_pld(8,(uint32_t *)((int)pvVar2 + 0xd0),'\a','\x03','9',false); + sec_eng_pka0_pld(8,&PrivateKey256.sign,'\b','\x03','9',false); + sec_eng_pka0_pld(8,Bar_2,'\t','\x03','9',false); + sec_eng_pka0_pld(8,Bar_3,'\n','\x03','9',false); + sec_eng_pka0_pld(8,Bar_4,'\v','\x03','9',false); + sec_eng_pka0_pld(8,Bar_8,'\f','\x03','9',false); + sec_eng_pka0_pld(8,Bar_1p1,'\x13','\x03','9',false); + sec_eng_pka0_pld(8,Bar_1m1,'\x14','\x03','9',false); + *(undefined4 *)((int)pvVar2 + 0x128) = 0x3f; + *(undefined4 *)((int)pvVar2 + 0x124) = 0; + *(undefined4 *)((int)pvVar2 + 4) = 8; + if (*(char *)((int)pvVar2 + 300) == '\x02') { + point = (ECC_Jacobian_Point256 *)ble_ke_malloc(0x708,'\0'); + *(ECC_Jacobian_Point256 **)((int)pvVar2 + 0x130) = point; + pka_read_result(point,'\x05'); + *(undefined *)((int)pvVar2 + 300) = 3; + *(undefined4 *)((int)pvVar2 + 0x128) = 0; + } + ble_co_list_push_back(&ecc_env,pvVar2); + ble_ke_event_set('\0'); + return '\0'; +} + + + +void ecc_gen_new_public_key(u_int8 *secret_key,ke_msg_id_t msg_id,ke_task_id_t task_id) + +{ + ecc_generate_key256('\x01',secret_key,BasePoint_x_256,BasePoint_y_256,msg_id,task_id); + return; +} + + + +void ecc_gen_new_secret_key(uint8_t *secret_key256,_Bool forced) + +{ + int iVar1; + undefined3 in_register_0000202d; + + if (CONCAT31(in_register_0000202d,forced) != 0) { + return; + } + do { + iVar1 = bl_rand(); + *secret_key256 = (uint8_t)iVar1; + secret_key256[1] = (uint8_t)((uint)iVar1 >> 8); + secret_key256[2] = (uint8_t)((uint)iVar1 >> 0x10); + secret_key256[3] = (uint8_t)((uint)iVar1 >> 0x18); + iVar1 = bl_rand(); + secret_key256[4] = (uint8_t)iVar1; + secret_key256[5] = (uint8_t)((uint)iVar1 >> 8); + secret_key256[6] = (uint8_t)((uint)iVar1 >> 0x10); + secret_key256[7] = (uint8_t)((uint)iVar1 >> 0x18); + iVar1 = bl_rand(); + secret_key256[8] = (uint8_t)iVar1; + secret_key256[9] = (uint8_t)((uint)iVar1 >> 8); + secret_key256[10] = (uint8_t)((uint)iVar1 >> 0x10); + secret_key256[0xb] = (uint8_t)((uint)iVar1 >> 0x18); + iVar1 = bl_rand(); + secret_key256[0xc] = (uint8_t)iVar1; + secret_key256[0xd] = (uint8_t)((uint)iVar1 >> 8); + secret_key256[0xe] = (uint8_t)((uint)iVar1 >> 0x10); + secret_key256[0xf] = (uint8_t)((uint)iVar1 >> 0x18); + iVar1 = bl_rand(); + secret_key256[0x10] = (uint8_t)iVar1; + secret_key256[0x11] = (uint8_t)((uint)iVar1 >> 8); + secret_key256[0x12] = (uint8_t)((uint)iVar1 >> 0x10); + secret_key256[0x13] = (uint8_t)((uint)iVar1 >> 0x18); + iVar1 = bl_rand(); + secret_key256[0x14] = (uint8_t)iVar1; + secret_key256[0x15] = (uint8_t)((uint)iVar1 >> 8); + secret_key256[0x16] = (uint8_t)((uint)iVar1 >> 0x10); + secret_key256[0x17] = (uint8_t)((uint)iVar1 >> 0x18); + iVar1 = bl_rand(); + secret_key256[0x18] = (uint8_t)iVar1; + secret_key256[0x19] = (uint8_t)((uint)iVar1 >> 8); + secret_key256[0x1a] = (uint8_t)((uint)iVar1 >> 0x10); + secret_key256[0x1b] = (uint8_t)((uint)iVar1 >> 0x18); + iVar1 = bl_rand(); + secret_key256[0x1c] = (uint8_t)iVar1; + secret_key256[0x1d] = (uint8_t)((uint)iVar1 >> 8); + secret_key256[0x1e] = (uint8_t)((uint)iVar1 >> 0x10); + secret_key256[0x1f] = (uint8_t)((uint)iVar1 >> 0x18); + iVar1 = 0x1f; + do { + if (secret_key256[iVar1] != '\0') goto LAB_2300d670; + iVar1 = iVar1 + -1; + } while (iVar1 != -1); + if (*secret_key256 != '\0') { +LAB_2300d670: + iVar1 = 0x1f; + while( true ) { + if (maxSecretKey_256[iVar1] < secret_key256[iVar1]) break; + if ((secret_key256[iVar1] < maxSecretKey_256[iVar1]) || (iVar1 = iVar1 + -1, iVar1 == -1)) { + return; + } + } + } + } while( true ); +} + + + +void ble_ke_event_init(void) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,_rom_patch_hook); + if (uVar1 == 0) { + // WARNING: Could not recover jumptable at 0x2300d6ca. Too many branches + // WARNING: Treating indirect jump as call + (*ble_memset_ptr)(&ble_ke_event_env,0,0x30); + return; + } + return; +} + + + +uint8_t ble_ke_event_callback_set(uint8_t event_type,intCallback_Type *p_callback) + +{ + undefined3 in_register_00002029; + uint uVar1; + uint32_t uVar2; + uint8_t auStack17 [4]; + uint8_t status; + + uVar1 = CONCAT31(in_register_00002029,event_type); + uVar2 = (*_rom_patch_hook)(auStack17,uVar1,p_callback,_rom_patch_hook); + if ((uVar2 == 0) && (auStack17[0] = '\x03', uVar1 < 10)) { + *(intCallback_Type **)(ble_ke_event_env.callback + uVar1) = p_callback; + auStack17[0] = '\0'; + } + return auStack17[0]; +} + + +/* +Unable to decompile 'ble_ke_event_set' +Cause: +Low-level Error: Assignment to constant at r0x2300d75a +*/ + +/* +Unable to decompile 'ble_ke_event_clear' +Cause: Exception while decompiling 2300d77c: Decompiler process died + +*/ + + +void ble_ke_event_flush(void) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,_rom_patch_hook); + if (uVar1 == 0) { + ble_ke_event_env.event_field = 0; + } + return; +} + + + +void ble_ke_event_schedule(void) + +{ + uint32_t uVar1; + uint uVar2; + + uVar1 = (*_rom_patch_hook)((void *)0x0,_rom_patch_hook); + if (uVar1 == 0) { + while (ble_ke_event_env.event_field != 0) { + ble_ke_event_env.state = '\x01'; + uVar2 = 0; + do { + if ((0x80000000U >> (uVar2 & 0x1f) & ble_ke_event_env.event_field) != 0) break; + uVar2 = uVar2 + 1; + } while (uVar2 != 0x20); + if (ble_ke_event_env.callback[0x1f - uVar2 & 0xff] != (p_callback_t)0x0) { + (*ble_ke_event_env.callback[0x1f - uVar2 & 0xff])(); + } + } + ble_ke_event_env.state = '\0'; + } + return; +} + + + +_Bool ble_ke_mem_is_in_heap(uint8_t type,void *mem_ptr) + +{ + undefined3 in_register_00002029; + int iVar1; + uint32_t uVar2; + co_list_hdr *pcVar3; + undefined auStack17 [4]; + _Bool ret; + + iVar1 = CONCAT31(in_register_00002029,type); + uVar2 = (*_rom_patch_hook)(auStack17,iVar1,mem_ptr,_rom_patch_hook); + if (uVar2 == 0) { + pcVar3 = (&ble_ke_env.queue_saved.first)[iVar1 + 4]; + auStack17[0] = 0; + if ((pcVar3 <= mem_ptr) && + (mem_ptr <= + (void *)((int)&pcVar3->next + + (uint)*(ushort *)((int)&ble_ke_env.queue_sent.first + (iVar1 + 0x10) * 2)))) { + auStack17[0] = 1; + } + } + return (_Bool)auStack17[0]; +} + + +/* +Unable to decompile 'ble_ke_mem_init' +Cause: Exception while decompiling 2300d8c2: Decompiler process died + +*/ + +/* +Unable to decompile 'ble_ke_malloc' +Cause: Exception while decompiling 2300d942: Decompiler process died + +*/ + +/* +Unable to decompile 'ble_ke_free' +Cause: Exception while decompiling 2300da32: Decompiler process died + +*/ + + +_Bool ble_ke_is_free(void *mem_ptr) + +{ + uint32_t uVar1; + bool abStack17 [4]; + _Bool ret; + + uVar1 = (*_rom_patch_hook)(abStack17,mem_ptr,_rom_patch_hook); + if (uVar1 == 0) { + abStack17[0] = *(short *)((int)mem_ptr + -4) != -0x7cc8; + } + return (_Bool)abStack17[0]; +} + + + +void * ble_ke_msg_alloc(ke_msg_id_t id,ke_task_id_t dest_id,ke_task_id_t src_id,uint16_t param_len) + +{ + anon_subr_void_ptr_void_ptr_int_uint *paVar1; + undefined2 in_register_0000202a; + uint32_t uVar2; + undefined2 in_register_0000202e; + undefined2 in_register_00002032; + undefined2 in_register_00002036; + uint uVar3; + undefined4 *puStack36; + void *param_ptr; + + uVar3 = CONCAT22(in_register_00002036,param_len); + puStack36 = (undefined4 *)0x0; + uVar2 = (*_rom_patch_hook)(&puStack36,CONCAT22(in_register_0000202a,id), + CONCAT22(in_register_0000202e,dest_id), + CONCAT22(in_register_00002032,src_id),uVar3,_rom_patch_hook); + if (uVar2 == 0) { + puStack36 = (undefined4 *)ble_ke_malloc(uVar3 + 0xc,'\0'); + *puStack36 = 0xffffffff; + paVar1 = ble_memset_ptr; + *(ke_msg_id_t *)(puStack36 + 1) = id; + *(ke_task_id_t *)((int)puStack36 + 6) = dest_id; + *(ke_task_id_t *)(puStack36 + 2) = src_id; + *(uint16_t *)((int)puStack36 + 10) = param_len; + puStack36 = puStack36 + 3; + (*paVar1)(puStack36,0,uVar3); + } + return puStack36; +} + + +/* +Unable to decompile 'ble_ke_msg_send' +Cause: Exception while decompiling 2300dbe2: Decompiler process died + +*/ + +/* +Unable to decompile 'ble_ke_msg_get_sent_num' +Cause: Exception while decompiling 2300dc30: Decompiler process died + +*/ + + +void ble_ke_msg_send_basic(ke_msg_id_t id,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined2 in_register_0000202a; + uint32_t uVar1; + undefined2 in_register_0000202e; + undefined2 in_register_00002032; + + uVar1 = (*_rom_patch_hook)((void *)0x0,CONCAT22(in_register_0000202a,id), + CONCAT22(in_register_0000202e,dest_id), + CONCAT22(in_register_00002032,src_id),_rom_patch_hook); + if (uVar1 == 0) { + ble_ke_msg_alloc(id,dest_id,src_id,0); + ble_ke_msg_send(); + return; + } + return; +} + + + +void ble_ke_msg_free(ke_msg *msg) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,msg,_rom_patch_hook); + if (uVar1 == 0) { + ble_ke_free(msg); + return; + } + return; +} + + + +_Bool ble_cmp_abs_time(co_list_hdr *timerA,co_list_hdr *timerB) + +{ + uint32_t uVar1; + byte abStack17 [4]; + _Bool result; + + uVar1 = (*_rom_patch_hook)(abStack17,timerA,timerB,_rom_patch_hook); + if (uVar1 == 0) { + abStack17[0] = (byte)((uint)((int)timerA[2].next - (int)timerB[2].next) >> 0x16) & 1; + } + return (_Bool)abStack17[0]; +} + + + +_Bool ble_cmp_timer_id(co_list_hdr *timer,uint32_t timer_task) + +{ + uint32_t uVar1; + bool abStack17 [4]; + _Bool result; + + uVar1 = (*_rom_patch_hook)(abStack17,timer,timer_task,_rom_patch_hook); + if ((uVar1 == 0) && (abStack17[0] = false, (uint)*(ushort *)&timer[1].next == timer_task >> 0x10)) + { + abStack17[0] = (uint)*(ushort *)((int)&timer[1].next + 2) == (timer_task & 0xffff); + } + return (_Bool)abStack17[0]; +} + + + +// WARNING: Removing unreachable block (ram,0x2300dd92) +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t ble_ke_time(void) + +{ + uint32_t uVar1; + uint32_t uStack20; + uint32_t time; + + uVar1 = (*_rom_patch_hook)(&uStack20,_rom_patch_hook); + if (uVar1 == 0) { + do { + } while( true ); + } + return uStack20; +} + + + +_Bool ble_ke_time_cmp(uint32_t newer,uint32_t older) + +{ + uint32_t uVar1; + byte abStack17 [4]; + _Bool result; + + uVar1 = (*_rom_patch_hook)(abStack17,newer,older,_rom_patch_hook); + if (uVar1 == 0) { + abStack17[0] = ((byte)(newer - older >> 0x16) ^ 1) & 1; + } + return (_Bool)abStack17[0]; +} + + + +_Bool ble_ke_time_past(uint32_t time) + +{ + uint32_t newer; + _Bool a_Stack17 [4]; + _Bool result; + + newer = (*_rom_patch_hook)(a_Stack17,time,_rom_patch_hook); + if (newer == 0) { + newer = ble_ke_time(); + a_Stack17[0] = ble_ke_time_cmp(newer,time); + } + return a_Stack17[0]; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ble_ke_timer_hw_set(ke_timer *timer) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,timer,_rom_patch_hook); + if (uVar1 == 0) { + if (timer == (ke_timer *)0x0) { + _DAT_2800000c = _DAT_2800000c & 0xffffffbf; + } + else { + _DAT_280000f4 = timer->time; + if ((_DAT_2800000c >> 6 & 1) == 0) { + _DAT_28000018 = 0x40; + _DAT_2800000c = _DAT_2800000c | 0x40; + } + } + } + return; +} + + + +void ble_ke_timer_schedule(void) + +{ + _Bool _Var1; + uint32_t uVar2; + undefined3 extraout_var; + co_list_hdr *mem_ptr; + undefined3 extraout_var_00; + + uVar2 = (*_rom_patch_hook)((void *)0x0,_rom_patch_hook); + if (uVar2 != 0) { + return; + } + do { + ble_ke_event_clear('\x03'); + mem_ptr = ble_ke_env.queue_timer.first; + if (ble_ke_env.queue_timer.first == (co_list_hdr *)0x0) { + ble_ke_timer_hw_set((ke_timer *)0x0); + return; + } + _Var1 = ble_ke_time_past((int)&ble_ke_env.queue_timer.first[2].next[-1].next + 3); + if (CONCAT31(extraout_var,_Var1) == 0) { + ble_ke_timer_hw_set((ke_timer *)mem_ptr); + _Var1 = ble_ke_time_past((uint32_t)mem_ptr[2].next); + if (CONCAT31(extraout_var_00,_Var1) == 0) { + return; + } + } + mem_ptr = ble_co_list_pop_front(&ble_ke_env.queue_timer); + ble_ke_msg_send_basic + (*(ke_msg_id_t *)&mem_ptr[1].next,*(ke_task_id_t *)((int)&mem_ptr[1].next + 2),0xff); + ble_ke_free(mem_ptr); + } while( true ); +} + + + +void ble_ke_timer_init(void) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,_rom_patch_hook); + if (uVar1 == 0) { + ble_ke_event_callback_set('\x03',ble_ke_timer_schedule); + return; + } + return; +} + + + +void ble_ke_timer_set(ke_msg_id_t timer_id,ke_task_id_t task_id,uint32_t delay) + +{ + bool bVar1; + _Bool _Var2; + undefined2 in_register_0000202a; + uint uVar3; + uint32_t uVar4; + co_list_hdr *element; + undefined3 extraout_var; + undefined2 in_register_0000202e; + uint uVar5; + + uVar5 = CONCAT22(in_register_0000202e,task_id); + uVar3 = CONCAT22(in_register_0000202a,timer_id); + uVar4 = (*_rom_patch_hook)((void *)0x0,uVar3,uVar5,delay,_rom_patch_hook); + if (uVar4 == 0) { + if (delay < 0x400000) { + if (delay == 0) { + delay = 1; + } + } + else { + delay = 0x3fffff; + } + bVar1 = false; + if ((ble_ke_env.queue_timer.first != (co_list_hdr *)0x0) && + ((uint)*(ushort *)&ble_ke_env.queue_timer.first[1].next == uVar3)) { + bVar1 = (uint)*(ushort *)((int)&ble_ke_env.queue_timer.first[1].next + 2) == uVar5; + } + element = ble_ke_queue_extract(&ble_ke_env.queue_timer,ble_cmp_timer_id,uVar3 << 0x10 | uVar5); + if (element == (co_list_hdr *)0x0) { + element = (co_list_hdr *)ble_ke_malloc(0xc,'\0'); + *(ke_msg_id_t *)&element[1].next = timer_id; + *(ke_task_id_t *)((int)&element[1].next + 2) = task_id; + } + uVar4 = ble_ke_time(); + element[2].next = (co_list_hdr *)(delay + uVar4 & 0x7fffff); + ble_ke_queue_insert(&ble_ke_env.queue_timer,element,ble_cmp_abs_time); + if ((bVar1) || (ble_ke_env.queue_timer.first == element)) { + ble_ke_timer_hw_set((ke_timer *)ble_ke_env.queue_timer.first); + } + _Var2 = ble_ke_time_past(delay + uVar4); + if (CONCAT31(extraout_var,_Var2) != 0) { + ble_ke_event_set('\x03'); + return; + } + } + return; +} + + + +void ble_ke_timer_clear(ke_msg_id_t timer_id,ke_task_id_t task_id) + +{ + co_list_hdr *pcVar1; + _Bool _Var2; + undefined2 in_register_0000202a; + uint uVar3; + uint32_t uVar4; + undefined3 extraout_var; + co_list_hdr *mem_ptr; + undefined2 in_register_0000202e; + uint uVar5; + + uVar5 = CONCAT22(in_register_0000202e,task_id); + uVar3 = CONCAT22(in_register_0000202a,timer_id); + uVar4 = (*_rom_patch_hook)((void *)0x0,uVar3,uVar5,_rom_patch_hook); + mem_ptr = ble_ke_env.queue_timer.first; + if ((uVar4 == 0) && (ble_ke_env.queue_timer.first != (co_list_hdr *)0x0)) { + if (((uint)*(ushort *)&ble_ke_env.queue_timer.first[1].next == uVar3) && + ((uint)*(ushort *)((int)&ble_ke_env.queue_timer.first[1].next + 2) == uVar5)) { + ble_co_list_pop_front(&ble_ke_env.queue_timer); + pcVar1 = ble_ke_env.queue_timer.first; + ble_ke_timer_hw_set((ke_timer *)ble_ke_env.queue_timer.first); + if ((pcVar1 != (co_list_hdr *)0x0) && + (_Var2 = ble_ke_time_past((uint32_t)pcVar1[2].next), CONCAT31(extraout_var,_Var2) != 0)) { + ble_ke_event_set('\x03'); + } + } + else { + mem_ptr = ble_ke_queue_extract(&ble_ke_env.queue_timer,ble_cmp_timer_id,uVar3 << 0x10 | uVar5) + ; + if (mem_ptr == (co_list_hdr *)0x0) { + return; + } + } + ble_ke_free(mem_ptr); + return; + } + return; +} + + + +_Bool ble_ke_timer_active(ke_msg_id_t timer_id,ke_task_id_t task_id) + +{ + undefined2 in_register_0000202a; + uint32_t uVar1; + undefined2 in_register_0000202e; + co_list_hdr cVar2; + undefined auStack17 [4]; + _Bool result; + + uVar1 = (*_rom_patch_hook)(auStack17,CONCAT22(in_register_0000202a,timer_id), + CONCAT22(in_register_0000202e,task_id),_rom_patch_hook); + cVar2 = (co_list_hdr)ble_ke_env.queue_timer.first; + if (uVar1 == 0) { + while (cVar2 != (co_list_hdr)0x0) { + if (((uint)*(ushort *)&((co_list_hdr *)((int)cVar2 + 4))->next == + CONCAT22(in_register_0000202a,timer_id)) && + ((uint)*(ushort *)((int)cVar2 + 6) == CONCAT22(in_register_0000202e,task_id))) { + return true; + } + cVar2 = *(co_list_hdr *)cVar2; + } + auStack17[0] = 0; + } + return (_Bool)auStack17[0]; +} + + + +void ble_ke_init(void) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,_rom_patch_hook); + if (uVar1 == 0) { + (*ble_memset_ptr)((void *)0x4201a1b4,0,8); + (*ble_memset_ptr)((void *)0x4201a1bc,0,4); + ble_ke_event_init(); + ble_ke_env.queue_saved.first = (co_list_hdr *)0x0; + ble_ke_env.queue_saved.last = (co_list_hdr *)0x0; + ble_ke_env.queue_sent.first = (co_list_hdr *)0x0; + ble_ke_env.queue_sent.last = (co_list_hdr *)0x0; + ble_ke_env.queue_timer.first = (co_list_hdr *)0x0; + ble_ke_env.queue_timer.last = (co_list_hdr *)0x0; + ble_ke_task_init(); + ble_ke_timer_init(); + return; + } + return; +} + + + +void ble_ke_flush(void) + +{ + uint32_t uVar1; + ke_msg *msg; + co_list_hdr *mem_ptr; + + uVar1 = (*_rom_patch_hook)((void *)0x0,_rom_patch_hook); + if (uVar1 != 0) { + return; + } + while (msg = (ke_msg *)ble_co_list_pop_front((co_list *)&ble_ke_env), msg != (ke_msg *)0x0) { + ble_ke_msg_free(msg); + } + while (msg = (ke_msg *)ble_co_list_pop_front(&ble_ke_env.queue_saved), msg != (ke_msg *)0x0) { + ble_ke_msg_free(msg); + } + while (mem_ptr = ble_co_list_pop_front(&ble_ke_env.queue_timer), mem_ptr != (co_list_hdr *)0x0) { + ble_ke_free(mem_ptr); + } + ble_ke_event_flush(); + return; +} + + + +void rf_force_agc_enable(_Bool en) + +{ + return; +} + + + +uint8_t rf_txpwr_dbm_get(uint8_t txpwr_idx,uint8_t modulation) + +{ + return (uint8_t)g_txpower_dbm; +} + + + +int8_t rf_rssi_convert(uint8_t rssi_reg) + +{ + undefined3 in_register_00002029; + + return (int8_t)((uint)((2 - CONCAT31(in_register_00002029,rssi_reg)) * 0x1000000) >> 0x18); +} + + + +uint32_t rf_reg_rd(uint16_t addr) + +{ + return 0; +} + + + +void rf_reg_wr(uint16_t addr,uint32_t value) + +{ + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_sleep(void) + +{ + _DAT_28000030 = _DAT_28000030 | 7; + return; +} + + + +_Bool rf_txpwr_dec(uint8_t dec) + +{ + _Bool _Var1; + undefined3 in_register_00002029; + undefined3 extraout_var; + + _Var1 = rfc_config_power_ble + ((int)g_txpower_offset + + ((int)g_txpower_dbm - CONCAT31(in_register_00002029,dec))); + if (CONCAT31(extraout_var,_Var1) != 0) { + g_txpower_dbm = g_txpower_dbm - dec; + } + return _Var1; +} + + + +_Bool rf_txpwr_inc(uint8_t inc) + +{ + _Bool _Var1; + undefined3 in_register_00002029; + undefined3 extraout_var; + + _Var1 = rfc_config_power_ble + ((int)g_txpower_offset + (int)g_txpower_dbm + CONCAT31(in_register_00002029,inc) + ); + if (CONCAT31(extraout_var,_Var1) != 0) { + g_txpower_dbm = inc + g_txpower_dbm; + } + return _Var1; +} + + + +void rf_txpwr_max_set(int8_t txpwr_dbm) + +{ + _Bool _Var1; + undefined3 in_register_00002029; + int iVar2; + undefined3 extraout_var; + + iVar2 = CONCAT31(in_register_00002029,txpwr_dbm); + if (g_txpower_dbm == '\x7f') { + iVar2 = 0xf; + } + g_txpower_dbm = (int8_t)iVar2; + _Var1 = rfc_config_power_ble(iVar2 + g_txpower_offset); + if (CONCAT31(extraout_var,_Var1) == 0) { + rfc_config_power_ble((int)g_txpower_offset + 0xf); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_reset(void) + +{ + _DAT_28000080 = _DAT_28000080 & 0x80000000 | 0x3c0042; + _DAT_280001a4 = 10; + _DAT_280001a8 = 0x7d; + _DAT_280001ac = _DAT_280001ac & 0xffffffc0 | 0x28; + bz_phy_reset(); + rf_txpwr_max_set(g_txpower_dbm); + return; +} + + + +void ble_rf_set_pwr_offset(int8_t offset) + +{ + g_txpower_offset = offset; + return; +} + + + +void ble_controller_set_tx_pwr(int ble_tx_power) + +{ + _Bool _Var1; + undefined3 extraout_var; + + g_txpower_dbm = (int8_t)ble_tx_power; + _Var1 = rfc_config_power_ble((int)g_txpower_dbm + (int)g_txpower_offset); + if (CONCAT31(extraout_var,_Var1) == 0) { + rfc_config_power_ble((int)g_txpower_offset + 0xf); + return; + } + return; +} + + + +void ble_rf_init(rwip_rf_api_conflict5 *api) + +{ + api->reg_rd = rf_reg_rd; + api->reg_wr = rf_reg_wr; + api->txpwr_dbm_get = rf_txpwr_dbm_get; + api->txpwr_max = '\x0f'; + api->txpwr_max_set = rf_txpwr_max_set; + api->txpwr_inc = rf_txpwr_inc; + api->txpwr_dec = rf_txpwr_dec; + api->sleep = rf_sleep; + api->reset = rf_reset; + api->force_agc_enable = rf_force_agc_enable; + api->rssi_convert = rf_rssi_convert; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pka0_write_common_op_first_cfg + (uint8_t s0_reg_index,uint8_t s0_reg_type,uint8_t d_reg_index,uint8_t d_reg_type, + uint8_t op,_Bool last_op) + +{ + uint uVar1; + undefined3 in_register_00002039; + uint uStack36; + pka0_common_op_first_cfg cfg; + + (*ble_memset_ptr)(&uStack36,0,4); + uVar1 = ((uint)s0_reg_type & 0xf) << 8; + uStack36 = uStack36 & 0xfffff000 | (uint)s0_reg_index | uVar1; + if (CONCAT31(in_register_00002039,op) != 0x19) { + uStack36 = (uint)s0_reg_index | uVar1 | (uint)d_reg_index << 0xc | + ((uint)d_reg_type & 0xf) << 0x14; + } + _DAT_40004340 = uStack36 & 0xffffff | ((uint)op & 0x7f) << 0x18 | (uint)last_op << 0x1f; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pka0_write_common_op_snd_cfg_S1(uint8_t s1_reg_index,uint8_t s1_reg_type) + +{ + undefined3 in_register_00002029; + uint uStack20; + pka0_common_op_snd_cfg_S1_only cfg; + + (*ble_memset_ptr)(&uStack20,0,4); + _DAT_40004340 = + (uStack20 & 0xfff00fff | CONCAT31(in_register_00002029,s1_reg_index) << 0xc) & 0xff0fffff | + ((uint)s1_reg_type & 0xf) << 0x14; + return; +} + + + +// WARNING: Variable defined which should be unmapped: cfg +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pka0_write_common_op_snd_cfg_S1_S2 + (uint8_t s1_reg_index,uint8_t s1_reg_type,uint8_t s2_reg_index,uint8_t s2_reg_type) + +{ + undefined3 in_register_00002029; + uint uStack20; + pka0_common_op_snd_cfg_S1_S2 cfg; + + (*ble_memset_ptr)(&uStack20,0,4); + _DAT_40004340 = + (uStack20 & 0xfff00fff | CONCAT31(in_register_00002029,s1_reg_index) << 0xc) & 0xff0ff000 | + ((uint)s1_reg_type & 0xf) << 0x14 | (uint)s2_reg_index | ((uint)s2_reg_type & 0xf) << 8; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_eng_pka0_reset(void) + +{ + _DAT_40004300 = 8; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_eng_pka0_clear_int(void) + +{ + _DAT_40004300 = _DAT_40004300 & 0xfffffdff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_eng_pka0_pld(uint16_t size,uint32_t *data,uint8_t reg_index,uint8_t reg_type,uint8_t op, + _Bool last_op) + +{ + int iVar1; + undefined2 in_register_0000202a; + undefined3 in_register_00002031; + uint uVar2; + + _DAT_40004340 = + (uint)size & 0xfff | CONCAT31(in_register_00002031,reg_index) << 0xc | + ((uint)reg_type & 0xf) << 0x14 | ((uint)op & 0x7f) << 0x18 | (uint)last_op << 0x1f; + uVar2 = 0; + while ((int)uVar2 < CONCAT22(in_register_0000202a,size)) { + iVar1 = 0x340; + if ((size & 7) == 0) { + iVar1 = 0x360; + } + *(uint32_t *)(&DAT_40004000 + (uVar2 & 7) * 4 + iVar1) = data[uVar2]; + uVar2 = uVar2 + 1; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_eng_pka0_wait_4_isr(void) + +{ + do { + } while ((_DAT_40004300 & 0x100) == 0); + return; +} + + + +// WARNING: Variable defined which should be unmapped: ret_data +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_eng_pka0_read_data(uint8_t reg_ype,uint8_t reg_idx,uint32_t *result,uint8_t ret_size) + +{ + int iVar1; + undefined3 in_register_00002035; + uint uVar2; + uint uVar3; + undefined4 uStack36; + uint32_t ret_data; + + uVar3 = (uint)reg_ype - 1 & 0xff; + uVar2 = 0; + if (uVar3 < 10) { + uVar2 = (uint)*(ushort *)(CSWTCH_9 + uVar3 * 2); + } + if (CONCAT31(in_register_00002035,ret_size) <= (uVar2 & 0xff)) { + _DAT_40004340 = 0; + sec_eng_pka0_wait_4_isr(); + uVar2 = 0; + sec_eng_pka0_clear_int(); + while ((int)uVar2 < (int)CONCAT31(in_register_00002035,ret_size)) { + uVar3 = uVar2 & 7; + iVar1 = 0x360; + if ((ret_size & 7) != 0) { + iVar1 = 0x340; + } + uStack36 = *(undefined4 *)(&DAT_40004000 + uVar3 * 4 + iVar1); + uVar2 = uVar2 + 1; + (*ble_memcpy_ptr)(result + uVar3,&uStack36,4); + } + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_eng_pka0_clir(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t size) + +{ + _DAT_40004340 = 0; + sec_eng_pka0_wait_4_isr(); + sec_eng_pka0_clear_int(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_eng_pka0_movdat(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type, + uint8_t s0_reg_idx) + +{ + undefined3 in_register_00002029; + + pka0_write_common_op_first_cfg + (s0_reg_idx,s0_reg_type,d_reg_idx,d_reg_type,'2', + (_Bool)(CONCAT31(in_register_00002029,last_op) != 0)); + _DAT_40004340 = 0; + if (CONCAT31(in_register_00002029,last_op) != 0) { + sec_eng_pka0_wait_4_isr(); + sec_eng_pka0_clear_int(); + return; + } + _DAT_40004340 = 0; + return; +} + + + +void sec_eng_pka0_msub(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type, + uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx,uint8_t s2_reg_type, + uint8_t s2_reg_idx) + +{ + undefined3 in_register_00002029; + uint8_t in_stack_00000000; + + pka0_write_common_op_first_cfg + (s0_reg_idx,s0_reg_type,d_reg_idx,d_reg_type,'\'', + (_Bool)(CONCAT31(in_register_00002029,last_op) != 0)); + pka0_write_common_op_snd_cfg_S1_S2(s1_reg_idx,s1_reg_type,in_stack_00000000,s2_reg_type); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_eng_pka0_mrem(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type, + uint8_t s0_reg_idx,uint8_t s2_reg_type,uint8_t s2_reg_idx) + +{ + undefined3 in_register_00002029; + uint uStack20; + pka0_common_op_snd_cfg_S2_only cfg; + + pka0_write_common_op_first_cfg + (s0_reg_idx,s0_reg_type,d_reg_idx,d_reg_type,'&', + (_Bool)(CONCAT31(in_register_00002029,last_op) != 0)); + (*ble_memset_ptr)(&uStack20,0,4); + _DAT_40004340 = uStack20 & 0xfffff000 | (uint)s2_reg_idx | ((uint)s2_reg_type & 0xf) << 8; + return; +} + + + +void sec_eng_pka0_mmul(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type, + uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx,uint8_t s2_reg_type, + uint8_t s2_reg_idx) + +{ + undefined3 in_register_00002029; + uint8_t in_stack_00000000; + + pka0_write_common_op_first_cfg + (s0_reg_idx,s0_reg_type,d_reg_idx,d_reg_type,'%', + (_Bool)(CONCAT31(in_register_00002029,last_op) != 0)); + pka0_write_common_op_snd_cfg_S1_S2(s1_reg_idx,s1_reg_type,in_stack_00000000,s2_reg_type); + return; +} + + + +void sec_eng_pka0_mexp(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type, + uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx,uint8_t s2_reg_type, + uint8_t s2_reg_idx) + +{ + undefined3 in_register_00002029; + uint8_t in_stack_00000000; + + pka0_write_common_op_first_cfg + (s0_reg_idx,s0_reg_type,d_reg_idx,d_reg_type,'#', + (_Bool)(CONCAT31(in_register_00002029,last_op) != 0)); + pka0_write_common_op_snd_cfg_S1_S2(s1_reg_idx,s1_reg_type,in_stack_00000000,s2_reg_type); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_eng_pka0_lcmp(uint8_t *cout,uint8_t s0_reg_type,uint8_t s0_reg_idx,uint8_t s1_reg_type, + uint8_t s1_reg_idx) + +{ + pka0_write_common_op_first_cfg(s0_reg_idx,s0_reg_type,'\0','\0','\x19',true); + pka0_write_common_op_snd_cfg_S1(s1_reg_idx,s1_reg_type); + sec_eng_pka0_wait_4_isr(); + sec_eng_pka0_clear_int(); + *cout = (byte)((uint)_DAT_40004300 >> 0x18) & 1; + return; +} + + + +void sec_eng_pka0_lsub(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type, + uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx) + +{ + undefined3 in_register_00002029; + + pka0_write_common_op_first_cfg + (s0_reg_idx,s0_reg_type,d_reg_idx,d_reg_type,'\x17', + (_Bool)(CONCAT31(in_register_00002029,last_op) != 0)); + pka0_write_common_op_snd_cfg_S1(s1_reg_idx,s1_reg_type); + return; +} + + + +void sec_eng_pka0_lmul(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type, + uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx) + +{ + undefined3 in_register_00002029; + + pka0_write_common_op_first_cfg + (s0_reg_idx,s0_reg_type,d_reg_idx,d_reg_type,'\x16', + (_Bool)(CONCAT31(in_register_00002029,last_op) != 0)); + pka0_write_common_op_snd_cfg_S1(s1_reg_idx,s1_reg_type); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_eng_pka0_lmul2n(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type, + uint8_t s0_reg_idx,uint16_t bit_shift) + +{ + uint uStack36; + pka0_bit_shift_op_cfg cfg; + + (*ble_memset_ptr)(&uStack36,0,4); + pka0_write_common_op_first_cfg(s0_reg_idx,s0_reg_type,d_reg_idx,d_reg_type,'\x13',false); + _DAT_40004340 = uStack36 & 0xffff8000 | (uint)bit_shift & 0x7fff; + return; +} + + + +void em_buf_init(void) + +{ + em_desc_node *peVar1; + undefined2 *puVar2; + uint uVar3; + em_buf_env_tag *peVar4; + int iVar5; + uint uVar6; + ushort *puVar7; + ushort *puVar8; + em_buf_env_tag *peVar9; + + em_buf_env.rx_current = '\0'; + ble_co_list_init((co_list *)&em_buf_env); + ble_co_list_init(&em_buf_env.tx_buff_free); + em_buf_env.tx_desc = (em_buf_tx_desc *)&DAT_280082ca; + peVar9 = &em_buf_env; + peVar4 = &em_buf_env; + uVar3 = 0; + puVar2 = (undefined2 *)&DAT_280082ce; + do { + uVar6 = uVar3 & 0xffff; + peVar4->tx_desc_node[0].idx = (uint16_t)uVar3; + uVar3 = uVar3 + 1; + peVar4 = (em_buf_env_tag *)&(peVar4->tx_buff_free).last; + *puVar2 = (short)((uVar6 * 0x26 + 0x43e) * 0x10000 >> 0x10); + puVar2[2] = 0; + puVar2[1] = 0; + puVar2[-1] = puVar2[-1] & 0xffdf; + puVar2[-1] = puVar2[-1] & 0xffdf; + puVar2[-2] = 0x8000; + puVar2 = puVar2 + 5; + } while (uVar3 != 6); + puVar2 = (undefined2 *)&DAT_2800830a; + do { + peVar9->tx_desc_node[6].idx = (uint16_t)uVar3; + *puVar2 = 0; + puVar2[2] = 0; + puVar2[1] = 0; + peVar1 = peVar9->tx_desc_node; + puVar2[-1] = puVar2[-1] & 0xffdf; + uVar3 = uVar3 + 1; + peVar9 = (em_buf_env_tag *)&(peVar9->tx_buff_free).last; + puVar2[-1] = puVar2[-1] & 0xffdf; + puVar2[-2] = 0x8000; + ble_co_list_push_back(&em_buf_env,peVar1 + 6); + puVar2 = puVar2 + 5; + } while (uVar3 != 0x1a); + em_buf_env.tx_buff_node[0]._4_4_ = 0x5220000; + ble_co_list_push_back(0x4201a1c8,0x4201a308); + em_buf_env.tx_buff_node[1]._4_4_ = 0x6260001; + ble_co_list_push_back(0x4201a1c8,0x4201a310); + iVar5 = 0; + puVar2 = (undefined2 *)&DAT_280083d6; + do { + iVar5 = iVar5 + 1; + *puVar2 = (short)((uint)((iVar5 * 0x104 + 0x626) * 0x10000) >> 0x10); + puVar2[-4] = ((ushort)iVar5 & 7) * 0xe + 0x3ce; + puVar2[2] = 0; + puVar2[-2] = puVar2[-2] & 0xffdf; + puVar2[-2] = puVar2[-2] & 0xffdf; + puVar2 = puVar2 + 7; + } while (iVar5 != 8); + puVar7 = (ushort *)&DAT_2800809e; + do { + puVar8 = puVar7 + 0x2e; + *puVar7 = *puVar7 & 0xbfff; + puVar7[9] = puVar7[9] & 0xfcff; + puVar7[0x25] = 0; + puVar7 = puVar8; + } while (puVar8 != (ushort *)0x2800820e); + return; +} + + + +void em_buf_rx_free(uint8_t hdl) + +{ + undefined3 in_register_00002029; + + *(ushort *)(&DAT_280083ce + CONCAT31(in_register_00002029,hdl) * 0xe) = + (ushort)(((uint)*(ushort *)(&DAT_280083ce + CONCAT31(in_register_00002029,hdl) * 0xe) << 0x11 + ) >> 0x11); + return; +} + + + +uint8_t * em_buf_rx_buff_addr_get(uint16_t rx_hdl) + +{ + undefined2 in_register_0000202a; + + return &DAT_28008000 + *(ushort *)(&DAT_280083d6 + CONCAT22(in_register_0000202a,rx_hdl) * 0xe); +} + + +/* +Unable to decompile 'em_buf_tx_free' +Cause: Exception while decompiling 2300eb66: Decompiler process died + +*/ + + +void llc_init(void) + +{ + ble_ke_task_create('\x01',&TASK_DESC_LLC); + ble_ke_state_set(1,'\x7f'); + ble_ke_state_set(0x101,'\x7f'); + // WARNING: Could not recover jumptable at 0x2300ec60. Too many branches + // WARNING: Treating indirect jump as call + (*ble_memset_ptr)(llc_env,0,8); + return; +} + + + +void llc_stop(int param_1) + +{ + void *pvVar1; + int iVar2; + + ble_ke_state_set((ushort)(param_1 << 8) | 1,'\x7f'); + if (llc_env[param_1] != (llc_env_tag *)0x0) { + iVar2 = 0; + do { + pvVar1 = llc_env[param_1]->operation[iVar2]; + if (pvVar1 != (void *)0x0) { + ble_ke_msg_free((ke_msg *)((int)pvVar1 + -0xc)); + } + iVar2 = iVar2 + 1; + } while (iVar2 != 4); + ble_ke_free(llc_env[param_1]); + llc_env[param_1] = (llc_env_tag *)0x0; + llm_util_bl_rem((uint16_t)param_1); + return; + } + return; +} + + + +void llc_reset(void) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + + kVar1 = ble_ke_state_get(1); + if (CONCAT31(extraout_var,kVar1) != 0x7f) { + llc_stop(0); + } + kVar1 = ble_ke_state_get(0x101); + if (CONCAT31(extraout_var_00,kVar1) != 0x7f) { + llc_stop(1); + return; + } + return; +} + + + +void llc_discon_event_complete_send + (ke_task_id_t src_id,uint8_t status,uint8_t conhdl,uint8_t reason) + +{ + uint8_t *param; + ke_task_id_t dest_id; + undefined3 in_register_00002031; + + dest_id = (ke_task_id_t)CONCAT31(in_register_00002031,conhdl); + param = (uint8_t *)ble_ke_msg_alloc(0x803,dest_id,5,6); + *param = status; + param[4] = reason; + *(ke_task_id_t *)(param + 2) = dest_id; + hci_send_2_host(param); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void llc_le_con_cmp_evt_send(uint8_t status,uint16_t conhdl,llc_create_con_req_ind *param) + +{ + ushort uVar1; + undefined *param_00; + _Bool _Var2; + uint8_t uVar3; + undefined3 in_register_00002029; + int iVar4; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + bd_addr *pbVar5; + undefined *puVar6; + anon_subr_void_ptr_void_ptr_void_ptr_uint *paVar7; + undefined *puVar8; + ushort *puVar9; + + iVar4 = CONCAT31(in_register_00002029,status); + _Var2 = llm_util_check_evt_mask('\0'); + if ((CONCAT31(extraout_var,_Var2) == 0) && + (_Var2 = llm_util_check_evt_mask('\t'), CONCAT31(extraout_var_02,_Var2) == 0)) { + return; + } + _Var2 = llm_util_check_evt_mask('\t'); + if (CONCAT31(extraout_var_00,_Var2) != 0) { + param_00 = (undefined *)ble_ke_msg_alloc(0x804,conhdl,0,0x20); + *param_00 = 10; + param_00[1] = status; + *(uint16_t *)(param_00 + 2) = conhdl; + if (iVar4 != 0) { + if (iVar4 != 0x3c) goto LAB_2300ee44; + param_00[4] = 1; + uVar3 = param->peer_addr_type; + *(undefined2 *)(param_00 + 2) = 0; + param_00[5] = uVar3; + paVar7 = ble_memcpy_ptr; + *(undefined2 *)(param_00 + 0x18) = 0; + *(undefined2 *)(param_00 + 0x1a) = 0; + *(undefined2 *)(param_00 + 0x1c) = 0; + (*paVar7)(param_00 + 6,¶m->peer_addr,6); + (*ble_memset_ptr)(param_00 + 0x12,0,6); + pbVar5 = (bd_addr *)0x0; + puVar8 = param_00 + 0xc; + paVar7 = (anon_subr_void_ptr_void_ptr_void_ptr_uint *)ble_memset_ptr; + goto LAB_2300eedc; + } + uVar3 = lld_get_mode(conhdl); + *(bool *)(param_00 + 4) = CONCAT31(extraout_var_03,uVar3) != 3; + uVar1 = param->ral_ptr; + puVar8 = param_00 + 0xc; + if (uVar1 == 0) { + (*ble_memset_ptr)(puVar8,0,6); + puVar8 = param_00 + 0x12; +LAB_2300efa6: + (*ble_memset_ptr)(puVar8,0,6); + } + else { + puVar9 = (ushort *)(&DAT_2800822e + (((uint)uVar1 - 0x22e) / 0x34 & 0xff) * 0x34); + if (((*puVar9 >> 1 & 1) == 0) || ((param->filter_policy != '\0' && ((*puVar9 >> 3 & 1) == 0))) + ) { + puVar6 = (undefined *)0x0; + paVar7 = (anon_subr_void_ptr_void_ptr_void_ptr_uint *)ble_memset_ptr; + } + else { + puVar6 = &DAT_28008000 + ((uint)uVar1 + 0x12 & 0xffff); + paVar7 = ble_memcpy_ptr; + } + (*paVar7)(param_00 + 0x12,puVar6,6); + if (((*puVar9 >> 5 & 1) == 0) || ((param_00[4] == '\x01' && ((_DAT_28008154 >> 2 & 1) == 0)))) + goto LAB_2300efa6; + (*ble_memcpy_ptr)(puVar8,&DAT_28008000 + ((uint)param->ral_ptr + 0x2e & 0xffff),6); + } + param_00[5] = param->peer_addr_type; + (*ble_memcpy_ptr)(param_00 + 6,¶m->peer_addr,6); + *(uint16_t *)(param_00 + 0x18) = param->con_int; + *(uint16_t *)(param_00 + 0x1a) = param->con_lat; + *(uint16_t *)(param_00 + 0x1c) = param->sup_to; + if (param_00[4] == '\0') { + param_00[0x1e] = 0; + } + else { + param_00[0x1e] = param->sleep_clk_acc; + } + goto LAB_2300ee44; + } + param_00 = (undefined *)ble_ke_msg_alloc(0x804,conhdl,0,0x14); + *param_00 = 1; + param_00[1] = status; + *(uint16_t *)(param_00 + 2) = conhdl; + if (iVar4 != 0) { + if (iVar4 != 0x3c) goto LAB_2300ee44; + param_00[4] = 1; + uVar3 = param->peer_addr_type; + *(undefined2 *)(param_00 + 2) = 0; + *(undefined2 *)(param_00 + 0xc) = 0; + param_00[5] = uVar3; + paVar7 = ble_memcpy_ptr; + *(undefined2 *)(param_00 + 0xe) = 0; + *(undefined2 *)(param_00 + 0x10) = 0; + pbVar5 = ¶m->peer_addr; + puVar8 = param_00 + 6; +LAB_2300eedc: + (*paVar7)(puVar8,pbVar5,6); + goto LAB_2300ee44; + } + uVar3 = lld_get_mode(conhdl); + *(bool *)(param_00 + 4) = CONCAT31(extraout_var_01,uVar3) != 3; + puVar8 = param_00 + 6; + if ((param->ral_ptr == 0) || + ((*(ushort *)(&DAT_2800822e + (((uint)param->ral_ptr - 0x22e) / 0x34 & 0xff) * 0x34) >> 1 & 1) + == 0)) { +LAB_2300ee84: + param_00[5] = param->peer_addr_type & 1; + (*ble_memcpy_ptr)(puVar8,¶m->peer_addr,6); + } + else { + if ((param->filter_policy != '\0') && + ((*(ushort *)(&DAT_2800822e + (((uint)param->ral_ptr - 0x22e) / 0x34 & 0xff) * 0x34) >> 3 & 1 + ) == 0)) { + (*ble_memset_ptr)(puVar8,0,6); + goto LAB_2300ee84; + } + param_00[5] = 1; + (*ble_memcpy_ptr)(puVar8,&DAT_28008000 + ((uint)param->ral_ptr + 0x12 & 0xffff),6); + } + *(uint16_t *)(param_00 + 0xc) = param->con_int; + *(uint16_t *)(param_00 + 0xe) = param->con_lat; + *(uint16_t *)(param_00 + 0x10) = param->sup_to; + if (param_00[4] == '\0') { + param_00[0x12] = 0; + } + else { + param_00[0x12] = param->sleep_clk_acc; + } +LAB_2300ee44: + hci_send_2_host(param_00); + return; +} + + + +void llc_le_ch_sel_algo_evt_send(uint8_t chSel,uint16_t conhdl,llc_create_con_req_ind *param) + +{ + _Bool _Var1; + undefined3 extraout_var; + undefined *param_00; + + _Var1 = llm_util_check_evt_mask('\x13'); + if (CONCAT31(extraout_var,_Var1) != 0) { + param_00 = (undefined *)ble_ke_msg_alloc(0x804,conhdl,0,6); + *param_00 = 0x14; + param_00[4] = chSel; + *(uint16_t *)(param_00 + 2) = conhdl; + hci_send_2_host(param_00); + return; + } + return; +} + + + +void llc_start(llc_create_con_req_ind *param_1,ea_elt_tag *param_2) + +{ + ushort conhdl; + ushort uVar1; + anon_subr_void_ptr_void_ptr_int_uint *paVar2; + uint16_t uVar3; + llc_env_tag *plVar4; + llc_env_tag **pplVar5; + ushort task_id; + uint delay; + llc_env_tag *plVar6; + uint uVar7; + + conhdl = *(ushort *)¶m_2[2].ea_cb_start; + uVar7 = (uint)conhdl; + task_id = conhdl << 8 | 1; + if (llc_env[uVar7] == (llc_env_tag *)0x0) { + plVar4 = (llc_env_tag *)ble_ke_malloc(0xa8,'\0'); + llc_env[uVar7] = plVar4; + } + paVar2 = ble_memset_ptr; + plVar4 = llc_env[uVar7]; + plVar4->peer_sup_conn_param_req = true; + (*paVar2)(&plVar4->peer_version,0,6); + llm_util_get_channel_map(&plVar4->ch_map); + llm_util_get_channel_map(&plVar4->n_ch_map); + if (*(char *)((int)¶m_2[2].ea_cb_stop + 3) == '\x03') { + (*ble_memset_ptr)(&plVar4->chnl_assess,0,0x28); + delay = (uint)llm_le_env.ch_map_assess.assess_timer; + (plVar4->chnl_assess).reassess_count = llm_le_env.ch_map_assess.reassess_count; + ble_ke_timer_set(0x105,task_id,delay); + if (*(ushort *)((int)¶m_2[2].linked_element + 2) < 2) { + (plVar4->chnl_assess).latency_en = false; + } + else { + (plVar4->chnl_assess).latency_en = true; + } + } + plVar4->elt = param_2; + uVar1 = param_1->sup_to; + plVar4->sup_to = uVar1; + ble_ke_timer_set(0x101,task_id,(uint)uVar1); + plVar4->disc_reason = '\b'; + plVar4->llc_status = 0; + plVar4->disc_event_sent = false; + llm_util_get_supp_features(&plVar4->feats_used); + plVar4->operation[0] = (void *)0x0; + plVar4->operation[1] = (void *)0x0; + plVar4->operation[2] = (void *)0x0; + plVar4->operation[3] = (void *)0x0; + ble_ke_state_set(task_id,'\0'); + pplVar5 = llc_env + uVar7; + plVar6 = *pplVar5; + plVar6->auth_payl_to = 3000; + plVar6->loc_proc_state = '\0'; + plVar6->rem_proc_state = '\0'; + llc_util_set_auth_payl_to_margin((lld_evt_tag *)¶m_2->env); + uVar3 = llm_le_env.data_len_val.conn_initial_max_tx_octets; + (plVar4->data_len_ext_info).send_req_not_allowed = false; + (plVar4->data_len_ext_info).conn_max_tx_octets = uVar3; + (plVar4->data_len_ext_info).conn_max_tx_time = llm_le_env.data_len_val.conn_initial_max_tx_time; + *(undefined4 *)&(plVar4->data_len_ext_info).conn_max_rx_octets = 0x1b00fb; + (plVar4->data_len_ext_info).conn_eff_max_rx_octets = 0x1b; + *(undefined4 *)&(plVar4->data_len_ext_info).conn_max_rx_time = 0x1480848; + (plVar4->data_len_ext_info).conn_eff_max_rx_time = 0x148; + (plVar4->data_len_ext_info).data_len_ext_flag = + (plVar4->data_len_ext_info).data_len_ext_flag & 0xfe | 2; + (*pplVar5)->operation[0] = (void *)0x0; + (*pplVar5)->operation[1] = (void *)0x0; + plVar4 = *pplVar5; + plVar4->operation[2] = (void *)0x0; + plVar4->operation[3] = (void *)0x0; + plVar4->encryption_state = '\0'; + llc_le_con_cmp_evt_send('\0',conhdl,param_1); + llc_le_ch_sel_algo_evt_send + ((byte)((ushort)*(undefined2 *)(&DAT_2800809e + uVar7 * 0x5c) >> 0xe) & 1,conhdl,param_1 + ); + return; +} + + + +void llc_con_update_complete_send(uint8_t status,uint16_t conhdl,lld_evt_tag *evt) + +{ + undefined *param; + undefined2 in_register_0000202e; + uint16_t uVar1; + void *pvVar2; + + param = (undefined *)ble_ke_msg_alloc(0x804,conhdl,0,10); + *param = 3; + *(uint16_t *)(param + 2) = conhdl; + param[1] = status; + if (evt == (lld_evt_tag *)0x0) { + pvVar2 = llc_env[CONCAT22(in_register_0000202e,conhdl)]->operation[0]; + if (pvVar2 == (void *)0x0) { + *(undefined2 *)(param + 4) = 0; + *(undefined2 *)(param + 6) = 0; + *(undefined2 *)(param + 8) = 0; + goto LAB_2300f300; + } + *(undefined2 *)(param + 4) = *(undefined2 *)((int)pvVar2 + 0xe); + *(undefined2 *)(param + 6) = *(undefined2 *)((int)pvVar2 + 6); + uVar1 = *(uint16_t *)((int)pvVar2 + 8); + } + else { + *(uint16_t *)(param + 4) = evt->interval >> 1; + *(short *)(param + 6) = *(short *)(evt->evt + 10) + -1; + uVar1 = llc_env[CONCAT22(in_register_0000202e,conhdl)]->sup_to; + } + *(uint16_t *)(param + 8) = uVar1; +LAB_2300f300: + hci_send_2_host(param); + return; +} + + + +void llc_ltk_req_send(uint16_t conhdl,llcp_enc_req *param) + +{ + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x804,conhdl,0,0xe); + *(uint16_t *)(param_00 + 2) = conhdl; + *param_00 = 5; + *(undefined2 *)(param_00 + 0xc) = *(undefined2 *)param->ediv; + (*ble_memcpy_ptr)(param_00 + 4,¶m->rand,8); + hci_send_2_host(param_00); + return; +} + + + +void llc_feats_rd_event_send(uint8_t status,uint16_t conhdl,le_features *feats) + +{ + _Bool _Var1; + undefined3 extraout_var; + undefined *param; + + _Var1 = llm_util_check_evt_mask('\x03'); + if (CONCAT31(extraout_var,_Var1) != 0) { + param = (undefined *)ble_ke_msg_alloc(0x804,conhdl,0,0xc); + *param = 4; + param[1] = status; + *(uint16_t *)(param + 2) = conhdl; + (*ble_memcpy_ptr)(param + 4,feats,8); + hci_send_2_host(param); + return; + } + return; +} + + + +void llc_version_rd_event_send(uint8_t status,uint16_t conhdl) + +{ + uint8_t *param; + undefined2 in_register_0000202e; + llc_env_tag *plVar1; + + param = (uint8_t *)ble_ke_msg_alloc(0x803,conhdl,0xc,10); + *(uint16_t *)(param + 2) = conhdl; + *param = status; + *(uint16_t *)(param + 6) = (llc_env[CONCAT22(in_register_0000202e,conhdl)]->peer_version).compid; + plVar1 = llc_env[CONCAT22(in_register_0000202e,conhdl)]; + *(uint16_t *)(param + 8) = (plVar1->peer_version).subvers; + param[4] = (plVar1->peer_version).vers; + hci_send_2_host(param); + return; +} + + + +void llc_common_cmd_complete_send(uint16_t opcode,uint8_t status,uint16_t conhdl) + +{ + uint8_t *param; + + param = (uint8_t *)ble_ke_msg_alloc(0x801,conhdl,opcode,4); + *param = status; + *(uint16_t *)(param + 2) = conhdl; + hci_send_2_host(param); + return; +} + + + +void llc_common_cmd_status_send(uint16_t opcode,uint8_t status,uint16_t conhdl) + +{ + uint8_t *param; + + param = (uint8_t *)ble_ke_msg_alloc(0x802,conhdl,opcode,1); + *param = status; + hci_send_2_host(param); + return; +} + + + +void llc_common_flush_occurred_send(uint16_t conhdl) + +{ + uint16_t *param; + + param = (uint16_t *)ble_ke_msg_alloc(0x803,conhdl,0x11,2); + *param = conhdl; + hci_send_2_host(param); + return; +} + + + +void llc_common_enc_key_ref_comp_evt_send(uint16_t conhdl,uint8_t status) + +{ + uint8_t *param; + + param = (uint8_t *)ble_ke_msg_alloc(0x803,conhdl,0x30,4); + *(uint16_t *)(param + 2) = conhdl; + *param = status; + hci_send_2_host(param); + return; +} + + + +void llc_common_enc_change_evt_send(uint16_t conhdl,uint8_t enc_status,uint8_t status) + +{ + undefined2 in_register_0000202a; + uint8_t *param; + ushort task_id; + undefined3 in_register_0000202d; + llc_env_tag *plVar1; + + task_id = conhdl << 8 | 1; + if (CONCAT31(in_register_0000202d,enc_status) == 0) { + ble_ke_timer_clear(0x103,task_id); + ble_ke_timer_clear(0x104,task_id); + } + else { + plVar1 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + ble_ke_timer_set(0x103,task_id,(uint)plVar1->auth_payl_to - (uint)plVar1->auth_payl_to_margin); + ble_ke_timer_set(0x104,task_id, + (uint)llc_env[CONCAT22(in_register_0000202a,conhdl)]->auth_payl_to); + } + param = (uint8_t *)ble_ke_msg_alloc(0x803,conhdl,8,6); + *(uint16_t *)(param + 2) = conhdl; + param[4] = enc_status; + *param = status; + hci_send_2_host(param); + return; +} + + + +void llc_common_nb_of_pkt_comp_evt_send(uint16_t conhdl,uint8_t nb_of_pkt) + +{ + undefined *param; + undefined3 in_register_0000202d; + + param = (undefined *)ble_ke_msg_alloc(0x803,conhdl,0x13,6); + *(uint16_t *)(param + 2) = conhdl; + *(short *)(param + 4) = (short)CONCAT31(in_register_0000202d,nb_of_pkt); + *param = 1; + hci_send_2_host(param); + return; +} + + + +void llc_con_update_ind(uint16_t conhdl,ea_elt_tag *elt_new) + +{ + ushort uVar1; + _Bool _Var2; + undefined2 in_register_0000202a; + undefined3 extraout_var; + + uVar1 = llc_env[CONCAT22(in_register_0000202a,conhdl)]->llc_status; + if ((uVar1 & 0xc0) != 0) { + llc_env[CONCAT22(in_register_0000202a,conhdl)]->llc_status = uVar1 & 0xff3f; + _Var2 = llm_util_check_evt_mask('\x02'); + if (CONCAT31(extraout_var,_Var2) != 0) { + llc_con_update_complete_send('\0',conhdl,(lld_evt_tag *)&elt_new->env); + } + } + if (*(ushort *)((int)&elt_new[2].linked_element + 2) < 2) { + (llc_env[CONCAT22(in_register_0000202a,conhdl)]->chnl_assess).latency_en = false; + } + else { + (llc_env[CONCAT22(in_register_0000202a,conhdl)]->chnl_assess).latency_en = true; + } + return; +} + + + +void llc_lsto_con_update(uint16_t conhdl) + +{ + llc_env_tag *plVar1; + undefined2 in_register_0000202a; + uint uVar2; + + plVar1 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + uVar2 = (uint)plVar1->sup_to; + if ((uint)plVar1->sup_to < (uint)plVar1->n_sup_to) { + uVar2 = (uint)plVar1->n_sup_to; + } + plVar1->sup_to = (uint16_t)((uVar2 << 0x11) >> 0x10); + ble_ke_timer_set(0x101,conhdl << 8 | 1,(uVar2 << 0x11) >> 0x10); + plVar1->llc_status = plVar1->llc_status | 0x20; + return; +} + + + +void llc_map_update_ind(uint16_t conhdl) + +{ + llc_env_tag *plVar1; + uint8_t uVar2; + undefined2 in_register_0000202a; + int iVar3; + + plVar1 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + uVar2 = llm_util_check_map_validity((uint8_t *)&plVar1->n_ch_map,'\x05'); + iVar3 = CONCAT22(in_register_0000202a,conhdl) * 0x5c; + *(undefined2 *)(iVar3 + 0x280080aa) = *(undefined2 *)(plVar1->n_ch_map).map; + *(undefined2 *)(iVar3 + 0x280080ac) = *(undefined2 *)((plVar1->n_ch_map).map + 2); + *(undefined2 *)(iVar3 + 0x280080ae) = CONCAT11(uVar2,(plVar1->n_ch_map).map[4]); + memcpy(&plVar1->ch_map,&plVar1->n_ch_map,5); + return; +} + + + +void llc_con_update_finished(int param_1) + +{ + ushort uVar1; + byte bVar2; + uint8_t uVar3; + ushort id; + undefined3 extraout_var; + llc_env_tag *plVar4; + + id = (ushort)(param_1 << 8) | 1; + bVar2 = ble_ke_state_get(id); + if ((bVar2 & 0xf) != 0xf) { + uVar3 = lld_get_mode((uint16_t)param_1); + if (CONCAT31(extraout_var,uVar3) == 3) { + llc_util_clear_operation_ptr(param_1,0); + ble_ke_state_set(id,bVar2 & 0xfe); + llc_env[param_1]->loc_proc_state = '\0'; + } + else { + plVar4 = llc_env[param_1]; + uVar1 = plVar4->llc_status; + if ((uVar1 & 0x400) == 0) { + plVar4->llc_status = uVar1 | 0x800; + } + else { + ble_ke_state_set(id,bVar2 & 0xfd); + plVar4 = llc_env[param_1]; + plVar4->rem_proc_state = '\0'; + plVar4->llc_status = plVar4->llc_status & 0xfbff; + } + } + } + return; +} + + + +void llc_map_update_finished(int param_1) + +{ + ushort uVar1; + byte bVar2; + uint8_t uVar3; + ushort id; + undefined3 extraout_var; + llc_env_tag *plVar4; + + id = (ushort)(param_1 << 8) | 1; + bVar2 = ble_ke_state_get(id); + if ((bVar2 & 0xf) != 0xf) { + uVar3 = lld_get_mode((uint16_t)param_1); + if (CONCAT31(extraout_var,uVar3) == 3) { + ble_ke_state_set(id,bVar2 & 0xfe); + llc_env[param_1]->loc_proc_state = '\0'; + } + else { + plVar4 = llc_env[param_1]; + uVar1 = plVar4->llc_status; + if ((uVar1 & 0x400) == 0) { + plVar4->llc_status = uVar1 | 0x800; + } + else { + ble_ke_state_set(id,bVar2 & 0xfd); + plVar4 = llc_env[param_1]; + plVar4->rem_proc_state = '\0'; + plVar4->llc_status = plVar4->llc_status & 0xfbff; + } + } + } + return; +} + + + +void lld_evt_winsize_change(lld_evt_tag *evt,_Bool instant) + +{ + undefined3 in_register_0000202d; + uint uVar1; + uint uVar2; + + uVar1 = *(uint *)evt->evt; + if ((int)(uVar1 << 0x10) < 0) { + uVar1 = (uVar1 & 0x7fff) * 0x271; + } + uVar1 = uVar1 + *(int *)(evt->evt + 4) * 2; + uVar2 = uVar1; + if (uVar1 < 0xe) { + uVar2 = 0xe; + } + if (((uint)(evt->interval >> 1) * (uint)*(ushort *)(evt->evt + 10) * 0x271 - 0x96 <= uVar2) && + (CONCAT31(in_register_0000202d,instant) == 0)) { + evt->evt_flag = evt->evt_flag | 0x10; + return; + } + if (0x3fff < uVar1) { + uVar2 = ((uVar2 + 0x270) / 0x271 | 0xffff8000) & 0xffff; + if ((evt->anchor_point).finetime_cnt == 0) goto LAB_2300f8f2; + uVar2 = uVar2 + 1; + } + uVar2 = uVar2 & 0xffff; +LAB_2300f8f2: + *(undefined2 *)((uint)evt->conhdl * 0x5c + 0x280080a2) = (short)uVar2; + *(uint *)evt->evt = uVar2; + return; +} + + + +void lld_evt_slave_time_compute(ea_elt_tag *elt,uint16_t slot_offset) + +{ + ushort uVar1; + int iVar2; + undefined2 in_register_0000202e; + uint uVar3; + uint uVar4; + int iVar5; + anon_subr_void_ea_elt_tag_ptr_for_ea_cb_cancel *paVar6; + uint16_t uVar7; + void *pvVar8; + + pvVar8 = elt->env; + uVar3 = CONCAT22(in_register_0000202e,slot_offset) * 0x271 + (uint)*(ushort *)&elt[1].hdr.next; + iVar5 = (uint)*(ushort *)&elt[2].ea_cb_start * 0x5c; + uVar1 = *(ushort *)(iVar5 + 0x280080a2); + if ((short)uVar1 < 0) { + iVar2 = (((uint)uVar1 << 0x11) >> 0x12) * -0x271; + } + else { + iVar2 = -(uint)(uVar1 >> 1); + } + uVar4 = (uVar3 + iVar2) - 0x21; + elt->env = (void *)(uVar3 / 0x271 + (int)pvVar8 & 0x7ffffff); + *(short *)&elt[1].hdr.next = (short)(uVar3 % 0x271); + elt->timestamp = uVar4 / 0x271 + (int)pvVar8 & 0x7ffffff; + if ((short)uVar1 < 0) { + uVar7 = uVar1 & 0x7fff; + } + else { + uVar7 = (uint16_t)(((uint)uVar1 / 0x271 + 1) * 0x10000 >> 0x10); + } + paVar6 = elt[1].ea_cb_cancel; + elt->duration_min = uVar7; + elt->duration_min = (uVar7 + *(short *)(paVar6 + 8)) * 0x271; + uVar7 = (uint16_t)(uVar4 % 0x271); + *(uint16_t *)(iVar5 + 0x28008090) = uVar7; + elt->delay = uVar7; + return; +} + + + +void lld_evt_prevent_stop(ea_elt_tag *elt) + +{ + return; +} + + + +void lld_evt_deferred_elt_push(ea_elt_tag *elt,uint8_t type,uint8_t rx_desc_cnt) + +{ + void *pvVar1; + + pvVar1 = ble_ke_malloc(0xc,'\0'); + *(ea_elt_tag **)((int)pvVar1 + 4) = elt; + *(uint8_t *)((int)pvVar1 + 8) = type; + *(uint8_t *)((int)pvVar1 + 9) = rx_desc_cnt; + ble_co_list_push_back(0x4201a338,pvVar1); + return; +} + + + +void lld_evt_elt_wait_insert(ea_elt_tag *elt) + +{ + void *pvVar1; + + pvVar1 = ble_ke_malloc(8,'\0'); + *(ea_elt_tag **)((int)pvVar1 + 4) = elt; + ble_co_list_push_back(0x4201a330,pvVar1); + return; +} + + +/* +Unable to decompile 'lld_evt_deferred_elt_pop' +Cause: Exception while decompiling 2300fa36: Decompiler process died + +*/ + + +// WARNING: Removing unreachable block (ram,0x2300fab8) +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t lld_evt_get_next_free_slot(void) + +{ + if (lld_evt_env.elt_prog.first != (co_list_hdr *)0x0) { + return (int)&(lld_evt_env.elt_prog.last[2].next)->next + + (uint)*(ushort *)((int)&lld_evt_env.elt_prog.last[4].next + 2) / 0x271 & 0x7ffffff; + } + do { + } while( true ); +} + + + +lld_evt_wait_tag * lld_evt_elt_wait_get(ea_elt_tag *elt) + +{ + co_list_hdr list_hdr; + lld_evt_wait_tag *plVar1; + + list_hdr = (co_list_hdr)lld_evt_env.elt_wait.first; + if (elt == (ea_elt_tag *)0x0) { + plVar1 = (lld_evt_wait_tag *)ble_co_list_pop_front(&lld_evt_env.elt_wait); + return plVar1; + } + while( true ) { + if (list_hdr == (co_list_hdr)0x0) { + return (lld_evt_wait_tag *)0x0; + } + if ((ea_elt_tag *)((co_list_hdr *)((int)list_hdr + 4))->next == elt) break; + list_hdr = *(co_list_hdr *)list_hdr; + } + ble_co_list_extract(&lld_evt_env.elt_wait,(co_list_hdr *)list_hdr,'\0'); + return (lld_evt_wait_tag *)list_hdr; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_evt_schedule(ea_elt_tag *elt) + +{ + char cVar1; + uint uVar2; + ushort *puVar3; + lld_evt_wait_tag *mem_ptr; + uint uVar4; + int iVar5; + ea_elt_tag *peVar6; + uint uVar7; + + if (elt == (ea_elt_tag *)0x0) { + return; + } + uVar2 = elt->timestamp; + mem_ptr = lld_evt_elt_wait_get(elt); + if (mem_ptr != (lld_evt_wait_tag *)0x0) { + ble_ke_free(mem_ptr); + } + cVar1 = *(char *)((int)&elt[2].ea_cb_stop + 3); + if ((cVar1 == '\0') || (cVar1 == '\x05')) { + if ((*(byte *)((int)&elt[2].ea_cb_cancel + 2) & 0x10) != 0) goto LAB_2300fb2c; + llm_util_adv_data_update(); + if (((llm_le_env.advertising_params)->adv_ldc_flag == false) && + (peVar6 = (ea_elt_tag *)((int)elt[2].linked_element - elt->timestamp), + _DAT_28008160 = SUB42(peVar6,0), (int)peVar6 * 0x10000 >> 0x10 < 1)) { + _DAT_28008160 = 1; + } + } + if (*(char *)((int)&elt[2].ea_cb_stop + 3) == '\x01') { + if ((*(byte *)((int)&elt[2].ea_cb_cancel + 2) & 0x10) != 0) { +LAB_2300fb2c: + lld_evt_deferred_elt_push(elt,'\x01','\0'); + return; + } + iVar5 = (int)((int)elt[2].linked_element - elt->timestamp) * 0x10000; + _DAT_280081bc = (ushort)((uint)iVar5 >> 0x10); + if (iVar5 >> 0x10 < 1) { + _DAT_280081bc = 1; + } + _DAT_280081b6 = _DAT_280081bc | 0x8000; + peVar6 = elt->linked_element; + if (peVar6 != (ea_elt_tag *)0x0) { + uVar4 = (uint)*(ushort *)&peVar6[2].ea_cb_stop; + uVar7 = uVar4 - (elt->timestamp - peVar6->timestamp & 0x7ffffff) % uVar4 & 0xffff; + if (uVar7 < 6) { + uVar7 = uVar7 + uVar4 & 0xffff; + } + _DAT_280081ba = (undefined2)(((uVar7 >> 1) - 1) * 0x10000 >> 0x10); + } + } + puVar3 = (ushort *)(((uVar2 & 0xf) + 0xa002000) * 4); + *puVar3 = 0; + if ((byte)(*(char *)((int)&elt[2].ea_cb_stop + 3) - 3U) < 2) { + lld_util_dle_set_cs_fields(*(uint16_t *)&elt[2].ea_cb_start); + } + *(undefined2 *)((uint)*(ushort *)&elt[2].ea_cb_start * 0x5c + 0x280080d8) = + *(undefined2 *)&elt[2].timestamp; + *puVar3 = *puVar3 & 0xffcf; + *puVar3 = *puVar3 & 0xfff0 | 2; + puVar3[1] = *(ushort *)((int)&elt[2].ea_cb_start + 2); + lld_pdu_tx_prog(&elt->env); + ble_co_list_push_back(&lld_evt_env,elt); + return; +} + + +/* +Unable to decompile 'lld_evt_delete_elt_push' +Cause: Exception while decompiling 2300fc74: Decompiler process died + +*/ + +/* +Unable to decompile 'lld_evt_deffered_elt_handler' +Cause: Exception while decompiling 2300fcd6: Decompiler process died + +*/ + + +void lld_evt_channel_next(uint16_t conhdl,int16_t nb_inc) + +{ + undefined2 in_register_0000202a; + ushort *puVar1; + ushort uVar2; + undefined2 in_register_0000202e; + int iVar3; + + puVar1 = (ushort *)(&DAT_2800809e + CONCAT22(in_register_0000202a,conhdl) * 0x5c); + iVar3 = (int)(((int)(uint)*puVar1 >> 8 & 0x1fU) * CONCAT22(in_register_0000202e,nb_inc) + + ((uint)*puVar1 & 0x3f)) % 0x25; + uVar2 = (ushort)iVar3; + if (iVar3 < 0) { + uVar2 = uVar2 + 0x25; + } + *puVar1 = uVar2 | *puVar1 & 0xffc0; + return; +} + + +/* +Unable to decompile 'lld_evt_init' +Cause: Exception while decompiling 2300fe2c: Decompiler process died + +*/ + +/* +Unable to decompile 'lld_evt_init_evt' +Cause: Exception while decompiling 2300ff3e: Decompiler process died + +*/ + +/* +Unable to decompile 'lld_evt_elt_delete' +Cause: Exception while decompiling 2300ff90: Decompiler process died + +*/ + +/* +Unable to decompile 'lld_evt_delete_elt_handler' +Cause: Exception while decompiling 2301007e: Decompiler process died + +*/ + + +uint16_t lld_evt_drift_compute(uint16_t delay,uint8_t master_sca) + +{ + undefined2 in_register_0000202a; + undefined3 in_register_0000202d; + + return (uint16_t) + (((uint)co_sca2ppm[lld_evt_env.sca] + + (uint)co_sca2ppm[CONCAT31(in_register_0000202d,master_sca)]) * + CONCAT22(in_register_0000202a,delay) * 0x29 >> 0x10); +} + + + +void lld_evt_rxwin_compute(ea_elt_tag *elt) + +{ + _Bool instant; + ushort uVar1; + uint16_t uVar2; + undefined2 extraout_var; + + uVar2 = lld_evt_drift_compute + ((uint16_t) + (((uint)*(ushort *)((int)&elt[2].timestamp + 2) + 1) * + (uint)*(ushort *)&elt[2].ea_cb_stop * 0x10000 >> 0x10),elt[2].current_prio); + uVar1 = *(ushort *)&elt[2].ea_cb_start; + elt[2].hdr.next = (co_list_hdr *)CONCAT22(extraout_var,uVar2); + instant = (_Bool)elt[2].start_latency; + elt[1].env = (void *)(uint)*(ushort *)((uint)uVar1 * 0x5c + 0x280080a2); + lld_evt_winsize_change((lld_evt_tag *)&elt->env,instant); + return; +} + + +/* +Unable to decompile 'lld_evt_restart' +Cause: Exception while decompiling 230101ae: Decompiler process died + +*/ + +/* +Unable to decompile 'lld_evt_elt_insert' +Cause: Exception while decompiling 23010988: Decompiler process died + +*/ + + +void lld_evt_canceled(ea_elt_tag *elt) + +{ + lld_evt_wait_tag *mem_ptr; + int iVar1; + + mem_ptr = lld_evt_elt_wait_get(elt); + if (mem_ptr != (lld_evt_wait_tag *)0x0) { + ble_ke_free(mem_ptr); + } + if (elt->current_prio < 0x1f) { + elt->current_prio = elt->current_prio + 1; + } + iVar1 = lld_evt_restart(elt,1); + if (iVar1 != 0) { + lld_evt_elt_insert(elt,true); + return; + } + lld_evt_deferred_elt_push(elt,'\x01','\0'); + ble_ke_event_set('\b'); + return; +} + + +/* +Unable to decompile 'lld_evt_schedule_next' +Cause: Exception while decompiling 23010a4e: Decompiler process died + +*/ + + +ea_elt_tag * lld_evt_scan_create(uint16_t handle,uint16_t latency) + +{ + ea_elt_tag *elt; + uint32_t uVar1; + + elt = ea_elt_create(0x58); + lld_evt_init_evt((lld_evt_tag *)&elt->env); + *(undefined *)((int)&elt[2].ea_cb_stop + 3) = 1; + *(uint16_t *)&elt[2].ea_cb_start = handle; + *(short *)((int)&elt[2].linked_element + 2) = latency + 1; + *(short *)((int)&elt[2].ea_cb_start + 2) = handle * 0x5c + 0x8e; + lld_util_priority_set(elt,'\0'); + elt->ea_cb_start = lld_evt_schedule; + elt->ea_cb_cancel = lld_evt_canceled; + elt->ea_cb_stop = lld_evt_prevent_stop; + elt->duration_min = 0x9c4; + elt->asap_settings = 0x6051; + elt->stop_latency1 = '\0'; + *(undefined2 *)&elt->stop_latency2 = 0x200; + uVar1 = ea_time_get_halfslot_rounded(); + elt->timestamp = uVar1; + return elt; +} + + + +ea_elt_tag * +lld_evt_move_to_master + (ea_elt_tag *elt_scan,uint16_t conhdl,llc_create_con_req_ind *pdu_tx,uint8_t rx_hdl) + +{ + ushort uVar1; + uint16_t uVar2; + uint uVar3; + uint uVar4; + ea_interval_tag *interval_to_add; + uint32_t uVar5; + undefined3 in_register_00002035; + uint uVar6; + uint uVar7; + ea_elt_tag *elt; + uint uVar8; + + elt = elt_scan->linked_element; + interval_to_add = ea_interval_create(); + uVar8 = (uint)*(ushort *)&elt[2].ea_cb_stop; + uVar4 = elt->timestamp; + uVar1 = *(ushort *)((uint)*(ushort *)&elt_scan[2].ea_cb_start * 0x5c + 0x280080cc); + elt_scan->linked_element = (ea_elt_tag *)0x0; + lld_scan_stop(elt_scan); + uVar5 = ea_time_get_halfslot_rounded(); + uVar4 = uVar4 % uVar8; + uVar7 = (int)elt_scan->env + + (((uint)*(ushort *)&elt_scan[1].hdr.next + + (uint)(*(ushort *)(&DAT_280083d2 + CONCAT31(in_register_00002035,rx_hdl) * 0xe) >> 8) * + 8 + 0x48e) / 0x271 - 1) & 0x7ffffff; + uVar3 = (uVar8 + uVar7) - (uVar7 - uVar4 & 0x7ffffff) % uVar8 & 0x7ffffff; + uVar6 = uVar3 - uVar7 & 0x7ffffff; + if (0x4000000 < uVar6) { + uVar6 = -(uVar7 - uVar3 & 0x7ffffff); + } + if ((int)uVar6 < (int)(((uint)uVar1 << 0x11) >> 0x10)) { + uVar3 = uVar3 + uVar8 & 0x7ffffff; + } + uVar6 = uVar5 - uVar3 & 0x7ffffff; + if (0x4000000 < uVar6) { + if ((uVar3 - uVar5 & 0x7ffffff) != 0) goto LAB_23010e16; + uVar6 = 0; + } + uVar6 = (int)uVar6 / (int)uVar8 + 1; + uVar7 = uVar6 & 0xffff; + lld_evt_channel_next(conhdl,(int16_t)uVar7); + *(short *)&elt[2].timestamp = (short)(uVar6 * 0x10000 >> 0x10) + *(short *)&elt[2].timestamp; + uVar3 = uVar3 + uVar7 * uVar8 & 0x7ffffff; +LAB_23010e16: + uVar2 = *(uint16_t *)&elt[2].ea_cb_stop; + elt->timestamp = uVar3; + interval_to_add->interval_used = uVar2; + interval_to_add->bandwidth_used = elt->duration_min / 0x271; + uVar2 = *(uint16_t *)&elt[2].ea_cb_start; + interval_to_add->offset_used = (uint16_t)uVar4; + interval_to_add->role_used = 0; + interval_to_add->conhdl_used = uVar2; + interval_to_add->linkid = *(short *)&elt[2].ea_cb_start * 0x5c + 0x8e; + ea_interval_insert(interval_to_add); + *(ea_interval_tag **)&elt[1].ea_cb_cancel = interval_to_add; + lld_util_priority_set(elt,'\x02'); + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = *(byte *)((int)&elt[2].ea_cb_cancel + 2) | 2; + return elt; +} + + + +// WARNING: Could not reconcile some variable overlaps + +ea_elt_tag * +lld_evt_update_create + (ea_elt_tag *elt_old,uint16_t ce_len,uint16_t mininterval,uint16_t maxinterval, + uint16_t latency,uint8_t pref_period,lld_evt_update_tag *upd_par) + +{ + uint8_t uVar1; + ea_elt_tag *elt; + undefined3 extraout_var; + ea_elt_tag *peVar2; + uint uVar3; + uint16_t uVar4; + undefined2 in_register_00002036; + uint uVar5; + uint uVar6; + uint32_t uVar7; + uint16_t uStack84; + ea_param_output set_param; + ea_param_input input_param; + + uVar5 = CONCAT22(in_register_00002036,maxinterval); + elt = ea_elt_create(0x58); + if (elt == (ea_elt_tag *)0x0) { + return (ea_elt_tag *)0x0; + } + (*ble_memcpy_ptr)(elt,elt_old,0x2c); + lld_evt_init_evt((lld_evt_tag *)&elt->env); + *(short *)((int)&elt[2].linked_element + 2) = latency + 1; + *(undefined *)((int)&elt[2].ea_cb_stop + 3) = 3; + set_param.offset = mininterval; + set_param._10_2_ = maxinterval; + ea_interval_duration_req((ea_param_input *)&set_param.offset,(ea_param_output *)&uStack84); + uVar1 = ea_offset_req((ea_param_input *)&set_param.offset,(ea_param_output *)&uStack84); + if (CONCAT31(extraout_var,uVar1) == 0) { + *(uint16_t *)&elt[2].ea_cb_stop = uStack84; + lld_util_connection_param_set(elt,(ea_param_output *)&uStack84); + peVar2 = (ea_elt_tag *)elt->timestamp; + uVar5 = (uint)*(ushort *)((int)&elt_old[2].linked_element + 2) * 0x60000; + uVar4 = *(short *)&elt_old[2].timestamp + (short)(uVar5 >> 0x10); + uVar3 = 0x7ffffff; + uVar5 = (uint)*(ushort *)&elt_old[2].ea_cb_stop * (uVar5 >> 0x10) + elt_old->timestamp & + 0x7ffffff; + uVar6 = uVar5 - (int)peVar2 & 0x7ffffff; + if (uVar6 < 0x4000001) goto LAB_23010fa2; + } + else { + uVar4 = 0; + uVar3 = 1; + peVar2 = elt; + lld_evt_delete_elt_push(elt,true,false); + ebreak(); + } + uVar6 = -((uint)((int)peVar2 - uVar5) & uVar3); +LAB_23010fa2: + uVar3 = (uint)*(ushort *)&elt[2].ea_cb_stop; + elt->timestamp = + (uint)((int)&(peVar2->hdr).next + ((int)((uVar3 - 1) + uVar6) / (int)uVar3) * uVar3) & + 0x7ffffff; + upd_par->win_size = '\x01'; + *(uint16_t *)&elt_old[2].linked_element = uVar4; + uVar7 = elt->timestamp; + upd_par->instant = uVar4; + upd_par->win_offset = (uint16_t)((uVar7 - uVar5) * 0x20 >> 6); + elt_old->linked_element = elt; + *(undefined *)((int)&elt_old[2].delay + 1) = 1; + return elt; +} + + + +// WARNING: Could not reconcile some variable overlaps +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +ea_elt_tag * +lld_evt_move_to_slave + (llc_create_con_req_ind *con_par,llm_pdu_con_req_rx *con_req_pdu,ea_elt_tag *elt_adv, + uint16_t conhdl) + +{ + byte master_sca; + byte bVar1; + byte bVar2; + short sVar3; + undefined2 uVar4; + ushort uVar5; + undefined2 uVar6; + uint8_t uVar7; + uint16_t delay; + ea_elt_tag *elt; + ea_interval_tag *interval_to_add; + undefined2 extraout_var_01; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined *puVar8; + undefined2 extraout_var_02; + ushort uVar9; + void *pvVar10; + uint uVar11; + ushort uStack100; + ea_param_output set_param; + ea_param_input input_param; + + elt = ea_elt_create(0x58); + interval_to_add = ea_interval_create(); + uVar5 = _DAT_28008198; + uVar6 = _DAT_28008196; + uVar4 = _DAT_28008194; + uVar11 = (uint)con_req_pdu->winoffset; + master_sca = con_req_pdu->hop_sca; + bVar1 = con_req_pdu->winsize; + con_par->filter_policy = (uint8_t)((ushort)_DAT_28008154 >> 8); + if (elt == (ea_elt_tag *)0x0) { + lld_evt_delete_elt_push(elt_adv,true,false); + } + else { + lld_evt_init_evt((lld_evt_tag *)&elt->env); + lld_evt_delete_elt_push(elt_adv,true,false); + *(uint16_t *)&elt[2].ea_cb_start = conhdl; + master_sca = master_sca >> 5; + *(uint16_t *)&elt[2].ea_cb_stop = con_par->con_int << 1; + delay = con_par->con_lat; + elt[2].current_prio = master_sca; + elt[2].start_latency = '\0'; + *(short *)((int)&elt[2].linked_element + 2) = delay + 1; + *(undefined *)((int)&elt[2].ea_cb_stop + 3) = 4; + *(undefined2 *)&elt[2].asap_limit = 2; + bVar2 = elt_adv->start_latency; + elt->duration_min = 0x4e2; + elt->start_latency = bVar2; + if (uVar11 << 1 <= (uint)bVar2) { + uVar9 = con_par->con_int; + lld_evt_channel_next(conhdl,1); + uVar11 = uVar11 + uVar9 & 0xffff; + *(undefined2 *)&elt[2].timestamp = 1; + } + delay = (uint16_t)((uVar11 * 2 + (uint)bVar1 + 2) * 0x10000 >> 0x10); + delay = lld_evt_drift_compute(delay,master_sca); + elt[2].hdr.next = (co_list_hdr *)CONCAT22(extraout_var_01,delay); + pvVar10 = (void *)CONCAT22(uVar6,uVar4); + elt[1].env = (void *)((uint)bVar1 * 0x4e2 + -0x21); + lld_evt_winsize_change((lld_evt_tag *)&elt->env,true); + uVar9 = 0x3a8 - (uVar5 & 0x3ff); + if (0x270 < uVar9) { + uVar9 = 0x137 - (uVar5 & 0x3ff); + pvVar10 = (void *)((int)pvVar10 + 1); + } + sVar3 = *(short *)&elt[2].ea_cb_start; + *(ushort *)&elt[1].hdr.next = uVar9; + elt->env = pvVar10; + elt->asap_settings = 0x6000; + *(short *)((int)&elt[2].ea_cb_start + 2) = sVar3 * 0x5c + 0x8e; + elt->ea_cb_start = lld_evt_schedule; + elt->ea_cb_cancel = lld_evt_canceled; + elt->ea_cb_stop = lld_evt_prevent_stop; + lld_util_priority_set(elt,'\x02'); + set_param.offset = *(uint16_t *)&elt[2].ea_cb_stop; + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = *(byte *)((int)&elt[2].ea_cb_cancel + 2) | 2; + uStack100 = 0; + set_param._0_4_ = 0; + set_param.duration._0_2_ = 0; + set_param._10_2_ = set_param.offset; + ea_interval_duration_req((ea_param_input *)&set_param.offset,(ea_param_output *)&uStack100); + uVar7 = ea_offset_req((ea_param_input *)&set_param.offset,(ea_param_output *)&uStack100); + if (CONCAT31(extraout_var,uVar7) != 0) { + uVar7 = ea_offset_req((ea_param_input *)&set_param.offset,(ea_param_output *)&uStack100); + if (CONCAT31(extraout_var_00,uVar7) == 0) { + puVar8 = (undefined *)ble_ke_msg_alloc(0x109,conhdl << 8 | 1,2,0x22); + *puVar8 = 1; + uVar5 = uStack100 >> 1; + *(ushort *)(puVar8 + 2) = uVar5; + *(ushort *)(puVar8 + 4) = uVar5; + *(ushort *)(puVar8 + 0xe) = uVar5; + *(ushort *)(puVar8 + 0x10) = uVar5; + sVar3 = *(short *)((int)&elt[2].linked_element + 2); + puVar8[0x12] = 0; + *(short *)(puVar8 + 6) = sVar3 + -1; + *(undefined2 *)(puVar8 + 8) = 3000; + uVar4 = *(undefined2 *)&elt[2].timestamp; + *(undefined2 *)(puVar8 + 0x14) = uVar4; + *(undefined2 *)(puVar8 + 10) = uVar4; + *(undefined2 *)(puVar8 + 0xc) = *(undefined2 *)&elt[2].timestamp; + delay = lld_util_get_peer_offset((uint16_t)set_param.duration,uStack100,elt->timestamp); + *(short *)(puVar8 + 0x16) = (short)(CONCAT22(extraout_var_02,delay) >> 1); + *(undefined2 *)(puVar8 + 0x18) = 0xffff; + *(undefined2 *)(puVar8 + 0x1a) = 0xffff; + *(undefined2 *)(puVar8 + 0x1c) = 0xffff; + *(undefined2 *)(puVar8 + 0x1e) = 0xffff; + *(undefined2 *)(puVar8 + 0x20) = 0xffff; + ble_ke_msg_send(puVar8); + } + } + interval_to_add->offset_used = (uint16_t)(elt->timestamp % (uint)*(ushort *)&elt[2].ea_cb_stop); + interval_to_add->interval_used = *(uint16_t *)&elt[2].ea_cb_stop; + interval_to_add->bandwidth_used = 2; + interval_to_add->conhdl_used = *(uint16_t *)&elt[2].ea_cb_start; + interval_to_add->role_used = 1; + interval_to_add->linkid = *(short *)&elt[2].ea_cb_start * 0x5c + 0x8e; + ea_interval_insert(interval_to_add); + *(ea_interval_tag **)&elt[1].ea_cb_cancel = interval_to_add; + lld_evt_slave_time_compute(elt,delay); + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = *(byte *)((int)&elt[2].ea_cb_cancel + 2) | 1; + } + return elt; +} + + + +void lld_evt_slave_update(llcp_con_upd_ind *param_pdu,ea_elt_tag *elt_old) + +{ + uint8_t master_sca; + byte bVar1; + short sVar2; + uint16_t uVar3; + ea_elt_tag *peVar4; + undefined2 extraout_var; + llc_env_tag *plVar5; + + if (*(uint16_t *)&elt_old[2].timestamp == param_pdu->instant) { + plVar5 = llc_env[*(ushort *)&elt_old[2].ea_cb_start]; + if ((((uint)*(ushort *)&elt_old[2].ea_cb_stop != (uint)param_pdu->interv << 1) || + ((uint)*(ushort *)((int)&elt_old[2].linked_element + 2) != (uint)param_pdu->latency + 1)) || + (plVar5->sup_to != plVar5->n_sup_to)) { + plVar5->llc_status = plVar5->llc_status | 0x80; + } + *(uint16_t *)&elt_old[2].ea_cb_stop = param_pdu->interv << 1; + *(short *)((int)&elt_old[2].linked_element + 2) = param_pdu->latency + 1; + *(uint16_t *)&elt_old[2].linked_element = param_pdu->instant; + *(undefined *)((int)&elt_old[2].delay + 1) = 1; + *(byte *)((int)&elt_old[2].ea_cb_cancel + 2) = *(byte *)((int)&elt_old[2].ea_cb_cancel + 2) | 9; + return; + } + peVar4 = ea_elt_create(0x58); + if (peVar4 != (ea_elt_tag *)0x0) { + (*ble_memcpy_ptr)(peVar4,elt_old,0x2c); + lld_evt_init_evt((lld_evt_tag *)&peVar4->env); + *(undefined2 *)&peVar4[2].ea_cb_start = *(undefined2 *)&elt_old[2].ea_cb_start; + *(uint16_t *)&peVar4[2].ea_cb_stop = param_pdu->interv << 1; + *(short *)((int)&peVar4[2].linked_element + 2) = param_pdu->latency + 1; + *(undefined *)((int)&peVar4[2].ea_cb_stop + 3) = 4; + master_sca = elt_old[2].current_prio; + peVar4[2].current_prio = master_sca; + *(undefined2 *)&peVar4[2].asap_limit = *(undefined2 *)&elt_old[2].asap_limit; + *(byte *)((int)&peVar4[2].ea_cb_cancel + 2) = *(byte *)((int)&peVar4[2].ea_cb_cancel + 2) | 1; + peVar4->duration_min = 0xffff; + uVar3 = lld_evt_drift_compute + ((uint16_t) + ((((uint)param_pdu->win_off + (uint)param_pdu->win_size) * 2 + + (uint)*(ushort *)&elt_old[2].ea_cb_stop) * 0x10000 >> 0x10),master_sca); + peVar4[2].hdr.next = (co_list_hdr *)CONCAT22(extraout_var,uVar3); + peVar4[1].env = (void *)((uint)param_pdu->win_size * 0x4e2 + -0x21); + elt_old->linked_element = peVar4; + bVar1 = *(byte *)((int)&elt_old[2].ea_cb_cancel + 2); + sVar2 = *(short *)&elt_old[2].timestamp; + *(uint16_t *)&elt_old[2].linked_element = param_pdu->instant; + *(undefined *)((int)&elt_old[2].delay + 1) = 1; + *(uint16_t *)((int)&elt_old[2].asap_limit + 2) = param_pdu->win_off; + *(uint8_t *)&elt_old[2].delay = param_pdu->win_size; + *(byte *)((int)&elt_old[2].ea_cb_cancel + 2) = bVar1 | 1; + if (sVar2 == (uint16_t)(param_pdu->instant - 1)) { + *(byte *)((int)&elt_old[2].ea_cb_cancel + 2) = bVar1 | 9; + } + } + return; +} + + + +ea_elt_tag * +lld_evt_adv_create(uint16_t handle,uint16_t mininterval,uint16_t maxinterval,_Bool restart_pol) + +{ + ea_elt_tag *elt; + uint32_t uVar1; + undefined3 in_register_00002035; + + elt = ea_elt_create(0x58); + lld_evt_init_evt((lld_evt_tag *)&elt->env); + elt->duration_min = 0x9c4; + *(uint16_t *)&elt[2].ea_cb_start = handle; + *(undefined2 *)((int)&elt[2].ea_cb_stop + 2) = 0; + *(uint16_t *)&elt[2].ea_cb_stop = maxinterval; + *(short *)((int)&elt[2].ea_cb_start + 2) = handle * 0x5c + 0x8e; + lld_util_priority_set(elt,'\x05'); + *(undefined2 *)&elt->stop_latency2 = 0x200; + elt->ea_cb_start = lld_evt_schedule; + elt->ea_cb_cancel = lld_evt_canceled; + elt->ea_cb_stop = lld_evt_prevent_stop; + elt->stop_latency1 = '\0'; + elt->asap_settings = 0x6000; + if (CONCAT31(in_register_00002035,restart_pol) == 0) { + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = *(byte *)((int)&elt[2].ea_cb_cancel + 2) | 0x20; + } + uVar1 = ea_time_get_halfslot_rounded(); + elt->timestamp = uVar1; + return elt; +} + + + +void lld_evt_end(ea_elt_tag *elt) + +{ + byte bVar1; + ushort uVar2; + byte bVar3; + bool bVar4; + char "lld_evt_end" [12]; + uint uVar5; + uint32_t uVar6; + uint8_t rx_desc_cnt; + char cVar7; + bool bVar8; + char cVar9; + int iVar10; + ea_elt_tag *peVar11; + + iVar10 = (uint)*(ushort *)&elt[2].ea_cb_start * 0x5c; + uVar2 = *(ushort *)(iVar10 + 0x280080e2); + uVar5 = (uint)(*(ushort *)(iVar10 + 0x280080e4) >> 8) + + (uint)(*(ushort *)(iVar10 + 0x280080e2) >> 8) & 0xff; + if (((*(ushort *)(iVar10 + 0x280080e6) >> 7 & 1) != 0) && (uVar5 == 0)) { + bVar4 = true; +LAB_23011628: + bVar8 = false; + goto LAB_230116d0; + } + bVar1 = *(byte *)((int)&elt[2].ea_cb_cancel + 2); + if ((bVar1 & 0x10) == 0) { + if ((bVar1 & 0x40) == 0) { + elt->current_prio = *(uint8_t *)((int)&elt[2].ea_cb_cancel + 1); + if (uVar5 == 0) goto LAB_230115ea; + goto LAB_230115a2; + } + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = bVar1 & 0xbf; + cVar7 = *(char *)((int)&elt[2].ea_cb_stop + 3); + cVar9 = '\x01'; + if (uVar5 == 0) { +LAB_230115ea: + cVar9 = *(char *)((int)&elt[2].ea_cb_stop + 3); + if (cVar9 != '\0') { + cVar7 = '\x01'; + goto LAB_230115f2; + } + if ((llm_le_env.advertising_params)->adv_ldc_flag != false) goto LAB_230115a2; + } + else { +LAB_230115f2: + if (cVar9 != cVar7) goto LAB_230115a2; + } + uVar6 = lld_evt_get_next_free_slot(); + elt->asap_settings = 0xa051; + peVar11 = elt[2].linked_element; + elt->timestamp = uVar6; + *(ea_elt_tag **)&elt->asap_limit = peVar11; + iVar10 = ea_elt_insert(elt); + if (iVar10 != 0) goto LAB_230115a2; + lld_evt_elt_wait_insert(elt); + bVar4 = false; + bVar8 = false; + if (uVar5 == 0) goto LAB_23011628; + } + else { +LAB_230115a2: + bVar8 = true; + } + bVar4 = bVar8; + bVar1 = *(byte *)((int)&elt[2].ea_cb_stop + 2); + if (uVar5 < bVar1) { + printf("%s:rx_desc_cnt is less than evt->rx_cnt,assert!!!\r\n","lld_evt_end"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + bVar3 = (byte)uVar5; + lld_pdu_rx_handler((lld_evt_tag *)&elt->env,bVar3 - bVar1); + if (*(char *)((int)&elt[2].ea_cb_stop + 3) == '\x02') { + lld_evt_deferred_elt_push(elt,'\x02',bVar3 & 1); + } + else { + bVar1 = *(byte *)((int)&elt[2].ea_cb_stop + 2); + if (uVar5 < bVar1) { + rx_desc_cnt = '\0'; + } + else { + rx_desc_cnt = bVar3 - bVar1; + } + lld_evt_deferred_elt_push(elt,'\x01',rx_desc_cnt); + elt[2].stop_latency1 = + (byte)(*(ushort *) + (&DAT_280083d2 + + ((int)((uint)em_buf_env.rx_current + (uVar5 - 1)) % 8 & 0xffU) * 0xe) >> 4) & 1; + } + if (((*(char *)((int)&elt[2].ea_cb_stop + 3) == '\x01') && (*(char *)&elt[2].timestamp != '\0')) + && ((uVar2 & 0xff) != 0)) { + *(undefined *)((int)&elt[2].timestamp + 1) = 1; + } + *(undefined *)((int)&elt[2].ea_cb_stop + 2) = 0; + ble_ke_event_set('\b'); + bVar8 = true; +LAB_230116d0: + bVar1 = *(byte *)((int)&elt[2].ea_cb_cancel + 2); + if (((bVar1 & 0x30) == 0) && (bVar4)) { + iVar10 = lld_evt_restart(elt,0); + if (iVar10 != 0) { + lld_evt_elt_insert(elt,false); + return; + } + } + else { + if (((bVar1 & 0x10) != 0) && (!bVar8)) { + lld_evt_delete_elt_push(elt,true,true); + return; + } + } + return; +} + + + +void lld_evt_rx(ea_elt_tag *elt) + +{ + byte rx_desc_cnt; + + rx_desc_cnt = (byte)((ushort)*(undefined2 *) + ((uint)*(ushort *)&elt[2].ea_cb_start * 0x5c + 0x28008092) >> 8); + lld_pdu_rx_handler((lld_evt_tag *)&elt->env,rx_desc_cnt >> 4); + rx_desc_cnt = rx_desc_cnt >> 4; + *(char *)((int)&elt[2].ea_cb_stop + 2) = *(char *)((int)&elt[2].ea_cb_stop + 2) + rx_desc_cnt; + lld_evt_deferred_elt_push(elt,'\0',rx_desc_cnt); + ble_ke_event_set('\b'); + return; +} + + + +void lld_evt_rx_afs(ea_elt_tag *elt,uint8_t num) + +{ + byte bVar1; + undefined3 in_register_0000202d; + + bVar1 = *(byte *)((int)&elt[2].ea_cb_stop + 2); + if ((uint)bVar1 < CONCAT31(in_register_0000202d,num)) { + lld_pdu_rx_handler((lld_evt_tag *)&elt->env,num - bVar1); + *(uint8_t *)((int)&elt[2].ea_cb_stop + 2) = num; + lld_evt_deferred_elt_push(elt,'\0','\0'); + ble_ke_event_set('\b'); + return; + } + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void lld_evt_timer_isr(void) + +{ + ble_ke_event_set('\x03'); + return; +} + + + +void lld_evt_end_isr(_Bool apfm) + +{ + undefined3 in_register_00002029; + ea_elt_tag *elt; + + elt = (ea_elt_tag *)ble_co_list_pop_front((co_list *)&lld_evt_env); + ea_elt_remove(); + if (CONCAT31(in_register_00002029,apfm) == 0) { + if (elt->asap_settings >> 0xe != 0) { + elt->asap_settings = 0; + } + } + else { + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = *(byte *)((int)&elt[2].ea_cb_cancel + 2) | 0x40; + } + lld_evt_end(elt); + return; +} + + + +void lld_evt_rx_isr(void) + +{ + if (lld_evt_env.elt_prog.first != (co_list_hdr *)0x0) { + lld_evt_rx((ea_elt_tag *)lld_evt_env.elt_prog.first); + return; + } + return; +} + + + +void lld_evt_afs_isr(uint8_t num) + +{ + if (lld_evt_env.elt_prog.first != (co_list_hdr *)0x0) { + lld_evt_rx_afs((ea_elt_tag *)lld_evt_env.elt_prog.first,num); + return; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void lld_pdu_llcp_con_param_req_unpk(uint16_t pdu_ptr,uint8_t parlen,uint8_t *param) + +{ + undefined2 in_register_0000202a; + int iVar1; + undefined2 auStack34 [2]; + uint16_t res; + + iVar1 = CONCAT22(in_register_0000202a,pdu_ptr); + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + iVar1,2); + *(undefined2 *)(param + 2) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 2U & 0xffff),2); + *(undefined2 *)(param + 4) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 4U & 0xffff),2); + *(undefined2 *)(param + 6) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 6U & 0xffff),2); + *(undefined2 *)(param + 8) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 8U & 0xffff),1); + param[10] = (uint8_t)auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 9U & 0xffff),2); + *(undefined2 *)(param + 0xc) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0xbU & 0xffff),2); + *(undefined2 *)(param + 0xe) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0xdU & 0xffff),2); + *(undefined2 *)(param + 0x10) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0xfU & 0xffff),2); + *(undefined2 *)(param + 0x12) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0x11U & 0xffff),2); + *(undefined2 *)(param + 0x14) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0x13U & 0xffff),2); + *(undefined2 *)(param + 0x16) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0x15U & 0xffff),2); + *(undefined2 *)(param + 0x18) = auStack34[0]; + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void lld_pdu_llcp_con_param_rsp_unpk(uint16_t pdu_ptr,uint8_t parlen,uint8_t *param) + +{ + undefined2 in_register_0000202a; + int iVar1; + undefined2 auStack34 [2]; + uint16_t res; + + iVar1 = CONCAT22(in_register_0000202a,pdu_ptr); + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + iVar1,2); + *(undefined2 *)(param + 2) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 2U & 0xffff),2); + *(undefined2 *)(param + 4) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 4U & 0xffff),2); + *(undefined2 *)(param + 6) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 6U & 0xffff),2); + *(undefined2 *)(param + 8) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 8U & 0xffff),1); + param[10] = (uint8_t)auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 9U & 0xffff),2); + *(undefined2 *)(param + 0xc) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0xbU & 0xffff),2); + *(undefined2 *)(param + 0xe) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0xdU & 0xffff),2); + *(undefined2 *)(param + 0x10) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0xfU & 0xffff),2); + *(undefined2 *)(param + 0x12) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0x11U & 0xffff),2); + *(undefined2 *)(param + 0x14) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0x13U & 0xffff),2); + *(undefined2 *)(param + 0x16) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 0x15U & 0xffff),2); + *(undefined2 *)(param + 0x18) = auStack34[0]; + return; +} + + + +void lld_pdu_llcp_length_req_unpk(uint16_t pdu_ptr,uint8_t parlen,uint8_t *param) + +{ + undefined2 in_register_0000202a; + int iVar1; + undefined2 auStack34 [2]; + uint16_t res; + + iVar1 = CONCAT22(in_register_0000202a,pdu_ptr); + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + iVar1,2); + *(undefined2 *)(param + 2) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 2U & 0xffff),2); + *(undefined2 *)(param + 4) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 4U & 0xffff),2); + *(undefined2 *)(param + 6) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 6U & 0xffff),2); + *(undefined2 *)(param + 8) = auStack34[0]; + return; +} + + + +void lld_pdu_llcp_length_rsp_unpk(uint16_t pdu_ptr,uint8_t parlen,uint8_t *param) + +{ + undefined2 in_register_0000202a; + int iVar1; + undefined2 auStack34 [2]; + uint16_t res; + + iVar1 = CONCAT22(in_register_0000202a,pdu_ptr); + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + iVar1,2); + *(undefined2 *)(param + 2) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 2U & 0xffff),2); + *(undefined2 *)(param + 4) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 4U & 0xffff),2); + *(undefined2 *)(param + 6) = auStack34[0]; + (*ble_memcpy_ptr)(auStack34,&DAT_28008000 + (iVar1 + 6U & 0xffff),2); + *(undefined2 *)(param + 8) = auStack34[0]; + return; +} + + + +uint8_t lld_pdu_pack(uint8_t *p_data,uint8_t *p_length,char *format) + +{ + byte bVar1; + undefined2 uVar2; + uint8_t *puVar3; + uint8_t *puVar4; + uint uVar5; + uint uVar6; + undefined2 *puVar7; + undefined4 *puVar8; + undefined4 uVar9; + undefined4 *puVar10; + + puVar3 = p_data; + puVar8 = (undefined4 *)p_data; + while( true ) { + while( true ) { + while( true ) { + puVar10 = puVar8; + puVar4 = puVar3; + if (*format == 0) { + *p_length = (char)puVar4 - (char)p_data; + return '\0'; + } + uVar6 = (uint)(byte)*format - 0x30; + uVar5 = 0; + if ((uVar6 & 0xff) < 10) { + while( true ) { + uVar5 = uVar6 & 0xffff; + format = (char *)((byte *)format + 1); + if (9 < ((uint)(byte)*format - 0x30 & 0xff)) break; + uVar6 = uVar5 * 10 + -0x30 + (uint)(byte)*format; + } + } + bVar1 = *format; + format = (char *)((byte *)format + 1); + if (bVar1 != 0x48) break; + puVar7 = (undefined2 *)((uint)((int)puVar10 + 1) & 0xfffffffe); + uVar2 = *puVar7; + *puVar4 = (uint8_t)uVar2; + puVar4[1] = (uint8_t)((ushort)uVar2 >> 8); + puVar3 = puVar4 + 2; + puVar8 = (undefined4 *)(puVar7 + 1); + } + if (bVar1 != 0x4c) break; + puVar8 = (undefined4 *)((uint)((int)puVar10 + 3) & 0xfffffffc); + uVar9 = *puVar8; + *puVar4 = (uint8_t)uVar9; + puVar4[1] = (uint8_t)((uint)uVar9 >> 8); + puVar4[2] = (uint8_t)((uint)uVar9 >> 0x10); + puVar4[3] = (uint8_t)((uint)uVar9 >> 0x18); + puVar3 = puVar4 + 4; + puVar8 = puVar8 + 1; + } + if (bVar1 != 0x42) break; + *puVar4 = *(uint8_t *)puVar10; + puVar3 = puVar4 + 1; + puVar8 = (undefined4 *)((int)puVar10 + 1); + if (1 < uVar5) { + (*ble_memcpy_ptr)(puVar4 + 1,(undefined4 *)((int)puVar10 + 1),uVar5 - 1); + puVar3 = puVar4 + uVar5; + puVar8 = (undefined4 *)((int)puVar10 + uVar5); + } + } + return '\x01'; +} + + +/* +Unable to decompile 'lld_pdu_tx_flush_list' +Cause: Exception while decompiling 23011d9a: Decompiler process died + +*/ + + +void lld_pdu_cntl_aligned_unpk(uint16_t pdu_ptr,uint8_t parlen,uint8_t *param) + +{ + undefined2 in_register_0000202a; + undefined3 in_register_0000202d; + + if (CONCAT31(in_register_0000202d,parlen) != 0) { + // WARNING: Could not recover jumptable at 0x23011e28. Too many branches + // WARNING: Treating indirect jump as call + (*ble_memcpy_ptr)(param + 1,&DAT_28008000 + CONCAT22(in_register_0000202a,pdu_ptr), + CONCAT31(in_register_0000202d,parlen)); + return; + } + return; +} + + +/* +Unable to decompile 'lld_pdu_check' +Cause: Exception while decompiling 23011e2c: Decompiler process died + +*/ + +/* +Unable to decompile 'lld_pdu_tx_loop' +Cause: Exception while decompiling 23012008: Decompiler process died + +*/ + + +void lld_pdu_data_tx_push(lld_evt_tag *evt,em_desc_node *txnode,_Bool can_be_freed,_Bool encrypted) + +{ + undefined3 in_register_00002031; + undefined3 in_register_00002035; + int iVar1; + + iVar1 = (uint)*(byte *)&txnode->idx * 10; + *(undefined2 *)(&DAT_280082ca + iVar1) = 0; + if (CONCAT31(in_register_00002035,encrypted) != 0) { + txnode->length = txnode->length + '\x04'; + } + *(undefined2 *)(&DAT_280082cc + iVar1) = *(undefined2 *)&txnode->llid; + *(uint16_t *)(&DAT_280082ce + iVar1) = txnode->buffer_ptr; + if (CONCAT31(in_register_00002031,can_be_freed) != 0) { + *(uint16_t *)(&DAT_280082d2 + iVar1) = txnode->buffer_idx | 0x8000; + evt->evt[0x1c] = evt->evt[0x1c] + 1; + } + if (((evt->tx_prog).first == (co_list_hdr *)0x0) || + (*(uint16_t *)(&DAT_280082ca + (uint)*(ushort *)&(evt->tx_prog).last[1].next * 10) = + txnode->idx * 10 + 0x2ca | + *(ushort *)(&DAT_280082ca + (uint)*(ushort *)&(evt->tx_prog).last[1].next * 10) & 0x8000, + (evt->tx_prog).first == (co_list_hdr *)0x0)) { + *(em_desc_node **)&(evt->tx_prog).first = txnode; + } + else { + *(em_desc_node **)&((evt->tx_prog).last)->next = txnode; + } + *(em_desc_node **)&(evt->tx_prog).last = txnode; + (txnode->hdr).next = (co_list_hdr *)0x0; + return; +} + + +/* +Unable to decompile 'lld_pdu_data_send' +Cause: Exception while decompiling 23012106: Decompiler process died + +*/ + +/* +Unable to decompile 'lld_pdu_tx_push' +Cause: Exception while decompiling 23012172: Decompiler process died + +*/ + + +// WARNING: Type propagation algorithm not settling + +void lld_pdu_tx_prog(lld_evt_tag *param_1) + +{ + uint uVar1; + byte bVar2; + co_list_hdr list_hdr; + byte bVar3; + uint8_t opcode; + uint16_t uVar4; + undefined2 extraout_var_00; + em_desc_node *txnode; + undefined3 extraout_var; + _Bool encrypted; + co_list_hdr *pcVar5; + uint uVar6; + short sVar7; + ushort *puVar8; + int *piVar9; + uint uVar10; + uint uVar11; + uint uVar12; + co_list_hdr *p_data; + int iVar13; + uint uVar14; + uint uVar15; + byte abStack65 [13]; + + list_hdr = (co_list_hdr)(param_1->tx_llcp_pdu_rdy).first; + uVar12 = (uint)param_1->conhdl; + if ((list_hdr != (co_list_hdr)0x0) && (*(short *)(&DAT_280082ca + uVar12 * 10) < 0)) { + bVar2 = llc_env[uVar12]->encryption_state; + if ((bVar2 & 4) == 0) { +LAB_2301240a: + ble_co_list_extract(¶m_1->tx_llcp_pdu_rdy,(co_list_hdr *)list_hdr,'\0'); + p_data = ((co_list_hdr *)list_hdr)[2].next; + if (((char *)lld_pdu_llcp_pk_desc_tab[*(byte *)&p_data->next].pack_fmt != (char *)0x0) && + (opcode = lld_pdu_pack((uint8_t *)p_data,abStack65, + (char *)lld_pdu_llcp_pk_desc_tab[*(byte *)&p_data->next].pack_fmt), + CONCAT31(extraout_var,opcode) == 0)) { + (*ble_memcpy_ptr)(&DAT_28008000 + + *(ushort *) + (&DAT_280082ce + (uint)*(ushort *)&((co_list_hdr *)list_hdr)[1].next * 10 + ),p_data,(uint)abStack65[0]); + ble_ke_free(((co_list_hdr *)list_hdr)[2].next); + if ((llc_env[uVar12]->encryption_state & 1) != 0) { + abStack65[0] = abStack65[0] + 4; + } + puVar8 = (ushort *)(&DAT_280082cc + uVar12 * 10); + *puVar8 = (ushort)abStack65[0] << 8 | *puVar8 & 0xff; + *puVar8 = *puVar8 & 0xfffc | 3; + *(undefined2 *)(&DAT_280082ca + (uint)param_1->conhdl * 10) = 0; + if ((param_1->tx_prog).first != (co_list_hdr *)0x0) { + *(ushort *)(&DAT_280082ca + (uint)*(ushort *)&(param_1->tx_prog).last[1].next * 10) = + *(short *)&((co_list_hdr *)list_hdr)[1].next * 10 + 0x2caU | + *(ushort *)(&DAT_280082ca + (uint)*(ushort *)&(param_1->tx_prog).last[1].next * 10) & + 0x8000; + } + ble_co_list_push_back(¶m_1->tx_prog,list_hdr); + param_1->evt[0x1c] = param_1->evt[0x1c] + 1; + } + } + else { + do { + opcode = *(uint8_t *)&((co_list_hdr *)((int)list_hdr + 0xc))->next; + if ((bVar2 & 0x20) == 0) { + bVar3 = llc_llcp_get_autorize(opcode); + bVar3 = bVar3 & 1; + } + else { + bVar3 = llc_llcp_get_autorize(opcode); + bVar3 = bVar3 & 2; + } + if (bVar3 != 0) goto LAB_2301240a; + list_hdr = *(co_list_hdr *)list_hdr; + } while (list_hdr != (co_list_hdr)0x0); + } + } + bVar2 = 1; + if (param_1->conhdl < 2) { + bVar2 = (llc_env[uVar12]->encryption_state >> 2 ^ 1) & 1; + } + if (((param_1->tx_acl_rdy).first != (co_list_hdr *)0x0) && (bVar2 != 0)) { + if (param_1->conhdl < 2) { + uVar4 = ble_co_list_size((co_list *)&em_buf_env); + uVar11 = CONCAT22(extraout_var_00,uVar4); + p_data = (param_1->tx_acl_rdy).first; + if (p_data != (co_list_hdr *)0x0) { + bVar3 = llc_env[param_1->conhdl]->encryption_state; + pcVar5 = p_data->next; + (param_1->tx_acl_rdy).first = pcVar5; + if (pcVar5 == (co_list_hdr *)0x0) { + (param_1->tx_acl_rdy).last = (co_list_hdr *)0x0; + } + encrypted = (_Bool)(bVar3 & 1); + uVar1 = (uint)bVar3 & 1; + uVar10 = 0; + while( true ) { + iVar13 = (int)*(short *)&p_data[2].next; + uVar14 = (uint)*(ushort *)(param_1->evt + 0x16) & 0xff; + if ((uint)*(ushort *)(param_1->evt + 0x14) < + (iVar13 + 10 + ((uVar1 << 0x12) >> 0x10)) * 0x80000 >> 0x10) { + uVar6 = (int)((uint)*(ushort *)(param_1->evt + 0x14) + uVar1 * -0x20 + -0x50) >> 3; + if ((int)((uint)*(ushort *)(param_1->evt + 0x16) + uVar1 * -4) < (int)(uVar6 & 0xff)) { + uVar14 = uVar14 + uVar1 * -4 & 0xff; + } + else { + uVar14 = uVar6 & 0xff; + } + } + if ((int)uVar14 < iVar13) { + uVar14 = uVar14 & 0xfe; + } + uVar6 = (iVar13 + -1) / (int)uVar14 + 1U & 0xff; + if (uVar11 < uVar6) { + pcVar5 = (param_1->tx_acl_rdy).first; + if (pcVar5 == (co_list_hdr *)0x0) { + (param_1->tx_acl_rdy).last = p_data; + } + p_data->next = pcVar5; + (param_1->tx_acl_rdy).first = p_data; + goto LAB_23012556; + } + uVar4 = 0; + uVar15 = 0; + bVar3 = bVar2; + while( true ) { + txnode = (em_desc_node *)ble_co_list_pop_front((co_list *)&em_buf_env); + if (bVar3 == 0) { + txnode->llid = '\x01'; + uVar15 = uVar14 + uVar15 & 0xffff; + } + else { + bVar3 = *(byte *)((int)&p_data[2].next + 2) & 3; + if (bVar3 != 1) { + bVar3 = 2; + } + txnode->llid = bVar3; + uVar15 = (uint)*(ushort *)((int)&p_data[3].next[1].next + 2); + uVar4 = *(uint16_t *)&p_data[3].next[1].next; + } + opcode = (uint8_t)uVar14; + if (iVar13 <= (int)uVar14) { + opcode = (uint8_t)iVar13; + } + txnode->length = opcode; + txnode->buffer_idx = uVar4; + txnode->buffer_ptr = (uint16_t)uVar15; + iVar13 = (int)((iVar13 - uVar14) * 0x10000) >> 0x10; + if (iVar13 < 1) break; + lld_pdu_data_tx_push(param_1,txnode,false,encrypted); + bVar3 = 0; + } + lld_pdu_data_tx_push(param_1,txnode,true,encrypted); + uVar10 = uVar10 + uVar6 & 0xff; + uVar11 = uVar11 - uVar6 & 0xffff; + if ((param_1->tx_acl_tofree).first == (co_list_hdr *)0x0) { + (param_1->tx_acl_tofree).first = p_data; + } + else { + ((param_1->tx_acl_tofree).last)->next = p_data; + } + (param_1->tx_acl_tofree).last = p_data; + p_data->next = (co_list_hdr *)0x0; + if (10 < uVar10) goto LAB_23012556; + p_data = (param_1->tx_acl_rdy).first; + if (p_data == (co_list_hdr *)0x0) break; + pcVar5 = p_data->next; + (param_1->tx_acl_rdy).first = pcVar5; + if (pcVar5 == (co_list_hdr *)0x0) { + (param_1->tx_acl_rdy).last = (co_list_hdr *)0x0; + } + } + } + } + else { + ble_co_list_merge(¶m_1->tx_prog,¶m_1->tx_acl_rdy); + } + ble_co_list_init(¶m_1->tx_acl_rdy); + } +LAB_23012556: + piVar9 = (int *)(param_1->tx_prog).first; + puVar8 = (ushort *)(uVar12 * 0x5c + 0x2800808e); + if (piVar9 == (int *)0x0) { + *puVar8 = *puVar8 & 0x1f | 0xf000; + sVar7 = 0; + } + else { + do { + if (-1 < *(short *)(&DAT_280082ca + (uint)*(ushort *)(piVar9 + 1) * 10)) { + sVar7 = *(ushort *)(piVar9 + 1) * 10 + 0x2ca; + goto LAB_23012594; + } + piVar9 = (int *)*piVar9; + } while (piVar9 != (int *)0x0); + sVar7 = 0; +LAB_23012594: + *puVar8 = *puVar8 & 0x1f | 0xf600; + } + *(short *)(uVar12 * 0x5c + 0x280080a4) = sVar7; + return; +} + + +/* +Unable to decompile 'lld_pdu_tx_flush' +Cause: Exception while decompiling 23012648: Decompiler process died + +*/ + + +uint8_t lld_pdu_adv_pack(uint8_t code,uint8_t *buf,uint8_t *p_len) + +{ + uint8_t uVar1; + undefined3 in_register_00002029; + + if ((char *)lld_pdu_adv_pk_desc_tab[CONCAT31(in_register_00002029,code)].pack_fmt != (char *)0x0) + { + uVar1 = lld_pdu_pack(buf,p_len, + (char *)lld_pdu_adv_pk_desc_tab[CONCAT31(in_register_00002029,code)]. + pack_fmt); + return uVar1; + } + return '\x02'; +} + + + +void lld_pdu_rx_handler(lld_evt_tag *evt,uint8_t nb_rx_desc) + +{ + uint8_t uVar1; + ushort uVar2; + ushort uVar3; + void *pvVar4; + byte *pbVar5; + undefined2 *puVar6; + ushort dest_id; + uint uVar7; + byte bVar8; + int iVar9; + llcp_pdu_unpk_func_t *plVar10; + uint8_t hdl; + uint uVar11; + byte *pbVar12; + + uVar11 = (uint)em_buf_env.rx_current; + do { + nb_rx_desc = nb_rx_desc + -1; + hdl = (uint8_t)uVar11; + if (nb_rx_desc == -1) { + em_buf_env.rx_current = hdl; + return; + } + if ((evt->evt_flag & 0x10) == 0) { + pvVar4 = ble_ke_malloc(0x10,'\0'); + iVar9 = uVar11 * 0xe; + dest_id = *(ushort *)(&DAT_280083d2 + iVar9); + *(uint8_t *)((int)pvVar4 + 4) = hdl; + *(uint16_t *)((int)pvVar4 + 6) = evt->conhdl; + uVar2 = *(ushort *)(iVar9 + 0x280083d0); + *(ushort *)((int)pvVar4 + 8) = uVar2; + uVar3 = *(ushort *)(iVar9 + 0x280083d4); + *(undefined *)((int)pvVar4 + 5) = 0; + *(byte *)((int)pvVar4 + 0xd) = (byte)(uVar3 >> 0xf); + *(byte *)((int)pvVar4 + 0xb) = (byte)((uint)uVar3 >> 8) & 0x3f; + *(undefined *)((int)pvVar4 + 0xc) = (char)uVar3; + if (((evt->evt_flag & 1) != 0) && ((uVar2 & 0x40) == 0)) { + evt->evt_flag = evt->evt_flag & 0xfe; + } + if (1 < (ushort)(*(short *)((int)pvVar4 + 6) - 2U)) { + *(undefined *)((int)pvVar4 + 10) = (char)((uint)dest_id >> 8); + if (((evt->evt_flag & 2) != 0) && ((*(ushort *)((int)pvVar4 + 8) & 1) == 0)) { + evt->evt_flag = evt->evt_flag & 0xfd; + llc_env[*(ushort *)((int)pvVar4 + 6)]->llc_status = + llc_env[*(ushort *)((int)pvVar4 + 6)]->llc_status | 0x100; + } + if (((*(ushort *)((int)pvVar4 + 8) & 0x13f) == 0) && (*(char *)((int)pvVar4 + 10) != '\0')) + { + uVar2 = *(ushort *)((int)pvVar4 + 6); + uVar7 = (uint)dest_id & 3; + if ((llc_env[(uint)uVar2]->encryption_state & 2) != 0) { + *(char *)((int)pvVar4 + 10) = *(char *)((int)pvVar4 + 10) + -4; + } + if ((dest_id & 3) != 0) { + if (uVar7 < 3) { + dest_id = uVar2 << 8 | 1; + puVar6 = (undefined2 *)ble_ke_msg_alloc(0x100,dest_id,dest_id,8); + *puVar6 = *(undefined2 *)((int)pvVar4 + 6); + bVar8 = *(byte *)((int)pvVar4 + 10); + *(char *)(puVar6 + 1) = (char)uVar7; + puVar6[2] = (ushort)bVar8; + *(undefined *)(puVar6 + 3) = *(undefined *)((int)pvVar4 + 4); + ble_ke_msg_send(); + goto LAB_23012960; + } + if (uVar7 != 3) goto LAB_230128e6; + uVar7 = (uint)uVar2 << 8; + dest_id = (ushort)uVar7 | 1; + hdl = *(uint8_t *)((int)pvVar4 + 10); + pbVar5 = (byte *)ble_ke_msg_alloc(0x10a,dest_id,dest_id,0x1c); + pbVar12 = pbVar5 + 2; + dest_id = *(ushort *)(&DAT_280083d6 + (uint)*(byte *)((int)pvVar4 + 4) * 0xe); + (*ble_memcpy_ptr)(pbVar12,&DAT_28008000 + dest_id,1); + bVar8 = pbVar5[2]; + if (bVar8 < 0x16) { + uVar1 = lld_pdu_llcp_pk_desc_tab[bVar8].pdu_len; + if (uVar1 != hdl) { + bVar8 = 0x1e; + goto LAB_230128ce; + } + plVar10 = lld_pdu_llcp_pk_desc_tab[bVar8].unpack_func; + *pbVar5 = 0; + (*plVar10)(dest_id + 1,uVar1 + -1,pbVar12); + } + else { + bVar8 = 0x19; +LAB_230128ce: + *pbVar5 = bVar8; + } + llc_llcp_recv_handler(uVar7 & 0xffff | 1,(uint)*pbVar5,pbVar12,1); + ble_ke_msg_send(pbVar5); + } + } +LAB_230128e6: + em_buf_rx_free(*(uint8_t *)((int)pvVar4 + 4)); + *(undefined *)((int)pvVar4 + 5) = 1; + } +LAB_23012960: + ble_co_list_push_back(0x4201a340,pvVar4); + } + else { + em_buf_rx_free(hdl); + } + uVar11 = uVar11 + 1 & 7; + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_sleep_init(void) + +{ + uint32_t uVar1; + uint32_t uVar2; + uint32_t uVar3; + + (*ble_memset_ptr)(&lld_sleep_env,0,0x14); + uVar1 = rwip_us_2_lpcycles(5000); + uVar2 = rwip_us_2_lpcycles(5000); + uVar3 = rwip_us_2_lpcycles(0x271); + _DAT_2800003c = uVar3 & 0xffff | uVar1 << 0x15 | (uVar2 & 0xffff) << 10; + rwip_wakeup_delay_set(5000); + _DAT_28000030 = _DAT_28000030 & 0x7fffffff; + lld_sleep_env.last_sleep_dur = 0; + lld_sleep_env._8_2_ = 0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_sleep_wakeup(void) + +{ + uint32_t uVar1; + uint32_t lpcycles; + + _DAT_28000030 = _DAT_28000030 & 0x7fffffff; + if (lld_sleep_env.pds_reset == false) { + lpcycles = _DAT_28000038; + uVar1 = _DAT_28000038; + if (lld_sleep_env.sw_wakeup != false) { + lld_sleep_env._8_2_ = 0; + lpcycles = _DAT_28000038 - lld_sleep_env.last_sleep_dur; + uVar1 = lld_sleep_env.last_sleep_dur; + } + lld_sleep_env.last_sleep_dur = uVar1; + lpcycles = rwip_sleep_lpcycles_2_us(lpcycles); + _DAT_28000044 = (lpcycles + lld_evt_env.hw_wa_sleep_compensation) / 0x271; + _DAT_28000040 = + (_DAT_28000044 * 0x271 - (lpcycles + lld_evt_env.hw_wa_sleep_compensation)) + 0x270 & + 0xffff; + lld_evt_env.hw_wa_sleep_compensation = _DAT_28000040 == 0; + if ((bool)lld_evt_env.hw_wa_sleep_compensation) { + _DAT_28000044 = _DAT_28000044 + 1; + _DAT_28000040 = 0x270; + } + _DAT_2800000c = 1; + _DAT_28000018 = 1; + _DAT_28000030 = _DAT_28000030 | 8; + return; + } + _DAT_2800000c = 1; + _DAT_28000018 = 1; + _DAT_28000030 = _DAT_28000030 | 8; + _DAT_28000040 = lld_sleep_env.finetimecnt; + _DAT_28000044 = lld_sleep_env.basetimecnt; + lld_sleep_env._8_2_ = 0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_sleep_wakeup_end(void) + +{ + _DAT_2800000c = lld_sleep_env.irq_mask; + return; +} + + + +uint16_t lld_util_instant_get(void *event,uint8_t action) + +{ + uint16_t uVar1; + + *(uint8_t *)((int)event + 0x45) = action; + uVar1 = (uint16_t) + (((uint)*(ushort *)((int)event + 0x36) * 6 + (uint)*(ushort *)((int)event + 0x38)) * + 0x10000 >> 0x10); + *(uint16_t *)((int)event + 0x34) = uVar1; + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_util_set_bd_address(bd_addr *bd_addr,uint8_t type) + +{ + undefined3 in_register_0000202d; + + _DAT_28000024 = *(undefined4 *)bd_addr->addr; + _DAT_28000028 = + (uint)*(ushort *)(bd_addr->addr + 4) | _DAT_28000028 & 0xfffe0000 | + CONCAT31(in_register_0000202d,type) << 0x10; + return; +} + + + +uint8_t lld_util_freq2chnl(uint8_t freq) + +{ + char cVar1; + undefined3 in_register_00002029; + uint uVar2; + + uVar2 = CONCAT31(in_register_00002029,freq); + if (uVar2 == 0xc) { + return '&'; + } + if (uVar2 != 0x27) { + if (uVar2 != 0) { + if (uVar2 < 0xc) { + cVar1 = -1; + } + else { + cVar1 = -2; + } + return freq + cVar1; + } + freq = '%'; + } + return freq; +} + + + +uint16_t lld_util_get_local_offset(uint16_t PeerOffset,uint16_t Interval,uint32_t AnchorPoint) + +{ + undefined2 in_register_0000202a; + undefined2 in_register_0000202e; + + return (uint16_t) + ((int)(CONCAT22(in_register_0000202a,PeerOffset) + + AnchorPoint % CONCAT22(in_register_0000202e,Interval)) % + CONCAT22(in_register_0000202e,Interval)); +} + + + +uint16_t lld_util_get_peer_offset(uint16_t LocalOffset,uint16_t Interval,uint32_t AnchorPoint) + +{ + undefined2 in_register_0000202a; + undefined2 in_register_0000202e; + uint uVar1; + + uVar1 = CONCAT22(in_register_0000202e,Interval); + return (uint16_t) + ((int)((CONCAT22(in_register_0000202a,LocalOffset) + uVar1) - AnchorPoint % uVar1) % uVar1) + ; +} + + + +void lld_util_connection_param_set(ea_elt_tag *elt,ea_param_output *param) + +{ + ushort uVar1; + uint uVar2; + ushort uVar3; + + uVar3 = param->interval; + uVar2 = (uint)uVar3 - (uint)elt->start_latency; + if (uVar2 < param->duration) { + param->duration = uVar2; + } + if (param->duration == 0) { + param->duration = 2; + } + uVar1 = param->offset; + param->duration = param->duration * 0x271; + uVar2 = elt->timestamp % (uint)uVar3; + if (uVar1 < uVar2) { + uVar3 = (uVar3 + uVar1) - (short)uVar2; + } + else { + if ((uVar2 != 0) || (uVar1 != 0)) { + uVar3 = uVar1 - (short)uVar2; + } + } + param->offset = uVar3; + return; +} + + + +void lld_util_dle_set_cs_fields(uint16_t conhdl) + +{ + undefined2 in_register_0000202a; + int iVar1; + + iVar1 = CONCAT22(in_register_0000202a,conhdl) * 0x5c; + *(ushort *)(&DAT_280080b0 + iVar1) = + *(ushort *)(&DAT_280080b0 + iVar1) & 0xff00 | + (ushort)*(byte *)&(llc_env[CONCAT22(in_register_0000202a,conhdl)]->data_len_ext_info). + conn_eff_max_rx_octets; + *(uint16_t *)(iVar1 + 0x280080b2) = + (llc_env[CONCAT22(in_register_0000202a,conhdl)]->data_len_ext_info).conn_eff_max_rx_time; + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void lld_util_anchor_point_move(ea_elt_tag *elt_connect) + +{ + short sVar1; + undefined2 uVar2; + ushort uVar3; + uint8_t uVar4; + undefined3 extraout_var; + undefined *puVar5; + uint uVar6; + ushort uStack52; + ea_param_output set_param; + ea_param_input input_param; + + set_param.duration._0_2_ = 0; + uStack52 = *(ushort *)&elt_connect[2].ea_cb_stop; + set_param._0_4_ = (int)((uint)elt_connect->duration_min + 0x270) / 0x271; + uVar4 = ea_offset_req((ea_param_input *)&set_param.offset,(ea_param_output *)&uStack52); + if (CONCAT31(extraout_var,uVar4) == 0) { + puVar5 = (undefined *) + ble_ke_msg_alloc(0x109,*(short *)&elt_connect[2].ea_cb_start << 8 | 1,2,0x22); + *puVar5 = 1; + uVar6 = (uint)uStack52; + uVar3 = uStack52 >> 1; + *(ushort *)(puVar5 + 2) = uVar3; + *(ushort *)(puVar5 + 4) = uVar3; + *(ushort *)(puVar5 + 0xe) = uVar3; + *(ushort *)(puVar5 + 0x10) = uVar3; + sVar1 = *(short *)((int)&elt_connect[2].linked_element + 2); + puVar5[0x12] = 0; + *(short *)(puVar5 + 6) = sVar1 + -1; + *(undefined2 *)(puVar5 + 8) = 3000; + uVar2 = *(undefined2 *)&elt_connect[2].timestamp; + *(undefined2 *)(puVar5 + 0x14) = uVar2; + *(undefined2 *)(puVar5 + 10) = uVar2; + *(undefined2 *)(puVar5 + 0xc) = *(undefined2 *)&elt_connect[2].timestamp; + *(short *)(puVar5 + 0x16) = + (short)(((int)(((ushort)set_param.duration + uVar6) - elt_connect->timestamp % uVar6) % + uVar6 & 0xffffU) >> 1); + *(undefined2 *)(puVar5 + 0x18) = 0xffff; + *(undefined2 *)(puVar5 + 0x1a) = 0xffff; + *(undefined2 *)(puVar5 + 0x1c) = 0xffff; + *(undefined2 *)(puVar5 + 0x1e) = 0xffff; + *(undefined2 *)(puVar5 + 0x20) = 0xffff; + ble_ke_msg_send(); + } + return; +} + + + +void lld_util_flush_list(co_list *list) + +{ + co_list_hdr *mem_ptr; + + while (mem_ptr = ble_co_list_pop_front(list), mem_ptr != (co_list_hdr *)0x0) { + ble_ke_free(mem_ptr); + } + return; +} + + + +_Bool lld_util_instant_ongoing(ea_elt_tag *elt) + +{ + return (_Bool)(*(char *)((int)&elt[2].delay + 1) != '\0'); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_util_compute_ce_max(ea_elt_tag *elt,uint16_t tx_time,uint16_t rx_time) + +{ + undefined2 in_register_0000202e; + int iVar1; + uint uVar2; + int iVar3; + ushort *puVar4; + uint uVar5; + + iVar1 = (uint)*(ushort *)&elt[2].ea_cb_start * 0x5c; + if (*(char *)((int)&elt[2].ea_cb_stop + 3) == '\x03') { + uVar2 = _DAT_28000000 >> 4 & 0xf; + } + else { + uVar2 = (uint)*(ushort *)(iVar1 + 0x280080a2); + if ((short)*(ushort *)(iVar1 + 0x280080a2) < 0) { + iVar3 = ((uVar2 << 0x11) >> 0x12) * 0x271; + goto LAB_23012da6; + } + } + iVar3 = (int)uVar2 >> 1; +LAB_23012da6: + uVar2 = CONCAT22(in_register_0000202e,tx_time) + 0x15c; + if ((*(ushort *)(iVar1 + 0x28008092) & 0x200) != 0) { + uVar2 = CONCAT22(in_register_0000202e,tx_time) + 0x17c; + } + uVar5 = ((((((uint)*(ushort *)&elt[2].ea_cb_stop - (uint)elt->start_latency) + -1) * 0x271 - iVar3 + ) / uVar2) * uVar2 - (uVar2 >> 1)) / 0x271; + if (0x96 < (int)((uVar2 - 0x271) * uVar5)) { + uVar5 = uVar5 - 1; + } + *(ushort *)(iVar1 + 0x280080a8) = (ushort)uVar5; + puVar4 = (ushort *)((uint)*(ushort *)&elt[2].ea_cb_start * 0x5c + 0x280080a6); + if (uVar5 < *puVar4) { + *puVar4 = (ushort)uVar5; + } + return; +} + + + +void lld_util_priority_set(ea_elt_tag *elt,uint8_t priority_index) + +{ + undefined3 in_register_0000202d; + uint8_t uVar1; + + switch(CONCAT31(in_register_0000202d,priority_index)) { + case 0: + uVar1 = '\x05'; + break; + case 1: + uVar1 = '\x05'; + break; + case 2: + uVar1 = '\x14'; + break; + case 3: + uVar1 = '\n'; + break; + case 4: + uVar1 = '\x0f'; + break; + case 5: + if ((llm_le_env.advertising_params)->adv_ldc_flag != false) goto switchD_23012e2e_caseD_7; + case 6: + uVar1 = '\n'; + break; + default: +switchD_23012e2e_caseD_7: + uVar1 = '\x05'; + } + elt->current_prio = uVar1; + *(uint8_t *)((int)&elt[2].ea_cb_cancel + 1) = uVar1; + return; +} + + + +uint8_t lld_util_get_tx_pkt_cnt(ea_elt_tag *elt) + +{ + return elt[2].stop_latency2; +} + + + +void lld_util_eff_tx_time_set(ea_elt_tag *elt,uint16_t max_tx_time,uint16_t max_tx_size) + +{ + elt[2].asap_settings = max_tx_time; + elt[2].duration_min = max_tx_size; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_wlcoex_set(int param_1) + +{ + if (param_1 == 0) { + _DAT_28000100 = _DAT_28000100 & 0xffddff0c; + } + else { + _DAT_28000100 = _DAT_28000100 | 0x2200f3; + } + _DAT_28000074 = _DAT_28000074 & 0xffe0ffff; + return; +} + + + +// WARNING: Could not reconcile some variable overlaps +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_init(_Bool reset) + +{ + _Bool _Var1; + undefined3 in_register_00002029; + undefined3 extraout_var; + bd_addr *pbVar2; + anon_subr_void_ptr_void_ptr_void_ptr_uint *paVar3; + undefined2 *puVar4; + undefined4 uStack24; + bd_addr bd_addr; + + if (CONCAT31(in_register_00002029,reset) == 0) { + ble_ke_task_create('\x02',&TASK_DESC_LLD); + } + _DAT_280000f0 = _DAT_280000f0 & 0xfc00fe00 | 0x1b800d2; + _DAT_2800000c = 0x1033a; + _DAT_28000000 = _DAT_28000000 & 0xffcfff0f | 0xe0; + _Var1 = co_bdaddr_compare(&co_null_bdaddr,&co_default_bdaddr); + if (CONCAT31(extraout_var,_Var1) == 0) { + pbVar2 = &co_default_bdaddr; + paVar3 = ble_memcpy_ptr; + } + else { + pbVar2 = (bd_addr *)0x7; + paVar3 = (anon_subr_void_ptr_void_ptr_void_ptr_uint *)ble_memset_ptr; + } + (*paVar3)(&uStack24,pbVar2,6); + ecc_gen_new_secret_key(llm_le_env.secret_key256,false); + _DAT_28000024 = uStack24; + _DAT_28000028 = (uint)bd_addr.addr._0_2_; + _DAT_28000000 = _DAT_28000000 | 0x200; + _DAT_28000090 = 7; + _DAT_280000b0 = 0x1fe; + _DAT_280000b4 = 0x216; + _DAT_280000b8 = 0x404; + _DAT_28000120 = 0x22e; + _DAT_28000124 = 3; + puVar4 = (undefined2 *)&DAT_28008000; + _DAT_2800814c = 0xbed6; + _DAT_2800814e = 0x8e89; + _DAT_28008150 = 0x5555; + _DAT_28008152 = 0x55; + _DAT_28008162 = 0; + _DAT_28008164 = 0; + _DAT_28008166 = 0; + _DAT_280081a8 = 0xbed6; + _DAT_280081aa = 0x8e89; + _DAT_280081ac = 0x5555; + _DAT_280081ae = 0x55; + _DAT_280081be = 0; + _DAT_280081c0 = 0; + _DAT_280081c2 = 0; + _DAT_28008168 = 0; + _DAT_2800816a = 0; + _DAT_280081c4 = 0; + _DAT_280081c6 = 0; + _DAT_2800002c = 0x3ce; + _DAT_28008158 = (ushort)rwip_rf.txpwr_max; + _DAT_2800814a = _DAT_2800814a & 0xfff | 0x2000; + _DAT_2800819e = _DAT_2800819e & 0xff7f; + _DAT_28008154 = 0; + _DAT_280081b4 = (ushort)rwip_rf.txpwr_max; + _DAT_280081a6 = _DAT_280081a6 & 0xfff | 0x2000; + _DAT_280081fa = _DAT_280081fa & 0xff7f; + _DAT_280081b0 = 0; + _DAT_28008194 = 0; + _DAT_28008196 = 0; + _DAT_28008198 = 0; + _DAT_2800819a = 0; + _DAT_2800819c = 0; + _DAT_280081f0 = 0; + _DAT_280081f2 = 0; + _DAT_280081f4 = 0; + _DAT_280081f6 = 0; + _DAT_280081f8 = 0; + do { + *puVar4 = 0; + puVar4[1] = 0; + puVar4 = puVar4 + 2; + } while (puVar4 != (undefined2 *)0x28008040); + lld_evt_init(CONCAT31(in_register_00002029,reset)); + lld_sleep_init(); + _DAT_28008146 = _DAT_28008146 & 0xf8ff; + _DAT_280081a2 = _DAT_280081a2 & 0xf8ff; + lld_wlcoex_set(1); + _DAT_28000000 = _DAT_28000000 | 0x100; + _DAT_280000e0 = _DAT_280000e0 & 0xffffefff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_core_reset(void) + +{ + undefined2 *puVar1; + + do { + } while ((int)(_DAT_28000000 & 0xfffffeff | 0x80000000) < 0); + _DAT_28000000 = _DAT_28000000 & 0xbffffeff | 0xc0000000; + do { + } while ((int)(_DAT_28000000 << 1) < 0); + puVar1 = (undefined2 *)&DAT_28008000; + do { + *puVar1 = 0; + puVar1[1] = 0; + puVar1 = puVar1 + 2; + } while (puVar1 != (undefined2 *)0x28008040); + _DAT_28008146 = _DAT_28008146 & 0xf8ff; + _DAT_280081a2 = _DAT_280081a2 & 0xf8ff; + lld_wlcoex_set(1); + _DAT_2800000c = 0; + _DAT_28000018 = 0xffffffff; + return; +} + + +/* +Unable to decompile 'lld_adv_start' +Cause: Exception while decompiling 23013272: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_adv_stop(ea_elt_tag *elt) + +{ + _Bool _Var1; + undefined3 extraout_var; + + _Var1 = lld_evt_elt_delete(elt,true,true); + if (CONCAT31(extraout_var,_Var1) == 0) { + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = *(byte *)((int)&elt[2].ea_cb_cancel + 2) | 0x10; + _DAT_28000000 = _DAT_28000000 | 0x2000000; + } + return; +} + + +/* +Unable to decompile 'lld_scan_start' +Cause: Exception while decompiling 23013462: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_scan_stop(ea_elt_tag *elt) + +{ + _Bool _Var1; + undefined3 extraout_var; + + _Var1 = lld_evt_elt_delete(elt,true,true); + if (CONCAT31(extraout_var,_Var1) == 0) { + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = *(byte *)((int)&elt[2].ea_cb_cancel + 2) | 0x10; + _DAT_28000000 = _DAT_28000000 | 0x1000000; + } + return; +} + + +/* +Unable to decompile 'lld_con_start' +Cause: Exception while decompiling 2301360e: Decompiler process died + +*/ + + +ea_elt_tag * +lld_move_to_master(ea_elt_tag *elt,uint16_t conhdl,llc_create_con_req_ind *param,uint8_t rx_hdl) + +{ + int iVar1; + ea_elt_tag *elt_00; + undefined2 in_register_0000202e; + undefined3 in_register_00002035; + ushort *puVar2; + + elt_00 = lld_evt_move_to_master(elt,conhdl,param,rx_hdl); + iVar1 = CONCAT22(in_register_0000202e,conhdl) * 0x5c; + *(ushort *)(&DAT_2800809e + iVar1) = + (ushort)(((uint)(*(ushort *)(&DAT_280083d2 + CONCAT31(in_register_00002035,rx_hdl) * 0xe) >> + 5) & 1) << 0xe) | *(ushort *)(&DAT_2800809e + iVar1) & 0xbfff; + lld_util_eff_tx_time_set(elt_00,0x148,0x1b); + lld_util_compute_ce_max(elt_00,0x148,0x148); + *(undefined2 *)(iVar1 + 0x280080a6) = *(undefined2 *)(iVar1 + 0x280080a8); + *(ushort *)(&DAT_280082ca + CONCAT22(in_register_0000202e,conhdl) * 10) = + (ushort)(((uint)*(ushort *)(&DAT_280082ca + CONCAT22(in_register_0000202e,conhdl) * 10) << + 0x11) >> 0x11) | 0x8000; + puVar2 = (ushort *)(iVar1 + 0x28008092); + *puVar2 = *puVar2 & 0xfeff; + *puVar2 = *puVar2 & 0xfdff; + *puVar2 = *puVar2 & 0xfbff; + *(undefined2 *)(iVar1 + 0x2800809c) = 0; + *(undefined2 *)(iVar1 + 0x280080cc) = 0; + *(undefined2 *)(iVar1 + 0x280080ce) = 0; + *(undefined2 *)(iVar1 + 0x280080d0) = 0; + *(undefined2 *)(iVar1 + 0x280080d2) = 0; + *(undefined2 *)(iVar1 + 0x280080d4) = 0; + *(undefined2 *)(iVar1 + 0x280080d6) = 0; + *(undefined2 *)(iVar1 + 0x280080d8) = 0; + *(undefined2 *)(iVar1 + 0x280080a4) = 0; + *puVar2 = *puVar2 & 0xf7ff; + lld_evt_elt_insert(elt_00,true); + return elt_00; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void lld_con_update_req(ea_elt_tag *elt_old,llc_con_upd_req_ind *param,llcp_con_upd_ind *param_pdu) + +{ + ea_elt_tag *peVar1; + uint16_t ce_len; + uint16_t uStack24; + uint16_t uStack22; + lld_evt_update_tag upd_par; + + _ce_len = (uint)param->ce_len_min + 1 & 0xfffffffe; + ce_len = (uint16_t)_ce_len; + if (_ce_len < 2) { + ce_len = 2; + } + peVar1 = lld_evt_update_create + (elt_old,ce_len,(uint16_t)(((uint)param->interval_min << 0x11) >> 0x10), + (uint16_t)(((uint)param->interval_max << 0x11) >> 0x10),param->con_latency, + param->pref_period,(lld_evt_update_tag *)&uStack24); + param_pdu->timeout = param->superv_to; + param_pdu->interv = *(ushort *)&peVar1[2].ea_cb_stop >> 1; + param_pdu->latency = param->con_latency; + param_pdu->win_size = (uint8_t)upd_par.win_offset; + param_pdu->win_off = uStack24; + param_pdu->instant = uStack22; + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +uint8_t lld_con_update_after_param_req + (uint16_t conhdl,ea_elt_tag *elt_old,llc_con_upd_req_ind *param, + llcp_con_upd_ind *param_pdu,_Bool bypass_offchk) + +{ + ushort uVar1; + int iVar2; + uint8_t uVar3; + uint16_t uVar4; + undefined2 in_register_0000202a; + ea_elt_tag *elt; + undefined2 extraout_var_01; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint uVar5; + undefined3 in_register_00002039; + uint uVar6; + uint uVar7; + uint uVar8; + uint uVar9; + llc_env_tag *plVar10; + uint16_t uVar11; + uint uVar12; + uint uVar13; + uint16_t local_54; + ea_param_output set_param; + ea_param_input input_param; + + set_param.offset = param->interval_min << 1; + set_param._10_2_ = param->interval_max << 1; + uVar4 = param->offset0; + ea_interval_duration_req((ea_param_input *)&set_param.offset,(ea_param_output *)&local_54); + if (param->offset0 != 0xffff) { + uVar6 = (uint)*(ushort *)&elt_old[2].timestamp; + uVar8 = (uint)param->ref_con_event_count; + if (uVar8 < uVar6) { + iVar2 = -((uVar6 - uVar8) * (uint)*(ushort *)&elt_old[2].ea_cb_stop); + } + else { + iVar2 = (uVar8 - uVar6) * (uint)*(ushort *)&elt_old[2].ea_cb_stop; + } + lld_util_get_local_offset + ((uint16_t)(((uint)param->offset0 << 0x11) >> 0x10),local_54, + elt_old->timestamp + iVar2); + } + if (((uVar4 == 0xffff) || + (uVar3 = ea_offset_req((ea_param_input *)&set_param.offset,(ea_param_output *)&local_54), + CONCAT31(extraout_var,uVar3) == 0)) || + (uVar3 = ea_offset_req((ea_param_input *)&set_param.offset,(ea_param_output *)&local_54), + CONCAT31(extraout_var_00,uVar3) == 0)) { + uVar3 = '\0'; + } + else { + uVar3 = '\x1f'; + if (CONCAT31(in_register_00002039,bypass_offchk) == 0) { + return '\x1f'; + } + } + elt = ea_elt_create(0x58); + if (elt != (ea_elt_tag *)0x0) { + (*ble_memcpy_ptr)(elt,elt_old,0x2c); + lld_evt_init_evt((lld_evt_tag *)&elt->env); + *(short *)((int)&elt[2].linked_element + 2) = param->con_latency + 1; + *(undefined *)((int)&elt[2].ea_cb_stop + 3) = 3; + *(uint16_t *)&elt[2].ea_cb_stop = local_54; + uVar6 = (uint)param->offset0; + if (param->offset0 == 0xffff) { + uVar4 = lld_util_get_peer_offset((uint16_t)set_param.duration,local_54,elt_old->timestamp); + uVar1 = *(ushort *)&elt_old[2].timestamp; + uVar6 = CONCAT22(extraout_var_01,uVar4) >> 1 & 0xffff; + } + else { + uVar1 = param->ref_con_event_count; + } + uVar9 = (uint)uVar1; + uVar8 = (uint)*(ushort *)&elt_old[2].ea_cb_stop; + uVar7 = (uint)*(ushort *)((int)&elt_old[2].linked_element + 2) * 0x70000 >> 0x10; + uVar12 = ((uint)*(ushort *)&elt_old[2].timestamp - 1) + uVar7; + uVar13 = uVar12 & 0xffff; + uVar5 = (uint)*(ushort *)&elt[2].ea_cb_stop; + if (uVar13 < uVar9) { + iVar2 = (uVar9 - uVar13) * uVar8 + uVar6 * 2; + } + else { + iVar2 = uVar5 - (int)((uVar13 - uVar9) * uVar8 + uVar6 * -2) % uVar5; + } + uVar6 = iVar2 % uVar5 & 0xffff; + elt->timestamp = uVar6 + ((uVar7 - 1) * uVar8 + elt_old->timestamp & 0x7ffffff) & 0x7ffffff; + elt_old->linked_element = elt; + plVar10 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + uVar11 = (uint16_t)(uVar12 * 0x10000 >> 0x10); + *(uint16_t *)&elt_old[2].linked_element = uVar11; + *(undefined *)((int)&elt_old[2].delay + 1) = 1; + lld_util_compute_ce_max + (elt,(plVar10->data_len_ext_info).conn_eff_max_tx_time, + (plVar10->data_len_ext_info).conn_eff_max_rx_time); + iVar2 = (uint)*(ushort *)&elt_old[2].ea_cb_start * 0x5c; + *(undefined2 *)(iVar2 + 0x280080a6) = *(undefined2 *)(iVar2 + 0x280080a8); + param_pdu->timeout = param->superv_to; + param_pdu->interv = *(ushort *)&elt[2].ea_cb_stop >> 1; + uVar4 = param->con_latency; + param_pdu->win_size = '\x01'; + param_pdu->win_off = (uint16_t)(uVar6 >> 1); + param_pdu->latency = uVar4; + param_pdu->instant = uVar11; + } + return uVar3; +} + + + +// WARNING: Variable defined which should be unmapped: input_param +// WARNING: Could not reconcile some variable overlaps + +uint8_t lld_con_param_rsp(uint16_t conhdl,ea_elt_tag *elt,llc_con_upd_req_ind *param) + +{ + uint8_t uVar1; + uint16_t uVar2; + undefined3 extraout_var; + undefined2 extraout_var_00; + uint uVar3; + uint uVar4; + int iVar5; + uint16_t local_34; + ea_param_output set_param; + ea_param_input input_param; + + set_param.offset = param->interval_min << 1; + set_param._10_2_ = param->interval_max << 1; + ea_interval_duration_req((ea_param_input *)&set_param.offset,(ea_param_output *)&local_34); + if (param->offset0 != 0xffff) { + uVar3 = (uint)*(ushort *)&elt[2].timestamp; + uVar4 = (uint)param->ref_con_event_count; + if (uVar4 < uVar3) { + iVar5 = -((uVar3 - uVar4) * (uint)*(ushort *)&elt[2].ea_cb_stop); + } + else { + iVar5 = (uVar4 - uVar3) * (uint)*(ushort *)&elt[2].ea_cb_stop; + } + lld_util_get_local_offset + ((uint16_t)(((uint)param->offset0 << 0x11) >> 0x10),local_34,elt->timestamp + iVar5); + } + uVar1 = ea_offset_req((ea_param_input *)&set_param.offset,(ea_param_output *)&local_34); + if (CONCAT31(extraout_var,uVar1) == 0) { + param->pref_period = '\0'; + param->interval_min = local_34 >> 1; + param->interval_max = local_34 >> 1; + if (param->offset0 == 0xffff) { + uVar2 = lld_util_get_peer_offset((uint16_t)set_param.duration,local_34,elt->timestamp); + param->offset0 = (uint16_t)(CONCAT22(extraout_var_00,uVar2) >> 1); + param->ref_con_event_count = *(uint16_t *)&elt[2].timestamp; + } + param->offset1 = 0xffff; + param->offset2 = 0xffff; + param->offset3 = 0xffff; + param->offset4 = 0xffff; + param->offset5 = 0xffff; + } + else { + uVar1 = '\x1f'; + } + return uVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void lld_con_param_req(uint16_t conhdl,ea_elt_tag *elt,llc_con_upd_req_ind *param) + +{ + ushort Interval; + uint8_t uVar1; + uint16_t uVar2; + undefined3 extraout_var; + undefined2 extraout_var_00; + uint uVar3; + uint uVar4; + ushort local_34; + ea_param_output set_param; + ea_param_input input_param; + + set_param.offset = param->con_intv_min << 1; + set_param._10_2_ = param->con_intv_max << 1; + ea_interval_duration_req((ea_param_input *)&set_param.offset,(ea_param_output *)&local_34); + uVar3 = (uint)local_34; + uVar4 = elt->timestamp; + uVar1 = ea_offset_req((ea_param_input *)&set_param.offset,(ea_param_output *)&local_34); + Interval = set_param._10_2_; + if (CONCAT31(extraout_var,uVar1) == 0) { + Interval = local_34; + } + param->interval_min = Interval >> 1; + param->interval_max = Interval >> 1; + uVar2 = lld_util_get_peer_offset((uint16_t)(uVar4 % uVar3),Interval,elt->timestamp); + param->offset0 = (uint16_t)(CONCAT22(extraout_var_00,uVar2) >> 1); + param->pref_period = '\0'; + param->ref_con_event_count = *(short *)&elt[2].timestamp + 2; + param->offset1 = 0xffff; + param->offset2 = 0xffff; + param->offset3 = 0xffff; + param->offset4 = 0xffff; + param->offset5 = 0xffff; + return; +} + + + +void lld_con_stop(ea_elt_tag *elt) + +{ + lld_evt_delete_elt_push(elt,true,true); + return; +} + + + +uint8_t lld_get_mode(uint16_t conhdl) + +{ + uint8_t uVar1; + undefined2 in_register_0000202a; + int iVar2; + ea_elt_tag *peVar3; + + iVar2 = CONCAT22(in_register_0000202a,conhdl); + peVar3 = llm_le_env.elt; + if ((iVar2 != 2) && (peVar3 = llm_le_env.elt_coext_scan, iVar2 != 3)) { + if (llc_env[iVar2] == (llc_env_tag *)0x0) { + return '\b'; + } + peVar3 = llc_env[iVar2]->elt; + } + uVar1 = '\b'; + if (peVar3 != (ea_elt_tag *)0x0) { + uVar1 = *(uint8_t *)((int)&peVar3[2].ea_cb_stop + 3); + } + return uVar1; +} + + + +ea_elt_tag * +lld_move_to_slave(llc_create_con_req_ind *con_par,llm_pdu_con_req_rx *con_req_pdu, + ea_elt_tag *elt_adv,uint16_t conhdl,uint8_t rx_hdl) + +{ + int iVar1; + uint8_t uVar2; + ea_elt_tag *elt; + undefined2 in_register_00002036; + undefined3 in_register_00002039; + ushort *puVar3; + + iVar1 = CONCAT22(in_register_00002036,conhdl) * 0x5c; + *(undefined2 *)(iVar1 + 0x2800808e) = 3; + puVar3 = (ushort *)(iVar1 + 0x28008092); + *(ushort *)(&DAT_280082ca + CONCAT22(in_register_00002036,conhdl) * 10) = + *(ushort *)(&DAT_280082ca + CONCAT22(in_register_00002036,conhdl) * 10) & 0x7fff | 0x8000; + *(ushort *)(&DAT_2800809e + iVar1) = + (ushort)(((uint)(*(ushort *)(&DAT_280083d2 + CONCAT31(in_register_00002039,rx_hdl) * 0xe) >> + 5) & 1) << 0xe) | ((ushort)con_req_pdu->hop_sca & 0x1f) << 8 | 0x8000; + *(undefined2 *)(iVar1 + 0x28008094) = *(undefined2 *)(con_req_pdu->aa).addr; + *(undefined2 *)(iVar1 + 0x28008096) = *(undefined2 *)((con_req_pdu->aa).addr + 2); + *(undefined2 *)(iVar1 + 0x28008098) = *(undefined2 *)(con_req_pdu->crcinit).crc; + *(ushort *)(iVar1 + 0x2800809a) = (ushort)(con_req_pdu->crcinit).crc[2]; + *(ushort *)(iVar1 + 0x280080a0) = (ushort)rwip_rf.txpwr_max; + *puVar3 = (ushort)(((uint)*puVar3 << 0x14) >> 0x14) | 0x2000; + *puVar3 = *puVar3 & 0xffe0 | conhdl & 0x1f; + *(undefined2 *)(iVar1 + 0x280080aa) = *(undefined2 *)(con_req_pdu->chm).map; + *(undefined2 *)(iVar1 + 0x280080ac) = *(undefined2 *)((con_req_pdu->chm).map + 2); + uVar2 = llm_util_check_map_validity((uint8_t *)&con_req_pdu->chm,'\x05'); + *(undefined2 *)(iVar1 + 0x280080ae) = CONCAT11(uVar2,(con_req_pdu->chm).map[4]); + *puVar3 = *puVar3 & 0xfeff; + *puVar3 = *puVar3 & 0xfdff; + *puVar3 = *puVar3 & 0xfbff; + *(undefined2 *)(iVar1 + 0x2800809c) = 0; + *(ushort *)(iVar1 + 0x280080e6) = *(ushort *)(iVar1 + 0x280080e6) & 0xff7f; + *(undefined2 *)(iVar1 + 0x280080dc) = 0; + *(undefined2 *)(iVar1 + 0x280080de) = 0; + *(undefined2 *)(iVar1 + 0x280080e0) = 0; + *(undefined2 *)(iVar1 + 0x280080e2) = 0; + *(undefined2 *)(iVar1 + 0x280080e4) = 0; + elt = lld_evt_move_to_slave(con_par,con_req_pdu,elt_adv,conhdl); + lld_util_eff_tx_time_set(elt,0x148,0x1b); + lld_util_compute_ce_max(elt,0x148,0x148); + *(undefined2 *)(iVar1 + 0x280080a6) = *(undefined2 *)(iVar1 + 0x280080a8); + *(undefined2 *)(&DAT_280080b0 + iVar1) = 0; + *(undefined2 *)(iVar1 + 0x280080b2) = 0; + *(undefined2 *)(iVar1 + 0x280080cc) = 0; + *(undefined2 *)(iVar1 + 0x280080ce) = 0; + *(undefined2 *)(iVar1 + 0x280080d0) = 0; + *(undefined2 *)(iVar1 + 0x280080d2) = 0; + *(undefined2 *)(iVar1 + 0x280080d4) = 0; + *(undefined2 *)(iVar1 + 0x280080d6) = 0; + *(undefined2 *)(iVar1 + 0x280080d8) = 0; + *(undefined2 *)(iVar1 + 0x280080a4) = 0; + *puVar3 = *puVar3 & 0xf7ff; + lld_evt_elt_insert(elt,true); + return elt; +} + + + +void lld_ch_map_ind(ea_elt_tag *elt,uint16_t instant) + +{ + byte bVar1; + ushort uVar2; + undefined2 in_register_0000202e; + + *(undefined *)((int)&elt[2].delay + 1) = 2; + bVar1 = *(byte *)((int)&elt[2].ea_cb_cancel + 2); + uVar2 = *(ushort *)&elt[2].timestamp; + *(uint16_t *)&elt[2].linked_element = instant; + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = bVar1 | 1; + if ((uint)uVar2 == (CONCAT22(in_register_0000202e,instant) - 1 & 0xffff)) { + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = bVar1 | 9; + return; + } + if ((uint)uVar2 == CONCAT22(in_register_0000202e,instant)) { + llc_map_update_ind(*(uint16_t *)&elt[2].ea_cb_start); + *(byte *)((int)&elt[2].ea_cb_cancel + 2) = *(byte *)((int)&elt[2].ea_cb_cancel + 2) | 8; + return; + } + return; +} + + + +void lld_con_update_ind(ea_elt_tag *elt_old,llcp_con_upd_ind *param_pdu) + +{ + lld_evt_slave_update(param_pdu,elt_old); + return; +} + + + +void lld_crypt_isr(void) + +{ + ble_ke_event_set('\x01'); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +ea_elt_tag * lld_test_mode_tx(em_desc_node *txdesc,uint8_t tx_freq,uint8_t tx_phy) + +{ + short sVar1; + uint8_t uVar2; + ea_elt_tag *elt; + undefined3 extraout_var; + undefined3 in_register_00002031; + int iVar3; + + iVar3 = CONCAT31(in_register_00002031,tx_phy); + sVar1 = (short)iVar3; + elt = lld_evt_adv_create(2,0,1,false); + *(undefined *)((int)&elt[2].ea_cb_stop + 3) = 2; + _DAT_280000e0 = _DAT_280000e0 & 0xfffff7ff | 0x800; + _DAT_28008184 = 0; + _DAT_28008186 = 0; + _DAT_28008188 = 0; + _DAT_28008146 = 0x1c; + _DAT_2800814c = 0x4129; + _DAT_2800814e = 0x7176; + _DAT_28008158 = _DAT_28008158 & 0xff00 | 0xf; + _DAT_28008148 = 0; + _DAT_2800819e = _DAT_2800819e & 0xff7f; + _DAT_2800814a = _DAT_2800814a & 0xffe0 | 2; + _DAT_28008194 = 0; + _DAT_28008196 = 0; + _DAT_28008198 = 0; + _DAT_2800819a = 0; + _DAT_2800819c = 0; + uVar2 = lld_util_freq2chnl(tx_freq); + _DAT_28008156 = (ushort)CONCAT31(extraout_var,uVar2) | _DAT_28008156 & 0xffc0; + if (iVar3 != 0) { + if (iVar3 == 4) { + sVar1 = 3; + _DAT_280081a0 = _DAT_280081a0 & 0xffcf | 0x10; + } + else { + if (iVar3 == 3) { + _DAT_280081a0 = _DAT_280081a0 & 0xffcf; + } + } + _DAT_280081a0 = sVar1 - 1U & 0xff | _DAT_280081a0 & 0xfffc; + } + lld_pdu_tx_push(elt,txdesc); + lld_pdu_tx_loop((lld_evt_tag *)&elt->env); + lld_evt_elt_insert(elt,true); + return elt; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +ea_elt_tag * lld_test_mode_rx(uint8_t rx_freq) + +{ + uint8_t uVar1; + ea_elt_tag *elt; + undefined3 extraout_var; + + elt = lld_evt_adv_create(2,0,1,false); + *(undefined *)((int)&elt[2].ea_cb_stop + 3) = 2; + _DAT_280000e0 = _DAT_280000e0 & 0xf7ffffff | 0x8000000; + _DAT_2800818a = 0; + _DAT_2800818c = 0; + _DAT_2800818e = 0; + _DAT_28008146 = 0x1d; + _DAT_2800815a = 0x804b; + orig_rxsyncwinszdef = (byte)_DAT_280001ac & 0x3f; + _DAT_280001ac = _DAT_280001ac & 0xffffffc0 | 0xf; + orig_rfrxtmda = (uint8_t)(_DAT_28000078 >> 0x1c); + _DAT_28000078 = _DAT_28000078 & 0xfffffff | 0xf0000000; + _DAT_40002850 = _DAT_40002850 & 0xcfffffff | 0x10000000; + _DAT_28000000 = _DAT_28000000 & 0xffff7fff; + _DAT_2800814c = 0x4129; + _DAT_2800814e = 0x7176; + _DAT_28008148 = 0; + _DAT_28008168 = 0xff; + _DAT_2800816a = 0; + _DAT_2800819e = _DAT_2800819e & 0xff7f; + _DAT_2800814a = _DAT_2800814a & 0xffe0 | 2; + _DAT_28008194 = 0; + _DAT_28008196 = 0; + _DAT_28008198 = 0; + _DAT_2800819a = 0; + _DAT_2800819c = 0; + uVar1 = lld_util_freq2chnl(rx_freq); + _DAT_28008156 = (ushort)CONCAT31(extraout_var,uVar1) | _DAT_28008156 & 0xffc0; + (*rwip_rf.force_agc_enable)(false); + lld_evt_elt_insert(elt,true); + return elt; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void lld_test_stop(ea_elt_tag *elt) + +{ + _DAT_28000000 = _DAT_28000000 | 0x4000000; + (*rwip_rf.force_agc_enable)(true); + _DAT_280000e0 = 0; + return; +} + + + +// WARNING: Variable defined which should be unmapped: tmp_addr + +uint16_t llm_util_bd_addr_wl_position(bd_addr *bd_address,uint8_t bd_addr_type) + +{ + int iVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined auStack40 [4]; + bd_addr tmp_addr; + + iVar1 = 0; + if ((bd_addr_type & 1) == 0) { + do { + (*ble_memcpy_ptr)(auStack40,(void *)(iVar1 * 6 + 0x280081fe),6); + _Var2 = co_bdaddr_compare((bd_addr *)auStack40,bd_address); + if (CONCAT31(extraout_var,_Var2) != 0) { + return (uint16_t)iVar1; + } + iVar1 = iVar1 + 1; + } while (iVar1 != 4); + } + else { + do { + (*ble_memcpy_ptr)(auStack40,(void *)(iVar1 * 6 + 0x28008216),6); + _Var2 = co_bdaddr_compare((bd_addr *)auStack40,bd_address); + if (CONCAT31(extraout_var_00,_Var2) != 0) { + return (uint16_t)iVar1; + } + iVar1 = iVar1 + 1; + } while (iVar1 != 4); + } + return 4; +} + + + +uint8_t llm_util_check_address_validity(bd_addr *bd_address,uint8_t addr_type) + +{ + _Bool _Var1; + uint8_t uVar2; + undefined3 extraout_var; + + _Var1 = co_bdaddr_compare(bd_address,&co_null_bdaddr); + if (CONCAT31(extraout_var,_Var1) == 0) { + uVar2 = '\0'; + } + else { + uVar2 = '\x12'; + } + return uVar2; +} + + + +uint8_t llm_util_check_map_validity(uint8_t *channel_map,uint8_t nb_octet) + +{ + uint uVar1; + undefined3 in_register_0000202d; + uint uVar2; + uint uVar3; + uint uVar4; + + uVar4 = (uint)*channel_map & 0xf8; + if (((*channel_map & 0xf8) != 0) && (uVar4 = 0, CONCAT31(in_register_0000202d,nb_octet) == 1)) { + return '\0'; + } + uVar3 = 0; + while( true ) { + if (CONCAT31(in_register_0000202d,nb_octet) <= (uVar3 & 0xff)) { + return (uint8_t)uVar4; + } + if (((uVar3 & 0xff) == 4) && ((channel_map[uVar3] & 0xe0) != 0)) break; + uVar2 = 0; + do { + uVar1 = uVar2 & 0x1f; + uVar2 = uVar2 + 1; + uVar4 = uVar4 + ((int)(uint)channel_map[uVar3] >> uVar1 & 1U) & 0xff; + } while (uVar2 != 8); + uVar3 = uVar3 + 1; + } + return '&'; +} + + + +void llm_util_apply_bd_addr(uint8_t addr_type) + +{ + undefined3 in_register_00002029; + bd_addr *bd_addr; + uint8_t type; + + if ((CONCAT31(in_register_00002029,addr_type) == 1) || + (CONCAT31(in_register_00002029,addr_type) == 3)) { + type = '\x01'; + bd_addr = &llm_le_env.rand_add; + } + else { + type = '\0'; + bd_addr = &llm_le_env.public_add; + } + lld_util_set_bd_address(bd_addr,type); + return; +} + + + +_Bool llm_util_check_evt_mask(uint8_t event_id) + +{ + undefined3 in_register_00002029; + uint uVar1; + + uVar1 = CONCAT31(in_register_00002029,event_id); + return (_Bool)((byte)((int)(uint)llm_le_env.eventmask.mask[uVar1 >> 3] >> + (uVar1 - (uVar1 & 0xfffffff8) & 0x1f)) & 1); +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void llm_util_get_channel_map(le_chnl_map *map) + +{ + // WARNING: Could not recover jumptable at 0x23014a18. Too many branches + // WARNING: Treating indirect jump as call + (*ble_memcpy_ptr)((void *)0x4201a38a,(void *)0x5); + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void llm_util_get_supp_features(le_features *feats) + +{ + // WARNING: Could not recover jumptable at 0x23014a2c. Too many branches + // WARNING: Treating indirect jump as call + (*ble_memcpy_ptr)(&llm_local_le_feats,(void *)0x8); + return; +} + + + +void llm_util_adv_data_update(void) + +{ + if ((llm_le_env.advertising_params)->adv_data_req != (ke_msg *)0x0) { + llm_set_adv_data((hci_le_set_adv_data_cmd *)(llm_le_env.advertising_params)->adv_data_req->param + ); + ble_ke_msg_free((llm_le_env.advertising_params)->adv_data_req); + (llm_le_env.advertising_params)->adv_data_req = (ke_msg *)0x0; + } + if ((llm_le_env.advertising_params)->scan_rsp_req != (ke_msg *)0x0) { + llm_set_scan_rsp_data + ((hci_le_set_scan_rsp_data_cmd *)(llm_le_env.advertising_params)->scan_rsp_req->param) + ; + ble_ke_msg_free((llm_le_env.advertising_params)->scan_rsp_req); + (llm_le_env.advertising_params)->scan_rsp_req = (ke_msg *)0x0; + } + return; +} + + + +uint8_t llm_util_bl_check(bd_addr *bd_addr_to_add,uint8_t bd_addr_type,uint16_t *conhdl, + uint8_t wl_flag_action,_Bool *in_wl) + +{ + co_list_hdr cVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 in_register_00002035; + int iVar3; + + iVar3 = CONCAT31(in_register_00002035,wl_flag_action); + cVar1 = (co_list_hdr)llm_le_env.cnx_list.first; + do { + if (cVar1 == (co_list_hdr)0x0) { + return '\0'; + } + if ((bd_addr_to_add == (bd_addr *)0x0) && (iVar3 == 1)) { + *(undefined *)((int)cVar1 + 0xd) = 0; + } + else { + _Var2 = co_bdaddr_compare(bd_addr_to_add,(bd_addr *)((int)cVar1 + 4)); + if ((CONCAT31(extraout_var,_Var2) != 0) && + (*(byte *)&((co_list_hdr *)((int)cVar1 + 0xc))->next == (bd_addr_type & 1))) { + if (conhdl != (uint16_t *)0x0) { + *conhdl = *(uint16_t *)((int)cVar1 + 10); + } + if (iVar3 == 1) { + *(undefined *)((int)cVar1 + 0xd) = 0; + } + else { + if (iVar3 == 2) { + *(undefined *)((int)cVar1 + 0xd) = 1; + } + } + if (in_wl == (_Bool *)0x0) { + return '\v'; + } + *in_wl = *(_Bool *)((int)cVar1 + 0xd); + return '\v'; + } + } + cVar1 = *(co_list_hdr *)cVar1; + } while( true ); +} + + + +// WARNING: Variable defined which should be unmapped: found + +_Bool llm_util_bd_addr_in_wl(bd_addr *bd_address,uint8_t bd_addr_type,_Bool *in_black_list) + +{ + uint8_t uVar1; + uint16_t uVar2; + undefined3 extraout_var; + undefined2 extraout_var_00; + _Bool a_Stack17 [4]; + _Bool found; + + a_Stack17[0] = false; + if (in_black_list != (_Bool *)0x0) { + *in_black_list = false; + } + uVar1 = llm_util_bl_check(bd_address,bd_addr_type,(uint16_t *)0x0,'\0',a_Stack17); + if ((CONCAT31(extraout_var,uVar1) == 0xb) && (in_black_list != (_Bool *)0x0)) { + *in_black_list = true; + } + if ((a_Stack17[0] == false) && + (uVar2 = llm_util_bd_addr_wl_position(bd_address,bd_addr_type), + CONCAT22(extraout_var_00,uVar2) < 4)) { + a_Stack17[0] = true; + } + return a_Stack17[0]; +} + + + +uint8_t llm_util_bl_add(bd_addr *bd_addr_to_add,uint8_t bd_addr_type,uint16_t conhdl) + +{ + uint8_t uVar1; + uint16_t uVar2; + void *pvVar3; + undefined2 extraout_var; + + pvVar3 = ble_ke_malloc(0x10,'\0'); + uVar1 = '\a'; + if (pvVar3 != (void *)0x0) { + (*ble_memcpy_ptr)((bd_addr *)((int)pvVar3 + 4),bd_addr_to_add,6); + *(uint16_t *)((int)pvVar3 + 10) = conhdl; + *(byte *)((int)pvVar3 + 0xc) = bd_addr_type & 1; + uVar2 = llm_util_bd_addr_wl_position(bd_addr_to_add,bd_addr_type); + *(bool *)((int)pvVar3 + 0xd) = CONCAT22(extraout_var,uVar2) < 4; + ble_co_list_push_back(0x4201a370,pvVar3); + uVar1 = '\0'; + if (*(char *)((int)pvVar3 + 0xd) != '\0') { + llm_wl_dev_rem((bd_addr *)((int)pvVar3 + 4),bd_addr_type & 1); + } + } + return uVar1; +} + + + +uint8_t llm_util_bl_rem(uint16_t conhdl) + +{ + co_list_hdr list_hdr; + undefined2 in_register_0000202a; + + list_hdr = (co_list_hdr)llm_le_env.cnx_list.first; + while( true ) { + if (list_hdr == (co_list_hdr)0x0) { + return '\x02'; + } + if ((uint)*(ushort *)((int)list_hdr + 10) == CONCAT22(in_register_0000202a,conhdl)) break; + list_hdr = *(co_list_hdr *)list_hdr; + } + ble_co_list_extract(&llm_le_env.cnx_list,(co_list_hdr *)list_hdr,'\0'); + if (*(char *)((int)list_hdr + 0xd) != '\0') { + llm_wl_dev_add((bd_addr *)((int)list_hdr + 4), + *(uint8_t *)&((co_list_hdr *)((int)list_hdr + 0xc))->next); + } + ble_ke_free((void *)list_hdr); + return '\0'; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void llm_end_evt_defer(void) + +{ + byte bVar1; + undefined *param; + undefined2 uVar2; + undefined auStack36 [4]; + llc_create_con_req_ind msg_param; + + bVar1 = ble_ke_state_get(0); + if ((bVar1 & 0xf0) == 0x10) { + if (((llm_le_env.advertising_params)->type == '\x01') && + ((llm_le_env.advertising_params)->adv_ldc_flag == false)) { + (*ble_memcpy_ptr)(&msg_param.sup_to,&(llm_le_env.advertising_params)->peer_addr,6); + msg_param.peer_addr.addr[2] = (llm_le_env.advertising_params)->peer_addr_type; + llc_le_con_cmp_evt_send('<',0,(llc_create_con_req_ind *)auStack36); + lld_evt_delete_elt_push(llm_le_env.elt,true,false); + bVar1 = ble_ke_state_get(0); + ble_ke_state_set(0,bVar1 & 0xf); + } + } + if ((llm_le_env.test_mode.directtesttype != '\x03') && (llm_le_env.test_mode.end_of_tst != false)) + { + param = (undefined *)ble_ke_msg_alloc(0x801,0,0x201f,4); + llm_le_env.test_mode.end_of_tst = false; + if (llm_le_env.test_mode.directtesttype == '\x01') { + _DAT_280001ac = _DAT_280001ac & 0xffffffc0 | (uint)orig_rxsyncwinszdef; + _DAT_28000078 = (uint)orig_rfrxtmda << 0x1c | _DAT_28000078 & 0xfffffff; + _DAT_40002850 = _DAT_40002850 & 0xcfffffff | 0x20000000; + } + _DAT_28000000 = _DAT_28000000 & 0xfffb7fff | 0x8000; + uVar2 = 0; + if (llm_le_env.test_mode.directtesttype != '\0') { + uVar2 = _DAT_2800818a; + } + *(undefined2 *)(param + 2) = uVar2; + llm_le_env.test_mode.directtesttype = '\x03'; + *param = 0; + hci_send_2_host(param); + ble_ke_msg_send_basic(1,0,0); + } + return; +} + + + +_Bool llm_pdu_defer(uint16_t status,uint8_t rx_hdl,uint8_t tx_cnt) + +{ + undefined uVar1; + byte bVar2; + undefined3 extraout_var; + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + uint uVar3; + + bVar2 = ble_ke_state_get(0); + _bVar2 = CONCAT31(extraout_var,bVar2); + if ((bVar2 & 0xf) == 2) { + if ((status & 3) == 0) { + uVar1 = 0; + if (CONCAT31(in_register_00002031,tx_cnt) != 0) { + llm_con_req_tx_cfm(rx_hdl); + uVar1 = 1; + } + goto LAB_23014dac; + } + if (_bVar2 == 0x23) { + uVar1 = 0; + goto LAB_23014dac; + } + } + else { + uVar1 = 0; + if ((_bVar2 == 0x23) || (_bVar2 == 0)) goto LAB_23014dac; + } + uVar1 = 0; + if (((_bVar2 != 0x24) && ((status & 0x1f) == 0)) && + (((uint)*(ushort *)(&DAT_280083d2 + CONCAT31(in_register_0000202d,rx_hdl) * 0xe) & 0xf) < 7)) { + uVar3 = 1 << ((uint)*(ushort *)(&DAT_280083d2 + CONCAT31(in_register_0000202d,rx_hdl) * 0xe) & + 0xf); + if ((uVar3 & 0x57) == 0) { + if (((uVar3 & 0x20) != 0) && ((bVar2 & 0xf0) == 0x10)) { + llm_con_req_ind(rx_hdl,status); + } + } + else { + if ((bVar2 & 0xf) == 1) { + llm_le_adv_report_ind(rx_hdl); + } + } + } +LAB_23014dac: + em_buf_rx_free(rx_hdl); + return (_Bool)uVar1; +} + + + +void llm_wlpub_addr_set(uint16_t elem_index,bd_addr *bdaddr) + +{ + undefined2 *puVar1; + undefined2 in_register_0000202a; + undefined2 *puVar2; + bd_addr *pbVar3; + + pbVar3 = bdaddr + 1; + puVar2 = (undefined2 *)(CONCAT22(in_register_0000202a,elem_index) * 6 + 0x280081fe); + do { + puVar1 = (undefined2 *)bdaddr->addr; + bdaddr = (bd_addr *)(bdaddr->addr + 2); + *puVar2 = *puVar1; + puVar2 = puVar2 + 1; + } while (pbVar3 != bdaddr); + return; +} + + + +void llm_wlpriv_addr_set(uint16_t elem_index,bd_addr *bdaddr) + +{ + undefined2 *puVar1; + undefined2 in_register_0000202a; + undefined2 *puVar2; + bd_addr *pbVar3; + + pbVar3 = bdaddr + 1; + puVar2 = (undefined2 *)(CONCAT22(in_register_0000202a,elem_index) * 6 + 0x28008216); + do { + puVar1 = (undefined2 *)bdaddr->addr; + bdaddr = (bd_addr *)(bdaddr->addr + 2); + *puVar2 = *puVar1; + puVar2 = puVar2 + 1; + } while (pbVar3 != bdaddr); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void llm_con_req_ind(uint8_t rx_hdl,uint16_t status) + +{ + ushort uVar1; + int iVar2; + uint8_t uVar3; + byte bVar4; + undefined3 in_register_00002029; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + uint16_t local_5a; + ushort uStack88; + uint16_t conhdl; + llc_create_con_req_ind param; + llm_pdu_con_req_rx data; + + iVar2 = CONCAT31(in_register_00002029,rx_hdl) * 0xe; + (*ble_memcpy_ptr)(¶m.sleep_clk_acc,&DAT_28008000 + *(ushort *)(&DAT_280083d6 + iVar2),0x22); + if (0xc76 < ((uint)data.interval - 10 & 0xffff)) { + return; + } + if (0xc7a < ((uint)data._18_2_ - 6 & 0xffff)) { + return; + } + if (499 < data.winoffset) { + return; + } + if ((uint)data.interval << 2 <= ((uint)data.winoffset + 1) * (uint)data._18_2_) { + return; + } + uVar3 = llc_util_get_free_conhdl(&local_5a); + if (CONCAT31(extraout_var,uVar3) != 0) { + return; + } + if ((status & 0x200) == 0) { + uVar1 = *(ushort *)(iVar2 + 0x280083d8); + if (uVar1 != 0) { + (*ble_memcpy_ptr)(¶m.sleep_clk_acc,&DAT_28008000 + ((uint)uVar1 + 0x18 & 0xffff),6); + param.peer_addr.addr[2] = + (byte)*(undefined2 *)(&DAT_2800822e + (((uint)uVar1 - 0x22e) / 0x34 & 0xff) * 0x34) & 2 | + (byte)*(undefined2 *)(&DAT_2800822e + (((uint)uVar1 - 0x22e) / 0x34 & 0xff) * 0x34) & 1; + goto LAB_23014f6e; + } + } + uVar1 = 0; + param.peer_addr.addr[2] = (byte)(*(ushort *)(&DAT_280083d2 + iVar2) >> 6) & 1; +LAB_23014f6e: + uVar3 = llm_util_bl_check((bd_addr *)¶m.sleep_clk_acc,param.peer_addr.addr[2],&local_5a,'\0', + (_Bool *)0x0); + if (CONCAT31(extraout_var_00,uVar3) == 0) { + uVar3 = llm_util_bl_add((bd_addr *)¶m.sleep_clk_acc,param.peer_addr.addr[2],local_5a); + if (CONCAT31(extraout_var_01,uVar3) == 0) { + uStack88 = data._18_2_; + conhdl = data.winoffset; + param.con_int = data.interval; + param.peer_addr.addr[4] = data.chm.map[1] >> 5; + param.peer_addr.addr[3] = data.chm.map[1] & 0x1f; + param.con_lat = uVar1; + (*ble_memcpy_ptr)(¶m.sup_to,¶m.sleep_clk_acc,6); + llm_le_env.elt = + lld_move_to_slave((llc_create_con_req_ind *)&uStack88, + (llm_pdu_con_req_rx *)¶m.sleep_clk_acc,llm_le_env.elt,local_5a, + rx_hdl); + llc_start(&uStack88,llm_le_env.elt); + llm_le_env.elt = (ea_elt_tag *)0x0; + llc_util_update_channel_map(local_5a,(le_chnl_map *)&data.latency); + } + bVar4 = ble_ke_state_get(0); + ble_ke_state_set(0,bVar4 & 0xf); + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void llm_le_adv_report_ind(uint8_t rx_hdl) + +{ + ushort uVar1; + ushort uVar2; + co_list_hdr cVar3; + uint uVar4; + uint uVar5; + undefined *param; + _Bool _Var6; + int8_t iVar7; + uint16_t uVar8; + undefined3 in_register_00002029; + undefined2 extraout_var_02; + void *pvVar9; + undefined2 extraout_var_03; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + byte bVar10; + undefined uVar11; + ushort *puVar12; + ushort *puVar13; + int iVar14; + undefined auStack72 [4]; + bd_addr adv_addr; + bd_addr inita; + bd_addr adva; + + iVar14 = CONCAT31(in_register_00002029,rx_hdl) * 0xe; + puVar12 = (ushort *)(&DAT_280083d2 + iVar14); + puVar13 = (ushort *)(&DAT_280083d6 + iVar14); + uVar1 = *puVar12; + (*ble_memcpy_ptr)(auStack72,&DAT_28008000 + *puVar13,6); + uVar5 = (uint)uVar1 & 0xf; + cVar3 = (co_list_hdr)llm_le_env.adv_list.first; + if (((llm_le_env.scanning_params)->filter_duplicate == '\x01') || (uVar5 == 1)) { + while (cVar3 != (co_list_hdr)0x0) { + _Var6 = co_bdaddr_compare((bd_addr *)auStack72,(bd_addr *)((int)cVar3 + 5)); + if ((CONCAT31(extraout_var_00,_Var6) != 0) && + ((uint)*(byte *)&((co_list_hdr *)((int)cVar3 + 4))->next == uVar5)) { + return; + } + cVar3 = *(co_list_hdr *)cVar3; + } + uVar8 = ble_co_list_size(&llm_le_env.adv_list); + if (CONCAT22(extraout_var_02,uVar8) == 10) { + return; + } + pvVar9 = ble_ke_malloc(0xc,'\0'); + (*ble_memcpy_ptr)((void *)((int)pvVar9 + 5),auStack72,6); + *(undefined *)((int)pvVar9 + 4) = (char)uVar5; + ble_co_list_push_back(0x4201a360,pvVar9); + } + if (Is_ext_scan_enable != '\0') { + return; + } + uVar8 = ble_ke_msg_get_sent_num(); + if (0x14 < CONCAT22(extraout_var_03,uVar8)) { + return; + } + uVar1 = *(ushort *)(iVar14 + 0x280083d8); + uVar4 = (uint)uVar1; + uVar2 = *(ushort *)(iVar14 + 0x280083d0); + (*ble_memcpy_ptr)(adv_addr.addr + 4,&DAT_28008000 + ((uint)*puVar13 + 6 & 0xffff),6); + (*ble_memcpy_ptr)(inita.addr + 4,&DAT_28008000 + *puVar13,6); + if (((((uVar5 == 1) && (1 < (llm_le_env.scanning_params)->filterpolicy)) && + ((*puVar12 >> 7 & 1) != 0)) && ((inita.addr[1] & 0xc0) == 0x40)) && + ((uVar1 == 0 || ((uVar2 & 0x600) == 0x600)))) { + _Var6 = llm_util_check_evt_mask('\n'); + if (CONCAT31(extraout_var,_Var6) == 0) { + return; + } + param = (undefined *)ble_ke_msg_alloc(0x804,0,0,0x12); + *param = 0xb; + param[1] = 1; + iVar7 = (*rwip_rf.rssi_convert)((uint8_t)*(undefined2 *)(iVar14 + 0x280083d4)); + param[0x11] = iVar7; + param[2] = (byte)*puVar12 & 0xf; + if (uVar1 == 0) { + (*ble_memcpy_ptr)(&DAT_28008000 + *puVar13,(void *)0x6,(uint)ble_memcpy_ptr); + param[3] = (byte)(*puVar12 >> 6) & 1; + (*ble_memcpy_ptr)(param + 0xb,adv_addr.addr + 4,6); + param[10] = 1; + } + else { + (*ble_memcpy_ptr)(param + 4,&DAT_28008000 + (uVar4 + 0x18 & 0xffff),6); + bVar10 = (byte)*(undefined2 *)(&DAT_2800822e + ((uVar4 - 0x22e) / 0x34 & 0xff) * 0x34) & 1; + param[3] = bVar10; + if ((adva.addr[1] & 0xc0) == 0x40) { + param[3] = bVar10 | 2; + } + (*ble_memcpy_ptr)(param + 0xb,adv_addr.addr + 4,6); + param[10] = 1; + } + goto LAB_2301522e; + } + _Var6 = llm_util_check_evt_mask('\x01'); + if (CONCAT31(extraout_var_01,_Var6) == 0) { + return; + } + param = (undefined *)ble_ke_msg_alloc(0x804,0,0,0x2b); + param[1] = 1; + *param = 2; + iVar7 = (*rwip_rf.rssi_convert)((uint8_t)*(undefined2 *)(iVar14 + 0x280083d4)); + param[0x2a] = iVar7; + uVar5 = (uint)*puVar12 & 0xf; + uVar11 = (undefined)uVar5; + if (uVar5 == 2) { + uVar11 = 3; +LAB_230152e8: + param[2] = uVar11; + } + else { + if (uVar5 != 6) goto LAB_230152e8; + param[2] = 2; + } + if (param[2] == '\x01') { + param[10] = 0; + } + else { + uVar5 = (uint)(*puVar12 >> 8) - 6 & 0xff; + if (uVar5 < 0x20) { + param[10] = (char)uVar5; + } + else { + param[10] = 0x1f; + } + (*ble_memcpy_ptr)(param + 0xb,&DAT_28008000 + ((uint)*puVar13 + 6 & 0xffff), + (uint)(byte)param[10]); + } + if ((uVar1 == 0) || ((uVar2 & 0x600) == 0x200)) { + (*ble_memcpy_ptr)(param + 4,&DAT_28008000 + *puVar13,6); + bVar10 = (byte)(*puVar12 >> 6) & 1; + } + else { + (*ble_memcpy_ptr)(param + 4,&DAT_28008000 + (uVar4 + 0x18 & 0xffff),6); + bVar10 = (byte)*(undefined2 *)(&DAT_2800822e + ((uVar4 - 0x22e) / 0x34 & 0xff) * 0x34) & 1; + param[3] = bVar10; + if ((adva.addr[1] & 0xc0) != 0x40) goto LAB_2301522e; + bVar10 = bVar10 | 2; + } + param[3] = bVar10; +LAB_2301522e: + hci_send_2_host(param); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void llm_con_req_tx_cfm(uint8_t rx_hdl) + +{ + int iVar1; + uint8_t uVar2; + byte bVar3; + undefined3 in_register_00002029; + undefined3 extraout_var; + undefined auStack88 [4]; + llm_pdu_adv rxdata; + llc_create_con_req_ind param; + llm_pdu_con_req_tx txdata; + + iVar1 = CONCAT31(in_register_00002029,rx_hdl) * 0xe; + (*ble_memcpy_ptr)(auStack88,&DAT_28008000 + *(ushort *)(&DAT_280083d6 + iVar1),6); + (*ble_memcpy_ptr)(¶m.sleep_clk_acc,&DAT_28008000 + _DAT_280082ec,0x16); + param.con_lat = *(ushort *)(iVar1 + 0x280083d8); + if (param.con_lat == 0) { + param.peer_addr.addr[2] = (byte)(*(ushort *)(&DAT_280083d2 + iVar1) >> 6) & 1; + (*ble_memcpy_ptr)(¶m.sup_to,auStack88,6); + } + else { + (*ble_memcpy_ptr)(¶m.sup_to,&DAT_28008000 + ((uint)param.con_lat + 0x18 & 0xffff),6); + param.peer_addr.addr[2] = + (byte)*(undefined2 *)(&DAT_2800822e + (((uint)param.con_lat - 0x22e) / 0x34 & 0xff) * 0x34) + & 2 | (byte)*(undefined2 *) + (&DAT_2800822e + (((uint)param.con_lat - 0x22e) / 0x34 & 0xff) * 0x34) & 1; + } + param.peer_addr.addr[4] = txdata.chm.map[1] >> 5; + param.peer_addr.addr[3] = txdata.chm.map[1] & 0x1f; + if ((llm_le_env.elt_coext_scan != (ea_elt_tag *)0x0) && + (uVar2 = llm_util_bl_add((bd_addr *)¶m.sup_to,param.peer_addr.addr[2], + llm_le_env.conhdl_alloc), CONCAT31(extraout_var,uVar2) == 0)) { + llm_le_env.elt_coext_scan = + lld_move_to_master(llm_le_env.elt_coext_scan,llm_le_env.conhdl_alloc, + (llc_create_con_req_ind *)&rxdata.adva_data,rx_hdl); + llc_start(&rxdata.adva_data,llm_le_env.elt_coext_scan); + llm_le_env.elt_coext_scan = (ea_elt_tag *)0x0; + } + bVar3 = ble_ke_state_get(0); + ble_ke_state_set(0,bVar3 & 0xf0); + return; +} + + + +void llm_common_cmd_complete_send(uint16_t opcode,uint8_t status) + +{ + uint8_t *param; + + param = (uint8_t *)ble_ke_msg_alloc(0x801,0,opcode,1); + *param = status; + hci_send_2_host(param); + return; +} + + + +void llm_common_cmd_status_send(uint16_t opcode,uint8_t status) + +{ + uint8_t *param; + + param = (uint8_t *)ble_ke_msg_alloc(0x802,0,opcode,1); + *param = status; + hci_send_2_host(param); + return; +} + + +/* +Unable to decompile 'llm_test_mode_start_tx' +Cause: Exception while decompiling 23015548: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t llm_test_mode_start_rx(hci_le_rx_test_cmd *param) + +{ + advertising_pdu_params *paVar1; + uint8_t uVar2; + + if (param->rx_freq < 0x28) { + if (llm_le_env.advertising_params == (advertising_pdu_params *)0x0) { + llm_le_env.advertising_params = (advertising_pdu_params *)ble_ke_malloc(0x24,'\0'); + (*ble_memset_ptr)(llm_le_env.advertising_params,0,0x24); + paVar1 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->intervalmin = 0x800; + paVar1->type = '\0'; + paVar1->intervalmax = 0x800; + paVar1->filterpolicy = '\0'; + paVar1 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->channelmap = '\a'; + paVar1->adv_ldc_flag = true; + _DAT_280082fe = (ushort)paVar1->type | 0x600; + _DAT_280082f4 = 0x604; + } + _DAT_28000000 = _DAT_28000000 & 0xfffbffff | 0x40000; + ble_ke_state_set(0,'$'); + llm_le_env.elt = lld_test_mode_rx(param->rx_freq); + uVar2 = '\x1f'; + if (llm_le_env.elt != (ea_elt_tag *)0x0) { + llm_le_env.test_mode.directtesttype = '\x01'; + uVar2 = '\0'; + } + return uVar2; + } + return '\x12'; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t llm_set_adv_param(hci_le_set_adv_param_cmd *param) + +{ + uint8_t uVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + advertising_pdu_params *paVar2; + bd_addr *bd_address; + + if ((((((param->adv_intv_max < param->adv_intv_min) || (7 < param->adv_chnl_map)) || + (3 < param->adv_filt_policy)) || + (((param->adv_type & 0xfb) == 0 && (param->adv_intv_min < 0x20)))) || + ((3 < param->own_addr_type || (1 < param->peer_addr_type)))) || + ((param->adv_type != 1 && (0x4000 < param->adv_intv_max)))) { + return '\x12'; + } + if (llm_le_env.advertising_params == (advertising_pdu_params *)0x0) { + llm_le_env.advertising_params = (advertising_pdu_params *)ble_ke_malloc(0x24,'\0'); + (*ble_memset_ptr)(llm_le_env.advertising_params,0,0x24); + paVar2 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->intervalmin = 0x800; + paVar2->type = '\0'; + paVar2->intervalmax = 0x800; + paVar2->filterpolicy = '\0'; + paVar2 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->channelmap = '\a'; + paVar2->adv_ldc_flag = true; + _DAT_280082fe = (ushort)paVar2->type | 0x600; + _DAT_280082f4 = 0x604; + } + paVar2 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->type = '\b'; + paVar2->adv_ldc_flag = true; + if (4 < param->adv_type) { + return '\x12'; + } + bd_address = ¶m->peer_addr; + switch(param->adv_type) { + default: + paVar2->type = '\x01'; + _DAT_280082e0 = 0xc21; + uVar1 = llm_util_check_address_validity(bd_address,param->peer_addr_type); + if (CONCAT31(extraout_var,uVar1) == 0) { + _DAT_280082e0 = (ushort)param->peer_addr_type << 7 | _DAT_280082e0 & 0xff7f; + (*ble_memcpy_ptr)(&DAT_28008000 + _DAT_280082e2,bd_address,6); + } + paVar2 = llm_le_env.advertising_params; + if (param->adv_type != '\x04') { + (llm_le_env.advertising_params)->adv_ldc_flag = false; + goto LAB_230159c6; + } + break; + case '\x02': + paVar2->type = '\x06'; + case '\0': + if (paVar2->type != '\x06') { + paVar2->type = '\0'; + } + case '\x03': + if ((paVar2->type != '\x06') && (paVar2->type != '\0')) { + paVar2->type = '\x02'; + } + paVar2->filterpolicy = param->adv_filt_policy; + } + paVar2->intervalmax = param->adv_intv_max; + paVar2->intervalmin = param->adv_intv_min; +LAB_230159c6: + paVar2 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->peer_addr_type = param->peer_addr_type; + (*ble_memcpy_ptr)(&paVar2->peer_addr,bd_address,6); + (llm_le_env.advertising_params)->own_addr_type = param->own_addr_type; + uVar1 = llm_util_check_map_validity(¶m->adv_chnl_map,'\x01'); + if (CONCAT31(extraout_var_00,uVar1) == 0) { + uVar1 = '\x12'; + } + else { + uVar1 = '\0'; + (llm_le_env.advertising_params)->channelmap = param->adv_chnl_map; + } + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t llm_set_adv_en(hci_le_set_adv_en_cmd *param) + +{ + advertising_pdu_params *paVar1; + uint8_t uVar2; + _Bool _Var3; + byte bVar4; + undefined3 extraout_var; + em_desc_node *adv_pdu; + + if (param->adv_en == '\0') { + bVar4 = ble_ke_state_get(0); + ble_ke_state_set(0,bVar4 & 0xf | 0x20); + lld_adv_stop(llm_le_env.elt); + return '\0'; + } + if (llm_le_env.advertising_params == (advertising_pdu_params *)0x0) { + llm_le_env.advertising_params = (advertising_pdu_params *)ble_ke_malloc(0x24,'\0'); + (*ble_memset_ptr)(llm_le_env.advertising_params,0,0x24); + paVar1 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->intervalmin = 0x800; + paVar1->type = '\0'; + paVar1->intervalmax = 0x800; + paVar1->filterpolicy = '\0'; + paVar1 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->channelmap = '\a'; + paVar1->adv_ldc_flag = true; + _DAT_280082fe = (ushort)paVar1->type | 0x600; + _DAT_280082f4 = 0x604; + } + _Var3 = co_bdaddr_compare(&llm_le_env.rand_add,&co_null_bdaddr); + if ((CONCAT31(extraout_var,_Var3) == 0) || + (((llm_le_env.advertising_params)->own_addr_type & 1) == 0)) { + llm_util_apply_bd_addr((llm_le_env.advertising_params)->own_addr_type); + bVar4 = (llm_le_env.advertising_params)->type; + if (bVar4 == 1) { + adv_pdu = em_buf_env.tx_desc_node + 2; +LAB_23015b38: + llm_le_env.elt = + lld_adv_start(llm_le_env.advertising_params,adv_pdu,(em_desc_node *)0x0,rwip_rf.txpwr_max + ); + if (llm_le_env.elt == (ea_elt_tag *)0x0) goto LAB_23015ac8; + } + else { + if (((bVar4 != 0) && (bVar4 != 2)) && (bVar4 != 6)) { + return '\x12'; + } + _DAT_280082fe = + (ushort)(((uint)(llm_le_env.advertising_params)->datalen + 6 & 0xff) << 8) | + (ushort)bVar4 | 0x20; + if ((llm_le_env.advertising_params)->type == '\x02') { + adv_pdu = em_buf_env.tx_desc_node + 5; + goto LAB_23015b38; + } + _DAT_280082f4 = + (ushort)(((uint)(llm_le_env.advertising_params)->scanrsplen + 6 & 0xff) << 8) | 0x24; + llm_le_env.elt = + lld_adv_start(llm_le_env.advertising_params,em_buf_env.tx_desc_node + 5, + em_buf_env.tx_desc_node + 4,rwip_rf.txpwr_max); + if (llm_le_env.elt == (ea_elt_tag *)0x0) { + return '\x1f'; + } + } + bVar4 = ble_ke_state_get(0); + ble_ke_state_set(0,bVar4 & 0xf | 0x10); + uVar2 = '\0'; + } + else { +LAB_23015ac8: + uVar2 = '\x12'; + } + return uVar2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t llm_set_adv_data(hci_le_set_adv_data_cmd *param) + +{ + byte bVar1; + advertising_pdu_params *paVar2; + + if (param->adv_data_len < 0x20) { + if (llm_le_env.advertising_params == (advertising_pdu_params *)0x0) { + llm_le_env.advertising_params = (advertising_pdu_params *)ble_ke_malloc(0x24,'\0'); + (*ble_memset_ptr)(llm_le_env.advertising_params,0,0x24); + paVar2 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->intervalmin = 0x800; + paVar2->type = '\0'; + paVar2->intervalmax = 0x800; + paVar2->filterpolicy = '\0'; + paVar2 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->channelmap = '\a'; + paVar2->adv_ldc_flag = true; + _DAT_280082fe = (ushort)paVar2->type | 0x600; + _DAT_280082f4 = 0x604; + } + bVar1 = param->adv_data_len; + (llm_le_env.advertising_params)->datalen = bVar1; + if (bVar1 != 0) { + (*ble_memcpy_ptr)(&DAT_28008000 + _DAT_28008300,¶m->data,(uint)bVar1); + } + _DAT_280082fe = + (ushort)(((uint)(llm_le_env.advertising_params)->datalen + 6 & 0xff) << 8) | + _DAT_280082fe & 0xff; + return '\0'; + } + return '\x12'; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t llm_set_scan_rsp_data(hci_le_set_scan_rsp_data_cmd *param) + +{ + byte bVar1; + advertising_pdu_params *paVar2; + + if (param->scan_rsp_data_len < 0x20) { + if (llm_le_env.advertising_params == (advertising_pdu_params *)0x0) { + llm_le_env.advertising_params = (advertising_pdu_params *)ble_ke_malloc(0x24,'\0'); + (*ble_memset_ptr)(llm_le_env.advertising_params,0,0x24); + paVar2 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->intervalmin = 0x800; + paVar2->type = '\0'; + paVar2->intervalmax = 0x800; + paVar2->filterpolicy = '\0'; + paVar2 = llm_le_env.advertising_params; + (llm_le_env.advertising_params)->channelmap = '\a'; + paVar2->adv_ldc_flag = true; + _DAT_280082fe = (ushort)paVar2->type | 0x600; + _DAT_280082f4 = 0x604; + } + bVar1 = param->scan_rsp_data_len; + (llm_le_env.advertising_params)->scanrsplen = bVar1; + if (bVar1 != 0) { + (*ble_memcpy_ptr)(&DAT_28008000 + _DAT_280082f6,¶m->data,(uint)bVar1); + } + _DAT_280082f4 = + (ushort)(((uint)(llm_le_env.advertising_params)->scanrsplen + 6 & 0xff) << 8) | + _DAT_280082f4 & 0xff; + return '\0'; + } + return '\x12'; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t llm_set_scan_param(hci_le_set_scan_param_cmd *param) + +{ + uint8_t uVar1; + + if (param->scan_window <= param->scan_intv) { + uVar1 = '\x12'; + if ((((param->scan_type < 2) && ((ushort)(param->scan_window - 4) < 0x3ffd)) && + ((ushort)(param->scan_intv - 4) < 0x3ffd)) && (param->scan_filt_policy < 4)) { + if (llm_le_env.scanning_params == (scanning_pdu_params *)0x0) { + llm_le_env.scanning_params = (scanning_pdu_params *)ble_ke_malloc(0xc,'\0'); + (*ble_memset_ptr)(llm_le_env.scanning_params,0,0xc); + } + uVar1 = '\0'; + (llm_le_env.scanning_params)->filterpolicy = param->scan_filt_policy; + (llm_le_env.scanning_params)->interval = param->scan_intv; + (llm_le_env.scanning_params)->window = param->scan_window; + (llm_le_env.scanning_params)->type = param->scan_type; + (llm_le_env.scanning_params)->own_addr_type = param->own_addr_type; + if (param->scan_type == '\x01') { + _DAT_280082ea = 0xc03; + } + } + return uVar1; + } + return '\x12'; +} + + + +uint8_t llm_set_scan_en(hci_le_set_scan_en_cmd *param) + +{ + byte bVar1; + _Bool _Var2; + undefined3 extraout_var; + em_desc_node *scan_req_pdu; + + if (param->scan_en == '\0') { + bVar1 = ble_ke_state_get(0); + ble_ke_state_set(0,bVar1 & 0xf0 | 3); + lld_scan_stop(llm_le_env.elt_coext_scan); + lld_util_flush_list(&llm_le_env.adv_list); + return '\0'; + } + if (llm_le_env.scanning_params == (scanning_pdu_params *)0x0) { + llm_le_env.scanning_params = (scanning_pdu_params *)ble_ke_malloc(0xc,'\0'); + (llm_le_env.scanning_params)->filterpolicy = '\0'; + (llm_le_env.scanning_params)->interval = 0x10; + (llm_le_env.scanning_params)->window = 8; + (llm_le_env.scanning_params)->type = '\0'; + (llm_le_env.scanning_params)->filter_duplicate = '\0'; + } + _Var2 = co_bdaddr_compare(&llm_le_env.rand_add,&co_null_bdaddr); + if (((CONCAT31(extraout_var,_Var2) != 0) && + (((llm_le_env.scanning_params)->own_addr_type & 1) != 0)) && + ((llm_le_env.scanning_params)->type == '\x01')) { + return '\x12'; + } + (llm_le_env.scanning_params)->filter_duplicate = param->filter_duplic_en; + llm_util_apply_bd_addr((llm_le_env.scanning_params)->own_addr_type); + if ((llm_le_env.scanning_params)->type == '\0') { + scan_req_pdu = (em_desc_node *)0x0; + } + else { + if ((llm_le_env.scanning_params)->type != '\x01') goto LAB_23015eec; + scan_req_pdu = em_buf_env.tx_desc_node + 3; + } + llm_le_env.elt_coext_scan = lld_scan_start(llm_le_env.scanning_params,scan_req_pdu); + if (llm_le_env.elt_coext_scan == (ea_elt_tag *)0x0) { + return '\x1f'; + } +LAB_23015eec: + bVar1 = ble_ke_state_get(0); + ble_ke_state_set(0,bVar1 & 0xf0 | 1); + return '\0'; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void llm_wl_clr(void) + +{ + uint16_t elem_index; + uint16_t uVar1; + + elem_index = 0; + do { + uVar1 = elem_index + 1; + llm_wlpriv_addr_set(elem_index,&llm_dflt_bdaddr); + elem_index = uVar1; + } while (uVar1 != 4); + elem_index = 0; + do { + uVar1 = elem_index + 1; + llm_wlpub_addr_set(elem_index,&llm_dflt_bdaddr); + elem_index = uVar1; + } while (uVar1 != 4); + _DAT_2800822e = _DAT_2800822e & 0xdfff; + _DAT_28008262 = _DAT_28008262 & 0xdfff; + _DAT_28008296 = _DAT_28008296 & 0xdfff; + llm_le_env.nb_dev_in_wl = '\0'; + llm_le_env.nb_dev_in_hw_wl = '\0'; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void llm_init(_Bool reset) + +{ + undefined3 in_register_00002029; + int iVar1; + ke_msg *msg; + + if (CONCAT31(in_register_00002029,reset) == 0) { + ble_ke_task_create(reset,&TASK_DESC_LLM); + ble_ke_event_callback_set('\x01',llm_encryption_done); + } + else { + if (llm_le_env.advertising_params != (advertising_pdu_params *)0x0) { + if ((llm_le_env.advertising_params)->adv_data_req != (ke_msg *)0x0) { + ble_ke_msg_free((llm_le_env.advertising_params)->adv_data_req); + } + if ((llm_le_env.advertising_params)->scan_rsp_req != (ke_msg *)0x0) { + ble_ke_msg_free((llm_le_env.advertising_params)->scan_rsp_req); + } + ble_ke_free(llm_le_env.advertising_params); + } + if (llm_le_env.scanning_params != (scanning_pdu_params *)0x0) { + ble_ke_free(llm_le_env.scanning_params); + } + lld_util_flush_list(&llm_le_env.adv_list); + lld_util_flush_list(&llm_le_env.cnx_list); + } + ble_ke_state_set(0,'\0'); + llm_le_env.test_mode.directtesttype = '\x03'; + llm_le_env.last_opcode = false; + llm_le_env.elt_coext_scan = (ea_elt_tag *)0x0; + llm_le_env.test_mode.end_of_tst = false; + iVar1 = bl_rand(); + llm_le_env.aa.intrand = (uint8_t)iVar1; + llm_le_env.aa.ct1_idx = '\0'; + llm_le_env.aa.ct2_idx = '\0'; + (*ble_memset_ptr)((void *)0x4201a38a,0xff,4); + llm_le_env.ch_map_assess.ch_map.map[4] = '\x1f'; + llm_le_env.elt = (ea_elt_tag *)0x0; + llm_wl_clr(); + llm_le_env.p256_byte_process_timeout = 0x10; + llm_le_env.cur_ecc_multiplication = LLM_ECC_IDLE; + llm_le_env.eventmask.mask[0] = '\x1f'; + (*ble_memset_ptr)((void *)0x4201a391,0,7); + llm_le_env.enc_pend = false; + llm_le_env.scanning_params = (scanning_pdu_params *)0x0; + ble_co_list_init(&llm_le_env.adv_list); + llm_le_env.advertising_params = (advertising_pdu_params *)0x0; + (*ble_memset_ptr)((void *)0x4201a3b3,0,6); + llm_le_env.public_add.addr[0] = (uint8_t)_DAT_28000024; + llm_le_env.public_add.addr[1] = (uint8_t)((uint)_DAT_28000024 >> 8); + llm_le_env.public_add.addr[2] = (uint8_t)((uint)_DAT_28000024 >> 0x10); + llm_le_env.public_add.addr[3] = (uint8_t)((uint)_DAT_28000024 >> 0x18); + llm_le_env.public_add.addr[4] = (uint8_t)_DAT_28000028; + llm_le_env.public_add.addr[5] = (uint8_t)((uint)_DAT_28000028 >> 8); + while (msg = (ke_msg *)ble_co_list_pop_front((co_list *)&llm_le_env), msg != (ke_msg *)0x0) { + ble_ke_msg_free(msg); + } + ble_co_list_init((co_list *)&llm_le_env); + ble_co_list_init(&llm_le_env.cnx_list); + memcpy(&llm_le_env.data_len_val,&llm_local_data_len_values,0xc); + llm_le_env.ch_map_assess._0_4_ = 0xaf60064; + llm_le_env.ch_map_assess._4_2_ = 0x8c4; + llm_le_env.ch_map_assess.llm_le_set_host_ch_class_cmd_sto = true; + llm_le_env.opcode2 = 0; + llm_le_env.state2 = '\0'; + llm_le_env.opcode = 0; + llm_le_env.state = '\0'; + return; +} + + + +void llm_wl_dev_add(bd_addr *bd_addr,uint8_t bd_addr_type) + +{ + uint16_t elem_index; + undefined3 in_register_0000202d; + + elem_index = llm_util_bd_addr_wl_position(&llm_dflt_bdaddr,bd_addr_type); + if (CONCAT31(in_register_0000202d,bd_addr_type) == 0) { + llm_wlpub_addr_set(elem_index,bd_addr); + } + else { + if (CONCAT31(in_register_0000202d,bd_addr_type) == 1) { + llm_wlpriv_addr_set(elem_index,bd_addr); + } + } + llm_le_env.nb_dev_in_hw_wl = llm_le_env.nb_dev_in_hw_wl + '\x01'; + return; +} + + + +void llm_wl_dev_rem(bd_addr *bd_addr,uint8_t bd_addr_type) + +{ + uint16_t elem_index; + undefined2 extraout_var; + undefined3 in_register_0000202d; + + elem_index = llm_util_bd_addr_wl_position(bd_addr,bd_addr_type); + if (CONCAT22(extraout_var,elem_index) < 4) { + if (CONCAT31(in_register_0000202d,bd_addr_type) == 1) { + llm_wlpriv_addr_set(elem_index,&llm_dflt_bdaddr); + } + else { + llm_wlpub_addr_set(elem_index,&llm_dflt_bdaddr); + } + llm_le_env.nb_dev_in_hw_wl = llm_le_env.nb_dev_in_hw_wl + -1; + } + return; +} + + + +uint8_t llm_wl_dev_add_hdl(bd_addr *bd_addr,uint8_t bd_addr_type) + +{ + _Bool _Var1; + uint8_t uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 in_register_0000202d; + + if (1 < CONCAT31(in_register_0000202d,bd_addr_type)) { + return '\x12'; + } + _Var1 = llm_util_bd_addr_in_wl(bd_addr,bd_addr_type,(_Bool *)0x0); + if (CONCAT31(extraout_var,_Var1) == 0) { + uVar2 = '\a'; + if (llm_le_env.nb_dev_in_wl < 4) { + uVar2 = llm_util_bl_check(bd_addr,bd_addr_type,(uint16_t *)0x0,'\x02',(_Bool *)0x0); + if (CONCAT31(extraout_var_00,uVar2) != 0xb) { + llm_wl_dev_add(bd_addr,bd_addr_type); + } + uVar2 = '\0'; + llm_le_env.nb_dev_in_wl = llm_le_env.nb_dev_in_wl + '\x01'; + } + } + else { + uVar2 = '\x12'; + } + return uVar2; +} + + + +uint8_t llm_wl_dev_rem_hdl(bd_addr *bd_addr,uint8_t bd_addr_type) + +{ + uint8_t uVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 in_register_0000202d; + _Bool a_Stack17 [4]; + _Bool in_black_list; + + if (1 < CONCAT31(in_register_0000202d,bd_addr_type)) { + return '\x12'; + } + _Var2 = llm_util_bd_addr_in_wl(bd_addr,bd_addr_type,a_Stack17); + if (CONCAT31(extraout_var,_Var2) == 0) { + uVar1 = '\x12'; + } + else { + if (a_Stack17[0] == false) { + llm_wl_dev_rem(bd_addr,bd_addr_type); + } + else { + llm_util_bl_check(bd_addr,bd_addr_type,(uint16_t *)0x0,'\x01',(_Bool *)0x0); + } + uVar1 = '\0'; + llm_le_env.nb_dev_in_wl = llm_le_env.nb_dev_in_wl + -1; + } + return uVar1; +} + + + +uint8_t llm_create_con(hci_le_create_con_cmd *param) + +{ + ushort uVar1; + uint8_t uVar2; + uint8_t uVar3; + _Bool _Var4; + byte bVar5; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + + uVar2 = llc_util_get_free_conhdl(&llm_le_env.conhdl_alloc); + if (CONCAT31(extraout_var,uVar2) != 0) { + return '\t'; + } + if (param->init_filt_policy == '\x01') { + if (llm_le_env.nb_dev_in_hw_wl == '\0') { + return (llm_le_env.nb_dev_in_wl == '\0') + '\v'; + } + } + else { + uVar3 = llm_util_bl_check(¶m->peer_addr,param->peer_addr_type,&llm_le_env.conhdl_alloc,'\0', + (_Bool *)0x0); + if (CONCAT31(extraout_var_00,uVar3) != 0) { + return uVar3; + } + } + if (param->scan_window <= param->scan_intv) { + uVar1 = param->con_intv_max; + if ((uint)uVar1 < (uint)param->con_intv_min) { + return '\x12'; + } + if (0x3ffc < (ushort)(param->scan_window - 4)) { + return '\x12'; + } + if (0x3ffc < (ushort)(param->scan_intv - 4)) { + return '\x12'; + } + if (param->ce_len_max < param->ce_len_min) { + return '\x12'; + } + if (param->con_intv_min < 6) { + return '\x12'; + } + if (0xc80 < uVar1) { + return '\x12'; + } + if (0xc76 < ((uint)param->superv_to - 10 & 0xffff)) { + return '\x12'; + } + if (499 < param->con_latency) { + return '\x12'; + } + if ((uint)param->superv_to << 2 <= ((uint)param->con_latency + 1) * (uint)uVar1) { + return '\x12'; + } + _Var4 = co_bdaddr_compare(&llm_le_env.rand_add,&co_null_bdaddr); + bVar5 = param->own_addr_type; + if ((CONCAT31(extraout_var_01,_Var4) != 0) && ((bVar5 & 1) != 0)) { + return '\x12'; + } + if ((llm_le_env.enh_priv_info & 1) == 0) { + if ((bVar5 & 2) != 0) { + return '\x12'; + } + } + else { + if ((bVar5 & 2) != 0) goto LAB_230163d2; + } + if ((param->peer_addr_type & 2) == 0) { +LAB_230163d2: + bVar5 = ble_ke_state_get(0); + ble_ke_state_set(0,bVar5 & 0xf0 | 2); + llm_le_env.elt_coext_scan = + (ea_elt_tag *)lld_con_start(param,0x4201a1f4,(uint)llm_le_env.conhdl_alloc); + if (llm_le_env.elt_coext_scan == (ea_elt_tag *)0x0) { + return '\x1f'; + } + return uVar2; + } + } + return '\x12'; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void llm_encryption_start(llm_enc_req *param) + +{ + _DAT_280000c4 = *(undefined4 *)(param->key).ltk; + _DAT_280000c8 = *(undefined4 *)((param->key).ltk + 4); + _DAT_280000cc = *(undefined4 *)((param->key).ltk + 8); + _DAT_280000d0 = *(undefined4 *)((param->key).ltk + 0xc); + (*ble_memcpy_ptr)((void *)0x2800806e,param->plain_data,0x10); + _DAT_280000d4 = 0x6e; + _DAT_280000c0 = 1; + llm_le_env.enc_pend = true; + rwip_prevent_sleep_set(0x10); + return; +} + + + +void llm_encryption_done(void) + +{ + ke_msg *msg; + undefined *param; + + msg = (ke_msg *)ble_co_list_pop_front((co_list *)&llm_le_env); + ble_ke_event_clear('\x01'); + if (msg != (ke_msg *)0x0) { + if ((msg->src_id & 0xff) == 1) { + param = (undefined *)ble_ke_msg_alloc(5,msg->src_id,0,0x11); + (*ble_memcpy_ptr)(param + 1,(void *)0x2800807e,0x10); + *param = 0; + ble_ke_msg_send(param); + } + else { + param = (undefined *)ble_ke_msg_alloc(0x801,0,0x2017,0x11); + (*ble_memcpy_ptr)(param + 1,(void *)0x2800807e,0x10); + *param = 0; + hci_send_2_host(param); + } + ble_ke_msg_free(msg); + if (llm_le_env.enc_req.first != (co_list_hdr *)0x0) { + llm_encryption_start((llm_enc_req *)(llm_le_env.enc_req.first + 3)); + return; + } + rwip_prevent_sleep_clear(0x10); + llm_le_env.enc_pend = false; + } + return; +} + + + +void hci_fc_init(void) + +{ + // WARNING: Could not recover jumptable at 0x230165a2. Too many branches + // WARNING: Treating indirect jump as call + (*ble_memset_ptr)(&hci_fc_env,0,10); + return; +} + + + +uint8_t hci_fc_acl_buf_size_set(uint16_t acl_pkt_len,uint16_t nb_acl_pkts) + +{ + undefined2 in_register_0000202a; + undefined2 in_register_0000202e; + uint8_t uVar1; + + uVar1 = '\x12'; + if (((CONCAT22(in_register_0000202a,acl_pkt_len) != 0) && + (CONCAT22(in_register_0000202e,nb_acl_pkts) != 0)) && + (uVar1 = '\x11', 0x3fc < CONCAT22(in_register_0000202a,acl_pkt_len))) { + uVar1 = '\0'; + hci_fc_env.host_set.acl_pkt_len = acl_pkt_len; + hci_fc_env.host_set.acl_pkt_nb = nb_acl_pkts; + } + return uVar1; +} + + + +uint8_t hci_fc_acl_en(_Bool flow_enable) + +{ + ke_state_t kVar1; + uint8_t uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + + kVar1 = ble_ke_state_get(1); + if ((CONCAT31(extraout_var,kVar1) == 0x7f) && + (kVar1 = ble_ke_state_get(0x101), CONCAT31(extraout_var_00,kVar1) == 0x7f)) { + uVar2 = '\0'; + hci_fc_env.host_set.acl_flow_cntl_en = flow_enable; + } + else { + uVar2 = '\f'; + } + return uVar2; +} + + + +void hci_fc_host_nb_acl_pkts_complete(uint16_t acl_pkt_nb) + +{ + undefined2 in_register_0000202a; + uint16_t uVar1; + + uVar1 = 0; + if (CONCAT22(in_register_0000202a,acl_pkt_nb) < (uint)hci_fc_env.cntr) { + uVar1 = hci_fc_env.cntr - acl_pkt_nb; + } + hci_fc_env.cntr = uVar1; + return; +} + + + +uint8_t hci_pack_bytes(uint8_t **pp_in,uint8_t **pp_out,uint8_t *p_in_end,uint8_t *p_out_end, + uint8_t len) + +{ + uint8_t uVar1; + undefined3 in_register_00002039; + uint uVar2; + + uVar2 = CONCAT31(in_register_00002039,len); + uVar1 = '\x01'; + if (*pp_in + uVar2 <= p_in_end) { + uVar1 = '\0'; + if (p_out_end != (uint8_t *)0x0) { + uVar1 = (p_out_end < *pp_out + uVar2) << 1; + (*ble_memcpy_ptr)(*pp_out,*pp_in,uVar2); + } + *pp_in = *pp_in + uVar2; + *pp_out = *pp_out + uVar2; + } + return uVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +uint8_t hci_host_nb_cmp_pkts_cmd_pkupk(uint8_t *out,uint8_t *in,uint16_t *out_len,uint16_t in_len) + +{ + uint8_t *p_in_end; + uint8_t uVar1; + uint8_t uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined2 in_register_00002036; + uint uVar3; + int iVar4; + uint8_t *p_out_end; + uint8_t *puStack56; + uint8_t *p_in; + uint8_t *p_out; + + if (in == (uint8_t *)0x0) { + *out_len = 0xe; + uVar2 = '\0'; + } + else { + p_in_end = in + CONCAT22(in_register_00002036,in_len); + p_out_end = out + *out_len; + puStack56 = in; + p_in = out; + uVar1 = hci_pack_bytes(&puStack56,&p_in,p_in_end,p_out_end,'\x01'); + uVar2 = uVar1; + if (CONCAT31(extraout_var,uVar1) == 0) { + uVar3 = 0; + while( true ) { + uVar2 = uVar1; + if ((*in <= uVar3) || (&DAT_0000000e < p_in + -(int)out)) break; + iVar4 = (uVar3 + 1) * 2; + p_in = out + iVar4; + uVar2 = hci_pack_bytes(&puStack56,&p_in,p_in_end,p_out_end,'\x02'); + if (CONCAT31(extraout_var_00,uVar2) != 0) break; + p_in = out + iVar4 + 6; + uVar2 = hci_pack_bytes(&puStack56,&p_in,p_in_end,p_out_end,'\x02'); + if (CONCAT31(extraout_var_01,uVar2) != 0) break; + uVar3 = uVar3 + 1 & 0xff; + } + } + *out_len = (short)p_in - (short)out; + } + return uVar2; +} + + + +// WARNING: Variable defined which should be unmapped: temp_out +// WARNING: Could not reconcile some variable overlaps + +uint8_t hci_le_adv_report_evt_pkupk(uint8_t *out,uint8_t *in,uint16_t *out_len,uint16_t in_len) + +{ + uint8_t *p_out_end; + uint8_t uVar1; + uint8_t uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + undefined3 extraout_var_05; + undefined3 extraout_var_06; + undefined2 in_register_00002036; + uint8_t **ppuVar3; + int iVar4; + uint8_t **ppuStack84; + uint8_t *p_in; + uint8_t *p_out; + hci_le_adv_report_evt temp_out; + + if (in == (uint8_t *)0x0) { + *out_len = 0; + uVar1 = '\0'; + } + else { + if (out == (uint8_t *)0x0) { + p_out_end = temp_out.adv_rep[0].data + 0x1c; + out = (uint8_t *)&p_out; + } + else { + p_out_end = out + *out_len; + } + in = in + CONCAT22(in_register_00002036,in_len); + ppuStack84 = (uint8_t **)out; + p_in = out; + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack84,&p_in,in,p_out_end,'\x01'); + if (CONCAT31(extraout_var,uVar1) == 0) { + ppuStack84 = (uint8_t **)((int)out + 1); + uVar2 = hci_pack_bytes((uint8_t **)&ppuStack84,&p_in,in,p_out_end,'\x01'); + uVar1 = uVar2; + if (CONCAT31(extraout_var_00,uVar2) == 0) { + ppuVar3 = (uint8_t **)((int)out + 10); + iVar4 = 0; + while (uVar1 = uVar2, iVar4 < (int)(uint)*(byte *)((int)out + 1)) { + ppuStack84 = ppuVar3 + -2; + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack84,&p_in,in,p_out_end,'\x01'); + if (CONCAT31(extraout_var_01,uVar1) != 0) break; + ppuStack84 = (uint8_t **)((int)ppuVar3 + -7); + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack84,&p_in,in,p_out_end,'\x01'); + if (CONCAT31(extraout_var_02,uVar1) != 0) break; + ppuStack84 = (uint8_t **)((int)ppuVar3 + -6); + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack84,&p_in,in,p_out_end,'\x06'); + if (CONCAT31(extraout_var_03,uVar1) != 0) break; + ppuStack84 = ppuVar3; + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack84,&p_in,in,p_out_end,'\x01'); + if (CONCAT31(extraout_var_04,uVar1) != 0) break; + ppuStack84 = (uint8_t **)((int)ppuVar3 + 1); + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack84,&p_in,in,p_out_end,*(uint8_t *)ppuVar3); + if (CONCAT31(extraout_var_05,uVar1) != 0) break; + ppuStack84 = ppuVar3 + 8; + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack84,&p_in,in,p_out_end,'\x01'); + ppuVar3 = (uint8_t **)((int)ppuVar3 + 0x29); + if (CONCAT31(extraout_var_06,uVar1) != 0) break; + iVar4 = iVar4 + 1; + } + } + } + *out_len = (short)p_in - (short)out; + } + return uVar1; +} + + + +// WARNING: Variable defined which should be unmapped: temp_out +// WARNING: Could not reconcile some variable overlaps + +uint8_t hci_le_dir_adv_report_evt_pkupk(uint8_t *out,uint8_t *in,uint16_t *out_len,uint16_t in_len) + +{ + uint8_t *p_out_end; + uint8_t uVar1; + uint8_t uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + undefined3 extraout_var_05; + undefined3 extraout_var_06; + undefined2 in_register_00002036; + uint8_t **ppuVar3; + int iVar4; + uint8_t **ppuStack60; + uint8_t *p_in; + uint8_t *p_out; + hci_le_dir_adv_rep_evt temp_out; + + if (in == (uint8_t *)0x0) { + *out_len = 0; + uVar1 = '\0'; + } + else { + if (out == (uint8_t *)0x0) { + p_out_end = temp_out.adv_rep[0].dir_addr.addr + 3; + out = (uint8_t *)&p_out; + } + else { + p_out_end = out + *out_len; + } + in = in + CONCAT22(in_register_00002036,in_len); + ppuStack60 = (uint8_t **)out; + p_in = out; + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack60,&p_in,in,p_out_end,'\x01'); + if (CONCAT31(extraout_var,uVar1) == 0) { + ppuStack60 = (uint8_t **)((int)out + 1); + uVar2 = hci_pack_bytes((uint8_t **)&ppuStack60,&p_in,in,p_out_end,'\x01'); + uVar1 = uVar2; + if (CONCAT31(extraout_var_00,uVar2) == 0) { + ppuVar3 = (uint8_t **)((int)out + 0x11); + iVar4 = 0; + while (uVar1 = uVar2, iVar4 < (int)(uint)*(byte *)((int)out + 1)) { + ppuStack60 = (uint8_t **)((int)ppuVar3 + -0xf); + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack60,&p_in,in,p_out_end,'\x01'); + if (CONCAT31(extraout_var_01,uVar1) != 0) break; + ppuStack60 = (uint8_t **)((int)ppuVar3 + -0xe); + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack60,&p_in,in,p_out_end,'\x01'); + if (CONCAT31(extraout_var_02,uVar1) != 0) break; + ppuStack60 = (uint8_t **)((int)ppuVar3 + -0xd); + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack60,&p_in,in,p_out_end,'\x06'); + if (CONCAT31(extraout_var_03,uVar1) != 0) break; + ppuStack60 = (uint8_t **)((int)ppuVar3 + -7); + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack60,&p_in,in,p_out_end,'\x01'); + if (CONCAT31(extraout_var_04,uVar1) != 0) break; + ppuStack60 = (uint8_t **)((int)ppuVar3 + -6); + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack60,&p_in,in,p_out_end,'\x06'); + if (CONCAT31(extraout_var_05,uVar1) != 0) break; + ppuStack60 = ppuVar3; + uVar1 = hci_pack_bytes((uint8_t **)&ppuStack60,&p_in,in,p_out_end,'\x01'); + ppuVar3 = ppuVar3 + 4; + if (CONCAT31(extraout_var_06,uVar1) != 0) break; + iVar4 = iVar4 + 1; + } + } + } + *out_len = (short)p_in - (short)out; + } + return uVar1; +} + + + +hci_cmd_desc_tag * hci_look_for_cmd_desc(uint16_t opcode) + +{ + undefined2 in_register_0000202a; + hci_cmd_desc_tag *phVar1; + uint16_t uVar2; + uint uVar3; + int iVar4; + + uVar3 = CONCAT22(in_register_0000202a,opcode) >> 10; + if (uVar3 == 1) { + iVar4 = 0; + } + else { + if (uVar3 == 3) { + iVar4 = 1; + } + else { + if (uVar3 == 4) { + iVar4 = 2; + } + else { + if (uVar3 == 5) { + iVar4 = 3; + } + else { + if (uVar3 == 8) { + iVar4 = 4; + } + else { + if (uVar3 != 0x3f) { + return (hci_cmd_desc_tag *)0x0; + } + iVar4 = 5; + } + } + } + } + } + phVar1 = hci_cmd_desc_root_tab[iVar4].cmd_desc_tab; + uVar2 = 0; + if (phVar1 != (hci_cmd_desc_tag *)0x0) { + while( true ) { + if (uVar2 == hci_cmd_desc_root_tab[iVar4].nb_cmds) { + return (hci_cmd_desc_tag *)0x0; + } + if ((phVar1->opcode & 0x3ff) == (opcode & 0x3ff)) break; + uVar2 = uVar2 + 1; + phVar1 = phVar1 + 1; + } + return phVar1; + } + return (hci_cmd_desc_tag *)0x0; +} + + + +hci_evt_desc_tag * hci_look_for_evt_desc(uint8_t code) + +{ + undefined3 in_register_00002029; + hci_evt_desc_tag *phVar1; + int iVar2; + + phVar1 = hci_evt_desc_tab; + iVar2 = 0; + do { + if ((uint)phVar1->code == CONCAT31(in_register_00002029,code)) { + return hci_evt_desc_tab + iVar2; + } + iVar2 = iVar2 + 1; + phVar1 = phVar1 + 1; + } while (iVar2 != 9); + return (hci_evt_desc_tag *)0x0; +} + + + +hci_evt_desc_tag * hci_look_for_le_evt_desc(uint8_t subcode) + +{ + undefined3 in_register_00002029; + hci_evt_desc_tag *phVar1; + int iVar2; + + phVar1 = hci_evt_le_desc_tab; + iVar2 = 0; + do { + if ((uint)phVar1->code == CONCAT31(in_register_00002029,subcode)) { + return hci_evt_le_desc_tab + iVar2; + } + iVar2 = iVar2 + 1; + phVar1 = phVar1 + 1; + } while (iVar2 != 0xc); + return (hci_evt_desc_tag *)0x0; +} + + + +void hci_tl_init(_Bool reset) + +{ + undefined3 in_register_00002029; + + if (CONCAT31(in_register_00002029,reset) == 0) { + (*ble_memset_ptr)(&hci_tl_env,0,0x1c); + ble_co_list_init((co_list *)&hci_tl_env); + ble_co_list_init(&hci_tl_env.acl_queue); + hci_tl_env.tx_state = '\x01'; + } + hci_tl_env.nb_h2c_cmd_pkts = '\x05'; + return; +} + + + +uint16_t hci_util_read_array_size(char **fmt_cursor) + +{ + byte *pbVar1; + uint uVar2; + + pbVar1 = (byte *)*fmt_cursor; + *(byte **)fmt_cursor = pbVar1 + 1; + uVar2 = (uint)*pbVar1 - 0x30; + while( true ) { + pbVar1 = (byte *)*fmt_cursor; + if (9 < (byte)(*pbVar1 - 0x30)) break; + *(byte **)fmt_cursor = pbVar1 + 1; + uVar2 = (uVar2 & 0xffff) * 10 + ((uint)*pbVar1 - 0x30); + } + return (uint16_t)(uVar2 & 0xffff); +} + + + +HCI_PACK_STATUS hci_util_pack(uint8_t *inout,uint16_t *inout_len,char *format) + +{ + char cVar1; + undefined2 uVar2; + uint8_t *puVar3; + undefined4 *puVar4; + uint16_t uVar5; + undefined2 extraout_var; + uint8_t *puVar6; + char *pcVar7; + uint uVar8; + undefined4 *puVar9; + undefined2 *puVar10; + undefined4 *puVar11; + undefined4 uVar12; + HCI_PACK_STATUS HVar13; + undefined4 *puVar14; + char *pcStack68; + char *cursor; + + puVar14 = (undefined4 *)(inout + *inout_len); + HVar13 = HCI_PACK_OK; + puVar6 = inout; + puVar9 = (undefined4 *)inout; + pcStack68 = format; +LAB_23016b30: + do { + do { + while( true ) { + while( true ) { + while( true ) { + puVar4 = puVar9; + puVar3 = puVar6; + if (*pcStack68 == '\0') { + if (HVar13 == HCI_PACK_OK) { + *inout_len = (short)puVar3 - (short)inout; + } + return HVar13; + } + if (HVar13 != HCI_PACK_OK) { + return HVar13; + } + uVar8 = 0; + if ((byte)(*pcStack68 - 0x30U) < 10) { + uVar5 = hci_util_read_array_size(&pcStack68); + uVar8 = CONCAT22(extraout_var,uVar5); + } + pcVar7 = pcStack68 + 1; + cVar1 = *pcStack68; + puVar6 = puVar3; + pcStack68 = pcVar7; + if (cVar1 != 'H') break; + puVar10 = (undefined2 *)((uint)((int)puVar4 + 1) & 0xfffffffe); + puVar9 = (undefined4 *)(puVar10 + 1); + if (inout != (uint8_t *)0x0) { + if (puVar14 < puVar9) goto LAB_23016c28; + uVar2 = *puVar10; + *puVar3 = (uint8_t)uVar2; + puVar3[1] = (uint8_t)((ushort)uVar2 >> 8); + } + puVar6 = puVar3 + 2; + } + if (cVar1 != 'L') break; + puVar11 = (undefined4 *)((uint)((int)puVar4 + 3) & 0xfffffffc); + puVar9 = puVar11 + 1; + if (inout != (uint8_t *)0x0) { + if (puVar14 < puVar9) goto LAB_23016c28; + uVar12 = *puVar11; + *puVar3 = (uint8_t)uVar12; + puVar3[1] = (uint8_t)((uint)uVar12 >> 8); + puVar3[2] = (uint8_t)((uint)uVar12 >> 0x10); + puVar3[3] = (uint8_t)((uint)uVar12 >> 0x18); + } + puVar6 = puVar3 + 4; + } + if (cVar1 == 'B') break; + HVar13 = HCI_PACK_WRONG_FORMAT; + puVar9 = puVar4; + } + puVar9 = (undefined4 *)((int)puVar4 + 1); + if (inout != (uint8_t *)0x0) { + if (puVar14 < puVar9) goto LAB_23016c28; + *puVar3 = *(uint8_t *)puVar4; + } + puVar6 = puVar3 + 1; + } while (uVar8 < 2); + if (inout != (uint8_t *)0x0) { + puVar4 = puVar9; + if (puVar14 < (undefined4 *)((int)puVar4 + uVar8)) { +LAB_23016c28: + HVar13 = HCI_PACK_IN_BUF_OVFLW; + puVar9 = puVar4; + goto LAB_23016b30; + } + (*ble_memcpy_ptr)(puVar6,puVar9,uVar8 - 1); + } + puVar6 = puVar3 + uVar8; + puVar9 = (undefined4 *)((int)puVar4 + uVar8); + } while( true ); +} + + + +HCI_PACK_STATUS +hci_util_unpack(uint8_t *out,uint8_t *in,uint16_t *out_len,uint16_t in_len,char *format) + +{ + char cVar1; + bool bVar2; + bool bVar3; + undefined4 *puVar4; + undefined4 *puVar5; + undefined4 *puVar6; + uint16_t uVar7; + undefined2 extraout_var; + undefined2 in_register_00002036; + char *pcVar8; + undefined2 *puVar9; + HCI_PACK_STATUS HVar10; + undefined4 *puVar11; + uint uVar12; + undefined4 *puVar13; + char *pcStack68; + char *cursor; + + puVar13 = (undefined4 *)(in + CONCAT22(in_register_00002036,in_len)); + puVar11 = (undefined4 *)(out + *out_len); + bVar2 = in != (uint8_t *)0x0; + bVar3 = out != (uint8_t *)0x0; + HVar10 = 0; + puVar6 = (undefined4 *)out; + pcStack68 = format; +LAB_23016c7e: + do { + puVar5 = puVar6; + puVar4 = (undefined4 *)in; + if ((*pcStack68 == '\0') || (HVar10 != HCI_PACK_OK)) { + if (puVar13 < puVar4) { + HVar10 = HCI_PACK_IN_BUF_OVFLW; + } + *out_len = (short)puVar5 - (short)out; + return HVar10; + } + uVar12 = 0; + if ((byte)(*pcStack68 - 0x30U) < 10) { + uVar7 = hci_util_read_array_size(&pcStack68); + uVar12 = CONCAT22(extraout_var,uVar7); + } + pcVar8 = pcStack68 + 1; + cVar1 = *pcStack68; + puVar6 = puVar5; + pcStack68 = pcVar8; + if (cVar1 != 'H') { + if (cVar1 == 'L') { + puVar5 = (undefined4 *)((uint)((int)puVar5 + 3) & 0xfffffffc); + if (bVar3 && bVar2) { + if (puVar13 < puVar4 + 1) { +LAB_23016db2: + HVar10 = 1; + in = (uint8_t *)puVar4; + goto LAB_23016c7e; + } + if (puVar11 < puVar5 + 1) goto LAB_23016dba; + *puVar5 = *puVar4; + } + in = (uint8_t *)(puVar4 + 1); + puVar6 = puVar5 + 1; + goto LAB_23016c7e; + } + if (cVar1 == 'B') { + in = (uint8_t *)((int)puVar4 + 1); + if (bVar3 && bVar2) { + if (puVar13 < in) goto LAB_23016db2; + if (puVar11 < (undefined4 *)((int)puVar5 + 1)) goto LAB_23016dba; + *(undefined *)puVar5 = *(undefined *)puVar4; + } + puVar6 = (undefined4 *)((int)puVar5 + 1); + if (1 < uVar12) { + if (bVar3 && bVar2) { + puVar4 = (undefined4 *)in; + if (puVar13 < (undefined4 *)((int)puVar4 + uVar12)) goto LAB_23016db2; + if (puVar11 < (undefined4 *)((int)puVar5 + uVar12)) goto LAB_23016dba; + (*ble_memcpy_ptr)(puVar6,in,uVar12 - 1); + } + in = (uint8_t *)(undefined4 *)((int)puVar4 + uVar12); + puVar6 = (undefined4 *)((int)puVar5 + uVar12); + } + } + else { + HVar10 = 3; + in = (uint8_t *)puVar4; + } + goto LAB_23016c7e; + } + puVar9 = (undefined2 *)((uint)((int)puVar5 + 1) & 0xfffffffe); + if (bVar3 && bVar2) { + if (puVar13 < (undefined4 *)((int)puVar4 + 2)) goto LAB_23016db2; + if (puVar11 < puVar9 + 1) { +LAB_23016dba: + HVar10 = 2; + in = (uint8_t *)puVar4; + goto LAB_23016c7e; + } + *puVar9 = *(undefined2 *)puVar4; + } + in = (uint8_t *)(undefined4 *)((int)puVar4 + 2); + puVar6 = (undefined4 *)(puVar9 + 1); + } while( true ); +} + + + +// WARNING: Variable defined which should be unmapped: ret_par_len + +uint8_t * hci_build_cc_evt(ke_msg *msg,int8_t nb_h2c_cmd_pkts) + +{ + uint16_t opcode; + hci_cmd_desc_tag *phVar1; + code *format; + uint16_t auStack18 [2]; + uint16_t ret_par_len; + + opcode = msg->src_id; + auStack18[0] = msg->param_len; + phVar1 = hci_look_for_cmd_desc(opcode); + if ((phVar1 == (hci_cmd_desc_tag *)0x0) || (auStack18[0] == 0)) { + if (opcode != 0) { + *(undefined *)msg->param = 1; + } + } + else { + format = (code *)phVar1->ret_par_fmt; + if (format != (code *)0x0) { + if ((char)phVar1->dest_field < '\0') { + (*format)(msg->param,auStack18); + } + else { + hci_util_pack((uint8_t *)msg->param,auStack18,(char *)format); + } + } + } + msg->param_len = auStack18[0]; + return (uint8_t *)((int)&msg->dest_id + 1); +} + + + +uint8_t * hci_build_evt(ke_msg *msg) + +{ + hci_evt_desc_tag *phVar1; + code *format; + uint16_t auStack18 [2]; + uint16_t par_len; + + auStack18[0] = msg->param_len; + phVar1 = hci_look_for_evt_desc(*(uint8_t *)&msg->src_id); + if (phVar1 != (hci_evt_desc_tag *)0x0) { + format = (code *)phVar1->par_fmt; + if (format != (code *)0x0) { + if (phVar1->special_pack == '\0') { + hci_util_pack((uint8_t *)msg->param,auStack18,(char *)format); + } + else { + (*format)(msg->param,auStack18,(uint)auStack18[0]); + } + } + msg->param_len = auStack18[0]; + } + return (uint8_t *)&msg->param_len; +} + + + +uint8_t * hci_build_le_evt(ke_msg *msg) + +{ + HCI_PACK_STATUS HVar1; + hci_evt_desc_tag *phVar2; + undefined3 extraout_var; + uint uVar3; + code *format; + uint16_t auStack18 [2]; + uint16_t par_len; + + auStack18[0] = msg->param_len; + phVar2 = hci_look_for_le_evt_desc(*(uint8_t *)msg->param); + if ((phVar2 != (hci_evt_desc_tag *)0x0) && + (format = (code *)phVar2->par_fmt, format != (code *)0x0)) { + if (phVar2->special_pack == '\0') { + HVar1 = hci_util_pack((uint8_t *)msg->param,auStack18,(char *)format); + uVar3 = CONCAT31(extraout_var,HVar1); + } + else { + uVar3 = (*format)(msg->param,auStack18,(uint)auStack18[0]); + uVar3 = uVar3 & 0xff; + } + if (uVar3 == 0) { + msg->param_len = auStack18[0]; + } + } + return (uint8_t *)&msg->param_len; +} + + + +uint8_t * hci_build_acl_rx_data(ke_msg *msg) + +{ + byte bVar1; + undefined2 uVar2; + uint8_t *puVar3; + uint uVar4; + + puVar3 = em_buf_rx_buff_addr_get((ushort)*(byte *)((int)&msg[1].hdr.next + 2)); + bVar1 = *(byte *)((int)msg->param + 2); + uVar4 = (uint)*(ushort *)msg->param & 0xfff; + puVar3[-4] = (uint8_t)uVar4; + puVar3[-3] = (uint8_t)((((uint)bVar1 << 0xc | uVar4) << 0x10) >> 0x18); + uVar2 = *(undefined2 *)&msg[1].hdr.next; + puVar3[-2] = (uint8_t)uVar2; + puVar3[-1] = (uint8_t)((ushort)uVar2 >> 8); + return puVar3 + -4; +} + + + +// WARNING: Type propagation algorithm not settling + +co_list_hdr * +ble_ke_queue_extract + (co_list *queue,anon_subr__Bool_co_list_hdr_ptr_uint32_t_conflict *func,uint32_t arg) + +{ + co_list_hdr cVar1; + _Bool _Var2; + uint32_t uVar3; + undefined3 extraout_var; + co_list_hdr cStack36; + co_list_hdr *element; + + uVar3 = (*_rom_patch_hook)(&cStack36,queue,func,arg,_rom_patch_hook); + if (uVar3 == 0) { + cVar1 = (co_list_hdr)0x0; + cStack36 = (co_list_hdr)queue->first; + while (cStack36 != (co_list_hdr)0x0) { + _Var2 = (*func)((co_list_hdr *)cStack36,arg); + if (CONCAT31(extraout_var,_Var2) != 0) { + if (cVar1 == (co_list_hdr)0x0) { + *(co_list_hdr *)&queue->first = *(co_list_hdr *)cStack36; + } + else { + *(co_list_hdr *)cVar1 = *(co_list_hdr *)cStack36; + } + if (*(co_list_hdr *)cStack36 != (co_list_hdr)0x0) { + *(co_list_hdr *)cStack36 = (co_list_hdr)0x0; + return (co_list_hdr *)cStack36; + } + *(co_list_hdr *)&((co_list_hdr *)&queue->last)->next = cVar1; + return (co_list_hdr *)cStack36; + } + cVar1 = cStack36; + cStack36 = *(co_list_hdr *)cStack36; + } + } + return (co_list_hdr *)cStack36; +} + + + +// WARNING: Type propagation algorithm not settling + +void ble_ke_queue_insert(co_list *queue,co_list_hdr *element, + anon_subr__Bool_co_list_hdr_ptr_co_list_hdr_ptr *cmp) + +{ + co_list_hdr cVar1; + co_list_hdr cVar2; + _Bool _Var3; + uint32_t uVar4; + undefined3 extraout_var; + co_list_hdr cVar5; + + uVar4 = (*_rom_patch_hook)((void *)0x0,queue,element,cmp,_rom_patch_hook); + if (uVar4 == 0) { + cVar1 = (co_list_hdr)queue->first; + cVar5 = (co_list_hdr)(co_list_hdr *)0x0; + while (cVar2 = cVar1, cVar2 != (co_list_hdr)0x0) { + _Var3 = (*cmp)(element,(co_list_hdr *)cVar2); + if (CONCAT31(extraout_var,_Var3) != 0) goto LAB_23016fe2; + cVar1 = *(co_list_hdr *)cVar2; + cVar5 = cVar2; + } + queue->last = element; +LAB_23016fe2: + *(co_list_hdr *)&element->next = cVar2; + if (cVar5 == (co_list_hdr)0x0) { + queue->first = element; + } + else { + ((co_list_hdr *)cVar5)->next = element; + } + } + return; +} + + + +_Bool ble_cmp_dest_id(co_list_hdr *msg,uint32_t dest_id) + +{ + uint32_t uVar1; + bool abStack17 [4]; + _Bool result; + + uVar1 = (*_rom_patch_hook)(abStack17,msg,dest_id,_rom_patch_hook); + if (uVar1 == 0) { + abStack17[0] = (uint)*(ushort *)((int)&msg[1].next + 2) == dest_id; + } + return (_Bool)abStack17[0]; +} + + +/* +Unable to decompile 'ble_ke_task_saved_update' +Cause: Exception while decompiling 2301703c: Decompiler process died + +*/ + + +ke_msg_func_t * ble_ke_handler_search(ke_msg_id_t msg_id,ke_state_handler *state_handler) + +{ + ushort uVar1; + undefined2 in_register_0000202a; + uint32_t uVar2; + uint uVar3; + ke_msg_func_t *pkStack20; + ke_msg_func_t *func; + + uVar2 = (*_rom_patch_hook)(&pkStack20,CONCAT22(in_register_0000202a,msg_id),state_handler, + _rom_patch_hook); + if (uVar2 == 0) { + uVar3 = (uint)state_handler->msg_cnt; + do { + uVar3 = uVar3 - 1; + if (uVar3 == 0xffffffff) { + return (ke_msg_func_t *)0x0; + } + uVar1 = state_handler->msg_table[uVar3].id; + } while ((CONCAT22(in_register_0000202a,msg_id) != (uint)uVar1) && (uVar1 != 0xffff)); + pkStack20 = state_handler->msg_table[uVar3].func; + } + return pkStack20; +} + + + +// WARNING: Variable defined which should be unmapped: func + +ke_msg_func_t * ble_ke_task_handler_get(ke_msg_id_t msg_id,ke_task_id_t task_id) + +{ + uint uVar1; + ke_task_desc *pkVar2; + undefined2 in_register_0000202a; + uint32_t uVar3; + undefined2 in_register_0000202e; + ke_msg_func_t *pkStack20; + ke_msg_func_t *func; + + pkStack20 = (ke_msg_func_t *)0x0; + uVar3 = (*_rom_patch_hook)(&pkStack20,CONCAT22(in_register_0000202a,msg_id), + CONCAT22(in_register_0000202e,task_id),_rom_patch_hook); + if (uVar3 == 0) { + pkVar2 = ble_ke_task_env.task_list[(uint)task_id & 0xff].p_desc; + if ((pkVar2->idx_max != 0) && + (uVar1 = CONCAT22(in_register_0000202e,task_id) >> 8, uVar1 < pkVar2->idx_max)) { + if (pkVar2->state_handler != (ke_state_handler *)0x0) { + pkStack20 = ble_ke_handler_search(msg_id,pkVar2->state_handler + pkVar2->state[uVar1]); + } + if ((pkStack20 == (ke_msg_func_t *)0x0) && + (pkVar2->default_handler != (ke_state_handler *)0x0)) { + pkStack20 = ble_ke_handler_search(msg_id,pkVar2->default_handler); + } + } + } + return pkStack20; +} + + +/* +Unable to decompile 'ble_ke_task_schedule' +Cause: Exception while decompiling 23017178: Decompiler process died + +*/ + + +void ble_ke_task_init(void) + +{ + uint32_t uVar1; + + uVar1 = (*_rom_patch_hook)((void *)0x0,_rom_patch_hook); + if (uVar1 == 0) { + (*ble_memset_ptr)(&ble_ke_task_env,0,0x14); + ble_ke_event_callback_set('\x02',ble_ke_task_schedule); + return; + } + return; +} + + +/* +Unable to decompile 'ble_ke_task_create' +Cause: Exception while decompiling 2301725c: Decompiler process died + +*/ + + +void ble_ke_state_set(ke_task_id_t id,ke_state_t state_id) + +{ + undefined2 in_register_0000202a; + uint32_t uVar1; + undefined3 in_register_0000202d; + uint uVar2; + ke_task_desc *pkVar3; + byte *pbVar4; + + uVar1 = (*_rom_patch_hook)((void *)0x0,CONCAT22(in_register_0000202a,id), + CONCAT31(in_register_0000202d,state_id),_rom_patch_hook); + if (uVar1 == 0) { + if (((uint)id & 0xff) < 5) { + pkVar3 = ble_ke_task_env.task_list[(uint)id & 0xff].p_desc; + uVar2 = CONCAT22(in_register_0000202a,id) >> 8; + if ((uVar2 < pkVar3->idx_max) && + (pbVar4 = pkVar3->state + uVar2, (uint)*pbVar4 != CONCAT31(in_register_0000202d,state_id))) + { + *pbVar4 = state_id; + ble_ke_task_saved_update(id); + return; + } + } + else { + ebreak(); + } + } + return; +} + + +/* +Unable to decompile 'ble_ke_state_get' +Cause: Exception while decompiling 2301732c: Decompiler process died + +*/ + +/* +Unable to decompile 'llc_llcp_send' +Cause: Exception while decompiling 2301738e: Decompiler process died + +*/ + + +undefined4 llcp_ping_rsp_handler(int param_1,ke_task_id_t param_2) + +{ + llc_env_tag *plVar1; + byte bVar2; + + bVar2 = ble_ke_state_get(param_2); + plVar1 = llc_env[param_1]; + if ((plVar1->encryption_state & 8) == 0) { + if (((bVar2 & 1) != 0) && (plVar1->loc_proc_state == '\x05')) { + ble_ke_state_set(param_2,bVar2 & 0xfe); + plVar1->loc_proc_state = '\0'; + ble_ke_timer_clear(0x102,param_2); + } + } + else { + llc_util_dicon_procedure((uint16_t)param_1,'='); + } + return 0; +} + + + +int llcp_terminate_ind_handler + (uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_terminate_ind *param) + +{ + uint8_t uVar1; + undefined2 in_register_0000202a; + undefined3 extraout_var; + llc_env_tag *plVar2; + + ble_ke_timer_clear(0x102,dest_id); + plVar2 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + plVar2->disc_reason = param->err_code; + plVar2->llc_status = plVar2->llc_status | 0x200; + ble_ke_state_set(dest_id,'\x0f'); + uVar1 = lld_get_mode(conhdl); + if (CONCAT31(extraout_var,uVar1) == 4) { + llc_util_dicon_procedure(conhdl,param->err_code); + } + return 0; +} + + +/* +Unable to decompile 'llcp_enc_rsp_handler' +Cause: Exception while decompiling 2301750c: Decompiler process died + +*/ + + +void llc_llcp_reject_ind(int param_1,ke_task_id_t param_2,int param_3,int param_4) + +{ + byte bVar1; + uint8_t uVar2; + _Bool _Var3; + uint16_t conhdl; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + llc_env_tag *plVar4; + + bVar1 = ble_ke_state_get(param_2); + plVar4 = llc_env[param_1]; + ble_ke_timer_clear(0x102,param_2); + conhdl = (uint16_t)param_1; + if ((bVar1 & 1) == 0) { + if ((((bVar1 & 2) != 0) && (param_4 != 0)) && ((llc_env[param_1]->encryption_state & 8) == 0)) { + if (plVar4->rem_proc_state != '\x03') { + return; + } + ble_ke_state_set(param_2,bVar1 & 0xfd); + plVar4->rem_proc_state = '\0'; + return; + } +LAB_23017802: + if ((llc_env[param_1]->encryption_state & 8) == 0) { + return; + } + llc_util_dicon_procedure(conhdl,'='); + return; + } + switch((uint)plVar4->loc_proc_state - 4 & 0xff) { + case 0: + if ((llc_env[param_1]->encryption_state & 8) != 0) goto LAB_23017802; + ble_ke_timer_clear(0x102,param_2); + break; + case 1: + break; + case 2: + case 5: + goto LAB_230177a4; + case 3: + if ((param_4 == 0) || ((llc_env[param_1]->encryption_state & 8) != 0)) goto LAB_23017802; + ble_ke_timer_clear(0x102,param_2); + if ((param_3 == 0x1a) && (uVar2 = lld_get_mode(conhdl), CONCAT31(extraout_var_00,uVar2) == 3)) { + *(undefined *)llc_env[param_1]->operation[0] = 2; + ble_ke_msg_send(); + return; + } + if ((plVar4->llc_status & 0x40) != 0) { + plVar4->llc_status = plVar4->llc_status & 0xffbf; + _Var3 = llm_util_check_evt_mask('\x02'); + if (CONCAT31(extraout_var_01,_Var3) != 0) { + llc_con_update_complete_send((uint8_t)param_3,conhdl,(lld_evt_tag *)&plVar4->elt->env); + } + } + llc_util_clear_operation_ptr(param_1,0); + break; + default: + goto LAB_23017802; + case 9: + case 10: + case 0xb: + case 0xc: + ble_ke_timer_clear(0x102,param_2); + uVar2 = lld_get_mode(conhdl); + if (CONCAT31(extraout_var,uVar2) != 3) { + return; + } + if ((llc_env[param_1]->encryption_state & 0x10) != 0) { + return; + } + llc_env[param_1]->encryption_state = '\0'; + llc_common_enc_change_evt_send(conhdl,'\0',(uint8_t)param_3); + ble_ke_state_set(param_2,bVar1 & 0xfe); + plVar4->loc_proc_state = '\0'; + ble_ke_state_set(param_2,bVar1 & 0xfa); + return; + } + ble_ke_state_set(param_2,bVar1 & 0xfe); + plVar4->loc_proc_state = '\0'; +LAB_230177a4: + return; +} + + + +int llcp_reject_ind_ext_handler + (uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_reject_ind_ext *param) + +{ + undefined2 in_register_0000202a; + + llc_llcp_reject_ind(CONCAT22(in_register_0000202a,conhdl),(uint)param->err_code,1); + return 0; +} + + + +int llcp_reject_ind_handler + (uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_reject_ind *param) + +{ + undefined2 in_register_0000202a; + + llc_llcp_reject_ind(CONCAT22(in_register_0000202a,conhdl),(uint)param->err_code,0); + return 0; +} + + +/* +Unable to decompile 'llcp_pause_enc_req_handler' +Cause: Exception while decompiling 23017858: Decompiler process died + +*/ + + +undefined4 llcp_start_enc_req_handler(int param_1,ke_task_id_t param_2) + +{ + uint8_t uVar1; + llc_env_tag *plVar2; + byte bVar3; + + bVar3 = ble_ke_state_get(param_2); + plVar2 = llc_env[param_1]; + if (((plVar2->encryption_state & 8) != 0) && ((plVar2->loc_proc_state - 0xe & 0xfd) != 0)) { + llc_util_dicon_procedure((uint16_t)param_1,'='); + } + uVar1 = plVar2->loc_proc_state; + if ((bVar3 & 1) == 0) { + if (uVar1 == '\x0e') goto LAB_230179b4; + } + else { + if (uVar1 == '\x0e') { +LAB_230179b4: + plVar2->loc_proc_state = '\x0f'; + return 0; + } + if (uVar1 != '\x10') { + return 0; + } + } + plVar2->loc_proc_state = '\x11'; + ble_ke_msg_send_basic(0x106,param_2,param_2); + return 0; +} + + +/* +Unable to decompile 'llcp_enc_req_handler' +Cause: Exception while decompiling 230179ca: Decompiler process died + +*/ + + +undefined4 llcp_unknown_rsp_handler(int param_1,ke_task_id_t param_2,int param_3) + +{ + llc_env_tag *plVar1; + byte bVar2; + uint8_t uVar3; + _Bool _Var4; + uint16_t conhdl; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined *param; + + bVar2 = ble_ke_state_get(param_2); + plVar1 = llc_env[param_1]; + conhdl = (uint16_t)param_1; + if (((plVar1->encryption_state & 8) != 0) && (plVar1->loc_proc_state != '\r')) { + llc_util_dicon_procedure(conhdl,'='); + return 0; + } + if ((bVar2 & 1) == 0) { + return 0; + } + switch((uint)plVar1->loc_proc_state - 1 & 0xff) { + case 0: + if (*(char *)(param_3 + 1) != '\x0e') { + return 0; + } + ble_ke_timer_clear(0x102,param_2); + llc_feats_rd_event_send('\x1a',conhdl,&plVar1->feats_used); + break; + default: + goto switchD_23017b54_caseD_1; + case 3: + if (*(char *)(param_3 + 1) != '\x14') { + return 0; + } + ble_ke_timer_clear(0x102,param_2); + (plVar1->data_len_ext_info).send_req_not_allowed = true; + _Var4 = llm_util_check_evt_mask('\x06'); + if ((CONCAT31(extraout_var_01,_Var4) != 0) && + (((plVar1->data_len_ext_info).data_len_ext_flag & 2) == 0)) { + param = (undefined *)ble_ke_msg_alloc(0x804,conhdl,0x3e,0xc); + *param = 7; + *(uint16_t *)(param + 2) = conhdl; + *(uint16_t *)(param + 8) = (plVar1->data_len_ext_info).conn_eff_max_rx_octets; + *(uint16_t *)(param + 10) = (plVar1->data_len_ext_info).conn_eff_max_rx_time; + *(uint16_t *)(param + 4) = (plVar1->data_len_ext_info).conn_eff_max_tx_octets; + *(uint16_t *)(param + 6) = (plVar1->data_len_ext_info).conn_eff_max_tx_time; + hci_send_2_host(param); + (plVar1->data_len_ext_info).data_len_ext_flag = + (plVar1->data_len_ext_info).data_len_ext_flag | 2; + } + break; + case 4: + if (*(char *)(param_3 + 1) != '\x12') { + return 0; + } + ble_ke_state_set(param_2,bVar2 & 0xfe); + plVar1->loc_proc_state = '\0'; + ble_ke_timer_clear(0x102,param_2); + return 0; + case 6: + if (*(char *)(param_3 + 1) != '\x0f') { + return 0; + } + ble_ke_timer_clear(0x102,param_2); + plVar1->peer_sup_conn_param_req = false; + uVar3 = lld_get_mode(conhdl); + if (CONCAT31(extraout_var,uVar3) == 3) { + *(undefined *)llc_env[param_1]->operation[0] = 2; + ble_ke_msg_send(); + return 0; + } + if ((plVar1->llc_status & 0x40) != 0) { + plVar1->llc_status = plVar1->llc_status & 0xffbf; + _Var4 = llm_util_check_evt_mask('\x02'); + if (CONCAT31(extraout_var_00,_Var4) != 0) { + llc_con_update_complete_send('\x1a',conhdl,(lld_evt_tag *)&plVar1->elt->env); + } + } + llc_util_clear_operation_ptr(param_1,0); + break; + case 0xc: + if ((plVar1->encryption_state & 0x10) != 0) { + return 0; + } + plVar1->encryption_state = '\0'; + llc_common_enc_change_evt_send(conhdl,'\0','\x1a'); + } + ble_ke_state_set(param_2,bVar2 & 0xfe); + plVar1->loc_proc_state = '\0'; +switchD_23017b54_caseD_1: + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void llc_llcp_version_ind_pdu_send(uint16_t conhdl) + +{ + undefined4 uStack24; + llcp_vers_ind pdu; + + uStack24 = 0x7af090c; + pdu._0_2_ = 0x321; + llc_llcp_send((uint8_t)conhdl,&uStack24,'\f'); + return; +} + + + +undefined4 llcp_vers_ind_handler(int param_1,ke_task_id_t param_2,int param_3) + +{ + ushort uVar1; + uint16_t uVar2; + llc_env_tag *plVar3; + byte bVar4; + uint16_t conhdl; + + bVar4 = ble_ke_state_get(param_2); + plVar3 = llc_env[param_1]; + conhdl = (uint16_t)param_1; + if ((plVar3->encryption_state & 8) == 0) { + uVar1 = plVar3->llc_status; + (plVar3->peer_version).vers = *(uint8_t *)(param_3 + 1); + (plVar3->peer_version).compid = *(uint16_t *)(param_3 + 2); + uVar2 = *(uint16_t *)(param_3 + 4); + plVar3->llc_status = uVar1 | 2; + (plVar3->peer_version).subvers = uVar2; + if (((bVar4 & 1) == 0) || (plVar3->loc_proc_state != '\x02')) { + if (((int)(uint)uVar1 >> 1 & 1U) == 0) { + llc_llcp_version_ind_pdu_send(conhdl); + } + } + else { + ble_ke_timer_clear(0x102,param_2); + llc_version_rd_event_send('\0',conhdl); + plVar3->loc_proc_state = '\0'; + ble_ke_state_set(param_2,bVar4 & 0xfe); + } + } + else { + llc_util_dicon_procedure(conhdl,'='); + } + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void llc_llcp_ch_map_update_pdu_send(uint16_t conhdl) + +{ + llc_env_tag *plVar1; + undefined2 in_register_0000202a; + uint8_t uStack24; + undefined auStack23 [3]; + llcp_channel_map_ind pdu; + + plVar1 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + uStack24 = '\x01'; + pdu.ch_map.map._1_2_ = lld_util_instant_get(&plVar1->elt->env,'\x02'); + (*ble_memcpy_ptr)(auStack23,&plVar1->n_ch_map,5); + llc_llcp_send((uint8_t)conhdl,&uStack24,uStack24); + return; +} + + + +void llc_llcp_pause_enc_req_pdu_send(uint16_t conhdl) + +{ + uint8_t auStack20 [4]; + llcp_pause_enc_req pdu; + + auStack20[0] = '\n'; + ble_ke_timer_set(0x102,conhdl << 8 | 1,4000); + llc_llcp_send((uint8_t)conhdl,auStack20,auStack20[0]); + return; +} + + + +void llc_llcp_pause_enc_rsp_pdu_send(uint16_t conhdl) + +{ + undefined2 in_register_0000202a; + ushort *puVar1; + undefined auStack20 [4]; + llcp_pause_enc_rsp pdu; + + auStack20[0] = 0xb; + puVar1 = (ushort *)(CONCAT22(in_register_0000202a,conhdl) * 0x5c + 0x28008092); + *puVar1 = *puVar1 & 0xfeff; + llc_env[CONCAT22(in_register_0000202a,conhdl)]->encryption_state = + llc_env[CONCAT22(in_register_0000202a,conhdl)]->encryption_state & 0xfd; + llc_llcp_send((uint8_t)conhdl,auStack20,'\v'); + return; +} + + +/* +Unable to decompile 'llcp_pause_enc_rsp_handler' +Cause: Exception while decompiling 23017e72: Decompiler process died + +*/ + + +// WARNING: Variable defined which should be unmapped: pdu +// WARNING: Could not reconcile some variable overlaps + +void llc_llcp_enc_req_pdu_send(uint16_t conhdl,hci_le_start_enc_cmd *param) + +{ + int iVar1; + undefined2 in_register_0000202a; + llc_env_tag *plVar2; + uint8_t uStack56; + undefined auStack55 [3]; + llcp_enc_req pdu; + + uStack56 = '\x03'; + pdu.rand.nb[4] = (uint8_t)param->enc_div; + pdu.rand.nb[5] = (uint8_t)(param->enc_div >> 8); + plVar2 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + (*ble_memcpy_ptr)(auStack55,¶m->nb,8); + (*ble_memcpy_ptr)(pdu.skdm.skdiv + 4,(plVar2->encrypt).randn,4); + iVar1 = CONCAT22(in_register_0000202a,conhdl) * 0x5c; + (*ble_memcpy_ptr)(pdu.rand.nb + 6,(plVar2->encrypt).randn + 4,8); + *(undefined2 *)(iVar1 + 0x280080c4) = pdu.skdm.skdiv._4_2_; + *(undefined2 *)(iVar1 + 0x280080c6) = pdu.skdm.skdiv._6_2_; + (*ble_memcpy_ptr)(&(plVar2->encrypt).ltk,¶m->ltk,0x10); + (*ble_memcpy_ptr)(&plVar2->encrypt,pdu.rand.nb + 6,8); + *(ushort *)(iVar1 + 0x28008092) = *(ushort *)(iVar1 + 0x28008092) & 0xfeff; + plVar2 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + plVar2->encryption_state = plVar2->encryption_state & 0xfd; + ble_ke_timer_set(0x102,conhdl << 8 | 1,4000); + llc_llcp_send((uint8_t)conhdl,&uStack56,uStack56); + return; +} + + + +// WARNING: Variable defined which should be unmapped: pdu +// WARNING: Could not reconcile some variable overlaps + +void llc_llcp_enc_rsp_pdu_send(uint16_t conhdl,llcp_enc_req *param) + +{ + llc_env_tag *plVar1; + undefined2 in_register_0000202a; + int iVar2; + uint8_t local_20; + undefined auStack31 [3]; + llcp_enc_rsp pdu; + + plVar1 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + local_20 = '\x04'; + (*ble_memcpy_ptr)(pdu.skds.skdiv + 4,(plVar1->encrypt).randn,4); + (*ble_memcpy_ptr)(auStack31,(plVar1->encrypt).randn + 4,8); + iVar2 = CONCAT22(in_register_0000202a,conhdl) * 0x5c; + *(undefined2 *)(iVar2 + 0x280080c8) = pdu.skds.skdiv._4_2_; + *(undefined2 *)(iVar2 + 0x280080ca) = pdu.skds.skdiv._6_2_; + (*ble_memcpy_ptr)((plVar1->encrypt).skd.skd + 8,auStack31,8); + llc_llcp_send((uint8_t)conhdl,&local_20,local_20); + return; +} + + + +void llc_llcp_start_enc_rsp_pdu_send(uint16_t conhdl) + +{ + uint16_t rx_time; + uint16_t tx_time; + undefined2 in_register_0000202a; + ushort *puVar1; + llc_env_tag *plVar2; + uint8_t auStack20 [4]; + llcp_start_enc_rsp pdu; + + auStack20[0] = '\x06'; + puVar1 = (ushort *)(CONCAT22(in_register_0000202a,conhdl) * 0x5c + 0x28008092); + *puVar1 = *puVar1 | 0x300; + plVar2 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + rx_time = (plVar2->data_len_ext_info).conn_eff_max_rx_time; + tx_time = (plVar2->data_len_ext_info).conn_eff_max_tx_time; + plVar2->encryption_state = plVar2->encryption_state | 3; + lld_util_compute_ce_max(plVar2->elt,tx_time,rx_time); + llc_llcp_send((uint8_t)conhdl,auStack20,auStack20[0]); + return; +} + + +/* +Unable to decompile 'llcp_start_enc_rsp_handler' +Cause: Exception while decompiling 230181d8: Decompiler process died + +*/ + + +void llc_llcp_reject_ind_pdu_send(uint16_t conhdl,uint8_t rej_opcode,uint8_t reason) + +{ + undefined2 in_register_0000202a; + undefined3 in_register_0000202d; + uint8_t opcode; + llc_env_tag *plVar1; + undefined uStack20; + uint8_t uStack19; + uint8_t uStack18; + llcp_reject_ind_ext pdu; + + plVar1 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + if ((((plVar1->llc_status & 1) == 0) || (((plVar1->feats_used).feats[0] & 4) == 0)) && + (CONCAT31(in_register_0000202d,rej_opcode) < 0xe)) { + uStack20 = 0xd; + if ((CONCAT31(in_register_0000202d,rej_opcode) - 3 & 0xfd) == 0) { + plVar1->encryption_state = '\0'; + } + opcode = '\r'; + uStack19 = reason; + } + else { + uStack20 = 0x11; + opcode = '\x11'; + uStack19 = rej_opcode; + uStack18 = reason; + } + llc_llcp_send((uint8_t)conhdl,&uStack20,opcode); + return; +} + + +/* +Unable to decompile 'llcp_length_rsp_handler' +Cause: Exception while decompiling 230183ae: Decompiler process died + +*/ + + +int llcp_con_param_rsp_handler + (uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_con_param_rsp *param) + +{ + byte bVar1; + uint8_t uVar2; + _Bool _Var3; + undefined2 in_register_0000202a; + undefined3 extraout_var; + undefined *puVar4; + undefined3 extraout_var_00; + llc_env_tag *plVar5; + ushort uVar6; + ea_elt_tag *peVar7; + + bVar1 = ble_ke_state_get(dest_id); + plVar5 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + if ((plVar5->encryption_state & 8) == 0) { + if (plVar5->loc_proc_state == '\a') { + ble_ke_timer_clear(0x102,dest_id); + uVar2 = lld_get_mode(conhdl); + if (CONCAT31(extraout_var,uVar2) == 3) { + plVar5 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + puVar4 = (undefined *)plVar5->operation[0]; + if ((*(ushort *)(puVar4 + 4) < param->interval_min) || + (param->interval_max < *(ushort *)(puVar4 + 2))) { + peVar7 = plVar5->elt; + llc_llcp_reject_ind_pdu_send(conhdl,'\x10',' '); + if ((plVar5->llc_status & 0x40) != 0) { + plVar5->llc_status = plVar5->llc_status & 0xffbf; + _Var3 = llm_util_check_evt_mask('\x02'); + if (CONCAT31(extraout_var_00,_Var3) != 0) { + llc_con_update_complete_send(' ',conhdl,(lld_evt_tag *)&peVar7->env); + } + } + ble_ke_state_set(dest_id,bVar1 & 0xfe); + plVar5->loc_proc_state = '\0'; + llc_util_clear_operation_ptr(CONCAT22(in_register_0000202a,conhdl),0); + } + else { + *puVar4 = 4; + *(uint16_t *)(puVar4 + 2) = param->interval_min; + *(uint16_t *)(puVar4 + 4) = param->interval_max; + uVar6 = param->latency; + if (param->latency < *(ushort *)(puVar4 + 6)) { + uVar6 = *(ushort *)(puVar4 + 6); + } + *(ushort *)(puVar4 + 6) = uVar6; + uVar6 = param->timeout; + if (param->timeout < *(ushort *)(puVar4 + 8)) { + uVar6 = *(ushort *)(puVar4 + 8); + } + *(ushort *)(puVar4 + 8) = uVar6; + *(ushort *)(puVar4 + 10) = plVar5->elt->duration_min / 0x271; + *(ushort *)(puVar4 + 0xc) = plVar5->elt->duration_min / 0x271; + ble_ke_msg_send(); + } + } + } + else { + llc_llcp_reject_ind_pdu_send(conhdl,param->opcode,'\x1f'); + } + } + else { + llc_util_dicon_procedure(conhdl,'='); + } + return 0; +} + + + +undefined4 llcp_feats_rsp_handler(int param_1,ke_task_id_t param_2,uint8_t *param_3) + +{ + byte *pbVar1; + llc_env_tag *plVar2; + byte bVar3; + uint16_t conhdl; + le_features *plVar4; + encrypt_conflict1 *peVar5; + encrypt_conflict1 *peVar6; + + bVar3 = ble_ke_state_get(param_2); + plVar2 = llc_env[param_1]; + conhdl = (uint16_t)param_1; + if ((plVar2->encryption_state & 8) == 0) { + if (((bVar3 & 1) == 0) || (plVar2->loc_proc_state != '\x01')) { + llc_llcp_reject_ind_pdu_send(conhdl,*param_3,'\x11'); + } + else { + ble_ke_timer_clear(0x102,(ushort)(param_1 << 8) | 1); + plVar4 = (le_features *)(param_3 + 1); + peVar5 = (encrypt_conflict1 *)&plVar2->feats_used; + do { + pbVar1 = plVar4->feats; + peVar6 = (encrypt_conflict1 *)((peVar5->skd).skd + 1); + plVar4 = (le_features *)(plVar4->feats + 1); + (peVar5->skd).skd[0] = (peVar5->skd).skd[0] & *pbVar1; + peVar5 = peVar6; + } while (peVar6 != &plVar2->encrypt); + plVar2->llc_status = plVar2->llc_status | 1; + llc_feats_rd_event_send('\0',conhdl,(le_features *)(param_3 + 1)); + plVar2->loc_proc_state = '\0'; + ble_ke_state_set(param_2,bVar3 & 0xfe); + } + } + else { + llc_util_dicon_procedure(conhdl,'='); + } + return 0; +} + + + +int llcp_channel_map_ind_handler(int param_1,ke_task_id_t param_2,int param_3,uint8_t *param_4) + +{ + uint16_t instant; + ushort uVar1; + llc_env_tag *plVar2; + byte bVar3; + _Bool _Var4; + uint8_t reason; + uint16_t conhdl; + undefined3 extraout_var; + undefined3 extraout_var_00; + int iVar5; + ea_elt_tag *elt; + + bVar3 = ble_ke_state_get(param_2); + plVar2 = llc_env[param_1]; + iVar5 = (uint)(param_3 != 0) << 1; + conhdl = (uint16_t)param_1; + if (param_3 == 0) { + if (param_4[-1] == 0) goto LAB_230187c6; + switch((uint)param_4[-1] - 1 & 0xff) { + case 0: + goto switchD_23018802_caseD_0; + case 1: + goto switchD_23018802_caseD_1; + case 2: +switchD_23018802_caseD_2: + reason = '('; + goto LAB_230188ae; + case 3: + goto switchD_23018802_caseD_3; + case 4: + goto switchD_23018802_caseD_4; + default: + return iVar5; + } + } + param_4[-1] = '\0'; +LAB_230187c6: + if ((llc_env[param_1]->encryption_state & 8) != 0) { + param_4[-1] = '\x04'; + if (param_3 != 0) { + return iVar5; + } +switchD_23018802_caseD_3: + reason = '='; +LAB_230188ae: + llc_util_dicon_procedure(conhdl,reason); + return iVar5; + } + _Var4 = lld_util_instant_ongoing(plVar2->elt); + if (CONCAT31(extraout_var,_Var4) == 0) { + reason = lld_get_mode(conhdl); + if ((CONCAT31(extraout_var_00,reason) == 4) && ((bVar3 & 2) == 0)) { + elt = plVar2->elt; + instant = *(uint16_t *)(param_4 + 6); + if ((ushort)(instant - *(short *)&elt[2].timestamp) < 0x7fff) { + memcpy(&plVar2->n_ch_map,param_4 + 1,5); + lld_ch_map_ind(elt,instant); + param_4[-1] = '\x01'; + if (param_3 != 0) { + return iVar5; + } +switchD_23018802_caseD_0: + uVar1 = plVar2->llc_status; + if (-1 < (int)((uint)uVar1 << 0x14)) { + plVar2->llc_status = uVar1 | 0x400; + plVar2->rem_proc_state = '\x01'; + ble_ke_state_set(param_2,bVar3 | 2); + return iVar5; + } + plVar2->llc_status = uVar1 & 0xf7ff; + return iVar5; + } + param_4[-1] = '\x03'; + if (param_3 != 0) { + return iVar5; + } + goto switchD_23018802_caseD_2; + } + param_4[-1] = '\x05'; + if (param_3 != 0) { + return iVar5; + } +switchD_23018802_caseD_4: + reason = '\x11'; + goto LAB_230188ba; + } + param_4[-1] = '\x02'; + if (param_3 != 0) { + return iVar5; + } +switchD_23018802_caseD_1: + reason = '#'; +LAB_230188ba: + llc_llcp_reject_ind_pdu_send(conhdl,*param_4,reason); + return iVar5; +} + + + +int llcp_con_upd_ind_handler(int param_1,ke_task_id_t param_2,int param_3,llcp_con_upd_ind *param_4) + +{ + byte bVar1; + ushort uVar2; + llc_env_tag *plVar3; + byte state_id; + _Bool _Var4; + uint8_t reason; + uint16_t conhdl; + undefined3 extraout_var; + undefined3 extraout_var_00; + int iVar5; + + plVar3 = llc_env[param_1]; + state_id = ble_ke_state_get(param_2); + iVar5 = (uint)(param_3 != 0) << 1; + conhdl = (uint16_t)param_1; + if (param_3 == 0) { + bVar1 = *(byte *)((int)¶m_4[-1].instant + 1); + if (bVar1 == 0) goto LAB_23018932; + switch((uint)bVar1 - 1 & 0xff) { + case 0: + goto switchD_23018970_caseD_0; + case 1: + goto switchD_23018970_caseD_1; + case 2: +switchD_23018970_caseD_2: + reason = '('; + goto LAB_23018a84; + case 3: + goto switchD_23018970_caseD_3; + case 4: + goto switchD_23018970_caseD_4; + default: + return iVar5; + } + } + *(undefined *)((int)¶m_4[-1].instant + 1) = 0; +LAB_23018932: + if ((llc_env[param_1]->encryption_state & 8) != 0) { + *(undefined *)((int)¶m_4[-1].instant + 1) = 4; + if (param_3 != 0) { + return iVar5; + } +switchD_23018970_caseD_3: + reason = '='; +LAB_23018a84: + llc_util_dicon_procedure(conhdl,reason); + return iVar5; + } + _Var4 = lld_util_instant_ongoing(plVar3->elt); + if (CONCAT31(extraout_var,_Var4) == 0) { + reason = lld_get_mode(conhdl); + if (CONCAT31(extraout_var_00,reason) == 4) { + if ((ushort)(param_4->instant - *(short *)&plVar3->elt[2].timestamp) < 0x7fff) { + uVar2 = *(ushort *)&plVar3->elt[2].ea_cb_stop >> 1; + if ((uint)uVar2 <= (uint)param_4->win_size) { + param_4->win_size = (char)uVar2 + -1; + } + plVar3->n_sup_to = param_4->timeout; + lld_con_update_ind(plVar3->elt,param_4); + *(undefined *)((int)¶m_4[-1].instant + 1) = 1; + if (param_3 != 0) { + return iVar5; + } +switchD_23018970_caseD_0: + if (((state_id & 1) != 0) && ((byte)(plVar3->loc_proc_state - 7) < 2)) { + ble_ke_timer_clear(0x102,param_2); + state_id = state_id & 0xfe; + plVar3->loc_proc_state = '\0'; + ble_ke_state_set(param_2,state_id); + llc_util_clear_operation_ptr(param_1,0); + } + if (plVar3->rem_proc_state == '\x03') { + ble_ke_timer_clear(0x102,param_2); + } + uVar2 = plVar3->llc_status; + if (-1 < (int)((uint)uVar2 << 0x14)) { + plVar3->llc_status = uVar2 | 0x400; + plVar3->rem_proc_state = '\x04'; + ble_ke_state_set(param_2,state_id | 2); + return iVar5; + } + plVar3->llc_status = uVar2 & 0xf7ff; + return iVar5; + } + *(undefined *)((int)¶m_4[-1].instant + 1) = 3; + if (param_3 != 0) { + return iVar5; + } + goto switchD_23018970_caseD_2; + } + *(undefined *)((int)¶m_4[-1].instant + 1) = 5; + if (param_3 != 0) { + return iVar5; + } +switchD_23018970_caseD_4: + reason = '\x11'; + goto LAB_23018988; + } + *(undefined *)((int)¶m_4[-1].instant + 1) = 2; + if (param_3 != 0) { + return iVar5; + } +switchD_23018970_caseD_1: + reason = '#'; +LAB_23018988: + llc_llcp_reject_ind_pdu_send(conhdl,param_4->opcode,reason); + return iVar5; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void llc_llcp_con_update_pdu_send(uint16_t conhdl,llcp_con_upd_ind *param) + +{ + undefined uStack28; + uint8_t uStack27; + uint16_t uStack26; + llcp_con_upd_ind pdu; + + uStack27 = param->win_size; + uStack26 = param->win_off; + uStack28 = 0; + pdu._0_2_ = param->interv; + pdu.win_off = param->latency; + pdu.interv = param->timeout; + pdu.latency = param->instant; + llc_llcp_send((uint8_t)conhdl,&uStack28,'\0'); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void llc_llcp_con_param_req_pdu_send(uint16_t conhdl,llc_con_upd_req_ind *param) + +{ + undefined auStack44 [2]; + uint16_t uStack42; + llcp_con_param_req pdu; + + auStack44[0] = 0xf; + uStack42 = param->interval_min; + pdu._0_2_ = param->interval_max; + pdu.interval_min = param->con_latency; + pdu.interval_max = param->superv_to; + pdu.latency._0_1_ = param->pref_period; + pdu.timeout = param->ref_con_event_count; + pdu._10_2_ = param->offset0; + pdu.ref_con_event_count = param->offset1; + pdu.offset0 = param->offset2; + pdu.offset1 = param->offset3; + pdu.offset2 = param->offset4; + pdu.offset3 = param->offset5; + llc_llcp_send((uint8_t)conhdl,auStack44,'\x0f'); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void llc_llcp_con_param_rsp_pdu_send(uint16_t conhdl,llc_con_upd_req_ind *param) + +{ + undefined auStack44 [2]; + uint16_t uStack42; + llcp_con_param_rsp pdu; + + auStack44[0] = 0x10; + uStack42 = param->interval_min; + pdu._0_2_ = param->interval_max; + pdu.interval_min = param->con_latency; + pdu.interval_max = param->superv_to; + pdu.latency._0_1_ = param->pref_period; + pdu.timeout = param->ref_con_event_count; + pdu._10_2_ = param->offset0; + pdu.ref_con_event_count = param->offset1; + pdu.offset0 = param->offset2; + pdu.offset1 = param->offset3; + pdu.offset2 = param->offset4; + pdu.offset3 = param->offset5; + llc_llcp_send((uint8_t)conhdl,auStack44,'\x10'); + return; +} + + + +undefined4 llcp_con_param_req_handler(int param_1,ke_task_id_t param_2,uint8_t *param_3) + +{ + ushort uVar1; + ushort uVar2; + byte bVar3; + uint8_t reason; + _Bool _Var4; + uint16_t conhdl; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined *puVar5; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + uint8_t rej_opcode; + uint uVar6; + uint uVar7; + uint uVar8; + llc_env_tag *plVar9; + llc_con_upd_req_ind lStack68; + + bVar3 = ble_ke_state_get(param_2); + plVar9 = llc_env[param_1]; + conhdl = (uint16_t)param_1; + if ((plVar9->encryption_state & 8) != 0) { + llc_util_dicon_procedure(conhdl,'='); + return 0; + } + if ((bVar3 & 2) == 0) { + reason = lld_get_mode(conhdl); + if ((CONCAT31(extraout_var,reason) != 3) || ((bVar3 & 1) == 0)) { +LAB_23018c86: + uVar1 = *(ushort *)(param_3 + 2); + uVar7 = (uint)*(ushort *)(param_3 + 4); + if (((((uVar7 < uVar1) || (uVar2 = *(ushort *)(param_3 + 6), 499 < uVar2)) || + (0xc80 < *(ushort *)(param_3 + 4))) || + ((uVar1 < 6 || (uVar6 = (uint)*(ushort *)(param_3 + 8), 0xc76 < (uVar6 - 10 & 0xffff))))) + || (uVar6 << 2 <= ((uint)uVar2 + 1) * uVar7)) { + reason = '\x1e'; + } + else { + uVar8 = (uint)(*(ushort *)&plVar9->elt[2].ea_cb_stop >> 1); + if (((uVar8 < uVar1) || (uVar7 < uVar8)) || + (((uint)uVar2 != (uint)*(ushort *)((int)&plVar9->elt[2].linked_element + 2) - 1 || + ((uint)plVar9->sup_to != uVar6)))) { + _Var4 = llm_util_check_evt_mask('\x05'); + if (CONCAT31(extraout_var_00,_Var4) != 0) { + puVar5 = (undefined *)ble_ke_msg_alloc(0x109,param_2,param_2,0x22); + *puVar5 = 3; + goto LAB_23018d1c; + } + reason = '\x1a'; + } + else { + reason = lld_get_mode(conhdl); + if (CONCAT31(extraout_var_01,reason) == 3) { + puVar5 = (undefined *)ble_ke_msg_alloc(0x109,param_2,param_2,0x22); + *puVar5 = 2; + *(undefined2 *)(puVar5 + 2) = *(undefined2 *)(param_3 + 2); + *(undefined2 *)(puVar5 + 4) = *(undefined2 *)(param_3 + 4); + *(uint16_t *)(puVar5 + 8) = plVar9->sup_to; + *(ushort *)(puVar5 + 10) = plVar9->elt->duration_min / 0x271; + *(ushort *)(puVar5 + 0xc) = plVar9->elt->duration_min / 0x271; +LAB_23018d1c: + *(undefined2 *)(puVar5 + 0xe) = *(undefined2 *)(param_3 + 2); + *(undefined2 *)(puVar5 + 0x10) = *(undefined2 *)(param_3 + 4); + *(undefined2 *)(puVar5 + 6) = *(undefined2 *)(param_3 + 6); + *(undefined2 *)(puVar5 + 8) = *(undefined2 *)(param_3 + 8); + puVar5[0x12] = param_3[10]; + *(undefined2 *)(puVar5 + 0x14) = *(undefined2 *)(param_3 + 0xc); + *(undefined2 *)(puVar5 + 0x16) = *(undefined2 *)(param_3 + 0xe); + *(undefined2 *)(puVar5 + 0x18) = *(undefined2 *)(param_3 + 0x10); + *(undefined2 *)(puVar5 + 0x1a) = *(undefined2 *)(param_3 + 0x12); + *(undefined2 *)(puVar5 + 0x1c) = *(undefined2 *)(param_3 + 0x14); + *(undefined2 *)(puVar5 + 0x1e) = *(undefined2 *)(param_3 + 0x16); + *(undefined2 *)(puVar5 + 0x20) = *(undefined2 *)(param_3 + 0x18); + ble_ke_msg_send(); + return 0; + } + reason = lld_get_mode(conhdl); + if (CONCAT31(extraout_var_02,reason) != 4) { + return 0; + } + lStack68.interval_min = *(uint16_t *)(param_3 + 2); + lStack68.interval_max = *(uint16_t *)(param_3 + 4); + lStack68.con_latency = *(uint16_t *)(param_3 + 6); + lStack68.superv_to = *(uint16_t *)(param_3 + 8); + lStack68.pref_period = param_3[10]; + lStack68.ref_con_event_count = *(uint16_t *)(param_3 + 0xc); + lStack68.offset0 = *(uint16_t *)(param_3 + 0xe); + lStack68.offset1 = *(uint16_t *)(param_3 + 0x10); + lStack68.offset2 = *(uint16_t *)(param_3 + 0x12); + lStack68.offset3 = *(uint16_t *)(param_3 + 0x14); + lStack68.offset4 = *(uint16_t *)(param_3 + 0x16); + lStack68.offset5 = *(uint16_t *)(param_3 + 0x18); + reason = lld_con_param_rsp(conhdl,plVar9->elt,&lStack68); + if (CONCAT31(extraout_var_03,reason) == 0) { + plVar9->rem_proc_state = '\x03'; + ble_ke_state_set(param_2,bVar3 | 2); + llc_llcp_con_param_rsp_pdu_send(conhdl,&lStack68); + ble_ke_timer_set(0x102,param_2,4000); + return 0; + } + reason = ' '; + } + } + rej_opcode = '\x0f'; + goto LAB_23018c50; + } + reason = plVar9->loc_proc_state; + if ((reason == '\a') || (reason == '\t')) goto LAB_23018c48; + if (reason != '\x06') goto LAB_23018c86; + reason = '*'; + } + else { +LAB_23018c48: + reason = '#'; + } + rej_opcode = *param_3; +LAB_23018c50: + llc_llcp_reject_ind_pdu_send(conhdl,rej_opcode,reason); + return 0; +} + + + +void llc_llcp_feats_req_pdu_send(uint16_t conhdl) + +{ + uint8_t uVar1; + undefined3 extraout_var; + uint8_t uStack28; + undefined auStack27 [3]; + llcp_feats_req pdu; + + uVar1 = lld_get_mode(conhdl); + uStack28 = '\x0e'; + if (CONCAT31(extraout_var,uVar1) == 3) { + uStack28 = '\b'; + } + llm_util_get_supp_features((le_features *)auStack27); + llc_llcp_send((uint8_t)conhdl,&uStack28,uStack28); + return; +} + + + +void llc_llcp_feats_rsp_pdu_send(uint16_t conhdl) + +{ + undefined2 in_register_0000202a; + uint8_t uStack28; + uint8_t auStack27 [3]; + llcp_feats_rsp pdu; + + uStack28 = '\t'; + llm_util_get_supp_features((le_features *)auStack27); + auStack27[0] = (llc_env[CONCAT22(in_register_0000202a,conhdl)]->feats_used).feats[0]; + llc_llcp_send((uint8_t)conhdl,&uStack28,uStack28); + return; +} + + + +void llc_llcp_start_enc_req_pdu_send(uint16_t conhdl) + +{ + undefined2 in_register_0000202a; + int iVar1; + undefined auStack20 [4]; + llcp_start_enc_req pdu; + + iVar1 = CONCAT22(in_register_0000202a,conhdl) * 0x5c; + *(ushort *)(iVar1 + 0x28008092) = *(ushort *)(iVar1 + 0x28008092) | 0x100; + llc_env[CONCAT22(in_register_0000202a,conhdl)]->encryption_state = + llc_env[CONCAT22(in_register_0000202a,conhdl)]->encryption_state | 2; + *(undefined2 *)(iVar1 + 0x280080cc) = 0; + *(undefined2 *)(iVar1 + 0x280080ce) = 0; + *(undefined2 *)(iVar1 + 0x280080d0) = 0; + *(undefined2 *)(iVar1 + 0x280080d2) = 0; + *(undefined2 *)(iVar1 + 0x280080d4) = 0; + *(undefined2 *)(iVar1 + 0x280080d6) = 0; + auStack20[0] = 5; + llc_llcp_send((uint8_t)conhdl,auStack20,'\x05'); + return; +} + + + +// WARNING: Variable defined which should be unmapped: pdu + +void llc_llcp_terminate_ind_pdu_send(uint16_t conhdl,uint8_t err_code) + +{ + byte bVar1; + ushort id; + undefined2 in_register_0000202a; + undefined3 in_register_0000202d; + uint8_t uVar2; + llc_env_tag *plVar3; + uint8_t uStack20; + uint8_t uStack19; + llcp_terminate_ind pdu; + + id = conhdl << 8 | 1; + plVar3 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + bVar1 = ble_ke_state_get(id); + uVar2 = '\x16'; + if (CONCAT31(in_register_0000202d,err_code) != 0x13) { + uVar2 = err_code; + } + plVar3->disc_reason = uVar2; + uStack20 = '\x02'; + uStack19 = err_code; + ble_ke_state_set(id,bVar1 | 0xf); + llc_llcp_send((uint8_t)conhdl,&uStack20,uStack20); + ble_ke_timer_set(0x102,id,(uint)plVar3->sup_to); + return; +} + + + +void llc_llcp_unknown_rsp_send_pdu(uint16_t conhdl,uint8_t unk_type) + +{ + undefined uStack20; + uint8_t uStack19; + llcp_unknown_rsp pdu; + + uStack20 = 7; + uStack19 = unk_type; + llc_llcp_send((uint8_t)conhdl,&uStack20,'\a'); + return; +} + + + +int llc_llcp_unknown_ind_handler(uint16_t conhdl,uint8_t opcode) + +{ + undefined2 in_register_0000202a; + + if ((llc_env[CONCAT22(in_register_0000202a,conhdl)]->encryption_state & 8) == 0) { + llc_llcp_unknown_rsp_send_pdu(conhdl,opcode); + } + else { + llc_util_dicon_procedure(conhdl,'='); + } + return 0; +} + + + +int llcp_feats_req_handler(uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_feats_req *param) + +{ + uint8_t uVar1; + undefined2 in_register_0000202a; + undefined3 extraout_var; + encrypt_conflict1 *peVar2; + encrypt_conflict1 *peVar3; + llc_env_tag *plVar4; + + plVar4 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + uVar1 = lld_get_mode(conhdl); + if ((CONCAT31(extraout_var,uVar1) == 4) || (param->opcode != '\b')) { + if ((llc_env[CONCAT22(in_register_0000202a,conhdl)]->encryption_state & 8) == 0) { + peVar2 = (encrypt_conflict1 *)&plVar4->feats_used; + do { + param = (llcp_feats_req *)¶m->feats; + peVar3 = (encrypt_conflict1 *)((peVar2->skd).skd + 1); + (peVar2->skd).skd[0] = (peVar2->skd).skd[0] & param->opcode; + peVar2 = peVar3; + } while (peVar3 != &plVar4->encrypt); + plVar4->llc_status = plVar4->llc_status | 1; + llc_llcp_feats_rsp_pdu_send(conhdl); + } + else { + llc_util_dicon_procedure(conhdl,'='); + } + } + else { + llc_llcp_unknown_ind_handler(conhdl,'\b'); + } + return 0; +} + + + +int llcp_slave_feature_req_handler + (uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_slave_feature_req *param) + +{ + uint8_t uVar1; + undefined3 extraout_var; + int iVar2; + + uVar1 = lld_get_mode(conhdl); + if (CONCAT31(extraout_var,uVar1) == 3) { + iVar2 = llcp_feats_req_handler(conhdl,dest_id,int_ctx,(llcp_feats_req *)param); + return iVar2; + } + llc_llcp_unknown_ind_handler(conhdl,'\x0e'); + return 0; +} + + + +void llc_llcp_ping_req_pdu_send(uint16_t conhdl) + +{ + undefined auStack20 [4]; + llcp_ping_req pdu; + + auStack20[0] = 0x12; + llc_llcp_send((uint8_t)conhdl,auStack20,'\x12'); + return; +} + + + +void llc_llcp_ping_rsp_pdu_send(uint16_t conhdl) + +{ + undefined auStack20 [4]; + llcp_ping_rsp pdu; + + auStack20[0] = 0x13; + llc_llcp_send((uint8_t)conhdl,auStack20,'\x13'); + return; +} + + + +int llcp_ping_req_handler(uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,void *param) + +{ + undefined2 in_register_0000202a; + + if ((llc_env[CONCAT22(in_register_0000202a,conhdl)]->encryption_state & 8) == 0) { + llc_llcp_ping_rsp_pdu_send(conhdl); + } + else { + llc_util_dicon_procedure(conhdl,'='); + } + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void llc_llcp_length_req_pdu_send(uint16_t conhdl) + +{ + undefined2 in_register_0000202a; + llc_env_tag *plVar1; + undefined auStack28 [2]; + uint16_t uStack26; + llcp_length_req pdu; + + plVar1 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + auStack28[0] = 0x14; + uStack26 = (plVar1->data_len_ext_info).conn_max_rx_octets; + pdu._0_2_ = (plVar1->data_len_ext_info).conn_max_rx_time; + pdu.max_rx_octets = (plVar1->data_len_ext_info).conn_max_tx_octets; + pdu.max_rx_time = (plVar1->data_len_ext_info).conn_max_tx_time; + llc_llcp_send((uint8_t)conhdl,auStack28,'\x14'); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void llc_llcp_length_rsp_pdu_send(uint16_t conhdl) + +{ + undefined2 in_register_0000202a; + llc_env_tag *plVar1; + undefined auStack28 [2]; + uint16_t uStack26; + llcp_length_rsp pdu; + + plVar1 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + auStack28[0] = 0x15; + uStack26 = (plVar1->data_len_ext_info).conn_max_rx_octets; + pdu._0_2_ = (plVar1->data_len_ext_info).conn_max_rx_time; + pdu.max_rx_octets = (plVar1->data_len_ext_info).conn_max_tx_octets; + pdu.max_rx_time = (plVar1->data_len_ext_info).conn_max_tx_time; + llc_llcp_send((uint8_t)conhdl,auStack28,'\x15'); + return; +} + + +/* +Unable to decompile 'llcp_length_req_handler' +Cause: Exception while decompiling 23019254: Decompiler process died + +*/ + + +// WARNING: Exceeded maximum restarts with more pending + +int llc_llcp_recv_handler(uint param_1,int param_2,byte *param_3,int param_4) + +{ + byte bVar1; + int iVar2; + + bVar1 = ble_ke_state_get((ke_task_id_t)param_1); + if ((bVar1 & 0x7f) != 0x7f) { + if ((((bVar1 & 0xf) != 0xf) || ((*param_3 & 0xfb) == 2)) && + ((llc_env[param_1 >> 8]->llc_status & 8) == 0)) { + if (param_2 == 0) { + if ((param_4 == 0) || (llcp_pdu_handler[*param_3].int_ctx_allowed != false)) { + // WARNING: Could not recover jumptable at 0x23019450. Too many branches + // WARNING: Treating indirect jump as call + iVar2 = (*llcp_pdu_handler[*param_3].handler)((uint16_t)param_1,(ke_task_id_t)param_3); + return iVar2; + } + } + else { + if ((param_2 == 0x19) && (param_4 == 0)) { + iVar2 = llc_llcp_unknown_ind_handler((uint16_t)(param_1 >> 8),*param_3); + return iVar2; + } + } + } + } + return (uint)(param_4 != 0) << 1; +} + + + +uint8_t llc_llcp_get_autorize(uint8_t opcode) + +{ + undefined3 in_register_00002029; + + if (CONCAT31(in_register_00002029,opcode) < 0x16) { + return llcp_pdu_handler[CONCAT31(in_register_00002029,opcode)].enc_auth; + } + return '\0'; +} + + + +int llc_dft_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + return 0; +} + + + +undefined4 llm_enc_ind_handler(int param_1,uint param_2) + +{ + byte id; + uint8_t uVar1; + uint16_t conhdl; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined2 *puVar2; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + uint uVar3; + llc_env_tag *plVar4; + + _id = (ke_task_id_t)param_2; + id = ble_ke_state_get(_id); + if ((id & 0xf) != 0xf) { + plVar4 = llc_env[param_2 >> 8]; + conhdl = (uint16_t)(param_2 >> 8); + if (((plVar4->loc_proc_state == '\x13') && + (uVar1 = lld_get_mode(conhdl), CONCAT31(extraout_var_01,uVar1) == 3)) || + ((plVar4->rem_proc_state == '\x0e' && + (uVar1 = lld_get_mode(conhdl), CONCAT31(extraout_var,uVar1) == 4)))) { + (*ble_memcpy_ptr)((plVar4->encrypt).randn,(void *)(param_1 + 1),0x10); + } + else { + uVar1 = lld_get_mode(conhdl); + if (((CONCAT31(extraout_var_00,uVar1) != 4) || ((id & 2) == 0)) || + (plVar4->rem_proc_state != '\n')) { + uVar1 = lld_get_mode(conhdl); + if (CONCAT31(extraout_var_02,uVar1) != 3) { + return 0; + } + if ((id & 1) == 0) { + return 0; + } + if (1 < (byte)(plVar4->loc_proc_state - 0xe)) { + return 0; + } + } + puVar2 = (undefined2 *)((param_2 >> 8) * 0x5c + 0x280080b4); + uVar3 = 0xf; + do { + *puVar2 = CONCAT11(*(undefined *)(param_1 + uVar3),((undefined *)(param_1 + uVar3))[1]); + uVar3 = uVar3 - 2 & 0xff; + puVar2 = puVar2 + 1; + } while (uVar3 != 0xff); + } + ble_ke_msg_send_basic(0x106,_id,_id); + } + return 0; +} + + + +int llc_llcp_recv_ind_handler + (ke_msg_id_t msgid,llc_llcp_recv_ind *ind,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + int iVar1; + undefined2 in_register_00002032; + + iVar1 = llc_llcp_recv_handler(CONCAT22(in_register_00002032,dest_id),(uint)ind->status,ind->pdu,0) + ; + return iVar1; +} + + + +undefined4 llc_chmap_update_req_ind_handler(uint param_1) + +{ + byte bVar1; + uint16_t conhdl; + int iVar2; + llc_env_tag *plVar3; + + bVar1 = ble_ke_state_get((ke_task_id_t)param_1); + if (((bVar1 & 0xf) != 0xf) && ((bVar1 & 4) == 0)) { + if ((bVar1 & 1) != 0) { + return 2; + } + plVar3 = llc_env[param_1 >> 8]; + conhdl = (uint16_t)(param_1 >> 8); + _conhdl = llc_ch_assess_get_current_ch_map(conhdl); + iVar2 = (*ble_memcmp_ptr)(_conhdl,&plVar3->n_ch_map,5); + if (iVar2 != 0) { + ble_ke_state_set((ke_task_id_t)param_1,bVar1 | 1); + plVar3->loc_proc_state = '\x06'; + llc_llcp_ch_map_update_pdu_send(conhdl); + } + } + return 0; +} + + + +undefined4 llc_auth_payl_real_to_ind_handler(uint param_1) + +{ + byte id; + ke_task_id_t *param; + llc_env_tag *plVar1; + + _id = (ke_task_id_t)param_1; + id = ble_ke_state_get(_id); + if ((id & 0xf) != 0xf) { + plVar1 = llc_env[param_1 >> 8]; + ble_ke_timer_set(0x103,_id,(uint)plVar1->auth_payl_to - (uint)plVar1->auth_payl_to_margin); + ble_ke_timer_set(0x104,_id,(uint)llc_env[param_1 >> 8]->auth_payl_to); + _id = (ke_task_id_t)(param_1 >> 8); + param = (ke_task_id_t *)ble_ke_msg_alloc(0x803,_id,0x57,2); + *param = _id; + hci_send_2_host(param); + } + return 0; +} + + + +undefined4 llc_con_upd_req_ind_handler(llc_con_upd_req_ind *param_1,uint param_2) + +{ + byte id; + _Bool _Var1; + uint8_t uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined *param; + undefined3 extraout_var_01; + uint16_t dest_id; + uint uVar3; + llc_env_tag *plVar4; + llcp_con_upd_ind lStack44; + + _id = (ke_task_id_t)param_2; + id = ble_ke_state_get(_id); + if ((id & 0xf) == 0xf) { + return 0; + } + uVar3 = param_2 >> 8; + if (((id & 1) != 0) && (llc_env[uVar3]->operation[0] == (void *)0x0)) { + return 2; + } + if (((id & 2) != 0) && (llc_env[uVar3]->rem_proc_state == '\x04')) { + return 2; + } + if ((id & 4) != 0) { + return 2; + } + plVar4 = llc_env[uVar3]; + if (4 < param_1->operation) { + return 0; + } + dest_id = (uint16_t)(param_2 >> 8); + switch(param_1->operation) { + case '\x01': + param_1->superv_to = plVar4->sup_to; + break; + case '\x02': + uVar2 = lld_get_mode(dest_id); + if (CONCAT31(extraout_var_01,uVar2) != 3) { + return 0; + } + case '\x04': + lld_con_update_after_param_req(dest_id,plVar4->elt,param_1,&lStack44,true); + goto LAB_23019826; + case '\x03': + param = (undefined *)ble_ke_msg_alloc(0x804,dest_id,0x3e,0xc); + *param = 6; + *(uint16_t *)(param + 2) = dest_id; + *(uint16_t *)(param + 4) = param_1->interval_min; + *(uint16_t *)(param + 6) = param_1->interval_max; + *(uint16_t *)(param + 8) = param_1->con_latency; + *(uint16_t *)(param + 10) = param_1->superv_to; + hci_send_2_host(param); + *(llc_con_upd_req_ind **)(llc_env[uVar3]->operation + 1) = param_1; + plVar4->rem_proc_state = '\x02'; + ble_ke_state_set(_id,id | 2); + return 1; + } + param_1->pref_period = '\0'; + if ((plVar4->peer_sup_conn_param_req == false) || + ((((plVar4->llc_status & 1) != 0 && (((plVar4->feats_used).feats[0] & 2) == 0)) && + (_Var1 = llm_util_check_evt_mask('\x05'), CONCAT31(extraout_var,_Var1) != 0)))) { + param_1->interval_min = param_1->con_intv_min; + param_1->interval_max = param_1->con_intv_max; + uVar2 = lld_get_mode(dest_id); + if (CONCAT31(extraout_var_00,uVar2) != 3) { + return 0; + } + lld_con_update_req(plVar4->elt,param_1,&lStack44); +LAB_23019826: + plVar4->n_sup_to = param_1->superv_to; + llc_llcp_con_update_pdu_send(dest_id,&lStack44); + param_1->interval_min = lStack44.interv; + param_1->con_latency = lStack44.latency; + ble_ke_state_set(_id,id | 1); + plVar4->loc_proc_state = '\t'; + } + else { + if (param_1->operation != '\x01') { + plVar4->llc_status = plVar4->llc_status | 0x40; + lld_con_param_req(dest_id,plVar4->elt,param_1); + } + llc_llcp_con_param_req_pdu_send(dest_id,param_1); + ble_ke_state_set(_id,id | 1); + plVar4->loc_proc_state = '\a'; + ble_ke_timer_set(0x102,_id,4000); + } + *(llc_con_upd_req_ind **)llc_env[uVar3]->operation = param_1; + return 1; +} + + + +undefined4 llc_length_req_ind_handler(uint param_1) + +{ + llc_env_tag *plVar1; + byte id; + void *pvVar2; + + _id = (ke_task_id_t)param_1; + id = ble_ke_state_get(_id); + if ((id & 0xf) != 0xf) { + if ((id & 5) != 0) { + return 2; + } + plVar1 = llc_env[param_1 >> 8]; + pvVar2 = plVar1->operation[3]; + if (pvVar2 != (void *)0x0) { + (plVar1->data_len_ext_info).conn_max_tx_octets = *(uint16_t *)((int)pvVar2 + 2); + (plVar1->data_len_ext_info).conn_max_tx_time = *(uint16_t *)((int)pvVar2 + 4); + } + llc_util_clear_operation_ptr(param_1 >> 8,3); + if (((plVar1->data_len_ext_info).data_len_ext_flag & 1) == 0) { + ble_ke_state_set(_id,id | 1); + plVar1->loc_proc_state = '\x04'; + llc_llcp_length_req_pdu_send((uint16_t)(param_1 >> 8)); + ble_ke_timer_set(0x102,_id,4000); + } + } + return 0; +} + + + +void llc_task_random_gen_request(ke_task_id_t dest_id) + +{ + void *pvVar1; + void *pvVar2; + void *pvVar3; + int iStack36; + uint32_t randn; + + pvVar2 = ble_ke_msg_alloc(4,0,dest_id,0x20); + iStack36 = 0; + pvVar1 = pvVar2; + do { + iStack36 = bl_rand(); + (*ble_memcpy_ptr)(pvVar1,&iStack36,4); + iStack36 = bl_rand(); + pvVar3 = (void *)((int)pvVar1 + 0x10); + pvVar1 = (void *)((int)pvVar1 + 4); + (*ble_memcpy_ptr)(pvVar3,&iStack36,4); + } while (pvVar1 != (void *)((int)pvVar2 + 0x10)); + ble_ke_msg_send(pvVar2); + return; +} + + + +undefined4 llc_enc_mgt_ind_handler(uint param_1) + +{ + byte bVar1; + uint uVar2; + void *pvVar3; + byte id; + uint8_t conhdl; + _Bool _Var4; + undefined3 extraout_var; + undefined3 extraout_var_00; + hci_le_start_enc_cmd *param; + llc_env_tag *plVar5; + int iVar6; + llc_env_tag **pplVar7; + + _id = (ke_task_id_t)param_1; + id = ble_ke_state_get(_id); + if ((id & 0xf) == 0xf) { + return 0; + } + uVar2 = param_1 >> 8; + _conhdl = (uint16_t)(param_1 >> 8); + conhdl = lld_get_mode(_conhdl); + if (CONCAT31(extraout_var,conhdl) == 3) { + if ((id & 1) == 0) { + return 0; + } + plVar5 = llc_env[uVar2]; + switch((uint)plVar5->loc_proc_state - 10 & 0xff) { + case 0: + if ((plVar5->encryption_state & 3) == 3) { + plVar5->encryption_state = plVar5->encryption_state | 0x30; + llc_env[uVar2]->loc_proc_state = '\v'; + llc_llcp_pause_enc_req_pdu_send(_conhdl); + return 0; + } + case 2: + llc_task_random_gen_request(_id); + llc_env[uVar2]->loc_proc_state = '\x13'; + break; + case 4: + plVar5->loc_proc_state = '\x10'; + break; + case 5: + case 7: + iVar6 = uVar2 * 0x5c; + *(undefined2 *)(iVar6 + 0x280080cc) = 0; + *(undefined2 *)(iVar6 + 0x280080ce) = 0; + *(undefined2 *)(iVar6 + 0x280080d0) = 0; + *(undefined2 *)(iVar6 + 0x280080d2) = 0; + *(undefined2 *)(iVar6 + 0x280080d4) = 0; + *(undefined2 *)(iVar6 + 0x280080d6) = 0; + llc_env[uVar2]->loc_proc_state = '\x12'; + llc_llcp_start_enc_rsp_pdu_send(_conhdl); + goto LAB_23019b1c; + case 9: + plVar5->loc_proc_state = '\r'; + param = (hci_le_start_enc_cmd *)plVar5->operation[2]; + llc_env[uVar2]->encryption_state = llc_env[uVar2]->encryption_state & 0xdf; + llc_llcp_enc_req_pdu_send(_conhdl,param); + goto LAB_23019ab4; + } + } + else { + if ((id & 2) == 0) { + return 0; + } + pplVar7 = llc_env + uVar2; + plVar5 = *pplVar7; + bVar1 = plVar5->rem_proc_state; + if (bVar1 == 8) { + _Var4 = llm_util_check_evt_mask('\x04'); + if (CONCAT31(extraout_var_00,_Var4) != 0) { + llc_task_random_gen_request(_id); + (*pplVar7)->rem_proc_state = '\x0e'; + return 0; + } + if (((*pplVar7)->encryption_state & 0x10) == 0) { + if ((id & 1) != 0) { + ble_ke_timer_set(0x102,_id,4000); + } + llc_llcp_reject_ind_pdu_send(_conhdl,'\x03','\x06'); + ble_ke_state_set(_id,id & 0xfd); + ble_ke_state_set(_id,id & 0xf9); + llc_env[uVar2]->rem_proc_state = '\0'; + } + else { + llc_llcp_terminate_ind_pdu_send(_conhdl,'\x06'); + } + } + else { + if (bVar1 < 9) { + if (bVar1 != 5) { + return 0; + } + plVar5->encryption_state = plVar5->encryption_state | 0x30; + plVar5->rem_proc_state = '\x06'; + llc_llcp_pause_enc_rsp_pdu_send(_conhdl); +LAB_23019b1c: + ble_ke_timer_set(0x102,_id,4000); + return 0; + } + if (bVar1 == 10) { + llc_llcp_start_enc_req_pdu_send(_conhdl); + (*pplVar7)->rem_proc_state = '\v'; + goto LAB_23019b1c; + } + if (bVar1 != 0xe) { + return 0; + } + pvVar3 = plVar5->operation[2]; + plVar5->rem_proc_state = '\t'; + (*ble_memcpy_ptr)(&plVar5->encrypt,(void *)((int)pvVar3 + 0xd),8); + *(undefined2 *)(uVar2 * 0x5c + 0x280080c4) = *(undefined2 *)((int)pvVar3 + 0x15); + *(undefined2 *)(uVar2 * 0x5c + 0x280080c6) = *(undefined2 *)((int)pvVar3 + 0x17); + llc_llcp_enc_rsp_pdu_send(_conhdl,(llcp_enc_req *)((int)pvVar3 + 2)); + llc_ltk_req_send(_conhdl,(llcp_enc_req *)((int)pvVar3 + 2)); + } +LAB_23019ab4: + llc_util_clear_operation_ptr(uVar2,2); + } + return 0; +} + + + +undefined4 llc_chnl_assess_timer_handler(uint param_1) + +{ + byte id; + uint8_t conhdl; + undefined3 extraout_var; + uint8_t uVar1; + llc_env_tag *plVar2; + le_chnl_map lStack48; + le_chnl_map alStack40 [4]; + + plVar2 = llc_env[param_1 >> 8]; + _id = (ke_task_id_t)param_1; + id = ble_ke_state_get(_id); + if ((id & 0xf) != 0xf) { + if (plVar2->loc_proc_state != '\x06') { + llm_util_get_channel_map(alStack40); + _conhdl = (uint16_t)(param_1 >> 8); + conhdl = llc_ch_assess_get_local_ch_map(_conhdl,&lStack48,alStack40); + uVar1 = (plVar2->chnl_assess).reassess_count + -1; + (plVar2->chnl_assess).reassess_count = uVar1; + if ((uVar1 == '\0') || (CONCAT31(extraout_var,conhdl) < 2)) { + llc_ch_assess_reass_ch(_conhdl,&lStack48,alStack40,conhdl); + } + (*ble_memcpy_ptr)(&plVar2->n_ch_map,&lStack48,5); + ble_ke_msg_send_basic(0x108,_id,_id); + } + ble_ke_timer_set(0x105,_id,(uint)llm_le_env.ch_map_assess.assess_timer); + } + return 0; +} + + + +int llc_llcp_rsp_to_ind_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined2 in_register_00002032; + + llc_util_dicon_procedure((uint16_t)(CONCAT22(in_register_00002032,dest_id) >> 8),'\"'); + return 0; +} + + + +undefined4 llc_link_sup_to_ind_handler(uint param_1) + +{ + byte bVar1; + + bVar1 = ble_ke_state_get((ke_task_id_t)param_1); + if ((bVar1 & 0x7f) != 0x7f) { + if ((*(byte *)((int)&llc_env[param_1 >> 8]->elt[2].ea_cb_cancel + 2) & 2) == 0) { + llc_util_dicon_procedure((uint16_t)(param_1 >> 8),'\b'); + } + else { + ble_ke_timer_set(0x101,(ke_task_id_t)param_1 & 0xff00 | 1,(uint)llc_env[param_1 >> 8]->sup_to) + ; + } + } + return 0; +} + + + +undefined4 llc_auth_payl_nearly_to_ind_handler(uint param_1) + +{ + byte id; + _Bool _Var1; + undefined3 extraout_var; + + _id = (ke_task_id_t)param_1; + id = ble_ke_state_get(_id); + if ((id & 0xf) != 0xf) { + if ((id & 1) == 0) { + if ((id & 4) != 0) { + return 2; + } + _Var1 = ble_ke_timer_active(0x102,_id); + if (CONCAT31(extraout_var,_Var1) == 0) { + ble_ke_state_set(_id,id | 1); + llc_env[param_1 >> 8]->loc_proc_state = '\x05'; + llc_llcp_ping_req_pdu_send((uint16_t)(param_1 >> 8)); + ble_ke_timer_set(0x102,_id,4000); + } + } + else { + if (llc_env[param_1 >> 8]->loc_proc_state != '\x05') { + return 2; + } + } + } + return 0; +} + + + +undefined4 llc_data_ind_handler(void *param_1,uint param_2) + +{ + byte bVar1; + uint16_t conhdl; + + bVar1 = ble_ke_state_get((ke_task_id_t)param_2); + if ((bVar1 & 0xf) == 0xf) { + em_buf_rx_free(*(uint8_t *)((int)param_1 + 6)); + } + else { + conhdl = (uint16_t)(param_2 >> 8); + if ((llc_env[param_2 >> 8]->encryption_state & 8) == 0) { + *(undefined2 *)((int)param_1 + -8) = 0x806; + *(uint16_t *)((int)param_1 + -6) = conhdl; + hci_send_2_host(param_1); + return 1; + } + em_buf_rx_free(*(uint8_t *)((int)param_1 + 6)); + llc_util_dicon_procedure(conhdl,'='); + } + return 0; +} + + + +undefined4 lld_stop_ind_handler(uint param_1) + +{ + uint uVar1; + ke_state_t id; + byte bVar2; + _Bool _Var3; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + uint16_t conhdl; + ushort *puVar4; + uint8_t status; + llc_env_tag *plVar5; + + _id = (ke_task_id_t)param_1; + id = ble_ke_state_get(_id); + if (CONCAT31(extraout_var,id) != 0x7f) { + uVar1 = param_1 >> 8; + puVar4 = (ushort *)(uVar1 * 0x5c + 0x28008092); + *puVar4 = *puVar4 & 0xfcff; + plVar5 = llc_env[uVar1]; + status = plVar5->disc_reason; + bVar2 = ble_ke_state_get(_id); + if ((CONCAT31(extraout_var_00,bVar2) != 0xf) && + (status = '\b', (llc_env[uVar1]->llc_status & 0x100) == 0)) { + status = '>'; + } + if ((bVar2 & 1) != 0) { + conhdl = (uint16_t)(param_1 >> 8); + switch((uint)plVar5->loc_proc_state - 1 & 0xff) { + case 0: + llc_feats_rd_event_send(status,conhdl,&plVar5->feats_used); + break; + case 1: + llc_version_rd_event_send(status,conhdl); + break; + case 6: + case 7: + case 8: + _Var3 = llm_util_check_evt_mask('\x02'); + if ((CONCAT31(extraout_var_01,_Var3) != 0) && ((plVar5->llc_status & 0x40) != 0)) { + llc_con_update_complete_send(status,conhdl,(lld_evt_tag *)0x0); + } + break; + case 9: + case 10: + case 0xb: + case 0xc: + case 0xd: + case 0xe: + case 0xf: + case 0x10: + case 0x11: + case 0x12: + if ((llc_env[uVar1]->encryption_state & 0x10) == 0) { + llc_common_enc_change_evt_send(conhdl,'\0',status); + } + else { + llc_common_enc_key_ref_comp_evt_send(conhdl,status); + } + } + } + llc_discon_event_complete_send(_id,'\0',(uint8_t)(param_1 >> 8),status); + ble_ke_timer_clear(0x101,_id); + ble_ke_timer_clear(0x102,_id); + ble_ke_timer_clear(0x103,_id); + ble_ke_timer_clear(0x104,_id); + llc_stop(uVar1); + } + return 0; +} + + +/* +Unable to decompile 'llc_check_trafic_paused' +Cause: Exception while decompiling 23019ffe: Decompiler process died + +*/ + + +uint8_t llc_util_get_free_conhdl(uint16_t *conhdl) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint16_t uVar2; + + kVar1 = ble_ke_state_get(1); + if (CONCAT31(extraout_var,kVar1) == 0x7f) { + uVar2 = 0; + } + else { + kVar1 = ble_ke_state_get(0x101); + if (CONCAT31(extraout_var_00,kVar1) != 0x7f) { + return '\t'; + } + uVar2 = 1; + } + *conhdl = uVar2; + return '\0'; +} + + + +uint8_t llc_util_get_nb_active_link(void) + +{ + bool bVar1; + ke_state_t kVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + + kVar2 = ble_ke_state_get(1); + bVar1 = CONCAT31(extraout_var,kVar2) != 0x7f; + kVar2 = ble_ke_state_get(0x101); + if (CONCAT31(extraout_var_00,kVar2) != 0x7f) { + bVar1 = (bool)(bVar1 + '\x01'); + } + return (uint8_t)bVar1; +} + + +/* +Unable to decompile 'llc_util_dicon_procedure' +Cause: Exception while decompiling 2301a0d8: Decompiler process died + +*/ + + +// WARNING: Exceeded maximum restarts with more pending + +void llc_util_update_channel_map(uint16_t conhdl,le_chnl_map *map) + +{ + undefined2 in_register_0000202a; + + // WARNING: Could not recover jumptable at 0x2301a14c. Too many branches + // WARNING: Treating indirect jump as call + (*ble_memcpy_ptr)(&llc_env[CONCAT22(in_register_0000202a,conhdl)]->ch_map,(void *)0x5); + return; +} + + + +void llc_util_set_auth_payl_to_margin(lld_evt_tag *evt) + +{ + int iVar1; + uint16_t uVar2; + uint uVar3; + + iVar1 = (uint)evt->interval * (uint)*(ushort *)(evt->evt + 10); + uVar3 = iVar1 * 8; + while ((uint)llc_env[evt->conhdl]->auth_payl_to << 4 < uVar3) { + uVar3 = uVar3 - iVar1; + } + uVar2 = (uint16_t)(uVar3 >> 4); + if (uVar3 >> 4 == 0) { + uVar2 = 1; + } + llc_env[evt->conhdl]->auth_payl_to_margin = uVar2; + return; +} + + + +void llc_util_clear_operation_ptr(int param_1,int param_2) + +{ + void *pvVar1; + + pvVar1 = llc_env[param_1]->operation[param_2]; + if (pvVar1 != (void *)0x0) { + llc_env[param_1]->operation[param_2] = (void *)0x0; + ble_ke_msg_free((ke_msg *)((int)pvVar1 + -0xc)); + return; + } + return; +} + + + +void llc_util_bw_mgt(uint16_t conhdl) + +{ + uint uVar1; + uint uVar2; + ea_elt_tag *elt_connect; + uint8_t uVar3; + undefined2 in_register_0000202a; + undefined3 extraout_var; + undefined3 extraout_var_00; + llc_env_tag *plVar4; + + plVar4 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + if (plVar4 == (llc_env_tag *)0x0) { + return; + } + elt_connect = plVar4->elt; + uVar1 = (uint)(plVar4->data_len_ext_info).conn_eff_max_rx_time + + (uint)(plVar4->data_len_ext_info).conn_eff_max_tx_time + 0x96; + uVar2 = uVar1 & 0xffff; + if ((uint)*(ushort *)(elt_connect[1].ea_cb_cancel + 8) * 0x2710000 >> 0x10 < uVar2) { + *(short *)(elt_connect[1].ea_cb_cancel + 8) = (short)((int)(uVar2 + 0x270) / 0x271); + uVar3 = lld_get_mode(conhdl); + if (CONCAT31(extraout_var,uVar3) == 3) { + elt_connect->duration_min = (uint16_t)(uVar1 * 0x10000 >> 0x10); + } + uVar3 = llc_util_get_nb_active_link(); + if (CONCAT31(extraout_var_00,uVar3) != 1) { + lld_util_anchor_point_move(elt_connect); + return; + } + } + return; +} + + + +void llc_end_evt_defer(int param_1) + +{ + byte bVar1; + llc_env_tag *plVar2; + + if (llc_env[param_1] != (llc_env_tag *)0x0) { + bVar1 = ble_ke_state_get((ushort)(param_1 << 8) | 1); + if ((bVar1 & 0xf) == 0xf) { + plVar2 = llc_env[param_1]; + if ((plVar2->llc_status & 0x200) != 0) { + plVar2->llc_status = plVar2->llc_status & 0xfdff; + llc_util_dicon_procedure((uint16_t)param_1,plVar2->disc_reason); + } + } + llc_util_bw_mgt((uint16_t)param_1); + return; + } + return; +} + + +/* +Unable to decompile 'llc_pdu_llcp_tx_ack_defer' +Cause: Exception while decompiling 2301a29a: Decompiler process died + +*/ + + +void llc_pdu_acl_tx_ack_defer(uint16_t conhdl,uint8_t tx_cnt) + +{ + undefined2 in_register_0000202a; + undefined3 in_register_0000202d; + + if (llc_env[CONCAT22(in_register_0000202a,conhdl)] != (llc_env_tag *)0x0) { + if (CONCAT31(in_register_0000202d,tx_cnt) != 0) { + llc_common_nb_of_pkt_comp_evt_send(conhdl,tx_cnt); + } + llc_check_trafic_paused((uint8_t)conhdl); + return; + } + return; +} + + + +void llc_pdu_defer(uint16_t conhdl,uint16_t status,uint8_t rssi,uint8_t channel,uint8_t length) + +{ + int8_t iVar1; + undefined2 in_register_0000202a; + int iVar2; + ushort task_id; + undefined2 in_register_0000202e; + undefined3 in_register_00002035; + undefined3 in_register_00002039; + llc_env_tag *plVar3; + llc_env_tag **pplVar4; + llc_env_tag *plVar5; + + iVar2 = CONCAT22(in_register_0000202a,conhdl); + pplVar4 = llc_env + iVar2; + plVar5 = *pplVar4; + if (plVar5 != (llc_env_tag *)0x0) { + iVar1 = (*rwip_rf.rssi_convert)(rssi); + plVar3 = *pplVar4; + plVar5->rssi = iVar1; + llc_ch_assess_local(iVar2,CONCAT22(in_register_0000202e,status),(int)plVar3->rssi, + CONCAT31(in_register_00002035,channel)); + if ((status & 0x1d) == 0) { + task_id = conhdl << 8 | 1; + ble_ke_timer_set(0x101,task_id,(uint)(*pplVar4)->sup_to); + if (((((status & 0x120) == 0) && (CONCAT31(in_register_00002039,length) != 0)) && + (plVar5 = *pplVar4, (plVar5->encryption_state & 3) == 3)) && + ((plVar5->llc_status & 8) == 0)) { + ble_ke_timer_set(0x103,task_id, + (uint)plVar5->auth_payl_to - (uint)plVar5->auth_payl_to_margin); + ble_ke_timer_set(0x104,task_id,(uint)(*pplVar4)->auth_payl_to); + } + } + else { + if ((status & 0x10) != 0) { + llc_util_dicon_procedure(conhdl,'='); + } + } + plVar5 = llc_env[iVar2]; + if ((plVar5->llc_status & 0x20) != 0) { + plVar5->llc_status = plVar5->llc_status & 0xffdf; + plVar5->sup_to = plVar5->n_sup_to; + } + } + return; +} + + + +int llm_dft_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + return 0; +} + + + +int llm_le_set_host_ch_class_cmd_sto_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + llm_le_env.ch_map_assess.llm_le_set_host_ch_class_cmd_sto = true; + return 0; +} + + + +int llm_ecc_result_ind_handler + (ke_msg_id_t msgid,ecc_result_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *param_00; + _Bool _Var1; + undefined3 extraout_var; + undefined *puVar2; + undefined3 extraout_var_00; + + if (llm_le_env.cur_ecc_multiplication == LLM_DHKEY_GENERATION) { + _Var1 = llm_util_check_evt_mask('\b'); + if (CONCAT31(extraout_var,_Var1) == 0) { + llm_le_env.cur_ecc_multiplication = LLM_ECC_IDLE; + return 0; + } + param_00 = (undefined *)ble_ke_msg_alloc(0x804,0,0x3e,0x22); + *param_00 = 9; + param_00[1] = 0; + puVar2 = param_00 + 2; + } + else { + if (llm_le_env.cur_ecc_multiplication != LLM_PUBLIC_KEY_GENERATION) { + llm_le_env.cur_ecc_multiplication = LLM_ECC_IDLE; + return 0; + } + _Var1 = llm_util_check_evt_mask('\a'); + if (CONCAT31(extraout_var_00,_Var1) == 0) { + llm_le_env.cur_ecc_multiplication = LLM_ECC_IDLE; + return 0; + } + param_00 = (undefined *)ble_ke_msg_alloc(0x804,0,0x3e,0x42); + *param_00 = 8; + param_00[1] = 0; + (*ble_memcpy_ptr)(param_00 + 2,param,0x20); + param = (ecc_result_ind *)param->key_res_y; + puVar2 = param_00 + 0x22; + } + (*ble_memcpy_ptr)(puVar2,param,0x20); + hci_send_2_host(param_00); + llm_le_env.cur_ecc_multiplication = LLM_ECC_IDLE; + return 0; +} + + + +int llm_enc_req_handler(ke_msg_id_t msgid,llm_enc_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + ble_co_list_push_back(&llm_le_env,param[-1].plain_data + 4); + if (llm_le_env.enc_pend == false) { + llm_encryption_start(param); + } + return 1; +} + + + +int lld_stop_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + byte bVar1; + ke_state_t kVar2; + undefined3 extraout_var; + byte state_id; + + bVar1 = ble_ke_state_get(0); + if (((bVar1 & 0xf0) != 0x20) && (bVar1 = ble_ke_state_get(0), (bVar1 & 0xf) != 3)) { + return 0; + } + kVar2 = ble_ke_state_get(0); + if (CONCAT31(extraout_var,kVar2) == 0x23) { + if ((llm_le_env.state & 0xf0) == 0x10) { + llm_common_cmd_complete_send(llm_le_env.opcode,'\0'); + llm_le_env.state = llm_le_env.state & 0xf; + } + llm_le_env.elt = (ea_elt_tag *)0x0; + if ((byte)(llm_le_env.state2 - 1) < 2) { +LAB_2301a6d0: + llm_common_cmd_complete_send(llm_le_env.opcode2,'\0'); + if (llm_le_env.state2 == '\x02') { + llc_le_con_cmp_evt_send('\x02',0xffff,(llc_create_con_req_ind *)0x0); + } + llm_le_env.state2 = llm_le_env.state2 & 0xf0; + } + } + else { + bVar1 = ble_ke_state_get(0); + if (((bVar1 & 0xf0) == 0x20) && (llm_le_env.last_opcode == false)) { + if ((llm_le_env.state & 0xf0) == 0x10) { + llm_common_cmd_complete_send(llm_le_env.opcode,'\0'); + llm_le_env.state = llm_le_env.state & 0xf; + } + llm_le_env.elt = (ea_elt_tag *)0x0; + goto LAB_2301a702; + } + bVar1 = ble_ke_state_get(0); + if (((bVar1 & 0xf) != 3) || (llm_le_env.last_opcode == false)) { + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + if (((byte)(llm_le_env.state2 - 1) < 2) || (llm_le_env.state2 == '\x11')) goto LAB_2301a6d0; + } + llm_le_env.elt_coext_scan = (ea_elt_tag *)0x0; +LAB_2301a702: + bVar1 = ble_ke_state_get(0); + if (llm_le_env.elt == (ea_elt_tag *)0x0) { + state_id = 0; + if (llm_le_env.elt_coext_scan != (ea_elt_tag *)0x0) { + state_id = bVar1 & 0xf; + } + } + else { + if (llm_le_env.elt_coext_scan != (ea_elt_tag *)0x0) { + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + state_id = bVar1 & 0xf0; + } + ble_ke_state_set(0,state_id); + llm_le_env.conhdl_alloc = 0xffff; + return 0; +} + + + +void llc_ch_assess_local(int param_1,uint param_2,int param_3,int param_4) + +{ + char cVar1; + int8_t iVar2; + + param_4 = (int)llc_env[param_1]->operation + param_4; + cVar1 = *(char *)(param_4 + 0x14); + if ((param_2 & 1) == 0) { + if ((param_2 & 8) != 0) goto LAB_2301a7a4; + cVar1 = cVar1 + '\x03'; + } + else { + if (llm_le_env.ch_map_assess.rssi_noise_limit < param_3) { +LAB_2301a7a4: + cVar1 = cVar1 + -3; + } + else { + cVar1 = cVar1 + -1; + if ((llc_env[param_1]->chnl_assess).latency_en != false) goto LAB_2301a7b4; + } + } + *(char *)(param_4 + 0x14) = cVar1; +LAB_2301a7b4: + iVar2 = llm_le_env.ch_map_assess.lower_limit; + if ((*(char *)(param_4 + 0x14) < llm_le_env.ch_map_assess.lower_limit) || + (iVar2 = llm_le_env.ch_map_assess.upper_limit, + llm_le_env.ch_map_assess.upper_limit < *(char *)(param_4 + 0x14))) { + *(int8_t *)(param_4 + 0x14) = iVar2; + } + return; +} + + + +uint8_t llc_ch_assess_get_local_ch_map(uint16_t conhdl,le_chnl_map *map,le_chnl_map *hostmap) + +{ + llc_env_tag *plVar1; + uint8_t uVar2; + undefined2 in_register_0000202a; + uint uVar3; + int iVar4; + uint uVar5; + + plVar1 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + (*ble_memset_ptr)(map,0,5); + uVar3 = 0x24; + uVar2 = '\0'; + do { + iVar4 = (int)(char)uVar3 >> 3; + uVar5 = 1 << (uVar3 & 7) & 0xff; + if (((hostmap->map[iVar4] & uVar5) != 0) && + (llm_le_env.ch_map_assess.lower_limit < (plVar1->chnl_assess).rcvd_quality[uVar3])) { + uVar2 = uVar2 + '\x01'; + map->map[iVar4] = (byte)uVar5 | map->map[iVar4]; + } + uVar3 = uVar3 - 1; + } while (uVar3 != 0xffffffff); + return uVar2; +} + + + +le_chnl_map * llc_ch_assess_get_current_ch_map(uint16_t conhdl) + +{ + undefined2 in_register_0000202a; + + return &llc_env[CONCAT22(in_register_0000202a,conhdl)]->ch_map; +} + + + +void llc_ch_assess_reass_ch(uint16_t conhdl,le_chnl_map *map,le_chnl_map *hostmap,uint8_t nb_chgood) + +{ + undefined2 in_register_0000202a; + uint uVar1; + undefined3 in_register_00002035; + uint uVar2; + uint uVar3; + char cVar4; + byte *pbVar5; + llc_env_tag *plVar6; + + plVar6 = llc_env[CONCAT22(in_register_0000202a,conhdl)]; + uVar1 = 10; + if (2 < CONCAT31(in_register_00002035,nb_chgood)) { + uVar1 = CONCAT31(in_register_00002035,nb_chgood) * 0x20 + 0x7f >> 7; + } + cVar4 = '%'; + (plVar6->chnl_assess).reassess_count = llm_le_env.ch_map_assess.reassess_count; + uVar3 = (uint)(plVar6->chnl_assess).reassess_cursor; + do { + uVar2 = uVar3 + 0xb & 0xff; + if (0x24 < uVar2) { + uVar2 = uVar3 - 0x1a & 0xff; + } + pbVar5 = map->map + (uVar2 >> 3); + uVar3 = 1 << (uVar2 & 7) & 0xff; + if (((uVar3 & *pbVar5) == 0) && ((hostmap->map[uVar2 >> 3] & uVar3) != 0)) { + (plVar6->chnl_assess).rcvd_quality[uVar2] = '\0'; + *pbVar5 = (byte)uVar3 | *pbVar5; + uVar1 = uVar1 - 1 & 0xffff; + } + cVar4 = cVar4 + -1; + } while ((cVar4 != '\0') && (uVar3 = uVar2, uVar1 != 0)); + (plVar6->chnl_assess).reassess_cursor = (uint8_t)uVar2; + return; +} + + + +undefined4 hci_le_set_data_len_cmd_handler(ushort *param_1,ke_task_id_t param_2,uint16_t param_3) + +{ + undefined4 uVar1; + byte bVar2; + uint8_t status; + llc_env_tag *plVar3; + + bVar2 = ble_ke_state_get(param_2); + if ((bVar2 & 0xf) == 0xf) { + status = '\f'; + } + else { + plVar3 = llc_env[*param_1]; + if ((plVar3->data_len_ext_info).send_req_not_allowed == false) { + if ((((ushort)(param_1[1] - 0x1b) < 0xe1) && ((ushort)(param_1[2] - 0x148) < 0x701)) && + (*param_1 < 3)) { + if (((plVar3->data_len_ext_info).conn_eff_max_tx_octets != param_1[1]) || + ((plVar3->data_len_ext_info).conn_eff_max_tx_time != param_1[2])) { + *(ushort **)(plVar3->operation + 3) = param_1; + ble_ke_msg_send_basic(0x107,param_2,param_2); + status = '\0'; + uVar1 = 1; + goto LAB_2301a9b0; + } + status = '\0'; + } + else { + status = '\x12'; + } + } + else { + status = '\x1a'; + } + } + uVar1 = 0; +LAB_2301a9b0: + llc_common_cmd_complete_send(param_3,status,*param_1); + return uVar1; +} + + + +undefined4 +hci_le_rem_con_param_req_neg_reply_cmd_handler + (ushort *param_1,ke_task_id_t param_2,uint16_t param_3) + +{ + byte bVar1; + uint8_t status; + + bVar1 = ble_ke_state_get(param_2); + status = '\f'; + if ((((bVar1 & 0xf) != 0xf) && ((bVar1 & 2) != 0)) && + (llc_env[*param_1]->rem_proc_state == '\x02')) { + status = '\x12'; + if (*(char *)(param_1 + 1) == ';') { + llc_util_clear_operation_ptr(1); + ble_ke_state_set(param_2,bVar1 & 0xfd); + llc_env[*param_1]->rem_proc_state = '\0'; + llc_llcp_reject_ind_pdu_send(*param_1,'\x0f',*(uint8_t *)(param_1 + 1)); + status = '\0'; + } + } + llc_common_cmd_complete_send(param_3,status,*param_1); + return 0; +} + + + +undefined4 +hci_le_rem_con_param_req_reply_cmd_handler(ushort *param_1,ke_task_id_t param_2,uint16_t param_3) + +{ + llc_con_upd_req_ind *param; + byte bVar1; + uint8_t status; + uint8_t uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + ushort uVar3; + llc_env_tag *plVar4; + + bVar1 = ble_ke_state_get(param_2); + status = '\f'; + if (((bVar1 & 0xf) != 0xf) && ((bVar1 & 2) != 0)) { + plVar4 = llc_env[*param_1]; + if (plVar4->rem_proc_state == '\x02') { + param = (llc_con_upd_req_ind *)plVar4->operation[1]; + status = lld_get_mode(*param_1); + if (CONCAT31(extraout_var,status) == 3) { + param->operation = '\x02'; + uVar3 = param->interval_min; + if (param_1[1] < param->interval_min) { + uVar3 = param_1[1]; + } + param->interval_min = uVar3; + uVar3 = param->interval_max; + if (param->interval_max < param_1[2]) { + uVar3 = param_1[2]; + } + param->interval_max = uVar3; + param->con_latency = param_1[3]; + uVar3 = param->superv_to; + if (param->superv_to < param_1[4]) { + uVar3 = param_1[4]; + } + param->superv_to = uVar3; + ble_ke_msg_send(param); + ble_ke_state_set(param_2,bVar1 & 0xfd); + plVar4->rem_proc_state = '\0'; + llc_env[*param_1]->operation[1] = (void *)0x0; + status = '\0'; + } + else { + uVar2 = lld_get_mode(*param_1); + status = '\0'; + if (CONCAT31(extraout_var_00,uVar2) == 4) { + param->interval_min = param_1[1]; + param->interval_max = param_1[2]; + param->con_latency = param_1[3]; + param->superv_to = param_1[4]; + lld_con_param_rsp(*param_1,plVar4->elt,param); + plVar4->rem_proc_state = '\x03'; + llc_llcp_con_param_rsp_pdu_send(*param_1,param); + ble_ke_timer_set(0x102,param_2,4000); + llc_util_clear_operation_ptr((uint)*param_1,1); + status = '\0'; + } + } + } + } + llc_common_cmd_complete_send(param_3,status,*param_1); + return 0; +} + + +/* +Unable to decompile 'hci_le_ltk_req_neg_reply_cmd_handler' +Cause: Exception while decompiling 2301abe0: Decompiler process died + +*/ + + +undefined4 hci_le_ltk_req_reply_cmd_handler(ushort *param_1,ke_task_id_t param_2,uint16_t param_3) + +{ + byte bVar1; + void *pvVar2; + uint8_t status; + + bVar1 = ble_ke_state_get(param_2); + status = '\f'; + if ((((bVar1 & 0xf) != 0xf) && ((bVar1 & 2) != 0)) && (llc_env[*param_1]->rem_proc_state == '\t')) + { + pvVar2 = ble_ke_msg_alloc(4,0,param_2,0x20); + (*ble_memcpy_ptr)(pvVar2,param_1 + 1,0x10); + (*ble_memcpy_ptr)((void *)((int)pvVar2 + 0x10),&llc_env[*param_1]->encrypt,0x10); + ble_ke_msg_send(pvVar2); + status = '\0'; + llc_env[*param_1]->rem_proc_state = '\n'; + } + llc_common_cmd_complete_send(param_3,status,*param_1); + return 0; +} + + + +undefined4 hci_disconnect_cmd_handler(uint16_t *param_1,ke_task_id_t param_2,uint16_t param_3) + +{ + byte bVar1; + uint8_t status; + int iVar2; + undefined4 local_18; + undefined2 uStack20; + undefined uStack18; + + bVar1 = ble_ke_state_get(param_2); + status = '\f'; + if ((bVar1 & 0xf) != 0xf) { + local_18 = 0x15141305; + uStack20 = 0x291a; + uStack18 = 0x3b; + iVar2 = 0; + do { + if (*(uint8_t *)((int)&local_18 + iVar2) == *(uint8_t *)(param_1 + 1)) { + llc_llcp_terminate_ind_pdu_send(*param_1,*(uint8_t *)(param_1 + 1)); + status = '\0'; + goto LAB_2301adc2; + } + iVar2 = iVar2 + 1; + } while (iVar2 != 7); + status = '\x12'; + } +LAB_2301adc2: + if (llc_env[*param_1]->disc_event_sent == false) { + llc_common_cmd_status_send(param_3,status,*param_1); + llc_env[*param_1]->disc_event_sent = true; + } + llc_env[*param_1]->disc_event_sent = false; + return 0; +} + + +/* +Unable to decompile 'hci_le_start_enc_cmd_handler' +Cause: Exception while decompiling 2301ae12: Decompiler process died + +*/ + + +int hci_le_rd_rem_used_feats_cmd_handler + (ke_msg_id_t msgid,hci_le_rd_rem_used_feats_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + byte bVar1; + byte status; + + bVar1 = ble_ke_state_get(dest_id); + if ((bVar1 & 0xf) == 0xf) { + status = 0xc; + } + else { + if ((llc_env[param->conhdl]->llc_status & 1) == 0) { + status = bVar1 & 5; + if ((bVar1 & 5) != 0) { + return 2; + } + ble_ke_state_set(dest_id,bVar1 | 1); + llc_env[param->conhdl]->loc_proc_state = '\x01'; + llc_llcp_feats_req_pdu_send(param->conhdl); + ble_ke_timer_set(0x102,dest_id,4000); + } + else { + status = 0; + } + } + llc_common_cmd_status_send(src_id,status,param->conhdl); + if ((llc_env[param->conhdl]->llc_status & 1) != 0) { + llc_feats_rd_event_send('\0',param->conhdl,&llc_env[param->conhdl]->feats_used); + } + return 0; +} + + + +undefined4 hci_le_rd_chnl_map_cmd_handler(ke_task_id_t *param_1,ke_task_id_t param_2) + +{ + byte bVar1; + undefined *param; + undefined uVar2; + + param = (undefined *)ble_ke_msg_alloc(0x801,*param_1,0x2015,10); + bVar1 = ble_ke_state_get(param_2); + uVar2 = 0xc; + if ((bVar1 & 0xf) != 0xf) { + (*ble_memcpy_ptr)(param + 4,&llc_env[*param_1]->ch_map,5); + uVar2 = 0; + } + *param = uVar2; + *(ke_task_id_t *)(param + 2) = *param_1; + hci_send_2_host(param); + return 0; +} + + + +undefined4 hci_rd_auth_payl_to_cmd_handler(ke_task_id_t *param_1,uint param_2) + +{ + byte bVar1; + undefined *param; + + bVar1 = ble_ke_state_get((ke_task_id_t)param_2); + param = (undefined *)ble_ke_msg_alloc(0x801,*param_1,0xc7b,6); + if ((bVar1 & 0xf) == 0xf) { + *param = 0xc; + } + else { + *param = 0; + *(uint16_t *)(param + 4) = llc_env[param_2 >> 8]->auth_payl_to; + } + *(ke_task_id_t *)(param + 2) = *param_1; + hci_send_2_host(param); + return 0; +} + + + +undefined4 hci_rd_rssi_cmd_handler(ke_task_id_t *param_1,ke_task_id_t param_2) + +{ + byte bVar1; + undefined *param; + + param = (undefined *)ble_ke_msg_alloc(0x801,*param_1,0x1405,6); + bVar1 = ble_ke_state_get(param_2); + if ((bVar1 & 0xf) == 0xf) { + *param = 0xc; + param[4] = 0; + } + else { + *param = 0; + param[4] = llc_env[*param_1]->rssi; + } + *(ke_task_id_t *)(param + 2) = *param_1; + hci_send_2_host(param); + return 0; +} + + + +undefined4 hci_rd_tx_pwr_lvl_cmd_handler(ke_task_id_t *param_1,ke_task_id_t param_2) + +{ + byte bVar1; + uint8_t uVar2; + undefined *param; + undefined uVar3; + + param = (undefined *)ble_ke_msg_alloc(0x801,*param_1,0xc2d,6); + bVar1 = ble_ke_state_get(param_2); + if ((bVar1 & 0xf) == 0xf) { + uVar3 = 0xc; +LAB_2301b180: + *param = uVar3; + param[4] = 0; + } + else { + *param = 0; + if (*(char *)(param_1 + 1) == '\0') { + uVar2 = (*rwip_rf.txpwr_dbm_get) + ((uint8_t)*(undefined2 *)((uint)*param_1 * 0x5c + 0x280080a0),'\x01'); + } + else { + if (*(char *)(param_1 + 1) != '\x01') { + uVar3 = 0x12; + goto LAB_2301b180; + } + uVar2 = (*rwip_rf.txpwr_dbm_get)(rwip_rf.txpwr_max,'\x01'); + } + param[4] = uVar2; + } + *(ke_task_id_t *)(param + 2) = *param_1; + hci_send_2_host(param); + return 0; +} + + + +undefined4 hci_le_con_update_cmd_handler(ushort *param_1,ke_task_id_t param_2,uint16_t param_3) + +{ + byte bVar1; + ushort uVar2; + ushort uVar3; + byte status; + uint8_t status_00; + _Bool _Var4; + undefined3 extraout_var; + undefined *puVar5; + undefined3 extraout_var_00; + uint uVar6; + uint uVar7; + uint uVar8; + llc_env_tag *plVar9; + lld_evt_tag *evt; + ea_elt_tag *peVar10; + + status = ble_ke_state_get(param_2); + if ((status & 0xf) == 0xf) { + evt = (lld_evt_tag *)0x0; + status_00 = -1; + status = 0xc; + goto LAB_2301b34e; + } + plVar9 = llc_env[*param_1]; + peVar10 = plVar9->elt; + status_00 = lld_get_mode(*param_1); + evt = (lld_evt_tag *)&peVar10->env; + if (CONCAT31(extraout_var,status_00) == 4) { + if ((plVar9->llc_status & 1) != 0) { + bVar1 = (plVar9->feats_used).feats[0]; + status_00 = '\x1a'; + status = bVar1 & 2; + if ((bVar1 & 2) == 0) goto LAB_2301b34e; + } + if (plVar9->peer_sup_conn_param_req != false) goto LAB_2301b264; + status_00 = '\x1a'; +LAB_2301b342: + status = 0; + } + else { +LAB_2301b264: + uVar2 = param_1[1]; + uVar7 = (uint)param_1[2]; + if (uVar2 <= uVar7) { + if (((((uint)param_1[5] <= (uint)param_1[6]) && (param_1[2] < 0xc81)) && (5 < uVar2)) && + (((uVar3 = param_1[3], uVar3 < 500 && + (uVar6 = (uint)param_1[4], (uVar6 - 10 & 0xffff) < 0xc77)) && + (((uint)uVar3 + 1) * uVar7 < uVar6 << 2)))) { + uVar8 = (uint)(*(ushort *)&peVar10[2].ea_cb_stop >> 1); + if (((uVar8 < uVar2) || (uVar7 < uVar8)) || + ((uVar7 = (uint)plVar9->elt->duration_min / 0x4e2, uVar7 < (uint)param_1[5] || + ((((uint)param_1[6] < uVar7 || ((uint)plVar9->sup_to != uVar6)) || + (status_00 = '\0', + (uint)*(ushort *)((int)&peVar10[2].linked_element + 2) - 1 != (uint)uVar3)))))) { + puVar5 = (undefined *)ble_ke_msg_alloc(0x109,param_2,param_2,0x22); + *puVar5 = 0; + status_00 = -1; + *(ushort *)(puVar5 + 2) = param_1[1]; + *(ushort *)(puVar5 + 4) = param_1[2]; + *(ushort *)(puVar5 + 6) = param_1[3]; + *(ushort *)(puVar5 + 8) = param_1[4]; + *(ushort *)(puVar5 + 10) = param_1[5]; + *(ushort *)(puVar5 + 0xc) = param_1[6]; + ble_ke_msg_send(); + } + goto LAB_2301b342; + } + } + status_00 = -1; + status = 0x12; + } +LAB_2301b34e: + llc_common_cmd_status_send(param_3,status,*param_1); + _Var4 = llm_util_check_evt_mask('\x02'); + if ((CONCAT31(extraout_var_00,_Var4) != 0) && (status_00 != -1)) { + llc_con_update_complete_send(status_00,*param_1,evt); + } + return 0; +} + + + +undefined4 hci_wr_auth_payl_to_cmd_handler(ke_task_id_t *param_1,uint param_2) + +{ + llc_env_tag **pplVar1; + byte id; + undefined *param; + undefined uVar2; + llc_env_tag *plVar3; + + _id = (ke_task_id_t)param_2; + id = ble_ke_state_get(_id); + param = (undefined *)ble_ke_msg_alloc(0x801,*param_1,0xc7c,4); + if ((id & 0xf) == 0xf) { + uVar2 = 0xc; + } + else { + pplVar1 = llc_env + (param_2 >> 8); + if ((uint)*(ushort *)&(*pplVar1)->elt[2].ea_cb_stop * + (uint)*(ushort *)((int)&(*pplVar1)->elt[2].linked_element + 2) <= (uint)param_1[1] << 4) { + *param = 0; + plVar3 = *pplVar1; + plVar3->auth_payl_to = param_1[1]; + llc_util_set_auth_payl_to_margin((lld_evt_tag *)&plVar3->elt->env); + plVar3 = *pplVar1; + if ((plVar3->encryption_state & 3) == 3) { + ble_ke_timer_set(0x103,_id,(uint)plVar3->auth_payl_to - (uint)plVar3->auth_payl_to_margin); + ble_ke_timer_set(0x104,_id,(uint)(*pplVar1)->auth_payl_to); + } + goto LAB_2301b446; + } + uVar2 = 0x12; + } + *param = uVar2; +LAB_2301b446: + *(ke_task_id_t *)(param + 2) = *param_1; + hci_send_2_host(param); + return 0; +} + + + +int hci_flush_cmd_handler + (ke_msg_id_t msgid,hci_basic_conhdl_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + ushort dest_id_00; + undefined *param_00; + + dest_id_00 = param->conhdl; + param_00 = (undefined *)ble_ke_msg_alloc(0x801,dest_id_00,0xc08,4); + llc_common_flush_occurred_send(dest_id_00); + lld_pdu_tx_flush(&llc_env[dest_id_00]->elt->env); + *(ushort *)(param_00 + 2) = dest_id_00; + *param_00 = 0; + hci_send_2_host(param_00); + return 0; +} + + + +undefined4 hci_rd_rem_ver_info_cmd_handler(uint16_t *param_1,uint param_2,uint16_t param_3) + +{ + byte id; + uint8_t status; + uint16_t conhdl; + + _id = (ke_task_id_t)param_2; + id = ble_ke_state_get(_id); + if ((id & 0xf) == 0xf) { + conhdl = *param_1; + status = '\f'; + } + else { + if ((llc_env[param_2 >> 8]->llc_status & 2) != 0) { + llc_common_cmd_status_send(param_3,'\0',*param_1); + llc_version_rd_event_send('\0',(uint16_t)(param_2 >> 8)); + return 0; + } + if ((id & 5) != 0) { + return 2; + } + ble_ke_state_set(_id,id | 1); + llc_env[param_2 >> 8]->loc_proc_state = '\x02'; + llc_llcp_version_ind_pdu_send(*param_1); + ble_ke_timer_set(0x102,_id,4000); + conhdl = *param_1; + status = '\0'; + } + llc_common_cmd_status_send(param_3,status,conhdl); + return 0; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +int llc_hci_command_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_msg_handler_conflict110 *pkVar1; + undefined2 in_register_00002036; + int iVar2; + + pkVar1 = llc_hci_command_handler_tab; + iVar2 = 0; + do { + if ((uint)pkVar1->id == CONCAT22(in_register_00002036,src_id)) { + if (llc_hci_command_handler_tab[iVar2].func == (ke_msg_func_t *)0x0) { + return 0; + } + // WARNING: Could not recover jumptable at 0x2301b59a. Too many branches + // WARNING: Treating indirect jump as call + iVar2 = (*llc_hci_command_handler_tab[iVar2].func) + ((ke_msg_id_t)CONCAT22(in_register_00002036,src_id)); + return iVar2; + } + iVar2 = iVar2 + 1; + pkVar1 = pkVar1 + 1; + } while (iVar2 != 0x10); + return 0; +} + + +/* +Unable to decompile 'llc_hci_acl_data_tx_handler' +Cause: Exception while decompiling 2301b5a8: Decompiler process died + +*/ + + +int hci_vsc_set_tx_pwr(ke_msg_id_t msgid,hci_vsc_set_tx_pwr_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t status; + + status = '\x12'; + if ((byte)param->power < 0x15) { + (*rwip_rf.txpwr_max_set)(param->power); + status = '\0'; + } + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_le_wr_rfpath_compensation_cmd_handler + (ke_msg_id_t msgid,hci_le_wr_rfpath_cps_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + g_rf_txpath_compensation_value = param->rf_txpath_compensation_value; + g_rf_rxpath_compensation_value = param->rf_rxpath_compensation_value; + llm_common_cmd_complete_send(src_id,'\0'); + return 0; +} + + + +int hci_wr_le_host_supp_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + llm_local_supp_feats[1][0] = *(char *)param << 1 | llm_local_supp_feats[1][0]; + llm_common_cmd_complete_send(src_id,'\0'); + return 0; +} + + + +int hci_le_wr_suggted_dft_data_len_cmd_handler + (ke_msg_id_t msgid,hci_le_wr_suggted_dft_data_len_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t status; + + status = '\x12'; + if (((ushort)(param->suggted_max_tx_octets - 0x1b) < 0xe1) && + ((ushort)(param->suggted_max_tx_time - 0x148) < 0x701)) { + llm_le_env.data_len_val.conn_initial_max_tx_time = param->suggted_max_tx_time; + status = '\0'; + llm_le_env.data_len_val.conn_initial_max_tx_octets = param->suggted_max_tx_octets; + } + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_le_set_evt_mask_cmd_handler + (ke_msg_id_t msgid,hci_le_set_evt_mask_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + (*ble_memcpy_ptr)(&llm_le_env.eventmask,param,8); + llm_common_cmd_complete_send(src_id,'\0'); + return 0; +} + + + +int hci_le_rd_rfpath_compensation_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint16_t uVar1; + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x204c,6); + *(uint16_t *)(param_00 + 2) = g_rf_txpath_compensation_value; + uVar1 = g_rf_rxpath_compensation_value; + *param_00 = 0; + *(uint16_t *)(param_00 + 4) = uVar1; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_le_rd_trans_pwr_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t uVar1; + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x204b,3); + param_00[1] = 0; + uVar1 = rwip_rf.txpwr_max; + *param_00 = 0; + param_00[2] = uVar1; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_rd_buff_size_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x1005,10); + *(undefined2 *)(param_00 + 6) = 0; + *(undefined2 *)(param_00 + 2) = 0; + param_00[4] = 0; + *(undefined2 *)(param_00 + 8) = 0; + *param_00 = 0; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_rd_local_supp_feats_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,src_id,9); + (*ble_memcpy_ptr)(param_00 + 1,llm_local_supp_feats,8); + *param_00 = 0; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_rd_local_supp_cmds_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x1002,0x41); + (*ble_memcpy_ptr)(param_00 + 1,&llm_local_cmds,0x40); + *param_00 = 0; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_rd_local_ver_info_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined2 *param_00; + + param_00 = (undefined2 *)ble_ke_msg_alloc(0x801,0,0x1001,10); + param_00[4] = 0x321; + param_00[1] = 0x321; + *param_00 = 0x900; + param_00[3] = 0x7af; + *(undefined *)(param_00 + 2) = 9; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_rd_bd_addr_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x1009,7); + (*ble_memcpy_ptr)(param_00 + 1,(void *)0x4201a3b9,6); + *param_00 = 0; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_le_rd_max_data_len_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint16_t uVar1; + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x202f,10); + *(uint16_t *)(param_00 + 6) = llm_le_env.data_len_val.suppted_max_rx_octets; + *(uint16_t *)(param_00 + 8) = llm_le_env.data_len_val.suppted_max_rx_time; + *(uint16_t *)(param_00 + 2) = llm_le_env.data_len_val.suppted_max_tx_octets; + uVar1 = llm_le_env.data_len_val.suppted_max_tx_time; + *param_00 = 0; + *(uint16_t *)(param_00 + 4) = uVar1; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_le_rd_suggted_dft_data_len_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint16_t uVar1; + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x2023,6); + *(uint16_t *)(param_00 + 2) = llm_le_env.data_len_val.conn_initial_max_tx_octets; + uVar1 = llm_le_env.data_len_val.conn_initial_max_tx_time; + *param_00 = 0; + *(uint16_t *)(param_00 + 4) = uVar1; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_le_rd_supp_states_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x201c,9); + (*ble_memcpy_ptr)(param_00 + 1,&llm_local_le_states,8); + *param_00 = 0; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_le_rd_wl_size_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x200f,2); + *param_00 = 0; + param_00[1] = 4; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_le_rd_adv_ch_tx_pw_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t uVar1; + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x2007,2); + uVar1 = (*rwip_rf.txpwr_dbm_get)(rwip_rf.txpwr_max,'\x01'); + param_00[1] = uVar1; + *param_00 = 0; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_le_rd_local_supp_feats_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x2003,9); + (*ble_memcpy_ptr)(param_00 + 1,&llm_local_le_feats,8); + *param_00 = 0; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_le_rd_buff_size_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint16_t uVar1; + undefined *param_00; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x2002,6); + param_00[4] = 2; + uVar1 = llm_le_env.data_len_val.suppted_max_tx_octets; + *param_00 = 0; + *(uint16_t *)(param_00 + 2) = uVar1; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_le_generate_dhkey_cmd_handler + (ke_msg_id_t msgid,hci_le_generate_dh_key_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t status; + int iVar1; + hci_le_generate_dh_key_cmd *phVar2; + + iVar1 = 0; + do { + if (param->public_key[iVar1] != '\0') { + status = '\0'; + goto LAB_2301bae6; + } + iVar1 = iVar1 + 1; + } while (iVar1 != 0x20); + status = '\x12'; +LAB_2301bae6: + phVar2 = (hci_le_generate_dh_key_cmd *)(param->public_key + 0x20); + do { + if (phVar2->public_key[0] != '\0') goto LAB_2301bafe; + phVar2 = (hci_le_generate_dh_key_cmd *)(phVar2->public_key + 1); + } while (param + 1 != phVar2); + status = '\x12'; +LAB_2301bafe: + if (llm_le_env.cur_ecc_multiplication == LLM_ECC_IDLE) { + if (status == '\0') { + llm_le_env.cur_ecc_multiplication = LLM_DHKEY_GENERATION; + status = ecc_generate_key256('\x02',llm_le_env.secret_key256,(u_int8 *)param, + (u_int8 *) + (hci_le_generate_dh_key_cmd *)(param->public_key + 0x20),6,0); + } + } + else { + status = '\f'; + } + llm_common_cmd_status_send(src_id,status); + return 0; +} + + + +int hci_host_nb_cmp_pkts_cmd_handler + (ke_msg_id_t msgid,hci_host_nb_cmp_pkts_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint16_t acl_pkt_nb; + uint8_t status; + uint8_t uVar1; + ushort *puVar2; + + puVar2 = param->con_hdl; + acl_pkt_nb = 0; + uVar1 = '\0'; + status = '\0'; + while (param->nb_of_hdl != uVar1) { + if (*puVar2 < 2) { + acl_pkt_nb = acl_pkt_nb + puVar2[3]; + } + else { + status = '\x12'; + } + uVar1 = uVar1 + '\x01'; + puVar2 = puVar2 + 1; + } + hci_fc_host_nb_acl_pkts_complete(acl_pkt_nb); + if (status != '\0') { + llm_common_cmd_complete_send(src_id,status); + } + return 0; +} + + + +int hci_host_buf_size_cmd_handler + (ke_msg_id_t msgid,hci_host_buf_size_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t status; + + status = hci_fc_acl_buf_size_set(param->acl_pkt_len,param->nb_acl_pkts); + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_set_evt_mask_page_2_cmd_handler + (ke_msg_id_t msgid,hci_set_evt_mask_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t status; + + status = hci_evt_mask_set((evt_mask *)param,'\x02'); + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_set_evt_mask_cmd_handler + (ke_msg_id_t msgid,hci_set_evt_mask_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t status; + + status = hci_evt_mask_set((evt_mask *)param,'\x03'); + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_set_ctrl_to_host_flow_ctrl_cmd_handler + (ke_msg_id_t msgid,hci_set_ctrl_to_host_flow_ctrl_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + byte bVar1; + uint8_t status; + + bVar1 = param->flow_cntl; + status = '\x12'; + if (bVar1 < 4) { + status = hci_fc_acl_en((_Bool)(bVar1 == 1 || bVar1 == 3)); + } + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_reset_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined2 in_register_0000202a; + + rwip_reset(CONCAT22(in_register_0000202a,msgid)); + llm_common_cmd_complete_send(src_id,'\0'); + return 0; +} + + + +int hci_le_tx_test_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t status; + undefined3 extraout_var; + undefined2 in_register_00002036; + + status = ble_ke_state_get(0); + if (CONCAT31(extraout_var,status) == 0) { + if (CONCAT22(in_register_00002036,src_id) == 0x201e) { + status = llm_test_mode_start_tx((hci_le_tx_test_cmd *)param); + } + } + else { + status = '\f'; + } + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_le_rx_test_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t status; + undefined3 extraout_var; + undefined2 in_register_00002036; + + status = ble_ke_state_get(0); + if (CONCAT31(extraout_var,status) == 0) { + if (CONCAT22(in_register_00002036,src_id) == 0x201d) { + status = llm_test_mode_start_rx((hci_le_rx_test_cmd *)param); + } + } + else { + status = '\f'; + } + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_le_rand_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *param_00; + int iVar1; + + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x2018,9); + iVar1 = bl_rand(); + param_00[1] = (char)iVar1; + param_00[2] = (char)((uint)iVar1 >> 8); + param_00[3] = (char)((uint)iVar1 >> 0x10); + param_00[4] = (char)((uint)iVar1 >> 0x18); + iVar1 = bl_rand(); + param_00[5] = (char)iVar1; + param_00[6] = (char)((uint)iVar1 >> 8); + param_00[8] = (char)((uint)iVar1 >> 0x18); + param_00[7] = (char)((uint)iVar1 >> 0x10); + *param_00 = 0; + hci_send_2_host(param_00); + return 0; +} + + + +int hci_le_enc_cmd_handler + (ke_msg_id_t msgid,hci_le_enc_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + *(undefined2 *)(param[-1].plain_data + 8) = 4; + *(undefined2 *)(param[-1].plain_data + 0xc) = 8; + ble_co_list_push_back(&llm_le_env,param[-1].plain_data + 4); + if (llm_le_env.enc_pend == false) { + llm_encryption_start((llm_enc_req *)param); + } + return 1; +} + + + +int hci_le_wl_mngt_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + byte bVar1; + uint8_t status; + undefined2 in_register_0000202a; + int iVar2; + uint16_t auStack34 [2]; + uint16_t conhdl; + + iVar2 = CONCAT22(in_register_0000202a,msgid); + bVar1 = ble_ke_state_get(0); + if ((((bVar1 & 0xf0) != 0x10) || + (status = '\f', (llm_le_env.advertising_params)->filterpolicy == '\0')) && + ((1 < ((uint)bVar1 & 0xf) - 1 || + (status = '\f', (llm_le_env.scanning_params)->filterpolicy == '\0')))) { + if (iVar2 == 0x2011) { + status = llm_wl_dev_add_hdl((bd_addr *)((int)param + 1),*(uint8_t *)param); + } + else { + if (iVar2 == 0x2012) { + status = llm_wl_dev_rem_hdl((bd_addr *)((int)param + 1),*(uint8_t *)param); + } + else { + status = '\0'; + if (iVar2 == 0x2010) { + llm_wl_clr(); + llm_util_bl_check((bd_addr *)0x0,'\0',auStack34,'\x01',(_Bool *)0x0); + } + } + } + } + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_le_set_host_ch_class_cmd_handler + (ke_msg_id_t msgid,hci_le_set_host_ch_class_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t uVar1; + uint8_t status; + + status = '\f'; + if (llm_le_env.ch_map_assess.llm_le_set_host_ch_class_cmd_sto != false) { + uVar1 = llm_util_check_map_validity((uint8_t *)param,'\x05'); + ble_ke_timer_set(0,0,100); + llm_le_env.ch_map_assess.llm_le_set_host_ch_class_cmd_sto = false; + status = '\x12'; + if ((byte)(uVar1 - 2) < 0x24) { + memcpy(&llm_le_env.ch_map_assess.ch_map,param,5); + status = '\0'; + } + } + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_le_create_con_cmd_handler + (ke_msg_id_t msgid,hci_le_create_con_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + ke_state_t kVar1; + uint8_t status; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint uVar2; + + kVar1 = ble_ke_state_get(0); + _kVar1 = CONCAT31(extraout_var,kVar1); + if (_kVar1 == 0x10) { +LAB_2301bed0: + status = llm_create_con(param); + if (CONCAT31(extraout_var_00,status) == 0) { + llm_le_env.opcode2 = src_id; + llm_le_env.state2 = ble_ke_state_get(0); + llm_le_env.last_opcode = true; + } + } + else { + if (_kVar1 < 0x11) { + if (_kVar1 == 0) goto LAB_2301bed0; + uVar2 = 3; + } + else { + if (_kVar1 == 0x20) goto LAB_2301bed0; + if (_kVar1 == 0x23) { + return 2; + } + uVar2 = 0x13; + } + status = '\f'; + if (_kVar1 == uVar2) { + return 2; + } + } + llm_common_cmd_status_send(src_id,status); + return 0; +} + + + +int hci_le_set_scan_en_cmd_handler + (ke_msg_id_t msgid,hci_le_set_scan_en_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + ke_state_t kVar1; + uint8_t status; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint uVar2; + + kVar1 = ble_ke_state_get(0); + _kVar1 = CONCAT31(extraout_var,kVar1); + if (_kVar1 == 0x12) { +LAB_2301bfd0: + status = '\f'; + goto LAB_2301bf6e; + } + if (_kVar1 < 0x13) { + if (_kVar1 == 2) goto LAB_2301bfd0; + if (_kVar1 < 3) { + uVar2 = 1; + } + else { + if (_kVar1 == 3) { + return 2; + } + uVar2 = 0x11; + } + if (_kVar1 == uVar2) goto LAB_2301bfca; +LAB_2301bf32: + status = '\f'; + if (param->scan_en != '\x01') goto LAB_2301bf6e; + } + else { + if (_kVar1 != 0x21) { + if (_kVar1 < 0x22) { + uVar2 = 0x13; + } + else { + if (_kVar1 == 0x22) goto LAB_2301bfd0; + uVar2 = 0x23; + } + if (_kVar1 == uVar2) { + return 2; + } + goto LAB_2301bf32; + } +LAB_2301bfca: + if (param->scan_en != '\0') goto LAB_2301bfd0; + } + llm_le_env.state2 = ble_ke_state_get(0); + llm_le_env.last_opcode = true; + llm_le_env.opcode2 = src_id; + status = llm_set_scan_en(param); + if ((CONCAT31(extraout_var_00,status) == 0) && (param->scan_en != '\x01')) { + return 0; + } +LAB_2301bf6e: + llm_common_cmd_complete_send(src_id,status); + llm_le_env.last_opcode = true; + llm_le_env.state2 = llm_le_env.state2 & 0xf0; + return 0; +} + + + +int hci_le_set_scan_param_cmd_handler + (ke_msg_id_t msgid,hci_le_set_scan_param_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + ke_state_t kVar1; + uint8_t status; + undefined3 extraout_var; + + kVar1 = ble_ke_state_get(0); + _kVar1 = CONCAT31(extraout_var,kVar1); + status = '\f'; + if (((_kVar1 != 0x11) && (_kVar1 != 0x21)) && (_kVar1 != 1)) { + status = llm_set_scan_param(param); + } + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + +/* +Unable to decompile 'hci_le_set_scan_rsp_data_cmd_handler' +Cause: Exception while decompiling 2301c016: Decompiler process died + +*/ + + +int hci_le_set_adv_en_cmd_handler + (ke_msg_id_t msgid,hci_le_set_adv_en_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + ke_state_t kVar1; + uint8_t status; + undefined3 extraout_var; + undefined3 extraout_var_00; + + kVar1 = ble_ke_state_get(0); + _kVar1 = CONCAT31(extraout_var,kVar1); + if (_kVar1 < 0x10) { +LAB_2301c108: + status = '\f'; + if (param->adv_en != '\x01') goto LAB_2301c114; + } + else { + if (0x13 < _kVar1) { + if ((_kVar1 - 0x20 & 0xff) < 4) { + return 2; + } + goto LAB_2301c108; + } + status = '\f'; + if (param->adv_en != '\0') goto LAB_2301c114; + } + llm_le_env.state = ble_ke_state_get(0); + llm_le_env.opcode = src_id; + status = llm_set_adv_en(param); + if ((CONCAT31(extraout_var_00,status) == 0) && (param->adv_en != '\x01')) { + llm_le_env.last_opcode = false; + return 0; + } +LAB_2301c114: + llm_common_cmd_complete_send(src_id,status); + llm_le_env.last_opcode = false; + return 0; +} + + +/* +Unable to decompile 'hci_le_set_adv_data_cmd_handler' +Cause: Exception while decompiling 2301c11e: Decompiler process died + +*/ + + +int hci_le_set_adv_param_cmd_handler + (ke_msg_id_t msgid,hci_le_set_adv_param_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + ke_state_t kVar1; + uint8_t status; + undefined3 extraout_var; + + kVar1 = ble_ke_state_get(0); + status = '\f'; + if (3 < CONCAT31(extraout_var,kVar1) - 0x10U) { + status = llm_set_adv_param(param); + } + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_le_set_rand_add_cmd_handler + (ke_msg_id_t msgid,hci_le_set_rand_addr_cmd *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t status; + ke_state_t kVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 extraout_var_00; + + kVar1 = ble_ke_state_get(0); + status = '\f'; + if (CONCAT31(extraout_var,kVar1) == 0) { + _Var2 = co_bdaddr_compare((bd_addr *)param,&co_null_bdaddr); + if (CONCAT31(extraout_var_00,_Var2) == 0) { + (*ble_memcpy_ptr)((void *)0x4201a3b3,param,6); + status = kVar1; + } + else { + status = '\x12'; + } + } + llm_common_cmd_complete_send(src_id,status); + return 0; +} + + + +int hci_le_rd_local_p256_public_key_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + t_key_multi_type status; + + status = llm_le_env.cur_ecc_multiplication; + if (llm_le_env.cur_ecc_multiplication != LLM_ECC_IDLE) { + status = 0xc; + } + llm_common_cmd_status_send(src_id,status); + if (status == LLM_ECC_IDLE) { + ecc_gen_new_secret_key(llm_le_env.secret_key256,false); + llm_le_env.cur_ecc_multiplication = LLM_PUBLIC_KEY_GENERATION; + ecc_gen_new_public_key(llm_le_env.secret_key256,6,0); + } + return 0; +} + + + +int hci_le_test_end_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + undefined *param_00; + + kVar1 = ble_ke_state_get(0); + if (CONCAT31(extraout_var,kVar1) == 0x24) { + llm_le_env.test_mode.end_of_tst = true; + lld_test_stop(llm_le_env.elt); + ble_ke_state_set(0,'#'); + } + else { + param_00 = (undefined *)ble_ke_msg_alloc(0x801,0,0x201f,4); + *(undefined2 *)(param_00 + 2) = 0; + *param_00 = 0xc; + hci_send_2_host(param_00); + } + return 0; +} + + + +int hci_le_create_con_cancel_cmd_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + byte bVar2; + undefined3 extraout_var; + + kVar1 = ble_ke_state_get(0); + _kVar1 = CONCAT31(extraout_var,kVar1); + if (((_kVar1 == 0x12) || (_kVar1 == 0x22)) || (_kVar1 == 2)) { + lld_scan_stop(llm_le_env.elt_coext_scan); + llm_le_env.state2 = llm_le_env.state2 & 0xf0 | 2; + llm_le_env.last_opcode = true; + llm_le_env.opcode2 = src_id; + bVar2 = ble_ke_state_get(0); + ble_ke_state_set(0,bVar2 & 0xf0 | 3); + } + else { + llm_common_cmd_complete_send(src_id,'\f'); + } + return 0; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +int hci_command_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_msg_handler_conflict117 *pkVar1; + undefined2 in_register_00002036; + uint uVar2; + int iVar3; + + uVar2 = CONCAT22(in_register_00002036,src_id); + pkVar1 = llm_hci_command_handler_tab; + iVar3 = 0; + do { + if ((uint)pkVar1->id == uVar2) { + if (llm_hci_command_handler_tab[iVar3].func == (ke_msg_func_t *)0x0) { + return 0; + } + // WARNING: Could not recover jumptable at 0x2301c378. Too many branches + // WARNING: Treating indirect jump as call + iVar3 = (*llm_hci_command_handler_tab[iVar3].func)((ke_msg_id_t)uVar2,(void *)uVar2); + return iVar3; + } + iVar3 = iVar3 + 1; + pkVar1 = pkVar1 + 1; + } while (iVar3 != 0x2d); + return 0; +} + + + +int hci_driver_send(net_buf *buf) + +{ + int iVar1; + + if (*(short *)((int)&buf->field_4 + 4) == 0) { + printf("Empty HCI packet\r\n"); + iVar1 = -0x16; + } + else { + iVar1 = bl_onchiphci_send_2_controller(buf); + net_buf_unref(buf); + } + return iVar1; +} + + + +int hci_driver_open(void) + +{ + k_queue_init((k_queue *)&recv_fifo,0x14); + k_thread_create(&recv_thread_data,"recv_thread",0x800,recv_thread,0x1c); + return 0; +} + + + +void recv_thread(void *p1) + +{ + net_buf *buf; + + do { + buf = net_buf_get(&recv_fifo,-1); + if (buf != (net_buf *)0x0) { + bt_recv(buf); + } + k_yield(); + } while( true ); +} + + + +void hci_driver_enque_recvq(net_buf *buf) + +{ + net_buf_put(&recv_fifo,buf); + return; +} + + + +int hci_driver_init(void) + +{ + bt_hci_driver_register(&drv); + return 0; +} + + + +void le_dhkey_complete(net_buf *buf) + +{ + u8_t *puVar1; + + if (dh_key_cb != (bt_dh_key_cb_t *)0x0) { + puVar1 = (u8_t *)0x0; + if (**(char **)&buf->field_4 == '\0') { + puVar1 = (u8_t *)(*(char **)&buf->field_4 + 1); + } + (*dh_key_cb)(puVar1); + dh_key_cb = (bt_dh_key_cb_t *)0x0; + return; + } + return; +} + + + +void hci_data_buf_overflow(net_buf *buf) + +{ + printf("Data buffer overflow (link type 0x%02x)\r\n",(uint)**(byte **)&buf->field_4); + return; +} + + + +int atomic_test_bit(atomic_t *target,int bit) + +{ + atomic_val_t aVar1; + + aVar1 = atomic_get(target); + return aVar1 >> (bit & 0x1fU) & 1; +} + + + +void bt_addr_le_copy(bt_addr_le_t *dst,bt_addr_le_t *src) + +{ + memcpy(dst,src,7); + return; +} + + + +void le_pkey_complete(net_buf *buf) + +{ + bt_pub_key_cb *pbVar1; + u8_t *puVar2; + char *pcVar3; + + pcVar3 = *(char **)&buf->field_4; + atomic_and(bt_dev.flags,-0x21); + if (*pcVar3 == '\0') { + memcpy(pub_key,pcVar3 + 1,0x40); + atomic_or(bt_dev.flags,0x10); + } + pbVar1 = pub_key_cb; + while (pbVar1 != (bt_pub_key_cb *)0x0) { + puVar2 = pub_key; + if (*pcVar3 != '\0') { + puVar2 = (u8_t *)0x0; + } + (*pbVar1->func)(puVar2); + pbVar1 = pbVar1->_next; + } + pub_key_cb = (bt_pub_key_cb *)0x0; + return; +} + + + +void atomic_set_bit_to(atomic_t *target,int bit,_Bool val) + +{ + uint value; + undefined3 in_register_00002031; + + value = 1 << (bit & 0x1fU); + if (CONCAT31(in_register_00002031,val) != 0) { + atomic_or(target + ((uint)bit >> 5),value); + return; + } + atomic_and(target + ((uint)bit >> 5),~value); + return; +} + + + +void slave_update_conn_param(bt_conn *conn) + +{ + int iVar1; + + iVar1 = atomic_test_bit(conn->flags,8); + if (iVar1 == 0) { + k_delayed_work_submit(&conn->update_work,5000); + return; + } + return; +} + + + +void le_remote_feat_complete(net_buf *buf) + +{ + ushort handle; + bt_conn *conn; + char *pcVar1; + + pcVar1 = *(char **)&buf->field_4; + handle = *(ushort *)(pcVar1 + 1); + conn = bt_conn_lookup_handle(handle); + if (conn == (bt_conn *)0x0) { + printf("Unable to lookup conn for handle %u\r\n",(uint)handle); + return; + } + if (*pcVar1 == '\0') { + memcpy(conn->field_20 + 0x24,pcVar1 + 3,8); + } + if (conn->role == '\x01') { + slave_update_conn_param(conn); + } + bt_conn_unref(conn); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void le_conn_update_complete(net_buf *buf) + +{ + ushort handle; + char *pcVar1; + bt_conn *conn; + uint uVar2; + undefined4 uStack24; + bt_le_conn_param param; + + pcVar1 = *(char **)&buf->field_4; + handle = *(ushort *)(pcVar1 + 1); + conn = bt_conn_lookup_handle(handle); + if (conn == (bt_conn *)0x0) { + printf("Unable to lookup conn for handle %u\r\n",(uint)handle); + } + else { + if (*pcVar1 == '\0') { + *(undefined2 *)(conn->field_20 + 0x16) = *(undefined2 *)(pcVar1 + 3); + *(undefined2 *)(conn->field_20 + 0x1c) = *(undefined2 *)(pcVar1 + 5); + *(undefined2 *)(conn->field_20 + 0x1e) = *(undefined2 *)(pcVar1 + 7); + notify_le_param_updated(conn); + } + else { + if (((*pcVar1 == '\x1a') && (conn->role == '\x01')) && + (uVar2 = atomic_or(conn->flags,0x400), (uVar2 & 0x400) == 0)) { + uStack24 = *(undefined4 *)(conn->field_20 + 0x18); + param._0_4_ = *(undefined4 *)(conn->field_20 + 0x20); + bt_l2cap_update_conn_param(conn,(bt_le_conn_param *)&uStack24); + } + } + bt_conn_unref(conn); + } + return; +} + + + +void hci_num_completed_packets(net_buf *buf) + +{ + ushort handle; + sys_snode_t *psVar1; + uint uVar2; + bt_conn *conn; + k_sem *sem; + byte *pbVar3; + _snode *p_Var4; + sys_snode_t *psVar5; + short sVar6; + int iVar7; + byte *pbVar8; + + pbVar8 = *(byte **)&buf->field_4; + iVar7 = 0; + do { + if ((int)(uint)*pbVar8 <= iVar7) { + return; + } + pbVar3 = pbVar8 + iVar7 * 4; + handle = *(ushort *)(pbVar3 + 1); + sVar6 = *(short *)(pbVar3 + 3); + uVar2 = irq_lock(); + conn = bt_conn_lookup_handle(handle); + if (conn == (bt_conn *)0x0) { + irq_unlock(uVar2); + printf("No connection for handle %u\r\n",(uint)handle); + } + else { + irq_unlock(uVar2); + while (sVar6 != 0) { + uVar2 = irq_lock(); + if (conn->pending_no_cb == 0) { + psVar1 = (conn->tx_pending).head; + if (psVar1 != (sys_snode_t *)0x0) { + p_Var4 = psVar1->next; + *(_snode **)&(conn->tx_pending).head = p_Var4; + if (psVar1 == (conn->tx_pending).tail) { + *(_snode **)&(conn->tx_pending).tail = p_Var4; + } + } + irq_unlock(uVar2); + if (psVar1 == (sys_snode_t *)0x0) { + printf("packets count mismatch\r\n"); + break; + } + irq_lock(); + *(_snode **)&conn->pending_no_cb = psVar1[3].next; + psVar1[3].next = (_snode *)0x0; + psVar1->next = (_snode *)0x0; + psVar5 = (conn->tx_complete).tail; + if (psVar5 == (sys_snode_t *)0x0) { + (conn->tx_complete).tail = psVar1; + (conn->tx_complete).head = psVar1; + } + else { + *(sys_snode_t **)&psVar5->next = psVar1; + (conn->tx_complete).tail = psVar1; + } + irq_unlock(); + k_work_submit(&conn->tx_complete_work); + sem = bt_conn_get_pkts(conn); + k_sem_give(sem); + sem = &g_poll_sem; + } + else { + conn->pending_no_cb = conn->pending_no_cb - 1; + irq_unlock(); + sem = bt_conn_get_pkts(conn); + } + sVar6 = sVar6 + -1; + k_sem_give(sem); + } + bt_conn_unref(conn); + } + iVar7 = iVar7 + 1; + } while( true ); +} + + + +void update_sec_level(bt_conn *conn) + +{ + int iVar1; + bt_security_t bVar2; + + if (conn->encrypt == '\0') { + conn->sec_level = BT_SECURITY_LOW; + return; + } + iVar1 = *(int *)(conn->field_20 + 0x2c); + if ((iVar1 == 0) || ((*(byte *)(iVar1 + 9) & 1) == 0)) { + bVar2 = BT_SECURITY_MEDIUM; + } + else { + if (((*(byte *)(iVar1 + 9) & 0x10) == 0) || (*(char *)(iVar1 + 8) != '\x10')) { + bVar2 = BT_SECURITY_L3; + } + else { + bVar2 = BT_SECURITY_L4; + } + } + conn->sec_level = bVar2; + if ((byte)conn->sec_level < (byte)conn->required_sec_level) { + printf("Failed to set required security level\r\n"); + bt_conn_disconnect(conn,'\x05'); + return; + } + return; +} + + + +void hci_encrypt_key_refresh_complete(net_buf *buf) + +{ + ushort handle; + byte *pbVar1; + bt_conn *conn; + uint uVar2; + + pbVar1 = *(byte **)&buf->field_4; + handle = *(ushort *)(pbVar1 + 1); + conn = bt_conn_lookup_handle(handle); + if (conn == (bt_conn *)0x0) { + printf("Unable to look up conn with handle %u\r\n",(uint)handle); + return; + } + if (*pbVar1 == 0) { + if (conn->type == '\x01') { + bt_smp_update_keys(conn); + update_sec_level(conn); + } + conn->required_sec_level = conn->sec_level; + bt_l2cap_encrypt_change(conn,*pbVar1); + uVar2 = 0; + } + else { + conn->required_sec_level = conn->sec_level; + bt_l2cap_encrypt_change(conn,*pbVar1); + uVar2 = 8; + if (*pbVar1 < 0x2a) { + uVar2 = (uint)(byte)CSWTCH_71[*pbVar1]; + } + } + bt_conn_security_changed(conn,uVar2); + bt_conn_unref(conn); + return; +} + + + +void hci_encrypt_change(net_buf *buf) + +{ + byte bVar1; + ushort handle; + byte *pbVar2; + bt_conn *conn; + uint uVar3; + + pbVar2 = *(byte **)&buf->field_4; + handle = *(ushort *)(pbVar2 + 1); + conn = bt_conn_lookup_handle(handle); + if (conn == (bt_conn *)0x0) { + printf("Unable to look up conn with handle %u\r\n",(uint)handle); + return; + } + if (*pbVar2 == 0) { + bVar1 = pbVar2[3]; + conn->encrypt = bVar1; + if (conn->type == '\x01') { + if (bVar1 != 0) { + bt_smp_update_keys(conn); + } + update_sec_level(conn); + } + conn->required_sec_level = conn->sec_level; + bt_l2cap_encrypt_change(conn,*pbVar2); + uVar3 = 0; + } + else { + conn->required_sec_level = conn->sec_level; + bt_l2cap_encrypt_change(conn,*pbVar2); + uVar3 = 8; + if (*pbVar2 < 0x2a) { + uVar3 = (uint)(byte)CSWTCH_71[*pbVar2]; + } + } + bt_conn_security_changed(conn,uVar3); + bt_conn_unref(conn); + return; +} + + + +bt_conn * find_pending_connect(bt_addr_le_t *peer_addr) + +{ + bt_conn *pbVar1; + + pbVar1 = bt_conn_lookup_state_le(peer_addr,BT_CONN_CONNECT); + if (pbVar1 == (bt_conn *)0x0) { + pbVar1 = bt_conn_lookup_state_le(peer_addr,BT_CONN_CONNECT_DIR_ADV); + return pbVar1; + } + return pbVar1; +} + + + +void hci_vendor_event(net_buf *buf) + +{ + undefined2 uVar1; + size_t sVar2; + + if (hci_vnd_evt_cb != (bt_hci_vnd_evt_cb_t *)0x0) { + sVar2 = net_buf_simple_headroom((net_buf_simple *)&buf->field_4); + uVar1 = *(undefined2 *)((int)&buf->field_4 + 4); + (*hci_vnd_evt_cb)((net_buf_simple *)&buf->field_4); + *(size_t *)&buf->field_4 = *(int *)((int)&buf->field_4 + 8) + (sVar2 & 0xffff); + *(undefined2 *)((int)&buf->field_4 + 4) = uVar1; + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void handle_event(u8_t event,net_buf *buf,event_handler *handlers,size_t num_handlers) + +{ + undefined3 in_register_00002029; + uint uVar1; + char *pcVar2; + uint len; + event_handler *peVar3; + + uVar1 = CONCAT31(in_register_00002029,event); + peVar3 = handlers + num_handlers; + do { + if ((uint)handlers->event == uVar1) { + if ((uint)*(ushort *)((int)&buf->field_4 + 4) < (uint)handlers->min_len) { + printf("Too small (%u bytes) event 0x%02x\r\n",uVar1); + return; + } + // WARNING: Could not recover jumptable at 0x2301ca54. Too many branches + // WARNING: Treating indirect jump as call + (*handlers->handler)(); + return; + } + handlers = handlers + 1; + } while (handlers != peVar3); + len = (uint)*(ushort *)((int)&buf->field_4 + 4); + pcVar2 = bt_hex_real(*(void **)&buf->field_4,len); + printf("Unhandled event 0x%02x len %u: %s\r\n",uVar1,len,pcVar2); + return; +} + + + +void hci_le_meta_event(net_buf *buf) + +{ + u8_t *puVar1; + + puVar1 = (u8_t *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,1); + handle_event(*puVar1,buf,meta_events,9); + return; +} + + + +void hci_cmd_done(u16_t opcode,u8_t status,net_buf *buf) + +{ + byte bVar1; + undefined2 in_register_0000202a; + uint uVar2; + net_buf_pool *pnVar3; + int iVar4; + undefined3 in_register_0000202d; + cmd_state_set *pcVar5; + + uVar2 = CONCAT22(in_register_0000202a,opcode); + pnVar3 = net_buf_pool_get((uint)buf->pool_id); + if (pnVar3 != &hci_cmd_pool) { + bVar1 = buf->pool_id; + pnVar3 = net_buf_pool_get((uint)bVar1); + printf("opcode 0x%04x pool id %u pool %p != &hci_cmd_pool %p\r\n",uVar2,(uint)bVar1,pnVar3, + &hci_cmd_pool); + return; + } + iVar4 = net_buf_id(buf); + if ((uint)cmd_data[iVar4].opcode != uVar2) { + iVar4 = net_buf_id(buf); + printf("OpCode 0x%04x completed instead of expected 0x%04x\r\n",uVar2, + (uint)cmd_data[iVar4].opcode); + } + iVar4 = net_buf_id(buf); + if ((cmd_data[iVar4].state != (cmd_state_set *)0x0) && + (CONCAT31(in_register_0000202d,status) == 0)) { + iVar4 = net_buf_id(buf); + pcVar5 = cmd_data[iVar4].state; + atomic_set_bit_to(pcVar5->target,pcVar5->bit,pcVar5->val); + } + iVar4 = net_buf_id(buf); + if (cmd_data[iVar4].sync != (k_sem *)0x0) { + iVar4 = net_buf_id(buf); + cmd_data[iVar4].status = status; + iVar4 = net_buf_id(buf); + k_sem_give(cmd_data[iVar4].sync); + return; + } + return; +} + + + +void hci_cmd_status(net_buf *buf) + +{ + u8_t uVar1; + u8_t *puVar2; + + puVar2 = (u8_t *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,4); + uVar1 = puVar2[1]; + hci_cmd_done(*(u16_t *)(puVar2 + 2),*puVar2,buf); + if (uVar1 != '\0') { + k_sem_give(&bt_dev.ncmd_sem); + return; + } + return; +} + + + +void hci_cmd_complete(net_buf *buf) + +{ + char cVar1; + char *pcVar2; + + pcVar2 = (char *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,3); + cVar1 = *pcVar2; + hci_cmd_done(*(u16_t *)(pcVar2 + 1),**(u8_t **)&buf->field_4,buf); + if (cVar1 != '\0') { + k_sem_give(&bt_dev.ncmd_sem); + return; + } + return; +} + + + +int id_find(bt_addr_le_t *addr) + +{ + uint uVar1; + int iVar2; + + uVar1 = 0; + while( true ) { + if (bt_dev.id_count <= uVar1) { + return -2; + } + iVar2 = memcmp(addr,bt_dev.id_addr + uVar1,7); + if (iVar2 == 0) break; + uVar1 = uVar1 + 1 & 0xff; + } + return uVar1; +} + + + +void sys_put_le64(u8_t *dst) + +{ + undefined4 in_a1; + undefined *in_a2; + + in_a2[1] = (char)((uint)dst >> 8); + *in_a2 = (char)dst; + in_a2[2] = 0; + in_a2[3] = (char)((uint)dst >> 0x18); + in_a2[4] = 0; + in_a2[5] = (char)((uint)in_a1 >> 8); + in_a2[6] = 0; + in_a2[7] = (char)((uint)in_a1 >> 0x18); + return; +} + + + +net_buf * bt_hci_cmd_create(u16_t opcode,u8_t param_len) + +{ + net_buf *buf; + int iVar1; + undefined *puVar2; + + buf = net_buf_alloc_fixed(&hci_cmd_pool,-1); + net_buf_simple_reserve((net_buf_simple *)&buf->field_4,1); + buf->user_data[0] = '\0'; + iVar1 = net_buf_id(buf); + cmd_data[iVar1].opcode = opcode; + iVar1 = net_buf_id(buf); + cmd_data[iVar1].sync = (k_sem *)0x0; + iVar1 = net_buf_id(buf); + cmd_data[iVar1].state = (cmd_state_set *)0x0; + puVar2 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,3); + *puVar2 = (char)opcode; + puVar2[1] = (char)(opcode >> 8); + puVar2[2] = param_len; + return buf; +} + + + +int bt_hci_cmd_send_sync(u16_t opcode,net_buf *buf,net_buf **rsp) + +{ + undefined2 in_register_0000202a; + int iVar1; + int iVar2; + undefined auStack44 [4]; + k_sem sync_sem; + + if ((buf == (net_buf *)0x0) && (buf = bt_hci_cmd_create(opcode,'\0'), buf == (net_buf *)0x0)) { + return -0x37; + } + k_sem_init((k_sem *)auStack44,0,1); + iVar1 = net_buf_id(buf); + cmd_data[iVar1].sync = (k_sem *)auStack44; + iVar1 = net_buf_id(buf); + cmd_data[iVar1].status = -1; + net_buf_ref(buf); + net_buf_put(&bt_dev.cmd_tx_queue,buf); + k_sem_give(&g_poll_sem); + k_sem_take((k_sem *)auStack44,10000); + k_sem_delete((k_sem *)auStack44); + iVar1 = net_buf_id(buf); + if (cmd_data[iVar1].status == '\0') { + if (rsp == (net_buf **)0x0) { + net_buf_unref(buf); + } + else { + *rsp = buf; + } + iVar1 = 0; + } + else { + iVar2 = net_buf_id(buf); + iVar1 = -0x3d; + if ((cmd_data[iVar2].status != '\t') && (iVar1 = -5, cmd_data[iVar2].status == -1)) { + printf("k_sem_take timeout with opcode 0x%04x\r\n",CONCAT22(in_register_0000202a,opcode)); + vAssertCalled(); + iVar1 = -0x4f; + } + net_buf_unref(buf); + } + return iVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int set_le_scan_enable(u8_t enable) + +{ + undefined3 in_register_00002029; + net_buf *buf; + u8_t *puVar1; + int iVar2; + atomic_t *paStack44; + cmd_state_set state; + + buf = bt_hci_cmd_create(0x200c,'\x02'); + if (buf == (net_buf *)0x0) { + iVar2 = -0x37; + } + else { + puVar1 = (u8_t *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + if (CONCAT31(in_register_00002029,enable) == 1) { + iVar2 = atomic_test_bit(bt_dev.flags,0xd); + puVar1[1] = (u8_t)iVar2; + } + else { + puVar1[1] = '\0'; + } + *puVar1 = enable; + state.bit._0_1_ = (_Bool)(enable & 1); + state.target = (atomic_t *)&DAT_0000000a; + paStack44 = (atomic_t *)0x4200d3c4; + iVar2 = net_buf_id(buf); + cmd_data[iVar2].state = (cmd_state_set *)&paStack44; + iVar2 = bt_hci_cmd_send_sync(0x200c,buf,(net_buf **)0x0); + } + return iVar2; +} + + + +int set_random_address(bt_addr_t *addr) + +{ + int iVar1; + net_buf *buf; + + iVar1 = memcmp(addr,&bt_dev.random_addr.a,6); + if (iVar1 != 0) { + buf = bt_hci_cmd_create(0x2005,'\x06'); + iVar1 = -0x37; + if (buf != (net_buf *)0x0) { + net_buf_simple_add_mem((net_buf_simple *)&buf->field_4,addr,6); + iVar1 = bt_hci_cmd_send_sync(0x2005,buf,(net_buf **)0x0); + if (iVar1 == 0) { + memcpy(&bt_dev.random_addr.a,addr,6); + bt_dev.random_addr.type = '\x01'; + } + } + } + return iVar1; +} + + + +int le_set_private_addr(void) + +{ + int iVar1; + undefined auStack24 [4]; + bt_addr_t nrpa; + + iVar1 = bt_rand(auStack24,6); + if (iVar1 == 0) { + nrpa.val[1] = nrpa.val[1] & 0x3f; + iVar1 = set_random_address((bt_addr_t *)auStack24); + } + return iVar1; +} + + + +int hci_id_add(bt_addr_le_t *addr,u8_t *val) + +{ + net_buf *buf; + bt_addr_le_t *dst; + int iVar1; + + buf = bt_hci_cmd_create(0x2027,'\''); + if (buf != (net_buf *)0x0) { + dst = (bt_addr_le_t *)net_buf_simple_add((net_buf_simple *)&buf->field_4,0x27); + bt_addr_le_copy(dst,addr); + memcpy(dst + 1,val,0x10); + memset(dst[3].a.val + 1,0,0x10); + iVar1 = bt_hci_cmd_send_sync(0x2027,buf,(net_buf **)0x0); + return iVar1; + } + return -0x37; +} + + + +void keys_add_id(bt_keys *keys,void *data) + +{ + hci_id_add(&keys->addr,(u8_t *)&keys->irk); + return; +} + + + +int addr_res_enable(u8_t enable) + +{ + net_buf *buf; + int iVar1; + + buf = bt_hci_cmd_create(0x202d,'\x01'); + if (buf != (net_buf *)0x0) { + net_buf_simple_add_u8((net_buf_simple *)&buf->field_4,enable); + iVar1 = bt_hci_cmd_send_sync(0x202d,buf,(net_buf **)0x0); + return iVar1; + } + return -0x37; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int set_advertise_enable(_Bool enable) + +{ + undefined3 in_register_00002029; + net_buf *buf; + int iVar1; + atomic_t *paStack28; + cmd_state_set state; + + buf = bt_hci_cmd_create(0x200a,'\x01'); + if (buf == (net_buf *)0x0) { + iVar1 = -0x37; + } + else { + net_buf_simple_add_u8 + ((net_buf_simple *)&buf->field_4,CONCAT31(in_register_00002029,enable) != 0); + paStack28 = (atomic_t *)0x4200d3c4; + state.target = (atomic_t *)0x6; + state.bit._0_1_ = enable; + iVar1 = net_buf_id(buf); + cmd_data[iVar1].state = (cmd_state_set *)&paStack28; + iVar1 = bt_hci_cmd_send_sync(0x200a,buf,(net_buf **)0x0); + } + return iVar1; +} + + + +void hci_disconn_complete(net_buf *buf) + +{ + ushort handle; + char *pcVar1; + bt_conn *conn; + int iVar2; + + pcVar1 = *(char **)&buf->field_4; + if (*pcVar1 == '\0') { + handle = *(ushort *)(pcVar1 + 1); + conn = bt_conn_lookup_handle(handle); + if (conn == (bt_conn *)0x0) { + printf("Unable to look up conn with handle %u\r\n",(uint)handle); + } + else { + conn->err = pcVar1[3]; + bt_conn_set_state(conn,BT_CONN_DISCONNECTED); + conn->handle = 0; + if (conn->type != '\x01') { + bt_conn_unref(conn); + return; + } + bt_conn_unref(conn); + atomic_clear(&conn->ref); + } + iVar2 = atomic_test_bit(bt_dev.flags,9); + if ((iVar2 != 0) && (iVar2 = atomic_test_bit(bt_dev.flags,6), iVar2 == 0)) { + set_advertise_enable(true); + return; + } + } + return; +} + + + +int set_ad(u16_t hci_op,bt_ad *ad,size_t ad_len) + +{ + net_buf *buf; + byte *__s; + int iVar1; + uint uVar2; + size_t __n; + byte bVar3; + uint uVar4; + bt_ad *pbVar5; + bt_data *pbVar6; + uint uVar7; + + buf = bt_hci_cmd_create(hci_op,' '); + if (buf == (net_buf *)0x0) { + return -0x37; + } + __s = (byte *)net_buf_simple_add((net_buf_simple *)&buf->field_4,0x20); + pbVar5 = ad + ad_len; + memset(__s,0,0x20); + do { + if (ad == pbVar5) { + iVar1 = bt_hci_cmd_send_sync(hci_op,buf,(net_buf **)0x0); + return iVar1; + } + pbVar6 = ad->data; + uVar7 = 0; + while (uVar7 < ad->len) { + __n = (size_t)pbVar6->data_len; + uVar4 = (uint)*__s; + bVar3 = pbVar6->type; + if (0x1d < uVar4 + __n) { + __n = 0x1d - uVar4; + if ((bVar3 != 9) || (__n == 0)) { + net_buf_unref(buf); + printf("Too big advertising data\r\n"); + return -0x16; + } + bVar3 = 8; + } + __s[uVar4 + 1] = (char)__n + 1; + uVar2 = uVar4 + 2 & 0xff; + *__s = (byte)uVar2; + __s[(uVar4 + 1 & 0xff) + 1] = bVar3; + memcpy(__s + uVar2 + 1,pbVar6->data,__n); + uVar7 = uVar7 + 1; + pbVar6 = pbVar6 + 1; + *__s = (char)__n + *__s; + } + ad = ad + 1; + } while( true ); +} + + + +// WARNING: Variable defined which should be unmapped: d +// WARNING: Could not reconcile some variable overlaps + +int le_adv_update(bt_data *ad,size_t ad_len,bt_data *sd,size_t sd_len,_Bool connectable, + _Bool use_name) + +{ + int iVar1; + size_t sVar2; + size_t sVar3; + undefined3 in_register_00002039; + undefined3 in_register_0000203d; + undefined uStack40; + undefined uStack39; + bt_data data; + bt_ad d [2]; + + d[0].len = 0; + data.data = (u8_t *)ad; + iVar1 = set_ad(0x2008,(bt_ad *)&data.data,1); + if (iVar1 == 0) { + data.data = (u8_t *)sd; + if (CONCAT31(in_register_0000203d,use_name) != 0) { + if (sd != (bt_data *)0x0) { + sVar3 = 0; + while (sVar3 != sd_len) { + if ((byte)(sd[sVar3].type - 8) < 2) { + return -0x16; + } + sVar3 = sVar3 + 1; + } + } + sVar2 = strlen(bt_dev.name); + uStack40 = 9; + d[0].len = (size_t)&uStack40; + uStack39 = (undefined)sVar2; + data._0_4_ = 0x4200d410; + } + if (((data.data != (u8_t *)0x0) || (d[0].len != 0)) || + (CONCAT31(in_register_00002039,connectable) != 0)) { + iVar1 = set_ad(0x2009,(bt_ad *)&data.data,2); + } + } + return iVar1; +} + + + +bt_addr_le_t * bt_lookup_id_addr(u8_t id,bt_addr_le_t *addr) + +{ + bt_keys *pbVar1; + + pbVar1 = bt_keys_find_irk(id,addr); + if (pbVar1 != (bt_keys *)0x0) { + addr = &pbVar1->addr; + } + return addr; +} + + + +_Bool bt_le_conn_params_valid(bt_le_conn_param *param) + +{ + ushort uVar1; + bool bVar2; + + uVar1 = param->interval_max; + bVar2 = false; + if (((((uint)param->interval_min <= (uint)uVar1) && (bVar2 = false, 5 < param->interval_min)) && + (uVar1 < 0xc81)) && ((param->latency < 500 && (((uint)param->timeout - 10 & 0xffff) < 0xc77))) + ) { + bVar2 = ((uint)param->latency + 1) * (uint)uVar1 < (uint)param->timeout << 2; + } + return (_Bool)bVar2; +} + + + +int bt_unpair(u8_t id,bt_addr_le_t *addr) + +{ + undefined3 in_register_00002029; + int iVar1; + bt_conn *conn; + bt_keys *keys; + undefined4 uStack24; + undefined2 uStack20; + undefined uStack18; + + if (CONCAT31(in_register_00002029,id) != 0) { + return -0x16; + } + if (addr == (bt_addr_le_t *)0x0) { +LAB_2301d3aa: + bt_conn_disconnect_all('\0'); + bt_keys_clear_all('\0'); + return 0; + } + uStack24 = 0; + uStack20 = 0; + uStack18 = 0; + iVar1 = memcmp(addr,&uStack24,7); + if (iVar1 == 0) goto LAB_2301d3aa; + conn = bt_conn_lookup_addr_le('\0',addr); + if (conn != (bt_conn *)0x0) { + keys = (bt_keys *)0x0; + if (conn->type == '\x01') { + keys = *(bt_keys **)(conn->field_20 + 0x2c); + *(undefined4 *)(conn->field_20 + 0x2c) = 0; + } + bt_conn_disconnect(conn,'\x13'); + bt_conn_unref(conn); + if (keys != (bt_keys *)0x0) goto LAB_2301d3f2; + } + keys = bt_keys_find_addr('\0',addr); + if (keys == (bt_keys *)0x0) { + return 0; + } +LAB_2301d3f2: + bt_keys_clear(keys); + return 0; +} + + + +void bt_id_add(bt_keys *keys) + +{ + bt_conn *conn; + int iVar1; + int iVar2; + int iVar3; + char *fmt; + net_buf *buf; + undefined auStack40 [4]; + bt_hci_cp_le_set_privacy_mode cp; + + if ((bt_dev.le.rl_size == '\0') || (bt_dev.le.rl_size < bt_dev.le.rl_entries)) { + bt_dev.le.rl_entries = bt_dev.le.rl_entries + '\x01'; + return; + } + conn = bt_conn_lookup_state_le((bt_addr_le_t *)0x0,BT_CONN_CONNECT); + if (conn != (bt_conn *)0x0) { + atomic_or(bt_dev.flags,0x20000); + keys->flags = keys->flags | 4; + bt_conn_unref(conn); + return; + } + iVar1 = atomic_test_bit(bt_dev.flags,6); + if (iVar1 != 0) { + set_advertise_enable(false); + } + iVar2 = atomic_test_bit(bt_dev.flags,10); + if (iVar2 != 0) { + set_le_scan_enable('\0'); + } + if ((bt_dev.le.rl_entries == '\0') || (iVar3 = addr_res_enable('\0'), iVar3 == 0)) { + if (bt_dev.le.rl_entries == bt_dev.le.rl_size) { + printf("Resolving list size exceeded. Switching to host.\r\n"); + iVar3 = bt_hci_cmd_send_sync(0x2029,(net_buf *)0x0,(net_buf **)0x0); + if (iVar3 == 0) { + bt_dev.le.rl_entries = bt_dev.le.rl_entries + '\x01'; + goto done; + } + fmt = "Failed to clear resolution list\r\n"; + } + else { + iVar3 = hci_id_add(&keys->addr,(u8_t *)&keys->irk); + if (iVar3 == 0) { + bt_dev.le.rl_entries = bt_dev.le.rl_entries + '\x01'; + if ((bt_dev.supported_commands[39] & 4) == 0) { + fmt = "Set privacy mode command is not supported\r\n"; + } + else { + bt_addr_le_copy((bt_addr_le_t *)auStack40,&keys->addr); + cp.id_addr.a.val[2] = '\x01'; + buf = bt_hci_cmd_create(0x204e,'\b'); + if (buf != (net_buf *)0x0) { + net_buf_simple_add_mem((net_buf_simple *)&buf->field_4,auStack40,8); + iVar3 = bt_hci_cmd_send_sync(0x204e,buf,(net_buf **)0x0); + if (iVar3 == 0) goto done; + } + fmt = "Failed to set privacy mode\r\n"; + } + } + else { + fmt = "Failed to add IRK to controller\r\n"; + } + } + } + else { + fmt = "Failed to disable address resolution\r\n"; + } + printf(fmt); +done: + addr_res_enable('\x01'); + if (iVar2 != 0) { + set_le_scan_enable('\x01'); + } + if (iVar1 != 0) { + set_advertise_enable(true); + } + return; +} + + + +void bt_id_del(bt_keys *keys) + +{ + bt_conn *conn; + int iVar1; + int iVar2; + int iVar3; + net_buf *buf; + bt_addr_le_t *dst; + + if ((bt_dev.le.rl_size == '\0') || ((uint)bt_dev.le.rl_size + 1 < (uint)bt_dev.le.rl_entries)) { + bt_dev.le.rl_entries = bt_dev.le.rl_entries + -1; + } + else { + conn = bt_conn_lookup_state_le((bt_addr_le_t *)0x0,BT_CONN_CONNECT); + if (conn != (bt_conn *)0x0) { + atomic_or(bt_dev.flags,0x20000); + keys->flags = keys->flags | 8; + bt_conn_unref(conn); + return; + } + iVar1 = atomic_test_bit(bt_dev.flags,6); + if (iVar1 != 0) { + set_advertise_enable(false); + } + iVar2 = atomic_test_bit(bt_dev.flags,10); + if (iVar2 != 0) { + set_le_scan_enable('\0'); + } + iVar3 = addr_res_enable('\0'); + if (iVar3 == 0) { + if (bt_dev.le.rl_size < bt_dev.le.rl_entries) { + bt_dev.le.rl_entries = bt_dev.le.rl_entries + -1; + keys->keys = keys->keys & 0xfffd; + bt_keys_foreach(2,keys_add_id,(void *)0x0); + } + else { + buf = bt_hci_cmd_create(0x2028,'\a'); + if (buf != (net_buf *)0x0) { + dst = (bt_addr_le_t *)net_buf_simple_add((net_buf_simple *)&buf->field_4,7); + bt_addr_le_copy(dst,&keys->addr); + iVar3 = bt_hci_cmd_send_sync(0x2028,buf,(net_buf **)0x0); + if (iVar3 == 0) { + bt_dev.le.rl_entries = bt_dev.le.rl_entries + -1; + } + else { + printf("Failed to remove IRK from controller\r\n"); + } + } + } + } + else { + printf("Disabling address resolution failed (err %d)\r\n",iVar3); + } + if (bt_dev.le.rl_entries != '\0') { + addr_res_enable('\x01'); + } + if (iVar2 != 0) { + set_le_scan_enable('\x01'); + } + if (iVar1 != 0) { + set_advertise_enable(true); + return; + } + } + return; +} + + + +void update_pending_id(bt_keys *keys,void *data) + +{ + byte bVar1; + + bVar1 = keys->flags; + if ((bVar1 & 4) != 0) { + keys->flags = bVar1 & 0xfb; + bt_id_add(keys); + return; + } + if ((bVar1 & 8) != 0) { + keys->flags = bVar1 & 0xf7; + bt_id_del(keys); + return; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void bt_data_parse(net_buf_simple *ad,anon_subr__Bool_bt_data_ptr_void_ptr *func,void *user_data) + +{ + u8_t uVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 extraout_var_00; + u8_t uStack40; + u8_t uStack39; + bt_data data; + + while( true ) { + if (ad->len < 2) { + return; + } + uVar1 = net_buf_simple_pull_u8(ad); + _uVar1 = CONCAT31(extraout_var,uVar1); + if (_uVar1 == 0) { + return; + } + if ((uint)ad->len < (_uVar1 & 0xffff)) { + printf("Malformed data\r\n"); + return; + } + uStack40 = net_buf_simple_pull_u8(ad); + data._0_4_ = ad->data; + uStack39 = (u8_t)(_uVar1 - 1); + _Var2 = (*func)((bt_data *)&uStack40,user_data); + if (CONCAT31(extraout_var_00,_Var2) == 0) break; + net_buf_simple_pull(ad,_uVar1 - 1); + } + return; +} + + + +int bt_addr_le_create_static(bt_addr_le_t *addr) + +{ + int iVar1; + + addr->type = '\x01'; + iVar1 = bt_rand(&addr->a,6); + if (iVar1 == 0) { + (addr->a).val[5] = (addr->a).val[5] | 0xc0; + } + return iVar1; +} + + + +void id_create(u8_t id,bt_addr_le_t *addr) + +{ + bool bVar1; + bt_addr_le_t *dst; + undefined3 in_register_00002029; + int iVar2; + bt_addr_le_t *dst_00; + undefined4 local_20; + undefined2 uStack28; + undefined uStack26; + undefined auStack24 [4]; + bt_addr_le_t new_addr; + + dst = bt_dev.id_addr + CONCAT31(in_register_00002029,id); + if (addr != (bt_addr_le_t *)0x0) { + local_20 = 0; + uStack28 = 0; + uStack26 = 0; + iVar2 = memcmp(addr,&local_20,7); + dst_00 = dst; + if (iVar2 != 0) goto LAB_2301d81a; + } + do { + bt_addr_le_create_static((bt_addr_le_t *)auStack24); + iVar2 = id_find((bt_addr_le_t *)auStack24); + } while (-1 < iVar2); + bt_addr_le_copy(dst,(bt_addr_le_t *)auStack24); + bVar1 = addr == (bt_addr_le_t *)0x0; + dst_00 = addr; + addr = dst; + if (bVar1) { + return; + } +LAB_2301d81a: + bt_addr_le_copy(dst_00,addr); + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +int bt_send(net_buf *buf) + +{ + int iVar1; + + // WARNING: Could not recover jumptable at 0x2301d854. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*(bt_dev.drv)->send)(); + return iVar1; +} + + + +int bt_hci_cmd_send(u16_t opcode,net_buf *buf) + +{ + undefined2 in_register_0000202a; + int iVar1; + + if ((buf == (net_buf *)0x0) && (buf = bt_hci_cmd_create(opcode,'\0'), buf == (net_buf *)0x0)) { + return -0x37; + } + if (CONCAT22(in_register_0000202a,opcode) == 0xc35) { + iVar1 = bt_send(buf); + if (iVar1 != 0) { + printf("Unable to send to driver (err %d)\r\n",iVar1); + net_buf_unref(buf); + } + } + else { + net_buf_put(&bt_dev.cmd_tx_queue,buf); + k_sem_give(&g_poll_sem); + iVar1 = 0; + } + return iVar1; +} + + + +int bt_le_set_data_len(bt_conn *conn,u16_t tx_octets,u16_t tx_time) + +{ + u16_t uVar1; + net_buf *buf; + undefined *puVar2; + int iVar3; + + buf = bt_hci_cmd_create(0x2022,'\x06'); + if (buf != (net_buf *)0x0) { + puVar2 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,6); + uVar1 = conn->handle; + puVar2[2] = (char)tx_octets; + puVar2[4] = (char)tx_time; + *puVar2 = (char)uVar1; + puVar2[1] = (char)(uVar1 >> 8); + puVar2[3] = (char)(tx_octets >> 8); + puVar2[5] = (char)(tx_time >> 8); + iVar3 = bt_hci_cmd_send(0x2022,buf); + return iVar3; + } + printf("bt_le_set_data_len, Failed to create LE Set Data Length Command\r\n"); + return -0x37; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int start_le_scan(u8_t scan_type,u16_t interval,u16_t window) + +{ + undefined3 in_register_00002029; + int iVar1; + net_buf *buf; + u8_t uStack40; + undefined uStack39; + undefined uStack38; + undefined uStack37; + bt_hci_cp_le_set_scan_param set_param; + + memset(&uStack40,0,7); + uStack37 = (undefined)window; + uStack39 = (undefined)interval; + set_param.scan_type = (u8_t)(window >> 8); + uStack38 = (undefined)(interval >> 8); + uStack40 = scan_type; + iVar1 = atomic_test_bit(bt_dev.flags,0xe); + set_param.interval._1_1_ = iVar1 != 0; + set_param.interval._0_1_ = bt_dev.id_addr[0].type; + if ((CONCAT31(in_register_00002029,scan_type) == 1) && + (iVar1 = atomic_test_bit(bt_dev.flags,6), iVar1 == 0)) { + iVar1 = le_set_private_addr(); + set_param.interval._0_1_ = scan_type; + } + else { + if ((u8_t)set_param.interval != '\x01') goto LAB_2301d9ce; + iVar1 = set_random_address(&bt_dev.id_addr[0].a); + } + if (iVar1 != 0) { + return iVar1; + } +LAB_2301d9ce: + buf = bt_hci_cmd_create(0x200b,'\a'); + iVar1 = -0x37; + if (buf != (net_buf *)0x0) { + net_buf_simple_add_mem((net_buf_simple *)&buf->field_4,&uStack40,7); + bt_hci_cmd_send(0x200b,buf); + iVar1 = set_le_scan_enable('\x01'); + if (iVar1 == 0) { + atomic_set_bit_to(bt_dev.flags,0xc,(_Bool)(CONCAT31(in_register_00002029,scan_type) == 1)); + } + } + return iVar1; +} + + + +int bt_le_scan_update(_Bool fast_scan) + +{ + undefined3 in_register_00002029; + int iVar1; + bt_conn *conn; + u16_t interval; + u16_t window; + + iVar1 = atomic_test_bit(bt_dev.flags,0xb); + if (iVar1 == 0) { + iVar1 = atomic_test_bit(bt_dev.flags,10); + if ((iVar1 != 0) && (iVar1 = set_le_scan_enable('\0'), iVar1 != 0)) { + return iVar1; + } + conn = bt_conn_lookup_state_le((bt_addr_le_t *)0x0,BT_CONN_CONNECT); + if (conn == (bt_conn *)0x0) { + conn = bt_conn_lookup_state_le((bt_addr_le_t *)0x0,BT_CONN_CONNECT_SCAN); + if (conn != (bt_conn *)0x0) { + atomic_and(bt_dev.flags,-0x2001); + bt_conn_unref(conn); + if (CONCAT31(in_register_00002029,fast_scan) == 0) { + window = 0x12; + interval = 0x800; + } + else { + window = 0x30; + interval = 0x60; + } + iVar1 = start_le_scan('\0',interval,window); + return iVar1; + } + } + else { + bt_conn_unref(conn); + } + } + return 0; +} + + + +void le_adv_report(net_buf *buf) + +{ + byte bVar1; + undefined2 uVar2; + bt_le_scan_cb_t_conflict1 *pbVar3; + u8_t uVar4; + undefined3 extraout_var; + byte *pbVar5; + size_t sVar6; + int iVar7; + bt_conn *conn; + net_buf *buf_00; + undefined *__s; + bt_addr_le_t *src; + uint uVar8; + net_buf_simple *buf_01; + bt_addr_le_t *addr; + uint uVar9; + u8_t auStack72 [4]; + bt_addr_le_t id_addr; + + buf_01 = (net_buf_simple *)&buf->field_4; + uVar4 = net_buf_simple_pull_u8(buf_01); + uVar8 = CONCAT31(extraout_var,uVar4); + do { + if (uVar8 == 0) { + return; + } + if (*(ushort *)((int)&buf->field_4 + 4) < 9) { + printf("Unexpected end of buffer\r\n"); + return; + } + pbVar5 = (byte *)net_buf_simple_pull_mem(buf_01,9); + addr = (bt_addr_le_t *)(pbVar5 + 1); + bVar1 = pbVar5[(uint)pbVar5[8] + 9]; + if ((byte)(pbVar5[1] - 2) < 2) { + bt_addr_le_copy((bt_addr_le_t *)auStack72,addr); + auStack72[0] = auStack72[0] + -2; + } + else { + src = bt_lookup_id_addr(bt_dev.adv_id,addr); + bt_addr_le_copy((bt_addr_le_t *)auStack72,src); + } + if (scan_dev_found_cb != (bt_le_scan_cb_t_conflict1 *)0x0) { + sVar6 = net_buf_simple_headroom(buf_01); + pbVar3 = scan_dev_found_cb; + uVar2 = *(undefined2 *)((int)&buf->field_4 + 4); + *(ushort *)((int)&buf->field_4 + 4) = (ushort)pbVar5[8]; + (*pbVar3)((bt_addr_le_t *)auStack72,bVar1,*pbVar5,buf_01); + *(undefined2 *)((int)&buf->field_4 + 4) = uVar2; + *(size_t *)&buf->field_4 = *(int *)((int)&buf->field_4 + 8) + (sVar6 & 0xffff); + } + bVar1 = *pbVar5; + iVar7 = atomic_test_bit(bt_dev.flags,0xb); + if (((iVar7 == 0) && (bVar1 < 2)) && + (conn = bt_conn_lookup_state_le((bt_addr_le_t *)auStack72,BT_CONN_CONNECT_SCAN), + conn != (bt_conn *)0x0)) { + iVar7 = atomic_test_bit(bt_dev.flags,10); + if ((iVar7 == 0) || (iVar7 = set_le_scan_enable('\0'), iVar7 == 0)) { + src = (bt_addr_le_t *)(conn->field_20 + 0xe); + bt_addr_le_copy(src,addr); + uVar9 = (uint)conn->id; + if ((bt_dev.id_addr[uVar9].type != '\x01') || + (iVar7 = set_random_address(&bt_dev.id_addr[uVar9].a), iVar7 == 0)) { + uVar4 = bt_dev.id_addr[uVar9].type; + buf_00 = bt_hci_cmd_create(0x200d,'\x19'); + if (buf_00 != (net_buf *)0x0) { + __s = (undefined *)net_buf_simple_add((net_buf_simple *)&buf_00->field_4,0x19); + memset(__s,0,0x19); + *__s = 0x60; + __s[1] = 0; + __s[2] = 0x60; + __s[3] = 0; + if ((bt_dev.le.rl_size != '\0') && (bt_dev.le.rl_entries <= bt_dev.le.rl_size)) { + src = (bt_addr_le_t *)conn->field_20; + } + bt_addr_le_copy((bt_addr_le_t *)(__s + 5),src); + __s[0xc] = uVar4; + uVar2 = *(undefined2 *)(conn->field_20 + 0x18); + __s[0xd] = (char)uVar2; + __s[0xe] = (char)((ushort)uVar2 >> 8); + uVar2 = *(undefined2 *)(conn->field_20 + 0x1a); + __s[0xf] = (char)uVar2; + __s[0x10] = (char)((ushort)uVar2 >> 8); + uVar2 = *(undefined2 *)(conn->field_20 + 0x1c); + __s[0x11] = (char)uVar2; + __s[0x12] = (char)((ushort)uVar2 >> 8); + uVar2 = *(undefined2 *)(conn->field_20 + 0x1e); + __s[0x13] = (char)uVar2; + __s[0x14] = (char)((ushort)uVar2 >> 8); + iVar7 = bt_hci_cmd_send_sync(0x200d,buf_00,(net_buf **)0x0); + if (iVar7 == 0) { + bt_conn_set_state(conn,BT_CONN_CONNECT); + bt_conn_unref(conn); + goto LAB_2301dcd8; + } + } + } + } + conn->err = '\x1f'; + bt_conn_set_state(conn,BT_CONN_DISCONNECTED); + bt_conn_unref(conn); + bt_le_scan_update(false); + } +LAB_2301dcd8: + net_buf_simple_pull(buf_01,(uint)pbVar5[8] + 1); + uVar8 = uVar8 - 1 & 0xff; + } while( true ); +} + + + +void le_ltk_request(net_buf *buf) + +{ + ushort handle; + undefined uVar1; + ushort *puVar2; + _Bool _Var3; + u16_t opcode; + bt_conn *conn; + undefined3 extraout_var; + net_buf *buf_00; + undefined *puVar4; + undefined auStack48 [4]; + u8_t ltk [16]; + + puVar2 = *(ushort **)&buf->field_4; + handle = *puVar2; + conn = bt_conn_lookup_handle(handle); + if (conn == (bt_conn *)0x0) { + printf("Unable to lookup conn for handle %u\r\n",(uint)handle); + return; + } + _Var3 = bt_smp_request_ltk(conn,(u16_t)*(undefined4 *)(puVar2 + 1),*(u8_t **)(puVar2 + 3)); + uVar1 = (undefined)(handle >> 8); + if (CONCAT31(extraout_var,_Var3) == 0) { + buf_00 = bt_hci_cmd_create(0x201b,'\x02'); + if (buf_00 == (net_buf *)0x0) goto LAB_2301ddc8; + puVar4 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf_00->field_4,2); + *puVar4 = (char)handle; + puVar4[1] = uVar1; + opcode = 0x201b; + } + else { + buf_00 = bt_hci_cmd_create(0x201a,'\x12'); + if (buf_00 == (net_buf *)0x0) { +LAB_2301ddc8: + printf("Out of command buffers\r\n"); + goto LAB_2301ddd4; + } + puVar4 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf_00->field_4,0x12); + *puVar4 = (char)handle; + puVar4[1] = uVar1; + memcpy(puVar4 + 2,auStack48,0x10); + opcode = 0x201a; + } + bt_hci_cmd_send(opcode,buf_00); +LAB_2301ddd4: + bt_conn_unref(conn); + return; +} + + + +void le_conn_param_neg_reply(u16_t handle,u8_t reason) + +{ + net_buf *buf; + undefined *puVar1; + + buf = bt_hci_cmd_create(0x2021,'\x03'); + if (buf == (net_buf *)0x0) { + printf("Unable to allocate buffer\r\n"); + return; + } + puVar1 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,3); + *puVar1 = (char)handle; + puVar1[1] = (char)(handle >> 8); + puVar1[2] = reason; + bt_hci_cmd_send(0x2021,buf); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void le_conn_param_req(net_buf *buf) + +{ + ushort handle; + _Bool _Var1; + bt_conn *conn; + undefined3 extraout_var; + net_buf *buf_00; + undefined *__s; + ushort *puVar2; + undefined2 uStack40; + ushort uStack38; + bt_le_conn_param param; + + puVar2 = *(ushort **)&buf->field_4; + handle = *puVar2; + uStack40 = puVar2[1]; + uStack38 = puVar2[2]; + param.interval_min = puVar2[3]; + param.interval_max = puVar2[4]; + conn = bt_conn_lookup_handle(handle); + if (conn == (bt_conn *)0x0) { + printf("Unable to lookup conn for handle %u\r\n",(uint)handle); + le_conn_param_neg_reply(handle,'\x02'); + } + else { + _Var1 = le_param_req(conn,(bt_le_conn_param *)&uStack40); + if (CONCAT31(extraout_var,_Var1) == 0) { + le_conn_param_neg_reply(handle,'\x1e'); + } + else { + buf_00 = bt_hci_cmd_create(0x2020,'\x0e'); + if (buf_00 != (net_buf *)0x0) { + __s = (undefined *)net_buf_simple_add((net_buf_simple *)&buf_00->field_4,0xe); + memset(__s,0,0xe); + *__s = (char)handle; + __s[1] = (char)(handle >> 8); + __s[2] = (undefined)uStack40; + __s[3] = uStack40._1_1_; + __s[4] = (char)uStack38; + __s[5] = (char)(uStack38 >> 8); + __s[6] = (undefined)param.interval_min; + __s[7] = param.interval_min._1_1_; + __s[8] = (char)param.interval_max; + __s[9] = (char)(param.interval_max >> 8); + bt_hci_cmd_send(0x2020,buf_00); + } + } + bt_conn_unref(conn); + } + return; +} + + + +void enh_conn_complete(bt_hci_evt_le_enh_conn_complete *evt) + +{ + u8_t uVar1; + u16_t uVar2; + ushort uVar3; + atomic_val_t aVar4; + bt_conn *conn; + int iVar5; + net_buf *buf; + undefined *puVar6; + u8_t local_30; + undefined auStack47 [3]; + bt_addr_le_t peer_addr; + bt_addr_le_t id_addr; + + uVar3 = evt->handle; + aVar4 = atomic_and(bt_dev.flags,-0x20001); + if (aVar4 << 0xe < 0) { + bt_keys_foreach(2,update_pending_id,(void *)0x0); + } + if (evt->status != '\0') { + conn = find_pending_connect((bt_addr_le_t *)0x0); + if (conn == (bt_conn *)0x0) { + return; + } + uVar1 = evt->status; + conn->err = uVar1; + if (uVar1 == '<') { + atomic_and(bt_dev.flags,-0x41); + } + else { + if (uVar1 != '\x02') { + printf("Unexpected status 0x%02x\r\n"); + bt_conn_unref(conn); + return; + } + } + bt_conn_set_state(conn,BT_CONN_DISCONNECTED); + goto done; + } + bt_addr_le_copy((bt_addr_le_t *)(peer_addr.a.val + 3),&evt->peer_addr); + if ((byte)(peer_addr.a.val[3] - 2) < 2) { + peer_addr.a.val[3] = peer_addr.a.val[3] - 2; + memcpy(&local_30 + 1,&evt->peer_rpa,6); + local_30 = '\x01'; + } + else { + bt_addr_le_copy((bt_addr_le_t *)&local_30,&evt->peer_addr); + } + conn = find_pending_connect((bt_addr_le_t *)(peer_addr.a.val + 3)); + if ((evt->role == '\x01') && (atomic_and(bt_dev.flags,-0x41), conn == (bt_conn *)0x0)) { + conn = bt_conn_add_le(bt_dev.adv_id,(bt_addr_le_t *)(peer_addr.a.val + 3)); + } + if (evt->role == '\0') { + if (conn == (bt_conn *)0x0) { + conn = bt_conn_add_le('\0',(bt_addr_le_t *)(peer_addr.a.val + 3)); + goto LAB_2301e0de; + } + } + else { +LAB_2301e0de: + if (conn == (bt_conn *)0x0) { + printf("Unable to add new conn for handle %u\r\n",(uint)uVar3); + return; + } + } + conn->handle = uVar3; + bt_addr_le_copy((bt_addr_le_t *)conn->field_20,(bt_addr_le_t *)(peer_addr.a.val + 3)); + *(u16_t *)(conn->field_20 + 0x16) = evt->interval; + *(u16_t *)(conn->field_20 + 0x1c) = evt->latency; + *(u16_t *)(conn->field_20 + 0x1e) = evt->supv_timeout; + uVar1 = evt->role; + conn->err = '\0'; + conn->role = uVar1; + if (uVar1 == '\x01') { + bt_addr_le_copy((bt_addr_le_t *)(conn->field_20 + 7),(bt_addr_le_t *)&local_30); + bt_addr_le_copy((bt_addr_le_t *)(conn->field_20 + 0xe),bt_dev.id_addr + conn->id); + iVar5 = atomic_test_bit(bt_dev.flags,9); + if ((iVar5 != 0) && ((bt_dev.le.states._4_4_ & 0x40) != 0)) { + set_advertise_enable(true); + } + } + if (conn->role == '\0') { + iVar5 = atomic_test_bit(bt_dev.flags,0xf); + if (iVar5 != 0) { + conn->id = '\0'; + atomic_and(bt_dev.flags,-0x8001); + } + bt_addr_le_copy((bt_addr_le_t *)(conn->field_20 + 0xe),(bt_addr_le_t *)&local_30); + bt_addr_le_copy((bt_addr_le_t *)(conn->field_20 + 7),bt_dev.id_addr + conn->id); + } + bt_conn_set_state(conn,BT_CONN_CONNECTED); + if (conn->state == BT_CONN_CONNECTED) { + if (((evt->role == '\0') || ((bt_dev.le.features[0] & 8) != 0)) && + (buf = bt_hci_cmd_create(0x2016,'\x02'), buf != (net_buf *)0x0)) { + puVar6 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + uVar2 = conn->handle; + *puVar6 = (char)uVar2; + puVar6[1] = (char)(uVar2 >> 8); + bt_hci_cmd_send(0x2016,buf); + } + else { + if (conn->role == '\x01') { + slave_update_conn_param(conn); + } + } + } +done: + bt_conn_unref(conn); + bt_le_scan_update(false); + return; +} + + + +void le_enh_conn_complete(net_buf *buf) + +{ + enh_conn_complete(*(bt_hci_evt_le_enh_conn_complete **)&buf->field_4); + return; +} + + + +void le_legacy_conn_complete(net_buf *buf) + +{ + u8_t *puVar1; + u8_t src; + undefined4 local_40; + undefined2 uStack60; + undefined4 uStack56; + undefined2 uStack52; + u8_t uStack48; + u8_t uStack47; + u8_t uStack46; + u8_t uStack45; + bt_hci_evt_le_enh_conn_complete enh; + + puVar1 = *(u8_t **)&buf->field_4; + uStack48 = *puVar1; + uStack47 = puVar1[1]; + uStack46 = puVar1[2]; + uStack45 = puVar1[3]; + enh.peer_rpa.val[2] = (u8_t)*(undefined2 *)(puVar1 + 0xb); + enh.peer_rpa.val[3] = (u8_t)((ushort)*(undefined2 *)(puVar1 + 0xb) >> 8); + enh.peer_rpa.val[4] = (u8_t)*(undefined2 *)(puVar1 + 0xd); + enh.peer_rpa.val[5] = (u8_t)((ushort)*(undefined2 *)(puVar1 + 0xd) >> 8); + enh.interval._0_1_ = (undefined)*(undefined2 *)(puVar1 + 0xf); + enh.interval._1_1_ = (undefined)((ushort)*(undefined2 *)(puVar1 + 0xf) >> 8); + enh.latency._0_1_ = puVar1[0x11]; + bt_addr_le_copy((bt_addr_le_t *)&enh,(bt_addr_le_t *)(puVar1 + 4)); + local_40 = 0; + uStack60 = 0; + memcpy(enh.peer_addr.a.val + 2,&local_40,6); + src = '\0'; + if (puVar1[3] == '\x01') { + src = bt_dev.adv_id; + } + _src = (bt_hci_evt_le_enh_conn_complete *)bt_lookup_id_addr(src,(bt_addr_le_t *)&enh); + if (_src == &enh) { + uStack56 = 0; + uStack52 = 0; + memcpy(enh.local_rpa.val + 2,&uStack56,6); + } + else { + memcpy(enh.local_rpa.val + 2,&enh.handle,6); + bt_addr_le_copy((bt_addr_le_t *)&enh,(bt_addr_le_t *)_src); + enh.status = enh.status + '\x02'; + } + enh_conn_complete((bt_hci_evt_le_enh_conn_complete *)&uStack48); + return; +} + + + +void hci_tx_thread(void *p1) + +{ + k_poll_event events [4]; + int num_events; + int iVar1; + net_buf *buf; + uint uVar2; + int iVar3; + + do { + events[0]._12_4_ = events[0]._12_4_ & 0xffff0fff; + num_events = bt_conn_prepare_events((k_poll_event *)0x4200d444); + num_events = num_events + 1; + iVar1 = k_poll((k_poll_event *)0x4200d430,num_events,-1); + iVar3 = 0x4200d430; + if (iVar1 != 0) { + vAssertCalled(); + } + while (num_events != 0) { + uVar2 = *(uint *)(iVar3 + 0xc) >> 0xc & 0xf; + if (uVar2 != 2) { + if (uVar2 == 4) { + if (*(char *)(iVar3 + 0xc) == '\0') { + buf = net_buf_get(&bt_dev.cmd_tx_queue,0); + if (buf == (net_buf *)0x0) { + vAssertCalled(); + } + k_sem_take(&bt_dev.ncmd_sem,0xffffffff); + if (bt_dev.sent_cmd != (net_buf *)0x0) { + printf("Uncleared pending sent_cmd\r\n"); + net_buf_unref(bt_dev.sent_cmd); + bt_dev.sent_cmd = (net_buf *)0x0; + } + bt_dev.sent_cmd = net_buf_ref(buf); + iVar1 = bt_send(buf); + if (iVar1 != 0) { + printf("Unable to send to driver (err %d)\r\n",iVar1); + k_sem_give(&bt_dev.ncmd_sem); + iVar1 = net_buf_id(buf); + hci_cmd_done(cmd_data[iVar1].opcode,'\x1f',(net_buf *)0x0); + net_buf_unref(bt_dev.sent_cmd); + bt_dev.sent_cmd = (net_buf *)0x0; + net_buf_unref(buf); + } + } + else { + if (*(char *)(iVar3 + 0xc) == '\x01') { + bt_conn_process_tx(*(int *)(iVar3 + 0x10) + -0x34); + } + } + } + else { + if (uVar2 != 0) { + printf("Unexpected k_poll event state %u\r\n"); + } + } + } + num_events = num_events + -1; + iVar3 = iVar3 + 0x14; + } + k_yield(); + } while( true ); +} + + + +int bt_recv(net_buf *buf) + +{ + byte bVar1; + ushort uVar2; + ushort uVar3; + ushort uVar4; + u8_t uVar5; + ushort handle; + ushort *puVar6; + bt_conn *conn; + byte *pbVar7; + + bVar1 = buf->user_data[0]; + if (bVar1 == 1) { + if ((uint)*(ushort *)((int)&buf->field_4 + 4) <= (uint)bVar1) { + vAssertCalled(); + } + pbVar7 = (byte *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,2); + if ((*pbVar7 < 0x1b) && ((1 << ((uint)*pbVar7 & 0x1f) & 0x408c000U) != 0)) { + vAssertCalled(); + } + handle_event(*pbVar7,buf,normal_events,5); + } + else { + if (bVar1 != 3) { + printf("Invalid buf type %u\r\n"); + net_buf_unref(buf); + return -0x16; + } + if ((uint)*(ushort *)((int)&buf->field_4 + 4) <= (uint)bVar1) { + vAssertCalled(); + } + puVar6 = (ushort *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,4); + uVar3 = puVar6[1]; + uVar4 = *puVar6; + uVar2 = *(ushort *)((int)&buf->field_4 + 4); + handle = (ushort)(((uint)uVar4 << 0x14) >> 0x14); + *(ushort *)(buf->user_data + 2) = handle; + buf->user_data[1] = -1; + if (uVar3 == uVar2) { + conn = bt_conn_lookup_handle(handle); + if (conn != (bt_conn *)0x0) { + uVar5 = bt_conn_index(conn); + buf->user_data[1] = uVar5; + bt_conn_recv(conn,buf,(byte)(uVar4 >> 0xc)); + bt_conn_unref(conn); + return 0; + } + printf("Unable to find conn for handle %u\r\n",(uint)*(ushort *)(buf->user_data + 2)); + } + else { + printf("ACL data length mismatch (%u != %u)\r\n"); + } + } + net_buf_unref(buf); + return 0; +} + + + +undefined4 bt_recv_prio(net_buf *param_1) + +{ + byte *pbVar1; + + if (param_1->user_data[0] != '\x01') { + vAssertCalled(); + } + if (*(ushort *)((int)¶m_1->field_4 + 4) < 2) { + vAssertCalled(); + } + pbVar1 = (byte *)net_buf_simple_pull_mem((net_buf_simple *)¶m_1->field_4,2); + if (*pbVar1 < 0x1b) { + if ((1 << ((uint)*pbVar1 & 0x1f) & 0x408c000U) != 0) goto LAB_2301e5d0; + } + vAssertCalled(); +LAB_2301e5d0: + handle_event(*pbVar1,param_1,prio_events,4); + net_buf_unref(param_1); + return 0; +} + + + +int bt_hci_driver_register(bt_hci_driver *drv) + +{ + int iVar1; + + if (bt_dev.drv == (bt_hci_driver *)0x0) { + iVar1 = -0x16; + if ((drv->open != (anon_subr_int_for_open *)0x0) && + (drv->send != (anon_subr_int_net_buf_ptr_for_send *)0x0)) { + iVar1 = 0; + bt_dev.drv = drv; + } + } + else { + iVar1 = -0x45; + } + return iVar1; +} + + + +void bt_finalize_init(void) + +{ + atomic_or(bt_dev.flags,2); + bt_le_scan_update(false); + return; +} + + + +void bt_delete_queue(k_fifo *queue_to_del) + +{ + net_buf *buf; + + while (buf = net_buf_get(queue_to_del,0), buf != (net_buf *)0x0) { + net_buf_unref(buf); + } + k_queue_free((k_queue *)queue_to_del); + return; +} + + + +int bt_disable_action(void) + +{ + bt_gatt_deinit(); + k_thread_delete(&tx_thread_data); + k_thread_delete(&recv_thread_data); + k_thread_delete(&work_q_thread); + bt_delete_queue(&recv_fifo); + bt_delete_queue((k_fifo *)&g_work_queue_main); + bt_delete_queue(&bt_dev.cmd_tx_queue); + k_queue_free((k_queue *)&free_tx); + k_sem_delete(&bt_dev.ncmd_sem); + k_sem_delete(&g_poll_sem); + k_sem_delete(&sc_local_pkey_ready); + k_sem_delete(&bt_dev.le.pkts); + queue_inited = true; + atomic_and(bt_dev.flags,-2); + bl_onchiphci_interface_deinit(); + ble_controller_deinit(); + return 0; +} + + + +int bt_disable(void) + +{ + _Bool _Var1; + undefined3 extraout_var; + int iVar2; + + _Var1 = le_check_valid_conn(); + if (((CONCAT31(extraout_var,_Var1) == 0) && + (iVar2 = atomic_test_bit(bt_dev.flags,0xb), iVar2 == 0)) && + (iVar2 = atomic_test_bit(bt_dev.flags,6), iVar2 == 0)) { + iVar2 = bt_disable_action(); + return iVar2; + } + return -1; +} + + + +// WARNING: Variable defined which should be unmapped: sd +// WARNING: Could not reconcile some variable overlaps + +int bt_set_name(char *name) + +{ + size_t sVar1; + int iVar2; + u8_t local_20; + undefined uStack31; + bt_data data [1]; + bt_ad sd; + + data[0].data = &local_20; + sVar1 = strlen(name); + if (sVar1 < 0x1e) { + iVar2 = strcmp(bt_dev.name,name); + if (iVar2 != 0) { + strncpy(bt_dev.name,name,0x1e); + iVar2 = atomic_test_bit(bt_dev.flags,7); + if (iVar2 != 0) { + local_20 = '\t'; + sVar1 = strlen(name); + uStack31 = (undefined)sVar1; + data[0]._0_4_ = name; + set_ad(0x2009,(bt_ad *)&data[0].data,1); + iVar2 = atomic_test_bit(bt_dev.flags,6); + if (iVar2 != 0) { + set_advertise_enable(false); + set_advertise_enable(true); + } + } + } + iVar2 = 0; + } + else { + iVar2 = -0xc; + } + return iVar2; +} + + + +int bt_enable(bt_ready_cb_t *cb) + +{ + int iVar1; + uint uVar2; + + if (bt_dev.drv == (bt_hci_driver *)0x0) { + printf("No HCI driver registered\r\n"); + iVar1 = -0x13; + } + else { + uVar2 = atomic_or(bt_dev.flags,1); + iVar1 = -0x45; + if ((uVar2 & 1) == 0) { + k_work_init(&bt_dev.init,init_work); + k_work_q_start(); + k_sem_init(&bt_dev.ncmd_sem,1,1); + k_queue_init((k_queue *)&bt_dev.cmd_tx_queue,0x14); + if (queue_inited == false) { + k_queue_init((k_queue *)&hci_cmd_pool,2); + k_queue_init((k_queue *)&hci_rx_pool,5); + } + k_sem_init(&g_poll_sem,0,1); + bt_set_name("BL602-BLE-DEV"); + ready_cb = cb; + k_thread_create(&tx_thread_data,"hci_tx_thread",0x600,hci_tx_thread,0x1d); + iVar1 = (*(bt_dev.drv)->open)((bt_dev.drv)->open); + if (iVar1 == 0) { + k_work_submit(&bt_dev.init); + } + else { + printf("HCI driver open failed (%d)\r\n",iVar1); + } + } + } + return iVar1; +} + + + +char * bt_get_name(void) + +{ + return bt_dev.name; +} + + + +int bt_id_create(bt_addr_le_t *addr,u8_t *irk) + +{ + bool bVar1; + u8_t id; + uint uVar2; + int iVar3; + u8_t uVar4; + uint uVar5; + undefined4 uStack40; + undefined2 uStack36; + undefined uStack34; + + if (addr != (bt_addr_le_t *)0x0) { + uStack40 = 0; + uStack36 = 0; + uStack34 = 0; + iVar3 = memcmp(addr,&uStack40,7); + if (iVar3 != 0) { + if ((addr->type != '\x01') || (((addr->a).val[5] & 0xc0) != 0xc0)) { + printf("Only static random identity address supported\r\n"); + return -0x16; + } + iVar3 = id_find(addr); + if (-1 < iVar3) { + return -0x45; + } + } + } + id = bt_dev.id_count; + uVar2 = 0xffffffea; + if (irk == (u8_t *)0x0) { + uVar5 = (uint)bt_dev.id_count; + uVar2 = 0xfffffff4; + if (bt_dev.id_count != '\x01') { + uVar4 = bt_dev.id_count + '\x01'; + bVar1 = bt_dev.id_count == '\0'; + bt_dev.id_count = uVar4; + if ((bVar1) && (iVar3 = atomic_test_bit(bt_dev.flags,1), iVar3 == 0)) { + atomic_or(bt_dev.flags,8); + } + id_create(id,addr); + uVar2 = uVar5; + } + } + return uVar2; +} + + + +int bt_setup_id_addr(void) + +{ + int iVar1; + + iVar1 = bt_id_create((bt_addr_le_t *)0x0,(u8_t *)0x0); + return iVar1; +} + + + +void init_work(k_work *work) + +{ + void *__s1; + uint8_t uVar1; + undefined3 extraout_var; + int iVar2; + uint initial_count; + net_buf *buf; + u8_t *dst; + undefined *puVar3; + net_buf *pnStack36; + net_buf *rsp; + undefined4 uStack24; + undefined2 uStack20; + + uVar1 = bl_onchiphci_interface_init(); + iVar2 = CONCAT31(extraout_var,uVar1); + if (iVar2 != 0) goto LAB_2301eb52; + if (((bt_dev.drv)->quirks & 1) == 0) { + iVar2 = bt_hci_cmd_send_sync(0xc03,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_2301eb52; + if (**(char **)&pnStack36->field_4 == '\0') { + scan_dev_found_cb = (bt_le_scan_cb_t_conflict1 *)0x0; + initial_count = atomic_get(bt_dev.flags); + atomic_set(bt_dev.flags,initial_count & 0xd); + } + net_buf_unref(pnStack36); + } + iVar2 = bt_hci_cmd_send_sync(0x1003,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_2301eb52; + memcpy(bt_dev.features,(void *)(*(int *)&pnStack36->field_4 + 1),8); + net_buf_unref(pnStack36); + iVar2 = bt_hci_cmd_send_sync(0x1001,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_2301eb52; + iVar2 = *(int *)&pnStack36->field_4; + bt_dev.hci_version = *(u8_t *)(iVar2 + 1); + bt_dev.hci_revision = *(u16_t *)(iVar2 + 2); + bt_dev.lmp_version = *(u8_t *)(iVar2 + 4); + bt_dev.lmp_subversion = *(u16_t *)(iVar2 + 7); + bt_dev.manufacturer = *(u16_t *)(iVar2 + 5); + net_buf_unref(pnStack36); + iVar2 = atomic_test_bit(bt_dev.flags,3); + if (iVar2 == 0) { + iVar2 = bt_hci_cmd_send_sync(0x1009,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_2301eb52; + rsp = (net_buf *)0x0; + __s1 = (void *)(*(int *)&pnStack36->field_4 + 1); + iVar2 = memcmp(__s1,&rsp,6); + if (iVar2 != 0) { + uStack24 = DAT_4200dcf8; + uStack20 = DAT_4200dcfc; + iVar2 = memcmp(__s1,&uStack24,6); + if (iVar2 != 0) { + memcpy(&bt_dev.id_addr[0].a,__s1,6); + bt_dev.id_addr[0].type = '\0'; + bt_dev.id_count = '\x01'; + } + } + net_buf_unref(pnStack36); + } + iVar2 = bt_hci_cmd_send_sync(0x1002,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_2301eb52; + memcpy(bt_dev.supported_commands,(void *)(*(int *)&pnStack36->field_4 + 1),0x40); + net_buf_unref(pnStack36); + if ((bt_dev.features[0][4] & 0x40) == 0) { + printf("Non-LE capable controller detected!\r\n"); + iVar2 = -0x13; + goto LAB_2301eb52; + } + iVar2 = bt_hci_cmd_send_sync(0x2003,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_2301eb52; + memcpy(&bt_dev.le,(void *)(*(int *)&pnStack36->field_4 + 1),8); + net_buf_unref(pnStack36); + iVar2 = bt_hci_cmd_send_sync(0x2002,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_2301eb52; + bt_dev.le.mtu = *(u16_t *)(*(int *)&pnStack36->field_4 + 1); + if (bt_dev.le.mtu != 0) { + initial_count = (uint)*(byte *)(*(int *)&pnStack36->field_4 + 3); + k_sem_init(&bt_dev.le.pkts,initial_count,initial_count); + } + net_buf_unref(pnStack36); + if ((bt_dev.features[0][4] & 0x20) == 0) { + buf = bt_hci_cmd_create(0xc6d,'\x02'); + if (buf != (net_buf *)0x0) { + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + *puVar3 = 1; + puVar3[1] = 0; + iVar2 = bt_hci_cmd_send_sync(0xc6d,buf,(net_buf **)0x0); + if (iVar2 != 0) goto LAB_2301eb52; + goto LAB_2301ebda; + } + } + else { +LAB_2301ebda: + if ((bt_dev.supported_commands[28] & 8) != 0) { + iVar2 = bt_hci_cmd_send_sync(0x201c,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_2301eb52; + bt_dev.le.states._0_4_ = *(undefined4 *)(*(int *)&pnStack36->field_4 + 1); + bt_dev.le.states._4_4_ = *(undefined4 *)(*(int *)&pnStack36->field_4 + 5); + net_buf_unref(pnStack36); + } + if ((bt_dev.le.features[0] & 0x40) != 0) { + iVar2 = bt_hci_cmd_send_sync(0x202a,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_2301eb52; + bt_dev.le.rl_size = *(u8_t *)(*(int *)&pnStack36->field_4 + 1); + net_buf_unref(pnStack36); + } + iVar2 = bt_hci_cmd_send_sync(0x200f,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_2301eb52; + bt_dev.le.wl_size = *(u8_t *)(*(int *)&pnStack36->field_4 + 1); + net_buf_unref(pnStack36); + buf = bt_hci_cmd_create(0x2001,'\b'); + if (buf != (net_buf *)0x0) { + net_buf_simple_add((net_buf_simple *)&buf->field_4,8); + initial_count = 0x202; + if ((bt_dev.le.features[0] & 0x40) == 0) { + initial_count = 3; + } + dst = (u8_t *)(initial_count | 0x2c); + if ((bt_dev.le.features[0] & 2) == 0) { + dst = (u8_t *)(initial_count | 0xc); + } + if ((bt_dev.le.features[0] & 1) != 0) { + dst = (u8_t *)((uint)dst | 0x10); + } + if ((bt_dev.supported_commands[34] & 6) == 6) { + dst = (u8_t *)((uint)dst | 0x180); + } + sys_put_le64(dst); + iVar2 = bt_hci_cmd_send_sync(0x2001,buf,(net_buf **)0x0); + if (iVar2 == 0) { + if (((bt_dev.features[0][4] & 0x20) == 0) && (bt_dev.le.mtu == 0)) { + iVar2 = bt_hci_cmd_send_sync(0x1005,(net_buf *)0x0,&pnStack36); + if (iVar2 != 0) goto LAB_2301eb52; + if (bt_dev.le.mtu == 0) { + bt_dev.le.mtu = *(u16_t *)(*(int *)&pnStack36->field_4 + 1); + initial_count = (uint)*(ushort *)(*(int *)&pnStack36->field_4 + 4); + k_sem_init(&bt_dev.le.pkts,initial_count,initial_count); + } + net_buf_unref(pnStack36); + } + buf = bt_hci_cmd_create(0xc01,'\b'); + iVar2 = -0x37; + if (buf != (net_buf *)0x0) { + net_buf_simple_add((net_buf_simple *)&buf->field_4,8); + if ((bt_dev.le.features[0] & 1) == 0) { + dst = (u8_t *)0x2008810; + } + else { + dst = (u8_t *)0x2008890; + } + sys_put_le64(dst); + iVar2 = bt_hci_cmd_send_sync(0xc01,buf,(net_buf **)0x0); + if (iVar2 == 0) { + if ((bt_dev.id_count == '\0') && (iVar2 = bt_setup_id_addr(), iVar2 != 0)) { + printf("Unable to set identity address\r\n"); + } + else { + iVar2 = bt_conn_init(); + if (iVar2 == 0) { + bt_finalize_init(); + } + } + } + } + } + goto LAB_2301eb52; + } + } + iVar2 = -0x37; +LAB_2301eb52: + if (ready_cb != (bt_ready_cb_t *)0x0) { + (*ready_cb)(iVar2); + } + return; +} + + + +_Bool bt_addr_le_is_bonded(u8_t id,bt_addr_le_t *addr) + +{ + bool bVar1; + bt_keys *pbVar2; + + pbVar2 = bt_keys_find_addr(id,addr); + if (pbVar2 == (bt_keys *)0x0) { + bVar1 = false; + } + else { + bVar1 = pbVar2->keys != 0; + } + return (_Bool)bVar1; +} + + + +int bt_le_adv_start_internal + (byte *param_1,bt_data *param_2,size_t param_3,bt_data *param_4,size_t param_5, + bt_addr_le_t *param_6) + +{ + byte bVar1; + int iVar2; + net_buf *buf; + uint uVar3; + undefined4 uStack72; + undefined2 uStack68; + undefined uStack66; + undefined2 uStack64; + undefined2 uStack62; + byte bStack60; + byte bStack59; + bt_addr_le_t bStack58; + u8_t uStack51; + undefined uStack50; + + iVar2 = atomic_test_bit(bt_dev.flags,1); + if (iVar2 == 0) { + return 0xfffffff5; + } + if ((uint)*param_1 < (uint)bt_dev.id_count) { + uStack72 = 0; + uStack68 = 0; + uStack66 = 0; + iVar2 = memcmp(bt_dev.id_addr + (uint)*param_1,&uStack72,7); + if (((iVar2 != 0) && + (((bVar1 = param_1[1], (bVar1 & 1) != 0 || (8 < bt_dev.hci_version)) || + (0x9f < *(ushort *)(param_1 + 2))))) && + ((bt_dev.le.wl_entries != '\0' || (((bVar1 & 0x40) == 0 && (-1 < (char)bVar1)))))) { + if (((bVar1 & 0x10) != 0) || (param_6 == (bt_addr_le_t *)0x0)) { + if (*(ushort *)(param_1 + 4) < *(ushort *)(param_1 + 2)) { + return 0xffffffea; + } + if (*(ushort *)(param_1 + 2) < 0x20) { + return 0xffffffea; + } + if (0x4000 < *(ushort *)(param_1 + 4)) { + return 0xffffffea; + } + } + iVar2 = atomic_test_bit(bt_dev.flags,6); + if (iVar2 != 0) { + return 0xffffffbb; + } + memset(&uStack64,0,0xf); + uStack64 = *(undefined2 *)(param_1 + 2); + uStack62 = *(undefined2 *)(param_1 + 4); + uStack51 = adv_ch_map; + if (bt_dev.adv_id != *param_1) { + atomic_and(bt_dev.flags,-0x10001); + } + bVar1 = param_1[1]; + if ((bVar1 & 0x40) == 0) { + uStack50 = 2; + if (-1 < (char)bVar1) { + uStack50 = 0; + } + } + else { + uStack50 = 3; + if (-1 < (char)bVar1) { + uStack50 = 1; + } + } + bt_dev.adv_id = *param_1; + uVar3 = (uint)bt_dev.adv_id; + bVar1 = param_1[1]; + bStack60 = bVar1 & 1; + if ((bVar1 & 1) == 0) { + if ((bVar1 & 4) == 0) { + iVar2 = le_set_private_addr(); + bStack59 = 1; + } + else { + if (bt_dev.id_addr[uVar3].type == '\x01') { + iVar2 = set_random_address(&bt_dev.id_addr[uVar3].a); + } + bStack59 = bt_dev.id_addr[uVar3].type; + } + if (iVar2 != 0) { + return iVar2; + } + bStack60 = 2; + if (param_4 == (bt_data *)0x0) { + bStack60 = 3; + } + } + else { + if ((bt_dev.id_addr[uVar3].type == '\x01') && + (iVar2 = set_random_address(&bt_dev.id_addr[uVar3].a), iVar2 != 0)) { + return iVar2; + } + bStack59 = bt_dev.id_addr[uVar3].type; + if (param_6 == (bt_addr_le_t *)0x0) { + bStack60 = 0; + } + else { + if ((param_1[1] & 0x10) != 0) { + bStack60 = 4; + } + bt_addr_le_copy(&bStack58,param_6); + if (((bt_dev.le.features[0] & 0x40) != 0) && ((param_1[1] & 0x20) != 0)) { + bStack59 = bStack59 | 2; + } + } + } + buf = bt_hci_cmd_create(0x2006,'\x0f'); + if (buf == (net_buf *)0x0) { + return 0xffffffc9; + } + net_buf_simple_add_mem((net_buf_simple *)&buf->field_4,&uStack64,0xf); + iVar2 = bt_hci_cmd_send_sync(0x2006,buf,(net_buf **)0x0); + if (iVar2 == 0) { + if ((param_6 == (bt_addr_le_t *)0x0) && + (iVar2 = le_adv_update(param_2,param_3,param_4,param_5,(_Bool)(param_1[1] & 1), + (_Bool)(param_1[1] >> 3 & 1)), iVar2 != 0)) { + return iVar2; + } + iVar2 = set_advertise_enable(true); + if (iVar2 == 0) { + atomic_set_bit_to(bt_dev.flags,9,(_Bool)((param_1[1] >> 1 ^ 1) & 1)); + atomic_set_bit_to(bt_dev.flags,7,(_Bool)(param_1[1] >> 3 & 1)); + atomic_set_bit_to(bt_dev.flags,8,(_Bool)(param_1[1] & 1)); + return 0; + } + return iVar2; + } + return iVar2; + } + } + return 0xffffffea; +} + + + +int set_adv_channel_map(u8_t channel) + +{ + if ((byte)(channel - 1) < 7) { + adv_ch_map = channel; + return 0; + } + return -1; +} + + + +int bt_get_local_public_address(bt_addr_le_t *adv_addr) + +{ + bt_addr_le_copy(adv_addr,(bt_addr_le_t *)&bt_dev); + return 0; +} + + + +int bt_get_local_ramdon_address(bt_addr_le_t *adv_addr) + +{ + bt_addr_le_copy(adv_addr,&bt_dev.random_addr); + return 0; +} + + + +int bt_le_adv_start(bt_le_adv_param *param,bt_data *ad,size_t ad_len,bt_data *sd,size_t sd_len) + +{ + int iVar1; + + if ((param->options & 0x10) == 0) { + iVar1 = bt_le_adv_start_internal(); + return iVar1; + } + return -0x16; +} + + + +int bt_le_adv_stop(void) + +{ + int iVar1; + + atomic_and(bt_dev.flags,-0x201); + iVar1 = atomic_test_bit(bt_dev.flags,6); + if (iVar1 != 0) { + iVar1 = set_advertise_enable(false); + if (iVar1 != 0) { + return iVar1; + } + iVar1 = atomic_test_bit(bt_dev.flags,10); + if ((iVar1 != 0) && (iVar1 = atomic_test_bit(bt_dev.flags,0xc), iVar1 != 0)) { + le_set_private_addr(); + return 0; + } + } + return 0; +} + + + +int bt_le_scan_start(byte *param_1,bt_le_scan_cb_t_conflict1 *param_2) + +{ + int iVar1; + int iVar2; + uint uVar3; + + iVar2 = atomic_test_bit(bt_dev.flags,1); + iVar1 = -0xb; + if ((((iVar2 != 0) && (iVar1 = -0x16, *param_1 < 2)) && ((param_1[1] & 0xfc) == 0)) && + ((bt_dev.le.wl_entries != '\0' || ((param_1[1] & 2) == 0)))) { + iVar1 = -0x16; + if (((ushort)(*(ushort *)(param_1 + 2) - 4) < 0x3ffd) && + (((ushort)(*(ushort *)(param_1 + 4) - 4) < 0x3ffd && + (*(ushort *)(param_1 + 4) <= *(ushort *)(param_1 + 2))))) { + uVar3 = atomic_or(bt_dev.flags,0x800); + iVar1 = -0x45; + if ((uVar3 & 0x800) == 0) { + iVar1 = atomic_test_bit(bt_dev.flags,10); + if ((iVar1 == 0) || (iVar1 = set_le_scan_enable('\0'), iVar1 == 0)) { + atomic_set_bit_to(bt_dev.flags,0xd,(_Bool)(param_1[1] & 1)); + atomic_set_bit_to(bt_dev.flags,0xe,(_Bool)(param_1[1] >> 1 & 1)); + iVar1 = start_le_scan(*param_1,*(u16_t *)(param_1 + 2),*(u16_t *)(param_1 + 4)); + if (iVar1 == 0) { + scan_dev_found_cb = param_2; + return 0; + } + } + atomic_and(bt_dev.flags,-0x801); + } + } + } + return iVar1; +} + + + +int bt_le_scan_stop(void) + +{ + atomic_val_t aVar1; + int iVar2; + + aVar1 = atomic_and(bt_dev.flags,-0x801); + if (aVar1 << 0x14 < 0) { + scan_dev_found_cb = (bt_le_scan_cb_t_conflict1 *)0x0; + iVar2 = bt_le_scan_update(false); + return iVar2; + } + return -0x45; +} + + + +int bt_set_tx_pwr(int8_t power) + +{ + net_buf *buf; + int iVar1; + int8_t aiStack20 [4]; + bt_hci_cp_vs_set_tx_pwr set_param; + + if ((byte)power < 0x15) { + memset(aiStack20,0,1); + aiStack20[0] = power; + buf = bt_hci_cmd_create(0xfc61,'\x01'); + iVar1 = -0x37; + if (buf != (net_buf *)0x0) { + net_buf_simple_add_mem((net_buf_simple *)&buf->field_4,aiStack20,1); + iVar1 = bt_hci_cmd_send_sync(0xfc61,buf,(net_buf **)0x0); + } + return iVar1; + } + return 0x12; +} + + + +int bt_buf_get_rx_avail_cnt(void) + +{ + int iVar1; + + iVar1 = k_queue_get_cnt((k_queue *)&hci_rx_pool); + return iVar1 + (uint)hci_rx_pool.uninit_count; +} + + + +net_buf * bt_buf_get_rx(bt_buf_type type,s32_t timeout) + +{ + net_buf *pnVar1; + + pnVar1 = net_buf_alloc_fixed(&hci_rx_pool,timeout); + if (pnVar1 != (net_buf *)0x0) { + net_buf_simple_reserve((net_buf_simple *)&pnVar1->field_4,1); + pnVar1->user_data[0] = type; + } + return pnVar1; +} + + + +net_buf * bt_buf_get_cmd_complete(s32_t timeout) + +{ + net_buf *pnVar1; + + irq_lock(); + pnVar1 = bt_dev.sent_cmd; + bt_dev.sent_cmd = (net_buf *)0x0; + irq_unlock(); + if (pnVar1 == (net_buf *)0x0) { + pnVar1 = bt_buf_get_rx(BT_BUF_EVT,timeout); + return pnVar1; + } + pnVar1->user_data[0] = '\x01'; + *(undefined2 *)((int)&pnVar1->field_4 + 4) = 0; + net_buf_simple_reserve((net_buf_simple *)&pnVar1->field_4,1); + return pnVar1; +} + + + +int bt_pub_key_gen(bt_pub_key_cb *new_cb) + +{ + bt_pub_key_cb *pbVar1; + uint uVar2; + bt_pub_key_cb *pbVar3; + int iVar4; + + if ((bt_dev.supported_commands[34] & 6) == 6) { + pbVar1 = new_cb; + if (pub_key_cb != (bt_pub_key_cb *)0x0) { + pbVar1 = pub_key_cb; + do { + pbVar3 = pbVar1; + pbVar1 = pub_key_cb; + if (new_cb->func == pbVar3->func) goto LAB_2301f440; + pbVar1 = pbVar3->_next; + } while (pbVar3->_next != (bt_pub_key_cb *)0x0); + pbVar3->_next = new_cb; + pbVar1 = pub_key_cb; + } +LAB_2301f440: + pub_key_cb = pbVar1; + uVar2 = atomic_or(bt_dev.flags,0x20); + iVar4 = 0; + if ((uVar2 & 0x20) == 0) { + atomic_and(bt_dev.flags,-0x11); + iVar4 = bt_hci_cmd_send_sync(0x2025,(net_buf *)0x0,(net_buf **)0x0); + if (iVar4 != 0) { + printf("Sending LE P256 Public Key command failed\r\n"); + atomic_and(bt_dev.flags,-0x21); + pub_key_cb = (bt_pub_key_cb *)0x0; + } + } + } + else { + printf("ECC HCI commands not available\r\n"); + iVar4 = -0x23; + } + return iVar4; +} + + + +u8_t * bt_pub_key_get(void) + +{ + int iVar1; + u8_t *puVar2; + + iVar1 = atomic_test_bit(bt_dev.flags,4); + puVar2 = (u8_t *)0x0; + if (iVar1 != 0) { + puVar2 = pub_key; + } + return puVar2; +} + + + +int bt_dh_key_gen(u8_t *remote_pk,bt_dh_key_cb_t *cb) + +{ + int iVar1; + net_buf *buf; + void *__dest; + int iVar2; + + if ((dh_key_cb == (bt_dh_key_cb_t *)0x0) && (iVar2 = atomic_test_bit(bt_dev.flags,5), iVar2 == 0)) + { + iVar1 = atomic_test_bit(bt_dev.flags,4); + iVar2 = -0x31; + if (iVar1 != 0) { + dh_key_cb = cb; + buf = bt_hci_cmd_create(0x2026,'@'); + if (buf == (net_buf *)0x0) { + dh_key_cb = (bt_dh_key_cb_t *)0x0; + iVar2 = -0x37; + } + else { + __dest = net_buf_simple_add((net_buf_simple *)&buf->field_4,0x40); + memcpy(__dest,remote_pk,0x40); + iVar2 = bt_hci_cmd_send_sync(0x2026,buf,(net_buf **)0x0); + if (iVar2 != 0) { + dh_key_cb = (bt_dh_key_cb_t *)0x0; + } + } + } + } + else { + iVar2 = -0x10; + } + return iVar2; +} + + + +void sys_slist_remove(sys_slist_t *list,sys_snode_t *prev_node,sys_snode_t *node) + +{ + sys_snode_t *psVar1; + + psVar1 = (sys_snode_t *)node->next; + if (prev_node == (sys_snode_t *)0x0) { + list->head = psVar1; + if (list->tail == node) { + list->tail = psVar1; + } + } + else { + *(sys_snode_t **)&prev_node->next = psVar1; + if (list->tail == node) { + list->tail = prev_node; + } + } + node->next = (_snode *)0x0; + return; +} + + + +size_t net_buf_frags_len(net_buf *buf) + +{ + anon_union_for_field_4 *paVar1; + size_t sVar2; + + sVar2 = 0; + while (buf != (net_buf *)0x0) { + paVar1 = &buf->field_4; + buf = (net_buf *)buf->field_0; + sVar2 = sVar2 + *(ushort *)((int)paVar1 + 4); + } + return sVar2; +} + + + +u8_t get_ident(void) + +{ + u8_t ident; + u8_t uVar1; + + uVar1 = ident + '\x01'; + if (uVar1 == '\0') { + uVar1 = '\x01'; + } + return uVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +bt_l2cap_le_chan * __l2cap_lookup_ident(bt_conn *conn,u16_t ident,_Bool remove) + +{ + sys_snode_t node; + undefined2 in_register_0000202e; + undefined3 in_register_00002031; + sys_snode_t sVar1; + sys_snode_t prev_node; + + node = (sys_snode_t)(conn->channels).head; + if (node != (sys_snode_t)0x0) { + prev_node = (sys_snode_t)0x0; + do { + sVar1 = (sys_snode_t)((int)node + -8); + if (sVar1 == (sys_snode_t)0x0) { + return (bt_l2cap_le_chan *)0; + } + if ((uint)*(byte *)&((sys_snode_t *)((int)node + 0x34))->next == + CONCAT22(in_register_0000202e,ident)) { + if (CONCAT31(in_register_00002031,remove) == 0) { + return (bt_l2cap_le_chan *)sVar1; + } + sys_slist_remove(&conn->channels,(sys_snode_t *)prev_node,(sys_snode_t *)node); + return (bt_l2cap_le_chan *)sVar1; + } + sVar1 = *(sys_snode_t *)node; + prev_node = node; + node = sVar1; + } while (sVar1 != (sys_snode_t)0x0); + node = (sys_snode_t)0x0; + } + return (bt_l2cap_le_chan *)node; +} + + + +bt_l2cap_server * l2cap_server_lookup_psm(u16_t psm) + +{ + undefined2 in_register_0000202a; + sys_snode_t sVar1; + sys_snode_t sVar2; + + sVar2 = (sys_snode_t)servers.head; + while (((sVar1 = sVar2, sVar2 != (sys_snode_t)0x0 && + (sVar1 = (sys_snode_t)((int)sVar2 + -8), sVar1 != (sys_snode_t)0x0)) && + ((uint)*(ushort *)sVar1 != CONCAT22(in_register_0000202a,psm)))) { + sVar2 = *(sys_snode_t *)sVar2; + } + return (bt_l2cap_server *)sVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +bt_l2cap_le_chan * l2cap_remove_rx_cid(bt_conn *conn,u16_t cid) + +{ + sys_snode_t sVar1; + sys_snode_t node; + undefined2 in_register_0000202e; + sys_snode_t prev_node; + + sVar1 = (sys_snode_t)0x0; + if (((CONCAT22(in_register_0000202e,cid) - 0x40 & 0xffff) < 0x40) && + (sVar1 = (sys_snode_t)(conn->channels).head, sVar1 != (sys_snode_t)0x0)) { + prev_node = (sys_snode_t)0x0; + node = sVar1; + do { + if ((sys_snode_t)((int)node + -8) == (sys_snode_t)0x0) { + return (bt_l2cap_le_chan *)0; + } + if ((uint)*(ushort *)&((sys_snode_t *)((int)node + 0x38))->next == + CONCAT22(in_register_0000202e,cid)) { + sys_slist_remove(&conn->channels,(sys_snode_t *)prev_node,(sys_snode_t *)node); + return (bt_l2cap_le_chan *)((int)node + -8); + } + sVar1 = *(sys_snode_t *)node; + prev_node = node; + node = sVar1; + } while (sVar1 != (sys_snode_t)0x0); + } + return (bt_l2cap_le_chan *)sVar1; +} + + + +void l2cap_chan_sdu_sent(bt_conn *conn,void *user_data) + +{ + code *UNRECOVERED_JUMPTABLE; + + UNRECOVERED_JUMPTABLE = *(code **)(*(int *)((int)user_data + 4) + 0x14); + if (UNRECOVERED_JUMPTABLE != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x2301f658. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(user_data); + return; + } + return; +} + + + +net_buf * l2cap_alloc_frag(s32_t timeout,void *user_data) + +{ + net_buf *pnVar1; + + // WARNING: Could not recover jumptable at 0x2301f664. Too many branches + // WARNING: Treating indirect jump as call + pnVar1 = (net_buf *)(**(code **)(*(int *)((int)user_data + 4) + 0xc))(user_data); + return pnVar1; +} + + + +void l2cap_connected(bt_l2cap_chan *chan) + +{ + return; +} + + + +void l2cap_chan_destroy(bt_l2cap_chan *chan) + +{ + net_buf *buf; + + k_delayed_work_cancel(&chan->rtx_work); + if ((net_buf *)chan[1].status[0] != (net_buf *)0x0) { + net_buf_unref((net_buf *)chan[1].status[0]); + chan[1].status[0] = 0; + } + while (buf = net_buf_get((k_fifo *)&chan[1].rtx_work.timer.args,0), buf != (net_buf *)0x0) { + net_buf_unref(buf); + } + while (buf = net_buf_get((k_fifo *)&chan[2].destroy,0), buf != (net_buf *)0x0) { + net_buf_unref(buf); + } + if (*(net_buf **)&chan[1].state != (net_buf *)0x0) { + net_buf_unref(*(net_buf **)&chan[1].state); + *(undefined4 *)&chan[1].state = 0; + *(undefined2 *)&chan[1].ident = 0; + } + return; +} + + + +void l2cap_chan_tx_init(bt_l2cap_le_chan *chan) + +{ + memset(&chan->tx,0,0x14); + k_sem_init(&(chan->tx).credits,0,0xffffffff); + k_queue_init((k_queue *)&chan->tx_queue,0x14); + return; +} + + + +void l2cap_chan_rx_init(bt_l2cap_le_chan *chan) + +{ + u16_t uVar1; + ushort uVar2; + + if ((chan->rx).mtu == 0) { + (chan->rx).mtu = 0xf5; + } + uVar2 = (chan->rx).mtu; + if ((chan->rx).init_credits == 0) { + if (((chan->chan).ops)->alloc_buf == + (anon_subr_net_buf_ptr_bt_l2cap_chan_ptr_for_alloc_buf *)0x0) { + uVar1 = 4; + } + else { + uVar1 = (u16_t)((int)((uint)uVar2 + 0xf6) / 0xf7); + } + (chan->rx).init_credits = uVar1; + } + if (0xf5 < uVar2) { + uVar2 = 0xf5; + } + (chan->rx).mps = uVar2 + 2; + k_sem_init(&(chan->rx).credits,0,0xffffffff); + return; +} + + + +int l2cap_accept(bt_conn *conn,bt_l2cap_chan **chan) + +{ + int iVar1; + + if (bt_l2cap_pool[0].chan.chan.conn == (bt_conn *)0x0) { + iVar1 = 0; + } + else { + if (bt_l2cap_pool[1].chan.chan.conn != (bt_conn *)0x0) { + printf("No available L2CAP context for conn %p\r\n",conn); + return -0xc; + } + iVar1 = 1; + } + bt_l2cap_pool[iVar1].chan.chan.ops = (bt_l2cap_chan_ops *)0x4200d480; + *(bt_l2cap **)chan = bt_l2cap_pool + iVar1; + return 0; +} + + + +net_buf * l2cap_create_le_sig_pdu(u8_t code,u8_t ident,u16_t len) + +{ + undefined3 in_register_00002029; + net_buf *pnVar1; + u8_t *puVar2; + + pnVar1 = bt_conn_create_pdu_timeout((net_buf_pool *)0x0,4,2000); + if (pnVar1 == (net_buf *)0x0) { + printf("Unable to allocate buffer for op 0x%02x\r\n",CONCAT31(in_register_00002029,code)); + } + else { + puVar2 = (u8_t *)net_buf_simple_add((net_buf_simple *)&pnVar1->field_4,4); + puVar2[2] = (u8_t)len; + *puVar2 = code; + puVar2[1] = ident; + puVar2[3] = (u8_t)(len >> 8); + } + return pnVar1; +} + + + +void l2cap_chan_tx_give_credits(bt_l2cap_le_chan *chan,u16_t credits) + +{ + anon_subr_void_bt_l2cap_chan_ptr_atomic_t_ptr_for_status *UNRECOVERED_JUMPTABLE; + atomic_t *target; + uint uVar1; + + while (credits = credits - 1, credits != 0xffff) { + k_sem_give(&(chan->tx).credits); + } + target = (chan->chan).status; + uVar1 = atomic_or(target,1); + if ((uVar1 & 1) != 0) { + UNRECOVERED_JUMPTABLE = ((chan->chan).ops)->status; + if (UNRECOVERED_JUMPTABLE != (anon_subr_void_bt_l2cap_chan_ptr_atomic_t_ptr_for_status *)0x0) { + // WARNING: Could not recover jumptable at 0x2301f83a. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)((bt_l2cap_chan *)chan,target); + return; + } + } + return; +} + + + +void l2cap_disconnected(void) + +{ + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void bt_l2cap_chan_remove(bt_conn *conn,bt_l2cap_chan *ch) + +{ + sys_snode_t prev_node; + sys_snode_t node; + sys_snode_t sVar1; + + node = (sys_snode_t)(conn->channels).head; + if (node != (sys_snode_t)0x0) { + prev_node = (sys_snode_t)0x0; + do { + if (node == (sys_snode_t)&DAT_00000008) { + return; + } + if ((bt_l2cap_chan *)((int)node + -8) == ch) { + sys_slist_remove(&conn->channels,(sys_snode_t *)prev_node,(sys_snode_t *)node); + return; + } + sVar1 = *(sys_snode_t *)node; + prev_node = node; + node = sVar1; + } while (sVar1 != (sys_snode_t)0x0); + } + return; +} + + + +void bt_l2cap_chan_del(bt_l2cap_chan *chan) + +{ + anon_subr_void_bt_l2cap_chan_ptr_for_disconnected *paVar1; + + if (chan->conn != (bt_conn *)0x0) { + paVar1 = chan->ops->disconnected; + if (paVar1 != (anon_subr_void_bt_l2cap_chan_ptr_for_disconnected *)0x0) { + (*paVar1)(chan); + } + chan->conn = (bt_conn *)0x0; + } + chan->state = BT_L2CAP_DISCONNECTED; + chan->psm = 0; + if (chan->destroy != (bt_l2cap_chan_destroy_t *)0x0) { + (*chan->destroy)(chan); + } + if ((chan->rtx_work).timer.timer.hdl != (void *)0x0) { + k_delayed_work_del_timer(&chan->rtx_work); + return; + } + return; +} + + + +void l2cap_rtx_timeout(k_work *work) + +{ + bt_l2cap_chan *ch; + + ch = (bt_l2cap_chan *)work[-2].flags; + printf("chan %p timeout\r\n",ch); + bt_l2cap_chan_remove((bt_conn *)work[-2].flags[0],ch); + bt_l2cap_chan_del(ch); + return; +} + + + +void bt_l2cap_disconnected(bt_conn *conn) + +{ + bt_l2cap_chan *pbVar1; + bt_l2cap_chan *pbVar2; + bt_l2cap_chan *chan; + sys_snode_t *psVar3; + + psVar3 = (conn->channels).head; + if ((psVar3 != (sys_snode_t *)0x0) && + (chan = (bt_l2cap_chan *)(psVar3 + -2), chan != (bt_l2cap_chan *)0x0)) { + pbVar1 = (bt_l2cap_chan *)psVar3->next; + if (pbVar1 != (bt_l2cap_chan *)0x0) { + pbVar1 = (bt_l2cap_chan *)&pbVar1[-1].state; + } + while (pbVar2 = pbVar1, bt_l2cap_chan_del(chan), pbVar2 != (bt_l2cap_chan *)0x0) { + pbVar1 = (bt_l2cap_chan *)(pbVar2->node).next; + chan = pbVar2; + if (pbVar1 != (bt_l2cap_chan *)0x0) { + pbVar1 = (bt_l2cap_chan *)&pbVar1[-1].state; + } + } + return; + } + return; +} + + + +net_buf * bt_l2cap_create_pdu_timeout(net_buf_pool *pool,size_t reserve,s32_t timeout) + +{ + net_buf *pnVar1; + + pnVar1 = bt_conn_create_pdu_timeout(pool,reserve + 4,timeout); + return pnVar1; +} + + + +int bt_l2cap_send_cb(bt_conn *conn,u16_t cid,net_buf *buf,bt_conn_tx_cb_t *cb,void *user_data) + +{ + ushort uVar1; + undefined *puVar2; + int iVar3; + + puVar2 = (undefined *)net_buf_simple_push((net_buf_simple *)&buf->field_4,4); + uVar1 = *(ushort *)((int)&buf->field_4 + 4); + puVar2[2] = (char)cid; + iVar3 = (uint)uVar1 - 4; + *puVar2 = (char)((uint)(iVar3 * 0x10000) >> 0x10); + puVar2[1] = (char)((uint)iVar3 >> 8); + puVar2[3] = (char)(cid >> 8); + iVar3 = bt_conn_send_cb(conn,buf,cb,user_data); + return iVar3; +} + + + +void bt_l2cap_send(bt_conn *conn,u16_t cid,net_buf *buf) + +{ + bt_l2cap_send_cb(conn,cid,buf,(bt_conn_tx_cb_t *)0x0,(void *)0x0); + return; +} + + + +void l2cap_chan_send_credits(bt_l2cap_le_chan *chan,u16_t credits) + +{ + u16_t uVar1; + uint uVar2; + uint uVar3; + u8_t ident; + net_buf *buf; + undefined *puVar4; + undefined2 in_register_0000202e; + + uVar2 = (uint)(chan->rx).init_credits; + if (CONCAT22(in_register_0000202e,credits) < uVar2) { + uVar2 = CONCAT22(in_register_0000202e,credits); + } + uVar3 = uVar2 & 0xffff; + while (uVar3 = uVar3 - 1 & 0xffff, uVar3 != 0xffff) { + k_sem_give(&(chan->rx).credits); + } + ident = get_ident(); + buf = l2cap_create_le_sig_pdu('\x16',ident,4); + if (buf != (net_buf *)0x0) { + puVar4 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,4); + uVar1 = (chan->rx).cid; + puVar4[2] = (char)uVar2; + *puVar4 = (char)uVar1; + puVar4[1] = (char)(uVar1 >> 8); + puVar4[3] = (char)((uVar2 & 0xffff) >> 8); + bt_l2cap_send((chan->chan).conn,5,buf); + return; + } + return; +} + + + +int l2cap_le_conn_req(bt_l2cap_le_chan *ch) + +{ + u16_t uVar1; + u8_t ident; + net_buf *buf; + undefined *puVar2; + int iVar3; + + ident = get_ident(); + (ch->chan).ident = ident; + buf = l2cap_create_le_sig_pdu('\x14',ident,10); + if (buf == (net_buf *)0x0) { + iVar3 = -0xc; + } + else { + puVar2 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,10); + uVar1 = (ch->chan).psm; + *puVar2 = (char)uVar1; + puVar2[1] = (char)(uVar1 >> 8); + uVar1 = (ch->rx).cid; + puVar2[2] = (char)uVar1; + puVar2[3] = (char)(uVar1 >> 8); + uVar1 = (ch->rx).mtu; + puVar2[4] = (char)uVar1; + puVar2[5] = (char)(uVar1 >> 8); + uVar1 = (ch->rx).mps; + puVar2[6] = (char)uVar1; + puVar2[7] = (char)(uVar1 >> 8); + uVar1 = (ch->rx).init_credits; + puVar2[8] = (char)uVar1; + puVar2[9] = (char)(uVar1 >> 8); + k_delayed_work_submit(&(ch->chan).rtx_work,40000); + bt_l2cap_send((ch->chan).conn,5,buf); + iVar3 = 0; + } + return iVar3; +} + + + +// WARNING: Type propagation algorithm not settling + +void bt_l2cap_encrypt_change(bt_conn *conn,u8_t hci_status) + +{ + bt_l2cap_le_chan *ch; + undefined3 in_register_0000202d; + int *piVar1; + + piVar1 = (int *)(conn->channels).head; + if (piVar1 == (int *)0x0) { + return; + } + do { + ch = (bt_l2cap_le_chan *)(piVar1 + 0xfffffffe); + if (ch == (bt_l2cap_le_chan *)0x0) { + return; + } + if ((*(char *)(piVar1 + 0xc) == '\x01') && (*(char *)(piVar1 + 0xd) == '\0')) { + if (CONCAT31(in_register_0000202d,hci_status) == 0) { + l2cap_le_conn_req(ch); + } + else { + bt_l2cap_chan_remove((ch->chan).conn,(bt_l2cap_chan *)ch); + bt_l2cap_chan_del((bt_l2cap_chan *)ch); + } + } + if (*(code **)(piVar1[0xffffffff] + 8) != (code *)0x0) { + (**(code **)(piVar1[0xffffffff] + 8))(ch,CONCAT31(in_register_0000202d,hci_status)); + } + piVar1 = (int *)*piVar1; + } while (piVar1 != (int *)0x0); + return; +} + + + +void l2cap_send_reject(bt_conn *conn,u8_t ident,u16_t reason,void *data,u8_t data_len) + +{ + net_buf *buf; + undefined *puVar1; + undefined3 in_register_00002039; + + buf = l2cap_create_le_sig_pdu('\x01',ident,(short)CONCAT31(in_register_00002039,data_len) + 2); + if (buf != (net_buf *)0x0) { + puVar1 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + *puVar1 = (char)reason; + puVar1[1] = (char)(reason >> 8); + if (data != (void *)0x0) { + net_buf_simple_add_mem + ((net_buf_simple *)&buf->field_4,data,CONCAT31(in_register_00002039,data_len)); + } + bt_l2cap_send(conn,5,buf); + return; + } + return; +} + + + +int l2cap_chan_le_send(bt_l2cap_le_chan *ch,net_buf *buf,u16_t sdu_hdr_len) + +{ + u16_t cid; + atomic_t *target; + int iVar1; + size_t sVar2; + net_buf *buf_00; + net_buf_pool *pool; + bt_conn *conn; + uint uVar3; + uint len; + undefined2 in_register_00002032; + anon_subr_void_bt_l2cap_chan_ptr_atomic_t_ptr_for_status *paVar4; + int iVar5; + net_buf_simple *buf_01; + k_sem *sem; + + iVar5 = CONCAT22(in_register_00002032,sdu_hdr_len); + sem = &(ch->tx).credits; + iVar1 = k_sem_take(sem,0); + if (iVar1 != 0) { + return -0xb; + } + if ((uint)*(ushort *)((int)&buf->field_4 + 4) + iVar5 <= (uint)(ch->tx).mps) { + sVar2 = net_buf_simple_headroom((net_buf_simple *)&buf->field_4); + if (((iVar5 + 9U & 0xffff) <= sVar2) && (buf->field_0 == 0)) { + if (iVar5 != 0) { + sVar2 = net_buf_frags_len(buf); + net_buf_simple_push_le16((net_buf_simple *)&buf->field_4,(u16_t)sVar2); + } + buf_00 = net_buf_ref(buf); + if (buf_00 == (net_buf *)0x0) { + return -0xc; + } + goto LAB_2301fc88; + } + } + pool = net_buf_pool_get((uint)buf->pool_id); + buf_00 = net_buf_alloc_fixed(pool,0); + if (buf_00 == (net_buf *)0x0) { + buf_00 = bt_conn_create_pdu_timeout((net_buf_pool *)0x0,4,-1); + if (buf_00 == (net_buf *)0x0) { + return -0xc; + } + } + else { + net_buf_simple_reserve((net_buf_simple *)&buf_00->field_4,9); + } + buf_01 = (net_buf_simple *)&buf_00->field_4; + if (iVar5 != 0) { + sVar2 = net_buf_frags_len(buf); + net_buf_simple_add_le16(buf_01,(u16_t)sVar2); + } + sVar2 = net_buf_simple_tailroom(buf_01); + uVar3 = (uint)(ch->tx).mps - iVar5; + if (sVar2 < uVar3) { + uVar3 = net_buf_simple_tailroom(buf_01); + } + len = (uint)*(ushort *)((int)&buf->field_4 + 4); + if ((uVar3 & 0xffff) < len) { + len = uVar3 & 0xffff; + } + net_buf_simple_add_mem(buf_01,*(void **)&buf->field_4,len); + net_buf_simple_pull((net_buf_simple *)&buf->field_4,len); +LAB_2301fc88: + conn = (ch->chan).conn; + if (conn == (bt_conn *)0x0) { + net_buf_unref(buf); + iVar5 = -0x36; + } + else { + cid = (ch->tx).cid; + iVar5 = (uint)*(ushort *)((int)&buf_00->field_4 + 4) - iVar5; + if (((buf == buf_00) || (*(short *)((int)&buf->field_4 + 4) == 0)) && + (((ch->chan).ops)->sent != (anon_subr_void_bt_l2cap_chan_ptr_for_sent *)0x0)) { + bt_l2cap_send_cb(conn,cid,buf_00,l2cap_chan_sdu_sent,ch); + } + else { + bt_l2cap_send(conn,cid,buf_00); + } + uVar3 = k_sem_count_get(sem); + if (uVar3 == 0) { + target = (ch->chan).status; + atomic_and(target,-2); + paVar4 = ((ch->chan).ops)->status; + if (paVar4 != (anon_subr_void_bt_l2cap_chan_ptr_atomic_t_ptr_for_status *)0x0) { + (*paVar4)((bt_l2cap_chan *)ch,target); + } + } + } + return iVar5; +} + + + +int l2cap_chan_le_send_sdu(bt_l2cap_le_chan *param_1,net_buf **param_2,ushort param_3) + +{ + net_buf *buf; + int iVar1; + size_t sVar2; + uint uVar3; + ushort auStack34 [5]; + + buf = *param_2; + auStack34[0] = param_3; + sVar2 = net_buf_frags_len(buf); + uVar3 = (uint)auStack34[0]; + iVar1 = -0x24; + if ((int)(uVar3 + sVar2) <= (int)(uint)(param_1->tx).mtu) { + if ((*(short *)((int)&buf->field_4 + 4) == 0) && ((net_buf *)buf->field_0 != (net_buf *)0x0)) { + buf = (net_buf *)buf->field_0; + } + if (auStack34[0] == 0) { + iVar1 = l2cap_chan_le_send(param_1,buf,2); + if (iVar1 < 0) { +LAB_2301fd60: + if (iVar1 == -0xb) { + memcpy(buf->user_data,auStack34,2); + } + *param_2 = buf; + return iVar1; + } + auStack34[0] = (ushort)iVar1; + } + iVar1 = 0; + while ((int)(uint)auStack34[0] < (int)(uVar3 + sVar2)) { + if (*(short *)((int)&buf->field_4 + 4) == 0) { + buf = net_buf_frag_del((net_buf *)0x0,buf); + } + iVar1 = l2cap_chan_le_send(param_1,buf,0); + if (iVar1 < 0) goto LAB_2301fd60; + auStack34[0] = auStack34[0] + (short)iVar1; + } + net_buf_unref(buf); + } + return iVar1; +} + + + +bt_l2cap_chan * bt_l2cap_le_lookup_tx_cid(bt_conn *conn,u16_t cid) + +{ + bt_conn *pbVar1; + bt_conn *pbVar2; + undefined2 in_register_0000202e; + + pbVar2 = (bt_conn *)(conn->channels).head; + while (((pbVar1 = pbVar2, pbVar2 != (bt_conn *)0x0 && + (pbVar1 = (bt_conn *)&(&pbVar2[-1].update_work)[2].work.handler, pbVar1 != (bt_conn *)0x0) + ) && ((uint)*(ushort *)&(&pbVar2->channels)[1].tail != CONCAT22(in_register_0000202e,cid)) + )) { + pbVar2 = *(bt_conn **)&pbVar2->handle; + } + return (bt_l2cap_chan *)pbVar1; +} + + + +bt_l2cap_chan * bt_l2cap_le_lookup_rx_cid(bt_conn *conn,u16_t cid) + +{ + bt_conn *pbVar1; + bt_conn *pbVar2; + undefined2 in_register_0000202e; + + pbVar2 = (bt_conn *)(conn->channels).head; + while (((pbVar1 = pbVar2, pbVar2 != (bt_conn *)0x0 && + (pbVar1 = (bt_conn *)&(&pbVar2[-1].update_work)[2].work.handler, pbVar1 != (bt_conn *)0x0) + ) && ((uint)*(ushort *)&pbVar2->tx_queue != CONCAT22(in_register_0000202e,cid)))) { + pbVar2 = *(bt_conn **)&pbVar2->handle; + } + return (bt_l2cap_chan *)pbVar1; +} + + + +_Bool l2cap_chan_add(bt_conn *conn,bt_l2cap_chan *chan,bt_l2cap_chan_destroy_t *destroy) + +{ + short sVar1; + undefined uVar2; + u16_t cid; + bt_l2cap_chan *pbVar3; + sys_snode_t *psVar4; + _snode *p_Var5; + + if ((chan == (bt_l2cap_chan *)0x0) || (*(short *)&chan[1].conn == 0)) { + cid = 0x40; + do { + if (chan != (bt_l2cap_chan *)0x0) { + pbVar3 = bt_l2cap_le_lookup_rx_cid(conn,cid); + if (pbVar3 == (bt_l2cap_chan *)0x0) { + *(u16_t *)&chan[1].conn = cid; + goto LAB_2301fe2c; + } + } + cid = cid + 1; + } while (cid != 0x80); + printf("Unable to allocate L2CAP CID\r\n"); + uVar2 = 0; + } + else { +LAB_2301fe2c: + k_delayed_work_init(&chan->rtx_work,l2cap_rtx_timeout); + (chan->node).next = (_snode *)0x0; + psVar4 = (conn->channels).tail; + p_Var5 = (_snode *)&chan->node; + if (psVar4 == (sys_snode_t *)0x0) { + *(_snode **)&(conn->channels).tail = p_Var5; + *(_snode **)&(conn->channels).head = p_Var5; + } + else { + psVar4->next = p_Var5; + *(_snode **)&(conn->channels).tail = p_Var5; + } + sVar1 = *(short *)&chan[1].conn; + chan->conn = conn; + *(bt_l2cap_chan_destroy_t **)&chan->destroy = destroy; + uVar2 = 1; + if ((ushort)(sVar1 - 0x40U) < 0x40) { + k_work_init((k_work *)(chan + 2),l2cap_rx_process); + k_queue_init((k_queue *)&chan[2].destroy,0x14); + chan->state = BT_L2CAP_CONNECT; + } + } + return (_Bool)uVar2; +} + + + +// WARNING: Variable defined which should be unmapped: chan + +void bt_l2cap_connected(bt_conn *conn) + +{ + undefined2 uVar1; + bt_l2cap_fixed_chan *pbVar2; + _Bool _Var3; + int iVar4; + undefined3 extraout_var; + code *pcVar5; + anon_subr_void_bt_l2cap_chan_ptr_for_connected *paVar6; + anon_subr_void_bt_l2cap_chan_ptr_atomic_t_ptr_for_status *paVar7; + bt_l2cap_chan *local_14; + bt_l2cap_chan *chan; + + pbVar2 = &att_fixed_chan; + do { + if (&boot2_partition_table <= pbVar2) { + return; + } + pcVar5 = (code *)(((anon_struct_conflict1 *)pbVar2)->table).ptTable.magicCode; + iVar4 = (*pcVar5)(conn,&local_14,pcVar5); + if (-1 < iVar4) { + uVar1 = *(undefined2 *)pbVar2; + *(undefined2 *)&local_14[1].conn = uVar1; + *(undefined2 *)&local_14[1].rtx_work.work.handler = uVar1; + _Var3 = l2cap_chan_add(conn,local_14,(bt_l2cap_chan_destroy_t *)0x0); + if (CONCAT31(extraout_var,_Var3) == 0) { + return; + } + paVar6 = local_14->ops->connected; + if (paVar6 != (anon_subr_void_bt_l2cap_chan_ptr_for_connected *)0x0) { + (*paVar6)(local_14); + } + atomic_or(local_14->status,1); + paVar7 = local_14->ops->status; + if (paVar7 != (anon_subr_void_bt_l2cap_chan_ptr_atomic_t_ptr_for_status *)0x0) { + (*paVar7)(local_14,local_14->status); + } + } + pbVar2 = (bt_l2cap_fixed_chan *)&(((anon_struct_conflict1 *)pbVar2)->table).ptTable.age; + } while( true ); +} + + + +void bt_l2cap_recv(bt_conn *conn,net_buf *buf) + +{ + ushort cid; + void *pvVar1; + bt_l2cap_chan *pbVar2; + net_buf *buf_00; + + if (*(ushort *)((int)&buf->field_4 + 4) < 4) { + printf("Too small L2CAP PDU received\r\n"); + } + else { + pvVar1 = net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,4); + cid = *(ushort *)((int)pvVar1 + 2); + pbVar2 = bt_l2cap_le_lookup_rx_cid(conn,cid); + if (pbVar2 == (bt_l2cap_chan *)0x0) { + printf("Ignoring data for unknown CID 0x%04x\r\n",(uint)cid); + } + else { + if ((ushort)(*(short *)&pbVar2[1].conn - 0x40U) < 0x40) { + buf_00 = net_buf_ref(buf); + net_buf_put((k_fifo *)&pbVar2[2].destroy,buf_00); + k_work_submit((k_work *)(pbVar2 + 2)); + return; + } + (*pbVar2->ops->recv)(pbVar2,buf); + } + } + net_buf_unref(buf); + return; +} + + + +int bt_l2cap_update_conn_param(bt_conn *conn,bt_le_conn_param *param) + +{ + u16_t uVar1; + u8_t ident; + net_buf *buf; + undefined *puVar2; + int iVar3; + + ident = get_ident(); + buf = l2cap_create_le_sig_pdu('\x12',ident,8); + if (buf == (net_buf *)0x0) { + iVar3 = -0xc; + } + else { + puVar2 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,8); + uVar1 = param->interval_min; + *puVar2 = (char)uVar1; + puVar2[1] = (char)(uVar1 >> 8); + uVar1 = param->interval_max; + puVar2[2] = (char)uVar1; + puVar2[3] = (char)(uVar1 >> 8); + uVar1 = param->latency; + puVar2[4] = (char)uVar1; + puVar2[5] = (char)(uVar1 >> 8); + uVar1 = param->timeout; + puVar2[6] = (char)uVar1; + puVar2[7] = (char)(uVar1 >> 8); + bt_l2cap_send(conn,5,buf); + iVar3 = 0; + } + return iVar3; +} + + + +void bt_l2cap_init(void) + +{ + return; +} + + + +int bt_l2cap_chan_disconnect(bt_l2cap_chan *chan) + +{ + undefined2 uVar1; + u8_t ident; + net_buf *buf; + int iVar2; + undefined *puVar3; + + if (chan->conn != (bt_conn *)0x0) { + ident = get_ident(); + chan->ident = ident; + buf = l2cap_create_le_sig_pdu('\x06',ident,4); + iVar2 = -0xc; + if (buf != (net_buf *)0x0) { + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,4); + uVar1 = *(undefined2 *)&chan[1].conn; + *puVar3 = (char)uVar1; + puVar3[1] = (char)((ushort)uVar1 >> 8); + uVar1 = *(undefined2 *)&chan[1].rtx_work.work.handler; + puVar3[2] = (char)uVar1; + puVar3[3] = (char)((ushort)uVar1 >> 8); + k_delayed_work_submit(&chan->rtx_work,2000); + bt_l2cap_send(chan->conn,5,buf); + chan->state = BT_L2CAP_DISCONNECT; + iVar2 = 0; + } + return iVar2; + } + return -0x39; +} + + + +void l2cap_chan_le_recv_seg(bt_l2cap_le_chan *param_1,net_buf *param_2) + +{ + ushort uVar1; + u16_t credits; + size_t sVar2; + char *fmt; + uint uVar3; + int iVar4; + uint uVar5; + bt_l2cap_chan_ops *pbVar6; + net_buf *buf; + k_sem *sem; + u16_t auStack34 [7]; + + buf = param_1->_sdu; + auStack34[0] = 0; + sVar2 = net_buf_frags_len(buf); + if ((sVar2 & 0xffff) != 0) { + memcpy(auStack34,buf->user_data,2); + } + if ((uint)param_1->_sdu_len < (sVar2 & 0xffff) + (uint)*(ushort *)((int)¶m_2->field_4 + 4)) { + fmt = "SDU length mismatch\r\n"; + } + else { + auStack34[0] = auStack34[0] + 1; + memcpy(param_1->_sdu->user_data,auStack34,2); + sVar2 = net_buf_append_bytes + (param_1->_sdu,(uint)*(ushort *)((int)¶m_2->field_4 + 4), + *(void **)¶m_2->field_4,0,l2cap_alloc_frag,param_1); + if ((uint)*(ushort *)((int)¶m_2->field_4 + 4) == (sVar2 & 0xffff)) { + buf = param_1->_sdu; + sVar2 = net_buf_frags_len(buf); + credits = auStack34[0]; + if (param_1->_sdu_len <= sVar2) { + pbVar6 = (param_1->chan).ops; + param_1->_sdu = (net_buf *)0x0; + param_1->_sdu_len = 0; + iVar4 = (*pbVar6->recv)((bt_l2cap_chan *)param_1,buf); + if (iVar4 < 0) { + if (iVar4 == -0x44) { + return; + } + printf("err %d\r\n"); + bt_l2cap_chan_disconnect((bt_l2cap_chan *)param_1); + } + else { + l2cap_chan_send_credits(param_1,credits); + } + net_buf_unref(buf); + return; + } + sem = &(param_1->rx).credits; + uVar3 = k_sem_count_get(sem); + if (uVar3 != 0) { + return; + } + if ((param_1->rx).init_credits != auStack34[0]) { + return; + } + sVar2 = net_buf_frags_len(param_2); + uVar5 = (uint)(param_1->rx).mps; + uVar1 = param_1->_sdu_len; + uVar3 = k_sem_count_get(sem); + iVar4 = ((uVar1 + uVar5 + -1) - sVar2) / uVar5 - uVar3; + if ((short)iVar4 < 1) { + return; + } + l2cap_chan_send_credits(param_1,(u16_t)((uint)(iVar4 * 0x10000) >> 0x10)); + return; + } + fmt = "Unable to store SDU\r\n"; + } + printf(fmt); + bt_l2cap_chan_disconnect((bt_l2cap_chan *)param_1); + return; +} + + + +void l2cap_rx_process(k_work *work) + +{ + bt_l2cap_le_chan *chan; + u16_t uVar1; + net_buf *buf; + int iVar2; + char *fmt; + undefined2 extraout_var; + k_work_handler_t *pkVar3; + code *pcVar4; + + chan = (bt_l2cap_le_chan *)&work[-0xb].handler; + do { + buf = net_buf_get((k_fifo *)(work + 1),0); + if (buf == (net_buf *)0x0) { + return; + } + iVar2 = k_sem_take((k_sem *)&work[-5].handler,0); + if (iVar2 != 0) { + fmt = "No credits to receive packet\r\n"; + goto LAB_230202a0; + } + if (work[-1].handler != (k_work_handler_t *)0x0) { +LAB_230202b8: + l2cap_chan_le_recv_seg(chan,buf); + goto LAB_230202aa; + } + uVar1 = net_buf_simple_pull_le16((net_buf_simple *)&buf->field_4); + fmt = "Invalid SDU length\r\n"; + if ((uint)*(ushort *)((int)work[-6].flags + 2) < CONCAT22(extraout_var,uVar1)) { +LAB_230202a0: + printf(fmt); +LAB_230202a4: + bt_l2cap_chan_disconnect((bt_l2cap_chan *)chan); + } + else { + pcVar4 = *(code **)(work[-0xb].flags[0] + 0xc); + if (pcVar4 != (code *)0x0) { + pkVar3 = (k_work_handler_t *)(*pcVar4)(chan); + work[-1].handler = pkVar3; + if (pkVar3 != (k_work_handler_t *)0x0) { + *(u16_t *)work[-1].flags = uVar1; + goto LAB_230202b8; + } + fmt = "Unable to allocate buffer for SDU\r\n"; + goto LAB_230202a0; + } + pcVar4 = *(code **)(work[-0xb].flags[0] + 0x10); + iVar2 = (*pcVar4)(chan,buf,pcVar4); + if (iVar2 != 0) { + if (iVar2 == -0x44) goto LAB_230202aa; + printf("err %d\r\n",iVar2); + goto LAB_230202a4; + } + l2cap_chan_send_credits(chan,1); + } +LAB_230202aa: + net_buf_unref(buf); + } while( true ); +} + + + +// WARNING: Could not reconcile some variable overlaps + +int l2cap_recv(bt_l2cap_chan *chan_1,net_buf *buf) + +{ + ushort credits; + u16_t cid; + u16_t credits_00; + u16_t credits_01; + ushort uVar1; + u16_t *__s; + _Bool remove; + char *fmt; + byte *pbVar2; + net_buf *buf_00; + bt_l2cap_server *pbVar3; + undefined3 extraout_var; + bt_l2cap_le_chan *chan_00; + uint uVar4; + bt_l2cap_le_chan *pbVar5; + int iVar6; + undefined3 extraout_var_00; + bt_conn *conn; + byte ident; + undefined *data; + u8_t data_len; + int iVar7; + bt_security_t bVar8; + u16_t psm; + bt_l2cap_chan_ops *pbVar9; + anon_subr_void_bt_l2cap_chan_ptr_for_connected *paVar10; + bt_l2cap_chan **ppbVar11; + bt_l2cap_le_chan *local_38; + bt_l2cap_chan *chan; + + if (*(ushort *)((int)&buf->field_4 + 4) < 4) { + fmt = "Too small L2CAP signaling PDU\r\n"; + goto LAB_23020344; + } + pbVar2 = (byte *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,4); + credits = *(ushort *)((int)&buf->field_4 + 4); + if ((uint)*(ushort *)(pbVar2 + 2) != (uint)credits) { + printf("L2CAP length mismatch (%u != %u)\r\n",(uint)credits); + return 0; + } + ident = pbVar2[1]; + if (ident == 0) { + fmt = "Invalid ident value in L2CAP PDU\r\n"; + goto LAB_23020344; + } + switch((uint)*pbVar2 - 1 & 0xff) { + case 0: + chan_00 = __l2cap_lookup_ident(chan_1->conn,(ushort)ident,true); + break; + default: + printf("Unknown L2CAP PDU code 0x%02x\r\n"); + data_len = '\0'; + data = (undefined *)0x0; + psm = 0; + ident = pbVar2[1]; + conn = chan_1->conn; + goto LAB_230206e8; + case 5: + if (3 < credits) { + __s = *(u16_t **)&buf->field_4; + conn = chan_1->conn; + chan_00 = l2cap_remove_rx_cid(conn,*__s); + if (chan_00 != (bt_l2cap_le_chan *)0x0) { + buf_00 = l2cap_create_le_sig_pdu('\a',ident,4); + if (buf_00 == (net_buf *)0x0) { + return 0; + } + data = (undefined *)net_buf_simple_add((net_buf_simple *)&buf_00->field_4,4); + psm = (chan_00->rx).cid; + *data = (char)psm; + data[1] = (char)(psm >> 8); + psm = (chan_00->tx).cid; + data[2] = (char)psm; + data[3] = (char)(psm >> 8); + bt_l2cap_chan_del((bt_l2cap_chan *)chan_00); + goto LAB_230204a2; + } + data = &local_38; + psm = 2; + local_38 = (bt_l2cap_le_chan *)CONCAT22(*__s,__s[1]); + data_len = '\x04'; + goto LAB_230206e8; + } + goto LAB_230203e0; + case 6: + if (credits < 4) { + fmt = "Too small LE disconn rsp packet size\r\n"; + goto LAB_23020344; + } + chan_00 = l2cap_remove_rx_cid(chan_1->conn,*(u16_t *)(*(int *)&buf->field_4 + 2)); + break; + case 0x11: + if (credits < 8) { + fmt = "Too small LE conn update param req\r\n"; + goto LAB_23020344; + } + conn = chan_1->conn; + if (conn->role == '\0') { + ppbVar11 = *(bt_l2cap_chan ***)&buf->field_4; + local_38 = (bt_l2cap_le_chan *)*ppbVar11; + chan._0_2_ = *(u16_t *)(ppbVar11 + 1); + chan._2_2_ = *(u16_t *)((int)ppbVar11 + 6); + buf_00 = l2cap_create_le_sig_pdu('\x13',ident,2); + if (buf_00 == (net_buf *)0x0) { + return 0; + } + remove = le_param_req(conn,(bt_le_conn_param *)&local_38); + pbVar2 = (byte *)net_buf_simple_add((net_buf_simple *)&buf_00->field_4,2); + *pbVar2 = remove ^ 1; + pbVar2[1] = 0; + bt_l2cap_send(conn,5,buf_00); + if (CONCAT31(extraout_var_00,remove) == 0) { + return 0; + } + bt_conn_le_conn_update(conn,(bt_le_conn_param *)&local_38); + return 0; + } + data_len = '\0'; + data = (undefined *)0x0; + psm = 0; +LAB_230206e8: + l2cap_send_reject(conn,ident,psm,data,data_len); + return 0; + case 0x12: + if (1 < credits) { + return 0; + } + fmt = "Too small LE conn param rsp\r\n"; + goto LAB_23020344; + case 0x13: + if (9 < credits) { + __s = *(u16_t **)&buf->field_4; + credits = __s[2]; + if ((credits < 0x17) || (uVar1 = __s[3], uVar1 < 0x17)) { + fmt = "Invalid LE-Conn Req params\r\n"; + goto LAB_23020344; + } + psm = *__s; + conn = chan_1->conn; + cid = __s[1]; + credits_00 = __s[4]; + buf_00 = l2cap_create_le_sig_pdu('\x15',ident,10); + if (buf_00 == (net_buf *)0x0) { + return 0; + } + __s = (u16_t *)net_buf_simple_add((net_buf_simple *)&buf_00->field_4,10); + memset(__s,0,10); + pbVar3 = l2cap_server_lookup_psm(psm); + psm = 2; + if (pbVar3 != (bt_l2cap_server *)0x0) { + if ((byte)conn->sec_level < (byte)pbVar3->sec_level) { + psm = 5; + } + else { + if (0x3f < (ushort)(cid - 0x40)) { + __s[4] = 9; + goto LAB_230204a2; + } + local_38 = (bt_l2cap_le_chan *)bt_l2cap_le_lookup_tx_cid(conn,cid); + psm = 10; + if (local_38 == (bt_l2cap_le_chan *)0x0) { + iVar6 = (*pbVar3->accept)(conn,(bt_l2cap_chan **)&local_38); + if (iVar6 < 0) { + psm = 6; + if (iVar6 != -0xd) { + if (iVar6 < -0xc) { + iVar7 = -0x23; + psm = 2; + } + else { + psm = 4; + if (iVar6 == -0xc) goto LAB_23020482; + iVar7 = -1; + psm = 7; + } + if (iVar6 != iVar7) { + psm = 0xb; + } + } + } + else { + (local_38->chan).required_sec_level = pbVar3->sec_level; + remove = l2cap_chan_add(conn,(bt_l2cap_chan *)local_38,l2cap_chan_destroy); + chan_00 = local_38; + psm = 4; + if (CONCAT31(extraout_var,remove) != 0) { + l2cap_chan_tx_init(local_38); + (chan_00->tx).cid = cid; + (chan_00->tx).mtu = credits; + (chan_00->tx).init_credits = credits_00; + (chan_00->tx).mps = uVar1; + l2cap_chan_tx_give_credits(chan_00,credits_00); + l2cap_chan_rx_init(chan_00); + psm = (chan_00->rx).init_credits; + while (psm = psm - 1, psm != 0xffff) { + k_sem_give(&(chan_00->rx).credits); + } + (local_38->chan).psm = pbVar3->psm; + (local_38->chan).state = BT_L2CAP_CONNECTED; + paVar10 = ((local_38->chan).ops)->connected; + if (paVar10 != (anon_subr_void_bt_l2cap_chan_ptr_for_connected *)0x0) { + (*paVar10)((bt_l2cap_chan *)local_38); + } + *__s = (chan_00->rx).cid; + __s[2] = (chan_00->rx).mps; + __s[1] = (chan_00->rx).mtu; + psm = (chan_00->rx).init_credits; + __s[4] = 0; + __s[3] = psm; + goto LAB_230204a2; + } + } + } + } + } +LAB_23020482: + __s[4] = psm; +LAB_230204a2: + bt_l2cap_send(conn,5,buf_00); + return 0; + } +LAB_230203e0: + fmt = "Too small LE conn req packet size\r\n"; +LAB_23020344: + printf(fmt); + return 0; + case 0x14: + if (credits < 10) { + fmt = "Too small LE conn rsp packet size\r\n"; + goto LAB_23020344; + } + __s = *(u16_t **)&buf->field_4; + conn = chan_1->conn; + credits = __s[4]; + psm = *__s; + cid = __s[1]; + credits_00 = __s[2]; + credits_01 = __s[3]; + if (((credits & 0xfff7) == 0) || (remove = true, credits == 5)) { + remove = false; + } + chan_00 = __l2cap_lookup_ident(conn,(ushort)ident,remove); + if (chan_00 == (bt_l2cap_le_chan *)0x0) { + printf("Cannot find channel for ident %u\r\n",(uint)ident); + return 0; + } + k_delayed_work_cancel(&(chan_00->chan).rtx_work); + (chan_00->chan).ident = '\0'; + if ((credits != 5) && (credits != 8)) { + if (credits == 0) { + (chan_00->chan).state = BT_L2CAP_CONNECTED; + pbVar9 = (chan_00->chan).ops; + (chan_00->tx).cid = psm; + (chan_00->tx).mtu = cid; + (chan_00->tx).mps = credits_00; + paVar10 = pbVar9->connected; + if (paVar10 != (anon_subr_void_bt_l2cap_chan_ptr_for_connected *)0x0) { + (*paVar10)((bt_l2cap_chan *)chan_00); + } + l2cap_chan_tx_give_credits(chan_00,credits_01); + psm = (chan_00->rx).init_credits; + while (psm = psm - 1, psm != 0xffff) { + k_sem_give(&(chan_00->rx).credits); + } + return 0; + } + goto LAB_23020678; + } + if (credits == 5) { + ident = (chan_00->chan).required_sec_level; + if (ident < 2) goto LAB_2302065a; + if (ident == 2) { + bVar8 = BT_SECURITY_L3; + } + else { + if (ident != 3) goto LAB_2302066e; + bVar8 = BT_SECURITY_L4; + } +LAB_2302065c: + (chan_00->chan).required_sec_level = bVar8; + iVar6 = bt_conn_set_security((chan_00->chan).conn,(chan_00->chan).required_sec_level); + if (iVar6 == 0) { + return 0; + } + } + else { + if ((credits == 8) && ((byte)(chan_00->chan).required_sec_level < 2)) { +LAB_2302065a: + bVar8 = BT_SECURITY_MEDIUM; + goto LAB_2302065c; + } + } +LAB_2302066e: + bt_l2cap_chan_remove(conn,(bt_l2cap_chan *)chan_00); + goto LAB_23020678; + case 0x15: + if (credits < 4) { + fmt = "Too small LE Credits packet size\r\n"; + } + else { + __s = *(u16_t **)&buf->field_4; + chan_00 = (bt_l2cap_le_chan *)bt_l2cap_le_lookup_tx_cid(chan_1->conn,*__s); + if (chan_00 != (bt_l2cap_le_chan *)0x0) { + credits = __s[1]; + uVar4 = k_sem_count_get(&(chan_00->tx).credits); + if (0xffff < uVar4 + credits) { + printf("Credits overflow\r\n"); + bt_l2cap_chan_disconnect((bt_l2cap_chan *)chan_00); + return 0; + } + l2cap_chan_tx_give_credits(chan_00,credits); + while( true ) { + pbVar5 = (bt_l2cap_le_chan *)chan_00->tx_buf; + if (pbVar5 == (bt_l2cap_le_chan *)0x0) { + pbVar5 = (bt_l2cap_le_chan *)net_buf_get(&chan_00->tx_queue,0); + } + else { + chan_00->tx_buf = (net_buf *)0x0; + } + if (pbVar5 == (bt_l2cap_le_chan *)0x0) break; + local_38 = pbVar5; + iVar6 = l2cap_chan_le_send_sdu + (chan_00,&local_38, + (uint)*(ushort *)&(pbVar5->chan).rtx_work.work.handler); + if (iVar6 < 0) { + if (iVar6 != -0xb) { + return 0; + } + *(bt_l2cap_le_chan **)&chan_00->tx_buf = local_38; + return 0; + } + } + return 0; + } + fmt = "Unable to find channel of LE Credits packet\r\n"; + } + goto LAB_23020344; + } + if (chan_00 == (bt_l2cap_le_chan *)0x0) { + return 0; + } +LAB_23020678: + bt_l2cap_chan_del((bt_l2cap_chan *)chan_00); + return 0; +} + + + +void sys_memcpy_swap(void *dst,void *src,size_t length) + +{ + undefined *puVar1; + undefined *puVar2; + undefined *puVar3; + + puVar1 = (undefined *)dst; + puVar3 = (undefined *)((int)src + (length - 1)); + do { + puVar2 = puVar1 + 1; + *puVar1 = *puVar3; + puVar1 = puVar2; + puVar3 = puVar3 + -1; + } while ((undefined *)(length + (int)dst) != puVar2); + return; +} + + + +void sys_mem_swap(void *buf,size_t length) + +{ + undefined uVar1; + undefined *puVar2; + undefined *puVar3; + int iVar4; + + iVar4 = (int)buf + length; + puVar2 = (undefined *)buf; + do { + uVar1 = *puVar2; + puVar3 = puVar2 + 1; + *puVar2 = *(undefined *)(iVar4 + -1); + *(undefined *)(iVar4 + -1) = uVar1; + iVar4 = iVar4 + -1; + puVar2 = puVar3; + } while (puVar3 != (undefined *)((length >> 1) + (int)buf)); + return; +} + + + +u8_t get_io_capa(void) + +{ + u8_t uVar1; + anon_subr_void_bt_conn_ptr_uint_for_passkey_display *paVar2; + + uVar1 = '\x03'; + if (bt_auth != (bt_conn_auth_cb *)0x0) { + paVar2 = bt_auth->passkey_display; + if ((paVar2 == (anon_subr_void_bt_conn_ptr_uint_for_passkey_display *)0x0) || + (bt_auth->passkey_entry == (anon_subr_void_bt_conn_ptr_for_passkey_entry *)0x0)) { + if ((sc_supported != false) && + ((paVar2 != (anon_subr_void_bt_conn_ptr_uint_for_passkey_display *)0x0 && + (bt_auth->passkey_confirm != (anon_subr_void_bt_conn_ptr_uint_for_passkey_confirm *)0x0))) + ) { + return '\x01'; + } + } + else { + if (bt_auth->passkey_confirm != (anon_subr_void_bt_conn_ptr_uint_for_passkey_confirm *)0x0) { + return '\x04'; + } + if (sc_supported == false) { + return '\x04'; + } + } + uVar1 = '\x02'; + if ((bt_auth->passkey_entry == (anon_subr_void_bt_conn_ptr_for_passkey_entry *)0x0) && + (uVar1 = '\x03', paVar2 != (anon_subr_void_bt_conn_ptr_uint_for_passkey_display *)0x0)) { + uVar1 = '\0'; + } + } + return uVar1; +} + + + +bt_smp * smp_chan_get(bt_conn *conn) + +{ + bt_smp *pbVar1; + + pbVar1 = (bt_smp *)bt_l2cap_le_lookup_rx_cid(conn,6); + if (pbVar1 == (bt_smp *)0x0) { + printf("Unable to find SMP channel\r\n"); + } + return pbVar1; +} + + + +void atomic_set_bit(atomic_t *target,int bit) + +{ + atomic_or(target,1 << (bit & 0x1fU)); + return; +} + + + +int atomic_test_bit(atomic_t *target,int bit) + +{ + atomic_val_t aVar1; + + aVar1 = atomic_get(target); + return aVar1 >> (bit & 0x1fU) & 1; +} + + + +void smp_reset(bt_smp *smp) + +{ + bt_conn *pbVar1; + int bit; + + pbVar1 = (smp->chan).chan.conn; + k_delayed_work_cancel(&smp->work); + smp->method = '\0'; + atomic_set(&smp->allowed_cmds,0); + atomic_set(smp->flags,0); + if (pbVar1->required_sec_level != pbVar1->sec_level) { + pbVar1->required_sec_level = pbVar1->sec_level; + } + bit = 0xb; + if (pbVar1->role != '\0') { + bit = 1; + } + atomic_set_bit(&smp->allowed_cmds,bit); + return; +} + + + +void smp_pairing_complete(bt_smp *smp,u8_t status) + +{ + bool bVar1; + uint uVar2; + int iVar3; + undefined3 in_register_0000202d; + uint uVar4; + anon_subr_void_bt_conn_ptr__Bool_for_pairing_complete *paVar5; + + if (CONCAT31(in_register_0000202d,status) == 0) { + iVar3 = atomic_test_bit(smp->flags,0xc); + if (bt_auth == (bt_conn_auth_cb *)0x0) goto LAB_23020a2a; + paVar5 = bt_auth->pairing_complete; + bVar1 = iVar3 != 0; + } + else { + uVar4 = CONCAT31(in_register_0000202d,status) - 1U & 0xff; + uVar2 = 8; + if (uVar4 < 0xe) { + uVar2 = (uint)(byte)CSWTCH_108[uVar4]; + } + bVar1 = (bool)SUB41(uVar2,0); + iVar3 = atomic_test_bit(smp->flags,2); + if (iVar3 == 0) { + bt_conn_security_changed((smp->chan).chan.conn,uVar2); + } + if (bt_auth == (bt_conn_auth_cb *)0x0) goto LAB_23020a2a; + paVar5 = (anon_subr_void_bt_conn_ptr__Bool_for_pairing_complete *)bt_auth->pairing_failed; + } + if (paVar5 != (anon_subr_void_bt_conn_ptr__Bool_for_pairing_complete *)0x0) { + (*paVar5)((smp->chan).chan.conn,(_Bool)bVar1); + } +LAB_23020a2a: + smp_reset(smp); + return; +} + + + +// WARNING: Variable defined which should be unmapped: sched + +int bt_smp_aes_cmac(u8_t *key,u8_t *in,size_t len,u8_t *out) + +{ + int iVar1; + undefined auStack280 [4]; + tc_cmac_struct state; + tc_aes_key_sched_struct sched; + + iVar1 = tc_cmac_setup((TCCmacState_t)auStack280,key,(TCAesKeySched_t)((int)&state.countdown + 4)); + if (((iVar1 != 0) && (iVar1 = tc_cmac_update((TCCmacState_t)auStack280,in,len), iVar1 != 0)) && + (iVar1 = tc_cmac_final(out,(TCCmacState_t)auStack280), iVar1 != 0)) { + return 0; + } + return -5; +} + + + +int smp_sign_buf(u8_t *key,u8_t *msg,u16_t len) + +{ + size_t length; + int iVar1; + undefined2 in_register_00002032; + undefined4 uStack68; + u32_t_conflict cnt; + u8_t key_s [16]; + u8_t tmp [16]; + + length = CONCAT22(in_register_00002032,len) + 4; + uStack68 = *(undefined4 *)(msg + CONCAT22(in_register_00002032,len)); + sys_mem_swap(msg,length); + sys_memcpy_swap(&cnt,key,0x10); + iVar1 = bt_smp_aes_cmac((u8_t *)&cnt,msg,length,key_s + 0xc); + if (iVar1 == 0) { + sys_mem_swap(key_s + 0xc,0x10); + memcpy(tmp,&uStack68,4); + sys_mem_swap(msg,length); + memcpy(msg + CONCAT22(in_register_00002032,len),tmp,0xc); + } + else { + printf("Data signing failed\r\n"); + } + return iVar1; +} + + + +// WARNING: Variable defined which should be unmapped: m + +int smp_f4(u8_t *u,u8_t *v,u8_t *x,u8_t z,u8_t *res) + +{ + int iVar1; + u8_t auStack100 [4]; + u8_t xs [16]; + u8_t m [65]; + + sys_memcpy_swap(xs + 0xc,u,0x20); + sys_memcpy_swap(m + 0x1c,v,0x20); + m[60] = z; + sys_memcpy_swap(auStack100,x,0x10); + iVar1 = bt_smp_aes_cmac(auStack100,xs + 0xc,0x41,res); + if (iVar1 == 0) { + sys_mem_swap(res,0x10); + } + return iVar1; +} + + + +u8_t sc_smp_check_confirm(bt_smp *smp) + +{ + int iVar1; + byte z; + u8_t uVar2; + u8_t auStack32 [4]; + u8_t cfm [16]; + + switch(smp->method) { + case '\0': + case '\x03': + z = 0; + break; + case '\x01': + case '\x02': + z = (byte)(smp->passkey >> ((uint)smp->passkey_round & 0x1f)) & 1 | 0x80; + break; + default: + return '\b'; + case '\x05': + return '\0'; + } + iVar1 = smp_f4(smp->pkey,sc_public_key,smp->rrnd,z,auStack32); + uVar2 = '\b'; + if (iVar1 == 0) { + iVar1 = memcmp(smp->pcnf,auStack32,0x10); + uVar2 = (iVar1 != 0) << 2; + } + return uVar2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int smp_f5(u8_t *w,u8_t *n1,u8_t *n2,bt_addr_le_t *a1,bt_addr_le_t *a2,u8_t *mackey,u8_t *ltk) + +{ + u8_t salt [16]; + int iVar1; + u8_t auStack152 [4]; + u8_t t [16]; + u8_t ws [32]; + u8_t m [53]; + + memset(ws + 0x1c,0,0x35); + ws[29] = 'b'; + ws._30_2_ = 0x6c74; + m[0] = 'e'; + m[47] = '\x01'; + sys_memcpy_swap(t + 0xc,w,0x20); + iVar1 = bt_smp_aes_cmac((u8_t *)&ram0x230757f0,t + 0xc,0x20,auStack152); + if (iVar1 == 0) { + sys_memcpy_swap(m + 1,n1,0x10); + sys_memcpy_swap(m + 0x11,n2,0x10); + m[33] = a1->type; + sys_memcpy_swap(m + 0x22,&a1->a,6); + m[40] = a2->type; + sys_memcpy_swap(m + 0x29,&a2->a,6); + iVar1 = bt_smp_aes_cmac(auStack152,ws + 0x1c,0x35,mackey); + if (iVar1 == 0) { + sys_mem_swap(mackey,0x10); + ws[28] = '\x01'; + iVar1 = bt_smp_aes_cmac(auStack152,ws + 0x1c,0x35,ltk); + if (iVar1 == 0) { + sys_mem_swap(ltk,0x10); + } + } + } + return iVar1; +} + + + +// WARNING: Variable defined which should be unmapped: m + +int smp_f6(u8_t *w,u8_t *n1,u8_t *n2,u8_t *r,u8_t *iocap,bt_addr_le_t *a1,bt_addr_le_t *a2, + u8_t *check) + +{ + int iVar1; + u8_t auStack100 [4]; + u8_t ws [16]; + u8_t m [65]; + + sys_memcpy_swap(ws + 0xc,n1,0x10); + sys_memcpy_swap(m + 0xc,n2,0x10); + sys_memcpy_swap(m + 0x1c,r,0x10); + sys_memcpy_swap(m + 0x2c,iocap,3); + m[47] = a1->type; + memcpy(m + 0x30,&a1->a,6); + sys_memcpy_swap(m + 0x30,&a1->a,6); + m[54] = a2->type; + memcpy(m + 0x37,&a2->a,6); + sys_memcpy_swap(m + 0x37,&a2->a,6); + sys_memcpy_swap(auStack100,w,0x10); + iVar1 = bt_smp_aes_cmac(auStack100,ws + 0xc,0x41,check); + if (iVar1 == 0) { + sys_mem_swap(check,0x10); + } + return iVar1; +} + + + +// WARNING: Variable defined which should be unmapped: m + +int smp_g2(u8_t *u,u8_t *v,u8_t *x,u8_t *y,u32_t_conflict *passkey) + +{ + int iVar1; + uint uVar2; + u8_t auStack112 [4]; + u8_t xs [16]; + u8_t m [80]; + + sys_memcpy_swap(xs + 0xc,u,0x20); + sys_memcpy_swap(m + 0x1c,v,0x20); + sys_memcpy_swap(m + 0x3c,y,0x10); + sys_memcpy_swap(auStack112,x,0x10); + iVar1 = bt_smp_aes_cmac(auStack112,xs + 0xc,0x50,auStack112); + if (iVar1 == 0) { + memcpy(passkey,xs + 8,4); + uVar2 = *passkey; + *passkey = (uVar2 >> 0x18 | uVar2 << 0x18 | uVar2 >> 8 & 0xff00 | (uVar2 & 0xff00) << 8) % + 1000000; + } + return iVar1; +} + + + +int atomic_test_and_clear_bit(atomic_t *target,int bit) + +{ + uint uVar1; + uint uVar2; + + uVar1 = 1 << (bit & 0x1fU); + uVar2 = atomic_and(target + ((uint)bit >> 5),~uVar1); + return (uint)((uVar2 & uVar1) != 0); +} + + + +u8_t display_passkey(bt_smp *smp) + +{ + u8_t uVar1; + int iVar2; + + iVar2 = bt_rand(&smp->passkey,4); + uVar1 = '\b'; + if (iVar2 == 0) { + smp->passkey_round = '\0'; + uVar1 = '\0'; + smp->passkey = smp->passkey % 1000000; + if ((bt_auth != (bt_conn_auth_cb *)0x0) && + (bt_auth->passkey_display != (anon_subr_void_bt_conn_ptr_uint_for_passkey_display *)0x0)) { + atomic_set_bit(smp->flags,10); + (*bt_auth->passkey_display)((smp->chan).chan.conn,smp->passkey); + } + } + return uVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +_Bool update_keys_check(bt_smp *smp) + +{ + bt_conn *pbVar1; + bt_keys *pbVar2; + int iVar3; + byte bVar4; + + pbVar1 = (smp->chan).chan.conn; + if (*(int *)(pbVar1->field_20 + 0x2c) == 0) { + pbVar2 = bt_keys_get_addr(pbVar1->id,(bt_addr_le_t *)pbVar1->field_20); + *(bt_keys **)(pbVar1->field_20 + 0x2c) = pbVar2; + } + iVar3 = *(int *)(pbVar1->field_20 + 0x2c); + if ((iVar3 != 0) && ((*(ushort *)(iVar3 + 10) & 0x24) != 0)) { + bVar4 = smp->prsp[4]; + if (smp->preq[4] < smp->prsp[4]) { + bVar4 = smp->preq[4]; + } + if ((bVar4 < *(byte *)(iVar3 + 8)) || + (((*(ushort *)(iVar3 + 10) & 0x20) != 0 && + (iVar3 = atomic_test_bit(smp->flags,5), iVar3 == 0)))) { + return false; + } + if ((*(byte *)(*(int *)(pbVar1->field_20 + 0x2c) + 9) & 1) != 0) { + return (_Bool)(smp->method != '\0'); + } + } + return true; +} + + + +u8_t smp_pairing_failed(bt_smp *smp,net_buf *buf) + +{ + atomic_t *target; + int iVar1; + bt_keys *keys; + byte *pbVar2; + bt_conn *pbVar3; + + pbVar2 = *(byte **)&buf->field_4; + pbVar3 = (smp->chan).chan.conn; + printf("reason 0x%x\r\n",(uint)*pbVar2); + target = smp->flags; + iVar1 = atomic_test_and_clear_bit(target,9); + if ((((iVar1 != 0) || (iVar1 = atomic_test_and_clear_bit(target,10), iVar1 != 0)) && + (bt_auth != (bt_conn_auth_cb *)0x0)) && + (bt_auth->cancel != (anon_subr_void_bt_conn_ptr_for_cancel *)0x0)) { + (*bt_auth->cancel)(pbVar3); + } + iVar1 = atomic_test_bit(target,2); + if ((iVar1 != 0) && + (keys = *(bt_keys **)(((smp->chan).chan.conn)->field_20 + 0x2c), keys != (bt_keys *)0x0)) { + bt_keys_clear(keys); + } + smp_pairing_complete(smp,*pbVar2); + return '\0'; +} + + + +void smp_timeout(k_work *work) + +{ + int iVar1; + bt_keys *keys; + + printf("SMP Timeout\r\n"); + iVar1 = atomic_test_bit(work[-0x14].flags,2); + if ((iVar1 != 0) && (keys = *(bt_keys **)(work[-0x21].flags[0] + 0x9c), keys != (bt_keys *)0x0)) { + bt_keys_clear(keys); + } + atomic_set_bit(work[-0x14].flags,4); + smp_pairing_complete((bt_smp *)work[-0x21].flags,'\b'); + return; +} + + + +u8_t smp_ident_info(bt_smp *smp,net_buf *buf) + +{ + bt_addr_le_t *addr; + int iVar1; + bt_keys *pbVar2; + char *pcVar3; + bt_conn *pbVar4; + void *__src; + + iVar1 = atomic_test_bit(smp->flags,0xc); + if (iVar1 != 0) { + pbVar4 = (smp->chan).chan.conn; + __src = *(void **)&buf->field_4; + addr = (bt_addr_le_t *)pbVar4->field_20; + pbVar2 = bt_keys_get_type(2,pbVar4->id,addr); + if (pbVar2 == (bt_keys *)0x0) { + pcVar3 = bt_addr_le_str_real(addr); + printf("Unable to get keys for %s\r\n",pcVar3); + return '\b'; + } + memcpy(&pbVar2->irk,__src,0x10); + } + atomic_set_bit(&smp->allowed_cmds,9); + return '\0'; +} + + + +u8_t smp_encrypt_info(bt_smp *smp,net_buf *buf) + +{ + bt_addr_le_t *addr; + int iVar1; + bt_keys *pbVar2; + char *pcVar3; + bt_conn *pbVar4; + void *__src; + + iVar1 = atomic_test_bit(smp->flags,0xc); + if (iVar1 != 0) { + pbVar4 = (smp->chan).chan.conn; + __src = *(void **)&buf->field_4; + addr = (bt_addr_le_t *)pbVar4->field_20; + pbVar2 = bt_keys_get_type(4,pbVar4->id,addr); + if (pbVar2 == (bt_keys *)0x0) { + pcVar3 = bt_addr_le_str_real(addr); + printf("Unable to get keys for %s\r\n",pcVar3); + return '\b'; + } + memcpy((pbVar2->ltk).val,__src,0x10); + } + atomic_set_bit(&smp->allowed_cmds,7); + return '\0'; +} + + + +// WARNING: Variable defined which should be unmapped: passkey + +u8_t legacy_request_tk(bt_smp *smp) + +{ + bt_conn *pbVar1; + bt_keys *pbVar2; + int iVar3; + u8_t uVar4; + uint uStack20; + u32_t_conflict passkey; + + pbVar1 = (smp->chan).chan.conn; + pbVar2 = bt_keys_find_addr(pbVar1->id,(bt_addr_le_t *)pbVar1->field_20); + uVar4 = smp->method; + if (((pbVar2 == (bt_keys *)0x0) || ((pbVar2->flags & 1) == 0)) || (uVar4 != '\0')) { + if (uVar4 == '\x01') { + atomic_set_bit(smp->flags,9); + (*bt_auth->passkey_entry)(pbVar1); + } + else { + if (uVar4 == '\0') { + return '\0'; + } + if (uVar4 != '\x02') { + printf("Unknown pairing method (%u)\r\n"); + goto LAB_230211a0; + } + iVar3 = bt_rand(&uStack20,4); + if (iVar3 != 0) { + return '\b'; + } + uStack20 = uStack20 % 1000000; + if ((bt_auth != (bt_conn_auth_cb *)0x0) && + (bt_auth->passkey_display != (anon_subr_void_bt_conn_ptr_uint_for_passkey_display *)0x0)) { + atomic_set_bit(smp->flags,10); + (*bt_auth->passkey_display)(pbVar1,uStack20); + } + smp->tk[0] = (u8_t)uStack20; + smp->tk[2] = (u8_t)(uStack20 >> 0x10); + smp->tk[1] = (u8_t)(uStack20 >> 8); + smp->tk[3] = (u8_t)(uStack20 >> 0x18); + } + uVar4 = '\0'; + } + else { + printf("JustWorks failed, authenticated keys present\r\n"); +LAB_230211a0: + uVar4 = '\b'; + } + return uVar4; +} + + + +void bt_smp_disconnected(bt_l2cap_chan *chan) + +{ + bt_keys *keys; + + keys = *(bt_keys **)(chan->conn->field_20 + 0x2c); + k_delayed_work_cancel((k_delayed_work *)&chan[6].ops); + if (chan[6].rtx_work.work.handler != (k_work_handler_t *)0x0) { + k_delayed_work_del_timer((k_delayed_work *)&chan[6].ops); + } + if ((chan->rtx_work).timer.timer.hdl != (void *)0x0) { + k_delayed_work_del_timer(&chan->rtx_work); + } + if ((keys != (bt_keys *)0x0) && ((keys->keys == 0 || ((keys->flags & 2) != 0)))) { + bt_keys_clear(keys); + } + memset(chan,0,0x1a8); + return; +} + + + +void bt_smp_connected(bt_l2cap_chan *chan) + +{ + k_delayed_work_init((k_delayed_work *)&chan[6].ops,smp_timeout); + smp_reset((bt_smp *)chan); + return; +} + + + +u8_t get_auth(u8_t auth) + +{ + u8_t uVar1; + byte bVar2; + undefined3 in_register_00002029; + undefined3 extraout_var; + byte in_a1; + byte bVar3; + + bVar2 = in_a1 & 0xf; + if (sc_supported == false) { + bVar2 = in_a1 & 7; + } + uVar1 = get_io_capa(); + if ((CONCAT31(extraout_var,uVar1) == 3) || + (bVar3 = bVar2 | 4, *(byte *)CONCAT31(in_register_00002029,auth) < 3)) { + bVar3 = bVar2 & 0xb; + } + bVar2 = bVar3 & 0xfe; + if (bondable != false) { + bVar2 = bVar3 | 1; + } + return (u8_t)bVar2; +} + + + +_Bool sec_level_reachable(void) + +{ + u8_t uVar1; + uint in_a0; + undefined3 extraout_var; + undefined3 extraout_var_00; + _Bool _Var2; + + if (in_a0 == 3) { + uVar1 = get_io_capa(); + _Var2 = true; + if (((CONCAT31(extraout_var_00,uVar1) == 3) && + (_Var2 = false, bt_auth != (bt_conn_auth_cb *)0x0)) && + (bt_auth->oob_data_request != + (anon_subr_void_bt_conn_ptr_bt_conn_oob_info_ptr_for_oob_data_request *)0x0)) { + _Var2 = oobd_present; + } + return (_Bool)(_Var2 & 1); + } + if (3 < in_a0) { + if (in_a0 == 4) { + uVar1 = get_io_capa(); + if ((CONCAT31(extraout_var,uVar1) != 3) || + (((_Var2 = false, bt_auth != (bt_conn_auth_cb *)0x0 && + (bt_auth->oob_data_request != + (anon_subr_void_bt_conn_ptr_bt_conn_oob_info_ptr_for_oob_data_request *)0x0)) && + (oobd_present != false)))) { + _Var2 = sc_supported; + } + return (_Bool)(_Var2 & 1); + } + return false; + } + return (_Bool)(in_a0 != 0); +} + + + +int bt_smp_accept(bt_conn *conn,bt_l2cap_chan **chan) + +{ + int iVar1; + + if (bt_smp_pool[0].chan.chan.conn == (bt_conn *)0x0) { + iVar1 = 0; + } + else { + if (bt_smp_pool[1].chan.chan.conn != (bt_conn *)0x0) { + printf("No available SMP context for conn %p\r\n",conn); + return -0xc; + } + iVar1 = 1; + } + bt_smp_pool[iVar1].chan.chan.ops = (bt_l2cap_chan_ops *)0x4200d49c; + *(bt_smp **)chan = bt_smp_pool + iVar1; + return 0; +} + + + +_Bool smp_keys_check(bt_conn *conn) + +{ + byte bVar1; + bt_keys *pbVar2; + int iVar3; + + if (*(int *)(conn->field_20 + 0x2c) == 0) { + pbVar2 = bt_keys_find(0x20,conn->id,(bt_addr_le_t *)conn->field_20); + *(bt_keys **)(conn->field_20 + 0x2c) = pbVar2; + if (pbVar2 == (bt_keys *)0x0) { + pbVar2 = bt_keys_find(4,conn->id,(bt_addr_le_t *)conn->field_20); + *(bt_keys **)(conn->field_20 + 0x2c) = pbVar2; + } + } + iVar3 = *(int *)(conn->field_20 + 0x2c); + bVar1 = 0; + if (((iVar3 != 0) && ((*(ushort *)(iVar3 + 10) & 0x24) != 0)) && + (bVar1 = 1, 2 < (byte)conn->required_sec_level)) { + bVar1 = *(byte *)(iVar3 + 9) & 1; + } + return (_Bool)bVar1; +} + + + +u8_t get_pair_method(bt_smp *smp,u8_t remote_io) + +{ + byte bVar1; + byte bVar2; + u8_t uVar3; + int iVar4; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 in_register_0000202d; + uint uVar5; + + uVar5 = CONCAT31(in_register_0000202d,remote_io); + iVar4 = atomic_test_bit(smp->flags,5); + bVar2 = (byte)iVar4; + if (iVar4 == 0) { + if ((uVar5 < 5) && (bVar1 = smp->preq[3] | smp->prsp[3], bVar2 = bVar1 & 4, (bVar1 & 4) != 0)) { + uVar3 = get_io_capa(); + bVar2 = ""[CONCAT31(extraout_var,uVar3) + uVar5 * 5]; + if (bVar2 == 4) { + bVar2 = (((smp->chan).chan.conn)->role == '\0') + 1; + } + } + } + else { + if (((((smp->preq[3] & smp->prsp[3] & 8) == 0) || + (bVar2 = 5, ((smp->preq[2] | smp->prsp[2]) & 1) == 0)) && (bVar2 = 0, uVar5 < 5)) && + (bVar1 = smp->preq[3] | smp->prsp[3], bVar2 = bVar1 & 4, (bVar1 & 4) != 0)) { + uVar3 = get_io_capa(); + bVar2 = ""[CONCAT31(extraout_var_00,uVar3) + uVar5 * 5]; + } + } + return (u8_t)bVar2; +} + + + +net_buf * smp_create_pdu(bt_smp *smp,u8_t op) + +{ + int iVar1; + net_buf *pnVar2; + u8_t *puVar3; + s32_t timeout; + + iVar1 = atomic_test_bit(smp->flags,4); + timeout = 0; + if (iVar1 == 0) { + timeout = 30000; + } + pnVar2 = bt_l2cap_create_pdu_timeout((net_buf_pool *)0x0,0,timeout); + if (pnVar2 == (net_buf *)0x0) { + atomic_set_bit(smp->flags,4); + } + else { + puVar3 = (u8_t *)net_buf_simple_add((net_buf_simple *)&pnVar2->field_4,1); + *puVar3 = op; + } + return pnVar2; +} + + + +void smp_send(bt_smp *smp,net_buf *buf,bt_conn_tx_cb_t *cb) + +{ + bt_l2cap_send_cb((smp->chan).chan.conn,6,buf,cb,(void *)0x0); + k_delayed_work_submit(&smp->work,30000); + return; +} + + + +u8_t sc_smp_send_dhkey_check(bt_smp *smp,u8_t *e) + +{ + u8_t uVar1; + net_buf *buf; + void *__dest; + + buf = smp_create_pdu(smp,'\r'); + if (buf == (net_buf *)0x0) { + uVar1 = '\b'; + } + else { + __dest = net_buf_simple_add((net_buf_simple *)&buf->field_4,0x10); + memcpy(__dest,e,0x10); + smp_send(smp,buf,(bt_conn_tx_cb_t *)0x0); + uVar1 = '\0'; + } + return uVar1; +} + + + +u8_t compute_and_send_master_dhcheck(bt_smp *smp) + +{ + u8_t uVar1; + int iVar2; + bt_le_oob_sc_data *__src; + size_t __n; + bt_conn *pbVar3; + u8_t auStack64 [4]; + u8_t e [16]; + u8_t r [16]; + + memset(e + 0xc,0,0x10); + switch(smp->method) { + case '\0': + case '\x03': + break; + case '\x01': + case '\x02': + __n = 4; + __src = (bt_le_oob_sc_data *)&smp->passkey; +LAB_230215fe: + memcpy(e + 0xc,__src,__n); + break; + default: + goto switchD_230215f6_caseD_4; + case '\x05': + __src = smp->oobd_remote; + if (__src != (bt_le_oob_sc_data *)0x0) { + __n = 0x10; + goto LAB_230215fe; + } + } + pbVar3 = (smp->chan).chan.conn; + iVar2 = smp_f5(smp->dhkey,smp->prnd,smp->rrnd,(bt_addr_le_t *)(pbVar3->field_20 + 7), + (bt_addr_le_t *)(pbVar3->field_20 + 0xe),smp->mackey,smp->tk); + if ((iVar2 == 0) && + (pbVar3 = (smp->chan).chan.conn, + iVar2 = smp_f6(smp->mackey,smp->prnd,smp->rrnd,e + 0xc,smp->preq + 1, + (bt_addr_le_t *)(pbVar3->field_20 + 7),(bt_addr_le_t *)(pbVar3->field_20 + 0xe), + auStack64), iVar2 == 0)) { + atomic_set_bit(&smp->allowed_cmds,0xd); + uVar1 = sc_smp_send_dhkey_check(smp,auStack64); + } + else { +switchD_230215f6_caseD_4: + uVar1 = '\b'; + } + return uVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +u8_t compute_and_check_and_send_slave_dhcheck(bt_smp *smp) + +{ + u8_t *mackey; + u8_t uVar1; + int iVar2; + undefined3 extraout_var; + bt_le_oob_sc_data *__src; + size_t __n; + bt_conn *pbVar3; + u8_t *n1; + u8_t *n2; + u8_t auStack80 [4]; + u8_t re [16]; + u8_t e [16]; + u8_t r [16]; + + memset(e + 0xc,0,0x10); + switch(smp->method) { + case '\0': + case '\x03': + break; + case '\x01': + case '\x02': + __n = 4; + __src = (bt_le_oob_sc_data *)&smp->passkey; +LAB_230216b2: + memcpy(e + 0xc,__src,__n); + break; + default: + goto LAB_2302176c; + case '\x05': + __src = smp->oobd_remote; + if (__src != (bt_le_oob_sc_data *)0x0) { + __n = 0x10; + goto LAB_230216b2; + } + } + pbVar3 = (smp->chan).chan.conn; + n1 = smp->rrnd; + n2 = smp->prnd; + mackey = smp->mackey; + iVar2 = smp_f5(smp->dhkey,n1,n2,(bt_addr_le_t *)(pbVar3->field_20 + 7), + (bt_addr_le_t *)(pbVar3->field_20 + 0xe),mackey,smp->tk); + if ((iVar2 == 0) && + (pbVar3 = (smp->chan).chan.conn, + iVar2 = smp_f6(mackey,n2,n1,e + 0xc,smp->prsp + 1,(bt_addr_le_t *)(pbVar3->field_20 + 0xe), + (bt_addr_le_t *)(pbVar3->field_20 + 7),re + 0xc), iVar2 == 0)) { + if (smp->method == '\x05') { + if (smp->oobd_local == (bt_le_oob_sc_data *)0x0) { + memset(e + 0xc,0,0x10); + } + else { + memcpy(e + 0xc,smp->oobd_local,0x10); + } + } + pbVar3 = (smp->chan).chan.conn; + iVar2 = smp_f6(mackey,n1,n2,e + 0xc,smp->preq + 1,(bt_addr_le_t *)(pbVar3->field_20 + 7), + (bt_addr_le_t *)(pbVar3->field_20 + 0xe),auStack80); + if (iVar2 == 0) { + iVar2 = memcmp(smp->e,auStack80,0x10); + if (iVar2 != 0) { + return '\v'; + } + uVar1 = sc_smp_send_dhkey_check(smp,re + 0xc); + if (CONCAT31(extraout_var,uVar1) != 0) { + return uVar1; + } + atomic_set_bit(smp->flags,1); + return uVar1; + } + } +LAB_2302176c: + return '\b'; +} + + + +// WARNING: Variable defined which should be unmapped: r +// WARNING: Type propagation algorithm not settling + +u8_t smp_dhkey_check(bt_smp *smp,net_buf *buf) + +{ + atomic_t *target; + u8_t uVar1; + int iVar2; + bt_le_oob_sc_data *__src; + size_t __n; + uint len; + bt_conn *pbVar3; + void *__src_00; + u8_t auStack60 [4]; + u8_t ediv [2]; + u8_t rand [8]; + u8_t e [16]; + u8_t r [16]; + + __src_00 = *(void **)&buf->field_4; + uVar1 = ((smp->chan).chan.conn)->role; + if (uVar1 != '\0') { + if (uVar1 == '\x01') { + target = smp->flags; + atomic_and(target,-0x8001); + memcpy(smp->e,__src_00,0x10); + iVar2 = atomic_test_bit(target,7); + if ((iVar2 == 0) && (iVar2 = atomic_test_bit(target,9), iVar2 == 0)) { + uVar1 = compute_and_check_and_send_slave_dhcheck(smp); + return uVar1; + } + atomic_set_bit(target,8); + } + return '\0'; + } + memset(e + 0xc,0,0x10); + switch(smp->method) { + case '\0': + case '\x03': + break; + case '\x01': + case '\x02': + __n = 4; + __src = (bt_le_oob_sc_data *)&smp->passkey; +LAB_230217c8: + memcpy(e + 0xc,__src,__n); + break; + default: + goto LAB_23021854; + case '\x05': + __src = smp->oobd_local; + if (__src != (bt_le_oob_sc_data *)0x0) { + __n = 0x10; + goto LAB_230217c8; + } + } + pbVar3 = (smp->chan).chan.conn; + iVar2 = smp_f6(smp->mackey,smp->rrnd,smp->prnd,e + 0xc,smp->prsp + 1, + (bt_addr_le_t *)(pbVar3->field_20 + 0xe),(bt_addr_le_t *)(pbVar3->field_20 + 7), + rand + 4); + if (iVar2 == 0) { + iVar2 = memcmp(rand + 4,__src_00,0x10); + if (iVar2 != 0) { + return '\v'; + } + len = (uint)smp->prsp[4]; + if ((uint)smp->preq[4] < (uint)smp->prsp[4]) { + len = (uint)smp->preq[4]; + } + memset(auStack60,0,2); + memset(ediv,0,8); + iVar2 = bt_conn_le_start_encryption((smp->chan).chan.conn,ediv,auStack60,smp->tk,len); + if (-1 < iVar2) { + atomic_set_bit(smp->flags,1); + return 0; + } + } +LAB_23021854: + return '\b'; +} + + + +u8_t smp_send_pairing_random(bt_smp *smp) + +{ + u8_t uVar1; + net_buf *buf; + void *__dest; + + buf = smp_create_pdu(smp,'\x04'); + if (buf == (net_buf *)0x0) { + uVar1 = '\b'; + } + else { + __dest = net_buf_simple_add((net_buf_simple *)&buf->field_4,0x10); + memcpy(__dest,smp->prnd,0x10); + smp_send(smp,buf,(bt_conn_tx_cb_t *)0x0); + uVar1 = '\0'; + } + return uVar1; +} + + + +u8_t sc_send_public_key(bt_smp *smp) + +{ + u8_t uVar1; + net_buf *buf; + void *__dest; + + buf = smp_create_pdu(smp,'\f'); + if (buf == (net_buf *)0x0) { + uVar1 = '\b'; + } + else { + __dest = net_buf_simple_add((net_buf_simple *)&buf->field_4,0x40); + memcpy(__dest,sc_public_key,0x20); + memcpy((void *)((int)__dest + 0x20),sc_public_key + 0x20,0x20); + smp_send(smp,buf,(bt_conn_tx_cb_t *)0x0); + uVar1 = '\0'; + } + return uVar1; +} + + + +u8_t send_pairing_rsp(bt_smp *smp) + +{ + u8_t uVar1; + net_buf *buf; + void *__dest; + + buf = smp_create_pdu(smp,'\x02'); + if (buf == (net_buf *)0x0) { + uVar1 = '\b'; + } + else { + __dest = net_buf_simple_add((net_buf_simple *)&buf->field_4,6); + memcpy(__dest,smp->prsp + 1,6); + smp_send(smp,buf,(bt_conn_tx_cb_t *)0x0); + uVar1 = '\0'; + } + return uVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +u8_t bt_smp_distribute_keys(bt_smp *smp) + +{ + byte bVar1; + bt_keys *keys; + bt_conn *pbVar2; + char *fmt; + int iVar3; + net_buf *buf; + void *__dest; + bt_keys *keys_00; + atomic_t *target; + undefined auStack60 [4]; + anon_struct_for_rand rand; + + pbVar2 = (smp->chan).chan.conn; + keys_00 = *(bt_keys **)(pbVar2->field_20 + 0x2c); + if (keys_00 == (bt_keys *)0x0) { + fmt = bt_addr_le_str_real((bt_addr_le_t *)pbVar2->field_20); + printf("No keys space for %s\r\n",fmt); + return '\b'; + } + target = smp->flags; + iVar3 = atomic_test_bit(target,5); + if ((iVar3 == 0) && ((smp->local_dist & 1) != 0)) { + keys = *(bt_keys **)(((smp->chan).chan.conn)->field_20 + 0x2c); + bt_rand(auStack60,0x1a); + buf = smp_create_pdu(smp,'\x06'); + if (buf == (net_buf *)0x0) { + fmt = "Unable to allocate Encrypt Info buffer\r\n"; + } + else { + __dest = net_buf_simple_add((net_buf_simple *)&buf->field_4,0x10); + memcpy(__dest,auStack60,(uint)keys->enc_size); + bVar1 = keys->enc_size; + if (bVar1 < 0x10) { + memset((void *)((uint)bVar1 + (int)__dest),0,0x10 - (uint)bVar1); + } + smp_send(smp,buf,(bt_conn_tx_cb_t *)0x0); + buf = smp_create_pdu(smp,'\a'); + if (buf != (net_buf *)0x0) { + __dest = net_buf_simple_add((net_buf_simple *)&buf->field_4,10); + memcpy((void *)((int)__dest + 2),rand.key + 0xc,8); + memcpy(__dest,rand.rand + 4,2); + smp_send(smp,buf,smp_ident_sent); + iVar3 = atomic_test_bit(target,0xc); + if (iVar3 != 0) { + bt_keys_add_type(keys,1); + memcpy((keys->slave_ltk).val,auStack60,0x10); + memcpy(&keys->slave_ltk,rand.key + 0xc,8); + memcpy((keys->slave_ltk).ediv,rand.rand + 4,2); + } + goto LAB_23021a18; + } + fmt = "Unable to allocate Master Ident buffer\r\n"; + } + printf(fmt); + } +LAB_23021a18: + if ((smp->local_dist & 4) == 0) { + return smp->local_dist & 4; + } + buf = smp_create_pdu(smp,'\n'); + if (buf == (net_buf *)0x0) { + printf("Unable to allocate Signing Info buffer\r\n"); + return '\b'; + } + __dest = net_buf_simple_add((net_buf_simple *)&buf->field_4,0x10); + bt_rand(__dest,0x10); + iVar3 = atomic_test_bit(target,0xc); + if (iVar3 != 0) { + bt_keys_add_type(keys_00,8); + memcpy(&keys_00->local_csrk,__dest,0x10); + (keys_00->local_csrk).cnt = 0; + } + smp_send(smp,buf,smp_sign_info_sent); + return '\0'; +} + + + +u8_t smp_signing_info(bt_smp *smp,net_buf *buf) + +{ + bt_conn *pbVar1; + u8_t uVar2; + int iVar3; + bt_keys *pbVar4; + char *pcVar5; + undefined3 extraout_var; + byte bVar6; + void *__src; + + pbVar1 = (smp->chan).chan.conn; + iVar3 = atomic_test_bit(smp->flags,0xc); + if (iVar3 != 0) { + __src = *(void **)&buf->field_4; + pbVar4 = bt_keys_get_type(0x10,pbVar1->id,(bt_addr_le_t *)pbVar1->field_20); + if (pbVar4 == (bt_keys *)0x0) { + pcVar5 = bt_addr_le_str_real((bt_addr_le_t *)pbVar1->field_20); + printf("Unable to get keys for %s\r\n",pcVar5); + return '\b'; + } + memcpy(&pbVar4->remote_csrk,__src,0x10); + } + bVar6 = smp->remote_dist & 0xfb; + smp->remote_dist = bVar6; + if (((bVar6 | pbVar1->role) != 0) || + (uVar2 = bt_smp_distribute_keys(smp), CONCAT31(extraout_var,uVar2) == 0)) { + if (*(short *)&smp->local_dist == 0) { + smp_pairing_complete(smp,'\0'); + } + uVar2 = '\0'; + } + return uVar2; +} + + + +u8_t smp_master_ident(bt_smp *smp,net_buf *buf) + +{ + bt_conn *pbVar1; + u8_t uVar2; + int bit; + bt_keys *pbVar3; + char *pcVar4; + undefined3 extraout_var; + void *__src; + + pbVar1 = (smp->chan).chan.conn; + bit = atomic_test_bit(smp->flags,0xc); + if (bit != 0) { + __src = *(void **)&buf->field_4; + pbVar3 = bt_keys_get_type(4,pbVar1->id,(bt_addr_le_t *)pbVar1->field_20); + if (pbVar3 == (bt_keys *)0x0) { + pcVar4 = bt_addr_le_str_real((bt_addr_le_t *)pbVar1->field_20); + printf("Unable to get keys for %s\r\n",pcVar4); + return '\b'; + } + memcpy((pbVar3->ltk).ediv,__src,2); + memcpy(&pbVar3->ltk,(void *)((int)__src + 2),8); + smp->remote_dist = smp->remote_dist & 0xfe; + } + bit = 8; + if ((smp->remote_dist & 2) == 0) { + if ((smp->remote_dist & 4) == 0) goto LAB_23021c60; + bit = 10; + } + atomic_set_bit(&smp->allowed_cmds,bit); +LAB_23021c60: + if (((pbVar1->role != '\0') || (smp->remote_dist != '\0')) || + (uVar2 = bt_smp_distribute_keys(smp), CONCAT31(extraout_var,uVar2) == 0)) { + if (*(short *)&smp->local_dist == 0) { + smp_pairing_complete(smp,'\0'); + } + uVar2 = '\0'; + } + return uVar2; +} + + + +int smp_init(bt_smp *smp) + +{ + int iVar1; + int iVar2; + + memset(&smp->allowed_cmds,0,0xec); + iVar2 = bt_rand(smp->prnd,0x10); + iVar1 = 8; + if (iVar2 == 0) { + atomic_set_bit(&smp->allowed_cmds,5); + sc_public_key = bt_pub_key_get(); + k_sem_init(&sc_local_pkey_ready,0,1); + iVar1 = iVar2; + } + return iVar1; +} + + + +int smp_send_pairing_req(bt_conn *conn) + +{ + int iVar1; + _Bool _Var2; + u8_t uVar3; + bt_smp *smp; + int iVar4; + undefined3 extraout_var; + bt_keys *pbVar5; + net_buf *buf; + u8_t *__src; + atomic_t *target; + + smp = smp_chan_get(conn); + iVar1 = -0x39; + if (smp != (bt_smp *)0x0) { + target = smp->flags; + iVar4 = atomic_test_bit(target,4); + iVar1 = -5; + if (iVar4 == 0) { + iVar1 = atomic_test_bit(target,3); + if ((iVar1 == 0) && (iVar1 = atomic_test_bit(target,1), iVar1 == 0)) { + iVar1 = -0x16; + _Var2 = sec_level_reachable(); + if (CONCAT31(extraout_var,_Var2) != 0) { + if (*(int *)(conn->field_20 + 0x2c) == 0) { + pbVar5 = bt_keys_get_addr(conn->id,(bt_addr_le_t *)conn->field_20); + *(bt_keys **)(conn->field_20 + 0x2c) = pbVar5; + if (pbVar5 == (bt_keys *)0x0) { + return -0xc; + } + } + iVar1 = smp_init(smp); + if ((iVar1 == 0) && (buf = smp_create_pdu(smp,'\x01'), buf != (net_buf *)0x0)) { + __src = (u8_t *)net_buf_simple_add((net_buf_simple *)&buf->field_4,6); + uVar3 = get_auth((char)conn + '\n'); + __src[2] = uVar3; + uVar3 = get_io_capa(); + _Var2 = oobd_present; + *__src = uVar3; + *(_Bool *)(__src + 1) = _Var2; + __src[3] = '\x10'; + __src[4] = '\x05'; + __src[5] = '\a'; + *(undefined2 *)&smp->local_dist = 0x705; + smp->preq[0] = '\x01'; + memcpy(smp->preq + 1,__src,6); + smp_send(smp,buf,(bt_conn_tx_cb_t *)0x0); + atomic_set_bit(&smp->allowed_cmds,2); + atomic_set_bit(&smp->allowed_cmds,0xb); + atomic_set_bit(target,3); + } + else { + iVar1 = -0x37; + } + } + } + else { + iVar1 = -0x10; + } + } + } + return iVar1; +} + + + +u8_t smp_security_request(bt_smp *smp,net_buf *buf) + +{ + bt_conn *conn; + atomic_t *target; + u8_t uVar1; + int bit; + bt_keys *pbVar2; + undefined3 extraout_var; + int iVar3; + byte *pbVar4; + uint uVar5; + + target = smp->flags; + conn = (smp->chan).chan.conn; + pbVar4 = *(byte **)&buf->field_4; + bit = atomic_test_bit(target,3); + if (bit != 0) { + return '\0'; + } + bit = atomic_test_bit(target,1); + if (bit != 0) { + return '\0'; + } + uVar5 = (uint)*pbVar4 & 7; + if (sc_supported != false) { + uVar5 = (uint)*pbVar4 & 0xf; + } + if (*(int *)(conn->field_20 + 0x2c) == 0) { + pbVar2 = bt_keys_find(0x20,conn->id,(bt_addr_le_t *)conn->field_20); + *(bt_keys **)(conn->field_20 + 0x2c) = pbVar2; + if (pbVar2 == (bt_keys *)0x0) { + pbVar2 = bt_keys_find(4,conn->id,(bt_addr_le_t *)conn->field_20); + *(bt_keys **)(conn->field_20 + 0x2c) = pbVar2; + } +LAB_23021e90: + bit = *(int *)(conn->field_20 + 0x2c); + if (bit != 0) { + if (((uVar5 & 4) == 0) || ((*(byte *)(bit + 9) & 1) != 0)) { + if (((uVar5 & 8) == 0) || ((*(ushort *)(bit + 10) & 0x20) != 0)) { + iVar3 = bt_conn_le_start_encryption + (conn,(u8_t *)(bit + 0xc),(u8_t *)(bit + 0x14),(u8_t *)(bit + 0x16), + (uint)*(byte *)(bit + 8)); + bit = 1; + if (iVar3 < 0) { + return '\b'; + } + goto LAB_23021e60; + } + } + else { + uVar1 = get_io_capa(); + if (CONCAT31(extraout_var,uVar1) == 3) { + printf("Unsupported auth requirements: 0x%x, repairing\r\n",uVar5); + } + } + } + } + else { + if ((*(ushort *)(*(int *)(conn->field_20 + 0x2c) + 10) & 0x24) != 0) goto LAB_23021e90; + } + bit = smp_send_pairing_req(conn); + if (bit < 0) { + return '\b'; + } + bit = 0xe; +LAB_23021e60: + atomic_set_bit(target,bit); + return '\0'; +} + + + +// WARNING: Type propagation algorithm not settling + +u8_t smp_pairing_req(bt_smp *smp,net_buf *buf) + +{ + u8_t *__src; + byte bVar1; + u8_t uVar2; + _Bool _Var3; + int iVar4; + undefined3 extraout_var; + bt_keys *pbVar5; + undefined3 extraout_var_00; + atomic_t *target; + bt_conn *pbVar6; + + __src = *(u8_t **)&buf->field_4; + if (9 < (byte)(__src[3] - 7)) { + return '\x06'; + } + pbVar6 = (smp->chan).chan.conn; + if (*(int *)(pbVar6->field_20 + 0x2c) == 0) { + pbVar5 = bt_keys_get_addr(pbVar6->id,(bt_addr_le_t *)pbVar6->field_20); + *(bt_keys **)(pbVar6->field_20 + 0x2c) = pbVar5; + if (pbVar5 == (bt_keys *)0x0) { + return '\b'; + } + } + target = smp->flags; + iVar4 = atomic_test_bit(target,0xe); + if ((iVar4 == 0) && (iVar4 = smp_init(smp), iVar4 != 0)) { + return (u8_t)iVar4; + } + smp->preq[0] = '\x01'; + memcpy(smp->preq + 1,__src,6); + smp->prsp[0] = '\x02'; + bVar1 = get_auth((char)pbVar6 + '\n'); + smp->prsp[3] = bVar1; + uVar2 = get_io_capa(); + _Var3 = oobd_present; + smp->prsp[1] = uVar2; + *(_Bool *)(smp->prsp + 2) = _Var3; + smp->prsp[4] = '\x10'; + smp->prsp[5] = __src[4] & 7; + smp->prsp[6] = __src[5] & 5; + if (((bVar1 & 8) != 0) && ((__src[2] & 8) != 0)) { + atomic_set_bit(target,5); + smp->prsp[5] = smp->prsp[5] & 6; + smp->prsp[6] = smp->prsp[6] & 4; + } + if (((smp->prsp[3] & 0x20) != 0) && ((__src[2] & 0x20) != 0)) { + atomic_set_bit(target,0x13); + } + smp->local_dist = smp->prsp[6]; + smp->remote_dist = smp->prsp[5]; + if (((smp->prsp[3] & 1) != 0) && ((__src[2] & 1) != 0)) { + atomic_set_bit(target,0xc); + } + atomic_set_bit(target,3); + uVar2 = get_pair_method(smp,*__src); + smp->method = uVar2; + _Var3 = update_keys_check(smp); + if (CONCAT31(extraout_var,_Var3) == 0) { +LAB_23022032: + uVar2 = '\x03'; + } + else { + iVar4 = atomic_test_bit(target,5); + uVar2 = smp->method; + if (iVar4 == 0) { + if (((uVar2 != '\0') || (iVar4 = atomic_test_bit(target,0xe), iVar4 != 0)) || + ((bt_auth == (bt_conn_auth_cb *)0x0 || + (bt_auth->pairing_confirm == (anon_subr_void_bt_conn_ptr_for_pairing_confirm *)0x0)))) { + uVar2 = send_pairing_rsp(smp); + if (CONCAT31(extraout_var_00,uVar2) == 0) { + atomic_set_bit(&smp->allowed_cmds,3); + uVar2 = legacy_request_tk(smp); + return uVar2; + } + return uVar2; + } + } + else { + if (pbVar6->required_sec_level == BT_SECURITY_L4) { + if (uVar2 != '\0') { + bVar1 = smp->preq[4]; + if (smp->prsp[4] < smp->preq[4]) { + bVar1 = smp->prsp[4]; + } + if (bVar1 != 0x10) { + return 6; + } + goto LAB_230220ea; + } + goto LAB_23022032; + } + if ((((uVar2 != '\0') || (iVar4 = atomic_test_bit(target,0xe), iVar4 != 0)) || + (bt_auth == (bt_conn_auth_cb *)0x0)) || + (bt_auth->pairing_confirm == (anon_subr_void_bt_conn_ptr_for_pairing_confirm *)0x0)) { +LAB_230220ea: + atomic_set_bit(&smp->allowed_cmds,0xc); + uVar2 = send_pairing_rsp(smp); + return uVar2; + } + } + atomic_set_bit(target,9); + (*bt_auth->pairing_confirm)((smp->chan).chan.conn); + } + return uVar2; +} + + + +void smp_check_complete(bt_conn *conn,u8_t dist_complete) + +{ + bt_smp *smp; + + smp = (bt_smp *)bt_l2cap_le_lookup_tx_cid(conn,6); + smp->local_dist = ~dist_complete & smp->local_dist; + if (*(short *)&smp->local_dist == 0) { + smp_pairing_complete(smp,'\0'); + return; + } + return; +} + + + +void smp_sign_info_sent(bt_conn *conn,void *user_data) + +{ + if (conn->type == '\x01') { + smp_check_complete(conn,'\x04'); + return; + } + return; +} + + + +void le_sc_oob_config_set_isra_3_constprop_19(int *param_1,char *param_2) + +{ + byte bVar1; + char cVar2; + + bVar1 = *(byte *)((int)param_1 + 0xaa); + if (*(char *)(*param_1 + 3) == '\0') { + cVar2 = (char)((uint)bVar1 & 1) + '\x01'; + if (((*(byte *)((int)param_1 + 0xa3) & 1) == 0) && (cVar2 = '\x03', (bVar1 & 1) != 0)) { + cVar2 = '\0'; + } + } + else { + cVar2 = (char)(((uint)bVar1 & 1) << 1); + if (((*(byte *)((int)param_1 + 0xa3) & 1) == 0) && (cVar2 = '\x03', (bVar1 & 1) != 0)) { + cVar2 = '\x01'; + } + } + *param_2 = cVar2; + return; +} + + + +int smp_error(bt_smp *smp,u8_t reason) + +{ + net_buf *buf; + u8_t *puVar1; + int iVar2; + + smp_pairing_complete(smp,reason); + buf = smp_create_pdu(smp,'\x05'); + if (buf == (net_buf *)0x0) { + iVar2 = -0x37; + } + else { + puVar1 = (u8_t *)net_buf_simple_add((net_buf_simple *)&buf->field_4,1); + *puVar1 = reason; + bt_l2cap_send_cb((smp->chan).chan.conn,6,buf,(bt_conn_tx_cb_t *)0x0,(void *)0x0); + iVar2 = 0; + } + return iVar2; +} + + + +void bt_smp_dhkey_ready(u8_t *dhkey) + +{ + atomic_t *target; + u8_t reason; + int iVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + bt_smp *smp; + + iVar1 = atomic_test_and_clear_bit(bt_smp_pool[0].flags,7); + if (iVar1 == 0) { + iVar1 = atomic_test_and_clear_bit(bt_smp_pool[1].flags,7); + if (iVar1 == 0) { + return; + } + iVar1 = 1; + } + else { + iVar1 = 0; + } + reason = '\v'; + smp = bt_smp_pool + iVar1; + if (dhkey == (u8_t *)0x0) { +LAB_23022292: + smp_error(smp,reason); + return; + } + memcpy(bt_smp_pool[iVar1].dhkey,dhkey,0x20); + target = bt_smp_pool[iVar1].flags; + iVar1 = atomic_test_bit(target,9); + if ((iVar1 != 0) || (iVar1 = atomic_test_bit(target,0xf), iVar1 != 0)) { + atomic_set_bit(target,8); + return; + } + iVar1 = atomic_test_bit(target,8); + if (iVar1 != 0) { + if (((smp->chan).chan.conn)->role == '\0') { + reason = compute_and_send_master_dhcheck(smp); + iVar1 = CONCAT31(extraout_var,reason); + } + else { + reason = compute_and_check_and_send_slave_dhcheck(smp); + iVar1 = CONCAT31(extraout_var_00,reason); + } + reason = (u8_t)iVar1; + if (iVar1 != 0) goto LAB_23022292; + } + return; +} + + + +int bt_smp_recv(bt_l2cap_chan *chan,net_buf *buf) + +{ + byte bVar1; + u8_t reason; + byte *pbVar2; + int iVar3; + undefined3 extraout_var; + uint uVar4; + + if (*(short *)((int)&buf->field_4 + 4) == 0) { + printf("Too small SMP PDU received\r\n"); + } + else { + pbVar2 = (byte *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,1); + iVar3 = atomic_test_bit((atomic_t *)&chan[2].rtx_work.work_q,4); + bVar1 = *pbVar2; + if (iVar3 == 0) { + if ((bVar1 < 0xe) && + (handlers[(uint)bVar1].func != (anon_subr_u8_t_bt_smp_ptr_net_buf_ptr_for_func *)0x0)) { + iVar3 = atomic_test_and_clear_bit(chan[2].rtx_work.work.flags,(uint)bVar1); + uVar4 = (uint)*pbVar2; + if (iVar3 == 0) { + printf("Unexpected SMP code 0x%02x\r\n",uVar4); + reason = '\b'; + if (*pbVar2 == 5) { + return 0; + } + } + else { + if ((uint)handlers[uVar4].expect_len == (uint)*(ushort *)((int)&buf->field_4 + 4)) { + reason = (*handlers[uVar4].func)((bt_smp *)chan,buf); + if (CONCAT31(extraout_var,reason) == 0) { + return 0; + } + } + else { + printf("Invalid len %u for code 0x%02x\r\n"); + reason = '\n'; + } + } + } + else { + printf("Unhandled SMP code 0x%02x\r\n"); + reason = '\a'; + } + smp_error((bt_smp *)chan,reason); + } + else { + printf("SMP command (code 0x%02x) received after timeout\r\n"); + } + } + return 0; +} + + + +void bt_smp_encrypt_change(bt_l2cap_chan *chan,u8_t hci_status) + +{ + byte bVar1; + k_work_q **target; + u8_t uVar2; + int bit; + undefined3 extraout_var; + undefined3 in_register_0000202d; + bt_conn *pbVar3; + + target = &chan[2].rtx_work.work_q; + pbVar3 = chan->conn; + atomic_and((atomic_t *)target,-3); + if (CONCAT31(in_register_0000202d,hci_status) != 0) { + return; + } + if (pbVar3->encrypt == '\0') { + return; + } + bit = atomic_test_bit((atomic_t *)target,3); + if (bit == 0) { + smp_reset((bt_smp *)chan); + return; + } + bit = atomic_test_bit((atomic_t *)target,5); + if (bit != 0) { + if (((*(byte *)&chan[6].conn & 8) != 0) && ((*(byte *)((int)&chan[6].conn + 1) & 8) != 0)) { + atomic_set_bit((atomic_t *)target,0x10); + } + *(ushort *)&chan[6].conn = *(ushort *)&chan[6].conn & 0xf7f7; + } + bVar1 = *(byte *)((int)&chan[6].conn + 1); + bit = 6; + if (((bVar1 & 1) == 0) && (bit = 8, (bVar1 & 2) == 0)) { + if ((bVar1 & 4) == 0) goto LAB_23022436; + bit = 10; + } + atomic_set_bit(chan[2].rtx_work.work.flags,bit); +LAB_23022436: + atomic_set_bit((atomic_t *)target,2); + if ((((pbVar3->role != '\0') || (*(char *)((int)&chan[6].conn + 1) == '\0')) && + (uVar2 = bt_smp_distribute_keys((bt_smp *)chan), CONCAT31(extraout_var,uVar2) == 0)) && + (*(short *)&chan[6].conn == 0)) { + smp_pairing_complete((bt_smp *)chan,'\0'); + return; + } + return; +} + + + +u8_t smp_send_pairing_confirm(bt_smp *smp) + +{ + byte z; + net_buf *buf; + u8_t *res; + int iVar1; + + z = smp->method; + if (z < 3) { + if (z != 0) { + z = (byte)(smp->passkey >> ((uint)smp->passkey_round & 0x1f)) & 1 | 0x80; + goto LAB_230224be; + } + } + else { + if (z != 3) { + return '\b'; + } + } + z = 0; +LAB_230224be: + buf = smp_create_pdu(smp,'\x03'); + if (buf == (net_buf *)0x0) { + return '\b'; + } + res = (u8_t *)net_buf_simple_add((net_buf_simple *)&buf->field_4,0x10); + iVar1 = smp_f4(sc_public_key,smp->pkey,smp->prnd,z,res); + if (iVar1 != 0) { + net_buf_unref(buf); + return '\b'; + } + smp_send(smp,buf,(bt_conn_tx_cb_t *)0x0); + atomic_and(smp->flags,-2); + return '\0'; +} + + + +void smp_ident_sent(bt_conn *conn,void *user_data) + +{ + if (conn->type == '\x01') { + smp_check_complete(conn,'\x01'); + return; + } + return; +} + + + +int smp_c1(u8_t *k,u8_t *r,u8_t *preq,u8_t *pres,bt_addr_le_t *ia,bt_addr_le_t *ra,u8_t *enc_data) + +{ + byte bVar1; + byte *pbVar2; + int iVar3; + byte *pbVar4; + byte *pbVar5; + byte local_40; + u8_t uStack63; + byte abStack62 [2]; + u8_t p1 [16]; + u8_t p2 [16]; + + local_40 = ia->type; + uStack63 = ra->type; + memcpy(&local_40 + 2,preq,7); + memcpy(p1 + 5,pres,7); + iVar3 = 0; + do { + pbVar2 = r + iVar3; + pbVar5 = &local_40 + iVar3; + pbVar4 = enc_data + iVar3; + iVar3 = iVar3 + 1; + *pbVar4 = *pbVar2 ^ *pbVar5; + } while (iVar3 != 0x10); + iVar3 = bt_encrypt_le(k,enc_data,enc_data); + if (iVar3 == 0) { + memcpy(p1 + 0xc,&ra->a,6); + memcpy(p2 + 2,&ia->a,6); + memset(p2 + 8,0,4); + pbVar2 = p1 + 0xc; + pbVar5 = enc_data; + while (enc_data + 0x10 != pbVar5) { + bVar1 = *pbVar2; + pbVar2 = pbVar2 + 1; + *pbVar5 = *pbVar5 ^ bVar1; + pbVar5 = pbVar5 + 1; + } + iVar3 = bt_encrypt_le(k,enc_data,enc_data); + } + return iVar3; +} + + + +u8_t legacy_send_pairing_confirm(bt_smp *smp) + +{ + net_buf *buf; + u8_t *enc_data; + int iVar1; + bt_conn *pbVar2; + + pbVar2 = (smp->chan).chan.conn; + buf = smp_create_pdu(smp,'\x03'); + if (buf != (net_buf *)0x0) { + enc_data = (u8_t *)net_buf_simple_add((net_buf_simple *)&buf->field_4,0x10); + iVar1 = smp_c1(smp->tk,smp->prnd,smp->preq,smp->prsp,(bt_addr_le_t *)(pbVar2->field_20 + 7), + (bt_addr_le_t *)(pbVar2->field_20 + 0xe),enc_data); + if (iVar1 == 0) { + smp_send(smp,buf,(bt_conn_tx_cb_t *)0x0); + atomic_and(smp->flags,-2); + return '\0'; + } + net_buf_unref(buf); + } + return '\b'; +} + + + +u8_t legacy_pairing_confirm(bt_smp *smp) + +{ + u8_t uVar1; + int bit; + + bit = 3; + if (((smp->chan).chan.conn)->role != '\0') { + bit = atomic_test_bit(smp->flags,9); + if (bit != 0) { + atomic_set_bit(smp->flags,0); + return '\0'; + } + bit = 4; + } + atomic_set_bit(&smp->allowed_cmds,bit); + uVar1 = legacy_send_pairing_confirm(smp); + return uVar1; +} + + + +u8_t smp_pairing_confirm(bt_smp *smp,net_buf *buf) + +{ + atomic_t *target; + u8_t uVar1; + int iVar2; + void *__src; + + __src = *(void **)&buf->field_4; + target = smp->flags; + atomic_and(target,-0x401); + memcpy(smp->pcnf,__src,0x10); + if (((smp->chan).chan.conn)->role == '\0') { + atomic_set_bit(&smp->allowed_cmds,4); + uVar1 = smp_send_pairing_random(smp); + return uVar1; + } + iVar2 = atomic_test_bit(target,5); + if (iVar2 != 0) { + if (smp->method == '\x01') { + iVar2 = atomic_test_bit(target,9); + if (iVar2 != 0) { + atomic_set_bit(target,0); + return '\0'; + } + } + else { + if (smp->method != '\x02') { + return '\b'; + } + } + atomic_set_bit(&smp->allowed_cmds,4); + uVar1 = smp_send_pairing_confirm(smp); + return uVar1; + } + uVar1 = legacy_pairing_confirm(smp); + return uVar1; +} + + + +u8_t smp_pairing_rsp(bt_smp *smp,net_buf *buf) + +{ + u8_t *__src; + u8_t uVar1; + _Bool _Var2; + undefined3 extraout_var; + int iVar3; + undefined3 extraout_var_00; + byte bVar4; + atomic_t *target; + bt_conn *pbVar5; + + __src = *(u8_t **)&buf->field_4; + if (9 < (byte)(__src[3] - 7)) { + return '\x06'; + } + pbVar5 = (smp->chan).chan.conn; + smp->local_dist = smp->local_dist & __src[4]; + smp->remote_dist = smp->remote_dist & __src[5]; + smp->prsp[0] = '\x02'; + memcpy(smp->prsp + 1,__src,6); + if (((__src[2] & 8) != 0) && ((smp->preq[3] & 8) != 0)) { + atomic_set_bit(smp->flags,5); + } + if (((__src[2] & 0x20) != 0) && ((smp->preq[3] & 0x20) != 0)) { + atomic_set_bit(smp->flags,0x13); + } + if (((__src[2] & 1) != 0) && ((smp->preq[3] & 1) != 0)) { + atomic_set_bit(smp->flags,0xc); + } + uVar1 = get_pair_method(smp,*__src); + smp->method = uVar1; + _Var2 = update_keys_check(smp); + if (CONCAT31(extraout_var,_Var2) == 0) { +LAB_23022832: + uVar1 = '\x03'; + } + else { + target = smp->flags; + iVar3 = atomic_test_bit(target,5); + uVar1 = smp->method; + if (iVar3 == 0) { + if (((uVar1 != '\0') || (iVar3 = atomic_test_bit(target,0xe), iVar3 == 0)) || + ((bt_auth == (bt_conn_auth_cb *)0x0 || + (bt_auth->pairing_confirm == (anon_subr_void_bt_conn_ptr_for_pairing_confirm *)0x0)))) { + uVar1 = legacy_request_tk(smp); + if (CONCAT31(extraout_var_00,uVar1) != 0) { + return uVar1; + } + iVar3 = atomic_test_bit(target,9); + if (iVar3 == 0) { + atomic_set_bit(&smp->allowed_cmds,3); + uVar1 = legacy_send_pairing_confirm(smp); + return uVar1; + } + atomic_set_bit(target,0); + return uVar1; + } + } + else { + if (pbVar5->required_sec_level == BT_SECURITY_L4) { + if (uVar1 == '\0') goto LAB_23022832; + bVar4 = smp->prsp[4]; + if (smp->preq[4] < smp->prsp[4]) { + bVar4 = smp->preq[4]; + } + if (bVar4 != 0x10) { + return '\x06'; + } + } + *(ushort *)&smp->local_dist = *(ushort *)&smp->local_dist & 0x604; + if ((((uVar1 != '\0') || (iVar3 = atomic_test_bit(target,0xe), iVar3 == 0)) || + (bt_auth == (bt_conn_auth_cb *)0x0)) || + (bt_auth->pairing_confirm == (anon_subr_void_bt_conn_ptr_for_pairing_confirm *)0x0)) { + if (sc_public_key != (u8_t *)0x0) { + atomic_set_bit(&smp->allowed_cmds,0xc); + atomic_and(&smp->allowed_cmds,-0x801); + uVar1 = sc_send_public_key(smp); + return uVar1; + } + atomic_set_bit(target,6); + return '\0'; + } + } + atomic_set_bit(target,9); + (*bt_auth->pairing_confirm)((smp->chan).chan.conn); + } + return uVar1; +} + + + +u8_t smp_ident_addr_info(bt_smp *smp,net_buf *buf) + +{ + byte bVar1; + bt_conn *conn; + u8_t uVar2; + char *pcVar3; + int iVar4; + bt_keys *keys; + undefined3 extraout_var; + byte *pbVar5; + bt_addr_le_t *addr; + bt_addr_le_t *addr_00; + + addr = *(bt_addr_le_t **)&buf->field_4; + conn = (smp->chan).chan.conn; + if ((addr->type == '\0') || (((addr->a).val[5] & 0xc0) == 0xc0)) { + iVar4 = atomic_test_bit(smp->flags,0xc); + if (iVar4 != 0) { + addr_00 = (bt_addr_le_t *)conn->field_20; + keys = bt_keys_get_type(2,conn->id,addr_00); + if (keys == (bt_keys *)0x0) { + pcVar3 = bt_addr_le_str_real(addr_00); + printf("Unable to get keys for %s\r\n",pcVar3); + return '\b'; + } + pbVar5 = conn->field_20 + 7; + if (conn->role == '\0') { + pbVar5 = conn->field_20 + 0xe; + } + if ((((*pbVar5 == 1) && ((pbVar5[6] & 0xc0) == 0x40)) && + (memcpy(&(keys->irk).rpa,pbVar5 + 1,6), conn->field_20[0] != 0)) && + ((conn->field_20[6] & 0xc0) != 0xc0)) { + memcpy(&keys->addr,addr,7); + memcpy(addr_00,addr,7); + bt_conn_identity_resolved(conn); + } + bt_id_add(keys); + } + bVar1 = smp->remote_dist; + smp->remote_dist = bVar1 & 0xfd; + if ((bVar1 & 4) != 0) { + atomic_set_bit(&smp->allowed_cmds,10); + } + if (((conn->role != '\0') || (smp->remote_dist != '\0')) || + (uVar2 = bt_smp_distribute_keys(smp), CONCAT31(extraout_var,uVar2) == 0)) { + if (*(short *)&smp->local_dist == 0) { + smp_pairing_complete(smp,'\0'); + } + uVar2 = '\0'; + } + } + else { + pcVar3 = bt_addr_le_str_real(addr); + printf("Invalid identity %s\r\n",pcVar3); + pcVar3 = bt_addr_le_str_real((bt_addr_le_t *)conn->field_20); + printf(" for %s\r\n",pcVar3); + uVar2 = '\n'; + } + return uVar2; +} + + + +u8_t smp_public_key_slave(bt_smp *smp) + +{ + u8_t uVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + int bit; + + switch(smp->method) { + case '\0': + case '\x03': + atomic_set_bit(&smp->allowed_cmds,4); + uVar1 = smp_send_pairing_confirm(smp); + if (CONCAT31(extraout_var,uVar1) != 0) { + return uVar1; + } + goto LAB_23022b04; + case '\x01': + atomic_set_bit(&smp->allowed_cmds,3); + atomic_set_bit(smp->flags,9); + (*bt_auth->passkey_entry)((smp->chan).chan.conn); + goto LAB_23022b04; + case '\x02': + uVar1 = display_passkey(smp); + bit = 3; + if (CONCAT31(extraout_var_00,uVar1) != 0) { + return uVar1; + } + break; + case '\x04': + return '\b'; + case '\x05': + bit = 4; + break; + default: + return '\b'; + } + atomic_set_bit(&smp->allowed_cmds,bit); +LAB_23022b04: + bit = bt_dh_key_gen(smp->pkey,bt_smp_dhkey_ready); + uVar1 = '\b'; + if (bit == 0) { + atomic_set_bit(smp->flags,7); + uVar1 = '\0'; + } + return uVar1; +} + + + +// WARNING: Variable defined which should be unmapped: info +// WARNING: Type propagation algorithm not settling + +u8_t smp_public_key(bt_smp *smp,net_buf *buf) + +{ + void *__src; + bt_conn *pbVar1; + u8_t uVar2; + int bit; + bt_keys *pbVar3; + int iVar4; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + u8_t *remote_pk; + bt_conn_oob_info abStack20 [2]; + bt_conn_oob_info info; + + __src = *(void **)&buf->field_4; + remote_pk = smp->pkey; + memcpy(remote_pk,__src,0x20); + memcpy(smp->pkey + 0x20,(void *)((int)__src + 0x20),0x20); + bit = memcmp(remote_pk,sc_debug_public_key,0x40); + if (bit == 0) { + atomic_set_bit(smp->flags,0xd); + pbVar1 = (smp->chan).chan.conn; + if (*(int *)(pbVar1->field_20 + 0x2c) == 0) { + pbVar3 = bt_keys_get_addr(pbVar1->id,(bt_addr_le_t *)pbVar1->field_20); + *(bt_keys **)(pbVar1->field_20 + 0x2c) = pbVar3; + } + bit = *(int *)(pbVar1->field_20 + 0x2c); + if (((bit != 0) && ((*(ushort *)(bit + 10) & 0x24) != 0)) && ((*(byte *)(bit + 9) & 2) != 0)) { + return '\x03'; + } + } + if (((smp->chan).chan.conn)->role != '\0') { + if (sc_public_key != (u8_t *)0x0) { + uVar2 = sc_send_public_key(smp); + if (CONCAT31(extraout_var_01,uVar2) != 0) { + return uVar2; + } + uVar2 = smp_public_key_slave(smp); + return uVar2; + } + bit = 6; + goto LAB_23022c0c; + } + switch(smp->method) { + case '\0': + case '\x03': + atomic_set_bit(&smp->allowed_cmds,3); + break; + case '\x01': + atomic_set_bit(smp->flags,9); + (*bt_auth->passkey_entry)((smp->chan).chan.conn); + break; + case '\x02': + uVar2 = display_passkey(smp); + if (CONCAT31(extraout_var,uVar2) != 0) { + return uVar2; + } + atomic_set_bit(&smp->allowed_cmds,3); + uVar2 = smp_send_pairing_confirm(smp); + if (CONCAT31(extraout_var_00,uVar2) != 0) { + return uVar2; + } + break; + default: + goto switchD_23022bee_caseD_4; + case '\x05': + bit = bt_rand(smp->prnd,0x10); + if (bit == 0) { + if (bt_auth == (bt_conn_auth_cb *)0x0) { + return '\x02'; + } + if (bt_auth->oob_data_request == + (anon_subr_void_bt_conn_ptr_bt_conn_oob_info_ptr_for_oob_data_request *)0x0) { + return '\x02'; + } + abStack20[0] = (bt_conn_oob_info)0x301; + le_sc_oob_config_set_isra_3_constprop_19(smp,&abStack20[0].field_1); + smp->oobd_local = (bt_le_oob_sc_data *)0x0; + smp->oobd_remote = (bt_le_oob_sc_data *)0x0; + atomic_set_bit(smp->flags,0xb); + (*bt_auth->oob_data_request)((smp->chan).chan.conn,abStack20); + break; + } + goto switchD_23022bee_caseD_4; + } + iVar4 = bt_dh_key_gen(remote_pk,bt_smp_dhkey_ready); + bit = 7; + if (iVar4 == 0) { +LAB_23022c0c: + atomic_set_bit(smp->flags,bit); + uVar2 = '\0'; + } + else { +switchD_23022bee_caseD_4: + uVar2 = '\b'; + } + return uVar2; +} + + + +void bt_smp_pkey_ready(u8_t *pkey) + +{ + u8_t reason; + int iVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + + sc_public_key = pkey; + if (pkey == (u8_t *)0x0) { + printf("Public key not available\r\n"); + return; + } + k_sem_give(&sc_local_pkey_ready); + iVar1 = atomic_test_bit(bt_smp_pool[0].flags,6); + if (iVar1 != 0) { + if ((bt_smp_pool[0].chan.chan.conn)->role == '\0') { + reason = sc_send_public_key(bt_smp_pool); + if (CONCAT31(extraout_var_02,reason) != 0) { + smp_error(bt_smp_pool,reason); + } + atomic_set_bit(&bt_smp_pool[0].allowed_cmds,0xc); + } + else { + reason = sc_send_public_key(bt_smp_pool); + if ((CONCAT31(extraout_var,reason) != 0) || + (reason = smp_public_key_slave(bt_smp_pool), CONCAT31(extraout_var_01,reason) != 0)) { + smp_error(bt_smp_pool,reason); + } + } + } + iVar1 = atomic_test_bit(bt_smp_pool[1].flags,6); + if (iVar1 != 0) { + if ((bt_smp_pool[1].chan.chan.conn)->role == '\0') { + reason = sc_send_public_key(bt_smp_pool + 1); + if (CONCAT31(extraout_var_00,reason) != 0) { + smp_error(bt_smp_pool + 1,reason); + } + atomic_set_bit(&bt_smp_pool[1].allowed_cmds,0xc); + return; + } + reason = sc_send_public_key(bt_smp_pool + 1); + if ((CONCAT31(extraout_var_03,reason) != 0) || + (reason = smp_public_key_slave(bt_smp_pool + 1), CONCAT31(extraout_var_04,reason) != 0)) { + smp_error(bt_smp_pool + 1,reason); + return; + } + } + return; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +u8_t smp_pairing_random(bt_smp *smp,net_buf *buf) + +{ + u8_t uVar1; + int bit; + undefined3 extraout_var; + int iVar2; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + uint len; + u8_t uVar3; + atomic_t *target; + u8_t *x; + bt_conn *conn; + u8_t *k; + u8_t auStack60 [4]; + u8_t ediv [2]; + u8_t rand [8]; + u32_t_conflict passkey; + undefined auStack40 [8]; + + x = smp->rrnd; + memcpy(x,*(void **)&buf->field_4,0x10); + target = smp->flags; + bit = atomic_test_bit(target,5); + conn = (smp->chan).chan.conn; + if (bit == 0) { + k = smp->tk; + bit = smp_c1(k,x,smp->preq,smp->prsp,(bt_addr_le_t *)(conn->field_20 + 7), + (bt_addr_le_t *)(conn->field_20 + 0xe),rand + 4); + if (bit != 0) { + return '\b'; + } + bit = memcmp(smp->pcnf,rand + 4,0x10); + if (bit != 0) { + return '\x04'; + } + uVar1 = conn->role; + if (uVar1 != '\0') { + memcpy(rand + 4,x,8); + memcpy(auStack40,smp->prnd,8); + bit = bt_encrypt_le(k,rand + 4,rand + 4); + if (bit != 0) { + return '\b'; + } + memcpy(k,rand + 4,0x10); + bit = 1; +LAB_23022ed6: + atomic_set_bit(target,bit); + uVar1 = smp_send_pairing_random(smp); + return uVar1; + } + memcpy(rand + 4,smp->prnd,8); + memcpy(auStack40,x,8); + bit = bt_encrypt_le(k,rand + 4,rand + 4); + if (bit != 0) { + return '\b'; + } + memset(auStack60,0,2); + memset(ediv,0,8); + len = (uint)smp->prsp[4]; + if ((uint)smp->preq[4] < (uint)smp->prsp[4]) { + len = (uint)smp->preq[4]; + } + bit = bt_conn_le_start_encryption(conn,ediv,auStack60,rand + 4,len); + if (bit != 0) { + printf("Failed to start encryption\r\n"); + return '\b'; + } + bit = 1; +LAB_23022ea4: + atomic_set_bit(target,bit); + return uVar1; + } + if (conn->role == '\0') { + uVar1 = sc_smp_check_confirm(smp); + if (CONCAT31(extraout_var,uVar1) != 0) { + return uVar1; + } + switch(smp->method) { + case '\x01': + case '\x02': + uVar3 = smp->passkey_round + '\x01'; + smp->passkey_round = uVar3; + if (uVar3 != '\x14') { + bit = bt_rand(smp->prnd,0x10); + if (bit != 0) { + return '\b'; + } + atomic_set_bit(&smp->allowed_cmds,3); + uVar1 = smp_send_pairing_confirm(smp); + return uVar1; + } + case '\0': + case '\x05': + iVar2 = atomic_test_bit(target,7); + bit = 8; + if (iVar2 == 0) { + uVar1 = compute_and_send_master_dhcheck(smp); + return uVar1; + } + goto LAB_23022ea4; + case '\x03': + bit = smp_g2(sc_public_key,smp->pkey,smp->prnd,x,(u32_t_conflict *)(rand + 4)); + if (bit == 0) { + atomic_set_bit(target,9); + atomic_set_bit(target,8); + (*bt_auth->passkey_confirm)((smp->chan).chan.conn,rand._4_4_); + return uVar1; + } + } + } + else { + switch(smp->method) { + case '\x01': + case '\x02': + uVar1 = sc_smp_check_confirm(smp); + if (CONCAT31(extraout_var_00,uVar1) != 0) { + return uVar1; + } + atomic_set_bit(&smp->allowed_cmds,3); + uVar1 = smp_send_pairing_random(smp); + if (CONCAT31(extraout_var_01,uVar1) != 0) { + return uVar1; + } + uVar3 = smp->passkey_round + '\x01'; + smp->passkey_round = uVar3; + if (uVar3 != '\x14') { + bit = bt_rand(smp->prnd,0x10); + if (bit != 0) { + return '\b'; + } + return uVar1; + } + atomic_set_bit(&smp->allowed_cmds,0xd); + bit = 0xf; + goto LAB_23022ea4; + case '\x03': + bit = smp_g2(smp->pkey,sc_public_key,x,smp->prnd,(u32_t_conflict *)(rand + 4)); + if (bit != 0) { + return '\b'; + } + atomic_set_bit(target,9); + (*bt_auth->passkey_confirm)((smp->chan).chan.conn,rand._4_4_); + case '\0': + atomic_set_bit(&smp->allowed_cmds,0xd); + bit = 0xf; + goto LAB_23022ed6; + case '\x05': + bit = bt_rand(smp->prnd,0x10); + if (bit == 0) { + if (bt_auth == (bt_conn_auth_cb *)0x0) { + return '\x02'; + } + if (bt_auth->oob_data_request == + (anon_subr_void_bt_conn_ptr_bt_conn_oob_info_ptr_for_oob_data_request *)0x0) { + return '\x02'; + } + rand._4_4_ = CONCAT22(rand._6_2_,0x301); + le_sc_oob_config_set_isra_3_constprop_19(smp,rand + 5); + smp->oobd_local = (bt_le_oob_sc_data *)0x0; + smp->oobd_remote = (bt_le_oob_sc_data *)0x0; + atomic_set_bit(target,0xb); + (*bt_auth->oob_data_request)((smp->chan).chan.conn,(bt_conn_oob_info *)(rand + 4)); + return '\0'; + } + } + } + return '\b'; +} + + + +// WARNING: Type propagation algorithm not settling + +_Bool bt_smp_request_ltk(bt_conn *conn,u16_t ediv,u8_t *ltk) + +{ + byte bVar1; + uint __n; + bt_smp *smp; + int iVar2; + bt_keys *pbVar3; + undefined2 in_register_0000202e; + short in_a3; + void *in_a4; + short sStack42; + uint uStack40; + u8_t *puStack36; + + uStack40 = CONCAT22(in_register_0000202e,ediv); + sStack42 = in_a3; + puStack36 = ltk; + smp = smp_chan_get(conn); + if (smp == (bt_smp *)0x0) { + return false; + } + if ((sStack42 == 0) && ((uStack40 | (uint)puStack36) == 0)) { + iVar2 = atomic_test_bit(smp->flags,3); + if ((iVar2 != 0) && (iVar2 = atomic_test_bit(smp->flags,1), iVar2 != 0)) { + __n = (uint)smp->prsp[4]; + if ((uint)smp->preq[4] < (uint)smp->prsp[4]) { + __n = (uint)smp->preq[4]; + } + memcpy(in_a4,smp->tk,__n); + if (__n < 0x10) { + memset((void *)((int)in_a4 + __n),0,0x10 - __n); + } + goto LAB_2302311c; + } + } + if (*(int *)(conn->field_20 + 0x2c) == 0) { + pbVar3 = bt_keys_find(0x20,conn->id,(bt_addr_le_t *)conn->field_20); + *(bt_keys **)(conn->field_20 + 0x2c) = pbVar3; + if (pbVar3 == (bt_keys *)0x0) { + pbVar3 = bt_keys_find(1,conn->id,(bt_addr_le_t *)conn->field_20); + *(bt_keys **)(conn->field_20 + 0x2c) = pbVar3; + } + } + iVar2 = *(int *)(conn->field_20 + 0x2c); + if ((sStack42 == 0) && ((uStack40 | (uint)puStack36) == 0)) { + if (iVar2 == 0) goto LAB_23023202; + if ((*(ushort *)(iVar2 + 10) & 0x20) != 0) { + bVar1 = *(byte *)(iVar2 + 8); + __n = (uint)bVar1; + memcpy(in_a4,(void *)(iVar2 + 0x16),__n); + if (bVar1 < 0x10) { + memset((void *)((int)in_a4 + __n),0,0x10 - __n); + return true; + } + return true; + } + } + else { + if (iVar2 == 0) goto LAB_23023202; + } + if ((((*(ushort *)(iVar2 + 10) & 1) != 0) && + (iVar2 = memcmp((void *)(iVar2 + 100),&uStack40,8), iVar2 == 0)) && + (iVar2 = memcmp((void *)(*(int *)(conn->field_20 + 0x2c) + 0x6c),&sStack42,2), iVar2 == 0)) { + bVar1 = *(byte *)(*(int *)(conn->field_20 + 0x2c) + 8); + __n = (uint)bVar1; + memcpy(in_a4,(void *)(*(int *)(conn->field_20 + 0x2c) + 0x6e),__n); + if (bVar1 < 0x10) { + memset((void *)((int)in_a4 + __n),0,0x10 - __n); + } +LAB_2302311c: + atomic_set_bit(smp->flags,1); + return true; + } +LAB_23023202: + iVar2 = atomic_test_bit(smp->flags,0xe); + if (iVar2 != 0) { + bt_conn_security_changed((smp->chan).chan.conn,2); + } + smp_reset(smp); + return false; +} + + + +// WARNING: Variable defined which should be unmapped: sig + +int bt_smp_sign_verify(bt_conn *conn,net_buf *buf) + +{ + bt_keys *pbVar1; + char *pcVar2; + int iVar3; + bt_addr_le_t *addr; + u32_t_conflict local_20; + u32_t_conflict cnt; + u8_t sig [12]; + + memcpy(&cnt,(void *)(*(int *)&buf->field_4 + ((uint)*(ushort *)((int)&buf->field_4 + 4) - 0xc)), + 0xc); + addr = (bt_addr_le_t *)conn->field_20; + pbVar1 = bt_keys_find(0x10,conn->id,addr); + if (pbVar1 == (bt_keys *)0x0) { + pcVar2 = bt_addr_le_str_real(addr); + printf("Unable to find Remote CSRK for %s\r\n",pcVar2); + iVar3 = -2; + } + else { + local_20 = (pbVar1->remote_csrk).cnt; + memcpy((void *)(*(int *)&buf->field_4 + ((uint)*(ushort *)((int)&buf->field_4 + 4) - 0xc)), + &local_20,4); + iVar3 = smp_sign_buf((u8_t *)&pbVar1->remote_csrk,*(u8_t **)&buf->field_4, + (u16_t)(((uint)*(ushort *)((int)&buf->field_4 + 4) - 0xc) * 0x10000 >> 0x10 + )); + if (iVar3 == 0) { + iVar3 = memcmp(&cnt,(void *)(*(int *)&buf->field_4 + + ((uint)*(ushort *)((int)&buf->field_4 + 4) - 0xc)),0xc); + if (iVar3 == 0) { + (pbVar1->remote_csrk).cnt = (pbVar1->remote_csrk).cnt + 1; + } + else { + pcVar2 = bt_addr_le_str_real(addr); + printf("Unable to verify signature for %s\r\n",pcVar2); + iVar3 = -0x4d; + } + } + else { + pcVar2 = bt_addr_le_str_real(addr); + printf("Unable to create signature for %s\r\n",pcVar2); + iVar3 = -5; + } + } + return iVar3; +} + + + +// WARNING: Variable defined which should be unmapped: cnt + +int bt_smp_sign(bt_conn *conn,net_buf *buf) + +{ + bt_keys *pbVar1; + char *pcVar2; + int iVar3; + bt_addr_le_t *addr; + u32_t_conflict uStack20; + u32_t_conflict cnt; + + addr = (bt_addr_le_t *)conn->field_20; + pbVar1 = bt_keys_find(8,conn->id,addr); + if (pbVar1 == (bt_keys *)0x0) { + pcVar2 = bt_addr_le_str_real(addr); + printf("Unable to find local CSRK for %s\r\n",pcVar2); + iVar3 = -2; + } + else { + net_buf_simple_add((net_buf_simple *)&buf->field_4,0xc); + uStack20 = (pbVar1->local_csrk).cnt; + memcpy((void *)(*(int *)&buf->field_4 + ((uint)*(ushort *)((int)&buf->field_4 + 4) - 0xc)), + &uStack20,4); + iVar3 = smp_sign_buf((u8_t *)&pbVar1->local_csrk,*(u8_t **)&buf->field_4, + (u16_t)(((uint)*(ushort *)((int)&buf->field_4 + 4) - 0xc) * 0x10000 >> 0x10 + )); + if (iVar3 == 0) { + (pbVar1->local_csrk).cnt = (pbVar1->local_csrk).cnt + 1; + } + else { + pcVar2 = bt_addr_le_str_real(addr); + printf("Unable to create signature for %s\r\n",pcVar2); + iVar3 = -5; + } + } + return iVar3; +} + + + +// WARNING: Type propagation algorithm not settling + +int bt_smp_auth_passkey_entry(bt_conn *conn,uint passkey) + +{ + u8_t uVar1; + bt_smp *smp; + int bit; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + bt_conn *pbVar2; + atomic_t *target; + uint auStack36 [4]; + + smp = smp_chan_get(conn); + if (smp == (bt_smp *)0x0) { + return -0x16; + } + target = smp->flags; + bit = atomic_test_and_clear_bit(target,9); + if (bit == 0) { + return 0xffffffea; + } + bit = atomic_test_bit(target,5); + if (bit == 0) { + auStack36[0] = passkey; + memcpy(smp->tk,auStack36,4); + bit = atomic_test_and_clear_bit(target,0); + if (bit == 0) { + return 0; + } + uVar1 = legacy_pairing_confirm(smp); + if (CONCAT31(extraout_var,uVar1) == 0) { + bit = 3; + if (((smp->chan).chan.conn)->role != '\0') { + bit = 4; + } + atomic_set_bit(&smp->allowed_cmds,bit); + return 0; + } + smp_error(smp,'\x01'); + return 0; + } + pbVar2 = (smp->chan).chan.conn; + smp->passkey = passkey; + if (pbVar2->role == '\0') { + uVar1 = smp_send_pairing_confirm(smp); + if (CONCAT31(extraout_var_00,uVar1) == 0) { + bit = 3; +LAB_2302342c: + atomic_set_bit(&smp->allowed_cmds,bit); + return 0; + } + } + else { + bit = atomic_test_bit(target,0); + if (bit == 0) { + return 0; + } + uVar1 = smp_send_pairing_confirm(smp); + bit = 4; + if (CONCAT31(extraout_var_01,uVar1) == 0) goto LAB_2302342c; + } + smp_error(smp,'\x01'); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling + +int bt_smp_auth_passkey_confirm(bt_conn *conn) + +{ + atomic_t *target; + u8_t uVar1; + bt_smp *smp; + int iVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + + smp = smp_chan_get(conn); + if (smp != (bt_smp *)0x0) { + target = smp->flags; + iVar2 = atomic_test_and_clear_bit(target,9); + if (iVar2 != 0) { + iVar2 = atomic_test_bit(target,7); + if ((iVar2 != 0) || (iVar2 = atomic_test_bit(target,0xf), iVar2 != 0)) { + atomic_set_bit(target,8); + return 0; + } + iVar2 = atomic_test_bit(target,8); + if (iVar2 == 0) { + return 0; + } + if (((smp->chan).chan.conn)->role == '\0') { + uVar1 = compute_and_send_master_dhcheck(smp); + iVar2 = CONCAT31(extraout_var,uVar1); + } + else { + uVar1 = compute_and_check_and_send_slave_dhcheck(smp); + iVar2 = CONCAT31(extraout_var_00,uVar1); + } + if (iVar2 == 0) { + return 0; + } + smp_error(smp,(u8_t)iVar2); + return 0; + } + } + return -0x16; +} + + + +int bt_smp_auth_cancel(bt_conn *conn) + +{ + bt_smp *smp; + int iVar1; + u8_t reason; + + smp = smp_chan_get(conn); + if ((smp != (bt_smp *)0x0) && (iVar1 = atomic_test_and_clear_bit(smp->flags,9), iVar1 != 0)) { + switch(smp->method) { + case '\0': + reason = '\b'; + break; + case '\x01': + case '\x02': + reason = '\x01'; + break; + case '\x03': + reason = '\x04'; + break; + default: + return 0; + case '\x05': + reason = '\x02'; + } + iVar1 = smp_error(smp,reason); + return iVar1; + } + return -0x16; +} + + + +int bt_smp_auth_pairing_confirm(bt_conn *conn) + +{ + atomic_t *target; + u8_t uVar1; + bt_smp *smp; + int iVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + + smp = smp_chan_get(conn); + if (smp != (bt_smp *)0x0) { + target = smp->flags; + iVar2 = atomic_test_and_clear_bit(target,9); + if (iVar2 != 0) { + if (conn->role != '\0') { + iVar2 = atomic_test_bit(target,5); + if (iVar2 == 0) { + atomic_set_bit(&smp->allowed_cmds,3); + uVar1 = send_pairing_rsp(smp); + return CONCAT31(extraout_var_01,uVar1); + } + atomic_set_bit(&smp->allowed_cmds,0xc); + uVar1 = send_pairing_rsp(smp); + if (CONCAT31(extraout_var_02,uVar1) == 0) { + return 0; + } + return -5; + } + iVar2 = atomic_test_bit(target,5); + if (iVar2 == 0) { + atomic_set_bit(&smp->allowed_cmds,3); + uVar1 = legacy_send_pairing_confirm(smp); + return CONCAT31(extraout_var,uVar1); + } + if (sc_public_key != (u8_t *)0x0) { + atomic_set_bit(&smp->allowed_cmds,0xc); + uVar1 = sc_send_public_key(smp); + return CONCAT31(extraout_var_00,uVar1); + } + atomic_set_bit(target,6); + return 0; + } + } + return -0x16; +} + + + +int bt_smp_start_security(bt_conn *conn) + +{ + int iVar1; + _Bool _Var2; + u8_t uVar3; + undefined3 extraout_var; + atomic_t *target; + bt_smp *smp; + undefined3 extraout_var_00; + bt_keys *pbVar4; + undefined3 extraout_var_01; + net_buf *buf; + u8_t *puVar5; + + if (conn->role == '\0') { + smp = smp_chan_get(conn); + if (smp != (bt_smp *)0x0) { + iVar1 = atomic_test_bit(conn->flags,0xb); + if ((iVar1 != 0) || (_Var2 = smp_keys_check(conn), CONCAT31(extraout_var,_Var2) == 0)) { + iVar1 = smp_send_pairing_req(conn); + return iVar1; + } + target = smp->flags; + iVar1 = atomic_test_bit(target,3); + if ((iVar1 != 0) || (iVar1 = atomic_test_bit(target,1), iVar1 != 0)) { + return -0x10; + } + iVar1 = *(int *)(conn->field_20 + 0x2c); + iVar1 = bt_conn_le_start_encryption + (conn,(u8_t *)(iVar1 + 0xc),(u8_t *)(iVar1 + 0x14),(u8_t *)(iVar1 + 0x16), + (uint)*(byte *)(iVar1 + 8)); + if (iVar1 != 0) { + return iVar1; + } + atomic_set_bit(&smp->allowed_cmds,0xb); +LAB_23023682: + atomic_set_bit(target,1); + return iVar1; + } +LAB_230235fe: + iVar1 = -0x39; + } + else { + if (conn->role == '\x01') { + smp = smp_chan_get(conn); + if (smp == (bt_smp *)0x0) goto LAB_230235fe; + target = smp->flags; + iVar1 = atomic_test_bit(target,4); + if (iVar1 != 0) { + return -5; + } + iVar1 = atomic_test_bit(target,3); + if (iVar1 != 0) { + return -0x10; + } + iVar1 = atomic_test_bit(target,1); + if (iVar1 != 0) { + return -0x10; + } + _Var2 = sec_level_reachable(); + if ((CONCAT31(extraout_var_00,_Var2) != 0) || + ((iVar1 = atomic_test_bit(conn->flags,0xb), iVar1 == 0 && + (_Var2 = smp_keys_check(conn), CONCAT31(extraout_var_01,_Var2) != 0)))) { + if (*(int *)(conn->field_20 + 0x2c) == 0) { + pbVar4 = bt_keys_get_addr(conn->id,(bt_addr_le_t *)conn->field_20); + *(bt_keys **)(conn->field_20 + 0x2c) = pbVar4; + if (pbVar4 == (bt_keys *)0x0) { + return -0xc; + } + } + iVar1 = smp_init(smp); + if ((iVar1 != 0) || (buf = smp_create_pdu(smp,'\v'), buf == (net_buf *)0x0)) { + return -0x37; + } + puVar5 = (u8_t *)net_buf_simple_add((net_buf_simple *)&buf->field_4,1); + uVar3 = get_auth((char)conn + '\n'); + *puVar5 = uVar3; + bt_l2cap_send_cb(conn,6,buf,(bt_conn_tx_cb_t *)0x0,(void *)0x0); + atomic_set_bit(target,0xe); + target = &smp->allowed_cmds; + goto LAB_23023682; + } + } + iVar1 = -0x16; + } + return iVar1; +} + + + +void bt_smp_update_keys(bt_conn *conn) + +{ + bt_smp *smp; + int iVar1; + bt_keys *pbVar2; + char *pcVar3; + byte bVar4; + int iVar5; + atomic_t *target; + + smp = smp_chan_get(conn); + if (smp != (bt_smp *)0x0) { + target = smp->flags; + iVar1 = atomic_test_bit(target,3); + if (iVar1 != 0) { + if (*(bt_keys **)(conn->field_20 + 0x2c) != (bt_keys *)0x0) { + bt_keys_clear(*(bt_keys **)(conn->field_20 + 0x2c)); + } + pbVar2 = bt_keys_get_addr(conn->id,(bt_addr_le_t *)conn->field_20); + *(bt_keys **)(conn->field_20 + 0x2c) = pbVar2; + if (pbVar2 == (bt_keys *)0x0) { + pcVar3 = bt_addr_le_str_real((bt_addr_le_t *)conn->field_20); + printf("Unable to get keys for %s\r\n",pcVar3); + smp_error(smp,'\b'); + return; + } + iVar1 = atomic_test_bit(target,0xd); + if (iVar1 != 0) { + *(byte *)(*(int *)(conn->field_20 + 0x2c) + 9) = + *(byte *)(*(int *)(conn->field_20 + 0x2c) + 9) | 2; + } + bVar4 = *(byte *)(*(int *)(conn->field_20 + 0x2c) + 9); + if ((smp->method < 6) && ((1 << ((uint)smp->method & 0x1f) & 0x2eU) != 0)) { + bVar4 = bVar4 | 1; + } + else { + bVar4 = bVar4 & 0xfe; + } + *(byte *)(*(int *)(conn->field_20 + 0x2c) + 9) = bVar4; + bVar4 = smp->preq[4]; + if (smp->prsp[4] < smp->preq[4]) { + bVar4 = smp->prsp[4]; + } + *(byte *)(*(int *)(conn->field_20 + 0x2c) + 8) = bVar4; + iVar1 = atomic_test_bit(target,5); + iVar5 = *(int *)(conn->field_20 + 0x2c); + if (iVar1 == 0) { + *(byte *)(iVar5 + 9) = *(byte *)(iVar5 + 9) & 0xef; + } + else { + *(byte *)(iVar5 + 9) = *(byte *)(iVar5 + 9) | 0x10; + iVar1 = atomic_test_bit(target,0xc); + if (iVar1 != 0) { + bt_keys_add_type(*(bt_keys **)(conn->field_20 + 0x2c),0x20); + memcpy((void *)(*(int *)(conn->field_20 + 0x2c) + 0x16),smp->tk,0x10); + memset((void *)(*(int *)(conn->field_20 + 0x2c) + 0xc),0,8); + memset((void *)(*(int *)(conn->field_20 + 0x2c) + 0x14),0,2); + return; + } + } + } + } + return; +} + + + +int bt_smp_init(void) + +{ + bt_pub_key_cb pub_key_cb; + + k_sem_init(&sc_local_pkey_ready,0,1); + sc_supported = (_Bool)((bt_dev.supported_commands[34] & 6) == 6); + bt_pub_key_gen((bt_pub_key_cb *)&ram0x4200dbb8); + return 0; +} + + + +bt_keys * bt_keys_find_addr(u8_t id,bt_addr_le_t *addr) + +{ + undefined3 in_register_00002029; + int iVar1; + + if (((uint)key_pool[0].id != CONCAT31(in_register_00002029,id)) || + (iVar1 = memcmp(&key_pool[0].addr,addr,7), iVar1 != 0)) { + if (((uint)key_pool[1].id != CONCAT31(in_register_00002029,id)) || + (iVar1 = memcmp(&key_pool[1].addr,addr,7), iVar1 != 0)) { + return (bt_keys *)0x0; + } + iVar1 = 1; + } + return key_pool + iVar1; +} + + + +bt_keys * bt_keys_find(int type,u8_t id,bt_addr_le_t *addr) + +{ + int iVar1; + undefined3 in_register_0000202d; + + if (((((uint)key_pool[0].keys & type) == 0) || + ((uint)key_pool[0].id != CONCAT31(in_register_0000202d,id))) || + (iVar1 = memcmp(&key_pool[0].addr,addr,7), iVar1 != 0)) { + if (((((uint)key_pool[1].keys & type) == 0) || + ((uint)key_pool[1].id != CONCAT31(in_register_0000202d,id))) || + (iVar1 = memcmp(&key_pool[1].addr,addr,7), iVar1 != 0)) { + return (bt_keys *)0x0; + } + iVar1 = 0x84; + } + else { + iVar1 = 0; + } + return (bt_keys *)(&key_pool[0].id + iVar1); +} + + + +bt_keys * bt_keys_get_addr(u8_t id,bt_addr_le_t *addr) + +{ + uint uVar1; + bt_keys *pbVar2; + undefined3 in_register_00002029; + int iVar3; + undefined4 local_30; + undefined2 uStack44; + undefined uStack42; + undefined4 uStack40; + undefined2 uStack36; + undefined uStack34; + + if (((uint)key_pool[0].id == CONCAT31(in_register_00002029,id)) && + (iVar3 = memcmp(&key_pool[0].addr,addr,7), iVar3 == 0)) { + iVar3 = 0; + } + else { + local_30 = 0; + uStack44 = 0; + uStack42 = 0; + iVar3 = memcmp(&key_pool[0].addr,&local_30,7); + uVar1 = 0; + if (iVar3 != 0) { + uVar1 = (uint)(key_pool[0].enc_size != '\0') << 1; + } + if (((uint)key_pool[1].id != CONCAT31(in_register_00002029,id)) || + (iVar3 = memcmp(&key_pool[1].addr,addr,7), iVar3 != 0)) { + if (uVar1 == 2) { + local_30 = 0; + uStack44 = 0; + uStack42 = 0; + iVar3 = memcmp(&key_pool[1].addr,&local_30,7); + if ((iVar3 == 0) || (key_pool[1].enc_size == '\0')) { + uVar1 = 1; + } + else { + pbVar2 = key_pool + 1; + if (key_pool[0].aging_counter <= key_pool[1].aging_counter) { + pbVar2 = key_pool; + } + bt_unpair(pbVar2->id,&pbVar2->addr); + uStack40 = 0; + uStack36 = 0; + uStack34 = 0; + iVar3 = memcmp(&pbVar2->addr,&uStack40,7); + if (iVar3 != 0) { + return (bt_keys *)0x0; + } + uVar1 = ((int)pbVar2[-0x80022a].slave_ltk.ediv >> 2) * 0x3e0f83e1; + if (1 < uVar1) { + return (bt_keys *)0x0; + } + } + } + pbVar2 = key_pool + uVar1; + pbVar2->id = id; + memcpy(&key_pool[uVar1].addr,addr,7); + aging_counter_val = aging_counter_val + 1; + key_pool[uVar1].aging_counter = aging_counter_val; + last_keys_updated = pbVar2; + return pbVar2; + } + iVar3 = 0x84; + } + return (bt_keys *)(&key_pool[0].id + iVar3); +} + + + +void bt_keys_foreach(int type,anon_subr_void_bt_keys_ptr_void_ptr *func,void *data) + +{ + if (((uint)key_pool[0].keys & type) != 0) { + (*func)(key_pool,data); + } + if (((uint)key_pool[1].keys & type) != 0) { + // WARNING: Could not recover jumptable at 0x23023b1e. Too many branches + // WARNING: Treating indirect jump as call + (*func)((bt_keys *)0x42011dc0,data); + return; + } + return; +} + + + +bt_keys * bt_keys_find(int type,u8_t id,bt_addr_le_t *addr) + +{ + int iVar1; + undefined3 in_register_0000202d; + + if (((((uint)key_pool[0].keys & type) == 0) || + ((uint)key_pool[0].id != CONCAT31(in_register_0000202d,id))) || + (iVar1 = memcmp(&key_pool[0].addr,addr,7), iVar1 != 0)) { + if (((((uint)key_pool[1].keys & type) == 0) || + ((uint)key_pool[1].id != CONCAT31(in_register_0000202d,id))) || + (iVar1 = memcmp(&key_pool[1].addr,addr,7), iVar1 != 0)) { + return (bt_keys *)0x0; + } + iVar1 = 0x84; + } + else { + iVar1 = 0; + } + return (bt_keys *)(&key_pool[0].id + iVar1); +} + + + +bt_keys * bt_keys_get_type(int type,u8_t id,bt_addr_le_t *addr) + +{ + bt_keys *pbVar1; + + pbVar1 = bt_keys_find(type,id,addr); + if ((pbVar1 == (bt_keys *)0x0) && (pbVar1 = bt_keys_get_addr(id,addr), pbVar1 != (bt_keys *)0x0)) + { + pbVar1->keys = (ushort)type | pbVar1->keys; + } + return pbVar1; +} + + + +bt_keys * bt_keys_find_irk(u8_t id,bt_addr_le_t *addr) + +{ + _Bool _Var1; + undefined3 in_register_00002029; + uint uVar2; + int iVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + + uVar2 = CONCAT31(in_register_00002029,id); + if ((addr->type != '\x01') || (((addr->a).val[5] & 0xc0) != 0x40)) { + return (bt_keys *)0x0; + } + if ((((key_pool[0].keys & 2) == 0) || ((uint)key_pool[0].id != uVar2)) || + (iVar3 = memcmp(&addr->a,&key_pool[0].irk.rpa,6), iVar3 != 0)) { + if ((((key_pool[1].keys & 2) == 0) || ((uint)key_pool[1].id != uVar2)) || + (iVar3 = memcmp(&addr->a,&key_pool[1].irk.rpa,6), iVar3 != 0)) { + if ((((key_pool[0].keys & 2) != 0) && ((uint)key_pool[0].id == uVar2)) && + (_Var1 = bt_rpa_irk_matches((u8_t *)&key_pool[0].irk,&addr->a), + CONCAT31(extraout_var,_Var1) != 0)) { + iVar3 = 0; +LAB_23023c42: + memcpy(key_pool[0].irk.rpa.val + iVar3,&addr->a,6); + return (bt_keys *)(&key_pool[0].id + iVar3); + } + if (((key_pool[1].keys & 2) != 0) && ((uint)key_pool[1].id == uVar2)) { + _Var1 = bt_rpa_irk_matches((u8_t *)&key_pool[1].irk,&addr->a); + iVar3 = 0x84; + if (CONCAT31(extraout_var_00,_Var1) != 0) goto LAB_23023c42; + } + return (bt_keys *)0x0; + } + iVar3 = 0x84; + } + else { + iVar3 = 0; + } + return (bt_keys *)(&key_pool[0].id + iVar3); +} + + + +bt_keys * bt_keys_find_addr(u8_t id,bt_addr_le_t *addr) + +{ + int iVar1; + undefined3 in_register_00002029; + + if (((uint)key_pool[0].id != CONCAT31(in_register_00002029,id)) || + (iVar1 = memcmp(&key_pool[0].addr,addr,7), iVar1 != 0)) { + if (((uint)key_pool[1].id != CONCAT31(in_register_00002029,id)) || + (iVar1 = memcmp(&key_pool[1].addr,addr,7), iVar1 != 0)) { + return (bt_keys *)0x0; + } + iVar1 = 1; + } + return key_pool + iVar1; +} + + + +void bt_keys_add_type(bt_keys *keys,int type) + +{ + keys->keys = (ushort)type | keys->keys; + return; +} + + + +void bt_keys_clear(bt_keys *keys) + +{ + if ((keys->keys & 2) != 0) { + bt_id_del(keys); + } + memset(keys,0,0x84); + return; +} + + + +void keys_clear_id(bt_keys *keys,void *data) + +{ + if (*(u8_t *)data == keys->id) { + bt_keys_clear(keys); + return; + } + return; +} + + + +void bt_keys_clear_all(u8_t id) + +{ + u8_t auStack17 [13]; + + auStack17[0] = id; + bt_keys_foreach(0x3f,keys_clear_id,auStack17); + return; +} + + + +void bt_keys_update_usage(u8_t id,bt_addr_le_t *addr) + +{ + bt_keys *pbVar1; + + pbVar1 = bt_keys_find_addr(id,addr); + if ((pbVar1 != (bt_keys *)0x0) && (last_keys_updated != pbVar1)) { + aging_counter_val = aging_counter_val + 1; + last_keys_updated = pbVar1; + pbVar1->aging_counter = aging_counter_val; + } + return; +} + + + +u8_t notify_func(bt_conn *conn,bt_gatt_subscribe_params *params,void *data,u16_t length) + +{ + bool bVar1; + undefined2 in_register_00002036; + + bVar1 = params->value != 0; + if (bVar1) { + printf("Notification: data length %u\r\n",CONCAT22(in_register_00002036,length)); + } + else { + printf("Unsubscribed\r\n"); + params->value_handle = 0; + } + return (u8_t)bVar1; +} + + + +void le_param_updated(bt_conn *conn,u16_t interval,u16_t latency,u16_t timeout) + +{ + printf("LE conn param updated: int 0x%04x lat %d to %d \r\n"); + return; +} + + + +void ble_set_tx_pwr(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + byte abStack17 [4]; + u8_t power; + + if (argc == 2) { + get_uint8_from_string(argv + 1,abStack17); + if (0x14 < abStack17[0]) { + printf("ble_set_tx_pwr, invalid value, value shall be in [0x%x - 0x%x]\r\n",0,0x14); + return; + } + xWriteBufferLen = bt_set_tx_pwr(abStack17[0]); + if (xWriteBufferLen != 0) { + printf("ble_set_tx_pwr, Fail to set tx power (err %d)\r\n",xWriteBufferLen); + return; + } + fmt = "ble_set_tx_pwr, Set tx power successfully\r\n"; + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt,xWriteBufferLen); + return; +} + + + +void ble_unsubscribe(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + + if (default_conn == (bt_conn *)0x0) { + fmt = "Not connected\r\n"; + } + else { + xWriteBufferLen = 0x42012000; + if (subscribe_params.value_handle == 0) { + fmt = "No subscription found\r\n"; + } + else { + xWriteBufferLen = + bt_gatt_unsubscribe(default_conn,(bt_gatt_subscribe_params *)&subscribe_params); + if (xWriteBufferLen != 0) { + printf("Unsubscribe failed (err %d)\r\n",xWriteBufferLen); + return; + } + fmt = "Unsubscribe success\r\n"; + } + } + printf(fmt,xWriteBufferLen); + return; +} + + + +void write_func(bt_conn *conn,u8_t err,bt_gatt_write_params *params) + +{ + undefined3 in_register_0000202d; + + printf("Write complete: err %u \r\n",CONCAT31(in_register_0000202d,err)); + memset(&write_params,0,0x28); + return; +} + + + +void ble_exchange_mtu(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + + if (default_conn == (bt_conn *)0x0) { + fmt = "Not connected\r\n"; + } + else { + exchange_params.func = exchange_func; + xWriteBufferLen = bt_gatt_exchange_mtu(default_conn,&exchange_params); + if (xWriteBufferLen != 0) { + printf("Exchange failed (err %d)\r\n",xWriteBufferLen); + return; + } + fmt = "Exchange pending\r\n"; + } + printf(fmt,xWriteBufferLen); + return; +} + + + +void exchange_func(bt_conn *conn,u8_t err,bt_gatt_exchange_params *params) + +{ + u16_t uVar1; + undefined2 extraout_var; + undefined3 in_register_0000202d; + char *pcVar2; + + if (CONCAT31(in_register_0000202d,err) == 0) { + pcVar2 = "successful"; + } + else { + pcVar2 = "failed"; + } + uVar1 = bt_gatt_get_mtu(conn); + printf("Exchange %s MTU Size =%d \r\n",pcVar2,CONCAT22(extraout_var,uVar1)); + return; +} + + + +void ble_auth_pairing_confirm(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + if (default_conn == (bt_conn *)0x0) { + printf("Not connected\r\n"); + return; + } + bt_conn_auth_pairing_confirm(default_conn); + return; +} + + + +void ble_auth_passkey_confirm(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + if (default_conn == (bt_conn *)0x0) { + printf("Not connected\r\n"); + return; + } + bt_conn_auth_passkey_confirm(default_conn); + return; +} + + + +void ble_auth_cancel(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + if (default_conn == (bt_conn *)0x0) { + printf("Not connected\r\n"); + return; + } + bt_conn_auth_cancel(default_conn); + return; +} + + + +void ble_auth(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + int iVar1; + char *fmt; + + iVar1 = bt_conn_auth_cb_register(&auth_cb_display); + if (iVar1 == 0) { + fmt = "Register auth callback successfully\r\n"; + } + else { + fmt = "Auth callback has already been registered\r\n"; + } + printf(fmt); + return; +} + + + +void ble_security(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + uint8_t local_11 [4]; + u8_t sec_level; + + local_11[0] = '\x04'; + if (default_conn == (bt_conn *)0x0) { + fmt = "Please firstly choose the connection using ble_select_conn\r\n"; + } + else { + if (argc == 2) { + get_uint8_from_string(argv + 1,local_11); + } + xWriteBufferLen = bt_conn_set_security(default_conn,local_11[0]); + if (xWriteBufferLen != 0) { + printf("Failed to start security, (err %d) \r\n",xWriteBufferLen); + return; + } + fmt = "Start security successfully\r\n"; + } + printf(fmt,xWriteBufferLen); + return; +} + + + +void ble_select_conn(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + bt_conn *pbVar1; + uint8_t auStack32 [4]; + u8_t addr_val [6]; + bt_addr_le_t addr; + + if (argc == 3) { + get_uint8_from_string(argv + 1,addr_val + 4); + get_bytearray_from_string(argv + 2,auStack32,6); + reverse_bytearray(auStack32,addr_val + 5,6); + pbVar1 = bt_conn_lookup_addr_le('\0',(bt_addr_le_t *)(addr_val + 4)); + if (pbVar1 != (bt_conn *)0x0) { + if (default_conn == (bt_conn *)0x0) { + default_conn = pbVar1; + return; + } + bt_conn_unref(default_conn); + default_conn = pbVar1; + return; + } + fmt = "No matching connection found\r\n"; + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt); + return; +} + + + +void ble_disconnect(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + bt_conn *conn; + int iVar1; + uint8_t uStack33; + uint8_t auStack32 [3]; + s8_t type; + u8_t addr_val [6]; + bt_addr_le_t addr; + + uStack33 = -1; + if (argc == 3) { + get_uint8_from_string(argv + 1,&uStack33); + get_bytearray_from_string(argv + 2,auStack32,6); + reverse_bytearray(auStack32,addr_val + 5,6); + addr_val[4] = uStack33; + conn = bt_conn_lookup_addr_le('\0',(bt_addr_le_t *)(addr_val + 4)); + if (conn != (bt_conn *)0x0) { + iVar1 = bt_conn_disconnect(conn,'\x13'); + if (iVar1 == 0) { + fmt = "Disconnect successfully\r\n"; + } + else { + fmt = "Disconnection failed\r\n"; + } + printf(fmt); + bt_conn_unref(conn); + return; + } + fmt = "Not connected\r\n"; + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt); + return; +} + + + +// WARNING: Variable defined which should be unmapped: param + +void ble_connect(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + int iVar1; + int iVar2; + char *fmt; + bt_conn *pbVar3; + uint8_t uStack41; + byte local_28 [3]; + s8_t type; + u8_t addr_val [6]; + bt_addr_le_t addr; + bt_le_conn_param param; + + uStack41 = -1; + stack0xffffffe8 = DAT_4200dd00; + memset(local_28,0,6); + if (argc == 3) { + get_uint8_from_string(argv + 1,&uStack41); + addr_val[4] = uStack41; + get_bytearray_from_string(argv + 2,local_28,6); + iVar1 = 0; + do { + iVar2 = iVar1 + 1; + printf("addr[%d]:[0x%x]\r\n",iVar1,(uint)local_28[iVar1]); + iVar1 = iVar2; + } while (iVar2 != 6); + reverse_bytearray(local_28,addr_val + 5,6); + pbVar3 = bt_conn_create_le((bt_addr_le_t *)(addr_val + 4),(bt_le_conn_param *)(addr.a.val + 3)); + if (pbVar3 == (bt_conn *)0x0) { + fmt = "Connection failed\r\n"; + } + else { + fmt = "Connection pending\r\n"; + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt); + return; +} + + + +void ble_stop_advertise(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + int iVar1; + char *fmt; + + iVar1 = bt_le_adv_stop(); + if (iVar1 == 0) { + fmt = "Advertising stopped\r\n"; + } + else { + fmt = "Failed to stop advertising\r\n"; + } + printf(fmt); + return; +} + + + +void ble_get_device_name(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *pcVar1; + + pcVar1 = bt_get_name(); + if (pcVar1 != (char *)0x0) { + printf("device_name: %s\r\n",pcVar1); + return; + } + printf("Failed to read device name\r\n"); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void ble_start_advertise(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + u8_t *__s; + size_t sVar1; + int iVar2; + bt_data *sd; + u8_t auStack52 [4]; + u8_t auStack48 [4]; + u8_t auStack44 [2]; + byte local_2a; + byte local_29; + u8_t uStack40; + u8_t uStack39; + uint8_t adv_type; + uint8_t mode; + bt_le_adv_param param; + + if ((argc - 3U & 0xfffffffd) == 0) { + _adv_type = 0xa0; + param._0_2_ = 0xf0; + uStack40 = '\0'; + get_uint8_from_string(argv + 1,&local_2a); + printf("adv_type 0x%x\r\n",(uint)local_2a); + if (local_2a == 0) { + uStack39 = '\v'; + } + else { + if (local_2a == 1) { + uStack39 = '\b'; + } + else { + if (local_2a != 2) { + fmt = "Arg1 is invalid\r\n"; + goto LAB_230241b6; + } + uStack39 = '\0'; + } + } + get_uint8_from_string(argv + 2,&local_29); + printf("mode 0x%x\r\n",(uint)local_29); + if (local_29 < 3) { + if (local_29 == 0) { + auStack52[0] = '\x06'; + ad_discov[0].data = auStack52; + } + else { + if (local_29 == 1) { + auStack48[0] = '\x04'; + ad_discov[0].data = auStack48; + } + else { + auStack44[0] = '\x05'; + ad_discov[0].data = auStack44; + } + } + ad_discov[0]._0_2_ = 0x101; + __s = (u8_t *)bt_get_name(); + sVar1 = strlen((char *)__s); + ad_discov[1].type = '\t'; + ad_discov[1].data_len = (u8_t)sVar1; + ad_discov[1].data = __s; + if (argc == 5) { + get_uint16_from_string(argv + 3,(uint16_t *)&adv_type); + get_uint16_from_string(argv + 4,(uint16_t *)¶m); + printf("interval min 0x%x\r\n",(uint)_adv_type); + printf("interval max 0x%x\r\n",(uint)param._0_2_); + } + if (1 < local_2a) { + sd = (bt_data *)0x0; + } + else { + sd = ad_discov; + } + iVar2 = bt_le_adv_start((bt_le_adv_param *)&uStack40,ad_discov,2,sd,(uint)(1 >= local_2a)); + if (iVar2 != 0) { + printf("Failed to start advertising (err %d) \r\n",iVar2); + return; + } + fmt = "Advertising started\r\n"; + } + else { + fmt = "Arg2 is invalid\r\n"; + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } +LAB_230241b6: + printf(fmt); + return; +} + + + +void ble_set_adv_channel(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + int iVar1; + uint8_t auStack17 [4]; + u8_t channel; + + auStack17[0] = '\a'; + if (argc == 2) { + get_uint8_from_string(argv + 1,auStack17); + iVar1 = set_adv_channel_map(auStack17[0]); + if (iVar1 == 0) { + fmt = "Set adv channel success\r\n"; + } + else { + fmt = "Failed to Set adv channel\r\n"; + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt); + return; +} + + + +void ble_stop_scan(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + int iVar1; + + iVar1 = bt_le_scan_stop(); + if (iVar1 != 0) { + printf("Stopping scanning failed (err %d)\r\n",iVar1); + return; + } + printf("Scan successfully stopped \r\n"); + return; +} + + + +void ble_disable(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + int iVar1; + char *fmt; + + iVar1 = bt_disable(); + if (iVar1 == 0) { + fmt = "Disable bt successfully\r\n"; + } + else { + fmt = "Fail to disable bt, there is existed scan/adv/conn event \r\n"; + } + printf(fmt); + return; +} + + + +u8_t discover_func(bt_conn *conn,bt_gatt_attr *attr,bt_gatt_discover_params *params) + +{ + byte bVar1; + u8_t uVar2; + bt_uuid **ppbVar3; + char acStack56 [4]; + char str [37]; + + if (attr == (bt_gatt_attr *)0x0) { + printf("Discover complete\r\n"); + memset(params,0,0x2c); + uVar2 = '\0'; + } + else { + bVar1 = params->type; + if (bVar1 == 2) { + ppbVar3 = (bt_uuid **)attr->user_data; + bt_uuid_to_str(*ppbVar3,acStack56,0x25); + printf("Include %s found: handle %x, start %x, end %x\r\n",acStack56,(uint)attr->handle, + (uint)*(ushort *)(ppbVar3 + 1),(uint)*(ushort *)((int)ppbVar3 + 6)); + } + else { + if (bVar1 < 2) { + ppbVar3 = (bt_uuid **)attr->user_data; + bt_uuid_to_str(*ppbVar3,acStack56,0x25); + printf("Service %s found: start handle %x, end_handle %x\r\n",acStack56,(uint)attr->handle, + (uint)*(ushort *)(ppbVar3 + 1)); + } + else { + if (bVar1 == 3) { + ppbVar3 = (bt_uuid **)attr->user_data; + bt_uuid_to_str(*ppbVar3,acStack56,0x25); + printf("Characteristic %s found: attr->handle %x chrc->handle %x \r\n",acStack56, + (uint)attr->handle,(uint)*(ushort *)(ppbVar3 + 1)); + bVar1 = *(byte *)((int)ppbVar3 + 6); + printf("Properties: "); + if ((bVar1 & 1) != 0) { + printf("[bcast]\r\n"); + } + if ((bVar1 & 2) != 0) { + printf("[read]\r\n"); + } + if ((bVar1 & 8) != 0) { + printf("[write]\r\n"); + } + if ((bVar1 & 4) != 0) { + printf("[write w/w rsp]\r\n"); + } + if ((bVar1 & 0x10) != 0) { + printf("[notify]\r\n"); + } + if ((bVar1 & 0x20) != 0) { + printf("[indicate]"); + } + if ((bVar1 & 0x40) != 0) { + printf("[auth]\r\n"); + } + if (-1 < (char)bVar1) { + return '\x01'; + } + printf("[ext prop]\r\n"); + return '\x01'; + } + bt_uuid_to_str(attr->uuid,acStack56,0x25); + printf("Descriptor %s found: handle %x\r\n",acStack56,(uint)attr->handle); + } + } + uVar2 = '\x01'; + } + return uVar2; +} + + + +void ble_set_data_len(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + uint16_t uStack20; + uint16_t uStack18; + u16_t tx_octets; + u16_t tx_time; + + if (argc == 3) { + if (default_conn == (bt_conn *)0x0) { + fmt = "Not connected\r\n"; + } + else { + get_uint16_from_string(argv + 1,&uStack20); + get_uint16_from_string(argv + 2,&uStack18); + xWriteBufferLen = bt_le_set_data_len(default_conn,uStack20,uStack18); + if (xWriteBufferLen != 0) { + printf("ble_set_data_len, LE Set Data Length (err %d)\r\n",xWriteBufferLen); + return; + } + fmt = "ble_set_data_len, LE Set Data Length success\r\n"; + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt,xWriteBufferLen); + return; +} + + + +void ble_subscribe(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + + if (argc == 4) { + if (default_conn == (bt_conn *)0x0) { + fmt = "Not connected\r\n"; + } + else { + get_uint16_from_string(argv + 1,&subscribe_params.ccc_handle); + get_uint16_from_string(argv + 2,&subscribe_params.value_handle); + get_uint16_from_string(argv + 3,&subscribe_params.value); + subscribe_params.notify = notify_func; + xWriteBufferLen = + bt_gatt_subscribe(default_conn,(bt_gatt_subscribe_params *)&subscribe_params); + if (xWriteBufferLen != 0) { + printf("Subscribe failed (err %d)\r\n",xWriteBufferLen); + return; + } + fmt = "Subscribed\r\n"; + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt,xWriteBufferLen); + return; +} + + + +void ble_write(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + uint array_size; + + if (argc == 5) { + if (default_conn == (bt_conn *)0x0) { + fmt = "Not connected\r\n"; + } + else { + if (write_params.func == (bt_gatt_write_func_t *)0x0) { + get_uint16_from_string(argv + 1,&write_params.handle); + get_uint16_from_string(argv + 2,&write_params.offset); + get_uint16_from_string(argv + 3,&write_params.length); + array_size = (uint)write_params.length; + if (0x200 < write_params.length) { + array_size = 0x200; + } + get_bytearray_from_string(argv + 4,gatt_write_buf,array_size); + write_params.data = gatt_write_buf; + write_params.length = (u16_t)array_size; + write_params.func = write_func; + xWriteBufferLen = bt_gatt_write(default_conn,(bt_gatt_write_params *)&write_params); + if (xWriteBufferLen != 0) { + printf("Write failed (err %d)\r\n",xWriteBufferLen); + return; + } + fmt = "Write pending\r\n"; + } + else { + fmt = "Write ongoing\r\n"; + } + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt,xWriteBufferLen); + return; +} + + + +void ble_read(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + + if (argc == 3) { + if (default_conn == (bt_conn *)0x0) { + fmt = "Not connected\r\n"; + } + else { + get_uint16_from_string(argv + 1,(uint16_t *)&read_params.field_3); + get_uint16_from_string(argv + 2,(uint16_t *)((int)&read_params.field_3 + 2)); + read_params.func = read_func; + read_params.handle_count = 1; + xWriteBufferLen = bt_gatt_read(default_conn,(bt_gatt_read_params *)&read_params); + if (xWriteBufferLen != 0) { + printf("Read failed (err %d)\r\n",xWriteBufferLen); + return; + } + fmt = "Read pending\r\n"; + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt,xWriteBufferLen); + return; +} + + + +u8_t read_func(bt_conn *conn,u8_t err,bt_gatt_read_params *params,void *data,u16_t length) + +{ + int iVar1; + undefined3 in_register_0000202d; + undefined2 in_register_0000203a; + size_t __n; + byte *pbVar2; + undefined auStack56 [4]; + char str [22]; + + __n = CONCAT22(in_register_0000203a,length); + printf("Read complete: err %u length %u \r\n",CONCAT31(in_register_0000202d,err),__n); + memset(auStack56,0,0xf); + if ((__n - 1 & 0xffff) < 0x16) { + memcpy(auStack56,data,__n); + printf("device name : %s \r\n",auStack56); + iVar1 = 0; + while (iVar1 < (int)__n) { + pbVar2 = (byte *)((int)data + iVar1); + iVar1 = iVar1 + 1; + printf("buf=[0x%x]\r\n",(uint)*pbVar2); + } + } + if (data == (void *)0x0) { + memset(params,0,0x28); + } + return (u8_t)(data != (void *)0x0); +} + + + +_Bool data_cb(bt_data *data,void *user_data) + +{ + size_t __n; + + if ((uint)data->type - 8 < 2) { + __n = (size_t)data->data_len; + if (0x1d < data->data_len) { + __n = 0x1d; + } + memcpy(user_data,data->data,__n); + return false; + } + return true; +} + + + +void ble_discover(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + int iVar1; + bt_uuid_16 *pbVar2; + uint8_t auStack33 [4]; + u8_t disc_type; + + if (argc == 5) { + if (default_conn == (bt_conn *)0x0) { + fmt = "Not connected\r\n"; + } + else { + discover_params.func = discover_func; + discover_params.field_3._0_2_ = 1; + discover_params.end_handle = 0xffff; + get_uint8_from_string(argv + 1,auStack33); + if (auStack33[0] == '\0') { + discover_params.type = '\0'; + auStack33[0] = discover_params.type; + } + else { + if ((((auStack33[0] != '\x01') && (auStack33[0] != '\x02')) && (auStack33[0] != '\x03')) && + (auStack33[0] != '\x04')) { + fmt = "Invalid discovery type\r\n"; + goto LAB_230248fc; + } + } + discover_params.type = auStack33[0]; + get_uint16_from_string(argv + 2,&uuid.val); + pbVar2 = &uuid; + if (uuid.val == 0) { + pbVar2 = (bt_uuid_16 *)0x0; + } + discover_params.uuid = (bt_uuid *)pbVar2; + get_uint16_from_string(argv + 3,(uint16_t *)&discover_params.field_3); + get_uint16_from_string(argv + 4,&discover_params.end_handle); + iVar1 = bt_gatt_discover(default_conn,(bt_gatt_discover_params *)&discover_params); + if (iVar1 != 0) { + printf("Discover failed (err %d)\r\n",iVar1); + return; + } + fmt = "Discover pending\r\n"; + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } +LAB_230248fc: + printf(fmt); + return; +} + + + +void ble_auth_passkey(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + + if (argc == 2) { + if (default_conn == (bt_conn *)0x0) { + fmt = "Not connected\r\n"; + } + else { + xWriteBufferLen = atoi(argv[1]); + if ((uint)xWriteBufferLen < 1000000) { + bt_conn_auth_passkey_entry(default_conn,xWriteBufferLen); + return; + } + fmt = "Passkey should be between 0-999999\r\n"; + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt,xWriteBufferLen); + return; +} + + + +void ble_conn_update(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + undefined auStack24 [2]; + undefined auStack22 [2]; + bt_le_conn_param param; + + if (argc == 5) { + get_uint16_from_string(argv + 1,(uint16_t *)auStack24); + get_uint16_from_string(argv + 2,(uint16_t *)(auStack24 + 2)); + get_uint16_from_string(argv + 3,(uint16_t *)¶m); + get_uint16_from_string(argv + 4,¶m.interval_max); + xWriteBufferLen = bt_conn_le_param_update(default_conn,(bt_le_conn_param *)auStack24); + if (xWriteBufferLen != 0) { + printf("conn update failed (err %d)\r\n",xWriteBufferLen); + return; + } + fmt = "conn update initiated\r\n"; + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt,xWriteBufferLen); + return; +} + + + +void ble_unpair(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + int iVar1; + uint8_t auStack32 [4]; + u8_t addr_val [6]; + bt_addr_le_t addr; + + if (argc == 3) { + get_uint8_from_string(argv + 1,addr_val + 4); + get_bytearray_from_string(argv + 2,auStack32,6); + reverse_bytearray(auStack32,addr_val + 5,6); + iVar1 = bt_unpair('\0',(bt_addr_le_t *)(addr_val + 4)); + if (iVar1 == 0) { + fmt = "Unpair successfully\r\n"; + } + else { + fmt = "Failed to unpair\r\n"; + } + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt); + return; +} + + + +void ble_start_scan(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + uint8_t uStack24; + uint8_t uStack23; + uint16_t uStack22; + bt_le_scan_param scan_param; + + if (argc == 5) { + get_uint8_from_string(argv + 1,&uStack24); + get_uint8_from_string(argv + 2,&uStack23); + get_uint16_from_string(argv + 3,&uStack22); + get_uint16_from_string(argv + 4,(uint16_t *)&scan_param); + xWriteBufferLen = bt_le_scan_start(&uStack24,device_found); + if (xWriteBufferLen != 0) { + printf("Failed to start scan (err %d) \r\n",xWriteBufferLen); + return; + } + fmt = "Start scan successfully \r\n"; + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt,xWriteBufferLen); + return; +} + + + +void ble_set_device_name(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + size_t sVar1; + int iVar2; + char *fmt; + + sVar1 = strlen(argv[1]); + if ((sVar1 != 0) && (sVar1 = strlen(argv[1]), sVar1 < 0x1e)) { + iVar2 = bt_set_name(argv[1]); + if (iVar2 == 0) { + fmt = "Set the device name successfully\r\n"; + } + else { + fmt = "Failed to set device name\r\n"; + } + printf(fmt); + return; + } + sVar1 = strlen(argv[1]); + printf("Invaild lenth(%d)\r\n",sVar1); + return; +} + + + +void ble_init(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + + if (ble_inited == false) { + default_conn = (bt_conn *)0x0; + bt_conn_cb_register(&conn_callbacks); + ble_inited = true; + fmt = "Init successfully \r\n"; + } + else { + fmt = "Has initialized \r\n"; + } + printf(fmt); + return; +} + + + +// WARNING: Variable defined which should be unmapped: type + +int bt_addr_le_to_str(bt_addr_le_t *addr,char *str) + +{ + u8_t uVar1; + int iVar2; + char *__src; + char acStack28 [4]; + char type [10]; + + uVar1 = addr->type; + if (uVar1 == '\x01') { + __src = "random"; + } + else { + if (uVar1 == '\0') { + __src = "public"; + } + else { + if (uVar1 == '\x02') { + __src = "public-id"; + } + else { + if (uVar1 != '\x03') { + snprintf(acStack28,10,"0x%02x"); + goto LAB_23024c88; + } + __src = "random-id"; + } + } + } + strcpy(acStack28,__src); +LAB_23024c88: + iVar2 = snprintf(str,0x1e,"%02X:%02X:%02X:%02X:%02X:%02X (%s)",(uint)(addr->a).val[5], + (uint)(addr->a).val[4],(uint)(addr->a).val[3],(uint)(addr->a).val[2], + (uint)(addr->a).val[1]); + return iVar2; +} + + + +// WARNING: Variable defined which should be unmapped: name + +void device_found(bt_addr_le_t *addr,s8_t rssi,u8_t evtype,net_buf_simple *buf) + +{ + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + char acStack80 [4]; + char le_addr [30]; + char name [30]; + + memset(le_addr + 0x1c,0,0x1e); + bt_data_parse(buf,data_cb,le_addr + 0x1c); + bt_addr_le_to_str(addr,acStack80); + printf("[DEVICE]: %s, AD evt type %u, RSSI %i %s \r\n",acStack80, + CONCAT31(in_register_00002031,evtype),CONCAT31(in_register_0000202d,rssi),le_addr + 0x1c); + return; +} + + + +void ble_read_local_address(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + undefined auStack64 [4]; + bt_addr_le_t local_pub_addr; + bt_addr_le_t local_ram_addr; + char le_addr [30]; + + bt_get_local_public_address((bt_addr_le_t *)auStack64); + bt_addr_le_to_str((bt_addr_le_t *)auStack64,(char *)(local_ram_addr.a.val + 3)); + printf("Local public addr : %s\r\n",local_ram_addr.a.val + 3); + bt_get_local_ramdon_address((bt_addr_le_t *)(local_pub_addr.a.val + 3)); + bt_addr_le_to_str((bt_addr_le_t *)(local_pub_addr.a.val + 3),(char *)(local_ram_addr.a.val + 3)); + printf("Local random addr : %s\r\n",local_ram_addr.a.val + 3); + return; +} + + + +void connected(bt_conn *conn,u8_t err) + +{ + bt_addr_le_t *addr_00; + undefined3 in_register_0000202d; + char acStack48 [4]; + char addr [30]; + + addr_00 = bt_conn_get_dst(conn); + bt_addr_le_to_str(addr_00,acStack48); + if (CONCAT31(in_register_0000202d,err) == 0) { + printf("Connected: %s \r\n",acStack48); + if (default_conn == (bt_conn *)0x0) { + default_conn = conn; + } + } + else { + printf("Failed to connect to %s (%u) \r\n",acStack48); + } + return; +} + + + +void disconnected(bt_conn *conn,u8_t reason) + +{ + bt_addr_le_t *addr_00; + undefined3 in_register_0000202d; + char acStack48 [4]; + char addr [30]; + + addr_00 = bt_conn_get_dst(conn); + bt_addr_le_to_str(addr_00,acStack48); + printf("Disconnected: %s (reason %u) \r\n",acStack48,CONCAT31(in_register_0000202d,reason)); + if (default_conn == conn) { + default_conn = (bt_conn *)0x0; + } + return; +} + + + +void security_changed(bt_conn *conn,bt_security_t level,bt_security_err err) + +{ + bt_addr_le_t *addr_00; + undefined3 in_register_0000202d; + char acStack48 [4]; + char addr [30]; + + addr_00 = bt_conn_get_dst(conn); + bt_addr_le_to_str(addr_00,acStack48); + printf("Security changed: %s level %u \r\n",acStack48,CONCAT31(in_register_0000202d,level)); + return; +} + + + +void auth_passkey_display(bt_conn *conn,uint passkey) + +{ + bt_addr_le_t *addr_00; + char acStack48 [4]; + char addr [30]; + + addr_00 = bt_conn_get_dst(conn); + bt_addr_le_to_str(addr_00,acStack48); + printf("passkey_str is: %06u\r\n",passkey); + return; +} + + + +void auth_passkey_entry(bt_conn *conn) + +{ + bt_addr_le_t *addr_00; + char acStack48 [4]; + char addr [30]; + + addr_00 = bt_conn_get_dst(conn); + bt_addr_le_to_str(addr_00,acStack48); + printf("Enter passkey for %s\r\n",acStack48); + return; +} + + + +void auth_passkey_confirm(bt_conn *conn,uint passkey) + +{ + bt_addr_le_t *addr_00; + char acStack48 [4]; + char addr [30]; + + addr_00 = bt_conn_get_dst(conn); + bt_addr_le_to_str(addr_00,acStack48); + printf("Confirm passkey for %s: %06u\r\n",acStack48,passkey); + return; +} + + + +void auth_cancel(bt_conn *conn) + +{ + bt_addr_le_t *addr_00; + char acStack48 [4]; + char addr [30]; + + addr_00 = bt_conn_get_dst(conn); + bt_addr_le_to_str(addr_00,acStack48); + printf("Pairing cancelled: %s\r\n",acStack48); + return; +} + + + +void auth_pairing_confirm(bt_conn *conn) + +{ + bt_addr_le_t *addr_00; + char acStack48 [4]; + char addr [30]; + + addr_00 = bt_conn_get_dst(conn); + bt_addr_le_to_str(addr_00,acStack48); + printf("Confirm pairing for %s\r\n",acStack48); + return; +} + + + +void auth_pairing_complete(bt_conn *conn,_Bool bonded) + +{ + bt_addr_le_t *addr_00; + undefined3 in_register_0000202d; + char *pcVar1; + char acStack48 [4]; + char addr [30]; + + addr_00 = bt_conn_get_dst(conn); + bt_addr_le_to_str(addr_00,acStack48); + if (CONCAT31(in_register_0000202d,bonded) == 0) { + pcVar1 = "Paired"; + } + else { + pcVar1 = "Bonded"; + } + printf("%s with %s\r\n",pcVar1,acStack48); + return; +} + + + +void auth_pairing_failed(bt_conn *conn,bt_security_err reason) + +{ + bt_addr_le_t *addr_00; + char acStack48 [4]; + char addr [30]; + + addr_00 = bt_conn_get_dst(conn); + bt_addr_le_to_str(addr_00,acStack48); + printf("Pairing failed with %s\r\n",acStack48); + return; +} + + + +void identity_resolved(bt_conn *conn,bt_addr_le_t *rpa,bt_addr_le_t *identity) + +{ + char acStack80 [4]; + char addr_identity [30]; + char addr_rpa [30]; + + bt_addr_le_to_str(identity,acStack80); + bt_addr_le_to_str(rpa,addr_identity + 0x1c); + printf("Identity resolved %s -> %s \r\n",addr_identity + 0x1c,acStack80); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void ble_get_all_conn_info(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *pcVar1; + int iVar2; + int iVar3; + char acStack120 [4]; + char le_addr [30]; + bt_conn_info info [2]; + + iVar3 = bt_conn_get_remote_dev_info((bt_conn_info *)(le_addr + 0x1c)); + if (0 < iVar3) { + bt_addr_le_to_str(info[0].field_3._4_4_,acStack120); + printf("ble local device address: %s\r\n",acStack120); + } + printf("ble connected devices count: %d\r\n",iVar3); + iVar2 = 0; + pcVar1 = le_addr; + while (iVar2 < iVar3) { + bt_addr_le_to_str(*(bt_addr_le_t **)(pcVar1 + 0x2c),acStack120); + printf("[%d]: address %s\r\n",iVar2,acStack120); + iVar2 = iVar2 + 1; + pcVar1 = pcVar1 + 0x1c; + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: handle +// WARNING: Could not reconcile some variable overlaps + +void ble_write_without_rsp(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv) + +{ + char *fmt; + int iVar1; + uint array_size; + _Bool _Stack21; + uint16_t uStack20; + _Bool sign; + u16_t uStack18; + u16_t handle; + u16_t len; + + if (argc == 5) { + if (default_conn != (bt_conn *)0x0) { + get_uint8_from_string(argv + 1,&_Stack21); + get_uint16_from_string(argv + 2,&uStack20); + get_uint16_from_string(argv + 3,(uint16_t *)&stack0xffffffee); + array_size = (uint)uStack18; + if (0x200 < uStack18) { + array_size = 0x200; + } + uStack18 = (u16_t)array_size; + get_bytearray_from_string(argv + 4,gatt_write_buf,array_size); + iVar1 = bt_gatt_write_without_response_cb + (default_conn,uStack20,gatt_write_buf,uStack18,_Stack21, + (bt_gatt_complete_func_t *)0x0,(void *)0x0); + printf("Write Complete (err %d)\r\n",iVar1); + return; + } + fmt = "Not connected\r\n"; + } + else { + fmt = "Number of Parameters is not correct\r\n"; + } + printf(fmt); + return; +} + + + +int ble_cli_register(void) + +{ + return 0; +} + + + +void k_queue_init(k_queue *queue,int size) + +{ + QueueHandle_t pQVar1; + + pQVar1 = xQueueGenericCreate(size,5,'\0'); + *(QueueHandle_t *)&queue->hdl = pQVar1; + if (pQVar1 == (QueueHandle_t)0x0) { + vAssertCalled(); + } + *(sys_dlist_t **)&(queue->poll_events).field_0 = &queue->poll_events; + *(sys_dlist_t **)&(queue->poll_events).field_1 = &queue->poll_events; + return; +} + + + +void k_queue_insert(k_queue *queue,void *prev,void *data) + +{ + BaseType_t BVar1; + void *apvStack20 [4]; + + apvStack20[0] = data; + BVar1 = xQueueGenericSend((QueueHandle_t)queue->hdl,apvStack20,0xffffffff,0); + if (BVar1 != 1) { + vAssertCalled(); + } + return; +} + + + +void k_queue_append(k_queue *queue,void *data) + +{ + k_queue_insert(queue,(void *)0x0,data); + return; +} + + + +void k_queue_free(k_queue *queue) + +{ + if ((queue != (k_queue *)0x0) && ((QueueHandle_t)queue->hdl != (QueueHandle_t)0x0)) { + vQueueDelete((QueueHandle_t)queue->hdl); + queue->hdl = (void *)0x0; + return; + } + printf("Queue is NULL\n\r\n"); + return; +} + + + +void k_queue_prepend(k_queue *queue,void *data) + +{ + k_queue_insert(queue,(void *)0x0,data); + return; +} + + + +void k_queue_append_list(k_queue *queue,void *head,void *tail) + +{ + while (head != (void *)0x0) { + k_queue_append(queue,head); + head = *(void **)head; + } + return; +} + + + +void * k_queue_get(k_queue *queue,s32_t timeout) + +{ + BaseType_t BVar1; + void *pvVar2; + void *pvStack20; + void *msg; + + pvStack20 = (void *)0x0; + if (timeout == -1) { + timeout = 0xffffffff; + } + BVar1 = xQueueReceive((QueueHandle_t)queue->hdl,&pvStack20,timeout); + pvVar2 = (void *)0x0; + if (BVar1 == 1) { + pvVar2 = pvStack20; + } + return pvVar2; +} + + + +int k_queue_is_empty(k_queue *queue) + +{ + UBaseType_t UVar1; + + UVar1 = uxQueueMessagesWaiting((QueueHandle_t)queue->hdl); + return (uint)(UVar1 == 0); +} + + + +int k_queue_get_cnt(k_queue *queue) + +{ + UBaseType_t UVar1; + + UVar1 = uxQueueMessagesWaiting((QueueHandle_t)queue->hdl); + return UVar1; +} + + + +int k_sem_init(k_sem *sem,uint initial_count,uint limit) + +{ + int iVar1; + QueueHandle_t pQVar2; + + if (sem == (k_sem *)0x0) { + printf("sem is NULL\n\r\n"); + iVar1 = -0x16; + } + else { + pQVar2 = xQueueCreateCountingSemaphore(limit,initial_count); + *(QueueHandle_t *)&(sem->sem).hdl = pQVar2; + *(sys_dlist_t **)&(sem->poll_events).field_0 = &sem->poll_events; + *(sys_dlist_t **)&(sem->poll_events).field_1 = &sem->poll_events; + iVar1 = 0; + } + return iVar1; +} + + + +int k_sem_take(k_sem *sem,uint32_t timeout) + +{ + BaseType_t BVar1; + + if (sem != (k_sem *)0x0) { + BVar1 = xQueueSemaphoreTake((QueueHandle_t)(sem->sem).hdl,timeout); + return -(uint)(BVar1 != 1); + } + return -1; +} + + + +int k_sem_give(k_sem *sem) + +{ + int iVar1; + BaseType_t BVar2; + + if (sem == (k_sem *)0x0) { + printf("sem is NULL\n\r\n"); + iVar1 = -0x16; + } + else { + BVar2 = xQueueGenericSend((QueueHandle_t)(sem->sem).hdl,(void *)0x0,0,0); + iVar1 = -(uint)(BVar2 != 1); + } + return iVar1; +} + + + +int k_sem_delete(k_sem *sem) + +{ + QueueHandle_t xQueue; + int iVar1; + + if ((sem == (k_sem *)0x0) || + (xQueue = (QueueHandle_t)(sem->sem).hdl, xQueue == (QueueHandle_t)0x0)) { + printf("sem is NULL\n\r\n"); + iVar1 = -0x16; + } + else { + vQueueDelete(xQueue); + iVar1 = 0; + (sem->sem).hdl = (void *)0x0; + } + return iVar1; +} + + + +uint k_sem_count_get(k_sem *sem) + +{ + UBaseType_t UVar1; + + UVar1 = uxQueueMessagesWaiting((QueueHandle_t)(sem->sem).hdl); + return UVar1; +} + + + +int k_thread_create(k_thread *new_thread,char *name,size_t stack_size,k_thread_entry_t entry, + int prio) + +{ + xTaskCreate((TaskFunction_t *)entry,name,(uint16_t)(stack_size >> 2),(void *)0x0,prio, + (TaskHandle_t *)new_thread); + return -(uint)(new_thread->task == 0); +} + + + +void k_thread_delete(k_thread *new_thread) + +{ + if ((new_thread != (k_thread *)0x0) && ((TaskHandle_t)new_thread->task != (TaskHandle_t)0x0)) { + vTaskDelete((TaskHandle_t)new_thread->task); + new_thread->task = 0; + return; + } + printf("task is NULL\n\r\n"); + return; +} + + + +int k_yield(void) + +{ + ecall(); + return 0; +} + + + +uint irq_lock(void) + +{ + vTaskEnterCritical(); + return 1; +} + + + +void irq_unlock(void) + +{ + if ((xSchedulerRunning != 0) && (pxCurrentTCB->uxCriticalNesting != 0)) { + vTaskExitCritical(); + return; + } + return; +} + + + +void k_timer_init(k_timer_t_conflict1 *timer,k_timer_handler_t_conflict handle,void *args) + +{ + TimerHandle_t ptVar1; + + if (timer == (k_timer_t_conflict1 *)0x0) { + vAssertCalled(); + } + timer->args = args; + timer->handler = handle; + ptVar1 = xTimerCreate("Timer",1000,0,(void *)0x0,(TimerCallbackFunction_t *)handle); + *(TimerHandle_t *)&(timer->timer).hdl = ptVar1; + if (ptVar1 == (TimerHandle_t)0x0) { + vAssertCalled(); + return; + } + return; +} + + + +void k_timer_stop(k_timer_t_conflict1 *timer) + +{ + BaseType_t BVar1; + + if (timer == (k_timer_t_conflict1 *)0x0) { + vAssertCalled(); + } + BVar1 = xTimerGenericCommand((TimerHandle_t)(timer->timer).hdl,3,0,(BaseType_t *)0x0,0); + if (BVar1 != 1) { + vAssertCalled(); + return; + } + return; +} + + + +void k_timer_delete(k_timer_t_conflict1 *timer) + +{ + BaseType_t BVar1; + + if (timer == (k_timer_t_conflict1 *)0x0) { + vAssertCalled(); + } + BVar1 = xTimerGenericCommand((TimerHandle_t)(timer->timer).hdl,5,0,(BaseType_t *)0x0,0); + if (BVar1 != 1) { + vAssertCalled(); + return; + } + return; +} + + + +longlong k_now_ms(void) + +{ + longlong in_fa0; + + xTaskGetTickCount(); + return in_fa0; +} + + + +u32_t_conflict k_uptime_get_32(void) + +{ + u32_t_conflict in_a0; + + k_now_ms(); + return in_a0; +} + + + +void k_timer_start(k_timer_t_conflict1 *timer,uint32_t timeout) + +{ + TimerHandle_t xTimer; + k_timer_t_conflict1 *pkVar1; + BaseType_t BVar2; + TickType_t xOptionalValue; + + pkVar1 = timer; + if (timer == (k_timer_t_conflict1 *)0x0) { + pkVar1 = (k_timer_t_conflict1 *)vAssertCalled(); + } + timer->timeout = timeout; + k_now_ms(); + *(k_timer_t_conflict1 **)&timer->start_ms = pkVar1; + BVar2 = xTimerGenericCommand((TimerHandle_t)(timer->timer).hdl,3,0,(BaseType_t *)0x0,0); + if (BVar2 != 1) { + vAssertCalled(); + } + BVar2 = xTimerGenericCommand + ((TimerHandle_t)(timer->timer).hdl,4,(timeout * 1000) / 1000,(BaseType_t *)0x0,0 + ); + if (BVar2 != 1) { + vAssertCalled(); + } + xTimer = (TimerHandle_t)(timer->timer).hdl; + xOptionalValue = xTaskGetTickCount(); + BVar2 = xTimerGenericCommand(xTimer,1,xOptionalValue,(BaseType_t *)0x0,0); + if (BVar2 != 1) { + vAssertCalled(); + return; + } + return; +} + + + +void k_get_random_byte_array(uint8_t *buf,size_t len) + +{ + uint8_t *puVar1; + int iVar2; + + puVar1 = buf + len; + while (buf != puVar1) { + iVar2 = bl_rand(); + *buf = (uint8_t)iVar2; + buf = buf + 1; + } + return; +} + + + +void * k_malloc(size_t xWantedSize) + +{ + size_t sVar1; + size_t sVar2; + BlockLink_t *pBVar3; + A_BLOCK_LINK *pAVar4; + BlockLink_t *pxBlockToInsert; + uint uVar5; + uint uVar6; + + if (pxEnd == (BlockLink_t *)0x0) { + vAssertCalled(); + } + vTaskSuspendAll(); + sVar2 = xFreeBytesRemaining; + sVar1 = xBlockAllocatedBit; + if (((xBlockAllocatedBit & xWantedSize) == 0) && (xWantedSize != 0)) { + uVar6 = xWantedSize + 8; + if ((uVar6 & 7) != 0) { + uVar6 = (uVar6 & 0xfffffff8) + 8; + } + if ((uVar6 != 0) && (uVar6 <= xFreeBytesRemaining)) { + pAVar4 = xStart.pxNextFreeBlock; + pBVar3 = &xStart; + do { + pxBlockToInsert = pBVar3; + pBVar3 = (BlockLink_t *)pAVar4; + if (uVar6 <= pBVar3->xBlockSize) break; + pAVar4 = pBVar3->pxNextFreeBlock; + } while (pBVar3->pxNextFreeBlock != (A_BLOCK_LINK *)0x0); + if (pxEnd != pBVar3) { + pAVar4 = pxBlockToInsert->pxNextFreeBlock; + pxBlockToInsert->pxNextFreeBlock = pBVar3->pxNextFreeBlock; + uVar5 = pBVar3->xBlockSize; + pAVar4 = pAVar4 + 1; + if (0x10 < uVar5 - uVar6) { + pxBlockToInsert = (BlockLink_t *)((int)&pBVar3->pxNextFreeBlock + uVar6); + pxBlockToInsert->xBlockSize = uVar5 - uVar6; + pBVar3->xBlockSize = uVar6; + prvInsertBlockIntoFreeList(pxBlockToInsert); + uVar5 = pBVar3->xBlockSize; + } + xFreeBytesRemaining = sVar2 - uVar5; + if (xFreeBytesRemaining < xMinimumEverFreeBytesRemaining) { + xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; + } + pBVar3->xBlockSize = sVar1 | uVar5; + pBVar3->pxNextFreeBlock = (A_BLOCK_LINK *)0x0; + xTaskResumeAll(); + if (pAVar4 != (A_BLOCK_LINK *)0x0) { + return pAVar4; + } + goto LAB_230359be; + } + } + } + xTaskResumeAll(); +LAB_230359be: + vApplicationMallocFailedHook(); + return (void *)0x0; +} + + + +void k_free(void *pv) + +{ + uint uVar1; + + if (pv == (void *)0x0) { + return; + } + uVar1 = *(uint *)((int)pv + -4); + if ((uVar1 & xBlockAllocatedBit) == 0) { + vAssertCalled(); + if (*(int *)((int)pv + -8) == 0) { + uVar1 = *(uint *)((int)pv + -4); + if ((uVar1 & xBlockAllocatedBit) == 0) { + return; + } + goto LAB_23035ace; + } + } + else { + if (*(int *)((int)pv + -8) == 0) goto LAB_23035ace; + } + vAssertCalled(); + uVar1 = *(uint *)((int)pv + -4); + if (((uVar1 & xBlockAllocatedBit) == 0) || (*(int *)((int)pv + -8) != 0)) { + return; + } +LAB_23035ace: + *(uint *)((int)pv + -4) = ~xBlockAllocatedBit & uVar1; + vTaskSuspendAll(); + xFreeBytesRemaining = *(int *)((int)pv + -4) + xFreeBytesRemaining; + prvInsertBlockIntoFreeList((BlockLink_t *)((int)pv + -8)); + xTaskResumeAll(); + return; +} + + + +int atomic_cas(atomic_t *target,atomic_val_t old_value,atomic_val_t new_value) + +{ + int iVar1; + + irq_lock(); + iVar1 = *target; + if (iVar1 == old_value) { + *target = new_value; + } + irq_unlock(); + return (uint)(iVar1 == old_value); +} + + + +atomic_val_t atomic_inc(atomic_t *target) + +{ + int iVar1; + + irq_lock(); + iVar1 = *target; + *target = iVar1 + 1; + irq_unlock(); + return iVar1; +} + + + +atomic_val_t atomic_dec(atomic_t *target) + +{ + int iVar1; + + irq_lock(); + iVar1 = *target; + *target = iVar1 + -1; + irq_unlock(); + return iVar1; +} + + + +atomic_val_t atomic_get(atomic_t *target) + +{ + return *target; +} + + + +atomic_val_t atomic_set(atomic_t *target,atomic_val_t value) + +{ + atomic_t aVar1; + + irq_lock(); + aVar1 = *target; + *target = value; + irq_unlock(); + return aVar1; +} + + + +atomic_val_t atomic_clear(atomic_t *target) + +{ + atomic_t aVar1; + + irq_lock(); + aVar1 = *target; + *target = 0; + irq_unlock(); + return aVar1; +} + + + +atomic_val_t atomic_or(atomic_t *target,atomic_val_t value) + +{ + uint uVar1; + + irq_lock(); + uVar1 = *target; + *target = value | uVar1; + irq_unlock(); + return uVar1; +} + + + +atomic_val_t atomic_and(atomic_t *target,atomic_val_t value) + +{ + uint uVar1; + + irq_lock(); + uVar1 = *target; + *target = value & uVar1; + irq_unlock(); + return uVar1; +} + + + +void fixed_data_unref(net_buf *buf,u8_t *data) + +{ + return; +} + + + +net_buf_pool * net_buf_pool_get(int id) + +{ + return &acl_tx_pool + id; +} + + + +int net_buf_id(net_buf *buf) + +{ + return (int)((int)buf - (int)(&acl_tx_pool)[buf->pool_id].__bufs) >> 5; +} + + + +u8_t * fixed_data_alloc(net_buf *buf,size_t *size,s32_t timeout) + +{ + uint *puVar1; + int iVar2; + uint uVar3; + + puVar1 = (uint *)((&acl_tx_pool)[buf->pool_id].alloc)->alloc_data; + uVar3 = *size; + if (*puVar1 < *size) { + uVar3 = *puVar1; + } + *size = uVar3; + iVar2 = net_buf_id(buf); + return (u8_t *)(iVar2 * *puVar1 + puVar1[1]); +} + + + +// WARNING: Could not reconcile some variable overlaps + +net_buf * net_buf_alloc_len(net_buf_pool *pool,size_t size,s32_t timeout) + +{ + ushort uVar1; + net_buf *data; + u32_t_conflict uVar2; + uint uVar3; + u32_t_conflict uVar4; + u8_t *puVar5; + size_t asStack36 [2]; + + asStack36[0] = size; + uVar2 = k_uptime_get_32(); + uVar3 = irq_lock(); + if (pool->uninit_count == 0) { + irq_unlock(); + data = (net_buf *)k_queue_get((k_queue *)pool,timeout); + if (data == (net_buf *)0x0) { + return (net_buf *)0x0; + } + } + else { + if ((pool->uninit_count < pool->buf_count) && + (data = (net_buf *)k_queue_get((k_queue *)pool,0), data != (net_buf *)0x0)) { + irq_unlock(uVar3); + } + else { + uVar1 = pool->uninit_count; + pool->uninit_count = uVar1 - 1; + irq_unlock(uVar3); + data = pool->__bufs + ((uint)pool->buf_count - (uint)uVar1); + data->pool_id = (char)((int)&pool[-0x25b759e].__bufs >> 2) * -0x49; + } + } + if (asStack36[0] == 0) { + *(undefined4 *)((int)&data->field_4 + 8) = 0; + } + else { + if (1 < timeout + 1U) { + uVar4 = k_uptime_get_32(); + uVar3 = uVar4 - uVar2; + if ((uint)timeout < uVar4 - uVar2) { + uVar3 = timeout; + } + timeout = timeout - uVar3; + } + puVar5 = (*((&acl_tx_pool)[data->pool_id].alloc)->cb->alloc)(data,asStack36,timeout); + *(u8_t **)((int)&data->field_4 + 8) = puVar5; + if (puVar5 == (u8_t *)0x0) { + k_queue_prepend((k_queue *)(&acl_tx_pool + data->pool_id),data); + return (net_buf *)0x0; + } + } + data->field_0 = 0; + *(undefined2 *)&data->ref = 1; + *(undefined2 *)((int)&data->field_4 + 4) = 0; + *(undefined2 *)((int)&data->field_4 + 6) = (undefined2)asStack36[0]; + *(undefined4 *)&data->field_4 = *(undefined4 *)((int)&data->field_4 + 8); + return data; +} + + + +net_buf * net_buf_alloc_fixed(net_buf_pool *pool,s32_t timeout) + +{ + net_buf *pnVar1; + + pnVar1 = net_buf_alloc_len(pool,*(size_t *)pool->alloc->alloc_data,timeout); + return pnVar1; +} + + + +net_buf * net_buf_get(k_fifo *fifo,s32_t timeout) + +{ + net_buf *pnVar1; + net_buf *pnVar2; + net_buf *pnVar3; + + pnVar2 = (net_buf *)k_queue_get((k_queue *)fifo,timeout); + pnVar1 = pnVar2; + if (pnVar2 != (net_buf *)0x0) { + while ((pnVar1->flags & 1) != 0) { + pnVar3 = (net_buf *)k_queue_get((k_queue *)fifo,0); + *(net_buf **)&pnVar1->field_0 = pnVar3; + pnVar1->flags = pnVar1->flags & 0xfe; + pnVar1 = pnVar3; + } + pnVar1->field_0 = 0; + } + return pnVar2; +} + + + +void net_buf_simple_reserve(net_buf_simple *buf,size_t reserve) + +{ + buf->data = buf->__buf + reserve; + return; +} + + + +void net_buf_put(k_fifo *fifo,net_buf *buf) + +{ + net_buf *tail; + + tail = buf; + while ((net_buf *)tail->field_0 != (net_buf *)0x0) { + tail->flags = tail->flags | 1; + tail = (net_buf *)tail->field_0; + } + k_queue_append_list((k_queue *)fifo,buf,tail); + return; +} + + + +void net_buf_unref(net_buf *buf) + +{ + byte bVar1; + u8_t *puVar2; + u8_t uVar3; + net_buf *pnVar4; + + while( true ) { + if (buf == (net_buf *)0x0) { + return; + } + pnVar4 = (net_buf *)buf->field_0; + uVar3 = buf->ref + -1; + buf->ref = uVar3; + if (uVar3 != '\0') break; + puVar2 = *(u8_t **)((int)&buf->field_4 + 8); + if (puVar2 != (u8_t *)0x0) { + if ((buf->flags & 2) == 0) { + (*((&acl_tx_pool)[buf->pool_id].alloc)->cb->unref)(buf,puVar2); + } + *(undefined4 *)((int)&buf->field_4 + 8) = 0; + } + bVar1 = buf->pool_id; + *(undefined4 *)&buf->field_4 = 0; + buf->field_0 = 0; + if ((&acl_tx_pool)[bVar1].destroy == (anon_subr_void_net_buf_ptr_for_destroy *)0x0) { + k_queue_prepend((k_queue *)(&acl_tx_pool + bVar1),buf); + } + else { + (*(&acl_tx_pool)[bVar1].destroy)(buf); + } + buf = pnVar4; + if (&acl_tx_pool + bVar1 == &hci_rx_pool) { + bl_handle_queued_msg(); + return; + } + } + return; +} + + + +net_buf * net_buf_ref(net_buf *buf) + +{ + buf->ref = buf->ref + '\x01'; + return buf; +} + + + +void net_buf_frag_insert(net_buf *parent,net_buf *frag) + +{ + net_buf *pnVar1; + net_buf *pnVar2; + + pnVar1 = frag; + if (parent->field_0 != 0) { + do { + pnVar2 = pnVar1; + pnVar1 = (net_buf *)pnVar2->field_0; + } while (pnVar1 != (net_buf *)0x0); + pnVar2->field_0 = parent->field_0; + } + *(net_buf **)&parent->field_0 = frag; + return; +} + + + +net_buf * net_buf_frag_add(net_buf *head,net_buf *frag) + +{ + net_buf *parent; + net_buf *pnVar1; + + pnVar1 = head; + if (head != (net_buf *)0x0) { + do { + parent = pnVar1; + pnVar1 = (net_buf *)parent->field_0; + } while (pnVar1 != (net_buf *)0x0); + net_buf_frag_insert(parent,frag); + return head; + } + frag->ref = frag->ref + '\x01'; + return frag; +} + + + +net_buf * net_buf_frag_del(net_buf *parent,net_buf *frag) + +{ + net_buf *pnVar1; + + if (parent != (net_buf *)0x0) { + parent->field_0 = frag->field_0; + } + pnVar1 = (net_buf *)frag->field_0; + frag->field_0 = 0; + net_buf_unref(frag); + return pnVar1; +} + + + +void * net_buf_simple_add(net_buf_simple *buf,size_t len) + +{ + ushort uVar1; + + uVar1 = buf->len; + buf->len = (short)len + uVar1; + return buf->data + uVar1; +} + + + +void * net_buf_simple_add_mem(net_buf_simple *buf,void *mem,size_t len) + +{ + ushort uVar1; + void *pvVar2; + + uVar1 = buf->len; + buf->len = uVar1 + (short)len; + pvVar2 = memcpy(buf->data + uVar1,mem,len); + return pvVar2; +} + + + +u8_t * net_buf_simple_add_u8(net_buf_simple *buf,u8_t val) + +{ + ushort uVar1; + u8_t *puVar2; + + uVar1 = buf->len; + puVar2 = buf->data; + buf->len = uVar1 + 1; + puVar2[uVar1] = val; + return puVar2 + uVar1; +} + + + +void net_buf_simple_add_le16(net_buf_simple *buf,u16_t val) + +{ + ushort uVar1; + u8_t *puVar2; + + uVar1 = buf->len; + puVar2 = buf->data; + buf->len = uVar1 + 2; + puVar2[uVar1] = (u8_t)val; + (puVar2 + uVar1)[1] = (u8_t)(val >> 8); + return; +} + + + +void * net_buf_simple_push(net_buf_simple *buf,size_t len) + +{ + u8_t *puVar1; + + puVar1 = buf->data; + buf->data = puVar1 + -len; + buf->len = (short)len + buf->len; + return puVar1 + -len; +} + + + +void net_buf_simple_push_le16(net_buf_simple *buf,u16_t val) + +{ + u8_t *puVar1; + + puVar1 = buf->data; + buf->data = puVar1 + -2; + buf->len = buf->len + 2; + puVar1[-2] = (u8_t)val; + puVar1[-1] = (u8_t)(val >> 8); + return; +} + + + +void * net_buf_simple_pull(net_buf_simple *buf,size_t len) + +{ + u8_t *puVar1; + + buf->len = buf->len - (short)len; + puVar1 = buf->data; + buf->data = puVar1 + len; + return puVar1 + len; +} + + + +void * net_buf_simple_pull_mem(net_buf_simple *buf,size_t len) + +{ + u8_t *puVar1; + + puVar1 = buf->data; + buf->len = buf->len - (short)len; + buf->data = puVar1 + len; + return puVar1; +} + + + +u8_t net_buf_simple_pull_u8(net_buf_simple *buf) + +{ + u8_t uVar1; + + uVar1 = *buf->data; + net_buf_simple_pull(buf,1); + return uVar1; +} + + + +u16_t net_buf_simple_pull_le16(net_buf_simple *buf) + +{ + u16_t uVar1; + + uVar1 = *(u16_t *)buf->data; + net_buf_simple_pull(buf,2); + return uVar1; +} + + + +size_t net_buf_simple_headroom(net_buf_simple *buf) + +{ + return (size_t)(buf->data + -(int)buf->__buf); +} + + + +size_t net_buf_simple_tailroom(net_buf_simple *buf) + +{ + return ((uint)buf->size - (uint)buf->len) - (int)(buf->data + -(int)buf->__buf); +} + + + +size_t net_buf_append_bytes + (net_buf *buf,size_t len,void *value,s32_t timeout, + net_buf_allocator_cb *allocate_cb,void *user_data) + +{ + net_buf *pnVar1; + uint len_00; + net_buf *frag; + size_t sVar2; + + pnVar1 = buf; + do { + frag = pnVar1; + pnVar1 = (net_buf *)frag->field_0; + } while ((net_buf *)frag->field_0 != (net_buf *)0x0); + sVar2 = 0; + while( true ) { + len_00 = net_buf_simple_tailroom((net_buf_simple *)&frag->field_4); + if (len < len_00) { + len_00 = len; + } + len_00 = len_00 & 0xffff; + len = len - len_00; + net_buf_simple_add_mem((net_buf_simple *)&frag->field_4,value,len_00); + sVar2 = sVar2 + len_00; + value = (void *)((int)value + len_00); + if ((len == 0) || (frag = (*allocate_cb)(timeout,user_data), frag == (net_buf *)0x0)) break; + net_buf_frag_add(buf,frag); + } + return sVar2; +} + + + +char * bt_hex_real(void *buf,size_t len) + +{ + char "0123456789abcdef" [17]; + char str [128]; + byte *pbVar1; + char *pcVar2; + + if (0x3f < len) { + len = 0x3f; + } + pbVar1 = (byte *)buf; + pcVar2 = (char *)&ram0x42012110; + while (pbVar1 != (byte *)((int)buf + len)) { + *pcVar2 = "0123456789abcdef"[*pbVar1 >> 4]; + pcVar2[1] = *(char *)(((uint)*pbVar1 & 0xf) + 0x23076794); + pbVar1 = pbVar1 + 1; + pcVar2 = pcVar2 + 2; + } + *(undefined *)(len * 2 + 0x42012110) = 0; + return (char *)0x42012110; +} + + + +// WARNING: Variable defined which should be unmapped: type + +char * bt_addr_le_str_real(bt_addr_le_t *addr) + +{ + u8_t uVar1; + char str [30]; + char *__src; + char acStack28 [4]; + char type [10]; + + uVar1 = addr->type; + if (uVar1 == '\x01') { + __src = "random"; + } + else { + if (uVar1 == '\0') { + __src = "public"; + } + else { + if (uVar1 == '\x02') { + __src = "public-id"; + } + else { + if (uVar1 != '\x03') { + snprintf(acStack28,10,"0x%02x"); + goto LAB_23025aaa; + } + __src = "random-id"; + } + } + } + strcpy(acStack28,__src); +LAB_23025aaa: + snprintf((char *)&ram0x42012190,0x1e,"%02X:%02X:%02X:%02X:%02X:%02X (%s)",(uint)(addr->a).val[5], + (uint)(addr->a).val[4],(uint)(addr->a).val[3],(uint)(addr->a).val[2], + (uint)(addr->a).val[1]); + return (char *)0x42012190; +} + + + +// WARNING: Type propagation algorithm not settling + +_Bool polling_events(k_poll_event *events,int num_events,s32_t timeout,int *last_registered) + +{ + bool bVar1; + int iVar2; + uint uVar3; + k_poll_event *pkVar4; + int iVar5; + uint uVar6; + k_poll_event *pkVar7; + + iVar2 = 0; + bVar1 = true; + pkVar7 = events; + do { + if (num_events <= iVar2) { + return (_Bool)bVar1; + } + uVar3 = irq_lock(); + uVar6 = *(uint *)&pkVar7->field_0xc >> 8 & 0xf; + if (uVar6 == 2) { + uVar6 = k_sem_count_get((k_sem *)pkVar7->field_7); + if (uVar6 != 0) { + uVar6 = 3; + goto LAB_23025bcc; + } +LAB_23025b8a: + if ((timeout != 0) && (bVar1)) { + uVar6 = *(uint *)&pkVar7->field_0xc >> 8 & 0xf; + if ((uVar6 == 2) || (uVar6 == 3)) { + iVar5 = pkVar7->field_7; + (pkVar7->_node).field_0 = iVar5 + 4; + pkVar4 = *(k_poll_event **)(iVar5 + 8); + *(k_poll_event **)&(pkVar7->_node).field_1 = pkVar4; + *(k_poll_event **)&pkVar4->_node = events + iVar2; + *(k_poll_event **)(iVar5 + 8) = events + iVar2; + } + else { + if (uVar6 == 1) { + iVar5 = pkVar7->field_7; + (pkVar7->_node).field_0 = iVar5; + pkVar4 = *(k_poll_event **)(iVar5 + 4); + *(k_poll_event **)&(pkVar7->_node).field_1 = pkVar4; + *(k_poll_event **)&pkVar4->_node = events + iVar2; + *(k_poll_event **)(iVar5 + 4) = events + iVar2; + } + } + pkVar7->poller = (_poller *)0x0; + *last_registered = *last_registered + 1; + } + } + else { + if (uVar6 == 3) { + iVar5 = k_queue_is_empty((k_queue *)pkVar7->field_7); + if (iVar5 == 0) { + uVar6 = 4; + goto LAB_23025bcc; + } + goto LAB_23025b8a; + } + if ((uVar6 != 1) || (uVar6 = 2, *(int *)(pkVar7->field_7 + 8) == 0)) goto LAB_23025b8a; +LAB_23025bcc: + pkVar7->poller = (_poller *)0x0; + bVar1 = false; + *(uint *)&pkVar7->field_0xc = + (*(uint *)&pkVar7->field_0xc >> 0xc & 0xf | uVar6) << 0xc | + *(uint *)&pkVar7->field_0xc & 0xffff0fff; + } + irq_unlock(uVar3); + iVar2 = iVar2 + 1; + pkVar7 = pkVar7 + 1; + } while( true ); +} + + + +void k_poll_event_init(k_poll_event *event,u32_t_conflict type,int mode,void *obj) + +{ + event->poller = (_poller *)0x0; + *(uint *)&event->field_0xc = + *(uint *)&event->field_0xc & 0xff | (type & 0xf) << 8 | (mode & 1U) << 0x10; + *(void **)&event->field_7 = obj; + return; +} + + + +int k_poll(k_poll_event *events,int num_events,s32_t timeout) + +{ + int iVar1; + _Bool _Var2; + undefined3 extraout_var; + uint uVar3; + uint uVar4; + int iVar5; + int iStack36; + int last_registered; + + iStack36 = -1; + _Var2 = polling_events(events,num_events,timeout,&iStack36); + if (CONCAT31(extraout_var,_Var2) != 0) { + k_sem_take(&g_poll_sem,timeout); + iStack36 = -1; + polling_events(events,num_events,timeout,&iStack36); + } + uVar3 = irq_lock(); + events = events + iStack36; + iVar1 = iStack36; + while (-1 < iVar1) { + events->poller = (_poller *)0x0; + uVar4 = *(uint *)&events->field_0xc >> 8 & 0xf; + if (((uVar4 == 2) || (uVar4 == 3)) || (uVar4 == 1)) { + iVar5 = (events->_node).field_0; + *(int *)(events->_node).field_1 = iVar5; + *(undefined4 *)(iVar5 + 4) = (events->_node).field_1; + } + irq_unlock(); + irq_lock(); + iVar1 = iVar1 + -1; + events = events + -1; + } + irq_unlock(uVar3); + return 0; +} + + + +int k_poll_signal_raise(k_poll_signal *signal,int result) + +{ + uint uVar1; + int iVar2; + k_poll_signal *pkVar3; + + uVar1 = irq_lock(); + signal->signaled = 1; + pkVar3 = (k_poll_signal *)(signal->poll_events).field_0; + signal->result = result; + if (signal != pkVar3) { + iVar2 = (pkVar3->poll_events).field_0; + *(int *)(pkVar3->poll_events).field_1 = iVar2; + *(undefined4 *)(iVar2 + 4) = (pkVar3->poll_events).field_1; + pkVar3->signaled = 0; + pkVar3->result = pkVar3->result | 0x2000; + k_sem_give(&g_poll_sem); + } + irq_unlock(uVar1); + return 0; +} + + + +_Bool bt_rpa_irk_matches(u8_t *irk,bt_addr_t *addr) + +{ + bool bVar1; + int iVar2; + undefined auStack36 [4]; + u8_t hash [3]; + undefined uStack29; + u8_t res [16]; + + memcpy(hash,addr->val + 3,3); + memset(&uStack29,0,0xd); + iVar2 = bt_encrypt_le(irk,hash,hash); + if (iVar2 == 0) { + memcpy(auStack36,hash,3); + iVar2 = memcmp(addr,auStack36,3); + bVar1 = iVar2 == 0; + } + else { + bVar1 = false; + } + return (_Bool)bVar1; +} + + + +void k_work_submit_to_queue(k_work_q *work_q,k_work *work) + +{ + uint uVar1; + + uVar1 = atomic_or(work->flags,1); + if ((uVar1 & 1) == 0) { + k_queue_append((k_queue *)work_q,work); + return; + } + return; +} + + + +void work_queue_main(void *p1) + +{ + void *pvVar1; + uint uVar2; + + do { + pvVar1 = k_queue_get((k_queue *)&g_work_queue_main,-1); + uVar2 = atomic_and((atomic_t *)((int)pvVar1 + 8),-2); + if ((uVar2 & 1) != 0) { + (**(code **)((int)pvVar1 + 4))(pvVar1,*(code **)((int)pvVar1 + 4)); + } + k_yield(); + } while( true ); +} + + + +int k_work_q_start(void) + +{ + int iVar1; + + timer_records[0].timer = (void *)0x0; + timer_records[0].delay_work = (k_delayed_work *)0x0; + timer_records[1].timer = (void *)0x0; + timer_records[1].delay_work = (k_delayed_work *)0x0; + timer_records[2].timer = (void *)0x0; + timer_records[2].delay_work = (k_delayed_work *)0x0; + timer_records[3].timer = (void *)0x0; + timer_records[3].delay_work = (k_delayed_work *)0x0; + timer_records[4].timer = (void *)0x0; + timer_records[4].delay_work = (k_delayed_work *)0x0; + k_queue_init((k_queue *)&g_work_queue_main,0x14); + iVar1 = k_thread_create(&work_q_thread,"work_q_thread",0x600,work_queue_main,0x1e); + return iVar1; +} + + + +int k_work_init(k_work *work,k_work_handler_t *handler) + +{ + atomic_and(work->flags,-2); + work->handler = handler; + return 0; +} + + + +void k_work_submit(k_work *work) + +{ + k_work_submit_to_queue(&g_work_queue_main,work); + return; +} + + + +void k_delayed_work_init(k_delayed_work *work,k_work_handler_t *handler) + +{ + k_work_init((k_work *)work,handler); + k_timer_init((k_timer_t_conflict1 *)&work->timer,work_timeout,work); + work->work_q = (k_work_q *)0x0; + return; +} + + + +void k_delayed_work_del_timer(k_delayed_work *work) + +{ + if ((work != (k_delayed_work *)0x0) && ((work->timer).timer.hdl != (void *)0x0)) { + k_timer_delete((k_timer_t_conflict1 *)&work->timer); + (work->timer).timer.hdl = (void *)0x0; + return; + } + return; +} + + + +int add_timer_record(k_delayed_work *delay_work) + +{ + _snode *p_Var1; + timer_rec_d *ptVar2; + timer_rec_d *ptVar3; + int iVar4; + + p_Var1 = (_snode *)(delay_work->timer).timer.hdl; + ptVar2 = timer_records; + ptVar3 = timer_records; + do { + if ((((bt_conn_tx *)ptVar3)->node).next == p_Var1) { + return 0; + } + ptVar3 = (timer_rec_d *)&((bt_conn_tx *)ptVar3)->user_data; + } while ((bt_conn_tx *)ptVar3 != conn_tx); + iVar4 = 0; + do { + if ((ptVar2->timer).hdl == (void *)0x0) { + *(_snode **)&timer_records[iVar4].timer.hdl = p_Var1; + timer_records[iVar4].delay_work = delay_work; + return 0; + } + iVar4 = iVar4 + 1; + ptVar2 = ptVar2 + 1; + } while (iVar4 != 5); + return -1; +} + + + +int remv_timer_record(k_delayed_work *delay_work) + +{ + timer_rec_d *ptVar1; + int iVar2; + + ptVar1 = timer_records; + iVar2 = 0; + do { + if ((ptVar1->timer).hdl == (delay_work->timer).timer.hdl) { + timer_records[iVar2].timer.hdl = (void *)0x0; + return 0; + } + iVar2 = iVar2 + 1; + ptVar1 = ptVar1 + 1; + } while (iVar2 != 5); + return 0; +} + + + +int k_delayed_work_cancel(k_delayed_work *work) + +{ + uint uVar1; + uint uVar2; + + uVar1 = irq_lock(); + uVar2 = atomic_get((work->work).flags); + uVar2 = uVar2 & 1; + if (uVar2 == 0) { + if (work->work_q == (k_work_q *)0x0) { + uVar2 = 0xffffffea; + } + else { + k_timer_stop((k_timer_t_conflict1 *)&work->timer); + remv_timer_record(work); + work->work_q = (k_work_q *)0x0; + (work->timer).timeout = 0; + (work->timer).start_ms = 0; + } + } + else { + uVar2 = 0xffffffbc; + } + irq_unlock(uVar1); + return uVar2; +} + + + +int k_delayed_work_submit(k_delayed_work *work,uint32_t delay) + +{ + uint uVar1; + int iVar2; + + uVar1 = irq_lock(); + if (work->work_q != (k_work_q *)0x0) { + iVar2 = -0x30; + if (work->work_q != &g_work_queue_main) goto done; + iVar2 = k_delayed_work_cancel(work); + if (iVar2 < 0) goto done; + } + work->work_q = &g_work_queue_main; + if (delay == 0) { + k_work_submit_to_queue(&g_work_queue_main,(k_work *)work); + work->work_q = (k_work_q *)0x0; + } + else { + k_timer_start((k_timer_t_conflict1 *)&work->timer,delay); + iVar2 = add_timer_record(work); + if (iVar2 == 0) goto done; + vAssertCalled(); + } + iVar2 = 0; +done: + irq_unlock(uVar1); + return iVar2; +} + + + +timer_rec_d * get_timer_record(void *hdl) + +{ + timer_rec_d *ptVar1; + int iVar2; + + ptVar1 = timer_records; + iVar2 = 0; + do { + if ((ptVar1->timer).hdl == hdl) { + return timer_records + iVar2; + } + iVar2 = iVar2 + 1; + ptVar1 = ptVar1 + 1; + } while (iVar2 != 5); + return (timer_rec_d *)0x0; +} + + + +void work_timeout(void *timer) + +{ + k_delayed_work *work; + timer_rec_d *ptVar1; + + ptVar1 = get_timer_record(timer); + if (ptVar1 == (timer_rec_d *)0x0) { + vAssertCalled(); + } + work = ptVar1->delay_work; + k_timer_stop((k_timer_t_conflict1 *)&work->timer); + k_work_submit_to_queue(work->work_q,(k_work *)work); + work->work_q = (k_work_q *)0x0; + (ptVar1->timer).hdl = (void *)0x0; + return; +} + + + +void reverse_bytearray(uint8_t *src,uint8_t *result,int array_size) + +{ + uint8_t *puVar1; + int iVar2; + + result = result + array_size; + iVar2 = 0; + while (result = result + -1, iVar2 < array_size) { + puVar1 = src + iVar2; + iVar2 = iVar2 + 1; + *result = *puVar1; + } + return; +} + + + +void gf_double(uint8_t *out,uint8_t *in) + +{ + byte *pbVar1; + byte *pbVar2; + uint uVar3; + + uVar3 = (int)(char)*in >> 0x1f & 0x87; + pbVar1 = out + 0xf; + pbVar2 = in + 0xf; + while( true ) { + *pbVar1 = (byte)uVar3 ^ *pbVar2 << 1; + if (pbVar2 == in) break; + uVar3 = (uint)(*pbVar2 >> 7); + pbVar1 = pbVar1 + -1; + pbVar2 = pbVar2 + -1; + } + return; +} + + + +int tc_cmac_erase(TCCmacState_t s) + +{ + if (s != (TCCmacState_t)0x0) { + _set(s,0,0x58); + return 1; + } + return 0; +} + + + +int tc_cmac_init(TCCmacState_t s) + +{ + if (s != (TCCmacState_t)0x0) { + _set(s,0,0x10); + _set(s->leftover,0,0x10); + s->leftover_offset = 0; + *(undefined4 *)&s->countdown = 0; + *(undefined4 *)((int)&s->countdown + 4) = 0x10000; + return 1; + } + return 0; +} + + + +int tc_cmac_setup(TCCmacState_t s,uint8_t *key,TCAesKeySched_t sched) + +{ + if ((s != (TCCmacState_t)0x0) && (key != (uint8_t *)0x0)) { + _set(s,0,0x58); + s->sched = sched; + tc_aes128_set_encrypt_key(sched,key); + _set(s,0,0x10); + tc_aes_encrypt((uint8_t *)s,(uint8_t *)s,s->sched); + gf_double(s->K1,(uint8_t *)s); + gf_double(s->K2,s->K1); + tc_cmac_init(s); + return 1; + } + return 0; +} + + + +int tc_cmac_update(TCCmacState_t s,uint8_t *data,size_t data_length) + +{ + uint8_t *puVar1; + byte *pbVar2; + uint to_len; + byte *pbVar3; + uint uVar4; + TCCmacState_t ptVar5; + int iVar6; + uint uVar7; + + if (s == (TCCmacState_t)0x0) { + return 0; + } + if (data_length == 0) { + return 1; + } + if (data == (uint8_t *)0x0) { + return 0; + } + uVar4 = *(uint *)&s->countdown; + to_len = *(uint *)((int)&s->countdown + 4); + if ((uVar4 | to_len) == 0) { + return 0; + } + uVar7 = s->leftover_offset; + *(uint *)&s->countdown = uVar4 - 1; + *(int *)((int)&s->countdown + 4) = (uint)(uVar4 - 1 < uVar4) + (to_len - 1); + to_len = data_length; + if (uVar7 != 0) { + to_len = 0x10 - uVar7; + if (data_length < to_len) { + _copy(s->leftover + uVar7,data_length,data,data_length); + data_length = data_length + s->leftover_offset; + goto LAB_2302621a; + } + _copy(s->leftover + uVar7,to_len,data,to_len); + data_length = (data_length - 0x10) + uVar7; + data = data + to_len; + s->leftover_offset = 0; + ptVar5 = s; + do { + puVar1 = ptVar5->iv; + ptVar5->iv[0] = ptVar5->iv[0] ^ ptVar5->leftover[0]; + ptVar5 = (TCCmacState_t)(puVar1 + 1); + } while ((TCCmacState_t)s->K1 != (TCCmacState_t)(puVar1 + 1)); + tc_aes_encrypt((uint8_t *)s,(uint8_t *)s,s->sched); + to_len = data_length; + } + while (0x10 < data_length) { + iVar6 = 0; + do { + pbVar2 = s->iv + iVar6; + pbVar3 = data + (to_len - data_length) + iVar6; + iVar6 = iVar6 + 1; + *pbVar2 = *pbVar3 ^ *pbVar2; + } while (iVar6 != 0x10); + tc_aes_encrypt((uint8_t *)s,(uint8_t *)s,s->sched); + data_length = data_length - 0x10; + } + if (data_length == 0) { + return 1; + } + _copy(s->leftover,data_length,data + (to_len - data_length),data_length); +LAB_2302621a: + s->leftover_offset = data_length; + return 1; +} + + + +int tc_cmac_final(uint8_t *tag,TCCmacState_t s) + +{ + byte *pbVar1; + uint8_t *puVar2; + int iVar3; + uint uVar4; + TCCmacState_t ptVar5; + + if ((tag != (uint8_t *)0x0) && (s != (TCCmacState_t)0x0)) { + uVar4 = s->leftover_offset; + if (uVar4 == 0x10) { + puVar2 = s->K1; + } + else { + _set(s->leftover + uVar4,0,0x10 - uVar4); + puVar2 = s->K2; + s->leftover[s->leftover_offset] = -0x80; + } + iVar3 = 0; + ptVar5 = s; + do { + pbVar1 = puVar2 + iVar3; + iVar3 = iVar3 + 1; + ptVar5->iv[0] = ptVar5->iv[0] ^ ptVar5->leftover[0] ^ *pbVar1; + ptVar5 = (TCCmacState_t)(ptVar5->iv + 1); + } while (iVar3 != 0x10); + tc_aes_encrypt(tag,(uint8_t *)s,s->sched); + tc_cmac_erase(s); + return 1; + } + return 0; +} + + + +uint _copy(uint8_t *to,uint to_len,uint8_t *from,uint from_len) + +{ + if (from_len <= to_len) { + memcpy(to,from,from_len); + return from_len; + } + return 0; +} + + + +void * _set(void *__s,int __c,size_t __n) + +{ + uint uVar1; + uint extraout_a1; + uint *puVar2; + uint *puVar3; + void *pvVar4; + uint uVar5; + + uVar1 = 0xf; + if (0xf < __n) { + uVar5 = (uint)__s & 0xf; + puVar3 = (uint *)__s; + if (uVar5 != 0) { + pvVar4 = __s; + __s = (void *)(*(code *)(uVar5 * 4 + 0x2306d210))(); + puVar3 = (uint *)((int)pvVar4 - (uVar5 - 0x10)); + __n = __n + (uVar5 - 0x10); + __c = extraout_a1; + if (__n <= uVar1) goto LAB_2306d200; + } + if (__c != 0) { + uVar5 = __c & 0xffU | (__c & 0xffU) << 8; + __c = uVar5 | uVar5 << 0x10; + } + uVar5 = __n & 0xfffffff0; + __n = __n & 0xf; + puVar2 = (uint *)(uVar5 + (int)puVar3); + do { + *puVar3 = __c; + puVar3[1] = __c; + puVar3[2] = __c; + puVar3[3] = __c; + puVar3 = puVar3 + 4; + } while (puVar3 < puVar2); + if (__n == 0) { + return __s; + } + } +LAB_2306d200: + // WARNING: Could not recover jumptable at 0x2306d210. Too many branches + // WARNING: Treating indirect jump as call + pvVar4 = (void *)(*(code *)(&UNK_2306d214 + (uVar1 - __n) * 4))(); + return pvVar4; +} + + + +uint8_t _double_byte(uint8_t a) + +{ + undefined3 in_register_00002029; + + return a << 1 ^ (char)(CONCAT31(in_register_00002029,a) >> 7) * '\x1b'; +} + + + +rx_msg_struct * bl_find_valid_queued_entry(void) + +{ + int iVar1; + int iVar2; + undefined auStack40 [4]; + rx_msg_struct empty_msg; + + iVar1 = 0; + memset(auStack40,0,8); + do { + iVar2 = memcmp(msg_array + iVar1,auStack40,8); + if (iVar2 == 0) { + return msg_array + iVar1; + } + iVar1 = iVar1 + 1; + } while (iVar1 != 9); + return (rx_msg_struct *)0x0; +} + + + +void bl_onchiphci_rx_packet_handler + (uint8_t pkt_type,uint16_t src_id,uint8_t *param,uint8_t param_len,void *rx_buf) + +{ + uint8_t uVar1; + bool bVar2; + uint32_t monitor; + undefined uVar3; + bt_buf_type type; + undefined3 in_register_00002029; + int iVar4; + undefined *puVar5; + int iVar6; + rx_msg_struct *data; + void *__dest; + uint uVar7; + undefined2 in_register_0000202e; + undefined3 in_register_00002035; + size_t xWantedSize; + size_t len; + + xWantedSize = CONCAT31(in_register_00002035,param_len); + iVar4 = CONCAT31(in_register_00002029,pkt_type); + uVar3 = (undefined)src_id; + uVar3 = (undefined)(src_id >> 8); + if (rx_buf == (void *)0x0) { + if (iVar4 == 1) { + type = BT_BUF_ACL_IN; +LAB_2302641c: + rx_buf = bt_buf_get_rx(type,0); + } + else { + if (1 < (iVar4 - 2U & 0xff)) { + if (((iVar4 == 4) && (*param == '\x02')) && (iVar6 = bt_buf_get_rx_avail_cnt(), iVar6 < 2)) + goto LAB_23026436; + type = BT_BUF_EVT; + goto LAB_2302641c; + } + rx_buf = bt_buf_get_cmd_complete(-1); + } + if ((net_buf *)rx_buf == (net_buf *)0x0) { +LAB_23026436: + monitor = monitor + 1; + if ((monitor & 0xff) == 0) { + puts("hci_rx_pool is not available\n"); + } + if (((iVar4 != 4) || (*param != '\x02')) && + (data = bl_find_valid_queued_entry(), data != (rx_msg_struct *)0x0)) { + *(undefined *)&data->src_id = uVar3; + data->pkt_type = pkt_type; + *(undefined *)((int)&data->src_id + 1) = uVar3; + if (xWantedSize != 0) { + __dest = k_malloc(xWantedSize); + *(undefined *)((int)&data->param + 1) = (char)((uint)__dest >> 8); + *(char *)&data->param = (char)__dest; + *(undefined *)((int)&data->param + 2) = (char)((uint)__dest >> 0x10); + *(undefined *)((int)&data->param + 3) = (char)((uint)__dest >> 0x18); + memcpy(__dest,param,xWantedSize); + } + data->param_len = param_len; + k_queue_append(&msg_queue,data); + return; + } + return; + } + monitor = 0; + } + puVar5 = (undefined *) + ((uint)*(ushort *)((int)&((net_buf *)rx_buf)->field_4 + 4) + + *(int *)&((net_buf *)rx_buf)->field_4); + switch(iVar4 - 1U & 0xff) { + case 0: + ((net_buf *)rx_buf)->user_data[0] = '\x03'; + uVar7 = bt_onchiphci_hanlde_rx_acl(param,puVar5); + len = uVar7 & 0xffff; + goto LAB_23026568; + case 1: + *puVar5 = 0xe; + puVar5[1] = param_len + '\x03'; + puVar5[3] = uVar3; + puVar5[2] = 1; + puVar5[4] = uVar3; + len = xWantedSize + 5; + memcpy(puVar5 + 5,param,xWantedSize); + bVar2 = true; + break; + case 2: + *puVar5 = 0xf; + puVar5[1] = 4; + uVar1 = *param; + puVar5[4] = uVar3; + puVar5[2] = uVar1; + puVar5[3] = 1; + puVar5[5] = uVar3; + bVar2 = true; + len = 6; + break; + case 3: + ((net_buf *)rx_buf)->user_data[0] = '\x01'; + *puVar5 = 0x3e; + puVar5[1] = param_len; + len = xWantedSize + 2; + memcpy(puVar5 + 2,param,xWantedSize); +LAB_23026568: + bVar2 = false; + break; + case 4: + ((net_buf *)rx_buf)->user_data[0] = '\x01'; + *puVar5 = uVar3; + puVar5[1] = param_len; + bVar2 = CONCAT22(in_register_0000202e,src_id) == 0x13; + len = xWantedSize + 2; + memcpy(puVar5 + 2,param,xWantedSize); + break; + default: + return; + } + net_buf_simple_add((net_buf_simple *)&((net_buf *)rx_buf)->field_4,len); + if (bVar2) { + bt_recv_prio(); + return; + } + hci_driver_enque_recvq((net_buf *)rx_buf); + return; +} + + + +void bl_handle_queued_msg(void) + +{ + int iVar1; + net_buf *rx_buf; + uint8_t *__s; + + iVar1 = k_queue_is_empty(&msg_queue); + if (iVar1 == 0) { + rx_buf = bt_buf_get_rx(BT_BUF_ACL_IN,0); + if (rx_buf != (net_buf *)0x0) { + __s = (uint8_t *)k_queue_get(&msg_queue,0); + bl_onchiphci_rx_packet_handler + (*__s,*(uint16_t *)(__s + 1),*(uint8_t **)(__s + 3),__s[7],rx_buf); + if (*(void **)(__s + 3) != (void *)0x0) { + k_free(*(void **)(__s + 3)); + } + memset(__s,0,8); + return; + } + } + return; +} + + + +void bl_onchiphci_interface_deinit(void) + +{ + void *pvVar1; + + while (pvVar1 = k_queue_get(&msg_queue,0), pvVar1 != (void *)0x0) { + if (*(void **)((int)pvVar1 + 3) != (void *)0x0) { + k_free(*(void **)((int)pvVar1 + 3)); + } + } + k_queue_free(&msg_queue); + return; +} + + + +uint8_t bl_onchiphci_interface_init(void) + +{ + uint8_t uVar1; + + memset(msg_array,0,0x48); + k_queue_init(&msg_queue,9); + uVar1 = bt_onchiphci_interface_init(bl_onchiphci_rx_packet_handler); + return uVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bl_onchiphci_send_2_controller(net_buf *buf) + +{ + ushort uVar1; + int iVar2; + ushort dest_id; + byte pkt_type; + ushort *puVar3; + ushort uStack44; + byte bStack42; + hci_pkt_struct pkt; + + pkt_type = buf->user_data[0]; + if (pkt_type == 0) { + dest_id = *(ushort *)((int)&buf->field_4 + 4); + if ((2 < dest_id) && + (puVar3 = *(ushort **)&buf->field_4, (uint)*(byte *)(puVar3 + 1) <= (uint)dest_id)) { + uStack44 = *puVar3; + net_buf_simple_pull((net_buf_simple *)&buf->field_4,3); + pkt.p._0_4_ = *(byte **)&buf->field_4; + dest_id = 0; + if ((((uint)uStack44 - 0x2013 & 0xffff) < 0x20) && + (dest_id = (ushort)pkt_type, (1 << ((uint)uStack44 - 0x2013 & 0x1f) & 0xa000e1cdU) != 0)) { + dest_id = (ushort)*(byte *)pkt.p; + } + pkt.p._4_4_ = pkt.p._4_4_ & 0xffffff00 | (uint)*(byte *)(puVar3 + 1); +LAB_23026778: + iVar2 = bt_onchiphci_send(pkt_type,dest_id,(hci_pkt_struct *)&uStack44); + return iVar2; + } + } + else { + if ((pkt_type == 2) && (3 < *(ushort *)((int)&buf->field_4 + 4))) { + dest_id = (*(ushort **)&buf->field_4)[1]; + uVar1 = **(ushort **)&buf->field_4; + net_buf_simple_pull((net_buf_simple *)&buf->field_4,4); + if (dest_id <= *(ushort *)((int)&buf->field_4 + 4)) { + pkt.p._4_4_ = *(uint *)&buf->field_4; + pkt.p._0_4_ = (byte *)CONCAT22(pkt.p._2_2_,dest_id); + dest_id = (ushort)(((uint)uVar1 << 0x14) >> 0x14); + bStack42 = (byte)(uVar1 >> 0xc); + pkt_type = 1; + uStack44 = dest_id; + goto LAB_23026778; + } + } + } + return -0x16; +} + + + +int atomic_test_bit(atomic_t *target,int bit) + +{ + atomic_val_t aVar1; + + aVar1 = atomic_get(target); + return aVar1 >> (bit & 0x1fU) & 1; +} + + + +void tx_free(bt_conn_tx *tx) + +{ + tx->cb = (bt_conn_tx_cb_t *)0x0; + tx->user_data = (void *)0x0; + tx->pending_no_cb = 0; + k_queue_append((k_queue *)&free_tx,tx); + return; +} + + + +// WARNING: Type propagation algorithm not settling + +int send_frag(ushort *param_1,net_buf *param_2,int param_3,int param_4) + +{ + ushort uVar1; + bt_conn_tx *tx; + undefined *puVar2; + bt_conn_tx *pbVar3; + int iVar4; + bt_conn_tx *pbVar5; + undefined4 uVar6; + int *unaff_s6; + + tx = *(bt_conn_tx **)param_2->user_data; + k_sem_take(&bt_dev.le.pkts,0xffffffff); + if (*(char *)((int)param_1 + 0xd) == '\x04') { + puVar2 = (undefined *)net_buf_simple_push((net_buf_simple *)¶m_2->field_4,4); + uVar1 = *param_1; + *puVar2 = (char)uVar1; + puVar2[1] = (byte)((uint)(param_3 << 0xc) >> 8) | (byte)((uint)uVar1 >> 8); + iVar4 = (uint)*(ushort *)((int)¶m_2->field_4 + 4) - 4; + puVar2[2] = (char)((uint)(iVar4 * 0x10000) >> 0x10); + puVar2[3] = (char)((uint)iVar4 >> 8); + irq_lock(); + if (tx == (bt_conn_tx *)0x0) { + iVar4 = *(int *)(param_1 + 0xc); + if (iVar4 == 0) { + unaff_s6 = (int *)(param_1 + 0xe); + iVar4 = *(int *)(param_1 + 0xe); + } + else { + unaff_s6 = (int *)(iVar4 + 0xc); + iVar4 = *(int *)(iVar4 + 0xc); + } + *unaff_s6 = iVar4 + 1; + } + else { + tx->node = 0; + if (*(bt_conn_tx **)(param_1 + 0xc) == (bt_conn_tx *)0x0) { + *(bt_conn_tx **)(param_1 + 0xc) = tx; + *(bt_conn_tx **)(param_1 + 10) = tx; + } + else { + *(bt_conn_tx **)&(*(bt_conn_tx **)(param_1 + 0xc))->node = tx; + *(bt_conn_tx **)(param_1 + 0xc) = tx; + } + } + irq_unlock(); + param_2->user_data[0] = '\x02'; + iVar4 = bt_send(param_2); + if (iVar4 == 0) { + return 1; + } + printf("Unable to send to driver (err %d)\r\n"); + irq_lock(); + if (tx == (bt_conn_tx *)0x0) { + *unaff_s6 = *unaff_s6 + -1; + } + else { + pbVar3 = (bt_conn_tx *)0x0; + pbVar5 = *(bt_conn_tx **)(param_1 + 10); + while (pbVar5 != (bt_conn_tx *)0x0) { + if (tx == pbVar5) { + uVar6 = tx->node; + if (pbVar3 == (bt_conn_tx *)0x0) { + *(undefined4 *)(param_1 + 10) = uVar6; + if (tx == *(bt_conn_tx **)(param_1 + 0xc)) { + *(undefined4 *)(param_1 + 0xc) = uVar6; + } + } + else { + pbVar3->node = uVar6; + if (tx == *(bt_conn_tx **)(param_1 + 0xc)) { + *(bt_conn_tx **)(param_1 + 0xc) = pbVar3; + } + } + tx->node = 0; + break; + } + pbVar3 = pbVar5; + pbVar5 = *(bt_conn_tx **)&pbVar5->node; + } + } + irq_unlock(); + } + k_sem_give(&bt_dev.le.pkts); + if (tx != (bt_conn_tx *)0x0) { + tx_free(tx); + } + if (param_4 != 0) { + net_buf_unref(param_2); + param_4 = 0; + } + return param_4; +} + + + +void notify_connected(bt_conn *conn) + +{ + bt_conn_cb *pbVar1; + + pbVar1 = callback_list; + while (pbVar1 != (bt_conn_cb *)0x0) { + if (pbVar1->connected != (anon_subr_void_bt_conn_ptr_u8_t_for_connected *)0x0) { + (*pbVar1->connected)(conn,conn->err); + } + pbVar1 = pbVar1->_next; + } + if (conn->err == '\0') { + bt_gatt_connected(conn); + return; + } + return; +} + + + +void bt_conn_reset_rx_state(bt_conn *conn) + +{ + if (conn->rx_len != 0) { + net_buf_unref(conn->rx); + conn->rx = (net_buf *)0x0; + conn->rx_len = 0; + return; + } + return; +} + + + +void conn_cleanup(bt_conn *conn) + +{ + net_buf *buf; + void *pvVar1; + + while (buf = net_buf_get((k_fifo *)(k_queue *)&conn->tx_queue,0), buf != (net_buf *)0x0) { + if (*(bt_conn_tx **)buf->user_data != (bt_conn_tx *)0x0) { + tx_free(*(bt_conn_tx **)buf->user_data); + } + net_buf_unref(buf); + } + bt_conn_reset_rx_state(conn); + k_delayed_work_submit(&conn->update_work,0); + k_queue_free((k_queue *)&conn->tx_queue); + pvVar1 = (conn->update_work).timer.timer.hdl; + (conn->tx_queue)._queue.hdl = (void *)0x0; + if (pvVar1 != (void *)0x0) { + k_delayed_work_del_timer(&conn->update_work); + return; + } + return; +} + + + +void tx_notify(bt_conn *conn) + +{ + bt_conn_tx *tx; + uint uVar1; + void *pvVar2; + _snode *p_Var3; + bt_conn_tx_cb_t *pbVar4; + + while( true ) { + uVar1 = irq_lock(); + tx = (bt_conn_tx *)(conn->tx_complete).head; + if (tx == (bt_conn_tx *)0x0) break; + p_Var3 = (tx->node).next; + *(_snode **)&(conn->tx_complete).head = p_Var3; + if (tx == (bt_conn_tx *)(conn->tx_complete).tail) { + *(_snode **)&(conn->tx_complete).tail = p_Var3; + } + irq_unlock(uVar1); + pvVar2 = tx->user_data; + pbVar4 = tx->cb; + tx_free(tx); + (*pbVar4)(conn,pvVar2); + } + irq_unlock(); + return; +} + + + +void tx_complete_work(k_work *work) + +{ + tx_notify((bt_conn *)work[-4].flags); + return; +} + + + +k_sem * bt_conn_get_pkts(bt_conn *conn) + +{ + return &bt_dev.le.pkts; +} + + + +void notify_le_param_updated(bt_conn *conn) + +{ + bt_conn_cb *pbVar1; + int iVar2; + + iVar2 = atomic_test_bit(conn->flags,9); + pbVar1 = callback_list; + if ((((iVar2 != 0) && (*(ushort *)(conn->field_20 + 0x18) <= *(ushort *)(conn->field_20 + 0x16))) + && (*(ushort *)(conn->field_20 + 0x16) <= *(ushort *)(conn->field_20 + 0x1a))) && + (*(int *)(conn->field_20 + 0x1c) == *(int *)(conn->field_20 + 0x20))) { + atomic_and(conn->flags,-0x201); + pbVar1 = callback_list; + } + while (pbVar1 != (bt_conn_cb *)0x0) { + if (pbVar1->le_param_updated != + (anon_subr_void_bt_conn_ptr_u16_t_u16_t_u16_t_for_le_param_updated *)0x0) { + (*pbVar1->le_param_updated) + (conn,*(u16_t *)(conn->field_20 + 0x16),*(u16_t *)(conn->field_20 + 0x1c), + *(u16_t *)(conn->field_20 + 0x1e)); + } + pbVar1 = pbVar1->_next; + } + return; +} + + + +_Bool le_param_req(bt_conn *conn,bt_le_conn_param *param) + +{ + bt_conn_cb *pbVar1; + _Bool _Var2; + _Bool _Var3; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + + _Var2 = bt_le_conn_params_valid(param); + pbVar1 = callback_list; + if (CONCAT31(extraout_var,_Var2) == 0) { +LAB_23026aee: + _Var2 = false; + } + else { + while (pbVar1 != (bt_conn_cb *)0x0) { + if ((pbVar1->le_param_req != + (anon_subr__Bool_bt_conn_ptr_bt_le_conn_param_ptr_for_le_param_req *)0x0) && + ((_Var3 = (*pbVar1->le_param_req)(conn,param), CONCAT31(extraout_var_00,_Var3) == 0 || + (_Var3 = bt_le_conn_params_valid(param), CONCAT31(extraout_var_01,_Var3) == 0)))) + goto LAB_23026aee; + pbVar1 = pbVar1->_next; + } + } + return _Var2; +} + + + +_Bool le_check_valid_conn(void) + +{ + atomic_val_t aVar1; + bool bVar2; + + aVar1 = atomic_get(&conns[0].ref); + bVar2 = true; + if (aVar1 == 0) { + aVar1 = atomic_get(&conns[1].ref); + bVar2 = aVar1 != 0; + } + return (_Bool)bVar2; +} + + + +void bt_conn_identity_resolved(bt_conn *conn) + +{ + bt_conn_cb *pbVar1; + bt_addr_le_t *pbVar2; + + pbVar2 = (bt_addr_le_t *)(conn->field_20 + 0xe); + if (conn->role != '\0') { + pbVar2 = (bt_addr_le_t *)(conn->field_20 + 7); + } + pbVar1 = callback_list; + while (pbVar1 != (bt_conn_cb *)0x0) { + if (pbVar1->identity_resolved != + (anon_subr_void_bt_conn_ptr_bt_addr_le_t_ptr_bt_addr_le_t_ptr_for_identity_resolved *)0x0) { + (*pbVar1->identity_resolved)(conn,pbVar2,(bt_addr_le_t *)conn->field_20); + } + pbVar1 = pbVar1->_next; + } + return; +} + + + +int bt_conn_le_start_encryption(bt_conn *conn,u8_t *rand,u8_t *ediv,u8_t *ltk,size_t len) + +{ + u16_t uVar1; + net_buf *buf; + undefined *puVar2; + int iVar3; + + buf = bt_hci_cmd_create(0x2019,'\x1c'); + if (buf != (net_buf *)0x0) { + puVar2 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,0x1c); + uVar1 = conn->handle; + *puVar2 = (char)uVar1; + puVar2[1] = (char)(uVar1 >> 8); + memcpy(puVar2 + 2,rand,8); + memcpy(puVar2 + 10,ediv,2); + memcpy(puVar2 + 0xc,ltk,len); + if (len < 0x10) { + memset(puVar2 + 0xc + len,0,0x10 - len); + } + iVar3 = bt_hci_cmd_send_sync(0x2019,buf,(net_buf **)0x0); + return iVar3; + } + return -0x37; +} + + + +void bt_conn_security_changed(bt_conn *param_1,int param_2) + +{ + bt_conn_cb *pbVar1; + + pbVar1 = callback_list; + while (pbVar1 != (bt_conn_cb *)0x0) { + if (pbVar1->security_changed != + (anon_subr_void_bt_conn_ptr_bt_security_t_bt_security_err_for_security_changed *)0x0) { + (*pbVar1->security_changed)(param_1,param_1->sec_level,(bt_security_err)param_2); + } + pbVar1 = pbVar1->_next; + } + if ((param_2 == 0) && (1 < (byte)param_1->sec_level)) { + bt_keys_update_usage(param_1->id,(bt_addr_le_t *)param_1->field_20); + return; + } + return; +} + + + +int bt_conn_set_security(bt_conn *conn,bt_security_t sec) + +{ + int iVar1; + undefined3 in_register_0000202d; + + if (conn->state == BT_CONN_CONNECTED) { + iVar1 = 0; + if (((uint)(byte)conn->sec_level < CONCAT31(in_register_0000202d,sec)) && + ((uint)(byte)conn->required_sec_level < CONCAT31(in_register_0000202d,sec))) { + if (sec < '\0') { + atomic_or(conn->flags,0x800); + } + else { + atomic_and(conn->flags,-0x801); + } + conn->required_sec_level = sec & 0x7f; + iVar1 = bt_smp_start_security(conn); + if (iVar1 != 0) { + conn->required_sec_level = conn->sec_level; + } + } + return iVar1; + } + return -0x39; +} + + + +bt_security_t bt_conn_get_security(bt_conn *conn) + +{ + return conn->sec_level; +} + + + +void bt_conn_cb_register(bt_conn_cb *cb) + +{ + bt_conn_cb *pbVar1; + + pbVar1 = cb; + cb->_next = callback_list; + callback_list = pbVar1; + return; +} + + + +void bt_conn_recv(bt_conn *conn,net_buf *buf,u8_t flags) + +{ + ushort uVar1; + char *fmt; + size_t sVar2; + undefined3 in_register_00002031; + int iVar3; + uint uVar4; + + iVar3 = CONCAT31(in_register_00002031,flags); + tx_notify(conn); + if (iVar3 == 1) { + if (conn->rx_len == 0) { + fmt = "Unexpected L2CAP continuation\r\n"; + } + else { + uVar4 = (uint)*(ushort *)((int)&buf->field_4 + 4); + if (conn->rx_len < uVar4) { + fmt = "L2CAP data overflow\r\n"; + } + else { + sVar2 = net_buf_simple_tailroom((net_buf_simple *)&conn->rx->field_4); + if (uVar4 <= sVar2) { + net_buf_simple_add_mem + ((net_buf_simple *)&conn->rx->field_4,*(void **)&buf->field_4, + (uint)*(ushort *)((int)&buf->field_4 + 4)); + conn->rx_len = conn->rx_len - *(short *)((int)&buf->field_4 + 4); + net_buf_unref(buf); + if (conn->rx_len != 0) { + return; + } + buf = conn->rx; + conn->rx_len = 0; + conn->rx = (net_buf *)0x0; + goto LAB_23026e1e; + } + fmt = "Not enough buffer space for L2CAP data\r\n"; + } + } + printf(fmt); + } + else { + if (iVar3 == 2) { + uVar1 = **(ushort **)&buf->field_4; + if (conn->rx_len != 0) { + printf("Unexpected first L2CAP frame\r\n"); + bt_conn_reset_rx_state(conn); + } + uVar4 = ((uint)uVar1 - (uint)*(ushort *)((int)&buf->field_4 + 4)) + 4; + conn->rx_len = (u16_t)(uVar4 * 0x10000 >> 0x10); + if ((uVar4 & 0xffff) != 0) { + conn->rx = buf; + return; + } +LAB_23026e1e: + if ((uint)**(ushort **)&buf->field_4 + 4 == (uint)*(ushort *)((int)&buf->field_4 + 4)) { + bt_l2cap_recv(conn,buf); + return; + } + printf("ACL len mismatch (%u != %u)\r\n"); + goto LAB_23026db4; + } + printf("Unexpected ACL flags (0x%02x)\r\n",iVar3); + } + bt_conn_reset_rx_state(conn); +LAB_23026db4: + net_buf_unref(buf); + return; +} + + + +int bt_conn_send_cb(bt_conn *conn,net_buf *buf,bt_conn_tx_cb_t *cb,void *user_data) + +{ + int iVar1; + bt_conn_tx *tx; + + if (conn->state == BT_CONN_CONNECTED) { + if (cb == (bt_conn_tx_cb_t *)0x0) { + *(undefined4 *)buf->user_data = 0; + } + else { + tx = (bt_conn_tx *)k_queue_get((k_queue *)&free_tx,-1); + if (tx == (bt_conn_tx *)0x0) { + printf("Unable to allocate TX context\r\n"); + net_buf_unref(buf); + return -0x37; + } + if (conn->state != BT_CONN_CONNECTED) { + printf("Disconnected while allocating context\r\n"); + net_buf_unref(buf); + tx_free(tx); + goto LAB_23026e92; + } + tx->cb = cb; + tx->user_data = user_data; + tx->pending_no_cb = 0; + *(bt_conn_tx **)buf->user_data = tx; + } + net_buf_put(&conn->tx_queue,buf); + k_sem_give(&g_poll_sem); + iVar1 = 0; + } + else { + printf("not connected!\r\n"); + net_buf_unref(buf); +LAB_23026e92: + iVar1 = -0x39; + } + return iVar1; +} + + + +int bt_conn_prepare_events(k_poll_event *events) + +{ + int iVar1; + int iVar2; + atomic_val_t aVar3; + uint uVar4; + + conn_change.signaled = 0; + k_poll_event_init(events,1,0,&conn_change); + aVar3 = atomic_get(&conns[0].ref); + iVar1 = 1; + if (aVar3 != 0) { + if ((conns[0].state == BT_CONN_DISCONNECTED) && + (uVar4 = atomic_and(conns[0].flags,-0x41), (uVar4 & 0x40) != 0)) { + conn_cleanup(conns); + iVar1 = 1; + } + else { + iVar1 = 1; + if (conns[0].state == BT_CONN_CONNECTED) { + k_poll_event_init(events + 1,3,0,&conns[0].tx_queue); + *(undefined *)&events[1].field_0xc = 1; + iVar1 = 2; + } + } + } + aVar3 = atomic_get(&conns[1].ref); + iVar2 = iVar1; + if (aVar3 != 0) { + if ((conns[1].state == BT_CONN_DISCONNECTED) && + (uVar4 = atomic_and(conns[1].flags,-0x41), (uVar4 & 0x40) != 0)) { + conn_cleanup(conns + 1); + } + else { + if (conns[1].state == BT_CONN_CONNECTED) { + iVar2 = iVar1 + 1; + k_poll_event_init(events + iVar1,3,0,&conns[1].tx_queue); + *(undefined *)&events[iVar1].field_0xc = 1; + } + } + } + return iVar2; +} + + + +bt_conn * bt_conn_add_le(u8_t id,bt_addr_le_t *peer) + +{ + int iVar1; + atomic_val_t aVar2; + + iVar1 = atomic_get(&conns[0].ref); + if (iVar1 != 0) { + aVar2 = atomic_get(&conns[1].ref); + if (aVar2 != 0) { + return (bt_conn *)0x0; + } + iVar1 = 1; + } + memset(conns + iVar1,0,0xa0); + k_delayed_work_init(&conns[iVar1].update_work,conn_update_timeout); + k_work_init(&conns[iVar1].tx_complete_work,tx_complete_work); + atomic_set(&conns[iVar1].ref,1); + conns[iVar1].id = id; + memcpy(conns[iVar1].field_20,peer,7); + conns[iVar1].sec_level = BT_SECURITY_LOW; + conns[iVar1].required_sec_level = BT_SECURITY_LOW; + conns[iVar1].type = '\x01'; + *(undefined4 *)(conns[iVar1].field_20 + 0x18) = 0x280018; + return conns + iVar1; +} + + + +void bt_conn_set_state(bt_conn *conn,bt_conn_state_t state) + +{ + bt_conn_state_t bVar1; + bt_conn_tx *tx; + uint uVar2; + undefined3 in_register_0000202d; + _snode *p_Var3; + + bVar1 = conn->state; + if ((uint)bVar1 == CONCAT31(in_register_0000202d,state)) { + printf("no transition\r\n"); + return; + } + conn->state = state; + if (bVar1 == BT_CONN_DISCONNECTED) { + atomic_inc(&conn->ref); + } + else { + if ((bVar1 == BT_CONN_CONNECT) && (conn->type == '\x01')) { + k_delayed_work_cancel(&conn->update_work); + } + } + switch(conn->state) { + case BT_CONN_DISCONNECTED: + if (conn->type != '\x04') { + if (((uint)bVar1 - 4 & 0xff) < 2) { + do { + uVar2 = irq_lock(); + if (conn->pending_no_cb == 0) { + tx = (bt_conn_tx *)(conn->tx_pending).head; + if (tx != (bt_conn_tx *)0x0) { + p_Var3 = (tx->node).next; + *(_snode **)&(conn->tx_pending).head = p_Var3; + if (tx == (bt_conn_tx *)(conn->tx_pending).tail) { + *(_snode **)&(conn->tx_pending).tail = p_Var3; + } + } + irq_unlock(uVar2); + if (tx == (bt_conn_tx *)0x0) { + tx_notify(conn); + if (conn->type == '\x01') { + k_delayed_work_cancel(&conn->update_work); + } + atomic_or(conn->flags,0x40); + k_poll_signal_raise(&conn_change,0); + return; + } + irq_lock(); + conn->pending_no_cb = tx->pending_no_cb; + tx->pending_no_cb = 0; + irq_unlock(); + tx_free(tx); + } + else { + conn->pending_no_cb = conn->pending_no_cb - 1; + irq_unlock(); + } + k_sem_give(&bt_dev.le.pkts); + } while( true ); + } + if (bVar1 != BT_CONN_CONNECT) { + if ((bVar1 != BT_CONN_CONNECT_SCAN) && (bVar1 != BT_CONN_CONNECT_DIR_ADV)) { + return; + } + if (conn->err == '\0') goto LAB_23027182; + } + notify_connected(conn); + } +LAB_23027182: + atomic_dec(&conn->ref); + return; + case BT_CONN_CONNECT_SCAN: + case BT_CONN_CONNECT_DIR_ADV: + case BT_CONN_DISCONNECT: + break; + case BT_CONN_CONNECT: + if (conn->type == '\x01') { + k_delayed_work_submit(&conn->update_work,3000); + return; + } + break; + case BT_CONN_CONNECTED: + if (conn->type != '\x04') { + k_queue_init((k_queue *)&conn->tx_queue,0x14); + k_poll_signal_raise(&conn_change,0); + (conn->channels).head = (sys_snode_t *)0x0; + (conn->channels).tail = (sys_snode_t *)0x0; + bt_l2cap_connected(conn); + notify_connected(conn); + return; + } + break; + default: + printf("no valid (%u) state was set\r\n",CONCAT31(in_register_0000202d,state)); + return; + } + return; +} + + + +bt_conn * bt_conn_lookup_handle(u16_t handle) + +{ + bt_conn *pbVar1; + undefined2 in_register_0000202a; + atomic_val_t aVar2; + int iVar3; + + pbVar1 = conns; + aVar2 = atomic_get(&conns[0].ref); + if (((aVar2 == 0) || (1 < (byte)(conns[0].state + ~BT_CONN_CONNECT))) || + ((uint)conns[0].handle != CONCAT22(in_register_0000202a,handle))) { + pbVar1 = conns + 1; + aVar2 = atomic_get(&conns[1].ref); + if (aVar2 == 0) { + return (bt_conn *)0x0; + } + if (1 < (byte)(conns[1].state + ~BT_CONN_CONNECT)) { + return (bt_conn *)0x0; + } + if ((uint)conns[1].handle != CONCAT22(in_register_0000202a,handle)) { + return (bt_conn *)0x0; + } + iVar3 = 0xa0; + } + else { + iVar3 = 0; + } + atomic_inc(&pbVar1->ref); + return (bt_conn *)((int)&conns[0].handle + iVar3); +} + + + +int bt_conn_addr_le_cmp(bt_conn *conn,bt_addr_le_t *peer) + +{ + int iVar1; + + iVar1 = memcmp(peer,conn->field_20,7); + if (iVar1 != 0) { + iVar1 = 0x7e; + if (conn->role != '\0') { + iVar1 = 0x77; + } + iVar1 = memcmp(peer,(void *)((int)&conn->handle + iVar1),7); + return iVar1; + } + return 0; +} + + + +bt_conn * bt_conn_lookup_state_le(bt_addr_le_t *peer,bt_conn_state_t state) + +{ + atomic_val_t aVar1; + int iVar2; + undefined3 in_register_0000202d; + int iVar3; + + aVar1 = atomic_get(&conns[0].ref); + if ((((aVar1 == 0) || (conns[0].type != '\x01')) || + ((peer != (bt_addr_le_t *)0x0 && (iVar2 = bt_conn_addr_le_cmp(conns,peer), iVar2 != 0)))) || + ((uint)conns[0].state != CONCAT31(in_register_0000202d,state))) { + aVar1 = atomic_get(&conns[1].ref); + if (((aVar1 == 0) || (conns[1].type != '\x01')) || + (((peer != (bt_addr_le_t *)0x0 && (iVar2 = bt_conn_addr_le_cmp(conns + 1,peer), iVar2 != 0)) + || ((uint)conns[1].state != CONCAT31(in_register_0000202d,state))))) { + return (bt_conn *)0x0; + } + iVar2 = 0x360; + iVar3 = 0xa0; + } + else { + iVar2 = 0x2c0; + iVar3 = 0; + } + atomic_inc((atomic_t *)(gatt_write_buf + iVar2 + 0x174)); + return (bt_conn *)((int)&conns[0].handle + iVar3); +} + + + +bt_conn * bt_conn_lookup_addr_le(u8_t id,bt_addr_le_t *peer) + +{ + bt_conn *pbVar1; + bt_conn *pbVar2; + undefined3 in_register_00002029; + atomic_val_t aVar3; + int iVar4; + + pbVar1 = conns; + aVar3 = atomic_get(&conns[0].ref); + if ((((aVar3 == 0) || (conns[0].type != '\x01')) || + ((uint)conns[0].id != CONCAT31(in_register_00002029,id))) || + (iVar4 = bt_conn_addr_le_cmp(conns,peer), iVar4 != 0)) { + pbVar1 = conns + 1; + aVar3 = atomic_get(&conns[1].ref); + if (((aVar3 != 0) && (conns[1].type == '\x01')) && + ((uint)conns[1].id == CONCAT31(in_register_00002029,id))) { + pbVar2 = conns + 1; + iVar4 = bt_conn_addr_le_cmp(conns + 1,peer); + if (iVar4 == 0) goto LAB_2302747a; + } + pbVar2 = (bt_conn *)0x0; + } + else { + pbVar2 = conns; +LAB_2302747a: + atomic_inc(&pbVar1->ref); + } + return pbVar2; +} + + + +bt_conn * bt_conn_lookup_state_le(bt_addr_le_t *peer,bt_conn_state_t state) + +{ + atomic_val_t aVar1; + int iVar2; + undefined3 in_register_0000202d; + int iVar3; + + aVar1 = atomic_get(&conns[0].ref); + if ((((aVar1 == 0) || (conns[0].type != '\x01')) || + ((peer != (bt_addr_le_t *)0x0 && (iVar2 = bt_conn_addr_le_cmp(conns,peer), iVar2 != 0)))) || + ((uint)conns[0].state != CONCAT31(in_register_0000202d,state))) { + aVar1 = atomic_get(&conns[1].ref); + if (((aVar1 == 0) || (conns[1].type != '\x01')) || + (((peer != (bt_addr_le_t *)0x0 && (iVar2 = bt_conn_addr_le_cmp(conns + 1,peer), iVar2 != 0)) + || ((uint)conns[1].state != CONCAT31(in_register_0000202d,state))))) { + return (bt_conn *)0x0; + } + iVar2 = 0x360; + iVar3 = 0xa0; + } + else { + iVar2 = 0x2c0; + iVar3 = 0; + } + atomic_inc((atomic_t *)(gatt_write_buf + iVar2 + 0x174)); + return (bt_conn *)((int)&conns[0].handle + iVar3); +} + + + +void bt_conn_foreach(int type,anon_subr_void_bt_conn_ptr_void_ptr *func,void *data) + +{ + atomic_val_t aVar1; + + aVar1 = atomic_get(&conns[0].ref); + if ((aVar1 != 0) && (((uint)conns[0].type & type) != 0)) { + (*func)(conns,data); + } + aVar1 = atomic_get(&conns[1].ref); + if ((aVar1 != 0) && (((uint)conns[1].type & type) != 0)) { + // WARNING: Could not recover jumptable at 0x23027508. Too many branches + // WARNING: Treating indirect jump as call + (*func)((bt_conn *)0x42012318,data); + return; + } + return; +} + + + +void bt_conn_disconnect_all(u8_t id) + +{ + u8_t auStack17 [13]; + + auStack17[0] = id; + bt_conn_foreach(7,disconnect_all,auStack17); + return; +} + + + +void bt_conn_unref(bt_conn *conn) + +{ + atomic_dec(&conn->ref); + return; +} + + + +bt_addr_le_t * bt_conn_get_dst(bt_conn *conn) + +{ + return (bt_addr_le_t *)conn->field_20; +} + + + +int bt_conn_get_info(bt_conn *conn,bt_conn_info *info) + +{ + info->type = conn->type; + info->role = conn->role; + info->id = conn->id; + if (conn->type == '\x01') { + *(byte **)(info->field_3 + 4) = conn->field_20; + *(bt_addr_le_t **)info->field_3 = bt_dev.id_addr + conn->id; + if (conn->role == '\0') { + *(byte **)(info->field_3 + 8) = conn->field_20 + 7; + *(byte **)(info->field_3 + 0xc) = conn->field_20 + 0xe; + } + else { + *(byte **)(info->field_3 + 8) = conn->field_20 + 0xe; + *(byte **)(info->field_3 + 0xc) = conn->field_20 + 7; + } + *(undefined2 *)(info->field_3 + 0x10) = *(undefined2 *)(conn->field_20 + 0x16); + *(undefined2 *)(info->field_3 + 0x12) = *(undefined2 *)(conn->field_20 + 0x1c); + *(undefined2 *)(info->field_3 + 0x14) = *(undefined2 *)(conn->field_20 + 0x1e); + return 0; + } + return -0x16; +} + + + +int bt_conn_get_remote_dev_info(bt_conn_info *info) + +{ + int iVar1; + int iVar2; + atomic_val_t aVar3; + + iVar2 = atomic_get(&conns[0].ref); + if (iVar2 != 0) { + bt_conn_get_info(conns,info); + iVar2 = 1; + } + aVar3 = atomic_get(&conns[1].ref); + iVar1 = iVar2; + if (aVar3 != 0) { + iVar1 = iVar2 + 1; + bt_conn_get_info(conns + 1,info + iVar2); + } + return iVar1; +} + + + +int bt_conn_disconnect(bt_conn *conn,u8_t reason) + +{ + u16_t uVar1; + int iVar2; + net_buf *buf; + undefined *puVar3; + + switch((uint)conn->state - 1 & 0xff) { + case 0: + conn->err = reason; + bt_conn_set_state(conn,BT_CONN_DISCONNECTED); + bt_le_scan_update(false); + case 4: + iVar2 = 0; + break; + case 1: + conn->err = reason; + bt_conn_set_state(conn,BT_CONN_DISCONNECTED); + iVar2 = bt_le_adv_stop(); + return iVar2; + case 2: + k_delayed_work_cancel(&conn->update_work); + iVar2 = bt_hci_cmd_send(0x200e,(net_buf *)0x0); + return iVar2; + case 3: + buf = bt_hci_cmd_create(0x406,'\x03'); + iVar2 = -0x37; + if (buf != (net_buf *)0x0) { + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,3); + uVar1 = conn->handle; + puVar3[2] = reason; + *puVar3 = (char)uVar1; + puVar3[1] = (char)(uVar1 >> 8); + iVar2 = bt_hci_cmd_send(0x406,buf); + if (iVar2 == 0) { + bt_conn_set_state(conn,BT_CONN_DISCONNECT); + } + } + break; + default: + iVar2 = -0x39; + } + return iVar2; +} + + + +void disconnect_all(bt_conn *conn,void *data) + +{ + if ((conn->id == *(u8_t *)data) && (conn->state == BT_CONN_CONNECTED)) { + bt_conn_disconnect(conn,'\x13'); + return; + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: dst + +bt_conn * bt_conn_create_le(bt_addr_le_t *peer,bt_le_conn_param *param) + +{ + bt_conn_state_t bVar1; + _Bool _Var2; + int iVar3; + undefined3 extraout_var; + bt_conn *conn; + bt_addr_le_t *__src; + u8_t auStack24 [4]; + bt_addr_le_t dst; + + iVar3 = atomic_test_bit(bt_dev.flags,1); + if ((((iVar3 != 0) && (_Var2 = bt_le_conn_params_valid(param), CONCAT31(extraout_var,_Var2) != 0)) + && (iVar3 = atomic_test_bit(bt_dev.flags,0xb), iVar3 == 0)) && + (iVar3 = atomic_test_bit(bt_dev.flags,0xf), iVar3 == 0)) { + conn = bt_conn_lookup_addr_le('\0',peer); + if (conn == (bt_conn *)0x0) { + if ((byte)(peer->type - 2) < 2) { + memcpy(auStack24,peer,7); + auStack24[0] = auStack24[0] + -2; + } + else { + __src = bt_lookup_id_addr('\0',peer); + memcpy(auStack24,__src,7); + } + conn = bt_conn_add_le('\0',(bt_addr_le_t *)auStack24); + if (conn != (bt_conn *)0x0) goto start_scan; + } + else { + bVar1 = conn->state; + if (bVar1 == BT_CONN_CONNECT_SCAN) { + *(u16_t *)(conn->field_20 + 0x18) = param->interval_min; + *(u16_t *)(conn->field_20 + 0x1a) = param->interval_max; + *(u16_t *)(conn->field_20 + 0x1c) = param->latency; + *(u16_t *)(conn->field_20 + 0x1e) = param->timeout; + return conn; + } + if (bVar1 == BT_CONN_DISCONNECTED) { + printf("Found valid but disconnected conn object\r\n"); +start_scan: + *(u16_t *)(conn->field_20 + 0x18) = param->interval_min; + *(u16_t *)(conn->field_20 + 0x1a) = param->interval_max; + *(u16_t *)(conn->field_20 + 0x1c) = param->latency; + *(u16_t *)(conn->field_20 + 0x1e) = param->timeout; + bt_conn_set_state(conn,BT_CONN_CONNECT_SCAN); + bt_le_scan_update(true); + return conn; + } + if ((byte)(bVar1 + ~BT_CONN_CONNECT_DIR_ADV) < 2) { + return conn; + } + atomic_dec(&conn->ref); + } + } + return (bt_conn *)0x0; +} + + + +int bt_conn_le_conn_update(bt_conn *conn,bt_le_conn_param *param) + +{ + u16_t uVar1; + net_buf *buf; + undefined *__s; + int iVar2; + + buf = bt_hci_cmd_create(0x2013,'\x0e'); + if (buf != (net_buf *)0x0) { + __s = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,0xe); + memset(__s,0,0xe); + uVar1 = conn->handle; + *__s = (char)uVar1; + __s[1] = (char)(uVar1 >> 8); + uVar1 = param->interval_min; + __s[2] = (char)uVar1; + __s[3] = (char)(uVar1 >> 8); + uVar1 = param->interval_max; + __s[4] = (char)uVar1; + __s[5] = (char)(uVar1 >> 8); + uVar1 = param->latency; + __s[6] = (char)uVar1; + __s[7] = (char)(uVar1 >> 8); + uVar1 = param->timeout; + __s[8] = (char)uVar1; + __s[9] = (char)(uVar1 >> 8); + iVar2 = bt_hci_cmd_send_sync(0x2013,buf,(net_buf **)0x0); + return iVar2; + } + return -0x37; +} + + + +int send_conn_le_param_update(bt_conn *conn,bt_le_conn_param *param) + +{ + int iVar1; + + if (((((bt_dev.le.features[0] & 2) == 0) || ((conn->field_20[0x24] & 2) == 0)) || + (iVar1 = atomic_test_bit(conn->flags,10), iVar1 != 0)) && (conn->role != '\0')) { + iVar1 = bt_l2cap_update_conn_param(conn,param); + return iVar1; + } + iVar1 = bt_conn_le_conn_update(conn,param); + if (iVar1 == 0) { + *(u16_t *)(conn->field_20 + 0x20) = param->latency; + *(u16_t *)(conn->field_20 + 0x22) = param->timeout; + } + return iVar1; +} + + + +void conn_update_timeout(k_work *work) + +{ + bt_conn *conn; + uint uVar1; + bt_le_conn_param *param; + bt_conn_cb *pbVar2; + void *local_20; + atomic_t aStack28; + undefined4 uStack24; + undefined4 uStack20; + + param = (bt_le_conn_param *)&local_20; + conn = (bt_conn *)work[-7].flags; + if (*(char *)((int)work[-6].flags + 1) == '\0') { + bt_l2cap_disconnected(conn); + pbVar2 = callback_list; + while (pbVar2 != (bt_conn_cb *)0x0) { + if (pbVar2->disconnected != (anon_subr_void_bt_conn_ptr_u8_t_for_disconnected *)0x0) { + (*pbVar2->disconnected)(conn,*(u8_t *)work[-6].flags); + } + pbVar2 = pbVar2->_next; + } + atomic_dec(work[-1].flags); + } + else { + if (*(char *)((int)work[-7].flags + 2) == '\x01') { + if (*(char *)((int)work[-7].flags + 3) == '\0') { + bt_hci_cmd_send(0x200e,(net_buf *)0x0); + } + else { + uVar1 = atomic_and((atomic_t *)(work + -6),-0x201); + if ((uVar1 & 0x200) == 0) { + uStack24 = DAT_4200dd08; + uStack20 = DAT_4200dd0c; + param = (bt_le_conn_param *)&uStack24; + } + else { + local_20 = work[5]._reserved; + aStack28 = work[5].flags[0]; + } + send_conn_le_param_update(conn,param); + atomic_or((atomic_t *)(work + -6),0x100); + } + } + } + return; +} + + + +int bt_conn_le_param_update(bt_conn *conn,bt_le_conn_param *param) + +{ + int iVar1; + + if ((((param->interval_min <= *(ushort *)(conn->field_20 + 0x16)) && + (*(ushort *)(conn->field_20 + 0x16) <= param->interval_max)) && + (*(u16_t *)(conn->field_20 + 0x1c) == param->latency)) && + (*(u16_t *)(conn->field_20 + 0x1e) == param->timeout)) { + atomic_and(conn->flags,-0x201); + return -0x45; + } + if (conn->role != '\0') { + iVar1 = atomic_test_bit(conn->flags,8); + if (iVar1 == 0) { + *(u16_t *)(conn->field_20 + 0x18) = param->interval_min; + *(u16_t *)(conn->field_20 + 0x1a) = param->interval_max; + *(u16_t *)(conn->field_20 + 0x20) = param->latency; + *(u16_t *)(conn->field_20 + 0x22) = param->timeout; + atomic_or(conn->flags,0x200); + return 0; + } + } + iVar1 = send_conn_le_param_update(conn,param); + return iVar1; +} + + + +net_buf * bt_conn_create_pdu_timeout(net_buf_pool *pool,size_t reserve,s32_t timeout) + +{ + net_buf *pnVar1; + + if (pool == (net_buf_pool *)0x0) { + pool = &acl_tx_pool; + } + pnVar1 = net_buf_alloc_fixed(pool,timeout); + if (pnVar1 == (net_buf *)0x0) { + printf("Unable to allocate buffer: timeout %d\r\n",timeout); + } + else { + net_buf_simple_reserve((net_buf_simple *)&pnVar1->field_4,reserve + 5); + } + return pnVar1; +} + + + +net_buf * create_frag(net_buf *buf) + +{ + net_buf *buf_00; + size_t len; + int in_a1; + net_buf_simple *buf_01; + uint uVar1; + + buf_00 = bt_conn_create_pdu_timeout((net_buf_pool *)0x0,0,-1); + if (*(char *)&buf->field_0 == '\x04') { + *(undefined4 *)buf_00->user_data = 0; + uVar1 = (uint)bt_dev.le.mtu; + buf_01 = (net_buf_simple *)&buf_00->field_4; + len = net_buf_simple_tailroom(buf_01); + if (uVar1 < len) { + len = (size_t)bt_dev.le.mtu; + } + else { + len = net_buf_simple_tailroom(buf_01); + len = len & 0xffff; + } + net_buf_simple_add_mem(buf_01,*(void **)(in_a1 + 8),len); + net_buf_simple_pull((net_buf_simple *)(in_a1 + 8),len); + } + else { + net_buf_unref(buf_00); + buf_00 = (net_buf *)0x0; + } + return buf_00; +} + + + +void bt_conn_process_tx(bt_conn *param_1) + +{ + uint uVar1; + net_buf *buf; + int iVar2; + net_buf *pnVar3; + undefined4 uVar4; + + if ((param_1->state == BT_CONN_DISCONNECTED) && + (uVar1 = atomic_and(param_1->flags,-0x41), (uVar1 & 0x40) != 0)) { + conn_cleanup(param_1); + return; + } + buf = net_buf_get(¶m_1->tx_queue,0); + if (buf == (net_buf *)0x0) { + vAssertCalled(); + } + if (bt_dev.le.mtu < *(ushort *)((int)&buf->field_4 + 4)) { + pnVar3 = create_frag((net_buf *)¶m_1->state); + if (pnVar3 != (net_buf *)0x0) { + uVar4 = 0; + while (iVar2 = send_frag(param_1,uVar4,1), iVar2 != 0) { + if (*(ushort *)((int)&buf->field_4 + 4) <= bt_dev.le.mtu) { + uVar4 = 1; + goto LAB_23027bca; + } + pnVar3 = create_frag((net_buf *)¶m_1->state); + if (pnVar3 == (net_buf *)0x0) break; + uVar4 = 1; + } + } + } + else { + uVar4 = 0; +LAB_23027bca: + iVar2 = send_frag(param_1,buf,uVar4,0); + if (iVar2 != 0) { + return; + } + } + net_buf_unref(buf); + return; +} + + + +int bt_conn_auth_cb_register(bt_conn_auth_cb *cb) + +{ + bt_conn_auth_cb *pbVar1; + + if (cb == (bt_conn_auth_cb *)0x0) { + bt_auth = (bt_conn_auth_cb *)0x0; + pbVar1 = bt_auth; + } + else { + if (bt_auth != (bt_conn_auth_cb *)0x0) { + return -0x45; + } + pbVar1 = cb; + if (cb->cancel == (anon_subr_void_bt_conn_ptr_for_cancel *)0x0) { + if (cb->passkey_display != (anon_subr_void_bt_conn_ptr_uint_for_passkey_display *)0x0) { + return -0x16; + } + if (cb->passkey_entry != (anon_subr_void_bt_conn_ptr_for_passkey_entry *)0x0) { + return -0x16; + } + if (cb->passkey_confirm != (anon_subr_void_bt_conn_ptr_uint_for_passkey_confirm *)0x0) { + return -0x16; + } + pbVar1 = cb; + if (cb->pairing_confirm != (anon_subr_void_bt_conn_ptr_for_pairing_confirm *)0x0) { + return -0x16; + } + } + } + bt_auth = pbVar1; + return 0; +} + + + +int bt_conn_auth_passkey_entry(bt_conn *conn,uint passkey) + +{ + if ((bt_auth != (bt_conn_auth_cb *)0x0) && (conn->type == '\x01')) { + bt_smp_auth_passkey_entry(conn,passkey); + return 0; + } + return -0x16; +} + + + +int bt_conn_auth_passkey_confirm(bt_conn *conn) + +{ + int iVar1; + + if ((bt_auth != (bt_conn_auth_cb *)0x0) && (conn->type == '\x01')) { + iVar1 = bt_smp_auth_passkey_confirm(conn); + return iVar1; + } + return -0x16; +} + + + +int bt_conn_auth_cancel(bt_conn *conn) + +{ + int iVar1; + + if ((bt_auth != (bt_conn_auth_cb *)0x0) && (conn->type == '\x01')) { + iVar1 = bt_smp_auth_cancel(conn); + return iVar1; + } + return -0x16; +} + + + +int bt_conn_auth_pairing_confirm(bt_conn *conn) + +{ + int iVar1; + + if ((bt_auth != (bt_conn_auth_cb *)0x0) && (conn->type == '\x01')) { + iVar1 = bt_smp_auth_pairing_confirm(conn); + return iVar1; + } + return -0x16; +} + + + +u8_t bt_conn_index(bt_conn *conn) + +{ + return (u8_t)((char)((int)&conn[-0x699b6b].update_work.timer.timeout >> 5) * -0x33); +} + + + +int bt_conn_init(void) + +{ + bt_conn *data; + bt_conn *pbVar1; + int iVar2; + atomic_val_t aVar3; + int iVar4; + + if (queue_inited == false) { + k_queue_init((k_queue *)&acl_tx_pool,2); + } + k_queue_init((k_queue *)&free_tx,0x14); + data = (bt_conn *)conn_tx; + do { + pbVar1 = (bt_conn *)&data->rx; + k_queue_append((k_queue *)&free_tx,data); + data = pbVar1; + } while (pbVar1 != conns); + bt_att_init(); + iVar2 = bt_smp_init(); + if (iVar2 == 0) { + bt_l2cap_init(); + aVar3 = atomic_get(&conns[0].ref); + if ((aVar3 != 0) && (iVar4 = atomic_test_bit(conns[0].flags,0), iVar4 != 0)) { + conns[0].id = '\0'; + bt_conn_set_state(conns,BT_CONN_CONNECT_SCAN); + } + aVar3 = atomic_get(&conns[1].ref); + if ((aVar3 != 0) && (iVar4 = atomic_test_bit(conns[1].flags,0), iVar4 != 0)) { + conns[1].id = '\0'; + bt_conn_set_state(conns + 1,BT_CONN_CONNECT_SCAN); + } + } + return iVar2; +} + + + +int bt_rand(void *buf,size_t len) + +{ + k_get_random_byte_array((uint8_t *)buf,len); + return 0; +} + + + +// WARNING: Variable defined which should be unmapped: s + +int bt_encrypt_le(u8_t *key,u8_t *plaintext,u8_t *enc_data) + +{ + u8_t uVar1; + int iVar2; + u8_t *puVar3; + u8_t *puVar4; + u8_t *puVar5; + u8_t auStack208 [4]; + u8_t tmp [16]; + tc_aes_key_sched_struct s; + + puVar3 = auStack208; + puVar4 = key + 0xf; + do { + puVar5 = puVar4 + -1; + *puVar3 = *puVar4; + puVar3 = puVar3 + 1; + puVar4 = puVar5; + } while (key + -1 != puVar5); + iVar2 = tc_aes128_set_encrypt_key((TCAesKeySched_t)(tmp + 0xc),auStack208); + if (iVar2 != 0) { + puVar3 = auStack208; + puVar4 = plaintext + 0xf; + do { + puVar5 = puVar4 + -1; + *puVar3 = *puVar4; + puVar3 = puVar3 + 1; + puVar4 = puVar5; + } while (puVar5 != plaintext + -1); + iVar2 = tc_aes_encrypt(enc_data,auStack208,(TCAesKeySched_t)(tmp + 0xc)); + if (iVar2 != 0) { + puVar4 = enc_data + 7; + puVar3 = enc_data + 0xf; + do { + uVar1 = *enc_data; + puVar5 = puVar3 + -1; + *enc_data = *puVar3; + *puVar3 = uVar1; + enc_data = enc_data + 1; + puVar3 = puVar5; + } while (puVar4 != puVar5); + return 0; + } + } + return -0x16; +} + + + +void sys_slist_remove(sys_slist_t *list,sys_snode_t *prev_node,sys_snode_t *node) + +{ + sys_snode_t *psVar1; + + psVar1 = (sys_snode_t *)node->next; + if (prev_node == (sys_snode_t *)0x0) { + list->head = psVar1; + if (list->tail == node) { + list->tail = psVar1; + } + } + else { + *(sys_snode_t **)&prev_node->next = psVar1; + if (list->tail == node) { + list->tail = prev_node; + } + } + node->next = (_snode *)0x0; + return; +} + + + +u8_t found_attr(bt_gatt_attr *attr,void *user_data) + +{ + *(bt_gatt_attr **)user_data = attr; + return '\0'; +} + + + +u16_t find_static_attr(bt_gatt_attr *attr) + +{ + anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *paVar1; + bt_gatt_service_static *pbVar2; + uint uVar3; + + pbVar2 = &_1_gatt_svc; + uVar3 = 1; + do { + if (&att_fixed_chan <= pbVar2) { + return 0; + } + paVar1 = (anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *)0x0; + while( true ) { + if (paVar1 == ((bt_l2cap_fixed_chan *)pbVar2)->accept) break; + if (attr == (bt_gatt_attr *)((int)paVar1 * 0x14 + *(int *)pbVar2)) { + return (u16_t)((uint)(paVar1 + uVar3) & 0xffff); + } + paVar1 = paVar1 + 1; + } + pbVar2 = (bt_gatt_service_static *)&((bt_l2cap_fixed_chan *)pbVar2)->node; + uVar3 = (uint)(paVar1 + uVar3) & 0xffff; + } while( true ); +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void gatt_ccc_changed(bt_gatt_attr *attr,_bt_gatt_ccc_conflict2 *ccc) + +{ + ushort uVar1; + ushort uVar2; + + uVar1 = ccc->cfg[1].value; + uVar2 = ccc->cfg[0].value; + if (uVar2 < uVar1) { + uVar2 = uVar1; + } + if (ccc->value != uVar2) { + ccc->value = uVar2; + if (ccc->cfg_changed != (anon_subr_void_bt_gatt_attr_ptr_u16_t_for_cfg_changed *)0x0) { + // WARNING: Could not recover jumptable at 0x23027efa. Too many branches + // WARNING: Treating indirect jump as call + (*ccc->cfg_changed)(); + return; + } + } + return; +} + + + +void gatt_indicate_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + undefined3 in_register_0000202d; + + // WARNING: Could not recover jumptable at 0x23027f06. Too many branches + // WARNING: Treating indirect jump as call + (**(code **)((int)user_data + 0x20)) + (*(undefined4 *)((int)user_data + 0x1c),CONCAT31(in_register_0000202d,err)); + return; +} + + + +void sc_restore_rsp(bt_conn *conn,bt_gatt_attr *attr,u8_t err) + +{ + return; +} + + + +void gatt_subscription_remove(bt_conn *conn,sys_snode_t *prev,bt_gatt_subscribe_params *params) + +{ + sys_slist_remove(&subscriptions,prev,¶ms->node); + // WARNING: Could not recover jumptable at 0x23027f3a. Too many branches + // WARNING: Treating indirect jump as call + (*params->notify)(conn,params,(void *)0x0,0); + return; +} + + + +void gatt_mtu_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + // WARNING: Could not recover jumptable at 0x23027f42. Too many branches + // WARNING: Treating indirect jump as call + (**(code **)((int)user_data + 0x18))(user_data); + return; +} + + + +void gatt_write_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + // WARNING: Could not recover jumptable at 0x23027f4a. Too many branches + // WARNING: Treating indirect jump as call + (**(code **)((int)user_data + 0x18))(user_data); + return; +} + + + +bt_gatt_ccc_cfg * find_ccc_cfg(bt_conn *conn,_bt_gatt_ccc_conflict2 *ccc) + +{ + int iVar1; + undefined4 uStack24; + undefined2 uStack20; + undefined uStack18; + + if (conn == (bt_conn *)0x0) { + uStack24 = 0; + uStack20 = 0; + uStack18 = 0; + iVar1 = memcmp(&ccc->cfg[0].peer,&uStack24,7); + if (iVar1 == 0) { +LAB_23027f70: + iVar1 = 0; + goto LAB_23027f72; + } + uStack24 = 0; + uStack20 = 0; + uStack18 = 0; + iVar1 = memcmp(&ccc->cfg[1].peer,&uStack24,7); + } + else { + if ((conn->id == ccc->cfg[0].id) && + (iVar1 = bt_conn_addr_le_cmp(conn,&ccc->cfg[0].peer), iVar1 == 0)) goto LAB_23027f70; + if (conn->id != ccc->cfg[1].id) { + return (bt_gatt_ccc_cfg *)0x0; + } + iVar1 = bt_conn_addr_le_cmp(conn,&ccc->cfg[1].peer); + } + if (iVar1 != 0) { + return (bt_gatt_ccc_cfg *)0x0; + } + iVar1 = 10; +LAB_23027f72: + return (bt_gatt_ccc_cfg *)(&ccc->cfg[0].id + iVar1); +} + + + +int gatt_notify(bt_conn *conn,u16_t handle,bt_gatt_notify_params_conflict1 *params) + +{ + net_buf *buf; + undefined *puVar1; + int iVar2; + + buf = bt_att_create_pdu(conn,'\x1b',(uint)params->len + 2); + if (buf != (net_buf *)0x0) { + puVar1 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + *puVar1 = (char)handle; + puVar1[1] = (char)(handle >> 8); + net_buf_simple_add((net_buf_simple *)&buf->field_4,(uint)params->len); + memcpy(puVar1 + 2,params->data,(uint)params->len); + iVar2 = bt_att_send(conn,buf,(bt_conn_tx_cb_t *)params->func,params->user_data); + return iVar2; + } + printf("No buffer available to send notification\r\n"); + return -0xc; +} + + + +void gatt_read_multiple_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + code *UNRECOVERED_JUMPTABLE; + undefined3 in_register_0000202d; + int iVar1; + undefined2 in_register_00002036; + + iVar1 = CONCAT31(in_register_0000202d,err); + UNRECOVERED_JUMPTABLE = *(code **)((int)user_data + 0x18); + if ((iVar1 == 0) && (CONCAT22(in_register_00002036,length) != 0)) { + (*UNRECOVERED_JUMPTABLE)(user_data,pdu,CONCAT22(in_register_00002036,length),0); + UNRECOVERED_JUMPTABLE = *(code **)((int)user_data + 0x18); + iVar1 = 0; + } + // WARNING: Could not recover jumptable at 0x23028086. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(conn,iVar1,user_data,0,0); + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void gatt_write_ccc_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + sys_snode_t sVar1; + undefined3 in_register_0000202d; + sys_snode_t prev; + sys_snode_t sVar2; + + atomic_and((atomic_t *)((int)user_data + 0x2c),-3); + if (CONCAT31(in_register_0000202d,err) == 0) { + // WARNING: Could not recover jumptable at 0x230280fa. Too many branches + // WARNING: Treating indirect jump as call + (**(code **)((int)user_data + 0x20))(conn,user_data,0,0); + return; + } + if (subscriptions.head != (sys_snode_t *)0x0) { + sVar1 = (sys_snode_t)(subscriptions.head)->next; + sVar2 = (sys_snode_t)subscriptions.head; + while( true ) { + prev = sVar1; + if (sVar2 == (sys_snode_t)((int)user_data + 0x30)) { + gatt_subscription_remove(conn,(sys_snode_t *)prev,(bt_gatt_subscribe_params *)user_data); + return; + } + if (prev == (sys_snode_t)0x0) break; + sVar1 = *(sys_snode_t *)prev; + sVar2 = prev; + } + } + return; +} + + + +int gatt_send(bt_conn *conn,net_buf *buf,bt_att_func_t *func,void *params) + +{ + int iVar1; + + if (params == (void *)0x0) { + iVar1 = bt_att_send(conn,buf,(bt_conn_tx_cb_t *)0x0,(void *)0x0); + } + else { + *(net_buf **)((int)params + 0x10) = buf; + *(bt_att_func_t **)((int)params + 4) = func; + *(undefined4 *)((int)params + 8) = 0; + iVar1 = bt_att_req_send(conn,(bt_att_req_conflict26 *)params); + } + if (iVar1 != 0) { + printf("Error sending ATT PDU: %d\r\n",iVar1); + } + return iVar1; +} + + + +int gatt_indicate(bt_conn *conn,u16_t handle,bt_gatt_indicate_params_conflict2 *params) + +{ + net_buf *buf; + undefined *puVar1; + int iVar2; + code *func; + + buf = bt_att_create_pdu(conn,'\x1d',(uint)params->len + 2); + if (buf != (net_buf *)0x0) { + puVar1 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + *puVar1 = (char)handle; + puVar1[1] = (char)(handle >> 8); + net_buf_simple_add((net_buf_simple *)&buf->field_4,(uint)params->len); + memcpy(puVar1 + 2,params->data,(uint)params->len); + if (params->func == (bt_gatt_indicate_func_t *)0x0) { + params = (bt_gatt_indicate_params_conflict2 *)0x0; + func = (bt_att_func_t *)0x0; + } + else { + func = gatt_indicate_rsp; + } + iVar2 = gatt_send(conn,buf,func,params); + return iVar2; + } + printf("No buffer available to send indication\r\n"); + return -0xc; +} + + + +undefined4 match_uuid(undefined4 param_1,undefined4 *param_2) + +{ + *param_2 = param_1; + return 0; +} + + + +void sc_indicate_rsp(bt_conn *conn,bt_gatt_attr *attr,u8_t err) + +{ + uint uVar1; + + atomic_and(gatt_sc.flags,-3); + uVar1 = atomic_get(gatt_sc.flags); + if ((uVar1 & 1) != 0) { + k_delayed_work_submit((k_delayed_work *)&gatt_sc.work,0); + return; + } + return; +} + + + +u8_t disconnected_cb(bt_gatt_attr *attr,void *user_data) + +{ + bool bVar1; + bt_addr_le_t *peer; + _Bool _Var2; + bt_conn *conn; + int iVar3; + undefined3 extraout_var; + void *pvVar4; + undefined4 uStack56; + undefined2 uStack52; + undefined uStack50; + + if (attr->write == bt_gatt_attr_write_ccc) { + pvVar4 = attr->user_data; + if (*(short *)((int)pvVar4 + 0x14) != 0) { + peer = (bt_addr_le_t *)((int)pvVar4 + 1); + bVar1 = false; + do { + if (*(short *)(peer + 1) != 0) { + if ((*(u8_t *)((int)user_data + 8) == peer[-1].a.val[5]) && + (iVar3 = bt_conn_addr_le_cmp((bt_conn *)user_data,peer), iVar3 == 0)) { + _Var2 = bt_addr_le_is_bonded + (*(u8_t *)((int)user_data + 8),(bt_addr_le_t *)((int)user_data + 0x70) + ); + if (CONCAT31(extraout_var,_Var2) == 0) { + uStack56 = 0; + uStack52 = 0; + uStack50 = 0; + memcpy(peer,&uStack56,7); + peer[-1].a.val[5] = '\0'; + *(undefined2 *)(peer + 1) = 0; + } + else { + memcpy(peer,(bt_addr_le_t *)((int)user_data + 0x70),7); + } + } + else { + conn = bt_conn_lookup_addr_le(peer[-1].a.val[5],peer); + if (conn != (bt_conn *)0x0) { + if (conn->state == BT_CONN_CONNECTED) { + bVar1 = true; + } + bt_conn_unref(conn); + } + } + } + peer = (bt_addr_le_t *)(peer[1].a.val + 2); + } while (peer != (bt_addr_le_t *)((int)pvVar4 + 0x15)); + if (!bVar1) { + *(undefined2 *)((int)pvVar4 + 0x14) = 0; + if (*(code **)((int)pvVar4 + 0x18) != (code *)0x0) { + (**(code **)((int)pvVar4 + 0x18))(attr,0); + } + } + } + return '\x01'; + } + return '\x01'; +} + + + +gatt_sc_cfg * find_sc_cfg(u8_t id,bt_addr_le_t *addr) + +{ + int iVar1; + undefined3 in_register_00002029; + int iVar2; + gatt_sc_cfg *pgVar3; + + pgVar3 = sc_cfg; + iVar1 = 0; + do { + if ((uint)pgVar3->id == CONCAT31(in_register_00002029,id)) { + iVar2 = memcmp(&pgVar3->peer,addr,7); + if (iVar2 == 0) { + return sc_cfg + iVar1; + } + } + iVar1 = iVar1 + 1; + pgVar3 = pgVar3 + 1; + } while (iVar1 != 4); + return (gatt_sc_cfg *)0x0; +} + + + +int gatt_write_ccc(bt_conn *conn,u16_t handle,u16_t value,bt_gatt_subscribe_params *params) + +{ + net_buf *buf; + undefined *puVar1; + int iVar2; + + buf = bt_att_create_pdu(conn,'\x12',4); + if (buf != (net_buf *)0x0) { + puVar1 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + *puVar1 = (char)handle; + puVar1[1] = (char)(handle >> 8); + net_buf_simple_add_le16((net_buf_simple *)&buf->field_4,value); + atomic_or(params->flags,2); + iVar2 = gatt_send(conn,buf,gatt_write_ccc_rsp,params); + return iVar2; + } + return -0xc; +} + + + +ssize_t read_appearance(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset) + +{ + size_t __n; + undefined2 in_register_00002036; + undefined2 in_register_0000203a; + uint uVar1; + undefined2 auStack18 [2]; + u16_t appearance; + + uVar1 = CONCAT22(in_register_0000203a,offset); + auStack18[0] = 0x341; + __n = 0xfffffff9; + if (uVar1 < 3) { + __n = 2 - uVar1; + if ((int)CONCAT22(in_register_00002036,len) < (int)(2 - uVar1)) { + __n = CONCAT22(in_register_00002036,len); + } + memcpy(buf,(void *)((int)auStack18 + uVar1),__n); + } + return __n; +} + + + +// WARNING: Could not reconcile some variable overlaps + +ssize_t read_ppcp(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset) + +{ + size_t __n; + undefined2 in_register_00002036; + undefined2 in_register_0000203a; + uint uVar1; + undefined4 uStack24; + anon_struct_for_ppcp ppcp; + + uVar1 = CONCAT22(in_register_0000203a,offset); + uStack24 = 0x280018; + ppcp._0_4_ = 0x1900000; + __n = 0xfffffff9; + if (uVar1 < 9) { + __n = 8 - uVar1; + if ((int)CONCAT22(in_register_00002036,len) < (int)(8 - uVar1)) { + __n = CONCAT22(in_register_00002036,len); + } + memcpy(buf,(void *)((int)&uStack24 + uVar1),__n); + } + return __n; +} + + + +ssize_t read_name(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset) + +{ + uint __n; + char *__s; + size_t sVar1; + undefined2 in_register_00002036; + undefined2 in_register_0000203a; + uint uVar2; + + uVar2 = CONCAT22(in_register_0000203a,offset); + __s = bt_get_name(); + sVar1 = strlen(__s); + __n = 0xfffffff9; + if (uVar2 <= (sVar1 & 0xffff)) { + __n = (sVar1 & 0xffff) - uVar2; + if ((int)CONCAT22(in_register_00002036,len) < (int)__n) { + __n = CONCAT22(in_register_00002036,len); + } + __n = __n & 0xffff; + memcpy(buf,__s + uVar2,__n); + } + return __n; +} + + + +ssize_t bt_gatt_attr_read_ccc(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset) + +{ + size_t __n; + bt_gatt_ccc_cfg *pbVar1; + undefined2 in_register_00002036; + undefined2 in_register_0000203a; + uint uVar2; + u16_t auStack18 [2]; + u16_t value; + + uVar2 = CONCAT22(in_register_0000203a,offset); + pbVar1 = find_ccc_cfg(conn,(_bt_gatt_ccc_conflict2 *)attr->user_data); + auStack18[0] = 0; + if (pbVar1 != (bt_gatt_ccc_cfg *)0x0) { + auStack18[0] = pbVar1->value; + } + __n = 0xfffffff9; + if (uVar2 < 3) { + __n = 2 - uVar2; + if ((int)CONCAT22(in_register_00002036,len) < (int)(2 - uVar2)) { + __n = CONCAT22(in_register_00002036,len); + } + memcpy(buf,(void *)((int)auStack18 + uVar2),__n); + } + return __n; +} + + + +ssize_t bt_gatt_attr_read_service(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset) + +{ + size_t __n; + char *pcVar1; + undefined2 in_register_00002036; + size_t sVar2; + undefined2 in_register_0000203a; + uint uVar3; + undefined2 *puVar4; + undefined2 auStack18 [2]; + u16_t uuid16; + + uVar3 = CONCAT22(in_register_0000203a,offset); + sVar2 = CONCAT22(in_register_00002036,len); + pcVar1 = (char *)attr->user_data; + if (*pcVar1 == '\0') { + auStack18[0] = *(undefined2 *)(pcVar1 + 2); + if (2 < uVar3) { + return -7; + } + __n = 2 - uVar3; + if ((int)sVar2 < (int)(2 - uVar3)) { + __n = sVar2; + } + puVar4 = auStack18; + } + else { + puVar4 = (undefined2 *)(pcVar1 + 1); + if (0x10 < uVar3) { + return -7; + } + __n = 0x10 - uVar3; + if ((int)sVar2 < (int)(0x10 - uVar3)) { + __n = sVar2; + } + } + memcpy(buf,(void *)((int)puVar4 + uVar3),__n); + return __n; +} + + + +void sc_save(u8_t id,bt_addr_le_t *peer,u16_t start,u16_t end) + +{ + ushort uVar1; + ushort uVar2; + gatt_sc_cfg *pgVar3; + undefined2 in_register_00002032; + undefined2 in_register_00002036; + undefined4 uStack40; + undefined2 uStack36; + u8_t uStack34; + + pgVar3 = find_sc_cfg(id,peer); + if (pgVar3 == (gatt_sc_cfg *)0x0) { + uStack40 = 0; + uStack36 = 0; + uStack34 = '\0'; + pgVar3 = find_sc_cfg('\0',(bt_addr_le_t *)&uStack40); + if (pgVar3 == (gatt_sc_cfg *)0x0) { + printf("unable to save SC: no cfg left\r\n"); + return; + } + pgVar3->id = id; + memcpy(&pgVar3->peer,peer,7); + } + uVar1 = (pgVar3->data).start; + uVar2 = (pgVar3->data).end; + if (uVar1 == 0) { + if (uVar2 == 0) { + (pgVar3->data).start = start; + goto LAB_230285e6; + } + } + else { + if (CONCAT22(in_register_00002032,start) < (uint)uVar1) { + (pgVar3->data).start = start; + } + } + if (CONCAT22(in_register_00002036,end) <= (uint)uVar2) { + return; + } +LAB_230285e6: + (pgVar3->data).end = end; + return; +} + + + +_Bool sc_ccc_cfg_write(bt_conn *conn,bt_gatt_attr *attr,u16_t value) + +{ + gatt_sc_cfg *__s; + undefined2 in_register_00002032; + + if (CONCAT22(in_register_00002032,value) == 2) { + sc_save(conn->id,(bt_addr_le_t *)conn->field_20,0,0); + } + else { + __s = find_sc_cfg(conn->id,(bt_addr_le_t *)conn->field_20); + if (__s != (gatt_sc_cfg *)0x0) { + memset(__s,0,0xc); + } + } + return true; +} + + + +u8_t notify_cb(bt_gatt_attr *attr,void *user_data) + +{ + bt_addr_le_t *peer; + gatt_sc_cfg *pgVar1; + _Bool _Var2; + bt_conn *conn; + undefined3 extraout_var; + int iVar3; + u16_t handle; + u16_t *puVar4; + _bt_gatt_ccc_conflict2 *p_Var5; + undefined4 uStack56; + undefined2 uStack52; + undefined uStack50; + + if (attr->write != bt_gatt_attr_write_ccc) { + return '\x01'; + } + p_Var5 = (_bt_gatt_ccc_conflict2 *)attr->user_data; + if (p_Var5 == &sc_ccc) { + pgVar1 = sc_cfg; + do { + peer = (bt_addr_le_t *) + ((int)&(((bt_gatt_indicate_params_conflict3 *)pgVar1)->_req).node.next + 1); + uStack56 = 0; + uStack52 = 0; + uStack50 = 0; + iVar3 = memcmp(peer,&uStack56,7); + if (iVar3 != 0) { + conn = bt_conn_lookup_state_le(peer,BT_CONN_CONNECTED); + if (conn == (bt_conn *)0x0) { + puVar4 = *(u16_t **)(*(int *)((int)user_data + 8) + 0x24); + sc_save(*(u8_t *)&(((bt_gatt_indicate_params_conflict3 *)pgVar1)->_req).node.next,peer, + *puVar4,puVar4[1]); + } + else { + bt_conn_unref(conn); + } + } + pgVar1 = (gatt_sc_cfg *)&(((bt_gatt_indicate_params_conflict3 *)pgVar1)->_req).state; + } while ((bt_gatt_indicate_params_conflict3 *)pgVar1 != sc_restore_params); + } + peer = &p_Var5->cfg[0].peer; + do { + if ((*(short *)(peer + 1) == *(short *)((int)user_data + 4)) && + (conn = bt_conn_lookup_addr_le(peer[-1].a.val[5],peer), conn != (bt_conn *)0x0)) { + if ((conn->state == BT_CONN_CONNECTED) && + ((p_Var5->cfg_match == (anon_subr__Bool_bt_conn_ptr_bt_gatt_attr_ptr_for_cfg_match *)0x0 || + (_Var2 = (*p_Var5->cfg_match)(conn,attr), CONCAT31(extraout_var,_Var2) != 0)))) { + handle = attr->handle - 1; + if (*(short *)((int)user_data + 4) == 2) { + iVar3 = gatt_indicate(conn,handle, + *(bt_gatt_indicate_params_conflict2 **)((int)user_data + 8)); + } + else { + iVar3 = gatt_notify(conn,handle, + (bt_gatt_notify_params_conflict1 *) + *(bt_gatt_indicate_params_conflict2 **)((int)user_data + 8)); + } + bt_conn_unref(conn); + if (iVar3 < 0) { + return '\0'; + } + *(undefined4 *)user_data = 0; + } + else { + bt_conn_unref(conn); + } + } + peer = (bt_addr_le_t *)(peer[1].a.val + 2); + if ((bt_addr_le_t *)((int)&p_Var5->value + 1) == peer) { + return '\x01'; + } + } while( true ); +} + + + +void sc_indicate(u16_t start,u16_t end) + +{ + u16_t uVar1; + undefined2 in_register_0000202a; + bt_conn *conn; + uint uVar2; + atomic_val_t aVar3; + undefined2 in_register_0000202e; + + conn = bt_conn_lookup_state_le((bt_addr_le_t *)0x0,BT_CONN_CONNECTED); + if ((conn == (bt_conn *)0x0) || + (uVar2 = atomic_or(gatt_sc.flags,1), uVar1 = start, (uVar2 & 1) != 0)) { + if (CONCAT22(in_register_0000202a,start) < (uint)gatt_sc.start) { + gatt_sc.start = start; + uVar1 = start; + if (CONCAT22(in_register_0000202e,end) <= (uint)gatt_sc.end) goto submit; + } + else { + uVar1 = gatt_sc.start; + if (CONCAT22(in_register_0000202e,end) <= (uint)gatt_sc.end) { + return; + } + } + } + gatt_sc.start = uVar1; + gatt_sc.end = end; +submit: + aVar3 = atomic_get(gatt_sc.flags); + if (((aVar3 >> 1 & 1U) == 0) && (conn != (bt_conn *)0x0)) { + k_delayed_work_submit((k_delayed_work *)&gatt_sc.work,10); + bt_conn_unref(conn); + return; + } + return; +} + + + +ssize_t bt_gatt_attr_write_ccc + (bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset,u8_t flags) + +{ + uint uVar1; + _Bool _Var2; + bt_gatt_ccc_cfg *pbVar3; + undefined3 extraout_var; + undefined2 in_register_00002036; + undefined2 in_register_0000203a; + int iVar4; + _bt_gatt_ccc_conflict2 *ccc; + undefined4 uStack40; + undefined2 uStack36; + undefined uStack34; + + iVar4 = CONCAT22(in_register_00002036,len); + ccc = (_bt_gatt_ccc_conflict2 *)attr->user_data; + if (CONCAT22(in_register_0000203a,offset) != 0) { + return -7; + } + if (1 < (iVar4 - 1U & 0xffff)) { + return -0xd; + } + uVar1 = (uint)*(byte *)buf; + if (iVar4 != 1) { + uVar1 = (uint)CONCAT11(*(undefined *)((int)buf + 1),*(byte *)buf); + } + pbVar3 = find_ccc_cfg(conn,ccc); + if (pbVar3 == (bt_gatt_ccc_cfg *)0x0) { + if (uVar1 == 0) { + return iVar4; + } + pbVar3 = find_ccc_cfg((bt_conn *)0x0,ccc); + if (pbVar3 == (bt_gatt_ccc_cfg *)0x0) { + printf("No space to store CCC cfg\r\n"); + return -0x11; + } + memcpy(&pbVar3->peer,conn->field_20,7); + pbVar3->id = conn->id; + } + if ((ccc->cfg_write == (anon_subr__Bool_bt_conn_ptr_bt_gatt_attr_ptr_u16_t_for_cfg_write *)0x0) || + (_Var2 = (*ccc->cfg_write)(conn,attr,(u16_t)uVar1), CONCAT31(extraout_var,_Var2) != 0)) { + pbVar3->value = (u16_t)uVar1; + if ((uint)ccc->value != uVar1) { + gatt_ccc_changed(attr,ccc); + } + if (uVar1 == 0) { + uStack40 = 0; + uStack36 = 0; + uStack34 = 0; + memcpy(&pbVar3->peer,&uStack40,7); + pbVar3->id = '\0'; + pbVar3->value = 0; + } + } + else { + iVar4 = -3; + } + return iVar4; +} + + + +void bt_gatt_init(void) + +{ + anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept **ppaVar1; + bool bVar2; + int iVar3; + uint uVar4; + bt_gatt_service_static *pbVar5; + + iVar3 = atomic_cas(&init,0,1); + if (iVar3 != 0) { + uVar4 = (uint)last_static_handle; + bVar2 = false; + pbVar5 = &_1_gatt_svc; + while (pbVar5 < &att_fixed_chan) { + ppaVar1 = &((bt_l2cap_fixed_chan *)pbVar5)->accept; + pbVar5 = (bt_gatt_service_static *)&((bt_l2cap_fixed_chan *)pbVar5)->node; + uVar4 = (uint)(*ppaVar1 + uVar4) & 0xffff; + bVar2 = true; + } + if (bVar2) { + last_static_handle = (u16_t)uVar4; + } + k_delayed_work_init((k_delayed_work *)&gatt_sc.work,sc_process); + return; + } + return; +} + + + +void bt_gatt_deinit(void) + +{ + k_delayed_work_del_timer((k_delayed_work *)&gatt_sc.work); + return; +} + + + +undefined4 bt_gatt_service_unregister(int *param_1) + +{ + sys_snode_t prev_node; + sys_snode_t sVar1; + + prev_node = (sys_snode_t)0x0; + sVar1 = (sys_snode_t)db.head; + while( true ) { + if (sVar1 == (sys_snode_t)0x0) { + return 0xfffffffe; + } + if ((sys_snode_t)(param_1 + 2) == sVar1) break; + prev_node = sVar1; + sVar1 = *(sys_snode_t *)sVar1; + } + sys_slist_remove(&db,(sys_snode_t *)prev_node,(sys_snode_t *)(param_1 + 2)); + sc_indicate(*(u16_t *)(*param_1 + 0x10),*(u16_t *)(param_1[1] * 0x14 + *param_1 + -4)); + return 0; +} + + + +ssize_t bt_gatt_attr_read(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t buf_len,u16_t offset, + void *value,u16_t value_len) + +{ + uint __n; + undefined2 in_register_00002036; + undefined2 in_register_0000203a; + uint uVar1; + undefined2 in_register_00002042; + + uVar1 = CONCAT22(in_register_0000203a,offset); + __n = 0xfffffff9; + if (uVar1 <= CONCAT22(in_register_00002042,value_len)) { + __n = CONCAT22(in_register_00002042,value_len) - uVar1; + if ((int)CONCAT22(in_register_00002036,buf_len) < (int)__n) { + __n = CONCAT22(in_register_00002036,buf_len); + } + __n = __n & 0xffff; + memcpy(buf,(void *)((int)value + uVar1),__n); + } + return __n; +} + + + +uint16_t bt_gatt_attr_value_handle(bt_gatt_attr *attr) + +{ + u16_t uVar1; + undefined2 extraout_var; + uint16_t uVar2; + + if (attr == (bt_gatt_attr *)0x0) { + uVar2 = 0; + } + else { + uVar2 = 0; + if ((attr->read == bt_gatt_attr_read_chrc) && + (uVar2 = *(uint16_t *)((int)attr->user_data + 4), uVar2 == 0)) { + if (attr->handle == 0) { + uVar1 = find_static_attr(attr); + return (uint16_t)((uint)((CONCAT22(extraout_var,uVar1) + 1) * 0x10000) >> 0x10); + } + uVar2 = attr->handle + 1; + } + } + return uVar2; +} + + + +uint lexical_block_0(bt_gatt_attr *param_1) + +{ + ushort uVar1; + u16_t uVar2; + uint uVar3; + + uVar1 = *(ushort *)((int)param_1->user_data + 4); + uVar3 = (uint)uVar1; + if (uVar1 == 0) { + if (param_1->handle == 0) { + uVar2 = find_static_attr(param_1); + return (uint)uVar2 + 1 & 0xffff; + } + uVar3 = (uint)param_1->handle + 1 & 0xffff; + } + return uVar3; +} + + + +ssize_t bt_gatt_attr_read_chrc(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset) + +{ + char **ppcVar1; + uint __n; + uint16_t uVar2; + char *pcVar3; + undefined2 in_register_00002036; + undefined2 in_register_0000203a; + uint uVar4; + uint uVar5; + u8_t auStack52 [4]; + gatt_chrc pdu; + + uVar4 = CONCAT22(in_register_0000203a,offset); + ppcVar1 = (char **)attr->user_data; + auStack52[0] = *(u8_t *)((int)ppcVar1 + 6); + uVar2 = bt_gatt_attr_value_handle(attr); + auStack52[1] = (u8_t)uVar2; + auStack52[2] = (u8_t)(uVar2 >> 8); + pcVar3 = *ppcVar1; + if (*pcVar3 == '\0') { + auStack52[3] = (u8_t)*(undefined2 *)(pcVar3 + 2); + pdu.properties = (u8_t)((ushort)*(undefined2 *)(pcVar3 + 2) >> 8); + uVar5 = 5; + } + else { + memcpy(auStack52 + 3,pcVar3 + 1,0x10); + uVar5 = 0x13; + } + __n = 0xfffffff9; + if (uVar4 <= uVar5) { + __n = uVar5 - uVar4; + if ((int)CONCAT22(in_register_00002036,len) < (int)(uVar5 - uVar4)) { + __n = CONCAT22(in_register_00002036,len); + } + __n = __n & 0xffff; + memcpy(buf,auStack52 + uVar4,__n); + } + return __n; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void bt_gatt_foreach_attr_type + (u16_t start_handle,u16_t end_handle,bt_uuid *uuid,void *attr_data, + uint16_t num_matches,bt_gatt_attr_func_t *func,void *user_data) + +{ + uint uVar1; + anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *paVar2; + sys_snode_t sVar3; + u8_t uVar4; + undefined2 in_register_0000202a; + anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *paVar5; + undefined3 extraout_var; + undefined3 extraout_var_00; + int iVar6; + undefined2 in_register_0000202e; + undefined2 in_register_0000203a; + sys_snode_t sVar7; + _snode *p_Var8; + anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *paVar9; + bt_gatt_attr *pbVar10; + anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *paVar11; + bt_gatt_service_static *pbVar12; + bt_uuid *pbStack84; + bt_gatt_attr attr; + + uVar1 = CONCAT22(in_register_0000203a,num_matches); + paVar5 = (anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *) + CONCAT22(in_register_0000202a,start_handle); + if (uVar1 == 0) { + uVar1 = 0xffff; + } + if (paVar5 <= (anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *) + (uint)last_static_handle) { + pbVar12 = &_1_gatt_svc; + paVar9 = (anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *)0x1; + while (pbVar12 < &att_fixed_chan) { + if (((bt_l2cap_fixed_chan *)pbVar12)->accept + (int)paVar9 < paVar5) { + paVar2 = (anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *) + ((uint)(((bt_l2cap_fixed_chan *)pbVar12)->accept + (int)paVar9) & 0xffff); + } + else { + paVar11 = (anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *)0x0; + while( true ) { + paVar2 = (anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *) + ((uint)(paVar11 + (int)paVar9) & 0xffff); + if (((bt_l2cap_fixed_chan *)pbVar12)->accept <= paVar11) break; + memcpy(&pbStack84,(void *)((int)paVar11 * 0x14 + *(int *)pbVar12),0x14); + attr.user_data._0_2_ = (u16_t)((uint)((int)(paVar11 + (int)paVar9) * 0x10000) >> 0x10); + if ((anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *) + CONCAT22(in_register_0000202e,end_handle) < paVar2) { + return; + } + if (((paVar5 <= paVar2) && + ((uuid == (bt_uuid *)0x0 || (iVar6 = bt_uuid_cmp(uuid,pbStack84), iVar6 == 0)))) && + ((attr_data == (void *)0x0 || + ((anon_subr_ssize_t_bt_conn_ptr_bt_gatt_attr_ptr_void_ptr_u16_t_u16_t_u8_t_for_write * + )attr_data == attr.write)))) { + uVar1 = uVar1 - 1 & 0xffff; + uVar4 = (*func)((bt_gatt_attr *)&pbStack84,user_data); + if (uVar1 == 0) { + return; + } + if (CONCAT31(extraout_var,uVar4) == 0) { + return; + } + } + paVar11 = paVar11 + 1; + } + } + pbVar12 = (bt_gatt_service_static *)&((bt_l2cap_fixed_chan *)pbVar12)->node; + paVar9 = paVar2; + } + } + sVar3 = (sys_snode_t)db.head; + if (db.head != (sys_snode_t *)0x0) { + while ((sys_snode_t *)((int)sVar3 + -8) != (sys_snode_t *)0x0) { + sVar7 = *(sys_snode_t *)sVar3; + if (((sVar7 == (sys_snode_t)0x0) || (sVar7 == (sys_snode_t)0x8)) || + (paVar5 < (anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *) + (uint)*(ushort *)(*(int *)((int)sVar7 + -8) + 0x10))) { + p_Var8 = (_snode *)0x0; + while (p_Var8 < ((sys_snode_t *)((int)sVar3 + -4))->next) { + pbVar10 = (bt_gatt_attr *)(((sys_snode_t *)((int)sVar3 + -8))->next + (int)p_Var8 * 5); + if ((anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *) + CONCAT22(in_register_0000202e,end_handle) < + (anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *)(uint)pbVar10->handle) { + return; + } + if (((paVar5 <= (anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept *) + (uint)pbVar10->handle) && + ((uuid == (bt_uuid *)0x0 || (iVar6 = bt_uuid_cmp(uuid,pbVar10->uuid), iVar6 == 0)))) + && ((attr_data == (void *)0x0 || (attr_data == pbVar10->user_data)))) { + uVar1 = uVar1 - 1 & 0xffff; + uVar4 = (*func)(pbVar10,user_data); + if (uVar1 == 0) { + return; + } + if (CONCAT31(extraout_var_00,uVar4) == 0) { + return; + } + } + p_Var8 = (_snode *)((int)&p_Var8->next + 1); + } + } + sVar3 = *(sys_snode_t *)sVar3; + if (sVar3 == (sys_snode_t)0x0) { + return; + } + } + } + return; +} + + + +void bt_gatt_foreach_attr + (u16_t start_handle,u16_t end_handle,bt_gatt_attr_func_t *func,void *user_data) + +{ + bt_gatt_foreach_attr_type(start_handle,end_handle,(bt_uuid *)0x0,(void *)0x0,0,func,user_data); + return; +} + + + +int bt_gatt_service_register(bt_uuid **param_1) + +{ + ushort start_handle; + sys_snode_t *psVar1; + sys_snode_t *psVar2; + u16_t start_handle_00; + int iVar3; + bt_conn *conn; + undefined2 extraout_var; + undefined2 extraout_var_00; + uint uVar4; + sys_snode_t sVar5; + sys_snode_t *psVar6; + sys_snode_t *psVar7; + sys_snode_t *psVar8; + uint uVar9; + bt_uuid *pbVar10; + short sVar11; + uint uVar12; + bt_gatt_attr *pbStack88; + bt_uuid abStack84 [2]; + undefined2 uStack82; + bt_uuid abStack80 [2]; + undefined2 uStack78; + int iStack76; + undefined2 uStack72; + bt_gatt_indicate_params_conflict2 *pbStack68; + bt_uuid **ppbStack60; + sys_slist_t *psStack56; + undefined4 uStack52; + bt_uuid abStack44 [2]; + undefined2 uStack42; + undefined auStack40 [2]; + undefined2 uStack38; + bt_att_func_t *pbStack36; + + bt_gatt_init(); + abStack44[0] = (bt_uuid)0x0; + uStack42 = 0x1800; + iVar3 = bt_uuid_cmp(*(bt_uuid **)*param_1,abStack44); + if (iVar3 == 0) { + return 0xffffffbb; + } + pbStack68 = (bt_gatt_indicate_params_conflict2 *)auStack40; + auStack40[0] = 0; + uStack38 = 0x1801; + uStack52 = 0x23028c68; + conn = (bt_conn *)bt_uuid_cmp(*(bt_uuid **)*param_1,(bt_uuid *)pbStack68); + if (conn == (bt_conn *)0x0) { + return 0xffffffbb; + } + pbVar10 = *param_1; + sVar11 = *(short *)(param_1 + 1); + if (db.head == (sys_snode_t *)0x0) { + uVar9 = (uint)last_static_handle; + uVar12 = 0; +LAB_23028cca: + while ((psVar1 = db.tail, pbVar10 != (bt_uuid *)0x0 && (sVar11 != 0))) { + start_handle = *(ushort *)(pbVar10 + 0x10); + if (start_handle == 0) { + *(short *)(pbVar10 + 0x10) = (short)((uVar9 + 1) * 0x10000 >> 0x10); + uVar4 = uVar9 + 1 & 0xffff; + } + else { + uVar4 = (uint)start_handle; + if ((uint)start_handle <= uVar9) { + pbStack36 = (bt_att_func_t *)0x0; + bt_gatt_foreach_attr(start_handle,start_handle,found_attr,&pbStack36); + uVar4 = uVar9; + if (pbStack36 != (bt_att_func_t *)0x0) { + printf("Unable to register handle 0x%04x\r\n"); + return 0xffffffea; + } + } + } + sVar11 = sVar11 + -1; + pbVar10 = pbVar10 + 0x14; + uVar9 = uVar4; + } + if ((uVar12 == 0) || (uVar12 < (uint)*(ushort *)(*param_1 + 0x10))) { +LAB_23028ce4: + psVar8 = (sys_snode_t *)(param_1 + 2); + psVar8->next = (_snode *)0x0; + psVar2 = psVar8; + if (db.tail != (sys_snode_t *)0x0) { + *(sys_snode_t **)&(db.tail)->next = psVar8; +LAB_23028d62: + psVar8 = db.head; + psVar2 = (sys_snode_t *)(param_1 + 2); + } + } + else { + psVar8 = db.head; + psVar2 = db.tail; + if (db.head != (sys_snode_t *)0x0) { + psVar6 = (sys_snode_t *)0x0; + sVar5 = (sys_snode_t)db.head; + while (psVar7 = (sys_snode_t *)((int)sVar5 + -8), psVar7 != (sys_snode_t *)0x0) { + if ((uint)*(ushort *)(*param_1 + 0x10) < (uint)*(ushort *)&psVar7->next[4].next) { + psVar8 = (sys_snode_t *)(param_1 + 2); + if (psVar6 == (sys_snode_t *)0x0) { + *(sys_snode_t **)(param_1 + 2) = db.head; + db.head = psVar8; + psVar2 = db.tail; + if (psVar1 == (sys_snode_t *)0x0) goto LAB_23028d62; + } + else { + if (psVar6[2].next == (_snode *)0x0) goto LAB_23028ce4; + *(_snode **)(param_1 + 2) = psVar6[2].next; + *(sys_snode_t **)&psVar6[2].next = psVar8; + psVar8 = db.head; + psVar2 = db.tail; + } + break; + } + sVar5 = *(sys_snode_t *)sVar5; + psVar6 = psVar7; + if (sVar5 == (sys_snode_t)0x0) break; + } + } + } + db.tail = psVar2; + db.head = psVar8; + sc_indicate(*(u16_t *)(*param_1 + 0x10),*(u16_t *)(*param_1 + (int)param_1[1] * 0x14 + -4)); + return 0; + } + if (db.tail != (sys_snode_t *)0x0) { + uVar9 = (uint)*(ushort *)&db.tail[-2].next[(int)db.tail[-1].next * 5 + -1].next; + uVar12 = uVar9; + goto LAB_23028cca; + } + ebreak(); + psStack56 = &db; + pbStack88 = pbStack68->attr; + if ((conn != (bt_conn *)0x0) && (conn->state != BT_CONN_CONNECTED)) { + return 0xffffffc7; + } + start_handle_00 = pbStack88->handle; + ppbStack60 = param_1; + if ((start_handle_00 == 0) && + (start_handle_00 = find_static_attr(pbStack88), CONCAT22(extraout_var,start_handle_00) == 0)) { +LAB_23028db4: + iStack76 = -2; + } + else { + if (pbStack68->uuid != (bt_uuid *)0x0) { + pbStack88 = (bt_gatt_attr *)0x0; + bt_gatt_foreach_attr_type + (start_handle_00,0xffff,pbStack68->uuid,(void *)0x0,1,match_uuid,&pbStack88); + if ((pbStack88 == (bt_gatt_attr *)0x0) || + ((start_handle_00 = pbStack88->handle, start_handle_00 == 0 && + (start_handle_00 = find_static_attr(pbStack88), + CONCAT22(extraout_var_00,start_handle_00) == 0)))) goto LAB_23028db4; + } + abStack84[0] = (bt_uuid)0x0; + uStack82 = 0x2803; + iVar3 = bt_uuid_cmp(pbStack88->uuid,abStack84); + if (iVar3 == 0) { + if ((*(byte *)((int)pbStack68->attr->user_data + 6) & 0x20) == 0) { + return 0xffffffea; + } + start_handle_00 = bt_gatt_attr_value_handle(pbStack68->attr); + } + if (conn == (bt_conn *)0x0) { + iStack76 = -0x39; + uStack72 = 2; + uStack78 = 0x2902; + abStack80[0] = (bt_uuid)0x0; + bt_gatt_foreach_attr_type(start_handle_00,0xffff,abStack80,(void *)0x0,1,notify_cb,&iStack76); + } + else { + iStack76 = gatt_indicate(conn,start_handle_00,pbStack68); + } + } + return iStack76; +} + + + +// WARNING: Variable defined which should be unmapped: data +// WARNING: Could not reconcile some variable overlaps + +int bt_gatt_indicate(bt_conn *conn,bt_gatt_indicate_params_conflict2 *params) + +{ + u16_t start_handle; + undefined2 extraout_var; + undefined2 extraout_var_00; + int iVar1; + bt_gatt_attr *pbStack40; + bt_gatt_attr *attr; + bt_uuid abStack32 [2]; + undefined2 uStack30; + int iStack28; + notify_data data; + + pbStack40 = params->attr; + if ((conn != (bt_conn *)0x0) && (conn->state != BT_CONN_CONNECTED)) { + return -0x39; + } + start_handle = pbStack40->handle; + if ((start_handle == 0) && + (start_handle = find_static_attr(pbStack40), CONCAT22(extraout_var,start_handle) == 0)) { +LAB_23028db4: + iStack28 = -2; + } + else { + if (params->uuid != (bt_uuid *)0x0) { + pbStack40 = (bt_gatt_attr *)0x0; + bt_gatt_foreach_attr_type + (start_handle,0xffff,params->uuid,(void *)0x0,1,match_uuid,&pbStack40); + if ((pbStack40 == (bt_gatt_attr *)0x0) || + ((start_handle = pbStack40->handle, start_handle == 0 && + (start_handle = find_static_attr(pbStack40), CONCAT22(extraout_var_00,start_handle) == 0)) + )) goto LAB_23028db4; + } + attr._0_1_ = 0; + attr._2_2_ = 0x2803; + iVar1 = bt_uuid_cmp(pbStack40->uuid,(bt_uuid *)&attr); + if (iVar1 == 0) { + if ((*(byte *)((int)params->attr->user_data + 6) & 0x20) == 0) { + return -0x16; + } + start_handle = bt_gatt_attr_value_handle(params->attr); + } + if (conn == (bt_conn *)0x0) { + iStack28 = -0x39; + data.err._0_2_ = 2; + uStack30 = 0x2902; + abStack32[0] = (bt_uuid)0x0; + data._4_4_ = params; + bt_gatt_foreach_attr_type(start_handle,0xffff,abStack32,(void *)0x0,1,notify_cb,&iStack28); + } + else { + iStack28 = gatt_indicate(conn,start_handle,params); + } + } + return iStack28; +} + + + +// WARNING: Variable defined which should be unmapped: sc_range + +void sc_process(k_work *work) + +{ + int iVar1; + atomic_t aStack20; + u16_t sc_range [2]; + + aStack20 = work[-1].flags[0]; + atomic_and((atomic_t *)(work + 3),-2); + work[-2].handler = (k_work_handler_t *)0x230769fc; + work[-2].flags[0] = 0x230281ec; + *(atomic_t **)&work[-1]._reserved = &aStack20; + *(undefined2 *)work[-1].flags = 0; + *(undefined2 *)((int)work[-1].flags + 2) = 0; + *(undefined2 *)&work[-1].handler = 4; + iVar1 = bt_gatt_indicate((bt_conn *)0x0,(bt_gatt_indicate_params_conflict2 *)(work + -4)); + if (iVar1 == 0) { + atomic_or((atomic_t *)(work + 3),2); + } + return; +} + + + +u16_t bt_gatt_get_mtu(bt_conn *conn) + +{ + u16_t uVar1; + bt_att *pbVar2; + + pbVar2 = att_chan_get(conn); + if (pbVar2 == (bt_att *)0x0) { + uVar1 = 0; + } + else { + uVar1 = (pbVar2->chan).tx.mtu; + } + return uVar1; +} + + + +u8_t bt_gatt_check_perm(bt_conn *conn,bt_gatt_attr *attr,u8_t mask) + +{ + byte bVar1; + bt_security_t bVar2; + undefined3 extraout_var; + byte bVar3; + + bVar1 = attr->perm; + if ((((mask & 1) == 0) || + ((bVar3 = 2, (bVar1 & 0x15) != 0 && + (attr->read != + (anon_subr_ssize_t_bt_conn_ptr_bt_gatt_attr_ptr_void_ptr_u16_t_u16_t_for_read *)0x0)))) && + (((mask & 2) == 0 || + ((bVar3 = 3, (bVar1 & 0x2a) != 0 && + (attr->write != + (anon_subr_ssize_t_bt_conn_ptr_bt_gatt_attr_ptr_void_ptr_u16_t_u16_t_u8_t_for_write *)0x0))) + ))) { + bVar1 = bVar1 & mask; + if (((bVar1 & 0x30) != 0) && + (bVar2 = bt_conn_get_security(conn), CONCAT31(extraout_var,bVar2) < 3)) { + return '\x05'; + } + bVar3 = bVar1 & 0xc; + if (((bVar1 & 0xc) != 0) && (bVar3 = 0, conn->encrypt == '\0')) { + bVar3 = 0xf; + } + } + return (u8_t)bVar3; +} + + + +u8_t update_ccc(bt_gatt_attr *attr,void *user_data) + +{ + bt_conn *conn; + u8_t uVar1; + bt_security_t bVar2; + int iVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + gatt_sc_cfg *pgVar4; + undefined3 extraout_var_01; + bt_addr_le_t *peer; + uint uVar5; + _bt_gatt_ccc_conflict2 *ccc; + ushort uStack52; + ushort uStack50; + u16_t sc_range [2]; + + if (attr->write != bt_gatt_attr_write_ccc) { + return '\x01'; + } + ccc = (_bt_gatt_ccc_conflict2 *)attr->user_data; + conn = *(bt_conn **)user_data; + peer = &ccc->cfg[0].peer; + do { + iVar3 = bt_conn_addr_le_cmp(conn,peer); + if (iVar3 == 0) { + uVar1 = bt_gatt_check_perm(conn,attr,'*'); + iVar3 = CONCAT31(extraout_var,uVar1); + if (iVar3 == 0) { +LAB_23028fd8: + if (*(short *)(peer + 1) != 0) { + gatt_ccc_changed(attr,ccc); + if (ccc != &sc_ccc) { + return '\x01'; + } + pgVar4 = find_sc_cfg(conn->id,(bt_addr_le_t *)conn->field_20); + if (pgVar4 == (gatt_sc_cfg *)0x0) { + return '\x01'; + } + uStack52 = (pgVar4->data).start; + uStack50 = (pgVar4->data).end; + if ((uStack52 | uStack50) == 0) { + return '\x01'; + } + uVar1 = bt_conn_index(conn); + iVar3 = CONCAT31(extraout_var_01,uVar1); + sc_restore_params[iVar3].attr = (bt_gatt_attr *)0x230769fc; + sc_restore_params[iVar3].func = sc_restore_rsp; + *(ushort **)&sc_restore_params[iVar3].data = &uStack52; + sc_restore_params[iVar3].len = 4; + iVar3 = bt_gatt_indicate(conn,(bt_gatt_indicate_params_conflict2 *) + (sc_restore_params + iVar3)); + if (iVar3 != 0) { + printf("SC restore indication failed\r\n"); + } + memset(&pgVar4->data,0,4); + return '\x01'; + } + } + else { + if (iVar3 == 3) { + printf("CCC %p not writable\r\n",attr); + } + else { + uVar5 = 2; + if (iVar3 == 5) { + uVar5 = 3; + } + bVar2 = bt_conn_get_security(conn); + if (uVar5 <= CONCAT31(extraout_var_00,bVar2)) goto LAB_23028fd8; + if (*(byte *)((int)user_data + 4) < uVar5) { + *(undefined *)((int)user_data + 4) = (char)uVar5; + } + } + } + } + peer = (bt_addr_le_t *)(peer[1].a.val + 2); + if (peer == (bt_addr_le_t *)((int)&ccc->value + 1)) { + return '\x01'; + } + } while( true ); +} + + + +int bt_gatt_exchange_mtu(bt_conn *conn,bt_gatt_exchange_params *params) + +{ + net_buf *buf; + undefined *puVar1; + int iVar2; + + if (conn->state != BT_CONN_CONNECTED) { + return -0x39; + } + buf = bt_att_create_pdu(conn,'\x02',2); + if (buf != (net_buf *)0x0) { + puVar1 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + *puVar1 = 0xf7; + puVar1[1] = 0; + iVar2 = gatt_send(conn,buf,gatt_mtu_rsp,params); + return iVar2; + } + return -0xc; +} + + + +int bt_gatt_discover(bt_conn *conn,bt_gatt_discover_params *params) + +{ + undefined2 uVar1; + int iVar2; + net_buf *buf; + undefined *puVar3; + u16_t val; + code *func; + undefined *puVar4; + bt_uuid *pbVar5; + net_buf_simple *buf_00; + bt_uuid abStack56 [2]; + undefined2 uStack54; + bt_uuid abStack52 [2]; + undefined2 uStack50; + bt_uuid abStack48 [2]; + undefined2 uStack46; + bt_uuid abStack44 [2]; + undefined2 uStack42; + undefined auStack40 [2]; + undefined2 uStack38; + undefined auStack36 [2]; + undefined2 uStack34; + + if (conn->state != BT_CONN_CONNECTED) { + return -0x39; + } + switch(params->type) { + case '\0': + case '\x01': + if (params->uuid == (bt_uuid *)0x0) { + buf = bt_att_create_pdu(conn,'\x10',4); + if (buf == (net_buf *)0x0) goto LAB_23029138; + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,4); + uVar1 = *(undefined2 *)¶ms->field_3; + *puVar3 = (char)uVar1; + puVar3[1] = (char)((ushort)uVar1 >> 8); + val = params->end_handle; + puVar3[2] = (char)val; + puVar3[3] = (char)(val >> 8); + if (params->type == '\0') { + val = 0x2800; + } + else { + val = 0x2801; + } + net_buf_simple_add_le16((net_buf_simple *)&buf->field_4,val); + func = gatt_read_group_rsp; + goto LAB_230291de; + } + buf = bt_att_create_pdu(conn,'\x06',6); + if (buf != (net_buf *)0x0) { + buf_00 = (net_buf_simple *)&buf->field_4; + puVar3 = (undefined *)net_buf_simple_add(buf_00,6); + uVar1 = *(undefined2 *)¶ms->field_3; + *puVar3 = (char)uVar1; + puVar3[1] = (char)((ushort)uVar1 >> 8); + val = params->end_handle; + puVar3[2] = (char)val; + puVar3[3] = (char)(val >> 8); + if (params->type == '\0') { + uStack34 = 0x2800; + auStack36[0] = 0; + puVar4 = auStack36; + } + else { + uStack38 = 0x2801; + auStack40[0] = 0; + puVar4 = auStack40; + } + uVar1 = *(undefined2 *)(puVar4 + 2); + puVar3[4] = (char)uVar1; + puVar3[5] = (char)((ushort)uVar1 >> 8); + pbVar5 = params->uuid; + if (pbVar5->type == '\0') { + net_buf_simple_add_le16(buf_00,*(u16_t *)(pbVar5 + 2)); + } + else { + if (pbVar5->type != '\x02') { + printf("Unknown UUID type %u\r\n"); + net_buf_unref(buf); + return -0x16; + } + net_buf_simple_add_mem(buf_00,pbVar5 + 1,0x10); + } + func = gatt_find_type_rsp; + goto LAB_230291de; + } + goto LAB_23029138; + case '\x02': + case '\x03': + buf = bt_att_create_pdu(conn,'\b',4); + if (buf == (net_buf *)0x0) goto LAB_23029138; + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,4); + uVar1 = *(undefined2 *)¶ms->field_3; + *puVar3 = (char)uVar1; + puVar3[1] = (char)((ushort)uVar1 >> 8); + val = params->end_handle; + puVar3[2] = (char)val; + puVar3[3] = (char)(val >> 8); + if (params->type == '\x02') { + val = 0x2802; + } + else { + val = 0x2803; + } + net_buf_simple_add_le16((net_buf_simple *)&buf->field_4,val); + func = gatt_read_type_rsp; + goto LAB_230291de; + case '\x04': + if (params->uuid != (bt_uuid *)0x0) { + abStack56[0] = (bt_uuid)0x0; + uStack54 = 0x2800; + iVar2 = bt_uuid_cmp(params->uuid,abStack56); + if (iVar2 == 0) { + return -0x16; + } + abStack52[0] = (bt_uuid)0x0; + uStack50 = 0x2801; + iVar2 = bt_uuid_cmp(params->uuid,abStack52); + if (iVar2 == 0) { + return -0x16; + } + abStack48[0] = (bt_uuid)0x0; + uStack46 = 0x2802; + iVar2 = bt_uuid_cmp(params->uuid,abStack48); + if (iVar2 == 0) { + return -0x16; + } + abStack44[0] = (bt_uuid)0x0; + uStack42 = 0x2803; + iVar2 = bt_uuid_cmp(params->uuid,abStack44); + if (iVar2 == 0) { + return -0x16; + } + } +switchD_23029126_caseD_5: + buf = bt_att_create_pdu(conn,'\x04',4); + if (buf == (net_buf *)0x0) { +LAB_23029138: + iVar2 = -0xc; + } + else { + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,4); + uVar1 = *(undefined2 *)¶ms->field_3; + *puVar3 = (char)uVar1; + puVar3[1] = (char)((ushort)uVar1 >> 8); + val = params->end_handle; + func = gatt_find_info_rsp; + puVar3[2] = (char)val; + puVar3[3] = (char)(val >> 8); +LAB_230291de: + iVar2 = gatt_send(conn,buf,func,params); + } + return iVar2; + case '\x05': + goto switchD_23029126_caseD_5; + default: + printf("Invalid discovery type: %u\r\n"); + return -0x16; + } +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void gatt_discover_next(bt_conn *conn,u16_t last_handle,bt_gatt_discover_params *params) + +{ + int iVar1; + undefined2 in_register_0000202e; + + iVar1 = CONCAT22(in_register_0000202e,last_handle); + if (iVar1 != 0) { + if (iVar1 == 0xffff) { + *(undefined2 *)¶ms->field_3 = 0xffff; + goto done; + } + *(short *)¶ms->field_3 = (short)((iVar1 + 1U) * 0x10000 >> 0x10); + if ((uint)params->end_handle < (iVar1 + 1U & 0xffff)) goto done; + } + iVar1 = bt_gatt_discover(conn,params); + if (iVar1 == 0) { + return; + } +done: + // WARNING: Could not recover jumptable at 0x230293a0. Too many branches + // WARNING: Treating indirect jump as call + (*params->func)(conn,(bt_gatt_attr *)0x0); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void gatt_find_type_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + u16_t last_handle; + int iVar1; + undefined3 in_register_0000202d; + undefined2 in_register_00002036; + uint uVar2; + uint uVar3; + undefined auStack84 [2]; + undefined2 uStack82; + undefined auStack80 [2]; + undefined2 uStack78; + undefined4 uStack76; + bt_gatt_service_val value; + bt_gatt_attr attr; + + uVar2 = CONCAT22(in_register_00002036,length); + uVar3 = CONCAT31(in_register_0000202d,err); + if (uVar3 == 0) { + last_handle = 0; + while (3 < uVar2) { + last_handle = *(u16_t *)((int)pdu + uVar3 * 4 + 2); + if (*(char *)((int)user_data + 0x28) == '\0') { + auStack84[0] = 0; + uStack82 = 0x2800; + value._4_4_ = auStack84; + } + else { + auStack80[0] = 0; + uStack78 = 0x2801; + value._4_4_ = auStack80; + } + uStack76 = *(undefined4 *)((int)user_data + 0x18); + value.uuid._0_2_ = last_handle; + iVar1 = (**(code **)((int)user_data + 0x1c)) + (conn,&value.end_handle,user_data,*(code **)((int)user_data + 0x1c)); + if (iVar1 == 0) { + return; + } + uVar3 = uVar3 + 1 & 0xff; + uVar2 = uVar2 - 4 & 0xffff; + } + if (uVar2 == 0) { + gatt_discover_next(conn,last_handle,(bt_gatt_discover_params *)user_data); + return; + } + } + (**(code **)((int)user_data + 0x1c))(conn,0,user_data,*(code **)((int)user_data + 0x1c)); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void gatt_read_group_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + ushort last_handle; + int iVar1; + void *__dest; + undefined3 in_register_0000202d; + size_t __n; + uint uVar2; + code *pcVar3; + ushort *puVar4; + undefined auStack120 [2]; + undefined2 uStack118; + undefined auStack116 [2]; + undefined2 uStack114; + u16_t *puStack112; + bt_gatt_service_val value; + anon_union u; + bt_gatt_attr attr; + + if (CONCAT31(in_register_0000202d,err) != 0) { + pcVar3 = *(code **)((int)user_data + 0x1c); + goto LAB_230294bc; + } + if (*(char *)pdu == '\x06') { + value.end_handle._0_1_ = '\0'; +LAB_2302950c: + uVar2 = (uint)length - 1; + puVar4 = (ushort *)((int)pdu + 1); + last_handle = 0; + while (uVar2 = uVar2 & 0xffff, *(byte *)pdu <= uVar2) { + stack0xffffffac = (undefined *)0x0; + if (((*puVar4 == 0) || (last_handle = puVar4[1], last_handle == 0)) || (last_handle < *puVar4) + ) goto done; + if ((char)value.end_handle == '\0') { + __n = 2; + __dest = (void *)&value.field_0x6; +LAB_230295ce: + memcpy(__dest,puVar4 + 2,__n); + } + else { + if ((char)value.end_handle == '\x02') { + __n = 0x10; + __dest = (void *)((int)&value.end_handle + 1); + goto LAB_230295ce; + } + } + if (*(char *)((int)user_data + 0x28) == '\0') { + auStack116[0] = 0; + uStack114 = 0x2800; + unique0x10000079 = auStack116; + } + else { + auStack120[0] = 0; + uStack118 = 0x2801; + unique0x1000007d = auStack120; + } + puStack112 = &value.end_handle; + value.uuid._0_2_ = last_handle; + iVar1 = (**(code **)((int)user_data + 0x1c)) + (conn,u + 0x10,user_data,*(code **)((int)user_data + 0x1c)); + if (iVar1 == 0) { + return; + } + uVar2 = uVar2 - (uint)*(byte *)pdu; + puVar4 = (ushort *)((int)puVar4 + (uint)*(byte *)pdu); + } + if ((uVar2 == 0) && (last_handle != 0)) { + gatt_discover_next(conn,last_handle,(bt_gatt_discover_params *)user_data); + return; + } + } + else { + if (*(char *)pdu == '\x14') { + value.end_handle._0_1_ = '\x02'; + goto LAB_2302950c; + } + printf("Invalid data len %u\r\n"); + } +done: + pcVar3 = *(code **)((int)user_data + 0x1c); +LAB_230294bc: + (*pcVar3)(conn,0,user_data,pcVar3); + return; +} + + + +// WARNING: Variable defined which should be unmapped: u_1 +// WARNING: Could not reconcile some variable overlaps + +void gatt_read_type_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + char cVar1; + undefined2 uVar2; + ushort last_handle; + uint uVar3; + int iVar4; + net_buf *buf; + undefined *puVar5; + undefined3 in_register_0000202d; + code *pcVar6; + ushort *puVar7; + undefined auStack104 [2]; + undefined2 uStack102; + undefined auStack100 [2]; + undefined2 uStack98; + u16_t *puStack96; + bt_gatt_include value; + anon_union u; + anon_union u_1; + + if (CONCAT31(in_register_0000202d,err) != 0) { + pcVar6 = *(code **)((int)user_data + 0x1c); + goto LAB_23029610; + } + cVar1 = *(char *)pdu; + if (*(char *)((int)user_data + 0x28) == '\x02') { + if (cVar1 == '\x06') { + stack0xffffffbc = (undefined *)((uint)stack0xffffffbc & 0xffffff00 | 2); +LAB_23029636: + uVar3 = (uint)length - 1; + puVar7 = (ushort *)((int)pdu + 1); + last_handle = 0; + while (uVar3 = uVar3 & 0xffff, *(byte *)pdu <= uVar3) { + last_handle = *puVar7; + if (last_handle == 0) goto done; + value.uuid._0_2_ = puVar7[1]; + value.uuid._2_2_ = puVar7[2]; + if (u[16] == 0) { + stack0xffffffbc = (undefined *)((uint)stack0xffffffbc & 0xffff | (uint)puVar7[3] << 0x10); + puStack96 = (u16_t *)(u + 0x10); + } + else { + if (u[16] == 2) { + *(ushort *)((int)user_data + 0x20) = last_handle; + *(ushort *)((int)user_data + 0x22) = (ushort)value.uuid; + *(ushort *)((int)user_data + 0x24) = value.uuid._2_2_; + buf = bt_att_create_pdu(conn,'\n',2); + if (buf == (net_buf *)0x0) { + last_handle = 0xfff4; + } + else { + puVar5 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + uVar2 = *(undefined2 *)((int)user_data + 0x22); + *puVar5 = (char)uVar2; + puVar5[1] = (char)((ushort)uVar2 >> 8); + uVar3 = gatt_send(conn,buf,read_included_uuid_cb,user_data); + last_handle = (ushort)(uVar3 & 0xffff); + if ((uVar3 & 0xffff) == 0) { + return; + } + } + goto LAB_23029762; + } + } + if ((*(bt_uuid **)((int)user_data + 0x18) == (bt_uuid *)0x0) || + (iVar4 = bt_uuid_cmp((bt_uuid *)(u + 0x10),*(bt_uuid **)((int)user_data + 0x18)), + iVar4 == 0)) { + u._0_4_ = 0; + u._4_4_ = 0; + auStack104[0] = 0; + uStack102 = 0x2802; + u._12_4_ = (uint)last_handle; + value._4_4_ = auStack104; + u._8_4_ = &puStack96; + iVar4 = (**(code **)((int)user_data + 0x1c)) + (conn,&value.start_handle,user_data,*(code **)((int)user_data + 0x1c)); + if (iVar4 == 0) { + return; + } + } + uVar3 = uVar3 - (uint)*(byte *)pdu; + puVar7 = (ushort *)((int)puVar7 + (uint)*(byte *)pdu); + } + goto LAB_23029660; + } + if (cVar1 == '\b') { + stack0xffffffbc = (undefined *)((uint)stack0xffffffbc & 0xffffff00); + goto LAB_23029636; + } +LAB_23029784: + printf("Invalid data len %u\r\n"); + } + else { + if (cVar1 == '\a') { + value._4_4_ = (undefined *)((uint)value._5_3_ << 8); + } + else { + if (cVar1 != '\x15') goto LAB_23029784; + value._4_4_ = (undefined *)CONCAT31(value._5_3_,2); + } + uVar3 = (uint)length - 1; + puVar7 = (ushort *)((int)pdu + 1); + last_handle = 0; + while (uVar3 = uVar3 & 0xffff, *(byte *)pdu <= uVar3) { + last_handle = *puVar7; + if (last_handle == 0) goto done; + if ((char)value.start_handle == '\0') { + value._4_4_ = (undefined *) + ((uint)value._4_4_ & 0xffff | (uint)*(ushort *)((int)puVar7 + 5) << 0x10); + } + else { + if ((char)value.start_handle == '\x02') { + memcpy((void *)((int)&value.start_handle + 1),(void *)((int)puVar7 + 5),0x10); + } + } + if (*(bt_uuid **)((int)user_data + 0x18) == (bt_uuid *)0x0) { +LAB_230297f0: + auStack100[0] = 0; + uStack98 = 0x2803; + value.uuid._0_2_ = *(ushort *)((int)puVar7 + 3); + value.uuid._2_2_ = CONCAT11(value.uuid._3_1_,*(undefined *)(puVar7 + 1)); + puStack96 = &value.start_handle; + unique0x100000f4 = auStack100; + iVar4 = (**(code **)((int)user_data + 0x1c)) + (conn,u + 0x10,user_data,*(code **)((int)user_data + 0x1c)); + if (iVar4 == 0) { + return; + } + } + else { + iVar4 = bt_uuid_cmp((bt_uuid *)&value.start_handle,*(bt_uuid **)((int)user_data + 0x18)); + if (iVar4 == 0) goto LAB_230297f0; + } + uVar3 = uVar3 - (uint)*(byte *)pdu; + puVar7 = (ushort *)((int)puVar7 + (uint)*(byte *)pdu); + } +LAB_23029660: + if ((uVar3 == 0) && (last_handle != 0)) { +LAB_23029762: + gatt_discover_next(conn,last_handle,(bt_gatt_discover_params *)user_data); + return; + } + } +done: + pcVar6 = *(code **)((int)user_data + 0x1c); +LAB_23029610: + (*pcVar6)(conn,0,user_data,pcVar6); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void read_included_uuid_cb(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + int iVar1; + undefined2 in_register_00002036; + undefined auStack68 [2]; + undefined2 uStack66; + u16_t *puStack64; + bt_gatt_include value; + anon_union_for_u u; + + if (CONCAT22(in_register_00002036,length) == 0x10) { + value.uuid._0_2_ = *(undefined2 *)((int)user_data + 0x22); + value.uuid._2_2_ = *(undefined2 *)((int)user_data + 0x24); + value.start_handle._0_1_ = 2; + puStack64 = &value.start_handle; + memcpy((void *)((int)&value.start_handle + 1),pdu,0x10); + if ((*(bt_uuid **)((int)user_data + 0x18) == (bt_uuid *)0x0) || + (iVar1 = bt_uuid_cmp((bt_uuid *)&value.start_handle,*(bt_uuid **)((int)user_data + 0x18)), + iVar1 == 0)) { + uStack66 = 0x2802; + register0x0000203c = auStack68; + auStack68[0] = 0; + iVar1 = (**(code **)((int)user_data + 0x1c)) + (conn,u + 0x10,user_data,*(code **)((int)user_data + 0x1c)); + if (iVar1 == 0) { + return; + } + } + gatt_discover_next(conn,*(u16_t *)((int)user_data + 0x20),(bt_gatt_discover_params *)user_data); + } + else { + printf("Invalid data len %u\r\n",CONCAT22(in_register_00002036,length)); + (**(code **)((int)user_data + 0x1c))(conn,0,user_data,*(code **)((int)user_data + 0x1c)); + } + return; +} + + + +void gatt_find_info_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + bt_uuid bVar1; + bool bVar2; + uint uVar3; + u16_t *puVar4; + int iVar5; + undefined3 in_register_0000202d; + u16_t last_handle; + uint uVar6; + bt_uuid abStack104 [2]; + undefined2 uStack102; + bt_uuid abStack100 [2]; + undefined2 uStack98; + bt_uuid abStack96 [2]; + undefined2 uStack94; + bt_uuid abStack92 [2]; + undefined2 uStack90; + bt_uuid bStack88; + undefined uStack87; + u16_t uStack86; + anon_union_for_u u; + + if (CONCAT31(in_register_0000202d,err) == 0) { + bVar1 = *(bt_uuid *)pdu; + if (bVar1 == (bt_uuid)0x1) { + bStack88 = (bt_uuid)0x0; + uVar6 = 4; + } + else { + if (bVar1 != (bt_uuid)0x2) { + printf("Invalid format %u\r\n"); + goto done; + } + uVar6 = 0x12; + bStack88 = bVar1; + } + uVar3 = (uint)length - 1 & 0xffff; + if (uVar6 <= uVar3) { + uVar3 = uVar3 / uVar6; + puVar4 = (u16_t *)((int)pdu + 1); + bVar2 = false; + last_handle = 0; + do { + if (uVar3 == 0) { + gatt_discover_next(conn,last_handle,(bt_gatt_discover_params *)user_data); + return; + } + last_handle = *puVar4; + if (bVar2) { +LAB_230299c0: + bVar2 = false; + } + else { + if (bStack88 == (bt_uuid)0x0) { + uStack86 = puVar4[1]; + } + else { + if (bStack88 == (bt_uuid)0x2) { + memcpy(&uStack87,puVar4 + 1,0x10); + } + } + if ((*(bt_uuid **)((int)user_data + 0x18) != (bt_uuid *)0x0) && + (iVar5 = bt_uuid_cmp(&bStack88,*(bt_uuid **)((int)user_data + 0x18)), iVar5 != 0)) + goto LAB_230299c0; + if (*(char *)((int)user_data + 0x28) != '\x04') { +LAB_23029a60: + unique0x10000057 = &bStack88; + iVar5 = (**(code **)((int)user_data + 0x1c)) + (conn,u + 0x10,user_data,*(code **)((int)user_data + 0x1c)); + if (iVar5 == 0) { + return; + } + goto LAB_230299c0; + } + abStack104[0] = (bt_uuid)0x0; + uStack102 = 0x2800; + iVar5 = bt_uuid_cmp(&bStack88,abStack104); + if (iVar5 == 0) goto LAB_230299c0; + abStack100[0] = (bt_uuid)0x0; + uStack98 = 0x2801; + iVar5 = bt_uuid_cmp(&bStack88,abStack100); + if (iVar5 == 0) goto LAB_230299c0; + abStack96[0] = (bt_uuid)0x0; + uStack94 = 0x2802; + iVar5 = bt_uuid_cmp(&bStack88,abStack96); + if (iVar5 == 0) goto LAB_230299c0; + abStack92[0] = (bt_uuid)0x0; + uStack90 = 0x2803; + iVar5 = bt_uuid_cmp(&bStack88,abStack92); + if (iVar5 != 0) goto LAB_23029a60; + bVar2 = true; + } + uVar3 = uVar3 - 1; + puVar4 = (u16_t *)((int)puVar4 + uVar6); + } while( true ); + } + } +done: + (**(code **)((int)user_data + 0x1c))(conn,0,user_data,*(code **)((int)user_data + 0x1c)); + return; +} + + + +int bt_gatt_read(bt_conn *conn,bt_gatt_read_params *params) + +{ + undefined2 uVar1; + net_buf *buf; + int iVar2; + undefined *puVar3; + char *pcVar4; + uint uVar5; + code *func; + net_buf_simple *buf_00; + + if (conn->state != BT_CONN_CONNECTED) { + return -0x39; + } + uVar5 = params->handle_count; + if (uVar5 == 0) { + buf = bt_att_create_pdu(conn,'\b',4); + if (buf == (net_buf *)0x0) { + return -0xc; + } + buf_00 = (net_buf_simple *)&buf->field_4; + puVar3 = (undefined *)net_buf_simple_add(buf_00,4); + uVar1 = *(undefined2 *)¶ms->field_3; + *puVar3 = (char)uVar1; + puVar3[1] = (char)((ushort)uVar1 >> 8); + uVar1 = *(undefined2 *)((int)¶ms->field_3 + 2); + puVar3[2] = (char)uVar1; + puVar3[3] = (char)((ushort)uVar1 >> 8); + pcVar4 = *(char **)((int)¶ms->field_3 + 4); + if (*pcVar4 == '\0') { + net_buf_simple_add_le16(buf_00,*(u16_t *)(pcVar4 + 2)); + } + else { + net_buf_simple_add_mem(buf_00,pcVar4 + 1,0x10); + } + } + else { + if (1 < uVar5) { + buf = bt_att_create_pdu(conn,'\x0e',uVar5 << 1); + if (buf == (net_buf *)0x0) { + return -0xc; + } + uVar5 = 0; + while (uVar5 < params->handle_count) { + iVar2 = uVar5 * 2; + uVar5 = uVar5 + 1 & 0xff; + net_buf_simple_add_le16 + ((net_buf_simple *)&buf->field_4,*(u16_t *)(*(int *)¶ms->field_3 + iVar2)); + } + func = gatt_read_multiple_rsp; + goto LAB_23029b54; + } + if (*(short *)((int)¶ms->field_3 + 2) == 0) { + buf = bt_att_create_pdu(conn,'\n',2); + if (buf == (net_buf *)0x0) { + return -0xc; + } + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + uVar1 = *(undefined2 *)¶ms->field_3; + *puVar3 = (char)uVar1; + puVar3[1] = (char)((ushort)uVar1 >> 8); + } + else { + buf = bt_att_create_pdu(conn,'\f',4); + if (buf == (net_buf *)0x0) { + return -0xc; + } + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,4); + uVar1 = *(undefined2 *)¶ms->field_3; + *puVar3 = (char)uVar1; + puVar3[1] = (char)((ushort)uVar1 >> 8); + uVar1 = *(undefined2 *)((int)¶ms->field_3 + 2); + puVar3[2] = (char)uVar1; + puVar3[3] = (char)((ushort)uVar1 >> 8); + } + } + func = gatt_read_rsp; +LAB_23029b54: + iVar2 = gatt_send(conn,buf,func,params); + return iVar2; +} + + + +void gatt_read_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + code *UNRECOVERED_JUMPTABLE; + uint uVar1; + u16_t uVar2; + int iVar3; + undefined2 extraout_var; + undefined3 in_register_0000202d; + undefined2 in_register_00002036; + int iVar4; + uint uVar5; + short *psVar6; + + iVar4 = CONCAT22(in_register_00002036,length); + iVar3 = CONCAT31(in_register_0000202d,err); + if ((iVar3 == 0) && (iVar4 != 0)) { + if (*(int *)((int)user_data + 0x1c) == 0) { + uVar1 = iVar4 - 1; + psVar6 = (short *)((int)pdu + 1); + while (uVar1 = uVar1 & 0xffff, uVar1 != 0) { + if (*psVar6 == 0) { + printf("Invalid handle\r\n"); + return; + } + uVar5 = (uint)*(byte *)pdu; + if (uVar1 < uVar5) { + uVar5 = uVar1; + } + *(short *)((int)user_data + 0x20) = *psVar6; + iVar3 = (**(code **)((int)user_data + 0x18)) + (conn,0,user_data,psVar6 + 1,uVar5 - 2 & 0xffff, + *(code **)((int)user_data + 0x18)); + if (iVar3 == 0) { + return; + } + if (uVar1 < *(byte *)pdu) break; + if (*(short *)((int)user_data + 0x22) == *(short *)((int)user_data + 0x20)) + goto LAB_23029cb0; + *(short *)((int)user_data + 0x20) = *(short *)((int)user_data + 0x20) + 1; + uVar1 = uVar1 - (uint)*(byte *)pdu; + psVar6 = (short *)((int)psVar6 + (uint)*(byte *)pdu); + } + } + else { + iVar3 = (**(code **)((int)user_data + 0x18)) + (user_data,pdu,iVar4,*(code **)((int)user_data + 0x18)); + if (iVar3 == 0) { + return; + } + uVar2 = bt_att_get_mtu(conn); + if (iVar4 < CONCAT22(extraout_var,uVar2) + -1) { +LAB_23029cb0: + UNRECOVERED_JUMPTABLE = *(code **)((int)user_data + 0x18); + iVar3 = 0; + goto LAB_23029c0a; + } + *(short *)((int)user_data + 0x22) = length + *(short *)((int)user_data + 0x22); + } + iVar3 = bt_gatt_read(conn,(bt_gatt_read_params *)user_data); + if (-1 < iVar3) { + return; + } + UNRECOVERED_JUMPTABLE = *(code **)((int)user_data + 0x18); + iVar3 = 0xe; + } + else { + UNRECOVERED_JUMPTABLE = *(code **)((int)user_data + 0x18); + } +LAB_23029c0a: + // WARNING: Could not recover jumptable at 0x23029c1a. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(conn,iVar3,user_data,0,0); + return; +} + + + +int bt_gatt_write_without_response_cb + (bt_conn *conn,u16_t handle,void *data,u16_t length,_Bool sign, + bt_gatt_complete_func_t *func,void *user_data) + +{ + net_buf *buf; + undefined *puVar1; + int iVar2; + u8_t op; + size_t len; + undefined2 in_register_00002036; + size_t __n; + undefined3 in_register_00002039; + + __n = CONCAT22(in_register_00002036,length); + if (conn->state != BT_CONN_CONNECTED) { + return -0x39; + } + if ((conn->encrypt == '\0') && (CONCAT31(in_register_00002039,sign) != 0)) { + len = __n + 0xe; + op = -0x2e; + } + else { + len = __n + 2; + op = 'R'; + } + buf = bt_att_create_pdu(conn,op,len); + if (buf != (net_buf *)0x0) { + puVar1 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + *puVar1 = (char)handle; + puVar1[1] = (char)(handle >> 8); + memcpy(puVar1 + 2,data,__n); + net_buf_simple_add((net_buf_simple *)&buf->field_4,__n); + iVar2 = bt_att_send(conn,buf,(bt_conn_tx_cb_t *)func,user_data); + return iVar2; + } + return -0xc; +} + + + +int bt_gatt_write(bt_conn *conn,bt_gatt_write_params *params) + +{ + ushort uVar1; + u16_t uVar2; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined *puVar3; + net_buf *buf; + int iVar4; + code *func; + size_t __n; + + if (conn->state != BT_CONN_CONNECTED) { + return -0x39; + } + if ((params->offset == 0) && + (uVar1 = params->length, uVar2 = bt_att_get_mtu(conn), + (uint)uVar1 <= CONCAT22(extraout_var_00,uVar2) - 3U)) { + buf = bt_att_create_pdu(conn,'\x12',(uint)params->length + 2); + if (buf != (net_buf *)0x0) { + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,2); + uVar2 = params->handle; + *puVar3 = (char)uVar2; + puVar3[1] = (char)(uVar2 >> 8); + memcpy(puVar3 + 2,params->data,(uint)params->length); + net_buf_simple_add((net_buf_simple *)&buf->field_4,(uint)params->length); + func = gatt_write_rsp; + goto LAB_23029ee6; + } + } + else { + uVar1 = params->length; + uVar2 = bt_att_get_mtu(conn); + if ((uint)uVar1 < CONCAT22(extraout_var,uVar2) - 5U) { + __n = (size_t)params->length; + } + else { + uVar2 = bt_att_get_mtu(conn); + __n = (uint)uVar2 - 5 & 0xffff; + } + buf = bt_att_create_pdu(conn,'\x16',__n + 4); + if (buf != (net_buf *)0x0) { + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,4); + uVar2 = params->handle; + *puVar3 = (char)uVar2; + puVar3[1] = (char)(uVar2 >> 8); + uVar2 = params->offset; + puVar3[2] = (char)uVar2; + puVar3[3] = (char)(uVar2 >> 8); + memcpy(puVar3 + 4,params->data,__n); + net_buf_simple_add((net_buf_simple *)&buf->field_4,__n); + params->offset = params->offset + (short)__n; + func = gatt_prepare_write_rsp; + params->data = (void *)((int)params->data + __n); + params->length = params->length - (short)__n; +LAB_23029ee6: + iVar4 = gatt_send(conn,buf,func,params); + return iVar4; + } + } + return -0xc; +} + + + +void gatt_prepare_write_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data) + +{ + net_buf *buf; + undefined *puVar1; + undefined3 in_register_0000202d; + undefined2 in_register_00002036; + + if (CONCAT31(in_register_0000202d,err) != 0) { + // WARNING: Could not recover jumptable at 0x23029f08. Too many branches + // WARNING: Treating indirect jump as call + (**(code **)((int)user_data + 0x18))(user_data,CONCAT22(in_register_00002036,length)); + return; + } + if (*(short *)((int)user_data + 0x24) == 0) { + buf = bt_att_create_pdu(conn,'\x18',1); + if (buf != (net_buf *)0x0) { + puVar1 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf->field_4,1); + *puVar1 = 1; + gatt_send(conn,buf,gatt_write_rsp,user_data); + return; + } + return; + } + bt_gatt_write(conn,(bt_gatt_write_params *)user_data); + return; +} + + + +int bt_gatt_subscribe(bt_conn *conn,bt_gatt_subscribe_params *params) + +{ + bool bVar1; + sys_snode_t *psVar2; + bt_gatt_subscribe_params *pbVar3; + _snode *p_Var4; + int iVar5; + + if (conn->state != BT_CONN_CONNECTED) { + return -0x39; + } + pbVar3 = (bt_gatt_subscribe_params *)subscriptions.head; + if (subscriptions.head != (sys_snode_t *)0x0) { + pbVar3 = (bt_gatt_subscribe_params *)(subscriptions.head + -0xc); + } + bVar1 = false; + while (pbVar3 != (bt_gatt_subscribe_params *)0x0) { + if (pbVar3 == params) { + return -0x45; + } + iVar5 = bt_conn_addr_le_cmp(conn,&pbVar3->_peer); + if (((iVar5 == 0) && (pbVar3->value_handle == params->value_handle)) && + (params->value <= pbVar3->value)) { + bVar1 = true; + } + if ((pbVar3 == (bt_gatt_subscribe_params *)0xffffffd0) || + (p_Var4 = (pbVar3->node).next, p_Var4 == (_snode *)0x0)) break; + pbVar3 = (bt_gatt_subscribe_params *)(p_Var4 + -0xc); + } + if ((bVar1) || (iVar5 = gatt_write_ccc(conn,params->ccc_handle,params->value,params), iVar5 == 0)) + { + memcpy(¶ms->_peer,conn->field_20,7); + psVar2 = ¶ms->node; + *(sys_snode_t **)&(params->node).next = subscriptions.head; + subscriptions.head = psVar2; + if (subscriptions.tail == (sys_snode_t *)0x0) { + subscriptions.tail = ¶ms->node; + } + iVar5 = 0; + } + return iVar5; +} + + + +int bt_gatt_unsubscribe(bt_conn *conn,bt_gatt_subscribe_params *params) + +{ + bool bVar1; + bool bVar2; + bt_gatt_subscribe_params *pbVar3; + bt_gatt_subscribe_params *pbVar4; + int iVar5; + uint uVar6; + sys_snode_t *node; + bt_gatt_subscribe_params *pbVar7; + sys_snode_t *prev_node; + + if (conn->state != BT_CONN_CONNECTED) { + return -0x39; + } + pbVar7 = (bt_gatt_subscribe_params *)0x0; + pbVar3 = (bt_gatt_subscribe_params *)subscriptions.head; + if (subscriptions.head != (sys_snode_t *)0x0) { + pbVar7 = (bt_gatt_subscribe_params *)(subscriptions.head + -0xc); + if (pbVar7 == (bt_gatt_subscribe_params *)0x0) { + pbVar3 = (bt_gatt_subscribe_params *)0x0; + } + else { + pbVar3 = (bt_gatt_subscribe_params *)(subscriptions.head)->next; + if (pbVar3 != (bt_gatt_subscribe_params *)0x0) { + pbVar3 = (bt_gatt_subscribe_params *)&pbVar3[-1]._req.func; + } + } + } + bVar1 = false; + bVar2 = false; + prev_node = (sys_snode_t *)0x0; + while (pbVar4 = pbVar3, pbVar7 != (bt_gatt_subscribe_params *)0x0) { + node = &pbVar7->node; + if (pbVar7 == params) { + sys_slist_remove(&subscriptions,prev_node,node); + uVar6 = atomic_get(params->flags); + if ((uVar6 & 2) != 0) { + bt_att_req_cancel(conn,params); + } + bVar1 = true; + node = prev_node; + } + else { + iVar5 = bt_conn_addr_le_cmp(conn,&pbVar7->_peer); + if ((iVar5 == 0) && (pbVar7->value_handle == params->value_handle)) { + bVar2 = true; + } + } + pbVar3 = (bt_gatt_subscribe_params *)0x0; + pbVar7 = pbVar4; + prev_node = node; + if ((pbVar4 != (bt_gatt_subscribe_params *)0x0) && + (pbVar3 = (bt_gatt_subscribe_params *)(pbVar4->node).next, + pbVar3 != (bt_gatt_subscribe_params *)0x0)) { + pbVar3 = (bt_gatt_subscribe_params *)&pbVar3[-1]._req.func; + } + } + if (bVar1) { + if (!bVar2) { + params->value = 0; + iVar5 = gatt_write_ccc(conn,params->ccc_handle,0,params); + return iVar5; + } + (*params->notify)(conn,params,(void *)0x0,0); + iVar5 = 0; + } + else { + iVar5 = -0x16; + } + return iVar5; +} + + + +void bt_gatt_notification(bt_conn *conn,u16_t handle,void *data,u16_t length) + +{ + bt_gatt_subscribe_params *pbVar1; + bt_gatt_subscribe_params *pbVar2; + bt_gatt_subscribe_params *params; + u8_t uVar3; + int iVar4; + undefined3 extraout_var; + undefined2 in_register_0000202e; + + if (subscriptions.head == (sys_snode_t *)0x0) { + return; + } + params = (bt_gatt_subscribe_params *)(subscriptions.head + -0xc); + if (params != (bt_gatt_subscribe_params *)0x0) { + pbVar1 = (bt_gatt_subscribe_params *)(subscriptions.head)->next; + if (pbVar1 != (bt_gatt_subscribe_params *)0x0) { + pbVar1 = (bt_gatt_subscribe_params *)&pbVar1[-1]._req.func; + } + while( true ) { + pbVar2 = pbVar1; + iVar4 = bt_conn_addr_le_cmp(conn,¶ms->_peer); + if (((iVar4 == 0) && ((uint)params->value_handle == CONCAT22(in_register_0000202e,handle))) && + (uVar3 = (*params->notify)(conn,params,data,length), CONCAT31(extraout_var,uVar3) == 0)) { + bt_gatt_unsubscribe(conn,params); + } + if (pbVar2 == (bt_gatt_subscribe_params *)0x0) break; + pbVar1 = (bt_gatt_subscribe_params *)(pbVar2->node).next; + params = pbVar2; + if (pbVar1 != (bt_gatt_subscribe_params *)0x0) { + pbVar1 = (bt_gatt_subscribe_params *)&pbVar1[-1]._req.func; + } + } + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void bt_gatt_connected(bt_conn *conn) + +{ + sys_snode_t sVar1; + _Bool _Var2; + bt_security_t bVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + int iVar4; + char *key_00; + char acStack64 [4]; + char id_str [4]; + conn_data data; + char key [36]; + + data.conn._0_1_ = 1; + id_str = conn; + _Var2 = bt_addr_le_is_bonded(conn->id,(bt_addr_le_t *)conn->field_20); + if (CONCAT31(extraout_var,_Var2) != 0) { + key_00 = (char *)0x0; + if (conn->id != '\0') { + u8_to_dec(acStack64,'\x04',conn->id); + key_00 = acStack64; + } + bt_settings_encode_key(&data.sec,0x24,"ccc",(bt_addr_le_t *)conn->field_20,key_00); + } + bt_gatt_foreach_attr(1,0xffff,update_ccc,id_str); + bVar3 = bt_conn_get_security(conn); + sVar1 = (sys_snode_t)subscriptions.head; + if (CONCAT31(extraout_var_00,bVar3) < (uint)(byte)data.conn) { + bt_conn_set_security(conn,(byte)data.conn); + sVar1 = (sys_snode_t)subscriptions.head; + } + while ((sVar1 != (sys_snode_t)0x0 && + ((bt_gatt_subscribe_params *)((int)sVar1 + -0x30) != (bt_gatt_subscribe_params *)0x0))) { + iVar4 = bt_conn_addr_le_cmp(conn,(bt_addr_le_t *)((int)sVar1 + -0x18)); + if (iVar4 == 0) { + gatt_write_ccc(conn,*(u16_t *)((int)sVar1 + -10), + *(u16_t *)&((sys_snode_t *)((int)sVar1 + -8))->next, + (bt_gatt_subscribe_params *)((int)sVar1 + -0x30)); + } + sVar1 = *(sys_snode_t *)sVar1; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void bt_gatt_encrypt_change(bt_conn *conn) + +{ + bt_conn *pbStack24; + conn_data data; + + data.conn._0_1_ = 1; + pbStack24 = conn; + bt_gatt_foreach_attr(1,0xffff,update_ccc,&pbStack24); + return; +} + + + +_Bool bt_gatt_change_aware(bt_conn *conn,_Bool req) + +{ + return true; +} + + + +void bt_gatt_disconnected(bt_conn *conn) + +{ + bt_gatt_subscribe_params *params; + bt_gatt_subscribe_params *pbVar1; + bt_gatt_subscribe_params *pbVar2; + _Bool _Var3; + int iVar4; + undefined3 extraout_var; + uint uVar5; + sys_snode_t *prev; + + bt_gatt_foreach_attr(1,0xffff,disconnected_cb,conn); + if ((subscriptions.head != (sys_snode_t *)0x0) && + ((bt_gatt_subscribe_params *)(subscriptions.head + -0xc) != (bt_gatt_subscribe_params *)0x0)) { + pbVar1 = (bt_gatt_subscribe_params *)(subscriptions.head)->next; + if (pbVar1 != (bt_gatt_subscribe_params *)0x0) { + pbVar1 = (bt_gatt_subscribe_params *)&pbVar1[-1]._req.func; + } + prev = (sys_snode_t *)0x0; + params = (bt_gatt_subscribe_params *)(subscriptions.head + -0xc); +LAB_2302a2dc: + pbVar2 = pbVar1; + iVar4 = bt_conn_addr_le_cmp(conn,¶ms->_peer); + if (iVar4 == 0) { + _Var3 = bt_addr_le_is_bonded(conn->id,(bt_addr_le_t *)conn->field_20); + if ((CONCAT31(extraout_var,_Var3) != 0) && + (uVar5 = atomic_get(params->flags), (uVar5 & 1) == 0)) { + if ((params->_peer).type != '\0') { + memcpy(¶ms->_peer,(bt_addr_le_t *)conn->field_20,7); + } + goto LAB_2302a2ea; + } + params->value = 0; + gatt_subscription_remove(conn,prev,params); + } + else { +LAB_2302a2ea: + prev = ¶ms->node; + } + if (pbVar2 != (bt_gatt_subscribe_params *)0x0) { + pbVar1 = (bt_gatt_subscribe_params *)(pbVar2->node).next; + params = pbVar2; + if (pbVar1 != (bt_gatt_subscribe_params *)0x0) { + pbVar1 = (bt_gatt_subscribe_params *)&pbVar1[-1]._req.func; + } + goto LAB_2302a2dc; + } + } + return; +} + + + +void uuid_to_uuid128(bt_uuid *src,bt_uuid_128 *dst) + +{ + u8_t uVar1; + undefined2 uVar2; + void *pvVar3; + undefined4 uVar4; + + uVar1 = src->type; + if (uVar1 == '\x01') { + pvVar3 = memcpy(dst,&uuid128_base,0x11); + uVar4 = *(undefined4 *)(src + 4); + *(undefined *)((int)pvVar3 + 0xd) = (char)uVar4; + *(undefined *)((int)pvVar3 + 0xf) = (char)((uint)uVar4 >> 0x10); + *(undefined *)((int)pvVar3 + 0xe) = (char)((uint)uVar4 >> 8); + *(undefined *)((int)pvVar3 + 0x10) = (char)((uint)uVar4 >> 0x18); + } + else { + if (uVar1 == '\0') { + pvVar3 = memcpy(dst,&uuid128_base,0x11); + uVar2 = *(undefined2 *)(src + 2); + *(undefined *)((int)pvVar3 + 0xd) = (char)uVar2; + *(undefined *)((int)pvVar3 + 0xe) = (char)((ushort)uVar2 >> 8); + } + else { + if (uVar1 == '\x02') { + memcpy(dst,src,0x11); + return; + } + } + } + return; +} + + + +int bt_uuid_cmp(bt_uuid *u1,bt_uuid *u2) + +{ + u8_t uVar1; + int iVar2; + uint uVar3; + uint uVar4; + undefined uStack56; + undefined auStack55 [3]; + bt_uuid_128 uuid1; + undefined auStack35 [3]; + bt_uuid_128 uuid2; + + uVar1 = u2->type; + if (uVar1 == u1->type) { + if (uVar1 == '\x01') { + uVar3 = *(uint *)(u1 + 4); + uVar4 = *(uint *)(u2 + 4); + } + else { + if (uVar1 != '\0') { + if (uVar1 != '\x02') { + return -0x16; + } + u2 = u2 + 1; + u1 = u1 + 1; + goto LAB_2302a3fa; + } + uVar3 = (uint)*(ushort *)(u1 + 2); + uVar4 = (uint)*(ushort *)(u2 + 2); + } + iVar2 = uVar3 - uVar4; + } + else { + uuid_to_uuid128(u1,(bt_uuid_128 *)&uStack56); + uuid_to_uuid128(u2,(bt_uuid_128 *)(uuid1.val + 0xf)); + u2 = (bt_uuid *)auStack35; + u1 = (bt_uuid *)(&uStack56 + 1); +LAB_2302a3fa: + iVar2 = memcmp(u1,u2,0x10); + } + return iVar2; +} + + + +_Bool bt_uuid_create(bt_uuid *uuid,u8_t *data,u8_t data_len) + +{ + undefined3 in_register_00002031; + int iVar1; + + iVar1 = CONCAT31(in_register_00002031,data_len); + if (iVar1 == 4) { + uuid->type = '\x01'; + *(undefined4 *)(uuid + 4) = *(undefined4 *)data; + } + else { + if (iVar1 == 0x10) { + uuid->type = '\x02'; + memcpy(uuid + 1,data,0x10); + return true; + } + if (iVar1 != 2) { + return false; + } + uuid->type = '\0'; + *(undefined2 *)(uuid + 2) = *(undefined2 *)data; + } + return true; +} + + + +// WARNING: Variable defined which should be unmapped: tmp5 + +void bt_uuid_to_str(bt_uuid *uuid,char *str,size_t len) + +{ + u8_t uVar1; + uint uVar2; + undefined auStack32 [2]; + ushort uStack30; + u16_t tmp0; + u16_t tmp2; + u16_t tmp3; + u16_t tmp4; + u32_t_conflict tmp1; + u32_t_conflict tmp5; + + uVar1 = uuid->type; + if (uVar1 == '\x01') { + uVar2 = *(uint *)(uuid + 4); + } + else { + if (uVar1 != '\0') { + if (uVar1 != '\x02') { + memset(str,0,len); + return; + } + memcpy(auStack32,uuid + 1,2); + memcpy(&tmp3,uuid + 3,4); + memcpy(&uStack30,uuid + 7,2); + memcpy(&tmp0,uuid + 9,2); + memcpy(&tmp2,uuid + 0xb,2); + memcpy(&tmp1,uuid + 0xd,4); + snprintf(str,len,"%08x-%04x-%04x-%04x-%08x%04x",tmp1,(uint)tmp2,(uint)tmp0,(uint)uStack30, + _tmp3); + return; + } + uVar2 = (uint)*(ushort *)(uuid + 2); + } + snprintf(str,len,"%04x",uVar2); + return; +} + + + +void bt_settings_encode_key(char *path,size_t path_size,char *subsys,bt_addr_le_t *addr,char *key) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + uint uVar4; + + uVar2 = (uint)(addr->a).val[4]; + uVar1 = (uint)(addr->a).val[5]; + uVar3 = (uint)(addr->a).val[3]; + uVar4 = (uint)(addr->a).val[2]; + if (key == (char *)0x0) { + snprintf(path,path_size,"bt/%s/%02x%02x%02x%02x%02x%02x%u",subsys,uVar1,uVar2,uVar3,uVar4); + } + else { + snprintf(path,path_size,"bt/%s/%02x%02x%02x%02x%02x%02x%u/%s",subsys,uVar1,uVar2,uVar3,uVar4); + } + return; +} + + + +u8_t u8_to_dec(char *buf,u8_t buflen,u8_t value) + +{ + undefined3 in_register_0000202d; + uint uVar1; + undefined3 in_register_00002031; + uint uVar2; + int iVar3; + uint uVar4; + u8_t uVar5; + + uVar2 = CONCAT31(in_register_00002031,value); + uVar1 = CONCAT31(in_register_0000202d,buflen); + iVar3 = 4; + uVar5 = '\0'; + uVar4 = 100; + while( true ) { + if (uVar1 == 0) { + return uVar5; + } + iVar3 = iVar3 + -1; + if (iVar3 == 0) break; + if (((uVar4 <= uVar2) || (uVar4 == 1)) || (uVar5 != '\0')) { + uVar5 = uVar5 + '\x01'; + *buf = (char)(uVar2 / uVar4) + '0'; + uVar1 = uVar1 - 1 & 0xff; + buf = buf + 1; + } + uVar2 = uVar2 % uVar4; + uVar4 = uVar4 / 10; + } + *buf = '\0'; + return uVar5; +} + + + +void add_round_key(uint8_t *s,uint *k) + +{ + *s = *(byte *)((int)k + 3) ^ *s; + s[1] = (byte)*(undefined2 *)((int)k + 2) ^ s[1]; + s[2] = (byte)(*k >> 8) ^ s[2]; + s[3] = (byte)*k ^ s[3]; + s[4] = *(byte *)((int)k + 7) ^ s[4]; + s[5] = (byte)*(undefined2 *)((int)k + 6) ^ s[5]; + s[6] = (byte)(k[1] >> 8) ^ s[6]; + s[7] = (byte)k[1] ^ s[7]; + s[8] = *(byte *)((int)k + 0xb) ^ s[8]; + s[9] = (byte)*(undefined2 *)((int)k + 10) ^ s[9]; + s[10] = (byte)(k[2] >> 8) ^ s[10]; + s[0xb] = (byte)k[2] ^ s[0xb]; + s[0xc] = *(byte *)((int)k + 0xf) ^ s[0xc]; + s[0xd] = (byte)*(undefined2 *)((int)k + 0xe) ^ s[0xd]; + s[0xe] = (byte)(k[3] >> 8) ^ s[0xe]; + s[0xf] = (byte)k[3] ^ s[0xf]; + return; +} + + + +void shift_rows(uint8_t *s) + +{ + uint8_t local_20; + uint8_t uStack31; + uint8_t uStack30; + uint8_t uStack29; + uint8_t t [16]; + + local_20 = *s; + t[11] = s[0xb]; + uStack31 = s[5]; + uStack30 = s[10]; + uStack29 = s[0xf]; + t[0] = s[4]; + t[1] = s[9]; + t[2] = s[0xe]; + t[3] = s[3]; + t[4] = s[8]; + t[5] = s[0xd]; + t[6] = s[2]; + t[7] = s[7]; + t[8] = s[0xc]; + t[9] = s[1]; + t[10] = s[6]; + _copy(s,0x10,&local_20,0x10); + return; +} + + + +void mult_row_column(uint8_t *out,uint8_t *in) + +{ + byte bVar1; + byte bVar2; + byte bVar3; + byte bVar4; + byte bVar5; + + bVar1 = _double_byte(*in); + bVar2 = _double_byte(in[1]); + *out = bVar1 ^ in[1] ^ in[2] ^ in[3] ^ bVar2; + bVar1 = *in; + bVar2 = _double_byte(in[1]); + bVar3 = _double_byte(in[2]); + out[1] = bVar2 ^ bVar1 ^ in[2] ^ in[3] ^ bVar3; + bVar1 = in[1]; + bVar2 = *in; + bVar3 = _double_byte(in[2]); + bVar4 = _double_byte(in[3]); + out[2] = bVar3 ^ bVar2 ^ bVar1 ^ in[3] ^ bVar4; + bVar4 = _double_byte(*in); + bVar1 = in[1]; + bVar2 = *in; + bVar3 = in[2]; + bVar5 = _double_byte(in[3]); + out[3] = bVar5 ^ bVar2 ^ bVar1 ^ bVar3 ^ bVar4; + return; +} + + + +int tc_aes128_set_encrypt_key(TCAesKeySched_t s,uint8_t *k) + +{ + int iVar1; + byte *pbVar2; + byte *pbVar3; + uint uVar4; + TCAesKeySched_t ptVar5; + uint uVar6; + uint uStack60; + uint rconst [11]; + + memcpy(&uStack60,&DAT_23076cb8,0x2c); + iVar1 = 0; + if ((s != (TCAesKeySched_t)0x0) && (k != (uint8_t *)0x0)) { + pbVar2 = k; + ptVar5 = s; + do { + pbVar3 = pbVar2 + 4; + ptVar5->words[0] = + (uint)*pbVar2 << 0x18 | (uint)pbVar2[1] << 0x10 | (uint)pbVar2[3] | (uint)pbVar2[2] << 8; + pbVar2 = pbVar3; + ptVar5 = (TCAesKeySched_t)(ptVar5->words + 1); + } while (k + 0x10 != pbVar3); + uVar4 = 4; + do { + uVar6 = s->words[3]; + if ((uVar4 & 3) == 0) { + uVar6 = *(uint *)((int)&uStack60 + (uVar4 & 0xfffffffc)) ^ + ((uint)sbox[(uVar6 << 8) >> 0x10 & 0xff] << 0x10 | + (uint)sbox[(uVar6 << 8) >> 0x18] << 0x18 | (uint)sbox[uVar6 >> 0x18] | + (uint)sbox[uVar6 & 0xff] << 8); + } + uVar4 = uVar4 + 1; + s->words[4] = uVar6 ^ s->words[0]; + s = (TCAesKeySched_t)(s->words + 1); + } while (uVar4 != 0x2c); + iVar1 = 1; + } + return iVar1; +} + + + +int tc_aes_encrypt(uint8_t *out,uint8_t *in,TCAesKeySched_t s) + +{ + byte *pbVar1; + byte *pbVar2; + byte *out_00; + uint *k; + uint *puVar3; + byte local_40 [4]; + uint8_t state [16]; + uint8_t t [16]; + + if (((out != (uint8_t *)0x0) && (in != (uint8_t *)0x0)) && (s != (TCAesKeySched_t)0x0)) { + _copy(local_40,0x10,in,0x10); + add_round_key(local_40,(uint *)s); + out_00 = state + 0xc; + pbVar1 = local_40; + k = s->words + 4; + do { + do { + pbVar2 = pbVar1 + 1; + *pbVar1 = sbox[*pbVar1]; + pbVar1 = pbVar2; + } while (pbVar2 != out_00); + shift_rows(local_40); + mult_row_column(out_00,local_40); + mult_row_column(t,state); + mult_row_column(t + 4,state + 4); + mult_row_column(t + 8,state + 8); + _copy(local_40,0x10,out_00,0x10); + puVar3 = k + 4; + add_round_key(local_40,k); + pbVar2 = local_40; + pbVar1 = local_40; + k = puVar3; + } while (puVar3 != s->words + 0x28); + do { + pbVar1 = pbVar2 + 1; + *pbVar2 = sbox[*pbVar2]; + pbVar2 = pbVar1; + } while (out_00 != pbVar1); + shift_rows(local_40); + add_round_key(local_40,s->words + 0x28); + _copy(out,0x10,local_40,0x10); + _set(local_40,0,0x10); + return 1; + } + return 0; +} + + + +u8_t att_prepare_write_req(bt_att *att,net_buf *buf) + +{ + return '\x06'; +} + + + +att_type_t att_op_get_type(u8_t op) + +{ + att_type_t aVar1; + undefined3 in_register_00002029; + uint uVar2; + uint uVar3; + + uVar2 = CONCAT31(in_register_00002029,op); + if (uVar2 == 0xe) { +LAB_2302aa56: + aVar1 = ATT_REQUEST; + } + else { + if (uVar2 < 0xf) { + if (uVar2 == 7) { + return ATT_RESPONSE; + } + if (uVar2 < 8) { + if (uVar2 == 3) { + return ATT_RESPONSE; + } + if (3 < uVar2) { + if (uVar2 == 5) { + return ATT_RESPONSE; + } + goto LAB_2302aa56; + } + if (uVar2 == 1) { + return ATT_RESPONSE; + } + if (uVar2 == 2) { + return ATT_REQUEST; + } + } + else { + if (uVar2 == 10) { + return ATT_REQUEST; + } + if (10 < uVar2) { + if (uVar2 == 0xc) { + return ATT_REQUEST; + } + return ATT_RESPONSE; + } + if (uVar2 == 8) { + return ATT_REQUEST; + } + if (uVar2 == 9) { + return ATT_RESPONSE; + } + } + } + else { + if (uVar2 == 0x17) { + return ATT_RESPONSE; + } + if (uVar2 < 0x18) { + if (uVar2 == 0x11) { + return ATT_RESPONSE; + } + if (uVar2 < 0x12) { + if (uVar2 == 0xf) { + return ATT_RESPONSE; + } + if (uVar2 == 0x10) { + return ATT_REQUEST; + } + } + else { + if (uVar2 == 0x13) { + return ATT_RESPONSE; + } + if (uVar2 < 0x13) { + return ATT_REQUEST; + } + if (uVar2 == 0x16) { + return ATT_REQUEST; + } + } + } + else { + if (uVar2 == 0x1d) { + return ATT_INDICATION; + } + if (uVar2 < 0x1e) { + if (uVar2 == 0x19) { + return ATT_RESPONSE; + } + if (uVar2 < 0x19) { + return ATT_REQUEST; + } + uVar3 = 0x1b; + aVar1 = ATT_NOTIFICATION; + } + else { + if (uVar2 == 0x52) { + return ATT_COMMAND; + } + if (uVar2 == 0xd2) { + return ATT_COMMAND; + } + uVar3 = 0x1e; + aVar1 = ATT_CONFIRMATION; + } + if (uVar2 == uVar3) { + return aVar1; + } + } + } + aVar1 = ATT_UNKNOWN; + if ((op & 0x40) != 0) { + return ATT_COMMAND; + } + } + return aVar1; +} + + + +void att_req_destroy(bt_att_req_conflict26 *req) + +{ + if (req->buf != (net_buf *)0x0) { + net_buf_unref(req->buf); + } + if (req->destroy != (bt_att_destroy_t_conflict)0x0) { + (*req->destroy)(req); + } + memset(req,0,0x18); + return; +} + + + +u8_t att_notify(bt_att *att,net_buf *buf) + +{ + bt_conn *conn; + u16_t handle; + + conn = (att->chan).chan.conn; + handle = net_buf_simple_pull_le16((net_buf_simple *)&buf->field_4); + bt_gatt_notification(conn,handle,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4)); + return '\0'; +} + + + +void bt_gatt_foreach_attr + (u16_t start_handle,u16_t end_handle,bt_gatt_attr_func_t *func,void *user_data) + +{ + bt_gatt_foreach_attr_type(start_handle,end_handle,(bt_uuid *)0x0,(void *)0x0,0,func,user_data); + return; +} + + + +u8_t read_group_cb(bt_gatt_attr *attr,void *user_data) + +{ + byte bVar1; + ushort uVar2; + u16_t uVar3; + undefined uVar4; + u8_t uVar5; + int iVar6; + undefined *puVar7; + size_t len; + undefined uVar8; + bt_conn **ppbVar9; + bt_conn *pbVar10; + bt_uuid abStack40 [2]; + undefined2 uStack38; + bt_uuid abStack36 [2]; + undefined2 uStack34; + + ppbVar9 = *(bt_conn ***)user_data; + pbVar10 = *ppbVar9; + abStack40[0] = (bt_uuid)0x0; + uStack38 = 0x2800; + iVar6 = bt_uuid_cmp(attr->uuid,abStack40); + if (iVar6 != 0) { + abStack36[0] = (bt_uuid)0x0; + uStack34 = 0x2801; + iVar6 = bt_uuid_cmp(attr->uuid,abStack36); + if (iVar6 != 0) { + iVar6 = *(int *)((int)user_data + 0x10); + if (iVar6 == 0) { + return '\x01'; + } + uVar2 = attr->handle; + if (uVar2 <= *(ushort *)(iVar6 + 2)) { + return '\x01'; + } + *(undefined *)(iVar6 + 2) = (char)uVar2; + *(undefined *)(iVar6 + 3) = (char)(uVar2 >> 8); + return '\x01'; + } + } + iVar6 = bt_uuid_cmp(attr->uuid,*(bt_uuid **)((int)user_data + 4)); + if (iVar6 == 0) { + if ((**(byte **)((int)user_data + 0xc) == 0) || + ((int)(uint)**(byte **)((int)user_data + 0xc) <= + (int)((uint)*(ushort *)((int)ppbVar9 + 0x56) - + (uint)*(ushort *)(*(int *)((int)user_data + 8) + 0xc)))) { + puVar7 = (undefined *) + net_buf_simple_add((net_buf_simple *)(*(int *)((int)user_data + 8) + 8),4); + *(undefined **)((int)user_data + 0x10) = puVar7; + uVar3 = attr->handle; + uVar4 = (undefined)uVar3; + *puVar7 = uVar4; + uVar8 = (undefined)(uVar3 >> 8); + puVar7[1] = uVar8; + iVar6 = *(int *)((int)user_data + 0x10); + *(undefined *)(iVar6 + 3) = uVar8; + *(undefined *)(iVar6 + 2) = uVar4; + uVar2 = *(ushort *)(*(int *)((int)user_data + 8) + 0xc); + len = (*attr->read)(pbVar10,attr, + (void *)(*(int *)(*(int *)((int)user_data + 8) + 8) + (uint)uVar2), + *(short *)((int)ppbVar9 + 0x56) - uVar2,0); + if (-1 < (int)len) { + bVar1 = **(byte **)((int)user_data + 0xc); + if (bVar1 == 0) { + **(byte **)((int)user_data + 0xc) = (byte)(len + 4); + } + else { + if ((uint)bVar1 != len + 4) { + *(short *)(*(int *)((int)user_data + 8) + 0xc) = + *(short *)(*(int *)((int)user_data + 8) + 0xc) + -4; + goto LAB_2302ac0c; + } + } + net_buf_simple_add((net_buf_simple *)(*(int *)((int)user_data + 8) + 8),len); + goto LAB_2302abf0; + } + } +LAB_2302ac0c: + uVar5 = '\0'; + } + else { + *(undefined4 *)((int)user_data + 0x10) = 0; +LAB_2302abf0: + uVar5 = '\x01'; + } + return uVar5; +} + + + +u8_t read_type_cb(bt_gatt_attr *attr,void *user_data) + +{ + byte bVar1; + u16_t uVar2; + ushort uVar3; + bool bVar4; + char cVar5; + int iVar6; + undefined3 extraout_var; + undefined *puVar7; + size_t len; + bt_conn **ppbVar8; + bt_conn *conn; + + ppbVar8 = *(bt_conn ***)user_data; + conn = *ppbVar8; + bVar4 = true; + iVar6 = bt_uuid_cmp(attr->uuid,*(bt_uuid **)((int)user_data + 4)); + if (iVar6 == 0) { + bVar4 = (bool)bt_gatt_check_perm(conn,attr,'\x15'); + *(bool *)((int)user_data + 0x14) = bVar4; + if (CONCAT31(extraout_var,bVar4) == 0) { + puVar7 = (undefined *) + net_buf_simple_add((net_buf_simple *)(*(int *)((int)user_data + 8) + 8),2); + *(undefined **)((int)user_data + 0x10) = puVar7; + uVar2 = attr->handle; + *puVar7 = (char)uVar2; + puVar7[1] = (char)(uVar2 >> 8); + uVar3 = *(ushort *)(*(int *)((int)user_data + 8) + 0xc); + len = (*attr->read)(conn,attr, + (void *)(*(int *)(*(int *)((int)user_data + 8) + 8) + (uint)uVar3), + *(short *)((int)ppbVar8 + 0x56) - uVar3,0); + if ((int)len < 0) { + cVar5 = '\x0e'; + if (len + 0xff < 0xff) { + cVar5 = -(char)len; + } + *(char *)((int)user_data + 0x14) = cVar5; + } + else { + bVar1 = **(byte **)((int)user_data + 0xc); + if (bVar1 == 0) { + **(byte **)((int)user_data + 0xc) = (byte)(len + 2); + } + else { + if ((uint)bVar1 != len + 2) { + *(short *)(*(int *)((int)user_data + 8) + 0xc) = + *(short *)(*(int *)((int)user_data + 8) + 0xc) + -2; + return bVar4; + } + } + net_buf_simple_add((net_buf_simple *)(*(int *)((int)user_data + 8) + 8),len); + bVar4 = (int)(uint)**(byte **)((int)user_data + 0xc) < + (int)((uint)*(ushort *)((int)ppbVar8 + 0x56) - + (uint)*(ushort *)(*(int *)((int)user_data + 8) + 0xc)); + } + } + else { + bVar4 = (bool)**(char **)((int)user_data + 0xc); + if (bVar4 != false) { + *(undefined *)((int)user_data + 0x14) = 0; + bVar4 = false; + } + } + } + return (u8_t)bVar4; +} + + + +u8_t find_type_cb(bt_gatt_attr *attr,void *user_data) + +{ + byte data_len; + ushort uVar1; + u16_t uVar2; + undefined uVar3; + _Bool _Var4; + int iVar5; + uint uVar6; + undefined3 extraout_var; + char *fmt; + undefined3 extraout_var_00; + undefined *puVar7; + undefined uVar8; + bt_conn **ppbVar9; + bt_conn *pbVar10; + bt_uuid local_60 [2]; + undefined2 uStack94; + bt_uuid abStack92 [2]; + undefined2 uStack90; + u8_t auStack88 [4]; + u8_t uuid [16]; + bt_uuid_128 ref_uuid; + bt_uuid_128 recvd_uuid; + + ppbVar9 = *(bt_conn ***)user_data; + pbVar10 = *ppbVar9; + local_60[0] = (bt_uuid)0x0; + uStack94 = 0x2801; + iVar5 = bt_uuid_cmp(attr->uuid,local_60); + if (iVar5 == 0) goto skip; + abStack92[0] = (bt_uuid)0x0; + uStack90 = 0x2800; + iVar5 = bt_uuid_cmp(attr->uuid,abStack92); + if (iVar5 != 0) { + iVar5 = *(int *)((int)user_data + 8); + if (iVar5 == 0) { + return '\x01'; + } + uVar1 = attr->handle; + if (*(ushort *)(iVar5 + 2) < uVar1) { + *(undefined *)(iVar5 + 2) = (char)uVar1; + *(undefined *)(iVar5 + 3) = (char)(uVar1 >> 8); + return '\x01'; + } + return '\x01'; + } + if ((uint)*(ushort *)((int)ppbVar9 + 0x56) - (uint)*(ushort *)(*(int *)((int)user_data + 4) + 0xc) + < 4) { + return '\0'; + } + uVar6 = (*attr->read)(pbVar10,attr,auStack88,0x10,0); + if ((int)uVar6 < 0) goto skip; + data_len = *(byte *)((int)user_data + 0x10); + if ((uint)data_len == uVar6) { + iVar5 = memcmp(*(u8_t **)((int)user_data + 0xc),auStack88,(uint)data_len); +LAB_2302ae6e: + if (iVar5 == 0) { + *(undefined *)((int)user_data + 0x11) = 0; + puVar7 = (undefined *) + net_buf_simple_add((net_buf_simple *)(*(int *)((int)user_data + 4) + 8),4); + *(undefined **)((int)user_data + 8) = puVar7; + uVar2 = attr->handle; + uVar3 = (undefined)uVar2; + *puVar7 = uVar3; + uVar8 = (undefined)(uVar2 >> 8); + puVar7[1] = uVar8; + iVar5 = *(int *)((int)user_data + 8); + *(undefined *)(iVar5 + 2) = uVar3; + *(undefined *)(iVar5 + 3) = uVar8; + return '\x01'; + } + } + else { + _Var4 = bt_uuid_create((bt_uuid *)(ref_uuid.val + 0xf),*(u8_t **)((int)user_data + 0xc),data_len + ); + if (CONCAT31(extraout_var,_Var4) == 0) { + uVar6 = (uint)*(byte *)((int)user_data + 0x10); + fmt = "Unable to create UUID: size %u\r\n"; + } + else { + _Var4 = bt_uuid_create((bt_uuid *)(uuid + 0xc),auStack88,(u8_t)uVar6); + if (CONCAT31(extraout_var_00,_Var4) != 0) { + iVar5 = bt_uuid_cmp((bt_uuid *)(ref_uuid.val + 0xf),(bt_uuid *)(uuid + 0xc)); + goto LAB_2302ae6e; + } + fmt = "Unable to create UUID: size %d\r\n"; + } + printf(fmt,uVar6); + } +skip: + *(undefined4 *)((int)user_data + 8) = 0; + return '\x01'; +} + + + +u8_t find_info_cb(bt_gatt_attr *attr,void *user_data) + +{ + u16_t uVar1; + undefined2 uVar2; + bool bVar3; + char *pcVar4; + undefined *puVar5; + int iVar6; + int iVar7; + + iVar7 = *(int *)user_data; + if (*(int *)((int)user_data + 8) == 0) { + pcVar4 = (char *)net_buf_simple_add((net_buf_simple *)(*(int *)((int)user_data + 4) + 8),1); + *(char **)((int)user_data + 8) = pcVar4; + *pcVar4 = (attr->uuid->type != '\0') + '\x01'; + } + if (**(char **)((int)user_data + 8) == '\x01') { + if (attr->uuid->type != '\0') { + return '\0'; + } + puVar5 = (undefined *)net_buf_simple_add((net_buf_simple *)(*(int *)((int)user_data + 4) + 8),4) + ; + *(undefined **)((int)user_data + 0xc) = puVar5; + uVar1 = attr->handle; + *puVar5 = (char)uVar1; + puVar5[1] = (char)(uVar1 >> 8); + iVar6 = *(int *)((int)user_data + 0xc); + uVar2 = *(undefined2 *)(attr->uuid + 2); + *(undefined *)(iVar6 + 2) = (char)uVar2; + *(undefined *)(iVar6 + 3) = (char)((ushort)uVar2 >> 8); + bVar3 = (uint)*(ushort *)(iVar7 + 0x56) - (uint)*(ushort *)(*(int *)((int)user_data + 4) + 0xc) + < 5; + } + else { + if (**(char **)((int)user_data + 8) != '\x02') { + return '\0'; + } + if (attr->uuid->type != '\x02') { + return '\0'; + } + puVar5 = (undefined *) + net_buf_simple_add((net_buf_simple *)(*(int *)((int)user_data + 4) + 8),0x12); + *(undefined **)((int)user_data + 0xc) = puVar5; + uVar1 = attr->handle; + *puVar5 = (char)uVar1; + puVar5[1] = (char)(uVar1 >> 8); + memcpy((void *)(*(int *)((int)user_data + 0xc) + 2),attr->uuid + 1,0x10); + bVar3 = (uint)*(ushort *)(iVar7 + 0x56) - (uint)*(ushort *)(*(int *)((int)user_data + 4) + 0xc) + < 0x13; + } + return (u8_t)(bVar3 ^ 1); +} + + + +void bt_att_connected(bt_l2cap_chan *chan) + +{ + k_queue_init((k_queue *)chan[3].rtx_work.work.flags,0x14); + *(undefined2 *)((int)&chan[1].rtx_work.work.handler + 2) = 0x17; + *(undefined2 *)((int)&chan[1].conn + 2) = 0x17; + k_delayed_work_init((k_delayed_work *)&chan[2].rtx_work.timer.args,att_timeout); + chan[2].rtx_work.timer.timer.hdl = (void *)0x0; + chan[2].rtx_work.timer.handler = (k_timer_handler_t *)0x0; + return; +} + + + +bt_conn_tx_cb_t * att_cb(void) + +{ + att_type_t aVar1; + u8_t *in_a0; + uint uVar2; + code *pcVar3; + + aVar1 = att_op_get_type(*in_a0); + uVar2 = (uint)aVar1 - 1 & 0xff; + if (uVar2 < 5) { + pcVar3 = *(code **)(&CSWTCH_31 + uVar2 * 4); + } + else { + pcVar3 = att_pdu_sent; + } + return pcVar3; +} + + + +int att_send(bt_conn *conn,net_buf *buf,bt_conn_tx_cb_t *cb,void *user_data) + +{ + int iVar1; + + if (**(char **)&buf->field_4 == -0x2e) { + iVar1 = bt_smp_sign(conn,buf); + if (iVar1 != 0) { + printf("Error signing data\r\n"); + net_buf_unref(buf); + return iVar1; + } + } + if (cb == (bt_conn_tx_cb_t *)0x0) { + cb = att_cb(); + } + iVar1 = bt_l2cap_send_cb(conn,4,buf,cb,user_data); + return iVar1; +} + + + +int att_send_req(bt_att *att,bt_att_req_conflict26 *req) + +{ + bt_conn *conn; + int iVar1; + size_t sVar2; + net_buf *buf; + bt_conn_tx_cb_t *cb; + net_buf *buf_00; + + att->req = req; + iVar1 = k_sem_take(&att->tx_sem,0); + buf_00 = req->buf; + if (iVar1 < 0) { + k_queue_append((k_queue *)&att->tx_queue,buf_00); + iVar1 = 0; + } + else { + sVar2 = net_buf_simple_headroom((net_buf_simple *)&buf_00->field_4); + (req->state).offset = (u16_t)sVar2; + buf = req->buf; + (req->state).len = *(u16_t *)((int)&buf_00->field_4 + 4); + conn = (att->chan).chan.conn; + buf_00 = net_buf_ref(buf); + cb = att_cb(); + iVar1 = bt_l2cap_send_cb(conn,4,buf_00,cb,(void *)0x0); + if (iVar1 != 0) { + net_buf_unref(req->buf); + req->buf = (net_buf *)0x0; + } + } + return iVar1; +} + + + +u8_t att_handle_rsp(bt_att *att,void *pdu,u16_t len,u8_t err) + +{ + bt_att_req_conflict26 *req; + sys_snode_t *psVar1; + bt_att_func_t *pbVar2; + + k_delayed_work_cancel((k_delayed_work *)&att->timeout_work); + req = att->req; + if (req == (bt_att_req_conflict26 *)0x0) { + printf("No pending ATT request\r\n"); + } + else { + if (req != &cancel) { + if (req->buf != (net_buf *)0x0) { + net_buf_unref(req->buf); + att->req->buf = (net_buf *)0x0; + } + pbVar2 = att->req->func; + att->req->func = (bt_att_func_t *)0x0; + (*pbVar2)((att->chan).chan.conn,err,pdu,len,att->req); + if (att->req->func == (bt_att_func_t *)0x0) { + att_req_destroy(att->req); + } + } + att->req = (bt_att_req_conflict26 *)0x0; + } + req = (bt_att_req_conflict26 *)(att->reqs).head; + if (req != (bt_att_req_conflict26 *)0x0) { + psVar1 = (sys_snode_t *)(req->node).next; + (att->reqs).head = psVar1; + if (req == (bt_att_req_conflict26 *)(att->reqs).tail) { + (att->reqs).tail = psVar1; + } + att_send_req(att,req); + } + return '\0'; +} + + + +u8_t att_handle_find_info_rsp(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_handle_find_type_rsp(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_handle_read_type_rsp(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_handle_read_rsp(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_handle_read_blob_rsp(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_handle_read_mult_rsp(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_handle_read_group_rsp(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_handle_write_rsp(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_handle_prepare_write_rsp(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_handle_exec_write_rsp(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_confirm(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_handle_rsp(att,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4),'\0'); + return uVar1; +} + + + +u8_t att_error_rsp(bt_att *att,net_buf *buf) + +{ + byte bVar1; + u8_t err; + bt_conn *conn; + bt_security_t sec; + int iVar2; + net_buf *pnVar3; + bt_att_req_conflict26 *pbVar4; + + pbVar4 = att->req; + if ((pbVar4 == (bt_att_req_conflict26 *)0x0) || (pbVar4 == &cancel)) { + err = '\x0e'; + goto done; + } + pnVar3 = pbVar4->buf; + iVar2 = *(int *)&buf->field_4; + if (pnVar3 != (net_buf *)0x0) { + *(uint *)&pnVar3->field_4 = *(int *)((int)&pnVar3->field_4 + 8) + (uint)(pbVar4->state).offset; + *(u16_t *)((int)&pnVar3->field_4 + 4) = (pbVar4->state).len; + } + err = *(u8_t *)(iVar2 + 3); + if (att->req->retrying != false) goto done; + conn = (att->chan).chan.conn; + if (err == '\x05') { + bVar1 = conn->sec_level; + if (bVar1 < 2) goto LAB_2302b21e; + if (bVar1 == 2) { + sec = BT_SECURITY_L3; + } + else { + sec = BT_SECURITY_L4; + if (bVar1 != 3) goto done; + } + } + else { + if ((err != '\x0f') || (1 < (byte)conn->sec_level)) goto done; +LAB_2302b21e: + sec = BT_SECURITY_MEDIUM; + } + iVar2 = bt_conn_set_security(conn,sec); + if (iVar2 == 0) { + att->req->retrying = true; + return '\0'; + } +done: + err = att_handle_rsp(att,(void *)0x0,0,err); + return err; +} + + + +int bt_att_accept(bt_conn *conn,bt_l2cap_chan **chan) + +{ + int iVar1; + bt_att *__s; + + if (bt_req_pool[0].chan.chan.conn == (bt_conn *)0x0) { + __s = bt_req_pool; + iVar1 = 0; + } + else { + if (bt_req_pool[1].chan.chan.conn != (bt_conn *)0x0) { + printf("No available ATT context for conn %p\r\n",conn); + return -0xc; + } + __s = bt_req_pool + 1; + iVar1 = 1; + } + memset(__s,0,0xe4); + bt_req_pool[iVar1].chan.chan.ops = (bt_l2cap_chan_ops *)0x4200d538; + k_sem_init(&bt_req_pool[iVar1].tx_sem,10,10); + *(bt_att **)chan = bt_req_pool + iVar1; + return 0; +} + + + +u8_t att_mtu_rsp(bt_att *att,net_buf *buf) + +{ + u8_t err; + ushort *pdu; + u16_t len; + ushort uVar1; + + if (att != (bt_att *)0x0) { + pdu = *(ushort **)&buf->field_4; + uVar1 = *pdu; + if (uVar1 < 0x17) { + err = '\x04'; + len = 0; + pdu = (ushort *)0x0; + } + else { + if (0xf7 < uVar1) { + uVar1 = 0xf7; + } + (att->chan).rx.mtu = uVar1; + (att->chan).tx.mtu = uVar1; + len = *(u16_t *)((int)&buf->field_4 + 4); + err = '\0'; + } + err = att_handle_rsp(att,pdu,len,err); + return err; + } + return '\0'; +} + + + +// WARNING: Type propagation algorithm not settling + +void att_reset(bt_att *att) + +{ + int iVar1; + net_buf *buf; + bt_att_req_conflict26 *req; + bt_att_req_conflict26 *pbVar2; + + while (buf = (net_buf *)k_queue_get((k_queue *)&att->tx_queue,0), buf != (net_buf *)0x0) { + net_buf_unref(buf); + } + atomic_or(att->flags,4); + iVar1 = 10; + do { + iVar1 = iVar1 + -1; + k_sem_give(&att->tx_sem); + } while (iVar1 != 0); + req = (bt_att_req_conflict26 *)(att->reqs).head; + if (req != (bt_att_req_conflict26 *)0x0) { + pbVar2 = *(bt_att_req_conflict26 **)&req->node; + while( true ) { + if (req->func != (bt_att_func_t *)0x0) { + (*req->func)((bt_conn *)0x0,'\x0e',(void *)0x0,0,req); + } + att_req_destroy(req); + if (pbVar2 == (bt_att_req_conflict26 *)0x0) break; + req = pbVar2; + pbVar2 = *(bt_att_req_conflict26 **)&pbVar2->node; + } + } + req = att->req; + (att->reqs).head = (sys_snode_t *)0x0; + (att->reqs).tail = (sys_snode_t *)0x0; + if (req == (bt_att_req_conflict26 *)0x0) { + return; + } + att_handle_rsp(att,(void *)0x0,0,'\x0e'); + return; +} + + + +void bt_att_disconnected(bt_l2cap_chan *chan) + +{ + att_reset((bt_att *)chan); + bt_gatt_disconnected(chan->conn); + if (*(int *)&chan[2].state != 0) { + k_delayed_work_del_timer((k_delayed_work *)&chan[2].rtx_work.timer.args); + } + if (chan[3].rtx_work.work.flags[0] != 0) { + k_queue_free((k_queue *)chan[3].rtx_work.work.flags); + chan[3].rtx_work.work.flags[0] = 0; + } + if (chan[3].destroy != (bt_l2cap_chan_destroy_t *)0x0) { + k_sem_delete((k_sem *)&chan[3].destroy); + return; + } + return; +} + + + +void att_timeout(k_work *work) + +{ + printf("ATT Timeout\r\n"); + att_reset((bt_att *)(work + -0xe)); + bt_gatt_disconnected((bt_conn *)work[-0xe]._reserved); + work[-0xe]._reserved = (void *)0x0; + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void bt_att_encrypt_change(bt_l2cap_chan *chan,u8_t hci_status) + +{ + bt_conn *conn; + atomic_val_t aVar1; + bt_conn_tx_cb_t *cb; + undefined3 in_register_0000202d; + net_buf *buf; + k_work_q *pkVar2; + + if (CONCAT31(in_register_0000202d,hci_status) != 0) { + att_handle_rsp((bt_att *)chan,(void *)0x0,0,'\x05'); + return; + } + conn = chan->conn; + bt_gatt_encrypt_change(conn); + if (((conn->sec_level != BT_SECURITY_LOW) && + (pkVar2 = chan[2].rtx_work.work_q, pkVar2 != (k_work_q *)0x0)) && + (*(char *)&pkVar2[1].fifo._queue.poll_events.field_1 != '\0')) { + k_sem_take((k_sem *)&chan[3].destroy,0xffffffff); + if ((chan->conn->state == BT_CONN_CONNECTED) && + (aVar1 = atomic_get(chan[2].rtx_work.work.flags), (aVar1 >> 2 & 1U) != 0)) { + printf("Disconnected\r\n"); + k_sem_give((k_sem *)&chan[3].destroy); + return; + } + buf = (net_buf *)chan[2].rtx_work.work_q[1].fifo._queue.poll_events.field_0; + cb = att_cb(); + bt_l2cap_send_cb(conn,4,buf,cb,(void *)0x0); + chan[2].rtx_work.work_q[1].fifo._queue.poll_events.field_0 = 0; + } + return; +} + + + +undefined4 att_exec_write_req(void) + +{ + return 6; +} + + + +void att_pdu_sent(bt_conn *conn,void *user_data) + +{ + k_work_q *pkVar1; + bt_l2cap_chan *pbVar2; + net_buf *buf; + size_t sVar3; + int iVar4; + + pbVar2 = bt_l2cap_le_lookup_tx_cid(conn,4); + do { + buf = net_buf_get((k_fifo *)pbVar2[3].rtx_work.work.flags,0); + if (buf == (net_buf *)0x0) { + k_sem_give((k_sem *)&pbVar2[3].destroy); + return; + } + pkVar1 = pbVar2[2].rtx_work.work_q; + if ((pkVar1 != (k_work_q *)0x0) && ((net_buf *)pkVar1[1].fifo._queue.poll_events.field_0 == buf) + ) { + sVar3 = net_buf_simple_headroom((net_buf_simple *)&buf->field_4); + *(short *)&pkVar1[1].fifo._queue.hdl = (short)sVar3; + *(undefined2 *)((int)&pkVar1[1].fifo._queue.hdl + 2) = *(undefined2 *)((int)&buf->field_4 + 4) + ; + } + iVar4 = att_send(conn,buf,(bt_conn_tx_cb_t *)0x0,(void *)0x0); + } while (iVar4 != 0); + return; +} + + + +bt_att * att_chan_get(bt_conn *conn) + +{ + char *fmt; + bt_att *pbVar1; + atomic_val_t aVar2; + + if (conn->state == BT_CONN_CONNECTED) { + pbVar1 = (bt_att *)bt_l2cap_le_lookup_rx_cid(conn,4); + if (pbVar1 == (bt_att *)0x0) { + printf("Unable to find ATT channel\r\n"); + return (bt_att *)0x0; + } + aVar2 = atomic_get(pbVar1->flags); + if ((aVar2 >> 2 & 1U) == 0) { + return pbVar1; + } + fmt = "ATT context flagged as disconnected\r\n"; + } + else { + fmt = "Not connected\r\n"; + } + printf(fmt); + return (bt_att *)0x0; +} + + + +void att_req_sent(bt_conn *conn,void *user_data) + +{ + bt_l2cap_chan *pbVar1; + + pbVar1 = bt_l2cap_le_lookup_tx_cid(conn,4); + if (pbVar1[2].rtx_work.work_q != (k_work_q *)0x0) { + k_delayed_work_submit((k_delayed_work *)&pbVar1[2].rtx_work.timer.args,30000); + } + att_pdu_sent(conn,user_data); + return; +} + + + +void att_cfm_sent(bt_conn *conn,void *user_data) + +{ + bt_l2cap_le_lookup_tx_cid(conn,4); + att_pdu_sent(conn,user_data); + return; +} + + + +void att_rsp_sent(bt_conn *conn,void *user_data) + +{ + bt_l2cap_le_lookup_tx_cid(conn,4); + att_pdu_sent(conn,user_data); + return; +} + + + +u8_t write_cb(bt_gatt_attr *attr,void *user_data) + +{ + u8_t uVar1; + u8_t uVar2; + undefined3 extraout_var; + uint uVar3; + char cVar4; + + uVar2 = bt_gatt_check_perm(*(bt_conn **)user_data,attr,'*'); + *(u8_t *)((int)user_data + 0x14) = uVar2; + uVar1 = '\0'; + if (CONCAT31(extraout_var,uVar2) == 0) { + uVar3 = (*attr->write)(*(bt_conn **)user_data,attr,*(void **)((int)user_data + 0xc), + *(u16_t *)((int)user_data + 0x10),*(u16_t *)((int)user_data + 0x12), + (*(char *)((int)user_data + 8) == '\0') << 1); + if ((int)uVar3 < 0) { + cVar4 = '\x0e'; + if (uVar3 + 0xff < 0xff) { + cVar4 = -(char)uVar3; + } + } + else { + if (uVar3 == (uint)*(ushort *)((int)user_data + 0x10)) { + *(undefined *)((int)user_data + 0x14) = 0; + return '\x01'; + } + cVar4 = '\x0e'; + } + *(char *)((int)user_data + 0x14) = cVar4; + uVar1 = uVar2; + } + return uVar1; +} + + + +u8_t read_cb(bt_gatt_attr *attr,void *user_data) + +{ + ushort uVar1; + u8_t uVar2; + u8_t uVar3; + char cVar4; + void *pvVar5; + undefined3 extraout_var; + size_t len; + bt_conn *conn; + bt_conn **ppbVar6; + + ppbVar6 = *(bt_conn ***)user_data; + conn = *ppbVar6; + pvVar5 = net_buf_simple_add((net_buf_simple *)(*(int *)((int)user_data + 8) + 8),0); + *(void **)((int)user_data + 0xc) = pvVar5; + *(undefined *)((int)user_data + 0x10) = 0; + uVar3 = bt_gatt_check_perm(conn,attr,'\x15'); + *(u8_t *)((int)user_data + 0x10) = uVar3; + uVar2 = '\0'; + if (CONCAT31(extraout_var,uVar3) == 0) { + uVar1 = *(ushort *)(*(int *)((int)user_data + 8) + 0xc); + len = (*attr->read)(conn,attr,(void *)(*(int *)(*(int *)((int)user_data + 8) + 8) + (uint)uVar1) + ,*(short *)((int)ppbVar6 + 0x56) - uVar1,*(u16_t *)((int)user_data + 4)); + if ((int)len < 0) { + cVar4 = '\x0e'; + if (len + 0xff < 0xff) { + cVar4 = -(char)len; + } + *(char *)((int)user_data + 0x10) = cVar4; + uVar2 = uVar3; + } + else { + uVar2 = '\x01'; + net_buf_simple_add((net_buf_simple *)(*(int *)((int)user_data + 8) + 8),len); + } + } + return uVar2; +} + + + +net_buf * bt_att_create_pdu(bt_conn *conn,u8_t op,size_t len) + +{ + att_type_t aVar1; + bt_att *pbVar2; + undefined3 extraout_var; + u8_t *puVar3; + undefined3 in_register_0000202d; + s32_t timeout; + + pbVar2 = att_chan_get(conn); + if (pbVar2 != (bt_att *)0x0) { + if ((uint)(pbVar2->chan).tx.mtu < len + 1) { + printf("ATT MTU exceeded, max %u, wanted %zu\r\n"); + pbVar2 = (bt_att *)0x0; + } + else { + aVar1 = att_op_get_type(op); + if ((CONCAT31(extraout_var,aVar1) == 2) || (timeout = -1, CONCAT31(extraout_var,aVar1) == 4)) + { + timeout = 30000; + } + pbVar2 = (bt_att *)bt_l2cap_create_pdu_timeout((net_buf_pool *)0x0,0,timeout); + if (pbVar2 == (bt_att *)0x0) { + printf("Unable to allocate buffer for op 0x%02x\r\n",CONCAT31(in_register_0000202d,op)); + } + else { + puVar3 = (u8_t *)net_buf_simple_add((net_buf_simple *)&(pbVar2->chan).chan.node,1); + *puVar3 = op; + } + } + } + return (net_buf *)pbVar2; +} + + + +u8_t att_indicate(bt_att *att,net_buf *buf) + +{ + bt_conn *conn; + u16_t handle; + net_buf *buf_00; + + conn = (att->chan).chan.conn; + handle = net_buf_simple_pull_le16((net_buf_simple *)&buf->field_4); + bt_gatt_notification(conn,handle,*(void **)&buf->field_4,*(u16_t *)((int)&buf->field_4 + 4)); + buf_00 = bt_att_create_pdu(conn,'\x1e',0); + if (buf_00 != (net_buf *)0x0) { + bt_l2cap_send_cb(conn,4,buf_00,att_cfm_sent,(void *)0x0); + } + return '\0'; +} + + + +u8_t att_mtu_req(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + net_buf *buf_00; + undefined *puVar2; + ushort uVar3; + bt_conn *conn; + + uVar3 = **(ushort **)&buf->field_4; + if (uVar3 < 0x17) { + uVar1 = '\x04'; + } + else { + conn = (att->chan).chan.conn; + buf_00 = bt_att_create_pdu(conn,'\x03',2); + uVar1 = '\x0e'; + if (buf_00 != (net_buf *)0x0) { + puVar2 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf_00->field_4,2); + *puVar2 = 0xf7; + puVar2[1] = 0; + bt_l2cap_send_cb(conn,4,buf_00,att_rsp_sent,(void *)0x0); + if (0xf7 < uVar3) { + uVar3 = 0xf7; + } + (att->chan).rx.mtu = uVar3; + (att->chan).tx.mtu = uVar3; + uVar1 = '\0'; + } + } + return uVar1; +} + + + +void send_err_rsp(bt_conn *conn,u8_t req,u16_t handle,u8_t err) + +{ + net_buf *buf; + u8_t *puVar1; + + buf = bt_att_create_pdu(conn,'\x01',4); + if (buf != (net_buf *)0x0) { + puVar1 = (u8_t *)net_buf_simple_add((net_buf_simple *)&buf->field_4,4); + puVar1[1] = (u8_t)handle; + *puVar1 = req; + puVar1[2] = (u8_t)(handle >> 8); + puVar1[3] = err; + bt_l2cap_send_cb(conn,4,buf,att_rsp_sent,(void *)0x0); + return; + } + return; +} + + + +int bt_att_recv(bt_l2cap_chan *chan,net_buf *buf) + +{ + att_type_t aVar1; + u8_t err; + byte *pbVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + byte op; + int iVar3; + att_handler_conflict2 *paVar4; + int iVar5; + + if (*(short *)((int)&buf->field_4 + 4) == 0) { + printf("Too small ATT PDU received\r\n"); + } + else { + pbVar2 = (byte *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,1); + paVar4 = handlers; + iVar5 = 0; + do { + if ((uint)paVar4->op == (uint)*pbVar2) { + if ((uint)*(ushort *)((int)&buf->field_4 + 4) < (uint)handlers[iVar5].expect_len) { + printf("Invalid len %u for code 0x%02x\r\n"); + iVar3 = 4; + } + else { + err = (*handlers[iVar5].func)((bt_att *)chan,buf); + iVar3 = CONCAT31(extraout_var_00,err); + } + err = (u8_t)iVar3; + if (handlers[iVar5].type != ATT_REQUEST) { + return 0; + } + if (iVar3 == 0) { + return 0; + } + op = *pbVar2; + if (op == 0) { + return 0; + } + goto LAB_2302b9c2; + } + iVar5 = iVar5 + 1; + paVar4 = paVar4 + 1; + } while (iVar5 != 0x1c); + printf("Unhandled ATT code 0x%02x\r\n",(uint)*pbVar2); + op = *pbVar2; + aVar1 = att_op_get_type(op); + if ((CONCAT31(extraout_var,aVar1) != 0) && (err = '\x06', op != 0)) { +LAB_2302b9c2: + send_err_rsp(chan->conn,op,0,err); + } + } + return 0; +} + + + +u8_t att_read_group_req(bt_att *att,net_buf *buf) + +{ + u16_t end_handle; + u16_t handle; + _Bool _Var1; + u16_t *puVar2; + undefined3 extraout_var; + int iVar3; + net_buf *buf_00; + char *pcVar4; + u8_t data_len; + bt_conn *conn; + bt_uuid abStack80 [2]; + undefined2 uStack78; + bt_uuid abStack76 [2]; + undefined2 uStack74; + bt_uuid abStack72 [4]; + anon_union_for_u u; + read_group_data data; + + data_len = *(char *)((int)&buf->field_4 + 4) + -4; + if ((data_len != '\x02') && (data_len != '\x10')) { + return '\x04'; + } + conn = (att->chan).chan.conn; + puVar2 = (u16_t *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,4); + handle = *puVar2; + end_handle = puVar2[1]; + _Var1 = bt_uuid_create(abStack72,(u8_t *)(puVar2 + 2),data_len); + if (CONCAT31(extraout_var,_Var1) == 0) { + return '\x0e'; + } + if (handle != 0) { + if (end_handle == 0) { + handle = 0; + } + else { + if (handle <= end_handle) { + abStack80[0] = (bt_uuid)0x0; + uStack78 = 0x2800; + iVar3 = bt_uuid_cmp(abStack72,abStack80); + if (iVar3 == 0) { +LAB_2302ba66: + conn = (att->chan).chan.conn; + memset(u + 0x10,0,0x14); + buf_00 = bt_att_create_pdu(conn,'\x11',1); + if (buf_00 == (net_buf *)0x0) { + return '\x0e'; + } + unique0x10000076 = att; + pcVar4 = (char *)net_buf_simple_add((net_buf_simple *)&buf_00->field_4,1); + *pcVar4 = '\0'; + bt_gatt_foreach_attr(handle,end_handle,read_group_cb,u + 0x10); + if (*pcVar4 != '\0') { + bt_l2cap_send_cb(conn,4,buf_00,att_rsp_sent,(void *)0x0); + return '\0'; + } + net_buf_unref(buf_00); + send_err_rsp(conn,'\x10',handle,'\n'); + return '\0'; + } + abStack76[0] = (bt_uuid)0x0; + uStack74 = 0x2801; + iVar3 = bt_uuid_cmp(abStack72,abStack76); + if (iVar3 == 0) goto LAB_2302ba66; + data_len = '\x10'; + goto LAB_2302bade; + } + } + } + data_len = '\x01'; +LAB_2302bade: + send_err_rsp(conn,'\x10',handle,data_len); + return '\0'; +} + + + +// WARNING: Could not reconcile some variable overlaps + +u8_t att_read_mult_req(bt_att *att,net_buf *buf) + +{ + bt_conn *conn; + u8_t uVar1; + u16_t start_handle; + bt_att *pbStack52; + read_data data; + + conn = (att->chan).chan.conn; + memset(&pbStack52,0,0x14); + data._4_4_ = bt_att_create_pdu(conn,'\x0f',0); + if (data._4_4_ == (net_buf *)0x0) { + uVar1 = '\x0e'; + } + else { + pbStack52 = att; + do { + if (*(ushort *)((int)&buf->field_4 + 4) < 2) { + bt_l2cap_send_cb(conn,4,data._4_4_,att_rsp_sent,(void *)0x0); + goto LAB_2302bba4; + } + start_handle = net_buf_simple_pull_le16((net_buf_simple *)&buf->field_4); + data.rsp._0_1_ = '\x01'; + bt_gatt_foreach_attr(start_handle,start_handle,read_cb,&pbStack52); + } while ((u8_t)data.rsp == '\0'); + net_buf_unref(data._4_4_); + send_err_rsp(conn,'\x0e',start_handle,(u8_t)data.rsp); +LAB_2302bba4: + uVar1 = '\0'; + } + return uVar1; +} + + + +// WARNING: Variable defined which should be unmapped: data +// WARNING: Could not reconcile some variable overlaps + +u8_t att_read_rsp(bt_att *att,u8_t op,u8_t rsp,u16_t handle,u16_t offset) + +{ + u8_t uVar1; + bt_conn *conn; + _Bool _Var2; + undefined3 extraout_var; + undefined2 in_register_00002036; + bt_att *pbStack52; + read_data data; + + conn = (att->chan).chan.conn; + _Var2 = bt_gatt_change_aware(conn,true); + uVar1 = '\x12'; + if ((CONCAT31(extraout_var,_Var2) != 0) && + (uVar1 = '\x01', CONCAT22(in_register_00002036,handle) != 0)) { + memset(&pbStack52,0,0x14); + data._4_4_ = bt_att_create_pdu(conn,rsp,0); + if (data._4_4_ == (net_buf *)0x0) { + uVar1 = '\x0e'; + } + else { + data.rsp._0_1_ = '\x01'; + pbStack52 = att; + data.att._0_2_ = offset; + bt_gatt_foreach_attr(handle,handle,read_cb,&pbStack52); + uVar1 = (u8_t)data.rsp; + if ((u8_t)data.rsp == '\0') { + bt_l2cap_send_cb(conn,4,data._4_4_,att_rsp_sent,(void *)0x0); + } + else { + net_buf_unref(data._4_4_); + send_err_rsp(conn,op,handle,(u8_t)data.rsp); + uVar1 = '\0'; + } + } + } + return uVar1; +} + + + +u8_t att_read_blob_req(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_read_rsp(att,'\f','\r',**(u16_t **)&buf->field_4,(*(u16_t **)&buf->field_4)[1]); + return uVar1; +} + + + +u8_t att_read_req(bt_att *att,net_buf *buf) + +{ + u8_t uVar1; + + uVar1 = att_read_rsp(att,'\n','\v',**(u16_t **)&buf->field_4,0); + return uVar1; +} + + + +// WARNING: Removing unreachable block (ram,0x2302bd9a) +// WARNING: Could not reconcile some variable overlaps + +u8_t att_read_type_req(bt_att *att,net_buf *buf) + +{ + u16_t end_handle; + u16_t start_handle; + _Bool _Var1; + u16_t *puVar2; + undefined3 extraout_var; + net_buf *buf_00; + undefined *puVar3; + u8_t data_len; + bt_conn *conn; + bt_uuid abStack76 [4]; + anon_union_for_u u; + read_type_data data; + + data_len = *(char *)((int)&buf->field_4 + 4) + -4; + if ((data_len != '\x02') && (data_len != '\x10')) { + return '\x04'; + } + conn = (att->chan).chan.conn; + puVar2 = (u16_t *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,4); + start_handle = *puVar2; + end_handle = puVar2[1]; + _Var1 = bt_uuid_create(abStack76,(u8_t *)(puVar2 + 2),data_len); + if (CONCAT31(extraout_var,_Var1) == 0) { + return '\x0e'; + } + if (start_handle != 0) { + if (end_handle == 0) { + start_handle = 0; + } + else { + if (start_handle <= end_handle) { + conn = (att->chan).chan.conn; + memset(u + 0x10,0,0x18); + buf_00 = bt_att_create_pdu(conn,'\t',1); + if (buf_00 == (net_buf *)0x0) { + return '\x0e'; + } + unique0x10000060 = att; + puVar3 = (undefined *)net_buf_simple_add((net_buf_simple *)&buf_00->field_4,1); + *puVar3 = 0; + data.item._0_1_ = '\n'; + bt_gatt_foreach_attr(start_handle,end_handle,read_type_cb,u + 0x10); + net_buf_unref(buf_00); + goto LAB_2302bd4e; + } + } + } + data.item._0_1_ = '\x01'; +LAB_2302bd4e: + send_err_rsp(conn,'\b',start_handle,(u8_t)data.item); + return '\0'; +} + + + +// WARNING: Variable defined which should be unmapped: data +// WARNING: Could not reconcile some variable overlaps + +u8_t att_find_type_req(bt_att *att,net_buf *buf) + +{ + u16_t end_handle; + u16_t *puVar1; + int iVar2; + u16_t start_handle; + u8_t err; + bt_conn *conn; + bt_att_handle_group *pbVar3; + bt_uuid abStack60 [2]; + u16_t uStack58; + bt_uuid abStack56 [2]; + undefined2 uStack54; + bt_att *pbStack52; + find_type_data data; + + conn = (att->chan).chan.conn; + puVar1 = (u16_t *)net_buf_simple_pull_mem((net_buf_simple *)&buf->field_4,6); + start_handle = *puVar1; + if (start_handle != 0) { + end_handle = puVar1[1]; + if (end_handle == 0) { + start_handle = 0; + } + else { + if (start_handle <= end_handle) { + uStack58 = puVar1[2]; + pbVar3 = *(bt_att_handle_group **)&buf->field_4; + abStack60[0] = (bt_uuid)0x0; + abStack56[0] = (bt_uuid)0x0; + uStack54 = 0x2800; + iVar2 = bt_uuid_cmp(abStack60,abStack56); + if (iVar2 == 0) { + data.value._0_1_ = *(undefined *)((int)&buf->field_4 + 4); + conn = (att->chan).chan.conn; + memset(&pbStack52,0,0x14); + data.att = (bt_att *)bt_att_create_pdu(conn,'\a',0); + if (data.att == (bt_att *)0x0) { + return '\x0e'; + } + data.buf = (net_buf *)0x0; + data.value._1_1_ = '\n'; + pbStack52 = att; + data.group = pbVar3; + bt_gatt_foreach_attr(start_handle,end_handle,find_type_cb,&pbStack52); + if (data.value._1_1_ == '\0') { + bt_l2cap_send_cb(conn,4,(net_buf *)data.att,att_rsp_sent,(void *)0x0); + return '\0'; + } + net_buf_unref((net_buf *)data.att); + err = data.value._1_1_; + } + else { + err = '\n'; + } + goto LAB_2302be30; + } + } + } + err = '\x01'; +LAB_2302be30: + send_err_rsp(conn,'\x06',start_handle,err); + return '\0'; +} + + + +u8_t att_find_info_req(bt_att *att,net_buf *buf) + +{ + u16_t end_handle; + u16_t start_handle; + u8_t err; + bt_conn *conn; + bt_att *local_30; + find_info_data data; + + conn = (att->chan).chan.conn; + start_handle = **(u16_t **)&buf->field_4; + if (start_handle != 0) { + end_handle = (*(u16_t **)&buf->field_4)[1]; + if (end_handle == 0) { + start_handle = 0; + } + else { + if (start_handle <= end_handle) { + memset(&local_30,0,0x10); + data.att = (bt_att *)bt_att_create_pdu(conn,'\x05',0); + if (data.att == (bt_att *)0x0) { + return '\x0e'; + } + local_30 = att; + bt_gatt_foreach_attr(start_handle,end_handle,find_info_cb,&local_30); + if (data.buf != (net_buf *)0x0) { + bt_l2cap_send_cb(conn,4,(net_buf *)data.att,att_rsp_sent,(void *)0x0); + return '\0'; + } + net_buf_unref((net_buf *)data.att); + err = '\n'; + goto LAB_2302bf22; + } + } + } + err = '\x01'; +LAB_2302bf22: + send_err_rsp(conn,'\x04',start_handle,err); + return '\0'; +} + + + +// WARNING: Variable defined which should be unmapped: data +// WARNING: Could not reconcile some variable overlaps + +u8_t att_write_rsp(bt_conn *conn,u8_t req,u8_t rsp,u16_t handle,void *value,u16_t len) + +{ + u8_t uVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + undefined2 in_register_00002036; + bt_conn *pbStack56; + write_data_conflict data; + + _Var2 = bt_gatt_change_aware(conn,(_Bool)(CONCAT31(in_register_0000202d,req) != 0)); + uVar1 = '\x12'; + if ((CONCAT31(extraout_var,_Var2) != 0) && + (uVar1 = '\x01', CONCAT22(in_register_00002036,handle) != 0)) { + memset(&pbStack56,0,0x18); + if ((CONCAT31(in_register_00002031,rsp) != 0) && + (data.conn = (bt_conn *)bt_att_create_pdu(conn,rsp,0), data.conn == (bt_conn *)0x0)) { + return '\x0e'; + } + data.value._2_2_ = 0; + data.len._0_1_ = '\x01'; + pbStack56 = conn; + data.buf._0_1_ = req; + data._8_4_ = value; + data.value._0_2_ = len; + bt_gatt_foreach_attr(handle,handle,write_cb,&pbStack56); + if ((u8_t)data.len == '\0') { + if (data.conn != (bt_conn *)0x0) { + bt_l2cap_send_cb(conn,4,(net_buf *)data.conn,att_rsp_sent,(void *)0x0); + return '\0'; + } + } + else { + if ((CONCAT31(in_register_00002031,rsp) != 0) && + (net_buf_unref((net_buf *)data.conn), CONCAT31(in_register_0000202d,req) != 0)) { + send_err_rsp(conn,req,handle,(u8_t)data.len); + } + } + uVar1 = '\0'; + } + return uVar1; +} + + + +u8_t att_write_req(bt_att *att,net_buf *buf) + +{ + bt_conn *conn; + u8_t uVar1; + u16_t handle; + + conn = (att->chan).chan.conn; + handle = net_buf_simple_pull_le16((net_buf_simple *)&buf->field_4); + uVar1 = att_write_rsp(conn,'\x12','\x13',handle,*(void **)&buf->field_4, + *(u16_t *)((int)&buf->field_4 + 4)); + return uVar1; +} + + + +u8_t att_write_cmd(bt_att *att,net_buf *buf) + +{ + bt_conn *conn; + u8_t uVar1; + u16_t handle; + + conn = (att->chan).chan.conn; + handle = net_buf_simple_pull_le16((net_buf_simple *)&buf->field_4); + uVar1 = att_write_rsp(conn,'\0','\0',handle,*(void **)&buf->field_4, + *(u16_t *)((int)&buf->field_4 + 4)); + return uVar1; +} + + + +u8_t att_signed_write_cmd(bt_att *att,net_buf *buf) + +{ + u16_t handle; + u8_t uVar1; + int iVar2; + net_buf_simple *buf_00; + bt_conn *conn; + + conn = (att->chan).chan.conn; + buf_00 = (net_buf_simple *)&buf->field_4; + handle = **(u16_t **)&buf->field_4; + net_buf_simple_push(buf_00,1); + iVar2 = bt_smp_sign_verify(conn,buf); + if (iVar2 == 0) { + net_buf_simple_pull(buf_00,1); + net_buf_simple_pull(buf_00,2); + uVar1 = att_write_rsp(conn,'\0','\0',handle,*(void **)&buf->field_4, + (u16_t)(((uint)*(ushort *)((int)&buf->field_4 + 4) - 0xc) * 0x10000 >> + 0x10)); + return uVar1; + } + printf("Error verifying data\r\n"); + return '\0'; +} + + + +void bt_att_init(void) + +{ + anon_subr_int_bt_conn_ptr_bt_l2cap_chan_ptr_ptr_for_accept **ppaVar1; + bool bVar2; + int iVar3; + uint uVar4; + bt_gatt_service_static *pbVar5; + + iVar3 = atomic_cas(&init,0,1); + if (iVar3 != 0) { + uVar4 = (uint)last_static_handle; + bVar2 = false; + pbVar5 = &_1_gatt_svc; + while (pbVar5 < &att_fixed_chan) { + ppaVar1 = &((bt_l2cap_fixed_chan *)pbVar5)->accept; + pbVar5 = (bt_gatt_service_static *)&((bt_l2cap_fixed_chan *)pbVar5)->node; + uVar4 = (uint)(*ppaVar1 + uVar4) & 0xffff; + bVar2 = true; + } + if (bVar2) { + last_static_handle = (u16_t)uVar4; + } + k_delayed_work_init((k_delayed_work *)&gatt_sc.work,sc_process); + return; + } + return; +} + + + +u16_t bt_att_get_mtu(bt_conn *conn) + +{ + u16_t uVar1; + bt_att *pbVar2; + + pbVar2 = att_chan_get(conn); + if (pbVar2 == (bt_att *)0x0) { + uVar1 = 0; + } + else { + uVar1 = (pbVar2->chan).tx.mtu; + } + return uVar1; +} + + + +int bt_att_send(bt_conn *conn,net_buf *buf,bt_conn_tx_cb_t *cb,void *user_data) + +{ + int iVar1; + bt_att *pbVar2; + + pbVar2 = att_chan_get(conn); + if (pbVar2 == (bt_att *)0x0) { + net_buf_unref(buf); + iVar1 = -0x39; + } + else { + if ((cb == (bt_conn_tx_cb_t *)0x0) && (iVar1 = k_sem_take(&pbVar2->tx_sem,0), iVar1 < 0)) { + k_queue_append((k_queue *)&pbVar2->tx_queue,buf); + return 0; + } + iVar1 = att_send(conn,buf,cb,user_data); + if ((iVar1 != 0) && (cb == (bt_conn_tx_cb_t *)0x0)) { + k_sem_give(&pbVar2->tx_sem); + } + } + return iVar1; +} + + + +int bt_att_req_send(bt_conn *conn,bt_att_req_conflict26 *req) + +{ + bt_att *att; + int iVar1; + sys_snode_t *psVar2; + + att = att_chan_get(conn); + if (att == (bt_att *)0x0) { + net_buf_unref(req->buf); + iVar1 = -0x39; + req->buf = (net_buf *)0x0; + } + else { + if (att->req == (bt_att_req_conflict26 *)0x0) { + iVar1 = att_send_req(att,req); + return iVar1; + } + (req->node).next = (_snode *)0x0; + psVar2 = (att->reqs).tail; + if (psVar2 == (sys_snode_t *)0x0) { + *(bt_att_req_conflict26 **)&(att->reqs).tail = req; + *(bt_att_req_conflict26 **)&(att->reqs).head = req; + } + else { + *(bt_att_req_conflict26 **)&psVar2->next = req; + *(bt_att_req_conflict26 **)&(att->reqs).tail = req; + } + iVar1 = 0; + } + return iVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +void bt_att_req_cancel(bt_conn *param_1,sys_snode_t param_2) + +{ + bt_att *pbVar1; + sys_snode_t sVar2; + sys_snode_t sVar3; + + if ((param_1 == (bt_conn *)0x0) || (param_2 == (sys_snode_t)0x0)) { + return; + } + pbVar1 = att_chan_get(param_1); + if (pbVar1 == (bt_att *)0x0) { + return; + } + if ((sys_snode_t)((sys_snode_t *)&pbVar1->req)->next == param_2) { + pbVar1->req = &cancel; + } + else { + sVar2 = (sys_snode_t)0x0; + sVar3 = (sys_snode_t)(pbVar1->reqs).head; + while (sVar3 != (sys_snode_t)0x0) { + if (param_2 == sVar3) { + sVar3 = *(sys_snode_t *)param_2; + if (sVar2 == (sys_snode_t)0x0) { + sVar2 = (sys_snode_t)((sys_snode_t *)&(pbVar1->reqs).tail)->next; + *(sys_snode_t *)&(pbVar1->reqs).head = sVar3; + if (param_2 == sVar2) { + *(sys_snode_t *)&((sys_snode_t *)&(pbVar1->reqs).tail)->next = sVar3; + } + } + else { + *(sys_snode_t *)sVar2 = sVar3; + if (param_2 == (sys_snode_t)((sys_snode_t *)&(pbVar1->reqs).tail)->next) { + *(sys_snode_t *)&((sys_snode_t *)&(pbVar1->reqs).tail)->next = sVar2; + } + } + *(undefined4 *)param_2 = 0; + break; + } + sVar2 = sVar3; + sVar3 = *(sys_snode_t *)sVar3; + } + } + att_req_destroy((bt_att_req_conflict26 *)param_2); + return; +} + + + +uint32_t fdt32_ld(fdt32_t *p) + +{ + return (uint)*(byte *)((int)p + 2) << 8 | + (uint)*(byte *)p << 0x18 | (uint)*(byte *)((int)p + 1) << 0x10 | + (uint)*(byte *)((int)p + 3); +} + + + +int nextprop_(void *fdt,int offset) + +{ + uint32_t uVar1; + int iStack36; + int nextoffset; + + while( true ) { + uVar1 = fdt_next_tag(fdt,offset,&iStack36); + if (uVar1 == 3) { + return offset; + } + if (uVar1 == 9) break; + offset = iStack36; + if (uVar1 != 4) { + return -1; + } + } + if (iStack36 < 0) { + return iStack36; + } + return -0xb; +} + + + +fdt_property * fdt_get_property_by_offset_(void *fdt,int offset,int *lenp) + +{ + fdt_property *pfVar1; + uint32_t uVar2; + + uVar2 = fdt_check_prop_offset_(fdt,offset); + if ((int)uVar2 < 0) { + pfVar1 = (fdt_property *)0x0; + if (lenp == (int *)0x0) { + return (fdt_property *)0x0; + } + } + else { + uVar2 = fdt32_ld((fdt32_t *)((int)fdt + 8)); + pfVar1 = (fdt_property *)((int)fdt + uVar2 + offset); + if (lenp == (int *)0x0) { + return pfVar1; + } + uVar2 = fdt32_ld(&pfVar1->len); + } + *lenp = uVar2; + return pfVar1; +} + + + +char * fdt_get_string(void *fdt,int stroffset,int *lenp) + +{ + char *__s; + uint32_t uVar1; + void *pvVar2; + uint __n; + uint uVar3; + + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0xc)); + pvVar2 = (void *)fdt_ro_probe_(fdt); + if (pvVar2 == (void *)0x0) { + uVar3 = uVar1 + stroffset; + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 4)); + if (uVar3 < uVar1) { + __n = uVar1 - uVar3; + uVar1 = fdt32_ld((fdt32_t *)fdt); + if (uVar1 == 0xd00dfeed) { + if (-1 < stroffset) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x14)); + if (0x10 < uVar1) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x20)); + if (uVar1 <= (uint)stroffset) goto LAB_2302c3e4; + if (uVar1 - stroffset < __n) { + __n = uVar1 - stroffset; + } + } +LAB_2302c384: + __s = (char *)((int)fdt + uVar3); + pvVar2 = memchr(__s,0,__n); + if (pvVar2 != (void *)0x0) { + pvVar2 = (void *)((int)pvVar2 - (int)__s); + goto joined_r0x2302c3da; + } + pvVar2 = (void *)0xfffffff8; + goto fail; + } + } + else { + if (uVar1 != 0x2ff20112) { + pvVar2 = (void *)0xfffffff3; + goto fail; + } + if ((stroffset < 0) && + (uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x20)), -uVar1 <= (uint)stroffset)) { + if ((uint)-stroffset < __n) { + __n = -stroffset; + } + goto LAB_2302c384; + } + } + } +LAB_2302c3e4: + pvVar2 = (void *)0xfffffffc; + } +fail: + __s = (char *)0x0; +joined_r0x2302c3da: + if (lenp != (int *)0x0) { + *(void **)lenp = pvVar2; + } + return __s; +} + + + +char * fdt_get_name(void *fdt,int nodeoffset,int *len) + +{ + uint32_t uVar1; + size_t sVar2; + uint32_t uVar3; + char *__s; + + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 8)); + sVar2 = fdt_ro_probe_(fdt); + if ((sVar2 == 0) && (sVar2 = fdt_check_node_offset_(fdt,nodeoffset), -1 < (int)sVar2)) { + uVar3 = fdt32_ld((fdt32_t *)((int)fdt + 0x14)); + __s = (char *)((int)fdt + nodeoffset + uVar1 + 4); + if (uVar3 < 0x10) { + __s = strrchr(__s,0x2f); + if (__s == (char *)0x0) { + sVar2 = 0xfffffff5; + goto fail; + } + __s = __s + 1; + } + if (len == (int *)0x0) { + return __s; + } + sVar2 = strlen(__s); + } + else { +fail: + __s = (char *)0x0; + if (len == (int *)0x0) { + return (char *)0x0; + } + } + *len = sVar2; + return __s; +} + + + +int fdt_subnode_offset_namelen(void *fdt,int offset,char *name,int namelen) + +{ + int iVar1; + char *__s1; + void *pvVar2; + int iStack40; + int depth; + int olen; + + iVar1 = fdt_ro_probe_(fdt); + if (iVar1 == 0) { + iStack40 = 0; + while (-1 < offset) { + if (iStack40 < 0) goto LAB_2302c492; + if ((((iStack40 == 1) && (__s1 = fdt_get_name(fdt,offset,&depth), __s1 != (char *)0x0)) && + (namelen <= depth)) && (iVar1 = memcmp(__s1,name,namelen), iVar1 == 0)) { + if (__s1[namelen] == '\0') { + return offset; + } + pvVar2 = memchr(name,0x40,namelen); + if ((pvVar2 == (void *)0x0) && (__s1[namelen] == '@')) { + return offset; + } + } + offset = fdt_next_node(fdt,offset,&iStack40); + } + iVar1 = offset; + if (iStack40 < 0) { +LAB_2302c492: + iVar1 = -1; + } + } + return iVar1; +} + + + +int fdt_subnode_offset(void *fdt,int parentoffset,char *name) + +{ + size_t namelen; + int iVar1; + + namelen = strlen(name); + iVar1 = fdt_subnode_offset_namelen(fdt,parentoffset,name,namelen); + return iVar1; +} + + + +int fdt_first_property_offset(void *fdt,int nodeoffset) + +{ + int offset; + + offset = fdt_check_node_offset_(fdt,nodeoffset); + if (-1 < offset) { + offset = nextprop_(fdt,offset); + return offset; + } + return offset; +} + + + +int fdt_next_property_offset(void *fdt,int offset) + +{ + int offset_00; + + offset_00 = fdt_check_prop_offset_(fdt,offset); + if (-1 < offset_00) { + offset_00 = nextprop_(fdt,offset_00); + return offset_00; + } + return offset_00; +} + + + +// WARNING: Variable defined which should be unmapped: slen + +fdt_property * +fdt_get_property_namelen_(void *fdt,int offset,char *name,int namelen,int *lenp,int *poffset) + +{ + int offset_00; + fdt_property *pfVar1; + uint32_t stroffset; + char *__s1; + int iVar2; + int iStack36; + int slen; + + offset_00 = fdt_first_property_offset(fdt,offset); + do { + if (offset_00 < 0) { +LAB_2302c590: + if (lenp != (int *)0x0) { + *lenp = offset_00; + } + return (fdt_property *)0x0; + } + pfVar1 = fdt_get_property_by_offset_(fdt,offset_00,lenp); + if (pfVar1 == (fdt_property *)0x0) { + offset_00 = -0xd; + goto LAB_2302c590; + } + stroffset = fdt32_ld(&pfVar1->nameoff); + __s1 = fdt_get_string(fdt,stroffset,&iStack36); + if (((__s1 != (char *)0x0) && (namelen == iStack36)) && + (iVar2 = memcmp(__s1,name,namelen), iVar2 == 0)) { + if (poffset == (int *)0x0) { + return pfVar1; + } + *poffset = offset_00; + return pfVar1; + } + offset_00 = fdt_next_property_offset(fdt,offset_00); + } while( true ); +} + + + +void * fdt_getprop_namelen(void *fdt,int nodeoffset,char *name,int namelen,int *lenp) + +{ + fdt_property *pfVar1; + uint32_t uVar2; + int iStack20; + int poffset; + + pfVar1 = fdt_get_property_namelen_(fdt,nodeoffset,name,namelen,lenp,&iStack20); + if (pfVar1 != (fdt_property *)0x0) { + uVar2 = fdt32_ld((fdt32_t *)((int)fdt + 0x14)); + if (((uVar2 < 0x10) && ((iStack20 + 0xcU & 7) != 0)) && + (uVar2 = fdt32_ld(&pfVar1->len), 7 < uVar2)) { + pfVar1 = (fdt_property *)&pfVar1[1].len; + } + else { + pfVar1 = pfVar1 + 1; + } + } + return pfVar1; +} + + + +void * fdt_getprop(void *fdt,int nodeoffset,char *name,int *lenp) + +{ + size_t namelen; + void *pvVar1; + + namelen = strlen(name); + pvVar1 = fdt_getprop_namelen(fdt,nodeoffset,name,namelen,lenp); + return pvVar1; +} + + + +// WARNING: Variable defined which should be unmapped: length + +int fdt_stringlist_count(void *fdt,int nodeoffset,char *property) + +{ + int iVar1; + char *__string; + size_t sVar2; + char *pcVar3; + int iStack20; + int length; + + __string = (char *)fdt_getprop(fdt,nodeoffset,property,&iStack20); + iVar1 = iStack20; + if (__string != (char *)0x0) { + pcVar3 = __string + iStack20; + iVar1 = 0; + while (__string < pcVar3) { + sVar2 = strnlen(__string,(size_t)(pcVar3 + -(int)__string)); + iStack20 = sVar2 + 1; + __string = __string + iStack20; + if (pcVar3 < __string) { + return -0xf; + } + iVar1 = iVar1 + 1; + } + } + return iVar1; +} + + + +char * fdt_stringlist_get(void *fdt,int nodeoffset,char *property,int idx,int *lenp) + +{ + char *__string; + size_t sVar1; + int iVar2; + char *pcVar3; + int iStack36; + int length; + + __string = (char *)fdt_getprop(fdt,nodeoffset,property,&iStack36); + if (__string == (char *)0x0) { + if (lenp != (int *)0x0) { + *lenp = iStack36; + return (char *)0x0; + } + } + else { + pcVar3 = __string + iStack36; + while (__string < pcVar3) { + sVar1 = strnlen(__string,(size_t)(pcVar3 + -(int)__string)); + iStack36 = sVar1 + 1; + if (pcVar3 < __string + iStack36) { + iVar2 = -0xf; + if (lenp == (int *)0x0) { + return (char *)0x0; + } + goto LAB_2302c710; + } + if (idx == 0) { + if (lenp != (int *)0x0) { + *lenp = sVar1; + return __string; + } + return __string; + } + idx = idx + -1; + __string = __string + iStack36; + } + if (lenp != (int *)0x0) { + iVar2 = -1; +LAB_2302c710: + *lenp = iVar2; + } + } + return (char *)0x0; +} + + + +uint32_t fdt32_ld(fdt32_t *p) + +{ + return (uint)*(byte *)((int)p + 2) << 8 | + (uint)*(byte *)p << 0x18 | (uint)*(byte *)((int)p + 1) << 0x10 | + (uint)*(byte *)((int)p + 3); +} + + + +int fdt_ro_probe_(void *fdt) + +{ + uint32_t uVar1; + int iVar2; + + uVar1 = fdt32_ld((fdt32_t *)fdt); + if (uVar1 == 0xd00dfeed) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x14)); + iVar2 = -10; + if (1 < uVar1) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x18)); + iVar2 = 0; + if (0x11 < uVar1) { + iVar2 = -10; + } + } + } + else { + iVar2 = -9; + if (uVar1 == 0x2ff20112) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x24)); + iVar2 = 0; + if (uVar1 == 0) { + iVar2 = -7; + } + } + } + return iVar2; +} + + + +void * fdt_offset_ptr(void *fdt,int offset,uint len) + +{ + uint32_t uVar1; + void *pvVar2; + uint uVar3; + + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 8)); + uVar3 = uVar1 + offset; + pvVar2 = (void *)0x0; + if ((uint)offset <= uVar3) { + pvVar2 = (void *)0x0; + if (uVar3 <= uVar3 + len) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 4)); + pvVar2 = (void *)0x0; + if (uVar3 + len <= uVar1) { + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x14)); + if (0x10 < uVar1) { + if (len + offset < (uint)offset) { + return (void *)0x0; + } + uVar1 = fdt32_ld((fdt32_t *)((int)fdt + 0x24)); + if (uVar1 < len + offset) { + return (void *)0x0; + } + } + pvVar2 = (void *)((int)fdt + uVar3); + } + } + } + return pvVar2; +} + + + +uint32_t fdt_next_tag(void *fdt,int startoffset,int *nextoffset) + +{ + int offset; + int offset_00; + uint *puVar1; + char *pcVar2; + void *pvVar3; + uint32_t uVar4; + uint uVar5; + uint uVar6; + + *nextoffset = -8; + puVar1 = (uint *)fdt_offset_ptr(fdt,startoffset,4); + if (puVar1 != (uint *)0x0) { + uVar5 = *puVar1; + offset = startoffset + 4; + uVar5 = uVar5 << 0x18 | uVar5 >> 0x18 | (uVar5 >> 8 & 0xff) << 0x10 | + (uVar5 >> 0x10 & 0xff) << 8; + *nextoffset = -0xb; + offset_00 = offset; + switch(uVar5) { + case 1: + do { + offset = offset_00 + 1; + pcVar2 = (char *)fdt_offset_ptr(fdt,offset_00,1); + if (pcVar2 == (char *)0x0) { + return 9; + } + offset_00 = offset; + } while (*pcVar2 != '\0'); + break; + case 2: + case 4: + case 9: + break; + case 3: + puVar1 = (uint *)fdt_offset_ptr(fdt,offset,4); + if (puVar1 == (uint *)0x0) { + return 9; + } + uVar6 = *puVar1; + uVar6 = uVar6 << 0x18 | uVar6 >> 0x18 | (uVar6 >> 8 & 0xff) << 0x10 | + (uVar6 >> 0x10 & 0xff) << 8; + uVar4 = fdt32_ld((fdt32_t *)((int)fdt + 0x14)); + offset = startoffset + 0xcU + uVar6; + if (((uVar4 < 0x10) && (7 < uVar6)) && ((startoffset + 0xcU & 7) != 0)) { + offset = offset + 4; + } + break; + default: + goto LAB_2302c8b6; + } + pvVar3 = fdt_offset_ptr(fdt,startoffset,offset - startoffset); + if (pvVar3 != (void *)0x0) { + *nextoffset = offset + 3U & 0xfffffffc; + return uVar5; + } + } +LAB_2302c8b6: + return 9; +} + + + +int fdt_check_node_offset_(void *fdt,int offset) + +{ + uint32_t uVar1; + int aiStack20 [4]; + + if (((offset < 0) || ((offset & 3U) != 0)) || + (aiStack20[0] = offset, uVar1 = fdt_next_tag(fdt,offset,aiStack20), uVar1 != 1)) { + aiStack20[0] = -4; + } + return aiStack20[0]; +} + + + +int fdt_check_prop_offset_(void *fdt,int offset) + +{ + uint32_t uVar1; + int aiStack20 [4]; + + if (((offset < 0) || ((offset & 3U) != 0)) || + (aiStack20[0] = offset, uVar1 = fdt_next_tag(fdt,offset,aiStack20), uVar1 != 3)) { + aiStack20[0] = -4; + } + return aiStack20[0]; +} + + + +int fdt_next_node(void *fdt,int offset,int *depth) + +{ + uint32_t uVar1; + int iVar2; + int iStack36; + int nextoffset; + + iStack36 = 0; + if (offset < 0) goto LAB_2302c998; + iStack36 = fdt_check_node_offset_(fdt,offset); + iVar2 = iStack36; + do { + if (iVar2 < 0) { + return iStack36; + } +LAB_2302c998: + do { + while (iVar2 = iStack36, uVar1 = fdt_next_tag(fdt,iStack36,&iStack36), uVar1 != 2) { + if (uVar1 == 9) { + if (iStack36 < 0) { + if (iStack36 != -8) { + return iStack36; + } + if (depth != (int *)0x0) { + return -8; + } + } + return -1; + } + if (uVar1 == 1) { + if (depth == (int *)0x0) { + return iVar2; + } + *depth = *depth + 1; + return iVar2; + } + } + } while (depth == (int *)0x0); + iVar2 = *depth + -1; + *depth = iVar2; + } while( true ); +} + + + +void cmd_blog_info_dump(char *buf,int len,int argc,char **argv) + +{ + blog_info_t *pbVar1; + blog_info_t *pbVar2; + size_t __n; + int iVar3; + char *pcVar4; + byte *pbVar5; + byte **ppbVar6; + char local_b0 [4]; + char name_buf [128]; + + memset(local_b0,0,0x80); + bl_printk("blog code1 = %p - %p\r\n",&_fsymc_info_bloop,&_fsymf_info_bloopbloop_base); + bl_printk("blog code2 = %p - %p\r\n",&_fsymf_info_bloopbloop_base,&_bl_static_blogfile_code_end); + bl_printk("blog code3 = %p - %p\r\n",&_bl_static_blogfile_code_end,&_bl_static_blogfile_code_end); + pbVar1 = &_fsymc_info_bloop; + do { + if ((blog_info_t *)((int)&_fsymc_info_loopset.name + 3U) < pbVar1) { + return; + } + __n = strlen(pbVar1->name); + if (0x80 < __n) { + bl_printk("name too long.\r\n"); + return; + } + if (local_b0[0] == '\0') { +LAB_2302cae4: + bl_printk("[%-48s] = [%d]\r\n",pbVar1->name,(uint)*pbVar1->level); + if ((local_b0[0] == '\0') || (iVar3 = strcmp(pbVar1->name,local_b0), iVar3 != 0)) { + pbVar2 = &_fsymf_info_bloopbloop_base; + strcpy(local_b0,pbVar1->name); + while (pbVar2 < (blog_info_t *)&_bl_static_blogfile_code_end) { + pcVar4 = strstr(pbVar2->name,pbVar1->name); + if (pcVar4 == pbVar2->name) { + ppbVar6 = (byte **)&_bl_static_blogfile_code_end; + bl_printk("[%-48s] = [%d]\r\n",pcVar4,(uint)*pbVar2->level); + while (ppbVar6 < &_bl_static_blogfile_code_end) { + pbVar5 = (byte *)strstr((char *)ppbVar6[1],pbVar2->name); + if (pbVar5 == ppbVar6[1]) { + bl_printk("[%-48s] = [%d]\r\n",pbVar5,(uint)**ppbVar6); + } + ppbVar6 = ppbVar6 + 2; + } + } + pbVar2 = pbVar2 + 1; + } + } + } + else { + iVar3 = strcmp(local_b0,pbVar1->name); + if (iVar3 != 0) { + __n = strlen(local_b0); + memset(local_b0,0,__n); + goto LAB_2302cae4; + } + } + pbVar1 = pbVar1 + 1; + } while( true ); +} + + + +size_t blog_strcpy(size_t cur_len,char *dst,char *src) + +{ + char cVar1; + char *pcVar2; + + pcVar2 = src; + while ((cVar1 = *pcVar2, cVar1 != '\0' && (pcVar2 + (cur_len - (int)src) < (char *)0x100))) { + pcVar2 = pcVar2 + 1; + *dst = cVar1; + dst = dst + 1; + } + return (size_t)(pcVar2 + -(int)src); +} + + + +void cmd_blog_set_level(char *buf,int len,int argc,char **argv) + +{ + blog_info_t *pbVar1; + int iVar2; + char *format; + size_t sVar3; + int iVar4; + char *__s; + int iVar5; + blog_info_t *pbVar6; + blog_level_t bVar7; + int iVar8; + + if (argc != 3) { + bl_printk("arg error.\r\n"); + goto LAB_2302cbb2; + } + iVar2 = strcmp(argv[1],"all"); + if (iVar2 == 0) { + bVar7 = BLOG_LEVEL_ALL; +LAB_2302cc60: + __s = argv[2]; + sVar3 = strlen(__s); + iVar5 = 0; + iVar2 = 0; + while (iVar2 < (int)sVar3) { + if (__s[iVar2] == '.') { + iVar5 = iVar5 + 1; + } + iVar2 = iVar2 + 1; + } + if (iVar5 == 0) { + pbVar1 = &_fsymf_info_bloopbloop_base; + pbVar6 = &_fsymc_info_bloop; + } + else { + if (iVar5 == 1) { + pbVar1 = (blog_info_t *)&_bl_static_blogfile_code_end; + pbVar6 = &_fsymf_info_bloopbloop_base; + } + else { + if (iVar5 != 2) { + __s = argv[2]; + format = "input name = %s not support.\r\n"; + goto LAB_2302cc58; + } + pbVar1 = (blog_info_t *)&_bl_static_blogfile_code_end; + pbVar6 = (blog_info_t *)&_bl_static_blogfile_code_end; + } + } + iVar2 = ((int)((int)pbVar1 - (int)pbVar6) >> 3) + -1; + iVar5 = 0; + while (__s = argv[2], iVar5 <= iVar2) { + iVar8 = iVar5 + iVar2 >> 1; + pbVar1 = pbVar6 + iVar8; + iVar4 = strcmp(pbVar1->name,__s); + if (iVar4 < 0) { + iVar5 = iVar8 + 1; + } + else { + if (iVar4 == 0) { + *pbVar1->level = bVar7; + bl_printk("set %s = %d\r\n",pbVar1->name,(uint)*pbVar1->level); + return; + } + iVar2 = iVar8 + -1; + } + } + format = "input name = %s not find.\r\n"; + } + else { + iVar2 = strcmp(argv[1],"debug"); + bVar7 = BLOG_LEVEL_DEBUG; + if (iVar2 == 0) goto LAB_2302cc60; + iVar2 = strcmp(argv[1],"info"); + bVar7 = BLOG_LEVEL_INFO; + if (iVar2 == 0) goto LAB_2302cc60; + iVar2 = strcmp(argv[1],"warn"); + bVar7 = BLOG_LEVEL_WARN; + if (iVar2 == 0) goto LAB_2302cc60; + iVar2 = strcmp(argv[1],"error"); + bVar7 = BLOG_LEVEL_ERROR; + if (iVar2 == 0) goto LAB_2302cc60; + iVar2 = strcmp(argv[1],"assert"); + bVar7 = BLOG_LEVEL_ASSERT; + if (iVar2 == 0) goto LAB_2302cc60; + iVar2 = strcmp(argv[1],"never"); + bVar7 = BLOG_LEVEL_NEVER; + if (iVar2 == 0) goto LAB_2302cc60; + __s = argv[1]; + format = "input level = %s not support.\r\n"; + } +LAB_2302cc58: + bl_printk(format,__s); +LAB_2302cbb2: + bl_printk("set blog error.\r\n"); + return; +} + + + +void blog_port_output(char *log,size_t size) + +{ + bl_printk("%.*s",log); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void blog_hexdump_out(char *name,uint8_t width,uint8_t *buf,uint16_t size) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + size_t sVar4; + size_t sVar5; + undefined3 in_register_0000202d; + undefined2 in_register_00002036; + uint uVar6; + uint uVar7; + size_t cur_len; + undefined4 uStack72; + char dump_string [8]; + + uVar6 = CONCAT22(in_register_00002036,size); + uStack72 = 0; + dump_string._0_4_ = 0; + uVar1 = 0; + while (uVar1 < uVar6) { + uVar3 = snprintf(log_buf,0x100,"[%s]: %04X-%04X: ",name,uVar1, + CONCAT31(in_register_0000202d,width) + uVar1 + -1); + if (0x100 < uVar3) { + uVar3 = 0x100; + } + cur_len = uVar3 & 0xffff; + uVar7 = 0; + uVar2 = CONCAT31(in_register_0000202d,width) & 0xffff; + uVar3 = uVar1; + while ((uVar7 & 0xffff) < uVar2) { + if ((int)uVar3 < (int)uVar6) { + snprintf((char *)&uStack72,8,"%02X ",(uint)buf[uVar3]); + } + else { + strncpy((char *)&uStack72," ",8); + } + sVar4 = blog_strcpy(cur_len,log_buf + cur_len,(char *)&uStack72); + uVar7 = uVar7 + 1; + cur_len = cur_len + sVar4 & 0xffff; + if ((uVar7 & 7) == 0) { + sVar4 = blog_strcpy(cur_len,log_buf + cur_len," "); + cur_len = cur_len + sVar4 & 0xffff; + } + uVar3 = uVar3 + 1; + } + sVar4 = blog_strcpy(cur_len,log_buf + cur_len," "); + cur_len = sVar4 + cur_len & 0xffff; + uVar3 = uVar1; + while ((uVar3 - uVar1 & 0xffff) < uVar2) { + if ((int)uVar3 < (int)uVar6) { + uVar7 = (uint)buf[uVar3]; + if (0x5e < uVar7 - 0x20) { + uVar7 = 0x2e; + } + snprintf((char *)&uStack72,8,"%c",uVar7); + sVar4 = blog_strcpy(cur_len,log_buf + cur_len,(char *)&uStack72); + cur_len = cur_len + sVar4 & 0xffff; + } + uVar3 = uVar3 + 1; + } + sVar5 = strlen("\r\n"); + if (0x100 < sVar5 + cur_len) { + sVar5 = strlen("\r\n"); + cur_len = 0x100 - sVar5 & 0xffff; + } + sVar4 = blog_strcpy(cur_len,log_buf + cur_len,"\r\n"); + blog_port_output(log_buf,sVar4 + cur_len & 0xffff); + uVar1 = uVar1 + uVar2 & 0xffff; + } + return; +} + + + +void blog_init(void) + +{ + blog_level_t **ppbVar1; + undefined *puVar2; + blog_info_t *pbVar3; + undefined4 *puVar4; + + bl_printk("\r\nblog init set power on level %d, %d, %d.\r\n",2,2); + pbVar3 = &_fsymc_info_bloop; + while (pbVar3 < &_fsymf_info_bloopbloop_base) { + ppbVar1 = &pbVar3->level; + pbVar3 = pbVar3 + 1; + **ppbVar1 = BLOG_LEVEL_INFO; + } + pbVar3 = &_fsymf_info_bloopbloop_base; + while (pbVar3 < (blog_info_t *)&_bl_static_blogfile_code_end) { + ppbVar1 = &pbVar3->level; + pbVar3 = pbVar3 + 1; + **ppbVar1 = BLOG_LEVEL_INFO; + } + puVar4 = (undefined4 *)&_bl_static_blogfile_code_end; + while (puVar4 < &_bl_static_blogfile_code_end) { + puVar2 = (undefined *)*puVar4; + puVar4 = puVar4 + 2; + *puVar2 = 2; + } + return; +} + + + +void wifiprov_ccc_cfg_changed(bt_gatt_attr *attr,u16_t value) + +{ + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void __bl_ble_sync_task(void *p_arg) + +{ + uint16_t mtu; + u16_t uVar1; + pro_handle_t ppVar2; + QueueHandle_t pQVar3; + BaseType_t BVar4; + int iVar5; + TickType_t TVar6; + undefined auStack308 [4]; + queue_buf recv_buf; + + cJSON_InitHooks(&__g_cjson_hooks); + ppVar2 = pro_trans_init((pro_dev *)((int)p_arg + 0xef0),&ble_gatt_func,(void *)0x0); + *(pro_handle_t *)((int)p_arg + 0x40c) = ppVar2; + *(undefined *)((int)p_arg + 0x61e) = 1; + pQVar3 = xQueueGenericCreateStatic(1,0,(uint8_t *)0x0,(StaticQueue_t *)((int)p_arg + 4),'\x03'); + *(QueueHandle_t *)p_arg = pQVar3; + pQVar3 = xQueueGenericCreateStatic + (2,0x104,(uint8_t *)((int)p_arg + 0x100),(StaticQueue_t *)((int)p_arg + 0xb0), + '\0'); + *(QueueHandle_t *)((int)p_arg + 0xac) = pQVar3; + mtu = 0; + while (*(char *)((int)p_arg + 0x620) == '\0') { + BVar4 = xQueueReceive(*(QueueHandle_t *)((int)p_arg + 0xac),auStack308,10000); + if (BVar4 == 1) { + if (*(bt_conn **)((int)p_arg + 0x684) != (bt_conn *)0x0) { + uVar1 = bt_gatt_get_mtu(*(bt_conn **)((int)p_arg + 0x684)); + mtu = uVar1 - 3; + } + iVar5 = pro_trans_read(*(pro_handle_t *)((int)p_arg + 0x40c),auStack308,recv_buf.buf._252_4_, + mtu); + if (((iVar5 != 0) && (_fsymc_level_blsync_ble < BLOG_LEVEL_WARN)) && + (_fsymf_level_blsync_bleblsync_ble < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar6 = xTaskGetTickCount(); + } + else { + TVar6 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] protocol analyze failed\r\n",TVar6,&DAT_2306e4ac, + "blsync_ble.c",0x142); + } + } + else { + pro_trans_reset(*(pro_handle_t *)((int)p_arg + 0x40c)); + } + } + *(undefined *)((int)p_arg + 0x61e) = 0; + vTaskDelete(*(TaskHandle_t *)((int)p_arg + 0xee8)); + return; +} + + + +void scan_complete_cb(void *param) + +{ + byte bVar1; + bl_ble_sync_t *pbVar2; + + pbVar2 = gp_index; + gp_index->scaning = '\0'; + bVar1 = pbVar2->w_ap_item; + if (bVar1 < 0x32) { + memcpy(pbVar2->ap_item + bVar1,param,0x30); + gp_index->w_ap_item = gp_index->w_ap_item + '\x01'; + } + return; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +int __recv_event(void *p_drv,pro_event *p_event) + +{ + event_type_t eVar1; + bl_ble_sync_t *pbVar2; + blog_level_t bVar3; + SemaphoreHandle_t *ppQVar4; + pro_handle_t handle; + TickType_t TVar5; + wifi_conn *__dest; + code *pcVar6; + BaseType_t BVar7; + cJSON *object; + cJSON *item; + char *__s; + void *__src; + size_t bytes; + uint uVar8; + blesync_wifi_func *pbVar9; + anon_subr_void_wifi_conn_ptr_for_local_connect_remote_ap *paVar10; + anon_subr_void_for_local_disconnect_remote_ap *paVar11; + anon_subr_void_anon_subr_void_void_ptr_ptr_for_local_wifi_state_get *paVar12; + undefined4 uStack52; + char bssid [20]; + + uStack52 = 0; + bssid._0_4_ = 0; + bssid._4_4_ = 0; + bssid._8_4_ = 0; + bssid._12_4_ = 0; + if ((_fsymc_level_blsync_ble < BLOG_LEVEL_WARN) && + (_fsymf_level_blsync_bleblsync_ble < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] event type %d, id %d\r\n",TVar5,&DAT_2306e4ac,"blsync_ble.c",0xa0, + (uint)p_event->type,p_event->event_id); + } + bVar3 = _fsymc_level_blsync_ble; + pbVar2 = gp_index; + eVar1 = p_event->type; + if (eVar1 == PROTOCOL_EVENT_DATA) { + uVar8 = p_event->event_id; + if (uVar8 == 2) { + memset(&gp_index->conn_info,0,0x20); + pbVar2 = gp_index; + (gp_index->conn_info).ssid_tail[0] = '\0'; + bytes = p_event->length; + __src = p_event->p_buf; + __dest = &pbVar2->conn_info; + } + else { + if (uVar8 != 3) { + if (uVar8 != (uint)eVar1) { + return 2; + } + return 0; + } + memset((gp_index->conn_info).pask,0,0x40); + bytes = p_event->length; + __src = p_event->p_buf; + __dest = (wifi_conn *)(gp_index->conn_info).pask; + } + memcpy(__dest,__src,bytes); + return 0; + } + if (eVar1 != PROTOCOL_EVENT_CMD) { + return 0; + } + switch(p_event->event_id) { + case 3: + pcVar6 = (code *)&gp_index->conn_info; + paVar10 = gp_index->wifi_func->local_connect_remote_ap; + if (paVar10 == (anon_subr_void_wifi_conn_ptr_for_local_connect_remote_ap *)0x0) { + return 0; + } + break; + case 4: + paVar11 = gp_index->wifi_func->local_disconnect_remote_ap; + if (paVar11 != (anon_subr_void_for_local_disconnect_remote_ap *)0x0) { + (*paVar11)(); + return 0; + } + return 0; + default: + return 2; + case 7: + pro_trans_layer_ack_read(gp_index->pro_handle,"v1.1.0",7); + return 0; + case 9: + pbVar9 = gp_index->wifi_func; + if (pbVar9->local_wifi_scan == + (anon_subr_void_anon_subr_void_void_ptr_ptr_for_local_wifi_scan *)0x0) { + return 0; + } + *(undefined2 *)&gp_index->w_ap_item = 0; + pbVar2->scaning = '\x01'; + paVar10 = (anon_subr_void_wifi_conn_ptr_for_local_connect_remote_ap *)pbVar9->local_wifi_scan; + pcVar6 = scan_complete_cb; + break; + case 0xb: + if (gp_index->w_ap_item == 0) { + return 1; + } + uVar8 = (uint)gp_index->r_ap_item; + if ((uint)gp_index->w_ap_item == uVar8) { + *(undefined2 *)&gp_index->w_ap_item = 0; + if (BLOG_LEVEL_INFO < bVar3) { + return 0; + } + if (_fsymf_level_blsync_bleblsync_ble < BLOG_LEVEL_WARN) { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] wifi list end\r\n",TVar5,&DAT_2306e4ac,"blsync_ble.c",0xd2); + return 0; + } + return 0; + } + if ((_fsymc_level_blsync_ble < BLOG_LEVEL_WARN) && + (_fsymf_level_blsync_bleblsync_ble < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + gp_index->r_ap_item = gp_index->r_ap_item + '\x01'; + bl_printk("[%10u][%s: %s:%4d] item_nums %d\r\n",TVar5,&DAT_2306e4ac,"blsync_ble.c",0xd6); + } + object = cJSON_CreateObject(); + ppQVar4 = &pbVar2->xSemaphore + uVar8 * 0xc; + sprintf((char *)&uStack52,"%02X:%02X:%02X:%02X:%02X:%02X",(uint)*(byte *)(ppQVar4 + 0x3f1), + (uint)*(byte *)((int)ppQVar4 + 0xfc5),(uint)*(byte *)((int)ppQVar4 + 0xfc6), + (uint)*(byte *)((int)ppQVar4 + 0xfc7),(uint)*(byte *)(ppQVar4 + 0x3f2), + (uint)*(byte *)((int)ppQVar4 + 0xfc9)); + __floatunsidf((uint)*(byte *)((int)ppQVar4 + 0xfca)); + item = cJSON_CreateNumber(); + cJSON_AddItemToObject(object,"chan",item); + item = cJSON_CreateString((char *)&uStack52); + cJSON_AddItemToObject(object,"bssid",item); + __floatsidf((int)*(char *)(ppQVar4 + 0x3f3)); + item = cJSON_CreateNumber(); + cJSON_AddItemToObject(object,"rssi",item); + item = cJSON_CreateString((char *)(pbVar2->ap_item + uVar8)); + cJSON_AddItemToObject(object,"ssid",item); + __floatunsidf((uint)*(byte *)((int)ppQVar4 + 0xfcb)); + item = cJSON_CreateNumber(); + cJSON_AddItemToObject(object,"auth",item); + __s = cJSON_Print(object); + handle = gp_index->pro_handle; + bytes = strlen(__s); + pro_trans_layer_ack_read(handle,__s,bytes); + cJSON_Delete(object); + goto LAB_2302d470; + case 0xc: + paVar10 = (anon_subr_void_wifi_conn_ptr_for_local_connect_remote_ap *)gp_index->complete_cb; + if (paVar10 == (anon_subr_void_wifi_conn_ptr_for_local_connect_remote_ap *)0x0) { + return 0; + } + pcVar6 = (code *)gp_index->p_arg; + break; + case 0xd: + paVar12 = gp_index->wifi_func->local_wifi_state_get; + if (paVar12 == (anon_subr_void_anon_subr_void_void_ptr_ptr_for_local_wifi_state_get *)0x0) { + return 0; + } + (*paVar12)(wifi_state_get_cb); + BVar7 = xQueueSemaphoreTake((QueueHandle_t)gp_index->xSemaphore,10000); + if (BVar7 != 1) { + return 2; + } + sprintf((char *)&uStack52,"%02X:%02X:%02X:%02X:%02X:%02X",(uint)(gp_index->state).bssid[0], + (uint)(gp_index->state).bssid[1],(uint)(gp_index->state).bssid[2], + (uint)(gp_index->state).bssid[3],(uint)(gp_index->state).bssid[4], + (uint)(gp_index->state).bssid[5]); + object = cJSON_CreateObject(); + __floatunsidf((uint)(gp_index->state).state); + item = cJSON_CreateNumber(); + cJSON_AddItemToObject(object,"state",item); + item = cJSON_CreateString((char *)&gp_index->state); + cJSON_AddItemToObject(object,"ip",item); + item = cJSON_CreateString((gp_index->state).gw); + cJSON_AddItemToObject(object,"gw",item); + item = cJSON_CreateString((gp_index->state).mask); + cJSON_AddItemToObject(object,"mask",item); + item = cJSON_CreateString((gp_index->state).ssid); + cJSON_AddItemToObject(object,"ssid",item); + item = cJSON_CreateString((char *)&uStack52); + cJSON_AddItemToObject(object,"bssid",item); + __s = cJSON_Print(object); + handle = gp_index->pro_handle; + bytes = strlen(__s); + pro_trans_layer_ack_read(handle,__s,bytes); + cJSON_Delete(object); +LAB_2302d470: + vPortFree(__s); + return 0; + } + (*paVar10)(pcVar6); + return 0; +} + + + +void wifi_state_get_cb(void *p_arg) + +{ + bl_ble_sync_t *pbVar1; + + pbVar1 = gp_index; + memcpy(&gp_index->state,p_arg,0x58); + xQueueGenericSend((QueueHandle_t)pbVar1->xSemaphore,(void *)0x0,0,0); + return; +} + + + +size_t write_data(bt_conn *param_1,uint8_t *param_2,size_t param_3) + +{ + bl_ble_sync_t *pbVar1; + blog_level_t bVar2; + TickType_t TVar3; + + bVar2 = _fsymc_level_blsync_ble; + gp_index->p_cur_conn = param_1; + if ((bVar2 < BLOG_LEVEL_WARN) && (_fsymf_level_blsync_bleblsync_ble < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] write length %d\r\n",TVar3,&DAT_2306e4ac,"blsync_ble.c",0x7c, + param_3); + if ((_fsymc_level_blsync_ble < BLOG_LEVEL_WARN) && + (_fsymf_level_blsync_bleblsync_ble < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %s:\r\n",TVar3,&DAT_2306e4ac,"blsync_ble.c",0x7d,&DAT_23077518); + blog_hexdump_out("data",'\x10',param_2,(uint16_t)param_3); + } + } + pbVar1 = gp_index; + (gp_index->send_buf).len = param_3; + memcpy(&pbVar1->send_buf,param_2,param_3); + xQueueGenericSend(gp_index->xQueue1,&gp_index->send_buf,0,0); + return param_3; +} + + + +undefined4 __ble_bytes_send(uint8_t *param_1,uint param_2) + +{ + blog_level_t bVar1; + undefined4 uVar2; + TickType_t TVar3; + + uVar2 = 0xffffffff; + if ((gp_index->p_cur_conn != (bt_conn *)0x0) && (param_2 < 0x100)) { + memcpy(gp_index->attr_read_buf,param_1,param_2); + bVar1 = _fsymc_level_blsync_ble; + gp_index->rbuf_len = (uint16_t)param_2; + if ((bVar1 < BLOG_LEVEL_WARN) && (_fsymf_level_blsync_bleblsync_ble < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ble send size %d\r\n",&DAT_2306e4ac,"blsync_ble.c",0x91,param_2 + ); + if ((_fsymc_level_blsync_ble < BLOG_LEVEL_WARN) && + (_fsymf_level_blsync_bleblsync_ble < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %s:\r\n",TVar3,&DAT_2306e4ac,"blsync_ble.c",0x93,&DAT_23077518 + ); + blog_hexdump_out("data",'\x10',param_1,(uint16_t)param_2); + } + } + printf("\r\n"); + uVar2 = 0; + } + return uVar2; +} + + + +void blsync_disconnected(bt_conn *conn,u8_t reason) + +{ + printf("disconnected (reason %u)%s\r\n"); + blsync_conn = (bt_conn *)0x0; + return; +} + + + +void blsync_exchange_func(bt_conn *conn,u8_t err,bt_gatt_exchange_params *params) + +{ + undefined3 in_register_0000202d; + char *pcVar1; + + if (CONCAT31(in_register_0000202d,err) == 0) { + pcVar1 = "successful"; + } + else { + pcVar1 = "failed"; + } + printf("Exchange %s\r\n",pcVar1); + return; +} + + + +ssize_t read_data(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset) + +{ + TickType_t TVar1; + ssize_t sVar2; + + if (gp_index->rbuf_len == 0) { + sVar2 = -4; + } + else { + if ((_fsymc_level_blsync_ble < BLOG_LEVEL_WARN) && + (_fsymf_level_blsync_bleblsync_ble < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] read length %d\r\n",TVar1,&DAT_2306e4ac,"blsync_ble.c",0x6d, + (uint)gp_index->rbuf_len); + } + pro_trans_ack(gp_index->pro_handle); + sVar2 = bt_gatt_attr_read(conn,attr,buf,len,offset,gp_index->attr_read_buf,gp_index->rbuf_len); + gp_index->rbuf_len = 0; + } + return sVar2; +} + + + +void blsync_connected(bt_conn *conn,u8_t err) + +{ + char "blsync_connected" [17]; + int iVar1; + + printf("%s\n","blsync_connected"); + blsync_conn = conn; + iVar1 = bt_le_set_data_len(conn,0xfb,0x848); + if (iVar1 == 0) { + printf("Set data length success.\n"); + } + else { + printf("Set data length failure, err: %d\n",iVar1); + } + blsync_exchg_mtu.func = blsync_exchange_func; + iVar1 = bt_gatt_exchange_mtu(blsync_conn,&blsync_exchg_mtu); + if (iVar1 == 0) { + printf("Exchange mtu size pending.\n",0); + return; + } + printf("Exchange mtu size failure, err: %d\n",iVar1); + return; +} + + + +int bl_ble_sync_start(bl_ble_sync_t *index,blesync_wifi_func *func,pfn_complete_cb_t *cb, + void *cb_arg) + +{ + uint uVar1; + int iVar2; + TickType_t TVar3; + TaskHandle_t ptVar4; + + if ((index == (bl_ble_sync_t *)0x0) || (func == (blesync_wifi_func *)0x0)) { + iVar2 = -1; + if ((_fsymc_level_blsync_ble < BLOG_LEVEL_WARN) && + (_fsymf_level_blsync_bleblsync_ble < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ble sync init failed\r\n",TVar3,&DAT_2306e4ac,"blsync_ble.c", + 0x16d); + iVar2 = -1; + } + } + else { + memset(index,0,0x1908); + uVar1 = isRegister; + gp_index = index; + index->wifi_func = func; + index->complete_cb = cb; + index->p_arg = cb_arg; + *(undefined2 *)&index->task_runing = 0; + index->stop_flag = '\0'; + if (uVar1 == 0) { + isRegister = 1; + bt_conn_cb_register(&blsync_conn_callbacks); + } + bt_gatt_service_register(&wifiprov_server); + ptVar4 = xTaskCreateStatic(__bl_ble_sync_task,"pro",0x200,index,10,index->stack,&index->task); + index->task_handle = ptVar4; + iVar2 = 0; + } + return iVar2; +} + + + +int bl_ble_sync_stop(bl_ble_sync_t *index) + +{ + TaskHandle_t ptVar1; + + if (index == (bl_ble_sync_t *)0x0) { + return -1; + } + bt_gatt_service_unregister(&wifiprov_server); + index->stop_flag = '\x01'; + ptVar1 = xTaskGetCurrentTaskHandle(); + if (gp_index->task_handle == ptVar1) { + while (gp_index->scaning == '\x01') { + vTaskDelay(10); + } + vTaskDelete(index->task_handle); + } + else { + while ((gp_index->scaning == '\x01' || (index->task_runing == '\x01'))) { + vTaskDelay(10); + } + } + return 0; +} + + + +void * __malloc(size_t size) + +{ + void *pvVar1; + TickType_t TVar2; + + pvVar1 = pvPortMalloc(size); + if (((pvVar1 != (void *)0x0) && (_fsymc_level_blsync_ble < BLOG_LEVEL_WARN)) && + (_fsymf_level_blsync_bletransfer < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] malloc %p\r\n",TVar2,&DAT_2306e4ac,"transfer.c",0x1e,pvVar1); + } + return pvVar1; +} + + + +void __free(void *ptr) + +{ + TickType_t TVar1; + + if (((ptr != (void *)0x0) && (_fsymc_level_blsync_ble < BLOG_LEVEL_WARN)) && + (_fsymf_level_blsync_bletransfer < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] free %p\r\n",TVar1,&DAT_2306e4ac,"transfer.c",0x14,ptr); + } + vPortFree(ptr); + return; +} + + + +void __clear_dev(pro_handle_t handle) + +{ + *(undefined4 *)&handle->tol_len_now = 0; + __free(handle->pyld_buf); + handle->pyld_buf = (uint8_t *)0x0; + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int __protocol_send(pro_handle_t handle,uint8_t seq,uint8_t ack,uint8_t type,void *p_data, + uint16_t length) + +{ + ushort uVar1; + bool bVar2; + void *__dest; + BaseType_t BVar3; + undefined3 in_register_00002031; + undefined2 in_register_0000203e; + uint uVar4; + int iVar5; + uint uVar6; + char *pcVar7; + char cVar8; + uint uVar9; + byte bStack69; + byte bStack68; + uint8_t uStack67; + uint8_t dst_len; + ushort uStack66; + general_head head; + + uVar4 = CONCAT22(in_register_0000203e,length); + bStack68 = 0; + uStack66 = 0; + if (CONCAT31(in_register_00002031,ack) != 0) { + bStack68 = 8; + } + uVar6 = 0xfffffffd; + bStack68 = bStack68 | 0x10; + uStack67 = seq; + __dest = __malloc((uint)handle->mtu); + if (__dest != (void *)0x0) { + uVar9 = 0; + do { + bStack69 = 4; + uVar1 = handle->mtu; + if (uVar9 == 0) { + *(char *)((int)__dest + 4) = (char)length; + iVar5 = (uint)uVar1 - 6; + *(undefined *)((int)__dest + 5) = (char)(length >> 8); + bStack69 = 6; + handle->enc_handle->is_head = '\x01'; + cVar8 = '\x06'; + pcVar7 = (char *)((int)__dest + 6); + } + else { + iVar5 = (uint)uVar1 - 4; + cVar8 = '\x04'; + pcVar7 = (char *)((int)__dest + 4); + } + bStack69 = bStack69 + 1; + uVar6 = (*handle->enc_handle->pfnc->pfn_enc_write) + (handle->enc_handle->p_drv,'\x01',type,(uint8_t *)(pcVar7 + 1),&bStack69, + (uint8_t *)((int)p_data + uVar9),(char)length - (char)uVar9, + (int16_t)((uint)(((iVar5 * 0x10000 >> 0x10) + -1) * 0x10000) >> 0x10)); + handle->enc_handle->is_head = '\0'; + if ((int)uVar6 < 0) break; + uVar9 = uVar9 + (uVar6 & 0xff) & 0xffff; + if (uVar9 < uVar4) { + bVar2 = false; + } + else { + if (uVar4 != uVar9) { + uVar6 = 0xfffffffe; + break; + } + uStack66 = uStack66 | 0x8000; + bVar2 = true; + } + if ((uVar6 & 0xff) < uVar4) { + bStack68 = bStack68 | 2; + } + memcpy(__dest,&bStack68,2); + *(undefined *)((int)__dest + 2) = (char)uStack66; + *(undefined *)((int)__dest + 3) = (char)(uStack66 >> 8); + *pcVar7 = (bStack69 - 1) - cVar8; + (*handle->p_func->pfu_bytes_send)((void *)0x0,__dest,(uint)bStack69); + uStack67 = uStack67 + '\x01'; + uStack66 = uStack66 + 1; + BVar3 = xQueueSemaphoreTake((QueueHandle_t)handle->xSemaphore,10000); + if (BVar3 != 1) { + uVar6 = 0xfffffffc; + break; + } + } while (!bVar2); + __free(__dest); + } + return uVar6; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int pro_trans_read(pro_handle_t handle,void *buf,size_t bytes,uint16_t mtu) + +{ + uint8_t uVar1; + uint8_t *puVar2; + TickType_t TVar3; + uint8_t *puVar4; + uint uVar5; + int iVar6; + size_t sVar7; + int iVar8; + event_type_t eVar9; + byte local_36; + uint8_t uStack53; + byte bStack52; + uint8_t uStack51; + uint8_t dst_len; + uint8_t ev_id; + general_head head; + pro_event ev; + + if (handle == (pro_handle_t)0x0) { + return -2; + } + if (buf == (void *)0x0) { + return -2; + } + handle->mtu = mtu; + memcpy(&bStack52,buf,2); + uVar1 = uStack51; + if ((bStack52 & 1) != 0) { + if (handle->old_seq != uStack51) { + TVar3 = xTaskGetTickCount(); + *(TickType_t *)&handle->seq_start_ms = TVar3; + *(undefined4 *)((int)&handle->seq_start_ms + 4) = 0; + handle->old_seq = uVar1; + } + if ((*(uint *)&handle->seq_start_ms | *(uint *)((int)&handle->seq_start_ms + 4)) != 0) { + TVar3 = xTaskGetTickCount(); + iVar6 = *(int *)((int)&handle->seq_start_ms + 4); + uVar5 = TVar3 - *(int *)&handle->seq_start_ms; + iVar8 = -(uint)(TVar3 < uVar5); + if ((0 < iVar8 - iVar6) || ((iVar8 == iVar6 && (10000 < uVar5)))) { + __clear_dev(handle); + if (BLOG_LEVEL_INFO < _fsymc_level_blsync_ble) { + return -4; + } + if (BLOG_LEVEL_INFO < _fsymf_level_blsync_bletransfer) { + return -4; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] -----------timeout-----------\r\n",TVar3,&DAT_2306e4ac, + "transfer.c",0x145); + return -4; + } + } + } + _dst_len = *(ushort *)((int)buf + 2); + eVar9 = bStack52 >> 4 & 3; + sVar7 = (size_t)*(byte *)((int)buf + 4); + if ((_dst_len & 0x7fff) == 0) { + puVar2 = (uint8_t *)((int)buf + 7); + handle->total_length = CONCAT11(*(undefined *)((int)buf + 5),*(byte *)((int)buf + 4)); + sVar7 = (size_t)*(byte *)((int)buf + 6); + if (bytes - 4 == sVar7 + 3) { + if (handle->pyld_buf != (uint8_t *)0x0) { + __clear_dev(handle); + } + if (handle->total_length == 0) { +LAB_2302df24: + handle->enc_handle->is_head = '\x01'; + goto LAB_2302df2c; + } + puVar4 = (uint8_t *)__malloc((uint)handle->total_length); + handle->pyld_buf = puVar4; + if (puVar4 != (uint8_t *)0x0) goto LAB_2302df24; +LAB_2302df62: + iVar8 = -3; + goto __end; + } +LAB_2302df10: + iVar8 = -2; + } + else { + puVar2 = (uint8_t *)((int)buf + 5); + if (bytes - 4 != sVar7 + 1) goto LAB_2302df10; + handle->enc_handle->is_head = '\0'; +LAB_2302df2c: + iVar8 = (*handle->enc_handle->pfnc->pfn_enc_read) + (handle->enc_handle->p_drv,eVar9,&uStack53, + handle->pyld_buf + handle->tol_len_now,&local_36,puVar2,sVar7); + if (iVar8 == 0) { + uVar5 = (uint)handle->tol_len_now + (uint)local_36; + handle->tol_len_now = (uint16_t)(uVar5 * 0x10000 >> 0x10); + if (((bStack52 & 2) != 0) && (-1 < (short)_dst_len)) goto __end; + if ((uint)handle->total_length != (uVar5 & 0xffff)) { + __clear_dev(handle); + goto LAB_2302df10; + } + head.ctrl = eVar9; + if (handle->p_func->pfn_recv_event != + (anon_subr_int_void_ptr_pro_event_ptr_for_pfn_recv_event *)0x0) { + puVar2 = (uint8_t *)__malloc(0x100); + handle->ack_buf = puVar2; + if (puVar2 == (uint8_t *)0x0) goto LAB_2302df62; + iVar8 = (*handle->p_func->pfn_recv_event)(handle->p_drv,(pro_event *)&head); + } + } + __clear_dev(handle); + } +__end: + if ((bStack52 >> 3 & 1) == 0) { + __protocol_send(handle,uStack51,'\x01',(uint8_t)iVar8,handle->ack_buf, + (ushort)*(byte *)&handle->ack_len); + } + handle->ack_len = 0; + __free(handle->ack_buf); + handle->ack_buf = (uint8_t *)0x0; + return iVar8; +} + + + +int pro_trans_ack(pro_handle_t handle) + +{ + BaseType_t BVar1; + int iVar2; + + BVar1 = xQueueGenericSend((QueueHandle_t)handle->xSemaphore,(void *)0x0,0,0); + if (BVar1 == 1) { + iVar2 = 0; + } + else { + iVar2 = 2; + } + return iVar2; +} + + + +int pro_trans_layer_ack_read(pro_handle_t handle,void *ack_buf,size_t bytes) + +{ + int iVar1; + + if ((handle != (pro_handle_t)0x0) && (iVar1 = -2, ack_buf != (void *)0x0)) { + if (bytes < 0x101) { + iVar1 = -3; + if (handle->ack_buf != (uint8_t *)0x0) { + memcpy(handle->ack_buf,ack_buf,bytes); + iVar1 = 0; + handle->ack_len = (uint16_t)bytes; + } + } + return iVar1; + } + return -2; +} + + + +pro_handle_t pro_trans_init(pro_dev *p_dev,pro_func *p_func,void *p_drv) + +{ + enc_handle_t peVar1; + QueueHandle_t pQVar2; + + memset(p_dev,0,0xb0); + peVar1 = pro_encrypt_init(&p_dev->enc,&p_dev->enc); + p_dev->enc_handle = peVar1; + p_dev->p_func = p_func; + p_dev->p_drv = p_drv; + pQVar2 = xQueueGenericCreateStatic + (1,0,(uint8_t *)0x0,(StaticQueue_t *)&p_dev->xSemaphoreBuffer,'\x03'); + *(QueueHandle_t *)&p_dev->xSemaphore = pQVar2; + return (pro_handle_t)p_dev; +} + + + +void pro_trans_reset(pro_handle_t handle) + +{ + *(undefined4 *)&handle->tol_len_now = 0; + __free(handle->pyld_buf); + handle->pyld_buf = (uint8_t *)0x0; + return; +} + + + +int __pack_encrypt_read(void *p_drv,uint8_t pack_type,uint8_t *dst_id,uint8_t *dst_buf, + uint8_t *dst_len,uint8_t *src_buf,size_t src_lenght) + +{ + int iVar1; + undefined3 in_register_0000202d; + uint uVar2; + + if (*(char *)((int)p_drv + 0x10) == '\0') { + src_buf = src_buf + 1; + uVar2 = src_lenght - 1; + } + else { + src_buf = src_buf + 9; + uVar2 = src_lenght - 9; + } + *(bool *)((int)p_drv + 0xc) = CONCAT31(in_register_0000202d,pack_type) != 0; + // WARNING: Could not recover jumptable at 0x2302e0e6. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (**(code **)**(code ***)p_drv)((*(code ***)p_drv)[1],dst_buf,dst_len,src_buf,uVar2 & 0xff) + ; + return iVar1; +} + + + +int __pack_encrypt_write + (void *p_drv,uint8_t pack_type,uint8_t src_id,uint8_t *dst_buf,uint8_t *dst_len, + uint8_t *src_buf,uint8_t src_len,int16_t remain_len) + +{ + int iVar1; + undefined3 in_register_00002031; + undefined3 in_register_00002041; + short sVar2; + + *dst_buf = '\0'; + if (*(char *)((int)p_drv + 0x10) == '\0') { + dst_buf = dst_buf + 1; + sVar2 = remain_len + -1; + *dst_len = *dst_len + '\x01'; + } + else { + dst_buf[1] = '\0'; + dst_buf[2] = '\0'; + dst_buf[3] = '\0'; + dst_buf[4] = '\0'; + dst_buf[5] = '\0'; + dst_buf[6] = '\0'; + dst_buf[7] = '\0'; + dst_buf[8] = '\0'; + dst_buf = dst_buf + 9; + sVar2 = remain_len + -9; + *dst_len = *dst_len + '\t'; + } + *(undefined *)((int)p_drv + 0xc) = 1; + // WARNING: Could not recover jumptable at 0x2302e152. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (**(code **)(**(int **)p_drv + 4)) + ((*(int **)p_drv)[1],dst_buf,CONCAT31(in_register_00002031,src_id),src_buf, + CONCAT31(in_register_00002041,src_len),(int)sVar2); + return iVar1; +} + + + +enc_handle_t pro_encrypt_init(encrypt *p_enc,void *p_drv) + +{ + pyld_handle_t ppVar1; + + ppVar1 = pro_payload_init(&p_enc->pyld,&p_enc->pyld); + p_enc->pyld_handle = ppVar1; + p_enc->p_drv = p_drv; + p_enc->pfnc = &__g_enc_func; + return (enc_handle_t)p_enc; +} + + + +int __payload_write(void *p_arg,uint8_t *dst_buf,uint8_t *dst_len,uint8_t src_id,uint8_t *src_buf, + uint8_t src_len,int16_t remain_len) + +{ + uint8_t uVar1; + undefined3 in_register_0000203d; + uint uVar2; + short in_register_00002042; + uint __n; + + uVar2 = CONCAT31(in_register_0000203d,src_len); + if (in_register_00002042 < 0) { + return -2; + } + if (*(char *)((int)p_arg + 8) == '\0') { + __n = (int)(((uint)(ushort)remain_len - 1) * 0x10000) >> 0x10; + if ((int)uVar2 < (int)__n) { + __n = uVar2; + } + __n = __n & 0xff; + if (__n != 4) { + return -2; + } + *dst_buf = src_id; + memcpy(dst_buf + 1,src_buf,4); + uVar1 = *dst_len + '\x05'; + } + else { + __n = (int)(((uint)(ushort)remain_len - 2) * 0x10000) >> 0x10; + if ((int)uVar2 < (int)__n) { + __n = uVar2; + } + __n = __n & 0xff; + *dst_buf = (uint8_t)__n; + dst_buf[1] = src_id; + memcpy(dst_buf + 2,src_buf,__n); + uVar1 = *dst_len + '\x02' + (uint8_t)__n; + } + *dst_len = uVar1; + return __n; +} + + + +int __payload_read(void *p_arg,uint8_t *dst_buf,uint8_t *dst_type,uint8_t *dst_len,uint8_t *src_buf, + uint8_t src_len) + +{ + byte bVar1; + uint8_t *__src; + undefined3 in_register_0000203d; + uint uVar2; + + if (*(char *)((int)p_arg + 8) == '\0') { + if (CONCAT31(in_register_0000203d,src_len) != 5) { + return -2; + } + *dst_len = '\x04'; + __src = src_buf + 1; + *dst_type = *src_buf; + bVar1 = *dst_len; + } + else { + uVar2 = CONCAT31(in_register_0000203d,src_len) - 2; + if (uVar2 != (uint)*src_buf) { + return -2; + } + *dst_len = (uint8_t)uVar2; + __src = src_buf + 2; + *dst_type = src_buf[1]; + bVar1 = *dst_len; + } + memcpy(dst_buf,__src,(uint)bVar1); + return 0; +} + + + +pyld_handle_t pro_payload_init(payload *p_pyld,void *p_drv) + +{ + p_pyld->pfnc = (pro_pyld_func *)0x2308277c; + p_pyld->p_drv = p_drv; + return (pyld_handle_t)p_pyld; +} + + + +cJSON * cJSON_New_Item(void) + +{ + cJSON *__s; + + __s = (cJSON *)(*cJSON_malloc)(0x28); + if (__s != (cJSON *)0x0) { + memset(__s,0,0x28); + } + return __s; +} + + + +char * ensure(printbuffer *p,int needed) + +{ + uint uVar1; + size_t sVar2; + int iVar3; + char *__dest; + + __dest = (char *)0x0; + if ((p != (printbuffer *)0x0) && (__dest = p->buffer, __dest != (char *)0x0)) { + iVar3 = p->offset; + if (p->length < needed + iVar3) { + uVar1 = (needed + iVar3) - 1; + uVar1 = uVar1 | (int)uVar1 >> 1; + uVar1 = uVar1 | (int)uVar1 >> 2; + uVar1 = uVar1 | (int)uVar1 >> 4; + uVar1 = uVar1 | (int)uVar1 >> 8; + sVar2 = (uVar1 | (int)uVar1 >> 0x10) + 1; + __dest = (char *)(*cJSON_malloc)(sVar2); + if (__dest == (char *)0x0) { + (*cJSON_free)(p->buffer); + p->length = 0; + p->buffer = (char *)0x0; + return (char *)0x0; + } + memcpy(__dest,p->buffer,p->length); + (*cJSON_free)(p->buffer); + iVar3 = p->offset; + p->length = sVar2; + p->buffer = __dest; + } + __dest = __dest + iVar3; + } + return __dest; +} + + + +char * cJSON_strdup(char *str) + +{ + size_t sVar1; + char *__dest; + + sVar1 = strlen(str); + __dest = (char *)(*cJSON_malloc)(sVar1 + 1); + if (__dest != (char *)0x0) { + memcpy(__dest,str,sVar1 + 1); + } + return __dest; +} + + + +int update(printbuffer *p) + +{ + int iVar1; + size_t sVar2; + + iVar1 = 0; + if (p != (printbuffer *)0x0) { + iVar1 = 0; + if (p->buffer != (char *)0x0) { + iVar1 = p->offset; + sVar2 = strlen(p->buffer + iVar1); + iVar1 = iVar1 + sVar2; + } + } + return iVar1; +} + + + +char * print_number(cJSON *item,printbuffer *p) + +{ + __gcc_CMPtype _Var1; + char *buffer; + char *extraout_a0; + char *format; + undefined4 uVar2; + undefined4 uVar3; + double in_fa1; + + uVar3 = *(undefined4 *)((int)&item->valuedouble + 4); + uVar2 = *(undefined4 *)&item->valuedouble; + _Var1 = __eqdf2(); + if (_Var1 == 0) { + if (p == (printbuffer *)0x0) { + buffer = (char *)(*cJSON_malloc)(2); + } + else { + buffer = ensure(p,2); + } + if (buffer == (char *)0x0) { + return (char *)0x0; + } + strcpy(buffer,"0"); + return buffer; + } + __floatsidf(item->valueint); + __subdf3(); + fabs(in_fa1); + _Var1 = __ledf2(); + if (((_Var1 < 1) && (_Var1 = __ledf2(), _Var1 < 1)) && (_Var1 = __gedf2(), -1 < _Var1)) { + if (p == (printbuffer *)0x0) { + buffer = (char *)(*cJSON_malloc)(0x15); + } + else { + buffer = ensure(p,0x15); + } + if (buffer == (char *)0x0) { + return (char *)0x0; + } + sprintf(buffer,"%d",item->valueint); + return buffer; + } + if (p == (printbuffer *)0x0) { + in_fa1 = (double)(*cJSON_malloc)(0x40); + buffer = extraout_a0; + } + else { + buffer = ensure(p,0x40); + } + if (buffer == (char *)0x0) { + return (char *)0x0; + } + floor(in_fa1); + __subdf3(); + fabs(in_fa1); + _Var1 = __ledf2(); + if (_Var1 < 1) { + fabs(in_fa1); + _Var1 = __ledf2(); + if (_Var1 < 0) { + format = "%.0f"; + goto LAB_2302e4f2; + } + } + fabs(in_fa1); + _Var1 = __ledf2(); + if (-1 < _Var1) { + fabs(in_fa1); + _Var1 = __gedf2(); + if (_Var1 < 1) { + format = "%f"; + goto LAB_2302e4f2; + } + } + format = "%e"; +LAB_2302e4f2: + sprintf(buffer,format,uVar2,uVar3); + return buffer; +} + + + +char * print_string_ptr(char *str,printbuffer *p) + +{ + char cVar1; + int iVar2; + char *pcVar3; + bool bVar4; + bool bVar5; + byte bVar6; + byte *pbVar7; + char *__dest; + byte *pbVar8; + + bVar5 = false; + __dest = str; + while (cVar1 = *__dest, cVar1 != '\0') { + bVar4 = true; + if ((0x1e < (byte)(cVar1 - 1U)) && (cVar1 != '\"')) { + bVar4 = cVar1 == '\\'; + } + bVar5 = (bool)(bVar5 | bVar4); + __dest = __dest + 1; + } + if (bVar5) { + if (str == (char *)0x0) { + if (p == (printbuffer *)0x0) { + __dest = (char *)(*cJSON_malloc)(3); + } + else { + __dest = ensure(p,3); + } + if (__dest == (char *)0x0) { + return (char *)0x0; + } + strcpy(__dest,"\"\""); + return __dest; + } + iVar2 = 0; + pbVar8 = (byte *)str; + while( true ) { + bVar6 = *pbVar8; + if (bVar6 == 0) break; + __dest = strchr("\"\\\b\f\n\r\t",(uint)bVar6); + if (__dest == (char *)0x0) { + if (bVar6 < 0x20) { + iVar2 = iVar2 + 6; + } + else { + iVar2 = iVar2 + 1; + } + } + else { + iVar2 = iVar2 + 2; + } + pbVar8 = pbVar8 + 1; + } + if (p == (printbuffer *)0x0) { + pcVar3 = (char *)(*cJSON_malloc)(iVar2 + 3U); + } + else { + pcVar3 = ensure(p,iVar2 + 3U); + } + if (pcVar3 == (char *)0x0) { + return (char *)0x0; + } + *pcVar3 = '\"'; + pbVar8 = (byte *)(pcVar3 + 1); + while (bVar6 = *str, bVar6 != 0) { + pbVar7 = (byte *)str + 1; + if (((bVar6 < 0x20) || (bVar6 == 0x22)) || (bVar6 == 0x5c)) { + *pbVar8 = 0x5c; + bVar6 = *str; + if (bVar6 == 0xc) { + pbVar8[1] = 0x66; + pbVar8 = pbVar8 + 2; + str = (char *)pbVar7; + } + else { + if (bVar6 < 0xd) { + if (bVar6 == 9) { + bVar6 = 0x74; + } + else { + if (bVar6 == 10) { + bVar6 = 0x6e; + } + else { + if (bVar6 != 8) goto LAB_2302e750; + bVar6 = 0x62; + } + } + pbVar8[1] = bVar6; + pbVar8 = pbVar8 + 2; + str = (char *)pbVar7; + } + else { + if (bVar6 == 0x22) { + pbVar8[1] = 0x22; + pbVar8 = pbVar8 + 2; + str = (char *)pbVar7; + } + else { + if (bVar6 == 0x5c) { + pbVar8[1] = 0x5c; + pbVar8 = pbVar8 + 2; + str = (char *)pbVar7; + } + else { + if (bVar6 == 0xd) { + pbVar8[1] = 0x72; + pbVar8 = pbVar8 + 2; + str = (char *)pbVar7; + } + else { +LAB_2302e750: + sprintf((char *)(pbVar8 + 1),"u%04x"); + pbVar8 = pbVar8 + 6; + str = (char *)pbVar7; + } + } + } + } + } + } + else { + *pbVar8 = bVar6; + pbVar8 = pbVar8 + 1; + str = (char *)pbVar7; + } + } + *pbVar8 = 0x22; + } + else { + __dest = __dest + -(int)str; + if (p == (printbuffer *)0x0) { + pcVar3 = (char *)(*cJSON_malloc)((size_t)(__dest + 3)); + } + else { + pcVar3 = ensure(p,(int)(__dest + 3)); + } + if (pcVar3 == (char *)0x0) { + return (char *)0x0; + } + *pcVar3 = '\"'; + pbVar8 = (byte *)(pcVar3 + 1 + (int)__dest); + strcpy(pcVar3 + 1,str); + *pbVar8 = 0x22; + } + pbVar8[1] = 0; + return pcVar3; +} + + + +char * print_array(int depth,int fmt,printbuffer *p) + +{ + undefined4 *__dest; + size_t sVar1; + undefined *__dest_00; + char *__s; + int iVar2; + char **__s_00; + size_t __n; + printbuffer *in_a3; + char *pcVar3; + cJSON *item; + int iVar4; + char **ppcVar5; + + __dest = *(undefined4 **)depth; + iVar4 = 0; + while (__dest != (undefined4 *)0x0) { + iVar4 = iVar4 + 1; + __dest = (undefined4 *)*__dest; + } + if (iVar4 == 0) { + if (in_a3 == (printbuffer *)0x0) { + __dest = (undefined4 *)(*cJSON_malloc)(3); + } + else { + __dest = (undefined4 *)ensure(in_a3,3); + } + if (__dest != (undefined4 *)0x0) { + strcpy((char *)__dest,"[]"); + } + } + else { + if (in_a3 == (printbuffer *)0x0) { + __s_00 = (char **)(*cJSON_malloc)(iVar4 << 2); + if (__s_00 != (char **)0x0) { + memset(__s_00,0,iVar4 << 2); + item = *(cJSON **)depth; + iVar2 = 0; + sVar1 = 5; + ppcVar5 = __s_00; + while (item != (cJSON *)0x0) { + if (iVar2 != 0) goto LAB_2302e8b4; + __s = print_value(item,fmt + 1,(int)p,(printbuffer *)0x0); + *ppcVar5 = __s; + if (__s == (char *)0x0) { + iVar2 = 1; + } + else { + __n = strlen(__s); + sVar1 = sVar1 + (uint)(p != (printbuffer *)0x0) + 2 + __n; + } + item = item->next; + ppcVar5 = ppcVar5 + 1; + } + if ((iVar2 == 0) && + (__dest = (undefined4 *)(*cJSON_malloc)(sVar1), __dest != (undefined4 *)0x0)) { + *(undefined *)__dest = 0x5b; + __dest_00 = (undefined *)((int)__dest + 1); + *(undefined *)((int)__dest + 1) = 0; + ppcVar5 = __s_00; + do { + __n = strlen(*ppcVar5); + memcpy(__dest_00,*ppcVar5,__n); + __dest_00 = __dest_00 + __n; + if (iVar4 + -1 != iVar2) { + *__dest_00 = 0x2c; + if (p == (printbuffer *)0x0) { + __dest_00 = __dest_00 + 1; + } + else { + __dest_00[1] = 0x20; + __dest_00 = __dest_00 + 2; + } + *__dest_00 = 0; + } + __s = *ppcVar5; + iVar2 = iVar2 + 1; + ppcVar5 = ppcVar5 + 1; + (*cJSON_free)(__s); + } while (iVar4 != iVar2); + (*cJSON_free)(__s_00); + *__dest_00 = 0x5d; + __dest_00[1] = 0; + } + else { +LAB_2302e8b4: + iVar2 = 0; + do { + if (__s_00[iVar2] != (char *)0x0) { + (*cJSON_free)(__s_00[iVar2]); + } + iVar2 = iVar2 + 1; + } while (iVar4 != iVar2); + __dest = (undefined4 *)0x0; + (*cJSON_free)(__s_00); + } + } + } + else { + iVar4 = in_a3->offset; + __s = ensure(in_a3,1); + if (__s != (char *)0x0) { + *__s = '['; + in_a3->offset = in_a3->offset + 1; + item = *(cJSON **)depth; + while (item != (cJSON *)0x0) { + print_value(item,fmt + 1,(int)p,in_a3); + iVar2 = update(in_a3); + in_a3->offset = iVar2; + if (item->next != (cJSON *)0x0) { + __s = ensure(in_a3,(uint)(p != (printbuffer *)0x0) + 2); + if (__s == (char *)0x0) { + return (char *)0x0; + } + *__s = ','; + pcVar3 = __s + 1; + if (p != (printbuffer *)0x0) { + pcVar3 = __s + 2; + __s[1] = ' '; + } + *pcVar3 = '\0'; + in_a3->offset = in_a3->offset + (uint)(p != (printbuffer *)0x0) + 1; + } + item = item->next; + } + __s = ensure(in_a3,2); + if (__s != (char *)0x0) { + *__s = ']'; + __s[1] = '\0'; + __dest = (undefined4 *)(in_a3->buffer + iVar4); + } + } + } + } + return (char *)__dest; +} + + + +char * print_value(cJSON *item,int depth,int fmt,printbuffer *p) + +{ + char *str; + char *__src; + + if (item == (cJSON *)0x0) { + return (char *)0x0; + } + if (p != (printbuffer *)0x0) { + switch(*(undefined *)&item->type) { + case 0: + str = ensure(p,6); + if (str == (char *)0x0) { + return (char *)0x0; + } + __src = "false"; + break; + case 1: + str = ensure(p,5); + if (str == (char *)0x0) { + return (char *)0x0; + } + __src = "true"; + break; + case 2: + str = ensure(p,5); + if (str == (char *)0x0) { + return (char *)0x0; + } + __src = "null"; + break; + case 3: +LAB_2302ea06: + str = print_number(item,p); + return str; + case 4: +LAB_2302ea14: + str = print_string_ptr(item->valuestring,p); + return str; + case 5: +switchD_2302e9b4_caseD_5: + str = print_array((int)&item->child,depth,(printbuffer *)fmt); + return str; + case 6: +switchD_2302e9b4_caseD_6: + str = print_object((int)&item->child,depth,(printbuffer *)fmt); + return str; + default: +LAB_2302e9ce: + return (char *)0x0; + } + strcpy(str,__src); + return str; + } + switch(*(undefined *)&item->type) { + case 0: + str = "false"; + break; + case 1: + str = "true"; + break; + case 2: + str = "null"; + break; + case 3: + p = (printbuffer *)0x0; + goto LAB_2302ea06; + case 4: + p = (printbuffer *)0x0; + goto LAB_2302ea14; + case 5: + goto switchD_2302e9b4_caseD_5; + case 6: + goto switchD_2302e9b4_caseD_6; + default: + goto LAB_2302e9ce; + } + str = cJSON_strdup(str); + return str; +} + + + +char * print_object(int depth,int fmt,printbuffer *p) + +{ + size_t sVar1; + char *__s; + size_t sVar2; + char **__s_00; + char **__s_01; + size_t sVar3; + char *__dest; + printbuffer *in_a3; + int *piVar4; + char *__s_02; + int iVar5; + char **ppcVar6; + int needed; + int needed_00; + int needed_01; + char **ppcVar7; + size_t __n; + cJSON *item; + char **ppcStack88; + + piVar4 = *(int **)depth; + needed_00 = 0; + while (piVar4 != (int *)0x0) { + needed_00 = needed_00 + 1; + piVar4 = (int *)*piVar4; + } + if (needed_00 == 0) { + if (in_a3 == (printbuffer *)0x0) { + sVar2 = 3; + if (p != (printbuffer *)0x0) { + sVar2 = fmt + 4; + } + __s = (char *)(*cJSON_malloc)(sVar2); + } + else { + needed_00 = 3; + if (p != (printbuffer *)0x0) { + needed_00 = fmt + 4; + } + __s = ensure(in_a3,needed_00); + } + if (__s != (char *)0x0) { + *__s = '{'; + __s_02 = __s + 1; + if (p != (printbuffer *)0x0) { + __s[1] = '\n'; + __s_02 = __s + 2; + while ((int)(__s_02 + (-2 - (int)__s)) < fmt + -1) { + *__s_02 = '\t'; + __s_02 = __s_02 + 1; + } + } + *__s_02 = '}'; + __s_02[1] = '\0'; + return __s; + } + } + else { + if (in_a3 == (printbuffer *)0x0) { + __n = needed_00 << 2; + __s_00 = (char **)(*cJSON_malloc)(__n); + if (__s_00 != (char **)0x0) { + __s_01 = (char **)(*cJSON_malloc)(__n); + if (__s_01 != (char **)0x0) { + memset(__s_00,0,__n); + memset(__s_01,0,__n); + item = *(cJSON **)depth; + if (p == (printbuffer *)0x0) { + sVar2 = 7; + needed = 0; + } + else { + sVar2 = fmt + 8; + needed = fmt + 3; + } + needed_01 = 0; + ppcVar6 = __s_00; + ppcStack88 = __s_01; + while (item != (cJSON *)0x0) { + __s = print_string_ptr(item->string,(printbuffer *)0x0); + *ppcStack88 = __s; + __s_02 = print_value(item,fmt + 1,(int)p,(printbuffer *)0x0); + *ppcVar6 = __s_02; + if ((__s == (char *)0x0) || (__s_02 == (char *)0x0)) { + needed_01 = 1; + } + else { + sVar1 = strlen(__s_02); + sVar3 = strlen(__s); + sVar2 = needed + 2 + sVar2 + sVar1 + sVar3; + } + item = item->next; + ppcVar6 = ppcVar6 + 1; + ppcStack88 = ppcStack88 + 1; + } + if ((needed_01 == 0) && (__s = (char *)(*cJSON_malloc)(sVar2), __s != (char *)0x0)) { + *__s = '{'; + __s_02 = __s + 1; + if (p != (printbuffer *)0x0) { + __s_02 = __s + 2; + __s[1] = '\n'; + } + *__s_02 = '\0'; + needed = 0; + ppcVar6 = __s_00; + ppcVar7 = __s_01; + do { + __dest = __s_02; + if (p != (printbuffer *)0x0) { + iVar5 = 0; + while (__dest = __s_02 + iVar5, iVar5 < fmt + 1) { + *__dest = '\t'; + iVar5 = iVar5 + 1; + } + } + __n = strlen(*ppcVar7); + memcpy(__dest,*ppcVar7,__n); + __dest = __dest + __n; + *__dest = ':'; + __s_02 = __dest + 1; + if (p != (printbuffer *)0x0) { + __s_02 = __dest + 2; + __dest[1] = '\t'; + } + strcpy(__s_02,*ppcVar6); + __n = strlen(*ppcVar6); + __s_02 = __s_02 + __n; + if (needed_00 + -1 != needed) { + *__s_02 = ','; + __s_02 = __s_02 + 1; + } + if (p != (printbuffer *)0x0) { + *__s_02 = '\n'; + __s_02 = __s_02 + 1; + } + *__s_02 = '\0'; + __dest = *ppcVar7; + needed = needed + 1; + ppcVar7 = ppcVar7 + 1; + (*cJSON_free)(__dest); + __dest = *ppcVar6; + ppcVar6 = ppcVar6 + 1; + (*cJSON_free)(__dest); + } while (needed_00 != needed); + (*cJSON_free)(__s_01); + (*cJSON_free)(__s_00); + if (p != (printbuffer *)0x0) { + while (needed_01 < fmt) { + __s_02[needed_01] = '\t'; + needed_01 = needed_01 + 1; + } + if (fmt < 0) { + fmt = 0; + } + __s_02 = __s_02 + fmt; + } + *__s_02 = '}'; + __s_02[1] = '\0'; + return __s; + } + sVar1 = 0; + do { + if (*(void **)((int)__s_01 + sVar1) != (void *)0x0) { + (*cJSON_free)(*(void **)((int)__s_01 + sVar1)); + } + if (*(void **)((int)__s_00 + sVar1) != (void *)0x0) { + (*cJSON_free)(*(void **)((int)__s_00 + sVar1)); + } + sVar1 = sVar1 + 4; + } while (__n != sVar1); + (*cJSON_free)(__s_01); + } + (*cJSON_free)(__s_00); + } + } + else { + needed = (uint)(p != (printbuffer *)0x0) + 1; + needed_00 = in_a3->offset; + __s = ensure(in_a3,(uint)(p != (printbuffer *)0x0) + 2); + if (__s != (char *)0x0) { + *__s = '{'; + __s_02 = __s + 1; + if (p != (printbuffer *)0x0) { + __s_02 = __s + 2; + __s[1] = '\n'; + } + *__s_02 = '\0'; + needed_01 = fmt + 1; + in_a3->offset = in_a3->offset + needed; + item = *(cJSON **)depth; + while (item != (cJSON *)0x0) { + if (p != (printbuffer *)0x0) { + __s = ensure(in_a3,needed_01); + if (__s == (char *)0x0) { + return (char *)0x0; + } + iVar5 = 0; + while (iVar5 < needed_01) { + __s[iVar5] = '\t'; + iVar5 = iVar5 + 1; + } + in_a3->offset = in_a3->offset + needed_01; + } + print_string_ptr(item->string,in_a3); + iVar5 = update(in_a3); + in_a3->offset = iVar5; + __s = ensure(in_a3,needed); + if (__s == (char *)0x0) { + return (char *)0x0; + } + *__s = ':'; + if (p != (printbuffer *)0x0) { + __s[1] = '\t'; + } + in_a3->offset = in_a3->offset + needed; + print_value(item,needed_01,(int)p,in_a3); + iVar5 = update(in_a3); + in_a3->offset = iVar5; + iVar5 = (uint)(item->next != (cJSON *)0x0) + (uint)(p != (printbuffer *)0x0); + __s = ensure(in_a3,iVar5 + 1); + if (__s == (char *)0x0) { + return (char *)0x0; + } + if (item->next != (cJSON *)0x0) { + *__s = ','; + __s = __s + 1; + } + if (p != (printbuffer *)0x0) { + *__s = '\n'; + __s = __s + 1; + } + *__s = '\0'; + in_a3->offset = iVar5 + in_a3->offset; + item = item->next; + } + needed = 2; + if (p != (printbuffer *)0x0) { + needed = fmt + 2; + } + __s = ensure(in_a3,needed); + if (__s != (char *)0x0) { + if (p != (printbuffer *)0x0) { + needed_00 = 0; + while (needed_00 < fmt) { + __s[needed_00] = '\t'; + needed_00 = needed_00 + 1; + } + if (fmt < 0) { + fmt = 0; + } + __s = __s + fmt; + needed_00 = fmt; + } + *__s = '}'; + __s[1] = '\0'; + return in_a3->buffer + needed_00; + } + } + } + } + return (char *)0x0; +} + + + +void cJSON_InitHooks(cJSON_Hooks *hooks) + +{ + code *pcVar1; + + if (hooks == (cJSON_Hooks *)0x0) { + cJSON_malloc = malloc; + } + else { + pcVar1 = hooks->malloc_fn; + if (pcVar1 == (anon_subr_void_ptr_size_t *)0x0) { + pcVar1 = malloc; + } + cJSON_malloc = pcVar1; + if (hooks->free_fn != (anon_subr_void_void_ptr_for_free_fn *)0x0) { + cJSON_free = (anon_subr_void_void_ptr *)hooks->free_fn; + return; + } + } + cJSON_free = free; + return; +} + + + +void cJSON_Delete(cJSON *c) + +{ + cJSON *pcVar1; + + while (c != (cJSON *)0x0) { + pcVar1 = c->next; + if (((c->type & 0x100U) == 0) && + (((c->child == (cJSON *)0x0 || (cJSON_Delete(c->child), (c->type & 0x100U) == 0)) && + (c->valuestring != (char *)0x0)))) { + (*cJSON_free)(c->valuestring); + } + if (((c->type & 0x200U) == 0) && (c->string != (char *)0x0)) { + (*cJSON_free)(c->string); + } + (*cJSON_free)(c); + c = pcVar1; + } + return; +} + + + +char * cJSON_Print(cJSON *item) + +{ + char *pcVar1; + + pcVar1 = print_value(item,0,1,(printbuffer *)0x0); + return pcVar1; +} + + + +void cJSON_AddItemToArray(cJSON *array,cJSON *item) + +{ + cJSON *pcVar1; + cJSON *pcVar2; + + if (item != (cJSON *)0x0) { + pcVar1 = array->child; + if (array->child == (cJSON *)0x0) { + array->child = item; + return; + } + do { + pcVar2 = pcVar1; + pcVar1 = pcVar2->next; + } while (pcVar2->next != (cJSON *)0x0); + pcVar2->next = item; + item->prev = pcVar2; + } + return; +} + + + +void cJSON_AddItemToObject(cJSON *object,char *string,cJSON *item) + +{ + char *pcVar1; + + if (item != (cJSON *)0x0) { + if (item->string != (char *)0x0) { + (*cJSON_free)(item->string); + } + pcVar1 = cJSON_strdup(string); + item->string = pcVar1; + cJSON_AddItemToArray(object,item); + return; + } + return; +} + + + +cJSON * cJSON_CreateNumber(void) + +{ + undefined4 in_a0; + cJSON *pcVar1; + SItype SVar2; + undefined4 in_a1; + + pcVar1 = cJSON_New_Item(); + if (pcVar1 != (cJSON *)0x0) { + pcVar1->type = 3; + *(undefined4 *)&pcVar1->valuedouble = in_a0; + *(undefined4 *)((int)&pcVar1->valuedouble + 4) = in_a1; + SVar2 = __fixdfsi(); + pcVar1->valueint = SVar2; + } + return pcVar1; +} + + + +cJSON * cJSON_CreateString(char *string) + +{ + cJSON *pcVar1; + char *pcVar2; + + pcVar1 = cJSON_New_Item(); + if (pcVar1 != (cJSON *)0x0) { + pcVar1->type = 4; + pcVar2 = cJSON_strdup(string); + pcVar1->valuestring = pcVar2; + } + return pcVar1; +} + + + +cJSON * cJSON_CreateObject(void) + +{ + cJSON *pcVar1; + + pcVar1 = cJSON_New_Item(); + if (pcVar1 != (cJSON *)0x0) { + pcVar1->type = 6; + } + return pcVar1; +} + + + +cli_command * cli_command_get(int idx,int *is_static_cmd) + +{ + cli_st *pcVar1; + cli_command *pcVar2; + + pcVar1 = cli; + pcVar2 = (cli_command *)0xffffffff; + if (-1 < idx) { + pcVar2 = (cli_command *)0xffffffff; + if ((uint)idx < cli->num_static_cmds + 8) { + if ((uint)idx < cli->num_static_cmds) { + if (is_static_cmd != (int *)0x0) { + *is_static_cmd = 1; + } + pcVar2 = pcVar1->static_cmds + idx; + } + else { + if (is_static_cmd != (int *)0x0) { + *is_static_cmd = 0; + } + pcVar2 = pcVar1->dynamic_cmds[idx - pcVar1->num_static_cmds]; + } + } + } + return pcVar2; +} + + + +void exit_cmd(char *buf,int len,int argc,char **argv) + +{ + cliexit = 1; + return; +} + + + +int cb_idnoe(void *arg,inode_t *node) + +{ + uint8_t uVar1; + char *pcVar2; + undefined4 uVar3; + + if (*(int *)arg == 0) { + *(undefined4 *)arg = 1; + printf("\tSize\t\t\t\t\t Name\t\t\tFiletype\r\n"); + printf("----------------------------------------------------------------------------------\r\n") + ; + } + uVar1 = node->type; + uVar3 = 0x1c; + if ((1 < (byte)(uVar1 - 1)) && (uVar3 = 0x50, uVar1 != '\x03')) { + uVar3 = 0; + } + if (uVar1 == '\x01') { + pcVar2 = "Char Device"; + } + else { + if (uVar1 == '\x02') { + pcVar2 = "Block Device"; + } + else { + if (uVar1 == '\x03') { + pcVar2 = "File System"; + } + else { + pcVar2 = "Unknown"; + } + } + } + printf("%10d\t\t%30s\t\t\t%s\r\n",uVar3,node->i_name,pcVar2); + return 0; +} + + + +void ota_cmd(char *buf,int len,int argc,char **argv) + +{ + aos_task_new("LOCAL OTA",tftp_ota_thread,(void *)0x0,0x1000); + return; +} + + + +void tftp_ota_thread(void *arg) + +{ + aos_task_exit(0); + return; +} + + + +void cat_cmd(char *buf,int len,int argc,char **argv) + +{ + int fd; + ssize_t sVar1; + byte local_11 [4]; + char ch; + + if (argc != 2) { + printf("invalid parameter!\r\n"); + } + fd = aos_open(argv[1],0); + if (fd < 0) { + printf("open %s failed!\r\n",argv[1]); + } + else { + while (sVar1 = aos_read(fd,local_11,1), sVar1 == 1) { + printf("%c",(uint)local_11[0]); + } + printf("\r\n"); + aos_close(fd); + } + return; +} + + + +void hexdump_cmd(char *buf,int len,int argc,char **argv) + +{ + int fd; + void *local_18; + romfs_filebuf_t filebuf; + + if (argc != 2) { + printf("invalid parameter!\r\n"); + } + fd = aos_open(argv[1],0); + if (fd < 0) { + printf("open %s failed!\r\n",argv[1]); + } + else { + memset(&local_18,0,8); + aos_ioctl(fd,1,(ulong)&local_18); + printf("Found file %s. XIP Addr %p, len %lu\r\n",argv[1],local_18,filebuf.buf); + utils_hexdump(local_18,(uint)filebuf.buf); + aos_close(fd); + } + return; +} + + + +int aos_cli_init(int use_thread) + +{ + cli_st *pcVar1; + int iVar2; + + cli = (cli_st *)aos_malloc(0x244); + iVar2 = 0xc; + if (cli != (cli_st *)0x0) { + memset(cli,0,0x244); + pcVar1 = cli; + cli->static_cmds = cmds_user; + pcVar1->echo_disabled = 0; + pcVar1->num_static_cmds = 0x5b; + pcVar1->num_commands = 0x5b; + pcVar1->initialized = 1; + iVar2 = 0; + } + return iVar2; +} + + + +void * aos_cli_event_cb_read_get(void) + +{ + return console_cb_read; +} + + + +int cli_putstr(char *msg) + +{ + int iVar1; + size_t sVar2; + ssize_t sVar3; + + sVar2 = strlen(msg); + iVar1 = 0; + while ((iVar1 < (int)sVar2 && + (sVar3 = aos_write(fd_console,msg + iVar1,sVar2 - iVar1), -1 < sVar3))) { + iVar1 = iVar1 + sVar3; + } + return 0; +} + + + +void ps_cmd(char *buf,int len,int argc,char **argv) + +{ + char *__dest; + char *__dest_00; + size_t sVar1; + int iVar2; + + __dest_00 = (char *)pvPortMalloc(0x600); + if (__dest_00 != (char *)0x0) { + strcpy(__dest_00,"Task"); + sVar1 = strlen(__dest_00); + __dest = __dest_00 + sVar1; + sVar1 = strlen("Task"); + iVar2 = sVar1 - (int)__dest; + while ((int)(__dest + iVar2) < 0xd) { + *__dest = ' '; + __dest = __dest + 1; + *__dest = '\0'; + } + strcpy(__dest, + "State Priority Stack # Base\r\n********************************************************\r\n" + ); + sVar1 = strlen( + "State Priority Stack # Base\r\n********************************************************\r\n" + ); + vTaskList(__dest + sVar1); + cli_putstr(__dest_00); + vPortFree(__dest_00); + return; + } + return; +} + + + +int aos_cli_printf(char *msg,...) + +{ + size_t sVar1; + int iVar2; + undefined4 in_a1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list ap; + char message [256]; + undefined4 uStack28; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack28 = in_a1; + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + memset(&ap,0,0x100); + sVar1 = 0; + if (esc_tag_len != '\0') { + strcpy((char *)&ap,esc_tag); + sVar1 = strlen(esc_tag); + } + iVar2 = vsnprintf((char *)((int)&ap + sVar1),0x100 - sVar1,msg,&uStack28); + if (0 < iVar2) { + cli_putstr((char *)&ap); + } + return 0; +} + + + +int proc_onecmd(int argc,char **argv) + +{ + cli_st *pcVar1; + cli_st *pcVar2; + char *__s1; + cli_command *pcVar3; + int iVar4; + uint idx; + uint uVar5; + char *__n; + char *__s2; + + if (argc < 1) { + return 0; + } + if (cli->echo_disabled == 0) { + printf("\r\n"); + } + __n = (char *)0x0; + __s1 = strchr(*argv,0x2e); + __s2 = *argv; + if (__s1 != (char *)0x0) { + __n = __s1 + -(int)__s2; + } + idx = 0; + uVar5 = 0; + while( true ) { + if (cli->num_static_cmds + 8 <= idx) { + return 1; + } + if (cli->num_commands <= uVar5) break; + pcVar3 = cli_command_get(idx,(int *)0x0); + __s1 = pcVar3->name; + if (__s1 != (char *)0x0) { + if (__n == (char *)0x0) { + iVar4 = strcmp(__s1,__s2); + } + else { + iVar4 = strncmp(__s1,__s2,(size_t)__n); + } + pcVar1 = cli; + if (iVar4 == 0) { + __s1 = (char *)aos_malloc(0x200); + pcVar2 = cli; + pcVar1->outbuf = __s1; + if (pcVar2->outbuf == (char *)0x0) { + aos_cli_printf("Error! cli alloc mem fail!\r\n"); + return 1; + } + memset(pcVar2->outbuf,0,0x200); + (*pcVar3->function)(cli->outbuf,0x200,argc,argv); + aos_cli_printf("%s",cli->outbuf); + aos_free(cli->outbuf); + cli->outbuf = (char *)0x0; + return 0; + } + uVar5 = uVar5 + 1; + } + idx = idx + 1; + } + return 1; +} + + + +void ls_cmd(char *buf,int len,int argc,char **argv) + +{ + stat *st; + int iVar1; + aos_dir_t *dir; + aos_dirent_t *paVar2; + char *msg; + size_t __n; + size_t sVar3; + undefined4 uStack180; + int env; + char path_name [128]; + + uStack180 = 0; + st = (stat *)pvPortMalloc(0x58); + memset(stat,0,0x58); + memset(&env,0,0x80); + if (argc == 2) { + iVar1 = strcmp(argv[1],"/sdcard"); + if (iVar1 == 0) { + dir = aos_opendir("/sdcard"); + if (dir == (aos_dir_t *)0x0) { + msg = "can not open sdcard\r\n"; +LAB_2302f604: + printf(msg); + goto LAB_2302f5de; + } + printf("\tSize\t\t\t\t\t Name\t\t\tFiletype\r\n"); + printf( + "----------------------------------------------------------------------------------\r\n" + ); + while (paVar2 = aos_readdir(dir), paVar2 != (aos_dirent_t *)0x0) { + snprintf((char *)&env,0x7f,"/sdcard/%s",&paVar2->field_0x5); + iVar1 = aos_stat((char *)&env,st); + if (iVar1 == 0) { + iVar1 = -0x6a8; + if (-1 < (int)(st->st_mode << 0x11)) { + iVar1 = -0x68c; + } + printf("Warning: Moved an ENV (size %d) failed when recovery. Now will GC then retry.\r\n" + + iVar1 + 0x38,st->st_size,&paVar2->field_0x5); + } + } + } + else { + msg = argv[1]; + __n = strlen("/romfs"); + iVar1 = memcmp(msg,"/romfs",__n); + if (iVar1 != 0) { + iVar1 = strcmp(argv[1],"/"); + if (iVar1 != 0) { + msg = "un-supported direcotry!\r\n"; + goto LAB_2302f72a; + } + goto LAB_2302f712; + } + dir = aos_opendir(argv[1]); + if (dir == (aos_dir_t *)0x0) { + msg = "can not open romfs\r\n"; + goto LAB_2302f604; + } + printf("\tSize\t\t\t\t\t Name\t\t\tFiletype\r\n"); + printf( + "----------------------------------------------------------------------------------\r\n" + ); + while (paVar2 = aos_readdir(dir), paVar2 != (aos_dirent_t *)0x0) { + memset(&env,0,0x80); + snprintf((char *)&env,0x7f,"%s",argv[1]); + __n = strlen((char *)&env); + if (*(char *)((int)&uStack180 + __n + 3) != '/') { + __n = strlen((char *)&env); + *(undefined *)((int)&env + __n) = 0x2f; + } + __n = strlen((char *)&env); + sVar3 = strlen((char *)&env); + snprintf((char *)((int)&env + __n),0x7f - sVar3,"%s",&paVar2->field_0x5); + iVar1 = aos_stat((char *)&env,st); + if (iVar1 == 0) { + iVar1 = -0x6a8; + if (-1 < (int)(st->st_mode << 0x11)) { + iVar1 = -0x68c; + } + printf("Warning: Moved an ENV (size %d) failed when recovery. Now will GC then retry.\r\n" + + iVar1 + 0x38,st->st_size,&paVar2->field_0x5); + } + } + } + aos_closedir(dir); + } + else { + if (argc != 1) { + msg = "invalid parameter!\r\n"; +LAB_2302f72a: + aos_cli_printf(msg); + goto LAB_2302f5de; + } +LAB_2302f712: + inode_forearch_name(cb_idnoe,&uStack180); + } +LAB_2302f5de: + vPortFree(st); + return; +} + + + +void uptime_cmd(char *buf,int len,int argc,char **argv) + +{ + char *pcVar1; + char *pcVar2; + int iVar3; + int iVar4; + longlong lVar5; + DItype DVar6; + + lVar5 = aos_now_ms(); + aos_cli_printf("UP time in ms %llu\r\n",buf,len,(int)lVar5); + pcVar1 = buf; + iVar3 = len; + __divdi3(); + __moddi3(); + pcVar2 = buf; + iVar4 = len; + __divdi3(); + __moddi3(); + __divdi3(); + __divdi3(); + DVar6 = __moddi3(); + aos_cli_printf("UP time in %llu days, %llu hours, %llu minutes, %llu seconds\r\n",buf,len,pcVar2, + iVar4,pcVar1,iVar3,(int)DVar6); + return; +} + + + +void reset_cmd(char *buf,int len,int argc,char **argv) + +{ + aos_cli_printf("system reset\r\n"); + hal_sys_reset(); + return; +} + + + +void poweroff_cmd(char *buf,int len,int argc,char **argv) + +{ + aos_cli_printf("poweroff\r\n"); + hal_poweroff(); + return; +} + + + +void reboot_cmd(char *buf,int len,int argc,char **argv) + +{ + aos_cli_printf("reboot\r\n"); + hal_reboot(); + return; +} + + + +// WARNING: Variable defined which should be unmapped: desc + +void version_cmd(char *buf,int len,int argc,char **argv) + +{ + int iVar1; + size_t sVar2; + int iStack76; + int num; + uint addr [4]; + uint size [4]; + char desc [4] [6]; + + iStack76 = 4; + aos_cli_printf("kernel version :posix\r\n"); + aos_cli_printf("release_bl_iot_sdk_1.6.11-1-g66bb28da-dirty"); + aos_cli_printf("\r\n"); + iVar1 = bl_chip_memory_ram(&iStack76,(uint *)&num,addr + 3,(char (*) [6])(size + 3)); + if (iVar1 == 0) { + aos_cli_printf("Memory Configuration on %d banks:\r\n",iStack76); + while (iVar1 < iStack76) { + aos_cli_printf(" [%d]%6s %6u Kbytes @ %p\r\n",iVar1,(int)size + iVar1 * 6 + 0xc, + addr[iVar1 + 3] >> 10,(&num)[iVar1]); + iVar1 = iVar1 + 1; + } + } + sVar2 = xPortGetFreeHeapSize(); + aos_cli_printf("Heap left: %d Bytes\r\n",sVar2); + return; +} + + + +void devname_cmd(char *buf,int len,int argc,char **argv) + +{ + aos_cli_printf("device name: %s\r\n",&UNK_23077830); + return; +} + + + +void echo_cmd(char *buf,int len,int argc,char **argv) + +{ + int iVar1; + char *pcVar2; + + if (argc == 1) { + if (cli->echo_disabled == 0) { + pcVar2 = "Enabled"; + } + else { + pcVar2 = "Disabled"; + } + aos_cli_printf("Usage: echo on/off. Echo is currently %s\r\n",pcVar2); + return; + } + iVar1 = strcmp(argv[1],"on"); + if (iVar1 == 0) { + aos_cli_printf("Enable echo\r\n"); + cli->echo_disabled = 0; + } + else { + iVar1 = strcmp(argv[1],"off"); + if (iVar1 == 0) { + aos_cli_printf("Disable echo\r\n"); + cli->echo_disabled = 1; + } + } + return; +} + + + +void mmem_cmd(char *buf,int len,int argc,char **argv) + +{ + uint uVar1; + int iVar2; + uint uVar3; + + if (argc == 3) { + iVar2 = 4; +LAB_2302f9c2: + uVar1 = strtol(argv[2],(char **)0x0,0); + } + else { + if (argc == 4) { + iVar2 = strtol(argv[3],(char **)0x0,0); + goto LAB_2302f9c2; + } + if (argc != 2) goto LAB_2302f9e0; + uVar1 = 0; + iVar2 = 4; + } + len = strtol(argv[1],(char **)0x0,0); + if ((uint *)len != (uint *)0x0) { + if (iVar2 == 1) { + uVar3 = (uint)*(byte *)len; + *(byte *)len = (byte)uVar1; + uVar1 = (uint)*(byte *)len; + } + else { + if (iVar2 == 2) { + uVar3 = (uint)*(ushort *)len; + *(ushort *)len = (ushort)uVar1; + uVar1 = (uint)*(ushort *)len; + } + else { + uVar3 = *(uint *)len; + *(uint *)len = uVar1; + uVar1 = *(uint *)len; + } + } + aos_cli_printf("value on 0x%x change from 0x%x to 0x%x.\r\n",len,uVar3,uVar1); + return; + } +LAB_2302f9e0: + aos_cli_printf( + "m \r\naddr : address to modify\r\nvalue : new value (default is 0)\r\nwidth : width of unit, 1/2/4 (default is 4)\r\n" + ,len); + return; +} + + + +void pmem_cmd(char *buf,int len,int argc,char **argv) + +{ + ushort uVar1; + undefined4 *puVar2; + int iVar3; + undefined4 uVar4; + long lVar5; + uint uVar6; + char *pcStack52; + char *pos; + + pcStack52 = (char *)0x0; + if (argc == 3) { + lVar5 = 4; +LAB_2302fad2: + iVar3 = strtol(argv[2],(char **)0x0,0); + if (0x400 < iVar3) { + iVar3 = 0x400; + } + } + else { + if (argc == 4) { + lVar5 = strtol(argv[3],(char **)0x0,0); + goto LAB_2302fad2; + } + lVar5 = 4; + iVar3 = 0x10; + puVar2 = (undefined4 *)0x0; + if (argc != 2) goto LAB_2302fa96; + } + puVar2 = (undefined4 *)strtol(argv[1],&pcStack52,0); +LAB_2302fa96: + if ((pcStack52 == (char *)0x0) || (pcStack52 == argv[1])) { + aos_cli_printf( + "p \r\naddr : address to display\r\nnunits: number of units to display (default is 16)\r\nwidth : width of unit, 1/2/4 (default is 4)\r\n" + ); + } + else { + if (lVar5 == 1) { + uVar6 = 0; + while ((int)uVar6 < iVar3) { + if ((uVar6 & 0xf) == 0) { + aos_cli_printf("0x%08x:",(byte *)((int)puVar2 + uVar6)); + } + aos_cli_printf(" %02x",(uint)*(byte *)((int)puVar2 + uVar6)); + if ((uVar6 & 0xf) == 0xf) { + aos_cli_printf("\r\n"); + } + uVar6 = uVar6 + 1; + } + } + else { + if (lVar5 == 2) { + uVar6 = 0; + while ((int)uVar6 < iVar3) { + if ((uVar6 & 7) == 0) { + aos_cli_printf("0x%08x:",puVar2); + } + uVar1 = *(ushort *)puVar2; + puVar2 = (undefined4 *)((int)puVar2 + 2); + aos_cli_printf(" %04x",(uint)uVar1); + if ((uVar6 & 7) == 7) { + aos_cli_printf("\r\n"); + } + uVar6 = uVar6 + 1; + } + } + else { + uVar6 = 0; + while ((int)uVar6 < iVar3) { + if ((uVar6 & 3) == 0) { + aos_cli_printf("0x%08x:",puVar2); + } + uVar4 = *puVar2; + puVar2 = puVar2 + 1; + aos_cli_printf(" %08x",uVar4); + if ((uVar6 & 3) == 3) { + aos_cli_printf("\r\n"); + } + uVar6 = uVar6 + 1; + } + } + } + } + return; +} + + + +void help_cmd(char *buf,int len,int argc,char **argv) + +{ + cli_command *pcVar1; + uint idx; + undefined *puVar2; + char *pcVar3; + uint uVar4; + + aos_cli_printf("====Build-in Commands====\r\n"); + pcVar1 = built_ins; + aos_cli_printf("====Support %d cmds once, seperate by ; ====\r\n",4); + do { + if (((cfg_element_entry *)pcVar1)->task != 0) { + puVar2 = *(undefined **)&((cfg_element_entry *)pcVar1)->element; + if (*(undefined **)&((cfg_element_entry *)pcVar1)->element == (undefined *)0x0) { + puVar2 = &DAT_2307cef0; + } + aos_cli_printf("%-25s: %s\r\n",puVar2); + } + pcVar1 = (cli_command *)&((cfg_element_entry *)pcVar1)->val; + } while ((cfg_element_entry *)pcVar1 != cfg_entrys_mm); + aos_cli_printf("\r\n"); + aos_cli_printf("====User Commands====\r\n"); + uVar4 = 0x10; + idx = 0; + while ((idx < cli->num_static_cmds + 8 && (uVar4 < cli->num_commands))) { + pcVar1 = cli_command_get(idx,(int *)0x0); + if (((pcVar1 < built_ins) || ((cli_command *)((int)&built_ins[0xf].function + 3U) < pcVar1)) && + (pcVar1->name != (char *)0x0)) { + pcVar3 = pcVar1->help; + if (pcVar1->help == (char *)0x0) { + pcVar3 = ""; + } + aos_cli_printf("%-25s: %s\r\n",pcVar3); + uVar4 = uVar4 + 1; + } + idx = idx + 1; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int cli_getchar(char *inbuf) + +{ + int32_t iVar1; + uint uVar2; + uint32_t local_50; + uint32_t recv_size; + uart_dev_t uart_stdio; + + local_50 = 0; + memset(&recv_size,0,0x3c); + recv_size._0_1_ = '\0'; + iVar1 = hal_uart_recv_II((uart_dev_t *)&recv_size,inbuf,1,&local_50,0xffffffff); + if (iVar1 == 0) { + uVar2 = (uint)(local_50 == 1); + } + else { + uVar2 = 0; + } + return uVar2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void cli_main_input(char *buffer,int count) + +{ + byte bVar1; + char cVar2; + cli_st *pcVar3; + cli_st *pcVar4; + uint8_t uVar5; + anon_struct *paVar6; + undefined1 *argv; + size_t __n; + cli_command *pcVar7; + uint uVar8; + char *__s1; + char *__s; + anon_struct aVar9; + int iVar10; + byte *__src; + char *__s_00; + uint idx; + int iVar11; + size_t __n_00; + int iVar12; + uint uStack84; + anon_struct stat; + char c; + + pcVar3 = cli; + __s1 = cli->inbuf; + if (__s1 == (char *)0x0) { + __s1 = "inbuf_null\r\n"; +LAB_2302fe04: + aos_cli_printf(__s1); + return; + } + iVar11 = 0; + uVar5 = esc_tag_len; +LAB_2302fd26: + esc_tag_len = uVar5; + if (buffer == (char *)0x0) { + iVar12 = cli_getchar((char *)&stat); + if (iVar12 != 1) { + return; + } + } + else { + if (count <= iVar11) { + return; + } + __src = (byte *)(buffer + iVar11); + iVar11 = iVar11 + 1; + stat = (anon_struct)((uint)stat & 0xffffff00 | (uint)*__src); + } + pcVar4 = cli; + cVar2 = key1_4388; + if ((stat._0_1_ != '\n') && (stat._0_1_ != '\r')) { + uVar5 = esc_tag_len; + if (stat._0_1_ == '\x1b') { + esc_4387 = '\x01'; + key1_4388 = -1; + key2_4389 = -1; + } + else { + if (esc_4387 != '\0') { + if (key1_4388 < '\0') { + __s = (char *)(int)stat._0_1_; + key1_4388 = stat._0_1_; + if (__s == (char *)0x5b) goto LAB_2302fd26; + __s1[pcVar3->bp] = '\x1b'; + idx = pcVar3->bp + 1; + pcVar3->bp = idx; + __s1[idx] = stat._0_1_; + pcVar3->bp = pcVar3->bp + 1; + if (cli->echo_disabled == 0) { + __s_00 = "\x1b%c"; +LAB_2302fe8e: + printf(__s_00,__s); + } + } + else { + if ((key2_4389 < '\0') && (key2_4389 = stat._0_1_, stat._0_1_ == 't')) { + esc_tag[0] = '\x1b'; + esc_tag[1] = key1_4388; + esc_tag_len = '\x02'; + } + idx = SEXT14(key2_4389); + if (((idx & 0xff) - 0x41 & 0xff) < 2) { + __s_00 = __s1; + if (idx == 0x41) { + iVar10 = cli->his_idx; + iVar12 = iVar10; + do { + iVar12 = (iVar12 + 0xff) % 0x100; + if (cli->history[iVar12] != '\0') { + if (iVar10 != iVar12) { + do { + iVar12 = (iVar12 + 0xff) % 0x100; + } while (cli->history[iVar12] != '\0'); + iVar12 = (iVar12 + 1) % 0x100; + } + break; + } + } while (iVar10 != iVar12); + cli->his_idx = iVar12; + while (pcVar4->history[iVar10] != '\0') { + *__s_00 = pcVar4->history[iVar10]; + iVar10 = (iVar10 + 1) % 0x100; + __s_00 = __s_00 + 1; + } + } + else { + iVar10 = cli->his_idx; + iVar12 = iVar10; + while (cli->history[iVar12] != '\0') { + iVar12 = (iVar12 + 1) % 0x100; + } + if (iVar10 != iVar12) { + do { + iVar12 = (iVar12 + 1) % 0x100; + } while (cli->history[iVar12] == '\0'); + } + cli->his_idx = iVar12; + while (pcVar4->history[iVar10] != '\0') { + *__s_00 = pcVar4->history[iVar10]; + iVar10 = (iVar10 + 1) % 0x100; + __s_00 = __s_00 + 1; + } + } + *__s_00 = '\0'; + printf("\r\n# %s",__s1); + __n = strlen(__s1); + pcVar3->bp = __n; + esc_tag[0] = '\0'; + esc_tag_len = '\0'; + } + else { + if (idx == 0x74) { + if (0x3f < esc_tag_len) { + esc_tag[0] = '\0'; + esc_tag_len = '\0'; + esc_4387 = '\0'; + printf("Error: esc_tag buffer overflow\r\n"); + uVar5 = esc_tag_len; + goto LAB_2302fd26; + } + idx = (uint)esc_tag_len + 1 & 0xff; + esc_tag[(uint)esc_tag_len] = stat._0_1_; + pcVar4 = cli; + uVar5 = (uint8_t)idx; + if (stat._0_1_ != 'm') goto LAB_2302fd26; + esc_tag[idx] = '\0'; + esc_tag_len = esc_tag_len + '\x02'; + if (pcVar4->echo_disabled == 0) { + __s = esc_tag; + __s_00 = "%s"; + goto LAB_2302fe8e; + } + } + else { + __s1[pcVar3->bp] = '\x1b'; + uVar8 = pcVar3->bp + 1; + pcVar3->bp = uVar8; + __s1[uVar8] = cVar2; + uVar8 = pcVar3->bp + 1; + pcVar3->bp = uVar8; + __s1[uVar8] = (char)(idx & 0xff); + pcVar3->bp = pcVar3->bp + 1; + if (cli->echo_disabled == 0) { + printf("\x1b%c%c"); + } + esc_tag[0] = '\0'; + esc_tag_len = '\0'; + } + } + } + esc_4387 = '\0'; + uVar5 = esc_tag_len; + goto LAB_2302fd26; + } + __s1[pcVar3->bp] = stat._0_1_; + if ((stat._0_1_ == '\b') || (stat._0_1_ == '\x7f')) { + uVar5 = esc_tag_len; + if ((pcVar3->bp != 0) && + (pcVar3->bp = pcVar3->bp - 1, uVar5 = esc_tag_len, cli->echo_disabled == 0)) { + printf("%c %c",8,8); + uVar5 = esc_tag_len; + } + } + else { + if (stat._0_1_ == '\t') { + __s1[pcVar3->bp] = '\0'; + aos_cli_printf("\r\n"); + iVar12 = 0; + uVar8 = 0; + idx = 0; + __s_00 = (char *)0x0; + while ((idx < cli->num_static_cmds + 8 && (uVar8 < cli->num_commands))) { + pcVar7 = cli_command_get(idx,(int *)0x0); + __s = __s_00; + if (pcVar7->name != (char *)0x0) { + iVar10 = strncmp(__s1,pcVar7->name,pcVar3->bp); + if (iVar10 == 0) { + iVar12 = iVar12 + 1; + __s = pcVar7->name; + if (iVar12 != 1) { + if (iVar12 == 2) { + aos_cli_printf("%s %s ",__s_00); + __s = __s_00; + } + else { + aos_cli_printf("%s ",__s); + __s = __s_00; + } + } + } + uVar8 = uVar8 + 1; + } + idx = idx + 1; + __s_00 = __s; + } + if (iVar12 == 1) { + if ((__s_00 != (char *)0x0) && (__n = strlen(__s_00), __n < 0x100)) { + idx = pcVar3->bp; + memcpy(__s1 + idx,__s_00 + idx,__n - idx); + iVar12 = (__n - idx) + pcVar3->bp; + pcVar3->bp = iVar12 + 1; + __s1[iVar12] = ' '; + __s1[pcVar3->bp] = '\0'; + } + } + else { + if (1 < iVar12) { + aos_cli_printf("\r\n"); + } + } + aos_cli_printf("%s%s",&DAT_230777ac,__s1); + uVar5 = esc_tag_len; + } + else { + if (cli->echo_disabled == 0) { + printf("%c",(uint)stat & 0xff); + } + idx = pcVar3->bp + 1; + pcVar3->bp = idx; + uVar5 = esc_tag_len; + if (0xff < idx) { + aos_cli_printf("Error: input buffer overflow\r\n"); + aos_cli_printf("# "); + pcVar3->bp = 0; + return; + } + } + } + } + goto LAB_2302fd26; + } + __s1[pcVar3->bp] = '\0'; + __s1 = pcVar4->inbuf; + pcVar3->bp = 0; + __n = strlen(__s1); + if (__n != 0) { + __s = cli->inbuf; + __n = strlen(__s); + pcVar3 = cli; + __n = __n + 1; + iVar11 = cli->his_cur; + __n_00 = 0x100 - iVar11; + cli->his_idx = iVar11; + __s_00 = pcVar3->history + iVar11; + iVar12 = iVar11 + __n + -1; + if ((int)__n_00 < (int)__n) { + iVar12 = iVar12 % 0x100; + cVar2 = pcVar3->history[iVar12]; + strncpy(__s_00,__s,__n_00); + __n = __n - __n_00; + __s = __s + __n_00; + __s_00 = cli->history; + } + else { + cVar2 = pcVar3->history[iVar11 + __n + -1]; + } + strncpy(__s_00,__s,__n); + pcVar3 = cli; + iVar11 = (iVar12 + 1) % 0x100; + cli->his_cur = iVar11; + if (cVar2 != '\0') { + while (iVar12 = (int)&pcVar3->initialized + iVar11, *(char *)(iVar12 + 0x144) != '\0') { + *(undefined *)(iVar12 + 0x144) = 0; + iVar11 = (iVar11 + 1) % 0x100; + } + } + } + stat = (anon_struct)0x0; + memset(argvall_4310,0,0x100); + memset(&stat,0,0x10); + memset(&uStack84,0,4); + iVar11 = 0; + paVar6 = &stat; + iVar12 = 0; + do { + __src = (byte *)(__s1 + iVar11); + bVar1 = *__src; + if (bVar1 != 0x20) { + if (0x20 < bVar1) { + if (bVar1 == 0x22) { + if (((iVar11 == 0) || (__s_00 = __s1 + iVar11 + -1, *__s_00 != '\\')) || + ((uStack84 & 1) == 0)) { + idx = uStack84 & 3; + if (idx != 1) { + if (idx == 2) goto LAB_2303049e; + if (idx == 0) { + aVar9 = *paVar6; + uStack84 = uStack84 & 0xfffffffc | 3; + *(int *)paVar6 = (int)aVar9 + 1; + *(char **)(argvall_4310 + (iVar12 * 0x10 + (int)aVar9) * 4) = __s1 + iVar11 + 1; + } + else { + if (idx == 3) { + uStack84._0_1_ = (byte)uStack84 & 0xfc; + goto LAB_23030464; + } + } + } + } + else { +LAB_23030400: + iVar11 = iVar11 + -1; + __n = strlen((char *)__src); + memcpy(__s_00,__src,__n + 1); + } + } + else { + if (bVar1 != 0x3b) goto LAB_2302fdce; + if (((iVar11 != 0) && (__s_00 = __s1 + iVar11 + -1, *__s_00 == '\\')) && + ((uStack84 & 1) != 0)) goto LAB_23030400; + if ((uStack84 & 2) != 0) goto LAB_2303049e; + if ((uStack84 & 3) == 1) { + uStack84 = uStack84 & 0xfffffffe; + *__src = 0; + if ((*paVar6 != (anon_struct)0x0) && (iVar12 = iVar12 + 1, iVar12 < 4)) { + paVar6 = &stat + iVar12; + } + } + } + goto LAB_23030358; + } + if (bVar1 != 0) { +LAB_2302fdce: + if ((uStack84 & 1) == 0) { + aVar9 = *paVar6; + uStack84 = uStack84 | 1; + *(int *)paVar6 = (int)aVar9 + 1; + *(byte **)(argvall_4310 + (iVar12 * 0x10 + (int)aVar9) * 4) = __src; + } + goto LAB_23030358; + } + if ((uStack84 & 2) == 0) { + uStack84 = uStack84 | 4; + goto LAB_23030358; + } +LAB_2303049e: + aos_cli_printf("syntax error\r\n"); + goto LAB_230303c0; + } + if (((iVar11 != 0) && (__s_00 = __s1 + iVar11 + -1, *__s_00 == '\\')) && ((uStack84 & 1) != 0)) + goto LAB_23030400; + if ((uStack84 & 3) == 1) { + uStack84._0_1_ = (byte)uStack84 & 0xfe; +LAB_23030464: + uStack84 = uStack84 & 0xffffff00 | (uint)(byte)uStack84; + *__src = 0; + } +LAB_23030358: + } while ((((uStack84 & 4) == 0) && (iVar11 = iVar11 + 1, iVar11 < 0x100)) && + ((iVar12 < 4 && ((int)*paVar6 < 0x10)))); + if ((uStack84 & 2) != 0) goto LAB_2303049e; + paVar6 = &stat; + argv = argvall_4310; + idx = 0; + iVar11 = 0; + do { + iVar11 = iVar11 + 1; + uVar8 = proc_onecmd((int)*paVar6,(char **)argv); + idx = idx | uVar8; + if (iVar12 < iVar11) break; + paVar6 = paVar6 + 1; + argv = (undefined1 *)((char **)argv + 0x10); + } while (iVar11 != 4); + if (idx == 1) { + if (__s1 != (char *)0x0) { + aos_cli_printf("command \'%s\' not found\r\n",__s1); + } + } + else { + if (idx == 2) goto LAB_2303049e; + } +LAB_230303c0: + aos_cli_printf("\r\n"); + esc_tag[0] = '\0'; + esc_tag_len = '\0'; + __s1 = "# "; + goto LAB_2302fe04; +} + + + +void console_cb_read(int fd,void *param) + +{ + ssize_t count; + char acStack32 [4]; + char buffer [16]; + + count = aos_read(fd,acStack32,0x10); + if (0 < count) { + if (count < 0x11) { + fd_console = fd; + cli_main_input(acStack32,count); + } + else { + printf("-------------BUG from aos_read for ret\r\n"); + } + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void aos_cli_input_direct(char *buffer,int count) + +{ + byte bVar1; + char cVar2; + cli_st *pcVar3; + cli_st *pcVar4; + uint8_t uVar5; + uint *puVar6; + undefined1 *argv; + size_t __n; + cli_command *pcVar7; + uint uVar8; + char *__s1; + char *__s; + uint idx; + int iVar9; + byte *__src; + char *__s_00; + int iVar10; + size_t __n_00; + int iVar11; + uint uStack84; + uint auStack80 [7]; + + pcVar3 = cli; + __s1 = cli->inbuf; + if (__s1 == (char *)0x0) { + __s1 = "inbuf_null\r\n"; +LAB_2302fe04: + aos_cli_printf(__s1); + return; + } + iVar10 = 0; + uVar5 = esc_tag_len; +LAB_2302fd26: + esc_tag_len = uVar5; + if (buffer == (char *)0x0) { + iVar11 = cli_getchar((char *)auStack80); + if (iVar11 != 1) { + return; + } + } + else { + if (count <= iVar10) { + return; + } + __src = (byte *)(buffer + iVar10); + iVar10 = iVar10 + 1; + auStack80[0] = auStack80[0] & 0xffffff00 | (uint)*__src; + } + pcVar4 = cli; + cVar2 = key1_4388; + if (((char)auStack80[0] != '\n') && ((char)auStack80[0] != '\r')) { + uVar5 = esc_tag_len; + if ((char)auStack80[0] == '\x1b') { + esc_4387 = '\x01'; + key1_4388 = -1; + key2_4389 = -1; + } + else { + if (esc_4387 != '\0') { + if (key1_4388 < '\0') { + __s = (char *)(int)(char)auStack80[0]; + key1_4388 = (char)auStack80[0]; + if (__s == (char *)0x5b) goto LAB_2302fd26; + __s1[pcVar3->bp] = '\x1b'; + idx = pcVar3->bp + 1; + pcVar3->bp = idx; + __s1[idx] = (char)auStack80[0]; + pcVar3->bp = pcVar3->bp + 1; + if (cli->echo_disabled == 0) { + __s_00 = "\x1b%c"; +LAB_2302fe8e: + printf(__s_00,__s); + } + } + else { + if ((key2_4389 < '\0') && (key2_4389 = (char)auStack80[0], (char)auStack80[0] == 't')) { + esc_tag[0] = '\x1b'; + esc_tag[1] = key1_4388; + esc_tag_len = '\x02'; + } + idx = SEXT14(key2_4389); + if (((idx & 0xff) - 0x41 & 0xff) < 2) { + __s_00 = __s1; + if (idx == 0x41) { + iVar9 = cli->his_idx; + iVar11 = iVar9; + do { + iVar11 = (iVar11 + 0xff) % 0x100; + if (cli->history[iVar11] != '\0') { + if (iVar9 != iVar11) { + do { + iVar11 = (iVar11 + 0xff) % 0x100; + } while (cli->history[iVar11] != '\0'); + iVar11 = (iVar11 + 1) % 0x100; + } + break; + } + } while (iVar9 != iVar11); + cli->his_idx = iVar11; + while (pcVar4->history[iVar9] != '\0') { + *__s_00 = pcVar4->history[iVar9]; + iVar9 = (iVar9 + 1) % 0x100; + __s_00 = __s_00 + 1; + } + } + else { + iVar9 = cli->his_idx; + iVar11 = iVar9; + while (cli->history[iVar11] != '\0') { + iVar11 = (iVar11 + 1) % 0x100; + } + if (iVar9 != iVar11) { + do { + iVar11 = (iVar11 + 1) % 0x100; + } while (cli->history[iVar11] == '\0'); + } + cli->his_idx = iVar11; + while (pcVar4->history[iVar9] != '\0') { + *__s_00 = pcVar4->history[iVar9]; + iVar9 = (iVar9 + 1) % 0x100; + __s_00 = __s_00 + 1; + } + } + *__s_00 = '\0'; + printf("\r\n# %s",__s1); + __n = strlen(__s1); + pcVar3->bp = __n; + esc_tag[0] = '\0'; + esc_tag_len = '\0'; + } + else { + if (idx == 0x74) { + if (0x3f < esc_tag_len) { + esc_tag[0] = '\0'; + esc_tag_len = '\0'; + esc_4387 = '\0'; + printf("Error: esc_tag buffer overflow\r\n"); + uVar5 = esc_tag_len; + goto LAB_2302fd26; + } + idx = (uint)esc_tag_len + 1 & 0xff; + esc_tag[(uint)esc_tag_len] = (char)auStack80[0]; + pcVar4 = cli; + uVar5 = (uint8_t)idx; + if ((char)auStack80[0] != 'm') goto LAB_2302fd26; + esc_tag[idx] = '\0'; + esc_tag_len = esc_tag_len + '\x02'; + if (pcVar4->echo_disabled == 0) { + __s = esc_tag; + __s_00 = "%s"; + goto LAB_2302fe8e; + } + } + else { + __s1[pcVar3->bp] = '\x1b'; + uVar8 = pcVar3->bp + 1; + pcVar3->bp = uVar8; + __s1[uVar8] = cVar2; + uVar8 = pcVar3->bp + 1; + pcVar3->bp = uVar8; + __s1[uVar8] = (char)(idx & 0xff); + pcVar3->bp = pcVar3->bp + 1; + if (cli->echo_disabled == 0) { + printf("\x1b%c%c"); + } + esc_tag[0] = '\0'; + esc_tag_len = '\0'; + } + } + } + esc_4387 = '\0'; + uVar5 = esc_tag_len; + goto LAB_2302fd26; + } + __s1[pcVar3->bp] = (char)auStack80[0]; + if (((char)auStack80[0] == '\b') || ((char)auStack80[0] == '\x7f')) { + uVar5 = esc_tag_len; + if ((pcVar3->bp != 0) && + (pcVar3->bp = pcVar3->bp - 1, uVar5 = esc_tag_len, cli->echo_disabled == 0)) { + printf("%c %c",8,8); + uVar5 = esc_tag_len; + } + } + else { + if ((char)auStack80[0] == '\t') { + __s1[pcVar3->bp] = '\0'; + aos_cli_printf("\r\n"); + iVar11 = 0; + uVar8 = 0; + idx = 0; + __s_00 = (char *)0x0; + while ((idx < cli->num_static_cmds + 8 && (uVar8 < cli->num_commands))) { + pcVar7 = cli_command_get(idx,(int *)0x0); + __s = __s_00; + if (pcVar7->name != (char *)0x0) { + iVar9 = strncmp(__s1,pcVar7->name,pcVar3->bp); + if (iVar9 == 0) { + iVar11 = iVar11 + 1; + __s = pcVar7->name; + if (iVar11 != 1) { + if (iVar11 == 2) { + aos_cli_printf("%s %s ",__s_00); + __s = __s_00; + } + else { + aos_cli_printf("%s ",__s); + __s = __s_00; + } + } + } + uVar8 = uVar8 + 1; + } + idx = idx + 1; + __s_00 = __s; + } + if (iVar11 == 1) { + if ((__s_00 != (char *)0x0) && (__n = strlen(__s_00), __n < 0x100)) { + idx = pcVar3->bp; + memcpy(__s1 + idx,__s_00 + idx,__n - idx); + iVar11 = (__n - idx) + pcVar3->bp; + pcVar3->bp = iVar11 + 1; + __s1[iVar11] = ' '; + __s1[pcVar3->bp] = '\0'; + } + } + else { + if (1 < iVar11) { + aos_cli_printf("\r\n"); + } + } + aos_cli_printf("%s%s",&DAT_230777ac,__s1); + uVar5 = esc_tag_len; + } + else { + if (cli->echo_disabled == 0) { + printf("%c",auStack80[0] & 0xff); + } + idx = pcVar3->bp + 1; + pcVar3->bp = idx; + uVar5 = esc_tag_len; + if (0xff < idx) { + aos_cli_printf("Error: input buffer overflow\r\n"); + aos_cli_printf("# "); + pcVar3->bp = 0; + return; + } + } + } + } + goto LAB_2302fd26; + } + __s1[pcVar3->bp] = '\0'; + __s1 = pcVar4->inbuf; + pcVar3->bp = 0; + __n = strlen(__s1); + if (__n != 0) { + __s = cli->inbuf; + __n = strlen(__s); + pcVar3 = cli; + __n = __n + 1; + iVar10 = cli->his_cur; + __n_00 = 0x100 - iVar10; + cli->his_idx = iVar10; + __s_00 = pcVar3->history + iVar10; + iVar11 = iVar10 + __n + -1; + if ((int)__n_00 < (int)__n) { + iVar11 = iVar11 % 0x100; + cVar2 = pcVar3->history[iVar11]; + strncpy(__s_00,__s,__n_00); + __n = __n - __n_00; + __s = __s + __n_00; + __s_00 = cli->history; + } + else { + cVar2 = pcVar3->history[iVar10 + __n + -1]; + } + strncpy(__s_00,__s,__n); + pcVar3 = cli; + iVar10 = (iVar11 + 1) % 0x100; + cli->his_cur = iVar10; + if (cVar2 != '\0') { + while (iVar11 = (int)&pcVar3->initialized + iVar10, *(char *)(iVar11 + 0x144) != '\0') { + *(undefined *)(iVar11 + 0x144) = 0; + iVar10 = (iVar10 + 1) % 0x100; + } + } + } + auStack80[0] = 0; + auStack80[1] = 0; + auStack80[2] = 0; + auStack80[3] = 0; + memset(argvall_4310,0,0x100); + memset(auStack80,0,0x10); + memset(&uStack84,0,4); + iVar10 = 0; + puVar6 = auStack80; + iVar11 = 0; + do { + __src = (byte *)(__s1 + iVar10); + bVar1 = *__src; + if (bVar1 != 0x20) { + if (0x20 < bVar1) { + if (bVar1 == 0x22) { + if (((iVar10 == 0) || (__s_00 = __s1 + iVar10 + -1, *__s_00 != '\\')) || + ((uStack84 & 1) == 0)) { + idx = uStack84 & 3; + if (idx != 1) { + if (idx == 2) goto LAB_2303049e; + if (idx == 0) { + idx = *puVar6; + uStack84 = uStack84 & 0xfffffffc | 3; + *puVar6 = idx + 1; + *(char **)(argvall_4310 + (iVar11 * 0x10 + idx) * 4) = __s1 + iVar10 + 1; + } + else { + if (idx == 3) { + uStack84._0_1_ = (byte)uStack84 & 0xfc; + goto LAB_23030464; + } + } + } + } + else { +LAB_23030400: + iVar10 = iVar10 + -1; + __n = strlen((char *)__src); + memcpy(__s_00,__src,__n + 1); + } + } + else { + if (bVar1 != 0x3b) goto LAB_2302fdce; + if (((iVar10 != 0) && (__s_00 = __s1 + iVar10 + -1, *__s_00 == '\\')) && + ((uStack84 & 1) != 0)) goto LAB_23030400; + if ((uStack84 & 2) != 0) goto LAB_2303049e; + if ((uStack84 & 3) == 1) { + uStack84 = uStack84 & 0xfffffffe; + *__src = 0; + if ((*puVar6 != 0) && (iVar11 = iVar11 + 1, iVar11 < 4)) { + puVar6 = auStack80 + iVar11; + } + } + } + goto LAB_23030358; + } + if (bVar1 != 0) { +LAB_2302fdce: + if ((uStack84 & 1) == 0) { + idx = *puVar6; + uStack84 = uStack84 | 1; + *puVar6 = idx + 1; + *(byte **)(argvall_4310 + (iVar11 * 0x10 + idx) * 4) = __src; + } + goto LAB_23030358; + } + if ((uStack84 & 2) == 0) { + uStack84 = uStack84 | 4; + goto LAB_23030358; + } +LAB_2303049e: + aos_cli_printf("syntax error\r\n"); + goto LAB_230303c0; + } + if (((iVar10 != 0) && (__s_00 = __s1 + iVar10 + -1, *__s_00 == '\\')) && ((uStack84 & 1) != 0)) + goto LAB_23030400; + if ((uStack84 & 3) == 1) { + uStack84._0_1_ = (byte)uStack84 & 0xfe; +LAB_23030464: + uStack84 = uStack84 & 0xffffff00 | (uint)(byte)uStack84; + *__src = 0; + } +LAB_23030358: + } while ((((uStack84 & 4) == 0) && (iVar10 = iVar10 + 1, iVar10 < 0x100)) && + ((iVar11 < 4 && ((int)*puVar6 < 0x10)))); + if ((uStack84 & 2) != 0) goto LAB_2303049e; + puVar6 = auStack80; + argv = argvall_4310; + idx = 0; + iVar10 = 0; + do { + iVar10 = iVar10 + 1; + uVar8 = proc_onecmd(*puVar6,(char **)argv); + idx = idx | uVar8; + if (iVar11 < iVar10) break; + puVar6 = puVar6 + 1; + argv = (undefined1 *)((char **)argv + 0x10); + } while (iVar10 != 4); + if (idx == 1) { + if (__s1 != (char *)0x0) { + aos_cli_printf("command \'%s\' not found\r\n",__s1); + } + } + else { + if (idx == 2) goto LAB_2303049e; + } +LAB_230303c0: + aos_cli_printf("\r\n"); + esc_tag[0] = '\0'; + esc_tag_len = '\0'; + __s1 = "# "; + goto LAB_2302fe04; +} + + + +// WARNING: Variable defined which should be unmapped: qry +// WARNING: Could not reconcile some variable overlaps + +void get_dns_request(void *arg,udp_pcb *upcb,pbuf *p,ip_addr_t *addr,u16_t port) + +{ + u16_t uVar1; + int iVar2; + pbuf *buf; + uint uVar3; + char *dataptr; + char *pcVar4; + uint uVar5; + uint local_50; + int len; + dns_ans_hdr hdr; + dns_ans_hdr hdr_1; + dns_ans_ans qry; + + *(udp_pcb **)((int)arg + 0x108) = upcb; + *(ip_addr_t **)((int)arg + 0x10c) = addr; + *(u16_t *)((int)arg + 0x110) = port; + if (0xb < p->tot_len) { + pbuf_copy_partial(p,&len,0xc,0); + uVar1 = lwip_htons((u16_t)len); + *(u16_t *)((int)arg + 0x100) = uVar1; + uVar1 = lwip_htons(hdr.id); + *(u16_t *)((int)arg + 0x102) = uVar1; + local_50 = (uint)p->tot_len; + if (0xff < p->tot_len) { + local_50 = 0xff; + } + pbuf_copy_partial(p,arg,(u16_t)local_50,0xc); + iVar2 = utils_dns_domain_get((uint8_t *)arg,(uint8_t *)arg,(int *)&local_50); + if (iVar2 == 0) { + if ((0 < (int)local_50) && (*(char *)((int)arg + (local_50 - 1)) == '.')) { + local_50 = local_50 - 1; + } + *(undefined *)(local_50 + (int)arg) = 0; + } + } + pbuf_free(p); + buf = pbuf_alloc(PBUF_TRANSPORT,0x200,PBUF_RAM); + if (buf != (pbuf *)0x0) { + memset(&hdr.numauthrr,0,0xc); + pcVar4 = (char *)((int)arg + -1); + uVar3 = 0xc; + hdr.numauthrr = lwip_htons(*(u16_t *)((int)arg + 0x100)); + hdr.numextrarr = lwip_htons(0x8180); + hdr_1.id = lwip_htons(1); + hdr_1.flag = lwip_htons(1); + hdr_1.numquestions = lwip_htons(0); + hdr_1.numanswers = lwip_htons(0); + pbuf_take(buf,&hdr.numauthrr,0xc); + do { + dataptr = pcVar4 + 1; + uVar5 = 0; + pcVar4 = dataptr; + while ((*pcVar4 != '.' && (*pcVar4 != '\0'))) { + uVar5 = uVar5 + 1 & 0xff; + pcVar4 = pcVar4 + 1; + } + pbuf_put_at(buf,(u16_t)uVar3,(u8_t)uVar5); + pbuf_take_at(buf,dataptr,(u16_t)((uint)((int)(pcVar4 + -(int)dataptr) * 0x10000) >> 0x10), + (u16_t)((uVar3 + 1) * 0x10000 >> 0x10)); + uVar5 = uVar3 + uVar5 & 0xffff; + uVar3 = uVar5 + 1 & 0xffff; + } while (*pcVar4 != '\0'); + pbuf_put_at(buf,(u16_t)((uVar5 + 1) * 0x10000 >> 0x10),'\0'); + hdr_1.numauthrr = lwip_htons(1); + hdr_1.numextrarr = lwip_htons(1); + lwip_htons(0xc00c); + lwip_htons(1); + lwip_htons(1); + lwip_htons(0); + lwip_htonl(0x3c0004); + lwip_htonl(0xc0a8a901); + pbuf_take_at(buf,&hdr_1.numauthrr,0x14,(u16_t)((uVar5 + 2) * 0x10000 >> 0x10)); + pbuf_realloc(buf,(u16_t)((uVar5 + 0x16) * 0x10000 >> 0x10)); + udp_sendto(*(udp_pcb **)((int)arg + 0x108),buf,*(ip_addr_t **)((int)arg + 0x10c), + *(u16_t *)((int)arg + 0x110)); + pbuf_free(buf); + } + return; +} + + + +void dns_server_init(void) + +{ + err_t eVar1; + udp_pcb *pcb; + undefined3 extraout_var; + void *__s; + + pcb = udp_new(); + if (pcb == (udp_pcb *)0x0) { + return; + } + eVar1 = udp_bind(pcb,&ip_addr_any,0x35); + if ((CONCAT31(extraout_var,eVar1) == 0) && (__s = pvPortMalloc(0x114), __s != (void *)0x0)) { + memset(__s,0,4); + udp_recv(pcb,get_dns_request,__s); + return; + } + udp_remove(pcb); + return; +} + + + +EfErrCode easyflash_init(void) + +{ + EfErrCode EVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + char *format; + size_t local_18; + size_t default_env_set_size; + ef_env *default_env_set; + + local_18 = 0; + EVar1 = ef_port_init((ef_env **)&default_env_set_size,&local_18); + if ((CONCAT31(extraout_var,EVar1) == 0) && + (EVar1 = ef_env_init((ef_env *)default_env_set_size,local_18), + CONCAT31(extraout_var_00,EVar1) == 0)) { + format = "EasyFlash V%s is initialize success.\r\n"; + } + else { + format = "EasyFlash V%s is initialize fail.\r\n"; + } + ef_log_info(format,&UNK_23077e28); + ef_log_info("You can get the latest version on https://github.com/armink/EasyFlash .\r\n"); + return EVar1; +} + + + +size_t get_status(uint8_t *status_table,size_t status_num) + +{ + size_t sVar1; + size_t sVar2; + + sVar2 = status_num - 1; + do { + sVar1 = sVar2; + sVar2 = sVar1 - 1; + if (sVar2 == 0xffffffff) { + return sVar1; + } + } while (status_table[sVar2] != '\0'); + return sVar1; +} + + + +void update_sector_cache(uint32_t sec_addr,uint32_t empty_addr) + +{ + sector_cache_node *psVar1; + int iVar2; + int iVar3; + uint32_t uVar4; + + psVar1 = sector_cache_table; + iVar2 = 4; + iVar3 = 0; + do { + uVar4 = psVar1->addr; + if ((sec_addr < empty_addr) && (empty_addr < sec_addr + 0x1000)) { + if (sec_addr == uVar4) { + psVar1 = sector_cache_table + iVar3; + goto LAB_2303081c; + } + if ((uVar4 == 0xffffffff) && (iVar2 == 4)) { + iVar2 = iVar3; + } + } + else { + if (sec_addr == uVar4) { + sector_cache_table[iVar3].addr = 0xffffffff; + return; + } + } + iVar3 = iVar3 + 1; + psVar1 = psVar1 + 1; + } while (iVar3 != 4); + if (iVar2 != 4) { + psVar1 = sector_cache_table + iVar2; + psVar1->addr = sec_addr; +LAB_2303081c: + psVar1->empty_addr = empty_addr; + } + return; +} + + + +uint32_t get_next_sector_addr(sector_meta_data_t pre_sec) + +{ + uint uVar1; + int iVar2; + + uVar1 = env_start_addr; + if (pre_sec->addr != 0xffffffff) { + if (pre_sec->combined == 0xffffffff) { + iVar2 = 0x1000; + } + else { + iVar2 = pre_sec->combined << 0xc; + } + uVar1 = iVar2 + pre_sec->addr; + if (env_start_addr + 0x8000 <= uVar1) { + return 0xffffffff; + } + } + return uVar1; +} + + + +_Bool gc_check_cb(sector_meta_data_t sector,void *arg1,void *arg2) + +{ + if (sector->check_ok != false) { + *(int *)arg1 = *(int *)arg1 + 1; + } + return false; +} + + + +void update_env_cache(char *name,size_t name_len,uint32_t addr) + +{ + uint32_t uVar1; + int iVar2; + env_cache_node *peVar3; + int iVar4; + int iVar5; + ushort uVar6; + + uVar1 = ef_calc_crc32(0,name,name_len); + peVar3 = env_cache_table; + uVar6 = 0xffff; + iVar5 = 0x10; + iVar2 = 0x10; + iVar4 = 0; + do { + if (addr == 0xffffffff) { + if ((uint)peVar3->name_crc == uVar1 >> 0x10) { + peVar3 = env_cache_table + iVar4; + env_cache_table[iVar4].addr = 0xffffffff; + goto LAB_2303091a; + } + } + else { + if ((uint)peVar3->name_crc == uVar1 >> 0x10) { + env_cache_table[iVar4].addr = addr; + return; + } + if (peVar3->addr == 0xffffffff) { + if (iVar2 == 0x10) { + iVar2 = iVar4; + } + } + else { + if (peVar3->active != 0) { + peVar3->active = peVar3->active - 1; + } + if (peVar3->active < uVar6) { + iVar5 = iVar4; + uVar6 = peVar3->active; + } + } + } + iVar4 = iVar4 + 1; + peVar3 = peVar3 + 1; + } while (iVar4 != 0x10); + if ((iVar2 != 0x10) || (iVar2 = iVar5, iVar5 != 0x10)) { + peVar3 = env_cache_table + iVar2; + env_cache_table[iVar2].addr = addr; + peVar3->name_crc = (uint16_t)(uVar1 >> 0x10); +LAB_2303091a: + peVar3->active = 0; + } + return; +} + + + +_Bool find_env_cb(env_node_obj_t env,void *arg1,void *arg2) + +{ + _Bool _Var1; + size_t sVar2; + int iVar3; + + sVar2 = strlen((char *)arg1); + if (((((uint)env->name_len == sVar2) && (_Var1 = env->crc_is_ok, _Var1 != false)) && + (env->status == ENV_WRITE)) && + (iVar3 = strncmp(env->name,(char *)arg1,(uint)env->name_len), iVar3 == 0)) { + *(undefined *)arg2 = 1; + } + else { + _Var1 = false; + } + return _Var1; +} + + + +_Bool sector_statistics_cb(sector_meta_data_t sector,void *arg1,void *arg2) + +{ + sector_store_status_t sVar1; + + if (sector->check_ok != false) { + sVar1 = (sector->status).store; + if (sVar1 == SECTOR_STORE_EMPTY) { + *(int *)arg1 = *(int *)arg1 + 1; + } + else { + if (sVar1 == SECTOR_STORE_USING) { + *(int *)arg2 = *(int *)arg2 + 1; + } + } + } + return false; +} + + + +_Bool alloc_env_cb(sector_meta_data_t sector,void *arg1,void *arg2) + +{ + sector_dirty_status_t sVar1; + _Bool _Var2; + + _Var2 = sector->check_ok; + if (_Var2 != false) { + if ((*(uint *)arg1 < sector->remain) && + ((sVar1 = (sector->status).dirty, sVar1 == SECTOR_DIRTY_FALSE || + ((sVar1 == SECTOR_DIRTY_TRUE && (gc_request == false)))))) { + *(uint32_t *)arg2 = sector->empty_env; + } + else { + _Var2 = false; + } + } + return _Var2; +} + + + +EfErrCode write_status(uint32_t addr,uint8_t *status_table,size_t status_num,size_t status_index) + +{ + EfErrCode EVar1; + + if (status_num <= status_index) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x111, + "(%s) has assert failed at %s.\r\n","status_index < status_num","write_status"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + if (status_table == (uint8_t *)0x0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x112, + "(%s) has assert failed at %s.\r\n","status_table","write_status"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + memset(status_table,0xff,status_num * 8 - 1 >> 3); + status_table[status_index - 1] = 0; + EVar1 = ef_port_write(addr + (status_index - 1),(uint32_t *)(status_table + (status_index - 1)),1) + ; + return EVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +EfErrCode read_env(env_node_obj_t env) + +{ + char "read_env" [9]; + uint uVar1; + uint32_t crc; + size_t size; + uint uVar2; + uint32_t uStack92; + env_hdr_data env_hdr; + uint8_t buf [32]; + + ef_port_read((env->addr).start,&uStack92,0x1c); + size = get_status((uint8_t *)&uStack92,6); + env->status = (env_status_t)(size & 0xff); + env->len = env_hdr.magic; + uVar2 = env_hdr.magic - 0x14; + if (uVar2 < 0x7fed) { + if (env_hdr.magic - 0xfed < 0x7013) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x223 + ,"(%s) has assert failed at %s.\r\n",0x2307cdb4,"read_env"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + uVar1 = 0; + crc = 0; + while (uVar1 < uVar2) { + size = 0x20; + if (uVar2 <= uVar1 + 0x20) { + size = uVar2 - uVar1; + } + ef_port_read((env->addr).start + 0x14 + uVar1,&env_hdr.value_len,size); + crc = ef_calc_crc32(crc,&env_hdr.value_len,size); + uVar1 = uVar1 + size; + } + if (env_hdr.len == crc) { + crc = (env->addr).start + 0x1c; + env->crc_is_ok = true; + ef_port_read(crc,(uint32_t *)env->name,(uint)(byte)env_hdr.crc32); + (env->addr).value = crc + (byte)env_hdr.crc32; + env->value_len = env_hdr._20_4_; + env->name_len = (byte)env_hdr.crc32; + return EF_NO_ERR; + } + } + else { + env->len = 0x1c; + if ((size & 0xff) != 5) { + env->status = ENV_ERR_HDR; + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x21c + ,"Error: The ENV @0x%08X length has an error.\r\n",(env->addr).start); + write_status((env->addr).start,(uint8_t *)&uStack92,6,5); + } + } + env->crc_is_ok = false; + return EF_READ_ERR; +} + + + +// WARNING: Variable defined which should be unmapped: status_table + +EfErrCode update_sec_status(sector_meta_data_t sector,size_t new_env_len,_Bool *is_full) + +{ + sector_store_status_t sVar1; + EfErrCode EVar2; + uint8_t auStack20 [4]; + uint8_t status_table [3]; + + sVar1 = (sector->status).store; + if (sVar1 == SECTOR_STORE_EMPTY) { + EVar2 = write_status(sector->addr,auStack20,4,2); + } + else { + EVar2 = EF_NO_ERR; + if (sVar1 == SECTOR_STORE_USING) { + if ((sector->remain < 0x5c) || (sector->remain - new_env_len < 0x5c)) { + EVar2 = write_status(sector->addr,auStack20,4,3); + update_sector_cache(sector->addr,sector->addr + 0x1000); + if (is_full != (_Bool *)0x0) { + *is_full = true; + } + } + else { + if (is_full != (_Bool *)0x0) { + *is_full = false; + } + } + } + } + return EVar2; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +EfErrCode format_sector(uint32_t addr) + +{ + EfErrCode EVar1; + undefined3 extraout_var; + undefined uStack36; + undefined uStack33; + sector_hdr_data sec_hdr; + + if ((addr & 0xfff) != 0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x3b5, + "(%s) has assert failed at %s.\r\n","addr % SECTOR_SIZE == 0","format_sector"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + EVar1 = ef_port_erase(addr,0x1000); + if (CONCAT31(extraout_var,EVar1) == 0) { + memset(&uStack36,0xff,0x14); + memset(&uStack36,0xff,3); + uStack36 = 0; + memset(&uStack36 + 3,0xff,3); + sec_hdr._4_4_ = 0x30344645; + uStack33 = 0; + sec_hdr.magic = 0xffffffff; + sec_hdr.combined = 0xffffffff; + EVar1 = ef_port_write(addr,&uStack36,0x14); + update_sector_cache(addr,addr + 0x1000); + } + return EVar1; +} + + + +_Bool check_sec_hdr_cb(sector_meta_data_t sector,void *arg1,void *arg2) + +{ + if (sector->check_ok == false) { + ef_log_info("Warning: Sector header check failed. Format this sector (0x%08x).\r\n",sector->addr + ); + *(int *)arg1 = *(int *)arg1 + 1; + format_sector(sector->addr); + return false; + } + return false; +} + + + +// WARNING: Variable defined which should be unmapped: buf + +uint32_t get_next_env_addr(sector_meta_data_t sector,env_node_obj_t pre_env) + +{ + uint uVar1; + uint32_t uVar2; + sector_cache_node *psVar3; + uint addr; + int iVar4; + uint32_t *puVar5; + uint32_t uVar6; + uint32_t local_40; + uint8_t buf [32]; + + if ((sector->status).store != SECTOR_STORE_EMPTY) { + addr = (pre_env->addr).start; + uVar6 = sector->addr; + if (addr == 0xffffffff) { + return uVar6 + 0x14; + } + if (addr <= uVar6 + 0x1000) { + uVar1 = addr + 1; + if (pre_env->crc_is_ok != false) { + uVar1 = pre_env->len + addr; + } + psVar3 = sector_cache_table; + iVar4 = 0; + do { + if ((uVar1 & 0xfffff000) == psVar3->addr) { + if (uVar1 == sector_cache_table[iVar4].empty_addr) goto LAB_23030d60; + break; + } + iVar4 = iVar4 + 1; + psVar3 = psVar3 + 1; + } while (iVar4 != 4); + addr = uVar1; + while (addr < uVar6 + 0xfec) { + ef_port_read(addr,&local_40,0x20); + uVar2 = addr - 8; + puVar5 = &local_40; + do { + if (uVar6 + 0xfe4 == uVar2) break; + if ((*puVar5 == 0x3034564b) && (uVar1 <= uVar2)) goto LAB_23030d62; + uVar2 = uVar2 + 1; + puVar5 = (uint32_t *)((int)puVar5 + 1); + } while (addr + 0x14 != uVar2); + addr = addr + 0x1c; + } +LAB_23030d60: + uVar2 = 0xffffffff; +LAB_23030d62: + if ((sector->addr + 0x1000 < uVar2) || (pre_env->len == 0)) { + uVar2 = 0xffffffff; + } + return uVar2; + } + } + return 0xffffffff; +} + + + +// WARNING: Could not reconcile some variable overlaps + +EfErrCode read_sector_meta_data(uint32_t addr,sector_meta_data_t sector,_Bool traversal) + +{ + char cVar1; + EfErrCode EVar2; + uint uVar3; + size_t size; + undefined3 in_register_00002031; + sector_cache_node *psVar4; + int iVar5; + uint32_t uVar6; + uint32_t uVar7; + size_t sVar8; + uint addr_00; + char cVar9; + uint32_t uVar10; + undefined4 uStack188; + sector_hdr_data sec_hdr; + uint8_t buf [32]; + env_node_obj env_meta; + + if ((addr & 0xfff) != 0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x24a, + "(%s) has assert failed at %s.\r\n","addr % SECTOR_SIZE == 0", + "read_sector_meta_data"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + ef_port_read(addr,&uStack188,0x14); + sector->addr = addr; + sector->magic = sec_hdr._4_4_; + if (sec_hdr._4_4_ == 0x30344645) { + sector->combined = sec_hdr.magic; + sector->check_ok = true; + size = get_status((uint8_t *)&uStack188,4); + uVar3 = size & 0xff; + EVar2 = (EfErrCode)uVar3; + (sector->status).store = EVar2; + size = get_status((uint8_t *)((int)&uStack188 + 3),4); + (sector->status).dirty = (sector_dirty_status_t)size; + if (CONCAT31(in_register_00002031,traversal) != 0) { + sector->remain = 0; + sector->empty_env = addr + 0x14; + if (uVar3 == 1) { + sector->remain = 0xfec; + } + else { + if (uVar3 == 2) { + psVar4 = sector_cache_table; + iVar5 = 0; + do { + if (addr == psVar4->addr) { + uVar6 = sector_cache_table[iVar5].empty_addr; + sector->empty_env = uVar6; + sector->remain = (addr + 0x1000) - uVar6; + goto LAB_23030eae; + } + iVar5 = iVar5 + 1; + psVar4 = psVar4 + 1; + } while (iVar5 != 4); + sector->remain = 0xfec; + do { + uVar6 = get_next_env_addr(sector,(env_node_obj_t)(buf + 0x1c)); + if (uVar6 == 0xffffffff) { + EVar2 = EF_NO_ERR; +LAB_23030f4c: + uVar7 = sector->addr; + uVar6 = sector->empty_env; + uVar3 = uVar7 + 0x1000; + cVar9 = '\0'; + uVar10 = uVar6; + while (addr_00 = uVar10, addr_00 < uVar3) { + uVar10 = addr_00 + 0x20; + size = 0x20; + if (uVar3 <= uVar10) { + size = (uVar7 + 0x1020) - uVar10; + } + ef_port_read(addr_00,&sec_hdr.reserved,size); + sVar8 = 0; + while (size != sVar8) { + cVar1 = *(char *)((int)&sec_hdr.reserved + sVar8); + if ((cVar9 != -1) && (cVar1 == -1)) { + uVar6 = addr_00 + sVar8; + } + sVar8 = sVar8 + 1; + cVar9 = cVar1; + } + } + if (cVar9 != -1) { + uVar6 = uVar3; + } + if (sector->empty_env != uVar6) { + sector->empty_env = uVar6; + sector->remain = (sector->addr + 0x1000) - uVar6; + } + update_sector_cache(sector->addr,sector->empty_env); + return EVar2; + } + read_env((env_node_obj_t)(buf + 0x1c)); + if ((buf[29] == '\0') && ((buf[28] & 0xfb) != 1)) { + ef_log_info("Error: The ENV (@0x%08X) CRC32 check failed!\r\n",uVar6); + sector->remain = 0; + goto LAB_23030f4c; + } + sector->empty_env = sector->empty_env + env_meta.magic; + sector->remain = sector->remain - env_meta.magic; + } while( true ); + } + } + } +LAB_23030eae: + EVar2 = EF_NO_ERR; + } + else { + sector->check_ok = false; + sector->combined = 0xffffffff; + EVar2 = EF_ENV_INIT_FAILED; + } + return EVar2; +} + + + +void sector_iterator(sector_meta_data_t sector,sector_store_status_t status,void *arg1,void *arg2, + anon_subr__Bool_sector_meta_data_t_void_ptr_void_ptr *callback, + _Bool traversal_env) + +{ + _Bool _Var1; + uint32_t addr; + undefined3 extraout_var; + undefined3 in_register_0000202d; + undefined3 in_register_0000203d; + + sector->addr = 0xffffffff; + do { + do { + addr = get_next_sector_addr(sector); + if (addr == 0xffffffff) { + return; + } + read_sector_meta_data(addr,sector,false); + } while ((CONCAT31(in_register_0000202d,status) != 0) && + ((uint)(sector->status).store != CONCAT31(in_register_0000202d,status))); + if (CONCAT31(in_register_0000203d,traversal_env) != 0) { + read_sector_meta_data(addr,sector,true); + } + _Var1 = (*callback)(sector,arg1,arg2); + } while (CONCAT31(extraout_var,_Var1) == 0); + return; +} + + + +// WARNING: Variable defined which should be unmapped: using_sector + +uint32_t alloc_env(sector_meta_data_t sector,size_t env_size) + +{ + size_t asStack36 [2]; + uint32_t local_1c; + uint32_t empty_env; + size_t empty_sector; + size_t using_sector; + + local_1c = 0xffffffff; + empty_env = 0; + empty_sector = 0; + asStack36[0] = env_size; + sector_iterator(sector,SECTOR_STORE_UNUSED,&empty_env,&empty_sector,sector_statistics_cb,false); + if (empty_sector != 0) { + sector_iterator(sector,SECTOR_STORE_USING,asStack36,&local_1c,alloc_env_cb,true); + } + if ((empty_env != 0) && (local_1c == 0xffffffff)) { + if ((empty_env < 2) && (gc_request == false)) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x42d + ,"Trigger a GC check after alloc ENV failed.\r\n"); + gc_request = true; + } + else { + sector_iterator(sector,SECTOR_STORE_EMPTY,asStack36,&local_1c,alloc_env_cb,true); + } + } + return local_1c; +} + + + +void gc_collect(void) + +{ + uint uStack44; + size_t empty_sec; + sector_meta_data sector; + + uStack44 = 0; + sector_iterator((sector_meta_data_t)&empty_sec,SECTOR_STORE_EMPTY,&uStack44,(void *)0x0, + gc_check_cb,false); + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x4fa, + "The remain empty sector is %d, GC threshold is %d.\r\n",uStack44,1); + if (uStack44 < 2) { + sector_iterator((sector_meta_data_t)&empty_sec,SECTOR_STORE_UNUSED,(void *)0x0,(void *)0x0,do_gc + ,false); + } + gc_request = false; + return; +} + + + +uint32_t new_env(sector_meta_data_t sector,size_t env_size) + +{ + uint32_t uVar1; + + uVar1 = alloc_env(sector,env_size); + if ((uVar1 == 0xffffffff) && (gc_request != false)) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x4b6, + "Warning: Alloc an ENV (size %d) failed when new ENV. Now will GC then retry.\r\n", + env_size); + gc_collect(); + uVar1 = alloc_env(sector,env_size); + } + return uVar1; +} + + + +_Bool check_and_recovery_gc_cb(sector_meta_data_t sector,void *arg1,void *arg2) + +{ + if ((sector->check_ok != false) && ((sector->status).dirty == SECTOR_DIRTY_GC)) { + gc_request = true; + gc_collect(); + return false; + } + return false; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void env_iterator(env_node_obj_t env,void *arg1,void *arg2, + anon_subr__Bool_env_node_obj_t_void_ptr_void_ptr *callback) + +{ + EfErrCode EVar1; + _Bool _Var2; + uint32_t addr; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined uStack56; + sector_store_status_t sStack55; + sector_meta_data sector; + + sector._0_4_ = 0xffffffff; + do { + do { + addr = get_next_sector_addr((sector_meta_data_t)&uStack56); + if (addr == 0xffffffff) { + return; + } + EVar1 = read_sector_meta_data(addr,(sector_meta_data_t)&uStack56,false); + } while ((CONCAT31(extraout_var,EVar1) != 0) || (1 < (byte)(sStack55 + ~SECTOR_STORE_EMPTY))); + (env->addr).start = 0xffffffff; + while( true ) { + addr = get_next_env_addr((sector_meta_data_t)&uStack56,env); + (env->addr).start = addr; + if (addr == 0xffffffff) break; + read_env(env); + _Var2 = (*callback)(env,arg1,arg2); + if (CONCAT31(extraout_var_00,_Var2) != 0) { + return; + } + } + } while( true ); +} + + + +_Bool find_env(char *key,env_node_obj_t env) + +{ + char cVar1; + int iVar2; + size_t size; + uint32_t uVar3; + int iVar4; + uint16_t uVar5; + env_cache_node *peVar6; + char local_70; + char saved_name [64]; + + size = strlen(key); + uVar3 = ef_calc_crc32(0,key,size); + peVar6 = env_cache_table; + iVar2 = 0; + do { + if ((peVar6->addr != 0xffffffff) && ((uint)peVar6->name_crc == uVar3 >> 0x10)) { + ef_port_read(peVar6->addr + 0x1c,&local_70,0x40); + iVar4 = strncmp(key,(char *)&local_70,size); + if (iVar4 == 0) { + (env->addr).start = env_cache_table[iVar2].addr; + uVar5 = 0xffff; + if (env_cache_table[iVar2].active < 0xffef) { + uVar5 = env_cache_table[iVar2].active + 0x10; + } + env_cache_table[iVar2].active = uVar5; + read_env(env); + return true; + } + } + iVar2 = iVar2 + 1; + peVar6 = peVar6 + 1; + } while (iVar2 != 0x10); + local_70 = '\0'; + env_iterator(env,key,&local_70,find_env_cb); + cVar1 = local_70; + if (local_70 != '\0') { + update_env_cache(key,size,(env->addr).start); + } + return (_Bool)cVar1; +} + + + +EfErrCode del_env(char *key,env_node_obj_t old_env,_Bool complete_del) + +{ + _Bool last_is_complete_del; + int iVar1; + _Bool _Var2; + EfErrCode EVar3; + undefined3 extraout_var; + uint32_t addr; + undefined3 extraout_var_00; + size_t sVar4; + undefined3 extraout_var_01; + size_t name_len; + undefined3 in_register_00002031; + uint32_t uStack128; + uint8_t status_table [5]; + env_node_obj env; + + if (old_env == (env_node_obj_t)0x0) { + _Var2 = find_env(key,(env_node_obj_t)(status_table + 4)); + if (CONCAT31(extraout_var,_Var2) == 0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x447 + ,"Not found \'%s\' in ENV.\r\n",key); + return EF_ENV_NAME_ERR; + } + old_env = (env_node_obj_t)(status_table + 4); + } + addr = (old_env->addr).start; + if (CONCAT31(in_register_00002031,complete_del) == 0) { + EVar3 = write_status(addr,(uint8_t *)&uStack128,6,3); + iVar1 = CONCAT31(extraout_var_00,EVar3); + last_is_complete_del = true; + } + else { + EVar3 = write_status(addr,(uint8_t *)&uStack128,6,4); + iVar1 = CONCAT31(extraout_var_01,EVar3); + if ((last_is_complete_del == false) && (iVar1 == 0)) { + if (key == (char *)0x0) { + name_len = (size_t)old_env->name_len; + key = old_env->name; + } + else { + name_len = strlen(key); + } + update_env_cache(key,name_len,0xffffffff); + } + last_is_complete_del = false; + } + EVar3 = (EfErrCode)iVar1; + if (iVar1 == 0) { + addr = ((old_env->addr).start & 0xfffff000) + 3; + ef_port_read(addr,&uStack128,3); + sVar4 = get_status((uint8_t *)&uStack128,4); + if (sVar4 == 1) { + EVar3 = write_status(addr,(uint8_t *)&uStack128,4,2); + } + } + return EVar3; +} + + + +EfErrCode move_env(env_node_obj_t env) + +{ + EfErrCode EVar1; + uint32_t addr; + uint uVar2; + size_t new_env_len; + uint uVar3; + char *__src; + char cStack229; + undefined auStack228 [3]; + _Bool find_ok; + sector_meta_data sector; + uint8_t status_table [5]; + undefined auStack136 [4]; + env_node_obj env_bak; + + if (env->status == ENV_WRITE) { + del_env((char *)0x0,env,false); + } + addr = alloc_env((sector_meta_data_t)auStack228,env->len); + if (addr == 0xffffffff) { + return EF_ENV_FULL; + } + __src = env->name; + if (in_recovery_check != false) { + memset(§or.empty_env,0,0x41); + strncpy((char *)§or.empty_env,__src,(uint)env->name_len); + cStack229 = '\0'; + env_iterator((env_node_obj_t)auStack136,§or.empty_env,&cStack229,find_env_cb); + EVar1 = EF_NO_ERR; + if (cStack229 != '\0') goto __exit; + } + new_env_len = env->len; + update_sec_status((sector_meta_data_t)auStack228,new_env_len,(_Bool *)0x0); + write_status(addr,(uint8_t *)§or.empty_env,6,1); + uVar3 = new_env_len - 8; + uVar2 = 0; + EVar1 = EF_NO_ERR; + while (uVar2 < uVar3) { + new_env_len = 0x20; + if (uVar3 <= uVar2 + 0x20) { + new_env_len = uVar3 - uVar2; + } + ef_port_read((env->addr).start + 8 + uVar2,(uint32_t *)auStack136,new_env_len); + EVar1 = ef_port_write(addr + 8 + uVar2,(uint32_t *)auStack136,new_env_len); + uVar2 = uVar2 + new_env_len; + } + write_status(addr,(uint8_t *)§or.empty_env,6,2); + update_sector_cache(addr & 0xfffff000,env->value_len + 0x1c + (uint)env->name_len + addr); + update_env_cache(__src,(uint)env->name_len,addr); + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x4a6, + "Moved the ENV (%.*s) from 0x%08X to 0x%08X.\r\n",(uint)env->name_len,__src, + (env->addr).start,addr); +__exit: + del_env((char *)0x0,env,true); + return EVar1; +} + + + +_Bool check_and_recovery_env_cb(env_node_obj_t env,void *arg1,void *arg2) + +{ + _Bool _Var1; + EfErrCode EVar2; + undefined3 extraout_var; + uint8_t auStack24 [4]; + uint8_t status_table [5]; + + _Var1 = env->crc_is_ok; + if ((_Var1 == false) || (env->status != ENV_PRE_DELETE)) { + _Var1 = false; + if (env->status == ENV_PRE_WRITE) { + write_status((env->addr).start,auStack24,6,5); + _Var1 = true; + } + } + else { + ef_log_info("Found an ENV (%.*s) which has changed value failed. Now will recovery it.\r\n", + (uint)env->name_len,env->name); + EVar2 = move_env(env); + if (CONCAT31(extraout_var,EVar2) == 0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x6d5 + ,"Recovery the ENV successful.\r\n"); + _Var1 = false; + } + else { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x6d7 + , + "Warning: Moved an ENV (size %d) failed when recovery. Now will GC then retry.\r\n" + ,env->len); + } + } + return _Var1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +_Bool do_gc(sector_meta_data_t sector,void *arg1,void *arg2) + +{ + EfErrCode EVar1; + undefined3 extraout_var; + uint8_t auStack124 [4]; + uint8_t status_table [3]; + env_node_obj env; + + if ((sector->check_ok != false) && ((byte)((sector->status).dirty + ~SECTOR_DIRTY_FALSE) < 2)) { + write_status(sector->addr + 3,auStack124,4,3); + env.name._60_4_ = 0xffffffff; + while( true ) { + env.name._60_4_ = get_next_env_addr(sector,(env_node_obj_t)status_table); + if (env.name._60_4_ == 0xffffffff) break; + read_env((env_node_obj_t)status_table); + if ((((_Bool)status_table[1] != false) && ((byte)(status_table[0] + ~ENV_PRE_WRITE) < 2)) && + (EVar1 = move_env((env_node_obj_t)status_table), CONCAT31(extraout_var,EVar1) != 0)) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c", + 0x4e1,"Error: Moved the ENV (%.*s) for GC failed.\r\n",(uint)status_table[2], + &env.value_len); + } + } + format_sector(sector->addr); + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x4e6, + "Collect a sector @0x%08X\r\n",sector->addr); + return false; + } + return false; +} + + + +// WARNING: Could not reconcile some variable overlaps + +EfErrCode create_env_blob(sector_meta_data_t sector,char *key,void *value,size_t len) + +{ + size_t size; + uint size_00; + uint32_t addr; + EfErrCode EVar1; + size_t sVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + undefined auStack64 [3]; + _Bool _Stack61; + uint8_t align_data [1]; + _Bool is_full; + env_hdr_data env_hdr; + + addr = sector->empty_env; + _Stack61 = false; + sVar2 = strlen(key); + if (sVar2 < 0x41) { + memset(align_data,0xff,0x1c); + env_hdr._4_4_ = 0x3034564b; + sVar2 = strlen(key); + env_hdr.crc32._0_1_ = (byte)sVar2; + env_hdr.magic = len + 0x1c + (sVar2 & 0xff); + env_hdr._20_4_ = len; + if (env_hdr.magic < 0xfed) { + if ((addr == 0xffffffff) && (addr = new_env(sector,env_hdr.magic), addr == 0xffffffff)) { + return EF_ENV_FULL; + } + EVar1 = update_sec_status(sector,env_hdr.magic,&_Stack61); + if (CONCAT31(extraout_var,EVar1) == 0) { + env_hdr.len = ef_calc_crc32(0,&env_hdr.crc32,8); + env_hdr.len = ef_calc_crc32(env_hdr.len,key,(uint)(byte)env_hdr.crc32); + env_hdr.len = ef_calc_crc32(env_hdr.len,value,env_hdr._20_4_); + EVar1 = write_status(addr,align_data,6,1); + if ((CONCAT31(extraout_var_00,EVar1) == 0) && + (EVar1 = ef_port_write(addr + 8,(uint32_t *)(env_hdr.status_table + 4),0x14), + CONCAT31(extraout_var_01,EVar1) == 0)) { + size_00 = (uint)(byte)env_hdr.crc32; + memset(auStack64,0xff,1); + EVar1 = ef_port_write(addr + 0x1c,(uint32_t *)key,size_00); + if (_Stack61 == false) { + update_sector_cache(sector->addr, + env_hdr._20_4_ + 0x1c + (uint)(byte)env_hdr.crc32 + addr); + } + update_env_cache(key,(uint)(byte)env_hdr.crc32,addr); + size = env_hdr._20_4_; + if (CONCAT31(extraout_var_02,EVar1) == 0) { + size_00 = (uint)(byte)env_hdr.crc32; + memset(auStack64,0xff,1); + EVar1 = ef_port_write(size_00 + 0x1c + addr,(uint32_t *)value,size); + if (((CONCAT31(extraout_var_03,EVar1) == 0) && + (EVar1 = write_status(addr,align_data,6,2), CONCAT31(extraout_var_04,EVar1) == 0)) + && (_Stack61 != false)) { + ef_log_debug( + "/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c" + ,0x562,"Trigger a GC check after created ENV.\r\n"); + gc_request = true; + } + } + } + } + } + else { + ef_log_info("Error: The ENV size is too big\r\n"); + EVar1 = EF_ENV_FULL; + } + } + else { + ef_log_info("Error: The ENV name length is more than %d\r\n",0x40); + EVar1 = EF_ENV_NAME_ERR; + } + return EVar1; +} + + + +size_t ef_get_env_blob(char *key,void *value_buf,size_t buf_len,size_t *saved_value_len) + +{ + size_t sVar1; + _Bool _Var2; + TickType_t TVar3; + char *format; + size_t sVar4; + undefined3 extraout_var; + undefined4 uVar5; + undefined auStack120 [4]; + env_node_obj env; + + if (init_ok == false) { + ef_log_info("ENV isn\'t initialize OK.\r\n"); + sVar1 = 0; + } + else { + if ((key == (char *)0x0) || (value_buf == (void *)0x0)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar5 = 0x34c; + format = "[%10u][%s: %s:%4d] key = %p, value_buf = %p\r\n"; + } + else { + sVar4 = strlen(key); + if (sVar4 < 0x41) { + ef_port_env_lock(); + _Var2 = find_env(key,(env_node_obj_t)auStack120); + sVar1 = 0; + if (CONCAT31(extraout_var,_Var2) != 0) { + if (saved_value_len != (size_t *)0x0) { + *saved_value_len = env.len; + } + if (env.len < buf_len) { + buf_len = env.len; + } + ef_port_read(env.addr.start,(uint32_t *)value_buf,buf_len); + sVar1 = buf_len; + } + ef_port_env_unlock(); + return sVar1; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + key = (char *)strlen(key); + value_buf = (void *)0x40; + uVar5 = 0x351; + format = "[%10u][%s: %s:%4d] key err. %d > %d\r\n"; + } + bl_printk(format,TVar3,&DAT_230781b4,&UNK_230781a8,uVar5,key,value_buf); + sVar1 = 8; + } + return sVar1; +} + + + +EfErrCode ef_set_env_blob(char *key,void *value_buf,size_t buf_len) + +{ + _Bool _Var1; + EfErrCode EVar2; + TickType_t TVar3; + char *format; + size_t sVar4; + uint32_t uVar5; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined4 uVar6; + + if (init_ok == false) { + ef_log_info("ENV isn\'t initialize OK.\r\n"); + return EF_ENV_INIT_FAILED; + } + if ((key == (char *)0x0) || (value_buf == (void *)0x0)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar6 = 0x5d4; + format = "[%10u][%s: %s:%4d] key = %p, value_buf = %p\r\n"; + } + else { + sVar4 = strlen(key); + if (sVar4 < 0x41) { + if (buf_len < 0xf8d) { + ef_port_env_lock(); + sVar4 = strlen(key); + uVar5 = new_env((sector_meta_data_t)sector_3152,buf_len + 0x1c + sVar4); + EVar2 = EF_ENV_FULL; + if (uVar5 != 0xffffffff) { + _Var1 = find_env(key,(env_node_obj_t)env_3151); + if ((CONCAT31(extraout_var,_Var1) == 0) || + (EVar2 = del_env(key,(env_node_obj_t)env_3151,false), + CONCAT31(extraout_var_01,EVar2) == 0)) { + EVar2 = create_env_blob((sector_meta_data_t)sector_3152,key,value_buf,buf_len); + if ((CONCAT31(extraout_var,_Var1) != 0) && (CONCAT31(extraout_var_00,EVar2) == 0)) { + EVar2 = del_env(key,(env_node_obj_t)env_3151,true); + } + } + if (gc_request != false) { + gc_collect(); + } + } + ef_port_env_unlock(); + return EVar2; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + value_buf = (void *)0xf8c; + uVar6 = 0x5de; + format = "[%10u][%s: %s:%4d] buf_len err. %d > %d\r\n"; + key = (char *)buf_len; + } + else { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + key = (char *)strlen(key); + value_buf = (void *)0x40; + uVar6 = 0x5d9; + format = "[%10u][%s: %s:%4d] key err. %d > %d\r\n"; + } + } + bl_printk(format,TVar3,&DAT_230781b4,&UNK_230781a8,uVar6,key,value_buf); + return EF_ENV_ARG_ERR; +} + + + +EfErrCode ef_set_env(char *key,char *value) + +{ + EfErrCode EVar1; + size_t buf_len; + + buf_len = strlen(value); + EVar1 = ef_set_env_blob(key,value,buf_len); + return EVar1; +} + + + +EfErrCode ef_save_env(void) + +{ + return EF_NO_ERR; +} + + + +EfErrCode ef_env_set_default(void) + +{ + uint uVar1; + uint32_t addr; + EfErrCode EVar2; + undefined3 extraout_var; + size_t len; + ef_env *peVar3; + undefined auStack56 [4]; + sector_meta_data sector; + + if (default_env_set == (ef_env *)0x0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x621, + "(%s) has assert failed at %s.\r\n","default_env_set","ef_env_set_default"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + if (default_env_set_size == 0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x622, + "(%s) has assert failed at %s.\r\n","default_env_set_size","ef_env_set_default"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + ef_port_env_lock(); + addr = env_start_addr; + while (addr < env_start_addr + 0x8000) { + EVar2 = format_sector(addr); + if (CONCAT31(extraout_var,EVar2) != 0) goto __exit; + addr = addr + 0x1000; + } + uVar1 = 0; + while (uVar1 < default_env_set_size) { + len = default_env_set[uVar1].value_len; + if (len == 0) { + len = strlen((char *)default_env_set[uVar1].value); + } + sector.remain = 0xffffffff; + peVar3 = default_env_set + uVar1; + uVar1 = uVar1 + 1; + create_env_blob((sector_meta_data_t)auStack56,peVar3->key,peVar3->value,len); + } + EVar2 = EF_NO_ERR; +__exit: + ef_port_env_unlock(); + return EVar2; +} + + + +// WARNING: Variable defined which should be unmapped: env + +EfErrCode ef_load_env(void) + +{ + int iStack132; + size_t check_failed_count; + sector_meta_data sector; + env_node_obj env; + + in_recovery_check = true; + iStack132 = 0; + sector_iterator((sector_meta_data_t)&check_failed_count,SECTOR_STORE_UNUSED,&iStack132,(void *)0x0 + ,check_sec_hdr_cb,false); + if (iStack132 == 8) { + ef_log_info("Warning: All sector header check failed. Set it to default.\r\n"); + ef_env_set_default(); + } + ef_port_env_lock(); + sector_iterator((sector_meta_data_t)&check_failed_count,SECTOR_STORE_UNUSED,(void *)0x0, + (void *)0x0,check_and_recovery_gc_cb,false); + while( true ) { + env_iterator((env_node_obj_t)§or.empty_env,(void *)0x0,(void *)0x0,check_and_recovery_env_cb + ); + if (gc_request == false) break; + gc_collect(); + } + in_recovery_check = false; + ef_port_env_unlock(); + return EF_NO_ERR; +} + + + +EfErrCode ef_env_init(ef_env *default_env,size_t default_env_size) + +{ + char "ef_env_init" [12]; + EfErrCode EVar1; + undefined3 extraout_var; + env_cache_node *peVar2; + + if (default_env == (ef_env *)0x0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x71e, + "(%s) has assert failed at %s.\r\n","default_env","ef_env_init"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + EVar1 = EF_NO_ERR; + if (init_ok == false) { + sector_cache_table[0].addr = 0xffffffff; + sector_cache_table[1].addr = 0xffffffff; + sector_cache_table[2].addr = 0xffffffff; + sector_cache_table[3].addr = 0xffffffff; + peVar2 = env_cache_table; + do { + peVar2->addr = 0xffffffff; + peVar2 = peVar2 + 1; + } while (peVar2 != (env_cache_node *)sector_3152); + env_start_addr = 0; + default_env_set = default_env; + default_env_set_size = default_env_size; + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_env.c",0x738, + "ENV start address is 0x%08X, size is %d bytes.\r\n",0,0x8000); + EVar1 = ef_load_env(); + if (CONCAT31(extraout_var,EVar1) == 0) { + init_ok = true; + } + } + return EVar1; +} + + + +EfErrCode ef_port_read(uint32_t addr,uint32_t *buf,size_t size) + +{ + int iVar1; + + iVar1 = bl_mtd_read(handle,addr,size,(uint8_t *)buf); + return (EfErrCode)((iVar1 < 0) << 1); +} + + + +EfErrCode ef_port_write(uint32_t addr,uint32_t *buf,size_t size) + +{ + EfErrCode EVar1; + int iVar2; + + iVar2 = bl_mtd_write(handle,addr,size,(uint8_t *)buf); + if (iVar2 < 0) { + EVar1 = EF_WRITE_ERR; + } + else { + EVar1 = EF_NO_ERR; + } + return EVar1; +} + + + +void ef_port_env_lock(void) + +{ + xQueueSemaphoreTake((QueueHandle_t)env_cache_lock,0xffffffff); + return; +} + + + +void ef_port_env_unlock(void) + +{ + xQueueGenericSend((QueueHandle_t)env_cache_lock,(void *)0x0,0,0); + return; +} + + + +void ef_log_debug(char *file,long line,char *format,...) + +{ + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list args; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + vprint(format,&uStack20); + return; +} + + + +EfErrCode ef_port_erase(uint32_t addr,size_t size) + +{ + char "ef_port_erase" [14]; + int iVar1; + + if ((addr & 0xfff) != 0) { + ef_log_debug("/home/yangff/Projects/bl_iot_sdk/components/stage/easyflash4/src/ef_port.c",0x77, + "(%s) has assert failed at %s.\r\n","addr % EF_ERASE_MIN_SIZE == 0","ef_port_erase" + ); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + iVar1 = bl_mtd_erase(handle,addr,size); + return (EfErrCode)((uint)iVar1 >> 0x1f); +} + + + +void ef_log_info(char *format,...) + +{ + undefined4 in_a1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list args; + undefined4 uStack28; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + uStack28 = in_a1; + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + vprint(format,&uStack28); + return; +} + + + +// WARNING: Variable defined which should be unmapped: info +// WARNING: Could not reconcile some variable overlaps + +EfErrCode ef_port_init(ef_env **default_env,size_t *default_env_size) + +{ + int iVar1; + undefined auStack44 [4]; + bl_mtd_info_t info; + + iVar1 = bl_mtd_open("PSM",&handle,2); + if (iVar1 < 0) { + ef_log_info("[EF] [PART] [XIP] error when get PSM partition %d\r\n",iVar1); + puts("[EF] [PART] [XIP] Dead Loop. Reason: no Valid PSM partition found\r\n"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + memset(auStack44,0,0x1c); + bl_mtd_info(handle,(bl_mtd_info_t *)auStack44); + ef_log_info("[EF] Found Valid PSM partition, XIP Addr %08x, flash addr %08x\r\n",info.size, + info.name._12_4_); + *default_env = default_env_set; + *default_env_size = 1; + printf("*default_env_size = 0x%08x\r\n",1); + env_cache_lock = (SemaphoreHandle_t)xQueueCreateMutex('\x01'); + return EF_NO_ERR; +} + + + +uint32_t ef_calc_crc32(uint32_t crc,void *buf,size_t size) + +{ + uint uVar1; + byte *pbVar2; + + uVar1 = ~crc; + pbVar2 = (byte *)buf; + while (pbVar2 != (byte *)(size + (int)buf)) { + uVar1 = uVar1 >> 8 ^ crc32_table[(*pbVar2 ^ uVar1) & 0xff]; + pbVar2 = pbVar2 + 1; + } + return ~uVar1; +} + + + +// WARNING: Removing unreachable block (ram,0x23031f20) +// WARNING: Removing unreachable block (ram,0x23031f36) + +EventGroupHandle_t xEventGroupCreateStatic(StaticEventGroup_t *pxEventGroupBuffer) + +{ + size_t xSize; + + if (pxEventGroupBuffer == (StaticEventGroup_t *)0x0) { + vAssertCalled(); + } + else { + pxEventGroupBuffer->xDummy1 = 0; + vListInitialise((List_t *)&pxEventGroupBuffer->xDummy2); + pxEventGroupBuffer->ucDummy4 = '\x01'; + } + return (EventGroupHandle_t)pxEventGroupBuffer; +} + + + +EventBits_t +xEventGroupWaitBits(EventGroupHandle_t xEventGroup,EventBits_t uxBitsToWaitFor, + BaseType_t xClearOnExit,BaseType_t xWaitForAllBits,TickType_t xTicksToWait) + +{ + uint uVar1; + BaseType_t BVar2; + uint uVar3; + + if (xEventGroup == (EventGroupHandle_t)0x0) { + vAssertCalled(); + } + if (((uxBitsToWaitFor & 0xff000000) == 0) && (uxBitsToWaitFor != 0)) { + BVar2 = xTaskGetSchedulerState(); + if (BVar2 != 0) goto LAB_23031f68; +LAB_23031fe8: + if (xTicksToWait == 0) goto LAB_23031f68; + vAssertCalled(); + vTaskSuspendAll(); + uVar1 = xEventGroup->uxEventBits; + uVar3 = uxBitsToWaitFor & uVar1; + if (xWaitForAllBits != 0) goto LAB_23031fac; +LAB_23031f78: + if (uVar3 == 0) { +LAB_23031fb0: + if (xTicksToWait == 0) goto LAB_23032002; + uVar1 = (uint)(xClearOnExit != 0) << 0x18; + if (xWaitForAllBits != 0) { + uVar1 = uVar1 | 0x4000000; + } + vTaskPlaceOnUnorderedEventList + (&xEventGroup->xTasksWaitingForBits,uVar1 | uxBitsToWaitFor,xTicksToWait); + BVar2 = xTaskResumeAll(); + if (BVar2 == 0) { + ecall(); + } + uVar1 = uxTaskResetEventItemValue(); + if ((int)(uVar1 << 6) < 0) goto LAB_23031fe0; + vTaskEnterCritical(); + uVar1 = xEventGroup->uxEventBits; + if (xWaitForAllBits == 0) { + if ((uxBitsToWaitFor & uVar1) != 0) { +LAB_23032028: + if (xClearOnExit != 0) { + xEventGroup->uxEventBits = ~uxBitsToWaitFor & uVar1; + } + } + } + else { + if (uxBitsToWaitFor == (uxBitsToWaitFor & uVar1)) goto LAB_23032028; + } + vTaskExitCritical(); +LAB_23031fe0: + return uVar1 & 0xffffff; + } + } + else { + vAssertCalled(); + BVar2 = xTaskGetSchedulerState(); + if (BVar2 == 0) goto LAB_23031fe8; +LAB_23031f68: + vTaskSuspendAll(); + uVar1 = xEventGroup->uxEventBits; + uVar3 = uxBitsToWaitFor & uVar1; + if (xWaitForAllBits == 0) goto LAB_23031f78; +LAB_23031fac: + if (uxBitsToWaitFor != uVar3) goto LAB_23031fb0; + } + if (xClearOnExit != 0) { + xEventGroup->uxEventBits = ~uxBitsToWaitFor & uVar1; + xTaskResumeAll(); + return uVar1; + } +LAB_23032002: + xTaskResumeAll(); + return uVar1; +} + + + +EventBits_t xEventGroupSetBits(EventGroupHandle_t xEventGroup,EventBits_t uxBitsToSet) + +{ + xLIST_ITEM *pxEventListItem; + xLIST_ITEM *pxVar1; + uint uVar2; + uint uVar3; + xLIST_ITEM *pxVar4; + uint uVar5; + + if (xEventGroup == (EventGroupHandle_t)0x0) { + vAssertCalled(); + } + if ((uxBitsToSet & 0xff000000) != 0) { + vAssertCalled(); + } + vTaskSuspendAll(); + pxEventListItem = (xEventGroup->xTasksWaitingForBits).xListEnd.pxNext; + pxVar4 = (xLIST_ITEM *)&(xEventGroup->xTasksWaitingForBits).xListEnd; + uxBitsToSet = uxBitsToSet | xEventGroup->uxEventBits; + xEventGroup->uxEventBits = uxBitsToSet; + if (pxVar4 != pxEventListItem) { + uVar5 = 0; + do { + while( true ) { + uVar3 = ((ListItem_t *)pxEventListItem)->xItemValue; + uVar2 = uVar3 & 0xffffff; + pxVar1 = ((ListItem_t *)pxEventListItem)->pxNext; + if ((int)(uVar3 << 5) < 0) break; + if ((uVar2 & uxBitsToSet) != 0) { +LAB_230320a6: + if ((int)(uVar3 << 7) < 0) { + uVar5 = uVar5 | uVar2; + } + vTaskRemoveFromUnorderedEventList((ListItem_t *)pxEventListItem,uxBitsToSet | 0x2000000); + uxBitsToSet = xEventGroup->uxEventBits; + } + pxEventListItem = pxVar1; + if (pxVar4 == pxVar1) goto LAB_230320bc; + } + if (uVar2 == (uVar2 & uxBitsToSet)) goto LAB_230320a6; + pxEventListItem = pxVar1; + } while (pxVar4 != pxVar1); +LAB_230320bc: + uxBitsToSet = uxBitsToSet & ~uVar5; + } + xEventGroup->uxEventBits = uxBitsToSet; + xTaskResumeAll(); + return xEventGroup->uxEventBits; +} + + + +void vEventGroupDelete(EventGroupHandle_t xEventGroup) + +{ + ListItem_t *pxEventListItem; + UBaseType_t UVar1; + + vTaskSuspendAll(); + UVar1 = (xEventGroup->xTasksWaitingForBits).uxNumberOfItems; + while (UVar1 != 0) { + while (pxEventListItem = (ListItem_t *)(xEventGroup->xTasksWaitingForBits).xListEnd.pxNext, + pxEventListItem != (ListItem_t *)&(xEventGroup->xTasksWaitingForBits).xListEnd) { + vTaskRemoveFromUnorderedEventList(pxEventListItem,0x2000000); + if ((xEventGroup->xTasksWaitingForBits).uxNumberOfItems == 0) goto LAB_23032130; + } + vAssertCalled(); + vTaskRemoveFromUnorderedEventList + ((ListItem_t *)(xEventGroup->xTasksWaitingForBits).xListEnd.pxNext,0x2000000); + UVar1 = (xEventGroup->xTasksWaitingForBits).uxNumberOfItems; + } +LAB_23032130: + if (xEventGroup->ucStaticallyAllocated != '\0') { + xTaskResumeAll(); + return; + } + vPortFree(xEventGroup); + xTaskResumeAll(); + return; +} + + + +void vListInitialise(List_t *pxList) + +{ + ListItem_t *pLVar1; + + pLVar1 = (ListItem_t *)&pxList->xListEnd; + pxList->pxIndex = pLVar1; + (pxList->xListEnd).xItemValue = 0xffffffff; + *(ListItem_t **)&(pxList->xListEnd).pxNext = pLVar1; + *(ListItem_t **)&(pxList->xListEnd).pxPrevious = pLVar1; + pxList->uxNumberOfItems = 0; + return; +} + + + +void vListInitialiseItem(ListItem_t *pxItem) + +{ + pxItem->pvContainer = (xLIST *)0x0; + return; +} + + + +void vListInsertEnd(List_t *pxList,ListItem_t *pxNewListItem) + +{ + xLIST_ITEM *pxVar1; + ListItem_t *pLVar2; + + pLVar2 = pxList->pxIndex; + *(ListItem_t **)&pxNewListItem->pxNext = pLVar2; + pxVar1 = pLVar2->pxPrevious; + pxNewListItem->pxPrevious = pxVar1; + *(ListItem_t **)&pxVar1->pxNext = pxNewListItem; + *(ListItem_t **)&pLVar2->pxPrevious = pxNewListItem; + *(List_t **)&pxNewListItem->pvContainer = pxList; + pxList->uxNumberOfItems = pxList->uxNumberOfItems + 1; + return; +} + + + +void vListInsert(List_t *pxList,ListItem_t *pxNewListItem) + +{ + xLIST_ITEM *pxVar1; + xLIST_ITEM *pxVar2; + + pxVar2 = (xLIST_ITEM *)&pxList->xListEnd; + if (pxNewListItem->xItemValue == 0xffffffff) { + pxVar1 = (pxList->xListEnd).pxPrevious; + pxVar2 = pxVar1->pxNext; + } + else { + do { + pxVar1 = pxVar2; + pxVar2 = pxVar1->pxNext; + } while (pxVar2->xItemValue <= pxNewListItem->xItemValue); + } + pxNewListItem->pxNext = pxVar2; + *(ListItem_t **)&pxVar2->pxPrevious = pxNewListItem; + pxNewListItem->pxPrevious = pxVar1; + *(ListItem_t **)&pxVar1->pxNext = pxNewListItem; + *(List_t **)&pxNewListItem->pvContainer = pxList; + pxList->uxNumberOfItems = pxList->uxNumberOfItems + 1; + return; +} + + + +UBaseType_t uxListRemove(ListItem_t *pxItemToRemove) + +{ + xLIST_ITEM *pxVar1; + xLIST *pxVar2; + + pxVar1 = pxItemToRemove->pxPrevious; + pxVar2 = pxItemToRemove->pvContainer; + pxItemToRemove->pxNext->pxPrevious = pxVar1; + pxVar1->pxNext = pxItemToRemove->pxNext; + if (pxVar2->pxIndex != pxItemToRemove) { + pxItemToRemove->pvContainer = (xLIST *)0x0; + pxVar2->uxNumberOfItems = pxVar2->uxNumberOfItems - 1; + return pxVar2->uxNumberOfItems; + } + pxVar2->pxIndex = (ListItem_t *)pxItemToRemove->pxPrevious; + pxItemToRemove->pvContainer = (xLIST *)0x0; + pxVar2->uxNumberOfItems = pxVar2->uxNumberOfItems - 1; + return pxVar2->uxNumberOfItems; +} + + + +BaseType_t prvCopyDataToQueue(Queue_t *pxQueue,void *pvItemToQueue,BaseType_t xPosition) + +{ + UBaseType_t UVar1; + BaseType_t BVar2; + UBaseType_t UVar3; + size_t __n; + int8_t *piVar4; + int8_t *piVar5; + + __n = pxQueue->uxItemSize; + UVar1 = pxQueue->uxMessagesWaiting; + if (__n == 0) { + UVar1 = UVar1 + 1; + BVar2 = 0; + if (pxQueue->pcHead == (int8_t *)0x0) { + BVar2 = xTaskPriorityDisinherit(*(TaskHandle_t *)&pxQueue->u); + *(undefined4 *)&pxQueue->u = 0; + } + } + else { + if (xPosition == 0) { + UVar1 = UVar1 + 1; + memcpy(pxQueue->pcWriteTo,pvItemToQueue,__n); + piVar4 = pxQueue->pcWriteTo; + BVar2 = 0; + pxQueue->pcWriteTo = piVar4 + pxQueue->uxItemSize; + if (*(int8_t **)&pxQueue->u <= piVar4 + pxQueue->uxItemSize) { + pxQueue->uxMessagesWaiting = UVar1; + pxQueue->pcWriteTo = pxQueue->pcHead; + return 0; + } + } + else { + memcpy(*(void **)((int)&pxQueue->u + 4),pvItemToQueue,__n); + UVar3 = pxQueue->uxItemSize; + piVar4 = pxQueue->pcHead; + piVar5 = (int8_t *)(*(int *)((int)&pxQueue->u + 4) + -UVar3); + *(int8_t **)((int)&pxQueue->u + 4) = piVar5; + if (piVar5 < piVar4) { + *(int *)((int)&pxQueue->u + 4) = -UVar3 + *(int *)&pxQueue->u; + } + if (xPosition != 2) { + pxQueue->uxMessagesWaiting = UVar1 + 1; + return 0; + } + BVar2 = 0; + if (UVar1 == 0) { + UVar1 = 1; + } + } + } + pxQueue->uxMessagesWaiting = UVar1; + return BVar2; +} + + + +void prvCopyDataFromQueue(Queue_t *pxQueue,void *pvBuffer) + +{ + int8_t *__src; + size_t __n; + int8_t *piVar1; + + __n = pxQueue->uxItemSize; + if (__n != 0) { + piVar1 = *(int8_t **)&pxQueue->u; + __src = (int8_t *)(*(int *)((int)&pxQueue->u + 4) + __n); + *(int8_t **)((int)&pxQueue->u + 4) = __src; + if (piVar1 <= __src) { + __src = pxQueue->pcHead; + *(int8_t **)((int)&pxQueue->u + 4) = __src; + } + memcpy(pvBuffer,__src,__n); + return; + } + return; +} + + + +void prvUnlockQueue(Queue_t *pxQueue) + +{ + char cVar1; + int iVar2; + BaseType_t BVar3; + uint uVar4; + + vTaskEnterCritical(); + iVar2 = (int)pxQueue->cTxLock; + if ((0 < iVar2) && ((pxQueue->xTasksWaitingToReceive).uxNumberOfItems != 0)) { + do { + BVar3 = xTaskRemoveFromEventList(&pxQueue->xTasksWaitingToReceive); + if (BVar3 == 0) { + uVar4 = iVar2 - 1U & 0xff; + cVar1 = (char)uVar4; + } + else { + vTaskMissedYield(); + uVar4 = iVar2 - 1U & 0xff; + cVar1 = (char)uVar4; + } + } while ((uVar4 != 0) && + (iVar2 = (int)cVar1, (pxQueue->xTasksWaitingToReceive).uxNumberOfItems != 0)); + } + pxQueue->cTxLock = -1; + vTaskExitCritical(); + vTaskEnterCritical(); + iVar2 = (int)pxQueue->cRxLock; + if ((0 < iVar2) && ((pxQueue->xTasksWaitingToSend).uxNumberOfItems != 0)) { + do { + BVar3 = xTaskRemoveFromEventList(&pxQueue->xTasksWaitingToSend); + if (BVar3 == 0) { + uVar4 = iVar2 - 1U & 0xff; + cVar1 = (char)uVar4; + } + else { + vTaskMissedYield(); + uVar4 = iVar2 - 1U & 0xff; + cVar1 = (char)uVar4; + } + } while ((uVar4 != 0) && + (iVar2 = (int)cVar1, (pxQueue->xTasksWaitingToSend).uxNumberOfItems != 0)); + } + pxQueue->cRxLock = -1; + vTaskExitCritical(); + return; +} + + + +BaseType_t xQueueGenericReset(QueueHandle_t xQueue,BaseType_t xNewQueue) + +{ + BaseType_t BVar1; + int8_t *piVar2; + int iVar3; + + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + vTaskEnterCritical(); + piVar2 = xQueue->pcHead; + xQueue->uxMessagesWaiting = 0; + iVar3 = xQueue->uxItemSize * xQueue->uxLength; + xQueue->cRxLock = -1; + xQueue->pcWriteTo = piVar2; + xQueue->cTxLock = -1; + *(int8_t **)&xQueue->u = piVar2 + iVar3; + *(int8_t **)((int)&xQueue->u + 4) = piVar2 + (iVar3 - xQueue->uxItemSize); + if (xNewQueue == 0) { + if (((xQueue->xTasksWaitingToSend).uxNumberOfItems != 0) && + (BVar1 = xTaskRemoveFromEventList(&xQueue->xTasksWaitingToSend), BVar1 != 0)) { + ecall(); + vTaskExitCritical(); + return 1; + } + vTaskExitCritical(); + return 1; + } + vListInitialise(&xQueue->xTasksWaitingToSend); + vListInitialise(&xQueue->xTasksWaitingToReceive); + vTaskExitCritical(); + return 1; +} + + + +// WARNING: Removing unreachable block (ram,0x2303241e) + +QueueHandle_t +xQueueGenericCreateStatic + (UBaseType_t uxQueueLength,UBaseType_t uxItemSize,uint8_t *pucQueueStorage, + StaticQueue_t *pxStaticQueue,uint8_t ucQueueType) + +{ + size_t xSize; + + if (uxQueueLength == 0) { + vAssertCalled(); + } + if (pxStaticQueue == (StaticQueue_t *)0x0) { + vAssertCalled(); + } + if (pucQueueStorage == (uint8_t *)0x0) { + if (uxItemSize == 0) goto LAB_23032422; + } + else { + if (uxItemSize != 0) goto LAB_23032422; + } + vAssertCalled(); +LAB_23032422: + if (pxStaticQueue != (StaticQueue_t *)0x0) { + pxStaticQueue->ucDummy6 = '\x01'; + if (uxItemSize == 0) { + pucQueueStorage = (uint8_t *)pxStaticQueue; + } + *(uint8_t **)pxStaticQueue->pvDummy1 = pucQueueStorage; + pxStaticQueue->uxDummy4[1] = uxQueueLength; + pxStaticQueue->uxDummy4[2] = uxItemSize; + xQueueGenericReset((QueueHandle_t)pxStaticQueue,1); + pxStaticQueue->ucDummy9 = ucQueueType; + } + return (QueueHandle_t)pxStaticQueue; +} + + + +QueueHandle_t +xQueueGenericCreate(UBaseType_t uxQueueLength,UBaseType_t uxItemSize,uint8_t ucQueueType) + +{ + QueueHandle_t xQueue; + + if (uxQueueLength == 0) { + vAssertCalled(); + } + if (uxItemSize == 0) { + xQueue = (QueueHandle_t)pvPortMalloc(0x50); + if (xQueue == (QueueHandle_t)0x0) { + return (QueueHandle_t)0x0; + } + xQueue->ucStaticallyAllocated = '\0'; + *(QueueHandle_t *)&xQueue->pcHead = xQueue; + } + else { + xQueue = (QueueHandle_t)pvPortMalloc(uxQueueLength * uxItemSize + 0x50); + if (xQueue == (QueueHandle_t)0x0) { + return (QueueHandle_t)0x0; + } + xQueue->ucStaticallyAllocated = '\0'; + *(QueueHandle_t *)&xQueue->pcHead = xQueue + 1; + } + xQueue->uxLength = uxQueueLength; + xQueue->uxItemSize = uxItemSize; + xQueueGenericReset(xQueue,1); + xQueue->ucQueueType = ucQueueType; + return xQueue; +} + + + +QueueHandle_t xQueueCreateCountingSemaphore(UBaseType_t uxMaxCount,UBaseType_t uxInitialCount) + +{ + bool bVar1; + QueueHandle_t pQVar2; + + if (uxMaxCount == 0) { + vAssertCalled(); + bVar1 = uxInitialCount == 0; + } + else { + bVar1 = uxInitialCount <= uxMaxCount; + } + if (!bVar1) { + vAssertCalled(); + } + pQVar2 = xQueueGenericCreate(uxMaxCount,0,'\x02'); + if (pQVar2 != (QueueHandle_t)0x0) { + pQVar2->uxMessagesWaiting = uxInitialCount; + } + return pQVar2; +} + + + +// WARNING: Variable defined which should be unmapped: xTimeOut + +BaseType_t +xQueueGenericSend(QueueHandle_t xQueue,void *pvItemToQueue,TickType_t xTicksToWait, + BaseType_t xCopyPosition) + +{ + bool bVar1; + BaseType_t BVar2; + int iVar3; + TickType_t local_34 [3]; + undefined auStack40 [4]; + TimeOut_t xTimeOut; + + local_34[0] = xTicksToWait; + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + if ((pvItemToQueue == (void *)0x0) && (xQueue->uxItemSize != 0)) { + vAssertCalled(); + } + if ((xCopyPosition == 2) && (xQueue->uxLength != 1)) { + vAssertCalled(); + } + BVar2 = xTaskGetSchedulerState(); + if ((BVar2 == 0) && (local_34[0] != 0)) { + vAssertCalled(); + } + vTaskEnterCritical(); + bVar1 = false; + if (xQueue->uxLength <= xQueue->uxMessagesWaiting) { + do { + if (xCopyPosition == 2) break; + if (local_34[0] == 0) { + vTaskExitCritical(); + return 0; + } + if (!bVar1) { + vTaskInternalSetTimeOutState((TimeOut_t *)auStack40); + } + vTaskExitCritical(); + vTaskSuspendAll(); + vTaskEnterCritical(); + if (xQueue->cRxLock == -1) { + xQueue->cRxLock = '\0'; + } + if (xQueue->cTxLock == -1) { + xQueue->cTxLock = '\0'; + } + vTaskExitCritical(); + BVar2 = xTaskCheckForTimeOut((TimeOut_t *)auStack40,local_34); + if (BVar2 != 0) { + prvUnlockQueue((Queue_t *)xQueue); + xTaskResumeAll(); + return 0; + } + vTaskEnterCritical(); + if (xQueue->uxMessagesWaiting == xQueue->uxLength) { + vTaskExitCritical(); + vTaskPlaceOnEventList(&xQueue->xTasksWaitingToSend,local_34[0]); + prvUnlockQueue((Queue_t *)xQueue); + BVar2 = xTaskResumeAll(); + if (BVar2 == 0) { + ecall(); + } + } + else { + vTaskExitCritical(); + prvUnlockQueue((Queue_t *)xQueue); + xTaskResumeAll(); + } + bVar1 = true; + vTaskEnterCritical(); + } while (xQueue->uxLength <= xQueue->uxMessagesWaiting); + } + iVar3 = prvCopyDataToQueue((Queue_t *)xQueue,pvItemToQueue,xCopyPosition); + if ((xQueue->xTasksWaitingToReceive).uxNumberOfItems != 0) { + iVar3 = xTaskRemoveFromEventList(&xQueue->xTasksWaitingToReceive); + } + if (iVar3 != 0) { + ecall(); + } + vTaskExitCritical(); + return 1; +} + + + +QueueHandle_t xQueueCreateMutexStatic(uint8_t ucQueueType,StaticQueue_t *pxStaticQueue) + +{ + QueueHandle_t xQueue; + + xQueue = xQueueGenericCreateStatic(1,0,(uint8_t *)0x0,pxStaticQueue,ucQueueType); + if (xQueue != (QueueHandle_t)0x0) { + *(undefined4 *)&xQueue->u = 0; + xQueue->pcHead = (int8_t *)0x0; + *(undefined4 *)((int)&xQueue->u + 4) = 0; + xQueueGenericSend(xQueue,(void *)0x0,0,0); + } + return xQueue; +} + + + +QueueHandle_t xQueueCreateMutex(uint8_t ucQueueType) + +{ + QueueHandle_t xQueue; + + xQueue = xQueueGenericCreate(1,0,ucQueueType); + if (xQueue != (QueueHandle_t)0x0) { + *(undefined4 *)&xQueue->u = 0; + xQueue->pcHead = (int8_t *)0x0; + *(undefined4 *)((int)&xQueue->u + 4) = 0; + xQueueGenericSend(xQueue,(void *)0x0,0,0); + } + return xQueue; +} + + + +BaseType_t +xQueueGenericSendFromISR + (QueueHandle_t xQueue,void *pvItemToQueue,BaseType_t *pxHigherPriorityTaskWoken, + BaseType_t xCopyPosition) + +{ + byte bVar1; + BaseType_t BVar2; + + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + if ((pvItemToQueue == (void *)0x0) && (xQueue->uxItemSize != 0)) { + vAssertCalled(); + } + if (xCopyPosition == 2) { + if (xQueue->uxLength != 1) { + vAssertCalled(); + } + } + else { + if (xQueue->uxLength <= xQueue->uxMessagesWaiting) { + return 0; + } + } + bVar1 = xQueue->cTxLock; + prvCopyDataToQueue((Queue_t *)xQueue,pvItemToQueue,xCopyPosition); + if (bVar1 == 0xff) { + if ((((xQueue->xTasksWaitingToReceive).uxNumberOfItems != 0) && + (BVar2 = xTaskRemoveFromEventList(&xQueue->xTasksWaitingToReceive), BVar2 != 0)) && + (pxHigherPriorityTaskWoken != (BaseType_t *)0x0)) { + *pxHigherPriorityTaskWoken = 1; + } + return 1; + } + xQueue->cTxLock = (int8_t)(((uint)bVar1 + 1) * 0x1000000 >> 0x18); + return 1; +} + + + +BaseType_t xQueueGiveFromISR(QueueHandle_t xQueue,BaseType_t *pxHigherPriorityTaskWoken) + +{ + BaseType_t BVar1; + int8_t *piVar2; + + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + if (xQueue->uxItemSize == 0) { + piVar2 = xQueue->pcHead; + } + else { + vAssertCalled(); + piVar2 = xQueue->pcHead; + } + if ((piVar2 == (int8_t *)0x0) && (*(int *)&xQueue->u != 0)) { + vAssertCalled(); + } + BVar1 = 0; + if (xQueue->uxMessagesWaiting < xQueue->uxLength) { + xQueue->uxMessagesWaiting = xQueue->uxMessagesWaiting + 1; + if (xQueue->cTxLock == 0xff) { + if ((((xQueue->xTasksWaitingToReceive).uxNumberOfItems != 0) && + (BVar1 = xTaskRemoveFromEventList(&xQueue->xTasksWaitingToReceive), BVar1 != 0)) && + (pxHigherPriorityTaskWoken != (BaseType_t *)0x0)) { + *pxHigherPriorityTaskWoken = 1; + return 1; + } + } + else { + xQueue->cTxLock = (int8_t)(((uint)(byte)xQueue->cTxLock + 1) * 0x1000000 >> 0x18); + } + BVar1 = 1; + } + return BVar1; +} + + + +BaseType_t xQueueReceive(QueueHandle_t xQueue,void *pvBuffer,TickType_t xTicksToWait) + +{ + BaseType_t BVar1; + UBaseType_t UVar2; + TickType_t local_34 [3]; + undefined auStack40 [4]; + TimeOut_t xTimeOut; + + local_34[0] = xTicksToWait; + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + if ((pvBuffer == (void *)0x0) && (xQueue->uxItemSize != 0)) { + vAssertCalled(); + } + BVar1 = xTaskGetSchedulerState(); + if ((BVar1 == 0) && (local_34[0] != 0)) { + vAssertCalled(); + } + vTaskEnterCritical(); + UVar2 = xQueue->uxMessagesWaiting; + if (UVar2 != 0) { +LAB_230328f8: + prvCopyDataFromQueue((Queue_t *)xQueue,pvBuffer); + xQueue->uxMessagesWaiting = UVar2 - 1; + if (((xQueue->xTasksWaitingToSend).uxNumberOfItems != 0) && + (BVar1 = xTaskRemoveFromEventList(&xQueue->xTasksWaitingToSend), BVar1 != 0)) { + ecall(); + } + vTaskExitCritical(); + return 1; + } + if (local_34[0] != 0) { + vTaskInternalSetTimeOutState((TimeOut_t *)auStack40); + do { + vTaskExitCritical(); + vTaskSuspendAll(); + vTaskEnterCritical(); + if (xQueue->cRxLock == -1) { + xQueue->cRxLock = '\0'; + } + if (xQueue->cTxLock == -1) { + xQueue->cTxLock = '\0'; + } + vTaskExitCritical(); + BVar1 = xTaskCheckForTimeOut((TimeOut_t *)auStack40,local_34); + if (BVar1 == 0) { + vTaskEnterCritical(); + if (xQueue->uxMessagesWaiting == 0) { + vTaskExitCritical(); + vTaskPlaceOnEventList(&xQueue->xTasksWaitingToReceive,local_34[0]); + prvUnlockQueue((Queue_t *)xQueue); + BVar1 = xTaskResumeAll(); + if (BVar1 == 0) { + ecall(); + } + goto LAB_230328ec; + } + vTaskExitCritical(); + prvUnlockQueue((Queue_t *)xQueue); + xTaskResumeAll(); + vTaskEnterCritical(); + UVar2 = xQueue->uxMessagesWaiting; + } + else { + prvUnlockQueue((Queue_t *)xQueue); + xTaskResumeAll(); + vTaskEnterCritical(); + if (xQueue->uxMessagesWaiting == 0) break; + vTaskExitCritical(); +LAB_230328ec: + vTaskEnterCritical(); + UVar2 = xQueue->uxMessagesWaiting; + } + if (UVar2 != 0) goto LAB_230328f8; + } while (local_34[0] != 0); + } + vTaskExitCritical(); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling + +BaseType_t xQueueSemaphoreTake(QueueHandle_t xQueue,TickType_t xTicksToWait) + +{ + bool bVar1; + BaseType_t BVar2; + TaskHandle_t ptVar3; + UBaseType_t uxHighestPriorityWaitingTask; + int iVar4; + TickType_t local_34 [3]; + undefined auStack40 [4]; + TimeOut_t xTimeOut; + + local_34[0] = xTicksToWait; + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + if (xQueue->uxItemSize != 0) { + vAssertCalled(); + } + BVar2 = xTaskGetSchedulerState(); + if ((BVar2 == 0) && (local_34[0] != 0)) { + vAssertCalled(); + } + vTaskEnterCritical(); + uxHighestPriorityWaitingTask = xQueue->uxMessagesWaiting; + iVar4 = 0; + bVar1 = false; + while( true ) { + if (uxHighestPriorityWaitingTask != 0) { + xQueue->uxMessagesWaiting = uxHighestPriorityWaitingTask - 1; + if (xQueue->pcHead == (int8_t *)0x0) { + ptVar3 = pvTaskIncrementMutexHeldCount(); + *(TaskHandle_t *)&xQueue->u = ptVar3; + } + if (((xQueue->xTasksWaitingToSend).uxNumberOfItems != 0) && + (BVar2 = xTaskRemoveFromEventList(&xQueue->xTasksWaitingToSend), BVar2 != 0)) { + ecall(); + } + vTaskExitCritical(); + return 1; + } + if (local_34[0] == 0) break; + if (!bVar1) { + vTaskInternalSetTimeOutState((TimeOut_t *)auStack40); + } + vTaskExitCritical(); + vTaskSuspendAll(); + vTaskEnterCritical(); + if (xQueue->cRxLock == -1) { + xQueue->cRxLock = '\0'; + } + if (xQueue->cTxLock == -1) { + xQueue->cTxLock = '\0'; + } + vTaskExitCritical(); + BVar2 = xTaskCheckForTimeOut((TimeOut_t *)auStack40,local_34); + if (BVar2 == 0) { + vTaskEnterCritical(); + if (xQueue->uxMessagesWaiting == 0) { + vTaskExitCritical(); + if (xQueue->pcHead == (int8_t *)0x0) { + vTaskEnterCritical(); + iVar4 = xTaskPriorityInherit(*(TaskHandle_t *)&xQueue->u); + vTaskExitCritical(); + } + vTaskPlaceOnEventList(&xQueue->xTasksWaitingToReceive,local_34[0]); + prvUnlockQueue((Queue_t *)xQueue); + BVar2 = xTaskResumeAll(); + if (BVar2 == 0) { + ecall(); + } + } + else { + vTaskExitCritical(); + prvUnlockQueue((Queue_t *)xQueue); + xTaskResumeAll(); + } + } + else { + prvUnlockQueue((Queue_t *)xQueue); + xTaskResumeAll(); + vTaskEnterCritical(); + if (xQueue->uxMessagesWaiting == 0) { + vTaskExitCritical(); + if (iVar4 == 0) { + return 0; + } + vTaskEnterCritical(); + uxHighestPriorityWaitingTask = (xQueue->xTasksWaitingToReceive).uxNumberOfItems; + if (uxHighestPriorityWaitingTask != 0) { + uxHighestPriorityWaitingTask = + 0x20 - ((xQueue->xTasksWaitingToReceive).xListEnd.pxNext)->xItemValue; + } + vTaskPriorityDisinheritAfterTimeout + (*(TaskHandle_t *)&xQueue->u,uxHighestPriorityWaitingTask); + vTaskExitCritical(); + return 0; + } + vTaskExitCritical(); + } + bVar1 = true; + vTaskEnterCritical(); + uxHighestPriorityWaitingTask = xQueue->uxMessagesWaiting; + } + if (iVar4 != 0) { + vAssertCalled(); + } + vTaskExitCritical(); + return 0; +} + + + +UBaseType_t uxQueueMessagesWaiting(QueueHandle_t xQueue) + +{ + UBaseType_t UVar1; + + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + } + vTaskEnterCritical(); + UVar1 = xQueue->uxMessagesWaiting; + vTaskExitCritical(); + return UVar1; +} + + + +void vQueueDelete(QueueHandle_t xQueue) + +{ + QueueHandle_t *ppQVar1; + int iVar2; + QueueRegistryItem_t *pQVar3; + + if (xQueue == (QueueHandle_t)0x0) { + vAssertCalled(); + iVar2 = 0; + pQVar3 = xQueueRegistry; + do { + ppQVar1 = &pQVar3->xHandle; + pQVar3 = pQVar3 + 1; + if (*ppQVar1 == (QueueHandle_t)0x0) { + xQueueRegistry[iVar2].pcQueueName = (char *)0x0; + xQueueRegistry[iVar2].xHandle = (QueueHandle_t)0x0; + break; + } + iVar2 = iVar2 + 1; + } while (iVar2 != 8); + if (cRam00000046 != '\0') { + return; + } + vPortFree((void *)0x0); + return; + } + iVar2 = 0; + pQVar3 = xQueueRegistry; + do { + ppQVar1 = &pQVar3->xHandle; + pQVar3 = pQVar3 + 1; + if (xQueue == *ppQVar1) { + xQueueRegistry[iVar2].pcQueueName = (char *)0x0; + xQueueRegistry[iVar2].xHandle = (QueueHandle_t)0x0; + break; + } + iVar2 = iVar2 + 1; + } while (iVar2 != 8); + if (xQueue->ucStaticallyAllocated != '\0') { + return; + } + vPortFree(xQueue); + return; +} + + + +void vQueueAddToRegistry(QueueHandle_t xQueue,char *pcQueueName) + +{ + char **ppcVar1; + int iVar2; + QueueRegistryItem_t *pQVar3; + + iVar2 = 0; + pQVar3 = xQueueRegistry; + do { + ppcVar1 = &pQVar3->pcQueueName; + pQVar3 = pQVar3 + 1; + if (*ppcVar1 == (char *)0x0) { + xQueueRegistry[iVar2].pcQueueName = pcQueueName; + xQueueRegistry[iVar2].xHandle = xQueue; + return; + } + iVar2 = iVar2 + 1; + } while (iVar2 != 8); + return; +} + + + +void vQueueWaitForMessageRestricted + (QueueHandle_t xQueue,TickType_t xTicksToWait,BaseType_t xWaitIndefinitely) + +{ + vTaskEnterCritical(); + if (xQueue->cRxLock == -1) { + xQueue->cRxLock = '\0'; + } + if (xQueue->cTxLock == -1) { + xQueue->cTxLock = '\0'; + } + vTaskExitCritical(); + if (xQueue->uxMessagesWaiting != 0) { + prvUnlockQueue((Queue_t *)xQueue); + return; + } + vTaskPlaceOnEventListRestricted(&xQueue->xTasksWaitingToReceive,xTicksToWait,xWaitIndefinitely); + prvUnlockQueue((Queue_t *)xQueue); + return; +} + + + +void prvInitialiseNewStreamBuffer + (StreamBuffer_t *pxStreamBuffer,uint8_t *pucBuffer,size_t xBufferSizeBytes, + size_t xTriggerLevelBytes,uint8_t ucFlags) + +{ + uint8_t *puVar1; + + puVar1 = (uint8_t *)memset(pucBuffer,0x55,xBufferSizeBytes); + if (pucBuffer != puVar1) { + vAssertCalled(); + } + memset(pxStreamBuffer,0,0x24); + pxStreamBuffer->pucBuffer = pucBuffer; + pxStreamBuffer->xLength = xBufferSizeBytes; + pxStreamBuffer->xTriggerLevelBytes = xTriggerLevelBytes; + pxStreamBuffer->ucFlags = ucFlags; + return; +} + + + +size_t prvWriteBytesToBuffer(StreamBuffer_t *pxStreamBuffer,uint8_t *pucData,size_t xCount) + +{ + uint uVar1; + uint __n; + size_t __n_00; + + if (xCount == 0) { + vAssertCalled(); + uVar1 = pxStreamBuffer->xHead; + if (pxStreamBuffer->xLength < uVar1) { + __n_00 = 0; + goto LAB_23032d00; + } + memcpy(pxStreamBuffer->pucBuffer + uVar1,pucData,0); + __n = pxStreamBuffer->xLength; + if (uVar1 < __n) goto LAB_23032cde; + } + else { + uVar1 = pxStreamBuffer->xHead; + __n_00 = pxStreamBuffer->xLength - uVar1; + if (xCount < __n_00) { + __n = uVar1 + xCount; + __n_00 = xCount; + } + else { + __n = uVar1 + __n_00; + } + if (pxStreamBuffer->xLength < __n) { +LAB_23032d00: + vAssertCalled(); + } + memcpy(pxStreamBuffer->pucBuffer + uVar1,pucData,__n_00); + if (__n_00 < xCount) { + __n = xCount - __n_00; + if (pxStreamBuffer->xLength < __n) { + vAssertCalled(); + memcpy(pxStreamBuffer->pucBuffer,pucData + __n_00,__n); + } + else { + memcpy(pxStreamBuffer->pucBuffer,pucData + __n_00,__n); + } + } + __n = pxStreamBuffer->xLength; + uVar1 = uVar1 + xCount; + if (uVar1 < __n) goto LAB_23032cde; + } + uVar1 = uVar1 - __n; +LAB_23032cde: + pxStreamBuffer->xHead = uVar1; + return xCount; +} + + + +size_t prvReadBytesFromBuffer + (StreamBuffer_t *pxStreamBuffer,uint8_t *pucData,size_t xMaxCount, + size_t xBytesAvailable) + +{ + size_t sVar1; + uint __n; + + if (xMaxCount <= xBytesAvailable) { + xBytesAvailable = xMaxCount; + } + if (xBytesAvailable == 0) { + return 0; + } + sVar1 = pxStreamBuffer->xTail; + __n = pxStreamBuffer->xLength - sVar1; + if (xBytesAvailable < __n) { + __n = xBytesAvailable; + if (xBytesAvailable <= xMaxCount) goto LAB_23032d6e; +LAB_23032dc8: + vAssertCalled(); + if (sVar1 + __n <= pxStreamBuffer->xLength) goto LAB_23032d76; + } + else { + if (xMaxCount < __n) goto LAB_23032dc8; +LAB_23032d6e: + if (sVar1 + __n <= pxStreamBuffer->xLength) goto LAB_23032d76; + } + vAssertCalled(); +LAB_23032d76: + memcpy(pucData,pxStreamBuffer->pucBuffer + sVar1,__n); + if (__n < xBytesAvailable) { + if (xMaxCount < xBytesAvailable) { + vAssertCalled(); + } + memcpy(pucData + __n,pxStreamBuffer->pucBuffer,xBytesAvailable - __n); + } + sVar1 = sVar1 + xBytesAvailable; + if (pxStreamBuffer->xLength <= sVar1) { + sVar1 = sVar1 - pxStreamBuffer->xLength; + } + pxStreamBuffer->xTail = sVar1; + return xBytesAvailable; +} + + + +StreamBufferHandle_t +xStreamBufferGenericCreate + (size_t xBufferSizeBytes,size_t xTriggerLevelBytes,BaseType_t xIsMessageBuffer) + +{ + uint8_t uVar1; + StreamBuffer_t *pxStreamBuffer; + uint8_t ucFlags; + + ucFlags = (uint8_t)xBufferSizeBytes; + if (xIsMessageBuffer == 1) { + uVar1 = '\x01'; + if (xBufferSizeBytes < 5) { + vAssertCalled(); + uVar1 = '\x01'; + } +joined_r0x23032e52: + ucFlags = uVar1; + if (xTriggerLevelBytes <= xBufferSizeBytes) goto joined_r0x23032e00; + } + else { + uVar1 = '\0'; + if (xBufferSizeBytes != 0) goto joined_r0x23032e52; + vAssertCalled(); + if (xTriggerLevelBytes == 0) goto joined_r0x23032e00; + } + vAssertCalled(); +joined_r0x23032e00: + if (xTriggerLevelBytes == 0) { + xTriggerLevelBytes = 1; + } + pxStreamBuffer = (StreamBuffer_t *)pvPortMalloc(xBufferSizeBytes + 0x25); + if (pxStreamBuffer != (StreamBuffer_t *)0x0) { + prvInitialiseNewStreamBuffer + (pxStreamBuffer,(uint8_t *)(pxStreamBuffer + 1),xBufferSizeBytes + 1, + xTriggerLevelBytes,ucFlags); + } + return (StreamBufferHandle_t)pxStreamBuffer; +} + + + +// WARNING: Removing unreachable block (ram,0x23032ee4) + +StreamBufferHandle_t +xStreamBufferGenericCreateStatic + (size_t xBufferSizeBytes,size_t xTriggerLevelBytes,BaseType_t xIsMessageBuffer, + uint8_t *pucStreamBufferStorageArea,StaticStreamBuffer_t *pxStaticStreamBuffer) + +{ + size_t xSize; + + if (pucStreamBufferStorageArea == (uint8_t *)0x0) { + vAssertCalled(); + } + if (pxStaticStreamBuffer == (StaticStreamBuffer_t *)0x0) { + vAssertCalled(); + } + if (xBufferSizeBytes < xTriggerLevelBytes) { + vAssertCalled(); + } + if (xTriggerLevelBytes == 0) { + xTriggerLevelBytes = 1; + } + if (xBufferSizeBytes < 5) { + vAssertCalled(); + } + if (pucStreamBufferStorageArea == (uint8_t *)0x0) { + pxStaticStreamBuffer = (StaticStreamBuffer_t *)0x0; + } + else { + if (pxStaticStreamBuffer != (StaticStreamBuffer_t *)0x0) { + prvInitialiseNewStreamBuffer + ((StreamBuffer_t *)pxStaticStreamBuffer,pucStreamBufferStorageArea,xBufferSizeBytes, + xTriggerLevelBytes,(xIsMessageBuffer != 0) + '\x02'); + pxStaticStreamBuffer->ucDummy3 = pxStaticStreamBuffer->ucDummy3 | 2; + } + } + return (StreamBufferHandle_t)pxStaticStreamBuffer; +} + + + +void vStreamBufferDelete(StreamBufferHandle_t xStreamBuffer) + +{ + if (xStreamBuffer == (StreamBufferHandle_t)0x0) { + vAssertCalled(); + if ((bRam0000001c & 2) == 0) { + vPortFree((void *)0x0); + return; + } + memset((void *)0x0,0,0x24); + return; + } + if ((xStreamBuffer->ucFlags & 2) == 0) { + vPortFree(xStreamBuffer); + return; + } + memset(xStreamBuffer,0,0x24); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +size_t xStreamBufferSpacesAvailable(StreamBufferHandle_t xStreamBuffer) + +{ + uint uVar1; + size_t sVar2; + uint uVar3; + + if (xStreamBuffer == (StreamBufferHandle_t)0x0) { + vAssertCalled(); + sVar2 = (_DAT_00000008 + iRam00000000 + -1) - _DAT_00000004; + if (_DAT_00000008 <= sVar2) { + sVar2 = sVar2 - _DAT_00000008; + } + return sVar2; + } + uVar3 = xStreamBuffer->xLength; + uVar1 = (uVar3 + xStreamBuffer->xTail + -1) - xStreamBuffer->xHead; + if (uVar3 <= uVar1) { + return uVar1 - uVar3; + } + return uVar1; +} + + + +size_t xStreamBufferSend(StreamBufferHandle_t xStreamBuffer,void *pvTxData,size_t xDataLengthBytes, + TickType_t xTicksToWait) + +{ + TaskHandle_t ptVar1; + BaseType_t BVar2; + uint uVar3; + uint uVar4; + size_t sVar5; + TickType_t aTStack52 [2]; + size_t sStack44; + undefined auStack40 [4]; + TimeOut_t xTimeOut; + + aTStack52[0] = xTicksToWait; + if (pvTxData == (void *)0x0) { + vAssertCalled(); + } + if (xStreamBuffer == (StreamBufferHandle_t)0x0) { + vAssertCalled(); + } + sVar5 = xDataLengthBytes; + if (((xStreamBuffer->ucFlags & 1) == 0) || + (sVar5 = xDataLengthBytes + 4, xDataLengthBytes < sVar5)) { + if (aTStack52[0] != 0) goto LAB_23032fc2; +LAB_23033064: + uVar3 = xStreamBufferSpacesAvailable(xStreamBuffer); + if (uVar3 != 0) goto LAB_23033014; +LAB_23033070: + sVar5 = 0; + } + else { + vAssertCalled(); + if (aTStack52[0] == 0) goto LAB_23033064; +LAB_23032fc2: + vTaskSetTimeOutState((TimeOut_t *)auStack40); + do { + vTaskEnterCritical(); + uVar3 = xStreamBufferSpacesAvailable(xStreamBuffer); + if (sVar5 <= uVar3) { + vTaskExitCritical(); + break; + } + xTaskNotifyStateClear((TaskHandle_t)0x0); + if (xStreamBuffer->xTaskWaitingToSend != (TaskHandle_t)0x0) { + vAssertCalled(); + } + ptVar1 = xTaskGetCurrentTaskHandle(); + xStreamBuffer->xTaskWaitingToSend = ptVar1; + vTaskExitCritical(); + xTaskNotifyWait(0,0,(uint32_t *)0x0,aTStack52[0]); + xStreamBuffer->xTaskWaitingToSend = (TaskHandle_t)0x0; + BVar2 = xTaskCheckForTimeOut((TimeOut_t *)auStack40,aTStack52); + } while (BVar2 == 0); + if (uVar3 == 0) goto LAB_23033064; +LAB_23033014: + if ((xStreamBuffer->ucFlags & 1) == 0) { + sStack44 = xDataLengthBytes; + if (uVar3 < xDataLengthBytes) { + sStack44 = uVar3; + } + } + else { + if (uVar3 < sVar5) goto LAB_23033070; + sStack44 = xDataLengthBytes; + prvWriteBytesToBuffer((StreamBuffer_t *)xStreamBuffer,(uint8_t *)&sStack44,4); + } + sVar5 = prvWriteBytesToBuffer((StreamBuffer_t *)xStreamBuffer,(uint8_t *)pvTxData,sStack44); + if (sVar5 != 0) { + uVar3 = xStreamBuffer->xLength; + uVar4 = (xStreamBuffer->xHead + uVar3) - xStreamBuffer->xTail; + if (uVar3 <= uVar4) { + uVar4 = uVar4 - uVar3; + } + if (xStreamBuffer->xTriggerLevelBytes <= uVar4) { + vTaskSuspendAll(); + if (xStreamBuffer->xTaskWaitingToReceive != (TaskHandle_t)0x0) { + xTaskGenericNotify(xStreamBuffer->xTaskWaitingToReceive,0,eNoAction,(uint32_t *)0x0); + xStreamBuffer->xTaskWaitingToReceive = (TaskHandle_t)0x0; + } + xTaskResumeAll(); + } + } + } + return sVar5; +} + + + +size_t xStreamBufferSendFromISR + (StreamBufferHandle_t xStreamBuffer,void *pvTxData,size_t xDataLengthBytes, + BaseType_t *pxHigherPriorityTaskWoken) + +{ + size_t sVar1; + uint uVar2; + uint uVar3; + size_t sVar4; + size_t asStack36 [3]; + + if (pvTxData == (void *)0x0) { + vAssertCalled(); + } + if (xStreamBuffer == (StreamBufferHandle_t)0x0) { + vAssertCalled(); + } + sVar4 = xDataLengthBytes; + if ((xStreamBuffer->ucFlags & 1) != 0) { + sVar4 = xDataLengthBytes + 4; + } + sVar1 = xStreamBufferSpacesAvailable(xStreamBuffer); + if (sVar1 == 0) { +LAB_230330e6: + sVar4 = 0; + } + else { + if ((xStreamBuffer->ucFlags & 1) == 0) { + asStack36[0] = xDataLengthBytes; + if (sVar1 < xDataLengthBytes) { + asStack36[0] = sVar1; + } + } + else { + if (sVar1 < sVar4) goto LAB_230330e6; + asStack36[0] = xDataLengthBytes; + prvWriteBytesToBuffer((StreamBuffer_t *)xStreamBuffer,(uint8_t *)asStack36,4); + } + sVar4 = prvWriteBytesToBuffer((StreamBuffer_t *)xStreamBuffer,(uint8_t *)pvTxData,asStack36[0]); + if (sVar4 != 0) { + uVar2 = xStreamBuffer->xLength; + uVar3 = (xStreamBuffer->xHead + uVar2) - xStreamBuffer->xTail; + if (uVar2 <= uVar3) { + uVar3 = uVar3 - uVar2; + } + if ((xStreamBuffer->xTriggerLevelBytes <= uVar3) && + (xStreamBuffer->xTaskWaitingToReceive != (TaskHandle_t)0x0)) { + xTaskGenericNotifyFromISR + (xStreamBuffer->xTaskWaitingToReceive,0,eNoAction,(uint32_t *)0x0, + pxHigherPriorityTaskWoken); + xStreamBuffer->xTaskWaitingToReceive = (TaskHandle_t)0x0; + } + } + } + return sVar4; +} + + + +size_t xStreamBufferReceive + (StreamBufferHandle_t xStreamBuffer,void *pvRxData,size_t xBufferLengthBytes, + TickType_t xTicksToWait) + +{ + bool bVar1; + byte bVar2; + size_t xBytesAvailable; + TaskHandle_t ptVar3; + uint uVar4; + uint uVar5; + uint xMaxCount; + size_t sVar6; + uint uStack36; + size_t xTempNextMessageLength; + + if (pvRxData == (void *)0x0) { + vAssertCalled(); + } + if (xStreamBuffer == (StreamBufferHandle_t)0x0) { + vAssertCalled(); + } + bVar2 = xStreamBuffer->ucFlags; + uVar5 = (uint)bVar2 & 1; + xMaxCount = uVar5 * 4; + if (xTicksToWait != 0) { + vTaskEnterCritical(); + uVar4 = xStreamBuffer->xLength; + xBytesAvailable = (xStreamBuffer->xHead + uVar4) - xStreamBuffer->xTail; + if (uVar4 <= xBytesAvailable) { + xBytesAvailable = xBytesAvailable - uVar4; + } + if (xMaxCount < xBytesAvailable) { + vTaskExitCritical(); + goto LAB_230331d6; + } + xTaskNotifyStateClear((TaskHandle_t)0x0); + if (xStreamBuffer->xTaskWaitingToReceive != (TaskHandle_t)0x0) { + vAssertCalled(); + } + ptVar3 = xTaskGetCurrentTaskHandle(); + xStreamBuffer->xTaskWaitingToReceive = ptVar3; + vTaskExitCritical(); + xTaskNotifyWait(0,0,(uint32_t *)0x0,xTicksToWait); + xStreamBuffer->xTaskWaitingToReceive = (TaskHandle_t)0x0; + } + uVar4 = xStreamBuffer->xLength; + xBytesAvailable = (xStreamBuffer->xHead + uVar4) - xStreamBuffer->xTail; + if (uVar4 <= xBytesAvailable) { + xBytesAvailable = xBytesAvailable - uVar4; + } + if (xBytesAvailable <= xMaxCount) { + return 0; + } +LAB_230331d6: + if ((bVar2 & 1) != 0) { + sVar6 = xStreamBuffer->xTail; + prvReadBytesFromBuffer + ((StreamBuffer_t *)xStreamBuffer,(uint8_t *)&uStack36,xMaxCount,xBytesAvailable); + xBytesAvailable = xBytesAvailable + uVar5 * -4; + bVar1 = xBufferLengthBytes < uStack36; + xBufferLengthBytes = uStack36; + if (bVar1) { + xStreamBuffer->xTail = sVar6; + xBufferLengthBytes = 0; + } + } + xBytesAvailable = + prvReadBytesFromBuffer + ((StreamBuffer_t *)xStreamBuffer,(uint8_t *)pvRxData,xBufferLengthBytes, + xBytesAvailable); + if (xBytesAvailable == 0) { + return 0; + } + vTaskSuspendAll(); + if (xStreamBuffer->xTaskWaitingToSend != (TaskHandle_t)0x0) { + xTaskGenericNotify(xStreamBuffer->xTaskWaitingToSend,0,eNoAction,(uint32_t *)0x0); + xStreamBuffer->xTaskWaitingToSend = (TaskHandle_t)0x0; + } + xTaskResumeAll(); + return xBytesAvailable; +} + + + +// WARNING: Variable defined which should be unmapped: xTempNextMessageLength + +size_t xStreamBufferReceiveFromISR + (StreamBufferHandle_t xStreamBuffer,void *pvRxData,size_t xBufferLengthBytes, + BaseType_t *pxHigherPriorityTaskWoken) + +{ + bool bVar1; + size_t xBytesAvailable; + uint uVar2; + uint uVar3; + uint xMaxCount; + size_t sVar4; + uint uStack36; + size_t xTempNextMessageLength; + + if (pvRxData == (void *)0x0) { + vAssertCalled(); + } + if (xStreamBuffer == (StreamBufferHandle_t)0x0) { + vAssertCalled(); + } + uVar2 = xStreamBuffer->xLength; + uVar3 = (uint)xStreamBuffer->ucFlags & 1; + xBytesAvailable = (xStreamBuffer->xHead + uVar2) - xStreamBuffer->xTail; + xMaxCount = uVar3 * 4; + if (uVar2 <= xBytesAvailable) { + xBytesAvailable = xBytesAvailable - uVar2; + } + if (xMaxCount < xBytesAvailable) { + if ((xStreamBuffer->ucFlags & 1) != 0) { + sVar4 = xStreamBuffer->xTail; + prvReadBytesFromBuffer + ((StreamBuffer_t *)xStreamBuffer,(uint8_t *)&uStack36,xMaxCount,xBytesAvailable); + xBytesAvailable = xBytesAvailable + uVar3 * -4; + bVar1 = xBufferLengthBytes < uStack36; + xBufferLengthBytes = uStack36; + if (bVar1) { + xStreamBuffer->xTail = sVar4; + xBufferLengthBytes = 0; + } + } + xBytesAvailable = + prvReadBytesFromBuffer + ((StreamBuffer_t *)xStreamBuffer,(uint8_t *)pvRxData,xBufferLengthBytes, + xBytesAvailable); + if (xBytesAvailable != 0) { + if (xStreamBuffer->xTaskWaitingToSend == (TaskHandle_t)0x0) { + return xBytesAvailable; + } + xTaskGenericNotifyFromISR + (xStreamBuffer->xTaskWaitingToSend,0,eNoAction,(uint32_t *)0x0, + pxHigherPriorityTaskWoken); + xStreamBuffer->xTaskWaitingToSend = (TaskHandle_t)0x0; + return xBytesAvailable; + } + } + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BaseType_t xStreamBufferIsEmpty(StreamBufferHandle_t xStreamBuffer) + +{ + if (xStreamBuffer != (StreamBufferHandle_t)0x0) { + return (uint)(xStreamBuffer->xHead == xStreamBuffer->xTail); + } + vAssertCalled(); + return (uint)(_DAT_00000004 == iRam00000000); +} + + + +void prvResetNextTaskUnblockTime(void) + +{ + xNextTaskUnblockTime = *(TickType_t *)((int)((pxDelayedTaskList->xListEnd).pxNext)->pvOwner + 4); + return; +} + + + +void prvInitialiseNewTask + (TaskFunction_t *pxTaskCode,char *pcName,uint32_t ulStackDepth,void *pvParameters, + UBaseType_t uxPriority,TaskHandle_t *pxCreatedTask,TCB_t *pxNewTCB) + +{ + char cVar1; + char *pcVar2; + char *pcVar3; + StackType_t *pSVar4; + + memset(pxNewTCB->pxStack,0xa5,ulStackDepth * 4); + pSVar4 = pxNewTCB->pxStack; + if (pcName == (char *)0x0) { + pxNewTCB->pcTaskName[0] = '\0'; + } + else { + pcVar2 = pcName + 0x10; + pcVar3 = pxNewTCB->pcTaskName; + do { + cVar1 = *pcName; + pcName = pcName + 1; + *pcVar3 = cVar1; + if (cVar1 == '\0') break; + pcVar3 = pcVar3 + 1; + } while (pcName != pcVar2); + pxNewTCB->pcTaskName[0xf] = '\0'; + } + if (0x1f < uxPriority) { + uxPriority = 0x1f; + } + pxNewTCB->uxPriority = uxPriority; + pxNewTCB->uxBasePriority = uxPriority; + pxNewTCB->uxMutexesHeld = 0; + vListInitialiseItem(&pxNewTCB->xStateListItem); + vListInitialiseItem(&pxNewTCB->xEventListItem); + pxNewTCB->ulNotifiedValue = 0; + *(TCB_t **)&(pxNewTCB->xStateListItem).pvOwner = pxNewTCB; + (pxNewTCB->xEventListItem).xItemValue = 0x20 - uxPriority; + *(TCB_t **)&(pxNewTCB->xEventListItem).pvOwner = pxNewTCB; + pxNewTCB->uxCriticalNesting = 0; + pxNewTCB->ucNotifyState = '\0'; + pSVar4 = (StackType_t *) + pxPortInitialiseStack + ((uint)(pSVar4 + (ulStackDepth - 1)) & 0xfffffff8,pxTaskCode,pvParameters); + pxNewTCB->pxTopOfStack = pSVar4; + if (pxCreatedTask != (TaskHandle_t *)0x0) { + *(TCB_t **)pxCreatedTask = pxNewTCB; + } + return; +} + + + +void prvDeleteTCB(TCB_t *pxTCB) + +{ + uint8_t uVar1; + + uVar1 = pxTCB->ucStaticallyAllocated; + if (uVar1 == '\0') { + vPortFree(pxTCB->pxStack); + vPortFree(pxTCB); + return; + } + if (uVar1 != '\x01') { + if (uVar1 == '\x02') { + return; + } + vAssertCalled(); + return; + } + vPortFree(pxTCB); + return; +} + + + +void prvAddCurrentTaskToDelayedList(TickType_t xTicksToWait,BaseType_t xCanBlockIndefinitely) + +{ + TickType_t TVar1; + uint uVar2; + UBaseType_t UVar3; + + TVar1 = xTickCount; + UVar3 = uxListRemove(&pxCurrentTCB->xStateListItem); + if (UVar3 == 0) { + uxTopReadyPriority = ~(1 << (pxCurrentTCB->uxPriority & 0x1f)) & uxTopReadyPriority; + } + if ((xTicksToWait == 0xffffffff) && (xCanBlockIndefinitely != 0)) { + vListInsertEnd(&xSuspendedTaskList,&pxCurrentTCB->xStateListItem); + return; + } + uVar2 = xTicksToWait + TVar1; + (pxCurrentTCB->xStateListItem).xItemValue = uVar2; + if (TVar1 <= uVar2) { + vListInsert(pxDelayedTaskList,&pxCurrentTCB->xStateListItem); + if (uVar2 < xNextTaskUnblockTime) { + xNextTaskUnblockTime = uVar2; + } + return; + } + vListInsert(pxOverflowDelayedTaskList,&pxCurrentTCB->xStateListItem); + return; +} + + + +void vTaskEnterCritical(void) + +{ + pxCurrentTCB->uxCriticalNesting = pxCurrentTCB->uxCriticalNesting + 1; + return; +} + + + +void vTaskExitCritical(void) + +{ + pxCurrentTCB->uxCriticalNesting = pxCurrentTCB->uxCriticalNesting - 1; + return; +} + + + +void prvAddNewTaskToReadyList(TCB_t *pxNewTCB) + +{ + uint uVar1; + List_t *pxList; + List_t *pLVar2; + + if (xSchedulerRunning != 0) { + vTaskEnterCritical(); + } + uxCurrentNumberOfTasks = uxCurrentNumberOfTasks + 1; + if (pxCurrentTCB == (TCB_t *)0x0) { + if (uxCurrentNumberOfTasks == 1) { + pxList = pxReadyTasksLists; + pxCurrentTCB = pxNewTCB; + do { + pLVar2 = pxList + 1; + vListInitialise(pxList); + pxList = pLVar2; + } while (pLVar2 != &xDelayedTaskList1); + vListInitialise(&xDelayedTaskList1); + vListInitialise(&xDelayedTaskList2); + vListInitialise(&xPendingReadyList); + vListInitialise(&xTasksWaitingTermination); + vListInitialise(&xSuspendedTaskList); + pxDelayedTaskList = &xDelayedTaskList1; + pxOverflowDelayedTaskList = &xDelayedTaskList2; + uVar1 = pxNewTCB->uxPriority; + } + else { + uVar1 = pxNewTCB->uxPriority; + pxCurrentTCB = pxNewTCB; + } + } + else { + uVar1 = pxNewTCB->uxPriority; + if ((xSchedulerRunning == 0) && (pxCurrentTCB->uxPriority <= uVar1)) { + pxCurrentTCB = pxNewTCB; + } + } + uxTaskNumber = uxTaskNumber + 1; + uxTopReadyPriority = 1 << (uVar1 & 0x1f) | uxTopReadyPriority; + pxNewTCB->uxTCBNumber = uxTaskNumber; + vListInsertEnd(pxReadyTasksLists + uVar1,&pxNewTCB->xStateListItem); + if ((xSchedulerRunning != 0) && (pxCurrentTCB->uxCriticalNesting != 0)) { + vTaskExitCritical(); + } + if ((xSchedulerRunning != 0) && (pxCurrentTCB->uxPriority < pxNewTCB->uxPriority)) { + ecall(); + } + return; +} + + +/* +Unable to decompile 'prvIdleTask' +Cause: Exception while decompiling 230336ae: Decompiler process died + +*/ + + +// WARNING: Removing unreachable block (ram,0x23033796) +// WARNING: Removing unreachable block (ram,0x230337dc) + +TaskHandle_t +xTaskCreateStatic(TaskFunction_t *pxTaskCode,char *pcName,uint32_t ulStackDepth,void *pvParameters, + UBaseType_t uxPriority,StackType_t *puxStackBuffer,StaticTask_t *pxTaskBuffer) + +{ + TaskHandle_t ptVar1; + size_t xSize; + TaskHandle_t xReturn; + + ptVar1 = (TaskHandle_t)xSize; + if (puxStackBuffer == (StackType_t *)0x0) { + vAssertCalled(); + ptVar1 = (TaskHandle_t)xSize; + } + if (pxTaskBuffer == (StaticTask_t *)0x0) { + vAssertCalled(); + return (TaskHandle_t)0x0; + } + xSize = 0; + if (puxStackBuffer != (StackType_t *)0x0) { + pxTaskBuffer->uxDummy20 = '\x02'; + *(StackType_t **)&pxTaskBuffer->pxDummy6 = puxStackBuffer; + xSize = (size_t)ptVar1; + prvInitialiseNewTask + (pxTaskCode,pcName,ulStackDepth,pvParameters,uxPriority,(TaskHandle_t *)&xSize, + (TCB_t *)pxTaskBuffer); + prvAddNewTaskToReadyList((TCB_t *)pxTaskBuffer); + } + return (TaskHandle_t)xSize; +} + + + +BaseType_t +xTaskCreate(TaskFunction_t *pxTaskCode,char *pcName,uint16_t usStackDepth,void *pvParameters, + UBaseType_t uxPriority,TaskHandle_t *pxCreatedTask) + +{ + StackType_t *pv; + TCB_t *pxNewTCB; + BaseType_t BVar1; + undefined2 in_register_00002032; + + pv = (StackType_t *)pvPortMalloc(CONCAT22(in_register_00002032,usStackDepth) << 2); + if (pv == (StackType_t *)0x0) { + BVar1 = -1; + } + else { + pxNewTCB = (TCB_t *)pvPortMalloc(0x60); + if (pxNewTCB == (TCB_t *)0x0) { + vPortFree(pv); + BVar1 = -1; + } + else { + pxNewTCB->pxStack = pv; + pxNewTCB->ucStaticallyAllocated = '\0'; + prvInitialiseNewTask + (pxTaskCode,pcName,CONCAT22(in_register_00002032,usStackDepth),pvParameters, + uxPriority,pxCreatedTask,pxNewTCB); + prvAddNewTaskToReadyList(pxNewTCB); + BVar1 = 1; + } + } + return BVar1; +} + + + +void vTaskDelete(TaskHandle_t xTaskToDelete) + +{ + UBaseType_t UVar1; + + if (xSchedulerRunning != 0) { + vTaskEnterCritical(); + } + if (xTaskToDelete == (TaskHandle_t)0x0) { + xTaskToDelete = (TaskHandle_t)pxCurrentTCB; + } + UVar1 = uxListRemove(&((TCB_t *)xTaskToDelete)->xStateListItem); + if ((UVar1 == 0) && (pxReadyTasksLists[((TCB_t *)xTaskToDelete)->uxPriority].uxNumberOfItems == 0) + ) { + uxTopReadyPriority = ~(1 << (((TCB_t *)xTaskToDelete)->uxPriority & 0x1f)) & uxTopReadyPriority; + } + if ((((TCB_t *)xTaskToDelete)->xEventListItem).pvContainer != (xLIST *)0x0) { + uxListRemove(&((TCB_t *)xTaskToDelete)->xEventListItem); + } + uxTaskNumber = uxTaskNumber + 1; + if (pxCurrentTCB == (TCB_t *)xTaskToDelete) { + vListInsertEnd(&xTasksWaitingTermination,&((TCB_t *)xTaskToDelete)->xStateListItem); + uxDeletedTasksWaitingCleanUp = uxDeletedTasksWaitingCleanUp + 1; + } + else { + uxCurrentNumberOfTasks = uxCurrentNumberOfTasks - 1; + prvDeleteTCB((TCB_t *)xTaskToDelete); + if (pxDelayedTaskList->uxNumberOfItems == 0) { + xNextTaskUnblockTime = 0xffffffff; + } + else { + prvResetNextTaskUnblockTime(); + } + } + if ((xSchedulerRunning != 0) && (pxCurrentTCB->uxCriticalNesting != 0)) { + vTaskExitCritical(); + } + if ((xSchedulerRunning != 0) && (pxCurrentTCB == (TCB_t *)xTaskToDelete)) { + if (uxSchedulerSuspended == 0) { + ecall(); + } + else { + vAssertCalled(); + ecall(); + } + return; + } + return; +} + + +/* +Unable to decompile 'eTaskGetState' +Cause: Exception while decompiling 2303399e: Decompiler process died + +*/ + +/* +Unable to decompile 'vTaskStartScheduler' +Cause: Exception while decompiling 23033a6c: Decompiler process died + +*/ + + +void vTaskSuspendAll(void) + +{ + uxSchedulerSuspended = uxSchedulerSuspended + 1; + return; +} + + + +TickType_t xTaskGetTickCount(void) + +{ + return xTickCount; +} + + + +BaseType_t xTaskGetTickCount2(TickType_t *ticks,BaseType_t *overflow) + +{ + BaseType_t BVar1; + + BVar1 = xNumOfOverflows; + *ticks = xTickCount; + *overflow = BVar1; + return 1; +} + + + +TickType_t xTaskGetTickCountFromISR(void) + +{ + return xTickCount; +} + + + +BaseType_t xTaskIncrementTick(void) + +{ + List_t *pLVar1; + List_t *pLVar2; + TickType_t TVar3; + void *pvVar4; + int iVar5; + int iVar6; + uint uVar7; + uint32_t uStack52; + uint32_t tmp; + + iVar6 = bl_sys_time_sync_state(&uStack52); + if (iVar6 != 0) { + if (uxSchedulerSuspended == 0) { + uVar7 = xTickCount + 1; + xTickCount = uVar7; + if (uVar7 == 0) { + if (pxDelayedTaskList->uxNumberOfItems != 0) { + vAssertCalled(); + } + pLVar2 = pxOverflowDelayedTaskList; + pLVar1 = pxDelayedTaskList; + pxDelayedTaskList = pxOverflowDelayedTaskList; + pxOverflowDelayedTaskList = pLVar1; + xNumOfOverflows = xNumOfOverflows + 1; + if (pLVar2->uxNumberOfItems == 0) { + xNextTaskUnblockTime = 0xffffffff; + } + else { + prvResetNextTaskUnblockTime(); + } + } + if (uVar7 < xNextTaskUnblockTime) { + iVar6 = 0; + TVar3 = xNextTaskUnblockTime; + } + else { + iVar6 = 0; + while (iVar5 = iVar6, pxDelayedTaskList->uxNumberOfItems != 0) { + while( true ) { + pvVar4 = ((pxDelayedTaskList->xListEnd).pxNext)->pvOwner; + TVar3 = *(uint *)((int)pvVar4 + 4); + if (uVar7 < *(uint *)((int)pvVar4 + 4)) goto LAB_23033c92; + uxListRemove((ListItem_t *)((int)pvVar4 + 4)); + if (*(int *)((int)pvVar4 + 0x28) != 0) { + uxListRemove((ListItem_t *)((int)pvVar4 + 0x18)); + } + uxTopReadyPriority = 1 << (*(uint *)((int)pvVar4 + 0x2c) & 0x1f) | uxTopReadyPriority; + vListInsertEnd(pxReadyTasksLists + *(uint *)((int)pvVar4 + 0x2c), + (ListItem_t *)((int)pvVar4 + 4)); + if (*(uint *)((int)pvVar4 + 0x2c) < pxCurrentTCB->uxPriority) break; + iVar6 = 1; + iVar5 = 1; + if (pxDelayedTaskList->uxNumberOfItems == 0) goto LAB_23033c78; + } + } +LAB_23033c78: + xNextTaskUnblockTime = 0xffffffff; + iVar6 = iVar5; + TVar3 = xNextTaskUnblockTime; + } +LAB_23033c92: + xNextTaskUnblockTime = TVar3; + if (1 < pxReadyTasksLists[pxCurrentTCB->uxPriority].uxNumberOfItems) { + iVar6 = 1; + } + } + else { + iVar6 = 0; + uxPendedTicks = uxPendedTicks + 1; + } + if (xYieldPending != 0) { + iVar6 = 1; + } + } + return iVar6; +} + + +/* +Unable to decompile 'xTaskResumeAll' +Cause: Exception while decompiling 23033cbc: Decompiler process died + +*/ + + +void vTaskDelay(TickType_t xTicksToDelay) + +{ + BaseType_t BVar1; + + if (xTicksToDelay == 0) { + ecall(); + return; + } + if (uxSchedulerSuspended != 0) { + vAssertCalled(); + } + uxSchedulerSuspended = uxSchedulerSuspended + 1; + prvAddCurrentTaskToDelayedList(xTicksToDelay,0); + BVar1 = xTaskResumeAll(); + if (BVar1 == 0) { + ecall(); + } + return; +} + + + +void vTaskSwitchContext(void) + +{ + int iVar1; + StackType_t *pSVar2; + xLIST_ITEM *pxVar3; + + if (uxSchedulerSuspended == 0) { + xYieldPending = 0; + pSVar2 = pxCurrentTCB->pxStack; + if ((((*pSVar2 != 0xa5a5a5a5) || (pSVar2[1] != 0xa5a5a5a5)) || (pSVar2[2] != 0xa5a5a5a5)) || + (pSVar2[3] != 0xa5a5a5a5)) { + vApplicationStackOverflowHook((TaskHandle_t)pxCurrentTCB,pxCurrentTCB->pcTaskName); + } + iVar1 = __clzsi2(uxTopReadyPriority); + iVar1 = 0x1f - iVar1; + if (pxReadyTasksLists[iVar1].uxNumberOfItems == 0) { + vAssertCalled(); + } + pxVar3 = (pxReadyTasksLists[iVar1].pxIndex)->pxNext; + *(xLIST_ITEM **)&pxReadyTasksLists[iVar1].pxIndex = pxVar3; + if (pxVar3 == (xLIST_ITEM *)(iVar1 * 0x14 + 0x42012c10)) { + pxVar3 = pxVar3->pxNext; + *(xLIST_ITEM **)&pxReadyTasksLists[iVar1].pxIndex = pxVar3; + } + pxCurrentTCB = (TCB_t *)pxVar3->pvOwner; + return; + } + xYieldPending = 1; + return; +} + + + +void vTaskPlaceOnEventList(List_t *pxEventList,TickType_t xTicksToWait) + +{ + if (pxEventList == (List_t *)0x0) { + vAssertCalled(); + } + vListInsert(pxEventList,&pxCurrentTCB->xEventListItem); + prvAddCurrentTaskToDelayedList(xTicksToWait,1); + return; +} + + + +void vTaskPlaceOnUnorderedEventList + (List_t *pxEventList,TickType_t xItemValue,TickType_t xTicksToWait) + +{ + ListItem_t *pxNewListItem; + + if (pxEventList == (List_t *)0x0) { + vAssertCalled(); + } + if (uxSchedulerSuspended == 0) { + vAssertCalled(); + } + pxNewListItem = &pxCurrentTCB->xEventListItem; + (pxCurrentTCB->xEventListItem).xItemValue = xItemValue | 0x80000000; + vListInsertEnd(pxEventList,pxNewListItem); + prvAddCurrentTaskToDelayedList(xTicksToWait,1); + return; +} + + + +void vTaskPlaceOnEventListRestricted + (List_t *pxEventList,TickType_t xTicksToWait,BaseType_t xWaitIndefinitely) + +{ + if (pxEventList == (List_t *)0x0) { + vAssertCalled(); + } + vListInsertEnd(pxEventList,&pxCurrentTCB->xEventListItem); + if (xWaitIndefinitely != 0) { + xTicksToWait = 0xffffffff; + } + prvAddCurrentTaskToDelayedList(xTicksToWait,xWaitIndefinitely); + return; +} + + + +BaseType_t xTaskRemoveFromEventList(List_t *pxEventList) + +{ + bool bVar1; + void *pvVar2; + + pvVar2 = ((pxEventList->xListEnd).pxNext)->pvOwner; + if (pvVar2 == (void *)0x0) { + vAssertCalled(); + } + uxListRemove((ListItem_t *)((int)pvVar2 + 0x18)); + if (uxSchedulerSuspended == 0) { + uxListRemove((ListItem_t *)((int)pvVar2 + 4)); + uxTopReadyPriority = 1 << (*(uint *)((int)pvVar2 + 0x2c) & 0x1f) | uxTopReadyPriority; + vListInsertEnd(pxReadyTasksLists + *(uint *)((int)pvVar2 + 0x2c),(ListItem_t *)((int)pvVar2 + 4) + ); + } + else { + vListInsertEnd(&xPendingReadyList,(ListItem_t *)((int)pvVar2 + 0x18)); + } + bVar1 = pxCurrentTCB->uxPriority < *(uint *)((int)pvVar2 + 0x2c); + if (bVar1) { + xYieldPending = 1; + } + return (uint)bVar1; +} + + + +void vTaskRemoveFromUnorderedEventList(ListItem_t *pxEventListItem,TickType_t xItemValue) + +{ + void *pvVar1; + + if (uxSchedulerSuspended == 0) { + vAssertCalled(); + pvVar1 = pxEventListItem->pvOwner; + pxEventListItem->xItemValue = xItemValue | 0x80000000; + } + else { + pvVar1 = pxEventListItem->pvOwner; + pxEventListItem->xItemValue = xItemValue | 0x80000000; + } + if (pvVar1 == (void *)0x0) { + vAssertCalled(); + } + uxListRemove(pxEventListItem); + uxListRemove((ListItem_t *)((int)pvVar1 + 4)); + uxTopReadyPriority = 1 << (*(uint *)((int)pvVar1 + 0x2c) & 0x1f) | uxTopReadyPriority; + vListInsertEnd(pxReadyTasksLists + *(uint *)((int)pvVar1 + 0x2c),(ListItem_t *)((int)pvVar1 + 4)); + if (pxCurrentTCB->uxPriority < *(uint *)((int)pvVar1 + 0x2c)) { + xYieldPending = 1; + } + return; +} + + +/* +Unable to decompile 'vTaskSetTimeOutState' +Cause: Exception while decompiling 23034116: Decompiler process died + +*/ + + +void vTaskInternalSetTimeOutState(TimeOut_t *pxTimeOut) + +{ + TickType_t TVar1; + + TVar1 = xTickCount; + pxTimeOut->xOverflowCount = xNumOfOverflows; + pxTimeOut->xTimeOnEntering = TVar1; + return; +} + + +/* +Unable to decompile 'xTaskCheckForTimeOut' +Cause: Exception while decompiling 2303418c: Decompiler process died + +*/ + + +void vTaskMissedYield(void) + +{ + xYieldPending = 1; + return; +} + + + +void vTaskGetInfo(TaskHandle_t xTask,TaskStatus_t *pxTaskStatus,BaseType_t xGetFreeStackSpace, + eTaskState eState) + +{ + eTaskState eVar1; + undefined3 in_register_00002035; + UBaseType_t UVar2; + uint uVar3; + + if (xTask == (TaskHandle_t)0x0) { + xTask = (TaskHandle_t)pxCurrentTCB; + } + pxTaskStatus->pcTaskName = xTask->pcTaskName; + pxTaskStatus->xHandle = xTask; + pxTaskStatus->uxCurrentPriority = xTask->uxPriority; + pxTaskStatus->pxStackBase = xTask->pxStack; + pxTaskStatus->xTaskNumber = xTask->uxTCBNumber; + UVar2 = xTask->uxBasePriority; + pxTaskStatus->ulRunTimeCounter = 0; + pxTaskStatus->uxBasePriority = UVar2; + if (CONCAT31(in_register_00002035,eState) == 5) { + eVar1 = eTaskGetState(xTask); + pxTaskStatus->eCurrentState = eVar1; + } + else { + if (pxCurrentTCB == (TCB_t *)xTask) { + pxTaskStatus->eCurrentState = eRunning; + } + else { + pxTaskStatus->eCurrentState = eState; + if (CONCAT31(in_register_00002035,eState) == 3) { + uxSchedulerSuspended = uxSchedulerSuspended + 1; + if ((xTask->xEventListItem).pvContainer != (xLIST *)0x0) { + pxTaskStatus->eCurrentState = eBlocked; + } + xTaskResumeAll(); + } + } + } + if (xGetFreeStackSpace != 0) { + if (*(char *)xTask->pxStack == -0x5b) { + uVar3 = 0; + do { + uVar3 = uVar3 + 1; + } while (*(char *)((int)xTask->pxStack + uVar3) == -0x5b); + pxTaskStatus->usStackHighWaterMark = (uint16_t)(uVar3 >> 2); + } + else { + pxTaskStatus->usStackHighWaterMark = 0; + } + return; + } + pxTaskStatus->usStackHighWaterMark = 0; + return; +} + + + +UBaseType_t +prvListTasksWithinSingleList(TaskStatus_t *pxTaskStatusArray,List_t *pxList,eTaskState eState) + +{ + TaskHandle_t xTask; + xLIST_ITEM *pxVar1; + int iVar2; + TaskHandle_t ptVar3; + + pxVar1 = pxList->pxIndex->pxNext; + *(xLIST_ITEM **)&pxList->pxIndex = pxVar1; + if (pxVar1 == (xLIST_ITEM *)&pxList->xListEnd) { + pxVar1 = (pxList->xListEnd).pxNext; + *(xLIST_ITEM **)&pxList->pxIndex = pxVar1; + } + ptVar3 = (TaskHandle_t)pxVar1->pvOwner; + iVar2 = 0; + while( true ) { + pxVar1 = pxVar1->pxNext; + *(xLIST_ITEM **)&pxList->pxIndex = pxVar1; + if ((xLIST_ITEM *)&pxList->xListEnd == pxVar1) { + pxVar1 = (pxList->xListEnd).pxNext; + *(xLIST_ITEM **)&pxList->pxIndex = pxVar1; + xTask = (TaskHandle_t)pxVar1->pvOwner; + vTaskGetInfo(xTask,pxTaskStatusArray,1,eState); + } + else { + xTask = (TaskHandle_t)pxVar1->pvOwner; + vTaskGetInfo(xTask,pxTaskStatusArray,1,eState); + } + if (ptVar3 == xTask) break; + iVar2 = iVar2 + 1; + pxTaskStatusArray = pxTaskStatusArray + 1; + pxVar1 = (xLIST_ITEM *)pxList->pxIndex; + } + return iVar2 + 1; +} + + + +UBaseType_t +uxTaskGetSystemState + (TaskStatus_t *pxTaskStatusArray,UBaseType_t uxArraySize,uint32_t *pulTotalRunTime) + +{ + int iVar1; + UBaseType_t UVar2; + int iVar3; + TaskStatus_t *pxTaskStatusArray_00; + UBaseType_t UVar4; + List_t *pxList; + + uxSchedulerSuspended = uxSchedulerSuspended + 1; + UVar4 = 0; + if (uxCurrentNumberOfTasks <= uxArraySize) { + pxList = pxReadyTasksLists + 0x1f; + iVar1 = 0x20; + UVar4 = 0; + iVar3 = 0; + do { + iVar1 = iVar1 + -1; + pxTaskStatusArray_00 = (TaskStatus_t *)(&pxTaskStatusArray->xHandle + iVar3 + UVar4); + if (pxReadyTasksLists[iVar1].uxNumberOfItems != 0) { + UVar2 = prvListTasksWithinSingleList(pxTaskStatusArray_00,pxList,eReady); + UVar4 = UVar4 + UVar2; + iVar3 = UVar4 * 8; + pxTaskStatusArray_00 = pxTaskStatusArray + UVar4; + } + pxList = pxList + -1; + } while (iVar1 != 0); + if (pxDelayedTaskList->uxNumberOfItems != 0) { + UVar2 = prvListTasksWithinSingleList(pxTaskStatusArray_00,pxDelayedTaskList,eBlocked); + UVar4 = UVar4 + UVar2; + pxTaskStatusArray_00 = pxTaskStatusArray + UVar4; + } + if (pxOverflowDelayedTaskList->uxNumberOfItems != 0) { + UVar2 = prvListTasksWithinSingleList(pxTaskStatusArray_00,pxOverflowDelayedTaskList,eBlocked); + UVar4 = UVar4 + UVar2; + pxTaskStatusArray_00 = pxTaskStatusArray + UVar4; + } + if (xTasksWaitingTermination.uxNumberOfItems != 0) { + UVar2 = prvListTasksWithinSingleList(pxTaskStatusArray_00,&xTasksWaitingTermination,eDeleted); + UVar4 = UVar4 + UVar2; + pxTaskStatusArray_00 = pxTaskStatusArray + UVar4; + } + if (xSuspendedTaskList.uxNumberOfItems != 0) { + UVar2 = prvListTasksWithinSingleList(pxTaskStatusArray_00,&xSuspendedTaskList,eSuspended); + UVar4 = UVar4 + UVar2; + } + if (pulTotalRunTime != (uint32_t *)0x0) { + *pulTotalRunTime = 0; + } + } + xTaskResumeAll(); + return UVar4; +} + + + +TaskHandle_t xTaskGetCurrentTaskHandle(void) + +{ + return (TaskHandle_t)pxCurrentTCB; +} + + + +BaseType_t xTaskGetSchedulerState(void) + +{ + BaseType_t BVar1; + + BVar1 = 1; + if (xSchedulerRunning != 0) { + BVar1 = (uint)(uxSchedulerSuspended == 0) << 1; + } + return BVar1; +} + + + +BaseType_t xTaskPriorityInherit(TaskHandle_t pxMutexHolder) + +{ + UBaseType_t UVar1; + uint uVar2; + + if (pxMutexHolder == (TaskHandle_t)0x0) { + return 0; + } + uVar2 = pxMutexHolder->uxPriority; + if (uVar2 < pxCurrentTCB->uxPriority) { + if (-1 < (int)(pxMutexHolder->xEventListItem).xItemValue) { + (pxMutexHolder->xEventListItem).xItemValue = 0x20 - pxCurrentTCB->uxPriority; + } + if ((List_t *)(pxMutexHolder->xStateListItem).pvContainer != pxReadyTasksLists + uVar2) { + pxMutexHolder->uxPriority = pxCurrentTCB->uxPriority; + return 1; + } + UVar1 = uxListRemove(&pxMutexHolder->xStateListItem); + if ((UVar1 == 0) && (pxReadyTasksLists[pxMutexHolder->uxPriority].uxNumberOfItems == 0)) { + uxTopReadyPriority = ~(1 << (pxMutexHolder->uxPriority & 0x1f)) & uxTopReadyPriority; + } + uVar2 = pxCurrentTCB->uxPriority; + uxTopReadyPriority = 1 << (uVar2 & 0x1f) | uxTopReadyPriority; + pxMutexHolder->uxPriority = uVar2; + vListInsertEnd(pxReadyTasksLists + uVar2,&pxMutexHolder->xStateListItem); + uVar2 = 1; + } + else { + uVar2 = (uint)(pxMutexHolder->uxBasePriority < pxCurrentTCB->uxPriority); + } + return uVar2; +} + + + +BaseType_t xTaskPriorityDisinherit(TaskHandle_t pxMutexHolder) + +{ + uint uVar1; + UBaseType_t UVar2; + + if (pxMutexHolder == (TaskHandle_t)0x0) { + return 0; + } + if (pxCurrentTCB != (TCB_t *)pxMutexHolder) { + vAssertCalled(); + } + if (pxMutexHolder->uxMutexesHeld == 0) { + vAssertCalled(); + UVar2 = pxMutexHolder->uxMutexesHeld - 1; + pxMutexHolder->uxMutexesHeld = UVar2; + if (pxMutexHolder->uxPriority == pxMutexHolder->uxBasePriority) { + return 0; + } + } + else { + UVar2 = pxMutexHolder->uxMutexesHeld - 1; + pxMutexHolder->uxMutexesHeld = UVar2; + if (pxMutexHolder->uxPriority == pxMutexHolder->uxBasePriority) { + return 0; + } + } + if (UVar2 != 0) { + return 0; + } + UVar2 = uxListRemove(&pxMutexHolder->xStateListItem); + if ((UVar2 == 0) && (pxReadyTasksLists[pxMutexHolder->uxPriority].uxNumberOfItems == 0)) { + uxTopReadyPriority = ~(1 << (pxMutexHolder->uxPriority & 0x1f)) & uxTopReadyPriority; + } + uVar1 = pxMutexHolder->uxBasePriority; + uxTopReadyPriority = 1 << (uVar1 & 0x1f) | uxTopReadyPriority; + pxMutexHolder->uxPriority = uVar1; + (pxMutexHolder->xEventListItem).xItemValue = 0x20 - uVar1; + vListInsertEnd(pxReadyTasksLists + uVar1,&pxMutexHolder->xStateListItem); + return 1; +} + + + +void vTaskPriorityDisinheritAfterTimeout + (TaskHandle_t pxMutexHolder,UBaseType_t uxHighestPriorityWaitingTask) + +{ + UBaseType_t UVar1; + TickType_t TVar2; + uint uVar3; + int iVar4; + uint uVar5; + + if (pxMutexHolder == (TaskHandle_t)0x0) { + return; + } + if (pxMutexHolder->uxMutexesHeld == 0) { + vAssertCalled(); + uVar5 = pxMutexHolder->uxBasePriority; + } + else { + uVar5 = pxMutexHolder->uxBasePriority; + } + if (uVar5 < uxHighestPriorityWaitingTask) { + uVar3 = pxMutexHolder->uxPriority; + if (uVar3 == uxHighestPriorityWaitingTask) { + return; + } + } + else { + uVar3 = pxMutexHolder->uxPriority; + uxHighestPriorityWaitingTask = uVar5; + if (uVar3 == uVar5) { + return; + } + } + if (pxMutexHolder->uxMutexesHeld == 1) { + if (pxCurrentTCB == (TCB_t *)pxMutexHolder) { + vAssertCalled(); + uVar3 = pxMutexHolder->uxPriority; + } + TVar2 = (pxMutexHolder->xEventListItem).xItemValue; + pxMutexHolder->uxPriority = uxHighestPriorityWaitingTask; + if (-1 < (int)TVar2) { + (pxMutexHolder->xEventListItem).xItemValue = 0x20 - uxHighestPriorityWaitingTask; + } + if ((List_t *)(pxMutexHolder->xStateListItem).pvContainer == pxReadyTasksLists + uVar3) { + UVar1 = uxListRemove(&pxMutexHolder->xStateListItem); + if (UVar1 == 0) { + uVar5 = pxMutexHolder->uxPriority; + iVar4 = uVar5 * 4; + uVar3 = 1 << (uVar5 & 0x1f); + if (pxReadyTasksLists[uVar5].uxNumberOfItems == 0) { + uxTopReadyPriority = ~uVar3 & uxTopReadyPriority; + } + } + else { + uVar5 = pxMutexHolder->uxPriority; + uVar3 = 1 << (uVar5 & 0x1f); + iVar4 = uVar5 << 2; + } + uxTopReadyPriority = uVar3 | uxTopReadyPriority; + vListInsertEnd((List_t *)(&pxReadyTasksLists[0].uxNumberOfItems + iVar4 + uVar5), + &pxMutexHolder->xStateListItem); + return; + } + } + return; +} + + + +void vTaskEnterCritical(void) + +{ + if (xSchedulerRunning == 0) { + return; + } + vTaskEnterCritical(); + return; +} + + + +void vTaskExitCritical(void) + +{ + if ((xSchedulerRunning != 0) && (pxCurrentTCB->uxCriticalNesting != 0)) { + vTaskExitCritical(); + return; + } + return; +} + + + +void vTaskList(char *pcWriteBuffer) + +{ + TaskStatus_t *pTVar1; + TaskStatus_t *pxTaskStatusArray; + UBaseType_t uxArraySize; + size_t sVar2; + char *pcVar3; + uint uVar4; + + uxArraySize = uxCurrentNumberOfTasks; + *pcWriteBuffer = '\0'; + pxTaskStatusArray = (TaskStatus_t *)pvPortMalloc(uxArraySize * 0x24); + if (pxTaskStatusArray != (TaskStatus_t *)0x0) { + uxArraySize = uxTaskGetSystemState(pxTaskStatusArray,uxArraySize,(uint32_t *)0x0); + if (uxArraySize != 0) { + pTVar1 = pxTaskStatusArray; + do { + uVar4 = 0; + if (pTVar1->eCurrentState < eInvalid) { + uVar4 = (uint)(byte)"XRBSD"[pTVar1->eCurrentState]; + } + strcpy(pcWriteBuffer,pTVar1->pcTaskName); + sVar2 = strlen(pcWriteBuffer); + if (sVar2 < 0xf) { + pcVar3 = pcWriteBuffer + sVar2; + do { + *pcVar3 = ' '; + pcVar3 = pcVar3 + 1; + } while (pcWriteBuffer + 0xf != pcVar3); + sVar2 = 0xf; + } + pcWriteBuffer = pcWriteBuffer + sVar2; + *pcWriteBuffer = '\0'; + sprintf(pcWriteBuffer,"\t%c\t%u\t%u\t%u\t%p\r\n",uVar4,pTVar1->uxCurrentPriority, + (uint)pTVar1->usStackHighWaterMark,pTVar1->xTaskNumber,pTVar1->pxStackBase); + sVar2 = strlen(pcWriteBuffer); + pTVar1 = pTVar1 + 1; + pcWriteBuffer = pcWriteBuffer + sVar2; + } while (pTVar1 != pxTaskStatusArray + uxArraySize); + } + vPortFree(pxTaskStatusArray); + return; + } + return; +} + + + +TickType_t uxTaskResetEventItemValue(void) + +{ + TickType_t TVar1; + + TVar1 = (pxCurrentTCB->xEventListItem).xItemValue; + (pxCurrentTCB->xEventListItem).xItemValue = 0x20 - pxCurrentTCB->uxPriority; + return TVar1; +} + + + +TaskHandle_t pvTaskIncrementMutexHeldCount(void) + +{ + if (pxCurrentTCB != (TCB_t *)0x0) { + pxCurrentTCB->uxMutexesHeld = pxCurrentTCB->uxMutexesHeld + 1; + } + return (TaskHandle_t)pxCurrentTCB; +} + + +/* +Unable to decompile 'ulTaskNotifyTake' +Cause: Exception while decompiling 23034906: Decompiler process died + +*/ + +/* +Unable to decompile 'xTaskNotifyWait' +Cause: Exception while decompiling 230349ac: Decompiler process died + +*/ + +/* +Unable to decompile 'xTaskGenericNotify' +Cause: +Low-level Error: Assignment to constant at r0x23034aa6 +*/ + + +BaseType_t +xTaskGenericNotifyFromISR + (TaskHandle_t xTaskToNotify,uint32_t ulValue,eNotifyAction eAction, + uint32_t *pulPreviousNotificationValue,BaseType_t *pxHigherPriorityTaskWoken) + +{ + uint8_t uVar1; + undefined3 in_register_00002031; + + if (xTaskToNotify == (TaskHandle_t)0x0) { + vAssertCalled(); + } + if (pulPreviousNotificationValue != (uint32_t *)0x0) { + *pulPreviousNotificationValue = xTaskToNotify->ulNotifiedValue; + } + uVar1 = xTaskToNotify->ucNotifyState; + xTaskToNotify->ucNotifyState = '\x02'; + switch(CONCAT31(in_register_00002031,eAction)) { + case 0: + break; + case 1: + xTaskToNotify->ulNotifiedValue = ulValue | xTaskToNotify->ulNotifiedValue; + break; + case 2: + xTaskToNotify->ulNotifiedValue = xTaskToNotify->ulNotifiedValue + 1; + break; + case 4: + if (uVar1 == '\x02') { + return 0; + } + case 3: + xTaskToNotify->ulNotifiedValue = ulValue; + break; + default: + if (xTaskToNotify->ulNotifiedValue != 0xffffffff) { + vAssertCalled(); + } + } + if (uVar1 == '\x01') { + if ((xTaskToNotify->xEventListItem).pvContainer != (xLIST *)0x0) { + vAssertCalled(); + } + if (uxSchedulerSuspended == 0) { + uxListRemove(&xTaskToNotify->xStateListItem); + uxTopReadyPriority = 1 << (xTaskToNotify->uxPriority & 0x1f) | uxTopReadyPriority; + vListInsertEnd(pxReadyTasksLists + xTaskToNotify->uxPriority,&xTaskToNotify->xStateListItem); + } + else { + vListInsertEnd(&xPendingReadyList,&xTaskToNotify->xEventListItem); + } + if (pxCurrentTCB->uxPriority < xTaskToNotify->uxPriority) { + if (pxHigherPriorityTaskWoken != (BaseType_t *)0x0) { + *pxHigherPriorityTaskWoken = 1; + } + xYieldPending = 1; + } + } + return 1; +} + + + +void vTaskNotifyGiveFromISR(TaskHandle_t xTaskToNotify,BaseType_t *pxHigherPriorityTaskWoken) + +{ + uint8_t uVar1; + + if (xTaskToNotify == (TaskHandle_t)0x0) { + vAssertCalled(); + } + uVar1 = xTaskToNotify->ucNotifyState; + xTaskToNotify->ucNotifyState = '\x02'; + xTaskToNotify->ulNotifiedValue = xTaskToNotify->ulNotifiedValue + 1; + if (uVar1 == '\x01') { + if ((xTaskToNotify->xEventListItem).pvContainer != (xLIST *)0x0) { + vAssertCalled(); + } + if (uxSchedulerSuspended == 0) { + uxListRemove(&xTaskToNotify->xStateListItem); + uxTopReadyPriority = 1 << (xTaskToNotify->uxPriority & 0x1f) | uxTopReadyPriority; + vListInsertEnd(pxReadyTasksLists + xTaskToNotify->uxPriority,&xTaskToNotify->xStateListItem); + } + else { + vListInsertEnd(&xPendingReadyList,&xTaskToNotify->xEventListItem); + } + if (pxCurrentTCB->uxPriority < xTaskToNotify->uxPriority) { + if (pxHigherPriorityTaskWoken != (BaseType_t *)0x0) { + *pxHigherPriorityTaskWoken = 1; + } + xYieldPending = 1; + return; + } + } + return; +} + + + +BaseType_t xTaskNotifyStateClear(TaskHandle_t xTask) + +{ + bool bVar1; + + if (xTask == (TaskHandle_t)0x0) { + xTask = (TaskHandle_t)pxCurrentTCB; + } + if (xSchedulerRunning != 0) { + vTaskEnterCritical(); + } + bVar1 = ((TCB_t *)xTask)->ucNotifyState == '\x02'; + if (bVar1) { + ((TCB_t *)xTask)->ucNotifyState = '\0'; + } + if ((xSchedulerRunning != 0) && (pxCurrentTCB->uxCriticalNesting != 0)) { + vTaskExitCritical(); + } + return (uint)bVar1; +} + + + +void prvCheckForValidListAndQueue(void) + +{ + uint8_t ucStaticTimerQueueStorage [64]; + StaticQueue_t xStaticTimerQueue; + + vTaskEnterCritical(); + if (xTimerQueue == (QueueHandle_t)0x0) { + vListInitialise(&xActiveTimerList1); + vListInitialise(&xActiveTimerList2); + pxCurrentTimerList = &xActiveTimerList1; + pxOverflowTimerList = &xActiveTimerList2; + xTimerQueue = xQueueGenericCreateStatic + (4,0x10,ucStaticTimerQueueStorage,&xStaticTimerQueue,'\0'); + if (xTimerQueue != (QueueHandle_t)0x0) { + vQueueAddToRegistry(xTimerQueue,"TmrQ"); + } + } + vTaskExitCritical(); + return; +} + + + +BaseType_t +prvInsertTimerInActiveList + (Timer_t *pxTimer,TickType_t xNextExpiryTime,TickType_t xTimeNow,TickType_t xCommandTime) + +{ + (pxTimer->xTimerListItem).xItemValue = xNextExpiryTime; + *(Timer_t **)&(pxTimer->xTimerListItem).pvOwner = pxTimer; + if (xTimeNow < xNextExpiryTime) { + if ((xCommandTime <= xTimeNow) || (xNextExpiryTime < xCommandTime)) { + vListInsert(pxCurrentTimerList,&pxTimer->xTimerListItem); + return 0; + } + } + else { + if (xTimeNow - xCommandTime < pxTimer->xTimerPeriodInTicks) { + vListInsert(pxOverflowTimerList,&pxTimer->xTimerListItem); + return 0; + } + } + return 1; +} + + + +BaseType_t xTimerCreateTimerTask(void) + +{ + StaticTask_t *pSStack28; + StaticTask_t *pxTimerTaskTCBBuffer; + StackType_t *pxTimerTaskStackBuffer; + uint32_t ulTimerTaskStackSize; + + prvCheckForValidListAndQueue(); + if (xTimerQueue != (QueueHandle_t)0x0) { + pSStack28 = (StaticTask_t *)0x0; + pxTimerTaskTCBBuffer = (StaticTask_t *)0x0; + vApplicationGetTimerTaskMemory + (&pSStack28,(StackType_t **)&pxTimerTaskTCBBuffer,(uint32_t *)&pxTimerTaskStackBuffer) + ; + xTimerTaskHandle = + xTaskCreateStatic(prvTimerTask,"Tmr Svc",(uint32_t)pxTimerTaskStackBuffer,(void *)0x0,0x1f, + (StackType_t *)pxTimerTaskTCBBuffer,pSStack28); + if (xTimerTaskHandle != (TaskHandle_t)0x0) { + return 1; + } + } + vAssertCalled(); + return 0; +} + + + +TimerHandle_t +xTimerCreate(char *pcTimerName,TickType_t xTimerPeriodInTicks,UBaseType_t uxAutoReload, + void *pvTimerID,TimerCallbackFunction_t *pxCallbackFunction) + +{ + TimerHandle_t ptVar1; + + ptVar1 = (TimerHandle_t)pvPortMalloc(0x2c); + if (ptVar1 != (TimerHandle_t)0x0) { + ptVar1->ucStatus = '\0'; + if (xTimerPeriodInTicks == 0) { + vAssertCalled(); + } + prvCheckForValidListAndQueue(); + ptVar1->pcTimerName = pcTimerName; + ptVar1->xTimerPeriodInTicks = xTimerPeriodInTicks; + ptVar1->pvTimerID = pvTimerID; + ptVar1->pxCallbackFunction = pxCallbackFunction; + vListInitialiseItem(&ptVar1->xTimerListItem); + if (uxAutoReload != 0) { + ptVar1->ucStatus = ptVar1->ucStatus | 4; + } + } + return ptVar1; +} + + + +// WARNING: Removing unreachable block (ram,0x23034fc4) + +TimerHandle_t +xTimerCreateStatic(char *pcTimerName,TickType_t xTimerPeriodInTicks,UBaseType_t uxAutoReload, + void *pvTimerID,TimerCallbackFunction_t *pxCallbackFunction, + StaticTimer_t *pxTimerBuffer) + +{ + size_t xSize; + + if (pxTimerBuffer == (StaticTimer_t *)0x0) { + vAssertCalled(0x2c); + } + else { + pxTimerBuffer->ucDummy8 = '\x02'; + if (xTimerPeriodInTicks == 0) { + vAssertCalled(); + } + prvCheckForValidListAndQueue(); + *(char **)&pxTimerBuffer->pvDummy1 = pcTimerName; + pxTimerBuffer->xDummy3 = xTimerPeriodInTicks; + pxTimerBuffer->pvDummy5 = pvTimerID; + *(TimerCallbackFunction_t **)&pxTimerBuffer->pvDummy6 = pxCallbackFunction; + vListInitialiseItem((ListItem_t *)&pxTimerBuffer->xDummy2); + if (uxAutoReload != 0) { + pxTimerBuffer->ucDummy8 = pxTimerBuffer->ucDummy8 | 4; + } + } + return (TimerHandle_t)pxTimerBuffer; +} + + + +// WARNING: Could not reconcile some variable overlaps + +BaseType_t +xTimerGenericCommand + (TimerHandle_t xTimer,BaseType_t xCommandID,TickType_t xOptionalValue, + BaseType_t *pxHigherPriorityTaskWoken,TickType_t xTicksToWait) + +{ + BaseType_t BVar1; + BaseType_t BStack48; + DaemonTaskMessage_t xMessage; + + if (xTimer == (TimerHandle_t)0x0) { + vAssertCalled(); + } + BVar1 = 0; + if (xTimerQueue != (QueueHandle_t)0x0) { + BStack48 = xCommandID; + xMessage.xMessageID = xOptionalValue; + xMessage.u._0_4_ = xTimer; + if (5 < xCommandID) { + BVar1 = xQueueGenericSendFromISR(xTimerQueue,&BStack48,pxHigherPriorityTaskWoken,0); + return BVar1; + } + BVar1 = xTaskGetSchedulerState(); + if (BVar1 == 2) { + BVar1 = xQueueGenericSend(xTimerQueue,&BStack48,xTicksToWait,0); + return BVar1; + } + BVar1 = xQueueGenericSend(xTimerQueue,&BStack48,0,0); + } + return BVar1; +} + + + +void prvSwitchTimerLists(void) + +{ + List_t *pxList; + TimerHandle_t xTimer; + BaseType_t BVar1; + xLIST_ITEM *pxVar2; + uint uVar3; + uint xOptionalValue; + + while (pxList = pxCurrentTimerList, pxCurrentTimerList->uxNumberOfItems != 0) { + pxVar2 = (pxCurrentTimerList->xListEnd).pxNext; + xTimer = (TimerHandle_t)pxVar2->pvOwner; + xOptionalValue = pxVar2->xItemValue; + uxListRemove(&xTimer->xTimerListItem); + (*xTimer->pxCallbackFunction)(xTimer); + pxList = pxCurrentTimerList; + if ((xTimer->ucStatus & 4) != 0) { + uVar3 = xTimer->xTimerPeriodInTicks + xOptionalValue; + if (xOptionalValue < uVar3) { + (xTimer->xTimerListItem).xItemValue = uVar3; + *(TimerHandle_t *)&(xTimer->xTimerListItem).pvOwner = xTimer; + vListInsert(pxList,&xTimer->xTimerListItem); + } + else { + BVar1 = xTimerGenericCommand(xTimer,0,xOptionalValue,(BaseType_t *)0x0,0); + if (BVar1 == 0) { + vAssertCalled(); + } + } + } + } + pxCurrentTimerList = pxOverflowTimerList; + pxOverflowTimerList = pxList; + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void prvTimerTask(void *pvParameters) + +{ + uint xTimeNow; + BaseType_t BVar1; + TickType_t xTimeNow_00; + TickType_t TVar2; + uint xWaitIndefinitely; + UBaseType_t xCommandTime; + Timer_t *pxTimer; + uint uStack64; + DaemonTaskMessage_t xMessage; + + do { + xCommandTime = pxCurrentTimerList->uxNumberOfItems; + if (xCommandTime == 0) { + vTaskSuspendAll(pvParameters); + xTimeNow = xTaskGetTickCount(); + if (xTimeNow < xLastTime_2297) goto LAB_230352ac; + xWaitIndefinitely = (uint)(pxOverflowTimerList->uxNumberOfItems == 0); +LAB_230351a6: + xLastTime_2297 = xTimeNow; + vQueueWaitForMessageRestricted(xTimerQueue,xCommandTime - xTimeNow,xWaitIndefinitely); + BVar1 = xTaskResumeAll(); + if (BVar1 == 0) { + ecall(); + } + } + else { + xCommandTime = ((pxCurrentTimerList->xListEnd).pxNext)->xItemValue; + vTaskSuspendAll(pvParameters); + xTimeNow = xTaskGetTickCount(); + if (xTimeNow < xLastTime_2297) { +LAB_230352ac: + prvSwitchTimerLists(); + xLastTime_2297 = xTimeNow; + xTaskResumeAll(); + } + else { + xWaitIndefinitely = 0; + if (xTimeNow < xCommandTime) goto LAB_230351a6; + xLastTime_2297 = xTimeNow; + xTaskResumeAll(); + pxTimer = (Timer_t *)((pxCurrentTimerList->xListEnd).pxNext)->pvOwner; + uxListRemove(&pxTimer->xTimerListItem); + if ((pxTimer->ucStatus & 4) == 0) { + pxTimer->ucStatus = pxTimer->ucStatus & 0xfe; + } + else { + BVar1 = prvInsertTimerInActiveList + (pxTimer,pxTimer->xTimerPeriodInTicks + xCommandTime,xTimeNow, + xCommandTime); + if ((BVar1 != 0) && + (BVar1 = xTimerGenericCommand + ((TimerHandle_t)pxTimer,0,xCommandTime,(BaseType_t *)0x0,0), + BVar1 == 0)) { + vAssertCalled(); + } + } + (*pxTimer->pxCallbackFunction)((TimerHandle_t)pxTimer); + } + } + while (pvParameters = (void *)xQueueReceive(xTimerQueue,&uStack64,0), + pvParameters != (void *)0x0) { + if ((-1 < (int)uStack64) || + ((*(code *)xMessage.xMessageID)((Timer_t *)xMessage.u,xMessage.u._4_4_,xMessage.xMessageID) + , -1 < (int)uStack64)) { + pxTimer = (Timer_t *)xMessage.u; + if ((((Timer_t *)xMessage.u)->xTimerListItem).pvContainer != (xLIST *)0x0) { + uxListRemove(&((Timer_t *)xMessage.u)->xTimerListItem); + } + xTimeNow_00 = xTaskGetTickCount(); + if (xTimeNow_00 < xLastTime_2297) { + prvSwitchTimerLists(); + } + xLastTime_2297 = xTimeNow_00; + switch(uStack64) { + case 0: + case 1: + case 2: + case 6: + case 7: + pxTimer->ucStatus = pxTimer->ucStatus | 1; + BVar1 = prvInsertTimerInActiveList + (pxTimer,pxTimer->xTimerPeriodInTicks + xMessage.xMessageID,xTimeNow_00, + xMessage.xMessageID); + if (((BVar1 != 0) && + ((*pxTimer->pxCallbackFunction)((TimerHandle_t)pxTimer), (pxTimer->ucStatus & 4) != 0) + ) && (BVar1 = xTimerGenericCommand + ((TimerHandle_t)pxTimer,0, + xMessage.xMessageID + pxTimer->xTimerPeriodInTicks, + (BaseType_t *)0x0,0), BVar1 == 0)) { + vAssertCalled(); + } + break; + case 3: + case 8: + pxTimer->ucStatus = pxTimer->ucStatus & 0xfe; + break; + case 4: + case 9: + pxTimer->ucStatus = pxTimer->ucStatus | 1; + pxTimer->xTimerPeriodInTicks = xMessage.xMessageID; + TVar2 = xMessage.xMessageID; + if (xMessage.xMessageID == 0) { + vAssertCalled(); + TVar2 = pxTimer->xTimerPeriodInTicks; + } + prvInsertTimerInActiveList(pxTimer,TVar2 + xTimeNow_00,xTimeNow_00,xTimeNow_00); + break; + case 5: + if ((pxTimer->ucStatus & 2) == 0) { + vPortFree(pxTimer); + } + else { + pxTimer->ucStatus = pxTimer->ucStatus & 0xfe; + } + } + } + } + } while( true ); +} + + + +void * pvTimerGetTimerID(TimerHandle_t xTimer) + +{ + void *pvVar1; + + if (xTimer == (TimerHandle_t)0x0) { + vAssertCalled(); + } + vTaskEnterCritical(); + pvVar1 = xTimer->pvTimerID; + vTaskExitCritical(); + return pvVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void vPortSetupTimerInterrupt(void) + +{ + _DAT_02004000 = _DAT_0200bff8 + 10000; + _DAT_02004004 = (uint)(_DAT_0200bff8 + 10000 < _DAT_0200bff8) + _DAT_0200bffc; + ullNextTime._0_4_ = _DAT_0200bff8 + 20000; + ullNextTime._4_4_ = _DAT_0200bffc + (uint)(_DAT_0200bff8 + 20000 < _DAT_0200bff8); + return; +} + + +/* +Unable to decompile 'xPortStartScheduler' +Cause: Exception while decompiling 2303539c: Decompiler process died + +*/ + +/* +Unable to decompile 'xPortStartFirstTask' +Cause: Exception while decompiling 23035700: Decompiler process died + +*/ + + +// WARNING: Removing unreachable block (ram,0x23035800) + +void pxPortInitialiseStack(int param_1,undefined4 param_2,undefined4 param_3) + +{ + int iVar1; + undefined4 *puVar2; + uint in_mstatus; + + *(uint *)(param_1 + -4) = in_mstatus & 0xfffffff7 | 0x1880; + *(undefined4 *)(param_1 + -0x5c) = param_3; + puVar2 = (undefined4 *)(param_1 + -0x74); + *puVar2 = 0; + iVar1 = 0x22; + while (iVar1 != 0) { + puVar2 = puVar2 + -1; + *puVar2 = 0; + iVar1 = iVar1 + -1; + } + puVar2[-1] = param_2; + return; +} + + + +void prvInsertBlockIntoFreeList(BlockLink_t *pxBlockToInsert) + +{ + size_t sVar1; + BlockLink_t *pBVar2; + BlockLink_t *pBVar3; + + pBVar3 = &xStart; + do { + pBVar2 = pBVar3; + pBVar3 = (BlockLink_t *)pBVar2->pxNextFreeBlock; + } while (pBVar3 < pxBlockToInsert); + sVar1 = pxBlockToInsert->xBlockSize; + if (pxBlockToInsert == (BlockLink_t *)(pBVar2->xBlockSize + (int)&pBVar2->pxNextFreeBlock)) { + sVar1 = pBVar2->xBlockSize + sVar1; + pBVar2->xBlockSize = sVar1; + pxBlockToInsert = pBVar2; + } + if ((pBVar3 == (BlockLink_t *)(sVar1 + (int)&pxBlockToInsert->pxNextFreeBlock)) && + (pBVar3 != pxEnd)) { + pxBlockToInsert->xBlockSize = sVar1 + pBVar3->xBlockSize; + pxBlockToInsert->pxNextFreeBlock = pBVar2->pxNextFreeBlock->pxNextFreeBlock; + } + else { + *(BlockLink_t **)&pxBlockToInsert->pxNextFreeBlock = pBVar3; + } + if (pxBlockToInsert != pBVar2) { + *(BlockLink_t **)&pBVar2->pxNextFreeBlock = pxBlockToInsert; + } + return; +} + + + +void * pvPortMalloc(size_t xWantedSize) + +{ + size_t sVar1; + size_t sVar2; + BlockLink_t *pBVar3; + A_BLOCK_LINK *pAVar4; + BlockLink_t *pxBlockToInsert; + uint uVar5; + uint uVar6; + + if (pxEnd == (BlockLink_t *)0x0) { + vAssertCalled(); + } + vTaskSuspendAll(); + sVar2 = xFreeBytesRemaining; + sVar1 = xBlockAllocatedBit; + if (((xBlockAllocatedBit & xWantedSize) == 0) && (xWantedSize != 0)) { + uVar6 = xWantedSize + 8; + if ((uVar6 & 7) != 0) { + uVar6 = (uVar6 & 0xfffffff8) + 8; + } + if ((uVar6 != 0) && (uVar6 <= xFreeBytesRemaining)) { + pAVar4 = xStart.pxNextFreeBlock; + pBVar3 = &xStart; + do { + pxBlockToInsert = pBVar3; + pBVar3 = (BlockLink_t *)pAVar4; + if (uVar6 <= pBVar3->xBlockSize) break; + pAVar4 = pBVar3->pxNextFreeBlock; + } while (pBVar3->pxNextFreeBlock != (A_BLOCK_LINK *)0x0); + if (pxEnd != pBVar3) { + pAVar4 = pxBlockToInsert->pxNextFreeBlock; + pxBlockToInsert->pxNextFreeBlock = pBVar3->pxNextFreeBlock; + uVar5 = pBVar3->xBlockSize; + pAVar4 = pAVar4 + 1; + if (0x10 < uVar5 - uVar6) { + pxBlockToInsert = (BlockLink_t *)((int)&pBVar3->pxNextFreeBlock + uVar6); + pxBlockToInsert->xBlockSize = uVar5 - uVar6; + pBVar3->xBlockSize = uVar6; + prvInsertBlockIntoFreeList(pxBlockToInsert); + uVar5 = pBVar3->xBlockSize; + } + xFreeBytesRemaining = sVar2 - uVar5; + if (xFreeBytesRemaining < xMinimumEverFreeBytesRemaining) { + xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; + } + pBVar3->xBlockSize = sVar1 | uVar5; + pBVar3->pxNextFreeBlock = (A_BLOCK_LINK *)0x0; + xTaskResumeAll(); + if (pAVar4 != (A_BLOCK_LINK *)0x0) { + return pAVar4; + } + goto LAB_230359be; + } + } + } + xTaskResumeAll(); +LAB_230359be: + vApplicationMallocFailedHook(); + return (void *)0x0; +} + + + +void vPortFree(void *pv) + +{ + uint uVar1; + + if (pv == (void *)0x0) { + return; + } + uVar1 = *(uint *)((int)pv + -4); + if ((uVar1 & xBlockAllocatedBit) == 0) { + vAssertCalled(); + if (*(int *)((int)pv + -8) == 0) { + uVar1 = *(uint *)((int)pv + -4); + if ((uVar1 & xBlockAllocatedBit) == 0) { + return; + } + goto LAB_23035ace; + } + } + else { + if (*(int *)((int)pv + -8) == 0) goto LAB_23035ace; + } + vAssertCalled(); + uVar1 = *(uint *)((int)pv + -4); + if (((uVar1 & xBlockAllocatedBit) == 0) || (*(int *)((int)pv + -8) != 0)) { + return; + } +LAB_23035ace: + *(uint *)((int)pv + -4) = ~xBlockAllocatedBit & uVar1; + vTaskSuspendAll(); + xFreeBytesRemaining = *(int *)((int)pv + -4) + xFreeBytesRemaining; + prvInsertBlockIntoFreeList((BlockLink_t *)((int)pv + -8)); + xTaskResumeAll(); + return; +} + + + +size_t xPortGetFreeHeapSize(void) + +{ + return xFreeBytesRemaining; +} + + + +void vPortDefineHeapRegions(HeapRegion_t *pxHeapRegions) + +{ + size_t sVar1; + BlockLink_t *pBVar2; + BlockLink_t *pBVar3; + BlockLink_t *pBVar4; + A_BLOCK_LINK *pAVar5; + int iVar6; + size_t sVar7; + + if (pxEnd == (BlockLink_t *)0x0) { + sVar1 = pxHeapRegions->xSizeInBytes; + pBVar4 = pxEnd; + } + else { + vAssertCalled(); + sVar1 = pxHeapRegions->xSizeInBytes; + pBVar4 = pxEnd; + } + pxEnd = pBVar4; + if (sVar1 == 0) { + xMinimumEverFreeBytesRemaining = 0; + } + else { + iVar6 = 0; + sVar7 = 0; + do { + pBVar3 = (BlockLink_t *)pxHeapRegions->pucStartAddress; + pBVar2 = pBVar3; + if (((uint)pBVar3 & 7) != 0) { + pBVar2 = (BlockLink_t *)((int)&pBVar3->xBlockSize + 3U & 0xfffffff8); + sVar1 = (int)pBVar3 + (sVar1 - (int)pBVar2); + } + if (iVar6 == 0) { + xStart.xBlockSize = 0; + pBVar3 = pBVar4; + xStart.pxNextFreeBlock = (A_BLOCK_LINK *)pBVar2; + } + else { + if (pBVar4 == (BlockLink_t *)0x0) { + vAssertCalled(); + pBVar4 = pxEnd; + } + pBVar3 = pBVar4; + if (pBVar2 <= pBVar4) { + vAssertCalled(); + pBVar3 = pxEnd; + } + } + pBVar4 = (BlockLink_t *)((int)&pBVar2[-1].pxNextFreeBlock + sVar1 & 0xfffffff8); + ((A_BLOCK_LINK *)pBVar4)->xBlockSize = 0; + ((A_BLOCK_LINK *)pBVar4)->pxNextFreeBlock = (A_BLOCK_LINK *)0x0; + pAVar5 = (A_BLOCK_LINK *)((int)pBVar4 - (int)pBVar2); + pxEnd = pBVar4; + *(A_BLOCK_LINK **)&pBVar2->xBlockSize = pAVar5; + *(BlockLink_t **)&pBVar2->pxNextFreeBlock = pBVar4; + if (pBVar3 != (BlockLink_t *)0x0) { + *(BlockLink_t **)&pBVar3->pxNextFreeBlock = pBVar2; + pAVar5 = (A_BLOCK_LINK *)pBVar2->xBlockSize; + } + sVar1 = pxHeapRegions[1].xSizeInBytes; + sVar7 = (int)&pAVar5->pxNextFreeBlock + sVar7; + iVar6 = iVar6 + 1; + pxHeapRegions = pxHeapRegions + 1; + } while (sVar1 != 0); + xMinimumEverFreeBytesRemaining = sVar7; + if (sVar7 != 0) { + xBlockAllocatedBit = 0x80000000; + xFreeBytesRemaining = sVar7; + return; + } + } + xFreeBytesRemaining = xMinimumEverFreeBytesRemaining; + vAssertCalled(); + xBlockAllocatedBit = 0x80000000; + return; +} + + + +void uart_generic_notify_handler(uint8_t id) + +{ + uint uVar1; + uint uVar2; + undefined3 in_register_00002029; + int iVar3; + uint32_t uVar4; + + iVar3 = CONCAT31(in_register_00002029,id); + uVar4 = uartAddr[iVar3]; + uVar2 = *(uint *)(uVar4 + 0x20); + uVar1 = *(uint *)(uVar4 + 0x24); + if (((uVar2 & 1) != 0) && ((uVar1 & 1) == 0)) { + *(undefined4 *)(uVar4 + 0x28) = 1; + } + if (((uVar2 & 2) != 0) && ((uVar1 & 2) == 0)) { + *(undefined4 *)(uVar4 + 0x28) = 2; + if (g_uart_notify_arg[iVar3].rx_cb != (cb_uart_notify_t *)0x0) { + (*g_uart_notify_arg[iVar3].rx_cb)(g_uart_notify_arg[iVar3].rx_cb_arg); + } + } + if (((uVar2 & 4) != 0) && ((uVar1 & 4) == 0)) { + if (g_uart_notify_arg[iVar3].tx_cb != (cb_uart_notify_t *)0x0) { + (*g_uart_notify_arg[iVar3].tx_cb)(g_uart_notify_arg[iVar3].tx_cb_arg); + } + } + if (((uVar2 & 8) != 0) && ((uVar1 & 8) == 0)) { + if (g_uart_notify_arg[iVar3].rx_cb != (cb_uart_notify_t *)0x0) { + (*g_uart_notify_arg[iVar3].rx_cb)(g_uart_notify_arg[iVar3].rx_cb_arg); + } + } + if (((uVar2 & 0x10) != 0) && ((uVar1 & 0x10) == 0)) { + *(undefined4 *)(uVar4 + 0x28) = 0x10; + if (g_uart_notify_arg[iVar3].rx_cb != (cb_uart_notify_t *)0x0) { + (*g_uart_notify_arg[iVar3].rx_cb)(g_uart_notify_arg[iVar3].rx_cb_arg); + } + } + if (((uVar2 & 0x20) != 0) && ((uVar1 & 0x20) == 0)) { + *(undefined4 *)(uVar4 + 0x28) = 0x20; + } + return; +} + + + +void UART0_IRQHandler(void) + +{ + uart_generic_notify_handler('\0'); + return; +} + + + +void UART1_IRQHandler(void) + +{ + uart_generic_notify_handler('\x01'); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bl_uart_init(uint8_t id,uint8_t tx_pin,uint8_t rx_pin,uint8_t cts_pin,uint8_t rts_pin, + uint32_t baudrate) + +{ + uint8_t uart_clk_init; + GLB_UART_SIG_FUN_Type fun; + undefined3 in_register_00002029; + GLB_UART_SIG_FUN_Type fun_00; + UART_FifoCfg_Type UStack60; + UART_FifoCfg_Type fifoCfg; + GLB_GPIO_Cfg_Type cfg; + UART_CFG_Type uartCfg; + + memcpy(&cfg.drive,&DAT_23078a54,0x10); + UStack60 = DAT_4200dd10; + if (uart_clk_init == '\0') { + GLB_Set_UART_CLK('\x01',HBN_UART_CLK_160M,'\x03'); + uart_clk_init = '\x01'; + } + fifoCfg.rxFifoDmaThreshold = '\a'; + fifoCfg._2_2_ = 2; + cfg._0_2_ = 0x101; + fifoCfg.txFifoDmaThreshold = rx_pin; + GLB_GPIO_Init((GLB_GPIO_Cfg_Type *)&fifoCfg); + fifoCfg._2_2_ = 2; + fifoCfg.txFifoDmaThreshold = tx_pin; + GLB_GPIO_Init((GLB_GPIO_Cfg_Type *)&fifoCfg); + if (CONCAT31(in_register_00002029,id) == 0) { + fun = GLB_UART_SIG_FUN_UART0_RXD; + fun_00 = GLB_UART_SIG_FUN_UART0_TXD; + } + else { + fun = GLB_UART_SIG_FUN_UART1_RXD; + fun_00 = GLB_UART_SIG_FUN_UART1_TXD; + } + GLB_UART_Fun_Sel(tx_pin & 7,fun_00); + GLB_UART_Fun_Sel(rx_pin & 7,fun); + stack0xffffffd0 = 40000000; + UART_IntMask(id,UART_INT_ALL,MASK); + UART_Disable(id,UART_TXRX); + UART_Init(id,(UART_CFG_Type *)&cfg.drive); + UART_TxFreeRun(id,ENABLE); + UART_FifoConfig(id,&UStack60); + UART_Enable(id,UART_TXRX); + return 0; +} + + + +int bl_uart_data_send(uint8_t id,uint8_t data) + +{ + uint32_t uVar1; + uint8_t uVar2; + undefined3 in_register_00002029; + undefined3 extraout_var; + + uVar1 = uartAddr[CONCAT31(in_register_00002029,id)]; + do { + uVar2 = UART_GetTxFifoCount(id); + } while (CONCAT31(extraout_var,uVar2) == 0); + *(uint8_t *)(uVar1 + 0x88) = data; + return 0; +} + + + +int bl_uart_data_recv(uint8_t id) + +{ + uint32_t uVar1; + uint8_t uVar2; + undefined3 in_register_00002029; + undefined3 extraout_var; + uint uVar3; + + uVar1 = uartAddr[CONCAT31(in_register_00002029,id)]; + uVar2 = UART_GetRxFifoCount(id); + if (CONCAT31(extraout_var,uVar2) == 0) { + uVar3 = 0xffffffff; + } + else { + uVar3 = (uint)*(byte *)(uVar1 + 0x8c); + } + return uVar3; +} + + + +int bl_uart_int_rx_enable(uint8_t id) + +{ + UART_SetRxTimeoutValue(id,'\x18'); + UART_IntMask(id,UART_INT_RX_FIFO_REQ,UNMASK); + UART_IntMask(id,UART_INT_RX_END,UNMASK); + UART_IntMask(id,UART_INT_RTO,UNMASK); + return 0; +} + + + +int bl_uart_int_rx_disable(uint8_t id) + +{ + UART_IntMask(id,UART_INT_RX_FIFO_REQ,MASK); + UART_IntMask(id,UART_INT_RX_END,MASK); + UART_IntMask(id,UART_INT_RTO,MASK); + return 0; +} + + + +int bl_uart_int_tx_enable(uint8_t id) + +{ + UART_IntMask(id,UART_INT_TX_FIFO_REQ,UNMASK); + return 0; +} + + + +int bl_uart_int_tx_disable(uint8_t id) + +{ + UART_IntMask(id,UART_INT_TX_FIFO_REQ,MASK); + return 0; +} + + + +int bl_uart_flush(uint8_t id) + +{ + uint8_t uVar1; + undefined3 extraout_var; + + do { + uVar1 = UART_GetTxFifoCount(id); + } while (CONCAT31(extraout_var,uVar1) != 0x20); + return 0; +} + + + +void bl_uart_getdefconfig(uint8_t id,uint8_t *parity) + +{ + if (parity != (uint8_t *)0x0) { + *parity = '\0'; + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: UartCfg +// WARNING: Could not reconcile some variable overlaps + +void bl_uart_setconfig(uint8_t id,uint32_t baudrate,UART_Parity_Type parity) + +{ + undefined auStack32 [4]; + UART_CFG_Type UartCfg; + + memcpy(auStack32,&DAT_23078a64,0x10); + UartCfg.uartClk = baudrate; + UartCfg.baudRate._2_1_ = parity; + UART_Disable(id,UART_TXRX); + UART_Init(id,(UART_CFG_Type *)auStack32); + UART_TxFreeRun(id,ENABLE); + UART_Enable(id,UART_TXRX); + return; +} + + + +void bl_uart_setbaud(uint8_t id,uint32_t baud) + +{ + bl_uart_setconfig(id,baud,UART_PARITY_NONE); + return; +} + + + +int bl_uart_int_enable(uint8_t id) + +{ + undefined3 in_register_00002029; + uint source; + + if (CONCAT31(in_register_00002029,id) == 0) { + bl_uart_int_rx_enable(id); + bl_uart_int_tx_enable('\0'); + bl_irq_register(0x2d,UART0_IRQHandler); + source = 0x2d; + } + else { + if (CONCAT31(in_register_00002029,id) != 1) { + return -1; + } + bl_uart_int_rx_enable(id); + bl_uart_int_tx_enable('\x01'); + bl_irq_register(0x2e,UART1_IRQHandler); + source = 0x2e; + } + bl_irq_enable(source); + return 0; +} + + + +int bl_uart_int_disable(uint8_t id) + +{ + undefined3 in_register_00002029; + uint source; + + if (CONCAT31(in_register_00002029,id) == 0) { + bl_uart_int_rx_disable(id); + bl_uart_int_tx_disable('\0'); + bl_irq_unregister(0x2d,UART0_IRQHandler); + source = 0x2d; + } + else { + if (CONCAT31(in_register_00002029,id) != 1) { + return -1; + } + bl_uart_int_rx_disable(id); + bl_uart_int_tx_disable('\x01'); + bl_irq_unregister(0x2e,UART1_IRQHandler); + source = 0x2e; + } + bl_irq_disable(source); + return 0; +} + + + +int bl_uart_int_rx_notify_register(uint8_t id,cb_uart_notify_t *cb,void *arg) + +{ + undefined3 in_register_00002029; + uint uVar1; + + uVar1 = CONCAT31(in_register_00002029,id); + if (uVar1 < 2) { + g_uart_notify_arg[uVar1].rx_cb = cb; + g_uart_notify_arg[uVar1].rx_cb_arg = arg; + return 0; + } + return -1; +} + + + +int bl_uart_int_tx_notify_register(uint8_t id,cb_uart_notify_t *cb,void *arg) + +{ + undefined3 in_register_00002029; + uint uVar1; + + uVar1 = CONCAT31(in_register_00002029,id); + if (uVar1 < 2) { + g_uart_notify_arg[uVar1].tx_cb = cb; + g_uart_notify_arg[uVar1].tx_cb_arg = arg; + return 0; + } + return -1; +} + + + +// WARNING: Removing unreachable block (ram,0x23036074) + +int bl_chip_info(char *info) + +{ + char *pcVar1; + undefined *__src; + uint uVar2; + uint in_register_90000c04; + uint32_t misa; + + uVar2 = in_register_90000c04 >> 0x1e; + if (uVar2 == 2) { + memcpy(info,&DAT_23078d38,4); + pcVar1 = info + 4; + } + else { + if (uVar2 == 3) { + memcpy(info,"RV128",5); + pcVar1 = info + 5; + } + else { + pcVar1 = info + 4; + if (uVar2 == 1) { + __src = &DAT_23078d30; + } + else { + __src = &DAT_23078d48; + } + memcpy(info,__src,4); + } + } + *pcVar1 = '-'; + pcVar1 = pcVar1 + 1; + uVar2 = 0; + do { + if ((1 << (uVar2 & 0x1f) & in_register_90000c04) != 0) { + *pcVar1 = (char)uVar2 + 'A'; + pcVar1 = pcVar1 + 1; + } + uVar2 = uVar2 + 1; + } while (uVar2 != 0x1a); + *pcVar1 = '\0'; + return 0; +} + + + +int bl_chip_banner(char **banner) + +{ + *banner = + "██████╗ ██╗ ██████╗ ██████╗ ██████╗\n\r██╔══██╗██║ ██╔════╝ ██╔═████╗╚════██╗\n\r██████╔╝██║ ███████╗ ██║██╔██║ █████╔╝\n\r██╔══██╗██║ ██╔═══██╗████╔╝██║██╔═══╝\n\r██████╔╝███████╗╚██████╔╝╚██████╔╝███████╗\n\r╚═════╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝\n\r" + ; + return 0; +} + + + +int bl_chip_memory_ram(int *num,uint *addr,uint *size,char (*desc) [6]) + +{ + if (2 < *num) { + *num = 3; + *addr = 0x23000000; + *size = 0x400000; + strcpy((char *)desc,"flash"); + addr[1] = 0x4200c000; + size[1] = 0x34000; + strcpy((char *)(desc + 1),"tcm"); + addr[2] = 0x42040000; + size[2] = 0xa000; + strcpy((char *)(desc + 2),"wifi"); + return 0; + } + return -1; +} + + + +int bl_sys_reset_por(void) + +{ + GLB_SW_POR_Reset(); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void bl_sys_reset_system(void) + +{ + GLB_SW_System_Reset(); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +int bl_sys_isxipaddr(uint32_t addr) + +{ + return (uint)(((addr & 0xff000000) + 0xdd000000 & 0xdf000000) == 0); +} + + + +// WARNING: Removing unreachable block (ram,0x23036206) +// WARNING: Removing unreachable block (ram,0x2303620c) + +int bl_sys_em_config(void) + +{ + GLB_Set_EM_Sel(GLB_EM_8KB); + return 0; +} + + +/* +Unable to decompile 'bl_sys_early_init' +Cause: Exception while decompiling 2303621e: Decompiler process died + +*/ + + +int bl_sys_init(void) + +{ + bl_sys_em_config(); + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void bl_dma_int_process(void) + +{ + uint uVar1; + uint uVar2; + int iVar3; + uint uVar4; + uint uVar5; + uint uVar6; + uint uVar7; + int *piStack52; + dma_ctx *pstctx; + + uVar1 = _DAT_4000c00c; + uVar2 = _DAT_4000c004; + uVar5 = 0; + bl_irq_ctx_get(0x1f,&piStack52); + do { + uVar4 = 1 << (uVar5 & 0x1f); + uVar7 = uVar4 & uVar2; + uVar6 = uVar4 & uVar1; + if (uVar7 == 0) { + if (uVar6 != 0) { +LAB_23036290: + uVar2 = _DAT_4000c010 | uVar4; + _DAT_4000c010 = uVar2; + goto LAB_2303629a; + } + } + else { + uVar2 = _DAT_4000c008 | uVar4; + _DAT_4000c008 = uVar2; + if (uVar6 != 0) goto LAB_23036290; +LAB_2303629a: + iVar3 = *(int *)(*piStack52 + 4); + while (iVar3 != *piStack52) { + if (*(uint *)(iVar3 + 8) == uVar5) { + if ((*(code **)(iVar3 + 0xc) != (code *)0x0) && (uVar7 != 0)) { + (**(code **)(iVar3 + 0xc))(); + } + if ((*(code **)(iVar3 + 0x10) != (code *)0x0) && (uVar6 != 0)) { + (**(code **)(iVar3 + 0x10))(); + } + } + iVar3 = *(int *)(iVar3 + 4); + } + } + uVar5 = uVar5 + 1; + if (uVar5 == 4) { + return; + } + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int bl_dma_int_clear(int ch) + +{ + uint uVar1; + + uVar1 = 1 << (ch & 0x1fU); + if ((_DAT_4000c004 & uVar1 & 0xff) != 0) { + _DAT_4000c008 = _DAT_4000c008 | uVar1; + } + if ((_DAT_4000c00c & uVar1 & 0xff) != 0) { + _DAT_4000c010 = uVar1 | _DAT_4000c010; + } + return 0; +} + + + +void bl_dma_IRQHandler(void) + +{ + utils_list_hdr *puVar1; + TickType_t TVar2; + + bl_dma_int_clear(0); + puVar1 = utils_list_pop_front(&dma_copy_list); + if (puVar1 == (utils_list_hdr *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvbl_dma < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [INT] ASSERT here for empty chain\r\n",TVar2,&DAT_2306e4ac, + &UNK_23078d64,0x9d); + } + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + if (puVar1[1].next != (utils_list_hdr *)0x0) { + (*(code *)puVar1[1].next)(puVar1[2].next); + } + if (dma_copy_list.first != (utils_list_hdr *)0x0) { + DMA_LLI_Update('\0',(uint32_t)(dma_copy_list.first + 3)); + DMA_Channel_Enable('\0'); + return; + } + return; +} + + + +int bl_dma_irq_register(int channel,void *tc_handler,void *interr_handler,void *ctx) + +{ + int iVar1; + TickType_t TVar2; + int *piVar3; + int **ppiVar4; + int *piStack36; + dma_ctx *pstctx; + + if (((uint)channel < 5) && (tc_handler != (void *)0x0)) { + bl_irq_ctx_get(0x1f,&piStack36); + iVar1 = *(int *)(*piStack36 + 4); + while (*piStack36 != iVar1) { + if (channel == *(int *)(iVar1 + 8)) { + if (BLOG_LEVEL_WARN < _fsymc_level_hal_drv) { + return -1; + } + if (BLOG_LEVEL_WARN < _fsymf_level_hal_drvbl_dma) { + return -1; + } + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] channel %d already register \r\n",TVar2,&DAT_230781b4, + &UNK_23078d64,0x124,*(undefined4 *)(iVar1 + 8)); + return -1; + } + iVar1 = *(int *)(iVar1 + 4); + } + piVar3 = (int *)pvPortMalloc(0x18); + if (((piVar3 == (int *)0x0) && (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvbl_dma < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] malloc dma node failed. \r\n",TVar2,&DAT_23078e4c,&UNK_23078d64, + 0x12a); + } + piVar3[2] = channel; + *(void **)(piVar3 + 3) = tc_handler; + *(void **)(piVar3 + 4) = interr_handler; + *(void **)(piVar3 + 5) = ctx; + iVar1 = *piStack36; + ppiVar4 = *(int ***)(iVar1 + 4); + *piVar3 = iVar1; + *(int ***)(piVar3 + 1) = ppiVar4; + *(int **)(iVar1 + 4) = piVar3; + *ppiVar4 = piVar3; + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvbl_dma < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] not valid para \r\n",TVar2,&DAT_23078e4c,&UNK_23078d64,0x11c); + } + } + return -1; +} + + + +void bl_dma_init(void) + +{ + void **ctx; + char *format; + void *pvVar1; + undefined4 uVar2; + undefined2 uStack20; + DMA_Periph_Req_Type DStack18; + DMA_LLI_Cfg_Type lliCfg; + + uStack20 = 0; + DStack18 = DMA_REQ_UART0_RX; + utils_list_init(&dma_copy_list); + ctx = (void **)pvPortMalloc(4); + if (ctx == (void **)0x0) { + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvbl_dma) { + return; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar2 = 0x180; + format = "[%10u][%s: %s:%4d] malloc dma ctx failed \r\n"; + } + else { + pvVar1 = pvPortMalloc(8); + *ctx = pvVar1; + if (pvVar1 != (void *)0x0) { + *(void **)((int)pvVar1 + 4) = pvVar1; + *(void **)pvVar1 = pvVar1; + DMA_Enable(); + DMA_IntMask('\0',DMA_INT_ALL,MASK); + DMA_IntMask('\0',DMA_INT_TCOMPLETED,UNMASK); + DMA_IntMask('\0',DMA_INT_ERR,UNMASK); + DMA_LLI_Init('\0',(DMA_LLI_Cfg_Type *)&uStack20); + bl_irq_register_with_ctx(0x1f,bl_dma_int_process,ctx); + bl_dma_irq_register(0,bl_dma_IRQHandler,(void *)0x0,(void *)0x0); + bl_irq_enable(0x1f); + return; + } + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvbl_dma) { + return; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar2 = 0x187; + format = "[%10u][%s: %s:%4d] malloc dma pstqueue failed \r\n"; + } + bl_printk(format,&DAT_23078e4c,&UNK_23078d64,uVar2); + return; +} + + + +void _irq_num_check(int irqnum) + +{ + TickType_t TVar1; + + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && (_fsymf_level_hal_drvbl_irq < BLOG_LEVEL_ASSERT) + ) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] illegal irqnum %d\r\n",TVar1,&DAT_23078e4c,"bl_irq.c",0x70,irqnum) + ; + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void bl_irq_enable(uint source) + +{ + (&DAT_02800400)[source] = 1; + return; +} + + + +void bl_irq_disable(uint source) + +{ + (&DAT_02800400)[source] = 0; + return; +} + + + +void bl_irq_pending_clear(uint source) + +{ + (&DAT_02800000)[source] = 0; + return; +} + + + +void bl_irq_register_with_ctx(int irqnum,void *handler,void *ctx) + +{ + TickType_t TVar1; + + if (0x4f < (uint)irqnum) { + _irq_num_check(irqnum); + } + if (handler_list[irqnum] == (anon_subr_void *)0x0) goto LAB_23036764; + if (handler_list[irqnum] == (anon_subr_void *)handler) { +LAB_230367d6: + handler_list[irqnum] = handler; + if ((anon_subr_void *)ctx == (anon_subr_void *)0x0) { + handler_list[irqnum + 0x50] = (anon_subr_void *)0x0; + } + else { + handler_list[irqnum + 0x50] = ctx; + } + } + else { + if (_fsymc_level_hal_drv < BLOG_LEVEL_ERROR) { + if (_fsymf_level_hal_drvbl_irq < BLOG_LEVEL_ERROR) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] IRQ %d already registered with %p \r\n",TVar1,&DAT_230781b4, + "bl_irq.c",0x7e,irqnum,handler_list[irqnum]); + goto LAB_23036764; + } + if ((anon_subr_void *)handler != (anon_subr_void *)0x0) goto LAB_230367d6; + } + else { +LAB_23036764: + if ((anon_subr_void *)handler != (anon_subr_void *)0x0) goto LAB_230367d6; + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return; + } + } + if (_fsymf_level_hal_drvbl_irq < BLOG_LEVEL_ASSERT) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] handler is NULL pointer! \r\n",TVar1,&DAT_23078e4c,"bl_irq.c", + 0x82); + return; + } + } + return; +} + + + +void bl_irq_ctx_get(int irqnum,void **ctx) + +{ + if (0x4f < (uint)irqnum) { + _irq_num_check(irqnum); + } + *(anon_subr_void **)ctx = handler_list[irqnum + 0x50]; + return; +} + + + +void bl_irq_register(int irqnum,void *handler) + +{ + bl_irq_register_with_ctx(irqnum,handler,(void *)0x0); + return; +} + + + +void bl_irq_unregister(int irqnum,void *handler) + +{ + TickType_t TVar1; + + if (0x4f < (uint)irqnum) { + _irq_num_check(irqnum); + } + if (((handler_list[irqnum] != (anon_subr_void *)handler) && + (_fsymc_level_hal_drv < BLOG_LEVEL_ERROR)) && (_fsymf_level_hal_drvbl_irq < BLOG_LEVEL_ERROR)) + { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] IRQ %d:%p Not match with registered %p\r\n",TVar1,&DAT_230781b4, + "bl_irq.c",0xa8,irqnum,handler,handler_list[irqnum]); + } + handler_list[irqnum] = handler; + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void interrupt_entry(uint32_t mcause) + +{ + anon_subr_void *UNRECOVERED_JUMPTABLE_00; + uint uVar1; + + uVar1 = mcause & 0x7ffffff; + if (uVar1 < 0x50) { + UNRECOVERED_JUMPTABLE_00 = handler_list[uVar1]; + if (UNRECOVERED_JUMPTABLE_00 != (anon_subr_void *)0x0) { + if (handler_list[uVar1 + 0x50] != (anon_subr_void *)0x0) { + // WARNING: Could not recover jumptable at 0x230368fc. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE_00)(); + return; + } + // WARNING: Could not recover jumptable at 0x230368fe. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE_00)(); + return; + } + } + printf("Cannot handle mcause 0x%lx:%lu, adjust to externel(0x%lx:%lu)\r\n",uVar1,uVar1 - 0x10); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void exception_entry(uint32_t mcause,uint32_t mepc,uint32_t mtval,uintptr_t *regs) + +{ + char *s; + + if ((mcause & 0x3ff) == 4) { + misaligned_load_trap(mcause,mepc); + return; + } + if ((mcause & 0x3ff) != 6) { + puts("Exception Entry--->>>\r\n"); + printf("mcause %08lx, mepc %08lx, mtval %08lx\r\n",mcause,mepc,mtval); + printf("Exception code: %lu\r\n",mcause & 0xffff); + switch(mcause & 0xffff) { + case 0: + s = " msg: Instruction address misaligned\r\n"; + break; + case 1: + s = " msg: Instruction access fault\r\n"; + break; + case 2: + s = " msg: Illegal instruction\r\n"; + break; + case 3: + s = " msg: Breakpoint\r\n"; + break; + case 4: + s = " msg: Load address misaligned\r\n"; + break; + case 5: + s = " msg: Load access fault\r\n"; + break; + case 6: + s = " msg: Store/AMO access misaligned\r\n"; + break; + case 7: + s = " msg: Store/AMO access fault\r\n"; + break; + case 8: + s = " msg: Environment call from U-mode\r\n"; + break; + case 9: + s = " msg: Environment call from S-mode\r\n"; + break; + case 10: + case 0xe: + s = " msg: Reserved\r\n"; + break; + case 0xb: + s = " msg: Environment call from M-mode\r\n"; + break; + case 0xc: + s = " msg: Instruction page fault\r\n"; + break; + case 0xd: + s = " msg: Load page fault\r\n"; + break; + case 0xf: + s = " msg: Store/AMO page fault\r\n"; + break; + default: + s = " msg: Reserved default exception\r\n"; + } + puts(s); + backtrace_riscv(printf,regs); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + misaligned_store_trap(mcause,mepc); + return; +} + + + +void bl_irq_init(void) + +{ + undefined *puVar1; + + puts("[IRQ] Clearing and Disable all the pending IRQ...\r\n"); + puVar1 = &DAT_02800400; + do { + *puVar1 = 0; + puVar1 = puVar1 + 1; + } while (puVar1 != (undefined *)0x2800480); + puVar1 = &DAT_02800000; + do { + *puVar1 = 0; + puVar1 = puVar1 + 1; + } while (puVar1 != (undefined *)0x2800080); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void _trng_trigger(void) + +{ + if ((_DAT_40004200 & 1) == 0) { + _DAT_40004200 = _DAT_40004200 | 0x606; + _DAT_4000422c = trng_buffer[0]; + _DAT_40004230 = trng_buffer[1]; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void wait_trng4feed(void) + +{ + do { + } while ((_DAT_40004200 & 1) != 0); + _DAT_40004200 = _DAT_40004200 & 0xfffffffd | 0x200; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && (_fsymf_level_hal_drvbl_sec < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Feed random number is %08lx\r\n","DEBUG ","bl_sec.c",0x5b, + trng_buffer[0]); + } + trng_buffer[0] = _DAT_40004208; + trng_buffer[1] = _DAT_4000420c; + trng_buffer[2] = _DAT_40004210; + trng_buffer[3] = _DAT_40004214; + trng_buffer[4] = _DAT_40004218; + trng_buffer[5] = _DAT_4000421c; + trng_buffer[6] = _DAT_40004220; + trng_buffer[7] = _DAT_40004224; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sec_trng_IRQHandler(uint param_1,int param_2) + +{ + aos_now_ms(); + if ((param_2 < 1) && ((param_2 != 0 || (param_1 < 2000)))) { + puts("[BL] [SEC] TRNG Handler\r\n"); + } + _DAT_40004200 = _DAT_40004200 & 0xfffffffd | 0x200; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && (_fsymf_level_hal_drvbl_sec < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] random number is %08lx\r\n","DEBUG ","bl_sec.c",0xab, + trng_buffer[0]); + } + trng_buffer[0] = _DAT_40004208; + trng_buffer[1] = _DAT_4000420c; + trng_buffer[2] = _DAT_40004210; + trng_buffer[3] = _DAT_40004214; + trng_buffer[4] = _DAT_40004218; + trng_buffer[5] = _DAT_4000421c; + trng_buffer[6] = _DAT_40004220; + trng_buffer[7] = _DAT_40004224; + return; +} + + + +uint32_t bl_sec_get_random_word(void) + +{ + uint uVar1; + + uVar1 = trng_idx & 7; + if (uVar1 == 0) { + trng_idx = uVar1; + _trng_trigger(); + } + trng_idx = uVar1 + 1; + return trng_buffer[uVar1]; +} + + + +void bl_rand_stream(uint8_t *buf,int len) + +{ + size_t __n; + int iVar1; + + if (trng_idx != 0) { + _trng_trigger(); + wait_trng4feed(); + trng_idx = 0; + } + iVar1 = 0; + while (0 < len) { + if (trng_idx != 0) { + _trng_trigger(); + wait_trng4feed(); + trng_idx = 0; + } + __n = len; + if (0x20 < len) { + __n = 0x20; + } + memcpy(buf + iVar1,trng_buffer,__n); + iVar1 = iVar1 + __n; + len = len - __n; + trng_idx = 0x1f; + } + _trng_trigger(); + wait_trng4feed(); + trng_idx = 0; + return; +} + + + +int bl_rand(void) + +{ + int iVar1; + uint32_t uVar2; + + iVar1 = 0x13; + do { + uVar2 = bl_sec_get_random_word(); + iVar1 = iVar1 + -1; + if (iVar1 == 0) { + puts("[BL] [SEC] Failed after loop (17)\r\n"); + break; + } + } while (uVar2 == 0); + return uVar2 >> 1; +} + + + +int bl_sec_init(void) + +{ + g_bl_sec_sha_mutex = + (SemaphoreHandle_t)xQueueCreateMutexStatic('\x01',(StaticQueue_t *)&sha_mutex_buf); + _trng_trigger(); + wait_trng4feed(); + _trng_trigger(); + wait_trng4feed(); + bl_irq_register(0x1c,sec_trng_IRQHandler); + bl_irq_enable(0x1c); + return 0; +} + + + +int bl_sec_test(void) + +{ + int iVar1; + + bl_printk("------------------TRNG TEST---------------------------------\r\n"); + iVar1 = bl_rand(); + bl_printk("**********TRNG TEST rand[%08x]**************\r\n",iVar1); + iVar1 = bl_rand(); + bl_printk("**********TRNG TEST rand[%08x]**************\r\n",iVar1); + bl_printk("------------------------------------------------------------\r\n"); + return 0; +} + + + +int bl_efuse_read_mac(uint8_t *mac) + +{ + EF_Ctrl_Read_MAC_Address(mac); + return 0; +} + + + +int bl_efuse_read_mac_factory(uint8_t *mac) + +{ + int8_t iVar1; + undefined3 extraout_var; + + iVar1 = mfg_media_read_macaddr(mac,'\x01'); + return -(uint)(CONCAT31(extraout_var,iVar1) != 0); +} + + + +int bl_efuse_read_capcode(uint8_t *capcode) + +{ + int8_t iVar1; + undefined3 extraout_var; + + iVar1 = mfg_media_read_xtal_capcode(capcode,'\x01'); + return -(uint)(CONCAT31(extraout_var,iVar1) != 0); +} + + + +int bl_efuse_read_pwroft(int8_t *poweroffset) + +{ + int8_t iVar1; + undefined3 extraout_var; + + iVar1 = mfg_media_read_poweroffset(poweroffset,'\x01'); + return -(uint)(CONCAT31(extraout_var,iVar1) != 0); +} + + + +int bl_wifi_clock_enable(void) + +{ + int called; + + return 0; +} + + + +int bl_wifi_enable_irq(void) + +{ + bl_irq_register(0x46,mac_irq); + bl_irq_register(0x4f,bl_irq_handler); + bl_irq_enable(0x46); + bl_irq_enable(0x4f); + puts("Enable BMX IRQ\r\n"); + return 0; +} + + + +int bl_wifi_sta_mac_addr_set(uint8_t *mac) + +{ + memcpy(&wifi_env,mac,6); + return 0; +} + + + +int bl_wifi_ap_mac_addr_set(uint8_t *mac) + +{ + memcpy(wifi_env.ap_mac_addr_board,mac,6); + return 0; +} + + + +int bl_wifi_mac_addr_get(uint8_t *mac) + +{ + memcpy(mac,&wifi_env,6); + return 0; +} + + + +int bl_wifi_country_code_set(uint8_t country_code) + +{ + wifi_env.country_code = country_code; + return 0; +} + + + +int bl_wifi_ap_info_set(uint8_t *ssid,uint8_t ssid_len,uint8_t *psk,uint8_t psk_len,uint8_t chan) + +{ + undefined3 in_register_0000202d; + undefined3 in_register_00002035; + + memset(&wifi_env.ap_info,0,99); + memcpy(&wifi_env.ap_info,ssid,CONCAT31(in_register_0000202d,ssid_len)); + memcpy(wifi_env.ap_info.psk,psk,CONCAT31(in_register_00002035,psk_len)); + wifi_env.ap_info.chan = chan; + wifi_env.ap_info_en = '\x01'; + return 0; +} + + + +int bl_wifi_sta_info_set + (uint8_t *ssid,uint8_t ssid_len,uint8_t *psk,uint8_t psk_len,int autoconnect) + +{ + undefined3 in_register_0000202d; + undefined3 in_register_00002035; + + memset(&wifi_env.sta_info,0,99); + memcpy(&wifi_env.sta_info,ssid,CONCAT31(in_register_0000202d,ssid_len)); + memcpy(wifi_env.sta_info.psk,psk,CONCAT31(in_register_00002035,psk_len)); + wifi_env.sta_info_en = (uint8_t)autoconnect; + return 0; +} + + + +uint32_t fdt32_to_cpu(fdt32_t x) + +{ + return (x >> 0x10 & 0xff) << 8 | x << 0x18 | x >> 0x18 | (x >> 8 & 0xff) << 0x10; +} + + + +int dev_uart_init(uint8_t id,char *path,uint32_t rx_buf_size,uint32_t tx_buf_size) + +{ + uart_dev_t **ppuVar1; + undefined3 in_register_00002029; + uint uVar2; + TickType_t TVar3; + char *format; + void *pvVar4; + int iVar5; + undefined4 uVar6; + uart_dev_t *__s; + + uVar2 = CONCAT31(in_register_00002029,id); + if ((uVar2 < 3) && (path != (char *)0x0)) { + if (uVar2 == 0) { + ppuVar1 = &dev_uart0; + __s = dev_uart0; + } + else { + if (uVar2 != 1) { + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return -1; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_uart) { + return -1; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar6 = 0x74; + format = "[%10u][%s: %s:%4d] err.\r\n"; + goto LAB_230370e0; + } + ppuVar1 = &dev_uart1; + __s = dev_uart1; + } + if (__s == (uart_dev_t *)0x0) { + __s = (uart_dev_t *)pvPortMalloc(0x3c); + *ppuVar1 = __s; + if (__s == (uart_dev_t *)0x0) { + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return -1; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_uart) { + return -1; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar6 = 0x3c; + } + else { + memset(__s,0,0x3c); + (*ppuVar1)->read_block_flag = '\x02'; + (*ppuVar1)->priv = (void *)0x0; + __s = *ppuVar1; + pvVar4 = pvPortMalloc(4); + __s->priv = pvVar4; + if ((*ppuVar1)->priv != (void *)0x0) { + memset((*ppuVar1)->priv,0,4); + (*ppuVar1)->rx_buf_size = rx_buf_size; + (*ppuVar1)->tx_buf_size = tx_buf_size; + if (*ppuVar1 == (uart_dev_t *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] mem err.\r\n",TVar3,&DAT_23078e4c,"hal_uart.c",0x50); + } + } + else { + (*ppuVar1)->port = id; + (*ppuVar1)->read_block_flag = '\x02'; + ((*ppuVar1)->config).baud_rate = 0x1c200; + ((*ppuVar1)->config).data_width = DATA_WIDTH_8BIT; + ((*ppuVar1)->config).parity = NO_PARITY; + ((*ppuVar1)->config).stop_bits = STOP_BITS_1; + ((*ppuVar1)->config).flow_control = FLOW_CONTROL_DISABLED; + ((*ppuVar1)->config).mode = MODE_TX_RX; + } + iVar5 = aos_register_driver(path,(file_ops_t *)&uart_ops,*ppuVar1); + return iVar5; + } + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return -1; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_uart) { + return -1; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar6 = 0x45; + } + format = "[%10u][%s: %s:%4d] mem err.\r\n"; + goto LAB_230370e0; + } + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return -1; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_uart) { + return -1; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar6 = 0x36; + } + else { + if (BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) { + return -1; + } + if (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_uart) { + return -1; + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar6 = 0x65; + } + format = "[%10u][%s: %s:%4d] arg err.\r\n"; +LAB_230370e0: + bl_printk(format,TVar3,&DAT_23078e4c,"hal_uart.c",uVar6); + return -1; +} + + + +int32_t hal_uart_send_trigger(uart_dev_t *uart) + +{ + bl_uart_int_tx_enable(uart->port); + return 0; +} + + + +int32_t hal_uart_send_trigger_off(uart_dev_t *uart) + +{ + bl_uart_int_tx_disable(uart->port); + return 0; +} + + + +int32_t hal_uart_init(uart_dev_t *uart) + +{ + int iVar1; + int iVar2; + hal_uart_parity_t ahStack17 [4]; + uint8_t parity; + + iVar2 = aos_mutex_new((aos_mutex_t *)uart->priv); + iVar1 = -1; + if (iVar2 == 0) { + bl_uart_getdefconfig(uart->port,ahStack17); + if (ahStack17[0] == NO_PARITY) { + (uart->config).parity = NO_PARITY; + } + else { + if (ahStack17[0] != ODD_PARITY) { + ahStack17[0] = EVEN_PARITY; + } + (uart->config).parity = ahStack17[0]; + } + bl_uart_int_enable(uart->port); + iVar1 = iVar2; + } + return iVar1; +} + + + +int32_t hal_uart_recv_II(uart_dev_t *uart,void *data,uint32_t expect_size,uint32_t *recv_size, + uint32_t timeout) + +{ + uint32_t uVar1; + int iVar2; + + uVar1 = 0; + while (uVar1 != expect_size) { + iVar2 = bl_uart_data_recv(uart->port); + if (iVar2 < 0) break; + *(undefined *)((int)data + uVar1) = (char)iVar2; + uVar1 = uVar1 + 1; + } + *recv_size = uVar1; + return 0; +} + + + +int32_t hal_uart_send(uart_dev_t *uart,void *data,uint32_t size,uint32_t timeout) + +{ + uint8_t data_00; + uint8_t *puVar1; + + puVar1 = (uint8_t *)((int)data + size); + while ((uint8_t *)data != puVar1) { + data_00 = *(uint8_t *)data; + data = (uint8_t *)data + 1; + bl_uart_data_send(uart->port,data_00); + } + return 0; +} + + + +int32_t hal_uart_finalize(uart_dev_t *uart) + +{ + aos_mutex_t *mutex; + + mutex = (aos_mutex_t *)uart->priv; + bl_uart_int_disable(uart->port); + aos_mutex_free(mutex); + return 0; +} + + + +int32_t hal_uart_notify_register(uart_dev_t *uart,hal_uart_int_t type,anon_subr_void_void_ptr *cb) + +{ + undefined3 in_register_0000202d; + + if (CONCAT31(in_register_0000202d,type) == 0) { + bl_uart_int_tx_notify_register(uart->port,(cb_uart_notify_t *)cb,uart); + } + else { + if (CONCAT31(in_register_0000202d,type) != 1) { + return -1; + } + bl_uart_int_rx_notify_register(uart->port,(cb_uart_notify_t *)cb,uart); + } + return 0; +} + + + +undefined4 vfs_uart_init(void *param_1,int param_2) + +{ + int nodeoffset; + char *property; + int nodeoffset_00; + TickType_t TVar1; + fdt32_t *pfVar2; + uint32_t baudrate; + uint32_t uVar3; + int iVar4; + char *__s2; + uint32_t uVar5; + undefined4 uVar6; + int iVar7; + char *name; + fdt32_t x; + fdt32_t x_00; + char **ppcVar8; + uint32_t rx_buf_size; + uint32_t tx_buf_size; + fdt32_t x_01; + uint8_t uStack152; + char **ppcStack148; + uint local_7c; + char *pcStack120; + char *pcStack116; + char *local_70; + undefined4 uStack108; + byte bStack104; + uint8_t uStack92; + uint8_t uStack80; + uint8_t uStack68; + char *apcStack64 [3]; + + if (inited == '\x01') { + return 0; + } + pcStack120 = "uart@4000A000"; + pcStack116 = "uart@4000A100"; + local_7c = 0; + memcpy(&local_70,&PTR_DAT_23079448,0x30); + ppcStack148 = &pcStack120; + iVar7 = 0; + do { + name = *ppcStack148; + nodeoffset = fdt_subnode_offset(param_1,param_2,name); + if (nodeoffset < 1) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 300; + goto LAB_2303747e; + } + } + else { + name = (char *)fdt_stringlist_count(param_1,nodeoffset,"status"); + if (name == (char *)0x1) { + name = fdt_stringlist_get(param_1,nodeoffset,"status",0,(int *)&local_7c); + if ((local_7c == 4) && (nodeoffset_00 = memcmp(&DAT_2307958c,name,4), nodeoffset_00 == 0)) { + name = (char *)fdt_stringlist_count(param_1,nodeoffset,"path"); + if (name == (char *)0x1) { + name = fdt_stringlist_get(param_1,nodeoffset,"path",0,(int *)&local_7c); + if (((0x20 < local_7c) && (_fsymc_level_hal_drv < BLOG_LEVEL_WARN)) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] path lentmp = %d\r\n",TVar1,&DAT_2306e4ac, + "hal_uart.c",0x144,iVar7,local_7c); + } + pfVar2 = (fdt32_t *)fdt_getprop(param_1,nodeoffset,"baudrate",(int *)&local_7c); + if (pfVar2 == (fdt32_t *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x14b; + name = "[%10u][%s: %s:%4d] uart[%d] baudrate NULL.\r\n"; +LAB_230376aa: + bl_printk(name,&DAT_2306e4ac,"hal_uart.c",uVar6,iVar7); + } + } + else { + x_00 = *pfVar2; + pfVar2 = (fdt32_t *)fdt_getprop(param_1,nodeoffset,"id",(int *)&local_7c); + if (pfVar2 == (fdt32_t *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x153; + name = "[%10u][%s: %s:%4d] uart[%d] id NULL.\r\n"; + goto LAB_230376aa; + } + } + else { + x = *pfVar2; + nodeoffset_00 = fdt_subnode_offset(param_1,nodeoffset,"buf_size"); + if (nodeoffset_00 < 1) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] buf_size NULL, will use default.\r\n", + TVar1,&DAT_2306e4ac,"hal_uart.c",0x15b,iVar7); + } + tx_buf_size = 0x200; + rx_buf_size = 0x200; +LAB_2303782e: + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] rx_buf_size %d, tx_buf_size %d\r\n",TVar1 + ,&DAT_2306e4ac,"hal_uart.c",0x16c,iVar7,rx_buf_size,tx_buf_size); + } + baudrate = fdt32_to_cpu(x_00); + uVar3 = fdt32_to_cpu(x); + ppcVar8 = &local_70; + do { + nodeoffset_00 = fdt_subnode_offset(param_1,nodeoffset,"feature"); + if (nodeoffset_00 < 1) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] feature NULL.\r\n",TVar1, + &DAT_2306e4ac,"hal_uart.c",0x171,iVar7); + } + } + else { + property = *ppcVar8; + iVar4 = fdt_stringlist_count(param_1,nodeoffset_00,property); + if (iVar4 == 1) { + __s2 = fdt_stringlist_get(param_1,nodeoffset_00,property,0,(int *)&local_7c) + ; + if ((local_7c == 4) && + (nodeoffset_00 = memcmp(&DAT_2307958c,__s2,4), nodeoffset_00 == 0)) { + nodeoffset_00 = fdt_subnode_offset(param_1,nodeoffset,"pin"); + if (nodeoffset_00 < 1) { + if ((BLOG_LEVEL_INFO < _fsymc_level_hal_drv) || + (BLOG_LEVEL_INFO < _fsymf_level_hal_drvhal_uart)) goto LAB_230379e8; + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] pin NULL.\r\n",TVar1, + &DAT_2306e4ac,"hal_uart.c",0x182,iVar7); + break; + } + property = ppcVar8[1]; + pfVar2 = (fdt32_t *) + fdt_getprop(param_1,nodeoffset_00,property,(int *)&local_7c); + if (pfVar2 == (fdt32_t *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] %s NULL.\r\n",TVar1, + &DAT_2306e4ac,"hal_uart.c",0x187,iVar7,property); + } + } + else { + uVar5 = fdt32_to_cpu(*pfVar2); + *(char *)(ppcVar8 + 2) = (char)uVar5; + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] %s status = %s lentmp = %d\r\n", + TVar1,&DAT_2306e4ac,"hal_uart.c",0x17b,iVar7,property,__s2); + } + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] uart[%d] %s countindex = %d.\r\n",TVar1, + &DAT_2306e4ac,"hal_uart.c",0x176,iVar7,property,iVar4); + } + } + } + ppcVar8 = ppcVar8 + 3; + } while (apcStack64 != ppcVar8); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] id = %d, %s = %d, %s = %d, %s = %d, %s = %d baudrate = %ld.\r\n" + ,TVar1,&DAT_2306e4ac,"hal_uart.c",0x192,uVar3 & 0xff,uStack108, + (uint)bStack104); + } +LAB_230379e8: + uStack152 = (uint8_t)uVar3; + bl_uart_flush(uStack152); + bl_uart_init(uStack152,bStack104,uStack92,uStack80,uStack68,baudrate); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] bl_uart_init %d ok.\r\n",TVar1,&DAT_2306e4ac, + "hal_uart.c",0x19a,uVar3 & 0xff); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] bl_uart_init %d baudrate = %ld ok.\r\n",TVar1, + &DAT_2306e4ac,"hal_uart.c",0x19b,uVar3 & 0xff,baudrate); + } + } + nodeoffset = dev_uart_init(uStack152,name,rx_buf_size,tx_buf_size); + if (((nodeoffset != 0) && (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] dev_uart_init err.\r\n",&DAT_23078e4c,"hal_uart.c" + ,0x19e); + } + } + else { + pfVar2 = (fdt32_t *)fdt_getprop(param_1,nodeoffset_00,"rx_size",(int *)&local_7c); + if (pfVar2 == (fdt32_t *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + name = "rx_size"; + uVar6 = 0x161; +LAB_2303747e: + property = "[%10u][%s: %s:%4d] uart[%d] %s NULL.\r\n"; + goto LAB_230374f2; + } + } + else { + x_01 = *pfVar2; + pfVar2 = (fdt32_t *) + fdt_getprop(param_1,nodeoffset_00,"tx_size",(int *)&local_7c); + if (pfVar2 != (fdt32_t *)0x0) { + rx_buf_size = fdt32_to_cpu(x_01); + tx_buf_size = fdt32_to_cpu(*pfVar2); + goto LAB_2303782e; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + name = "tx_size"; + uVar6 = 0x167; + goto LAB_2303747e; + } + } + } + } + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x13e; + property = "[%10u][%s: %s:%4d] uart[%d] path_countindex = %d NULL.\r\n"; + goto LAB_230374f2; + } + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x137; + property = "[%10u][%s: %s:%4d] uart[%d] status = %s\r\n"; + goto LAB_230374f2; + } + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_uart < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x132; + property = "[%10u][%s: %s:%4d] uart[%d] status_countindex = %d NULL.\r\n"; +LAB_230374f2: + bl_printk(property,&DAT_2306e4ac,"hal_uart.c",uVar6,iVar7,name); + } + } + } + ppcStack148 = ppcStack148 + 1; + if (iVar7 != 0) { + inited = (int8_t)iVar7; + return 0; + } + iVar7 = 1; + } while( true ); +} + + + +int32_t hal_uart_send_flush(uart_dev_t *uart,uint32_t timeout) + +{ + bl_uart_flush(uart->port); + return 0; +} + + + +void hal_uart_setbaud(uart_dev_t *uart,uint32_t baud) + +{ + bl_uart_setbaud(uart->port,baud); + return; +} + + + +void hal_uart_setconfig(uart_dev_t *uart,uint32_t baud,hal_uart_parity_t parity) + +{ + bl_uart_setconfig(uart->port,baud,parity); + return; +} + + + +undefined4 hal_gpio_init_from_dts(void *param_1,int param_2) + +{ + uint uVar1; + uint *puVar2; + int nodeoffset; + char *format; + TickType_t TVar3; + int iVar4; + char *format_00; + undefined *puVar5; + undefined4 uVar6; + uint uVar7; + int iVar8; + int local_5c; + char acStack88 [11]; + undefined uStack77; + uint uStack76; + char cStack72; + byte bStack71; + byte bStack70; + undefined uStack69; + uint uStack68; + + uStack76 = 0; + puVar2 = (uint *)fdt_getprop(param_1,param_2,"max_num",(int *)&uStack76); + uVar1 = 0xffffffff; + if (puVar2 != (uint *)0x0) { + uVar1 = *puVar2; + uVar1 = uVar1 << 0x18 | uVar1 >> 0x18 | (uVar1 >> 8 & 0xff) << 0x10 | + (uVar1 >> 0x10 & 0xff) << 8; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvhal_gpio < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [HAL] [GPIO] Max num is %d\r\n",&DAT_2306e4ac,"hal_gpio.c",0xb5, + uVar1); + } + iVar8 = 0; + do { + if ((int)uVar1 <= iVar8) { + return 0; + } + snprintf(acStack88,0xb,"gpio%u",iVar8); + uStack77 = 0; + local_5c = 0; + nodeoffset = fdt_subnode_offset(param_1,param_2,acStack88); + if (nodeoffset < 0) { + if (BLOG_LEVEL_INFO < _fsymc_level_hal_drv) { + return 0; + } + if (BLOG_LEVEL_INFO < _fsymf_level_hal_drvhal_gpio) { + return 0; + } + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %s NOT found\r\n",&DAT_2306e4ac,"hal_gpio.c",0x61,acStack88); + return 0; + } + memset(&uStack76,0,0xc); + cStack72 = '\0'; + format = fdt_stringlist_get(param_1,nodeoffset,"status",0,&local_5c); + if ((local_5c == 4) && (iVar4 = memcmp(&DAT_2307958c,format,4), iVar4 == 0)) { + puVar2 = (uint *)fdt_getprop(param_1,nodeoffset,"pin",&local_5c); + if (puVar2 == (uint *)0x0) { + if ((BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) || + (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_gpio)) goto LAB_23037dae; + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x70; + format = "[%10u][%s: %s:%4d] no pin found for %s\r\n"; +LAB_23037e6c: + bl_printk(format,&DAT_23078e4c,"hal_gpio.c",uVar6,acStack88); + } + else { + uVar7 = *puVar2; + uStack76 = (uVar7 >> 0x10 & 0xff) << 8 | + uVar7 << 0x18 | uVar7 >> 0x18 | (uVar7 >> 8 & 0xff) << 0x10; + format = fdt_stringlist_get(param_1,nodeoffset,"feature",0,&local_5c); + if ((local_5c != 3) || (iVar4 = memcmp("led",format,3), iVar4 != 0)) { + if ((BLOG_LEVEL_ERROR < _fsymc_level_hal_drv) || + (BLOG_LEVEL_ERROR < _fsymf_level_hal_drvhal_gpio)) goto LAB_23037dae; + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x79; +LAB_23037fee: + puVar5 = &DAT_23078e4c; + format_00 = "[%10u][%s: %s:%4d] %s: unvalid GPIO config %3s\r\n"; + goto LAB_23037ea2; + } + bStack71 = 0; + format = fdt_stringlist_get(param_1,nodeoffset,"active",0,&local_5c); + if (local_5c == 2) { + iVar4 = memcmp(&DAT_230799e8,format,2); + if (iVar4 == 0) { + bStack70 = 1; + } + else { + if ((local_5c != 2) || (iVar4 = memcmp(&DAT_230799ec,format,2), iVar4 != 0)) + goto LAB_2303802a; + bStack70 = 0; + } + format = fdt_stringlist_get(param_1,nodeoffset,"mode",0,&local_5c); + if ((local_5c == 5) && (iVar4 = memcmp("blink",format,5), iVar4 == 0)) { + uStack69 = 0; + } + else { + if ((local_5c != 9) || (iVar4 = memcmp("heartbeat",format,9), iVar4 != 0)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_gpio < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x8d; + goto LAB_23037fee; + } + goto LAB_23037dae; + } + uStack69 = 1; + } + puVar2 = (uint *)fdt_getprop(param_1,nodeoffset,"time",&local_5c); + if (puVar2 == (uint *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_gpio < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x93; + format = "[%10u][%s: %s:%4d] %s: unvalid GPIO config\r\n"; + goto LAB_23037e6c; + } + } + else { + uVar7 = *puVar2; + uStack68 = (uVar7 >> 0x10 & 0xff) << 8 | + uVar7 << 0x18 | uVar7 >> 0x18 | (uVar7 >> 8 & 0xff) << 0x10; + cStack72 = '\x01'; + } + } + else { +LAB_2303802a: + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_gpio < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x83; + goto LAB_23037fee; + } + } + } + } + else { + if ((BLOG_LEVEL_INFO < _fsymc_level_hal_drv) || + (BLOG_LEVEL_INFO < _fsymf_level_hal_drvhal_gpio)) goto LAB_23037dae; + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + uVar6 = 0x6a; + puVar5 = &DAT_2306e4ac; + format_00 = "[%10u][%s: %s:%4d] [%s] status = %s\r\n"; +LAB_23037ea2: + bl_printk(format_00,puVar5,"hal_gpio.c",uVar6,acStack88,format); + } +LAB_23037dae: + if (cStack72 == '\x01') { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_gpio < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] New CONF: GPIO%02u: feature %u, active %u, mode %u, time %u\r\n" + ,TVar3,&DAT_2306e4ac,"hal_gpio.c",0xa6,uStack76,(uint)bStack71,(uint)bStack70); + } + loopset_led_trigger(uStack76,uStack68); + } + else { + if (((cStack72 == '\0') && (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvhal_gpio < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] %s: unvalid GPIO config\r\n",&DAT_23078e4c,"hal_gpio.c",0xc3, + acStack88); + } + } + iVar8 = iVar8 + 1; + } while( true ); +} + + + +int hal_reboot(void) + +{ + GLB_SW_POR_Reset(); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void hal_sys_reset(void) + +{ + GLB_SW_System_Reset(); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void hal_poweroff(void) + +{ + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_sys_capcode_update(uint8_t capin,uint8_t capout) + +{ + uint8_t capin_static; + uint8_t capout_static; + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + + if ((CONCAT31(in_register_00002029,capin) != 0xff) && + (CONCAT31(in_register_0000202d,capout) != 0xff)) { + (*_DAT_2101081c)(); + return; + } + // WARNING: Could not recover jumptable at 0x2303818e. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_2101081c)((uint)capin_static,(uint)capout_static); + return; +} + + + +uint8_t hal_sys_capcode_get(void) + +{ + uint8_t uVar1; + + uVar1 = AON_Get_Xtal_CapCode(); + return uVar1; +} + + + +uint32_t fdt32_to_cpu(fdt32_t x) + +{ + return (x >> 0x10 & 0xff) << 8 | x << 0x18 | x >> 0x18 | (x >> 8 & 0xff) << 0x10; +} + + + +uint32_t hal_board_get_factory_addr(void) + +{ + return factory_addr; +} + + + +// WARNING: Could not reconcile some variable overlaps + +undefined4 hal_board_cfg(void) + +{ + char cVar1; + byte bVar2; + uint32_t ble_tx_power; + int parentoffset; + TickType_t TVar3; + int nodeoffset; + int iVar4; + char *format; + size_t sVar5; + uint32_t uVar6; + uint32_t uVar7; + void *__src; + uint32_t autoconnect; + fdt32_t x; + int iVar8; + int iVar9; + char *pcVar10; + uint8_t chan; + undefined4 uVar11; + size_t *psVar12; + size_t *psVar13; + byte *pbVar14; + fdt32_t *pfVar15; + uint8_t capin; + uint8_t psk_len; + fdt32_t *pfVar16; + int iStack220; + byte local_c4 [4]; + uint32_t uStack192; + int iStack188; + size_t sStack184; + size_t local_b4; + size_t local_b0; + int8_t iStack170; + size_t local_a0 [3]; + size_t asStack146 [4]; + undefined4 local_80; + byte bStack124; + byte bStack123; + + parentoffset = hal_boot2_partition_addr_active("factory",&factory_addr,&uStack192); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [MAIN] [BOARD] [FLASH] addr from partition is %08x, ret is %d\r\n" + ,TVar3,&DAT_2306e4ac,"hal_board.c",0x376,factory_addr,parentoffset); + } + if (factory_addr == 0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] [MAIN] [BOARD] [FLASH] Dead loop. Reason: NO valid Param Parition found\r\n" + ,TVar3,&DAT_23078e4c,"hal_board.c",0x378); + } + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + parentoffset = hal_boot2_partition_bus_addr_active("factory",&factory_addr,&uStack192); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [MAIN] [BOARD] [XIP] addr from partition is %08x, ret is %d\r\n", + TVar3,&DAT_2306e4ac,"hal_board.c",0x37e,factory_addr,parentoffset); + } + ble_tx_power = factory_addr; + if (factory_addr == 0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] [MAIN] [BOARD] [XIP] Dead loop. Reason: NO valid Param Parition found\r\n" + ,TVar3,&DAT_23078e4c,"hal_board.c",0x380); + } + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + iStack188 = 0; + parentoffset = fdt_subnode_offset((void *)factory_addr,0,"wifi"); + if (((parentoffset < 1) && (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] wifi NULL.\r\n",TVar3,&DAT_23078e4c,"hal_board.c",0x242); + } + nodeoffset = fdt_subnode_offset((void *)ble_tx_power,parentoffset,"brd_rf"); + if (0 < nodeoffset) { + local_a0[0] = 0; + iVar4 = fdt_stringlist_count((void *)ble_tx_power,nodeoffset,"xtal_mode"); + if (iVar4 == 1) { + format = fdt_stringlist_get((void *)ble_tx_power,nodeoffset,"xtal_mode",0,(int *)local_a0); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] xtal_mode length %d\r\n",TVar3,&DAT_2306e4ac,"hal_board.c", + 0x141,local_a0[0]); + } + if ((int)local_a0[0] < 3) { + memcpy(&local_b0,format,local_a0[0]); + local_b0 = local_b0 & 0xff00ffff; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] xtal_mode is %s\r\n",TVar3,&DAT_2306e4ac,"hal_board.c",0x145 + ,&local_b0); + } + sVar5 = strlen((char *)&local_b0); + iVar4 = 0; + while (iVar4 < (int)sVar5) { + if (*(char *)((int)&local_b0 + iVar4) == 'F') { + local_80 = 0; + pfVar15 = (fdt32_t *)fdt_getprop((void *)ble_tx_power,nodeoffset,"xtal",&local_80); + if (local_80 == 0x14) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + autoconnect = fdt32_to_cpu(*pfVar15); + uVar6 = fdt32_to_cpu(pfVar15[1]); + uVar7 = fdt32_to_cpu(pfVar15[2]); + fdt32_to_cpu(pfVar15[3]); + fdt32_to_cpu(pfVar15[4]); + bl_printk("[%10u][%s: %s:%4d] xtal dtb in DEC :%u %u %u %u %u\r\n",TVar3, + &DAT_2306e4ac,"hal_board.c",0xf9,autoconnect & 0xff,uVar6 & 0xff, + uVar7 & 0xff); + } + autoconnect = fdt32_to_cpu(*pfVar15); + capin = (uint8_t)autoconnect; + autoconnect = fdt32_to_cpu(pfVar15[1]); + local_80._0_1_ = (byte)autoconnect; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] get xtal from F ready\r\n",TVar3,"DEBUG ", + "hal_board.c",0x114); + } + goto LAB_2303863a; + } + if (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) { + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] xtal dtb NULL.",TVar3,&DAT_23078e4c,"hal_board.c", + 0x100); + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x117; + format = "[%10u][%s: %s:%4d] get xtal from F failed\r\n"; + goto LAB_230389a4; + } + } + } + else { + if (*(char *)((int)&local_b0 + iVar4) != 'M') { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ASSERT: %s:%d\r\n",TVar3,&UNK_2307261c,"hal_board.c", + 0x128,"hal_board.c",0x128); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + local_80 = local_80 & 0xffffff00; + iVar8 = bl_efuse_read_capcode((uint8_t *)&local_80); + if (iVar8 == 0) { + capin = (byte)local_80; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] get xtal from M ready\r\n",TVar3,"DEBUG ", + "hal_board.c",0x11f); + } + goto LAB_2303863a; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x122; + format = "[%10u][%s: %s:%4d] get xtal from M failed\r\n"; +LAB_230389a4: + bl_printk(format,TVar3,"DEBUG ","hal_board.c",uVar11); + } + } + iVar4 = iVar4 + 1; + if (iVar4 == 2) break; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Using Default xtal\r\n",TVar3,&DAT_2306e4ac,"hal_board.c", + 0x12e); + } + local_80._0_1_ = '2'; + capin = '2'; +LAB_2303863a: + hal_sys_capcode_update(capin,(byte)local_80); + } + } + __src = fdt_getprop((void *)ble_tx_power,nodeoffset,"channel_div_table",&iStack188); + if (iStack188 == 0x3c) { + iVar4 = 0; + do { + autoconnect = fdt32_to_cpu(*(fdt32_t *)((int)__src + iVar4)); + *(uint32_t *)((int)&local_80 + iVar4) = autoconnect; + iVar4 = iVar4 + 4; + } while (iVar4 != 0x3c); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] channel_div_table :\r\n",TVar3,&DAT_2306e4ac,"hal_board.c",600 + ); + } + log_buf_out("hal_board.c",0x259,&local_80,0x3c,LOG_BUF_OUT_DATA_TYPE_HEX); + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] channel_div_table NULL.\r\n",TVar3,&DAT_23078e4c,"hal_board.c" + ,0x25b); + } + } + pfVar15 = (fdt32_t *)fdt_getprop((void *)ble_tx_power,nodeoffset,"channel_cnt_table",&iStack188) + ; + if (iStack188 == 0x38) { + pfVar16 = pfVar15 + 0xe; + psVar12 = local_a0; + do { + x = *pfVar15; + pfVar15 = pfVar15 + 1; + autoconnect = fdt32_to_cpu(x); + *(short *)psVar12 = (short)autoconnect; + psVar12 = (size_t *)((int)psVar12 + 2); + } while (pfVar16 != pfVar15); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] channel_cnt_table :\r\n",TVar3,&DAT_2306e4ac,"hal_board.c", + 0x263); + } + log_buf_out("hal_board.c",0x264,local_a0,0x38,LOG_BUF_OUT_DATA_TYPE_HEX); + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] channel_cnt_table NULL.\r\n",TVar3,&DAT_23078e4c,"hal_board.c" + ,0x266); + } + } + pfVar15 = (fdt32_t *)fdt_getprop((void *)ble_tx_power,nodeoffset,"lo_fcal_div",&iStack188); + if (iStack188 == 4) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + x = *pfVar15; + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + autoconnect = fdt32_to_cpu(x); + bl_printk("[%10u][%s: %s:%4d] lo_fcal_div : %d\r\n",TVar3,&DAT_2306e4ac,"hal_board.c",0x26c, + autoconnect & 0xffff); + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] lo_fcal_div NULL.\r\n",TVar3,&DAT_23078e4c,"hal_board.c",0x26e + ); + } + } + } + nodeoffset = fdt_subnode_offset((void *)ble_tx_power,parentoffset,"mac"); + if (0 < nodeoffset) { + local_b4 = 0; + iVar4 = fdt_stringlist_count((void *)ble_tx_power,nodeoffset,"mode"); + if (iVar4 == 1) { + format = fdt_stringlist_get((void *)ble_tx_power,nodeoffset,"mode",0,(int *)&local_b4); + bl_printk("MAC address mode length %d\r\n",local_b4); + if ((int)local_b4 < 4) { + memcpy(&local_b0,format,local_b4); + local_b0 = local_b0 & 0xffffff; + bl_printk("MAC address mode is %s\r\n",&local_b0); + sVar5 = strlen((char *)&local_b0); + iVar4 = 0; + do { + if ((int)sVar5 <= iVar4) break; + cVar1 = *(char *)((int)&local_b0 + iVar4); + if (cVar1 == 'F') { + __src = fdt_getprop((void *)ble_tx_power,nodeoffset,"sta_mac_addr",(int *)local_a0); + if (local_a0[0] == 6) { + memcpy(&local_80,__src,6); + bl_wifi_sta_mac_addr_set((uint8_t *)&local_80); + __src = fdt_getprop((void *)ble_tx_power,nodeoffset,"ap_mac_addr",(int *)local_a0); + if (local_a0[0] == 6) { + memcpy(&local_80,__src,6); + bl_wifi_ap_mac_addr_set((uint8_t *)&local_80); + if (BLOG_LEVEL_DEBUG < _fsymc_level_hal_drv) goto LAB_23038bfe; + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x9b; + format = "[%10u][%s: %s:%4d] get MAC from F ready\r\n"; + goto LAB_23038bfa; + } + goto LAB_23038c08; + } + if (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) { + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x54; + iVar8 = -0x10; + goto LAB_23039138; + } + goto LAB_2303913c; + } + } + else { + if (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) { + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x47; + iVar8 = -0x38; +LAB_23039138: + bl_printk("[%10u][%s: %s:%4d] ap_mac_addr NULL.\r\n" + iVar8 + 0x10,TVar3, + &DAT_23078e4c,"hal_board.c",uVar11); + } +LAB_2303913c: + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x9e; + format = "[%10u][%s: %s:%4d] get MAC from F failed\r\n"; + goto LAB_2303890e; + } + } + } + } + else { + if (cVar1 == 'M') { + iVar8 = bl_efuse_read_mac_factory((uint8_t *)&local_80); + if (iVar8 == 0) { + if (((byte)(bStack123 | + bStack124 | + local_80._3_1_ | local_80._2_1_ | (byte)local_80 | local_80._1_1_) != 0) + && (((byte)local_80 & local_80._1_1_ & local_80._2_1_ & local_80._3_1_ & + bStack124 & bStack123) != 1)) { + if (BLOG_LEVEL_DEBUG < _fsymc_level_hal_drv) goto LAB_23038bfe; + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0xa6; + format = "[%10u][%s: %s:%4d] get MAC from M ready\r\n"; + goto LAB_23038bfa; + } + goto LAB_23038c08; + } + } + if ((BLOG_LEVEL_DEBUG < _fsymc_level_hal_drv) || + (BLOG_LEVEL_DEBUG < _fsymf_level_hal_drvhal_board)) goto LAB_23038912; + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0xa9; + format = "[%10u][%s: %s:%4d] get MAC from M failed\r\n"; + } + else { + if (cVar1 != 'B') { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ASSERT: %s:%d\r\n",TVar3,&UNK_2307261c,"hal_board.c", + 0xaf,"hal_board.c",0xaf); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + bl_efuse_read_mac((uint8_t *)&local_80); + if (((byte)(bStack123 | + bStack124 | + local_80._3_1_ | local_80._2_1_ | (byte)local_80 | local_80._1_1_) != 0) && + (((byte)local_80 & local_80._1_1_ & local_80._2_1_ & local_80._3_1_ & bStack124 & + bStack123) != 1)) { + if (BLOG_LEVEL_DEBUG < _fsymc_level_hal_drv) goto LAB_23038bfe; + if (BLOG_LEVEL_DEBUG < _fsymf_level_hal_drvhal_board) goto LAB_23038c08; + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x90; + format = "[%10u][%s: %s:%4d] get MAC from B ready\r\n"; +LAB_23038bfa: + bl_printk(format,TVar3,"DEBUG ","hal_board.c",uVar11); + goto LAB_23038bfe; + } + if ((BLOG_LEVEL_DEBUG < _fsymc_level_hal_drv) || + (BLOG_LEVEL_DEBUG < _fsymf_level_hal_drvhal_board)) goto LAB_23038912; + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x93; + format = "[%10u][%s: %s:%4d] get MAC from B failed\r\n"; + } +LAB_2303890e: + bl_printk(format,TVar3,"DEBUG ","hal_board.c",uVar11); + } +LAB_23038912: + iVar4 = iVar4 + 1; + } while (iVar4 != 3); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Using Default MAC address\r\n",TVar3,&DAT_2306e4ac, + "hal_board.c",0xb5); + } + memcpy(&local_80,&mac_default_3792,6); +LAB_23038bfe: + if (_fsymc_level_hal_drv < BLOG_LEVEL_WARN) { +LAB_23038c08: + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Set MAC addrress %02X:%02X:%02X:%02X:%02X:%02X\r\n",TVar3, + &DAT_2306e4ac,"hal_board.c",0xc0,local_80 & 0xff,local_80 >> 8 & 0xff, + local_80 >> 0x10 & 0xff); + } + } + bl_wifi_ap_mac_addr_set((uint8_t *)&local_80); + bl_wifi_sta_mac_addr_set((uint8_t *)&local_80); + } + } + } + nodeoffset = fdt_subnode_offset((void *)ble_tx_power,parentoffset,"region"); + if (0 < nodeoffset) { + pfVar15 = (fdt32_t *)fdt_getprop((void *)ble_tx_power,nodeoffset,"country_code",&iStack188); + if (iStack188 == 4) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + autoconnect = fdt32_to_cpu(*pfVar15); + bl_printk("[%10u][%s: %s:%4d] country_code : %d\r\n",TVar3,&DAT_2306e4ac,"hal_board.c",0x27f + ,autoconnect & 0xff); + } + autoconnect = fdt32_to_cpu(*pfVar15); + bl_wifi_country_code_set((uint8_t)autoconnect); + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] country_code NULL.\r\n",TVar3,&DAT_23078e4c,"hal_board.c", + 0x283); + } + } + } + nodeoffset = fdt_subnode_offset((void *)ble_tx_power,parentoffset,"brd_rf"); + if (nodeoffset < 1) goto LAB_2303990c; + __src = fdt_getprop((void *)ble_tx_power,nodeoffset,"pwr_table_11b",&iStack188); + if (iStack188 == 0x10) { + iVar4 = 0; + do { + autoconnect = fdt32_to_cpu(*(fdt32_t *)(iVar4 * 4 + (int)__src)); + *(undefined *)((int)&local_80 + iVar4) = (char)autoconnect; + iVar4 = iVar4 + 1; + } while (iVar4 != 4); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table_11b :%u %u %u %u\r\n",TVar3,&DAT_2306e4ac, + "hal_board.c",0x298,local_80 & 0xff,local_80 >> 8 & 0xff,local_80 >> 0x10 & 0xff); + } + bl_tpc_update_power_rate_11b((int8_t *)&local_80); + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table_11b NULL. lentmp = %d\r\n",TVar3,&DAT_23078e4c, + "hal_board.c",0x29b,iStack188); + } + } + __src = fdt_getprop((void *)ble_tx_power,nodeoffset,"pwr_table_11g",&iStack188); + if (iStack188 == 0x20) { + iVar4 = 0; + do { + autoconnect = fdt32_to_cpu(*(fdt32_t *)(iVar4 * 4 + (int)__src)); + *(undefined *)((int)&local_80 + iVar4) = (char)autoconnect; + iVar4 = iVar4 + 1; + } while (iVar4 != 8); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table_11g :%u %u %u %u %u %u %u %u\r\n",TVar3,&DAT_2306e4ac, + "hal_board.c",0x2ac,local_80 & 0xff,local_80 >> 8 & 0xff,local_80 >> 0x10 & 0xff); + } + bl_tpc_update_power_rate_11g((int8_t *)&local_80); + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table_11g NULL. lentmp = %d\r\n",TVar3,&DAT_23078e4c, + "hal_board.c",0x2af,iStack188); + } + } + __src = fdt_getprop((void *)ble_tx_power,nodeoffset,"pwr_table_11n",&iStack188); + if (iStack188 == 0x20) { + iVar4 = 0; + do { + autoconnect = fdt32_to_cpu(*(fdt32_t *)(iVar4 * 4 + (int)__src)); + *(undefined *)((int)&local_80 + iVar4) = (char)autoconnect; + iVar4 = iVar4 + 1; + } while (iVar4 != 8); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table_11n :%u %u %u %u %u %u %u %u\r\n",TVar3,&DAT_2306e4ac, + "hal_board.c",0x2c0,local_80 & 0xff,local_80 >> 8 & 0xff,local_80 >> 0x10 & 0xff); + } + bl_tpc_update_power_rate_11n((int8_t *)&local_80); + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_table_11n NULL. lentmp = %d\r\n",TVar3,&DAT_23078e4c, + "hal_board.c",0x2c3,iStack188); + } + } + sStack184 = 0; + iVar4 = fdt_stringlist_count((void *)ble_tx_power,nodeoffset,"pwr_mode"); + if (iVar4 != 1) goto LAB_2303990c; + format = fdt_stringlist_get((void *)ble_tx_power,nodeoffset,"pwr_mode",0,(int *)&sStack184); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_mode length %d\r\n",TVar3,&DAT_2306e4ac,"hal_board.c",0x1c1, + sStack184); + } + if (2 < (int)sStack184) goto LAB_2303990c; + memcpy(local_c4,format,sStack184); + local_c4[2] = 0; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) + { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_mode is %s\r\n",TVar3,&DAT_2306e4ac,"hal_board.c",0x1c5, + local_c4); + } + memset(&local_b0,0,0xe); + memset(local_a0,0,0xe); + sVar5 = strlen((char *)local_c4); + pbVar14 = local_c4; + iStack220 = 0; + iVar8 = 0; + do { + if ((int)sVar5 <= iVar8) break; + bVar2 = *pbVar14; + if (bVar2 == 0x46) { +LAB_2303949e: + local_b4 = 0; + __src = fdt_getprop((void *)ble_tx_power,nodeoffset,"pwr_offset",(int *)&local_b4); + if (local_b4 != 0x38) { + if (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) { + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_offset NULL. lentmp = %d\r\n",TVar3,&DAT_23078e4c, + "hal_board.c",0x15f,local_b4); + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x1a0; + format = "[%10u][%s: %s:%4d] get pwr offset from F(f) failed\r\n"; + goto LAB_230397ec; + } + } + goto LAB_23039762; + } + nodeoffset = 0; + do { + autoconnect = fdt32_to_cpu(*(fdt32_t *)(nodeoffset * 4 + (int)__src)); + *(undefined *)((int)local_a0 + nodeoffset) = (char)autoconnect; + nodeoffset = nodeoffset + 1; + } while (nodeoffset != 0xe); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_offset from dtb:\r\n",TVar3,&DAT_2306e4ac,"hal_board.c", + 0x156); + } + log_buf_out("hal_board.c",0x157,local_a0,0xe,LOG_BUF_OUT_DATA_TYPE_HEX); + psVar12 = local_a0; + do { + psVar13 = (size_t *)((int)psVar12 + 1); + *(char *)psVar12 = *(char *)psVar12 + -10; + psVar12 = psVar13; + } while (asStack146 != psVar13); + if (_fsymc_level_hal_drv < BLOG_LEVEL_WARN) { + if (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] pwr_offset from dtb (rebase on %d):\r\n",TVar3,&DAT_2306e4ac + ,"hal_board.c",0x15b,10); + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] get pwr offset from F(f) ready\r\n",TVar3,"DEBUG ", + "hal_board.c",399); + } + } + if (*pbVar14 == 0x42) { + nodeoffset = 0; + do { + *(undefined *)((int)&local_b0 + nodeoffset) = *(undefined *)((int)local_a0 + nodeoffset); + nodeoffset = nodeoffset + 1; + } while (nodeoffset != 0xe); + if ((BLOG_LEVEL_DEBUG < _fsymc_level_hal_drv) || + (BLOG_LEVEL_DEBUG < _fsymf_level_hal_drvhal_board)) goto LAB_230398e8; + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x195; + pcVar10 = "DEBUG "; + format = "[%10u][%s: %s:%4d] Use pwr offset from F only\r\n"; + goto LAB_230396fa; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Use pwr offset from f in incremental mode\r\n",TVar3,"DEBUG ", + "hal_board.c",0x199); + } + nodeoffset = 0; + psVar12 = &local_b0; + do { + format = (char *)((int)local_a0 + nodeoffset); + nodeoffset = nodeoffset + 1; + *(char *)psVar12 = *format + *(char *)psVar12; + psVar12 = (size_t *)((int)psVar12 + 1); + } while (nodeoffset != 0xe); + goto LAB_230398e8; + } + if (bVar2 < 0x47) { + if (bVar2 != 0x42) { +LAB_23039042: + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ASSERT: %s:%d\r\n",TVar3,&UNK_2307261c,"hal_board.c",0x1a6, + "hal_board.c",0x1a6); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + } + else { + if (bVar2 != 0x62) { + if (bVar2 != 0x66) goto LAB_23039042; + goto LAB_2303949e; + } + } + iVar9 = bl_efuse_read_pwroft((int8_t *)local_a0); + if (iVar9 != 0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x186; + format = "[%10u][%s: %s:%4d] get pwr offset from B(b) failed\r\n"; +LAB_230397ec: + bl_printk(format,TVar3,"DEBUG ","hal_board.c",uVar11); + } + goto LAB_23039762; + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] get pwr offset from B(b) ready\r\n",TVar3,&DAT_2306e4ac, + "hal_board.c",0x175); + } + log_buf_out("hal_board.c",0x176,local_a0,0xe,LOG_BUF_OUT_DATA_TYPE_INT8); + if (*pbVar14 == 0x42) goto LAB_230396a6; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Use pwr offset from b in incremental mode\r\n",TVar3,"DEBUG ", + "hal_board.c",0x180); + } + psVar12 = &local_b0; + do { + format = (char *)((int)local_a0 + iVar9); + iVar9 = iVar9 + 1; + *(char *)psVar12 = *format + *(char *)psVar12; + psVar12 = (size_t *)((int)psVar12 + 1); + iStack220 = iVar4; + } while (iVar9 != 0xe); +LAB_23039762: + iVar8 = iVar8 + 1; + pbVar14 = pbVar14 + 1; + } while (iVar8 != 2); + if (((iStack220 == 0) && (_fsymc_level_hal_drv < BLOG_LEVEL_WARN)) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x1ac; + pcVar10 = "\x1b[32mINFO \x1b[0m"; + format = "[%10u][%s: %s:%4d] Using Default pwr offset\r\n"; + goto LAB_230396fa; + } +LAB_230398e8: + log_buf_out("hal_board.c",0x1ae,&local_b0,0xe,LOG_BUF_OUT_DATA_TYPE_INT8); + ble_rf_set_pwr_offset(iStack170); + phy_powroffset_set((int8_t *)&local_b0); +LAB_2303990c: + local_b0 = 0; + nodeoffset = fdt_subnode_offset((void *)ble_tx_power,parentoffset,"ap"); + if (0 < nodeoffset) { + iVar4 = fdt_stringlist_count((void *)ble_tx_power,nodeoffset,"ssid"); + if ((iVar4 == 1) && + (format = fdt_stringlist_get((void *)ble_tx_power,nodeoffset,"ssid",0,(int *)&local_b0), + local_b0 - 1 < 0x1f)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ap_ssid string[%d] = %s, ap_ssid_len = %d\r\n",TVar3, + &DAT_2306e4ac,"hal_board.c",0x213,0,format,local_b0); + } + memcpy(local_a0,format,local_b0); + *(undefined *)((int)local_a0 + local_b0) = 0; + capin = (uint8_t)local_b0; + } + else { + capin = '\0'; + } + iVar4 = fdt_stringlist_count((void *)ble_tx_power,nodeoffset,"pwd"); + if ((iVar4 == 1) && + (format = fdt_stringlist_get((void *)ble_tx_power,nodeoffset,"pwd",0,(int *)&local_b0), + local_b0 - 1 < 0x1f)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ap_psk string[%d] = %s, ap_psk_len = %d\r\n",TVar3, + &DAT_2306e4ac,"hal_board.c",0x21e,0,format,local_b0); + } + memcpy(&local_80,format,local_b0); + *(undefined *)((int)&local_80 + local_b0) = 0; + psk_len = (uint8_t)local_b0; + } + else { + psk_len = '\0'; + } + pfVar15 = (fdt32_t *)fdt_getprop((void *)ble_tx_power,nodeoffset,"ap_channel",(int *)&local_b0); + if (pfVar15 == (fdt32_t *)0x0) { + chan = '\0'; + if ((_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT) && + (chan = '\0', _fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ap_channel NULL.\r\n",TVar3,&DAT_23078e4c,"hal_board.c",0x22b) + ; + chan = '\0'; + } + } + else { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + autoconnect = fdt32_to_cpu(*pfVar15); + bl_printk("[%10u][%s: %s:%4d] ap_channel = %ld\r\n",TVar3,&DAT_2306e4ac,"hal_board.c",0x227, + autoconnect); + } + autoconnect = fdt32_to_cpu(*pfVar15); + chan = (uint8_t)autoconnect; + } + bl_wifi_ap_info_set((uint8_t *)local_a0,capin,(uint8_t *)&local_80,psk_len,chan); + } + local_b0 = 0; + parentoffset = fdt_subnode_offset((void *)ble_tx_power,parentoffset,"sta"); + if (0 < parentoffset) { + nodeoffset = fdt_stringlist_count((void *)ble_tx_power,parentoffset,"ssid"); + if ((nodeoffset == 1) && + (format = fdt_stringlist_get((void *)ble_tx_power,parentoffset,"ssid",0,(int *)&local_b0), + local_b0 - 1 < 0x1f)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [STA] ap_ssid string[%d] = %s, ap_ssid_len = %d\r\n",TVar3, + &DAT_2306e4ac,"hal_board.c",0x1df,0,format,local_b0); + } + memcpy(local_a0,format,local_b0); + *(undefined *)((int)local_a0 + local_b0) = 0; + capin = (uint8_t)local_b0; + } + else { + capin = '\0'; + } + nodeoffset = fdt_stringlist_count((void *)ble_tx_power,parentoffset,"pwd"); + if ((nodeoffset == 1) && + (format = fdt_stringlist_get((void *)ble_tx_power,parentoffset,"pwd",0,(int *)&local_b0), + local_b0 - 1 < 0x1f)) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [STA] ap_psk string[%d] = %s, ap_psk_len = %d\r\n",TVar3, + &DAT_2306e4ac,"hal_board.c",0x1ea,0,format,local_b0); + } + memcpy(&local_80,format,local_b0); + *(undefined *)((int)&local_80 + local_b0) = 0; + psk_len = (uint8_t)local_b0; + } + else { + psk_len = '\0'; + } + pfVar15 = (fdt32_t *) + fdt_getprop((void *)ble_tx_power,parentoffset,"auto_connect_enable",(int *)&local_b0); + autoconnect = 0; + if (pfVar15 != (fdt32_t *)0x0) { + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + autoconnect = fdt32_to_cpu(*pfVar15); + bl_printk("[%10u][%s: %s:%4d] auto_connect_enable = %ld\r\n",TVar3,&DAT_2306e4ac, + "hal_board.c",0x1f2,autoconnect); + } + autoconnect = fdt32_to_cpu(*pfVar15); + } + bl_wifi_sta_info_set((uint8_t *)local_a0,capin,(uint8_t *)&local_80,psk_len,autoconnect); + } + parentoffset = fdt_subnode_offset((void *)ble_tx_power,0,"bluetooth"); + if (((parentoffset < 1) && (_fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] bt NULL.\r\n",TVar3,&DAT_23078e4c,"hal_board.c",0x2cd); + } + parentoffset = fdt_subnode_offset((void *)ble_tx_power,parentoffset,"brd_rf"); + if (0 < parentoffset) { + pfVar15 = (fdt32_t *)fdt_getprop((void *)ble_tx_power,parentoffset,"pwr_table_ble",&iStack188); + ble_tx_power = 0; + if (pfVar15 != (fdt32_t *)0x0) { + ble_tx_power = fdt32_to_cpu(*pfVar15); + } + if ((_fsymc_level_hal_drv < BLOG_LEVEL_WARN) && + (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] set pwr_table_ble = %ld in dts\r\n",&DAT_2306e4ac,"hal_board.c", + 0x2d9,ble_tx_power); + } + ble_controller_set_tx_pwr(ble_tx_power); + } + return 0; +LAB_230396a6: + do { + *(undefined *)((int)&local_b0 + iVar9) = *(undefined *)((int)local_a0 + iVar9); + iVar9 = iVar9 + 1; + } while (iVar9 != 0xe); + if ((_fsymc_level_hal_drv < BLOG_LEVEL_INFO) && (_fsymf_level_hal_drvhal_board < BLOG_LEVEL_INFO)) + { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar11 = 0x17c; + pcVar10 = "DEBUG "; + format = "[%10u][%s: %s:%4d] Use pwr offset from B only\r\n"; +LAB_230396fa: + bl_printk(format,TVar3,pcVar10,"hal_board.c",uVar11); + } + goto LAB_230398e8; +} + + + +// WARNING: Control flow encountered bad instruction data + +void bl_tsen_adc_get(void) + +{ + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +int hal_wifi_start_firmware_task(void) + +{ + StackType_t wifi_fw_stack [1536]; + StaticTask_t wifi_fw_task; + + xTaskCreateStatic(wifi_main,"fw",0x600,(void *)0x0,0x1e,(StackType_t *)&ram0x420132b4, + (StaticTask_t *)&ram0x42014ab4); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int bl_gpio_enable_output(uint8_t pin,uint8_t pullup,uint8_t pulldown) + +{ + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + uint8_t uStack24; + uint8_t uStack23; + uint8_t uStack22; + uint8_t uStack21; + GLB_GPIO_Cfg_Type cfg; + + cfg._0_2_ = 0x100; + uStack23 = '\v'; + uStack22 = '\x01'; + if (CONCAT31(in_register_0000202d,pullup) == 0) { + uStack21 = '\x02'; + } + else { + uStack21 = '\0'; + } + if (CONCAT31(in_register_00002031,pulldown) != 0) { + uStack21 = '\x01'; + } + uStack24 = pin; + GLB_GPIO_Init((GLB_GPIO_Cfg_Type *)&uStack24); + return 0; +} + + + +int bl_gpio_output_set(uint8_t pin,uint8_t value) + +{ + undefined3 in_register_0000202d; + + GLB_GPIO_Write(pin,(uint)(CONCAT31(in_register_0000202d,value) != 0)); + return 0; +} + + + +void proc_entry_looprt(void *pvParameters) + +{ + bloop_run(&looprt); + do { + puts("--->>> Error terminated looprt\r\n"); + vTaskDelay(1000); + } while( true ); +} + + + +void looprt_evt_notify_async(uint task,uint32_t evt_map) + +{ + bloop_evt_set_async(&looprt,task,evt_map); + return; +} + + + +void looprt_evt_status_dump(void) + +{ + bloop_status_dump(&looprt); + return; +} + + + +int looprt_start(StackType_t *proc_stack_looprt,int stack_count,StaticTask_t *proc_task_looprt) + +{ + bloop_init(&looprt); + bloop_handler_register(&looprt,&bloop_handler_sys,0x1f); + looprt_evt_status_dump(); + xTaskCreateStatic(proc_entry_looprt,"bloop_rt",stack_count,(void *)0x0,0x1a,proc_stack_looprt, + proc_task_looprt); + bloop_wait_startup(&looprt); + return 0; +} + + + +int looprt_handler_register(loop_evt_handler *handler,int priority) + +{ + int iVar1; + + if (looprt.looper != (TaskHandle_t)0x0) { + iVar1 = bloop_handler_register(&looprt,handler,priority); + return iVar1; + } + return -1; +} + + + +int looprt_timer_register(loop_timer *timer) + +{ + bloop_timer_register(&looprt,timer); + return 0; +} + + + +void _cb_led_trigger(loop_ctx *loop,loop_timer *timer,void *arg) + +{ + TickType_t TVar1; + undefined *puVar2; + + bl_gpio_output_set(*(uint8_t *)((int)arg + 0x30),*(int *)((int)arg + 0x38) != 0); + if ((_fsymc_level_loopset < BLOG_LEVEL_INFO) && + (_fsymf_level_loopsetloopset_led < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + if (*(int *)((int)arg + 0x38) == 0) { + puVar2 = &DAT_230799ec; + } + else { + puVar2 = &DAT_230799e8; + } + bl_printk("[%10u][%s: %s:%4d] [LED] [CB] Set pin %d to %s\r\n",TVar1,"DEBUG ","loopset_led.c", + 0x95,*(undefined4 *)((int)arg + 0x30),puVar2); + } + *(uint *)((int)arg + 0x38) = (uint)(*(int *)((int)arg + 0x38) == 0); + return; +} + + + +int _led_bloop_msg(loop_ctx *loop,loop_evt_handler *handler,loop_msg *msg) + +{ + TickType_t TVar1; + + if ((_fsymc_level_loopset < BLOG_LEVEL_INFO) && + (_fsymf_level_loopsetloopset_led < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar1 = xTaskGetTickCount(); + } + else { + TVar1 = xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] [LED] [MSG] called with msg info\r\n priority %u\r\n dst %u\r\n msgid %u\r\n src %u\r\n arg1 %p\r\n arg2 %p\r\n" + ,TVar1,"DEBUG ","loopset_led.c",0x78,(uint)*(byte *)&msg->u, + (uint)*(byte *)((int)&msg->u + 1),(uint)*(byte *)((int)&msg->u + 2)); + return 0; + } + return 0; +} + + + +int _led_bloop_evt(loop_ctx *loop,loop_evt_handler *handler,uint32_t *bitmap_evt, + uint32_t *evt_type_map) + +{ + char **ppcVar1; + uint uVar2; + TickType_t TVar3; + char *pcVar4; + undefined *puVar5; + char *pcVar6; + char **ppcVar7; + char **ppcVar8; + + uVar2 = *evt_type_map; + do { + if ((uVar2 & 1) == 0) { + if ((uVar2 & 2) == 0) { + if (uVar2 != 0) { + printf("[ASSERT] [ERR] %s:%d\r\n","loopset_led.c",0x5e); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + break; + } + pcVar6 = handler[1].name; + ppcVar7 = (char **)0x0; + ppcVar1 = *(char ***)(pcVar6 + 0xc); + if (ppcVar1 != (char **)0x0) { + ppcVar7 = (char **)ppcVar1[1]; + } + while (ppcVar8 = ppcVar7, ppcVar1 != (char **)(pcVar6 + 8)) { + if ((_fsymc_level_loopset < BLOG_LEVEL_WARN) && + (_fsymf_level_loopsetloopset_led < BLOG_LEVEL_WARN)) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(loop); + } + puVar5 = &DAT_230799e8; + if (ppcVar1[0xd] == (char *)0x0) { + puVar5 = &DAT_230799ec; + } + pcVar4 = "Hearbeat"; + if (ppcVar1[0xb] == (char *)0x0) { + pcVar4 = "Blink"; + } + bl_printk("[%10u][%s: %s:%4d] [LED] New Trigger: PIN %d, active level %s, type %s\r\n", + TVar3,&DAT_2306e4ac,"loopset_led.c",0x4b,ppcVar1[0xc],puVar5,pcVar4); + } + loop = (loop_ctx *)looprt_timer_register((loop_timer *)(ppcVar1 + 2)); + ppcVar7 = (char **)ppcVar1[1]; + pcVar4 = *ppcVar1; + *(char ***)(pcVar4 + 4) = ppcVar7; + *ppcVar7 = pcVar4; + ppcVar7 = *(char ***)(pcVar6 + 4); + *ppcVar1 = pcVar6; + *(char ***)(ppcVar1 + 1) = ppcVar7; + *(char ***)(pcVar6 + 4) = ppcVar1; + *(char ***)ppcVar7 = ppcVar1; + ppcVar1 = ppcVar8; + ppcVar7 = (char **)0x0; + if (ppcVar8 != (char **)0x0) { + ppcVar7 = (char **)ppcVar8[1]; + } + } + uVar2 = uVar2 & 0xfffffffd; + } + else { + uVar2 = uVar2 & 0xfffffffe; + } + } while (uVar2 != 0); + *evt_type_map = 0; + return 0; +} + + + +int loopset_led_hook_on_looprt(void) + +{ + loop_evt_handler_holder _led_bloop_handler_holder; + int iVar1; + + led_ctx.trigger_queue.next = &led_ctx; + led_ctx.trigger_queue.prev = &led_ctx; + led_ctx.waiting_queue.next = (utils_dlist_s *)&led_ctx.waiting_queue; + led_ctx.waiting_queue.prev = (utils_dlist_s *)&led_ctx.waiting_queue; + iVar1 = looprt_handler_register((loop_evt_handler *)(loop_evt_handler_holder *)&ram0x2307aa38,1); + return iVar1; +} + + + +void loopset_led_trigger(int pin,uint timeon_ms) + +{ + utils_dlist_s **ppuVar1; + loop_timer *timer; + utils_dlist_s *__s; + TickType_t TVar2; + + __s = (utils_dlist_s *)pvPortMalloc(0x3c); + if (__s == (utils_dlist_s *)0x0) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] ASSERT: %s:%d\r\n",TVar2,&UNK_2307261c,"loopset_led.c",0x9e, + "loopset_led.c",0x9e); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + memset(__s,0,0x3c); + timer = (loop_timer *)(__s + 1); + *(int *)&__s[6].prev = pin; + bloop_timer_init(timer,0); + bloop_timer_repeat_enable(timer); + bloop_timer_configure(timer,timeon_ms,_cb_led_trigger,__s,1,1); + bl_gpio_enable_output((uint8_t)pin,'\0','\0'); + vTaskEnterCritical(); + __s->prev = (utils_dlist_s *)0x42014fbc; + __s->next = led_ctx.waiting_queue.next; + ppuVar1 = &(led_ctx.waiting_queue.next)->prev; + led_ctx.waiting_queue.next = __s; + *ppuVar1 = __s; + vTaskExitCritical(); + looprt_evt_notify_async(1,2); + return; +} + + + +err_t netifapi_do_netif_add(tcpip_api_call_data *m) + +{ + err_t eVar1; + netif *pnVar2; + + pnVar2 = netif_add(*(netif **)(m + 1),(ip4_addr_t *)m[1].sem,*(ip4_addr_t **)(m + 2), + (ip4_addr_t *)m[2].sem,*(void **)(m + 3),(netif_init_fn_conflict *)m[3].sem, + *(netif_input_fn **)(m + 4)); + if (pnVar2 == (netif *)0x0) { + eVar1 = -0xc; + } + else { + eVar1 = '\0'; + } + return eVar1; +} + + + +err_t netifapi_do_netif_set_addr(tcpip_api_call_data *m) + +{ + netif_set_addr(*(netif **)(m + 1),(ip4_addr_t *)m[1].sem,*(ip4_addr_t **)(m + 2), + (ip4_addr_t *)m[2].sem); + return '\0'; +} + + + +err_t netifapi_do_netif_common(tcpip_api_call_data *m) + +{ + err_t eVar1; + + if (*(code **)(m + 2) != (code *)0x0) { + // WARNING: Could not recover jumptable at 0x2303a45c. Too many branches + // WARNING: Treating indirect jump as call + eVar1 = (**(code **)(m + 2))(); + return eVar1; + } + (*(code *)m[1].sem)(*(undefined4 *)(m + 1),m[1].sem); + return '\0'; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netifapi_netif_add(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw, + void *state,netif_init_fn init,netif_input_fn *input) + +{ + err_t eVar1; + undefined auStack52 [4]; + netifapi_msg msg; + + if (ipaddr == (ip4_addr_t *)0x0) { + ipaddr = (ip4_addr_t *)&ip_addr_any; + } + if (netmask == (ip4_addr_t *)0x0) { + netmask = (ip4_addr_t *)&ip_addr_any; + } + if (gw == (ip4_addr_t *)0x0) { + gw = (ip4_addr_t *)&ip_addr_any; + } + msg.call.sem = (sys_sem_t)netif; + msg.netif = (netif *)ipaddr; + msg.msg._0_4_ = netmask; + msg.msg._4_4_ = gw; + msg.msg._8_4_ = state; + msg.msg._12_4_ = init; + msg.msg._16_4_ = input; + eVar1 = tcpip_api_call(netifapi_do_netif_add,(tcpip_api_call_data *)auStack52); + return eVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netifapi_netif_set_addr(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw) + +{ + err_t eVar1; + undefined auStack52 [4]; + netifapi_msg msg; + + if (ipaddr == (ip4_addr_t *)0x0) { + ipaddr = (ip4_addr_t *)&ip_addr_any; + } + if (netmask == (ip4_addr_t *)0x0) { + netmask = (ip4_addr_t *)&ip_addr_any; + } + if (gw == (ip4_addr_t *)0x0) { + gw = (ip4_addr_t *)&ip_addr_any; + } + msg.call.sem = (sys_sem_t)netif; + msg.netif = (netif *)ipaddr; + msg.msg._0_4_ = netmask; + msg.msg._4_4_ = gw; + eVar1 = tcpip_api_call(netifapi_do_netif_set_addr,(tcpip_api_call_data *)auStack52); + return eVar1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t netifapi_netif_common(netif *netif,netifapi_void_fn voidfunc,netifapi_errt_fn errtfunc) + +{ + err_t eVar1; + undefined auStack52 [4]; + netifapi_msg msg; + + msg.call.sem = (sys_sem_t)netif; + msg.netif = (netif *)voidfunc; + msg.msg._0_4_ = errtfunc; + eVar1 = tcpip_api_call(netifapi_do_netif_common,(tcpip_api_call_data *)auStack52); + return eVar1; +} + + + +void tcpip_thread(void *arg) + +{ + byte *mem; + undefined uVar1; + memp_t type; + u32_t timeout; + int iVar2; + undefined *puVar3; + byte *pbStack36; + tcpip_msg *msg; + + if (tcpip_init_done != (tcpip_init_done_fn)0x0) { + (*tcpip_init_done)(tcpip_init_done_arg); + } +switchD_2303a564_caseD_5: + do { + while (timeout = sys_timeouts_sleeptime(), timeout != 0xffffffff) { + if ((timeout != 0) && + (timeout = sys_arch_mbox_fetch(&tcpip_mbox,&pbStack36,timeout), timeout != 0xffffffff)) + goto LAB_2303a552; + sys_check_timeouts(); + } + sys_arch_mbox_fetch(&tcpip_mbox,&pbStack36,0); +LAB_2303a552: + mem = pbStack36; + } while (pbStack36 == (byte *)0x0); + switch(*pbStack36) { + case 0: + case 4: + (**(code **)(pbStack36 + 4))(*(undefined4 *)(pbStack36 + 8),*(code **)(pbStack36 + 4)); + goto switchD_2303a564_caseD_5; + case 1: + puVar3 = *(undefined **)(pbStack36 + 8); + uVar1 = (**(code **)(pbStack36 + 4))(puVar3,*(code **)(pbStack36 + 4)); + *puVar3 = uVar1; + sys_sem_signal((sys_mutex_t *)*(sys_mutex_t *)(mem + 0xc)); + goto switchD_2303a564_caseD_5; + case 2: + iVar2 = (**(code **)(pbStack36 + 0xc)) + (*(undefined4 *)(pbStack36 + 4),*(undefined4 *)(pbStack36 + 8), + *(code **)(pbStack36 + 0xc)); + if (iVar2 != 0) { + pbuf_free(*(pbuf **)(mem + 4)); + } + type = MEMP_TCPIP_MSG_INPKT; + break; + case 3: + (**(code **)(pbStack36 + 4))(*(undefined4 *)(pbStack36 + 8),*(code **)(pbStack36 + 4)); + type = MEMP_TCPIP_MSG_API; + break; + default: + goto switchD_2303a564_caseD_5; + } + memp_free(type,mem); + goto switchD_2303a564_caseD_5; +} + + + +err_t tcpip_inpkt(pbuf *p,netif *inp,netif_input_fn *input_fn) + +{ + err_t eVar1; + undefined *msg; + undefined3 extraout_var; + + sys_mbox_valid(&tcpip_mbox); + msg = (undefined *)memp_malloc(MEMP_TCPIP_MSG_INPKT); + if (msg == (undefined *)0x0) { + printf("[LWIP] NO TCP MSG\r\n"); + } + else { + *(netif **)(msg + 8) = inp; + *msg = 2; + *(pbuf **)(msg + 4) = p; + *(netif_input_fn **)(msg + 0xc) = input_fn; + eVar1 = sys_mbox_trypost(&tcpip_mbox,msg); + if (CONCAT31(extraout_var,eVar1) == 0) { + return eVar1; + } + printf("[LWIP] NO MBOX\r\n"); + memp_free(MEMP_TCPIP_MSG_INPKT,msg); + } + return -1; +} + + + +err_t tcpip_input(pbuf *p,netif *inp) + +{ + err_t eVar1; + code *input_fn; + + if ((inp->flags & 0x18) == 0) { + input_fn = ip4_input; + } + else { + input_fn = ethernet_input; + } + eVar1 = tcpip_inpkt(p,inp,input_fn); + return eVar1; +} + + + +err_t tcpip_try_callback(tcpip_callback_fn function,void *ctx) + +{ + err_t eVar1; + undefined *msg; + undefined3 extraout_var; + + sys_mbox_valid(&tcpip_mbox); + msg = (undefined *)memp_malloc(MEMP_TCPIP_MSG_API); + if (msg != (undefined *)0x0) { + *(void **)(msg + 8) = ctx; + *msg = 3; + *(tcpip_callback_fn *)(msg + 4) = function; + eVar1 = sys_mbox_trypost(&tcpip_mbox,msg); + if (CONCAT31(extraout_var,eVar1) == 0) { + return eVar1; + } + memp_free(MEMP_TCPIP_MSG_API,msg); + } + return -1; +} + + + +// WARNING: Could not reconcile some variable overlaps + +err_t tcpip_api_call(tcpip_api_call_fn *fn,tcpip_api_call_data *call) + +{ + sys_sem_t *sem; + err_t eVar1; + undefined3 extraout_var; + undefined local_30 [4]; + tcpip_msg msg; + + sem = &call->sem; + eVar1 = sys_sem_new(sem,'\0'); + if (CONCAT31(extraout_var,eVar1) == 0) { + sys_mbox_valid(&tcpip_mbox); + local_30[0] = 1; + msg._0_4_ = fn; + msg.msg._0_4_ = call; + msg.msg._4_4_ = sem; + sys_mbox_post(&tcpip_mbox,local_30); + sys_arch_sem_wait(msg.msg._4_4_,0); + sys_sem_free(sem); + eVar1 = call->err; + } + return eVar1; +} + + + +void tcpip_init(tcpip_init_done_fn initfunc,void *arg) + +{ + lwip_init(); + tcpip_init_done = initfunc; + tcpip_init_done_arg = arg; + sys_mbox_new(&tcpip_mbox,0x32); + sys_thread_new("TCP/IP",tcpip_thread,(void *)0x0,4000,0x1e); + return; +} + + + +u16_t lwip_htons(u16_t n) + +{ + undefined2 in_register_0000202a; + + return (u16_t)((ushort)(CONCAT22(in_register_0000202a,n) >> 8) | n << 8); +} + + + +u32_t lwip_htonl(u32_t n) + +{ + return n >> 8 & 0xff00 | n << 0x18 | n >> 0x18 | (n & 0xff00) << 8; +} + + + +void dns_call_found(u8_t idx,ip_addr_t *addr) + +{ + undefined3 in_register_00002029; + int iVar1; + + iVar1 = CONCAT31(in_register_00002029,idx); + if (dns_requests[iVar1].found != (dns_found_callback *)0x0) { + (*dns_requests[iVar1].found)(dns_table[iVar1].name,addr,dns_requests[iVar1].arg); + } + dns_requests[iVar1].found = (dns_found_callback *)0x0; + return; +} + + + +// WARNING: Variable defined which should be unmapped: hdr + +err_t dns_send(u8_t idx) + +{ + u8_t *dataptr; + u8_t *puVar1; + err_t eVar2; + undefined3 in_register_00002029; + int iVar3; + size_t sVar4; + pbuf *buf; + uint uVar5; + uint uVar6; + uint uVar7; + undefined4 local_40; + dns_query qry; + dns_hdr hdr; + + iVar3 = CONCAT31(in_register_00002029,idx); + if (dns_servers[dns_table[iVar3].server_idx].addr == 0) { + dns_call_found(idx,(ip_addr_t *)0x0); + eVar2 = '\0'; + dns_table[iVar3].state = '\0'; + } + else { + sVar4 = strlen(dns_table[iVar3].name); + buf = pbuf_alloc(PBUF_TRANSPORT,(u16_t)((sVar4 + 0x12) * 0x10000 >> 0x10),PBUF_RAM); + eVar2 = -1; + if (buf != (pbuf *)0x0) { + memset(&qry,0,0xc); + qry.type = lwip_htons(dns_table[iVar3].txid); + qry.cls._0_1_ = 1; + puVar1 = &dns_table[iVar3].seqno; + pbuf_take(buf,&qry,0xc); + uVar6 = 0xc; + do { + dataptr = puVar1 + 1; + uVar5 = 0; + puVar1 = dataptr; + while ((*puVar1 != '.' && (*puVar1 != '\0'))) { + uVar5 = uVar5 + 1 & 0xff; + puVar1 = puVar1 + 1; + } + if (0xfffe < uVar6 + uVar5) { + pbuf_free(buf); + return -6; + } + pbuf_put_at(buf,(u16_t)uVar6,(u8_t)uVar5); + pbuf_take_at(buf,dataptr,(u16_t)((uint)((int)(puVar1 + -(int)dataptr) * 0x10000) >> 0x10), + (u16_t)((uVar6 + 1) * 0x10000 >> 0x10)); + uVar7 = uVar6 + uVar5 & 0xffff; + uVar5 = uVar7 + 1; + uVar6 = uVar5 & 0xffff; + } while (*puVar1 != '\0'); + pbuf_put_at(buf,(u16_t)(uVar5 * 0x10000 >> 0x10),'\0'); + local_40 = 0x1000100; + pbuf_take_at(buf,&local_40,4,(u16_t)((uVar7 + 2) * 0x10000 >> 0x10)); + eVar2 = udp_sendto(dns_pcbs,buf,dns_servers + dns_table[iVar3].server_idx,0x35); + pbuf_free(buf); + } + } + return eVar2; +} + + + +void dns_check_entry(u8_t i) + +{ + undefined3 in_register_00002029; + int iVar1; + u8_t uVar2; + u16_t uVar3; + uint uVar4; + uint uVar5; + u32_t uVar6; + dns_table_entry_conflict *pdVar7; + + iVar1 = CONCAT31(in_register_00002029,i); + uVar2 = dns_table[iVar1].state; + if (uVar2 != '\x02') { + if (uVar2 != '\x03') { + if (uVar2 != '\x01') { + return; + } + uVar4 = (uint)dns_txid; + do { + uVar5 = uVar4 + 1; + uVar4 = uVar5 & 0xffff; + pdVar7 = dns_table; + while ((pdVar7->state != '\x02' || ((uint)pdVar7->txid != uVar4))) { + pdVar7 = pdVar7 + 1; + if (pdVar7 == (dns_table_entry_conflict *)arp_table) { + uVar3 = (u16_t)(uVar5 * 0x10000 >> 0x10); + dns_txid = uVar3; + *(undefined2 *)&dns_table[iVar1].state = 2; + dns_table[iVar1].txid = uVar3; + *(undefined2 *)&dns_table[iVar1].tmr = 1; + goto LAB_2303a9e4; + } + } + } while( true ); + } + uVar6 = dns_table[iVar1].ttl; + if ((uVar6 != 0) && (uVar6 = uVar6 - 1, dns_table[iVar1].ttl = uVar6, uVar6 != 0)) { + return; + } +LAB_2303aa40: + dns_table[iVar1].state = '\0'; + return; + } + uVar2 = dns_table[iVar1].tmr + -1; + dns_table[iVar1].tmr = uVar2; + if (uVar2 != '\0') { + return; + } + uVar2 = dns_table[iVar1].retries + '\x01'; + dns_table[iVar1].retries = uVar2; + if (uVar2 == '\x04') { + if ((dns_table[iVar1].server_idx != '\0') || (dns_servers[1] == 0)) { + dns_call_found(i,(ip_addr_t *)0x0); + goto LAB_2303aa40; + } + dns_table[iVar1].server_idx = '\x01'; + *(undefined2 *)&dns_table[iVar1].tmr = 1; + } + else { + dns_table[iVar1].tmr = uVar2; + } +LAB_2303a9e4: + dns_send(i); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void dns_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port) + +{ + u8_t i; + uint uVar1; + u16_t uVar2; + u16_t uVar3; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined2 extraout_var_02; + uint uVar4; + int iVar5; + undefined2 extraout_var_03; + uint uVar6; + undefined2 extraout_var_04; + undefined2 extraout_var_05; + u32_t uVar7; + undefined2 extraout_var_06; + dns_table_entry_conflict *pdVar8; + byte *pbVar9; + int iVar10; + uint uVar11; + byte *pbVar12; + short sStack96; + short sStack94; + dns_query qry; + ip4_addr_t ip4addr; + dns_hdr hdr; + dns_answer ans; + + if (0xf < p->tot_len) { + uVar2 = pbuf_copy_partial(p,&ip4addr,0xc,0); + uVar1 = CONCAT22(extraout_var,uVar2); + if (uVar1 == 0xc) { + iVar10 = 0; + uVar2 = lwip_htons((u16_t)ip4addr.addr); + pdVar8 = dns_table; + do { + i = (u8_t)iVar10; + if ((pdVar8->state == '\x02') && ((uint)pdVar8->txid == CONCAT22(extraout_var_00,uVar2))) { + uVar2 = lwip_htons(hdr.id); + uVar3 = lwip_htons(hdr._2_2_); + uVar11 = CONCAT22(extraout_var_02,uVar3); + if ((ip4addr.addr._2_1_ < '\0') && + ((CONCAT22(extraout_var_01,uVar2) == 1 && + (addr->addr == dns_servers[dns_table[iVar10].server_idx].addr)))) { + pbVar12 = (byte *)dns_table[iVar10].name; + goto LAB_2303ab38; + } + break; + } + iVar10 = iVar10 + 1; + pdVar8 = pdVar8 + 1; + } while (iVar10 != 4); + } + } + goto ignore_packet; + while( true ) { + pbVar9 = pbVar12 + uVar4; + while( true ) { + uVar1 = uVar1 + 1 & 0xffff; + if (pbVar12 == pbVar9) break; + uVar4 = pbuf_try_get_at(p,(u16_t)uVar1); + if ((int)uVar4 < 0) goto ignore_packet; + uVar6 = (uint)*pbVar12; + if ((_ctype_[uVar6 + 1] & 3) == 1) { + uVar6 = uVar6 + 0x20; + } + uVar4 = uVar4 & 0xff; + if ((_ctype_[uVar4 + 1] & 3) == 1) { + uVar4 = uVar4 + 0x20; + } + if ((uVar6 != uVar4) || (uVar1 == 0xffff)) goto ignore_packet; + pbVar12 = pbVar12 + 1; + } + pbVar12 = pbVar12 + 1; + iVar5 = pbuf_try_get_at(p,(u16_t)uVar1); + if (iVar5 < 0) goto ignore_packet; + if (iVar5 == 0) break; +LAB_2303ab38: + uVar4 = pbuf_try_get_at(p,(u16_t)uVar1); + if ((((int)uVar4 < 0) || (uVar1 == 0xffff)) || ((uVar4 & 0xc0) == 0xc0)) goto ignore_packet; + } + if (uVar1 != 0xffff) { + uVar4 = uVar1 + 1 & 0xffff; + if (((uVar4 != 0xffff) && + (uVar2 = pbuf_copy_partial(p,&sStack96,4,(u16_t)((uVar1 + 1) * 0x10000 >> 0x10)), + CONCAT22(extraout_var_03,uVar2) == 4)) && + ((sStack94 == 0x100 && ((sStack96 == 0x100 && (uVar4 < 0xfffc)))))) { + if ((ip4addr.addr._3_1_ & 0xf) == 0) { + uVar1 = uVar1 + 5; + while ((uVar1 = uVar1 & 0xffff, uVar11 != 0 && (uVar1 < p->tot_len))) { + do { + uVar4 = uVar1 + 1 & 0xffff; + uVar6 = pbuf_try_get_at(p,(u16_t)uVar1); + if (((int)uVar6 < 0) || (uVar4 == 0)) goto ignore_packet; + if ((uVar6 & 0xc0) == 0xc0) break; + uVar6 = uVar6 + uVar4; + if ((int)(uint)p->tot_len <= (int)uVar6) goto ignore_packet; + uVar1 = uVar6 & 0xffff; + iVar5 = pbuf_try_get_at(p,(u16_t)(uVar6 * 0x10000 >> 0x10)); + if (iVar5 < 0) goto ignore_packet; + uVar4 = uVar1; + } while (iVar5 != 0); + if (uVar4 == 0xffff) goto ignore_packet; + uVar1 = uVar4 + 1 & 0xffff; + if (((uVar1 == 0xffff) || + (uVar2 = pbuf_copy_partial(p,&hdr.numauthrr,10,(u16_t)((uVar4 + 1) * 0x10000 >> 0x10)) + , CONCAT22(extraout_var_04,uVar2) != 10)) || (0xfff5 < uVar1)) goto ignore_packet; + uVar1 = uVar4 + 0xb & 0xffff; + if (((hdr.numextrarr == 0x100) && (hdr.numauthrr == 0x100)) && ((u16_t)ans.ttl == 0x400)) + { + uVar2 = pbuf_copy_partial(p,&qry,4,(u16_t)((uVar4 + 0xb) * 0x10000 >> 0x10)); + if (CONCAT22(extraout_var_05,uVar2) == 4) { + *(dns_query *)&dns_table[iVar10].ipaddr = qry; + pbuf_free(p); + uVar7 = lwip_htonl(ans._0_4_); + dns_table[iVar10].state = '\x03'; + if (uVar7 < 0x93a81) { + dns_table[iVar10].ttl = uVar7; + } + else { + dns_table[iVar10].ttl = 0x93a80; + } + dns_call_found(i,&dns_table[iVar10].ipaddr); + if (dns_table[iVar10].ttl != 0) { + return; + } + if (dns_table[iVar10].state != '\x03') { + return; + } + dns_table[iVar10].state = '\0'; + return; + } + goto ignore_packet; + } + uVar2 = lwip_htons((u16_t)ans.ttl); + if (0xffff < (int)(CONCAT22(extraout_var_06,uVar2) + uVar1)) goto ignore_packet; + uVar2 = lwip_htons((u16_t)ans.ttl); + uVar1 = uVar2 + uVar1; + uVar11 = uVar11 - 1 & 0xffff; + } + } + else { + if ((dns_table[iVar10].server_idx == '\0') && (dns_servers[1] != 0)) { + *(undefined2 *)&dns_table[iVar10].tmr = 0x301; + dns_check_entry(i); + goto ignore_packet; + } + } + pbuf_free(p); + dns_call_found(i,(ip_addr_t *)0x0); + dns_table[iVar10].state = '\0'; + return; + } + } +ignore_packet: + pbuf_free(p); + return; +} + + + +void dns_init(void) + +{ + if (dns_pcbs == (udp_pcb *)0x0) { + dns_pcbs = udp_new_ip_type(); + udp_bind(dns_pcbs,&ip_addr_any,0); + udp_recv(dns_pcbs,dns_recv,(void *)0x0); + return; + } + return; +} + + + +void dns_setserver(u8_t numdns,ip_addr_t *dnsserver) + +{ + undefined3 in_register_00002029; + u32_t uVar1; + + if (CONCAT31(in_register_00002029,numdns) < 2) { + if (dnsserver == (ip_addr_t *)0x0) { + uVar1 = 0; + } + else { + uVar1 = dnsserver->addr; + } + dns_servers[CONCAT31(in_register_00002029,numdns)].addr = uVar1; + } + return; +} + + + +ip_addr_t * dns_getserver(u8_t numdns) + +{ + undefined3 in_register_00002029; + + if (CONCAT31(in_register_00002029,numdns) < 2) { + return dns_servers + CONCAT31(in_register_00002029,numdns); + } + return &ip_addr_any; +} + + + +void dns_tmr(void) + +{ + dns_check_entry('\0'); + dns_check_entry('\x01'); + dns_check_entry('\x02'); + dns_check_entry('\x03'); + return; +} + + + +void lwip_init(void) + +{ + stats_init(); + sys_init(); + mem_init(); + memp_init(); + netif_init(); + udp_init(); + tcp_init(); + igmp_init(); + dns_init(); + sys_timeouts_init(); + return; +} + + + +void dhcp_set_state(dhcp *dhcp,u8_t new_state) + +{ + undefined3 in_register_0000202d; + + if ((uint)dhcp->state != CONCAT31(in_register_0000202d,new_state)) { + dhcp->state = new_state; + dhcp->tries = '\0'; + dhcp->request_timeout = 0; + } + return; +} + + + +u16_t dhcp_option_short(u16_t options_out_len,u8_t *options,u16_t value) + +{ + undefined2 in_register_0000202a; + int iVar1; + + iVar1 = CONCAT22(in_register_0000202a,options_out_len); + options[iVar1] = (u8_t)(value >> 8); + options[iVar1 + 1U & 0xffff] = (u8_t)value; + return (u16_t)((uint)((iVar1 + 2) * 0x10000) >> 0x10); +} + + + +u16_t dhcp_option_long(u16_t options_out_len,u8_t *options,u32_t value) + +{ + undefined2 in_register_0000202a; + int iVar1; + + iVar1 = CONCAT22(in_register_0000202a,options_out_len); + options[iVar1] = (u8_t)(value >> 0x18); + options[iVar1 + 1U & 0xffff] = (u8_t)(value >> 0x10); + options[iVar1 + 2U & 0xffff] = (u8_t)(value >> 8); + options[iVar1 + 3U & 0xffff] = (u8_t)value; + return (u16_t)((uint)((iVar1 + 4) * 0x10000) >> 0x10); +} + + + +pbuf * dhcp_create_msg(netif *netif,dhcp *dhcp,u8_t message_type,u16_t *options_out_len) + +{ + u8_t uVar1; + u32_t xid; + undefined *__s; + u32_t uVar2; + undefined3 in_register_00002031; + int iVar3; + u8_t *puVar4; + u8_t *puVar5; + pbuf *ppVar6; + + iVar3 = CONCAT31(in_register_00002031,message_type); + if (((netif == (netif *)0x0) || (dhcp == (dhcp *)0x0)) || + (ppVar6 = pbuf_alloc(PBUF_TRANSPORT,0x134,PBUF_RAM), ppVar6 == (pbuf *)0x0)) { + ppVar6 = (pbuf *)0x0; + } + else { + if ((iVar3 != 3) || (dhcp->state == '\x03')) { + if (dhcp->tries == '\0') { + xid = bl_rand(); + } + dhcp->xid = xid; + } + __s = (undefined *)ppVar6->payload; + memset(__s,0,0x134); + *__s = 1; + __s[1] = 1; + __s[2] = netif->hwaddr_len; + uVar2 = lwip_htonl(dhcp->xid); + __s[4] = (char)uVar2; + __s[5] = (char)(uVar2 >> 8); + __s[6] = (char)(uVar2 >> 0x10); + __s[7] = (char)(uVar2 >> 0x18); + if (((iVar3 == 4) || ((iVar3 - 7U & 0xff) < 2)) || + ((iVar3 == 3 && ((byte)(dhcp->state - 4) < 2)))) { + uVar2 = (netif->ip_addr).addr; + __s[0xc] = (char)uVar2; + __s[0xd] = (char)(uVar2 >> 8); + __s[0xe] = (char)(uVar2 >> 0x10); + __s[0xf] = (char)(uVar2 >> 0x18); + } + puVar5 = netif->hwaddr; + puVar4 = __s + 0x1c; + do { + uVar1 = *puVar5; + puVar5 = puVar5 + 1; + *puVar4 = uVar1; + puVar4 = puVar4 + 1; + } while (puVar5 != &netif->hwaddr_len); + __s[0xec] = 99; + __s[0xef] = 99; + __s[0xed] = 0x82; + __s[0xf0] = 0x35; + __s[0xf1] = 1; + __s[0xee] = 0x53; + __s[0xf2] = message_type; + *options_out_len = 3; + } + return ppVar6; +} + + + +void dhcp_option_trailer(u16_t options_out_len,u8_t *options,pbuf *p_out) + +{ + undefined2 in_register_0000202a; + uint uVar1; + + uVar1 = CONCAT22(in_register_0000202a,options_out_len) + 1U & 0xffff; + options[CONCAT22(in_register_0000202a,options_out_len)] = -1; + options = options + uVar1; + while (uVar1 < 0x44) { + *options = '\0'; + uVar1 = uVar1 + 1 & 0xffff; + options = options + 1; + } + pbuf_realloc(p_out,(u16_t)((uVar1 + 0xf0) * 0x10000 >> 0x10)); + return; +} + + + +err_t dhcp_discover(netif *netif) + +{ + u8_t *options; + dhcp *dhcp; + pbuf *p_out; + undefined2 extraout_var; + uint uVar1; + int iVar2; + u16_t auStack34 [2]; + u16_t options_out_len; + + dhcp = (dhcp *)netif->client_data[0]; + (dhcp->offered_ip_addr).addr = 0; + dhcp_set_state(dhcp,'\x06'); + p_out = dhcp_create_msg(netif,dhcp,'\x01',auStack34); + if (p_out != (pbuf *)0x0) { + uVar1 = (uint)auStack34[0]; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar1] = '9'; + options[uVar1 + 1 & 0xffff] = '\x02'; + auStack34[0] = (u16_t)((uVar1 + 2) * 0x10000 >> 0x10); + auStack34[0] = dhcp_option_short(auStack34[0],options,netif->mtu); + options[CONCAT22(extraout_var,auStack34[0])] = '7'; + options[CONCAT22(extraout_var,auStack34[0]) + 1U & 0xffff] = '\x04'; + auStack34[0] = auStack34[0] + 2; + iVar2 = 0; + do { + options[(uint)auStack34[0]] = "\x01\x03\x1c\x06"[iVar2]; + auStack34[0] = (u16_t)(((uint)auStack34[0] + 1) * 0x10000 >> 0x10); + iVar2 = iVar2 + 1; + } while (iVar2 != 4); + dhcp_option_trailer(auStack34[0],options,p_out); + udp_sendto_if_src(dhcp_pcb,p_out,&ip_addr_broadcast,0x43,netif,&ip_addr_any); + pbuf_free(p_out); + } + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + if (dhcp->tries < 6) { + uVar1 = (uint)((1 << ((uint)dhcp->tries & 0x1f)) * 0x3e80000) >> 0x10; + } + else { + uVar1 = 60000; + } + dhcp->request_timeout = (u16_t)((int)(uVar1 + 499) / 500); + return '\0'; +} + + + +void dhcp_check(netif *netif) + +{ + dhcp *dhcp; + + dhcp = (dhcp *)netif->client_data[0]; + dhcp_set_state(dhcp,'\b'); + etharp_query(netif,&dhcp->offered_ip_addr,(pbuf *)0x0); + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + dhcp->request_timeout = 1; + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void dhcp_bind(netif *netif) + +{ + byte bVar1; + dhcp *dhcp; + u16_t uVar2; + uint uVar3; + int iVar4; + ip4_addr_t iStack24; + ip4_addr_t sn_mask; + ip4_addr_t gw_addr; + + if (netif == (netif *)0x0) { + return; + } + dhcp = (dhcp *)netif->client_data[0]; + if (dhcp == (dhcp *)0x0) { + return; + } + dhcp->lease_used = 0; + if (dhcp->offered_t0_lease != 0xffffffff) { + uVar3 = dhcp->offered_t0_lease + 0x1e; + if (uVar3 < 0x3c0000) { + uVar3 = uVar3 / 0x3c; + uVar2 = (u16_t)uVar3; + if (uVar3 == 0) { + dhcp->t0_timeout = 1; + goto LAB_2303b27c; + } + } + else { + uVar2 = 0xffff; + } + dhcp->t0_timeout = uVar2; + } +LAB_2303b27c: + if (dhcp->offered_t1_renew != 0xffffffff) { + uVar3 = dhcp->offered_t1_renew + 0x1e; + if (uVar3 < 0x3c0000) { + uVar3 = uVar3 / 0x3c; + uVar2 = (u16_t)uVar3; + if (uVar3 != 0) goto LAB_2303b29e; + dhcp->t1_timeout = 1; + } + else { + uVar2 = 0xffff; +LAB_2303b29e: + dhcp->t1_timeout = uVar2; + } + dhcp->t1_renew_time = dhcp->t1_timeout; + } + if (dhcp->offered_t2_rebind == 0xffffffff) goto LAB_2303b2d8; + uVar3 = dhcp->offered_t2_rebind + 0x1e; + if (uVar3 < 0x3c0000) { + uVar3 = uVar3 / 0x3c; + uVar2 = (u16_t)uVar3; + if (uVar3 != 0) goto LAB_2303b2cc; + dhcp->t2_timeout = 1; + } + else { + uVar2 = 0xffff; +LAB_2303b2cc: + dhcp->t2_timeout = uVar2; + } + dhcp->t2_rebind_time = dhcp->t2_timeout; +LAB_2303b2d8: + if ((dhcp->t2_timeout <= dhcp->t1_timeout) && (dhcp->t2_timeout != 0)) { + dhcp->t1_timeout = 0; + } + if (dhcp->subnet_mask_given == '\0') { + bVar1 = *(byte *)&(dhcp->offered_ip_addr).addr; + if ((char)bVar1 < '\0') { + if (bVar1 < 0xc0) { + iVar4 = 0x10000; + } + else { + iVar4 = 0x1000000; + } + iStack24 = (ip4_addr_t)(iVar4 - 1); + } + else { + iStack24 = (ip4_addr_t)0xff; + } + } + else { + iStack24 = (ip4_addr_t)(dhcp->offered_sn_mask).addr; + } + sn_mask = (dhcp->offered_gw_addr).addr; + if ((ip4_addr_t)sn_mask == (ip4_addr_t)0x0) { + sn_mask = (dhcp->offered_ip_addr).addr & (uint)iStack24 | 0x1000000; + } + dhcp_set_state(dhcp,'\n'); + netif_set_addr(netif,&dhcp->offered_ip_addr,&iStack24,&sn_mask); + return; +} + + + +err_t dhcp_inc_pcb_refcount(void) + +{ + udp_pcb *pcb; + + if (dhcp_pcb_refcount == '\0') { + pcb = udp_new(); + if (pcb == (udp_pcb *)0x0) { + dhcp_pcb = pcb; + return -1; + } + dhcp_pcb = pcb; + pcb->so_options = pcb->so_options | 0x20; + udp_bind(pcb,&ip_addr_any,0x44); + udp_connect(dhcp_pcb,&ip_addr_any,0x43); + udp_recv(dhcp_pcb,dhcp_recv,(void *)0x0); + } + dhcp_pcb_refcount = dhcp_pcb_refcount + '\x01'; + return '\0'; +} + + + +u16_t dhcp_option_hostname(u16_t options_out_len,u8_t *options) + +{ + undefined2 in_register_0000202a; + int iVar1; + size_t sVar2; + u8_t **in_a2; + u8_t *puVar3; + u8_t *puVar4; + uint uVar5; + uint uVar6; + uint uVar7; + + iVar1 = CONCAT22(in_register_0000202a,options_out_len); + if ((*in_a2 != (u8_t *)0x0) && (sVar2 = strlen((char *)*in_a2), sVar2 != 0)) { + puVar3 = *in_a2; + uVar6 = 0x41U - iVar1; + if (sVar2 < 0x41U - iVar1) { + uVar6 = sVar2; + } + options[iVar1] = '\f'; + uVar5 = iVar1 + 2U & 0xffff; + options[iVar1 + 1U & 0xffff] = (u8_t)uVar6; + puVar4 = puVar3; + uVar7 = uVar5; + while (puVar4 != puVar3 + uVar6) { + options[uVar7] = *puVar4; + uVar7 = uVar7 + 1 & 0xffff; + puVar4 = puVar4 + 1; + } + options_out_len = (short)uVar5 + (short)uVar6; + } + return options_out_len; +} + + + +err_t dhcp_reboot(netif *netif) + +{ + u8_t *options; + dhcp *dhcp; + err_t eVar1; + u16_t options_out_len_00; + pbuf *p_out; + undefined2 extraout_var; + u32_t value; + undefined2 extraout_var_00; + uint uVar2; + int iVar3; + u16_t auStack34 [2]; + u16_t options_out_len; + + dhcp = (dhcp *)netif->client_data[0]; + dhcp_set_state(dhcp,'\x03'); + p_out = dhcp_create_msg(netif,dhcp,'\x03',auStack34); + eVar1 = -1; + if (p_out != (pbuf *)0x0) { + uVar2 = (uint)auStack34[0]; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar2] = '9'; + options[uVar2 + 1 & 0xffff] = '\x02'; + auStack34[0] = (u16_t)((uVar2 + 2) * 0x10000 >> 0x10); + options_out_len_00 = dhcp_option_short(auStack34[0],options,0x240); + iVar3 = CONCAT22(extraout_var,options_out_len_00); + options[iVar3] = '2'; + options[iVar3 + 1U & 0xffff] = '\x04'; + options_out_len_00 = (u16_t)((uint)((iVar3 + 2) * 0x10000) >> 0x10); + auStack34[0] = options_out_len_00; + value = lwip_htonl((dhcp->offered_ip_addr).addr); + auStack34[0] = dhcp_option_long(options_out_len_00,options,value); + options[CONCAT22(extraout_var_00,auStack34[0])] = '7'; + options[CONCAT22(extraout_var_00,auStack34[0]) + 1U & 0xffff] = '\x04'; + auStack34[0] = auStack34[0] + 2; + iVar3 = 0; + do { + options[(uint)auStack34[0]] = "\x01\x03\x1c\x06"[iVar3]; + auStack34[0] = (u16_t)(((uint)auStack34[0] + 1) * 0x10000 >> 0x10); + iVar3 = iVar3 + 1; + } while (iVar3 != 4); + auStack34[0] = dhcp_option_hostname(auStack34[0],options); + dhcp_option_trailer(auStack34[0],options,p_out); + eVar1 = udp_sendto_if(dhcp_pcb,p_out,&ip_addr_broadcast,0x43,netif); + pbuf_free(p_out); + } + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + if (dhcp->tries < 10) { + uVar2 = (uint)dhcp->tries * 0x3e80000 >> 0x10; + } + else { + uVar2 = 10000; + } + dhcp->request_timeout = (u16_t)((int)(uVar2 + 499) / 500); + return eVar1; +} + + + +err_t dhcp_select(netif *netif) + +{ + u8_t *options; + dhcp *dhcp; + err_t eVar1; + u16_t options_out_len_00; + pbuf *p_out; + undefined2 extraout_var; + u32_t value; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + uint uVar2; + int iVar3; + u16_t auStack34 [2]; + u16_t options_out_len; + + eVar1 = -0x10; + if (netif != (netif *)0x0) { + dhcp = (dhcp *)netif->client_data[0]; + eVar1 = -6; + if (dhcp != (dhcp *)0x0) { + dhcp_set_state(dhcp,'\x01'); + p_out = dhcp_create_msg(netif,dhcp,'\x03',auStack34); + eVar1 = -1; + if (p_out != (pbuf *)0x0) { + uVar2 = (uint)auStack34[0]; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar2] = '9'; + options[uVar2 + 1 & 0xffff] = '\x02'; + auStack34[0] = (u16_t)((uVar2 + 2) * 0x10000 >> 0x10); + options_out_len_00 = dhcp_option_short(auStack34[0],options,netif->mtu); + iVar3 = CONCAT22(extraout_var,options_out_len_00); + options[iVar3] = '2'; + options[iVar3 + 1U & 0xffff] = '\x04'; + options_out_len_00 = (u16_t)((uint)((iVar3 + 2) * 0x10000) >> 0x10); + auStack34[0] = options_out_len_00; + value = lwip_htonl((dhcp->offered_ip_addr).addr); + options_out_len_00 = dhcp_option_long(options_out_len_00,options,value); + iVar3 = CONCAT22(extraout_var_00,options_out_len_00); + options[iVar3] = '6'; + options[iVar3 + 1U & 0xffff] = '\x04'; + options_out_len_00 = (u16_t)((uint)((iVar3 + 2) * 0x10000) >> 0x10); + auStack34[0] = options_out_len_00; + value = lwip_htonl((dhcp->server_ip_addr).addr); + auStack34[0] = dhcp_option_long(options_out_len_00,options,value); + options[CONCAT22(extraout_var_01,auStack34[0])] = '7'; + options[CONCAT22(extraout_var_01,auStack34[0]) + 1U & 0xffff] = '\x04'; + auStack34[0] = auStack34[0] + 2; + iVar3 = 0; + do { + options[(uint)auStack34[0]] = "\x01\x03\x1c\x06"[iVar3]; + auStack34[0] = (u16_t)(((uint)auStack34[0] + 1) * 0x10000 >> 0x10); + iVar3 = iVar3 + 1; + } while (iVar3 != 4); + auStack34[0] = dhcp_option_hostname(auStack34[0],options); + dhcp_option_trailer(auStack34[0],options,p_out); + eVar1 = udp_sendto_if_src(dhcp_pcb,p_out,&ip_addr_broadcast,0x43,netif,&ip_addr_any); + pbuf_free(p_out); + } + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + if (dhcp->tries < 6) { + uVar2 = (uint)((1 << ((uint)dhcp->tries & 0x1f)) * 0x3e80000) >> 0x10; + } + else { + uVar2 = 60000; + } + dhcp->request_timeout = (u16_t)((int)(uVar2 + 499) / 500); + } + } + return eVar1; +} + + + +void dhcp_dec_pcb_refcount(void) + +{ + dhcp_pcb_refcount = dhcp_pcb_refcount + -1; + if (dhcp_pcb_refcount == '\0') { + udp_remove(dhcp_pcb); + dhcp_pcb = (udp_pcb *)0x0; + return; + } + return; +} + + + +void dhcp_handle_ack(dhcp_msg *msg_in) + +{ + u8_t uVar1; + u32_t uVar2; + int in_a1; + uint uVar3; + ip_addr_t iStack20; + ip_addr_t dns_addr; + + uVar1 = dhcp_rx_options_given[3]; + *(undefined4 *)(msg_in->chaddr + 4) = 0; + *(undefined4 *)(msg_in->chaddr + 8) = 0; + if (uVar1 != '\0') { + *(u32_t *)(msg_in->chaddr + 0xc) = dhcp_rx_options_val[3]; + } + uVar3 = dhcp_rx_options_val[4]; + if (dhcp_rx_options_given[4] == '\0') { + uVar3 = *(uint *)(msg_in->chaddr + 0xc) >> 1; + } + *(uint *)msg_in->sname = uVar3; + uVar3 = dhcp_rx_options_val[5]; + if (dhcp_rx_options_given[5] == '\0') { + uVar3 = (uint)(*(int *)(msg_in->chaddr + 0xc) * 7) >> 3; + } + *(uint *)(msg_in->sname + 4) = uVar3; + *(undefined4 *)msg_in->chaddr = *(undefined4 *)(in_a1 + 0x10); + if (dhcp_rx_options_given[6] == '\0') { + *(undefined *)((int)&msg_in->xid + 3) = 0; + } + else { + uVar2 = lwip_htonl(dhcp_rx_options_val[6]); + *(u32_t *)(msg_in->chaddr + 4) = uVar2; + *(undefined *)((int)&msg_in->xid + 3) = 1; + } + if (dhcp_rx_options_given[7] != '\0') { + uVar2 = lwip_htonl(dhcp_rx_options_val[7]); + *(u32_t *)(msg_in->chaddr + 8) = uVar2; + } + if (dhcp_rx_options_given[8] != '\0') { + iStack20 = (ip_addr_t)lwip_htonl(dhcp_rx_options_val[8]); + dns_setserver('\0',&iStack20); + if (dhcp_rx_options_given[9] != '\0') { + iStack20 = (ip_addr_t)lwip_htonl(dhcp_rx_options_val[9]); + dns_setserver('\x01',&iStack20); + } + } + return; +} + + + +void dhcp_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port) + +{ + byte bVar1; + byte bVar2; + bool bVar3; + pbuf **pppVar4; + netif *netif; + uint uVar5; + void *pvVar6; + u16_t uVar7; + u32_t uVar8; + undefined2 extraout_var; + void *pvVar9; + uint uVar10; + char *pcVar11; + uint uVar12; + u8_t *puVar13; + u32_t *puVar14; + pbuf *buf; + uint uVar15; + uint uVar16; + int iVar17; + uint uVar18; + void *pvStack96; + u32_t uStack68; + u32_t value; + + netif = ip_data.current_input_netif; + puVar14 = (u32_t *)(ip_data.current_input_netif)->client_data[0]; + if ((((puVar14 != (u32_t *)0x0) && (*(char *)(puVar14 + 1) != '\0')) && (0x2b < p->len)) && + (pcVar11 = (char *)p->payload, *pcVar11 == '\x02')) { + uVar16 = 0; + do { + if (((uint)(ip_data.current_input_netif)->hwaddr_len <= (uVar16 & 0xff)) || (uVar16 == 6)) { + uVar8 = lwip_htonl(*(u32_t *)(pcVar11 + 4)); + if ((uVar8 == *puVar14) && (memset(dhcp_rx_options_given,0,10), 0x2b < p->len)) { + uVar16 = (uint)p->tot_len; + bVar3 = false; + uVar18 = 0xf0; + buf = p; + goto LAB_2303b9b2; + } + break; + } + puVar13 = (ip_data.current_input_netif)->hwaddr + uVar16; + iVar17 = uVar16 + 0x1c; + uVar16 = uVar16 + 1; + } while (pcVar11[iVar17] == *puVar13); + } +free_pbuf_and_return: + pbuf_free(p); + return; +LAB_2303b9b2: + do { + uVar12 = (uint)buf->len; + if (uVar18 < uVar12) { + pvStack96 = buf->payload; + uVar12 = uVar18; +LAB_2303bbf4: + if (uVar16 <= uVar12) goto LAB_2303bc0a; + bVar2 = *(byte *)((int)pvStack96 + uVar12); + if (bVar2 == 0xff) goto LAB_2303bc0a; + uVar15 = uVar12 + 2 & 0xffff; + if (uVar15 < uVar12) break; + if (uVar12 + 1 < (uint)buf->len) { + bVar1 = ((byte *)((int)pvStack96 + uVar12))[1]; +LAB_2303ba48: + uVar10 = (uint)bVar1; + if (bVar2 == 0x33) { + if (bVar1 != 4) break; + uVar5 = 4; + iVar17 = 3; + } + else { + if (bVar2 < 0x34) { + if (bVar2 == 1) { + if (bVar1 == 4) { + uVar5 = 4; + iVar17 = 6; + goto LAB_2303bace; + } + break; + } + if (bVar2 == 0) goto LAB_2303bbba; + if (bVar2 != 3) goto LAB_2303ba66; + if (uVar10 <= bVar2) break; + iVar17 = 7; + uVar5 = 4; + } + else { + if (bVar2 == 0x36) { +LAB_2303bba0: + if (uVar10 != 4) break; + uVar5 = 4; + iVar17 = 2; + } + else { + if (bVar2 < 0x37) { + if (bVar2 == 0x34) goto LAB_2303bb8a; +LAB_2303ba98: + if (bVar2 == 0x35) { + if (uVar10 != 1) break; + uVar5 = 1; + iVar17 = 1; + } + else { +LAB_2303ba6a: + iVar17 = -1; + uVar5 = 0; + } + } + else { + if (bVar2 == 0x3a) goto LAB_2303bbae; +LAB_2303bab4: + if (bVar2 != 0x3b) goto LAB_2303ba6a; + if (uVar10 != 4) break; + uVar5 = 4; + iVar17 = 5; + } + } + } + } + } + else { + if (buf->next != (pbuf *)0x0) { + bVar1 = *(byte *)buf->next->payload; + goto LAB_2303ba48; + } + if (bVar2 == 0x33) break; + if (bVar2 < 0x34) { + if (bVar2 == 1) break; + if (bVar2 != 0) { + if (bVar2 != 3) { + uVar10 = 0; +LAB_2303ba66: + if (bVar2 != 6) goto LAB_2303ba6a; + if ((uVar10 & 3) == 0) { + uVar5 = uVar10; + if (8 < uVar10) { + uVar5 = 8; + } + if (uVar5 <= uVar10) { + iVar17 = 8; + goto LAB_2303bace; + } + } + } + break; + } +LAB_2303bbba: + uVar12 = uVar12 + 1 & 0xffff; + goto LAB_2303bbc2; + } + if (bVar2 == 0x36) { + uVar10 = 0; + goto LAB_2303bba0; + } + if (bVar2 < 0x37) { + if (bVar2 != 0x34) { + uVar10 = 0; + goto LAB_2303ba98; + } + uVar10 = 0; +LAB_2303bb8a: + if ((uVar10 != 1) || (uVar18 != 0xf0)) break; + uVar5 = 1; + iVar17 = 0; + } + else { + if (bVar2 != 0x3a) { + uVar10 = 0; + goto LAB_2303bab4; + } + uVar10 = 0; +LAB_2303bbae: + if (uVar10 != 4) break; + uVar5 = 4; + iVar17 = 4; + } + } +LAB_2303bace: + if (0xfffd < uVar10 + uVar12) break; + uVar12 = uVar10 + uVar15 & 0xffff; + if (uVar5 != 0) { + uStack68 = 0; + puVar13 = dhcp_rx_options_given + iVar17; + while (*puVar13 == '\0') { + uVar10 = uVar5; + if (4 < uVar5) { + uVar10 = 4; + } + uVar7 = pbuf_copy_partial(buf,&uStack68,(u16_t)uVar10,(u16_t)uVar15); + if (uVar10 != CONCAT22(extraout_var,uVar7)) goto free_pbuf_and_return; + if (uVar5 < 5) { + if (uVar5 == 4) { + uStack68 = lwip_htonl(uStack68); + } + else { + if (uVar5 != 1) goto free_pbuf_and_return; + uStack68 = uStack68 & 0xff; + } + dhcp_rx_options_given[iVar17] = '\x01'; + dhcp_rx_options_val[iVar17] = uStack68; + break; + } + if ((uVar5 & 3) != 0) goto free_pbuf_and_return; + *puVar13 = '\x01'; + uVar8 = lwip_htonl(uStack68); + dhcp_rx_options_val[iVar17] = uVar8; + uVar10 = uVar15 + 4 & 0xffff; + uVar5 = uVar5 - 4 & 0xff; + puVar13 = puVar13 + 1; + if (uVar10 < uVar15) goto free_pbuf_and_return; + iVar17 = iVar17 + 1; + uVar15 = uVar10; + } + } +LAB_2303bbc2: + uVar15 = (uint)buf->len; + if (uVar15 <= uVar12) { + uVar12 = uVar12 - uVar15 & 0xffff; + uVar16 = uVar16 - uVar15 & 0xffff; + if ((uVar16 <= uVar12) || (buf = buf->next, buf == (pbuf *)0x0)) break; + pvStack96 = buf->payload; + } + goto LAB_2303bbf4; + } + pppVar4 = &buf->next; + uVar18 = uVar18 - uVar12 & 0xffff; + uVar16 = uVar16 - uVar12 & 0xffff; + buf = *pppVar4; + } while (*pppVar4 != (pbuf *)0x0); + goto free_pbuf_and_return; +LAB_2303bc0a: + if (dhcp_rx_options_given[0] != '\0') { + dhcp_rx_options_given[0] = '\0'; + if (dhcp_rx_options_val[0] == 1) { +LAB_2303bcbe: + uVar16 = 0xec; + uVar18 = 0x6c; + buf = p; + goto LAB_2303b9b2; + } + if (dhcp_rx_options_val[0] == 2) goto LAB_2303bca8; + if (dhcp_rx_options_val[0] == 3) { + bVar3 = true; + goto LAB_2303bcbe; + } + } + if (!bVar3) { + if (dhcp_rx_options_given[1] == '\0') goto free_pbuf_and_return; + pvVar9 = p->payload; + if ((char)dhcp_rx_options_val[1] != '\x05') { + if ((char)dhcp_rx_options_val[1] == '\x06') { + if (((byte)(*(char *)((int)puVar14 + 5) - 3U) < 3) || + (*(char *)((int)puVar14 + 5) == '\x01')) { + dhcp_set_state((dhcp *)netif->client_data[0],'\f'); + netif_set_addr(netif,(ip4_addr_t *)&ip_addr_any,(ip4_addr_t *)&ip_addr_any, + (ip4_addr_t *)&ip_addr_any); + dhcp_discover(netif); + } + } + else { + if ((((char)dhcp_rx_options_val[1] == '\x02') && (*(char *)((int)puVar14 + 5) == '\x06')) && + (dhcp_rx_options_given[2] != '\0')) { + pvVar6 = netif->client_data[0]; + *(undefined2 *)((int)pvVar6 + 8) = 0; + uVar8 = lwip_htonl(dhcp_rx_options_val[2]); + *(u32_t *)((int)pvVar6 + 0x18) = uVar8; + *(undefined4 *)((int)pvVar6 + 0x1c) = *(undefined4 *)((int)pvVar9 + 0x10); + dhcp_select(netif); + } + } + goto free_pbuf_and_return; + } + if (*(char *)((int)puVar14 + 5) == '\x01') { + dhcp_handle_ack((dhcp_msg *)netif->client_data[0]); + if ((netif->flags & 8) != 0) { + dhcp_check(netif); + goto free_pbuf_and_return; + } + } + else { + if (2 < (byte)(*(char *)((int)puVar14 + 5) - 3U)) goto free_pbuf_and_return; + dhcp_handle_ack((dhcp_msg *)netif->client_data[0]); + } + dhcp_bind(netif); + goto free_pbuf_and_return; + } +LAB_2303bca8: + bVar3 = false; + uVar16 = 0x6c; + uVar18 = 0x2c; + buf = p; + goto LAB_2303b9b2; +} + + + +void dhcp_network_changed(netif *netif) + +{ + byte bVar1; + void *pvVar2; + + pvVar2 = netif->client_data[0]; + if (pvVar2 == (void *)0x0) { + return; + } + bVar1 = *(byte *)((int)pvVar2 + 5); + if (bVar1 < 6) { + if (2 < bVar1) { +LAB_2303bdee: + *(undefined *)((int)pvVar2 + 6) = 0; + dhcp_reboot(netif); + return; + } + if (bVar1 == 0) { + return; + } + } + else { + if (bVar1 == 10) goto LAB_2303bdee; + } + *(undefined *)((int)pvVar2 + 6) = 0; + dhcp_discover(netif); + return; +} + + + +void dhcp_arp_reply(netif *netif,ip4_addr_t *addr) + +{ + dhcp *dhcp; + u8_t *options; + pbuf *p_out; + u32_t value; + uint uVar1; + u16_t options_out_len_00; + u16_t auStack34 [2]; + u16_t options_out_len; + + if (netif != (netif *)0x0) { + dhcp = (dhcp *)netif->client_data[0]; + if (((dhcp != (dhcp *)0x0) && (dhcp->state == '\b')) && + (addr->addr == (dhcp->offered_ip_addr).addr)) { + dhcp_set_state(dhcp,'\f'); + p_out = dhcp_create_msg(netif,dhcp,'\x04',auStack34); + if (p_out != (pbuf *)0x0) { + uVar1 = (uint)auStack34[0]; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar1] = '2'; + options[uVar1 + 1 & 0xffff] = '\x04'; + options_out_len_00 = (u16_t)((uVar1 + 2) * 0x10000 >> 0x10); + auStack34[0] = options_out_len_00; + value = lwip_htonl((dhcp->offered_ip_addr).addr); + auStack34[0] = dhcp_option_long(options_out_len_00,options,value); + dhcp_option_trailer(auStack34[0],options,p_out); + udp_sendto_if_src(dhcp_pcb,p_out,&ip_addr_broadcast,0x43,netif,&ip_addr_any); + pbuf_free(p_out); + } + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + dhcp->request_timeout = 0x14; + } + return; + } + return; +} + + + +err_t dhcp_renew(netif *netif) + +{ + u8_t *options; + dhcp *dhcp; + err_t eVar1; + pbuf *p_out; + undefined2 extraout_var; + uint uVar2; + int iVar3; + u16_t auStack34 [2]; + u16_t options_out_len; + + dhcp = (dhcp *)netif->client_data[0]; + dhcp_set_state(dhcp,'\x05'); + p_out = dhcp_create_msg(netif,dhcp,'\x03',auStack34); + eVar1 = -1; + if (p_out != (pbuf *)0x0) { + uVar2 = (uint)auStack34[0]; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar2] = '9'; + options[uVar2 + 1 & 0xffff] = '\x02'; + auStack34[0] = (u16_t)((uVar2 + 2) * 0x10000 >> 0x10); + auStack34[0] = dhcp_option_short(auStack34[0],options,netif->mtu); + options[CONCAT22(extraout_var,auStack34[0])] = '7'; + options[CONCAT22(extraout_var,auStack34[0]) + 1U & 0xffff] = '\x04'; + auStack34[0] = auStack34[0] + 2; + iVar3 = 0; + do { + options[(uint)auStack34[0]] = "\x01\x03\x1c\x06"[iVar3]; + auStack34[0] = (u16_t)(((uint)auStack34[0] + 1) * 0x10000 >> 0x10); + iVar3 = iVar3 + 1; + } while (iVar3 != 4); + auStack34[0] = dhcp_option_hostname(auStack34[0],options); + dhcp_option_trailer(auStack34[0],options,p_out); + eVar1 = udp_sendto_if(dhcp_pcb,p_out,&dhcp->server_ip_addr,0x43,netif); + pbuf_free(p_out); + } + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + if (dhcp->tries < 10) { + uVar2 = (uint)dhcp->tries * 0x7d00000 >> 0x10; + } + else { + uVar2 = 20000; + } + dhcp->request_timeout = (u16_t)((int)(uVar2 + 499) / 500); + return eVar1; +} + + + +u8_t dhcp_supplied_address(netif *netif) + +{ + byte bVar1; + bool bVar2; + + if ((netif != (netif *)0x0) && (netif->client_data[0] != (void *)0x0)) { + bVar1 = *(byte *)((int)netif->client_data[0] + 5); + bVar2 = true; + if (bVar1 != 10) { + bVar2 = (uint)bVar1 - 4 < 2; + } + return (u8_t)bVar2; + } + return '\0'; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +void dhcp_release_and_stop(netif *netif) + +{ + dhcp *dhcp; + u8_t uVar1; + undefined3 extraout_var; + pbuf *p_out; + u32_t value; + uint uVar2; + u8_t *options; + u16_t options_out_len_00; + u16_t uStack38; + u16_t options_out_len; + ip_addr_t n; + ip_addr_t server_ip_addr; + + dhcp = (dhcp *)netif->client_data[0]; + if ((dhcp != (dhcp *)0x0) && (dhcp->state != '\0')) { + n = (ip_addr_t)(dhcp->server_ip_addr).addr; + (dhcp->offered_ip_addr).addr = 0; + (dhcp->server_ip_addr).addr = 0; + (dhcp->offered_sn_mask).addr = 0; + (dhcp->offered_gw_addr).addr = 0; + dhcp->offered_t2_rebind = 0; + dhcp->offered_t1_renew = 0; + dhcp->offered_t0_lease = 0; + dhcp->t1_renew_time = 0; + *(undefined4 *)&dhcp->t2_rebind_time = 0; + dhcp->t0_timeout = 0; + uVar1 = dhcp_supplied_address(netif); + if ((CONCAT31(extraout_var,uVar1) != 0) && + (p_out = dhcp_create_msg(netif,dhcp,'\a',&uStack38), p_out != (pbuf *)0x0)) { + uVar2 = (uint)uStack38; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar2] = '6'; + options[uVar2 + 1 & 0xffff] = '\x04'; + options_out_len_00 = (u16_t)((uVar2 + 2) * 0x10000 >> 0x10); + uStack38 = options_out_len_00; + value = lwip_htonl((u32_t)n); + uStack38 = dhcp_option_long(options_out_len_00,options,value); + dhcp_option_trailer(uStack38,options,p_out); + udp_sendto_if(dhcp_pcb,p_out,(ip_addr_t *)&stack0xffffffdc,0x43,netif); + pbuf_free(p_out); + } + netif_set_addr(netif,(ip4_addr_t *)&ip_addr_any,(ip4_addr_t *)&ip_addr_any, + (ip4_addr_t *)&ip_addr_any); + dhcp_set_state(dhcp,'\0'); + if (dhcp->pcb_allocated != '\0') { + dhcp_dec_pcb_refcount(); + dhcp->pcb_allocated = '\0'; + } + } + return; +} + + + +err_t dhcp_start(netif *netif) + +{ + err_t eVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + dhcp *dhcp; + + if (netif == (netif *)0x0) { + return -0x10; + } + if ((netif->flags & 1) == 0) { + return -0x10; + } + dhcp = (dhcp *)netif->client_data[0]; + if (0x23f < netif->mtu) { + if (dhcp == (dhcp *)0x0) { + dhcp = (dhcp *)mem_malloc(0x34); + if (dhcp == (dhcp *)0x0) { + return -1; + } + *(dhcp **)netif->client_data = dhcp; + } + else { + if (dhcp->pcb_allocated != '\0') { + dhcp_dec_pcb_refcount(); + } + } + memset(dhcp,0,0x34); + eVar1 = dhcp_inc_pcb_refcount(); + if (CONCAT31(extraout_var,eVar1) == 0) { + dhcp->pcb_allocated = '\x01'; + if ((netif->flags & 4) == 0) { + dhcp_set_state(dhcp,'\x02'); + return eVar1; + } + eVar1 = dhcp_discover(netif); + if (CONCAT31(extraout_var_00,eVar1) == 0) { + return eVar1; + } + dhcp_release_and_stop(netif); + } + } + return -1; +} + + + +void dhcp_coarse_tmr(void) + +{ + short sVar1; + netif *netif; + dhcp *dhcp; + pbuf *p_out; + undefined2 extraout_var; + uint uVar2; + void *pvVar3; + int iVar4; + u8_t *options; + u16_t auStack50 [2]; + u16_t options_out_len; + + netif = netif_list; + while (netif != (netif *)0x0) { + pvVar3 = netif->client_data[0]; + if ((pvVar3 != (void *)0x0) && (*(char *)((int)pvVar3 + 5) != '\0')) { + if ((*(ushort *)((int)pvVar3 + 0x14) == 0) || + (uVar2 = (uint)*(ushort *)((int)pvVar3 + 0x12) + 1, + *(undefined2 *)((int)pvVar3 + 0x12) = (short)(uVar2 * 0x10000 >> 0x10), + (uint)*(ushort *)((int)pvVar3 + 0x14) != (uVar2 & 0xffff))) { + sVar1 = *(short *)((int)pvVar3 + 0x10); + if ((sVar1 == 0) || (*(short *)((int)pvVar3 + 0x10) = sVar1 + -1, sVar1 != 1)) { + sVar1 = *(short *)((int)pvVar3 + 0xe); + if ((sVar1 != 0) && (*(short *)((int)pvVar3 + 0xe) = sVar1 + -1, sVar1 == 1)) { + pvVar3 = netif->client_data[0]; + if (((*(byte *)((int)pvVar3 + 5) & 0xfb) == 1) || (*(byte *)((int)pvVar3 + 5) == 10)) { + dhcp_renew(netif); + iVar4 = (uint)*(ushort *)((int)pvVar3 + 0xc) - (uint)*(ushort *)((int)pvVar3 + 0x12); + if (1 < iVar4) { + *(undefined2 *)((int)pvVar3 + 0xe) = (short)(iVar4 >> 1); + } + } + } + } + else { + dhcp = (dhcp *)netif->client_data[0]; + if ((dhcp->state < 0xb) && ((0x432U >> ((uint)dhcp->state & 0x1f) & 1) != 0)) { + dhcp_set_state(dhcp,'\x04'); + p_out = dhcp_create_msg(netif,dhcp,'\x03',auStack50); + if (p_out != (pbuf *)0x0) { + uVar2 = (uint)auStack50[0]; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar2] = '9'; + options[uVar2 + 1 & 0xffff] = '\x02'; + auStack50[0] = (u16_t)((uVar2 + 2) * 0x10000 >> 0x10); + auStack50[0] = dhcp_option_short(auStack50[0],options,netif->mtu); + options[CONCAT22(extraout_var,auStack50[0])] = '7'; + options[CONCAT22(extraout_var,auStack50[0]) + 1U & 0xffff] = '\x04'; + auStack50[0] = auStack50[0] + 2; + iVar4 = 0; + do { + options[(uint)auStack50[0]] = "\x01\x03\x1c\x06"[iVar4]; + auStack50[0] = (u16_t)(((uint)auStack50[0] + 1) * 0x10000 >> 0x10); + iVar4 = iVar4 + 1; + } while (iVar4 != 4); + auStack50[0] = dhcp_option_hostname(auStack50[0],options); + dhcp_option_trailer(auStack50[0],options,p_out); + udp_sendto_if(dhcp_pcb,p_out,&ip_addr_broadcast,0x43,netif); + pbuf_free(p_out); + } + if (dhcp->tries != -1) { + dhcp->tries = dhcp->tries + '\x01'; + } + uVar2 = 10000; + if (dhcp->tries < 10) { + uVar2 = (uint)dhcp->tries * 0x3e80000 >> 0x10; + } + dhcp->request_timeout = (u16_t)((int)(uVar2 + 499) / 500); + iVar4 = (uint)dhcp->t0_timeout - (uint)dhcp->lease_used; + if (1 < iVar4) { + dhcp->t2_rebind_time = (u16_t)(iVar4 >> 1); + } + } + } + } + else { + dhcp_release_and_stop(netif); + dhcp_start(netif); + } + } + netif = netif->next; + } + return; +} + + + +void dhcp_fine_tmr(void) + +{ + char cVar1; + ushort uVar2; + netif *netif; + void *pvVar3; + + netif = netif_list; + do { + if (netif == (netif *)0x0) { + return; + } + pvVar3 = netif->client_data[0]; + if (pvVar3 != (void *)0x0) { + uVar2 = *(ushort *)((int)pvVar3 + 8); + if (uVar2 < 2) { + if (uVar2 == 1) { + *(undefined2 *)((int)pvVar3 + 8) = 0; + pvVar3 = netif->client_data[0]; + cVar1 = *(char *)((int)pvVar3 + 5); + if ((cVar1 == '\f') || (cVar1 == '\x06')) { +LAB_2303c45c: + dhcp_discover(netif); + } + else { + if (cVar1 == '\x01') { + if (*(byte *)((int)pvVar3 + 6) < 6) { + dhcp_select(netif); + } + else { + dhcp_release_and_stop(netif); + dhcp_start(netif); + } + } + else { + if (cVar1 == '\b') { + if (*(byte *)((int)pvVar3 + 6) < 2) { + dhcp_check(netif); + } + else { + dhcp_bind(netif); + } + } + else { + if (cVar1 == '\x03') { + if (1 < *(byte *)((int)pvVar3 + 6)) goto LAB_2303c45c; + dhcp_reboot(netif); + } + } + } + } + } + } + else { + *(short *)((int)pvVar3 + 8) = uVar2 - 1; + } + } + netif = netif->next; + } while( true ); +} + + + +// WARNING: Type propagation algorithm not settling + +void dhcp_stop(netif *netif) + +{ + dhcp *dhcp; + u8_t uVar1; + undefined3 extraout_var; + pbuf *p_out; + u32_t value; + uint uVar2; + u8_t *options; + u16_t options_out_len; + u16_t uStack38; + ip_addr_t aiStack36 [3]; + + dhcp = (dhcp *)netif->client_data[0]; + if ((dhcp != (dhcp *)0x0) && (dhcp->state != '\0')) { + aiStack36[0] = (ip_addr_t)(dhcp->server_ip_addr).addr; + (dhcp->offered_ip_addr).addr = 0; + (dhcp->server_ip_addr).addr = 0; + (dhcp->offered_sn_mask).addr = 0; + (dhcp->offered_gw_addr).addr = 0; + dhcp->offered_t2_rebind = 0; + dhcp->offered_t1_renew = 0; + dhcp->offered_t0_lease = 0; + dhcp->t1_renew_time = 0; + *(undefined4 *)&dhcp->t2_rebind_time = 0; + dhcp->t0_timeout = 0; + uVar1 = dhcp_supplied_address(netif); + if ((CONCAT31(extraout_var,uVar1) != 0) && + (p_out = dhcp_create_msg(netif,dhcp,'\a',&uStack38), p_out != (pbuf *)0x0)) { + uVar2 = (uint)uStack38; + options = (u8_t *)((int)p_out->payload + 0xf0); + options[uVar2] = '6'; + options[uVar2 + 1 & 0xffff] = '\x04'; + options_out_len = (u16_t)((uVar2 + 2) * 0x10000 >> 0x10); + uStack38 = options_out_len; + value = lwip_htonl((u32_t)aiStack36[0]); + uStack38 = dhcp_option_long(options_out_len,options,value); + dhcp_option_trailer(uStack38,options,p_out); + udp_sendto_if(dhcp_pcb,p_out,aiStack36,0x43,netif); + pbuf_free(p_out); + } + netif_set_addr(netif,(ip4_addr_t *)&ip_addr_any,(ip4_addr_t *)&ip_addr_any, + (ip4_addr_t *)&ip_addr_any); + dhcp_set_state(dhcp,'\0'); + if (dhcp->pcb_allocated != '\0') { + dhcp_dec_pcb_refcount(); + dhcp->pcb_allocated = '\0'; + } + } + return; +} + + + +void etharp_free_entry(int i) + +{ + pbuf *p; + + p = arp_table[i].q; + if (p != (pbuf *)0x0) { + pbuf_free(p); + arp_table[i].q = (pbuf *)0x0; + } + arp_table[i].state = '\0'; + return; +} + + + +s16_t etharp_find_entry(ip4_addr_t *ipaddr,u8_t flags,netif *netif) + +{ + ushort uVar1; + ushort uVar2; + int iVar3; + int iVar4; + int i; + undefined3 in_register_0000202d; + etharp_entry *peVar5; + int iVar6; + s16_t sVar7; + int iVar8; + uint uVar9; + int iVar10; + ushort uVar11; + ushort uVar12; + + peVar5 = arp_table; + uVar2 = 0; + uVar12 = 0; + uVar11 = 0; + iVar3 = 10; + iVar8 = 0; + iVar10 = 10; + iVar4 = 10; + iVar6 = 10; + do { + i = iVar6; + if (iVar6 == 10) { + i = iVar8; + } + if (peVar5->state != '\0') { + if ((ipaddr != (ip4_addr_t *)0x0) && (ipaddr->addr == (peVar5->ipaddr).addr)) { + if (netif == (netif *)0x0) { + return (s16_t)iVar8; + } + if (peVar5->netif == netif) { + return (s16_t)iVar8; + } + } + uVar1 = peVar5->ctime; + if (peVar5->state == '\x01') { + if (peVar5->q == (pbuf *)0x0) { + i = iVar6; + if (uVar12 <= uVar1) { + iVar4 = iVar8; + uVar12 = uVar1; + } + } + else { + i = iVar6; + if (uVar11 <= uVar1) { + iVar3 = iVar8; + uVar11 = uVar1; + } + } + } + else { + i = iVar6; + if (uVar2 <= uVar1) { + iVar10 = iVar8; + uVar2 = uVar1; + } + } + } + uVar9 = iVar8 + 1U & 0xffff; + peVar5 = peVar5 + 1; + iVar8 = (int)(short)uVar9; + iVar6 = i; + if (uVar9 == 10) { + sVar7 = -1; + if (CONCAT31(in_register_0000202d,flags) == 1) { + if (i == 10) { + i = iVar10; + if (((iVar10 == 10) && (i = iVar4, iVar4 == 10)) && (i = iVar3, iVar3 == 10)) { + return -1; + } + etharp_free_entry(i); + } + sVar7 = (s16_t)i; + if (ipaddr != (ip4_addr_t *)0x0) { + arp_table[i].ipaddr.addr = ipaddr->addr; + } + arp_table[i].ctime = 0; + arp_table[i].netif = netif; + } + return sVar7; + } + } while( true ); +} + + + +err_t etharp_raw(netif *netif,eth_addr *ethsrc_addr,eth_addr *ethdst_addr,eth_addr *hwsrc_addr, + ip4_addr_t *ipsrc_addr,eth_addr *hwdst_addr,ip4_addr_t *ipdst_addr,u16_t opcode) + +{ + undefined *puVar1; + err_t eVar2; + u16_t uVar3; + pbuf *p; + + p = pbuf_alloc(PBUF_LINK,0x1c,PBUF_RAM); + if (p == (pbuf *)0x0) { + eVar2 = -1; + lwip_stats.etharp.memerr = lwip_stats.etharp.memerr + 1; + } + else { + puVar1 = (undefined *)p->payload; + uVar3 = lwip_htons(opcode); + puVar1[6] = (char)uVar3; + puVar1[7] = (char)(uVar3 >> 8); + memcpy(puVar1 + 8,hwsrc_addr,6); + memcpy(puVar1 + 0x12,hwdst_addr,6); + memcpy(puVar1 + 0xe,ipsrc_addr,4); + memcpy(puVar1 + 0x18,ipdst_addr,4); + puVar1[1] = 1; + puVar1[2] = 8; + puVar1[4] = 6; + puVar1[5] = 4; + *puVar1 = 0; + puVar1[3] = 0; + ethernet_output(netif,p,ethsrc_addr,ethdst_addr,0x806); + lwip_stats.etharp.xmit = lwip_stats.etharp.xmit + 1; + pbuf_free(p); + eVar2 = '\0'; + } + return eVar2; +} + + + +void etharp_cleanup_netif(netif *netif) + +{ + etharp_entry *peVar1; + int i; + + peVar1 = arp_table; + i = 0; + do { + if ((peVar1->state != '\0') && (peVar1->netif == netif)) { + etharp_free_entry(i); + } + i = i + 1; + peVar1 = peVar1 + 1; + } while (i != 10); + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void etharp_input(pbuf *p,netif *netif) + +{ + bool bVar1; + short *psVar2; + u8_t uVar3; + s16_t sVar4; + undefined3 extraout_var; + short extraout_var_00; + ip4_addr_t iVar5; + eth_addr *dst; + u8_t flags; + pbuf *p_00; + ip4_addr_t iStack56; + ip4_addr_t sipaddr; + ip4_addr_t dipaddr; + + if (netif != (netif *)0x0) { + psVar2 = (short *)p->payload; + if ((((*psVar2 == 0x100) && (*(char *)(psVar2 + 2) == '\x06')) && + (*(char *)((int)psVar2 + 5) == '\x04')) && (psVar2[1] == 8)) { + lwip_stats.etharp.recv = lwip_stats.etharp.recv + 1; + memcpy(&iStack56,psVar2 + 7,4); + memcpy(&sipaddr,psVar2 + 0xc,4); + iVar5 = (ip4_addr_t)(netif->ip_addr).addr; + dst = (eth_addr *)(psVar2 + 4); + if ((iVar5 == (ip4_addr_t)0x0) || (iVar5 != (ip4_addr_t)sipaddr)) { + bVar1 = false; + flags = '\x02'; + } + else { + bVar1 = true; + flags = '\x01'; + } + if (((iStack56 != (ip4_addr_t)0x0) && + (uVar3 = ip4_addr_isbroadcast_u32((u32_t)iStack56,netif), + CONCAT31(extraout_var,uVar3) == 0)) && (((uint)iStack56 & 0xf0) != 0xe0)) { + sVar4 = etharp_find_entry(&iStack56,flags,netif); + _sVar4 = CONCAT22(extraout_var_00,sVar4); + if (-1 < extraout_var_00) { + arp_table[_sVar4].state = '\x02'; + arp_table[_sVar4].netif = netif; + memcpy(&arp_table[_sVar4].ethaddr,dst,6); + p_00 = arp_table[_sVar4].q; + arp_table[_sVar4].ctime = 0; + if (p_00 != (pbuf *)0x0) { + arp_table[_sVar4].q = (pbuf *)0x0; + ethernet_output(netif,p_00,(eth_addr *)netif->hwaddr,dst,0x800); + pbuf_free(p_00); + } + } + } + if (psVar2[3] == 0x100) { + if (bVar1) { + etharp_raw(netif,(eth_addr *)netif->hwaddr,dst,(eth_addr *)netif->hwaddr, + (ip4_addr_t *)&netif->ip_addr,dst,&iStack56,2); + } + } + else { + if (psVar2[3] == 0x200) { + dhcp_arp_reply(netif,&iStack56); + } + else { + lwip_stats.etharp.err = lwip_stats.etharp.err + 1; + } + } + } + else { + lwip_stats.etharp.proterr = lwip_stats.etharp.proterr + 1; + lwip_stats.etharp.drop = lwip_stats.etharp.drop + 1; + } + pbuf_free(p); + return; + } + return; +} + + + +err_t etharp_request(netif *netif,ip4_addr_t *ipaddr) + +{ + err_t eVar1; + + eVar1 = etharp_raw(netif,(eth_addr *)netif->hwaddr,ðbroadcast,(eth_addr *)netif->hwaddr, + (ip4_addr_t *)&netif->ip_addr,ðzero,ipaddr,1); + return eVar1; +} + + + +void etharp_tmr(void) + +{ + u8_t uVar1; + etharp_entry *peVar2; + int i; + uint uVar3; + uint uVar4; + + peVar2 = arp_table; + i = 0; + do { + uVar1 = peVar2->state; + if (uVar1 != '\0') { + uVar3 = (uint)peVar2->ctime + 1; + uVar4 = uVar3 & 0xffff; + peVar2->ctime = (u16_t)(uVar3 * 0x10000 >> 0x10); + if (uVar4 < 300) { + if (uVar1 == '\x01') { + if (4 < uVar4) goto LAB_2303c930; + etharp_request(peVar2->netif,&peVar2->ipaddr); + } + else { + if (uVar1 == '\x03') { + peVar2->state = '\x04'; + } + else { + if (uVar1 == '\x04') { + peVar2->state = '\x02'; + } + } + } + } + else { +LAB_2303c930: + etharp_free_entry(i); + } + } + i = i + 1; + peVar2 = peVar2 + 1; + if (i == 10) { + return; + } + } while( true ); +} + + + +err_t etharp_output_to_arp_index(netif *netif,pbuf *q,netif_addr_idx_t arp_idx) + +{ + err_t eVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 in_register_00002031; + int iVar2; + eth_addr *ethsrc_addr; + + iVar2 = CONCAT31(in_register_00002031,arp_idx); + ethsrc_addr = (eth_addr *)netif->hwaddr; + if (arp_table[iVar2].state == '\x02') { + if (arp_table[iVar2].ctime < 0x11d) { + if (arp_table[iVar2].ctime < 0x10e) goto LAB_2303c9c8; + eVar1 = etharp_raw(netif,ethsrc_addr,&arp_table[iVar2].ethaddr,ethsrc_addr, + (ip4_addr_t *)&netif->ip_addr,ðzero,&arp_table[iVar2].ipaddr,1); + _eVar1 = CONCAT31(extraout_var_00,eVar1); + } + else { + eVar1 = etharp_request(netif,&arp_table[iVar2].ipaddr); + _eVar1 = CONCAT31(extraout_var,eVar1); + } + if (_eVar1 == 0) { + arp_table[iVar2].state = '\x03'; + } + } +LAB_2303c9c8: + eVar1 = ethernet_output(netif,q,ethsrc_addr,&arp_table[iVar2].ethaddr,0x800); + return eVar1; +} + + + +err_t etharp_query(netif *netif,ip4_addr_t *ipaddr,pbuf *q) + +{ + pbuf **pppVar1; + u8_t uVar2; + err_t eVar3; + ushort uVar4; + undefined3 extraout_var; + short extraout_var_00; + pbuf *ppVar5; + uint uVar6; + + uVar2 = ip4_addr_isbroadcast_u32(ipaddr->addr,netif); + if (((CONCAT31(extraout_var,uVar2) != 0) || ((ipaddr->addr & 0xf0) == 0xe0)) || + (ipaddr->addr == 0)) { + return -0x10; + } + uVar4 = etharp_find_entry(ipaddr,'\x01',netif); + if (extraout_var_00 < 0) { + if (q != (pbuf *)0x0) { + lwip_stats.etharp.memerr = lwip_stats.etharp.memerr + 1; + } + return (err_t)uVar4; + } + uVar6 = (uint)uVar4 & 0xff; + if (arp_table[uVar6].state == '\0') { + arp_table[uVar6].state = '\x01'; + arp_table[uVar6].netif = netif; + } + else { + eVar3 = -1; + if (q != (pbuf *)0x0) goto LAB_2303caa6; + } + eVar3 = etharp_request(netif,ipaddr); + if (q == (pbuf *)0x0) { + return eVar3; + } +LAB_2303caa6: + if (1 < arp_table[uVar6].state) { + etharp_cached_entry = (netif_addr_idx_t)uVar6; + eVar3 = ethernet_output(netif,q,(eth_addr *)netif->hwaddr,&arp_table[uVar6].ethaddr,0x800); + return eVar3; + } + ppVar5 = q; + if (arp_table[uVar6].state == 1) { + do { + if ((ppVar5->type_internal & 0x40) != 0) { + q = pbuf_clone(PBUF_LINK,PBUF_RAM,q); + if (q == (pbuf *)0x0) { + lwip_stats.etharp.memerr = lwip_stats.etharp.memerr + 1; + return -1; + } + goto LAB_2303cb0c; + } + pppVar1 = &ppVar5->next; + ppVar5 = *pppVar1; + } while (*pppVar1 != (pbuf *)0x0); + pbuf_ref(q); +LAB_2303cb0c: + if (arp_table[uVar6].q != (pbuf *)0x0) { + pbuf_free(arp_table[uVar6].q); + } + arp_table[uVar6].q = q; + eVar3 = '\0'; + } + return eVar3; +} + + + +// WARNING: Variable defined which should be unmapped: mcastaddr + +err_t etharp_output(netif *netif,pbuf *q,ip4_addr_t *ipaddr) + +{ + netif_addr_idx_t nVar1; + u8_t uVar2; + err_t eVar3; + undefined3 extraout_var; + eth_addr *dst; + uint uVar4; + uint uVar5; + etharp_entry *peVar6; + undefined2 uStack24; + u8_t uStack22; + byte bStack21; + eth_addr mcastaddr; + + uVar2 = ip4_addr_isbroadcast_u32(ipaddr->addr,netif); + uVar4 = CONCAT31(extraout_var,uVar2); + if (uVar4 == 0) { + uVar5 = ipaddr->addr; + if ((uVar5 & 0xf0) != 0xe0) { + if (((((netif->ip_addr).addr ^ uVar5) & (netif->netmask).addr) != 0) && + ((uVar5 & 0xffff) != 0xfea9)) { + if ((netif->gw).addr == 0) { + return -4; + } + ipaddr = (ip4_addr_t *)&netif->gw; + } + uVar5 = (uint)etharp_cached_entry; + peVar6 = arp_table; + if (((arp_table[uVar5].state < 2) || (arp_table[uVar5].netif != netif)) || + (ipaddr->addr != arp_table[uVar5].ipaddr.addr)) { + while (((peVar6->state < 2 || (peVar6->netif != netif)) || + (nVar1 = (netif_addr_idx_t)uVar4, ipaddr->addr != (peVar6->ipaddr).addr))) { + uVar4 = uVar4 + 1 & 0xff; + peVar6 = peVar6 + 1; + if (uVar4 == 10) { + eVar3 = etharp_query(netif,ipaddr,q); + return eVar3; + } + } + } + else { + lwip_stats.etharp.cachehit = lwip_stats.etharp.cachehit + 1; + nVar1 = etharp_cached_entry; + } + etharp_cached_entry = nVar1; + eVar3 = etharp_output_to_arp_index(netif,q,etharp_cached_entry); + return eVar3; + } + uStack24 = 1; + uStack22 = '^'; + dst = (eth_addr *)&uStack24; + bStack21 = *(byte *)((int)&ipaddr->addr + 1) & 0x7f; + mcastaddr.addr[0] = *(u8_t *)((int)&ipaddr->addr + 2); + mcastaddr.addr[1] = *(u8_t *)((int)&ipaddr->addr + 3); + } + else { + dst = ðbroadcast; + } + eVar3 = ethernet_output(netif,q,(eth_addr *)netif->hwaddr,dst,0x800); + return eVar3; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void igmp_send(netif *netif,igmp_group *group,u8_t type) + +{ + u8_t *dataptr; + u16_t uVar1; + pbuf *p; + undefined3 in_register_00002031; + ip4_addr_t *dest; + u8_t uVar2; + u8_t uVar3; + u8_t uVar4; + u32_t uVar5; + ip4_addr_t iStack40; + ip4_addr_t src; + u16_t ra [2]; + + iStack40 = (ip4_addr_t)0; + p = pbuf_alloc(PBUF_TRANSPORT,8,PBUF_RAM); + if (p == (pbuf *)0x0) { + lwip_stats.igmp.memerr = lwip_stats.igmp.memerr + 1; + } + else { + iStack40 = (ip4_addr_t)(netif->ip_addr).addr; + uVar5 = (group->group_address).addr; + dataptr = (u8_t *)p->payload; + uVar4 = (u8_t)(uVar5 >> 0x18); + uVar2 = (u8_t)(uVar5 >> 8); + uVar3 = (u8_t)(uVar5 >> 0x10); + if (CONCAT31(in_register_00002031,type) == 0x16) { + dataptr[7] = uVar4; + dataptr[4] = (u8_t)uVar5; + dataptr[5] = uVar2; + dataptr[6] = uVar3; + dest = &group->group_address; + group->last_reporter_flag = '\x01'; + } + else { + dataptr[4] = (u8_t)uVar5; + dataptr[5] = uVar2; + dataptr[6] = uVar3; + dataptr[7] = uVar4; + dest = &allrouters; + } + *dataptr = type; + dataptr[1] = '\0'; + dataptr[2] = '\0'; + dataptr[3] = '\0'; + uVar1 = inet_chksum(dataptr,8); + dataptr[2] = (u8_t)uVar1; + dataptr[3] = (u8_t)(uVar1 >> 8); + src = 0x494; + lwip_stats.igmp.xmit = lwip_stats.igmp.xmit + 1; + ip4_output_if_opt(p,&iStack40,dest,'\x01','\0','\x02',netif,&src,_DAT_00000010); + pbuf_free(p); + } + return; +} + + + +void igmp_delaying_member(igmp_group *group,u8_t maxresp) + +{ + uint uVar1; + undefined3 in_register_0000202d; + uint uVar2; + + uVar2 = CONCAT31(in_register_0000202d,maxresp); + if ((group->group_state != '\x02') && + ((group->group_state != '\x01' || ((group->timer != 0 && (group->timer <= uVar2)))))) { + return; + } + if (2 < uVar2) { + uVar1 = bl_rand(); + group->timer = (u16_t)(uVar1 % uVar2); + if (uVar1 % uVar2 != 0) goto LAB_2303cdba; + } + group->timer = 1; +LAB_2303cdba: + group->group_state = '\x01'; + return; +} + + + +void igmp_init(void) + +{ + allrouters = 0x20000e0; + allsystems = 0x10000e0; + return; +} + + + +err_t igmp_stop(netif *netif) + +{ + void **mem; + void *pvVar1; + + mem = (void **)netif->client_data[1]; + netif->client_data[1] = (void *)0x0; + while (mem != (void **)0x0) { + pvVar1 = *mem; + if (netif->igmp_mac_filter != (netif_igmp_mac_filter_fn *)0x0) { + (*netif->igmp_mac_filter)(netif,(ip4_addr_t *)(mem + 1),NETIF_DEL_MAC_FILTER); + } + memp_free(MEMP_IGMP_GROUP,mem); + mem = (void **)pvVar1; + } + return '\0'; +} + + + +// WARNING: Type propagation algorithm not settling + +void igmp_report_groups(netif *netif) + +{ + igmp_group *group; + + if ((igmp_group *)netif->client_data[1] != (igmp_group *)0x0) { + group = ((igmp_group *)netif->client_data[1])->next; + while (group != (igmp_group *)0x0) { + igmp_delaying_member(group,'\x05'); + group = group->next; + } + return; + } + return; +} + + + +igmp_group * igmp_lookfor_group(netif *ifp,ip4_addr_t *addr) + +{ + igmp_group *piVar1; + + piVar1 = (igmp_group *)ifp->client_data[1]; + while ((piVar1 != (igmp_group *)0x0 && ((piVar1->group_address).addr != addr->addr))) { + piVar1 = piVar1->next; + } + return piVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +igmp_group * igmp_lookup_group(netif *ifp,ip4_addr_t *addr) + +{ + igmp_group *piVar1; + igmp_group *piVar2; + u32_t uVar3; + + piVar2 = igmp_lookfor_group(ifp,addr); + if (piVar2 == (igmp_group *)0x0) { + piVar1 = (igmp_group *)ifp->client_data[1]; + piVar2 = (igmp_group *)memp_malloc(MEMP_IGMP_GROUP); + if (piVar2 != (igmp_group *)0x0) { + uVar3 = 0; + if (addr != (ip4_addr_t *)0x0) { + uVar3 = addr->addr; + } + (piVar2->group_address).addr = uVar3; + *(undefined4 *)&piVar2->last_reporter_flag = 0; + piVar2->use = '\0'; + if (piVar1 == (igmp_group *)0x0) { + piVar2->next = (igmp_group *)0x0; + *(igmp_group **)(ifp->client_data + 1) = piVar2; + } + else { + piVar2->next = piVar1->next; + piVar1->next = piVar2; + } + } + } + return piVar2; +} + + + +err_t igmp_start(netif *netif) + +{ + err_t eVar1; + igmp_group *piVar2; + + piVar2 = igmp_lookup_group(netif,&allsystems); + if (piVar2 == (igmp_group *)0x0) { + eVar1 = -1; + } + else { + piVar2->group_state = '\x02'; + piVar2->use = piVar2->use + '\x01'; + eVar1 = '\0'; + if (netif->igmp_mac_filter != (netif_igmp_mac_filter_fn *)0x0) { + (*netif->igmp_mac_filter)(netif,&allsystems,NETIF_ADD_MAC_FILTER); + eVar1 = '\0'; + } + } + return eVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +void igmp_input(pbuf *p,netif *inp,ip4_addr_t *dest) + +{ + ip4_addr_t iVar1; + char *dataptr; + u16_t uVar2; + undefined2 extraout_var; + igmp_group *group; + ip4_addr_t iStack36; + ip4_addr_t groupaddr; + + lwip_stats.igmp.recv = lwip_stats.igmp.recv + 1; + if (p->len < 8) { + pbuf_free(p); + lwip_stats.igmp.lenerr = lwip_stats.igmp.lenerr + 1; + return; + } + dataptr = (char *)p->payload; + uVar2 = inet_chksum(dataptr,p->len); + if (CONCAT22(extraout_var,uVar2) != 0) { + pbuf_free(p); + lwip_stats.igmp.chkerr = lwip_stats.igmp.chkerr + 1; + return; + } + group = igmp_lookfor_group(inp,dest); + if (group == (igmp_group *)0x0) { + pbuf_free(p); + lwip_stats.igmp.drop = lwip_stats.igmp.drop + 1; + return; + } + if (*dataptr == '\x11') { + iVar1 = (ip4_addr_t)((ip4_addr_t *)(dataptr + 4))->addr; + if (dest->addr == allsystems) { + if (iVar1 == (ip4_addr_t)0x0) { + if (dataptr[1] == '\0') { + lwip_stats.igmp.rx_v1 = lwip_stats.igmp.rx_v1 + 1; + dataptr[1] = '\n'; + } + else { + lwip_stats.igmp.rx_general = lwip_stats.igmp.rx_general + 1; + } + if ((igmp_group *)inp->client_data[1] != (igmp_group *)0x0) { + group = ((igmp_group *)inp->client_data[1])->next; + while (group != (igmp_group *)0x0) { + igmp_delaying_member(group,dataptr[1]); + group = group->next; + } + } + goto LAB_2303d002; + } + iStack36 = iVar1; + group = igmp_lookfor_group(inp,&iStack36); + if (group == (igmp_group *)0x0) { + lwip_stats.igmp.drop = lwip_stats.igmp.drop + 1; + goto LAB_2303d002; + } + } + else { + if (iVar1 == (ip4_addr_t)0x0) goto LAB_2303cfa4; + } + lwip_stats.igmp.rx_group = lwip_stats.igmp.rx_group + 1; + igmp_delaying_member(group,dataptr[1]); + } + else { + if (*dataptr == '\x16') { + lwip_stats.igmp.rx_report = lwip_stats.igmp.rx_report + 1; + if (group->group_state == '\x01') { + *(undefined4 *)&group->last_reporter_flag = 0x200; + } + goto LAB_2303d002; + } +LAB_2303cfa4: + lwip_stats.igmp.proterr = lwip_stats.igmp.proterr + 1; + } +LAB_2303d002: + pbuf_free(p); + return; +} + + + +void igmp_tmr(void) + +{ + igmp_group *group; + netif *netif; + uint uVar1; + + netif = netif_list; + while (netif != (netif *)0x0) { + group = (igmp_group *)netif->client_data[1]; + while (group != (igmp_group *)0x0) { + if ((((group->timer != 0) && + (uVar1 = (uint)group->timer - 1, group->timer = (u16_t)(uVar1 * 0x10000 >> 0x10), + (uVar1 & 0xffff) == 0)) && (group->group_state == '\x01')) && + ((group->group_address).addr != allsystems)) { + group->group_state = '\x02'; + lwip_stats.igmp.tx_report = lwip_stats.igmp.tx_report + 1; + igmp_send(netif,group,'\x16'); + } + group = group->next; + } + netif = netif->next; + } + return; +} + + + +int ip4_input_accept(netif *netif) + +{ + u8_t uVar1; + int iVar2; + undefined3 extraout_var; + u32_t uVar3; + + if ((netif->flags & 1) == 0) { + return 0; + } + uVar3 = (netif->ip_addr).addr; + iVar2 = 0; + if (uVar3 != 0) { + iVar2 = 1; + if (uVar3 != ip_data.current_iphdr_dest) { + uVar1 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_dest,netif); + return (uint)(CONCAT31(extraout_var,uVar1) != 0); + } + } + return iVar2; +} + + + +netif * ip4_route(ip4_addr_t *dest) + +{ + byte bVar1; + netif *pnVar2; + netif *pnVar3; + uint uVar4; + uint uVar5; + + uVar5 = dest->addr; + pnVar2 = netif_list; + if (((uVar5 & 0xf0) != 0xe0) || + (pnVar3 = ip4_default_multicast_netif, ip4_default_multicast_netif == (netif *)0x0)) { + while (pnVar2 != (netif *)0x0) { + bVar1 = pnVar2->flags; + if ((((bVar1 & 1) != 0) && ((bVar1 >> 2 & 1) != 0)) && + (uVar4 = (pnVar2->ip_addr).addr, uVar4 != 0)) { + if (((uVar4 ^ uVar5) & (pnVar2->netmask).addr) == 0) { + return pnVar2; + } + if (((bVar1 & 2) == 0) && (uVar5 == (pnVar2->gw).addr)) { + return pnVar2; + } + } + pnVar2 = pnVar2->next; + } + if (((netif_default == (netif *)0x0) || ((netif_default->flags & 5) != 5)) || + (((netif_default->ip_addr).addr == 0 || (pnVar3 = netif_default, (uVar5 & 0xff) == 0x7f)))) { + lwip_stats.ip.rterr = lwip_stats.ip.rterr + 1; + return (netif *)0x0; + } + } + return pnVar3; +} + + + +err_t ip4_input(pbuf *p,netif *inp) + +{ + byte bVar1; + uint uVar2; + u8_t uVar3; + raw_input_state_t rVar4; + u16_t new_len; + undefined2 extraout_var_02; + undefined2 extraout_var_03; + igmp_group *piVar5; + undefined3 extraout_var; + int iVar6; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + ip_hdr *dataptr; + netif *netif; + uint uVar7; + + lwip_stats.ip.recv = lwip_stats.ip.recv + 1; + dataptr = (ip_hdr *)p->payload; + bVar1 = dataptr->_v_hl; + if (bVar1 >> 4 != 4) { + pbuf_free(p); + lwip_stats.ip.drop = lwip_stats.ip.drop + 1; + lwip_stats.ip.err = lwip_stats.ip.err + 1; + return '\0'; + } + new_len = lwip_htons(dataptr->_len); + uVar7 = (uint)bVar1 & 0xf; + uVar2 = (uVar7 << 0x12) >> 0x10; + if (CONCAT22(extraout_var_02,new_len) < (uint)p->tot_len) { + pbuf_realloc(p,new_len); + } + if (((p->len < uVar2) || ((uint)p->tot_len < CONCAT22(extraout_var_02,new_len))) || (uVar2 < 0x14) + ) { + pbuf_free(p); + lwip_stats.ip.lenerr = lwip_stats.ip.lenerr + 1; + goto LAB_2303d27e; + } + new_len = inet_chksum(dataptr,(u16_t)((uVar7 << 0x12) >> 0x10)); + if (CONCAT22(extraout_var_03,new_len) != 0) { + pbuf_free(p); + lwip_stats.ip.chkerr = lwip_stats.ip.chkerr + 1; + goto LAB_2303d27e; + } + ip_data.current_iphdr_dest = (dataptr->dest).addr; + ip_data.current_iphdr_src = (dataptr->src).addr; + netif = inp; + if ((ip_data.current_iphdr_dest & 0xf0) == 0xe0) { + if (((inp->flags & 0x20) == 0) || + (piVar5 = igmp_lookfor_group(inp,(ip4_addr_t *)&ip_data.current_iphdr_dest), + piVar5 == (igmp_group *)0x0)) goto LAB_2303d304; + if ((ip_data.current_iphdr_dest != 0x10000e0) || (ip_data.current_iphdr_src != 0)) + goto LAB_2303d334; + } + else { + iVar6 = ip4_input_accept(inp); + if (iVar6 == 0) { + netif = netif_list; + if ((char)ip_data.current_iphdr_dest.addr != '\x7f') { + while (netif != (netif *)0x0) { + if ((netif != inp) && (iVar6 = ip4_input_accept(netif), iVar6 != 0)) goto LAB_2303d334; + netif = netif->next; + } + } + } + else { + if (inp != (netif *)0x0) goto LAB_2303d334; + } +LAB_2303d304: + if ((dataptr->_proto != '\x11') || (netif = inp, (&dataptr->_len)[uVar7 * 2] != 0x4400)) { + netif = (netif *)0x0; +LAB_2303d334: + if ((ip_data.current_iphdr_src != 0) && + ((uVar3 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_src,inp), + CONCAT31(extraout_var,uVar3) != 0 || ((ip_data.current_iphdr_src & 0xf0) == 0xe0)))) { + pbuf_free(p); + goto LAB_2303d27e; + } + } + if (netif == (netif *)0x0) { + lwip_stats.ip.drop = lwip_stats.ip.drop + 1; + pbuf_free(p); + return '\0'; + } + } + if (((uint)*(byte *)&dataptr->_offset & 0x3f | (uint)*(byte *)((int)&dataptr->_offset + 1) << 8) + == 0) { + ip_data.current_ip_header_tot_len = (u16_t)(((uint)dataptr->_v_hl & 0xf) << 2); + ip_data.current_netif = netif; + ip_data.current_input_netif = inp; + ip_data.current_ip4_header = dataptr; + rVar4 = raw_input(p,inp); + if (CONCAT31(extraout_var_00,rVar4) != 1) { + pbuf_remove_header(p,uVar7 * 4); + bVar1 = dataptr->_proto; + if (bVar1 == 2) { + igmp_input(p,inp,(ip4_addr_t *)&ip_data.current_iphdr_dest); + } + else { + if (bVar1 < 3) { + if (bVar1 == 1) { + icmp_input(p,inp); + ip_data.current_netif = (netif *)0x0; + ip_data.current_input_netif = (netif *)0x0; + ip_data.current_ip4_header = (ip_hdr *)0x0; + ip_data.current_ip_header_tot_len = 0; + ip_data.current_iphdr_src = 0; + ip_data.current_iphdr_dest = 0; + return '\0'; + } + } + else { + if (bVar1 == 6) { + tcp_input(p,inp); + ip_data.current_netif = (netif *)0x0; + ip_data.current_input_netif = (netif *)0x0; + ip_data.current_ip4_header = (ip_hdr *)0x0; + ip_data.current_ip_header_tot_len = 0; + ip_data.current_iphdr_src = 0; + ip_data.current_iphdr_dest = 0; + return '\0'; + } + if (bVar1 == 0x11) { + udp_input(p,inp); + ip_data.current_netif = (netif *)0x0; + ip_data.current_input_netif = (netif *)0x0; + ip_data.current_ip4_header = (ip_hdr *)0x0; + ip_data.current_ip_header_tot_len = 0; + ip_data.current_iphdr_src = 0; + ip_data.current_iphdr_dest = 0; + return '\0'; + } + } + if (CONCAT31(extraout_var_00,rVar4) != 2) { + uVar3 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_dest,netif); + if ((CONCAT31(extraout_var_01,uVar3) == 0) && + ((ip_data.current_iphdr_dest & 0xf0) != 0xe0)) { + pbuf_header_force(p,(s16_t)(uVar7 * 4)); + icmp_dest_unreach(p,ICMP_DUR_PROTO); + } + lwip_stats.ip.proterr = lwip_stats.ip.proterr + 1; + lwip_stats.ip.drop = lwip_stats.ip.drop + 1; + } + pbuf_free(p); + } + } + ip_data.current_netif = (netif *)0x0; + ip_data.current_input_netif = (netif *)0x0; + ip_data.current_ip4_header = (ip_hdr *)0x0; + ip_data.current_ip_header_tot_len = 0; + ip_data.current_iphdr_src = 0; + ip_data.current_iphdr_dest = 0; + return '\0'; + } + pbuf_free(p); + lwip_stats.ip.opterr = lwip_stats.ip.opterr + 1; +LAB_2303d27e: + lwip_stats.ip.drop = lwip_stats.ip.drop + 1; + return '\0'; +} + + + +// WARNING: Type propagation algorithm not settling + +err_t ip4_output_if_opt_src + (pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto,netif *netif, + void *ip_options,u16_t optlen) + +{ + uint header_size_increment; + undefined *puVar1; + uint uVar2; + u8_t uVar3; + err_t eVar4; + u16_t uVar5; + u16_t n; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined2 extraout_var_01; + undefined2 extraout_var_02; + undefined3 in_register_00002035; + undefined3 in_register_00002039; + int iVar6; + undefined3 in_register_0000203d; + int iVar7; + uint uVar8; + uint __n; + int iVar9; + ushort in_stack_00000000; + ip4_addr_t iStack52; + ip4_addr_t dest_addr; + + __n = (uint)in_stack_00000000; + if (dest == (ip4_addr_t *)0x0) { + if (0x13 < p->len) { + dest = &iStack52; + iStack52 = (ip4_addr_t)((ip4_addr_t *)((int)p->payload + 0x10))->addr; + goto LAB_2303d6b6; + } + } + else { + if (in_stack_00000000 == 0) { + uVar2 = 0x14; + iVar9 = 0; + } + else { + if (0x28 < in_stack_00000000) { + lwip_stats.ip.err = lwip_stats.ip.err + 1; + return -6; + } + header_size_increment = __n + 3 & 0xfffc; + uVar3 = pbuf_add_header(p,header_size_increment); + uVar2 = header_size_increment + 0x14 & 0xffff; + if (CONCAT31(extraout_var,uVar3) != 0) goto LAB_2303d54c; + memcpy(p->payload,ip_options,__n); + if (__n < header_size_increment) { + memset((void *)((int)p->payload + __n),0,header_size_increment - __n); + } + iVar7 = 0; + iVar9 = 0; + do { + iVar6 = iVar7 * 2; + iVar7 = iVar7 + 1; + iVar9 = iVar9 + (uint)*(ushort *)(iVar6 + (int)p->payload); + } while (iVar7 < (int)(header_size_increment >> 1)); + } + uVar3 = pbuf_add_header(p,0x14); + if (CONCAT31(extraout_var_00,uVar3) == 0) { + puVar1 = (undefined *)p->payload; + puVar1[8] = ttl; + puVar1[9] = proto; + header_size_increment = dest->addr; + uVar8 = CONCAT31(in_register_00002035,ttl) << 8 | CONCAT31(in_register_0000203d,proto); + puVar1[0x10] = (char)header_size_increment; + puVar1[0x11] = (char)(header_size_increment >> 8); + puVar1[0x12] = (char)(header_size_increment >> 0x10); + __n = uVar2 >> 2 & 0xff | 0x40; + *puVar1 = (char)__n; + __n = __n << 8 | CONCAT31(in_register_00002039,tos); + puVar1[0x13] = (char)(header_size_increment >> 0x18); + puVar1[1] = tos; + uVar5 = lwip_htons(p->tot_len); + puVar1[2] = (char)uVar5; + n = ip_id; + puVar1[3] = (char)(uVar5 >> 8); + puVar1[6] = 0; + puVar1[7] = 0; + n = lwip_htons(n); + puVar1[5] = (char)(n >> 8); + puVar1[4] = (char)n; + ip_id = ip_id + 1; + if (src == (ip4_addr_t *)0x0) { + uVar2 = 0; + } + else { + uVar2 = src->addr; + } + puVar1[0xf] = (char)(uVar2 >> 0x18); + puVar1[0xc] = (char)uVar2; + puVar1[0xd] = (char)(uVar2 >> 8); + __n = (uVar2 & 0xffff) + + CONCAT22(extraout_var_02,n) + + (((int)__n >> 8 | __n << 8) & 0xffff) + + ((uVar8 << 8 | (int)uVar8 >> 8) & 0xffff) + + (header_size_increment & 0xffff) + (header_size_increment >> 0x10) + iVar9 + + CONCAT22(extraout_var_01,uVar5) + (uVar2 >> 0x10); + puVar1[0xe] = (char)(uVar2 >> 0x10); + __n = (__n & 0xffff) + (__n >> 0x10); + __n = ~((__n >> 0x10) + __n); + puVar1[10] = (char)__n; + puVar1[0xb] = (char)(__n >> 8); +LAB_2303d6b6: + lwip_stats.ip.xmit = lwip_stats.ip.xmit + 1; + eVar4 = (*netif->output)(netif,p,dest); + return eVar4; + } + } +LAB_2303d54c: + lwip_stats.ip.err = lwip_stats.ip.err + 1; + return -2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +err_t ip4_output_if_opt(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto, + netif *netif,void *ip_options,u16_t optlen) + +{ + err_t eVar1; + + if ((dest != (ip4_addr_t *)0x0) && ((src == (ip4_addr_t *)0x0 || (src->addr == 0)))) { + src = (ip4_addr_t *)&netif->ip_addr; + } + eVar1 = ip4_output_if_opt_src(p,src,dest,ttl,tos,proto,netif,ip_options,optlen); + return eVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +err_t ip4_output_if(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto, + netif *netif) + +{ + err_t eVar1; + + eVar1 = ip4_output_if_opt(p,src,dest,ttl,tos,proto,netif,(void *)0x0,_DAT_00000010); + return eVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +err_t ip4_output_if_src(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto, + netif *netif) + +{ + err_t eVar1; + + eVar1 = ip4_output_if_opt_src(p,src,dest,ttl,tos,proto,netif,(void *)0x0,_DAT_00000010); + return eVar1; +} + + + +u8_t ip4_addr_isbroadcast_u32(u32_t addr,netif *netif) + +{ + byte bVar1; + uint uVar2; + uint uVar3; + + if (addr - 1 < 0xfffffffe) { + bVar1 = netif->flags & 2; + if ((netif->flags & 2) != 0) { + uVar3 = (netif->ip_addr).addr; + bVar1 = 0; + if ((uVar3 != addr) && (uVar2 = (netif->netmask).addr, ((uVar3 ^ addr) & uVar2) == 0)) { + uVar2 = ~uVar2; + return (u8_t)((uVar2 & addr) == uVar2); + } + } + } + else { + bVar1 = 1; + } + return (u8_t)bVar1; +} + + + +int ip4addr_aton(char *cp,ip4_addr_t *addr) + +{ + byte bVar1; + int iVar2; + u32_t n; + u32_t *puVar3; + uint uVar4; + uint uVar5; + int iVar6; + u32_t uStack32; + u32_t parts [4]; + + bVar1 = *cp; + puVar3 = &uStack32; +LAB_2303d7b2: + uVar5 = (uint)bVar1; + if ((_ctype_[uVar5 + 1] & 4) == 0) { + return 0; + } + iVar6 = 10; + if (bVar1 == 0x30) { + uVar5 = (uint)(byte)cp[1]; + if ((uVar5 & 0xdf) == 0x58) { + uVar5 = (uint)(byte)cp[2]; + iVar6 = 0x10; + cp = cp + 2; + } + else { + cp = cp + 1; + iVar6 = 8; + } + } + n = 0; + do { + bVar1 = _ctype_[uVar5 + 1]; + if ((bVar1 & 4) == 0) { + if ((iVar6 != 0x10) || ((bVar1 & 0x44) == 0)) break; + iVar2 = 0x61; + if ((bVar1 & 3) != 2) { + iVar2 = 0x41; + } + n = n << 4 | (uVar5 + 10) - iVar2; + } + else { + n = (iVar6 * n + uVar5) - 0x30; + } + uVar5 = (uint)(byte)cp[1]; + cp = cp + 1; + } while( true ); + if (uVar5 == 0x2e) { + if (puVar3 == parts + 2) { + return 0; + } + *puVar3 = n; + bVar1 = cp[1]; + cp = cp + 1; + puVar3 = puVar3 + 1; + goto LAB_2303d7b2; + } + if ((uVar5 != 0) && ((bVar1 & 8) == 0)) { + return 0; + } + iVar6 = (int)((int)puVar3 - (int)&uStack32) >> 2; + iVar2 = iVar6 + 1; + if (iVar2 == 2) { + if (0xffffff < n) { + return 0; + } + if (0xff < uStack32) { + return 0; + } + uVar5 = uStack32 << 0x18; + } + else { + if (iVar2 < 3) { + if (iVar6 == -1) { + return 0; + } + goto LAB_2303d860; + } + if (iVar2 == 3) { + if (0xffff < n) { + return 0; + } + if (0xff < uStack32) { + return 0; + } + if (0xff < parts[0]) { + return 0; + } + uVar5 = uStack32 << 0x18; + uVar4 = parts[0] << 0x10; + } + else { + if (iVar2 != 4) goto LAB_2303d860; + if (0xff < n) { + return 0; + } + if (0xff < uStack32) { + return 0; + } + if (0xff < parts[0]) { + return 0; + } + if (0xff < parts[1]) { + return 0; + } + uVar5 = uStack32 << 0x18 | parts[0] << 0x10; + uVar4 = parts[1] << 8; + } + uVar5 = uVar5 | uVar4; + } + n = n | uVar5; +LAB_2303d860: + if (addr != (ip4_addr_t *)0x0) { + n = lwip_htonl(n); + addr->addr = n; + return 1; + } + return 1; +} + + + +u32_t ipaddr_addr(char *cp) + +{ + int iVar1; + ip4_addr_t iStack20; + ip4_addr_t val; + + iVar1 = ip4addr_aton(cp,&iStack20); + if (iVar1 == 0) { + iStack20 = (ip4_addr_t)0xffffffff; + } + return (u32_t)iStack20; +} + + + +// WARNING: Could not reconcile some variable overlaps + +char * ip4addr_ntoa_r(ip4_addr_t *addr,char *buf,int buflen) + +{ + bool bVar1; + uint uVar2; + int iVar3; + int iVar4; + byte *pbVar5; + uint uVar6; + char *pcVar7; + uint uVar8; + uint uVar9; + char *pcVar10; + u32_t s_addr; + char local_8 [4]; + char inv [3]; + + _inv = addr->addr; + iVar3 = 0; + pbVar5 = (byte *)inv; + pcVar10 = buf; + while( true ) { + uVar2 = 0; + uVar9 = (uint)*pbVar5; + do { + uVar8 = uVar2; + uVar6 = uVar9 / 10; + local_8[uVar8] = (char)(uVar9 % 10) + '0'; + bVar1 = 9 < uVar9; + uVar2 = uVar8 + 1 & 0xff; + uVar9 = uVar6; + } while (bVar1); + *pbVar5 = (byte)uVar6; + iVar4 = iVar3; + pcVar7 = pcVar10; + while (iVar3 = iVar4 + 1, uVar8 != 0xff) { + if (buflen <= iVar4) { + return (char *)0x0; + } + *pcVar7 = local_8[uVar8]; + iVar4 = iVar3; + pcVar7 = pcVar7 + 1; + uVar8 = uVar8 - 1 & 0xff; + } + if (buflen <= iVar4) break; + *pcVar7 = '.'; + pbVar5 = pbVar5 + 1; + pcVar10 = pcVar7 + 1; + if (pbVar5 == (byte *)register0x00002008) { + *pcVar7 = '\0'; + return buf; + } + } + return (char *)0x0; +} + + + +char * ip4addr_ntoa(ip4_addr_t *addr) + +{ + char str [16]; + char *pcVar1; + + pcVar1 = ip4addr_ntoa_r(addr,(char *)&ram0x42015514,0x10); + return pcVar1; +} + + + +void mem_init(void) + +{ + ram = ram_heap; + ram_heap._0_4_ = 0x2000; + ram_heap[4] = '\0'; + ram_end = (mem *)(ram_heap + 0x2000); + ram_heap._8192_4_ = 0x20002000; + ram_heap[8196] = '\x01'; + lfree = (mem *)ram_heap; + lwip_stats.mem.avail = 0x2000; + sys_mutex_new(&mem_mutex); + return; +} + + + +void mem_free(uint param_1) + +{ + ushort uVar1; + ushort uVar2; + short sVar3; + u8_t *puVar4; + mem *pmVar5; + mem *pmVar6; + mem *pmVar7; + uint uVar8; + mem *pmVar9; + + if (param_1 == 0) { + return; + } + if ((((param_1 & 3) == 0) && (pmVar6 = (mem *)(param_1 - 8), ram <= pmVar6)) && + ((mem *)(param_1 + 0xc) <= ram_end)) { + sys_mutex_lock(&mem_mutex); + pmVar5 = ram_end; + puVar4 = ram; + pmVar9 = lfree; + if (*(char *)(param_1 - 4) != '\0') { + uVar1 = *(ushort *)(param_1 - 8); + if ((uVar1 < 0x2001) && (uVar2 = *(ushort *)(param_1 - 6), uVar2 < 0x2001)) { + pmVar7 = (mem *)((int)pmVar6 - (int)ram); + uVar8 = (uint)pmVar7 & 0xffff; + if ((uVar8 == (uint)uVar2) || ((uint)*(ushort *)(ram + (uint)uVar2) == uVar8)) { + if (((mem *)(ram + uVar1) == ram_end) || ((uint)((mem *)(ram + uVar1))->prev == uVar8)) { + *(undefined *)(param_1 - 4) = 0; + if (pmVar6 < pmVar9) { + lfree = pmVar6; + } + sVar3 = (short)((uint)((int)pmVar7 * 0x10000) >> 0x10); + lwip_stats.mem.used = (lwip_stats.mem.used - uVar1) + sVar3; + pmVar9 = (mem *)(puVar4 + *(ushort *)(param_1 - 8)); + if (((pmVar6 != pmVar9) && (pmVar9->used == '\0')) && (pmVar5 != pmVar9)) { + if (pmVar9 == lfree) { + lfree = pmVar6; + } + *(mem_size_t *)(param_1 - 8) = pmVar9->next; + if (pmVar9->next != 0x2000) { + *(short *)(puVar4 + (uint)pmVar9->next + 2) = sVar3; + } + } + uVar1 = *(ushort *)(param_1 - 6); + pmVar9 = (mem *)(puVar4 + uVar1); + if ((pmVar6 != pmVar9) && (pmVar9->used == '\0')) { + if (pmVar6 == lfree) { + lfree = pmVar9; + } + pmVar9->next = *(mem_size_t *)(param_1 - 8); + if (*(ushort *)(param_1 - 8) != 0x2000) { + *(ushort *)(puVar4 + (uint)*(ushort *)(param_1 - 8) + 2) = uVar1; + } + } + sys_mutex_unlock(&mem_mutex); + return; + } + } + } + } + sys_mutex_unlock(&mem_mutex); + } + sys_arch_protect(); + lwip_stats.mem.illegal = lwip_stats.mem.illegal + 1; + sys_arch_unprotect(); + return; +} + + + +mem * mem_trim(mem *param_1,uint param_2) + +{ + mem_size_t mVar1; + short sVar2; + u8_t *puVar3; + uint uVar4; + mem_size_t mVar5; + uint uVar6; + uint uVar7; + mem *pmVar8; + mem *pmVar9; + undefined2 uVar10; + uint uVar11; + uint uVar12; + uint uVar13; + + uVar4 = param_2 + 3 & 0xfffc; + if (uVar4 < 0xc) { + uVar4 = 0xc; + } + else { + if (0x2000 < uVar4) { + return (mem *)0; + } + } + if (uVar4 < param_2) { + return (mem *)0; + } + if ((param_1 < ram) || (ram_end <= param_1)) { + sys_arch_protect(); + lwip_stats.mem.illegal = lwip_stats.mem.illegal + 1; + sys_arch_unprotect(); + return param_1; + } + uVar6 = (int)param_1 + (-8 - (int)ram); + uVar11 = (uint)*(ushort *)¶m_1[-2].used - 8; + uVar7 = uVar6 & 0xffff; + uVar12 = uVar11 & 0xffff; + uVar13 = uVar12 - uVar7 & 0xffff; + if (uVar13 < uVar4) { + return (mem *)0; + } + if (uVar13 == uVar4) { + return param_1; + } + sys_mutex_lock(&mem_mutex); + puVar3 = ram; + pmVar8 = (mem *)(ram + *(ushort *)¶m_1[-2].used); + mVar5 = (mem_size_t)uVar7; + if (pmVar8->used == '\0') { + uVar6 = uVar7 + 8 + uVar4; + mVar1 = pmVar8->next; + pmVar9 = (mem *)(ram + (uVar6 & 0xffff)); + if (lfree == pmVar8) { + lfree = pmVar9; + } + pmVar9->used = '\0'; + pmVar9->next = mVar1; + pmVar9->prev = mVar5; + uVar10 = (undefined2)(uVar6 * 0x10000 >> 0x10); + *(undefined2 *)¶m_1[-2].used = uVar10; + if (pmVar9->next != 0x2000) { + *(undefined2 *)(puVar3 + (uint)pmVar9->next + 2) = uVar10; + } + sVar2 = (mVar5 - (short)uVar12) + lwip_stats.mem.used; + } + else { + if (uVar13 < uVar4 + 0x14) goto LAB_2303dc84; + uVar7 = uVar7 + 8 + uVar4; + pmVar8 = (mem *)(ram + (uVar7 & 0xffff)); + if (pmVar8 < lfree) { + lfree = pmVar8; + } + pmVar8->used = '\0'; + mVar1 = *(mem_size_t *)¶m_1[-2].used; + pmVar8->prev = mVar5; + pmVar8->next = mVar1; + uVar10 = (undefined2)(uVar7 * 0x10000 >> 0x10); + *(undefined2 *)¶m_1[-2].used = uVar10; + if (pmVar8->next != 0x2000) { + *(undefined2 *)(puVar3 + (uint)pmVar8->next + 2) = uVar10; + } + sVar2 = ((short)(uVar6 * 0x10000 >> 0x10) - (short)(uVar11 * 0x10000 >> 0x10)) + + lwip_stats.mem.used; + } + lwip_stats.mem.used = (short)uVar4 + sVar2; +LAB_2303dc84: + sys_mutex_unlock(&mem_mutex); + return param_1; +} + + + +mem_size_t * mem_malloc(uint param_1) + +{ + ushort uVar1; + u8_t *puVar2; + mem_size_t *pmVar3; + mem *pmVar4; + uint uVar5; + uint uVar6; + ushort *puVar7; + mem_size_t mVar8; + uint uVar9; + uint uVar10; + mem *pmVar11; + + if (param_1 == 0) { +LAB_2303dd76: + pmVar3 = (mem_size_t *)0x0; + } + else { + uVar5 = param_1 + 3 & 0xfffc; + if (uVar5 < 0xc) { + uVar5 = 0xc; + } + else { + if (0x2000 < uVar5) { + return (mem_size_t *)0; + } + } + pmVar3 = (mem_size_t *)0x0; + if (param_1 <= uVar5) { + sys_mutex_lock(&mem_mutex); + puVar2 = ram; + pmVar11 = lfree; + uVar9 = (uint)((int)lfree - (int)ram) & 0xffff; + do { + uVar10 = uVar9; + if (0x2000 - uVar5 <= uVar10) { + lwip_stats.mem.err = lwip_stats.mem.err + 1; + sys_mutex_unlock(&mem_mutex); + goto LAB_2303dd76; + } + pmVar4 = (mem *)(ram + uVar10); + uVar9 = (uint)pmVar4->next; + } while ((pmVar4->used != '\0') || (uVar6 = (-8 - uVar10) + uVar9, uVar6 < uVar5)); + if (uVar6 < uVar5 + 0x14) { + pmVar4->used = '\x01'; + uVar10 = (uVar9 + lwip_stats.mem.used) - uVar10; + lwip_stats.mem.used = (mem_size_t)(uVar10 * 0x10000 >> 0x10); + if ((uint)lwip_stats.mem.max < (uVar10 & 0xffff)) { + lwip_stats.mem.max = lwip_stats.mem.used; + } + } + else { + uVar9 = uVar5 + 8 + uVar10; + puVar7 = (ushort *)(ram + (uVar9 & 0xffff)); + *(undefined *)(puVar7 + 2) = 0; + uVar1 = pmVar4->next; + puVar7[1] = (ushort)uVar10; + *puVar7 = uVar1; + mVar8 = (mem_size_t)(uVar9 * 0x10000 >> 0x10); + pmVar4->next = mVar8; + pmVar4->used = '\x01'; + if (*puVar7 != 0x2000) { + *(mem_size_t *)(puVar2 + (uint)*puVar7 + 2) = mVar8; + } + uVar5 = uVar5 + (uint)lwip_stats.mem.used + 8; + lwip_stats.mem.used = (mem_size_t)(uVar5 * 0x10000 >> 0x10); + if ((uint)lwip_stats.mem.max < (uVar5 & 0xffff)) { + lwip_stats.mem.max = lwip_stats.mem.used; + } + } + if (pmVar11 == pmVar4) { + while ((lfree = pmVar11, pmVar11->used != '\0' && (ram_end != pmVar11))) { + pmVar11 = (mem *)(puVar2 + pmVar11->next); + } + } + sys_mutex_unlock(&mem_mutex); + pmVar3 = &pmVar4[1].prev; + } + } + return pmVar3; +} + + + +// WARNING: Type propagation algorithm not settling + +void * do_memp_malloc_pool(memp_desc *desc) + +{ + memp mVar1; + sys_prot_t sVar2; + stats_mem *psVar3; + + sVar2 = sys_arch_protect(); + mVar1 = (memp)((memp *)desc->tab)->next; + if (mVar1 == (memp)0x0) { + desc->stats->err = desc->stats->err + 1; + } + else { + *(memp *)&((memp *)desc->tab)->next = *(memp *)mVar1; + desc->stats->used = desc->stats->used + 1; + psVar3 = desc->stats; + if (psVar3->max < psVar3->used) { + psVar3->max = psVar3->used; + } + } + sys_arch_unprotect(sVar2); + return (void *)mVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +void memp_init_pool(memp_desc *desc) + +{ + int iVar1; + memp mVar2; + + iVar1 = 0; + *desc->tab = (memp *)0x0; + mVar2 = (memp)((uint)(desc->base + 3) & 0xfffffffc); + while (iVar1 < (int)(uint)desc->num) { + iVar1 = iVar1 + 1; + *(memp **)mVar2 = ((memp *)desc->tab)->next; + *(memp *)&((memp *)desc->tab)->next = mVar2; + mVar2 = (memp)((int)mVar2 + (uint)desc->size); + } + desc->stats->avail = desc->num; + return; +} + + + +void memp_init(void) + +{ + stats_ *psVar1; + int iVar2; + memp_desc *desc; + + iVar2 = 0; + psVar1 = &lwip_stats; + do { + desc = *(memp_desc **)((int)memp_pools + iVar2); + iVar2 = iVar2 + 4; + memp_init_pool(desc); + psVar1->memp[0] = desc->stats; + psVar1 = (stats_ *)&(psVar1->link).fw; + } while (iVar2 != 0x3c); + return; +} + + + +void * memp_malloc(memp_t type) + +{ + undefined3 in_register_00002029; + void *pvVar1; + + if (CONCAT31(in_register_00002029,type) < 0xf) { + pvVar1 = do_memp_malloc_pool(memp_pools[CONCAT31(in_register_00002029,type)]); + return pvVar1; + } + return (void *)0x0; +} + + + +void memp_free(memp_t type,void *mem) + +{ + memp_desc *pmVar1; + undefined3 in_register_00002029; + + if ((CONCAT31(in_register_00002029,type) < 0xf) && (mem != (void *)0x0)) { + pmVar1 = memp_pools[CONCAT31(in_register_00002029,type)]; + sys_arch_protect(); + pmVar1->stats->used = pmVar1->stats->used - 1; + *(memp **)mem = *pmVar1->tab; + *pmVar1->tab = mem; + sys_arch_unprotect(); + return; + } + return; +} + + + +err_t netif_null_output_ip4(netif *netif,pbuf *p,ip4_addr_t *ipaddr) + +{ + return -0xc; +} + + + +void netif_issue_reports(netif *netif,u8_t report_type) + +{ + if (((netif->flags & 5) != 5) || ((report_type & 1) == 0)) { + return; + } + if ((netif->ip_addr).addr != 0) { + if ((netif->flags & 8) != 0) { + etharp_request(netif,(ip4_addr_t *)&netif->ip_addr); + } + if ((netif->flags & 0x20) != 0) { + igmp_report_groups(netif); + return; + } + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: new_addr +// WARNING: Type propagation algorithm not settling + +int netif_do_set_ipaddr(netif *netif,ip4_addr_t *ipaddr,ip_addr_t *old_addr) + +{ + ip_addr_t iVar1; + ip_addr_t iStack20; + ip_addr_t new_addr; + + iVar1 = (ip_addr_t)(netif->ip_addr).addr; + iStack20 = (ip_addr_t)ipaddr->addr; + if (iStack20 != iVar1) { + *(ip_addr_t *)&old_addr->addr = iVar1; + tcp_netif_ip_addr_changed(old_addr,&iStack20); + udp_netif_ip_addr_changed(old_addr,&iStack20); + raw_netif_ip_addr_changed(old_addr,&iStack20); + (netif->ip_addr).addr = ipaddr->addr; + netif_issue_reports(netif,'\x01'); + if (netif->status_callback != (netif_status_callback_fn *)0x0) { + (*netif->status_callback)(netif); + } + return 1; + } + return 0; +} + + + +void netif_init(void) + +{ + return; +} + + + +void netif_set_ipaddr(netif *netif,ip4_addr_t *ipaddr) + +{ + ip_addr_t iStack20; + ip_addr_t old_addr; + + if (netif != (netif *)0x0) { + if (ipaddr == (ip4_addr_t *)0x0) { + ipaddr = (ip4_addr_t *)&ip_addr_any; + } + netif_do_set_ipaddr(netif,ipaddr,&iStack20); + return; + } + return; +} + + + +void netif_set_netmask(netif *netif,ip4_addr_t *netmask) + +{ + if (netif != (netif *)0x0) { + if (netmask == (ip4_addr_t *)0x0) { + netmask = (ip4_addr_t *)&ip_addr_any; + } + if (netmask->addr != (netif->netmask).addr) { + (netif->netmask).addr = netmask->addr; + } + } + return; +} + + + +void netif_set_gw(netif *netif,ip4_addr_t *gw) + +{ + if (netif != (netif *)0x0) { + if (gw == (ip4_addr_t *)0x0) { + gw = (ip4_addr_t *)&ip_addr_any; + } + if (gw->addr != (netif->gw).addr) { + (netif->gw).addr = gw->addr; + } + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: old_addr + +void netif_set_addr(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw) + +{ + bool bVar1; + ip_addr_t iStack20; + ip_addr_t old_addr; + + if (ipaddr == (ip4_addr_t *)0x0) { + ipaddr = (ip4_addr_t *)&ip_addr_any; + } + if (netmask == (ip4_addr_t *)0x0) { + netmask = (ip4_addr_t *)&ip_addr_any; + } + if (gw == (ip4_addr_t *)0x0) { + gw = (ip4_addr_t *)&ip_addr_any; + } + bVar1 = ipaddr->addr == 0; + if (bVar1) { + netif_do_set_ipaddr(netif,ipaddr,&iStack20); + } + if (netmask->addr != (netif->netmask).addr) { + (netif->netmask).addr = netmask->addr; + } + if (gw->addr != (netif->gw).addr) { + (netif->gw).addr = gw->addr; + } + if (!bVar1) { + netif_do_set_ipaddr(netif,ipaddr,&iStack20); + } + return; +} + + + +netif * netif_add(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw,void *state, + netif_init_fn_conflict *init,netif_input_fn *input) + +{ + u8_t uVar1; + err_t eVar2; + undefined3 extraout_var; + netif *pnVar3; + + if ((netif != (netif *)0x0) && (init != (netif_init_fn_conflict *)0x0)) { + if (ipaddr == (ip4_addr_t *)0x0) { + ipaddr = (ip4_addr_t *)&ip_addr_any; + } + if (netmask == (ip4_addr_t *)0x0) { + netmask = (ip4_addr_t *)&ip_addr_any; + } + if (gw == (ip4_addr_t *)0x0) { + gw = (ip4_addr_t *)&ip_addr_any; + } + netif->output = netif_null_output_ip4; + (netif->ip_addr).addr = 0; + (netif->netmask).addr = 0; + (netif->gw).addr = 0; + netif->mtu = 0; + netif->flags = '\0'; + memset(netif->client_data,0,0xc); + netif->state = state; + uVar1 = netif_num; + netif->input = input; + netif->num = uVar1; + netif->status_callback = (netif_status_callback_fn *)0x0; + netif->link_callback = (netif_status_callback_fn *)0x0; + netif->igmp_mac_filter = (netif_igmp_mac_filter_fn *)0x0; + netif_set_addr(netif,ipaddr,netmask,gw); + eVar2 = (*init)(netif); + if (CONCAT31(extraout_var,eVar2) == 0) { + do { + if (netif->num == -1) { + netif->num = '\0'; + } + uVar1 = netif->num; + pnVar3 = netif_list; + while( true ) { + if (pnVar3 == (netif *)0x0) { + netif_num = '\0'; + if (uVar1 != -2) { + netif_num = uVar1 + '\x01'; + } + netif->next = netif_list; + if ((netif->flags & 0x20) == 0) { + netif_list = netif; + return netif; + } + netif_list = netif; + igmp_start(netif); + return netif; + } + if (pnVar3->num == uVar1) break; + pnVar3 = pnVar3->next; + } + netif->num = uVar1 + '\x01'; + } while( true ); + } + } + return (netif *)0x0; +} + + + +void netif_set_default(netif *netif) + +{ + netif_default = netif; + return; +} + + + +void netif_set_up(netif *netif) + +{ + if (netif == (netif *)0x0) { + return; + } + if ((netif->flags & 1) == 0) { + netif->flags = netif->flags | 1; + if (netif->status_callback != (netif_status_callback_fn *)0x0) { + (*netif->status_callback)(netif); + } + netif_issue_reports(netif,'\x03'); + return; + } + return; +} + + + +void netif_set_down(netif *netif) + +{ + byte bVar1; + + if (netif == (netif *)0x0) { + return; + } + bVar1 = netif->flags; + if ((bVar1 & 1) != 0) { + netif->flags = bVar1 & 0xfe; + if ((bVar1 & 8) != 0) { + etharp_cleanup_netif(netif); + } + if (netif->status_callback != (netif_status_callback_fn *)0x0) { + // WARNING: Could not recover jumptable at 0x2303e28a. Too many branches + // WARNING: Treating indirect jump as call + (*netif->status_callback)(netif); + return; + } + } + return; +} + + + +void netif_remove(netif *netif) + +{ + netif *pnVar1; + ip_addr_t *old_addr; + netif *pnVar2; + + if (netif == (netif *)0x0) { + return; + } + if ((netif->ip_addr).addr != 0) { + old_addr = &netif->ip_addr; + tcp_netif_ip_addr_changed(old_addr,(ip_addr_t *)0x0); + udp_netif_ip_addr_changed(old_addr,(ip_addr_t *)0x0); + raw_netif_ip_addr_changed(old_addr,(ip_addr_t *)0x0); + } + if ((netif->flags & 0x20) != 0) { + igmp_stop(netif); + } + if ((netif->flags & 1) != 0) { + netif_set_down(netif); + } + if (netif_default == netif) { + netif_default = (netif *)0x0; + } + pnVar1 = netif_list; + if (netif_list == netif) { + netif_list = netif->next; + } + else { + do { + pnVar2 = pnVar1; + if (pnVar2 == (netif *)0x0) { + return; + } + pnVar1 = pnVar2->next; + } while (pnVar2->next != netif); + pnVar2->next = netif->next; + } + return; +} + + + +void netif_set_status_callback(netif *netif,netif_status_callback_fn *status_callback) + +{ + if (netif != (netif *)0x0) { + netif->status_callback = status_callback; + } + return; +} + + + +void netif_set_link_up(netif *netif) + +{ + if (netif == (netif *)0x0) { + return; + } + if ((netif->flags & 4) == 0) { + netif->flags = netif->flags | 4; + dhcp_network_changed(netif); + netif_issue_reports(netif,'\x03'); + if (netif->link_callback != (netif_status_callback_fn *)0x0) { + // WARNING: Could not recover jumptable at 0x2303e35c. Too many branches + // WARNING: Treating indirect jump as call + (*netif->link_callback)(netif); + return; + } + } + return; +} + + + +// WARNING: Exceeded maximum restarts with more pending + +void netif_set_link_down(netif *netif) + +{ + if (netif != (netif *)0x0) { + if ((netif->flags & 4) != 0) { + netif->flags = netif->flags & 0xfb; + if (netif->link_callback != (netif_status_callback_fn *)0x0) { + // WARNING: Could not recover jumptable at 0x2303e382. Too many branches + // WARNING: Treating indirect jump as call + (*netif->link_callback)(); + return; + } + } + } + return; +} + + + +netif * netif_get_by_index(u8_t idx) + +{ + undefined3 in_register_00002029; + netif *pnVar1; + netif *pnVar2; + + pnVar1 = netif_list; + pnVar2 = (netif *)0x0; + if (CONCAT31(in_register_00002029,idx) != 0) { + while ((pnVar2 = pnVar1, pnVar1 != (netif *)0x0 && + (((uint)pnVar1->num + 1 & 0xff) != CONCAT31(in_register_00002029,idx)))) { + pnVar1 = pnVar1->next; + } + } + return pnVar2; +} + + + +pbuf * pbuf_skip_const(pbuf *in,u16_t in_offset,u16_t *out_offset) + +{ + pbuf *ppVar1; + undefined2 in_register_0000202e; + + if ((in != (pbuf *)0x0) && ((uint)in->len <= CONCAT22(in_register_0000202e,in_offset))) { + ppVar1 = pbuf_skip_const(in->next,(u16_t)((CONCAT22(in_register_0000202e,in_offset) - + (uint)in->len) * 0x10000 >> 0x10),out_offset); + return ppVar1; + } + if (out_offset != (u16_t *)0x0) { + *out_offset = in_offset; + } + return in; +} + + + +void pbuf_free_ooseq_callback(void *arg) + +{ + tcp_pcb *pcb; + + sys_arch_protect(); + pbuf_free_ooseq_pending = '\0'; + sys_arch_unprotect(); + pcb = tcp_active_pcbs; + while( true ) { + if (pcb == (tcp_pcb *)0x0) { + return; + } + if (pcb->ooseq != (tcp_seg *)0x0) break; + pcb = pcb->next; + } + tcp_free_ooseq(pcb); + return; +} + + + +u8_t pbuf_add_header_impl(pbuf *p,size_t header_size_increment,u8_t force) + +{ + u8_t uVar1; + pbuf *ppVar2; + undefined3 in_register_00002031; + uint uVar3; + + if (p == (pbuf *)0x0) { + uVar1 = '\x01'; + } + else { + uVar1 = '\x01'; + if ((header_size_increment < 0x10000) && (uVar1 = '\0', header_size_increment != 0)) { + uVar3 = (uint)p->tot_len + (header_size_increment & 0xffff); + uVar1 = '\x01'; + if ((header_size_increment & 0xffff) <= (uVar3 & 0xffff)) { + if ((char)p->type_internal < '\0') { + ppVar2 = (pbuf *)((int)p->payload - header_size_increment); + if (ppVar2 < p + 1) { + return '\x01'; + } + } + else { + if (CONCAT31(in_register_00002031,force) == 0) { + return '\x01'; + } + ppVar2 = (pbuf *)((int)p->payload - header_size_increment); + } + *(pbuf **)&p->payload = ppVar2; + p->tot_len = (u16_t)(uVar3 * 0x10000 >> 0x10); + p->len = (short)header_size_increment + p->len; + return '\0'; + } + } + } + return uVar1; +} + + + +pbuf * pbuf_alloc_reference(void *payload,u16_t length,pbuf_type type) + +{ + pbuf *ppVar1; + + ppVar1 = (pbuf *)memp_malloc(MEMP_PBUF); + if (ppVar1 != (pbuf *)0x0) { + ppVar1->next = (pbuf *)0x0; + ppVar1->payload = payload; + ppVar1->tot_len = length; + ppVar1->len = length; + ppVar1->type_internal = (u8_t)type; + ppVar1->flags = '\0'; + *(undefined2 *)&ppVar1->ref = 1; + } + return ppVar1; +} + + + +pbuf * pbuf_alloced_custom(pbuf_layer l,u16_t length,pbuf_type type,pbuf_custom *p,void *payload_mem + ,u16_t payload_mem_len) + +{ + undefined3 in_register_00002029; + uint uVar1; + undefined2 in_register_0000202e; + undefined2 in_register_0000203e; + + uVar1 = CONCAT31(in_register_00002029,l) + 3U & 0xfffffffc; + if (CONCAT22(in_register_0000202e,length) + uVar1 <= + CONCAT22(in_register_0000203e,payload_mem_len)) { + if (payload_mem != (void *)0x0) { + payload_mem = (void *)((int)payload_mem + uVar1); + } + (p->pbuf).flags = '\x02'; + (p->pbuf).next = (pbuf *)0x0; + (p->pbuf).payload = payload_mem; + (p->pbuf).tot_len = length; + (p->pbuf).len = length; + (p->pbuf).type_internal = (u8_t)type; + *(undefined2 *)&(p->pbuf).ref = 1; + return (pbuf *)p; + } + return (pbuf *)0x0; +} + + + +u8_t pbuf_add_header(pbuf *p,size_t header_size_increment) + +{ + u8_t uVar1; + + uVar1 = pbuf_add_header_impl(p,header_size_increment,'\0'); + return uVar1; +} + + + +u8_t pbuf_remove_header(pbuf *p,size_t header_size_decrement) + +{ + u8_t uVar1; + + if (p == (pbuf *)0x0) { + uVar1 = '\x01'; + } + else { + uVar1 = '\x01'; + if ((header_size_decrement < 0x10000) && (uVar1 = '\0', header_size_decrement != 0)) { + uVar1 = '\x01'; + if ((header_size_decrement & 0xffff) <= (uint)p->len) { + p->len = p->len - (short)header_size_decrement; + p->payload = (void *)(header_size_decrement + (int)p->payload); + p->tot_len = p->tot_len - (short)header_size_decrement; + return '\0'; + } + } + } + return uVar1; +} + + + +u8_t pbuf_header(pbuf *p,s16_t header_size_increment) + +{ + u8_t uVar1; + short in_register_0000202e; + + if (in_register_0000202e < 0) { + uVar1 = pbuf_remove_header(p,-CONCAT22(in_register_0000202e,header_size_increment)); + return uVar1; + } + uVar1 = pbuf_add_header_impl(p,CONCAT22(in_register_0000202e,header_size_increment),'\0'); + return uVar1; +} + + + +u8_t pbuf_header_force(pbuf *p,s16_t header_size_increment) + +{ + u8_t uVar1; + short in_register_0000202e; + + if (in_register_0000202e < 0) { + uVar1 = pbuf_remove_header(p,-CONCAT22(in_register_0000202e,header_size_increment)); + return uVar1; + } + uVar1 = pbuf_add_header_impl(p,CONCAT22(in_register_0000202e,header_size_increment),'\x01'); + return uVar1; +} + + + +u8_t pbuf_free(pbuf *p) + +{ + u8_t uVar1; + u8_t uVar2; + pbuf *ppVar3; + memp_t type; + byte bVar4; + + uVar1 = '\0'; + if (p != (pbuf *)0x0) { + uVar1 = '\0'; + do { + sys_arch_protect(); + uVar2 = p->ref + -1; + p->ref = uVar2; + sys_arch_unprotect(); + if (uVar2 != '\0') { + return uVar1; + } + ppVar3 = p->next; + if ((p->flags & 2) == 0) { + type = MEMP_PBUF_POOL; + bVar4 = p->type_internal & 0xf; + if (bVar4 != 2) { + if (bVar4 != 1) { + if ((p->type_internal & 0xf) == 0) { + mem_free(p); + } + goto LAB_2303e57c; + } + type = MEMP_PBUF; + } + memp_free(type,p); + } + else { + (*(code *)p[1].next)(p,p[1].next); + } +LAB_2303e57c: + uVar1 = uVar1 + '\x01'; + p = ppVar3; + } while (ppVar3 != (pbuf *)0x0); + } + return uVar1; +} + + + +pbuf * pbuf_alloc(pbuf_layer layer,u16_t length,pbuf_type type) + +{ + u8_t uVar1; + uint uVar2; + uint uVar3; + pbuf *ppVar4; + err_t eVar5; + undefined3 in_register_00002029; + pbuf *p; + pbuf *ppVar6; + undefined3 extraout_var; + undefined2 in_register_0000202e; + undefined2 in_register_00002032; + uint uVar7; + pbuf *ppVar8; + + uVar7 = CONCAT22(in_register_00002032,type); + uVar3 = CONCAT22(in_register_0000202e,length); + if (uVar7 != 0x41) { + if (uVar7 < 0x42) { + if (uVar7 == 1) goto LAB_2303e662; + } + else { + uVar2 = CONCAT31(in_register_00002029,layer) & 0xffff; + if (uVar7 == 0x182) { + p = (pbuf *)0x0; + ppVar8 = (pbuf *)0x0; + while (ppVar6 = (pbuf *)memp_malloc(MEMP_PBUF_POOL), ppVar6 != (pbuf *)0x0) { + uVar7 = 0x2f8 - (uVar2 + 3 & 0xfffffffc); + if (uVar3 < (uVar7 & 0xffff)) { + uVar7 = uVar3; + } + ppVar6->next = (pbuf *)0x0; + ppVar6->payload = (void *)((int)&ppVar6[1].next + uVar2 + 3 & 0xfffffffc); + ppVar6->tot_len = (u16_t)uVar3; + ppVar6->len = (u16_t)uVar7; + *(undefined4 *)&ppVar6->type_internal = 0x10082; + ppVar4 = ppVar6; + if (p != (pbuf *)0x0) { + ppVar8->next = ppVar6; + ppVar4 = p; + } + uVar3 = uVar3 - (uVar7 & 0xffff) & 0xffff; + uVar2 = 0; + p = ppVar4; + ppVar8 = ppVar6; + if (uVar3 == 0) { + return ppVar4; + } + } + sys_arch_protect(); + uVar1 = pbuf_free_ooseq_pending; + pbuf_free_ooseq_pending = '\x01'; + sys_arch_unprotect(); + if ((uVar1 == '\0') && + (eVar5 = tcpip_try_callback(pbuf_free_ooseq_callback,(void *)0x0), + CONCAT31(extraout_var,eVar5) != 0)) { + sys_arch_protect(); + pbuf_free_ooseq_pending = '\0'; + sys_arch_unprotect(); + } + if (p != (pbuf *)0x0) { + pbuf_free(p); + } + } + else { + if (uVar7 == 0x280) { + uVar7 = uVar3 + 3 & 0xfffffffc; + uVar3 = (uVar2 + 3 & 0xfffffffc) + uVar7 & 0xffff; + if ((uVar7 <= uVar3) && (uVar7 <= (uVar3 + 0x10 & 0xffff))) { + p = (pbuf *)mem_malloc(); + if (p == (pbuf *)0x0) { + return (pbuf *)0x0; + } + p->next = (pbuf *)0x0; + p->payload = (void *)((int)&p[1].next + CONCAT31(in_register_00002029,layer) + 3 & + 0xfffffffc); + p->tot_len = length; + p->len = length; + *(undefined4 *)&p->type_internal = 0x10080; + return p; + } + } + } + } + return (pbuf *)0x0; + } +LAB_2303e662: + p = pbuf_alloc_reference((void *)0x0,length,type); + return p; +} + + + +void pbuf_realloc(pbuf *p,u16_t new_len) + +{ + ushort uVar1; + uint uVar2; + undefined2 in_register_0000202e; + uint uVar3; + + uVar2 = CONCAT22(in_register_0000202e,new_len); + uVar1 = p->tot_len; + if (uVar2 < uVar1) { + while (uVar3 = (uint)p->len, uVar3 < uVar2) { + p->tot_len = p->tot_len + (new_len - uVar1); + uVar2 = uVar2 - uVar3 & 0xffff; + p = p->next; + } + if ((((p->type_internal & 0xf) == 0) && (uVar3 != uVar2)) && ((p->flags & 2) == 0)) { + p = (pbuf *)mem_trim(p,(int)p->payload + (uVar2 - (int)p) & 0xffff); + } + p->len = (u16_t)uVar2; + p->tot_len = (u16_t)uVar2; + if (p->next != (pbuf *)0x0) { + pbuf_free(p->next); + } + p->next = (pbuf *)0x0; + return; + } + return; +} + + + +u16_t pbuf_clen(pbuf *p) + +{ + u16_t uVar1; + + uVar1 = 0; + while (p != (pbuf *)0x0) { + uVar1 = uVar1 + 1; + p = p->next; + } + return uVar1; +} + + + +void pbuf_ref(pbuf *p) + +{ + if (p != (pbuf *)0x0) { + sys_arch_protect(); + p->ref = p->ref + '\x01'; + sys_arch_unprotect(); + return; + } + return; +} + + + +void pbuf_cat(pbuf *h,pbuf *t) + +{ + pbuf *ppVar1; + + if (h != (pbuf *)0x0) { + if (t == (pbuf *)0x0) { + return; + } + do { + ppVar1 = h; + ppVar1->tot_len = (u16_t)(((uint)ppVar1->tot_len + (uint)t->tot_len) * 0x10000 >> 0x10); + h = ppVar1->next; + } while (ppVar1->next != (pbuf *)0x0); + ppVar1->next = t; + } + return; +} + + + +void pbuf_chain(pbuf *h,pbuf *t) + +{ + pbuf_cat(h,t); + pbuf_ref(t); + return; +} + + + +err_t pbuf_copy(pbuf *p_to,pbuf *p_from) + +{ + err_t eVar1; + uint uVar2; + uint __n; + uint uVar3; + uint uVar4; + + if (p_to == (pbuf *)0x0) { + return -0x10; + } + if ((p_from == (pbuf *)0x0) || (p_to->tot_len < p_from->tot_len)) { +LAB_2303e86a: + eVar1 = -0x10; + } + else { + uVar4 = 0; + uVar3 = 0; + do { + __n = p_to->len - uVar3; + uVar2 = p_from->len - uVar4; + if (uVar2 < __n) { + __n = uVar2; + } + memcpy((void *)((int)p_to->payload + uVar3),(void *)((int)p_from->payload + uVar4),__n); + uVar4 = uVar4 + __n; + uVar3 = uVar3 + __n; + if (p_from->len <= uVar4) { + p_from = p_from->next; + uVar4 = 0; + } + if (uVar3 == (uint)p_to->len) { + p_to = p_to->next; + if (p_to == (pbuf *)0x0) { + if (p_from == (pbuf *)0x0) { + return '\0'; + } + goto LAB_2303e86a; + } + uVar3 = 0; + } + if ((((p_from != (pbuf *)0x0) && (p_from->len == p_from->tot_len)) && + (p_from->next != (pbuf *)0x0)) || + ((p_to->len == p_to->tot_len && (p_to->next != (pbuf *)0x0)))) { + return -6; + } + } while (p_from != (pbuf *)0x0); + eVar1 = '\0'; + } + return eVar1; +} + + + +u16_t pbuf_copy_partial(pbuf *buf,void *dataptr,u16_t len,u16_t offset) + +{ + u16_t uVar1; + uint uVar2; + uint uVar3; + uint __n; + undefined2 in_register_00002032; + undefined2 in_register_00002036; + uint uVar4; + + uVar4 = CONCAT22(in_register_00002036,offset); + uVar3 = CONCAT22(in_register_00002032,len); + uVar1 = 0; + if (buf != (pbuf *)0x0) { + uVar2 = 0; + uVar1 = 0; + if (dataptr != (void *)0x0) { + while ((uVar1 = (u16_t)uVar2, uVar3 != 0 && (buf != (pbuf *)0x0))) { + __n = (uint)buf->len; + if ((uVar4 == 0) || (uVar4 < __n)) { + __n = __n - uVar4 & 0xffff; + if (uVar3 < __n) { + __n = uVar3; + } + __n = __n & 0xffff; + memcpy((void *)((int)dataptr + uVar2),(void *)((int)buf->payload + uVar4),__n); + uVar2 = uVar2 + __n & 0xffff; + uVar3 = uVar3 - __n & 0xffff; + uVar4 = 0; + } + else { + uVar4 = uVar4 - __n & 0xffff; + } + buf = buf->next; + } + } + } + return uVar1; +} + + + +err_t pbuf_take(pbuf *buf,void *dataptr,u16_t len) + +{ + uint uVar1; + err_t eVar2; + undefined2 in_register_00002032; + uint __n; + int iVar3; + + uVar1 = CONCAT22(in_register_00002032,len); + if (buf != (pbuf *)0x0) { + eVar2 = -0x10; + if (dataptr != (void *)0x0) { + eVar2 = -1; + iVar3 = 0; + if (uVar1 <= buf->tot_len) { + while (uVar1 != 0) { + __n = (uint)buf->len; + if (uVar1 < (uint)buf->len) { + __n = uVar1; + } + memcpy(buf->payload,(void *)((int)dataptr + iVar3),__n); + buf = buf->next; + uVar1 = uVar1 - __n; + iVar3 = iVar3 + __n; + } + eVar2 = '\0'; + } + } + return eVar2; + } + return -0x10; +} + + + +err_t pbuf_take_at(pbuf *buf,void *dataptr,u16_t len,u16_t offset) + +{ + err_t eVar1; + pbuf *ppVar2; + undefined2 in_register_00002032; + size_t sVar3; + uint uVar4; + uint uVar5; + size_t __n; + u16_t auStack34 [2]; + u16_t target_offset; + + sVar3 = CONCAT22(in_register_00002032,len); + ppVar2 = pbuf_skip_const(buf,offset,auStack34); + if (ppVar2 == (pbuf *)0x0) { + eVar1 = -1; + } + else { + uVar4 = (uint)auStack34[0]; + eVar1 = -1; + if ((int)(uVar4 + sVar3) <= (int)(uint)ppVar2->tot_len) { + uVar5 = ppVar2->len - uVar4; + __n = sVar3; + if ((int)uVar5 < (int)sVar3) { + __n = uVar5 & 0xffff; + } + memcpy((void *)((int)ppVar2->payload + uVar4),dataptr,__n); + eVar1 = '\0'; + if ((sVar3 - __n & 0xffff) != 0) { + eVar1 = pbuf_take(ppVar2->next,(void *)((int)dataptr + __n), + (u16_t)((sVar3 - __n) * 0x10000 >> 0x10)); + } + } + } + return eVar1; +} + + + +pbuf * pbuf_clone(pbuf_layer layer,pbuf_type type,pbuf *p) + +{ + pbuf *p_to; + + p_to = pbuf_alloc(layer,p->tot_len,type); + if (p_to != (pbuf *)0x0) { + pbuf_copy(p_to,p); + } + return p_to; +} + + + +int pbuf_try_get_at(pbuf *p,u16_t offset) + +{ + pbuf *ppVar1; + uint uVar2; + u16_t auStack18 [2]; + u16_t q_idx; + + ppVar1 = pbuf_skip_const(p,offset,auStack18); + uVar2 = 0xffffffff; + if (ppVar1 != (pbuf *)0x0) { + uVar2 = 0xffffffff; + if ((uint)auStack18[0] < (uint)ppVar1->len) { + uVar2 = (uint)*(byte *)((int)ppVar1->payload + (uint)auStack18[0]); + } + } + return uVar2; +} + + + +void pbuf_put_at(pbuf *p,u16_t offset,u8_t data) + +{ + pbuf *ppVar1; + u16_t auStack18 [2]; + u16_t q_idx; + + ppVar1 = pbuf_skip_const(p,offset,auStack18); + if ((ppVar1 != (pbuf *)0x0) && ((uint)auStack18[0] < (uint)ppVar1->len)) { + *(u8_t *)((int)ppVar1->payload + (uint)auStack18[0]) = data; + } + return; +} + + + +raw_input_state_t raw_input(pbuf *p,netif *inp) + +{ + u8_t uVar1; + raw_pcb *prVar2; + raw_pcb *prVar3; + u8_t uVar4; + raw_input_state_t rVar5; + u8_t uVar6; + undefined3 extraout_var; + undefined3 extraout_var_00; + u32_t uVar7; + raw_pcb *prVar8; + + uVar4 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_dest,ip_data.current_netif); + uVar1 = *(u8_t *)((int)p->payload + 9); + rVar5 = RAW_INPUT_NONE; + prVar2 = raw_pcbs; + prVar8 = (raw_pcb *)0x0; + do { + prVar3 = prVar2; + if (prVar3 == (raw_pcb *)0x0) { + return rVar5; + } + if ((prVar3->protocol == uVar1) && + ((prVar3->netif_idx == '\0' || + (prVar3->netif_idx == (u8_t)((ip_data.current_input_netif)->num + '\x01'))))) { + uVar7 = (prVar3->local_ip).addr; + if (CONCAT31(extraout_var,uVar4) == 0) { + if ((uVar7 == 0) || (ip_data.current_iphdr_dest == uVar7)) goto LAB_2303eafa; + } + else { + if (uVar7 == 0) { +LAB_2303eafa: + if ((((prVar3->flags & 1) == 0) || ((prVar3->remote_ip).addr == ip_data.current_iphdr_src) + ) && (prVar3->recv != (raw_recv_fn *)0x0)) { + uVar6 = (*prVar3->recv)(prVar3->recv_arg,prVar3,p,(ip_addr_t *)0x4201a7a4); + if (CONCAT31(extraout_var_00,uVar6) != 0) { + if (prVar8 == (raw_pcb *)0x0) { + return RAW_INPUT_EATEN; + } + prVar8->next = prVar3->next; + prVar3->next = raw_pcbs; + raw_pcbs = prVar3; + return RAW_INPUT_EATEN; + } + rVar5 = RAW_INPUT_DELIVERED; + } + } + } + } + prVar2 = prVar3->next; + prVar8 = prVar3; + } while( true ); +} + + + +void raw_netif_ip_addr_changed(ip_addr_t *old_addr,ip_addr_t *new_addr) + +{ + raw_pcb *prVar1; + + if ((((old_addr != (ip_addr_t *)0x0) && (old_addr->addr != 0)) && (new_addr != (ip_addr_t *)0x0)) + && (prVar1 = raw_pcbs, new_addr->addr != 0)) { + while (prVar1 != (raw_pcb *)0x0) { + if ((prVar1->local_ip).addr == old_addr->addr) { + (prVar1->local_ip).addr = new_addr->addr; + } + prVar1 = prVar1->next; + } + } + return; +} + + + +void stats_init(void) + +{ + return; +} + + + +err_t tcp_close_shutdown_fin(tcp_pcb *pcb) + +{ + err_t eVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + tcp_state tVar2; + + tVar2 = pcb->state; + if (tVar2 != ESTABLISHED) { + if (tVar2 == CLOSE_WAIT) { + eVar1 = tcp_send_fin(pcb); + _eVar1 = CONCAT31(extraout_var_00,eVar1); + if (_eVar1 != 0) goto LAB_2303ebd0; + tVar2 = LAST_ACK; + goto LAB_2303ebae; + } + if (tVar2 != SYN_RCVD) { + return '\0'; + } + } + eVar1 = tcp_send_fin(pcb); + _eVar1 = CONCAT31(extraout_var,eVar1); + if (_eVar1 != 0) { +LAB_2303ebd0: + if (_eVar1 == -1) { + pcb->flags = pcb->flags | 8; + return '\0'; + } + return (err_t)_eVar1; + } + tVar2 = FIN_WAIT_1; +LAB_2303ebae: + pcb->state = tVar2; + tcp_output(pcb); + return '\0'; +} + + + +void tcp_init(void) + +{ + uint uVar1; + + uVar1 = bl_rand(); + tcp_port = (u16_t)(((uVar1 & 0x3fff) - 0x4000) * 0x10000 >> 0x10); + printf("-------------------->>>>>>>> LWIP tcp_port %u\r\n"); + return; +} + + + +void tcp_free(tcp_pcb *pcb) + +{ + memp_free(MEMP_TCP_PCB,pcb); + return; +} + + + +u32_t tcp_update_rcv_ann_wnd(tcp_pcb *pcb) + +{ + u32_t uVar1; + u32_t uVar2; + u32_t uVar3; + uint uVar4; + + uVar3 = pcb->rcv_ann_right_edge; + uVar2 = pcb->rcv_nxt; + uVar4 = (uint)pcb->mss; + uVar1 = (pcb->rcv_wnd - uVar3) + uVar2; + if (0x408 < pcb->mss) { + uVar4 = 0x408; + } + if (-1 < (int)(uVar1 - uVar4)) { + pcb->rcv_ann_wnd = pcb->rcv_wnd; + return uVar1; + } + if ((int)(uVar2 - uVar3) < 1) { + pcb->rcv_ann_wnd = (short)uVar3 - (short)uVar2; + } + else { + pcb->rcv_ann_wnd = 0; + } + return 0; +} + + + +void tcp_recved(tcp_pcb *pcb,u16_t len) + +{ + u32_t uVar1; + tcpwnd_size_t tVar2; + + if (pcb == (tcp_pcb *)0x0) { + return; + } + tVar2 = len + pcb->rcv_wnd; + if ((0x810 < tVar2) || (tVar2 < pcb->rcv_wnd)) { + tVar2 = 0x810; + } + pcb->rcv_wnd = tVar2; + uVar1 = tcp_update_rcv_ann_wnd(pcb); + if (0x407 < uVar1) { + pcb->flags = pcb->flags | 2; + tcp_output(pcb); + return; + } + return; +} + + + +void tcp_seg_free(tcp_seg *seg) + +{ + if (seg == (tcp_seg *)0x0) { + return; + } + if (seg->p != (pbuf *)0x0) { + pbuf_free(seg->p); + } + memp_free(MEMP_TCP_SEG,seg); + return; +} + + + +void tcp_segs_free(tcp_seg *seg) + +{ + tcp_seg *ptVar1; + + if (seg != (tcp_seg *)0x0) { + do { + ptVar1 = seg->next; + tcp_seg_free(seg); + seg = ptVar1; + } while (ptVar1 != (tcp_seg *)0x0); + return; + } + return; +} + + + +tcp_seg * tcp_seg_copy(tcp_seg *seg) + +{ + tcp_seg *__dest; + + __dest = (tcp_seg *)memp_malloc(MEMP_TCP_SEG); + if (__dest != (tcp_seg *)0x0) { + memcpy(__dest,seg,0x14); + pbuf_ref(__dest->p); + } + return __dest; +} + + + +u32_t tcp_next_iss(tcp_pcb *pcb) + +{ + u32_t iss; + + return iss + tcp_ticks; +} + + + +u16_t tcp_eff_send_mss_netif(u16_t sendmss,netif *outif,ip_addr_t *dest) + +{ + ushort uVar1; + u16_t uVar2; + undefined2 in_register_0000202a; + uint uVar3; + + uVar2 = sendmss; + if (outif != (netif *)0x0) { + uVar1 = outif->mtu; + if (((uVar1 != 0) && (uVar2 = 0, 0x28 < uVar1)) && + (uVar3 = (uint)uVar1 - 0x28 & 0xffff, uVar2 = (u16_t)uVar3, + CONCAT22(in_register_0000202a,sendmss) < uVar3)) { + uVar2 = sendmss; + } + } + return uVar2; +} + + + +void tcp_free_ooseq(tcp_pcb *pcb) + +{ + if (pcb->ooseq != (tcp_seg *)0x0) { + tcp_segs_free(pcb->ooseq); + pcb->ooseq = (tcp_seg *)0x0; + return; + } + return; +} + + + +void tcp_pcb_purge(tcp_pcb *pcb) + +{ + if (((pcb != (tcp_pcb *)0x0) && (LISTEN < pcb->state)) && (pcb->state != TIME_WAIT)) { + if (pcb->refused_data != (pbuf *)0x0) { + pbuf_free(pcb->refused_data); + pcb->refused_data = (pbuf *)0x0; + } + if (pcb->ooseq != (tcp_seg *)0x0) { + tcp_free_ooseq(pcb); + } + pcb->rtime = -1; + tcp_segs_free(pcb->unsent); + tcp_segs_free(pcb->unacked); + pcb->unsent = (tcp_seg *)0x0; + pcb->unacked = (tcp_seg *)0x0; + pcb->unsent_oversize = 0; + return; + } + return; +} + + + +void tcp_pcb_remove(tcp_pcb **pcblist,tcp_pcb *pcb) + +{ + tcp_pcb *ptVar1; + tcp_pcb *ptVar2; + + ptVar1 = *pcblist; + if (*pcblist == pcb) { + *pcblist = pcb->next; + } + else { + do { + ptVar2 = ptVar1; + if (ptVar2 == (tcp_pcb *)0x0) goto LAB_2303edf0; + ptVar1 = ptVar2->next; + } while (ptVar2->next != pcb); + ptVar2->next = pcb->next; + } +LAB_2303edf0: + pcb->next = (tcp_pcb *)0x0; + tcp_pcb_purge(pcb); + if (((pcb->state != TIME_WAIT) && (pcb->state != LISTEN)) && ((pcb->flags & 1) != 0)) { + pcb->flags = pcb->flags | 2; + tcp_output(pcb); + } + pcb->state = CLOSED; + pcb->local_port = 0; + return; +} + + + +void tcp_abandon(tcp_pcb *pcb,int reset) + +{ + tcp_pcb *ptVar1; + u16_t uVar2; + tcp_pcb *ptVar3; + tcp_err_fn *UNRECOVERED_JUMPTABLE; + void *pvVar4; + u32_t seqno; + u32_t ackno; + + if (pcb == (tcp_pcb *)0x0) { + return; + } + if (pcb->state == TIME_WAIT) { + tcp_pcb_remove(&tcp_tw_pcbs,pcb); + tcp_free(pcb); + return; + } + seqno = pcb->snd_nxt; + ackno = pcb->rcv_nxt; + UNRECOVERED_JUMPTABLE = pcb->errf; + pvVar4 = pcb->callback_arg; + uVar2 = pcb->local_port; + if (pcb->state == CLOSED) { + reset = 0; + if (uVar2 != 0) { + ptVar1 = tcp_bound_pcbs; + if (tcp_bound_pcbs == pcb) { + tcp_bound_pcbs = pcb->next; + } + else { + do { + ptVar3 = ptVar1; + if (ptVar3 == (tcp_pcb *)0x0) goto LAB_2303eeb6; + ptVar1 = ptVar3->next; + } while (ptVar3->next != pcb); + ptVar3->next = pcb->next; + } +LAB_2303eeb6: + pcb->next = (tcp_pcb *)0x0; + uVar2 = 0; + reset = 0; + } + } + else { + tcp_pcb_remove(&tcp_active_pcbs,pcb); + tcp_active_pcbs_changed = '\x01'; + } + if (pcb->unacked != (tcp_seg *)0x0) { + tcp_segs_free(pcb->unacked); + } + if (pcb->unsent != (tcp_seg *)0x0) { + tcp_segs_free(pcb->unsent); + } + if (pcb->ooseq != (tcp_seg *)0x0) { + tcp_segs_free(pcb->ooseq); + } + if (reset != 0) { + tcp_rst(pcb,seqno,ackno,(ip_addr_t *)pcb,&pcb->remote_ip,uVar2,pcb->remote_port); + } + tcp_free(pcb); + if (UNRECOVERED_JUMPTABLE == (tcp_err_fn *)0x0) { + return; + } + // WARNING: Could not recover jumptable at 0x2303ef12. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)(pvVar4,-0xd); + return; +} + + + +void tcp_abort(tcp_pcb *pcb) + +{ + tcp_abandon(pcb,1); + return; +} + + + +void tcp_netif_ip_addr_changed_pcblist(tcp_pcb *pcb_list) + +{ + tcp_pcb *in_a1; + tcp_pcb *pcb; + + while (pcb = in_a1, pcb != (tcp_pcb *)0x0) { + in_a1 = pcb->next; + if ((pcb->local_ip).addr == (pcb_list->local_ip).addr) { + tcp_abort(pcb); + } + } + return; +} + + + +void tcp_netif_ip_addr_changed(ip_addr_t *old_addr,ip_addr_t *new_addr) + +{ + u32_t *puVar1; + + if (old_addr == (ip_addr_t *)0x0) { + return; + } + if (old_addr->addr != 0) { + tcp_netif_ip_addr_changed_pcblist((tcp_pcb *)old_addr); + tcp_netif_ip_addr_changed_pcblist((tcp_pcb *)old_addr); + if ((new_addr != (ip_addr_t *)0x0) && (puVar1 = tcp_listen_pcbs, new_addr->addr != 0)) { + while (puVar1 != (u32_t *)0x0) { + if (*puVar1 == old_addr->addr) { + *puVar1 = new_addr->addr; + } + puVar1 = (u32_t *)puVar1[3]; + } + } + } + return; +} + + + +void tcp_kill_state(tcp_state state) + +{ + undefined3 in_register_00002029; + uint uVar1; + tcp_pcb *pcb; + uint uVar2; + tcp_pcb *ptVar3; + + uVar1 = 0; + pcb = (tcp_pcb *)0x0; + ptVar3 = tcp_active_pcbs; + while (ptVar3 != (tcp_pcb *)0x0) { + if (((uint)ptVar3->state == CONCAT31(in_register_00002029,state)) && + (uVar2 = tcp_ticks - ptVar3->tmr, uVar1 <= uVar2)) { + uVar1 = uVar2; + pcb = ptVar3; + } + ptVar3 = ptVar3->next; + } + if (pcb != (tcp_pcb *)0x0) { + tcp_abandon(pcb,0); + return; + } + return; +} + + + +tcp_pcb * tcp_alloc(u8_t prio) + +{ + u32_t uVar1; + tcp_pcb *pcb; + undefined3 in_register_00002029; + uint uVar2; + uint uVar3; + uint uVar4; + tcp_pcb *ptVar5; + int iVar6; + + iVar6 = CONCAT31(in_register_00002029,prio); + pcb = (tcp_pcb *)memp_malloc(MEMP_TCP_PCB); + ptVar5 = tcp_active_pcbs; + if (pcb != (tcp_pcb *)0x0) goto LAB_2303f0e6; + while (pcb = ptVar5, pcb != (tcp_pcb *)0x0) { + ptVar5 = pcb->next; + if ((pcb->flags & 8) != 0) { + pcb->flags = pcb->flags & 0xfff7; + tcp_close_shutdown_fin(pcb); + } + } + uVar3 = 0; + ptVar5 = tcp_tw_pcbs; + while (ptVar5 != (tcp_pcb *)0x0) { + uVar4 = tcp_ticks - ptVar5->tmr; + if (uVar3 <= uVar4) { + pcb = ptVar5; + uVar3 = uVar4; + } + ptVar5 = ptVar5->next; + } + if (pcb != (tcp_pcb *)0x0) { + tcp_abort(pcb); + } + pcb = (tcp_pcb *)memp_malloc(MEMP_TCP_PCB); + if (pcb == (tcp_pcb *)0x0) { + tcp_kill_state(LAST_ACK); + pcb = (tcp_pcb *)memp_malloc(MEMP_TCP_PCB); + if (pcb == (tcp_pcb *)0x0) { + tcp_kill_state(CLOSING); + pcb = (tcp_pcb *)memp_malloc(MEMP_TCP_PCB); + if (pcb == (tcp_pcb *)0x0) { + if ((char)prio < '\0') { + iVar6 = 0x7f; +LAB_2303f1a8: + uVar3 = iVar6 - 1U & 0xff; + uVar4 = 0; + ptVar5 = tcp_active_pcbs; + while (ptVar5 != (tcp_pcb *)0x0) { + uVar2 = (uint)ptVar5->prio; + if ((uVar2 < uVar3) || ((uVar2 == uVar3 && (uVar4 <= tcp_ticks - ptVar5->tmr)))) { + uVar4 = tcp_ticks - ptVar5->tmr; + pcb = ptVar5; + uVar3 = uVar2; + } + ptVar5 = ptVar5->next; + } + if (pcb != (tcp_pcb *)0x0) { + tcp_abort(pcb); + } + } + else { + if (iVar6 != 0) goto LAB_2303f1a8; + } + pcb = (tcp_pcb *)memp_malloc(MEMP_TCP_PCB); + if (pcb == (tcp_pcb *)0x0) { + return (tcp_pcb *)0x0; + } + lwip_stats.memp[2]->err = lwip_stats.memp[2]->err - 1; + } + lwip_stats.memp[2]->err = lwip_stats.memp[2]->err - 1; + } + lwip_stats.memp[2]->err = lwip_stats.memp[2]->err - 1; + } + lwip_stats.memp[2]->err = lwip_stats.memp[2]->err - 1; +LAB_2303f0e6: + memset(pcb,0,0xa4); + pcb->snd_buf = 0x1580; + *(undefined4 *)&pcb->rcv_wnd = 0x8100810; + pcb->ttl = -1; + pcb->rto = 6; + pcb->sv = 6; + *(undefined4 *)&pcb->rtime = 0x218ffff; + uVar1 = tcp_ticks; + pcb->prio = prio; + pcb->tmr = uVar1; + pcb->last_timer = tcp_timer_ctr; + *(undefined4 *)&pcb->cwnd = 0x15800001; + pcb->recv = tcp_recv_null; + pcb->keep_idle = 7200000; + pcb->keep_intvl = 75000; + pcb->keep_cnt = 9; + return pcb; +} + + + +err_t tcp_close_shutdown(tcp_pcb *pcb,u8_t rst_on_unacked_data) + +{ + tcp_state tVar1; + err_t eVar2; + undefined3 in_register_0000202d; + tcp_pcb *ptVar3; + tcp_pcb *ptVar4; + tcp_pcb ***ppptVar5; + + tVar1 = pcb->state; + if (((CONCAT31(in_register_0000202d,rst_on_unacked_data) == 0) || + ((tVar1 != ESTABLISHED && (tVar1 != CLOSE_WAIT)))) || + ((pcb->refused_data == (pbuf *)0x0 && (pcb->rcv_wnd == 0x810)))) { + if (tVar1 == LISTEN) { + ppptVar5 = tcp_pcb_lists; + do { + ptVar3 = *ppptVar5[1]; + while (ptVar3 != (tcp_pcb *)0x0) { + if (pcb == (tcp_pcb *)ptVar3->listener) { + ptVar3->listener = (tcp_pcb_listen *)0x0; + } + ptVar3 = ptVar3->next; + } + ppptVar5 = ppptVar5 + 1; + } while (ppptVar5 != (tcp_pcb ***)0x2307acb4); + tcp_pcb_remove((tcp_pcb **)&tcp_listen_pcbs,pcb); + memp_free(MEMP_TCP_PCB_LISTEN,pcb); + return '\0'; + } + if (tVar1 == CLOSED) { + if (pcb->local_port != 0) { + ptVar3 = tcp_bound_pcbs; + if (tcp_bound_pcbs == pcb) { + tcp_bound_pcbs = pcb->next; + } + else { + do { + ptVar4 = ptVar3; + if (ptVar4 == (tcp_pcb *)0x0) goto LAB_2303f2b6; + ptVar3 = ptVar4->next; + } while (ptVar4->next != pcb); + ptVar4->next = pcb->next; + } +LAB_2303f2b6: + pcb->next = (tcp_pcb *)0x0; + } + } + else { + if (tVar1 != SYN_SENT) { + eVar2 = tcp_close_shutdown_fin(pcb); + return eVar2; + } + tcp_pcb_remove(&tcp_active_pcbs,pcb); + tcp_active_pcbs_changed = '\x01'; + } + } + else { + tcp_rst(pcb,pcb->snd_nxt,pcb->rcv_nxt,(ip_addr_t *)pcb,&pcb->remote_ip,pcb->local_port, + pcb->remote_port); + tcp_pcb_purge(pcb); + ptVar3 = tcp_active_pcbs; + if (tcp_active_pcbs == pcb) { + tcp_active_pcbs = pcb->next; + } + else { + do { + ptVar4 = ptVar3; + if (ptVar4 == (tcp_pcb *)0x0) goto LAB_2303f248; + ptVar3 = ptVar4->next; + } while (ptVar4->next != pcb); + ptVar4->next = pcb->next; + } +LAB_2303f248: + ptVar3 = tcp_input_pcb; + tcp_active_pcbs_changed = '\x01'; + pcb->next = (tcp_pcb *)0x0; + if (ptVar3 == pcb) { + tcp_trigger_input_pcb_close(); + return '\0'; + } + } + tcp_free(pcb); + return '\0'; +} + + + +err_t tcp_close(tcp_pcb *pcb) + +{ + err_t eVar1; + + if (pcb != (tcp_pcb *)0x0) { + if (pcb->state != LISTEN) { + pcb->flags = pcb->flags | 0x10; + } + eVar1 = tcp_close_shutdown(pcb,'\x01'); + return eVar1; + } + return -0x10; +} + + + +err_t tcp_recv_null(void *arg,tcp_pcb *pcb,pbuf *p,err_t err) + +{ + err_t eVar1; + undefined3 in_register_00002035; + + if (pcb == (tcp_pcb *)0x0) { + return -0x10; + } + if (p != (pbuf *)0x0) { + tcp_recved(pcb,p->tot_len); + pbuf_free(p); + return '\0'; + } + if (CONCAT31(in_register_00002035,err) == 0) { + eVar1 = tcp_close(pcb); + return eVar1; + } + return '\0'; +} + + + +err_t tcp_process_refused_data(tcp_pcb *pcb) + +{ + byte bVar1; + err_t eVar2; + err_t eVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + pbuf *p; + + if (pcb == (tcp_pcb *)0x0) { + return -0x10; + } + p = pcb->refused_data; + bVar1 = p->flags; + pcb->refused_data = (pbuf *)0x0; + if (pcb->recv == (tcp_recv_fn *)0x0) { + eVar2 = tcp_recv_null((void *)0x0,pcb,p,'\0'); + _eVar2 = CONCAT31(extraout_var_01,eVar2); + } + else { + eVar2 = (*pcb->recv)(pcb->callback_arg,pcb,p,'\0'); + _eVar2 = CONCAT31(extraout_var,eVar2); + } + eVar2 = (err_t)_eVar2; + if (_eVar2 == 0) { + if ((bVar1 & 0x20) == 0) { + return eVar2; + } + if (pcb->rcv_wnd != 0x810) { + pcb->rcv_wnd = pcb->rcv_wnd + 1; + } + if (pcb->recv == (tcp_recv_fn *)0x0) { + return eVar2; + } + eVar3 = (*pcb->recv)(pcb->callback_arg,pcb,(pbuf *)0x0,'\0'); + if (CONCAT31(extraout_var_00,eVar3) != -0xd) { + return eVar2; + } + } + else { + if (_eVar2 != -0xd) { + pcb->refused_data = p; + return -5; + } + } + return -0xd; +} + + + +void tcp_fasttmr(void) + +{ + tcp_pcb *pcb; + tcp_pcb *ptVar1; + + tcp_timer_ctr = tcp_timer_ctr + '\x01'; + pcb = tcp_active_pcbs; + while( true ) { + if (pcb == (tcp_pcb *)0x0) { + return; + } + if (pcb->last_timer == tcp_timer_ctr) break; + pcb->last_timer = tcp_timer_ctr; + if ((pcb->flags & 1) != 0) { + pcb->flags = pcb->flags | 2; + tcp_output(pcb); + pcb->flags = pcb->flags & 0xfffc; + } + if ((pcb->flags & 8) != 0) { + pcb->flags = pcb->flags & 0xfff7; + tcp_close_shutdown_fin(pcb); + } + ptVar1 = pcb->next; + if (pcb->refused_data == (pbuf *)0x0) goto LAB_2303f4ac; + tcp_active_pcbs_changed = '\0'; + tcp_process_refused_data(pcb); + pcb = tcp_active_pcbs; + if (tcp_active_pcbs_changed == '\0') { +LAB_2303f4ac: + pcb = ptVar1; + } + } + ptVar1 = pcb->next; + goto LAB_2303f4ac; +} + + + +void tcp_slowtmr(void) + +{ + tcp_state tVar1; + short sVar2; + tcp_pcb *pcb; + uint uVar3; + tcp_err_fn *ptVar4; + err_t eVar5; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + uint uVar6; + byte bVar7; + uint uVar8; + u32_t uVar9; + byte bVar10; + s16_t sVar11; + void *pvVar12; + tcp_pcb *ptVar13; + tcp_pcb *pcb_00; + + tcp_ticks = tcp_ticks + 1; + tcp_timer_ctr = tcp_timer_ctr + '\x01'; + do { + pcb_00 = tcp_active_pcbs; + ptVar13 = (tcp_pcb *)0x0; +LAB_2303f51a: + do { + while( true ) { + pcb = pcb_00; + pcb_00 = tcp_tw_pcbs; + if (pcb == (tcp_pcb *)0x0) { + while (pcb_00 != (tcp_pcb *)0x0) { + if (tcp_ticks - pcb_00->tmr < 0xf1) { + pcb = pcb_00; + pcb_00 = pcb_00->next; + } + else { + tcp_pcb_purge(pcb_00); + ptVar13 = pcb_00->next; + if (pcb != (tcp_pcb *)0x0) { + pcb->next = pcb_00->next; + ptVar13 = tcp_tw_pcbs; + } + tcp_tw_pcbs = ptVar13; + ptVar13 = pcb_00->next; + tcp_free(pcb_00); + pcb_00 = ptVar13; + } + } + return; + } + if (pcb->last_timer != tcp_timer_ctr) break; + pcb_00 = pcb->next; + ptVar13 = pcb; + } + pcb->last_timer = tcp_timer_ctr; + if (pcb->state == SYN_SENT) { + bVar7 = 5; + } + else { + bVar7 = 0xb; + } + uVar3 = 1; + if (pcb->nrtx <= bVar7) { + uVar3 = (uint)pcb->persist_backoff; + if (pcb->persist_backoff == 0) { + sVar2 = pcb->rtime; + if (sVar2 < 0) { +LAB_2303f770: + if (pcb->rtime < pcb->rto) goto LAB_2303f5ca; + } + else { + if (sVar2 != 0x7fff) { + pcb->rtime = sVar2 + 1; + goto LAB_2303f770; + } + } + eVar5 = tcp_rexmit_rto_prepare(pcb); + if ((CONCAT31(extraout_var_02,eVar5) == 0) || + ((pcb->unacked == (tcp_seg *)0x0 && (pcb->unsent != (tcp_seg *)0x0)))) { + if (pcb->state != SYN_SENT) { + uVar6 = (uint)pcb->nrtx; + if (0xc < pcb->nrtx) { + uVar6 = 0xc; + } + _sVar11 = ((int)pcb->sa >> 3) + (int)pcb->sv << + ((uint)"\x01\x02\x03\x04\x05\x06\a\a\a\a\a\a\a"[uVar6] & 0x1f); + sVar11 = (s16_t)_sVar11; + if (0x7ffe < _sVar11) { + sVar11 = 0x7fff; + } + pcb->rto = sVar11; + } + pcb->rtime = 0; + uVar6 = (uint)pcb->snd_wnd; + if ((uint)pcb->cwnd < (uint)pcb->snd_wnd) { + uVar6 = (uint)pcb->cwnd; + } + uVar8 = (uint)pcb->mss << 0x11; + pcb->ssthresh = (tcpwnd_size_t)(uVar6 >> 1); + if (uVar6 >> 1 < uVar8 >> 0x10) { + pcb->ssthresh = (tcpwnd_size_t)(uVar8 >> 0x10); + } + pcb->cwnd = pcb->mss; + pcb->bytes_acked = 0; + tcp_rexmit_rto_commit(pcb); + goto LAB_2303f5cc; + } + } + else { + if (0xb < pcb->persist_probe) { + uVar3 = 1; + goto LAB_2303f5cc; + } + bVar7 = *(byte *)((int)&ip_addr_broadcast.addr + uVar3 + 3); + if ((bVar7 <= pcb->persist_cnt) || + (bVar10 = pcb->persist_cnt + 1, pcb->persist_cnt = bVar10, bVar7 <= bVar10)) { + if (pcb->snd_wnd == 0) { + eVar5 = tcp_zero_window_probe(pcb); + if (CONCAT31(extraout_var_01,eVar5) == 0) goto LAB_2303f6ba; + } + else { + eVar5 = tcp_split_unsent_seg(pcb,pcb->snd_wnd); + if ((CONCAT31(extraout_var,eVar5) != 0) || + (eVar5 = tcp_output(pcb), CONCAT31(extraout_var_00,eVar5) != 0)) { +LAB_2303f6ba: + pcb->persist_cnt = '\0'; + if (pcb->persist_backoff < 7) { + pcb->persist_backoff = pcb->persist_backoff + 1; + } + } + } + } + } +LAB_2303f5ca: + uVar3 = 0; + } +LAB_2303f5cc: + tVar1 = pcb->state; + if (((tVar1 == FIN_WAIT_2) && ((pcb->flags & 0x10) != 0)) && (0x28 < tcp_ticks - pcb->tmr)) { + uVar3 = uVar3 + 1 & 0xff; + } + bVar7 = pcb->so_options & 8; + if (((pcb->so_options & 8) != 0) && + ((tVar1 == ESTABLISHED || (bVar7 = 0, tVar1 == CLOSE_WAIT)))) { + uVar6 = tcp_ticks - pcb->tmr; + if ((pcb->keep_intvl * pcb->keep_cnt + pcb->keep_idle) / 500 < uVar6) { + uVar3 = uVar3 + 1 & 0xff; + bVar7 = 1; + } + else { + bVar7 = 0; + if ((((uint)pcb->keep_cnt_sent * pcb->keep_intvl + pcb->keep_idle) / 500 < uVar6) && + (eVar5 = tcp_keepalive(pcb), bVar7 = 0, CONCAT31(extraout_var_03,eVar5) == 0)) { + pcb->keep_cnt_sent = pcb->keep_cnt_sent + '\x01'; + } + } + } + if ((pcb->ooseq != (tcp_seg *)0x0) && ((uint)((int)pcb->rto * 6) <= tcp_ticks - pcb->tmr)) { + tcp_free_ooseq(pcb); + } + tVar1 = pcb->state; + if (tVar1 == SYN_RCVD) { + if (0x28 < tcp_ticks - pcb->tmr) { + uVar3 = uVar3 + 1 & 0xff; + } +LAB_2303f67c: + if (uVar3 == 0) { + pcb_00 = pcb->next; + bVar7 = pcb->polltmr + 1; + pcb->polltmr = bVar7; + ptVar13 = pcb; + if (pcb->pollinterval <= bVar7) { + pcb->polltmr = '\0'; + tcp_active_pcbs_changed = '\0'; + if (pcb->poll != (tcp_poll_fn *)0x0) { + eVar5 = (*pcb->poll)(pcb->callback_arg,pcb); + if (tcp_active_pcbs_changed != '\0') break; + if (CONCAT31(extraout_var_04,eVar5) != 0) goto LAB_2303f51a; + } + tcp_output(pcb); + } + goto LAB_2303f51a; + } + } + else { + if (tVar1 == LAST_ACK) { + uVar9 = pcb->tmr; + uVar6 = 0xf0; + } + else { + if ((tVar1 != FIN_WAIT_1) && (tVar1 != CLOSING)) goto LAB_2303f67c; + uVar9 = pcb->tmr; + uVar6 = 10; + } + if (tcp_ticks - uVar9 <= uVar6) goto LAB_2303f67c; + } + ptVar4 = pcb->errf; + tcp_pcb_purge(pcb); + pcb_00 = pcb->next; + if (ptVar13 != (tcp_pcb *)0x0) { + ptVar13->next = pcb->next; + pcb_00 = tcp_active_pcbs; + } + tcp_active_pcbs = pcb_00; + if (bVar7 != 0) { + tcp_rst(pcb,pcb->snd_nxt,pcb->rcv_nxt,(ip_addr_t *)pcb,&pcb->remote_ip,pcb->local_port, + pcb->remote_port); + } + pvVar12 = pcb->callback_arg; + pcb_00 = pcb->next; + tcp_free(pcb); + tcp_active_pcbs_changed = '\0'; + } while ((ptVar4 == (tcp_err_fn *)0x0) || + ((*ptVar4)(pvVar12,-0xd), tcp_active_pcbs_changed == '\0')); + } while( true ); +} + + + +void tcp_tmr(void) + +{ + tcp_fasttmr(); + tcp_timer = tcp_timer + 1; + if ((tcp_timer & 1) != 0) { + tcp_slowtmr(); + return; + } + return; +} + + + +u8_t tcp_get_next_optbyte(void) + +{ + uint uVar1; + + uVar1 = (uint)tcp_optidx; + if ((tcphdr_opt2 != (u8_t *)0x0) && (tcphdr_opt1len <= uVar1)) { + tcp_optidx = tcp_optidx + 1; + return tcphdr_opt2[uVar1 - tcphdr_opt1len & 0xff]; + } + tcp_optidx = tcp_optidx + 1; + return *(u8_t *)((int)&tcphdr[1].src + uVar1); +} + + + +void tcp_oos_insert_segment(tcp_seg *cseg,tcp_seg *next) + +{ + u32_t uVar1; + ushort uVar2; + tcp_seg *ptVar3; + u16_t new_len; + int iVar4; + tcp_hdr *ptVar5; + + new_len = lwip_htons(cseg->tcphdr->_hdrlen_rsvd_flags); + if ((new_len & 1) == 0) { + do { + iVar4 = cseg->len + seqno; + uVar1 = next->tcphdr->seqno; + if ((int)(iVar4 - (next->len + uVar1)) < 0) { + if (0 < (int)(iVar4 - uVar1)) { + new_len = (u16_t)((uVar1 - seqno) * 0x10000 >> 0x10); + cseg->len = new_len; + pbuf_realloc(cseg->p,new_len); + } + goto LAB_2303f96e; + } + new_len = lwip_htons(next->tcphdr->_hdrlen_rsvd_flags); + if ((new_len & 1) != 0) { + uVar2 = cseg->tcphdr->_hdrlen_rsvd_flags; + new_len = lwip_htons(1); + ptVar5 = cseg->tcphdr; + uVar2 = new_len | uVar2; + *(char *)&ptVar5->_hdrlen_rsvd_flags = (char)uVar2; + *(undefined *)((int)&ptVar5->_hdrlen_rsvd_flags + 1) = (char)((uint)uVar2 >> 8); + } + ptVar3 = next->next; + tcp_seg_free(next); + next = ptVar3; + } while (ptVar3 != (tcp_seg *)0x0); + } + else { + tcp_segs_free(next); + } + next = (tcp_seg *)0x0; +LAB_2303f96e: + cseg->next = next; + return; +} + + + +void tcp_parseopt(undefined2 *param_1) + +{ + uint uVar1; + u8_t uVar2; + byte bVar3; + undefined2 uVar4; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + + tcp_optidx = 0; + while( true ) { + while( true ) { + do { + uVar1 = (uint)tcphdr_optlen; + if (uVar1 <= tcp_optidx) { + return; + } + uVar2 = tcp_get_next_optbyte(); + } while (CONCAT31(extraout_var,uVar2) == 1); + if (uVar2 == '\0') { + return; + } + if (CONCAT31(extraout_var,uVar2) == 2) break; + uVar2 = tcp_get_next_optbyte(); + if (CONCAT31(extraout_var_02,uVar2) < 2) { + return; + } + tcp_optidx = (tcp_optidx - 2) + (short)CONCAT31(extraout_var_02,uVar2); + } + uVar2 = tcp_get_next_optbyte(); + if (CONCAT31(extraout_var_00,uVar2) != 4) { + return; + } + if (uVar1 <= (uint)tcp_optidx + 1) break; + bVar3 = tcp_get_next_optbyte(); + uVar2 = tcp_get_next_optbyte(); + uVar1 = CONCAT31(extraout_var_01,uVar2) & 0xffff | ((uint)bVar3 << 0x18) >> 0x10; + uVar4 = (undefined2)uVar1; + if (0x2af < (uVar1 - 1 & 0xffff)) { + uVar4 = 0x2b0; + } + *param_1 = uVar4; + } + return; +} + + + +int tcp_input_delayed_close(tcp_pcb *pcb) + +{ + if ((recv_flags & 0x10) != 0) { + if (((pcb->flags & 0x10) == 0) && (pcb->errf != (tcp_err_fn *)0x0)) { + (*pcb->errf)(pcb->callback_arg,-0xf); + } + tcp_pcb_remove(&tcp_active_pcbs,pcb); + tcp_free(pcb); + return 1; + } + return 0; +} + + + +tcp_seg * tcp_free_acked_segments(tcp_seg *seg_list) + +{ + ushort uVar1; + tcp_seg *ptVar2; + u16_t uVar3; + u32_t uVar4; + tcp_seg *in_a1; + + while( true ) { + if (in_a1 == (tcp_seg *)0x0) { + return (tcp_seg *)0x0; + } + uVar4 = lwip_htonl(in_a1->tcphdr->seqno); + uVar1 = in_a1->len; + uVar3 = lwip_htons(in_a1->tcphdr->_hdrlen_rsvd_flags); + if (0 < (int)((uVar1 - ackno) + uVar4 + (uint)((uVar3 & 3) != 0))) break; + ptVar2 = in_a1->next; + uVar3 = pbuf_clen(in_a1->p); + *(u16_t *)&seg_list->next = *(short *)&seg_list->next - uVar3; + recv_acked = in_a1->len + recv_acked; + tcp_seg_free(in_a1); + in_a1 = ptVar2; + } + return in_a1; +} + + + +void tcp_receive(tcp_pcb *pcb) + +{ + ushort n; + ushort uVar1; + short sVar2; + tcp_seg *cseg; + tcp_seg *next; + u16_t new_len; + u16_t uVar3; + int iVar4; + u32_t uVar5; + pbuf *p; + u32_t uVar6; + uint header_size_decrement; + u32_t uVar7; + uint uVar8; + tcp_hdr *ptVar9; + tcpwnd_size_t tVar10; + short sVar11; + tcpflags_t tVar12; + uint uVar13; + uint uVar14; + tcp_seg *ptVar15; + + uVar5 = seqno; + uVar7 = ackno; + if ((flags & 0x10) != 0) { + n = pcb->snd_wnd; + uVar6 = pcb->snd_wl2; + if ((((int)(pcb->snd_wl1 - seqno) < 0) || + ((pcb->snd_wl1 == seqno && ((int)(uVar6 - ackno) < 0)))) || + ((uVar6 == ackno && ((uint)n < (uint)tcphdr->wnd)))) { + uVar1 = tcphdr->wnd; + pcb->snd_wnd = uVar1; + if (pcb->snd_wnd_max < uVar1) { + pcb->snd_wnd_max = uVar1; + } + pcb->snd_wl1 = uVar5; + pcb->snd_wl2 = uVar7; + } + uVar13 = uVar7 - pcb->lastack; + if ((int)uVar13 < 1) { + if ((((tcplen == 0) && ((uint)pcb->snd_wnd + pcb->snd_wl2 == (uint)n + uVar6)) && + (-1 < pcb->rtime)) && (pcb->lastack == uVar7)) { + if (pcb->dupacks != -1) { + pcb->dupacks = pcb->dupacks + '\x01'; + } + if (pcb->dupacks < 4) { + if (pcb->dupacks != 3) goto LAB_2303fca8; + } + else { + tVar10 = pcb->mss + pcb->cwnd; + if (tVar10 < pcb->cwnd) { + tVar10 = 0xffff; + } + pcb->cwnd = tVar10; + } + tcp_rexmit_fast(pcb); + } + else { + pcb->dupacks = '\0'; + } + } + else { + if ((int)(uVar7 - pcb->snd_nxt) < 1) { + if ((pcb->flags & 4) != 0) { + pcb->flags = pcb->flags & 0xfffb; + pcb->bytes_acked = 0; + pcb->cwnd = pcb->ssthresh; + } + pcb->lastack = uVar7; + pcb->rto = (pcb->sa >> 3) + pcb->sv; + *(undefined2 *)&pcb->nrtx = 0; + if (SYN_RCVD < pcb->state) { + header_size_decrement = (uint)pcb->cwnd; + uVar13 = uVar13 & 0xffff; + if (header_size_decrement < pcb->ssthresh) { + uVar8 = ((uint)((pcb->flags & 0x800) == 0) + 1) * (uint)pcb->mss; + if (uVar13 < (uVar8 & 0xffff)) { + uVar8 = uVar13; + } + } + else { + uVar13 = uVar13 + pcb->bytes_acked; + uVar8 = uVar13 & 0xffff; + sVar11 = (short)uVar8; + if (uVar8 < pcb->bytes_acked) { + sVar11 = -1; + } + else { + if (uVar8 < header_size_decrement) { + pcb->bytes_acked = (tcpwnd_size_t)(uVar13 * 0x10000 >> 0x10); + goto LAB_23040004; + } + } + pcb->bytes_acked = sVar11 - pcb->cwnd; + uVar8 = (uint)pcb->mss; + } + uVar13 = header_size_decrement + uVar8 & 0xffff; + tVar10 = (tcpwnd_size_t)uVar13; + if (uVar13 < header_size_decrement) { + tVar10 = 0xffff; + } + pcb->cwnd = tVar10; + } +LAB_23040004: + cseg = tcp_free_acked_segments((tcp_seg *)&pcb->snd_queuelen); + pcb->unacked = cseg; + cseg = tcp_free_acked_segments((tcp_seg *)&pcb->snd_queuelen); + ptVar15 = pcb->unacked; + pcb->unsent = cseg; + pcb->polltmr = '\0'; + pcb->rtime = -(ushort)(ptVar15 == (tcp_seg *)0x0); + if (cseg == (tcp_seg *)0x0) { + pcb->unsent_oversize = 0; + } + pcb->snd_buf = pcb->snd_buf + recv_acked; + if ((int)((uint)pcb->flags << 0x14) < 0) { + if (ptVar15 == (tcp_seg *)0x0) { + if (cseg != (tcp_seg *)0x0) { + uVar7 = pcb->rto_end; + ptVar9 = cseg->tcphdr; + goto LAB_23040080; + } + } + else { + uVar7 = pcb->rto_end; + ptVar9 = ptVar15->tcphdr; +LAB_23040080: + uVar5 = lwip_htonl(ptVar9->seqno); + if (0 < (int)(uVar7 - uVar5)) goto LAB_2303fca8; + } + pcb->flags = pcb->flags & 0xf7ff; + } + } + else { + tcp_send_empty_ack(pcb); + } + } +LAB_2303fca8: + if ((pcb->rttest != 0) && ((int)(pcb->rtseq - ackno) < 0)) { + uVar8 = (uint)(ushort)tcp_ticks; + header_size_decrement = pcb->rttest & 0xffff; + uVar13 = (int)pcb->sa >> 3 & 0xffff; + uVar14 = (uVar8 - header_size_decrement) - uVar13 & 0xffff; + iVar4 = (int)(short)uVar14; + sVar11 = (short)((uVar14 + (int)pcb->sa) * 0x10000 >> 0x10); + pcb->sa = sVar11; + if (iVar4 < 0) { + iVar4 = (int)(((header_size_decrement - uVar8) + uVar13) * 0x10000) >> 0x10; + } + pcb->rttest = 0; + sVar2 = (short)((uint)((((int)pcb->sv - ((int)pcb->sv >> 2)) + iVar4) * 0x10000) >> 0x10); + pcb->sv = sVar2; + pcb->rto = (sVar11 >> 3) + sVar2; + } + } + uVar7 = pcb->rcv_nxt; + if ((tcplen == 0) || (FIN_WAIT_2 < pcb->state)) { + if ((-1 < (int)(seqno - uVar7)) && ((int)(((seqno + 1) - uVar7) - (uint)pcb->rcv_wnd) < 1)) { + return; + } + tVar12 = pcb->flags; + } + else { + uVar13 = uVar7 - seqno; + if (((int)(uVar13 - 1) < 0) || (0 < (int)(((1 - seqno) - (uint)tcplen) + uVar7))) { + if ((int)(seqno - uVar7) < 0) { + pcb->flags = pcb->flags | 2; + } + } + else { + header_size_decrement = uVar13 & 0xffff; + inseg.len = inseg.len - (short)(uVar13 * 0x10000 >> 0x10); + iVar4 = (inseg.p)->tot_len - header_size_decrement; + p = inseg.p; + while (n = p->len, n < header_size_decrement) { + p->tot_len = (u16_t)((uint)(iVar4 * 0x10000) >> 0x10); + p->len = 0; + header_size_decrement = header_size_decrement - n & 0xffff; + p = p->next; + } + pbuf_remove_header(p,header_size_decrement); + ptVar9 = inseg.tcphdr; + uVar7 = pcb->rcv_nxt; + seqno = uVar7; + *(char *)&(inseg.tcphdr)->seqno = (char)uVar7; + *(undefined *)((int)&ptVar9->seqno + 1) = (char)(uVar7 >> 8); + *(undefined *)((int)&ptVar9->seqno + 2) = (char)(uVar7 >> 0x10); + *(undefined *)((int)&ptVar9->seqno + 3) = (char)(uVar7 >> 0x18); + } + uVar7 = pcb->rcv_nxt; + if (((int)(seqno - uVar7) < 0) || (0 < (int)(((seqno + 1) - uVar7) - (uint)pcb->rcv_wnd))) { +LAB_23040308: + tcp_send_empty_ack(pcb); + return; + } + if (seqno != uVar7) { + cseg = pcb->ooseq; + ptVar15 = (tcp_seg *)0x0; + if (pcb->ooseq == (tcp_seg *)0x0) { + cseg = tcp_seg_copy(&inseg); + pcb->ooseq = cseg; + } + else { + do { + next = cseg; + uVar7 = next->tcphdr->seqno; + if (seqno == uVar7) { + if ((next->len < inseg.len) && (cseg = tcp_seg_copy(&inseg), cseg != (tcp_seg *)0x0)) { + if (ptVar15 == (tcp_seg *)0x0) { + pcb->ooseq = cseg; + } + else { + ptVar15->next = cseg; + } +LAB_2304036e: + tcp_oos_insert_segment(cseg,next); + } + goto LAB_23040308; + } + if (ptVar15 == (tcp_seg *)0x0) { + if ((int)(seqno - uVar7) < 0) { + cseg = tcp_seg_copy(&inseg); + if (cseg != (tcp_seg *)0x0) { + pcb->ooseq = cseg; + goto LAB_2304036e; + } + goto LAB_23040308; + } + } + else { + if ((-1 < (int)((seqno - 1) - ptVar15->tcphdr->seqno)) && + ((int)((seqno + 1) - uVar7) < 1)) { + cseg = tcp_seg_copy(&inseg); + if (cseg != (tcp_seg *)0x0) { + uVar7 = ptVar15->tcphdr->seqno; + if (0 < (int)((ptVar15->len + uVar7) - seqno)) { + new_len = (u16_t)((seqno - uVar7) * 0x10000 >> 0x10); + ptVar15->len = new_len; + pbuf_realloc(ptVar15->p,new_len); + } + ptVar15->next = cseg; + goto LAB_2304036e; + } + goto LAB_23040308; + } + } + cseg = next->next; + ptVar15 = next; + } while (next->next != (tcp_seg *)0x0); + if ((0 < (int)(seqno - uVar7)) && + (new_len = lwip_htons(next->tcphdr->_hdrlen_rsvd_flags), (new_len & 1) == 0)) { + cseg = tcp_seg_copy(&inseg); + next->next = cseg; + if (cseg != (tcp_seg *)0x0) { + uVar7 = next->tcphdr->seqno; + if (0 < (int)((next->len + uVar7) - seqno)) { + new_len = (u16_t)((seqno - uVar7) * 0x10000 >> 0x10); + next->len = new_len; + pbuf_realloc(next->p,new_len); + } + if (0 < (int)(((tcplen + seqno) - pcb->rcv_nxt) - (uint)pcb->rcv_wnd)) { + new_len = lwip_htons(next->next->tcphdr->_hdrlen_rsvd_flags); + if ((new_len & 1) != 0) { + n = next->next->tcphdr->_hdrlen_rsvd_flags; + new_len = lwip_htons(n); + new_len = lwip_htons(new_len & 0x3e); + ptVar9 = next->next->tcphdr; + uVar13 = (uint)n & 0xffffc0ff | (uint)new_len; + *(char *)&ptVar9->_hdrlen_rsvd_flags = (char)uVar13; + *(undefined *)((int)&ptVar9->_hdrlen_rsvd_flags + 1) = (char)(uVar13 >> 8); + } + next->next->len = (pcb->rcv_wnd - (short)seqno) + (short)pcb->rcv_nxt; + pbuf_realloc(next->next->p,next->next->len); + new_len = next->next->len; + uVar3 = lwip_htons(next->next->tcphdr->_hdrlen_rsvd_flags); + tcplen = new_len + ((uVar3 & 3) != 0); + } + } + } + } + goto LAB_23040308; + } + uVar13 = (uint)inseg.len; + new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + uVar13 = ((new_len & 3) != 0) + uVar13; + tcplen = (u16_t)(uVar13 * 0x10000 >> 0x10); + if ((uint)pcb->rcv_wnd < (uVar13 & 0xffff)) { + new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + if ((new_len & 1) != 0) { + n = (inseg.tcphdr)->_hdrlen_rsvd_flags; + new_len = lwip_htons(n); + new_len = lwip_htons(new_len & 0x3e); + ptVar9 = inseg.tcphdr; + uVar13 = (uint)n & 0xffffc0ff | (uint)new_len; + *(char *)&(inseg.tcphdr)->_hdrlen_rsvd_flags = (char)uVar13; + *(undefined *)((int)&ptVar9->_hdrlen_rsvd_flags + 1) = (char)(uVar13 >> 8); + } + inseg.len = pcb->rcv_wnd; + new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + if ((new_len & 2) != 0) { + inseg.len = inseg.len - 1; + } + pbuf_realloc(inseg.p,inseg.len); + new_len = inseg.len; + uVar3 = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + tcplen = new_len + ((uVar3 & 3) != 0); + } + if (pcb->ooseq != (tcp_seg *)0x0) { + new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + if ((new_len & 1) == 0) { + cseg = pcb->ooseq; + while (cseg != (tcp_seg *)0x0) { + uVar7 = cseg->tcphdr->seqno; + if ((int)((tcplen + seqno) - (cseg->len + uVar7)) < 0) { + if (0 < (int)((tcplen + seqno) - uVar7)) { + inseg.len = (short)uVar7 - (short)seqno; + new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + if ((new_len & 2) != 0) { + inseg.len = inseg.len - 1; + } + pbuf_realloc(inseg.p,inseg.len); + new_len = inseg.len; + uVar3 = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + tcplen = new_len + ((uVar3 & 3) != 0); + } + break; + } + new_len = lwip_htons(cseg->tcphdr->_hdrlen_rsvd_flags); + if (((new_len & 1) != 0) && + (new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags), (new_len & 2) == 0)) { + n = (inseg.tcphdr)->_hdrlen_rsvd_flags; + new_len = lwip_htons(1); + ptVar9 = inseg.tcphdr; + n = n | new_len; + *(char *)&(inseg.tcphdr)->_hdrlen_rsvd_flags = (char)n; + *(undefined *)((int)&ptVar9->_hdrlen_rsvd_flags + 1) = (char)((uint)n >> 8); + new_len = inseg.len; + uVar3 = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + tcplen = new_len + ((uVar3 & 3) != 0); + } + ptVar15 = cseg->next; + tcp_seg_free(cseg); + cseg = ptVar15; + } + pcb->ooseq = cseg; + } + else { + while (cseg = pcb->ooseq, cseg != (tcp_seg *)0x0) { + pcb->ooseq = cseg->next; + tcp_seg_free(cseg); + } + } + } + tVar10 = pcb->rcv_wnd - tcplen; + pcb->rcv_nxt = seqno + tcplen; + pcb->rcv_wnd = tVar10; + tcp_update_rcv_ann_wnd(pcb); + if ((inseg.p)->tot_len != 0) { + recv_data = inseg.p; + inseg.p = (pbuf *)0x0; + } + new_len = lwip_htons((inseg.tcphdr)->_hdrlen_rsvd_flags); + if ((new_len & 1) != 0) { + recv_flags = recv_flags | 0x20; + } + while (cseg = pcb->ooseq, cseg != (tcp_seg *)0x0) { + uVar7 = cseg->tcphdr->seqno; + if (uVar7 != pcb->rcv_nxt) break; + n = cseg->len; + seqno = uVar7; + new_len = lwip_htons(cseg->tcphdr->_hdrlen_rsvd_flags); + pcb->rcv_nxt = (uint)((new_len & 3) != 0) + (uint)n + pcb->rcv_nxt; + lwip_htons(cseg->tcphdr->_hdrlen_rsvd_flags); + new_len = cseg->len; + uVar3 = lwip_htons(cseg->tcphdr->_hdrlen_rsvd_flags); + pcb->rcv_wnd = pcb->rcv_wnd - (((uVar3 & 3) != 0) + new_len); + tcp_update_rcv_ann_wnd(pcb); + p = cseg->p; + if (p->tot_len != 0) { + if (recv_data != (pbuf *)0x0) { + pbuf_cat(recv_data,p); + p = recv_data; + } + recv_data = p; + cseg->p = (pbuf *)0x0; + } + new_len = lwip_htons(cseg->tcphdr->_hdrlen_rsvd_flags); + if (((new_len & 1) != 0) && (recv_flags = recv_flags | 0x20, pcb->state == ESTABLISHED)) { + pcb->state = CLOSE_WAIT; + } + pcb->ooseq = cseg->next; + tcp_seg_free(cseg); + } + n = pcb->flags; + if ((n & 1) == 0) { + tVar12 = n | 1; + goto LAB_230402d6; + } + tVar12 = n & 0xfffe; + } + tVar12 = tVar12 | 2; +LAB_230402d6: + pcb->flags = tVar12; + return; +} + + + +// WARNING: Restarted to delay deadcode elimination for space: ram + +void tcp_input(pbuf *p,netif *inp) + +{ + ushort uVar1; + u16_t uVar2; + byte bVar3; + tcp_hdr *ptVar4; + tcp_hdr *ptVar5; + tcp_pcb *ptVar6; + u8_t uVar7; + err_t eVar8; + u16_t sendmss; + tcpwnd_size_t tVar9; + undefined3 extraout_var; + undefined2 extraout_var_08; + undefined2 extraout_var_09; + undefined3 extraout_var_00; + tcp_pcb *pcb; + u32_t uVar10; + netif *outif; + undefined3 extraout_var_01; + undefined2 extraout_var_10; + tcp_seg *seg; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + undefined3 extraout_var_05; + undefined3 extraout_var_06; + undefined3 extraout_var_07; + uint header_size_decrement; + u32_t ackno; + int iVar11; + tcp_state tVar12; + u16_t uVar13; + tcpflags_t tVar14; + uint uVar15; + void *pvVar16; + tcp_accept_fn paVar17; + uint uVar18; + tcp_pcb *ptVar19; + pbuf *p_00; + u16_t remote_port; + tcp_pcb *ptVar20; + tcp_pcb *pcb_00; + + lwip_stats.tcp.recv = lwip_stats.tcp.recv + 1; + tcphdr = (tcp_hdr *)p->payload; + if (p->len < 0x14) goto LAB_230405b0; + uVar7 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_dest,ip_data.current_netif); + if ((CONCAT31(extraout_var,uVar7) == 0) && ((ip_data.current_iphdr_dest & 0xf0) != 0xe0)) { + sendmss = ip_chksum_pseudo(p,'\x06',p->tot_len,(ip4_addr_t *)&ip_data.current_iphdr_src, + (ip4_addr_t *)&ip_data.current_iphdr_dest); + if (CONCAT22(extraout_var_08,sendmss) == 0) { + sendmss = lwip_htons(tcphdr->_hdrlen_rsvd_flags); + header_size_decrement = CONCAT22(extraout_var_09,sendmss) >> 10 & 0xfc; + if ((0x13 < header_size_decrement) && (header_size_decrement <= p->tot_len)) { + tcphdr_optlen = (u16_t)((header_size_decrement - 0x14) * 0x10000 >> 0x10); + tcphdr_opt2 = (u8_t *)0x0; + if (p->len < header_size_decrement) { + pbuf_remove_header(p,0x14); + sendmss = tcphdr_optlen; + uVar1 = p->len; + header_size_decrement = (uint)tcphdr_optlen; + tcphdr_opt1len = uVar1; + pbuf_remove_header(p,(uint)uVar1); + p_00 = p->next; + header_size_decrement = header_size_decrement - (uint)uVar1 & 0xffff; + if (p_00->len < header_size_decrement) goto LAB_230405b0; + tcphdr_opt2 = (u8_t *)p_00->payload; + pbuf_remove_header(p_00,header_size_decrement); + p->tot_len = (uVar1 + p->tot_len) - sendmss; + } + else { + tcphdr_opt1len = tcphdr_optlen; + pbuf_remove_header(p,header_size_decrement); + } + ptVar4 = tcphdr; + sendmss = lwip_htons(tcphdr->src); + *(char *)&ptVar4->src = (char)sendmss; + *(undefined *)((int)&ptVar4->src + 1) = (char)(sendmss >> 8); + ptVar4 = tcphdr; + sendmss = lwip_htons(tcphdr->dest); + *(char *)&ptVar4->dest = (char)sendmss; + *(undefined *)((int)&ptVar4->dest + 1) = (char)(sendmss >> 8); + ptVar4 = tcphdr; + seqno = lwip_htonl(tcphdr->seqno); + *(undefined *)((int)&ptVar4->seqno + 1) = (char)(seqno >> 8); + *(undefined *)((int)&ptVar4->seqno + 2) = (char)(seqno >> 0x10); + *(char *)&ptVar4->seqno = (char)seqno; + *(undefined *)((int)&ptVar4->seqno + 3) = (char)(seqno >> 0x18); + ptVar4 = tcphdr; + ackno = lwip_htonl(tcphdr->ackno); + *(undefined *)((int)&ptVar4->ackno + 1) = (char)(ackno >> 8); + *(undefined *)((int)&ptVar4->ackno + 2) = (char)(ackno >> 0x10); + *(char *)&ptVar4->ackno = (char)ackno; + *(undefined *)((int)&ptVar4->ackno + 3) = (char)(ackno >> 0x18); + ptVar4 = tcphdr; + sendmss = lwip_htons(tcphdr->wnd); + ptVar5 = tcphdr; + *(char *)&ptVar4->wnd = (char)sendmss; + *(undefined *)((int)&ptVar4->wnd + 1) = (char)(sendmss >> 8); + sendmss = lwip_htons(ptVar5->_hdrlen_rsvd_flags); + ptVar19 = tcp_active_pcbs; + ptVar6 = tcp_listen_pcbs; + ptVar4 = tcphdr; + flags = (byte)sendmss & 0x3f; + tcplen = p->tot_len; + header_size_decrement = (uint)tcplen; + if (((sendmss & 3) == 0) || + (uVar15 = header_size_decrement + 1, tcplen = (u16_t)(uVar15 * 0x10000 >> 0x10), + header_size_decrement <= (uVar15 & 0xffff))) { + uVar2 = tcplen; + pcb = tcp_active_pcbs; + ptVar20 = (tcp_pcb *)0x0; +LAB_230407f2: + pcb_00 = pcb; + pcb = tcp_tw_pcbs; + if (pcb_00 == (tcp_pcb *)0x0) goto LAB_23040a58; + if (((((pcb_00->netif_idx != '\0') && + (pcb_00->netif_idx != (u8_t)((ip_data.current_input_netif)->num + '\x01'))) || + (pcb_00->remote_port != tcphdr->src)) || + ((pcb_00->local_port != tcphdr->dest || + ((pcb_00->remote_ip).addr != ip_data.current_iphdr_src)))) || + ((pcb_00->local_ip).addr != ip_data.current_iphdr_dest)) goto LAB_2304097e; + if (ptVar20 == (tcp_pcb *)0x0) { + lwip_stats.tcp.cachehit = lwip_stats.tcp.cachehit + 1; + } + else { + tcp_active_pcbs = pcb_00; + ptVar20->next = pcb_00->next; + pcb_00->next = ptVar19; + } + inseg.len = p->tot_len; + recv_data = (pbuf *)0x0; + recv_flags = '\0'; + recv_acked = 0; + inseg.next = (tcp_seg *)0x0; + inseg.tcphdr = ptVar4; + inseg.p = p; + if ((sendmss & 8) != 0) { + p->flags = p->flags | 1; + } + if ((pcb_00->refused_data != (pbuf *)0x0) && + ((eVar8 = tcp_process_refused_data(pcb_00), CONCAT31(extraout_var_00,eVar8) == -0xd || + ((pcb_00->refused_data != (pbuf *)0x0 && (tcplen != 0)))))) { + if (pcb_00->rcv_ann_wnd == 0) { + tcp_send_empty_ack(pcb_00); + } + lwip_stats.tcp.drop = lwip_stats.tcp.drop + 1; + goto aborted; + } + uVar7 = flags; + tcp_input_pcb = pcb_00; + if ((flags & 4) != 0) { + if (pcb_00->state == SYN_SENT) { + if (pcb_00->snd_nxt != ackno) goto switchD_23040d14_caseD_8; + } + else { + if (pcb_00->rcv_nxt != seqno) { + iVar11 = seqno - pcb_00->rcv_nxt; + if ((-1 < iVar11) && ((int)(iVar11 - (uint)pcb_00->rcv_wnd) < 1)) goto LAB_23040ca0; + goto switchD_23040d14_caseD_8; + } + } + recv_flags = recv_flags | 8; + tVar14 = pcb_00->flags & 0xfffe; +LAB_23040c5a: + pcb_00->flags = tVar14; + goto switchD_23040d14_caseD_8; + } + bVar3 = flags & 2; + tVar14 = pcb_00->flags; + if (((flags & 2) != 0) && (1 < (byte)(pcb_00->state + ~LISTEN))) { +LAB_23040cc2: + tVar14 = tVar14 | 2; + goto LAB_23040c5a; + } + if ((tVar14 & 0x10) == 0) { + pcb_00->tmr = tcp_ticks; + } + *(undefined2 *)&pcb_00->persist_probe = 0; + if (tcphdr_optlen != 0) { + tcp_parseopt(&pcb_00->mss); + } + ackno = seqno; + switch((uint)pcb_00->state - 2 & 0xff) { + case 0: + if (((uVar7 & 0x12) != 0x12) || (uVar10 = pcb_00->lastack + 1, uVar10 != ackno)) { + if (((uVar7 & 0x10) != 0) && + (tcp_rst(pcb_00,ackno,seqno + tcplen,&ip_data.current_iphdr_dest, + &ip_data.current_iphdr_src,tcphdr->dest,tcphdr->src), pcb_00->nrtx < 6)) { + pcb_00->rtime = 0; + tcp_rexmit_rto(pcb_00); + } + goto switchD_23040d14_caseD_8; + } + pcb_00->lastack = uVar10; + uVar10 = ackno + 1; + pcb_00->rcv_nxt = uVar10; + pcb_00->rcv_ann_right_edge = uVar10; + sendmss = pcb_00->mss; + uVar2 = tcphdr->wnd; + pcb_00->snd_wl1 = ackno - 1; + pcb_00->snd_wnd = uVar2; + pcb_00->snd_wnd_max = uVar2; + pcb_00->state = ESTABLISHED; + outif = ip4_route((ip4_addr_t *)&pcb_00->remote_ip); + sendmss = tcp_eff_send_mss_netif + (sendmss,outif,(ip_addr_t *)(ip4_addr_t *)&pcb_00->remote_ip); + iVar11 = CONCAT22(extraout_var_10,sendmss); + uVar15 = iVar11 << 1; + pcb_00->mss = sendmss; + tVar9 = 0x111c; + header_size_decrement = uVar15; + if (uVar15 < 0x111c) { + header_size_decrement = 0x111c; + } + if ((uint)(iVar11 << 2) < header_size_decrement) { + tVar9 = (tcpwnd_size_t)((uint)(iVar11 << 0x12) >> 0x10); + } + else { + if (0x111c < uVar15) { + tVar9 = (tcpwnd_size_t)((uint)(iVar11 << 0x11) >> 0x10); + } + } + pcb_00->cwnd = tVar9; + seg = pcb_00->unacked; + pcb_00->snd_queuelen = pcb_00->snd_queuelen - 1; + if (seg == (tcp_seg *)0x0) { + seg = pcb_00->unsent; + pcb_00->unsent = seg->next; + } + else { + pcb_00->unacked = seg->next; + } + tcp_seg_free(seg); + if (pcb_00->unacked == (tcp_seg *)0x0) { + pcb_00->rtime = -1; + } + else { + pcb_00->rtime = 0; + pcb_00->nrtx = '\0'; + } + if ((pcb_00->connected == (tcp_connected_fn)0x0) || + (eVar8 = (*pcb_00->connected)(pcb_00->callback_arg,pcb_00,'\0'), + CONCAT31(extraout_var_02,eVar8) != -0xd)) { +LAB_23040ca0: + tVar14 = pcb_00->flags; + goto LAB_23040cc2; + } + goto aborted; + case 1: + if ((uVar7 & 0x10) == 0) { + if ((bVar3 != 0) && (pcb_00->rcv_nxt - 1 == seqno)) { + tcp_rexmit(pcb_00); + } + goto switchD_23040d14_caseD_8; + } + if (((int)((ackno - 1) - pcb_00->lastack) < 0) || (0 < (int)(ackno - pcb_00->snd_nxt))) + { + tcp_rst(pcb_00,ackno,seqno + tcplen,&ip_data.current_iphdr_dest, + &ip_data.current_iphdr_src,tcphdr->dest,tcphdr->src); + goto switchD_23040d14_caseD_8; + } + pcb_00->state = ESTABLISHED; + if ((pcb_00->listener == (tcp_pcb_listen *)0x0) || + (paVar17 = pcb_00->listener->accept, paVar17 == (tcp_accept_fn)0x0)) + goto LAB_23040e74; + eVar8 = (*paVar17)(pcb_00->callback_arg,pcb_00,'\0'); + if (CONCAT31(extraout_var_03,eVar8) != 0) { + if (CONCAT31(extraout_var_03,eVar8) == -0xd) goto aborted; + goto LAB_23040e74; + } + tcp_receive(pcb_00); + if (recv_acked != 0) { + recv_acked = recv_acked - 1; + } + uVar18 = (uint)pcb_00->mss; + uVar15 = uVar18 << 1; + tVar9 = 0x111c; + header_size_decrement = uVar15; + if (uVar15 < 0x111c) { + header_size_decrement = 0x111c; + } + if (uVar18 << 2 < header_size_decrement) { + tVar9 = (tcpwnd_size_t)((uVar18 << 0x12) >> 0x10); + } + else { + if (0x111c < uVar15) { + tVar9 = (tcpwnd_size_t)((uVar18 << 0x11) >> 0x10); + } + } + pcb_00->cwnd = tVar9; + break; + case 2: + case 5: + tcp_receive(pcb_00); + break; + case 3: + tcp_receive(pcb_00); + if ((recv_flags & 0x20) != 0) { + if ((((flags & 0x10) == 0) || (pcb_00->snd_nxt != ackno)) || + (pcb_00->unsent != (tcp_seg *)0x0)) { + pcb_00->flags = pcb_00->flags | 2; + tVar12 = CLOSING; + goto LAB_23040ee6; + } + pcb_00->flags = pcb_00->flags | 2; + tcp_pcb_purge(pcb_00); + ptVar6 = tcp_active_pcbs; + if (pcb_00 == tcp_active_pcbs) goto LAB_23040f92; + goto LAB_23040fa8; + } + if ((((flags & 0x10) == 0) || (pcb_00->snd_nxt != ackno)) || + (pcb_00->unsent != (tcp_seg *)0x0)) goto switchD_23040d14_caseD_8; + tVar12 = FIN_WAIT_2; + goto LAB_23040ee6; + case 4: + tcp_receive(pcb_00); + if ((recv_flags & 0x20) == 0) goto switchD_23040d14_caseD_8; + pcb_00->flags = pcb_00->flags | 2; + tcp_pcb_purge(pcb_00); + ptVar6 = tcp_active_pcbs; + if (pcb_00 == tcp_active_pcbs) goto LAB_23040f92; + goto LAB_23041024; + case 6: + tcp_receive(pcb_00); + if ((((flags & 0x10) == 0) || (pcb_00->snd_nxt != ackno)) || + (pcb_00->unsent != (tcp_seg *)0x0)) goto switchD_23040d14_caseD_8; + tcp_pcb_purge(pcb_00); + ptVar6 = tcp_active_pcbs; + if (pcb_00 != tcp_active_pcbs) goto LAB_2304105e; +LAB_23040f92: + tcp_active_pcbs = pcb_00->next; + goto LAB_23040faa; + case 7: + tcp_receive(pcb_00); + if ((((flags & 0x10) != 0) && (pcb_00->snd_nxt == ackno)) && + (pcb_00->unsent == (tcp_seg *)0x0)) { + recv_flags = recv_flags | 0x10; + } + default: + goto switchD_23040d14_caseD_8; + } + if ((recv_flags & 0x20) == 0) goto switchD_23040d14_caseD_8; + pcb_00->flags = pcb_00->flags | 2; + tVar12 = CLOSE_WAIT; +LAB_23040ee6: + pcb_00->state = tVar12; + goto switchD_23040d14_caseD_8; + } + } +LAB_230405b0: + lwip_stats.tcp.lenerr = lwip_stats.tcp.lenerr + 1; + } + else { + lwip_stats.tcp.chkerr = lwip_stats.tcp.chkerr + 1; + } + } + else { + lwip_stats.tcp.proterr = lwip_stats.tcp.proterr + 1; + } + lwip_stats.tcp.drop = lwip_stats.tcp.drop + 1; +LAB_23040a34: + pbuf_free(p); + return; +LAB_23040a58: + if (pcb == (tcp_pcb *)0x0) goto code_r0x23040a5a; + if ((((pcb->netif_idx == '\0') || + (pcb->netif_idx == (u8_t)((ip_data.current_input_netif)->num + '\x01'))) && + ((remote_port = pcb->remote_port, remote_port == tcphdr->src && + ((uVar13 = pcb->local_port, uVar13 == tcphdr->dest && + (ip_data.current_iphdr_src == (pcb->remote_ip).addr)))))) && + (ip_data.current_iphdr_dest == (pcb->local_ip).addr)) { + if ((sendmss & 4) != 0) goto LAB_23040a34; + if ((sendmss & 2) == 0) { + if ((sendmss & 1) != 0) { + pcb->tmr = tcp_ticks; + } + } + else { + iVar11 = seqno - pcb->rcv_nxt; + if ((-1 < iVar11) && ((int)(iVar11 - (uint)pcb->rcv_wnd) < 1)) { + ackno = tcplen + seqno; + goto LAB_23040a0e; + } + } + if (uVar2 == 0) goto LAB_23040a34; + pcb->flags = pcb->flags | 2; + goto LAB_23040a30; + } + pcb = pcb->next; + goto LAB_23040a58; +code_r0x23040a5a: + ptVar20 = (tcp_pcb *)0x0; + pcb_00 = (tcp_pcb *)0x0; + ptVar19 = tcp_listen_pcbs; + while (ptVar19 != (tcp_pcb *)0x0) { + if (((ptVar19->netif_idx == '\0') || + (ptVar19->netif_idx == (u8_t)((ip_data.current_input_netif)->num + '\x01'))) && + (ptVar19->local_port == tcphdr->dest)) { + ackno = (ptVar19->local_ip).addr; + if (ip_data.current_iphdr_dest == ackno) goto LAB_23040ab6; + if (ackno == 0) { + ptVar20 = ptVar19; + pcb_00 = pcb; + } + } + pcb = ptVar19; + ptVar19 = ptVar19->next; + } + pcb = pcb_00; + ptVar19 = ptVar20; + if (ptVar20 == (tcp_pcb *)0x0) { + sendmss = lwip_htons(tcphdr->_hdrlen_rsvd_flags); + if ((sendmss & 4) != 0) goto LAB_23040a34; + lwip_stats.tcp.proterr = lwip_stats.tcp.proterr + 1; + lwip_stats.tcp.drop = lwip_stats.tcp.drop + 1; + remote_port = tcphdr->src; + uVar13 = tcphdr->dest; + ackno = seqno + tcplen; + pcb = (tcp_pcb *)0x0; + } + else { +LAB_23040ab6: + if (pcb == (tcp_pcb *)0x0) { + lwip_stats.tcp.cachehit = lwip_stats.tcp.cachehit + 1; + } + else { + tcp_listen_pcbs = ptVar19; + pcb->next = ptVar19->next; + ptVar19->next = ptVar6; + } + if ((sendmss & 4) != 0) goto LAB_23040a34; + if ((sendmss & 0x10) == 0) { + if ((sendmss & 2) != 0) { + pcb = tcp_alloc(ptVar19->prio); + ptVar4 = tcphdr; + if (pcb == (tcp_pcb *)0x0) { + lwip_stats.tcp.memerr = lwip_stats.tcp.memerr + 1; + if (*(code **)&ptVar19->remote_port != (code *)0x0) { + (**(code **)&ptVar19->remote_port)(ptVar19->callback_arg,0,0xffffffff); + } + } + else { + (pcb->local_ip).addr = ip_data.current_iphdr_dest; + (pcb->remote_ip).addr = ip_data.current_iphdr_src; + pcb->local_port = ptVar19->local_port; + pcb->remote_port = ptVar4->src; + pcb->state = SYN_RCVD; + ackno = seqno + 1; + pcb->rcv_nxt = ackno; + pcb->rcv_ann_right_edge = ackno; + uVar10 = tcp_next_iss(pcb); + ackno = seqno; + pcb->snd_wl2 = uVar10; + pcb->snd_nxt = uVar10; + pcb->lastack = uVar10; + pcb->snd_lbb = uVar10; + pcb->snd_wl1 = ackno - 1; + pvVar16 = ptVar19->callback_arg; + *(tcp_pcb **)&pcb->listener = ptVar19; + pcb->callback_arg = pvVar16; + pcb->so_options = ptVar19->so_options & 0xc; + pcb->netif_idx = ptVar19->netif_idx; + ptVar6 = pcb; + pcb->next = tcp_active_pcbs; + tcp_active_pcbs = ptVar6; + tcp_timer_needed(); + tcp_active_pcbs_changed = '\x01'; + if (tcphdr_optlen != 0) { + tcp_parseopt(&pcb->mss); + } + uVar2 = tcphdr->wnd; + sendmss = pcb->mss; + pcb->snd_wnd = uVar2; + pcb->snd_wnd_max = uVar2; + outif = ip4_route((ip4_addr_t *)&pcb->remote_ip); + sendmss = tcp_eff_send_mss_netif(sendmss,outif,(ip_addr_t *)(ip4_addr_t *)&pcb->remote_ip) + ; + pcb->mss = sendmss; + eVar8 = tcp_enqueue_flags(pcb,'\x12'); + if (CONCAT31(extraout_var_01,eVar8) == 0) { +LAB_23040a30: + tcp_output(pcb); + } + else { + tcp_abandon(pcb,0); + } + } + } + goto LAB_23040a34; + } + remote_port = tcphdr->src; + uVar13 = tcphdr->dest; + ackno = seqno + tcplen; + pcb = ptVar19; + } +LAB_23040a0e: + tcp_rst(pcb,ackno,ackno,&ip_data.current_iphdr_dest,&ip_data.current_iphdr_src,uVar13,remote_port) + ; + goto LAB_23040a34; +LAB_2304097e: + pcb = pcb_00->next; + ptVar20 = pcb_00; + goto LAB_230407f2; + while (ptVar6 = ptVar19->next, pcb_00 != ptVar19->next) { +LAB_2304105e: + ptVar19 = ptVar6; + if (ptVar19 == (tcp_pcb *)0x0) goto LAB_23040faa; + } + goto LAB_23040fa0; + while (ptVar6 = ptVar19->next, pcb_00 != ptVar19->next) { +LAB_23041024: + ptVar19 = ptVar6; + if (ptVar19 == (tcp_pcb *)0x0) goto LAB_23040faa; + } + goto LAB_23040fa0; + while (ptVar6 = ptVar19->next, pcb_00 != ptVar19->next) { +LAB_23040fa8: + ptVar19 = ptVar6; + if (ptVar19 == (tcp_pcb *)0x0) goto LAB_23040faa; + } +LAB_23040fa0: + ptVar19->next = pcb_00->next; +LAB_23040faa: + tcp_active_pcbs_changed = '\x01'; + pcb_00->state = TIME_WAIT; + ptVar6 = pcb_00; + pcb_00->next = tcp_tw_pcbs; + tcp_tw_pcbs = ptVar6; + tcp_timer_needed(); +switchD_23040d14_caseD_8: + if ((recv_flags & 8) == 0) { + if (recv_acked != 0) { + if ((pcb_00->sent != (tcp_sent_fn *)0x0) && + (eVar8 = (*pcb_00->sent)(pcb_00->callback_arg,pcb_00,recv_acked), + CONCAT31(extraout_var_04,eVar8) == -0xd)) goto aborted; + recv_acked = 0; + } + iVar11 = tcp_input_delayed_close(pcb_00); + if (iVar11 == 0) { + if (recv_data != (pbuf *)0x0) { + if ((pcb_00->flags & 0x10) != 0) { + pbuf_free(recv_data); +LAB_23040e74: + tcp_abort(pcb_00); + goto aborted; + } + if (pcb_00->recv == (tcp_recv_fn *)0x0) { + eVar8 = tcp_recv_null((void *)0x0,pcb_00,recv_data,'\0'); + iVar11 = CONCAT31(extraout_var_06,eVar8); + } + else { + eVar8 = (*pcb_00->recv)(pcb_00->callback_arg,pcb_00,recv_data,'\0'); + iVar11 = CONCAT31(extraout_var_05,eVar8); + } + if (iVar11 == -0xd) goto aborted; + if (iVar11 != 0) { + pcb_00->refused_data = recv_data; + } + } + if ((recv_flags & 0x20) != 0) { + p_00 = pcb_00->refused_data; + if (p_00 == (pbuf *)0x0) { + if (pcb_00->rcv_wnd != 0x810) { + pcb_00->rcv_wnd = pcb_00->rcv_wnd + 1; + } + if ((pcb_00->recv != (tcp_recv_fn *)0x0) && + (eVar8 = (*pcb_00->recv)(pcb_00->callback_arg,pcb_00,(pbuf *)0x0,'\0'), + CONCAT31(extraout_var_07,eVar8) == -0xd)) goto aborted; + } + else { + p_00->flags = p_00->flags | 0x20; + } + } + tcp_input_pcb = (tcp_pcb *)0x0; + iVar11 = tcp_input_delayed_close(pcb_00); + if (iVar11 == 0) { + tcp_output(pcb_00); + } + } + } + else { + if (pcb_00->errf != (tcp_err_fn *)0x0) { + (*pcb_00->errf)(pcb_00->callback_arg,-0xe); + } + tcp_pcb_remove(&tcp_active_pcbs,pcb_00); + tcp_free(pcb_00); + } +aborted: + tcp_input_pcb = (tcp_pcb *)0x0; + recv_data = (pbuf *)0x0; + if (inseg.p != (pbuf *)0x0) { + pbuf_free(inseg.p); + inseg.p = (pbuf *)0x0; + } + return; +} + + + +void tcp_trigger_input_pcb_close(void) + +{ + recv_flags = recv_flags | 0x10; + return; +} + + + +void tcp_seg_add_chksum(u16_t chksum,u16_t len,u16_t *seg_chksum,u8_t *seg_chksum_swapped) + +{ + ushort uVar1; + undefined2 in_register_0000202a; + uint uVar2; + + uVar2 = CONCAT22(in_register_0000202a,chksum) + (uint)*seg_chksum; + uVar2 = uVar2 + (uVar2 >> 0x10) & 0xffff; + uVar1 = (ushort)uVar2; + if ((len & 1) != 0) { + *seg_chksum_swapped = '\x01' - *seg_chksum_swapped; + uVar1 = (ushort)(uVar2 >> 8) | (ushort)(uVar2 << 8); + } + *seg_chksum = uVar1; + return; +} + + + +tcp_seg * tcp_create_segment(tcp_pcb *pcb,pbuf *p,u8_t hdrflags,u32_t seqno,u8_t optflags) + +{ + tcp_seg *seg; + u8_t uVar1; + u16_t uVar2; + undefined3 extraout_var; + u32_t uVar3; + undefined3 in_register_00002031; + tcp_hdr *ptVar4; + + seg = (tcp_seg *)memp_malloc(MEMP_TCP_SEG); + if (seg == (tcp_seg *)0x0) { + pbuf_free(p); + } + else { + seg->flags = optflags; + seg->next = (tcp_seg *)0x0; + seg->p = p; + uVar2 = p->tot_len; + seg->chksum = 0; + seg->len = uVar2 + ((ushort)optflags & 1) * -4; + seg->chksum_swapped = '\0'; + uVar1 = pbuf_add_header(p,0x14); + if (CONCAT31(extraout_var,uVar1) == 0) { + ptVar4 = (tcp_hdr *)seg->p->payload; + seg->tcphdr = ptVar4; + uVar2 = lwip_htons(pcb->local_port); + *(char *)&ptVar4->src = (char)uVar2; + *(undefined *)((int)&ptVar4->src + 1) = (char)(uVar2 >> 8); + ptVar4 = seg->tcphdr; + uVar2 = lwip_htons(pcb->remote_port); + *(char *)&ptVar4->dest = (char)uVar2; + *(undefined *)((int)&ptVar4->dest + 1) = (char)(uVar2 >> 8); + ptVar4 = seg->tcphdr; + uVar3 = lwip_htonl(seqno); + *(char *)&ptVar4->seqno = (char)uVar3; + *(undefined *)((int)&ptVar4->seqno + 1) = (char)(uVar3 >> 8); + *(undefined *)((int)&ptVar4->seqno + 3) = (char)(uVar3 >> 0x18); + *(undefined *)((int)&ptVar4->seqno + 2) = (char)(uVar3 >> 0x10); + ptVar4 = seg->tcphdr; + uVar2 = lwip_htons((((ushort)optflags & 1) + 5) * 0x1000 | + (ushort)CONCAT31(in_register_00002031,hdrflags)); + *(char *)&ptVar4->_hdrlen_rsvd_flags = (char)uVar2; + *(undefined *)((int)&ptVar4->_hdrlen_rsvd_flags + 1) = (char)(uVar2 >> 8); + ptVar4 = seg->tcphdr; + *(undefined *)&ptVar4->urgp = 0; + *(undefined *)((int)&ptVar4->urgp + 1) = 0; + } + else { + lwip_stats.tcp.err = lwip_stats.tcp.err + 1; + tcp_seg_free(seg); + seg = (tcp_seg *)0x0; + } + } + return seg; +} + + + +pbuf * tcp_output_alloc_header_common + (u32_t ackno,u16_t datalen,u32_t seqno_be,u16_t src_port,u16_t dst_port,u8_t flags, + u16_t wnd) + +{ + undefined *puVar1; + u16_t uVar2; + pbuf *ppVar3; + u32_t uVar4; + undefined2 in_register_0000202e; + undefined3 in_register_0000203d; + + ppVar3 = pbuf_alloc(PBUF_IP,(u16_t)((uint)((CONCAT22(in_register_0000202e,datalen) + 0x14) * + 0x10000) >> 0x10),PBUF_RAM); + if (ppVar3 != (pbuf *)0x0) { + puVar1 = (undefined *)ppVar3->payload; + uVar2 = lwip_htons(src_port); + *puVar1 = (char)uVar2; + puVar1[1] = (char)(uVar2 >> 8); + uVar2 = lwip_htons(dst_port); + puVar1[2] = (char)uVar2; + puVar1[4] = (char)seqno_be; + puVar1[5] = (char)(seqno_be >> 8); + puVar1[3] = (char)(uVar2 >> 8); + puVar1[6] = (char)(seqno_be >> 0x10); + puVar1[7] = (char)(seqno_be >> 0x18); + uVar4 = lwip_htonl(ackno); + puVar1[8] = (char)uVar4; + puVar1[9] = (char)(uVar4 >> 8); + puVar1[0xb] = (char)(uVar4 >> 0x18); + puVar1[10] = (char)(uVar4 >> 0x10); + uVar2 = lwip_htons((ushort)CONCAT31(in_register_0000203d,flags) | 0x5000); + puVar1[0xc] = (char)uVar2; + puVar1[0xd] = (char)(uVar2 >> 8); + uVar2 = lwip_htons(wnd); + puVar1[0xe] = (char)uVar2; + puVar1[0xf] = (char)(uVar2 >> 8); + puVar1[0x10] = 0; + puVar1[0x11] = 0; + puVar1[0x12] = 0; + puVar1[0x13] = 0; + } + return ppVar3; +} + + + +pbuf * tcp_output_alloc_header(tcp_pcb *pcb,u16_t datalen,u32_t seqno_be) + +{ + pbuf *ppVar1; + + ppVar1 = tcp_output_alloc_header_common + (pcb->rcv_nxt,datalen,seqno_be,pcb->local_port,pcb->remote_port,'\x10', + pcb->rcv_ann_wnd); + if (ppVar1 != (pbuf *)0x0) { + pcb->rcv_ann_right_edge = pcb->rcv_nxt + (uint)pcb->rcv_ann_wnd; + } + return ppVar1; +} + + + +err_t tcp_output_control_segment(tcp_pcb *pcb,pbuf *p,ip_addr_t *src,ip_addr_t *dst) + +{ + err_t eVar1; + u16_t uVar2; + netif *netif; + u8_t ttl; + u8_t tos; + void *pvVar3; + + if ((pcb == (tcp_pcb *)0x0) || (pcb->netif_idx == '\0')) { + netif = ip4_route((ip4_addr_t *)dst); + } + else { + netif = netif_get_by_index(pcb->netif_idx); + } + eVar1 = -4; + if (netif != (netif *)0x0) { + pvVar3 = p->payload; + uVar2 = ip_chksum_pseudo(p,'\x06',p->tot_len,(ip4_addr_t *)src,(ip4_addr_t *)dst); + *(undefined *)((int)pvVar3 + 0x10) = (char)uVar2; + *(undefined *)((int)pvVar3 + 0x11) = (char)(uVar2 >> 8); + if (pcb == (tcp_pcb *)0x0) { + tos = '\0'; + ttl = -1; + } + else { + ttl = pcb->ttl; + tos = pcb->tos; + } + lwip_stats.tcp.xmit = lwip_stats.tcp.xmit + 1; + eVar1 = ip4_output_if(p,(ip4_addr_t *)src,(ip4_addr_t *)dst,ttl,tos,'\x06',netif); + } + pbuf_free(p); + return eVar1; +} + + + +err_t tcp_split_unsent_seg(tcp_pcb *pcb,u16_t split) + +{ + byte bVar1; + ushort *puVar2; + ushort uVar3; + tcp_seg *ptVar4; + uint uVar5; + u16_t len; + u16_t uVar6; + pbuf *p; + undefined2 extraout_var; + u32_t uVar7; + tcp_seg *ptVar8; + undefined2 in_register_0000202e; + byte hdrflags; + tcp_hdr *ptVar9; + int iVar10; + uint uVar11; + uint uVar12; + u8_t uStack51; + u16_t uStack50; + u8_t chksum_swapped; + u16_t chksum; + + uVar5 = CONCAT22(in_register_0000202e,split); + ptVar4 = pcb->unsent; + uStack50 = 0; + uStack51 = '\0'; + if (ptVar4 != (tcp_seg *)0x0) { + if (uVar5 == 0) { + return -6; + } + uVar11 = (uint)ptVar4->len; + if (uVar11 <= uVar5) { + return '\0'; + } + bVar1 = ptVar4->flags; + iVar10 = ((uint)bVar1 & 1) * 4; + uVar12 = uVar11 - uVar5 & 0xffff; + p = pbuf_alloc(PBUF_TRANSPORT,(u16_t)((uVar12 + iVar10) * 0x10000 >> 0x10),PBUF_RAM); + if ((p != (pbuf *)0x0) && + (len = pbuf_copy_partial(ptVar4->p,(void *)((int)p->payload + iVar10), + (u16_t)((uVar11 - uVar5) * 0x10000 >> 0x10), + (u16_t)((((uint)ptVar4->p->tot_len - (uint)ptVar4->len) + uVar5) * + 0x10000 >> 0x10)), CONCAT22(extraout_var,len) == uVar12)) { + uVar6 = inet_chksum((void *)((int)p->payload + iVar10),len); + tcp_seg_add_chksum(~uVar6,len,&uStack50,&uStack51); + len = lwip_htons(ptVar4->tcphdr->_hdrlen_rsvd_flags); + hdrflags = (byte)len & 8; + if ((len & 8) == 0) { + len = len & 0x3f; + } + else { + len = len & 0x37; + hdrflags = 8; + } + if ((len & 1) != 0) { + len = len & 0xfe; + hdrflags = hdrflags | 1; + } + uVar7 = lwip_htonl(ptVar4->tcphdr->seqno); + ptVar8 = tcp_create_segment(pcb,p,hdrflags,uVar5 + uVar7,bVar1 & 0xfb); + if (ptVar8 != (tcp_seg *)0x0) { + ptVar8->chksum = uStack50; + ptVar8->chksum_swapped = uStack51; + ptVar8->flags = ptVar8->flags | 4; + uVar6 = pbuf_clen(ptVar4->p); + pcb->snd_queuelen = pcb->snd_queuelen - uVar6; + pbuf_realloc(ptVar4->p, + (u16_t)(((uint)ptVar4->p->tot_len + (uVar5 - uVar11 & 0xffff)) * 0x10000 >> + 0x10)); + ptVar4->len = (short)((uVar5 - uVar11) * 0x10000 >> 0x10) + ptVar4->len; + uVar3 = ptVar4->tcphdr->_hdrlen_rsvd_flags; + len = lwip_htons(len); + ptVar9 = ptVar4->tcphdr; + uVar3 = uVar3 | len; + *(char *)&ptVar9->_hdrlen_rsvd_flags = (char)uVar3; + *(undefined *)((int)&ptVar9->_hdrlen_rsvd_flags + 1) = (char)((uint)uVar3 >> 8); + len = pbuf_clen(ptVar4->p); + pcb->snd_queuelen = len + pcb->snd_queuelen; + p = ptVar4->p; + ptVar4->chksum = 0; + ptVar4->chksum_swapped = '\0'; + uVar5 = (uint)p->tot_len - (uint)ptVar4->len; + while( true ) { + uVar5 = uVar5 & 0xffff; + puVar2 = &p->len; + if (uVar5 <= *puVar2) break; + p = p->next; + uVar5 = uVar5 - *puVar2; + if (p == (pbuf *)0x0) goto LAB_230416fa; + } + do { + len = inet_chksum((void *)((int)p->payload + uVar5), + (u16_t)((p->len - uVar5) * 0x10000 >> 0x10)); + tcp_seg_add_chksum(~len,(u16_t)((p->len - uVar5) * 0x10000 >> 0x10),&ptVar4->chksum, + &ptVar4->chksum_swapped); + p = p->next; + uVar5 = 0; + } while (p != (pbuf *)0x0); +LAB_230416fa: + len = pbuf_clen(ptVar8->p); + pcb->snd_queuelen = len + pcb->snd_queuelen; + ptVar8->next = ptVar4->next; + ptVar4->next = ptVar8; + ptVar4 = ptVar8->next; + if (ptVar4 != (tcp_seg *)0x0) { + return '\0'; + } + pcb->unsent_oversize = 0; + return (err_t)ptVar4; + } + } + lwip_stats.tcp.memerr = lwip_stats.tcp.memerr + 1; + if (p != (pbuf *)0x0) { + pbuf_free(p); + } + } + return -1; +} + + + +err_t tcp_enqueue_flags(tcp_pcb *pcb,u8_t flags) + +{ + err_t eVar1; + u16_t uVar2; + pbuf *p; + tcp_seg *ptVar3; + uint uVar4; + tcp_seg *ptVar5; + tcp_seg *ptVar6; + + uVar4 = ((uint)flags & 2) >> 1; + p = pbuf_alloc(PBUF_TRANSPORT,(u16_t)(uVar4 << 2),PBUF_RAM); + if ((p == (pbuf *)0x0) || + (ptVar3 = tcp_create_segment(pcb,p,flags,pcb->snd_lbb,(u8_t)uVar4), ptVar3 == (tcp_seg *)0x0)) + { + eVar1 = -1; + pcb->flags = pcb->flags | 0x80; + lwip_stats.tcp.memerr = lwip_stats.tcp.memerr + 1; + } + else { + ptVar5 = pcb->unsent; + if (pcb->unsent == (tcp_seg *)0x0) { + pcb->unsent = ptVar3; + } + else { + do { + ptVar6 = ptVar5; + ptVar5 = ptVar6->next; + } while (ptVar5 != (tcp_seg *)0x0); + ptVar6->next = ptVar3; + } + pcb->unsent_oversize = 0; + if ((flags & 3) != 0) { + pcb->snd_lbb = pcb->snd_lbb + 1; + } + if ((flags & 1) != 0) { + pcb->flags = pcb->flags | 0x20; + } + uVar2 = pbuf_clen(ptVar3->p); + pcb->snd_queuelen = uVar2 + pcb->snd_queuelen; + eVar1 = '\0'; + } + return eVar1; +} + + + +err_t tcp_send_fin(tcp_pcb *pcb) + +{ + ushort uVar1; + tcp_seg *ptVar2; + tcp_seg *ptVar3; + err_t eVar4; + u16_t uVar5; + tcp_hdr *ptVar6; + + ptVar2 = pcb->unsent; + if (pcb->unsent != (tcp_seg *)0x0) { + do { + ptVar3 = ptVar2; + ptVar2 = ptVar3->next; + } while (ptVar3->next != (tcp_seg *)0x0); + uVar5 = lwip_htons(ptVar3->tcphdr->_hdrlen_rsvd_flags); + if ((uVar5 & 7) == 0) { + uVar1 = ptVar3->tcphdr->_hdrlen_rsvd_flags; + uVar5 = lwip_htons(1); + ptVar6 = ptVar3->tcphdr; + uVar1 = uVar5 | uVar1; + *(char *)&ptVar6->_hdrlen_rsvd_flags = (char)uVar1; + *(undefined *)((int)&ptVar6->_hdrlen_rsvd_flags + 1) = (char)((uint)uVar1 >> 8); + pcb->flags = pcb->flags | 0x20; + return '\0'; + } + } + eVar4 = tcp_enqueue_flags(pcb,'\x01'); + return eVar4; +} + + + +err_t tcp_rexmit_rto_prepare(tcp_pcb *pcb) + +{ + u8_t uVar1; + ushort uVar2; + tcp_seg *ptVar3; + u16_t uVar4; + u32_t uVar5; + tcp_seg *ptVar6; + + ptVar3 = pcb->unacked; + if (pcb->unacked != (tcp_seg *)0x0) { + do { + uVar1 = ptVar3->p->ref; + if (ptVar3->next == (tcp_seg *)0x0) { + if (uVar1 != '\x01') { + return -6; + } + ptVar3->next = pcb->unsent; + ptVar6 = pcb->unacked; + pcb->unacked = (tcp_seg *)0x0; + pcb->unsent = ptVar6; + pcb->flags = pcb->flags | 0x800; + uVar5 = lwip_htonl(ptVar3->tcphdr->seqno); + uVar2 = ptVar3->len; + uVar4 = lwip_htons(ptVar3->tcphdr->_hdrlen_rsvd_flags); + pcb->rto_end = (uint)((uVar4 & 3) != 0) + uVar5 + uVar2; + pcb->rttest = 0; + return '\0'; + } + ptVar3 = ptVar3->next; + } while (uVar1 == '\x01'); + } + return -6; +} + + + +err_t tcp_rexmit(tcp_pcb *pcb) + +{ + tcp_seg *ptVar1; + u32_t uVar2; + u32_t uVar3; + err_t eVar4; + tcp_seg *ptVar5; + + ptVar1 = pcb->unacked; + eVar4 = -6; + if ((ptVar1 != (tcp_seg *)0x0) && (eVar4 = -6, ptVar1->p->ref == '\x01')) { + ptVar5 = (tcp_seg *)&pcb->unsent; + pcb->unacked = ptVar1->next; + while (ptVar5->next != (tcp_seg *)0x0) { + uVar2 = lwip_htonl(ptVar5->next->tcphdr->seqno); + uVar3 = lwip_htonl(ptVar1->tcphdr->seqno); + if (-1 < (int)(uVar2 - uVar3)) break; + ptVar5 = ptVar5->next; + } + ptVar1->next = ptVar5->next; + ptVar5->next = ptVar1; + if (ptVar1->next == (tcp_seg *)0x0) { + pcb->unsent_oversize = 0; + } + if (pcb->nrtx != -1) { + pcb->nrtx = pcb->nrtx + '\x01'; + } + pcb->rttest = 0; + eVar4 = '\0'; + } + return eVar4; +} + + + +void tcp_rexmit_fast(tcp_pcb *pcb) + +{ + err_t eVar1; + undefined3 extraout_var; + uint uVar2; + uint uVar3; + + if (pcb->unacked != (tcp_seg *)0x0) { + if (((pcb->flags & 4) == 0) && (eVar1 = tcp_rexmit(pcb), CONCAT31(extraout_var,eVar1) == 0)) { + uVar3 = (uint)pcb->snd_wnd; + if ((uint)pcb->cwnd < (uint)pcb->snd_wnd) { + uVar3 = (uint)pcb->cwnd; + } + pcb->ssthresh = (tcpwnd_size_t)((int)uVar3 >> 1); + uVar2 = (uint)pcb->mss << 1; + if ((uint)((int)uVar3 >> 1) < uVar2) { + pcb->ssthresh = (tcpwnd_size_t)uVar2; + } + pcb->rtime = 0; + pcb->cwnd = pcb->mss * 3 + pcb->ssthresh; + pcb->flags = pcb->flags | 4; + } + return; + } + return; +} + + + +void tcp_rst(tcp_pcb *pcb,u32_t seqno,u32_t ackno,ip_addr_t *param_4,ip_addr_t *remote_ip, + u16_t param_6,u16_t remote_port) + +{ + u32_t seqno_be; + pbuf *p; + + seqno_be = lwip_htonl(seqno); + p = tcp_output_alloc_header_common(ackno,0,seqno_be,param_6,remote_port,'\x14',0x1008); + if (p != (pbuf *)0x0) { + tcp_output_control_segment(pcb,p,param_4,remote_ip); + return; + } + return; +} + + + +err_t tcp_send_empty_ack(tcp_pcb *pcb) + +{ + err_t eVar1; + u32_t seqno_be; + pbuf *p; + undefined3 extraout_var; + tcpflags_t tVar2; + + seqno_be = lwip_htonl(pcb->snd_nxt); + p = tcp_output_alloc_header(pcb,0,seqno_be); + if (p == (pbuf *)0x0) { + eVar1 = -2; + pcb->flags = pcb->flags | 3; + } + else { + eVar1 = tcp_output_control_segment(pcb,p,(ip_addr_t *)pcb,&pcb->remote_ip); + if (CONCAT31(extraout_var,eVar1) == 0) { + tVar2 = pcb->flags & 0xfffc; + } + else { + tVar2 = pcb->flags | 3; + } + pcb->flags = tVar2; + } + return eVar1; +} + + + +err_t tcp_output(tcp_pcb *pcb) + +{ + ushort uVar1; + ushort uVar2; + bool bVar3; + short sVar4; + tcp_seg *ptVar5; + tcp_seg *seg; + err_t eVar6; + u16_t proto_len; + u16_t uVar7; + netif *outif; + u32_t uVar8; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + uint uVar9; + undefined3 extraout_var; + u32_t uVar10; + tcp_hdr *ptVar11; + pbuf *p; + tcp_seg *ptVar12; + tcp_seg *ptVar13; + uint uVar14; + ip4_addr_t *dest; + + if (tcp_input_pcb == pcb) { + return '\0'; + } + seg = pcb->unsent; + if (seg == (tcp_seg *)0x0) { + uVar1 = pcb->flags; + } + else { + uVar1 = pcb->cwnd; + uVar2 = pcb->snd_wnd; + dest = (ip4_addr_t *)&pcb->remote_ip; + if (pcb->netif_idx == '\0') { + outif = ip4_route(dest); + } + else { + outif = netif_get_by_index(pcb->netif_idx); + } + if (outif == (netif *)0x0) { + return -4; + } + if ((pcb->local_ip).addr == 0) { + (pcb->local_ip).addr = (outif->ip_addr).addr; + } + uVar14 = (uint)uVar1; + if ((uint)uVar2 < (uint)uVar1) { + uVar14 = (uint)uVar2; + } + uVar8 = lwip_htonl(seg->tcphdr->seqno); + if (uVar8 + ((uint)seg->len - pcb->lastack) <= uVar14) { + pcb->persist_backoff = '\0'; + ptVar12 = pcb->unacked; + ptVar13 = pcb->unacked; + while (ptVar5 = ptVar12, ptVar5 != (tcp_seg *)0x0) { + ptVar12 = ptVar5->next; + ptVar13 = ptVar5; + } + do { + uVar8 = lwip_htonl(seg->tcphdr->seqno); + if ((uVar14 < (uVar8 - pcb->lastack) + (uint)seg->len) || + (((((lwip_htons(seg->tcphdr->_hdrlen_rsvd_flags), pcb->unacked != (tcp_seg *)0x0 && + ((pcb->flags & 0x44) == 0)) && + ((ptVar12 = pcb->unsent, ptVar12 == (tcp_seg *)0x0 || + ((ptVar12->next == (tcp_seg *)0x0 && (ptVar12->len < pcb->mss)))))) && + (pcb->snd_buf != 0)) && ((pcb->snd_queuelen < 0x10 && ((pcb->flags & 0xa0) == 0)))))) { + if (pcb->unsent != (tcp_seg *)0x0) goto output_done; + break; + } + if (pcb->state != SYN_SENT) { + uVar1 = seg->tcphdr->_hdrlen_rsvd_flags; + proto_len = lwip_htons(0x10); + ptVar11 = seg->tcphdr; + uVar1 = proto_len | uVar1; + *(char *)&ptVar11->_hdrlen_rsvd_flags = (char)uVar1; + *(undefined *)((int)&ptVar11->_hdrlen_rsvd_flags + 1) = (char)((uint)uVar1 >> 8); + } + if (seg->p->ref == '\x01') { + ptVar11 = seg->tcphdr; + uVar8 = lwip_htonl(pcb->rcv_nxt); + *(char *)&ptVar11->ackno = (char)uVar8; + *(undefined *)((int)&ptVar11->ackno + 1) = (char)(uVar8 >> 8); + *(undefined *)((int)&ptVar11->ackno + 2) = (char)(uVar8 >> 0x10); + *(undefined *)((int)&ptVar11->ackno + 3) = (char)(uVar8 >> 0x18); + ptVar11 = seg->tcphdr; + proto_len = lwip_htons(pcb->rcv_ann_wnd); + *(char *)&ptVar11->wnd = (char)proto_len; + *(undefined *)((int)&ptVar11->wnd + 1) = (char)(proto_len >> 8); + pcb->rcv_ann_right_edge = pcb->rcv_nxt + (uint)pcb->rcv_ann_wnd; + if ((seg->flags & 1) != 0) { + ptVar11 = seg->tcphdr; + proto_len = tcp_eff_send_mss_netif(0x2b0,outif,(ip_addr_t *)dest); + uVar8 = lwip_htonl(CONCAT22(extraout_var_00,proto_len) | 0x2040000); + *(u32_t *)(ptVar11 + 1) = uVar8; + } + if (pcb->rtime < 0) { + pcb->rtime = 0; + } + if (pcb->rttest == 0) { + pcb->rttest = tcp_ticks; + uVar8 = lwip_htonl(seg->tcphdr->seqno); + pcb->rtseq = uVar8; + } + p = seg->p; + sVar4 = (short)((uint)((int)((int)seg->tcphdr - (int)p->payload) * 0x10000) >> 0x10); + p->len = p->len - sVar4; + seg->p->tot_len = seg->p->tot_len - sVar4; + ptVar11 = seg->tcphdr; + *(tcp_hdr **)&seg->p->payload = ptVar11; + *(undefined *)&ptVar11->chksum = 0; + *(undefined *)((int)&ptVar11->chksum + 1) = 0; + if ((seg->flags & 4) == 0) { + lwip_htons(seg->tcphdr->_hdrlen_rsvd_flags); + } + p = seg->p; + proto_len = p->tot_len; + uVar7 = lwip_htons(seg->tcphdr->_hdrlen_rsvd_flags); + proto_len = ip_chksum_pseudo_partial + (p,'\x06',proto_len, + (ushort)(CONCAT22(extraout_var_01,uVar7) >> 10) & 0xfc, + (ip4_addr_t *)pcb,dest); + bVar3 = seg->chksum_swapped != '\0'; + if (bVar3) { + seg->chksum_swapped = '\0'; + seg->chksum = seg->chksum >> 8 | seg->chksum << 8; + } + ptVar11 = seg->tcphdr; + uVar9 = (uint)seg->chksum + (~(uint)proto_len & 0xffff); + uVar9 = ~((uVar9 >> 0x10) + uVar9); + *(char *)&ptVar11->chksum = (char)uVar9; + *(undefined *)((int)&ptVar11->chksum + 1) = (char)(uVar9 >> 8); + lwip_stats.tcp.xmit = lwip_stats.tcp.xmit + 1; + eVar6 = ip4_output_if(seg->p,(ip4_addr_t *)pcb,dest,pcb->ttl,pcb->tos,'\x06',outif); + if (bVar3) { + seg->chksum_swapped = '\x01'; + seg->chksum = seg->chksum >> 8 | seg->chksum << 8; + } + if (CONCAT31(extraout_var,eVar6) != 0) { + pcb->flags = pcb->flags | 0x80; + return eVar6; + } + } + pcb->unsent = seg->next; + if (pcb->state != SYN_SENT) { + pcb->flags = pcb->flags & 0xfffc; + } + uVar8 = lwip_htonl(seg->tcphdr->seqno); + uVar1 = seg->len; + proto_len = lwip_htons(seg->tcphdr->_hdrlen_rsvd_flags); + uVar8 = (uint)((proto_len & 3) != 0) + uVar8 + uVar1; + if ((int)(pcb->snd_nxt - uVar8) < 0) { + pcb->snd_nxt = uVar8; + } + uVar1 = seg->len; + proto_len = lwip_htons(seg->tcphdr->_hdrlen_rsvd_flags); + if ((uint)((proto_len & 3) != 0) + (uint)uVar1 == 0) { + tcp_seg_free(seg); + } + else { + seg->next = (tcp_seg *)0x0; + if (pcb->unacked == (tcp_seg *)0x0) { + pcb->unacked = seg; + ptVar13 = seg; + } + else { + uVar8 = lwip_htonl(seg->tcphdr->seqno); + uVar10 = lwip_htonl(ptVar13->tcphdr->seqno); + ptVar12 = (tcp_seg *)&pcb->unacked; + if ((int)(uVar8 - uVar10) < 0) { + while (ptVar12->next != (tcp_seg *)0x0) { + uVar8 = lwip_htonl(ptVar12->next->tcphdr->seqno); + uVar10 = lwip_htonl(seg->tcphdr->seqno); + if (-1 < (int)(uVar8 - uVar10)) break; + ptVar12 = ptVar12->next; + } + seg->next = ptVar12->next; + ptVar12->next = seg; + } + else { + ptVar13->next = seg; + ptVar13 = seg; + } + } + } + seg = pcb->unsent; + } while (seg != (tcp_seg *)0x0); + pcb->unsent_oversize = 0; + goto output_done; + } + if ((((uint)pcb->snd_wnd == uVar14) && (pcb->unacked == (tcp_seg *)0x0)) && + (pcb->persist_backoff == '\0')) { + *(undefined2 *)&pcb->persist_cnt = 0x100; + pcb->persist_probe = '\0'; + } + uVar1 = pcb->flags; + } + if ((uVar1 & 2) != 0) { + eVar6 = tcp_send_empty_ack(pcb); + return eVar6; + } +output_done: + pcb->flags = pcb->flags & 0xff7f; + return '\0'; +} + + + +void tcp_rexmit_rto_commit(tcp_pcb *pcb) + +{ + if (pcb->nrtx != -1) { + pcb->nrtx = pcb->nrtx + '\x01'; + } + tcp_output(pcb); + return; +} + + + +void tcp_rexmit_rto(tcp_pcb *pcb) + +{ + err_t eVar1; + undefined3 extraout_var; + + eVar1 = tcp_rexmit_rto_prepare(pcb); + if (CONCAT31(extraout_var,eVar1) == 0) { + tcp_rexmit_rto_commit(pcb); + return; + } + return; +} + + + +err_t tcp_keepalive(tcp_pcb *pcb) + +{ + err_t eVar1; + u32_t seqno_be; + pbuf *p; + + seqno_be = lwip_htonl(pcb->snd_nxt - 1); + p = tcp_output_alloc_header(pcb,0,seqno_be); + if (p != (pbuf *)0x0) { + eVar1 = tcp_output_control_segment(pcb,p,(ip_addr_t *)pcb,&pcb->remote_ip); + return eVar1; + } + return -1; +} + + + +err_t tcp_zero_window_probe(tcp_pcb *pcb) + +{ + ushort uVar1; + uint uVar2; + err_t eVar3; + u16_t uVar4; + pbuf *p; + u32_t uVar5; + tcp_seg *ptVar6; + void *pvVar7; + + ptVar6 = pcb->unsent; + if (ptVar6 == (tcp_seg *)0x0) { + eVar3 = '\0'; + } + else { + if (pcb->persist_probe != -1) { + pcb->persist_probe = pcb->persist_probe + '\x01'; + } + uVar2 = 0; + uVar4 = lwip_htons(ptVar6->tcphdr->_hdrlen_rsvd_flags); + if ((uVar4 & 1) != 0) { + uVar2 = (uint)(ptVar6->len == 0); + } + p = tcp_output_alloc_header(pcb,(ushort)uVar2 ^ 1,ptVar6->tcphdr->seqno); + if (p != (pbuf *)0x0) { + pvVar7 = p->payload; + if (uVar2 == 0) { + pbuf_copy_partial(ptVar6->p,(void *)((int)pvVar7 + 0x14),1, + (u16_t)(((uint)ptVar6->p->tot_len - (uint)ptVar6->len) * 0x10000 >> 0x10)) + ; + } + else { + uVar1 = *(ushort *)((int)pvVar7 + 0xc); + uVar4 = lwip_htons(0x11); + uVar2 = (int)(short)(uVar1 & 0xc0ff) | (uint)uVar4; + *(undefined *)((int)pvVar7 + 0xc) = (char)uVar2; + *(undefined *)((int)pvVar7 + 0xd) = (char)(uVar2 >> 8); + } + uVar5 = lwip_htonl(ptVar6->tcphdr->seqno); + if ((int)(pcb->snd_nxt - (uVar5 + 1)) < 0) { + pcb->snd_nxt = uVar5 + 1; + } + eVar3 = tcp_output_control_segment(pcb,p,(ip_addr_t *)pcb,&pcb->remote_ip); + return eVar3; + } + eVar3 = -1; + } + return eVar3; +} + + + +void sys_timeout_abs(u32_t abs_time,sys_timeout_handler *handler,void *arg) + +{ + sys_timeo *psVar1; + sys_timeo *psVar2; + sys_timeo *psVar3; + + psVar1 = (sys_timeo *)memp_malloc(MEMP_SYS_TIMEOUT); + psVar2 = next_timeout; + psVar3 = next_timeout; + if (psVar1 != (sys_timeo *)0x0) { + psVar1->next = (sys_timeo *)0x0; + psVar1->h = handler; + psVar1->arg = arg; + psVar1->time = abs_time; + psVar3 = psVar1; + if (psVar2 != (sys_timeo *)0x0) { + if ((int)(abs_time - psVar2->time) < 0) { + psVar1->next = psVar2; + } + else { + do { + psVar3 = psVar2; + psVar2 = psVar3->next; + if (psVar2 == (sys_timeo *)0x0) break; + } while (-1 < (int)(abs_time - psVar2->time)); + psVar1->next = psVar2; + psVar3->next = psVar1; + psVar3 = next_timeout; + } + } + } + next_timeout = psVar3; + return; +} + + + +void lwip_cyclic_timer(void *arg) + +{ + TickType_t TVar1; + u32_t abs_time; + u32_t uVar2; + + (**(code **)((int)arg + 4))(*(code **)((int)arg + 4)); + TVar1 = sys_now(); + uVar2 = current_timeout_due_time + *(int *)arg; + abs_time = TVar1 + *(int *)arg; + if (-1 < (int)(uVar2 - TVar1)) { + abs_time = uVar2; + } + sys_timeout_abs(abs_time,lwip_cyclic_timer,arg); + return; +} + + + +void sys_timeout(u32_t msecs,sys_timeout_handler *handler,void *arg) + +{ + TickType_t TVar1; + + TVar1 = sys_now(); + sys_timeout_abs(TVar1 + msecs,handler,arg); + return; +} + + + +void tcp_timer_needed(void) + +{ + if ((tcpip_tcp_timer_active == 0) && + ((tcp_active_pcbs != (tcp_pcb *)0x0 || (tcp_tw_pcbs != (tcp_pcb *)0x0)))) { + tcpip_tcp_timer_active = 1; + sys_timeout(0xfa,tcpip_tcp_timer,(void *)0x0); + return; + } + return; +} + + + +void tcpip_tcp_timer(void *arg) + +{ + tcp_tmr(); + if ((tcp_active_pcbs == (tcp_pcb *)0x0) && (tcp_tw_pcbs == (tcp_pcb *)0x0)) { + tcpip_tcp_timer_active = 0; + return; + } + sys_timeout(0xfa,tcpip_tcp_timer,(void *)0x0); + return; +} + + + +void sys_timeouts_init(void) + +{ + u32_t *arg; + u32_t *puVar1; + + arg = &DAT_2307ace0; + do { + puVar1 = arg + 2; + sys_timeout(*arg,lwip_cyclic_timer,arg); + arg = puVar1; + } while (puVar1 != (u32_t *)0x2307ad08); + return; +} + + + +void sys_check_timeouts(void) + +{ + sys_timeo *mem; + sys_timeout_handler *psVar1; + void *pvVar2; + TickType_t TVar3; + + TVar3 = sys_now(); + while ((mem = next_timeout, next_timeout != (sys_timeo *)0x0 && + (-1 < (int)(TVar3 - next_timeout->time)))) { + psVar1 = next_timeout->h; + pvVar2 = next_timeout->arg; + current_timeout_due_time = next_timeout->time; + next_timeout = next_timeout->next; + memp_free(MEMP_SYS_TIMEOUT,mem); + if (psVar1 != (sys_timeout_handler *)0x0) { + (*psVar1)(pvVar2); + } + } + return; +} + + + +u32_t sys_timeouts_sleeptime(void) + +{ + u32_t uVar1; + TickType_t TVar2; + + uVar1 = 0xffffffff; + if (next_timeout != (sys_timeo *)0x0) { + TVar2 = sys_now(); + uVar1 = next_timeout->time - TVar2; + if ((int)uVar1 < 0) { + uVar1 = 0; + } + } + return uVar1; +} + + + +void udp_init(void) + +{ + int iVar1; + + iVar1 = bl_rand(); + udp_port = (ushort)((uint)(iVar1 << 0x12) >> 0x12) + 0xc000; + return; +} + + + +void udp_input(pbuf *p,netif *inp) + +{ + udp_pcb *puVar1; + udp_pcb *puVar2; + u8_t uVar3; + u16_t uVar4; + u16_t uVar5; + undefined3 extraout_var; + undefined2 extraout_var_01; + undefined2 extraout_var_02; + undefined2 extraout_var_03; + undefined3 extraout_var_00; + u32_t uVar6; + uint uVar7; + udp_pcb *puVar8; + udp_pcb *puVar9; + udp_pcb *puVar10; + u16_t *puVar11; + + lwip_stats.udp.recv = lwip_stats.udp.recv + 1; + if (p->len < 8) { + lwip_stats.udp.lenerr = lwip_stats.udp.lenerr + 1; + lwip_stats.udp.drop = lwip_stats.udp.drop + 1; + } + else { + puVar11 = (u16_t *)p->payload; + uVar3 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_dest,ip_data.current_netif); + _uVar3 = CONCAT31(extraout_var,uVar3); + uVar4 = lwip_htons(*puVar11); + uVar5 = lwip_htons(puVar11[1]); + puVar1 = udp_pcbs; + puVar9 = (udp_pcb *)0x0; + puVar2 = udp_pcbs; + puVar8 = (udp_pcb *)0x0; + while (puVar10 = puVar2, puVar10 != (udp_pcb *)0x0) { + if (((uint)puVar10->local_port == CONCAT22(extraout_var_02,uVar5)) && + ((puVar10->netif_idx == '\0' || + (puVar10->netif_idx == (u8_t)((ip_data.current_input_netif)->num + '\x01'))))) { + uVar7 = (puVar10->local_ip).addr; + if (_uVar3 == 0) { + if ((uVar7 == 0) || (uVar7 == ip_data.current_iphdr_dest)) goto LAB_230424d8; + } + else { + if ((uVar7 == 0) || + ((ip_data.current_iphdr_dest == 0xffffffff || + (((uVar7 ^ ip_data.current_iphdr_dest) & (inp->netmask).addr) == 0)))) { +LAB_230424d8: + if ((puVar10->flags & 4) != 0) goto LAB_2304250e; + if (puVar9 == (udp_pcb *)0x0) { +LAB_230424fc: + puVar9 = puVar10; + } + else { + if ((_uVar3 == 0) || (ip_data.current_iphdr_dest != 0xffffffff)) { + if (uVar7 != 0) goto LAB_230424fc; + } + else { + uVar6 = (inp->ip_addr).addr; + if (((puVar9->local_ip).addr != uVar6) && (uVar6 == uVar7)) goto LAB_230424fc; + } + } +LAB_2304250e: + if (((uint)puVar10->remote_port == CONCAT22(extraout_var_01,uVar4)) && + ((uVar6 = (puVar10->remote_ip).addr, uVar6 == 0 || + (uVar6 == ip_data.current_iphdr_src)))) { + if (puVar8 == (udp_pcb *)0x0) { + lwip_stats.udp.cachehit = lwip_stats.udp.cachehit + 1; + } + else { + udp_pcbs = puVar10; + puVar8->next = puVar10->next; + puVar10->next = puVar1; + } + goto LAB_23042532; + } + } + } + } + puVar2 = puVar10->next; + puVar8 = puVar10; + } + puVar10 = puVar9; + if ((puVar9 != (udp_pcb *)0x0) || ((inp->ip_addr).addr == ip_data.current_iphdr_dest)) { +LAB_23042532: + if ((puVar11[3] == 0) || + (uVar5 = ip_chksum_pseudo(p,'\x11',p->tot_len,(ip4_addr_t *)&ip_data.current_iphdr_src, + (ip4_addr_t *)&ip_data.current_iphdr_dest), + CONCAT22(extraout_var_03,uVar5) == 0)) { + uVar3 = pbuf_remove_header(p,8); + if (CONCAT31(extraout_var_00,uVar3) == 0) { + if (puVar10 != (udp_pcb *)0x0) { + if (puVar10->recv != (udp_recv_fn *)0x0) { + // WARNING: Could not recover jumptable at 0x230425bc. Too many branches + // WARNING: Treating indirect jump as call + (*puVar10->recv)(puVar10->recv_arg,puVar10,p,(ip_addr_t *)0x4201a7a4,uVar4); + return; + } + goto LAB_23042414; + } + if ((_uVar3 == 0) && ((ip_data.current_iphdr_dest & 0xf0) != 0xe0)) { + pbuf_header_force(p,(s16_t)(((uint)ip_data.current_ip_header_tot_len + 8) * 0x10000 >> + 0x10)); + icmp_dest_unreach(p,ICMP_DUR_PORT); + } + lwip_stats.udp.proterr = lwip_stats.udp.proterr + 1; + } + } + else { + lwip_stats.udp.chkerr = lwip_stats.udp.chkerr + 1; + } + lwip_stats.udp.drop = lwip_stats.udp.drop + 1; + } + } +LAB_23042414: + pbuf_free(p); + return; +} + + + +err_t udp_bind(udp_pcb *pcb,ip_addr_t *ipaddr,u16_t port) + +{ + bool bVar1; + err_t eVar2; + undefined2 in_register_00002032; + u32_t uVar3; + udp_pcb *puVar4; + short sVar5; + + if (ipaddr == (ip_addr_t *)0x0) { + ipaddr = &ip_addr_any; + } + eVar2 = -0x10; + puVar4 = udp_pcbs; + if (pcb != (udp_pcb *)0x0) { + while (puVar4 != (udp_pcb *)0x0) { + if (puVar4 == pcb) { + bVar1 = true; + goto LAB_23042614; + } + puVar4 = puVar4->next; + } + bVar1 = false; +LAB_23042614: + puVar4 = udp_pcbs; + if (CONCAT22(in_register_00002032,port) == 0) { + sVar5 = 0x4000; + do { + puVar4 = udp_pcbs; + if (udp_port == 0xffff) { + port = 0xc000; + } + else { + port = udp_port + 1; + } + while( true ) { + udp_port = port; + if (puVar4 == (udp_pcb *)0x0) goto LAB_2304263c; + if (puVar4->local_port == port) break; + puVar4 = puVar4->next; + } + sVar5 = sVar5 + -1; + if (sVar5 == 0) { + return -8; + } + } while( true ); + } + while (puVar4 != (udp_pcb *)0x0) { + if ((puVar4 != pcb) && + ((((pcb->so_options & 4) == 0 || ((puVar4->so_options & 4) == 0)) && + ((uint)puVar4->local_port == CONCAT22(in_register_00002032,port))))) { + uVar3 = (puVar4->local_ip).addr; + if (uVar3 == ipaddr->addr) { + return -8; + } + if (ipaddr->addr == 0) { + return -8; + } + if (uVar3 == 0) { + return -8; + } + } + puVar4 = puVar4->next; + } +LAB_2304263c: + uVar3 = ipaddr->addr; + pcb->local_port = port; + (pcb->local_ip).addr = uVar3; + if (!bVar1) { + puVar4 = pcb; + pcb->next = udp_pcbs; + udp_pcbs = puVar4; + } + eVar2 = '\0'; + } + return eVar2; +} + + + +err_t udp_sendto_if_src_chksum + (udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif,u8_t have_chksum + ,u16_t chksum,ip_addr_t *src_ip) + +{ + u8_t ttl; + err_t eVar1; + u16_t uVar2; + undefined2 uVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + pbuf *h; + undefined2 extraout_var_01; + uint uVar4; + undefined2 extraout_var_02; + undefined3 in_register_0000203d; + undefined *puVar5; + + if (pcb == (udp_pcb *)0x0) { + return -0x10; + } + if (p == (pbuf *)0x0) { + return -0x10; + } + if (dst_ip == (ip_addr_t *)0x0) { + return -0x10; + } + if (src_ip == (ip_addr_t *)0x0) { + return -0x10; + } + if (netif == (netif *)0x0) { + return -0x10; + } + if ((pcb->local_port == 0) && + (eVar1 = udp_bind(pcb,(ip_addr_t *)pcb,0), CONCAT31(extraout_var,eVar1) != 0)) { + return eVar1; + } + if (p->tot_len < 0xfff8) { + ttl = pbuf_add_header(p,8); + h = p; + if (CONCAT31(extraout_var_00,ttl) != 0) { + h = pbuf_alloc(PBUF_IP,8,PBUF_RAM); + if (h == (pbuf *)0x0) goto LAB_23042702; + if (p->tot_len != 0) { + pbuf_chain(h,p); + } + } + puVar5 = (undefined *)h->payload; + uVar2 = lwip_htons(pcb->local_port); + *puVar5 = (char)uVar2; + puVar5[1] = (char)(uVar2 >> 8); + uVar2 = lwip_htons(dst_port); + puVar5[2] = (char)uVar2; + puVar5[3] = (char)(uVar2 >> 8); + puVar5[6] = 0; + puVar5[7] = 0; + if (((pcb->flags & 8) != 0) && ((dst_ip->addr & 0xf0) == 0xe0)) { + h->flags = h->flags | 4; + } + uVar2 = lwip_htons(h->tot_len); + puVar5[4] = (char)uVar2; + puVar5[5] = (char)(uVar2 >> 8); + if ((pcb->flags & 1) == 0) { + if (CONCAT31(in_register_0000203d,have_chksum) == 0) { + uVar2 = ip_chksum_pseudo(h,'\x11',h->tot_len,(ip4_addr_t *)src_ip,(ip4_addr_t *)dst_ip); + uVar4 = CONCAT22(extraout_var_02,uVar2); + } + else { + uVar2 = ip_chksum_pseudo_partial + (h,'\x11',h->tot_len,8,(ip4_addr_t *)src_ip,(ip4_addr_t *)dst_ip); + uVar4 = CONCAT22(extraout_var_01,uVar2) + (~(uint)chksum & 0xffff); + uVar4 = uVar4 + (uVar4 >> 0x10) & 0xffff; + } + uVar3 = (undefined2)uVar4; + if (uVar4 == 0) { + uVar3 = 0xffff; + } + puVar5[6] = (char)uVar3; + puVar5[7] = (char)((ushort)uVar3 >> 8); + } + if ((dst_ip->addr & 0xf0) == 0xe0) { + ttl = pcb->mcast_ttl; + } + else { + ttl = pcb->ttl; + } + eVar1 = ip4_output_if_src(h,(ip4_addr_t *)src_ip,(ip4_addr_t *)dst_ip,ttl,pcb->tos,'\x11',netif) + ; + if (h != p) { + pbuf_free(h); + } + lwip_stats.udp.xmit = lwip_stats.udp.xmit + 1; + } + else { +LAB_23042702: + eVar1 = -1; + } + return eVar1; +} + + + +err_t udp_sendto_if_chksum + (udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif,u8_t have_chksum + ,u16_t chksum) + +{ + err_t eVar1; + uint uVar2; + udp_pcb *src_ip; + + if ((((pcb != (udp_pcb *)0x0) && (p != (pbuf *)0x0)) && (dst_ip != (ip_addr_t *)0x0)) && + (netif != (netif *)0x0)) { + uVar2 = (pcb->local_ip).addr; + if ((uVar2 == 0) || ((uVar2 & 0xf0) == 0xe0)) { + src_ip = (udp_pcb *)&netif->ip_addr; + } + else { + src_ip = pcb; + if (uVar2 != (netif->ip_addr).addr) { + return -4; + } + } + eVar1 = udp_sendto_if_src_chksum + (pcb,p,dst_ip,dst_port,netif,have_chksum,chksum,(ip_addr_t *)src_ip); + return eVar1; + } + return -0x10; +} + + + +err_t udp_sendto_chksum(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,u8_t have_chksum, + u16_t chksum) + +{ + err_t eVar1; + netif *netif; + u32_t uVar2; + + if (((pcb == (udp_pcb *)0x0) || (p == (pbuf *)0x0)) || (dst_ip == (ip_addr_t *)0x0)) { + return -0x10; + } + if (pcb->netif_idx == '\0') { + if ((dst_ip->addr & 0xf0) == 0xe0) { + if (pcb->mcast_ifindex == '\0') { + uVar2 = (pcb->mcast_ip4).addr; + if ((uVar2 == 0) || (uVar2 == 0xffffffff)) goto LAB_230428f6; + netif = ip4_route(&pcb->mcast_ip4); + } + else { + netif = netif_get_by_index(pcb->mcast_ifindex); + } + if (netif != (netif *)0x0) goto LAB_2304290a; + } +LAB_230428f6: + netif = ip4_route((ip4_addr_t *)dst_ip); + } + else { + netif = netif_get_by_index(pcb->netif_idx); + } + if (netif == (netif *)0x0) { + lwip_stats.udp.rterr = lwip_stats.udp.rterr + 1; + return -4; + } +LAB_2304290a: + eVar1 = udp_sendto_if_chksum(pcb,p,dst_ip,dst_port,netif,have_chksum,chksum); + return eVar1; +} + + + +err_t udp_sendto(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port) + +{ + err_t eVar1; + + eVar1 = udp_sendto_chksum(pcb,p,dst_ip,dst_port,'\0',0); + return eVar1; +} + + + +err_t udp_sendto_if(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif) + +{ + err_t eVar1; + + eVar1 = udp_sendto_if_chksum(pcb,p,dst_ip,dst_port,netif,'\0',0); + return eVar1; +} + + + +err_t udp_sendto_if_src(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif, + ip_addr_t *src_ip) + +{ + err_t eVar1; + + eVar1 = udp_sendto_if_src_chksum(pcb,p,dst_ip,dst_port,netif,'\0',0,src_ip); + return eVar1; +} + + + +err_t udp_connect(udp_pcb *pcb,ip_addr_t *ipaddr,u16_t port) + +{ + err_t eVar1; + undefined3 extraout_var; + udp_pcb *puVar2; + u32_t uVar3; + + if ((pcb == (udp_pcb *)0x0) || (ipaddr == (ip_addr_t *)0x0)) { + return -0x10; + } + if ((pcb->local_port != 0) || + (eVar1 = udp_bind(pcb,(ip_addr_t *)pcb,0), CONCAT31(extraout_var,eVar1) == 0)) { + uVar3 = ipaddr->addr; + pcb->remote_port = port; + (pcb->remote_ip).addr = uVar3; + pcb->flags = pcb->flags | 4; + puVar2 = udp_pcbs; + while (puVar2 != (udp_pcb *)0x0) { + if (puVar2 == pcb) goto LAB_230429a6; + puVar2 = puVar2->next; + } + pcb->next = udp_pcbs; + udp_pcbs = pcb; +LAB_230429a6: + eVar1 = '\0'; + } + return eVar1; +} + + + +void udp_recv(udp_pcb *pcb,udp_recv_fn *recv,void *recv_arg) + +{ + if (pcb != (udp_pcb *)0x0) { + pcb->recv = recv; + pcb->recv_arg = recv_arg; + } + return; +} + + + +void udp_remove(udp_pcb *pcb) + +{ + udp_pcb *puVar1; + udp_pcb *puVar2; + + if (pcb == (udp_pcb *)0x0) { + return; + } + puVar1 = udp_pcbs; + if (udp_pcbs == pcb) { + udp_pcbs = pcb->next; + } + else { + do { + puVar2 = puVar1; + if ((puVar2 == (udp_pcb *)0x0) || (puVar1 = puVar2->next, puVar1 == (udp_pcb *)0x0)) + goto LAB_230429ee; + } while (puVar1 != pcb); + puVar2->next = pcb->next; + } +LAB_230429ee: + memp_free(MEMP_UDP_PCB,pcb); + return; +} + + + +udp_pcb * udp_new(void) + +{ + udp_pcb *__s; + + __s = (udp_pcb *)memp_malloc(MEMP_UDP_PCB); + if (__s != (udp_pcb *)0x0) { + memset(__s,0,0x28); + __s->ttl = -1; + __s->mcast_ttl = -1; + } + return __s; +} + + + +udp_pcb * udp_new_ip_type(void) + +{ + udp_pcb *__s; + + __s = (udp_pcb *)memp_malloc(MEMP_UDP_PCB); + if (__s != (udp_pcb *)0x0) { + memset(__s,0,0x28); + __s->ttl = -1; + __s->mcast_ttl = -1; + } + return __s; +} + + + +void udp_netif_ip_addr_changed(ip_addr_t *old_addr,ip_addr_t *new_addr) + +{ + udp_pcb *puVar1; + + if ((((old_addr != (ip_addr_t *)0x0) && (old_addr->addr != 0)) && (new_addr != (ip_addr_t *)0x0)) + && (puVar1 = udp_pcbs, new_addr->addr != 0)) { + while (puVar1 != (udp_pcb *)0x0) { + if ((puVar1->local_ip).addr == old_addr->addr) { + (puVar1->local_ip).addr = new_addr->addr; + } + puVar1 = puVar1->next; + } + } + return; +} + + + +err_t ethernet_input(pbuf *p,netif *netif) + +{ + short sVar1; + u8_t uVar2; + byte *__s1; + undefined3 extraout_var; + int iVar3; + undefined3 extraout_var_00; + byte bVar4; + + if (p->len < 0xf) { +LAB_23042a78: + lwip_stats.etharp.proterr = lwip_stats.etharp.proterr + 1; + } + else { + if (p->if_idx == '\0') { + p->if_idx = netif->num + '\x01'; + } + __s1 = (byte *)p->payload; + sVar1 = *(short *)(__s1 + 0xc); + if ((*__s1 & 1) != 0) { + if (*__s1 == 1) { + if ((__s1[1] == 0) && (__s1[2] == 0x5e)) { + bVar4 = p->flags | 0x10; +LAB_23042ad6: + p->flags = bVar4; + } + } + else { + iVar3 = memcmp(__s1,ðbroadcast,6); + if (iVar3 == 0) { + bVar4 = p->flags | 8; + goto LAB_23042ad6; + } + } + } + if (sVar1 == 8) { + if (((netif->flags & 8) != 0) && + (uVar2 = pbuf_remove_header(p,0xe), CONCAT31(extraout_var_00,uVar2) == 0)) { + ip4_input(p,netif); + return '\0'; + } + goto free_and_return; + } + if (sVar1 != 0x608) goto LAB_23042a78; + if ((netif->flags & 8) == 0) goto free_and_return; + uVar2 = pbuf_remove_header(p,0xe); + if (CONCAT31(extraout_var,uVar2) == 0) { + etharp_input(p,netif); + return '\0'; + } + lwip_stats.etharp.lenerr = lwip_stats.etharp.lenerr + 1; + } + lwip_stats.etharp.drop = lwip_stats.etharp.drop + 1; +free_and_return: + pbuf_free(p); + return '\0'; +} + + + +err_t ethernet_output(netif *netif,pbuf *p,eth_addr *src,eth_addr *dst,u16_t eth_type) + +{ + void *__dest; + u8_t uVar1; + err_t eVar2; + u16_t uVar3; + undefined3 extraout_var; + + uVar3 = lwip_htons(eth_type); + uVar1 = pbuf_add_header(p,0xe); + if (CONCAT31(extraout_var,uVar1) == 0) { + __dest = p->payload; + *(undefined *)((int)__dest + 0xc) = (char)uVar3; + *(undefined *)((int)__dest + 0xd) = (char)(uVar3 >> 8); + memcpy(__dest,dst,6); + memcpy((void *)((int)__dest + 6),src,6); + // WARNING: Could not recover jumptable at 0x23042bce. Too many branches + // WARNING: Treating indirect jump as call + eVar2 = (*netif->linkoutput)(netif,p); + return eVar2; + } + lwip_stats.link.lenerr = lwip_stats.link.lenerr + 1; + return -2; +} + + + +err_t sys_mbox_new(sys_mbox_t *mbox,int size) + +{ + QueueHandle_t pQVar1; + u16_t uVar2; + + pQVar1 = xQueueGenericCreate(0x32,4,'\0'); + *(QueueHandle_t *)mbox = pQVar1; + uVar2 = (u16_t)(((uint)lwip_stats.sys.mbox.used + 1) * 0x10000 >> 0x10); + if ((uint)lwip_stats.sys.mbox.max < ((uint)lwip_stats.sys.mbox.used + 1 & 0xffff)) { + lwip_stats.sys.mbox.max = uVar2; + } + lwip_stats.sys.mbox.used = uVar2; + return (err_t)-(*mbox == (sys_mbox_t)0x0); +} + + + +void sys_mbox_post(sys_mbox_t *mbox,void *data) + +{ + BaseType_t BVar1; + void *apvStack20 [2]; + + apvStack20[0] = data; + do { + BVar1 = xQueueGenericSend((QueueHandle_t)*mbox,apvStack20,0xffffffff,0); + } while (BVar1 != 1); + return; +} + + + +err_t sys_mbox_trypost(sys_mbox_t *mbox,void *msg) + +{ + err_t eVar1; + BaseType_t BVar2; + void *apvStack20 [4]; + + apvStack20[0] = msg; + BVar2 = xQueueGenericSend((QueueHandle_t)*mbox,apvStack20,0,0); + if (BVar2 == 1) { + eVar1 = '\0'; + } + else { + eVar1 = -1; + lwip_stats.sys.mbox.err = lwip_stats.sys.mbox.err + 1; + } + return eVar1; +} + + + +u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox,void **msg,u32_t timeout) + +{ + TickType_t TVar1; + BaseType_t BVar2; + TickType_t TVar3; + void *local_24; + void *dummyptr; + + TVar1 = xTaskGetTickCount(); + if (msg == (void **)0x0) { + msg = &local_24; + } + if (timeout == 0) { + do { + BVar2 = xQueueReceive((QueueHandle_t)*mbox,msg,0xffffffff); + } while (BVar2 != 1); + } + else { + BVar2 = xQueueReceive((QueueHandle_t)*mbox,msg,timeout); + if (BVar2 != 1) { + *msg = (void *)0x0; + return 0xffffffff; + } + } + TVar3 = xTaskGetTickCount(); + return TVar3 - TVar1; +} + + + +uint sys_mbox_valid(int *param_1) + +{ + return (uint)(*param_1 != 0); +} + + + +err_t sys_sem_new(sys_sem_t *sem,u8_t count) + +{ + err_t eVar1; + QueueHandle_t xQueue; + undefined3 in_register_0000202d; + uint uVar2; + + xQueue = xQueueGenericCreate(1,0,'\x03'); + *(QueueHandle_t *)sem = xQueue; + if (xQueue != (QueueHandle_t)0x0) { + xQueueGenericSend(xQueue,(void *)0x0,0,0); + } + if ((QueueHandle_t)*sem == (QueueHandle_t)0x0) { + lwip_stats.sys.sem.err = lwip_stats.sys.sem.err + 1; + eVar1 = -1; + } + else { + if (CONCAT31(in_register_0000202d,count) == 0) { + xQueueSemaphoreTake((QueueHandle_t)*sem,1); + } + uVar2 = (uint)lwip_stats.sys.sem.used; + lwip_stats.sys.sem.used = (u16_t)((uVar2 + 1) * 0x10000 >> 0x10); + eVar1 = '\0'; + if ((uint)lwip_stats.sys.sem.max < (uVar2 + 1 & 0xffff)) { + eVar1 = '\0'; + lwip_stats.sys.sem.max = lwip_stats.sys.sem.used; + } + } + return eVar1; +} + + + +u32_t sys_arch_sem_wait(sys_sem_t *sem,u32_t timeout) + +{ + TickType_t TVar1; + BaseType_t BVar2; + TickType_t TVar3; + + TVar1 = xTaskGetTickCount(); + if (timeout == 0) { + do { + BVar2 = xQueueSemaphoreTake((QueueHandle_t)*sem,0xffffffff); + } while (BVar2 != 1); + } + else { + BVar2 = xQueueSemaphoreTake((QueueHandle_t)*sem,timeout); + if (BVar2 != 1) { + return 0xffffffff; + } + } + TVar3 = xTaskGetTickCount(); + return TVar3 - TVar1; +} + + + +void sys_sem_free(sys_sem_t *sem) + +{ + lwip_stats.sys.sem.used = lwip_stats.sys.sem.used - 1; + vQueueDelete((QueueHandle_t)*sem); + return; +} + + + +void sys_init(void) + +{ + s_nextthread = 0; + return; +} + + + +err_t sys_mutex_new(sys_mutex_t *mutex) + +{ + err_t eVar1; + QueueHandle_t pQVar2; + uint uVar3; + + pQVar2 = xQueueCreateMutex('\x01'); + *(QueueHandle_t *)mutex = pQVar2; + if (pQVar2 == (QueueHandle_t)0x0) { + lwip_stats.sys.mutex.err = lwip_stats.sys.mutex.err + 1; + eVar1 = -1; + } + else { + uVar3 = (uint)lwip_stats.sys.mutex.used; + lwip_stats.sys.mutex.used = (u16_t)((uVar3 + 1) * 0x10000 >> 0x10); + eVar1 = '\0'; + if ((uint)lwip_stats.sys.mutex.max < (uVar3 + 1 & 0xffff)) { + eVar1 = '\0'; + lwip_stats.sys.mutex.max = lwip_stats.sys.mutex.used; + } + } + return eVar1; +} + + + +void sys_mutex_lock(sys_mutex_t *mutex) + +{ + sys_arch_sem_wait((sys_sem_t *)mutex,0); + return; +} + + + +void sys_mutex_unlock(sys_mutex_t *mutex) + +{ + xQueueGenericSend((QueueHandle_t)*mutex,(void *)0x0,0,0); + return; +} + + + +void sys_sem_signal(sys_mutex_t *mutex) + +{ + xQueueGenericSend((QueueHandle_t)*mutex,(void *)0x0,0,0); + return; +} + + + +sys_thread_t sys_thread_new(char *name,lwip_thread_fn *thread,void *arg,int stacksize,int prio) + +{ + BaseType_t BVar1; + TaskHandle_t ptStack20; + TaskHandle_t CreatedTask; + + if (s_nextthread < 6) { + BVar1 = xTaskCreate((TaskFunction_t *)thread,name,(uint16_t)stacksize,arg,prio,&ptStack20); + if (BVar1 != 1) { + ptStack20 = (sys_thread_t)0x0; + } + return ptStack20; + } + return (sys_thread_t)0x0; +} + + + +sys_prot_t sys_arch_protect(void) + +{ + vTaskEnterCritical(); + return 1; +} + + + +void sys_arch_unprotect(void) + +{ + if ((xSchedulerRunning != 0) && (pxCurrentTCB->uxCriticalNesting != 0)) { + vTaskExitCritical(); + return; + } + return; +} + + + +TickType_t sys_now(void) + +{ + return xTickCount; +} + + + +u16_t lwip_standard_chksum(void *dataptr,int len) + +{ + byte bVar1; + ushort uVar2; + uint uVar3; + uint uVar4; + uint uVar5; + int iVar6; + u16_t t; + ushort uStack2; + + uStack2 = 0; + uVar3 = (uint)dataptr & 1; + if ((uVar3 != 0) && (0 < len)) { + bVar1 = *(byte *)dataptr; + len = len + -1; + dataptr = (void *)((int)dataptr + 1); + uStack2 = (ushort)bVar1 << 8; + } + uVar5 = (uint)dataptr & 3; + if ((uVar5 != 0) && (uVar5 = 0, 1 < len)) { + uVar5 = (uint)*(ushort *)dataptr; + len = len + -2; + dataptr = (void *)((int)dataptr + 2); + } + while (7 < len) { + uVar4 = *(int *)dataptr + uVar5; + if (uVar4 < uVar5) { + uVar4 = uVar4 + 1; + } + uVar5 = ((int *)dataptr)[1] + uVar4; + if (uVar5 < uVar4) { + uVar5 = uVar5 + 1; + } + len = len + -8; + dataptr = (int *)dataptr + 2; + } + iVar6 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + while (1 < len) { + len = len + -2; + iVar6 = iVar6 + (uint)*(ushort *)dataptr; + dataptr = (int *)((int)dataptr + 2); + } + if (len == 1) { + uStack2 = uStack2 | *(byte *)dataptr; + } + uVar5 = ((uint)uStack2 + iVar6 >> 0x10) + ((uint)uStack2 + iVar6 & 0xffff); + iVar6 = (uVar5 >> 0x10) + (uVar5 & 0xffff); + uVar2 = (ushort)iVar6; + if (uVar3 != 0) { + uVar2 = (ushort)((uint)iVar6 >> 8) & 0xff | uVar2 * 0x100; + } + return (u16_t)uVar2; +} + + + +u16_t inet_chksum_pseudo(pbuf *p,u8_t proto,u16_t proto_len,ip4_addr_t *src,ip4_addr_t *dest) + +{ + bool bVar1; + int iVar2; + u16_t uVar3; + u16_t uVar4; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined3 in_register_0000202d; + uint uVar5; + + uVar5 = (src->addr >> 0x10) + (dest->addr & 0xffff) + (dest->addr >> 0x10) + (src->addr & 0xffff); + uVar5 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + uVar5 = (uVar5 >> 0x10) + (uVar5 & 0xffff); + bVar1 = false; + while (p != (pbuf *)0x0) { + uVar3 = lwip_standard_chksum(p->payload,(uint)p->len); + uVar5 = uVar5 + CONCAT22(extraout_var_01,uVar3); + uVar5 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + if ((p->len & 1) != 0) { + bVar1 = (bool)(bVar1 ^ 1); + uVar5 = uVar5 >> 8 & 0xff | uVar5 * 0x100 & 0xffff; + } + p = p->next; + } + if (bVar1) { + uVar5 = uVar5 >> 8 & 0xff | (uVar5 & 0xff) << 8; + } + uVar3 = lwip_htons((u16_t)CONCAT31(in_register_0000202d,proto)); + uVar4 = lwip_htons(proto_len); + uVar5 = uVar5 + CONCAT22(extraout_var_00,uVar4) + CONCAT22(extraout_var,uVar3); + iVar2 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + return (u16_t)~((short)iVar2 + (short)((uint)iVar2 >> 0x10)); +} + + + +u16_t ip_chksum_pseudo(pbuf *p,u8_t proto,u16_t proto_len,ip4_addr_t *src,ip4_addr_t *dest) + +{ + bool bVar1; + int iVar2; + u16_t uVar3; + u16_t uVar4; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined3 in_register_0000202d; + uint uVar5; + + uVar5 = (src->addr >> 0x10) + (dest->addr & 0xffff) + (dest->addr >> 0x10) + (src->addr & 0xffff); + uVar5 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + uVar5 = (uVar5 >> 0x10) + (uVar5 & 0xffff); + bVar1 = false; + while (p != (pbuf *)0x0) { + uVar3 = lwip_standard_chksum(p->payload,(uint)p->len); + uVar5 = uVar5 + CONCAT22(extraout_var_01,uVar3); + uVar5 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + if ((p->len & 1) != 0) { + bVar1 = (bool)(bVar1 ^ 1); + uVar5 = uVar5 >> 8 & 0xff | uVar5 * 0x100 & 0xffff; + } + p = p->next; + } + if (bVar1) { + uVar5 = uVar5 >> 8 & 0xff | (uVar5 & 0xff) << 8; + } + uVar3 = lwip_htons((u16_t)CONCAT31(in_register_0000202d,proto)); + uVar4 = lwip_htons(proto_len); + uVar5 = uVar5 + CONCAT22(extraout_var_00,uVar4) + CONCAT22(extraout_var,uVar3); + iVar2 = (uVar5 & 0xffff) + (uVar5 >> 0x10); + return (u16_t)~((short)iVar2 + (short)((uint)iVar2 >> 0x10)); +} + + + +u16_t inet_chksum_pseudo_partial + (pbuf *p,u8_t proto,u16_t proto_len,u16_t chksum_len,ip4_addr_t *src, + ip4_addr_t *dest) + +{ + bool bVar1; + int iVar2; + u16_t uVar3; + u16_t uVar4; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined3 in_register_0000202d; + undefined2 in_register_00002036; + uint uVar5; + uint uVar6; + uint uVar7; + + uVar5 = CONCAT22(in_register_00002036,chksum_len); + uVar6 = (src->addr >> 0x10) + (dest->addr & 0xffff) + (dest->addr >> 0x10) + (src->addr & 0xffff); + uVar6 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + uVar6 = (uVar6 >> 0x10) + (uVar6 & 0xffff); + bVar1 = false; + while ((p != (pbuf *)0x0 && (uVar5 != 0))) { + uVar7 = (uint)p->len; + if (uVar5 < (uint)p->len) { + uVar7 = uVar5; + } + uVar3 = lwip_standard_chksum(p->payload,uVar7 & 0xffff); + uVar6 = uVar6 + CONCAT22(extraout_var_01,uVar3); + uVar6 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + uVar5 = uVar5 - (uVar7 & 0xffff) & 0xffff; + if ((p->len & 1) != 0) { + bVar1 = (bool)(bVar1 ^ 1); + uVar6 = uVar6 >> 8 & 0xff | uVar6 * 0x100 & 0xffff; + } + p = p->next; + } + if (bVar1) { + uVar6 = uVar6 >> 8 & 0xff | (uVar6 & 0xff) << 8; + } + uVar3 = lwip_htons((u16_t)CONCAT31(in_register_0000202d,proto)); + uVar4 = lwip_htons(proto_len); + uVar6 = uVar6 + CONCAT22(extraout_var_00,uVar4) + CONCAT22(extraout_var,uVar3); + iVar2 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + return (u16_t)~((short)iVar2 + (short)((uint)iVar2 >> 0x10)); +} + + + +u16_t ip_chksum_pseudo_partial + (pbuf *p,u8_t proto,u16_t proto_len,u16_t chksum_len,ip4_addr_t *src, + ip4_addr_t *dest) + +{ + bool bVar1; + int iVar2; + u16_t uVar3; + u16_t uVar4; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + undefined3 in_register_0000202d; + uint uVar5; + undefined2 in_register_00002036; + uint uVar6; + uint uVar7; + + uVar5 = CONCAT22(in_register_00002036,chksum_len); + uVar6 = (src->addr >> 0x10) + (dest->addr & 0xffff) + (dest->addr >> 0x10) + (src->addr & 0xffff); + uVar6 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + uVar6 = (uVar6 >> 0x10) + (uVar6 & 0xffff); + bVar1 = false; + while ((p != (pbuf *)0x0 && (uVar5 != 0))) { + uVar7 = (uint)p->len; + if (uVar5 < (uint)p->len) { + uVar7 = uVar5; + } + uVar3 = lwip_standard_chksum(p->payload,uVar7 & 0xffff); + uVar6 = uVar6 + CONCAT22(extraout_var_01,uVar3); + uVar6 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + uVar5 = uVar5 - (uVar7 & 0xffff) & 0xffff; + if ((p->len & 1) != 0) { + bVar1 = (bool)(bVar1 ^ 1); + uVar6 = uVar6 >> 8 & 0xff | uVar6 * 0x100 & 0xffff; + } + p = p->next; + } + if (bVar1) { + uVar6 = uVar6 >> 8 & 0xff | (uVar6 & 0xff) << 8; + } + uVar3 = lwip_htons((u16_t)CONCAT31(in_register_0000202d,proto)); + uVar4 = lwip_htons(proto_len); + uVar6 = uVar6 + CONCAT22(extraout_var_00,uVar4) + CONCAT22(extraout_var,uVar3); + iVar2 = (uVar6 & 0xffff) + (uVar6 >> 0x10); + return (u16_t)~((short)iVar2 + (short)((uint)iVar2 >> 0x10)); +} + + + +u16_t inet_chksum(void *dataptr,u16_t len) + +{ + u16_t uVar1; + undefined2 in_register_0000202e; + + uVar1 = lwip_standard_chksum(dataptr,CONCAT22(in_register_0000202e,len)); + return ~uVar1; +} + + + +u16_t inet_chksum_pbuf(pbuf *p) + +{ + bool bVar1; + ushort uVar2; + uint uVar3; + u16_t uVar4; + undefined2 extraout_var; + + bVar1 = false; + uVar3 = 0; + while (uVar2 = (ushort)uVar3, p != (pbuf *)0x0) { + uVar4 = lwip_standard_chksum(p->payload,(uint)p->len); + uVar3 = uVar3 + CONCAT22(extraout_var,uVar4); + uVar3 = (uVar3 & 0xffff) + (uVar3 >> 0x10); + if ((p->len & 1) != 0) { + bVar1 = (bool)(bVar1 ^ 1); + uVar3 = uVar3 >> 8 & 0xff | uVar3 * 0x100 & 0xffff; + } + p = p->next; + } + if (bVar1) { + uVar2 = (ushort)(uVar3 >> 8) & 0xff | (ushort)((uVar3 & 0xff) << 8); + } + return (u16_t)~uVar2; +} + + + +void icmp_input(pbuf *p,netif *inp) + +{ + ip_hdr *__src; + u32_t uVar1; + uint uVar2; + uint __n; + void *dataptr; + u8_t uVar3; + err_t eVar4; + u16_t uVar5; + undefined3 extraout_var; + undefined2 extraout_var_05; + undefined3 extraout_var_00; + pbuf *p_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + uint uVar6; + short sVar7; + undefined *puVar8; + + __src = ip_data.current_ip4_header; + lwip_stats.icmp.recv = lwip_stats.icmp.recv + 1; + uVar2 = (uint)(ip_data.current_ip4_header)->_v_hl & 0xf; + __n = uVar2 * 4; + if ((__n < 0x14) || (p->len < 4)) { +lenerr: + pbuf_free(p); + lwip_stats.icmp.lenerr = lwip_stats.icmp.lenerr + 1; + } + else { + if (*(char *)p->payload == '\0') goto LAB_2304339a; + if (*(char *)p->payload != '\b') { + lwip_stats.icmp.proterr = lwip_stats.icmp.proterr + 1; + lwip_stats.icmp.drop = lwip_stats.icmp.drop + 1; + goto LAB_2304339a; + } + if (((ip_data.current_iphdr_dest & 0xf0) != 0xe0) && + (uVar3 = ip4_addr_isbroadcast_u32(ip_data.current_iphdr_dest,ip_data.current_netif), + CONCAT31(extraout_var,uVar3) == 0)) { + if (p->tot_len < 8) goto lenerr; + uVar5 = inet_chksum_pbuf(p); + if (CONCAT22(extraout_var_05,uVar5) != 0) { + pbuf_free(p); + lwip_stats.icmp.chkerr = lwip_stats.icmp.chkerr + 1; + return; + } + uVar2 = uVar2 << 0x12; + uVar3 = pbuf_add_header(p,__n + 0x8e); + if (CONCAT31(extraout_var_00,uVar3) == 0) { + uVar3 = pbuf_remove_header(p,__n + 0x8e); + if (CONCAT31(extraout_var_04,uVar3) == 0) { +LAB_230432e2: + puVar8 = (undefined *)p->payload; + uVar3 = pbuf_add_header(p,__n); + uVar1 = ip_data.current_iphdr_dest; + if (CONCAT31(extraout_var_03,uVar3) == 0) { + dataptr = p->payload; + *(undefined *)((int)dataptr + 0xc) = (char)ip_data.current_iphdr_dest; + *(undefined *)((int)dataptr + 0xd) = (char)(uVar1 >> 8); + *(undefined *)((int)dataptr + 0xe) = (char)(uVar1 >> 0x10); + *(undefined *)((int)dataptr + 0xf) = (char)(uVar1 >> 0x18); + uVar1 = ip_data.current_iphdr_src; + *(undefined *)((int)dataptr + 0x10) = (char)ip_data.current_iphdr_src; + *(undefined *)((int)dataptr + 0x11) = (char)(uVar1 >> 8); + *(undefined *)((int)dataptr + 0x12) = (char)(uVar1 >> 0x10); + *(undefined *)((int)dataptr + 0x13) = (char)(uVar1 >> 0x18); + *puVar8 = 0; + if (*(ushort *)(puVar8 + 2) < 0xfff8) { + sVar7 = 8; + } + else { + sVar7 = 9; + } + sVar7 = *(ushort *)(puVar8 + 2) + sVar7; + puVar8[2] = (char)sVar7; + puVar8[3] = (char)((ushort)sVar7 >> 8); + *(undefined *)((int)dataptr + 8) = 0xff; + *(undefined *)((int)dataptr + 10) = 0; + *(undefined *)((int)dataptr + 0xb) = 0; + uVar5 = inet_chksum(dataptr,(u16_t)(uVar2 >> 0x10)); + *(undefined *)((int)dataptr + 10) = (char)uVar5; + *(undefined *)((int)dataptr + 0xb) = (char)(uVar5 >> 8); + lwip_stats.icmp.xmit = lwip_stats.icmp.xmit + 1; + ip4_output_if(p,(ip4_addr_t *)&ip_data.current_iphdr_dest,(ip4_addr_t *)0x0,-1,'\0', + '\x01',inp); + } +LAB_2304339a: + pbuf_free(p); + return; + } + } + else { + uVar6 = (uint)p->tot_len + (uVar2 >> 0x10); + if (((uint)p->tot_len <= (uVar6 & 0xffff)) && + (p_00 = pbuf_alloc(PBUF_LINK,(u16_t)(uVar6 * 0x10000 >> 0x10),PBUF_RAM), + p_00 != (pbuf *)0x0)) { + if (__n + 8 <= (uint)p_00->len) { + memcpy(p_00->payload,__src,__n); + uVar3 = pbuf_remove_header(p_00,__n); + if ((CONCAT31(extraout_var_01,uVar3) == 0) && + (eVar4 = pbuf_copy(p_00,p), CONCAT31(extraout_var_02,eVar4) == 0)) { + pbuf_free(p); + p = p_00; + goto LAB_230432e2; + } + } + pbuf_free(p_00); + } + } + } + pbuf_free(p); + lwip_stats.icmp.err = lwip_stats.icmp.err + 1; + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void icmp_dest_unreach(pbuf *p,icmp_dur_type t) + +{ + undefined *dataptr; + u16_t uVar1; + pbuf *p_00; + netif *netif; + void *pvVar2; + ip4_addr_t iStack36; + ip4_addr_t iphdr_src; + + p_00 = pbuf_alloc(PBUF_IP,0x24,PBUF_RAM); + if (p_00 != (pbuf *)0x0) { + dataptr = (undefined *)p_00->payload; + pvVar2 = p->payload; + *dataptr = 3; + dataptr[1] = t; + dataptr[4] = 0; + dataptr[5] = 0; + dataptr[6] = 0; + dataptr[7] = 0; + memcpy((void *)((int)p_00->payload + 8),p->payload,0x1c); + iStack36 = (ip4_addr_t)((ip4_addr_t *)((int)pvVar2 + 0xc))->addr; + netif = ip4_route(&iStack36); + if (netif != (netif *)0x0) { + dataptr[2] = 0; + dataptr[3] = 0; + uVar1 = inet_chksum(dataptr,p_00->len); + dataptr[2] = (char)uVar1; + dataptr[3] = (char)(uVar1 >> 8); + lwip_stats.icmp.xmit = lwip_stats.icmp.xmit + 1; + ip4_output_if(p_00,(ip4_addr_t *)0x0,&iStack36,-1,'\0','\x01',netif); + } + pbuf_free(p_00); + } + return; +} + + + +u8_t * dhcp_server_option_find(u8_t *buf,u16_t len,u8_t option) + +{ + undefined2 in_register_0000202e; + byte *pbVar1; + undefined3 in_register_00002031; + + pbVar1 = buf + CONCAT22(in_register_0000202e,len); + while ((buf < pbVar1 && (*buf != 0xff))) { + if ((uint)*buf == CONCAT31(in_register_00002031,option)) { + return buf; + } + buf = buf + (uint)buf[1] + 2; + } + return (u8_t *)0x0; +} + + + +// WARNING: Type propagation algorithm not settling + +dhcp_client_node * dhcp_client_find_by_ip(uint8_t *ip) + +{ + dhcp_client_node *pdVar1; + void *in_a1; + ip4_addr_t iStack20; + uint32_t ipval; + + memcpy(&iStack20,in_a1,4); + pdVar1 = *(dhcp_client_node **)ip; + while ((pdVar1 != (dhcp_client_node *)0x0 && (iStack20 != (ip4_addr_t)(pdVar1->ipaddr).addr))) { + pdVar1 = pdVar1->next; + } + return pdVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +void dhcp_server_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *recv_addr,u16_t port) + +{ + byte bVar1; + u8_t uVar2; + char *pcVar3; + pbuf *p_to; + u8_t *puVar4; + u32_t n; + u32_t uVar5; + int iVar6; + u16_t len; + undefined4 *puVar7; + dhcp_client_node *pdVar8; + undefined4 *puVar9; + undefined4 *puVar10; + u8_t *buf; + ip_addr_t iStack56; + ip_addr_t addr; + u32_t tmp; + + iStack56 = (ip_addr_t)recv_addr->addr; + if (((p->len < 0x2c) || (p_to = pbuf_alloc(PBUF_TRANSPORT,0x5dc,PBUF_RAM), p_to == (pbuf *)0x0)) + || (p_to->tot_len < p->tot_len)) goto LAB_2304353a; + pbuf_copy(p_to,p); + pbuf_free(p); + pcVar3 = (char *)p_to->payload; + p = p_to; + if (((*pcVar3 != '\x01') || (*(int *)(pcVar3 + 0xec) != 0x63538263)) || + (bVar1 = pcVar3[2], 6 < bVar1)) goto LAB_2304353a; + buf = (u8_t *)(pcVar3 + 0xf0); + len = (u16_t)(((uint)p_to->tot_len - 0xf0) * 0x10000 >> 0x10); + puVar4 = dhcp_server_option_find(buf,len,'5'); + if (puVar4 == (u8_t *)0x0) goto LAB_2304353a; + uVar2 = puVar4[2]; + if (uVar2 == '\x01') { + pdVar8 = *(dhcp_client_node **)((int)arg + 0xc); + while (pdVar8 != (dhcp_client_node *)0x0) { + iVar6 = memcmp(pdVar8->chaddr,pcVar3 + 0x1c,(uint)bVar1); + if (iVar6 == 0) goto LAB_2304368e; + pdVar8 = pdVar8->next; + } + puVar4 = dhcp_server_option_find(buf,len,'2'); + if ((puVar4 == (u8_t *)0x0) || + (pdVar8 = dhcp_client_find_by_ip((uint8_t *)((int)arg + 0xc)), + pdVar8 == (dhcp_client_node *)0x0)) { + while (pdVar8 = dhcp_client_find_by_ip((uint8_t *)((int)arg + 0xc)), + pdVar8 != (dhcp_client_node *)0x0) { + n = lwip_htonl(*(u32_t *)((int)arg + 0x18)); + n = n + 1; + uVar5 = lwip_htonl(*(u32_t *)((int)arg + 0x14)); + if (uVar5 < n) { + n = lwip_htonl(*(u32_t *)((int)arg + 0x10)); + } + uVar5 = lwip_htonl(n); + *(u32_t *)((int)arg + 0x18) = uVar5; + } + pdVar8 = (dhcp_client_node *)mem_malloc(0x14); + if (pdVar8 == (dhcp_client_node *)0x0) goto LAB_2304353a; + memcpy(pdVar8->chaddr,pcVar3 + 0x1c,(uint)(byte)pcVar3[2]); + (pdVar8->ipaddr).addr = *(u32_t *)((int)arg + 0x18); + pdVar8->next = *(dhcp_client_node **)((int)arg + 0xc); + *(dhcp_client_node **)((int)arg + 0xc) = pdVar8; + } +LAB_2304368e: + pdVar8->lease_end = 0x80510100; + *pcVar3 = '\x02'; + pcVar3[3] = '\0'; + pcVar3[8] = '\0'; + pcVar3[9] = '\0'; + memcpy(pcVar3 + 0x14,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0xed] = -0x7e; + pcVar3[0xec] = 'c'; + pcVar3[0xef] = 'c'; + pcVar3[0x2c] = '\0'; + pcVar3[0x6c] = '\0'; + pcVar3[0xee] = 'S'; + memcpy(pcVar3 + 0x10,&pdVar8->ipaddr,4); + pcVar3[0xf0] = '5'; + pcVar3[0xf1] = '\x01'; + pcVar3[0xf2] = '\x02'; +LAB_230436fe: + pcVar3[0xf3] = '6'; + pcVar3[0xf4] = '\x04'; + memcpy(pcVar3 + 0xf5,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0xf9] = '3'; + pcVar3[0xfa] = '\x04'; + addr = 0x15180; + memcpy(pcVar3 + 0xfb,&addr,4); + pcVar3[0xff] = '\x01'; + pcVar3[0x100] = '\x04'; + memcpy(pcVar3 + 0x101,(void *)(*(int *)((int)arg + 4) + 8),4); + pcVar3[0x105] = '\x06'; + pcVar3[0x106] = '\x04'; + memcpy(pcVar3 + 0x107,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0x10b] = '\x03'; + pcVar3[0x10c] = '\x04'; + memcpy(pcVar3 + 0x10d,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0x111] = -1; + if (0x112 < p_to->tot_len) { + len = 0x112; +LAB_23043796: + pbuf_realloc(p_to,len); + } + } + else { + if (uVar2 != '\x03') { + if (uVar2 == '\a') { + puVar7 = *(undefined4 **)((int)arg + 0xc); + puVar10 = (undefined4 *)0x0; + while (puVar9 = puVar7, puVar9 != (undefined4 *)0x0) { + iVar6 = memcmp(puVar9 + 1,pcVar3 + 0x1c,(uint)(byte)pcVar3[2]); + puVar7 = (undefined4 *)*puVar9; + if (iVar6 == 0) { + if (*(undefined4 **)((int)arg + 0xc) == puVar9) { + *(undefined4 **)((int)arg + 0xc) = puVar7; + } + else { + *(undefined4 **)puVar10 = puVar7; + } + mem_free(puVar9); + break; + } + puVar7 = (undefined4 *)*puVar7; + puVar10 = puVar9; + } + } + goto LAB_2304353a; + } + pdVar8 = *(dhcp_client_node **)((int)arg + 0xc); + while (pdVar8 != (dhcp_client_node *)0x0) { + iVar6 = memcmp(pdVar8->chaddr,pcVar3 + 0x1c,(uint)bVar1); + if (iVar6 == 0) goto LAB_230438f0; + pdVar8 = pdVar8->next; + } + puVar4 = dhcp_server_option_find(buf,len,'2'); + if ((puVar4 != (u8_t *)0x0) && + (pdVar8 = dhcp_client_find_by_ip((uint8_t *)((int)arg + 0xc)), + pdVar8 != (dhcp_client_node *)0x0)) { + iVar6 = memcmp(pdVar8->chaddr,pcVar3 + 0x1c,(uint)(byte)pcVar3[2]); + if (iVar6 == 0) { +LAB_230438f0: + pdVar8->lease_end = 0x80510100; + *pcVar3 = '\x02'; + pcVar3[3] = '\0'; + pcVar3[8] = '\0'; + pcVar3[9] = '\0'; + memcpy(pcVar3 + 0x14,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0xed] = -0x7e; + pcVar3[0xec] = 'c'; + pcVar3[0xef] = 'c'; + pcVar3[0x2c] = '\0'; + pcVar3[0x6c] = '\0'; + pcVar3[0xee] = 'S'; + memcpy(pcVar3 + 0x10,&pdVar8->ipaddr,4); + pcVar3[0xf0] = '5'; + pcVar3[0xf1] = '\x01'; + pcVar3[0xf2] = '\x05'; + goto LAB_230436fe; + } + puts("IP Found, but MAC address is NOT the same\r\n"); + } + *pcVar3 = '\x02'; + pcVar3[3] = '\0'; + pcVar3[8] = '\0'; + pcVar3[9] = '\0'; + memcpy(pcVar3 + 0x14,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0xed] = -0x7e; + pcVar3[0xee] = 'S'; + pcVar3[0xec] = 'c'; + pcVar3[0xef] = 'c'; + pcVar3[0x2c] = '\0'; + pcVar3[0x6c] = '\0'; + memset(pcVar3 + 0x10,0,4); + pcVar3[0xf0] = '5'; + pcVar3[0xf1] = '\x01'; + pcVar3[0xf2] = '\x06'; + pcVar3[0xf3] = '6'; + pcVar3[0xf4] = '\x04'; + memcpy(pcVar3 + 0xf5,(void *)(*(int *)((int)arg + 4) + 4),4); + pcVar3[0xf9] = -1; + if (0xfa < p_to->tot_len) { + len = 0xfa; + goto LAB_23043796; + } + } + iStack56 = (ip_addr_t)0xffffffff; + udp_sendto_if(pcb,p_to,&iStack56,port,*(netif **)((int)arg + 4)); +LAB_2304353a: + pbuf_free(p); + return; +} + + + +err_t dhcp_server_start(netif *netif,ip4_addr_t *start,ip4_addr_t *end) + +{ + udp_pcb *puVar1; + dhcp_server *__s; + + __s = lw_dhcp_server; + while (__s != (dhcp_server *)0x0) { + if (__s->netif == netif) { + (__s->start).addr = start->addr; + (__s->end).addr = end->addr; + (__s->current).addr = start->addr; + return '\0'; + } + __s = __s->next; + } + __s = (dhcp_server *)mem_malloc(0x1c); + if (__s != (dhcp_server *)0x0) { + memset(__s,0,0x1c); + __s->netif = netif; + __s->node_list = (dhcp_client_node *)0x0; + __s->next = lw_dhcp_server; + lw_dhcp_server = __s; + (__s->start).addr = start->addr; + (__s->end).addr = end->addr; + (__s->current).addr = start->addr; + puVar1 = udp_new(); + __s->pcb = puVar1; + if (puVar1 != (udp_pcb *)0x0) { + puVar1->so_options = puVar1->so_options | 0x20; + udp_bind(__s->pcb,&ip_addr_any,0x43); + udp_recv(__s->pcb,dhcp_server_recv,__s); + return '\0'; + } + } + return -1; +} + + + +err_t dhcp_server_stop(netif *netif) + +{ + dhcp_server *pdVar1; + + pdVar1 = lw_dhcp_server; + while( true ) { + if (pdVar1 == (dhcp_server *)0x0) { + printf("[DHCP] [DHCPD] CRITICAL: no dhcp_server instance found\r\n"); + return -6; + } + if (pdVar1->netif == netif) break; + pdVar1 = pdVar1->next; + } + if (pdVar1->pcb != (udp_pcb *)0x0) { + udp_remove(pdVar1->pcb); + } + lw_dhcp_server = (dhcp_server *)0x0; + mem_free(pdVar1); + return '\0'; +} + + + +void dhcpd_start(netif *netif) + +{ + err_t eVar1; + char *fmt; + undefined3 extraout_var; + ip4_addr_t *piVar2; + ip4_addr_t iStack60; + ip4_addr_t ip_start; + ip4_addr_t ip_end; + char str_tmp [20]; + + dhcp_stop(netif); + set_if(netif,"192.168.169.1","0.0.0.0","255.255.255.0"); + netif_set_up(netif); + memcpy(&ip_end,"192.168.169.1",0xe); + fmt = strchr((char *)&ip_end,0x2e); + if (((fmt == (char *)0x0) || (fmt = strchr(fmt + 1,0x2e), fmt == (char *)0x0)) || + (fmt = strchr(fmt + 1,0x2e), fmt == (char *)0x0)) { + piVar2 = &ip_end; + fmt = "[DHCP] DHCPD_SERVER_IP: %s error!\r\n"; + } + else { + sprintf(fmt + 1,"%d",2); + ip4addr_aton((char *)&ip_end,&iStack60); + printf("[DHCP] ip_start: [%s]\r\n",&ip_end); + sprintf(fmt + 1,"%d",0xfe); + ip4addr_aton((char *)&ip_end,&ip_start); + printf("[DHCP] ip_start: [%s]\r\n",&ip_end); + eVar1 = dhcp_server_start(netif,&iStack60,&ip_start); + piVar2 = (ip4_addr_t *)CONCAT31(extraout_var,eVar1); + if (piVar2 == (ip4_addr_t *)0x0) { + return; + } + fmt = "[DHCP] dhcp_server_start res: %d.\r\n"; + } + printf(fmt,piVar2); + return; +} + + + +int dirent_type(void *addr) + +{ + int iVar1; + byte bVar2; + + bVar2 = *(byte *)((int)addr + 3) & 7; + if ((*(byte *)((int)addr + 3) & 7) == 0) { + iVar1 = 0; + } + else { + iVar1 = 2; + if ((bVar2 != 2) && (iVar1 = 3, bVar2 == 1)) { + return 1; + } + } + return iVar1; +} + + + +uint32_t dirent_hardfh(void *addr) + +{ + uint uVar1; + + uVar1 = *(uint *)addr; + return uVar1 << 0x18 | uVar1 >> 0x18 & 0xfffffff0 | (uVar1 & 0xff00) << 8 | uVar1 >> 8 & 0xff00; +} + + + +uint32_t dirent_childaddr(void *addr) + +{ + uint uVar1; + + uVar1 = *(uint *)((int)addr + 4); + return uVar1 << 0x18 | uVar1 >> 0x18 & 0xfffffff0 | (uVar1 & 0xff00) << 8 | uVar1 >> 8 & 0xff00; +} + + + +uint32_t dirent_size(void *addr) + +{ + uint uVar1; + + uVar1 = *(uint *)((int)addr + 8); + return uVar1 << 0x18 | uVar1 >> 0x18 | (uVar1 & 0xff00) << 8 | uVar1 >> 8 & 0xff00; +} + + + +int romfs_close(file_t *fp) + +{ + fp->f_arg = (void *)0x0; + fp->offset = 0; + return -1; +} + + + +int romfs_ioctl(file_t *fp,int cmd,ulong arg) + +{ + size_t sVar1; + uint32_t uVar2; + int iVar3; + void *pvVar4; + + iVar3 = -2; + if (((fp != (file_t *)0x0) && (arg != 0)) && (iVar3 = -3, cmd == 1)) { + pvVar4 = fp->f_arg; + sVar1 = strlen((char *)((int)pvVar4 + 0x10)); + *(size_t *)arg = (sVar1 + 0x10 & 0xfffffff0) + 0x10 + (int)pvVar4; + uVar2 = dirent_size(fp->f_arg); + *(uint32_t *)(arg + 4) = uVar2; + return 0; + } + return iVar3; +} + + + +ssize_t romfs_read(file_t *fp,char *buf,size_t length) + +{ + size_t sVar1; + uint32_t uVar2; + uint uVar3; + void *__src; + + __src = fp->f_arg; + sVar1 = strlen((char *)((int)__src + 0x10)); + uVar2 = dirent_size(fp->f_arg); + uVar3 = fp->offset; + if (uVar3 < uVar2) { + __src = (void *)((sVar1 + 0x10 & 0xfffffff0) + 0x10 + uVar3 + (int)__src); + if (uVar3 + length < uVar2) { + memcpy(buf,__src,length); + fp->offset = fp->offset + length; + } + else { + length = uVar2 - uVar3; + memcpy(buf,__src,length); + fp->offset = uVar2; + } + } + else { + length = 0; + } + return length; +} + + + +undefined4 file_info(char *param_1,char **param_2,char **param_3) + +{ + char *addr; + char *pcVar1; + char *pcVar2; + size_t __n; + int iVar3; + uint32_t uVar4; + TickType_t TVar5; + + addr = *param_2; + pcVar1 = *param_3; + __n = strlen(param_1); + if (__n < 0x41) { + if (romfs_root == addr) { + __n = strlen(addr + 0x10); + addr = addr + (__n + 0x10 & 0xfffffff0) + 0x50; + } + do { + iVar3 = dirent_type(addr); + if (iVar3 == 1) { + __n = strlen(param_1); + iVar3 = memcmp(param_1,addr + 0x10,__n); + if ((iVar3 == 0) && (__n = strlen(param_1), addr[__n + 0x10] == '\0')) { + uVar4 = dirent_hardfh(addr); + pcVar2 = romfs_root; + if (uVar4 == 0) goto LAB_23043d60; +LAB_23043d5e: + pcVar1 = pcVar2 + uVar4; +LAB_23043d60: + *param_2 = addr; + *param_3 = pcVar1; + return 0; + } + } + else { + if (iVar3 == 2) { + __n = strlen(param_1); + iVar3 = memcmp(param_1,addr + 0x10,__n); + if ((iVar3 == 0) && (__n = strlen(param_1), pcVar2 = romfs_root, addr[__n + 0x10] == '\0') + ) { + uVar4 = dirent_hardfh(addr); + goto LAB_23043d5e; + } + } + else { + if (iVar3 != 0) { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + iVar3 = dirent_type(addr); + bl_printk("[%10u][%s: %s:%4d] addr_start = %p, dirent_type(addr_start) = %d\r\n",TVar5, + &DAT_23078e4c,"bl_romfs.c",0xe6,addr,iVar3); + log_buf_out("bl_romfs.c",0xe7,addr,8,LOG_BUF_OUT_DATA_TYPE_HEX); + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] unknow the dirent_type.\r\n",&DAT_23078e4c,"bl_romfs.c", + 0xe8); + return 0xffffffff; + } + } + } + pcVar2 = romfs_root; + uVar4 = dirent_hardfh(addr); + addr = pcVar2 + uVar4; + } while (addr < pcVar1); + if (TrapNetCounter == 0) { + xTaskGetTickCount(); + } + else { + xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] start >= end, not found path = %s, addr_start = %p, addr_end = %p\r\n" + ,&DAT_230781b4,"bl_romfs.c",0xef,param_1,addr,pcVar1); + } + return 0xffffffff; +} + + + +int romfs_closedir(file_t *fp,aos_dir_t *dir) + +{ + if (dir != (aos_dir_t *)0x0) { + aos_free(dir); + return 0; + } + return -1; +} + + + +off_t romfs_lseek(file_t *fp,off_t off,int whence) + +{ + size_t sVar1; + uint32_t uVar2; + + if (fp == (file_t *)0x0) { + return -1; + } + uVar2 = dirent_size(fp->f_arg); + if (whence == 0) { + if (off < 0) { + printf("not support whence.\r\n"); + return -2; + } + } + else { + if (whence == 2) { + sVar1 = uVar2; + if (0 < off) { + printf("not support whence.\r\n"); + return -3; + } + } + else { + if (whence != 1) { + printf("not support whence.\r\n"); + return -4; + } + sVar1 = fp->offset; + } + off = off + sVar1; + if (off < 0) goto LAB_23043efe; + } + if ((uint)off <= uVar2) { + fp->offset = off; + return off; + } +LAB_23043efe: + printf("not support whence.\r\n"); + return -5; +} + + + +aos_dirent_t * romfs_readdir(file_t *fp,aos_dir_t *dir) + +{ + uint32_t uVar1; + int iVar2; + char *pcVar3; + uint uVar4; + void *addr; + void *addr_00; + + if (dir == (aos_dir_t *)0x0) { + return (aos_dirent_t *)0x0; + } +LAB_23043f6a: + do { + pcVar3 = romfs_root; + if ((void *)dir[2].dd_vfs_fd == (void *)0x0) { + dir[2].dd_vfs_fd = dir[1].dd_vfs_fd; + } + else { + addr_00 = (void *)dir[1].dd_rsv; + if (addr_00 <= (void *)dir[2].dd_vfs_fd) { + return (aos_dirent_t *)0x0; + } + while( true ) { + addr = (void *)dir[2].dd_vfs_fd; + if (addr_00 <= addr) { + return (aos_dirent_t *)0x0; + } + uVar1 = dirent_hardfh(addr); + if (uVar1 == 0) break; + if (addr == (void *)0x0) { + return (aos_dirent_t *)0x0; + } + iVar2 = dirent_type(addr); + if (iVar2 - 1U < 2) break; + *(char **)&dir[2].dd_vfs_fd = pcVar3 + uVar1; + } + } + strncpy((char *)((int)&dir[3].dd_vfs_fd + 1),(char *)(dir[2].dd_vfs_fd + 0x10),0x40); + addr_00 = (void *)dir[2].dd_vfs_fd; + *(undefined *)((int)&dir[0xb].dd_vfs_fd + 1) = 0; + uVar1 = dirent_hardfh(addr_00); + if (uVar1 == 0) { + pcVar3 = (char *)dir[1].dd_rsv; + } + else { + pcVar3 = romfs_root + uVar1; + } + *(char **)&dir[2].dd_vfs_fd = pcVar3; + uVar4 = dir[3].dd_vfs_fd & 0xffff00; + if (uVar4 == 0x2e2e00) { + if (*(char *)((int)&dir[3].dd_vfs_fd + 3) != '\0') goto LAB_23043fa0; + goto LAB_23043f6a; + } + if (uVar4 != 0x2e00) { +LAB_23043fa0: + return (aos_dirent_t *)&dir[2].dd_rsv; + } + } while( true ); +} + + + +uint32_t dirent_file(char *path,void **p_addr_start_input,void **p_addr_end_input) + +{ + bool bVar1; + char *pcVar2; + size_t __n; + size_t sVar3; + int iVar4; + TickType_t TVar5; + char *format; + char *pcVar6; + uint32_t uVar7; + undefined4 uVar8; + uint uVar9; + char *pcStack124; + char *addr_start; + char *addr_end; + char name [65]; + + __n = strlen(path); + sVar3 = strlen("/romfs"); + if (sVar3 <= __n) { + __n = strlen("/romfs"); + iVar4 = memcmp(path,"/romfs",__n); + if (iVar4 == 0) { + __n = strlen("/romfs"); + path = path + __n; + if (*path == '/') { + path = path + 1; +LAB_230440c0: + bVar1 = false; + uVar9 = *(uint *)(romfs_root + 8); + pcStack124 = romfs_root; + addr_start = romfs_root + + (uVar9 >> 8 & 0xff00 | uVar9 << 0x18 | uVar9 >> 0x18 | (uVar9 & 0xff00) << 8); + do { + if (*path == '\0') { +LAB_23044216: + *(char **)p_addr_start_input = pcStack124; + *(char **)p_addr_end_input = addr_start; + return 0; + } + pcVar6 = strchr(path,0x2f); + pcVar2 = pcStack124; + format = romfs_root; + if (bVar1) { + uVar7 = dirent_childaddr(pcStack124); + pcStack124 = format + uVar7; + if (pcVar2 == pcStack124) { + return 0xfffffffe; + } + } + if (pcVar6 == (char *)0x0) { + __n = strlen(path); + if (0x40 < __n) { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + uVar8 = 0x138; + format = "[%10u][%s: %s:%4d] name too long!\r\n"; + goto LAB_2304407e; + } + iVar4 = file_info(path,&pcStack124,&addr_start); + if (iVar4 != 0) { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + bl_printk( + "[%10u][%s: %s:%4d] file info error, p_name = %s, addr_start = %p, addr_end = %p\r\n" + ,TVar5,&DAT_230781b4,"bl_romfs.c",0x13c,path,pcStack124,addr_start); + return 0xffffffff; + } + goto LAB_23044216; + } + memset(&addr_end,0,0x41); + memcpy(&addr_end,path,(size_t)(pcVar6 + -(int)path)); + iVar4 = file_info(&addr_end,&pcStack124,&addr_start); + if (iVar4 != 0) { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + uVar8 = 0x147; + format = "[%10u][%s: %s:%4d] file info error.\r\n"; + goto LAB_2304407e; + } + path = pcVar6 + 1; + bVar1 = true; + } while( true ); + } + if (*path == '\0') goto LAB_230440c0; + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + uVar8 = 0x11a; + } + else { + if (TrapNetCounter == 0) { + TVar5 = xTaskGetTickCount(); + } + else { + TVar5 = xTaskGetTickCountFromISR(); + } + uVar8 = 0x115; + } + format = "[%10u][%s: %s:%4d] not support path.\r\n"; +LAB_2304407e: + bl_printk(format,TVar5,&DAT_23078e4c,"bl_romfs.c",uVar8); + } + return 0xffffffff; +} + + + +// WARNING: Variable defined which should be unmapped: end_addr + +aos_dir_t * romfs_opendir(file_t *fp,char *path) + +{ + char *pcVar1; + TickType_t TVar2; + aos_dir_t *__s; + uint32_t uVar3; + size_t sVar4; + char *pcStack24; + char *start_addr; + char *end_addr; + + if (romfs_root == (char *)0x0) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] romfs_root is null.\r\n",TVar2,&DAT_23078e4c,"bl_romfs.c",0x20d); + return (aos_dir_t *)0x0; + } + __s = (aos_dir_t *)aos_malloc(0x5d); + if (__s != (aos_dir_t *)0x0) { + memset(__s,0,0x5d); + uVar3 = dirent_file(path,&pcStack24,&start_addr); + pcVar1 = romfs_root; + if (uVar3 == 0) { + if (pcStack24 == romfs_root) { + sVar4 = strlen(pcStack24 + 0x10); + *(char **)&__s[1].dd_vfs_fd = pcStack24 + (sVar4 + 0x10 & 0xfffffff0) + 0x50; + } + else { + uVar3 = dirent_childaddr(pcStack24); + if (uVar3 == 0) { + return (aos_dir_t *)0x0; + } + *(char **)&__s[1].dd_vfs_fd = pcVar1 + uVar3; + } + __s[2].dd_vfs_fd = 0; + *(char **)&__s[1].dd_rsv = start_addr; + return __s; + } + aos_free(__s); + } + return (aos_dir_t *)0x0; +} + + + +// WARNING: Variable defined which should be unmapped: end_addr + +int romfs_stat(file_t *fp,char *path,stat *st) + +{ + char *addr; + uint32_t uVar1; + TickType_t TVar2; + int iVar3; + uint32_t uVar4; + mode_t mVar5; + char *pcStack24; + char *start_addr; + char *end_addr; + + pcStack24 = (char *)0x0; + start_addr = (char *)0x0; + uVar1 = dirent_file(path,&pcStack24,&start_addr); + addr = pcStack24; + if (uVar1 == 0) { + if (pcStack24 == romfs_root) { + st->st_size = 0; + } + else { + iVar3 = dirent_type(pcStack24); + if (iVar3 == 1) { + st->st_size = 0; + mVar5 = 0x4000; + } + else { + if (iVar3 != 2) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] dirent_type err.\r\n",TVar2,&DAT_230781b4,"bl_romfs.c",0x1fa + ); + return -2; + } + uVar4 = dirent_size(addr); + st->st_size = uVar4; + mVar5 = 0x8000; + } + st->st_mode = mVar5; + } + } + else { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] dirent_file res = %d\r\n",TVar2,&DAT_230781b4,"bl_romfs.c",0x1ea, + uVar1); + uVar1 = 0xffffffff; + } + return uVar1; +} + + + +int romfs_open(file_t *fp,char *path,int flags) + +{ + bool bVar1; + char cVar2; + TickType_t TVar3; + char *format; + size_t sVar4; + size_t __n; + int iVar5; + uint32_t uVar6; + undefined4 uVar7; + size_t unaff_s4; + void *pvStack40; + char *start_addr; + char *end_addr; + + if (romfs_root == (char *)0x0) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar7 = 0x162; + format = "[%10u][%s: %s:%4d] romfs_root is null.\r\n"; + } + else { + sVar4 = strlen(path); + __n = strlen("/romfs"); + iVar5 = strncmp(path,"/romfs",__n); + if (iVar5 == 0) { + __n = 0; + do { + if (sVar4 == __n) { + uVar6 = dirent_file(path,&pvStack40,&start_addr); + if (uVar6 != 0) { + return -2; + } + fp->offset = 0; + fp->f_arg = pvStack40; + return 0; + } + cVar2 = path[__n]; + if (0x19 < (byte)(cVar2 + 0x9fU)) { + if (((byte)(cVar2 + 0xbfU) < 0x1a) || ((byte)(cVar2 - 0x30U) < 10)) { + if (cVar2 == '/') goto LAB_23044576; + } + else { + if (cVar2 == '/') { +LAB_23044576: + if (__n == 0) { + unaff_s4 = 0; + } + else { + bVar1 = __n == unaff_s4; + unaff_s4 = __n; + if (bVar1) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar7 = 0x73; + format = "[%10u][%s: %s:%4d] format error.\r\n"; + goto LAB_230444bc; + } + } + } + else { + if ((cVar2 != '_') && (1 < (byte)(cVar2 - 0x2dU))) { + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] is_path_ch. i = %d\r\n",TVar3,&DAT_23078e4c, + "bl_romfs.c",0x69,__n); + goto LAB_23044548; + } + } + } + } + __n = __n + 1; + } while( true ); + } + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar7 = 0x61; + format = "[%10u][%s: %s:%4d] format is error.\r\n"; +LAB_230444bc: + bl_printk(format,TVar3,&DAT_23078e4c,"bl_romfs.c",uVar7); +LAB_23044548: + if (TrapNetCounter == 0) { + TVar3 = xTaskGetTickCount(); + } + else { + TVar3 = xTaskGetTickCountFromISR(); + } + uVar7 = 0x168; + format = "[%10u][%s: %s:%4d] path format is error.\r\n"; + } + bl_printk(format,TVar3,&DAT_23078e4c,"bl_romfs.c",uVar7); + return -1; +} + + + +// WARNING: Variable defined which should be unmapped: info + +int romfs_register(void) + +{ + uint __s1; + int iVar1; + TickType_t TVar2; + char *format; + size_t __n; + undefined4 uVar3; + undefined auStack44 [4]; + bl_mtd_info_t info; + + iVar1 = bl_mtd_open("media",&handle_romfs,2); + if (iVar1 == 0) { + memset(auStack44,0,0x1c); + bl_mtd_info(handle_romfs,(bl_mtd_info_t *)auStack44); + __s1 = info.size; + if ((void *)info.size == (void *)0x0) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar3 = 0x8d; + format = "[%10u][%s: %s:%4d] romfs has no XIP-Addr\r\n"; + } + else { + __n = strlen("-rom1fs-"); + iVar1 = memcmp((void *)__s1,"-rom1fs-",__n); + if (iVar1 == 0) { + romfs_root = (char *)info.size; + log_buf_out("bl_romfs.c",0x98,(void *)info.size,0x40,LOG_BUF_OUT_DATA_TYPE_HEX); + iVar1 = aos_register_fs("/romfs",&romfs_ops,(void *)0x0); + return iVar1; + } + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + uVar3 = 0x92; + format = "[%10u][%s: %s:%4d] romfs magic is NOT correct\r\n"; + } + bl_printk(format,TVar2,&DAT_23078e4c,"bl_romfs.c",uVar3); + } + else { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] [EF] [PART] [XIP] error when get romfs partition %d\r\n",TVar2, + &DAT_23078e4c,"bl_romfs.c",0x86,iVar1); + } + return -1; +} + + + +char * utils_bin2hex(char *dst,void *src,size_t count) + +{ + char cVar1; + byte *pbVar2; + char *pcVar3; + + pbVar2 = (byte *)src; + pcVar3 = dst; + while (pbVar2 != (byte *)((int)src + count)) { + cVar1 = "0123456789ABCDEF"[(uint)*pbVar2 & 0xf]; + *pcVar3 = "0123456789ABCDEF"[*pbVar2 >> 4]; + pcVar3[1] = cVar1; + pbVar2 = pbVar2 + 1; + pcVar3 = pcVar3 + 2; + } + return dst + count * 2; +} + + + +int utils_dns_domain_get(uint8_t *records,uint8_t *buf,int *len) + +{ + int iVar1; + int iVar2; + uint uVar3; + int iVar4; + int iVar5; + int iVar6; + + iVar6 = *len; + uVar3 = (uint)*records; + iVar2 = 1; + iVar5 = 0; + while ((iVar4 = iVar5, iVar1 = iVar2, uVar3 != 0 && (0 < iVar6))) { + uVar3 = uVar3 - 1; + buf[iVar4] = records[iVar1]; + iVar2 = iVar1 + 1; + iVar5 = iVar4 + 1; + iVar6 = iVar6 + -1; + if ((uVar3 == 0) && (iVar6 != 0)) { + buf[iVar5] = '.'; + uVar3 = (uint)records[iVar2]; + iVar2 = iVar1 + 2; + iVar5 = iVar4 + 2; + } + } + *len = iVar4; + return 0; +} + + + +void utils_list_init(utils_list *list) + +{ + list->first = (utils_list_hdr *)0x0; + list->last = (utils_list_hdr *)0x0; + return; +} + + + +void utils_list_push_back(utils_list *list,utils_list_hdr *list_hdr) + +{ + if (list->first == (utils_list_hdr *)0x0) { + list->first = list_hdr; + } + else { + list->last->next = list_hdr; + } + list->last = list_hdr; + list_hdr->next = (utils_list_hdr *)0x0; + return; +} + + + +utils_list_hdr * utils_list_pop_front(utils_list *list) + +{ + utils_list_hdr *puVar1; + + puVar1 = list->first; + if (puVar1 != (utils_list_hdr *)0x0) { + list->first = puVar1->next; + } + return puVar1; +} + + + +void utils_hexdump(void *mem,uint len) + +{ + uint uVar1; + int iVar2; + uint c; + int iVar3; + uint uVar4; + uint uVar5; + + iVar2 = 0; + if ((len & 0xf) != 0) { + iVar2 = 0x10 - (len & 0xf); + } + uVar4 = 0; + while (uVar1 = uVar4, iVar2 + len != uVar1) { + if ((uVar1 & 0xf) == 0) { + printf("0x%06x: ",uVar1); + } + if (uVar1 < len) { + printf("%02x ",(uint)*(byte *)((int)mem + uVar1)); + } + else { + printf(" "); + } + uVar4 = uVar1 + 1; + if ((uVar1 & 0xf) == 0xf) { + uVar5 = uVar1 - 0xf; + iVar3 = 0x11; + if (uVar4 < uVar5) { + iVar3 = 1; + } + while (uVar5 != (uVar1 - 0x10) + iVar3) { + c = 0x20; + if ((uVar5 < len) && (c = (uint)*(byte *)((int)mem + uVar5), (_ctype_[c + 1] & 0x97) == 0)) + { + c = 0x2e; + } + bl_putchar(c); + uVar5 = uVar5 + 1; + } + puts("\r\n"); + } + } + return; +} + + + +int utils_getopt_init(getopt_env_t *env,int opterr) + +{ + if (env != (getopt_env_t *)0x0) { + env->optarg = (char *)0x0; + env->optind = 1; + env->opterr = opterr; + env->optopt = 0; + env->__optpos = 0; + return 0; + } + return -1; +} + + + +int utils_getopt(getopt_env_t *env,int argc,char **argv,char *optstring) + +{ + byte bVar1; + byte bVar2; + int iVar3; + uint uVar4; + char **ppcVar5; + int iVar6; + byte *pbVar7; + char *pcVar8; + byte *pbVar9; + + if (env == (getopt_env_t *)0x0) { + return -1; + } + iVar6 = env->optind; + if (argc <= iVar6) { + return -1; + } + ppcVar5 = argv + iVar6; + pcVar8 = *ppcVar5; + if (pcVar8 == (char *)0x0) { + return -1; + } + if (*pcVar8 != '-') { + if (*optstring == '-') { + env->optind = iVar6 + 1; + env->optarg = *ppcVar5; + return 1; + } + return -1; + } + if (pcVar8[1] == '\0') { + return -1; + } + if ((pcVar8[1] == '-') && (pcVar8[2] == '\0')) { + env->optind = iVar6 + 1; + return -1; + } + if (env->__optpos == 0) { + env->__optpos = 1; + } + pbVar9 = (byte *)(*ppcVar5 + env->__optpos); + bVar1 = *pbVar9; + uVar4 = (uint)bVar1; + iVar3 = (uint)(bVar1 != 0) + env->__optpos; + env->__optpos = iVar3; + if ((*ppcVar5)[iVar3] == '\0') { + env->optind = iVar6 + 1; + env->__optpos = 0; + } + if ((*optstring - 0x2bU & 0xfd) == 0) { + optstring = optstring + 1; + } + iVar6 = 0; + do { + iVar3 = iVar6 + 1; + pbVar7 = (byte *)(optstring + iVar6); + bVar2 = *pbVar7; + if (bVar2 == 0) { + if (bVar1 == 0) goto LAB_230449a2; + goto LAB_23044984; + } + iVar6 = iVar3; + } while (uVar4 != (uint)bVar2); + if (bVar1 == 0x3a) { +LAB_23044984: + env->optopt = uVar4; + if (*optstring == ':') { + return 0x3f; + } + if (env->opterr == 0) { + return 0x3f; + } + bVar1 = *pbVar9; + pcVar8 = *argv; + iVar6 = 500; + } + else { +LAB_230449a2: + if (optstring[iVar3] != ':') { + return uVar4; + } + env->optarg = (char *)0x0; + iVar6 = env->__optpos; + if ((pbVar7[2] != 0x3a) || (iVar6 != 0)) { + iVar3 = env->optind; + env->optind = iVar3 + 1; + pcVar8 = argv[iVar3]; + env->__optpos = 0; + env->optarg = pcVar8 + iVar6; + } + if (env->optind <= argc) { + return uVar4; + } + env->optopt = uVar4; + if (*optstring == ':') { + return 0x3a; + } + if (env->opterr == 0) { + return 0x3f; + } + bVar1 = *pbVar9; + pcVar8 = *argv; + iVar6 = 0x214; + } + printf("[%10u][%s: %s:%4d] format error.\r\n" + iVar6 + 8,pcVar8,(uint)bVar1); + return 0x3f; +} + + + +int params_filter(uint32_t *r) + +{ + int *in_a1; + int iVar1; + uint uVar2; + int iVar3; + + iVar1 = 10; + if ((*(char *)r == '0') && ((*(byte *)((int)r + 1) & 0xdf) == 0x58)) { + r = (uint32_t *)((int)r + 2); + iVar1 = 0x10; + } + iVar3 = 0; + do { + uVar2 = (uint)*(byte *)r; + if (*(byte *)r == 0) { + *in_a1 = iVar3; + return 0; + } + iVar3 = iVar3 * iVar1; + if ((uVar2 - 0x30 & 0xff) < 10) { + iVar3 = iVar3 + -0x30; +LAB_23044a64: + iVar3 = iVar3 + uVar2; + } + else { + if (iVar1 == 10) { + return -1; + } + if (iVar1 == 0x10) { + if ((uVar2 - 0x61 & 0xff) < 6) { + iVar3 = iVar3 + -0x57; + } + else { + if (5 < (uVar2 - 0x41 & 0xff)) goto LAB_23044a66; + uVar2 = uVar2 - 0x37; + } + goto LAB_23044a64; + } + } +LAB_23044a66: + r = (uint32_t *)((int)r + 1); + } while( true ); +} + + + +void get_bytearray_from_string(char **params,uint8_t *result,int array_size) + +{ + int iVar1; + long lVar2; + char acStack36 [2]; + undefined uStack34; + char rand [3]; + + iVar1 = 0; + while (iVar1 < array_size) { + strncpy(acStack36,*params,2); + uStack34 = 0; + lVar2 = strtol(acStack36,(char **)0x0,0x10); + result[iVar1] = (uint8_t)lVar2; + iVar1 = iVar1 + 1; + *params = *params + 2; + } + return; +} + + + +void get_uint8_from_string(char **params,uint8_t *result) + +{ + uint32_t p; + + params_filter((uint32_t *)*params); + *result = '\0'; + return; +} + + + +void get_uint16_from_string(char **params,uint16_t *result) + +{ + uint32_t p; + + params_filter((uint32_t *)*params); + *result = 0; + return; +} + + + +int utils_tlv_bl_pack_auto(uint32_t *buf,int buf_sz,uint16_t type,void *arg1) + +{ + undefined2 in_register_00002032; + uint32_t uVar1; + int iVar2; + + if (CONCAT22(in_register_00002032,type) == 1) { + uVar1 = (uint32_t)*(byte *)arg1; + } + else { + if (CONCAT22(in_register_00002032,type) != 7) { + return -2; + } + uVar1 = *(uint32_t *)arg1; + } + iVar2 = -1; + if (3 < buf_sz) { + *buf = uVar1; + iVar2 = 4; + } + return iVar2; +} + + + +int utils_tlv_bl_unpack_auto(uint32_t *buf,int buf_sz,uint16_t type,void *arg1) + +{ + int iVar1; + undefined2 in_register_00002032; + bool bVar2; + uint32_t uVar3; + + if (CONCAT22(in_register_00002032,type) == 1) { + if (buf_sz < 4) { + bVar2 = true; + iVar1 = -1; + } + else { + iVar1 = 4; + bVar2 = *buf != 0; + } + *(bool *)arg1 = bVar2; + return iVar1; + } + if (CONCAT22(in_register_00002032,type) != 7) { + return -2; + } + if (buf_sz < 4) { + uVar3 = 0; + iVar1 = -1; + } + else { + uVar3 = *buf; + iVar1 = 4; + } + *(uint32_t *)arg1 = uVar3; + return iVar1; +} + + + +int aos_register_driver(char *path,file_ops_t *ops,void *arg) + +{ + BaseType_t BVar1; + int iVar2; + inode_t *piStack36; + inode_t *node; + + piStack36 = (inode_t *)0x0; + BVar1 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar1 == 1) { + iVar2 = inode_reserve(path,&piStack36); + if (iVar2 == 0) { + *(file_ops_t **)&piStack36->ops = ops; + piStack36->type = '\x01'; + piStack36->i_arg = arg; + } + BVar1 = xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + if (BVar1 == 1) { + return iVar2; + } + if (piStack36->i_name != (char *)0x0) { + vPortFree(piStack36->i_name); + } + memset(piStack36,0,0x14); + } + return -1; +} + + + +int aos_register_fs(char *path,fs_ops_t *ops,void *arg) + +{ + BaseType_t BVar1; + int iVar2; + inode_t *piStack36; + inode_t *node; + + piStack36 = (inode_t *)0x0; + BVar1 = xQueueSemaphoreTake((QueueHandle_t)g_vfs_mutex,0xffffffff); + if (BVar1 == 1) { + iVar2 = inode_reserve(path,&piStack36); + if (iVar2 == 0) { + *(fs_ops_t **)&piStack36->ops = ops; + piStack36->type = '\x03'; + piStack36->i_arg = arg; + } + BVar1 = xQueueGenericSend((QueueHandle_t)g_vfs_mutex,(void *)0x0,0,0); + if (BVar1 == 1) { + return iVar2; + } + if (piStack36->i_name != (char *)0x0) { + vPortFree(piStack36->i_name); + } + memset(piStack36,0,0x14); + } + return -1; +} + + + +int vfs_uart_open(inode_t *inode,file_t *fp) + +{ + uart_dev_t *uart; + int iVar1; + StreamBufferHandle_t pSVar2; + int32_t iVar3; + inode_t *piVar4; + + if ((fp == (file_t *)0x0) || (piVar4 = fp->node, piVar4 == (inode_t *)0x0)) { + iVar1 = -0x16; + } + else { + iVar1 = 0; + if (piVar4->refs == '\x01') { + uart = (uart_dev_t *)piVar4->i_arg; + aos_mutex_new((aos_mutex_t *)&uart->mutex); + pSVar2 = xStreamBufferGenericCreate(uart->rx_buf_size,1,0); + *(StreamBufferHandle_t *)&uart->rx_ringbuf_handle = pSVar2; + pSVar2 = xStreamBufferGenericCreate(uart->tx_buf_size,1,0); + *(StreamBufferHandle_t *)&uart->tx_ringbuf_handle = pSVar2; + if ((uart->rx_ringbuf_handle != (void *)0x0) && (pSVar2 != (StreamBufferHandle_t)0x0)) { + hal_uart_notify_register(uart,UART_TX_INT,__uart_tx_irq); + hal_uart_notify_register(uart,UART_RX_INT,__uart_rx_irq); + iVar3 = hal_uart_init(uart); + return iVar3; + } + return -0x16; + } + } + return iVar1; +} + + + +void __uart_rx_irq(void *p_arg) + +{ + uint32_t uStack88; + uint32_t length; + BaseType_t xHigherPriorityTaskWoken; + uint8_t tmp_buf [64]; + + uStack88 = 0; + length = 0; + hal_uart_recv_II((uart_dev_t *)p_arg,&xHigherPriorityTaskWoken,0x40,&uStack88,0); + if (uStack88 != 0) { + xStreamBufferSendFromISR + (*(StreamBufferHandle_t *)((int)p_arg + 0x10),&xHigherPriorityTaskWoken,uStack88, + (BaseType_t *)&length); + if (length != 0) { + vTaskSwitchContext(); + } + } + if (*(int *)((int)p_arg + 0x24) != 0) { + *(ushort *)(*(int *)((int)p_arg + 0x28) + 6) = *(ushort *)(*(int *)((int)p_arg + 0x28) + 6) | 1; + (**(code **)((int)p_arg + 0x24)) + (*(undefined4 *)((int)p_arg + 0x28),*(undefined4 *)((int)p_arg + 0x2c), + *(code **)((int)p_arg + 0x24)); + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void __uart_tx_irq(void *p_arg) + +{ + size_t sVar1; + undefined uStack21; + uint8_t ch; + int iStack20; + BaseType_t xHigherPriorityTaskWoken; + + iStack20 = 0; + sVar1 = xStreamBufferReceiveFromISR + (*(StreamBufferHandle_t *)((int)p_arg + 0x14),&uStack21,1, + (BaseType_t *)&stack0xffffffec); + if (iStack20 != 0) { + vTaskSwitchContext(); + } + if (sVar1 == 1) { + hal_uart_send((uart_dev_t *)p_arg,&uStack21,1,0); + } + else { + hal_uart_send_trigger_off((uart_dev_t *)p_arg); + } + return; +} + + + +int vfs_uart_close(file_t *fp) + +{ + uart_dev_t *uart; + int32_t iVar1; + inode_t *piVar2; + + if ((fp == (file_t *)0x0) || (piVar2 = fp->node, piVar2 == (inode_t *)0x0)) { + return -0x16; + } + if (piVar2->refs != '\x01') { + return 0; + } + uart = (uart_dev_t *)piVar2->i_arg; + if (uart != (uart_dev_t *)0x0) { + aos_mutex_free((aos_mutex_t *)&uart->mutex); + vStreamBufferDelete((StreamBufferHandle_t)uart->rx_ringbuf_handle); + vStreamBufferDelete((StreamBufferHandle_t)uart->tx_ringbuf_handle); + iVar1 = hal_uart_finalize(uart); + return iVar1; + } + return -0x16; +} + + + +ssize_t vfs_uart_read(file_t *fp,void *buf,size_t nbytes) + +{ + size_t sVar1; + TickType_t xTicksToWait; + size_t sVar2; + void *pvVar3; + + sVar1 = 0xffffffea; + if (fp != (file_t *)0x0) { + sVar1 = 0xffffffea; + if (((fp->node != (inode_t *)0x0) && (pvVar3 = fp->node->i_arg, nbytes != 0)) && + (pvVar3 != (void *)0x0)) { + aos_mutex_lock((aos_mutex_t *)((int)pvVar3 + 0x20),0xffffffff); + sVar1 = 0; + xTicksToWait = -(uint)(*(char *)((int)pvVar3 + 0x34) == '\x01'); + do { + sVar2 = xStreamBufferReceive + (*(StreamBufferHandle_t *)((int)pvVar3 + 0x10),(void *)((int)buf + sVar1), + nbytes - sVar1,xTicksToWait); + sVar1 = sVar1 + sVar2; + if (sVar1 == nbytes) break; + } while (xTicksToWait != 0); + aos_mutex_unlock((aos_mutex_t *)((int)pvVar3 + 0x20)); + } + } + return sVar1; +} + + + +ssize_t vfs_uart_write(file_t *fp,void *buf,size_t nbytes) + +{ + size_t sVar1; + uart_dev_t *uart; + + sVar1 = 0xffffffea; + if (fp != (file_t *)0x0) { + sVar1 = 0xffffffea; + if (((fp->node != (inode_t *)0x0) && + (uart = (uart_dev_t *)fp->node->i_arg, uart != (uart_dev_t *)0x0)) && + (sVar1 = xStreamBufferSend((StreamBufferHandle_t)uart->tx_ringbuf_handle,buf,nbytes,0), + 0 < (int)sVar1)) { + hal_uart_send_trigger(uart); + } + } + return sVar1; +} + + + +int vfs_uart_poll(file_t *fp,_Bool setup,poll_notify_t *notify,pollfd *fd,void *opa) + +{ + void *pvVar1; + BaseType_t BVar2; + undefined3 in_register_0000202d; + + pvVar1 = fp->node->i_arg; + aos_mutex_lock((aos_mutex_t *)((int)pvVar1 + 0x20),0xffffffff); + if (CONCAT31(in_register_0000202d,setup) == 0) { + vTaskEnterCritical(); + *(undefined4 *)((int)pvVar1 + 0x24) = 0; + *(undefined4 *)((int)pvVar1 + 0x2c) = 0; + vTaskExitCritical(); + } + else { + vTaskEnterCritical(); + *(poll_notify_t **)((int)pvVar1 + 0x24) = notify; + *(pollfd **)((int)pvVar1 + 0x28) = fd; + *(void **)((int)pvVar1 + 0x2c) = opa; + vTaskExitCritical(); + BVar2 = xStreamBufferIsEmpty(*(StreamBufferHandle_t *)((int)pvVar1 + 0x10)); + if (BVar2 != 1) { + *(ushort *)(*(int *)((int)pvVar1 + 0x28) + 6) = + *(ushort *)(*(int *)((int)pvVar1 + 0x28) + 6) | 1; + (*notify)(fd,opa); + } + } + aos_mutex_unlock((aos_mutex_t *)((int)pvVar1 + 0x20)); + return 0; +} + + + +int vfs_uart_sync(file_t *fp) + +{ + uart_dev_t *uart; + int iVar1; + + if (fp == (file_t *)0x0) { + return -0x16; + } + iVar1 = -0x16; + if (fp->node != (inode_t *)0x0) { + uart = (uart_dev_t *)fp->node->i_arg; + if (uart != (uart_dev_t *)0x0) { + aos_mutex_lock((aos_mutex_t *)&uart->mutex,0xffffffff); + hal_uart_send_flush(uart,0); + aos_mutex_unlock((aos_mutex_t *)&uart->mutex); + iVar1 = 0; + } + return iVar1; + } + return iVar1; +} + + + +int uart_ioctl_cmd_waimode(uart_dev_t *uart_dev,int cmd,ulong arg) + +{ + int iVar1; + size_t sVar2; + uint uVar3; + int iVar4; + + iVar1 = -0x16; + if (arg != 0) { + iVar4 = *(int *)(arg + 4); + uVar3 = *(int *)(arg + 8) * 1000; + iVar1 = 0; + do { + sVar2 = xStreamBufferReceive + ((StreamBufferHandle_t)uart_dev->rx_ringbuf_handle, + (void *)(*(int *)arg + iVar1),iVar4 - iVar1,uVar3 / 1000); + iVar1 = iVar1 + sVar2; + if (iVar4 == iVar1) { + return iVar1; + } + if (uVar3 < 1000) { + return iVar1; + } + } while ((cmd != 4) || (iVar1 < 1)); + } + return iVar1; +} + + + +int uart_ioctl_cmd_setconfig(uart_dev_t *uart_dev,ulong arg) + +{ + hal_uart_parity_t parity; + + if (arg != 0) { + parity = *(hal_uart_parity_t *)(arg + 4); + if ((parity != ODD_PARITY) && (parity != EVEN_PARITY)) { + parity = NO_PARITY; + } + hal_uart_setconfig(uart_dev,*(uint32_t *)arg,parity); + return 0; + } + return -0x16; +} + + + +int vfs_uart_ioctl(file_t *fp,int cmd,ulong arg) + +{ + int iVar1; + uart_dev_t *uart_dev; + uint8_t uVar2; + + if (fp == (file_t *)0x0) { + return -0x16; + } + iVar1 = -0x16; + if (fp->node == (inode_t *)0x0) { + return -0x16; + } + uart_dev = (uart_dev_t *)fp->node->i_arg; + if (uart_dev == (uart_dev_t *)0x0) { + return -0x16; + } + aos_mutex_lock((aos_mutex_t *)&uart_dev->mutex,0xffffffff); + switch(cmd) { + case 2: + hal_uart_send_flush(uart_dev,0); + break; + case 3: + hal_uart_setbaud(uart_dev,arg); + break; + case 4: + case 5: + iVar1 = uart_ioctl_cmd_waimode(uart_dev,cmd,arg); + goto switchD_23045074_caseD_7; + case 6: + uVar2 = '\x01'; + goto LAB_230450b8; + case 7: + uVar2 = '\x02'; +LAB_230450b8: + uart_dev->read_block_flag = uVar2; + break; + case 8: + iVar1 = uart_ioctl_cmd_setconfig(uart_dev,arg); + default: + goto switchD_23045074_caseD_7; + } + iVar1 = -1; +switchD_23045074_caseD_7: + aos_mutex_unlock((aos_mutex_t *)&uart_dev->mutex); + return iVar1; +} + + + +BL_Err_Type UART_Init(UART_ID_Type uartId,UART_CFG_Type *uartCfg) + +{ + UART_Parity_Type UVar1; + undefined3 in_register_00002029; + uint *puVar2; + uint uVar3; + uint uVar4; + uint uVar5; + uint uVar6; + + puVar2 = (uint *)uartAddr[CONCAT31(in_register_00002029,uartId)]; + uVar5 = uartCfg->uartClk / uartCfg->baudRate; + if (4 < ((uartCfg->uartClk * 10) / uartCfg->baudRate) % 10) { + uVar5 = uVar5 + 1; + } + puVar2[2] = uVar5 - 1 & 0xffff | (uVar5 - 1) * 0x10000; + UVar1 = uartCfg->parity; + uVar5 = *puVar2; + uVar6 = puVar2[1]; + if (UVar1 == UART_PARITY_ODD) { + uVar5 = uVar5 | 0x30; + uVar6 = uVar6 | 0x30; + } + else { + if (UVar1 == UART_PARITY_NONE) { + uVar5 = uVar5 & 0xffffffef; + uVar6 = uVar6 & 0xffffffef; + } + else { + if (UVar1 == UART_PARITY_EVEN) { + uVar5 = uVar5 & 0xffffffdf | 0x10; + uVar6 = uVar6 & 0xffffffdf | 0x10; + } + } + } + uVar3 = ((uint)uartCfg->dataBits + 4) * 0x100; + uVar4 = uVar5 & 0xfffff8ff | uVar3; + uVar3 = uVar6 & 0xfffff8ff | uVar3; + uVar5 = ((uint)uartCfg->stopBits + 1) * 0x1000; + uVar6 = uVar4 & 0xffffcffd | uVar5; + if (uartCfg->ctsFlowControl == ENABLE) { + uVar6 = uVar4 & 0xffffcfff | uVar5 | 2; + } + if (uartCfg->rxDeglitch == ENABLE) { + uVar3 = uVar3 | 0x800; + } + else { + uVar3 = uVar3 & 0xfffff7ff; + } + uVar5 = uVar3 & 0xfffffffd; + if (uartCfg->rtsSoftwareControl == ENABLE) { + uVar5 = uVar3 | 2; + } + *puVar2 = uVar6; + puVar2[1] = uVar5; + uVar5 = puVar2[3] & 0xfffffffe; + if (uartCfg->byteBitInverse == UART_MSB_FIRST) { + uVar5 = puVar2[3] | 1; + } + puVar2[3] = uVar5; + return SUCCESS; +} + + + +BL_Err_Type UART_FifoConfig(UART_ID_Type uartId,UART_FifoCfg_Type *fifoCfg) + +{ + undefined3 in_register_00002029; + uint32_t uVar1; + uint uVar2; + uint uVar3; + + uVar1 = uartAddr[CONCAT31(in_register_00002029,uartId)]; + *(uint *)(uVar1 + 0x84) = + (((uint)fifoCfg->txFifoDmaThreshold - 1) * 0x10000 | *(uint *)(uVar1 + 0x84) & 0xffe0ffff) & + 0xe0ffffff | ((uint)fifoCfg->rxFifoDmaThreshold - 1) * 0x1000000; + uVar3 = *(uint *)(uVar1 + 0x80) & 0xfffffffe; + if (fifoCfg->txFifoDmaEnable == ENABLE) { + uVar3 = *(uint *)(uVar1 + 0x80) | 1; + } + uVar2 = uVar3 & 0xfffffffd; + if (fifoCfg->rxFifoDmaEnable == ENABLE) { + uVar2 = uVar3 | 2; + } + *(uint *)(uVar1 + 0x80) = uVar2; + return SUCCESS; +} + + + +BL_Err_Type UART_Enable(UART_ID_Type uartId,UART_Direction_Type direct) + +{ + undefined3 in_register_00002029; + uint *puVar1; + + puVar1 = (uint *)uartAddr[CONCAT31(in_register_00002029,uartId)]; + if ((direct & ~UART_TXRX) == UART_TX) { + *puVar1 = *puVar1 | 1; + } + if ((byte)(direct + ~UART_TX) < 2) { + puVar1[1] = puVar1[1] | 1; + } + return SUCCESS; +} + + + +BL_Err_Type UART_Disable(UART_ID_Type uartId,UART_Direction_Type direct) + +{ + undefined3 in_register_00002029; + uint *puVar1; + + puVar1 = (uint *)uartAddr[CONCAT31(in_register_00002029,uartId)]; + if ((direct & ~UART_TXRX) == UART_TX) { + *puVar1 = *puVar1 & 0xfffffffe; + } + if ((byte)(direct + ~UART_TX) < 2) { + puVar1[1] = puVar1[1] & 0xfffffffe; + } + return SUCCESS; +} + + + +BL_Err_Type UART_SetRxTimeoutValue(UART_ID_Type uartId,uint8_t time) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + + *(uint *)(uartAddr[CONCAT31(in_register_00002029,uartId)] + 0x18) = + CONCAT31(in_register_0000202d,time) - 1U | + *(uint *)(uartAddr[CONCAT31(in_register_00002029,uartId)] + 0x18) & 0xffffff00; + return SUCCESS; +} + + + +BL_Err_Type UART_TxFreeRun(UART_ID_Type uartId,BL_Fun_Type txFreeRun) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + uint uVar1; + + uVar1 = *(uint *)uartAddr[CONCAT31(in_register_00002029,uartId)]; + if (CONCAT31(in_register_0000202d,txFreeRun) == 1) { + uVar1 = uVar1 | 4; + } + else { + uVar1 = uVar1 & 0xfffffffb; + } + *(uint *)uartAddr[CONCAT31(in_register_00002029,uartId)] = uVar1; + return SUCCESS; +} + + + +BL_Err_Type UART_IntMask(UART_ID_Type uartId,UART_INT_Type intType,BL_Mask_Type intMask) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + uint uVar1; + undefined3 in_register_00002031; + uint uVar2; + + uVar2 = *(uint *)(uartAddr[CONCAT31(in_register_00002029,uartId)] + 0x24); + if (CONCAT31(in_register_0000202d,intType) == 8) { + uVar1 = 0; + if (CONCAT31(in_register_00002031,intMask) == 1) { + uVar1 = uVar2 | 0xff; + } + } + else { + uVar1 = 1 << ((uint)intType & 0x1f); + if (CONCAT31(in_register_00002031,intMask) == 1) { + uVar1 = uVar1 | uVar2; + } + else { + uVar1 = ~uVar1 & uVar2; + } + } + *(uint *)(uartAddr[CONCAT31(in_register_00002029,uartId)] + 0x24) = uVar1; + return SUCCESS; +} + + + +uint8_t UART_GetTxFifoCount(UART_ID_Type uartId) + +{ + undefined3 in_register_00002029; + + return (uint8_t)((byte)*(undefined4 *)(uartAddr[CONCAT31(in_register_00002029,uartId)] + 0x84) & + 0x3f); +} + + + +BL_Err_Type UART_SendData(UART_ID_Type uartId,uint8_t *data,uint32_t len) + +{ + int iVar1; + uint uVar2; + uint8_t uVar3; + undefined3 in_register_00002029; + undefined3 extraout_var; + uint8_t *puVar4; + uint32_t uVar5; + + uVar5 = uartAddr[CONCAT31(in_register_00002029,uartId)]; + iVar1 = 160000; + uVar2 = 0; + do { + while( true ) { + if (len <= uVar2) { + return SUCCESS; + } + uVar3 = UART_GetTxFifoCount(uartId); + if (CONCAT31(extraout_var,uVar3) == 0) break; + puVar4 = data + uVar2; + uVar2 = uVar2 + 1; + iVar1 = 160000; + *(uint8_t *)(uVar5 + 0x88) = *puVar4; + } + iVar1 = iVar1 + -1; + } while (iVar1 != 0); + return TIMEOUT; +} + + + +uint8_t UART_GetRxFifoCount(UART_ID_Type uartId) + +{ + undefined3 in_register_00002029; + + return (uint8_t)((byte)((uint)*(undefined4 *) + (uartAddr[CONCAT31(in_register_00002029,uartId)] + 0x84) >> 8) & + 0x3f); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Reset(void) + +{ + _DAT_4000f90c = _DAT_4000f90c & 0xfffffffb; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Enable(void) + +{ + _DAT_4000f90c = _DAT_4000f90c | 1; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Disable(void) + +{ + _DAT_4000f90c = _DAT_4000f90c & 0xfffffffe; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Channel_Config(ADC_Chan_Type posCh,ADC_Chan_Type negCh,BL_Fun_Type contEn) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + + _DAT_4000f90c = + CONCAT31(in_register_00002029,posCh) << 8 | _DAT_4000f90c & 0xffffe007 | + CONCAT31(in_register_0000202d,negCh) << 3; + _DAT_4000f910 = + (CONCAT31(in_register_00002031,contEn) << 1 | _DAT_4000f910 & 0xfffffffd) & 0xfdffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Start(void) + +{ + _DAT_4000f90c = _DAT_4000f90c & 0xfffffffd; + BL602_Delay_US(100); + _DAT_4000f90c = _DAT_4000f90c | 2; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_FIFO_Cfg(ADC_FIFO_Cfg_Type *fifoCfg) + +{ + _DAT_40002000 = + (uint)fifoCfg->fifoThreshold << 0x16 | _DAT_40002000 & 0xff3ffffe | (uint)fifoCfg->dmaEn | 2; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t ADC_Get_FIFO_Count(void) + +{ + return (uint8_t)((byte)((uint)_DAT_40002000 >> 0x10) & 0x3f); +} + + + +// WARNING: Control flow encountered bad instruction data + +void ADC_Parse_Result(uint32_t *orgVal,uint32_t len,ADC_Result_Type *result) + +{ + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Tsen_Init(ADC_TSEN_MOD_Type tsenMod) + +{ + undefined3 in_register_00002029; + + _DAT_4000f90c = _DAT_4000f90c & 0x87ffffff | 0xc0000; + _DAT_4000f910 = _DAT_4000f910 | 0x4000000; + _DAT_4000f914 = + (_DAT_4000f914 & 0xfc3ffdf | CONCAT31(in_register_00002029,tsenMod) << 5) & 0xffffa07f | + 0x20000140; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_SET_TSVBE_LOW(void) + +{ + _DAT_4000f914 = _DAT_4000f914 & 0x7fffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_SET_TSVBE_HIGH(void) + +{ + _DAT_4000f914 = _DAT_4000f914 | 0x80000000; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t TSEN_Get_V_Error(void) + +{ + BL_Fun_Type BVar1; + uint8_t uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint uVar3; + uint32_t uStack44; + uint32_t regVal; + ADC_Result_Type result; + + uStack44 = 0; + _DAT_40002000 = _DAT_40002000 | 2; + ADC_SET_TSVBE_LOW(); + ADC_Start(); + do { + uVar2 = ADC_Get_FIFO_Count(); + BVar1 = adcGainCoeffCal.adcGainCoeffEnable; + } while (CONCAT31(extraout_var,uVar2) == 0); + uStack44 = _DAT_40002004; + adcGainCoeffCal.adcGainCoeffEnable = DISABLE; + ADC_Parse_Result(&uStack44,1,(ADC_Result_Type *)®Val); + uVar3 = (uint)regVal._2_2_; + _DAT_40002000 = _DAT_40002000 | 2; + adcGainCoeffCal.adcGainCoeffEnable = BVar1; + ADC_SET_TSVBE_HIGH(); + ADC_Start(); + do { + uVar2 = ADC_Get_FIFO_Count(); + BVar1 = adcGainCoeffCal.adcGainCoeffEnable; + } while (CONCAT31(extraout_var_00,uVar2) == 0); + uStack44 = _DAT_40002004; + adcGainCoeffCal.adcGainCoeffEnable = DISABLE; + ADC_Parse_Result(&uStack44,1,(ADC_Result_Type *)®Val); + adcGainCoeffCal.adcGainCoeffEnable = BVar1; + return uVar3 - regVal._2_2_; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +float TSEN_Get_Temp(uint32_t tsen_offset) + +{ + BL_Fun_Type BVar1; + uint8_t uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint32_t *orgVal; + SFtype SVar3; + undefined4 uVar4; + uint32_t uStack44; + uint32_t regVal; + ADC_Result_Type result; + + uStack44 = 0; + _DAT_40002000 = _DAT_40002000 | 2; + uVar4 = ADC_SET_TSVBE_LOW(); + ADC_Start(uVar4); + do { + uVar2 = ADC_Get_FIFO_Count(); + BVar1 = adcGainCoeffCal.adcGainCoeffEnable; + } while (CONCAT31(extraout_var,uVar2) == 0); + uStack44 = _DAT_40002004; + adcGainCoeffCal.adcGainCoeffEnable = DISABLE; + ADC_Parse_Result(&uStack44,1,(ADC_Result_Type *)®Val); + _DAT_40002000 = _DAT_40002000 | 2; + adcGainCoeffCal.adcGainCoeffEnable = BVar1; + uVar4 = ADC_SET_TSVBE_HIGH(); + ADC_Start(uVar4); + do { + uVar2 = ADC_Get_FIFO_Count(); + BVar1 = adcGainCoeffCal.adcGainCoeffEnable; + } while (CONCAT31(extraout_var_00,uVar2) == 0); + orgVal = &uStack44; + uStack44 = _DAT_40002004; + adcGainCoeffCal.adcGainCoeffEnable = DISABLE; + ADC_Parse_Result(orgVal,1,(ADC_Result_Type *)®Val); + adcGainCoeffCal.adcGainCoeffEnable = BVar1; + __extendsfdf2((SFtype)orgVal); + __divdf3(); + SVar3 = __truncdfsf2(); + return (float)SVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ADC_Init(ADC_CFG_Type *cfg) + +{ + uint uVar1; + uint uVar2; + + _DAT_4000f910 = + (uint)cfg->resWidth << 2 | + ((uint)cfg->clkDiv << 0x12 | + (uint)cfg->v11Sel << 0x1b | (uint)cfg->v18Sel << 0x1d | _DAT_4000f910 & 0x8001fffe | + (uint)cfg->offsetCalibEn) & 0xffffffe3; + if ((cfg->gain1 | cfg->gain2) == 0) { + uVar1 = 0xfffe1fff; + uVar2 = 0x8000; + } + else { + uVar1 = 0xfffe3fff; + uVar2 = 0x12000; + } + _DAT_4000f914 = + ((uint)cfg->biasSel << 0x11 | + (uint)cfg->gain2 << 0x16 | (uint)cfg->gain1 << 0x19 | _DAT_4000f914 & 0x803dffff) & uVar1 & + 0xffffe073 | uVar2 | (uint)cfg->vcm << 7 | (uint)cfg->vref << 3 | 0x1000 | + (uint)cfg->inputMode << 2; + _DAT_4000f938 = (int)cfg->offsetCalibVal | _DAT_4000f938 & 0xffff0000; + // WARNING: Treating indirect jump as call + ADC_Gain_Trim(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type Sec_Eng_SHA256_Update(SEC_Eng_SHA256_Ctx *shaCtx,uint8_t *input,uint32_t len) + +{ + byte bVar1; + uint uVar2; + int iVar3; + uint n; + uint32_t *psrc; + uint uVar4; + + uVar2 = _DAT_40004000; + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + bVar1 = shaCtx->shaFeed; + uVar4 = shaCtx->total[0] & 0x3f; + n = shaCtx->total[0] + len; + shaCtx->total[0] = n; + if (n < len) { + shaCtx->total[1] = shaCtx->total[1] + 1; + } + if ((uVar4 != 0) && (n = 0x40 - uVar4, n <= len)) { + BL602_MemCpy_Fast((void *)((int)shaCtx->shaBuf + uVar4),input,n); + _DAT_40004004 = shaCtx->shaBuf; + _DAT_40004000 = (uint)bVar1 << 6 | uVar2 & 0xffbf | 0x10002; + len = (len - 0x40) + uVar4; + shaCtx->shaFeed = '\x01'; + input = input + n; + uVar4 = 0; + } + psrc = (uint32_t *)input; + if (0x3f < len) { + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + _DAT_40004000 = (len >> 6) << 0x10 | (uint)shaCtx->shaFeed << 6 | _DAT_40004000 & 0xffbf | 2; + psrc = (uint32_t *)((int)input + (len & 0xffffffc0)); + _DAT_40004004 = (uint32_t *)input; + shaCtx->shaFeed = '\x01'; + } + if ((len & 0x3f) != 0) { + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + BL602_MemCpy_Fast((void *)((int)shaCtx->shaBuf + uVar4),psrc,len & 0x3f); + } + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_SHA256_Init(SEC_Eng_SHA256_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo, + SEC_ENG_SHA_Type shaType,uint32_t *shaTmpBuf,uint32_t *padding) + +{ + undefined3 in_register_00002031; + + _DAT_40004000 = CONCAT31(in_register_00002031,shaType) << 2 | _DAT_40004000 & 0xffffffe3; + memset(shaCtx,0,0x14); + shaCtx->shaPadding = padding; + shaCtx->shaBuf = shaTmpBuf; + BL602_MemSet(padding,'\0',0x40); + // WARNING: Treating indirect jump as call + BL602_MemSet(shaCtx->shaPadding,-0x80,1); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void Sec_Eng_SHA_Start(SEC_ENG_SHA_ID_Type shaNo) + +{ + _DAT_40004000 = _DAT_40004000 & 0xffffffbf | 0x20; + return; +} + + + +BL_Err_Type +Sec_Eng_SHA256_Update + (SEC_Eng_SHA256_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,uint8_t *input,uint32_t len) + +{ + BL_Err_Type BVar1; + + if (len != 0) { + BVar1 = Sec_Eng_SHA256_Update(shaCtx,input,len); + return BVar1; + } + return SUCCESS; +} + + + +// WARNING: Could not reconcile some variable overlaps +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +Sec_Eng_SHA256_Finish(SEC_Eng_SHA256_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,uint8_t *hash) + +{ + undefined4 uVar1; + uint uVar2; + int iVar3; + uint uVar4; + undefined uStack24; + undefined uStack23; + ushort uStack22; + uint8_t msgLen [8]; + + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + uVar2 = shaCtx->total[0]; + uVar4 = shaCtx->total[1] << 3; + uStack24 = (undefined)(uVar4 >> 0x18); + uStack23 = (undefined)(uVar4 >> 0x10); + uStack22 = (ushort)((uVar4 | uVar2 >> 0x1d) << 8) | (ushort)(uVar4 >> 8) & 0xff; + msgLen[0] = (uint8_t)((uVar2 << 3) >> 0x18); + msgLen[1] = (uint8_t)((uVar2 << 3) >> 0x10); + msgLen._2_2_ = (ushort)((uVar2 << 0x13) >> 0x18) | (ushort)(uVar2 << 0xb); + if ((uVar2 & 0x3f) < 0x38) { + iVar3 = 0x38; + } + else { + iVar3 = 0x78; + } + Sec_Eng_SHA256_Update(shaCtx,shaNo,(uint8_t *)shaCtx->shaPadding,iVar3 - (uVar2 & 0x3f)); + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + BL602_MemCpy_Fast(shaCtx->shaPadding,&uStack24,8); + Sec_Eng_SHA256_Update(shaCtx,(uint8_t *)shaCtx->shaPadding,8); + uVar1 = _DAT_40004010; + iVar3 = 16000000; + do { + iVar3 = iVar3 + -1; + if (iVar3 == 0) { + return TIMEOUT; + } + } while ((_DAT_40004000 & 1) != 0); + uVar2 = _DAT_40004000 >> 2; + *hash = (uint8_t)_DAT_40004010; + hash[1] = (uint8_t)((uint)uVar1 >> 8); + hash[2] = (uint8_t)((uint)uVar1 >> 0x10); + hash[3] = (uint8_t)((uint)uVar1 >> 0x18); + uVar1 = _DAT_40004014; + hash[4] = (uint8_t)_DAT_40004014; + hash[5] = (uint8_t)((uint)uVar1 >> 8); + hash[6] = (uint8_t)((uint)uVar1 >> 0x10); + hash[7] = (uint8_t)((uint)uVar1 >> 0x18); + uVar1 = _DAT_40004018; + hash[8] = (uint8_t)_DAT_40004018; + hash[9] = (uint8_t)((uint)uVar1 >> 8); + hash[10] = (uint8_t)((uint)uVar1 >> 0x10); + hash[0xb] = (uint8_t)((uint)uVar1 >> 0x18); + uVar1 = _DAT_4000401c; + hash[0xc] = (uint8_t)_DAT_4000401c; + hash[0xd] = (uint8_t)((uint)uVar1 >> 8); + hash[0xe] = (uint8_t)((uint)uVar1 >> 0x10); + hash[0xf] = (uint8_t)((uint)uVar1 >> 0x18); + uVar1 = _DAT_40004020; + hash[0x10] = (uint8_t)_DAT_40004020; + hash[0x11] = (uint8_t)((uint)uVar1 >> 8); + hash[0x13] = (uint8_t)((uint)uVar1 >> 0x18); + hash[0x12] = (uint8_t)((uint)uVar1 >> 0x10); + uVar1 = _DAT_40004024; + if ((uVar2 & 6) == 0) { + hash[0x14] = (uint8_t)_DAT_40004024; + hash[0x15] = (uint8_t)((uint)uVar1 >> 8); + hash[0x16] = (uint8_t)((uint)uVar1 >> 0x10); + hash[0x17] = (uint8_t)((uint)uVar1 >> 0x18); + uVar1 = _DAT_40004028; + hash[0x18] = (uint8_t)_DAT_40004028; + hash[0x19] = (uint8_t)((uint)uVar1 >> 8); + hash[0x1a] = (uint8_t)((uint)uVar1 >> 0x10); + hash[0x1b] = (uint8_t)((uint)uVar1 >> 0x18); + uVar1 = _DAT_4000402c; + if ((uVar2 & 7) == 0) { + hash[0x1c] = (uint8_t)_DAT_4000402c; + hash[0x1d] = (uint8_t)((uint)uVar1 >> 8); + hash[0x1e] = (uint8_t)((uint)uVar1 >> 0x10); + hash[0x1f] = (uint8_t)((uint)uVar1 >> 0x18); + } + } + _DAT_40004000 = _DAT_40004000 & 0xffffff9f; + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void DMA_Enable(void) + +{ + _DAT_4000c030 = _DAT_4000c030 | 1; + return; +} + + + +void DMA_Channel_Enable(uint8_t ch) + +{ + undefined3 in_register_00002029; + uint *puVar1; + + puVar1 = (uint *)(CONCAT31(in_register_00002029,ch) * 0x100 + 0x4000c110); + *puVar1 = *puVar1 | 1; + return; +} + + + +void DMA_LLI_Init(uint8_t ch,DMA_LLI_Cfg_Type *lliCfg) + +{ + undefined3 in_register_00002029; + uint *puVar1; + + puVar1 = (uint *)(CONCAT31(in_register_00002029,ch) * 0x100 + 0x4000c110); + *puVar1 = (uint)lliCfg->dir << 0xb | *puVar1 & 0xffffc001 | (uint)lliCfg->dstPeriph << 6 | + (uint)lliCfg->srcPeriph << 1; + return; +} + + + +void DMA_LLI_Update(uint8_t ch,uint32_t LLI) + +{ + undefined3 in_register_00002029; + + // WARNING: Treating indirect jump as call + BL602_MemCpy4((uint32_t *)(CONCAT31(in_register_00002029,ch) * 0x100 + 0x4000c100),(uint32_t *)LLI + ,4); + return; +} + + + +void DMA_IntMask(uint8_t ch,DMA_INT_Type intType,BL_Mask_Type intMask) + +{ + undefined3 in_register_00002029; + int iVar1; + uint *puVar2; + undefined3 in_register_0000202d; + int iVar3; + undefined3 in_register_00002031; + int iVar4; + uint uVar5; + uint uVar6; + + iVar4 = CONCAT31(in_register_00002031,intMask); + iVar3 = CONCAT31(in_register_0000202d,intType); + iVar1 = CONCAT31(in_register_00002029,ch) * 0x100; + if (iVar3 == 1) { + puVar2 = (uint *)(iVar1 + 0x4000c110); + uVar6 = *puVar2; + if (iVar4 == 0) { + uVar6 = uVar6 & 0xffffbfff; + goto LAB_23045ebe; + } + uVar5 = 0x4000; + } + else { + if (iVar3 == 0) { + uVar6 = *(uint *)(iVar1 + 0x4000c110); + iVar3 = -0x8000; + if (iVar4 != 0) { + uVar5 = 0x8000; + goto LAB_23045e9e; + } + } + else { + if (iVar3 != 2) { + return; + } + uVar6 = *(uint *)(iVar1 + 0x4000c110); + if (iVar4 != 0) { + uVar5 = 0xc000; +LAB_23045e9e: + puVar2 = (uint *)(iVar1 + 0x4000c10c); + *(uint *)(iVar1 + 0x4000c110) = uVar6 | uVar5; + uVar6 = *puVar2 & 0x7fffffff; + goto LAB_23045ebe; + } + iVar3 = -0xc000; + } + puVar2 = (uint *)(iVar1 + 0x4000c10c); + *(uint *)(iVar1 + 0x4000c110) = uVar6 & iVar3 - 1U; + uVar6 = *puVar2; + uVar5 = 0x80000000; + } + uVar6 = uVar6 | uVar5; +LAB_23045ebe: + *puVar2 = uVar6; + return; +} + + + +void Default_Handler(void) + +{ + bflb_platform_printf("Default_Handler\r\n"); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Set_UART_CLK(uint8_t enable,HBN_UART_CLK_Type clkSel,uint8_t div) + +{ + undefined3 in_register_00002029; + undefined3 in_register_00002031; + uint uVar1; + + _DAT_40000008 = CONCAT31(in_register_00002031,div) | _DAT_40000008 & 0xffffffe8; + HBN_Set_UART_CLK_Sel(clkSel); + uVar1 = _DAT_40000008 | 0x10; + if (CONCAT31(in_register_00002029,enable) == 0) { + uVar1 = _DAT_40000008 & 0xffffffef; + } + _DAT_40000008 = uVar1; + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Set_EM_Sel(GLB_EM_Type emType) + +{ + undefined3 in_register_00002029; + + _DAT_4000007c = CONCAT31(in_register_00002029,emType) | _DAT_4000007c & 0xfffffff0; + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Set_ADC_CLK(uint8_t enable,GLB_ADC_CLK_Type clkSel,uint8_t div) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + uint uVar1; + + uVar1 = (CONCAT31(in_register_00002031,div) | _DAT_400000a4 & 0xfffffec0) & 0xffffff7f | + CONCAT31(in_register_0000202d,clkSel) << 7; + _DAT_400000a4 = uVar1 & 0xfffffeff; + if (CONCAT31(in_register_00002029,enable) != 0) { + _DAT_400000a4 = uVar1 | 0x100; + } + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_UART_Fun_Sel(GLB_UART_SIG_Type sig,GLB_UART_SIG_FUN_Type fun) + +{ + undefined3 in_register_0000202d; + + _DAT_400000c0 = + ~(0xf << (((uint)sig & 7) << 2)) & _DAT_400000c0 | + CONCAT31(in_register_0000202d,fun) << (((uint)sig & 7) << 2); + return SUCCESS; +} + + + +BL_Err_Type GLB_GPIO_Write(GLB_GPIO_Type gpioPin,uint32_t val) + +{ + undefined3 in_register_00002029; + uint uVar1; + uint uVar2; + uint *puVar3; + + puVar3 = (uint *)((CONCAT31(in_register_00002029,gpioPin) >> 5) * 4 + 0x40000188); + uVar2 = *puVar3; + uVar1 = 1 << ((uint)gpioPin & 0x1f); + if (val == 0) { + uVar1 = ~uVar1 & uVar2; + } + else { + uVar1 = uVar1 | uVar2; + } + *puVar3 = uVar1; + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Set_UART_CLK_Sel(HBN_UART_CLK_Type clkSel) + +{ + undefined3 in_register_00002029; + + _DAT_4000f030 = CONCAT31(in_register_00002029,clkSel) << 2 | _DAT_4000f030 & 0xfffffffb; + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Get_RTC_Timer_Val(uint32_t *valLow,uint32_t *valHigh) + +{ + _DAT_4000f010 = _DAT_4000f010 & 0x7fffffff; + *valLow = _DAT_4000f00c; + *valHigh = _DAT_4000f010 & 0xff; + return SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Aon_Pad_IeSmt_Cfg(uint8_t padCfg) + +{ + undefined3 in_register_00002029; + + _DAT_4000f014 = CONCAT31(in_register_00002029,padCfg) << 8 | _DAT_4000f014 & 0xfffffeff; + return SUCCESS; +} + + + +uint32_t EF_Ctrl_Get_Byte_Zero_Cnt(uint8_t val) + +{ + undefined3 in_register_00002029; + uint32_t uVar1; + uint uVar2; + + uVar2 = 0; + uVar1 = 0; + do { + if ((CONCAT31(in_register_00002029,val) >> (uVar2 & 0x1f) & 1U) == 0) { + uVar1 = uVar1 + 1; + } + uVar2 = uVar2 + 1; + } while (uVar2 != 8); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type EF_Ctrl_Read_MAC_Address(uint8_t *mac) + +{ + uint8_t uVar1; + undefined4 uVar2; + uint uVar3; + BL_Err_Type BVar4; + uint32_t uVar5; + uint8_t *puVar6; + uint8_t *puVar7; + uint8_t *puVar8; + int iVar9; + uint uVar10; + + EF_Ctrl_Load_Efuse_R0(); + uVar2 = _DAT_40007014; + uVar10 = 0; + iVar9 = 0; + *mac = (uint8_t)_DAT_40007014; + mac[1] = (uint8_t)((uint)uVar2 >> 8); + mac[3] = (uint8_t)((uint)uVar2 >> 0x18); + mac[2] = (uint8_t)((uint)uVar2 >> 0x10); + uVar3 = _DAT_40007018; + mac[4] = (uint8_t)_DAT_40007018; + mac[5] = (uint8_t)(uVar3 >> 8); + do { + puVar7 = mac + iVar9; + iVar9 = iVar9 + 1; + uVar5 = EF_Ctrl_Get_Byte_Zero_Cnt(*puVar7); + uVar10 = uVar10 + uVar5; + } while (iVar9 != 6); + BVar4 = ERROR; + if (((uVar3 >> 0x10 ^ uVar10) & 0x3f) == 0) { + puVar6 = mac + 2; + puVar7 = mac + 5; + do { + uVar1 = *mac; + puVar8 = puVar7 + -1; + *mac = *puVar7; + *puVar7 = uVar1; + mac = mac + 1; + puVar7 = puVar8; + } while (puVar8 != puVar6); + BVar4 = SUCCESS; + } + return BVar4; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t EF_Ctrl_Is_MAC_Address_Slot_Empty(uint8_t slot,uint8_t reload) + +{ + undefined3 in_register_00002029; + int iVar1; + undefined3 in_register_0000202d; + int iVar2; + uint uVar3; + uint uVar4; + + iVar2 = CONCAT31(in_register_0000202d,reload); + iVar1 = CONCAT31(in_register_00002029,slot); + if (iVar1 == 0) { + EF_Ctrl_Sw_AHB_Clk_0(); + uVar3 = _DAT_40007014; + uVar4 = _DAT_40007018; + if (iVar2 != 0) { + EF_Ctrl_Load_Efuse_R0(); + uVar3 = _DAT_40007014; + uVar4 = _DAT_40007018; + } + } + else { + if (iVar1 == 1) { + EF_Ctrl_Sw_AHB_Clk_0(); + uVar3 = _DAT_4000706c; + uVar4 = _DAT_40007070; + if (iVar2 != 0) { + EF_Ctrl_Load_Efuse_R0(); + uVar3 = _DAT_4000706c; + uVar4 = _DAT_40007070; + } + } + else { + if (iVar1 != 2) { + return '\0'; + } + EF_Ctrl_Sw_AHB_Clk_0(); + uVar3 = _DAT_40007004; + uVar4 = _DAT_40007008; + if (iVar2 != 0) { + EF_Ctrl_Load_Efuse_R0(); + uVar3 = _DAT_40007004; + uVar4 = _DAT_40007008; + } + } + } + if ((uVar4 & 0x3fffff | uVar3) != 0) { + return '\0'; + } + return '\x01'; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type EF_Ctrl_Read_MAC_Address_Opt(uint8_t slot,uint8_t *mac,uint8_t reload) + +{ + uint8_t uVar1; + uint uVar2; + BL_Err_Type BVar3; + undefined3 in_register_00002029; + uint32_t uVar4; + undefined3 in_register_00002031; + uint8_t *puVar5; + undefined4 uVar6; + uint8_t *puVar7; + uint8_t *puVar8; + int iVar9; + uint uVar10; + + uVar10 = CONCAT31(in_register_00002029,slot); + if (2 < uVar10) { + return ERROR; + } + if (CONCAT31(in_register_00002031,reload) == 0) { +LAB_23046190: + uVar6 = _DAT_40007014; + if ((uVar10 == 0) || (uVar6 = _DAT_4000706c, uVar10 == 1)) goto LAB_23046198; + } + else { + if (uVar10 != 2) { + EF_Ctrl_Load_Efuse_R0(); + goto LAB_23046190; + } + EF_Ctrl_Load_Efuse_R0(); + } + uVar6 = _DAT_40007004; +LAB_23046198: + *mac = (uint8_t)uVar6; + mac[1] = (uint8_t)((uint)uVar6 >> 8); + mac[2] = (uint8_t)((uint)uVar6 >> 0x10); + mac[3] = (uint8_t)((uint)uVar6 >> 0x18); + uVar2 = _DAT_40007018; + if ((uVar10 != 0) && (uVar2 = _DAT_40007008, uVar10 == 1)) { + uVar2 = _DAT_40007070; + } + mac[4] = (uint8_t)uVar2; + mac[5] = (uint8_t)(uVar2 >> 8); + uVar10 = 0; + iVar9 = 0; + do { + puVar7 = mac + iVar9; + iVar9 = iVar9 + 1; + uVar4 = EF_Ctrl_Get_Byte_Zero_Cnt(*puVar7); + uVar10 = uVar10 + uVar4; + } while (iVar9 != 6); + BVar3 = ERROR; + if (((uVar2 >> 0x10 ^ uVar10) & 0x3f) == 0) { + puVar5 = mac + 2; + puVar7 = mac + 5; + do { + uVar1 = *mac; + puVar8 = puVar7 + -1; + *mac = *puVar7; + *puVar7 = uVar1; + mac = mac + 1; + puVar7 = puVar8; + } while (puVar5 != puVar8); + BVar3 = SUCCESS; + } + return BVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint EF_Ctrl_Is_CapCode_Slot_Empty(int param_1,int param_2) + +{ + uint uVar1; + + EF_Ctrl_Sw_AHB_Clk_0(); + if (param_2 != 0) { + EF_Ctrl_Load_Efuse_R0(); + } + if (param_1 == 0) { + uVar1 = _DAT_4000700c >> 2; + } + else { + uVar1 = _DAT_40007070; + if ((param_1 != 1) && (uVar1 = _DAT_40007008, param_1 != 2)) { + return 0; + } + uVar1 = uVar1 >> 0x16; + } + return (uint)((uVar1 & 0xff) == 0); +} + + + +// WARNING: Variable defined which should be unmapped: tmp +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type EF_Ctrl_Read_CapCode_Opt(uint8_t slot,uint8_t *code,uint8_t reload) + +{ + uint8_t uVar1; + undefined3 in_register_00002029; + uint uVar2; + undefined3 extraout_var; + undefined3 in_register_00002031; + uint uVar3; + uint32_t tmp; + + uVar2 = CONCAT31(in_register_00002029,slot); + if (2 < uVar2) { + return ERROR; + } + EF_Ctrl_Sw_AHB_Clk_0(); + if (CONCAT31(in_register_00002031,reload) != 0) { + EF_Ctrl_Load_Efuse_R0(); + } + if (uVar2 == 0) { + uVar3 = _DAT_4000700c >> 2; + } + else { + uVar3 = _DAT_40007008; + if (uVar2 == 1) { + uVar3 = _DAT_40007070; + } + uVar3 = uVar3 >> 0x16; + } + if ((uVar3 & 0x80) != 0) { + uVar1 = EF_Ctrl_Get_Trim_Parity(uVar3 & 0x3f,'\x06'); + if ((uVar3 >> 6 & 1) == CONCAT31(extraout_var,uVar1)) { + *code = (uint8_t)(uVar3 & 0x3f); + return SUCCESS; + } + } + return ERROR; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t EF_Ctrl_Is_PowerOffset_Slot_Empty(uint8_t slot,uint8_t reload) + +{ + byte bVar1; + undefined3 in_register_00002029; + int iVar2; + undefined3 in_register_0000202d; + byte bVar3; + uint uVar4; + + iVar2 = CONCAT31(in_register_00002029,slot); + EF_Ctrl_Sw_AHB_Clk_0(); + if (CONCAT31(in_register_0000202d,reload) != 0) { + EF_Ctrl_Load_Efuse_R0(); + } + if (iVar2 == 0) { + bVar3 = 1; + uVar4 = _DAT_40007078 >> 0xf; + } + else { + if (iVar2 == 1) { + bVar3 = (byte)_DAT_4000700c; + uVar4 = _DAT_40007074 & 0xffff; + } + else { + if (iVar2 != 2) { + return '\0'; + } + uVar4 = _DAT_40007074 >> 0x10; + bVar3 = (byte)(_DAT_4000700c >> 1); + } + bVar3 = ~bVar3 & 1; + } + bVar1 = 0; + if (uVar4 == 0) { + bVar1 = bVar3; + } + return (uint8_t)bVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type EF_Ctrl_Read_PowerOffset_Opt(uint8_t slot,int8_t *pwrOffset,uint8_t reload) + +{ + uint uVar1; + int iVar2; + uint32_t val; + uint8_t uVar3; + undefined3 in_register_00002029; + undefined3 extraout_var; + uint32_t uVar4; + undefined3 in_register_00002031; + byte bVar5; + uint uVar6; + undefined4 uVar7; + + iVar2 = CONCAT31(in_register_00002029,slot); + uVar7 = EF_Ctrl_Sw_AHB_Clk_0(); + if (CONCAT31(in_register_00002031,reload) != 0) { + EF_Ctrl_Load_Efuse_R0(uVar7); + } + if (iVar2 == 0) { + val = (_DAT_40007078 << 1) >> 0x11; + uVar1 = _DAT_40007078 >> 0x1f; + uVar6 = _DAT_40007078 >> 0xf; + } + else { + if (iVar2 == 1) { + val = _DAT_40007074 & 0x7fff; + uVar1 = _DAT_40007074 >> 0xf & 1; + uVar6 = _DAT_4000700c; + } + else { + if (iVar2 != 2) { + return ERROR; + } + val = (_DAT_40007074 << 1) >> 0x11; + uVar1 = _DAT_40007074 >> 0x1f; + uVar6 = _DAT_4000700c >> 1; + } + } + if (((uVar6 & 1) != 0) && + (uVar3 = EF_Ctrl_Get_Trim_Parity(val,'\x0f'), CONCAT31(extraout_var,uVar3) == uVar1)) { + iVar2 = 0; + do { + uVar4 = val; + __lshrdi3(val); + bVar5 = (byte)uVar4 & 0x1f; + if ((uVar4 & 0x10) != 0) { + bVar5 = bVar5 - 0x20; + } + pwrOffset[iVar2] = bVar5; + iVar2 = iVar2 + 1; + } while (iVar2 != 3); + return SUCCESS; + } + return ERROR; +} + + + +int8_t mfg_media_read_xtal_capcode(uint8_t *capcode,uint8_t reload) + +{ + int8_t iVar1; + + if (rf_para_on_flash != '\0') { + iVar1 = mfg_flash_read_xtal_capcode(capcode,reload); + return iVar1; + } + iVar1 = mfg_efuse_read_xtal_capcode(capcode,reload); + return iVar1; +} + + + +int8_t mfg_media_read_poweroffset(int8_t *pwrOffset,uint8_t reload) + +{ + int8_t iVar1; + + if (rf_para_on_flash != '\0') { + iVar1 = mfg_flash_read_poweroffset(pwrOffset,reload); + return iVar1; + } + iVar1 = mfg_efuse_read_poweroffset(pwrOffset,reload); + return iVar1; +} + + + +int8_t mfg_media_read_macaddr(uint8_t *mac,uint8_t reload) + +{ + int8_t iVar1; + + if (rf_para_on_flash != '\0') { + iVar1 = mfg_flash_read_macaddr(mac,reload); + return iVar1; + } + iVar1 = mfg_efuse_read_macaddr(mac,reload); + return iVar1; +} + + + +void bflb_platform_usart_dbg_send(uint8_t *data,uint32_t len) + +{ + UART_SendData(UART0_ID,data,len); + return; +} + + + +void bflb_platform_printf(char *fmt,...) + +{ + char print_buf [128]; + size_t len; + undefined4 in_a1; + undefined4 in_a2; + undefined4 in_a3; + undefined4 in_a4; + undefined4 in_a5; + undefined4 in_a6; + undefined4 in_a7; + va_list ap; + undefined4 uStack28; + undefined4 uStack24; + undefined4 uStack20; + undefined4 uStack16; + undefined4 uStack12; + undefined4 uStack8; + undefined4 uStack4; + + if (uart_dbg_disable == '\0') { + uStack28 = in_a1; + uStack24 = in_a2; + uStack20 = in_a3; + uStack16 = in_a4; + uStack12 = in_a5; + uStack8 = in_a6; + uStack4 = in_a7; + vsnprintf((char *)&ram0x420155ec,0x7f,fmt,&uStack28); + len = strlen((char *)0x420155ec); + bflb_platform_usart_dbg_send((uint8_t *)0x420155ec,len); + } + return; +} + + + +// WARNING: Control flow encountered bad instruction data + +void Default_Handler_Stub(void) + +{ + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +int8_t mfg_efuse_read_xtal_capcode(uint8_t *capcode,uint8_t reload) + +{ + uint8_t bclkDiv; + uint8_t hclkDiv; + BL_Err_Type BVar1; + int iVar2; + undefined3 extraout_var; + undefined3 in_register_0000202d; + undefined4 uVar3; + + uVar3 = CONCAT31(in_register_0000202d,reload); + bclkDiv = GLB_Get_BCLK_Div(); + hclkDiv = GLB_Get_HCLK_Div(); + HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_XTAL); + if ((rf_cal_slots < 3) || (iVar2 = EF_Ctrl_Is_CapCode_Slot_Empty(2,uVar3), iVar2 != 0)) { + if ((rf_cal_slots < 2) || (iVar2 = EF_Ctrl_Is_CapCode_Slot_Empty(1,uVar3), iVar2 != 0)) { + if ((rf_cal_slots == '\0') || (iVar2 = EF_Ctrl_Is_CapCode_Slot_Empty(0,uVar3), iVar2 != 0)) { + printf("No written slot found\r\n"); + iVar2 = 1; + goto LAB_23046628; + } + } + else { + iVar2 = 1; + } + } + else { + iVar2 = 2; + } + printf("Read slot:%d\r\n",iVar2); + BVar1 = EF_Ctrl_Read_CapCode_Opt((uint8_t)iVar2,capcode,reload); + iVar2 = CONCAT31(extraout_var,BVar1); +LAB_23046628: + GLB_Set_System_CLK_Div(hclkDiv,bclkDiv); + HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_PLL); + return (int8_t)-(iVar2 != 0); +} + + + +int8_t mfg_efuse_read_poweroffset(int8_t *pwrOffset,uint8_t reload) + +{ + int iVar1; + uint8_t bclkDiv; + uint8_t hclkDiv; + uint8_t uVar2; + BL_Err_Type BVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + int iVar4; + int iVar5; + int8_t iStack36; + char cStack35; + char cStack34; + int8_t pwrOffsetTmp [3]; + + bclkDiv = GLB_Get_BCLK_Div(); + hclkDiv = GLB_Get_HCLK_Div(); + HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_XTAL); + if ((rf_cal_slots < 3) || + (uVar2 = EF_Ctrl_Is_PowerOffset_Slot_Empty('\x02',reload), CONCAT31(extraout_var_00,uVar2) != 0 + )) { + if ((rf_cal_slots < 2) || + (uVar2 = EF_Ctrl_Is_PowerOffset_Slot_Empty('\x01',reload), CONCAT31(extraout_var,uVar2) != 0) + ) { + if (rf_cal_slots != '\0') { + uVar2 = EF_Ctrl_Is_PowerOffset_Slot_Empty('\0',reload); + iVar1 = CONCAT31(extraout_var_01,uVar2); + if (iVar1 == 0) goto LAB_230466e2; + } + printf("No written slot found\r\n"); + iVar1 = 1; + goto LAB_23046804; + } + iVar1 = 1; + } + else { + iVar1 = 2; + } +LAB_230466e2: + printf("Read slot:%d\r\n",iVar1); + BVar3 = EF_Ctrl_Read_PowerOffset_Opt((uint8_t)iVar1,&iStack36,reload); + iVar1 = CONCAT31(extraout_var_02,BVar3); + memset(pwrOffset,0,0xe); + *pwrOffset = iStack36; + pwrOffset[6] = cStack35; + pwrOffset[0xc] = cStack34; + iVar4 = (((int)cStack35 - (int)iStack36) * 100) / 6; + pwrOffset[2] = (char)((iVar4 + 0x19) / 0x32) + iStack36; + pwrOffset[3] = (char)((iVar4 * 3 + 0x32) / 100) + iStack36; + pwrOffset[4] = (char)((iVar4 * 4 + 0x32) / 100) + iStack36; + pwrOffset[1] = (char)((iVar4 + 0x32) / 100) + iStack36; + iVar5 = (((int)cStack34 - (int)cStack35) * 100) / 6; + pwrOffset[5] = (char)((iVar4 * 5 + 0x32) / 100) + iStack36; + pwrOffset[8] = (char)((iVar5 + 0x19) / 0x32) + cStack35; + pwrOffset[0xb] = (char)((iVar5 * 5 + 0x32) / 100) + cStack35; + pwrOffset[9] = (char)((iVar5 * 3 + 0x32) / 100) + cStack35; + pwrOffset[7] = (char)((iVar5 + 0x32) / 100) + cStack35; + pwrOffset[10] = (char)((iVar5 * 4 + 0x32) / 100) + cStack35; + pwrOffset[0xd] = (char)((iVar5 * 7 + 0x32) / 100) + cStack35; +LAB_23046804: + GLB_Set_System_CLK_Div(hclkDiv,bclkDiv); + HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_PLL); + return (int8_t)-(iVar1 != 0); +} + + + +int8_t mfg_efuse_read_macaddr(uint8_t *mac,uint8_t reload) + +{ + int iVar1; + uint8_t bclkDiv; + uint8_t hclkDiv; + uint8_t uVar2; + BL_Err_Type BVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + + bclkDiv = GLB_Get_BCLK_Div(); + hclkDiv = GLB_Get_HCLK_Div(); + HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_XTAL); + if ((rf_cal_slots < 3) || + (uVar2 = EF_Ctrl_Is_MAC_Address_Slot_Empty('\x02',reload), CONCAT31(extraout_var_00,uVar2) != 0 + )) { + if ((rf_cal_slots < 2) || + (uVar2 = EF_Ctrl_Is_MAC_Address_Slot_Empty('\x01',reload), CONCAT31(extraout_var,uVar2) != 0) + ) { + if (rf_cal_slots != '\0') { + uVar2 = EF_Ctrl_Is_MAC_Address_Slot_Empty('\0',reload); + iVar1 = CONCAT31(extraout_var_01,uVar2); + if (iVar1 == 0) goto LAB_230468bc; + } + printf("No written slot found\r\n"); + iVar1 = 1; + goto LAB_230468d6; + } + iVar1 = 1; + } + else { + iVar1 = 2; + } +LAB_230468bc: + printf("Read slot:%d\r\n",iVar1); + BVar3 = EF_Ctrl_Read_MAC_Address_Opt((uint8_t)iVar1,mac,reload); + iVar1 = CONCAT31(extraout_var_02,BVar3); +LAB_230468d6: + GLB_Set_System_CLK_Div(hclkDiv,bclkDiv); + HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_PLL); + return (int8_t)-(iVar1 != 0); +} + + +/* +Unable to decompile 'mfg_flash_read' +Cause: Exception while decompiling 23046908: Decompiler process died + +*/ + + +int8_t mfg_flash_read_xtal_capcode(uint8_t *capcode,uint8_t reload) + +{ + uint32_t uVar1; + int8_t iVar2; + undefined3 extraout_var; + uint32_t uVar3; + undefined3 in_register_0000202d; + + if ((((CONCAT31(in_register_0000202d,reload) == 0) || + (iVar2 = mfg_flash_read(), CONCAT31(extraout_var,iVar2) == 0)) && + (uVar1 = rf_para.crc32, rf_para.magic == 0x41)) && + ((uVar3 = BFLB_Soft_CRC32(&rf_para.capcode_valid,0x10), uVar1 == uVar3 && + (rf_para.capcode_valid == 'Z')))) { + iVar2 = '\0'; + *capcode = rf_para.capcode; + } + else { + iVar2 = -1; + } + return iVar2; +} + + + +int8_t mfg_flash_read_poweroffset(int8_t *pwrOffset,uint8_t reload) + +{ + int8_t iVar1; + int8_t iVar2; + uint32_t uVar3; + int8_t iVar4; + undefined3 extraout_var; + uint32_t uVar5; + undefined3 in_register_0000202d; + int iVar6; + int iVar7; + int iVar8; + + if ((((CONCAT31(in_register_0000202d,reload) == 0) || + (iVar4 = mfg_flash_read(), CONCAT31(extraout_var,iVar4) == 0)) && + (uVar3 = rf_para.crc32, rf_para.magic == 0x41)) && + ((uVar5 = BFLB_Soft_CRC32(&rf_para.capcode_valid,0x10), uVar3 == uVar5 && + (rf_para.poweroffset_valid == 'Z')))) { + memset(pwrOffset,0,0xe); + iVar2 = rf_para.poweroffset[2]; + iVar1 = rf_para.poweroffset[1]; + iVar4 = rf_para.poweroffset[0]; + iVar8 = (int)rf_para.poweroffset[1]; + iVar6 = (int)rf_para.poweroffset[0]; + iVar7 = (int)rf_para.poweroffset[2]; + *pwrOffset = rf_para.poweroffset[0]; + pwrOffset[6] = iVar1; + pwrOffset[0xc] = iVar2; + iVar6 = ((iVar8 - iVar6) * 100) / 6; + pwrOffset[2] = (char)((iVar6 + 0x19) / 0x32) + iVar4; + pwrOffset[3] = (char)((iVar6 * 3 + 0x32) / 100) + iVar4; + pwrOffset[4] = (char)((iVar6 * 4 + 0x32) / 100) + iVar4; + pwrOffset[1] = (char)((iVar6 + 0x32) / 100) + iVar4; + iVar7 = ((iVar7 - iVar8) * 100) / 6; + pwrOffset[5] = iVar4 + (char)((iVar6 * 5 + 0x32) / 100); + pwrOffset[8] = (char)((iVar7 + 0x19) / 0x32) + iVar1; + pwrOffset[10] = (char)((iVar7 * 4 + 0x32) / 100) + iVar1; + pwrOffset[7] = (char)((iVar7 + 0x32) / 100) + iVar1; + pwrOffset[9] = (char)((iVar7 * 3 + 0x32) / 100) + iVar1; + pwrOffset[0xb] = (char)((iVar7 * 5 + 0x32) / 100) + iVar1; + iVar4 = '\0'; + pwrOffset[0xd] = (char)((iVar7 * 7 + 0x32) / 100) + iVar1; + } + else { + iVar4 = -1; + } + return iVar4; +} + + + +int8_t mfg_flash_read_macaddr(uint8_t *mac,uint8_t reload) + +{ + uint32_t uVar1; + int8_t iVar2; + undefined3 extraout_var; + uint32_t uVar3; + undefined3 in_register_0000202d; + + if ((CONCAT31(in_register_0000202d,reload) == 0) || + (iVar2 = mfg_flash_read(), CONCAT31(extraout_var,iVar2) == 0)) { + uVar1 = rf_para.crc32; + if ((rf_para.magic == 0x41) && + ((uVar3 = BFLB_Soft_CRC32(&rf_para.capcode_valid,0x10), uVar1 == uVar3 && + (rf_para.mac_valid == 'Z')))) { + memcpy(mac,rf_para.mac,6); + return '\0'; + } + } + else { + printf("mfg_flash_read fail\r\n"); + } + return -1; +} + + + +void hal_mib_dump(void) + +{ + puts("---------- hal_mib_dump ----------\r\n"); + printf("machw_mib nx_rd_fifo_overflow_count is %u\r\n"); + puts("\r\n"); + return; +} + + + +int mm_monitor_channel_req_handler + (ke_msg_id_t msgid,mm_monitor_channel_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint16_t prim20_freq; + undefined4 *puVar1; + uint32_t uVar2; + uint16_t center1_freq; + + puVar1 = (undefined4 *)ke_msg_alloc(0x5f,src_id,dest_id,0x28); + center1_freq = (uint16_t)param->freq; + *puVar1 = 1; + puVar1[3] = 0x11111111; + puVar1[4] = 0x22222222; + puVar1[5] = 0x33333333; + puVar1[6] = 0x44444444; + puVar1[7] = 0x55555555; + puVar1[8] = 0x66666666; + puVar1[2] = 0; + puVar1[9] = 0x77777777; + uVar2 = param->freq; + puVar1[1] = uVar2; + prim20_freq = (uint16_t)uVar2; + if ((param->use_40Mhz != 0) && (center1_freq = prim20_freq + 10, param->higher_band == 0)) { + center1_freq = prim20_freq - 10; + } + phy_set_channel('\0',param->use_40Mhz != 0,prim20_freq,center1_freq,0,'\0'); + *puVar1 = 0; + ke_msg_send(puVar1); + return 0; +} + + + +int mm_monitor_enable_req_handler + (ke_msg_id_t msgid,mm_monitor_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined4 *puVar1; + u32_l local_50; + phy_cfg_tag config; + + puVar1 = (undefined4 *)ke_msg_alloc(0x5d,src_id,dest_id,0x28); + *puVar1 = 1; + puVar1[3] = 0x11111111; + puVar1[4] = 0x22222222; + puVar1[5] = 0x33333333; + puVar1[6] = 0x44444444; + puVar1[7] = 0x55555555; + puVar1[8] = 0x66666666; + puVar1[2] = 0; + puVar1[9] = 0x77777777; + puVar1[1] = param->enable; + memset(&local_50,0,0x40); + local_50 = 0; + phy_init((phy_cfg_tag *)&local_50); + phy_set_channel('\0','\0',0x985,0x985,0,'\0'); + mm_active(); + *puVar1 = 0; + ke_msg_send(puVar1); + return 0; +} + + + +int mm_cfg_rssi_req_handler + (ke_msg_id_t msgid,mm_cfg_rssi_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + byte bVar1; + uint uVar2; + + uVar2 = (uint)param->vif_index; + if (vif_info_tab[uVar2].type != '\0') { + assert_err("vif_entry->type == VIF_STA","module",0x8fe); + } + vif_info_tab[uVar2].u[0x1a] = param->rssi_thold; + bVar1 = param->rssi_hyst; + vif_info_tab[uVar2].u[0x1c] = 0; + vif_info_tab[uVar2].u[0x1b] = bVar1; + return 0; +} + + + +int mm_set_ps_options_req_handler + (ke_msg_id_t msgid,mm_set_ps_options_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint uVar1; + + uVar1 = (uint)param->vif_index; + if (vif_info_tab[uVar1].type != '\0') { + assert_err("vif_entry->type == VIF_STA","module",0x815); + } + *(uint16_t *)vif_info_tab[uVar1].u = param->listen_interval; + *(_Bool *)(vif_info_tab[uVar1].u + 2) = param->dont_listen_bc_mc; + ke_msg_send_basic(0x4c,src_id,dest_id); + return 0; +} + + + +int mm_tim_update_req_handler + (ke_msg_id_t msgid,mm_tim_update_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + mm_tim_update(param); + return 1; +} + + + +int mm_bcn_change_req_handler + (ke_msg_id_t msgid,mm_bcn_change_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + mm_bcn_change(param); + return 1; +} + + + +int mm_remain_on_channel_req_handler + (ke_msg_id_t msgid,mm_remain_on_channel_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + uint8_t uVar1; + uint8_t uVar2; + uint8_t *puVar3; + undefined2 in_register_00002036; + + uVar2 = chan_roc_req(param,src_id); + if (CONCAT22(in_register_00002036,src_id) != 0) { + puVar3 = (uint8_t *)ke_msg_alloc(0x47,src_id,dest_id,3); + uVar1 = param->op_code; + puVar3[1] = uVar2; + *puVar3 = uVar1; + puVar3[2] = '\x04'; + ke_msg_send(); + } + return 0; +} + + + +int mm_sta_del_req_handler + (ke_msg_id_t msgid,mm_sta_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + mm_sta_del(param->sta_idx); + ke_msg_send_basic(0xd,src_id,dest_id); + return 0; +} + + + +int mm_sta_add_req_handler + (ke_msg_id_t msgid,mm_sta_add_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t uVar1; + uint8_t *puVar2; + + puVar2 = (uint8_t *)ke_msg_alloc(0xb,src_id,dest_id,3); + uVar1 = mm_sta_add(param,puVar2 + 1,puVar2 + 2); + *puVar2 = uVar1; + ke_msg_send(puVar2); + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mm_key_del_req_handler + (ke_msg_id_t msgid,mm_key_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + if ((_DAT_44b000d8 >> 0x18) + 1 < (uint)param->hw_key_idx) { + assert_err("param->hw_key_idx <= MM_SEC_MAX_KEY_NBR","module",0x56e); + } + mm_sec_machwkey_del(param->hw_key_idx); + ke_msg_send_basic(0x27,src_id,dest_id); + return 0; +} + + + +int mm_key_add_req_handler + (ke_msg_id_t msgid,mm_key_add_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t uVar1; + undefined *puVar2; + + puVar2 = (undefined *)ke_msg_alloc(0x25,src_id,dest_id,2); + if (3 < param->key_idx) { + assert_err("param->key_idx < MAC_DEFAULT_KEY_COUNT","module",0x53d); + } + if (0x20 < (param->key).length) { + assert_err("param->key.length <= MAC_SEC_KEY_LEN","module",0x541); + } + if (5 < param->cipher_suite) { + assert_err("param->cipher_suite <= MAC_RSNIE_CIPHER_AES_CMAC","module",0x544); + } + uVar1 = mm_sec_machwkey_wr(param); + puVar2[1] = uVar1; + *puVar2 = 0; + ke_msg_send(puVar2); + return 0; +} + + + +int mm_set_power_req_handler + (ke_msg_id_t msgid,mm_set_power_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint uVar1; + uint8_t *idx; + + uVar1 = (uint)param->inst_nbr; + idx = (uint8_t *)ke_msg_alloc(0x2f,src_id,dest_id,2); + vif_info_tab[uVar1].user_tx_power = param->power; + idx[1] = vif_info_tab[uVar1].tx_power; + vif_info_tab[uVar1].tx_power = '\x7f'; + tpc_update_vif_tx_power(vif_info_tab + uVar1,(int8_t *)(idx + 1),idx); + ke_msg_send(idx); + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mm_set_idle_req_handler + (ke_msg_id_t msgid,mm_set_idle_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + int iVar1; + ke_state_t kVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + + kVar2 = ke_state_get(dest_id); + if (CONCAT31(extraout_var,kVar2) == 3) { +LAB_2304706e: + iVar1 = 2; + } + else { + mm_env.host_idle = param->hw_idle; + if (mm_env.host_idle == '\0') { + kVar2 = ke_state_get(dest_id); + if (CONCAT31(extraout_var_01,kVar2) == 2) goto LAB_2304706e; + mm_active(); + } + else { + kVar2 = ke_state_get(dest_id); + if (CONCAT31(extraout_var_00,kVar2) != 0) { + if (CONCAT31(extraout_var_00,kVar2) == 2) { + return 2; + } + hal_machw_idle_req(); + ke_state_set(dest_id,2); + return 2; + } + if ((_DAT_44b00038 & 0xf) != 0) { + assert_err("blmac_current_state_getf() == HW_IDLE","module",0x47d); + } + mm_env._18_2_ = 0; + } + ke_msg_send_basic(0x23,src_id,dest_id); + iVar1 = 0; + } + return iVar1; +} + + +/* +Unable to decompile 'mm_reset_req_handler' +Cause: Exception while decompiling 230470f6: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mm_version_req_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined4 *puVar1; + + puVar1 = (undefined4 *)ke_msg_alloc(5,src_id,dest_id,0x18); + *puVar1 = 0x5040000; + puVar1[1] = _DAT_44b00004; + puVar1[2] = _DAT_44b00008; + phy_get_version(puVar1 + 3,puVar1 + 4); + puVar1[5] = 0x89df; + ke_msg_send(puVar1); + return 0; +} + + + +int mm_start_req_handler + (ke_msg_id_t msgid,mm_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + + kVar1 = ke_state_get(dest_id); + if (CONCAT31(extraout_var,kVar1) != 0) { + assert_err("ke_state_get(dest_id) == MM_IDLE","module",0x135); + } + phy_init((phy_cfg_tag *)param); + phy_set_channel('\0','\0',0x96c,0x96c,0,'\0'); + tpc_update_tx_power('\x10'); + ps_env.uapsd_timeout = param->uapsd_timeout * 1000; + mm_env.lp_clk_accuracy = param->lp_clk_accuracy; + ke_msg_send_basic(3,src_id,dest_id); + mm_active(); + hal_machw_idle_req(); + ke_state_set(dest_id,2); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling + +int mm_set_ps_mode_req_handler + (ke_msg_id_t msgid,mm_set_ps_mode_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + vif_info_tag *vif_entry; + + vif_entry = (vif_info_tag *)vif_mgmt_env.used_list.first; + if (param->new_state == '\x03') { + while (vif_entry != (vif_info_tag *)0x0) { + if ((vif_entry->type == '\0') && (vif_entry->active != false)) { + ps_polling_frame(vif_entry); + } + vif_entry = *(vif_info_tag **)&vif_entry->list_hdr; + } + ke_msg_send_basic(0x32,ps_env.taskid,0); + } + else { + ps_set_mode(param->new_state,src_id); + } + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mm_force_idle_req_handler + (ke_msg_id_t msgid,mm_force_idle_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + int iVar1; + ke_state_t kVar2; + undefined3 extraout_var; + + kVar2 = ke_state_get(dest_id); + if (CONCAT31(extraout_var,kVar2) == 0) { + if ((_DAT_44b00038 & 0xf) != 0) { + assert_err("blmac_current_state_getf() == HW_IDLE","module",0x4c0); + } + ke_state_set(dest_id,3); + iVar1 = 0; + (*param->cb)(param->cb); + } + else { + iVar1 = 2; + if (CONCAT31(extraout_var,kVar2) != 2) { + hal_machw_idle_req(); + ke_state_set(dest_id,2); + } + } + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mm_hw_config_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + char cVar1; + byte bVar2; + _Bool _Var3; + uint8_t uVar4; + uint16_t uVar5; + uint32_t uVar6; + uint32_t uVar7; + int iVar8; + ke_state_t kVar9; + uint8_t uVar10; + ke_msg_id_t id; + undefined2 in_register_0000202a; + undefined3 extraout_var; + uint8_t *puVar11; + uint32_t uVar12; + uint32_t uVar13; + uint uVar14; + uint uVar15; + uint uVar16; + + uVar16 = CONCAT22(in_register_0000202a,msgid); + kVar9 = ke_state_get(dest_id); + if (CONCAT31(extraout_var,kVar9) != 0) { + if (1 < (CONCAT31(extraout_var,kVar9) - 2U & 0xffff)) { + mm_env.prev_hw_state = (byte)_DAT_44b00038 & 0xf; + mm_env.prev_mm_state = ke_state_get(dest_id); + hal_machw_idle_req(); + ke_state_set(dest_id,2); + } + return 2; + } + if ((_DAT_44b00038 & 0xf) != 0) { + assert_err("blmac_current_state_getf() == HW_IDLE","module",0x77b); + } + iVar8 = DAT_4201e2f0; + if (uVar16 == 0x16) { + (&mm_env.rx_filter_lmac_enable)[(uint)*(byte *)((int)param + 5) + 4] = *(uint32_t *)param; + if ((iVar8 != 0) && (*(char *)(iVar8 + 4) == *(char *)((int)param + 5))) { + _DAT_44b000dc = 0x10; + } + id = 0x17; +LAB_2304748e: + ke_msg_send_basic(id,src_id,dest_id); + } + else { + if (0x16 < uVar16) { + if (uVar16 == 0x1e) { + uVar16 = (uint)*(byte *)((int)param + 3); + if (vif_info_tab[uVar16].type == '\0') { + if (*(char *)((int)param + 2) == '\0') { + mm_timer_clear(&vif_info_tab[uVar16].tbtt_timer); + } + else { + uVar14 = (uint)vif_info_tab[uVar16].u[4]; + mm_timer_set(&vif_info_tab[uVar16].tbtt_timer, + _DAT_44b00120 + sta_info_tab[uVar14].bcn_int); + uVar5 = *(uint16_t *)param; + uVar12 = sta_info_tab[uVar14].bcn_int; + *(undefined2 *)vif_info_tab[uVar16].u = 0; + sta_info_tab[uVar14].aid = uVar5; + uVar15 = (uint)mm_env.lp_clk_accuracy; + vif_info_tab[uVar16].u[2] = 0; + sta_info_tab[uVar14].drift = (uint16_t)(((uVar15 + 0x14) * uVar12) / 1000000); + iVar8 = _DAT_44b00120; + vif_info_tab[uVar16].u[0x18] = 0; + *(undefined4 *)(vif_info_tab[uVar16].u + 0x14) = 0; + *(int *)(vif_info_tab[uVar16].u + 8) = iVar8; + vif_info_tab[uVar16].prevent_sleep = vif_info_tab[uVar16].prevent_sleep | 1; + *(int *)(vif_info_tab[uVar16].u + 0x10) = _DAT_44b00120; + chan_bcn_detect_start(vif_info_tab + uVar16); + } + } + _Var3 = *(_Bool *)((int)param + 2); + vif_info_tab[uVar16].active = _Var3; + if (_Var3 != false) { + _DAT_44b00200 = vif_info_tab[uVar16].txq_params[3]; + _DAT_44b00204 = vif_info_tab[uVar16].txq_params[3]; + _DAT_44b00208 = vif_info_tab[uVar16].txq_params[3]; + _DAT_44b0020c = vif_info_tab[uVar16].txq_params[3]; + mm_env_max_ampdu_duration_set(); + } + id = 0x1f; + } + else { + if (uVar16 < 0x1f) { + if (uVar16 == 0x1a) { + uVar16 = (uint)*(byte *)((int)param + 6); + vif_info_tab[0].txq_params[uVar16 * 0x176 + (uint)*(byte *)((int)param + 5)] = + *(uint32_t *)param; + if (vif_info_tab[uVar16].active != false) { + cVar1 = *(char *)((int)param + 5); + uVar13 = *(uint32_t *)param; + uVar12 = _DAT_44b00200; + uVar6 = uVar13; + uVar7 = _DAT_44b00208; + if (((cVar1 != '\x01') && (uVar12 = uVar13, uVar6 = _DAT_44b00204, cVar1 != '\0')) && + (uVar12 = _DAT_44b00200, uVar7 = uVar13, cVar1 != '\x02')) { + uVar7 = _DAT_44b00208; + _DAT_44b0020c = uVar13; + } + _DAT_44b00208 = uVar7; + _DAT_44b00204 = uVar6; + _DAT_44b00200 = uVar12; + mm_env_max_ampdu_duration_set(); + } + if (vif_info_tab[uVar16].type == '\0') { + ps_uapsd_set(vif_info_tab + uVar16,*(uint8_t *)((int)param + 5), + *(_Bool *)((int)param + 4)); + } + id = 0x1b; + } + else { + if (uVar16 == 0x1c) { + bVar2 = *(byte *)param; + if (((uint)bVar2 << 0xe & 0x3e0000) != 0) { + assert_err("(((uint32_t)abgnmode << 14) & ~((uint32_t)0x0001C000)) == 0","module", + 0x834); + } + _DAT_44b0004c = _DAT_44b0004c & 0xfffe3fff | (uint)bVar2 << 0xe; + id = 0x1d; + } + else { + if (uVar16 != 0x18) goto LAB_23047348; + memcpy(&vif_info_tab[*(byte *)((int)param + 6)].bssid,param,6); + if ((uint)vif_mgmt_env.vif_sta_cnt + (uint)vif_mgmt_env.vif_ap_cnt == 1) { + _DAT_44b00020 = *(undefined4 *)param; + _DAT_44b00024 = (uint)*(ushort *)((int)param + 4); + } + id = 0x19; + } + } + } + else { + if (uVar16 == 0x28) { + uVar10 = '\x05'; + if (*(char *)param != '\0') { + uVar10 = '\0'; + _DAT_44b00054 = _DAT_44b00054 | 0x80; + } + puVar11 = (uint8_t *)ke_msg_alloc(0x29,src_id,dest_id,3); + *puVar11 = *(uint8_t *)((int)param + 1); + uVar4 = *(uint8_t *)((int)param + 2); + puVar11[2] = uVar10; + puVar11[1] = uVar4; + goto LAB_230473a4; + } + if (uVar16 == 0x3b) { + chan_ctxt_update((mm_chan_ctxt_update_req *)param); + id = 0x3c; + } + else { + if (uVar16 != 0x20) goto LAB_23047348; + id = 0x21; + _DAT_44b000e8 = + (uint)*(byte *)param * (_DAT_44b000e4 & 0xff) * 0x100 | (uint)*(byte *)param; + } + } + } + goto LAB_2304748e; + } + if (uVar16 == 0xe) { + mm_env.rx_filter_umac = *(uint32_t *)param; + _DAT_44b00060 = mm_env.rx_filter_umac | mm_env.rx_filter_lmac_enable; + id = 0xf; + goto LAB_2304748e; + } + if (0xe < uVar16) { + if (uVar16 == 0x12) { + _DAT_44b00090 = (uint)*(byte *)param | _DAT_44b00090 & 0xffffff00 | 0x80000000; + id = 0x13; + } + else { + if (uVar16 != 0x14) { + if (uVar16 != 0x10) goto LAB_23047348; + puVar11 = (uint8_t *)ke_msg_alloc(0x11,src_id,dest_id,2); + if (*(uint8_t *)((int)param + 8) != '\0') { + phy_set_channel(*(uint8_t *)param,*(uint8_t *)((int)param + 1), + *(uint16_t *)((int)param + 2),*(uint16_t *)((int)param + 4), + *(uint16_t *)((int)param + 6),*(uint8_t *)((int)param + 8)); + } + goto LAB_230473a4; + } + uVar16 = (uint)*(byte *)((int)param + 2); + if (vif_info_tab[uVar16].type == '\0') { + sta_info_tab[vif_info_tab[uVar16].u[4]].bcn_int = (uint)*(ushort *)param << 10; + } + else { + vif_mgmt_set_ap_bcn_int(vif_info_tab + uVar16,*(ushort *)param); + } + id = 0x15; + } + goto LAB_2304748e; + } + if (uVar16 != 6) { + if (uVar16 != 8) { +LAB_23047348: + assert_err("0","module",0x7ae); + iVar8 = 2; + goto LAB_23047494; + } + if (*(byte *)param < 2) { + vif_mgmt_unregister(*(byte *)param); + } + if (vif_mgmt_env.used_list.first == (co_list_hdr *)0x0) { + hal_machw_monitor_mode(); + } + id = 9; + goto LAB_2304748e; + } + puVar11 = (uint8_t *)ke_msg_alloc(7,src_id,dest_id,2); + uVar10 = vif_mgmt_register((mac_addr_conflict38 *)((int)param + 1),*(uint8_t *)param, + *(_Bool *)((int)param + 7),puVar11 + 1); + *puVar11 = uVar10; +LAB_230473a4: + ke_msg_send(puVar11); + } + iVar8 = 0; +LAB_23047494: + uVar16 = (uint)mm_env.prev_hw_state; + if ((uVar16 << 4 & 0xffffff0f) != 0) { + assert_err("(((uint32_t)nextstate << 4) & ~((uint32_t)0x000000F0)) == 0","module",0x5b9); + } + _DAT_44b00038 = uVar16 << 4; + ke_state_set(dest_id,(ushort)mm_env.prev_mm_state); + return iVar8; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int bl60x_edca_get(int ac,uint8_t *aifs,uint8_t *cwmin,uint8_t *cwmax,uint16_t *txop) + +{ + uint uVar1; + uint uVar2; + + uVar1 = _DAT_44b00200; + uVar2 = _DAT_44b00204; + if (ac != 1) { + if (ac < 2) { + if (ac == 0) { + *txop = (uint16_t)(_DAT_44b00200 >> 0xc); + *cwmax = (byte)(uVar1 >> 8) & 0xf; + *cwmin = (byte)(uVar1 >> 4) & 0xf; + *aifs = (byte)uVar1 & 0xf; + return 0; + } + } + else { + uVar2 = _DAT_44b00208; + if ((ac == 2) || (uVar2 = _DAT_44b0020c, ac == 3)) goto LAB_2304786c; + } + return -1; + } +LAB_2304786c: + *txop = (uint16_t)(uVar2 >> 0xc); + *cwmax = (byte)(uVar2 >> 8) & 0xf; + *cwmin = (byte)(uVar2 >> 4) & 0xf; + *aifs = (byte)uVar2 & 0xf; + return 0; +} + + +/* +Unable to decompile 'mm_timer_hw_set' +Cause: Exception while decompiling 2304789c: Decompiler process died + +*/ + + +_Bool cmp_abs_time(co_list_hdr *timerA,co_list_hdr *timerB) + +{ + return SUB41((uint)((int)timerA[3].next - (int)timerB[3].next) >> 0x1f,0); +} + + + +void mm_timer_init(void) + +{ + co_list_init((co_list *)&mm_timer_env); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_timer_set(mm_timer_tag *timer,uint32_t value) + +{ + bool bVar1; + + if ((int)(value - _DAT_44b00120) < 0) { + puts("\r\n-------------------[FW] Timer is past due to flash operation. Try to fix\r\n"); + value = _DAT_44b00120 + 3000; + } + bVar1 = timer != (mm_timer_tag *)mm_timer_env.prog.first; + if (bVar1) { + co_list_extract((co_list *)&mm_timer_env,(co_list_hdr *)timer); + } + else { + co_list_pop_front((co_list *)&mm_timer_env); + } + timer->time = value; + co_list_insert((co_list *)&mm_timer_env,(co_list_hdr *)timer,cmp_abs_time); + if ((!bVar1) || (timer == (mm_timer_tag *)mm_timer_env.prog.first)) { + mm_timer_hw_set(mm_timer_env.prog.first); + } + if ((int)(value - _DAT_44b00120) < 0) { + ke_evt_set(0x8000000); + return; + } + return; +} + + + +void mm_timer_clear(mm_timer_tag *timer) + +{ + if (timer == (mm_timer_tag *)mm_timer_env.prog.first) { + co_list_pop_front((co_list *)&mm_timer_env); + mm_timer_hw_set(mm_timer_env.prog.first); + return; + } + co_list_extract((co_list *)&mm_timer_env,(co_list_hdr *)timer); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_timer_schedule(int dummy) + +{ + co_list_hdr *pcVar1; + + while( true ) { + ke_evt_clear(0x8000000); + pcVar1 = mm_timer_env.prog.first; + if (mm_timer_env.prog.first == (co_list_hdr *)0x0) { + mm_timer_hw_set(0); + return; + } + if ((-1 < (int)mm_timer_env.prog.first[3].next + (-0x32 - _DAT_44b00120)) && + (mm_timer_hw_set(mm_timer_env.prog.first), -1 < (int)((int)pcVar1[3].next - _DAT_44b00120))) + break; + co_list_pop_front((co_list *)&mm_timer_env); + if (pcVar1[1].next == (co_list_hdr *)0x0) { + assert_err("timer->cb","module",0xde); + } + (*(code *)pcVar1[1].next)(pcVar1[2].next,pcVar1[1].next); + } + return; +} + + + +// WARNING: Type propagation algorithm not settling +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ps_uapsd_timer_handle(void *env) + +{ + vif_info_tag *p_vif_entry; + _Bool _Var1; + undefined3 extraout_var; + int iVar2; + + iVar2 = 0; + p_vif_entry = (vif_info_tag *)vif_mgmt_env.used_list.first; + while (p_vif_entry != (vif_info_tag *)0x0) { + if (((p_vif_entry->type == '\0') && (p_vif_entry->active != false)) && + (*(char *)((int)p_vif_entry->u + 0xc) != '\0')) { + _Var1 = chan_is_on_channel(p_vif_entry); + __Var1 = CONCAT31(extraout_var,_Var1); + if ((__Var1 != 0) && + (iVar2 = __Var1, + (int)(((ps_env.uapsd_timeout >> 1) - _DAT_44b00120) + *(int *)((int)p_vif_entry->u + 8)) < + 0)) { + p_vif_entry->prevent_sleep = p_vif_entry->prevent_sleep | 8; + txl_frame_send_qosnull_frame + (*(uint8_t *)((int)p_vif_entry->u + 4),7,(cfm_func_ptr *)0x0,(void *)0x0); + *(int *)((int)p_vif_entry->u + 8) = _DAT_44b00120; + } + } + p_vif_entry = *(vif_info_tag **)&p_vif_entry->list_hdr; + } + if (iVar2 != 0) { + mm_timer_set(&ps_env.uapsd_timer,_DAT_44b00120 + ps_env.uapsd_timeout); + return; + } + ps_env.uapsd_tmr_on = false; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_pwr_mgt_setf(uint8_t pwrmgt) + +{ + undefined3 in_register_00002029; + + _DAT_44b0004c = CONCAT31(in_register_00002029,pwrmgt) << 2 | _DAT_44b0004c & 0xfffffffb; + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void ps_dpsm_update(_Bool pause) + +{ + vif_info_tag *p_vif_entry; + _Bool _Var1; + undefined3 in_register_00002029; + undefined3 extraout_var; + code *UNRECOVERED_JUMPTABLE; + + if (CONCAT31(in_register_00002029,pause) == 0) { + ps_env.dpsm_state = ps_env.dpsm_state | 4; + ps_env.prevent_sleep = ps_env.prevent_sleep & 0xfffffff7; + UNRECOVERED_JUMPTABLE = ps_enable_cfm; + } + else { + ps_env.dpsm_state = ps_env.dpsm_state | 2; + ps_env.prevent_sleep = ps_env.prevent_sleep | 8; + UNRECOVERED_JUMPTABLE = ps_disable_cfm; + } + blmac_pwr_mgt_setf(pause ^ 1); + ps_env.cfm_cnt = '\0'; + p_vif_entry = (vif_info_tag *)vif_mgmt_env.used_list.first; + while (p_vif_entry != (vif_info_tag *)0x0) { + if (((p_vif_entry->type == '\0') && (p_vif_entry->active != false)) && + (_Var1 = chan_is_on_channel(p_vif_entry), CONCAT31(extraout_var,_Var1) != 0)) { + *(undefined *)((int)p_vif_entry->u + 3) = 0; + ps_env.cfm_cnt = ps_env.cfm_cnt + '\x01'; + txl_frame_send_null_frame + (*(uint8_t *)((int)p_vif_entry->u + 4),UNRECOVERED_JUMPTABLE,p_vif_entry); + } + p_vif_entry = *(vif_info_tag **)&p_vif_entry->list_hdr; + } + if (ps_env.cfm_cnt == '\0') { + // WARNING: Could not recover jumptable at 0x23047ba6. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)((void *)0x0,0x800000); + return; + } + return; +} + + + +uint8_t ps_send_pspoll(vif_info_tag *vif_entry) + +{ + ushort uVar1; + txl_frame_desc_tag *frame; + tx_hw_desc *ptVar2; + txl_buffer_tag *ptVar3; + uint uVar4; + char acStack40 [4]; + phy_channel_info phy_info; + + uVar4 = (uint)vif_entry->u[4]; + phy_get_channel((phy_channel_info *)acStack40,'\0'); + frame = txl_frame_get((uint)(acStack40[0] != '\0'),0x10); + if (frame != (txl_frame_desc_tag *)0x0) { + tpc_update_frame_tx_power(vif_entry,frame); + ptVar3 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar3[1].length = 0xa4; + *(undefined *)((int)&ptVar3[1].length + 1) = 0; + uVar1 = sta_info_tab[uVar4].aid; + *(undefined *)((int)&ptVar3[1].length + 2) = (char)uVar1; + *(byte *)((int)&ptVar3[1].length + 3) = (byte)((uint)uVar1 >> 8) | 0xc0; + memcpy(&ptVar3[1].lenheader,&sta_info_tab[uVar4].mac_addr,6); + memcpy((void *)((int)&ptVar3[1].lenpad + 2),&vif_entry->mac_addr,6); + ptVar2 = (frame->txdesc).lmac.hw_desc; + (ptVar2->thd).macctrlinfo2 = (ptVar2->thd).macctrlinfo2 | 0x10000053; + (frame->txdesc).host.vif_idx = sta_info_tab[uVar4].inst_nbr; + (frame->txdesc).host.staid = sta_info_tab[uVar4].staid; + txl_frame_push(frame,'\x03'); + } + return (uint8_t)(frame == (txl_frame_desc_tag *)0x0); +} + + + +void ps_init(void) + +{ + memset(&ps_env,0,0x28); + ps_env.uapsd_timer.cb = ps_uapsd_timer_handle; + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void ps_set_mode(uint8_t mode,ke_task_id_t taskid) + +{ + vif_info_tag *p_vif_entry; + _Bool _Var1; + undefined3 in_register_00002029; + undefined3 extraout_var; + code *UNRECOVERED_JUMPTABLE; + + ps_env.taskid = taskid; + if (((ps_env.dpsm_state & 1) == 0) || ((ps_env.dpsm_state & 6) == 0)) { + if (CONCAT31(in_register_00002029,mode) == 0) { + ps_env.dpsm_state = '\0'; + UNRECOVERED_JUMPTABLE = ps_disable_cfm; + blmac_pwr_mgt_setf(mode); + } + else { + if (CONCAT31(in_register_00002029,mode) == 2) { + ps_env.dpsm_state = ps_env.dpsm_state | 1; + } + blmac_pwr_mgt_setf('\x01'); + UNRECOVERED_JUMPTABLE = ps_enable_cfm; + } + ps_env.cfm_cnt = '\0'; + ps_env.uapsd_on = false; + p_vif_entry = (vif_info_tag *)vif_mgmt_env.used_list.first; + while (p_vif_entry != (vif_info_tag *)0x0) { + if (((p_vif_entry->type == '\0') && (p_vif_entry->active != false)) && + (_Var1 = chan_is_on_channel(p_vif_entry), CONCAT31(extraout_var,_Var1) != 0)) { + *(undefined *)((int)p_vif_entry->u + 3) = 0; + ps_env.cfm_cnt = ps_env.cfm_cnt + '\x01'; + if (*(char *)((int)p_vif_entry->u + 0xc) != '\0') { + ps_env.uapsd_on = true; + } + txl_frame_send_null_frame + (*(uint8_t *)((int)p_vif_entry->u + 4),UNRECOVERED_JUMPTABLE,p_vif_entry); + } + p_vif_entry = *(vif_info_tag **)&p_vif_entry->list_hdr; + } + if (ps_env.cfm_cnt == '\0') { + // WARNING: Could not recover jumptable at 0x23047d74. Too many branches + // WARNING: Treating indirect jump as call + (*UNRECOVERED_JUMPTABLE)((void *)0x0,0x800000); + return; + } + } + else { + ps_env.dpsm_state = ps_env.dpsm_state | 0x10; + ps_env.next_mode = mode; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ps_enable_cfm(void *env,uint32_t status) + +{ + co_list_hdr cVar1; + char cVar2; + + if (-1 < (int)(status << 8)) { + cVar2 = *(char *)((int)env + 0x5f) + '\x01'; + *(char *)((int)env + 0x5f) = cVar2; + if (cVar2 != '\x03') { + txl_frame_send_null_frame(*(uint8_t *)((int)env + 0x60),ps_enable_cfm,env); + return; + } + mm_send_connection_loss_ind((vif_info_tag *)env); + } + cVar1 = (co_list_hdr)vif_mgmt_env.used_list.first; + if ((ps_env.cfm_cnt == '\0') || (ps_env.cfm_cnt = ps_env.cfm_cnt + -1, ps_env.cfm_cnt == '\0')) { + if (ps_env.uapsd_on != false) { + mm_timer_set(&ps_env.uapsd_timer,_DAT_44b00120 + ps_env.uapsd_timeout); + ps_env.uapsd_tmr_on = true; + while (cVar1 != (co_list_hdr)0x0) { + if (((*(char *)((int)cVar1 + 0x56) == '\0') && + (*(char *)&((co_list_hdr *)((int)cVar1 + 0x58))->next != '\0')) && + (*(char *)&((co_list_hdr *)((int)cVar1 + 0x68))->next != '\0')) { + ((co_list_hdr *)((int)cVar1 + 4))->next = + (co_list_hdr *)((uint)((co_list_hdr *)((int)cVar1 + 4))->next & 0xfffffff7); + } + cVar1 = *(co_list_hdr *)cVar1; + } + } + if ((ps_env.dpsm_state & 5) == 5) { + ps_env.dpsm_state = ps_env.dpsm_state & 0xf3; + } + else { + ps_env.ps_on = true; + ke_msg_send_basic(0x32,ps_env.taskid,0); + } + if ((ps_env.dpsm_state & 0x10) != 0) { + ps_env.dpsm_state = ps_env.dpsm_state & 0xef; + ps_set_mode(ps_env.next_mode,ps_env.taskid); + return; + } + } + return; +} + + + +void ps_disable_cfm(void *env,uint32_t status) + +{ + char cVar1; + + if (-1 < (int)(status << 8)) { + cVar1 = *(char *)((int)env + 0x5f) + '\x01'; + *(char *)((int)env + 0x5f) = cVar1; + if (cVar1 != '\x03') { + txl_frame_send_null_frame(*(uint8_t *)((int)env + 0x60),ps_disable_cfm,env); + return; + } + mm_send_connection_loss_ind((vif_info_tag *)env); + } + if ((ps_env.cfm_cnt == '\0') || (ps_env.cfm_cnt = ps_env.cfm_cnt + -1, ps_env.cfm_cnt == '\0')) { + mm_timer_clear(&ps_env.uapsd_timer); + ps_env.uapsd_tmr_on = false; + if ((ps_env.dpsm_state & 3) == 3) { + ps_env.dpsm_state = ps_env.dpsm_state & 0xfd | 8; + } + else { + ps_env.ps_on = false; + ke_msg_send_basic(0x32,ps_env.taskid,0); + } + if ((ps_env.dpsm_state & 0x10) != 0) { + ps_env.dpsm_state = ps_env.dpsm_state & 0xef; + ps_set_mode(ps_env.next_mode,ps_env.taskid); + return; + } + } + return; +} + + + +uint8_t ps_polling_frame(vif_info_tag *vif_entry) + +{ + ushort uVar1; + txl_frame_desc_tag *frame; + tx_hw_desc *ptVar2; + txl_buffer_tag *ptVar3; + uint uVar4; + char acStack40 [16]; + + uVar4 = (uint)vif_entry->u[4]; + phy_get_channel((phy_channel_info *)acStack40,'\0'); + frame = txl_frame_get((uint)(acStack40[0] != '\0'),0x10); + if (frame != (txl_frame_desc_tag *)0x0) { + tpc_update_frame_tx_power(vif_entry,frame); + ptVar3 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar3[1].length = 0xa4; + *(undefined *)((int)&ptVar3[1].length + 1) = 0; + uVar1 = sta_info_tab[uVar4].aid; + *(undefined *)((int)&ptVar3[1].length + 2) = (char)uVar1; + *(byte *)((int)&ptVar3[1].length + 3) = (byte)((uint)uVar1 >> 8) | 0xc0; + memcpy(&ptVar3[1].lenheader,&sta_info_tab[uVar4].mac_addr,6); + memcpy((void *)((int)&ptVar3[1].lenpad + 2),&vif_entry->mac_addr,6); + ptVar2 = (frame->txdesc).lmac.hw_desc; + (ptVar2->thd).macctrlinfo2 = (ptVar2->thd).macctrlinfo2 | 0x10000053; + (frame->txdesc).host.vif_idx = sta_info_tab[uVar4].inst_nbr; + (frame->txdesc).host.staid = sta_info_tab[uVar4].staid; + txl_frame_push(frame,'\x03'); + } + return (uint8_t)(frame == (txl_frame_desc_tag *)0x0); +} + + + +void ps_check_beacon(int param_1,vif_info_tag *param_2) + +{ + ushort uVar1; + _Bool _Var2; + uint8_t uVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint uVar4; + uint uVar5; + uint32_t uVar6; + byte bVar7; + + _Var2 = ps_env.ps_on; + uVar1 = sta_info_tab[param_2->u[4]].aid; + uVar5 = param_2->prevent_sleep; + uVar4 = uVar5 & 0xfffffffe; + param_2->prevent_sleep = uVar4; + if (((_Var2 == false) || ((ps_env.dpsm_state & 8) != 0)) || (param_1 == 0)) { + return; + } + if (param_2->u[2] == 0) { + if ((*(byte *)(param_1 + 4) & 1) == 0) { + param_2->prevent_sleep = uVar5 & 0xfffffffc; + } + else { + param_2->prevent_sleep = uVar4 | 2; + } + } + uVar5 = (uint)(uVar1 >> 3); + uVar4 = (uint)*(byte *)(param_1 + 4) & 0xfe; + bVar7 = param_2->u[0xc] & 0xf; + if (((uVar4 <= uVar5) && (uVar5 <= ((uint)*(byte *)(param_1 + 1) - 4) + uVar4)) && + (((uint)*(byte *)(((uVar5 + param_1) - uVar4) + 5) & 1 << ((uint)uVar1 & 7)) != 0)) { + if (bVar7 == 0xf) { + uVar3 = txl_frame_send_qosnull_frame(param_2->u[4],7,(cfm_func_ptr *)0x0,(void *)0x0); + if (CONCAT31(extraout_var,uVar3) != 0) { + return; + } + uVar6 = param_2->prevent_sleep | 8; + } + else { + uVar3 = ps_send_pspoll(param_2); + if (CONCAT31(extraout_var_00,uVar3) != 0) { + return; + } + uVar6 = param_2->prevent_sleep | 4; + } + param_2->prevent_sleep = uVar6; + return; + } + if (bVar7 == 0xf) { + uVar6 = param_2->prevent_sleep & 0xfffffff7; + } + else { + uVar6 = param_2->prevent_sleep & 0xfffffffb; + } + param_2->prevent_sleep = uVar6; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ps_check_frame(uint8_t *frame,uint32_t statinfo,vif_info_tag *vif_entry) + +{ + byte bVar1; + uint uVar2; + uint8_t uVar3; + undefined3 extraout_var; + uint32_t uVar4; + _Bool _Var5; + + _Var5 = ps_env.uapsd_on; + if (ps_env.ps_on == false) { + return; + } + uVar2 = (uint)*(ushort *)frame; + if ((frame[4] & 1) != 0) { + if (((int)(uVar2 << 0x12) < 0) && (vif_entry->u[2] == 0)) { + return; + } + uVar4 = vif_entry->prevent_sleep & 0xfffffffd; +LAB_230480b4: + vif_entry->prevent_sleep = uVar4; + return; + } + if ((statinfo & 0x200) != 0) { + return; + } + if (ps_env.uapsd_on != false) { + if ((uVar2 & 0x88) == 0x88) { + if ((uVar2 & 0x300) == 0x300) { + bVar1 = frame[0x1e]; + } + else { + bVar1 = frame[0x18]; + } + if ((vif_entry->u[0xc] >> ((uint)"\x01"[(uint)bVar1 & 7] & 0x1f) & 1) != 0) { + *(undefined4 *)(vif_entry->u + 8) = _DAT_44b00120; + if ((bVar1 & 0x10) == 0) { + return; + } + uVar4 = vif_entry->prevent_sleep & 0xfffffff7; + goto LAB_230480b4; + } + } + else { + if (((*(ushort *)frame & 0xc) == 0) && ((vif_entry->u[0xc] & 8) != 0)) { + *(undefined4 *)(vif_entry->u + 8) = _DAT_44b00120; + goto LAB_2304814e; + } + } + _Var5 = false; + } +LAB_2304814e: + td_pck_ps_ind(vif_entry->index,true); + if ((_Var5 == false) && + ((-1 < (int)(uVar2 << 0x12) || + (((ps_env.dpsm_state & 8) == 0 && + (uVar3 = ps_send_pspoll(vif_entry), CONCAT31(extraout_var,uVar3) != 0)))))) { + vif_entry->prevent_sleep = vif_entry->prevent_sleep & 0xfffffffb; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ps_check_tx_frame(uint8_t staid,uint8_t tid) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + uint uVar1; + + if ((((ps_env.ps_on != false) && (CONCAT31(in_register_00002029,staid) != 0xff)) && + (CONCAT31(in_register_0000202d,tid) != 0xff)) && + ((uVar1 = (uint)sta_info_tab[CONCAT31(in_register_00002029,staid)].inst_nbr, + vif_info_tab[uVar1].type == '\0' && (vif_info_tab[uVar1].active != false)))) { + if ((vif_info_tab[uVar1].u[0xc] >> ((uint)"\x01"[CONCAT31(in_register_0000202d,tid)] & 0x1f) & 1 + ) != 0) { + vif_info_tab[uVar1].prevent_sleep = vif_info_tab[uVar1].prevent_sleep | 8; + *(undefined4 *)(vif_info_tab[uVar1].u + 8) = _DAT_44b00120; + return; + } + td_pck_ps_ind(vif_info_tab[uVar1].index,false); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ps_uapsd_set(vif_info_tag *vif_entry,uint8_t hw_queue,_Bool uapsd) + +{ + byte bVar1; + undefined3 in_register_00002031; + + bVar1 = (byte)(1 << ((uint)hw_queue & 0x1f)); + if (CONCAT31(in_register_00002031,uapsd) == 0) { + vif_entry->u[0xc] = vif_entry->u[0xc] & ~bVar1; + } + else { + vif_entry->u[0xc] = vif_entry->u[0xc] | bVar1; + if ((ps_env.ps_on != false) && (ps_env.uapsd_tmr_on == false)) { + ps_env.uapsd_on = true; + mm_timer_set(&ps_env.uapsd_timer,_DAT_44b00120 + ps_env.uapsd_timeout); + ps_env.uapsd_tmr_on = true; + } + } + return; +} + + + +void ps_traffic_status_update(uint8_t vif_index,uint8_t new_status) + +{ + _Bool pause; + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + char cVar1; + co_list_hdr cVar2; + + if (((ps_env.ps_on != false) && ((ps_env.dpsm_state & 1) != 0)) && ((ps_env.dpsm_state & 6) == 0)) + { + cVar2 = (co_list_hdr)vif_mgmt_env.used_list.first; + if (CONCAT31(in_register_0000202d,new_status) == 0) { + while (cVar2 != (co_list_hdr)0x0) { + if ((((uint)*(byte *)((int)cVar2 + 0x57) != CONCAT31(in_register_00002029,vif_index)) && + (cVar1 = *(char *)&((co_list_hdr *)((int)cVar2 + 0x58))->next, cVar1 != '\0')) && + ((*(char *)((int)cVar2 + 0x56) == '\0' && + ((td_env[(uint)*(byte *)((int)cVar2 + 0x57)].status & 0xc) != 0)))) goto LAB_230482ae; + cVar2 = *(co_list_hdr *)cVar2; + } + cVar1 = '\0'; +LAB_230482ae: + if (cVar1 == '\0') { + if ((ps_env.dpsm_state & 8) == 0) { + return; + } + pause = false; + goto LAB_230482b6; + } + } + pause = true; + if ((ps_env.dpsm_state & 8) == 0) { +LAB_230482b6: + ps_dpsm_update(pause); + return; + } + } + return; +} + + + +void mm_ps_change_ind(uint8_t sta_idx,uint8_t ps_state) + +{ + undefined3 in_register_00002029; + uint8_t *puVar1; + + puVar1 = (uint8_t *)ke_msg_alloc(0x49,0xd,0,2); + sta_info_tab[CONCAT31(in_register_00002029,sta_idx)].ps_state = ps_state; + *puVar1 = sta_idx; + puVar1[1] = ps_state; + ke_msg_send(); + return; +} + + + +void rxl_mpdu_transfer(rx_swdesc *swdesc) + +{ + rx_pbd *prVar1; + rx_pbd *prVar2; + rx_pbd *prVar3; + rx_dmadesc *prVar4; + + prVar4 = swdesc->dma_hdrdesc; + prVar1 = (rx_pbd *)(prVar4->hd).first_pbd_ptr; + phy_get_channel(&prVar4->phy_info,'\0'); + prVar4->payl_offset = mac_payload_offset; + swdesc->pbd_count = '\0'; + prVar3 = (rx_pbd *)0x0; + do { + prVar2 = prVar1; + if ((prVar2->bufstatinfo & 1) != 0) { + swdesc->spare_pbd = prVar2; + swdesc->last_pbd = prVar3; + return; + } + prVar1 = (rx_pbd *)prVar2->next; + swdesc->pbd_count = swdesc->pbd_count + '\x01'; + prVar3 = prVar2; + } while (prVar1 != (rx_pbd *)0x0); + assert_rec("pd != NULL","module",0xb4); + return; +} + + + +void rxl_init(void) + +{ + rxl_hwdesc_init(1); + rx_swdesc_init(); + co_list_init((co_list *)&rxl_cntrl_env); + rxu_cntrl_init(); + return; +} + + + +void rxl_cntrl_dump(void) + +{ + uint32_t uVar1; + co_list_hdr cVar2; + + uVar1 = co_list_cnt((co_list *)&rxl_cntrl_env); + cVar2 = (co_list_hdr)rxl_cntrl_env.ready.first; + if (uVar1 != 0) { + while (cVar2 != (co_list_hdr)0x0) { + cVar2 = *(co_list_hdr *)cVar2; + } + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxl_timer_int_handler(void) + +{ + rx_hd *prVar1; + rx_dmadesc *desc; + char *condition; + rx_swdesc *list_hdr; + int line; + uint32_t uVar2; + + _DAT_44b0807c = 0xa0000; + do { + while( true ) { + if ((rxl_cntrl_env.first == (rx_dmadesc *)0x0) || + (-1 < (int)(((rxl_cntrl_env.first)->hd).statinfo << 0x11))) { + if (rxl_cntrl_env.ready.first != (co_list_hdr *)0x0) { + ke_evt_set(0x40000); + return; + } + return; + } + list_hdr = ((rxl_cntrl_env.first)->hd).swdesc; + prVar1 = &(rxl_cntrl_env.first)->hd; + desc = list_hdr->dma_hdrdesc; + rxl_cntrl_env.first = (rx_dmadesc *)((rxl_cntrl_env.first)->hd).next; + list_hdr->pd = (rx_payloaddesc *)prVar1->first_pbd_ptr; + uVar2 = (desc->hd).first_pbd_ptr; + if ((desc->hd).frmlen == 0) break; + if (uVar2 == 0) { + line = 0xd8; + condition = "pd != NULL"; +LAB_2304844e: + assert_rec(condition,"module",line); + } + else { + co_list_push_back((co_list *)&rxl_cntrl_env,(co_list_hdr *)list_hdr); + } + } + if (uVar2 != 0) { + line = 0xfa; + condition = "dma_hdrdesc->hd.first_pbd_ptr == 0"; + goto LAB_2304844e; + } + list_hdr->spare_pbd = (rx_pbd *)0x0; + list_hdr->last_pbd = (rx_pbd *)0x0; + rxl_hd_append(desc); + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxl_timeout_int_handler(void) + +{ + _DAT_44b0808c = _DAT_44b0808c & 0xffffffbf; + return; +} + + + +void rxl_dma_int_handler(void) + +{ + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxl_dma_evt(int dummy) + +{ + ke_evt_clear(0x100000); + _DAT_44a00020 = 0x20; + return; +} + + + +void rxl_frame_release(rx_swdesc *swdesc) + +{ + rxl_pd_append((rx_pbd *)(swdesc->dma_hdrdesc->hd).first_pbd_ptr,swdesc->last_pbd,swdesc->spare_pbd + ); + rxl_hd_append(swdesc->dma_hdrdesc); + return; +} + + + +void rxl_mpdu_free(rx_swdesc *swdesc) + +{ + ushort uVar1; + rx_pbd *prVar2; + rx_pbd *prVar3; + rx_pbd *prVar4; + + prVar2 = (rx_pbd *)(swdesc->dma_hdrdesc->hd).first_pbd_ptr; + vTaskEnterCritical(); + swdesc->use_in_tcpip = '\0'; + swdesc->dma_hdrdesc->use_in_tcpip = 0; + prVar4 = (rx_pbd *)0x0; + do { + prVar3 = prVar2; + uVar1 = prVar3->bufstatinfo; + prVar3[1].upattern = 0; + if ((uVar1 & 1) != 0) { + swdesc->spare_pbd = prVar3; + swdesc->last_pbd = prVar4; + rxl_frame_release(swdesc); + vTaskExitCritical(); + return; + } + prVar2 = (rx_pbd *)prVar3->next; + prVar4 = prVar3; + } while ((rx_pbd *)prVar3->next != (rx_pbd *)0x0); + assert_rec("pd != NULL","module",0x397); + return; +} + + +/* +Unable to decompile 'rxl_cntrl_evt' +Cause: Exception while decompiling 23048552: Decompiler process died + +*/ + + +void bl60x_firmwre_mpdu_free(void *swdesc_ptr) + +{ + rx_swdesc *swdesc; + + vTaskEnterCritical(); + rxl_cntrl_env.packet_stack_cnt = + rxl_cntrl_env.packet_stack_cnt - *(byte *)((int)swdesc_ptr + 0x1d); + vTaskExitCritical(); + rxl_mpdu_free((rx_swdesc *)swdesc_ptr); + return; +} + + + +void rxl_reset(void) + +{ + rxl_hwdesc_init(0); + co_list_init((co_list *)&rxl_cntrl_env); + co_list_init((co_list *)&swdesc); + return; +} + + + +void rxl_hwdesc_dump(void) + +{ + rx_dmadesc *prVar1; + rx_payloaddesc *prVar2; + int iVar3; + int iVar4; + uint32_t uVar5; + + puts("---------- rxl_hwdesc_dump -------\r\n"); + printf("rx_dma_hdrdesc: %d\r\n",0xd); + iVar3 = 0; + prVar1 = rx_dma_hdrdesc; + do { + printf(" [%2d]@%08lx: upatternrx %08lx next %08lx first_pbd_ptr %08lx, swdesc %p\r\n",iVar3, + prVar1,(prVar1->hd).upatternrx,(prVar1->hd).next,(prVar1->hd).first_pbd_ptr, + (prVar1->hd).swdesc); + iVar3 = iVar3 + 1; + printf( + " datastartptr %08lx dataendptr %08lx, headerctrlinfo %08lx frmlen %4u ampdu_stat_info %04x\r\n" + ,(prVar1->hd).datastartptr,(prVar1->hd).dataendptr,(prVar1->hd).headerctrlinfo, + (uint)(prVar1->hd).frmlen,(uint)(prVar1->hd).ampdu_stat_info); + printf( + " tsflo %08lx tsfhi %08lx recvec1b %08lx recvec1c %08lx recvec1d %08lx recvec2a %08lx recvec2b %08lx statinfo %08lx\r\n" + ,(prVar1->hd).tsflo,(prVar1->hd).tsfhi,(prVar1->hd).recvec1b,(prVar1->hd).recvec1c, + (prVar1->hd).recvec1d,(prVar1->hd).recvec2a,(prVar1->hd).recvec2b); + prVar1 = prVar1 + 1; + } while (iVar3 != 0xd); + printf("rx_payload_desc: %d\r\n",0xd); + iVar3 = 0; + prVar2 = rx_payload_desc; + do { + uVar5 = (prVar2->pbd).dataendptr; + iVar4 = 0; + if (uVar5 != 0) { + iVar4 = (uVar5 + 1) - (prVar2->pbd).datastartptr; + } + iVar3 = iVar3 + 1; + printf( + " [%2d]@%08lx %3lu Bytes: upatternrx %08lx next %08lx datastartptr %08lx dataendptr %08lx bufstatinfo %04x reserved %04X\r\n" + ,prVar2,iVar4,(prVar2->pbd).upattern,(prVar2->pbd).next); + prVar2 = prVar2 + 1; + } while (iVar3 != 0xd); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxl_hwdesc_init(int init) + +{ + rx_dmadesc *prVar1; + rx_dmadesc *prVar2; + txl_buffer_control *ptVar3; + txl_buffer_control *ptVar4; + txl_buffer_control *ptVar5; + int iVar6; + uint32_t *puVar7; + int iVar8; + txl_buffer_control *ptVar9; + rx_dmadesc *prVar10; + rx_dmadesc *prVar11; + rx_dmadesc *prVar12; + rx_dmadesc *prVar13; + txl_buffer_control *ptVar14; + txl_buffer_control *ptVar15; + + vTaskEnterCritical(); + prVar13 = (rx_dmadesc *)0x0; + iVar6 = 0; + iVar8 = 0; + prVar1 = (rx_dmadesc *)0x0; + prVar10 = rx_dma_hdrdesc; + prVar11 = (rx_dmadesc *)0x0; + do { + prVar2 = prVar10; + prVar10 = prVar2 + 1; + prVar12 = prVar11; + if ((init == 0) && (prVar2->use_in_tcpip == 1)) { + prVar2 = prVar1; + if (prVar1 != (rx_dmadesc *)0x0) { + (prVar1->hd).next = 0; + } + } + else { + if (prVar1 != (rx_dmadesc *)0x0) { + *(rx_dmadesc **)&(prVar1->hd).next = prVar2; + } + (prVar2->hd).datastartptr = 0; + (prVar2->hd).dataendptr = 0; + (prVar2->hd).upatternrx = 0xbaadf00d; + (prVar2->hd).statinfo = 0; + (prVar2->hd).headerctrlinfo = 0; + *(rx_dmadesc **)&(prVar2->hd).next = prVar10; + (prVar2->hd).first_pbd_ptr = 0; + (prVar2->hd).swdesc = rx_swdesc_tab + iVar8; + (prVar2->hd).frmlen = 0; + prVar12 = prVar2; + if ((iVar6 != 0) && (prVar12 = prVar11, iVar6 == 1)) { + prVar13 = prVar2; + } + iVar6 = iVar6 + 1; + } + iVar8 = iVar8 + 1; + prVar1 = prVar2; + prVar11 = prVar12; + } while (iVar8 != 0xd); + if (iVar6 < 4) { + printf("No enough DESC %d(%d)\r\n",0xd); + } + if (prVar2 != (rx_dmadesc *)0x0) { + (prVar2->hd).next = 0; + } + _DAT_44b08180 = 0x4000000; + puVar7 = rx_payload_desc_buffer; + ptVar9 = (txl_buffer_control *)0x0; + iVar6 = 0; + ptVar3 = (txl_buffer_control *)0x0; + ptVar5 = (txl_buffer_control *)rx_payload_desc; + ptVar14 = (txl_buffer_control *)0x0; + _DAT_44b081b8 = prVar13; + do { + ptVar4 = ptVar5; + ptVar5 = (txl_buffer_control *)&ptVar4->mac_control_info; + ptVar15 = ptVar14; + if ((init == 0) && (*(int *)(ptVar4->field_0 + 0x14) == 1)) { + ptVar4 = ptVar3; + if (ptVar3 != (txl_buffer_control *)0x0) { + *(undefined4 *)ptVar3->field_0 = 0; + } + } + else { + if (ptVar3 != (txl_buffer_control *)0x0) { + *(txl_buffer_control **)ptVar3->field_0 = ptVar4; + } + *(txl_buffer_control **)ptVar4->field_0 = ptVar5; + *(undefined4 *)ptVar4->field_0 = 0xc0dedbad; + *(undefined2 *)ptVar4->field_0 = 0; + *(uint32_t **)ptVar4->field_0 = puVar7; + *(int *)ptVar4->field_0 = (int)puVar7 + 0x34f; + *(uint32_t **)(ptVar4->field_0 + 0x18) = puVar7; + ptVar15 = ptVar4; + if ((iVar6 != 0) && (ptVar15 = ptVar14, iVar6 == 1)) { + ptVar9 = ptVar4; + } + iVar6 = iVar6 + 1; + } + puVar7 = puVar7 + 0xd4; + ptVar3 = ptVar4; + ptVar14 = ptVar15; + } while (ptVar5 != txl_buffer_control_desc_bcmc); + if (iVar6 < 4) { + printf("No enough PBD DESC, %d(%d)\r\n",0xd); + } + *(undefined4 *)ptVar4->field_0 = 0; + _DAT_44b08180 = 0x8000000; + _DAT_44b081bc = ptVar9; + if ((((prVar12 == (rx_dmadesc *)0x0) || (prVar13 == (rx_dmadesc *)0x0)) || + (prVar2 == (rx_dmadesc *)0x0)) || + ((ptVar15 == (txl_buffer_control *)0x0 || (ptVar9 == (txl_buffer_control *)0x0)))) { + printf("%p:%p%p vs %p:%p:%p\r\n",prVar12,prVar13,prVar2,ptVar15,ptVar4); + } + rxl_cntrl_env.first = prVar13; + rxl_cntrl_env.last = prVar2; + rxl_cntrl_env.free = prVar12; + rx_hwdesc_env.last = (rx_pbd *)ptVar4; + rx_hwdesc_env.free = (rx_pbd *)ptVar15; + vTaskExitCritical(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxl_hd_append(rx_dmadesc *desc) + +{ + rx_dmadesc *prVar1; + + if (desc == (rx_dmadesc *)0x0) { + assert_err("desc != NULL","module",0xf9); + } + prVar1 = desc; + if (rxl_cntrl_env.free != _DAT_44b08548) { + prVar1 = rxl_cntrl_env.free; + rxl_cntrl_env.free = desc; + } + (prVar1->hd).next = 0; + (prVar1->hd).first_pbd_ptr = 0; + (prVar1->hd).statinfo = 0; + (prVar1->hd).frmlen = 0; + *(rx_dmadesc **)&((rxl_cntrl_env.last)->hd).next = prVar1; + if (rxl_cntrl_env.first == (rx_dmadesc *)0x0) { + rxl_cntrl_env.first = prVar1; + } + rxl_cntrl_env.last = prVar1; + _DAT_44b08180 = 0x1000000; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxl_pd_append(rx_pbd *first,rx_pbd *last,rx_pbd *spare) + +{ + rx_pbd **pprVar1; + rx_pbd *prVar2; + rx_pbd *prVar3; + rx_pbd *prVar4; + + if (spare == (rx_pbd *)0x0) { + assert_err("spare != NULL","module",0x128); + } + prVar4 = rx_hwdesc_env.free; + if (rx_hwdesc_env.free == _DAT_44b0854c) { + prVar4 = first; + if (last == (rx_pbd *)0x0) { + prVar4 = spare; + } + spare->bufstatinfo = 0; + } + else { + prVar2 = rx_hwdesc_env.free; + prVar3 = spare; + if (last != (rx_pbd *)0x0) { + pprVar1 = (rx_pbd **)&(rx_hwdesc_env.free)->next; + rx_hwdesc_env.free = spare; + *pprVar1 = first; + prVar2 = last; + prVar3 = rx_hwdesc_env.free; + } + rx_hwdesc_env.free = prVar3; + spare = prVar2; + prVar4->bufstatinfo = 0; + } + spare->next = 0; + *(rx_pbd **)&(rx_hwdesc_env.last)->next = prVar4; + rx_hwdesc_env.last = spare; + _DAT_44b08180 = 0x2000000; + return; +} + + + +void sta_mgmt_entry_init(sta_info_tag *sta_entry) + +{ + txdesc *txdesc; + uint16_t *puVar1; + + while ((sta_entry->tx_desc_post).first != (co_list_hdr *)0x0) { + txdesc = (txdesc *)co_list_pop_front(&sta_entry->tx_desc_post); + txl_frame_release(txdesc,true); + } + memset(sta_entry,0,0x1b0); + puVar1 = (uint16_t *)&sta_entry->ba_info[0].bam_idx_rx; + do { + *(uint8_t *)puVar1 = '\x02'; + *(uint8_t *)((int)puVar1 + 1) = '\x02'; + puVar1 = puVar1 + 6; + } while (puVar1 != sta_entry->rx_qos_last_seqcntl + 3); + sta_entry->inst_nbr = -1; + return; +} + + + +void sta_mgmt_init(void) + +{ + sta_info_tag *sta_entry; + sta_info_tag *psVar1; + + co_list_init((co_list *)&sta_info_env); + sta_entry = sta_info_tab; + do { + sta_mgmt_entry_init(sta_entry); + psVar1 = sta_entry + 1; + co_list_push_back((co_list *)&sta_info_env,(co_list_hdr *)sta_entry); + sta_entry = psVar1; + } while (psVar1 != sta_info_tab + 10); + sta_mgmt_entry_init(sta_info_tab + 10); + sta_info_tab[10].pol_tbl.buf_ctrl = txl_buffer_control_desc_bcmc; + sta_info_tab[10].sta_sec_info.cur_key = &vif_info_tab[0].default_key; + sta_info_tab[10].inst_nbr = '\0'; + sta_info_tab[10].ctrl_port_state = '\0'; + printf("------ set default key %p, key ptr %p\r\n",0x4201c2b8,vif_info_tab[0].default_key); + sta_mgmt_entry_init(sta_info_tab + 0xb); + sta_info_tab[11].inst_nbr = '\x01'; + sta_info_tab[11].pol_tbl.buf_ctrl = txl_buffer_control_desc_bcmc + 1; + sta_info_tab[11].ctrl_port_state = '\0'; + sta_info_tab[11].sta_sec_info.cur_key = &vif_info_tab[1].default_key; + printf("------ set default key %p, key ptr %p\r\n",vif_info_tab[1].default_key); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t sta_mgmt_register(mm_sta_add_req *param,uint8_t *sta_idx) + +{ + uint8_t uVar1; + co_list_hdr *list_hdr; + char *fmt; + undefined4 uVar2; + key_info_tag *pkVar3; + co_list_hdr *pcVar4; + byte bVar5; + co_list_hdr *pcVar6; + co_list_hdr *pcVar7; + uint uVar8; + + uVar8 = (uint)param->inst_nbr; + list_hdr = co_list_pop_front((co_list *)&sta_info_env); + if (list_hdr == (co_list_hdr *)0x0) { + uVar1 = '\x01'; + } + else { + memcpy((void *)((int)&list_hdr[7].next + 2),¶m->mac_addr,6); + bVar5 = param->ampdu_spacing_min; + if (bVar5 < 0x10) { + bVar5 = 0x10; + } + *(byte *)&list_hdr[5].next = bVar5; + *(uint16_t *)&list_hdr[3].next = param->ampdu_size_max_ht; + list_hdr[2].next = (co_list_hdr *)param->ampdu_size_max_vht; + list_hdr[4].next = (co_list_hdr *)param->paid_gid; + *(uint8_t *)((int)&list_hdr[6].next + 2) = param->inst_nbr; + *(int8_t *)&list_hdr[9].next = param->rssi; + list_hdr[10].next = (co_list_hdr *)param->tsflo; + list_hdr[0xb].next = (co_list_hdr *)param->tsfhi; + *(uint8_t *)&list_hdr[0xc].next = param->data_rate; + uVar1 = (char)((int)(list_hdr + -0x10806a02) >> 4) * '\x13'; + *sta_idx = uVar1; + *(uint8_t *)((int)&list_hdr[6].next + 3) = uVar1; + list_hdr[1].next = (co_list_hdr *)0x19000; + *(undefined2 *)&list_hdr[0x62].next = 0xffff; + pcVar6 = (co_list_hdr *)((int)&list_hdr[0x62].next + 2); + do { + *(undefined2 *)&pcVar6->next = 0xffff; + pcVar6 = (co_list_hdr *)((int)&pcVar6->next + 2); + } while (pcVar6 != list_hdr + 0x67); + bVar5 = *sta_idx; + *(undefined *)((int)&list_hdr[0xc].next + 1) = 0; + *(txl_buffer_control **)&list_hdr[0x43].next = txl_buffer_control_desc + bVar5; + if ((vif_info_tab[uVar8].flags & 8) == 0) { + list_hdr[0x2b].next = (co_list_hdr *)(uVar8 * 0x5d8 + 0x4201c2b8); + pkVar3 = vif_info_tab[uVar8].default_key; + uVar2 = 0x10d; + fmt = "------ %d set default key %p, ptr %p\r\n"; + } + else { + pkVar3 = (key_info_tag *)list_hdr[0x2a].next; + list_hdr[0x2b].next = list_hdr + 0x2a; + uVar2 = 0x102; + fmt = "------ %d set default key %p, key ptr %p\r\n"; + } + printf(fmt,uVar2,pkVar3); + pcVar6 = _DAT_44b00120; + pcVar7 = list_hdr + 0x47; + pcVar4 = _DAT_44b00120 + -250000; + do { + pcVar7->next = pcVar6; + pcVar7[1].next = pcVar4; + pcVar7 = pcVar7 + 3; + } while (pcVar7 != list_hdr + 0x62); + co_list_push_back(&vif_info_tab[uVar8].sta_list,list_hdr); + *(undefined *)((int)&list_hdr[7].next + 1) = 1; + uVar1 = '\0'; + } + return uVar1; +} + + + +void sta_mgmt_unregister(uint8_t sta_idx) + +{ + sta_info_tag *sta_entry; + undefined3 in_register_00002029; + + sta_entry = sta_info_tab + CONCAT31(in_register_00002029,sta_idx); + co_list_extract(&vif_info_tab[sta_info_tab[CONCAT31(in_register_00002029,sta_idx)].inst_nbr]. + sta_list,(co_list_hdr *)sta_entry); + sta_mgmt_entry_init(sta_entry); + co_list_push_back((co_list *)&sta_info_env,(co_list_hdr *)sta_entry); + return; +} + + + +void sta_mgmt_add_key(mm_key_add_req *param,uint8_t hw_key_idx) + +{ + uint8_t uVar1; + uint uVar2; + + uVar2 = (uint)param->sta_idx; + sta_info_tab[uVar2].sta_sec_info.key_info.hw_key_idx = hw_key_idx; + sta_info_tab[uVar2].sta_sec_info.key_info.cipher = param->cipher_suite; + sta_info_tab[uVar2].sta_sec_info.key_info.key_idx = param->key_idx; + memset(&sta_info_tab[uVar2].sta_sec_info,0,0x48); + uVar1 = sta_info_tab[uVar2].sta_sec_info.key_info.cipher; + if (uVar1 == '\x01') { + *(undefined4 *)&sta_info_tab[uVar2].sta_sec_info.key_info.tx_pn = 0; + *(undefined4 *)((int)&sta_info_tab[uVar2].sta_sec_info.key_info.tx_pn + 4) = 0; + *(uint32_t *)sta_info_tab[uVar2].sta_sec_info.key_info.u = (param->key).array[4]; + *(uint32_t *)(sta_info_tab[uVar2].sta_sec_info.key_info.u + 4) = (param->key).array[5]; + *(uint32_t *)(sta_info_tab[uVar2].sta_sec_info.key_info.u + 8) = (param->key).array[6]; + *(uint32_t *)(sta_info_tab[uVar2].sta_sec_info.key_info.u + 0xc) = (param->key).array[7]; + } + else { + if ((uVar1 == '\0') || (uVar1 == '\x03')) { + next = next * 0x41c64e6d + 0x3039; + *(ulong *)&sta_info_tab[uVar2].sta_sec_info.key_info.tx_pn = next >> 0x10; + *(undefined4 *)((int)&sta_info_tab[uVar2].sta_sec_info.key_info.tx_pn + 4) = 0; + } + else { + *(undefined4 *)&sta_info_tab[uVar2].sta_sec_info.key_info.tx_pn = 0; + *(undefined4 *)((int)&sta_info_tab[uVar2].sta_sec_info.key_info.tx_pn + 4) = 0; + } + } + sta_info_tab[uVar2].sta_sec_info.key_info.valid = true; + *(sta_mgmt_sec_info **)&sta_info_tab[uVar2].sta_sec_info.pairwise_key = + &sta_info_tab[uVar2].sta_sec_info; + return; +} + + + +void sta_mgmt_del_key(sta_info_tag *sta) + +{ + (sta->sta_sec_info).key_info.valid = false; + (sta->sta_sec_info).pairwise_key = (key_info_tag *)0x0; + sta->ctrl_port_state = '\x01'; + return; +} + + + +int sta_mgmt_send_postponed_frame(vif_info_tag *p_vif_entry,sta_info_tag *p_sta_entry,int limit) + +{ + uint8_t access_category; + int iVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 extraout_var_00; + txdesc *txdesc; + int iStack36; + int stop; + + iVar1 = 0; + while( true ) { + txdesc = (txdesc *)(p_sta_entry->tx_desc_post).first; + if (txdesc == (txdesc *)0x0) { + return iVar1; + } + iStack36 = 0; + _Var2 = txl_cntrl_tx_check(p_vif_entry); + if (CONCAT31(extraout_var,_Var2) == 0) { + return iVar1; + } + _Var2 = apm_tx_int_ps_check(txdesc); + if (CONCAT31(extraout_var_00,_Var2) == 0) { + return iVar1; + } + txdesc = apm_tx_int_ps_get_postpone(p_vif_entry,p_sta_entry,&iStack36); + if (iStack36 != 0) break; + if (txdesc == (txdesc *)0x0) { + txdesc = (txdesc *)co_list_pop_front(&p_sta_entry->tx_desc_post); + } + access_category = (txdesc->host).tid; + *(undefined *)((int)&txdesc[1].host.packet_addr + 1) = 0; + iVar1 = iVar1 + 1; + txl_cntrl_push_int(txdesc,access_category); + if ((limit != 0) && (iVar1 == limit)) { + return iVar1; + } + } + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void td_timer_end(void *env) + +{ + int iVar1; + bool bVar2; + undefined *puVar3; + undefined *puVar4; + + iVar1 = _DAT_44b00120; + if (*(char *)((int)env + 0x23) != '\0') { + bVar2 = *(int *)((int)env + 0x10) != 0; + if (*(int *)((int)env + 0x14) != 0) { + bVar2 = (bool)(bVar2 | 2); + } + if (*(int *)((int)env + 0x18) != 0) { + bVar2 = (bool)(bVar2 | 4); + } + if (*(int *)((int)env + 0x1c) != 0) { + bVar2 = (bool)(bVar2 | 8); + } + if (((*(byte *)((int)env + 0x21) ^ bVar2) & 0xc) != 0) { + if ((bVar2 & 4U) == 0) { + puVar3 = &UNK_2307ba2c; + } + else { + puVar3 = &UNK_2307ba28; + } + if ((bVar2 & 8U) == 0) { + puVar4 = &UNK_2307ba2c; + } + else { + puVar4 = &UNK_2307ba30; + } + printf(&DAT_2307ba34,puVar3,puVar4); + ps_traffic_status_update(*(uint8_t *)((int)env + 0x20),bVar2 & 0xc); + } + *(bool *)((int)env + 0x21) = bVar2; + } + *(undefined4 *)((int)env + 0x10) = 0; + *(undefined4 *)((int)env + 0x14) = 0; + *(undefined4 *)((int)env + 0x18) = 0; + *(undefined4 *)((int)env + 0x1c) = 0; + *(bool *)((int)env + 0x23) = vif_info_tab[*(byte *)((int)env + 0x20)].chan_ctxt == DAT_4201e2f0; + mm_timer_set((mm_timer_tag *)env,iVar1 + 1000000); + return; +} + + + +void td_reset(uint8_t vif_index) + +{ + td_env_tag *__s; + undefined3 in_register_00002029; + int iVar1; + + iVar1 = CONCAT31(in_register_00002029,vif_index); + __s = td_env + iVar1; + printf(&DAT_2307ba00,iVar1); + if (td_env[iVar1].is_on != false) { + mm_timer_clear((mm_timer_tag *)__s); + } + memset(__s,0,0x24); + td_env[iVar1].td_timer.cb = td_timer_end; + *(td_env_tag **)&td_env[iVar1].td_timer.env = __s; + td_env[iVar1].vif_index = vif_index; + return; +} + + + +void td_init(void) + +{ + printf(&DAT_2307b9f4); + td_reset('\0'); + td_reset('\x01'); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void td_start(uint8_t vif_index) + +{ + int iVar1; + undefined3 in_register_00002029; + int iVar2; + + iVar1 = _DAT_44b00120; + iVar2 = CONCAT31(in_register_00002029,vif_index); + if (td_env[iVar2].is_on == false) { + printf(&DAT_2307ba14,iVar2); + td_env[iVar2].is_on = true; + mm_timer_set((mm_timer_tag *)(td_env + iVar2),iVar1 + 1000000); + return; + } + return; +} + + + +void td_pck_ind(uint8_t vif_index,uint8_t sta_index,_Bool rx) + +{ + undefined3 in_register_00002029; + int iVar1; + undefined3 in_register_00002031; + + iVar1 = CONCAT31(in_register_00002029,vif_index); + if (CONCAT31(in_register_00002031,rx) != 0) { + td_env[iVar1].pck_cnt_rx = td_env[iVar1].pck_cnt_rx + 1; + return; + } + td_env[iVar1].pck_cnt_tx = td_env[iVar1].pck_cnt_tx + 1; + return; +} + + + +void td_pck_ps_ind(uint8_t vif_index,_Bool rx) + +{ + undefined3 in_register_00002029; + int iVar1; + undefined3 in_register_0000202d; + + iVar1 = CONCAT31(in_register_00002029,vif_index); + if (CONCAT31(in_register_0000202d,rx) != 0) { + td_env[iVar1].pck_cnt_rx_ps = td_env[iVar1].pck_cnt_rx_ps + 1; + return; + } + td_env[iVar1].pck_cnt_tx_ps = td_env[iVar1].pck_cnt_tx_ps + 1; + return; +} + + + +void bl_tpc_update_power_table(int8_t *power_table) + +{ + char cVar1; + int32_t *piVar2; + char *pcVar3; + int iStack72; + int32_t power_os [14]; + + trpc_update_power((int8_t (*) [8])power_table); + pcVar3 = power_table + 0x18; + piVar2 = &iStack72; + while (pcVar3 != power_table + 0x26) { + cVar1 = *pcVar3; + pcVar3 = pcVar3 + 1; + *piVar2 = (int)cVar1; + piVar2 = piVar2 + 1; + } + rf_pri_update_power_offset(&iStack72); + return; +} + + + +void bl_tpc_power_table_get(int8_t *power_table_config) + +{ + int iVar1; + + trpc_power_get(power_table_config); + iVar1 = 0x18; + do { + power_table_config[iVar1] = '\0'; + iVar1 = iVar1 + 1; + } while (iVar1 != 0x26); + return; +} + + + +void bl_tpc_update_power_rate_11b(int8_t *power_rate_table) + +{ + int8_t *piVar1; + int8_t *piVar2; + int iVar3; + + iVar3 = 0; + do { + piVar1 = power_rate_table + iVar3; + piVar2 = txpwr_vs_rate_table + iVar3; + iVar3 = iVar3 + 1; + *piVar2 = *piVar1; + } while (iVar3 != 4); + return; +} + + + +void bl_tpc_update_power_rate_11g(int8_t *power_rate_table) + +{ + int8_t *piVar1; + int iVar2; + int8_t *piVar3; + + iVar2 = 0; + piVar3 = txpwr_vs_rate_table; + do { + piVar1 = power_rate_table + iVar2; + iVar2 = iVar2 + 1; + piVar3[8] = *piVar1; + piVar3 = piVar3 + 1; + } while (iVar2 != 8); + return; +} + + + +void bl_tpc_update_power_rate_11n(int8_t *power_rate_table) + +{ + int8_t *piVar1; + int iVar2; + int8_t *piVar3; + + iVar2 = 0; + piVar3 = txpwr_vs_rate_table; + do { + piVar1 = power_rate_table + iVar2; + iVar2 = iVar2 + 1; + piVar3[0x10] = *piVar1; + piVar3 = piVar3 + 1; + } while (iVar2 != 8); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void tpc_update_tx_power(int8_t pwr) + +{ + uint8_t uVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + + uVar1 = trpc_get_default_power_idx('\x02','\0'); + _DAT_44b000a0 = CONCAT31(extraout_var,uVar1) | _DAT_44b000a0 & 0xffffff00; + uVar1 = trpc_get_default_power_idx('\0','\0'); + _DAT_44b000a0 = CONCAT31(extraout_var_00,uVar1) << 8 | _DAT_44b000a0 & 0xffff00ff; + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void tpc_update_vif_tx_power(vif_info_tag *vif,int8_t *pwr,uint8_t *idx) + +{ + char cVar1; + char cVar2; + _Bool _Var3; + undefined3 extraout_var; + int *piVar4; + + if (*pwr == '\x7f') { + return; + } + cVar1 = vif->tx_power; + phy_get_rf_gain_idx(pwr,idx); + cVar2 = *pwr; + vif->tx_power = cVar2; + if (vif->user_tx_power < cVar2) { + *pwr = vif->user_tx_power; + phy_get_rf_gain_idx(pwr,idx); + } + if (*pwr != cVar1) { + piVar4 = (int *)(vif->sta_list).first; + while (piVar4 != (int *)0x0) { + *(byte *)((int)piVar4 + 0x11a) = *(byte *)((int)piVar4 + 0x11a) | 0x10; + piVar4 = (int *)*piVar4; + } + if (vif->chan_ctxt != (chan_ctxt_tag *)0x0) { + chan_update_tx_power(vif->chan_ctxt); + _Var3 = chan_is_on_channel(vif); + if (CONCAT31(extraout_var,_Var3) != 0) { + tpc_update_tx_power((vif->chan_ctxt->channel).tx_power); + return; + } + } + } + return; +} + + + +uint8_t tpc_get_vif_tx_power_vs_rate(uint32_t rate_config) + +{ + uint8_t formatmod; + byte mcs; + + mcs = (byte)rate_config & 0x7f; + if ((rate_config >> 0xb & 7) == 0) { + formatmod = (uint8_t)(rate_config & 0x7c); + if ((rate_config & 0x7c) != 0) { + mcs = mcs - 4; + formatmod = '\x01'; + } + } + else { + formatmod = '\x02'; + } + formatmod = trpc_get_default_power_idx(formatmod,mcs); + return formatmod; +} + + + +void tpc_update_frame_tx_power(vif_info_tag *vif,txl_frame_desc_tag *frame) + +{ + uint32_t uVar1; + uint8_t uVar2; + undefined3 extraout_var; + + uVar1 = (((frame->txdesc).lmac.hw_desc)->thd).policyentryaddr; + uVar2 = tpc_get_vif_tx_power_vs_rate(*(uint32_t *)(uVar1 + 0x14)); + *(undefined4 *)(uVar1 + 0x24) = CONCAT31(extraout_var,uVar2); + return; +} + + + +void txl_int_fake_transfer(txdesc *txdesc,uint8_t access_category) + +{ + undefined3 in_register_0000202d; + int iVar1; + txl_buffer_tag *ptVar2; + + ptVar2 = (txdesc->lmac).buffer; + (ptVar2->tbd).upatterntx = 0xcafefade; + iVar1 = CONCAT31(in_register_0000202d,access_category) + 0x16; + ptVar2->txdesc = txdesc; + if ((&txl_buffer_env.buf_idx[0].free)[iVar1 * 2] == 0) { + *(txl_buffer_tag **)(&txl_buffer_env.buf_idx[0].free + iVar1 * 2) = ptVar2; + } + else { + *(txl_buffer_tag **)((&txl_buffer_env.buf_idx[0].free_size)[iVar1 * 2] + 0x10) = ptVar2; + } + *(txl_buffer_tag **)(&txl_buffer_env.buf_idx[0].free_size + iVar1 * 2) = ptVar2; + ptVar2->next = (txl_buffer_tag *)0x0; + return; +} + + + +void blmac_abs_timer_set(int reg_idx,uint32_t value) + +{ + if (9 < reg_idx) { + assert_err("reg_idx <= 9","module",0x26a0); + } + *(uint32_t *)((reg_idx + 0x112c004a) * 4) = value; + return; +} + + + +void txl_machdr_format(uint32_t machdrptr) + +{ + uint uVar1; + + if ((*(byte *)(machdrptr + 0x16) & 0xf) == 0) { + txl_cntrl_env.seqnbr = txl_cntrl_env.seqnbr + 1; + } + uVar1 = (uint)txl_cntrl_env.seqnbr; + *(byte *)(machdrptr + 0x16) = (byte)(uVar1 << 4) | *(byte *)(machdrptr + 0x16) & 0xf; + *(undefined *)(machdrptr + 0x17) = (char)((uVar1 << 4) >> 8); + return; +} + + + +void txl_cntrl_init(void) + +{ + txl_cntrl_env_tag *ptVar1; + undefined4 uVar2; + undefined4 *puVar3; + + txl_hwdesc_init(); + txl_buffer_init(); + txl_cfm_init(); + txl_frame_init(false); + memset(&txl_cntrl_env,0,0x58); + ptVar1 = &txl_cntrl_env; + puVar3 = (undefined4 *)&DAT_44a00080; + do { + co_list_init(&ptVar1->txlist[0].transmitting); + ptVar1->txlist[0].last_frame_exch = (tx_hd *)0x0; + uVar2 = *puVar3; + ptVar1->txlist[0].chk_state = '\0'; + puVar3 = puVar3 + 1; + ptVar1->txlist[0].bridgedmacnt = (uint16_t)uVar2; + ptVar1 = (txl_cntrl_env_tag *)(ptVar1->txlist + 1); + } while (puVar3 != (undefined4 *)0x44a00094); + txl_cntrl_env.seqnbr = 0; + return; +} + + + +_Bool txl_cntrl_tx_check(vif_info_tag *p_vif_entry) + +{ + _Bool _Var1; + + if (txl_cntrl_env.reset == false) { + _Var1 = chan_is_tx_allowed(p_vif_entry); + return _Var1; + } + return false; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_cntrl_halt_ac(uint8_t access_category) + +{ + undefined3 in_register_00002029; + + switch(CONCAT31(in_register_00002029,access_category)) { + case 0: + _DAT_44b08180 = 0x10000; + do { + } while ((_DAT_44b08188 >> 4 & 3) != 0); + _DAT_44b08184 = 0x10000; + break; + case 1: + _DAT_44b08180 = 0x20000; + do { + } while ((_DAT_44b08188 >> 8 & 3) != 0); + _DAT_44b08184 = 0x20000; + break; + case 2: + _DAT_44b08180 = 0x40000; + do { + } while ((_DAT_44b08188 >> 0xc & 3) != 0); + _DAT_44b08184 = 0x40000; + break; + case 3: + _DAT_44b08180 = 0x80000; + do { + } while ((_DAT_44b08188 >> 0x10 & 3) != 0); + _DAT_44b08184 = 0x80000; + break; + case 4: + _DAT_44b08180 = 0x8000; + do { + } while ((_DAT_44b08188 & 3) != 0); + _DAT_44b08184 = 0x8000; + break; + default: + assert_err("0","module",0x779); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_cntrl_flush_ac(uint8_t access_category,uint32_t status) + +{ + uint uVar1; + undefined3 in_register_00002029; + int iVar2; + uint uVar3; + + uVar1 = _DAT_44b0808c; + iVar2 = CONCAT31(in_register_00002029,access_category); + uVar3 = 1 << ((uint)access_category & 0x1f); + txl_cfm_flush(access_category,txl_cfm_env.cfmlist + iVar2,status); + txl_cfm_flush(access_category,&txl_cntrl_env.txlist[iVar2].transmitting,status); + txl_cntrl_env.txlist[iVar2].last_frame_exch = (tx_hd *)0x0; + txl_buffer_reset(iVar2); + _DAT_44b08088 = uVar3; + _DAT_44b0808c = ~uVar3 & uVar1; + return; +} + + +/* +Unable to decompile 'txl_cntrl_clear_bcn_ac' +Cause: Exception while decompiling 230497b6: Decompiler process died + +*/ + +/* +Unable to decompile 'txl_cntrl_clear_all_ac' +Cause: Exception while decompiling 230497d8: Decompiler process died + +*/ + + +void txl_cntrl_inc_pck_cnt(void) + +{ + txl_cntrl_env.pck_cnt = txl_cntrl_env.pck_cnt + 1; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_payload_handle(void) + +{ + int iVar1; + + while ((_DAT_44a00024 & 0x1f) != 0) { + iVar1 = __clzsi2(_DAT_44a00024 & 0x1f); + _DAT_44a00020 = 1 << (0x1fU - iVar1 & 0x1f); + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_payload_handle_backup(void) + +{ + ushort uVar1; + uint uVar2; + uint uVar3; + txl_buffer_tag *ptVar4; + char *condition; + int line; + byte bVar5; + uint reg_idx; + tx_hd *ptVar6; + undefined *puVar7; + txdesc *txdesc; + tx_hd *ptVar8; + txl_buffer_env_tag *ptVar9; + txl_cntrl_env_tag *ptVar10; + uint uVar11; + tx_hw_desc *ptVar12; + + ptVar9 = &txl_buffer_env; + ptVar10 = &txl_cntrl_env; + uVar3 = 0; + while (ptVar4 = ptVar9->list[0].first, ptVar4 == (txl_buffer_tag *)0x0) { +LAB_230498ce: + uVar3 = uVar3 + 1; + ptVar9 = (txl_buffer_env_tag *)&ptVar9->buf_idx[0].free_size; + ptVar10 = (txl_cntrl_env_tag *)(ptVar10->txlist + 1); + if (uVar3 == 5) { + return; + } + } + uVar2 = uVar3 & 0xff; + ptVar9->list[0].first = ptVar4->next; + uVar11 = 1 << (uVar3 & 0x1f); + do { + txdesc = ptVar4->txdesc; + if ((txdesc->host).packet_addr != 0) { + if (uVar3 == 4) { + reg_idx = (uint)(txdesc->host).vif_idx; + if ((*(byte *)((int)&ptVar4[1].length + 1) >> 5 & 1) == 0) { + bVar5 = vif_info_tab[reg_idx].u[0x2ea] & 0xfd; + } + else { + bVar5 = vif_info_tab[reg_idx].u[0x2ea] | 2; + } + vif_info_tab[reg_idx].u[0x2ea] = bVar5; + } + if ((txdesc->host).tid == -1) { + uVar1 = (txdesc->host).flags; + if ((((uVar1 & 8) != 0) && ((*(byte *)&ptVar4[1].length & 0xdc) == 0x10)) && + (*(short *)((int)&ptVar4[1].dma_desc[0].src + 2) == 0)) { + (txdesc->host).flags = uVar1 | 0x20; + rxu_cntrl_monitor_pm((mac_addr_conflict *)&ptVar4[1].lenheader); + } + txl_machdr_format((uint32_t)(ptVar4 + 1)); + } + ptVar4 = (txdesc->lmac).buffer; + ptVar12 = (txdesc->lmac).hw_desc; + if (((txdesc->host).flags & 8) == 0) { + txu_cntrl_tkip_mic_append(txdesc,(uint8_t)uVar2); + (ptVar12->thd).macctrlinfo1 = (ptVar4->buffer_control).mac_control_info; + } + else { + (ptVar12->thd).macctrlinfo2 = (ptVar12->thd).macctrlinfo2 & 0xff87ffff; + bVar5 = *(byte *)&ptVar4[1].lenheader; + (ptVar12->thd).statinfo = 0; + (ptVar12->thd).macctrlinfo1 = (uint)((bVar5 & 1) == 0) << 9; + } + *(txl_buffer_control **)&(ptVar12->thd).policyentryaddr = &ptVar4->buffer_control; + (ptVar12->thd).phyctrlinfo = (ptVar4->buffer_control).phy_control_info; + } + ptVar10->txlist[0].bridgedmacnt = ptVar10->txlist[0].bridgedmacnt + 1; + ptVar6 = ptVar10->txlist[0].last_frame_exch; + ptVar8 = &((txdesc->lmac).hw_desc)->thd; + if (ptVar6 == (tx_hd *)0x0) { + reg_idx = uVar3; + if (uVar2 == 2) { + if ((_DAT_44b08188 >> 0xc & 3) == 2) { + line = 0x23c; + condition = "blmac_tx_ac_2_state_getf() != 2"; + goto LAB_23049ac4; + } + _DAT_44b08180 = 0x800; + puVar7 = (undefined *)0x61a80; + _DAT_44b081a4 = ptVar8; + } + else { + if (2 < uVar2) { + if (uVar2 == 3) { + if ((_DAT_44b08188 >> 0x10 & 3) != 2) { + _DAT_44b08180 = 0x1000; + _DAT_44b081a8 = ptVar8; + goto LAB_23049b24; + } + line = 0x236; + condition = "blmac_tx_ac_3_state_getf() != 2"; + } + else { + if (uVar2 != 4) goto LAB_23049a72; + if ((_DAT_44b08188 & 3) != 2) { + _DAT_44b08180 = 0x100; + reg_idx = 4; + puVar7 = (undefined *)0xc350; + _DAT_44b08198 = ptVar8; + goto LAB_23049ae0; + } + line = 0x22f; + condition = "blmac_tx_bcn_state_getf() != 2"; + } +LAB_23049ac4: + assert_rec(condition,"module",line); + goto LAB_23049a36; + } + if (uVar2 == 1) { + if ((_DAT_44b08188 >> 8 & 3) == 2) { + line = 0x242; + condition = "blmac_tx_ac_1_state_getf() != 2"; + goto LAB_23049ac4; + } + _DAT_44b08180 = 0x400; + puVar7 = &DAT_001e8480; + _DAT_44b081a0 = ptVar8; + } + else { +LAB_23049a72: + if ((_DAT_44b08188 >> 4 & 3) == 2) { + line = 0x248; + condition = "blmac_tx_ac_0_state_getf() != 2"; + goto LAB_23049ac4; + } + _DAT_44b08180 = 0x200; + _DAT_44b0819c = ptVar8; +LAB_23049b24: + puVar7 = (undefined *)0x30d40; + } + } +LAB_23049ae0: + blmac_abs_timer_set(reg_idx,(uint32_t)(puVar7 + _DAT_44b00120)); + _DAT_44b0808c = uVar11 | _DAT_44b0808c; + _DAT_44b08088 = uVar11; + } + else { + *(tx_hd **)&ptVar6->nextfrmexseq_ptr = ptVar8; + if (uVar2 == 2) { + _DAT_44b08180 = 8; + } + else { + if (uVar2 < 3) { + if (uVar2 == 1) { + _DAT_44b08180 = 4; + } + else { +LAB_230499fe: + _DAT_44b08180 = 2; + } + } + else { + if (uVar2 == 3) { + _DAT_44b08180 = 0x10; + } + else { + if (uVar2 != 4) goto LAB_230499fe; + _DAT_44b08180 = 1; + } + } + } + } +LAB_23049a36: + ptVar4 = ptVar9->list[0].first; + ptVar10->txlist[0].last_frame_exch = ptVar8; + if (ptVar4 == (txl_buffer_tag *)0x0) goto LAB_230498ce; + ptVar9->list[0].first = ptVar4->next; + } while( true ); +} + + +/* +Unable to decompile 'txl_cntrl_push_int' +Cause: Exception while decompiling 23049baa: Decompiler process died + +*/ + +/* +Unable to decompile 'txl_cntrl_push_int_force' +Cause: Exception while decompiling 23049c7c: Decompiler process died + +*/ + +/* +Unable to decompile 'txl_cntrl_push' +Cause: Exception while decompiling 23049cca: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_transmit_trigger(void) + +{ + uint reg_idx; + uint uVar1; + int iVar2; + u32_l status; + tx_hw_desc *ptVar3; + uint32_t uVar4; + txdesc *txdesc; + co_list *list; + + if ((_DAT_44b08078 & 0x7c0) == 0) { + return; + } + iVar2 = __clzsi2(_DAT_44b08078 & 0x7c0); + reg_idx = 0x19U - iVar2 & 0xff; + if (4 < reg_idx) { + assert_err("access_category < NX_TXQ_CNT","module",0x90b); + } + _DAT_44b0807c = 1 << (reg_idx + 6 & 0x1f); + list = &txl_cntrl_env.txlist[reg_idx].transmitting; + uVar1 = ~(1 << (0x19U - iVar2 & 0x1f)); + while( true ) { + txdesc = (txdesc *)list->first; + if (txdesc == (txdesc *)0x0) { + txl_cntrl_env.txlist[reg_idx].last_frame_exch = (tx_hd *)0x0; + _DAT_44b0808c = uVar1 & _DAT_44b0808c; + return; + } + ptVar3 = (txdesc->lmac).hw_desc; + status = (ptVar3->thd).statinfo; + if (-1 < (int)status) break; + if (((txdesc->host).packet_addr != 0) && ((txdesc->lmac).buffer != (txl_buffer_tag *)0x0)) { + (txdesc->lmac).buffer = (txl_buffer_tag *)0x0; + } + ptVar3->cfm_ptr->status = status; + uVar4 = (ptVar3->thd).nextfrmexseq_ptr; + if (uVar4 == 0) { + txl_cntrl_env.txlist[reg_idx].last_frame_exch = (tx_hd *)0x0; + _DAT_44b0808c = _DAT_44b0808c & uVar1; + } + else { + if (-1 < *(int *)(uVar4 + 0x3c)) { + blmac_abs_timer_set(reg_idx,_DAT_44b00120 + TX_TIMEOUT[reg_idx]); + return; + } + } + co_list_pop_front(list); + if ((txdesc->host).packet_addr == 0) { + txl_frame_cfm(txdesc); + } + else { + txl_cfm_push(txdesc,status,(u8_l)reg_idx); + } + blmac_abs_timer_set(reg_idx,_DAT_44b00120 + TX_TIMEOUT[reg_idx]); + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_reset(void) + +{ + u8_l access_category; + uint16_t uVar1; + txl_cntrl_env_tag *ptVar2; + undefined4 *puVar3; + undefined4 uVar4; + uint uVar5; + co_list *list; + txl_cfm_env_tag *list_00; + + uVar1 = txl_cntrl_env.seqnbr; + ke_evt_clear(0x1f000); + do { + } while ((_DAT_44a00010 & 0xffff) != 0xffff); + txl_cntrl_env.reset = true; + list_00 = &txl_cfm_env; + list = &txl_cntrl_env.txlist[0].transmitting; + uVar5 = 0; + do { + _DAT_44a00020 = 1 << (uVar5 & 0x1f); + access_category = (u8_l)uVar5; + txl_cfm_flush(access_category,(co_list *)list_00,0x40000000); + uVar5 = uVar5 + 1; + txl_cfm_flush(access_category,list,0x40000000); + list_00 = (txl_cfm_env_tag *)(list_00->cfmlist + 1); + list = list + 2; + } while (uVar5 != 5); + txl_hwdesc_reset(); + txl_buffer_reinit(); + txl_cfm_init(); + memset(&txl_cntrl_env,0,0x58); + ptVar2 = &txl_cntrl_env; + puVar3 = (undefined4 *)&DAT_44a00080; + txl_cntrl_env.seqnbr = uVar1; + do { + co_list_init(&ptVar2->txlist[0].transmitting); + ptVar2->txlist[0].last_frame_exch = (tx_hd *)0x0; + uVar4 = *puVar3; + ptVar2->txlist[0].chk_state = '\0'; + puVar3 = puVar3 + 1; + ptVar2->txlist[0].bridgedmacnt = (uint16_t)uVar4; + ptVar2 = (txl_cntrl_env_tag *)(ptVar2->txlist + 1); + } while (puVar3 != (undefined4 *)0x44a00094); + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void txl_cntrl_env_dump(void) + +{ + int iVar1; + uint32_t uVar2; + int *piVar3; + int iVar4; + int *piVar5; + co_list *list; + + iVar1 = 4; + do { + list = (co_list *)((int)&txl_cntrl_env.txlist[0].last_frame_exch + iVar1); + uVar2 = co_list_cnt(list); + if (uVar2 != 0) { + piVar5 = (int *)list->first; + piVar3 = piVar5; + while (piVar3 != (int *)0x0) { + piVar3 = (int *)*piVar3; + } + while (piVar5 != (int *)0x0) { + iVar4 = *(int *)(piVar5[0x1b] + 0x10); + while (iVar4 != 0) { + iVar4 = *(int *)(iVar4 + 4); + } + piVar5 = (int *)*piVar5; + } + } + iVar1 = iVar1 + 0x10; + } while (iVar1 != 0x54); + return; +} + + + +void txl_frame_init_desc(txl_frame_desc_tag *frame,txl_buffer_tag *buffer,tx_hw_desc *hwdesc, + txl_buffer_control *bufctrl) + +{ + memset(frame,0,0x2d8); + (hwdesc->thd).upatterntx = 0xcafebabe; + *(txl_buffer_tag **)&(hwdesc->thd).field_4 = buffer + 1; + (hwdesc->thd).frmlifetime = 0; + (hwdesc->thd).optlen[0] = 0; + (hwdesc->thd).optlen[1] = 0; + (hwdesc->thd).optlen[2] = 0; + *(undefined4 *)bufctrl->field_0 = 0xbadcab1e; + (frame->txdesc).lmac.hw_desc = hwdesc; + (frame->txdesc).lmac.buffer = buffer; + (frame->txdesc).umac.buf_control = bufctrl; + frame->type = '\x01'; + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void txl_frame_init(_Bool reset) + +{ + tx_hw_desc *ptVar1; + txl_frame_desc_tag *__s; + uint8_t uVar2; + byte bVar3; + undefined3 in_register_00002029; + undefined3 extraout_var; + undefined3 extraout_var_00; + txl_buffer_control *ptVar4; + uint32_t *puVar5; + int iVar6; + + co_list_init((co_list *)&txl_frame_env); + co_list_init(&txl_frame_env.desc_done); + __s = txl_frame_desc; + ptVar1 = txl_frame_hwdesc_pool; + puVar5 = txl_frame_pool; + ptVar4 = txl_frame_buf_ctrl; + iVar6 = 0; + do { + if ((CONCAT31(in_register_00002029,reset) == 0) || ((&__s->type)[1] == '\0')) { + memset(__s,0,0x2d8); + (ptVar1->thd).upatterntx = 0xcafebabe; + (ptVar1->thd).frmlifetime = 0; + (ptVar1->thd).optlen[0] = 0; + (ptVar1->thd).optlen[1] = 0; + (ptVar1->thd).optlen[2] = 0; + *(undefined4 *)ptVar4->field_0 = 0xbadcab1e; + *(uint32_t **)&(__s->txdesc).lmac.buffer = puVar5; + (__s->txdesc).umac.buf_control = ptVar4; + (__s->txdesc).lmac.hw_desc = ptVar1; + ptVar1->cfm_ptr = txl_frame_hwdesc_cfms + iVar6; + *(txl_buffer_tag **)&(ptVar1->thd).field_4 = (txl_buffer_tag *)puVar5 + 1; + __s->type = '\0'; + co_list_push_back((co_list *)&txl_frame_env,(co_list_hdr *)__s); + } + iVar6 = iVar6 + 1; + __s = __s + 1; + ptVar1 = ptVar1 + 1; + puVar5 = (uint32_t *)(((txl_buffer_tag *)puVar5)[1].buffer_control.field_0 + 0x10); + ptVar4 = ptVar4 + 1; + } while (iVar6 != 4); + txl_buffer_control_24G.field_0._0_4_ = 0xbadcab1e; + txl_buffer_control_24G.mac_control_info = 0; + txl_buffer_control_24G.phy_control_info = 0; + uVar2 = phy_get_ntx(); + txl_buffer_control_24G.field_0._4_4_ = CONCAT31(extraout_var,uVar2) << 0xe; + bVar3 = phy_get_ntx(); + txl_buffer_control_24G.field_0._8_4_ = (1 << ((uint)bVar3 + 1 & 0x1f)) + -1; + txl_buffer_control_24G.field_0._16_4_ = 0xffff0704; + txl_buffer_control_24G.field_0._20_4_ = 0x400; + txl_buffer_control_24G.field_0._12_4_ = 0; + txl_buffer_control_24G.field_0._24_4_ = 0; + txl_buffer_control_24G.field_0._28_4_ = 0; + txl_buffer_control_24G.field_0._32_4_ = 0; + txl_buffer_control_24G.field_0._40_4_ = 0; + txl_buffer_control_24G.field_0._44_4_ = 0; + txl_buffer_control_24G.field_0._48_4_ = 0; + txl_buffer_control_5G.field_0._0_4_ = 0xbadcab1e; + txl_buffer_control_5G.mac_control_info = 0; + txl_buffer_control_5G.phy_control_info = 0; + uVar2 = phy_get_ntx(); + txl_buffer_control_5G.field_0._4_4_ = CONCAT31(extraout_var_00,uVar2) << 0xe; + bVar3 = phy_get_ntx(); + txl_buffer_control_5G.field_0._8_4_ = (1 << ((uint)bVar3 + 1 & 0x1f)) + -1; + txl_buffer_control_5G.field_0._12_4_ = 0; + txl_buffer_control_5G.field_0._16_4_ = 0xffff0704; + txl_buffer_control_5G.field_0._20_4_ = iVar6; + txl_buffer_control_5G.field_0._24_4_ = 0; + txl_buffer_control_5G.field_0._28_4_ = 0; + txl_buffer_control_5G.field_0._32_4_ = 0; + txl_buffer_control_5G.field_0._40_4_ = 0; + txl_buffer_control_5G.field_0._44_4_ = 0; + txl_buffer_control_5G.field_0._48_4_ = 0; + return; +} + + + +// WARNING: Type propagation algorithm not settling + +txl_frame_desc_tag * txl_frame_get(int type,int len) + +{ + txl_frame_desc_tag *ptVar1; + tx_hw_desc *ptVar2; + uint8_t uVar3; + undefined3 extraout_var; + uint32_t uVar4; + uint32_t uVar5; + txl_buffer_control *__src; + txl_buffer_control *__dest; + txl_buffer_tag *ptVar6; + + ptVar1 = (txl_frame_desc_tag *)co_list_pop_front((co_list *)&txl_frame_env); + if (ptVar1 == (txl_frame_desc_tag *)0x0) { + tx_count = tx_count + 1; + if (tx_count == 10) { + tx_count = 0; + rx_count = 2; + uVar4 = co_list_cnt((co_list *)&txl_frame_env); + uVar5 = co_list_cnt(&txl_frame_env.desc_done); + if ((uVar5 | uVar4) == 0) { + txl_cntrl_clear_all_ac(); + } + } + } + else { + if (rx_count == 1) { + rx_count = 0; + mac_hw_reset = '\x01'; + vTaskEnterCritical(); + assert_rec("MAC HW RESET include tx and rx","tx rx",0x10b); + vTaskDelay(200); + ptVar1 = (txl_frame_desc_tag *)0x0; + vTaskExitCritical(); + } + else { + if (rx_count != 0) { + rx_count = rx_count - 1; + } + ptVar2 = (ptVar1->txdesc).lmac.hw_desc; + ptVar6 = (ptVar1->txdesc).lmac.buffer; + (ptVar2->thd).frmlen = len + 4; + (ptVar2->thd).field_5 = (ptVar2->thd).field_4 + len + -1; + __dest = &ptVar6->buffer_control; + if (type == 0) { + __src = &txl_buffer_control_24G; + } + else { + __src = __dest; + if (type == 1) { + __src = &txl_buffer_control_5G; + } + } + memcpy(__dest,__src,0x34); + uVar3 = tpc_get_vif_tx_power_vs_rate(*(uint32_t *)((ptVar6->buffer_control).field_0 + 0x14)); + *(uint *)((ptVar6->buffer_control).field_0 + 0x24) = CONCAT31(extraout_var,uVar3); + *(txl_buffer_control **)&(ptVar2->thd).policyentryaddr = __dest; + (ptVar2->thd).phyctrlinfo = 0; + (ptVar2->thd).macctrlinfo2 = 0; + (ptVar2->thd).field_3 = 0; + (ptVar1->cfm).cfm_func = (cfm_func_ptr *)0x0; + (ptVar1->cfm).env = (void *)0x0; + } + } + return ptVar1; +} + + + +_Bool txl_frame_push(txl_frame_desc_tag *frame,uint8_t ac) + +{ + byte bVar1; + tx_hw_desc *ptVar2; + _Bool _Var3; + + ptVar2 = (frame->txdesc).lmac.hw_desc; + if (((ptVar2->thd).field_4 & 1) != 0) { + assert_err("(thd->datastartptr & 0x01) == 0","module",0x182); + } + (ptVar2->thd).nextfrmexseq_ptr = 0; + (ptVar2->thd).nextmpdudesc_ptr = 0; + (ptVar2->thd).macctrlinfo2 = (ptVar2->thd).macctrlinfo2 & 0xff87ffff; + bVar1 = *(byte *)((ptVar2->thd).field_4 + 4); + (ptVar2->thd).statinfo = 0; + (ptVar2->thd).macctrlinfo1 = (uint)((bVar1 & 1) == 0) << 9; + _Var3 = txl_cntrl_push_int((txdesc *)frame,ac); + return _Var3; +} + + + +_Bool txl_frame_push_force(txl_frame_desc_tag *frame,uint8_t ac) + +{ + byte bVar1; + tx_hw_desc *ptVar2; + _Bool _Var3; + + ptVar2 = (frame->txdesc).lmac.hw_desc; + if (((ptVar2->thd).field_4 & 1) != 0) { + assert_err("(thd->datastartptr & 0x01) == 0","module",0x1ad); + } + (ptVar2->thd).nextfrmexseq_ptr = 0; + (ptVar2->thd).nextmpdudesc_ptr = 0; + (ptVar2->thd).macctrlinfo2 = (ptVar2->thd).macctrlinfo2 & 0xff87ffff; + bVar1 = *(byte *)((ptVar2->thd).field_4 + 4); + (ptVar2->thd).statinfo = 0; + (ptVar2->thd).macctrlinfo1 = (uint)((bVar1 & 1) == 0) << 9; + _Var3 = txl_cntrl_push_int_force((txdesc *)frame,ac); + return _Var3; +} + + + +void txl_frame_cfm(txdesc *txdesc) + +{ + co_list_push_back(&txl_frame_env.desc_done,(co_list_hdr *)txdesc); + ke_evt_set(0x20000); + return; +} + + + +void txl_frame_release(txdesc *txdesc,_Bool postponed) + +{ + co_list_hdr *UNRECOVERED_JUMPTABLE; + undefined3 in_register_0000202d; + + if (*(char *)&txdesc[1].host.packet_addr == '\0') { + co_list_push_back((co_list *)&txl_frame_env,(co_list_hdr *)txdesc); + } + if ((CONCAT31(in_register_0000202d,postponed) != 0) && + (UNRECOVERED_JUMPTABLE = txdesc[1].list_hdr.next, UNRECOVERED_JUMPTABLE != (co_list_hdr *)0x0)) + { + // WARNING: Could not recover jumptable at 0x2304a49c. Too many branches + // WARNING: Treating indirect jump as call + (*(code *)UNRECOVERED_JUMPTABLE)(txdesc[1].host.pbuf_addr,0); + return; + } + return; +} + + +/* +Unable to decompile 'txl_frame_evt' +Cause: Exception while decompiling 2304a4a8: Decompiler process died + +*/ + + +uint8_t txl_frame_send_null_frame(uint8_t sta_idx,cfm_func_ptr *cfm,void *env) + +{ + byte bVar1; + uint8_t uVar2; + txl_buffer_tag *ptVar3; + undefined3 in_register_00002029; + int iVar4; + txl_frame_desc_tag *frame; + uint uVar5; + int iVar6; + char acStack56 [4]; + phy_channel_info phy_info; + + iVar4 = CONCAT31(in_register_00002029,sta_idx); + bVar1 = sta_info_tab[iVar4].inst_nbr; + phy_get_channel((phy_channel_info *)acStack56,'\0'); + frame = txl_frame_get((uint)(acStack56[0] != '\0'),0x18); + if (frame != (txl_frame_desc_tag *)0x0) { + tpc_update_frame_tx_power(vif_info_tab + bVar1,frame); + ptVar3 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar3[1].length = 0x48; + *(undefined *)((int)&ptVar3[1].length + 1) = 1; + *(undefined *)((int)&ptVar3[1].length + 2) = 0; + *(undefined *)((int)&ptVar3[1].length + 3) = 0; + memcpy(&ptVar3[1].lenheader,&sta_info_tab[iVar4].mac_addr,6); + memcpy((void *)((int)&ptVar3[1].lenpad + 2),&vif_info_tab[bVar1].mac_addr,6); + memcpy(&ptVar3[1].next,&sta_info_tab[iVar4].mac_addr,6); + uVar5 = (uint)txl_cntrl_env.seqnbr; + txl_cntrl_env.seqnbr = (uint16_t)((uVar5 + 1) * 0x10000 >> 0x10); + iVar6 = (uVar5 + 1) * 0x100000; + *(undefined *)((int)&ptVar3[1].txdesc + 2) = (char)((uint)iVar6 >> 0x10); + *(undefined *)((int)&ptVar3[1].txdesc + 3) = (char)((uint)iVar6 >> 0x18); + (frame->cfm).cfm_func = cfm; + (frame->cfm).env = env; + uVar2 = sta_info_tab[iVar4].inst_nbr; + (frame->txdesc).host.staid = sta_idx; + (frame->txdesc).host.vif_idx = uVar2; + txl_frame_push(frame,'\x03'); + } + return (uint8_t)(frame == (txl_frame_desc_tag *)0x0); +} + + + +// WARNING: Variable defined which should be unmapped: phy_info + +uint8_t txl_frame_send_qosnull_frame(uint8_t sta_idx,uint16_t qos,cfm_func_ptr *cfm,void *env) + +{ + txl_buffer_tag *ptVar1; + uint8_t uVar2; + undefined3 in_register_00002029; + int iVar3; + txl_frame_desc_tag *frame; + mac_addr_conflict *__src; + uint uVar4; + char acStack56 [4]; + phy_channel_info phy_info; + + iVar3 = CONCAT31(in_register_00002029,sta_idx); + uVar4 = (uint)sta_info_tab[iVar3].inst_nbr; + phy_get_channel((phy_channel_info *)acStack56,'\0'); + frame = txl_frame_get((uint)(acStack56[0] != '\0'),0x1a); + if (frame == (txl_frame_desc_tag *)0x0) { + uVar2 = '\x01'; + } + else { + tpc_update_frame_tx_power(vif_info_tab + uVar4,frame); + ptVar1 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar1[1].length = 200; + *(undefined *)((int)&ptVar1[1].length + 1) = 0; + *(undefined *)((int)&ptVar1[1].length + 2) = 0; + *(undefined *)((int)&ptVar1[1].length + 3) = 0; + memcpy(&ptVar1[1].lenheader,&sta_info_tab[iVar3].mac_addr,6); + __src = &vif_info_tab[uVar4].mac_addr; + memcpy((void *)((int)&ptVar1[1].lenpad + 2),__src,6); + uVar2 = vif_info_tab[uVar4].type; + *(undefined *)&ptVar1[1].length = 200; + if (uVar2 == '\0') { + *(undefined *)((int)&ptVar1[1].length + 1) = 1; + __src = &sta_info_tab[iVar3].mac_addr; + } + else { + *(undefined *)((int)&ptVar1[1].length + 1) = 2; + } + memcpy(&ptVar1[1].next,__src,6); + *(char *)&ptVar1[1].dma_desc[0].src = (char)qos; + *(undefined *)((int)&ptVar1[1].txdesc + 2) = 0; + *(undefined *)((int)&ptVar1[1].txdesc + 3) = 0; + *(undefined *)((int)&ptVar1[1].dma_desc[0].src + 1) = (char)(qos >> 8); + (frame->cfm).cfm_func = cfm; + (frame->cfm).env = env; + uVar2 = sta_info_tab[iVar3].inst_nbr; + (frame->txdesc).host.staid = sta_idx; + (frame->txdesc).host.vif_idx = uVar2; + txl_frame_push(frame,'\x03'); + uVar2 = '\0'; + } + return uVar2; +} + + + +uint8_t txl_frame_send_eapol_frame + (uint8_t sta_idx,cfm_func_ptr *cfm,void *cfm_env,uint8_t *pBuf,uint32_t pBuf_len) + +{ + byte bVar1; + uint8_t uVar2; + ushort uVar3; + undefined2 uVar4; + txl_buffer_tag *ptVar5; + undefined3 in_register_00002029; + txl_frame_desc_tag *frame; + key_info_tag *pkVar6; + uint32_t uVar7; + undefined *puVar8; + int iVar9; + tx_hw_desc *ptVar10; + uint16_t uVar11; + uint uVar12; + dma_desc *pdVar13; + uint uVar14; + dma_desc *unaff_s8; + mac_addr_conflict *pmVar15; + mac_addr_conflict *pmVar16; + uint uVar17; + int iVar18; + char acStack88 [4]; + phy_channel_info phy_info; + mic_calc mic; + + iVar18 = CONCAT31(in_register_00002029,sta_idx); + bVar1 = sta_info_tab[iVar18].inst_nbr; + uVar17 = (uint)bVar1; + phy_get_channel((phy_channel_info *)acStack88,'\0'); + frame = txl_frame_get((uint)(acStack88[0] != '\0'),0x100); + if (frame == (txl_frame_desc_tag *)0x0) { + return '\0'; + } + (frame->txdesc).host.vif_idx = bVar1; + (frame->txdesc).host.staid = sta_idx; + (frame->txdesc).host.tid = '\0'; + uVar3 = sta_info_tab[iVar18].seq_nbr[0]; + sta_info_tab[iVar18].seq_nbr[0] = (ushort)(((uint)uVar3 + 1) * 0x100000 >> 0x14); + (frame->txdesc).host.ethertype = 0x8e88; + (frame->txdesc).host.sn = uVar3; + pmVar15 = &sta_info_tab[iVar18].mac_addr; + (frame->txdesc).host.eth_dest_addr.array[0] = pmVar15->array[0]; + (frame->txdesc).host.eth_dest_addr.array[1] = sta_info_tab[iVar18].mac_addr.array[1]; + (frame->txdesc).host.eth_dest_addr.array[2] = sta_info_tab[iVar18].mac_addr.array[2]; + pmVar16 = &vif_info_tab[uVar17].mac_addr; + (frame->txdesc).host.eth_src_addr.array[0] = pmVar16->array[0]; + (frame->txdesc).host.eth_src_addr.array[1] = vif_info_tab[uVar17].mac_addr.array[1]; + (frame->txdesc).host.eth_src_addr.array[2] = vif_info_tab[uVar17].mac_addr.array[2]; + tpc_update_frame_tx_power(vif_info_tab + uVar17,frame); + ptVar5 = (frame->txdesc).lmac.buffer; + if ((vif_info_tab[uVar17].bss_info.valid_flags & 1) == 0) { + *(undefined *)&ptVar5[1].length = 8; + uVar14 = (uint)txl_cntrl_env.seqnbr; + *(undefined *)((int)&ptVar5[1].length + 1) = 0; + pdVar13 = ptVar5[1].dma_desc; + txl_cntrl_env.seqnbr = (uint16_t)((uVar14 + 1) * 0x10000 >> 0x10); + iVar9 = (uVar14 + 1) * 0x100000; + *(undefined *)((int)&ptVar5[1].txdesc + 2) = (char)((uint)iVar9 >> 0x10); + *(undefined *)((int)&ptVar5[1].txdesc + 3) = (char)((uint)iVar9 >> 0x18); + uVar14 = pBuf_len + 0x20; + } + else { + *(undefined *)&ptVar5[1].length = 0x88; + *(undefined *)((int)&ptVar5[1].length + 1) = 0; + pdVar13 = (dma_desc *)((int)&ptVar5[1].dma_desc[0].src + 2); + uVar14 = pBuf_len + 0x22; + iVar9 = (uint)(frame->txdesc).host.sn << 0x14; + *(undefined *)((int)&ptVar5[1].txdesc + 2) = (char)((uint)iVar9 >> 0x10); + *(undefined *)((int)&ptVar5[1].txdesc + 3) = (char)((uint)iVar9 >> 0x18); + uVar2 = (frame->txdesc).host.tid; + *(undefined *)((int)&ptVar5[1].dma_desc[0].src + 1) = 0; + *(uint8_t *)&ptVar5[1].dma_desc[0].src = uVar2; + } + if (0x100 < uVar14) { + assert_err("length<=NX_TXFRAME_LEN","module",0x591); + } + uVar4 = *(undefined2 *)&ptVar5[1].length; + bVar1 = 1; + if (vif_info_tab[uVar17].type == '\x02') { + bVar1 = 2; + } + *(char *)&ptVar5[1].length = (char)uVar4; + *(byte *)((int)&ptVar5[1].length + 1) = (byte)((ushort)uVar4 >> 8) | bVar1; + *(undefined *)((int)&ptVar5[1].length + 2) = 0; + *(undefined *)((int)&ptVar5[1].length + 3) = 0; + *(uint16_t *)&ptVar5[1].lenheader = pmVar15->array[0]; + *(uint16_t *)((int)&ptVar5[1].lenheader + 2) = sta_info_tab[iVar18].mac_addr.array[1]; + *(uint16_t *)&ptVar5[1].lenpad = sta_info_tab[iVar18].mac_addr.array[2]; + *(uint16_t *)((int)&ptVar5[1].lenpad + 2) = pmVar16->array[0]; + *(uint16_t *)&ptVar5[1].flags = vif_info_tab[uVar17].mac_addr.array[1]; + *(uint16_t *)((int)&ptVar5[1].flags + 2) = vif_info_tab[uVar17].mac_addr.array[2]; + if (vif_info_tab[uVar17].type == '\x02') { + *(uint16_t *)&ptVar5[1].next = pmVar16->array[0]; + *(uint16_t *)((int)&ptVar5[1].next + 2) = vif_info_tab[uVar17].mac_addr.array[1]; + uVar11 = vif_info_tab[uVar17].mac_addr.array[2]; + } + else { + *(uint16_t *)&ptVar5[1].next = pmVar15->array[0]; + *(uint16_t *)((int)&ptVar5[1].next + 2) = sta_info_tab[iVar18].mac_addr.array[1]; + uVar11 = sta_info_tab[iVar18].mac_addr.array[2]; + } + *(uint16_t *)&ptVar5[1].txdesc = uVar11; + iVar18 = 0; + if ((vif_info_tab[(frame->txdesc).host.vif_idx].type != '\0') || + (uVar17 = (uint)(frame->txdesc).host.staid, sta_info_tab[uVar17].ctrl_port_state != '\x02')) + goto LAB_2304aa3c; + pkVar6 = *sta_info_tab[uVar17].sta_sec_info.cur_key; + uVar2 = pkVar6->cipher; + if (uVar2 == '\x01') { + uVar17 = *(uint *)&pkVar6->tx_pn + 1; + *(int *)((int)&pkVar6->tx_pn + 4) = + (uint)(uVar17 < *(uint *)&pkVar6->tx_pn) + *(int *)((int)&pkVar6->tx_pn + 4); + *(uint *)&pkVar6->tx_pn = uVar17; + memcpy((frame->txdesc).host.pn,&pkVar6->tx_pn,6); + iVar9 = 0xc; +LAB_2304ab94: + iVar18 = 8; + } + else { + if (uVar2 == '\0') { +LAB_2304a976: + uVar17 = *(uint *)&pkVar6->tx_pn + 1; + *(int *)((int)&pkVar6->tx_pn + 4) = + (uint)(uVar17 < *(uint *)&pkVar6->tx_pn) + *(int *)((int)&pkVar6->tx_pn + 4); + *(uint *)&pkVar6->tx_pn = uVar17; + memcpy((frame->txdesc).host.pn,&pkVar6->tx_pn,4); + iVar9 = 4; + iVar18 = 4; + } + else { + if (uVar2 == '\x02') { + uVar17 = *(uint *)&pkVar6->tx_pn + 1; + *(int *)((int)&pkVar6->tx_pn + 4) = + (uint)(uVar17 < *(uint *)&pkVar6->tx_pn) + *(int *)((int)&pkVar6->tx_pn + 4); + *(uint *)&pkVar6->tx_pn = uVar17; + memcpy((frame->txdesc).host.pn,&pkVar6->tx_pn,6); + iVar9 = 8; + goto LAB_2304ab94; + } + if (uVar2 == '\x03') goto LAB_2304a976; + iVar9 = 0; + iVar18 = 0; + } + } + iVar18 = iVar18 + iVar9; + if (iVar18 == 0) goto LAB_2304aa3c; + uVar3 = *(ushort *)&ptVar5[1].length; + uVar14 = uVar14 + iVar18; + *(char *)&ptVar5[1].length = (char)uVar3; + *(byte *)((int)&ptVar5[1].length + 1) = (byte)((uint)uVar3 >> 8) | 0x40; + uVar17 = (uint)vif_info_tab[(frame->txdesc).host.vif_idx].type; + if (vif_info_tab[(frame->txdesc).host.vif_idx].type == 0) { + uVar12 = (uint)(frame->txdesc).host.staid; + if (sta_info_tab[uVar12].ctrl_port_state == '\x02') { + pkVar6 = *sta_info_tab[uVar12].sta_sec_info.cur_key; + uVar7 = (((frame->txdesc).lmac.hw_desc)->thd).policyentryaddr; + uVar2 = pkVar6->cipher; + if (uVar2 == '\x01') { + uVar3 = (frame->txdesc).host.pn[0]; + *(ushort *)&pdVar13->src = uVar3 & 0x7f00 | 0x2000 | uVar3 >> 8; + uVar3 = (ushort)*(byte *)(frame->txdesc).host.pn | (ushort)pkVar6->key_idx << 0xe; +LAB_2304abec: + *(ushort *)((int)&pdVar13->src + 2) = uVar3 | 0x2000; + uVar17 = 8; + *(uint16_t *)&pdVar13->dest = (frame->txdesc).host.pn[1]; + *(uint16_t *)((int)&pdVar13->dest + 2) = (frame->txdesc).host.pn[2]; + } + else { + if (uVar2 == '\0') { +LAB_2304aa0a: + *(uint16_t *)&pdVar13->src = (frame->txdesc).host.pn[0]; + *(ushort *)((int)&pdVar13->src + 2) = + (ushort)pkVar6->key_idx << 0xe | (frame->txdesc).host.pn[1]; + uVar17 = 4; + } + else { + if (uVar2 == '\x02') { + *(uint16_t *)&pdVar13->src = (frame->txdesc).host.pn[0]; + uVar3 = (ushort)pkVar6->key_idx << 0xe; + goto LAB_2304abec; + } + if (uVar2 == '\x03') goto LAB_2304aa0a; + } + } + *(uint *)(uVar7 + 0xc) = *(uint *)(uVar7 + 0xc) & 0xffc00 | (uint)pkVar6->hw_key_idx; + } + } + else { + uVar17 = 0; + } + pdVar13 = (dma_desc *)((int)&pdVar13->src + uVar17); + unaff_s8 = pdVar13; +LAB_2304aa3c: + *(undefined2 *)&pdVar13->src = 0xaaaa; + *(undefined2 *)((int)&pdVar13->src + 2) = 3; + *(undefined2 *)&pdVar13->dest = 0; + *(uint16_t *)((int)&pdVar13->dest + 2) = (frame->txdesc).host.ethertype; + memcpy(&pdVar13->length,pBuf,pBuf_len); + if ((iVar18 != 0) && + (pkVar6 = *sta_info_tab[(frame->txdesc).host.staid].sta_sec_info.cur_key, + pkVar6->cipher == '\x01')) { + me_mic_init((mic_calc *)&phy_info.info2,(uint32_t *)pkVar6->u, + (mac_addr_conflict51 *)&(frame->txdesc).host.eth_dest_addr, + (mac_addr_conflict51 *)&(frame->txdesc).host.eth_src_addr,(frame->txdesc).host.tid); + me_mic_calc((mic_calc *)&phy_info.info2,(uint32_t)unaff_s8,pBuf_len + 8); + me_mic_end((mic_calc *)&phy_info.info2); + iVar18 = 0; + do { + puVar8 = (undefined *)((int)&phy_info.info2 + iVar18); + iVar9 = iVar18 + pBuf_len + 8; + iVar18 = iVar18 + 1; + *(undefined *)((int)&unaff_s8->length + iVar9 + -8) = *puVar8; + } while (iVar18 != 8); + } + ptVar10 = (frame->txdesc).lmac.hw_desc; + (ptVar10->thd).field_5 = (ptVar10->thd).field_4 + -1 + uVar14; + (ptVar10->thd).frmlen = uVar14 + 4; + if (cfm != (cfm_func_ptr *)0x0) { + (frame->cfm).cfm_func = cfm; + (frame->cfm).env = cfm_env; + } + txl_frame_push(frame,"\x01"[(frame->txdesc).host.tid]); + return '\0'; +} + + + +void txl_frame_dump(void) + +{ + uint32_t uVar1; + co_list_hdr cVar2; + co_list_hdr cVar3; + + uVar1 = co_list_cnt((co_list *)&txl_frame_env); + cVar2 = (co_list_hdr)txl_frame_env.desc_free.first; + if (uVar1 != 0) { + while (cVar3 = (co_list_hdr)txl_frame_env.desc_done.first, cVar2 != (co_list_hdr)0x0) { + cVar2 = *(co_list_hdr *)cVar2; + } + while (cVar3 != (co_list_hdr)0x0) { + cVar3 = *(co_list_hdr *)cVar3; + } + } + return; +} + + + +void txl_hwdesc_init(void) + +{ + return; +} + + + +void txl_hwdesc_reset(void) + +{ + return; +} + + + +void vif_mgmt_bcn_to_evt(void *env) + +{ + if (*(int *)((int)env + 0x40) != 0) { + chan_bcn_to_evt((vif_info_tag *)env); + return; + } + return; +} + + + +void vif_mgmt_init(void) + +{ + memset(&vif_mgmt_env,0,0x14); + co_list_init((co_list *)&vif_mgmt_env); + co_list_init(&vif_mgmt_env.used_list); + memset(vif_info_tab,0,0x5d8); + vif_info_tab[0].type = '\x04'; + vif_info_tab[0].tx_power = '\x7f'; + vif_info_tab[0].user_tx_power = '\x7f'; + vif_info_tab[0].tmr_bcn_to.cb = vif_mgmt_bcn_to_evt; + vif_info_tab[0].tmr_bcn_to.env = vif_info_tab; + co_list_push_back((co_list *)&vif_mgmt_env,(co_list_hdr *)vif_info_tab); + memset(vif_info_tab + 1,0,0x5d8); + vif_info_tab[1].type = '\x04'; + vif_info_tab[1].tx_power = '\x7f'; + vif_info_tab[1].user_tx_power = '\x7f'; + vif_info_tab[1].tmr_bcn_to.cb = vif_mgmt_bcn_to_evt; + vif_info_tab[1].tmr_bcn_to.env = vif_info_tab + 1; + co_list_push_back((co_list *)&vif_mgmt_env,(co_list_hdr *)(vif_info_tab + 1)); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t vif_mgmt_register(mac_addr_conflict38 *mac_addr,uint8_t vif_type,_Bool p2p,uint8_t *vif_idx) + +{ + uint8_t uVar1; + vif_info_tag *vif_entry; + undefined3 in_register_0000202d; + + if (vif_mgmt_env.free_list.first == (co_list_hdr *)0x0) { + uVar1 = '\x01'; + } + else { + if (vif_mgmt_env.used_list.first == (co_list_hdr *)0x0) { + mm_hw_info_set((mac_addr_conflict171 *)mac_addr); + } + else { + if (*(int *)mac_addr->array != _DAT_44b00010) { + return '\x01'; + } + if (((mac_addr->array[2] ^ _DAT_44b00014) & ~_DAT_44b0001c) != 0) { + return '\x01'; + } + mm_env.rx_filter_lmac_enable = mm_env.rx_filter_lmac_enable | 0x10; + _DAT_44b00060 = mm_env.rx_filter_lmac_enable | mm_env.rx_filter_umac; + } + vif_entry = (vif_info_tag *)co_list_pop_front((co_list *)&vif_mgmt_env); + vif_entry->type = vif_type; + memcpy(&vif_entry->mac_addr,mac_addr,6); + uVar1 = (char)((int)(vif_entry[-0xb4b98].u + 0x2ec) >> 3) * 's'; + vif_entry->txq_params[1] = 0xa43; + vif_entry->txq_params[2] = 0x5e432; + vif_entry->index = uVar1; + vif_entry->txq_params[0] = 0xa47; + vif_entry->txq_params[3] = 0x2f322; + vif_entry->chan_ctxt = (chan_ctxt_tag *)0x0; + (vif_entry->tbtt_switch).vif_index = uVar1; + if (CONCAT31(in_register_0000202d,vif_type) == 0) { + *(vif_info_tag **)&(vif_entry->tbtt_timer).env = vif_entry; + vif_entry->u[0x1d] = 0; + vif_mgmt_env.vif_sta_cnt = vif_mgmt_env.vif_sta_cnt + '\x01'; + (vif_entry->tbtt_timer).cb = mm_sta_tbtt; + vif_entry->u[4] = 0xff; + vif_entry->u[0x1e] = 0; + } + else { + if (CONCAT31(in_register_0000202d,vif_type) == 2) { + if (vif_mgmt_env.vif_ap_cnt == '\0') { + mm_hw_ap_info_set(); + } + vif_mgmt_env.vif_ap_cnt = vif_mgmt_env.vif_ap_cnt + '\x01'; + mm_bcn_init_vif(vif_entry); + } + } + td_start(vif_entry->index); + *vif_idx = vif_entry->index; + co_list_push_back(&vif_mgmt_env.used_list,(co_list_hdr *)vif_entry); + uVar1 = '\0'; + } + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void vif_mgmt_unregister(uint8_t vif_idx) + +{ + vif_info_tag *__s; + undefined3 in_register_00002029; + int iVar1; + + iVar1 = CONCAT31(in_register_00002029,vif_idx); + __s = vif_info_tab + iVar1; + co_list_extract(&vif_mgmt_env.used_list,(co_list_hdr *)__s); + if (vif_info_tab[iVar1].type == '\0') { + vif_mgmt_env.vif_sta_cnt = vif_mgmt_env.vif_sta_cnt + -1; + } + else { + if (vif_info_tab[iVar1].type == '\x02') { + vif_mgmt_env.vif_ap_cnt = vif_mgmt_env.vif_ap_cnt + -1; + if (vif_mgmt_env.vif_ap_cnt == '\0') { + mm_hw_ap_info_reset(); + } + } + } + if ((uint)vif_mgmt_env.vif_ap_cnt + (uint)vif_mgmt_env.vif_sta_cnt == 1) { + mm_env.rx_filter_lmac_enable = mm_env.rx_filter_lmac_enable & 0xffffffef; + _DAT_44b00060 = mm_env.rx_filter_lmac_enable | mm_env.rx_filter_umac; + _DAT_44b00020 = vif_mgmt_env.used_list.first[0xe].next; + _DAT_44b00024 = (uint)*(ushort *)&vif_mgmt_env.used_list.first[0xf].next; + } + if (vif_info_tab[iVar1].type == '\x02') { + txl_cntrl_clear_bcn_ac(); + } + mm_timer_clear(&vif_info_tab[iVar1].tbtt_timer); + mm_timer_clear(&vif_info_tab[iVar1].tmr_bcn_to); + td_reset(vif_info_tab[iVar1].index); + memset(__s,0,0x5d8); + vif_info_tab[iVar1].type = '\x04'; + vif_info_tab[iVar1].tx_power = '\x7f'; + vif_info_tab[iVar1].user_tx_power = '\x7f'; + vif_info_tab[iVar1].tmr_bcn_to.cb = vif_mgmt_bcn_to_evt; + *(vif_info_tag **)&vif_info_tab[iVar1].tmr_bcn_to.env = __s; + co_list_push_back((co_list *)&vif_mgmt_env,(co_list_hdr *)__s); + return; +} + + + +void vif_mgmt_add_key(mm_key_add_req *param,uint8_t hw_key_idx) + +{ + uint8_t uVar1; + uint uVar2; + uint uVar3; + + uVar3 = (uint)param->inst_nbr; + uVar2 = (uint)param->key_idx; + vif_info_tab[uVar3].key_info[uVar2].hw_key_idx = hw_key_idx; + vif_info_tab[uVar3].key_info[uVar2].cipher = param->cipher_suite; + vif_info_tab[uVar3].key_info[uVar2].key_idx = param->key_idx; + memset(vif_info_tab[uVar3].key_info + uVar2,0,0x48); + uVar1 = vif_info_tab[uVar3].key_info[uVar2].cipher; + if (uVar1 == '\x01') { + *(undefined4 *)&vif_info_tab[uVar3].key_info[uVar2].tx_pn = 0; + *(undefined4 *)((int)&vif_info_tab[uVar3].key_info[uVar2].tx_pn + 4) = 0; + *(uint32_t *)vif_info_tab[uVar3].key_info[uVar2].u = (param->key).array[4]; + *(uint32_t *)(vif_info_tab[uVar3].key_info[uVar2].u + 4) = (param->key).array[5]; + *(uint32_t *)(vif_info_tab[uVar3].key_info[uVar2].u + 8) = (param->key).array[6]; + *(uint32_t *)(vif_info_tab[uVar3].key_info[uVar2].u + 0xc) = (param->key).array[7]; + } + else { + if ((uVar1 == '\0') || (uVar1 == '\x03')) { + next = next * 0x41c64e6d + 0x3039; + *(__uint32_t *)&vif_info_tab[uVar3].key_info[uVar2].tx_pn = next >> 0x10; + *(undefined4 *)((int)&vif_info_tab[uVar3].key_info[uVar2].tx_pn + 4) = 0; + } + else { + *(undefined4 *)&vif_info_tab[uVar3].key_info[uVar2].tx_pn = 0; + *(undefined4 *)((int)&vif_info_tab[uVar3].key_info[uVar2].tx_pn + 4) = 0; + } + } + vif_info_tab[uVar3].key_info[uVar2].valid = true; + vif_info_tab[uVar3].default_key = vif_info_tab[uVar3].key_info + uVar2; + return; +} + + + +void vif_mgmt_del_key(vif_info_tag *vif,uint8_t keyid) + +{ + undefined3 in_register_0000202d; + _Bool *p_Var1; + int iVar2; + + vif->key_info[CONCAT31(in_register_0000202d,keyid)].valid = false; + if (vif->default_key == vif->key_info + CONCAT31(in_register_0000202d,keyid)) { + vif->default_key = (key_info_tag *)0x0; + p_Var1 = &vif->key_info[0].valid; + iVar2 = 0; + do { + if (*p_Var1 != false) { + vif->default_key = vif->key_info + iVar2; + return; + } + iVar2 = iVar2 + 1; + p_Var1 = p_Var1 + 0x68; + } while (iVar2 != 4); + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void vif_mgmt_send_postponed_frame(vif_info_tag *p_vif_entry) + +{ + sta_info_tag *p_sta_entry; + + p_sta_entry = (sta_info_tag *)(p_vif_entry->sta_list).first; + while (p_sta_entry != (sta_info_tag *)0x0) { + sta_mgmt_send_postponed_frame(p_vif_entry,p_sta_entry,0); + p_sta_entry = *(sta_info_tag **)&p_sta_entry->list_hdr; + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void vif_mgmt_reset(void) + +{ + vif_info_tag *p_vif_entry; + + p_vif_entry = (vif_info_tag *)vif_mgmt_env.used_list.first; + while (p_vif_entry != (vif_info_tag *)0x0) { + vif_mgmt_send_postponed_frame(p_vif_entry); + p_vif_entry = *(vif_info_tag **)&p_vif_entry->list_hdr; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void vif_mgmt_bcn_to_prog(vif_info_tag *p_vif_entry) + +{ + mm_timer_set(&p_vif_entry->tmr_bcn_to,_DAT_44b00120 + 10000); + return; +} + + + +void vif_mgmt_bcn_recv(vif_info_tag *p_vif_entry) + +{ + if (((ps_env.ps_on != false) && ((ps_env.prevent_sleep & 8) == 0)) && + (p_vif_entry->prevent_sleep == 0)) { + mm_timer_clear(&p_vif_entry->tmr_bcn_to); + vif_mgmt_bcn_to_evt(p_vif_entry); + return; + } + return; +} + + +/* +Unable to decompile 'vif_mgmt_set_ap_bcn_int' +Cause: Exception while decompiling 2304b1b4: Decompiler process died + +*/ + + +// WARNING: Variable defined which should be unmapped: chan_idx +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void vif_mgmt_switch_channel(vif_info_tag *p_vif_entry) + +{ + byte bVar1; + uint16_t freq; + uint8_t uVar2; + void *pvVar3; + scan_chan_tag *psVar4; + undefined3 extraout_var; + uint8_t chan_idx_00; + uint8_t local_11 [4]; + uint8_t chan_idx; + + pvVar3 = ke_msg_alloc(0x58,0xd,0,3); + local_11[0] = -1; + chan_ctxt_unlink(p_vif_entry->index); + freq = (p_vif_entry->csa_channel).prim20_freq; + chan_idx_00 = (uint8_t)freq; + psVar4 = me_freq_to_chan_ptr((p_vif_entry->csa_channel).band,freq); + freq = (p_vif_entry->csa_channel).center1_freq; + (p_vif_entry->bss_info).chan = psVar4; + (p_vif_entry->bss_info).center_freq1 = freq; + (p_vif_entry->bss_info).center_freq2 = (p_vif_entry->csa_channel).center2_freq; + uVar2 = (p_vif_entry->csa_channel).type; + (p_vif_entry->bss_info).phy_bw = uVar2; + if (uVar2 == '\x04') { + uVar2 = '\x03'; + } + (p_vif_entry->bss_info).bw = uVar2; + if (psVar4 == (scan_chan_tag *)0x0) { + ebreak(); + } + else { + (p_vif_entry->csa_channel).tx_power = psVar4->tx_power; + uVar2 = chan_ctxt_add(&p_vif_entry->csa_channel,local_11); + psVar4 = (scan_chan_tag *)CONCAT31(extraout_var,uVar2); + *(uint8_t *)((int)pvVar3 + 1) = uVar2; + *(uint8_t *)((int)pvVar3 + 2) = local_11[0]; + chan_idx_00 = local_11[0]; + if (p_vif_entry->type != '\0') { + if ((p_vif_entry->type == '\x02') && + (p_vif_entry->u[0x2eb] = 0, psVar4 == (scan_chan_tag *)0x0)) { + chan_ctxt_link(p_vif_entry->index,local_11[0]); + mm_bcn_env.update_ongoing = true; + } + goto LAB_2304b332; + } + } + p_vif_entry->u[0x1d] = 0; + if (psVar4 == (scan_chan_tag *)0x0) { + bVar1 = p_vif_entry->u[4]; + chan_ctxt_link(p_vif_entry->index,chan_idx_00); + mm_timer_clear(&p_vif_entry->tmr_bcn_to); + mm_timer_set(&p_vif_entry->tbtt_timer,_DAT_44b00120 + sta_info_tab[bVar1].bcn_int); + p_vif_entry->u[0x18] = 0; + p_vif_entry->u[0x1e] = 1; + } + else { + mm_send_connection_loss_ind(p_vif_entry); + } +LAB_2304b332: + ke_msg_send(pvVar3); + return; +} + + + +vif_info_tag * vif_mgmt_get_first_ap_inf(void) + +{ + co_list_hdr cVar1; + co_list_hdr cVar2; + + cVar1 = (co_list_hdr)vif_mgmt_env.used_list.first; + cVar2 = (co_list_hdr)0x0; + if (vif_mgmt_env.vif_ap_cnt != '\0') { + while ((cVar2 = cVar1, cVar1 != (co_list_hdr)0x0 && (*(char *)((int)cVar1 + 0x56) != '\x02'))) { + cVar1 = *(co_list_hdr *)cVar1; + } + } + return (vif_info_tag *)cVar2; +} + + + +void me_init(void) + +{ + memset(&me_env,0,0x134); + ke_state_set(5,0); + scanu_init(); + apm_init(); + sm_init(); + bam_init(); + return; +} + + + +scan_chan_tag * me_freq_to_chan_ptr(uint8_t band,uint16_t freq) + +{ + int iVar1; + byte bVar2; + ushort *puVar3; + undefined3 in_register_00002029; + scan_chan_tag *psVar4; + undefined2 in_register_0000202e; + scan_chan_tag *psVar5; + + if (CONCAT31(in_register_00002029,band) == 0) { + iVar1 = -0x714; + bVar2 = me_env.chan.chan2G4_cnt; + } + else { + iVar1 = -0x6c0; + bVar2 = me_env.chan.chan5G_cnt; + } + psVar5 = (scan_chan_tag *)(ke_mem_heap + iVar1 + 0x290); + do { + if (psVar5 == (scan_chan_tag *)(ke_mem_heap + iVar1 + 0x290) + bVar2) { + return (scan_chan_tag *)0x0; + } + psVar4 = psVar5; + puVar3 = &psVar5->freq; + psVar5 = psVar5 + 1; + } while ((uint)*puVar3 != CONCAT22(in_register_0000202e,freq)); + return psVar4; +} + + + +void michael_block(mic_calc *mic_calc_ptr,uint32_t block) + +{ + uint uVar1; + uint uVar2; + + uVar1 = block ^ mic_calc_ptr->mic_key_least; + uVar2 = mic_calc_ptr->mic_key_most ^ (uVar1 >> 0xf | uVar1 << 0x11); + uVar1 = uVar1 + uVar2; + uVar2 = (uVar1 >> 8 & 0xff00ff | uVar1 * 0x100 & 0xff00ff00) ^ uVar2; + uVar1 = uVar1 + uVar2; + uVar2 = (uVar1 * 8 | uVar1 >> 0x1d) ^ uVar2; + uVar1 = uVar1 + uVar2; + uVar2 = (uVar1 >> 2 | uVar1 * 0x40000000) ^ uVar2; + mic_calc_ptr->mic_key_most = uVar2; + mic_calc_ptr->mic_key_least = uVar1 + uVar2; + return; +} + + + +void me_mic_init(mic_calc *mic_calc_ptr,uint32_t *mic_key_ptr,mac_addr_conflict51 *da, + mac_addr_conflict51 *sa,uint8_t tid) + +{ + uint32_t block; + uint16_t uVar1; + uint16_t uVar2; + uint32_t block_00; + undefined3 in_register_00002039; + uint32_t uVar3; + uint32_t block_01; + + block = *(uint32_t *)da->array; + block_01 = (uint)tid & 7; + uVar1 = sa->array[0]; + uVar2 = da->array[2]; + block_00 = *(uint32_t *)(sa->array + 1); + if (CONCAT31(in_register_00002039,tid) == 0xff) { + block_01 = 0; + } + mic_calc_ptr->mic_key_least = *mic_key_ptr; + uVar3 = mic_key_ptr[1]; + mic_calc_ptr->last_m_i = 0; + mic_calc_ptr->mic_key_most = uVar3; + mic_calc_ptr->last_m_i_len = '\0'; + michael_block(mic_calc_ptr,block); + michael_block(mic_calc_ptr,CONCAT22(uVar1,uVar2)); + michael_block(mic_calc_ptr,block_00); + michael_block(mic_calc_ptr,block_01); + return; +} + + + +void me_mic_calc(mic_calc *mic_calc_ptr,uint32_t start_ptr,uint32_t data_len) + +{ + uint8_t uVar1; + uint block; + uint block_00; + uint uVar2; + uint uVar3; + uint *puVar4; + uint uVar5; + uint uVar6; + uint *puVar7; + uint uVar8; + + puVar7 = (uint *)(start_ptr & 0xfffffffc) + 1; + block = 4 - (start_ptr & 3) & 0xff; + uVar3 = (uint)mic_calc_ptr->last_m_i_len; + uVar2 = *(uint *)(start_ptr & 0xfffffffc) >> ((start_ptr & 3) << 3); + uVar8 = data_len - block; + if (data_len < block) { + uVar2 = uVar2 & 0xffffffffU >> ((4 - data_len) * 8 & 0x1f); + block = data_len & 0xff; + uVar8 = 0; + } + block = block + uVar3; + block_00 = uVar2 << ((uVar3 & 3) << 3) | mic_calc_ptr->last_m_i; + uVar6 = block_00; + if (3 < block) { + uVar3 = (4 - uVar3) * 8; + uVar6 = 0; + if (uVar3 != 0x20) { + uVar6 = uVar2 >> (uVar3 & 0x1f); + } + block = block - 4; + michael_block(mic_calc_ptr,block_00); + } + uVar1 = (uint8_t)block; + uVar2 = (4 - block) * 8; + uVar3 = 0; + puVar4 = puVar7; + while (uVar8 >> 2 != uVar3) { + uVar5 = *puVar4; + puVar4 = puVar4 + 1; + block_00 = uVar5 << (block << 3 & 0x1f) | uVar6; + uVar6 = 0; + if (uVar2 != 0x20) { + uVar6 = uVar5 >> (uVar2 & 0x1f); + } + michael_block(mic_calc_ptr,block_00); + uVar3 = uVar3 + 1; + } + if ((uVar8 & 0xfffffffc) < uVar8) { + block_00 = (4 - (uVar8 & 3)) * 8; + uVar3 = 0; + if (block_00 != 0x20) { + uVar3 = 0xffffffff >> (block_00 & 0x1f); + } + uVar3 = *(uint *)((int)puVar7 + (uVar8 & 0xfffffffc)) & uVar3; + uVar8 = block + (uVar8 & 3); + uVar1 = (uint8_t)uVar8; + block = uVar6 | uVar3 << (block << 3 & 0x1f); + uVar6 = block; + if (3 < uVar8) { + uVar6 = 0; + if (uVar2 != 0x20) { + uVar6 = uVar3 >> (uVar2 & 0x1f); + } + uVar1 = uVar1 + -4; + michael_block(mic_calc_ptr,block); + } + } + mic_calc_ptr->last_m_i_len = uVar1; + mic_calc_ptr->last_m_i = uVar6; + return; +} + + + +void me_mic_end(mic_calc *mic_calc_ptr) + +{ + uint uVar1; + + uVar1 = mic_calc_ptr->last_m_i; + if (3 < mic_calc_ptr->last_m_i_len) { + assert_err("mic_calc_ptr->last_m_i_len < 4","module",0x13e); + } + michael_block(mic_calc_ptr,0x5a << (((uint)mic_calc_ptr->last_m_i_len & 3) << 3) | uVar1); + michael_block(mic_calc_ptr,0); + return; +} + + + +uint8_t rxu_cntrl_machdr_len_get(uint16_t frame_cntl) + +{ + uint8_t uVar1; + + uVar1 = '\x18'; + if ((frame_cntl & 0x300) == 0x300) { + uVar1 = '\x1e'; + } + if ((frame_cntl & 0xfc) == 0x88) { + uVar1 = uVar1 + '\x02'; + } + if ((short)frame_cntl < 0) { + uVar1 = uVar1 + '\x04'; + } + return uVar1; +} + + + +_Bool rxu_cntrl_protected_handle(uint8_t *frame,uint32_t statinfo) + +{ + ushort *puVar1; + uint uVar2; + vif_info_tag *pvVar3; + int iVar4; + + uVar2 = statinfo & 0x1c; + puVar1 = (ushort *)(frame + DAT_4201cae8); + if (uVar2 == 0x18) { + DAT_4201cae8 = DAT_4201cae8 + 8; + DAT_4201caf4 = (uint)puVar1[3]; + DAT_4201caf0 = (uint)puVar1[2] << 0x10 | (uint)*(byte *)(puVar1 + 1) | + ((uint)*puVar1 & 0xff) << 8; + DAT_4201cb10 = DAT_4201cb10 | 3; + if ((statinfo & 0x400) == 0) { + iVar4 = (uint)DAT_4201cae9 * 0x1b0 + 0x40; + pvVar3 = (vif_info_tag *)sta_info_tab; + } + else { + iVar4 = (uint)(puVar1[1] >> 0xe) * 0x68 + (uint)DAT_4201caea * 0x5d8 + 0x420; + pvVar3 = vif_info_tab; + } + key = (key_info_tag *)((int)&(pvVar3->list_hdr).next + iVar4); + } + else { + if (uVar2 == 0x1c) { + if ((statinfo & 0x400) == 0) { + iVar4 = (uint)DAT_4201cae9 * 0x1b0 + 0x40; + pvVar3 = (vif_info_tag *)sta_info_tab; + } + else { + iVar4 = (uint)(puVar1[1] >> 0xe) * 0x68 + (uint)DAT_4201caea * 0x5d8 + 0x420; + pvVar3 = vif_info_tab; + } + key = (key_info_tag *)((int)&(pvVar3->list_hdr).next + iVar4); + DAT_4201cae8 = DAT_4201cae8 + 8; + DAT_4201caf4 = (uint)puVar1[3]; + DAT_4201caf0 = CONCAT22(puVar1[2],*puVar1); + DAT_4201cb10 = DAT_4201cb10 | 2; + } + else { + if (uVar2 != 0x14) { + return false; + } + DAT_4201cae8 = DAT_4201cae8 + 4; + } + } + return true; +} + + +/* +Unable to decompile 'rxu_mpdu_upload_and_indicate' +Cause: Exception while decompiling 2304b7e6: Decompiler process died + +*/ + + +undefined4 rxu_mgt_frame_check(rx_swdesc *param_1,uint param_2) + +{ + char cVar1; + ushort length; + bool bVar2; + ushort uVar3; + int8_t iVar4; + ushort *bcn_addr; + ushort uVar5; + _Bool _Var6; + ke_state_t kVar7; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined2 *puVar8; + byte sta_idx; + byte bw; + uint8_t nss; + co_list_hdr cVar9; + char *pcVar10; + uint uVar11; + uint uVar12; + ke_task_id_t dest_id; + rx_dmadesc *prVar13; + uint uVar14; + vif_info_tag *vif; + int8_t iStack73; + phy_channel_info apStack72 [2]; + + sta_idx = (byte)param_2; + prVar13 = param_1->dma_hdrdesc; + iStack73 = '\0'; + bcn_addr = *(ushort **)((prVar13->hd).first_pbd_ptr + 0x18); + length = *bcn_addr; + if ((length & 0x400) != 0) { + return 1; + } + if ((*(byte *)(bcn_addr + 0xb) & 0xf) != 0) { + return 1; + } + if ((param_2 == 0xff) && (DAT_4201caea = 0xff, ((prVar13->hd).statinfo & 0x600) == 0)) { + cVar9 = (co_list_hdr)vif_mgmt_env.used_list.first; + if (((length == 0xb0) || (bVar2 = true, length == 0)) && + ((((bVar2 = true, *(char *)(bcn_addr + 2) == *(char *)(bcn_addr + 8) && + (*(char *)((int)bcn_addr + 5) == *(char *)((int)bcn_addr + 0x11))) && + (*(char *)(bcn_addr + 3) == *(char *)(bcn_addr + 9))) && + ((*(char *)((int)bcn_addr + 7) == *(char *)((int)bcn_addr + 0x13) && + (*(char *)(bcn_addr + 4) == *(char *)(bcn_addr + 10))))))) { + bVar2 = *(char *)((int)bcn_addr + 9) != *(char *)((int)bcn_addr + 0x15); + } + while (DAT_4201caea = sta_idx, cVar9 != (co_list_hdr)0x0) { + if (((*(char *)&((co_list_hdr *)((int)cVar9 + 0x50))->next == *(char *)(bcn_addr + 2)) && + (*(char *)((int)cVar9 + 0x51) == *(char *)((int)bcn_addr + 5))) && + ((*(char *)((int)cVar9 + 0x52) == *(char *)(bcn_addr + 3) && + (((*(char *)((int)cVar9 + 0x53) == *(char *)((int)bcn_addr + 7) && + (*(char *)&((co_list_hdr *)((int)cVar9 + 0x54))->next == *(char *)(bcn_addr + 4))) && + (*(char *)((int)cVar9 + 0x55) == *(char *)((int)bcn_addr + 9))))))) { + if (*(char *)((int)cVar9 + 0x56) == '\0') { + if (bVar2) { +LAB_2304ba24: + DAT_4201caea = *(byte *)((int)cVar9 + 0x57); + break; + } + } + else { + if ((*(char *)((int)cVar9 + 0x56) == '\x02') && (!bVar2)) goto LAB_2304ba24; + } + } + cVar9 = *(co_list_hdr *)cVar9; + } + } + phyif_utils_decode((phyif_utils_recvtable_t *)&(prVar13->hd).recvec1a,&iStack73); + iVar4 = iStack73; + bw = DAT_4201cae8; + uVar3 = *bcn_addr; + uVar14 = (uint)DAT_4201cae8; + uVar11 = (uint)DAT_4201caea; + length = (prVar13->hd).frmlen; + uVar12 = (uint)length; + if (DAT_4201caea == 0xff) { + if (param_2 != uVar11) { + DAT_4201caea = sta_info_tab[param_2].inst_nbr; + uVar11 = (uint)DAT_4201caea; + goto LAB_2304ba72; + } + nss = '\x04'; + vif = (vif_info_tag *)0x0; + } + else { +LAB_2304ba72: + vif = vif_info_tab + uVar11; + nss = vif_info_tab[uVar11].type; + } + uVar5 = uVar3 & 0xfc; + if (uVar5 == 0x50) { + if (vif == (vif_info_tag *)0x0) goto LAB_2304baae; + bVar2 = true; + dest_id = 4; + goto LAB_2304bbce; + } + if (uVar5 < 0x51) { + if (uVar5 == 0x20) { +LAB_2304bafc: + _Var6 = apm_embedded_enabled(vif); + if (CONCAT31(extraout_var,_Var6) == 0) { +LAB_2304baae: + rxu_mpdu_upload_and_indicate(param_1); + return 1; + } +LAB_2304bbca: + bVar2 = true; + dest_id = 7; + goto LAB_2304bbce; + } + if (uVar5 < 0x21) { + if ((uVar3 & 0xfc) == 0) goto LAB_2304bafc; + if (uVar5 != 0x10) goto LAB_2304baae; + } + else { + if (uVar5 != 0x30) { + if (uVar5 != 0x40) goto LAB_2304baae; + goto LAB_2304bafc; + } + } + if (nss != '\0') goto LAB_2304baae; + } + else { + if (uVar5 != 0xb0) { + if (0xb0 < uVar5) { + if (uVar5 != 0xc0) { + if ((uVar5 != 0xd0) || (pcVar10 = (char *)((int)bcn_addr + uVar14), param_2 == 0xff)) + goto LAB_2304baae; + cVar1 = *pcVar10; + if (cVar1 == '\a') { + if (pcVar10[1] == '\0') { + if ((sta_info_tab[param_2].info.capa_flags & 2) == 0) { + return 0; + } + bw = pcVar10[2]; + nss = -1; + if (1 < bw) { + return 0; + } + } + else { + if (pcVar10[1] != '\x01') goto LAB_2304baae; + if ((sta_info_tab[param_2].info.capa_flags & 2) == 0) { + return 0; + } + nss = -1; + if ((pcVar10[2] & 1U) != 0) { + nss = '\0'; + } + bw = 0xff; + } + me_sta_bw_nss_max_upd(sta_idx,bw,nss); + return 0; + } + if (cVar1 == '\b') { + if ((int)(uVar12 - uVar14) < 4) { + return 0; + } + if ((DAT_4201caea == 0xff) || + ((byte)(vif_info_tab[DAT_4201caea].type | pcVar10[1]) != 0)) goto LAB_2304baae; + dest_id = 6; + } + else { + if (cVar1 != '\x03') goto LAB_2304baae; + dest_id = 8; + } + bVar2 = false; + goto LAB_2304bbce; + } +LAB_2304bb22: + if (param_2 == 0xff) { + return 0; + } + goto LAB_2304bb2c; + } + if (uVar5 != 0x80) { + if (uVar5 != 0xa0) goto LAB_2304baae; + goto LAB_2304bb22; + } + kVar7 = ke_state_get(4); + bVar2 = CONCAT31(extraout_var_00,kVar7) != 1; + if (bVar2) { + dest_id = 0xff; + } + else { + dest_id = 4; + } + bVar2 = !bVar2; + if (param_2 != 0xff) { + if (vif->active != false) { + me_beacon_check(DAT_4201caea,length,(uint32_t)bcn_addr); + } +LAB_2304bba4: + if (dest_id != 0xff) goto LAB_2304bbce; + goto LAB_2304baae; + } + kVar7 = ke_state_get(4); + if ((CONCAT31(extraout_var_01,kVar7) == 1) || + (_Var6 = apm_embedded_enabled(vif), CONCAT31(extraout_var_02,_Var6) == 0)) + goto LAB_2304bba4; + goto LAB_2304bbca; + } +LAB_2304bb2c: + if (nss != '\0') goto LAB_2304bafc; + } + bVar2 = false; + dest_id = 6; +LAB_2304bbce: + puVar8 = (undefined2 *) + ke_msg_alloc(0x2c00,dest_id,0xb,(uint16_t)((uVar12 + 0x1c) * 0x10000 >> 0x10)); + if (puVar8 != (undefined2 *)0x0) { + phy_get_channel(apStack72,'\0'); + if (!bVar2) { + if ((bw & 1) != 0) { + assert_warn("(machdr_length & 0x1) == 0","module",0x64d); + } + uVar12 = uVar12 - uVar14 & 0xffff; + bcn_addr = (ushort *)((int)bcn_addr + uVar14); + } + *puVar8 = (short)uVar12; + uVar11 = 0; + while (bw = DAT_4201caea, (uVar12 + 3 & 0xfffffffc) != uVar11) { + *(undefined4 *)((int)puVar8 + uVar11 + 0x1c) = *(undefined4 *)((int)bcn_addr + uVar11); + uVar11 = uVar11 + 4; + } + puVar8[1] = uVar3; + *(byte *)((int)puVar8 + 7) = sta_idx; + *(byte *)(puVar8 + 4) = bw; + *(int8_t *)(puVar8 + 0xd) = iVar4; + *(int8_t *)((int)puVar8 + 0x19) = iVar4; + puVar8[2] = (short)(apStack72[0].info1 >> 0x10); + *(char *)(puVar8 + 3) = (char)apStack72[0].info1; + *(undefined *)(puVar8 + 0xc) = *(undefined *)((int)&(prVar13->hd).recvec1c + 3); + if ((dest_id == 7) && ((uVar3 & 0xfc) == 0)) { + *(uint32_t *)(puVar8 + 8) = (prVar13->hd).tsflo; + *(uint32_t *)(puVar8 + 10) = (prVar13->hd).tsfhi; + *(byte *)((int)puVar8 + 0x1b) = (byte)((prVar13->hd).recvec1a >> 0xc) & 0xf; + } + ke_msg_send(puVar8); + } + return 0; +} + + + +void rxu_cntrl_init(void) + +{ + co_list_init((co_list *)&swdesc); + co_list_init((co_list *)&DAT_4201cb18); + co_list_init((co_list *)&DAT_4201cb2c); + co_list_init((co_list *)&DAT_4201cb34); + DAT_4201cb42 = 0xffff; + return; +} + + +/* +Unable to decompile 'rxu_cntrl_frame_handle' +Cause: Exception while decompiling 2304bda8: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rxu_cntrl_monitor_pm(mac_addr_conflict *addr) + +{ + if (DAT_4201cb4f == '\0') { + _DAT_4201cb48 = addr->array[0]; + _DAT_4201cb4a = addr->array[1]; + _DAT_4201cb4c = addr->array[2]; + _DAT_4201cb4e = 0x100; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t rxu_cntrl_get_pm(void) + +{ + _DAT_4201cb4e = 0; + return DAT_4201cb4e; +} + + + +void rxu_cntrl_evt(int dummy) + +{ + ke_evt_clear(0x80000); + if (swdesc != (rx_swdesc *)0x0) { + ke_evt_set(0x20000000); + return; + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: pkt + +void rxu_swdesc_upload_evt(int arg) + +{ + rx_swdesc *swdesc; + uint uVar1; + int iVar2; + uint32_t uVar3; + uint32_t *puVar4; + uint32_t *puVar5; + uint32_t uVar6; + uint32_t local_48; + wifi_pkt pkt; + + ke_evt_clear(0x20000000); + swdesc = (rx_swdesc *)co_list_pop_front((co_list *)&swdesc); + while (swdesc != (rx_swdesc *)0x0) { + uVar1 = (uint)(swdesc->dma_hdrdesc->hd).frmlen; + memset(&local_48,0,0x28); + puVar4 = (uint32_t *)&local_48; + uVar6 = (swdesc->dma_hdrdesc->hd).first_pbd_ptr; + puVar5 = puVar4; + while ((uVar1 != 0 && (puVar5 != pkt.pkt + 3))) { + swdesc->pbd_count = swdesc->pbd_count + '\x01'; + uVar3 = *(uint32_t *)(uVar6 + 8); + *puVar5 = uVar3; + *(short *)(puVar4 + 8) = ((short)*(undefined4 *)(uVar6 + 0xc) + 1) - (short)uVar3; + puVar5[4] = uVar6 + 0x1c; + *(undefined4 *)(uVar6 + 0x14) = 1; + if (uVar1 < 0x350) { + uVar1 = 0; + } + else { + uVar1 = uVar1 - 0x350; + } + uVar6 = *(uint32_t *)(uVar6 + 4); + puVar5 = puVar5 + 1; + puVar4 = (uint32_t *)((int)puVar4 + 2); + } + swdesc->use_in_tcpip = '\x01'; + swdesc->dma_hdrdesc->use_in_tcpip = 1; + iVar2 = tcpip_stack_input(swdesc,swdesc->status,&(swdesc->dma_hdrdesc->hd).frmlen, + swdesc->dma_hdrdesc->payl_offset,(wifi_pkt *)&local_48); + if (iVar2 == 0) { + vTaskEnterCritical(); + rxl_cntrl_env.packet_stack_cnt = rxl_cntrl_env.packet_stack_cnt + swdesc->pbd_count; + vTaskExitCritical(); + } + else { + rxl_mpdu_free(swdesc); + } + swdesc = (rx_swdesc *)co_list_pop_front((co_list *)&swdesc); + } + return; +} + + + +void scanu_confirm(uint8_t status) + +{ + uint8_t *puVar1; + uint8_t *puVar2; + + if (scanu_env.joining == false) { + puVar2 = (uint8_t *)ke_msg_alloc(0x1001,scanu_env.src_id,4,1); + puVar1 = (uint8_t *)0x0; + } + else { + puVar2 = (uint8_t *)ke_msg_alloc(0x1003,scanu_env.src_id,4,1); + puVar1 = (uint8_t *)ke_msg_alloc(0x1003,0xd,4,1); + } + *puVar2 = status; + ke_msg_free(&scanu_env.param[-1].add_ies); + scanu_env.param = (scanu_start_req *)0x0; + ke_msg_send(puVar2); + if (puVar1 != (uint8_t *)0x0) { + *puVar1 = status; + ke_msg_send(puVar1); + } + ke_state_set(4,0); + return; +} + + + +void scanu_raw_send_cfm(uint8_t status,ke_task_id_t dst_id) + +{ + undefined3 in_register_00002029; + undefined4 *puVar1; + + puVar1 = (undefined4 *)ke_msg_alloc(0x1006,dst_id,4,4); + *puVar1 = CONCAT31(in_register_00002029,status); + ke_msg_send(); + return; +} + + + +void scanu_init(void) + +{ + ke_state_set(4,0); + memset(&scanu_env,0,0x194); + scanu_env.dma_desc.dma_desc = &scanu_add_ie; + scanu_env.dma_desc.cb = scanu_dma_cb; + scanu_env.dma_desc.env = (void *)0x0; + scanu_add_ie.dma_desc.dest = 0x42045ddc; + return; +} + + + +mac_scan_result * scanu_find_result(mac_addr_conflict *bssid_ptr,_Bool allocate) + +{ + undefined3 in_register_0000202d; + mac_scan_result *pmVar1; + + pmVar1 = scanu_env.scan_result; + do { + if (pmVar1->valid_flag == false) { + if (CONCAT31(in_register_0000202d,allocate) != 0) { + return pmVar1; + } + } + else { + if ((((*(char *)(pmVar1->bssid).array == *(char *)bssid_ptr->array) && + (*(char *)((int)(pmVar1->bssid).array + 1) == *(char *)((int)bssid_ptr->array + 1))) && + (*(char *)((pmVar1->bssid).array + 1) == *(char *)(bssid_ptr->array + 1))) && + (((*(char *)((int)(pmVar1->bssid).array + 3) == *(char *)((int)bssid_ptr->array + 3) && + (*(char *)((pmVar1->bssid).array + 2) == *(char *)(bssid_ptr->array + 2))) && + (*(char *)((int)(pmVar1->bssid).array + 5) == *(char *)((int)bssid_ptr->array + 5))))) { + return pmVar1; + } + } + pmVar1 = pmVar1 + 1; + if (pmVar1 == (mac_scan_result *)&scanu_env.src_id) { + return (mac_scan_result *)0x0; + } + } while( true ); +} + + + +// WARNING: Restarted to delay deadcode elimination for space: ram + +undefined4 scanu_frame_handler(ushort *param_1) + +{ + undefined uVar1; + u8_l uVar2; + uint8_t band; + _Bool _Var3; + ushort uVar4; + scanu_start_req *psVar5; + sm_connect_req *psVar6; + ke_state_t kVar7; + uchar uVar8; + uint16_t uVar9; + int iVar10; + undefined3 extraout_var; + mac_scan_result *pmVar11; + scan_chan_tag *psVar12; + void *__src; + byte bVar13; + uint16_t freq; + uint __n; + undefined *puVar14; + u8_l *puVar15; + undefined *puVar16; + u8_l *puVar17; + SecurityMode_t *security_mode; + char cVar18; + uint uVar19; + uint uVar20; + mac_bss_info *bss; + int iVar21; + Cipher_t_conflict *mcstCipher; + Cipher_t_conflict *mcstCipher_00; + Cipher_t_conflict *ucstCipher; + u32_l uVar22; + mac_ssid *pmVar23; + uint uVar24; + ushort *buffer; + uint8_t *rsn_ie; + mac_rateset *mac_rate_set_ptr; + Cipher_t_conflict *ucstCipher_00; + undefined uStack100; + undefined local_63 [47]; + + psVar5 = scanu_env.param; + buffer = param_1 + 0x20; + uVar24 = (uint)(scanu_env.param)->vif_idx; + iVar10 = mac_ie_find(buffer,(uint)*param_1 - 0x24 & 0xffff,0); + if (iVar10 != 0) { + bVar13 = *(byte *)(iVar10 + 1); + uVar19 = (uint)bVar13; + if (bVar13 < 0x21) { + if (bVar13 == 0) goto LAB_2304c988; + } + else { + uVar19 = 0x20; + } + puVar14 = (undefined *)(iVar10 + 2); + if (*(char *)(iVar10 + 2) != '\0') { + uStack100 = (undefined)uVar19; + puVar16 = &uStack100; + uVar20 = uVar19; + while( true ) { + uVar20 = uVar20 - 1; + puVar16 = puVar16 + 1; + if (uVar20 == 0xffffffff) break; + uVar1 = *puVar14; + puVar14 = puVar14 + 1; + *puVar16 = uVar1; + } + local_63[uVar19] = 0; + } + } +LAB_2304c988: + kVar7 = ke_state_get(4); + if (((CONCAT31(extraout_var,kVar7) != 1) || + (pmVar11 = scanu_find_result((mac_addr_conflict *)(param_1 + 0x16),true), + pmVar11 == (mac_scan_result *)0x0)) || + ((((byte)scanu_env.bssid.array[0] & 1) == 0 && + (((((*(byte *)(param_1 + 0x16) != (byte)scanu_env.bssid.array[0] || + (*(char *)((int)param_1 + 0x2d) != scanu_env.bssid.array[0]._1_1_)) || + (*(char *)(param_1 + 0x17) != (char)scanu_env.bssid.array[1])) || + ((*(char *)((int)param_1 + 0x2f) != scanu_env.bssid.array[1]._1_1_ || + (*(char *)(param_1 + 0x18) != (char)scanu_env.bssid.array[2])))) || + (*(char *)((int)param_1 + 0x31) != scanu_env.bssid.array[2]._1_1_)))))) goto LAB_2304d0be; + (pmVar11->bssid).array[0] = param_1[0x16]; + (pmVar11->bssid).array[1] = param_1[0x17]; + (pmVar11->bssid).array[2] = param_1[0x18]; + pmVar11->beacon_period = param_1[0x1e]; + uVar4 = param_1[0x1f]; + pmVar11->cap_info = uVar4; + freq = uVar4 & 1; + if ((uVar4 & 1) == 0) { + freq = 2; + } + pmVar11->bsstype = freq; + uVar4 = *param_1; + uVar19 = (uint)uVar4 - 0x24 & 0xffff; + iVar10 = mac_ie_find(buffer,uVar19,0); + if (iVar10 == 0) { + (pmVar11->ssid).length = '\0'; + } + else { + bVar13 = *(byte *)(iVar10 + 1); + uVar20 = (uint)bVar13; + if (bVar13 < 0x21) { + if (bVar13 == 0) goto LAB_2304ca5c; + } + else { + uVar20 = 0x20; + } + puVar17 = (u8_l *)(iVar10 + 2); + if (*(char *)(iVar10 + 2) != '\0') { + (pmVar11->ssid).length = (u8_l)uVar20; + puVar15 = (pmVar11->ssid).array; + while (uVar20 = uVar20 - 1, uVar20 != 0xffffffff) { + uVar2 = *puVar17; + puVar17 = puVar17 + 1; + *puVar15 = uVar2; + puVar15 = puVar15 + 1; + } + } + } +LAB_2304ca5c: + pmVar11->ppm_rel = *(int8_t *)(param_1 + 0xd); + pmVar11->ppm_abs = *(int8_t *)((int)param_1 + 0x19); + if (psVar5->ssid_cnt != '\0') { + uVar20 = 0; + pmVar23 = psVar5->ssid; + while ((int)uVar20 < (int)(uint)psVar5->ssid_cnt) { + if (pmVar23->length == 0) goto LAB_2304cafa; + __n = (uint)(pmVar11->ssid).length; + if ((__n == (uint)pmVar23->length) && + (iVar10 = memcmp(pmVar23->array,(pmVar11->ssid).array,__n), iVar10 == 0)) break; + uVar20 = uVar20 + 1; + pmVar23 = pmVar23 + 1; + } + if ((uint)psVar5->ssid_cnt == uVar20) goto LAB_2304d0be; + } +LAB_2304cafa: + iVar10 = mac_ie_find(buffer,uVar19,3); + if (iVar10 == 0) { + if (pmVar11->rssi < *(char *)(param_1 + 0xc)) { + psVar12 = me_freq_to_chan_ptr(*(uint8_t *)(param_1 + 3),param_1[2]); + pmVar11->chan = psVar12; + cVar18 = *(char *)(param_1 + 0xc); + goto LAB_2304cb4a; + } + } + else { + bVar13 = *(byte *)(iVar10 + 2); + band = *(uint8_t *)(param_1 + 3); + if (band == '\0') { + if ((uint)bVar13 - 1 < 0xe) { + if (bVar13 == 0xe) { + freq = 0x9b4; + } + else { + freq = (ushort)bVar13 * 5 + 0x967; + } + } + else { +LAB_2304cfa8: + freq = 0xffff; + } + } + else { + if ((band != '\x01') || (0xa4 < (uint)bVar13 - 1)) goto LAB_2304cfa8; + freq = (ushort)bVar13 * 5 + 5000; + } + psVar12 = me_freq_to_chan_ptr(band,freq); + pmVar11->chan = psVar12; + cVar18 = *(char *)(param_1 + 0xc); + if (pmVar11->rssi < cVar18) { +LAB_2304cb4a: + pmVar11->rssi = cVar18; + } + } + if (scanu_env.joining != false) { + bss = &vif_info_tab[uVar24].bss_info; + vif_info_tab[uVar24].bss_info.bsstype = pmVar11->bsstype; + mac_rate_set_ptr = &vif_info_tab[uVar24].bss_info.rate_set; + *(undefined4 *)vif_info_tab[uVar24].bss_info.bssid.array = *(undefined4 *)(pmVar11->bssid).array + ; + vif_info_tab[uVar24].bss_info.bssid.array[2] = (pmVar11->bssid).array[2]; + vif_info_tab[uVar24].bss_info.cap_info = pmVar11->cap_info; + vif_info_tab[uVar24].bss_info.beacon_period = pmVar11->beacon_period; + memcpy(&vif_info_tab[uVar24].bss_info.ssid,&pmVar11->ssid,0x22); + psVar12 = pmVar11->chan; + vif_info_tab[uVar24].bss_info.valid_flags = 0; + vif_info_tab[uVar24].bss_info.chan = psVar12; + vif_info_tab[uVar24].bss_info.ppm_rel = pmVar11->ppm_rel; + vif_info_tab[uVar24].bss_info.ppm_abs = pmVar11->ppm_abs; + freq = (uint16_t)(((uint)uVar4 - 0x24) * 0x10000 >> 0x10); + me_extract_rate_set((uint32_t)buffer,freq,mac_rate_set_ptr); + if (pmVar11->chan->band == '\0') { + uVar9 = me_legacy_rate_bitfield_build(mac_rate_set_ptr,true); + if ((uVar9 & 0xf) == 0) { + vif_info_tab[uVar24].bss_info.high_11b_rate = '\x01'; + } + else { + iVar10 = __clzsi2((uint)uVar9 & 0xf); + vif_info_tab[uVar24].bss_info.high_11b_rate = '\x1f' - (char)iVar10; + } + } + iVar10 = mac_vsie_find(buffer,uVar19,&DAT_2307bbfc,5); + if (iVar10 == 0) { + vif_info_tab[uVar24].bss_info.edca_param.ac_param[0] = 0xa43; + vif_info_tab[uVar24].bss_info.edca_param.ac_param[1] = 0xa43; + vif_info_tab[uVar24].bss_info.edca_param.ac_param[2] = 0xa43; + vif_info_tab[uVar24].bss_info.edca_param.ac_param[3] = 0xa43; + } + else { + vif_info_tab[uVar24].bss_info.edca_param.qos_info = *(uint8_t *)(iVar10 + 8); + vif_info_tab[uVar24].bss_info.cap_info = vif_info_tab[uVar24].bss_info.cap_info | 0x200; + uVar20 = *(uint *)(iVar10 + 10); + bVar13 = (byte)(uVar20 >> 3) & 2; + vif_info_tab[uVar24].bss_info.edca_param.acm = bVar13; + vif_info_tab[uVar24].bss_info.edca_param.ac_param[1] = uVar20 & 0xf | (uVar20 >> 8) << 4; + uVar20 = *(uint *)(iVar10 + 0xe); + bVar13 = (byte)(uVar20 >> 4) & 1 | bVar13; + vif_info_tab[uVar24].bss_info.edca_param.acm = bVar13; + vif_info_tab[uVar24].bss_info.edca_param.ac_param[0] = uVar20 & 0xf | (uVar20 >> 8) << 4; + uVar20 = *(uint *)(iVar10 + 0x12); + bVar13 = bVar13 | (byte)(uVar20 >> 2) & 4; + vif_info_tab[uVar24].bss_info.edca_param.acm = bVar13; + vif_info_tab[uVar24].bss_info.edca_param.ac_param[2] = uVar20 & 0xf | (uVar20 >> 8) << 4; + uVar20 = *(uint *)(iVar10 + 0x16); + vif_info_tab[uVar24].bss_info.edca_param.acm = bVar13 | (byte)(uVar20 >> 1) & 8; + __n = vif_info_tab[uVar24].bss_info.valid_flags; + vif_info_tab[uVar24].bss_info.edca_param.ac_param[3] = uVar20 & 0xf | (uVar20 >> 8) << 4; + vif_info_tab[uVar24].bss_info.valid_flags = __n | 1; + } + uVar20 = 0; + if (me_env.ht_supported != false) { + uVar20 = vif_info_tab[uVar24].bss_info.valid_flags & 1; + if (uVar20 != 0) { + iVar10 = mac_ie_find(buffer,uVar19,0x2d); + if (iVar10 != 0) { + vif_info_tab[uVar24].bss_info.ht_cap.ht_capa_info = *(u16_l *)(iVar10 + 2); + vif_info_tab[uVar24].bss_info.ht_cap.a_mpdu_param = *(u8_l *)(iVar10 + 4); + iVar21 = 0; + do { + vif_info_tab[uVar24].bss_info.ht_cap.mcs_rate[iVar21] = *(u8_l *)(iVar10 + 5 + iVar21); + iVar21 = iVar21 + 1; + } while (iVar21 != 0x10); + vif_info_tab[uVar24].bss_info.ht_cap.ht_extended_capa = *(u16_l *)(iVar10 + 0x15); + vif_info_tab[uVar24].bss_info.ht_cap.tx_beamforming_capa = + (uint)*(ushort *)(iVar10 + 0x17); + vif_info_tab[uVar24].bss_info.ht_cap.asel_capa = *(u8_l *)(iVar10 + 0x1b); + vif_info_tab[uVar24].bss_info.valid_flags = vif_info_tab[uVar24].bss_info.valid_flags | 2; + } + uVar20 = mac_ie_find(buffer,uVar19,0x3d); + } + } + _Var3 = (sm_env.connect_param)->is_supplicant_enabled; + vif_info_tab[uVar24].bss_info.is_supplicant_enabled = _Var3; + if ((_Var3 != false) && (-1 < (int)vif_info_tab[uVar24].bss_info.valid_flags)) { + security_mode = &vif_info_tab[uVar24].bss_info.wpa_wpa2_wep; + memset(security_mode,0,2); + mcstCipher = &vif_info_tab[uVar24].bss_info.rsn_mcstCipher; + ucstCipher_00 = &vif_info_tab[uVar24].bss_info.rsn_ucstCipher; + memset(mcstCipher,0,1); + memset(ucstCipher_00,0,1); + mcstCipher_00 = &vif_info_tab[uVar24].bss_info.wpa_mcstCipher; + memset(mcstCipher_00,0,1); + ucstCipher = &vif_info_tab[uVar24].bss_info.wpa_ucstCipher; + memset(ucstCipher,0,1); + vif_info_tab[uVar24].bss_info.rsn_wpa_ie_len = '\0'; + vif_info_tab[uVar24].bss_info.is_pmf_required = false; + vif_info_tab[uVar24].bss_info.is_wpa2_prefered = false; + __src = (void *)mac_ie_find(buffer,uVar19,0x30); + rsn_ie = vif_info_tab[uVar24].bss_info.rsn_wpa_ie; + if (__src != (void *)0x0) { + __n = (uint)*(byte *)((int)__src + 1) + 2 & 0xff; + vif_info_tab[uVar24].bss_info.rsn_wpa_ie_len = (uint8_t)__n; + memcpy(rsn_ie,__src,__n); + uVar8 = process_rsn_ie(rsn_ie,mcstCipher,ucstCipher_00, + &vif_info_tab[uVar24].bss_info.is_pmf_required,security_mode, + *(_Bool *)(uVar24 * 0x5d8 + 0x4201c0e8)); + __n = *(uint *)&vif_info_tab[uVar24].bss_info.wpa_ucstCipher; + vif_info_tab[uVar24].bss_info.rsn_wpa_ie_len = uVar8; + printf("wpa2/wpa3 pairwise ccmp:%d,tkip:%d,wep104:%d,wep:40:%d\r\n",__n >> 0x13 & 1, + __n >> 0x12 & 1,__n >> 0x11 & 1,__n >> 0x10 & 1); + __n = *(uint *)&vif_info_tab[uVar24].bss_info.wpa_ucstCipher; + printf("wpa2/wpa3 group ccmp:%d,tkip:%d,wep104:%d,wep:40:%d\r\n",__n >> 0xb & 1, + __n >> 10 & 1,__n >> 9 & 1,__n >> 8 & 1); + printf("wpa2/wpa3 is_pmf_required:%d\r\n", + (uint)vif_info_tab[uVar24].bss_info.is_pmf_required); + } + __src = (void *)mac_vsie_find(buffer,uVar19,&DAT_2307bc04,4); + if (__src != (void *)0x0) { + *(byte *)&vif_info_tab[uVar24].bss_info.wpa_wpa2_wep = + *(byte *)&vif_info_tab[uVar24].bss_info.wpa_wpa2_wep | 8; + if (vif_info_tab[uVar24].bss_info.rsn_wpa_ie_len == '\0') { + __n = (uint)*(byte *)((int)__src + 1) + 2 & 0xff; + vif_info_tab[uVar24].bss_info.rsn_wpa_ie_len = (uint8_t)__n; + memcpy(rsn_ie,__src,__n); + uVar8 = process_wpa_ie(rsn_ie,mcstCipher_00,ucstCipher); + vif_info_tab[uVar24].bss_info.rsn_wpa_ie_len = uVar8; + } + } + psVar6 = sm_env.connect_param; + (sm_env.connect_param)->flags = 0; + if ((*(uint *)&vif_info_tab[uVar24].bss_info.is_supplicant_enabled & 0x12800) == 0) { + if ((vif_info_tab[uVar24].bss_info.cap_info & 0x10) == 0) { + uVar22 = 2; + goto LAB_2304cf7a; + } + *(byte *)&vif_info_tab[uVar24].bss_info.wpa_wpa2_wep = + *(byte *)&vif_info_tab[uVar24].bss_info.wpa_wpa2_wep | 2; + psVar6->auth_type = '\x01'; + } + else { + uVar22 = 9; +LAB_2304cf7a: + psVar6->flags = uVar22; + } + memcpy(psVar6->ie_buf,rsn_ie,(uint)vif_info_tab[uVar24].bss_info.rsn_wpa_ie_len); + (sm_env.connect_param)->ie_len = (ushort)vif_info_tab[uVar24].bss_info.rsn_wpa_ie_len; + __n = *(uint *)&vif_info_tab[uVar24].bss_info.is_supplicant_enabled; + printf("AP Security mode: wep:%d,wpa:%d,wpa2:%d,wpa3:%d\r\n",__n >> 9 & 1,__n >> 0xb & 1, + __n >> 0xd & 1,__n >> 0x10 & 1); + } + me_bw_check(uVar20,0,bss); + me_extract_power_constraint((uint32_t)buffer,freq,bss); + me_extract_country_reg(buffer,uVar19,bss); + me_extract_mobility_domain((uint32_t)buffer,freq,bss); + vif_info_tab[uVar24].bss_info.valid_flags = + vif_info_tab[uVar24].bss_info.valid_flags | 0x80000000; + } + if (pmVar11->valid_flag == false) { + scanu_env.result_cnt = scanu_env.result_cnt + 1; + } + if (psVar5->ssid_cnt != '\0') { + pmVar11->valid_flag = true; + } +LAB_2304d0be: + ke_msg_forward_and_change_id(param_1,0x1004,0xd,4); + return 1; +} + + + +mac_scan_result * scanu_search_by_bssid(mac_addr_conflict *bssid) + +{ + mac_scan_result *pmVar1; + + pmVar1 = scanu_find_result(bssid,false); + return pmVar1; +} + + + +mac_scan_result * scanu_search_by_ssid(mac_ssid *ssid,int *idx) + +{ + scanu_env_tag_conflict *psVar1; + int iVar2; + int iVar3; + mac_scan_result *pmVar4; + int8_t iVar5; + + pmVar4 = (mac_scan_result *)0x0; + if (ssid->length != '\0') { + psVar1 = &scanu_env; + iVar3 = 0; + pmVar4 = (mac_scan_result *)0x0; + iVar5 = -0x80; + do { + if (psVar1->scan_result[0].valid_flag == false) { + return pmVar4; + } + if (((iVar5 < psVar1->scan_result[0].rssi) && + ((uint)ssid->length == (uint)psVar1->scan_result[0].ssid.length)) && + (iVar2 = memcmp(psVar1->scan_result[0].ssid.array,ssid->array,(uint)ssid->length), + iVar2 == 0)) { + iVar5 = psVar1->scan_result[0].rssi; + pmVar4 = psVar1->scan_result; + *idx = iVar3; + } + iVar3 = iVar3 + 1; + psVar1 = (scanu_env_tag_conflict *)(psVar1->scan_result[0].ssid.array + 0x19); + } while (iVar3 != 6); + } + return pmVar4; +} + + + +void scanu_rm_exist_ssid(mac_ssid *ssid,int index) + +{ + int iVar1; + + if ((index < 0) || (ssid == (mac_ssid *)0x0)) { + return; + } + if (((scanu_env.scan_result[index].valid_flag != false) && + ((uint)ssid->length == (uint)scanu_env.scan_result[index].ssid.length)) && + (iVar1 = memcmp(scanu_env.scan_result[index].ssid.array,ssid->array,(uint)ssid->length), + iVar1 == 0)) { + memset(scanu_env.scan_result + index,0,0x38); + return; + } + return; +} + + + +void scanu_scan_next(void) + +{ + byte bVar1; + int iVar2; + scanu_start_req *psVar3; + uint uVar4; + void *pvVar5; + uint uVar6; + uint8_t *puVar7; + undefined *puVar8; + undefined *puVar9; + uint32_t *puVar10; + u8_l *puVar11; + me_env_tag *pmVar12; + short sVar13; + int iVar14; + undefined *puVar15; + int iVar16; + scanu_add_ie_tag *psVar17; + uint8_t *puVar18; + uint uVar19; + int iVar20; + int iVar21; + + psVar3 = scanu_env.param; + while( true ) { + if (1 < scanu_env.band) { + scanu_confirm('\0'); + return; + } + uVar19 = 0; + puVar11 = &(scanu_env.param)->chan[0].band; + while ((int)uVar19 < (int)(uint)(scanu_env.param)->chan_cnt) { + if (*puVar11 == scanu_env.band) goto LAB_2304d238; + uVar19 = uVar19 + 1; + puVar11 = puVar11 + 6; + } + if ((uint)(scanu_env.param)->chan_cnt != uVar19) break; + scanu_env.band = scanu_env.band + '\x01'; + } +LAB_2304d238: + pvVar5 = ke_msg_alloc(0x800,2,4,0x154); + *(u8_l *)((int)pvVar5 + 0x14e) = psVar3->vif_idx; + *(undefined4 *)((int)pvVar5 + 0x140) = *(undefined4 *)(psVar3->bssid).array; + *(undefined2 *)((int)pvVar5 + 0x144) = *(undefined2 *)((psVar3->bssid).array + 4); + *(u8_l *)((int)pvVar5 + 0x150) = psVar3->ssid_cnt; + *(_Bool *)((int)pvVar5 + 0x151) = psVar3->no_cck; + while ((int)uVar19 < (int)(uint)psVar3->chan_cnt) { + if (*(uint8_t *)(&psVar3->chan[uVar19].freq + 1) == scanu_env.band) { + bVar1 = *(byte *)((int)pvVar5 + 0x14f); + memcpy((void *)((uint)bVar1 * 6 + (int)pvVar5),psVar3->chan + uVar19,6); + *(char *)((int)pvVar5 + 0x14f) = bVar1 + 1; + } + uVar19 = uVar19 + 1; + } + iVar20 = 0xfc; + iVar21 = 0; + while (iVar21 < (int)(uint)psVar3->ssid_cnt) { + memcpy((void *)((int)pvVar5 + iVar20),(void *)((int)&psVar3->chan[0].freq + iVar20),0x22); + iVar21 = iVar21 + 1; + iVar20 = iVar20 + 0x22; + } + uVar19 = (uint)(scanu_env.param)->add_ie_len; + puVar10 = scanu_add_ie.buf; + if (200 < (scanu_env.param)->add_ie_len) { + uVar19 = 0; + } + if ((scanu_env.band == '\x01') || ((scanu_env.param)->no_cck != false)) { + iVar20 = 4; + iVar21 = 8; + } + else { + iVar20 = 0; + iVar21 = 0xc; + } + scan_probe_req_ie.buf[0]._0_1_ = 1; + scan_probe_req_ie.buf[0]._1_1_ = 8; + iVar14 = 0; + do { + iVar16 = iVar20 + iVar14; + iVar2 = iVar14 + 2; + iVar14 = iVar14 + 1; + *(uint8_t *)((int)scan_probe_req_ie.buf + iVar2) = mac_id2rate[iVar16]; + } while (iVar14 != 8); + puVar15 = (undefined *)((int)scan_probe_req_ie.buf + 10); + if ((uVar19 != 0) && ((char)scanu_add_ie.buf[0] == '\n')) { + uVar6 = (uint)scanu_add_ie.buf[0]._1_1_ + 2 & 0xff; + uVar4 = uVar6; + psVar17 = &scanu_add_ie; + while( true ) { + uVar4 = uVar4 - 1; + if (uVar4 == 0xffffffff) break; + *puVar15 = *(undefined *)psVar17->buf; + psVar17 = (scanu_add_ie_tag *)((int)&(psVar17->dma_desc).src + 1); + puVar15 = puVar15 + 1; + } + puVar15 = (undefined *)((int)scan_probe_req_ie.buf + uVar6 + 10); + puVar10 = (uint32_t *)((int)scanu_add_ie.buf + uVar6); + uVar19 = uVar19 - uVar6 & 0xffff; + } + if (iVar21 != 8) { + uVar4 = iVar21 - 8U & 0xff; + *puVar15 = 0x32; + puVar15[1] = (char)uVar4; + iVar20 = uVar4 + 2; + puVar7 = mac_id2rate; + puVar18 = puVar15 + 2; + while( true ) { + uVar4 = uVar4 - 1; + if (uVar4 == 0xffffffff) break; + *puVar18 = puVar7[8]; + puVar7 = puVar7 + 1; + puVar18 = puVar18 + 1; + } + puVar15 = puVar15 + iVar20; + } + if (scanu_env.band == '\0') { + *puVar15 = 3; + puVar15[1] = 1; + puVar15 = puVar15 + 3; + } + if ((uVar19 != 0) && (*(char *)puVar10 == ';')) { + uVar4 = 0; + uVar6 = (uint)*(byte *)((int)puVar10 + 1) + 2 & 0xff; + while (uVar6 != uVar4) { + puVar8 = (undefined *)((int)puVar10 + uVar4); + puVar9 = puVar15 + uVar4; + uVar4 = uVar4 + 1; + *puVar9 = *puVar8; + } + puVar15 = puVar15 + uVar6; + puVar10 = (uint32_t *)((int)puVar10 + uVar6); + uVar19 = uVar19 - uVar6 & 0xffff; + } + if (me_env.ht_supported != false) { + *puVar15 = 0x2d; + puVar15[1] = 0x1a; + puVar8 = puVar15 + 0x1c; + pmVar12 = &me_env; + puVar15 = puVar15 + 2; + while (puVar8 != puVar15) { + *puVar15 = *(undefined *)&(pmVar12->ht_cap).ht_capa_info; + pmVar12 = (me_env_tag *)((int)&pmVar12->active_vifs + 1); + puVar15 = puVar15 + 1; + } + } + sVar13 = (short)puVar15; + if (uVar19 != 0) { + uVar4 = 0; + do { + puVar8 = (undefined *)((int)puVar10 + uVar4); + puVar9 = puVar15 + uVar4; + uVar4 = uVar4 + 1; + *puVar9 = *puVar8; + } while (uVar19 != uVar4); + sVar13 = sVar13 + (short)uVar19; + } + *(short *)((int)pvVar5 + 0x14c) = sVar13 + -0x5d04; + *(undefined4 *)((int)pvVar5 + 0x148) = 0; + ke_msg_send(pvVar5); + return; +} + + + +void scanu_dma_cb(void) + +{ + byte bVar1; + int iVar2; + scanu_start_req *psVar3; + uint uVar4; + void *pvVar5; + uint uVar6; + uint8_t *puVar7; + undefined *puVar8; + undefined *puVar9; + uint32_t *puVar10; + u8_l *puVar11; + me_env_tag *pmVar12; + short sVar13; + int iVar14; + undefined *puVar15; + int iVar16; + scanu_add_ie_tag *psVar17; + uint8_t *puVar18; + uint uVar19; + int iVar20; + int iVar21; + + psVar3 = scanu_env.param; + while( true ) { + if (1 < scanu_env.band) { + scanu_confirm('\0'); + return; + } + uVar19 = 0; + puVar11 = &(scanu_env.param)->chan[0].band; + while ((int)uVar19 < (int)(uint)(scanu_env.param)->chan_cnt) { + if (*puVar11 == scanu_env.band) goto LAB_2304d238; + uVar19 = uVar19 + 1; + puVar11 = puVar11 + 6; + } + if ((uint)(scanu_env.param)->chan_cnt != uVar19) break; + scanu_env.band = scanu_env.band + '\x01'; + } +LAB_2304d238: + pvVar5 = ke_msg_alloc(0x800,2,4,0x154); + *(u8_l *)((int)pvVar5 + 0x14e) = psVar3->vif_idx; + *(undefined4 *)((int)pvVar5 + 0x140) = *(undefined4 *)(psVar3->bssid).array; + *(undefined2 *)((int)pvVar5 + 0x144) = *(undefined2 *)((psVar3->bssid).array + 4); + *(u8_l *)((int)pvVar5 + 0x150) = psVar3->ssid_cnt; + *(_Bool *)((int)pvVar5 + 0x151) = psVar3->no_cck; + while ((int)uVar19 < (int)(uint)psVar3->chan_cnt) { + if (*(uint8_t *)(&psVar3->chan[uVar19].freq + 1) == scanu_env.band) { + bVar1 = *(byte *)((int)pvVar5 + 0x14f); + memcpy((void *)((uint)bVar1 * 6 + (int)pvVar5),psVar3->chan + uVar19,6); + *(char *)((int)pvVar5 + 0x14f) = bVar1 + 1; + } + uVar19 = uVar19 + 1; + } + iVar20 = 0xfc; + iVar21 = 0; + while (iVar21 < (int)(uint)psVar3->ssid_cnt) { + memcpy((void *)((int)pvVar5 + iVar20),(void *)((int)&psVar3->chan[0].freq + iVar20),0x22); + iVar21 = iVar21 + 1; + iVar20 = iVar20 + 0x22; + } + uVar19 = (uint)(scanu_env.param)->add_ie_len; + puVar10 = scanu_add_ie.buf; + if (200 < (scanu_env.param)->add_ie_len) { + uVar19 = 0; + } + if ((scanu_env.band == '\x01') || ((scanu_env.param)->no_cck != false)) { + iVar20 = 4; + iVar21 = 8; + } + else { + iVar20 = 0; + iVar21 = 0xc; + } + scan_probe_req_ie.buf[0]._0_1_ = 1; + scan_probe_req_ie.buf[0]._1_1_ = 8; + iVar14 = 0; + do { + iVar16 = iVar20 + iVar14; + iVar2 = iVar14 + 2; + iVar14 = iVar14 + 1; + *(uint8_t *)((int)scan_probe_req_ie.buf + iVar2) = mac_id2rate[iVar16]; + } while (iVar14 != 8); + puVar15 = (undefined *)((int)scan_probe_req_ie.buf + 10); + if ((uVar19 != 0) && ((char)scanu_add_ie.buf[0] == '\n')) { + uVar6 = (uint)scanu_add_ie.buf[0]._1_1_ + 2 & 0xff; + uVar4 = uVar6; + psVar17 = &scanu_add_ie; + while( true ) { + uVar4 = uVar4 - 1; + if (uVar4 == 0xffffffff) break; + *puVar15 = *(undefined *)psVar17->buf; + psVar17 = (scanu_add_ie_tag *)((int)&(psVar17->dma_desc).src + 1); + puVar15 = puVar15 + 1; + } + puVar15 = (undefined *)((int)scan_probe_req_ie.buf + uVar6 + 10); + puVar10 = (uint32_t *)((int)scanu_add_ie.buf + uVar6); + uVar19 = uVar19 - uVar6 & 0xffff; + } + if (iVar21 != 8) { + uVar4 = iVar21 - 8U & 0xff; + *puVar15 = 0x32; + puVar15[1] = (char)uVar4; + iVar20 = uVar4 + 2; + puVar7 = mac_id2rate; + puVar18 = puVar15 + 2; + while( true ) { + uVar4 = uVar4 - 1; + if (uVar4 == 0xffffffff) break; + *puVar18 = puVar7[8]; + puVar7 = puVar7 + 1; + puVar18 = puVar18 + 1; + } + puVar15 = puVar15 + iVar20; + } + if (scanu_env.band == '\0') { + *puVar15 = 3; + puVar15[1] = 1; + puVar15 = puVar15 + 3; + } + if ((uVar19 != 0) && (*(char *)puVar10 == ';')) { + uVar4 = 0; + uVar6 = (uint)*(byte *)((int)puVar10 + 1) + 2 & 0xff; + while (uVar6 != uVar4) { + puVar8 = (undefined *)((int)puVar10 + uVar4); + puVar9 = puVar15 + uVar4; + uVar4 = uVar4 + 1; + *puVar9 = *puVar8; + } + puVar15 = puVar15 + uVar6; + puVar10 = (uint32_t *)((int)puVar10 + uVar6); + uVar19 = uVar19 - uVar6 & 0xffff; + } + if (me_env.ht_supported != false) { + *puVar15 = 0x2d; + puVar15[1] = 0x1a; + puVar8 = puVar15 + 0x1c; + pmVar12 = &me_env; + puVar15 = puVar15 + 2; + while (puVar8 != puVar15) { + *puVar15 = *(undefined *)&(pmVar12->ht_cap).ht_capa_info; + pmVar12 = (me_env_tag *)((int)&pmVar12->active_vifs + 1); + puVar15 = puVar15 + 1; + } + } + sVar13 = (short)puVar15; + if (uVar19 != 0) { + uVar4 = 0; + do { + puVar8 = (undefined *)((int)puVar10 + uVar4); + puVar9 = puVar15 + uVar4; + uVar4 = uVar4 + 1; + *puVar9 = *puVar8; + } while (uVar19 != uVar4); + sVar13 = sVar13 + (short)uVar19; + } + *(short *)((int)pvVar5 + 0x14c) = sVar13 + -0x5d04; + *(undefined4 *)((int)pvVar5 + 0x148) = 0; + ke_msg_send(pvVar5); + return; +} + + + +void scanu_start(void) + +{ + scanu_env_tag_conflict *psVar1; + + if (scanu_env.joining == false) { + psVar1 = &scanu_env; + do { + psVar1->scan_result[0].valid_flag = false; + psVar1->scan_result[0].rssi = -0x80; + psVar1 = (scanu_env_tag_conflict *)(psVar1->scan_result[0].ssid.array + 0x19); + } while (psVar1 != (scanu_env_tag_conflict *)0x4201ccac); + scanu_env.result_cnt = 0; + } + ke_state_set(4,1); + if ((scanu_env.param)->add_ies != 0) { + if ((scanu_env.param)->add_ie_len < 0xc9) { + scanu_add_ie.dma_desc.src = (scanu_env.param)->add_ies; + scanu_add_ie.dma_desc.length = (scanu_env.param)->add_ie_len; + hal_dma_push(&scanu_env.dma_desc,0); + return; + } + } + scanu_scan_next(); + return; +} + + + +uint16_t txl_get_seq_ctrl(void) + +{ + uint uVar1; + + uVar1 = (uint)txl_cntrl_env.seqnbr; + txl_cntrl_env.seqnbr = (uint16_t)((uVar1 + 1) * 0x10000 >> 0x10); + return (uint16_t)((uVar1 + 1) * 0x100000 >> 0x10); +} + + + +void sm_delete_resources(vif_info_tag *vif) + +{ + undefined *puVar1; + undefined *puVar2; + void *pvVar3; + byte *pbVar4; + + puVar1 = (undefined *)ke_msg_alloc(0x1413,5,6,2); + puVar2 = (undefined *)ke_msg_alloc(0x1411,5,6,2); + *puVar1 = 0; + puVar1[1] = vif->index; + ke_msg_send(puVar1); + if (vif->active != false) { + pvVar3 = ke_msg_alloc(0x1e,0,6,4); + *(undefined *)((int)pvVar3 + 2) = 0; + *(uint8_t *)((int)pvVar3 + 3) = vif->index; + ke_msg_send(); + } + if (vif->u[4] != 0xff) { + pbVar4 = (byte *)ke_msg_alloc(0xc,0,6,1); + *pbVar4 = vif->u[4]; + ke_msg_send(); + } + if (vif->chan_ctxt != (chan_ctxt_tag *)0x0) { + chan_ctxt_unlink(vif->index); + } + *puVar2 = 0; + puVar2[1] = vif->index; + ke_msg_send(puVar2); + (vif->bss_info).valid_flags = 0; + return; +} + + + +void sm_frame_tx_cfm_handler(void *env,u32_l status) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + + kVar1 = ke_state_get(6); + if (((status & 0x40030000) != 0) && (CONCAT31(extraout_var,kVar1) - 5U < 2)) { + txl_frame_push((txl_frame_desc_tag *)env,'\x03'); + *(undefined *)((int)env + 0x2d6) = 1; + } + return; +} + + + +void sm_init(void) + +{ + sm_env.connect_param = (sm_connect_req *)0x0; + ke_state_set(6,0); + return; +} + + + +void sm_get_bss_params(mac_addr_conflict67 **bssid,scan_chan_tag **chan) + +{ + byte bVar1; + sm_connect_req *ssid; + int iVar2; + int iVar3; + mac_scan_result *pmVar4; + mac_addr_conflict *bssid_00; + mac_addr_conflict *pmVar5; + int local_34; + int index; + + ssid = sm_env.connect_param; + *bssid = (mac_addr_conflict67 *)0x0; + *chan = (scan_chan_tag *)0x0; + bssid_00 = (mac_addr_conflict *)&ssid->bssid; + local_34 = -1; + printf("===start sm_get_bss_params===\r\n"); + iVar2 = 0; + pmVar5 = bssid_00; + do { + iVar3 = iVar2 + 1; + printf("bssid[%d] = 0x%x\r\n",iVar2,(uint)pmVar5->array[0]); + pmVar5 = (mac_addr_conflict *)(pmVar5->array + 1); + iVar2 = iVar3; + } while (iVar3 != 3); + bVar1 = (ssid->bssid).array[0]; + if (((bVar1 & 1) == 0) && + ((((bVar1 != 0 || ((ssid->bssid).array[1] != '\0')) || ((ssid->bssid).array[2] != '\0')) || + ((((ssid->bssid).array[3] != '\0' || ((ssid->bssid).array[4] != '\0')) || + ((ssid->bssid).array[5] != '\0')))))) { + printf("search bssid \r\n "); + *(mac_addr_conflict **)bssid = bssid_00; + pmVar4 = scanu_search_by_bssid(bssid_00); + if (pmVar4 == (mac_scan_result *)0x0) goto LAB_2304d752; + } + else { + printf("search ssid = %s\r\n",(ssid->ssid).array); + pmVar4 = scanu_search_by_ssid((mac_ssid *)ssid,&local_34); + printf("result ssid index = %d\r\n",local_34); + if (pmVar4 == (mac_scan_result *)0x0) { +LAB_2304d752: + if ((ssid->chan).freq != 0xffff) { + *chan = &ssid->chan; + } + goto LAB_2304d714; + } + if (-1 < local_34) { + *(mac_scan_result **)bssid = pmVar4; + sm_env.exist_ssid_idx = local_34; + } + } + *chan = pmVar4->chan; +LAB_2304d714: + printf("===end sm_get_bss_params===\r\n"); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void sm_scan_bss(mac_addr_conflict67 *bssid,scan_chan_tag *chan_1) + +{ + u8_l uVar1; + byte bVar2; + undefined2 uVar3; + sm_connect_req *__src; + int iVar4; + void *__dest; + void *__src_00; + undefined2 *puVar5; + int *piVar6; + undefined2 local_2c; + undefined2 uStack42; + uint8_t chan_cnt [2]; + scan_chan_tag *chan [2]; + + __src = sm_env.connect_param; + __dest = ke_msg_alloc(0x1000,4,6,0x154); + uVar1 = __src->vif_idx; + *(undefined4 *)((int)__dest + 0x148) = 0; + *(u8_l *)((int)__dest + 0x14e) = uVar1; + *(undefined2 *)((int)__dest + 0x14c) = 0; + memcpy((void *)((int)__dest + 0xfc),__src,0x22); + *(undefined *)((int)__dest + 0x150) = 1; + if (bssid == (mac_addr_conflict67 *)0x0) { + bssid = (mac_addr_conflict67 *)&mac_addr_bcst; + } + memcpy((void *)((int)__dest + 0x140),bssid,6); + uVar3 = me_env.chan._252_2_; + if (chan_1 == (scan_chan_tag *)0x0) { + _chan_cnt = 0x4201c8ec; + *(undefined *)((int)__dest + 0x14f) = 0; + puVar5 = &local_2c; + local_2c = uVar3; + piVar6 = (int *)chan_cnt; + do { + iVar4 = 0; + while (iVar4 < (int)(uint)*(byte *)puVar5) { + __src_00 = (void *)(iVar4 * 6 + *piVar6); + if ((*(byte *)((int)__src_00 + 3) & 2) == 0) { + bVar2 = *(byte *)((int)__dest + 0x14f); + *(char *)((int)__dest + 0x14f) = bVar2 + 1; + memcpy((void *)((uint)bVar2 * 6 + (int)__dest),__src_00,6); + } + iVar4 = iVar4 + 1; + } + puVar5 = (undefined2 *)((int)puVar5 + 1); + piVar6 = piVar6 + 1; + } while (puVar5 != &uStack42); + } + else { + memcpy(__dest,chan_1,6); + *(undefined *)((int)__dest + 0x14f) = 1; + } + ke_msg_send(__dest); + ke_state_set(6,1); + return; +} + + + +void sm_join_bss(mac_addr_conflict67 *bssid,scan_chan_tag *chan,_Bool passive) + +{ + sm_connect_req *__src; + void *__dest; + undefined3 in_register_00002031; + + __src = sm_env.connect_param; + __dest = ke_msg_alloc(0x1002,4,6,0x154); + memcpy(__dest,chan,6); + *(undefined *)((int)__dest + 0x14f) = 1; + memcpy((void *)((int)__dest + 0xfc),__src,0x22); + *(undefined *)((int)__dest + 0x150) = 1; + *(undefined2 *)((int)__dest + 0x14c) = 0; + *(undefined4 *)((int)__dest + 0x148) = 0; + *(u8_l *)((int)__dest + 0x14e) = __src->vif_idx; + memcpy((void *)((int)__dest + 0x140),bssid,6); + if (CONCAT31(in_register_00002031,passive) != 0) { + *(byte *)((int)__dest + 3) = *(byte *)((int)__dest + 3) | 1; + } + sm_env.join_passive = passive; + ke_msg_send(__dest); + ke_state_set(6,2); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +uint8_t sm_add_chan_ctx(uint8_t *p_chan_idx) + +{ + uint8_t uVar1; + scan_chan_tag *psVar2; + uint uVar3; + u8_l uStack28; + uint8_t uStack27; + u16_l uStack26; + mm_chan_ctxt_add_req req; + + uVar3 = (uint)(sm_env.connect_param)->vif_idx; + psVar2 = vif_info_tab[uVar3].bss_info.chan; + uStack27 = vif_info_tab[uVar3].bss_info.phy_bw; + uStack28 = psVar2->band; + uStack26 = psVar2->freq; + req._0_4_ = *(undefined4 *)&vif_info_tab[uVar3].bss_info.center_freq1; + req.center1_freq._0_1_ = psVar2->tx_power; + uVar1 = chan_ctxt_add((mm_chan_ctxt_add_req *)&uStack28,p_chan_idx); + return uVar1; +} + + + +void sm_send_next_bss_param(void) + +{ + co_list_hdr *pcVar1; + + pcVar1 = co_list_pop_front(&sm_env.bss_config); + if (pcVar1 == (co_list_hdr *)0x0) { + assert_err("msg != NULL","module",0x1a0); + } + ke_msg_send(pcVar1 + 3); + return; +} + + + +void sm_set_bss_param(void) + +{ + sm_connect_req *psVar1; + vif_info_tag *pvVar2; + uint16_t uVar3; + undefined *puVar4; + void *__dest; + undefined4 *puVar5; + uint16_t *puVar6; + undefined *puVar7; + undefined2 extraout_var; + uint32_t *puVar8; + bool bVar9; + uint32_t uVar10; + uint uVar11; + int iVar12; + + psVar1 = sm_env.connect_param; + uVar11 = (uint)(sm_env.connect_param)->vif_idx; + puVar4 = (undefined *)ke_msg_alloc(0x1413,5,6,2); + __dest = ke_msg_alloc(0x18,0,6,7); + puVar5 = (undefined4 *)ke_msg_alloc(0x16,0,6,8); + puVar6 = (uint16_t *)ke_msg_alloc(0x14,0,6,4); + puVar7 = (undefined *)ke_msg_alloc(0x1411,5,6,2); + co_list_init(&sm_env.bss_config); + *puVar4 = 1; + puVar4[1] = psVar1->vif_idx; + co_list_push_back(&sm_env.bss_config,(co_list_hdr *)(puVar4 + -0xc)); + pvVar2 = vif_info_tab + uVar11; + memcpy(__dest,&vif_info_tab[uVar11].bss_info.bssid,6); + *(u8_l *)((int)__dest + 6) = psVar1->vif_idx; + co_list_push_back(&sm_env.bss_config,(co_list_hdr *)((int)__dest + -0xc)); + *(u8_l *)((int)puVar5 + 5) = (vif_info_tab[uVar11].bss_info.chan)->band; + uVar3 = me_legacy_rate_bitfield_build(&vif_info_tab[uVar11].bss_info.rate_set,true); + *puVar5 = CONCAT22(extraout_var,uVar3); + *(u8_l *)(puVar5 + 1) = psVar1->vif_idx; + co_list_push_back(&sm_env.bss_config,(co_list_hdr *)(puVar5 + -3)); + *puVar6 = vif_info_tab[uVar11].bss_info.beacon_period; + iVar12 = 0; + *(u8_l *)(puVar6 + 1) = psVar1->vif_idx; + co_list_push_back(&sm_env.bss_config,(co_list_hdr *)(puVar6 + -6)); + do { + puVar8 = (uint32_t *)ke_msg_alloc(0x1a,0,6,8); + uVar10 = (pvVar2->bss_info).edca_param.ac_param[0]; + *(undefined *)((int)puVar8 + 5) = (char)iVar12; + *puVar8 = uVar10; + *(u8_l *)((int)puVar8 + 6) = psVar1->vif_idx; + bVar9 = false; + if ((ps_env.uapsd_timeout != 0) && + ((char)vif_info_tab[uVar11].bss_info.edca_param.qos_info < '\0')) { + bVar9 = (mac_ac2uapsd[iVar12] & psVar1->uapsd_queues) != 0; + } + *(bool *)(puVar8 + 1) = bVar9; + iVar12 = iVar12 + 1; + co_list_push_back(&sm_env.bss_config,(co_list_hdr *)(puVar8 + -3)); + pvVar2 = (vif_info_tag *)&pvVar2->prevent_sleep; + } while (iVar12 != 4); + *puVar7 = 1; + puVar7[1] = psVar1->vif_idx; + co_list_push_back(&sm_env.bss_config,(co_list_hdr *)(puVar7 + -0xc)); + sm_send_next_bss_param(); + ke_state_set(6,4); + return; +} + + + +void sm_disconnect_process(vif_info_tag *vif,uint16_t reason) + +{ + uint16_t *puVar1; + + puVar1 = (uint16_t *)ke_msg_alloc(0x1805,0xd,6,4); + sm_delete_resources(vif); + *puVar1 = reason; + *(uint8_t *)(puVar1 + 1) = vif->index; + if (sm_env.ft_over_ds != false) { + *(undefined *)((int)puVar1 + 3) = 1; + } + ke_msg_send(puVar1); + return; +} + + + +void sm_deauth_cfm(void *env,u32_l status) + +{ + sm_disconnect_process((vif_info_tag *)env,0); + return; +} + + + +void sm_disconnect(uint8_t vif_index,uint16_t reason_code) + +{ + byte bVar1; + _Bool _Var2; + uint16_t uVar3; + undefined3 in_register_00002029; + int iVar4; + txl_frame_desc_tag *frame; + undefined2 extraout_var_00; + undefined3 extraout_var; + vif_info_tag *vif; + tx_hw_desc *ptVar5; + txl_buffer_tag *ptVar6; + + iVar4 = CONCAT31(in_register_00002029,vif_index); + vif = vif_info_tab + iVar4; + if ((vif_info_tab[iVar4].type == '\0') && (vif_info_tab[iVar4].active != false)) { + bVar1 = vif_info_tab[iVar4].u[4]; + ke_state_set(6,8); + frame = txl_frame_get((uint)((vif_info_tab[iVar4].bss_info.chan)->band != '\0'),0x100); + if (frame != (txl_frame_desc_tag *)0x0) { + tpc_update_frame_tx_power(vif,frame); + ptVar6 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar6[1].length = 0xc0; + *(undefined *)((int)&ptVar6[1].length + 1) = 0; + *(undefined *)((int)&ptVar6[1].length + 2) = 0; + *(undefined *)((int)&ptVar6[1].length + 3) = 0; + memcpy(&ptVar6[1].lenheader,&sta_info_tab[bVar1].mac_addr,6); + memcpy((void *)((int)&ptVar6[1].lenpad + 2),&vif_info_tab[iVar4].mac_addr,6); + memcpy(&ptVar6[1].next,&sta_info_tab[bVar1].mac_addr,6); + uVar3 = txl_get_seq_ctrl(); + *(undefined *)((int)&ptVar6[1].txdesc + 2) = (char)uVar3; + *(undefined *)((int)&ptVar6[1].txdesc + 3) = (char)(uVar3 >> 8); + (frame->cfm).cfm_func = sm_deauth_cfm; + *(vif_info_tag **)&(frame->cfm).env = vif; + (frame->txdesc).host.vif_idx = vif_index; + (frame->txdesc).host.staid = vif_info_tab[iVar4].u[4]; + uVar3 = me_build_deauthenticate((uint32_t)ptVar6[1].dma_desc,reason_code); + ptVar5 = (frame->txdesc).lmac.hw_desc; + (ptVar5->thd).frmlen = CONCAT22(extraout_var_00,uVar3) + 0x1c; + (ptVar5->thd).field_5 = (ptVar5->thd).field_4 + 0x17 + CONCAT22(extraout_var_00,uVar3); + _Var2 = txl_frame_push(frame,'\x03'); + if (CONCAT31(extraout_var,_Var2) != 0) { + return; + } + vif = (vif_info_tag *)(frame->cfm).env; + } + sm_disconnect_process(vif,0); + return; + } + return; +} + + + +void sm_connect_ind(uint16_t status) + +{ + sm_connect_req *ssid; + sm_connect_ind *psVar1; + int index; + undefined2 in_register_0000202a; + uint8_t uVar2; + uint uVar3; + chan_ctxt_tag *pcVar4; + uint uVar5; + + index = sm_env.exist_ssid_idx; + psVar1 = sm_env.connect_ind; + ssid = sm_env.connect_param; + uVar5 = (uint)(sm_env.connect_param)->vif_idx; + (sm_env.connect_ind)->vif_idx = (sm_env.connect_param)->vif_idx; + memcpy(&psVar1->bssid,&vif_info_tab[uVar5].bss_info.bssid,6); + psVar1->ap_idx = vif_info_tab[uVar5].u[4]; + printf("ind ix %p, chan_ctxt is %p\r\n",psVar1,vif_info_tab[uVar5].chan_ctxt); + pcVar4 = vif_info_tab[uVar5].chan_ctxt; + psVar1->ch_idx = '\0'; + if (pcVar4 == (chan_ctxt_tag *)0x0) { + psVar1->band = '\0'; + psVar1->center_freq = 0; + psVar1->center_freq1 = 0; + psVar1->center_freq2 = 0; + psVar1->width = '\0'; + } + else { + psVar1->band = ((vif_info_tab[uVar5].chan_ctxt)->channel).band; + psVar1->center_freq = ((vif_info_tab[uVar5].chan_ctxt)->channel).prim20_freq; + psVar1->center_freq1 = (uint)((vif_info_tab[uVar5].chan_ctxt)->channel).center1_freq; + psVar1->center_freq2 = (uint)((vif_info_tab[uVar5].chan_ctxt)->channel).center2_freq; + psVar1->width = ((vif_info_tab[uVar5].chan_ctxt)->channel).type; + } + uVar2 = '\0'; + uVar3 = vif_info_tab[uVar5].bss_info.valid_flags & 1; + psVar1->qos = SUB41(uVar3,0); + if (uVar3 != 0) { + uVar2 = vif_info_tab[uVar5].bss_info.edca_param.acm; + } + psVar1->acm = uVar2; + psVar1->roamed = false; + if (CONCAT22(in_register_0000202a,status) == 0) { + ke_state_set(6,0); + } + else { + ke_state_set(6,8); + printf("connect failure, ssid = %s, index = %d\r\n",(ssid->ssid).array,index); + if (-1 < index) { + printf("from sm_connect_ind to scanu_rm_exist_ssid\r\n"); + scanu_rm_exist_ssid((mac_ssid *)ssid,index); + sm_env.exist_ssid_idx = -1; + } + sm_delete_resources(vif_info_tab + uVar5); + } + ke_msg_free(sm_env.connect_param[-1].phrase_pmk + 0x37); + sm_env.connect_param = (sm_connect_req *)0x0; + sm_env.ft_over_ds = false; + psVar1->status_code = status; + ke_msg_send(psVar1); + sm_env.connect_ind = (sm_connect_ind *)0x0; + return; +} + + + +void sm_supplicant_deauth_cfm(void *env,u32_l status) + +{ + if (-1 < (int)(status << 8)) { + printf("sm deauth frame transmit failure\r\n"); + } + sm_connect_ind(8); + return; +} + + + +void sm_auth_send(uint16_t auth_seq,uint32_t *challenge) + +{ + byte bVar1; + sm_connect_req *psVar2; + txl_buffer_tag *ptVar3; + uint16_t uVar4; + undefined2 in_register_0000202a; + txl_frame_desc_tag *frame; + undefined2 extraout_var; + tx_hw_desc *ptVar5; + uint uVar6; + int iVar7; + + psVar2 = sm_env.connect_param; + uVar6 = (uint)(sm_env.connect_param)->vif_idx; + bVar1 = vif_info_tab[uVar6].u[4]; + frame = txl_frame_get((uint)((vif_info_tab[uVar6].bss_info.chan)->band != '\0'),0x100); + if (frame != (txl_frame_desc_tag *)0x0) { + tpc_update_frame_tx_power(vif_info_tab + uVar6,frame); + ptVar3 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar3[1].length = 0xb0; + *(undefined *)((int)&ptVar3[1].length + 1) = 0; + *(undefined *)((int)&ptVar3[1].length + 2) = 0; + *(undefined *)((int)&ptVar3[1].length + 3) = 0; + memcpy(&ptVar3[1].lenheader,&sta_info_tab[bVar1].mac_addr,6); + memcpy((void *)((int)&ptVar3[1].lenpad + 2),&vif_info_tab[uVar6].mac_addr,6); + memcpy(&ptVar3[1].next,&sta_info_tab[bVar1].mac_addr,6); + uVar4 = txl_get_seq_ctrl(); + *(undefined *)((int)&ptVar3[1].txdesc + 2) = (char)uVar4; + *(undefined *)((int)&ptVar3[1].txdesc + 3) = (char)(uVar4 >> 8); + (frame->txdesc).host.vif_idx = vif_info_tab[uVar6].index; + bVar1 = vif_info_tab[uVar6].u[4]; + (frame->txdesc).umac.head_len = '\0'; + (frame->txdesc).umac.tail_len = '\0'; + (frame->txdesc).host.staid = bVar1; + iVar7 = 0x18; + if ((psVar2->auth_type == '\x01') && (CONCAT22(in_register_0000202a,auth_seq) == 3)) { + txu_cntrl_protect_mgmt_frame((txdesc *)frame,(uint32_t)(ptVar3 + 1),0x18); + iVar7 = (uint)(frame->txdesc).umac.head_len + 0x18; + } + uVar4 = me_build_authenticate + ((int)&ptVar3[1].length + iVar7,(ushort)psVar2->auth_type,auth_seq,0,challenge + ); + bVar1 = (frame->txdesc).umac.tail_len; + ptVar5 = (frame->txdesc).lmac.hw_desc; + *(txl_frame_desc_tag **)&(frame->cfm).env = frame; + iVar7 = CONCAT22(extraout_var,uVar4) + (uint)bVar1 + iVar7; + (frame->cfm).cfm_func = sm_frame_tx_cfm_handler; + (ptVar5->thd).frmlen = iVar7 + 4; + (ptVar5->thd).field_5 = (ptVar5->thd).field_4 + -1 + iVar7; + txl_frame_push(frame,'\x03'); + ke_timer_set(0x1806,6,0x32000); + ke_state_set(6,5); + return; + } + sm_connect_ind(1); + return; +} + + + +// WARNING: Variable defined which should be unmapped: ie_addr +// WARNING: Could not reconcile some variable overlaps + +void sm_assoc_req_send(void) + +{ + byte bVar1; + sm_connect_req *con_par; + sm_connect_ind *psVar2; + txl_buffer_tag *ptVar3; + uint16_t uVar4; + txl_frame_desc_tag *frame; + undefined2 extraout_var; + tx_hw_desc *ptVar5; + _Bool _Var6; + sm_connect_ind *psVar7; + uint uVar8; + mac_addr_conflict171 *old_ap_addr_ptr; + uint16_t uStack54; + uint16_t ie_len; + uint32_t uStack52; + u32_l ie_addr; + + con_par = sm_env.connect_param; + uVar8 = (uint)(sm_env.connect_param)->vif_idx; + bVar1 = vif_info_tab[uVar8].u[4]; + frame = txl_frame_get((uint)((vif_info_tab[uVar8].bss_info.chan)->band != '\0'),0x100); + psVar2 = sm_env.connect_ind; + if (frame == (txl_frame_desc_tag *)0x0) { + sm_connect_ind(4); + } + else { + tpc_update_frame_tx_power(vif_info_tab + uVar8,frame); + ptVar3 = (frame->txdesc).lmac.buffer; + old_ap_addr_ptr = (mac_addr_conflict171 *)0x0; + _Var6 = sm_env.ft_over_ds; + if (sm_env.ft_over_ds != false) { + _Var6 = true; + old_ap_addr_ptr = (mac_addr_conflict171 *)&sm_env.ft_old_bssid; + } + *(_Bool *)&ptVar3[1].length = _Var6; + *(undefined *)((int)&ptVar3[1].length + 1) = 0; + *(undefined *)((int)&ptVar3[1].length + 2) = 0; + *(undefined *)((int)&ptVar3[1].length + 3) = 0; + memcpy(&ptVar3[1].lenheader,&sta_info_tab[bVar1].mac_addr,6); + memcpy((void *)((int)&ptVar3[1].lenpad + 2),&vif_info_tab[uVar8].mac_addr,6); + memcpy(&ptVar3[1].next,&sta_info_tab[bVar1].mac_addr,6); + uVar4 = txl_get_seq_ctrl(); + *(undefined *)((int)&ptVar3[1].txdesc + 2) = (char)uVar4; + *(undefined *)((int)&ptVar3[1].txdesc + 3) = (char)(uVar4 >> 8); + uVar4 = me_build_associate_req + ((uint32_t)ptVar3[1].dma_desc,&vif_info_tab[uVar8].bss_info,old_ap_addr_ptr, + vif_info_tab[uVar8].index,(uint32_t *)&stack0xffffffcc,&uStack54,con_par); + ptVar5 = (frame->txdesc).lmac.hw_desc; + (frame->txdesc).host.vif_idx = vif_info_tab[uVar8].index; + bVar1 = vif_info_tab[uVar8].u[4]; + *(txl_frame_desc_tag **)&(frame->cfm).env = frame; + (frame->txdesc).host.staid = bVar1; + (frame->cfm).cfm_func = sm_frame_tx_cfm_handler; + (ptVar5->thd).field_5 = (ptVar5->thd).field_4 + 0x17 + CONCAT22(extraout_var,uVar4); + (ptVar5->thd).frmlen = CONCAT22(extraout_var,uVar4) + 0x1c; + psVar7 = psVar2; + while (psVar7 != (sm_connect_ind *)((int)&psVar2->status_code + (uint)uStack54)) { + *(undefined *)psVar7->assoc_ie_buf = *(undefined *)((uStack52 - (int)psVar2) + (int)psVar7); + psVar7 = (sm_connect_ind *)((int)&psVar7->status_code + 1); + } + psVar2->assoc_req_ie_len = uStack54; + txl_frame_push(frame,'\x03'); + ke_timer_set(0x1806,6,0x32000); + ke_state_set(6,6); + } + return; +} + + + +void sm_assoc_done(uint16_t aid) + +{ + sm_connect_req *psVar1; + uint16_t *puVar2; + + psVar1 = sm_env.connect_param; + puVar2 = (uint16_t *)ke_msg_alloc(0x1e,0,6,4); + *puVar2 = aid; + *(undefined *)(puVar2 + 1) = 1; + *(u8_l *)((int)puVar2 + 3) = psVar1->vif_idx; + ke_msg_send(); + ke_state_set(6,7); + return; +} + + + +void sm_auth_handler(rxu_mgt_ind *param) + +{ + uint16_t auth_seq; + uint32_t *challenge; + + ke_timer_clear(0x1806,6); + if (param[1].center_freq != 0) { + if (((sm_env.connect_param)->auth_type != '\x01') || + ((sm_env.connect_param)->is_supplicant_enabled == false)) { + printf("Authentication failure, Wlan802.11 status code = %d\r\n"); + sm_connect_ind(2); + return; + } + (sm_env.connect_param)->auth_type = '\0'; + challenge = (uint32_t *)0x0; + auth_seq = 1; +LAB_2304e268: + sm_auth_send(auth_seq,challenge); + return; + } + if (param[1].length != 0) { + if (param[1].length != 1) { + return; + } + if (param[1].framectrl != 4) { + if (param[1].framectrl != 2) { + sm_connect_ind(3); + assert_warn("0","module",0x374); + return; + } + if (param->length < 0x88) { + printf("Drop illegal auth packet length %u\r\n"); + return; + } + challenge = (uint32_t *)¶m[1].inst_nbr; + auth_seq = 3; + goto LAB_2304e268; + } + } + sm_assoc_req_send(); + return; +} + + + +void sm_assoc_rsp_handler(rxu_mgt_ind *param) + +{ + uint8_t *puVar1; + byte bVar2; + ushort uVar3; + int iVar4; + sm_connect_ind *psVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint8_t uStack50; + int8_t aiStack49 [3]; + uint8_t idx; + s8_l pwr; + + psVar5 = sm_env.connect_ind; + uVar8 = (uint)(sm_env.connect_param)->vif_idx; + uStack50 = '\0'; + bVar2 = vif_info_tab[uVar8].u[4]; + ke_timer_clear(0x1806,6); + uVar6 = (uint)param[1].framectrl; + if (param[1].framectrl == 0) { + if (5 < param->length) { + uVar6 = (uint)param->length - 6 & 0xffff; + } + sm_assoc_done((ushort)(((uint)param[1].center_freq << 0x12) >> 0x12)); + me_init_rate(sta_info_tab + bVar2); + aiStack49[0] = (vif_info_tab[uVar8].bss_info.chan)->tx_power - + vif_info_tab[uVar8].bss_info.power_constraint; + tpc_update_vif_tx_power(vif_info_tab + uVar8,aiStack49,&uStack50); + uVar3 = psVar5->assoc_req_ie_len; + uVar7 = 0; + while (uVar6 != uVar7) { + puVar1 = ¶m[1].band + uVar7; + iVar4 = uVar7 + uVar3; + uVar7 = uVar7 + 1; + *(uint8_t *)((int)psVar5->assoc_ie_buf + iVar4) = *puVar1; + } + psVar5->assoc_rsp_ie_len = (u16_l)uVar6; + if ((*(uint *)&vif_info_tab[uVar8].bss_info.is_supplicant_enabled & 0x12a00) != 0) { + supplicantInitSession + (&sta_conn_info,(CHAR *)vif_info_tab[uVar8].bss_info.ssid.array, + (ushort)vif_info_tab[uVar8].bss_info.ssid.length, + (CHAR *)&vif_info_tab[uVar8].bss_info.bssid,(UINT8 *)&vif_info_tab[uVar8].mac_addr) + ; + } + } + else { + printf("Association failure, Wlan802.11 status code = %d\r\n",uVar6); + sm_connect_ind(5); + } + return; +} + + + +int sm_deauth_handler(rxu_mgt_ind *param) + +{ + byte bVar1; + ushort reason; + sm_connect_req *psVar2; + ke_state_t kVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + + psVar2 = sm_env.connect_param; + bVar1 = param->inst_nbr; + kVar3 = ke_state_get(6); + if (CONCAT31(extraout_var,kVar3) != 8) { + kVar3 = ke_state_get(6); + if (CONCAT31(extraout_var_00,kVar3) == 0) { + if (vif_info_tab[bVar1].active == false) { + return 0; + } + reason = param[1].length; + ke_state_set(6,8); + printf("Deauth by AP, Wlan802.11 reason code = %d\r\n",(uint)reason); + sm_disconnect_process(vif_info_tab + bVar1,reason); + return 0; + } + if (psVar2->vif_idx == param->inst_nbr) { + sm_connect_ind(6); + return 0; + } + } + return 2; +} + + + +void sm_handle_supplicant_result(uint8_t sta_id,uint16_t reason_code) + +{ + byte bVar1; + txl_buffer_tag *ptVar2; + _Bool _Var3; + uint16_t status; + undefined3 in_register_00002029; + int iVar4; + txl_frame_desc_tag *frame; + undefined2 extraout_var_00; + undefined3 extraout_var; + undefined2 in_register_0000202e; + tx_hw_desc *ptVar5; + uint uVar6; + + iVar4 = CONCAT31(in_register_00002029,sta_id); + bVar1 = sta_info_tab[iVar4].inst_nbr; + uVar6 = (uint)bVar1; + if (CONCAT22(in_register_0000202e,reason_code) == 0) { + sta_info_tab[iVar4].ctrl_port_state = '\x02'; + status = 0; + } + else { + if (CONCAT22(in_register_0000202e,reason_code) == 0xf) { + printf( + "4-way handshake timeout failure, wlan 802.11 reason code = %u, try to transmit deauth frame\r\n" + ); + } + frame = txl_frame_get((uint)((vif_info_tab[uVar6].bss_info.chan)->band != '\0'),0x100); + if (frame == (txl_frame_desc_tag *)0x0) { + status = 10; + } + else { + tpc_update_frame_tx_power(vif_info_tab + uVar6,frame); + ptVar2 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar2[1].length = 0xc0; + *(undefined *)((int)&ptVar2[1].length + 1) = 0; + *(undefined *)((int)&ptVar2[1].length + 2) = 0; + *(undefined *)((int)&ptVar2[1].length + 3) = 0; + memcpy(&ptVar2[1].lenheader,&sta_info_tab[iVar4].mac_addr,6); + memcpy((void *)((int)&ptVar2[1].lenpad + 2),&vif_info_tab[uVar6].mac_addr,6); + memcpy(&ptVar2[1].next,&sta_info_tab[iVar4].mac_addr,6); + status = txl_get_seq_ctrl(); + *(undefined *)((int)&ptVar2[1].txdesc + 2) = (char)status; + *(undefined *)((int)&ptVar2[1].txdesc + 3) = (char)(status >> 8); + (frame->cfm).cfm_func = sm_supplicant_deauth_cfm; + *(vif_info_tag **)&(frame->cfm).env = vif_info_tab + uVar6; + (frame->txdesc).host.vif_idx = bVar1; + (frame->txdesc).host.staid = sta_id; + status = me_build_deauthenticate((uint32_t)ptVar2[1].dma_desc,reason_code); + ptVar5 = (frame->txdesc).lmac.hw_desc; + (ptVar5->thd).frmlen = CONCAT22(extraout_var_00,status) + 0x1c; + (ptVar5->thd).field_5 = (ptVar5->thd).field_4 + 0x17 + CONCAT22(extraout_var_00,status); + _Var3 = txl_frame_push(frame,'\x03'); + if (CONCAT31(extraout_var,_Var3) != 0) { + return; + } + status = 9; + } + } + sm_connect_ind(status); + return; +} + + + +undefined2 * txu_cntrl_sec_hdr_append(int param_1,undefined2 *param_2,int param_3) + +{ + uint8_t uVar1; + ushort uVar2; + undefined2 *puVar3; + int iVar4; + key_info_tag *pkVar5; + + pkVar5 = *sta_info_tab[*(byte *)(param_1 + 0x30)].sta_sec_info.cur_key; + if (pkVar5 == (key_info_tag *)0x0) { + return param_2; + } + if (((vif_info_tab[*(byte *)(param_1 + 0x2f)].flags & 2) != 0) && + ((uint)sta_info_tab[*(byte *)(param_1 + 0x30)].ctrl_port_ethertype == + (((uint)*(ushort *)(param_1 + 0x20) & 0xff) << 8 | (uint)(*(ushort *)(param_1 + 0x20) >> 8)))) + { + return param_2; + } + uVar1 = pkVar5->cipher; + if (uVar1 == '\x01') { + param_2[-4] = *(ushort *)(param_1 + 0x22) & 0x7f00 | 0x2000 | *(ushort *)(param_1 + 0x22) >> 8; + uVar2 = (ushort)*(byte *)(param_1 + 0x22) | (ushort)pkVar5->key_idx << 0xe; +LAB_2304e702: + puVar3 = param_2 + -4; + param_2[-3] = uVar2 | 0x2000; + param_2[-2] = *(undefined2 *)(param_1 + 0x24); + param_2[-1] = *(undefined2 *)(param_1 + 0x26); + } + else { + if (uVar1 != '\0') { + if (uVar1 == '\x02') { + param_2[-4] = *(undefined2 *)(param_1 + 0x22); + uVar2 = (ushort)pkVar5->key_idx << 0xe; + goto LAB_2304e702; + } + puVar3 = param_2; + if (uVar1 != '\x03') goto LAB_2304e6b4; + } + puVar3 = param_2 + -2; + *puVar3 = *(undefined2 *)(param_1 + 0x22); + param_2[-1] = (ushort)pkVar5->key_idx << 0xe | *(ushort *)(param_1 + 0x24); + } +LAB_2304e6b4: + if (param_3 == 0) { + iVar4 = *(int *)(param_1 + 0x68) + 0xf0; + } + else { + iVar4 = *(int *)(param_1 + 0x54); + } + *(uint *)(iVar4 + 0xc) = (uint)pkVar5->hw_key_idx | *(uint *)(iVar4 + 0xc) & 0xffc00; + return puVar3; +} + + + +int txu_cntrl_sechdr_len_compute(txdesc *txdesc,int *tail_len) + +{ + byte bVar1; + uint8_t uVar2; + ushort uVar3; + int iVar4; + int iVar5; + uint uVar6; + uint uVar7; + key_info_tag *pkVar8; + + bVar1 = (txdesc->host).vif_idx; + pkVar8 = *sta_info_tab[(txdesc->host).staid].sta_sec_info.cur_key; + *tail_len = 0; + if (pkVar8 == (key_info_tag *)0x0) { + return 0; + } + if (((vif_info_tab[bVar1].flags & 2) != 0) && + (uVar3 = (txdesc->host).ethertype, + (uint)sta_info_tab[(txdesc->host).staid].ctrl_port_ethertype == + (((uint)uVar3 & 0xff) << 8 | (uint)(uVar3 >> 8)))) { + return 0; + } + uVar2 = pkVar8->cipher; + if (uVar2 == '\x01') { + iVar4 = 0xc; +LAB_2304e7f8: + *tail_len = iVar4; + if (((txdesc->host).flags & 1) == 0) { + uVar7 = *(uint *)&pkVar8->tx_pn; + iVar4 = *(int *)((int)&pkVar8->tx_pn + 4); + uVar6 = uVar7 + 1; + *(uint *)&pkVar8->tx_pn = uVar6; + *(int *)((int)&pkVar8->tx_pn + 4) = (uint)(uVar6 < uVar7) + iVar4; + memcpy((txdesc->host).pn,&pkVar8->tx_pn,6); + } + iVar4 = 8; + } + else { + if (uVar2 != '\0') { + if (uVar2 == '\x02') { + iVar4 = 8; + goto LAB_2304e7f8; + } + if (uVar2 != '\x03') { + return 0; + } + } + *tail_len = 4; + iVar4 = 4; + if (((txdesc->host).flags & 1) == 0) { + uVar7 = *(uint *)&pkVar8->tx_pn; + iVar5 = *(int *)((int)&pkVar8->tx_pn + 4); + uVar6 = uVar7 + 1; + *(uint *)&pkVar8->tx_pn = uVar6; + *(int *)((int)&pkVar8->tx_pn + 4) = (uint)(uVar6 < uVar7) + iVar5; + memcpy((txdesc->host).pn,&pkVar8->tx_pn,4); + } + } + return iVar4; +} + + + +void txu_cntrl_frame_build(txdesc *txdesc,uint32_t buf) + +{ + uint8_t uVar1; + byte bVar2; + int iVar3; + ushort *puVar4; + ushort *puVar5; + uint uVar6; + ushort uVar7; + ushort uVar8; + ushort *puVar9; + uint uVar10; + key_info_tag *pkVar11; + + uVar8 = (txdesc->host).ethertype; + if (0x5ff < (((uint)uVar8 & 0xff) << 8 | (uint)(uVar8 >> 8))) { + *(undefined2 *)(buf - 8) = 0xaaaa; + *(undefined2 *)(buf - 6) = 3; + *(undefined2 *)(buf - 4) = 0; + *(uint16_t *)(buf - 2) = (txdesc->host).ethertype; + } + iVar3 = txu_cntrl_sec_hdr_append(txdesc,1); + uVar6 = (uint)(txdesc->host).staid; + uVar1 = (txdesc->host).tid; + uVar10 = (uint)(txdesc->host).vif_idx; + pkVar11 = *sta_info_tab[uVar6].sta_sec_info.cur_key; + puVar9 = (ushort *)(iVar3 + -0x1a); + if (uVar1 == -1) { + puVar9 = (ushort *)(iVar3 + -0x18); + } + puVar4 = puVar9 + 0xc; + puVar5 = (ushort *)0x0; + if (((txdesc->host).flags & 0x100) != 0) { + puVar5 = puVar9 + -3; + puVar9 = puVar5; + } + if (uVar1 == -1) { + *(undefined *)puVar9 = 0; + *(undefined *)((int)puVar9 + 1) = 0; + *(undefined *)(puVar9 + 0xb) = 0; + *(undefined *)((int)puVar9 + 0x17) = 0; + } + else { + *(undefined *)puVar9 = 0x80; + *(undefined *)((int)puVar9 + 1) = 0; + *puVar4 = (ushort)(txdesc->host).tid; + iVar3 = (uint)(txdesc->host).sn << 0x14; + *(char *)(puVar9 + 0xb) = (char)((uint)iVar3 >> 0x10); + *(undefined *)((int)puVar9 + 0x17) = (char)((uint)iVar3 >> 0x18); + if (((txdesc->host).flags & 0x200) != 0) { + *puVar4 = *puVar4 | 0x10; + } + } + uVar7 = *puVar9; + *(byte *)puVar9 = (byte)uVar7 | 8; + *(undefined *)((int)puVar9 + 1) = (char)((uint)uVar7 >> 8); + uVar8 = (txdesc->host).flags; + if ((int)((uint)uVar8 << 0x14) < 0) { + uVar7 = uVar7 & 0xfcff | 8; +LAB_2304e93a: + *(char *)puVar9 = (char)uVar7; + *(undefined *)((int)puVar9 + 1) = (char)(uVar7 >> 8); + } + else { + if ((uVar8 & 0x100) != 0) { + uVar7 = uVar7 | 0x308; + goto LAB_2304e93a; + } + if (vif_info_tab[uVar10].type == '\0') { + uVar7 = uVar7 | 0x108; + goto LAB_2304e93a; + } + if (vif_info_tab[uVar10].type == '\x02') { + uVar7 = uVar7 | 0x208; + goto LAB_2304e93a; + } + } + if (((txdesc->host).flags & 4) != 0) { + uVar8 = *puVar9; + *(char *)puVar9 = (char)uVar8; + *(byte *)((int)puVar9 + 1) = (byte)((uint)uVar8 >> 8) | 0x20; + } + puVar9[5] = vif_info_tab[uVar10].mac_addr.array[0]; + puVar9[6] = vif_info_tab[uVar10].mac_addr.array[1]; + puVar9[7] = vif_info_tab[uVar10].mac_addr.array[2]; + bVar2 = *(byte *)((int)puVar9 + 1) & 3; + if (bVar2 == 1) { + puVar9[2] = sta_info_tab[uVar6].mac_addr.array[0]; + puVar9[3] = sta_info_tab[uVar6].mac_addr.array[1]; + puVar9[4] = sta_info_tab[uVar6].mac_addr.array[2]; + puVar9[8] = (txdesc->host).eth_dest_addr.array[0]; + puVar9[9] = (txdesc->host).eth_dest_addr.array[1]; + uVar8 = (txdesc->host).eth_dest_addr.array[2]; + } + else { + if (bVar2 == 2) { + puVar9[2] = (txdesc->host).eth_dest_addr.array[0]; + puVar9[3] = (txdesc->host).eth_dest_addr.array[1]; + puVar9[4] = (txdesc->host).eth_dest_addr.array[2]; + puVar9[8] = (txdesc->host).eth_src_addr.array[0]; + puVar9[9] = (txdesc->host).eth_src_addr.array[1]; + uVar8 = (txdesc->host).eth_src_addr.array[2]; + } + else { + if (bVar2 != 0) { + puVar5[2] = sta_info_tab[uVar6].mac_addr.array[0]; + puVar5[3] = sta_info_tab[uVar6].mac_addr.array[1]; + puVar5[4] = sta_info_tab[uVar6].mac_addr.array[2]; + puVar5[8] = (txdesc->host).eth_dest_addr.array[0]; + puVar5[9] = (txdesc->host).eth_dest_addr.array[1]; + puVar5[10] = (txdesc->host).eth_dest_addr.array[2]; + puVar5[0xc] = (txdesc->host).eth_src_addr.array[0]; + puVar5[0xd] = (txdesc->host).eth_src_addr.array[1]; + puVar5[0xe] = (txdesc->host).eth_src_addr.array[2]; + goto LAB_2304e9de; + } + puVar9[2] = (txdesc->host).eth_dest_addr.array[0]; + puVar9[3] = (txdesc->host).eth_dest_addr.array[1]; + puVar9[4] = (txdesc->host).eth_dest_addr.array[2]; + puVar9[8] = vif_info_tab[uVar10].bss_info.bssid.array[0]; + puVar9[9] = vif_info_tab[uVar10].bss_info.bssid.array[1]; + uVar8 = vif_info_tab[uVar10].bss_info.bssid.array[2]; + } + } + puVar9[10] = uVar8; +LAB_2304e9de: + if ((pkVar11 != (key_info_tag *)0x0) && + (((vif_info_tab[uVar10].flags & 2) == 0 || + (uVar8 = (txdesc->host).ethertype, + (uint)sta_info_tab[(txdesc->host).staid].ctrl_port_ethertype != + (((uint)uVar8 & 0xff) << 8 | (uint)(uVar8 >> 8)))))) { + uVar8 = *puVar9; + *(char *)puVar9 = (char)uVar8; + *(byte *)((int)puVar9 + 1) = (byte)((uint)uVar8 >> 8) | 0x40; + } + return; +} + + +/* +Unable to decompile 'txu_cntrl_push' +Cause: Exception while decompiling 2304eb44: Decompiler process died + +*/ + + +void txu_cntrl_tkip_mic_append(txdesc *txdesc,uint8_t ac) + +{ + uint8_t uVar1; + byte bVar2; + byte bVar3; + txl_buffer_tag *ptVar4; + uint32_t uVar5; + int iVar6; + key_info_tag *pkVar7; + int iVar8; + tx_pbd *ptVar9; + undefined *puVar10; + undefined *puVar11; + tx_pbd *ptVar12; + txl_buffer_tag *ptVar13; + undefined auStack48 [4]; + mic_calc mic; + + pkVar7 = *sta_info_tab[(txdesc->host).staid].sta_sec_info.cur_key; + if (pkVar7 != (key_info_tag *)0x0) { + uVar1 = pkVar7->cipher; + ptVar4 = (txdesc->lmac).buffer; + if (uVar1 != '\x01') { + if ((uVar1 == '\0') || (uVar1 == '\x03')) { + ptVar9 = &ptVar4->tbd; + do { + ptVar12 = ptVar9; + ptVar9 = (tx_pbd *)ptVar12->next; + } while (ptVar9 != (tx_pbd *)0x0); + *(tx_pbd **)&ptVar12->next = &ptVar4->tkip_mic_icv_pbd; + *(uint8_t **)&(ptVar4->tkip_mic_icv_pbd).datastartptr = ptVar4->tkip_mic_icv; + *(uint8_t **)&(ptVar4->tkip_mic_icv_pbd).dataendptr = ptVar4->tkip_mic_icv + 3; + (ptVar4->tkip_mic_icv_pbd).upatterntx = 0xcafefade; + (ptVar4->tkip_mic_icv_pbd).bufctrlinfo = 0; + (ptVar4->tkip_mic_icv_pbd).next = 0; + } + return; + } + ptVar9 = &ptVar4->tbd; + do { + ptVar12 = ptVar9; + ptVar9 = (tx_pbd *)ptVar12->next; + } while (ptVar9 != (tx_pbd *)0x0); + bVar2 = (txdesc->umac).head_len; + bVar3 = (txdesc->umac).hdr_len_802_2; + *(tx_pbd **)&ptVar12->next = &ptVar4->tkip_mic_icv_pbd; + *(uint8_t **)&(ptVar4->tkip_mic_icv_pbd).datastartptr = ptVar4->tkip_mic_icv; + *(uint8_t **)&(ptVar4->tkip_mic_icv_pbd).dataendptr = ptVar4->tkip_mic_icv + 0xb; + (ptVar4->tkip_mic_icv_pbd).upatterntx = 0xcafefade; + (ptVar4->tkip_mic_icv_pbd).bufctrlinfo = 0; + (ptVar4->tkip_mic_icv_pbd).next = 0; + ptVar13 = (txdesc->lmac).buffer; + me_mic_init((mic_calc *)auStack48,(uint32_t *)pkVar7->u, + (mac_addr_conflict51 *)&(txdesc->host).eth_dest_addr, + (mac_addr_conflict51 *)&(txdesc->host).eth_src_addr,(txdesc->host).tid); + me_mic_calc((mic_calc *)auStack48,(int)ptVar4 + (uint)bVar2 + (0x14c - (uint)bVar3), + (uint)(txdesc->umac).hdr_len_802_2); + uVar5 = (ptVar13->tbd).next; + while (uVar5 != 0) { + iVar6 = *(int *)(uVar5 + 4); + if (iVar6 == 0) { + me_mic_end((mic_calc *)auStack48); + iVar8 = *(int *)(uVar5 + 8); + do { + puVar10 = auStack48 + iVar6; + puVar11 = (undefined *)(iVar8 + iVar6); + iVar6 = iVar6 + 1; + *puVar11 = *puVar10; + } while (iVar6 != 8); + return; + } + me_mic_calc((mic_calc *)auStack48,*(uint32_t *)(uVar5 + 8), + (*(int *)(uVar5 + 0xc) + 1) - *(uint32_t *)(uVar5 + 8)); + uVar5 = *(uint32_t *)(uVar5 + 4); + } + me_mic_end((mic_calc *)auStack48); + ebreak(); + } + return; +} + + + +void txu_cntrl_cfm(txdesc *txdesc) + +{ + ushort uVar1; + tx_cfm_tag *ptVar2; + uint32_t *puVar3; + + puVar3 = (uint32_t *)(txdesc->host).status_addr; + ptVar2 = ((txdesc->lmac).hw_desc)->cfm_ptr; + uVar1 = (txdesc->host).flags; + if ((uVar1 & 8) == 0) { + if ((uVar1 & 0x200) == 0) goto LAB_2304eeba; + } + else { + if (((uVar1 & 0x20) != 0) && (-1 < (int)(ptVar2->status << 8))) { + rxu_cntrl_get_pm(); + } + if (((txdesc->host).flags & 0x200) == 0) goto LAB_2304eeba; + if ((txdesc->host).staid == -1) { + assert_err("txdesc->host.staid != INVALID_STA_IDX","module",0x3a9); + } + txl_frame_send_qosnull_frame((txdesc->host).staid,0x17,(cfm_func_ptr *)0x0,(void *)0x0); + } + sta_info_tab[(txdesc->host).staid].ps_service_period = 0; +LAB_2304eeba: + ptVar2->status = ptVar2->status | 1; + *(undefined2 *)&ptVar2->credits = 0x101; + txdesc[-1].buf[0x6b] = 0; + *puVar3 = ptVar2->status; + return; +} + + + +void txu_cntrl_protect_mgmt_frame(txdesc *txdesc,uint32_t frame,uint16_t hdr_len) + +{ + byte bVar1; + ushort uVar2; + uint uVar3; + undefined2 in_register_00002032; + uint uStack20; + int tail_len; + + bVar1 = (txdesc->umac).head_len; + uVar3 = (uint)bVar1; + if (bVar1 == 0) { + uVar3 = txu_cntrl_sechdr_len_compute(txdesc,(int *)&uStack20); + (txdesc->umac).head_len = (uint8_t)uVar3; + (txdesc->umac).tail_len = (uint8_t)uStack20; + } + else { + uStack20 = (uint)(txdesc->umac).tail_len; + } + uVar2 = *(ushort *)frame; + *(undefined *)frame = *(undefined *)frame; + *(byte *)(frame + 1) = (byte)((uint)uVar2 >> 8) | 0x40; + txu_cntrl_sec_hdr_append(txdesc,CONCAT22(in_register_00002032,hdr_len) + frame + uVar3,0); + return; +} + + + +int _aid_list_delete(uint8_t *mac) + +{ + int iVar1; + int iVar2; + apm *paVar3; + + paVar3 = &apm_env; + iVar1 = 0; + do { + if (paVar3->aid_list[0].used != '\0') { + iVar2 = memcmp(paVar3->aid_list,mac,6); + if (iVar2 == 0) { + memset(paVar3->aid_list,0,6); + apm_env.aid_list[iVar1].used = '\0'; + return 0; + } + } + iVar1 = iVar1 + 1; + paVar3 = (apm *)((int)&(paVar3->bss_config).first + 3); + } while (iVar1 != 10); + return -1; +} + + + +void apm_sta_delete(u8_l sta_idx,uint8_t *mac) + +{ + u8_l *puVar1; + u8_l *puVar2; + + puVar1 = (u8_l *)ke_msg_alloc(0x1409,5,7,2); + puVar2 = (u8_l *)ke_msg_alloc(0x1c09,0xd,7,1); + _aid_list_delete(mac); + mm_sec_machwkey_del(sta_idx + '\b'); + apm_env.assoc_sta_count = apm_env.assoc_sta_count + -1; + *puVar2 = sta_idx; + ke_msg_send(puVar2); + *puVar1 = sta_idx; + puVar1[1] = '\0'; + ke_msg_send(puVar1); + return; +} + + + +void apm_tx_cfm_handler(uint8_t *param_1,int param_2) + +{ + if (-1 < param_2 << 8) { + _aid_list_delete(param_1); + ke_msg_free(param_1 + -0xc); + printf("apm mlme assoc rsp send failed:%d,aid:%d\n",(uint)*(ushort *)(param_1 + 0x44)); + apm_env.assoc_sta_count = apm_env.assoc_sta_count + -1; + return; + } + if (*(short *)(param_1 + 0x44) != 0) { + ke_msg_send(); + return; + } + ke_msg_free(param_1 + -0xc); + return; +} + + + +void apm_init(void) + +{ + memset(&apm_env,0,0x60); + apm_env.aging_sta_idx = '\0'; + apm_env._22_2_ = 0xc00; + ke_state_set(7,0); + return; +} + + + +void apm_start_cfm(int param_1) + +{ + byte bVar1; + u16_l uVar2; + apm_start_req *__src; + undefined *puVar3; + void *pvVar4; + uint uVar5; + int iVar6; + + __src = apm_env.param; + puVar3 = (undefined *)ke_msg_alloc(0x1c01,0xd,7,4); + if (param_1 == 0) { + uVar5 = (uint)__src->vif_idx; + pvVar4 = ke_msg_alloc(0x1e,0,7,4); + iVar6 = uVar5 + 10; + *(undefined *)((int)pvVar4 + 2) = 1; + *(uint8_t *)((int)pvVar4 + 3) = vif_info_tab[uVar5].index; + ke_msg_send(); + vif_info_tab[uVar5].flags = __src->flags; + uVar2 = __src->ctrl_port_ethertype; + vif_info_tab[uVar5].u[0x2ee] = 0; + *(u16_l *)(vif_info_tab[uVar5].u + 0x2f0) = uVar2; + puVar3[2] = (vif_info_tab[uVar5].chan_ctxt)->idx; + puVar3[3] = __src->vif_idx + '\n'; + memcpy(&sta_info_tab[iVar6].info,__src,0xd); + sta_info_tab[iVar6].ctrl_port_state = '\x02'; + me_init_bcmc_rate(sta_info_tab + iVar6); + bVar1 = sta_info_tab[iVar6].pol_tbl.upd_field; + sta_info_tab[iVar6].mac_addr.array[0] = 1; + sta_info_tab[iVar6].pol_tbl.upd_field = bVar1 | 0x10; + sta_info_tab[iVar6].staid = __src->vif_idx + '\n'; + } + *puVar3 = (char)param_1; + puVar3[1] = __src->vif_idx; + ke_timer_set(0x1c0a,7,5000000); + ke_msg_send(puVar3); + ke_msg_free(__src[-1].phrase + 0x35); + apm_env.param = (apm_start_req *)0x0; + ke_state_set(7,0); + return; +} + + + +void apm_send_next_bss_param(void) + +{ + co_list_hdr *pcVar1; + + pcVar1 = co_list_pop_front(&apm_env.bss_config); + if (pcVar1 == (co_list_hdr *)0x0) { + assert_err("msg != NULL","module",0xbf); + } + ke_msg_send(pcVar1 + 3); + return; +} + + + +void apm_set_bss_param(void) + +{ + byte bVar1; + apm_start_req *rateset; + uint16_t uVar2; + undefined *puVar3; + void *__dest; + undefined4 *puVar4; + u16_l *puVar5; + undefined *puVar6; + undefined2 extraout_var; + + rateset = apm_env.param; + bVar1 = (apm_env.param)->vif_idx; + puVar3 = (undefined *)ke_msg_alloc(0x1413,5,7,2); + __dest = ke_msg_alloc(0x18,0,7,7); + puVar4 = (undefined4 *)ke_msg_alloc(0x16,0,7,8); + puVar5 = (u16_l *)ke_msg_alloc(0x14,0,7,4); + puVar6 = (undefined *)ke_msg_alloc(0x1411,5,7,2); + *puVar3 = 1; + puVar3[1] = vif_info_tab[bVar1].index; + co_list_push_back(&apm_env.bss_config,(co_list_hdr *)(puVar3 + -0xc)); + memcpy(__dest,&vif_info_tab[bVar1].mac_addr,6); + *(u8_l *)((int)__dest + 6) = rateset->vif_idx; + co_list_push_back(&apm_env.bss_config,(co_list_hdr *)((int)__dest + -0xc)); + *(u8_l *)((int)puVar4 + 5) = (rateset->chan).band; + uVar2 = me_legacy_rate_bitfield_build((mac_rateset *)rateset,true); + *puVar4 = CONCAT22(extraout_var,uVar2); + *(u8_l *)(puVar4 + 1) = rateset->vif_idx; + co_list_push_back(&apm_env.bss_config,(co_list_hdr *)(puVar4 + -3)); + *puVar5 = rateset->bcn_int; + *(u8_l *)(puVar5 + 1) = rateset->vif_idx; + co_list_push_back(&apm_env.bss_config,(co_list_hdr *)(puVar5 + -6)); + *puVar6 = 1; + puVar6[1] = rateset->vif_idx; + co_list_push_back(&apm_env.bss_config,(co_list_hdr *)(puVar6 + -0xc)); + apm_send_next_bss_param(); + ke_state_set(7,1); + return; +} + + + +void apm_stop(vif_info_tag *vif) + +{ + undefined *puVar1; + undefined *puVar2; + void *pvVar3; + + puVar1 = (undefined *)ke_msg_alloc(0x1413,5,7,2); + puVar2 = (undefined *)ke_msg_alloc(0x1411,5,7,2); + ke_timer_clear(0x1c0a,7); + *puVar1 = 0; + puVar1[1] = vif->index; + ke_msg_send(puVar1); + if (vif->active != false) { + pvVar3 = ke_msg_alloc(0x1e,0,7,4); + *(undefined *)((int)pvVar3 + 2) = 0; + *(uint8_t *)((int)pvVar3 + 3) = vif->index; + ke_msg_send(); + } + if (vif->chan_ctxt != (chan_ctxt_tag *)0x0) { + chan_ctxt_unlink(vif->index); + } + *puVar2 = 0; + puVar2[1] = vif->index; + ke_msg_send(puVar2); + return; +} + + + +_Bool apm_tx_int_ps_check(txdesc *txdesc) + +{ + byte bVar1; + undefined uVar2; + + if (vif_info_tab[(txdesc->host).vif_idx].type == '\x02') { + bVar1 = (txdesc->host).staid; + uVar2 = 1; + if (((bVar1 < 0xc) && (sta_info_tab[bVar1].ps_state == '\x01')) && + ((sta_info_tab[bVar1].ps_service_period & 3U) == 0)) { + (txdesc->host).flags = (txdesc->host).flags | 0x1000; + uVar2 = 0; + } + } + else { + uVar2 = 1; + } + return (_Bool)uVar2; +} + + + +void apm_tx_int_ps_postpone(txdesc *txdesc,sta_info_tag *sta) + +{ + byte bVar1; + sta_ps_traffic sVar2; + sta_ps_traffic sVar3; + uint16_t *puVar4; + + if ((int)((uint)(txdesc->host).flags << 0x13) < 0) { + bVar1 = (sta->info).uapsd_queues; + sVar2 = sta->traffic_avail; + if ((mac_ac2uapsd[(txdesc->host).tid] & bVar1) == 0) { + if ((sVar2 & PS_TRAFFIC_INT) != 0) { + return; + } + sVar3 = PS_TRAFFIC_INT; + } + else { + sVar3 = UAPSD_TRAFFIC_INT; + if ((sVar2 & UAPSD_TRAFFIC_INT) != 0) { + return; + } + } + sta->traffic_avail = sVar2 | sVar3; + if (((mac_ac2uapsd[(txdesc->host).tid] & bVar1) == 0) || (bVar1 == 0xf)) { + puVar4 = (uint16_t *)ke_msg_alloc(0x41,0,5,4); + *puVar4 = sta->aid; + *(uint8_t *)((int)puVar4 + 3) = sta->inst_nbr; + *(undefined *)(puVar4 + 1) = 1; + ke_msg_send(); + return; + } + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +txdesc * apm_tx_int_ps_get_postpone(vif_info_tag *vif,sta_info_tag *sta,int *stop) + +{ + uint8_t uVar1; + ushort uVar2; + co_list_hdr cVar3; + co_list_hdr element; + uint16_t *puVar4; + co_list_hdr *pcVar5; + uint uVar6; + int *piVar7; + sta_ps_traffic sVar8; + sta_ps_traffic sVar9; + co_list_hdr prev_element; + + sVar8 = vif->type; + if ((sVar8 == PS_TRAFFIC_INT) && (uVar6 = sta->ps_service_period, uVar6 != 0)) { + sVar9 = PS_TRAFFIC_HOST; + if ((uVar6 & 1) == 0) { + sVar9 = UAPSD_TRAFFIC_HOST; + sVar8 = UAPSD_TRAFFIC_INT; + } + if ((sVar8 & sta->traffic_avail) != 0) { + cVar3 = (co_list_hdr)(sta->tx_desc_post).first; + prev_element = (co_list_hdr)(co_list_hdr *)0x0; + while( true ) { + element = cVar3; + if (element == (co_list_hdr)0x0) { + assert_warn("txdesc","module",0x16f); + *stop = 1; + return (txdesc *)0x0; + } + if (((mac_ac2uapsd[*(byte *)((int)element + 0x2e)] & (sta->info).uapsd_queues) == 0) != + (uVar6 == 2)) break; + cVar3 = *(co_list_hdr *)element; + prev_element = element; + } + co_list_remove(&sta->tx_desc_post,(co_list_hdr *)prev_element,(co_list_hdr *)element); + *(char *)((int)element + 0x2e) = ((sta->ps_service_period & 8U) != 0) + '\x03'; + if (prev_element == (co_list_hdr)0x0) { + piVar7 = (int *)(sta->tx_desc_post).first; + } + else { + piVar7 = (int *)((co_list_hdr *)prev_element)->next; + } + while (piVar7 != (int *)0x0) { + if (((mac_ac2uapsd[*(byte *)((int)piVar7 + 0x2e)] & (sta->info).uapsd_queues) == 0) != + (sta->ps_service_period == 2)) goto LAB_2304f5ce; + piVar7 = (int *)*piVar7; + } + sVar8 = ~sVar8 & sta->traffic_avail; + sta->traffic_avail = sVar8; + if ((sVar8 & sVar9) == 0) { + puVar4 = (uint16_t *)ke_msg_alloc(0x41,0,5,4); + *puVar4 = sta->aid; + uVar1 = sta->inst_nbr; + *(undefined *)(puVar4 + 1) = 0; + *(uint8_t *)((int)puVar4 + 3) = uVar1; + ke_msg_send(); + } + else { +LAB_2304f5ce: + pcVar5 = ((co_list_hdr *)((int)element + 0x68))->next; + uVar2 = *(ushort *)&pcVar5[0x53].next; + *(char *)&pcVar5[0x53].next = (char)uVar2; + *(byte *)((int)&pcVar5[0x53].next + 1) = (byte)((uint)uVar2 >> 8) | 0x20; + } + return (txdesc *)element; + } + *stop = 1; + } + else { + *stop = 0; + } + return (txdesc *)0x0; +} + + + +void apm_tx_int_ps_clear(vif_info_tag *vif,u8_l sta_idx) + +{ + sta_ps_traffic sVar1; + uint8_t uVar2; + uint16_t *puVar3; + undefined3 in_register_0000202d; + int iVar4; + + iVar4 = CONCAT31(in_register_0000202d,sta_idx); + if (vif->type != '\x02') { + return; + } + sta_mgmt_send_postponed_frame(vif,sta_info_tab + iVar4,0); + sVar1 = sta_info_tab[iVar4].traffic_avail; + if (((sVar1 & (PS_TRAFFIC_INT|UAPSD_TRAFFIC_INT)) != 0) && + (sta_info_tab[iVar4].traffic_avail = sVar1 & ~(PS_TRAFFIC_INT|UAPSD_TRAFFIC_INT), + (sVar1 & ~(PS_TRAFFIC_INT|UAPSD_TRAFFIC_INT)) == 0)) { + puVar3 = (uint16_t *)ke_msg_alloc(0x41,0,5,4); + *puVar3 = sta_info_tab[iVar4].aid; + uVar2 = sta_info_tab[iVar4].inst_nbr; + *(undefined *)(puVar3 + 1) = 0; + *(uint8_t *)((int)puVar3 + 3) = uVar2; + ke_msg_send(); + return; + } + return; +} + + + +void apm_sta_fw_delete(u8_l sta_idx) + +{ + undefined3 in_register_00002029; + + apm_sta_delete(sta_idx,(uint8_t *)&sta_info_tab[CONCAT31(in_register_00002029,sta_idx)].mac_addr); + return; +} + + + +void apm_sta_add(u8_l sta_idx) + +{ + undefined3 in_register_00002029; + int iVar1; + uint32_t *puVar2; + + iVar1 = CONCAT31(in_register_00002029,sta_idx); + puVar2 = (uint32_t *)ke_msg_alloc(0x1c08,0xd,7,0x1c); + sta_info_tab[iVar1].ctrl_port_state = '\x02'; + *puVar2 = sta_info_tab[iVar1].info.capa_flags; + memcpy(puVar2 + 1,&sta_info_tab[iVar1].mac_addr,6); + *(uint8_t *)((int)puVar2 + 0xb) = sta_info_tab[iVar1].staid; + *(uint8_t *)((int)puVar2 + 10) = sta_info_tab[iVar1].inst_nbr; + *(int8_t *)(puVar2 + 3) = sta_info_tab[iVar1].rssi; + puVar2[4] = sta_info_tab[iVar1].tsflo; + puVar2[5] = sta_info_tab[iVar1].tsfhi; + *(uint8_t *)(puVar2 + 6) = sta_info_tab[iVar1].data_rate; + ke_msg_send(puVar2); + return; +} + + + +void apm_send_mlme(vif_info_tag *vif,uint16_t fctl,mac_addr_conflict75 *ra,cfm_func_ptr *cfm_func, + void *env,uint16_t status_code) + +{ + uint8_t uVar1; + txl_buffer_tag *ptVar2; + uint16_t uVar3; + txl_frame_desc_tag *frame; + undefined2 in_register_0000202e; + uint uVar4; + int iVar5; + tx_hw_desc *ptVar6; + + _uVar3 = CONCAT22(in_register_0000202e,fctl); + frame = txl_frame_get((uint)(((vif->bss_info).chan)->band != '\0'),0x100); + if (frame == (txl_frame_desc_tag *)0x0) { + return; + } + ptVar2 = (frame->txdesc).lmac.buffer; + *(undefined *)((int)&ptVar2[1].length + 1) = (char)(fctl >> 8); + *(char *)&ptVar2[1].length = (char)fctl; + *(undefined *)((int)&ptVar2[1].length + 2) = 0; + *(undefined *)((int)&ptVar2[1].length + 3) = 0; + memcpy(&ptVar2[1].lenheader,ra,6); + memcpy((void *)((int)&ptVar2[1].lenpad + 2),&vif->mac_addr,6); + memcpy(&ptVar2[1].next,&vif->mac_addr,6); + uVar4 = (uint)txl_cntrl_env.seqnbr; + txl_cntrl_env.seqnbr = (uint16_t)((uVar4 + 1) * 0x10000 >> 0x10); + iVar5 = (uVar4 + 1) * 0x100000; + *(undefined *)((int)&ptVar2[1].txdesc + 2) = (char)((uint)iVar5 >> 0x10); + *(undefined *)((int)&ptVar2[1].txdesc + 3) = (char)((uint)iVar5 >> 0x18); + if (_uVar3 == 0xb0) { + uVar3 = me_build_authenticate((uint32_t)ptVar2[1].dma_desc,0,2,0,(uint32_t *)0x0); + _uVar3 = (uint)uVar3; + } + else { + if (_uVar3 == 0xc0) { + uVar3 = me_build_deauthenticate((uint32_t)ptVar2[1].dma_desc,status_code); + _uVar3 = (uint)uVar3; + } + else { + if (_uVar3 == 0x50) { + uVar3 = me_build_probe_rsp((uint32_t)ptVar2[1].dma_desc,vif->index); + _uVar3 = (uint)uVar3; + } + else { + uVar4 = 0x18; + if ((_uVar3 & 0xffffffdf) != 0x10) goto LAB_2304f826; + uVar3 = me_build_associate_rsp + ((uint32_t)ptVar2[1].dma_desc,vif->index,status_code,(me_sta_add_req *)env + ); + _uVar3 = (uint)uVar3; + } + } + } + uVar4 = _uVar3 + 0x18 & 0xffff; +LAB_2304f826: + ptVar6 = (frame->txdesc).lmac.hw_desc; + (ptVar6->thd).frmlen = uVar4 + 4; + (ptVar6->thd).field_5 = (ptVar6->thd).field_4 + -1 + uVar4; + uVar1 = vif->index; + (frame->txdesc).umac.head_len = '\0'; + (frame->txdesc).umac.tail_len = '\0'; + (frame->txdesc).host.vif_idx = uVar1; + (frame->txdesc).host.staid = -1; + (frame->cfm).cfm_func = cfm_func; + (frame->cfm).env = env; + txl_frame_push(frame,'\x03'); + return; +} + + + +_Bool apm_embedded_enabled(vif_info_tag *vif) + +{ + _Bool _Var1; + + if (vif != (vif_info_tag *)0x0) { + _Var1 = false; + if (vif->type == '\x02') { + _Var1 = apm_env.apm_emb_enabled; + } + return (_Bool)(_Var1 & 1); + } + return apm_env.apm_emb_enabled; +} + + + +void apm_bcn_set(void) + +{ + byte bVar1; + apm_start_req *paVar2; + _Bool _Var3; + u32_l *puVar4; + undefined3 extraout_var; + + paVar2 = apm_env.param; + puVar4 = (u32_l *)ke_msg_alloc(0x3f,0,7,(uint16_t) + (((uint)(apm_env.param)->bcn_len + 0xc) * 0x10000 >> 0x10) + ); + *puVar4 = paVar2->bcn_addr; + *(u16_l *)(puVar4 + 1) = paVar2->bcn_len; + *(u16_l *)((int)puVar4 + 6) = paVar2->tim_oft; + *(u8_l *)(puVar4 + 2) = paVar2->tim_len; + bVar1 = paVar2->vif_idx; + *(byte *)((int)puVar4 + 9) = bVar1; + _Var3 = apm_embedded_enabled(vif_info_tab + bVar1); + if (CONCAT31(extraout_var,_Var3) == 0) { + memcpy(puVar4 + 3,(void *)&paVar2->field_0xa7,(uint)paVar2->bcn_len); + } + else { + memcpy(puVar4 + 3,apm_env.bcn_buf,(uint)paVar2->bcn_len); + ke_free(apm_env.bcn_buf); + apm_env.bcn_buf = (uint8_t *)0x0; + } + ke_msg_send(puVar4); + ke_state_set(7,2); + return; +} + + + +void apm_probe_req_handler(ushort *param_1) + +{ + u8_l uVar1; + ushort uVar2; + int iVar3; + vif_info_tag *vif; + uint __n; + scan_chan_tag *psVar4; + int iVar5; + uint uVar6; + + if (*(byte *)(param_1 + 4) == 0xff) { + vif = vif_mgmt_get_first_ap_inf(); + if (vif == (vif_info_tag *)0x0) { + return; + } + } + else { + vif = vif_info_tab + *(byte *)(param_1 + 4); + } + iVar3 = mac_ie_find(param_1 + 0x1a,(uint)*param_1 - 0x18 & 0xffff,0); + if ((iVar3 == 0) || (*(byte *)(iVar3 + 1) == 0)) { + if (apm_env.hidden_ssid != '\0') { + return; + } + } + else { + __n = (uint)(vif->bss_info).ssid.length; + if (__n != (uint)*(byte *)(iVar3 + 1)) { + return; + } + iVar3 = memcmp((void *)(iVar3 + 2),(vif->bss_info).ssid.array,__n); + if (iVar3 != 0) { + return; + } + } + iVar3 = mac_ie_find(param_1 + 0x1a,(uint)*param_1 - 0x18 & 0xffff,3); + if (iVar3 == 0) goto LAB_2304fa0e; + psVar4 = (vif->bss_info).chan; + uVar1 = psVar4->band; + uVar2 = psVar4->freq; + __n = (uint)uVar2; + if (uVar1 == '\0') { + uVar6 = 0; + if (((__n - 0x96c & 0xffff) < 0x49) && (uVar6 = 0xe, uVar2 != 0x9b4)) { + iVar5 = -0x967; +LAB_2304fa84: + uVar6 = (int)(__n + iVar5) / 5; + } + } + else { + uVar6 = 0; + if ((uVar1 == '\x01') && (uVar6 = 0, (__n - 0x138d & 0xffff) < 0x335)) { + iVar5 = -5000; + goto LAB_2304fa84; + } + } + if ((uint)*(byte *)(iVar3 + 2) != uVar6) { + return; + } +LAB_2304fa0e: + apm_send_mlme(vif,0x50,(mac_addr_conflict75 *)(param_1 + 0x13),(cfm_func_ptr *)0x0,(void *)0x0,0); + return; +} + + + +void apm_auth_handler(rxu_mgt_ind *param) + +{ + byte bVar1; + mac_addr_conflict171 *addr; + u8_l sta_idx; + undefined3 extraout_var; + + bVar1 = param->inst_nbr; + if (bVar1 != 0xff) { + addr = (mac_addr_conflict171 *)(param[1].sa + 1); + sta_idx = hal_machw_search_addr(addr); + if (CONCAT31(extraout_var,sta_idx) != 0xff) { + apm_sta_delete(sta_idx,(uint8_t *)addr); + } + apm_send_mlme(vif_info_tab + bVar1,0xb0,(mac_addr_conflict75 *)addr,(cfm_func_ptr *)0x0, + (void *)0x0,0); + return; + } + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void apm_assoc_req_handler(ushort *param_1,int param_2) + +{ + u8_l uVar1; + IEEEtypes_Addr_t IVar2; + uint8_t uVar3; + uint8_t uVar4; + ushort *puVar5; + byte bVar6; + uint16_t status_code; + IEEEtypes_MacAddr_t *peerMacAddr; + int iVar7; + int iVar8; + undefined2 extraout_var; + u8_l *puVar9; + int iVar10; + uint16_t fctl; + uint __n; + mac_rateset *pmVar11; + IEEEtypes_Addr_t *pIVar12; + IEEEtypes_Addr_t *pIVar13; + uint uVar14; + apm *paVar15; + mac_addr_conflict75 *ra; + short sVar16; + uint uVar17; + Cipher_t_conflict aCStack84 [4]; + undefined2 uStack80; + + uVar17 = (uint)*(byte *)(param_1 + 4); + if (*(byte *)(param_1 + 4) == 0xff) { + return; + } + peerMacAddr = (IEEEtypes_MacAddr_t *)ke_msg_alloc(0x1407,5,7,0x58); + ra = (mac_addr_conflict75 *)(param_1 + 0x13); + memset(peerMacAddr,0,0x58); + memcpy(peerMacAddr,ra,6); + (peerMacAddr + 0xc)[1] = *(IEEEtypes_Addr_t *)(param_1 + 4); + *(undefined4 *)(peerMacAddr + 0xc + 4) = *(undefined4 *)(param_1 + 8); + *(undefined4 *)(peerMacAddr + 0xd + 2) = *(undefined4 *)(param_1 + 10); + (peerMacAddr + 0xe)[0] = *(IEEEtypes_Addr_t *)(param_1 + 0xc); + (peerMacAddr + 0xe)[1] = *(IEEEtypes_Addr_t *)((int)param_1 + 0x1b); + if (param_2 == 0) { + puVar5 = param_1 + 0x1c; + uVar14 = (uint)*param_1 - 0x1c; + } + else { + puVar5 = param_1 + 0x1f; + uVar14 = (uint)*param_1 - 0x22; + } + status_code = 0x33; + if (param_1[0x1b] <= vif_info_tab[uVar17].bss_info.max_listen_interval) { + uVar14 = uVar14 & 0xffff; + iVar7 = mac_ie_find(puVar5,uVar14,0); + if (((iVar7 == 0) || + (__n = (uint)vif_info_tab[uVar17].bss_info.ssid.length, __n != (uint)*(byte *)(iVar7 + 1))) + || (iVar7 = memcmp((void *)(iVar7 + 2),vif_info_tab[uVar17].bss_info.ssid.array,__n), + iVar7 != 0)) { + status_code = 1; + } + else { + iVar8 = mac_ie_find(puVar5,uVar14,1); + status_code = 0x12; + if (iVar8 != 0) { + __n = (uint)*(byte *)(iVar8 + 1); + puVar9 = (u8_l *)(iVar8 + 2); + uStack80 = uStack80 & 0xff00 | (ushort)*(byte *)(iVar8 + 1); + pmVar11 = (mac_rateset *)&uStack80; + while( true ) { + __n = __n - 1; + pmVar11 = (mac_rateset *)pmVar11->array; + if (__n == 0xffffffff) break; + uVar1 = *puVar9; + puVar9 = puVar9 + 1; + pmVar11->length = uVar1; + } + iVar8 = mac_ie_find(puVar5,uVar14,0x32); + if (iVar8 != 0) { + bVar6 = *(byte *)(iVar8 + 1); + __n = 0; + while ((uint)bVar6 != __n) { + *(undefined *)((int)&uStack80 + (byte)uStack80 + __n + 1) = + *(undefined *)(iVar8 + 2 + __n); + __n = __n + 1; + } + uStack80 = uStack80 & 0xff00 | (ushort)(byte)(bVar6 + (byte)uStack80); + } + status_code = me_legacy_rate_bitfield_build((mac_rateset *)&uStack80,false); + (peerMacAddr + 1)[0] = '\0'; + __n = 0; + while (__n < vif_info_tab[uVar17].bss_info.rate_set.length) { + iVar8 = (int)&vif_info_tab[uVar17].list_hdr.next + __n; + bVar6 = me_rate_translate(*(uint8_t *)(iVar8 + 0x3b1)); + if ((CONCAT22(extraout_var,status_code) >> ((uint)bVar6 & 0x1f) & 1U) == 0) { + if (*(char *)(iVar8 + 0x3b1) < '\0') { + status_code = 0x12; + goto fail; + } + } + else { + bVar6 = (peerMacAddr + 1)[0]; + (peerMacAddr + 1)[(uint)bVar6 + 1] = *(IEEEtypes_Addr_t *)(iVar8 + 0x3b1); + (peerMacAddr + 1)[0] = bVar6 + 1; + } + __n = __n + 1 & 0xff; + } + iVar8 = mac_ie_find(puVar5,uVar14,0x2d); + if (iVar8 != 0) { + *(undefined2 *)(peerMacAddr + 3 + 2) = *(undefined2 *)(iVar8 + 2); + pIVar12 = (IEEEtypes_Addr_t *)(iVar8 + 5); + (peerMacAddr + 3)[4] = *(IEEEtypes_Addr_t *)(iVar8 + 4); + pIVar13 = peerMacAddr + 3 + 5; + while (pIVar13 != peerMacAddr + 6 + 3) { + IVar2 = *pIVar12; + pIVar12 = pIVar12 + 1; + *pIVar13 = IVar2; + pIVar13 = pIVar13 + 1; + } + *(undefined2 *)(peerMacAddr + 6 + 4) = *(undefined2 *)(iVar8 + 0x15); + *(uint *)(peerMacAddr + 7 + 2) = (uint)*(ushort *)(iVar8 + 0x17); + (peerMacAddr + 8)[0] = *(IEEEtypes_Addr_t *)(iVar8 + 0x1b); + *(uint *)(peerMacAddr + 10 + 4) = *(uint *)(peerMacAddr + 10 + 4) | 2; + } + iVar8 = mac_vsie_find(puVar5,uVar14,&DAT_2307bf70,4); + if (iVar8 != 0) { + bVar6 = *(byte *)(iVar8 + 8); + *(uint *)(peerMacAddr + 10 + 4) = *(uint *)(peerMacAddr + 10 + 4) | 1; + (peerMacAddr + 0xb)[4] = bVar6 & 0xf; + (peerMacAddr + 0xb)[5] = bVar6 >> 4 & 6; + } + memset((mac_rateset *)&uStack80,0,2); + memset(aCStack84,0,1); + iVar8 = mac_ie_find(puVar5,uVar14,0x30); + if (iVar8 == 0) { + iVar8 = mac_vsie_find(puVar5,uVar14,&DAT_2307bf78,4); + if (iVar8 != 0) { + uStack80 = uStack80 | 8; + aCStack84[0] = (Cipher_t_conflict)((byte)aCStack84[0] | 4); + } + } + else { + uStack80 = uStack80 | 0x20; + aCStack84[0] = (Cipher_t_conflict)((byte)aCStack84[0] | 8); + } + if (uap_conn_info != (cm_ConnectionInfo_t *)0x0) { + status_code = 0x2e; + if ((uStack80 & 0x28) == 0) goto fail; + InitStaKeyInfo(uap_conn_info,(SecurityMode_t *)(mac_rateset *)&uStack80,aCStack84,0,'\0'); + cm_SetPeerAddr(uap_conn_info,(IEEEtypes_MacAddr_t *)0x0,peerMacAddr); + } + uVar4 = apm_env.max_sta_supported; + uVar3 = apm_env.assoc_sta_count; + *(undefined2 *)(peerMacAddr + 0xb + 2) = 0; + if (uVar3 < uVar4) { + paVar15 = &apm_env; + iVar8 = -1; + do { + sVar16 = (short)iVar7; + if (paVar15->aid_list[0].used == '\0') { + if (iVar8 == -1) { + iVar8 = iVar7; + } + } + else { + iVar10 = memcmp(paVar15->aid_list,ra,6); + if (iVar10 == 0) { + apm_env.aid_list[iVar7].used = '\x01'; + goto LAB_2304fea4; + } + } + sVar16 = (short)iVar8; + iVar7 = iVar7 + 1; + paVar15 = (apm *)((int)&(paVar15->bss_config).first + 3); + } while (iVar7 != 10); + if (iVar8 != -1) { + memcpy(apm_env.aid_list + iVar8,ra,6); + apm_env.aid_list[iVar8].used = '\x01'; +LAB_2304fea4: + *(short *)(peerMacAddr + 0xb + 2) = sVar16 + 1; + apm_env.assoc_sta_count = apm_env.assoc_sta_count + '\x01'; + status_code = 0; + goto fail; + } + } + status_code = 0x11; + } + } + } +fail: + fctl = 0x30; + if (param_2 == 0) { + fctl = 0x10; + } + apm_send_mlme(vif_info_tab + uVar17,fctl,ra,apm_tx_cfm_handler,peerMacAddr,status_code); + return; +} + + + +void apm_deauth_handler(rxu_mgt_ind *param) + +{ + if ((param->inst_nbr != -1) && (param->sta_idx != -1)) { + apm_sta_delete(param->sta_idx,param[1].sa + 1); + return; + } + return; +} + + + +void apm_disassoc_handler(rxu_mgt_ind *param) + +{ + byte bVar1; + + bVar1 = param->inst_nbr; + if ((bVar1 != 0xff) && (param->sta_idx != -1)) { + apm_sta_delete(param->sta_idx,(uint8_t *)(mac_addr_conflict75 *)(param[1].sa + 1)); + apm_send_mlme(vif_info_tab + bVar1,0xc0,(mac_addr_conflict75 *)(param[1].sa + 1), + (cfm_func_ptr *)0x0,(void *)0x0,2); + return; + } + return; +} + + + +void apm_beacon_handler(rxu_mgt_ind *param) + +{ + return; +} + + + +void apm_sta_remove(u8_l vif_idx,u8_l sta_idx) + +{ + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + + apm_send_mlme(vif_info_tab + CONCAT31(in_register_00002029,vif_idx),0xc0, + (mac_addr_conflict75 *) + &sta_info_tab[CONCAT31(in_register_0000202d,sta_idx)].mac_addr,(cfm_func_ptr *)0x0, + (void *)0x0,2); + apm_sta_delete(sta_idx,(uint8_t *) + (mac_addr_conflict75 *) + &sta_info_tab[CONCAT31(in_register_0000202d,sta_idx)].mac_addr); + return; +} + + + +void co_list_init(co_list *list) + +{ + list->first = (co_list_hdr *)0x0; + list->last = (co_list_hdr *)0x0; + return; +} + + + +void co_list_push_back(co_list *list,co_list_hdr *list_hdr) + +{ + if (list_hdr == (co_list_hdr *)0x0) { + assert_err("list_hdr != NULL","module",0x47); + } + if (list->first == (co_list_hdr *)0x0) { + list->first = list_hdr; + } + else { + list->last->next = list_hdr; + } + list->last = list_hdr; + list_hdr->next = (co_list_hdr *)0x0; + return; +} + + + +void co_list_push_front(co_list *list,co_list_hdr *list_hdr) + +{ + if (list_hdr == (co_list_hdr *)0x0) { + assert_err("list_hdr != NULL","module",0x5e); + } + if (list->first == (co_list_hdr *)0x0) { + list->last = list_hdr; + } + list_hdr->next = list->first; + list->first = list_hdr; + return; +} + + + +co_list_hdr * co_list_pop_front(co_list *list) + +{ + co_list_hdr *pcVar1; + + pcVar1 = list->first; + if (pcVar1 != (co_list_hdr *)0x0) { + list->first = pcVar1->next; + } + return pcVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +void co_list_extract(co_list *list,co_list_hdr *list_hdr) + +{ + co_list_hdr cVar1; + co_list_hdr cVar2; + + if (list == (co_list *)0x0) { + assert_err("list != NULL","module",0x81); + } + cVar1 = (co_list_hdr)list->first; + if (cVar1 != (co_list_hdr)0x0) { + if (cVar1 == (co_list_hdr)list_hdr) { + list->first = list_hdr->next; + } + else { + do { + cVar2 = cVar1; + cVar1 = *(co_list_hdr *)cVar2; + if (cVar1 == (co_list_hdr)0x0) { + return; + } + } while (cVar1 != (co_list_hdr)list_hdr); + if (list->last == list_hdr) { + *(co_list_hdr *)&((co_list_hdr *)&list->last)->next = cVar2; + } + *(co_list_hdr **)cVar2 = list_hdr->next; + } + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +uint32_t co_list_cnt(co_list *list) + +{ + uint32_t uVar1; + int *piVar2; + + piVar2 = (int *)list->first; + uVar1 = 0; + while (piVar2 != (int *)0x0) { + uVar1 = uVar1 + 1; + piVar2 = (int *)*piVar2; + } + return uVar1; +} + + + +// WARNING: Type propagation algorithm not settling + +void co_list_insert(co_list *list,co_list_hdr *element, + anon_subr__Bool_co_list_hdr_ptr_co_list_hdr_ptr *cmp) + +{ + co_list_hdr cVar1; + co_list_hdr cVar2; + _Bool _Var3; + undefined3 extraout_var; + co_list_hdr cVar4; + + cVar1 = (co_list_hdr)list->first; + cVar4 = (co_list_hdr)(co_list_hdr *)0x0; + while (cVar2 = cVar1, cVar2 != (co_list_hdr)0x0) { + _Var3 = (*cmp)(element,(co_list_hdr *)cVar2); + if (CONCAT31(extraout_var,_Var3) != 0) goto LAB_230500d4; + cVar1 = *(co_list_hdr *)cVar2; + cVar4 = cVar2; + } + list->last = element; +LAB_230500d4: + *(co_list_hdr *)&element->next = cVar2; + if (cVar4 == (co_list_hdr)0x0) { + list->first = element; + } + else { + ((co_list_hdr *)cVar4)->next = element; + } + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void co_list_insert_after(co_list *list,co_list_hdr *prev_element,co_list_hdr *element) + +{ + co_list_hdr cVar1; + + cVar1 = (co_list_hdr)list->first; + if (prev_element == (co_list_hdr *)0x0) { + co_list_push_front(list,element); + return; + } + while( true ) { + if (cVar1 == (co_list_hdr)0x0) { + return; + } + if (cVar1 == (co_list_hdr)prev_element) break; + cVar1 = *(co_list_hdr *)cVar1; + } + element->next = *(co_list_hdr **)cVar1; + *(co_list_hdr **)cVar1 = element; + if (element->next != (co_list_hdr *)0x0) { + return; + } + list->last = element; + return; +} + + + +void co_list_remove(co_list *list,co_list_hdr *prev_element,co_list_hdr *element) + +{ + if (list == (co_list *)0x0) { + assert_err("list != NULL","module",0x168); + } + if (prev_element == (co_list_hdr *)0x0) { + if (element == (co_list_hdr *)0x0) goto LAB_23050178; +LAB_23050192: + list->first = element->next; + } + else { + if (prev_element->next != element) { + assert_err("(prev_element == NULL) || (prev_element->next == element)","module",0x169); + } + if (element == (co_list_hdr *)0x0) { +LAB_23050178: + assert_err("element != NULL","module",0x16a); + if (prev_element == (co_list_hdr *)0x0) goto LAB_23050192; + } + prev_element->next = element->next; + if (list->last == element) { + list->last = prev_element; + } + } + element->next = (co_list_hdr *)0x0; + return; +} + + +/* +Unable to decompile 'ke_evt_set' +Cause: Exception while decompiling 230501a8: Decompiler process died + +*/ + +/* +Unable to decompile 'ke_evt_clear' +Cause: Exception while decompiling 230501c0: Decompiler process died + +*/ + + +void bl_event_handle(int param) + +{ + ke_evt_clear(0x40000000); + bl_main_event_handle(); + return; +} + + +/* +Unable to decompile 'bl_fw_statistic_dump' +Cause: Exception while decompiling 230501f0: Decompiler process died + +*/ + + +void bl60x_fw_dump_statistic(int forced) + +{ + if (forced != 0) { + bl_fw_statistic_dump(0); + return; + } + ke_evt_set(0x20); + return; +} + + + +void ke_evt_schedule(void) + +{ + int iVar1; + evt_ptr_t *peVar2; + + while (ke_env.evt_field != 0) { + iVar1 = __clzsi2(ke_env.evt_field); + peVar2 = ke_evt_hdlr[iVar1].func; + if ((0x1a < iVar1) || (peVar2 == (evt_ptr_t *)0x0)) { + assert_err("(event < KE_EVT_MAX) && ke_evt_hdlr[event].func","module",0xdd); + } + (*peVar2)(ke_evt_hdlr[iVar1].param); + } + return; +} + + + +void ke_init(void) + +{ + ke_env.mblock_first = ke_mem_init(); + ke_env.queue_saved.first = (co_list_hdr *)0x0; + ke_env.queue_saved.last = (co_list_hdr *)0x0; + ke_env.queue_sent.first = (co_list_hdr *)0x0; + ke_env.queue_sent.last = (co_list_hdr *)0x0; + ke_env.queue_timer.first = (co_list_hdr *)0x0; + ke_env.queue_timer.last = (co_list_hdr *)0x0; + ke_evt_clear(0xffffffff); + return; +} + + +/* +Unable to decompile 'ke_mem_init' +Cause: Exception while decompiling 230502e8: Decompiler process died + +*/ + +/* +Unable to decompile 'ke_malloc' +Cause: Exception while decompiling 2305030e: Decompiler process died + +*/ + +/* +Unable to decompile 'ke_free' +Cause: Exception while decompiling 230503a2: Decompiler process died + +*/ + + +void * ke_msg_alloc(ke_msg_id_t id,ke_task_id_t dest_id,ke_task_id_t src_id,uint16_t param_len) + +{ + undefined4 *puVar1; + undefined2 in_register_00002036; + + puVar1 = (undefined4 *)ke_malloc(CONCAT22(in_register_00002036,param_len) + 0xc); + if (puVar1 == (undefined4 *)0x0) { + assert_err("msg != NULL","module",0x50); + } + *(ke_msg_id_t *)(puVar1 + 1) = id; + *(ke_task_id_t *)((int)puVar1 + 6) = dest_id; + *(ke_task_id_t *)(puVar1 + 2) = src_id; + *(uint16_t *)((int)puVar1 + 10) = param_len; + *puVar1 = 0; + memset(puVar1 + 3,0,CONCAT22(in_register_00002036,param_len)); + return puVar1 + 3; +} + + + +void ke_msg_send(int param_1) + +{ + if (*(byte *)(param_1 + -6) < 0xf) { + if (*(byte *)(param_1 + -6) < 0xd) { + co_list_push_back(&ke_env.queue_sent,(co_list_hdr *)(param_1 + -0xc)); + ke_evt_set(0x1000000); + return; + } + } + else { + assert_err("id <= TASK_MAX","module",0xb6); + } + bl_rx_e2a_handler((void *)(param_1 + -8)); + ke_free((co_list_hdr *)(param_1 + -0xc)); + return; +} + + + +void ke_msg_send_basic(ke_msg_id_t id,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_msg_alloc(id,dest_id,src_id,0); + ke_msg_send(); + return; +} + + + +void ke_msg_forward_and_change_id + (void *param_ptr,ke_msg_id_t msg_id,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + *(ke_msg_id_t *)((int)param_ptr + -8) = msg_id; + *(ke_task_id_t *)((int)param_ptr + -6) = dest_id; + *(ke_task_id_t *)((int)param_ptr + -4) = src_id; + ke_msg_send(); + return; +} + + +/* +Unable to decompile 'ke_msg_free' +Cause: Exception while decompiling 2305056c: Decompiler process died + +*/ + + +_Bool cmp_dest_id(co_list_hdr *msg,u32_l dest_id) + +{ + return (_Bool)((uint)*(ushort *)((int)&msg[1].next + 2) == dest_id); +} + + + +_Bool ke_task_local(ke_task_id_t id) + +{ + undefined2 in_register_0000202a; + + if (0xe < CONCAT22(in_register_0000202a,id)) { + assert_err("id <= TASK_MAX","module",0xb6); + } + return (_Bool)(CONCAT22(in_register_0000202a,id) < 0xd); +} + + + +ke_msg_func_t * ke_handler_search(ke_msg_id_t msg_id,ke_state_handler *state_handler) + +{ + undefined2 in_register_0000202a; + int iVar1; + + iVar1 = (uint)state_handler->msg_cnt - 1; + if (iVar1 == -1) { + return (ke_msg_func_t *)0x0; + } + do { + if ((uint)state_handler->msg_table[iVar1].id == CONCAT22(in_register_0000202a,msg_id)) { + if (state_handler->msg_table[iVar1].func == (ke_msg_func_t *)0x0) { + assert_err("state_handler->msg_table[i].func","module",0xf4); + } + return state_handler->msg_table[iVar1].func; + } + iVar1 = iVar1 + -1; + } while (iVar1 != -1); + return (ke_msg_func_t *)0x0; +} + + +/* +Unable to decompile 'ke_state_set' +Cause: Exception while decompiling 2305060e: Decompiler process died + +*/ + + +ke_state_t ke_state_get(ke_task_id_t id) + +{ + uint uVar1; + _Bool _Var2; + undefined2 in_register_0000202a; + undefined3 extraout_var; + uint uVar3; + + uVar1 = (uint)id & 0xff; + uVar3 = CONCAT22(in_register_0000202a,id) >> 8; + if (0xd < uVar1) { + assert_err("type < TASK_MAX","module",0xd7); + } + _Var2 = ke_task_local((ke_task_id_t)uVar1); + if (CONCAT31(extraout_var,_Var2) == 0) { + assert_err("ke_task_local(type)","module",0xd8); + } + if (TASK_DESC[uVar1].idx_max <= uVar3) { + assert_err("idx < TASK_DESC[type].idx_max","module",0xd9); + } + return (ke_state_t)*(undefined2 *)(TASK_DESC[uVar1].state + uVar3 * 2); +} + + +/* +Unable to decompile 'ke_task_schedule' +Cause: Exception while decompiling 230507a6: Decompiler process died + +*/ + + +int ke_msg_discard(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + return 0; +} + + + +int ke_msg_save(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + return 2; +} + + +/* +Unable to decompile 'ke_timer_hw_set' +Cause: Exception while decompiling 23050914: Decompiler process died + +*/ + + +_Bool cmp_abs_time(co_list_hdr *timerA,co_list_hdr *timerB) + +{ + return (_Bool)((co_list_hdr *)0x11e1a300 < + (co_list_hdr *)((int)timerA[2].next - (int)timerB[2].next)); +} + + + +_Bool cmp_timer_id(co_list_hdr *timer,uint32_t timer_task) + +{ + if ((uint)*(ushort *)&timer[1].next == timer_task >> 0x10) { + return (_Bool)((uint)*(ushort *)((int)&timer[1].next + 2) == (timer_task & 0xffff)); + } + return false; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ke_timer_set(ke_msg_id_t timer_id,ke_task_id_t task_id,uint32_t delay) + +{ + bool bVar1; + co_list_hdr *pcVar2; + undefined2 in_register_0000202a; + char *condition; + co_list_hdr *element; + undefined2 in_register_0000202e; + int line; + + if (delay == 0) { + line = 0x8c; + condition = "delay > 0"; + } + else { + if (delay < 300000000) goto LAB_230509c2; + line = 0x8d; + condition = "delay < KE_TIMER_DELAY_MAX"; + } + assert_err(condition,"module",line); +LAB_230509c2: + bVar1 = false; + if ((ke_env.queue_timer.first != (co_list_hdr *)0x0) && + ((uint)*(ushort *)&ke_env.queue_timer.first[1].next == CONCAT22(in_register_0000202a,timer_id)) + ) { + bVar1 = (uint)*(ushort *)((int)&ke_env.queue_timer.first[1].next + 2) == + CONCAT22(in_register_0000202e,task_id); + } + element = ke_queue_extract(&ke_env.queue_timer,cmp_timer_id, + CONCAT22(in_register_0000202a,timer_id) << 0x10 | + CONCAT22(in_register_0000202e,task_id)); + if (element == (co_list_hdr *)0x0) { + element = (co_list_hdr *)ke_malloc(0xc); + if (element == (co_list_hdr *)0x0) { + assert_err("timer","module",0x9d); + } + *(ke_msg_id_t *)&element[1].next = timer_id; + *(ke_task_id_t *)((int)&element[1].next + 2) = task_id; + } + pcVar2 = (co_list_hdr *)(delay + _DAT_44b00120); + element[2].next = pcVar2; + co_list_insert(&ke_env.queue_timer,element,cmp_abs_time); + if ((bVar1) || (ke_env.queue_timer.first == element)) { + ke_timer_hw_set(ke_env.queue_timer.first); + } + if ((int)((int)pcVar2 - _DAT_44b00120) < 0) { + ke_evt_set(0x4000000); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ke_timer_clear(ke_msg_id_t timer_id,ke_task_id_t task_id) + +{ + co_list_hdr *pcVar1; + undefined2 in_register_0000202a; + co_list_hdr *mem_ptr; + undefined2 in_register_0000202e; + + mem_ptr = ke_env.queue_timer.first; + if (ke_env.queue_timer.first == (co_list_hdr *)0x0) { + return; + } + if (((uint)*(ushort *)&ke_env.queue_timer.first[1].next == CONCAT22(in_register_0000202a,timer_id) + ) && ((uint)*(ushort *)((int)&ke_env.queue_timer.first[1].next + 2) == + CONCAT22(in_register_0000202e,task_id))) { + co_list_pop_front(&ke_env.queue_timer); + pcVar1 = ke_env.queue_timer.first; + ke_timer_hw_set(ke_env.queue_timer.first); + if ((pcVar1 != (co_list_hdr *)0x0) && ((int)((int)pcVar1[2].next - _DAT_44b00120) < 0)) { + assert_err("!first || !ke_time_past(first->time)","module",0xd7); + } + } + else { + mem_ptr = ke_queue_extract(&ke_env.queue_timer,cmp_timer_id, + CONCAT22(in_register_0000202a,timer_id) << 0x10 | + CONCAT22(in_register_0000202e,task_id)); + if (mem_ptr == (co_list_hdr *)0x0) { + return; + } + } + ke_free(mem_ptr); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ke_timer_schedule(int dummy) + +{ + co_list_hdr *mem_ptr; + + while( true ) { + ke_evt_clear(0x4000000); + mem_ptr = ke_env.queue_timer.first; + if (ke_env.queue_timer.first == (co_list_hdr *)0x0) { + ke_timer_hw_set(0); + return; + } + if ((-1 < (int)ke_env.queue_timer.first[2].next + (-0x32 - _DAT_44b00120)) && + (ke_timer_hw_set(ke_env.queue_timer.first), -1 < (int)((int)mem_ptr[2].next - _DAT_44b00120)) + ) break; + mem_ptr = co_list_pop_front(&ke_env.queue_timer); + ke_msg_send_basic(*(ke_msg_id_t *)&mem_ptr[1].next,*(ke_task_id_t *)((int)&mem_ptr[1].next + 2), + 0xff); + ke_free(mem_ptr); + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void bl60x_current_time_us(longlong *time_now) + +{ + undefined4 uVar1; + + uVar1 = _DAT_44b080a8; + *(undefined4 *)time_now = _DAT_44b080a4; + *(undefined4 *)((int)time_now + 4) = uVar1; + return; +} + + + +byte * mac_ie_find(byte *param_1,int param_2,uint param_3) + +{ + byte *pbVar1; + + pbVar1 = param_1 + param_2; + while( true ) { + if (pbVar1 <= param_1) { + return (byte *)0; + } + if ((uint)*param_1 == param_3) break; + param_1 = param_1 + (uint)param_1[1] + 2; + } + return param_1; +} + + + +char * mac_vsie_find(char *param_1,int param_2,int param_3,int param_4) + +{ + int iVar1; + char *pcVar2; + int iVar3; + + pcVar2 = param_1 + param_2; + while (param_1 < pcVar2) { + if (*param_1 == -0x23) { + iVar3 = 0; + do { + if (param_4 == iVar3) { + return param_1; + } + iVar1 = iVar3 + 2; + iVar3 = iVar3 + 1; + } while (*(char *)(param_3 + iVar3 + -1) == param_1[iVar1]); + } + param_1 = param_1 + (uint)(byte)param_1[1] + 2; + } + if (param_1 != pcVar2) { + puts("--->>> addr != end\r\n"); + return (char *)0; + } + return (char *)0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BufferDesc_t * +GetTxEAPOLBuffer(cm_ConnectionInfo_t *connPtr,EAPOL_KeyMsg_Tx_t **ppTxEapol,BufferDesc_t *pBufDesc) + +{ + char "GetTxEAPOLBuffer" [17]; + void *pvVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"GetTxEAPOLBuffer"); + if (pBufDesc == (BufferDesc_t *)0x0) { + pBufDesc = (BufferDesc_t *)ke_malloc(0xc); + if (pBufDesc != (BufferDesc_t *)0x0) { + memset(pBufDesc,0,0xc); + pvVar1 = ke_malloc(0x200); + pBufDesc->Buffer = pvVar1; + if (pvVar1 != (void *)0x0) goto LAB_23050cd6; + } + pBufDesc = (BufferDesc_t *)0x0; + } + else { +LAB_23050cd6: + *(cm_ConnectionInfo_t **)&pBufDesc->intf = connPtr; + *ppTxEapol = (EAPOL_KeyMsg_Tx_t *)pBufDesc->Buffer; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c408); + } + return pBufDesc; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void UpdateEAPOLWcbLenAndTransmit(BufferDesc_t *pBufDesc,UINT16 frameLen) + +{ + char "UpdateEAPOLWcbLenAndTransmit" [29]; + undefined2 in_register_0000202e; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"UpdateEAPOLWcbLenAndTransmit"); + txl_frame_send_eapol_frame + (*(uint8_t *)(pBufDesc->intf + 1),(cfm_func_ptr *)0x0,(void *)0x0, + (uint8_t *)((int)pBufDesc->Buffer + 0xe),CONCAT22(in_register_0000202e,frameLen) + 4); + ke_free(pBufDesc->Buffer); + ke_free(pBufDesc); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c430); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN keyMgmtProcessMsgExt(keyMgmtInfoSta_t *pKeyMgmtInfoSta,EAPOL_KeyMsg_t *pKeyMsg) + +{ + char "keyMgmtProcessMsgExt" [21]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtProcessMsgExt"); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c450); + return 1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmtInitSta(cm_ConnectionInfo_t *connPtr) + +{ + char "KeyMgmtInitSta" [15]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtInitSta"); + KeyMgmtSta_InitSession(&connPtr->suppData->keyMgmtInfoSta); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c468); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void keyMgmtSta_StartSession(cm_ConnectionInfo_t *connPtr,CHAR *pBssid,UINT8 *pStaAddr) + +{ + char "keyMgmtSta_StartSession" [24]; + supplicantData *psVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtSta_StartSession"); + psVar1 = connPtr->suppData; + *(cm_ConnectionInfo_t **)&(psVar1->keyMgmtInfoSta).connPtr = connPtr; + memcpy(connPtr->suppData->localStaAddr,pStaAddr,6); + memcpy(connPtr->suppData->localBssid,pBssid,6); + keyMgmtSta_StartSession_internal(&psVar1->keyMgmtInfoSta,10000000); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c514); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void init_customApp_mibs(supplicantData_t *suppData) + +{ + char "init_customApp_mibs" [20]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"init_customApp_mibs"); + memset(&suppData->customMIB_RSNStats,0,3); + memset(&suppData->customMIB_RSNConfig,0,0x1c); + *(ushort *)&(suppData->customMIB_RSNConfig).wpaType = + (ushort)(suppData->customMIB_RSNConfig).wpaType | 1; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c544); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT8 supplicantIsEnabled(void *connectionPtr) + +{ + byte bVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantIsEnabled"); + bVar1 = 0; + if (*(int *)((int)connectionPtr + 8) != 0) { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"supplicantIsEnabled"); + bVar1 = (byte)((uint)*(undefined4 *)(*(int *)((int)connectionPtr + 8) + 0x34) >> 8) & 1; + } + return (UINT8)bVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantInitSession + (cm_ConnectionInfo_t *connPtr,CHAR *pSsid,UINT16 len,CHAR *pBssid,UINT8 *pStaAddr) + +{ + char "supplicantInitSession" [22]; + UINT8 UVar1; + undefined3 extraout_var; + undefined2 in_register_00002032; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantInitSession"); + UVar1 = supplicantIsEnabled(connPtr); + if (CONCAT31(extraout_var,UVar1) != 0) { + KeyMgmtInitSta(connPtr); + memcpy((connPtr->suppData->hashSsId).SsId,pSsid,CONCAT22(in_register_00002032,len)); + (connPtr->suppData->hashSsId).Len = (IEEEtypes_Len_t)len; + keyMgmtSta_StartSession(connPtr,pBssid,pStaAddr); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c52c); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantDisable(cm_ConnectionInfo_t *connPtr) + +{ + char "supplicantDisable" [18]; + UINT8 UVar1; + undefined3 extraout_var; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantDisable"); + UVar1 = supplicantIsEnabled(connPtr); + if (CONCAT31(extraout_var,UVar1) != 0) { + mm_timer_clear(&(connPtr->suppData->keyMgmtInfoSta).rsnTimer); + *(byte *)&connPtr->suppData->customMIB_RSNConfig = + *(byte *)&connPtr->suppData->customMIB_RSNConfig & 0xfe; + init_customApp_mibs((supplicantData_t *)connPtr->suppData); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c56c); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantEnable(void *connectionPtr,int security_mode,void *mcstCipher,void *ucstCipher, + _Bool is_pmf_required) + +{ + char "supplicantEnable" [17]; + int iVar1; + UINT8 *__src; + undefined3 in_register_00002039; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantEnable"); + *(byte *)(*(int *)((int)connectionPtr + 8) + 0x35) = + *(byte *)(*(int *)((int)connectionPtr + 8) + 0x35) | 1; + if (security_mode - 4U < 3) { + *(ushort *)(*(int *)((int)connectionPtr + 8) + 0x36) = + *(ushort *)(*(int *)((int)connectionPtr + 8) + 0x36) | 0x20; + *(byte *)(*(int *)((int)connectionPtr + 8) + 0x35) = + *(byte *)(*(int *)((int)connectionPtr + 8) + 0x35) | 4; + *(ushort *)(*(int *)((int)connectionPtr + 8) + 0x4e) = + *(ushort *)(*(int *)((int)connectionPtr + 8) + 0x4e) | 1; + memcpy((void *)(*(int *)((int)connectionPtr + 8) + 0x38),mcstCipher,1); + memcpy((void *)(*(int *)((int)connectionPtr + 8) + 0x39),ucstCipher,1); + if (CONCAT31(in_register_00002039,is_pmf_required) == 0) { + *(undefined *)(*(int *)((int)connectionPtr + 8) + 0x3d) = 2; + } + else { + *(undefined *)(*(int *)((int)connectionPtr + 8) + 0x3d) = 6; + } + iVar1 = *(int *)((int)connectionPtr + 8); + __src = ""; + } + else { + if (security_mode != 3) goto LAB_2305118e; + *(ushort *)(*(int *)((int)connectionPtr + 8) + 0x36) = + *(ushort *)(*(int *)((int)connectionPtr + 8) + 0x36) | 8; + memcpy((void *)(*(int *)((int)connectionPtr + 8) + 0x38),mcstCipher,1); + memcpy((void *)(*(int *)((int)connectionPtr + 8) + 0x39),ucstCipher,1); + *(undefined *)(*(int *)((int)connectionPtr + 8) + 0x3d) = 2; + iVar1 = *(int *)((int)connectionPtr + 8); + __src = ""; + } + memcpy((void *)(iVar1 + 0x3a),__src,3); +LAB_2305118e: + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c580); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT16 keyMgmtFormatWpaRsnIe + (cm_ConnectionInfo_t *connPtr,UINT8 *pos,IEEEtypes_MacAddr_t *pBssid, + IEEEtypes_MacAddr_t *pStaAddr,UINT8 *pPmkid,BOOLEAN addPmkid) + +{ + char "keyMgmtFormatWpaRsnIe" [22]; + uint16_t uVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtFormatWpaRsnIe"); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c594); + uVar1 = mm_get_rsn_wpa_ie(connPtr->staId,pos); + return (UINT16)uVar1; +} + + + +// WARNING: Variable defined which should be unmapped: pTxEapol +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +Status_e GeneratePWKMsg2(BufferDesc_t *pEAPoLBufDesc,UINT8 *pSNonce,UINT8 *pEAPOLMICKey, + UINT8 forceKeyDescVersion) + +{ + EAPOL_KeyMsg_Tx_t *pEVar1; + char "GeneratePWKMsg2" [16]; + cm_ConnectionInfo_t *connPtr; + Status_e SVar2; + UINT16 frameLen; + BufferDesc_t *pBufDesc; + EAPOL_KeyMsg_t *pRxEapol; + EAPOL_KeyMsg_Tx_t *pEStack36; + EAPOL_KeyMsg_Tx_t *pTxEapol; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"GeneratePWKMsg2"); + connPtr = (cm_ConnectionInfo_t *)pEAPoLBufDesc->intf; + pRxEapol = (EAPOL_KeyMsg_t *)pEAPoLBufDesc->Buffer; + pBufDesc = GetTxEAPOLBuffer(connPtr,&pEStack36,(BufferDesc_t *)0x0); + if (pBufDesc == (BufferDesc_t *)0x0) { + SVar2 = FAIL; + } + else { + KeyMgmtSta_PrepareEAPOLFrame + (pEStack36,pRxEapol,(IEEEtypes_MacAddr_t *)connPtr->suppData->localBssid, + (IEEEtypes_MacAddr_t *)connPtr->suppData->localStaAddr,pSNonce); + pEVar1 = pEStack36; + if ((pEStack36->keyMsg).desc_type != '\x01') { + frameLen = keyMgmtFormatWpaRsnIe + (connPtr,(pEStack36->keyMsg).key_data, + (IEEEtypes_MacAddr_t *)connPtr->suppData->localBssid, + (IEEEtypes_MacAddr_t *)connPtr->suppData->localStaAddr,(UINT8 *)0x0,0); + *(char *)&(pEVar1->keyMsg).key_material_len = (char)frameLen; + *(undefined *)((int)&(pEVar1->keyMsg).key_material_len + 1) = (char)(frameLen >> 8); + } + frameLen = KeyMgmtSta_PopulateEAPOLLengthMic(pEStack36,pEAPOLMICKey,'\x01',forceKeyDescVersion); + UpdateEAPOLWcbLenAndTransmit(pBufDesc,frameLen); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c478); + SVar2 = FW_SUCCESS; + } + return SVar2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN KeyMgmtStaHsk_Recvd_PWKMsg1 + (BufferDesc_t *pEAPoLBufDesc,IEEEtypes_MacAddr_t *sa,IEEEtypes_MacAddr_t *da) + +{ + char "KeyMgmtStaHsk_Recvd_PWKMsg1" [28]; + int iVar1; + int iVar2; + Status_e SVar3; + EAPOL_KeyMsg_t *pEVar4; + BOOLEAN BVar5; + UINT8 *pPMK; + undefined3 extraout_var; + int iVar6; + keyMgmtInfoSta_t *pKeyMgmtInfoSta; + BOOLEAN in_fa0; + + iVar6 = pEAPoLBufDesc->intf; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtStaHsk_Recvd_PWKMsg1"); + iVar1 = *(int *)(iVar6 + 8); + pKeyMgmtInfoSta = (keyMgmtInfoSta_t *)(iVar1 + 0x54); + pEVar4 = GetKeyMsgNonceFromEAPOL(pEAPoLBufDesc,pKeyMgmtInfoSta); + if (pEVar4 == (EAPOL_KeyMsg_t *)0x0) { +LAB_230513aa: + iVar2 = 0; + } + else { + iVar2 = supplicantAkmIsWpaWpa2((AkmSuite_t *)(*(int *)(iVar6 + 8) + 0x3a)); + if (iVar2 != 0) { + BVar5 = supplicantAkmIsWpaWpa2Psk((AkmSuite_t *)(*(int *)(iVar6 + 8) + 0x3a)); + if ((BVar5 == 0) || + (pPMK = pmkCacheFindPSK((UINT8 *)(*(int *)(iVar6 + 8) + 6), + *(UINT8 *)(*(int *)(iVar6 + 8) + 5)), pPMK == (UINT8 *)0x0)) + goto LAB_230513aa; + supplicantAkmUsesKdf((AkmSuite_t *)(*(int *)(iVar6 + 8) + 0x3a)); + KeyMgmtSta_DeriveKeys + (pPMK,da,sa,(UINT8 *)pKeyMgmtInfoSta,(UINT8 *)(iVar1 + 0x74),(UINT8 *)(iVar1 + 0x94) + ,(UINT8 *)(iVar1 + 0xa4),(KeyData_t *)(iVar1 + 0x128),in_fa0); + iVar2 = 1; + } + SVar3 = GeneratePWKMsg2(pEAPoLBufDesc,(UINT8 *)(iVar1 + 0x74),(UINT8 *)(iVar1 + 0x94),'\0'); + if (CONCAT31(extraout_var,SVar3) == 0) { + if (iVar2 == 1) { + updateApReplayCounter(pKeyMgmtInfoSta,(UINT8 *)pEVar4->replay_cnt); + *(undefined4 *)(iVar1 + 0xcc) = 0; + } + } + else { + iVar2 = 0; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c4a8); + } + return iVar2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantInit(supplicantData_t *suppData) + +{ + char "supplicantInit" [15]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantInit"); + init_customApp_mibs(suppData); + memset(&suppData->currParams,0xff,4); + memset(&suppData->keyMgmtInfoSta,0,0x144); + (suppData->keyMgmtInfoSta).sta_MIC_Error.disableStaAsso = 0; + (suppData->keyMgmtInfoSta).sta_MIC_Error.MICCounterMeasureEnabled = 1; + (suppData->keyMgmtInfoSta).sta_MIC_Error.status = NO_MIC_FAILURE; + KeyMgmtResetCounter(&suppData->keyMgmtInfoSta); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c5ac); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void allocSupplicantData(void *connectionPtr) + +{ + char "allocSupplicantData" [20]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"allocSupplicantData"); + if (*(int *)((int)connectionPtr + 8) == 0) { + if ((*(char *)connectionPtr == '\0') && (keyMgmt_SuppData[0].inUse == 0)) { + keyMgmt_SuppData[0].inUse = 1; + supplicantInit(keyMgmt_SuppData); + *(undefined4 *)((int)connectionPtr + 8) = 0x420161e4; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c41c); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT16 keyMgmtGetKeySize(cm_ConnectionInfo_t *connPtr,UINT8 isPairwise) + +{ + char "keyMgmtGetKeySize" [18]; + UINT16 UVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtGetKeySize"); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c5bc); + UVar1 = keyMgmtGetKeySize_internal(&connPtr->suppData->customMIB_RSNConfig,isPairwise); + return UVar1; +} + + + +// WARNING: Variable defined which should be unmapped: key_add_req +// WARNING: Could not reconcile some variable overlaps + +uint8_t add_key_to_mac(cm_ConnectionInfo_t *connPtr,UINT8 pairwise) + +{ + uint32_t uVar1; + uint32_t uVar2; + size_t __n; + uint8_t uVar3; + UINT16 UVar4; + apInfo_t *paVar5; + undefined3 in_register_0000202d; + int iVar6; + KeyData_t *__src; + byte bStack60; + byte bStack59; + mm_key_add_req key_add_req; + + iVar6 = CONCAT31(in_register_0000202d,pairwise); + __n = 0x10; + if (connPtr->conType == '\0') { + UVar4 = keyMgmtGetKeySize(connPtr,pairwise); + __n = (uint)UVar4 & 0xff; + } + memset(&bStack60,0,0x2c); + key_add_req.key.array[7]._3_1_ = iVar6 != 0; + key_add_req.key.array[7]._1_1_ = connPtr->instNbr; + if (iVar6 == 0) { + bStack59 = 0xff; + if (connPtr->conType == '\0') { + __src = &(connPtr->suppData->keyMgmtInfoSta).GRKey; + bStack60 = (byte)(connPtr->suppData->keyMgmtInfoSta).GRKey.KeyIndex; + } + else { + paVar5 = cm_GetApInfo(connPtr); + __src = &(paVar5->bssData).grpKeyData; + bStack60 = (byte)(paVar5->bssData).grpKeyData.KeyIndex; + } + } + else { + bStack59 = connPtr->staId; + if (connPtr->conType == '\0') { + __src = &(connPtr->suppData->keyMgmtInfoSta).PWKey; + } + else { + __src = (KeyData_t *)((connPtr->TxRxCipherKeyBuf).cipher_key.ckd + 0x20); + } + } + memcpy(&key_add_req.key,__src,__n); + uVar2 = key_add_req.key.array[6]; + uVar1 = key_add_req.key.array[3]; + key_add_req.key_idx = (uint8_t)__n; + if (__n == 0x10) { + key_add_req.key.array[7]._0_1_ = 2; + } + else { + if (__n == 0x20) { + key_add_req.key.array[7]._0_1_ = 1; + if (iVar6 != 0) { + key_add_req.key.array[3] = key_add_req.key.array[5]; + key_add_req.key.array[5] = uVar1; + key_add_req.key.array[6] = key_add_req.key.array[4]; + key_add_req.key.array[4] = uVar2; + } + } + else { + if (__n == 0xd) { + key_add_req.key.array[7]._0_1_ = 3; + } + else { + if (__n == 5) { + key_add_req.key.array[7]._0_1_ = 0; + } + else { + assert_err("0","module",0x783); + } + } + } + } + printf("set key:sta_idx:%d, inst_nbr:%d, key_idx:%d,cipher_suite:%d,key_len:%d\r\n",(uint)bStack59 + ,(uint)key_add_req.key.array[7]._1_1_,(uint)bStack60,(uint)(byte)key_add_req.key.array[7], + (uint)key_add_req.key_idx); + uVar3 = mm_sec_machwkey_wr((mm_key_add_req *)&bStack60); + return uVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BufferReturnNotify_t * keyMgmtKeyGroupTxDone(void) + +{ + cm_ConnectionInfo_t *connPtr; + uint8_t uVar1; + cm_ConnectionInfo_t **in_a0; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtKeyGroupTxDone"); + connPtr = *in_a0; + if (connPtr->gtkHwKeyId != -1) { + mm_sec_machwkey_del(connPtr->gtkHwKeyId); + } + uVar1 = add_key_to_mac(connPtr,'\0'); + connPtr->gtkHwKeyId = uVar1; + (connPtr->suppData->keyMgmtInfoSta).RSNDataTrafficEnabled = 1; + if ((connPtr->suppData->keyMgmtInfoSta).RSNSecured == 0) { + (connPtr->suppData->keyMgmtInfoSta).RSNSecured = 1; + sm_handle_supplicant_result(connPtr->staId,0); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"keyMgmtKeyGroupTxDone"); + return (BufferReturnNotify_t *)0x0; +} + + + +// WARNING: Variable defined which should be unmapped: pTxEapol +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +Status_e GenerateGrpMsg2(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta) + +{ + char "GenerateGrpMsg2" [16]; + UINT16 frameLen_00; + BufferDesc_t *pBufDesc; + supplicantData *psVar1; + cm_ConnectionInfo_t *connPtr; + EAPOL_KeyMsg_t *pRxEapol; + UINT16 frameLen; + EAPOL_KeyMsg_Tx_t *pEStack36; + EAPOL_KeyMsg_Tx_t *pTxEapol; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"GenerateGrpMsg2"); + connPtr = (cm_ConnectionInfo_t *)pEAPoLBufDesc->intf; + pRxEapol = (EAPOL_KeyMsg_t *)pEAPoLBufDesc->Buffer; + pBufDesc = GetTxEAPOLBuffer(connPtr,&pEStack36,(BufferDesc_t *)0x0); + if (pBufDesc != (BufferDesc_t *)0x0) { + psVar1 = connPtr->suppData; + KeyMgmtSta_PrepareEAPOLFrame + (pEStack36,pRxEapol,(IEEEtypes_MacAddr_t *)psVar1->localBssid, + (IEEEtypes_MacAddr_t *)psVar1->localStaAddr,(UINT8 *)0x0); + frameLen_00 = KeyMgmtSta_PopulateEAPOLLengthMic + (pEStack36,pKeyMgmtInfoSta->EAPOL_MIC_Key,'\x01','\0'); + keyMgmtKeyGroupTxDone(); + UpdateEAPOLWcbLenAndTransmit(pBufDesc,frameLen_00); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c498); + } + return (Status_e)(pBufDesc == (BufferDesc_t *)0x0); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +EAPOL_KeyMsg_t * KeyMgmtStaHsk_Recvd_GrpMsg1(BufferDesc_t *pEAPoLBufDesc) + +{ + char "KeyMgmtStaHsk_Recvd_GrpMsg1" [28]; + keyMgmtInfoSta_t *pKeyMgmtInfoSta; + Status_e SVar1; + EAPOL_KeyMsg_t *pEVar2; + undefined3 extraout_var; + + pKeyMgmtInfoSta = (keyMgmtInfoSta_t *)(*(int *)(pEAPoLBufDesc->intf + 8) + 0x54); + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtStaHsk_Recvd_GrpMsg1"); + pEVar2 = ProcessRxEAPOL_GrpMsg1(pEAPoLBufDesc,pKeyMgmtInfoSta); + if ((pEVar2 == (EAPOL_KeyMsg_t *)0x0) || + (SVar1 = GenerateGrpMsg2(pEAPoLBufDesc,pKeyMgmtInfoSta), CONCAT31(extraout_var,SVar1) != 0)) { + pEVar2 = (EAPOL_KeyMsg_t *)0x0; + } + else { + updateApReplayCounter(pKeyMgmtInfoSta,(UINT8 *)pEVar2->replay_cnt); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c4e0); + } + return pEVar2; +} + + + +// WARNING: Variable defined which should be unmapped: key_add_req +// WARNING: Could not reconcile some variable overlaps + +uint8_t add_mfp_key_to_mac(cm_ConnectionInfo_t *connPtr,UINT8 pairwise) + +{ + uint8_t uVar1; + UINT16 UVar2; + undefined3 extraout_var; + undefined3 in_register_0000202d; + KeyData_t *__src; + undefined2 uStack60; + mm_key_add_req key_add_req; + + UVar2 = keyMgmtGetKeySize(connPtr,pairwise); + memset(&uStack60,0,0x2c); + key_add_req.key.array[7]._1_1_ = connPtr->instNbr; + key_add_req.key_idx = (uint8_t)((uint)UVar2 & 0xff); + key_add_req.key.array[7]._0_1_ = 5; + uStack60 = 0xff04; + if (CONCAT31(in_register_0000202d,pairwise) == 0) { + if (connPtr->conType != '\0') goto LAB_23051956; + __src = &(connPtr->suppData->keyMgmtInfoSta).GRKey; + } + else { + if (connPtr->conType != '\0') goto LAB_23051956; + __src = &(connPtr->suppData->keyMgmtInfoSta).PWKey; + } + memcpy(&key_add_req.key,__src,(uint)UVar2 & 0xff); +LAB_23051956: + printf("set mfp key:sta_idx:%d, inst_nbr:%d, key_idx:%d,cipher_suite:%d,key_len:%d\r\n", + (uint)uStack60._1_1_,(uint)key_add_req.key.array[7]._1_1_,(uint)(byte)uStack60, + (uint)(byte)key_add_req.key.array[7],(uint)key_add_req.key_idx); + uVar1 = mm_sec_machwkey_wr((mm_key_add_req *)&uStack60); + printf("mfp hw id: %d\n",CONCAT31(extraout_var,uVar1)); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void keyMgmtPlumbPairwiseKey(cm_ConnectionInfo_t *connPtr) + +{ + char "keyMgmtPlumbPairwiseKey" [24]; + uint8_t uVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtPlumbPairwiseKey"); + memcpy(&(connPtr->suppData->keyMgmtInfoSta).PWKey,&(connPtr->suppData->keyMgmtInfoSta).newPWKey, + 0x28); + uVar1 = add_key_to_mac(connPtr,'\x01'); + connPtr->ptkHwKeyId = uVar1; + if ((connPtr->suppData->customMIB_RSNConfig).AKM.akmType == AKM_SHA256_PSK) { + uVar1 = add_mfp_key_to_mac(connPtr,'\x01'); + connPtr->mfpHwKeyId = uVar1; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c5d0); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BufferReturnNotify_t * keyMgmtKeyPairwiseTxDone(void) + +{ + cm_ConnectionInfo_t **in_a0; + cm_ConnectionInfo_t *connPtr; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtKeyPairwiseTxDone"); + connPtr = *in_a0; + keyMgmtPlumbPairwiseKey(connPtr); + (connPtr->suppData->keyMgmtInfoSta).pwkHandshakeComplete = 1; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"keyMgmtKeyPairwiseTxDone"); + return (BufferReturnNotify_t *)0x0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +Status_e GeneratePWKMsg4(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta, + BOOLEAN groupKeyReceived) + +{ + char "GeneratePWKMsg4" [16]; + Status_e SVar1; + UINT16 frameLen; + BufferDesc_t *pBufDesc; + supplicantData *psVar2; + cm_ConnectionInfo_t *connPtr; + EAPOL_KeyMsg_t *pRxEapol; + EAPOL_KeyMsg_Tx_t *pEStack52; + EAPOL_KeyMsg_Tx_t *pTxEapol; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"GeneratePWKMsg4"); + connPtr = (cm_ConnectionInfo_t *)pEAPoLBufDesc->intf; + pRxEapol = (EAPOL_KeyMsg_t *)pEAPoLBufDesc->Buffer; + pBufDesc = GetTxEAPOLBuffer(connPtr,&pEStack52,(BufferDesc_t *)0x0); + if (pBufDesc == (BufferDesc_t *)0x0) { + SVar1 = FAIL; + } + else { + psVar2 = connPtr->suppData; + KeyMgmtSta_PrepareEAPOLFrame + (pEStack52,pRxEapol,(IEEEtypes_MacAddr_t *)psVar2->localBssid, + (IEEEtypes_MacAddr_t *)psVar2->localStaAddr,(UINT8 *)0x0); + frameLen = KeyMgmtSta_PopulateEAPOLLengthMic + (pEStack52,pKeyMgmtInfoSta->EAPOL_MIC_Key,'\x01','\0'); + UpdateEAPOLWcbLenAndTransmit(pBufDesc,frameLen); + if (groupKeyReceived == 0) { + keyMgmtKeyPairwiseTxDone(); + } + else { + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtKeyPairAndGroupTxDone"); + keyMgmtKeyPairwiseTxDone(); + keyMgmtKeyGroupTxDone(); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"keyMgmtKeyPairAndGroupTxDone"); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c488); + SVar1 = FW_SUCCESS; + } + return SVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +EAPOL_KeyMsg_t * KeyMgmtStaHsk_Recvd_PWKMsg3(BufferDesc_t *pEAPoLBufDesc) + +{ + char "KeyMgmtStaHsk_Recvd_PWKMsg3" [28]; + int iVar1; + keyMgmtInfoSta_t *pKeyMgmtInfoSta; + Status_e SVar2; + EAPOL_KeyMsg_t *pEVar3; + undefined3 extraout_var; + + iVar1 = pEAPoLBufDesc->intf; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtStaHsk_Recvd_PWKMsg3"); + pKeyMgmtInfoSta = (keyMgmtInfoSta_t *)(*(int *)(iVar1 + 8) + 0x54); + pEVar3 = ProcessRxEAPOL_PwkMsg3(pEAPoLBufDesc,pKeyMgmtInfoSta); + if ((pEVar3 != (EAPOL_KeyMsg_t *)0x0) && + (SVar2 = GeneratePWKMsg4(pEAPoLBufDesc,pKeyMgmtInfoSta,(uint)(pEVar3->desc_type == '\x02')), + CONCAT31(extraout_var,SVar2) == 0)) { + updateApReplayCounter(pKeyMgmtInfoSta,(UINT8 *)pEVar3->replay_cnt); + pEVar3 = (EAPOL_KeyMsg_t *)0x0; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c4c4); + } + return pEVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ProcessKeyMgmtDataSta(BufferDesc_t *pBufDesc,IEEEtypes_MacAddr_t *sa,IEEEtypes_MacAddr_t *da) + +{ + char "ProcessKeyMgmtDataSta" [22]; + void *pvVar1; + + pvVar1 = pBufDesc->Buffer; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"ProcessKeyMgmtDataSta"); + if ((*(byte *)((int)pvVar1 + 6) & 8) == 0) { + KeyMgmtStaHsk_Recvd_GrpMsg1(pBufDesc); + } + else { + if ((*(byte *)((int)pvVar1 + 5) & 1) == 0) { + KeyMgmtStaHsk_Recvd_PWKMsg1(pBufDesc,sa,da); + } + else { + KeyMgmtStaHsk_Recvd_PWKMsg3(pBufDesc); + } + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c4fc); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT8 ProcessEAPoLPkt(BufferDesc_t *bufDesc,IEEEtypes_MacAddr_t *sa,IEEEtypes_MacAddr_t *da) + +{ + char "ProcessEAPoLPkt" [16]; + UINT8 UVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"ProcessEAPoLPkt"); + if (*(char *)((int)bufDesc->Buffer + 1) == '\x03') { + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"ProcessEAPoLKeyPkt"); + if (*(char *)bufDesc->intf == '\x02') { + ProcessKeyMgmtDataAp(bufDesc); + } + else { + ProcessKeyMgmtDataSta(bufDesc,sa,da); + } + UVar1 = '\x01'; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"ProcessEAPoLKeyPkt"); + } + else { + UVar1 = '\0'; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c3f8); + return UVar1; +} + + + +uchar process_rsn_ie(uint8_t *rsn_ie,Cipher_t_conflict *mcstCipher,Cipher_t_conflict *ucstCipher, + _Bool *is_pmf_required,SecurityMode_t *security_mode,_Bool wpa2_prefered) + +{ + int iVar1; + UINT8 *__s2; + Cipher_t_conflict CVar2; + undefined3 in_register_0000203d; + uint uVar3; + uint8_t *__s1; + uint8_t *__dest; + ushort auStack66 [2]; + uint16_t akmp_count; + + __s1 = rsn_ie + 0xe; + __dest = rsn_ie + 10; + if (*(short *)(rsn_ie + 8) == 2) { + rsn_ie[9] = '\0'; + rsn_ie[1] = rsn_ie[1] + -4; + rsn_ie[8] = '\x01'; + iVar1 = memcmp(__s1,"",4); + if (iVar1 == 0) { + memcpy(__dest,__s1,4); + } + memcpy(__s1,rsn_ie + 0x12,0xc); + } + memcpy(auStack66,__s1,2); + uVar3 = 0; + while (uVar3 < auStack66[0]) { + iVar1 = memcmp(__dest + (uVar3 + 1) * 4 + 2,"",4); + if (iVar1 == 0) { + *(byte *)security_mode = *(byte *)security_mode | 0x20; + } + else { + iVar1 = memcmp(__dest + (uVar3 + 1) * 4 + 2,"",4); + if (iVar1 == 0) { + *(byte *)&security_mode->field_0x1 = *(byte *)&security_mode->field_0x1 | 1; + } + } + uVar3 = uVar3 + 1 & 0xff; + } + if (auStack66[0] == 2) { + rsn_ie[1] = '\x14'; + auStack66[0] = 1; + memcpy(__s1,auStack66,2); + __s1 = rsn_ie + 0x14; + if (CONCAT31(in_register_0000203d,wpa2_prefered) == 0) { + __s2 = ""; + } + else { + __s2 = ""; + } + iVar1 = memcmp(__s1,__s2,4); + if (iVar1 == 0) { + memcpy(rsn_ie + 0x10,__s1,6); + } + memcpy(__s1,rsn_ie + 0x18,2); + } + if (((*(byte *)&security_mode->field_0x1 & 1) != 0) && + (((*(byte *)security_mode & 0x20) == 0 || (CONCAT31(in_register_0000203d,wpa2_prefered) == 0))) + ) { + *is_pmf_required = true; + rsn_ie[0x14] = -0x40; + rsn_ie[0x16] = '\0'; + rsn_ie[1] = rsn_ie[1] + '\x02'; + rsn_ie[0x17] = '\0'; + memcpy(rsn_ie + 0x18,"",4); + rsn_ie[1] = rsn_ie[1] + '\x04'; + } + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t_conflict)((byte)*ucstCipher | 8); +LAB_23051f04: + *ucstCipher = CVar2; + } + else { + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t_conflict)((byte)*ucstCipher | 4); + goto LAB_23051f04; + } + } + __s1 = rsn_ie + 4; + iVar1 = memcmp(__s1,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t_conflict)((byte)*mcstCipher | 8); + } + else { + iVar1 = memcmp(__s1,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t_conflict)((byte)*mcstCipher | 4); + } + else { + iVar1 = memcmp(__s1,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t_conflict)((byte)*mcstCipher | 2); + } + else { + iVar1 = memcmp(__s1,"",4); + if (iVar1 != 0) goto LAB_23051f26; + CVar2 = (Cipher_t_conflict)((byte)*mcstCipher | 1); + } + } + } + *mcstCipher = CVar2; +LAB_23051f26: + return (uchar)(rsn_ie[1] + '\x02'); +} + + + +uchar process_wpa_ie(uint8_t *wpa_ie,Cipher_t_conflict *mcstCipher,Cipher_t_conflict *ucstCipher) + +{ + int iVar1; + Cipher_t_conflict CVar2; + uint8_t *__dest; + uint8_t *__s1; + + __dest = wpa_ie + 0xe; + if (*(short *)(wpa_ie + 0xc) == 2) { + wpa_ie[1] = '\x16'; + __s1 = wpa_ie + 0x12; + wpa_ie[0xc] = '\x01'; + wpa_ie[0xd] = '\0'; + iVar1 = memcmp(__s1,"",4); + if (iVar1 == 0) { + memcpy(__dest,__s1,4); + } + memcpy(__s1,wpa_ie + 0x16,8); + } + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t_conflict)((byte)*ucstCipher | 8); +LAB_2305208e: + *ucstCipher = CVar2; + } + else { + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t_conflict)((byte)*ucstCipher | 4); + goto LAB_2305208e; + } + } + __dest = wpa_ie + 8; + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t_conflict)((byte)*mcstCipher | 8); + } + else { + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t_conflict)((byte)*mcstCipher | 4); + } + else { + iVar1 = memcmp(__dest,"",4); + if (iVar1 == 0) { + CVar2 = (Cipher_t_conflict)((byte)*mcstCipher | 2); + } + else { + iVar1 = memcmp(__dest,"",4); + if (iVar1 != 0) goto LAB_230520b0; + CVar2 = (Cipher_t_conflict)((byte)*mcstCipher | 1); + } + } + } + *mcstCipher = CVar2; +LAB_230520b0: + return (uchar)(wpa_ie[1] + '\x02'); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void keyMgmtStaRsnSecuredTimeoutHandler(void *env) + +{ + char "keyMgmtStaRsnSecuredTimeoutHandler" [35]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtStaRsnSecuredTimeoutHandler"); + if ((env != (void *)0x0) && (*(int *)((int)env + 0x78) == 0)) { + sm_handle_supplicant_result(*(uint8_t *)(*(int *)((int)env + 0x118) + 1),0xf); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c950); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantGenerateRand(UINT8 *dataOut,UINT32 length) + +{ + char "supplicantGenerateRand" [23]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantGenerateRand"); + bl_rand_stream(dataOut,length); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c700); + return; +} + + + +void ComputeEAPOL_MIC(EAPOL_KeyMsg_t *pKeyMsg,UINT16 data_length,UINT8 *MIC_Key,UINT8 MIC_Key_length + ,UINT8 micKeyDescVersion) + +{ + undefined2 in_register_0000202e; + undefined3 in_register_00002035; + undefined3 in_register_00002039; + uint uVar1; + uchar *output; + int iStack24; + int len; + UINT8 *pMicData; + + uVar1 = CONCAT31(in_register_00002039,micKeyDescVersion); + iStack24 = CONCAT22(in_register_0000202e,data_length); + if (uVar1 == 0) { + uVar1 = (uint)*(byte *)&(pKeyMsg->key_info).field_0x1 & 7; + } + output = pKeyMsg->key_MIC; + len = (int)pKeyMsg; + if (uVar1 == 1) { + Bl_hmac_md5((UINT8 *)pKeyMsg,iStack24,MIC_Key,CONCAT31(in_register_00002035,MIC_Key_length), + output); + } + else { + if (uVar1 == 2) { + Bl_hmac_sha1((uchar **)&len,&iStack24,1,MIC_Key,CONCAT31(in_register_00002035,MIC_Key_length), + output,0x10); + } + else { + bl_aes_cmac(MIC_Key,(UINT8 *)pKeyMsg,iStack24,output); + } + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT16 keyMgmtGetKeySize_internal(RSNConfig_t *pRsnConfig,UINT8 isPairwise) + +{ + Cipher_t_conflict CVar1; + char "keyMgmtGetKeySize_internal" [27]; + UINT16 UVar2; + undefined3 in_register_0000202d; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtGetKeySize_internal"); + if (CONCAT31(in_register_0000202d,isPairwise) == 0) { + CVar1 = pRsnConfig->mcstCipher; + UVar2 = 0x10; + if (((((byte)CVar1 & 8) == 0) && (UVar2 = 0xd, ((byte)CVar1 & 2) == 0)) && + (UVar2 = 0x20, ((byte)CVar1 & 1) != 0)) { + UVar2 = 5; + } + } + else { + UVar2 = 0x20; + if (((byte)pRsnConfig->ucstCipher & 8) != 0) { + UVar2 = 0x10; + } + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c718); + return UVar2; +} + + + +// WARNING: Variable defined which should be unmapped: tmpLo +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int isApReplayCounterFresh(keyMgmtInfoSta_t *pKeyMgmtInfoSta,UINT8 *pRxReplayCount) + +{ + char "isApReplayCounterFresh" [23]; + uint uVar1; + uint uVar2; + uint uVar3; + uint uVar4; + uint uStack24; + UINT32 tmpHi; + UINT32 tmpLo; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"isApReplayCounterFresh"); + memcpy(&uStack24,pRxReplayCount,4); + memcpy(&tmpHi,pRxReplayCount + 4,4); + uVar3 = uStack24 * 0x1000000 + (uStack24 >> 0x18) + (uStack24 & 0xff00) * 0x100 + + (uStack24 >> 8 & 0xff00); + uVar2 = pKeyMgmtInfoSta->apCounterHi; + uVar1 = 1; + if ((uVar3 <= uVar2) && (uVar1 = 0, uVar2 == uVar3)) { + uVar1 = 1; + uVar4 = tmpHi * 0x1000000 + (tmpHi >> 0x18) + (tmpHi & 0xff00) * 0x100 + (tmpHi >> 8 & 0xff00); + uVar3 = pKeyMgmtInfoSta->apCounterLo; + if ((uVar4 <= uVar3) && ((uVar1 = 0, uVar3 == uVar4 && ((uVar2 | uVar3) == 0)))) { + uVar1 = (uint)(pKeyMgmtInfoSta->apCounterZeroDone == 0); + } + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c734); + return uVar1; +} + + + +// WARNING: Variable defined which should be unmapped: tmpLo +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void updateApReplayCounter(keyMgmtInfoSta_t *pKeyMgmtStaInfo,UINT8 *pRxReplayCount) + +{ + char "updateApReplayCounter" [22]; + uint uVar1; + uint uVar2; + uint uStack24; + UINT32 tmpHi; + UINT32 tmpLo; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"updateApReplayCounter"); + memcpy(&uStack24,pRxReplayCount,4); + memcpy(&tmpHi,pRxReplayCount + 4,4); + uVar2 = uStack24 * 0x1000000 + (uStack24 >> 0x18) + (uStack24 & 0xff00) * 0x100 + + (uStack24 >> 8 & 0xff00); + uVar1 = tmpHi * 0x1000000 + (tmpHi >> 0x18) + (tmpHi & 0xff00) * 0x100 + (tmpHi >> 8 & 0xff00); + pKeyMgmtStaInfo->apCounterHi = uVar2; + pKeyMgmtStaInfo->apCounterLo = uVar1; + if ((uVar2 | uVar1) == 0) { + pKeyMgmtStaInfo->apCounterZeroDone = 1; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c74c); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void formEAPOLEthHdr(EAPOL_KeyMsg_Tx_t *pTxEapol,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa) + +{ + char "formEAPOLEthHdr" [16]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"formEAPOLEthHdr"); + memcpy(pTxEapol,da,6); + memcpy((pTxEapol->ethHdr).sa,sa,6); + *(undefined *)&(pTxEapol->ethHdr).type = 0x88; + *(undefined *)((int)&(pTxEapol->ethHdr).type + 1) = 0x8e; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c764); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN IsEAPOL_MICValid(EAPOL_KeyMsg_t *pKeyMsg,UINT8 *pMICKey) + +{ + UINT8 *__src; + int iVar1; + undefined auStack48 [4]; + UINT8 msgMIC [16]; + + __src = pKeyMsg->key_MIC; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"IsEAPOL_MICValid"); + memcpy(auStack48,__src,0x10); + memset(__src,0,0x10); + ComputeEAPOL_MIC(pKeyMsg,(UINT16)(((uint)CONCAT21((pKeyMsg->hdr_8021x).pckt_body_len, + *(undefined *) + ((int)&(pKeyMsg->hdr_8021x).pckt_body_len + 1)) + + 4) * 0x10000 >> 0x10),pMICKey,'\x10','\0'); + iVar1 = memcmp(__src,auStack48,0x10); + if (iVar1 == 0) { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"IsEAPOL_MICValid"); + } + return (uint)(iVar1 == 0); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT16 KeyMgmtSta_PopulateEAPOLLengthMic + (EAPOL_KeyMsg_Tx_t *pTxEapol,UINT8 *pEAPOLMICKey,UINT8 eapolProtocolVersion, + UINT8 forceKeyDescVersion) + +{ + undefined uVar1; + ushort uVar2; + char "KeyMgmtSta_PopulateEAPOLLengthMic" [34]; + UINT16 UVar3; + uint uVar4; + + UVar3 = 0; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_PopulateEAPOLLengthMic"); + if (pTxEapol != (EAPOL_KeyMsg_Tx_t *)0x0) { + uVar1 = *(undefined *)((int)&(pTxEapol->keyMsg).key_material_len + 1); + uVar2 = (pTxEapol->keyMsg).key_material_len; + uVar4 = (uint)uVar2 + 0x5f & 0xffff; + UVar3 = (UINT16)uVar4; + (pTxEapol->keyMsg).hdr_8021x.pckt_type = IEEE_8021X_PACKET_TYPE_EAPOL_KEY; + *(char *)&(pTxEapol->keyMsg).hdr_8021x.pckt_body_len = (char)(uVar4 >> 8); + *(undefined *)((int)&(pTxEapol->keyMsg).hdr_8021x.pckt_body_len + 1) = (char)uVar4; + *(undefined *)&(pTxEapol->keyMsg).key_material_len = uVar1; + (pTxEapol->keyMsg).hdr_8021x.protocol_ver = eapolProtocolVersion; + *(undefined *)((int)&(pTxEapol->keyMsg).key_material_len + 1) = + (char)((uint)CONCAT21(uVar2,uVar1) >> 8); + ComputeEAPOL_MIC(&pTxEapol->keyMsg,(UINT16)(((uint)uVar2 + 99) * 0x10000 >> 0x10),pEAPOLMICKey, + '\x10',forceKeyDescVersion); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c788); + } + return UVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +KDE_t * parseKeyKDE(IEEEtypes_InfoElementHdr_t *pIe) + +{ + char "parseKeyKDE" [12]; + int iVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"parseKeyKDE"); + if (((pIe->ElementId != ELEM_ID_VENDOR_SPECIFIC) || (pIe->Len < 8)) || + (iVar1 = memcmp(pIe + 1,"",3), iVar1 != 0)) { + pIe = (IEEEtypes_InfoElementHdr_t *)0x0; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c7ac); + } + return (KDE_t *)pIe; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +KDE_t * parseKeyKDE_DataType(UINT8 *pData,SINT32 dataLen,IEEEtypes_KDEDataType_e KDEDataType) + +{ + KDE_t *pKVar1; + undefined3 in_register_00002031; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"parseKeyKDE_DataType"); + if (pData != (UINT8 *)0x0) { + while (2 < dataLen) { + if (((IEEEtypes_InfoElementHdr_t *)pData)->ElementId == ELEM_ID_VENDOR_SPECIFIC) { + pKVar1 = parseKeyKDE((IEEEtypes_InfoElementHdr_t *)pData); + if ((pKVar1 != (KDE_t *)0x0) && + ((uint)pKVar1->dataType == CONCAT31(in_register_00002031,KDEDataType))) { + return pKVar1; + } + if (((IEEEtypes_InfoElementHdr_t *)pData)->Len == '\0') { + dataLen = 2; + } + } + dataLen = dataLen + (-2 - (uint)((IEEEtypes_InfoElementHdr_t *)pData)->Len); + pData = (UINT8 *)(&((IEEEtypes_InfoElementHdr_t *)pData)[1].ElementId + + (uint)((IEEEtypes_InfoElementHdr_t *)pData)->Len); + } + pData = (UINT8 *)0x0; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"parseKeyKDE_DataType"); + } + return (KDE_t *)pData; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +KDE_t * parseKeyDataGTK(UINT8 *pKey,UINT16 len,KeyData_t *pGRKey) + +{ + char "parseKeyDataGTK" [16]; + KDE_t *pKVar1; + undefined2 in_register_0000202e; + undefined auStack40 [4]; + UINT8 buf [8]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"parseKeyDataGTK"); + pKVar1 = parseKeyKDE_DataType(pKey,CONCAT22(in_register_0000202e,len),KDE_DATA_TYPE_GTK); + if (pKVar1 != (KDE_t *)0x0) { + memcpy(pGRKey,&pKVar1[1].length,(uint)pKVar1->length - 6); + pGRKey->KeyIndex = (ushort)pKVar1->data[0] & 3; + memcpy(auStack40,pGRKey->TxMICKey,8); + memcpy(pGRKey->TxMICKey,pGRKey->RxMICKey,8); + memcpy(pGRKey->RxMICKey,auStack40,8); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c7d0); + return pKVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmtSta_ApplyKEK(EAPOL_KeyMsg_t *pKeyMsg,KeyData_t *pGRKey,UINT8 *EAPOL_Encr_Key) + +{ + byte bVar1; + undefined uVar2; + uint3 uVar3; + char "KeyMgmtSta_ApplyKEK" [20]; + UINT8 *cipher; + uint uVar4; + int iVar5; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_ApplyKEK"); + bVar1 = pKeyMsg->key_RSC[1]; + cipher = pKeyMsg->key_data; + pGRKey->TxIV16 = (ushort)bVar1 << 8; + pGRKey->TxIV16 = CONCAT11(bVar1,pKeyMsg->key_RSC[0]); + pGRKey->TxIV32 = 0xffffffff; + uVar2 = *(undefined *)((int)&pKeyMsg->key_material_len + 1); + uVar3 = CONCAT21(pKeyMsg->key_material_len,uVar2); + uVar4 = (uint)uVar3 & 0xffff; + *(undefined *)((int)&pKeyMsg->key_material_len + 1) = (char)(uVar4 >> 8); + bVar1 = *(byte *)&(pKeyMsg->key_info).field_0x1; + *(undefined *)&pKeyMsg->key_material_len = uVar2; + if ((bVar1 & 7) == 1) { + RC4_Encrypt(EAPOL_Encr_Key,pKeyMsg->EAPOL_key_IV,0x10,cipher,(__uint16_t)uVar3,0x100); + } + else { + BL_AesUnWrap(EAPOL_Encr_Key,'\x02',(uVar4 >> 3) - 1,cipher,(UINT8 *)0x0,cipher); + iVar5 = (uint)pKeyMsg->key_material_len - 8; + *(char *)&pKeyMsg->key_material_len = (char)((uint)(iVar5 * 0x10000) >> 0x10); + *(undefined *)((int)&pKeyMsg->key_material_len + 1) = (char)((uint)iVar5 >> 8); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c7e0); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN KeyMgmtSta_IsRxEAPOLValid(keyMgmtInfoSta_t *pKeyMgmtInfoSta,EAPOL_KeyMsg_t *pKeyMsg) + +{ + BOOLEAN BVar1; + int iVar2; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_IsRxEAPOLValid"); + if ((((pKeyMgmtInfoSta == (keyMgmtInfoSta_t *)0x0) || (pKeyMsg == (EAPOL_KeyMsg_t *)0x0)) || + (iVar2 = isApReplayCounterFresh(pKeyMgmtInfoSta,(UINT8 *)pKeyMsg->replay_cnt), iVar2 == 0)) || + (((*(byte *)&pKeyMsg->key_info & 1) != 0 && + ((((*(byte *)&(pKeyMsg->key_info).field_0x1 & 8) != 0 && + (iVar2 = memcmp(pKeyMsg->key_nonce,pKeyMgmtInfoSta,0x20), iVar2 != 0)) || + (BVar1 = IsEAPOL_MICValid(pKeyMsg,pKeyMgmtInfoSta->EAPOL_MIC_Key), BVar1 == 0)))))) { + BVar1 = 0; + } + else { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_IsRxEAPOLValid"); + BVar1 = 1; + } + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmtSta_PrepareEAPOLFrame + (EAPOL_KeyMsg_Tx_t *pTxEapol,EAPOL_KeyMsg_t *pRxEapol,IEEEtypes_MacAddr_t *da, + IEEEtypes_MacAddr_t *sa,UINT8 *pSNonce) + +{ + byte bVar1; + byte bVar2; + UINT32 UVar3; + char "KeyMgmtSta_PrepareEAPOLFrame" [29]; + byte bVar4; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_PrepareEAPOLFrame"); + if ((pTxEapol != (EAPOL_KeyMsg_Tx_t *)0x0) && (pRxEapol != (EAPOL_KeyMsg_t *)0x0)) { + memset(pTxEapol,0,0x72); + formEAPOLEthHdr(pTxEapol,da,sa); + (pTxEapol->keyMsg).desc_type = pRxEapol->desc_type; + bVar4 = *(byte *)&(pRxEapol->key_info).field_0x1 & 8; + bVar1 = *(byte *)&(pTxEapol->keyMsg).key_info.field_0x1; + bVar2 = *(byte *)&(pTxEapol->keyMsg).key_info; + *(byte *)&(pTxEapol->keyMsg).key_info.field_0x1 = bVar1 & 0xf7 | bVar4; + *(byte *)&(pTxEapol->keyMsg).key_info = bVar2 | 1; + *(byte *)&(pTxEapol->keyMsg).key_info = bVar2 & 0xfd | 1 | *(byte *)&pRxEapol->key_info & 2; + UVar3 = pRxEapol->replay_cnt[0]; + *(char *)(pTxEapol->keyMsg).replay_cnt = (char)*(undefined3 *)pRxEapol->replay_cnt; + *(undefined *)((int)(pTxEapol->keyMsg).replay_cnt + 1) = (char)(UVar3 >> 8); + *(undefined *)((int)(pTxEapol->keyMsg).replay_cnt + 2) = (char)(UVar3 >> 0x10); + *(undefined *)((int)(pTxEapol->keyMsg).replay_cnt + 3) = (char)(UVar3 >> 0x18); + UVar3 = pRxEapol->replay_cnt[1]; + *(char *)((pTxEapol->keyMsg).replay_cnt + 1) = (char)*(undefined3 *)(pRxEapol->replay_cnt + 1); + *(undefined *)((int)(pTxEapol->keyMsg).replay_cnt + 5) = (char)(UVar3 >> 8); + *(undefined *)((int)(pTxEapol->keyMsg).replay_cnt + 6) = (char)(UVar3 >> 0x10); + *(undefined *)((int)(pTxEapol->keyMsg).replay_cnt + 7) = (char)(UVar3 >> 0x18); + *(byte *)&(pTxEapol->keyMsg).key_info.field_0x1 = + bVar1 & 0xf0 | bVar4 | *(byte *)&(pRxEapol->key_info).field_0x1 & 7; + if (pSNonce != (UINT8 *)0x0) { + memcpy((pTxEapol->keyMsg).key_nonce,pSNonce,0x20); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c810); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN supplicantAkmIsWpaWpa2(AkmSuite_t *pAkm) + +{ + int iVar1; + BOOLEAN BVar2; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantAkmIsWpaWpa2"); + iVar1 = memcmp(pAkm,"",3); + if ((iVar1 == 0) || (iVar1 = memcmp(pAkm,"",3), iVar1 == 0)) { + BVar2 = 1; + } + else { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"supplicantAkmIsWpaWpa2"); + BVar2 = 0; + } + return BVar2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN supplicantAkmIsWpa2(AkmSuite_t *pAkm) + +{ + int iVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantAkmIsWpa2"); + iVar1 = memcmp(pAkm,"",3); + if (iVar1 != 0) { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"supplicantAkmIsWpa2"); + } + return (uint)(iVar1 == 0); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN supplicantAkmIsWpaWpa2Psk(AkmSuite_t *pAkm) + +{ + char "supplicantAkmIsWpaWpa2Psk" [26]; + uint uVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantAkmIsWpaWpa2Psk"); + uVar1 = supplicantAkmIsWpaWpa2(pAkm); + if (uVar1 == 0) { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c85c); + } + else { + uVar1 = 1; + if ((pAkm->akmType & 0xfb) != 2) { + uVar1 = (uint)(pAkm->akmType == AKM_FT_PSK); + } + } + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BOOLEAN supplicantAkmUsesKdf(AkmSuite_t *pAkm) + +{ + char "supplicantAkmUsesKdf" [21]; + BOOLEAN BVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantAkmUsesKdf"); + BVar1 = supplicantAkmIsWpa2(pAkm); + if ((BVar1 == 0) || (BVar1 = 1, 3 < (byte)(pAkm->akmType + ~AKM_WPA_MAX))) { + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c878); + BVar1 = 0; + } + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantConstructContext + (IEEEtypes_MacAddr_t *pAddr1,IEEEtypes_MacAddr_t *pAddr2,UINT8 *pNonce1, + UINT8 *pNonce2,UINT8 *pContext) + +{ + char "supplicantConstructContext" [27]; + int iVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantConstructContext"); + iVar1 = memcmp(pAddr1,pAddr2,6); + if (iVar1 < 0) { + memcpy(pContext,pAddr1,6); + pAddr1 = pAddr2; + } + else { + memcpy(pContext,pAddr2,6); + } + memcpy(pContext + 6,pAddr1,6); + iVar1 = memcmp(pNonce1,pNonce2,0x20); + if (iVar1 < 0) { + memcpy(pContext + 0xc,pNonce1,0x20); + pNonce1 = pNonce2; + } + else { + memcpy(pContext + 0xc,pNonce2,0x20); + } + memcpy(pContext + 0x2c,pNonce1,0x20); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c890); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmt_DerivePTK(IEEEtypes_MacAddr_t *pAddr1,IEEEtypes_MacAddr_t *pAddr2,UINT8 *pNonce1, + UINT8 *pNonce2,UINT8 *pPTK,UINT8 *pPMK,BOOLEAN use_kdf) + +{ + char "KeyMgmt_DerivePTK" [18]; + UINT8 *pContext; + + pContext = pPTK + 200; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmt_DerivePTK"); + supplicantConstructContext(pAddr1,pAddr2,pNonce1,pNonce2,pContext); + if (use_kdf == 0) { + Bl_PRF(pPMK,0x20,(uchar *)"Pairwise key expansion",0x16,pContext,0x4c,pPTK,0x40); + } + else { + bl_sha256_crypto_kdf(pPMK,' ',"Pairwise key expansion",'\x16',pContext,0x4c,pPTK,0x180); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c8ac); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmtSta_DeriveKeys + (UINT8 *pPMK,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa,UINT8 *ANonce, + UINT8 *SNonce,UINT8 *EAPOL_MIC_Key,UINT8 *EAPOL_Encr_Key,KeyData_t *newPWKey, + BOOLEAN use_kdf) + +{ + char "KeyMgmtSta_DeriveKeys" [22]; + BOOLEAN in_stack_00000000; + UINT8 aUStack548 [4]; + UINT8 pBuf [500]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_DeriveKeys"); + if (((pPMK != (UINT8 *)0x0) && (EAPOL_MIC_Key != (UINT8 *)0x0)) && (newPWKey != (KeyData_t *)0x0)) + { + KeyMgmt_DerivePTK(sa,da,ANonce,SNonce,aUStack548,pPMK,in_stack_00000000); + memcpy(EAPOL_MIC_Key,aUStack548,0x10); + memcpy(EAPOL_Encr_Key,pBuf + 0xc,0x10); + memcpy(newPWKey,pBuf + 0x1c,0x10); + memcpy(newPWKey->RxMICKey,pBuf + 0x2c,8); + memcpy(newPWKey->TxMICKey,pBuf + 0x34,8); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c8c0); + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SetEAPOLKeyDescTypeVersion + (EAPOL_KeyMsg_Tx_t *pTxEapol,BOOLEAN isWPA2,BOOLEAN isKDF,BOOLEAN nonTKIP) + +{ + byte bVar1; + char "SetEAPOLKeyDescTypeVersion" [27]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"SetEAPOLKeyDescTypeVersion"); + bVar1 = *(byte *)&(pTxEapol->keyMsg).key_info.field_0x1; + (pTxEapol->keyMsg).desc_type = '\x02'; + *(byte *)&(pTxEapol->keyMsg).key_info.field_0x1 = bVar1 & 0xf8 | (isKDF != 0) + 2U; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c8d8); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +EAPOL_KeyMsg_t * +GetKeyMsgNonceFromEAPOL(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta) + +{ + char "GetKeyMsgNonceFromEAPOL" [24]; + EAPOL_KeyMsg_t *pKeyMsg; + BOOLEAN BVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"GetKeyMsgNonceFromEAPOL"); + pKeyMsg = (EAPOL_KeyMsg_t *)pEAPoLBufDesc->Buffer; + BVar1 = KeyMgmtSta_IsRxEAPOLValid(pKeyMgmtInfoSta,pKeyMsg); + if (BVar1 == 0) { + pKeyMsg = (EAPOL_KeyMsg_t *)0x0; + } + else { + if ((*(byte *)&pKeyMsg->key_info & 1) == 0) { + memcpy(pKeyMgmtInfoSta,pKeyMsg->key_nonce,0x20); + supplicantGenerateRand(pKeyMgmtInfoSta->SNonce,0x20); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c8f4); + } + return pKeyMsg; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +EAPOL_KeyMsg_t * +ProcessRxEAPOL_PwkMsg3(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta) + +{ + char "ProcessRxEAPOL_PwkMsg3" [23]; + EAPOL_KeyMsg_t *pKeyMsg; + BOOLEAN BVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"ProcessRxEAPOL_PwkMsg3"); + pKeyMsg = GetKeyMsgNonceFromEAPOL(pEAPoLBufDesc,pKeyMgmtInfoSta); + if (pKeyMsg == (EAPOL_KeyMsg_t *)0x0) { +LAB_23053168: + pKeyMsg = (EAPOL_KeyMsg_t *)0x0; + } + else { + (pKeyMgmtInfoSta->newPWKey).TxIV16 = 1; + (pKeyMgmtInfoSta->newPWKey).TxIV32 = 0; + if ((*(byte *)&pKeyMsg->key_info & 0x10) != 0) { + mm_timer_clear(&pKeyMgmtInfoSta->rsnTimer); + KeyMgmtSta_ApplyKEK(pKeyMsg,&pKeyMgmtInfoSta->GRKey,pKeyMgmtInfoSta->EAPOL_Encr_Key); + BVar1 = keyMgmtProcessMsgExt(pKeyMgmtInfoSta,pKeyMsg); + if (BVar1 == 0) goto LAB_23053168; + parseKeyDataGTK(pKeyMsg->key_data,pKeyMsg->key_material_len,&pKeyMgmtInfoSta->GRKey); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c90c); + } + return pKeyMsg; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +EAPOL_KeyMsg_t * +ProcessRxEAPOL_GrpMsg1(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta) + +{ + char "ProcessRxEAPOL_GrpMsg1" [23]; + EAPOL_KeyMsg_t *pKeyMsg; + BOOLEAN BVar1; + KeyData_t *pGRKey; + UINT8 *__src; + UINT8 *__src_00; + undefined auStack40 [4]; + UINT8 buf [8]; + + pKeyMsg = GetKeyMsgNonceFromEAPOL(pEAPoLBufDesc,pKeyMgmtInfoSta); + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"ProcessRxEAPOL_GrpMsg1"); + if (pKeyMsg == (EAPOL_KeyMsg_t *)0x0) { +LAB_23053224: + pKeyMsg = (EAPOL_KeyMsg_t *)0x0; + } + else { + pGRKey = &pKeyMgmtInfoSta->GRKey; + KeyMgmtSta_ApplyKEK(pKeyMsg,pGRKey,pKeyMgmtInfoSta->EAPOL_Encr_Key); + pKeyMgmtInfoSta->RSNDataTrafficEnabled = 1; + mm_timer_clear(&pKeyMgmtInfoSta->rsnTimer); + if (pKeyMsg->desc_type == '\x02') { + parseKeyDataGTK(pKeyMsg->key_data,pKeyMsg->key_material_len,pGRKey); + BVar1 = keyMgmtProcessMsgExt(pKeyMgmtInfoSta,pKeyMsg); + if (BVar1 == 0) goto LAB_23053224; + } + else { + memcpy(pGRKey,pKeyMsg->key_data,(uint)pKeyMsg->key_material_len); + __src_00 = (pKeyMgmtInfoSta->GRKey).TxMICKey; + memcpy(auStack40,__src_00,8); + __src = (pKeyMgmtInfoSta->GRKey).RxMICKey; + memcpy(__src_00,__src,8); + memcpy(__src,auStack40,8); + (pKeyMgmtInfoSta->GRKey).KeyIndex = (ushort)(*(byte *)&(pKeyMsg->key_info).field_0x1 >> 4) & 3 + ; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c924); + } + return pKeyMsg; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmtResetCounter(keyMgmtInfoSta_t *pKeyMgmtInfo) + +{ + char "KeyMgmtResetCounter" [20]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtResetCounter"); + if (pKeyMgmtInfo != (keyMgmtInfoSta_t *)0x0) { + pKeyMgmtInfo->staCounterHi = 0; + pKeyMgmtInfo->staCounterLo = 0; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c93c); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void keyMgmtSta_StartSession_internal(keyMgmtInfoSta_t *pKeyMgmtInfoSta,UINT32 expiry) + +{ + char "keyMgmtSta_StartSession_internal" [33]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"keyMgmtSta_StartSession_internal"); + if ((pKeyMgmtInfoSta->sta_MIC_Error).disableStaAsso == 0) { + mm_timer_set(&pKeyMgmtInfoSta->rsnTimer,_DAT_44b00120 + expiry); + } + pKeyMgmtInfoSta->apCounterLo = 0; + pKeyMgmtInfoSta->apCounterHi = 0; + pKeyMgmtInfoSta->apCounterZeroDone = 0; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c974); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void KeyMgmtSta_InitSession(keyMgmtInfoSta_t *pKeyMgmtInfoSta) + +{ + char "KeyMgmtSta_InitSession" [23]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"KeyMgmtSta_InitSession"); + pKeyMgmtInfoSta->RSNDataTrafficEnabled = 0; + pKeyMgmtInfoSta->RSNSecured = 0; + pKeyMgmtInfoSta->pRxDecryptKey = (cipher_key_t *)0x0; + pKeyMgmtInfoSta->pwkHandshakeComplete = 0; + (pKeyMgmtInfoSta->rsnTimer).cb = keyMgmtStaRsnSecuredTimeoutHandler; + *(keyMgmtInfoSta_t **)&(pKeyMgmtInfoSta->rsnTimer).env = pKeyMgmtInfoSta; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c998); + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +void bl_sha256_crypto_kdf + (UINT8 *pKey,UINT8 key_len,char *label,UINT8 label_len,UINT8 *pContext, + UINT16 context_len,UINT8 *pOutput,UINT16 output_len) + +{ + UINT8 *mac; + undefined3 in_register_0000202d; + undefined2 in_register_0000203e; + undefined2 in_register_00002046; + ushort auStack114 [8]; + ushort uStack98; + UINT16 i; + ushort *puStack96; + UINT8 *vectors [4]; + size_t vectLen [4]; + + uStack98 = 1; + mac = pContext + CONCAT22(in_register_0000203e,context_len); + auStack114[0] = output_len; + while ((uint)uStack98 <= (CONCAT22(in_register_00002046,output_len) + 0xff >> 8 & 0xffU)) { + vectors[3] = (UINT8 *)0x2; + puStack96 = &uStack98; + vectors[0] = (UINT8 *)label; + vectors[1] = pContext; + vectors[2] = (UINT8 *)auStack114; + hmac_sha256_vector(pKey,CONCAT31(in_register_0000202d,key_len),4,(UINT8 **)&stack0xffffffa0, + (size_t *)(vectors + 3),mac); + mac = mac + 0x20; + uStack98 = uStack98 + 1; + } + memcpy(pOutput,pContext + CONCAT22(in_register_0000203e,context_len),(uint)(auStack114[0] >> 3)); + return; +} + + + +void Bl_F(uchar *digest,uchar *digest1,char *password,uchar *ssid,int ssidlength,int iterations, + int count,uchar *output) + +{ + int iVar1; + size_t key_len; + byte *pbVar2; + uchar *puVar3; + byte *pbVar4; + int iVar5; + int iStack56; + int tmpLen; + uchar *pTemp; + + key_len = strlen(password); + iStack56 = ssidlength + 4; + tmpLen = (int)digest; + memcpy(digest,ssid,ssidlength); + puVar3 = digest + ssidlength; + *puVar3 = (uchar)((uint)count >> 0x18); + puVar3[1] = (uchar)((uint)count >> 0x10); + puVar3[2] = (uchar)((uint)count >> 8); + puVar3[3] = (uchar)count; + Bl_hmac_sha1((uchar **)&tmpLen,&iStack56,1,(uchar *)password,key_len,digest1,0x14); + memcpy(output,digest1,0x14); + iVar1 = 1; + tmpLen = (int)digest1; + while (iVar1 < iterations) { + iStack56 = 0x14; + Bl_hmac_sha1((uchar **)&tmpLen,&iStack56,1,(uchar *)password,key_len,digest,0x14); + memcpy(digest1,digest,0x14); + iVar5 = 0; + do { + pbVar2 = output + iVar5; + pbVar4 = digest + iVar5; + iVar5 = iVar5 + 1; + *pbVar2 = *pbVar4 ^ *pbVar2; + } while (iVar5 != 0x14); + iVar1 = iVar1 + 1; + } + return; +} + + + +int Bl_PasswordHash(char *password,uchar *ssid,int ssidlength,uchar *output) + +{ + size_t sVar1; + int iVar2; + uchar auStack88 [4]; + uchar digest1 [20]; + uchar digest [36]; + + sVar1 = strlen(password); + if (sVar1 < 0x40) { + iVar2 = -1; + if (ssidlength < 0x21) { + Bl_F(digest1 + 0x10,auStack88,password,ssid,ssidlength,0x1000,2,output); + memcpy(output + 0x14,output,0xc); + Bl_F(digest1 + 0x10,auStack88,password,ssid,ssidlength,0x1000,1,output); + iVar2 = 0; + } + } + else { + iVar2 = -1; + } + return iVar2; +} + + + +int bl60x_fw_password_hash(char *password,uchar *ssid,int ssidlength,uchar *output) + +{ + size_t sVar1; + int iVar2; + uchar auStack88 [20]; + uchar auStack68 [48]; + + sVar1 = strlen(password); + if (sVar1 < 0x40) { + iVar2 = -1; + if (ssidlength < 0x21) { + Bl_F(auStack68,auStack88,password,ssid,ssidlength,0x1000,2,output); + memcpy(output + 0x14,output,0xc); + Bl_F(auStack68,auStack88,password,ssid,ssidlength,0x1000,1,output); + iVar2 = 0; + } + } + else { + iVar2 = -1; + } + return iVar2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT8 * pmkCacheFindPSK(UINT8 *pSsid,UINT8 ssidLen) + +{ + char "pmkCacheFindPSK" [16]; + pmkElement_t *pPSK; + size_t sVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheFindPSK"); + pPSK = pmkCacheFindPSKElement(pSsid,ssidLen); + if (pPSK == (pmkElement_t *)0x0) { + if (PSKPassPhrase != '\0') { + pmkCacheAddPSK(pSsid,ssidLen,(UINT8 *)0x0,'\0'); + pPSK = pmkCacheFindPSKElement(pSsid,ssidLen); + sVar1 = strlen((char *)PSKPassPhrase); + pPSK = (pmkElement_t *)pPSK->PMK; + pmkCacheGeneratePSK(pSsid,ssidLen,PSKPassPhrase,(UINT8)sVar1,(UINT8 *)pPSK); + } + } + else { + pPSK = (pmkElement_t *)pPSK->PMK; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c9b0); + return (UINT8 *)pPSK; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheSetPassphrase(UINT8 *pSsid,UINT8 ssidLen,UINT8 *pPassphrase,UINT8 PassphraseLen) + +{ + char "pmkCacheSetPassphrase" [22]; + pmkElement_t *pSsid_00; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheSetPassphrase"); + if (pPassphrase != (UINT8 *)0x0) { + memcpy(PSKPassPhrase,pPassphrase,0x40); + pmkCacheAddPSK(pSsid,ssidLen,pPassphrase,PassphraseLen); + pSsid_00 = pmkCacheFindPSKElement(pSsid,ssidLen); + pmkCacheGeneratePSK((UINT8 *)pSsid_00,pSsid_00->length,PSKPassPhrase,PassphraseLen,pSsid_00->PMK + ); + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c9c0); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheInit(void) + +{ + char "pmkCacheInit" [13]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheInit"); + memset(pmkCache,0,0x86); + memset(PSKPassPhrase,0,0x40); + replacementRankMax = '\0'; + dbg_test_print("%dms : Leave: %s\n",0x2307c9d8); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheRomInit(void) + +{ + char "pmkCacheRomInit" [16]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheRomInit"); + ramHook_MAX_PMK_CACHE_ENTRIES = 2; + ramHook_pmkCache = pmkCache; + ramHook_PSKPassPhrase = PSKPassPhrase; + dbg_test_print("%dms : Leave: %s\n",0x2307c9e8); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +pmkElement_t * pmkCacheNewElement(void) + +{ + char "pmkCacheNewElement" [19]; + uint uVar1; + pmkElement_t *__s; + pmkElement_t *ppVar2; + + ppVar2 = (pmkElement_t *)0x0; + uVar1 = 0; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheNewElement"); + while ((int)uVar1 < ramHook_MAX_PMK_CACHE_ENTRIES) { + if ((int)replacementRankMax == ramHook_MAX_PMK_CACHE_ENTRIES) { + ramHook_pmkCache[uVar1].replacementRank = ramHook_pmkCache[uVar1].replacementRank + -1; + } + if (ppVar2 == (pmkElement_t *)0x0) { + __s = ramHook_pmkCache + uVar1; + if (__s->replacementRank == '\0') { + memset(__s,0,0x43); + if (replacementRankMax < ramHook_MAX_PMK_CACHE_ENTRIES) { + replacementRankMax = replacementRankMax + '\x01'; + } + ramHook_pmkCache[uVar1].replacementRank = replacementRankMax; + ppVar2 = __s; + } + } + uVar1 = uVar1 + 1 & 0xff; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307c9f8); + return ppVar2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheUpdateReplacementRank(pmkElement_t *pPMKElement) + +{ + char cVar1; + SINT8 SVar2; + pmkElement_t *ppVar3; + SINT32 SVar4; + char "pmkCacheUpdateReplacementRank" [30]; + uint uVar5; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheUpdateReplacementRank"); + SVar4 = ramHook_MAX_PMK_CACHE_ENTRIES; + ppVar3 = ramHook_pmkCache; + SVar2 = replacementRankMax; + if ((pPMKElement != (pmkElement_t *)0x0) && (pPMKElement->replacementRank != replacementRankMax)) + { + uVar5 = 0; + while ((int)uVar5 < SVar4) { + cVar1 = ppVar3[uVar5].replacementRank; + if (pPMKElement->replacementRank < cVar1) { + ppVar3[uVar5].replacementRank = cVar1 + -1; + } + uVar5 = uVar5 + 1 & 0xff; + } + pPMKElement->replacementRank = SVar2; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307ca0c); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +pmkElement_t * pmkCacheFindPSKElement(UINT8 *pSsid,UINT8 ssidLen) + +{ + char "pmkCacheFindPSKElement" [23]; + uint uVar1; + pmkElement_t *pPMKElement; + pmkElement_t *__s1; + int iVar2; + undefined3 in_register_0000202d; + + pPMKElement = (pmkElement_t *)0x0; + uVar1 = 0; + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheFindPSKElement"); + while ((int)uVar1 < ramHook_MAX_PMK_CACHE_ENTRIES) { + __s1 = ramHook_pmkCache + uVar1; + if (((__s1->replacementRank != '\0') && + ((uint)__s1->length == CONCAT31(in_register_0000202d,ssidLen))) && + (iVar2 = memcmp(__s1,pSsid,CONCAT31(in_register_0000202d,ssidLen)), iVar2 == 0)) { + pPMKElement = ramHook_pmkCache + uVar1; + } + uVar1 = uVar1 + 1 & 0xff; + } + pmkCacheUpdateReplacementRank(pPMKElement); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307ca2c); + return pPMKElement; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheAddPSK(UINT8 *pSsid,UINT8 ssidLen,UINT8 *pPSK,UINT8 pPSKLen) + +{ + char "pmkCacheAddPSK" [15]; + pmkElement_t *__dest; + undefined3 in_register_0000202d; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheAddPSK"); + __dest = pmkCacheFindPSKElement(pSsid,ssidLen); + if (__dest == (pmkElement_t *)0x0) { + __dest = pmkCacheNewElement(); + memcpy(__dest,pSsid,CONCAT31(in_register_0000202d,ssidLen)); + __dest->length = ssidLen; + } + if (pPSK != (UINT8 *)0x0) { + memcpy(__dest->PMK,pPSK,0x20); + __dest->psk_length = pPSKLen; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307ca44); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheDeletePSK(UINT8 *pSsid,UINT8 ssidLen) + +{ + char "pmkCacheDeletePSK" [18]; + pmkElement_t *__s; + + __s = pmkCacheFindPSKElement(pSsid,ssidLen); + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheDeletePSK"); + if (__s != (pmkElement_t *)0x0) { + memset(__s,0,0x43); + replacementRankMax = replacementRankMax + -1; + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307ca54); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +UINT8 pmkCacheGetHexNibble(UINT8 nibble) + +{ + undefined3 in_register_00002029; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheGetHexNibble"); + if (CONCAT31(in_register_00002029,nibble) < 0x61) { + if (CONCAT31(in_register_00002029,nibble) < 0x41) { + nibble = nibble + -0x30; + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,"pmkCacheGetHexNibble"); + } + else { + nibble = nibble + -0x37; + } + } + else { + nibble = nibble + -0x57; + } + return nibble; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void pmkCacheGeneratePSK(UINT8 *pSsid,UINT8 ssidLen,UINT8 *pPassphrase,UINT8 PassphraseLen, + UINT8 *pPSK) + +{ + char "pmkCacheGeneratePSK" [20]; + UINT8 UVar1; + byte bVar2; + undefined3 in_register_0000202d; + undefined3 in_register_00002035; + int iVar3; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"pmkCacheGeneratePSK"); + if ((pPSK != (UINT8 *)0x0) && (pPassphrase != (UINT8 *)0x0)) { + if (CONCAT31(in_register_00002035,PassphraseLen) - 8U < 0x38) { + utils_wifi_psk_cal_fast_bin + ((char *)pPassphrase,pSsid,CONCAT31(in_register_0000202d,ssidLen),pPSK); + } + else { + if (CONCAT31(in_register_00002035,PassphraseLen) == 0x40) { + iVar3 = 0; + do { + UVar1 = pmkCacheGetHexNibble(*pPassphrase); + bVar2 = pmkCacheGetHexNibble(pPassphrase[1]); + pPSK[iVar3 >> 1] = bVar2 | UVar1 << 4; + iVar3 = iVar3 + 2; + pPassphrase = pPassphrase + 2; + } while (iVar3 != 0x40); + } + } + } + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307ca80); + return; +} + + + +void prepare_key(uchar *key_data_ptr,int key_data_len,rc4_key *key) + +{ + byte bVar1; + uchar *puVar2; + rc4_key *prVar3; + uint uVar4; + int iVar5; + uint uVar6; + uint uVar7; + + iVar5 = 0; + do { + key->state[iVar5] = (uchar)iVar5; + iVar5 = iVar5 + 1; + } while (iVar5 != 0x100); + key->x = '\0'; + key->y = '\0'; + uVar7 = 0; + uVar4 = 0; + prVar3 = key; + do { + bVar1 = prVar3->state[0]; + puVar2 = prVar3->state; + uVar6 = (uint)key_data_ptr[uVar4] + (uint)bVar1 + uVar7; + uVar7 = uVar6 & 0xff; + prVar3->state[0] = key->state[uVar6 & 0xff]; + key->state[uVar6 & 0xff] = bVar1; + uVar4 = (int)(uVar4 + 1) % key_data_len & 0xff; + prVar3 = (rc4_key *)(puVar2 + 1); + } while ((rc4_key *)&key->x != (rc4_key *)(puVar2 + 1)); + return; +} + + + +void rc4(uchar *buffer_ptr,int buffer_len,int skip,rc4_key *key) + +{ + byte bVar1; + byte bVar2; + byte *pbVar3; + uint uVar4; + int iVar5; + uint uVar6; + byte *pbVar7; + uint uVar8; + + bVar1 = key->x; + uVar4 = (uint)key->y; + iVar5 = 0; + while (uVar8 = (uint)bVar1 + iVar5 & 0xff, iVar5 < skip) { + bVar2 = key->state[uVar8 + 1 & 0xff]; + uVar4 = uVar4 + bVar2 & 0xff; + iVar5 = (iVar5 + 1) * 0x10000 >> 0x10; + key->state[uVar8 + 1 & 0xff] = key->state[uVar4]; + key->state[uVar4] = bVar2; + } + iVar5 = 0; + while (uVar6 = uVar8 + iVar5 & 0xff, iVar5 < buffer_len) { + pbVar7 = key->state + (uVar6 + 1 & 0xff); + bVar1 = *pbVar7; + uVar4 = uVar4 + (uint)bVar1 & 0xff; + *pbVar7 = key->state[uVar4]; + key->state[uVar4] = bVar1; + pbVar3 = buffer_ptr + iVar5; + iVar5 = (iVar5 + 1) * 0x10000 >> 0x10; + *pbVar3 = key->state[(uint)bVar1 + (uint)*pbVar7 & 0xff] ^ *pbVar3; + } + key->x = (uchar)uVar6; + key->y = (uchar)uVar4; + return; +} + + + +void RC4_Encrypt(uchar *Encr_Key,uchar *IV,__uint16_t iv_length,uchar *Data,__uint16_t data_length, + __uint16_t skipBytes) + +{ + undefined2 in_register_00002032; + size_t __n; + undefined2 in_register_0000203a; + undefined2 in_register_0000203e; + uchar auStack64 [4]; + uchar key [32]; + + __n = CONCAT22(in_register_00002032,iv_length); + if ((int)(__n + 0x10) < 0x21) { + memcpy(auStack64,IV,__n); + memcpy(auStack64 + __n,Encr_Key,0x10); + prepare_key(auStack64,__n + 0x10,&rc4key); + rc4(Data,CONCAT22(in_register_0000203a,data_length),CONCAT22(in_register_0000203e,skipBytes), + &rc4key); + } + return; +} + + + +int sha256_compress(sha256_state *md,UINT8 *msgBuf,UINT8 *pScratchMem) + +{ + UINT32 *pUVar1; + UINT32 *pUVar2; + int iVar3; + uint uVar4; + uint *puVar5; + uint uVar6; + int *piVar7; + int *piVar8; + int iVar9; + int iVar10; + uint uVar11; + int *__dest; + ushort *puVar12; + ushort *puVar13; + uint uVar14; + uint uVar15; + uint uVar16; + + __dest = (int *)(pScratchMem + 0x100); + memcpy(__dest,md->state,0x20); + puVar5 = (uint *)pScratchMem; + puVar12 = (ushort *)msgBuf; + do { + puVar13 = puVar12 + 2; + *puVar5 = (((uint)(*puVar12 >> 8) | ((uint)*puVar12 & 0xff) << 8) << 8 | + (uint)*(byte *)(puVar12 + 1)) << 8 | (uint)*(byte *)((int)puVar12 + 3); + puVar5 = puVar5 + 1; + puVar12 = puVar13; + } while (puVar13 != (ushort *)(msgBuf + 0x40)); + piVar7 = (int *)(pScratchMem + 0x40); + do { + uVar6 = piVar7[-2]; + uVar4 = piVar7[-0xf]; + piVar8 = piVar7 + 1; + *piVar7 = ((uVar6 << 0xf | uVar6 >> 0x11) ^ (uVar6 << 0xd | uVar6 >> 0x13) ^ uVar6 >> 10) + + piVar7[-7] + piVar7[-0x10] + + ((uVar4 >> 7 | uVar4 << 0x19) ^ (uVar4 << 0xe | uVar4 >> 0x12) ^ uVar4 >> 3); + piVar7 = piVar8; + } while (__dest != piVar8); + iVar3 = 0; + do { + uVar4 = *(uint *)(pScratchMem + 0x110); + uVar14 = *(uint *)(pScratchMem + 0x118); + uVar15 = *(uint *)(pScratchMem + 0x114); + uVar6 = *(uint *)(pScratchMem + 0x100); + iVar9 = *(int *)((int)K + iVar3); + uVar11 = *(uint *)(pScratchMem + 0x104); + uVar16 = *(uint *)(pScratchMem + 0x108); + iVar10 = *(int *)(pScratchMem + iVar3); + *(uint *)(pScratchMem + 0x114) = uVar4; + iVar10 = ((uVar4 >> 6 | uVar4 << 0x1a) ^ (uVar4 >> 0xb | uVar4 << 0x15) ^ + (uVar4 << 7 | uVar4 >> 0x19)) + ((uVar14 ^ uVar15) & uVar4 ^ uVar14) + + *(int *)(pScratchMem + 0x11c) + iVar9 + iVar10; + *(int *)(pScratchMem + 0x110) = *(int *)(pScratchMem + 0x10c) + iVar10; + *(uint *)(pScratchMem + 0x104) = uVar6; + *(uint *)(pScratchMem + 0x11c) = uVar14; + *(uint *)(pScratchMem + 0x118) = uVar15; + *(uint *)(pScratchMem + 0x10c) = uVar16; + *(uint *)(pScratchMem + 0x108) = uVar11; + *(uint *)(pScratchMem + 0x100) = + iVar10 + ((uVar6 >> 2 | uVar6 << 0x1e) ^ (uVar6 >> 0xd | uVar6 << 0x13) ^ + (uVar6 << 10 | uVar6 >> 0x16)) + (uVar6 & uVar11 | (uVar6 | uVar11) & uVar16); + iVar3 = iVar3 + 4; + } while (iVar3 != 0x100); + pUVar1 = md->state; + do { + iVar3 = *__dest; + pUVar2 = pUVar1 + 1; + __dest = __dest + 1; + *pUVar1 = *pUVar1 + iVar3; + pUVar1 = pUVar2; + } while (&md->curlen != pUVar2); + return 0; +} + + + +void sha256_init(sha256_state *md) + +{ + *(undefined4 *)&md->length = 0; + md->state[0] = 0x6a09e667; + md->state[1] = 0xbb67ae85; + md->state[2] = 0x3c6ef372; + md->state[3] = 0xa54ff53a; + md->state[4] = 0x510e527f; + md->state[5] = 0x9b05688c; + md->state[6] = 0x1f83d9ab; + md->curlen = 0; + *(undefined4 *)((int)&md->length + 4) = 0; + md->state[7] = 0x5be0cd19; + return; +} + + + +void sha256_vector(size_t num_elem,UINT8 **addr,size_t *len,UINT8 *mac,UINT8 *pScratchMem) + +{ + int iVar1; + uint uVar2; + uint __n; + undefined4 uVar3; + undefined4 uVar4; + undefined4 *puVar5; + uint uVar6; + UINT8 *msgBuf; + UINT8 *pScratchMem_00; + int iVar7; + + pScratchMem_00 = pScratchMem + 0x70; + sha256_init((sha256_state *)pScratchMem); + iVar7 = 0; + do { + __n = *(uint *)(pScratchMem + 0x28); + if (iVar7 == num_elem << 2) { + if (__n < 0x40) { + uVar2 = __n * 8 + *(uint *)pScratchMem; + *(uint *)(pScratchMem + 4) = + (uint)(uVar2 < *(uint *)pScratchMem) + *(int *)(pScratchMem + 4); + *(uint *)pScratchMem = uVar2; + *(uint *)(pScratchMem + 0x28) = __n + 1; + pScratchMem[__n + 0x2c] = -0x80; + if (0x38 < __n + 1) { + while (__n = *(uint *)(pScratchMem + 0x28), __n < 0x40) { + *(uint *)(pScratchMem + 0x28) = __n + 1; + pScratchMem[__n + 0x2c] = '\0'; + } + sha256_compress((sha256_state *)pScratchMem,pScratchMem + 0x2c,pScratchMem_00); + *(undefined4 *)(pScratchMem + 0x28) = 0; + } + while (__n = *(uint *)(pScratchMem + 0x28), __n < 0x38) { + *(uint *)(pScratchMem + 0x28) = __n + 1; + pScratchMem[__n + 0x2c] = '\0'; + } + uVar3 = *(undefined4 *)pScratchMem; + pScratchMem[0x68] = (UINT8)((uint)uVar3 >> 0x18); + pScratchMem[0x69] = (UINT8)((uint)uVar3 >> 0x10); + pScratchMem[0x6b] = (UINT8)uVar3; + uVar4 = *(undefined4 *)(pScratchMem + 4); + pScratchMem[0x6a] = (UINT8)((uint)uVar3 >> 8); + pScratchMem[100] = (UINT8)((uint)uVar4 >> 0x18); + pScratchMem[0x65] = (UINT8)((uint)uVar4 >> 0x10); + pScratchMem[0x67] = (UINT8)uVar4; + pScratchMem[0x66] = (UINT8)((uint)uVar4 >> 8); + sha256_compress((sha256_state *)pScratchMem,pScratchMem + 0x2c,pScratchMem_00); + puVar5 = (undefined4 *)(pScratchMem + 8); + do { + puVar5 = puVar5 + 1; + uVar3 = *puVar5; + *mac = (UINT8)((uint)uVar3 >> 0x18); + mac[1] = (UINT8)((uint)uVar3 >> 0x10); + mac[2] = (UINT8)((uint)uVar3 >> 8); + mac[3] = (UINT8)uVar3; + puVar5 = puVar5; + mac = mac + 4; + } while (puVar5 != (undefined4 *)(pScratchMem + 0x28)); + } + return; + } + msgBuf = *(UINT8 **)((int)addr + iVar7); + uVar2 = *(uint *)((int)len + iVar7); + if (__n < 0x41) { + while (iVar1 = *(int *)(pScratchMem + 0x28), uVar2 != 0) { + if ((iVar1 == 0) && (0x3f < uVar2)) { + iVar1 = sha256_compress((sha256_state *)pScratchMem,msgBuf,pScratchMem_00); + if (iVar1 < 0) break; + uVar6 = *(uint *)pScratchMem; + msgBuf = msgBuf + 0x40; + __n = uVar6 + 0x200; + *(uint *)pScratchMem = __n; + *(uint *)(pScratchMem + 4) = (uint)(__n < uVar6) + *(int *)(pScratchMem + 4); + uVar2 = uVar2 - 0x40; + } + else { + __n = 0x40U - iVar1; + if (uVar2 < 0x40U - iVar1) { + __n = uVar2; + } + memcpy(pScratchMem + 0x2c + iVar1,msgBuf,__n); + iVar1 = *(int *)(pScratchMem + 0x28); + msgBuf = msgBuf + __n; + uVar2 = uVar2 - __n; + *(uint *)(pScratchMem + 0x28) = iVar1 + __n; + if (iVar1 + __n == 0x40) { + iVar1 = sha256_compress((sha256_state *)pScratchMem,pScratchMem + 0x2c,pScratchMem_00); + if (iVar1 < 0) break; + uVar6 = *(uint *)pScratchMem; + *(undefined4 *)(pScratchMem + 0x28) = 0; + __n = uVar6 + 0x200; + *(uint *)pScratchMem = __n; + *(uint *)(pScratchMem + 4) = (uint)(__n < uVar6) + *(int *)(pScratchMem + 4); + } + } + } + } + iVar7 = iVar7 + 4; + } while( true ); +} + + + +// WARNING: Variable defined which should be unmapped: pScratchMem + +void hmac_sha256_vector(UINT8 *key,size_t key_len,size_t num_elem,UINT8 **addr,size_t *len, + UINT8 *mac) + +{ + size_t *mac_00; + UINT8 **ppUVar1; + size_t **ppsVar2; + UINT8 **len_00; + UINT8 **ppUVar3; + size_t *psVar4; + int iVar5; + size_t *psVar6; + size_t sStack600; + uint *apuStack596 [4]; + size_t *psStack580; + UINT8 *_addr [6]; + size_t _len [6]; + UINT8 pScratchMem [500]; + + mac_00 = (size_t *)(pScratchMem + 0x3c); + sStack600 = key_len; + apuStack596[0] = (uint *)key; + if (0x40 < key_len) { + apuStack596[0] = (uint *)key; + sha256_vector(1,(UINT8 **)apuStack596,&sStack600,(UINT8 *)mac_00,pScratchMem + 0x5c); + sStack600 = 0x20; + apuStack596[0] = mac_00; + } + memset(_len + 5,0,0x40); + memcpy(_len + 5,apuStack596[0],sStack600); + psVar6 = _len + 5; + do { + psVar4 = psVar6 + 1; + *psVar6 = *psVar6 ^ 0x36363636; + psVar6 = psVar4; + } while (psVar4 != mac_00); + psStack580 = _len + 5; + len_00 = _addr + 5; + _addr[5] = (UINT8 *)0x40; + iVar5 = 0; + ppsVar2 = &psStack580; + ppUVar3 = len_00; + while( true ) { + ppsVar2 = ppsVar2 + 1; + ppUVar3 = ppUVar3 + 1; + if (iVar5 == num_elem << 2) break; + *ppsVar2 = *(size_t **)((int)addr + iVar5); + ppUVar1 = (UINT8 **)((int)len + iVar5); + iVar5 = iVar5 + 4; + *ppUVar3 = *ppUVar1; + } + sha256_vector(num_elem + 1,(UINT8 **)&psStack580,(size_t *)len_00,mac,pScratchMem + 0x5c); + memset(_len + 5,0,0x40); + memcpy(_len + 5,apuStack596[0],sStack600); + psVar6 = _len + 5; + do { + psVar4 = psVar6 + 1; + *psVar6 = *psVar6 ^ 0x5c5c5c5c; + psVar6 = psVar4; + } while (psVar4 != mac_00); + psStack580 = _len + 5; + _addr[5] = (UINT8 *)0x40; + _len[0] = 0x20; + _addr[0] = mac; + sha256_vector(2,(UINT8 **)&psStack580,(size_t *)len_00,mac,pScratchMem + 0x5c); + return; +} + + + +void KeyMgmtInit(cm_ConnectionInfo_t *connPtr) + +{ + UINT8 ssidLen; + apInfo_t *paVar1; + size_t sVar2; + UINT8 *pPassphrase; + + paVar1 = cm_GetApInfo(connPtr); + ROM_InitGTK(&(paVar1->bssData).grpKeyData,(paVar1->bssData).GNonce,connPtr->localMacAddr); + if ((paVar1->bssData).updatePassPhrase == 1) { + ssidLen = (connPtr->comData).SsIdLen; + pPassphrase = (paVar1->bssConfig).RsnConfig.PSKPassPhrase; + sVar2 = strlen((char *)pPassphrase); + pmkCacheGeneratePSK((UINT8 *)&connPtr->comData,ssidLen,pPassphrase,(UINT8)sVar2, + (paVar1->bssConfig).RsnConfig.PSKValue); + (paVar1->bssData).updatePassPhrase = 0; + } + return; +} + + + +BufferDesc_t * +PrepDefaultEapolMsg(cm_ConnectionInfo_t *connPtr,EAPOL_KeyMsg_Tx_t **pTxEapolPtr, + BufferDesc_t *pBufDesc) + +{ + apSpecificData_t *paVar1; + apInfo_t *paVar2; + BufferDesc_t *pBVar3; + uint nonTKIP; + EAPOL_KeyMsg_Tx_t *pEStack36; + EAPOL_KeyMsg_Tx_t *tx_eapol_ptr; + + paVar1 = cm_GetApData(connPtr); + paVar2 = cm_GetApInfo(connPtr); + pBVar3 = GetTxEAPOLBuffer(connPtr,&pEStack36,pBufDesc); + if (pBVar3 != (BufferDesc_t *)0x0) { + memset(pEStack36,0,0x72); + formEAPOLEthHdr(pEStack36,(IEEEtypes_MacAddr_t *)connPtr->peerMacAddr, + (IEEEtypes_MacAddr_t *)connPtr->localMacAddr); + nonTKIP = 1; + if (((byte)(paVar1->staData).keyMgmtInfo.rom.staUcstCipher & 8) == 0) { + nonTKIP = (uint)((byte)(paVar2->bssConfig).RsnConfig.mcstCipher >> 3) & 1; + } + SetEAPOLKeyDescTypeVersion + (pEStack36,*(uint *)&(paVar1->staData).keyMgmtInfo.rom >> 0x15 & 1,0,nonTKIP); + *pTxEapolPtr = pEStack36; + } + return pBVar3; +} + + + +// WARNING: Variable defined which should be unmapped: replay_cnt + +Status_e GeneratePWKMsg1(cm_ConnectionInfo_t *connPtr,BufferDesc_t *pBufDesc) + +{ + Status_e SVar1; + apSpecificData_t *paVar2; + BufferDesc_t *pBufDesc_00; + uint uVar3; + uint uVar4; + UINT32 UVar5; + EAPOL_KeyMsg_Tx_t *pEStack28; + EAPOL_KeyMsg_Tx_t *tx_eapol_ptr; + UINT32 replay_cnt [2]; + + paVar2 = cm_GetApData(connPtr); + pBufDesc_00 = PrepDefaultEapolMsg(connPtr,&pEStack28,pBufDesc); + if (pBufDesc_00 == (BufferDesc_t *)0x0) { + SVar1 = FAIL; + } + else { + UVar5 = (paVar2->staData).keyMgmtInfo.counterLo + 1; + (paVar2->staData).keyMgmtInfo.counterLo = UVar5; + if (UVar5 == 0) { + (paVar2->staData).keyMgmtInfo.counterHi = (paVar2->staData).keyMgmtInfo.counterHi + 1; + } + tx_eapol_ptr = (EAPOL_KeyMsg_Tx_t *)(paVar2->staData).keyMgmtInfo.counterHi; + supplicantGenerateRand((UINT8 *)&connPtr->TxRxCipherKeyBuf,0x20); + PopulateKeyMsg(pEStack28,&(paVar2->staData).keyMgmtInfo.rom.staUcstCipher,0x800, + (UINT32 *)&tx_eapol_ptr,(UINT8 *)&connPtr->TxRxCipherKeyBuf); + uVar3 = (uint)(pEStack28->keyMsg).key_material_len + 0x5f; + uVar4 = uVar3 & 0xffff; + (pEStack28->keyMsg).hdr_8021x.protocol_ver = (paVar2->staData).keyMgmtInfo.EAPOLProtoVersion; + (pEStack28->keyMsg).hdr_8021x.pckt_type = IEEE_8021X_PACKET_TYPE_EAPOL_KEY; + *(char *)&(pEStack28->keyMsg).hdr_8021x.pckt_body_len = (char)(uVar4 >> 8); + *(undefined *)((int)&(pEStack28->keyMsg).hdr_8021x.pckt_body_len + 1) = (char)uVar4; + UpdateEAPOLWcbLenAndTransmit(pBufDesc_00,(UINT16)(uVar3 * 0x10000 >> 0x10)); + SVar1 = FW_SUCCESS; + } + return SVar1; +} + + + +Status_e GeneratePWKMsg3(cm_ConnectionInfo_t *connPtr,BufferDesc_t *pBufDesc) + +{ + SecurityMode_t SVar1; + UINT16 frameLen; + BufferDesc_t *pBufDesc_00; + apSpecificData_t *paVar2; + apInfo_t *paVar3; + BOOLEAN BVar4; + uint8_t *pWPA2; + UINT32 UVar5; + Cipher_t_conflict *Cipher; + EAPOL_KeyMsg_Tx_t *pEStack44; + EAPOL_KeyMsg_Tx_t *tx_eapol_ptr; + UINT32 replay_cnt [2]; + + pBufDesc_00 = PrepDefaultEapolMsg(connPtr,&pEStack44,pBufDesc); + if (pBufDesc_00 != (BufferDesc_t *)0x0) { + paVar2 = cm_GetApData(connPtr); + paVar3 = cm_GetApInfo(connPtr); + UVar5 = (paVar2->staData).keyMgmtInfo.counterLo + 1; + (paVar2->staData).keyMgmtInfo.counterLo = UVar5; + if (UVar5 == 0) { + (paVar2->staData).keyMgmtInfo.counterHi = (paVar2->staData).keyMgmtInfo.counterHi + 1; + } + tx_eapol_ptr = (EAPOL_KeyMsg_Tx_t *)(paVar2->staData).keyMgmtInfo.counterHi; + Cipher = &(paVar2->staData).keyMgmtInfo.rom.staUcstCipher; + PopulateKeyMsg(pEStack44,Cipher, + ((ushort)(paVar2->staData).keyMgmtInfo.rom.staSecType & 0x20) << 10 | 0x880, + (UINT32 *)&tx_eapol_ptr,(UINT8 *)&connPtr->TxRxCipherKeyBuf); + SVar1 = (paVar2->staData).keyMgmtInfo.rom.staSecType; + pWPA2 = (uint8_t *)0x0; + if ((((ushort)SVar1 & 8) == 0) && (((ushort)SVar1 & 0x20) != 0)) { + pWPA2 = int_rsn_ie; + } + BVar4 = KeyData_UpdateKeyMaterial + (pEStack44,&(paVar2->staData).keyMgmtInfo.rom.staSecType,(void *)0x0,pWPA2); + if (BVar4 != 0) { + if (((ushort)(paVar2->staData).keyMgmtInfo.rom.staSecType & 0x20) == 0) { +LAB_2305462c: + frameLen = KeyMgmtSta_PopulateEAPOLLengthMic + (pEStack44,(paVar2->staData).keyMgmtInfo.EAPOL_MIC_Key, + (paVar2->staData).keyMgmtInfo.EAPOLProtoVersion, + *(byte *)&(pEStack44->keyMsg).key_info.field_0x1 & 7); + UpdateEAPOLWcbLenAndTransmit(pBufDesc_00,frameLen); + return FW_SUCCESS; + } + prepareKDE(pEStack44,&(paVar3->bssData).grpKeyData, + (Cipher_t_conflict *)&(paVar3->bssConfig).RsnConfig); + BVar4 = Encrypt_keyData(pEStack44,(paVar2->staData).keyMgmtInfo.EAPOL_Encr_Key,Cipher); + if (BVar4 != 0) goto LAB_2305462c; + } + vPortFree(pBufDesc_00->Buffer); + vPortFree(pBufDesc_00); + } + return FAIL; +} + + + +Status_e ProcessPWKMsg4(BufferDesc_t *pBufDesc) + +{ + SecurityMode_t SVar1; + cm_ConnectionInfo_t *connPtr; + Status_e SVar2; + apSpecificData_t *paVar3; + BOOLEAN BVar4; + + connPtr = (cm_ConnectionInfo_t *)pBufDesc->intf; + paVar3 = cm_GetApData(connPtr); + BVar4 = IsEAPOL_MICValid((EAPOL_KeyMsg_t *)pBufDesc->Buffer, + (paVar3->staData).keyMgmtInfo.EAPOL_MIC_Key); + if (BVar4 == 0) { + SVar2 = FAIL; + } + else { + (connPtr->TxRxCipherKeyBuf).cipher_key.ckd[0x44] = 1; + (connPtr->TxRxCipherKeyBuf).cipher_key.ckd[0x45] = 0; + (connPtr->TxRxCipherKeyBuf).cipher_key.ckd[0x40] = 0; + (connPtr->TxRxCipherKeyBuf).cipher_key.ckd[0x41] = 0; + (connPtr->TxRxCipherKeyBuf).cipher_key.ckd[0x42] = 0; + (connPtr->TxRxCipherKeyBuf).cipher_key.ckd[0x43] = 0; + add_key_to_mac(connPtr,'\x01'); + apm_sta_add(connPtr->staId); + SVar1 = (paVar3->staData).keyMgmtInfo.rom.staSecType; + (paVar3->staData).keyMgmtInfo.numHskTries = '\0'; + SVar2 = FW_SUCCESS; + if (((ushort)SVar1 & 0x20) != 0) { + (paVar3->staData).keyMgmtInfo.rom.keyMgmtState = HSK_END; + } + } + return SVar2; +} + + + +Status_e GenerateApEapolMsg(cm_ConnectionInfo_t *connPtr,keyMgmtState_e msgState, + BufferDesc_t *pBufDesc) + +{ + IEEEtypes_PwrMgmtMode_e IVar1; + uint uVar2; + Status_e SVar3; + apSpecificData_t *paVar4; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 in_register_0000202d; + + uVar2 = CONCAT31(in_register_0000202d,msgState); + paVar4 = cm_GetApData(connPtr); + if ((msgState & 1) == 0) { + uVar2 = uVar2 - 1 & 0xff; + } + IVar1 = (paVar4->staData).pwrSaveInfo.mode; + (paVar4->staData).keyMgmtInfo.rom.keyMgmtState = (keyMgmtState_e)uVar2; + if (IVar1 != PWR_MODE_PWR_SAVE) { + if (uVar2 == 1) { + SVar3 = GeneratePWKMsg1(connPtr,pBufDesc); + _SVar3 = CONCAT31(extraout_var,SVar3); + } + else { + if (uVar2 != 3) { + if (pBufDesc == (BufferDesc_t *)0x0) { + return FAIL; + } + vPortFree(pBufDesc->Buffer); + vPortFree(pBufDesc); + return FAIL; + } + SVar3 = GeneratePWKMsg3(connPtr,pBufDesc); + _SVar3 = CONCAT31(extraout_var_00,SVar3); + } + if (_SVar3 != 0) { + return (Status_e)_SVar3; + } + (paVar4->staData).keyMgmtInfo.rom.keyMgmtState = + (paVar4->staData).keyMgmtInfo.rom.keyMgmtState + MSG1_PENDING; + } + (paVar4->staData).keyMgmtInfo.numHskTries = (paVar4->staData).keyMgmtInfo.numHskTries + '\x01'; + return FW_SUCCESS; +} + + + +Status_e ProcessPWKMsg2(BufferDesc_t *pBufDesc) + +{ + cm_ConnectionInfo_t *connPtr; + EAPOL_KeyMsg_t *pKeyMsg; + Status_e SVar1; + apSpecificData_t *paVar2; + apInfo_t *paVar3; + BOOLEAN BVar4; + UINT8 *EAPOL_MIC_Key; + BOOLEAN in_fa0; + + connPtr = (cm_ConnectionInfo_t *)pBufDesc->intf; + paVar2 = cm_GetApData(connPtr); + paVar3 = cm_GetApInfo(connPtr); + pKeyMsg = (EAPOL_KeyMsg_t *)pBufDesc->Buffer; + EAPOL_MIC_Key = (paVar2->staData).keyMgmtInfo.EAPOL_MIC_Key; + KeyMgmtAp_DerivePTK((paVar3->bssConfig).RsnConfig.PSKValue, + (IEEEtypes_MacAddr_t *)connPtr->peerMacAddr, + (IEEEtypes_MacAddr_t *)(connPtr->comData).BssId, + (UINT8 *)&connPtr->TxRxCipherKeyBuf,pKeyMsg->key_nonce,EAPOL_MIC_Key, + (paVar2->staData).keyMgmtInfo.EAPOL_Encr_Key, + (KeyData_t *)((connPtr->TxRxCipherKeyBuf).cipher_key.ckd + 0x20),in_fa0); + BVar4 = IsEAPOL_MICValid(pKeyMsg,EAPOL_MIC_Key); + if (BVar4 != 0) { + (paVar2->staData).keyMgmtInfo.numHskTries = '\0'; + rsn_len = pKeyMsg[1].hdr_8021x.protocol_ver + '\x02'; + SVar1 = GenerateApEapolMsg(connPtr,MSG3_PENDING,(BufferDesc_t *)0x0); + return SVar1; + } + return FAIL; +} + + + +BOOLEAN SendEAPOLMsgUsingBufDesc(cm_ConnectionInfo_t *connPtr,BufferDesc_t *pBufDesc) + +{ + keyMgmtState_e msgState; + bool bVar1; + apSpecificData_t *paVar2; + + paVar2 = cm_GetApData(connPtr); + msgState = (paVar2->staData).keyMgmtInfo.rom.keyMgmtState; + bVar1 = (msgState & 1) != 0; + if (bVar1) { + GenerateApEapolMsg(connPtr,msgState,pBufDesc); + } + return (uint)bVar1; +} + + + +// WARNING: Variable defined which should be unmapped: rxCounterLo + +Status_e ProcessKeyMgmtDataAp(BufferDesc_t *pBufDesc) + +{ + keyMgmtState_e kVar1; + Status_e SVar2; + apSpecificData_t *paVar3; + void *pvVar4; + uint uStack24; + UINT32 rxCounterHi; + UINT32 rxCounterLo; + + paVar3 = cm_GetApData((cm_ConnectionInfo_t *)pBufDesc->intf); + pvVar4 = pBufDesc->Buffer; + if ((*(byte *)((int)pvVar4 + 5) & 4) == 0) { + memcpy(&uStack24,(void *)((int)pvVar4 + 9),4); + memcpy(&rxCounterHi,(void *)((int)pvVar4 + 0xd),4); + if (((paVar3->staData).keyMgmtInfo.counterHi == + (uStack24 >> 8 & 0xff00) + + (uStack24 & 0xff00) * 0x100 + uStack24 * 0x1000000 + (uStack24 >> 0x18)) && + ((paVar3->staData).keyMgmtInfo.counterLo == + (rxCounterHi >> 8 & 0xff00) + + rxCounterHi * 0x1000000 + (rxCounterHi >> 0x18) + (rxCounterHi & 0xff00) * 0x100)) { + kVar1 = (paVar3->staData).keyMgmtInfo.rom.keyMgmtState; + if (kVar1 == WAITING_4_MSG2) { + SVar2 = ProcessPWKMsg2(pBufDesc); + return SVar2; + } + if (kVar1 == WAITING_4_MSG4) { + SVar2 = ProcessPWKMsg4(pBufDesc); + return SVar2; + } + } + } + return FAIL; +} + + + +void InitStaKeyInfo(void *pConn,SecurityMode_t *secType,Cipher_t_conflict *pwCipher,UINT16 staRsnCap + ,UINT8 akmType) + +{ + apKeyMgmtInfoSta_t *__s; + apSpecificData_t *paVar1; + + paVar1 = cm_GetApData((cm_ConnectionInfo_t *)pConn); + __s = &(paVar1->staData).keyMgmtInfo; + memset(__s,0,0x48); + InitKeyMgmtInfo((apKeyMgmtInfoStaRom_t *)__s,secType,pwCipher,staRsnCap,akmType); + (paVar1->staData).keyMgmtInfo.EAPOLProtoVersion = '\x01'; + return; +} + + + +void RemoveAPKeyInfo(void *pConn) + +{ + if (*(uint8_t *)((int)pConn + 3) != -1) { + mm_sec_machwkey_del(*(uint8_t *)((int)pConn + 3)); + return; + } + return; +} + + + +void InitGroupKey(cm_ConnectionInfo_t *connPtr) + +{ + uint8_t uVar1; + apInfo_t *paVar2; + int iVar3; + undefined3 extraout_var; + UINT32 UVar4; + + paVar2 = cm_GetApInfo(connPtr); + (paVar2->bssData).grpRekeyBcnCntConfigured = 0; + (paVar2->bssData).grpRekeyBcnCntRemaining = 0; + KeyMgmtInit(connPtr); + UVar4 = (paVar2->bssConfig).RsnConfig.GrpReKeyTime; + if (UVar4 != 0) { + iVar3 = UVar4 * 0x1e848 + -0x7d; + __udivdi3(); + (paVar2->bssData).grpRekeyBcnCntConfigured = iVar3 + 1U; + (paVar2->bssData).grpRekeyBcnCntRemaining = iVar3 + 1U; + } + uVar1 = add_key_to_mac(connPtr,'\0'); + connPtr->gtkHwKeyId = uVar1; + printf("gtkHwKeyId is %d\r\n",CONCAT31(extraout_var,uVar1)); + return; +} + + + +// WARNING: Variable defined which should be unmapped: inp_data + +void GenerateGTK_internal(KeyData_t *grpKeyData,UINT8 *nonce,IEEEtypes_Addr_t *StaMacAddr) + +{ + size_t prefix_len; + uchar auStack140 [4]; + UINT8 prefix [20]; + UINT8 GTK [32]; + UINT8 grpMasterKey [32]; + UINT8 inp_data [38]; + + memcpy(auStack140,"Group key expansion",0x14); + if ((grpKeyData != (KeyData_t *)0x0) && (nonce != (UINT8 *)0x0)) { + memcpy(grpMasterKey + 0x1c,StaMacAddr,6); + supplicantGenerateRand(nonce,0x20); + memcpy(inp_data + 2,nonce,0x20); + supplicantGenerateRand(GTK + 0x1c,0x20); + prefix_len = strlen((char *)auStack140); + Bl_PRF(GTK + 0x1c,0x20,auStack140,prefix_len,grpMasterKey + 0x1c,0x26,prefix + 0x10,0x20); + memcpy(grpKeyData,prefix + 0x10,0x10); + memcpy(grpKeyData->TxMICKey,GTK + 0xc,8); + memcpy(grpKeyData->RxMICKey,GTK + 0x14,8); + } + return; +} + + + +void PopulateKeyMsg(EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,Cipher_t_conflict *Cipher,UINT16 Type, + UINT32 *replay_cnt,UINT8 *Nonce) + +{ + byte bVar1; + undefined2 in_register_00002032; + int iVar2; + undefined uVar3; + byte bVar4; + uint uVar5; + + uVar5 = CONCAT22(in_register_00002032,Type); + if ((tx_eapol_ptr == (EAPOL_KeyMsg_Tx_t *)0x0) || (Cipher == (Cipher_t_conflict *)0x0)) { + return; + } + if (((byte)*Cipher & 4) == 0) { + if (((byte)*Cipher & 8) != 0) { + *(undefined *)&(tx_eapol_ptr->keyMsg).key_length = 0; + uVar3 = 0x10; + goto LAB_23054a3a; + } + } + else { + *(undefined *)&(tx_eapol_ptr->keyMsg).key_length = 0; + uVar3 = 0x20; +LAB_23054a3a: + *(undefined *)((int)&(tx_eapol_ptr->keyMsg).key_length + 1) = uVar3; + } + bVar1 = *(byte *)&(tx_eapol_ptr->keyMsg).key_info.field_0x1; + *(byte *)&(tx_eapol_ptr->keyMsg).key_info.field_0x1 = bVar1 | 0x80; + if ((int)(uVar5 << 0x14) < 0) { + *(byte *)&(tx_eapol_ptr->keyMsg).key_info.field_0x1 = bVar1 | 0x88; + if ((Type & 0x80) == 0) goto LAB_23054a84; + bVar4 = *(byte *)&(tx_eapol_ptr->keyMsg).key_info; + *(byte *)&(tx_eapol_ptr->keyMsg).key_info.field_0x1 = bVar1 | 200; + bVar4 = bVar4 & 0xed | 1 | (byte)((uVar5 >> 0xf) << 1); + bVar1 = (byte)((uVar5 >> 0xf) << 4); + } + else { + bVar1 = (byte)((uVar5 >> 0xf) << 4); + bVar4 = *(byte *)&(tx_eapol_ptr->keyMsg).key_info & 0xec | 3; + } + *(byte *)&(tx_eapol_ptr->keyMsg).key_info = bVar1 | bVar4; +LAB_23054a84: + uVar5 = *replay_cnt; + iVar2 = uVar5 * 0x1000000 + (uVar5 >> 0x18) + (uVar5 & 0xff00) * 0x100 + (uVar5 >> 8 & 0xff00); + *(char *)(tx_eapol_ptr->keyMsg).replay_cnt = (char)iVar2; + *(undefined *)((int)(tx_eapol_ptr->keyMsg).replay_cnt + 1) = (char)((uint)iVar2 >> 8); + *(undefined *)((int)(tx_eapol_ptr->keyMsg).replay_cnt + 2) = (char)((uint)iVar2 >> 0x10); + *(undefined *)((int)(tx_eapol_ptr->keyMsg).replay_cnt + 3) = (char)((uint)iVar2 >> 0x18); + uVar5 = replay_cnt[1]; + iVar2 = uVar5 * 0x1000000 + (uVar5 >> 0x18) + (uVar5 & 0xff00) * 0x100 + (uVar5 >> 8 & 0xff00); + *(char *)((tx_eapol_ptr->keyMsg).replay_cnt + 1) = (char)iVar2; + *(undefined *)((int)(tx_eapol_ptr->keyMsg).replay_cnt + 5) = (char)((uint)iVar2 >> 8); + *(undefined *)((int)(tx_eapol_ptr->keyMsg).replay_cnt + 6) = (char)((uint)iVar2 >> 0x10); + *(undefined *)((int)(tx_eapol_ptr->keyMsg).replay_cnt + 7) = (char)((uint)iVar2 >> 0x18); + memcpy((tx_eapol_ptr->keyMsg).key_nonce,Nonce,0x20); + return; +} + + + +void prepareKDE(EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,KeyData_t *grKey,Cipher_t_conflict *cipher) + +{ + uint uVar1; + uint uVar2; + int iVar3; + UINT8 *pUVar4; + UINT8 *__dest; + + if (tx_eapol_ptr != (EAPOL_KeyMsg_Tx_t *)0x0) { + if ((grKey != (KeyData_t *)0x0) && (cipher != (Cipher_t_conflict *)0x0)) { + pUVar4 = (tx_eapol_ptr->keyMsg).key_data + *(byte *)&(tx_eapol_ptr->keyMsg).key_material_len; + *pUVar4 = -0x23; + pUVar4[1] = '\x16'; + pUVar4[2] = '\0'; + pUVar4[3] = '\x0f'; + pUVar4[4] = -0x54; + pUVar4[5] = '\x01'; + pUVar4[6] = pUVar4[6] & 0xfc | 1; + memcpy(pUVar4 + 8,grKey,0x10); + __dest = pUVar4 + 0x18; + if (((byte)*cipher & 4) != 0) { + pUVar4[1] = pUVar4[1] + '\x10'; + memcpy(__dest,grKey->TxMICKey,8); + memcpy(pUVar4 + 0x20,grKey->RxMICKey,8); + __dest = pUVar4 + 0x28; + } + uVar1 = (uint)(tx_eapol_ptr->keyMsg).key_material_len + 2 + (uint)pUVar4[1]; + uVar2 = uVar1 & 0xffff; + *(char *)&(tx_eapol_ptr->keyMsg).key_material_len = (char)(uVar1 * 0x10000 >> 0x10); + *(undefined *)((int)&(tx_eapol_ptr->keyMsg).key_material_len + 1) = (char)(uVar2 >> 8); + uVar1 = -uVar2 & 7; + if (uVar1 != 0) { + *__dest = -0x23; + memset(__dest + 1,0,uVar1 - 1); + iVar3 = uVar1 + (tx_eapol_ptr->keyMsg).key_material_len; + *(char *)&(tx_eapol_ptr->keyMsg).key_material_len = (char)((uint)(iVar3 * 0x10000) >> 0x10); + *(undefined *)((int)&(tx_eapol_ptr->keyMsg).key_material_len + 1) = (char)((uint)iVar3 >> 8) + ; + } + } + return; + } + return; +} + + + +BOOLEAN Encrypt_keyData(EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,UINT8 *EAPOL_Encr_Key, + Cipher_t_conflict *cipher) + +{ + void *pv; + UINT8 *cipher_00; + uint uVar1; + uint __n; + UINT8 *plain; + UINT8 aUStack48 [4]; + UINT8 key [16]; + + if (((tx_eapol_ptr != (EAPOL_KeyMsg_Tx_t *)0x0) && (EAPOL_Encr_Key != (UINT8 *)0x0)) && + (cipher != (Cipher_t_conflict *)0x0)) { + if (((byte)*cipher & 8) == 0) { + return (uint)((byte)*cipher >> 2) & 1; + } + pv = pvPortMalloc(0xc); + if (pv != (void *)0x0) { + cipher_00 = (UINT8 *)pvPortMalloc(400); + *(UINT8 **)((int)pv + 8) = cipher_00; + if (cipher_00 != (UINT8 *)0x0) { + memcpy(aUStack48,EAPOL_Encr_Key,0x10); + plain = (tx_eapol_ptr->keyMsg).key_data; + BL_AesWrap(aUStack48,'\x02',(uint)((tx_eapol_ptr->keyMsg).key_material_len >> 3),plain, + (UINT8 *)0x0,cipher_00); + uVar1 = (uint)(tx_eapol_ptr->keyMsg).key_material_len + 8; + __n = uVar1 & 0xffff; + *(char *)&(tx_eapol_ptr->keyMsg).key_material_len = (char)(uVar1 * 0x10000 >> 0x10); + *(undefined *)((int)&(tx_eapol_ptr->keyMsg).key_material_len + 1) = (char)(__n >> 8); + memcpy(plain,cipher_00,__n); + vPortFree(*(void **)((int)pv + 8)); + vPortFree(pv); + return 1; + } + } + return 0; + } + return 0; +} + + + +void KeyMgmtAp_DerivePTK(UINT8 *pPMK,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa,UINT8 *ANonce, + UINT8 *SNonce,UINT8 *EAPOL_MIC_Key,UINT8 *EAPOL_Encr_Key,KeyData_t *newPWKey + ,BOOLEAN use_kdf) + +{ + undefined auStack24 [4]; + UINT8 tmp [8]; + + KeyMgmtSta_DeriveKeys(pPMK,da,sa,ANonce,SNonce,EAPOL_MIC_Key,EAPOL_Encr_Key,newPWKey,use_kdf); + memcpy(auStack24,newPWKey->RxMICKey,8); + memcpy(newPWKey->RxMICKey,newPWKey->TxMICKey,8); + memcpy(newPWKey->TxMICKey,auStack24,8); + return; +} + + + +BOOLEAN KeyData_CopyWPAWP2(EAPOL_KeyMsg_Tx_t *pTxEAPOL,void *pIe) + +{ + size_t __n; + + if (pIe != (void *)0x0) { + __n = (uint)*(byte *)((int)pIe + 1) + 2; + *(char *)&(pTxEAPOL->keyMsg).key_material_len = (char)__n; + *(undefined *)((int)&(pTxEAPOL->keyMsg).key_material_len + 1) = (char)(__n >> 8); + memcpy((pTxEAPOL->keyMsg).key_data,pIe,__n); + return 1; + } + return 0; +} + + + +BOOLEAN KeyData_UpdateKeyMaterial + (EAPOL_KeyMsg_Tx_t *pTxEAPOL,SecurityMode_t *pSecType,void *pWPA,void *pWPA2) + +{ + BOOLEAN BVar1; + uint uVar2; + + if (((*(byte *)pSecType & 0x18) != 0) || + (uVar2 = 1, pWPA = pWPA2, (*(byte *)pSecType & 0x20) != 0)) { + BVar1 = KeyData_CopyWPAWP2(pTxEAPOL,pWPA); + uVar2 = (uint)(BVar1 != 0); + } + return uVar2; +} + + + +void ROM_InitGTK(KeyData_t *grpKeyData,UINT8 *nonce,IEEEtypes_Addr_t *StaMacAddr) + +{ + grpKeyData->TxIV32 = 0; + *(undefined4 *)&grpKeyData->TxIV16 = 0x10001; + GenerateGTK_internal(grpKeyData,nonce,StaMacAddr); + return; +} + + + +void InitKeyMgmtInfo(apKeyMgmtInfoStaRom_t *pKeyMgmtInfo,SecurityMode_t *secType, + Cipher_t_conflict *pwCipher,UINT16 staRsnCap,UINT8 akmType) + +{ + pKeyMgmtInfo->keyMgmtState = MSG1_PENDING; + memcpy(&pKeyMgmtInfo->staSecType,secType,2); + memcpy(&pKeyMgmtInfo->staUcstCipher,pwCipher,1); + pKeyMgmtInfo->staAkmType = akmType; + if ((*(byte *)secType & 0x20) != 0) { + pKeyMgmtInfo->staRsnCap = staRsnCap; + } + return; +} + + + +apInfo_t * cm_GetApInfo(cm_ConnectionInfo_t *connPtr) + +{ + if (connPtr != (cm_ConnectionInfo_t *)0x0) { + if (connPtr->conType == '\x02') { + return *(apInfo_t **)connPtr->specDat; + } + connPtr = (cm_ConnectionInfo_t *)0x0; + } + return (apInfo_t *)connPtr; +} + + + +apSpecificData_t * cm_GetApData(cm_ConnectionInfo_t *connPtr) + +{ + if (connPtr != (cm_ConnectionInfo_t *)0x0) { + if (connPtr->conType == '\x02') { + return (apSpecificData_t *)connPtr->specDat; + } + connPtr = (cm_ConnectionInfo_t *)0x0; + } + return (apSpecificData_t *)connPtr; +} + + + +Status_e cm_AllocAPResources(cm_ConnectionInfo_t *connPtr) + +{ + apSpecificData_t *paVar1; + BufferDesc_t *pBVar2; + void *pvVar3; + + paVar1 = cm_GetApData(connPtr); + if (paVar1->apInfoBuffDesc == (BufferDesc_t *)0x0) { + pBVar2 = (BufferDesc_t *)pvPortMalloc(0xc); + if (pBVar2 == (BufferDesc_t *)0x0) { + return FAIL; + } + pvVar3 = pvPortMalloc(0x120); + pBVar2->Buffer = pvVar3; + paVar1->apInfoBuffDesc = pBVar2; + paVar1->apInfo = (apInfo_t *)pBVar2->Buffer; + InitializeAp(connPtr); + } + return FW_SUCCESS; +} + + + +Status_e cm_AllocResources(cm_ConnectionInfo_t *connPtr) + +{ + Status_e SVar1; + + if (connPtr->conType == '\x02') { + SVar1 = cm_AllocAPResources(connPtr); + return SVar1; + } + return FW_SUCCESS; +} + + + +cm_ConnectionInfo_t * +cm_InitConnection(UINT8 conType,UINT8 bssType,UINT8 bssNum,IEEEtypes_MacAddr_t *bssId, + IEEEtypes_MacAddr_t *peerMacAddr,UINT8 channel,unkbyte0 *hostMdev) + +{ + cm_ConnectionInfo_t *connPtr; + Status_e SVar1; + undefined3 extraout_var; + IEEEtypes_Addr_t *__s; + + connPtr = (cm_ConnectionInfo_t *)pvPortMalloc(0xec); + if (connPtr != (cm_ConnectionInfo_t *)0x0) { + memset(connPtr,0,0xec); + connPtr->conType = conType; + SVar1 = cm_AllocResources(connPtr); + if (CONCAT31(extraout_var,SVar1) == 1) { + vPortFree(connPtr); + connPtr = (cm_ConnectionInfo_t *)0x0; + } + else { + if (peerMacAddr != (IEEEtypes_MacAddr_t *)0x0) { + memcpy(connPtr->peerMacAddr,peerMacAddr,6); + } + __s = (connPtr->comData).BssId; + memset(__s,0,6); + memset(&connPtr->comData,0,0x20); + (connPtr->comData).SsIdLen = '\0'; + if (bssId != (IEEEtypes_MacAddr_t *)0x0) { + memcpy(__s,bssId,6); + memcpy(connPtr->localMacAddr,bssId,6); + } + } + } + return connPtr; +} + + + +void cm_DeleteConnection(cm_ConnectionInfo_t *connPtr) + +{ + apSpecificData_t *paVar1; + + if (connPtr->conType == '\x02') { + paVar1 = cm_GetApData(connPtr); + if (paVar1->apInfoBuffDesc != (BufferDesc_t *)0x0) { + vPortFree(paVar1->apInfoBuffDesc->Buffer); + vPortFree(paVar1->apInfoBuffDesc); + paVar1->apInfoBuffDesc = (BufferDesc_t *)0x0; + paVar1->apInfo = (apInfo_t *)0x0; + } + } + vPortFree(connPtr); + return; +} + + + +void cm_SetPeerAddr(cm_ConnectionInfo_t *connPtr,IEEEtypes_MacAddr_t *bssId, + IEEEtypes_MacAddr_t *peerMacAddr) + +{ + if (bssId != (IEEEtypes_MacAddr_t *)0x0) { + memcpy((connPtr->comData).BssId,bssId,6); + } + if (peerMacAddr != (IEEEtypes_MacAddr_t *)0x0) { + memcpy(connPtr->peerMacAddr,peerMacAddr,6); + return; + } + return; +} + + + +void cm_SetComData(cm_ConnectionInfo_t *connPtr,char *ssid) + +{ + byte bVar1; + size_t sVar2; + + if (ssid != (char *)0x0) { + sVar2 = strlen(ssid); + (connPtr->comData).SsIdLen = (IEEEtypes_Len_t)sVar2; + memcpy(&connPtr->comData,ssid,0x20); + bVar1 = (connPtr->comData).SsIdLen; + if (bVar1 < 0x20) { + (connPtr->comData).SsId[bVar1] = '\0'; + } + return; + } + return; +} + + +/* +Unable to decompile 'assert_rec' +Cause: Exception while decompiling 23054fb4: Decompiler process died + +*/ + + +void assert_err(char *condition,char *file,int line) + +{ + do { + // WARNING: Do nothing block with infinite loop + } while( true ); +} + + + +void assert_warn(char *condition,char *file,int line) + +{ + return; +} + + + +void coex_wifi_rf_forece_enable(int enable) + +{ + if (enable != 0) { + enable = 1; + } + rfc_coex_force_to(enable,0); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void coex_wifi_pti_forece_enable(int enable) + +{ + if (enable == 0) { + _DAT_44b00400 = _DAT_44b00400 & 0xffffffef; + } + else { + _DAT_44b00400 = _DAT_44b00400 | 0xf0000010; + } + if ((int)(_DAT_44b00400 << 4) < 0) { + _DAT_44b00400 = _DAT_44b00400 & 0xfbffffff; + } + else { + _DAT_44b00400 = _DAT_44b00400 & 0xfbffffff | 0x4000000; + } + return; +} + + +/* +Unable to decompile 'coex_wifi_pta_forece_enable' +Cause: Exception while decompiling 23055054: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void wifi_main(void) + +{ + int iVar1; + uint uVar2; + + rfc_init(40000000); + _DAT_44b00400 = _DAT_44b00400 | 1; + mpif_clk_init(); + sysctrl_init(); + intc_init(); + ipc_emb_init(); + bl_init(); + _DAT_44b00404 = 0x24f037; + _DAT_44b00400 = 0x49; + _DAT_44920004 = 0x5010001f; + do { + if (_DAT_44b00120 << 0xc < 0) { + _DAT_44900084 = _DAT_44900084 | 1; + } + else { + _DAT_44900084 = _DAT_44900084 & 0xfffffffe; + } + if (ke_env.evt_field == 0) { + ipc_emb_wait(); + } + if ((packets_num_12624 & 0xf) == 0) { + uVar2 = _DAT_40007018 >> 0x18 & 7; + if (uVar2 != 0) { + if (uVar2 != 3) { + _DAT_40000014 = _DAT_40000014 | 0x40000; + } + if ((uVar2 != 0) && (uVar2 != 3)) { + _DAT_40002040 = _DAT_40002040 & 0xfffffffc; + _DAT_40002044 = _DAT_40002044 & 0xfffffffe; + } + } + if ((_DAT_40007018 >> 0x18 & 4) != 0) { + _DAT_40000014 = _DAT_40000014 | 0x5c2000; + _DAT_4000f90c = _DAT_4000f90c & 0xfffffffe | 4; + } + } + packets_num_12624 = packets_num_12624 + 1; + ke_evt_schedule(); + iVar1 = bl_sleep(); + coex_wifi_pta_forece_enable((uint)(iVar1 == 0)); + } while( true ); +} + + + +void ipc_emb_notify(void) + +{ + BaseType_t BStack20; + BaseType_t xHigherPriorityTaskWoken; + + if (xTaskToNotify == (TaskHandle_t)0x0) { + assert_err("NULL != xTaskToNotify","module",0x93); + } + if (TrapNetCounter == 0) { + xTaskGenericNotify(xTaskToNotify,0,eIncrement,(uint32_t *)0x0); + } + else { + vTaskNotifyGiveFromISR(xTaskToNotify,&BStack20); + if (BStack20 != 0) { + vTaskSwitchContext(); + } + } + return; +} + + + +void ipc_emb_wait(void) + +{ + ulTaskNotifyTake(1,0xffffffff); + ipc_emb_counter = ipc_emb_counter + 1; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_init(void) + +{ + xTaskToNotify = xTaskGetCurrentTaskHandle(); + memset(&ipc_emb_env,0,0x20); + ipc_emb_env.txdesc = (txdesc_host *)ipc_shared_env.txdesc0; + if (_DAT_44800140 != 0x49504332) { + assert_err("ipc_emb_signature_get() == IPC_EMB_SIGNATURE_RESET","module",0xbb); + } + _DAT_4480010c = 0x1f03; + _DAT_44800114 = 0x3ff2a04; + _DAT_44800118 = 0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_tx_irq(void) + +{ + uint uVar1; + + uVar1 = _DAT_4480011c & 0x1f00; + if (uVar1 != 0) { + ke_evt_set(uVar1 >> 1); + _DAT_44800108 = uVar1; + _DAT_44800110 = uVar1; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_tx_evt(int queue_idx) + +{ + txdesc_host *ptVar1; + txdesc_host *ptVar2; + hostdesc *phVar3; + hostdesc *phVar4; + uint event; + hostdesc *__s; + + event = ipc_emb_evt_bit[queue_idx]; + ke_evt_clear(event); + ptVar1 = ipc_emb_env.txdesc; + while( true ) { + ptVar2 = ptVar1 + (ipc_emb_env.txdesc_idx & 3); + if (ptVar2->ready != 0xffffffff) { + _DAT_4480010c = 0x100; + return; + } + if (((event & 0x800) == 0) && ((ke_env.evt_field & 0x440800) != 0)) break; + __s = (hostdesc *)ptVar2->pad_txdesc; + _DAT_44800108 = 0x100; + memset(__s,0,0x2cc); + *(uint32_t **)(ptVar2->pad_txdesc + 0x1c) = ptVar2->pad_txdesc + 0x2e; + *(uint32_t **)(ptVar2->pad_txdesc + 0x1b) = ptVar2->pad_txdesc + 0x1c; + phVar3 = &ptVar2->host; + do { + phVar4 = (hostdesc *)&phVar3->packet_addr; + phVar3[1].packet_addr = phVar3->pbuf_addr; + phVar3 = phVar4; + } while (__s != phVar4); + ptVar2->pad_txdesc[0x19] = 0; + *(undefined4 *)(*(int *)ptVar2->pad_txdesc[0x1b] + 0x10) = 0; + ptVar2->pad_txdesc[0x27] = 0; + ptVar2->pad_txdesc[0x28] = 0; + ptVar2->pad_txdesc[0x29] = 0; + ptVar2->pad_txdesc[0x15] = 0; + txu_cntrl_push(__s,0); + ptVar2->ready = 1; + ipc_emb_env.txdesc_idx = ipc_emb_env.txdesc_idx + 1; + } + ke_evt_set(event); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_cfmback_irq(void) + +{ + uint uVar1; + + uVar1 = _DAT_4480011c; + if ((_DAT_4480011c & 0x20) != 0) { + _DAT_44800110 = 0x20; + _DAT_44800108 = 0x20; + ke_evt_set(0x40000); + } + if ((uVar1 & 0x10) != 0) { + _DAT_44800110 = 0x10; + _DAT_44800108 = 0x10; + ke_evt_set(0x80000); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_txcfm_ind(uint32_t queue_bits) + +{ + _DAT_44800100 = queue_bits << 7; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_msg_irq(void) + +{ + if ((_DAT_4480011c & 2) != 0) { + ke_evt_set(0x2000000); + _DAT_44800110 = 2; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_msg_evt(void) + +{ + undefined4 *puVar1; + uint8_t uVar2; + undefined4 *puVar3; + undefined4 *puVar4; + int iVar5; + + do { + if ((_DAT_44800104 & 2) == 0) { + ke_evt_clear(0x2000000); + _DAT_4480010c = 2; + return; + } + _DAT_44800108 = 2; + puVar1 = (undefined4 *)ke_malloc((uint)ipc_shared_env.msg_a2e_buf.msg[1]._2_2_ + 0xc); + if (puVar1 == (undefined4 *)0x0) { + assert_err("kmsg_dst != NULL","module",0x1d9); + } + *puVar1 = 0; + *(undefined2 *)(puVar1 + 1) = (undefined2)ipc_shared_env.msg_a2e_buf.msg[0]; + *(undefined2 *)((int)puVar1 + 6) = ipc_shared_env.msg_a2e_buf.msg[0]._2_2_; + *(undefined2 *)(puVar1 + 2) = 0xd; + *(ushort *)((int)puVar1 + 10) = ipc_shared_env.msg_a2e_buf.msg[1]._2_2_; + iVar5 = 0xc; + while (iVar5 + -0xc < (int)(uint)*(ushort *)((int)puVar1 + 10)) { + puVar3 = (undefined4 *)((int)&ipc_shared_env.msg_a2e_buf.dummy_word + iVar5); + puVar4 = (undefined4 *)((int)puVar1 + iVar5); + iVar5 = iVar5 + 4; + *puVar4 = *puVar3; + } + uVar2 = ipc_emb_env.ipc_msgacke2a_cnt + '\x01'; + ipc_shared_env.msg_a2e_buf.msg[1]._0_2_ = (ushort)ipc_emb_env.ipc_msgacke2a_cnt; + ipc_emb_env.ipc_msgacke2a_cnt = uVar2; + if (*(ushort *)((int)puVar1 + 6) < 0xf) { + if (0xc < *(ushort *)((int)puVar1 + 6)) goto LAB_230556b8; + } + else { + assert_err("id <= TASK_MAX","module",0xb6); +LAB_230556b8: + assert_err("ke_task_local(kmsg_dst->dest_id)","module",0x1ed); + } + _DAT_44800100 = 4; + ke_msg_send(puVar1 + 3); + } while( true ); +} + + + +void ipc_emb_msg_dma_int_handler(void) + +{ + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ipc_emb_dbg_dma_int_handler(void) + +{ + _DAT_44800100 = 1; + _DAT_44a00020 = 0x80; + return; +} + + + +void ipc_emb_dump(void) + +{ + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mdm_txcbwmax_setf(uint8_t txcbwmax) + +{ + if ((txcbwmax & 0xfc) != 0) { + assert_err("(((uint32_t)txcbwmax << 24) & ~((uint32_t)0x03000000)) == 0","module",0xb58); + } + _DAT_44c00824 = _DAT_44c00824 & 0xfcffffff | (uint)txcbwmax << 0x18; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void phy_config_rxgain(int offset) + +{ + if ((int)rxgain_offset_vs_temperature != offset) { + rxgain_offset_vs_temperature = (int8_t)offset; + _DAT_44c0c080 = + ((int)rxgain_offset_vs_temperature + 0x19) * 0x1000000 | + ((int)rxgain_offset_vs_temperature + 0x12) * 0x10000 & 0xff0000U | + ((int)rxgain_offset_vs_temperature + 0xb) * 0x100 & 0xffffU | + (int)rxgain_offset_vs_temperature + 3U & 0xff; + _DAT_44c0c084 = + ((int)rxgain_offset_vs_temperature + 0x35) * 0x1000000 | + ((int)rxgain_offset_vs_temperature + 0x2d) * 0x10000 & 0xff0000U | + ((int)rxgain_offset_vs_temperature + 0x27) * 0x100 & 0xffffU | + (int)rxgain_offset_vs_temperature + 0x20U & 0xff; + _DAT_44c0c088 = (int)rxgain_offset_vs_temperature + 0x3bU & 0xff | _DAT_44c0c088 & 0xffffff00; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void agc_config(void) + +{ + _DAT_44c0b390 = _DAT_44c0b390 & 0xfffefbff; + _DAT_44c0b3a4 = _DAT_44c0b3a4 & 0xffff0000; + _DAT_44c0b394 = _DAT_44c0b394 & 0xff00ffff | 0xf80000; + _DAT_44c0b398 = _DAT_44c0b398 & 0xffff00ff | 0x9e00; + _DAT_44c0b3c4 = _DAT_44c0b3c4 & 0xffffff00 | 0xce; + _DAT_44c0b364 = _DAT_44c0b364 & 0xe0c0c0c0 | 0x83c3839; + _DAT_44c0b368 = _DAT_44c0b368 & 0xffc00c00 | 0x70070; + _DAT_44c0b36c = _DAT_44c0b36c & 0xf800f800 | 0x7280512; + _DAT_44c0b370 = _DAT_44c0b370 & 0xff80ffff | 0x580000; + _DAT_44c0b3c0 = _DAT_44c0b3c0 & 0xffffff | 0x18000000; + _DAT_44c0b380 = _DAT_44c0b380 & 0x3ff | 0x77f8400; + _DAT_44c0b384 = _DAT_44c0b384 & 0x3ff | 0xe7750800; + _DAT_44c0b388 = _DAT_44c0b388 & 0x3ff | 0x3d7a9400; + _DAT_44c0b38c = _DAT_44c0b38c & 0x23ff | 0x64038800; + _DAT_44c0c830 = _DAT_44c0c830 & 0x23ff | 0xfc1d9400; + _DAT_44c0c814 = _DAT_44c0c814 & 0xffffffc0 | 8; + _DAT_44c0c040 = _DAT_44c0c040 & 0xfe007fff | 0xc18000; + _DAT_44c0c044 = _DAT_44c0c044 & 0xffff0000 | 0x800; + phy_config_rxgain(0); + _DAT_44c0b3a0 = _DAT_44c0b3a0 & 0xffffff00 | 0x9e; + _DAT_44c0b3c0 = _DAT_44c0b3c0 & 0xffff0000 | 0xa3a4; + _DAT_44c0c82c = _DAT_44c0c82c & 0xff007700 | 0x2009b5; + _DAT_44c0c838 = _DAT_44c0c838 & 0x7ff80000 | 0x80000100; + _DAT_44c0c83c = _DAT_44c0c83c & 0x7ff00000 | 0x8000017c; + _DAT_44c0c840 = _DAT_44c0c840 & 0x7fc00000 | 0x80000100; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mdm_reset(void) + +{ + _DAT_44c00888 = 0; + return; +} + + + +void phy_powroffset_set(int8_t *power_offset) + +{ + int8_t *piVar1; + int8_t *piVar2; + int iVar3; + + iVar3 = 0; + do { + piVar1 = power_offset + iVar3; + piVar2 = poweroffset + iVar3; + iVar3 = iVar3 + 1; + *piVar2 = *piVar1; + } while (iVar3 != 0xe); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void phy_hw_set_channel(uint8_t band,uint16_t freq,uint16_t freq1,uint8_t chantype) + +{ + uint8_t channel; + undefined3 in_register_00002029; + int iVar1; + undefined2 in_register_0000202e; + int iVar2; + undefined3 in_register_00002035; + + iVar2 = CONCAT22(in_register_0000202e,freq); + iVar1 = CONCAT31(in_register_00002029,band); + if (CONCAT31(in_register_00002035,chantype) != 0) { + assert_err("chantype == PHY_CHNL_BW_20","module",0x144); + } + if (iVar1 != 0) { + assert_err("band == PHY_BAND_2G4","module",0x145); + } + _DAT_44c0b390 = _DAT_44c0b390 & 0xfffffeff; + _DAT_44c00820 = _DAT_44c00820 | 1; + _DAT_44c00800 = 0; + mdm_reset(); + _DAT_44c00838 = 0xb4; + _DAT_44c0088c = 0x1c13; + _DAT_44c00898 = 0x2d00438; + _DAT_44c00858 = _DAT_44c00858 & 0xffffff00; + _DAT_44c0081c = 0xf07; + _DAT_44c00834 = _DAT_44c00834 & 0xffffff | 0x6000000; + _DAT_44c00818 = 0x1880c06; + _DAT_44c00860 = 0x7f03; + _DAT_44c0b340 = 0; + _DAT_44c0b344 = 0; + _DAT_44c0b348 = 0; + mdm_txcbwmax_setf(chantype); + if (_DAT_44c0b000 << 10 < 0) { + _DAT_44c0b118 = 1; + } + rf_set_channel(chantype,freq1); + if (iVar1 == 0) { + channel = '\0'; + if ((0x48 < (iVar2 - 0x96cU & 0xffff)) || (channel = '\x0e', iVar2 == 0x9b4)) goto LAB_23055e36; + iVar1 = -0x967; + } + else { + channel = '\0'; + if ((iVar1 != 1) || (channel = '\0', 0x334 < (iVar2 - 0x138dU & 0xffff))) goto LAB_23055e36; + iVar1 = -5000; + } + channel = (uint8_t)((iVar2 + iVar1) / 5); +LAB_23055e36: + rfc_apply_tx_power_offset(channel,poweroffset); + trpc_update_vs_channel((int8_t)freq1); + return; +} + + + +void phy_get_channel(phy_channel_info *info,uint8_t index) + +{ + info->info1 = (uint)phy_env[0].chnl_type << 8 | (uint)phy_env[0].chnl_prim20_freq << 0x10 | + (uint)phy_env[0].band; + info->info2 = phy_env[0]._6_4_; + return; +} + + + +void phy_set_channel(uint8_t band,uint8_t type,uint16_t prim20_freq,uint16_t center1_freq, + uint16_t center2_freq,uint8_t index) + +{ + undefined3 in_register_00002029; + + if ((((ushort)(center1_freq - 0x96c) < 0x49) || (CONCAT31(in_register_00002029,band) != 0)) && + (CONCAT31(in_register_00002029,band) < 2)) { + phy_hw_set_channel(band,prim20_freq,center1_freq,type); + phy_env[0].chnl_prim20_freq = prim20_freq; + phy_env[0].chnl_center1_freq = center1_freq; + phy_env[0].band = band; + phy_env[0].chnl_type = type; + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void phy_get_version(uint32_t *version_1,uint32_t *version_2) + +{ + *version_1 = _DAT_44c00000; + *version_2 = 0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +_Bool phy_vht_supported(void) + +{ + byte bVar1; + + bVar1 = 1; + if (-1 < _DAT_44c00000 << 9) { + bVar1 = (byte)((uint)_DAT_44c00000 >> 0x19) & 1; + } + return (_Bool)bVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void phy_init(phy_cfg_tag *config) + +{ + uint uVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 extraout_var_00; + uint32_t uVar3; + uint32_t *puVar4; + uint32_t *puVar5; + uint32_t *puVar6; + + _DAT_44c00800 = 0; + mdm_reset(); + _DAT_44c00820 = 0x20d; + uVar1 = ((_DAT_44c00000 >> 8 & 0xf) - 1 & 0xff) << 4; + if ((uVar1 & 0xffffff8f) != 0) { + assert_err("(((uint32_t)rxnssmax << 4) & ~((uint32_t)0x00000070)) == 0","module",0xa09); + } + _DAT_44c00820 = uVar1 | _DAT_44c00820 & 0xffffff8f; + uVar1 = ((_DAT_44c00000 >> 0xc & 0xf) - 1 & 0xff) << 0xc; + if ((uVar1 & 0xf8000) != 0) { + assert_err("(((uint32_t)rxndpnstsmax << 12) & ~((uint32_t)0x00007000)) == 0","module",0x987); + } + _DAT_44c00820 = _DAT_44c00000 >> 0x13 & 0x100 | uVar1 | _DAT_44c00820 & 0xffff8eff; + _Var2 = phy_vht_supported(); + _DAT_44c00820 = + (_DAT_44c00000 >> 0x1e & 1) << 0x14 | + (_DAT_44c00000 >> 0x1e & 1) << 0x10 | + (CONCAT31(extraout_var,_Var2) << 1 | _DAT_44c00820 & 0xfffffffd) & 0xffeeffff; + _DAT_44c03024 = _DAT_44c03024 & 0xffc0ffff | 0x2d0000; + _DAT_44c0089c = 0xffffffff; + _DAT_44c00824 = 0x20d; + uVar1 = ((_DAT_44c00000 >> 8 & 0xf) - 1 & 0xff) << 4; + if ((uVar1 & 0xffffff8f) != 0) { + assert_err("(((uint32_t)txnssmax << 4) & ~((uint32_t)0x00000070)) == 0","module",0xc0e); + } + _DAT_44c00824 = uVar1 | _DAT_44c00824 & 0xffffff8f; + uVar1 = ((_DAT_44c00000 >> 4 & 0xf) - 1 & 0xff) << 0x14; + if ((uVar1 & 0xf800000) != 0) { + assert_err("(((uint32_t)ntxmax << 20) & ~((uint32_t)0x00700000)) == 0","module",0xb72); + } + _DAT_44c00824 = uVar1 | _DAT_44c00824 & 0xff8fffff; + mdm_txcbwmax_setf((byte)(_DAT_44c00000 >> 0x18) & 3); + _DAT_44c00824 = _DAT_44c00000 >> 0x12 & 0x100 | _DAT_44c00824 & 0xfffffeff; + _Var2 = phy_vht_supported(); + _DAT_44c00824 = + (_DAT_44c00000 >> 0x1f) << 0x10 | + (CONCAT31(extraout_var_00,_Var2) << 1 | _DAT_44c00824 & 0xfffffffd) & 0xfffeffff; + _DAT_44c00834 = _DAT_44c00834 | 1; + _DAT_44c00818 = _DAT_44c00818 & 0xfffbffff; + _DAT_44c00830 = _DAT_44c00830 & 0xffff0000 | 0x1b0f; + _DAT_44c0083c = 0x4920492; + _DAT_44c00874 = _DAT_44c00874 & 0xf7ffffff | 0x8000000; + _DAT_44c0b500 = _DAT_44c0b500 & 0xffffcfff | 0x2000; + if (_DAT_44c0b000 << 10 < 0) { + _DAT_44c0b110 = _DAT_44c0b110 & 0xfffffff0; + _DAT_44c0b118 = 0; + } + _DAT_44c0b004 = 1; + _DAT_44c0b390 = _DAT_44c0b390 & 0xfffffffc | 1; + _DAT_44c0b3bc = 4000000; + _DAT_44c0b414 = _DAT_44c0b414 | 0x100; + agc_config(); + _DAT_44c0b390 = _DAT_44c0b390 & 0xffffefff | 0x1000; + _DAT_44c00874 = _DAT_44c00874 & 0xdfffffff | 0x20000000; + puVar6 = agcmem; + puVar4 = (uint32_t *)&DAT_54c0a000; + do { + uVar3 = *puVar6; + puVar5 = puVar4 + 1; + puVar6 = puVar6 + 1; + *puVar4 = uVar3; + puVar4 = puVar5; + } while (puVar5 != (uint32_t *)0x54c0a800); + _DAT_44c00874 = _DAT_44c00874 & 0xdfffffff; + _DAT_44c0b390 = _DAT_44c0b390 & 0xffffefff; + _DAT_44c0c020 = _DAT_44c0c020 & 0xfc00ffff | 0x140000; + phy_env[0].cfg = config->parameters[0]; + phy_env[0]._4_4_ = 0xff00ff; + phy_env[0]._8_4_ = 0x50000ff; + trpc_init(); + pa_init(); + phy_tcal_reset(); + phy_tcal_start(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t phy_get_nss(void) + +{ + return (uint8_t)(((byte)((uint)_DAT_44c00000 >> 8) & 0xf) - 1); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t phy_get_ntx(void) + +{ + return (uint8_t)(((byte)(_DAT_44c00000 >> 4) & 0xf) - 1); +} + + + +void phy_stop(void) + +{ + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +_Bool phy_ldpc_tx_supported(void) + +{ + return (_Bool)((byte)((uint)_DAT_44c00000 >> 0x1a) & 1); +} + + + +uint8_t phy_get_mac_freq(void) + +{ + return '('; +} + + + +void phy_get_rf_gain_idx(int8_t *power,uint8_t *idx) + +{ + uint32_t uVar1; + + uVar1 = rfc_get_power_level(2,(int)*power * 10); + *idx = (uint8_t)uVar1; + return; +} + + + +void phy_get_rf_gain_capab(int8_t *max,int8_t *min) + +{ + int8_t iVar1; + + iVar1 = trpc_get_rf_max_power(); + *max = iVar1; + iVar1 = trpc_get_rf_min_power(); + *min = iVar1; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void bz_phy_reset(void) + +{ + _DAT_40002808 = _DAT_40002808 & 0x7fffff | 0x8800000; + _DAT_4000280c = _DAT_4000280c & 0x7fff00 | 0x4800000; + _DAT_40002810 = _DAT_40002810 & 0xfffffffe | 2; + _DAT_40002854 = 0x1e0a201e; + _DAT_40002cac = _DAT_40002cac & 0xffffffe0 | 4; + return; +} + + + +void mpif_clk_init(void) + +{ + return; +} + + + +void phy_mdm_isr(void) + +{ + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void phy_rc_isr(void) + +{ + _DAT_44c0b420 = _DAT_44c0b41c; + if ((_DAT_44c0b41c & 0x100) != 0) { + mdm_reset(); + return; + } + _DAT_44c0b420 = _DAT_44c0b41c; + return; +} + + + +void pa_init(void) + +{ + int iVar1; + pa_state_t *ppVar2; + pa_state_t *ppVar3; + + ppVar3 = pa_env; + do { + ppVar3->rss_state = '\0'; + ppVar3->rss_count = 0; + ppVar3->last_update = 0; + ppVar3->input_buffer_ptr = '\0'; + ppVar3->ce_state = '\0'; + ppVar3->ce = 0.00000000; + ppVar3->ce_num_up_cmds = '\0'; + ppVar3->ce_num_dn_cmds = '\0'; + iVar1 = 8; + ppVar2 = ppVar3; + do { + ppVar2->input_buffer[0].new = '\0'; + ppVar2->input_buffer[0].rssi = '\0'; + ppVar2->input_buffer[0].lna = '\0'; + ppVar2->input_buffer[0].ppm = 0.00000000; + iVar1 = iVar1 + -1; + ppVar2 = (pa_state_t *)&ppVar2->input_buffer[0].ppm; + } while (iVar1 != 0); + ppVar3 = ppVar3 + 1; + } while (ppVar3 != (pa_state_t *)&tcal_env); + return; +} + + + +// WARNING: Control flow encountered bad instruction data + +void pa_input(uint8_t id,rx_hd *rhd) + +{ + undefined3 in_register_00002029; + uint uVar1; + int iVar2; + + uVar1 = CONCAT31(in_register_00002029,id); + if (uVar1 < 4) { + iVar2 = (int)pa_env[uVar1].input_buffer_ptr; + pa_env[uVar1].last_update = rhd->tsflo; + pa_env[uVar1].input_buffer[iVar2].new = '\x01'; + pa_env[uVar1].input_buffer[iVar2].rssi = *(int8_t *)((int)&rhd->recvec1c + 3); + pa_env[uVar1].input_buffer[iVar2].lna = (char)((int)(rhd->recvec1d << 0x14) >> 0x1c); + if (((rhd->recvec1b & 0x70000) == 0) && ((rhd->recvec1a >> 0xc & 0xf) < 4)) { + __floatsidf((int)*(char *)((int)&rhd->recvec2a + 3)); + __muldf3(); + } + else { + __floatsidf(-(int)*(short *)((int)&rhd->recvec2a + 3)); + __muldf3(); + __divdf3(); + } + __truncdfsf2(); + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); + } + return; +} + + +/* +Unable to decompile 'pa_adapt' +Cause: Exception while decompiling 23056596: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t hal_get_capcode(void) + +{ + return (uint8_t)((byte)(_DAT_4000f884 >> 0x16) & 0x3f); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_set_capcode(uint32_t capcode) + +{ + _DAT_4000f884 = capcode << 0x10 | capcode << 0x16 | _DAT_4000f884 & 0xf000ffff; + return; +} + + + +_Bool hal_get_temperature(int16_t *temperature) + +{ + *temperature = hal_env.temperature; + return true; +} + + + +void hal_set_temperature(int16_t temperature) + +{ + hal_env.temperature = temperature; + return; +} + + + +void trpc_update_power(int8_t (*power_rate_table) [8]) + +{ + int iVar1; + int iVar2; + int iVar3; + int8_t *piVar4; + int8_t *piVar5; + + piVar4 = txpwr_vs_rate_table; + iVar2 = 0; + do { + iVar3 = 0; + do { + iVar1 = iVar3 + iVar2; + piVar5 = piVar4 + iVar3; + iVar3 = iVar3 + 1; + *piVar5 = (*power_rate_table)[iVar1]; + } while (iVar3 != 8); + iVar2 = iVar2 + 8; + piVar4 = piVar4 + 8; + } while (iVar2 != 0x18); + return; +} + + + +void trpc_power_get(int8_t *power_rate_table) + +{ + memcpy(power_rate_table,txpwr_vs_rate_table,0x18); + return; +} + + + +void trpc_update_power_11b(int8_t *power_rate_table) + +{ + int8_t *piVar1; + int8_t *piVar2; + int iVar3; + + iVar3 = 0; + do { + piVar1 = power_rate_table + iVar3; + piVar2 = txpwr_vs_rate_table + iVar3; + iVar3 = iVar3 + 1; + *piVar2 = *piVar1; + } while (iVar3 != 4); + return; +} + + + +void trpc_update_power_11g(int8_t *power_rate_table) + +{ + int8_t *piVar1; + int iVar2; + int8_t *piVar3; + + iVar2 = 0; + piVar3 = txpwr_vs_rate_table; + do { + piVar1 = power_rate_table + iVar2; + iVar2 = iVar2 + 1; + piVar3[8] = *piVar1; + piVar3 = piVar3 + 1; + } while (iVar2 != 8); + return; +} + + + +void trpc_update_power_11n(int8_t *power_rate_table) + +{ + int8_t *piVar1; + int iVar2; + int8_t *piVar3; + + iVar2 = 0; + piVar3 = txpwr_vs_rate_table; + do { + piVar1 = power_rate_table + iVar2; + iVar2 = iVar2 + 1; + piVar3[0x10] = *piVar1; + piVar3 = piVar3 + 1; + } while (iVar2 != 8); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void trpc_init(void) + +{ + int32_t iVar1; + + DAT_4201e240 = 0x98a; + iVar1 = rf_pri_get_txgain_max(); + trpc_env = (undefined)iVar1; + iVar1 = rf_pri_get_txgain_min(); + pwr_dbm_bottom = (int8_t)iVar1; + DAT_4201e23e = 0x1e; + _DAT_4201e242 = 0x19; + return; +} + + + +int8_t trpc_get_rf_max_power(void) + +{ + return trpc_env; +} + + + +int8_t trpc_get_rf_min_power(void) + +{ + return pwr_dbm_bottom; +} + + + +uint8_t trpc_get_power_idx(uint8_t formatmod,uint8_t mcs,int8_t pwr_dbm) + +{ + int8_t pwr_dbm_bottom; + undefined3 in_register_00002029; + uint uVar1; + undefined3 in_register_0000202d; + int iVar2; + undefined3 in_register_00002031; + char cVar3; + uint uVar4; + char cVar5; + int iVar6; + + uVar1 = CONCAT31(in_register_00002029,formatmod); + uVar4 = 2; + if (uVar1 < 3) { + uVar4 = (uint)formatmod; + } + iVar6 = 3; + if (uVar1 != 0) { + iVar6 = 7; + } + cVar5 = DAT_4201e23e; + if ((int)trpc_env < (int)DAT_4201e23e) { + cVar5 = trpc_env; + } + if (CONCAT31(in_register_00002031,pwr_dbm) < (int)cVar5) { + cVar5 = pwr_dbm; + } + iVar2 = CONCAT31(in_register_0000202d,mcs); + if (iVar6 < CONCAT31(in_register_0000202d,mcs)) { + iVar2 = iVar6; + } + cVar3 = txpwr_vs_rate_table[iVar2 + uVar4 * 8]; + if (cVar5 < txpwr_vs_rate_table[iVar2 + uVar4 * 8]) { + cVar3 = cVar5; + } + if (pwr_dbm_bottom < cVar3) { + pwr_dbm_bottom = cVar3; + } + __floatsidf(((int)pwr_dbm_bottom * -0x1fe + (int)trpc_env) / 0x200); + __adddf3(); + uVar4 = __fixdfsi(); + iVar6 = 3; + if (uVar1 != 0) { + iVar6 = 0; + } + uVar4 = iVar6 + (uVar4 & 0xff) & 0xff; + if (0xf < uVar4) { + uVar4 = 0xf; + } + return (uint8_t)(uVar4 << 2); +} + + + +uint8_t trpc_get_default_power_idx(uint8_t formatmod,uint8_t mcs) + +{ + uint8_t uVar1; + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + int iVar2; + uint uVar3; + int iVar4; + + uVar3 = (uint)formatmod; + if (2 < CONCAT31(in_register_00002029,formatmod)) { + uVar3 = 2; + } + iVar4 = 3; + if (CONCAT31(in_register_00002029,formatmod) != 0) { + iVar4 = 7; + } + iVar2 = CONCAT31(in_register_0000202d,mcs); + if (iVar4 < CONCAT31(in_register_0000202d,mcs)) { + iVar2 = iVar4; + } + uVar1 = trpc_get_power_idx((uint8_t)uVar3,(uint8_t)iVar2,txpwr_vs_rate_table[iVar2 + uVar3 * 8]); + return uVar1; +} + + + +void trpc_update_vs_channel(int8_t channel_MHz) + +{ + undefined3 in_register_00002029; + int32_t iVar1; + + DAT_4201e240 = (undefined2)CONCAT31(in_register_00002029,channel_MHz); + iVar1 = rf_pri_get_txgain_max(); + trpc_env = (undefined)iVar1; + iVar1 = rf_pri_get_txgain_min(); + pwr_dbm_bottom = (int8_t)iVar1; + return; +} + + + +void trpc_update_vs_temperature(int8_t temperature) + +{ + int32_t iVar1; + + DAT_4201e242 = temperature; + iVar1 = rf_pri_get_txgain_max(); + trpc_env = (undefined)iVar1; + iVar1 = rf_pri_get_txgain_min(); + pwr_dbm_bottom = (int8_t)iVar1; + return; +} + + + +void phy_tcal_reset(void) + +{ + memset(&tcal_env,0,0x38); + tcal_env.prev_temperature = 0x19; + tcal_env.last_action_temperature[0] = 0x19; + tcal_env.last_action_temperature[1] = 0x19; + tcal_env.last_action_temperature[2] = 0x19; + tcal_env.last_action_temperature[3] = 0x19; + tcal_env.enabled = true; + return; +} + + + +void phy_tcal_start(void) + +{ + tcal_env.enabled = true; + return; +} + + + +void phy_tcal_txpwr(int16_t curr_temperature) + +{ + undefined2 in_register_0000202a; + + rf_pri_tx_gain_comp(CONCAT22(in_register_0000202a,curr_temperature)); + trpc_update_vs_temperature((int8_t)curr_temperature); + return; +} + + +/* +Unable to decompile 'phy_tcal_handle' +Cause: Exception while decompiling 23056b44: Decompiler process died + +*/ + + +void phy_tcal_callback(int16_t temperature) + +{ + hal_set_temperature(temperature); + if (tcal_env.enabled != false) { + phy_tcal_handle(); + return; + } + return; +} + + + +int bl60x_check_mac_status(int *is_ok) + +{ + int iVar1; + dump_data_t *pdVar2; + + iVar1 = 0; + pdVar2 = dump_data_poll; + while( true ) { + if ((int)(uint)dump_data_ptr <= iVar1) { + *is_ok = 0; + return 0; + } + if (pdVar2->mac_debugRegHWSM2 != 0x8801e000) break; + iVar1 = iVar1 + 1; + pdVar2 = pdVar2 + 1; + } + *is_ok = 1; + return 0; +} + + + +void helper_record_dump(void) + +{ + uint32_t *puVar1; + dump_data_t *pdVar2; + int iVar3; + + pdVar2 = dump_data_poll; + puts("========= helper_record_dump\r\n"); + iVar3 = 0; + while (iVar3 < (int)(uint)dump_data_ptr) { + printf("[%d] time %ld, func %s\r\n",iVar3,pdVar2->time,pdVar2->func_name); + printf("MAC: %08lx: rxControlCs %d,txControlCs %d,macControlCs %d\r\n",pdVar2->mac_debugRegHWSM2 + ,pdVar2->mac_debugRegHWSM2 & 0x3f,pdVar2->mac_debugRegHWSM2 >> 8 & 0x1ff, + (uint)*(byte *)((int)&pdVar2->mac_debugRegHWSM2 + 3)); + iVar3 = iVar3 + 1; + printf("MAC: Coex %04x,Backoff %04x,MPIF %04x,MPIF2 %04x\r\n",(uint)pdVar2->mac_debugPortCoex, + (uint)pdVar2->mac_debugPortBackoff,(uint)pdVar2->mac_debugPortMacPhyIf, + (uint)pdVar2->mac_debugPortMacPhyIf2); + printf("PHY: MainFSM %04x,TDTX %04x,DSSSCCK1 %04x,DSSSCCKTx %04x\r\n", + (uint)pdVar2->phy_debugPortMainFSM,(uint)pdVar2->phy_debugPortTDTX, + (uint)pdVar2->phy_debugPortDSSSCCK1,(uint)pdVar2->phy_debugPortDSSSCCKTx); + puVar1 = &pdVar2->rf_state; + pdVar2 = pdVar2 + 1; + printf("RFC: RC %s, RF %s\r\n",rf_state_str[*puVar1]); + } + printf("\r\n\r\n"); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void helper_record_rc_rf_states(uint *param_1,uint *param_2) + +{ + uint uVar1; + + _DAT_40001220 = _DAT_40001220 & 0xfffffff | 0x20000000; + uVar1 = _DAT_40001224 >> 0x19; + *param_1 = _DAT_40001224 >> 0x1c & 7; + *param_2 = uVar1 & 7; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void helper_record_all_states(char *func_name) + +{ + uint32_t uVar1; + uint uVar2; + uint uVar3; + uint uVar4; + + uVar1 = _DAT_44b00120; + uVar4 = (uint)dump_data_ptr; + dump_data_poll[uVar4].func_name = func_name; + dump_data_poll[uVar4].time = uVar1; + helper_record_rc_rf_states(uVar4 * 0x28 + 0x42016704,uVar4 * 0x28 + 0x42016708); + dump_data_poll[uVar4].mac_debugRegHWSM1 = _DAT_44b00500; + dump_data_poll[uVar4].mac_debugRegHWSM2 = _DAT_44b00504; + _DAT_44b00510 = _DAT_44b00510 & 0xffff0000 | 0x31; + *(undefined4 *)&dump_data_poll[uVar4].mac_debugPortCoex = _DAT_44b0050c; + _DAT_44b00510 = _DAT_44b00510 & 0xffff0000 | 0x2f0b; + *(undefined4 *)&dump_data_poll[uVar4].mac_debugPortMacPhyIf = _DAT_44b0050c; + _DAT_44900068 = _DAT_44900068 & 0xffff0000 | 0x14; + _DAT_400000d0 = 4; + _DAT_400000d4 = 0x40000004; + _DAT_400000d8 = 0x80000004; + _DAT_400000dc = 0xc0000004; + uVar2 = _DAT_400000e0 & 0xfffffffe; + uVar3 = _DAT_400000e0 >> 1; + _DAT_400000e0 = uVar2; + dump_data_poll[uVar4].phy_debugPortTDTX = (uint16_t)uVar3; + dump_data_poll[uVar4].phy_debugPortMainFSM = (ushort)(uVar2 >> 0x11); + _DAT_44900074 = 0xb09; + uVar2 = _DAT_400000e0 & 0xfffffffe; + uVar3 = _DAT_400000e0 >> 1; + _DAT_400000e0 = uVar2; + dump_data_poll[uVar4].phy_debugPortDSSSCCK1 = (uint16_t)uVar3; + dump_data_poll[uVar4].phy_debugPortDSSSCCKTx = (ushort)(uVar2 >> 0x11); + dump_data_ptr = dump_data_ptr + 1 & 0xf; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_fsm_ctrl_en_setf(uint32_t x) + +{ + _DAT_40001004 = x << 1 | _DAT_40001004 & 0xfffffffd; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_gc_tbb_setf(uint32_t x) + +{ + _DAT_40001048 = (x & 0x1f) << 0x14 | _DAT_40001048 & 0xfe0fffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_gc_tmx_setf(uint32_t x) + +{ + _DAT_40001048 = (x & 7) << 0x10 | _DAT_40001048 & 0xfff8ffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pa_ib_fix_setf(uint32_t x) + +{ + _DAT_40001064 = x << 0x10 | _DAT_40001064 & 0xfffeffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pa_vbcas_setf(uint32_t x) + +{ + _DAT_40001064 = x << 0xc | _DAT_40001064 & 0xffff8fff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pa_vbcore_setf(uint32_t x) + +{ + _DAT_40001064 = x << 8 | _DAT_40001064 & 0xfffff0ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tmx_cs_setf(uint32_t x) + +{ + _DAT_4000106c = x | _DAT_4000106c & 0xfffffff8; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_fsm_st_dbg_en_setf(uint32_t x) + +{ + _DAT_4000126c = x << 3 | _DAT_4000126c & 0xfffffff7; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc3_setf(uint32_t x) + +{ + _DAT_40001630 = (x & 0x7f) << 0x18 | _DAT_40001630 & 0x80ffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc2_setf(uint32_t x) + +{ + _DAT_40001630 = (x & 0x7f) << 0x10 | _DAT_40001630 & 0xff80ffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc1_setf(uint32_t x) + +{ + _DAT_40001630 = (x & 0x7f) << 8 | _DAT_40001630 & 0xffff80ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc0_setf(uint32_t x) + +{ + _DAT_40001630 = x & 0x7f | _DAT_40001630 & 0xffffff80; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc7_setf(uint32_t x) + +{ + _DAT_40001634 = (x & 0x7f) << 0x18 | _DAT_40001634 & 0x80ffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc6_setf(uint32_t x) + +{ + _DAT_40001634 = (x & 0x7f) << 0x10 | _DAT_40001634 & 0xff80ffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc5_setf(uint32_t x) + +{ + _DAT_40001634 = (x & 0x7f) << 8 | _DAT_40001634 & 0xffff80ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc4_setf(uint32_t x) + +{ + _DAT_40001634 = x & 0x7f | _DAT_40001634 & 0xffffff80; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc11_setf(uint32_t x) + +{ + _DAT_40001638 = (x & 0x7f) << 0x18 | _DAT_40001638 & 0x80ffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc10_setf(uint32_t x) + +{ + _DAT_40001638 = (x & 0x7f) << 0x10 | _DAT_40001638 & 0xff80ffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc9_setf(uint32_t x) + +{ + _DAT_40001638 = (x & 0x7f) << 8 | _DAT_40001638 & 0xffff80ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc8_setf(uint32_t x) + +{ + _DAT_40001638 = x & 0x7f | _DAT_40001638 & 0xffffff80; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc15_setf(uint32_t x) + +{ + _DAT_4000163c = (x & 0x7f) << 0x18 | _DAT_4000163c & 0x80ffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc14_setf(uint32_t x) + +{ + _DAT_4000163c = (x & 0x7f) << 0x10 | _DAT_4000163c & 0xff80ffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc13_setf(uint32_t x) + +{ + _DAT_4000163c = (x & 0x7f) << 8 | _DAT_4000163c & 0xffff80ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_tx_dvga_gain_qdb_gc12_setf(uint32_t x) + +{ + _DAT_4000163c = x & 0x7f | _DAT_4000163c & 0xffffff80; + return; +} + + + +void wait_us(uint32_t us) + +{ + bool bVar1; + uint32_t n; + int iStack4; + + iStack4 = us << 4; + do { + bVar1 = iStack4 != 0; + iStack4 = iStack4 + -1; + } while (bVar1); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pa_etb_en_setf(void) + +{ + _DAT_40001064 = _DAT_40001064 & 0xfffffff7; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pa_half_on_setf(void) + +{ + _DAT_40001064 = _DAT_40001064 & 0xffff7fff | 0x8000; + return; +} + + + +void _print_channel_info(void) + +{ + int iVar1; + + iVar1 = 8; + do { + iVar1 = iVar1 + -1; + wait_us(1000); + } while (iVar1 != 0); + iVar1 = 8; + do { + iVar1 = iVar1 + -1; + wait_us(1000); + } while (iVar1 != 0); + return; +} + + + +// WARNING: Control flow encountered bad instruction data + +void rfc_init(uint32_t xtalfreq_hz) + +{ + uint32_t rfg_index; + uint32_t dg; + + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rfc_rxdfe_set_notch0(uint8_t en,uint8_t alpha,int8_t nrmfc) + +{ + _DAT_40001700 = + ((uint)en & 1) << 6 | (uint)(byte)nrmfc << 8 | (uint)alpha & 7 | _DAT_40001700 & 0xffff00b8; + return; +} + + + +// WARNING: Variable defined which should be unmapped: ncf_freq_hz +// WARNING: Could not reconcile some variable overlaps +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rfc_config_channel(uint32_t channel_freq) + +{ + SItype SVar1; + uint8_t uStack21; + uint8_t ncf_on; + SItype SStack20; + int32_t ncf_freq_hz; + + _DAT_40001228 = _DAT_40001228 | 8; + _DAT_4000100c = _DAT_4000100c | 0x241; + _DAT_40001264 = channel_freq & 0xfff | _DAT_40001264 & 0xfffff000; + _DAT_40001268 = _DAT_40001268 & 0xfffdffff | 0x20000; + wait_us(10); + _DAT_40001268 = _DAT_40001268 & 0xfffdffff; + wait_us(10); + rf_fsm_ctrl_en_setf(0); + wait_us(10); + rf_fsm_ctrl_en_setf(1); + wait_us(10); + _DAT_4000126c = _DAT_4000126c & 0xfffffff8 | 1; + wait_us(10); + rf_fsm_st_dbg_en_setf(1); + wait_us(10); + _DAT_4000126c = _DAT_4000126c & 0xfffffff8 | 2; + wait_us(100); + rf_fsm_st_dbg_en_setf(0); + wait_us(10); + _print_channel_info(); + rf_pri_update_param(channel_freq); + rf_pri_get_notch_param(channel_freq,&uStack21,(int32_t *)&stack0xffffffec); + __floatsidf(SStack20); + __divdf3(); + __muldf3(); + __adddf3(); + SVar1 = __fixdfsi(); + rfc_rxdfe_set_notch0(uStack21,'\x01',(int8_t)SVar1); + _DAT_40001228 = _DAT_40001228 & 0xfffffff7; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rfc_coex_force_to(uint32_t force_enable,uint32_t bbmode) + +{ + rf_fsm_ctrl_en_setf(0); + wait_us(10); + _DAT_40001220 = + (uint)(force_enable != 0) << 0x1b | (bbmode & 1) << 0x1a | _DAT_40001220 & 0xf3ffffff; + wait_us(10); + rf_fsm_ctrl_en_setf(1); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +_Bool rfc_config_power_ble(int32_t pwr_dbm) + +{ + int iVar1; + uint uVar2; + + if ((uint)pwr_dbm < 0x10) { + if (pwr_dbm < 4) { + rf_pa_ib_fix_setf(1); + rf_pa_half_on_setf(); + rf_pa_vbcas_setf(4); + rf_pa_vbcore_setf(9); + rf_pa_etb_en_setf(); + rf_tmx_cs_setf(5); + rf_gc_tbb_setf(2); + rf_gc_tmx_setf(5); + iVar1 = pwr_dbm * 4 + -0x12; + } + else { + if (pwr_dbm < 7) { + rf_pa_ib_fix_setf(1); + rf_pa_half_on_setf(); + rf_pa_vbcas_setf(4); + rf_pa_vbcore_setf(9); + rf_pa_etb_en_setf(); + rf_tmx_cs_setf(5); + rf_gc_tbb_setf(2); + rf_gc_tmx_setf(7); + iVar1 = pwr_dbm * 4 + -0x1e; + } + else { + if (pwr_dbm < 10) { + rf_pa_ib_fix_setf(1); + rf_pa_half_on_setf(); + rf_pa_vbcas_setf(4); + rf_pa_vbcore_setf(9); + rf_pa_etb_en_setf(); + rf_tmx_cs_setf(5); + rf_gc_tbb_setf(3); + rf_gc_tmx_setf(7); + iVar1 = pwr_dbm + -10; + } + else { + if (pwr_dbm < 0xc) { + rf_pa_ib_fix_setf(1); + rf_pa_half_on_setf(); + rf_pa_vbcas_setf(4); + rf_pa_vbcore_setf(9); + rf_pa_etb_en_setf(); + rf_tmx_cs_setf(5); + rf_gc_tbb_setf(4); + rf_gc_tmx_setf(7); + iVar1 = pwr_dbm + -0xc; + } + else { + rf_pa_ib_fix_setf(1); + rf_pa_half_on_setf(); + rf_pa_vbcas_setf(4); + rf_pa_vbcore_setf(9); + rf_pa_etb_en_setf(); + rf_tmx_cs_setf(5); + rf_gc_tbb_setf(6); + rf_gc_tmx_setf(7); + iVar1 = pwr_dbm + -0xf; + } + } + iVar1 = iVar1 << 2; + } + } + uVar2 = iVar1 - 1; + _DAT_40001648 = + uVar2 * 0x10000 & 0x7f0000 | + uVar2 * 0x100 & 0x7f00 | uVar2 & 0x7f | _DAT_40001648 & 0xff808080; + return true; + } + return false; +} + + + +uint32_t rfc_get_power_level(uint32_t formatmod,int32_t power) + +{ + uint32_t mode; + + mode = 0; + if ((formatmod != 0) && (mode = 1, formatmod != 1)) { + mode = 2; + } + mode = rf_pri_get_txgain_index(power,mode); + return mode << 2; +} + + + +void rfc_apply_tx_dvga(int8_t *dvga_qdb) + +{ + rf_tx_dvga_gain_qdb_gc0_setf((int)*dvga_qdb); + rf_tx_dvga_gain_qdb_gc1_setf((int)dvga_qdb[1]); + rf_tx_dvga_gain_qdb_gc2_setf((int)dvga_qdb[2]); + rf_tx_dvga_gain_qdb_gc3_setf((int)dvga_qdb[3]); + rf_tx_dvga_gain_qdb_gc4_setf((int)dvga_qdb[4]); + rf_tx_dvga_gain_qdb_gc5_setf((int)dvga_qdb[5]); + rf_tx_dvga_gain_qdb_gc6_setf((int)dvga_qdb[6]); + rf_tx_dvga_gain_qdb_gc7_setf((int)dvga_qdb[7]); + rf_tx_dvga_gain_qdb_gc8_setf((int)dvga_qdb[8]); + rf_tx_dvga_gain_qdb_gc9_setf((int)dvga_qdb[9]); + rf_tx_dvga_gain_qdb_gc10_setf((int)dvga_qdb[10]); + rf_tx_dvga_gain_qdb_gc11_setf((int)dvga_qdb[0xb]); + rf_tx_dvga_gain_qdb_gc12_setf((int)dvga_qdb[0xc]); + rf_tx_dvga_gain_qdb_gc13_setf((int)dvga_qdb[0xd]); + rf_tx_dvga_gain_qdb_gc14_setf((int)dvga_qdb[0xe]); + rf_tx_dvga_gain_qdb_gc15_setf((int)dvga_qdb[0xf]); + return; +} + + + +// WARNING: Variable defined which should be unmapped: dg +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rfc_apply_tx_power_offset(uint8_t channel,int8_t *power_offset) + +{ + uint32_t uStack56; + uint32_t rfg_index; + uint32_t dg; + + rf_pri_update_tx_power_offset(channel,power_offset); + rf_pri_query_txgain_table(0,&uStack56,&rfg_index); + _DAT_40001640 = uStack56 & 7 | _DAT_40001640 & 0xfffffff8; + rf_tx_dvga_gain_qdb_gc0_setf(rfg_index); + rf_pri_query_txgain_table(1,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 4 | _DAT_40001640 & 0xffffff8f; + rf_tx_dvga_gain_qdb_gc1_setf(rfg_index); + rf_pri_query_txgain_table(2,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 8 | _DAT_40001640 & 0xfffff8ff; + rf_tx_dvga_gain_qdb_gc2_setf(rfg_index); + rf_pri_query_txgain_table(3,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 0xc | _DAT_40001640 & 0xffff8fff; + rf_tx_dvga_gain_qdb_gc3_setf(rfg_index); + rf_pri_query_txgain_table(4,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 0x10 | _DAT_40001640 & 0xfff8ffff; + rf_tx_dvga_gain_qdb_gc4_setf(rfg_index); + rf_pri_query_txgain_table(5,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 0x14 | _DAT_40001640 & 0xff8fffff; + rf_tx_dvga_gain_qdb_gc5_setf(rfg_index); + rf_pri_query_txgain_table(6,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 0x18 | _DAT_40001640 & 0xf8ffffff; + rf_tx_dvga_gain_qdb_gc6_setf(rfg_index); + rf_pri_query_txgain_table(7,&uStack56,&rfg_index); + _DAT_40001640 = (uStack56 & 7) << 0x1c | _DAT_40001640 & 0x8fffffff; + rf_tx_dvga_gain_qdb_gc7_setf(rfg_index); + rf_pri_query_txgain_table(8,&uStack56,&rfg_index); + _DAT_40001644 = uStack56 & 7 | _DAT_40001644 & 0xfffffff8; + rf_tx_dvga_gain_qdb_gc8_setf(rfg_index); + rf_pri_query_txgain_table(9,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 4 | _DAT_40001644 & 0xffffff8f; + rf_tx_dvga_gain_qdb_gc9_setf(rfg_index); + rf_pri_query_txgain_table(10,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 8 | _DAT_40001644 & 0xfffff8ff; + rf_tx_dvga_gain_qdb_gc10_setf(rfg_index); + rf_pri_query_txgain_table(0xb,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 0xc | _DAT_40001644 & 0xffff8fff; + rf_tx_dvga_gain_qdb_gc11_setf(rfg_index); + rf_pri_query_txgain_table(0xc,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 0x10 | _DAT_40001644 & 0xfff8ffff; + rf_tx_dvga_gain_qdb_gc12_setf(rfg_index); + rf_pri_query_txgain_table(0xd,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 0x14 | _DAT_40001644 & 0xff8fffff; + rf_tx_dvga_gain_qdb_gc13_setf(rfg_index); + rf_pri_query_txgain_table(0xe,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 0x18 | _DAT_40001644 & 0xf8ffffff; + rf_tx_dvga_gain_qdb_gc14_setf(rfg_index); + rf_pri_query_txgain_table(0xf,&uStack56,&rfg_index); + _DAT_40001644 = (uStack56 & 7) << 0x1c | _DAT_40001644 & 0x8fffffff; + rf_tx_dvga_gain_qdb_gc15_setf(rfg_index); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_set_gain_table_regs(void) + +{ + _DAT_40001118 = + ((tx_pwr_table[12][2] << 0x18 | + (tx_pwr_table[12][3] << 0x10 | + (tx_pwr_table[14][0] << 0xe | + (tx_pwr_table[14][1] << 0xc | + (tx_pwr_table[14][2] << 8 | (_DAT_40001118 & 0xffffffe0 | tx_pwr_table[14][3]) & 0xfffff8ff) + & 0xffffcfff) & 0xffff3fff) & 0xffe0ffff) & 0xf8ffffff) & 0xcfffffff | + tx_pwr_table[12][1] << 0x1c) & 0x3fffffff | tx_pwr_table[12][0] << 0x1e; + _DAT_4000111c = + (tx_pwr_table[8][1] << 0x1c | + (tx_pwr_table[8][2] << 0x18 | + (tx_pwr_table[8][3] << 0x10 | + (tx_pwr_table[10][0] << 0xe | + (tx_pwr_table[10][1] << 0xc | + (tx_pwr_table[10][2] << 8 | (_DAT_4000111c & 0xffffffe0 | tx_pwr_table[10][3]) & 0xfffff8ff) + & 0xffffcfff) & 0xffff3fff) & 0xffe0ffff) & 0xf8ffffff) & 0xcfffffff) & 0x3fffffff | + tx_pwr_table[8][0] << 0x1e; + _DAT_40001120 = + tx_pwr_table[4][0] << 0x1e | + (tx_pwr_table[4][1] << 0x1c | + (tx_pwr_table[4][2] << 0x18 | + (tx_pwr_table[4][3] << 0x10 | + (tx_pwr_table[6][0] << 0xe | + (tx_pwr_table[6][1] << 0xc | + (tx_pwr_table[6][2] << 8 | (_DAT_40001120 & 0xffffffe0 | tx_pwr_table[6][3]) & 0xfffff8ff) & + 0xffffcfff) & 0xffff3fff) & 0xffe0ffff) & 0xf8ffffff) & 0xcfffffff) & 0x3fffffff; + _DAT_40001124 = + (tx_pwr_table[0][1] << 0x1c | + ((tx_pwr_table[0][3] << 0x10 | + (tx_pwr_table[2][0] << 0xe | + ((tx_pwr_table[2][2] << 8 | (_DAT_40001124 & 0xffffffe0 | tx_pwr_table[2][3]) & 0xfffff8ff) + & 0xffffcfff | tx_pwr_table[2][1] << 0xc) & 0xffff3fff) & 0xffe0ffff) & 0xf8ffffff | + tx_pwr_table[0][2] << 0x18) & 0xcfffffff) & 0x3fffffff | tx_pwr_table[0][0] << 0x1e; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_manu_pu(uint32_t mode) + +{ + int iVar1; + uint uVar2; + + if (mode == 5) { + _DAT_40001030 = _DAT_40001030 & 0xcefff8ff; + iVar1 = -0x39009000; + } + else { + if (5 < mode) { + if (7 < mode) goto LAB_23058062; + _DAT_40001030 = _DAT_40001030 & 0x8f090ff; + uVar2 = 0xf00000; + goto LAB_23058096; + } + if (mode != 4) { +LAB_23058062: + _DAT_40001004 = _DAT_40001004 & 0xfffffffd; + _DAT_4000100c = 0; + _DAT_40001030 = _DAT_40001030 & 0x2df0feff | 0x25f06e00; + return; + } + _DAT_40001030 = _DAT_40001030 & 0x2cf8f8ff; + iVar1 = 0x24f87000; + } + uVar2 = iVar1 - 0x800; +LAB_23058096: + _DAT_40001004 = _DAT_40001004 & 0xfffffffd; + _DAT_4000100c = 0; + _DAT_40001030 = _DAT_40001030 | uVar2; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_save_state_for_cal(void) + +{ + state_adda1 = _DAT_4000108c; + state_dfe_ctrl_0 = _DAT_40001600; + state_dfe_ctrl_3 = _DAT_4000160c; + state_dfe_ctrl_6 = _DAT_40001618; + state_dfe_ctrl_7 = _DAT_4000161c; + state_fbdv = _DAT_400010b8; + state_pa1 = _DAT_40001064; + state_pucr1 = _DAT_40001030; + state_rbb3 = _DAT_40001084; + state_rf_fsm_ctrl_hw = _DAT_40001004; + state_rf_resv_reg_1 = _DAT_400010f0; + state_rfcal_ctrlen = _DAT_4000101c; + state_rfctrl_hw_en = _DAT_4000100c; + state_rfif_dfe_ctrl0 = _DAT_40001220; + state_sdm1 = _DAT_400010c0; + state_sdm2 = _DAT_400010c4; + state_singen_ctrl0 = _DAT_4000120c; + state_singen_ctrl2 = _DAT_40001214; + state_singen_ctrl3 = _DAT_40001218; + state_sram_ctrl0 = _DAT_4000123c; + state_sram_ctrl1 = _DAT_40001240; + state_sram_ctrl2 = _DAT_40001244; + state_tbb = _DAT_40001070; + state_ten_ac = _DAT_40001058; + state_trx_gain1 = _DAT_40001048; + state_vco2 = _DAT_400010a4; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_restore_state_for_cal(void) + +{ + _DAT_40001004 = state_rf_fsm_ctrl_hw; + _DAT_4000100c = state_rfctrl_hw_en; + _DAT_4000101c = state_rfcal_ctrlen; + _DAT_40001030 = state_pucr1; + _DAT_40001048 = state_trx_gain1; + _DAT_40001058 = state_ten_ac; + _DAT_40001064 = state_pa1; + _DAT_40001070 = state_tbb; + _DAT_40001084 = state_rbb3; + _DAT_4000108c = state_adda1; + _DAT_400010a4 = state_vco2; + _DAT_400010b8 = state_fbdv; + _DAT_400010c0 = state_sdm1; + _DAT_400010c4 = state_sdm2; + _DAT_400010f0 = state_rf_resv_reg_1; + _DAT_4000120c = state_singen_ctrl0; + _DAT_40001214 = state_singen_ctrl2; + _DAT_40001218 = state_singen_ctrl3; + _DAT_40001220 = state_rfif_dfe_ctrl0; + _DAT_4000123c = state_sram_ctrl0; + _DAT_40001240 = state_sram_ctrl1; + _DAT_40001244 = state_sram_ctrl2; + _DAT_40001600 = state_dfe_ctrl_0; + _DAT_4000160c = state_dfe_ctrl_3; + _DAT_40001618 = state_dfe_ctrl_6; + _DAT_4000161c = state_dfe_ctrl_7; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_singen_start(void) + +{ + _DAT_4000120c = _DAT_4000120c & 0x7fffffff | 0x80000000; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t rf_pri_pm_pwr(void) + +{ + int iVar1; + int iVar2; + + do { + } while (-1 < (int)((_DAT_40001618 & 0xdfefffff | 0x20100000) << 3)); + iVar1 = (_DAT_40001620 << 7) >> 0x10; + iVar2 = (_DAT_40001624 << 7) >> 0x10; + _DAT_40001618 = _DAT_40001618 & 0xdfefffff; + return iVar1 * iVar1 + iVar2 * iVar2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_start_txdfe(void) + +{ + _DAT_40001220 = _DAT_40001220 & 0xffffe67f | 0x1182; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int32_t rf_pri_pm_pwr_avg(uint32_t iq,uint32_t acc_len) + +{ + int iVar1; + + do { + } while (-1 < (int)((_DAT_40001618 & 0xdfefffff) << 3)); + iVar1 = _DAT_40001624; + if (iq != 0) { + iVar1 = _DAT_40001620; + } + _DAT_40001618 = _DAT_40001618 & 0xdfefffff; + _DAT_4000161c = acc_len << 0x10 | _DAT_4000161c & 0xffff; + return (iVar1 << 7) >> 7; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_txcal_config_hw(void) + +{ + _DAT_40001180 = + (*(uint *)(rf_calib_data->txcal + 1) >> 6 & 0x3f) << 0x18 | + (*(uint *)rf_calib_data->txcal >> 6 & 0x3f) << 8 | + *(uint *)rf_calib_data->txcal & 0x3f | _DAT_40001180 & 0xc0c0c0c0 | + (*(uint *)(rf_calib_data->txcal + 1) & 0x3f) << 0x10; + _DAT_40001184 = + (*(uint *)(rf_calib_data->txcal + 3) >> 6 & 0x3f) << 0x18 | + (*(uint *)(rf_calib_data->txcal + 2) >> 6 & 0x3f) << 8 | + *(uint *)(rf_calib_data->txcal + 2) & 0x3f | _DAT_40001184 & 0xc0c0c0c0 | + (*(uint *)(rf_calib_data->txcal + 3) & 0x3f) << 0x10; + _DAT_40001188 = + (*(uint *)(rf_calib_data->txcal + 5) >> 6 & 0x3f) << 0x18 | + (*(uint *)(rf_calib_data->txcal + 4) >> 6 & 0x3f) << 8 | + *(uint *)(rf_calib_data->txcal + 4) & 0x3f | _DAT_40001188 & 0xc0c0c0c0 | + (*(uint *)(rf_calib_data->txcal + 5) & 0x3f) << 0x10; + _DAT_4000118c = + (*(uint *)(rf_calib_data->txcal + 7) >> 6 & 0x3f) << 0x18 | + (*(uint *)(rf_calib_data->txcal + 6) >> 6 & 0x3f) << 8 | + *(uint *)(rf_calib_data->txcal + 6) & 0x3f | _DAT_4000118c & 0xc0c0c0c0 | + (*(uint *)(rf_calib_data->txcal + 7) & 0x3f) << 0x10; + _DAT_40001190 = + (*(uint *)rf_calib_data->txcal >> 0xc & 0x7ff) << 0x10 | _DAT_40001190 & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[0].field_0x4 & 0x3ff; + _DAT_40001194 = + (*(uint *)(rf_calib_data->txcal + 1) >> 0xc & 0x7ff) << 0x10 | _DAT_40001194 & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[1].field_0x4 & 0x3ff; + _DAT_40001198 = + (*(uint *)(rf_calib_data->txcal + 2) >> 0xc & 0x7ff) << 0x10 | _DAT_40001198 & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[2].field_0x4 & 0x3ff; + _DAT_4000119c = + (*(uint *)(rf_calib_data->txcal + 3) >> 0xc & 0x7ff) << 0x10 | _DAT_4000119c & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[3].field_0x4 & 0x3ff; + _DAT_400011a0 = + (*(uint *)(rf_calib_data->txcal + 4) >> 0xc & 0x7ff) << 0x10 | _DAT_400011a0 & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[4].field_0x4 & 0x3ff; + _DAT_400011a4 = + (*(uint *)(rf_calib_data->txcal + 5) >> 0xc & 0x7ff) << 0x10 | _DAT_400011a4 & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[5].field_0x4 & 0x3ff; + _DAT_400011a8 = + (*(uint *)(rf_calib_data->txcal + 6) >> 0xc & 0x7ff) << 0x10 | _DAT_400011a8 & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[6].field_0x4 & 0x3ff; + _DAT_400011ac = + (*(uint *)(rf_calib_data->txcal + 7) >> 0xc & 0x7ff) << 0x10 | _DAT_400011ac & 0xf800fc00 | + *(uint *)&rf_calib_data->txcal[7].field_0x4 & 0x3ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint16_t rf_pri_fcal_meas(uint32_t cw) + +{ + _DAT_400010a0 = cw | _DAT_400010a0 & 0xffffff00; + BL602_Delay_US(100); + do { + } while (-1 < (int)((_DAT_400010ac | 0x10) << 0xb)); + _DAT_400010ac = _DAT_400010ac & 0xffffffef; + return (uint16_t)((uint)_DAT_400010a8 >> 0x10); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_rccal_config(uint32_t rbb_fc) + +{ + _DAT_40001080 = rbb_fc << 8 | rbb_fc << 0x18 | _DAT_40001080 & 0xc0ffc0ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_rccal_config(uint32_t iq,uint32_t rbb_fc) + +{ + if (iq != 0) { + rf_pri_rccal_config(rbb_fc); + return; + } + _DAT_40001080 = rbb_fc << 0x10 | _DAT_40001080 & 0xffc0ffc0 | rbb_fc; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_txcal_config(uint32_t param_ind,int32_t val) + +{ + uint uVar1; + + if (param_ind == 2) { + _DAT_40001600 = val << 0xc | _DAT_40001600 & 0xff800fff | 0x800000; + return; + } + if (param_ind != 3) { + if (param_ind == 0) { + _DAT_40001070 = _DAT_40001070 & 0xc0ffffff; + uVar1 = val << 0x18; + } + else { + if (param_ind != 1) { + return; + } + _DAT_40001070 = _DAT_40001070 & 0xffc0ffff; + uVar1 = val << 0x10; + } + _DAT_40001070 = uVar1 | _DAT_40001070; + return; + } + if (val < 0) { + val = val + 0x400; + } + _DAT_40001600 = val | _DAT_40001600 & 0xfffffc00 | 0x400; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int32_t rf_pri_txcal_search_core + (uint32_t param_ind,uint32_t center,uint32_t delta,uint32_t meas_freq) + +{ + uint32_t val; + uint32_t val_00; + uint32_t uVar1; + uint uVar2; + uint32_t uVar3; + + rf_pri_txcal_config(param_ind,center); + BL602_Delay_US(10); + _DAT_40001618 = meas_freq << 10 | _DAT_40001618 & 0xfff00000; + uVar1 = rf_pri_pm_pwr(); + do { + val = center - delta; + val_00 = center + delta; + if (param_ind < 2) { + if ((int)val < 0) { + val = 0; + } + if (0x3f < (int)val_00) { + val_00 = 0x3f; + } + } + else { + if (param_ind == 2) { + if ((int)val < 0) { + val = 0; + } + if (0x7ff < (int)val_00) { + val_00 = 0x7ff; + } + } + else { + if ((int)val < -0x200) { + val = 0xfffffe00; + } + if (0x1ff < (int)val_00) { + val_00 = 0x1ff; + } + } + } + rf_pri_txcal_config(param_ind,val); + delta = (int)delta >> 1; + BL602_Delay_US(10); + uVar2 = rf_pri_pm_pwr(); + if (uVar1 <= uVar2) { + rf_pri_txcal_config(param_ind,val_00); + BL602_Delay_US(10); + uVar3 = rf_pri_pm_pwr(); + val = center; + uVar2 = uVar1; + if (uVar3 < uVar1) { + val = val_00; + uVar2 = uVar3; + } + } + center = val; + uVar1 = uVar2; + } while (delta != 0); + return val; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_singen_config(uint32_t fcw) + +{ + _DAT_4000120c = fcw << 0x10 | _DAT_4000120c & 0xfc00ffff; + _DAT_40001214 = _DAT_40001214 & 0x3fffff; + _DAT_40001218 = _DAT_40001218 & 0x3fffff | 0xc0000000; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t rf_pri_rccal_iq(uint32_t iq) + +{ + uint uVar1; + uint32_t i; + USItype UVar2; + uint32_t uVar3; + uint uVar4; + int iVar5; + undefined4 uVar6; + + if (iq == 0) { + _DAT_4000160c = _DAT_4000160c & 0xfbffffff | 0x400; + } + else { + _DAT_4000160c = _DAT_4000160c & 0xfffffbff | 0x4000000; + } + _DAT_40001048 = _DAT_40001048 & 0xffff8cff | 0x3100; + rf_pri_singen_config(3); + _DAT_40001214 = _DAT_40001214 & 0xfffff800 | 0x3ff; + _DAT_40001218 = _DAT_40001218 & 0xfffff800 | 0x3ff; + uVar6 = rf_pri_singen_start(); + rf_pri_start_txdfe(uVar6); + _DAT_40001618 = _DAT_40001618 & 0xfff00000 | 0xc00; + rf_pri_pm_pwr_avg(iq,0x400); + i = rf_pri_pm_pwr(); + __floatunsidf(i); + __muldf3(); + UVar2 = __fixunsdfsi(); + _DAT_40001048 = _DAT_40001048 & 0xffff8cff | 0x6200; + rf_pri_singen_config(0xb5); + uVar6 = rf_pri_singen_start(); + rf_pri_start_txdfe(uVar6); + _DAT_40001618 = _DAT_40001618 & 0xfff00000 | 0x2d400; + i = 0; + uVar1 = 6; + uVar4 = 0x20; + do { + rf_pri_rccal_config(iq,uVar4 + i); + uVar3 = rf_pri_pm_pwr(); + if (UVar2 < uVar3) { + i = uVar4 + i; + } + uVar1 = uVar1 - 1; + uVar4 = uVar4 >> 1; + } while (uVar1 != 0); + iVar5 = 0x3f; + do { + rf_pri_rccal_config(iq,i); + uVar3 = rf_pri_pm_pwr(); + if (UVar2 < uVar3) { + uVar1 = uVar1 * 2 + 1 & 0xf; + i = i + 1; + if (uVar1 == 5) { + return 3; + } + } + else { + uVar1 = uVar1 * 2 & 0xf; + i = i - 1; + if (uVar1 == 10) { + return 3; + } + } + iVar5 = iVar5 + -1; + } while (iVar5 != 0); + return 2; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_config_channel(void) + +{ + _DAT_400010a0 = + ((uint)((ushort)rf_calib_data->lo[9] >> 8) & 0x1f) << 0x10 | + (uint)(ushort)rf_calib_data->lo[9] & 0xff | _DAT_400010a0 & 0xffe0ff00; + _DAT_400010bc = + (((uint)(ushort)rf_calib_data->lo[9] & 0xff) >> 4) << 0x14 | _DAT_400010bc & 0xff0fffff; + _DAT_400010c4 = _DAT_400010c4 & 0xc0000000 | channel_div_table[9]; + _DAT_400010c0 = _DAT_400010c0 & 0xffffefff; + while( true ) { + _DAT_400010b8 = _DAT_400010b8 | 0x10000; + BL602_Delay_US(10); + _DAT_400010b8 = _DAT_400010b8 & 0xfffeffff; + BL602_Delay_US(0x32); + _DAT_400010b0 = _DAT_400010b0 | 0x10000000; + BL602_Delay_US(10); + _DAT_400010b0 = _DAT_400010b0 & 0xefffffff; + BL602_Delay_US(0x32); + if ((_DAT_400010b4 & 0x1100000) == 0) break; + printf("."); + } + printf("LO locked %ld %ld\r\n",(uint)(ushort)rf_calib_data->lo[9] & 0xff); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t rf_pri_roscal_iq(uint32_t iq) + +{ + uint uVar1; + int32_t iVar2; + uint uVar3; + uint uVar4; + int iVar5; + uint uVar6; + + uVar1 = 6; + uVar3 = 0; + uVar4 = 0x20; + do { + uVar6 = uVar4 + uVar3; + if (iq == 0) { + _DAT_4000107c = uVar6 | _DAT_4000107c & 0xffffffc0; + } + else { + _DAT_4000107c = uVar6 * 0x100 | _DAT_4000107c & 0xffffc0ff; + } + iVar2 = rf_pri_pm_pwr_avg(iq,0x400); + if (iVar2 < 1) { + uVar3 = uVar6; + } + uVar1 = uVar1 - 1; + uVar4 = uVar4 >> 1; + } while (uVar1 != 0); + iVar5 = 0x3f; + do { + if (iq == 0) { + _DAT_4000107c = _DAT_4000107c & 0xffffffc0 | uVar3; + } + else { + _DAT_4000107c = uVar3 << 8 | _DAT_4000107c & 0xffffc0ff; + } + iVar2 = rf_pri_pm_pwr_avg(iq,0x400); + if (iVar2 < 1) { + uVar1 = uVar1 * 2 & 0xf; + uVar3 = uVar3 + 1; + if (uVar1 == 10) { + return uVar3; + } + } + else { + uVar1 = uVar1 * 2 + 1 & 0xf; + uVar3 = uVar3 - 1; + if (uVar1 == 5) { + return uVar3; + } + } + iVar5 = iVar5 + -1; + } while (iVar5 != 0); + return uVar3; +} + + + +void rf_pri_chipv(uint8_t chipv) + +{ + regs_to_opti *prVar1; + undefined3 in_register_00002029; + undefined4 *puVar2; + undefined4 *puVar3; + int iVar4; + uint32_t *puVar5; + void_fn **ppvVar6; + int iVar7; + uint32_t *puVar8; + uint32_t *puVar9; + int iVar10; + void_fn **ppvVar11; + void_fn **ppvVar12; + + if (CONCAT31(in_register_00002029,chipv) == 0) { + tmxcss._0_4_ = 0x60003; + tmxcss[2] = 6; + iVar4 = 0x1c; + do { + iVar7 = iVar4 + -0x1c; + do { + *(undefined4 *)((int)tx_pwr_table + iVar7) = *(undefined4 *)((int)tx_pwr_table_a0 + iVar7); + *(undefined4 *)((int)tx_pwr_table_origin + iVar7) = + *(undefined4 *)((int)tx_pwr_table_a0 + iVar7); + iVar7 = iVar7 + 4; + } while (iVar4 != iVar7); + iVar4 = iVar4 + 0x1c; + } while (iVar4 != 0x1dc); + iVar4 = 0; + do { + puVar2 = (undefined4 *)((int)tx_pwr_ch_os_a0 + iVar4); + puVar3 = (undefined4 *)((int)tx_pwr_ch_os + iVar4); + iVar4 = iVar4 + 4; + *puVar3 = *puVar2; + } while (iVar4 != 0x38); + puVar5 = txcal_para; + puVar8 = txcal_para_a0; + do { + puVar9 = puVar8 + 4; + *puVar5 = *puVar8; + puVar5[1] = puVar8[1]; + puVar5[2] = puVar8[2]; + puVar5[3] = puVar8[3]; + puVar5 = puVar5 + 4; + puVar8 = puVar9; + } while (puVar9 != txcal_para_a1); + opti_regs->vbcore = 10; + prVar1 = opti_regs; + opti_regs->iet = 3; + prVar1->vbcore_11n = 10; + prVar1->iet_11n = 3; + prVar1->vbcore_11g = 10; + prVar1->iet_11g = 3; + prVar1->vbcore_11b = 10; + prVar1->iet_11b = 3; + prVar1->lo_fbdv_halfstep_en = 0; + prVar1->lo_fbdv_halfstep_en_tx = 0; + prVar1->lo_fbdv_halfstep_en_tx = 0; + prVar1->clkpll_reset_postdiv = 0; + prVar1->clkpll_dither_sel = 0; + return; + } + if (CONCAT31(in_register_00002029,chipv) == 1) { + tmxcss._0_4_ = 0x50005; + tmxcss[2] = 5; + iVar4 = 0x1c; + do { + iVar7 = iVar4 + -0x1c; + do { + iVar10 = iVar7; + *(undefined4 *)((int)tx_pwr_table + iVar10) = *(undefined4 *)((int)tx_pwr_table_a1 + iVar10) + ; + *(undefined4 *)((int)tx_pwr_table_origin + iVar10) = + *(undefined4 *)((int)tx_pwr_table_a1 + iVar10); + iVar7 = iVar10 + 4; + } while (iVar10 + 4 != iVar4); + iVar4 = iVar10 + 0x20; + } while (iVar4 != 0x1dc); + iVar4 = 0; + do { + puVar2 = (undefined4 *)((int)tx_pwr_ch_os_a1 + iVar4); + puVar3 = (undefined4 *)((int)tx_pwr_ch_os + iVar4); + iVar4 = iVar4 + 4; + *puVar3 = *puVar2; + } while (iVar4 != 0x38); + ppvVar6 = (void_fn **)txcal_para; + ppvVar11 = (void_fn **)txcal_para_a1; + do { + ppvVar12 = ppvVar11 + 4; + *ppvVar6 = *ppvVar11; + ppvVar6[1] = ppvVar11[1]; + ppvVar6[2] = ppvVar11[2]; + ppvVar6[3] = ppvVar11[3]; + ppvVar6 = ppvVar6 + 4; + ppvVar11 = ppvVar12; + } while (ppvVar12 != intc_irq_handlers); + opti_regs->vbcore = 0xc; + prVar1 = opti_regs; + opti_regs->iet = 5; + prVar1->vbcore_11n = 0xc; + prVar1->iet_11n = 5; + prVar1->vbcore_11g = 0xc; + prVar1->iet_11g = 5; + prVar1->vbcore_11b = 0xc; + prVar1->iet_11b = 5; + prVar1->lo_fbdv_halfstep_en = 1; + prVar1->lo_fbdv_halfstep_en_tx = 1; + prVar1->lo_fbdv_halfstep_en_tx = 1; + prVar1->clkpll_reset_postdiv = 1; + prVar1->clkpll_dither_sel = 2; + } + return; +} + + + +void rf_pri_update_tx_power_offset(uint8_t channel,int8_t *power_offset) + +{ + char cVar1; + undefined3 in_register_00002029; + int32_t *piVar2; + int32_t *piVar3; + + cVar1 = power_offset[CONCAT31(in_register_00002029,channel)]; + memcpy(tx_pwr_table,tx_pwr_table_origin,0x1c0); + piVar2 = tx_pwr_table; + do { + piVar3 = piVar2 + 7; + piVar2[5] = piVar2[5] + (int)cVar1 % 4; + piVar2[6] = piVar2[6] + ((int)cVar1 / 4) * -10; + piVar2 = piVar3; + } while (piVar3 != tx_pwr_table_origin); + rf_pri_set_gain_table_regs(); + return; +} + + + +void rf_pri_get_notch_param(uint32_t chanfreq_MHz,uint8_t *ncf_on,int32_t *ncf_freq_Hz) + +{ + uint uVar1; + int32_t iVar2; + + uVar1 = 0xd; + if (chanfreq_MHz < 0x9a9) { + uVar1 = (chanfreq_MHz - 0x96c) / 5; + } + iVar2 = rx_notch_para_40M[uVar1 * 2 + 1]; + *ncf_on = (uint8_t)rx_notch_para_40M[uVar1 * 2]; + *ncf_freq_Hz = iVar2; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_update_param(uint32_t chanfreq_MHz) + +{ + ushort uVar1; + int iVar2; + int32_t *piVar3; + int iVar4; + int iVar5; + int iVar6; + int32_t iVar7; + int iVar8; + uint32_t uVar9; + int32_t *piVar10; + + index_os_pre = 0; + index_os_pre_mdb = 0; + dvga_os_pre = 0; + up_dn = 0; + if ((chanfreq_MHz < 0x96c) || (chanfreq_MHz < 0x971)) { + iVar5 = 0; + } + else { + if (chanfreq_MHz < 0x97b) { + iVar5 = 1; + } + else { + if (chanfreq_MHz < 0x98a) { + iVar5 = 2; + } + else { + if (chanfreq_MHz < 0x999) { + iVar5 = 3; + } + else { + iVar4 = 8; + iVar5 = 7; + if (0x9a7 < chanfreq_MHz) goto LAB_23059024; + iVar5 = 4; + } + } + } + } + uVar9 = Tchannels[iVar5]; + iVar8 = 0; + if (uVar9 != chanfreq_MHz) { + iVar8 = chanfreq_MHz - uVar9; + } + iVar6 = iVar5 + 1; + iVar4 = (uint)((Tchannel_os[iVar6] - Tchannel_os[iVar5]) * iVar8) / (Tchannels[iVar6] - uVar9) + + Tchannel_os[iVar5]; + iVar5 = (uint)((Tchannel_os_low[iVar6] - Tchannel_os_low[iVar5]) * iVar8) / + (Tchannels[iVar6] - uVar9) + Tchannel_os_low[iVar5]; +LAB_23059024: + piVar3 = temps; + piVar10 = temps; + iVar8 = 0; + iVar6 = 10; + do { + iVar2 = (piVar10[4] + iVar8) - (0x14 - iVar5); + iVar8 = 0; + if (iVar6 < iVar2) { + iVar8 = iVar2 - iVar6; + iVar2 = iVar6; + } + piVar10[3] = iVar2; + iVar6 = iVar6 + -5; + piVar10 = piVar10 + -1; + } while (iVar6 != -10); + iVar8 = 0x38; + iVar5 = 0; + do { + iVar7 = (piVar3[5] - iVar5) + (0x14 - iVar4); + if (0x5f < iVar7) { + iVar7 = iVar7 + (5 - iVar4 / 4); + } + piVar3[6] = iVar7; + iVar6 = piVar3[6]; + iVar5 = 0; + if (iVar6 < iVar8) { + iVar5 = iVar8 - iVar6; + iVar6 = iVar8; + } + piVar3[6] = iVar6; + iVar8 = iVar8 + 5; + piVar3 = piVar3 + 1; + } while (iVar8 != 0x5b); + uVar1 = tmxcss[2]; + if (chanfreq_MHz < 0x986) { + uVar1 = tmxcss[1]; + } + _DAT_4000106c = (uint)uVar1 | _DAT_4000106c & 0xfffffff8; + tx_pwr_os = tx_pwr_ch_os[6]; + if (chanfreq_MHz != 0x98a) { + if (chanfreq_MHz < 0x98b) { + tx_pwr_os = tx_pwr_ch_os[2]; + if (chanfreq_MHz != 0x976) { + if (chanfreq_MHz < 0x977) { + tx_pwr_os = tx_pwr_ch_os[0]; + if ((chanfreq_MHz != 0x96c) && (tx_pwr_os = tx_pwr_ch_os[1], chanfreq_MHz != 0x971)) { + temps[4] = 0xf; + temps[5] = 0x33; + tx_pwr_os = 0; + return; + } + } + else { + tx_pwr_os = tx_pwr_ch_os[4]; + if (((chanfreq_MHz != 0x980) && (tx_pwr_os = tx_pwr_ch_os[5], chanfreq_MHz != 0x985)) && + (tx_pwr_os = tx_pwr_ch_os[3], chanfreq_MHz != 0x97b)) { + temps[4] = 0xf; + temps[5] = 0x33; + tx_pwr_os = 0; + return; + } + } + } + } + else { + tx_pwr_os = tx_pwr_ch_os[10]; + if (chanfreq_MHz != 0x99e) { + if (chanfreq_MHz < 0x99f) { + tx_pwr_os = tx_pwr_ch_os[8]; + if (((chanfreq_MHz != 0x994) && (tx_pwr_os = tx_pwr_ch_os[9], chanfreq_MHz != 0x999)) && + (tx_pwr_os = tx_pwr_ch_os[7], chanfreq_MHz != 0x98f)) { + temps[4] = 0xf; + temps[5] = 0x33; + tx_pwr_os = 0; + return; + } + } + else { + tx_pwr_os = tx_pwr_ch_os[12]; + if (((chanfreq_MHz != 0x9a8) && (tx_pwr_os = tx_pwr_ch_os[13], chanfreq_MHz != 0x9b4)) && + (tx_pwr_os = tx_pwr_ch_os[11], chanfreq_MHz != 0x9a3)) { + temps[4] = 0xf; + temps[5] = 0x33; + tx_pwr_os = 0; + return; + } + } + } + } + } + temps[4] = 0xf; + temps[5] = 0x33; + return; +} + + + +void rf_pri_xtalfreq(uint32_t xtalfreq) + +{ + if (xtalfreq == 0) { + channel_div_table[0] = 0x21638e39; + channel_div_table[1] = 0x2171c71c; + channel_div_table[2] = 0x21800000; + channel_div_table[3] = 0x218e38e4; + channel_div_table[4] = 0x219c71c7; + channel_div_table[5] = 0x21aaaaab; + channel_div_table[6] = 0x21b8e38e; + channel_div_table[7] = 0x21c71c72; + channel_div_table[8] = 0x21d55555; + channel_div_table[9] = 0x21e38e39; + channel_div_table[10] = 0x21f1c71c; + channel_div_table[11] = 0x22000000; + channel_div_table[12] = 0x220e38e4; + channel_div_table[13] = 0x221c71c7; + channel_div_table[14] = 0x222aaaab; + channel_div_table[15] = 0x2238e38e; + channel_div_table[16] = 0x22471c72; + channel_div_table[17] = 0x22555555; + channel_div_table[18] = 0x22638e39; + channel_div_table[19] = 0x2271c71c; + channel_div_table[20] = 0x22800000; + fcal_div = 0x500; + rx_notch_para_40M[4][0] = 1; + rx_notch_para_40M[6][0] = 1; + rx_notch_para_40M[7][0] = 1; + rx_notch_para_40M[12][0] = 1; + rx_notch_para_40M[1][1] = 7000000; + rx_notch_para_40M[2][1] = (int32_t)&DAT_001e8480; + rx_notch_para_40M[3][1] = -3000000; + rx_notch_para_40M[4][1] = -8000000; + rx_notch_para_40M[6][1] = 6000000; + rx_notch_para_40M[7][1] = 1000000; + rx_notch_para_40M[8][1] = -4000000; + rx_notch_para_40M[9][1] = -9000000; + rx_notch_para_40M[0][0] = 0; + rx_notch_para_40M[10][0] = 0; + rx_notch_para_40M[0][1] = 0; + rx_notch_para_40M[10][1] = 0; + rx_notch_para_40M[11][1] = 5000000; +LAB_23059426: + channel_cnt_range[2] = 0xace7; + channel_cnt_range._0_4_ = 0xa6e7a6a7; + rx_notch_para_40M[11][0] = 1; + rx_notch_para_40M[9][0] = 1; + rx_notch_para_40M[5][1] = 0; + rx_notch_para_40M[5][0] = 0; + rx_notch_para_40M[3][0] = 1; + rx_notch_para_40M[2][0] = 1; + rx_notch_para_40M[1][0] = 1; + channel_cnt_table[20] = 0xac80; + channel_cnt_table._36_4_ = 0xac39abf2; + channel_cnt_table._32_4_ = 0xababab64; + channel_cnt_table._28_4_ = 0xab1caad5; + channel_cnt_table._24_4_ = 0xaa8eaa47; + channel_cnt_table._20_4_ = 0xaa00a9b9; + channel_cnt_table._16_4_ = 0xa972a92b; + channel_cnt_table._12_4_ = 0xa8e4a89c; + channel_cnt_table._8_4_ = 0xa855a80e; + channel_cnt_table._4_4_ = 0xa7c7a780; + channel_cnt_table._0_4_ = 0xa739a6f2; +LAB_23059428: + rx_notch_para_40M[8][0] = 1; + rx_notch_para_40M[12][1] = 0; + } + else { + if (xtalfreq == 1) { + channel_div_table[0] = 0x1ed20d21; + channel_div_table[1] = 0x1edf2df3; + channel_div_table[2] = 0x1eec4ec5; + channel_div_table[3] = 0x1ef96f97; + channel_div_table[4] = 0x1f069069; + channel_div_table[5] = 0x1f13b13b; + channel_div_table[6] = 0x1f20d20d; + channel_div_table[7] = 0x1f2df2df; + channel_div_table[8] = 0x1f3b13b1; + channel_div_table[9] = 0x1f483483; + channel_div_table[10] = 0x1f555555; + channel_div_table[11] = 0x1f627627; + channel_div_table[12] = 0x1f6f96f9; + channel_div_table[13] = 0x1f7cb7cb; + channel_div_table[14] = 0x1f89d89e; + channel_div_table[15] = 0x1f96f970; + channel_div_table[16] = 0x1fa41a42; + channel_div_table[17] = 0x1fb13b14; + channel_div_table[18] = 0x1fbe5be6; + channel_div_table[19] = 0x1fcb7cb8; + channel_div_table[20] = 0x1fd89d8a; + channel_cnt_table._0_4_ = 0xa743a6fc; + channel_cnt_table._4_4_ = 0xa7d1a78a; + channel_cnt_table._8_4_ = 0xa860a819; + channel_cnt_table._12_4_ = 0xa8eea8a7; + channel_cnt_table._16_4_ = 0xa97ca935; + channel_cnt_table._20_4_ = 0xaa0aa9c3; + channel_cnt_table._24_4_ = 0xaa99aa52; + channel_cnt_table._28_4_ = 0xab27aae0; + channel_cnt_table._32_4_ = 0xabb5ab6e; + channel_cnt_table._36_4_ = 0xac43abfc; + channel_cnt_table[20] = 0xac8b; + channel_cnt_range._0_4_ = 0xa6f1a6b1; + channel_cnt_range[2] = 0xacf2; + fcal_div = 0x56b; + rx_notch_para_40M[0][1] = 6000000; + rx_notch_para_40M[1][1] = 1000000; + rx_notch_para_40M[2][1] = -4000000; + rx_notch_para_40M[3][1] = -9000000; + rx_notch_para_40M[5][1] = 7000000; + rx_notch_para_40M[6][1] = (int32_t)&DAT_001e8480; + rx_notch_para_40M[7][1] = -3000000; + rx_notch_para_40M[8][1] = -8000000; + rx_notch_para_40M[10][1] = 8000000; + rx_notch_para_40M[11][1] = 3000000; + rx_notch_para_40M[4][0] = 0; + rx_notch_para_40M[9][0] = 0; + rx_notch_para_40M[9][1] = 0; + rx_notch_para_40M[12][1] = -2000000; + rx_notch_para_40M[8][0] = xtalfreq; + rx_notch_para_40M[12][0] = xtalfreq; + } + else { + if (xtalfreq != 2) { + if (xtalfreq == 3) { + channel_div_table[0] = 0x14de38e4; + channel_div_table[1] = 0x14e71c72; + channel_div_table[2] = 0x14f00000; + channel_div_table[3] = 0x14f8e38e; + channel_div_table[4] = 0x1501c71c; + channel_div_table[5] = 0x150aaaab; + channel_div_table[6] = 0x15138e39; + channel_div_table[7] = 0x151c71c7; + channel_div_table[8] = 0x15255555; + channel_div_table[9] = 0x152e38e4; + channel_div_table[10] = 0x15371c72; + channel_div_table[11] = 0x15400000; + channel_div_table[12] = 0x1548e38e; + channel_div_table[13] = 0x1551c71c; + channel_div_table[14] = 0x155aaaab; + channel_div_table[15] = 0x15638e39; + channel_div_table[16] = 0x156c71c7; + channel_div_table[17] = 0x15755555; + channel_div_table[18] = 0x157e38e4; + channel_div_table[19] = 0x15871c72; + channel_div_table[20] = 0x15900000; + fcal_div = 0x800; + rx_notch_para_40M[0][0] = 1; + rx_notch_para_40M[10][0] = 1; + rx_notch_para_40M[0][1] = 7200000; + rx_notch_para_40M[1][1] = 2200000; + rx_notch_para_40M[2][1] = -2800000; + rx_notch_para_40M[3][1] = -7800000; + rx_notch_para_40M[8][1] = 5600000; + rx_notch_para_40M[9][1] = 600000; + rx_notch_para_40M[10][1] = -4400000; + rx_notch_para_40M[4][0] = 0; + rx_notch_para_40M[6][0] = 0; + rx_notch_para_40M[7][0] = 0; + rx_notch_para_40M[12][0] = 0; + rx_notch_para_40M[4][1] = 0; + rx_notch_para_40M[6][1] = 0; + rx_notch_para_40M[7][1] = 0; + rx_notch_para_40M[11][1] = -9400000; + goto LAB_23059426; + } + if (xtalfreq == 4) { + channel_cnt_table._0_4_ = 0xa732a6eb; + channel_cnt_table._4_4_ = 0xa7c0a779; + channel_cnt_table._8_4_ = 0xa84fa808; + channel_cnt_table._12_4_ = 0xa8dda896; + channel_cnt_table._16_4_ = 0xa96ba924; + channel_cnt_table._20_4_ = 0xa9f9a9b2; + channel_cnt_table._24_4_ = 0xaa87aa40; + channel_cnt_table._28_4_ = 0xab16aacf; + channel_cnt_table._32_4_ = 0xaba4ab5d; + channel_cnt_table._36_4_ = 0xac32abeb; + channel_cnt_table[20] = 0xac79; + channel_div_table[0] = 0x14088889; + channel_div_table[1] = 0x14111111; + channel_div_table[2] = 0x1419999a; + channel_div_table[3] = 0x14222222; + channel_div_table[4] = 0x142aaaab; + channel_div_table[5] = 0x14333333; + channel_div_table[6] = 0x143bbbbc; + channel_div_table[7] = 0x14444444; + channel_div_table[8] = 0x144ccccd; + channel_div_table[9] = 0x14555555; + channel_div_table[10] = 0x145dddde; + channel_div_table[11] = 0x14666666; + channel_div_table[12] = 0x146eeeef; + channel_div_table[13] = 0x14777777; + channel_div_table[14] = 0x14800000; + channel_div_table[15] = 0x14888889; + channel_div_table[16] = 0x14911111; + channel_div_table[17] = 0x1499999a; + channel_div_table[18] = 0x14a22222; + channel_div_table[19] = 0x14aaaaab; + channel_div_table[20] = 0x14b33333; + rx_notch_para_40M[0][0] = 0; + rx_notch_para_40M[0][1] = 0; + rx_notch_para_40M[1][0] = 0; + rx_notch_para_40M[1][1] = 0; + rx_notch_para_40M[2][0] = 0; + rx_notch_para_40M[2][1] = 0; + rx_notch_para_40M[3][0] = 0; + rx_notch_para_40M[3][1] = 0; + rx_notch_para_40M[4][0] = 1; + rx_notch_para_40M[4][1] = 8000000; + rx_notch_para_40M[5][0] = 1; + rx_notch_para_40M[5][1] = 3000000; + rx_notch_para_40M[6][0] = 1; + rx_notch_para_40M[6][1] = -2000000; + rx_notch_para_40M[7][0] = 1; + rx_notch_para_40M[7][1] = -7000000; + rx_notch_para_40M[8][0] = 0; + rx_notch_para_40M[8][1] = 0; + rx_notch_para_40M[9][0] = 0; + rx_notch_para_40M[9][1] = 0; + rx_notch_para_40M[10][0] = 0; + rx_notch_para_40M[10][1] = 0; + rx_notch_para_40M[11][0] = 0; + rx_notch_para_40M[11][1] = 0; + rx_notch_para_40M[12][0] = 1; + rx_notch_para_40M[12][1] = 8000000; + rx_notch_para_40M[13][0] = 1; + rx_notch_para_40M[13][1] = -4000000; + channel_cnt_range._0_4_ = 0xa6e0a6a0; + channel_cnt_range[2] = 0xace0; + fcal_div = 0x855; + return; + } + if (xtalfreq != 5) { + return; + } + channel_div_table[0] = 0xf690690; + channel_div_table[1] = 0xf6f96f9; + channel_div_table[2] = 0xf762762; + channel_div_table[3] = 0xf7cb7cb; + channel_div_table[4] = 0xf834835; + channel_div_table[5] = 0xf89d89e; + channel_div_table[6] = 0xf906907; + channel_div_table[7] = 0xf96f970; + channel_div_table[8] = 0xf9d89d9; + channel_div_table[9] = 0xfa41a42; + channel_div_table[10] = 0xfaaaaab; + channel_div_table[11] = 0xfb13b14; + channel_div_table[12] = 0xfb7cb7d; + channel_div_table[13] = 0xfbe5be6; + channel_div_table[14] = 0xfc4ec4f; + channel_div_table[15] = 0xfcb7cb8; + channel_div_table[16] = 0xfd20d21; + channel_div_table[17] = 0xfd89d8a; + channel_div_table[18] = 0xfdf2df3; + channel_div_table[19] = 0xfe5be5c; + channel_div_table[20] = 0xfec4ec5; + channel_cnt_table._0_4_ = 0xa734a6ed; + channel_cnt_table._4_4_ = 0xa7c2a77b; + channel_cnt_table._8_4_ = 0xa850a809; + channel_cnt_table._12_4_ = 0xa8dea897; + channel_cnt_table._16_4_ = 0xa96da925; + channel_cnt_table._20_4_ = 0xa9fba9b4; + channel_cnt_table._24_4_ = 0xaa89aa42; + channel_cnt_table._28_4_ = 0xab17aad0; + channel_cnt_table._32_4_ = 0xaba5ab5e; + channel_cnt_table._36_4_ = 0xac34abec; + channel_cnt_table[20] = 0xac7b; + channel_cnt_range._0_4_ = 0xa6e2a6a2; + channel_cnt_range[2] = 0xace2; + fcal_div = 0xad5; + rx_notch_para_40M[5][0] = 1; + rx_notch_para_40M[6][0] = 1; + rx_notch_para_40M[7][0] = 1; + rx_notch_para_40M[5][1] = 7000000; + rx_notch_para_40M[6][1] = (int32_t)&DAT_001e8480; + rx_notch_para_40M[7][1] = -3000000; + rx_notch_para_40M[0][0] = 0; + rx_notch_para_40M[1][0] = 0; + rx_notch_para_40M[2][0] = 0; + rx_notch_para_40M[3][0] = 0; + rx_notch_para_40M[4][0] = 0; + rx_notch_para_40M[9][0] = 0; + rx_notch_para_40M[10][0] = 0; + rx_notch_para_40M[11][0] = 0; + rx_notch_para_40M[12][0] = 0; + rx_notch_para_40M[0][1] = 0; + rx_notch_para_40M[1][1] = 0; + rx_notch_para_40M[2][1] = 0; + rx_notch_para_40M[3][1] = 0; + rx_notch_para_40M[4][1] = 0; + rx_notch_para_40M[8][1] = -8000000; + rx_notch_para_40M[9][1] = 0; + rx_notch_para_40M[10][1] = 0; + rx_notch_para_40M[11][1] = 0; + goto LAB_23059428; + } + channel_div_table[0] = 0x190aaaab; + channel_div_table[1] = 0x19155555; + channel_div_table[2] = 0x19200000; + channel_div_table[3] = 0x192aaaab; + channel_div_table[4] = 0x19355555; + channel_div_table[5] = 0x19400000; + channel_div_table[6] = 0x194aaaab; + channel_div_table[7] = 0x19555555; + channel_div_table[8] = 0x19600000; + channel_div_table[9] = 0x196aaaab; + channel_div_table[10] = 0x19755555; + channel_div_table[11] = 0x19800000; + channel_div_table[12] = 0x198aaaab; + channel_div_table[13] = 0x19955555; + channel_div_table[14] = 0x19a00000; + channel_div_table[15] = 0x19aaaaab; + channel_div_table[16] = 0x19b55555; + channel_div_table[17] = 0x19c00000; + channel_div_table[18] = 0x19caaaab; + channel_div_table[19] = 0x19d55555; + channel_div_table[20] = 0x19e00000; + channel_cnt_table._0_4_ = 0xa741a6fa; + channel_cnt_table._4_4_ = 0xa7d0a788; + channel_cnt_table._8_4_ = 0xa85ea817; + channel_cnt_table._12_4_ = 0xa8eca8a5; + channel_cnt_table._16_4_ = 0xa97aa933; + channel_cnt_table._20_4_ = 0xaa09a9c1; + channel_cnt_table._24_4_ = 0xaa97aa50; + channel_cnt_table._28_4_ = 0xab25aade; + channel_cnt_table._32_4_ = 0xabb3ab6c; + channel_cnt_table._36_4_ = 0xac42abfa; + channel_cnt_table[20] = 0xac89; + channel_cnt_range._0_4_ = 0xa6efa6af; + channel_cnt_range[2] = 0xacf0; + fcal_div = 0x6ab; + rx_notch_para_40M[4][0] = 1; + rx_notch_para_40M[9][0] = 1; + rx_notch_para_40M[12][0] = 1; + rx_notch_para_40M[2][1] = 10000000; + rx_notch_para_40M[3][1] = 5000000; + rx_notch_para_40M[5][1] = -5000000; + rx_notch_para_40M[6][1] = -10000000; + rx_notch_para_40M[9][1] = 7000000; + rx_notch_para_40M[10][1] = (int32_t)&DAT_001e8480; + rx_notch_para_40M[11][1] = -3000000; + rx_notch_para_40M[8][0] = 0; + rx_notch_para_40M[0][1] = 0; + rx_notch_para_40M[1][1] = 0; + rx_notch_para_40M[7][1] = 0; + rx_notch_para_40M[8][1] = 0; + rx_notch_para_40M[12][1] = -8000000; + } + rx_notch_para_40M[4][1] = 0; + rx_notch_para_40M[0][0] = rx_notch_para_40M[8][0]; + rx_notch_para_40M[1][0] = rx_notch_para_40M[8][0]; + rx_notch_para_40M[2][0] = rx_notch_para_40M[12][0]; + rx_notch_para_40M[3][0] = rx_notch_para_40M[12][0]; + rx_notch_para_40M[5][0] = rx_notch_para_40M[12][0]; + rx_notch_para_40M[6][0] = rx_notch_para_40M[12][0]; + rx_notch_para_40M[7][0] = rx_notch_para_40M[8][0]; + rx_notch_para_40M[10][0] = rx_notch_para_40M[12][0]; + rx_notch_para_40M[11][0] = rx_notch_para_40M[12][0]; + } + rx_notch_para_40M[13][0] = 0; + rx_notch_para_40M[13][1] = 0; + return; +} + + + +uint32_t rf_pri_get_vco_freq_cw(uint32_t chanfreq_MHz) + +{ + int iVar1; + + __floatunsidf(chanfreq_MHz - 0x964 >> 2); + __adddf3(); + iVar1 = __fixdfsi(); + if (0x14 < iVar1) { + iVar1 = 0x14; + } + return (uint)*(ushort *)(&(rf_calib_data->cal).field_0x8 + (iVar1 + 8) * 2) & 0xff; +} + + + +uint32_t rf_pri_get_vco_idac_cw(uint32_t chanfreq_MHz) + +{ + int iVar1; + + __floatunsidf(chanfreq_MHz - 0x964 >> 2); + __adddf3(); + iVar1 = __fixdfsi(); + if (0x14 < iVar1) { + iVar1 = 0x14; + } + return (uint)(*(ushort *)(&(rf_calib_data->cal).field_0x8 + (iVar1 + 8) * 2) >> 8) & 0x1f; +} + + + +int32_t rf_pri_get_txgain_max(void) + +{ + return tx_pwr_os_temperature + tx_pwr_table[0][6] + tx_pwr_os; +} + + + +int32_t rf_pri_get_txgain_min(void) + +{ + return tx_pwr_os_temperature + tx_pwr_table[15][6] + tx_pwr_os; +} + + + +uint32_t rf_pri_get_txgain_index(int32_t pwr,uint32_t mode) + +{ + int32_t *piVar1; + uint32_t uVar2; + + if (mode == 0) { + pwr = pwr + -0x1e; + } + piVar1 = tx_pwr_table; + uVar2 = 0; + do { + if (piVar1[6] + tx_pwr_os + tx_pwr_os_temperature <= pwr) { + return uVar2; + } + uVar2 = uVar2 + 1; + piVar1 = piVar1 + 7; + } while (uVar2 != 0x10); + return 0xf; +} + + + +void rf_pri_query_txgain_table(uint32_t index,uint32_t *rfg_index,uint32_t *dg) + +{ + if (0xf < index) { + index = 0xf; + } + *rfg_index = 7 - (index >> 1); + *dg = tx_pwr_table[index * 7 + 5]; + return; +} + + + +void rf_pri_update_dvga_os(int8_t dvga_os) + +{ + int iVar1; + int32_t *piVar2; + int8_t *piVar3; + + piVar2 = tx_pwr_table; + iVar1 = 0; + do { + piVar3 = temps_dvga + iVar1; + iVar1 = iVar1 + 1; + *piVar3 = (char)piVar2[5] + dvga_os; + piVar2 = piVar2 + 7; + } while (iVar1 != 0x10); + return; +} + + + +void rf_pri_tx_gain_comp(int32_t Tsens) + +{ + int iVar1; + int iVar2; + int32_t *piVar3; + uint uVar4; + + if (up_dn == 1) { + if ((Tthr <= Tsens) || (Tsens <= Tthr + -5)) { +LAB_2305a016: + piVar3 = temps; + iVar2 = 0xc; + do { + if (piVar3[0xc] <= Tsens) break; + iVar2 = iVar2 + -1; + piVar3 = piVar3 + -1; + } while (iVar2 != -1); + if (iVar2 < 0) { + iVar2 = 0; + } + uVar4 = iVar2 - 4; + iVar1 = temps[iVar2]; + Tthr = iVar1; + if (Tsens < 0x23) { + if (iVar1 < Tsens) { + Tthr = temps[iVar2 + 1]; + if (0x22 < temps[iVar2 + 1]) { + Tthr = iVar1; + } + } + else { + uVar4 = iVar2 - 5; + } + } + else { + if (iVar1 < 0x24) { + Tthr = temps[iVar2 + 1]; + } + } + if (index_os_pre_mdb < (int)uVar4) { + up_dn = 1; + } + else { + if ((int)uVar4 < index_os_pre_mdb) { + up_dn = -1; + } + } + if ((int)uVar4 < 1) { + dvga_os_pre = 0; + index_os_pre = uVar4; + if (uVar4 != 0) { + dvga_os_pre = 0xffffffff; + if ((uVar4 & 1) != 0) { + dvga_os_pre = 1; + } + index_os_pre = (int)(uVar4 - 1) / 2; + } + } + else { + dvga_os_pre = uVar4 + 1 & 1; + if (dvga_os_pre == 0) { + dvga_os_pre = 0xffffffff; + } + index_os_pre = (int)(uVar4 + 1) >> 1; + } + tx_pwr_os_temperature = index_os_pre * -10; + index_os_pre_mdb = uVar4; + goto LAB_23059fea; + } + } + else { + if (((up_dn != -1) || (Tsens <= Tthr)) || (Tthr + 5 <= Tsens)) goto LAB_2305a016; + } + tx_pwr_os_temperature = index_os_pre * -10; +LAB_23059fea: + rf_pri_update_dvga_os((int8_t)dvga_os_pre); + rfc_apply_tx_dvga(temps_dvga); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_txcal(void) + +{ + int32_t val; + uint32_t center; + uint val_00; + uint val_01; + uint32_t *puVar1; + int iVar2; + uint32_t *puVar3; + int32_t *piVar4; + uint val_02; + uint uVar5; + int iVar6; + + _DAT_40001014 = _DAT_40001014 & 0xff0fffff | 0x500000; + rf_pri_save_state_for_cal(); + rf_pri_manu_pu(5); + rf_pri_config_channel(); + _DAT_4000101c = _DAT_4000101c | 0x3000; + _DAT_40001084 = _DAT_40001084 | 0x80000000; + _DAT_40001064 = _DAT_40001064 | 0x400000; + iVar2 = 7; + _DAT_4000106c = (uint)tmxcss[0] | _DAT_4000106c & 0xfffffff8; + rf_pri_singen_config(0x3d); + puVar3 = txcal_para; + piVar4 = tx_pwr_table; + do { + _DAT_40001064 = *puVar3 << 0x1c | _DAT_40001064 & 0xfc3ffff | puVar3[2] << 0x12; + _DAT_40001058 = puVar3[1] << 0x10 | _DAT_40001058 & 0xfff8ffff; + _DAT_40001048 = *piVar4 << 0x1c | _DAT_40001048 & 0xce08ffff | piVar4[3] << 0x14 | 0x70000; + BL602_Delay_US(10); + val_02 = puVar3[3]; + uVar5 = val_02; + do { + uVar5 = uVar5 >> 1; + _DAT_40001214 = val_02 | _DAT_40001214 & 0xfffff800; + _DAT_40001218 = val_02 | _DAT_40001218 & 0xfffff800; + rf_pri_singen_start(); + rf_pri_start_txdfe(); + BL602_Delay_US(10); + val = rf_pri_pm_pwr_avg(1,0x400); + iVar6 = val >> 10; + printf("amp=%ld,step=%ld,adc_mean_i=%ld\r\n",val_02,uVar5,iVar6); + if (iVar6 < 0x141) { + val_00 = uVar5; + if (0xbf < iVar6) break; + } + else { + val_00 = -uVar5; + } + val_02 = val_02 + val_00; + } while (uVar5 != 0); + rf_pri_pm_pwr_avg(1,0x1000); + center = rf_pri_txcal_search_core(0,0x20,0x10,0x3d); + rf_pri_txcal_config(0,center); + uVar5 = rf_pri_txcal_search_core(1,0x20,0x10,0x3d); + _DAT_40001070 = uVar5 << 0x10 | _DAT_40001070 & 0xffc0ffff; + val_02 = rf_pri_txcal_search_core(0,center,2,0x3d); + rf_pri_txcal_config(0,val_02); + center = rf_pri_txcal_search_core(2,0x400,0x80,0x7a); + rf_pri_txcal_config(2,center); + val = rf_pri_txcal_search_core(3,0,0x40,0x7a); + rf_pri_txcal_config(3,val); + val_00 = rf_pri_txcal_search_core(2,center,0x40,0x7a); + rf_pri_txcal_config(2,val_00); + val_01 = rf_pri_txcal_search_core(3,0,0x20,0x7a); + rf_pri_txcal_config(3,val_01); + puVar1 = &rf_calib_data->inited + (iVar2 + 0xc) * 2; + puVar1[2] = puVar1[2] & 0xffffffc0 | val_02 & 0x3f; + puVar1[2] = puVar1[2] & 0xfffff03f | (uVar5 & 0x3f) << 6; + puVar1[2] = puVar1[2] & 0xff800fff | (val_00 & 0x7ff) << 0xc; + puVar1[3] = puVar1[3] & 0xfffffc00 | val_01 & 0x3ff; + printf("tosdac_i=%ld,tosdac_q=%ld,tx_iq_gain_comp=%ld,tx_iq_phase_comp=%ld\r\n",val_02,uVar5, + val_00); + iVar2 = iVar2 + -1; + puVar3 = puVar3 + 4; + piVar4 = piVar4 + 0xe; + if (iVar2 == -1) { + rf_pri_txcal_config_hw(); + _DAT_4000101c = _DAT_4000101c & 0xffffcfff; + rf_pri_restore_state_for_cal(); + _DAT_40001014 = _DAT_40001014 | 0xf00000; + _DAT_40001070 = + (*(uint *)(rf_calib_data->txcal + 3) >> 6 & 0x3f) << 0x10 | + (*(uint *)(rf_calib_data->txcal + 3) & 0x3f) << 0x18 | _DAT_40001070 & 0xc0c0ffff; + _DAT_40001600 = + *(uint *)&rf_calib_data->txcal[3].field_0x4 & 0x3ff | + *(uint *)(rf_calib_data->txcal + 3) & 0x7ff000 | _DAT_40001600 & 0xff800c00; + return; + } + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_roscal(void) + +{ + uint32_t uVar1; + uint uVar2; + + _DAT_40001014 = _DAT_40001014 & 0xffff3fff; + if ((_DAT_40001020 & 0x100) != 0) { + _DAT_40001014 = _DAT_40001014 | 0x4000; + rf_pri_save_state_for_cal(); + rf_pri_manu_pu(3); + _DAT_4000101c = _DAT_4000101c | 0x200; + rf_pri_config_channel(); + _DAT_40001048 = _DAT_40001048 & 0xffff8fff | 0x6300; + uVar1 = rf_pri_roscal_iq(1); + uVar2 = uVar1 & 0x3f; + *(uint *)(rf_calib_data->rxcal + 3) = *(uint *)(rf_calib_data->rxcal + 3) & 0xffffffc0 | uVar2; + _DAT_4000116c = _DAT_4000116c & 0xffc0ffff | uVar1 << 0x10; + printf("rosdac_i_gc3=%ld\r\n",uVar1); + *(uint *)(rf_calib_data->rxcal + 2) = *(uint *)(rf_calib_data->rxcal + 2) & 0xffffffc0 | uVar2; + _DAT_4000116c = uVar1 | _DAT_4000116c & 0xffffffc0; + printf("rosdac_i_gc2=%ld\r\n",uVar1); + *(uint *)(rf_calib_data->rxcal + 1) = *(uint *)(rf_calib_data->rxcal + 1) & 0xffffffc0 | uVar2; + _DAT_40001168 = uVar1 << 0x10 | _DAT_40001168 & 0xffc0ffff; + printf("rosdac_i_gc1=%ld\r\n",uVar1); + *(uint *)rf_calib_data->rxcal = *(uint *)rf_calib_data->rxcal & 0xffffffc0 | uVar2; + _DAT_40001168 = uVar1 | _DAT_40001168 & 0xffffffc0; + printf("rosdac_i_gc0=%ld\r\n",uVar1); + uVar1 = rf_pri_roscal_iq(0); + uVar2 = (uVar1 & 0x3f) << 6; + *(uint *)(rf_calib_data->rxcal + 3) = *(uint *)(rf_calib_data->rxcal + 3) & 0xfffff03f | uVar2; + _DAT_4000116c = _DAT_4000116c & 0xc0ffffff | uVar1 << 0x18; + printf("rosdac_q_gc3=%ld\r\n",uVar1); + *(uint *)(rf_calib_data->rxcal + 2) = *(uint *)(rf_calib_data->rxcal + 2) & 0xfffff03f | uVar2; + _DAT_4000116c = _DAT_4000116c & 0xffffc0ff | uVar1 << 8; + printf("rosdac_q_gc2=%ld\r\n",uVar1); + *(uint *)(rf_calib_data->rxcal + 1) = *(uint *)(rf_calib_data->rxcal + 1) & 0xfffff03f | uVar2; + _DAT_40001168 = uVar1 << 0x18 | _DAT_40001168 & 0xc0ffffff; + printf("rosdac_q_gc1=%ld\r\n",uVar1); + *(uint *)rf_calib_data->rxcal = *(uint *)rf_calib_data->rxcal & 0xfffff03f | uVar2; + _DAT_40001168 = uVar1 << 8 | _DAT_40001168 & 0xffffc0ff; + printf("rosdac_q_gc0=%ld\r\n",uVar1); + rf_pri_restore_state_for_cal(); + _DAT_40001014 = _DAT_40001014 | 0xc000; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_rccal(void) + +{ + rf_calib_data_tag *prVar1; + uint32_t uVar2; + uint32_t uVar3; + uint uVar4; + uint uVar5; + + _DAT_40001014 = _DAT_40001014 & 0xfff3ffff; + if ((_DAT_40001020 & 0x400) != 0) { + _DAT_40001014 = _DAT_40001014 | 0x40000; + rf_pri_save_state_for_cal(); + rf_pri_manu_pu(4); + _DAT_40001084 = _DAT_40001084 & 0xfcffffff | 0x2000000; + _DAT_4000108c = _DAT_4000108c | 0x1000; + _DAT_4000101c = _DAT_4000101c | 0x800; + uVar2 = rf_pri_rccal_iq(1); + uVar3 = rf_pri_rccal_iq(0); + prVar1 = rf_calib_data; + uVar5 = _DAT_40001080; + *(uint *)&(rf_calib_data->cal).field_0x4 = + *(uint *)&(rf_calib_data->cal).field_0x4 & 0xffffffc0 | _DAT_40001080 >> 0x18 & 0x3f; + *(uint *)&(prVar1->cal).field_0x4 = + *(uint *)&(prVar1->cal).field_0x4 & 0xfffff03f | (uVar5 >> 0x10 & 0x3f) << 6; + *(uint *)&(prVar1->cal).field_0x4 = + *(uint *)&(prVar1->cal).field_0x4 & 0xfffc0fff | (uVar5 >> 8 & 0x3f) << 0xc; + *(uint *)&(prVar1->cal).field_0x4 = + (uVar5 & 0x3f) << 0x12 | *(uint *)&(prVar1->cal).field_0x4 & 0xff03ffff; + printf("rbb_cap1_fc_i=%ld,rbb_cap2_fc_i=%ld,rbb_cap1_fc_q=%ld,rbb_cap2_fc_q=%ld\r\n", + *(uint *)&(prVar1->cal).field_0x4 & 0x3f,*(uint *)&(prVar1->cal).field_0x4 >> 0xc & 0x3f, + *(uint *)&(prVar1->cal).field_0x4 >> 6 & 0x3f, + *(uint *)&(prVar1->cal).field_0x4 >> 0x12 & 0x3f); + prVar1 = rf_calib_data; + uVar5 = *(uint *)&(rf_calib_data->cal).field_0x4 & 0x3f; + if (uVar5 < (*(uint *)&(rf_calib_data->cal).field_0x4 >> 6 & 0x3f)) { + uVar5 = *(uint *)&(rf_calib_data->cal).field_0x4 >> 6 & 0x3f; + } + if (uVar5 < (*(uint *)&(rf_calib_data->cal).field_0x4 >> 0xc & 0x3f)) { + uVar5 = *(uint *)&(rf_calib_data->cal).field_0x4 >> 0xc & 0x3f; + } + if (uVar5 < (*(uint *)&(rf_calib_data->cal).field_0x4 >> 0x12 & 0x3f)) { + uVar5 = *(uint *)&(rf_calib_data->cal).field_0x4 >> 0x12 & 0x3f; + } + uVar4 = 0x18; + if (0x27 < uVar5) { + uVar4 = 0x3f - uVar5; + } + uVar4 = uVar4 & 0xff; + *(uint *)&(rf_calib_data->cal).field_0x4 = + *(uint *)&(rf_calib_data->cal).field_0x4 & 0xffffffc0 | + *(int *)&(rf_calib_data->cal).field_0x4 + uVar4 & 0x3f; + *(uint *)&(prVar1->cal).field_0x4 = + ((*(uint *)&(prVar1->cal).field_0x4 >> 6) + uVar4 & 0x3f) << 6 | + *(uint *)&(prVar1->cal).field_0x4 & 0xfffff03f; + *(uint *)&(prVar1->cal).field_0x4 = + ((*(uint *)&(prVar1->cal).field_0x4 >> 0xc) + uVar4 & 0x3f) << 0xc | + *(uint *)&(prVar1->cal).field_0x4 & 0xfffc0fff; + *(uint *)&(prVar1->cal).field_0x4 = + ((*(uint *)&(prVar1->cal).field_0x4 >> 0x12) + uVar4 & 0x3f) << 0x12 | + *(uint *)&(prVar1->cal).field_0x4 & 0xff03ffff; + rf_pri_rccal_config(*(uint *)&(prVar1->cal).field_0x4 & 0x3f); + rf_pri_rccal_config(0,*(uint *)&(rf_calib_data->cal).field_0x4 >> 6 & 0x3f); + printf("new rbb_cap1_fc_i=%ld,rbb_cap2_fc_i=%ld,rbb_cap1_fc_q=%ld,rbb_cap2_fc_q=%ld\r\n", + *(uint *)&(rf_calib_data->cal).field_0x4 & 0x3f, + *(uint *)&(rf_calib_data->cal).field_0x4 >> 0xc & 0x3f, + *(uint *)&(rf_calib_data->cal).field_0x4 >> 6 & 0x3f, + *(uint *)&(rf_calib_data->cal).field_0x4 >> 0x12 & 0x3f); + rf_pri_restore_state_for_cal(); + if ((uVar2 == 2) || (uVar3 == 2)) { + _DAT_40001014 = _DAT_40001014 & 0xfff3ffff | 0x80000; + } + else { + _DAT_40001014 = _DAT_40001014 | 0xc0000; + } + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_lo_acal(void) + +{ + uint uVar1; + int iVar2; + int iVar3; + uint32_t *puVar4; + uint32_t *puVar5; + uint uVar6; + + _DAT_40001014 = _DAT_40001014 & 0xffffff3f | 0x40; + rf_pri_save_state_for_cal(); + rf_pri_manu_pu(6); + puVar4 = channel_div_table; + iVar3 = 0; + do { + _DAT_4000101c = _DAT_4000101c | 0x10; + _DAT_400010a4 = _DAT_400010a4 & 0xfffff8ff | 0x400; + uVar6 = 3; + uVar1 = 0x10; + _DAT_400010a0 = + (uint)*(ushort *)(&(rf_calib_data->cal).field_0x8 + (iVar3 + 8) * 2) & 0xff | + _DAT_400010a0 & 0xffe0ff00 | 0x100000; + _DAT_400010c4 = *puVar4; + BL602_Delay_US(1); + while (_DAT_400010a0 = _DAT_400010a0 & 0xffe0ffff | uVar1 << 0x10, uVar6 != 0xffffffff) { + BL602_Delay_US(1); + iVar2 = 1 << (uVar6 & 0x1f); + if ((int)(_DAT_400010a4 << 0x13) < 0) { + iVar2 = -iVar2; + } + uVar1 = uVar1 + iVar2; + uVar6 = uVar6 - 1; + } + BL602_Delay_US(1); + if ((-1 < (int)(_DAT_400010a4 << 0x13)) && (uVar1 < 0x1f)) { + uVar1 = uVar1 + 1; + } + puVar5 = (uint32_t *)((int)&rf_calib_data->inited + (iVar3 + 8) * 2); + *(ushort *)(puVar5 + 3) = *(ushort *)(puVar5 + 3) & 0xe0ff | (ushort)((uVar1 & 0x1f) << 8); + printf("%ldth channel,vco_idac_cw=%ld\r\n",iVar3,uVar1); + iVar3 = iVar3 + 1; + puVar4 = puVar4 + 1; + } while (iVar3 != 0x15); + rf_pri_restore_state_for_cal(); + _DAT_40001014 = _DAT_40001014 | 0xc0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_fcal(void) + +{ + uint cw; + uint16_t uVar1; + undefined2 extraout_var; + undefined2 extraout_var_00; + int iVar2; + uint32_t *puVar3; + uint uVar4; + uint uVar5; + uint cw_00; + uint16_t *puVar6; + uint uVar7; + + cw_00 = (uint)channel_cnt_range[0]; + uVar7 = (uint)channel_cnt_range[1]; + uVar5 = (uint)channel_cnt_range[2]; + _DAT_40001014 = _DAT_40001014 & 0xffffffcf | 0x10; + rf_pri_save_state_for_cal(); + rf_pri_manu_pu(7); + _DAT_4000101c = _DAT_4000101c | 8; + _DAT_400010a0 = _DAT_400010a0 & 0xffffff00 | 0x80; + _DAT_400010a8 = (uint)fcal_div | _DAT_400010a8 & 0xffff0000; + _DAT_400010c4 = 0x1000000; + _DAT_400010c0 = _DAT_400010c0 & 0xfffeffff | 0x1000; + _DAT_400010b8 = _DAT_400010b8 & 0xffffcfff | 0x10000; + BL602_Delay_US(10); + _DAT_400010c0 = _DAT_400010c0 | 0x10000; + _DAT_400010b8 = _DAT_400010b8 & 0xfffeffff; + BL602_Delay_US(0x32); + _DAT_400010a4 = _DAT_400010a4 & 0xfffffffc | 2; + BL602_Delay_US(0x32); + do { + uVar4 = 6; + cw = 0x80; + while (uVar4 != 0xffffffff) { + uVar1 = rf_pri_fcal_meas(cw); + if (CONCAT22(extraout_var,uVar1) < cw_00) { + iVar2 = -(1 << (uVar4 & 0x1f)); + } + else { + if (CONCAT22(extraout_var,uVar1) <= uVar7) break; + iVar2 = 1 << (uVar4 & 0x1f); + } + cw = cw + iVar2 & 0xffff; + uVar4 = uVar4 - 1; + } + if (0xe < cw) break; + printf("Unexpected cw %ld\r\n",cw); + _DAT_400010c0 = _DAT_400010c0 & 0xfffeffff; + _DAT_400010b8 = _DAT_400010b8 | 0x10000; + BL602_Delay_US(0x32); + _DAT_400010c0 = _DAT_400010c0 | 0x10000; + _DAT_400010b8 = _DAT_400010b8 & 0xfffeffff; + BL602_Delay_US(0x32); + } while( true ); + cw_00 = cw + 1 & 0xffff; + channel_cnt_opt_table[0] = rf_pri_fcal_meas(cw_00); + puVar6 = channel_cnt_opt_table; + do { + cw_00 = cw_00 - 1 & 0xffff; + uVar1 = rf_pri_fcal_meas(cw_00); + puVar6[1] = uVar1; + if (uVar5 < CONCAT22(extraout_var_00,uVar1)) break; + puVar6 = puVar6 + 1; + } while (cw_00 != (cw - 0x26 & 0xffff)); + iVar2 = 0; + uVar5 = 0; + puVar6 = channel_cw_table; + do { + while (cw_00 = uVar5 & 0xffff, + channel_cnt_opt_table[uVar5] < *(ushort *)((int)channel_cnt_table + iVar2)) { + uVar5 = (int)((cw_00 + 1) * 0x10000) >> 0x10; + } + *(short *)((int)channel_cw_table + iVar2) = ((short)cw + 2) - (short)cw_00; + if ((int)uVar5 < 1) { + uVar5 = 0; + } + else { + uVar5 = (int)((cw_00 - 1) * 0x10000) >> 0x10; + } + iVar2 = iVar2 + 2; + } while (iVar2 != 0x2a); + rf_pri_restore_state_for_cal(); + iVar2 = 0; + do { + puVar3 = (uint32_t *)((int)&rf_calib_data->inited + (iVar2 + 8) * 2); + iVar2 = iVar2 + 1; + *(ushort *)(puVar3 + 3) = *(ushort *)(puVar3 + 3) & 0xff00 | *puVar6 & 0xff; + printf("%ldth channel,lo_vco_freq_cw=%ld\r\n"); + puVar6 = puVar6 + 1; + } while (iVar2 != 0x15); + _DAT_40001014 = _DAT_40001014 | 0x30; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_full_cal(void) + +{ + _DAT_40001220 = _DAT_40001220 & 0xffffff9f | 0x61; + rf_pri_start_txdfe(); + rf_pri_fcal(); + rf_pri_lo_acal(); + rf_pri_roscal(); + rf_pri_rccal(); + rf_pri_txcal(); + _DAT_4000100c = _DAT_4000100c | 6; + _DAT_40001220 = _DAT_40001220 & 0xffffe61c; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_restore_cal_reg(void) + +{ + _DAT_40001168 = + (*(uint *)(rf_calib_data->rxcal + 1) >> 6 & 0x3f) << 0x18 | + (*(uint *)rf_calib_data->rxcal >> 6 & 0x3f) << 8 | + *(uint *)rf_calib_data->rxcal & 0x3f | _DAT_40001168 & 0xc0c0c0c0 | + (*(uint *)(rf_calib_data->rxcal + 1) & 0x3f) << 0x10; + _DAT_4000116c = + (*(uint *)(rf_calib_data->rxcal + 3) >> 6 & 0x3f) << 0x18 | + (*(uint *)(rf_calib_data->rxcal + 2) >> 6 & 0x3f) << 8 | + *(uint *)(rf_calib_data->rxcal + 2) & 0x3f | _DAT_4000116c & 0xc0c0c0c0 | + (*(uint *)(rf_calib_data->rxcal + 3) & 0x3f) << 0x10; + _DAT_40001080 = + (*(uint *)&(rf_calib_data->cal).field_0x4 >> 6 & 0x3f) << 0x10 | + (*(uint *)&(rf_calib_data->cal).field_0x4 >> 0xc & 0x3f) << 8 | + (*(uint *)&(rf_calib_data->cal).field_0x4 & 0x3f) << 0x18 | _DAT_40001080 & 0xc0c0c0c0 | + *(uint *)&(rf_calib_data->cal).field_0x4 >> 0x12 & 0x3f; + rf_pri_txcal_config_hw(); + _DAT_40001070 = + (*(uint *)(rf_calib_data->txcal + 3) >> 6 & 0x3f) << 0x10 | + (*(uint *)(rf_calib_data->txcal + 3) & 0x3f) << 0x18 | _DAT_40001070 & 0xc0c0ffff; + _DAT_40001600 = + *(uint *)(rf_calib_data->txcal + 3) & 0x7ff000 | _DAT_40001600 & 0xff800c00 | + *(uint *)&rf_calib_data->txcal[3].field_0x4 & 0x3ff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rf_pri_init(uint8_t reset,uint8_t chipv) + +{ + undefined3 in_register_00002029; + int iVar1; + + iVar1 = CONCAT31(in_register_00002029,reset); + rf_pri_chipv(chipv); + init_fast = (uint32_t)(iVar1 == 0); + _DAT_4000f814 = _DAT_4000f814 & 0xfffff0ff | 0x300; + _DAT_4000f030 = _DAT_4000f030 & 0xf0ffffff | 0x8000000; + _DAT_40001030 = _DAT_40001030 | 0x1001; + _DAT_4000f884 = _DAT_4000f884 | 4; + if (iVar1 != 0) { + BL602_Delay_MS(10); + } + _DAT_40001064 = _DAT_40001064 & 0xffff8008 | opti_regs->vbcore << 8 | opti_regs->iet << 4 | 0x4002 + ; + _DAT_40001128 = + _DAT_40001128 & 0xff800fff | opti_regs->vbcore_11n << 0x10 | opti_regs->iet_11n << 0xc | + 0x400000; + _DAT_4000112c = + (_DAT_4000112c & 0xfffff800 | opti_regs->vbcore_11g << 4 | opti_regs->iet_11g) & 0xff800fff | + 0x400 | opti_regs->vbcore_11b << 0x10 | opti_regs->iet_11b << 0xc | 0x400000; + _DAT_40001090 = _DAT_40001090 | 0x10000; + _DAT_400010b8 = opti_regs->lo_fbdv_halfstep_en << 4 | _DAT_400010b8 & 0xffffffef; + _DAT_40001138 = + (_DAT_40001138 & 0xfffffffc | opti_regs->lo_fbdv_halfstep_en_tx << 1 | + opti_regs->lo_fbdv_halfstep_en_tx) & 0xfffcfff7 | 0x300; + _DAT_40001130 = _DAT_40001130 & 0xfffefffe; + _DAT_4000e400 = opti_regs->clkpll_reset_postdiv << 1 | _DAT_4000e400 & 0xfffffffd; + _DAT_4000e418 = opti_regs->clkpll_dither_sel << 0x18 | _DAT_4000e418 & 0xfcffffff; + _DAT_4000108c = _DAT_4000108c & 0xfffffffc | 2; + _DAT_4000f030 = _DAT_4000f030 & 0xfff0ffff | 0xc0000; + rf_pri_set_gain_table_regs(); + _DAT_4000e404 = _DAT_4000e404 | 0x10000; + _DAT_4000e41c = _DAT_4000e41c | 0xff; + if (iVar1 == 0) { + rf_pri_restore_cal_reg(); + return; + } + rf_pri_full_cal(); + return; +} + + + +void rf_pri_update_power_offset(int32_t *power_offset) + +{ + undefined4 uVar1; + int iVar2; + + iVar2 = 0; + do { + uVar1 = *(undefined4 *)((int)power_offset + iVar2); + *(undefined4 *)((int)tx_pwr_ch_os_a1 + iVar2) = uVar1; + *(undefined4 *)((int)tx_pwr_ch_os + iVar2) = uVar1; + iVar2 = iVar2 + 4; + } while (iVar2 != 0x38); + return; +} + + + +int phyif_utils_decode(phyif_utils_recvtable_t *vec,int8_t *ppm) + +{ + char cVar1; + int8_t iVar2; + SItype SVar3; + + cVar1 = *(char *)((int)&vec->recvtable5 + 3); + if (((*(ushort *)((int)&vec->recvtable2 + 2) & 7) < 2) && ((vec->recvtable1 >> 0xc & 0xf) < 4)) { + __floatsidf(-(int)cVar1); + __muldf3(); + SVar3 = __fixdfsi(); + iVar2 = (int8_t)SVar3; + } + else { + iVar2 = (int8_t)((int)CONCAT11(*(undefined *)&vec->recvtable6,cVar1) / 0x7a); + } + *ppm = iVar2; + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void sysctrl_init(void) + +{ + _DAT_44900068 = 0x8000000c; + _DAT_449000e0 = _DAT_449000e0 | 0x1ff00; + return; +} + + + +void intc_spurious(void) + +{ + assert_err("0","module",0x36); + return; +} + + + +void intc_enable_irq(int index) + +{ + *(int *)(((index >> 5) + 0x11244004) * 4) = 1 << (index & 0x1fU); + return; +} + + + +void intc_init(void) + +{ + intc_enable_irq(0x3f); + intc_enable_irq(0x3e); + intc_enable_irq(0x3d); + intc_enable_irq(0x18); + intc_enable_irq(0x19); + intc_enable_irq(0x1a); + intc_enable_irq(0x1b); + intc_enable_irq(0x1c); + intc_enable_irq(0x1d); + intc_enable_irq(0x1e); + intc_enable_irq(0x1f); + intc_enable_irq(0x20); + intc_enable_irq(0x21); + intc_enable_irq(0x23); + intc_enable_irq(0x37); + intc_enable_irq(0x35); + intc_enable_irq(0x32); + intc_enable_irq(0x34); + intc_enable_irq(0x36); + intc_enable_irq(10); + intc_enable_irq(0xb); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mac_irq(void) + +{ + void_fn *pvVar1; + + if ((_DAT_44910000 == 0) && (_DAT_44910004 == 0)) { + return; + } + pvVar1 = intc_irq_handlers[_DAT_44910040]; + if (pvVar1 == (void_fn *)0x0) { + assert_err("intc_irq_handlers[irq_idx] != NULL","module",0x9d); + } + (*pvVar1)(); + ipc_emb_notify(); + return; +} + + + +void bl_irq_handler(void) + +{ + ipc_host_disable_irq_e2a(); + ke_evt_set(0x40000000); + ipc_emb_notify(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_pwr_mgt_setf(uint8_t pwrmgt) + +{ + uint uVar1; + undefined3 in_register_00002029; + + uVar1 = CONCAT31(in_register_00002029,pwrmgt) << 2; + if ((uVar1 & 0xfffffffb) != 0) { + assert_err("(((uint32_t)pwrmgt << 2) & ~((uint32_t)0x00000004)) == 0","module",0x952); + } + _DAT_44b0004c = _DAT_44b0004c & 0xfffffffb | uVar1; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +chan_ctxt_tag * chan_get_next_chan(void) + +{ + int iVar1; + int iVar2; + chan_ctxt_tag *pcVar3; + uint uVar4; + ushort uVar5; + + iVar2 = _DAT_44b00120; + iVar1 = DAT_4201e2e0; + if (DAT_4201e2f0 != (chan_ctxt_tag *)0x0) { + if ((DAT_4201e2e0 != 0) && (*(char *)(DAT_4201e2e0 + 10) == '\x02')) { + return DAT_4201e2f0; + } + if (-1 < (_DAT_44b00120 + 0x1400) - DAT_4201e314) { + return DAT_4201e2f0; + } + if (DAT_4201e2f0->status == '\x04') { + return DAT_4201e2f0; + } + } + pcVar3 = DAT_4201e2f0; + if ((DAT_4201e2e0 != 0) && (*(int *)(DAT_4201e2e0 + 4) - DAT_4201e314 < 0)) { + pcVar3 = vif_info_tab[*(byte *)(DAT_4201e2e0 + 8)].chan_ctxt; + if (pcVar3 == (chan_ctxt_tag *)0x0) { + assert_err("p_next_chan_entry","module",0x129); + } + if (-1 < (iVar2 + 0x1400) - *(int *)(iVar1 + 4)) goto LAB_2305b3e0; + uVar4 = 0; + if (pcVar3->nb_res_slots < pcVar3->nb_rem_slots) { + uVar4 = (uint)(ushort)(pcVar3->nb_rem_slots - pcVar3->nb_res_slots); + } + if (((uint)(*(int *)(iVar1 + 4) - iVar2) >> 10 & 0xffff) <= uVar4) { + return pcVar3; + } + } + uVar5 = 0; + if (chan_ctxt_pool[0].status != '\0') { + pcVar3 = chan_ctxt_pool; + uVar5 = chan_ctxt_pool[0].nb_rem_slots; + } + if ((chan_ctxt_pool[1].status != '\0') && (uVar5 <= chan_ctxt_pool[1].nb_rem_slots)) { + pcVar3 = chan_ctxt_pool + 1; + uVar5 = chan_ctxt_pool[1].nb_rem_slots; + } + if ((chan_ctxt_pool[2].status != '\0') && (uVar5 <= chan_ctxt_pool[2].nb_rem_slots)) { + return chan_ctxt_pool + 2; + } +LAB_2305b3e0: + if (pcVar3 == (chan_ctxt_tag *)0x0) { + assert_err("p_next_chan_entry","module",0x175); + } + return pcVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void chan_conn_less_delay_prog(void) + +{ + DAT_4201e340 = DAT_4201e340 | 0x10; + mm_timer_set((mm_timer_tag *)&DAT_4201e328,_DAT_44b00120 + 30000); + return; +} + + + +void chan_upd_nb_rem_slots(uint32_t current_time) + +{ + ushort uVar1; + ushort uVar2; + int in_a1; + uint uVar3; + + uVar1 = *(ushort *)current_time; + uVar3 = (uint)(in_a1 - DAT_4201e33c) >> 10 & 0xffff; + uVar2 = (ushort)uVar3; + if (uVar1 < uVar3) { + uVar2 = uVar1; + } + *(ushort *)current_time = uVar1 - uVar2; + return; +} + + + +_Bool chan_tbtt_detect_conflict(void) + +{ + byte bVar1; + int in_a0; + int in_a1; + + if (((in_a0 - in_a1 < 0) || (bVar1 = 1, (in_a1 + 0x2800) - in_a0 < 0)) && + (bVar1 = 0, -1 < in_a1 - in_a0)) { + bVar1 = ~(byte)((uint)((in_a0 - in_a1) + 0x2800) >> 0x18) >> 7; + } + return (_Bool)bVar1; +} + + + +void chan_tbtt_insert(chan_tbtt_tag *p_tbtt_entry) + +{ + bool bVar1; + co_list_hdr list_hdr; + char cVar2; + _Bool _Var3; + undefined3 extraout_var; + undefined3 extraout_var_00; + co_list_hdr cVar4; + uint uVar5; + uint uVar6; + co_list_hdr prev_element; + co_list_hdr cVar7; + + list_hdr = (co_list_hdr)0x0; + cVar2 = '\0'; + cVar4 = DAT_4201e2e0; + prev_element = (co_list_hdr)0x0; + while (cVar4 != (co_list_hdr)0x0) { + if (cVar4 == (co_list_hdr)p_tbtt_entry) { + assert_err("p_elem != p_tbtt_entry","module",0x668); + } + uVar5 = p_tbtt_entry->time; + uVar6 = *(uint *)((int)cVar4 + 4); + cVar7 = cVar4; + if (*(char *)((int)cVar4 + 10) == '\x02') { + if ((uVar5 < uVar6) || + (_Var3 = chan_tbtt_detect_conflict(), CONCAT31(extraout_var_00,_Var3) != 0)) { +LAB_2305b550: + cVar2 = '\x01'; + bVar1 = false; + list_hdr = (co_list_hdr)p_tbtt_entry; + goto LAB_2305b598; + } + } + else { + _Var3 = chan_tbtt_detect_conflict(); + if (CONCAT31(extraout_var,_Var3) == 0) { + if (uVar5 < uVar6) break; + } + else { + if (p_tbtt_entry->priority <= *(byte *)((int)cVar4 + 9)) goto LAB_2305b550; + if (list_hdr == (co_list_hdr)0x0) { + list_hdr = cVar4; + } + cVar2 = cVar2 + '\x01'; + cVar7 = prev_element; + } + } + cVar4 = *(co_list_hdr *)cVar4; + prev_element = cVar7; + } + bVar1 = true; +LAB_2305b598: + while (cVar2 = cVar2 + -1, cVar2 != -1) { + if (list_hdr == (co_list_hdr)0x0) { + assert_err("p_delay_elem","module",0x6b1); + } + if (list_hdr != (co_list_hdr)p_tbtt_entry) { + if (*(char *)((int)list_hdr + 10) == '\x01') { + mm_timer_clear((mm_timer_tag *)&DAT_4201e2f8); + *(undefined *)((int)list_hdr + 10) = 0; + } + co_list_extract((co_list *)&DAT_4201e2e0,(co_list_hdr *)list_hdr); + } + co_list_push_back((co_list *)&DAT_4201e2e8,(co_list_hdr *)list_hdr); + list_hdr = *(co_list_hdr *)list_hdr; + } + if (!bVar1) { + return; + } + co_list_insert_after + ((co_list *)&DAT_4201e2e0,(co_list_hdr *)prev_element,(co_list_hdr *)p_tbtt_entry); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void chan_upd_ctxt_status(chan_ctxt_tag *p_chan_entry,uint8_t next_status) + +{ + undefined3 in_register_0000202d; + int iVar1; + ushort uVar2; + int iVar3; + uint32_t value; + + iVar1 = CONCAT31(in_register_0000202d,next_status); + if (iVar1 == 2) { + value = 0; + if (2 < p_chan_entry->idx) goto LAB_2305b610; + iVar3 = 4000; + } + else { + value = 0; + if (iVar1 != 4) goto LAB_2305b610; + if (p_chan_entry->idx < 3) { + if (1 < DAT_4201e342) { + if ((p_chan_entry->nb_res_slots < p_chan_entry->nb_rem_slots) && + (uVar2 = p_chan_entry->nb_rem_slots - p_chan_entry->nb_res_slots, 4 < uVar2)) { + iVar3 = (uint)uVar2 << 10; + DAT_4201e33c = _DAT_44b00120; + goto LAB_2305b60e; + } + } + iVar1 = 5; + value = 0; + goto LAB_2305b610; + } + iVar3 = (uint)p_chan_entry->nb_rem_slots << 10; + } +LAB_2305b60e: + value = iVar3 + _DAT_44b00120; +LAB_2305b610: + p_chan_entry->status = (uint8_t)iVar1; + if (value != 0) { + DAT_4201e320 = p_chan_entry; + mm_timer_set((mm_timer_tag *)&DAT_4201e318,value); + return; + } + if (iVar1 != 3) { + mm_timer_clear((mm_timer_tag *)&DAT_4201e318); + return; + } + return; +} + + + +void chan_switch_start(chan_ctxt_tag *p_chan_entry) + +{ + undefined4 *puVar1; + + if (DAT_4201e2f0 == p_chan_entry) { + if ((1 < DAT_4201e342) && (DAT_4201e2f0->idx < 3)) { + chan_upd_ctxt_status(p_chan_entry,'\x04'); + return; + } + } + else { + if (DAT_4201e2f4 == (chan_ctxt_tag *)0x0) { + DAT_4201e2f4 = p_chan_entry; + chan_upd_ctxt_status(p_chan_entry,'\x02'); + puVar1 = (undefined4 *)ke_msg_alloc(0x60,0,0xff,4); + *puVar1 = 0x2305bcd8; + ke_msg_send(); + return; + } + } + return; +} + + + +void chan_conn_less_delay_evt(void *env) + +{ + chan_ctxt_tag *p_chan_entry; + + if ((DAT_4201e340 & 1) == 0) { + if ((DAT_4201e340 & 2) == 0) { + return; + } + if ((DAT_4201e340 & 8) != 0) { + assert_err("(chan_env.status & CO_BIT(CHAN_ENV_SCAN_BIT)) == 0","module",0x2ce); + } + p_chan_entry = chan_ctxt_pool + 3; + DAT_4201e340 = DAT_4201e340 & 0xfd | 8; + } + else { + if ((DAT_4201e340 & 4) != 0) { + assert_err("(chan_env.status & CO_BIT(CHAN_ENV_ROC_BIT)) == 0","module",0x2c0); + } + p_chan_entry = chan_ctxt_pool + 4; + DAT_4201e340 = DAT_4201e340 & 0xfe | 4; + } + if (DAT_4201e2f4 != 0) { + return; + } + chan_switch_start(p_chan_entry); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void chan_tbtt_switch_evt(void *env) + +{ + ushort uVar1; + undefined4 uVar2; + ushort uVar3; + chan_ctxt_tag *p_chan_entry; + + uVar2 = _DAT_44b00120; + if ((1 < DAT_4201e342) && ((DAT_4201e340 & 0xc) == 0)) { + p_chan_entry = vif_info_tab[*(byte *)((int)env + 8)].chan_ctxt; + if ((DAT_4201e2f4 == (chan_ctxt_tag *)0x0) || (DAT_4201e2f4 == p_chan_entry)) { + *(undefined *)((int)env + 9) = 0; + chan_upd_nb_rem_slots(DAT_4201e2f0 + 0x12); + uVar1 = p_chan_entry->nb_res_slots; + uVar3 = uVar1; + if (10 < uVar1) { + uVar3 = 10; + } + p_chan_entry->nb_res_slots = uVar1 - uVar3; + DAT_4201e33c = uVar2; + *(undefined *)((int)env + 10) = 2; + if (DAT_4201e2f4 == (chan_ctxt_tag *)0x0) { + chan_switch_start(p_chan_entry); + return; + } + } + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void chan_tbtt_schedule(chan_tbtt_tag *p_tbtt_entry) + +{ + void *pvVar1; + chan_tbtt_tag *p_tbtt_entry_00; + uint uVar2; + uint32_t uVar3; + + if (p_tbtt_entry != (chan_tbtt_tag *)0x0) { + chan_tbtt_insert(p_tbtt_entry); + while (DAT_4201e2e8 != 0) { + p_tbtt_entry_00 = (chan_tbtt_tag *)co_list_pop_front((co_list *)&DAT_4201e2e8); + uVar2 = (uint)p_tbtt_entry_00->vif_index; + if (vif_info_tab[uVar2].type == '\0') { + uVar3 = sta_info_tab[vif_info_tab[uVar2].u[4]].bcn_int; + } + else { + uVar3 = (uint)*(ushort *)(vif_info_tab[uVar2].u + 0x2e2) << 10; + } + p_tbtt_entry_00->time = uVar3 + p_tbtt_entry_00->time; + if (p_tbtt_entry_00->priority < 5) { + p_tbtt_entry_00->priority = p_tbtt_entry_00->priority + 1; + } + chan_tbtt_insert(p_tbtt_entry_00); + } + } + pvVar1 = DAT_4201e2e0; + if ((DAT_4201e2e0 != (void *)0x0) && (*(char *)((int)DAT_4201e2e0 + 10) == '\0')) { + if ((*(int *)((int)DAT_4201e2e0 + 4) - _DAT_44b00120) + -2000 < 0) { + chan_tbtt_switch_evt(DAT_4201e2e0); + return; + } + DAT_4201e300 = DAT_4201e2e0; + *(undefined *)((int)DAT_4201e2e0 + 10) = 1; + mm_timer_set((mm_timer_tag *)&DAT_4201e2f8,*(uint32_t *)((int)pvVar1 + 4)); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void chan_cde_evt(void *env) + +{ + int iVar1; + uint uVar2; + int iVar3; + chan_ctxt_tag *p_chan_entry; + int iVar4; + co_list_hdr *pcVar5; + co_list_hdr cVar6; + undefined2 uVar7; + ushort uVar8; + uint uVar9; + + iVar4 = _DAT_44b00120; + p_chan_entry = DAT_4201e2f4; + if ((1 < DAT_4201e342) && (uVar2 = (uint)DAT_4201e340 & 0x2c, (DAT_4201e340 & 0x2c) == 0)) { + mm_timer_set((mm_timer_tag *)&DAT_4201e308,DAT_4201e338 + _DAT_44b00120); + DAT_4201e33c = iVar4; + uVar9 = 0; + cVar6 = (co_list_hdr)vif_mgmt_env.used_list.first; + while (cVar6 != (co_list_hdr)0x0) { + pcVar5 = ((co_list_hdr *)((int)cVar6 + 0x40))->next; + if (pcVar5 != (co_list_hdr *)0x0) { + uVar2 = uVar2 + 1 & 0xff; + if (((td_env[*(byte *)((int)cVar6 + 0x57)].status & 3) != 0) || + (*(char *)&((co_list_hdr *)((int)cVar6 + 0x58))->next == '\0')) { + uVar9 = uVar9 + 1 & 0xff; + } + *(undefined2 *)&pcVar5[4].next = 0; + *(undefined2 *)&pcVar5[5].next = 0; + } + cVar6 = *(co_list_hdr *)cVar6; + } + if (uVar2 != DAT_4201e338 / 0xc800) { + assert_warn("nb_vifs == (chan_env.cde_dur_us / (CHAN_VIF_NB_SLOTS * CHAN_SLOT_DURATION_US))", + "module",0x268); + } + if ((uVar9 == 0) || (uVar2 == uVar9)) { + iVar3 = 0; + iVar4 = 0x32; + } + else { + iVar4 = 10; + iVar3 = (int)((uVar2 - uVar9) * 0x280000 >> 0x10) / (int)uVar9; + } + cVar6 = (co_list_hdr)vif_mgmt_env.used_list.first; + while (cVar6 != (co_list_hdr)0x0) { + pcVar5 = ((co_list_hdr *)((int)cVar6 + 0x40))->next; + if (pcVar5 != (co_list_hdr *)0x0) { + if (((td_env[*(byte *)((int)cVar6 + 0x57)].status & 3) != 0) || + (iVar1 = iVar4, *(char *)&((co_list_hdr *)((int)cVar6 + 0x58))->next == '\0')) { + iVar1 = iVar3 + 0x32; + } + uVar7 = (undefined2)(((uint)*(ushort *)&pcVar5[4].next + iVar1) * 0x10000 >> 0x10); + *(undefined2 *)&pcVar5[4].next = uVar7; + *(undefined2 *)((int)&pcVar5[4].next + 2) = uVar7; + if (*(char *)((int)cVar6 + 0x56) == '\0') { + uVar2 = sta_info_tab[*(byte *)&((co_list_hdr *)((int)cVar6 + 0x60))->next].bcn_int; + } + else { + uVar2 = (uint)*(ushort *)((int)cVar6 + 0x33e) << 10; + } + uVar8 = (ushort)(DAT_4201e338 / uVar2); + if (DAT_4201e338 / uVar2 == 0) { + uVar8 = 1; + } + *(ushort *)&pcVar5[5].next = (uVar8 & 0xff) * 10 + *(short *)&pcVar5[5].next; + } + cVar6 = *(co_list_hdr *)cVar6; + } + if (DAT_4201e2f0 != (chan_ctxt_tag *)0x0) { + chan_upd_ctxt_status(DAT_4201e2f0,'\x01'); + } + p_chan_entry = chan_get_next_chan(); + if (env == (void *)0x0) { + chan_switch_start(p_chan_entry); + return; + } + } + DAT_4201e2f4 = p_chan_entry; + return; +} + + +/* +Unable to decompile 'chan_pre_switch_channel' +Cause: Exception while decompiling 2305bae4: Decompiler process died + +*/ + + +void chan_goto_idle_cb(void) + +{ + undefined uVar1; + co_list_hdr *pcVar2; + co_list_hdr cVar3; + uint8_t uVar4; + undefined3 extraout_var; + int iVar5; + + mm_force_idle_req(); + pcVar2 = DAT_4201e2f0; + cVar3 = (co_list_hdr)vif_mgmt_env.used_list.first; + if (((DAT_4201e2f0 != (co_list_hdr *)0x0) && ((DAT_4201e340 & 0x20) == 0)) && + ((ps_env.ps_on == false || ((ps_env.prevent_sleep & 8) != 0)))) { + iVar5 = 0; + blmac_pwr_mgt_setf('\x01'); + while (cVar3 != (co_list_hdr)0x0) { + if ((((pcVar2 == ((co_list_hdr *)((int)cVar3 + 0x40))->next) && + (*(char *)((int)cVar3 + 0x56) == '\0')) && + (*(char *)&((co_list_hdr *)((int)cVar3 + 0x58))->next != '\0')) && + (*(char *)&((co_list_hdr *)((int)cVar3 + 0x60))->next != -1)) { + uVar1 = *(undefined *)((int)&pcVar2[5].next + 2); + *(undefined *)((int)&pcVar2[5].next + 2) = 6; + uVar4 = txl_frame_send_null_frame + (*(uint8_t *)&((co_list_hdr *)((int)cVar3 + 0x60))->next,chan_tx_cfm, + (void *)0x0); + if (CONCAT31(extraout_var,uVar4) == 0) { + iVar5 = iVar5 + 1; + } + *(undefined *)((int)&pcVar2[5].next + 2) = uVar1; + } + cVar3 = *(co_list_hdr *)cVar3; + } + DAT_4201e341 = (undefined)iVar5; + if (iVar5 != 0) { + chan_upd_ctxt_status(DAT_4201e2f4,'\x03'); + mm_active(); + return; + } + } + chan_pre_switch_channel(); + return; +} + + + +void chan_tx_cfm(void *dummy,uint32_t status) + +{ + if (DAT_4201e341 == '\0') { + assert_err("chan_env.cfm_cnt","module",0x48f); + } + DAT_4201e341 = DAT_4201e341 + -1; + if (DAT_4201e341 == '\0') { + mm_force_idle_req(); + chan_pre_switch_channel(); + return; + } + return; +} + + +/* +Unable to decompile 'chan_ctxt_op_evt' +Cause: Exception while decompiling 2305be10: Decompiler process died + +*/ + + +void chan_init(void) + +{ + chan_ctxt_tag *__s; + int iVar1; + + __s = chan_ctxt_pool; + memset(&chan_env,0,0x74); + iVar1 = 0; + do { + memset(__s,0,0x1c); + *(undefined2 *)(&__s->channel + 1) = 0xff; + *(undefined *)((int)&__s->nb_res_slots + 3) = 0xff; + if (iVar1 < 3) { + co_list_push_back((co_list *)&chan_env,(co_list_hdr *)__s); + } + else { + if (iVar1 == 3) { + chan_ctxt_pool[3].channel.center2_freq = 0; + chan_ctxt_pool[3].channel.type = '\0'; + } + } + iVar1 = iVar1 + 1; + __s = __s + 1; + } while (iVar1 != 5); + DAT_4201e2fc = chan_tbtt_switch_evt; + DAT_4201e30c = chan_cde_evt; + DAT_4201e310 = 0; + DAT_4201e31c = chan_ctxt_op_evt; + DAT_4201e32c = chan_conn_less_delay_evt; + return; +} + + + +void chan_scan_req(uint8_t band,uint16_t freq,int8_t pwr,uint32_t duration_us,uint8_t vif_index) + +{ + if (chan_ctxt_pool[3].idx != -1) { + assert_err("p_scan_chan->idx == CHAN_CTXT_UNUSED","module",0x8a1); + } + chan_ctxt_pool[3].taskid = 0xff; + chan_ctxt_pool[3]._22_2_ = 0x301; + chan_ctxt_pool[3].nb_rem_slots = (uint16_t)(duration_us >> 10); + if ((DAT_4201e340 & 0x10) == 0) { + chan_ctxt_pool[3].channel.band = band; + chan_ctxt_pool[3].channel.prim20_freq = freq; + chan_ctxt_pool[3].channel.center1_freq = freq; + chan_ctxt_pool[3].channel.tx_power = pwr; + chan_ctxt_pool[3].vif_index = vif_index; + DAT_4201e340 = DAT_4201e340 | 2; + chan_conn_less_delay_prog(); + return; + } + chan_ctxt_pool[3].channel.band = band; + chan_ctxt_pool[3].channel.prim20_freq = freq; + chan_ctxt_pool[3].channel.center1_freq = freq; + chan_ctxt_pool[3].channel.tx_power = pwr; + chan_ctxt_pool[3].taskid = 0xff; + chan_ctxt_pool[3]._22_2_ = 0x301; + chan_ctxt_pool[3].vif_index = vif_index; + DAT_4201e340 = DAT_4201e340 | 2; + return; +} + + + +uint8_t chan_roc_req(mm_remain_on_channel_req *req,ke_task_id_t taskid) + +{ + byte bVar1; + undefined2 in_register_0000202e; + + if (req->op_code == '\0') { + if (chan_ctxt_pool[4].idx == -1) { + chan_ctxt_pool[4].idx = '\x04'; + chan_ctxt_pool[4].channel.band = req->band; + chan_ctxt_pool[4].channel.type = req->type; + chan_ctxt_pool[4].channel.prim20_freq = req->prim20_freq; + chan_ctxt_pool[4].channel.center1_freq = req->center1_freq; + chan_ctxt_pool[4].channel.center2_freq = req->center2_freq; + chan_ctxt_pool[4].status = '\x01'; + chan_ctxt_pool[4].nb_rem_slots = (uint16_t)(req->duration_ms * 1000 >> 10); + chan_ctxt_pool[4].vif_index = req->vif_index; + chan_ctxt_pool[4].channel.tx_power = req->tx_power; + chan_ctxt_pool[4].taskid = taskid; + if (CONCAT22(in_register_0000202e,taskid) != 0) { + bVar1 = DAT_4201e340 & 0x10; + if ((DAT_4201e340 & 0x10) != 0) { + chan_ctxt_pool[4].status = '\x01'; + chan_ctxt_pool[4].idx = '\x04'; + DAT_4201e340 = DAT_4201e340 | 1; + return '\0'; + } + DAT_4201e340 = DAT_4201e340 | 1; + chan_conn_less_delay_prog(); + return bVar1; + } + DAT_4201e340 = DAT_4201e340 | 4; + if (DAT_4201e2f4 != 0) { + chan_ctxt_pool[4].status = '\x01'; + chan_ctxt_pool[4].idx = '\x04'; + return '\0'; + } + chan_switch_start(chan_ctxt_pool + 4); + return '\0'; + } + } + else { + if (req->op_code == '\x01') { + if (chan_ctxt_pool[4].idx != -1) { + if (chan_ctxt_pool[4].status < 4) { + if (chan_ctxt_pool[4].status < 2) { + if (chan_ctxt_pool[4].status == '\x01') { + DAT_4201e340 = DAT_4201e340 & 0xfe; + } + } + else { + DAT_4201e2f4 = 0; + DAT_4201e340 = DAT_4201e340 & 0xfb; + } + } + else { + if (chan_ctxt_pool[4].status == '\x04') { + mm_timer_clear((mm_timer_tag *)&DAT_4201e318); + chan_ctxt_op_evt(chan_ctxt_pool + 4); + } + } + chan_ctxt_pool[4].idx = -1; + if ((DAT_4201e340 & 0x12) == 0x10) { + DAT_4201e340 = DAT_4201e340 & 0xef; + mm_timer_clear((mm_timer_tag *)&DAT_4201e328); + DAT_4201e340 = DAT_4201e340 & 0xef; + } + } + return '\0'; + } + } + return '\x01'; +} + + + +uint8_t chan_ctxt_add(mm_chan_ctxt_add_req *p_add_req,uint8_t *idx) + +{ + uint8_t uVar1; + int iVar2; + co_list_hdr *pcVar3; + int iVar4; + chan_ctxt_tag *pcVar5; + + pcVar5 = chan_ctxt_pool; + iVar4 = 0; + do { + if (pcVar5->idx != -1) { + iVar2 = memcmp(p_add_req,&pcVar5->channel,8); + if (iVar2 == 0) { + *idx = (uint8_t)iVar4; + return (uint8_t)iVar2; + } + } + iVar4 = iVar4 + 1; + pcVar5 = pcVar5 + 1; + } while (iVar4 != 3); + pcVar3 = co_list_pop_front((co_list *)&chan_env); + if (pcVar3 != (co_list_hdr *)0x0) { + uVar1 = (char)((int)(pcVar3 + -0x10807891) >> 2) * -0x49; + *(uint8_t *)((int)&pcVar3[5].next + 3) = uVar1; + *idx = uVar1; + *(uint8_t *)&pcVar3[1].next = p_add_req->band; + *(uint8_t *)((int)&pcVar3[1].next + 1) = p_add_req->type; + *(uint16_t *)&pcVar3[2].next = p_add_req->center1_freq; + *(uint16_t *)((int)&pcVar3[2].next + 2) = p_add_req->center2_freq; + *(uint16_t *)((int)&pcVar3[1].next + 2) = p_add_req->prim20_freq; + *(int8_t *)&pcVar3[3].next = p_add_req->tx_power; + } + return (uint8_t)(pcVar3 == (co_list_hdr *)0x0); +} + + + +void chan_ctxt_del(uint8_t chan_idx) + +{ + undefined3 in_register_00002029; + int iVar1; + + iVar1 = CONCAT31(in_register_00002029,chan_idx); + if (chan_ctxt_pool[iVar1].idx == -1) { + assert_err("p_chan_entry->idx != CHAN_CTXT_UNUSED","module",0x989); + } + if (chan_ctxt_pool[iVar1].nb_linked_vif != '\0') { + assert_err("p_chan_entry->nb_linked_vif == 0","module",0x98b); + } + co_list_push_back((co_list *)&chan_env,(co_list_hdr *)(chan_ctxt_pool + iVar1)); + memset(chan_ctxt_pool + iVar1,0,0x1c); + chan_ctxt_pool[iVar1].taskid = 0xff; + chan_ctxt_pool[iVar1].idx = -1; + return; +} + + +/* +Unable to decompile 'chan_ctxt_update' +Cause: Exception while decompiling 2305c3ae: Decompiler process died + +*/ + + +void chan_tbtt_switch_update(vif_info_tag *p_vif_entry,uint32_t tbtt_time) + +{ + if ((((p_vif_entry->chan_ctxt != (chan_ctxt_tag *)0x0) && (p_vif_entry->chan_ctxt->status != '\0') + ) && ((p_vif_entry->tbtt_switch).time != tbtt_time - 0x9c4)) && + (((p_vif_entry->tbtt_switch).time = tbtt_time - 0x9c4, 1 < DAT_4201e342 && + ((p_vif_entry->tbtt_switch).status != '\x02')))) { + (p_vif_entry->tbtt_switch).status = '\0'; + co_list_extract((co_list *)&DAT_4201e2e0,(co_list_hdr *)&p_vif_entry->tbtt_switch); + chan_tbtt_schedule(&p_vif_entry->tbtt_switch); + return; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void chan_bcn_to_evt(vif_info_tag *p_vif_entry) + +{ + ushort uVar1; + int iVar2; + chan_ctxt_tag *p_chan_entry; + ushort uVar3; + uint uVar4; + + iVar2 = _DAT_44b00120; + if ((p_vif_entry->tbtt_switch).status == '\x02') { + (p_vif_entry->tbtt_switch).status = '\0'; + p_chan_entry = DAT_4201e2f0; + co_list_extract((co_list *)&DAT_4201e2e0,(co_list_hdr *)&p_vif_entry->tbtt_switch); + if (((1 < DAT_4201e342) && + (chan_tbtt_schedule(&p_vif_entry->tbtt_switch), (DAT_4201e340 & 0xc) == 0)) && + (DAT_4201e2f4 == 0)) { + chan_upd_nb_rem_slots((uint32_t)&p_chan_entry->nb_rem_slots); + uVar1 = p_chan_entry->nb_res_slots; + if (uVar1 != 0) { + uVar4 = (uint)(iVar2 - DAT_4201e33c) >> 10 & 0xffff; + uVar3 = (ushort)uVar4; + if (uVar1 < uVar4) { + uVar3 = uVar1; + } + p_chan_entry->nb_res_slots = uVar1 - uVar3; + } + DAT_4201e33c = iVar2; + p_chan_entry = chan_get_next_chan(); + if (DAT_4201e2f0 != p_chan_entry) { + chan_switch_start(p_chan_entry); + return; + } + } + } + return; +} + + + +void chan_bcn_detect_start(vif_info_tag *p_vif_entry) + +{ + byte bVar1; + chan_ctxt_tag *pcVar2; + undefined *puVar3; + + pcVar2 = p_vif_entry->chan_ctxt; + if (pcVar2 == (chan_ctxt_tag *)0x0) { + assert_err("p_chan_entry","module",0xb19); + } + if (((DAT_4201e340 & 0x40) == 0) && (1 < DAT_4201e342)) { + bVar1 = p_vif_entry->u[4]; + puVar3 = (undefined *)ke_msg_alloc(0x46,0,0,0x14); + *puVar3 = 0; + puVar3[1] = p_vif_entry->index; + puVar3[2] = (pcVar2->channel).band; + puVar3[3] = (pcVar2->channel).type; + *(uint16_t *)(puVar3 + 4) = (pcVar2->channel).prim20_freq; + *(uint16_t *)(puVar3 + 6) = (pcVar2->channel).center1_freq; + *(uint16_t *)(puVar3 + 8) = (pcVar2->channel).center2_freq; + *(uint *)(puVar3 + 0xc) = (sta_info_tab[bVar1].bcn_int - 5000) / 1000; + puVar3[0x10] = (pcVar2->channel).tx_power; + ke_msg_send(); + DAT_4201e340 = DAT_4201e340 | 0x40; + } + return; +} + + + +_Bool chan_is_on_channel(vif_info_tag *p_vif_entry) + +{ + chan_ctxt_tag *pcVar1; + + if (DAT_4201e2f0 != 0) { + if (*(byte *)(DAT_4201e2f0 + 0x17) < 3) { + pcVar1 = (chan_ctxt_tag *)((int)p_vif_entry->chan_ctxt - DAT_4201e2f0); + } + else { + pcVar1 = (chan_ctxt_tag *)((uint)*(byte *)(DAT_4201e2f0 + 0x19) - (uint)p_vif_entry->index); + } + return (_Bool)(pcVar1 == (chan_ctxt_tag *)0x0); + } + return false; +} + + + +_Bool chan_is_tx_allowed(vif_info_tag *p_vif_entry) + +{ + bool bVar1; + undefined3 extraout_var; + + bVar1 = (bool)chan_is_on_channel(p_vif_entry); + if ((CONCAT31(extraout_var,bVar1) != 0) && (DAT_4201e2f4 != 0)) { + bVar1 = *(char *)(DAT_4201e2f0 + 0x16) == '\x06'; + } + return (_Bool)bVar1; +} + + + +_Bool chan_is_on_operational_channel(vif_info_tag *p_vif_entry) + +{ + bool bVar1; + + bVar1 = false; + if ((DAT_4201e2f0 != (chan_ctxt_tag *)0x0) && (bVar1 = false, DAT_4201e2f0->idx < 3)) { + bVar1 = p_vif_entry->chan_ctxt == DAT_4201e2f0; + } + return (_Bool)bVar1; +} + + + +void chan_update_tx_power(chan_ctxt_tag *p_chan_entry) + +{ + int8_t iVar1; + int8_t iVar2; + char cVar3; + + if (p_chan_entry->nb_linked_vif == '\0') { + return; + } + iVar2 = '\x7f'; + if ((p_chan_entry == vif_info_tab[0].chan_ctxt) && + (iVar2 = vif_info_tab[0].user_tx_power, + vif_info_tab[0].tx_power < vif_info_tab[0].user_tx_power)) { + iVar2 = vif_info_tab[0].tx_power; + } + iVar1 = iVar2; + if (p_chan_entry == vif_info_tab[1].chan_ctxt) { + iVar1 = vif_info_tab[1].user_tx_power; + if (iVar2 < vif_info_tab[1].user_tx_power) { + iVar1 = iVar2; + } + cVar3 = vif_info_tab[1].tx_power; + if (vif_info_tab[1].tx_power < iVar1) goto LAB_2305c726; + } + cVar3 = iVar1; + if (iVar1 == '\x7f') { + return; + } +LAB_2305c726: + (p_chan_entry->channel).tx_power = cVar3; + return; +} + + + +void chan_ctxt_link(uint8_t vif_idx,uint8_t chan_idx) + +{ + uint8_t uVar1; + undefined3 in_register_00002029; + undefined3 in_register_0000202d; + int iVar2; + chan_ctxt_tag *p_chan_entry; + + iVar2 = CONCAT31(in_register_0000202d,chan_idx); + p_chan_entry = chan_ctxt_pool + iVar2; + if (vif_info_tab[CONCAT31(in_register_00002029,vif_idx)].chan_ctxt != (chan_ctxt_tag *)0x0) { + assert_err("p_vif_entry->chan_ctxt == NULL","module",0x99c); + } + if (chan_ctxt_pool[iVar2].idx == -1) { + assert_err("p_chan_entry->idx != CHAN_CTXT_UNUSED","module",0x99d); + } + uVar1 = chan_ctxt_pool[iVar2].nb_linked_vif + '\x01'; + DAT_4201e338 = DAT_4201e338 + 0xc800; + vif_info_tab[CONCAT31(in_register_00002029,vif_idx)].chan_ctxt = p_chan_entry; + chan_ctxt_pool[iVar2].nb_linked_vif = uVar1; + if (uVar1 == '\x01') { + chan_ctxt_pool[iVar2].status = '\x01'; + DAT_4201e342 = DAT_4201e342 + '\x01'; + co_list_push_back((co_list *)&p_chan_entry,(co_list_hdr *)p_chan_entry); + if (DAT_4201e2f4 == 0) { + if ((DAT_4201e340 & 0xc) == 0) { + if (DAT_4201e342 == '\x01') { + chan_switch_start(p_chan_entry); + } + else { + chan_cde_evt((void *)0x0); + } + } + } + else { + *(undefined *)(DAT_4201e2f4 + 0x16) = 1; + DAT_4201e2f4 = 0; + } + } + chan_update_tx_power(p_chan_entry); + return; +} + + + +void chan_ctxt_unlink(uint8_t vif_idx) + +{ + chan_ctxt_tag *pcVar1; + chan_ctxt_tag *p_chan_entry; + undefined3 in_register_00002029; + int iVar2; + + iVar2 = CONCAT31(in_register_00002029,vif_idx); + p_chan_entry = vif_info_tab[iVar2].chan_ctxt; + if (p_chan_entry == (chan_ctxt_tag *)0x0) { + assert_err("p_chan_entry != NULL","module",0x9e4); + } + co_list_extract((co_list *)&DAT_4201e2e0,(co_list_hdr *)&vif_info_tab[iVar2].tbtt_switch); + vif_info_tab[iVar2].tbtt_switch.status = '\0'; + vif_info_tab[iVar2].chan_ctxt = (chan_ctxt_tag *)0x0; + p_chan_entry->nb_linked_vif = p_chan_entry->nb_linked_vif + -1; + pcVar1 = DAT_4201e2f4; + if (p_chan_entry->status != '\0') { + DAT_4201e338 = DAT_4201e338 + -0xc800; + if (p_chan_entry->nb_linked_vif != '\0') goto LAB_2305c942; + co_list_extract((co_list *)&p_chan_entry,(co_list_hdr *)p_chan_entry); + p_chan_entry->status = '\0'; + DAT_4201e342 = DAT_4201e342 - 1; + if (DAT_4201e2f0 == p_chan_entry) { + DAT_4201e2f0 = (chan_ctxt_tag *)0x0; +LAB_2305c90e: + if (pcVar1 == (chan_ctxt_tag *)0x0) { + if (DAT_4201e342 < 2) { + if (DAT_4201e342 == 1) { + chan_switch_start(p_chan_entry); + } + } + else { + chan_cde_evt((void *)0x0); + } + goto LAB_2305c934; + } + } + else { + if (pcVar1 != p_chan_entry) goto LAB_2305c90e; + DAT_4201e2f4 = (chan_ctxt_tag *)0x0; + } + DAT_4201e340 = DAT_4201e340 | 0x20; + } +LAB_2305c934: + if (p_chan_entry->nb_linked_vif == '\0') { + chan_ctxt_del(p_chan_entry->idx); + } +LAB_2305c942: + chan_tbtt_schedule((chan_tbtt_tag *)0x0); + chan_update_tx_power(p_chan_entry); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_dma_init(void) + +{ + co_list_init((co_list *)&hal_dma_env); + hal_dma_env.lli_cnt[0] = (uint16_t)_DAT_44a000a4; + co_list_init(hal_dma_env.prog + 1); + hal_dma_env.lli_cnt[1] = (uint16_t)_DAT_44a000ac; + return; +} + + +/* +Unable to decompile 'hal_dma_push' +Cause: Exception while decompiling 2305c9a6: Decompiler process died + +*/ + +/* +Unable to decompile 'hal_dma_evt' +Cause: Exception while decompiling 2305ca36: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +u8_l blmac_soft_reset_getf(void) + +{ + uint uVar1; + + uVar1 = _DAT_44b08050; + if ((_DAT_44b08050 & 0xfffffffe) != 0) { + assert_err("(localVal & ~((uint32_t)0x00000001)) == 0","module",0x11d); + } + return (u8_l)uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_wt_2_crypt_clk_ratio_setf(u8_l wt2cryptclkratio) + +{ + undefined3 in_register_00002029; + + _DAT_44b000f0 = CONCAT31(in_register_00002029,wt2cryptclkratio) | _DAT_44b000f0 & 0xfffffffc; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_rx_flow_cntrl_en_setf(void) + +{ + _DAT_44b00054 = _DAT_44b00054 & 0xfffeffff | 0x10000; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_key_sto_ram_reset_setf(void) + +{ + _DAT_44b0004c = _DAT_44b0004c & 0xffffdfff | 0x2000; + return; +} + + +/* +Unable to decompile 'hal_machw_idle_req' +Cause: Exception while decompiling 2305caf8: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_machw_stop(void) + +{ + u8_l uVar1; + undefined3 extraout_var; + + _DAT_44b08050 = 1; + do { + uVar1 = blmac_soft_reset_getf(); + } while (CONCAT31(extraout_var,uVar1) != 0); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_machw_init(void) + +{ + uint uVar1; + u8_l wt2cryptclkratio; + uint8_t uVar2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + uint uVar3; + uint uVar4; + + _DAT_44b08050 = 1; + do { + wt2cryptclkratio = blmac_soft_reset_getf(); + } while (CONCAT31(extraout_var,wt2cryptclkratio) != 0); + _DAT_44b00404 = 0x24f637; + _DAT_44b00400 = 0x49; + _DAT_44920004 = 0x5010001f; + uVar2 = phy_get_mac_freq(); + _uVar2 = CONCAT31(extraout_var_00,uVar2); + uVar1 = _DAT_44b000e4 & 0xff; + uVar3 = _DAT_44b000e4 & 0xffffff00 | 0x28; + uVar4 = (((_DAT_44b000e4 & 0x3ff00) >> 8) * _uVar2) / uVar1 << 8; + _DAT_44b000e4 = uVar3; + if ((uVar4 & 0xfc0000) != 0) { + assert_err("(((uint32_t)txrfdelayinmacclk << 8) & ~((uint32_t)0x0003FF00)) == 0","module",0x1d59 + ); + } + _DAT_44b000e4 = (_DAT_44b000e4 & 0xfffc00ff | uVar4 & 0xffff00) & 0xf003ffff | 0x2200000; + _DAT_44b000e8 = + (((_DAT_44b000e8 >> 8 & 0xffff) * _uVar2) / uVar1 & 0xffff) << 8 | _DAT_44b000e8 & 0xff0000ff + ; + uVar3 = _DAT_44b000ec & 0xc00fffff | 0x2700000; + uVar4 = (((_DAT_44b000ec & 0xffc00) >> 10) * _uVar2) / uVar1 << 10; + _DAT_44b000ec = uVar3; + if ((uVar4 & 0x3f00000) != 0) { + assert_err("(((uint32_t)txdelayrfoninmacclk << 10) & ~((uint32_t)0x000FFC00)) == 0","module", + 0x1ea2); + } + wt2cryptclkratio = '\x03'; + _DAT_44b000ec = _DAT_44b000ec & 0xfff00000 | uVar4 & 0x3fffc00 | 0xb4; + if ((0x1d < _uVar2) && (wt2cryptclkratio = '\x02', 0x3b < _uVar2)) { + wt2cryptclkratio = '\x01'; + } + blmac_wt_2_crypt_clk_ratio_setf(wt2cryptclkratio); + _DAT_44b000f4 = + (((_DAT_44b000f4 >> 8 & 0xffff) * _uVar2) / uVar1 & 0xffff) << 8 | _DAT_44b000f4 & 0xff0000ff + ; + _DAT_44b000f8 = + (((_DAT_44b000f8 >> 8 & 0xffff) * _uVar2) / uVar1 & 0xffff) << 8 | _DAT_44b000f8 & 0xff0000ff + ; + uVar3 = ((_DAT_44b00104 >> 0x14 & 0x3ff) * _uVar2) / uVar1 << 0x14; + if ((uVar3 & 0xc0000000) != 0) { + assert_err("(((uint32_t)rifstoinmacclk << 20) & ~((uint32_t)0x3FF00000)) == 0","module",0x228a); + } + uVar3 = _DAT_44b00104 & 0xc00fffff | uVar3; + uVar4 = (((_DAT_44b00104 & 0xffc00) >> 10) * _uVar2) / uVar1 << 10; + _DAT_44b00104 = uVar3; + if ((uVar4 & 0x3f00000) != 0) { + assert_err("(((uint32_t)rifsinmacclk << 10) & ~((uint32_t)0x000FFC00)) == 0","module",0x22a4); + } + uVar3 = _DAT_44b00104 & 0xfff003ff | uVar4 & 0x3fffc00; + uVar1 = ((_DAT_44b00104 & 0x3ff) * _uVar2) / uVar1; + _DAT_44b00104 = uVar3; + if ((uVar1 & 0xfc00) != 0) { + assert_err("(((uint32_t)txdmaprocdlyinmacclk << 0) & ~((uint32_t)0x000003FF)) == 0","module", + 0x22be); + } + _DAT_44b00104 = _DAT_44b00104 & 0xfffffc00 | uVar1 & 0xffff; + _DAT_44b08074 = 0x8373f14c; + _DAT_44b0004c = _DAT_44b0004c & 0xfffff7ff; + if (_DAT_44b000d8 >> 0x18 < 0x11) { + assert_err("MM_STA_TO_KEY(NX_REMOTE_STA_MAX - 1) <= blmac_sta_key_max_index_getf()","module", + 0x124); + } + printf("[WF] [KEY] [CFG] nVAP is %d, endidx %d, startidx %d\r\n",2,0x11,8); + _DAT_44b000d8 = 0x21108; + _DAT_44b08080 = 0x800a07c0; + _DAT_44b0004c = _DAT_44b0004c | 0x4000780; + blmac_rx_flow_cntrl_en_setf(); + _DAT_44b00060 = 0x7fffffde; + _DAT_44b00114 = 0x3010a; + _DAT_44b00064 = 0xff900064; + _DAT_44b00150 = 0x1000; + _DAT_44b00224 = 0; + _DAT_44b000a0 = 0x2020; + _DAT_44b0004c = _DAT_44b0004c & 0xffffefff | 0x1000; + blmac_key_sto_ram_reset_setf(); + _DAT_44b00510 = 0x1c25; + _DAT_44b00310 = _DAT_44b00310 | 0x80; + uVar2 = phy_get_ntx(); + uVar1 = (CONCAT31(extraout_var_01,uVar2) + 1) * 0x4000000; + if ((uVar1 & 0xe0000000) != 0) { + assert_err("(((uint32_t)maxphyntx << 26) & ~((uint32_t)0x1C000000)) == 0","module",0x1539); + } + _DAT_44b0004c = _DAT_44b0004c & 0xfdffffff | 0x2000000; + _DAT_44b0009c = _DAT_44b0009c & 0xe3ffffff | uVar1; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_machw_disable_int(void) + +{ + _DAT_44b08074 = _DAT_44b08074 & 0x7fffffff; + _DAT_44b08080 = _DAT_44b08080 & 0x7fffffff; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_machw_reset(void) + +{ + char "hal_machw_reset" [16]; + + if ((_DAT_44b00038 & 0xf) != 0) { + helper_record_all_states("hal_machw_reset"); + } + _DAT_44b0004c = _DAT_44b0004c & 0xffffff7f; + _DAT_44b00038 = 0; + _DAT_44b00054 = 0x7c; + ps_env.prevent_sleep = ps_env.prevent_sleep & 0xfffffffb; + blmac_rx_flow_cntrl_en_setf(); + _DAT_44b0004c = _DAT_44b0004c | 0x80; + _DAT_44b08070 = 0x37ff187; + _DAT_44b08074 = _DAT_44b08074 & 0x7fffffff | 0x80000000; + _DAT_44b0807c = 0xffffffff; + _DAT_44b08080 = _DAT_44b08080 & 0x7fffffff | 0x80000000; + _DAT_44b0808c = _DAT_44b0808c & 0xffffffc0; + return; +} + + + +// WARNING: Removing unreachable block (ram,0x2305d0b8) +// WARNING: Removing unreachable block (ram,0x2305d0c4) +// WARNING: Removing unreachable block (ram,0x2305d0ce) + +u8_l hal_machw_search_addr(mac_addr_conflict171 *addr) + +{ + // WARNING: Do nothing block with infinite loop + do { + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_machw_monitor_mode(void) + +{ + _DAT_44b08074 = _DAT_44b08074 & 0xfffffffc; + mm_env.rx_filter_umac = 0x7fffffde; + _DAT_44b00060 = mm_env.rx_filter_lmac_enable | 0x7fffffde; + _DAT_44b0004c = _DAT_44b0004c & 0xfffe3fff | 0xc700; + blmac_key_sto_ram_reset_setf(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +_Bool hal_machw_sleep_check(void) + +{ + uint uVar1; + + uVar1 = 0; + while (((1 << (uVar1 & 0x1f) & _DAT_44b0808c) == 0 || + (-1 < (-2000 - _DAT_44b00120) + *(int *)(&DAT_44b00128 + uVar1 * 4)))) { + uVar1 = uVar1 + 1; + if (uVar1 == 9) { + return true; + } + } + if (-1 < (5000 - _DAT_44b00120) + *(int *)(&DAT_44b00128 + uVar1 * 4)) { + return false; + } + assert_err("!hal_machw_time_past(blmac_abs_timer_get(i) + 5000)","module",0x208); + return false; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void hal_machw_gen_handler(void) + +{ + uint uVar1; + uint uVar2; + char *condition; + int line; + + uVar2 = _DAT_44b08074 & _DAT_44b0806c; + _DAT_44b08070 = uVar2; + if ((uVar2 & 0x40001) != 0) { + ke_evt_set(0x400000); + } + if ((uVar2 & 0x80002) != 0) { + ke_evt_set(0x200000); + } + if ((uVar2 & 4) != 0) { + if ((_DAT_44b00038 & 0xf) == 0) { + _DAT_44b0808c = _DAT_44b0808c & 0xffffffdf; + ps_env.prevent_sleep = ps_env.prevent_sleep & 0xfffffffb; + ke_evt_set(0x800000); + } + else { + assert_rec("blmac_current_state_getf() == HW_IDLE","module",0x8c); + } + } + uVar1 = _DAT_44b08084; + if ((uVar2 & 8) != 0) { + _DAT_44b08088 = _DAT_44b08084; + if ((_DAT_44b08084 & 0x100) != 0) { + ke_evt_set(0x4000000); + } + if ((uVar1 & 0x40) != 0) { + rxl_timeout_int_handler(); + } + if ((uVar1 & 0x80) != 0) { + ke_evt_set(0x8000000); + } + if ((uVar1 & 1) != 0) { + assert_rec("HAL_AC0_TIMER_BIT timeout ","module",0x22f); + } + if ((uVar1 & 2) == 0) { + if ((uVar1 & 4) == 0) { + if ((uVar1 & 8) == 0) { + if ((uVar1 & 0x10) == 0) { + if ((uVar1 & 0x20) == 0) goto LAB_2305d26c; + line = 0x236; + condition = "!(timer_pending & HAL_IDLE_TIMER_BIT)"; + } + else { + line = 0x235; + condition = "!(timer_pending & HAL_BCN_TIMER_BIT)"; + } + } + else { + line = 0x234; + condition = "!(timer_pending & HAL_AC3_TIMER_BIT)"; + } + } + else { + line = 0x233; + condition = "!(timer_pending & HAL_AC2_TIMER_BIT)"; + } + } + else { + line = 0x232; + condition = "!(timer_pending & HAL_AC1_TIMER_BIT)"; + } + assert_rec(condition,"module",line); + } +LAB_2305d26c: + if ((uVar2 & 0x80) == 0) { + if ((uVar2 & 0x100) == 0) { + if ((int)(uVar2 << 0x13) < 0) { + line = 0x27a; + condition = "!(genirq_pending & NXMAC_PT_ERROR_BIT)"; + } + else { + if ((int)(uVar2 << 0x12) < 0) { + line = 0x27b; + condition = "!(genirq_pending & NXMAC_AC_0_TX_DMA_DEAD_BIT)"; + } + else { + if ((int)(uVar2 << 0x11) < 0) { + line = 0x27c; + condition = "!(genirq_pending & NXMAC_AC_1_TX_DMA_DEAD_BIT)"; + } + else { + if ((int)(uVar2 << 0x10) < 0) { + line = 0x27d; + condition = "!(genirq_pending & NXMAC_AC_2_TX_DMA_DEAD_BIT)"; + } + else { + if ((int)(uVar2 << 0xf) < 0) { + line = 0x27e; + condition = "!(genirq_pending & NXMAC_AC_3_TX_DMA_DEAD_BIT)"; + } + else { + if ((int)(uVar2 << 0xe) < 0) { + line = 0x27f; + condition = "!(genirq_pending & NXMAC_BCN_TX_DMA_DEAD_BIT)"; + } + else { + if ((int)(uVar2 << 10) < 0) { + line = 0x280; + condition = "!(genirq_pending & NXMAC_MAC_PHYIF_UNDER_RUN_BIT)"; + } + else { + if ((int)(uVar2 << 9) < 0) { + line = 0x281; + condition = "!(genirq_pending & NXMAC_PHY_ERR_BIT)"; + } + else { + if ((int)(uVar2 << 7) < 0) { + line = 0x282; + condition = "!(genirq_pending & NXMAC_RX_HEADER_DMA_DEAD_BIT)"; + } + else { + if ((int)(uVar2 << 6) < 0) { + line = 0x283; + condition = "!(genirq_pending & NXMAC_RX_PAYLOAD_DMA_DEAD_BIT)"; + } + else { + if (-1 < (int)(uVar2 << 0xb)) { + return; + } + line = 0x284; + condition = "!(genirq_pending & NXMAC_HW_ERR_BIT)"; + } + } + } + } + } + } + } + } + } + } + } + else { + line = 0x279; + condition = "!(genirq_pending & NXMAC_RX_FIFO_OVER_FLOW_BIT)"; + } + } + else { + line = 0x278; + condition = "!(genirq_pending & NXMAC_RX_DMA_EMPTY_BIT)"; + } + assert_rec(condition,"module",line); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_rx_filter_set(void) + +{ + _DAT_44b00060 = mm_env.rx_filter_lmac_enable | mm_env.rx_filter_umac; + return; +} + + + +int element_notify_status_enabled + (cfg_element_entry *entry,void *arg1,void *arg2,CFG_ELEMENT_TYPE_OPS ops) + +{ + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_ap_setf(uint8_t ap) + +{ + undefined3 in_register_00002029; + + _DAT_44b0004c = CONCAT31(in_register_00002029,ap) << 1 | _DAT_44b0004c & 0xfffffffd; + return; +} + + + +uchar ascii_to_hex(char asccode) + +{ + char cVar1; + byte bVar2; + + bVar2 = asccode - 0x30; + if (9 < bVar2) { + if ((byte)(asccode + 0x9fU) < 6) { + cVar1 = -0x57; + } + else { + if (5 < (byte)(asccode + 0xbfU)) { + return '\0'; + } + cVar1 = -0x37; + } + bVar2 = asccode + cVar1; + } + return (uchar)bVar2; +} + + + +undefined4 element_notify_time_last_received_set(void) + +{ + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void blmac_encr_cntrl_pack + (uint8_t newread,uint8_t newwrite,uint16_t keyindexram,uint8_t ctyperam, + uint8_t vlanidram,uint8_t sppram,uint8_t usedefkeyram,uint8_t clenram) + +{ + uint uVar1; + undefined3 in_register_00002035; + undefined3 in_register_00002039; + undefined3 in_register_0000203d; + undefined3 in_register_00002041; + undefined3 in_register_00002045; + uint uVar2; + + uVar2 = CONCAT31(in_register_00002039,vlanidram) << 4; + if ((uVar2 & 0xffffff0f) != 0) { + assert_err("(((uint32_t)vlanidram << 4) & ~((uint32_t)0x000000F0)) == 0","module",0x1873); + } + uVar1 = CONCAT31(in_register_0000203d,sppram) << 2; + if ((uVar1 & 0xfffffff3) != 0) { + assert_err("(((uint32_t)sppram << 2) & ~((uint32_t)0x0000000C)) == 0","module",0x1874); + } + _DAT_44b000c4 = + (uint)newread << 0x1f | CONCAT31(in_register_00002045,clenram) | + CONCAT31(in_register_00002041,usedefkeyram) << 1 | uVar1 | uVar2 | + CONCAT31(in_register_00002035,ctyperam) << 8 | (uint)keyindexram << 0x10 | + (uint)newwrite << 0x1e; + return; +} + + + +undefined4 element_notify_keepalive_received(void) + +{ + return 0; +} + + + +// WARNING: Removing unreachable block (ram,0x2305d62a) +// WARNING: Removing unreachable block (ram,0x2305d634) +// WARNING: Removing unreachable block (ram,0x2305d65c) +// WARNING: Removing unreachable block (ram,0x2305d650) +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t hal_machw_rx_duration(rx_hd *rhd,uint16_t len) + +{ + if ((""[rhd->recvec1a >> 0xc & 0xf] & 0x80) != 0) { + assert_err("(((uint32_t)ppdumcsindex << 0) & ~((uint32_t)0x0000007F)) == 0","module",0x1a99); + } + do { + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_env_max_ampdu_duration_set(void) + +{ + mm_env.ampdu_max_dur[0] = 0x96; + if (((_DAT_44b00200 >> 0xc & 0xffff) != 0) && ((_DAT_44b00200 >> 0xc & 0xffff) < 0x97)) { + mm_env.ampdu_max_dur[0] = (uint16_t)(_DAT_44b00200 >> 0xc); + } + mm_env.ampdu_max_dur[1] = 0x96; + if (((_DAT_44b00204 >> 0xc & 0xffff) != 0) && ((_DAT_44b00204 >> 0xc & 0xffff) < 0x97)) { + mm_env.ampdu_max_dur[1] = (uint16_t)(_DAT_44b00204 >> 0xc); + } + mm_env.ampdu_max_dur[2] = 0x96; + if (((_DAT_44b00208 >> 0xc & 0xffff) != 0) && ((_DAT_44b00208 >> 0xc & 0xffff) < 0x97)) { + mm_env.ampdu_max_dur[2] = (uint16_t)(_DAT_44b00208 >> 0xc); + } + mm_env.ampdu_max_dur[3] = 0x96; + if (((_DAT_44b0020c >> 0xc & 0xffff) != 0) && ((_DAT_44b0020c >> 0xc & 0xffff) < 0x97)) { + mm_env.ampdu_max_dur[3] = (uint16_t)(_DAT_44b0020c >> 0xc); + } + mm_env.ampdu_max_dur[4] = mm_env.ampdu_max_dur[3]; + return; +} + + + +void mm_env_init(void) + +{ + memset(&mm_env,0,0x2c); + mm_env._34_2_ = 0x101; + mm_env._18_2_ = 0; + mm_env.rx_filter_lmac_enable = 0; + mm_env.rx_filter_umac = 0x7fffffde; + mm_rx_filter_set(); + mm_env_max_ampdu_duration_set(); + return; +} + + + +void mm_init(void) + +{ + hal_machw_init(); + mm_env_init(); + vif_mgmt_init(); + sta_mgmt_init(); + td_init(); + ps_init(); + txl_cntrl_init(); + rxl_init(); + mm_timer_init(); + scan_init(); + chan_init(); + hal_dma_init(); + mm_bcn_init(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_active(void) + +{ + _DAT_44b00038 = 0x30; + ke_state_set(0,1); + return; +} + + + +void mm_reset(void) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + + kVar1 = ke_state_get(0); + if (CONCAT31(extraout_var,kVar1) == 1) { + mm_active(); + return; + } + ke_state_set(0,0); + return; +} + + +/* +Unable to decompile 'mm_tbtt_evt' +Cause: Exception while decompiling 2305d7ec: Decompiler process died + +*/ + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t mm_sec_machwaddr_wr(uint8_t sta_idx,uint8_t inst_nbr) + +{ + uint uVar1; + undefined3 in_register_00002029; + int iVar2; + + iVar2 = CONCAT31(in_register_00002029,sta_idx); + uVar1 = iVar2 + 8U & 0xff; + _DAT_44b000bc = *(undefined4 *)sta_info_tab[iVar2].mac_addr.array; + _DAT_44b000c0 = (uint)sta_info_tab[iVar2].mac_addr.array[2]; + _DAT_44b000ac = 0; + _DAT_44b000b0 = 0; + _DAT_44b000b4 = 0; + _DAT_44b000b8 = 0; + blmac_encr_cntrl_pack('\0','\x01',(uint16_t)uVar1,'\0',inst_nbr,'\0','\x01','\0'); + do { + } while (_DAT_44b000c4 << 1 < 0); + return (uint8_t)uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t mm_sec_machwkey_wr(mm_key_add_req *param) + +{ + byte bVar1; + byte vlanidram; + uint16_t keyindexram; + uint uVar2; + uint8_t ctyperam; + uint8_t clenram; + uint uVar3; + + bVar1 = param->sta_idx; + uVar3 = (uint)bVar1; + vlanidram = param->inst_nbr; + if (bVar1 == 0xff) { + uVar3 = (uint)vlanidram * 4 + (uint)param->key_idx & 0xff; + keyindexram = (uint16_t)uVar3; + _DAT_44b000bc = 0xffffffff; + _DAT_44b000c0 = 0xffffffff; + vif_mgmt_add_key(param,(uint8_t)uVar3); + } + else { + if (0xb < bVar1) { + assert_err("sta_idx < STA_MAX","module",0x3e4); + } + uVar2 = uVar3 + 8 & 0xff; + keyindexram = (uint16_t)uVar2; + sta_mgmt_add_key(param,(uint8_t)uVar2); + _DAT_44b000bc = *(undefined4 *)sta_info_tab[uVar3].mac_addr.array; + _DAT_44b000c0 = (uint)sta_info_tab[uVar3].mac_addr.array[2]; + } + bVar1 = param->cipher_suite; + if (bVar1 < 4) { + clenram = *(uint8_t *)((int)&CSWTCH_22 + (uint)bVar1); + ctyperam = *(uint8_t *)((int)&CSWTCH_23 + (uint)bVar1); + } + else { + assert_err("0","module",0x429); + ctyperam = '\0'; + clenram = '\x01'; + } + _DAT_44b000ac = (param->key).array[0]; + _DAT_44b000b0 = (param->key).array[1]; + _DAT_44b000b4 = (param->key).array[2]; + _DAT_44b000b8 = (param->key).array[3]; + blmac_encr_cntrl_pack('\0','\x01',keyindexram,ctyperam,vlanidram,param->spp,'\0',clenram); + do { + } while (_DAT_44b000c4 << 1 < 0); + return (uint8_t)keyindexram; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_sec_machwkey_del(uint8_t hw_key_idx) + +{ + undefined3 in_register_00002029; + uint uVar1; + uint uVar2; + + uVar1 = CONCAT31(in_register_00002029,hw_key_idx); + if (uVar1 < 8) { + _DAT_44b000bc = 0xffffffff; + _DAT_44b000c0 = 0xffffffff; + vif_mgmt_del_key(vif_info_tab + ((int)uVar1 >> 2),hw_key_idx & 3); + } + else { + uVar2 = uVar1 - 8 & 0xff; + _DAT_44b000bc = *(undefined4 *)sta_info_tab[uVar2].mac_addr.array; + _DAT_44b000c0 = (uint)sta_info_tab[uVar2].mac_addr.array[2]; + sta_mgmt_del_key(sta_info_tab + uVar2); + } + _DAT_44b000ac = 0; + _DAT_44b000b0 = 0; + _DAT_44b000b4 = 0; + _DAT_44b000b8 = 0; + blmac_encr_cntrl_pack('\0','\x01',(uint16_t)uVar1,'\0','\0','\0','\0','\0'); + do { + } while (_DAT_44b000c4 << 1 < 0); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_sec_machwaddr_del(uint8_t sta_idx) + +{ + _DAT_44b000bc = 0xffffffff; + _DAT_44b000c0 = 0xffffffff; + _DAT_44b000ac = 0; + _DAT_44b000b0 = 0; + _DAT_44b000b4 = 0; + _DAT_44b000b8 = 0; + blmac_encr_cntrl_pack('\0','\x01',(ushort)sta_idx + 8 & 0xff,'\0','\0','\0','\0','\0'); + do { + } while (_DAT_44b000c4 << 1 < 0); + return; +} + + + +void mm_hw_idle_evt(int dummy) + +{ + ke_evt_clear(0x800000); + ke_state_set(0,0); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_hw_info_set(mac_addr_conflict171 *mac_addr) + +{ + blmac_ap_setf('\0'); + _DAT_44b0001c = 0x100; + _DAT_44b080a4 = 0; + _DAT_44b080a8 = 0; + _DAT_44b00010 = *(undefined4 *)mac_addr->array; + _DAT_44b00014 = (uint)mac_addr->array[2]; + _DAT_44b0004c = _DAT_44b0004c & 0xfffff8ff | 1; + mm_env.rx_filter_umac = 0x3503858c; + mm_rx_filter_set(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_hw_ap_info_set(void) + +{ + blmac_ap_setf('\x01'); + mm_env.rx_filter_umac = 0x3507a58c; + mm_rx_filter_set(); + _DAT_44b08070 = 0x40001; + _DAT_44b08074 = _DAT_44b08074 | 0x40001; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_hw_ap_info_reset(void) + +{ + blmac_ap_setf('\0'); + mm_env.rx_filter_umac = 0x3503858c; + mm_rx_filter_set(); + _DAT_44b08070 = 0x40001; + _DAT_44b08074 = _DAT_44b08074 & 0xfffbfffe; + return; +} + + + +void mm_back_to_host_idle(void) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + + kVar1 = ke_state_get(0); + if (CONCAT31(extraout_var,kVar1) != 3) { + assert_err("ke_state_get(TASK_MM) == MM_HOST_BYPASSED","module",0x52a); + } + if (mm_env.host_idle == '\0') { + mm_active(); + return; + } + ke_state_set(0,0); + return; +} + + +/* +Unable to decompile 'mm_force_idle_req' +Cause: Exception while decompiling 2305dca8: Decompiler process died + +*/ + + +// WARNING: Type propagation algorithm not settling +// WARNING: Could not reconcile some variable overlaps + +uint8_t mm_sta_add(mm_sta_add_req *param,uint8_t *sta_idx,uint8_t *hw_sta_idx) + +{ + uint uVar1; + uint8_t uVar2; + uint8_t uVar3; + uchar uVar4; + uchar uVar5; + undefined3 extraout_var; + size_t sVar6; + int security_mode; + uint8_t *phrase; + int iVar7; + int iVar8; + _Bool is_pmf_required; + uint uVar9; + undefined2 uStack92; + mm_key_add_req key_add_req; + + uVar2 = sta_mgmt_register(param,sta_idx); + if (CONCAT31(extraout_var,uVar2) != 0) { + return uVar2; + } + uVar1 = (uint)param->inst_nbr; + uVar3 = mm_sec_machwaddr_wr(*sta_idx,param->inst_nbr); + *hw_sta_idx = uVar3; + if (vif_info_tab[uVar1].type != '\0') { + return uVar2; + } + if (vif_info_tab[uVar1].bss_info.is_supplicant_enabled == false) goto LAB_2305dd2e; + sta_conn_info.staId = *sta_idx; + if ((*(uint *)&vif_info_tab[uVar1].bss_info.is_supplicant_enabled & 0x12800) == 0) { + if ((*(byte *)&vif_info_tab[uVar1].bss_info.wpa_wpa2_wep & 2) != 0) { + sVar6 = strlen((char *)(sm_env.connect_param)->phrase); + printf("wep:len:%d,password:%s\n",sVar6,(sm_env.connect_param)->phrase); + memset(&uStack92,0,0x2c); + key_add_req.key.array[7]._1_1_ = param->inst_nbr; + uStack92 = 0xff00; + sVar6 = strlen((char *)(sm_env.connect_param)->phrase); + uVar9 = sVar6 & 0xff; + key_add_req.key_idx = (uint8_t)uVar9; + if (uVar9 == 5) { + key_add_req.key.array[7]._0_1_ = '\0'; +LAB_2305de62: + memcpy(&key_add_req.key,(sm_env.connect_param)->phrase,sVar6 & 0xff); + } + else { + if (uVar9 == 0xd) { + key_add_req.key.array[7]._0_1_ = '\x03'; + goto LAB_2305de62; + } + if (uVar9 == 10) { + key_add_req.key.array[7]._0_1_ = '\0'; + } + else { + if (uVar9 != 0x1a) { + printf("password length is not correct for wep\n"); + sta_mgmt_unregister(*sta_idx); + return '\x01'; + } + key_add_req.key.array[7]._0_1_ = '\x03'; + } + uVar9 = sVar6 & 0xff; + if ((sVar6 & 1) != 0) { + uVar9 = sVar6 & 0xfe; + } + if (uVar9 != 0) { + iVar7 = 0; + phrase = (sm_env.connect_param)->phrase; + do { + uVar4 = ascii_to_hex(*phrase); + uVar5 = ascii_to_hex(phrase[1]); + (&key_add_req.key.length)[iVar7 >> 1] = uVar4 * '\x10' + uVar5; + iVar7 = iVar7 + 2; + phrase = phrase + 2; + } while (iVar7 < (int)uVar9); + } + key_add_req.key_idx = key_add_req.key_idx >> 1; + } + wep_hw_keyid = mm_sec_machwkey_wr((mm_key_add_req *)&uStack92); + } + } + else { + if ((sm_env.connect_param)->phrase_pmk[0] == '\0') { + phrase = (sm_env.connect_param)->phrase; + } + else { + phrase = (sm_env.connect_param)->phrase_pmk; + } + set_psk((char *)vif_info_tab[uVar1].bss_info.ssid.array,vif_info_tab[uVar1].bss_info.ssid.length + ,(char *)phrase); + } + iVar7 = uVar1 * 0x5d8; + if ((*(uint *)&vif_info_tab[uVar1].bss_info.is_supplicant_enabled & 0x12000) == 0) { + if ((*(byte *)&vif_info_tab[uVar1].bss_info.wpa_wpa2_wep & 8) != 0) { + iVar8 = iVar7 + 0x3ec; + iVar7 = iVar7 + 0x3eb; + is_pmf_required = vif_info_tab[uVar1].bss_info.is_pmf_required; + security_mode = 3; + goto LAB_2305ddc4; + } + } + else { + is_pmf_required = vif_info_tab[uVar1].bss_info.is_pmf_required; + iVar8 = iVar7 + 0x3ee; + iVar7 = iVar7 + 0x3ed; + security_mode = 4; +LAB_2305ddc4: + supplicantEnable(&sta_conn_info,security_mode, + (void *)((int)&vif_info_tab[0].list_hdr.next + iVar7), + (void *)((int)&vif_info_tab[0].list_hdr.next + iVar8),is_pmf_required); + } + if (vif_info_tab[uVar1].type != '\0') { + return uVar2; + } +LAB_2305dd2e: + vif_info_tab[uVar1].u[4] = *sta_idx; + return '\0'; +} + + + +void mm_sta_del(uint8_t sta_idx) + +{ + uint uVar1; + undefined3 in_register_00002029; + undefined *puVar2; + byte bVar3; + uint uVar4; + + uVar4 = (uint)sta_info_tab[CONCAT31(in_register_00002029,sta_idx)].inst_nbr; + if (vif_info_tab[uVar4].type == '\0') { + vif_info_tab[uVar4].u[4] = 0xff; + if (vif_info_tab[uVar4].bss_info.is_supplicant_enabled != false) { + if ((*(uint *)&vif_info_tab[uVar4].bss_info.is_supplicant_enabled & 0x12800) == 0) { + if (((*(byte *)&vif_info_tab[uVar4].bss_info.wpa_wpa2_wep & 2) != 0) && (wep_hw_keyid != -1) + ) { + mm_sec_machwkey_del(wep_hw_keyid); + } + } + else { + mm_sec_machwkey_del(sta_conn_info.ptkHwKeyId); + mm_sec_machwkey_del(sta_conn_info.gtkHwKeyId); + mm_sec_machwkey_del(sta_conn_info.mfpHwKeyId); + supplicantDisable(&sta_conn_info); + memset(&(sta_conn_info.suppData)->hashSsId,0,0x22); + remove_psk((char *)vif_info_tab[uVar4].bss_info.ssid.array, + vif_info_tab[uVar4].bss_info.ssid.length); + } + vif_info_tab[uVar4].bss_info.is_supplicant_enabled = false; + } + } + else { + if ((sta_info_tab[CONCAT31(in_register_00002029,sta_idx)].ps_state == '\x01') && + (bVar3 = vif_info_tab[uVar4].u[0x2ee] - 1, vif_info_tab[uVar4].u[0x2ee] = bVar3, bVar3 == 0)) + { + uVar1 = (uint)vif_info_tab[uVar4].index + 10 & 0xff; + puVar2 = (undefined *)ke_msg_alloc(0x49,0xd,0,2); + sta_info_tab[uVar1].ps_state = '\0'; + *puVar2 = (char)uVar1; + puVar2[1] = 0; + ke_msg_send(); + apm_tx_int_ps_clear(vif_info_tab + uVar4,vif_info_tab[uVar4].index + '\n'); + } + } + mm_sec_machwaddr_del(sta_idx); + sta_mgmt_unregister(sta_idx); + return; +} + + + +void mm_cfg_element_keepalive_timestamp_update(void) + +{ + mm_env.keep_alive_time_last_received = xTaskGetTickCount(); + mm_env.keep_alive_packet_counter = mm_env.keep_alive_packet_counter + 1; + return; +} + + + +void mm_send_connection_loss_ind(vif_info_tag *p_vif_entry) + +{ + uint8_t *puVar1; + + puVar1 = (uint8_t *)ke_msg_alloc(0x43,6,0,1); + *puVar1 = p_vif_entry->index; + ke_msg_send(); + return; +} + + + +void mm_ap_probe_cfm(void *env,uint32_t status) + +{ + if ((int)(status << 8) < 0) { + *(undefined *)((int)env + 0x74) = 0; + return; + } + mm_send_connection_loss_ind((vif_info_tag *)env); + return; +} + + + +// WARNING: Variable defined which should be unmapped: cur_us +// WARNING: Could not reconcile some variable overlaps + +void mm_check_rssi(vif_info_tag *vif_entry,int8_t rssi) + +{ + byte bVar1; + uint8_t uVar2; + int iVar3; + uint8_t *puVar4; + undefined3 in_register_0000202d; + int iVar5; + uint uVar6; + bool bVar7; + int iVar8; + uint uStack40; + longlong cur_us; + + iVar5 = CONCAT31(in_register_0000202d,rssi); + iVar8 = (int)(char)vif_entry->u[0x19]; + iVar3 = (int)(char)vif_entry->u[0x1a]; + bVar1 = vif_entry->u[0x1b]; + bVar7 = (bool)vif_entry->u[0x1c]; + vif_entry->u[0x19] = rssi; + uStack40 = 0; + cur_us._0_4_ = 0; + bl60x_current_time_us((longlong *)&uStack40); + if (iVar8 != 0) { + uVar6 = (uint)(uStack40 < uStack40 - (uint)last_us); + if (((int)(((int)cur_us - last_us._4_4_) - uVar6) < 1) && + (((int)cur_us - last_us._4_4_ != uVar6 || (uStack40 - (uint)last_us < 0x1e8481)))) + goto LAB_2305e162; + } + puVar4 = (uint8_t *)ke_msg_alloc(0x57,0xd,0,3); + uVar2 = vif_entry->index; + *(bool *)(puVar4 + 1) = bVar7; + puVar4[2] = rssi; + *puVar4 = uVar2; + last_us._0_4_ = uStack40; + last_us._4_4_ = (int)cur_us; + ke_msg_send(); +LAB_2305e162: + if (iVar3 != 0) { + if (bVar7 == false) { + if (iVar5 < iVar8) { + bVar7 = iVar5 < iVar3 - (char)bVar1; + } + } + else { + if (iVar8 < iVar5) { + bVar7 = iVar5 <= iVar3 + (char)bVar1; + } + } + if ((bool)vif_entry->u[0x1c] != bVar7) { + puVar4 = (uint8_t *)ke_msg_alloc(0x57,0xd,0,3); + uVar2 = vif_entry->index; + *(bool *)(puVar4 + 1) = bVar7; + puVar4[2] = rssi; + *puVar4 = uVar2; + ke_msg_send(); + } + *(bool *)(vif_entry->u + 0x1c) = bVar7; + } + return; +} + + + +void mm_send_csa_traffic_ind(uint8_t vif_index,_Bool enable) + +{ + uint8_t *puVar1; + + puVar1 = (uint8_t *)ke_msg_alloc(0x59,0xd,0,2); + *puVar1 = vif_index; + *(_Bool *)(puVar1 + 1) = enable; + ke_msg_send(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint mm_check_beacon(rx_hd *param_1,vif_info_tag *param_2,int param_3,char **param_4) + +{ + ushort len; + ushort uVar1; + ushort uVar2; + uint uVar3; + int iVar4; + uint8_t uVar5; + undefined3 extraout_var; + uint32_t crc; + uint32_t uVar6; + uint32_t uVar7; + uint uVar8; + uint uVar9; + char *pcVar10; + uint uVar11; + int iVar12; + int iVar13; + uint len_00; + int iVar14; + uint uVar15; + + len = param_1->frmlen; + iVar13 = *(int *)(param_1->first_pbd_ptr + 8); + param_2->u[0x18] = 0; + beacon_rx_count = beacon_rx_count + 1; + iVar14 = *(int *)(param_2->u + 0x14); + if (param_2->u[0x1e] != 0) { + mm_send_csa_traffic_ind(param_2->index,true); + param_2->u[0x1e] = 0; + } + if ((((30000000 - _DAT_44b00120) + *(int *)(param_2->u + 0x10) < 0) && + (mm_env.keep_alive_status_enabled != false)) && + (uVar5 = txl_frame_send_null_frame(param_2->u[4],(cfm_func_ptr *)0x0,(void *)0x0), + CONCAT31(extraout_var,uVar5) == 0)) { + *(int *)(param_2->u + 0x10) = _DAT_44b00120; + } + uVar3 = (uint)len - 0x24; + mm_check_rssi(param_2,*(int8_t *)((int)¶m_1->recvec1c + 3)); + crc = co_crc32(iVar13 + 0x20,4,0); + pcVar10 = (char *)(iVar13 + 0x24); + *param_4 = (char *)0x0; + while (uVar3 = uVar3 & 0xffff, 1 < uVar3) { + len_00 = (uint)(byte)pcVar10[1]; + if (uVar3 <= len_00 + 1) break; + if (*pcVar10 == '\x05') { + *param_4 = pcVar10; + } + else { + crc = co_crc32((uint32_t)(pcVar10 + 2),len_00,crc); + } + uVar3 = uVar3 + (-2 - len_00); + pcVar10 = pcVar10 + 2 + len_00; + } + *(uint32_t *)(param_2->u + 0x14) = crc; + uVar1 = *(ushort *)(param_3 + 0x16); + uVar2 = *(ushort *)(iVar13 + 0x20); + uVar3 = *(uint *)(iVar13 + 0x18); + crc = param_1->tsflo; + iVar4 = (uint)uVar2 * 0x400; + iVar13 = *(int *)(iVar13 + 0x1c); + len_00 = (uint)*(ushort *)param_2->u; + if (*(ushort *)param_2->u == 0) { + pcVar10 = *param_4; + len_00 = 1; + if ((pcVar10 != (char *)0x0) && (len_00 = (uint)(byte)pcVar10[2], pcVar10[2] == 0)) { + len_00 = (uint)(byte)pcVar10[3]; + } + } + uVar6 = hal_machw_rx_duration(param_1,len); + uVar7 = hal_machw_rx_duration(param_1,0x18); + uVar8 = uVar3; + iVar12 = iVar13; + __udivdi3(); + uVar11 = uVar3 - uVar7; + uVar15 = iVar13 - (uint)(uVar3 < uVar11); + uVar9 = iVar12 * iVar4 + (int)((ulonglong)uVar8 * (ulonglong)uVar2 * 0x400 >> 0x20); + if ((uVar9 < uVar15) || ((uVar15 == uVar9 && (uVar8 * iVar4 < uVar11)))) { + uVar11 = uVar8 * iVar4; + } + iVar12 = ((uVar11 + len_00 * iVar4) - ((uVar3 - crc) + (uVar6 - uVar7))) - uVar1 * len_00; + iVar13 = iVar12 + -400; + if (iVar12 + (-0xc80 - _DAT_44b00120) < 0) { + iVar13 = iVar13 + iVar4; + } + crc = (_DAT_44b00120 - _DAT_44b080a4) + iVar13; + if (crc != (param_2->tbtt_timer).time) { + mm_timer_set(¶m_2->tbtt_timer,crc); + } + return (uint)(*(int *)(param_2->u + 0x14) != iVar14); +} + + + +void mm_sta_tbtt(void *env) + +{ + uint32_t value; + _Bool _Var1; + undefined3 extraout_var; + byte bVar2; + + if (*(char *)((int)env + 0x58) == '\0') { + return; + } + if (*(char *)((int)env + 0x79) != '\0') { + bVar2 = *(char *)((int)env + 0x79) - 1; + *(byte *)((int)env + 0x79) = bVar2; + if (bVar2 < 2) { + vif_mgmt_switch_channel((vif_info_tag *)env); + return; + } + if (bVar2 == 2) { + mm_send_csa_traffic_ind(*(uint8_t *)((int)env + 0x57),false); + } + } + value = sta_info_tab[*(byte *)((int)env + 0x60)].bcn_int + *(int *)((int)env + 0x24); + mm_timer_set((mm_timer_tag *)((int)env + 0x18),value); + vif_mgmt_bcn_to_prog((vif_info_tag *)env); + chan_tbtt_switch_update((vif_info_tag *)env,value); + _Var1 = chan_is_on_channel((vif_info_tag *)env); + if (CONCAT31(extraout_var,_Var1) != 0) { + *(uint *)((int)env + 4) = *(uint *)((int)env + 4) | 1; + bVar2 = *(char *)((int)env + 0x74) + 1; + *(byte *)((int)env + 0x74) = bVar2; + if (100 < bVar2) { + txl_frame_send_null_frame(*(uint8_t *)((int)env + 0x60),mm_ap_probe_cfm,env); + return; + } + if (bVar2 == 100) { + chan_bcn_detect_start((vif_info_tag *)env); + return; + } + } + return; +} + + + +uint16_t mm_get_rsn_wpa_ie(uint8_t sta_id,uint8_t *wpa_ie) + +{ + undefined3 in_register_00002029; + uint uVar1; + + uVar1 = (uint)sta_info_tab[CONCAT31(in_register_00002029,sta_id)].inst_nbr; + memcpy(wpa_ie,vif_info_tab[uVar1].bss_info.rsn_wpa_ie, + (uint)vif_info_tab[uVar1].bss_info.rsn_wpa_ie_len); + return (uint16_t)(ushort)vif_info_tab[uVar1].bss_info.rsn_wpa_ie_len; +} + + + +void mm_tim_update_proceed(ushort *param_1) + +{ + byte bVar1; + ushort uVar2; + uint uVar3; + uint8_t *puVar4; + uint uVar5; + int iVar6; + uint uVar7; + int iVar8; + uint uVar9; + uint uVar10; + uint uVar11; + byte *pbVar12; + + uVar2 = *param_1; + uVar9 = (uint)*(byte *)((int)param_1 + 3); + if (uVar2 == 0) { + if (*(char *)(param_1 + 1) == '\0') { + vif_info_tab[uVar9].u[0x2ea] = 0; + } + else { + vif_info_tab[uVar9].u[0x2ea] = 1; + } + } + else { + iVar8 = uVar9 * 8; + uVar10 = (uint)(uVar2 >> 3); + uVar11 = uVar10 & 0xff; + puVar4 = txl_tim_bitmap_pool + uVar9 * 0xfc; + pbVar12 = puVar4 + uVar11; + bVar1 = *pbVar12; + uVar7 = 1 << ((uint)uVar2 & 7); + uVar5 = uVar7 & 0xff; + uVar3 = uVar5 & bVar1; + if (*(char *)(param_1 + 1) == '\0') { + if (uVar3 != 0) { + *pbVar12 = ~(byte)uVar7 & bVar1; + uVar3 = (uint)*(ushort *)(vif_info_tab[uVar9].u + 0x2e0) - 1; + *(short *)(vif_info_tab[uVar9].u + 0x2e0) = (short)(uVar3 * 0x10000 >> 0x10); + if ((uVar3 & 0xffff) == 0) { + *(undefined2 *)(vif_info_tab[uVar9].u + 0x2de) = 6; + *(undefined2 *)(vif_info_tab[uVar9].u + 0x2e8) = 0xff; + bVar1 = vif_info_tab[uVar9].u[0x2de]; + txl_tim_ie_pool[iVar8 + 4] = '\0'; + txl_tim_ie_pool[iVar8 + 1] = bVar1 - 2; + txl_tim_desc[uVar9 * 2].dataendptr = iVar8 + 0x42045365; + *(tx_pbd **)&txl_tim_desc[uVar9 * 2].next = txl_bcn_end_desc + *(byte *)((int)param_1 + 3) + ; + *(uint8_t **)&txl_tim_desc[uVar9 * 2 + 1].dataendptr = + puVar4 + vif_info_tab[uVar9].u[0x2e9]; + } + else { + if ((uint)vif_info_tab[uVar9].u[0x2e8] == (uVar10 & 0xfe)) { + while( true ) { + bVar1 = vif_info_tab[uVar9].u[0x2e8]; + if ((bVar1 == 0xfb) || (puVar4[(uint)bVar1] != '\0')) break; + vif_info_tab[uVar9].u[0x2e8] = bVar1 + 1; + } + uVar3 = (uint)bVar1 & 0xfe; + vif_info_tab[uVar9].u[0x2e8] = (byte)uVar3; + *(uint8_t **)&txl_tim_desc[uVar9 * 2 + 1].datastartptr = puVar4 + uVar3; + } + if ((uint)vif_info_tab[uVar9].u[0x2e9] == uVar11) { + while( true ) { + bVar1 = vif_info_tab[uVar9].u[0x2e9]; + if ((bVar1 == 0) || (puVar4[bVar1] != '\0')) break; + vif_info_tab[uVar9].u[0x2e9] = bVar1 - 1; + } + *(uint8_t **)&txl_tim_desc[uVar9 * 2 + 1].dataendptr = puVar4 + bVar1; + } + iVar6 = (((uint)vif_info_tab[uVar9].u[0x2e9] + 6) - (uint)vif_info_tab[uVar9].u[0x2e8]) * + 0x10000; + *(short *)(vif_info_tab[uVar9].u + 0x2de) = (short)((uint)iVar6 >> 0x10); + txl_tim_ie_pool[iVar8 + 1] = (char)((uint)iVar6 >> 0x10) + -2; + txl_tim_ie_pool[iVar8 + 4] = vif_info_tab[uVar9].u[0x2e8]; + } + } + } + else { + if (uVar3 == 0) { + *pbVar12 = (byte)uVar5 | bVar1; + bVar1 = vif_info_tab[uVar9].u[0x2e8]; + *(short *)(vif_info_tab[uVar9].u + 0x2e0) = *(short *)(vif_info_tab[uVar9].u + 0x2e0) + 1; + if (uVar11 < bVar1) { + vif_info_tab[uVar9].u[0x2e8] = (byte)(uVar10 & 0xfe); + *(uint8_t **)&txl_tim_desc[uVar9 * 2 + 1].datastartptr = puVar4 + (uVar10 & 0xfe); + } + if (vif_info_tab[uVar9].u[0x2e9] < uVar11) { + vif_info_tab[uVar9].u[0x2e9] = (byte)uVar11; + *(byte **)&txl_tim_desc[uVar9 * 2 + 1].dataendptr = pbVar12; + } + iVar6 = (((uint)vif_info_tab[uVar9].u[0x2e9] + 6) - (uint)vif_info_tab[uVar9].u[0x2e8]) * + 0x10000; + *(short *)(vif_info_tab[uVar9].u + 0x2de) = (short)((uint)iVar6 >> 0x10); + txl_tim_ie_pool[iVar8 + 1] = (char)((uint)iVar6 >> 0x10) + -2; + txl_tim_ie_pool[iVar8 + 4] = vif_info_tab[uVar9].u[0x2e8]; + txl_tim_desc[uVar9 * 2].dataendptr = iVar8 + 0x42045364; + txl_tim_desc[uVar9 * 2].next = uVar9 * 0x28 + 0x42045aa4; + } + } + } + ke_msg_send_basic(0x42,param_1[-2],0); + ke_msg_free(param_1 + -6); + return; +} + + + +void mm_bcn_init(void) + +{ + memset(&mm_bcn_env,0,0x24); + mm_bcn_env.dma.dma_desc = &bcn_dwnld_desc; + mm_bcn_env.dma.cb = mm_bcn_updated; + co_list_init(&mm_bcn_env.tim_list); + return; +} + + + +void mm_bcn_init_vif(vif_info_tag *vif_entry) + +{ + byte bVar1; + tx_pbd *ptVar2; + uint uVar3; + int iVar4; + + uVar3 = (uint)vif_entry->index; + txl_frame_init_desc((txl_frame_desc_tag *)(vif_entry->u + 4), + (txl_buffer_tag *)(txl_bcn_pool + uVar3 * 0xd3),txl_bcn_hwdesc_pool + uVar3, + txl_bcn_buf_ctrl + uVar3); + txl_bcn_hwdesc_pool[uVar3].cfm_ptr = txl_bcn_hwdesc_cfms + vif_entry->index; + uVar3 = (uint)vif_entry->index; + iVar4 = uVar3 * 8; + vif_entry->u[0x2e7] = 0; + *(undefined2 *)(vif_entry->u + 0x2e0) = 0; + vif_entry->u[0x2ea] = 0; + *(undefined2 *)(vif_entry->u + 0x2de) = 6; + *(undefined2 *)(vif_entry->u + 0x2e8) = 0xff; + txl_tim_desc[uVar3 * 2].dataendptr = iVar4 + 0x42045365; + txl_tim_desc[uVar3 * 2].upatterntx = 0xcafefade; + *(uint8_t **)&txl_tim_desc[uVar3 * 2].datastartptr = txl_tim_ie_pool + iVar4; + txl_tim_desc[uVar3 * 2].bufctrlinfo = 0; + ptVar2 = txl_bcn_end_desc + uVar3; + *(tx_pbd **)&txl_tim_desc[uVar3 * 2].next = ptVar2; + txl_tim_ie_pool[iVar4] = '\x05'; + txl_tim_ie_pool[iVar4 + 1] = '\x04'; + bVar1 = vif_entry->u[0x2e7]; + txl_tim_ie_pool[iVar4 + 4] = '\0'; + txl_tim_ie_pool[iVar4 + 2] = bVar1; + txl_tim_ie_pool[iVar4 + 3] = '\x01'; + txl_tim_ie_pool[iVar4 + 5] = -1; + txl_tim_desc[uVar3 * 2 + 1].upatterntx = 0xcafefade; + bVar1 = vif_entry->u[0x2e9]; + *(tx_pbd **)&txl_tim_desc[uVar3 * 2 + 1].next = ptVar2; + *(uint8_t **)&txl_tim_desc[uVar3 * 2 + 1].dataendptr = txl_tim_bitmap_pool + uVar3 * 0xfc + bVar1; + memset(txl_tim_bitmap_pool + uVar3 * 0xfc,0,0xfc); + ptVar2->upatterntx = 0xcafefade; + txl_bcn_end_desc[uVar3].next = 0; + txl_bcn_end_desc[uVar3].bufctrlinfo = 0; + iVar4 = *(int *)(vif_entry->u + 0x70); + *(undefined4 *)(iVar4 + 0x24) = 0; + *(undefined4 *)(iVar4 + 0x3c) = 0; + *(undefined4 *)(iVar4 + 0x10) = 0; + *(undefined4 *)(vif_entry->u + 0x2d0) = 0x2305edbc; + *(vif_info_tag **)(vif_entry->u + 0x2d4) = vif_entry; + return; +} + + + +void mm_tim_update(mm_tim_update_req *param) + +{ + if (mm_bcn_env.tx_cfm != 0) { + co_list_push_back(&mm_bcn_env.tim_list,(co_list_hdr *)(param + -3)); + return; + } + mm_tim_update_proceed(); + return; +} + + + +// WARNING: Type propagation algorithm not settling + +void mm_bcn_transmit(void) + +{ + byte bVar1; + uint8_t uVar2; + uint8_t uVar3; + vif_info_tag *vif; + txl_frame_desc_tag *frame; + _Bool _Var4; + undefined3 extraout_var; + char *pcVar5; + undefined3 extraout_var_00; + uint8_t *puVar6; + int iVar7; + byte bVar8; + uint uVar9; + char cVar10; + int iVar11; + + vif = (vif_info_tag *)vif_mgmt_env.used_list.first; + if (mm_bcn_env.tx_cfm != 0) { + assert_err("!mm_bcn_env.tx_cfm","module",0x339); + } + if (mm_bcn_env.update_ongoing == false) { + mm_bcn_env.tx_pending = false; + while (vif != (vif_info_tag *)0x0) { + if (((vif->type == '\x02') && (*(char *)((int)vif->u + 0x2e6) != '\0')) && + (*(char *)((int)vif->u + 0x2e5) == *(char *)((int)vif->u + 0x2e4))) { + iVar7 = *(int *)((int)vif->u + 0x70); + iVar11 = (uint)vif->index * 8; + bVar1 = txl_tim_ie_pool[iVar11 + 4]; + *(int *)(iVar7 + 0x1c) = + (uint)*(ushort *)((int)vif->u + 0x2dc) + (uint)*(ushort *)((int)vif->u + 0x2de) + 4; + uVar9 = (uint)txl_cntrl_env.seqnbr; + frame = (txl_frame_desc_tag *)((int)vif->u + 4); + txl_cntrl_env.seqnbr = (uint16_t)((uVar9 + 1) * 0x10000 >> 0x10); + *(undefined2 *)(*(int *)(iVar7 + 0x14) + 0x16) = (short)((uVar9 + 1 & 0xffff) << 4); + uVar2 = *(uint8_t *)((int)vif->u + 0x2e7); + txl_tim_ie_pool[iVar11 + 2] = uVar2; + if (uVar2 == '\0') { + if ((*(char *)((int)vif->u + 0x2ea) != '\0') || + (bVar8 = bVar1 & 0xfe, ipc_emb_env.txdesc[ipc_emb_env.txdesc_idx & 3].ready != 0)) { + bVar8 = bVar1 | 1; + } + *(uint8_t *)((int)vif->u + 0x2e7) = txl_tim_ie_pool[iVar11 + 3]; + } + else { + bVar8 = bVar1 & 0xfe; + if ((*(byte *)((int)vif->u + 0x2ea) & 2) != 0) { + bVar8 = bVar1 | 1; + } + } + txl_tim_ie_pool[iVar11 + 4] = bVar8 | 1; + *(char *)((int)vif->u + 0x2e7) = *(char *)((int)vif->u + 0x2e7) + -1; + cVar10 = *(char *)((int)vif->u + 0x2eb); + if (cVar10 != '\0') { + bVar1 = *(byte *)((int)vif->u + 0x2ec); + cVar10 = cVar10 + -1; + *(char *)((int)vif->u + 0x2eb) = cVar10; + if (bVar1 != 0) { + *(char *)(*(int *)(iVar7 + 0x14) + (uint)bVar1) = cVar10; + bVar1 = *(byte *)((int)vif->u + 0x2ed); + if (bVar1 != 0) { + *(undefined *)(*(int *)(iVar7 + 0x14) + (uint)bVar1) = + *(undefined *)((int)vif->u + 0x2eb); + } + } + uVar2 = *(uint8_t *)((int)vif->u + 0x2eb); + if (uVar2 != '\0') { + uVar3 = vif->index; + puVar6 = (uint8_t *)ke_msg_alloc(0x4e,0xd,0,2); + *puVar6 = uVar3; + puVar6[1] = uVar2; + ke_msg_send(); + if (*(char *)((int)vif->u + 0x2eb) != '\0') goto LAB_2305eb34; + } + *(undefined *)((int)vif->u + 0x2eb) = 1; + } +LAB_2305eb34: + tpc_update_frame_tx_power(vif,frame); + _Var4 = chan_is_on_operational_channel(vif); + if (CONCAT31(extraout_var,_Var4) != 0) { + uVar2 = vif->index; + pcVar5 = (char *)ke_msg_alloc(0x4a,0xd,0,3); + *pcVar5 = uVar2 + '\n'; + pcVar5[1] = '\0'; + pcVar5[2] = '\0'; + ke_msg_send(); + *(uint8_t *)((int)vif->u + 0x33) = vif->index; + *(undefined *)((int)vif->u + 0x34) = 0xff; + _Var4 = txl_frame_push(frame,'\x04'); + if (CONCAT31(extraout_var_00,_Var4) != 0) { + mm_bcn_env.tx_cfm = mm_bcn_env.tx_cfm + 1; + } + iVar7 = (uint)vif->index + 10; + if ((sta_info_tab[iVar7].traffic_avail & PS_TRAFFIC_INT) != 0) { + sta_info_tab[iVar7].ps_service_period = 9; + sta_mgmt_send_postponed_frame(vif,sta_info_tab + iVar7,0); + sta_info_tab[iVar7].ps_service_period = 0; + } + } + } + vif = *(vif_info_tag **)&vif->list_hdr; + } + } + else { + mm_bcn_env.tx_pending = true; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void mm_bcn_updated(void *env,int dma_queue) + +{ + ushort uVar1; + ushort uVar2; + mm_bcn_change_req *pmVar3; + int iVar4; + uint32_t uVar5; + int iVar6; + txl_buffer_control *ptVar7; + mm_bcn_change_req *mem_ptr; + int iVar8; + uint uVar9; + int iVar10; + + mem_ptr = mm_bcn_env.param + -1; + ke_msg_send_basic(0x40,*(ke_task_id_t *)&mm_bcn_env.param[-1].tim_len,0); + pmVar3 = mm_bcn_env.param; + uVar9 = (uint)*(byte *)((int)env + 0x57); + iVar4 = *(int *)((int)env + 0xcc); + uVar1 = (mm_bcn_env.param)->tim_oft; + iVar10 = (uint)(mm_bcn_env.param)->bcn_len - (uint)(mm_bcn_env.param)->tim_len; + iVar8 = *(int *)(iVar4 + 0x14); + *(undefined2 *)((int)env + 0x338) = (short)iVar10; + me_beacon_check(*(byte *)((int)env + 0x57),pmVar3->bcn_len,*(uint32_t *)(iVar4 + 0x14)); + iVar6 = *(int *)(iVar4 + 0x14) + ((uint)pmVar3->tim_oft - 1); + *(int *)(iVar4 + 0x18) = iVar6; + uVar5 = (uint)pmVar3->tim_len + 1 + iVar6; + txl_bcn_end_desc[uVar9].datastartptr = uVar5; + uVar2 = pmVar3->tim_oft; + txl_bcn_end_desc[uVar9].bufctrlinfo = 0; + txl_bcn_end_desc[uVar9].dataendptr = ~(uint)uVar2 + iVar10 + uVar5; + if (*(char *)(*(int *)((int)env + 0x40) + 4) == '\0') { + ptVar7 = &txl_buffer_control_24G; + } + else { + ptVar7 = &txl_buffer_control_5G; + } + *(uint *)(ptVar7->field_0 + 0x24) = _DAT_44b000a0 & 0xff; + *(txl_buffer_control **)(iVar4 + 0x28) = ptVar7; + *(undefined4 *)(iVar4 + 0x24) = 0; + *(undefined4 *)(iVar4 + 0x3c) = 0; + *(tx_pbd **)(iVar4 + 0x10) = txl_tim_desc + (uint)*(byte *)((int)env + 0x57) * 2; + *(undefined *)((int)env + 0x342) = 1; + txl_tim_ie_pool[uVar9 * 8 + 3] = *(uint8_t *)(iVar8 + (uint)uVar1 + 3); + pmVar3 = mm_bcn_env.param; + *(undefined *)((int)env + 0x347) = 0; + *(uint8_t *)((int)env + 0x348) = pmVar3->csa_oft[0]; + *(uint8_t *)((int)env + 0x349) = pmVar3->csa_oft[1]; + if (pmVar3->csa_oft[0] != 0) { + *(char *)((int)env + 0x347) = + *(char *)(*(int *)(*(int *)((int)env + 0xcc) + 0x14) + (uint)pmVar3->csa_oft[0]) + '\x01'; + } + mm_bcn_env.update_ongoing = false; + if (mm_bcn_env.tx_pending != false) { + mm_bcn_transmit(); + } + mm_bcn_env.param = (mm_bcn_change_req *)0x0; + ke_msg_free(mem_ptr); + return; +} + + + +void mm_bcn_update(mm_bcn_change_req *param) + +{ + byte bVar1; + + bVar1 = param->inst_nbr; + memcpy(txl_bcn_pool + (uint)bVar1 * 0xd3 + 0x53,param + 1,(uint)param->bcn_len); + mm_bcn_env.update_pending = false; + mm_bcn_env.update_ongoing = true; + mm_bcn_updated(vif_info_tab + (uint)bVar1,0); + return; +} + + + +void mm_bcn_transmitted(vif_info_tag *param_1) + +{ + co_list_hdr *pcVar1; + + if (mm_bcn_env.tx_cfm == 0) { + assert_err("mm_bcn_env.tx_cfm","module",0x244); + } + mm_bcn_env.tx_cfm = mm_bcn_env.tx_cfm + -1; + if (mm_bcn_env.tx_cfm == 0) { + if (mm_bcn_env.update_pending != false) { + mm_bcn_update(mm_bcn_env.param); + } + while (mm_bcn_env.tim_list.first != (co_list_hdr *)0x0) { + pcVar1 = co_list_pop_front(&mm_bcn_env.tim_list); + mm_tim_update_proceed(pcVar1 + 3); + } + if (param_1->u[0x2eb] == 1) { + vif_mgmt_switch_channel(param_1); + return; + } + } + return; +} + + + +void mm_bcn_change(mm_bcn_change_req *param) + +{ + if (mm_bcn_env.tx_cfm != 0) { + mm_bcn_env.param = param; + mm_bcn_env.update_pending = true; + return; + } + mm_bcn_env.param = param; + mm_bcn_update(param); + return; +} + + + +void bl_init(void) + +{ + fw_nap_chain_ptr = &fw_nap_chain; + bl_env.hw_in_doze = 0; + dbg_init(); + me_init(); + mm_init(); + ke_init(); + memset(&sta_conn_info,0,0xec); + sta_conn_info._4_2_ = 0xffff; + sta_conn_info.conType = '\0'; + sta_conn_info.gtkHwKeyId = -1; + supplicantFuncInit(); + allocSupplicantData(&sta_conn_info); + return; +} + + +/* +Unable to decompile 'bl_reset_evt' +Cause: Exception while decompiling 2305eec0: Decompiler process died + +*/ + + +// WARNING: Type propagation algorithm not settling + +int bl_sleep(void) + +{ + vif_info_tag *p_vif_entry; + ke_state_t kVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + + if (ke_env.evt_field != 0) { + return 0; + } + kVar1 = ke_state_get(4); + if (((CONCAT31(extraout_var,kVar1) == 0) && (ps_env.ps_on != false)) && + (p_vif_entry = (vif_info_tag *)vif_mgmt_env.used_list.first, ps_env.prevent_sleep == 0)) { + while (p_vif_entry != (vif_info_tag *)0x0) { + _Var2 = chan_is_on_channel(p_vif_entry); + if ((CONCAT31(extraout_var_01,_Var2) != 0) && (p_vif_entry->prevent_sleep != 0)) { + return 0; + } + p_vif_entry = *(vif_info_tag **)&p_vif_entry->list_hdr; + } + if (txl_cntrl_env.pck_cnt == 0) { + _Var2 = hal_machw_sleep_check(); + return CONCAT31(extraout_var_00,_Var2); + } + } + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t bl_nap_calculate(void) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + + uVar2 = 0; + uVar1 = 0xffffffff; + do { + if ((1 << (uVar2 & 0x1f) & _DAT_44b0808c) != 0) { + uVar3 = *(uint *)(&DAT_44b00128 + uVar2 * 4); + if (_DAT_44b00120 < uVar3) { + uVar3 = uVar3 - _DAT_44b00120; + } + else { + uVar3 = (_DAT_44b00120 - 1) - uVar3; + } + if (uVar3 < uVar1) { + uVar1 = uVar3; + } + } + uVar2 = uVar2 + 1; + } while (uVar2 != 9); + return uVar1; +} + + + +void rx_swdesc_init(void) + +{ + rx_swdesc_tab[0].dma_hdrdesc = rx_dma_hdrdesc; + rx_swdesc_tab[1].dma_hdrdesc = &DAT_42041064; + rx_swdesc_tab[2].dma_hdrdesc = &DAT_420410c8; + rx_swdesc_tab[3].dma_hdrdesc = &DAT_4204112c; + rx_swdesc_tab[4].dma_hdrdesc = &DAT_42041190; + rx_swdesc_tab[5].dma_hdrdesc = &DAT_420411f4; + rx_swdesc_tab[6].dma_hdrdesc = &DAT_42041258; + rx_swdesc_tab[7].dma_hdrdesc = &DAT_420412bc; + rx_swdesc_tab[8].dma_hdrdesc = &DAT_42041320; + rx_swdesc_tab[9].dma_hdrdesc = &DAT_42041384; + rx_swdesc_tab[10].dma_hdrdesc = &DAT_420413e8; + rx_swdesc_tab[11].dma_hdrdesc = &DAT_4204144c; + rx_swdesc_tab[12].dma_hdrdesc = &DAT_420414b0; + return; +} + + + +void scan_search_ds(void) + +{ + scan_start_req *param; + + DAT_4201e578 = mac_ie_find(0x42045d04,(uint)param->add_ie_len,3); + return; +} + + + +void scan_init(void) + +{ + memset(&scan_env,0,0x1c); + ke_state_set(2,0); + DAT_4201e568 = &scan_probe_req_ie; + DAT_4201e56c = dma_cb; + DAT_4201e570 = 0; + scan_probe_req_ie.dma_desc.dest = 0x42045d04; + scan_probe_req_ie.pbd.upatterntx = 0xcafefade; + scan_probe_req_ie.pbd.next = 0; + scan_probe_req_ie.pbd.datastartptr = 0x42045d04; + scan_probe_req_ie.pbd.bufctrlinfo = 0; + return; +} + + + +void scan_set_channel_request(void) + +{ + scan_chan_tag *psVar1; + uint uVar2; + undefined uVar3; + int iVar4; + + psVar1 = param->chan + DAT_4201e57e; + chan_scan_req(*(uint8_t *)(&psVar1->freq + 1),psVar1->freq,*(int8_t *)(&psVar1->freq + 2),110000, + param->vif_idx); + if (DAT_4201e578 == 0) goto LAB_2305f13c; + uVar2 = (uint)psVar1->freq; + if (*(char *)(&psVar1->freq + 1) == '\0') { + uVar3 = 0; + if (((uVar2 - 0x96c & 0xffff) < 0x49) && (uVar3 = 0xe, psVar1->freq != 0x9b4)) { + iVar4 = -0x967; +LAB_2305f130: + uVar3 = (undefined)((int)(uVar2 + iVar4) / 5); + } + } + else { + uVar3 = 0; + if ((*(char *)(&psVar1->freq + 1) == '\x01') && ((uVar2 - 0x138d & 0xffff) < 0x335)) { + iVar4 = -5000; + goto LAB_2305f130; + } + } + *(undefined *)(DAT_4201e578 + 2) = uVar3; +LAB_2305f13c: + ke_state_set(2,2); + return; +} + + + +void dma_cb(void *env,int dma_queue) + +{ + scan_search_ds(); + scan_set_channel_request(); + return; +} + + + +void scan_ie_download(scan_start_req *param) + +{ + scan_search_ds(); + scan_set_channel_request(); + scan_probe_req_ie.pbd.dataendptr = + (scan_probe_req_ie.pbd.datastartptr - 1) + (uint)param->add_ie_len; + scan_probe_req_ie.pbd.bufctrlinfo = 0; + return; +} + + + +void scan_probe_req_tx(void) + +{ + byte bVar1; + byte bVar2; + scan_start_req *psVar3; + txl_buffer_tag *ptVar4; + uint type; + txl_frame_desc_tag *frame; + int iVar5; + int iVar6; + uint uVar7; + u8_l *puVar8; + tx_hw_desc *ptVar9; + + psVar3 = param; + uVar7 = (uint)DAT_4201e57e; + bVar1 = param->vif_idx; + puVar8 = param->ssid[0].array; + iVar6 = 0; + while( true ) { + if ((int)(uint)psVar3->ssid_cnt <= iVar6) { + return; + } + type = 1; + if (psVar3->chan[uVar7].band == '\0') { + type = (uint)psVar3->no_cck; + } + frame = txl_frame_get(type,(uint)psVar3->add_ie_len + (uint)puVar8[-1] + 0x1a); + if (frame == (txl_frame_desc_tag *)0x0) break; + ptVar4 = (frame->txdesc).lmac.buffer; + ptVar9 = (frame->txdesc).lmac.hw_desc; + *(undefined *)&ptVar4[1].length = 0x40; + *(undefined *)((int)&ptVar4[1].length + 1) = 0; + *(undefined *)((int)&ptVar4[1].length + 2) = 0; + *(undefined *)((int)&ptVar4[1].length + 3) = 0; + memcpy(&ptVar4[1].lenheader,&mac_addr_bcst,6); + memcpy((void *)((int)&ptVar4[1].lenpad + 2),&vif_info_tab[bVar1].mac_addr,6); + memcpy(&ptVar4[1].next,&psVar3->bssid,6); + type = (uint)txl_cntrl_env.seqnbr; + *(undefined *)&ptVar4[1].dma_desc[0].src = 0; + txl_cntrl_env.seqnbr = (uint16_t)((type + 1) * 0x10000 >> 0x10); + iVar5 = (type + 1) * 0x100000; + *(undefined *)((int)&ptVar4[1].txdesc + 2) = (char)((uint)iVar5 >> 0x10); + *(undefined *)((int)&ptVar4[1].txdesc + 3) = (char)((uint)iVar5 >> 0x18); + bVar2 = puVar8[-1]; + *(byte *)((int)&ptVar4[1].dma_desc[0].src + 1) = bVar2; + type = 0; + while ((uint)bVar2 != type) { + *(u8_l *)((int)&ptVar4[1].dma_desc[0].src + type + 2) = puVar8[type]; + type = type + 1; + } + (ptVar9->thd).field_3 = 0x42045cf0; + (ptVar9->thd).field_5 = (ptVar9->thd).field_5 - (uint)psVar3->add_ie_len; + (frame->cfm).cfm_func = (cfm_func_ptr *)0x0; + (frame->cfm).env = (void *)0x0; + iVar6 = iVar6 + 1; + puVar8 = puVar8 + 0x22; + (frame->txdesc).host.vif_idx = psVar3->vif_idx; + (frame->txdesc).host.staid = -1; + txl_frame_push(frame,'\x03'); + } + return; +} + + + +void scan_send_cancel_cfm(uint8_t status,ke_task_id_t dest_id) + +{ + uint8_t *puVar1; + + puVar1 = (uint8_t *)ke_msg_alloc(0x804,dest_id,2,1); + *puVar1 = status; + ke_msg_send(); + return; +} + + + +int scan_cancel_req_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + + kVar1 = ke_state_get(2); + if (CONCAT31(extraout_var,kVar1) == 0) { + scan_send_cancel_cfm('\x01',src_id); + } + else { + DAT_4201e57f = 1; + } + return 0; +} + + + +int scan_start_req_handler + (ke_msg_id_t msgid,scan_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + int iVar1; + ke_state_t kVar2; + undefined *puVar3; + undefined3 extraout_var; + + puVar3 = (undefined *)ke_msg_alloc(0x801,src_id,dest_id,1); + kVar2 = ke_state_get(2); + if (CONCAT31(extraout_var,kVar2) == 0) { + if (param->chan_cnt == '\0') { + assert_err("param->chan_cnt > 0","module",0x46); + } + *puVar3 = 0; + DAT_4201e57e = 0; + iVar1 = 1; + param = param; + DAT_4201e57c = src_id; + scan_ie_download(param); + } + else { + *puVar3 = 8; + iVar1 = 0; + } + ke_msg_send(puVar3); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +undefined4 mm_scan_channel_end_ind_handler(void) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + + kVar1 = ke_state_get(2); + if (CONCAT31(extraout_var,kVar1) != 3) { + assert_err("ke_state_get(TASK_SCAN) == SCAN_WAIT_BEACON_PROBE_RSP","module",0xc4); + } + mm_env.rx_filter_lmac_enable = mm_env.rx_filter_lmac_enable & 0xffffddff; + _DAT_44b00060 = mm_env.rx_filter_lmac_enable | mm_env.rx_filter_umac; + DAT_4201e57e = DAT_4201e57e + 1; + if ((DAT_4201e57e < param->chan_cnt) && (DAT_4201e57f == '\0')) { + scan_set_channel_request(); + } + else { + ke_msg_free(¶m[-1].add_ies); + if (DAT_4201e57f == '\0') { + ke_msg_send_basic(0x802,DAT_4201e57c,2); + } + else { + scan_send_cancel_cfm('\0',DAT_4201e57c); + DAT_4201e57f = '\0'; + } + ke_state_set(2,0); + } + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int mm_scan_channel_start_ind_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + scan_start_req *psVar1; + uint uVar2; + ke_state_t kVar3; + undefined3 extraout_var; + + psVar1 = param; + uVar2 = (uint)DAT_4201e57e; + kVar3 = ke_state_get(2); + if (CONCAT31(extraout_var,kVar3) != 2) { + assert_err("ke_state_get(TASK_SCAN) == SCAN_WAIT_CHANNEL","module",0x9d); + } + mm_env.rx_filter_lmac_enable = mm_env.rx_filter_lmac_enable | 0x2200; + _DAT_44b00060 = mm_env.rx_filter_lmac_enable | mm_env.rx_filter_umac; + if ((psVar1->chan[uVar2].flags & 1) == 0) { + scan_probe_req_tx(); + } + ke_state_set(2,3); + return 0; +} + + + +void txl_buffer_reinit(void) + +{ + txl_buffer_env.list[0].first = (txl_buffer_tag *)0x0; + txl_buffer_env.list[0].last = (txl_buffer_tag *)0x0; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_buffer_init(void) + +{ + uint uVar1; + txl_buffer_control *ptVar2; + txl_buffer_control *ptVar3; + uint8_t uVar4; + byte bVar5; + undefined3 extraout_var; + undefined3 extraout_var_00; + + txl_buffer_reinit(); + ptVar3 = txl_buffer_control_desc; + do { + *(undefined4 *)ptVar3->field_0 = 0xbadcab1e; + uVar4 = phy_get_ntx(); + *(int *)(ptVar3->field_0 + 4) = CONCAT31(extraout_var,uVar4) << 0xe; + bVar5 = phy_get_ntx(); + *(int *)(ptVar3->field_0 + 8) = (1 << ((uint)bVar5 + 1 & 0x1f)) + -1; + *(undefined4 *)(ptVar3->field_0 + 0xc) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x10) = 0xffff0704; + *(undefined4 *)(ptVar3->field_0 + 0x14) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x18) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x1c) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x20) = 0; + ptVar2 = ptVar3 + 1; + *(uint *)(ptVar3->field_0 + 0x24) = _DAT_44b000a0 & 0xff; + *(uint *)(ptVar3->field_0 + 0x28) = _DAT_44b000a0 & 0xff; + *(uint *)(ptVar3->field_0 + 0x2c) = _DAT_44b000a0 & 0xff; + uVar1 = _DAT_44b000a0; + ptVar3->mac_control_info = 0x2200; + ptVar3->phy_control_info = 0x3f0000; + *(uint *)(ptVar3->field_0 + 0x30) = uVar1 & 0xff; + ptVar3 = ptVar2; + } while (ptVar2 != txl_frame_buf_ctrl); + ptVar3 = txl_buffer_control_desc_bcmc; + do { + *(undefined4 *)ptVar3->field_0 = 0xbadcab1e; + uVar4 = phy_get_ntx(); + *(int *)(ptVar3->field_0 + 4) = CONCAT31(extraout_var_00,uVar4) << 0xe; + bVar5 = phy_get_ntx(); + *(int *)(ptVar3->field_0 + 8) = (1 << ((uint)bVar5 + 1 & 0x1f)) + -1; + *(undefined4 *)(ptVar3->field_0 + 0xc) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x10) = 0xffff0704; + *(undefined4 *)(ptVar3->field_0 + 0x14) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x18) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x1c) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x20) = 0; + uVar1 = _DAT_44b000a0; + ptVar2 = ptVar3 + 1; + *(undefined4 *)(ptVar3->field_0 + 0x28) = 0; + *(uint *)(ptVar3->field_0 + 0x24) = uVar1 & 0xff; + *(undefined4 *)(ptVar3->field_0 + 0x2c) = 0; + *(undefined4 *)(ptVar3->field_0 + 0x30) = 0; + ptVar3->mac_control_info = 0; + ptVar3->phy_control_info = 0x3f0000; + ptVar3 = ptVar2; + } while (ptVar2 != txl_buffer_control_desc); + return; +} + + + +void txl_buffer_reset(void) + +{ + txl_buffer_env.list[0].first = (txl_buffer_tag *)0x0; + txl_buffer_env.list[0].last = (txl_buffer_tag *)0x0; + return; +} + + + +txl_buffer_tag * txl_buffer_alloc(txdesc *txdesc,uint8_t access_category,uint8_t user_idx) + +{ + ushort uVar1; + txl_buffer_tag *ptVar2; + txl_buffer_tag *ptVar3; + txl_buffer_control *ptVar4; + uint uVar5; + int iVar6; + int iVar7; + + uVar5 = (uint)(txdesc->umac).head_len; + *(uint8_t *)(txdesc->buf + 0x3b) = user_idx; + txdesc->buf[2] = (uVar5 + 0xf & 0xfffffff0) - uVar5; + txdesc->buf[0xe] = 0xcafefade; + uVar1 = (txdesc->host).flags; + txdesc->buf[1] = uVar5; + ptVar3 = (txl_buffer_tag *)txdesc->buf; + if ((uVar1 & 8) == 0) { + txu_cntrl_frame_build(txdesc,(int)txdesc->buf + uVar5 + 0x14c); + } + ptVar4 = (txdesc->umac).buf_control; + iVar6 = 0; + do { + iVar7 = iVar6 + 4; + *(undefined4 *)((int)txdesc->buf + iVar6 + 0xf0) = *(undefined4 *)(ptVar4->field_0 + iVar6); + iVar6 = iVar7; + } while (iVar7 != 0x3c); + ptVar2 = ptVar3; + if (txl_buffer_env.list[0].first != (txl_buffer_tag *)0x0) { + (txl_buffer_env.list[0].last)->next = ptVar3; + ptVar2 = txl_buffer_env.list[0].first; + } + txl_buffer_env.list[0].first = ptVar2; + txl_buffer_env.list[0].last = ptVar3; + txdesc->buf[4] = 0; + return ptVar3; +} + + + +void txl_buffer_update_thd(txdesc *txdesc) + +{ + char "txl_buffer_update_thd" [22]; + uint32_t *puVar1; + int iVar2; + tx_pbd *in_a2; + tx_pbd *ptVar3; + uint32_t uVar4; + txl_buffer_tag *ptVar5; + tx_hw_desc *ptVar6; + uint32_t uVar7; + + ptVar5 = (txdesc->lmac).buffer; + ptVar6 = (txdesc->lmac).hw_desc; + puVar1 = (txdesc->host).pbuf_chained_ptr; + iVar2 = 0; + ptVar3 = ptVar5->tbd_body; + while (*puVar1 != 0) { + ptVar3->upatterntx = 0xcafefade; + uVar4 = *puVar1; + ptVar3->datastartptr = uVar4; + uVar7 = puVar1[4]; + ptVar3->bufctrlinfo = 0; + iVar2 = iVar2 + 1; + ptVar3->dataendptr = (uVar4 + uVar7) - 1; + *(tx_pbd **)&ptVar3->next = ptVar3 + 1; + puVar1 = puVar1 + 1; + in_a2 = ptVar3; + ptVar3 = ptVar3 + 1; + } + if (iVar2 == 0) { + printf("%s: assert when set add_pbd chain\r\n","txl_buffer_update_thd"); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + uVar4 = ptVar5->lenheader; + (ptVar5->tbd).upatterntx = 0xcafefade; + *(txl_buffer_tag **)&(ptVar5->tbd).datastartptr = ptVar5 + 1; + *(uint8_t **)&(ptVar5->tbd).dataendptr = ptVar5->tkip_mic_icv + uVar4 + 0xb; + *(tx_pbd **)&(ptVar5->tbd).next = ptVar5->tbd_body; + (ptVar5->tbd).bufctrlinfo = 0; + *(tx_pbd **)&(ptVar6->thd).field_3 = &ptVar5->tbd; + in_a2->bufctrlinfo = 0; + (ptVar6->thd).macctrlinfo2 = 0x100; + in_a2->next = 0; + return; +} + + + +void txl_cfm_init(void) + +{ + memset(&txl_cfm_env,0,0x28); + co_list_init((co_list *)&txl_cfm_env); + co_list_init(txl_cfm_env.cfmlist + 1); + co_list_init(txl_cfm_env.cfmlist + 2); + co_list_init(txl_cfm_env.cfmlist + 3); + co_list_init(txl_cfm_env.cfmlist + 4); + return; +} + + + +void txl_cfm_push(txdesc *txdesc,u32_l status,u8_l access_category) + +{ + undefined3 in_register_00002031; + + ((txdesc->lmac).hw_desc)->cfm_ptr->status = status; + co_list_push_back(txl_cfm_env.cfmlist + CONCAT31(in_register_00002031,access_category), + (co_list_hdr *)txdesc); + ke_evt_set(txl_cfm_evt_bit[CONCAT31(in_register_00002031,access_category)]); + return; +} + + +/* +Unable to decompile 'txl_cfm_evt' +Cause: Exception while decompiling 2305f834: Decompiler process died + +*/ + + +void txl_cfm_flush(u8_l access_category,co_list *list,u32_l status) + +{ + txdesc *txdesc; + tx_cfm_tag *ptVar1; + + while (txdesc = (txdesc *)co_list_pop_front(list), txdesc != (txdesc *)0x0) { + ptVar1 = ((txdesc->lmac).hw_desc)->cfm_ptr; + if ((txdesc->lmac).agg_desc == (tx_agg_desc *)0x0) { + if (-1 < (int)ptVar1->status) { + ptVar1->status = status; + } + } + else { + ptVar1->status = status | 0x3c000000; + } + if ((txdesc->host).packet_addr == 0) { + txl_frame_cfm(txdesc); + } + else { + txu_cntrl_cfm(txdesc); + txl_cntrl_env.pck_cnt = txl_cntrl_env.pck_cnt - 1; + if ((txdesc->lmac).buffer != (txl_buffer_tag *)0x0) { + (txdesc->lmac).buffer = (txl_buffer_tag *)0x0; + } + } + } + txl_frame_evt(0); + ipc_emb_txcfm_ind(1 << ((uint)access_category & 0x1f)); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void txl_cfm_dma_int_handler(void) + +{ + ps_env.prevent_sleep = ps_env.prevent_sleep & 0xfffffffe; + _DAT_44a00020 = _DAT_44a00024 & 0x100; + return; +} + + + +void txl_cfm_dump(void) + +{ + txl_cfm_env_tag *list; + uint32_t uVar1; + uint32_t **ppuVar2; + + list = &txl_cfm_env; + do { + uVar1 = co_list_cnt((co_list *)list); + if (uVar1 != 0) { + ppuVar2 = (uint32_t **)((bam_env_tag *)list)->pkt_cnt; + while (ppuVar2 != (uint32_t **)0x0) { + ppuVar2 = (uint32_t **)*ppuVar2; + } + } + list = (txl_cfm_env_tag *)&((bam_env_tag *)list)->ssn; + } while ((bam_env_tag *)list != bam_env); + return; +} + + + +void bam_init(void) + +{ + bam_env[0].sta_idx = -1; + ke_state_set(8,0); + return; +} + + + +void bam_send_air_action_frame + (int param_1,bam_env_tag *param_2,int param_3,uint8_t param_4,int param_5, + uint16_t param_6,cfm_func_ptr *param_7) + +{ + byte bVar1; + uint8_t ac; + uint16_t uVar2; + txl_frame_desc_tag *frame; + undefined2 extraout_var; + undefined2 extraout_var_00; + undefined2 extraout_var_01; + txl_buffer_tag *ptVar3; + tx_hw_desc *ptVar4; + int iVar5; + uint uVar6; + char acStack72 [20]; + + bVar1 = sta_info_tab[param_1].inst_nbr; + uVar6 = (uint)bVar1; + phy_get_channel((phy_channel_info *)acStack72,'\0'); + frame = txl_frame_get((uint)(acStack72[0] != '\0'),0x100); + if (frame == (txl_frame_desc_tag *)0x0) { + return; + } + tpc_update_frame_tx_power(vif_info_tab + uVar6,frame); + ptVar3 = (frame->txdesc).lmac.buffer; + *(undefined *)&ptVar3[1].length = 0xd0; + *(undefined *)((int)&ptVar3[1].length + 1) = 0; + *(undefined *)((int)&ptVar3[1].length + 2) = 0; + *(undefined *)((int)&ptVar3[1].length + 3) = 0; + *(uint16_t *)&ptVar3[1].lenheader = sta_info_tab[param_1].mac_addr.array[0]; + *(uint16_t *)((int)&ptVar3[1].lenheader + 2) = sta_info_tab[param_1].mac_addr.array[1]; + *(uint16_t *)&ptVar3[1].lenpad = sta_info_tab[param_1].mac_addr.array[2]; + *(uint16_t *)((int)&ptVar3[1].lenpad + 2) = vif_info_tab[uVar6].mac_addr.array[0]; + *(uint16_t *)&ptVar3[1].flags = vif_info_tab[uVar6].mac_addr.array[1]; + *(uint16_t *)((int)&ptVar3[1].flags + 2) = vif_info_tab[uVar6].mac_addr.array[2]; + if (vif_info_tab[uVar6].type == '\x02') { + *(uint16_t *)&ptVar3[1].next = vif_info_tab[uVar6].mac_addr.array[0]; + *(uint16_t *)((int)&ptVar3[1].next + 2) = vif_info_tab[uVar6].mac_addr.array[1]; + uVar2 = vif_info_tab[uVar6].mac_addr.array[2]; + } + else { + *(uint16_t *)&ptVar3[1].next = sta_info_tab[param_1].mac_addr.array[0]; + *(uint16_t *)((int)&ptVar3[1].next + 2) = sta_info_tab[param_1].mac_addr.array[1]; + uVar2 = sta_info_tab[param_1].mac_addr.array[2]; + } + *(uint16_t *)&ptVar3[1].txdesc = uVar2; + uVar6 = (uint)txl_cntrl_env.seqnbr; + txl_cntrl_env.seqnbr = (uint16_t)((uVar6 + 1) * 0x10000 >> 0x10); + iVar5 = (uVar6 + 1) * 0x100000; + *(undefined *)((int)&ptVar3[1].txdesc + 2) = (char)((uint)iVar5 >> 0x10); + *(undefined *)((int)&ptVar3[1].txdesc + 3) = (char)((uint)iVar5 >> 0x18); + (frame->txdesc).host.vif_idx = bVar1; + (frame->txdesc).host.staid = (uint8_t)param_1; + if (param_3 == 1) { + uVar2 = me_build_add_ba_rsp((uint32_t)ptVar3[1].dma_desc,param_2,(uint16_t)param_5,param_4, + param_6); + iVar5 = CONCAT22(extraout_var_00,uVar2); +LAB_2305fb96: + iVar5 = iVar5 + 0x18; + } + else { + if (param_3 == 0) { + ac = "\x01"[param_5 >> 2 & 0xf]; + uVar2 = me_build_add_ba_req((uint32_t)ptVar3[1].dma_desc,param_2); + iVar5 = CONCAT22(extraout_var,uVar2) + 0x18; + goto LAB_2305fb48; + } + if (param_3 == 2) { + uVar2 = me_build_del_ba((uint32_t)ptVar3[1].dma_desc,param_2,param_6); + iVar5 = CONCAT22(extraout_var_01,uVar2); + goto LAB_2305fb96; + } + assert_warn("0","module",0x25d); + iVar5 = 0x18; + } + ac = '\x03'; +LAB_2305fb48: + ptVar4 = (frame->txdesc).lmac.hw_desc; + (ptVar4->thd).field_5 = (ptVar4->thd).field_4 + -1 + iVar5; + (ptVar4->thd).frmlen = iVar5 + 4; + if (param_7 != (cfm_func_ptr *)0x0) { + (frame->cfm).cfm_func = param_7; + *(bam_env_tag **)&(frame->cfm).env = param_2; + } + txl_frame_push(frame,ac); + return; +} + + + +undefined4 rxu_mgt_ind_handler(int param_1) + +{ + int iVar1; + int iVar2; + byte bVar3; + byte bVar4; + ushort uVar5; + uint uVar6; + uint uVar7; + + if (*(char *)(param_1 + 0x1d) == '\0') { + uVar5 = *(ushort *)(param_1 + 0x1f); + bVar3 = *(byte *)(param_1 + 7); + bVar4 = *(byte *)(param_1 + 0x1e); + iVar1 = -0x4fc; + if ((uVar5 & 1) != 0) { + iVar1 = -0x4f8; + } + iVar2 = -0x4ec; + if ((uVar5 & 2) == 0) { + iVar2 = -0x4d8; + } + uVar7 = (uint)(uVar5 >> 6); + printf( + "-----------------> AABA Request:\r\n A-MSDU: %s\r\n Block Ack Policy: %s\r\n TID: %u\r\n Number of Buffers: %u\r\n" + ,iVar1 + 0x2307f000,iVar2 + 0x2307f000,(int)(uint)uVar5 >> 2 & 0xf,uVar7); + if (8 < uVar5 >> 6) { + uVar7 = 8; + } + uVar6 = SEXT24((short)((ushort)(uVar7 << 6) | uVar5 & 0x3e | 2)); + uVar7 = uVar6 & 0xffff; + printf( + "-----------------> AABA Response:\r\n A-MSDU: %s\r\n Block Ack Policy: %s\r\n TID: %u\r\n Number of Buffers: %u\r\n" + ,"Not Permitted","Immediate Block Ack",(int)uVar6 >> 2 & 0xf,uVar7 >> 6); + bam_send_air_action_frame((uint)bVar3,0,1,(uint)bVar4,uVar7,0,0); + return 0; + } + return 0; +} + + + +void co_pack8p(uint32_t dst,uint8_t *src,uint32_t len) + +{ + uint8_t *puVar1; + uint8_t *puVar2; + uint32_t uVar3; + + uVar3 = 0; + while (len != uVar3) { + puVar1 = src + uVar3; + puVar2 = (uint8_t *)(dst + uVar3); + uVar3 = uVar3 + 1; + *puVar2 = *puVar1; + } + return; +} + + + +int phy_freq_to_channel(uint8_t band,uint16_t freq) + +{ + undefined3 in_register_00002029; + undefined2 in_register_0000202e; + int iVar1; + int iVar2; + + iVar1 = CONCAT22(in_register_0000202e,freq); + if (CONCAT31(in_register_00002029,band) == 0) { + if (0x48 < (iVar1 - 0x96cU & 0xffff)) { + return 0; + } + if (iVar1 == 0x9b4) { + return 0xe; + } + iVar2 = -0x967; + } + else { + if (CONCAT31(in_register_00002029,band) != 1) { + return 0; + } + if (0x334 < (iVar1 - 0x138dU & 0xffff)) { + return 0; + } + iVar2 = -5000; + } + return (iVar1 + iVar2) / 5; +} + + + +uint16_t phy_channel_to_freq(uint8_t band,int channel) + +{ + undefined3 in_register_00002029; + int iVar1; + + if (CONCAT31(in_register_00002029,band) == 0) { + if (0xd < channel - 1U) { + return 0xffff; + } + if (channel == 0xe) { + return 0x9b4; + } + iVar1 = 0x967; + } + else { + if (0xa4 < channel - 1U) { + return 0xffff; + } + iVar1 = 5000; + } + return (uint16_t)((uint)((channel * 5 + iVar1) * 0x10000) >> 0x10); +} + + + +uint32_t me_add_ie_ssid(uint32_t *frame_addr,uint8_t ssid_len,uint8_t *p_ssid) + +{ + undefined3 in_register_0000202d; + uint32_t len; + + len = CONCAT31(in_register_0000202d,ssid_len); + *(undefined *)*frame_addr = 0; + *(uint8_t *)(*frame_addr + 1) = ssid_len; + if (len != 0) { + co_pack8p(*frame_addr + 2,p_ssid,len); + } + *frame_addr = *frame_addr + len + 2; + return len + 2; +} + + + +uint32_t me_add_ie_supp_rates(uint32_t *frame_addr,mac_rateset *p_rateset) + +{ + uint32_t len; + byte bVar1; + + bVar1 = p_rateset->length; + len = 8; + if (bVar1 < 9) { + len = (uint)bVar1; + } + *(undefined *)*frame_addr = 1; + if (8 < bVar1) { + bVar1 = 8; + } + *(byte *)(*frame_addr + 1) = bVar1; + co_pack8p(*frame_addr + 2,p_rateset->array,len); + *frame_addr = *frame_addr + len + 2; + return len + 2; +} + + + +uint32_t me_add_ie_ext_supp_rates(uint32_t *frame_addr,mac_rateset *p_rateset) + +{ + byte bVar1; + uint32_t uVar2; + uint32_t len; + + bVar1 = p_rateset->length; + *(undefined *)*frame_addr = 0x32; + uVar2 = (uint)bVar1 - 6; + len = (uint)bVar1 - 8; + *(undefined *)(*frame_addr + 1) = (char)len; + co_pack8p(*frame_addr + 2,p_rateset->array + 8,len); + *frame_addr = *frame_addr + uVar2; + return uVar2; +} + + + +uint32_t me_add_ie_ds(uint32_t *frame_addr,uint8_t channel) + +{ + *(undefined *)*frame_addr = 3; + *(undefined *)(*frame_addr + 1) = 1; + *(uint8_t *)(*frame_addr + 2) = channel; + *frame_addr = *frame_addr + 3; + return 3; +} + + + +uint32_t me_add_ie_erp(uint32_t *frame_addr,uint8_t erp_info) + +{ + *(undefined *)*frame_addr = 0x2a; + *(undefined *)(*frame_addr + 1) = 1; + *(uint8_t *)(*frame_addr + 2) = erp_info; + *frame_addr = *frame_addr + 3; + return 3; +} + + + +uint32_t me_add_ie_rsn(uint32_t *frame_addr,uint8_t enc_type) + +{ + undefined3 in_register_0000202d; + uint32_t uVar1; + uint32_t uVar2; + + if (CONCAT31(in_register_0000202d,enc_type) == 1) { + *(undefined *)*frame_addr = 0x30; + *(undefined *)(*frame_addr + 1) = 0x14; + uVar1 = *frame_addr; + *(uint8_t *)(uVar1 + 2) = enc_type; + *(undefined *)(uVar1 + 3) = 0; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 6) = 0xac; + *(undefined *)(uVar1 + 7) = 4; + *(undefined *)(uVar1 + 4) = 0; + *(undefined *)(uVar1 + 5) = 0xf; + uVar1 = *frame_addr; + *(uint8_t *)(uVar1 + 8) = enc_type; + *(undefined *)(uVar1 + 9) = 0; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 0xc) = 0xac; + *(undefined *)(uVar1 + 0xd) = 4; + *(undefined *)(uVar1 + 10) = 0; + *(undefined *)(uVar1 + 0xb) = 0xf; + uVar2 = *frame_addr; + uVar1 = 0x16; + *(uint8_t *)(uVar2 + 0xe) = enc_type; + *(undefined *)(uVar2 + 0xf) = 0; + uVar2 = *frame_addr; + *(undefined *)(uVar2 + 0x12) = 0xac; + *(undefined *)(uVar2 + 0x10) = 0; + *(undefined *)(uVar2 + 0x11) = 0xf; + *(undefined *)(uVar2 + 0x13) = 2; + uVar2 = *frame_addr; + *(undefined *)(uVar2 + 0x14) = 0; + *(undefined *)(uVar2 + 0x15) = 0; + } + else { + uVar1 = 0; + if (CONCAT31(in_register_0000202d,enc_type) == 2) { + *(undefined *)*frame_addr = 0x30; + *(undefined *)(*frame_addr + 1) = 0x18; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 2) = 1; + *(undefined *)(uVar1 + 3) = 0; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 4) = 0; + *(undefined *)(uVar1 + 5) = 0xf; + *(undefined *)(uVar1 + 6) = 0xac; + *(uint8_t *)(uVar1 + 7) = enc_type; + uVar1 = *frame_addr; + *(uint8_t *)(uVar1 + 8) = enc_type; + *(undefined *)(uVar1 + 9) = 0; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 10) = 0; + *(undefined *)(uVar1 + 0xb) = 0xf; + *(undefined *)(uVar1 + 0xc) = 0xac; + *(uint8_t *)(uVar1 + 0xd) = enc_type; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 0x11) = 4; + *(undefined *)(uVar1 + 0xe) = 0; + *(undefined *)(uVar1 + 0xf) = 0xf; + *(undefined *)(uVar1 + 0x10) = 0xac; + uVar2 = *frame_addr; + uVar1 = 0x1a; + *(undefined *)(uVar2 + 0x12) = 1; + *(undefined *)(uVar2 + 0x13) = 0; + uVar2 = *frame_addr; + *(undefined *)(uVar2 + 0x14) = 0; + *(undefined *)(uVar2 + 0x15) = 0xf; + *(undefined *)(uVar2 + 0x16) = 0xac; + *(uint8_t *)(uVar2 + 0x17) = enc_type; + uVar2 = *frame_addr; + *(undefined *)(uVar2 + 0x18) = 0; + *(undefined *)(uVar2 + 0x19) = 0; + } + } + *frame_addr = *frame_addr + uVar1; + return uVar1; +} + + + +uint32_t me_add_ie_wpa(uint32_t *frame_addr,uint8_t enc_type) + +{ + uint32_t uVar1; + undefined3 in_register_0000202d; + uint32_t uVar2; + + uVar1 = 0; + if (CONCAT31(in_register_0000202d,enc_type) == 2) { + *(undefined *)*frame_addr = 0xdd; + *(undefined *)(*frame_addr + 1) = 0x1c; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 5) = 1; + *(undefined *)(uVar1 + 2) = 0; + *(undefined *)(uVar1 + 3) = 0x50; + *(undefined *)(uVar1 + 4) = 0xf2; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 6) = 1; + *(undefined *)(uVar1 + 7) = 0; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 8) = 0; + *(undefined *)(uVar1 + 9) = 0x50; + *(undefined *)(uVar1 + 10) = 0xf2; + *(uint8_t *)(uVar1 + 0xb) = enc_type; + uVar1 = *frame_addr; + *(uint8_t *)(uVar1 + 0xc) = enc_type; + *(undefined *)(uVar1 + 0xd) = 0; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 0xe) = 0; + *(undefined *)(uVar1 + 0xf) = 0x50; + *(undefined *)(uVar1 + 0x10) = 0xf2; + *(uint8_t *)(uVar1 + 0x11) = enc_type; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 0x12) = 0; + *(undefined *)(uVar1 + 0x13) = 0x50; + *(undefined *)(uVar1 + 0x14) = 0xf2; + *(undefined *)(uVar1 + 0x15) = 4; + uVar1 = *frame_addr; + *(undefined *)(uVar1 + 0x16) = 1; + *(undefined *)(uVar1 + 0x17) = 0; + uVar2 = *frame_addr; + uVar1 = 0x1e; + *(undefined *)(uVar2 + 0x18) = 0; + *(undefined *)(uVar2 + 0x19) = 0x50; + *(undefined *)(uVar2 + 0x1a) = 0xf2; + *(uint8_t *)(uVar2 + 0x1b) = enc_type; + } + *frame_addr = *frame_addr + uVar1; + return uVar1; +} + + + +uint32_t me_add_ie_tim(uint32_t *frame_addr,uint8_t dtim_period) + +{ + *(undefined *)*frame_addr = 5; + *(undefined *)(*frame_addr + 1) = 4; + *(uint8_t *)(*frame_addr + 3) = dtim_period; + *frame_addr = *frame_addr + 6; + return 6; +} + + + +uint32_t me_add_ie_ht_capa(uint32_t *frame_addr) + +{ + u16_l uVar1; + uint32_t uVar2; + uint uVar3; + + uVar3 = (uint)me_env.ht_cap.ht_capa_info; + *(undefined *)*frame_addr = 0x2d; + *(undefined *)(*frame_addr + 1) = 0x1a; + uVar2 = *frame_addr; + *(byte *)(uVar2 + 2) = (byte)(uVar3 & 0xfffffff3) | 0xc; + *(undefined *)(uVar2 + 3) = (char)((uVar3 & 0xfffffff3) >> 8); + *(u8_l *)(*frame_addr + 4) = me_env.ht_cap.a_mpdu_param; + co_pack8p(*frame_addr + 5,me_env.ht_cap.mcs_rate,0x10); + uVar1 = me_env.ht_cap.ht_extended_capa; + uVar2 = *frame_addr; + *(undefined *)(uVar2 + 0x15) = (char)me_env.ht_cap.ht_extended_capa; + *(undefined *)(uVar2 + 0x16) = (char)(uVar1 >> 8); + co_pack8p(*frame_addr + 0x17,(uint8_t *)&me_env.ht_cap.tx_beamforming_capa,4); + *(u8_l *)(*frame_addr + 0x1b) = me_env.ht_cap.asel_capa; + *frame_addr = *frame_addr + 0x1c; + return 0x1c; +} + + + +uint32_t me_add_ie_ht_oper(uint32_t *frame_addr,vif_info_tag *p_vif_entry) + +{ + chan_ctxt_tag *pcVar1; + int iVar2; + uint8_t uVar3; + uint32_t uVar4; + + pcVar1 = p_vif_entry->chan_ctxt; + *(undefined *)*frame_addr = 0x3d; + *(undefined *)(*frame_addr + 1) = 0x16; + iVar2 = phy_freq_to_channel((pcVar1->channel).band,(pcVar1->channel).prim20_freq); + *(undefined *)(*frame_addr + 2) = (char)iVar2; + uVar3 = (pcVar1->channel).type; + if ((uVar3 != '\0') && + (uVar3 = '\a', (pcVar1->channel).prim20_freq <= (pcVar1->channel).center1_freq)) { + uVar3 = '\x05'; + } + *(uint8_t *)(*frame_addr + 3) = uVar3; + uVar4 = *frame_addr; + *(undefined *)(uVar4 + 4) = 3; + *(undefined *)(uVar4 + 5) = 0; + uVar4 = *frame_addr; + *(undefined *)(uVar4 + 6) = 0; + *(undefined *)(uVar4 + 7) = 0; + *(undefined *)(*frame_addr + 8) = 0xff; + *frame_addr = *frame_addr + 0x18; + return 0x18; +} + + + +uint16_t me_build_authenticate + (uint32_t frame,uint16_t algo_type,uint16_t seq_nbr,uint16_t status_code, + uint32_t *challenge_array_ptr) + +{ + undefined *puVar1; + undefined *puVar2; + int iVar3; + + *(char *)frame = (char)algo_type; + *(undefined *)(frame + 2) = (char)seq_nbr; + *(undefined *)(frame + 4) = (char)status_code; + *(undefined *)(frame + 1) = (char)(algo_type >> 8); + *(undefined *)(frame + 3) = (char)(seq_nbr >> 8); + *(undefined *)(frame + 5) = (char)(status_code >> 8); + if (challenge_array_ptr != (uint32_t *)0x0) { + *(undefined *)(frame + 6) = 0x10; + *(undefined *)(frame + 7) = 0x80; + iVar3 = 0; + do { + puVar1 = (undefined *)((int)challenge_array_ptr + iVar3); + puVar2 = (undefined *)(frame + 8 + iVar3); + iVar3 = iVar3 + 1; + *puVar2 = *puVar1; + } while (iVar3 != 0x80); + return 0x88; + } + return 6; +} + + + +uint16_t me_build_deauthenticate(uint32_t frame,uint16_t reason_code) + +{ + *(char *)frame = (char)reason_code; + *(undefined *)(frame + 1) = (char)(reason_code >> 8); + return 2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +uint16_t me_build_associate_req + (uint32_t frame,mac_bss_info *bss,mac_addr_conflict171 *old_ap_addr_ptr, + uint8_t vif_idx,uint32_t *ie_addr,uint16_t *ie_len,sm_connect_req *con_par) + +{ + byte bVar1; + u32_l *puVar2; + u8_l uVar3; + ushort uVar4; + mac_ssid *pmVar5; + int8_t *piVar6; + uint uVar7; + u16_l uVar8; + short sVar9; + int iVar10; + uint16_t uVar11; + uint32_t uVar12; + uint32_t uVar13; + uint uVar14; + char *pcVar15; + int8_t *dst; + uint uVar16; + uint uVar17; + uint uVar18; + uint uVar19; + me_chan_config_req *pmVar20; + char cVar21; + char cVar22; + uint uVar23; + u8_l uVar24; + int8_t *apiStack100 [4]; + int8_t iStack81; + undefined2 uStack80; + undefined uStack78; + s8_l min; + s8_l max; + + uVar8 = con_par->listen_interval; + uVar4 = con_par->ie_len; + if (uVar8 == 0) { + uVar8 = 5; + } + apiStack100[0] = (int8_t *)frame; + uVar11 = me_build_capability(vif_idx); + *apiStack100[0] = (int8_t)uVar11; + apiStack100[0][1] = (int8_t)(uVar11 >> 8); + apiStack100[0][2] = (int8_t)uVar8; + apiStack100[0][3] = (int8_t)(uVar8 >> 8); + iVar10 = 4; + if (old_ap_addr_ptr != (mac_addr_conflict171 *)0x0) { + iVar10 = 10; + *(uint16_t *)(apiStack100[0] + 4) = old_ap_addr_ptr->array[0]; + *(uint16_t *)(apiStack100[0] + 6) = old_ap_addr_ptr->array[1]; + *(uint16_t *)(apiStack100[0] + 8) = old_ap_addr_ptr->array[2]; + } + apiStack100[0] = apiStack100[0] + iVar10; + *(int8_t **)ie_addr = apiStack100[0]; + uVar12 = me_add_ie_ssid((uint32_t *)apiStack100,(bss->ssid).length,(bss->ssid).array); + uVar13 = me_add_ie_supp_rates((uint32_t *)apiStack100,&bss->rate_set); + sVar9 = (short)iVar10 + (short)uVar13 + (short)uVar12; + if (8 < (bss->rate_set).length) { + uVar12 = me_add_ie_ext_supp_rates((uint32_t *)apiStack100,&bss->rate_set); + sVar9 = sVar9 + (short)uVar12; + } + if ((uVar11 & 0x100) != 0) { + dst = apiStack100[0] + 1; + *apiStack100[0] = '!'; + apiStack100[0] = apiStack100[0] + 2; + *dst = '\x02'; + phy_get_rf_gain_capab((int8_t *)&uStack80,&iStack81); + bVar1 = bss->chan->tx_power; + if ((char)bVar1 < (char)uStack80) { + uStack80 = uStack80 & 0xff00 | (ushort)bVar1; + } + *apiStack100[0] = iStack81; + apiStack100[0][1] = (char)uStack80; + dst = apiStack100[0] + 3; + apiStack100[0][2] = '$'; + apiStack100[0] = apiStack100[0] + 4; + if (bss->chan->band == '\0') { + pmVar20 = &me_env.chan; + iVar10 = 1; + uVar3 = me_env.chan.chan2G4_cnt; + } + else { + pmVar20 = (me_chan_config_req *)me_env.chan.chan5G; + iVar10 = 4; + uVar3 = me_env.chan.chan5G_cnt; + } + uVar19 = 0; + cVar21 = '\0'; + uVar24 = '\0'; + uVar7 = 0; + uVar17 = 0; + while( true ) { + piVar6 = apiStack100[0]; + uVar23 = uVar19 + 2 & 0xff; + pcVar15 = apiStack100[0] + 1; + if (uVar24 == uVar3) break; + uVar16 = uVar7; + uVar18 = uVar17; + if ((pmVar20->chan2G4[0].flags & 2) == 0) { + uVar14 = phy_freq_to_channel(pmVar20->chan2G4[0].band,pmVar20->chan2G4[0].freq); + uVar16 = uVar14 & 0xff; + uVar18 = uVar16; + cVar22 = cVar21; + if ((cVar21 != '\0') && (uVar18 = uVar17, (uVar14 & 0xff) - uVar7 != iVar10)) { + cVar22 = cVar21 + '\x01'; + *piVar6 = (int8_t)uVar17; + apiStack100[0] = piVar6 + 2; + *pcVar15 = cVar21; + uVar19 = uVar23; + } + cVar21 = cVar22 + '\x01'; + pmVar20 = (me_chan_config_req *)(pmVar20->chan2G4 + 1); + } + uVar24 = uVar24 + '\x01'; + uVar7 = uVar16; + uVar17 = uVar18; + } + *apiStack100[0] = (int8_t)uVar17; + sVar9 = sVar9 + 6 + (short)uVar23; + apiStack100[0] = apiStack100[0] + 2; + *pcVar15 = cVar21; + *dst = (int8_t)uVar23; + } + pmVar5 = &con_par->ssid; + iVar10 = -(int)con_par; + while ((sm_connect_req *)(&pmVar5->length + uVar4) != con_par) { + puVar2 = con_par->ie_buf; + dst = apiStack100[0] + iVar10 + (int)con_par; + con_par = (sm_connect_req *)(con_par->ssid).array; + *dst = *(int8_t *)puVar2; + } + uVar11 = sVar9 + uVar4; + dst = apiStack100[0] + uVar4; + apiStack100[0] = dst; + if ((bss->valid_flags & 1) != 0) { + memset(&uStack78,0,0xe); + uStack80 = 0x7dd; + min = 'P'; + co_pack8p((uint32_t)dst,(uint8_t *)&uStack80,9); + uVar11 = uVar11 + (ushort)uStack80._1_1_ + 2; + apiStack100[0] = apiStack100[0] + (uint)uStack80._1_1_ + 2; + } + if (((bss->valid_flags & 2) != 0) && (me_env.ht_supported != false)) { + uVar12 = me_add_ie_ht_capa((uint32_t *)apiStack100); + uVar11 = uVar11 + (short)uVar12; + } + *ie_len = (short)apiStack100[0] - (short)*ie_addr; + return uVar11; +} + + + +uint16_t me_build_add_ba_req(uint32_t frame,bam_env_tag *bam_env) + +{ + uint16_t uVar1; + uint uVar2; + int iVar3; + + *(undefined *)frame = 3; + *(undefined *)(frame + 1) = 0; + *(uint8_t *)(frame + 2) = bam_env->dialog_token; + uVar2 = (uint)bam_env->ba_policy << 1 | (uint)bam_env->tid << 2 | (uint)bam_env->buffer_size << 6; + *(undefined *)(frame + 3) = (char)uVar2; + *(undefined *)(frame + 4) = (char)(uVar2 >> 8); + uVar1 = bam_env->ba_timeout; + *(undefined *)(frame + 5) = (char)uVar1; + *(undefined *)(frame + 6) = (char)(uVar1 >> 8); + iVar3 = (uint)bam_env->ssn << 0x14; + *(undefined *)(frame + 7) = (char)((uint)iVar3 >> 0x10); + *(undefined *)(frame + 8) = (char)((uint)iVar3 >> 0x18); + return 9; +} + + + +uint16_t me_build_add_ba_rsp(uint32_t frame,bam_env_tag *bam_env,uint16_t param,uint8_t dialog_token + ,uint16_t status_code) + +{ + undefined2 in_register_0000203a; + + *(undefined *)frame = 3; + *(undefined *)(frame + 1) = 1; + *(undefined *)(frame + 5) = (char)param; + *(undefined *)(frame + 4) = (char)(status_code >> 8); + *(uint8_t *)(frame + 2) = dialog_token; + *(undefined *)(frame + 3) = (char)status_code; + *(undefined *)(frame + 6) = (char)(param >> 8); + if (CONCAT22(in_register_0000203a,status_code) == 0) { + *(undefined *)(frame + 7) = 0xd0; + *(undefined *)(frame + 8) = 7; + } + else { + *(undefined *)(frame + 7) = 0; + *(undefined *)(frame + 8) = 0; + } + return 9; +} + + + +uint16_t me_build_del_ba(uint32_t frame,bam_env_tag *bam_env,uint16_t reason_code) + +{ + byte bVar1; + + *(undefined *)frame = 3; + *(undefined *)(frame + 1) = 2; + bVar1 = (byte)(((uint)bam_env->tid << 0x1c) >> 0x18); + if (bam_env->dev_type == '\x01') { + bVar1 = bVar1 | 8; + } + *(undefined *)(frame + 2) = 0; + *(byte *)(frame + 3) = bVar1; + *(undefined *)(frame + 4) = (char)reason_code; + *(undefined *)(frame + 5) = (char)(reason_code >> 8); + return 6; +} + + + +void me_extract_rate_set(uint32_t buffer,uint16_t buflen,mac_rateset *mac_rate_set_ptr) + +{ + byte bVar1; + byte bVar2; + int iVar3; + undefined2 in_register_0000202e; + uint uVar4; + u8_l *puVar5; + uint uVar6; + + mac_rate_set_ptr->length = '\0'; + iVar3 = mac_ie_find(CONCAT22(in_register_0000202e,buflen),1); + if (iVar3 != 0) { + bVar1 = *(byte *)(iVar3 + 1); + uVar4 = (uint)bVar1; + if (bVar1 < 0xd) { + puVar5 = mac_rate_set_ptr->array; + while (uVar4 = uVar4 - 1, uVar4 != 0xffffffff) { + *puVar5 = (puVar5 + 1)[iVar3 - (int)mac_rate_set_ptr]; + puVar5 = puVar5 + 1; + } + mac_rate_set_ptr->length = bVar1; + iVar3 = mac_ie_find(buffer,CONCAT22(in_register_0000202e,buflen),0x32); + if (iVar3 != 0) { + bVar1 = *(byte *)(iVar3 + 1); + uVar4 = (uint)bVar1; + if (0xc < mac_rate_set_ptr->length + uVar4) { + assert_err("mac_rate_set_ptr->length + elmt_length <= MAC_RATESET_LEN","module",0x396); + } + bVar2 = mac_rate_set_ptr->length; + if (bVar2 + uVar4 < 0xd) { + uVar6 = 0; + while (uVar4 != uVar6) { + mac_rate_set_ptr->array[bVar2 + uVar6] = *(u8_l *)(iVar3 + 2 + uVar6); + uVar6 = uVar6 + 1; + } + mac_rate_set_ptr->length = bVar1 + mac_rate_set_ptr->length; + } + } + } + } + return; +} + + + +void me_extract_power_constraint(uint32_t buffer,uint16_t buflen,mac_bss_info *bss) + +{ + int iVar1; + uint8_t uVar2; + + iVar1 = mac_ie_find(0x20); + uVar2 = '\0'; + if (iVar1 != 0) { + uVar2 = *(uint8_t *)(iVar1 + 2); + } + bss->power_constraint = uVar2; + return; +} + + + +void me_extract_country_reg(int param_1) + +{ + uint16_t *puVar1; + int iVar2; + uint uVar3; + byte *pbVar4; + uint uVar5; + byte bVar6; + uint uVar7; + int iVar8; + + iVar2 = mac_ie_find(7); + if (iVar2 != 0) { + puVar1 = *(uint16_t **)(param_1 + 0x4c); + iVar8 = 1; + if (*(uint8_t *)(puVar1 + 1) != '\0') { + iVar8 = 4; + } + uVar3 = phy_freq_to_channel(*(uint8_t *)(puVar1 + 1),*puVar1); + uVar7 = 5; + while (uVar7 <= (uint)*(byte *)(iVar2 + 1) + 1) { + pbVar4 = (byte *)(uVar7 + iVar2); + uVar5 = (uint)*pbVar4; + bVar6 = 0; + while (bVar6 != pbVar4[1]) { + if (uVar5 == (uVar3 & 0xff)) { + *(byte *)(puVar1 + 2) = pbVar4[2]; + return; + } + bVar6 = bVar6 + 1; + uVar5 = uVar5 + iVar8 & 0xff; + } + uVar7 = uVar7 + 3 & 0xff; + } + } + return; +} + + + +void me_extract_mobility_domain(uint32_t buffer,uint16_t buflen,mac_bss_info *bss) + +{ + int iVar1; + + iVar1 = mac_ie_find(0x36); + if (iVar1 == 0) { + (bss->mde).mdid = 0; + (bss->mde).ft_capability_policy = '\0'; + } + else { + (bss->mde).mdid = *(uint16_t *)(iVar1 + 2); + (bss->mde).ft_capability_policy = *(uint8_t *)(iVar1 + 4); + } + return; +} + + + +uint me_extract_csa(undefined4 param_1,undefined4 param_2,undefined *param_3,int param_4) + +{ + byte bVar1; + byte bVar2; + bool band; + short sVar3; + uint16_t uVar4; + uint16_t uVar5; + uint16_t uVar6; + uint uVar7; + uint uVar8; + int iVar9; + int iVar10; + undefined uVar11; + + uVar7 = mac_ie_find(0x25); + uVar8 = mac_ie_find(param_1,param_2,0x3c); + if ((uVar7 | uVar8) == 0) { + return 0; + } + iVar9 = mac_ie_find(param_1,param_2,0x3e); + iVar10 = mac_ie_find(param_1,param_2,0xc4); + if (iVar10 != 0) { + iVar10 = mac_ie_find(iVar10 + 2,(uint)*(byte *)(iVar10 + 1),0xc2); + } + if (uVar7 == 0) { + bVar1 = *(byte *)(uVar8 + 5); + *param_3 = *(undefined *)(uVar8 + 2); + bVar2 = *(byte *)(uVar8 + 4); + } + else { + bVar1 = *(byte *)(uVar7 + 4); + *param_3 = *(undefined *)(uVar7 + 2); + bVar2 = *(byte *)(uVar7 + 3); + } + uVar7 = (uint)bVar1; + if (bVar1 == 0) { + uVar7 = 2; + } + band = 0xe < bVar2; + uVar4 = phy_channel_to_freq(band,(uint)bVar2); + if (iVar10 != 0) { + uVar8 = (uint)*(byte *)(iVar10 + 2) - 1 & 0xff; + bVar1 = *(byte *)(iVar10 + 4); + uVar11 = 1; + if (uVar8 < 3) { + uVar11 = *(undefined *)((int)&CSWTCH_115 + uVar8); + } + uVar5 = phy_channel_to_freq(band,(uint)*(byte *)(iVar10 + 3)); + uVar6 = 0; + if (bVar1 != 0) { + uVar6 = phy_channel_to_freq(band,(uint)bVar1); + } + goto LAB_230607fe; + } + if (iVar9 == 0) { +LAB_23060860: + uVar6 = 0; + uVar11 = 0; + uVar5 = uVar4; + } + else { + sVar3 = 10; + if (*(char *)(iVar9 + 2) != '\x01') { + if (*(char *)(iVar9 + 2) != '\x03') goto LAB_23060860; + sVar3 = -10; + } + uVar6 = 0; + uVar11 = 1; + uVar5 = uVar4 + sVar3; + } +LAB_230607fe: + *(uint16_t *)(param_4 + 6) = uVar6; + *(bool *)param_4 = band; + *(undefined *)(param_4 + 1) = uVar11; + *(uint16_t *)(param_4 + 2) = uVar4; + *(uint16_t *)(param_4 + 4) = uVar5; + return uVar7; +} + + + +// WARNING: Could not reconcile some variable overlaps + +uint16_t me_build_beacon(uint32_t frame,uint8_t vif_idx,uint16_t *tim_oft,uint8_t *tim_len, + uint8_t hidden_ssid) + +{ + uint8_t enc_type; + short sVar1; + uint16_t uVar2; + uint32_t uVar3; + uint32_t uVar4; + uint32_t uVar5; + uint32_t uVar6; + u8_l ssid_len; + undefined3 in_register_0000202d; + int iVar7; + uint8_t *p_ssid; + undefined3 in_register_00002039; + uint uVar8; + int iVar9; + undefined *puVar10; + mac_rateset *p_rateset; + uint32_t uStack68; + undefined2 uStack64; + undefined uStack62; + undefined uStack61; + u8_l wme_ie [16]; + + iVar7 = CONCAT31(in_register_0000202d,vif_idx); + enc_type = vif_info_tab[iVar7].bss_info.sec_type; + *(undefined *)frame = 0x80; + *(undefined *)(frame + 1) = 0; + *(undefined *)(frame + 2) = 0; + *(undefined *)(frame + 3) = 0; + uStack68 = frame; + memcpy((void *)(frame + 4),&mac_addr_bcst,6); + memcpy((void *)(frame + 10),&vif_info_tab[iVar7].mac_addr,6); + memcpy((void *)(frame + 0x10),&vif_info_tab[iVar7].mac_addr,6); + uVar8 = (uint)txl_cntrl_env.seqnbr; + txl_cntrl_env.seqnbr = (uint16_t)((uVar8 + 1) * 0x10000 >> 0x10); + iVar9 = (uVar8 + 1) * 0x100000; + *(undefined *)(frame + 0x16) = (char)((uint)iVar9 >> 0x10); + *(undefined *)(frame + 0x17) = (char)((uint)iVar9 >> 0x18); + uVar2 = vif_info_tab[iVar7].bss_info.beacon_interval; + *(undefined *)(uStack68 + 0x20) = (char)uVar2; + *(undefined *)(uStack68 + 0x21) = (char)(uVar2 >> 8); + uVar2 = me_build_capability(vif_idx); + if (enc_type != '\0') { + uVar2 = uVar2 | 0x10; + } + p_ssid = vif_info_tab[iVar7].bss_info.ssid.array; + *(undefined *)(uStack68 + 0x22) = (char)uVar2; + *(undefined *)(uStack68 + 0x23) = (char)(uVar2 >> 8); + uStack68 = uStack68 + 0x24; + if (CONCAT31(in_register_00002039,hidden_ssid) == 0) { + ssid_len = vif_info_tab[iVar7].bss_info.ssid.length; + } + else { + printf("Using Hidden SSID [%s]\r\n",p_ssid); + p_ssid = (uint8_t *)0x0; + ssid_len = '\0'; + } + uVar3 = me_add_ie_ssid(&uStack68,ssid_len,p_ssid); + p_rateset = &vif_info_tab[iVar7].bss_info.rate_set; + uVar4 = me_add_ie_supp_rates(&uStack68,p_rateset); + uVar8 = (uVar3 + 0x24 & 0xffff) + uVar4 & 0xffff; + if (8 < vif_info_tab[iVar7].bss_info.rate_set.length) { + uVar3 = me_add_ie_ext_supp_rates(&uStack68,p_rateset); + uVar8 = uVar8 + uVar3 & 0xffff; + } + uVar3 = me_add_ie_ds(&uStack68, + (char)((int)((uint)(vif_info_tab[iVar7].bss_info.chan)->freq - 0x96c) / 5) + + '\x01'); + *tim_oft = (uint16_t)((uVar8 + uVar3) * 0x10000 >> 0x10); + uVar4 = me_add_ie_tim(&uStack68,*(uint8_t *)&vif_info_tab[iVar7].bss_info.beacon_period); + *tim_len = (uint8_t)(uVar4 & 0xff); + uVar5 = me_add_ie_rsn(&uStack68,enc_type); + memcpy(int_rsn_ie,(void *)(uStack68 - (uVar5 & 0xff)),uVar5 & 0xff); + uVar6 = me_add_ie_erp(&uStack68,'\0'); + sVar1 = (short)(uVar8 + uVar3) + (short)(uVar4 & 0xff) + (short)uVar6 + ((ushort)uVar5 & 0xff); + if ((vif_info_tab[iVar7].bss_info.valid_flags & 2) != 0) { + uVar3 = me_add_ie_ht_capa(&uStack68); + uVar4 = me_add_ie_ht_oper(&uStack68,vif_info_tab + iVar7); + sVar1 = sVar1 + (short)uVar4 + (short)uVar3; + } + uVar3 = me_add_ie_wpa(&uStack68,enc_type); + uVar2 = sVar1 + (short)uVar3; + if ((vif_info_tab[iVar7].bss_info.valid_flags & 1) != 0) { + memset(&uStack62,0,0xe); + uStack64 = 0x7dd; + uStack61 = 0x50; + wme_ie._0_2_ = 0x2f2; + wme_ie[3] = '\x01'; + wme_ie[4] = vif_info_tab[iVar7].bss_info.edca_param.qos_info; + co_pack8p(uStack68,(uint8_t *)&uStack64,9); + *(char *)(uStack68 + 1) = *(char *)(uStack68 + 1) + '\x11'; + puVar10 = (undefined *)(uStack68 + 2 + (uint)uStack64._1_1_); + *puVar10 = 0; + uVar3 = vif_info_tab[iVar7].txq_params[1]; + puVar10[1] = (char)uVar3; + puVar10[2] = (char)(uVar3 >> 8); + puVar10[3] = (char)(uVar3 >> 0x10); + puVar10[4] = (char)(uVar3 >> 0x18); + uVar3 = vif_info_tab[iVar7].txq_params[0]; + puVar10[5] = (char)uVar3; + puVar10[6] = (char)(uVar3 >> 8); + puVar10[7] = (char)(uVar3 >> 0x10); + puVar10[8] = (char)(uVar3 >> 0x18); + uVar3 = vif_info_tab[iVar7].txq_params[2]; + puVar10[9] = (char)uVar3; + puVar10[10] = (char)(uVar3 >> 8); + puVar10[0xb] = (char)(uVar3 >> 0x10); + puVar10[0xc] = (char)(uVar3 >> 0x18); + uVar3 = vif_info_tab[iVar7].txq_params[3]; + puVar10[0xd] = (char)uVar3; + puVar10[0xe] = (char)(uVar3 >> 8); + puVar10[0xf] = (char)(uVar3 >> 0x10); + puVar10[0x10] = (char)(uVar3 >> 0x18); + uVar2 = uVar2 + (ushort)uStack64._1_1_ + 0x13; + } + return uVar2; +} + + + +// WARNING: Variable defined which should be unmapped: wme_ie +// WARNING: Could not reconcile some variable overlaps + +uint16_t me_build_probe_rsp(uint32_t frame,uint8_t vif_idx) + +{ + uint8_t enc_type; + short sVar1; + uint16_t uVar2; + uint32_t uVar3; + uint32_t uVar4; + int iVar5; + uint32_t uVar6; + undefined3 in_register_0000202d; + int iVar7; + scan_chan_tag *psVar8; + undefined *puVar9; + mac_rateset *p_rateset; + uint32_t uStack52; + undefined2 uStack48; + undefined uStack46; + undefined uStack45; + u8_l wme_ie [16]; + + iVar7 = CONCAT31(in_register_0000202d,vif_idx); + enc_type = vif_info_tab[iVar7].bss_info.sec_type; + uVar2 = vif_info_tab[iVar7].bss_info.beacon_interval; + *(undefined *)(frame + 8) = (char)uVar2; + *(undefined *)(frame + 9) = (char)(uVar2 >> 8); + uStack52 = frame; + uVar2 = me_build_capability(vif_idx); + if (enc_type != '\0') { + uVar2 = uVar2 | 0x10; + } + *(undefined *)(uStack52 + 10) = (char)uVar2; + *(undefined *)(uStack52 + 0xb) = (char)(uVar2 >> 8); + uStack52 = uStack52 + 0xc; + p_rateset = &vif_info_tab[iVar7].bss_info.rate_set; + uVar3 = me_add_ie_ssid(&uStack52,vif_info_tab[iVar7].bss_info.ssid.length, + vif_info_tab[iVar7].bss_info.ssid.array); + uVar4 = me_add_ie_supp_rates(&uStack52,p_rateset); + sVar1 = (short)uVar3 + (short)uVar4 + 0xc; + if (8 < vif_info_tab[iVar7].bss_info.rate_set.length) { + uVar3 = me_add_ie_ext_supp_rates(&uStack52,p_rateset); + sVar1 = sVar1 + (short)uVar3; + } + psVar8 = vif_info_tab[iVar7].bss_info.chan; + iVar5 = phy_freq_to_channel(psVar8->band,psVar8->freq); + uVar3 = me_add_ie_ds(&uStack52,(uint8_t)iVar5); + uVar4 = me_add_ie_rsn(&uStack52,enc_type); + uVar6 = me_add_ie_erp(&uStack52,'\0'); + sVar1 = sVar1 + (short)uVar4 + (short)uVar3 + (short)uVar6; + if ((vif_info_tab[iVar7].bss_info.valid_flags & 2) != 0) { + uVar3 = me_add_ie_ht_capa(&uStack52); + uVar4 = me_add_ie_ht_oper(&uStack52,vif_info_tab + iVar7); + sVar1 = sVar1 + (short)uVar4 + (short)uVar3; + } + uVar3 = me_add_ie_wpa(&uStack52,enc_type); + uVar2 = sVar1 + (short)uVar3; + if ((vif_info_tab[iVar7].bss_info.valid_flags & 1) != 0) { + memset(&uStack46,0,0xe); + uStack48 = 0x7dd; + uStack45 = 0x50; + wme_ie._0_2_ = 0x2f2; + wme_ie[3] = '\x01'; + wme_ie[4] = vif_info_tab[iVar7].bss_info.edca_param.qos_info; + co_pack8p(uStack52,(uint8_t *)&uStack48,9); + *(char *)(uStack52 + 1) = *(char *)(uStack52 + 1) + '\x11'; + puVar9 = (undefined *)(uStack52 + 2 + (uint)uStack48._1_1_); + *puVar9 = 0; + uVar3 = vif_info_tab[iVar7].txq_params[1]; + puVar9[1] = (char)uVar3; + puVar9[2] = (char)(uVar3 >> 8); + puVar9[3] = (char)(uVar3 >> 0x10); + puVar9[4] = (char)(uVar3 >> 0x18); + uVar3 = vif_info_tab[iVar7].txq_params[0]; + puVar9[5] = (char)uVar3; + puVar9[6] = (char)(uVar3 >> 8); + puVar9[7] = (char)(uVar3 >> 0x10); + puVar9[8] = (char)(uVar3 >> 0x18); + uVar3 = vif_info_tab[iVar7].txq_params[2]; + puVar9[9] = (char)uVar3; + puVar9[10] = (char)(uVar3 >> 8); + puVar9[0xb] = (char)(uVar3 >> 0x10); + puVar9[0xc] = (char)(uVar3 >> 0x18); + uVar3 = vif_info_tab[iVar7].txq_params[3]; + puVar9[0xd] = (char)uVar3; + puVar9[0xe] = (char)(uVar3 >> 8); + puVar9[0xf] = (char)(uVar3 >> 0x10); + puVar9[0x10] = (char)(uVar3 >> 0x18); + uVar2 = uVar2 + (ushort)uStack48._1_1_ + 0x13; + } + return uVar2; +} + + + +// WARNING: Could not reconcile some variable overlaps + +uint16_t me_build_associate_rsp + (uint32_t frame,uint8_t vif_idx,uint16_t status_code,me_sta_add_req *req) + +{ + uint8_t uVar1; + ushort uVar2; + uint16_t uVar3; + uint32_t uVar4; + uint32_t uVar5; + undefined3 in_register_0000202d; + int iVar6; + undefined2 in_register_00002032; + undefined *puStack52; + undefined2 uStack48; + undefined uStack46; + undefined uStack45; + u8_l wme_ie [16]; + + iVar6 = CONCAT31(in_register_0000202d,vif_idx); + uVar1 = vif_info_tab[iVar6].bss_info.sec_type; + puStack52 = (undefined *)frame; + uVar3 = me_build_capability(vif_idx); + if (uVar1 != '\0') { + uVar3 = uVar3 | 0x10; + } + *puStack52 = (char)uVar3; + puStack52[1] = (char)(uVar3 >> 8); + uVar3 = 6; + puStack52[2] = (char)status_code; + puStack52[3] = (char)(status_code >> 8); + uVar2 = req->aid; + puStack52[4] = (char)uVar2; + puStack52[5] = (byte)((uint)uVar2 >> 8) | 0xc0; + puStack52 = puStack52 + 6; + if (CONCAT22(in_register_00002032,status_code) == 0) { + uVar4 = me_add_ie_supp_rates((uint32_t *)&puStack52,&req->rate_set); + uVar3 = (short)uVar4 + 6; + if (8 < (req->rate_set).length) { + uVar4 = me_add_ie_ext_supp_rates((uint32_t *)&puStack52,&req->rate_set); + uVar3 = uVar3 + (short)uVar4; + } + if ((req->flags & 2) != 0) { + uVar4 = me_add_ie_ht_capa((uint32_t *)&puStack52); + uVar5 = me_add_ie_ht_oper((uint32_t *)&puStack52,vif_info_tab + iVar6); + uVar3 = uVar3 + (short)uVar5 + (short)uVar4; + } + if ((req->flags & 1) != 0) { + memset(&uStack46,0,0xe); + uStack48 = 0x7dd; + uStack45 = 0x50; + wme_ie._0_2_ = 0x2f2; + wme_ie[3] = '\x01'; + wme_ie[4] = vif_info_tab[iVar6].bss_info.edca_param.qos_info; + co_pack8p((uint32_t)puStack52,(uint8_t *)&uStack48,9); + puStack52[1] = puStack52[1] + '\x11'; + puStack52 = puStack52 + (uint)uStack48._1_1_ + 2; + *puStack52 = 0; + uVar4 = vif_info_tab[iVar6].txq_params[1]; + puStack52[1] = (char)uVar4; + puStack52[2] = (char)(uVar4 >> 8); + puStack52[3] = (char)(uVar4 >> 0x10); + puStack52[4] = (char)(uVar4 >> 0x18); + uVar4 = vif_info_tab[iVar6].txq_params[0]; + puStack52[5] = (char)uVar4; + puStack52[6] = (char)(uVar4 >> 8); + puStack52[7] = (char)(uVar4 >> 0x10); + puStack52[8] = (char)(uVar4 >> 0x18); + uVar4 = vif_info_tab[iVar6].txq_params[2]; + puStack52[9] = (char)uVar4; + puStack52[10] = (char)(uVar4 >> 8); + puStack52[0xb] = (char)(uVar4 >> 0x10); + puStack52[0xc] = (char)(uVar4 >> 0x18); + uVar4 = vif_info_tab[iVar6].txq_params[3]; + puStack52[0xd] = (char)uVar4; + puStack52[0xe] = (char)(uVar4 >> 8); + puStack52[0xf] = (char)(uVar4 >> 0x10); + puStack52[0x10] = (char)(uVar4 >> 0x18); + uVar3 = uVar3 + (ushort)uStack48._1_1_ + 0x13; + } + } + return uVar3; +} + + + +int me_rc_set_rate_req_handler + (ke_msg_id_t msgid,me_rc_set_rate_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + byte bVar1; + uint16_t fixed_rate_config; + rc_sta_stats *rc_ss; + _Bool _Var2; + undefined3 extraout_var; + + bVar1 = param->sta_idx; + rc_ss = sta_info_tab[bVar1].pol_tbl.sta_stats; + if (rc_ss == (rc_sta_stats *)0x0) { + assert_err("rc_ss != NULL","module",0x31d); + } + fixed_rate_config = param->fixed_rate_cfg; + if (fixed_rate_config == 0xffff) { + rc_ss->fixed_rate_cfg = 0xffff; + rc_ss->info = rc_ss->info & 0x9f; + rc_update_bw_nss_max(sta_info_tab[bVar1].staid,rc_ss->bw_max,rc_ss->no_ss); + } + else { + _Var2 = rc_check_fixed_rate_config(rc_ss,fixed_rate_config); + if (CONCAT31(extraout_var,_Var2) != 0) { + rc_ss->fixed_rate_cfg = fixed_rate_config; + rc_ss->info = rc_ss->info & 0x9f | 0x20; + } + } + return 0; +} + + + +int me_rc_stats_req_handler + (ke_msg_id_t msgid,me_rc_stats_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + rc_sta_stats *rc_ss; + byte *pbVar1; + u32_l uVar2; + uint uVar3; + + pbVar1 = (byte *)ke_msg_alloc(0x140f,src_id,dest_id,0xd0); + rc_ss = sta_info_tab[param->sta_idx].pol_tbl.sta_stats; + *pbVar1 = param->sta_idx; + if (rc_ss == (rc_sta_stats *)0x0) { + *(undefined2 *)(pbVar1 + 2) = 0; + } + else { + *(uint16_t *)(pbVar1 + 2) = rc_ss->no_samples; + uVar3 = 0; + *(uint16_t *)(pbVar1 + 4) = rc_ss->ampdu_len; + *(uint16_t *)(pbVar1 + 6) = rc_ss->ampdu_packets; + *(uint32_t *)(pbVar1 + 8) = rc_ss->avg_ampdu_len; + pbVar1[0xc] = rc_ss->sw_retry_step; + pbVar1[0xd] = rc_ss->sample_wait; + memcpy(pbVar1 + 0x10,rc_ss->retry,0x20); + memcpy(pbVar1 + 0x30,rc_ss->rate_stats,0x78); + while (uVar3 < rc_ss->no_samples) { + uVar2 = rc_calc_tp(rc_ss,(u8_l)uVar3); + *(u32_l *)(pbVar1 + (uVar3 + 0x28) * 4 + 8) = uVar2; + uVar3 = uVar3 + 1 & 0xffff; + } + } + ke_msg_send(pbVar1); + return 0; +} + + + +int me_traffic_ind_req_handler + (ke_msg_id_t msgid,me_traffic_ind_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint uVar1; + uint16_t *puVar2; + sta_ps_traffic sVar3; + sta_ps_traffic sVar4; + + uVar1 = (uint)param->sta_idx; + sVar4 = sta_info_tab[uVar1].traffic_avail; + if (param->uapsd == false) { + if (param->tx_avail == '\0') { + sVar4 = sVar4 & ~PS_TRAFFIC_HOST; + } + else { + sVar4 = sVar4 | PS_TRAFFIC_HOST; + } + sta_info_tab[uVar1].traffic_avail = sVar4; + } + else { + sVar3 = sVar4 & ~UAPSD_TRAFFIC_HOST; + if (param->tx_avail != '\0') { + sVar3 = sVar4 | UAPSD_TRAFFIC_HOST; + } + sta_info_tab[uVar1].traffic_avail = sVar3; + if (sta_info_tab[uVar1].info.uapsd_queues != '\x0f') goto LAB_230611be; + } + puVar2 = (uint16_t *)ke_msg_alloc(0x41,0,5,4); + *puVar2 = sta_info_tab[uVar1].aid; + *(uint8_t *)((int)puVar2 + 3) = sta_info_tab[uVar1].inst_nbr; + *(uint8_t *)(puVar2 + 1) = param->tx_avail; + ke_msg_send(); +LAB_230611be: + ke_msg_send_basic(0x140d,src_id,dest_id); + return 0; +} + + + +int me_sta_del_req_handler + (ke_msg_id_t msgid,me_sta_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t *puVar1; + undefined *puVar2; + + puVar1 = (uint8_t *)ke_msg_alloc(0xc,0,5,1); + *puVar1 = param->sta_idx; + ke_msg_send(); + if (param->tdls_sta != false) { + puVar2 = (undefined *)ke_msg_alloc(0x1413,5,6,2); + *puVar2 = 0; + puVar2[1] = sta_info_tab[param->sta_idx].inst_nbr; + ke_msg_send(); + } + ke_msg_send_basic(0x140a,src_id,dest_id); + return 0; +} + + + +int me_set_control_port_req_handler + (ke_msg_id_t msgid,me_set_control_port_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + byte bVar1; + undefined *puVar2; + uint8_t uVar3; + uint uVar4; + + uVar4 = (uint)param->sta_idx; + bVar1 = sta_info_tab[uVar4].inst_nbr; + uVar3 = (param->control_port_open != false) + '\x01'; + sta_info_tab[uVar4].ctrl_port_state = uVar3; + if ((vif_info_tab[bVar1].type == '\0') && (uVar3 == '\x02')) { + puVar2 = (undefined *)ke_msg_alloc(0x1413,5,6,2); + *puVar2 = 0; + puVar2[1] = sta_info_tab[uVar4].inst_nbr; + ke_msg_send(); + } + ke_msg_send_basic(0x1405,src_id,dest_id); + return 0; +} + + + +int me_chan_config_req_handler + (ke_msg_id_t msgid,me_chan_config_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + memcpy(&me_env.chan,param,0xfe); + ke_msg_send_basic(0x1403,src_id,dest_id); + return 0; +} + + + +int mm_set_ps_mode_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + + kVar1 = ke_state_get(dest_id); + if (CONCAT31(extraout_var,kVar1) != 1) { + assert_err("ke_state_get(dest_id) == ME_BUSY","module",699); + } + if (me_env.requester_id != 0xff) { + ke_msg_send_basic(0x1414,me_env.requester_id,dest_id); + } + ke_state_set(dest_id,0); + return 0; +} + + + +int mm_set_idle_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + + kVar1 = ke_state_get(dest_id); + if (CONCAT31(extraout_var,kVar1) != 1) { + assert_err("ke_state_get(dest_id) == ME_BUSY","module",0x252); + } + if (me_env.requester_id != 0xff) { + ke_msg_send_basic(0x1412,me_env.requester_id,dest_id); + } + ke_state_set(dest_id,0); + return 0; +} + + + +int me_config_req_handler + (ke_msg_id_t msgid,me_config_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t uVar1; + undefined *puVar2; + undefined3 extraout_var; + + puVar2 = (undefined *)ke_msg_alloc(0x31,0,5,1); + me_env.ht_supported = (_Bool)param->ht_supp; + memcpy(&me_env.ht_cap,param,0x20); + ke_msg_send_basic(0x1401,src_id,dest_id); + if (me_env.ht_supported == false) { + me_env._302_2_ = 0; + } + else { + uVar1 = phy_get_nss(); + me_env._302_2_ = + CONCAT11((char)(me_env.ht_cap.ht_capa_info >> 1), + (char)(CONCAT31(extraout_var,uVar1) + 1 >> 1)) & 0x1ff; + } + me_env.tx_lft = param->tx_lft; + me_env.ps_on = (_Bool)param->ps_on; + if (me_env.ps_on != false) { + me_env.requester_id = 0xff; + *puVar2 = 2; + ke_msg_send(puVar2); + ke_state_set(5,1); + } + return 0; +} + + + +int me_set_ps_disable_req_handler + (ke_msg_id_t msgid,me_set_ps_disable_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + char *pcVar2; + + if (me_env.ps_on != false) { + kVar1 = ke_state_get(5); + if (CONCAT31(extraout_var,kVar1) == 1) { + return 2; + } + if (me_env.ps_disable_vifs == 0) { + if (param->ps_disable != false) goto LAB_23061504; + } + else { + if (param->ps_disable == false) { +LAB_23061504: + pcVar2 = (char *)ke_msg_alloc(0x31,0,dest_id,1); + if (param->ps_disable == false) { + me_env.ps_disable_vifs = ~(1 << ((uint)param->vif_idx & 0x1f)) & me_env.ps_disable_vifs; + } + else { + me_env.ps_disable_vifs = 1 << ((uint)param->vif_idx & 0x1f) | me_env.ps_disable_vifs; + } + me_env.requester_id = src_id; + *pcVar2 = (me_env.ps_disable_vifs == 0) << 1; + ke_msg_send(); + ke_state_set(dest_id,1); + return 0; + } + me_env.ps_disable_vifs = 1 << ((uint)param->vif_idx & 0x1f) | me_env.ps_disable_vifs; + } + } + ke_msg_send_basic(0x1414,src_id,dest_id); + return 0; +} + + + +int me_set_active_req_handler + (ke_msg_id_t msgid,me_set_active_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + void *pvVar2; + + kVar1 = ke_state_get(5); + if (CONCAT31(extraout_var,kVar1) == 1) { + return 2; + } + if (me_env.active_vifs == 0) { + if (param->active != false) goto LAB_2306159e; + } + else { + if (param->active == false) { +LAB_2306159e: + pvVar2 = ke_msg_alloc(0x22,0,dest_id,1); + if (param->active == false) { + me_env.active_vifs = ~(1 << ((uint)param->vif_idx & 0x1f)) & me_env.active_vifs; + } + else { + me_env.active_vifs = 1 << ((uint)param->vif_idx & 0x1f) | me_env.active_vifs; + } + me_env.requester_id = src_id; + *(bool *)pvVar2 = me_env.active_vifs == 0; + ke_msg_send(); + ke_state_set(dest_id,1); + return 0; + } + me_env.active_vifs = 1 << ((uint)param->vif_idx & 0x1f) | me_env.active_vifs; + } + ke_msg_send_basic(0x1412,src_id,dest_id); + return 0; +} + + + +// WARNING: Could not reconcile some variable overlaps + +int me_sta_add_req_handler + (ke_msg_id_t msgid,me_sta_add_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + byte bVar1; + byte bVar2; + _Bool _Var3; + byte *sta_idx; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined *puVar4; + undefined3 extraout_var_01; + uint uVar5; + uint uVar6; + uint uVar7; + int iVar8; + uint8_t uStack81; + uint8_t hw_sta_idx; + uint32_t uStack80; + mm_sta_add_req sta_add_req; + + sta_idx = (byte *)ke_msg_alloc(0x1408,src_id,dest_id,3); + bVar1 = rxu_cntrl_get_pm(); + sta_add_req.mac_addr.array[1]._1_1_ = param->vif_idx; + uVar7 = (uint)sta_add_req.mac_addr.array[1]._1_1_; + if ((param->flags & 2) == 0) { + sta_add_req.mac_addr.array[1]._0_1_ = '\0'; + sta_add_req.paid_gid._0_2_ = 0; + } + else { + uVar5 = (uint)(param->ht_cap).a_mpdu_param; + sta_add_req.mac_addr.array[1]._0_1_ = '\x01'; + uVar6 = (int)uVar5 >> 2 & 7; + if (2 < uVar6) { + sta_add_req.mac_addr.array[1]._0_1_ = (uint8_t)(1 << (uVar6 - 3 & 0x1f)); + } + sta_add_req.paid_gid._0_2_ = (short)(1 << (uVar5 & 3) + 0xd) - 1; + } + sta_add_req.ampdu_size_max_vht = 0; + memcpy((void *)((int)&sta_add_req.paid_gid + 2),param,6); + sta_add_req.mac_addr.array[2]._1_1_ = param->rssi; + sta_add_req._16_4_ = param->tsflo; + sta_add_req.tsflo = param->tsfhi; + uStack80 = 0; + sta_add_req.tsfhi._0_1_ = param->data_rate; + bVar2 = mm_sta_add((mm_sta_add_req *)&stack0xffffffb0,sta_idx,&uStack81); + sta_idx[1] = bVar2; + if (CONCAT31(extraout_var_00,bVar2) != 0) goto LAB_23061802; + uVar5 = (uint)*sta_idx; + memcpy(&sta_info_tab[uVar5].info,¶m->rate_set,0xd); + if ((param->flags & 1) == 0) { +LAB_23061706: + iVar8 = 0; + } + else { + uVar6 = sta_info_tab[uVar5].info.capa_flags; + sta_info_tab[uVar5].info.capa_flags = uVar6 | 1; + if (((param->flags & 2) == 0) || (me_env.ht_supported == false)) goto LAB_23061706; + sta_info_tab[uVar5].info.capa_flags = uVar6 | 3; + memcpy(&sta_info_tab[uVar5].info.ht_cap,¶m->ht_cap,0x20); + _Var3 = me_set_sta_ht_vht_param(sta_info_tab + uVar5,&vif_info_tab[uVar7].bss_info); + iVar8 = CONCAT31(extraout_var_01,_Var3); + } + sta_info_tab[uVar5].info.uapsd_queues = param->uapsd_queues; + sta_info_tab[uVar5].info.max_sp_len = param->max_sp_len; + sta_info_tab[uVar5].aid = param->aid; + me_init_rate(sta_info_tab + uVar5); + if (((param->flags & 0x10) != 0) && (bVar2 = param->opmode, -1 < (char)bVar2)) { + me_sta_bw_nss_max_upd(sta_info_tab[uVar5].staid,bVar2 & 3,bVar2 >> 4); + } + if (iVar8 != 0) { + me_sta_bw_nss_max_upd(sta_info_tab[uVar5].staid,-1,'\0'); + } + sta_info_tab[uVar5].pol_tbl.upd_field = sta_info_tab[uVar5].pol_tbl.upd_field | 0x10; + sta_info_tab[uVar5].ctrl_port_state = ((vif_info_tab[uVar7].flags & 1) == 0) + '\x01'; + sta_info_tab[uVar5].ctrl_port_ethertype = + *(ushort *)(vif_info_tab[uVar7].u + 0x2f0) >> 8 | + *(ushort *)(vif_info_tab[uVar7].u + 0x2f0) << 8; + sta_idx[2] = bVar1; + if (CONCAT31(extraout_var,bVar1) != 0) { + sta_info_tab[uVar5].ps_state = bVar1; + if (vif_info_tab[uVar7].u[0x2ee] == 0) { + uVar5 = (uint)vif_info_tab[uVar7].index + 10 & 0xff; + puVar4 = (undefined *)ke_msg_alloc(0x49,0xd,0,2); + sta_info_tab[uVar5].ps_state = '\x01'; + *puVar4 = (char)uVar5; + puVar4[1] = 1; + ke_msg_send(); + } + vif_info_tab[uVar7].u[0x2ee] = vif_info_tab[uVar7].u[0x2ee] + 1; + } +LAB_23061802: + ke_msg_send(sta_idx); + return 0; +} + + + +_Bool me_set_sta_ht_vht_param(sta_info_tag *sta,mac_bss_info *bss) + +{ + ushort uVar1; + uint uVar2; + uint uVar3; + uint8_t uVar4; + uint uVar5; + + uVar1 = (sta->info).ht_cap.ht_capa_info; + uVar3 = (uint)(uVar1 >> 1) & 1; + uVar2 = (int)(uint)uVar1 >> 8 & 3; + if ((uint)me_env.phy_bw_max < uVar3) { + uVar3 = (uint)me_env.phy_bw_max; + } + (sta->info).phy_bw_max = (uint8_t)uVar3; + uVar5 = (uint)bss->phy_bw; + if (bss->phy_bw == 4) { + uVar5 = 2; + } + uVar4 = (uint8_t)uVar5; + if (uVar3 < uVar5) { + uVar4 = (uint8_t)uVar3; + } + (sta->info).bw_cur = uVar4; + uVar4 = me_env.stbc_nss; + if (uVar2 < me_env.stbc_nss) { + uVar4 = (uint8_t)uVar2; + } + (sta->info).stbc_nss = uVar4; + return (_Bool)(((uint)uVar1 & 0xc) != 0xc); +} + + + +uint8_t me_11n_nss_max(uint8_t *mcs_set) + +{ + uint8_t uVar1; + + if (mcs_set[3] == '\0') { + uVar1 = '\x02'; + if ((mcs_set[2] == '\0') && (uVar1 = mcs_set[1], uVar1 != '\0')) { + uVar1 = '\x01'; + } + } + else { + uVar1 = '\x03'; + } + return uVar1; +} + + + +uint8_t me_legacy_ridx_min(uint16_t rate_map) + +{ + undefined2 in_register_0000202a; + uint uVar1; + + uVar1 = 0; + do { + if ((CONCAT22(in_register_0000202a,rate_map) >> (uVar1 & 0x1f) & 1U) != 0) { + return (uint8_t)uVar1; + } + uVar1 = uVar1 + 1; + } while (uVar1 != 0xc); + return '\f'; +} + + + +uint8_t me_legacy_ridx_max(uint16_t rate_map) + +{ + undefined2 in_register_0000202a; + char cVar1; + uint uVar2; + + if (CONCAT22(in_register_0000202a,rate_map) == 0) { + return '\f'; + } + uVar2 = 0xb; + do { + cVar1 = '\v' - (char)uVar2; + if ((CONCAT22(in_register_0000202a,rate_map) >> (uVar2 & 0x1f) & 1U) != 0) goto LAB_23061928; + uVar2 = uVar2 - 1; + } while (uVar2 != 0xffffffff); + cVar1 = '\f'; +LAB_23061928: + return '\v' - cVar1; +} + + + +uint8_t me_rate_translate(uint8_t rate) + +{ + uint8_t uVar1; + byte bVar2; + byte bVar3; + + bVar3 = rate & 0x7f; + if (bVar3 == 0x16) { + uVar1 = '\x03'; + } + else { + if (bVar3 < 0x17) { + if (bVar3 == 0xb) { + return '\x02'; + } + if (bVar3 < 0xc) { + if (bVar3 == 2) { + return '\0'; + } + bVar2 = 4; + uVar1 = '\x01'; + } + else { + if (bVar3 == 0xc) { + return '\x04'; + } + bVar2 = 0x12; + uVar1 = '\x05'; + } + } + else { + if (bVar3 == 0x30) { + return '\b'; + } + if (bVar3 < 0x31) { + if (bVar3 == 0x18) { + return '\x06'; + } + bVar2 = 0x24; + uVar1 = '\a'; + } + else { + if (bVar3 == 0x60) { + return '\n'; + } + if (bVar3 == 0x6c) { + return '\v'; + } + bVar2 = 0x48; + uVar1 = '\t'; + } + } + if (bVar3 != bVar2) { + return -1; + } + } + return uVar1; +} + + + +void me_get_basic_rates(mac_rateset *rateset,mac_rateset *basic_ratest) + +{ + byte bVar1; + int iVar2; + + basic_ratest->length = '\0'; + iVar2 = 0; + while (iVar2 < (int)(uint)rateset->length) { + if ((char)rateset->array[iVar2] < '\0') { + bVar1 = basic_ratest->length; + basic_ratest->array[bVar1] = rateset->array[iVar2]; + basic_ratest->length = bVar1 + 1; + } + iVar2 = iVar2 + 1; + } + return; +} + + + +uint16_t me_legacy_rate_bitfield_build(mac_rateset *rateset,_Bool basic_only) + +{ + uint uVar1; + int iVar2; + byte bVar3; + undefined3 extraout_var; + undefined3 in_register_0000202d; + + uVar1 = 0; + iVar2 = 0; + while (iVar2 < (int)(uint)rateset->length) { + if ((CONCAT31(in_register_0000202d,basic_only) == 0) || ((char)rateset->array[iVar2] < '\0')) { + bVar3 = me_rate_translate(rateset->array[iVar2]); + if (CONCAT31(extraout_var,bVar3) < 0xc) { + uVar1 = uVar1 | 1 << ((uint)bVar3 & 0x1f) & 0xffffU; + } + else { + assert_warn("bit_pos < MAC_RATESET_LEN","module",0x1c6); + } + } + iVar2 = iVar2 + 1; + } + return (uint16_t)uVar1; +} + + + +uint16_t me_build_capability(uint8_t vif_idx) + +{ + ushort uVar1; + undefined3 in_register_00002029; + int iVar2; + ushort uVar3; + + iVar2 = CONCAT31(in_register_00002029,vif_idx); + uVar3 = 0x11; + if (((vif_info_tab[iVar2].type != '\0') && (uVar3 = 1, vif_info_tab[iVar2].type == '\x02')) && + ((*(uint *)&vif_info_tab[iVar2].bss_info.is_supplicant_enabled & 0x12a00) != 0)) { + uVar3 = 0x11; + } + uVar1 = uVar3 | 0x520; + if ((vif_info_tab[iVar2].bss_info.chan)->band != '\x01') { + uVar1 = uVar3 | 0x420; + } + return (uint16_t)uVar1; +} + + + +void me_init_bcmc_rate(sta_info_tag *sta_entry) + +{ + byte bVar1; + byte rate; + uint8_t basic_rate_idx; + int iVar2; + + if ((sta_entry->info).rate_set.length == '\0') { + assert_err("rates->length != 0","module",0x229); + } + iVar2 = 0; + rate = 0; + while (iVar2 < (int)(uint)(sta_entry->info).rate_set.length) { + bVar1 = (sta_entry->info).rate_set.array[iVar2]; + if (rate < (bVar1 & 0x7f)) { + rate = bVar1 & 0x7f; + } + iVar2 = iVar2 + 1; + } + basic_rate_idx = me_rate_translate(rate); + rc_init_bcmc_rate(sta_entry,basic_rate_idx); + (sta_entry->pol_tbl).upd_field = '\0'; + return; +} + + + +void me_tx_cfm_singleton(txdesc *txdesc) + +{ + u8_l sta_idx; + uint uVar1; + uint uVar2; + + uVar1 = ((txdesc->lmac).hw_desc)->cfm_ptr->status; + uVar2 = uVar1 & 0x10000; + uVar1 = uVar1 >> 8 & 0xff; + if (uVar2 == 0) { + sta_idx = (txdesc->host).staid; + } + else { + rf_dump_status(); + sta_idx = (txdesc->host).staid; + } + rc_update_counters(sta_idx,uVar1 + 1,uVar1 + (uVar2 != 0),false,false); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void me_check_rc(u8_l sta_idx,_Bool *tx_ampdu) + +{ + ushort uVar1; + ushort uVar2; + ushort rate_config; + ushort rate_config_00; + uint16_t uVar3; + bool bVar4; + rc_sta_stats *rc_ss; + uint uVar5; + _Bool _Var6; + u8_l uVar7; + u8_l uVar8; + undefined3 in_register_00002029; + uint uVar9; + undefined3 extraout_var; + uint uVar10; + uint32_t uVar11; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + uint32_t uVar12; + uint8_t uVar13; + byte bVar14; + uint32_t *puVar15; + uint uVar16; + int iVar17; + uint uVar18; + uint uVar19; + + uVar9 = CONCAT31(in_register_00002029,sta_idx); + if (9 < uVar9) { + return; + } + rc_ss = sta_info_tab[uVar9].pol_tbl.sta_stats; + if (rc_ss == (rc_sta_stats *)0x0) { + assert_err("rc_ss != NULL","module",0x826); + } + iVar17 = 0; + if ((int)((100000 - _DAT_44b00120) + rc_ss->last_rc_time) < 0) { + _Var6 = rc_update_stats(rc_ss,false); + iVar17 = CONCAT31(extraout_var,_Var6); + rc_ss->trial_status = '\0'; + rc_ss->sw_retry_step = '\0'; + rc_ss->info = rc_ss->info & 0xef; + rc_ss->last_rc_time = _DAT_44b00120; + } + if (rc_ss->trial_status == '\x01') { + if ((rc_ss->info & 0x40) == 0) { + bVar14 = rc_ss->format_mod; + uVar1 = rc_ss->retry[0].idx; + uVar16 = (uint)uVar1; + if (bVar14 < 2) { + if ((ushort)(rc_ss->rate_stats[uVar16].probability + 0xe667) < 0xd99b) { + uVar13 = '\n'; + } + else { + uVar13 = '\x05'; + } + } + else { + uVar13 = ((char)*(undefined2 *)((int)&rc_ss->avg_ampdu_len + 2) + '\b') * '\x02'; + } + rc_ss->sample_wait = uVar13; + next = next * 0x41c64e6d + 0x3039; + uVar5 = (next >> 0x10) % (uint)rc_ss->no_samples; + if (uVar5 != uVar16) { + uVar2 = rc_ss->retry[1].idx; + if (((uVar5 != (uint)uVar2) && (uVar19 = (uint)rc_ss->retry[2].idx, uVar5 != uVar19)) && + (puVar15 = &rc_ss->last_rc_time + uVar5 * 3, *(ushort *)(puVar15 + 2) < 0xf334)) { + rate_config = *(ushort *)((int)puVar15 + 10); + uVar10 = rc_get_duration((uint)rate_config); + rate_config_00 = rc_ss->rate_stats[uVar16].rate_config; + if (bVar14 < 2) { + uVar16 = rc_get_duration((uint)rate_config_00); + if (uVar16 < uVar10) { + uVar11 = 0; + bVar4 = 0x13 < *(byte *)(puVar15 + 3); + } + else { + uVar11 = 0; + bVar4 = true; + } + } + else { + uVar18 = 0x20; + uVar16 = rc_get_duration((uint)rc_ss->rate_stats[(uint)uVar2].rate_config); + if (*(char *)((int)puVar15 + 0xd) == '\0') { + uVar18 = (uint)*(ushort *)((int)&rc_ss->avg_ampdu_len + 2); + } + if (uVar16 <= uVar10) { + uVar7 = rc_get_nss(rate_config_00); + uVar8 = rc_get_nss(rate_config); + if ((CONCAT31(extraout_var_00,uVar7) - 1U < CONCAT31(extraout_var_01,uVar8)) || + (uVar16 = rc_get_duration((uint)rc_ss->rate_stats[uVar19].rate_config), + uVar16 <= uVar10)) { + if (uVar18 <= *(byte *)(puVar15 + 3)) { + bVar14 = rc_ss->sample_slow + 1; + rc_ss->sample_slow = bVar14; + if (bVar14 < 3) goto LAB_23063714; + if (0xf < bVar14) { + rc_ss->sample_slow = '\x0f'; + } + } + goto LAB_230636ee; + } + } +LAB_23063714: + uVar11 = rc_calc_tp(rc_ss,(u8_l)uVar5); + bVar4 = true; + if ((*(byte *)((int)puVar15 + 0xe) & 0xf) < 10) { + bVar4 = uVar18 <= *(byte *)(puVar15 + 3); + } + } + uVar12 = rc_ss->retry[1].tp; + (rc_ss->max_tp_2_trial).idx = uVar2; + (rc_ss->max_tp_2_trial).tp = uVar12; + if (bVar4) { + uVar12 = rc_ss->retry[0].tp; + rc_ss->info = rc_ss->info & 0xfd; + rc_ss->retry[1].tp = uVar12; + rc_ss->retry[1].idx = uVar1; + rc_ss->retry[0].tp = uVar11; + rc_ss->retry[0].idx = (uint16_t)uVar5; + } + else { + rc_ss->info = rc_ss->info | 2; + rc_ss->retry[1].tp = uVar11; + rc_ss->retry[1].idx = (uint16_t)uVar5; + } + rc_ss->trial_status = '\x02'; + goto LAB_23063654; + } + } + } +LAB_230636ee: + rc_ss->trial_status = '\0'; + } + else { + if (rc_ss->trial_status == '\x03') { + if ((rc_ss->info & 2) == 0) { + rc_ss->retry[0].idx = rc_ss->retry[1].idx; + rc_ss->retry[0].tp = rc_ss->retry[1].tp; + } + uVar3 = (rc_ss->max_tp_2_trial).idx; + rc_ss->trial_status = '\0'; + rc_ss->retry[1].idx = uVar3; + uVar11 = (rc_ss->max_tp_2_trial).tp; + (rc_ss->max_tp_2_trial).tp = 0; + rc_ss->retry[1].tp = uVar11; + (rc_ss->max_tp_2_trial).idx = 0xff; + goto LAB_23063654; + } + } + if (iVar17 == 0) { + return; + } +LAB_23063654: + sta_info_tab[uVar9].pol_tbl.upd_field = sta_info_tab[uVar9].pol_tbl.upd_field | 1; + return; +} + + +/* +Unable to decompile 'me_update_buffer_control' +Cause: Exception while decompiling 23061b7a: Decompiler process died + +*/ + + +void me_init_rate(sta_info_tag *sta_entry) + +{ + rc_init(sta_entry); + me_update_buffer_control(sta_entry); + return; +} + + + +void me_bw_check(int param_1,int param_2) + +{ + short sVar1; + short sVar2; + byte bVar3; + + sVar2 = **(short **)(param_2 + 0x4c); + bVar3 = 0; + if ((param_1 != 0) && (bVar3 = me_env.phy_bw_max, me_env.phy_bw_max != '\0')) { + bVar3 = *(byte *)(param_1 + 3) & 3; + if ((*(byte *)(param_1 + 3) & 3) != 0) { + sVar1 = 10; + if (bVar3 != 1) { + sVar1 = -10; + } + sVar2 = sVar2 + sVar1; + bVar3 = 1; + } + } + *(byte *)(param_2 + 0x82) = bVar3; + *(byte *)(param_2 + 0x83) = bVar3; + *(short *)(param_2 + 0x50) = sVar2; + *(undefined2 *)(param_2 + 0x52) = 0; + return; +} + + + +void me_beacon_check(uint8_t vif_idx,uint16_t length,uint32_t bcn_addr) + +{ + byte bVar1; + uint8_t uVar2; + uint8_t uVar3; + undefined3 in_register_00002029; + int iVar4; + int iVar5; + undefined4 uVar6; + uint8_t *puVar7; + undefined2 in_register_0000202e; + uint uVar8; + uint16_t uVar9; + scan_chan_tag *psVar10; + uint uVar11; + byte bVar12; + char cStack51; + int8_t iStack50; + uint8_t auStack49 [2]; + uint8_t csa_mode; + int8_t pwr; + uint8_t idx; + + iVar4 = CONCAT31(in_register_00002029,vif_idx); + psVar10 = vif_info_tab[iVar4].bss_info.chan; + vif_info_tab[iVar4].bss_info.prot_status = 0; + uVar8 = CONCAT22(in_register_0000202e,length) - 0x24; + bVar1 = vif_info_tab[iVar4].bss_info.phy_bw; + uVar2 = vif_info_tab[iVar4].bss_info.power_constraint; + bcn_addr = bcn_addr + 0x24; + uVar11 = uVar8 & 0xffff; + if ((psVar10->band == '\0') && (iVar5 = mac_ie_find(bcn_addr,uVar11,0x2a), iVar5 != 0)) { + bVar12 = *(byte *)(iVar5 + 2); + uVar9 = vif_info_tab[iVar4].bss_info.prot_status & 0xfff8; + if ((bVar12 & 1) != 0) { + uVar9 = uVar9 | 1; + } + vif_info_tab[iVar4].bss_info.prot_status = uVar9; + if ((bVar12 & 2) != 0) { + vif_info_tab[iVar4].bss_info.prot_status = vif_info_tab[iVar4].bss_info.prot_status | 2; + } + if ((bVar12 & 4) != 0) { + vif_info_tab[iVar4].bss_info.prot_status = vif_info_tab[iVar4].bss_info.prot_status | 4; + } + } + uVar6 = 0; + if (me_env.ht_supported != false) { + uVar6 = mac_ie_find(bcn_addr,uVar11,0x3d); + } + me_bw_check(uVar6,0,&vif_info_tab[iVar4].bss_info); + uVar11 = me_extract_csa(bcn_addr,uVar11,&cStack51,iVar4 * 0x5d8 + 0x4201c2c0); + if ((uVar11 & 0xff) != 0) { + bVar12 = (byte)(uVar11 & 0xff); + if (vif_info_tab[iVar4].type == '\0') { + if ((vif_info_tab[iVar4].u[0x1d] == 0) && (cStack51 == '\x01')) { + mm_send_csa_traffic_ind(vif_info_tab[iVar4].index,false); + } + vif_info_tab[iVar4].u[0x1d] = bVar12; + } + else { + if (vif_info_tab[iVar4].type == '\x02') { + vif_info_tab[iVar4].u[0x2eb] = bVar12; + } + } + } + me_extract_power_constraint + (bcn_addr,(uint16_t)(uVar8 * 0x10000 >> 0x10),&vif_info_tab[iVar4].bss_info); + uVar3 = vif_info_tab[iVar4].bss_info.power_constraint; + if (uVar3 != uVar2) { + iStack50 = (vif_info_tab[iVar4].bss_info.chan)->tx_power - uVar3; + tpc_update_vif_tx_power(vif_info_tab + iVar4,&iStack50,auStack49); + } + if (bVar1 < vif_info_tab[iVar4].bss_info.phy_bw) { + puVar7 = (uint8_t *)ke_msg_alloc(0x3b,0,5,0xc); + if (vif_info_tab[iVar4].chan_ctxt == (chan_ctxt_tag *)0x0) { + assert_err("vif->chan_ctxt != NULL","module",0x39); + } + *puVar7 = (vif_info_tab[iVar4].chan_ctxt)->idx; + puVar7[1] = (vif_info_tab[iVar4].bss_info.chan)->band; + puVar7[2] = vif_info_tab[iVar4].bss_info.phy_bw; + *(u16_l *)(puVar7 + 4) = (vif_info_tab[iVar4].bss_info.chan)->freq; + *(uint16_t *)(puVar7 + 6) = vif_info_tab[iVar4].bss_info.center_freq1; + *(uint16_t *)(puVar7 + 8) = vif_info_tab[iVar4].bss_info.center_freq2; + puVar7[10] = ((vif_info_tab[iVar4].chan_ctxt)->channel).tx_power; + ke_msg_send(puVar7); + } + return; +} + + + +void me_sta_bw_nss_max_upd(uint8_t sta_idx,uint8_t bw,uint8_t nss) + +{ + byte bVar1; + byte bVar2; + u8_l sta_idx_00; + uint8_t uVar3; + uint8_t uVar4; + u8_l nss_max; + undefined3 in_register_00002029; + int iVar5; + undefined3 extraout_var; + undefined3 extraout_var_00; + u8_l bw_max; + undefined3 in_register_0000202d; + uint uVar6; + undefined3 in_register_00002031; + uint uVar7; + + iVar5 = CONCAT31(in_register_00002029,sta_idx); + bVar1 = sta_info_tab[iVar5].inst_nbr; + if (me_env.ht_supported == false) { + assert_err("me_env.ht_supported","module",0x429); + } + uVar3 = me_11n_nss_max(sta_info_tab[iVar5].info.ht_cap.mcs_rate); + uVar4 = me_11n_nss_max(me_env.ht_cap.mcs_rate); + uVar7 = CONCAT31(extraout_var_00,uVar4); + if (CONCAT31(extraout_var,uVar3) < CONCAT31(extraout_var_00,uVar4)) { + uVar7 = CONCAT31(extraout_var,uVar3); + } + nss_max = (u8_l)uVar7; + if (CONCAT31(in_register_00002031,nss) < uVar7) { + nss_max = nss; + } + bVar2 = sta_info_tab[iVar5].info.phy_bw_max; + uVar7 = (uint)bVar2; + if (bVar2 == 4) { + uVar7 = 3; + } + uVar6 = (uint)vif_info_tab[bVar1].bss_info.bw; + if (CONCAT31(in_register_0000202d,bw) < uVar6) { + uVar6 = CONCAT31(in_register_0000202d,bw); + } + bw_max = (u8_l)uVar6; + if (uVar7 < uVar6) { + bw_max = (u8_l)uVar7; + } + sta_idx_00 = sta_info_tab[iVar5].staid; + sta_info_tab[iVar5].info.bw_cur = bw_max; + rc_update_bw_nss_max(sta_idx_00,bw_max,nss_max); + sta_info_tab[iVar5].pol_tbl.upd_field = sta_info_tab[iVar5].pol_tbl.upd_field | 8; + return; +} + + + +// WARNING: Could not reconcile some variable overlaps + +uint8_t me_add_chan_ctx(uint8_t *p_chan_idx,scan_chan_tag *p_chan,uint32_t center_freq1, + uint32_t center_freq2,uint8_t ch_width) + +{ + uint8_t uVar1; + u8_l uStack28; + uint8_t uStack27; + u16_l uStack26; + mm_chan_ctxt_add_req req; + + uStack28 = p_chan->band; + req._0_2_ = (uint16_t)center_freq1; + uStack26 = p_chan->freq; + req.prim20_freq = (uint16_t)center_freq2; + req.center1_freq._0_1_ = p_chan->tx_power; + uStack27 = ch_width; + uVar1 = chan_ctxt_add((mm_chan_ctxt_add_req *)&uStack28,p_chan_idx); + return uVar1; +} + + + +u8_l rc_get_nss(uint16_t rate_config) + +{ + undefined2 in_register_0000202a; + + if ((CONCAT22(in_register_0000202a,rate_config) >> 0xb & 7U) - 2 < 2) { + return (u8_l)((byte)(CONCAT22(in_register_0000202a,rate_config) >> 3) & 3); + } + return '\0'; +} + + + +u8_l rc_get_mcs_index(uint16_t rate_config) + +{ + undefined2 in_register_0000202a; + byte bVar1; + uint uVar2; + + uVar2 = CONCAT22(in_register_0000202a,rate_config) >> 0xb & 7; + if (uVar2 < 2) { + bVar1 = (byte)rate_config & 0x7f; + } + else { + bVar1 = 0; + if (uVar2 < 4) { + bVar1 = (byte)rate_config & 7; + } + } + return (u8_l)bVar1; +} + + + +uint16_t rc_set_previous_mcs_index(rc_sta_stats *rc_ss,uint16_t rate_config) + +{ + uint uVar1; + u8_l uVar2; + undefined3 extraout_var; + undefined2 in_register_0000202e; + + uVar2 = rc_get_mcs_index(rate_config); + _uVar2 = CONCAT31(extraout_var,uVar2); + uVar1 = CONCAT22(in_register_0000202e,rate_config) >> 0xb & 7; + if (uVar1 < 2) { + if (rc_ss->r_idx_min < _uVar2) { + rate_config = rate_config & 0xff80 | (short)_uVar2 - 1U; + } + } + else { + if ((uVar1 < 4) && (_uVar2 != 0)) { + rate_config = rate_config & 0xfff8 | (short)_uVar2 - 1U; + if (rc_ss->short_gi != '\0') { + rate_config = rate_config | 0x200; + } + } + } + return rate_config; +} + + + +uint16_t rc_set_next_mcs_index(rc_sta_stats *rc_ss,uint16_t rate_config) + +{ + u8_l uVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined2 in_register_0000202e; + uint uVar2; + + uVar1 = rc_get_mcs_index(rate_config); + _uVar1 = CONCAT31(extraout_var,uVar1); + uVar2 = CONCAT22(in_register_0000202e,rate_config) >> 0xb & 7; + if (uVar2 < 2) { + if ((_uVar1 < rc_ss->r_idx_max) && ((rc_ss->rate_map_l >> (_uVar1 + 1 & 0x1f) & 1) != 0)) { + rate_config = rate_config & 0xff80 | (ushort)(_uVar1 + 1); + } + } + else { + if ((uVar2 < 4) && (_uVar1 < rc_ss->mcs_max)) { + uVar1 = rc_get_nss(rate_config); + if ((*(byte *)((int)&rc_ss->rate_map + CONCAT31(extraout_var_00,uVar1)) >> (_uVar1 + 1 & 0x1f) + & 1) != 0) { + rate_config = rate_config & 0xfff8 | (ushort)(_uVar1 + 1); + if (rc_ss->short_gi != '\0') { + rate_config = rate_config | 0x200; + } + } + } + } + return rate_config; +} + + + +_Bool is_cck_group(uint16_t rate_config) + +{ + u8_l uVar1; + undefined3 extraout_var; + + if ((rate_config & 0x3000) == 0) { + uVar1 = rc_get_mcs_index(rate_config); + return (_Bool)(CONCAT31(extraout_var,uVar1) < 4); + } + return false; +} + + + +void rc_update_retry_chain(rc_sta_stats *rc_ss,uint32_t *cur_tp) + +{ + ushort uVar1; + ushort uVar2; + int iVar3; + uint uVar4; + _Bool _Var5; + ushort uVar6; + undefined3 extraout_var; + undefined3 extraout_var_00; + ushort *puVar7; + int iVar8; + uint32_t uVar9; + uint uVar10; + uint uVar11; + uint uVar12; + uint uVar13; + + uVar6 = rc_ss->no_samples; + uVar13 = (uint)uVar6; + if (((rc_ss->info & 4) == 0) && (cur_tp[uVar13 - 1] < *cur_tp)) { + rc_ss->retry[0].idx = 0; + rc_ss->retry[0].tp = 0; + uVar4 = 1; + } + else { + rc_ss->retry[0].idx = uVar6 - 1; + uVar4 = 2; + rc_ss->retry[0].tp = cur_tp[uVar13 - 1]; + } + uVar1 = rc_ss->retry[0].idx; + _Var5 = is_cck_group(*(uint16_t *)((int)(&rc_ss->last_rc_time + (uint)uVar1 * 3) + 10)); + if (CONCAT31(extraout_var,_Var5) == 0) { + uVar12 = 0; + while ((int)uVar12 < (int)(uVar13 - 1)) { + _Var5 = is_cck_group(*(uint16_t *)((int)(&rc_ss->last_rc_time + uVar12 * 3) + 10)); + if (CONCAT31(extraout_var_00,_Var5) != 0) { + *(undefined *)((int)(&rc_ss->last_rc_time + uVar12 * 3) + 0xf) = 0; + } + uVar12 = uVar12 + 1 & 0xffff; + } + *(undefined *)((int)(&rc_ss->last_rc_time + (uint)uVar1 * 3) + 0xf) = 1; + } + uVar9 = rc_ss->retry[0].tp; + rc_ss->retry[1].idx = uVar1; + rc_ss->retry[1].tp = uVar9; + iVar3 = uVar13 - uVar4; + do { + iVar8 = iVar3; + uVar12 = uVar4; + uVar4 = uVar12 + 1 & 0xffff; + if (uVar13 <= uVar12) goto LAB_2306228c; + iVar3 = iVar8 + -1; + } while (rc_ss->rate_stats[iVar8].rate_allowed == false); + rc_ss->retry[1].idx = uVar6 - (short)uVar12; + rc_ss->retry[1].tp = cur_tp[iVar8]; +LAB_2306228c: + uVar12 = (uint)rc_ss->retry[1].idx; + uVar4 = uVar13 - uVar4; + do { + uVar10 = uVar4; + uVar11 = uVar12; + if (uVar13 <= (uVar13 - uVar10 & 0xffff)) break; + uVar4 = uVar10 - 1; + uVar11 = uVar10; + } while (rc_ss->rate_stats[uVar10].rate_allowed == false); + uVar13 = cur_tp[uVar11]; + puVar7 = &rc_ss->rate_stats[0].probability; + uVar6 = rc_ss->rate_stats[uVar11].probability; + uVar4 = 0; + do { + if (uVar12 <= (uVar4 & 0xffff)) { + rc_ss->retry[2].idx = (uint16_t)uVar11; + uVar9 = cur_tp[uVar11]; + rc_ss->retry[3].idx = 0; + rc_ss->retry[2].tp = uVar9; + rc_ss->retry[3].tp = *cur_tp; + return; + } + if ((*(char *)((int)puVar7 + 7) != '\0') && ((uVar4 & 0xffff) != (uint)uVar1)) { + uVar2 = *puVar7; + if (uVar2 < 0xf333) { + if (uVar6 <= uVar2) { + uVar9 = cur_tp[uVar4]; + goto LAB_23062370; + } + } + else { + uVar9 = cur_tp[uVar4]; + if (uVar13 <= uVar9) { +LAB_23062370: + uVar13 = uVar9; + uVar11 = uVar4; + uVar6 = uVar2; + } + } + } + uVar4 = uVar4 + 1; + puVar7 = puVar7 + 6; + } while( true ); +} + + + +uint16_t rc_get_lowest_rate_config(rc_sta_stats *rc_ss) + +{ + byte bVar1; + uint16_t uVar2; + + bVar1 = rc_ss->format_mod; + if (bVar1 < 2) { + uVar2 = (uint16_t)rc_ss->r_idx_min; + if (rc_ss->r_idx_min == 0) { + return 0x400; + } + } + else { + if (3 < bVar1) { + return 0; + } + if (rc_ss->r_idx_min == '\0') { + return 0x400; + } + uVar2 = (ushort)bVar1 << 0xb; + } + return uVar2; +} + + + +// WARNING: Variable defined which should be unmapped: rc_ss_tmp + +void rc_sort_samples_tp(rc_sta_stats *rc_ss,uint32_t *cur_tp) + +{ + ushort uVar1; + uint32_t *puVar2; + ushort uVar3; + uint32_t uVar4; + ushort uVar5; + rc_rate_stats *__src; + ushort uVar6; + rc_rate_stats *__src_00; + undefined auStack44 [4]; + rc_rate_stats rc_ss_tmp; + + uVar5 = rc_ss->no_samples; + uVar1 = uVar5 - 1; + while (uVar6 = uVar1, uVar5 != 0) { + puVar2 = cur_tp + 1; + uVar5 = 0; + uVar3 = 1; + __src = rc_ss->rate_stats + 1; + while (uVar1 = uVar5, uVar3 < uVar6) { + __src_00 = __src + 1; + if (puVar2[1] < *puVar2) { + memmove(auStack44,__src,0xc); + memmove(__src,__src_00,0xc); + memmove(__src_00,auStack44,0xc); + uVar4 = puVar2[1]; + puVar2[1] = *puVar2; + *puVar2 = uVar4; + uVar5 = uVar3; + } + uVar3 = uVar3 + 1; + puVar2 = puVar2 + 1; + __src = __src_00; + } + } + return; +} + + + +uint16_t rc_get_initial_rate_config(rc_sta_stats *rc_ss) + +{ + byte bVar1; + byte bVar2; + ushort uVar3; + int iVar4; + ushort uVar5; + + bVar1 = rc_ss->format_mod; + if (bVar1 < 2) { + uVar3 = (ushort)rc_ss->r_idx_max; + uVar5 = (ushort)bVar1 << 0xb | (ushort)rc_ss->p_type << 10; + } + else { + if (3 < bVar1) { + return 0; + } + bVar2 = rc_ss->no_ss; + iVar4 = __clzsi2((uint)*(byte *)((int)&rc_ss->rate_map + (uint)bVar2)); + uVar5 = (ushort)rc_ss->short_gi << 9 | (ushort)bVar1 << 0xb | (ushort)rc_ss->bw_max << 7 | + (ushort)bVar2 << 3; + uVar3 = 0x1fU - (short)iVar4 & 0xff; + } + return (uint16_t)(uVar5 | uVar3); +} + + + +void rc_calc_prob_ewma(rc_rate_stats *rc_rs) + +{ + ushort uVar1; + uint uVar2; + uint uVar3; + + uVar1 = rc_rs->attempts; + if (uVar1 != 0) { + rc_rs->sample_skipped = '\0'; + uVar3 = (uint)rc_rs->success << 0x10; + uVar2 = uVar3 / uVar1; + if (rc_rs->old_prob_available == false) { + if (uVar3 < uVar1) { + rc_rs->probability = 0; + } + else { + rc_rs->probability = (short)uVar2 - 1; + } + } + else { + rc_rs->probability = (uint16_t)((uint)rc_rs->probability * 0x60 + uVar2 * 0x20 >> 7); + } + rc_rs->old_prob_available = true; + return; + } + if (rc_rs->sample_skipped != -1) { + rc_rs->sample_skipped = rc_rs->sample_skipped + '\x01'; + } + return; +} + + + +_Bool rc_check_valid_rate(rc_sta_stats *rc_ss,uint16_t rate_config) + +{ + u8_l uVar1; + byte bVar2; + undefined3 extraout_var; + undefined2 in_register_0000202e; + uint uVar3; + + uVar3 = CONCAT22(in_register_0000202e,rate_config) >> 0xb & 7; + if (uVar3 < 2) { + bVar2 = rc_get_mcs_index(rate_config); + uVar3 = (uint)rc_ss->rate_map_l; + } + else { + if (3 < uVar3) { + return true; + } + uVar1 = rc_get_nss(rate_config); + bVar2 = rc_get_mcs_index(rate_config); + uVar3 = (uint)*(byte *)((int)&rc_ss->rate_map + CONCAT31(extraout_var,uVar1)); + } + return (_Bool)((byte)(uVar3 >> ((uint)bVar2 & 0x1f)) & 1); +} + + + +uint16_t rc_new_random_rate(rc_sta_stats *rc_ss) + +{ + byte bVar1; + byte bVar2; + uint uVar3; + int iVar4; + uint16_t uVar5; + uint uVar6; + ushort uVar7; + uint uVar8; + + bVar1 = rc_ss->bw_max; + uVar8 = 0; + next = next * 0x41c64e6d + 0x3039; + bVar2 = rc_ss->format_mod; + uVar6 = next >> 0x10; + uVar5 = (uint16_t)(((uint)bVar2 << 0x1b) >> 0x10); + if (bVar1 != 0) { + uVar8 = (uint)bVar1 - 1 & 0xff; + } + uVar7 = (ushort)(next >> 0x10); + if (bVar2 < 2) { + uVar8 = (int)(uVar6 & 0x7f) % (((uint)rc_ss->r_idx_max - (uint)rc_ss->r_idx_min) + 1) + + (uint)rc_ss->r_idx_min; + uVar6 = uVar8 & 0xff; + if ((rc_ss->rate_map_l >> (uVar8 & 0x1f) & 1) == 0) { + uVar6 = (uint)rc_ss->r_idx_max; + } + uVar5 = uVar5 | (ushort)uVar6; + if (uVar6 == 0) { + uVar5 = uVar5 | 0x400; + } + else { + if ((uVar6 - 1 & 0xff) < 3) { + uVar5 = uVar5 | uVar7 & 0x400 | (ushort)rc_ss->p_type << 10; + } + } + } + else { + if (bVar2 < 4) { + bVar2 = rc_ss->r_idx_min; + if ((bVar2 < 4) && ((int)(uVar6 << 0x14) < 0)) { + uVar8 = (int)(uVar6 & 0x7f) % (((uint)rc_ss->r_idx_max - (uint)bVar2) + 1) + (uint)bVar2; + uVar6 = uVar8 & 0xff; + if ((rc_ss->rate_map_l >> (uVar8 & 0x1f) & 1) == 0) { + uVar6 = (uint)rc_ss->r_idx_max; + } + uVar5 = 0x400; + if (uVar6 != 0) { + uVar5 = (ushort)rc_ss->p_type << 10 | uVar7 & 0x400 | (ushort)uVar6; + } + } + else { + uVar7 = (ushort)rc_ss->mcs_max; + iVar4 = (int)((int)uVar6 >> 3 & 3U) % ((uint)rc_ss->no_ss + 1); + uVar3 = (int)(uVar6 & 7) % ((uint)rc_ss->mcs_max + 1); + if ((*(byte *)((int)&rc_ss->rate_map + iVar4) >> (uVar3 & 0x1f) & 1) != 0) { + uVar7 = (ushort)uVar3 & 0xff; + } + uVar5 = uVar5 | (ushort)((int)((int)uVar6 >> 9 & 1U) % ((uint)rc_ss->short_gi + 1) << 9) | + (ushort)(iVar4 << 3) | + ((short)((int)((int)uVar6 >> 7 & 3U) % (((uint)bVar1 - uVar8) + 1)) + (short)uVar8) + * 0x80 | uVar7; + } + } + } + return uVar5; +} + + + +void rc_update_counters(u8_l sta_idx,u32_l attempts,u32_l failures,_Bool tx_ampdu, + _Bool retry_required) + +{ + short sVar1; + rc_sta_stats *prVar2; + undefined3 in_register_00002029; + uint uVar3; + uint8_t uVar4; + uint32_t *puVar5; + ushort *puVar6; + + uVar3 = CONCAT31(in_register_00002029,sta_idx); + if (9 < uVar3) { + return; + } + if (sta_info_tab[uVar3].inst_nbr != -1) { + prVar2 = sta_info_tab[uVar3].pol_tbl.sta_stats; + if (prVar2 == (rc_sta_stats *)0x0) { + assert_err("rc_ss != NULL","module",0x7ce); + } + puVar6 = &prVar2->retry[0].idx; + prVar2->ampdu_packets = prVar2->ampdu_packets + 1; + prVar2->ampdu_len = prVar2->ampdu_len + 1; + do { + if (attempts == 0) break; + puVar5 = &prVar2->last_rc_time + (uint)*puVar6 * 3; + if (failures < 4) { + *(short *)(puVar5 + 1) = *(short *)(puVar5 + 1) + (short)attempts; + sVar1 = (short)failures; + failures = 0; + *(short *)((int)puVar5 + 6) = ((short)attempts - sVar1) + *(short *)((int)puVar5 + 6); + attempts = 0; + } + else { + *(short *)(puVar5 + 1) = *(short *)(puVar5 + 1) + 4; + attempts = attempts - 4; + failures = failures - 4; + } + if (*(ushort *)(puVar5 + 1) < *(ushort *)((int)puVar5 + 6)) { + assert_err("rc_rs->attempts >= rc_rs->success","module",0x7fa); + } + puVar6 = puVar6 + 4; + } while (puVar6 != &(prVar2->max_tp_2_trial).idx); + if (prVar2->trial_status == '\0') { + if (prVar2->sample_wait != '\0') { + prVar2->sample_wait = prVar2->sample_wait + -1; + return; + } + uVar4 = '\x01'; + } + else { + if (prVar2->trial_status != '\x02') { + return; + } + if ((sta_info_tab[uVar3].pol_tbl.upd_field & 1) != 0) { + return; + } + uVar4 = '\x03'; + } + prVar2->trial_status = uVar4; + } + return; +} + + + +uint32_t rc_get_duration(uint param_1) + +{ + u8_l uVar1; + undefined3 extraout_var; + uint32_t uVar2; + undefined3 extraout_var_00; + uint uVar3; + + uVar1 = rc_get_mcs_index((uint16_t)param_1); + _uVar1 = CONCAT31(extraout_var,uVar1); + uVar3 = (int)param_1 >> 0xb & 7; + if (uVar3 < 2) { + if (_uVar1 < 4) { + uVar2 = rc_duration_cck[(int)param_1 >> 10 & 1U | _uVar1 << 1]; + } + else { + uVar2 = rc_duration_non_ht[_uVar1 - 4]; + } + } + else { + uVar2 = 0; + if (uVar3 < 4) { + uVar1 = rc_get_nss((uint16_t)param_1); + uVar2 = rc_duration_ht_ampdu[_uVar1 << 3 | param_1 >> 9 & 1 | param_1 >> 6 & 6] / + (CONCAT31(extraout_var_00,uVar1) + 1U); + } + } + return uVar2; +} + + + +void rc_update_bw_nss_max(u8_l sta_idx,u8_l bw_max,u8_l nss_max) + +{ + ushort uVar1; + rc_sta_stats *rc_ss; + uint16_t uVar2; + undefined3 in_register_00002029; + int iVar3; + undefined2 extraout_var; + undefined3 in_register_0000202d; + undefined3 in_register_00002031; + uint32_t *puVar4; + uint uVar5; + ushort *puVar6; + uint16_t *puVar7; + uint uVar8; + uint32_t local_48; + uint32_t cur_tp [10]; + + iVar3 = CONCAT31(in_register_00002029,sta_idx); + rc_ss = sta_info_tab[iVar3].pol_tbl.sta_stats; + if (rc_ss == (rc_sta_stats *)0x0) { + assert_err("rc_ss != NULL","module",0x969); + } + if (((uint)rc_ss->bw_max != CONCAT31(in_register_0000202d,bw_max)) || + ((uint)rc_ss->no_ss != CONCAT31(in_register_00002031,nss_max))) { + rc_ss->bw_max = bw_max; + if (3 < CONCAT31(in_register_0000202d,bw_max)) { + assert_err("rc_ss->bw_max <= BW_160MHZ","module",0x96f); + } + rc_ss->no_ss = nss_max; + if (7 < CONCAT31(in_register_00002031,nss_max)) { + assert_err("rc_ss->no_ss < 8","module",0x971); + } + if (rc_ss->fixed_rate_cfg == 0xffff) { + uVar2 = rc_get_lowest_rate_config(rc_ss); + rc_ss->rate_stats[0].rate_config = uVar2; + uVar2 = rc_get_initial_rate_config(rc_ss); + rc_ss->rate_stats[(uint)rc_ss->no_samples - 1].rate_config = uVar2; + uVar5 = 1; +LAB_23062974: + uVar1 = rc_ss->no_samples; + if ((int)uVar5 < (int)((uint)uVar1 - 1)) { + do { + uVar2 = rc_new_random_rate(rc_ss); + uVar8 = 0; + puVar6 = &rc_ss->rate_stats[0].rate_config; + while( true ) { + if (rc_ss->no_samples <= uVar8) { + rc_ss->rate_stats[uVar5].rate_config = uVar2; + uVar5 = uVar5 + 1 & 0xffff; + goto LAB_23062974; + } + if ((uint)*puVar6 == CONCAT22(extraout_var,uVar2)) break; + uVar8 = uVar8 + 1; + puVar6 = puVar6 + 6; + } + } while( true ); + } + puVar7 = &rc_ss->rate_stats[0].probability; + uVar5 = 0; + puVar4 = &local_48; + while ((uint)uVar1 != uVar5) { + *(undefined *)(puVar7 + 3) = 0; + *(undefined *)((int)puVar7 + 7) = 1; + *puVar7 = 0; + *(undefined *)((int)puVar7 + 5) = 0; + *puVar4 = 0; + uVar5 = uVar5 + 1 & 0xffff; + puVar7 = puVar7 + 6; + puVar4 = puVar4 + 1; + } + rc_sort_samples_tp(rc_ss,&local_48); + rc_update_retry_chain(rc_ss,&local_48); + sta_info_tab[iVar3].pol_tbl.upd_field = sta_info_tab[iVar3].pol_tbl.upd_field | 1; + } + } + return; +} + + + +void rc_init_bcmc_rate(sta_info_tag *sta_entry,u8_l basic_rate_idx) + +{ + undefined3 in_register_0000202d; + txl_buffer_control *ptVar1; + uint uVar2; + + ptVar1 = (sta_entry->pol_tbl).buf_ctrl; + uVar2 = 0; + if (CONCAT31(in_register_0000202d,basic_rate_idx) < 4) { + uVar2 = SEXT24((short)((sta_entry->pol_tbl).ppdu_tx_cfg & 0x400)); + } + uVar2 = CONCAT31(in_register_0000202d,basic_rate_idx) | uVar2 | 0x20000000; + *(uint *)(ptVar1->field_0 + 0x14) = uVar2; + *(uint *)(ptVar1->field_0 + 0x18) = uVar2; + *(uint *)(ptVar1->field_0 + 0x1c) = uVar2; + *(uint *)(ptVar1->field_0 + 0x20) = uVar2; + return; +} + + + +_Bool rc_check_fixed_rate_config(rc_sta_stats *rc_ss,uint16_t fixed_rate_config) + +{ + u8_l uVar1; + _Bool _Var2; + undefined3 extraout_var; + undefined2 in_register_0000202e; + uint uVar3; + uint uVar4; + + uVar4 = (uint)rc_ss->format_mod; + uVar3 = ((uint)fixed_rate_config & 0x3800) >> 0xb; + if (uVar4 < uVar3) { + return false; + } + if (rc_ss->format_mod == 4) { + if (uVar3 != uVar4) { + return false; + } +LAB_23062a66: + if ((fixed_rate_config & 0x3000) == 0) { +LAB_23062abe: + if (((CONCAT22(in_register_0000202e,fixed_rate_config) >> 10 & 1U) == 0) && + (rc_ss->p_type == '\x01')) { + return false; + } + goto LAB_23062a98; + } + } + else { + if (1 < (uVar4 - 2 & 0xff)) goto LAB_23062a66; + if ((fixed_rate_config & 0x3000) == 0) { + if (3 < rc_ss->r_idx_min) { + return false; + } + goto LAB_23062abe; + } + } + if (((((fixed_rate_config & 0x200) != 0) && (rc_ss->short_gi == '\0')) || + ((uint)rc_ss->bw_max < (CONCAT22(in_register_0000202e,fixed_rate_config) >> 7 & 3U))) || + (uVar1 = rc_get_nss(fixed_rate_config), (uint)rc_ss->no_ss < CONCAT31(extraout_var,uVar1))) { + return false; + } +LAB_23062a98: + _Var2 = rc_check_valid_rate(rc_ss,fixed_rate_config); + return _Var2; +} + + + +u32_l rc_calc_tp(rc_sta_stats *rc_ss,u8_l sample_idx) + +{ + ushort uVar1; + ushort rate_config; + uint uVar2; + _Bool _Var3; + undefined3 extraout_var; + int iVar4; + u32_l uVar5; + undefined3 in_register_0000202d; + + uVar1 = *(ushort *)(&rc_ss->last_rc_time + CONCAT31(in_register_0000202d,sample_idx) * 3 + 2); + if (uVar1 < 0x1999) { + uVar5 = 0; + } + else { + rate_config = *(ushort *) + ((int)(&rc_ss->last_rc_time + CONCAT31(in_register_0000202d,sample_idx) * 3) + 10 + ); + uVar2 = 0; + _Var3 = is_cck_group(rate_config); + if (CONCAT31(extraout_var,_Var3) == 0) { + uVar2 = 0x35390 / (uint)*(ushort *)((int)&rc_ss->avg_ampdu_len + 2); + } + iVar4 = rc_get_duration((uint)rate_config); + uVar5 = (((uint)uVar1 * 1000) / (iVar4 + uVar2)) * 1000000 >> 0x10; + } + return uVar5; +} + + + +_Bool rc_update_stats(rc_sta_stats *rc_ss,_Bool init) + +{ + byte bVar1; + ushort rate_config; + _Bool _Var2; + uint16_t rate_config_00; + u32_l uVar3; + undefined2 extraout_var_03; + undefined3 extraout_var; + undefined2 extraout_var_04; + undefined3 extraout_var_00; + undefined2 extraout_var_05; + undefined3 extraout_var_01; + undefined2 extraout_var_06; + undefined3 extraout_var_02; + uint uVar4; + undefined3 in_register_0000202d; + rc_rate_stats *prVar5; + uint32_t *cur_tp_00; + uint32_t *puVar6; + uint uVar7; + ushort rate_config_01; + uint16_t uVar8; + uint8_t *puVar9; + uint16_t *puVar10; + uint16_t *puVar11; + uint uVar12; + char cVar13; + uint16_t uStack148; + ushort uStack146; + uint16_t new_rate_cfg_array [6]; + step old_retry [4]; + uint32_t cur_tp [10]; + + memcpy(new_rate_cfg_array + 4,rc_ss->retry,0x20); + if (rc_ss->ampdu_packets != 0) { + rate_config = rc_ss->ampdu_len; + *(undefined4 *)&rc_ss->ampdu_len = 0; + rc_ss->avg_ampdu_len = + ((int)((uint)rate_config << 0x10) / (int)(uint)rc_ss->ampdu_packets) * 0x20 + + rc_ss->avg_ampdu_len * 0x60 >> 7; + } + rate_config = rc_ss->no_samples; + cur_tp_00 = (uint32_t *)&old_retry[3].idx; + rc_ss->sample_slow = '\0'; + puVar9 = &rc_ss->rate_stats[0].n_retry; + uVar7 = 0; + puVar6 = cur_tp_00; + while ((uint)rate_config != uVar7) { + *puVar6 = 0; + *puVar9 = '\0'; + puVar9[1] = '\x01'; + uVar7 = uVar7 + 1 & 0xffff; + puVar6 = puVar6 + 1; + puVar9 = puVar9 + 0xc; + } + rate_config_00 = rc_ss->fixed_rate_cfg; + uVar12 = 0; + if (rate_config_00 == 0xffff) { + while (uVar12 < rc_ss->no_samples) { + rc_calc_prob_ewma(rc_ss->rate_stats + uVar12); + uVar3 = rc_calc_tp(rc_ss,(u8_l)uVar12); + *(u32_l *)(&old_retry[3].idx + uVar12 * 2) = uVar3; + uVar12 = uVar12 + 1 & 0xffff; + } + rc_sort_samples_tp(rc_ss,cur_tp_00); + rc_update_retry_chain(rc_ss,cur_tp_00); + if (CONCAT31(in_register_0000202d,init) == 0) { + rate_config = rc_ss->no_samples; + if (9 < rate_config) { + cVar13 = '\0'; + rate_config = rc_ss->rate_stats[rc_ss->retry[0].idx].rate_config; + uVar7 = (uint)rate_config; + rate_config_01 = rc_ss->rate_stats[rc_ss->retry[1].idx].rate_config; + memset(&uStack148,-1,0xc); + do { + switch(cVar13) { + case '\x01': + if ((((int)uVar7 >> 0xb & 6U) != 0) && (rc_ss->short_gi == '\x01')) { + if ((rate_config & 0x200) == 0) { + uStack146 = rate_config | 0x200; + } + else { + uStack146 = rate_config & 0xfdff; + } + } + break; + case '\x02': + rate_config_00 = rc_set_next_mcs_index(rc_ss,rate_config); + if ((uVar7 != CONCAT22(extraout_var_03,rate_config_00)) && + (_Var2 = rc_check_valid_rate(rc_ss,rate_config_00), CONCAT31(extraout_var,_Var2) != 0 + )) { + new_rate_cfg_array[0] = rate_config_00; + } + break; + case '\x03': + rate_config_00 = rc_set_previous_mcs_index(rc_ss,rate_config); + if ((uVar7 != CONCAT22(extraout_var_04,rate_config_00)) && + (_Var2 = rc_check_valid_rate(rc_ss,rate_config_00), + CONCAT31(extraout_var_00,_Var2) != 0)) { + new_rate_cfg_array[1] = rate_config_00; + } + break; + case '\x04': + rate_config_00 = rc_set_next_mcs_index(rc_ss,rate_config_01); + if (((uint)rate_config_01 != CONCAT22(extraout_var_05,rate_config_00)) && + (_Var2 = rc_check_valid_rate(rc_ss,rate_config_00), + CONCAT31(extraout_var_01,_Var2) != 0)) { + new_rate_cfg_array[2] = rate_config_00; + } + break; + case '\x05': + rate_config_00 = rc_set_previous_mcs_index(rc_ss,rate_config_01); + if (((uint)rate_config_01 != CONCAT22(extraout_var_06,rate_config_00)) && + (_Var2 = rc_check_valid_rate(rc_ss,rate_config_00), + CONCAT31(extraout_var_02,_Var2) != 0)) { + new_rate_cfg_array[3] = rate_config_00; + } + break; + default: + uStack148 = rc_new_random_rate(rc_ss); + } + cVar13 = cVar13 + '\x01'; + } while (cVar13 != '\x06'); + rate_config = rc_ss->no_samples; + uVar12 = 1; + uVar7 = 0; + while (uVar12 < rate_config) { + puVar6 = &rc_ss->last_rc_time + uVar12 * 3; + if ((((*(short *)(puVar6 + 2) < 0) && (*(byte *)(puVar6 + 3) < 0xb)) || + ((uint)rc_ss->retry[0].idx == uVar12)) || + ((((uint)rc_ss->retry[1].idx == uVar12 || ((uint)rc_ss->retry[2].idx == uVar12)) || + (5 < uVar7)))) { + uVar12 = uVar12 + 1 & 0xffff; + } + else { + rate_config_00 = (&uStack148)[uVar7]; + if (rate_config_00 != 0xffff) { + uVar4 = 0; + puVar11 = &rc_ss->rate_stats[0].rate_config; + while (uVar4 < rate_config) { + if (*puVar11 == rate_config_00) goto LAB_23062e56; + uVar4 = uVar4 + 1; + puVar11 = puVar11 + 6; + } + *(uint16_t *)((int)puVar6 + 10) = rate_config_00; + *(undefined2 *)(puVar6 + 2) = 0; + *(undefined *)((int)puVar6 + 0xd) = 0; + uVar12 = uVar12 + 1 & 0xffff; + } +LAB_23062e56: + uVar7 = uVar7 + 1; + } + *(undefined2 *)(puVar6 + 1) = 0; + *(undefined2 *)((int)puVar6 + 6) = 0; + } + *(undefined4 *)rc_ss->rate_stats = 0; + goto LAB_23062d1c; + } + prVar5 = rc_ss->rate_stats; + rate_config_01 = 0; + while (rate_config != rate_config_01) { + rate_config_01 = rate_config_01 + 1; + prVar5->attempts = 0; + prVar5->success = 0; + prVar5 = prVar5 + 1; + } + } + } + else { + bVar1 = rc_ss->info; + uVar12 = 0; + if ((bVar1 & 0x20) != 0) { + while (uVar8 = (uint16_t)uVar12, uVar12 < uVar7) { + if (rc_ss->rate_stats[uVar12].rate_config == rate_config_00) goto LAB_23062eb0; + uVar12 = uVar12 + 1 & 0xff; + } + if (uVar7 == uVar12) { + uVar12 = uVar12 - 1 & 0xff; + uVar8 = (uint16_t)uVar12; + *(uint16_t *)((int)(&rc_ss->last_rc_time + uVar12 * 3) + 10) = rate_config_00; + *(undefined2 *)(&rc_ss->last_rc_time + uVar12 * 3 + 2) = 0; + } +LAB_23062eb0: + rc_ss->retry[0].idx = uVar8; + rc_ss->retry[1].idx = uVar8; + rc_ss->retry[2].idx = uVar8; + rc_ss->retry[0].tp = 0; + rc_ss->retry[1].tp = 0; + rc_ss->retry[2].tp = 0; + prVar5 = rc_ss->rate_stats; + uVar12 = 0; + while (uVar7 != uVar12) { + prVar5->attempts = 0; + prVar5->success = 0; + uVar12 = uVar12 + 1 & 0xffff; + prVar5 = prVar5 + 1; + } + rc_ss->info = bVar1 & 0x9f | 0x40; + init = true; + goto LAB_23062d1c; + } + uVar7 = (uint)*(byte *)&rc_ss->retry[0].idx; + rc_calc_prob_ewma(rc_ss->rate_stats + uVar7); + *(undefined2 *)(&rc_ss->last_rc_time + uVar7 * 3 + 1) = 0; + *(undefined2 *)((int)(&rc_ss->last_rc_time + uVar7 * 3) + 6) = 0; + *(undefined4 *)rc_ss->rate_stats = 0; + } + init = false; +LAB_23062d1c: + puVar10 = &rc_ss->retry[0].idx; + puVar11 = new_rate_cfg_array; + do { + if (puVar11[6] != *puVar10) { + return true; + } + puVar10 = puVar10 + 4; + puVar11 = puVar11 + 4; + } while (puVar10 != &(rc_ss->max_tp_2_trial).idx); + return init; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rc_init(sta_info_tag *sta_entry) + +{ + byte bVar1; + ushort uVar2; + uint uVar3; + step *psVar4; + uint8_t uVar5; + uint8_t uVar6; + _Bool _Var7; + byte bVar8; + uint16_t rate_map; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + undefined3 extraout_var_03; + undefined3 extraout_var_04; + undefined3 extraout_var_05; + undefined3 extraout_var_06; + undefined2 extraout_var_07; + int iVar9; + short sVar10; + uint *puVar11; + uint *puVar12; + uint uVar13; + ushort *puVar14; + uint uVar15; + uint uVar16; + rc_sta_stats *__s; + txl_buffer_control *ptVar17; + uint uVar18; + rc_sta_stats *rc_ss; + uint uVar19; + uint8_t *mcs_set; + ushort *puVar20; + + bVar8 = sta_entry->staid; + ptVar17 = (sta_entry->pol_tbl).buf_ctrl; + if (9 < bVar8) { + assert_err("sta_entry->staid < NX_REMOTE_STA_MAX","module",0x85f); + } + uVar16 = (uint)sta_entry->staid; + __s = sta_stats + uVar16; + (sta_entry->pol_tbl).sta_stats = __s; + uVar5 = phy_get_ntx(); + uVar18 = CONCAT31(extraout_var,uVar5) << 0xe; + memset(__s,0,200); + if (((sta_entry->info).capa_flags & 2) == 0) { + rate_map = me_legacy_rate_bitfield_build((mac_rateset *)&sta_entry->info,false); + sta_stats[uVar16].rate_map_l = rate_map; + uVar5 = me_legacy_ridx_min(rate_map); + sta_stats[uVar16].r_idx_min = uVar5; + if (0xb < CONCAT31(extraout_var_05,uVar5)) { + assert_err("rc_ss->r_idx_min < MAC_RATESET_LEN","module",0x8f4); + } + uVar5 = me_legacy_ridx_max(sta_stats[uVar16].rate_map_l); + sta_stats[uVar16].r_idx_max = uVar5; + if (0xb < CONCAT31(extraout_var_06,uVar5)) { + assert_err("rc_ss->r_idx_max < MAC_RATESET_LEN","module",0x8f6); + } + sta_stats[uVar16].mcs_max = -1; + uVar5 = (sta_entry->info).bw_cur; + sta_stats[uVar16].bw_max = uVar5; + if (uVar5 != '\0') { + assert_err("rc_ss->bw_max == BW_20MHZ","module",0x8f9); + } + sta_stats[uVar16].p_type = (byte)((int)(uint)(sta_entry->pol_tbl).ppdu_tx_cfg >> 10) & 1; + } + else { + rate_map = me_legacy_rate_bitfield_build((mac_rateset *)&sta_entry->info,false); + mcs_set = (sta_entry->info).ht_cap.mcs_rate; + sta_stats[uVar16].format_mod = '\x02'; + sta_stats[uVar16].rate_map_l = rate_map; + uVar5 = me_11n_nss_max(mcs_set); + uVar6 = me_11n_nss_max(me_env.ht_cap.mcs_rate); + uVar19 = CONCAT31(extraout_var_00,uVar5); + if (CONCAT31(extraout_var_01,uVar6) < CONCAT31(extraout_var_00,uVar5)) { + uVar19 = CONCAT31(extraout_var_01,uVar6); + } + sta_stats[uVar16].no_ss = (uint8_t)uVar19; + if (3 < uVar19) { + assert_err("rc_ss->no_ss <= 3","module",0x8a6); + } + memcpy(&sta_stats[uVar16].rate_map,mcs_set,4); + rate_map = sta_stats[uVar16].rate_map_l; + *(undefined *)&sta_stats[uVar16].rate_map = 0xff; + sta_stats[uVar16].mcs_max = '\a'; + uVar5 = me_legacy_ridx_min(rate_map); + sta_stats[uVar16].r_idx_min = uVar5; + if (0xc < CONCAT31(extraout_var_02,uVar5)) { + assert_err("(rc_ss->r_idx_min <= HW_RATE_54MBPS) || (rc_ss->r_idx_min == MAC_RATESET_LEN)", + "module",0x8b8); + } + uVar5 = me_legacy_ridx_max(sta_stats[uVar16].rate_map_l); + sta_stats[uVar16].r_idx_max = uVar5; + if (0xc < CONCAT31(extraout_var_03,uVar5)) { + assert_err("(rc_ss->r_idx_max <= HW_RATE_54MBPS) || (rc_ss->r_idx_max == MAC_RATESET_LEN)", + "module",0x8be); + } + sta_stats[uVar16].p_type = (byte)((int)(uint)(sta_entry->pol_tbl).ppdu_tx_cfg >> 10) & 1; + _Var7 = phy_ldpc_tx_supported(); + uVar2 = (sta_entry->info).ht_cap.ht_capa_info; + if ((CONCAT31(extraout_var_04,_Var7) != 0) && ((uVar2 & 1) != 0)) { + uVar18 = uVar18 | 0x40; + } + if ((int)((uint)uVar2 << 0x14) < 0) { + sVar10 = 0x2000; + } + else { + sVar10 = 0x1000; + } + sta_stats[uVar16].max_amsdu_len = sVar10 - 0x101; + bVar1 = (sta_entry->info).bw_cur; + sta_stats[uVar16].bw_max = bVar1; + if (3 < bVar1) { + assert_err("rc_ss->bw_max <= BW_160MHZ","module",0x8d5); + } + uVar5 = (sta_entry->info).bw_cur; + if (uVar5 == '\0') { + if (((sta_entry->info).ht_cap.ht_capa_info & 0x20) != 0) { + uVar5 = '\x01'; + goto LAB_23063162; + } + } + else { + if ((uVar5 == '\x01') && (((sta_entry->info).ht_cap.ht_capa_info & 0x40) != 0)) { +LAB_23063162: + sta_stats[uVar16].short_gi = uVar5; + } + } + } + if (sta_stats[uVar16].format_mod < 2) { + uVar19 = (uint)sta_stats[uVar16].rate_map_l; + uVar15 = 1 - (uint)sta_stats[uVar16].p_type; + uVar13 = (((int)uVar19 >> 1 & 1U) + ((int)uVar19 >> 2 & 1U) << (uVar15 & 0x1f)) + (uVar19 & 1) + + (((int)uVar19 >> 3 & 1U) << (uVar15 & 0x1f)) & 0xffff; + uVar15 = 4; + do { + uVar3 = uVar15 & 0x1f; + uVar15 = uVar15 + 1; + uVar13 = uVar13 + ((int)uVar19 >> uVar3 & 1U) & 0xffff; + } while (uVar15 != 0xc); +LAB_2306327c: + if (10 < uVar13) { + sta_stats[uVar16].no_samples = 10; + goto LAB_23063290; + } + sta_stats[uVar16].no_samples = (uint16_t)uVar13; + if (uVar13 != 0) goto LAB_23063290; + } + else { + if (sta_stats[uVar16].format_mod < 4) { + uVar19 = (uint)*(byte *)&sta_stats[uVar16].rate_map; + iVar9 = 8; + uVar15 = 0; + do { + uVar13 = uVar19 & 1; + iVar9 = iVar9 + -1; + uVar19 = uVar19 >> 1; + uVar15 = uVar15 + (1 << ((uint)sta_stats[uVar16].short_gi & 0x1f)) * uVar13 & 0xffff; + } while (iVar9 != 0); + uVar13 = (uint)sta_stats[uVar16].rate_map_l; + uVar19 = 1 - (uint)sta_stats[uVar16].p_type; + uVar13 = uVar15 + (((int)uVar13 >> 1 & 1U) + ((int)uVar13 >> 2 & 1U) << (uVar19 & 0x1f)) + + (uVar13 & 1) + (((int)uVar13 >> 3 & 1U) << (uVar19 & 0x1f)) & 0xffff; + goto LAB_2306327c; + } + sta_stats[uVar16].no_samples = 0; + } + assert_err("rc_ss->no_samples >= 1","module",0x8ff); + if (10 < sta_stats[uVar16].no_samples) { + assert_err("rc_ss->no_samples <= RC_MAX_N_SAMPLE","module",0x900); + } +LAB_23063290: + rc_ss = sta_info_tab[sta_entry->staid].pol_tbl.sta_stats; + if (rc_ss == (rc_sta_stats *)0x0) { + assert_err("rc_ss != NULL","module",0x6e4); + } + uVar2 = rc_ss->no_samples; + puVar20 = &rc_ss->rate_stats[0].rate_config; + uVar19 = 0; + puVar14 = puVar20; + while (uVar19 != (uint)uVar2) { + *puVar14 = 0xffff; + uVar19 = uVar19 + 1 & 0xffff; + puVar14 = puVar14 + 6; + } + rate_map = rc_get_lowest_rate_config(rc_ss); + rc_ss->rate_stats[0].rate_config = rate_map; + rate_map = rc_get_initial_rate_config(rc_ss); + rc_ss->rate_stats[uVar19 - 1].rate_config = rate_map; + uVar19 = 1; +LAB_230632fa: + do { + uVar2 = rc_ss->no_samples; + if ((int)((uint)uVar2 - 1) <= (int)uVar19) { + rc_ss->retry[0].idx = (uint16_t)((uint)uVar2 - 1); + rc_ss->retry[2].idx = uVar2 - 3; + rc_ss->avg_ampdu_len = 0x10000; + rc_ss->retry[1].idx = uVar2 - 2; + rc_ss->fixed_rate_cfg = 0xffff; + rc_ss->retry[0].tp = 0; + rc_ss->retry[1].tp = 0; + rc_ss->retry[2].tp = 0; + rc_ss->retry[3].idx = 0; + rc_ss->retry[3].tp = 0; + rc_ss->info = '\0'; + rc_update_stats(rc_ss,true); + rc_ss->sample_wait = '\x05'; + puVar11 = (uint *)(ptVar17->field_0 + 0x14); + do { + psVar4 = __s->retry; + puVar12 = puVar11 + 1; + __s = (rc_sta_stats *)&__s->rate_stats[0].probability; + *puVar11 = (uint)sta_stats[uVar16].rate_stats[*(byte *)&psVar4->idx].rate_config | + 0x80000000; + puVar11 = puVar12; + } while (puVar12 != (uint *)(ptVar17->field_0 + 0x24)); + sta_stats[uVar16].last_rc_time = _DAT_44b00120; + *(undefined4 *)ptVar17->field_0 = 0xbadcab1e; + *(uint *)(ptVar17->field_0 + 0xc) = ((uint)bVar8 + 8 & 0xff) << 10; + *(undefined4 *)(ptVar17->field_0 + 0x10) = 0xffff0704; + *(uint *)(ptVar17->field_0 + 4) = uVar18; + bVar8 = phy_get_ntx(); + *(int *)(ptVar17->field_0 + 8) = (1 << ((uint)bVar8 + 1 & 0x1f)) + -1; + ((sta_entry->pol_tbl).buf_ctrl)->mac_control_info = 0x2200; + ((sta_entry->pol_tbl).buf_ctrl)->phy_control_info = sta_entry->paid_gid; + (sta_entry->pol_tbl).upd_field = (sta_entry->pol_tbl).upd_field | 0x11; + return; + } + rate_map = rc_new_random_rate(rc_ss); + uVar15 = 0; + puVar14 = puVar20; + while (uVar15 < rc_ss->no_samples) { + if ((uint)*puVar14 == CONCAT22(extraout_var_07,rate_map)) goto LAB_230632fa; + uVar15 = uVar15 + 1; + puVar14 = puVar14 + 6; + } + rc_ss->rate_stats[uVar19].rate_config = rate_map; + uVar19 = uVar19 + 1 & 0xffff; + } while( true ); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void rc_check(u8_l sta_idx,_Bool *tx_ampdu) + +{ + ushort uVar1; + ushort uVar2; + ushort rate_config; + ushort rate_config_00; + uint16_t uVar3; + bool bVar4; + rc_sta_stats *rc_ss; + uint uVar5; + _Bool _Var6; + u8_l uVar7; + u8_l uVar8; + undefined3 in_register_00002029; + uint uVar9; + undefined3 extraout_var; + uint uVar10; + uint32_t uVar11; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + uint32_t uVar12; + uint8_t uVar13; + byte bVar14; + uint32_t *puVar15; + uint uVar16; + int iVar17; + uint uVar18; + uint uVar19; + + uVar9 = CONCAT31(in_register_00002029,sta_idx); + if (9 < uVar9) { + return; + } + rc_ss = sta_info_tab[uVar9].pol_tbl.sta_stats; + if (rc_ss == (rc_sta_stats *)0x0) { + assert_err("rc_ss != NULL","module",0x826); + } + iVar17 = 0; + if ((int)((100000 - _DAT_44b00120) + rc_ss->last_rc_time) < 0) { + _Var6 = rc_update_stats(rc_ss,false); + iVar17 = CONCAT31(extraout_var,_Var6); + rc_ss->trial_status = '\0'; + rc_ss->sw_retry_step = '\0'; + rc_ss->info = rc_ss->info & 0xef; + rc_ss->last_rc_time = _DAT_44b00120; + } + if (rc_ss->trial_status == '\x01') { + if ((rc_ss->info & 0x40) == 0) { + bVar14 = rc_ss->format_mod; + uVar1 = rc_ss->retry[0].idx; + uVar16 = (uint)uVar1; + if (bVar14 < 2) { + if ((ushort)(rc_ss->rate_stats[uVar16].probability + 0xe667) < 0xd99b) { + uVar13 = '\n'; + } + else { + uVar13 = '\x05'; + } + } + else { + uVar13 = ((char)*(undefined2 *)((int)&rc_ss->avg_ampdu_len + 2) + '\b') * '\x02'; + } + rc_ss->sample_wait = uVar13; + next = next * 0x41c64e6d + 0x3039; + uVar5 = (next >> 0x10) % (uint)rc_ss->no_samples; + if (uVar5 != uVar16) { + uVar2 = rc_ss->retry[1].idx; + if (((uVar5 != (uint)uVar2) && (uVar19 = (uint)rc_ss->retry[2].idx, uVar5 != uVar19)) && + (puVar15 = &rc_ss->last_rc_time + uVar5 * 3, *(ushort *)(puVar15 + 2) < 0xf334)) { + rate_config = *(ushort *)((int)puVar15 + 10); + uVar10 = rc_get_duration((uint)rate_config); + rate_config_00 = rc_ss->rate_stats[uVar16].rate_config; + if (bVar14 < 2) { + uVar16 = rc_get_duration((uint)rate_config_00); + if (uVar16 < uVar10) { + uVar11 = 0; + bVar4 = 0x13 < *(byte *)(puVar15 + 3); + } + else { + uVar11 = 0; + bVar4 = true; + } + } + else { + uVar18 = 0x20; + uVar16 = rc_get_duration((uint)rc_ss->rate_stats[(uint)uVar2].rate_config); + if (*(char *)((int)puVar15 + 0xd) == '\0') { + uVar18 = (uint)*(ushort *)((int)&rc_ss->avg_ampdu_len + 2); + } + if (uVar16 <= uVar10) { + uVar7 = rc_get_nss(rate_config_00); + uVar8 = rc_get_nss(rate_config); + if ((CONCAT31(extraout_var_00,uVar7) - 1U < CONCAT31(extraout_var_01,uVar8)) || + (uVar16 = rc_get_duration((uint)rc_ss->rate_stats[uVar19].rate_config), + uVar16 <= uVar10)) { + if (uVar18 <= *(byte *)(puVar15 + 3)) { + bVar14 = rc_ss->sample_slow + 1; + rc_ss->sample_slow = bVar14; + if (bVar14 < 3) goto LAB_23063714; + if (0xf < bVar14) { + rc_ss->sample_slow = '\x0f'; + } + } + goto LAB_230636ee; + } + } +LAB_23063714: + uVar11 = rc_calc_tp(rc_ss,(u8_l)uVar5); + bVar4 = true; + if ((*(byte *)((int)puVar15 + 0xe) & 0xf) < 10) { + bVar4 = uVar18 <= *(byte *)(puVar15 + 3); + } + } + uVar12 = rc_ss->retry[1].tp; + (rc_ss->max_tp_2_trial).idx = uVar2; + (rc_ss->max_tp_2_trial).tp = uVar12; + if (bVar4) { + uVar12 = rc_ss->retry[0].tp; + rc_ss->info = rc_ss->info & 0xfd; + rc_ss->retry[1].tp = uVar12; + rc_ss->retry[1].idx = uVar1; + rc_ss->retry[0].tp = uVar11; + rc_ss->retry[0].idx = (uint16_t)uVar5; + } + else { + rc_ss->info = rc_ss->info | 2; + rc_ss->retry[1].tp = uVar11; + rc_ss->retry[1].idx = (uint16_t)uVar5; + } + rc_ss->trial_status = '\x02'; + goto LAB_23063654; + } + } + } +LAB_230636ee: + rc_ss->trial_status = '\0'; + } + else { + if (rc_ss->trial_status == '\x03') { + if ((rc_ss->info & 2) == 0) { + rc_ss->retry[0].idx = rc_ss->retry[1].idx; + rc_ss->retry[0].tp = rc_ss->retry[1].tp; + } + uVar3 = (rc_ss->max_tp_2_trial).idx; + rc_ss->trial_status = '\0'; + rc_ss->retry[1].idx = uVar3; + uVar11 = (rc_ss->max_tp_2_trial).tp; + (rc_ss->max_tp_2_trial).tp = 0; + rc_ss->retry[1].tp = uVar11; + (rc_ss->max_tp_2_trial).idx = 0xff; + goto LAB_23063654; + } + } + if (iVar17 == 0) { + return; + } +LAB_23063654: + sta_info_tab[uVar9].pol_tbl.upd_field = sta_info_tab[uVar9].pol_tbl.upd_field | 1; + return; +} + + + +void cfm_raw_send(void *env,uint32_t status) + +{ + printf("send complete, status is %08lX\r\n"); + return; +} + + + +int scanu_raw_send_req_handler + (ke_msg_id_t msgid,scanu_raw_send_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + size_t __n; + txl_frame_desc_tag *frame; + tx_hw_desc *ptVar1; + void *__src; + + printf("[FW] pkt address is %p, len is %lu\r\n",param->pkt,param->len); + scanu_raw_send_cfm('\0',src_id); + __src = param->pkt; + __n = param->len; + frame = txl_frame_get(0,0x100); + if (frame != (txl_frame_desc_tag *)0x0) { + memcpy((frame->txdesc).lmac.buffer + 1,__src,__n); + (frame->txdesc).host.staid = -1; + (frame->cfm).cfm_func = cfm_raw_send; + ptVar1 = (frame->txdesc).lmac.hw_desc; + (frame->txdesc).host.vif_idx = '\0'; + (frame->txdesc).umac.head_len = '\0'; + (frame->txdesc).umac.tail_len = '\0'; + *(txl_frame_desc_tag **)&(frame->cfm).env = frame; + (ptVar1->thd).field_5 = (ptVar1->thd).field_4 + (__n - 1); + (ptVar1->thd).frmlen = __n + 4; + txl_frame_push_force(frame,'\x03'); + } + return 0; +} + + + +int scanu_join_req_handler + (ke_msg_id_t msgid,scanu_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + vif_info_tab[param->vif_idx].bss_info.valid_flags = 0; + scanu_env._362_2_ = 1; + scanu_env.bssid.array._0_4_ = *(undefined4 *)(param->bssid).array; + scanu_env.bssid.array[2] = *(uint16_t *)((param->bssid).array + 4); + scanu_env.param = param; + scanu_env.src_id = src_id; + if (((param->bssid).array[0] & 1) != 0) { + assert_err("!MAC_ADDR_GROUP(¶m->bssid)","module",0xb6); + } + scanu_start(); + return 1; +} + + + +int scanu_start_req_handler + (ke_msg_id_t msgid,scanu_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined2 in_register_0000202a; + + scanu_env._362_2_ = 0; + scanu_env.bssid.array._0_4_ = *(undefined4 *)(param->bssid).array; + scanu_env.bssid.array[2] = *(uint16_t *)((param->bssid).array + 4); + scanu_env.param = param; + scanu_env.src_id = src_id; + scanu_start(CONCAT22(in_register_0000202a,msgid)); + return 1; +} + + + +int rxu_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + int iVar1; + + iVar1 = scanu_frame_handler(param); + return iVar1; +} + + + +int scan_done_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined2 in_register_0000202a; + + scanu_env.band = scanu_env.band + '\x01'; + scanu_scan_next(CONCAT22(in_register_0000202a,msgid)); + return 0; +} + + + +int scan_start_cfm_handler + (ke_msg_id_t msgid,scan_start_cfm *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + if (param->status != '\0') { + scanu_confirm(param->status); + return 0; + } + return 0; +} + + + +int me_set_ps_disable_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + undefined3 extraout_var_02; + + kVar1 = ke_state_get(6); + if (((CONCAT31(extraout_var,kVar1) != 4) && + (kVar1 = ke_state_get(6), CONCAT31(extraout_var_00,kVar1) != 0)) && + (kVar1 = ke_state_get(6), CONCAT31(extraout_var_01,kVar1) != 8)) { + assert_err( + "(ke_state_get(TASK_SM) == SM_BSS_PARAM_SETTING) || (ke_state_get(TASK_SM) == SM_IDLE) || (ke_state_get(TASK_SM) == SM_DISCONNECTING)" + ,"module",0x1db); + } + kVar1 = ke_state_get(6); + if (CONCAT31(extraout_var_02,kVar1) == 4) { + sm_send_next_bss_param(); + } + return 0; +} + + + +int mm_bss_param_setting_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + + kVar1 = ke_state_get(6); + if (CONCAT31(extraout_var,kVar1) != 4) { + assert_err("ke_state_get(TASK_SM) == SM_BSS_PARAM_SETTING","module",0x1fa); + } + sm_send_next_bss_param(); + return 0; +} + + + +int sm_rsp_timeout_ind_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + + kVar1 = ke_state_get(6); + if ((CONCAT31(extraout_var,kVar1) == 5) || + (kVar1 = ke_state_get(6), CONCAT31(extraout_var_00,kVar1) == 6)) { + sm_connect_ind(0xb); + } + return 0; +} + + + +int scanu_start_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + mac_addr_conflict67 *pmStack24; + mac_addr_conflict171 *bssid; + scan_chan_tag *chan; + + pmStack24 = (mac_addr_conflict67 *)0x0; + bssid = (mac_addr_conflict171 *)0x0; + kVar1 = ke_state_get(6); + if (CONCAT31(extraout_var,kVar1) != 1) { + assert_err("ke_state_get(TASK_SM) == SM_SCANNING","module",0x10a); + } + sm_get_bss_params(&pmStack24,(scan_chan_tag **)&bssid); + if ((pmStack24 == (mac_addr_conflict67 *)0x0) || ((scan_chan_tag *)bssid == (scan_chan_tag *)0x0)) + { + sm_connect_ind(0xc); + } + else { + sm_join_bss(pmStack24,(scan_chan_tag *)bssid,false); + } + return 0; +} + + + +int mm_connection_loss_ind_handler + (ke_msg_id_t msgid,mm_connection_loss_ind *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + int iVar1; + ke_state_t kVar2; + undefined3 extraout_var; + uint uVar3; + + uVar3 = (uint)param->inst_nbr; + kVar2 = ke_state_get(6); + iVar1 = 2; + if (CONCAT31(extraout_var,kVar2) == 0) { + iVar1 = 0; + if ((vif_info_tab[uVar3].type == '\0') && (vif_info_tab[uVar3].active != false)) { + ke_state_set(6,8); + sm_disconnect_process(vif_info_tab + uVar3,0x10); + } + } + return iVar1; +} + + + +int scanu_join_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + sm_connect_req *psVar1; + ke_state_t kVar2; + uint8_t uVar3; + undefined3 extraout_var; + undefined3 extraout_var_00; + void *pvVar4; + undefined uVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint8_t auStack33 [4]; + u8_l chan_idx; + + psVar1 = sm_env.connect_param; + kVar2 = ke_state_get(6); + if (CONCAT31(extraout_var,kVar2) != 2) { + assert_err("ke_state_get(TASK_SM) == SM_JOINING","module",0x134); + } + uVar8 = (uint)psVar1->vif_idx; + if ((int)vif_info_tab[uVar8].bss_info.valid_flags < 0) { + uVar3 = sm_add_chan_ctx(auStack33); + if (CONCAT31(extraout_var_00,uVar3) == 0) { + pvVar4 = ke_msg_alloc(10,0,6,0x20); + chan_ctxt_link(psVar1->vif_idx,auStack33[0]); + *(u8_l *)((int)pvVar4 + 0x11) = psVar1->vif_idx; + memcpy((void *)((int)pvVar4 + 10),&vif_info_tab[uVar8].bss_info.bssid,6); + *(undefined *)((int)pvVar4 + 0x12) = 0; + if ((vif_info_tab[uVar8].bss_info.valid_flags & 2) != 0) { + uVar6 = (uint)vif_info_tab[uVar8].bss_info.ht_cap.a_mpdu_param; + uVar5 = 1; + uVar7 = (int)uVar6 >> 2 & 7; + if (2 < uVar7) { + uVar5 = (undefined)(1 << (uVar7 - 3 & 0x1f)); + } + *(undefined *)((int)pvVar4 + 0x10) = uVar5; + *(short *)((int)pvVar4 + 8) = (short)(1 << (uVar6 & 3) + 0xd) + -1; + } + *(undefined4 *)((int)pvVar4 + 4) = 0; + ke_msg_send(pvVar4); + ke_state_set(6,3); + } + else { + sm_connect_ind(0xd); + } + vif_info_tab[uVar8].flags = psVar1->flags; + if ((psVar1->flags & 4) != 0) { + vif_info_tab[uVar8].bss_info.valid_flags = + vif_info_tab[uVar8].bss_info.valid_flags & 0xfffffff9; + } + } + else { + if (sm_env.join_passive == false) { + sm_connect_ind(0xe); + } + else { + sm_join_bss((mac_addr_conflict67 *)&vif_info_tab[uVar8].bss_info.bssid, + vif_info_tab[uVar8].bss_info.chan,true); + } + } + return 0; +} + + + +// WARNING: Variable defined which should be unmapped: chan + +int sm_connect_req_handler + (ke_msg_id_t msgid,sm_connect_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + int iVar1; + ke_state_t kVar2; + undefined3 extraout_var; + undefined *puVar3; + undefined3 extraout_var_00; + undefined uVar4; + uint uVar5; + mac_addr_conflict67 *pmStack40; + mac_addr_conflict171 *bssid; + scan_chan_tag *chan; + + pmStack40 = (mac_addr_conflict67 *)0x0; + bssid = (mac_addr_conflict171 *)0x0; + uVar5 = (uint)param->vif_idx; + kVar2 = ke_state_get(6); + if (CONCAT31(extraout_var,kVar2) == 8) { + return 2; + } + puVar3 = (undefined *)ke_msg_alloc(0x1801,src_id,dest_id,1); + kVar2 = ke_state_get(6); + if (CONCAT31(extraout_var_00,kVar2) == 0) { + if ((vif_info_tab[uVar5].type == '\0') && (vif_info_tab[uVar5].active == false)) { + if (param->auth_type != '\x02') { + if (vif_info_tab[uVar5].u[4] != 0xff) { + assert_err("vif->u.sta.ap_id == INVALID_STA_IDX","module",0x59); + } + if (vif_info_tab[uVar5].chan_ctxt != (chan_ctxt_tag *)0x0) { + assert_err("vif->chan_ctxt == NULL","module",0x5a); + } + } + } + else { + if (param->auth_type != '\x02') { + iVar1 = 0; + uVar4 = 9; + goto LAB_23063cee; + } + } + if (sm_env.connect_param != (sm_connect_req *)0x0) { + assert_err("NULL == sm_env.connect_param","module",0x5d); + } + sm_env.connect_param = param; + if (sm_env.connect_ind != (sm_connect_ind *)0x0) { + assert_err("NULL == sm_env.connect_ind","module",0x61); + } + sm_env.connect_ind = (sm_connect_ind *)ke_msg_alloc(0x1802,src_id,dest_id,0x354); + sm_env.exist_ssid_idx = -1; + sm_env.ft_over_ds = false; + printf("connecting using vif_idx %u\r\n",(uint)param->vif_idx); + if (param->auth_type == '\x02') { + sm_env.ft_over_ds = true; + memcpy(&sm_env.ft_old_bssid,&vif_info_tab[param->vif_idx].bssid,6); + ke_state_set(6,8); + sm_disconnect_process(vif_info_tab + param->vif_idx,0); + } + else { + if ((param->chan).freq == 0xffff) { + sm_get_bss_params(&pmStack40,(scan_chan_tag **)&bssid); + } + else { + pmStack40 = (mac_addr_conflict67 *)¶m->bssid; + bssid = (mac_addr_conflict171 *)¶m->chan; + } + if ((pmStack40 == (mac_addr_conflict67 *)0x0) || + ((scan_chan_tag *)bssid == (scan_chan_tag *)0x0)) { + sm_scan_bss(pmStack40,(scan_chan_tag *)bssid); + } + else { + sm_join_bss(pmStack40,(scan_chan_tag *)bssid,false); + } + } + iVar1 = 1; + uVar4 = 0; + } + else { + iVar1 = 0; + uVar4 = 8; + } +LAB_23063cee: + *puVar3 = uVar4; + ke_msg_send(puVar3); + return iVar1; +} + + + +int rxu_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + int iVar2; + ushort uVar3; + + uVar3 = param->framectrl & 0xfc; + if (uVar3 == 0xb0) { + kVar1 = ke_state_get(6); + if (CONCAT31(extraout_var,kVar1) == 5) { + sm_auth_handler(param); + } + } + else { + if ((uVar3 == 0x10) || (uVar3 == 0x30)) { + kVar1 = ke_state_get(6); + if (CONCAT31(extraout_var_00,kVar1) == 6) { + sm_assoc_rsp_handler(param); + } + } + else { + if (((uVar3 == 0xc0) || (uVar3 == 0xa0)) && + (kVar1 = ke_state_get(6), CONCAT31(extraout_var_01,kVar1) == 0)) { + iVar2 = sm_deauth_handler(param); + return iVar2; + } + } + } + return 0; +} + + + +int mm_set_vif_state_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + byte bVar1; + sm_connect_req *psVar2; + ke_state_t kVar3; + undefined3 extraout_var; + u8_l *puVar4; + undefined *puVar5; + uint8_t uVar6; + uint uVar7; + + kVar3 = ke_state_get(6); + psVar2 = sm_env.connect_param; + if (CONCAT31(extraout_var,kVar3) == 7) { + uVar7 = (uint)(sm_env.connect_param)->vif_idx; + bVar1 = vif_info_tab[uVar7].u[4]; + puVar4 = (u8_l *)ke_msg_alloc(0x4b,0,6,6); + *(bool_l *)(puVar4 + 4) = psVar2->dont_wait_bcmc; + *(u16_l *)(puVar4 + 2) = psVar2->listen_interval; + *puVar4 = psVar2->vif_idx; + ke_msg_send(); + uVar6 = ((vif_info_tab[uVar7].flags & 1) == 0) + '\x01'; + sta_info_tab[bVar1].ctrl_port_state = uVar6; + sta_info_tab[bVar1].ctrl_port_ethertype = + psVar2->ctrl_port_ethertype >> 8 | psVar2->ctrl_port_ethertype << 8; + if (uVar6 == '\x02') { + puVar5 = (undefined *)ke_msg_alloc(0x1413,5,6,2); + *puVar5 = 0; + puVar5[1] = psVar2->vif_idx; + ke_msg_send(); + } + if ((*(uint *)&vif_info_tab[uVar7].bss_info.is_supplicant_enabled & 0x12800) == 0) { + sm_connect_ind(0); + } + } + return 0; +} + + + +int me_set_active_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + mac_addr_conflict67 *pmStack24; + mac_addr_conflict171 *bssid; + scan_chan_tag *chan; + + kVar1 = ke_state_get(6); + if ((CONCAT31(extraout_var,kVar1) != 4) && + (kVar1 = ke_state_get(6), CONCAT31(extraout_var_00,kVar1) != 8)) { + assert_err( + "(ke_state_get(TASK_SM) == SM_BSS_PARAM_SETTING) || (ke_state_get(TASK_SM) == SM_DISCONNECTING)" + ,"module",0x216); + } + kVar1 = ke_state_get(6); + if (CONCAT31(extraout_var_01,kVar1) == 8) { + if (sm_env.ft_over_ds == false) { + ke_state_set(6,0); + } + else { + pmStack24 = (mac_addr_conflict67 *)0x0; + bssid = (mac_addr_conflict171 *)0x0; + sm_get_bss_params(&pmStack24,(scan_chan_tag **)&bssid); + sm_join_bss(pmStack24,(scan_chan_tag *)bssid,false); + } + } + else { + if (sm_env.ft_over_ds == false) { + sm_auth_send(1,(uint32_t *)0x0); + } + else { + sm_assoc_req_send(); + } + } + return 0; +} + + + +int mm_sta_add_cfm_handler + (ke_msg_id_t msgid,mm_sta_add_cfm *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint uVar1; + ke_state_t kVar2; + undefined3 extraout_var; + uint uVar3; + uint uVar4; + + kVar2 = ke_state_get(6); + if (CONCAT31(extraout_var,kVar2) != 3) { + assert_err("ke_state_get(TASK_SM) == SM_STA_ADDING","module",0x19c); + } + if (param->status == '\0') { + uVar4 = (uint)param->sta_idx; + uVar1 = (uint)sta_info_tab[uVar4].inst_nbr; + memcpy(&sta_info_tab[uVar4].info,&vif_info_tab[uVar1].bss_info.rate_set,0xd); + uVar3 = vif_info_tab[uVar1].bss_info.valid_flags; + if ((uVar3 & 1) != 0) { + sta_info_tab[uVar4].info.capa_flags = sta_info_tab[uVar4].info.capa_flags | 1; + } + if ((uVar3 & 2) != 0) { + sta_info_tab[uVar4].info.capa_flags = sta_info_tab[uVar4].info.capa_flags | 2; + memcpy(&sta_info_tab[uVar4].info.ht_cap,&vif_info_tab[uVar1].bss_info,0x20); + me_set_sta_ht_vht_param(sta_info_tab + uVar4,&vif_info_tab[uVar1].bss_info); + } + sm_set_bss_param(); + } + else { + sm_connect_ind(0xf); + } + return 0; +} + + + +int sm_disconnect_req_handler + (ke_msg_id_t msgid,sm_disconnect_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + int iVar2; + + kVar1 = ke_state_get(6); + iVar2 = 2; + if (CONCAT31(extraout_var,kVar1) == 0) { + sm_disconnect(param->vif_idx,param->reason_code); + ke_msg_send_basic(0x1804,0xd,6); + iVar2 = 0; + } + return iVar2; +} + + + +int apm_sta_connect_timeout_ind_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + u8_l sta_idx; + sta_info_tag *psVar1; + TickType_t TVar2; + + TVar2 = xTaskGetTickCount(); + psVar1 = sta_info_tab; + sta_idx = '\0'; + do { + if ((psVar1->time_last_seen != 0) && (30000 < (int)(TVar2 - psVar1->time_last_seen))) { + apm_sta_fw_delete(sta_idx); + } + sta_idx = sta_idx + '\x01'; + psVar1 = psVar1 + 1; + } while (sta_idx != '\f'); + ke_timer_set(0x1c0a,7,5000000); + return 0; +} + + + +int rxu_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + undefined4 uVar1; + ushort uVar2; + + uVar2 = param->framectrl & 0xfc; + if (uVar2 == 0x40) { + apm_probe_req_handler(); + } + else { + if (uVar2 == 0xb0) { + apm_auth_handler(param); + } + else { + uVar1 = 0; + if ((param->framectrl & 0xfc) != 0) { + if (uVar2 != 0x20) { + if (uVar2 == 0xc0) { + apm_deauth_handler(param); + return 0; + } + if (uVar2 == 0xa0) { + apm_disassoc_handler(param); + return 0; + } + if (uVar2 != 0x80) { + return 0; + } + apm_beacon_handler(param); + return 0; + } + uVar1 = 1; + } + apm_assoc_req_handler(uVar1); + } + } + return 0; +} + + + +int apm_sta_add_cfm_handler + (ke_msg_id_t msgid,me_sta_add_cfm *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + if (uap_conn_info == (cm_ConnectionInfo_t *)0x0) { + apm_sta_add(param->sta_idx); + } + else { + uap_conn_info->staId = param->sta_idx; + SendEAPOLMsgUsingBufDesc(uap_conn_info,(BufferDesc_t *)0x0); + } + return 0; +} + + + +int apm_sta_del_req_handler + (ke_msg_id_t msgid,apm_sta_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined *puVar1; + + puVar1 = (undefined *)ke_msg_alloc(0x1c0c,src_id,dest_id,3); + if ((vif_info_tab[param->vif_idx].type == '\x02') && (param->sta_idx < 0xd)) { + apm_sta_remove(param->vif_idx,param->sta_idx); + *puVar1 = 0; + } + else { + *puVar1 = 0xff; + } + ke_msg_send(puVar1); + return 0; +} + + +/* +Unable to decompile 'apm_stop_cac_req_handler' +Cause: Exception while decompiling 2306423a: Decompiler process died + +*/ + + +int apm_conf_max_sta_req_handler + (ke_msg_id_t msgid,apm_conf_max_sta_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + apm_env.max_sta_supported = param->max_sta_supported; + if (0xc < apm_env.max_sta_supported) { + apm_env.max_sta_supported = 0xc; + } + ke_msg_send_basic(0x1c0e,src_id,dest_id); + return 0; +} + + +/* +Unable to decompile 'apm_start_cac_req_handler' +Cause: Exception while decompiling 230642e0: Decompiler process died + +*/ + + +int me_set_ps_disable_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + + kVar1 = ke_state_get(7); + if ((CONCAT31(extraout_var,kVar1) != 1) && + (kVar1 = ke_state_get(7), CONCAT31(extraout_var_00,kVar1) != 0)) { + assert_err( + "(ke_state_get(TASK_APM) == APM_BSS_PARAM_SETTING) || (ke_state_get(TASK_APM) == APM_IDLE)" + ,"module",0xee); + } + kVar1 = ke_state_get(7); + if (CONCAT31(extraout_var_01,kVar1) == 1) { + apm_send_next_bss_param(); + } + return 0; +} + + + +int mm_bss_param_setting_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + + kVar1 = ke_state_get(7); + if (CONCAT31(extraout_var,kVar1) != 1) { + assert_err("ke_state_get(TASK_APM) == APM_BSS_PARAM_SETTING","module",0x110); + } + apm_send_next_bss_param(); + return 0; +} + + + +int mm_bcn_change_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + + kVar1 = ke_state_get(7); + if (CONCAT31(extraout_var,kVar1) != 2) { + assert_err("ke_state_get(TASK_APM) == APM_BCN_SETTING","module",0x156); + } + apm_start_cfm(0); + return 0; +} + + + +int apm_stop_req_handler + (ke_msg_id_t msgid,apm_stop_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint uVar1; + ke_state_t kVar2; + undefined3 extraout_var; + + uVar1 = (uint)param->vif_idx; + if ((vif_info_tab[uVar1].type == '\x02') && (vif_info_tab[uVar1].active != false)) { + kVar2 = ke_state_get(7); + if (CONCAT31(extraout_var,kVar2) != 0) { + return 2; + } + if (apm_env.apm_emb_enabled != false) { + apm_env.apm_emb_enabled = false; + } + apm_stop(vif_info_tab + uVar1); + if (uap_conn_info != (cm_ConnectionInfo_t *)0x0) { + RemoveAPKeyInfo(uap_conn_info); + cm_DeleteConnection(uap_conn_info); + uap_conn_info = (cm_ConnectionInfo_t *)0x0; + } + } + ke_msg_send_basic(0x1c03,src_id,dest_id); + return 0; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int apm_start_req_handler + (ke_msg_id_t msgid,apm_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint32_t uVar1; + char "apm_start_req_handler" [22]; + ke_state_t kVar2; + uint8_t uVar3; + _Bool _Var4; + uint16_t uVar5; + undefined3 extraout_var; + undefined3 extraout_var_00; + scan_chan_tag *psVar6; + undefined3 extraout_var_01; + int iVar7; + undefined *puVar8; + uint uVar9; + undefined uVar10; + u8_l *ssid; + uint8_t uStack51; + int8_t iStack50; + uint8_t auStack49 [2]; + u8_l chan_idx; + s8_l pwr; + u8_l idx; + + printf("[WF] received APM Start %s:%d\r\n","apm_start_req_handler",0x4c); + uVar9 = (uint)param->vif_idx; + uVar10 = 4; + if (vif_info_tab[uVar9].type == '\x02') { + kVar2 = ke_state_get(7); + if (CONCAT31(extraout_var,kVar2) == 0) { + if (vif_info_tab[uVar9].active == false) { + if (vif_info_tab[uVar9].chan_ctxt != (chan_ctxt_tag *)0x0) { + assert_err("vif->chan_ctxt == NULL","module",0x67); + } + apm_env.param = param; + uVar3 = me_add_chan_ctx(&uStack51,¶m->chan,param->center_freq1,param->center_freq2, + param->ch_width); + uVar10 = 1; + if (CONCAT31(extraout_var_00,uVar3) == 0) { + psVar6 = me_freq_to_chan_ptr((param->chan).band,(param->chan).freq); + vif_info_tab[uVar9].bss_info.chan = psVar6; + psVar6->tx_power = (param->chan).tx_power; + vif_info_tab[uVar9].bss_info.center_freq1 = (uint16_t)param->center_freq1; + vif_info_tab[uVar9].bss_info.center_freq2 = (uint16_t)param->center_freq2; + uVar3 = param->ch_width; + if (uVar3 == '\x04') { + uVar3 = '\x03'; + } + vif_info_tab[uVar9].bss_info.bw = uVar3; + uVar3 = param->ch_width; + vif_info_tab[uVar9].bss_info.power_constraint = '\0'; + vif_info_tab[uVar9].bss_info.phy_bw = uVar3; + chan_ctxt_link(param->vif_idx,uStack51); + apm_env.apm_emb_enabled = param->apm_emb_enabled; + apm_env.hidden_ssid = param->hidden_ssid; + _Var4 = apm_embedded_enabled(vif_info_tab + uVar9); + if (CONCAT31(extraout_var_01,_Var4) != 0) { + me_get_basic_rates(¶m->rate_set,(mac_rateset *)param); + if (param->qos_supported != '\0') { + vif_info_tab[uVar9].bss_info.valid_flags = + vif_info_tab[uVar9].bss_info.valid_flags | 1; + } + if (me_env.ht_supported != false) { + vif_info_tab[uVar9].bss_info.valid_flags = + vif_info_tab[uVar9].bss_info.valid_flags | 2; + } + vif_info_tab[uVar9].bss_info.beacon_interval = param->bcn_int; + vif_info_tab[uVar9].bss_info.beacon_period = (ushort)param->beacon_period; + vif_info_tab[uVar9].bss_info.sec_type = param->ap_sec_type; + memcpy(&vif_info_tab[uVar9].bss_info.ssid,¶m->ssid,0x22); + vif_info_tab[uVar9].bss_info.ssid.array[vif_info_tab[uVar9].bss_info.ssid.length] = '\0' + ; + *(undefined4 *)vif_info_tab[uVar9].bss_info.bssid.array = + *(undefined4 *)vif_info_tab[uVar9].mac_addr.array; + vif_info_tab[uVar9].bss_info.bssid.array[2] = vif_info_tab[uVar9].mac_addr.array[2]; + memcpy(&vif_info_tab[uVar9].bss_info.rate_set,¶m->rate_set,0xd); + vif_info_tab[uVar9].txq_params[0] = _DAT_44b00200; + vif_info_tab[uVar9].txq_params[1] = _DAT_44b00204; + vif_info_tab[uVar9].txq_params[2] = _DAT_44b00208; + uVar1 = _DAT_44b0020c; + vif_info_tab[uVar9].bss_info.edca_param.qos_info = '\0'; + vif_info_tab[uVar9].txq_params[3] = uVar1; + *(undefined4 *)&vif_info_tab[uVar9].bss_info.aid_bitmap = 0xffff0000; + apm_env.bcn_buf = (uint8_t *)ke_malloc(0x14d); + uVar5 = me_build_beacon((uint32_t)apm_env.bcn_buf,vif_info_tab[uVar9].index, + ¶m->tim_oft,¶m->tim_len,apm_env.hidden_ssid); + param->bcn_len = uVar5; + if (param->ap_sec_type == '\0') { + uap_conn_info = (cm_ConnectionInfo_t *)0x0; + } + else { + uap_conn_info = + cm_InitConnection('\x02','\0','\0', + (IEEEtypes_MacAddr_t *)&vif_info_tab[uVar9].bss_info.bssid, + (IEEEtypes_MacAddr_t *)0x0,'\0',(unkbyte0 *)0x0); + ssid = vif_info_tab[uVar9].bss_info.ssid.array; + ap_setpsk(uap_conn_info,(CHAR *)ssid,(CHAR *)param->phrase); + cm_SetComData(uap_conn_info,(char *)ssid); + uap_conn_info->instNbr = param->vif_idx; + printf("%s:uap_conn_info->instNbr = %d\r\n",0x2307f464,(uint)uap_conn_info->instNbr); + InitGroupKey(uap_conn_info); + } + } + if ((param->chan).band == '\0') { + uVar5 = me_legacy_rate_bitfield_build(&vif_info_tab[uVar9].bss_info.rate_set,true); + if ((uVar5 & 0xf) == 0) { + vif_info_tab[uVar9].bss_info.high_11b_rate = '\x01'; + } + else { + iVar7 = __clzsi2((uint)uVar5 & 0xf); + vif_info_tab[uVar9].bss_info.high_11b_rate = '\x1f' - (char)iVar7; + } + } + apm_set_bss_param(); + iStack50 = (vif_info_tab[uVar9].bss_info.chan)->tx_power; + tpc_update_vif_tx_power(vif_info_tab + uVar9,&iStack50,auStack49); + printf("[WF] return with other handler\r\n"); + return 1; + } + } + else { + uVar10 = 9; + } + } + else { + uVar10 = 8; + } + } + printf("[WF] Sending APM CFM %s:%d\r\n",0x2307f464,0xcc); + puVar8 = (undefined *)ke_msg_alloc(0x1c01,src_id,dest_id,4); + *puVar8 = uVar10; + puVar8[1] = param->vif_idx; + ke_msg_send(); + return 0; +} + + + +int me_set_active_cfm_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ke_state_t kVar1; + undefined3 extraout_var; + undefined3 extraout_var_00; + undefined3 extraout_var_01; + + kVar1 = ke_state_get(7); + if ((CONCAT31(extraout_var,kVar1) != 1) && + (kVar1 = ke_state_get(7), CONCAT31(extraout_var_00,kVar1) != 0)) { + assert_err( + "(ke_state_get(TASK_APM) == APM_BSS_PARAM_SETTING) || (ke_state_get(TASK_APM) == APM_IDLE)" + ,"module",0x12f); + } + kVar1 = ke_state_get(7); + if (CONCAT31(extraout_var_01,kVar1) == 1) { + if (apm_env.bss_config.first != (co_list_hdr *)0x0) { + assert_err("co_list_is_empty(&apm_env.bss_config)","module",0x135); + } + apm_bcn_set(); + } + return 0; +} + + + +int hostapd_mgt_ind_handler + (ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + ushort uVar1; + + uVar1 = param->framectrl & 0xfc; + if ((uVar1 != 0x40) && (uVar1 != 0xb0)) { + return 0; + } + ke_state_get(10); + return 0; +} + + + +void dump_cfg_entries(void) + +{ + cfg_element_entry *pcVar1; + char *pcVar2; + char acStack64 [4]; + char strs [16]; + + puts("================= CFG TASK =================\r\n"); + pcVar1 = cfg_entrys_mm; + while (pcVar1 < &_fsymc_info_bloop) { + printf("entry %p\r\n",pcVar1); + printf(" task : %lu\r\n",(blog_level_t *)pcVar1->task); + printf(" element : %u\r\n",(uint)pcVar1->element); + printf(" type : %u\r\n",(uint)pcVar1->type); + printf(" name : %s\r\n",pcVar1->name); + pcVar2 = cfg_api_element_dump(pcVar1->val,*(CFG_ELEMENT_TYPE *)&pcVar1->type,acStack64); + printf(" type : %s\r\n",pcVar2); + printf(" val : %s\r\n"); + puts("------------------------\r\n"); + pcVar1 = pcVar1 + 1; + } + puts("---------------------------------------------\r\n"); + return; +} + + + +// WARNING: Variable defined which should be unmapped: val + +int cfg_start_req_handler + (ke_msg_id_t msgid,cfg_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined2 in_register_0000202a; + undefined *puVar1; + int iVar2; + undefined4 uStack20; + uint32_t val [1]; + + if (param->ops == 0) { + iVar2 = utils_tlv_bl_unpack_auto + ((uint32_t *)(param + 5),param[4].ops,*(uint16_t *)¶m[3].ops,&uStack20); + printf("unpack ret is %d, result is %lu\r\n",iVar2,uStack20); + cfg_api_element_set(param[1].ops,param[2].ops,param[3].ops,&uStack20,(void *)0x0); + } + else { + if (2 < param->ops) { + dump_cfg_entries(CONCAT22(in_register_0000202a,msgid)); + } + } + puVar1 = (undefined *)ke_msg_alloc(0x3001,src_id,dest_id,1); + *puVar1 = 0; + ke_msg_send(); + return 0; +} + + + +char * cfg_api_element_dump(void *val,CFG_ELEMENT_TYPE type,char *strs) + +{ + int iVar1; + char *pcVar2; + + switch((uint)type - 1 & 0xff) { + case 0: + if (*(char *)val == '\0') { + pcVar2 = "False"; + } + else { + pcVar2 = "True"; + } + iVar1 = snprintf(strs,0xf,"%s",pcVar2); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "Boolean"; + break; + case 1: + iVar1 = snprintf(strs,0xf,"%d",(int)*(char *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "SINT8"; + break; + case 2: + iVar1 = snprintf(strs,0xf,"%u",(uint)*(byte *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "UINT8"; + break; + case 3: + iVar1 = snprintf(strs,0xf,"%d",(int)*(short *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "SINT16"; + break; + case 4: + iVar1 = snprintf(strs,0xf,"%u",(uint)*(ushort *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "UINT16"; + break; + case 5: + iVar1 = snprintf(strs,0xf,"%ld",*(undefined4 *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "SINT32"; + break; + case 6: + iVar1 = snprintf(strs,0xf,"%lu",*(undefined4 *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "UINT32"; + break; + case 7: + iVar1 = snprintf(strs,0xf,"%lu",*(undefined4 *)val); + if (iVar1 < 0) { + iVar1 = 0; + } + strs[iVar1] = '\0'; + pcVar2 = "STRING"; + break; + default: + return (char *)0x0; + } + return pcVar2; +} + + + +int cfg_api_element_general_set(cfg_element_entry *entry,void *arg1,void *arg2) + +{ + undefined uVar1; + undefined2 uVar2; + uint uVar3; + undefined4 *puVar4; + + printf(" updating element: %s\r\n",entry->name); + uVar3 = (uint)entry->type - 1 & 0xffff; + if (6 < uVar3) { + return 0; + } + puVar4 = (undefined4 *)entry->val; + switch(uVar3) { + default: + uVar1 = *(undefined *)arg1; + break; + case 1: + uVar1 = *(undefined *)arg1; + break; + case 3: + uVar2 = *(undefined2 *)arg1; + goto LAB_23064c28; + case 4: + uVar2 = *(undefined2 *)arg1; +LAB_23064c28: + *(undefined2 *)puVar4 = uVar2; + return 0; + case 5: + case 6: + *puVar4 = *(undefined4 *)arg1; + return 0; + } + *(undefined *)puVar4 = uVar1; + return 0; +} + + + +int cfg_api_element_general_get(cfg_element_entry *entry,void *arg1,void *arg2) + +{ + return 0; +} + + + +int cfg_api_element_set(uint32_t task,uint32_t element,uint32_t type,void *arg1,void *arg2) + +{ + cfg_element_entry *pcVar1; + + pcVar1 = cfg_entrys_mm; + while (pcVar1 < &_fsymc_info_bloop) { + if ((pcVar1->task == task) && ((uint)pcVar1->element == element)) { + if ((uint)pcVar1->type == type) goto LAB_23064c90; + printf("type %lu NOT matched on element: %lu %lu %u\r\n",type,task,element); + } + pcVar1 = pcVar1 + 1; + } + if (pcVar1 != (cfg_element_entry *)&_fsymc_info_bloop) { +LAB_23064c90: + (*pcVar1->set)(pcVar1,arg1,arg2); + } + return 0; +} + + + +uint32_t co_crc32(uint32_t addr,uint32_t len,uint32_t crc) + +{ + uint32_t uVar1; + byte *pbVar2; + + uVar1 = 0; + while (uVar1 != len) { + pbVar2 = (byte *)(uVar1 + addr); + uVar1 = uVar1 + 1; + crc = crc << 8 ^ crc_tab[crc >> 0x18 ^ (uint)*pbVar2]; + } + return crc; +} + + + +void dbg_init(void) + +{ + memset(&dbg_env,0,8); + dbg_env.filter_module = 0xffffffff; + dbg_env.filter_severity = 2; + return; +} + + + +void dbg_test_print(char *fmt,...) + +{ + byte bVar1; + uint uVar2; + byte *pbVar3; + va_list args; + + if (dbg_env.filter_severity != 0) { + pbVar3 = (byte *)(fmt + 2); + do { + bVar1 = *fmt; + uVar2 = (uint)bVar1; + if (-1 < (char)bVar1) { + return; + } + if (bVar1 < 0x88) { + if ((~dbg_env.filter_module >> (uVar2 - 0x80 & 0x1f) & 1) != 0) { + return; + } + } + else { + if (5 < (uVar2 + 0x66 & 0xff)) { + assert_err("DBG_SEV_MIN <= prefix && prefix < DBG_SEV_MAX","module",0x297); + } + if (dbg_env.filter_severity <= uVar2 - 0x9a) { + return; + } + } + fmt = (char *)((byte *)fmt + 1); + } while (pbVar3 != (byte *)fmt); + } + return; +} + + + +int dbg_get_sys_stat_req_handler + (ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + undefined4 *puVar1; + + puVar1 = (undefined4 *)ke_msg_alloc(0x40a,src_id,dest_id,0xc); + *puVar1 = 0; + puVar1[1] = 0; + puVar1[2] = 0; + ke_msg_send(); + return 0; +} + + + +int dbg_mem_write_req_handler + (ke_msg_id_t msgid,dbg_mem_write_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint32_t **ppuVar1; + uint32_t **ppuVar2; + + ppuVar1 = (uint32_t **)ke_msg_alloc(0x403,src_id,dest_id,8); + *(uint32_t *)param->memaddr = param->memdata; + ppuVar2 = (uint32_t **)param->memaddr; + *(uint32_t ***)ppuVar1 = ppuVar2; + ppuVar1[1] = *ppuVar2; + ke_msg_send(); + return 0; +} + + + +int dbg_mem_read_req_handler + (ke_msg_id_t msgid,dbg_mem_read_req *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint32_t *puVar1; + + puVar1 = (uint32_t *)ke_msg_alloc(0x401,src_id,dest_id,8); + puVar1[1] = *(uint32_t *)param->memaddr; + *puVar1 = param->memaddr; + ke_msg_send(); + return 0; +} + + + +int dbg_set_sev_filter_req_handler + (ke_msg_id_t msgid,dbg_set_sev_filter_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + dbg_env.filter_severity = param->sev_filter; + ke_msg_send_basic(0x407,src_id,dest_id); + return 0; +} + + + +int dbg_set_mod_filter_req_handler + (ke_msg_id_t msgid,dbg_set_mod_filter_req *param,ke_task_id_t dest_id, + ke_task_id_t src_id) + +{ + dbg_env.filter_module = param->mod_filter; + ke_msg_send_basic(0x405,src_id,dest_id); + return 0; +} + + + +// WARNING: Type propagation algorithm not settling + +co_list_hdr * +ke_queue_extract(co_list *queue,anon_subr__Bool_co_list_hdr_ptr_uint32_t_conflict2 *func, + uint32_t arg) + +{ + co_list_hdr cVar1; + co_list_hdr cVar2; + _Bool _Var3; + undefined3 extraout_var; + co_list_hdr cVar4; + + cVar4 = (co_list_hdr)queue->first; + cVar1 = (co_list_hdr)0x0; + do { + cVar2 = cVar1; + cVar1 = cVar4; + if (cVar1 == (co_list_hdr)0x0) { + return (co_list_hdr *)0; + } + _Var3 = (*func)((co_list_hdr *)cVar1,arg); + cVar4 = *(co_list_hdr *)cVar1; + } while (CONCAT31(extraout_var,_Var3) == 0); + if (cVar2 == (co_list_hdr)0x0) { + *(co_list_hdr *)&queue->first = cVar4; + } + else { + *(co_list_hdr *)cVar2 = cVar4; + } + if (*(int *)cVar1 == 0) { + *(co_list_hdr *)&queue->last = cVar2; + } + else { + *(undefined4 *)cVar1 = 0; + } + return (co_list_hdr *)cVar1; +} + + + +void bl_aes_128(UINT8 *key,UINT8 *input,UINT8 *output) + +{ + BL_AesEncrypt(key,'\x02',input,output); + return; +} + + + +void xor_128(UINT8 *a,UINT8 *b,UINT8 *out) + +{ + byte *pbVar1; + int iVar2; + byte *pbVar3; + byte *pbVar4; + + iVar2 = 0; + do { + pbVar1 = a + iVar2; + pbVar4 = b + iVar2; + pbVar3 = out + iVar2; + iVar2 = iVar2 + 1; + *pbVar3 = *pbVar1 ^ *pbVar4; + } while (iVar2 != 0x10); + return; +} + + + +void leftshift_onebit(UINT8 *input,UINT8 *output) + +{ + byte *pbVar1; + int iVar2; + byte bVar3; + byte *pbVar4; + + bVar3 = 0; + iVar2 = 0xf; + do { + pbVar1 = input + iVar2; + pbVar4 = output + iVar2; + iVar2 = iVar2 + -1; + *pbVar4 = bVar3 | *pbVar1 << 1; + bVar3 = *pbVar1 >> 7; + } while (iVar2 != -1); + return; +} + + + +// WARNING: Variable defined which should be unmapped: tmp + +void generate_subkey(UINT8 *key,UINT8 *K1,UINT8 *K2) + +{ + UINT8 local_40 [4]; + UINT8 L [16]; + UINT8 Z [16]; + UINT8 tmp [16]; + + memset(L + 0xc,0,0x10); + bl_aes_128(key,L + 0xc,local_40); + if ((char)local_40[0] < '\0') { + leftshift_onebit(local_40,Z + 0xc); + xor_128(Z + 0xc,"",K1); + } + else { + leftshift_onebit(local_40,K1); + } + if ((char)*K1 < '\0') { + leftshift_onebit(K1,Z + 0xc); + xor_128(Z + 0xc,"",K2); + } + else { + leftshift_onebit(K1,K2); + } + return; +} + + + +void padding(UINT8 *lastb,UINT8 *pad,int length) + +{ + int iVar1; + + iVar1 = 0; + do { + if (iVar1 < length) { + pad[iVar1] = lastb[iVar1]; + } + else { + if (length == iVar1) { + pad[length] = -0x80; + } + else { + pad[iVar1] = '\0'; + } + } + iVar1 = iVar1 + 1; + } while (iVar1 != 0x10); + return; +} + + + +void bl_aes_cmac(UINT8 *key,UINT8 *input,int length,UINT8 *mac) + +{ + int iVar1; + int iVar2; + UINT8 *a; + UINT8 *pUVar3; + UINT8 local_80 [4]; + UINT8 X [16]; + UINT8 Y [16]; + UINT8 M_last [16]; + UINT8 padded [16]; + UINT8 K1 [16]; + UINT8 K2 [16]; + + generate_subkey(key,padded + 0xc,K1 + 0xc); + iVar1 = (length + 0xf) / 0x10; + if (iVar1 == 0) { + iVar1 = 1; + } + else { + if ((length & 0xfU) == 0) { + pUVar3 = padded; + a = input + (iVar1 + -1) * 0x10; + goto LAB_2306503c; + } + } + padding(input + (iVar1 + -1) * 0x10,M_last + 0xc,length % 0x10); + pUVar3 = K1; + a = M_last + 0xc; +LAB_2306503c: + xor_128(a,pUVar3 + 0xc,Y + 0xc); + memset(local_80,0,0x10); + iVar2 = 0; + while (iVar2 < iVar1 + -1) { + xor_128(local_80,input + iVar2 * 0x10,X + 0xc); + bl_aes_128(key,X + 0xc,local_80); + iVar2 = iVar2 + 1; + } + xor_128(local_80,Y + 0xc,X + 0xc); + bl_aes_128(key,X + 0xc,local_80); + iVar1 = 0; + do { + pUVar3 = local_80 + iVar1; + a = mac + iVar1; + iVar1 = iVar1 + 1; + *a = *pUVar3; + } while (iVar1 != 0x10); + return; +} + + + +int BL_AES_MEMCMP(UINT8 *dst,UINT8 *src,int len) + +{ + int iVar1; + int iVar2; + + iVar2 = 0; + iVar1 = len; + while (len != iVar2) { + if (dst[iVar2] == src[iVar2]) { + iVar1 = iVar1 + -1; + } + iVar2 = iVar2 + 1; + } + return -(uint)(iVar1 != 0); +} + + + +void BL_AES_MEMSET(UINT8 *dst,UINT8 val,int size) + +{ + UINT8 *pUVar1; + + pUVar1 = dst; + while (pUVar1 != dst + size) { + *pUVar1 = val; + pUVar1 = pUVar1 + 1; + } + return; +} + + + +void BL_AES_MEMCPY(UINT8 *dst,UINT8 *src,int size) + +{ + UINT8 *pUVar1; + UINT8 *pUVar2; + int iVar3; + + if (dst < src) { + iVar3 = 0; + while (iVar3 != size) { + pUVar1 = src + iVar3; + pUVar2 = dst + iVar3; + iVar3 = iVar3 + 1; + *pUVar2 = *pUVar1; + } + return; + } + while (size = size + -1, size != -1) { + dst[size] = src[size]; + } + return; +} + + + +int BL_AesEncrypt(UINT8 *kek,UINT8 kekLen,UINT8 *data,UINT8 *ret) + +{ + undefined3 in_register_0000202d; + undefined auStack416 [4]; + UINT8 pBuf [400]; + + rijndael_set_key((rijndael_ctx *)auStack416,kek,CONCAT31(in_register_0000202d,kekLen) << 6,1); + rijndael_encrypt((rijndael_ctx *)auStack416,data,ret); + return 0; +} + + + +int BL_AesWrap(UINT8 *kek,UINT8 kekLen,UINT32 n,UINT8 *plain,UINT8 *keyIv,UINT8 *cipher) + +{ + int iVar1; + uint uVar2; + int iVar3; + int iVar4; + UINT8 aUStack72 [4]; + UINT8 a [8]; + UINT8 b [16]; + + if (n != 0) { + BL_AES_MEMSET(a + 4,'\0',0x10); + if (keyIv == (UINT8 *)0x0) { + keyIv = BL_DEFAULT_IV; + } + BL_AES_MEMCPY(aUStack72,keyIv,8); + BL_AES_MEMCPY(cipher + 8,plain,n << 3); + uVar2 = 0; + iVar4 = 6; + do { + iVar1 = 1; + while (iVar3 = iVar1 * 8, iVar1 != n + 1) { + BL_AES_MEMCPY(a + 4,aUStack72,8); + BL_AES_MEMCPY(b + 4,cipher + iVar3,8); + BL_AesEncrypt(kek,kekLen,a + 4,a + 4); + BL_AES_MEMCPY(aUStack72,a + 4,8); + a[3] = (char)uVar2 + (char)iVar1 ^ a[3]; + iVar1 = iVar1 + 1; + BL_AES_MEMCPY(cipher + iVar3,b + 4,8); + } + iVar4 = iVar4 + -1; + uVar2 = uVar2 + (n & 0xff) & 0xff; + } while (iVar4 != 0); + BL_AES_MEMCPY(cipher,aUStack72,8); + return 0; + } + return -1; +} + + + +int BL_AesUnWrap(UINT8 *kek,UINT8 kekLen,UINT32 n,UINT8 *cipher,UINT8 *keyIv,UINT8 *plain) + +{ + uint uVar1; + undefined3 in_register_0000202d; + UINT32 UVar2; + UINT8 *src; + int iVar3; + UINT8 aUStack472 [4]; + UINT8 a [8]; + UINT8 b [16]; + UINT8 pBuf [400]; + + if (n != 0) { + BL_AES_MEMSET(aUStack472,'\0',8); + BL_AES_MEMSET(a + 4,'\0',0x10); + BL_AES_MEMCPY(aUStack472,cipher,8); + uVar1 = (n & 0xff) * 5; + BL_AES_MEMCPY(plain,cipher + 8,n * 8); + rijndael_set_key((rijndael_ctx *)(b + 0xc),kek,CONCAT31(in_register_0000202d,kekLen) << 6,0); + iVar3 = 6; + do { + UVar2 = n; + src = plain + n * 8 + -8; + while (0 < (int)UVar2) { + BL_AES_MEMCPY(a + 4,aUStack472,8); + b[3] = (char)(uVar1 & 0xff) + (char)UVar2 ^ b[3]; + BL_AES_MEMCPY(b + 4,src,8); + rijndael_decrypt((rijndael_ctx *)(b + 0xc),a + 4,a + 4); + BL_AES_MEMCPY(aUStack472,a + 4,8); + BL_AES_MEMCPY(src,b + 4,8); + src = src + -8; + UVar2 = UVar2 - 1; + } + uVar1 = (uVar1 & 0xff) - (n & 0xff); + iVar3 = iVar3 + -1; + } while (iVar3 != 0); + if (keyIv == (UINT8 *)0x0) { + keyIv = BL_DEFAULT_IV; + } + iVar3 = BL_AES_MEMCMP(keyIv,aUStack472,8); + return -(uint)(iVar3 != 0); + } + return -1; +} + + + +// WARNING: Variable defined which should be unmapped: pBuf + +void Bl_hmac_md5(UINT8 *text_data,int text_len,UINT8 *key,int key_len,void *digest) + +{ + ulong *puVar1; + Bl_MD5_CTX *pBVar2; + Bl_MD5_CTX *context; + Bl_MD5_CTX *context_00; + undefined auStack584 [4]; + Bl_MD5_CTX tctx; + uchar pBuf [400]; + + if (0x40 < key_len) { + wpa_MD5Init((Bl_MD5_CTX *)auStack584); + wpa_MD5Update((Bl_MD5_CTX *)auStack584,key,key_len); + wpa_MD5Final(pBuf + 0x94,(Bl_MD5_CTX *)auStack584); + key_len = 0x10; + key = pBuf + 0x94; + } + memset(tctx.buffer + 0x3c,0,0x40); + memcpy(tctx.buffer + 0x3c,key,key_len); + context_00 = (Bl_MD5_CTX *)(pBuf + 0x3c); + pBVar2 = (Bl_MD5_CTX *)(tctx.buffer + 0x3c); + do { + puVar1 = pBVar2->state; + pBVar2->state[0] = pBVar2->state[0] ^ 0x36363636; + pBVar2 = (Bl_MD5_CTX *)(puVar1 + 1); + } while ((Bl_MD5_CTX *)(puVar1 + 1) != context_00); + wpa_MD5Init(context_00); + wpa_MD5Update(context_00,tctx.buffer + 0x3c,0x40); + wpa_MD5Update(context_00,text_data,text_len); + wpa_MD5Final((uchar *)digest,context_00); + memset(tctx.buffer + 0x3c,0,0x40); + memcpy(tctx.buffer + 0x3c,key,key_len); + pBVar2 = (Bl_MD5_CTX *)(tctx.buffer + 0x3c); + do { + context = (Bl_MD5_CTX *)(pBVar2->state + 1); + pBVar2->state[0] = pBVar2->state[0] ^ 0x5c5c5c5c; + pBVar2 = context; + } while (context != context_00); + wpa_MD5Init(context); + wpa_MD5Update(context,tctx.buffer + 0x3c,0x40); + wpa_MD5Update(context,(UINT8 *)digest,0x10); + wpa_MD5Final((uchar *)digest,context); + return; +} + + + +void Bl_hmac_sha1(uchar **ppText,int *pTextLen,int textNum,uchar *key,int key_len,uchar *output, + int outputLen) + +{ + uint *puVar1; + uint *__src; + uchar **ppuVar2; + int iVar3; + uint *Message_Digest; + uint local_1c0; + uchar pBuf [400]; + + if (0x40 < key_len) { + Bl_SHA1Init((Bl_SHA1_CTX *)(pBuf + 0x50)); + Bl_SHA1Update((Bl_SHA1_CTX *)(pBuf + 0x50),key,key_len); + Bl_SHA1Final((Bl_SHA1_CTX *)(pBuf + 0x50),key); + key_len = 0x14; + } + memset(&local_1c0,0,0x40); + memcpy(&local_1c0,key,key_len); + Message_Digest = (uint *)(pBuf + 0x3c); + puVar1 = &local_1c0; + do { + __src = puVar1 + 2; + *puVar1 = *puVar1 ^ 0x36363636; + puVar1[1] = puVar1[1] ^ 0x36363636; + puVar1 = __src; + } while (__src != Message_Digest); + Bl_SHA1Init((Bl_SHA1_CTX *)(pBuf + 0x50)); + Bl_SHA1Update((Bl_SHA1_CTX *)(pBuf + 0x50),(UINT8 *)&local_1c0,0x40); + iVar3 = 0; + while (iVar3 < textNum) { + puVar1 = (uint *)(pTextLen + iVar3); + ppuVar2 = ppText + iVar3; + iVar3 = iVar3 + 1; + Bl_SHA1Update((Bl_SHA1_CTX *)(pBuf + 0x50),*ppuVar2,*puVar1); + } + Bl_SHA1Final((Bl_SHA1_CTX *)(pBuf + 0x50),(UINT8 *)Message_Digest); + memset(&local_1c0,0,0x40); + memcpy(&local_1c0,key,key_len); + puVar1 = &local_1c0; + do { + __src = puVar1 + 2; + *puVar1 = *puVar1 ^ 0x5c5c5c5c; + puVar1[1] = puVar1[1] ^ 0x5c5c5c5c; + puVar1 = __src; + } while (__src != Message_Digest); + Bl_SHA1Init((Bl_SHA1_CTX *)(pBuf + 0x50)); + Bl_SHA1Update((Bl_SHA1_CTX *)(pBuf + 0x50),(UINT8 *)&local_1c0,0x40); + Bl_SHA1Update((Bl_SHA1_CTX *)(pBuf + 0x50),(UINT8 *)__src,0x14); + Bl_SHA1Final((Bl_SHA1_CTX *)(pBuf + 0x50),(UINT8 *)__src); + memcpy(output,__src,outputLen); + return; +} + + + +void Bl_PRF(uchar *key,int key_len,uchar *prefix,int prefix_len,uchar *data,int data_len, + uchar *output,int len) + +{ + char cVar1; + int iVar2; + int iVar3; + int iVar4; + int local_b0; + int total_len; + uchar *pText; + UINT8 prf_input [120]; + + total_len = (int)&pText; + memset(&pText,0,0x78); + if (prefix == (uchar *)0x0) { + memcpy(&pText,data,data_len); + local_b0 = data_len; + } + else { + memcpy(&pText,prefix,prefix_len); + local_b0 = prefix_len + 1 + data_len; + *(undefined *)((int)&pText + prefix_len) = 0; + memcpy((void *)((int)&pText + prefix_len + 1),data,data_len); + } + *(undefined *)((int)&pText + local_b0) = 0; + iVar4 = 0; + iVar3 = 0; + local_b0 = local_b0 + 1; + while( true ) { + iVar2 = (iVar3 * -0x14 + len) * 0x1000000; + cVar1 = (char)((uint)iVar2 >> 0x18); + if ((len + 0x13) / 0x14 <= iVar3) break; + if (0x14 < iVar2 >> 0x18) { + cVar1 = '\x14'; + } + Bl_hmac_sha1((uchar **)&total_len,&local_b0,1,key,key_len,output + iVar4,(int)cVar1); + iVar4 = iVar4 + (int)cVar1; + iVar3 = iVar3 + 1; + *(char *)((int)&total_len + local_b0 + 3) = *(char *)((int)&total_len + local_b0 + 3) + '\x01'; + } + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void set_psk(char *pSsid,UINT8 ssidLen,char *phrase) + +{ + char "set_psk" [8]; + size_t sVar1; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"set_psk"); + memset(&nohostParams,0xff,0x43); + sVar1 = strlen(phrase); + pmkCacheSetPassphrase((UINT8 *)pSsid,ssidLen,(UINT8 *)phrase,(UINT8)sVar1); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x230828a4); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void remove_psk(char *pSsid,UINT8 ssidLen) + +{ + char "remove_psk" [11]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"remove_psk"); + pmkCacheDeletePSK((UINT8 *)pSsid,ssidLen); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x2307fc84); + return; +} + + + +void wpa_MD5Transform(UINT32 *state,ulong *block) + +{ + ulong uVar1; + ulong uVar2; + ulong uVar3; + ulong uVar4; + ulong uVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint uVar9; + uint uVar10; + uint uVar11; + uint uVar12; + ulong uVar13; + ulong uVar14; + ulong uVar15; + ulong uVar16; + ulong uVar17; + ulong uVar18; + ulong uVar19; + uint uVar20; + uint uVar21; + ulong uVar22; + ulong uVar23; + ulong uVar24; + ulong uVar25; + + uVar19 = *block; + uVar20 = state[2]; + uVar21 = state[3]; + uVar12 = state[1]; + uVar5 = block[1]; + uVar8 = ((uVar20 ^ uVar21) & uVar12 ^ uVar21) + *state + uVar19 + 0xd76aa478; + uVar9 = (uVar8 >> 0x19 | uVar8 * 0x80) + uVar12; + uVar22 = block[2]; + uVar8 = ((uVar12 ^ uVar20) & uVar9 ^ uVar20) + uVar5 + 0xe8c7b756 + uVar21; + uVar6 = (uVar8 >> 0x14 | uVar8 * 0x1000) + uVar9; + uVar8 = ((uVar12 ^ uVar9) & uVar6 ^ uVar12) + uVar22 + 0x242070db + uVar20; + uVar14 = block[3]; + uVar8 = (uVar8 * 0x20000 | uVar8 >> 0xf) + uVar6; + uVar7 = ((uVar9 ^ uVar6) & uVar8 ^ uVar9) + uVar14 + 0xc1bdceee + uVar12; + uVar24 = block[4]; + uVar7 = (uVar7 * 0x400000 | uVar7 >> 10) + uVar8; + uVar9 = ((uVar6 ^ uVar8) & uVar7 ^ uVar6) + uVar24 + 0xf57c0faf + uVar9; + uVar16 = block[5]; + uVar9 = (uVar9 >> 0x19 | uVar9 * 0x80) + uVar7; + uVar6 = ((uVar8 ^ uVar7) & uVar9 ^ uVar8) + uVar16 + 0x4787c62a + uVar6; + uVar1 = block[6]; + uVar6 = (uVar6 >> 0x14 | uVar6 * 0x1000) + uVar9; + uVar8 = ((uVar7 ^ uVar9) & uVar6 ^ uVar7) + uVar1 + 0xa8304613 + uVar8; + uVar18 = block[7]; + uVar8 = (uVar8 * 0x20000 | uVar8 >> 0xf) + uVar6; + uVar7 = ((uVar9 ^ uVar6) & uVar8 ^ uVar9) + uVar18 + 0xfd469501 + uVar7; + uVar4 = block[8]; + uVar7 = (uVar7 * 0x400000 | uVar7 >> 10) + uVar8; + uVar9 = ((uVar6 ^ uVar8) & uVar7 ^ uVar6) + uVar4 + 0x698098d8 + uVar9; + uVar2 = block[9]; + uVar9 = (uVar9 >> 0x19 | uVar9 * 0x80) + uVar7; + uVar6 = ((uVar8 ^ uVar7) & uVar9 ^ uVar8) + uVar2 + 0x8b44f7af + uVar6; + uVar13 = block[10]; + uVar6 = (uVar6 >> 0x14 | uVar6 * 0x1000) + uVar9; + uVar8 = ((uVar7 ^ uVar9) & uVar6 ^ uVar7) + (uVar13 - 0xa44f) + uVar8; + uVar23 = block[0xb]; + uVar8 = (uVar8 * 0x20000 | uVar8 >> 0xf) + uVar6; + uVar7 = ((uVar9 ^ uVar6) & uVar8 ^ uVar9) + uVar23 + 0x895cd7be + uVar7; + uVar15 = block[0xc]; + uVar7 = (uVar7 * 0x400000 | uVar7 >> 10) + uVar8; + uVar9 = ((uVar6 ^ uVar8) & uVar7 ^ uVar6) + uVar15 + 0x6b901122 + uVar9; + uVar25 = block[0xd]; + uVar9 = (uVar9 >> 0x19 | uVar9 * 0x80) + uVar7; + uVar6 = ((uVar8 ^ uVar7) & uVar9 ^ uVar8) + uVar25 + 0xfd987193 + uVar6; + uVar17 = block[0xe]; + uVar6 = (uVar6 >> 0x14 | uVar6 * 0x1000) + uVar9; + uVar8 = ((uVar7 ^ uVar9) & uVar6 ^ uVar7) + uVar17 + 0xa679438e + uVar8; + uVar3 = block[0xf]; + uVar8 = (uVar8 * 0x20000 | uVar8 >> 0xf) + uVar6; + uVar7 = ((uVar9 ^ uVar6) & uVar8 ^ uVar9) + uVar3 + 0x49b40821 + uVar7; + uVar7 = (uVar7 * 0x400000 | uVar7 >> 10) + uVar8; + uVar9 = ((uVar8 ^ uVar7) & uVar6 ^ uVar8) + uVar5 + 0xf61e2562 + uVar9; + uVar9 = (uVar9 >> 0x1b | uVar9 * 0x20) + uVar7; + uVar6 = ((uVar7 ^ uVar9) & uVar8 ^ uVar7) + uVar1 + 0xc040b340 + uVar6; + uVar6 = (uVar6 >> 0x17 | uVar6 * 0x200) + uVar9; + uVar8 = ((uVar9 ^ uVar6) & uVar7 ^ uVar9) + uVar23 + 0x265e5a51 + uVar8; + uVar8 = (uVar8 >> 0x12 | uVar8 * 0x4000) + uVar6; + uVar7 = ((uVar6 ^ uVar8) & uVar9 ^ uVar6) + uVar19 + 0xe9b6c7aa + uVar7; + uVar7 = (uVar7 * 0x100000 | uVar7 >> 0xc) + uVar8; + uVar9 = ((uVar8 ^ uVar7) & uVar6 ^ uVar8) + uVar16 + 0xd62f105d + uVar9; + uVar9 = (uVar9 >> 0x1b | uVar9 * 0x20) + uVar7; + uVar6 = ((uVar7 ^ uVar9) & uVar8 ^ uVar7) + uVar13 + 0x2441453 + uVar6; + uVar6 = (uVar6 >> 0x17 | uVar6 * 0x200) + uVar9; + uVar8 = ((uVar9 ^ uVar6) & uVar7 ^ uVar9) + uVar3 + 0xd8a1e681 + uVar8; + uVar8 = (uVar8 >> 0x12 | uVar8 * 0x4000) + uVar6; + uVar7 = ((uVar6 ^ uVar8) & uVar9 ^ uVar6) + uVar24 + 0xe7d3fbc8 + uVar7; + uVar7 = (uVar7 * 0x100000 | uVar7 >> 0xc) + uVar8; + uVar9 = ((uVar8 ^ uVar7) & uVar6 ^ uVar8) + uVar2 + 0x21e1cde6 + uVar9; + uVar9 = (uVar9 >> 0x1b | uVar9 * 0x20) + uVar7; + uVar6 = ((uVar7 ^ uVar9) & uVar8 ^ uVar7) + uVar17 + 0xc33707d6 + uVar6; + uVar6 = (uVar6 >> 0x17 | uVar6 * 0x200) + uVar9; + uVar8 = ((uVar9 ^ uVar6) & uVar7 ^ uVar9) + uVar14 + 0xf4d50d87 + uVar8; + uVar8 = (uVar8 >> 0x12 | uVar8 * 0x4000) + uVar6; + uVar7 = ((uVar6 ^ uVar8) & uVar9 ^ uVar6) + uVar4 + 0x455a14ed + uVar7; + uVar7 = (uVar7 * 0x100000 | uVar7 >> 0xc) + uVar8; + uVar9 = ((uVar8 ^ uVar7) & uVar6 ^ uVar8) + uVar25 + 0xa9e3e905 + uVar9; + uVar9 = (uVar9 >> 0x1b | uVar9 * 0x20) + uVar7; + uVar6 = ((uVar7 ^ uVar9) & uVar8 ^ uVar7) + uVar22 + 0xfcefa3f8 + uVar6; + uVar6 = (uVar6 >> 0x17 | uVar6 * 0x200) + uVar9; + uVar8 = ((uVar9 ^ uVar6) & uVar7 ^ uVar9) + uVar8 + uVar18 + 0x676f02d9; + uVar8 = (uVar8 >> 0x12 | uVar8 * 0x4000) + uVar6; + uVar7 = (uVar9 & (uVar6 ^ uVar8) ^ uVar6) + uVar15 + 0x8d2a4c8a + uVar7; + uVar7 = (uVar7 * 0x100000 | uVar7 >> 0xc) + uVar8; + uVar9 = uVar9 + (uVar16 - 0x5c6be) + (uVar6 ^ uVar8 ^ uVar7); + uVar10 = (uVar9 >> 0x1c | uVar9 * 0x10) + uVar7; + uVar6 = (uVar8 ^ uVar7 ^ uVar10) + uVar4 + 0x8771f681 + uVar6; + uVar6 = (uVar6 >> 0x15 | uVar6 * 0x800) + uVar10; + uVar8 = (uVar7 ^ uVar10 ^ uVar6) + uVar23 + 0x6d9d6122 + uVar8; + uVar8 = (uVar8 >> 0x10 | uVar8 * 0x10000) + uVar6; + uVar7 = (uVar10 ^ uVar6 ^ uVar8) + uVar17 + 0xfde5380c + uVar7; + uVar9 = (uVar7 * 0x800000 | uVar7 >> 9) + uVar8; + uVar7 = (uVar6 ^ uVar8 ^ uVar9) + uVar5 + 0xa4beea44 + uVar10; + uVar10 = (uVar7 >> 0x1c | uVar7 * 0x10) + uVar9; + uVar6 = (uVar8 ^ uVar9 ^ uVar10) + uVar6 + uVar24 + 0x4bdecfa9; + uVar6 = (uVar6 >> 0x15 | uVar6 * 0x800) + uVar10; + uVar8 = (uVar9 ^ uVar10 ^ uVar6) + uVar8 + uVar18 + 0xf6bb4b60; + uVar7 = (uVar8 >> 0x10 | uVar8 * 0x10000) + uVar6; + uVar8 = (uVar10 ^ uVar6 ^ uVar7) + uVar13 + 0xbebfbc70 + uVar9; + uVar9 = (uVar8 * 0x800000 | uVar8 >> 9) + uVar7; + uVar8 = (uVar6 ^ uVar7 ^ uVar9) + uVar10 + uVar25 + 0x289b7ec6; + uVar8 = (uVar8 >> 0x1c | uVar8 * 0x10) + uVar9; + uVar6 = (uVar7 ^ uVar9 ^ uVar8) + uVar6 + uVar19 + 0xeaa127fa; + uVar10 = (uVar6 >> 0x15 | uVar6 * 0x800) + uVar8; + uVar6 = (uVar9 ^ uVar8 ^ uVar10) + uVar14 + 0xd4ef3085 + uVar7; + uVar7 = (uVar6 >> 0x10 | uVar6 * 0x10000) + uVar10; + uVar6 = (uVar8 ^ uVar10 ^ uVar7) + uVar9 + uVar1 + 0x4881d05; + uVar6 = (uVar6 * 0x800000 | uVar6 >> 9) + uVar7; + uVar8 = (uVar10 ^ uVar7 ^ uVar6) + uVar8 + uVar2 + 0xd9d4d039; + uVar9 = (uVar8 >> 0x1c | uVar8 * 0x10) + uVar6; + uVar8 = (uVar7 ^ uVar6 ^ uVar9) + uVar10 + uVar15 + 0xe6db99e5; + uVar8 = (uVar8 >> 0x15 | uVar8 * 0x800) + uVar9; + uVar7 = (uVar6 ^ uVar9 ^ uVar8) + uVar3 + 0x1fa27cf8 + uVar7; + uVar7 = (uVar7 >> 0x10 | uVar7 * 0x10000) + uVar8; + uVar6 = (uVar9 ^ uVar8 ^ uVar7) + uVar6 + uVar22 + 0xc4ac5665; + uVar10 = (uVar6 * 0x800000 | uVar6 >> 9) + uVar7; + uVar6 = ((~uVar8 | uVar10) ^ uVar7) + uVar19 + 0xf4292244 + uVar9; + uVar9 = (uVar6 >> 0x1a | uVar6 * 0x40) + uVar10; + uVar8 = ((~uVar7 | uVar9) ^ uVar10) + uVar18 + 0x432aff97 + uVar8; + uVar8 = (uVar8 >> 0x16 | uVar8 * 0x400) + uVar9; + uVar6 = ((~uVar10 | uVar8) ^ uVar9) + uVar17 + 0xab9423a7 + uVar7; + uVar7 = (uVar6 >> 0x11 | uVar6 * 0x8000) + uVar8; + uVar6 = ((~uVar9 | uVar7) ^ uVar8) + uVar10 + uVar16 + 0xfc93a039; + uVar6 = (uVar6 * 0x200000 | uVar6 >> 0xb) + uVar7; + uVar9 = ((~uVar8 | uVar6) ^ uVar7) + uVar9 + uVar15 + 0x655b59c3; + uVar11 = (uVar9 >> 0x1a | uVar9 * 0x40) + uVar6; + uVar8 = ((~uVar7 | uVar11) ^ uVar6) + uVar8 + uVar14 + 0x8f0ccc92; + uVar10 = (uVar8 >> 0x16 | uVar8 * 0x400) + uVar11; + uVar8 = ((~uVar6 | uVar10) ^ uVar11) + (uVar13 - 0x100b83) + uVar7; + uVar7 = (uVar8 >> 0x11 | uVar8 * 0x8000) + uVar10; + uVar8 = ((~uVar11 | uVar7) ^ uVar10) + uVar5 + 0x85845dd1 + uVar6; + uVar9 = (uVar8 * 0x200000 | uVar8 >> 0xb) + uVar7; + uVar8 = ((~uVar10 | uVar9) ^ uVar7) + uVar11 + uVar4 + 0x6fa87e4f; + uVar6 = (uVar8 >> 0x1a | uVar8 * 0x40) + uVar9; + uVar8 = ((~uVar7 | uVar6) ^ uVar9) + uVar10 + uVar3 + 0xfe2ce6e0; + uVar8 = (uVar8 >> 0x16 | uVar8 * 0x400) + uVar6; + uVar7 = ((~uVar9 | uVar8) ^ uVar6) + uVar7 + uVar1 + 0xa3014314; + uVar7 = (uVar7 >> 0x11 | uVar7 * 0x8000) + uVar8; + uVar9 = ((~uVar6 | uVar7) ^ uVar8) + uVar25 + 0x4e0811a1 + uVar9; + uVar9 = (uVar9 * 0x200000 | uVar9 >> 0xb) + uVar7; + uVar6 = ((~uVar8 | uVar9) ^ uVar7) + uVar6 + uVar24 + 0xf7537e82; + uVar11 = (uVar6 >> 0x1a | uVar6 * 0x40) + uVar9; + uVar8 = ((~uVar7 | uVar11) ^ uVar9) + uVar8 + uVar23 + 0xbd3af235; + uVar10 = (uVar8 >> 0x16 | uVar8 * 0x400) + uVar11; + uVar8 = ((~uVar9 | uVar10) ^ uVar11) + uVar7 + uVar22 + 0x2ad7d2bb; + uVar6 = (uVar8 >> 0x11 | uVar8 * 0x8000) + uVar10; + uVar8 = ((~uVar11 | uVar6) ^ uVar10) + uVar2 + 0xeb86d391 + uVar9; + *state = uVar11 + *state; + state[2] = uVar20 + uVar6; + state[3] = uVar21 + uVar10; + state[1] = uVar12 + uVar6 + (uVar8 * 0x200000 | uVar8 >> 0xb); + memset(block,0,0x40); + return; +} + + + +void wpa_MD5Init(Bl_MD5_CTX *context) + +{ + context->state[0] = 0x67452301; + context->state[1] = 0xefcdab89; + context->state[2] = 0x98badcfe; + context->count[1] = 0; + context->count[0] = 0; + context->state[3] = 0x10325476; + return; +} + + + +void wpa_MD5Update(Bl_MD5_CTX *context,UINT8 *input,UINT32 inputLen) + +{ + uint uVar1; + uint __n; + + uVar1 = context->count[0]; + __n = uVar1 + inputLen * 8; + context->count[0] = __n; + uVar1 = uVar1 >> 3 & 0x3f; + if (__n < inputLen * 8) { + context->count[1] = context->count[1] + 1; + } + context->count[1] = (inputLen >> 0x1d) + context->count[1]; + __n = 0x40 - uVar1; + if (inputLen < __n) { + __n = 0; + } + else { + memcpy(context->buffer + uVar1,input,__n); + wpa_MD5Transform((UINT32 *)context,(ulong *)context->buffer); + while (__n + 0x3f < inputLen) { + memcpy(context->scratch,input + __n,0x40); + wpa_MD5Transform((UINT32 *)context,context->scratch); + __n = __n + 0x40; + } + uVar1 = 0; + } + memcpy(context->buffer + uVar1,input + __n,inputLen - __n); + return; +} + + + +void wpa_MD5Final(uchar *digest,Bl_MD5_CTX *context) + +{ + uint uVar1; + int iVar2; + UINT8 aUStack24 [4]; + uchar bits [8]; + + memcpy(aUStack24,context->count,8); + uVar1 = context->count[0] >> 3 & 0x3f; + if (uVar1 < 0x38) { + iVar2 = 0x38; + } + else { + iVar2 = 0x78; + } + wpa_MD5Update(context,PADDING,iVar2 - uVar1); + wpa_MD5Update(context,aUStack24,8); + memcpy(digest,context,0x10); + memset(context,0,0x98); + return; +} + + + +int rijndaelKeySetupEnc(u32_conflict *rk,u8 *cipherKey,int keyBits) + +{ + uint uVar1; + uint uVar2; + u32_conflict *puVar3; + u32_conflict *puVar4; + + *rk = (uint)*cipherKey << 0x18 ^ (uint)cipherKey[1] << 0x10 ^ (uint)cipherKey[3] ^ + (uint)cipherKey[2] << 8; + rk[1] = (uint)cipherKey[4] << 0x18 ^ (uint)cipherKey[5] << 0x10 ^ (uint)cipherKey[7] ^ + (uint)cipherKey[6] << 8; + rk[2] = (uint)cipherKey[8] << 0x18 ^ (uint)cipherKey[9] << 0x10 ^ (uint)cipherKey[0xb] ^ + (uint)cipherKey[10] << 8; + rk[3] = (uint)cipherKey[0xc] << 0x18 ^ (uint)cipherKey[0xd] << 0x10 ^ (uint)cipherKey[0xf] ^ + (uint)cipherKey[0xe] << 8; + if (keyBits == 0x80) { + puVar3 = rcon; + puVar4 = rk + 0x24; + while( true ) { + uVar1 = *puVar3; + uVar2 = rk[3]; + puVar3 = puVar3 + 1; + uVar1 = *rk ^ uVar1 ^ (uint)Te4[uVar2 >> 0x18] ^ (uint)Te4[uVar2 & 0xff] << 8 ^ + (uint)Te4[uVar2 >> 0x10 & 0xff] << 0x18 ^ (uint)Te4[uVar2 >> 8 & 0xff] << 0x10; + rk[4] = uVar1; + uVar1 = uVar1 ^ rk[1]; + rk[5] = uVar1; + uVar1 = uVar1 ^ rk[2]; + rk[6] = uVar1; + rk[7] = uVar1 ^ uVar2; + if (rk == puVar4) break; + rk = rk + 4; + } + return 10; + } + return 0; +} + + + +void rijndael_set_key(rijndael_ctx *ctx,u8 *key,int bits,int encrypt) + +{ + int iVar1; + u32_conflict *rk; + int iVar2; + u32_conflict uVar3; + u32_conflict *puVar4; + uint uVar5; + int *piVar6; + + rk = ctx->key; + iVar2 = rijndaelKeySetupEnc(rk,key,bits); + ctx->Nr = iVar2; + if (encrypt == 0) { + ctx->decrypt = 1; + if (iVar2 == 0) { + iVar2 = rijndaelKeySetupEnc(rk,key,bits); + } + puVar4 = rk; + piVar6 = &ctx->decrypt + iVar2 * 4; + while (encrypt < iVar2 * 4 - encrypt) { + uVar3 = *puVar4; + encrypt = encrypt + 4; + *puVar4 = piVar6[2]; + piVar6[2] = uVar3; + uVar3 = puVar4[1]; + puVar4[1] = piVar6[3]; + piVar6[3] = uVar3; + uVar3 = puVar4[2]; + puVar4[2] = piVar6[4]; + piVar6[4] = uVar3; + uVar3 = puVar4[3]; + puVar4[3] = piVar6[5]; + piVar6[5] = uVar3; + puVar4 = puVar4 + 4; + piVar6 = piVar6 + -4; + } + iVar1 = 1; + while (iVar1 < iVar2) { + puVar4 = rk + 4; + uVar5 = *puVar4; + iVar1 = iVar1 + 1; + *puVar4 = Td2[Te4[uVar5 >> 8 & 0xff]] ^ + Td0[Te4[uVar5 >> 0x18]] ^ Td3[Te4[uVar5 & 0xff]] ^ Td1[Te4[uVar5 >> 0x10 & 0xff]]; + uVar5 = rk[5]; + rk[5] = Td2[Te4[uVar5 >> 8 & 0xff]] ^ + Td0[Te4[uVar5 >> 0x18]] ^ Td3[Te4[uVar5 & 0xff]] ^ Td1[Te4[uVar5 >> 0x10 & 0xff]]; + uVar5 = rk[6]; + rk[6] = Td2[Te4[uVar5 >> 8 & 0xff]] ^ + Td0[Te4[uVar5 >> 0x18]] ^ Td3[Te4[uVar5 & 0xff]] ^ Td1[Te4[uVar5 >> 0x10 & 0xff]]; + uVar5 = rk[7]; + rk[7] = Td2[Te4[uVar5 >> 8 & 0xff]] ^ + Td0[Te4[uVar5 >> 0x18]] ^ Td3[Te4[uVar5 & 0xff]] ^ Td1[Te4[uVar5 >> 0x10 & 0xff]]; + rk = puVar4; + } + } + else { + ctx->decrypt = 0; + } + return; +} + + + +void rijndael_decrypt(rijndael_ctx *ctx,u8 *src,u8 *dst) + +{ + byte bVar1; + byte bVar2; + byte bVar3; + u32_conflict *puVar4; + uint uVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint uVar9; + uint uVar10; + uint uVar11; + uint uVar12; + int iVar13; + uint uVar14; + int iVar15; + uint uVar16; + uint uVar17; + uint uVar18; + uint uVar19; + + uVar10 = (uint)*src << 0x18 ^ (uint)src[1] << 0x10 ^ (uint)src[3] ^ (uint)src[2] << 8 ^ + ctx->key[0]; + uVar16 = (uint)src[4] << 0x18 ^ (uint)src[5] << 0x10 ^ (uint)src[7] ^ (uint)src[6] << 8 ^ + ctx->key[1]; + uVar14 = (uint)src[8] << 0x18 ^ (uint)src[9] << 0x10 ^ (uint)src[0xb] ^ (uint)src[10] << 8 ^ + ctx->key[2]; + uVar11 = (uint)src[0xc] << 0x18 ^ (uint)src[0xd] << 0x10 ^ (uint)src[0xf] ^ (uint)src[0xe] << 8 ^ + ctx->key[3]; + iVar13 = ctx->Nr >> 1; + puVar4 = ctx->key; + iVar15 = iVar13; + while( true ) { + uVar5 = Td0[uVar10 >> 0x18] ^ Td3[uVar16 & 0xff] ^ puVar4[4] ^ + *(uint *)((int)Td1 + (uVar11 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Td2 + (uVar14 >> 6 & 0x3fc)); + iVar15 = iVar15 + -1; + uVar17 = uVar5 >> 0x10 & 0xff; + uVar6 = Td0[uVar16 >> 0x18] ^ Td3[uVar14 & 0xff] ^ puVar4[5] ^ + *(uint *)((int)Td1 + (uVar10 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Td2 + (uVar11 >> 6 & 0x3fc)); + uVar8 = Td0[uVar14 >> 0x18] ^ Td3[uVar11 & 0xff] ^ puVar4[6] ^ + *(uint *)((int)Td1 + (uVar16 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Td2 + (uVar10 >> 6 & 0x3fc)); + uVar12 = Td0[uVar11 >> 0x18] ^ Td3[uVar10 & 0xff] ^ puVar4[7] ^ + *(uint *)((int)Td1 + (uVar14 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Td2 + (uVar16 >> 6 & 0x3fc)); + uVar19 = uVar12 >> 0x10 & 0xff; + uVar18 = uVar8 >> 8 & 0xff; + uVar10 = puVar4[8]; + uVar16 = uVar12 >> 8 & 0xff; + uVar11 = uVar6 >> 0x10 & 0xff; + uVar14 = uVar5 >> 8 & 0xff; + uVar9 = uVar8 >> 0x10 & 0xff; + uVar7 = uVar6 >> 8 & 0xff; + if (iVar15 == 0) break; + uVar10 = Td0[uVar5 >> 0x18] ^ Td3[uVar6 & 0xff] ^ uVar10 ^ Td1[uVar19] ^ Td2[uVar18]; + uVar16 = Td0[uVar6 >> 0x18] ^ Td3[uVar8 & 0xff] ^ puVar4[9] ^ Td1[uVar17] ^ Td2[uVar16]; + uVar14 = Td0[uVar8 >> 0x18] ^ Td3[uVar12 & 0xff] ^ puVar4[10] ^ Td1[uVar11] ^ Td2[uVar14]; + uVar11 = Td0[uVar12 >> 0x18] ^ Td3[uVar5 & 0xff] ^ puVar4[0xb] ^ Td1[uVar9] ^ Td2[uVar7]; + puVar4 = puVar4 + 8; + } + puVar4 = ctx->key + iVar13 * 8; + uVar10 = (uint)Td4[uVar5 >> 0x18] << 0x18 ^ (uint)Td4[uVar19] << 0x10 ^ (uint)Td4[uVar6 & 0xff] ^ + (uint)Td4[uVar18] << 8 ^ uVar10; + *dst = (u8)(uVar10 >> 0x18); + dst[1] = (u8)(uVar10 >> 0x10); + dst[2] = (u8)(uVar10 >> 8); + bVar1 = Td4[uVar17]; + bVar2 = Td4[uVar6 >> 0x18]; + bVar3 = Td4[uVar8 & 0xff]; + dst[3] = (u8)uVar10; + uVar10 = (uint)bVar2 << 0x18 ^ (uint)bVar1 << 0x10 ^ (uint)bVar3 ^ (uint)Td4[uVar16] << 8 ^ + puVar4[1]; + dst[4] = (u8)(uVar10 >> 0x18); + dst[5] = (u8)(uVar10 >> 0x10); + dst[6] = (u8)(uVar10 >> 8); + dst[7] = (u8)uVar10; + bVar1 = Td4[uVar12 >> 0x18]; + uVar10 = (uint)Td4[uVar8 >> 0x18] << 0x18 ^ (uint)Td4[uVar11] << 0x10 ^ (uint)Td4[uVar12 & 0xff] ^ + (uint)Td4[uVar14] << 8 ^ puVar4[2]; + dst[8] = (u8)(uVar10 >> 0x18); + dst[9] = (u8)(uVar10 >> 0x10); + dst[0xb] = (u8)uVar10; + bVar2 = Td4[uVar9]; + dst[10] = (u8)(uVar10 >> 8); + uVar10 = (uint)bVar1 << 0x18 ^ (uint)bVar2 << 0x10 ^ (uint)Td4[uVar5 & 0xff] ^ + (uint)Td4[uVar7] << 8 ^ puVar4[3]; + dst[0xc] = (u8)(uVar10 >> 0x18); + dst[0xd] = (u8)(uVar10 >> 0x10); + dst[0xe] = (u8)(uVar10 >> 8); + dst[0xf] = (u8)uVar10; + return; +} + + + +void rijndael_encrypt(rijndael_ctx *ctx,u8 *src,u8 *dst) + +{ + byte bVar1; + byte bVar2; + byte bVar3; + u32_conflict *puVar4; + uint uVar5; + uint uVar6; + uint uVar7; + uint uVar8; + uint uVar9; + uint uVar10; + uint uVar11; + uint uVar12; + int iVar13; + uint uVar14; + int iVar15; + uint uVar16; + uint uVar17; + uint uVar18; + uint uVar19; + + uVar10 = (uint)*src << 0x18 ^ (uint)src[1] << 0x10 ^ (uint)src[3] ^ (uint)src[2] << 8 ^ + ctx->key[0]; + uVar16 = (uint)src[4] << 0x18 ^ (uint)src[5] << 0x10 ^ (uint)src[7] ^ (uint)src[6] << 8 ^ + ctx->key[1]; + uVar14 = (uint)src[8] << 0x18 ^ (uint)src[9] << 0x10 ^ (uint)src[0xb] ^ (uint)src[10] << 8 ^ + ctx->key[2]; + uVar11 = (uint)src[0xc] << 0x18 ^ (uint)src[0xd] << 0x10 ^ (uint)src[0xf] ^ (uint)src[0xe] << 8 ^ + ctx->key[3]; + iVar13 = ctx->Nr >> 1; + puVar4 = ctx->key; + iVar15 = iVar13; + while( true ) { + uVar8 = Te0[uVar10 >> 0x18] ^ Te3[uVar11 & 0xff] ^ puVar4[4] ^ + *(uint *)((int)Te1 + (uVar16 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Te2 + (uVar14 >> 6 & 0x3fc)); + iVar15 = iVar15 + -1; + uVar6 = Te0[uVar16 >> 0x18] ^ Te3[uVar10 & 0xff] ^ puVar4[5] ^ + *(uint *)((int)Te1 + (uVar14 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Te2 + (uVar11 >> 6 & 0x3fc)); + uVar5 = Te0[uVar14 >> 0x18] ^ Te3[uVar16 & 0xff] ^ puVar4[6] ^ + *(uint *)((int)Te1 + (uVar11 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Te2 + (uVar10 >> 6 & 0x3fc)); + uVar12 = Te0[uVar11 >> 0x18] ^ Te3[uVar14 & 0xff] ^ puVar4[7] ^ + *(uint *)((int)Te1 + (uVar10 >> 0xe & 0x3fc)) ^ + *(uint *)((int)Te2 + (uVar16 >> 6 & 0x3fc)); + uVar19 = uVar6 >> 0x10 & 0xff; + uVar18 = uVar5 >> 8 & 0xff; + uVar10 = puVar4[8]; + uVar17 = uVar5 >> 0x10 & 0xff; + uVar16 = uVar12 >> 8 & 0xff; + uVar11 = uVar12 >> 0x10 & 0xff; + uVar14 = uVar8 >> 8 & 0xff; + uVar9 = uVar8 >> 0x10 & 0xff; + uVar7 = uVar6 >> 8 & 0xff; + if (iVar15 == 0) break; + uVar10 = Te0[uVar8 >> 0x18] ^ Te3[uVar12 & 0xff] ^ uVar10 ^ Te1[uVar19] ^ Te2[uVar18]; + uVar16 = Te0[uVar6 >> 0x18] ^ Te3[uVar8 & 0xff] ^ puVar4[9] ^ Te1[uVar17] ^ Te2[uVar16]; + uVar14 = Te0[uVar5 >> 0x18] ^ Te3[uVar6 & 0xff] ^ puVar4[10] ^ Te1[uVar11] ^ Te2[uVar14]; + uVar11 = Te0[uVar12 >> 0x18] ^ Te3[uVar5 & 0xff] ^ puVar4[0xb] ^ Te1[uVar9] ^ Te2[uVar7]; + puVar4 = puVar4 + 8; + } + puVar4 = ctx->key + iVar13 * 8; + uVar10 = (uint)Te4[uVar8 >> 0x18] << 0x18 ^ (uint)Te4[uVar19] << 0x10 ^ (uint)Te4[uVar12 & 0xff] ^ + (uint)Te4[uVar18] << 8 ^ uVar10; + *dst = (u8)(uVar10 >> 0x18); + dst[1] = (u8)(uVar10 >> 0x10); + dst[2] = (u8)(uVar10 >> 8); + bVar1 = Te4[uVar17]; + bVar2 = Te4[uVar6 >> 0x18]; + bVar3 = Te4[uVar8 & 0xff]; + dst[3] = (u8)uVar10; + uVar10 = (uint)bVar2 << 0x18 ^ (uint)bVar1 << 0x10 ^ (uint)bVar3 ^ (uint)Te4[uVar16] << 8 ^ + puVar4[1]; + dst[4] = (u8)(uVar10 >> 0x18); + dst[5] = (u8)(uVar10 >> 0x10); + dst[6] = (u8)(uVar10 >> 8); + dst[7] = (u8)uVar10; + bVar1 = Te4[uVar12 >> 0x18]; + uVar10 = (uint)Te4[uVar5 >> 0x18] << 0x18 ^ (uint)Te4[uVar11] << 0x10 ^ (uint)Te4[uVar6 & 0xff] ^ + (uint)Te4[uVar14] << 8 ^ puVar4[2]; + dst[8] = (u8)(uVar10 >> 0x18); + dst[9] = (u8)(uVar10 >> 0x10); + dst[0xb] = (u8)uVar10; + bVar2 = Te4[uVar9]; + dst[10] = (u8)(uVar10 >> 8); + uVar10 = (uint)bVar1 << 0x18 ^ (uint)bVar2 << 0x10 ^ (uint)Te4[uVar5 & 0xff] ^ + (uint)Te4[uVar7] << 8 ^ puVar4[3]; + dst[0xc] = (u8)(uVar10 >> 0x18); + dst[0xd] = (u8)(uVar10 >> 0x10); + dst[0xe] = (u8)(uVar10 >> 8); + dst[0xf] = (u8)uVar10; + return; +} + + + +void Bl_SHA1ProcessMessageBlock(Bl_SHA1_CTX *context) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + UINT32 *pUVar4; + uint uVar5; + UINT32 *pUVar6; + UINT32 *pUVar7; + uint uVar8; + UINT32 UVar9; + uint uVar10; + uint uVar11; + UINT32 UVar12; + uint uVar13; + uint uVar14; + uint uVar15; + UINT32 UVar16; + + pUVar4 = context->Scratch; + pUVar6 = pUVar4; + do { + pUVar7 = pUVar6 + 1; + *pUVar6 = (uint)*(byte *)(pUVar6 + 0x10) << 0x18 | (uint)*(byte *)((int)pUVar6 + 0x41) << 0x10 | + (uint)*(byte *)((int)pUVar6 + 0x42) << 8 | (uint)*(byte *)((int)pUVar6 + 0x43); + pUVar6 = pUVar7; + } while ((UINT32 *)context->Message_Block != pUVar7); + uVar11 = 0; + uVar8 = context->Intermediate_Hash[2]; + uVar10 = context->Intermediate_Hash[0]; + UVar12 = context->Intermediate_Hash[1]; + uVar2 = context->Intermediate_Hash[3]; + UVar16 = context->Intermediate_Hash[4]; + do { + uVar13 = uVar2; + uVar3 = uVar10; + uVar2 = uVar8; + if ((uVar11 & 0x30) == 0) { + UVar9 = context->Scratch[uVar11]; + } + else { + uVar8 = pUVar4[uVar11 + 0xd & 0xf] ^ pUVar4[uVar11 + 8 & 0xf] ^ pUVar4[uVar11 & 0xf] ^ + pUVar4[uVar11 + 2 & 0xf]; + UVar9 = uVar8 >> 0x1f | uVar8 << 1; + pUVar4[uVar11 & 0xf] = UVar9; + } + uVar11 = uVar11 + 1; + uVar10 = UVar9 + ((uVar2 ^ uVar13) & UVar12 ^ uVar13) + + (uVar3 << 5 | uVar3 >> 0x1b) + 0x5a827999 + UVar16; + uVar8 = UVar12 << 0x1e | UVar12 >> 2; + UVar12 = uVar3; + UVar16 = uVar13; + } while (uVar11 != 0x14); + do { + uVar14 = uVar10; + uVar1 = uVar2; + uVar2 = uVar11 + 0xd; + uVar10 = uVar11 + 8; + uVar15 = uVar11 & 0xf; + uVar5 = uVar11 + 2; + uVar11 = uVar11 + 1; + uVar2 = pUVar4[uVar2 & 0xf] ^ pUVar4[uVar10 & 0xf] ^ pUVar4[uVar15] ^ pUVar4[uVar5 & 0xf]; + uVar2 = uVar2 >> 0x1f | uVar2 << 1; + pUVar4[uVar15] = uVar2; + uVar10 = (uVar3 ^ uVar8 ^ uVar1) + (uVar14 << 5 | uVar14 >> 0x1b) + 0x6ed9eba1 + uVar2 + uVar13; + uVar5 = uVar3 << 0x1e | uVar3 >> 2; + uVar2 = uVar8; + uVar3 = uVar14; + uVar8 = uVar5; + uVar13 = uVar1; + } while (uVar11 != 0x28); + do { + uVar8 = uVar10; + uVar13 = uVar11 + 0xd; + uVar10 = uVar11 + 8; + uVar15 = uVar11 & 0xf; + uVar3 = uVar11 + 2; + uVar11 = uVar11 + 1; + uVar10 = pUVar4[uVar13 & 0xf] ^ pUVar4[uVar10 & 0xf] ^ pUVar4[uVar15] ^ pUVar4[uVar3 & 0xf]; + uVar10 = uVar10 >> 0x1f | uVar10 << 1; + pUVar4[uVar15] = uVar10; + uVar10 = ((uVar5 | uVar2) & uVar14 | uVar5 & uVar2) + (uVar8 << 5 | uVar8 >> 0x1b) + 0x8f1bbcdc + + uVar10 + uVar1; + uVar13 = uVar14 << 0x1e | uVar14 >> 2; + uVar1 = uVar2; + uVar14 = uVar8; + uVar3 = uVar2; + uVar2 = uVar5; + uVar5 = uVar13; + } while (uVar11 != 0x3c); + do { + uVar15 = uVar13; + uVar5 = uVar2; + uVar1 = uVar10; + uVar10 = uVar11 + 0xd; + uVar13 = uVar11 + 8; + uVar2 = uVar11 & 0xf; + uVar14 = uVar11 + 2; + uVar11 = uVar11 + 1; + uVar10 = pUVar4[uVar10 & 0xf] ^ pUVar4[uVar13 & 0xf] ^ pUVar4[uVar2] ^ pUVar4[uVar14 & 0xf]; + uVar10 = uVar10 >> 0x1f | uVar10 << 1; + pUVar4[uVar2] = uVar10; + uVar10 = uVar10 + (uVar8 ^ uVar15 ^ uVar5) + (uVar1 << 5 | uVar1 >> 0x1b) + 0xca62c1d6 + uVar3; + uVar13 = uVar8 << 0x1e | uVar8 >> 2; + uVar8 = uVar1; + uVar3 = uVar5; + uVar2 = uVar15; + } while (uVar11 != 0x50); + context->Message_Block_Index = 0; + UVar12 = context->Intermediate_Hash[1]; + context->Intermediate_Hash[0] = uVar10 + context->Intermediate_Hash[0]; + context->Intermediate_Hash[1] = uVar1 + UVar12; + context->Intermediate_Hash[2] = uVar13 + context->Intermediate_Hash[2]; + context->Intermediate_Hash[3] = uVar15 + context->Intermediate_Hash[3]; + context->Intermediate_Hash[4] = uVar5 + context->Intermediate_Hash[4]; + return; +} + + + +int Bl_SHA1Init(Bl_SHA1_CTX *context) + +{ + if (context != (Bl_SHA1_CTX *)0x0) { + context->Intermediate_Hash[0] = 0x67452301; + context->Intermediate_Hash[1] = 0xefcdab89; + context->Intermediate_Hash[2] = 0x98badcfe; + context->Intermediate_Hash[3] = 0x10325476; + context->Length_Low = 0; + context->Length_High = 0; + context->Intermediate_Hash[4] = 0xc3d2e1f0; + *(undefined4 *)&context->Message_Block_Index = 0; + return 0; + } + return 1; +} + + + +int Bl_SHA1Final(Bl_SHA1_CTX *context,UINT8 *Message_Digest) + +{ + short sVar1; + ushort uVar2; + int iVar3; + uint uVar4; + UINT32 UVar5; + SINT16 *pSVar6; + + uVar4 = 1; + if (((context != (Bl_SHA1_CTX *)0x0) && (Message_Digest != (UINT8 *)0x0)) && + (uVar4 = (uint)context->Corrupted, context->Corrupted == 0)) { + if (context->Computed == '\0') { + iVar3 = (int)context->Message_Block_Index; + context->Message_Block_Index = (SINT16)((uint)((iVar3 + 1) * 0x10000) >> 0x10); + context->Message_Block[iVar3] = -0x80; + if (iVar3 < 0x38) { + while( true ) { + sVar1 = context->Message_Block_Index; + if (0x37 < (int)sVar1) break; + context->Message_Block_Index = sVar1 + 1; + context->Message_Block[(int)sVar1] = '\0'; + } + } + else { + while( true ) { + sVar1 = context->Message_Block_Index; + if (0x3f < (int)sVar1) break; + context->Message_Block_Index = sVar1 + 1; + context->Message_Block[(int)sVar1] = '\0'; + } + Bl_SHA1ProcessMessageBlock(context); + while( true ) { + sVar1 = context->Message_Block_Index; + if (0x37 < (int)sVar1) break; + context->Message_Block_Index = sVar1 + 1; + context->Message_Block[(int)sVar1] = '\0'; + } + } + UVar5 = context->Length_High; + *(ushort *)(context->Message_Block + 0x3a) = + *(ushort *)&context->Length_High << 8 | *(ushort *)&context->Length_High >> 8; + context->Message_Block[0x39] = (UINT8)(UVar5 >> 0x10); + uVar2 = *(ushort *)&context->Length_Low; + context->Message_Block[0x38] = (UINT8)(UVar5 >> 0x18); + UVar5 = context->Length_Low; + *(ushort *)(context->Message_Block + 0x3e) = uVar2 << 8 | uVar2 >> 8; + context->Message_Block[0x3d] = (UINT8)(UVar5 >> 0x10); + context->Message_Block[0x3c] = (UINT8)(UVar5 >> 0x18); + Bl_SHA1ProcessMessageBlock(context); + pSVar6 = (SINT16 *)context->Message_Block; + do { + *(UINT8 *)pSVar6 = '\0'; + pSVar6 = (SINT16 *)((int)pSVar6 + 1); + } while (&context->Message_Block_Index != pSVar6); + context->Length_Low = 0; + context->Length_High = 0; + context->Computed = '\x01'; + } + uVar4 = 0; + do { + Message_Digest[uVar4] = + (UINT8)(*(uint *)((int)context->Intermediate_Hash + (uVar4 & 0xfffffffc)) >> + ((~uVar4 & 3) << 3)); + uVar4 = uVar4 + 1; + } while (uVar4 != 0x14); + memset(context,0,0xa0); + return 0; + } + return uVar4; +} + + + +int Bl_SHA1Update(Bl_SHA1_CTX *context,UINT8 *message_array,uint length) + +{ + short sVar1; + UINT8 *pUVar2; + uint uVar3; + UINT32 UVar4; + int iVar5; + + if (length == 0) { + return 0; + } + uVar3 = 1; + if ((context != (Bl_SHA1_CTX *)0x0) && (message_array != (UINT8 *)0x0)) { + if (context->Computed == '\0') { + uVar3 = (uint)context->Corrupted; + if (context->Corrupted == 0) { + pUVar2 = message_array + length; + while ((message_array != pUVar2 && (context->Corrupted == '\0'))) { + sVar1 = context->Message_Block_Index; + iVar5 = ((int)sVar1 + 1) * 0x10000; + context->Message_Block_Index = (SINT16)((uint)iVar5 >> 0x10); + context->Message_Block[(int)sVar1] = *message_array; + UVar4 = context->Length_Low + 8; + context->Length_Low = UVar4; + if ((UVar4 == 0) && + (UVar4 = context->Length_High + 1, context->Length_High = UVar4, UVar4 == 0)) { + context->Corrupted = '\x01'; + } + if (iVar5 >> 0x10 == 0x40) { + Bl_SHA1ProcessMessageBlock(context); + } + message_array = message_array + 1; + } + uVar3 = 0; + } + } + else { + context->Corrupted = '\x03'; + uVar3 = 3; + } + } + return uVar3; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +Status_e supplicantRestoreDefaults(void) + +{ + char "supplicantRestoreDefaults" [26]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantRestoreDefaults"); + pmkCacheInit(); + pmkCacheRomInit(); + dbg_test_print("%dms : Leave: %s\n",_DAT_44b00120 / 1000,0x23081ef8); + return FW_SUCCESS; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void supplicantFuncInit(void) + +{ + char "supplicantFuncInit" [19]; + + dbg_test_print("%dms : Enter: %s\n",_DAT_44b00120 / 1000,"supplicantFuncInit"); + supplicantRestoreDefaults(); + dbg_test_print("%dms : Leave: %s\n",0x23081f14); + return; +} + + + +void ap_setpsk(cm_ConnectionInfo_t *connPtr,CHAR *ssid,CHAR *passphrase) + +{ + apInfo_t *paVar1; + size_t sVar2; + + paVar1 = cm_GetApInfo(connPtr); + if (paVar1 != (apInfo_t *)0x0) { + sVar2 = strlen(ssid); + (paVar1->bssConfig).comData.SsIdLen = (IEEEtypes_Len_t)sVar2; + memcpy(&(paVar1->bssConfig).comData,ssid,0x20); + sVar2 = strlen(passphrase); + (paVar1->bssConfig).RsnConfig.PSKPassPhraseLen = (UINT8)sVar2; + memcpy((paVar1->bssConfig).RsnConfig.PSKPassPhrase,passphrase,0x40); + return; + } + return; +} + + + +void ap_resetConfiguration(cm_ConnectionInfo_t *connPtr) + +{ + ushort uVar1; + apInfo_t *paVar2; + apSpecificData_t *paVar3; + size_t sVar4; + + paVar2 = cm_GetApInfo(connPtr); + paVar3 = cm_GetApData(connPtr); + if ((paVar2 != (apInfo_t *)0x0) && (paVar3 != (apSpecificData_t *)0x0)) { + sVar4 = strlen("Marvell Micro AP"); + (paVar2->bssConfig).comData.SsIdLen = (IEEEtypes_Len_t)sVar4; + memcpy(&(paVar2->bssConfig).comData,"Marvell Micro AP",0x20); + (paVar2->bssData).updatePassPhrase = 1; + memset(&(paVar2->bssConfig).RsnConfig,0,0x7c); + uVar1 = *(ushort *)&(paVar2->bssConfig).RsnConfig; + (paVar2->bssConfig).RsnConfig.AuthKeyCount = 1; + *(ushort *)&(paVar2->bssConfig).RsnConfig = uVar1 & 0xf7 | 0x108; + *(ushort *)&(paVar2->bssConfig).RsnConfig.wpa2UcstCipher = + *(ushort *)&(paVar2->bssConfig).RsnConfig.wpa2UcstCipher & 0xf7 | 0x108; + (paVar2->bssConfig).RsnConfig.MaxPwsHskRetries = '\x03'; + (paVar2->bssConfig).RsnConfig.MaxGrpHskRetries = '\x03'; + (paVar2->bssConfig).RsnConfig.PwsHskTimeOut = 100; + (paVar2->bssConfig).RsnConfig.GrpHskTimeOut = 100; + (paVar2->bssConfig).RsnConfig.GrpReKeyTime = 0x15180; + } + return; +} + + + +void InitializeAp(cm_ConnectionInfo_t *connPtr) + +{ + ushort uVar1; + apInfo_t *paVar2; + apSpecificData_t *paVar3; + size_t sVar4; + + paVar2 = cm_GetApInfo(connPtr); + paVar3 = cm_GetApData(connPtr); + if ((paVar2 != (apInfo_t *)0x0) && (paVar3 != (apSpecificData_t *)0x0)) { + sVar4 = strlen("Marvell Micro AP"); + (paVar2->bssConfig).comData.SsIdLen = (IEEEtypes_Len_t)sVar4; + memcpy(&(paVar2->bssConfig).comData,"Marvell Micro AP",0x20); + (paVar2->bssData).updatePassPhrase = 1; + memset(&(paVar2->bssConfig).RsnConfig,0,0x7c); + uVar1 = *(ushort *)&(paVar2->bssConfig).RsnConfig; + (paVar2->bssConfig).RsnConfig.AuthKeyCount = 1; + *(ushort *)&(paVar2->bssConfig).RsnConfig = uVar1 & 0xf7 | 0x108; + *(ushort *)&(paVar2->bssConfig).RsnConfig.wpa2UcstCipher = + *(ushort *)&(paVar2->bssConfig).RsnConfig.wpa2UcstCipher & 0xf7 | 0x108; + (paVar2->bssConfig).RsnConfig.MaxPwsHskRetries = '\x03'; + (paVar2->bssConfig).RsnConfig.MaxGrpHskRetries = '\x03'; + (paVar2->bssConfig).RsnConfig.PwsHskTimeOut = 100; + (paVar2->bssConfig).RsnConfig.GrpHskTimeOut = 100; + (paVar2->bssConfig).RsnConfig.GrpReKeyTime = 0x15180; + } + return; +} + + + +void rf_set_channel(uint8_t bandwidth,uint16_t channel_freq) + +{ + undefined2 in_register_0000202e; + + rfc_config_channel(CONCAT22(in_register_0000202e,channel_freq)); + return; +} + + + +void rf_dump_status(void) + +{ + return; +} + + + +int bt_hcionchip_recv(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id) + +{ + uint8_t uVar1; + + switch((uint)msgid - 0x801 & 0xffff) { + case 0: + uVar1 = '\x02'; + break; + case 1: + uVar1 = '\x03'; + break; + case 2: + uVar1 = '\x05'; + break; + case 3: + uVar1 = '\x04'; + break; + default: + return 0; + case 5: + uVar1 = '\x01'; + } + (*hci_rx_cb)(uVar1,src_id,(uint8_t *)param,*(uint8_t *)((int)param + -2),(void *)0x0); + return 0; +} + + + +uint8_t bt_onchiphci_interface_init(bt_hci_recv_cb *cb) + +{ + uint8_t uVar1; + + hci_rx_cb = cb; + uVar1 = ble_ke_task_create('\x04',&TASK_DESC_HCI_ONCHIP); + return uVar1; +} + + +/* +Unable to decompile 'bt_onchiphci_send' +Cause: Exception while decompiling 230674a4: Decompiler process died + +*/ + + +uint bt_onchiphci_hanlde_rx_acl(int param_1,void *param_2) + +{ + uint uVar1; + uint8_t *puVar2; + + puVar2 = hci_build_acl_rx_data((ke_msg *)(param_1 + -0xc)); + uVar1 = (uint)puVar2[2] + 4 & 0xff; + (*ble_memcpy_ptr)(param_2,puVar2,uVar1); + em_buf_rx_free(*(uint8_t *)(param_1 + 6)); + return uVar1; +} + + + +int bl_mtd_open(char *name,bl_mtd_handle_t *handle,uint flags) + +{ + char *__dest; + int iVar1; + uint32_t uStack40; + uint32_t addr; + uint32_t size; + + uStack40 = 0; + addr = 0; + __dest = (char *)pvPortMalloc(0x20); + if (__dest == (char *)0x0) { + iVar1 = -1; + } + else { + memset(__dest,0,0x20); + strncpy(__dest,name,0x10); + if ((flags & 1) == 0) { + if ((flags & 2) == 0) { + *(undefined4 *)(__dest + 0x1c) = 0; + } + else { + iVar1 = hal_boot2_partition_bus_addr_active(name,&uStack40,&addr); + if ((iVar1 != 0) || (uStack40 == 0)) { + printf("[MTD] [PART] [XIP] error when get %s partition %d\r\n",name,iVar1); + printf("[MTD] [PART] [XIP] Dead Loop. Reason: no Valid %s partition found\r\n",name); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + *(uint32_t *)(__dest + 0x1c) = uStack40; + } + iVar1 = hal_boot2_partition_addr_active(name,&uStack40,&addr); + if ((iVar1 != 0) || (uStack40 == 0)) { + printf("[MTD] [PART] [XIP] error when get %s partition %d\r\n",name,iVar1); + printf("[MTD] [PART] [XIP] Dead Loop. Reason: no Valid %s partition found\r\n",name); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + } + else { + if ((flags & 2) == 0) { + *(undefined4 *)(__dest + 0x1c) = 0; + } + else { + iVar1 = hal_boot2_partition_bus_addr_inactive(name,&uStack40,&addr); + if ((iVar1 != 0) || (uStack40 == 0)) { + printf("[MTD] [PART] [XIP] error when get %s partition %d\r\n",name,iVar1); + printf("[MTD] [PART] [XIP] Dead Loop. Reason: no Valid %s partition found\r\n",name); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + *(uint32_t *)(__dest + 0x1c) = uStack40; + } + iVar1 = hal_boot2_partition_addr_inactive(name,&uStack40,&addr); + if ((iVar1 != 0) || (uStack40 == 0)) { + printf("[MTD] [PART] [XIP] error when get %s partition %d\r\n",name,iVar1); + printf("[MTD] [PART] [XIP] Dead Loop. Reason: no Valid %s partition found\r\n",name); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + } + *(uint32_t *)(__dest + 0x14) = uStack40; + *(uint32_t *)(__dest + 0x18) = addr; + puts("[MTD] >>>>>> Hanlde info Dump >>>>>>\r\n"); + printf(" name %s\r\n",__dest); + printf(" id %d\r\n",*(undefined4 *)(__dest + 0x10)); + printf(" offset %p(%u)\r\n",*(undefined4 *)(__dest + 0x14)); + printf(" size %p(%uKbytes)\r\n",*(uint *)(__dest + 0x18),*(uint *)(__dest + 0x18) >> 10); + printf(" xip_addr %p\r\n",*(undefined4 *)(__dest + 0x1c)); + puts("[MTD] <<<<<< Hanlde info End <<<<<<\r\n"); + iVar1 = 0; + *(char **)handle = __dest; + } + return iVar1; +} + + + +int bl_mtd_info(bl_mtd_handle_t handle,bl_mtd_info_t *info) + +{ + strcpy((char *)info,(char *)handle); + info->offset = *(uint *)((int)handle + 0x14); + info->size = *(uint *)((int)handle + 0x18); + info->xip_addr = *(void **)((int)handle + 0x1c); + return 0; +} + + + +int bl_mtd_erase(bl_mtd_handle_t handle,uint addr,uint size) + +{ + bl_flash_erase(*(int *)((int)handle + 0x14) + addr,size); + return 0; +} + + + +int bl_mtd_write(bl_mtd_handle_t handle,uint addr,uint size,uint8_t *data) + +{ + uint32_t addr_00; + int iVar1; + TickType_t TVar2; + uint __n; + uint8_t auStack96 [4]; + uint8_t buf_tmp [64]; + + addr_00 = *(int *)((int)handle + 0x14) + addr; + iVar1 = bl_sys_isxipaddr((uint32_t)data); + if (iVar1 == 0) { + bl_flash_write(addr_00,data,size); + } + else { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] addr@%p is xip flash, size %d\r\n",TVar2,&DAT_230781b4,"bl_mtd.c", + 0xc9,data,size); + while (size != 0) { + __n = size; + if (0x40 < size) { + __n = 0x40; + } + memcpy(auStack96,data,__n); + bl_flash_write(addr_00,auStack96,__n); + addr_00 = addr_00 + __n; + data = data + __n; + size = size - __n; + } + } + return 0; +} + + + +int bl_mtd_read(bl_mtd_handle_t handle,uint addr,uint size,uint8_t *data) + +{ + bl_flash_read(*(int *)((int)handle + 0x14) + addr,data,size); + return 0; +} + + + +int bloop_init(loop_ctx *loop) + +{ + loop_evt_handler_statistic *list; + loop_evt_handler_statistic *plVar1; + + memset(loop,0,0x4a0); + list = (loop_evt_handler_statistic *)loop->list; + do { + plVar1 = (loop_evt_handler_statistic *)&list->time_accumulated; + utils_list_init((utils_list *)list); + list = plVar1; + } while (plVar1 != loop->statistic); + *(utils_dlist_t **)&(loop->timer_dlist).next = &loop->timer_dlist; + *(utils_dlist_t **)&(loop->timer_dlist).prev = &loop->timer_dlist; + *(utils_dlist_t **)&(loop->timer_dued).next = &loop->timer_dued; + *(utils_dlist_t **)&(loop->timer_dued).prev = &loop->timer_dued; + printf("=== %d task inited\r\n",0x20); + return 0; +} + + + +int bloop_handler_register(loop_ctx *loop,loop_evt_handler *handler,int priority) + +{ + if (((uint)priority < 0x20) && ((&loop->looper + priority)[0x104] == (TaskHandle_t)0x0)) { + *(loop_evt_handler **)(&loop->looper + priority + 0x104) = handler; + return 0; + } + return -1; +} + + + +void bloop_timer_init(loop_timer *timer,int use_auto_free) + +{ + memset(timer,0,0x24); + *(loop_timer **)&(timer->dlist_item).prev = timer; + *(loop_timer **)&(timer->dlist_item).next = timer; + timer->flags = (use_auto_free != 0) << 1; + return; +} + + + +void bloop_timer_configure + (loop_timer *timer,uint delay_ms, + anon_subr_void_loop_ctx_ptr_loop_timer_ptr_void_ptr *cb,void *arg,int idx_task, + uint32_t evt_type_map) + +{ + TickType_t TVar1; + + TVar1 = xTaskGetTickCount(); + timer->time_added = TVar1; + timer->time_target = TVar1 + delay_ms; + *(anon_subr_void_loop_ctx_ptr_loop_timer_ptr_void_ptr **)&timer->cb = cb; + timer->arg = arg; + timer->idx_task = idx_task; + timer->evt_type_map = evt_type_map; + return; +} + + + +void bloop_timer_repeat_enable(loop_timer *timer) + +{ + timer->flags = timer->flags | 1; + return; +} + + + +void bloop_timer_repeat_reconfigure(loop_timer *timer) + +{ + uint uVar1; + uint uVar2; + TickType_t TVar3; + + uVar1 = timer->time_target; + uVar2 = timer->time_added; + TVar3 = xTaskGetTickCount(); + timer->time_target = (uVar1 - uVar2) + TVar3; + timer->time_added = TVar3; + return; +} + + + +void bloop_timer_register(loop_ctx *loop,loop_timer *timer) + +{ + utils_dlist_s *puVar1; + utils_dlist_s *puVar2; + utils_dlist_s *puVar3; + utils_dlist_s *puVar4; + utils_dlist_s *puVar5; + + puVar2 = (loop->timer_dlist).next; + puVar3 = (utils_dlist_s *)&loop->timer_dlist; + if (puVar3 == puVar2) { + (timer->dlist_item).next = puVar3; + (timer->dlist_item).prev = puVar3; + *(loop_timer **)&(loop->timer_dlist).next = timer; + *(loop_timer **)&(loop->timer_dlist).prev = timer; + return; + } + puVar1 = puVar2; + puVar5 = (utils_dlist_s *)0x0; + do { + puVar4 = puVar1; + if (puVar3 == puVar4) { +LAB_23067a0a: + puVar2 = puVar5->next; + (timer->dlist_item).prev = puVar5; + (timer->dlist_item).next = puVar2; + *(loop_timer **)&puVar5->next = timer; + *(loop_timer **)&puVar2->prev = timer; + return; + } + if ((int)(timer->time_target - (int)puVar4[2].prev) < 1) { + if (puVar5 == (utils_dlist_s *)0x0) { + (timer->dlist_item).next = puVar2; + (timer->dlist_item).prev = puVar3; + *(loop_timer **)&(loop->timer_dlist).next = timer; + *(loop_timer **)&puVar2->prev = timer; + return; + } + goto LAB_23067a0a; + } + puVar1 = puVar4->next; + puVar5 = puVar4; + } while( true ); +} + + + +void bloop_wait_startup(loop_ctx *loop) + +{ + while (loop->looper == (TaskHandle_t)0x0) { + vTaskDelay(1); + } + return; +} + + + +void bloop_evt_set_async(loop_ctx *loop,uint evt,uint32_t evt_map) + +{ + if (0x1f < evt) { + printf("[ASSERT] [ERR] %s:%d\r\n","bloop_base.c",0x15a); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + vTaskEnterCritical(); + loop->bitmap_evt_async = loop->bitmap_evt_async | 1 << (evt & 0x1f); + (&loop->looper + evt)[4] = (TaskHandle_t)((uint)(&loop->looper + evt)[4] | evt_map); + vTaskExitCritical(); + xTaskGenericNotify(loop->looper,0,eIncrement,(uint32_t *)0x0); + return; +} + + + +void bloop_evt_set_sync(loop_ctx *loop,uint evt,uint32_t evt_map) + +{ + if (0x1f < evt) { + printf("[ASSERT] [ERR] %s:%d\r\n","bloop_base.c",0x177); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + loop->bitmap_evt_sync = loop->bitmap_evt_sync | 1 << (evt & 0x1f); + (&loop->looper + evt)[4] = (TaskHandle_t)((uint)(&loop->looper + evt)[4] | evt_map); + return; +} + + + +void bloop_evt_unset_sync(loop_ctx *loop,uint evt) + +{ + if (0x1f < evt) { + printf("[ASSERT] [ERR] %s:%d\r\n","bloop_base.c",0x17f); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + loop->bitmap_evt_sync = ~(1 << (evt & 0x1f)) & loop->bitmap_evt_sync; + return; +} + + + +void bloop_run(loop_ctx *param_1) + +{ + loop_timer *plVar1; + utils_dlist_t *puVar2; + loop_timer *timer; + TaskHandle_t ptVar3; + TickType_t TVar4; + uint32_t uVar5; + uint32_t uVar6; + int iVar7; + int iVar8; + utils_list_hdr *puVar9; + utils_dlist_s *xTicksToWait; + uint evt; + TaskHandle_t ptVar10; + utils_dlist_s *puVar11; + utils_dlist_s *puVar12; + TaskHandle_t *pptVar13; + loop_timer *plVar14; + utils_dlist_t *puVar15; + + ptVar3 = xTaskGetCurrentTaskHandle(); + param_1->looper = ptVar3; +LAB_23067b3e: + do { + puVar15 = ¶m_1->timer_dlist; + while( true ) { + vTaskEnterCritical(); + evt = param_1->bitmap_evt_async; + param_1->bitmap_evt_async = 0; + param_1->bitmap_evt_sync = param_1->bitmap_evt_sync | evt; + vTaskExitCritical(); + if (param_1->bitmap_evt_sync != 0) break; + puVar2 = (utils_dlist_t *)(param_1->timer_dlist).next; + xTicksToWait = (utils_dlist_s *)0xffffffff; + if (puVar2 != puVar15) { + xTicksToWait = puVar2[2].prev; + TVar4 = xTaskGetTickCount(); + xTicksToWait = (utils_dlist_s *)((int)xTicksToWait - TVar4); + if ((int)xTicksToWait < 1) break; + } + ulTaskNotifyTake(1,(TickType_t)xTicksToWait); + } + if ((utils_dlist_t *)(param_1->timer_dlist).next != puVar15) { + TVar4 = xTaskGetTickCount(); + puVar2 = (utils_dlist_t *)(param_1->timer_dlist).next; + xTicksToWait = (utils_dlist_s *)0x0; + if (puVar2 != (utils_dlist_t *)0x0) { + xTicksToWait = (&puVar2->prev)[1]; + } + while ((puVar11 = xTicksToWait, puVar2 != puVar15 && (-1 < (int)(TVar4 - (int)puVar2[2].prev)) + )) { + bloop_evt_set_sync(param_1,(uint)puVar2[2].next,(uint32_t)puVar2[3].prev); + if (puVar2[3].next != (utils_dlist_s *)0x0) { + (*(code *)puVar2[3].next)(param_1,puVar2,puVar2[4].prev); + } + puVar12 = (&puVar2->prev)[1]; + xTicksToWait = puVar2->prev; + xTicksToWait->next = puVar12; + puVar12->prev = xTicksToWait; + xTicksToWait = (param_1->timer_dued).next; + *(loop_timer **)&puVar2->prev = (loop_timer *)¶m_1->timer_dued; + (&puVar2->prev)[1] = xTicksToWait; + *(utils_dlist_t **)&(param_1->timer_dued).next = puVar2; + *(utils_dlist_t **)&xTicksToWait->prev = puVar2; + puVar2 = (utils_dlist_t *)puVar11; + xTicksToWait = (utils_dlist_s *)0x0; + if (puVar11 != (utils_dlist_s *)0x0) { + xTicksToWait = (&puVar11->prev)[1]; + } + } + timer = (loop_timer *)(param_1->timer_dued).next; + plVar1 = (loop_timer *)0x0; + if (timer != (loop_timer *)0x0) { + plVar1 = (loop_timer *)(timer->dlist_item).next; + } + while (plVar14 = plVar1, timer != (loop_timer *)¶m_1->timer_dued) { + xTicksToWait = (timer->dlist_item).prev; + puVar11 = (timer->dlist_item).next; + xTicksToWait->next = puVar11; + puVar11->prev = xTicksToWait; + if ((timer->flags & 2) == 0) { + if ((timer->flags & 1) != 0) { + if ((_fsymc_level_bloop < BLOG_LEVEL_INFO) && + (_fsymf_level_bloopbloop_base < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar4 = xTaskGetTickCount(); + } + else { + TVar4 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Repeat timer\r\n",TVar4,"DEBUG ","bloop_base.c",0xbb); + } + bloop_timer_repeat_reconfigure(timer); + bloop_timer_register(param_1,timer); + } + } + else { + if ((_fsymc_level_bloop < BLOG_LEVEL_INFO) && + (_fsymf_level_bloopbloop_base < BLOG_LEVEL_INFO)) { + if (TrapNetCounter == 0) { + TVar4 = xTaskGetTickCount(); + } + else { + TVar4 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] Free now\r\n",TVar4,"DEBUG ","bloop_base.c",0xb8); + } + vPortFree(timer); + } + timer = plVar14; + plVar1 = (loop_timer *)0x0; + if (plVar14 != (loop_timer *)0x0) { + plVar1 = (loop_timer *)(plVar14->dlist_item).next; + } + } + } + iVar7 = __clzsi2(param_1->bitmap_evt_sync); + iVar8 = __clzsi2(param_1->bitmap_msg); + if (iVar7 <= iVar8) { + evt = -iVar7 + 0x1f; + if (evt != 0xffffffff) { + pptVar13 = ¶m_1->looper + evt; + ptVar3 = pptVar13[0x104]; + if (ptVar3 == (TaskHandle_t)0x0) { + printf("[ASSERT] [ERR] %s:%d\r\n","bloop_base.c",0x105); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + vTaskEnterCritical(); + ptVar10 = pptVar13[4]; + pptVar13[4] = (TaskHandle_t)0x0; + pptVar13[0x24] = (TaskHandle_t)((uint)pptVar13[0x24] | (uint)ptVar10); + vTaskExitCritical(); + uVar5 = bl_timer_now_us(); + (*(code *)(ptVar3->xStateListItem).xItemValue) + (param_1,(loop_evt_handler *)ptVar3,¶m_1->bitmap_evt_sync, + (uint32_t *)(¶m_1->looper + -iVar7 + 0x43)); + uVar6 = bl_timer_now_us(); + pptVar13 = ¶m_1->looper + evt * 4; + ptVar3 = (TaskHandle_t)(uVar6 - uVar5); + pptVar13[0x85] = ptVar3; + pptVar13[0x86] = (TaskHandle_t)((int)pptVar13[0x86] + (int)ptVar3); + if (pptVar13[0x84] < ptVar3) { + pptVar13[0x84] = ptVar3; + } + pptVar13[0x87] = (TaskHandle_t)((int)&pptVar13[0x87]->pxTopOfStack + 1); + bloop_evt_unset_sync(param_1,evt); + goto LAB_23067b3e; + } + } + if ((-iVar8 != -0x20) && + (puVar9 = utils_list_pop_front((utils_list *)(¶m_1->looper + (-iVar8 + 0x41) * 2)), + puVar9 == (utils_list_hdr *)0x0)) { + printf("[ASSERT] [ERR] %s:%d\r\n","bloop_base.c",0x124); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + } while( true ); +} + + + +int bloop_status_dump(loop_ctx *loop) + +{ + loop_evt_handler_statistic *plVar1; + utils_dlist_s *puVar2; + uint32_t *puVar3; + TickType_t TVar4; + char *pcVar5; + uint32_t uVar6; + int iVar7; + uint32_t uVar8; + uint32_t uVar9; + + puts("====== bloop dump ======\r\n"); + printf(" bitmap_evt %lx\r\n",loop->bitmap_evt_sync); + printf(" bitmap_msg %lx\r\n",loop->bitmap_msg); + TVar4 = xTaskGetTickCount(); + puts("--->>> timer list:\r\n"); + puVar2 = (loop->timer_dlist).next; + iVar7 = 0; + while ((utils_dlist_s *)&loop->timer_dlist != puVar2) { + printf(" timer[%02d]: %u(diff %d)ms, \t\t task idx %02d, evt map %08lx, ptr %p\r\n",iVar7, + puVar2[2].prev,TVar4 - (int)puVar2[2].prev,puVar2[2].next,puVar2[3].prev,puVar2[3].next); + iVar7 = iVar7 + 1; + puVar2 = puVar2->next; + } + puVar3 = loop->evt_type_map_async + 0x1f; + printf(" %d task:\r\n",0x20); + plVar1 = loop->statistic + 0x1f; + iVar7 = 0x1f; + do { + pcVar5 = "empty"; + if ((char **)puVar3[0x100] != (char **)0x0) { + pcVar5 = *(char **)puVar3[0x100]; + } + printf(" task[%02d] : %s\r\n",iVar7,pcVar5); + uVar8 = puVar3[0x100]; + if (uVar8 != 0) { + uVar6 = puVar3[0x20]; + uVar9 = *puVar3; + printf(" evt handler %p,",*(undefined4 *)(uVar8 + 4)); + printf(" msg handler %p,",*(undefined4 *)(uVar8 + 8)); + printf(" trigged cnt %u,",plVar1->count_triggered); + printf(" bitmap async %lx sync %lx,",uVar9,uVar6); + printf(" time consumed %dus acc %dms, max %uus\r\n",plVar1->time_consumed, + plVar1->time_accumulated / 1000,plVar1->time_max); + } + iVar7 = iVar7 + -1; + puVar3 = puVar3 + -1; + plVar1 = plVar1 + -1; + } while (iVar7 != -1); + return 0; +} + + + +int loop_evt_entity_sys_handler(loop_ctx *loop,loop_evt_handler *handler,loop_msg *msg) + +{ + printf( + "[SYS] [MSG] called with msg info\r\n priority %u\r\n dst %u\r\n msgid %u\r\n src %u\r\n arg1 %p\r\n arg2 %p\r\n" + ,(uint)*(byte *)&msg->u,(uint)*(byte *)((int)&msg->u + 1),(uint)*(byte *)((int)&msg->u + 2) + ,(uint)*(byte *)((int)&msg->u + 3),msg->arg1,msg->arg2); + return 0; +} + + + +int loop_evt_entity_sys_evt + (loop_ctx *loop,loop_evt_handler *handler,uint32_t *bitmap_evt,uint32_t *evt_type_map) + +{ + uint uVar1; + + uVar1 = *evt_type_map; + printf("[SYS] [EVT] called with bitmap_evt %08lx, bitmap_task %08lx\r\n",*bitmap_evt,uVar1); + do { + if ((uVar1 & 1) == 0) { + if (uVar1 != 0) { + printf("[ASSERT] [ERR] %s:%d\r\n","bloop_handler_sys.c",0x2e); + do { + // WARNING: Do nothing block with infinite loop + } while( true ); + } + break; + } + uVar1 = uVar1 & 0xfffffffe; + bloop_status_dump(loop); + } while (uVar1 != 0); + *evt_type_map = 0; + return 0; +} + + + +int bl_sys_time_sync_state(uint32_t *xTicksToJump) + +{ + bool bVar1; + TickType_t TVar2; + TickType_t TVar3; + uint uVar4; + uint64_t uVar5; + + if (sync_init != 0) { + vTaskEnterCritical(); + TVar2 = xTaskGetTickCount(); + TVar3 = TVar2; + uVar5 = bl_rtc_get_timestamp_ms(); + vTaskExitCritical((int)uVar5); + uVar4 = TVar3 - init_tick_rtc; + bVar1 = TVar2 - init_tick_rtos < uVar4; + if (bVar1) { + *xTicksToJump = (init_tick_rtos - TVar2) + uVar4; + } + return (uint)bVar1; + } + return -1; +} + + +/* +Unable to decompile 'misaligned_load_trap' +Cause: Exception while decompiling 23067fdc: Decompiler process died + +*/ + +/* +Unable to decompile 'misaligned_store_trap' +Cause: Exception while decompiling 2306812e: Decompiler process died + +*/ + + +void get_f32_reg(void) + +{ + uint in_t0; + + // WARNING: Could not recover jumptable at 0x2306827e. Too many branches + // WARNING: Treating indirect jump as call + (*(code *)(in_t0 & 0xfffffffe))(); + return; +} + + + +void put_f32_reg(void) + +{ + uint in_t0; + + // WARNING: Could not recover jumptable at 0x2306837e. Too many branches + // WARNING: Treating indirect jump as call + (*(code *)(in_t0 & 0xfffffffe))(); + return; +} + + + +int backtrace_riscv(anon_subr_int_char_ptr *print_func,uintptr_t *regs) + +{ + return -1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t bl_timer_now_us(void) + +{ + uint32_t uVar1; + + uVar1 = _DAT_0200bff8; + __udivdi3(); + return uVar1; +} + + + +uint64_t bl_rtc_get_counter(void) + +{ + uint64_t in_fa0; + uint32_t uStack24; + uint32_t valLow; + uint32_t valHigh; + + HBN_Get_RTC_Timer_Val(&uStack24,&valLow); + return in_fa0; +} + + + +uint64_t bl_rtc_get_timestamp_ms(void) + +{ + uint64_t uVar1; + + uVar1 = bl_rtc_get_counter(); + return uVar1; +} + + + +// WARNING: Variable defined which should be unmapped: addr + +void set_if(netif *netif,char *ip_addr,char *gw_addr,char *nm_addr) + +{ + int iVar1; + ip4_addr_t iStack20; + ip4_addr_t addr; + + if ((ip_addr != (char *)0x0) && (iVar1 = ip4addr_aton(ip_addr,&iStack20), iVar1 != 0)) { + netif_set_ipaddr(netif,&iStack20); + } + if ((gw_addr != (char *)0x0) && (iVar1 = ip4addr_aton(gw_addr,&iStack20), iVar1 != 0)) { + netif_set_gw(netif,&iStack20); + } + if ((nm_addr != (char *)0x0) && (iVar1 = ip4addr_aton(nm_addr,&iStack20), iVar1 != 0)) { + netif_set_netmask(netif,&iStack20); + } + return; +} + + + +// WARNING: Variable defined which should be unmapped: pTemp + +void Bl_F_fast(uchar *digest,uchar *digest1,char *password,uchar *ssid,int ssidlength,int count, + uchar *output) + +{ + int iVar1; + size_t key_len; + byte *pbVar2; + uchar *puVar3; + byte *pbVar4; + int iVar5; + int iStack40; + int tmpLen; + uchar *pTemp; + + key_len = strlen(password); + iStack40 = ssidlength + 4; + tmpLen = (int)digest; + memcpy(digest,ssid,ssidlength); + puVar3 = digest + ssidlength; + *puVar3 = '\0'; + puVar3[3] = (uchar)count; + puVar3[1] = '\0'; + puVar3[2] = '\0'; + bl_sha_mutex_take(); + utils_hmac_sha1_fast((uchar **)&tmpLen,&iStack40,1,(uchar *)password,key_len,digest1,0x14); + memcpy(output,digest1,0x14); + iVar1 = 0xfff; + tmpLen = (int)digest1; + do { + iStack40 = 0x14; + utils_hmac_sha1_fast((uchar **)&tmpLen,&iStack40,1,(uchar *)password,key_len,digest,0x14); + memcpy(digest1,digest,0x14); + iVar5 = 0; + do { + pbVar2 = output + iVar5; + pbVar4 = digest + iVar5; + iVar5 = iVar5 + 1; + *pbVar2 = *pbVar4 ^ *pbVar2; + } while (iVar5 != 0x14); + iVar1 = iVar1 + -1; + } while (iVar1 != 0); + bl_sha_mutex_give(); + return; +} + + + +int utils_wifi_psk_cal_fast_bin(char *password,uchar *ssid,int ssidlength,uchar *output) + +{ + size_t sVar1; + int iVar2; + uchar auStack88 [4]; + uchar digest1 [20]; + uchar digest [36]; + + sVar1 = strlen(password); + if (sVar1 < 0x40) { + iVar2 = -1; + if (ssidlength < 0x21) { + Bl_F_fast(digest1 + 0x10,auStack88,password,ssid,ssidlength,2,output); + memcpy(output + 0x14,output,0xc); + Bl_F_fast(digest1 + 0x10,auStack88,password,ssid,ssidlength,1,output); + iVar2 = 0; + } + } + else { + iVar2 = -1; + } + return iVar2; +} + + + +void utils_hmac_sha1_fast + (uchar **ppText,int *pTextLen,int textNum,uchar *key,int key_len,uchar *output, + int outputLen) + +{ + uint *puVar1; + uint32_t *puVar2; + uint *__src; + uchar **ppuVar3; + int iVar4; + uint *hash; + uint local_120; + uint64_t pBuf [11]; + undefined auStack196 [4]; + bl_sha_ctx_t sha_ctx; + + if (0x40 < key_len) { + bl_sha_init((bl_sha_ctx_t *)auStack196,BL_SHA1); + bl_sha_update((bl_sha_ctx_t *)auStack196,key,key_len); + bl_sha_finish((bl_sha_ctx_t *)auStack196,key); + key_len = 0x14; + } + memset(&local_120,0,0x40); + memcpy(&local_120,key,key_len); + hash = (uint *)((int)pBuf + 0x3c); + puVar1 = &local_120; + do { + __src = puVar1 + 2; + *puVar1 = *puVar1 ^ 0x36363636; + puVar1[1] = puVar1[1] ^ 0x36363636; + puVar1 = __src; + } while (__src != hash); + bl_sha_init((bl_sha_ctx_t *)auStack196,BL_SHA1); + bl_sha_update((bl_sha_ctx_t *)auStack196,(uint8_t *)&local_120,0x40); + iVar4 = 0; + while (iVar4 < textNum) { + puVar2 = (uint32_t *)(pTextLen + iVar4); + ppuVar3 = ppText + iVar4; + iVar4 = iVar4 + 1; + bl_sha_update((bl_sha_ctx_t *)auStack196,*ppuVar3,*puVar2); + } + bl_sha_finish((bl_sha_ctx_t *)auStack196,(uint8_t *)hash); + memset(&local_120,0,0x40); + memcpy(&local_120,key,key_len); + puVar1 = &local_120; + do { + __src = puVar1 + 2; + *puVar1 = *puVar1 ^ 0x5c5c5c5c; + puVar1[1] = puVar1[1] ^ 0x5c5c5c5c; + puVar1 = __src; + } while (__src != hash); + bl_sha_init((bl_sha_ctx_t *)auStack196,BL_SHA1); + bl_sha_update((bl_sha_ctx_t *)auStack196,(uint8_t *)&local_120,0x40); + bl_sha_update((bl_sha_ctx_t *)auStack196,(uint8_t *)__src,0x14); + bl_sha_finish((bl_sha_ctx_t *)auStack196,(uint8_t *)__src); + memcpy(output,__src,outputLen); + return; +} + + + +int bl_sha_mutex_take(void) + +{ + BaseType_t BVar1; + TickType_t TVar2; + int iVar3; + + BVar1 = xQueueSemaphoreTake((QueueHandle_t)g_bl_sec_sha_mutex,0xffffffff); + iVar3 = 0; + if (((BVar1 != 1) && (iVar3 = -1, _fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvbl_sec_sha < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] sha semphr take failed\r\n",TVar2,&DAT_23078e4c,"bl_sec_sha.c", + 0x36); + iVar3 = -1; + } + return iVar3; +} + + + +int bl_sha_mutex_give(void) + +{ + BaseType_t BVar1; + TickType_t TVar2; + int iVar3; + + BVar1 = xQueueGenericSend((QueueHandle_t)g_bl_sec_sha_mutex,(void *)0x0,0,0); + iVar3 = 0; + if (((BVar1 != 1) && (iVar3 = -1, _fsymc_level_hal_drv < BLOG_LEVEL_ASSERT)) && + (_fsymf_level_hal_drvbl_sec_sha < BLOG_LEVEL_ASSERT)) { + if (TrapNetCounter == 0) { + TVar2 = xTaskGetTickCount(); + } + else { + TVar2 = xTaskGetTickCountFromISR(); + } + bl_printk("[%10u][%s: %s:%4d] sha semphr give failed\\n",TVar2,&DAT_23078e4c,"bl_sec_sha.c",0x3f + ); + iVar3 = -1; + } + return iVar3; +} + + + +void bl_sha_init(bl_sha_ctx_t *ctx,bl_sha_type_t type) + +{ + Sec_Eng_SHA256_Init((SEC_Eng_SHA256_Ctx *)ctx,SEC_ENG_SHA_ID0,type,ctx->tmp,ctx->pad); + Sec_Eng_SHA_Start(SEC_ENG_SHA_ID0); + return; +} + + + +int bl_sha_update(bl_sha_ctx_t *ctx,uint8_t *input,uint32_t len) + +{ + BL_Err_Type BVar1; + undefined3 extraout_var; + + BVar1 = Sec_Eng_SHA256_Update((SEC_Eng_SHA256_Ctx *)ctx,SEC_ENG_SHA_ID0,input,len); + return CONCAT31(extraout_var,BVar1); +} + + + +int bl_sha_finish(bl_sha_ctx_t *ctx,uint8_t *hash) + +{ + BL_Err_Type BVar1; + undefined3 extraout_var; + + BVar1 = Sec_Eng_SHA256_Finish((SEC_Eng_SHA256_Ctx *)ctx,SEC_ENG_SHA_ID0,hash); + return CONCAT31(extraout_var,BVar1); +} + + + +double fabs(double __x) + +{ + double in_fa0; + + return in_fa0; +} + + + +double floor(double __x) + +{ + uint uVar1; + uint in_a0; + uint in_a1; + uint uVar2; + double in_fa0; + + uVar2 = (int)in_a1 >> 0x14 & 0x7ff; + uVar1 = uVar2 - 0x3ff; + if ((int)uVar1 < 0x14) { + if ((int)uVar1 < 0) { + in_fa0 = (double)__adddf3(); + __gedf2(); + } + else { + if ((0xfffff >> (uVar1 & 0x1f) & in_a1 | in_a0) != 0) { + in_fa0 = (double)__adddf3(); + __gedf2(); + } + } + } + else { + if ((int)uVar1 < 0x34) { + if ((0xffffffffU >> (uVar2 - 0x413 & 0x1f) & in_a0) != 0) { + in_fa0 = (double)__adddf3(); + __gedf2(); + } + } + else { + if (uVar1 == 0x400) { + in_fa0 = (double)__adddf3(); + } + } + } + return in_fa0; +} + + + +double modf(double __x,double *__iptr) + +{ + double *in_a1; + double **in_a2; + uint uVar1; + uint uVar2; + double in_fa0; + DFtype DVar3; + + uVar1 = (int)in_a1 >> 0x14 & 0x7ff; + uVar2 = uVar1 - 0x3ff; + if ((int)uVar2 < 0x14) { + if ((int)uVar2 < 0) { + *in_a2 = (double *)0x0; + in_a2[1] = (double *)((uint)in_a1 & 0x80000000); + return in_fa0; + } + uVar1 = 0xfffff >> (uVar2 & 0x1f); + if ((uVar1 & (uint)in_a1 | (uint)__iptr) != 0) { + in_a1 = (double *)(~uVar1 & (uint)in_a1); + __iptr = (double *)0x0; +LAB_23068bc0: + *in_a2 = __iptr; + in_a2[1] = in_a1; + DVar3 = __subdf3(); + return (double)DVar3; + } + } + else { + if (((int)uVar2 < 0x34) && + (uVar1 = 0xffffffff >> (uVar1 - 0x413 & 0x1f), (uVar1 & (uint)__iptr) != 0)) { + __iptr = (double *)(~uVar1 & (uint)__iptr); + goto LAB_23068bc0; + } + } + in_a2[1] = in_a1; + *in_a2 = __iptr; + return in_fa0; +} + + + +DItype __lshrdi3(shift_count_type b) + +{ + DItype in_fa0; + + return in_fa0; +} + + + +int __clzsi2(USItype x) + +{ + int iVar1; + + if (x < 0x10000) { + iVar1 = (uint)(0xff < x) << 3; + } + else { + iVar1 = 0x10; + if (0xffffff < x) { + iVar1 = 0x18; + } + } + return (0x20 - iVar1) - (uint)""[x >> iVar1]; +} + + + +// WARNING: Type propagation algorithm not settling + +DItype __divdi3(void) + +{ + DItype in_fa0; + + return in_fa0; +} + + + +// WARNING: Type propagation algorithm not settling + +DItype __moddi3(void) + +{ + DItype in_fa0; + + return in_fa0; +} + + + +// WARNING: Type propagation algorithm not settling + +UDItype __udivdi3(void) + +{ + UDItype in_fa0; + + return in_fa0; +} + + + +// WARNING: Type propagation algorithm not settling + +UDItype __umoddi3(void) + +{ + UDItype in_fa0; + + return in_fa0; +} + + +/* +Unable to decompile '__adddf3' +Cause: Exception while decompiling 23069da8: Decompiler process died + +*/ + +/* +Unable to decompile '__divdf3' +Cause: +Low-level Error: Assignment to constant at r0x2306af2c +*/ + + +__gcc_CMPtype __eqdf2(void) + +{ + uint in_a0; + uint in_a1; + uint in_a2; + uint in_a3; + uint uVar1; + uint uVar2; + uint uVar3; + + uVar1 = in_a1 >> 0x14 & 0x7ff; + uVar2 = in_a1 & 0xfffff; + uVar3 = in_a3 >> 0x14 & 0x7ff; + if (uVar1 == 0x7ff) { + if ((uVar2 | in_a0) != 0) { + return 1; + } + if (uVar3 != 0x7ff) { + return 1; + } + } + else { + if (uVar3 != 0x7ff) goto LAB_2306b1fc; + } + if ((in_a3 & 0xfffff | in_a2) != 0) { + return 1; + } +LAB_2306b1fc: + if (((uVar1 == uVar3) && (uVar2 == (in_a3 & 0xfffff))) && (in_a2 == in_a0)) { + if (in_a1 >> 0x1f == in_a3 >> 0x1f) { + return 0; + } + if (uVar1 == 0) { + return (uint)((uVar2 | in_a2) != 0); + } + } + return 1; +} + + + +__gcc_CMPtype __gedf2(void) + +{ + bool bVar1; + uint in_a0; + uint in_a1; + int iVar2; + uint in_a2; + uint in_a3; + int iVar3; + uint uVar4; + uint uVar5; + uint uVar6; + uint uVar7; + + uVar6 = in_a1 >> 0x14 & 0x7ff; + uVar7 = in_a1 & 0xfffff; + uVar5 = in_a3 & 0xfffff; + iVar2 = -((int)in_a1 >> 0x1f); + uVar4 = in_a3 >> 0x14 & 0x7ff; + iVar3 = -((int)in_a3 >> 0x1f); + if (uVar6 == 0x7ff) { + if ((uVar7 | in_a0) != 0) { + return -2; + } + if (uVar4 == 0x7ff) { +LAB_2306b2c0: + if ((uVar5 | in_a2) != 0) { + return -2; + } + goto LAB_2306b2c8; + } +LAB_2306b34c: + if (uVar4 == 0) { + bVar1 = false; +LAB_2306b2d8: + if ((uVar5 | in_a2) == 0) { + if (bVar1) { + return 0; + } + goto LAB_2306b2ec; + } + goto LAB_2306b2e0; + } + } + else { + if (uVar4 == 0x7ff) goto LAB_2306b2c0; +LAB_2306b2c8: + if (uVar6 != 0) goto LAB_2306b34c; + bVar1 = (uVar7 | in_a0) == 0; + if (uVar4 == 0) goto LAB_2306b2d8; +LAB_2306b2e0: + if (bVar1) { + if (iVar3 != 0) { + return iVar3; + } + return -1; + } + } + if ((iVar2 == iVar3) && (uVar6 <= uVar4)) { + if (uVar4 <= uVar6) { + if (uVar5 < uVar7) goto LAB_2306b2ec; + if (uVar7 == uVar5) { + if (in_a2 < in_a0) goto LAB_2306b2ec; + if (in_a2 <= in_a0) { + return 0; + } + } + else { + if (uVar5 <= uVar7) { + return 0; + } + } + } + if (iVar2 == 0) { + return -1; + } + return iVar2; + } +LAB_2306b2ec: + if (iVar2 != 0) { + return -1; + } + return 1; +} + + + +__gcc_CMPtype __ledf2(void) + +{ + bool bVar1; + uint in_a0; + uint in_a1; + int iVar2; + uint in_a2; + uint in_a3; + int iVar3; + uint uVar4; + uint uVar5; + uint uVar6; + uint uVar7; + + uVar6 = in_a1 >> 0x14 & 0x7ff; + uVar7 = in_a1 & 0xfffff; + uVar5 = in_a3 & 0xfffff; + iVar2 = -((int)in_a1 >> 0x1f); + uVar4 = in_a3 >> 0x14 & 0x7ff; + iVar3 = -((int)in_a3 >> 0x1f); + if (uVar6 == 0x7ff) { + if ((uVar7 | in_a0) != 0) { + return 2; + } + if (uVar4 == 0x7ff) { +LAB_2306b3ac: + if ((uVar5 | in_a2) != 0) { + return 2; + } + goto LAB_2306b3b4; + } +LAB_2306b438: + if (uVar4 == 0) { + bVar1 = false; +LAB_2306b3c4: + if ((uVar5 | in_a2) == 0) { + if (bVar1) { + return 0; + } + goto LAB_2306b3d8; + } + goto LAB_2306b3cc; + } + } + else { + if (uVar4 == 0x7ff) goto LAB_2306b3ac; +LAB_2306b3b4: + if (uVar6 != 0) goto LAB_2306b438; + bVar1 = (uVar7 | in_a0) == 0; + if (uVar4 == 0) goto LAB_2306b3c4; +LAB_2306b3cc: + if (bVar1) { + if (iVar3 != 0) { + return iVar3; + } + return -1; + } + } + if ((iVar2 == iVar3) && (uVar6 <= uVar4)) { + if (uVar4 <= uVar6) { + if (uVar5 < uVar7) goto LAB_2306b3d8; + if (uVar7 == uVar5) { + if (in_a2 < in_a0) goto LAB_2306b3d8; + if (in_a2 <= in_a0) { + return 0; + } + } + else { + if (uVar5 <= uVar7) { + return 0; + } + } + } + if (iVar2 == 0) { + return -1; + } + return iVar2; + } +LAB_2306b3d8: + if (iVar2 != 0) { + return -1; + } + return 1; +} + + +/* +Unable to decompile '__muldf3' +Cause: +Low-level Error: Assignment to constant at r0x2306b6ec +*/ + +/* +Unable to decompile '__subdf3' +Cause: Exception while decompiling 2306bbe0: Decompiler process died + +*/ + + +SItype __fixdfsi(void) + +{ + uint in_a0; + uint in_a1; + uint uVar1; + uint uVar2; + + uVar1 = in_a1 >> 0x14 & 0x7ff; + if (uVar1 < 0x3ff) { + if ((uVar1 != 0) || (uVar2 = in_a1 & 0xfffff | in_a0, uVar2 != 0)) { + uVar2 = 0; + } + } + else { + if (uVar1 < 0x41e) { + uVar2 = in_a1 & 0xfffff | 0x100000; + if ((int)(0x433 - uVar1) < 0x20) { + uVar2 = uVar2 << (uVar1 - 0x413 & 0x1f) | in_a0 >> (0x433 - uVar1 & 0x1f); + } + else { + uVar2 = uVar2 >> (0x413 - uVar1 & 0x1f); + } + if (-((int)in_a1 >> 0x1f) != 0) { + uVar2 = -uVar2; + } + } + else { + uVar2 = -((int)in_a1 >> 0x1f) + 0x7fffffff; + } + } + return uVar2; +} + + + +USItype __fixunsdfsi(void) + +{ + uint in_a0; + USItype UVar1; + uint in_a1; + uint uVar2; + uint uVar3; + uint uVar4; + uint uVar5; + + uVar3 = in_a1 >> 0x14 & 0x7ff; + if (uVar3 < 0x3ff) { + if ((uVar3 == 0) && ((in_a1 & 0xfffff | in_a0) == 0)) { + return 0; + } + UVar1 = 0; + } + else { + if ((int)in_a1 < 0) { + UVar1 = 0; + } + else { + if (uVar3 < 0x41f) { + uVar5 = in_a1 & 0xfffff | 0x100000; + uVar2 = 0x433 - uVar3; + if ((int)uVar2 < 0x20) { + uVar4 = in_a0 << (uVar3 - 0x413 & 0x1f); + UVar1 = uVar5 << (uVar3 - 0x413 & 0x1f) | in_a0 >> (uVar2 & 0x1f); + } + else { + uVar4 = 0; + if (uVar2 != 0x20) { + uVar4 = uVar5 << (uVar3 - 0x3f3 & 0x1f); + } + uVar4 = uVar4 | in_a0; + UVar1 = uVar5 >> (0x413 - uVar3 & 0x1f); + } + if (uVar4 == 0) { + return UVar1; + } + } + else { + UVar1 = 0xffffffff; + } + } + } + return UVar1; +} + + + +DFtype __floatsidf(SItype i) + +{ + DFtype in_fa0; + + if (i != 0) { + __clzsi2((i >> 0x1f ^ i) - (i >> 0x1f)); + } + return in_fa0; +} + + + +DFtype __floatunsidf(USItype i) + +{ + DFtype in_fa0; + + if (i != 0) { + __clzsi2(i); + } + return in_fa0; +} + + +/* +Unable to decompile '__extendsfdf2' +Cause: Exception while decompiling 2306ca0c: Decompiler process died + +*/ + + +SFtype __truncdfsf2(void) + +{ + uint uVar1; + SFtype in_a0; + uint in_a1; + uint uVar2; + uint uVar3; + uint uVar4; + uint uVar5; + int iVar6; + int in_frm; + + uVar1 = in_a1 >> 0x14 & 0x7ff; + uVar3 = (uint)in_a0 >> 0x1d | (in_a1 & 0xfffff) << 3; + uVar5 = (int)in_a0 << 3; + if ((uVar1 + 1 & 0x7fe) == 0) { + uVar3 = uVar3 | uVar5; + if (uVar1 == 0) { + uVar1 = (uint)(uVar3 != 0); +LAB_2306cc6c: + if (uVar1 == 0) { + return in_a0; + } +LAB_2306cc70: + if (((((uVar1 * 2 & 7) != 0) && (in_frm != 2)) && (in_frm != 3)) && (in_frm == 0)) { + in_a0 = 0.00000000; + } + } + else { + if (uVar3 == 0) { + return in_a0; + } + uVar1 = 0; + } + } + else { + iVar6 = uVar1 - 0x380; + if (0xfe < iVar6) { + if (in_frm == 0) { + return in_a0; + } + if (in_frm == 3) { + if (-1 < (int)in_a1) { + return in_a0; + } + } + else { + if ((in_frm == 2) && ((int)in_a1 < 0)) { + return in_a0; + } + } + goto LAB_2306cb7c; + } + if (iVar6 < 1) { + if (-0x18 < iVar6) { + uVar3 = uVar3 | 0x800000; + uVar2 = 0x1e - iVar6; + if ((int)uVar2 < 0x20) { + uVar1 = uVar5 >> (uVar2 & 0x1f) | + (uint)(uVar5 << (uVar1 - 0x37e & 0x1f) != 0) | uVar3 << (uVar1 - 0x37e & 0x1f); + } + else { + in_a0 = 0.00000000; + uVar4 = 0; + if (uVar2 != 0x20) { + uVar4 = uVar3 << (uVar1 - 0x35e & 0x1f); + } + uVar1 = uVar3 >> (-iVar6 - 2U & 0x1f) | (uint)((uVar4 | uVar5) != 0); + } + goto LAB_2306cc6c; + } + uVar1 = 1; + goto LAB_2306cc70; + } + in_a0 = (SFtype)(uint)(((uint)in_a0 & 0x3ffffff) != 0); + uVar1 = (uint)in_a0 | uVar5 >> 0x1d; + } + if ((uVar1 & 7) == 0) { + return in_a0; + } +LAB_2306cb7c: + if (((in_frm != 2) && (in_frm != 3)) && (in_frm == 0)) { + in_a0 = 0.00000000; + } + return in_a0; +} + + + +int atoi(char *__nptr) + +{ + long lVar1; + + lVar1 = strtol(__nptr,(char **)0x0,10); + return lVar1; +} + + + +void _atoi_r(void) + +{ + _strtol_r(0,10); + return; +} + + + +undefined * __errno(void) + +{ + return _impure_ptr; +} + + + +void * memchr(void *__s,int __c,size_t __n) + +{ + byte bVar1; + uint uVar2; + uint uVar3; + uint *puVar4; + uint uVar5; + + uVar5 = __c & 0xff; + if (((uint)__s & 3) != 0) { + if (__n == 0) { + return (void *)0x0; + } + bVar1 = *(byte *)__s; + __n = __n - 1; + while( true ) { + if ((uint)bVar1 == uVar5) { + return (uint *)__s; + } + __s = (void *)((int)__s + 1); + if (((uint)__s & 3) == 0) break; + __n = __n - 1; + if (__n == 0xffffffff) { + return (void *)0x0; + } + bVar1 = *(byte *)__s; + } + } + if (3 < __n) { + uVar2 = (__c & 0xffU) << 8 | __c & 0xffU; + do { + uVar3 = (uVar2 << 0x10 | uVar2) ^ *(uint *)__s; + if ((uVar3 + 0xfefefeff & ~uVar3 & 0x80808080) != 0) goto LAB_2306ce68; + __n = __n - 4; + __s = (uint *)__s + 1; + } while (3 < __n); + } + if (__n != 0) { +LAB_2306ce68: + if ((uint)*(byte *)__s == uVar5) { + return (uint *)__s; + } + puVar4 = (uint *)((int)__s + __n); + while (__s = (void *)((int)__s + 1), puVar4 != (uint *)__s) { + if ((uint)*(byte *)__s == uVar5) { + return (uint *)__s; + } + } + } + return (void *)0x0; +} + + + +int memcmp(void *__s1,void *__s2,size_t __n) + +{ + int *piVar1; + uint uVar2; + uint uVar3; + + if (3 < __n) { + if ((((uint)__s1 | (uint)__s2) & 3) != 0) goto LAB_2306cf34; + do { + if (*(int *)__s1 != *(int *)__s2) goto LAB_2306cf34; + __n = __n - 4; + __s1 = (int *)__s1 + 1; + __s2 = (int *)__s2 + 1; + } while (3 < __n); + } + if (__n == 0) { + return 0; + } +LAB_2306cf34: + uVar3 = (uint)*(byte *)__s1; + uVar2 = (uint)*(byte *)__s2; + if (uVar3 == uVar2) { + piVar1 = (int *)((int)__s1 + __n); + do { + __s1 = (void *)((int)__s1 + 1); + __s2 = (void *)((int)__s2 + 1); + if ((int *)__s1 == piVar1) { + return 0; + } + uVar3 = (uint)*(byte *)__s1; + uVar2 = (uint)*(byte *)__s2; + } while (uVar3 == uVar2); + } + return uVar3 - uVar2; +} + + + +void * memcpy(void *__dest,void *__src,size_t __n) + +{ + undefined uVar1; + undefined4 uVar2; + undefined4 uVar3; + undefined4 *puVar4; + undefined4 *puVar5; + undefined4 uVar6; + undefined4 *puVar7; + uint uVar8; + undefined4 *puVar9; + undefined4 *puVar10; + int iVar11; + undefined4 uVar12; + undefined4 *puVar13; + undefined4 uVar14; + undefined4 uVar15; + undefined4 uVar16; + undefined4 uVar17; + + puVar13 = (undefined4 *)((int)__dest + __n); + if (((((uint)__src ^ (uint)__dest) & 3) == 0) && (3 < __n)) { + uVar8 = (uint)__dest & 3; + puVar5 = (undefined4 *)__dest; + while (puVar4 = (undefined4 *)__src, puVar7 = puVar5, uVar8 != 0) { + puVar7 = (undefined4 *)((int)puVar5 + 1); + *(undefined *)puVar5 = *(undefined *)__src; + puVar4 = (undefined4 *)((int)__src + 1); + if (((uint)puVar7 & 3) == 0) break; + uVar8 = (uint)(undefined4 *)((int)puVar5 + 2) & 3; + *(undefined *)((int)puVar5 + 1) = *(undefined *)puVar4; + __src = (void *)((int)__src + 2); + puVar5 = (undefined4 *)((int)puVar5 + 2); + } + puVar5 = (undefined4 *)((uint)puVar13 & 0xfffffffc); + __src = puVar4; + while (puVar7 < puVar5 + -8) { + uVar2 = ((undefined4 *)__src)[1]; + uVar17 = ((undefined4 *)__src)[2]; + uVar16 = ((undefined4 *)__src)[3]; + uVar15 = ((undefined4 *)__src)[4]; + uVar14 = ((undefined4 *)__src)[5]; + uVar3 = ((undefined4 *)__src)[6]; + uVar12 = ((undefined4 *)__src)[7]; + *puVar7 = *(undefined4 *)__src; + uVar6 = ((undefined4 *)__src)[8]; + puVar7[1] = uVar2; + puVar7[2] = uVar17; + puVar7[3] = uVar16; + puVar7[4] = uVar15; + puVar7[5] = uVar14; + puVar7[6] = uVar3; + puVar7[7] = uVar12; + puVar7[8] = uVar6; + __src = (undefined4 *)__src + 9; + puVar7 = puVar7 + 9; + } + puVar4 = (undefined4 *)__src; + puVar9 = puVar7; + if (puVar7 < puVar5) { + do { + puVar10 = puVar9 + 1; + *puVar9 = *puVar4; + puVar4 = puVar4 + 1; + puVar9 = puVar10; + } while (puVar10 < puVar5); + iVar11 = ((int)puVar5 + (-1 - (int)puVar7) & 0xfffffffcU) + 4; + puVar7 = (undefined4 *)((int)puVar7 + iVar11); + __src = (void *)((int)__src + iVar11); + } + if (puVar7 < puVar13) { +LAB_2306cff8: + do { + uVar1 = *(undefined *)__src; + puVar5 = (undefined4 *)((int)puVar7 + 1); + __src = (void *)((int)__src + 1); + *(undefined *)puVar7 = uVar1; + puVar7 = puVar5; + } while (puVar5 < puVar13); + return __dest; + } + } + else { + puVar7 = (undefined4 *)__dest; + if (__dest < puVar13) goto LAB_2306cff8; + } + return __dest; +} + + + +void * memmove(void *__dest,void *__src,size_t __n) + +{ + int iVar1; + undefined *puVar2; + undefined4 *puVar3; + undefined *puVar4; + undefined4 *puVar5; + undefined4 *puVar6; + uint uVar7; + + if ((__src < __dest) && (puVar4 = (undefined *)((int)__src + __n), __dest < puVar4)) { + puVar2 = (undefined *)((int)__dest + __n); + if (__n == 0) { + return __dest; + } + do { + puVar4 = puVar4 + -1; + puVar2 = puVar2 + -1; + *puVar2 = *puVar4; + } while ((undefined *)__src != puVar4); + return __dest; + } + uVar7 = __n; + puVar5 = (undefined4 *)__dest; + if (0xf < __n) { + if ((((uint)__src | (uint)__dest) & 3) != 0) { + iVar1 = __n - 1; + goto LAB_2306d0dc; + } + iVar1 = (__n - 0x10 & 0xfffffff0) + 0x10; + puVar3 = (undefined4 *)__src; + puVar6 = (undefined4 *)__dest; + do { + puVar5 = puVar6 + 4; + *puVar6 = *puVar3; + puVar6[1] = puVar3[1]; + puVar6[2] = puVar3[2]; + puVar6[3] = puVar3[3]; + puVar3 = puVar3 + 4; + puVar6 = puVar5; + } while ((undefined4 *)((int)__dest + iVar1) != puVar5); + __src = (void *)((int)__src + iVar1); + uVar7 = __n & 0xf; + puVar3 = (undefined4 *)__src; + if ((__n & 0xc) != 0) { + do { + puVar3 = puVar3 + 1; + *puVar6 = *puVar3; + puVar3 = puVar3; + puVar6 = puVar6 + 1; + } while (3 < (int)__src + (uVar7 - (int)puVar3)); + iVar1 = (uVar7 - 4 & 0xfffffffc) + 4; + __src = (void *)((int)__src + iVar1); + uVar7 = __n & 3; + puVar5 = (undefined4 *)((int)puVar5 + iVar1); + } + } + iVar1 = uVar7 - 1; + if (uVar7 == 0) { + return __dest; + } +LAB_2306d0dc: + puVar3 = puVar5; + do { + puVar6 = (undefined4 *)((int)puVar3 + 1); + *(undefined *)puVar3 = *(undefined *)__src; + __src = (undefined4 *)((int)__src + 1); + puVar3 = puVar6; + } while (puVar6 != (undefined4 *)((int)puVar5 + iVar1 + 1)); + return __dest; +} + + + +void * memset(void *__s,int __c,size_t __n) + +{ + uint uVar1; + uint extraout_a1; + uint *puVar2; + uint *puVar3; + void *pvVar4; + uint uVar5; + + uVar1 = 0xf; + if (0xf < __n) { + uVar5 = (uint)__s & 0xf; + puVar3 = (uint *)__s; + if (uVar5 != 0) { + pvVar4 = __s; + __s = (void *)(*(code *)(uVar5 * 4 + 0x2306d210))(); + puVar3 = (uint *)((int)pvVar4 - (uVar5 - 0x10)); + __n = __n + (uVar5 - 0x10); + __c = extraout_a1; + if (__n <= uVar1) goto LAB_2306d200; + } + if (__c != 0) { + uVar5 = __c & 0xffU | (__c & 0xffU) << 8; + __c = uVar5 | uVar5 << 0x10; + } + uVar5 = __n & 0xfffffff0; + __n = __n & 0xf; + puVar2 = (uint *)(uVar5 + (int)puVar3); + do { + *puVar3 = __c; + puVar3[1] = __c; + puVar3[2] = __c; + puVar3[3] = __c; + puVar3 = puVar3 + 4; + } while (puVar3 < puVar2); + if (__n == 0) { + return __s; + } + } +LAB_2306d200: + // WARNING: Could not recover jumptable at 0x2306d210. Too many branches + // WARNING: Treating indirect jump as call + pvVar4 = (void *)(*(code *)(&UNK_2306d214 + (uVar1 - __n) * 4))(); + return pvVar4; +} + + + +char * strchr(char *__s,int __c) + +{ + uint uVar1; + uint uVar2; + uint uVar3; + uint uVar4; + + uVar3 = __c & 0xff; + if (uVar3 == 0) { + if (((uint)__s & 3) != 0) { + if (*__s == '\0') { + return __s; + } + while (__s = (char *)((int)__s + 1), ((uint)__s & 3) != 0) { + if (*__s == '\0') { + return (char *)(uint *)__s; + } + } + } + uVar3 = *(uint *)__s + 0xfefefeff & ~*(uint *)__s; + while ((uVar3 & 0x80808080) == 0) { + __s = (char *)((uint *)__s + 1); + uVar3 = *(uint *)__s + 0xfefefeff & ~*(uint *)__s; + } + if (*__s != '\0') { + do { + __s = (char *)((int)__s + 1); + } while (*__s != '\0'); + return __s; + } + return (char *)(uint *)__s; + } + if (((uint)__s & 3) != 0) { + if (*__s == 0) { + return (char *)0x0; + } + if (uVar3 == (uint)(byte)*__s) { + return __s; + } + while (__s = (char *)((int)__s + 1), ((uint)__s & 3) != 0) { + if (*__s == 0) { + return (char *)0x0; + } + if ((uint)(byte)*__s == uVar3) { + return (char *)(uint *)__s; + } + } + } + uVar1 = __c & 0xffU | (__c & 0xffU) << 8; + uVar4 = *(uint *)__s; + uVar1 = uVar1 << 0x10 | uVar1; + uVar2 = uVar1 ^ uVar4; + uVar2 = ~uVar4 & uVar4 + 0xfefefeff | ~uVar2 & uVar2 + 0xfefefeff; + while ((uVar2 & 0x80808080) == 0) { + __s = (char *)((uint *)__s + 1); + uVar4 = *(uint *)__s; + uVar2 = uVar4 ^ uVar1; + uVar2 = uVar4 + 0xfefefeff & ~uVar4 | uVar2 + 0xfefefeff & ~uVar2; + } + if (*__s != 0) { + if (uVar3 == (uint)(byte)*__s) { + return (char *)(uint *)__s; + } + while( true ) { + __s = (char *)((int)__s + 1); + if (*__s == 0) break; + if ((uint)(byte)*__s == uVar3) { + return __s; + } + } + } + return (char *)0x0; +} + + + +int strcmp(char *__s1,char *__s2) + +{ + byte bVar1; + byte bVar2; + uint uVar3; + uint uVar4; + + if ((((uint)__s1 | (uint)__s2) & 3) == 0) { + do { + uVar3 = *(uint *)__s1; + uVar4 = *(uint *)__s2; + if (((uVar3 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar3 | 0x7f7f7f7f) != 0xffffffff) { +LAB_2306d538: + if (uVar3 == uVar4) { + return 0; + } + goto LAB_2306d510; + } + if (uVar3 != uVar4) break; + uVar3 = ((uint *)__s1)[1]; + uVar4 = ((uint *)__s2)[1]; + if (((uVar3 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar3 | 0x7f7f7f7f) != 0xffffffff) { + __s1 = (char *)((uint *)__s1 + 1); + __s2 = (char *)((uint *)__s2 + 1); + goto LAB_2306d538; + } + if (uVar3 != uVar4) break; + uVar3 = ((uint *)__s1)[2]; + uVar4 = ((uint *)__s2)[2]; + if (((uVar3 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar3 | 0x7f7f7f7f) != 0xffffffff) { + __s1 = (char *)((uint *)__s1 + 2); + __s2 = (char *)((uint *)__s2 + 2); + if (uVar3 == uVar4) { + return 0; + } + goto LAB_2306d510; + } + if (uVar3 != uVar4) break; + uVar3 = ((uint *)__s1)[3]; + uVar4 = ((uint *)__s2)[3]; + if (((uVar3 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar3 | 0x7f7f7f7f) != 0xffffffff) { + __s1 = (char *)((uint *)__s1 + 3); + __s2 = (char *)((uint *)__s2 + 3); + if (uVar3 == uVar4) { + return 0; + } + goto LAB_2306d510; + } + if (uVar3 != uVar4) break; + uVar3 = ((uint *)__s1)[4]; + uVar4 = ((uint *)__s2)[4]; + if (((uVar3 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar3 | 0x7f7f7f7f) != 0xffffffff) { + __s1 = (char *)((uint *)__s1 + 4); + __s2 = (char *)((uint *)__s2 + 4); + if (uVar3 == uVar4) { + return 0; + } + goto LAB_2306d510; + } + __s1 = (char *)((uint *)__s1 + 5); + __s2 = (char *)((uint *)__s2 + 5); + } while (uVar3 == uVar4); + if (uVar3 << 0x10 == uVar4 << 0x10) { + uVar3 = uVar3 >> 0x10; + uVar4 = uVar4 >> 0x10; + if ((uVar3 - uVar4 & 0xff) == 0) { + return uVar3 - uVar4; + } + } + else { + uVar3 = uVar3 & 0xffff; + uVar4 = uVar4 & 0xffff; + if ((uVar3 - uVar4 & 0xff) == 0) { + return uVar3 - uVar4; + } + } + return (uVar3 & 0xff) - (uVar4 & 0xff); + } +LAB_2306d510: + do { + bVar1 = *__s1; + bVar2 = *__s2; + __s1 = (char *)((int)__s1 + 1); + __s2 = (char *)((int)__s2 + 1); + if ((uint)bVar1 != (uint)bVar2) break; + } while (bVar1 != 0); + return (uint)bVar1 - (uint)bVar2; +} + + + +char * strcpy(char *__dest,char *__src) + +{ + char cVar1; + char cVar2; + char cVar3; + uint *puVar4; + uint uVar5; + uint uVar6; + char *pcVar7; + + pcVar7 = __dest; + if ((((uint)__dest | (uint)__src) & 3) != 0) { + do { + cVar1 = *__src; + __src = __src + 1; + *pcVar7 = cVar1; + pcVar7 = pcVar7 + 1; + } while (cVar1 != '\0'); + return __dest; + } + uVar5 = *(uint *)__src; + uVar6 = (uVar5 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar5; + puVar4 = (uint *)__dest; + while ((uVar6 | 0x7f7f7f7f) == 0xffffffff) { + __src = (char *)((uint *)__src + 1); + *puVar4 = uVar5; + uVar5 = *(uint *)__src; + uVar6 = (uVar5 & 0x7f7f7f7f) + 0x7f7f7f7f | uVar5; + puVar4 = puVar4 + 1; + } + cVar1 = *__src; + cVar2 = *(char *)((int)__src + 1); + cVar3 = *(char *)((int)__src + 2); + *(char *)puVar4 = cVar1; + if (((cVar1 != '\0') && (*(char *)((int)puVar4 + 1) = cVar2, cVar2 != '\0')) && + (*(char *)((int)puVar4 + 2) = cVar3, cVar3 != '\0')) { + *(char *)((int)puVar4 + 3) = '\0'; + return __dest; + } + return __dest; +} + + + +size_t strlen(char *__s) + +{ + char cVar1; + uint *puVar2; + uint *puVar3; + uint uVar4; + + uVar4 = (uint)__s & 3; + puVar3 = (uint *)__s; + while (uVar4 != 0) { + cVar1 = *(char *)puVar3; + puVar3 = (uint *)((int)puVar3 + 1); + uVar4 = (uint)puVar3 & 3; + if (cVar1 == '\0') { + return (int)puVar3 + (-1 - (int)__s); + } + } + do { + puVar2 = puVar3; + puVar3 = puVar2 + 1; + } while (((*puVar2 & 0x7f7f7f7f) + 0x7f7f7f7f | *puVar2 | 0x7f7f7f7f) == 0xffffffff); + puVar3 = (uint *)((int)(puVar2 + 1) - (int)__s); + if (*(char *)puVar2 != '\0') { + if (*(char *)((int)puVar2 + 1) != '\0') { + return (int)puVar3 + ((uint)(*(char *)((int)puVar2 + 2) != '\0') - 2); + } + return (size_t)((int)puVar3 + -3); + } + return (size_t)(puVar3 + -1); +} + + + +int strncmp(char *__s1,char *__s2,size_t __n) + +{ + int iVar1; + uint *puVar2; + uint uVar3; + uint uVar4; + + if (__n == 0) { + return 0; + } + if (((((uint)__s1 | (uint)__s2) & 3) == 0) && (3 < __n)) { + uVar4 = *(uint *)__s1; + if (uVar4 != *(uint *)__s2) { +LAB_2306d798: + uVar3 = (uint)(byte)*__s1; + uVar4 = (uint)(byte)*__s2; + iVar1 = __n - 1; + if (uVar4 == uVar3) goto LAB_2306d75c; + goto LAB_2306d788; + } + __n = __n - 4; + if (__n == 0) { + return 0; + } + uVar4 = uVar4 + 0xfefefeff & ~uVar4; + while( true ) { + if ((uVar4 & 0x80808080) != 0) { + return 0; + } + __s1 = (char *)((uint *)__s1 + 1); + __s2 = (char *)((uint *)__s2 + 1); + if (__n < 4) break; + uVar3 = *(uint *)__s1; + uVar4 = uVar3 + 0xfefefeff & ~uVar3; + if (uVar3 != *(uint *)__s2) goto LAB_2306d798; + __n = __n - 4; + if (__n == 0) { + return 0; + } + } + } + uVar3 = (uint)(byte)*__s1; + uVar4 = (uint)(byte)*__s2; + iVar1 = __n - 1; + if (uVar4 == uVar3) { + if (iVar1 == 0) { + return 0; + } +LAB_2306d75c: + if (uVar3 != 0) { + puVar2 = (uint *)((int)__s1 + iVar1); + do { + __s1 = (char *)((int)__s1 + 1); + __s2 = (char *)((int)__s2 + 1); + uVar3 = (uint)(byte)*__s1; + uVar4 = (uint)(byte)*__s2; + if (uVar3 != uVar4) goto LAB_2306d788; + } while ((puVar2 != (uint *)__s1) && (*__s1 != 0)); + } + return 0; + } +LAB_2306d788: + return uVar3 - uVar4; +} + + + +char * strncpy(char *__dest,char *__src,size_t __n) + +{ + char cVar1; + uint uVar2; + uint *puVar3; + uint *puVar4; + char *pcVar5; + char *pcVar6; + char *pcVar7; + int iVar8; + + puVar3 = (uint *)__dest; + if (((((uint)__src | (uint)__dest) & 3) == 0) && (puVar4 = (uint *)__dest, 3 < __n)) { + do { + uVar2 = *(uint *)__src; + if ((uVar2 + 0xfefefeff & ~uVar2 & 0x80808080) != 0) goto LAB_2306d7c8; + puVar3 = puVar4 + 1; + __n = __n - 4; + *puVar4 = uVar2; + __src = (char *)((uint *)__src + 1); + puVar4 = puVar3; + } while (3 < __n); + } + puVar4 = puVar3; + if (__n != 0) { +LAB_2306d7c8: + cVar1 = *__src; + *(char *)puVar4 = cVar1; + pcVar5 = (char *)((int)puVar4 + 1); + iVar8 = __n - 1; + if (cVar1 != '\0') { + pcVar6 = pcVar5; + do { + __src = (char *)((int)__src + 1); + iVar8 = (__n - 1) - (int)pcVar6; + if (pcVar6 == (char *)((int)puVar4 + __n)) { + return __dest; + } + cVar1 = *__src; + pcVar5 = pcVar6 + 1; + *pcVar6 = cVar1; + pcVar6 = pcVar5; + iVar8 = (int)puVar4 + iVar8; + } while (cVar1 != '\0'); + } + pcVar6 = pcVar5; + if (iVar8 == 0) { + return __dest; + } + do { + pcVar7 = pcVar6 + 1; + *pcVar6 = '\0'; + pcVar6 = pcVar7; + } while (pcVar7 != pcVar5 + iVar8); + } + return __dest; +} + + + +size_t strnlen(char *__string,size_t __maxlen) + +{ + char *pcVar1; + + if (__maxlen != 0) { + if (*__string == '\0') { + __maxlen = 0; + } + else { + pcVar1 = __string; + while (pcVar1 = pcVar1 + 1, pcVar1 != __string + __maxlen) { + if (*pcVar1 == '\0') { + return (size_t)(pcVar1 + -(int)__string); + } + } + } + } + return __maxlen; +} + + + +char * strrchr(char *__s,int __c) + +{ + char *pcVar1; + char *pcVar2; + + if (__c != 0) { + pcVar2 = (char *)0x0; + while (pcVar1 = strchr(__s,__c), pcVar1 != (char *)0x0) { + __s = pcVar1 + 1; + pcVar2 = pcVar1; + } + return pcVar2; + } + pcVar2 = strchr(__s,0); + return pcVar2; +} + + + +byte * two_way_long_needle(int param_1,int param_2,byte *param_3,byte *param_4) + +{ + byte bVar1; + byte bVar2; + int iVar3; + size_t sVar4; + byte *pbVar5; + byte *pbVar6; + byte *__n; + byte *pbVar7; + byte *pbVar8; + byte **ppbVar9; + byte *pbVar10; + byte *pbVar11; + byte *pbVar12; + byte *pbVar13; + byte *pbVar14; + byte *local_440 [256]; + byte *apbStack64 [3]; + + pbVar13 = (byte *)0x1; + pbVar6 = (byte *)0x1; + __n = (byte *)0x0; + pbVar11 = (byte *)0xffffffff; + do { + pbVar14 = pbVar6 + (int)pbVar11; + pbVar10 = pbVar6 + (int)__n; + pbVar12 = __n; + while( true ) { + __n = pbVar10; + if (param_4 <= __n) { + pbVar6 = (byte *)0x1; + __n = (byte *)0x1; + pbVar14 = (byte *)0xffffffff; + pbVar12 = (byte *)0x0; + goto LAB_2306d9bc; + } + if (param_3[(int)pbVar14] <= param_3[(int)__n]) break; + pbVar6 = (byte *)0x1; + pbVar13 = __n + -(int)pbVar11; + pbVar14 = pbVar11 + 1; + pbVar10 = __n + 1; + pbVar12 = __n; + } + if (param_3[(int)__n] == param_3[(int)pbVar14]) { + if (pbVar6 == pbVar13) { + pbVar6 = (byte *)0x1; + } + else { + pbVar6 = pbVar6 + 1; + __n = pbVar12; + } + } + else { + pbVar13 = (byte *)0x1; + pbVar6 = (byte *)0x1; + __n = pbVar12 + 1; + pbVar11 = pbVar12; + } + } while( true ); +LAB_2306d9bc: + pbVar5 = __n + (int)pbVar14; + pbVar7 = __n + (int)pbVar12; + pbVar10 = pbVar12; + while (pbVar12 = pbVar7, pbVar12 < param_4) { + if (param_3[(int)pbVar12] <= param_3[(int)pbVar5]) goto LAB_2306db90; + __n = (byte *)0x1; + pbVar6 = pbVar12 + -(int)pbVar14; + pbVar5 = pbVar14 + 1; + pbVar7 = pbVar12 + 1; + pbVar10 = pbVar12; + } + __n = pbVar11 + 1; + if (pbVar11 + 1 <= pbVar14 + 1) { + pbVar13 = pbVar6; + __n = pbVar14 + 1; + } + ppbVar9 = local_440; + do { + *ppbVar9 = param_4; + ppbVar9 = ppbVar9 + 1; + } while (apbStack64 != ppbVar9); + pbVar11 = param_4 + -1; + pbVar6 = param_3; + if (param_4 != (byte *)0x0) { + do { + bVar1 = *pbVar6; + iVar3 = -(int)pbVar6; + pbVar6 = pbVar6 + 1; + local_440[bVar1] = param_3 + (int)(pbVar11 + iVar3); + } while (pbVar6 != param_3 + (int)param_4); + } + iVar3 = memcmp(param_3,param_3 + (int)pbVar13,(size_t)__n); + if (iVar3 != 0) { + pbVar13 = param_4 + -(int)__n; + if (param_4 + -(int)__n < __n) { + pbVar13 = __n; + } + pbVar6 = __n + -1; + pbVar12 = (byte *)0x0; +LAB_2306dc50: + pbVar14 = pbVar12 + param_1; + pbVar10 = local_440[pbVar11[(int)pbVar14]]; + if (pbVar10 == (byte *)0x0) goto LAB_2306dcb4; + do { + pbVar12 = pbVar10 + (int)pbVar12; + while( true ) { + if (pbVar12 <= (byte *)(param_2 - (int)param_4)) goto LAB_2306dc50; + sVar4 = strnlen((char *)(param_1 + param_2),(uint)param_4 | 0x800); + param_2 = param_2 + sVar4; + if ((byte *)(param_2 - (int)param_4) < pbVar12) { + return (byte *)0; + } + pbVar14 = pbVar12 + param_1; + pbVar10 = local_440[pbVar11[(int)pbVar14]]; + if (pbVar10 != (byte *)0x0) break; +LAB_2306dcb4: + if (__n < pbVar11) { + pbVar10 = __n; + if (__n[(int)pbVar14] == param_3[(int)__n]) { + do { + pbVar10 = pbVar10 + 1; + if (pbVar11 <= pbVar10) goto LAB_2306dcf4; + } while (param_3[(int)pbVar10] == pbVar10[(int)(pbVar12 + param_1)]); + } + pbVar12 = pbVar10 + (int)(pbVar12 + (1 - (int)__n)); + } + else { +LAB_2306dcf4: + if (pbVar6 == (byte *)0xffffffff) { + return pbVar14; + } + if (pbVar6[(int)pbVar14] == param_3[(int)pbVar6]) { + pbVar5 = param_3 + (int)(__n + -2); + pbVar10 = __n + -2 + (int)(pbVar12 + param_1); + do { + if (pbVar5 == param_3 + -1) { + return pbVar14; + } + bVar1 = *pbVar5; + bVar2 = *pbVar10; + pbVar5 = pbVar5 + -1; + pbVar10 = pbVar10 + -1; + } while (bVar1 == bVar2); + } + pbVar12 = pbVar13 + (int)(pbVar12 + 1); + } + } + } while( true ); + } + pbVar6 = __n + -1; + pbVar12 = (byte *)0x0; + pbVar14 = (byte *)0x0; + do { + pbVar5 = pbVar14 + param_1; + pbVar10 = local_440[pbVar11[(int)pbVar5]]; + if (pbVar10 == (byte *)0x0) { + pbVar10 = pbVar12; + if (pbVar12 < __n) { + pbVar10 = __n; + } + if (pbVar10 < pbVar11) { + pbVar7 = pbVar10 + (int)(pbVar14 + param_1); + pbVar8 = param_3 + (int)pbVar10; + do { + if (*pbVar7 != *pbVar8) { + pbVar14 = pbVar14 + (1 - (int)__n); + goto LAB_2306dac8; + } + pbVar10 = pbVar10 + 1; + pbVar7 = param_3 + (int)pbVar10; + pbVar8 = pbVar10 + (int)(pbVar14 + param_1); + } while (pbVar10 < pbVar11); + } + if ((pbVar12 < __n) && + (pbVar10 = pbVar6, pbVar6[(int)(pbVar14 + param_1)] == param_3[(int)pbVar6])) { + do { + pbVar7 = pbVar10; + pbVar10 = pbVar7 + -1; + if (pbVar12 == pbVar7) break; + } while (param_3[(int)pbVar10] == pbVar10[(int)(pbVar14 + param_1)]); + if (pbVar7 < pbVar12 + 1) { + return pbVar5; + } + } + else { + if (__n < pbVar12 + 1) { + return pbVar5; + } + } + pbVar14 = pbVar13 + (int)pbVar14; + pbVar12 = param_4 + -(int)pbVar13; + } + else { + if ((pbVar12 != (byte *)0x0) && (pbVar10 < pbVar13)) { + pbVar10 = param_4 + -(int)pbVar13; + } +LAB_2306dac8: + pbVar14 = pbVar10 + (int)pbVar14; + pbVar12 = (byte *)0x0; + } + if ((byte *)(param_2 - (int)param_4) < pbVar14) { + sVar4 = strnlen((char *)(param_1 + param_2),(uint)param_4 | 0x800); + param_2 = param_2 + sVar4; + if ((byte *)(param_2 - (int)param_4) < pbVar14) { + return (byte *)0; + } + } + } while( true ); +LAB_2306db90: + if (param_3[(int)pbVar12] == param_3[(int)pbVar5]) { + if (__n == pbVar6) { + __n = (byte *)0x1; + } + else { + __n = __n + 1; + pbVar12 = pbVar10; + } + } + else { + pbVar6 = (byte *)0x1; + __n = (byte *)0x1; + pbVar14 = pbVar10; + pbVar12 = pbVar10 + 1; + } + goto LAB_2306d9bc; +} + + + +char * strstr(char *__haystack,char *__needle) + +{ + byte bVar1; + byte bVar2; + char cVar3; + size_t __n; + size_t sVar4; + int iVar5; + uint __c; + char *pcVar6; + uint uVar7; + byte *pbVar8; + uint uVar9; + char *pcVar10; + byte abStack96 [68]; + + __c = (uint)(byte)*__needle; + if (*__needle != 0) { + uVar7 = (uint)(byte)__needle[1]; + if (__needle[1] == 0) { + __haystack = strchr(__haystack,__c); + } + else { + bVar1 = __needle[2]; + if (bVar1 == 0) { + uVar9 = (uint)(byte)*__haystack; + if (*__haystack != 0) { + bVar1 = __haystack[1]; + pcVar10 = __haystack + 1; + while (pcVar6 = pcVar10, uVar9 = (uint)bVar1 | uVar9 << 0x10, bVar1 != 0) { + bVar1 = pcVar6[1]; + pcVar10 = pcVar6 + 1; + if ((__c << 0x10 | uVar7) == uVar9) { + return pcVar6 + -1; + } + } + } + } + else { + if (__needle[3] == 0) { + if (*__haystack != 0) { + uVar9 = (uint)(byte)*__haystack << 8; + bVar2 = __haystack[1]; + pcVar10 = __haystack + 1; + while (pcVar6 = pcVar10, uVar9 = (bVar2 | uVar9) << 8, bVar2 != 0) { + bVar2 = pcVar6[1]; + pcVar10 = pcVar6 + 1; + if ((__c << 0x18 | uVar7 << 0x10 | (uint)bVar1 << 8) == uVar9) { + return pcVar6 + -2; + } + } + } + } + else { + if (__needle[4] == '\0') { + bVar2 = *__haystack; + __c = __c << 0x18 | uVar7 << 0x10 | (uint)(byte)__needle[3] | (uint)bVar1 << 8; + if (bVar2 != 0) { + uVar7 = 0; + do { + pcVar10 = __haystack; + uVar7 = (uint)bVar2 | uVar7 << 8; + bVar2 = pcVar10[1]; + if (bVar2 == 0) { + if (__c != uVar7) goto LAB_2306df5c; + break; + } + __haystack = pcVar10 + 1; + } while (__c != uVar7); + return pcVar10 + -3; + } + } + else { + __n = strlen(__needle); + sVar4 = strnlen(__haystack,__n | 0x200); + if (__n <= sVar4) { + if (0xfe < __n) { + pcVar10 = (char *)two_way_long_needle(__haystack,sVar4,__needle,__n); + return pcVar10; + } + pcVar10 = __haystack + (sVar4 - __n); + memset(abStack96,__n + 1,0x40); + if (__n != 0) { + pbVar8 = (byte *)__needle; + do { + bVar1 = *pbVar8; + cVar3 = (char)pbVar8; + pbVar8 = pbVar8 + 1; + abStack96[(uint)bVar1 & 0x3f] = ((char)__needle + (char)__n) - cVar3; + } while ((byte *)(__needle + __n) != pbVar8); + } + while( true ) { + __haystack = __haystack + -1 + abStack96[(uint)(byte)(__haystack + -1)[__n] & 0x3f]; + while (__haystack <= pcVar10) { + bVar1 = abStack96[(uint)(byte)__haystack[__n] & 0x3f]; + iVar5 = memcmp(__haystack,__needle,__n); + if (iVar5 == 0) { + return __haystack; + } + __haystack = __haystack + bVar1; + } + if (pcVar10[__n] == '\0') break; + sVar4 = strnlen(pcVar10 + __n,0x800); + pcVar10 = pcVar10 + sVar4; + if (pcVar10 < __haystack) { + return (char *)0x0; + } + } + } + } + } + } +LAB_2306df5c: + __haystack = (char *)0x0; + } + } + return __haystack; +} + + + +uint _strtol_l_isra_0(undefined4 *param_1,byte *param_2,byte **param_3,uint param_4) + +{ + byte bVar1; + bool bVar2; + uint uVar3; + byte *pbVar4; + uint uVar5; + byte *pbVar6; + uint uVar7; + uint uVar8; + int iVar9; + uint uVar10; + + pbVar6 = param_2; + do { + pbVar4 = pbVar6; + pbVar6 = pbVar4 + 1; + bVar1 = *pbVar4; + uVar7 = (uint)bVar1; + } while ((_ctype_[uVar7 + 1] & 8) != 0); + if (bVar1 == 0x2d) { + uVar7 = (uint)*pbVar6; + bVar2 = true; + pbVar6 = pbVar4 + 2; +LAB_2306e05c: + if (param_4 != 0) goto LAB_2306e060; +LAB_2306e0e4: + if (uVar7 != 0x30) { + uVar10 = 10; + param_4 = 10; + goto LAB_2306e06c; + } + if ((*pbVar6 & 0xdf) != 0x58) { + uVar10 = 8; + param_4 = 8; + goto LAB_2306e06c; + } + } + else { + if (bVar1 != 0x2b) { + bVar2 = false; + goto LAB_2306e05c; + } + uVar7 = (uint)*pbVar6; + bVar2 = false; + pbVar6 = pbVar4 + 2; + if (param_4 == 0) goto LAB_2306e0e4; +LAB_2306e060: + uVar10 = param_4; + if (param_4 != 0x10) goto LAB_2306e06c; + if ((uVar7 != 0x30) || ((*pbVar6 & 0xdf) != 0x58)) { + uVar10 = 0x10; + goto LAB_2306e06c; + } + } + uVar7 = (uint)pbVar6[1]; + uVar10 = 0x10; + pbVar6 = pbVar6 + 2; + param_4 = 0x10; +LAB_2306e06c: + uVar3 = 0x80000000; + if (!bVar2) { + uVar3 = 0x7fffffff; + } + iVar9 = 0; + uVar5 = 0; + do { + uVar8 = uVar7 - 0x30; + if (9 < uVar8) { + if (uVar7 - 0x41 < 0x1a) { + uVar8 = uVar7 - 0x37; + } + else { + if (0x19 < uVar7 - 0x61) break; + uVar8 = uVar7 - 0x57; + } + } + if ((int)param_4 <= (int)uVar8) break; + if (((iVar9 != -1) && (iVar9 = -1, uVar5 <= uVar3 / uVar10)) && + ((uVar3 / uVar10 != uVar5 || ((int)uVar8 <= (int)(uVar3 % uVar10))))) { + iVar9 = 1; + uVar5 = uVar8 + uVar10 * uVar5; + } + uVar7 = (uint)*pbVar6; + pbVar6 = pbVar6 + 1; + } while( true ); + if (iVar9 == -1) { + *param_1 = 0x22; + if (param_3 == (byte **)0x0) { + return uVar3; + } + } + else { + uVar3 = uVar5; + if (bVar2) { + uVar3 = -uVar5; + } + if (param_3 == (byte **)0x0) { + return uVar3; + } + if (iVar9 == 0) goto LAB_2306e120; + } + param_2 = pbVar6 + -1; +LAB_2306e120: + *param_3 = param_2; + return uVar3; +} + + + +uint _strtol_r(undefined4 *param_1,byte *param_2,byte **param_3,uint param_4) + +{ + byte bVar1; + bool bVar2; + uint uVar3; + byte *pbVar4; + uint uVar5; + byte *pbVar6; + uint uVar7; + uint uVar8; + int iVar9; + uint uVar10; + + pbVar6 = param_2; + do { + pbVar4 = pbVar6; + pbVar6 = pbVar4 + 1; + bVar1 = *pbVar4; + uVar7 = (uint)bVar1; + } while ((_ctype_[uVar7 + 1] & 8) != 0); + if (bVar1 == 0x2d) { + uVar7 = (uint)*pbVar6; + bVar2 = true; + pbVar6 = pbVar4 + 2; +LAB_2306e05c: + if (param_4 != 0) goto LAB_2306e060; +LAB_2306e0e4: + if (uVar7 != 0x30) { + uVar10 = 10; + param_4 = 10; + goto LAB_2306e06c; + } + if ((*pbVar6 & 0xdf) != 0x58) { + uVar10 = 8; + param_4 = 8; + goto LAB_2306e06c; + } + } + else { + if (bVar1 != 0x2b) { + bVar2 = false; + goto LAB_2306e05c; + } + uVar7 = (uint)*pbVar6; + bVar2 = false; + pbVar6 = pbVar4 + 2; + if (param_4 == 0) goto LAB_2306e0e4; +LAB_2306e060: + uVar10 = param_4; + if (param_4 != 0x10) goto LAB_2306e06c; + if ((uVar7 != 0x30) || ((*pbVar6 & 0xdf) != 0x58)) { + uVar10 = 0x10; + goto LAB_2306e06c; + } + } + uVar7 = (uint)pbVar6[1]; + uVar10 = 0x10; + pbVar6 = pbVar6 + 2; + param_4 = 0x10; +LAB_2306e06c: + uVar3 = 0x80000000; + if (!bVar2) { + uVar3 = 0x7fffffff; + } + iVar9 = 0; + uVar5 = 0; + do { + uVar8 = uVar7 - 0x30; + if (9 < uVar8) { + if (uVar7 - 0x41 < 0x1a) { + uVar8 = uVar7 - 0x37; + } + else { + if (0x19 < uVar7 - 0x61) break; + uVar8 = uVar7 - 0x57; + } + } + if ((int)param_4 <= (int)uVar8) break; + if (((iVar9 != -1) && (iVar9 = -1, uVar5 <= uVar3 / uVar10)) && + ((uVar3 / uVar10 != uVar5 || ((int)uVar8 <= (int)(uVar3 % uVar10))))) { + iVar9 = 1; + uVar5 = uVar8 + uVar10 * uVar5; + } + uVar7 = (uint)*pbVar6; + pbVar6 = pbVar6 + 1; + } while( true ); + if (iVar9 == -1) { + *param_1 = 0x22; + if (param_3 == (byte **)0x0) { + return uVar3; + } + } + else { + uVar3 = uVar5; + if (bVar2) { + uVar3 = -uVar5; + } + if (param_3 == (byte **)0x0) { + return uVar3; + } + if (iVar9 == 0) goto LAB_2306e120; + } + param_2 = pbVar6 + -1; +LAB_2306e120: + *param_3 = param_2; + return uVar3; +} + + + +long strtol_l(char *__nptr,char **__endptr,int __base,__locale_t __loc) + +{ + long lVar1; + + lVar1 = _strtol_l_isra_0(_impure_ptr,__nptr,__endptr,__base); + return lVar1; +} + + + +long strtol(char *__nptr,char **__endptr,int __base) + +{ + long lVar1; + + lVar1 = _strtol_l_isra_0(_impure_ptr,__nptr,__endptr,__base); + return lVar1; +} + + + +int stat(char *__file,stat *__buf) + +{ + int iVar1; + + iVar1 = _stat_r(_impure_ptr,__file,__buf); + return iVar1; +} + + + +void _stat_r(int *param_1,undefined4 param_2,undefined4 param_3) + +{ + int iVar1; + + errno = 0; + iVar1 = _stat(param_2,param_3); + if ((iVar1 == -1) && (errno != 0)) { + *param_1 = errno; + return; + } + return; +} + + + +int _stat(int param_1,undefined4 param_2) + +{ + int *piVar1; + undefined auStack144 [132]; + + ecall(); + if (param_1 < 0) { + piVar1 = (int *)__errno(auStack144,0,0,0,0,0x40e); + *piVar1 = -param_1; + param_1 = -1; + } + _conv_stat(param_2,auStack144); + return param_1; +} + + + +void _conv_stat(undefined2 *param_1,undefined4 *param_2) + +{ + undefined4 uVar1; + undefined4 uVar2; + undefined4 uVar3; + undefined4 uVar4; + undefined4 uVar5; + undefined4 uVar6; + undefined4 uVar7; + undefined4 uVar8; + undefined4 uVar9; + undefined4 uVar10; + undefined4 uVar11; + undefined4 uVar12; + undefined4 uVar13; + undefined4 uVar14; + undefined4 uVar15; + + uVar3 = param_2[5]; + uVar1 = param_2[6]; + uVar15 = param_2[7]; + uVar14 = param_2[8]; + uVar13 = param_2[0xc]; + uVar12 = param_2[0x10]; + uVar2 = param_2[0xe]; + uVar10 = param_2[0x12]; + uVar11 = param_2[0x13]; + uVar6 = param_2[0x16]; + uVar4 = param_2[4]; + uVar5 = param_2[2]; + uVar7 = param_2[0x17]; + uVar8 = param_2[0x1a]; + uVar9 = param_2[0x1b]; + *param_1 = (short)*param_2; + param_1[1] = (short)uVar5; + *(undefined4 *)(param_1 + 2) = uVar4; + param_1[4] = (short)uVar3; + param_1[5] = (short)uVar1; + param_1[6] = (short)uVar15; + param_1[7] = (short)uVar14; + *(undefined4 *)(param_1 + 8) = uVar13; + *(undefined4 *)(param_1 + 0x24) = uVar12; + *(undefined4 *)(param_1 + 0x22) = uVar2; + *(undefined4 *)(param_1 + 0xc) = uVar10; + *(undefined4 *)(param_1 + 0xe) = uVar11; + *(undefined4 *)(param_1 + 0x14) = uVar6; + *(undefined4 *)(param_1 + 0x16) = uVar7; + *(undefined4 *)(param_1 + 0x1c) = uVar8; + *(undefined4 *)(param_1 + 0x1e) = uVar9; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_On_BG(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4a0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010828)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_Off_BG(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4aa. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101082c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_On_LDO11_SOC(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4b4. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010830)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_Off_LDO11_SOC(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4be. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010834)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_On_LDO15_RF(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4c8. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010838)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_Off_LDO15_RF(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4d2. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101083c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_On_SFReg(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4dc. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010840)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_Off_SFReg(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4e6. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010844)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_LowPower_Enter_PDS0(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4f0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010848)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_LowPower_Exit_PDS0(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c4fa. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101084c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void ASM_Delay_Us(uint32_t core,uint32_t cnt) + +{ + // WARNING: Could not recover jumptable at 0x4200c504. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010850)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void BL602_Delay_US(uint32_t cnt) + +{ + // WARNING: Could not recover jumptable at 0x4200c50e. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010854)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void BL602_Delay_MS(uint32_t cnt) + +{ + // WARNING: Could not recover jumptable at 0x4200c518. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010858)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void * BL602_MemCpy(void *dst,void *src,uint32_t n) + +{ + void *pvVar1; + + // WARNING: Could not recover jumptable at 0x4200c522. Too many branches + // WARNING: Treating indirect jump as call + pvVar1 = (void *)(*_DAT_2101085c)(); + return pvVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t * BL602_MemCpy4(uint32_t *dst,uint32_t *src,uint32_t n) + +{ + uint32_t *puVar1; + + // WARNING: Could not recover jumptable at 0x4200c52c. Too many branches + // WARNING: Treating indirect jump as call + puVar1 = (uint32_t *)(*_DAT_21010860)(); + return puVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void * BL602_MemCpy_Fast(void *pdst,void *psrc,uint32_t n) + +{ + void *pvVar1; + + // WARNING: Could not recover jumptable at 0x4200c536. Too many branches + // WARNING: Treating indirect jump as call + pvVar1 = (void *)(*_DAT_21010864)(); + return pvVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void * BL602_MemSet(void *s,uint8_t c,uint32_t n) + +{ + void *pvVar1; + + // WARNING: Could not recover jumptable at 0x4200c540. Too many branches + // WARNING: Treating indirect jump as call + pvVar1 = (void *)(*_DAT_21010868)(); + return pvVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t * BL602_MemSet4(uint32_t *dst,uint32_t val,uint32_t n) + +{ + uint32_t *puVar1; + + // WARNING: Could not recover jumptable at 0x4200c54a. Too many branches + // WARNING: Treating indirect jump as call + puVar1 = (uint32_t *)(*_DAT_2101086c)(); + return puVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int BL602_MemCmp(void *s1,void *s2,uint32_t n) + +{ + int iVar1; + + // WARNING: Could not recover jumptable at 0x4200c554. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*_DAT_21010870)(); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Sw_AHB_Clk_0(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c55e. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010874)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Program_Efuse_0(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c568. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010878)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Load_Efuse_R0(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c572. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_2101087c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Sts_Type EF_Ctrl_Busy(void) + +{ + BL_Sts_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c57c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010880)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Sts_Type EF_Ctrl_AutoLoad_Done(void) + +{ + BL_Sts_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c586. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010884)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Clear(uint32_t index,uint32_t len) + +{ + // WARNING: Could not recover jumptable at 0x4200c590. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010894)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_SW_System_Reset(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c59a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108bc)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_SW_CPU_Reset(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5a4. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108c0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_SW_POR_Reset(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5ae. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108c4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Select_Internal_Flash(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5b8. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108c8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Select_External_Flash(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5c2. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108cc)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Deswap_Flash_Pin(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5cc. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108d0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Swap_Flash_Pin(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5d6. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108d4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_GPIO_Init(GLB_GPIO_Cfg_Type *cfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5e0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108d8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_GPIO_OUTPUT_Enable(GLB_GPIO_Type gpioPin) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5ea. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108dc)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_GPIO_OUTPUT_Disable(GLB_GPIO_Type gpioPin) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5f4. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108e0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_GPIO_Set_HZ(GLB_GPIO_Type gpioPin) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c5fe. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108e4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t GLB_GPIO_Get_Fun(GLB_GPIO_Type gpioPin) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c608. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_210108e8)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void HBN_Mode_Enter(HBN_APP_CFG_Type *cfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c612. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210108ec)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void HBN_Power_Down_Flash(SPI_Flash_Cfg_Type *flashCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c61c. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210108f0)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void HBN_Enable(uint8_t aGPIOIeCfg,HBN_LDO_LEVEL_Type ldoLevel,HBN_LEVEL_Type hbnLevel) + +{ + // WARNING: Could not recover jumptable at 0x4200c626. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210108f4)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Reset(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c630. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108f8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Set_Ldo11_Aon_Vout(HBN_LDO_LEVEL_Type ldoLevel) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c63a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108fc)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Set_Ldo11_Rt_Vout(HBN_LDO_LEVEL_Type ldoLevel) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c644. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010900)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Set_Ldo11_Soc_Vout(HBN_LDO_LEVEL_Type ldoLevel) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c64e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010904)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Hw_Pu_Pd_Cfg(uint8_t enable) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c658. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010924)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Pin_WakeUp_Mask(uint8_t maskVal) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c662. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010928)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +HBN_GPIO7_Dbg_Pull_Cfg(BL_Fun_Type pupdEn,BL_Fun_Type iesmtEn,BL_Fun_Type dlyEn,uint8_t dlySec) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c66c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101092c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Set_Embedded_Flash_Pullup(uint8_t enable) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c676. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010930)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type L1C_Set_Wrap(BL_Fun_Type wrap) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c680. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010934)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type L1C_Set_Way_Disable(uint8_t disableVal) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c68a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010938)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type L1C_IROM_2T_Access_Set(uint8_t enable) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c694. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101093c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Reset(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c69e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010940)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Force_Config(PDS_CTL2_Type_conflict4 *cfg2,PDS_CTL3_Type_conflict4 *cfg3) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c6a8. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010948)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_RAM_Config(PDS_RAM_CFG_Type_conflict1 *ramCfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c6b2. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101094c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +PDS_Default_Level_Config + (PDS_DEFAULT_LV_CFG_Type_conflict1 *defaultLvCfg,PDS_RAM_CFG_Type_conflict1 *ramCfg, + uint32_t pdsSleepCnt) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c6bc. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010950)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SEC_Eng_Turn_On_Sec_Ring(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c6c6. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010978)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SEC_Eng_Turn_Off_Sec_Ring(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c6d0. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_2101097c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Init(SF_Ctrl_Cfg_Type *pSfCtrlCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c6da. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010980)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_SetSPIMode(SF_Ctrl_Mode_Type mode) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c6e4. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010984)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Read_Reg(SPI_Flash_Cfg_Type *flashCfg,uint8_t regIndex,uint8_t *regValue,uint8_t regLen) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c6ee. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010988)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Write_Reg(SPI_Flash_Cfg_Type *flashCfg,uint8_t regIndex,uint8_t *regValue,uint8_t regLen) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c6f8. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101098c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Sts_Type SFlash_Busy(SPI_Flash_Cfg_Type *flashCfg) + +{ + BL_Sts_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c702. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010990)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Write_Enable(SPI_Flash_Cfg_Type *flashCfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c70c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010994)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Qspi_Enable(SPI_Flash_Cfg_Type *flashCfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c716. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010998)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Volatile_Reg_Write_Enable(SPI_Flash_Cfg_Type *flashCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c720. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_2101099c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Chip_Erase(SPI_Flash_Cfg_Type *flashCfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c72a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109a0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Sector_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t secNum) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c734. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109a4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Blk32_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t blkNum) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c73e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109a8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Blk64_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t blkNum) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c748. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109ac)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t startaddr,uint32_t endaddr) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c752. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109b0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Program(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint32_t addr,uint8_t *data, + uint32_t len) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c75c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109b4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_GetUniqueId(uint8_t *data,uint8_t idLen) + +{ + // WARNING: Could not recover jumptable at 0x4200c766. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109b8)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_GetJedecId(SPI_Flash_Cfg_Type *flashCfg,uint8_t *data) + +{ + // WARNING: Could not recover jumptable at 0x4200c770. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109bc)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_GetDeviceId(uint8_t *data) + +{ + // WARNING: Could not recover jumptable at 0x4200c77a. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109c0)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Powerdown(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c784. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109c4)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Releae_Powerdown(SPI_Flash_Cfg_Type *flashCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c78e. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109c8)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_SetBurstWrap(SPI_Flash_Cfg_Type *flashCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c798. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109cc)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_DisableBurstWrap(SPI_Flash_Cfg_Type *flashCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c7a2. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109d0)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Software_Reset(SPI_Flash_Cfg_Type *flashCfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c7ac. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109d4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Reset_Continue_Read(SPI_Flash_Cfg_Type *flashCfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c7b6. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109d8)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Set_IDbus_Cfg + (SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead,uint32_t addr, + uint32_t len) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c7c0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109dc)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_IDbus_Read_Enable(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c7ca. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109e0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Cache_Enable_Set(uint8_t wayDisable) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c7d4. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109e4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SFlash_Cache_Flush(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c7de. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109e8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Cache_Read_Enable + (SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead,uint8_t wayDisable) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c7e8. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109ec)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Cache_Hit_Count_Get(uint32_t *hitCountLow,uint32_t *hitCountHigh) + +{ + // WARNING: Could not recover jumptable at 0x4200c7f2. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109f0)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t SFlash_Cache_Miss_Count_Get(void) + +{ + uint32_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c7fc. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_210109f4)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SFlash_Cache_Read_Disable(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c806. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_210109f8)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Read(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead,uint32_t addr, + uint8_t *data,uint32_t len) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c810. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210109fc)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Read_Reg_With_Cmd + (SPI_Flash_Cfg_Type *flashCfg,uint8_t readRegCmd,uint8_t *regValue,uint8_t regLen) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c81a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a00)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +SFlash_Write_Reg_With_Cmd + (SPI_Flash_Cfg_Type *flashCfg,uint8_t writeRegCmd,uint8_t *regValue,uint8_t regLen) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c824. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a04)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Cfg_Init_Ext_Flash_Gpio(uint8_t extFlashPin) + +{ + // WARNING: Could not recover jumptable at 0x4200c82e. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a0c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Cfg_Init_Internal_Flash_Gpio(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c838. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a10)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Cfg_Deinit_Ext_Flash_Gpio(uint8_t extFlashPin) + +{ + // WARNING: Could not recover jumptable at 0x4200c842. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a14)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Cfg_Restore_GPIO17_Fun(uint8_t fun) + +{ + // WARNING: Could not recover jumptable at 0x4200c84c. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a18)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type SF_Cfg_Get_Flash_Cfg_Need_Lock(uint32_t flashID,SPI_Flash_Cfg_Type *pFlashCfg) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c856. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a1c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Cfg_Init_Flash_Gpio(uint8_t flashPinCfg,uint8_t restoreDefault) + +{ + // WARNING: Could not recover jumptable at 0x4200c860. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a20)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t SF_Cfg_Flash_Identify + (uint8_t callFromFlash,uint32_t autoScan,uint32_t flashPinCfg, + uint8_t restoreDefault,SPI_Flash_Cfg_Type *pFlashCfg) + +{ + undefined3 in_register_00002029; + uint32_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c86a. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010a24)(CONCAT31(in_register_00002029,callFromFlash)); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Enable(SF_Ctrl_Cfg_Type *cfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c874. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a28)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Select_Pad(SF_Ctrl_Pad_Sel sel) + +{ + // WARNING: Could not recover jumptable at 0x4200c87e. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a2c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Set_Owner(SF_Ctrl_Owner_Type owner) + +{ + // WARNING: Could not recover jumptable at 0x4200c888. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a30)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Disable(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c892. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a34)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Enable_BE(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c89c. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a38)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Enable_LE(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c8a6. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a3c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Set_Region + (uint8_t region,uint8_t enable,uint8_t hwKey,uint32_t startAddr,uint32_t endAddr, + uint8_t locked) + +{ + // WARNING: Could not recover jumptable at 0x4200c8b0. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a40)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Set_Key(uint8_t region,uint8_t *key,SF_Ctrl_AES_Key_Type keyType) + +{ + // WARNING: Could not recover jumptable at 0x4200c8ba. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a44)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Set_Key_BE(uint8_t region,uint8_t *key,SF_Ctrl_AES_Key_Type keyType) + +{ + // WARNING: Could not recover jumptable at 0x4200c8c4. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a48)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Set_IV(uint8_t region,uint8_t *iv,uint32_t addrOffset) + +{ + // WARNING: Could not recover jumptable at 0x4200c8ce. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a4c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Set_IV_BE(uint8_t region,uint8_t *iv,uint32_t addrOffset) + +{ + // WARNING: Could not recover jumptable at 0x4200c8d8. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a50)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Enable(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c8e2. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a54)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_AES_Disable(void) + +{ + // WARNING: Could not recover jumptable at 0x4200c8ec. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a58)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Set_Flash_Image_Offset(uint32_t addrOffset) + +{ + // WARNING: Could not recover jumptable at 0x4200c8f6. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a5c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t SF_Ctrl_Get_Flash_Image_Offset(void) + +{ + uint32_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c900. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010a60)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Select_Clock(SF_Ctrl_Sahb_Type sahbType) + +{ + // WARNING: Could not recover jumptable at 0x4200c90a. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a64)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_SendCmd(SF_Ctrl_Cmd_Cfg_Type *cfg) + +{ + // WARNING: Could not recover jumptable at 0x4200c914. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a68)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Icache_Set(SF_Ctrl_Cmd_Cfg_Type *cfg,uint8_t cmdValid) + +{ + // WARNING: Could not recover jumptable at 0x4200c91e. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a6c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Icache2_Set(SF_Ctrl_Cmd_Cfg_Type *cfg,uint8_t cmdValid) + +{ + // WARNING: Could not recover jumptable at 0x4200c928. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a70)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Sts_Type SF_Ctrl_GetBusyState(void) + +{ + BL_Sts_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c932. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a74)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t SF_Ctrl_Is_AES_Enable(void) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c93c. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010a78)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t SF_Ctrl_Get_Clock_Delay(void) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c946. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010a7c)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void SF_Ctrl_Set_Clock_Delay(uint8_t delay) + +{ + // WARNING: Could not recover jumptable at 0x4200c950. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010a80)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type XIP_SFlash_State_Save(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t *offset) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c95a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a84)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type XIP_SFlash_State_Restore(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t offset) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c964. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a88)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +XIP_SFlash_Erase_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t startaddr,uint32_t endaddr) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c96e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a8c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +XIP_SFlash_Write_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *data,uint32_t len) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c978. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a90)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +XIP_SFlash_Read_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *data,uint32_t len) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c982. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a94)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type XIP_SFlash_GetJedecId_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint8_t *data) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c98c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a98)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type XIP_SFlash_GetDeviceId_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint8_t *data) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c996. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010a9c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type +XIP_SFlash_GetUniqueId_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint8_t *data,uint8_t idLen) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c9a0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010aa0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type XIP_SFlash_Read_Via_Cache_Need_Lock(uint32_t addr,uint8_t *data,uint32_t len) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200c9aa. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010aa4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int XIP_SFlash_Read_With_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *dst,int len) + +{ + int iVar1; + + // WARNING: Could not recover jumptable at 0x4200c9b4. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*_DAT_21010aa8)(); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int XIP_SFlash_Write_With_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *src,int len) + +{ + int iVar1; + + // WARNING: Could not recover jumptable at 0x4200c9be. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*_DAT_21010aac)(); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +int XIP_SFlash_Erase_With_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,int len) + +{ + int iVar1; + + // WARNING: Could not recover jumptable at 0x4200c9c8. Too many branches + // WARNING: Treating indirect jump as call + iVar1 = (*_DAT_21010ab0)(); + return iVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void XIP_SFlash_Opt_Enter(uint8_t *aesEnable) + +{ + // WARNING: Could not recover jumptable at 0x4200c9d2. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010ab4)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void XIP_SFlash_Opt_Exit(uint8_t aesEnable) + +{ + // WARNING: Could not recover jumptable at 0x4200c9dc. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010ab8)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint32_t BFLB_Soft_CRC32(void *dataIn,uint32_t len) + +{ + uint32_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200c9e6. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010abc)(); + return uVar1; +} + + + +// WARNING: Control flow encountered bad instruction data + +BL_Err_Type ADC_Trim_TSEN(uint16_t *tsen_offset) + +{ + Efuse_TSEN_Refcode_Corner_Type_conflict trim; + + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); +} + + + +// WARNING: Control flow encountered bad instruction data + +BL_Err_Type ADC_Gain_Trim(void) + +{ + uint uVar1; + uint8_t a; + undefined3 extraout_var; + Efuse_ADC_Gain_Coeff_Type_conflict3 EStack36; + Efuse_ADC_Gain_Coeff_Type_conflict trim; + + EF_Ctrl_Read_ADC_Gain_Trim(&EStack36); + if ((int)EStack36 << 0x12 < 0) { + uVar1 = (uint)EStack36 >> 0xc; + a = EF_Ctrl_Get_Trim_Parity((uint)EStack36 & 0xfff,'\f'); + _a = (SFtype)CONCAT31(extraout_var,a); + if ((SFtype)(uVar1 & 1) == _a) { + adcGainCoeffCal.adcGainCoeffEnable = ENABLE; + adcGainCoeffCal.adcgainCoeffVal = SUB42(EStack36,0) & 0xfff; + if (((uint)EStack36 & 0x800) == 0) { + __extendsfdf2(_a); + __muldf3(); + __subdf3(); + } + else { + __extendsfdf2(_a); + __muldf3(); + __adddf3(); + } + __truncdfsf2(); + // WARNING: Bad instruction - Truncating control flow here + halt_baddata(); + } + } + return ERROR; +} + + + +uint8_t EF_Ctrl_Get_Trim_Parity(uint32_t val,uint8_t len) + +{ + undefined3 in_register_0000202d; + uint uVar1; + byte bVar2; + + uVar1 = 0; + bVar2 = 0; + while ((uVar1 & 0xff) < CONCAT31(in_register_0000202d,len)) { + if ((1 << (uVar1 & 0x1f) & val) != 0) { + bVar2 = bVar2 + 1; + } + uVar1 = uVar1 + 1; + } + return (uint8_t)(bVar2 & 1); +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Read_RC32M_Trim(Efuse_Ana_RC32M_Trim_Type_conflict1 *trim) + +{ + uint uVar1; + uint uVar2; + + EF_Ctrl_Sw_AHB_Clk_0(); + EF_Ctrl_Load_Efuse_R0(); + uVar1 = _DAT_4000700c; + uVar2 = _DAT_4000700c >> 10; + *(char *)trim = (char)uVar2; + *(uint *)trim = (uint)*trim & 0xfffffcff | uVar2 & 0x100 | uVar1 >> 10 & 0x200; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Read_RC32K_Trim(Efuse_Ana_RC32K_Trim_Type_conflict3 *trim) + +{ + EF_Ctrl_Sw_AHB_Clk_0(); + EF_Ctrl_Load_Efuse_R0(); + *(uint *)trim = + (uint)*trim & 0xfffff000 | _DAT_4000700c >> 0x14 & 0x3ff | _DAT_4000700c >> 0x14 & 0x400 | + (_DAT_4000700c >> 0x1f) << 0xb; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Read_TSEN_Trim(Efuse_TSEN_Refcode_Corner_Type_conflict3 *trim) + +{ + uint uVar1; + Efuse_TSEN_Refcode_Corner_Type_conflict3 EVar2; + uint uVar3; + uint uVar4; + + EF_Ctrl_Sw_AHB_Clk_0(); + EF_Ctrl_Load_Efuse_R0(); + uVar3 = (_DAT_40007078 & 1) << 0xd; + EVar2 = *trim; + *(uint *)trim = (uint)EVar2 & 0xffffdfff | uVar3; + uVar4 = _DAT_4000707c & 0xfff; + uVar1 = _DAT_4000707c & 0x1000; + *(uint *)trim = (uint)EVar2 & 0xffffc000 | uVar3 | uVar4 | uVar1; + *(uint *)trim = + (uint)EVar2 & 0xffff8000 | uVar3 | uVar4 | uVar1 | (_DAT_40007070 >> 0x1e & 1) << 0xe; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Read_ADC_Gain_Trim(Efuse_ADC_Gain_Coeff_Type_conflict3 *trim) + +{ + EF_Ctrl_Sw_AHB_Clk_0(); + EF_Ctrl_Load_Efuse_R0(); + *(uint *)trim = + (uint)*trim & 0xffffc000 | (_DAT_40007078 << 0x13) >> 0x14 | + (_DAT_40007078 >> 0xd & 1) << 0xc | (_DAT_40007078 >> 0xe & 1) << 0xd; + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_On_MBG(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cd8e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010810)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_Off_MBG(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cd98. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010814)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_On_XTAL(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cda2. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010818)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Set_Xtal_CapCode(uint8_t capIn,uint8_t capOut) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cdac. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101081c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t AON_Get_Xtal_CapCode(void) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200cdb6. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010820)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type AON_Power_Off_XTAL(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cdc0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010824)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t EF_Ctrl_Get_Trim_Parity(uint32_t val,uint8_t len) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200cdca. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_21010888)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Read_RC32M_Trim(Efuse_Ana_RC32M_Trim_Type_conflict4 *trim) + +{ + // WARNING: Could not recover jumptable at 0x4200cdd4. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_2101088c)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +void EF_Ctrl_Read_RC32K_Trim(Efuse_Ana_RC32K_Trim_Type_conflict6 *trim) + +{ + // WARNING: Could not recover jumptable at 0x4200cdde. Too many branches + // WARNING: Treating indirect jump as call + (*_DAT_21010890)(); + return; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +GLB_ROOT_CLK_Type GLB_Get_Root_CLK_Sel(void) + +{ + GLB_ROOT_CLK_Type GVar1; + + // WARNING: Could not recover jumptable at 0x4200cde8. Too many branches + // WARNING: Treating indirect jump as call + GVar1 = (*_DAT_21010898)(); + return GVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Set_System_CLK_Div(uint8_t hclkDiv,uint8_t bclkDiv) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cdf2. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101089c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t GLB_Get_BCLK_Div(void) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200cdfc. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_210108a0)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +uint8_t GLB_Get_HCLK_Div(void) + +{ + uint8_t uVar1; + + // WARNING: Could not recover jumptable at 0x4200ce06. Too many branches + // WARNING: Treating indirect jump as call + uVar1 = (*_DAT_210108a4)(); + return uVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type Update_SystemCoreClockWith_XTAL(GLB_PLL_XTAL_Type xtalType) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce10. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108a8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Set_System_CLK(GLB_PLL_XTAL_Type xtalType,GLB_SYS_CLK_Type clkFreq) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce1a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108ac)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type System_Core_Clock_Update_From_RC32M(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce24. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108b0)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Set_SF_CLK(uint8_t enable,GLB_SFLASH_CLK_Type clkSel,uint8_t div) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce2e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108b4)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type GLB_Set_PKA_CLK_Sel(GLB_PKA_CLK_Type clkSel) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce38. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_210108b8)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_32K_Sel(HBN_32K_CLK_Type clkType) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce42. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010908)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_Type rootClk) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce4c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101090c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Power_On_Xtal_32K(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce56. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010910)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Power_Off_Xtal_32K(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce60. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010914)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Power_On_RC32K(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce6a. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010918)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Power_Off_RC32K(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce74. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101091c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type HBN_Trim_RC32K(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce7e. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010920)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Trim_RC32M(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce88. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010954)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Select_RC32M_As_PLL_Ref(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce92. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010958)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Select_XTAL_As_PLL_Ref(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ce9c. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101095c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Power_On_PLL(PDS_PLL_XTAL_Type xtalType) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cea6. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010960)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Enable_PLL_All_Clks(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ceb0. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010964)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Disable_PLL_All_Clks(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ceba. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010968)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Enable_PLL_Clk(PDS_PLL_CLK_Type pllClk) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cec4. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_2101096c)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Disable_PLL_Clk(PDS_PLL_CLK_Type pllClk) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200cece. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010970)(); + return BVar1; +} + + + +// WARNING: Globals starting with '_' overlap smaller symbols at the same address + +BL_Err_Type PDS_Power_Off_PLL(void) + +{ + BL_Err_Type BVar1; + + // WARNING: Could not recover jumptable at 0x4200ced8. Too many branches + // WARNING: Treating indirect jump as call + BVar1 = (*_DAT_21010974)(); + return BVar1; +} + + diff --git a/blobs/sdk_app_ble_sync.ghidra.h b/blobs/sdk_app_ble_sync.ghidra.h new file mode 100755 index 0000000..326fd3f --- /dev/null +++ b/blobs/sdk_app_ble_sync.ghidra.h @@ -0,0 +1,39238 @@ +typedef unsigned char undefined; + +typedef unsigned char bool; +typedef unsigned char byte; +typedef unsigned int dword; +typedef long long longlong; +typedef unsigned long long qword; +typedef unsigned char uchar; +typedef unsigned int uint; +typedef unsigned long ulong; +typedef unsigned long long ulonglong; +typedef unsigned char undefined1; +typedef unsigned short undefined2; +typedef unsigned int undefined3; +typedef unsigned int undefined4; +typedef unsigned long long undefined5; +typedef unsigned long long undefined6; +typedef unsigned long long undefined7; +typedef unsigned long long undefined8; +typedef unsigned short ushort; +typedef unsigned short word; +#define unkbyte9 unsigned long long +#define unkbyte10 unsigned long long +#define unkbyte11 unsigned long long +#define unkbyte12 unsigned long long +#define unkbyte13 unsigned long long +#define unkbyte14 unsigned long long +#define unkbyte15 unsigned long long +#define unkbyte16 unsigned long long + +#define unkuint9 unsigned long long +#define unkuint10 unsigned long long +#define unkuint11 unsigned long long +#define unkuint12 unsigned long long +#define unkuint13 unsigned long long +#define unkuint14 unsigned long long +#define unkuint15 unsigned long long +#define unkuint16 unsigned long long + +#define unkint9 long long +#define unkint10 long long +#define unkint11 long long +#define unkint12 long long +#define unkint13 long long +#define unkint14 long long +#define unkint15 long long +#define unkint16 long long + +#define unkfloat1 float +#define unkfloat2 float +#define unkfloat3 float +#define unkfloat5 double +#define unkfloat6 double +#define unkfloat7 double +#define unkfloat9 long double +#define unkfloat11 long double +#define unkfloat12 long double +#define unkfloat13 long double +#define unkfloat14 long double +#define unkfloat15 long double +#define unkfloat16 long double + +#define BADSPACEBASE void +#define code void + +typedef struct stat stat, *Pstat; + +typedef ulonglong __u_quad_t; + +typedef __u_quad_t __dev_t; + +typedef ulong __ino_t; + +typedef uint __mode_t; + +typedef uint __nlink_t; + +typedef uint __uid_t; + +typedef uint __gid_t; + +typedef long __off_t; + +typedef long __blksize_t; + +typedef long __blkcnt_t; + +typedef struct timespec timespec, *Ptimespec; + +typedef long __time_t; + +struct timespec { + __time_t tv_sec; + long tv_nsec; +}; + +struct stat { + __dev_t st_dev; + ushort __pad1; + __ino_t st_ino; + __mode_t st_mode; + __nlink_t st_nlink; + __uid_t st_uid; + __gid_t st_gid; + __dev_t st_rdev; + ushort __pad2; + __off_t st_size; + __blksize_t st_blksize; + __blkcnt_t st_blocks; + struct timespec st_atim; + struct timespec st_mtim; + struct timespec st_ctim; + ulong __unused4; + ulong __unused5; +}; + +typedef undefined complex long double[32]; + +typedef qword complex float; + +typedef undefined complex double[16]; + +typedef bool _Bool; + +typedef struct trpc_env_tag trpc_env_tag, *Ptrpc_env_tag; + +typedef char int8_t; + +typedef short __int16_t; + +typedef __int16_t int16_t; + +struct trpc_env_tag { + int8_t power_dbm_max_rf; + int8_t power_dbm_min_rf; + int8_t power_dbm_lim_reg; + undefined field_0x3; + int16_t channel_freq; + int8_t temperature; + int8_t temperature_compensate; +}; + +typedef struct cfg80211_bss_select_adjust cfg80211_bss_select_adjust, *Pcfg80211_bss_select_adjust; + +typedef enum nl80211_band { + NL80211_BAND_2GHZ=0, + NL80211_BAND_5GHZ=1, + NL80211_BAND_60GHZ=2, + NUM_NL80211_BANDS=3 +} nl80211_band; + +typedef int8_t s8; + +struct cfg80211_bss_select_adjust { + enum nl80211_band band; + s8 delta; +}; + +typedef enum ieee80211_channel_flags { + IEEE80211_CHAN_DISABLED=1, + IEEE80211_CHAN_INDOOR_ONLY=512, + IEEE80211_CHAN_IR_CONCURRENT=1024, + IEEE80211_CHAN_NO_10MHZ=4096, + IEEE80211_CHAN_NO_160MHZ=256, + IEEE80211_CHAN_NO_20MHZ=2048, + IEEE80211_CHAN_NO_80MHZ=-128, + IEEE80211_CHAN_NO_HT40MINUS=32, + IEEE80211_CHAN_NO_HT40PLUS=16, + IEEE80211_CHAN_NO_IR=2, + IEEE80211_CHAN_NO_OFDM=64, + IEEE80211_CHAN_RADAR=8 +} ieee80211_channel_flags; + +typedef struct ieee80211_channel ieee80211_channel, *Pieee80211_channel; + +typedef ushort __uint16_t; + +typedef __uint16_t uint16_t; + +typedef uint16_t u16; + +typedef ulong __uint32_t; + +typedef __uint32_t uint32_t; + +typedef uint32_t u32; + +typedef enum nl80211_dfs_state { + NL80211_DFS_AVAILABLE=2, + NL80211_DFS_UNAVAILABLE=1, + NL80211_DFS_USABLE=0 +} nl80211_dfs_state; + +struct ieee80211_channel { + enum nl80211_band band; + undefined field_0x1; + u16 center_freq; + u16 hw_value; + undefined field_0x6; + undefined field_0x7; + u32 flags; + int max_antenna_gain; + int max_power; + int max_reg_power; + _Bool beacon_found; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; + u32 orig_flags; + int orig_mag; + int orig_mpwr; + enum nl80211_dfs_state dfs_state; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; + ulong dfs_state_entered; + uint dfs_cac_ms; +}; + +typedef struct ieee80211_dot_d ieee80211_dot_d, *Pieee80211_dot_d; + +struct ieee80211_dot_d { + char * code; + int channel_num; + struct ieee80211_channel * channels; +}; + +typedef struct cfg80211_connect_params cfg80211_connect_params, *Pcfg80211_connect_params; + +typedef uchar __uint8_t; + +typedef __uint8_t uint8_t; + +typedef uint8_t u8; + +typedef uint size_t; + +typedef enum nl80211_auth_type { + NL80211_AUTHTYPE_AUTOMATIC=8, + NL80211_AUTHTYPE_FILS_PK=7, + NL80211_AUTHTYPE_FILS_SK=5, + NL80211_AUTHTYPE_FILS_SK_PFS=6, + NL80211_AUTHTYPE_FT=2, + NL80211_AUTHTYPE_MAX=7, + NL80211_AUTHTYPE_NETWORK_EAP=3, + NL80211_AUTHTYPE_OPEN_SYSTEM=0, + NL80211_AUTHTYPE_SAE=4, + NL80211_AUTHTYPE_SHARED_KEY=1, + __NL80211_AUTHTYPE_NUM=8 +} nl80211_auth_type; + +typedef enum nl80211_mfp { + NL80211_MFP_NO=0, + NL80211_MFP_REQUIRED=1 +} nl80211_mfp; + +typedef struct cfg80211_crypto_settings cfg80211_crypto_settings, *Pcfg80211_crypto_settings; + +typedef struct ieee80211_ht_cap ieee80211_ht_cap, *Pieee80211_ht_cap; + +typedef struct cfg80211_bss_selection cfg80211_bss_selection, *Pcfg80211_bss_selection; + +typedef uint16_t __be16; + +typedef struct key_params key_params, *Pkey_params; + +typedef uint16_t __le16; + +typedef struct ieee80211_mcs_info ieee80211_mcs_info, *Pieee80211_mcs_info; + +typedef uint32_t __le32; + +typedef enum nl80211_bss_select_attr { + NL80211_BSS_SELECT_ATTR_BAND_PREF=2, + NL80211_BSS_SELECT_ATTR_MAX=3, + NL80211_BSS_SELECT_ATTR_RSSI=1, + NL80211_BSS_SELECT_ATTR_RSSI_ADJUST=3, + __NL80211_BSS_SELECT_ATTR_AFTER_LAST=4, + __NL80211_BSS_SELECT_ATTR_INVALID=0 +} nl80211_bss_select_attr; + +typedef union anon_union_for_param anon_union_for_param, *Panon_union_for_param; + +union anon_union_for_param { + enum nl80211_band band_pref; + struct cfg80211_bss_select_adjust adjust; +}; + +struct cfg80211_bss_selection { + enum nl80211_bss_select_attr behaviour; + union anon_union_for_param param; +}; + +struct cfg80211_crypto_settings { + u32 wpa_versions; + u32 cipher_group; + int n_ciphers_pairwise; + u32 ciphers_pairwise[5]; + int n_akm_suites; + u32 akm_suites[2]; + _Bool control_port; + undefined field_0x2d; + __be16 control_port_ethertype; + _Bool control_port_no_encrypt; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct key_params * wep_keys; + int wep_tx_key; +}; + +struct ieee80211_mcs_info { + u8 rx_mask[10]; + __le16 rx_highest; + u8 tx_params; + u8 reserved[3]; +}; + +struct ieee80211_ht_cap { + __le16 cap_info; + u8 ampdu_params_info; + undefined field_0x3; + struct ieee80211_mcs_info mcs; + __le16 extended_ht_cap_info; + undefined field_0x16; + undefined field_0x17; + __le32 tx_BF_cap_info; + u8 antenna_selection_info; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +struct cfg80211_connect_params { + struct ieee80211_channel channel; + struct ieee80211_channel * channel_hint; + u8 * bssid; + u8 * bssid_hint; + u8 * ssid; + size_t ssid_len; + enum nl80211_auth_type auth_type; + undefined field_0x49; + undefined field_0x4a; + undefined field_0x4b; + u8 * ie; + size_t ie_len; + _Bool privacy; + enum nl80211_mfp mfp; + undefined field_0x56; + undefined field_0x57; + struct cfg80211_crypto_settings crypto; + u8 * key; + u8 * pmk; + u8 key_len; + u8 pmk_len; + u8 key_idx; + undefined field_0x9f; + u32 flags; + int bg_scan_period; + struct ieee80211_ht_cap ht_capa; + struct ieee80211_ht_cap ht_capa_mask; + _Bool pbss; + struct cfg80211_bss_selection bss_select; + u8 * prev_bssid; +}; + +struct key_params { + u8 * key; + u8 * seq; + int key_len; + int seq_len; + u32 cipher; +}; + +typedef union anon_union.conflict13 anon_union.conflict13, *Panon_union.conflict13; + +union anon_union.conflict13 { + enum nl80211_band band_pref; + struct cfg80211_bss_select_adjust adjust; +}; + +typedef struct ieee80211_sta_ht_cap ieee80211_sta_ht_cap, *Pieee80211_sta_ht_cap; + +struct ieee80211_sta_ht_cap { + u16 cap; + _Bool ht_supported; + u8 ampdu_factor; + u8 ampdu_density; + undefined field_0x5; + struct ieee80211_mcs_info mcs; +}; + +typedef union anon_union.conflict17 anon_union.conflict17, *Panon_union.conflict17; + +union anon_union.conflict17 { + enum nl80211_band band_pref; + struct cfg80211_bss_select_adjust adjust; +}; + +typedef enum wiphy_flags { + WIPHY_FLAG_4ADDR_AP=32, + WIPHY_FLAG_4ADDR_STATION=64, + WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD=524288, + WIPHY_FLAG_AP_UAPSD=16384, + WIPHY_FLAG_CONTROL_PORT_PROTOCOL=-128, + WIPHY_FLAG_HAS_CHANNEL_SWITCH=8388608, + WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL=2097152, + WIPHY_FLAG_HAS_STATIC_WEP=16777216, + WIPHY_FLAG_HAVE_AP_SME=131072, + WIPHY_FLAG_IBSS_RSN=256, + WIPHY_FLAG_MESH_AUTH=1024, + WIPHY_FLAG_NETNS_OK=8, + WIPHY_FLAG_OFFCHAN_TX=1048576, + WIPHY_FLAG_PS_ON_BY_DEFAULT=16, + WIPHY_FLAG_REPORTS_OBSS=262144, + WIPHY_FLAG_SUPPORTS_5_10_MHZ=4194304, + WIPHY_FLAG_SUPPORTS_FW_ROAM=8192, + WIPHY_FLAG_SUPPORTS_SCHED_SCAN=2048, + WIPHY_FLAG_SUPPORTS_TDLS=-32768, + WIPHY_FLAG_TDLS_EXTERNAL_SETUP=65536 +} wiphy_flags; + +typedef enum KE_EVENT_STATUS { + KE_EVENT_ALREADY_EXISTS=4, + KE_EVENT_CAPA_EXCEEDED=3, + KE_EVENT_FAIL=1, + KE_EVENT_OK=0, + KE_EVENT_UNKNOWN=2 +} KE_EVENT_STATUS; + +typedef struct rx_msg_struct rx_msg_struct, *Prx_msg_struct; + +struct rx_msg_struct { + uint8_t pkt_type; + uint16_t src_id; + uint8_t * param; + uint8_t param_len; +}; + +typedef struct ble_ke_event_env_tag ble_ke_event_env_tag, *Pble_ke_event_env_tag; + +typedef void (* p_callback_t)(void); + +struct ble_ke_event_env_tag { + uint32_t event_field; + p_callback_t callback[10]; + uint8_t state; + undefined field_0x2d; + undefined field_0x2e; + undefined field_0x2f; +}; + +typedef struct ke_evt_tag ke_evt_tag, *Pke_evt_tag; + +struct ke_evt_tag { + void (* func)(int); + int param; +}; + +typedef struct cipher_key_buf cipher_key_buf, *Pcipher_key_buf; + +typedef struct cipher_key_buf cipher_key_buf_t; + +typedef struct cipher_key_t cipher_key_t, *Pcipher_key_t; + +typedef union ckd ckd, *Pckd; + +typedef struct eapolHskData_t eapolHskData_t, *PeapolHskData_t; + +typedef uchar UINT8; + +typedef struct KeyData_t KeyData_t, *PKeyData_t; + +typedef ulong UINT32; + +typedef ushort UINT16; + +struct KeyData_t { + UINT8 Key[16]; + UINT8 RxMICKey[8]; + UINT8 TxMICKey[8]; + UINT32 TxIV32; + UINT16 TxIV16; + UINT16 KeyIndex; +}; + +struct eapolHskData_t { + UINT8 ANonce[32]; + struct KeyData_t pwsKeyData; +}; + +union ckd { + struct eapolHskData_t hskData; +}; + +struct cipher_key_t { + union ckd ckd; +}; + +struct cipher_key_buf { + struct cipher_key_t cipher_key; +}; + +typedef void * __gnuc_va_list; + +typedef struct bt_dev bt_dev, *Pbt_dev; + +typedef struct bt_addr_le_t bt_addr_le_t, *Pbt_addr_le_t; + +typedef uint8_t u8_t; + +typedef uint16_t u16_t; + +typedef struct k_work k_work, *Pk_work; + +typedef int atomic_t; + +typedef struct bt_dev_le bt_dev_le, *Pbt_dev_le; + +typedef struct k_sem k_sem, *Pk_sem; + +typedef struct net_buf net_buf, *Pnet_buf; + +typedef struct k_fifo k_fifo, *Pk_fifo; + +typedef struct bt_hci_driver bt_hci_driver, *Pbt_hci_driver; + +typedef struct bt_addr_t bt_addr_t, *Pbt_addr_t; + +typedef ulonglong u64_t; + +typedef struct bl_hdl_t bl_hdl_t, *Pbl_hdl_t; + +typedef struct bl_hdl_t _sem_t; + +typedef struct _dnode _dnode, *P_dnode; + +typedef struct _dnode sys_dlist_t; + +typedef union anon_union_for_field_0 anon_union_for_field_0, *Panon_union_for_field_0; + +typedef union anon_union_for_field_4 anon_union_for_field_4, *Panon_union_for_field_4; + +typedef struct k_queue k_queue, *Pk_queue; + +typedef enum bt_hci_driver_bus { + BT_HCI_DRIVER_BUS_I2C=8, + BT_HCI_DRIVER_BUS_IPM=9, + BT_HCI_DRIVER_BUS_PCCARD=2, + BT_HCI_DRIVER_BUS_PCI=5, + BT_HCI_DRIVER_BUS_RS232=4, + BT_HCI_DRIVER_BUS_SDIO=6, + BT_HCI_DRIVER_BUS_SPI=7, + BT_HCI_DRIVER_BUS_UART=3, + BT_HCI_DRIVER_BUS_USB=1, + BT_HCI_DRIVER_BUS_VIRTUAL=0 +} bt_hci_driver_bus; + +typedef uint u32_t.conflict; + + +// WARNING! conflicting data type names: /DWARF/dlist.h/_dnode/anon_union_for_field_0 - /DWARF/buf.h/net_buf/anon_union_for_field_0 + +typedef union anon_union_for_field_1 anon_union_for_field_1, *Panon_union_for_field_1; + +typedef struct _snode _snode, *P_snode; + +typedef struct _snode sys_snode_t; + +typedef struct anon_struct.conflict6 anon_struct.conflict6, *Panon_struct.conflict6; + +typedef struct net_buf_simple net_buf_simple, *Pnet_buf_simple; + +union anon_union_for_field_1 { + struct _dnode * tail; + struct _dnode * prev; +}; + +struct _dnode { + union anon_union_for_field_0 field_0; + union anon_union_for_field_1 field_1; +}; + +struct k_queue { + void * hdl; + sys_dlist_t poll_events; +}; + +struct k_fifo { + struct k_queue _queue; +}; + +struct k_work { + void * _reserved; + void (* handler)(struct k_work *); + atomic_t flags[1]; +}; + +struct bl_hdl_t { + void * hdl; +}; + +struct k_sem { + _sem_t sem; + sys_dlist_t poll_events; +}; + +struct bt_dev_le { + u8_t features[8]; + u64_t states; + u16_t mtu; + undefined field_0x12; + undefined field_0x13; + struct k_sem pkts; + u8_t rl_size; + u8_t rl_entries; + u8_t wl_size; + u8_t wl_entries; + undefined field_0x24; + undefined field_0x25; + undefined field_0x26; + undefined field_0x27; +}; + +struct bt_addr_t { + u8_t val[6]; +}; + +struct bt_addr_le_t { + u8_t type; + struct bt_addr_t a; +}; + +struct bt_dev { + struct bt_addr_le_t id_addr[1]; + u8_t id_count; + u8_t adv_id; + struct bt_addr_le_t random_addr; + u8_t hci_version; + u8_t lmp_version; + u16_t hci_revision; + u16_t lmp_subversion; + u16_t manufacturer; + u8_t features[1][8]; + u8_t supported_commands[64]; + struct k_work init; + atomic_t flags[1]; + struct bt_dev_le le; + struct k_sem ncmd_sem; + struct net_buf * sent_cmd; + struct k_fifo cmd_tx_queue; + struct bt_hci_driver * drv; + char name[30]; + undefined field_0xd6; + undefined field_0xd7; +}; + +struct _snode { + struct _snode * next; +}; + +union anon_union_for_field_0 { + sys_snode_t node; +}; + +struct net_buf_simple { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +struct anon_struct.conflict6 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +union anon_union_for_field_4 { + struct anon_struct.conflict6 field_0; + struct net_buf_simple b; +}; + +struct net_buf { + union anon_union_for_field_0 field_0; + u8_t ref; + u8_t flags; + u8_t pool_id; + undefined field_0x7; + union anon_union_for_field_4 field_4; + u8_t user_data[10]; + undefined field_0x1e; + undefined field_0x1f; +}; + +struct bt_hci_driver { + char * name; + enum bt_hci_driver_bus bus; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + u32_t.conflict quirks; + int (* open)(void); + int (* send)(struct net_buf *); +}; + +typedef struct stats_mem stats_mem, *Pstats_mem; + +typedef u16_t mem_size_t; + +struct stats_mem { + u16_t err; + mem_size_t avail; + mem_size_t used; + mem_size_t max; + u16_t illegal; +}; + +typedef struct stats_proto stats_proto, *Pstats_proto; + +struct stats_proto { + u16_t xmit; + u16_t recv; + u16_t fw; + u16_t drop; + u16_t chkerr; + u16_t lenerr; + u16_t memerr; + u16_t rterr; + u16_t proterr; + u16_t opterr; + u16_t err; + u16_t cachehit; +}; + +typedef struct stats_ stats_, *Pstats_; + +typedef struct stats_igmp stats_igmp, *Pstats_igmp; + +typedef struct stats_sys stats_sys, *Pstats_sys; + +typedef struct stats_syselem stats_syselem, *Pstats_syselem; + +struct stats_igmp { + u16_t xmit; + u16_t recv; + u16_t drop; + u16_t chkerr; + u16_t lenerr; + u16_t memerr; + u16_t proterr; + u16_t rx_v1; + u16_t rx_group; + u16_t rx_general; + u16_t rx_report; + u16_t tx_join; + u16_t tx_leave; + u16_t tx_report; +}; + +struct stats_syselem { + u16_t used; + u16_t max; + u16_t err; +}; + +struct stats_sys { + struct stats_syselem sem; + struct stats_syselem mutex; + struct stats_syselem mbox; +}; + +struct stats_ { + struct stats_proto link; + struct stats_proto etharp; + struct stats_proto ip; + struct stats_proto icmp; + struct stats_igmp igmp; + struct stats_proto udp; + struct stats_proto tcp; + struct stats_mem mem; + undefined field_0xb6; + undefined field_0xb7; + struct stats_mem * memp[15]; + struct stats_sys sys; + undefined field_0x106; + undefined field_0x107; +}; + +typedef struct event_handler event_handler, *Pevent_handler; + +struct event_handler { + u8_t event; + u8_t min_len; + undefined field_0x2; + undefined field_0x3; + void (* handler)(struct net_buf *); +}; + +typedef struct bt_ad bt_ad, *Pbt_ad; + +typedef struct bt_data bt_data, *Pbt_data; + +struct bt_data { + u8_t type; + u8_t data_len; + undefined field_0x2; + undefined field_0x3; + u8_t * data; +}; + +struct bt_ad { + struct bt_data * data; + size_t len; +}; + +typedef struct cmd_data cmd_data, *Pcmd_data; + +typedef struct cmd_state_set cmd_state_set, *Pcmd_state_set; + +struct cmd_data { + u8_t status; + undefined field_0x1; + u16_t opcode; + struct cmd_state_set * state; + struct k_sem * sync; +}; + +struct cmd_state_set { + atomic_t * target; + int bit; + _Bool val; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct acl_data acl_data, *Pacl_data; + +struct acl_data { + u8_t type; + u8_t id; + u16_t handle; +}; + +typedef uchar uint8; + +typedef short SINT16; + +typedef enum Status_e { + FAIL=1, + FW_SUCCESS=0 +} Status_e; + +typedef long SINT32; + +typedef enum wlan_security_type { + WLAN_SECURITY_EAP_TLS=6, + WLAN_SECURITY_NONE=0, + WLAN_SECURITY_WEP_OPEN=1, + WLAN_SECURITY_WEP_SHARED=2, + WLAN_SECURITY_WILDCARD=7, + WLAN_SECURITY_WPA=3, + WLAN_SECURITY_WPA2=4, + WLAN_SECURITY_WPA_WPA2_MIXED=5 +} wlan_security_type; + +typedef char CHAR; + +typedef ushort uint16; + +typedef char SINT8; + +typedef void mdev_t; + +typedef ulong uint32; + +typedef ulonglong UINT64; + +typedef int BOOLEAN; + +typedef struct hw_rxhdr hw_rxhdr, *Phw_rxhdr; + +typedef struct hw_vect hw_vect, *Phw_vect; + +typedef long __int32_t; + +typedef __int32_t int32_t; + +typedef int32_t s32; + +struct hw_vect { + u32 len:16; + u32 reserved:8; + u32 mpdu_cnt:6; + u32 ampdu_cnt:2; + __le32 tsf_lo; + __le32 tsf_hi; + u32 leg_length:12; + u32 leg_rate:4; + u32 ht_length:16; + u32 _ht_length:4; + u32 short_gi:1; + u32 stbc:2; + u32 smoothing:1; + u32 mcs:7; + u32 pre_type:1; + u32 format_mod:3; + u32 ch_bw:2; + u32 n_sts:3; + u32 lsig_valid:1; + u32 sounding:1; + u32 num_extn_ss:2; + u32 aggregation:1; + u32 fec_coding:1; + u32 dyn_bw:1; + u32 doze_not_allowed:1; + u32 antenna_set:8; + u32 partial_aid:9; + u32 group_id:6; + u32 reserved_1c:1; + s32 rssi1:8; + s32 rssi2:8; + s32 rssi3:8; + s32 rssi4:8; + u32 reserved_1d:8; + u32 rcpi:8; + u32 evm1:8; + u32 evm2:8; + u32 evm3:8; + u32 evm4:8; + u32 reserved2b_1:8; + u32 reserved2b_2:8; + u32 reserved2b_3:8; + u32 rx_vect2_valid:1; + u32 resp_frame:1; + u32 decr_status:3; + u32 rx_fifo_oflow:1; + u32 undef_err:1; + u32 phy_err:1; + u32 fcs_err:1; + u32 addr_mismatch:1; + u32 ga_frame:1; + u32 current_ac:2; + u32 frm_successful_rx:1; + u32 desc_done_rx:1; + u32 key_sram_index:10; + u32 key_sram_v:1; + u32 type:2; + u32 subtype:4; +}; + +struct hw_rxhdr { + struct hw_vect hwvect; + u32 phy_band:8; + u32 phy_channel_type:8; + u32 phy_prim20_freq:16; + u32 phy_center1_freq:16; + u32 phy_center2_freq:16; + u32 flags_is_amsdu:1; + u32 flags_is_80211_mpdu:1; + u32 flags_is_4addr:1; + u32 flags_new_peer:1; + u32 flags_user_prio:3; + u32 flags_rsvd0:1; + u32 flags_vif_idx:8; + u32 flags_sta_idx:8; + u32 flags_dst_idx:8; + u32 pattern; + u32 payl_offset; + u32 reserved_pad[2]; + u32 wild[8]; +}; + +typedef struct sm_reason_code sm_reason_code, *Psm_reason_code; + +struct sm_reason_code { + uint16_t reason_code; + undefined field_0x2; + undefined field_0x3; + char * action; +}; + +typedef enum rx_status_bits { + RX_STAT_ALLOC=2, + RX_STAT_COPY=32, + RX_STAT_DELETE=4, + RX_STAT_ETH_LEN_UPDATE=16, + RX_STAT_FORWARD=1, + RX_STAT_LEN_UPDATE=8 +} rx_status_bits; + +typedef enum lld_util_instant_action { + LLD_UTIL_CHMAP_UPDATE=2, + LLD_UTIL_NO_ACTION=0, + LLD_UTIL_PARAM_UPDATE=1 +} lld_util_instant_action; + +typedef struct sha256_state sha256_state, *Psha256_state; + +struct sha256_state { + UINT64 length; + UINT32 state[8]; + UINT32 curlen; + UINT8 buf[64]; + undefined field_0x6c; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +typedef enum nl80211_iftype { + NL80211_IFTYPE_ADHOC=1, + NL80211_IFTYPE_AP=3, + NL80211_IFTYPE_AP_VLAN=4, + NL80211_IFTYPE_MAX=12, + NL80211_IFTYPE_MESH_POINT=7, + NL80211_IFTYPE_MONITOR=6, + NL80211_IFTYPE_NAN=12, + NL80211_IFTYPE_OCB=11, + NL80211_IFTYPE_P2P_CLIENT=8, + NL80211_IFTYPE_P2P_DEVICE=10, + NL80211_IFTYPE_P2P_GO=9, + NL80211_IFTYPE_STATION=2, + NL80211_IFTYPE_UNSPECIFIED=0, + NL80211_IFTYPE_WDS=5, + NUM_NL80211_IFTYPES=13 +} nl80211_iftype; + +typedef struct hci_le_rx_test_cmd hci_le_rx_test_cmd, *Phci_le_rx_test_cmd; + +struct hci_le_rx_test_cmd { + uint8_t rx_freq; +}; + +typedef struct hci_host_buf_size_cmd hci_host_buf_size_cmd, *Phci_host_buf_size_cmd; + +struct hci_host_buf_size_cmd { + uint16_t acl_pkt_len; + uint8_t sync_pkt_len; + undefined field_0x3; + uint16_t nb_acl_pkts; + uint16_t nb_sync_pkts; +}; + +typedef struct hci_rd_auth_payl_to_cmd hci_rd_auth_payl_to_cmd, *Phci_rd_auth_payl_to_cmd; + +struct hci_rd_auth_payl_to_cmd { + uint16_t conhdl; +}; + +typedef struct hci_le_rd_suggted_dft_data_len_cmd_cmp_evt hci_le_rd_suggted_dft_data_len_cmd_cmp_evt, *Phci_le_rd_suggted_dft_data_len_cmd_cmp_evt; + +struct hci_le_rd_suggted_dft_data_len_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t suggted_max_tx_octets; + uint16_t suggted_max_tx_time; +}; + +typedef struct hci_le_rd_rem_used_feats_cmd_cmp_evt hci_le_rd_rem_used_feats_cmd_cmp_evt, *Phci_le_rd_rem_used_feats_cmd_cmp_evt; + +typedef struct le_features le_features, *Ple_features; + +struct le_features { + uint8_t feats[8]; +}; + +struct hci_le_rd_rem_used_feats_cmd_cmp_evt { + uint8_t subcode; + uint8_t status; + uint16_t conhdl; + struct le_features feats_used; +}; + +typedef struct hci_rd_wlst_size_cmd_cmp_evt hci_rd_wlst_size_cmd_cmp_evt, *Phci_rd_wlst_size_cmd_cmp_evt; + +struct hci_rd_wlst_size_cmd_cmp_evt { + uint8_t status; + uint8_t wlst_size; +}; + +typedef struct hci_set_evt_mask_cmd hci_set_evt_mask_cmd, *Phci_set_evt_mask_cmd; + +typedef struct evt_mask evt_mask, *Pevt_mask; + +struct evt_mask { + uint8_t mask[8]; +}; + +struct hci_set_evt_mask_cmd { + struct evt_mask event_mask; +}; + +typedef struct hci_le_generate_dh_key_cmd hci_le_generate_dh_key_cmd, *Phci_le_generate_dh_key_cmd; + +struct hci_le_generate_dh_key_cmd { + uint8_t public_key[64]; +}; + +typedef struct hci_set_ctrl_to_host_flow_ctrl_cmd hci_set_ctrl_to_host_flow_ctrl_cmd, *Phci_set_ctrl_to_host_flow_ctrl_cmd; + +struct hci_set_ctrl_to_host_flow_ctrl_cmd { + uint8_t flow_cntl; +}; + +typedef struct hci_le_rem_con_param_req_neg_reply_cmd hci_le_rem_con_param_req_neg_reply_cmd, *Phci_le_rem_con_param_req_neg_reply_cmd; + +struct hci_le_rem_con_param_req_neg_reply_cmd { + uint16_t conhdl; + uint8_t reason; + undefined field_0x3; +}; + +typedef struct hci_basic_conhdl_cmd hci_basic_conhdl_cmd, *Phci_basic_conhdl_cmd; + +struct hci_basic_conhdl_cmd { + uint16_t conhdl; +}; + +typedef struct hci_rd_tx_pwr_lvl_cmd_cmp_evt hci_rd_tx_pwr_lvl_cmd_cmp_evt, *Phci_rd_tx_pwr_lvl_cmd_cmp_evt; + +struct hci_rd_tx_pwr_lvl_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; + uint8_t tx_pow_lvl; + undefined field_0x5; +}; + +typedef struct hci_rd_tx_pwr_lvl_cmd hci_rd_tx_pwr_lvl_cmd, *Phci_rd_tx_pwr_lvl_cmd; + +struct hci_rd_tx_pwr_lvl_cmd { + uint16_t conhdl; + uint8_t type; + undefined field_0x3; +}; + +typedef struct hci_basic_cmd_cmp_evt hci_basic_cmd_cmp_evt, *Phci_basic_cmd_cmp_evt; + +struct hci_basic_cmd_cmp_evt { + uint8_t status; +}; + +typedef struct hci_host_nb_cmp_pkts_cmd hci_host_nb_cmp_pkts_cmd, *Phci_host_nb_cmp_pkts_cmd; + +struct hci_host_nb_cmp_pkts_cmd { + uint8_t nb_of_hdl; + undefined field_0x1; + uint16_t con_hdl[3]; + uint16_t nb_comp_pkt[3]; +}; + +typedef struct hci_le_ltk_request_evt hci_le_ltk_request_evt, *Phci_le_ltk_request_evt; + +typedef struct rand_nb rand_nb, *Prand_nb; + +struct rand_nb { + uint8_t nb[8]; +}; + +struct hci_le_ltk_request_evt { + uint8_t subcode; + undefined field_0x1; + uint16_t conhdl; + struct rand_nb rand; + uint16_t ediv; +}; + +typedef struct hci_le_generate_dhkey_cmp_evt hci_le_generate_dhkey_cmp_evt, *Phci_le_generate_dhkey_cmp_evt; + +struct hci_le_generate_dhkey_cmp_evt { + uint8_t subcode; + uint8_t status; + uint8_t dh_key[32]; +}; + +typedef struct hci_le_ltk_req_reply_cmd hci_le_ltk_req_reply_cmd, *Phci_le_ltk_req_reply_cmd; + +typedef struct ltk ltk, *Pltk; + +struct ltk { + uint8_t ltk[16]; +}; + +struct hci_le_ltk_req_reply_cmd { + uint16_t conhdl; + struct ltk ltk; +}; + +typedef struct hci_rd_local_supp_cmds_cmd_cmp_evt hci_rd_local_supp_cmds_cmd_cmp_evt, *Phci_rd_local_supp_cmds_cmd_cmp_evt; + +typedef struct supp_cmds supp_cmds, *Psupp_cmds; + +struct supp_cmds { + uint8_t cmds[64]; +}; + +struct hci_rd_local_supp_cmds_cmd_cmp_evt { + uint8_t status; + struct supp_cmds local_cmds; +}; + +typedef struct hci_le_enc_cmd_cmp_evt hci_le_enc_cmd_cmp_evt, *Phci_le_enc_cmd_cmp_evt; + +struct hci_le_enc_cmd_cmp_evt { + uint8_t status; + uint8_t encrypted_data[16]; +}; + +typedef struct hci_le_set_scan_param_cmd hci_le_set_scan_param_cmd, *Phci_le_set_scan_param_cmd; + +struct hci_le_set_scan_param_cmd { + uint8_t scan_type; + undefined field_0x1; + uint16_t scan_intv; + uint16_t scan_window; + uint8_t own_addr_type; + uint8_t scan_filt_policy; +}; + +typedef struct hci_rd_local_supp_feats_cmd_cmp_evt hci_rd_local_supp_feats_cmd_cmp_evt, *Phci_rd_local_supp_feats_cmd_cmp_evt; + +typedef struct features features, *Pfeatures; + +struct features { + uint8_t feats[8]; +}; + +struct hci_rd_local_supp_feats_cmd_cmp_evt { + uint8_t status; + struct features feats; +}; + +typedef struct hci_le_rd_buff_size_cmd_cmp_evt hci_le_rd_buff_size_cmd_cmp_evt, *Phci_le_rd_buff_size_cmd_cmp_evt; + +struct hci_le_rd_buff_size_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t hc_data_pk_len; + uint8_t hc_tot_nb_data_pkts; + undefined field_0x5; +}; + +typedef struct hci_le_set_adv_param_cmd hci_le_set_adv_param_cmd, *Phci_le_set_adv_param_cmd; + +typedef struct bd_addr bd_addr, *Pbd_addr; + +struct bd_addr { + uint8_t addr[6]; +}; + +struct hci_le_set_adv_param_cmd { + uint16_t adv_intv_min; + uint16_t adv_intv_max; + uint8_t adv_type; + uint8_t own_addr_type; + uint8_t peer_addr_type; + struct bd_addr peer_addr; + uint8_t adv_chnl_map; + uint8_t adv_filt_policy; + undefined field_0xf; +}; + +typedef struct hci_le_rand_cmd_cmp_evt hci_le_rand_cmd_cmp_evt, *Phci_le_rand_cmd_cmp_evt; + +struct hci_le_rand_cmd_cmp_evt { + uint8_t status; + struct rand_nb nb; +}; + +typedef struct hci_rd_supp_states_cmd_cmp_evt hci_rd_supp_states_cmd_cmp_evt, *Phci_rd_supp_states_cmd_cmp_evt; + +typedef struct le_states le_states, *Ple_states; + +struct le_states { + uint8_t supp_states[8]; +}; + +struct hci_rd_supp_states_cmd_cmp_evt { + uint8_t status; + struct le_states states; +}; + +typedef struct hci_rd_rem_ver_info_cmp_evt hci_rd_rem_ver_info_cmp_evt, *Phci_rd_rem_ver_info_cmp_evt; + +struct hci_rd_rem_ver_info_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; + uint8_t vers; + undefined field_0x5; + uint16_t compid; + uint16_t subvers; +}; + +typedef struct hci_le_ch_sel_algo_evt hci_le_ch_sel_algo_evt, *Phci_le_ch_sel_algo_evt; + +struct hci_le_ch_sel_algo_evt { + uint8_t subcode; + undefined field_0x1; + uint16_t conhdl; + uint8_t chSel; + undefined field_0x5; +}; + +typedef struct hci_rd_auth_payl_to_cmd_cmp_evt hci_rd_auth_payl_to_cmd_cmp_evt, *Phci_rd_auth_payl_to_cmd_cmp_evt; + +struct hci_rd_auth_payl_to_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; + uint16_t auth_payl_to; +}; + +typedef enum hci_evt_code { + HCI_AUTH_CMP_EVT_CODE=6, + HCI_AUTH_PAYL_TO_EXP_EVT_CODE=87, + HCI_CHG_CON_LK_CMP_EVT_CODE=9, + HCI_CMD_CMP_EVT_CODE=14, + HCI_CMD_STATUS_EVT_CODE=15, + HCI_CON_CMP_EVT_CODE=3, + HCI_CON_PKT_TYPE_CHG_EVT_CODE=29, + HCI_CON_REQ_EVT_CODE=4, + HCI_CON_SLV_BCST_CH_MAP_CHG_EVT_CODE=85, + HCI_CON_SLV_BCST_REC_EVT_CODE=81, + HCI_CON_SLV_BCST_TO_EVT_CODE=82, + HCI_DATA_BUF_OVFLW_EVT_CODE=26, + HCI_DBG_META_EVT_CODE=-1, + HCI_DISC_CMP_EVT_CODE=5, + HCI_ENC_CHG_EVT_CODE=8, + HCI_ENC_KEY_REFRESH_CMP_EVT_CODE=48, + HCI_ENH_FLUSH_CMP_EVT_CODE=57, + HCI_EXT_INQ_RES_EVT_CODE=47, + HCI_FLOW_SPEC_CMP_EVT_CODE=33, + HCI_FLUSH_OCCURRED_EVT_CODE=17, + HCI_HW_ERR_EVT_CODE=16, + HCI_INQ_CMP_EVT_CODE=1, + HCI_INQ_RES_EVT_CODE=2, + HCI_INQ_RES_WITH_RSSI_EVT_CODE=34, + HCI_IO_CAP_REQ_EVT_CODE=49, + HCI_IO_CAP_RSP_EVT_CODE=50, + HCI_KEYPRESS_NOTIF_EVT_CODE=60, + HCI_LE_ADV_REPORT_EVT_SUBCODE=2, + HCI_LE_CH_SEL_ALGO_EVT_SUBCODE=20, + HCI_LE_CON_CMP_EVT_SUBCODE=1, + HCI_LE_CON_UPDATE_CMP_EVT_SUBCODE=3, + HCI_LE_DATA_LEN_CHG_EVT_SUBCODE=7, + HCI_LE_DIR_ADV_REP_EVT_SUBCODE=11, + HCI_LE_ENH_CON_CMP_EVT_SUBCODE=10, + HCI_LE_GEN_DHKEY_CMP_EVT_SUBCODE=9, + HCI_LE_LTK_REQUEST_EVT_SUBCODE=5, + HCI_LE_META_EVT_CODE=62, + HCI_LE_RD_LOC_P256_PUB_KEY_CMP_EVT_SUBCODE=8, + HCI_LE_RD_REM_USED_FEATS_CMP_EVT_SUBCODE=4, + HCI_LE_REM_CON_PARAM_REQ_EVT_SUBCODE=6, + HCI_LINK_SUPV_TO_CHG_EVT_CODE=56, + HCI_LK_NOTIF_EVT_CODE=24, + HCI_LK_REQ_EVT_CODE=23, + HCI_MASTER_LK_CMP_EVT_CODE=10, + HCI_MAX_EVT_MSK_PAGE_1_CODE=64, + HCI_MAX_EVT_MSK_PAGE_2_CODE=88, + HCI_MAX_SLOT_CHG_EVT_CODE=27, + HCI_MODE_CHG_EVT_CODE=20, + HCI_NB_CMP_PKTS_EVT_CODE=19, + HCI_PAGE_SCAN_REPET_MODE_CHG_EVT_CODE=32, + HCI_PIN_CODE_REQ_EVT_CODE=22, + HCI_QOS_SETUP_CMP_EVT_CODE=13, + HCI_QOS_VIOL_EVT_CODE=30, + HCI_RD_CLK_OFF_CMP_EVT_CODE=28, + HCI_RD_REM_EXT_FEATS_CMP_EVT_CODE=35, + HCI_RD_REM_SUPP_FEATS_CMP_EVT_CODE=11, + HCI_RD_REM_VER_INFO_CMP_EVT_CODE=12, + HCI_REM_HOST_SUPP_FEATS_NOTIF_EVT_CODE=61, + HCI_REM_NAME_REQ_CMP_EVT_CODE=7, + HCI_REM_OOB_DATA_REQ_EVT_CODE=53, + HCI_RETURN_LINK_KEYS_EVT_CODE=21, + HCI_ROLE_CHG_EVT_CODE=18, + HCI_SLV_PAGE_RSP_TO_EVT_CODE=84, + HCI_SNIFF_SUB_EVT_CODE=46, + HCI_SP_CMP_EVT_CODE=54, + HCI_SYNC_CON_CHG_EVT_CODE=45, + HCI_SYNC_CON_CMP_EVT_CODE=44, + HCI_SYNC_TRAIN_CMP_EVT_CODE=79, + HCI_SYNC_TRAIN_REC_EVT_CODE=80, + HCI_TRUNC_PAGE_CMP_EVT_CODE=83, + HCI_USER_CFM_REQ_EVT_CODE=51, + HCI_USER_PASSKEY_NOTIF_EVT_CODE=59, + HCI_USER_PASSKEY_REQ_EVT_CODE=52 +} hci_evt_code; + +typedef struct hci_enc_change_evt hci_enc_change_evt, *Phci_enc_change_evt; + +struct hci_enc_change_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; + uint8_t enc_stat; + undefined field_0x5; +}; + +typedef struct hci_le_set_host_ch_class_cmd hci_le_set_host_ch_class_cmd, *Phci_le_set_host_ch_class_cmd; + +typedef struct le_chnl_map le_chnl_map, *Ple_chnl_map; + +struct le_chnl_map { + uint8_t map[5]; +}; + +struct hci_le_set_host_ch_class_cmd { + struct le_chnl_map chmap; +}; + +typedef struct hci_le_set_scan_en_cmd hci_le_set_scan_en_cmd, *Phci_le_set_scan_en_cmd; + +struct hci_le_set_scan_en_cmd { + uint8_t scan_en; + uint8_t filter_duplic_en; +}; + +typedef struct hci_le_con_update_cmp_evt hci_le_con_update_cmp_evt, *Phci_le_con_update_cmp_evt; + +struct hci_le_con_update_cmp_evt { + uint8_t subcode; + uint8_t status; + uint16_t conhdl; + uint16_t con_interval; + uint16_t con_latency; + uint16_t sup_to; +}; + +typedef struct hci_le_create_con_cmd hci_le_create_con_cmd, *Phci_le_create_con_cmd; + +struct hci_le_create_con_cmd { + uint16_t scan_intv; + uint16_t scan_window; + uint8_t init_filt_policy; + uint8_t peer_addr_type; + struct bd_addr peer_addr; + uint8_t own_addr_type; + undefined field_0xd; + uint16_t con_intv_min; + uint16_t con_intv_max; + uint16_t con_latency; + uint16_t superv_to; + uint16_t ce_len_min; + uint16_t ce_len_max; +}; + +typedef struct hci_disconnect_cmd hci_disconnect_cmd, *Phci_disconnect_cmd; + +struct hci_disconnect_cmd { + uint16_t conhdl; + uint8_t reason; + undefined field_0x3; +}; + +typedef struct hci_nb_cmp_pkts_evt hci_nb_cmp_pkts_evt, *Phci_nb_cmp_pkts_evt; + +struct hci_nb_cmp_pkts_evt { + uint8_t nb_of_hdl; + undefined field_0x1; + uint16_t conhdl[1]; + uint16_t nb_comp_pkt[1]; +}; + +typedef struct hci_auth_payl_to_exp_evt hci_auth_payl_to_exp_evt, *Phci_auth_payl_to_exp_evt; + +struct hci_auth_payl_to_exp_evt { + uint16_t conhdl; +}; + +typedef struct hci_rd_local_ver_info_cmd_cmp_evt hci_rd_local_ver_info_cmd_cmp_evt, *Phci_rd_local_ver_info_cmd_cmp_evt; + +struct hci_rd_local_ver_info_cmd_cmp_evt { + uint8_t status; + uint8_t hci_ver; + uint16_t hci_rev; + uint8_t lmp_ver; + undefined field_0x5; + uint16_t manuf_name; + uint16_t lmp_subver; +}; + +typedef struct hci_le_rd_rem_used_feats_cmd hci_le_rd_rem_used_feats_cmd, *Phci_le_rd_rem_used_feats_cmd; + +struct hci_le_rd_rem_used_feats_cmd { + uint16_t conhdl; +}; + +typedef struct hci_le_data_len_chg_evt hci_le_data_len_chg_evt, *Phci_le_data_len_chg_evt; + +struct hci_le_data_len_chg_evt { + uint8_t subcode; + undefined field_0x1; + uint16_t conhdl; + uint16_t max_tx_octets; + uint16_t max_tx_time; + uint16_t max_rx_octets; + uint16_t max_rx_time; +}; + +typedef struct hci_le_set_data_len_cmd hci_le_set_data_len_cmd, *Phci_le_set_data_len_cmd; + +struct hci_le_set_data_len_cmd { + uint16_t conhdl; + uint16_t tx_octets; + uint16_t tx_time; +}; + +typedef struct hci_rd_bd_addr_cmd_cmp_evt hci_rd_bd_addr_cmd_cmp_evt, *Phci_rd_bd_addr_cmd_cmp_evt; + +struct hci_rd_bd_addr_cmd_cmp_evt { + uint8_t status; + struct bd_addr local_addr; +}; + +typedef struct hci_rd_adv_chnl_tx_pw_cmd_cmp_evt hci_rd_adv_chnl_tx_pw_cmd_cmp_evt, *Phci_rd_adv_chnl_tx_pw_cmd_cmp_evt; + +struct hci_rd_adv_chnl_tx_pw_cmd_cmp_evt { + uint8_t status; + int8_t adv_tx_pw_lvl; +}; + +typedef struct hci_le_wr_rfpath_cps_cmd hci_le_wr_rfpath_cps_cmd, *Phci_le_wr_rfpath_cps_cmd; + +struct hci_le_wr_rfpath_cps_cmd { + uint16_t rf_txpath_compensation_value; + uint16_t rf_rxpath_compensation_value; +}; + +typedef struct hci_le_set_evt_mask_cmd hci_le_set_evt_mask_cmd, *Phci_le_set_evt_mask_cmd; + +struct hci_le_set_evt_mask_cmd { + struct evt_mask le_mask; +}; + +typedef struct hci_basic_conhdl_cmd_cmp_evt hci_basic_conhdl_cmd_cmp_evt, *Phci_basic_conhdl_cmd_cmp_evt; + +struct hci_basic_conhdl_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; +}; + +typedef struct hci_rd_buff_size_cmd_cmp_evt hci_rd_buff_size_cmd_cmp_evt, *Phci_rd_buff_size_cmd_cmp_evt; + +struct hci_rd_buff_size_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t hc_data_pk_len; + uint8_t hc_sync_pk_len; + undefined field_0x5; + uint16_t hc_tot_nb_data_pkts; + uint16_t hc_tot_nb_sync_pkts; +}; + +typedef struct hci_wr_auth_payl_to_cmd_cmp_evt hci_wr_auth_payl_to_cmd_cmp_evt, *Phci_wr_auth_payl_to_cmd_cmp_evt; + +struct hci_wr_auth_payl_to_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; +}; + +typedef struct hci_le_tx_test_cmd hci_le_tx_test_cmd, *Phci_le_tx_test_cmd; + +struct hci_le_tx_test_cmd { + uint8_t tx_freq; + uint8_t test_data_len; + uint8_t pk_payload_type; +}; + +typedef struct hci_le_rd_local_supp_feats_cmd_cmp_evt hci_le_rd_local_supp_feats_cmd_cmp_evt, *Phci_le_rd_local_supp_feats_cmd_cmp_evt; + +struct hci_le_rd_local_supp_feats_cmd_cmp_evt { + uint8_t status; + struct le_features feats; +}; + +typedef struct hci_rd_rem_ver_info_cmd hci_rd_rem_ver_info_cmd, *Phci_rd_rem_ver_info_cmd; + +struct hci_rd_rem_ver_info_cmd { + uint16_t conhdl; +}; + +typedef struct hci_le_adv_report_evt hci_le_adv_report_evt, *Phci_le_adv_report_evt; + +typedef struct adv_report adv_report, *Padv_report; + +struct adv_report { + uint8_t evt_type; + uint8_t adv_addr_type; + struct bd_addr adv_addr; + uint8_t data_len; + uint8_t data[31]; + uint8_t rssi; +}; + +struct hci_le_adv_report_evt { + uint8_t subcode; + uint8_t nb_reports; + struct adv_report adv_rep[1]; +}; + +typedef struct hci_flush_cmd_cmp_evt hci_flush_cmd_cmp_evt, *Phci_flush_cmd_cmp_evt; + +struct hci_flush_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; +}; + +typedef struct hci_le_set_rand_addr_cmd hci_le_set_rand_addr_cmd, *Phci_le_set_rand_addr_cmd; + +struct hci_le_set_rand_addr_cmd { + struct bd_addr rand_addr; +}; + +typedef struct hci_le_start_enc_cmd hci_le_start_enc_cmd, *Phci_le_start_enc_cmd; + +struct hci_le_start_enc_cmd { + uint16_t conhdl; + struct rand_nb nb; + uint16_t enc_div; + struct ltk ltk; +}; + +typedef struct hci_test_end_cmd_cmp_evt hci_test_end_cmd_cmp_evt, *Phci_test_end_cmd_cmp_evt; + +struct hci_test_end_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t nb_packet_received; +}; + +typedef struct hci_disc_cmp_evt hci_disc_cmp_evt, *Phci_disc_cmp_evt; + +struct hci_disc_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; + uint8_t reason; + undefined field_0x5; +}; + +typedef enum hci_evt_mask_page { + HCI_PAGE_0=0, + HCI_PAGE_1=1, + HCI_PAGE_2=2, + HCI_PAGE_DFT=3 +} hci_evt_mask_page; + +typedef struct hci_vsc_set_tx_pwr_cmd hci_vsc_set_tx_pwr_cmd, *Phci_vsc_set_tx_pwr_cmd; + +struct hci_vsc_set_tx_pwr_cmd { + int8_t power; +}; + +typedef struct hci_le_set_scan_rsp_data_cmd hci_le_set_scan_rsp_data_cmd, *Phci_le_set_scan_rsp_data_cmd; + +typedef struct scan_rsp_data scan_rsp_data, *Pscan_rsp_data; + +struct scan_rsp_data { + uint8_t data[31]; +}; + +struct hci_le_set_scan_rsp_data_cmd { + uint8_t scan_rsp_data_len; + struct scan_rsp_data data; +}; + +typedef struct hci_enc_key_ref_cmp_evt hci_enc_key_ref_cmp_evt, *Phci_enc_key_ref_cmp_evt; + +struct hci_enc_key_ref_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; +}; + +typedef struct hci_le_rd_chnl_map_cmd_cmp_evt hci_le_rd_chnl_map_cmd_cmp_evt, *Phci_le_rd_chnl_map_cmd_cmp_evt; + +struct hci_le_rd_chnl_map_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; + struct le_chnl_map ch_map; + undefined field_0x9; +}; + +typedef struct hci_le_enh_con_cmp_evt hci_le_enh_con_cmp_evt, *Phci_le_enh_con_cmp_evt; + +struct hci_le_enh_con_cmp_evt { + uint8_t subcode; + uint8_t status; + uint16_t conhdl; + uint8_t role; + uint8_t peer_addr_type; + struct bd_addr peer_addr; + struct bd_addr loc_rslv_priv_addr; + struct bd_addr peer_rslv_priv_addr; + uint16_t con_interval; + uint16_t con_latency; + uint16_t sup_to; + uint8_t clk_accuracy; + undefined field_0x1f; +}; + +typedef struct hci_rd_rfpath_cps_cmd_cmp_evt hci_rd_rfpath_cps_cmd_cmp_evt, *Phci_rd_rfpath_cps_cmd_cmp_evt; + +struct hci_rd_rfpath_cps_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t rf_txpath_compensation_value; + uint16_t rf_rxpath_compensation_value; +}; + +typedef enum hci_opcode { + HCI_ACCEPT_CON_REQ_CMD_OPCODE=1033, + HCI_ACCEPT_SYNC_CON_REQ_CMD_OPCODE=1065, + HCI_AUTH_REQ_CMD_OPCODE=1041, + HCI_CHG_CON_LK_CMD_OPCODE=1045, + HCI_CHG_CON_PKT_TYPE_CMD_OPCODE=1039, + HCI_CREATE_CON_CANCEL_CMD_OPCODE=1032, + HCI_CREATE_CON_CMD_OPCODE=1029, + HCI_CREATE_NEW_UNIT_KEY_CMD_OPCODE=3083, + HCI_DBG_BLE_TST_LLCP_PT_EN_CMD_OPCODE=-958, + HCI_DBG_BLE_TST_SEND_LLCP_CMD_OPCODE=-957, + HCI_DBG_BT_SEND_LMP_CMD_OPCODE=-1010, + HCI_DBG_DEL_PAR_CMD_OPCODE=-1021, + HCI_DBG_ER_FLASH_CMD_OPCODE=-1018, + HCI_DBG_HW_REG_RD_CMD_OPCODE=-976, + HCI_DBG_HW_REG_WR_CMD_OPCODE=-975, + HCI_DBG_ID_FLASH_CMD_OPCODE=-1019, + HCI_DBG_LLCP_DISCARD_CMD_OPCODE=-970, + HCI_DBG_MWS_COEXTST_SCEN_CMD_OPCODE=-954, + HCI_DBG_MWS_COEX_CMD_OPCODE=-955, + HCI_DBG_PLF_RESET_CMD_OPCODE=-1007, + HCI_DBG_RD_FLASH_CMD_OPCODE=-1016, + HCI_DBG_RD_KE_STATS_CMD_OPCODE=-1008, + HCI_DBG_RD_MEM_CMD_OPCODE=-1023, + HCI_DBG_RD_MEM_INFO_CMD_OPCODE=-1006, + HCI_DBG_RD_PAR_CMD_OPCODE=-1015, + HCI_DBG_RESET_RX_CNT_CMD_OPCODE=-969, + HCI_DBG_RESET_TX_CNT_CMD_OPCODE=-968, + HCI_DBG_RF_CNTL_TX_CMD_OPCODE=-961, + HCI_DBG_RF_RD_DATA_RX_CMD_OPCODE=-962, + HCI_DBG_RF_REG_RD_CMD_OPCODE=-967, + HCI_DBG_RF_REG_WR_CMD_OPCODE=-966, + HCI_DBG_RF_SWITCH_CLK_CMD_OPCODE=-964, + HCI_DBG_RF_SYNC_P_CNTL_CMD_OPCODE=-960, + HCI_DBG_RF_WR_DATA_TX_CMD_OPCODE=-963, + HCI_DBG_SET_BD_ADDR_CMD_OPCODE=-974, + HCI_DBG_SET_CRC_CMD_OPCODE=-971, + HCI_DBG_SET_LOCAL_CLOCK_CMD_OPCODE=-1009, + HCI_DBG_SET_TX_PW_CMD_OPCODE=-965, + HCI_DBG_SET_TYPE_PUB_CMD_OPCODE=-973, + HCI_DBG_SET_TYPE_RAND_CMD_OPCODE=-972, + HCI_DBG_WLAN_COEXTST_SCEN_CMD_OPCODE=-1011, + HCI_DBG_WLAN_COEX_CMD_OPCODE=-1013, + HCI_DBG_WR_DLE_DFT_VALUE_CMD_OPCODE=-959, + HCI_DBG_WR_FLASH_CMD_OPCODE=-1017, + HCI_DBG_WR_MEM_CMD_OPCODE=-1022, + HCI_DBG_WR_PAR_CMD_OPCODE=-1014, + HCI_DEL_RES_LT_ADDR_CMD_OPCODE=3189, + HCI_DEL_STORED_LK_CMD_OPCODE=3090, + HCI_DISCONNECT_CMD_OPCODE=1030, + HCI_ENH_ACCEPT_SYNC_CON_CMD_OPCODE=1086, + HCI_ENH_FLUSH_CMD_OPCODE=3167, + HCI_ENH_SETUP_SYNC_CON_CMD_OPCODE=1085, + HCI_EN_DUT_MODE_CMD_OPCODE=6147, + HCI_EXIT_PARK_STATE_CMD_OPCODE=2054, + HCI_EXIT_PER_INQ_MODE_CMD_OPCODE=1028, + HCI_EXIT_SNIFF_MODE_CMD_OPCODE=2052, + HCI_FLOW_SPEC_CMD_OPCODE=2064, + HCI_FLUSH_CMD_OPCODE=3080, + HCI_GET_MWS_TRANSPORT_LAYER_CONFIG_CMD_OPCODE=5132, + HCI_HOLD_MODE_CMD_OPCODE=2049, + HCI_HOST_BUF_SIZE_CMD_OPCODE=3123, + HCI_HOST_NB_CMP_PKTS_CMD_OPCODE=3125, + HCI_INQ_CANCEL_CMD_OPCODE=1026, + HCI_INQ_CMD_OPCODE=1025, + HCI_IO_CAP_REQ_NEG_REPLY_CMD_OPCODE=1076, + HCI_IO_CAP_REQ_REPLY_CMD_OPCODE=1067, + HCI_LE_ADD_DEV_TO_RSLV_LIST_CMD_OPCODE=8231, + HCI_LE_ADD_DEV_TO_WLST_CMD_OPCODE=8209, + HCI_LE_CLEAR_RSLV_LIST_CMD_OPCODE=8233, + HCI_LE_CLEAR_WLST_CMD_OPCODE=8208, + HCI_LE_CON_UPDATE_CMD_OPCODE=8211, + HCI_LE_CREATE_CON_CANCEL_CMD_OPCODE=8206, + HCI_LE_CREATE_CON_CMD_OPCODE=8205, + HCI_LE_ENC_CMD_OPCODE=8215, + HCI_LE_GEN_DHKEY_CMD_OPCODE=8230, + HCI_LE_LTK_REQ_NEG_REPLY_CMD_OPCODE=8219, + HCI_LE_LTK_REQ_REPLY_CMD_OPCODE=8218, + HCI_LE_RAND_CMD_OPCODE=8216, + HCI_LE_RD_ADV_CHNL_TX_PW_CMD_OPCODE=8199, + HCI_LE_RD_BUFF_SIZE_CMD_OPCODE=8194, + HCI_LE_RD_CHNL_MAP_CMD_OPCODE=8213, + HCI_LE_RD_LOCAL_SUPP_FEATS_CMD_OPCODE=8195, + HCI_LE_RD_LOC_P256_PUB_KEY_CMD_OPCODE=8229, + HCI_LE_RD_LOC_RSLV_ADDR_CMD_OPCODE=8236, + HCI_LE_RD_MAX_DATA_LEN_CMD_OPCODE=8239, + HCI_LE_RD_PEER_RSLV_ADDR_CMD_OPCODE=8235, + HCI_LE_RD_REM_USED_FEATS_CMD_OPCODE=8214, + HCI_LE_RD_RFPATH_CPS_CMD_OPCODE=8268, + HCI_LE_RD_RSLV_LIST_SIZE_CMD_OPCODE=8234, + HCI_LE_RD_SUGGTED_DFT_DATA_LEN_CMD_OPCODE=8227, + HCI_LE_RD_SUPP_STATES_CMD_OPCODE=8220, + HCI_LE_RD_TRANS_PWR_CMD_OPCODE=8267, + HCI_LE_RD_WLST_SIZE_CMD_OPCODE=8207, + HCI_LE_REM_CON_PARAM_REQ_NEG_REPLY_CMD_OPCODE=8225, + HCI_LE_REM_CON_PARAM_REQ_REPLY_CMD_OPCODE=8224, + HCI_LE_RMV_DEV_FROM_RSLV_LIST_CMD_OPCODE=8232, + HCI_LE_RMV_DEV_FROM_WLST_CMD_OPCODE=8210, + HCI_LE_RX_TEST_CMD_OPCODE=8221, + HCI_LE_SET_ADDR_RESOL_EN_CMD_OPCODE=8237, + HCI_LE_SET_ADV_DATA_CMD_OPCODE=8200, + HCI_LE_SET_ADV_EN_CMD_OPCODE=8202, + HCI_LE_SET_ADV_PARAM_CMD_OPCODE=8198, + HCI_LE_SET_DATA_LEN_CMD_OPCODE=8226, + HCI_LE_SET_EVT_MASK_CMD_OPCODE=8193, + HCI_LE_SET_HOST_CH_CLASS_CMD_OPCODE=8212, + HCI_LE_SET_RAND_ADDR_CMD_OPCODE=8197, + HCI_LE_SET_RSLV_PRIV_ADDR_TO_CMD_OPCODE=8238, + HCI_LE_SET_SCAN_EN_CMD_OPCODE=8204, + HCI_LE_SET_SCAN_PARAM_CMD_OPCODE=8203, + HCI_LE_SET_SCAN_RSP_DATA_CMD_OPCODE=8201, + HCI_LE_START_ENC_CMD_OPCODE=8217, + HCI_LE_TEST_END_CMD_OPCODE=8223, + HCI_LE_TX_TEST_CMD_OPCODE=8222, + HCI_LE_WR_RFPATH_CPS_CMD_OPCODE=8269, + HCI_LE_WR_SUGGTED_DFT_DATA_LEN_CMD_OPCODE=8228, + HCI_LK_REQ_NEG_REPLY_CMD_OPCODE=1036, + HCI_LK_REQ_REPLY_CMD_OPCODE=1035, + HCI_MASTER_LK_CMD_OPCODE=1047, + HCI_NO_OPERATION_CMD_OPCODE=0, + HCI_PARK_STATE_CMD_OPCODE=2053, + HCI_PER_INQ_MODE_CMD_OPCODE=1027, + HCI_PIN_CODE_REQ_NEG_REPLY_CMD_OPCODE=1038, + HCI_PIN_CODE_REQ_REPLY_CMD_OPCODE=1037, + HCI_QOS_SETUP_CMD_OPCODE=2055, + HCI_RD_AFH_CH_ASSESS_MODE_CMD_OPCODE=3144, + HCI_RD_AFH_CH_MAP_CMD_OPCODE=5126, + HCI_RD_AUTH_EN_CMD_OPCODE=3103, + HCI_RD_AUTH_PAYL_TO_CMD_OPCODE=3195, + HCI_RD_AUTO_FLUSH_TO_CMD_OPCODE=3111, + HCI_RD_BD_ADDR_CMD_OPCODE=4105, + HCI_RD_BUFF_SIZE_CMD_OPCODE=4101, + HCI_RD_CLASS_OF_DEV_CMD_OPCODE=3107, + HCI_RD_CLK_CMD_OPCODE=5127, + HCI_RD_CLK_OFF_CMD_OPCODE=1055, + HCI_RD_CON_ACCEPT_TO_CMD_OPCODE=3093, + HCI_RD_CURR_IAC_LAP_CMD_OPCODE=3129, + HCI_RD_DFT_ERR_DATA_REP_CMD_OPCODE=3162, + HCI_RD_DFT_LINK_POL_STG_CMD_OPCODE=2062, + HCI_RD_ENC_KEY_SIZE_CMD_OPCODE=5128, + HCI_RD_ENH_TX_PWR_LVL_CMD_OPCODE=3176, + HCI_RD_EXT_INQ_LEN_CMD_OPCODE=3200, + HCI_RD_EXT_INQ_RSP_CMD_OPCODE=3153, + HCI_RD_EXT_PAGE_TO_CMD_OPCODE=3198, + HCI_RD_FAIL_CONTACT_CNT_CMD_OPCODE=5121, + HCI_RD_FLOW_CNTL_MODE_CMD_OPCODE=3174, + HCI_RD_HOLD_MODE_ACTIVITY_CMD_OPCODE=3115, + HCI_RD_INQ_MODE_CMD_OPCODE=3140, + HCI_RD_INQ_RSP_TX_PWR_LVL_CMD_OPCODE=3160, + HCI_RD_INQ_SCAN_ACT_CMD_OPCODE=3101, + HCI_RD_INQ_SCAN_TYPE_CMD_OPCODE=3138, + HCI_RD_LE_HOST_SUPP_CMD_OPCODE=3180, + HCI_RD_LINK_POL_STG_CMD_OPCODE=2060, + HCI_RD_LINK_QUAL_CMD_OPCODE=5123, + HCI_RD_LINK_SUPV_TO_CMD_OPCODE=3126, + HCI_RD_LMP_HDL_CMD_OPCODE=1056, + HCI_RD_LOCAL_EXT_FEATS_CMD_OPCODE=4100, + HCI_RD_LOCAL_NAME_CMD_OPCODE=3092, + HCI_RD_LOCAL_SUPP_CMDS_CMD_OPCODE=4098, + HCI_RD_LOCAL_SUPP_CODECS_CMD_OPCODE=4107, + HCI_RD_LOCAL_SUPP_FEATS_CMD_OPCODE=4099, + HCI_RD_LOCAL_VER_INFO_CMD_OPCODE=4097, + HCI_RD_LOC_OOB_DATA_CMD_OPCODE=3159, + HCI_RD_LOC_OOB_EXT_DATA_CMD_OPCODE=3197, + HCI_RD_LOOPBACK_MODE_CMD_OPCODE=6145, + HCI_RD_NB_BDCST_RETX_CMD_OPCODE=3113, + HCI_RD_NB_SUPP_IAC_CMD_OPCODE=3128, + HCI_RD_PAGE_SCAN_ACT_CMD_OPCODE=3099, + HCI_RD_PAGE_SCAN_TYPE_CMD_OPCODE=3142, + HCI_RD_PAGE_TO_CMD_OPCODE=3095, + HCI_RD_PIN_TYPE_CMD_OPCODE=3081, + HCI_RD_REM_EXT_FEATS_CMD_OPCODE=1052, + HCI_RD_REM_SUPP_FEATS_CMD_OPCODE=1051, + HCI_RD_REM_VER_INFO_CMD_OPCODE=1053, + HCI_RD_RSSI_CMD_OPCODE=5125, + HCI_RD_SCAN_EN_CMD_OPCODE=3097, + HCI_RD_SEC_CON_HOST_SUPP_CMD_OPCODE=3193, + HCI_RD_SP_MODE_CMD_OPCODE=3157, + HCI_RD_STORED_LK_CMD_OPCODE=3085, + HCI_RD_SYNC_FLOW_CTRL_EN_CMD_OPCODE=3118, + HCI_RD_SYNC_TRAIN_PARAM_CMD_OPCODE=3191, + HCI_RD_TX_PWR_LVL_CMD_OPCODE=3117, + HCI_RD_VOICE_STG_CMD_OPCODE=3109, + HCI_REC_SYNC_TRAIN_CMD_OPCODE=1092, + HCI_REFRESH_ENC_KEY_CMD_OPCODE=3155, + HCI_REJECT_CON_REQ_CMD_OPCODE=1034, + HCI_REJECT_SYNC_CON_REQ_CMD_OPCODE=1066, + HCI_REM_NAME_REQ_CANCEL_CMD_OPCODE=1050, + HCI_REM_NAME_REQ_CMD_OPCODE=1049, + HCI_REM_OOB_DATA_REQ_NEG_REPLY_CMD_OPCODE=1075, + HCI_REM_OOB_DATA_REQ_REPLY_CMD_OPCODE=1072, + HCI_REM_OOB_EXT_DATA_REQ_REPLY_CMD_OPCODE=1093, + HCI_RESET_CMD_OPCODE=3075, + HCI_ROLE_DISCOVERY_CMD_OPCODE=2057, + HCI_RST_FAIL_CONTACT_CNT_CMD_OPCODE=5122, + HCI_SEND_KEYPRESS_NOTIF_CMD_OPCODE=3168, + HCI_SETUP_SYNC_CON_CMD_OPCODE=1064, + HCI_SET_AFH_HOST_CH_CLASS_CMD_OPCODE=3135, + HCI_SET_CON_ENC_CMD_OPCODE=1043, + HCI_SET_CON_SLV_BCST_CMD_OPCODE=1089, + HCI_SET_CON_SLV_BCST_DATA_CMD_OPCODE=3190, + HCI_SET_CON_SLV_BCST_REC_CMD_OPCODE=1090, + HCI_SET_CTRL_TO_HOST_FLOW_CTRL_CMD_OPCODE=3121, + HCI_SET_EVT_FILTER_CMD_OPCODE=3077, + HCI_SET_EVT_MASK_CMD_OPCODE=3073, + HCI_SET_EVT_MASK_PAGE_2_CMD_OPCODE=3171, + HCI_SET_EXTERNAL_FRAME_CONFIG_CMD_OPCODE=3183, + HCI_SET_MWS_CHANNEL_PARAMS_CMD_OPCODE=3182, + HCI_SET_MWS_PATTERN_CONFIG_CMD_OPCODE=3187, + HCI_SET_MWS_SCAN_FREQ_TABLE_CMD_OPCODE=3186, + HCI_SET_MWS_SIGNALING_CMD_OPCODE=3184, + HCI_SET_MWS_TRANSPORT_LAYER_CMD_OPCODE=3185, + HCI_SET_RES_LT_ADDR_CMD_OPCODE=3188, + HCI_SET_TX_PWR_CMD_OPCODE=-927, + HCI_SNIFF_MODE_CMD_OPCODE=2051, + HCI_SNIFF_SUB_CMD_OPCODE=2065, + HCI_START_SYNC_TRAIN_CMD_OPCODE=1091, + HCI_SWITCH_ROLE_CMD_OPCODE=2059, + HCI_TESTER_SET_LE_PARAMS_CMD_OPCODE=-960, + HCI_TRUNC_PAGE_CAN_CMD_OPCODE=1088, + HCI_TRUNC_PAGE_CMD_OPCODE=1087, + HCI_USER_CFM_REQ_NEG_REPLY_CMD_OPCODE=1069, + HCI_USER_CFM_REQ_REPLY_CMD_OPCODE=1068, + HCI_USER_PASSKEY_REQ_NEG_REPLY_CMD_OPCODE=1071, + HCI_USER_PASSKEY_REQ_REPLY_CMD_OPCODE=1070, + HCI_VS_AUDIO_ALLOCATE_CMD_OPCODE=-944, + HCI_VS_AUDIO_CONFIGURE_CMD_OPCODE=-943, + HCI_VS_AUDIO_GET_BUFFER_RANGE_CMD_OPCODE=-939, + HCI_VS_AUDIO_RESET_CMD_OPCODE=-941, + HCI_VS_AUDIO_SET_MODE_CMD_OPCODE=-942, + HCI_VS_AUDIO_SET_POINTER_CMD_OPCODE=-940, + HCI_WR_AFH_CH_ASSESS_MODE_CMD_OPCODE=3145, + HCI_WR_AUTH_EN_CMD_OPCODE=3104, + HCI_WR_AUTH_PAYL_TO_CMD_OPCODE=3196, + HCI_WR_AUTO_FLUSH_TO_CMD_OPCODE=3112, + HCI_WR_CLASS_OF_DEV_CMD_OPCODE=3108, + HCI_WR_CON_ACCEPT_TO_CMD_OPCODE=3094, + HCI_WR_CURR_IAC_LAP_CMD_OPCODE=3130, + HCI_WR_DFT_ERR_DATA_REP_CMD_OPCODE=3163, + HCI_WR_DFT_LINK_POL_STG_CMD_OPCODE=2063, + HCI_WR_EXT_INQ_LEN_CMD_OPCODE=3201, + HCI_WR_EXT_INQ_RSP_CMD_OPCODE=3154, + HCI_WR_EXT_PAGE_TO_CMD_OPCODE=3199, + HCI_WR_FLOW_CNTL_MODE_CMD_OPCODE=3175, + HCI_WR_HOLD_MODE_ACTIVITY_CMD_OPCODE=3116, + HCI_WR_INQ_MODE_CMD_OPCODE=3141, + HCI_WR_INQ_SCAN_ACT_CMD_OPCODE=3102, + HCI_WR_INQ_SCAN_TYPE_CMD_OPCODE=3139, + HCI_WR_INQ_TX_PWR_LVL_CMD_OPCODE=3161, + HCI_WR_LE_HOST_SUPP_CMD_OPCODE=3181, + HCI_WR_LINK_POL_STG_CMD_OPCODE=2061, + HCI_WR_LINK_SUPV_TO_CMD_OPCODE=3127, + HCI_WR_LOCAL_NAME_CMD_OPCODE=3091, + HCI_WR_LOOPBACK_MODE_CMD_OPCODE=6146, + HCI_WR_NB_BDCST_RETX_CMD_OPCODE=3114, + HCI_WR_PAGE_SCAN_ACT_CMD_OPCODE=3100, + HCI_WR_PAGE_SCAN_TYPE_CMD_OPCODE=3143, + HCI_WR_PAGE_TO_CMD_OPCODE=3096, + HCI_WR_PIN_TYPE_CMD_OPCODE=3082, + HCI_WR_SCAN_EN_CMD_OPCODE=3098, + HCI_WR_SEC_CON_HOST_SUPP_CMD_OPCODE=3194, + HCI_WR_SEC_CON_TEST_MODE_CMD_OPCODE=6154, + HCI_WR_SP_DBG_MODE_CMD_OPCODE=6148, + HCI_WR_SP_MODE_CMD_OPCODE=3158, + HCI_WR_STORED_LK_CMD_OPCODE=3089, + HCI_WR_SYNC_FLOW_CTRL_EN_CMD_OPCODE=3119, + HCI_WR_SYNC_TRAIN_PARAM_CMD_OPCODE=3192, + HCI_WR_VOICE_STG_CMD_OPCODE=3110 +} hci_opcode; + +typedef struct hci_le_enc_cmd hci_le_enc_cmd, *Phci_le_enc_cmd; + +struct hci_le_enc_cmd { + struct ltk key; + uint8_t plain_data[16]; +}; + +typedef struct hci_rd_trans_pwr_cmd_cmp_evt hci_rd_trans_pwr_cmd_cmp_evt, *Phci_rd_trans_pwr_cmd_cmp_evt; + +struct hci_rd_trans_pwr_cmd_cmp_evt { + uint8_t status; + char min_tx_pwr; + char max_tx_pwr; +}; + +typedef struct hci_cmd_stat_event hci_cmd_stat_event, *Phci_cmd_stat_event; + +struct hci_cmd_stat_event { + uint8_t status; +}; + +typedef struct hci_le_rem_con_param_req_reply_cmd hci_le_rem_con_param_req_reply_cmd, *Phci_le_rem_con_param_req_reply_cmd; + +struct hci_le_rem_con_param_req_reply_cmd { + uint16_t conhdl; + uint16_t interval_min; + uint16_t interval_max; + uint16_t latency; + uint16_t timeout; + uint16_t min_ce_len; + uint16_t max_ce_len; +}; + +typedef struct hci_le_rem_con_param_req_evt hci_le_rem_con_param_req_evt, *Phci_le_rem_con_param_req_evt; + +struct hci_le_rem_con_param_req_evt { + uint8_t subcode; + undefined field_0x1; + uint16_t conhdl; + uint16_t interval_min; + uint16_t interval_max; + uint16_t latency; + uint16_t timeout; +}; + +typedef struct hci_le_add_dev_to_wlst_cmd hci_le_add_dev_to_wlst_cmd, *Phci_le_add_dev_to_wlst_cmd; + +struct hci_le_add_dev_to_wlst_cmd { + uint8_t dev_addr_type; + struct bd_addr dev_addr; +}; + +typedef struct hci_le_dir_adv_rep_evt hci_le_dir_adv_rep_evt, *Phci_le_dir_adv_rep_evt; + +typedef struct dir_adv_report dir_adv_report, *Pdir_adv_report; + +struct dir_adv_report { + uint8_t evt_type; + uint8_t addr_type; + struct bd_addr addr; + uint8_t dir_addr_type; + struct bd_addr dir_addr; + uint8_t rssi; +}; + +struct hci_le_dir_adv_rep_evt { + uint8_t subcode; + uint8_t nb_reports; + struct dir_adv_report adv_rep[1]; +}; + +typedef struct hci_le_set_adv_data_cmd hci_le_set_adv_data_cmd, *Phci_le_set_adv_data_cmd; + +typedef struct adv_data adv_data, *Padv_data; + +struct adv_data { + uint8_t data[31]; +}; + +struct hci_le_set_adv_data_cmd { + uint8_t adv_data_len; + struct adv_data data; +}; + +typedef struct hci_data_buf_ovflw_evt hci_data_buf_ovflw_evt, *Phci_data_buf_ovflw_evt; + +struct hci_data_buf_ovflw_evt { + uint8_t link_type; +}; + +typedef struct hci_wr_auth_payl_to_cmd hci_wr_auth_payl_to_cmd, *Phci_wr_auth_payl_to_cmd; + +struct hci_wr_auth_payl_to_cmd { + uint16_t conhdl; + uint16_t auth_payl_to; +}; + +typedef struct hci_rd_rssi_cmd_cmp_evt hci_rd_rssi_cmd_cmp_evt, *Phci_rd_rssi_cmd_cmp_evt; + +struct hci_rd_rssi_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t conhdl; + int8_t rssi; + undefined field_0x5; +}; + +typedef struct hci_acl_data_rx hci_acl_data_rx, *Phci_acl_data_rx; + +struct hci_acl_data_rx { + uint16_t conhdl; + uint8_t pb_bc_flag; + undefined field_0x3; + uint16_t length; + uint8_t rx_hdl; + undefined field_0x7; +}; + +typedef struct hci_le_set_adv_en_cmd hci_le_set_adv_en_cmd, *Phci_le_set_adv_en_cmd; + +struct hci_le_set_adv_en_cmd { + uint8_t adv_en; +}; + +typedef struct hci_le_wr_suggted_dft_data_len_cmd hci_le_wr_suggted_dft_data_len_cmd, *Phci_le_wr_suggted_dft_data_len_cmd; + +struct hci_le_wr_suggted_dft_data_len_cmd { + uint16_t suggted_max_tx_octets; + uint16_t suggted_max_tx_time; +}; + +typedef struct hci_le_generate_p256_public_key_cmp_evt hci_le_generate_p256_public_key_cmp_evt, *Phci_le_generate_p256_public_key_cmp_evt; + +typedef struct t_public_key t_public_key, *Pt_public_key; + +struct t_public_key { + uint8_t x[32]; + uint8_t y[32]; +}; + +struct hci_le_generate_p256_public_key_cmp_evt { + uint8_t subcode; + uint8_t status; + struct t_public_key public_key; +}; + +typedef struct hci_le_con_cmp_evt hci_le_con_cmp_evt, *Phci_le_con_cmp_evt; + +struct hci_le_con_cmp_evt { + uint8_t subcode; + uint8_t status; + uint16_t conhdl; + uint8_t role; + uint8_t peer_addr_type; + struct bd_addr peer_addr; + uint16_t con_interval; + uint16_t con_latency; + uint16_t sup_to; + uint8_t clk_accuracy; + undefined field_0x13; +}; + +typedef struct hci_le_con_update_cmd hci_le_con_update_cmd, *Phci_le_con_update_cmd; + +struct hci_le_con_update_cmd { + uint16_t conhdl; + uint16_t con_intv_min; + uint16_t con_intv_max; + uint16_t con_latency; + uint16_t superv_to; + uint16_t ce_len_min; + uint16_t ce_len_max; +}; + +typedef struct hci_acl_data_tx hci_acl_data_tx, *Phci_acl_data_tx; + +typedef struct em_buf_node em_buf_node, *Pem_buf_node; + +typedef struct co_list_hdr co_list_hdr, *Pco_list_hdr; + +struct co_list_hdr { + struct co_list_hdr * next; +}; + +struct hci_acl_data_tx { + uint16_t conhdl; + uint8_t pb_bc_flag; + undefined field_0x3; + uint16_t length; + undefined field_0x6; + undefined field_0x7; + struct em_buf_node * buf; +}; + +struct em_buf_node { + struct co_list_hdr hdr; + uint16_t idx; + uint16_t buf_ptr; +}; + +typedef struct hci_le_rd_max_data_len_cmd_cmp_evt hci_le_rd_max_data_len_cmd_cmp_evt, *Phci_le_rd_max_data_len_cmd_cmp_evt; + +struct hci_le_rd_max_data_len_cmd_cmp_evt { + uint8_t status; + undefined field_0x1; + uint16_t suppted_max_tx_octets; + uint16_t suppted_max_tx_time; + uint16_t suppted_max_rx_octets; + uint16_t suppted_max_rx_time; +}; + +typedef struct hci_flush_occurred_evt hci_flush_occurred_evt, *Phci_flush_occurred_evt; + +struct hci_flush_occurred_evt { + uint16_t conhdl; +}; + +typedef enum td_status_bit { + TD_STATUS_RX=1, + TD_STATUS_RX_PS=3, + TD_STATUS_TX=0, + TD_STATUS_TX_PS=2 +} td_status_bit; + +typedef struct td_env_tag td_env_tag, *Ptd_env_tag; + +typedef struct mm_timer_tag mm_timer_tag, *Pmm_timer_tag; + +struct mm_timer_tag { + struct co_list_hdr list_hdr; + void (* cb)(void *); + void * env; + uint32_t time; +}; + +struct td_env_tag { + struct mm_timer_tag td_timer; + uint32_t pck_cnt_tx; + uint32_t pck_cnt_rx; + uint32_t pck_cnt_tx_ps; + uint32_t pck_cnt_rx_ps; + uint8_t vif_index; + uint8_t status; + _Bool is_on; + _Bool has_active_chan; +}; + +typedef struct rw_task_msg_t rw_task_msg_t, *Prw_task_msg_t; + +struct rw_task_msg_t { + uint8_t msg_type; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + void * params; +}; + +typedef struct rwip_eif_api rwip_eif_api, *Prwip_eif_api; + +struct rwip_eif_api { + void (* read)(uint8_t *, uint32_t, void (* )(void *, uint8_t), void *); + void (* write)(uint8_t *, uint32_t, void (* )(void *, uint8_t), void *); + void (* flow_on)(void); + _Bool (* flow_off)(void); +}; + +typedef enum prevent_sleep { + RW_AHI_TIMEOUT=8, + RW_CRYPT_ONGOING=16, + RW_CSB_NOT_LPO_ALLOWED=64, + RW_DELETE_ELT_ONGOING=32, + RW_MWS_WLAN_EVENT_GENERATOR_ACTIVE=-128, + RW_TL_RX_ONGOING=4, + RW_TL_TX_ONGOING=2, + RW_WAKE_UP_ONGOING=1 +} prevent_sleep; + +typedef struct rwip_prio rwip_prio, *Prwip_prio; + +struct rwip_prio { + uint8_t value; + uint8_t increment; +}; + +typedef struct rwip_rf_api.conflict rwip_rf_api.conflict, *Prwip_rf_api.conflict; + +struct rwip_rf_api.conflict { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef enum rwip_eif_types { + RWIP_EIF_AHI=2, + RWIP_EIF_HCIC=0, + RWIP_EIF_HCIH=1 +} rwip_eif_types; + +typedef struct rwip_rf_api rwip_rf_api, *Prwip_rf_api; + +struct rwip_rf_api { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict10 rwip_rf_api.conflict10, *Prwip_rf_api.conflict10; + +struct rwip_rf_api.conflict10 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict11 rwip_rf_api.conflict11, *Prwip_rf_api.conflict11; + +struct rwip_rf_api.conflict11 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict12 rwip_rf_api.conflict12, *Prwip_rf_api.conflict12; + +struct rwip_rf_api.conflict12 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict9 rwip_rf_api.conflict9, *Prwip_rf_api.conflict9; + +struct rwip_rf_api.conflict9 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict8 rwip_rf_api.conflict8, *Prwip_rf_api.conflict8; + +struct rwip_rf_api.conflict8 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict7 rwip_rf_api.conflict7, *Prwip_rf_api.conflict7; + +struct rwip_rf_api.conflict7 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict6 rwip_rf_api.conflict6, *Prwip_rf_api.conflict6; + +struct rwip_rf_api.conflict6 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict1 rwip_rf_api.conflict1, *Prwip_rf_api.conflict1; + +struct rwip_rf_api.conflict1 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict13 rwip_rf_api.conflict13, *Prwip_rf_api.conflict13; + +struct rwip_rf_api.conflict13 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict14 rwip_rf_api.conflict14, *Prwip_rf_api.conflict14; + +struct rwip_rf_api.conflict14 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict15 rwip_rf_api.conflict15, *Prwip_rf_api.conflict15; + +struct rwip_rf_api.conflict15 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict16 rwip_rf_api.conflict16, *Prwip_rf_api.conflict16; + +struct rwip_rf_api.conflict16 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict5 rwip_rf_api.conflict5, *Prwip_rf_api.conflict5; + +struct rwip_rf_api.conflict5 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict17 rwip_rf_api.conflict17, *Prwip_rf_api.conflict17; + +struct rwip_rf_api.conflict17 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict4 rwip_rf_api.conflict4, *Prwip_rf_api.conflict4; + +struct rwip_rf_api.conflict4 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict18 rwip_rf_api.conflict18, *Prwip_rf_api.conflict18; + +struct rwip_rf_api.conflict18 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict3 rwip_rf_api.conflict3, *Prwip_rf_api.conflict3; + +struct rwip_rf_api.conflict3 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict19 rwip_rf_api.conflict19, *Prwip_rf_api.conflict19; + +struct rwip_rf_api.conflict19 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict2 rwip_rf_api.conflict2, *Prwip_rf_api.conflict2; + +struct rwip_rf_api.conflict2 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict20 rwip_rf_api.conflict20, *Prwip_rf_api.conflict20; + +struct rwip_rf_api.conflict20 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict21 rwip_rf_api.conflict21, *Prwip_rf_api.conflict21; + +struct rwip_rf_api.conflict21 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct rwip_rf_api.conflict22 rwip_rf_api.conflict22, *Prwip_rf_api.conflict22; + +struct rwip_rf_api.conflict22 { + void (* reset)(void); + void (* force_agc_enable)(_Bool); + _Bool (* txpwr_dec)(uint8_t); + _Bool (* txpwr_inc)(uint8_t); + void (* txpwr_max_set)(int8_t); + uint8_t (* txpwr_dbm_get)(uint8_t, uint8_t); + uint8_t (* txpwr_cs_get)(int8_t); + int8_t (* rssi_convert)(uint8_t); + uint32_t (* reg_rd)(uint16_t); + void (* reg_wr)(uint16_t, uint32_t); + void (* sleep)(void); + uint8_t txpwr_max; + int8_t rssi_high_thr; + int8_t rssi_low_thr; + int8_t rssi_interf_thr; + uint8_t wakeup_delay; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef enum rw_task_msg_type { + FW_TO_FW_MSG=2, + HOST_TO_FW_MSG=1 +} rw_task_msg_type; + +typedef struct rwip_time_t rwip_time_t, *Prwip_time_t; + +struct rwip_time_t { + uint32_t time; + uint32_t next_tick; +}; + +typedef struct rwip_env_tag rwip_env_tag, *Prwip_env_tag; + +struct rwip_env_tag { + uint32_t lp_cycle_wakeup_delay; + uint32_t sleep_acc_error; + uint16_t sleep_algo_dur; + uint16_t prevent_sleep; + _Bool sleep_enable; + _Bool ext_wakeup_enable; + undefined field_0xe; + undefined field_0xf; +}; + +typedef enum flag { + FL_HASH=32, + FL_MINUS=2, + FL_PLUS=4, + FL_SIGNED=64, + FL_SPACE=16, + FL_TICK=8, + FL_UPPER=-128, + FL_ZERO=1 +} flag; + +typedef enum ranks { + rank_char=-2, + rank_int=0, + rank_long=1, + rank_longlong=2, + rank_short=-1 +} ranks; + +typedef enum anon_enum_8 { + st_flags=1, + st_modifiers=4, + st_normal=0, + st_prec=3, + st_width=2 +} anon_enum_8; + +typedef struct tmrTimerControl tmrTimerControl, *PtmrTimerControl; + +typedef struct tmrTimerControl * TimerHandle_t; + +typedef struct xLIST_ITEM xLIST_ITEM, *PxLIST_ITEM; + +typedef struct xLIST_ITEM ListItem_t; + +typedef uint32_t TickType_t; + +typedef uint32_t UBaseType_t; + +typedef struct xLIST xLIST, *PxLIST; + +typedef struct xMINI_LIST_ITEM xMINI_LIST_ITEM, *PxMINI_LIST_ITEM; + +typedef struct xMINI_LIST_ITEM MiniListItem_t; + +struct xMINI_LIST_ITEM { + TickType_t xItemValue; + struct xLIST_ITEM * pxNext; + struct xLIST_ITEM * pxPrevious; +}; + +struct xLIST { + UBaseType_t uxNumberOfItems; + ListItem_t * pxIndex; + MiniListItem_t xListEnd; +}; + +struct xLIST_ITEM { + TickType_t xItemValue; + struct xLIST_ITEM * pxNext; + struct xLIST_ITEM * pxPrevious; + void * pvOwner; + struct xLIST * pvContainer; +}; + +struct tmrTimerControl { + char * pcTimerName; + ListItem_t xTimerListItem; + TickType_t xTimerPeriodInTicks; + void * pvTimerID; + void (* pxCallbackFunction)(TimerHandle_t); + UBaseType_t uxTimerNumber; + uint8_t ucStatus; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct scanu_env_tag.conflict3 scanu_env_tag.conflict3, *Pscanu_env_tag.conflict3; + +typedef struct scanu_start_req scanu_start_req, *Pscanu_start_req; + +typedef struct hal_dma_desc_tag hal_dma_desc_tag, *Phal_dma_desc_tag; + +typedef struct mac_scan_result mac_scan_result, *Pmac_scan_result; + +typedef uint16_t ke_task_id_t; + +typedef struct mac_addr.conflict171 mac_addr.conflict171, *Pmac_addr.conflict171; + +typedef struct mac_ssid mac_ssid, *Pmac_ssid; + +typedef struct scan_chan_tag scan_chan_tag, *Pscan_chan_tag; + +typedef struct mac_addr mac_addr, *Pmac_addr; + +typedef uint32_t u32_l; + +typedef uint16_t u16_l; + +typedef uint8_t u8_l; + +typedef struct dma_desc dma_desc, *Pdma_desc; + +typedef struct mac_addr.conflict41 mac_addr.conflict41, *Pmac_addr.conflict41; + +typedef int8_t s8_l; + +struct mac_addr.conflict171 { + uint16_t array[3]; +}; + +struct mac_addr.conflict41 { + uint16_t array[3]; +}; + +struct hal_dma_desc_tag { + struct co_list_hdr hdr; + struct dma_desc * dma_desc; + void (* cb)(void *, int); + void * env; +}; + +struct scan_chan_tag { + u16_l freq; + u8_l band; + u8_l flags; + s8_l tx_power; + undefined field_0x5; +}; + +struct mac_ssid { + u8_l length; + u8_l array[32]; + u8_l array_tail[1]; +}; + +struct mac_scan_result { + struct mac_addr.conflict41 bssid; + struct mac_ssid ssid; + uint16_t bsstype; + undefined field_0x2a; + undefined field_0x2b; + struct scan_chan_tag * chan; + uint16_t beacon_period; + uint16_t cap_info; + _Bool valid_flag; + int8_t rssi; + int8_t ppm_rel; + int8_t ppm_abs; +}; + +struct scanu_env_tag.conflict3 { + struct scanu_start_req * param; + struct hal_dma_desc_tag dma_desc; + uint16_t result_cnt; + undefined field_0x16; + undefined field_0x17; + struct mac_scan_result scan_result[6]; + ke_task_id_t src_id; + _Bool joining; + uint8_t band; + struct mac_addr.conflict171 bssid; + struct mac_ssid ssid; +}; + +struct mac_addr { + u8_l array[6]; +}; + +struct scanu_start_req { + struct scan_chan_tag chan[42]; + struct mac_ssid ssid[2]; + struct mac_addr bssid; + undefined field_0x146; + undefined field_0x147; + u32_l add_ies; + u16_l add_ie_len; + u8_l vif_idx; + u8_l chan_cnt; + u8_l ssid_cnt; + _Bool no_cck; + undefined field_0x152; + undefined field_0x153; +}; + +struct dma_desc { + uint32_t src; + uint32_t dest; + uint16_t length; + uint16_t ctrl; + uint32_t next; +}; + +typedef struct scanu_env_tag.conflict2 scanu_env_tag.conflict2, *Pscanu_env_tag.conflict2; + +struct scanu_env_tag.conflict2 { + struct scanu_start_req * param; + struct hal_dma_desc_tag dma_desc; + uint16_t result_cnt; + undefined field_0x16; + undefined field_0x17; + struct mac_scan_result scan_result[6]; + ke_task_id_t src_id; + _Bool joining; + uint8_t band; + struct mac_addr.conflict171 bssid; + struct mac_ssid ssid; +}; + +typedef struct scanu_env_tag.conflict scanu_env_tag.conflict, *Pscanu_env_tag.conflict; + +typedef struct mac_addr.conflict mac_addr.conflict, *Pmac_addr.conflict; + +struct mac_addr.conflict { + uint16_t array[3]; +}; + +struct scanu_env_tag.conflict { + struct scanu_start_req * param; + struct hal_dma_desc_tag dma_desc; + uint16_t result_cnt; + undefined field_0x16; + undefined field_0x17; + struct mac_scan_result scan_result[6]; + ke_task_id_t src_id; + _Bool joining; + uint8_t band; + struct mac_addr.conflict bssid; + struct mac_ssid ssid; +}; + +typedef struct scanu_env_tag.conflict1 scanu_env_tag.conflict1, *Pscanu_env_tag.conflict1; + +typedef struct mac_addr.conflict65 mac_addr.conflict65, *Pmac_addr.conflict65; + +struct mac_addr.conflict65 { + uint16_t array[3]; +}; + +struct scanu_env_tag.conflict1 { + struct scanu_start_req * param; + struct hal_dma_desc_tag dma_desc; + uint16_t result_cnt; + undefined field_0x16; + undefined field_0x17; + struct mac_scan_result scan_result[6]; + ke_task_id_t src_id; + _Bool joining; + uint8_t band; + struct mac_addr.conflict65 bssid; + struct mac_ssid ssid; +}; + +typedef struct scanu_env_tag scanu_env_tag, *Pscanu_env_tag; + +typedef struct mac_addr.conflict48 mac_addr.conflict48, *Pmac_addr.conflict48; + +struct mac_addr.conflict48 { + uint16_t array[3]; +}; + +struct scanu_env_tag { + struct scanu_start_req * param; + struct hal_dma_desc_tag dma_desc; + uint16_t result_cnt; + undefined field_0x16; + undefined field_0x17; + struct mac_scan_result scan_result[6]; + ke_task_id_t src_id; + _Bool joining; + uint8_t band; + struct mac_addr.conflict48 bssid; + struct mac_ssid ssid; +}; + +typedef struct scanu_add_ie_tag scanu_add_ie_tag, *Pscanu_add_ie_tag; + +struct scanu_add_ie_tag { + struct dma_desc dma_desc; + uint32_t buf[50]; +}; + +typedef enum HBN_PIR_HPF_Type { + HBN_PIR_HPF_METHOD0=0, + HBN_PIR_HPF_METHOD1=1, + HBN_PIR_HPF_METHOD2=2 +} HBN_PIR_HPF_Type; + +typedef enum HBN_OUT0_INT_Type { + HBN_OUT0_INT_GPIO7=0, + HBN_OUT0_INT_GPIO8=1, + HBN_OUT0_INT_RTC=2 +} HBN_OUT0_INT_Type; + +typedef enum HBN_XCLK_CLK_Type { + HBN_XCLK_CLK_RC32M=0, + HBN_XCLK_CLK_XTAL=1 +} HBN_XCLK_CLK_Type; + +typedef enum HBN_BOR_THRES_Type { + HBN_BOR_THRES_2P0V=0, + HBN_BOR_THRES_2P4V=1 +} HBN_BOR_THRES_Type; + +typedef struct HBN_APP_CFG_Type HBN_APP_CFG_Type, *PHBN_APP_CFG_Type; + +typedef enum HBN_GPIO_INT_Trigger_Type { + HBN_GPIO_INT_TRIGGER_ASYNC_FALLING_EDGE=4, + HBN_GPIO_INT_TRIGGER_ASYNC_HIGH_LEVEL=7, + HBN_GPIO_INT_TRIGGER_ASYNC_LOW_LEVEL=6, + HBN_GPIO_INT_TRIGGER_ASYNC_RISING_EDGE=5, + HBN_GPIO_INT_TRIGGER_SYNC_FALLING_EDGE=0, + HBN_GPIO_INT_TRIGGER_SYNC_HIGH_LEVEL=3, + HBN_GPIO_INT_TRIGGER_SYNC_LOW_LEVEL=2, + HBN_GPIO_INT_TRIGGER_SYNC_RISING_EDGE=1 +} HBN_GPIO_INT_Trigger_Type; + +typedef struct SPI_Flash_Cfg_Type SPI_Flash_Cfg_Type, *PSPI_Flash_Cfg_Type; + +typedef enum HBN_LEVEL_Type { + HBN_LEVEL_0=0, + HBN_LEVEL_1=1, + HBN_LEVEL_2=2, + HBN_LEVEL_3=3 +} HBN_LEVEL_Type; + +typedef enum HBN_LDO_LEVEL_Type { + HBN_LDO_LEVEL_0P60V=0, + HBN_LDO_LEVEL_0P65V=1, + HBN_LDO_LEVEL_0P70V=2, + HBN_LDO_LEVEL_0P75V=3, + HBN_LDO_LEVEL_0P80V=4, + HBN_LDO_LEVEL_0P85V=5, + HBN_LDO_LEVEL_0P90V=6, + HBN_LDO_LEVEL_0P95V=7, + HBN_LDO_LEVEL_1P00V=8, + HBN_LDO_LEVEL_1P05V=9, + HBN_LDO_LEVEL_1P10V=10, + HBN_LDO_LEVEL_1P15V=11, + HBN_LDO_LEVEL_1P20V=12, + HBN_LDO_LEVEL_1P25V=13, + HBN_LDO_LEVEL_1P30V=14, + HBN_LDO_LEVEL_1P35V=15 +} HBN_LDO_LEVEL_Type; + +struct HBN_APP_CFG_Type { + uint8_t useXtal32k; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + uint32_t sleepTime; + uint8_t gpioWakeupSrc; + enum HBN_GPIO_INT_Trigger_Type gpioTrigType; + undefined field_0xa; + undefined field_0xb; + struct SPI_Flash_Cfg_Type * flashCfg; + enum HBN_LEVEL_Type hbnLevel; + enum HBN_LDO_LEVEL_Type ldoLevel; + undefined field_0x12; + undefined field_0x13; +}; + +struct SPI_Flash_Cfg_Type { + uint8_t ioMode; + uint8_t cReadSupport; + uint8_t clkDelay; + uint8_t clkInvert; + uint8_t resetEnCmd; + uint8_t resetCmd; + uint8_t resetCreadCmd; + uint8_t resetCreadCmdSize; + uint8_t jedecIdCmd; + uint8_t jedecIdCmdDmyClk; + uint8_t qpiJedecIdCmd; + uint8_t qpiJedecIdCmdDmyClk; + uint8_t sectorSize; + uint8_t mid; + uint16_t pageSize; + uint8_t chipEraseCmd; + uint8_t sectorEraseCmd; + uint8_t blk32EraseCmd; + uint8_t blk64EraseCmd; + uint8_t writeEnableCmd; + uint8_t pageProgramCmd; + uint8_t qpageProgramCmd; + uint8_t qppAddrMode; + uint8_t fastReadCmd; + uint8_t frDmyClk; + uint8_t qpiFastReadCmd; + uint8_t qpiFrDmyClk; + uint8_t fastReadDoCmd; + uint8_t frDoDmyClk; + uint8_t fastReadDioCmd; + uint8_t frDioDmyClk; + uint8_t fastReadQoCmd; + uint8_t frQoDmyClk; + uint8_t fastReadQioCmd; + uint8_t frQioDmyClk; + uint8_t qpiFastReadQioCmd; + uint8_t qpiFrQioDmyClk; + uint8_t qpiPageProgramCmd; + uint8_t writeVregEnableCmd; + uint8_t wrEnableIndex; + uint8_t qeIndex; + uint8_t busyIndex; + uint8_t wrEnableBit; + uint8_t qeBit; + uint8_t busyBit; + uint8_t wrEnableWriteRegLen; + uint8_t wrEnableReadRegLen; + uint8_t qeWriteRegLen; + uint8_t qeReadRegLen; + uint8_t releasePowerDown; + uint8_t busyReadRegLen; + uint8_t readRegCmd[4]; + uint8_t writeRegCmd[4]; + uint8_t enterQpi; + uint8_t exitQpi; + uint8_t cReadMode; + uint8_t cRExit; + uint8_t burstWrapCmd; + uint8_t burstWrapCmdDmyClk; + uint8_t burstWrapDataMode; + uint8_t burstWrapData; + uint8_t deBurstWrapCmd; + uint8_t deBurstWrapCmdDmyClk; + uint8_t deBurstWrapDataMode; + uint8_t deBurstWrapData; + uint16_t timeEsector; + uint16_t timeE32k; + uint16_t timeE64k; + uint16_t timePagePgm; + uint16_t timeCe; + uint8_t pdDelay; + uint8_t qeData; +}; + +typedef struct HBN_BOR_CFG_Type HBN_BOR_CFG_Type, *PHBN_BOR_CFG_Type; + +struct HBN_BOR_CFG_Type { + uint8_t enableBor; + uint8_t enableBorInt; + uint8_t borThreshold; + uint8_t enablePorInBor; +}; + +typedef enum HBN_PIR_LPF_Type { + HBN_PIR_LPF_DIV1=0, + HBN_PIR_LPF_DIV2=1 +} HBN_PIR_LPF_Type; + +typedef struct HBN_PIR_INT_CFG_Type HBN_PIR_INT_CFG_Type, *PHBN_PIR_INT_CFG_Type; + +typedef enum BL_Fun_Type { + DISABLE=0, + ENABLE=1 +} BL_Fun_Type; + +struct HBN_PIR_INT_CFG_Type { + enum BL_Fun_Type lowIntEn; + enum BL_Fun_Type highIntEn; +}; + +typedef enum HBN_32K_CLK_Type { + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1 +} HBN_32K_CLK_Type; + +typedef enum HBN_ROOT_CLK_Type { + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1 +} HBN_ROOT_CLK_Type; + +typedef enum HBN_UART_CLK_Type { + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0 +} HBN_UART_CLK_Type; + +typedef enum HBN_INT_Type { + HBN_INT_ACOMP0=20, + HBN_INT_ACOMP1=22, + HBN_INT_BOR=18, + HBN_INT_GPIO7=0, + HBN_INT_GPIO8=1, + HBN_INT_PIR=17, + HBN_INT_RTC=16 +} HBN_INT_Type; + +typedef enum HBN_OUT1_INT_Type { + HBN_OUT1_INT_ACOMP0=2, + HBN_OUT1_INT_ACOMP1=3, + HBN_OUT1_INT_BOR=1, + HBN_OUT1_INT_PIR=0 +} HBN_OUT1_INT_Type; + +typedef enum HBN_BOR_MODE_Type { + HBN_BOR_MODE_POR_INDEPENDENT=0, + HBN_BOR_MODE_POR_RELEVANT=1 +} HBN_BOR_MODE_Type; + +typedef enum HBN_RTC_INT_Delay_Type { + HBN_RTC_INT_DELAY_0T=1, + HBN_RTC_INT_DELAY_32T=0 +} HBN_RTC_INT_Delay_Type; + +typedef struct tmrCallbackParameters.conflict1 tmrCallbackParameters.conflict1, *PtmrCallbackParameters.conflict1; + +typedef struct tmrCallbackParameters.conflict1 CallbackParameters_t.conflict; + +struct tmrCallbackParameters.conflict1 { + void (* pxCallbackFunction)(void *, uint32_t); + void * pvParameter1; + uint32_t ulParameter2; +}; + +typedef struct tmrTimerQueueMessage tmrTimerQueueMessage, *PtmrTimerQueueMessage; + +typedef int32_t BaseType_t; + +typedef union anon_union_for_u anon_union_for_u, *Panon_union_for_u; + +typedef struct tmrTimerParameters tmrTimerParameters, *PtmrTimerParameters; + +typedef struct tmrTimerParameters TimerParameter_t; + +typedef struct tmrCallbackParameters.conflict2 tmrCallbackParameters.conflict2, *PtmrCallbackParameters.conflict2; + +typedef struct tmrCallbackParameters.conflict2 CallbackParameters_t.conflict1; + +typedef struct tmrTimerControl xTIMER; + +typedef xTIMER Timer_t; + +struct tmrTimerParameters { + TickType_t xMessageValue; + Timer_t * pxTimer; +}; + +struct tmrCallbackParameters.conflict2 { + void (* pxCallbackFunction)(void *, uint32_t); + void * pvParameter1; + uint32_t ulParameter2; +}; + +union anon_union_for_u { + TimerParameter_t xTimerParameters; + CallbackParameters_t.conflict1 xCallbackParameters; +}; + +struct tmrTimerQueueMessage { + BaseType_t xMessageID; + union anon_union_for_u u; +}; + +typedef struct tmrCallbackParameters.conflict tmrCallbackParameters.conflict, *PtmrCallbackParameters.conflict; + +struct tmrCallbackParameters.conflict { + void (* pxCallbackFunction)(void *, uint32_t); + void * pvParameter1; + uint32_t ulParameter2; +}; + +typedef struct tmrCallbackParameters.conflict4 tmrCallbackParameters.conflict4, *PtmrCallbackParameters.conflict4; + +typedef struct tmrCallbackParameters.conflict4 CallbackParameters_t.conflict3; + +struct tmrCallbackParameters.conflict4 { + void (* pxCallbackFunction)(void *, uint32_t); + void * pvParameter1; + uint32_t ulParameter2; +}; + +typedef struct tmrTimerQueueMessage DaemonTaskMessage_t; + +typedef struct tmrCallbackParameters.conflict3 tmrCallbackParameters.conflict3, *PtmrCallbackParameters.conflict3; + +struct tmrCallbackParameters.conflict3 { + void (* pxCallbackFunction)(void *, uint32_t); + void * pvParameter1; + uint32_t ulParameter2; +}; + +typedef struct tmrCallbackParameters tmrCallbackParameters, *PtmrCallbackParameters; + +struct tmrCallbackParameters { + void (* pxCallbackFunction)(void *, uint32_t); + void * pvParameter1; + uint32_t ulParameter2; +}; + +typedef struct tmrCallbackParameters.conflict CallbackParameters_t; + +typedef struct tmrCallbackParameters.conflict3 CallbackParameters_t.conflict2; + +typedef enum llm_msg_id { + LLM_ECC_RESULT_IND=6, + LLM_ENC_IND=5, + LLM_ENC_REQ=4, + LLM_GEN_CHNL_CLS_CMD=8, + LLM_LE_CHNL_ASSESS_TIMER=7, + LLM_LE_ENH_PRIV_ADDR_RENEW_TIMER=9, + LLM_LE_SET_HOST_CH_CLASS_CMD_STO=0, + LLM_LE_SET_HOST_CH_CLASS_REQ=2, + LLM_LE_SET_HOST_CH_CLASS_REQ_IND=3, + LLM_STOP_IND=1 +} llm_msg_id; + +typedef struct llm_enc_req llm_enc_req, *Pllm_enc_req; + +struct llm_enc_req { + struct ltk key; + uint8_t plain_data[16]; +}; + +typedef struct llm_enc_ind llm_enc_ind, *Pllm_enc_ind; + +struct llm_enc_ind { + uint8_t status; + uint8_t encrypted_data[16]; +}; + +typedef enum llm_state_id { + LLM_ADV_STATE_MASK=-16, + LLM_COEXT_ADVERTISING_IDLE=16, + LLM_COEXT_ADVERTISING_INITIATING=18, + LLM_COEXT_ADVERTISING_SCANNING=17, + LLM_COEXT_ADVERTISING_STOPPING=19, + LLM_COEXT_IDLE_IDLE=0, + LLM_COEXT_IDLE_INITIATING=2, + LLM_COEXT_IDLE_SCANNING=1, + LLM_COEXT_IDLE_STOPPING=3, + LLM_COEXT_STOPPING_IDLE=32, + LLM_COEXT_STOPPING_INITIATING=34, + LLM_COEXT_STOPPING_SCANNING=33, + LLM_COEXT_STOPPING_STOPPING=35, + LLM_SCAN_INIT_STATE_MASK=15, + LLM_STATE_MAX=37, + LLM_TEST=36 +} llm_state_id; + +typedef struct ipc_shared_env_tag ipc_shared_env_tag, *Pipc_shared_env_tag; + +typedef struct ipc_a2e_msg ipc_a2e_msg, *Pipc_a2e_msg; + +typedef struct txdesc_host txdesc_host, *Ptxdesc_host; + +typedef struct hostdesc hostdesc, *Phostdesc; + +struct hostdesc { + uint32_t pbuf_addr; + u32_l packet_addr; + u16_l packet_len; + undefined field_0xa; + undefined field_0xb; + u32_l status_addr; + struct mac_addr eth_dest_addr; + struct mac_addr eth_src_addr; + u16_l ethertype; + u16_l pn[4]; + u16_l sn; + u16_l timestamp; + u8_l tid; + u8_l vif_idx; + u8_l staid; + undefined field_0x2d; + u16_l flags; + u32_l pbuf_chained_ptr[4]; + u32_l pbuf_chained_len[4]; +}; + +struct txdesc_host { + u32_l ready; + struct hostdesc host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_a2e_msg { + u32_l dummy_word; + u32_l msg[127]; +}; + +struct ipc_shared_env_tag { + struct ipc_a2e_msg msg_a2e_buf; + u32_l pattern_addr; + struct txdesc_host txdesc0[4]; +}; + +typedef struct ipc_e2a_msg ipc_e2a_msg, *Pipc_e2a_msg; + +struct ipc_e2a_msg { + u16_l id; + u16_l dummy_dest_id; + u16_l dummy_src_id; + u16_l param_len; + u32_l param[245]; + u32_l pattern; +}; + +typedef struct ipc_shared_env_tag.conflict ipc_shared_env_tag.conflict, *Pipc_shared_env_tag.conflict; + +typedef struct txdesc_host.conflict txdesc_host.conflict, *Ptxdesc_host.conflict; + +typedef struct hostdesc.conflict hostdesc.conflict, *Phostdesc.conflict; + +struct hostdesc.conflict { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict eth_dest_addr; + struct mac_addr.conflict eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict { + uint32_t ready; + struct hostdesc.conflict host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag.conflict { + struct ipc_a2e_msg msg_a2e_buf; + uint32_t pattern_addr; + struct txdesc_host.conflict txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict11 ipc_shared_env_tag.conflict11, *Pipc_shared_env_tag.conflict11; + +typedef struct txdesc_host.conflict28 txdesc_host.conflict28, *Ptxdesc_host.conflict28; + +typedef struct hostdesc.conflict44 hostdesc.conflict44, *Phostdesc.conflict44; + +typedef struct mac_addr.conflict201 mac_addr.conflict201, *Pmac_addr.conflict201; + +typedef struct mac_addr.conflict202 mac_addr.conflict202, *Pmac_addr.conflict202; + +struct mac_addr.conflict201 { + uint16_t array[3]; +}; + +struct mac_addr.conflict202 { + uint16_t array[3]; +}; + +struct hostdesc.conflict44 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict201 eth_dest_addr; + struct mac_addr.conflict202 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict28 { + uint32_t ready; + struct hostdesc.conflict44 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag.conflict11 { + struct ipc_a2e_msg msg_a2e_buf; + uint32_t pattern_addr; + struct txdesc_host.conflict28 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict10 ipc_shared_env_tag.conflict10, *Pipc_shared_env_tag.conflict10; + +typedef struct txdesc_host.conflict8 txdesc_host.conflict8, *Ptxdesc_host.conflict8; + +typedef struct hostdesc.conflict19 hostdesc.conflict19, *Phostdesc.conflict19; + +typedef struct mac_addr.conflict129 mac_addr.conflict129, *Pmac_addr.conflict129; + +typedef struct mac_addr.conflict130 mac_addr.conflict130, *Pmac_addr.conflict130; + +struct mac_addr.conflict129 { + uint16_t array[3]; +}; + +struct mac_addr.conflict130 { + uint16_t array[3]; +}; + +struct hostdesc.conflict19 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict129 eth_dest_addr; + struct mac_addr.conflict130 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict8 { + uint32_t ready; + struct hostdesc.conflict19 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag.conflict10 { + struct ipc_a2e_msg msg_a2e_buf; + uint32_t pattern_addr; + struct txdesc_host.conflict8 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict7 ipc_shared_env_tag.conflict7, *Pipc_shared_env_tag.conflict7; + +typedef struct txdesc_host.conflict13 txdesc_host.conflict13, *Ptxdesc_host.conflict13; + +typedef struct hostdesc.conflict25 hostdesc.conflict25, *Phostdesc.conflict25; + +typedef struct mac_addr.conflict143 mac_addr.conflict143, *Pmac_addr.conflict143; + +typedef struct mac_addr.conflict144 mac_addr.conflict144, *Pmac_addr.conflict144; + +struct mac_addr.conflict144 { + uint16_t array[3]; +}; + +struct mac_addr.conflict143 { + uint16_t array[3]; +}; + +struct hostdesc.conflict25 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict143 eth_dest_addr; + struct mac_addr.conflict144 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict13 { + uint32_t ready; + struct hostdesc.conflict25 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag.conflict7 { + struct ipc_a2e_msg msg_a2e_buf; + uint32_t pattern_addr; + struct txdesc_host.conflict13 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict8 ipc_shared_env_tag.conflict8, *Pipc_shared_env_tag.conflict8; + +typedef struct txdesc_host.conflict18 txdesc_host.conflict18, *Ptxdesc_host.conflict18; + +typedef struct hostdesc.conflict31 hostdesc.conflict31, *Phostdesc.conflict31; + +typedef struct mac_addr.conflict166 mac_addr.conflict166, *Pmac_addr.conflict166; + +typedef struct mac_addr.conflict167 mac_addr.conflict167, *Pmac_addr.conflict167; + +struct mac_addr.conflict167 { + uint16_t array[3]; +}; + +struct mac_addr.conflict166 { + uint16_t array[3]; +}; + +struct hostdesc.conflict31 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict166 eth_dest_addr; + struct mac_addr.conflict167 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict18 { + uint32_t ready; + struct hostdesc.conflict31 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag.conflict8 { + struct ipc_a2e_msg msg_a2e_buf; + uint32_t pattern_addr; + struct txdesc_host.conflict18 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict9 ipc_shared_env_tag.conflict9, *Pipc_shared_env_tag.conflict9; + +typedef struct txdesc_host.conflict23 txdesc_host.conflict23, *Ptxdesc_host.conflict23; + +typedef struct hostdesc.conflict37 hostdesc.conflict37, *Phostdesc.conflict37; + +typedef struct mac_addr.conflict182 mac_addr.conflict182, *Pmac_addr.conflict182; + +typedef struct mac_addr.conflict183 mac_addr.conflict183, *Pmac_addr.conflict183; + +struct mac_addr.conflict182 { + uint16_t array[3]; +}; + +struct mac_addr.conflict183 { + uint16_t array[3]; +}; + +struct hostdesc.conflict37 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict182 eth_dest_addr; + struct mac_addr.conflict183 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict23 { + uint32_t ready; + struct hostdesc.conflict37 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag.conflict9 { + struct ipc_a2e_msg msg_a2e_buf; + uint32_t pattern_addr; + struct txdesc_host.conflict23 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict14 ipc_shared_env_tag.conflict14, *Pipc_shared_env_tag.conflict14; + +typedef struct txdesc_host.conflict33 txdesc_host.conflict33, *Ptxdesc_host.conflict33; + +typedef struct hostdesc.conflict56 hostdesc.conflict56, *Phostdesc.conflict56; + +typedef struct mac_addr.conflict252 mac_addr.conflict252, *Pmac_addr.conflict252; + +typedef struct mac_addr.conflict253 mac_addr.conflict253, *Pmac_addr.conflict253; + +struct mac_addr.conflict252 { + uint16_t array[3]; +}; + +struct mac_addr.conflict253 { + uint16_t array[3]; +}; + +struct hostdesc.conflict56 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict252 eth_dest_addr; + struct mac_addr.conflict253 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict33 { + uint32_t ready; + struct hostdesc.conflict56 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag.conflict14 { + struct ipc_a2e_msg msg_a2e_buf; + uint32_t pattern_addr; + struct txdesc_host.conflict33 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict1 ipc_shared_env_tag.conflict1, *Pipc_shared_env_tag.conflict1; + +struct ipc_shared_env_tag.conflict1 { + struct ipc_a2e_msg msg_a2e_buf; + uint32_t pattern_addr; + struct txdesc_host.conflict txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict13 ipc_shared_env_tag.conflict13, *Pipc_shared_env_tag.conflict13; + +struct ipc_shared_env_tag.conflict13 { + struct ipc_a2e_msg msg_a2e_buf; + uint32_t pattern_addr; + struct txdesc_host.conflict8 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict2 ipc_shared_env_tag.conflict2, *Pipc_shared_env_tag.conflict2; + +struct ipc_shared_env_tag.conflict2 { + struct ipc_a2e_msg msg_a2e_buf; + uint32_t pattern_addr; + struct txdesc_host.conflict txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict12 ipc_shared_env_tag.conflict12, *Pipc_shared_env_tag.conflict12; + +struct ipc_shared_env_tag.conflict12 { + struct ipc_a2e_msg msg_a2e_buf; + uint32_t pattern_addr; + struct txdesc_host.conflict8 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict3 ipc_shared_env_tag.conflict3, *Pipc_shared_env_tag.conflict3; + +struct ipc_shared_env_tag.conflict3 { + struct ipc_a2e_msg msg_a2e_buf; + uint32_t pattern_addr; + struct txdesc_host.conflict txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict4 ipc_shared_env_tag.conflict4, *Pipc_shared_env_tag.conflict4; + +typedef struct txdesc_host.conflict3 txdesc_host.conflict3, *Ptxdesc_host.conflict3; + +typedef struct hostdesc.conflict12 hostdesc.conflict12, *Phostdesc.conflict12; + +typedef struct mac_addr.conflict88 mac_addr.conflict88, *Pmac_addr.conflict88; + +typedef struct mac_addr.conflict89 mac_addr.conflict89, *Pmac_addr.conflict89; + +struct mac_addr.conflict88 { + uint16_t array[3]; +}; + +struct mac_addr.conflict89 { + uint16_t array[3]; +}; + +struct hostdesc.conflict12 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict88 eth_dest_addr; + struct mac_addr.conflict89 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict3 { + uint32_t ready; + struct hostdesc.conflict12 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +struct ipc_shared_env_tag.conflict4 { + struct ipc_a2e_msg msg_a2e_buf; + uint32_t pattern_addr; + struct txdesc_host.conflict3 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict5 ipc_shared_env_tag.conflict5, *Pipc_shared_env_tag.conflict5; + +struct ipc_shared_env_tag.conflict5 { + struct ipc_a2e_msg msg_a2e_buf; + uint32_t pattern_addr; + struct txdesc_host.conflict8 txdesc0[4]; +}; + +typedef struct ipc_shared_env_tag.conflict6 ipc_shared_env_tag.conflict6, *Pipc_shared_env_tag.conflict6; + +struct ipc_shared_env_tag.conflict6 { + struct ipc_a2e_msg msg_a2e_buf; + uint32_t pattern_addr; + struct txdesc_host.conflict8 txdesc0[4]; +}; + +typedef struct lld_sleep_env_tag lld_sleep_env_tag, *Plld_sleep_env_tag; + +struct lld_sleep_env_tag { + uint32_t irq_mask; + int32_t last_sleep_dur; + _Bool sw_wakeup; + _Bool pds_reset; + undefined field_0xa; + undefined field_0xb; + uint32_t basetimecnt; + uint32_t finetimecnt; +}; + +typedef struct anon_struct.conflict284 anon_struct.conflict284, *Panon_struct.conflict284; + +struct anon_struct.conflict284 { + uint frac0:32; + uint frac1:20; + uint exp:11; + uint sign:1; +}; + +typedef union _FP_UNION_D _FP_UNION_D, *P_FP_UNION_D; + +typedef double DFtype; + +union _FP_UNION_D { + DFtype flt; + struct anon_struct.conflict284 bits; +}; + +typedef struct tcal_tag tcal_tag, *Ptcal_tag; + +struct tcal_tag { + int16_t prev_temperature; + undefined field_0x2; + undefined field_0x3; + uint32_t last_action_time[4]; + uint32_t last_action_temperature[4]; + int32_t last_action_out[4]; + _Bool enabled; + undefined field_0x35; + undefined field_0x36; + undefined field_0x37; +}; + +typedef enum HCI_MSG { + HCI_ACL_DATA_RX=2054, + HCI_ACL_DATA_TX=2055, + HCI_CMD_CMP_EVENT=2049, + HCI_CMD_STAT_EVENT=2050, + HCI_COMMAND=2053, + HCI_DBG_EVT=2057, + HCI_EVENT=2051, + HCI_LE_EVENT=2052, + HCI_MSG_ID_FIRST=2048, + HCI_MSG_ID_LAST=2058, + HCI_TCI_LMP=2056 +} HCI_MSG; + +typedef union _reg_t _reg_t, *P_reg_t; + +union _reg_t { + uint8_t byte[4]; + uint32_t word; +}; + +typedef struct bt_uuid bt_uuid, *Pbt_uuid; + +struct bt_uuid { + u8_t type; +}; + +typedef struct bt_uuid_128 bt_uuid_128, *Pbt_uuid_128; + +struct bt_uuid_128 { + struct bt_uuid uuid; + u8_t val[16]; +}; + +typedef struct bt_uuid_32 bt_uuid_32, *Pbt_uuid_32; + +struct bt_uuid_32 { + struct bt_uuid uuid; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + u32_t.conflict val; +}; + +typedef struct bt_uuid_16 bt_uuid_16, *Pbt_uuid_16; + +struct bt_uuid_16 { + struct bt_uuid uuid; + undefined field_0x1; + u16_t val; +}; + +typedef struct bl_hci_cmd_struct bl_hci_cmd_struct, *Pbl_hci_cmd_struct; + +struct bl_hci_cmd_struct { + uint16_t opcode; + undefined field_0x2; + undefined field_0x3; + uint8_t * params; + uint8_t param_len; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct bl_hci_acl_data_tx bl_hci_acl_data_tx, *Pbl_hci_acl_data_tx; + +struct bl_hci_acl_data_tx { + uint16_t conhdl; + uint8_t pb_bc_flag; + undefined field_0x3; + uint16_t len; + undefined field_0x6; + undefined field_0x7; + uint8_t * buffer; +}; + +typedef struct hci_pkt_struct hci_pkt_struct, *Phci_pkt_struct; + +typedef union anon_union_for_p anon_union_for_p, *Panon_union_for_p; + +union anon_union_for_p { + struct bl_hci_cmd_struct hci_cmd; + struct bl_hci_acl_data_tx acl_data; +}; + +struct hci_pkt_struct { + union anon_union_for_p p; +}; + +typedef struct _romfs_file_buf _romfs_file_buf, *P_romfs_file_buf; + +struct _romfs_file_buf { + char * buf; + uint32_t bufsize; +}; + +typedef struct _romfs_file_buf romfs_filebuf_t; + +typedef enum TASK_API_ID { + TASK_ID_AHI=16, + TASK_ID_AM0=-16, + TASK_ID_AM0_HAS=-15, + TASK_ID_ANPC=48, + TASK_ID_ANPS=47, + TASK_ID_APP=15, + TASK_ID_BASC=37, + TASK_ID_BASS=36, + TASK_ID_BCSC=64, + TASK_ID_BCSS=63, + TASK_ID_BLPC=29, + TASK_ID_BLPS=28, + TASK_ID_CPPC=52, + TASK_ID_CPPS=51, + TASK_ID_CSCPC=46, + TASK_ID_CSCPS=45, + TASK_ID_DBG=3, + TASK_ID_DISC=21, + TASK_ID_DISPLAY=9, + TASK_ID_DISS=20, + TASK_ID_ENVC=58, + TASK_ID_ENVS=57, + TASK_ID_FINDL=24, + TASK_ID_FINDT=25, + TASK_ID_GAPC=14, + TASK_ID_GAPM=13, + TASK_ID_GATTC=12, + TASK_ID_GATTM=11, + TASK_ID_GLPC=42, + TASK_ID_GLPS=41, + TASK_ID_HCI=8, + TASK_ID_HOGPBH=39, + TASK_ID_HOGPD=38, + TASK_ID_HOGPRH=40, + TASK_ID_HRPC=31, + TASK_ID_HRPS=30, + TASK_ID_HTPC=26, + TASK_ID_HTPT=27, + TASK_ID_INVALID=-1, + TASK_ID_IPSC=56, + TASK_ID_IPSS=55, + TASK_ID_L2CC=10, + TASK_ID_LANC=54, + TASK_ID_LANS=53, + TASK_ID_LB=6, + TASK_ID_LC=5, + TASK_ID_LD=7, + TASK_ID_LLC=1, + TASK_ID_LLD=2, + TASK_ID_LLM=0, + TASK_ID_LM=4, + TASK_ID_PASPC=50, + TASK_ID_PASPS=49, + TASK_ID_PLXC=68, + TASK_ID_PLXS=67, + TASK_ID_PROXM=22, + TASK_ID_PROXR=23, + TASK_ID_RSCPC=44, + TASK_ID_RSCPS=43, + TASK_ID_SCPPC=35, + TASK_ID_SCPPS=34, + TASK_ID_TIPC=33, + TASK_ID_TIPS=32, + TASK_ID_UDSC=62, + TASK_ID_UDSS=61, + TASK_ID_WPTC=66, + TASK_ID_WPTS=65, + TASK_ID_WSCC=60, + TASK_ID_WSCS=59 +} TASK_API_ID; + +typedef struct bt_hci_cp_le_set_scan_param bt_hci_cp_le_set_scan_param, *Pbt_hci_cp_le_set_scan_param; + +struct bt_hci_cp_le_set_scan_param { + u8_t scan_type; + u16_t interval; + u16_t window; + u8_t addr_type; + u8_t filter_policy; +}; + +typedef struct bt_hci_evt_num_completed_packets bt_hci_evt_num_completed_packets, *Pbt_hci_evt_num_completed_packets; + +typedef struct bt_hci_handle_count bt_hci_handle_count, *Pbt_hci_handle_count; + +struct bt_hci_evt_num_completed_packets { + u8_t num_handles; + struct bt_hci_handle_count[0] h; +}; + +struct bt_hci_handle_count { + u16_t handle; + u16_t count; +}; + +typedef struct bt_hci_cp_le_rem_dev_from_wl bt_hci_cp_le_rem_dev_from_wl, *Pbt_hci_cp_le_rem_dev_from_wl; + +struct bt_hci_cp_le_rem_dev_from_wl { + struct bt_addr_le_t addr; +}; + +typedef struct bt_hci_cp_le_write_default_data_len bt_hci_cp_le_write_default_data_len, *Pbt_hci_cp_le_write_default_data_len; + +struct bt_hci_cp_le_write_default_data_len { + u16_t max_tx_octets; + u16_t max_tx_time; +}; + +typedef struct bt_hci_cp_le_start_encryption bt_hci_cp_le_start_encryption, *Pbt_hci_cp_le_start_encryption; + +struct bt_hci_cp_le_start_encryption { + u16_t handle; + u64_t rand; + u16_t ediv; + u8_t ltk[16]; +}; + +typedef struct bt_hci_evt_encrypt_change bt_hci_evt_encrypt_change, *Pbt_hci_evt_encrypt_change; + +struct bt_hci_evt_encrypt_change { + u8_t status; + u16_t handle; + u8_t encrypt; +}; + +typedef struct bt_hci_rp_le_read_wl_size bt_hci_rp_le_read_wl_size, *Pbt_hci_rp_le_read_wl_size; + +struct bt_hci_rp_le_read_wl_size { + u8_t status; + u8_t wl_size; +}; + +typedef struct bt_hci_rp_read_encryption_key_size bt_hci_rp_read_encryption_key_size, *Pbt_hci_rp_read_encryption_key_size; + +struct bt_hci_rp_read_encryption_key_size { + u8_t status; + u16_t handle; + u8_t key_size; +}; + +typedef struct hci_cp_le_conn_update hci_cp_le_conn_update, *Phci_cp_le_conn_update; + +struct hci_cp_le_conn_update { + u16_t handle; + u16_t conn_interval_min; + u16_t conn_interval_max; + u16_t conn_latency; + u16_t supervision_timeout; + u16_t min_ce_len; + u16_t max_ce_len; +}; + +typedef struct bt_hci_evt_disconn_complete bt_hci_evt_disconn_complete, *Pbt_hci_evt_disconn_complete; + +struct bt_hci_evt_disconn_complete { + u8_t status; + u16_t handle; + u8_t reason; +}; + +typedef struct bt_hci_evt_le_conn_update_complete bt_hci_evt_le_conn_update_complete, *Pbt_hci_evt_le_conn_update_complete; + +struct bt_hci_evt_le_conn_update_complete { + u8_t status; + u16_t handle; + u16_t interval; + u16_t latency; + u16_t supv_timeout; +}; + +typedef struct bt_hci_evt_le_remote_feat_complete bt_hci_evt_le_remote_feat_complete, *Pbt_hci_evt_le_remote_feat_complete; + +struct bt_hci_evt_le_remote_feat_complete { + u8_t status; + u16_t handle; + u8_t features[8]; +}; + +typedef struct bt_hci_cp_read_encryption_key_size bt_hci_cp_read_encryption_key_size, *Pbt_hci_cp_read_encryption_key_size; + +struct bt_hci_cp_read_encryption_key_size { + u16_t handle; +}; + +typedef struct bt_hci_cmd_hdr bt_hci_cmd_hdr, *Pbt_hci_cmd_hdr; + +struct bt_hci_cmd_hdr { + u16_t opcode; + u8_t param_len; +}; + +typedef struct bt_hci_rp_le_read_local_features bt_hci_rp_le_read_local_features, *Pbt_hci_rp_le_read_local_features; + +struct bt_hci_rp_le_read_local_features { + u8_t status; + u8_t features[8]; +}; + +typedef struct bt_hci_rp_le_read_max_data_len bt_hci_rp_le_read_max_data_len, *Pbt_hci_rp_le_read_max_data_len; + +struct bt_hci_rp_le_read_max_data_len { + u8_t status; + u16_t max_tx_octets; + u16_t max_tx_time; + u16_t max_rx_octets; + u16_t max_rx_time; +}; + +typedef struct bt_hci_rp_read_supported_commands bt_hci_rp_read_supported_commands, *Pbt_hci_rp_read_supported_commands; + +struct bt_hci_rp_read_supported_commands { + u8_t status; + u8_t commands[64]; +}; + +typedef struct bt_hci_evt_le_conn_complete bt_hci_evt_le_conn_complete, *Pbt_hci_evt_le_conn_complete; + +struct bt_hci_evt_le_conn_complete { + u8_t status; + u16_t handle; + u8_t role; + struct bt_addr_le_t peer_addr; + u16_t interval; + u16_t latency; + u16_t supv_timeout; + u8_t clock_accuracy; +}; + +typedef struct bt_hci_evt_le_generate_dhkey_complete bt_hci_evt_le_generate_dhkey_complete, *Pbt_hci_evt_le_generate_dhkey_complete; + +struct bt_hci_evt_le_generate_dhkey_complete { + u8_t status; + u8_t dhkey[32]; +}; + +typedef struct bt_hci_evt_hdr bt_hci_evt_hdr, *Pbt_hci_evt_hdr; + +struct bt_hci_evt_hdr { + u8_t evt; + u8_t len; +}; + +typedef struct bt_hci_evt_data_buf_overflow bt_hci_evt_data_buf_overflow, *Pbt_hci_evt_data_buf_overflow; + +struct bt_hci_evt_data_buf_overflow { + u8_t link_type; +}; + +typedef struct bt_hci_rp_le_read_rl_size bt_hci_rp_le_read_rl_size, *Pbt_hci_rp_le_read_rl_size; + +struct bt_hci_rp_le_read_rl_size { + u8_t status; + u8_t rl_size; +}; + +typedef struct bt_hci_evt_encrypt_key_refresh_complete bt_hci_evt_encrypt_key_refresh_complete, *Pbt_hci_evt_encrypt_key_refresh_complete; + +struct bt_hci_evt_encrypt_key_refresh_complete { + u8_t status; + u16_t handle; +}; + +typedef struct bt_hci_cp_le_set_event_mask bt_hci_cp_le_set_event_mask, *Pbt_hci_cp_le_set_event_mask; + +struct bt_hci_cp_le_set_event_mask { + u8_t events[8]; +}; + +typedef struct bt_hci_cp_le_conn_param_req_reply bt_hci_cp_le_conn_param_req_reply, *Pbt_hci_cp_le_conn_param_req_reply; + +struct bt_hci_cp_le_conn_param_req_reply { + u16_t handle; + u16_t interval_min; + u16_t interval_max; + u16_t latency; + u16_t timeout; + u16_t min_ce_len; + u16_t max_ce_len; +}; + +typedef struct bt_hci_rp_le_read_buffer_size bt_hci_rp_le_read_buffer_size, *Pbt_hci_rp_le_read_buffer_size; + +struct bt_hci_rp_le_read_buffer_size { + u8_t status; + u16_t le_max_len; + u8_t le_max_num; +}; + +typedef struct bt_hci_cp_disconnect bt_hci_cp_disconnect, *Pbt_hci_cp_disconnect; + +struct bt_hci_cp_disconnect { + u16_t handle; + u8_t reason; +}; + +typedef struct bt_hci_cp_le_set_host_chan_classif bt_hci_cp_le_set_host_chan_classif, *Pbt_hci_cp_le_set_host_chan_classif; + +struct bt_hci_cp_le_set_host_chan_classif { + u8_t ch_map[5]; +}; + +typedef struct bt_hci_cp_le_ltk_req_reply bt_hci_cp_le_ltk_req_reply, *Pbt_hci_cp_le_ltk_req_reply; + +struct bt_hci_cp_le_ltk_req_reply { + u16_t handle; + u8_t ltk[16]; +}; + +typedef struct bt_hci_rp_read_local_version_info bt_hci_rp_read_local_version_info, *Pbt_hci_rp_read_local_version_info; + +struct bt_hci_rp_read_local_version_info { + u8_t status; + u8_t hci_version; + u16_t hci_revision; + u8_t lmp_version; + u16_t manufacturer; + u16_t lmp_subversion; +}; + +typedef struct bt_hci_evt_cmd_complete bt_hci_evt_cmd_complete, *Pbt_hci_evt_cmd_complete; + +struct bt_hci_evt_cmd_complete { + u8_t ncmd; + u16_t opcode; +}; + +typedef struct bt_hci_evt_le_conn_param_req bt_hci_evt_le_conn_param_req, *Pbt_hci_evt_le_conn_param_req; + +struct bt_hci_evt_le_conn_param_req { + u16_t handle; + u16_t interval_min; + u16_t interval_max; + u16_t latency; + u16_t timeout; +}; + +typedef struct bt_hci_cp_le_create_conn bt_hci_cp_le_create_conn, *Pbt_hci_cp_le_create_conn; + +struct bt_hci_cp_le_create_conn { + u16_t scan_interval; + u16_t scan_window; + u8_t filter_policy; + struct bt_addr_le_t peer_addr; + u8_t own_addr_type; + u16_t conn_interval_min; + u16_t conn_interval_max; + u16_t conn_latency; + u16_t supervision_timeout; + u16_t min_ce_len; + u16_t max_ce_len; +}; + +typedef struct bt_hci_cp_le_set_data_len bt_hci_cp_le_set_data_len, *Pbt_hci_cp_le_set_data_len; + +struct bt_hci_cp_le_set_data_len { + u16_t handle; + u16_t tx_octets; + u16_t tx_time; +}; + +typedef struct bt_hci_cp_read_rssi bt_hci_cp_read_rssi, *Pbt_hci_cp_read_rssi; + +struct bt_hci_cp_read_rssi { + u16_t handle; +}; + +typedef struct bt_hci_cp_le_read_remote_features bt_hci_cp_le_read_remote_features, *Pbt_hci_cp_le_read_remote_features; + +struct bt_hci_cp_le_read_remote_features { + u16_t handle; +}; + +typedef struct bt_hci_evt_le_ltk_request bt_hci_evt_le_ltk_request, *Pbt_hci_evt_le_ltk_request; + +struct bt_hci_evt_le_ltk_request { + u16_t handle; + u64_t rand; + u16_t ediv; +}; + +typedef struct bt_hci_rp_read_rssi bt_hci_rp_read_rssi, *Pbt_hci_rp_read_rssi; + +typedef int8_t s8_t; + +struct bt_hci_rp_read_rssi { + u8_t status; + u16_t handle; + s8_t rssi; +}; + +typedef struct bt_hci_evt_le_enh_conn_complete bt_hci_evt_le_enh_conn_complete, *Pbt_hci_evt_le_enh_conn_complete; + +struct bt_hci_evt_le_enh_conn_complete { + u8_t status; + u16_t handle; + u8_t role; + struct bt_addr_le_t peer_addr; + struct bt_addr_t local_rpa; + struct bt_addr_t peer_rpa; + u16_t interval; + u16_t latency; + u16_t supv_timeout; + u8_t clock_accuracy; +}; + +typedef struct bt_hci_cp_write_le_host_supp bt_hci_cp_write_le_host_supp, *Pbt_hci_cp_write_le_host_supp; + +struct bt_hci_cp_write_le_host_supp { + u8_t le; + u8_t simul; +}; + +typedef struct bt_hci_evt_cmd_status bt_hci_evt_cmd_status, *Pbt_hci_evt_cmd_status; + +struct bt_hci_evt_cmd_status { + u8_t status; + u8_t ncmd; + u16_t opcode; +}; + +typedef struct bt_hci_evt_le_meta_event bt_hci_evt_le_meta_event, *Pbt_hci_evt_le_meta_event; + +struct bt_hci_evt_le_meta_event { + u8_t subevent; +}; + +typedef struct bt_hci_cp_le_set_privacy_mode bt_hci_cp_le_set_privacy_mode, *Pbt_hci_cp_le_set_privacy_mode; + +struct bt_hci_cp_le_set_privacy_mode { + struct bt_addr_le_t id_addr; + u8_t mode; +}; + +typedef struct bt_hci_evt_le_p256_public_key_complete bt_hci_evt_le_p256_public_key_complete, *Pbt_hci_evt_le_p256_public_key_complete; + +struct bt_hci_evt_le_p256_public_key_complete { + u8_t status; + u8_t key[64]; +}; + +typedef struct bt_hci_rp_read_bd_addr bt_hci_rp_read_bd_addr, *Pbt_hci_rp_read_bd_addr; + +struct bt_hci_rp_read_bd_addr { + u8_t status; + struct bt_addr_t bdaddr; +}; + +typedef struct bt_hci_cp_le_add_dev_to_rl bt_hci_cp_le_add_dev_to_rl, *Pbt_hci_cp_le_add_dev_to_rl; + +struct bt_hci_cp_le_add_dev_to_rl { + struct bt_addr_le_t peer_id_addr; + u8_t peer_irk[16]; + u8_t local_irk[16]; +}; + +typedef struct bt_hci_rp_le_rand bt_hci_rp_le_rand, *Pbt_hci_rp_le_rand; + +struct bt_hci_rp_le_rand { + u8_t status; + u8_t rand[8]; +}; + +typedef struct bt_hci_cp_le_rem_dev_from_rl bt_hci_cp_le_rem_dev_from_rl, *Pbt_hci_cp_le_rem_dev_from_rl; + +struct bt_hci_cp_le_rem_dev_from_rl { + struct bt_addr_le_t peer_id_addr; +}; + +typedef struct bt_hci_evt_le_advertising_info bt_hci_evt_le_advertising_info, *Pbt_hci_evt_le_advertising_info; + +struct bt_hci_evt_le_advertising_info { + u8_t evt_type; + struct bt_addr_le_t addr; + u8_t length; + u8_t[0] data; +}; + +typedef struct bt_hci_cp_le_add_dev_to_wl bt_hci_cp_le_add_dev_to_wl, *Pbt_hci_cp_le_add_dev_to_wl; + +struct bt_hci_cp_le_add_dev_to_wl { + struct bt_addr_le_t addr; +}; + +typedef struct bt_hci_cp_le_ltk_req_neg_reply bt_hci_cp_le_ltk_req_neg_reply, *Pbt_hci_cp_le_ltk_req_neg_reply; + +struct bt_hci_cp_le_ltk_req_neg_reply { + u16_t handle; +}; + +typedef struct bt_hci_cp_le_conn_param_req_neg_reply bt_hci_cp_le_conn_param_req_neg_reply, *Pbt_hci_cp_le_conn_param_req_neg_reply; + +struct bt_hci_cp_le_conn_param_req_neg_reply { + u16_t handle; + u8_t reason; +}; + +typedef struct bt_hci_rp_read_local_features bt_hci_rp_read_local_features, *Pbt_hci_rp_read_local_features; + +struct bt_hci_rp_read_local_features { + u8_t status; + u8_t features[8]; +}; + +typedef struct bt_hci_cp_le_set_adv_param bt_hci_cp_le_set_adv_param, *Pbt_hci_cp_le_set_adv_param; + +struct bt_hci_cp_le_set_adv_param { + u16_t min_interval; + u16_t max_interval; + u8_t type; + u8_t own_addr_type; + struct bt_addr_le_t direct_addr; + u8_t channel_map; + u8_t filter_policy; +}; + +typedef struct bt_hci_cp_le_set_scan_rsp_data bt_hci_cp_le_set_scan_rsp_data, *Pbt_hci_cp_le_set_scan_rsp_data; + +struct bt_hci_cp_le_set_scan_rsp_data { + u8_t len; + u8_t data[31]; +}; + +typedef struct bt_hci_cp_le_set_adv_data bt_hci_cp_le_set_adv_data, *Pbt_hci_cp_le_set_adv_data; + +struct bt_hci_cp_le_set_adv_data { + u8_t len; + u8_t data[31]; +}; + +typedef struct bt_hci_cp_le_generate_dhkey bt_hci_cp_le_generate_dhkey, *Pbt_hci_cp_le_generate_dhkey; + +struct bt_hci_cp_le_generate_dhkey { + u8_t key[64]; +}; + +typedef struct bt_hci_cp_le_set_scan_enable bt_hci_cp_le_set_scan_enable, *Pbt_hci_cp_le_set_scan_enable; + +struct bt_hci_cp_le_set_scan_enable { + u8_t enable; + u8_t filter_dup; +}; + +typedef struct bt_hci_cp_set_event_mask bt_hci_cp_set_event_mask, *Pbt_hci_cp_set_event_mask; + +struct bt_hci_cp_set_event_mask { + u8_t events[8]; +}; + +typedef struct bt_hci_acl_hdr bt_hci_acl_hdr, *Pbt_hci_acl_hdr; + +struct bt_hci_acl_hdr { + u16_t handle; + u16_t len; +}; + +typedef struct bt_hci_rp_le_read_supp_states bt_hci_rp_le_read_supp_states, *Pbt_hci_rp_le_read_supp_states; + +struct bt_hci_rp_le_read_supp_states { + u8_t status; + u8_t le_states[8]; +}; + +typedef struct bt_hci_rp_read_buffer_size bt_hci_rp_read_buffer_size, *Pbt_hci_rp_read_buffer_size; + +struct bt_hci_rp_read_buffer_size { + u8_t status; + u16_t acl_max_len; + u8_t sco_max_len; + u16_t acl_max_num; + u16_t sco_max_num; +}; + +typedef struct BL_ENDECRYPT_t BL_ENDECRYPT_t, *PBL_ENDECRYPT_t; + +struct BL_ENDECRYPT_t { + UINT8 enDeAction; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + UINT8 * pData; +}; + +typedef struct sta_info_tag sta_info_tag, *Psta_info_tag; + +typedef enum sta_ps_traffic { + PS_TRAFFIC=3, + PS_TRAFFIC_HOST=1, + PS_TRAFFIC_INT=2, + UAPSD_TRAFFIC=12, + UAPSD_TRAFFIC_HOST=4, + UAPSD_TRAFFIC_INT=8 +} sta_ps_traffic; + +typedef int sta_ps_sp_t; + +typedef struct sta_mgmt_sec_info sta_mgmt_sec_info, *Psta_mgmt_sec_info; + +typedef struct mac_sta_info mac_sta_info, *Pmac_sta_info; + +typedef struct sta_pol_tbl_cntl sta_pol_tbl_cntl, *Psta_pol_tbl_cntl; + +typedef struct sta_mgmt_ba_info sta_mgmt_ba_info, *Psta_mgmt_ba_info; + +typedef struct co_list co_list, *Pco_list; + +typedef struct key_info_tag key_info_tag, *Pkey_info_tag; + +typedef struct mac_rateset mac_rateset, *Pmac_rateset; + +typedef struct mac_htcapability mac_htcapability, *Pmac_htcapability; + +typedef struct mac_vhtcapability mac_vhtcapability, *Pmac_vhtcapability; + +typedef struct txl_buffer_control txl_buffer_control, *Ptxl_buffer_control; + +typedef struct rc_sta_stats rc_sta_stats, *Prc_sta_stats; + +typedef ulonglong __uint64_t; + +typedef __uint64_t uint64_t; + + +// WARNING! conflicting data type names: /DWARF/mac.h/key_info_tag/anon_union_for_u - /DWARF/timers.c/tmrTimerQueueMessage/anon_union_for_u + + +// WARNING! conflicting data type names: /DWARF/txl_buffer.h/txl_buffer_control/anon_union_for_field_0 - /DWARF/buf.h/net_buf/anon_union_for_field_0 + +typedef struct rc_rate_stats rc_rate_stats, *Prc_rate_stats; + +typedef struct step step, *Pstep; + +typedef union anon_union_for_rate_map anon_union_for_rate_map, *Panon_union_for_rate_map; + +struct sta_mgmt_ba_info { + uint32_t last_tx_time; + uint32_t last_ba_add_time; + uint8_t bam_idx_rx; + uint8_t bam_idx_tx; + int8_t credit_oft; + undefined field_0xb; +}; + +struct rc_rate_stats { + uint16_t attempts; + uint16_t success; + uint16_t probability; + uint16_t rate_config; + uint8_t sample_skipped; + _Bool old_prob_available; + uint8_t n_retry; + _Bool rate_allowed; +}; + +struct step { + uint32_t tp; + uint16_t idx; + undefined field_0x6; + undefined field_0x7; +}; + +union anon_union_for_rate_map { + uint8_t ht[4]; +}; + +struct rc_sta_stats { + uint32_t last_rc_time; + struct rc_rate_stats rate_stats[10]; + struct step retry[4]; + struct step max_tp_2_trial; + uint16_t ampdu_len; + uint16_t ampdu_packets; + uint32_t avg_ampdu_len; + uint8_t sample_wait; + uint8_t sample_slow; + uint8_t trial_status; + uint8_t info; + uint8_t sw_retry_step; + uint8_t format_mod; + union anon_union_for_rate_map rate_map; + uint16_t rate_map_l; + uint8_t mcs_max; + uint8_t r_idx_min; + uint8_t r_idx_max; + uint8_t bw_max; + uint8_t no_ss; + uint8_t short_gi; + uint8_t p_type; + undefined field_0xbf; + uint16_t no_samples; + uint16_t max_amsdu_len; + uint16_t curr_amsdu_len; + uint16_t fixed_rate_cfg; +}; + +struct sta_pol_tbl_cntl { + struct txl_buffer_control * buf_ctrl; + struct rc_sta_stats * sta_stats; + uint32_t prot_cfg; + uint16_t ppdu_tx_cfg; + uint8_t upd_field; + undefined field_0xf; +}; + +struct mac_rateset { + u8_l length; + u8_l array[12]; +}; + +struct mac_htcapability { + u16_l ht_capa_info; + u8_l a_mpdu_param; + u8_l mcs_rate[16]; + undefined field_0x13; + u16_l ht_extended_capa; + undefined field_0x16; + undefined field_0x17; + u32_l tx_beamforming_capa; + u8_l asel_capa; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +struct mac_vhtcapability { + u32_l vht_capa_info; + u16_l rx_mcs_map; + u16_l rx_highest; + u16_l tx_mcs_map; + u16_l tx_highest; +}; + +struct mac_sta_info { + struct mac_rateset rate_set; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + struct mac_htcapability ht_cap; + struct mac_vhtcapability vht_cap; + uint32_t capa_flags; + uint8_t phy_bw_max; + uint8_t bw_cur; + uint8_t uapsd_queues; + uint8_t max_sp_len; + uint8_t stbc_nss; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; +}; + +struct key_info_tag { + uint64_t rx_pn[9]; + uint64_t tx_pn; + union anon_union_for_u u; + uint8_t cipher; + uint8_t key_idx; + uint8_t hw_key_idx; + _Bool valid; + undefined field_0x64; + undefined field_0x65; + undefined field_0x66; + undefined field_0x67; +}; + +struct sta_mgmt_sec_info { + struct key_info_tag key_info; + struct key_info_tag * pairwise_key; + struct key_info_tag * * cur_key; +}; + +struct co_list { + struct co_list_hdr * first; + struct co_list_hdr * last; +}; + +struct sta_info_tag { + struct co_list_hdr list_hdr; + uint32_t bcn_int; + uint32_t ampdu_size_max_vht; + uint16_t ampdu_size_max_ht; + undefined field_0xe; + undefined field_0xf; + uint32_t paid_gid; + uint8_t ampdu_spacing_min; + undefined field_0x15; + uint16_t drift; + uint16_t aid; + uint8_t inst_nbr; + uint8_t staid; + uint8_t ps_state; + _Bool valid; + struct mac_addr.conflict mac_addr; + int8_t rssi; + undefined field_0x25; + undefined field_0x26; + undefined field_0x27; + uint32_t tsflo; + uint32_t tsfhi; + uint8_t data_rate; + uint8_t ctrl_port_state; + enum sta_ps_traffic traffic_avail; + undefined field_0x33; + sta_ps_sp_t ps_service_period; + uint16_t ctrl_port_ethertype; + undefined field_0x3a; + undefined field_0x3b; + undefined field_0x3c; + undefined field_0x3d; + undefined field_0x3e; + undefined field_0x3f; + struct sta_mgmt_sec_info sta_sec_info; + struct mac_sta_info info; + uint16_t seq_nbr[9]; + undefined field_0x10a; + undefined field_0x10b; + struct sta_pol_tbl_cntl pol_tbl; + struct sta_mgmt_ba_info ba_info[9]; + uint16_t rx_nqos_last_seqcntl; + uint16_t rx_qos_last_seqcntl[9]; + struct co_list tx_desc_post; + void * suppData; + uint32_t time_last_seen; + undefined field_0x1ac; + undefined field_0x1ad; + undefined field_0x1ae; + undefined field_0x1af; +}; + +struct txl_buffer_control { + union anon_union_for_field_0 field_0; + uint32_t mac_control_info; + uint32_t phy_control_info; +}; + +typedef struct sta_info_env_tag sta_info_env_tag, *Psta_info_env_tag; + +struct sta_info_env_tag { + struct co_list free_sta_list; +}; + +typedef enum sta_mgmt_pol_upd { + STA_MGMT_POL_UPD_BW=3, + STA_MGMT_POL_UPD_MAX=5, + STA_MGMT_POL_UPD_PPDU_TX=2, + STA_MGMT_POL_UPD_PROT=1, + STA_MGMT_POL_UPD_RATE=0, + STA_MGMT_POL_UPD_TX_POWER=4 +} sta_mgmt_pol_upd; + +typedef enum sta_ps_sp { + ANY_SERVICE_PERIOD_INT=3, + BCN_SERVICE_PERIOD=8, + NO_SERVICE_PERIOD=0, + PS_SERVICE_PERIOD=1, + UAPSD_SERVICE_PERIOD=6, + UAPSD_SERVICE_PERIOD_HOST=4, + UAPSD_SERVICE_PERIOD_INT=2 +} sta_ps_sp; + +typedef struct machw_mib_tag machw_mib_tag, *Pmachw_mib_tag; + +struct machw_mib_tag { + uint32_t dot11_wep_excluded_count; + uint32_t dot11_fcs_error_count; + uint32_t nx_rx_phy_error_count; + uint32_t nx_rd_fifo_overflow_count; + uint32_t nx_tx_underun_count; + uint32_t reserved_1[7]; + uint32_t nx_qos_utransmitted_mpdu_count[8]; + uint32_t nx_qos_gtransmitted_mpdu_count[8]; + uint32_t dot11_qos_failed_count[8]; + uint32_t dot11_qos_retry_count[8]; + uint32_t dot11_qos_rts_success_count[8]; + uint32_t dot11_qos_rts_failure_count[8]; + uint32_t nx_qos_ack_failure_count[8]; + uint32_t nx_qos_ureceived_mpdu_count[8]; + uint32_t nx_qos_greceived_mpdu_count[8]; + uint32_t nx_qos_ureceived_other_mpdu[8]; + uint32_t dot11_qos_retries_received_count[8]; + uint32_t nx_utransmitted_amsdu_count[8]; + uint32_t nx_gtransmitted_amsdu_count[8]; + uint32_t dot11_failed_amsdu_count[8]; + uint32_t dot11_retry_amsdu_count[8]; + uint32_t dot11_transmitted_octets_in_amsdu[8]; + uint32_t dot11_amsdu_ack_failure_count[8]; + uint32_t nx_ureceived_amsdu_count[8]; + uint32_t nx_greceived_amsdu_count[8]; + uint32_t nx_ureceived_other_amsdu[8]; + uint32_t dot11_received_octets_in_amsdu_count[8]; + uint32_t reserved_2[24]; + uint32_t dot11_transmitted_ampdu_count; + uint32_t dot11_transmitted_mpdus_in_ampdu_count; + uint32_t dot11_transmitted_octets_in_ampdu_count; + uint32_t wnlu_ampdu_received_count; + uint32_t nx_gampdu_received_count; + uint32_t nx_other_ampdu_received_count; + uint32_t dot11_mpdu_in_received_ampdu_count; + uint32_t dot11_received_octets_in_ampdu_count; + uint32_t dot11_ampdu_delimiter_crc_error_count; + uint32_t dot11_implicit_bar_failure_count; + uint32_t dot11_explicit_bar_failure_count; + uint32_t reserved_3[5]; + uint32_t dot11_20mhz_frame_transmitted_count; + uint32_t dot11_40mhz_frame_transmitted_count; + uint32_t dot11_20mhz_frame_received_count; + uint32_t dot11_40mhz_frame_received_count; + uint32_t nx_failed_40mhz_txop; + uint32_t nx_successful_txops; + uint32_t reserved_4[4]; + uint32_t dot11_dualcts_success_count; + uint32_t dot11_stbc_cts_success_count; + uint32_t dot11_stbc_cts_failure_count; + uint32_t dot11_non_stbc_cts_success_count; + uint32_t dot11_non_stbc_cts_failure_count; +}; + +typedef struct scan_probe_req_ie_tag scan_probe_req_ie_tag, *Pscan_probe_req_ie_tag; + +typedef struct tx_pbd tx_pbd, *Ptx_pbd; + +struct tx_pbd { + uint32_t upatterntx; + uint32_t next; + uint32_t datastartptr; + uint32_t dataendptr; + uint32_t bufctrlinfo; +}; + +struct scan_probe_req_ie_tag { + struct dma_desc dma_desc; + struct tx_pbd pbd; + uint32_t buf[50]; +}; + +typedef struct scan_env_tag scan_env_tag, *Pscan_env_tag; + +typedef struct scan_start_req scan_start_req, *Pscan_start_req; + +struct scan_start_req { + struct scan_chan_tag chan[42]; + struct mac_ssid ssid[2]; + struct mac_addr.conflict bssid; + undefined field_0x146; + undefined field_0x147; + uint32_t add_ies; + uint16_t add_ie_len; + uint8_t vif_idx; + uint8_t chan_cnt; + uint8_t ssid_cnt; + _Bool no_cck; + undefined field_0x152; + undefined field_0x153; +}; + +struct scan_env_tag { + struct hal_dma_desc_tag dma_desc; + struct scan_start_req * param; + uint32_t ds_ie; + ke_task_id_t req_id; + uint8_t chan_idx; + _Bool abort; +}; + +typedef enum SEC_ENG_AES_ID_Type { + SEC_ENG_AES_ID0=0 +} SEC_ENG_AES_ID_Type; + +typedef struct SEC_Eng_SHA256_Link_Ctx SEC_Eng_SHA256_Link_Ctx, *PSEC_Eng_SHA256_Link_Ctx; + +struct SEC_Eng_SHA256_Link_Ctx { + uint32_t total[2]; + uint32_t * shaBuf; + uint32_t * shaPadding; + uint32_t linkAddr; +}; + +typedef enum SEC_ENG_AES_Key_Type { + SEC_ENG_AES_DOUBLE_KEY_128BITS=3, + SEC_ENG_AES_KEY_128BITS=0, + SEC_ENG_AES_KEY_192BITS=2, + SEC_ENG_AES_KEY_256BITS=1 +} SEC_ENG_AES_Key_Type; + +typedef struct SEC_Eng_SHA_Link_Config_Type SEC_Eng_SHA_Link_Config_Type, *PSEC_Eng_SHA_Link_Config_Type; + +struct SEC_Eng_SHA_Link_Config_Type { + uint32_t shaMode:3; + uint32_t shaHashSel:1; + uint32_t shaIntClr:1; + uint32_t shaIntSet:1; + uint32_t shaMsgLen:16; + uint32_t shaSrcAddr; + uint32_t result[8]; +}; + +typedef struct SEC_Eng_SHA256_Ctx SEC_Eng_SHA256_Ctx, *PSEC_Eng_SHA256_Ctx; + +struct SEC_Eng_SHA256_Ctx { + uint32_t total[2]; + uint32_t * shaBuf; + uint32_t * shaPadding; + uint8_t shaFeed; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; +}; + +typedef enum SEC_ENG_SHA_Type { + SEC_ENG_SHA1=2, + SEC_ENG_SHA1_RSVD=3, + SEC_ENG_SHA224=1, + SEC_ENG_SHA256=0 +} SEC_ENG_SHA_Type; + +typedef enum SEC_ENG_PKA_OP_Type { + SEC_ENG_PKA_OP_CFLIRI_BUFFER=54, + SEC_ENG_PKA_OP_CFLIR_BUFFER=56, + SEC_ENG_PKA_OP_CLIR=53, + SEC_ENG_PKA_OP_CTLIRI_PLD=55, + SEC_ENG_PKA_OP_CTLIR_PLD=57, + SEC_ENG_PKA_OP_LADD=24, + SEC_ENG_PKA_OP_LCMP=25, + SEC_ENG_PKA_OP_LDIV=20, + SEC_ENG_PKA_OP_LDIV2N=18, + SEC_ENG_PKA_OP_LMUL=22, + SEC_ENG_PKA_OP_LMUL2N=19, + SEC_ENG_PKA_OP_LSQR=21, + SEC_ENG_PKA_OP_LSUB=23, + SEC_ENG_PKA_OP_MADD=40, + SEC_ENG_PKA_OP_MDIV2=33, + SEC_ENG_PKA_OP_MEXP=35, + SEC_ENG_PKA_OP_MINV=34, + SEC_ENG_PKA_OP_MMUL=37, + SEC_ENG_PKA_OP_MOD2N=17, + SEC_ENG_PKA_OP_MOVDAT=50, + SEC_ENG_PKA_OP_MREM=38, + SEC_ENG_PKA_OP_MSQR=36, + SEC_ENG_PKA_OP_MSUB=39, + SEC_ENG_PKA_OP_NLIR=51, + SEC_ENG_PKA_OP_PPSEL=0, + SEC_ENG_PKA_OP_RESIZE=49, + SEC_ENG_PKA_OP_SLIR=52 +} SEC_ENG_PKA_OP_Type; + +typedef enum SEC_ENG_AES_Key_Src_Type { + SEC_ENG_AES_KEY_HW=1, + SEC_ENG_AES_KEY_SW=0 +} SEC_ENG_AES_Key_Src_Type; + +typedef struct SEC_Eng_AES_Ctx SEC_Eng_AES_Ctx, *PSEC_Eng_AES_Ctx; + +typedef enum SEC_ENG_AES_Type { + SEC_ENG_AES_CBC=2, + SEC_ENG_AES_CTR=1, + SEC_ENG_AES_ECB=0 +} SEC_ENG_AES_Type; + +struct SEC_Eng_AES_Ctx { + uint8_t aesFeed; + enum SEC_ENG_AES_Type mode; +}; + +typedef enum SEC_ENG_AES_EnDec_Type { + SEC_ENG_AES_DECRYPTION=1, + SEC_ENG_AES_ENCRYPTION=0 +} SEC_ENG_AES_EnDec_Type; + +typedef enum SEC_ENG_SHA_ID_Type { + SEC_ENG_SHA_ID0=0 +} SEC_ENG_SHA_ID_Type; + +typedef enum SEC_ENG_AES_Counter_Type { + SEC_ENG_AES_COUNTER_BYTE_1=1, + SEC_ENG_AES_COUNTER_BYTE_2=2, + SEC_ENG_AES_COUNTER_BYTE_3=3, + SEC_ENG_AES_COUNTER_BYTE_4=0 +} SEC_ENG_AES_Counter_Type; + +typedef enum SEC_ENG_PKA_REG_SIZE_Type { + SEC_ENG_PKA_REG_SIZE_128=6, + SEC_ENG_PKA_REG_SIZE_16=2, + SEC_ENG_PKA_REG_SIZE_192=7, + SEC_ENG_PKA_REG_SIZE_256=8, + SEC_ENG_PKA_REG_SIZE_32=3, + SEC_ENG_PKA_REG_SIZE_384=9, + SEC_ENG_PKA_REG_SIZE_512=10, + SEC_ENG_PKA_REG_SIZE_64=4, + SEC_ENG_PKA_REG_SIZE_8=1, + SEC_ENG_PKA_REG_SIZE_96=5 +} SEC_ENG_PKA_REG_SIZE_Type; + +typedef enum SEC_ENG_INT_Type { + SEC_ENG_INT_AES=1, + SEC_ENG_INT_ALL=6, + SEC_ENG_INT_CDET=4, + SEC_ENG_INT_GMAC=5, + SEC_ENG_INT_PKA=3, + SEC_ENG_INT_SHA=2, + SEC_ENG_INT_TRNG=0 +} SEC_ENG_INT_Type; + +typedef struct ip4_addr ip4_addr, *Pip4_addr; + +typedef struct ip4_addr ip4_addr_t; + +typedef ip4_addr_t ip_addr_t; + +typedef uint32_t u32_t; + +struct ip4_addr { + u32_t addr; +}; + +typedef enum lwip_ip_addr_type { + IPADDR_TYPE_ANY=46, + IPADDR_TYPE_V4=0, + IPADDR_TYPE_V6=6 +} lwip_ip_addr_type; + +typedef struct pka0_common_op_snd_cfg_S2_only.conflict pka0_common_op_snd_cfg_S2_only.conflict, *Ppka0_common_op_snd_cfg_S2_only.conflict; + +typedef union anon_union_for_value.conflict anon_union_for_value.conflict, *Panon_union_for_value.conflict; + +typedef struct anon_struct.conflict134 anon_struct.conflict134, *Panon_struct.conflict134; + +struct anon_struct.conflict134 { + uint32_t s2_reg_idx:8; + uint32_t s2_reg_type:4; + uint32_t reserved_12_31:20; +}; + +union anon_union_for_value.conflict { + struct anon_struct.conflict134 BF; + uint32_t WORD; +}; + +struct pka0_common_op_snd_cfg_S2_only.conflict { + union anon_union_for_value.conflict value; +}; + +typedef struct anon_struct.conflict125 anon_struct.conflict125, *Panon_struct.conflict125; + +struct anon_struct.conflict125 { + uint32_t size:12; + uint32_t d_reg_index:8; + uint32_t d_reg_type:4; + uint32_t op:7; + uint32_t last_op:1; +}; + +typedef struct anon_struct.conflict126 anon_struct.conflict126, *Panon_struct.conflict126; + +struct anon_struct.conflict126 { + uint32_t size:12; + uint32_t d_reg_index:8; + uint32_t d_reg_type:4; + uint32_t op:7; + uint32_t last_op:1; +}; + +typedef struct anon_struct.conflict127 anon_struct.conflict127, *Panon_struct.conflict127; + +struct anon_struct.conflict127 { + uint32_t rsvd:12; + uint32_t d_reg_index:8; + uint32_t d_reg_type:4; + uint32_t op:7; + uint32_t last_op:1; +}; + +typedef struct anon_struct.conflict128 anon_struct.conflict128, *Panon_struct.conflict128; + +struct anon_struct.conflict128 { + uint32_t rsvd:12; + uint32_t d_reg_index:8; + uint32_t d_reg_type:4; + uint32_t op:7; + uint32_t last_op:1; +}; + +typedef struct anon_struct.conflict129 anon_struct.conflict129, *Panon_struct.conflict129; + +struct anon_struct.conflict129 { + uint32_t s0_reg_idx:8; + uint32_t s0_reg_type:4; + uint32_t d_reg_idx:8; + uint32_t d_reg_type:4; + uint32_t op:7; + uint32_t last_op:1; +}; + +typedef struct anon_struct.conflict130 anon_struct.conflict130, *Panon_struct.conflict130; + +struct anon_struct.conflict130 { + uint32_t s0_reg_idx:8; + uint32_t s0_reg_type:4; + uint32_t d_reg_idx:8; + uint32_t d_reg_type:4; + uint32_t op:7; + uint32_t last_op:1; +}; + +typedef struct anon_struct.conflict131 anon_struct.conflict131, *Panon_struct.conflict131; + +struct anon_struct.conflict131 { + uint32_t reserved_0_11:12; + uint32_t s1_reg_idx:8; + uint32_t s1_reg_type:4; + uint32_t reserved_24_31:8; +}; + +typedef struct anon_struct.conflict136 anon_struct.conflict136, *Panon_struct.conflict136; + +struct anon_struct.conflict136 { + uint32_t s2_reg_idx:8; + uint32_t s2_reg_type:4; + uint32_t s1_reg_idx:8; + uint32_t s1_reg_type:4; + uint32_t reserved_24_31:8; +}; + +typedef struct anon_struct.conflict137 anon_struct.conflict137, *Panon_struct.conflict137; + +struct anon_struct.conflict137 { + uint32_t bit_shift:15; + uint32_t reserved_24_31:17; +}; + +typedef struct anon_struct.conflict138 anon_struct.conflict138, *Panon_struct.conflict138; + +struct anon_struct.conflict138 { + uint32_t bit_shift:15; + uint32_t reserved_24_31:17; +}; + +typedef struct anon_struct.conflict132 anon_struct.conflict132, *Panon_struct.conflict132; + +struct anon_struct.conflict132 { + uint32_t reserved_0_11:12; + uint32_t s1_reg_idx:8; + uint32_t s1_reg_type:4; + uint32_t reserved_24_31:8; +}; + +typedef struct anon_struct.conflict133 anon_struct.conflict133, *Panon_struct.conflict133; + +struct anon_struct.conflict133 { + uint32_t s2_reg_idx:8; + uint32_t s2_reg_type:4; + uint32_t reserved_12_31:20; +}; + +typedef struct anon_struct.conflict135 anon_struct.conflict135, *Panon_struct.conflict135; + +struct anon_struct.conflict135 { + uint32_t s2_reg_idx:8; + uint32_t s2_reg_type:4; + uint32_t s1_reg_idx:8; + uint32_t s1_reg_type:4; + uint32_t reserved_24_31:8; +}; + +typedef struct pka0_pld_cfg.conflict pka0_pld_cfg.conflict, *Ppka0_pld_cfg.conflict; + + +// WARNING! conflicting data type names: /DWARF/_UNCATEGORIZED_/pka0_pld_cfg/anon_union_for_value.conflict - /DWARF/_UNCATEGORIZED_/pka0_common_op_snd_cfg_S2_only/anon_union_for_value.conflict + +struct pka0_pld_cfg.conflict { + union anon_union_for_value.conflict value; +}; + +typedef struct pka0_pldi_cfg pka0_pldi_cfg, *Ppka0_pldi_cfg; + +typedef union anon_union_for_value anon_union_for_value, *Panon_union_for_value; + +union anon_union_for_value { + struct anon_struct.conflict128 BF; + uint32_t WORD; +}; + +struct pka0_pldi_cfg { + union anon_union_for_value value; +}; + +typedef struct pka0_common_op_first_cfg.conflict pka0_common_op_first_cfg.conflict, *Ppka0_common_op_first_cfg.conflict; + + +// WARNING! conflicting data type names: /DWARF/_UNCATEGORIZED_/pka0_common_op_first_cfg/anon_union_for_value.conflict - /DWARF/_UNCATEGORIZED_/pka0_common_op_snd_cfg_S2_only/anon_union_for_value.conflict + +struct pka0_common_op_first_cfg.conflict { + union anon_union_for_value.conflict value; +}; + +typedef struct pka0_common_op_snd_cfg_S1_only.conflict pka0_common_op_snd_cfg_S1_only.conflict, *Ppka0_common_op_snd_cfg_S1_only.conflict; + + +// WARNING! conflicting data type names: /DWARF/_UNCATEGORIZED_/pka0_common_op_snd_cfg_S1_only/anon_union_for_value.conflict - /DWARF/_UNCATEGORIZED_/pka0_common_op_snd_cfg_S2_only/anon_union_for_value.conflict + +struct pka0_common_op_snd_cfg_S1_only.conflict { + union anon_union_for_value.conflict value; +}; + +typedef struct pka0_bit_shift_op_cfg.conflict pka0_bit_shift_op_cfg.conflict, *Ppka0_bit_shift_op_cfg.conflict; + + +// WARNING! conflicting data type names: /DWARF/_UNCATEGORIZED_/pka0_bit_shift_op_cfg/anon_union_for_value.conflict - /DWARF/_UNCATEGORIZED_/pka0_common_op_snd_cfg_S2_only/anon_union_for_value.conflict + +struct pka0_bit_shift_op_cfg.conflict { + union anon_union_for_value.conflict value; +}; + +typedef struct pka0_common_op_snd_cfg_S1_S2.conflict pka0_common_op_snd_cfg_S1_S2.conflict, *Ppka0_common_op_snd_cfg_S1_S2.conflict; + + +// WARNING! conflicting data type names: /DWARF/_UNCATEGORIZED_/pka0_common_op_snd_cfg_S1_S2/anon_union_for_value.conflict - /DWARF/_UNCATEGORIZED_/pka0_common_op_snd_cfg_S2_only/anon_union_for_value.conflict + +struct pka0_common_op_snd_cfg_S1_S2.conflict { + union anon_union_for_value.conflict value; +}; + +typedef struct _ef_env _ef_env, *P_ef_env; + +typedef struct _ef_env ef_env; + +struct _ef_env { + char * key; + void * value; + size_t value_len; +}; + +typedef enum env_status { + ENV_DELETED=4, + ENV_ERR_HDR=5, + ENV_PRE_DELETE=3, + ENV_PRE_WRITE=1, + ENV_STATUS_NUM=6, + ENV_UNUSED=0, + ENV_WRITE=2 +} env_status; + +typedef enum env_status env_status_t; + +typedef enum EfErrCode { + EF_ENV_ARG_ERR=8, + EF_ENV_FULL=6, + EF_ENV_INIT_FAILED=7, + EF_ENV_NAME_ERR=4, + EF_ENV_NAME_EXIST=5, + EF_ERASE_ERR=1, + EF_NO_ERR=0, + EF_READ_ERR=2, + EF_WRITE_ERR=3 +} EfErrCode; + +typedef struct env_node_obj env_node_obj, *Penv_node_obj; + +typedef struct anon_struct_for_addr anon_struct_for_addr, *Panon_struct_for_addr; + +struct anon_struct_for_addr { + uint32_t start; + uint32_t value; +}; + +struct env_node_obj { + env_status_t status; + _Bool crc_is_ok; + uint8_t name_len; + undefined field_0x3; + uint32_t magic; + uint32_t len; + uint32_t value_len; + char name[64]; + struct anon_struct_for_addr addr; +}; + +typedef struct anon_struct.conflict114 anon_struct.conflict114, *Panon_struct.conflict114; + +struct anon_struct.conflict114 { + uint32_t start; + uint32_t value; +}; + +typedef struct env_node_obj * env_node_obj_t; + +typedef struct dbg_mem_write_req dbg_mem_write_req, *Pdbg_mem_write_req; + +struct dbg_mem_write_req { + uint32_t memaddr; + uint32_t memdata; +}; + +typedef struct dbg_set_sev_filter_req dbg_set_sev_filter_req, *Pdbg_set_sev_filter_req; + +struct dbg_set_sev_filter_req { + uint32_t sev_filter; +}; + +typedef struct dbg_mem_read_req dbg_mem_read_req, *Pdbg_mem_read_req; + +struct dbg_mem_read_req { + uint32_t memaddr; +}; + +typedef struct dbg_mem_write_cfm dbg_mem_write_cfm, *Pdbg_mem_write_cfm; + +struct dbg_mem_write_cfm { + uint32_t memaddr; + uint32_t memdata; +}; + +typedef struct dbg_get_sys_stat_cfm dbg_get_sys_stat_cfm, *Pdbg_get_sys_stat_cfm; + +struct dbg_get_sys_stat_cfm { + uint32_t cpu_sleep_time; + uint32_t doze_time; + uint32_t stats_time; +}; + +typedef struct dbg_mem_read_cfm dbg_mem_read_cfm, *Pdbg_mem_read_cfm; + +struct dbg_mem_read_cfm { + uint32_t memaddr; + uint32_t memdata; +}; + +typedef struct dbg_set_mod_filter_req dbg_set_mod_filter_req, *Pdbg_set_mod_filter_req; + +struct dbg_set_mod_filter_req { + uint32_t mod_filter; +}; + +typedef struct bt_gatt_discover_params.conflict bt_gatt_discover_params.conflict, *Pbt_gatt_discover_params.conflict; + +typedef struct bt_conn bt_conn, *Pbt_conn; + +typedef struct bt_gatt_attr bt_gatt_attr, *Pbt_gatt_attr; + +typedef int _ssize_t; + +typedef _ssize_t ssize_t; + +typedef struct bt_gatt_discover_params bt_gatt_discover_params, *Pbt_gatt_discover_params; + +typedef struct bt_att_req.conflict2 bt_att_req.conflict2, *Pbt_att_req.conflict2; + +typedef enum bt_security_t { + BT_SECURITY_FIPS=4, + BT_SECURITY_FORCE_PAIR=-128, + BT_SECURITY_HIGH=3, + BT_SECURITY_L0=0, + BT_SECURITY_L1=1, + BT_SECURITY_L2=2, + BT_SECURITY_L3=3, + BT_SECURITY_L4=4, + BT_SECURITY_LOW=1, + BT_SECURITY_MEDIUM=2, + BT_SECURITY_NONE=0 +} bt_security_t; + +typedef enum bt_conn_state_t { + BT_CONN_CONNECT=3, + BT_CONN_CONNECTED=4, + BT_CONN_CONNECT_DIR_ADV=2, + BT_CONN_CONNECT_SCAN=1, + BT_CONN_DISCONNECT=5, + BT_CONN_DISCONNECTED=0 +} bt_conn_state_t; + +typedef struct _slist _slist, *P_slist; + +typedef struct _slist sys_slist_t; + +typedef struct k_delayed_work k_delayed_work, *Pk_delayed_work; + +typedef union anon_union_for_field_20 anon_union_for_field_20, *Panon_union_for_field_20; + +typedef struct bt_att_req.conflict1 bt_att_req.conflict1, *Pbt_att_req.conflict1; + +typedef union anon_union_for_field_3 anon_union_for_field_3, *Panon_union_for_field_3; + +typedef struct net_buf_simple_state net_buf_simple_state, *Pnet_buf_simple_state; + +typedef struct k_work_q k_work_q, *Pk_work_q; + +typedef struct k_timer k_timer, *Pk_timer; + +typedef struct k_timer k_timer_t; + +typedef struct bt_conn_le bt_conn_le, *Pbt_conn_le; + +typedef struct anon_struct.conflict89 anon_struct.conflict89, *Panon_struct.conflict89; + +typedef struct bl_hdl_t bl_timer_t; + +typedef struct bt_keys bt_keys, *Pbt_keys; + +typedef struct bt_ltk bt_ltk, *Pbt_ltk; + +typedef struct bt_irk bt_irk, *Pbt_irk; + +typedef struct bt_csrk bt_csrk, *Pbt_csrk; + +struct bt_irk { + u8_t val[16]; + struct bt_addr_t rpa; +}; + +struct bt_ltk { + u8_t rand[8]; + u8_t ediv[2]; + u8_t val[16]; +}; + +struct bt_csrk { + u8_t val[16]; + u32_t.conflict cnt; +}; + +struct bt_keys { + u8_t id; + struct bt_addr_le_t addr; + u8_t enc_size; + u8_t flags; + u16_t keys; + struct bt_ltk ltk; + struct bt_irk irk; + struct bt_csrk local_csrk; + struct bt_csrk remote_csrk; + struct bt_ltk slave_ltk; + undefined field_0x7e; + undefined field_0x7f; + u32_t.conflict aging_counter; +}; + +struct bt_gatt_attr { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +struct net_buf_simple_state { + u16_t offset; + u16_t len; +}; + +struct bt_att_req.conflict2 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + void (* destroy)(void *); + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct anon_struct.conflict89 { + u16_t attr_handle; + u16_t start_handle; + u16_t end_handle; +}; + +union anon_union_for_field_3 { + struct anon_struct.conflict89 _included; + u16_t start_handle; +}; + +struct bt_gatt_discover_params.conflict { + struct bt_att_req.conflict2 _req; + struct bt_uuid * uuid; + u8_t (* func)(struct bt_conn *, struct bt_gatt_attr *, struct bt_gatt_discover_params *); + union anon_union_for_field_3 field_3; + u16_t end_handle; + u8_t type; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +struct bt_att_req.conflict1 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + void (* destroy)(void *); + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct k_timer { + bl_timer_t timer; + void (* handler)(void *); + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +struct k_delayed_work { + struct k_work work; + struct k_work_q * work_q; + k_timer_t timer; +}; + +struct _slist { + sys_snode_t * head; + sys_snode_t * tail; +}; + +struct bt_conn_le { + struct bt_addr_le_t dst; + struct bt_addr_le_t init_addr; + struct bt_addr_le_t resp_addr; + undefined field_0x15; + u16_t interval; + u16_t interval_min; + u16_t interval_max; + u16_t latency; + u16_t timeout; + u16_t pending_latency; + u16_t pending_timeout; + u8_t features[8]; + struct bt_keys * keys; +}; + +union anon_union_for_field_20 { + struct bt_conn_le le; +}; + +struct bt_conn { + u16_t handle; + u8_t type; + u8_t role; + atomic_t flags[1]; + u8_t id; + enum bt_security_t sec_level; + enum bt_security_t required_sec_level; + u8_t encrypt; + u8_t err; + enum bt_conn_state_t state; + u16_t rx_len; + struct net_buf * rx; + sys_slist_t tx_pending; + u32_t.conflict pending_no_cb; + sys_slist_t tx_complete; + struct k_work tx_complete_work; + struct k_fifo tx_queue; + sys_slist_t channels; + atomic_t ref; + struct k_delayed_work update_work; + union anon_union_for_field_20 field_20; +}; + +struct k_work_q { + struct k_fifo fifo; +}; + +struct bt_gatt_discover_params { + struct bt_att_req.conflict1 _req; + struct bt_uuid * uuid; + u8_t (* func)(struct bt_conn *, struct bt_gatt_attr *, struct bt_gatt_discover_params *); + union anon_union_for_field_3 field_3; + u16_t end_handle; + u8_t type; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct _bt_gatt_ccc.conflict1 _bt_gatt_ccc.conflict1, *P_bt_gatt_ccc.conflict1; + +typedef struct bt_gatt_ccc_cfg bt_gatt_ccc_cfg, *Pbt_gatt_ccc_cfg; + +struct bt_gatt_ccc_cfg { + u8_t id; + struct bt_addr_le_t peer; + u16_t value; +}; + +struct _bt_gatt_ccc.conflict1 { + struct bt_gatt_ccc_cfg cfg[2]; + u16_t value; + undefined field_0x16; + undefined field_0x17; + void (* cfg_changed)(struct bt_gatt_attr *, u16_t); + _Bool (* cfg_write)(struct bt_conn *, struct bt_gatt_attr *, u16_t); + _Bool (* cfg_match)(struct bt_conn *, struct bt_gatt_attr *); +}; + +typedef struct _bt_gatt_ccc.conflict3 _bt_gatt_ccc.conflict3, *P_bt_gatt_ccc.conflict3; + +struct _bt_gatt_ccc.conflict3 { + struct bt_gatt_ccc_cfg cfg[2]; + u16_t value; + undefined field_0x16; + undefined field_0x17; + void (* cfg_changed)(struct bt_gatt_attr *, u16_t); + _Bool (* cfg_write)(struct bt_conn *, struct bt_gatt_attr *, u16_t); + _Bool (* cfg_match)(struct bt_conn *, struct bt_gatt_attr *); +}; + +typedef struct _bt_gatt_ccc.conflict2 _bt_gatt_ccc.conflict2, *P_bt_gatt_ccc.conflict2; + +struct _bt_gatt_ccc.conflict2 { + struct bt_gatt_ccc_cfg cfg[2]; + u16_t value; + undefined field_0x16; + undefined field_0x17; + void (* cfg_changed)(struct bt_gatt_attr *, u16_t); + _Bool (* cfg_write)(struct bt_conn *, struct bt_gatt_attr *, u16_t); + _Bool (* cfg_match)(struct bt_conn *, struct bt_gatt_attr *); +}; + +typedef struct bt_gatt_indicate_params.conflict3 bt_gatt_indicate_params.conflict3, *Pbt_gatt_indicate_params.conflict3; + +typedef struct bt_att_req.conflict19 bt_att_req.conflict19, *Pbt_att_req.conflict19; + +typedef void (* bt_att_destroy_t.conflict)(void *); + +struct bt_att_req.conflict19 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t.conflict destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_indicate_params.conflict3 { + struct bt_att_req.conflict19 _req; + struct bt_uuid * uuid; + struct bt_gatt_attr * attr; + void (* func)(struct bt_conn *, struct bt_gatt_attr *, u8_t); + void * data; + u16_t len; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct anon_struct.conflict105 anon_struct.conflict105, *Panon_struct.conflict105; + +struct anon_struct.conflict105 { + u16_t attr_handle; + u16_t start_handle; + u16_t end_handle; +}; + +typedef struct anon_struct.conflict106 anon_struct.conflict106, *Panon_struct.conflict106; + +struct anon_struct.conflict106 { + u16_t handle; + u16_t offset; +}; + +typedef struct bt_gatt_chrc bt_gatt_chrc, *Pbt_gatt_chrc; + +struct bt_gatt_chrc { + struct bt_uuid * uuid; + u16_t value_handle; + u8_t properties; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict107 anon_struct.conflict107, *Panon_struct.conflict107; + +struct anon_struct.conflict107 { + u16_t start_handle; + u16_t end_handle; + struct bt_uuid * uuid; +}; + +typedef struct bt_gatt_service_val bt_gatt_service_val, *Pbt_gatt_service_val; + +struct bt_gatt_service_val { + struct bt_uuid * uuid; + u16_t end_handle; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct bt_gatt_read_params.conflict bt_gatt_read_params.conflict, *Pbt_gatt_read_params.conflict; + +typedef struct bt_gatt_read_params bt_gatt_read_params, *Pbt_gatt_read_params; + +typedef struct bt_att_req.conflict4 bt_att_req.conflict4, *Pbt_att_req.conflict4; + +typedef struct bt_att_req.conflict3 bt_att_req.conflict3, *Pbt_att_req.conflict3; + + +// WARNING! conflicting data type names: /DWARF/gatt.h/bt_gatt_read_params/anon_union_for_field_3 - /DWARF/gatt.h/bt_gatt_discover_params/anon_union_for_field_3 + +struct bt_att_req.conflict4 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + void (* destroy)(void *); + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_att_req.conflict3 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + void (* destroy)(void *); + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_read_params { + struct bt_att_req.conflict3 _req; + u8_t (* func)(struct bt_conn *, u8_t, struct bt_gatt_read_params *, void *, u16_t); + size_t handle_count; + union anon_union_for_field_3 field_3; +}; + +struct bt_gatt_read_params.conflict { + struct bt_att_req.conflict4 _req; + u8_t (* func)(struct bt_conn *, u8_t, struct bt_gatt_read_params *, void *, u16_t); + size_t handle_count; + union anon_union_for_field_3 field_3; +}; + +typedef struct bt_gatt_service bt_gatt_service, *Pbt_gatt_service; + +struct bt_gatt_service { + struct bt_gatt_attr * attrs; + size_t attr_count; + sys_snode_t node; +}; + +typedef struct bt_gatt_discover_params.conflict1 bt_gatt_discover_params.conflict1, *Pbt_gatt_discover_params.conflict1; + +typedef struct bt_att_req.conflict12 bt_att_req.conflict12, *Pbt_att_req.conflict12; + +struct bt_att_req.conflict12 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t.conflict destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_discover_params.conflict1 { + struct bt_att_req.conflict12 _req; + struct bt_uuid * uuid; + u8_t (* func)(struct bt_conn *, struct bt_gatt_attr *, struct bt_gatt_discover_params *); + union anon_union_for_field_3 field_3; + u16_t end_handle; + u8_t type; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct bt_gatt_cep bt_gatt_cep, *Pbt_gatt_cep; + +struct bt_gatt_cep { + u16_t properties; +}; + +typedef struct bt_gatt_attr.conflict11 bt_gatt_attr.conflict11, *Pbt_gatt_attr.conflict11; + +struct bt_gatt_attr.conflict11 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_indicate_params.conflict1 bt_gatt_indicate_params.conflict1, *Pbt_gatt_indicate_params.conflict1; + +typedef struct bt_att_req.conflict17 bt_att_req.conflict17, *Pbt_att_req.conflict17; + +struct bt_att_req.conflict17 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t.conflict destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_indicate_params.conflict1 { + struct bt_att_req.conflict17 _req; + struct bt_uuid * uuid; + struct bt_gatt_attr * attr; + void (* func)(struct bt_conn *, struct bt_gatt_attr *, u8_t); + void * data; + u16_t len; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct bt_gatt_exchange_params bt_gatt_exchange_params, *Pbt_gatt_exchange_params; + +typedef struct bt_att_req.conflict bt_att_req.conflict, *Pbt_att_req.conflict; + +struct bt_att_req.conflict { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + void (* destroy)(void *); + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_exchange_params { + struct bt_att_req.conflict _req; + void (* func)(struct bt_conn *, u8_t, struct bt_gatt_exchange_params *); +}; + +typedef struct bt_gatt_write_params bt_gatt_write_params, *Pbt_gatt_write_params; + +typedef struct bt_att_req.conflict5 bt_att_req.conflict5, *Pbt_att_req.conflict5; + +struct bt_att_req.conflict5 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + void (* destroy)(void *); + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_write_params { + struct bt_att_req.conflict5 _req; + void (* func)(struct bt_conn *, u8_t, struct bt_gatt_write_params *); + u16_t handle; + u16_t offset; + void * data; + u16_t length; + undefined field_0x26; + undefined field_0x27; +}; + +typedef struct bt_gatt_include bt_gatt_include, *Pbt_gatt_include; + +struct bt_gatt_include { + struct bt_uuid * uuid; + u16_t start_handle; + u16_t end_handle; +}; + +typedef struct bt_gatt_indicate_params.conflict4 bt_gatt_indicate_params.conflict4, *Pbt_gatt_indicate_params.conflict4; + +typedef struct bt_att_req.conflict21 bt_att_req.conflict21, *Pbt_att_req.conflict21; + +struct bt_att_req.conflict21 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t.conflict destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_indicate_params.conflict4 { + struct bt_att_req.conflict21 _req; + struct bt_uuid * uuid; + struct bt_gatt_attr * attr; + void (* func)(struct bt_conn *, struct bt_gatt_attr *, u8_t); + void * data; + u16_t len; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct bt_gatt_attr.conflict6 bt_gatt_attr.conflict6, *Pbt_gatt_attr.conflict6; + +struct bt_gatt_attr.conflict6 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_subscribe_params.conflict bt_gatt_subscribe_params.conflict, *Pbt_gatt_subscribe_params.conflict; + +typedef struct bt_gatt_subscribe_params bt_gatt_subscribe_params, *Pbt_gatt_subscribe_params; + +typedef struct bt_att_req.conflict8 bt_att_req.conflict8, *Pbt_att_req.conflict8; + +typedef struct bt_att_req.conflict7 bt_att_req.conflict7, *Pbt_att_req.conflict7; + +struct bt_att_req.conflict8 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + void (* destroy)(void *); + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_subscribe_params.conflict { + struct bt_att_req.conflict8 _req; + struct bt_addr_le_t _peer; + undefined field_0x1f; + u8_t (* notify)(struct bt_conn *, struct bt_gatt_subscribe_params *, void *, u16_t); + u16_t value_handle; + u16_t ccc_handle; + u16_t value; + undefined field_0x2a; + undefined field_0x2b; + atomic_t flags[1]; + sys_snode_t node; +}; + +struct bt_att_req.conflict7 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + void (* destroy)(void *); + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_subscribe_params { + struct bt_att_req.conflict7 _req; + struct bt_addr_le_t _peer; + undefined field_0x1f; + u8_t (* notify)(struct bt_conn *, struct bt_gatt_subscribe_params *, void *, u16_t); + u16_t value_handle; + u16_t ccc_handle; + u16_t value; + undefined field_0x2a; + undefined field_0x2b; + atomic_t flags[1]; + sys_snode_t node; +}; + +typedef struct bt_gatt_indicate_params.conflict2 bt_gatt_indicate_params.conflict2, *Pbt_gatt_indicate_params.conflict2; + +typedef struct bt_att_req.conflict18 bt_att_req.conflict18, *Pbt_att_req.conflict18; + +struct bt_att_req.conflict18 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t.conflict destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_indicate_params.conflict2 { + struct bt_att_req.conflict18 _req; + struct bt_uuid * uuid; + struct bt_gatt_attr * attr; + void (* func)(struct bt_conn *, struct bt_gatt_attr *, u8_t); + void * data; + u16_t len; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct bt_gatt_service_static bt_gatt_service_static, *Pbt_gatt_service_static; + +struct bt_gatt_service_static { + struct bt_gatt_attr * attrs; + size_t attr_count; +}; + +typedef struct bt_gatt_attr.conflict5 bt_gatt_attr.conflict5, *Pbt_gatt_attr.conflict5; + +struct bt_gatt_attr.conflict5 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_attr.conflict4 bt_gatt_attr.conflict4, *Pbt_gatt_attr.conflict4; + +struct bt_gatt_attr.conflict4 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_attr.conflict10 bt_gatt_attr.conflict10, *Pbt_gatt_attr.conflict10; + +struct bt_gatt_attr.conflict10 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct _bt_gatt_ccc _bt_gatt_ccc, *P_bt_gatt_ccc; + +struct _bt_gatt_ccc { + struct bt_gatt_ccc_cfg cfg[2]; + u16_t value; + undefined field_0x16; + undefined field_0x17; + void (* cfg_changed)(struct bt_gatt_attr *, u16_t); + _Bool (* cfg_write)(struct bt_conn *, struct bt_gatt_attr *, u16_t); + _Bool (* cfg_match)(struct bt_conn *, struct bt_gatt_attr *); +}; + +typedef struct bt_gatt_cpf bt_gatt_cpf, *Pbt_gatt_cpf; + +struct bt_gatt_cpf { + u8_t format; + s8_t exponent; + u16_t unit; + u8_t name_space; + u16_t description; +}; + +typedef struct bt_gatt_exchange_params.conflict bt_gatt_exchange_params.conflict, *Pbt_gatt_exchange_params.conflict; + +typedef struct bt_att_req.conflict11 bt_att_req.conflict11, *Pbt_att_req.conflict11; + +struct bt_att_req.conflict11 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t.conflict destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_exchange_params.conflict { + struct bt_att_req.conflict11 _req; + void (* func)(struct bt_conn *, u8_t, struct bt_gatt_exchange_params *); +}; + +typedef struct bt_gatt_indicate_params bt_gatt_indicate_params, *Pbt_gatt_indicate_params; + +typedef struct bt_att_req.conflict10 bt_att_req.conflict10, *Pbt_att_req.conflict10; + +struct bt_att_req.conflict10 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t.conflict destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_indicate_params { + struct bt_att_req.conflict10 _req; + struct bt_uuid * uuid; + struct bt_gatt_attr * attr; + void (* func)(struct bt_conn *, struct bt_gatt_attr *, u8_t); + void * data; + u16_t len; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct anon_struct.conflict94 anon_struct.conflict94, *Panon_struct.conflict94; + +struct anon_struct.conflict94 { + u16_t start_handle; + u16_t end_handle; + struct bt_uuid * uuid; +}; + +typedef struct anon_struct.conflict93 anon_struct.conflict93, *Panon_struct.conflict93; + +struct anon_struct.conflict93 { + u16_t handle; + u16_t offset; +}; + +typedef struct anon_struct.conflict92 anon_struct.conflict92, *Panon_struct.conflict92; + +struct anon_struct.conflict92 { + u16_t start_handle; + u16_t end_handle; + struct bt_uuid * uuid; +}; + +typedef struct anon_struct.conflict91 anon_struct.conflict91, *Panon_struct.conflict91; + +struct anon_struct.conflict91 { + u16_t handle; + u16_t offset; +}; + +typedef struct bt_gatt_notify_params.conflict1 bt_gatt_notify_params.conflict1, *Pbt_gatt_notify_params.conflict1; + +struct bt_gatt_notify_params.conflict1 { + struct bt_uuid * uuid; + struct bt_gatt_attr * attr; + void * data; + u16_t len; + undefined field_0xe; + undefined field_0xf; + void (* func)(struct bt_conn *, void *); + void * user_data; +}; + +typedef struct anon_struct.conflict90 anon_struct.conflict90, *Panon_struct.conflict90; + +struct anon_struct.conflict90 { + u16_t attr_handle; + u16_t start_handle; + u16_t end_handle; +}; + +typedef struct bt_gatt_notify_params.conflict bt_gatt_notify_params.conflict, *Pbt_gatt_notify_params.conflict; + +struct bt_gatt_notify_params.conflict { + struct bt_uuid * uuid; + struct bt_gatt_attr * attr; + void * data; + u16_t len; + undefined field_0xe; + undefined field_0xf; + void (* func)(struct bt_conn *, void *); + void * user_data; +}; + +typedef struct bt_gatt_write_params.conflict bt_gatt_write_params.conflict, *Pbt_gatt_write_params.conflict; + +typedef struct bt_att_req.conflict6 bt_att_req.conflict6, *Pbt_att_req.conflict6; + +struct bt_att_req.conflict6 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + void (* destroy)(void *); + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_write_params.conflict { + struct bt_att_req.conflict6 _req; + void (* func)(struct bt_conn *, u8_t, struct bt_gatt_write_params *); + u16_t handle; + u16_t offset; + void * data; + u16_t length; + undefined field_0x26; + undefined field_0x27; +}; + +typedef struct bt_gatt_notify_params bt_gatt_notify_params, *Pbt_gatt_notify_params; + +struct bt_gatt_notify_params { + struct bt_uuid * uuid; + struct bt_gatt_attr * attr; + void * data; + u16_t len; + undefined field_0xe; + undefined field_0xf; + void (* func)(struct bt_conn *, void *); + void * user_data; +}; + +typedef struct bt_gatt_write_params.conflict1 bt_gatt_write_params.conflict1, *Pbt_gatt_write_params.conflict1; + +typedef struct bt_att_req.conflict14 bt_att_req.conflict14, *Pbt_att_req.conflict14; + +struct bt_att_req.conflict14 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t.conflict destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_write_params.conflict1 { + struct bt_att_req.conflict14 _req; + void (* func)(struct bt_conn *, u8_t, struct bt_gatt_write_params *); + u16_t handle; + u16_t offset; + void * data; + u16_t length; + undefined field_0x26; + undefined field_0x27; +}; + +typedef struct bt_gatt_attr.conflict3 bt_gatt_attr.conflict3, *Pbt_gatt_attr.conflict3; + +struct bt_gatt_attr.conflict3 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_attr.conflict1 bt_gatt_attr.conflict1, *Pbt_gatt_attr.conflict1; + +struct bt_gatt_attr.conflict1 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_attr.conflict2 bt_gatt_attr.conflict2, *Pbt_gatt_attr.conflict2; + +struct bt_gatt_attr.conflict2 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_attr.conflict9 bt_gatt_attr.conflict9, *Pbt_gatt_attr.conflict9; + +struct bt_gatt_attr.conflict9 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_read_params.conflict1 bt_gatt_read_params.conflict1, *Pbt_gatt_read_params.conflict1; + +typedef struct bt_att_req.conflict13 bt_att_req.conflict13, *Pbt_att_req.conflict13; + +struct bt_att_req.conflict13 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t.conflict destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_read_params.conflict1 { + struct bt_att_req.conflict13 _req; + u8_t (* func)(struct bt_conn *, u8_t, struct bt_gatt_read_params *, void *, u16_t); + size_t handle_count; + union anon_union_for_field_3 field_3; +}; + +typedef struct bt_gatt_attr.conflict7 bt_gatt_attr.conflict7, *Pbt_gatt_attr.conflict7; + +struct bt_gatt_attr.conflict7 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_attr.conflict8 bt_gatt_attr.conflict8, *Pbt_gatt_attr.conflict8; + +struct bt_gatt_attr.conflict8 { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct bt_gatt_subscribe_params.conflict1 bt_gatt_subscribe_params.conflict1, *Pbt_gatt_subscribe_params.conflict1; + +typedef struct bt_att_req.conflict15 bt_att_req.conflict15, *Pbt_att_req.conflict15; + +struct bt_att_req.conflict15 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t.conflict destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_subscribe_params.conflict1 { + struct bt_att_req.conflict15 _req; + struct bt_addr_le_t _peer; + undefined field_0x1f; + u8_t (* notify)(struct bt_conn *, struct bt_gatt_subscribe_params *, void *, u16_t); + u16_t value_handle; + u16_t ccc_handle; + u16_t value; + undefined field_0x2a; + undefined field_0x2b; + atomic_t flags[1]; + sys_snode_t node; +}; + +typedef struct bt_gatt_attr.conflict bt_gatt_attr.conflict, *Pbt_gatt_attr.conflict; + +struct bt_gatt_attr.conflict { + struct bt_uuid * uuid; + ssize_t (* read)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t); + ssize_t (* write)(struct bt_conn *, struct bt_gatt_attr *, void *, u16_t, u16_t, u8_t); + void * user_data; + u16_t handle; + u8_t perm; + undefined field_0x13; +}; + +typedef struct _bt_gatt_ccc.conflict _bt_gatt_ccc.conflict, *P_bt_gatt_ccc.conflict; + +struct _bt_gatt_ccc.conflict { + struct bt_gatt_ccc_cfg cfg[2]; + u16_t value; + undefined field_0x16; + undefined field_0x17; + void (* cfg_changed)(struct bt_gatt_attr *, u16_t); + _Bool (* cfg_write)(struct bt_conn *, struct bt_gatt_attr *, u16_t); + _Bool (* cfg_match)(struct bt_conn *, struct bt_gatt_attr *); +}; + +typedef struct bt_gatt_indicate_params.conflict bt_gatt_indicate_params.conflict, *Pbt_gatt_indicate_params.conflict; + +typedef struct bt_att_req.conflict16 bt_att_req.conflict16, *Pbt_att_req.conflict16; + +struct bt_att_req.conflict16 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t.conflict destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_indicate_params.conflict { + struct bt_att_req.conflict16 _req; + struct bt_uuid * uuid; + struct bt_gatt_attr * attr; + void (* func)(struct bt_conn *, struct bt_gatt_attr *, u8_t); + void * data; + u16_t len; + undefined field_0x2a; + undefined field_0x2b; +}; + +typedef struct bt_gatt_exchange_params.conflict1 bt_gatt_exchange_params.conflict1, *Pbt_gatt_exchange_params.conflict1; + +typedef struct bt_att_req.conflict28 bt_att_req.conflict28, *Pbt_att_req.conflict28; + +struct bt_att_req.conflict28 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t.conflict destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_gatt_exchange_params.conflict1 { + struct bt_att_req.conflict28 _req; + void (* func)(struct bt_conn *, u8_t, struct bt_gatt_exchange_params *); +}; + +typedef _Bool bool_l; + +typedef uint64_t __le64; + +typedef struct work work, *Pwork; + +struct work { + void (* fn)(void *); + void * arg; + int dly; +}; + +typedef struct targ targ, *Ptarg; + +typedef struct AosStaticTask_t AosStaticTask_t, *PAosStaticTask_t; + +typedef struct xSTATIC_TCB xSTATIC_TCB, *PxSTATIC_TCB; + +typedef struct xSTATIC_TCB StaticTask_t; + +typedef struct xSTATIC_LIST_ITEM xSTATIC_LIST_ITEM, *PxSTATIC_LIST_ITEM; + +typedef struct xSTATIC_LIST_ITEM StaticListItem_t; + +struct xSTATIC_LIST_ITEM { + TickType_t xDummy2; + void * pvDummy3[4]; +}; + +struct xSTATIC_TCB { + void * pxDummy1; + StaticListItem_t xDummy3[2]; + UBaseType_t uxDummy5; + void * pxDummy6; + uint8_t ucDummy7[16]; + UBaseType_t uxDummy9; + UBaseType_t uxDummy10[2]; + UBaseType_t uxDummy12[2]; + uint32_t ulDummy18; + uint8_t ucDummy19; + uint8_t uxDummy20; + undefined field_0x5e; + undefined field_0x5f; +}; + +struct targ { + struct AosStaticTask_t * task; + void (* fn)(void *); + void * arg; +}; + +struct AosStaticTask_t { + StaticTask_t fTask; + uint32_t key_bitmap; + void * keys[4]; + void * stack; + char name[32]; + uint32_t magic; +}; + +typedef longlong s64_t; + +typedef __blkcnt_t blkcnt_t; + + +// WARNING! conflicting data type names: /DWARF/_types.h/__mode_t - /types.h/__mode_t + +typedef __mode_t mode_t; + + +// WARNING! conflicting data type names: /DWARF/_types.h/__ino_t - /types.h/__ino_t + +typedef __ino_t ino_t; + + +// WARNING! conflicting data type names: /DWARF/_types.h/__uid_t - /types.h/__uid_t + +typedef __uid_t uid_t; + +typedef short s16_t; + + +// WARNING! conflicting data type names: /DWARF/_types.h/__off_t - /types.h/__off_t + +typedef __off_t off_t; + + +// WARNING! conflicting data type names: /DWARF/_types.h/__nlink_t - /types.h/__nlink_t + +typedef __nlink_t nlink_t; + +typedef int s32_t; + + +// WARNING! conflicting data type names: /DWARF/_types.h/__gid_t - /types.h/__gid_t + +typedef __gid_t gid_t; + + +// WARNING! conflicting data type names: /DWARF/_types.h/__dev_t - /types.h/__dev_t + +typedef __dev_t dev_t; + +typedef __blksize_t blksize_t; + +typedef struct txl_list txl_list, *Ptxl_list; + +typedef struct tx_hd tx_hd, *Ptx_hd; + + +// WARNING! conflicting data type names: /DWARF/hal_desc.h/tx_hd/anon_union_for_field_3 - /DWARF/gatt.h/bt_gatt_discover_params/anon_union_for_field_3 + + +// WARNING! conflicting data type names: /DWARF/hal_desc.h/tx_hd/anon_union_for_field_4 - /DWARF/buf.h/net_buf/anon_union_for_field_4 + +typedef union anon_union_for_field_5 anon_union_for_field_5, *Panon_union_for_field_5; + +union anon_union_for_field_5 { + uint32_t dataendptr; + uint32_t sec_user3_ptr; +}; + +struct tx_hd { + uint32_t upatterntx; + uint32_t nextfrmexseq_ptr; + uint32_t nextmpdudesc_ptr; + union anon_union_for_field_3 field_3; + union anon_union_for_field_4 field_4; + union anon_union_for_field_5 field_5; + uint32_t frmlen; + uint32_t frmlifetime; + uint32_t phyctrlinfo; + uint32_t policyentryaddr; + uint32_t optlen[3]; + uint32_t macctrlinfo1; + uint32_t macctrlinfo2; + uint32_t statinfo; + uint32_t mediumtimeused; +}; + +struct txl_list { + struct tx_hd * last_frame_exch; + struct co_list transmitting; + uint16_t bridgedmacnt; + uint8_t chk_state; + undefined field_0xf; +}; + +typedef struct txl_cntrl_env_tag txl_cntrl_env_tag, *Ptxl_cntrl_env_tag; + +struct txl_cntrl_env_tag { + struct txl_list txlist[5]; + uint32_t pck_cnt; + uint16_t seqnbr; + _Bool reset; + undefined field_0x57; +}; + +typedef struct gatt_chrc gatt_chrc, *Pgatt_chrc; + +typedef union anon_union_for_field_2 anon_union_for_field_2, *Panon_union_for_field_2; + +union anon_union_for_field_2 { + u16_t uuid16; + u8_t uuid[16]; +}; + +struct gatt_chrc { + u8_t properties; + u16_t value_handle; + union anon_union_for_field_2 field_2; +}; + +typedef struct anon_struct.conflict108 anon_struct.conflict108, *Panon_struct.conflict108; + +struct anon_struct.conflict108 { + u16_t start; + u16_t end; +}; + +typedef struct gatt_incl gatt_incl, *Pgatt_incl; + +struct gatt_incl { + u16_t start_handle; + u16_t end_handle; + u16_t uuid16; +}; + +typedef struct sc_data sc_data, *Psc_data; + +struct sc_data { + u16_t start; + u16_t end; +}; + +typedef struct notify_data notify_data, *Pnotify_data; + + +// WARNING! conflicting data type names: /DWARF/gatt.c/notify_data/anon_union_for_field_2 - /DWARF/gatt.c/gatt_chrc/anon_union_for_field_2 + +struct notify_data { + int err; + u16_t type; + undefined field_0x6; + undefined field_0x7; + union anon_union_for_field_2 field_2; +}; + +typedef struct gatt_sc.conflict gatt_sc.conflict, *Pgatt_sc.conflict; + +typedef struct k_delayed_work.conflict4 k_delayed_work.conflict4, *Pk_delayed_work.conflict4; + +typedef struct k_timer.conflict9 k_timer.conflict9, *Pk_timer.conflict9; + +typedef struct k_timer.conflict9 k_timer_t.conflict7; + +typedef void (* k_timer_handler_t.conflict)(void *); + +struct k_timer.conflict9 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +struct k_delayed_work.conflict4 { + struct k_work work; + struct k_work_q * work_q; + k_timer_t.conflict7 timer; +}; + +struct gatt_sc.conflict { + struct bt_gatt_indicate_params.conflict4 params; + u16_t start; + u16_t end; + struct k_delayed_work.conflict4 work; + atomic_t flags[1]; +}; + +typedef struct gatt_sc_cfg gatt_sc_cfg, *Pgatt_sc_cfg; + +typedef struct anon_struct_for_data anon_struct_for_data, *Panon_struct_for_data; + +struct anon_struct_for_data { + u16_t start; + u16_t end; +}; + +struct gatt_sc_cfg { + u8_t id; + struct bt_addr_le_t peer; + struct anon_struct_for_data data; +}; + +typedef struct addr_with_id addr_with_id, *Paddr_with_id; + +struct addr_with_id { + struct bt_addr_le_t * addr; + u8_t id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct ccc_load ccc_load, *Pccc_load; + +typedef struct ccc_store ccc_store, *Pccc_store; + +struct ccc_load { + struct addr_with_id addr_with_id; + struct ccc_store * entry; + size_t count; +}; + +struct ccc_store { + u16_t handle; + u16_t value; +}; + +typedef struct gatt_sc gatt_sc, *Pgatt_sc; + +typedef struct k_delayed_work.conflict3 k_delayed_work.conflict3, *Pk_delayed_work.conflict3; + +typedef struct k_timer.conflict8 k_timer.conflict8, *Pk_timer.conflict8; + +typedef struct k_timer.conflict8 k_timer_t.conflict6; + +struct k_timer.conflict8 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +struct k_delayed_work.conflict3 { + struct k_work work; + struct k_work_q * work_q; + k_timer_t.conflict6 timer; +}; + +struct gatt_sc { + struct bt_gatt_indicate_params.conflict params; + u16_t start; + u16_t end; + struct k_delayed_work.conflict3 work; + atomic_t flags[1]; +}; + +typedef struct conn_data conn_data, *Pconn_data; + +struct conn_data { + struct bt_conn * conn; + enum bt_security_t sec; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef union anon_union anon_union, *Panon_union; + +union anon_union { + struct bt_uuid uuid; + struct bt_uuid_16 u16; + struct bt_uuid_128 u128; + undefined1 field3[18]; // Automatically generated padding to match DWARF declared size +}; + +typedef union anon_union_for_info anon_union_for_info, *Panon_union_for_info; + +typedef struct bt_att_info_16 bt_att_info_16, *Pbt_att_info_16; + +typedef struct bt_att_info_128 bt_att_info_128, *Pbt_att_info_128; + +struct bt_att_info_16 { + u16_t handle; + u16_t uuid; +}; + +union anon_union_for_info { + struct bt_att_info_16 * i16; + struct bt_att_info_128 * i128; +}; + +struct bt_att_info_128 { + u16_t handle; + u8_t uuid[16]; +}; + + +// WARNING! conflicting data type names: /DWARF/gatt.c/gatt_find_info_rsp/anon_union_for_u - /DWARF/timers.c/tmrTimerQueueMessage/anon_union_for_u + +typedef struct anon_struct_for_ppcp anon_struct_for_ppcp, *Panon_struct_for_ppcp; + +struct anon_struct_for_ppcp { + u16_t min_int; + u16_t max_int; + u16_t latency; + u16_t timeout; +}; + + +// WARNING! conflicting data type names: /DWARF/gatt.c/read_included_uuid_cb/anon_union_for_u - /DWARF/timers.c/tmrTimerQueueMessage/anon_union_for_u + +typedef struct ipc_emb_env_tag.conflict ipc_emb_env_tag.conflict, *Pipc_emb_env_tag.conflict; + +struct ipc_emb_env_tag.conflict { + struct co_list rx_queue; + struct co_list cfm_queue; + uint8_t ipc_rxdesc_idx; + uint8_t ipc_rxbuf_idx; + uint8_t ipc_radar_buf_idx; + uint8_t ipc_msge2a_buf_idx; + uint8_t ipc_dbg_buf_idx; + uint8_t ipc_msgacke2a_cnt; + undefined field_0x16; + undefined field_0x17; + uint32_t txdesc_idx; + struct txdesc_host * txdesc; +}; + +typedef struct ipc_emb_env_tag ipc_emb_env_tag, *Pipc_emb_env_tag; + +struct ipc_emb_env_tag { + struct co_list rx_queue; + struct co_list cfm_queue; + uint8_t ipc_rxdesc_idx; + uint8_t ipc_rxbuf_idx; + uint8_t ipc_radar_buf_idx; + uint8_t ipc_msge2a_buf_idx; + uint8_t ipc_dbg_buf_idx; + uint8_t ipc_msgacke2a_cnt; + undefined field_0x16; + undefined field_0x17; + uint32_t txdesc_idx; + struct txdesc_host * txdesc; +}; + +typedef struct ipc_emb_env_tag.conflict1 ipc_emb_env_tag.conflict1, *Pipc_emb_env_tag.conflict1; + +struct ipc_emb_env_tag.conflict1 { + struct co_list rx_queue; + struct co_list cfm_queue; + uint8_t ipc_rxdesc_idx; + uint8_t ipc_rxbuf_idx; + uint8_t ipc_radar_buf_idx; + uint8_t ipc_msge2a_buf_idx; + uint8_t ipc_dbg_buf_idx; + uint8_t ipc_msgacke2a_cnt; + undefined field_0x16; + undefined field_0x17; + uint32_t txdesc_idx; + struct txdesc_host * txdesc; +}; + +typedef struct ipc_emb_env_tag.conflict3 ipc_emb_env_tag.conflict3, *Pipc_emb_env_tag.conflict3; + +struct ipc_emb_env_tag.conflict3 { + struct co_list rx_queue; + struct co_list cfm_queue; + uint8_t ipc_rxdesc_idx; + uint8_t ipc_rxbuf_idx; + uint8_t ipc_radar_buf_idx; + uint8_t ipc_msge2a_buf_idx; + uint8_t ipc_dbg_buf_idx; + uint8_t ipc_msgacke2a_cnt; + undefined field_0x16; + undefined field_0x17; + uint32_t txdesc_idx; + struct txdesc_host * txdesc; +}; + +typedef struct ipc_emb_env_tag.conflict2 ipc_emb_env_tag.conflict2, *Pipc_emb_env_tag.conflict2; + +struct ipc_emb_env_tag.conflict2 { + struct co_list rx_queue; + struct co_list cfm_queue; + uint8_t ipc_rxdesc_idx; + uint8_t ipc_rxbuf_idx; + uint8_t ipc_radar_buf_idx; + uint8_t ipc_msge2a_buf_idx; + uint8_t ipc_dbg_buf_idx; + uint8_t ipc_msgacke2a_cnt; + undefined field_0x16; + undefined field_0x17; + uint32_t txdesc_idx; + struct txdesc_host * txdesc; +}; + +typedef struct ipc_emb_env_tag.conflict5 ipc_emb_env_tag.conflict5, *Pipc_emb_env_tag.conflict5; + +struct ipc_emb_env_tag.conflict5 { + struct co_list rx_queue; + struct co_list cfm_queue; + uint8_t ipc_rxdesc_idx; + uint8_t ipc_rxbuf_idx; + uint8_t ipc_radar_buf_idx; + uint8_t ipc_msge2a_buf_idx; + uint8_t ipc_dbg_buf_idx; + uint8_t ipc_msgacke2a_cnt; + undefined field_0x16; + undefined field_0x17; + uint32_t txdesc_idx; + struct txdesc_host * txdesc; +}; + +typedef struct ipc_emb_env_tag.conflict4 ipc_emb_env_tag.conflict4, *Pipc_emb_env_tag.conflict4; + +struct ipc_emb_env_tag.conflict4 { + struct co_list rx_queue; + struct co_list cfm_queue; + uint8_t ipc_rxdesc_idx; + uint8_t ipc_rxbuf_idx; + uint8_t ipc_radar_buf_idx; + uint8_t ipc_msge2a_buf_idx; + uint8_t ipc_dbg_buf_idx; + uint8_t ipc_msgacke2a_cnt; + undefined field_0x16; + undefined field_0x17; + uint32_t txdesc_idx; + struct txdesc_host * txdesc; +}; + +typedef struct romapi_freertos_map romapi_freertos_map, *Promapi_freertos_map; + +struct romapi_freertos_map { + void * vApplicationIdleHook; + void * interrupt_entry_ptr; + void * vApplicationGetIdleTaskMemory; + void * vApplicationStackOverflowHook; + void * vApplicationGetTimerTaskMemory; + void * rtos_sprintf; + void * vApplicationMallocFailedHook; + void * rtos_memcpy_ptr; + void * vAssertCalled; + void * rtos_strlen_ptr; + void * rtos_memset_ptr; + void * rtos_clz; + void * exception_entry_ptr; + void * rtos_strcpy_ptr; + void * xISRStackTop; +}; + +typedef union byte_array byte_array, *Pbyte_array; + +typedef uint uintptr_t; + +union byte_array { + uint8_t bytes[8]; + uintptr_t intx; + uint64_t int64; +}; + +typedef struct mac_hdr_qos mac_hdr_qos, *Pmac_hdr_qos; + +typedef struct mac_addr.conflict8 mac_addr.conflict8, *Pmac_addr.conflict8; + +typedef struct mac_addr.conflict9 mac_addr.conflict9, *Pmac_addr.conflict9; + +typedef struct mac_addr.conflict10 mac_addr.conflict10, *Pmac_addr.conflict10; + +struct mac_addr.conflict10 { + uint16_t array[3]; +}; + +struct mac_addr.conflict8 { + uint16_t array[3]; +}; + +struct mac_addr.conflict9 { + uint16_t array[3]; +}; + +struct mac_hdr_qos { + uint16_t fctl; + uint16_t durid; + struct mac_addr.conflict8 addr1; + struct mac_addr.conflict9 addr2; + struct mac_addr.conflict10 addr3; + uint16_t seq; + uint16_t qos; +}; + +typedef struct eth_hdr.conflict eth_hdr.conflict, *Peth_hdr.conflict; + +struct eth_hdr.conflict { + struct mac_addr.conflict da; + struct mac_addr.conflict sa; + uint16_t len; +}; + +typedef struct mac_hdr_long_qos mac_hdr_long_qos, *Pmac_hdr_long_qos; + +typedef struct mac_addr.conflict11 mac_addr.conflict11, *Pmac_addr.conflict11; + +typedef struct mac_addr.conflict12 mac_addr.conflict12, *Pmac_addr.conflict12; + +typedef struct mac_addr.conflict13 mac_addr.conflict13, *Pmac_addr.conflict13; + +typedef struct mac_addr.conflict14 mac_addr.conflict14, *Pmac_addr.conflict14; + +struct mac_addr.conflict11 { + uint16_t array[3]; +}; + +struct mac_addr.conflict13 { + uint16_t array[3]; +}; + +struct mac_addr.conflict14 { + uint16_t array[3]; +}; + +struct mac_addr.conflict12 { + uint16_t array[3]; +}; + +struct mac_hdr_long_qos { + uint16_t fctl; + uint16_t durid; + struct mac_addr.conflict11 addr1; + struct mac_addr.conflict12 addr2; + struct mac_addr.conflict13 addr3; + uint16_t seq; + struct mac_addr.conflict14 addr4; + uint16_t qos; +}; + +typedef struct mac_hdr mac_hdr, *Pmac_hdr; + +typedef struct mac_addr.conflict5 mac_addr.conflict5, *Pmac_addr.conflict5; + +typedef struct mac_addr.conflict6 mac_addr.conflict6, *Pmac_addr.conflict6; + +typedef struct mac_addr.conflict7 mac_addr.conflict7, *Pmac_addr.conflict7; + +struct mac_addr.conflict6 { + uint16_t array[3]; +}; + +struct mac_addr.conflict7 { + uint16_t array[3]; +}; + +struct mac_addr.conflict5 { + uint16_t array[3]; +}; + +struct mac_hdr { + uint16_t fctl; + uint16_t durid; + struct mac_addr.conflict5 addr1; + struct mac_addr.conflict6 addr2; + struct mac_addr.conflict7 addr3; + uint16_t seq; +}; + +typedef struct bcn_frame bcn_frame, *Pbcn_frame; + +struct bcn_frame { + struct mac_hdr h; + uint64_t tsf; + uint16_t bcnint; + uint16_t capa; + uint8_t[0] variable; +}; + +typedef struct mac_hdr_long mac_hdr_long, *Pmac_hdr_long; + +struct mac_hdr_long { + uint16_t fctl; + uint16_t durid; + struct mac_addr.conflict addr1; + struct mac_addr.conflict addr2; + struct mac_addr.conflict addr3; + uint16_t seq; + struct mac_addr.conflict addr4; +}; + +typedef struct preq_frame preq_frame, *Ppreq_frame; + +struct preq_frame { + struct mac_hdr h; + uint8_t[0] payload; +}; + +typedef struct mac_hdr_ctrl mac_hdr_ctrl, *Pmac_hdr_ctrl; + +typedef struct mac_addr.conflict3 mac_addr.conflict3, *Pmac_addr.conflict3; + +typedef struct mac_addr.conflict4 mac_addr.conflict4, *Pmac_addr.conflict4; + +struct mac_addr.conflict4 { + uint16_t array[3]; +}; + +struct mac_addr.conflict3 { + uint16_t array[3]; +}; + +struct mac_hdr_ctrl { + uint16_t fctl; + uint16_t durid; + struct mac_addr.conflict3 addr1; + struct mac_addr.conflict4 addr2; +}; + +typedef enum BL_IRQ_EXCEPTION_TYPE_T { + BL_IRQ_EXCEPTION_TYPE_ACCESS_ILLEGAL=2, + BL_IRQ_EXCEPTION_TYPE_ILLEGAL_INSTRUCTION=3, + BL_IRQ_EXCEPTION_TYPE_LOAD_MISALIGN=0, + BL_IRQ_EXCEPTION_TYPE_STORE_MISALIGN=1 +} BL_IRQ_EXCEPTION_TYPE_T; + +typedef struct dma_env_tag dma_env_tag, *Pdma_env_tag; + +struct dma_env_tag { + struct dma_desc * last_dma[4]; +}; + +typedef struct sm_connect_req.conflict sm_connect_req.conflict, *Psm_connect_req.conflict; + +struct sm_connect_req.conflict { + struct mac_ssid ssid; + struct mac_addr.conflict bssid; + struct scan_chan_tag chan; + undefined field_0x2e; + undefined field_0x2f; + uint32_t flags; + uint16_t ctrl_port_ethertype; + uint16_t ie_len; + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t auth_type; + uint8_t uapsd_queues; + uint8_t vif_idx; + undefined field_0x3e; + undefined field_0x3f; + uint32_t ie_buf[64]; + _Bool is_supplicant_enabled; + uint8_t phrase[64]; + uint8_t phrase_pmk[64]; + undefined field_0x1c1; + undefined field_0x1c2; + undefined field_0x1c3; +}; + +typedef struct sm_connect_req.conflict8 sm_connect_req.conflict8, *Psm_connect_req.conflict8; + +struct sm_connect_req.conflict8 { + struct mac_ssid ssid; + struct mac_addr.conflict171 bssid; + struct scan_chan_tag chan; + undefined field_0x2e; + undefined field_0x2f; + uint32_t flags; + uint16_t ctrl_port_ethertype; + uint16_t ie_len; + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t auth_type; + uint8_t uapsd_queues; + uint8_t vif_idx; + undefined field_0x3e; + undefined field_0x3f; + uint32_t ie_buf[64]; + _Bool is_supplicant_enabled; + uint8_t phrase[64]; + uint8_t phrase_pmk[64]; + undefined field_0x1c1; + undefined field_0x1c2; + undefined field_0x1c3; +}; + +typedef struct sm_connect_req.conflict5 sm_connect_req.conflict5, *Psm_connect_req.conflict5; + +struct sm_connect_req.conflict5 { + struct mac_ssid ssid; + struct mac_addr.conflict171 bssid; + struct scan_chan_tag chan; + undefined field_0x2e; + undefined field_0x2f; + uint32_t flags; + uint16_t ctrl_port_ethertype; + uint16_t ie_len; + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t auth_type; + uint8_t uapsd_queues; + uint8_t vif_idx; + undefined field_0x3e; + undefined field_0x3f; + uint32_t ie_buf[64]; + _Bool is_supplicant_enabled; + uint8_t phrase[64]; + uint8_t phrase_pmk[64]; + undefined field_0x1c1; + undefined field_0x1c2; + undefined field_0x1c3; +}; + +typedef struct sm_connect_req.conflict4 sm_connect_req.conflict4, *Psm_connect_req.conflict4; + +struct sm_connect_req.conflict4 { + struct mac_ssid ssid; + struct mac_addr.conflict171 bssid; + struct scan_chan_tag chan; + undefined field_0x2e; + undefined field_0x2f; + uint32_t flags; + uint16_t ctrl_port_ethertype; + uint16_t ie_len; + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t auth_type; + uint8_t uapsd_queues; + uint8_t vif_idx; + undefined field_0x3e; + undefined field_0x3f; + uint32_t ie_buf[64]; + _Bool is_supplicant_enabled; + uint8_t phrase[64]; + uint8_t phrase_pmk[64]; + undefined field_0x1c1; + undefined field_0x1c2; + undefined field_0x1c3; +}; + +typedef struct sm_connect_req.conflict7 sm_connect_req.conflict7, *Psm_connect_req.conflict7; + +struct sm_connect_req.conflict7 { + struct mac_ssid ssid; + struct mac_addr.conflict171 bssid; + struct scan_chan_tag chan; + undefined field_0x2e; + undefined field_0x2f; + uint32_t flags; + uint16_t ctrl_port_ethertype; + uint16_t ie_len; + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t auth_type; + uint8_t uapsd_queues; + uint8_t vif_idx; + undefined field_0x3e; + undefined field_0x3f; + uint32_t ie_buf[64]; + _Bool is_supplicant_enabled; + uint8_t phrase[64]; + uint8_t phrase_pmk[64]; + undefined field_0x1c1; + undefined field_0x1c2; + undefined field_0x1c3; +}; + +typedef struct sm_connect_req.conflict6 sm_connect_req.conflict6, *Psm_connect_req.conflict6; + +struct sm_connect_req.conflict6 { + struct mac_ssid ssid; + struct mac_addr.conflict171 bssid; + struct scan_chan_tag chan; + undefined field_0x2e; + undefined field_0x2f; + uint32_t flags; + uint16_t ctrl_port_ethertype; + uint16_t ie_len; + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t auth_type; + uint8_t uapsd_queues; + uint8_t vif_idx; + undefined field_0x3e; + undefined field_0x3f; + uint32_t ie_buf[64]; + _Bool is_supplicant_enabled; + uint8_t phrase[64]; + uint8_t phrase_pmk[64]; + undefined field_0x1c1; + undefined field_0x1c2; + undefined field_0x1c3; +}; + +typedef struct sm_connect_req.conflict1 sm_connect_req.conflict1, *Psm_connect_req.conflict1; + +typedef struct mac_addr.conflict57 mac_addr.conflict57, *Pmac_addr.conflict57; + +struct mac_addr.conflict57 { + uint16_t array[3]; +}; + +struct sm_connect_req.conflict1 { + struct mac_ssid ssid; + struct mac_addr.conflict57 bssid; + struct scan_chan_tag chan; + undefined field_0x2e; + undefined field_0x2f; + uint32_t flags; + uint16_t ctrl_port_ethertype; + uint16_t ie_len; + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t auth_type; + uint8_t uapsd_queues; + uint8_t vif_idx; + undefined field_0x3e; + undefined field_0x3f; + uint32_t ie_buf[64]; + _Bool is_supplicant_enabled; + uint8_t phrase[64]; + uint8_t phrase_pmk[64]; + undefined field_0x1c1; + undefined field_0x1c2; + undefined field_0x1c3; +}; + +typedef struct sm_connect_req.conflict3 sm_connect_req.conflict3, *Psm_connect_req.conflict3; + +typedef struct mac_addr.conflict98 mac_addr.conflict98, *Pmac_addr.conflict98; + +struct mac_addr.conflict98 { + uint16_t array[3]; +}; + +struct sm_connect_req.conflict3 { + struct mac_ssid ssid; + struct mac_addr.conflict98 bssid; + struct scan_chan_tag chan; + undefined field_0x2e; + undefined field_0x2f; + uint32_t flags; + uint16_t ctrl_port_ethertype; + uint16_t ie_len; + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t auth_type; + uint8_t uapsd_queues; + uint8_t vif_idx; + undefined field_0x3e; + undefined field_0x3f; + uint32_t ie_buf[64]; + _Bool is_supplicant_enabled; + uint8_t phrase[64]; + uint8_t phrase_pmk[64]; + undefined field_0x1c1; + undefined field_0x1c2; + undefined field_0x1c3; +}; + +typedef struct sm_connect_req.conflict2 sm_connect_req.conflict2, *Psm_connect_req.conflict2; + +typedef struct mac_addr.conflict58 mac_addr.conflict58, *Pmac_addr.conflict58; + +struct mac_addr.conflict58 { + uint16_t array[3]; +}; + +struct sm_connect_req.conflict2 { + struct mac_ssid ssid; + struct mac_addr.conflict58 bssid; + struct scan_chan_tag chan; + undefined field_0x2e; + undefined field_0x2f; + uint32_t flags; + uint16_t ctrl_port_ethertype; + uint16_t ie_len; + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t auth_type; + uint8_t uapsd_queues; + uint8_t vif_idx; + undefined field_0x3e; + undefined field_0x3f; + uint32_t ie_buf[64]; + _Bool is_supplicant_enabled; + uint8_t phrase[64]; + uint8_t phrase_pmk[64]; + undefined field_0x1c1; + undefined field_0x1c2; + undefined field_0x1c3; +}; + +typedef struct sm_connect_ind.conflict sm_connect_ind.conflict, *Psm_connect_ind.conflict; + +struct sm_connect_ind.conflict { + uint16_t status_code; + struct mac_addr.conflict bssid; + _Bool roamed; + uint8_t vif_idx; + uint8_t ap_idx; + uint8_t ch_idx; + _Bool qos; + uint8_t acm; + uint16_t assoc_req_ie_len; + uint16_t assoc_rsp_ie_len; + undefined field_0x12; + undefined field_0x13; + uint32_t assoc_ie_buf[200]; + uint16_t aid; + uint8_t band; + undefined field_0x337; + uint16_t center_freq; + uint8_t width; + undefined field_0x33b; + uint32_t center_freq1; + uint32_t center_freq2; + uint32_t ac_param[4]; +}; + +typedef enum sm_state_tag { + SM_ACTIVATING=7, + SM_ASSOCIATING=6, + SM_AUTHENTICATING=5, + SM_BSS_PARAM_SETTING=4, + SM_DISCONNECTING=8, + SM_IDLE=0, + SM_JOINING=2, + SM_SCANNING=1, + SM_STATE_MAX=9, + SM_STA_ADDING=3 +} sm_state_tag; + +typedef struct sm_connect_ind.conflict1 sm_connect_ind.conflict1, *Psm_connect_ind.conflict1; + +typedef struct mac_addr.conflict59 mac_addr.conflict59, *Pmac_addr.conflict59; + +struct mac_addr.conflict59 { + uint16_t array[3]; +}; + +struct sm_connect_ind.conflict1 { + uint16_t status_code; + struct mac_addr.conflict59 bssid; + _Bool roamed; + uint8_t vif_idx; + uint8_t ap_idx; + uint8_t ch_idx; + _Bool qos; + uint8_t acm; + uint16_t assoc_req_ie_len; + uint16_t assoc_rsp_ie_len; + undefined field_0x12; + undefined field_0x13; + uint32_t assoc_ie_buf[200]; + uint16_t aid; + uint8_t band; + undefined field_0x337; + uint16_t center_freq; + uint8_t width; + undefined field_0x33b; + uint32_t center_freq1; + uint32_t center_freq2; + uint32_t ac_param[4]; +}; + +typedef struct sm_connect_ind.conflict2 sm_connect_ind.conflict2, *Psm_connect_ind.conflict2; + +typedef struct mac_addr.conflict99 mac_addr.conflict99, *Pmac_addr.conflict99; + +struct mac_addr.conflict99 { + uint16_t array[3]; +}; + +struct sm_connect_ind.conflict2 { + uint16_t status_code; + struct mac_addr.conflict99 bssid; + _Bool roamed; + uint8_t vif_idx; + uint8_t ap_idx; + uint8_t ch_idx; + _Bool qos; + uint8_t acm; + uint16_t assoc_req_ie_len; + uint16_t assoc_rsp_ie_len; + undefined field_0x12; + undefined field_0x13; + uint32_t assoc_ie_buf[200]; + uint16_t aid; + uint8_t band; + undefined field_0x337; + uint16_t center_freq; + uint8_t width; + undefined field_0x33b; + uint32_t center_freq1; + uint32_t center_freq2; + uint32_t ac_param[4]; +}; + +typedef struct mm_csa_counter_ind mm_csa_counter_ind, *Pmm_csa_counter_ind; + +struct mm_csa_counter_ind { + uint8_t vif_index; + uint8_t csa_count; +}; + +typedef struct mm_set_edca_req mm_set_edca_req, *Pmm_set_edca_req; + +struct mm_set_edca_req { + uint32_t ac_param; + _Bool uapsd; + uint8_t hw_queue; + uint8_t inst_nbr; + undefined field_0x7; +}; + +typedef struct mm_remain_on_channel_req mm_remain_on_channel_req, *Pmm_remain_on_channel_req; + +struct mm_remain_on_channel_req { + uint8_t op_code; + uint8_t vif_index; + uint8_t band; + uint8_t type; + uint16_t prim20_freq; + uint16_t center1_freq; + uint16_t center2_freq; + undefined field_0xa; + undefined field_0xb; + uint32_t duration_ms; + int8_t tx_power; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct mm_force_idle_req mm_force_idle_req, *Pmm_force_idle_req; + +struct mm_force_idle_req { + void (* cb)(void); +}; + +typedef struct mm_set_bssid_req mm_set_bssid_req, *Pmm_set_bssid_req; + +struct mm_set_bssid_req { + struct mac_addr.conflict bssid; + uint8_t inst_nbr; +}; + +typedef struct mm_key_add_cfm mm_key_add_cfm, *Pmm_key_add_cfm; + +struct mm_key_add_cfm { + uint8_t status; + uint8_t hw_key_idx; +}; + +typedef struct mm_remain_on_channel_cfm mm_remain_on_channel_cfm, *Pmm_remain_on_channel_cfm; + +struct mm_remain_on_channel_cfm { + uint8_t op_code; + uint8_t status; + uint8_t chan_ctxt_index; +}; + +typedef struct mm_tim_update_req mm_tim_update_req, *Pmm_tim_update_req; + +struct mm_tim_update_req { + uint16_t aid; + uint8_t tx_avail; + uint8_t inst_nbr; +}; + +typedef struct mm_sta_del_req mm_sta_del_req, *Pmm_sta_del_req; + +struct mm_sta_del_req { + uint8_t sta_idx; +}; + +typedef struct mm_set_filter_req mm_set_filter_req, *Pmm_set_filter_req; + +struct mm_set_filter_req { + uint32_t filter; +}; + +typedef struct mm_key_add_req mm_key_add_req, *Pmm_key_add_req; + +typedef struct mac_sec_key mac_sec_key, *Pmac_sec_key; + +struct mac_sec_key { + uint8_t length; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + uint32_t array[8]; +}; + +struct mm_key_add_req { + uint8_t key_idx; + uint8_t sta_idx; + undefined field_0x2; + undefined field_0x3; + struct mac_sec_key key; + uint8_t cipher_suite; + uint8_t inst_nbr; + uint8_t spp; + _Bool pairwise; +}; + +typedef struct mm_sta_add_req mm_sta_add_req, *Pmm_sta_add_req; + +struct mm_sta_add_req { + uint32_t ampdu_size_max_vht; + uint32_t paid_gid; + uint16_t ampdu_size_max_ht; + struct mac_addr.conflict mac_addr; + uint8_t ampdu_spacing_min; + uint8_t inst_nbr; + _Bool tdls_sta; + int8_t rssi; + uint32_t tsflo; + uint32_t tsfhi; + uint8_t data_rate; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +typedef struct mm_set_power_cfm mm_set_power_cfm, *Pmm_set_power_cfm; + +struct mm_set_power_cfm { + uint8_t radio_idx; + int8_t power; +}; + +typedef struct mm_set_vif_state_req mm_set_vif_state_req, *Pmm_set_vif_state_req; + +struct mm_set_vif_state_req { + uint16_t aid; + _Bool active; + uint8_t inst_nbr; +}; + +typedef struct mm_set_mode_req mm_set_mode_req, *Pmm_set_mode_req; + +struct mm_set_mode_req { + uint8_t abgnmode; +}; + +typedef struct mm_chan_ctxt_update_req mm_chan_ctxt_update_req, *Pmm_chan_ctxt_update_req; + +struct mm_chan_ctxt_update_req { + uint8_t chan_index; + uint8_t band; + uint8_t type; + undefined field_0x3; + uint16_t prim20_freq; + uint16_t center1_freq; + uint16_t center2_freq; + int8_t tx_power; + undefined field_0xb; +}; + +typedef enum mm_remain_on_channel_op { + MM_ROC_OP_CANCEL=1, + MM_ROC_OP_MAX=2, + MM_ROC_OP_START=0 +} mm_remain_on_channel_op; + +typedef struct mm_cfg_rssi_req mm_cfg_rssi_req, *Pmm_cfg_rssi_req; + +struct mm_cfg_rssi_req { + uint8_t vif_index; + int8_t rssi_thold; + uint8_t rssi_hyst; +}; + +typedef struct mm_set_beacon_int_req mm_set_beacon_int_req, *Pmm_set_beacon_int_req; + +struct mm_set_beacon_int_req { + uint16_t beacon_int; + uint8_t inst_nbr; + undefined field_0x3; +}; + +typedef struct mm_traffic_req_ind mm_traffic_req_ind, *Pmm_traffic_req_ind; + +struct mm_traffic_req_ind { + uint8_t sta_idx; + uint8_t pkt_cnt; + _Bool uapsd; +}; + +typedef struct mm_set_ps_options_req mm_set_ps_options_req, *Pmm_set_ps_options_req; + +struct mm_set_ps_options_req { + uint8_t vif_index; + undefined field_0x1; + uint16_t listen_interval; + _Bool dont_listen_bc_mc; + undefined field_0x5; +}; + +typedef struct mm_set_power_req mm_set_power_req, *Pmm_set_power_req; + +struct mm_set_power_req { + uint8_t inst_nbr; + int8_t power; +}; + +typedef struct mm_connection_loss_ind mm_connection_loss_ind, *Pmm_connection_loss_ind; + +struct mm_connection_loss_ind { + uint8_t inst_nbr; +}; + +typedef struct mm_set_dtim_req mm_set_dtim_req, *Pmm_set_dtim_req; + +struct mm_set_dtim_req { + uint8_t dtim_period; +}; + +typedef struct mm_bcn_change_req mm_bcn_change_req, *Pmm_bcn_change_req; + +struct mm_bcn_change_req { + uint32_t bcn_ptr; + uint16_t bcn_len; + uint16_t tim_oft; + uint8_t tim_len; + uint8_t inst_nbr; + uint8_t csa_oft[2]; + uint8_t[0] bcn_buf; +}; + +typedef struct mm_key_del_req mm_key_del_req, *Pmm_key_del_req; + +struct mm_key_del_req { + uint8_t hw_key_idx; +}; + +typedef struct mm_ba_add_req mm_ba_add_req, *Pmm_ba_add_req; + +struct mm_ba_add_req { + uint8_t type; + uint8_t sta_idx; + uint8_t tid; + uint8_t bufsz; + uint16_t ssn; +}; + +typedef struct mm_chan_ctxt_add_req mm_chan_ctxt_add_req, *Pmm_chan_ctxt_add_req; + +struct mm_chan_ctxt_add_req { + uint8_t band; + uint8_t type; + uint16_t prim20_freq; + uint16_t center1_freq; + uint16_t center2_freq; + int8_t tx_power; + undefined field_0x9; +}; + +typedef struct mm_csa_finish_ind mm_csa_finish_ind, *Pmm_csa_finish_ind; + +struct mm_csa_finish_ind { + uint8_t vif_index; + uint8_t status; + uint8_t chan_idx; +}; + +typedef struct mm_csa_traffic_ind mm_csa_traffic_ind, *Pmm_csa_traffic_ind; + +struct mm_csa_traffic_ind { + uint8_t vif_index; + _Bool enable; +}; + +typedef struct mm_set_basic_rates_req mm_set_basic_rates_req, *Pmm_set_basic_rates_req; + +struct mm_set_basic_rates_req { + uint32_t rates; + uint8_t inst_nbr; + uint8_t band; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct mm_set_slottime_req mm_set_slottime_req, *Pmm_set_slottime_req; + +struct mm_set_slottime_req { + uint8_t slottime; +}; + +typedef struct mm_set_idle_req mm_set_idle_req, *Pmm_set_idle_req; + +struct mm_set_idle_req { + uint8_t hw_idle; +}; + +typedef struct mm_sta_add_cfm mm_sta_add_cfm, *Pmm_sta_add_cfm; + +struct mm_sta_add_cfm { + uint8_t status; + uint8_t sta_idx; + uint8_t hw_sta_idx; +}; + +typedef struct mm_ba_add_cfm mm_ba_add_cfm, *Pmm_ba_add_cfm; + +struct mm_ba_add_cfm { + uint8_t sta_idx; + uint8_t tid; + uint8_t status; +}; + +typedef enum mm_msg_tag.conflict { + MM_ADD_IF_CFM=7, + MM_ADD_IF_REQ=6, + MM_BA_ADD_CFM=41, + MM_BA_ADD_REQ=40, + MM_BA_DEL_CFM=43, + MM_BA_DEL_REQ=42, + MM_BCN_CHANGE_CFM=64, + MM_BCN_CHANGE_REQ=63, + MM_BFMER_ENABLE_REQ=80, + MM_CFG_RSSI_REQ=86, + MM_CHANNEL_PRE_SWITCH_IND=69, + MM_CHANNEL_SURVEY_IND=79, + MM_CHANNEL_SWITCH_IND=68, + MM_CHAN_CTXT_ADD_CFM=52, + MM_CHAN_CTXT_ADD_REQ=51, + MM_CHAN_CTXT_DEL_CFM=54, + MM_CHAN_CTXT_DEL_REQ=53, + MM_CHAN_CTXT_LINK_CFM=56, + MM_CHAN_CTXT_LINK_REQ=55, + MM_CHAN_CTXT_SCHED_CFM=62, + MM_CHAN_CTXT_SCHED_REQ=61, + MM_CHAN_CTXT_UNLINK_CFM=58, + MM_CHAN_CTXT_UNLINK_REQ=57, + MM_CHAN_CTXT_UPDATE_CFM=60, + MM_CHAN_CTXT_UPDATE_REQ=59, + MM_CONNECTION_LOSS_IND=67, + MM_CSA_COUNTER_IND=78, + MM_CSA_FINISH_IND=88, + MM_CSA_TRAFFIC_IND=89, + MM_DENOISE_REQ=48, + MM_FORCE_IDLE_REQ=96, + MM_KEY_ADD_CFM=37, + MM_KEY_ADD_REQ=36, + MM_KEY_DEL_CFM=39, + MM_KEY_DEL_REQ=38, + MM_MAX=99, + MM_MONITOR_CFM=93, + MM_MONITOR_CHANNEL_CFM=95, + MM_MONITOR_CHANNEL_REQ=94, + MM_MONITOR_REQ=92, + MM_MU_GROUP_UPDATE_CFM=91, + MM_MU_GROUP_UPDATE_REQ=90, + MM_P2P_NOA_UPD_IND=85, + MM_P2P_VIF_PS_CHANGE_IND=77, + MM_PRIMARY_TBTT_IND=44, + MM_PS_CHANGE_IND=73, + MM_REMAIN_ON_CHANNEL_CFM=71, + MM_REMAIN_ON_CHANNEL_EXP_IND=72, + MM_REMAIN_ON_CHANNEL_REQ=70, + MM_REMOVE_IF_CFM=9, + MM_REMOVE_IF_REQ=8, + MM_RESET_CFM=1, + MM_RESET_REQ=0, + MM_RSSI_STATUS_IND=87, + MM_SCAN_CHANNEL_END_IND=98, + MM_SCAN_CHANNEL_START_IND=97, + MM_SECONDARY_TBTT_IND=45, + MM_SET_BASIC_RATES_CFM=23, + MM_SET_BASIC_RATES_REQ=22, + MM_SET_BEACON_INT_CFM=21, + MM_SET_BEACON_INT_REQ=20, + MM_SET_BSSID_CFM=25, + MM_SET_BSSID_REQ=24, + MM_SET_CHANNEL_CFM=17, + MM_SET_CHANNEL_REQ=16, + MM_SET_DTIM_CFM=19, + MM_SET_DTIM_REQ=18, + MM_SET_EDCA_CFM=27, + MM_SET_EDCA_REQ=26, + MM_SET_FILTER_CFM=15, + MM_SET_FILTER_REQ=14, + MM_SET_IDLE_CFM=35, + MM_SET_IDLE_REQ=34, + MM_SET_MODE_CFM=29, + MM_SET_MODE_REQ=28, + MM_SET_P2P_NOA_CFM=83, + MM_SET_P2P_NOA_REQ=81, + MM_SET_P2P_OPPPS_CFM=84, + MM_SET_P2P_OPPPS_REQ=82, + MM_SET_POWER_CFM=47, + MM_SET_POWER_REQ=46, + MM_SET_PS_MODE_CFM=50, + MM_SET_PS_MODE_REQ=49, + MM_SET_PS_OPTIONS_CFM=76, + MM_SET_PS_OPTIONS_REQ=75, + MM_SET_SLOTTIME_CFM=33, + MM_SET_SLOTTIME_REQ=32, + MM_SET_VIF_STATE_CFM=31, + MM_SET_VIF_STATE_REQ=30, + MM_START_CFM=3, + MM_START_REQ=2, + MM_STA_ADD_CFM=11, + MM_STA_ADD_REQ=10, + MM_STA_DEL_CFM=13, + MM_STA_DEL_REQ=12, + MM_TIM_UPDATE_CFM=66, + MM_TIM_UPDATE_REQ=65, + MM_TRAFFIC_REQ_IND=74, + MM_VERSION_CFM=5, + MM_VERSION_REQ=4 +} mm_msg_tag.conflict; + +typedef struct mm_ps_change_ind mm_ps_change_ind, *Pmm_ps_change_ind; + +struct mm_ps_change_ind { + uint8_t sta_idx; + uint8_t ps_state; +}; + +typedef struct mm_add_if_req.conflict mm_add_if_req.conflict, *Pmm_add_if_req.conflict; + +struct mm_add_if_req.conflict { + uint8_t type; + struct mac_addr.conflict addr; + _Bool p2p; +}; + +typedef enum mm_state_tag { + MM_ACTIVE=1, + MM_GOING_TO_IDLE=2, + MM_HOST_BYPASSED=3, + MM_IDLE=0, + MM_STATE_MAX=4 +} mm_state_tag; + +typedef struct xLIST List_t; + +typedef struct list_head list_head, *Plist_head; + +struct list_head { + struct list_head * next; + struct list_head * prev; +}; + +typedef struct dlist_s dlist_s, *Pdlist_s; + +typedef struct dlist_s dlist_t; + +struct dlist_s { + struct dlist_s * prev; + struct dlist_s * next; +}; + +typedef __gnuc_va_list va_list; + +typedef struct hal_dma_env_tag hal_dma_env_tag, *Phal_dma_env_tag; + +struct hal_dma_env_tag { + struct co_list prog[2]; + struct co_list free_gp_dma_descs; + uint16_t lli_cnt[2]; +}; + +typedef struct dns_hdr dns_hdr, *Pdns_hdr; + +struct dns_hdr { + u16_t id; + u8_t flags1; + u8_t flags2; + u16_t numquestions; + u16_t numanswers; + u16_t numauthrr; + u16_t numextrarr; +}; + +typedef enum lwip_ieee_eth_type { + ETHTYPE_ARP=2054, + ETHTYPE_ETHERCAT=-30556, + ETHTYPE_IP=2048, + ETHTYPE_IPV6=-31011, + ETHTYPE_JUMBO=-30608, + ETHTYPE_LLDP=-30516, + ETHTYPE_MRP=-30493, + ETHTYPE_PPPOE=-30620, + ETHTYPE_PPPOEDISC=-30621, + ETHTYPE_PROFINET=-30574, + ETHTYPE_PTP=-30473, + ETHTYPE_QINQ=-28416, + ETHTYPE_RARP=-32715, + ETHTYPE_SERCOS=-30515, + ETHTYPE_VLAN=-32512, + ETHTYPE_WOL=2114 +} lwip_ieee_eth_type; + +typedef struct dns_table_entry.conflict dns_table_entry.conflict, *Pdns_table_entry.conflict; + +struct dns_table_entry.conflict { + u32_t ttl; + ip_addr_t ipaddr; + u16_t txid; + u8_t state; + u8_t server_idx; + u8_t tmr; + u8_t retries; + u8_t seqno; + char name[256]; + undefined field_0x10f; +}; + +typedef struct dns_req_entry dns_req_entry, *Pdns_req_entry; + +struct dns_req_entry { + void (* found)(char *, ip_addr_t *, void *); + void * arg; +}; + +typedef struct dns_query dns_query, *Pdns_query; + +struct dns_query { + u16_t type; + u16_t cls; +}; + +typedef struct dns_answer dns_answer, *Pdns_answer; + +struct dns_answer { + u16_t type; + u16_t cls; + u32_t ttl; + u16_t len; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct bt_hci_cp_vs_set_tx_pwr bt_hci_cp_vs_set_tx_pwr, *Pbt_hci_cp_vs_set_tx_pwr; + +struct bt_hci_cp_vs_set_tx_pwr { + int8_t power; +}; + +typedef struct memp memp, *Pmemp; + +struct memp { + struct memp * next; +}; + +typedef struct memp_desc memp_desc, *Pmemp_desc; + +struct memp_desc { + struct stats_mem * stats; + u16_t size; + u16_t num; + u8_t * base; + struct memp * * tab; +}; + +typedef struct __sFILE __sFILE, *P__sFILE; + +typedef struct _reent _reent, *P_reent; + +typedef long _fpos_t; + +typedef struct __sFILE __FILE; + +typedef struct __sbuf __sbuf, *P__sbuf; + +typedef struct __locale_t __locale_t, *P__locale_t; + +typedef struct _Bigint _Bigint, *P_Bigint; + +typedef union anon_union_for__new anon_union_for__new, *Panon_union_for__new; + +typedef struct _atexit _atexit, *P_atexit; + +typedef struct _glue _glue, *P_glue; + +typedef long _off_t; + +typedef int _LOCK_RECURSIVE_T; + +typedef _LOCK_RECURSIVE_T _flock_t; + +typedef struct _mbstate_t _mbstate_t, *P_mbstate_t; + +typedef ulong __ULong; + +typedef struct anon_struct anon_struct, *Panon_struct; + +typedef struct anon_struct.conflict anon_struct.conflict, *Panon_struct.conflict; + +typedef struct _on_exit_args _on_exit_args, *P_on_exit_args; + +typedef union anon_union_for___value anon_union_for___value, *Panon_union_for___value; + +typedef struct __tm __tm, *P__tm; + +typedef struct _rand48 _rand48, *P_rand48; + +typedef uint wint_t; + +struct __tm { + int __tm_sec; + int __tm_min; + int __tm_hour; + int __tm_mday; + int __tm_mon; + int __tm_year; + int __tm_wday; + int __tm_yday; + int __tm_isdst; +}; + +struct _rand48 { + ushort _seed[3]; + ushort _mult[3]; + ushort _add; +}; + +union anon_union_for___value { + wint_t __wch; + uchar __wchb[4]; +}; + +struct _mbstate_t { + int __count; + union anon_union_for___value __value; +}; + +struct anon_struct { + uint _unused_rand; + char * _strtok_last; + char _asctime_buf[26]; + undefined field_0x22; + undefined field_0x23; + struct __tm _localtime_buf; + int _gamma_signgam; + undefined field_0x4c; + undefined field_0x4d; + undefined field_0x4e; + undefined field_0x4f; + ulonglong _rand_next; + struct _rand48 _r48; + undefined field_0x66; + undefined field_0x67; + struct _mbstate_t _mblen_state; + struct _mbstate_t _mbtowc_state; + struct _mbstate_t _wctomb_state; + char _l64a_buf[8]; + char _signal_buf[24]; + int _getdate_err; + struct _mbstate_t _mbrlen_state; + struct _mbstate_t _mbrtowc_state; + struct _mbstate_t _mbsrtowcs_state; + struct _mbstate_t _wcrtomb_state; + struct _mbstate_t _wcsrtombs_state; + int _h_errno; +}; + +struct anon_struct.conflict { + uchar * _nextf[30]; + uint _nmalloc[30]; +}; + +union anon_union_for__new { + struct anon_struct _reent; + struct anon_struct.conflict _unused; +}; + +struct _Bigint { + struct _Bigint * _next; + int _k; + int _maxwds; + int _sign; + int _wds; + __ULong _x[1]; +}; + +struct _glue { + struct _glue * _next; + int _niobs; + __FILE * _iobs; +}; + +struct __sbuf { + uchar * _base; + int _size; +}; + +struct __sFILE { + uchar * _p; + int _r; + int _w; + short _flags; + short _file; + struct __sbuf _bf; + int _lbfsize; + void * _cookie; + _ssize_t (* _read)(struct _reent *, void *, char *, int); + _ssize_t (* _write)(struct _reent *, void *, char *, int); + _fpos_t (* _seek)(struct _reent *, void *, _fpos_t, int); + int (* _close)(struct _reent *, void *); + struct __sbuf _ub; + uchar * _up; + int _ur; + uchar _ubuf[3]; + uchar _nbuf[1]; + struct __sbuf _lb; + int _blksize; + _off_t _offset; + struct _reent * _data; + _flock_t _lock; + struct _mbstate_t _mbstate; + int _flags2; +}; + +struct _on_exit_args { + void * _fnargs[32]; + void * _dso_handle[32]; + __ULong _fntypes; + __ULong _is_cxa; +}; + +struct _atexit { + struct _atexit * _next; + int _ind; + void (* _fns[32])(void); + struct _on_exit_args _on_exit_args; +}; + +struct _reent { + int _errno; + __FILE * _stdin; + __FILE * _stdout; + __FILE * _stderr; + int _inc; + char _emergency[25]; + undefined field_0x2d; + undefined field_0x2e; + undefined field_0x2f; + int _unspecified_locale_info; + struct __locale_t * _locale; + int __sdidinit; + void (* __cleanup)(struct _reent *); + struct _Bigint * _result; + int _result_k; + struct _Bigint * _p5s; + struct _Bigint * * _freelist; + int _cvtlen; + char * _cvtbuf; + union anon_union_for__new _new; + struct _atexit * _atexit; + struct _atexit _atexit0; + void (** _sig_func)(int); + struct _glue __sglue; + __FILE __sf[3]; + undefined field_0x424; + undefined field_0x425; + undefined field_0x426; + undefined field_0x427; +}; + +struct __locale_t { +}; + +typedef union anon_union.conflict anon_union.conflict, *Panon_union.conflict; + +union anon_union.conflict { + struct anon_struct _reent; + struct anon_struct.conflict _unused; +}; + +typedef struct _atexit.conflict _atexit.conflict, *P_atexit.conflict; + +struct _atexit.conflict { + struct _atexit * _next; + int _ind; + void (* _fns[32])(void); + struct _on_exit_args _on_exit_args; +}; + +typedef struct _reent.conflict _reent.conflict, *P_reent.conflict; + +struct _reent.conflict { + int _errno; + __FILE * _stdin; + __FILE * _stdout; + __FILE * _stderr; + int _inc; + char _emergency[25]; + undefined field_0x2d; + undefined field_0x2e; + undefined field_0x2f; + int _unspecified_locale_info; + struct __locale_t * _locale; + int __sdidinit; + void (* __cleanup)(struct _reent *); + struct _Bigint * _result; + int _result_k; + struct _Bigint * _p5s; + struct _Bigint * * _freelist; + int _cvtlen; + char * _cvtbuf; + union anon_union_for__new _new; + struct _atexit * _atexit; + struct _atexit.conflict _atexit0; + void (** _sig_func)(int); + struct _glue __sglue; + __FILE __sf[3]; + undefined field_0x424; + undefined field_0x425; + undefined field_0x426; + undefined field_0x427; +}; + +typedef enum hal_uart_flow_control_t { + FLOW_CONTROL_CTS=1, + FLOW_CONTROL_CTS_RTS=3, + FLOW_CONTROL_DISABLED=0, + FLOW_CONTROL_RTS=2 +} hal_uart_flow_control_t; + +typedef enum hal_uart_mode_t { + MODE_RX=1, + MODE_TX=0, + MODE_TX_RX=2 +} hal_uart_mode_t; + +typedef enum hal_uart_stop_bits_t { + STOP_BITS_1=0, + STOP_BITS_2=1 +} hal_uart_stop_bits_t; + +typedef struct uart_dev_t uart_dev_t, *Puart_dev_t; + +typedef struct uart_config_t uart_config_t, *Puart_config_t; + +typedef enum hal_uart_data_width_t { + DATA_WIDTH_5BIT=0, + DATA_WIDTH_6BIT=1, + DATA_WIDTH_7BIT=2, + DATA_WIDTH_8BIT=3, + DATA_WIDTH_9BIT=4 +} hal_uart_data_width_t; + +typedef enum hal_uart_parity_t { + EVEN_PARITY=2, + NO_PARITY=0, + ODD_PARITY=1 +} hal_uart_parity_t; + +struct uart_config_t { + uint32_t baud_rate; + enum hal_uart_data_width_t data_width; + enum hal_uart_parity_t parity; + enum hal_uart_stop_bits_t stop_bits; + enum hal_uart_flow_control_t flow_control; + enum hal_uart_mode_t mode; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +struct uart_dev_t { + uint8_t port; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + struct uart_config_t config; + void * rx_ringbuf_handle; + void * tx_ringbuf_handle; + uint32_t rx_buf_size; + uint32_t tx_buf_size; + void * mutex; + void * poll_cb; + void * fd; + void * poll_data; + void * taskhdl; + uint8_t read_block_flag; + undefined field_0x35; + undefined field_0x36; + undefined field_0x37; + void * priv; +}; + +typedef enum hal_uart_int_t { + UART_RX_INT=1, + UART_TX_INT=0 +} hal_uart_int_t; + +typedef struct etharp_hdr etharp_hdr, *Petharp_hdr; + +typedef struct eth_addr eth_addr, *Peth_addr; + +typedef struct ip4_addr_wordaligned ip4_addr_wordaligned, *Pip4_addr_wordaligned; + +struct eth_addr { + u8_t addr[6]; +}; + +struct ip4_addr_wordaligned { + u16_t addrw[2]; +}; + +struct etharp_hdr { + u16_t hwtype; + u16_t proto; + u8_t hwlen; + u8_t protolen; + u16_t opcode; + struct eth_addr shwaddr; + struct ip4_addr_wordaligned sipaddr; + struct eth_addr dhwaddr; + struct ip4_addr_wordaligned dipaddr; +}; + +typedef enum etharp_opcode { + ARP_REPLY=2, + ARP_REQUEST=1 +} etharp_opcode; + +typedef struct bl_dma_item bl_dma_item, *Pbl_dma_item; + +typedef struct utils_list_hdr utils_list_hdr, *Putils_list_hdr; + +struct utils_list_hdr { + struct utils_list_hdr * next; +}; + +struct bl_dma_item { + struct utils_list_hdr item; + void (* cb)(void *); + void * arg; + uint32_t src; + uint32_t dst; + uint32_t next; + uint32_t ctrl; +}; + +typedef struct dma_ctx dma_ctx, *Pdma_ctx; + +typedef struct utils_dlist_s utils_dlist_s, *Putils_dlist_s; + +typedef struct utils_dlist_s utils_dlist_t; + +struct utils_dlist_s { + struct utils_dlist_s * prev; + struct utils_dlist_s * next; +}; + +struct dma_ctx { + utils_dlist_t * pstqueue; +}; + +typedef struct dma_node dma_node, *Pdma_node; + +struct dma_node { + utils_dlist_t dlist_item; + int channel; + void * tc_handler; + void * interr_handler; + void * ctx; +}; + +typedef struct aos_dir_t aos_dir_t, *Paos_dir_t; + +struct aos_dir_t { + int dd_vfs_fd; + int dd_rsv; +}; + +typedef struct aos_dirent_t aos_dirent_t, *Paos_dirent_t; + +struct aos_dirent_t { // Missing member d_name : char[1] at offset 0x5 [Unsupported interior flex array: char[1]] + int d_ino; + uint8_t d_type; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct statfs statfs, *Pstatfs; + +struct statfs { + long f_type; + long f_bsize; + long f_blocks; + long f_bfree; + long f_bavail; + long f_files; + long f_ffree; + long f_fsid; + long f_namelen; +}; + +typedef struct etharp_entry etharp_entry, *Petharp_entry; + +typedef struct pbuf pbuf, *Ppbuf; + +typedef struct netif netif, *Pnetif; + +typedef s8_t err_t; + +typedef enum netif_mac_filter_action { + NETIF_ADD_MAC_FILTER=1, + NETIF_DEL_MAC_FILTER=0 +} netif_mac_filter_action; + +struct etharp_entry { + struct pbuf * q; + ip4_addr_t ipaddr; + struct netif * netif; + struct eth_addr ethaddr; + u16_t ctime; + u8_t state; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct netif { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + void (* status_callback)(struct netif *); + void (* link_callback)(struct netif *); + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +struct pbuf { + struct pbuf * next; + void * payload; + u16_t tot_len; + u16_t len; + u8_t type_internal; + u8_t flags; + u8_t ref; + u8_t if_idx; +}; + +typedef enum etharp_state { + ETHARP_STATE_EMPTY=0, + ETHARP_STATE_PENDING=1, + ETHARP_STATE_STABLE=2, + ETHARP_STATE_STABLE_REREQUESTING_1=3, + ETHARP_STATE_STABLE_REREQUESTING_2=4 +} etharp_state; + +typedef ushort UHWtype; + +typedef struct bl_custom_pbuf bl_custom_pbuf, *Pbl_custom_pbuf; + +typedef struct bl_custom_pbuf bl_custom_pbuf_t; + +typedef struct pbuf_custom pbuf_custom, *Ppbuf_custom; + +struct pbuf_custom { + struct pbuf pbuf; + void (* custom_free_function)(struct pbuf *); +}; + +struct bl_custom_pbuf { + struct pbuf_custom p; + void * swdesc; +}; + +typedef struct wifi_pkt wifi_pkt, *Pwifi_pkt; + +struct wifi_pkt { + uint32_t pkt[4]; + void * pbuf[4]; + uint16_t len[4]; +}; + +typedef struct la_mem_format la_mem_format, *Pla_mem_format; + +struct la_mem_format { + uint32_t word[4]; +}; + +typedef struct QueueDefinition QueueDefinition, *PQueueDefinition; + +typedef struct QueueDefinition * QueueHandle_t; + + +// WARNING! conflicting data type names: /DWARF/queue.c/QueueDefinition/anon_union_for_u - /DWARF/timers.c/tmrTimerQueueMessage/anon_union_for_u + +struct QueueDefinition { + int8_t * pcHead; + int8_t * pcWriteTo; + union anon_union_for_u u; + List_t xTasksWaitingToSend; + List_t xTasksWaitingToReceive; + UBaseType_t uxMessagesWaiting; + UBaseType_t uxLength; + UBaseType_t uxItemSize; + int8_t cRxLock; + int8_t cTxLock; + uint8_t ucStaticallyAllocated; + undefined field_0x47; + UBaseType_t uxQueueNumber; + uint8_t ucQueueType; + undefined field_0x4d; + undefined field_0x4e; + undefined field_0x4f; +}; + +typedef enum bl_dev_flag { + RWNX_DEV_RESTARTING=0, + RWNX_DEV_STACK_RESTARTING=1, + RWNX_DEV_STARTED=2 +} bl_dev_flag; + +typedef ulonglong UDItype; + +typedef uchar UQItype; + +typedef int shift_count_type; + +typedef uint USItype; + +typedef struct DWstruct DWstruct, *PDWstruct; + +typedef int SItype; + +struct DWstruct { + SItype low; + SItype high; +}; + +typedef longlong DItype; + +typedef union DWunion DWunion, *PDWunion; + +union DWunion { + struct DWstruct s; + DItype ll; +}; + +typedef struct QueueDefinition xQUEUE; + +typedef struct QUEUE_REGISTRY_ITEM QUEUE_REGISTRY_ITEM, *PQUEUE_REGISTRY_ITEM; + +typedef struct QUEUE_REGISTRY_ITEM xQueueRegistryItem; + +typedef xQueueRegistryItem QueueRegistryItem_t; + +struct QUEUE_REGISTRY_ITEM { + char * pcQueueName; + QueueHandle_t xHandle; +}; + +typedef struct QueuePointers QueuePointers, *PQueuePointers; + +typedef struct QueuePointers QueuePointers_t; + +struct QueuePointers { + int8_t * pcTail; + int8_t * pcReadFrom; +}; + +typedef struct SemaphoreData SemaphoreData, *PSemaphoreData; + +typedef struct SemaphoreData SemaphoreData_t; + +typedef struct tskTaskControlBlock tskTaskControlBlock, *PtskTaskControlBlock; + +typedef struct tskTaskControlBlock * TaskHandle_t; + +typedef uint32_t StackType_t; + +struct SemaphoreData { + TaskHandle_t xMutexHolder; + UBaseType_t uxRecursiveCallCount; +}; + +struct tskTaskControlBlock { + StackType_t * pxTopOfStack; + ListItem_t xStateListItem; + ListItem_t xEventListItem; + UBaseType_t uxPriority; + StackType_t * pxStack; + char pcTaskName[16]; + UBaseType_t uxCriticalNesting; + UBaseType_t uxTCBNumber; + UBaseType_t uxTaskNumber; + UBaseType_t uxBasePriority; + UBaseType_t uxMutexesHeld; + uint32_t ulNotifiedValue; + uint8_t ucNotifyState; + uint8_t ucStaticallyAllocated; + undefined field_0x5e; + undefined field_0x5f; +}; + +typedef xQUEUE Queue_t; + +typedef enum BL_AHB_Slave1_Type { + BL_AHB_SLAVE1_CCI=8, + BL_AHB_SLAVE1_CKS=23, + BL_AHB_SLAVE1_DBG=3, + BL_AHB_SLAVE1_DMA=12, + BL_AHB_SLAVE1_EFUSE=7, + BL_AHB_SLAVE1_GLB=0, + BL_AHB_SLAVE1_GPIP=2, + BL_AHB_SLAVE1_I2C=19, + BL_AHB_SLAVE1_IRR=22, + BL_AHB_SLAVE1_L1C=9, + BL_AHB_SLAVE1_MAX=24, + BL_AHB_SLAVE1_PDSHBN=14, + BL_AHB_SLAVE1_PWM=20, + BL_AHB_SLAVE1_RF=1, + BL_AHB_SLAVE1_SDU=13, + BL_AHB_SLAVE1_SEC=4, + BL_AHB_SLAVE1_SFC=11, + BL_AHB_SLAVE1_SPI=18, + BL_AHB_SLAVE1_TMR=21, + BL_AHB_SLAVE1_TZ1=5, + BL_AHB_SLAVE1_TZ2=6, + BL_AHB_SLAVE1_UART0=16, + BL_AHB_SLAVE1_UART1=17, + BL_AHB_SLAVE1_WRAM=15 +} BL_AHB_Slave1_Type; + +typedef struct bt_att_req.conflict24 bt_att_req.conflict24, *Pbt_att_req.conflict24; + +struct bt_att_req.conflict24 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t.conflict destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_att_req.conflict26 bt_att_req.conflict26, *Pbt_att_req.conflict26; + +struct bt_att_req.conflict26 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t.conflict destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_att_req.conflict9 bt_att_req.conflict9, *Pbt_att_req.conflict9; + +struct bt_att_req.conflict9 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t.conflict destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_att_req.conflict23 bt_att_req.conflict23, *Pbt_att_req.conflict23; + +struct bt_att_req.conflict23 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t.conflict destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_att_req.conflict25 bt_att_req.conflict25, *Pbt_att_req.conflict25; + +struct bt_att_req.conflict25 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t.conflict destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_att_req.conflict20 bt_att_req.conflict20, *Pbt_att_req.conflict20; + +struct bt_att_req.conflict20 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t.conflict destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_att_req.conflict22 bt_att_req.conflict22, *Pbt_att_req.conflict22; + +struct bt_att_req.conflict22 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t.conflict destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_att_req.conflict27 bt_att_req.conflict27, *Pbt_att_req.conflict27; + +struct bt_att_req.conflict27 { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + bt_att_destroy_t.conflict destroy; + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_att_req bt_att_req, *Pbt_att_req; + +struct bt_att_req { + sys_snode_t node; + void (* func)(struct bt_conn *, u8_t, void *, u16_t, void *); + void (* destroy)(void *); + struct net_buf_simple_state state; + struct net_buf * buf; + _Bool retrying; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct _httpc_state _httpc_state, *P_httpc_state; + +typedef struct _httpc_state httpc_state_t; + +struct _httpc_state { +}; + +typedef struct write_data write_data, *Pwrite_data; + +struct write_data { + struct bt_conn * conn; + struct net_buf * buf; + u8_t req; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + void * value; + u16_t len; + u16_t offset; + u8_t err; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_att bt_att, *Pbt_att; + +typedef struct bt_l2cap_le_chan.conflict3 bt_l2cap_le_chan.conflict3, *Pbt_l2cap_le_chan.conflict3; + +typedef struct k_delayed_work.conflict14 k_delayed_work.conflict14, *Pk_delayed_work.conflict14; + +typedef struct bt_l2cap_chan.conflict4 bt_l2cap_chan.conflict4, *Pbt_l2cap_chan.conflict4; + +typedef struct bt_l2cap_chan bt_l2cap_chan, *Pbt_l2cap_chan; + +typedef struct bt_l2cap_le_endpoint bt_l2cap_le_endpoint, *Pbt_l2cap_le_endpoint; + +typedef struct k_timer.conflict21 k_timer.conflict21, *Pk_timer.conflict21; + +typedef struct k_timer.conflict21 k_timer_t.conflict18; + +typedef struct bt_l2cap_chan_ops bt_l2cap_chan_ops, *Pbt_l2cap_chan_ops; + +typedef enum bt_l2cap_chan_state { + BT_L2CAP_CONFIG=2, + BT_L2CAP_CONNECT=1, + BT_L2CAP_CONNECTED=3, + BT_L2CAP_DISCONNECT=4, + BT_L2CAP_DISCONNECTED=0 +} bt_l2cap_chan_state; + +typedef enum bt_l2cap_chan_state bt_l2cap_chan_state_t; + +typedef struct k_delayed_work.conflict13 k_delayed_work.conflict13, *Pk_delayed_work.conflict13; + +typedef struct k_timer.conflict20 k_timer.conflict20, *Pk_timer.conflict20; + +typedef struct k_timer.conflict20 k_timer_t.conflict17; + +struct bt_l2cap_chan { + struct bt_conn * conn; + struct bt_l2cap_chan_ops * ops; + sys_snode_t node; + void (* destroy)(struct bt_l2cap_chan *); + struct k_delayed_work rtx_work; + atomic_t status[1]; + bt_l2cap_chan_state_t state; + undefined field_0x39; + u16_t psm; + u8_t ident; + enum bt_security_t required_sec_level; + undefined field_0x3e; + undefined field_0x3f; +}; + +struct bt_l2cap_le_endpoint { + u16_t cid; + u16_t mtu; + u16_t mps; + u16_t init_credits; + struct k_sem credits; +}; + +struct k_timer.conflict20 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +struct k_delayed_work.conflict13 { + struct k_work work; + struct k_work_q * work_q; + k_timer_t.conflict17 timer; +}; + +struct bt_l2cap_chan.conflict4 { + struct bt_conn * conn; + struct bt_l2cap_chan_ops * ops; + sys_snode_t node; + void (* destroy)(struct bt_l2cap_chan *); + struct k_delayed_work.conflict13 rtx_work; + atomic_t status[1]; + bt_l2cap_chan_state_t state; + undefined field_0x39; + u16_t psm; + u8_t ident; + enum bt_security_t required_sec_level; + undefined field_0x3e; + undefined field_0x3f; +}; + +struct k_timer.conflict21 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +struct bt_l2cap_chan_ops { + void (* connected)(struct bt_l2cap_chan *); + void (* disconnected)(struct bt_l2cap_chan *); + void (* encrypt_change)(struct bt_l2cap_chan *, u8_t); + net_buf * (* alloc_buf)(struct bt_l2cap_chan *); + int (* recv)(struct bt_l2cap_chan *, struct net_buf *); + void (* sent)(struct bt_l2cap_chan *); + void (* status)(struct bt_l2cap_chan *, atomic_t *); +}; + +struct bt_l2cap_le_chan.conflict3 { + struct bt_l2cap_chan.conflict4 chan; + struct bt_l2cap_le_endpoint rx; + struct bt_l2cap_le_endpoint tx; + struct k_fifo tx_queue; + struct net_buf * tx_buf; + struct net_buf * _sdu; + u16_t _sdu_len; + undefined field_0x7e; + undefined field_0x7f; + struct k_work rx_work; + struct k_fifo rx_queue; +}; + +struct k_delayed_work.conflict14 { + struct k_work work; + struct k_work_q * work_q; + k_timer_t.conflict18 timer; +}; + +struct bt_att { + struct bt_l2cap_le_chan.conflict3 chan; + atomic_t flags[1]; + struct bt_att_req.conflict26 * req; + sys_slist_t reqs; + struct k_delayed_work.conflict14 timeout_work; + struct k_sem tx_sem; + struct k_fifo tx_queue; +}; + +typedef struct find_type_data find_type_data, *Pfind_type_data; + +typedef struct bt_att_handle_group bt_att_handle_group, *Pbt_att_handle_group; + +struct bt_att_handle_group { + u16_t start_handle; + u16_t end_handle; +}; + +struct find_type_data { + struct bt_att * att; + struct net_buf * buf; + struct bt_att_handle_group * group; + void * value; + u8_t value_len; + u8_t err; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct read_type_data read_type_data, *Pread_type_data; + +typedef struct bt_att_read_type_rsp bt_att_read_type_rsp, *Pbt_att_read_type_rsp; + +typedef struct bt_att_data bt_att_data, *Pbt_att_data; + +struct bt_att_data { + u16_t handle; + u8_t[0] value; +}; + +struct read_type_data { + struct bt_att * att; + struct bt_uuid * uuid; + struct net_buf * buf; + struct bt_att_read_type_rsp * rsp; + struct bt_att_data * item; + u8_t err; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +struct bt_att_read_type_rsp { + u8_t len; + struct bt_att_data[0] data; +}; + +typedef struct att_handler.conflict2 att_handler.conflict2, *Patt_handler.conflict2; + +typedef enum att_type_t { + ATT_COMMAND=0, + ATT_CONFIRMATION=4, + ATT_INDICATION=5, + ATT_NOTIFICATION=3, + ATT_REQUEST=1, + ATT_RESPONSE=2, + ATT_UNKNOWN=6 +} att_type_t; + +struct att_handler.conflict2 { + u8_t op; + u8_t expect_len; + enum att_type_t type; + undefined field_0x3; + u8_t (* func)(struct bt_att *, struct net_buf *); +}; + +typedef struct att_handler.conflict3 att_handler.conflict3, *Patt_handler.conflict3; + +struct att_handler.conflict3 { + u8_t op; + u8_t expect_len; + enum att_type_t type; + undefined field_0x3; + u8_t (* func)(struct bt_att *, struct net_buf *); +}; + +typedef struct att_handler.conflict1 att_handler.conflict1, *Patt_handler.conflict1; + +struct att_handler.conflict1 { + u8_t op; + u8_t expect_len; + enum att_type_t type; + undefined field_0x3; + u8_t (* func)(struct bt_att *, struct net_buf *); +}; + +typedef struct read_data read_data, *Pread_data; + +typedef struct bt_att_read_rsp bt_att_read_rsp, *Pbt_att_read_rsp; + +struct read_data { + struct bt_att * att; + u16_t offset; + undefined field_0x6; + undefined field_0x7; + struct net_buf * buf; + struct bt_att_read_rsp * rsp; + u8_t err; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; +}; + +struct bt_att_read_rsp { // Missing member value : u8_t[1] at offset 0x0 [Unsupported interior flex array: u8_t[1]] +}; + +typedef struct find_info_data find_info_data, *Pfind_info_data; + +typedef struct bt_att_find_info_rsp bt_att_find_info_rsp, *Pbt_att_find_info_rsp; + + +// WARNING! conflicting data type names: /DWARF/att.c/find_info_data/anon_union_for_field_3 - /DWARF/gatt.h/bt_gatt_discover_params/anon_union_for_field_3 + +struct find_info_data { + struct bt_att * att; + struct net_buf * buf; + struct bt_att_find_info_rsp * rsp; + union anon_union_for_field_3 field_3; +}; + +struct bt_att_find_info_rsp { + u8_t format; + u8_t[0] info; +}; + +typedef struct read_group_data read_group_data, *Pread_group_data; + +typedef struct bt_att_read_group_rsp bt_att_read_group_rsp, *Pbt_att_read_group_rsp; + +typedef struct bt_att_group_data bt_att_group_data, *Pbt_att_group_data; + +struct bt_att_read_group_rsp { + u8_t len; + struct bt_att_group_data[0] data; +}; + +struct bt_att_group_data { + u16_t start_handle; + u16_t end_handle; + u8_t[0] value; +}; + +struct read_group_data { + struct bt_att * att; + struct bt_uuid * uuid; + struct net_buf * buf; + struct bt_att_read_group_rsp * rsp; + struct bt_att_group_data * group; +}; + +typedef struct write_data.conflict write_data.conflict, *Pwrite_data.conflict; + +struct write_data.conflict { + struct bt_conn * conn; + struct net_buf * buf; + u8_t req; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + void * value; + u16_t len; + u16_t offset; + u8_t err; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct att_handler att_handler, *Patt_handler; + +struct att_handler { + u8_t op; + u8_t expect_len; + enum att_type_t type; + undefined field_0x3; + u8_t (* func)(struct bt_att *, struct net_buf *); +}; + +typedef struct att_handler.conflict att_handler.conflict, *Patt_handler.conflict; + +struct att_handler.conflict { + u8_t op; + u8_t expect_len; + enum att_type_t type; + undefined field_0x3; + u8_t (* func)(struct bt_att *, struct net_buf *); +}; + + +// WARNING! conflicting data type names: /DWARF/att.c/att_read_group_req/anon_union_for_u - /DWARF/timers.c/tmrTimerQueueMessage/anon_union_for_u + + +// WARNING! conflicting data type names: /DWARF/att.c/att_read_type_req/anon_union_for_u - /DWARF/timers.c/tmrTimerQueueMessage/anon_union_for_u + +typedef struct anon_struct.conflict118 anon_struct.conflict118, *Panon_struct.conflict118; + +typedef err_t (* netif_init_fn)(struct netif *); + +struct anon_struct.conflict118 { + ip4_addr_t * ipaddr; + ip4_addr_t * netmask; + ip4_addr_t * gw; + void * state; + netif_init_fn init; + err_t (* input)(struct pbuf *, struct netif *); +}; + +typedef struct anon_struct.conflict119 anon_struct.conflict119, *Panon_struct.conflict119; + +typedef void (* netifapi_void_fn)(struct netif *); + +typedef err_t (* netifapi_errt_fn)(struct netif *); + +struct anon_struct.conflict119 { + netifapi_void_fn voidfunc; + netifapi_errt_fn errtfunc; +}; + +typedef struct netifapi_msg netifapi_msg, *Pnetifapi_msg; + +typedef struct tcpip_api_call_data tcpip_api_call_data, *Ptcpip_api_call_data; + +typedef union anon_union_for_msg anon_union_for_msg, *Panon_union_for_msg; + +typedef QueueHandle_t SemaphoreHandle_t; + +typedef SemaphoreHandle_t sys_sem_t; + +typedef struct anon_struct.conflict120 anon_struct.conflict120, *Panon_struct.conflict120; + +struct tcpip_api_call_data { + err_t err; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + sys_sem_t sem; +}; + +struct anon_struct.conflict120 { + char * name; + u8_t index; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +union anon_union_for_msg { + struct anon_struct.conflict118 add; + struct anon_struct.conflict119 common; + struct anon_struct.conflict120 ifs; +}; + +struct netifapi_msg { + struct tcpip_api_call_data call; + struct netif * netif; + union anon_union_for_msg msg; +}; + +typedef struct k_delayed_work.conflict6 k_delayed_work.conflict6, *Pk_delayed_work.conflict6; + +typedef struct k_timer.conflict13 k_timer.conflict13, *Pk_timer.conflict13; + +typedef struct k_timer.conflict13 k_timer_t.conflict10; + +struct k_timer.conflict13 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +struct k_delayed_work.conflict6 { + struct k_work work; + struct k_work_q * work_q; + k_timer_t.conflict10 timer; +}; + +typedef struct k_delayed_work.conflict5 k_delayed_work.conflict5, *Pk_delayed_work.conflict5; + +typedef struct k_timer.conflict12 k_timer.conflict12, *Pk_timer.conflict12; + +typedef struct k_timer.conflict12 k_timer_t.conflict9; + +struct k_timer.conflict12 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +struct k_delayed_work.conflict5 { + struct k_work work; + struct k_work_q * work_q; + k_timer_t.conflict9 timer; +}; + +typedef struct k_delayed_work.conflict2 k_delayed_work.conflict2, *Pk_delayed_work.conflict2; + +typedef struct k_timer.conflict7 k_timer.conflict7, *Pk_timer.conflict7; + +typedef struct k_timer.conflict7 k_timer_t.conflict5; + +struct k_timer.conflict7 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +struct k_delayed_work.conflict2 { + struct k_work work; + struct k_work_q * work_q; + k_timer_t.conflict5 timer; +}; + +typedef struct k_delayed_work.conflict1 k_delayed_work.conflict1, *Pk_delayed_work.conflict1; + +typedef struct k_timer.conflict6 k_timer.conflict6, *Pk_timer.conflict6; + +typedef struct k_timer.conflict6 k_timer_t.conflict4; + +struct k_timer.conflict6 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +struct k_delayed_work.conflict1 { + struct k_work work; + struct k_work_q * work_q; + k_timer_t.conflict4 timer; +}; + +typedef struct timer_rec_d timer_rec_d, *Ptimer_rec_d; + +struct timer_rec_d { + bl_timer_t timer; + struct k_delayed_work * delay_work; +}; + +typedef struct k_delayed_work.conflict k_delayed_work.conflict, *Pk_delayed_work.conflict; + +typedef struct k_timer.conflict5 k_timer.conflict5, *Pk_timer.conflict5; + +typedef struct k_timer.conflict5 k_timer_t.conflict3; + +struct k_timer.conflict5 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +struct k_delayed_work.conflict { + struct k_work work; + struct k_work_q * work_q; + k_timer_t.conflict3 timer; +}; + +typedef struct _rom_dir_t _rom_dir_t, *P_rom_dir_t; + +struct _rom_dir_t { + struct aos_dir_t dir; + char * dir_start_addr; + char * dir_end_addr; + char * dir_cur_addr; + struct aos_dirent_t cur_dirent; +}; + +typedef struct _rom_dir_t romfs_dir_t; + +typedef struct romfh romfh, *Promfh; + +struct romfh { + int32_t nextfh; + int32_t spec; + int32_t size; + int32_t checksum; +}; + +typedef struct StreamBufferDef_t StreamBufferDef_t, *PStreamBufferDef_t; + +typedef struct StreamBufferDef_t * StreamBufferHandle_t; + +struct StreamBufferDef_t { + size_t xTail; + size_t xHead; + size_t xLength; + size_t xTriggerLevelBytes; + TaskHandle_t xTaskWaitingToReceive; + TaskHandle_t xTaskWaitingToSend; + uint8_t * pucBuffer; + uint8_t ucFlags; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; + UBaseType_t uxStreamBufferNumber; +}; + +typedef longlong __int_least64_t; + +typedef __int_least64_t time_t; + +typedef struct apInfo_t apInfo_t, *PapInfo_t; + +typedef struct BssConfig_t BssConfig_t, *PBssConfig_t; + +typedef struct BssData_t BssData_t, *PBssData_t; + +typedef struct apRsnConfig_t apRsnConfig_t, *PapRsnConfig_t; + +typedef struct CommonMlmeData_t CommonMlmeData_t, *PCommonMlmeData_t; + +typedef struct Cipher_t.conflict Cipher_t.conflict, *PCipher_t.conflict; + +typedef struct Operation_t Operation_t, *POperation_t; + +typedef UINT8 IEEEtypes_SsId_t[32]; + +typedef UINT8 IEEEtypes_Len_t; + +typedef UINT8 IEEEtypes_DtimPeriod_t; + +typedef UINT16 IEEEtypes_BcnInterval_t; + +typedef UINT8 IEEEtypes_Addr_t; + +typedef IEEEtypes_Addr_t IEEEtypes_MacAddr_t[6]; + +struct Operation_t { + UINT16 keyExchange:1; + UINT16 authenticate:1; + UINT16 reserved:14; +}; + +struct Cipher_t.conflict { + UINT8 wep40:1; + UINT8 wep104:1; + UINT8 tkip:1; + UINT8 ccmp:1; + UINT8 rsvd:4; +}; + +struct apRsnConfig_t { + struct Cipher_t.conflict mcstCipher; + UINT8 mcstCipherCount; + struct Cipher_t.conflict wpaUcstCipher; + UINT8 wpaUcstCipherCount; + struct Cipher_t.conflict wpa2UcstCipher; + UINT8 wpa2UcstCipherCount; + UINT16 AuthKey; + UINT16 AuthKeyCount; + struct Operation_t Akmp; + UINT32 GrpReKeyTime; + UINT8 PSKPassPhrase[64]; + UINT8 PSKPassPhraseLen; + UINT8 PSKValue[32]; + UINT8 MaxPwsHskRetries; + UINT8 MaxGrpHskRetries; + undefined field_0x73; + UINT32 PwsHskTimeOut; + UINT32 GrpHskTimeOut; +}; + +struct CommonMlmeData_t { + IEEEtypes_SsId_t SsId; + IEEEtypes_Len_t SsIdLen; + IEEEtypes_DtimPeriod_t DtimPeriod; + IEEEtypes_BcnInterval_t BcnPeriod; + IEEEtypes_MacAddr_t BssId; + UINT16 RtsThresh; + UINT16 FragThresh; + UINT8 ShortRetryLim; + UINT8 LongRetryLim; + UINT8 MbssBcnIntFac; + UINT8 MbssCurBcnIntCnt; + UINT16 Reserved; +}; + +struct BssConfig_t { + UINT32 StaAgeOutTime; + UINT32 PsStaAgeOutTime; + struct apRsnConfig_t RsnConfig; + struct CommonMlmeData_t comData; +}; + +struct BssData_t { + BOOLEAN updatePassPhrase; + struct mm_timer_tag apMicTimer; + struct KeyData_t grpKeyData; + UINT8 GNonce[32]; + UINT32 grpRekeyBcnCntConfigured; + UINT32 grpRekeyBcnCntRemaining; +}; + +struct apInfo_t { + struct BssConfig_t bssConfig; + struct BssData_t bssData; + UINT8 ApStop_Req_Pending; + undefined field_0x11d; + undefined field_0x11e; + undefined field_0x11f; +}; + +typedef struct _txQingInfo_t _txQingInfo_t, *P_txQingInfo_t; + +typedef enum IEEEtypes_PwrMgmtMode_e { + PWR_MODE_ACTIVE=0, + PWR_MODE_PWR_SAVE=1 +} IEEEtypes_PwrMgmtMode_e; + +struct _txQingInfo_t { + enum IEEEtypes_PwrMgmtMode_e mode; +}; + +typedef struct staData_t staData_t, *PstaData_t; + +typedef struct _txQingInfo_t txQingInfo_t; + +typedef struct apKeyMgmtInfoSta_t apKeyMgmtInfoSta_t, *PapKeyMgmtInfoSta_t; + +typedef struct apKeyMgmtInfoStaRom_t apKeyMgmtInfoStaRom_t, *PapKeyMgmtInfoStaRom_t; + +typedef struct SecurityMode_t SecurityMode_t, *PSecurityMode_t; + +typedef enum keyMgmtState_e { + GRPMSG1_PENDING=5, + GRP_REKEY_MSG1_PENDING=7, + HSK_DUMMY_STATE=9, + HSK_END=10, + HSK_NOT_STARTED=0, + MSG1_PENDING=1, + MSG3_PENDING=3, + WAITING_4_GRPMSG2=6, + WAITING_4_GRP_REKEY_MSG2=8, + WAITING_4_MSG2=2, + WAITING_4_MSG4=4 +} keyMgmtState_e; + +struct SecurityMode_t { + UINT16 noRsn:1; + UINT16 wepStatic:1; + UINT16 wepDynamic:1; + UINT16 wpa:1; + UINT16 wpaNone:1; + UINT16 wpa2:1; + UINT16 cckm:1; + UINT16 wapi:1; + UINT16 wpa3:1; + UINT16 rsvd:7; +}; + +struct apKeyMgmtInfoStaRom_t { + UINT16 staRsnCap; + struct SecurityMode_t staSecType; + struct Cipher_t.conflict staUcstCipher; + UINT8 staAkmType; + enum keyMgmtState_e keyMgmtState; + undefined field_0x7; +}; + +struct apKeyMgmtInfoSta_t { + struct apKeyMgmtInfoStaRom_t rom; + UINT8 numHskTries; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + UINT32 counterLo; + UINT32 counterHi; + struct mm_timer_tag HskTimer; + UINT8 EAPOL_MIC_Key[16]; + UINT8 EAPOL_Encr_Key[16]; + UINT8 EAPOLProtoVersion; + UINT8 rsvd[3]; +}; + +struct staData_t { + txQingInfo_t pwrSaveInfo; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + struct apKeyMgmtInfoSta_t keyMgmtInfo; +}; + +typedef struct StreamBufferDef_t StreamBuffer_t; + +typedef struct chan_env_tag chan_env_tag, *Pchan_env_tag; + +typedef struct chan_ctxt_tag chan_ctxt_tag, *Pchan_ctxt_tag; + +struct chan_env_tag { + struct co_list list_free_ctxt; + struct co_list list_sched_ctxt; + struct co_list list_tbtt; + struct co_list list_tbtt_delay; + struct chan_ctxt_tag * current_channel; + struct chan_ctxt_tag * chan_switch; + struct mm_timer_tag tmr_tbtt_switch; + struct mm_timer_tag tmr_cde; + struct mm_timer_tag tmr_ctxt_op; + struct mm_timer_tag tmr_conn_less; + uint32_t cde_dur_us; + uint32_t cde_time; + uint8_t status; + uint8_t cfm_cnt; + uint8_t nb_sched_ctxt; + uint8_t pm; +}; + +struct chan_ctxt_tag { + struct co_list_hdr list_hdr; + struct mm_chan_ctxt_add_req channel; + ke_task_id_t taskid; + uint16_t nb_slots; + uint16_t nb_rem_slots; + uint16_t nb_res_slots; + uint8_t status; + uint8_t idx; + uint8_t nb_linked_vif; + uint8_t vif_index; + undefined field_0x1a; + undefined field_0x1b; +}; + +typedef struct chan_tbtt_tag chan_tbtt_tag, *Pchan_tbtt_tag; + +struct chan_tbtt_tag { + struct co_list_hdr list_hdr; + uint32_t time; + uint8_t vif_index; + uint8_t priority; + uint8_t status; + undefined field_0xb; +}; + +typedef enum chan_tbtt_status { + CHAN_TBTT_NOT_PROG=0, + CHAN_TBTT_PRESENCE=2, + CHAN_TBTT_PROG=1, + CHAN_TBTT_STATUS_MAX=3 +} chan_tbtt_status; + +typedef enum chan_env_status_bit { + CHAN_ENV_BCN_DETECT_BIT=6, + CHAN_ENV_BIT_MAX=7, + CHAN_ENV_DELAY_PROG_BIT=4, + CHAN_ENV_ROC_BIT=2, + CHAN_ENV_ROC_WAIT_BIT=0, + CHAN_ENV_SCAN_BIT=3, + CHAN_ENV_SCAN_WAIT_BIT=1, + CHAN_ENV_TIMEOUT_BIT=5 +} chan_env_status_bit; + +typedef enum chan_ctxt_status { + CHAN_CTXT_STATUS_MAX=7, + CHAN_GOTO_IDLE=2, + CHAN_NOT_PROG=1, + CHAN_NOT_SCHEDULED=0, + CHAN_PRESENT=5, + CHAN_SENDING_NOA=6, + CHAN_WAITING_END=4, + CHAN_WAIT_NOA_CFM=3 +} chan_ctxt_status; + +typedef struct txl_cfm_env_tag txl_cfm_env_tag, *Ptxl_cfm_env_tag; + +struct txl_cfm_env_tag { + struct co_list cfmlist[5]; +}; + +typedef enum rxu_msg_tag { + RXU_MGT_IND=11264, + RXU_NULL_DATA=11265 +} rxu_msg_tag; + +typedef struct rxu_mgt_ind rxu_mgt_ind, *Prxu_mgt_ind; + +struct rxu_mgt_ind { + uint16_t length; + uint16_t framectrl; + uint16_t center_freq; + uint8_t band; + uint8_t sta_idx; + uint8_t inst_nbr; + uint8_t sa[6]; + undefined field_0xf; + uint32_t tsflo; + uint32_t tsfhi; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t data_rate; + uint32_t[0] payload; +}; + +typedef struct llc_snap llc_snap, *Pllc_snap; + +struct llc_snap { + uint16_t dsap_ssap; + uint16_t control_oui0; + uint16_t oui1_2; + uint16_t proto_id; +}; + +typedef struct rem_version rem_version, *Prem_version; + +struct rem_version { + uint8_t vers; + undefined field_0x1; + uint16_t compid; + uint16_t subvers; +}; + +typedef struct encrypt.conflict2 encrypt.conflict2, *Pencrypt.conflict2; + +typedef struct sess_k_div sess_k_div, *Psess_k_div; + +struct sess_k_div { + uint8_t skd[16]; +}; + +struct encrypt.conflict2 { + struct sess_k_div skd; + struct ltk ltk; + uint8_t randn[16]; +}; + +typedef struct encrypt.conflict1 encrypt.conflict1, *Pencrypt.conflict1; + +struct encrypt.conflict1 { + struct sess_k_div skd; + struct ltk ltk; + uint8_t randn[16]; +}; + +typedef struct encrypt.conflict4 encrypt.conflict4, *Pencrypt.conflict4; + +struct encrypt.conflict4 { + struct sess_k_div skd; + struct ltk ltk; + uint8_t randn[16]; +}; + +typedef struct encrypt.conflict3 encrypt.conflict3, *Pencrypt.conflict3; + +struct encrypt.conflict3 { + struct sess_k_div skd; + struct ltk ltk; + uint8_t randn[16]; +}; + +typedef struct encrypt.conflict6 encrypt.conflict6, *Pencrypt.conflict6; + +struct encrypt.conflict6 { + struct sess_k_div skd; + struct ltk ltk; + uint8_t randn[16]; +}; + +typedef struct encrypt.conflict5 encrypt.conflict5, *Pencrypt.conflict5; + +struct encrypt.conflict5 { + struct sess_k_div skd; + struct ltk ltk; + uint8_t randn[16]; +}; + +typedef struct encrypt.conflict8 encrypt.conflict8, *Pencrypt.conflict8; + +struct encrypt.conflict8 { + struct sess_k_div skd; + struct ltk ltk; + uint8_t randn[16]; +}; + +typedef struct encrypt.conflict7 encrypt.conflict7, *Pencrypt.conflict7; + +struct encrypt.conflict7 { + struct sess_k_div skd; + struct ltk ltk; + uint8_t randn[16]; +}; + +typedef struct llc_env_tag llc_env_tag, *Pllc_env_tag; + +typedef struct ea_elt_tag ea_elt_tag, *Pea_elt_tag; + +typedef struct llc_ch_asses_tag llc_ch_asses_tag, *Pllc_ch_asses_tag; + +typedef struct data_len_ext_tag data_len_ext_tag, *Pdata_len_ext_tag; + +struct ea_elt_tag { + struct co_list_hdr hdr; + struct ea_elt_tag * linked_element; + uint32_t timestamp; + uint32_t asap_limit; + uint16_t asap_settings; + uint16_t duration_min; + uint16_t delay; + uint8_t current_prio; + uint8_t stop_latency1; + uint8_t stop_latency2; + uint8_t start_latency; + undefined field_0x1a; + undefined field_0x1b; + void (* ea_cb_start)(struct ea_elt_tag *); + void (* ea_cb_stop)(struct ea_elt_tag *); + void (* ea_cb_cancel)(struct ea_elt_tag *); + void * env; +}; + +struct llc_ch_asses_tag { + int8_t rcvd_quality[37]; + _Bool latency_en; + uint8_t reassess_count; + uint8_t reassess_cursor; +}; + +struct data_len_ext_tag { + uint16_t conn_max_tx_octets; + uint16_t conn_max_rx_octets; + uint16_t conn_eff_max_tx_octets; + uint16_t conn_eff_max_rx_octets; + uint16_t conn_max_tx_time; + uint16_t conn_max_rx_time; + uint16_t conn_eff_max_tx_time; + uint16_t conn_eff_max_rx_time; + _Bool send_req_not_allowed; + uint8_t data_len_ext_flag; +}; + +struct llc_env_tag { + void * operation[4]; + struct ea_elt_tag * elt; + struct llc_ch_asses_tag chnl_assess; + struct rem_version peer_version; + struct data_len_ext_tag data_len_ext_info; + uint16_t sup_to; + uint16_t n_sup_to; + uint16_t auth_payl_to; + uint16_t auth_payl_to_margin; + uint16_t llc_status; + struct le_chnl_map ch_map; + struct le_chnl_map n_ch_map; + int8_t rssi; + struct le_features feats_used; + struct encrypt.conflict1 encrypt; + uint8_t disc_reason; + _Bool disc_event_sent; + uint8_t loc_proc_state; + uint8_t rem_proc_state; + uint8_t encryption_state; + _Bool peer_sup_conn_param_req; + undefined field_0xa7; +}; + +typedef struct encrypt.conflict9 encrypt.conflict9, *Pencrypt.conflict9; + +struct encrypt.conflict9 { + struct sess_k_div skd; + struct ltk ltk; + uint8_t randn[16]; +}; + +typedef enum llc_dle_flag { + LLC_DLE_EVT_SENT_LSB=1, + LLC_DLE_EVT_SENT_MASK=2, + LLC_DLE_REQ_RCVD_LSB=0, + LLC_DLE_REQ_RCVD_MASK=1 +} llc_dle_flag; + +typedef struct encrypt.conflict16 encrypt.conflict16, *Pencrypt.conflict16; + +struct encrypt.conflict16 { + struct sess_k_div skd; + struct ltk ltk; + uint8_t randn[16]; +}; + +typedef struct encrypt.conflict11 encrypt.conflict11, *Pencrypt.conflict11; + +struct encrypt.conflict11 { + struct sess_k_div skd; + struct ltk ltk; + uint8_t randn[16]; +}; + +typedef struct encrypt.conflict10 encrypt.conflict10, *Pencrypt.conflict10; + +struct encrypt.conflict10 { + struct sess_k_div skd; + struct ltk ltk; + uint8_t randn[16]; +}; + +typedef struct encrypt.conflict13 encrypt.conflict13, *Pencrypt.conflict13; + +struct encrypt.conflict13 { + struct sess_k_div skd; + struct ltk ltk; + uint8_t randn[16]; +}; + +typedef struct encrypt.conflict12 encrypt.conflict12, *Pencrypt.conflict12; + +struct encrypt.conflict12 { + struct sess_k_div skd; + struct ltk ltk; + uint8_t randn[16]; +}; + +typedef struct encrypt.conflict15 encrypt.conflict15, *Pencrypt.conflict15; + +struct encrypt.conflict15 { + struct sess_k_div skd; + struct ltk ltk; + uint8_t randn[16]; +}; + +typedef struct encrypt.conflict14 encrypt.conflict14, *Pencrypt.conflict14; + +struct encrypt.conflict14 { + struct sess_k_div skd; + struct ltk ltk; + uint8_t randn[16]; +}; + +typedef enum llc_status_flag { + LLC_STAT_DISC_REM_REQ_LSB=9, + LLC_STAT_DISC_REM_REQ_MASK=512, + LLC_STAT_FEAT_EXCH_LSB=0, + LLC_STAT_FEAT_EXCH_MASK=1, + LLC_STAT_INSTANT_PROCEED_LSB=11, + LLC_STAT_INSTANT_PROCEED_MASK=2048, + LLC_STAT_LLCP_DISCARD_LSB=3, + LLC_STAT_LLCP_DISCARD_MASK=8, + LLC_STAT_LLCP_INSTANT_EXTRACTED_LSB=10, + LLC_STAT_LLCP_INSTANT_EXTRACTED_MASK=1024, + LLC_STAT_PEER_VERS_KNOWN_LSB=1, + LLC_STAT_PEER_VERS_KNOWN_MASK=2, + LLC_STAT_SYNC_FOUND_LSB=8, + LLC_STAT_SYNC_FOUND_MASK=256, + LLC_STAT_TO_PENDING_LSB=4, + LLC_STAT_TO_PENDING_MASK=16, + LLC_STAT_UPDATE_EVT_SENT_LSB=7, + LLC_STAT_UPDATE_EVT_SENT_MASK=-128, + LLC_STAT_UPDATE_HOST_REQ_LSB=6, + LLC_STAT_UPDATE_HOST_REQ_MASK=64, + LLC_STAT_UPDATE_PENDING_LSB=5, + LLC_STAT_UPDATE_PENDING_MASK=32, + LLC_STAT_WAIT_TRAFFIC_PAUSED_LSB=2, + LLC_STAT_WAIT_TRAFFIC_PAUSED_MASK=4 +} llc_status_flag; + +typedef struct encrypt.conflict encrypt.conflict, *Pencrypt.conflict; + +struct encrypt.conflict { + struct sess_k_div skd; + struct ltk ltk; + uint8_t randn[16]; +}; + +typedef struct llc_snap_short llc_snap_short, *Pllc_snap_short; + +struct llc_snap_short { + uint16_t dsap_ssap; + uint16_t control_oui0; + uint16_t oui1_2; +}; + +typedef void * aos_loop_t; + +typedef struct yloop_sock_t yloop_sock_t, *Pyloop_sock_t; + +struct yloop_sock_t { + int sock; + void * private_data; + void (* cb)(int, void *); +}; + +typedef struct input_event_t input_event_t, *Pinput_event_t; + +struct input_event_t { + uint32_t time; + uint16_t type; + uint16_t code; + ulong value; + ulong extra; +}; + +typedef struct yloop_ctx_t yloop_ctx_t, *Pyloop_ctx_t; + +typedef struct pollfd pollfd, *Ppollfd; + +struct pollfd { + int fd; + short events; + short revents; +}; + +struct yloop_ctx_t { + dlist_t timeouts; + struct pollfd * pollfds; + struct yloop_sock_t * readers; + int eventfd; + uint16_t max_sock; + uint8_t reader_count; + _Bool pending_terminate; + _Bool terminate; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; +}; + +typedef struct wifi_mgmr_ap_item wifi_mgmr_ap_item, *Pwifi_mgmr_ap_item; + +typedef struct wifi_mgmr_ap_item wifi_mgmr_ap_item_t; + +struct wifi_mgmr_ap_item { + char ssid[32]; + char ssid_tail[1]; + undefined field_0x21; + undefined field_0x22; + undefined field_0x23; + uint32_t ssid_len; + uint8_t bssid[6]; + uint8_t channel; + uint8_t auth; + int8_t rssi; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef enum WIFI_STATE_ENUM_LIST { + WIFI_STATE_CONNECTED_IP_GETTING=3, + WIFI_STATE_CONNECTED_IP_GOT=4, + WIFI_STATE_CONNECTING=2, + WIFI_STATE_DISCONNECT=5, + WIFI_STATE_IDLE=1, + WIFI_STATE_IFDOWN=6, + WIFI_STATE_NO_AP_FOUND=9, + WIFI_STATE_PSK_ERROR=8, + WIFI_STATE_SNIFFER=7, + WIFI_STATE_UNKNOWN=0, + WIFI_STATE_WITH_AP_CONNECTED_IP_GETTING=19, + WIFI_STATE_WITH_AP_CONNECTED_IP_GOT=20, + WIFI_STATE_WITH_AP_CONNECTING=18, + WIFI_STATE_WITH_AP_DISCONNECT=21, + WIFI_STATE_WITH_AP_IDLE=17 +} WIFI_STATE_ENUM_LIST; + +typedef struct wifi_conf wifi_conf, *Pwifi_conf; + +typedef struct wifi_conf wifi_conf_t; + +struct wifi_conf { + char country_code[3]; + undefined field_0x3; + int channel_nums; +}; + +typedef struct wifi_sta_basic_info wifi_sta_basic_info, *Pwifi_sta_basic_info; + +struct wifi_sta_basic_info { + uint8_t sta_idx; + uint8_t is_used; + uint8_t sta_mac[6]; + uint32_t tsfhi; + uint32_t tsflo; + int rssi; + uint8_t data_rate; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct wifi_mgmr_sta_connect_ind_stat_info wifi_mgmr_sta_connect_ind_stat_info, *Pwifi_mgmr_sta_connect_ind_stat_info; + +typedef struct wifi_mgmr_sta_connect_ind_stat_info wifi_mgmr_sta_connect_ind_stat_info_t; + +struct wifi_mgmr_sta_connect_ind_stat_info { + uint16_t status_code; + uint8_t type_ind; + char ssid[32]; + char psk[65]; + char pmk[64]; + uint8_t bssid[6]; + uint16_t chan_freq; + uint8_t chan_band; + undefined field_0xad; +}; + +typedef void * wifi_interface_t; + +typedef enum WIFI_SCAN_DONE_EVENT_TYPE { + WIFI_SCAN_DONE_EVENT_BUSY=1, + WIFI_SCAN_DONE_EVENT_OK=0 +} WIFI_SCAN_DONE_EVENT_TYPE; + +typedef struct rx_cntrl_pm_mon rx_cntrl_pm_mon, *Prx_cntrl_pm_mon; + +struct rx_cntrl_pm_mon { + struct mac_addr.conflict addr; + uint8_t pm_state; + _Bool mon; +}; + +typedef struct rx_cntrl_ipcdesc rx_cntrl_ipcdesc, *Prx_cntrl_ipcdesc; + +struct rx_cntrl_ipcdesc { + uint32_t host_id; +}; + +typedef struct rxu_cntrl_env_tag rxu_cntrl_env_tag, *Prxu_cntrl_env_tag; + +typedef struct rx_cntrl_rx_status rx_cntrl_rx_status, *Prx_cntrl_rx_status; + +typedef struct rx_cntrl_dupli rx_cntrl_dupli, *Prx_cntrl_dupli; + +struct rx_cntrl_dupli { + struct mac_addr.conflict last_src_addr; + uint16_t last_seq_cntl; +}; + +struct rx_cntrl_rx_status { + uint16_t frame_cntl; + uint16_t seq_cntl; + uint16_t sn; + uint8_t fn; + uint8_t tid; + uint8_t machdr_len; + uint8_t sta_idx; + uint8_t vif_idx; + uint8_t dst_idx; + undefined field_0xc; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint64_t pn; + uint32_t statinfo; + uint32_t host_buf_addr; + struct key_info_tag * key; + struct mac_addr.conflict da; + struct mac_addr.conflict sa; + uint8_t frame_info; + _Bool eth_len_present; + uint8_t payl_offset; + undefined field_0x33; + undefined field_0x34; + undefined field_0x35; + undefined field_0x36; + undefined field_0x37; +}; + +struct rxu_cntrl_env_tag { + struct rx_cntrl_rx_status rx_status; + struct co_list rxdesc_pending; + struct co_list rxdesc_ready; + struct rx_cntrl_ipcdesc rx_ipcdesc_stat; + struct co_list rxu_defrag_free; + struct co_list rxu_defrag_used; + struct rx_cntrl_dupli rxu_dupli; + struct mac_addr.conflict * mac_addr_ptr; + struct rx_cntrl_pm_mon pm_mon; + uint32_t ttr; + undefined field_0x74; + undefined field_0x75; + undefined field_0x76; + undefined field_0x77; +}; + +typedef struct rxu_mic_calc rxu_mic_calc, *Prxu_mic_calc; + +typedef struct mic_calc mic_calc, *Pmic_calc; + +struct mic_calc { + uint32_t mic_key_least; + uint32_t mic_key_most; + uint32_t last_m_i; + uint8_t last_m_i_len; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; +}; + +struct rxu_mic_calc { + struct mic_calc mic_calc; + uint32_t last_bytes[2]; +}; + +typedef enum rxu_cntrl_frame_info_pos { + RXU_CNTRL_MIC_CHECK_NEEDED=1, + RXU_CNTRL_NEW_MESH_PEER=4, + RXU_CNTRL_PN_CHECK_NEEDED=2 +} rxu_cntrl_frame_info_pos; + +typedef struct A_BLOCK_LINK A_BLOCK_LINK, *PA_BLOCK_LINK; + +struct A_BLOCK_LINK { + struct A_BLOCK_LINK * pxNextFreeBlock; + size_t xBlockSize; +}; + +typedef struct A_BLOCK_LINK BlockLink_t; + +typedef struct yloop_timeout_s yloop_timeout_s, *Pyloop_timeout_s; + +typedef struct yloop_timeout_s yloop_timeout_t; + +struct yloop_timeout_s { + dlist_t next; + longlong timeout_ms; + void * private_data; + void (* cb)(void *); + int ms; + undefined field_0x1c; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +typedef struct llcp_pdu_tag llcp_pdu_tag, *Pllcp_pdu_tag; + +struct llcp_pdu_tag { + struct co_list_hdr hdr; + uint16_t idx; + undefined field_0x6; + undefined field_0x7; + void * ptr; + uint8_t opcode; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; +}; + +typedef enum llc_llcp_authorize { + LLC_LLCP_NO_AUTHZED=0, + LLC_LLCP_PAUSE_ENC_AUTHZED=2, + LLC_LLCP_START_ENC_AUTHZED=1 +} llc_llcp_authorize; + +typedef enum bam_state_tag { + BAM_ACTIVE=1, + BAM_CHECK_ADMISSION=3, + BAM_IDLE=0, + BAM_RESET=4, + BAM_STATE_MAX=5, + BAM_WAIT_RSP=2 +} bam_state_tag; + +typedef struct co_read16_struct co_read16_struct, *Pco_read16_struct; + +struct co_read16_struct { + uint16_t val; +}; + +typedef struct co_read32_struct co_read32_struct, *Pco_read32_struct; + +struct co_read32_struct { + uint32_t val; +}; + +typedef struct raw_pcb raw_pcb, *Praw_pcb; + +struct raw_pcb { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct raw_pcb * next; + u8_t protocol; + u8_t flags; + u8_t mcast_ifindex; + u8_t mcast_ttl; + u8_t (* recv)(void *, struct raw_pcb *, struct pbuf *, ip_addr_t *); + void * recv_arg; +}; + +typedef struct tskTaskControlBlock tskTCB; + +typedef tskTCB TCB_t; + +typedef int sys_prot_t; + +typedef struct ipc_host_cb_tag ipc_host_cb_tag, *Pipc_host_cb_tag; + +struct ipc_host_cb_tag { + int (* send_data_cfm)(void *, void *); + uint8_t (* recv_data_ind)(void *, void *); + uint8_t (* recv_radar_ind)(void *, void *); + uint8_t (* recv_msg_ind)(void *, void *); + uint8_t (* recv_msgack_ind)(void *, void *); + uint8_t (* recv_dbg_ind)(void *, void *); + void (* prim_tbtt_ind)(void *); + void (* sec_tbtt_ind)(void *); +}; + +typedef struct ipc_hostbuf ipc_hostbuf, *Pipc_hostbuf; + +struct ipc_hostbuf { + void * hostid; + uint32_t dma_addr; +}; + +typedef struct ipc_host_env_tag ipc_host_env_tag, *Pipc_host_env_tag; + +struct ipc_host_env_tag { + struct ipc_host_cb_tag cb; + struct ipc_shared_env_tag * shared; + struct ipc_hostbuf ipc_host_rxdesc_array[2]; + uint8_t ipc_host_rxdesc_idx; + uint8_t rxdesc_nb; + uint8_t ipc_host_rxbuf_idx; + undefined field_0x37; + uint32_t rx_bufnb; + uint32_t rx_bufsz; + uint32_t txdesc_free_idx; + uint32_t txdesc_used_idx; + void * tx_host_id0[4]; + void * * tx_host_id; + struct txdesc_host * txdesc; + struct ipc_hostbuf ipc_host_msgbuf_array[8]; + uint8_t ipc_host_msge2a_idx; + undefined field_0xa1; + undefined field_0xa2; + undefined field_0xa3; + uint32_t ipc_e2amsg_bufnb; + uint32_t ipc_e2amsg_bufsz; + uint8_t msga2e_cnt; + undefined field_0xad; + undefined field_0xae; + undefined field_0xaf; + void * msga2e_hostid; + struct ipc_hostbuf ipc_host_dbgbuf_array[4]; + uint8_t ipc_host_dbg_idx; + undefined field_0xd5; + undefined field_0xd6; + undefined field_0xd7; + uint32_t ipc_dbg_bufnb; + uint32_t ipc_dbg_bufsz; + void * pthis; +}; + +typedef struct k_poll_event k_poll_event, *Pk_poll_event; + +typedef struct _dnode sys_dnode_t; + +typedef struct _poller _poller, *P_poller; + +typedef union anon_union_for_field_7 anon_union_for_field_7, *Panon_union_for_field_7; + +typedef struct k_poll_signal k_poll_signal, *Pk_poll_signal; + +union anon_union_for_field_7 { + void * obj; + struct k_poll_signal * signal; + struct k_sem * sem; + struct k_fifo * fifo; + struct k_queue * queue; +}; + +struct k_poll_event { + sys_dnode_t _node; + struct _poller * poller; + u32_t.conflict tag:8; + u32_t.conflict type:4; + u32_t.conflict state:4; + u32_t.conflict mode:1; + u32_t.conflict unused:15; + union anon_union_for_field_7 field_7; +}; + +struct k_poll_signal { + sys_dlist_t poll_events; + uint signaled; + int result; +}; + +struct _poller { +}; + +typedef enum _poll_types_bits { + _POLL_NUM_TYPES=4, + _POLL_TYPE_DATA_AVAILABLE=3, + _POLL_TYPE_IGNORE=0, + _POLL_TYPE_SEM_AVAILABLE=2, + _POLL_TYPE_SIGNAL=1 +} _poll_types_bits; + +typedef enum _poll_states_bits { + _POLL_NUM_STATES=4, + _POLL_STATE_DATA_AVAILABLE=3, + _POLL_STATE_NOT_READY=0, + _POLL_STATE_SEM_AVAILABLE=2, + _POLL_STATE_SIGNALED=1 +} _poll_states_bits; + +typedef enum k_poll_modes { + K_POLL_MODE_NOTIFY_ONLY=0, + K_POLL_NUM_MODES=1 +} k_poll_modes; + +typedef struct rfc_status_tag.conflict rfc_status_tag.conflict, *Prfc_status_tag.conflict; + +struct rfc_status_tag.conflict { + uint32_t pkdet_out_raw:1; + uint32_t dig_xtal_clk_dbg:1; + uint32_t clk_ble_16m_dbg:1; + uint32_t clk_rc_dbg0:1; + uint32_t clk_adcpow_dbg:1; + uint32_t clk_fetx_dbg:1; + uint32_t clk_ferx_dbg:1; + uint32_t clkpll_postdiv_outclk_dbg:1; + uint32_t clk_soc_480m_dbg:1; + uint32_t clk_soc_240m_dbg:1; + uint32_t clk_soc_192m_dbg:1; + uint32_t clk_soc_160m_dbg:1; + uint32_t clk_soc_120m_dbg:1; + uint32_t clk_soc_96m_dbg:1; + uint32_t clk_soc_80m_dbg:1; + uint32_t clk_soc_48m_dbg:1; + uint32_t clk_soc_32m_dbg:1; + uint32_t pad_pkdet_out:1; + uint32_t pad_agc_ctrl:10; + uint32_t rf_pkdet_rst_hw:1; + uint32_t rf_cbw_wifi:2; + uint32_t lo_unlocked:1; + uint32_t fsm_pu_txbuf:1; + uint32_t fsm_pu_rxbuf:1; + uint32_t fsm_pu_tosdac:1; + uint32_t fsm_pu_dac:1; + uint32_t fsm_trsw_en:1; + uint32_t fsm_pu_adc:1; + uint32_t fsm_pu_pkdet:1; + uint32_t fsm_pu_rbb:1; + uint32_t fsm_pu_rmx:1; + uint32_t fsm_pu_rmxgm:1; + uint32_t fsm_pu_lna:1; + uint32_t clk_rc_dbg2:1; + uint32_t rf_lna_ind_hw:4; + uint32_t rf_rbb_ind_hw:4; + uint32_t rf_tx_pow_lvl_hw:4; + uint32_t rf_rc_lo_rdy:1; + uint32_t rf_fsm_state:3; + uint32_t rf_rc_state:3; + uint32_t clk_rc_dbg:1; +}; + +typedef struct rfc_status_tag rfc_status_tag, *Prfc_status_tag; + +struct rfc_status_tag { + uint32_t pkdet_out_raw:1; + uint32_t dig_xtal_clk_dbg:1; + uint32_t clk_ble_16m_dbg:1; + uint32_t clk_rc_dbg0:1; + uint32_t clk_adcpow_dbg:1; + uint32_t clk_fetx_dbg:1; + uint32_t clk_ferx_dbg:1; + uint32_t clkpll_postdiv_outclk_dbg:1; + uint32_t clk_soc_480m_dbg:1; + uint32_t clk_soc_240m_dbg:1; + uint32_t clk_soc_192m_dbg:1; + uint32_t clk_soc_160m_dbg:1; + uint32_t clk_soc_120m_dbg:1; + uint32_t clk_soc_96m_dbg:1; + uint32_t clk_soc_80m_dbg:1; + uint32_t clk_soc_48m_dbg:1; + uint32_t clk_soc_32m_dbg:1; + uint32_t pad_pkdet_out:1; + uint32_t pad_agc_ctrl:10; + uint32_t rf_pkdet_rst_hw:1; + uint32_t rf_cbw_wifi:2; + uint32_t lo_unlocked:1; + uint32_t fsm_pu_txbuf:1; + uint32_t fsm_pu_rxbuf:1; + uint32_t fsm_pu_tosdac:1; + uint32_t fsm_pu_dac:1; + uint32_t fsm_trsw_en:1; + uint32_t fsm_pu_adc:1; + uint32_t fsm_pu_pkdet:1; + uint32_t fsm_pu_rbb:1; + uint32_t fsm_pu_rmx:1; + uint32_t fsm_pu_rmxgm:1; + uint32_t fsm_pu_lna:1; + uint32_t clk_rc_dbg2:1; + uint32_t rf_lna_ind_hw:4; + uint32_t rf_rbb_ind_hw:4; + uint32_t rf_tx_pow_lvl_hw:4; + uint32_t rf_rc_lo_rdy:1; + uint32_t rf_fsm_state:3; + uint32_t rf_rc_state:3; + uint32_t clk_rc_dbg:1; +}; + +typedef struct tc_aes_key_sched_struct tc_aes_key_sched_struct, *Ptc_aes_key_sched_struct; + +struct tc_aes_key_sched_struct { + uint words[44]; +}; + +typedef struct tc_aes_key_sched_struct * TCAesKeySched_t; + +typedef struct Cipher_t Cipher_t, *PCipher_t; + +struct Cipher_t { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +typedef struct anon_struct.conflict16 anon_struct.conflict16, *Panon_struct.conflict16; + +struct anon_struct.conflict16 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct mm_monitor_channel_cfm mm_monitor_channel_cfm, *Pmm_monitor_channel_cfm; + +struct mm_monitor_channel_cfm { + uint32_t status; + uint32_t freq; + uint32_t data[8]; +}; + +typedef struct mm_rssi_status_ind mm_rssi_status_ind, *Pmm_rssi_status_ind; + +struct mm_rssi_status_ind { + u8_l vif_index; + bool_l rssi_status; + s8_l rssi; +}; + +typedef union anon_union.conflict16 anon_union.conflict16, *Panon_union.conflict16; + +union anon_union.conflict16 { + undefined1 get; // Data type larger than union's declared size: anon_struct[1] + undefined1 reset; // Data type larger than union's declared size: anon_struct[1] + undefined1 set; // Data type larger than union's declared size: anon_struct[1] +}; + +typedef struct mm_channel_switch_ind mm_channel_switch_ind, *Pmm_channel_switch_ind; + +struct mm_channel_switch_ind { + u8_l chan_index; + bool_l roc; + u8_l vif_index; + bool_l roc_tdls; +}; + +typedef struct phy_cfg_tag phy_cfg_tag, *Pphy_cfg_tag; + +struct phy_cfg_tag { + u32_l parameters[16]; +}; + +typedef struct me_chan_config_req me_chan_config_req, *Pme_chan_config_req; + +struct me_chan_config_req { + struct scan_chan_tag chan2G4[14]; + struct scan_chan_tag chan5G[28]; + u8_l chan2G4_cnt; + u8_l chan5G_cnt; +}; + +typedef enum apm_msg_tag { + APM_CONF_MAX_STA_CFM=7182, + APM_CONF_MAX_STA_REQ=7181, + APM_MAX=7183, + APM_START_CAC_CFM=7173, + APM_START_CAC_REQ=7172, + APM_START_CFM=7169, + APM_START_REQ=7168, + APM_STA_ADD_IND=7176, + APM_STA_CONNECT_TIMEOUT_IND=7178, + APM_STA_DEL_CFM=7180, + APM_STA_DEL_IND=7177, + APM_STA_DEL_REQ=7179, + APM_STOP_CAC_CFM=7175, + APM_STOP_CAC_REQ=7174, + APM_STOP_CFM=7171, + APM_STOP_REQ=7170 +} apm_msg_tag; + +typedef struct mm_set_channel_req mm_set_channel_req, *Pmm_set_channel_req; + +struct mm_set_channel_req { + u8_l band; + u8_l type; + u16_l prim20_freq; + u16_l center1_freq; + u16_l center2_freq; + u8_l index; + s8_l tx_power; +}; + +typedef enum sm_msg_tag { + SM_CONNECT_CFM=6145, + SM_CONNECT_IND=6146, + SM_CONNECT_REQ=6144, + SM_DISCONNECT_CFM=6148, + SM_DISCONNECT_IND=6149, + SM_DISCONNECT_REQ=6147, + SM_MAX=6151, + SM_RSP_TIMEOUT_IND=6150 +} sm_msg_tag; + +typedef struct scanu_raw_send_cfm scanu_raw_send_cfm, *Pscanu_raw_send_cfm; + +struct scanu_raw_send_cfm { + uint32_t status; +}; + +typedef struct anon_struct.conflict31 anon_struct.conflict31, *Panon_struct.conflict31; + +struct anon_struct.conflict31 { + uint32_t task; + uint32_t element; +}; + +typedef struct mm_monitor_req mm_monitor_req, *Pmm_monitor_req; + +struct mm_monitor_req { + uint32_t enable; +}; + +typedef struct apm_sta_add_ind apm_sta_add_ind, *Papm_sta_add_ind; + +struct apm_sta_add_ind { + uint32_t flags; + struct mac_addr sta_addr; + uint8_t vif_idx; + uint8_t sta_idx; + int8_t rssi; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t tsflo; + uint32_t tsfhi; + uint8_t data_rate; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; +}; + +typedef struct apm_sta_del_req apm_sta_del_req, *Papm_sta_del_req; + +struct apm_sta_del_req { + u8_l vif_idx; + u8_l sta_idx; +}; + +typedef struct me_rc_set_rate_req me_rc_set_rate_req, *Pme_rc_set_rate_req; + +struct me_rc_set_rate_req { + u8_l sta_idx; + undefined field_0x1; + u16_l fixed_rate_cfg; +}; + +typedef u16 lmac_msg_id_t; + +typedef struct mm_set_channel_cfm mm_set_channel_cfm, *Pmm_set_channel_cfm; + +struct mm_set_channel_cfm { + u8_l radio_idx; + s8_l power; +}; + +typedef struct me_config_req me_config_req, *Pme_config_req; + +struct me_config_req { + struct mac_htcapability ht_cap; + struct mac_vhtcapability vht_cap; + u16_l tx_lft; + bool_l ht_supp; + bool_l vht_supp; + bool_l ps_on; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; +}; + +typedef struct mm_add_if_req mm_add_if_req, *Pmm_add_if_req; + +struct mm_add_if_req { + u8_l type; + struct mac_addr addr; + bool_l p2p; +}; + +typedef struct mm_monitor_cfm mm_monitor_cfm, *Pmm_monitor_cfm; + +struct mm_monitor_cfm { + uint32_t status; + uint32_t enable; + uint32_t data[8]; +}; + +typedef struct lmac_msg lmac_msg, *Plmac_msg; + +typedef u16 lmac_task_id_t; + +struct lmac_msg { + lmac_msg_id_t id; + lmac_task_id_t dest_id; + lmac_task_id_t src_id; + u16 param_len; + u32[0] param; +}; + +typedef struct scanu_raw_send_req scanu_raw_send_req, *Pscanu_raw_send_req; + +struct scanu_raw_send_req { + void * pkt; + uint32_t len; +}; + +typedef struct apm_start_req apm_start_req, *Papm_start_req; + +struct apm_start_req { + struct mac_rateset basic_rates; + undefined field_0xd; + struct scan_chan_tag chan; + u32_l center_freq1; + u32_l center_freq2; + u8_l ch_width; + u8_l hidden_ssid; + undefined field_0x1e; + undefined field_0x1f; + u32_l bcn_addr; + u16_l bcn_len; + u16_l tim_oft; + u16_l bcn_int; + undefined field_0x2a; + undefined field_0x2b; + u32_l flags; + u16_l ctrl_port_ethertype; + u8_l tim_len; + u8_l vif_idx; + _Bool apm_emb_enabled; + struct mac_rateset rate_set; + uint8_t beacon_period; + uint8_t qos_supported; + struct mac_ssid ssid; + uint8_t ap_sec_type; + uint8_t phrase[64]; + undefined field_0xa7; +}; + +typedef struct apm_stop_req apm_stop_req, *Papm_stop_req; + +struct apm_stop_req { + u8_l vif_idx; +}; + +typedef struct mm_set_ps_mode_req mm_set_ps_mode_req, *Pmm_set_ps_mode_req; + +struct mm_set_ps_mode_req { + u8_l new_state; +}; + +typedef struct sm_connect_ind sm_connect_ind, *Psm_connect_ind; + +struct sm_connect_ind { + u16_l status_code; + struct mac_addr bssid; + bool_l roamed; + u8_l vif_idx; + u8_l ap_idx; + u8_l ch_idx; + bool_l qos; + u8_l acm; + u16_l assoc_req_ie_len; + u16_l assoc_rsp_ie_len; + undefined field_0x12; + undefined field_0x13; + u32_l assoc_ie_buf[200]; + u16_l aid; + u8_l band; + undefined field_0x337; + u16_l center_freq; + u8_l width; + undefined field_0x33b; + u32_l center_freq1; + u32_l center_freq2; + u32_l ac_param[4]; +}; + +typedef struct apm_sta_del_cfm apm_sta_del_cfm, *Papm_sta_del_cfm; + +struct apm_sta_del_cfm { + u8_l status; + u8_l vif_idx; + u8_l sta_idx; +}; + +typedef struct anon_struct.conflict32 anon_struct.conflict32, *Panon_struct.conflict32; + +struct anon_struct.conflict32 { + uint32_t task; + uint32_t element; + uint32_t type; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct sm_disconnect_req sm_disconnect_req, *Psm_disconnect_req; + +struct sm_disconnect_req { + u16_l reason_code; + u8_l vif_idx; + undefined field_0x3; +}; + +typedef struct anon_struct.conflict33 anon_struct.conflict33, *Panon_struct.conflict33; + +struct anon_struct.conflict33 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct sm_connect_req sm_connect_req, *Psm_connect_req; + +struct sm_connect_req { + struct mac_ssid ssid; + struct mac_addr bssid; + struct scan_chan_tag chan; + undefined field_0x2e; + undefined field_0x2f; + u32_l flags; + u16_l ctrl_port_ethertype; + u16_l ie_len; + u16_l listen_interval; + bool_l dont_wait_bcmc; + u8_l auth_type; + u8_l uapsd_queues; + u8_l vif_idx; + undefined field_0x3e; + undefined field_0x3f; + u32_l ie_buf[64]; + _Bool is_supplicant_enabled; + uint8_t phrase[64]; + uint8_t phrase_pmk[64]; + undefined field_0x1c1; + undefined field_0x1c2; + undefined field_0x1c3; +}; + +typedef struct sm_connect_cfm sm_connect_cfm, *Psm_connect_cfm; + +struct sm_connect_cfm { + u8_l status; +}; + +typedef enum cfg_msg_tag { + CFG_MAX=12290, + CFG_START_CFM=12289, + CFG_START_REQ=12288 +} cfg_msg_tag; + +typedef struct anon_struct.conflict28 anon_struct.conflict28, *Panon_struct.conflict28; + +struct anon_struct.conflict28 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef enum dbg_msg_tag { + DBG_ERROR_IND=1032, + DBG_GET_SYS_STAT_CFM=1034, + DBG_GET_SYS_STAT_REQ=1033, + DBG_MAX=1035, + DBG_MEM_READ_CFM=1025, + DBG_MEM_READ_REQ=1024, + DBG_MEM_WRITE_CFM=1027, + DBG_MEM_WRITE_REQ=1026, + DBG_SET_MOD_FILTER_CFM=1029, + DBG_SET_MOD_FILTER_REQ=1028, + DBG_SET_SEV_FILTER_CFM=1031, + DBG_SET_SEV_FILTER_REQ=1030, + DBG_SYS_STAT_TIMER=1035 +} dbg_msg_tag; + +typedef struct cfg_start_req cfg_start_req, *Pcfg_start_req; + +struct cfg_start_req { // Missing member u : anon_union_for_u at offset 0x4 [exceeds parent struct len] + uint32_t ops; +}; + +typedef struct scanu_result_ind scanu_result_ind, *Pscanu_result_ind; + +struct scanu_result_ind { + uint16_t length; + uint16_t framectrl; + uint16_t center_freq; + uint8_t band; + uint8_t sta_idx; + uint8_t inst_nbr; + uint8_t sa[6]; + undefined field_0xf; + uint32_t tsflo; + uint32_t tsfhi; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t data_rate; + uint32_t[0] payload; +}; + +typedef struct apm_start_cfm apm_start_cfm, *Papm_start_cfm; + +struct apm_start_cfm { + u8_l status; + u8_l vif_idx; + u8_l ch_idx; + u8_l bcmc_idx; +}; + +typedef struct apm_sta_del_ind apm_sta_del_ind, *Papm_sta_del_ind; + +struct apm_sta_del_ind { + uint8_t sta_idx; +}; + +typedef enum mm_msg_tag { + MM_ADD_IF_CFM=7, + MM_ADD_IF_REQ=6, + MM_BA_ADD_CFM=41, + MM_BA_ADD_REQ=40, + MM_BA_DEL_CFM=43, + MM_BA_DEL_REQ=42, + MM_BCN_CHANGE_CFM=64, + MM_BCN_CHANGE_REQ=63, + MM_BFMER_ENABLE_REQ=80, + MM_CFG_RSSI_REQ=86, + MM_CHANNEL_PRE_SWITCH_IND=69, + MM_CHANNEL_SURVEY_IND=79, + MM_CHANNEL_SWITCH_IND=68, + MM_CHAN_CTXT_ADD_CFM=52, + MM_CHAN_CTXT_ADD_REQ=51, + MM_CHAN_CTXT_DEL_CFM=54, + MM_CHAN_CTXT_DEL_REQ=53, + MM_CHAN_CTXT_LINK_CFM=56, + MM_CHAN_CTXT_LINK_REQ=55, + MM_CHAN_CTXT_SCHED_CFM=62, + MM_CHAN_CTXT_SCHED_REQ=61, + MM_CHAN_CTXT_UNLINK_CFM=58, + MM_CHAN_CTXT_UNLINK_REQ=57, + MM_CHAN_CTXT_UPDATE_CFM=60, + MM_CHAN_CTXT_UPDATE_REQ=59, + MM_CONNECTION_LOSS_IND=67, + MM_CSA_COUNTER_IND=78, + MM_CSA_FINISH_IND=88, + MM_CSA_TRAFFIC_IND=89, + MM_DENOISE_REQ=48, + MM_KEY_ADD_CFM=37, + MM_KEY_ADD_REQ=36, + MM_KEY_DEL_CFM=39, + MM_KEY_DEL_REQ=38, + MM_MAX=96, + MM_MONITOR_CFM=93, + MM_MONITOR_CHANNEL_CFM=95, + MM_MONITOR_CHANNEL_REQ=94, + MM_MONITOR_REQ=92, + MM_MU_GROUP_UPDATE_CFM=91, + MM_MU_GROUP_UPDATE_REQ=90, + MM_P2P_NOA_UPD_IND=85, + MM_P2P_VIF_PS_CHANGE_IND=77, + MM_PRIMARY_TBTT_IND=44, + MM_PS_CHANGE_IND=73, + MM_REMAIN_ON_CHANNEL_CFM=71, + MM_REMAIN_ON_CHANNEL_EXP_IND=72, + MM_REMAIN_ON_CHANNEL_REQ=70, + MM_REMOVE_IF_CFM=9, + MM_REMOVE_IF_REQ=8, + MM_RESET_CFM=1, + MM_RESET_REQ=0, + MM_RSSI_STATUS_IND=87, + MM_SECONDARY_TBTT_IND=45, + MM_SET_BASIC_RATES_CFM=23, + MM_SET_BASIC_RATES_REQ=22, + MM_SET_BEACON_INT_CFM=21, + MM_SET_BEACON_INT_REQ=20, + MM_SET_BSSID_CFM=25, + MM_SET_BSSID_REQ=24, + MM_SET_CHANNEL_CFM=17, + MM_SET_CHANNEL_REQ=16, + MM_SET_DTIM_CFM=19, + MM_SET_DTIM_REQ=18, + MM_SET_EDCA_CFM=27, + MM_SET_EDCA_REQ=26, + MM_SET_FILTER_CFM=15, + MM_SET_FILTER_REQ=14, + MM_SET_IDLE_CFM=35, + MM_SET_IDLE_REQ=34, + MM_SET_MODE_CFM=29, + MM_SET_MODE_REQ=28, + MM_SET_P2P_NOA_CFM=83, + MM_SET_P2P_NOA_REQ=81, + MM_SET_P2P_OPPPS_CFM=84, + MM_SET_P2P_OPPPS_REQ=82, + MM_SET_POWER_CFM=47, + MM_SET_POWER_REQ=46, + MM_SET_PS_MODE_CFM=50, + MM_SET_PS_MODE_REQ=49, + MM_SET_PS_OPTIONS_CFM=76, + MM_SET_PS_OPTIONS_REQ=75, + MM_SET_SLOTTIME_CFM=33, + MM_SET_SLOTTIME_REQ=32, + MM_SET_VIF_STATE_CFM=31, + MM_SET_VIF_STATE_REQ=30, + MM_START_CFM=3, + MM_START_REQ=2, + MM_STA_ADD_CFM=11, + MM_STA_ADD_REQ=10, + MM_STA_DEL_CFM=13, + MM_STA_DEL_REQ=12, + MM_TIM_UPDATE_CFM=66, + MM_TIM_UPDATE_REQ=65, + MM_TRAFFIC_REQ_IND=74, + MM_VERSION_CFM=5, + MM_VERSION_REQ=4 +} mm_msg_tag; + +typedef struct mm_monitor_channel_req mm_monitor_channel_req, *Pmm_monitor_channel_req; + +struct mm_monitor_channel_req { + uint32_t freq; + uint32_t use_40Mhz; + uint32_t higher_band; +}; + +typedef struct mm_set_denoise_req mm_set_denoise_req, *Pmm_set_denoise_req; + +struct mm_set_denoise_req { + u8_l denoise_mode; +}; + +typedef struct mm_start_req mm_start_req, *Pmm_start_req; + +struct mm_start_req { + struct phy_cfg_tag phy_cfg; + u32_l uapsd_timeout; + u16_l lp_clk_accuracy; + undefined field_0x46; + undefined field_0x47; +}; + +typedef struct apm_conf_max_sta_req apm_conf_max_sta_req, *Papm_conf_max_sta_req; + +struct apm_conf_max_sta_req { + u8_l max_sta_supported; +}; + +typedef struct sm_disconnect_ind sm_disconnect_ind, *Psm_disconnect_ind; + +struct sm_disconnect_ind { + u16_l reason_code; + u8_l vif_idx; + bool_l ft_over_ds; +}; + +typedef struct mm_remove_if_req mm_remove_if_req, *Pmm_remove_if_req; + +struct mm_remove_if_req { + u8_l inst_nbr; +}; + +typedef struct mm_version_cfm mm_version_cfm, *Pmm_version_cfm; + +struct mm_version_cfm { + u32_l version_lmac; + u32_l version_machw_1; + u32_l version_machw_2; + u32_l version_phy_1; + u32_l version_phy_2; + u32_l features; +}; + +typedef struct anon_struct.conflict62 anon_struct.conflict62, *Panon_struct.conflict62; + +struct anon_struct.conflict62 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef struct mm_add_if_cfm mm_add_if_cfm, *Pmm_add_if_cfm; + +struct mm_add_if_cfm { + u8_l status; + u8_l inst_nbr; +}; + +typedef enum tdls_msg_tag { + TDLS_CANCEL_CHAN_SWITCH_CFM=3077, + TDLS_CANCEL_CHAN_SWITCH_REQ=3076, + TDLS_CHAN_SWITCH_BASE_IND=3075, + TDLS_CHAN_SWITCH_CFM=3073, + TDLS_CHAN_SWITCH_IND=3074, + TDLS_CHAN_SWITCH_REQ=3072, + TDLS_MAX=3081, + TDLS_PEER_PS_IND=3078, + TDLS_PEER_TRAFFIC_IND_CFM=3080, + TDLS_PEER_TRAFFIC_IND_REQ=3079 +} tdls_msg_tag; + +typedef enum mesh_msg_tag { + MESH_MAX=9232, + MESH_PATH_CREATE_CFM=9225, + MESH_PATH_CREATE_REQ=9224, + MESH_PATH_UPDATE_CFM=9227, + MESH_PATH_UPDATE_IND=9230, + MESH_PATH_UPDATE_REQ=9226, + MESH_PEER_INFO_REQ=9222, + MESH_PEER_INFO_RSP=9223, + MESH_PEER_UPDATE_IND=9229, + MESH_PEER_UPDATE_NTF=9229, + MESH_PROXY_ADD_REQ=9228, + MESH_PROXY_UPDATE_IND=9231, + MESH_START_CFM=9217, + MESH_START_REQ=9216, + MESH_STOP_CFM=9219, + MESH_STOP_REQ=9218, + MESH_UPDATE_CFM=9221, + MESH_UPDATE_REQ=9220 +} mesh_msg_tag; + +typedef struct adc_ctx adc_ctx, *Padc_ctx; + +typedef struct adc_ctx adc_ctx_t; + +struct adc_ctx { + int mode; + uint32_t * channel_data; + void * adc_lli; + int lli_flag; + uint32_t chan_init_table; + uint32_t data_size; + void (* cb)(int, uint32_t *, uint32_t); +}; + + +// WARNING! conflicting data type names: /DWARF/cli.c/handle_input/anon_struct - /DWARF/reent.h/anon_struct + +typedef enum llc_instant_state { + LLC_INSTANT_ACCEPTED=1, + LLC_INSTANT_COLLISION=2, + LLC_INSTANT_IGNORED=0, + LLC_INSTANT_MIC_FAILURE=4, + LLC_INSTANT_PASSED=3, + LLC_INSTANT_REJECT=5 +} llc_instant_state; + +typedef struct llcp_pdu_handler_info.conflict llcp_pdu_handler_info.conflict, *Pllcp_pdu_handler_info.conflict; + +typedef union llcp_pdu llcp_pdu, *Pllcp_pdu; + +typedef struct llcp_con_upd_ind llcp_con_upd_ind, *Pllcp_con_upd_ind; + +typedef struct llcp_channel_map_ind llcp_channel_map_ind, *Pllcp_channel_map_ind; + +typedef struct llcp_terminate_ind llcp_terminate_ind, *Pllcp_terminate_ind; + +typedef struct llcp_enc_req llcp_enc_req, *Pllcp_enc_req; + +typedef struct llcp_enc_rsp llcp_enc_rsp, *Pllcp_enc_rsp; + +typedef struct llcp_start_enc_req llcp_start_enc_req, *Pllcp_start_enc_req; + +typedef struct llcp_start_enc_rsp llcp_start_enc_rsp, *Pllcp_start_enc_rsp; + +typedef struct llcp_unknown_rsp llcp_unknown_rsp, *Pllcp_unknown_rsp; + +typedef struct llcp_feats_req llcp_feats_req, *Pllcp_feats_req; + +typedef struct llcp_feats_rsp llcp_feats_rsp, *Pllcp_feats_rsp; + +typedef struct llcp_pause_enc_req llcp_pause_enc_req, *Pllcp_pause_enc_req; + +typedef struct llcp_pause_enc_rsp llcp_pause_enc_rsp, *Pllcp_pause_enc_rsp; + +typedef struct llcp_vers_ind llcp_vers_ind, *Pllcp_vers_ind; + +typedef struct llcp_reject_ind llcp_reject_ind, *Pllcp_reject_ind; + +typedef struct llcp_slave_feature_req llcp_slave_feature_req, *Pllcp_slave_feature_req; + +typedef struct llcp_con_param_req llcp_con_param_req, *Pllcp_con_param_req; + +typedef struct llcp_con_param_rsp llcp_con_param_rsp, *Pllcp_con_param_rsp; + +typedef struct llcp_reject_ind_ext llcp_reject_ind_ext, *Pllcp_reject_ind_ext; + +typedef struct llcp_ping_req llcp_ping_req, *Pllcp_ping_req; + +typedef struct llcp_ping_rsp llcp_ping_rsp, *Pllcp_ping_rsp; + +typedef struct llcp_length_req llcp_length_req, *Pllcp_length_req; + +typedef struct llcp_length_rsp llcp_length_rsp, *Pllcp_length_rsp; + +typedef struct sess_k_div_x sess_k_div_x, *Psess_k_div_x; + +typedef struct init_vect init_vect, *Pinit_vect; + +struct llcp_con_param_req { + uint8_t opcode; + undefined field_0x1; + uint16_t interval_min; + uint16_t interval_max; + uint16_t latency; + uint16_t timeout; + uint8_t pref_period; + undefined field_0xb; + uint16_t ref_con_event_count; + uint16_t offset0; + uint16_t offset1; + uint16_t offset2; + uint16_t offset3; + uint16_t offset4; + uint16_t offset5; +}; + +struct llcp_pause_enc_rsp { + uint8_t opcode; +}; + +struct llcp_ping_rsp { + uint8_t opcode; +}; + +struct llcp_vers_ind { + uint8_t opcode; + uint8_t vers; + uint16_t compid; + uint16_t subvers; +}; + +struct llcp_feats_req { + uint8_t opcode; + struct le_features feats; +}; + +struct llcp_start_enc_rsp { + uint8_t opcode; +}; + +struct llcp_unknown_rsp { + uint8_t opcode; + uint8_t unk_type; +}; + +struct llcp_con_upd_ind { + uint8_t opcode; + uint8_t win_size; + uint16_t win_off; + uint16_t interv; + uint16_t latency; + uint16_t timeout; + uint16_t instant; +}; + +struct init_vect { + uint8_t iv[4]; +}; + +struct sess_k_div_x { + uint8_t skdiv[8]; +}; + +struct llcp_enc_req { + uint8_t opcode; + struct rand_nb rand; + uint8_t ediv[2]; + struct sess_k_div_x skdm; + struct init_vect ivm; +}; + +struct llcp_terminate_ind { + uint8_t opcode; + uint8_t err_code; +}; + +struct llcp_length_rsp { + uint8_t opcode; + undefined field_0x1; + uint16_t max_rx_octets; + uint16_t max_rx_time; + uint16_t max_tx_octets; + uint16_t max_tx_time; +}; + +struct llcp_con_param_rsp { + uint8_t opcode; + undefined field_0x1; + uint16_t interval_min; + uint16_t interval_max; + uint16_t latency; + uint16_t timeout; + uint8_t pref_period; + undefined field_0xb; + uint16_t ref_con_event_count; + uint16_t offset0; + uint16_t offset1; + uint16_t offset2; + uint16_t offset3; + uint16_t offset4; + uint16_t offset5; +}; + +struct llcp_ping_req { + uint8_t opcode; +}; + +struct llcp_reject_ind { + uint8_t opcode; + uint8_t err_code; +}; + +struct llcp_channel_map_ind { + uint8_t opcode; + struct le_chnl_map ch_map; + uint16_t instant; +}; + +struct llcp_feats_rsp { + uint8_t opcode; + struct le_features feats; +}; + +struct llcp_pause_enc_req { + uint8_t opcode; +}; + +struct llcp_length_req { + uint8_t opcode; + undefined field_0x1; + uint16_t max_rx_octets; + uint16_t max_rx_time; + uint16_t max_tx_octets; + uint16_t max_tx_time; +}; + +struct llcp_start_enc_req { + uint8_t opcode; +}; + +struct llcp_slave_feature_req { + uint8_t opcode; + struct le_features feats; +}; + +struct llcp_enc_rsp { + uint8_t opcode; + struct sess_k_div_x skds; + struct init_vect ivs; +}; + +struct llcp_reject_ind_ext { + uint8_t opcode; + uint8_t rej_opcode; + uint8_t err_code; +}; + +union llcp_pdu { + uint8_t opcode; + struct llcp_con_upd_ind con_up_req; + struct llcp_channel_map_ind channel_map_req; + struct llcp_terminate_ind terminate_ind; + struct llcp_enc_req enc_req; + struct llcp_enc_rsp enc_rsp; + struct llcp_start_enc_req start_enc_req; + struct llcp_start_enc_rsp start_enc_rsp; + struct llcp_unknown_rsp unknown_rsp; + struct llcp_feats_req feats_req; + struct llcp_feats_rsp feats_rsp; + struct llcp_pause_enc_req pause_enc_req; + struct llcp_pause_enc_rsp pause_enc_rsp; + struct llcp_vers_ind vers_ind; + struct llcp_reject_ind reject_ind; + struct llcp_slave_feature_req slave_feature_req; + struct llcp_con_param_req con_param_req; + struct llcp_con_param_rsp con_param_rsp; + struct llcp_reject_ind_ext reject_ind_ext; + struct llcp_ping_req ping_req; + struct llcp_ping_rsp ping_rsp; + struct llcp_length_req length_req; + struct llcp_length_rsp length_rsp; +}; + +struct llcp_pdu_handler_info.conflict { + int (* handler)(uint16_t, ke_task_id_t, _Bool, union llcp_pdu *); + _Bool int_ctx_allowed; + uint8_t enc_auth; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct llcp_pdu_handler_info.conflict1 llcp_pdu_handler_info.conflict1, *Pllcp_pdu_handler_info.conflict1; + +struct llcp_pdu_handler_info.conflict1 { + int (* handler)(uint16_t, ke_task_id_t, _Bool, union llcp_pdu *); + _Bool int_ctx_allowed; + uint8_t enc_auth; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct llcp_pdu_handler_info llcp_pdu_handler_info, *Pllcp_pdu_handler_info; + +struct llcp_pdu_handler_info { + int (* handler)(uint16_t, ke_task_id_t, _Bool, union llcp_pdu *); + _Bool int_ctx_allowed; + uint8_t enc_auth; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct llcp_pdu_handler_info.conflict2 llcp_pdu_handler_info.conflict2, *Pllcp_pdu_handler_info.conflict2; + +struct llcp_pdu_handler_info.conflict2 { + int (* handler)(uint16_t, ke_task_id_t, _Bool, union llcp_pdu *); + _Bool int_ctx_allowed; + uint8_t enc_auth; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct cli_command cli_command, *Pcli_command; + +struct cli_command { + char * name; + char * help; + void (* function)(char *, int, int, char * *); +}; + +typedef struct cli_st cli_st, *Pcli_st; + +struct cli_st { + int initialized; + int echo_disabled; + struct cli_command * static_cmds; + struct cli_command * dynamic_cmds[8]; + uint num_static_cmds; + uint num_commands; + uint bp; + char inbuf[256]; + char * outbuf; + int his_idx; + int his_cur; + char history[256]; +}; + +typedef struct pmkElement_t pmkElement_t, *PpmkElement_t; + +typedef union anon_union_for_key anon_union_for_key, *Panon_union_for_key; + +union anon_union_for_key { + IEEEtypes_MacAddr_t Bssid; + char Ssid[32]; +}; + +struct pmkElement_t { + union anon_union_for_key key; + UINT8 PMK[32]; + UINT8 length; + UINT8 psk_length; + SINT8 replacementRank; +}; + +typedef struct net_device net_device, *Pnet_device; + +typedef struct bl_hw bl_hw, *Pbl_hw; + +typedef struct bl_cmd_mgr bl_cmd_mgr, *Pbl_cmd_mgr; + +typedef struct bl_cmd bl_cmd, *Pbl_cmd; + +typedef struct bl_stats bl_stats, *Pbl_stats; + +typedef struct bl_vif bl_vif, *Pbl_vif; + +typedef struct bl_sta bl_sta, *Pbl_sta; + +typedef struct bl_mod_params bl_mod_params, *Pbl_mod_params; + +typedef enum RWNX_INTERFACE_STATUS { + RWNX_INTERFACE_STATUS_DOWN=0, + RWNX_INTERFACE_STATUS_UP=1 +} RWNX_INTERFACE_STATUS; + +typedef enum bl_cmd_mgr_state { + RWNX_CMD_MGR_STATE_CRASHED=2, + RWNX_CMD_MGR_STATE_DEINIT=0, + RWNX_CMD_MGR_STATE_INITED=1 +} bl_cmd_mgr_state; + +typedef SemaphoreHandle_t os_mutex_t; + +typedef struct xSTATIC_EVENT_GROUP xSTATIC_EVENT_GROUP, *PxSTATIC_EVENT_GROUP; + +typedef struct xSTATIC_EVENT_GROUP StaticEventGroup_t; + +typedef StaticEventGroup_t os_event_t; + +typedef struct net_device_stats net_device_stats, *Pnet_device_stats; + +typedef union anon_union_for_field_13 anon_union_for_field_13, *Panon_union_for_field_13; + +typedef struct xSTATIC_LIST xSTATIC_LIST, *PxSTATIC_LIST; + +typedef struct xSTATIC_LIST StaticList_t; + +typedef struct anon_struct.conflict25 anon_struct.conflict25, *Panon_struct.conflict25; + +typedef struct anon_struct.conflict26 anon_struct.conflict26, *Panon_struct.conflict26; + +typedef struct anon_struct.conflict27 anon_struct.conflict27, *Panon_struct.conflict27; + +typedef struct xSTATIC_MINI_LIST_ITEM xSTATIC_MINI_LIST_ITEM, *PxSTATIC_MINI_LIST_ITEM; + +typedef struct xSTATIC_MINI_LIST_ITEM StaticMiniListItem_t; + +typedef struct bl_bcn bl_bcn, *Pbl_bcn; + +struct bl_bcn { + u8 * head; + u8 * tail; + u8 * ies; + size_t head_len; + size_t tail_len; + size_t ies_len; + size_t tim_len; + size_t len; + u8 dtim; + undefined field_0x21; + undefined field_0x22; + undefined field_0x23; +}; + +struct bl_mod_params { + _Bool ht_on; + _Bool vht_on; + undefined field_0x2; + undefined field_0x3; + int mcs_map; + _Bool ldpc_on; + _Bool vht_stbc; + undefined field_0xa; + undefined field_0xb; + int phy_cfg; + int uapsd_timeout; + _Bool ap_uapsd_on; + _Bool sgi; + _Bool sgi80; + _Bool use_2040; + _Bool use_80; + _Bool custregd; + undefined field_0x1a; + undefined field_0x1b; + int nss; + _Bool bfmee; + _Bool bfmer; + _Bool mesh; + _Bool murx; + _Bool mutx; + _Bool mutx_on; + undefined field_0x26; + undefined field_0x27; + uint roc_dur_max; + int listen_itv; + _Bool listen_bcmc; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + int lp_clk_ppm; + _Bool ps_on; + undefined field_0x39; + undefined field_0x3a; + undefined field_0x3b; + int tx_lft; + int amsdu_maxnb; + int uapsd_queues; + _Bool tdls; + undefined field_0x49; + undefined field_0x4a; + undefined field_0x4b; +}; + +struct anon_struct.conflict25 { + struct bl_sta * ap; + struct bl_sta * tdls_sta; +}; + +struct anon_struct.conflict26 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +struct anon_struct.conflict27 { + struct bl_vif * master; + struct bl_sta * sta_4a; +}; + +union anon_union_for_field_13 { + struct anon_struct.conflict25 sta; + struct anon_struct.conflict26 ap; + struct anon_struct.conflict27 ap_vlan; +}; + +struct net_device_stats { + ulong rx_packets; + ulong tx_packets; + ulong rx_bytes; + ulong tx_bytes; + ulong rx_errors; + ulong tx_errors; + ulong rx_dropped; + ulong tx_dropped; + ulong multicast; + ulong collisions; + ulong rx_length_errors; + ulong rx_over_errors; + ulong rx_crc_errors; + ulong rx_frame_errors; + ulong rx_fifo_errors; + ulong rx_missed_errors; + ulong tx_aborted_errors; + ulong tx_carrier_errors; + ulong tx_fifo_errors; + ulong tx_heartbeat_errors; + ulong tx_window_errors; + ulong rx_compressed; + ulong tx_compressed; +}; + +struct bl_vif { + struct list_head list; + struct netif * dev; + struct bl_hw * bl_hw; + struct net_device_stats net_stats; + u8 drv_vif_index; + u8 vif_index; + u8 ch_index; + _Bool up; + _Bool use_4addr; + _Bool is_resending; + _Bool user_mpm; + _Bool roc_tdls; + u8 tdls_status; + undefined field_0x75; + undefined field_0x76; + undefined field_0x77; + union anon_union_for_field_13 field_13; +}; + +struct net_device { + struct bl_hw * bl_hw; +}; + +struct bl_stats { + int cfm_balance; + ulong last_rx; + ulong last_tx; + int ampdus_tx[64]; + int ampdus_rx[64]; + int ampdus_rx_map[4]; + int ampdus_rx_miss; + int amsdus_rx[64]; +}; + +struct xSTATIC_MINI_LIST_ITEM { + TickType_t xDummy2; + void * pvDummy3[2]; +}; + +struct xSTATIC_LIST { + UBaseType_t uxDummy2; + void * pvDummy3; + StaticMiniListItem_t xDummy4; +}; + +struct xSTATIC_EVENT_GROUP { + TickType_t xDummy1; + StaticList_t xDummy2; + UBaseType_t uxDummy3; + uint8_t ucDummy4; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +struct bl_cmd { + struct list_head list; + lmac_msg_id_t id; + lmac_msg_id_t reqid; + struct lmac_msg * a2e_msg; + char * e2a_msg; + u32 tkn; + u16 flags; + undefined field_0x1a; + undefined field_0x1b; + os_event_t complete; + u32 result; +}; + +struct bl_cmd_mgr { + enum bl_cmd_mgr_state state; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + u32 next_tkn; + u32 queue_sz; + u32 max_queue_sz; + struct list_head cmds; + os_mutex_t lock; + int (* queue)(struct bl_cmd_mgr *, struct bl_cmd *); + int (* llind)(struct bl_cmd_mgr *, struct bl_cmd *); + int (* msgind)(struct bl_cmd_mgr *, struct ipc_e2a_msg *, int (* )(struct bl_hw *, struct bl_cmd *, struct ipc_e2a_msg *)); + void (* print)(struct bl_cmd_mgr *); + void (* drain)(struct bl_cmd_mgr *); +}; + +struct bl_sta { + struct mac_addr sta_addr; + u16 aid; + u8 is_used; + u8 sta_idx; + u8 vif_idx; + u8 vlan_idx; + int8_t rssi; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t tsflo; + uint32_t tsfhi; + uint8_t data_rate; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; +}; + +struct bl_hw { + int is_up; + struct bl_cmd_mgr cmd_mgr; + struct ipc_host_env_tag * ipc_env; + struct bl_stats stats; + struct list_head vifs; + struct bl_vif vif_table[12]; + struct bl_sta sta_table[12]; + ulong drv_flags; + struct mm_version_cfm version_cfm; + struct bl_mod_params * mod_params; + enum wiphy_flags flags; + struct ieee80211_sta_ht_cap ht_cap; + u8 vif_started; + undefined field_0xe1b; + int vif_index_sta; + int vif_index_ap; + int sta_idx; + int ap_bcmc_idx; + struct phy_cfg_tag phy_config; + enum RWNX_INTERFACE_STATUS status; + undefined field_0xe6d; + undefined field_0xe6e; + undefined field_0xe6f; +}; + +typedef struct bl_wifi_ap_info bl_wifi_ap_info, *Pbl_wifi_ap_info; + +typedef struct bl_wifi_ap_info bl_wifi_ap_info_t; + +struct bl_wifi_ap_info { + uint8_t ssid[33]; + uint8_t psk[65]; + uint8_t chan; +}; + +typedef enum ChanBand_e { + Band_2_4_GHz=0, + Band_4_GHz=2, + Band_5_GHz=1 +} ChanBand_e; + +typedef enum IEEEtypes_ElementId_e { + ELEM_ID_2040_BSS_COEXISTENCE=72, + ELEM_ID_2040_BSS_INTOL_CHRPT=73, + ELEM_ID_AID=-59, + ELEM_ID_ANTENNA_INFO=64, + ELEM_ID_AP_CHANNEL_REPORT=51, + ELEM_ID_BSS_ACCESS_DELAY=63, + ELEM_ID_BSS_AC_ACCESS_DELAY=68, + ELEM_ID_BSS_AVAIL_ADM_CAP=67, + ELEM_ID_BSS_LOAD=11, + ELEM_ID_BSS_MAX_IDLE_PERIOD=90, + ELEM_ID_CF_PARAM_SET=4, + ELEM_ID_CHALLENGE_TEXT=16, + ELEM_ID_CHANNEL_SWITCH_ANN=37, + ELEM_ID_CHANNEL_USAGE=97, + ELEM_ID_COLLOC_INTF_REPORT=96, + ELEM_ID_COUNTRY=7, + ELEM_ID_DIAG_REPORT=81, + ELEM_ID_DIAG_REQUEST=80, + ELEM_ID_DMS_REQUEST=99, + ELEM_ID_DMS_RESPONSE=100, + ELEM_ID_DSE_REGISTERED_LOC=58, + ELEM_ID_DS_PARAM_SET=3, + ELEM_ID_EDCA_PARAM_SET=12, + ELEM_ID_ERP_INFO=42, + ELEM_ID_EVENT_REPORT=79, + ELEM_ID_EVENT_REQUEST=78, + ELEM_ID_EXTENSION=-1, + ELEM_ID_EXT_ASSOC_DELAY_INFO=1, + ELEM_ID_EXT_CAPABILITIES=127, + ELEM_ID_EXT_CHAN_SWITCH_ANN=60, + ELEM_ID_EXT_ESTIMATED_SERVICE_PARAMS=11, + ELEM_ID_EXT_EXTENDED_REQUEST=10, + ELEM_ID_EXT_FILS_HLP_CONTAINER=5, + ELEM_ID_EXT_FILS_IP_ADDR_ASSIGN=6, + ELEM_ID_EXT_FILS_KEY_CONFIRM=3, + ELEM_ID_EXT_FILS_NONCE=13, + ELEM_ID_EXT_FILS_PUBLIC_KEY=12, + ELEM_ID_EXT_FILS_REQ_PARAMS=2, + ELEM_ID_EXT_FILS_SESSION=4, + ELEM_ID_EXT_FILS_WRAPPED_DATA=8, + ELEM_ID_EXT_FTM_SYNC_INFO=9, + ELEM_ID_EXT_FUTURE_CHANNEL_GUIDANCE=14, + ELEM_ID_EXT_HE_CAPABILITIES=35, + ELEM_ID_EXT_HE_OPERATION=36, + ELEM_ID_EXT_KEY_DELIVERY=7, + ELEM_ID_EXT_OWE_DH_PARAM=32, + ELEM_ID_EXT_PASSWORD_IDENTIFIER=33, + ELEM_ID_EXT_SUPPORTED_RATES=50, + ELEM_ID_FAST_BSS_TRANS=55, + ELEM_ID_FH_PARAM_SET=2, + ELEM_ID_FMS_DESCRIPTOR=86, + ELEM_ID_FMS_REQUEST=87, + ELEM_ID_FMS_RESPONSE=88, + ELEM_ID_HOP_PARAM=8, + ELEM_ID_HOP_TABLE=9, + ELEM_ID_HT_CAPABILITY=45, + ELEM_ID_HT_INFORMATION=61, + ELEM_ID_IBSS_DFS=41, + ELEM_ID_IBSS_PARAM_SET=6, + ELEM_ID_LINK_ID=101, + ELEM_ID_LOCATION_PARAM=82, + ELEM_ID_MANAGEMENT_MIC=76, + ELEM_ID_MBSSID_INDEX=85, + ELEM_ID_MEASUREMENT_REQ=38, + ELEM_ID_MEASUREMENT_RPT=39, + ELEM_ID_MEAS_PILOT_TX_INFO=66, + ELEM_ID_MOBILITY_DOMAIN=54, + ELEM_ID_MULTI_BSSID=71, + ELEM_ID_NEIGHBOR_REPORT=52, + ELEM_ID_NONTRANS_BSSID_CAP=83, + ELEM_ID_OBSS_SCAN_PARAM=74, + ELEM_ID_POWER_CAPABILITY=33, + ELEM_ID_POWER_CONSTRAINT=32, + ELEM_ID_PTI_CONTROL=105, + ELEM_ID_PU_BUFFER_STATUS=106, + ELEM_ID_QOS_CAPABILITY=46, + ELEM_ID_QOS_TRAFFIC_CAP=89, + ELEM_ID_QUIET=40, + ELEM_ID_RCPI=53, + ELEM_ID_REQUEST=10, + ELEM_ID_RIC_DATA=57, + ELEM_ID_RIC_DESCRIPTOR=75, + ELEM_ID_RRM_ENABLED_CAP=70, + ELEM_ID_RSN=48, + ELEM_ID_RSNI=65, + ELEM_ID_SCHEDULE=15, + ELEM_ID_SECONDARY_CHAN_OFFSET=62, + ELEM_ID_SSID=0, + ELEM_ID_SSID_LIST=84, + ELEM_ID_SUPPORTED_CHANNELS=36, + ELEM_ID_SUPPORTED_RATES=1, + ELEM_ID_SUPPORTED_REGCLASS=59, + ELEM_ID_TCLAS=14, + ELEM_ID_TCLAS_PROCESS=44, + ELEM_ID_TDLS_CS_TIMING=104, + ELEM_ID_TFS_REQUEST=91, + ELEM_ID_TFS_RESPONSE=92, + ELEM_ID_TIM=5, + ELEM_ID_TIMEOUT_INTERVAL=56, + ELEM_ID_TIME_ZONE=98, + ELEM_ID_TIM_BCAST_REQUEST=94, + ELEM_ID_TIM_BCAST_RESPONSE=95, + ELEM_ID_TPC_REPORT=35, + ELEM_ID_TPC_REQUEST=34, + ELEM_ID_TSPEC=13, + ELEM_ID_TS_DELAY=43, + ELEM_ID_VENDOR_SPECIFIC=-35, + ELEM_ID_VHT_CAPABILITIES=-65, + ELEM_ID_VHT_OPERATION=-64, + ELEM_ID_VHT_OP_MODE_NOTIFICATION=-57, + ELEM_ID_WAKEUP_SCHEDULE=102, + ELEM_ID_WAPI=68, + ELEM_ID_WIDE_BAND_CHAN_SW=-63, + ELEM_ID_WNM_SLEEP_MODE=93, + SUBELEM_ID_GTK=2, + SUBELEM_ID_IGTK=4, + SUBELEM_ID_PMK_R0_KEY_HOLDER_ID=3, + SUBELEM_ID_PMK_R1_KEY_HOLDER_ID=1, + SUBELEM_ID_REPORTED_FRAME_BODY=1, + SUBELEM_ID_REPORTING_DETAIL=2 +} IEEEtypes_ElementId_e; + +typedef enum Chan2Offset_e { + SECONDARY_CHAN_ABOVE=1, + SECONDARY_CHAN_BELOW=3, + SECONDARY_CHAN_NONE=0 +} Chan2Offset_e; + +typedef enum IEEEtypes_8021x_CodeType_e { + IEEE_8021X_CODE_TYPE_FAILURE=4, + IEEE_8021X_CODE_TYPE_REQUEST=1, + IEEE_8021X_CODE_TYPE_RESPONSE=2, + IEEE_8021X_CODE_TYPE_SUCCESS=3 +} IEEEtypes_8021x_CodeType_e; + +typedef struct IEEEtypes_WPAElement_t IEEEtypes_WPAElement_t, *PIEEEtypes_WPAElement_t; + +struct IEEEtypes_WPAElement_t { + enum IEEEtypes_ElementId_e ElementId; + IEEEtypes_Len_t Len; + UINT8 OuiType[4]; + UINT16 Ver; + UINT8 GrpKeyCipher[4]; + UINT16 PwsKeyCnt; + UINT8 PwsKeyCipherList[4]; + UINT16 AuthKeyCnt; + UINT8 AuthKeyList[4]; +}; + +typedef enum IEEEtypes_KDEDataType_e { + KDE_DATA_TYPE_ERROR=8, + KDE_DATA_TYPE_GTK=1, + KDE_DATA_TYPE_IGTK=9, + KDE_DATA_TYPE_LIFETIME=7, + KDE_DATA_TYPE_MACADDR=3, + KDE_DATA_TYPE_NONCE=6, + KDE_DATA_TYPE_PMKID=4, + KDE_DATA_TYPE_RESERVED=0, + KDE_DATA_TYPE_RESERVED2=2, + KDE_DATA_TYPE_SMK=5 +} IEEEtypes_KDEDataType_e; + +typedef struct IEEEtypes_RSNCapability_t IEEEtypes_RSNCapability_t, *PIEEEtypes_RSNCapability_t; + +struct IEEEtypes_RSNCapability_t { + UINT8 PreAuth:1; + UINT8 NoPairwise:1; + UINT8 PtksaReplayCtr:2; + UINT8 GtksaReplayCtr:2; + UINT8 MFPR:1; + UINT8 MFPC:1; + UINT8 Reserved_8:1; + UINT8 PeerkeyEnabled:1; + UINT8 SppAmsduCap:1; + UINT8 SppAmsduReq:1; + UINT8 PBAC:1; + UINT8 Reserved_13_15:3; +}; + +typedef struct BandConfig_t BandConfig_t, *PBandConfig_t; + +typedef enum ChanWidth_e { + ChanWidth_10_MHz=1, + ChanWidth_20_MHz=0, + ChanWidth_40_MHz=2, + ChanWidth_80_MHz=3 +} ChanWidth_e; + +typedef enum ScanMode_e { + ACS_MODE=1, + MANUAL_MODE=0 +} ScanMode_e; + +struct BandConfig_t { + enum ChanBand_e chanBand:2; + enum ChanWidth_e chanWidth:2; + enum Chan2Offset_e chan2Offset:2; + enum ScanMode_e scanMode:2; +}; + +typedef struct ether_hdr_t ether_hdr_t, *Pether_hdr_t; + +struct ether_hdr_t { + IEEEtypes_MacAddr_t da; + IEEEtypes_MacAddr_t sa; + UINT16 type; +}; + +typedef struct IEEEtypes_SsIdElement_t IEEEtypes_SsIdElement_t, *PIEEEtypes_SsIdElement_t; + +struct IEEEtypes_SsIdElement_t { + enum IEEEtypes_ElementId_e ElementId; + IEEEtypes_Len_t Len; + IEEEtypes_SsId_t SsId; +}; + +typedef enum IEEEtypes_8021x_PacketType_e { + IEEE_8021X_PACKET_TYPE_ASF_ALERT=4, + IEEE_8021X_PACKET_TYPE_EAPOL_KEY=3, + IEEE_8021X_PACKET_TYPE_EAPOL_LOGOFF=2, + IEEE_8021X_PACKET_TYPE_EAPOL_START=1, + IEEE_8021X_PACKET_TYPE_EAP_PACKET=0 +} IEEEtypes_8021x_PacketType_e; + +typedef struct IEEEtypes_InfoElementHdr_t IEEEtypes_InfoElementHdr_t, *PIEEEtypes_InfoElementHdr_t; + +struct IEEEtypes_InfoElementHdr_t { + enum IEEEtypes_ElementId_e ElementId; + IEEEtypes_Len_t Len; +}; + +typedef struct IEEEtypes_RSNElement_t IEEEtypes_RSNElement_t, *PIEEEtypes_RSNElement_t; + +struct IEEEtypes_RSNElement_t { + enum IEEEtypes_ElementId_e ElementId; + IEEEtypes_Len_t Len; + UINT16 Ver; + UINT8 GrpKeyCipher[4]; + UINT16 PwsKeyCnt; + UINT8 PwsKeyCipherList[4]; + UINT16 AuthKeyCnt; + UINT8 AuthKeyList[4]; + struct IEEEtypes_RSNCapability_t RsnCap; + UINT16 PMKIDCnt; + UINT8 PMKIDList[16]; + UINT8 GrpMgmtCipher[4]; +}; + +typedef struct ChanBandInfo_t ChanBandInfo_t, *PChanBandInfo_t; + +struct ChanBandInfo_t { + struct BandConfig_t bandConfig; + UINT8 chanNum; +}; + +typedef struct dns_ans_hdr dns_ans_hdr, *Pdns_ans_hdr; + +struct dns_ans_hdr { + uint16_t id; + uint16_t flag; + uint16_t numquestions; + uint16_t numanswers; + uint16_t numauthrr; + uint16_t numextrarr; +}; + +typedef struct dns_server_ctx dns_server_ctx, *Pdns_server_ctx; + +typedef struct udp_pcb udp_pcb, *Pudp_pcb; + +struct dns_server_ctx { + uint8_t name[256]; + uint16_t txid; + uint16_t nquestions; + uint16_t nanswers; + undefined field_0x106; + undefined field_0x107; + struct udp_pcb * upcb1; + ip_addr_t * addr1; + u16_t port1; + undefined field_0x112; + undefined field_0x113; +}; + +struct udp_pcb { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct udp_pcb * next; + u8_t flags; + undefined field_0x11; + u16_t local_port; + u16_t remote_port; + undefined field_0x16; + undefined field_0x17; + ip4_addr_t mcast_ip4; + u8_t mcast_ifindex; + u8_t mcast_ttl; + undefined field_0x1e; + undefined field_0x1f; + void (* recv)(void *, struct udp_pcb *, struct pbuf *, ip_addr_t *, u16_t); + void * recv_arg; +}; + +typedef struct dns_table_entry dns_table_entry, *Pdns_table_entry; + +struct dns_table_entry { + uint16_t txid; + uint16_t flags; + uint16_t numque; + uint16_t ansrrs; + uint16_t autrrs; + uint16_t addrrs; + uint16_t type; + uint16_t class; + uint16_t poiname; + uint16_t anstype; + uint16_t anstypee; + uint16_t datalen; + uint32_t anstime; + uint32_t adress; +}; + +typedef struct dns_ans_ans dns_ans_ans, *Pdns_ans_ans; + +struct dns_ans_ans { + uint16_t typ; + uint16_t cls; + uint16_t point; + uint16_t antyp; + uint16_t antypp; + uint16_t len; + uint32_t time; + uint32_t addr; +}; + +typedef struct _bl_wifi_env _bl_wifi_env, *P_bl_wifi_env; + +struct _bl_wifi_env { + uint8_t sta_mac_addr_board[6]; + uint8_t sta_mac_addr_usr[6]; + uint8_t ap_mac_addr_board[6]; + uint8_t ap_mac_addr_usr[6]; + uint8_t country_code; + bl_wifi_ap_info_t ap_info; + uint8_t ap_info_en; + bl_wifi_ap_info_t sta_info; + uint8_t sta_info_en; +}; + +typedef struct _bl_wifi_env bl_wifi_env_t; + +typedef struct tsen_reload_data tsen_reload_data, *Ptsen_reload_data; + +typedef struct tsen_reload_data tsen_reload_data_t; + +typedef struct xSTATIC_TIMER xSTATIC_TIMER, *PxSTATIC_TIMER; + +typedef struct xSTATIC_TIMER StaticTimer_t; + +typedef StaticTimer_t os_timer_t; + +struct xSTATIC_TIMER { + void * pvDummy1; + StaticListItem_t xDummy2; + TickType_t xDummy3; + void * pvDummy5; + void (* pvDummy6)(void *); + UBaseType_t uxDummy7; + uint8_t ucDummy8; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; +}; + +struct tsen_reload_data { + char name[32]; + os_timer_t timer; +}; + +typedef struct connectedIPNoData connectedIPNoData, *PconnectedIPNoData; + +typedef struct connectedIPNoData connectedIPNoData_t; + +struct connectedIPNoData { + char name[32]; + os_timer_t timer; +}; + +typedef struct disconnectData disconnectData, *PdisconnectData; + +typedef struct wifi_mgmr_profile_msg wifi_mgmr_profile_msg, *Pwifi_mgmr_profile_msg; + +typedef struct wifi_mgmr_profile_msg wifi_mgmr_profile_msg_t; + +struct wifi_mgmr_profile_msg { + char ssid[32]; + char ssid_tail[1]; + uint32_t ssid_len; + char psk[64]; + char psk_tail[1]; + char pmk[64]; + char pmk_tail[1]; + uint32_t psk_len; + uint32_t pmk_len; + uint8_t mac[6]; + uint8_t band; + uint16_t freq; + uint8_t dhcp_use; +}; + +struct disconnectData { + char name[32]; + os_timer_t timer; + uint8_t timer_started; + wifi_mgmr_profile_msg_t profile_msg; + undefined field_0x106; + undefined field_0x107; +}; + +typedef struct disconnectData disconnectData_t; + +typedef struct cJSON_Hooks cJSON_Hooks, *PcJSON_Hooks; + +struct cJSON_Hooks { + void * (* malloc_fn)(size_t); + void (* free_fn)(void *); +}; + +typedef struct cJSON cJSON, *PcJSON; + +struct cJSON { + struct cJSON * next; + struct cJSON * prev; + struct cJSON * child; + int type; + char * valuestring; + int valueint; + double valuedouble; + char * string; + undefined field_0x24; + undefined field_0x25; + undefined field_0x26; + undefined field_0x27; +}; + +typedef struct printbuffer printbuffer, *Pprintbuffer; + +struct printbuffer { + char * buffer; + int length; + int offset; +}; + +typedef struct bam_env_tag bam_env_tag, *Pbam_env_tag; + +typedef struct bam_baw bam_baw, *Pbam_baw; + +struct bam_baw { + uint (* idx_compute)(struct bam_baw *, uint); + uint16_t fsn; + uint8_t states[64]; + uint8_t fsn_idx; + uint8_t buf_size; + uint8_t mask; + undefined field_0x49; + undefined field_0x4a; + undefined field_0x4b; +}; + +struct bam_env_tag { + uint32_t pkt_cnt; + uint32_t last_activity_time; + uint16_t ssn; + uint16_t ba_timeout; + uint8_t sta_idx; + uint8_t dev_type; + uint8_t ba_policy; + uint8_t buffer_size; + uint8_t tid; + uint8_t dialog_token; + uint8_t amsdu; + uint8_t delba_count; + struct bam_baw baw; +}; + +typedef enum HCI_MSG_DEST_LL { + BLE_CTRL=3, + BLE_MNG=2, + BT_BCST=7, + BT_CTRL_BD_ADDR=6, + BT_CTRL_CONHDL=5, + BT_MNG=4, + CTRL=1, + DBG=8, + LL_UNDEF=9, + MNG=0 +} HCI_MSG_DEST_LL; + +typedef struct hci_evt_desc_tag hci_evt_desc_tag, *Phci_evt_desc_tag; + +struct hci_evt_desc_tag { + uint8_t code; + uint8_t dest_field; + uint8_t special_pack; + undefined field_0x3; + void * par_fmt; +}; + +typedef struct hci_cmd_desc_tab_ref hci_cmd_desc_tab_ref, *Phci_cmd_desc_tab_ref; + +typedef struct hci_cmd_desc_tag hci_cmd_desc_tag, *Phci_cmd_desc_tag; + +struct hci_cmd_desc_tab_ref { + uint8_t ogf; + undefined field_0x1; + uint16_t nb_cmds; + struct hci_cmd_desc_tag * cmd_desc_tab; +}; + +struct hci_cmd_desc_tag { + uint16_t opcode; + uint8_t dest_field; + uint8_t par_size_max; + void * par_fmt; + void * ret_par_fmt; +}; + +typedef enum HCI_MSG_DEST_HL { + HL_AM0=3, + HL_CTRL=1, + HL_DATA=2, + HL_MNG=0, + HL_UNDEF=4 +} HCI_MSG_DEST_HL; + +typedef enum HCI_PACK_STATUS { + HCI_PACK_ERROR=4, + HCI_PACK_IN_BUF_OVFLW=1, + HCI_PACK_OK=0, + HCI_PACK_OUT_BUF_OVFLW=2, + HCI_PACK_WRONG_FORMAT=3 +} HCI_PACK_STATUS; + +typedef struct hci_env_tag hci_env_tag, *Phci_env_tag; + +struct hci_env_tag { + struct evt_mask evt_msk; + struct evt_mask evt_msk_page_2; +}; + +typedef uintptr_t mem_ptr_t; + +typedef int32_t s32_t.conflict; + +typedef struct me_set_ps_disable_req me_set_ps_disable_req, *Pme_set_ps_disable_req; + +struct me_set_ps_disable_req { + _Bool ps_disable; + uint8_t vif_idx; +}; + +typedef struct me_rc_stats_cfm me_rc_stats_cfm, *Pme_rc_stats_cfm; + +struct me_rc_stats_cfm { + uint8_t sta_idx; + undefined field_0x1; + uint16_t no_samples; + uint16_t ampdu_len; + uint16_t ampdu_packets; + uint32_t avg_ampdu_len; + uint8_t sw_retry_step; + uint8_t sample_wait; + undefined field_0xe; + undefined field_0xf; + struct step retry[4]; + struct rc_rate_stats rate_stats[10]; + uint32_t tp[10]; +}; + +typedef struct me_set_control_port_req me_set_control_port_req, *Pme_set_control_port_req; + +struct me_set_control_port_req { + uint8_t sta_idx; + _Bool control_port_open; +}; + +typedef struct me_sta_del_req me_sta_del_req, *Pme_sta_del_req; + +struct me_sta_del_req { + uint8_t sta_idx; + _Bool tdls_sta; +}; + +typedef struct me_traffic_ind_req me_traffic_ind_req, *Pme_traffic_ind_req; + +struct me_traffic_ind_req { + uint8_t sta_idx; + uint8_t tx_avail; + _Bool uapsd; +}; + +typedef struct me_set_active_req me_set_active_req, *Pme_set_active_req; + +struct me_set_active_req { + _Bool active; + uint8_t vif_idx; +}; + +typedef struct me_sta_add_cfm me_sta_add_cfm, *Pme_sta_add_cfm; + +struct me_sta_add_cfm { + uint8_t sta_idx; + uint8_t status; + uint8_t pm_state; +}; + +typedef struct me_tkip_mic_failure_ind me_tkip_mic_failure_ind, *Pme_tkip_mic_failure_ind; + +struct me_tkip_mic_failure_ind { + struct mac_addr.conflict addr; + undefined field_0x6; + undefined field_0x7; + uint64_t tsc; + _Bool ga; + uint8_t keyid; + uint8_t vif_idx; + undefined field_0x13; + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct me_rc_stats_req me_rc_stats_req, *Pme_rc_stats_req; + +struct me_rc_stats_req { + uint8_t sta_idx; +}; + +typedef struct me_sta_add_req me_sta_add_req, *Pme_sta_add_req; + +typedef struct mac_addr.conflict73 mac_addr.conflict73, *Pmac_addr.conflict73; + +struct mac_addr.conflict73 { + uint16_t array[3]; +}; + +struct me_sta_add_req { + struct mac_addr.conflict73 mac_addr; + struct mac_rateset rate_set; + undefined field_0x13; + struct mac_htcapability ht_cap; + struct mac_vhtcapability vht_cap; + uint32_t flags; + uint16_t aid; + uint8_t uapsd_queues; + uint8_t max_sp_len; + uint8_t opmode; + uint8_t vif_idx; + _Bool tdls_sta; + undefined field_0x4b; + uint32_t tsflo; + uint32_t tsfhi; + int8_t rssi; + uint8_t data_rate; + undefined field_0x56; + undefined field_0x57; +}; + +typedef enum tcp_state { + CLOSED=0, + CLOSE_WAIT=7, + CLOSING=8, + ESTABLISHED=4, + FIN_WAIT_1=5, + FIN_WAIT_2=6, + LAST_ACK=9, + LISTEN=1, + SYN_RCVD=3, + SYN_SENT=2, + TIME_WAIT=10 +} tcp_state; + +typedef u16_t tcpwnd_size_t; + +typedef struct bt_att_hdr bt_att_hdr, *Pbt_att_hdr; + +struct bt_att_hdr { + u8_t code; +}; + +typedef struct bt_att_exchange_mtu_req bt_att_exchange_mtu_req, *Pbt_att_exchange_mtu_req; + +struct bt_att_exchange_mtu_req { + u16_t mtu; +}; + +typedef struct bt_att_error_rsp bt_att_error_rsp, *Pbt_att_error_rsp; + +struct bt_att_error_rsp { + u8_t request; + u16_t handle; + u8_t error; +}; + +typedef struct bt_att_signed_write_cmd bt_att_signed_write_cmd, *Pbt_att_signed_write_cmd; + +struct bt_att_signed_write_cmd { + u16_t handle; + u8_t[0] value; +}; + +typedef struct bt_att_find_info_req bt_att_find_info_req, *Pbt_att_find_info_req; + +struct bt_att_find_info_req { + u16_t start_handle; + u16_t end_handle; +}; + +typedef struct bt_att_prepare_write_req bt_att_prepare_write_req, *Pbt_att_prepare_write_req; + +struct bt_att_prepare_write_req { + u16_t handle; + u16_t offset; + u8_t[0] value; +}; + +typedef struct bt_att_read_req bt_att_read_req, *Pbt_att_read_req; + +struct bt_att_read_req { + u16_t handle; +}; + +typedef struct bt_att_write_req bt_att_write_req, *Pbt_att_write_req; + +struct bt_att_write_req { + u16_t handle; + u8_t[0] value; +}; + +typedef struct bt_att_read_group_req bt_att_read_group_req, *Pbt_att_read_group_req; + +struct bt_att_read_group_req { + u16_t start_handle; + u16_t end_handle; + u8_t[0] uuid; +}; + +typedef struct bt_att_write_cmd bt_att_write_cmd, *Pbt_att_write_cmd; + +struct bt_att_write_cmd { + u16_t handle; + u8_t[0] value; +}; + +typedef struct bt_att_read_blob_req bt_att_read_blob_req, *Pbt_att_read_blob_req; + +struct bt_att_read_blob_req { + u16_t handle; + u16_t offset; +}; + +typedef struct bt_att_find_type_rsp bt_att_find_type_rsp, *Pbt_att_find_type_rsp; + +struct bt_att_find_type_rsp { // Missing member list : bt_att_handle_group[1] at offset 0x0 [Unsupported interior flex array: bt_att_handle_group[1]] +}; + +typedef struct bt_att_notify bt_att_notify, *Pbt_att_notify; + +struct bt_att_notify { + u16_t handle; + u8_t[0] value; +}; + +typedef struct bt_att_exchange_mtu_rsp bt_att_exchange_mtu_rsp, *Pbt_att_exchange_mtu_rsp; + +struct bt_att_exchange_mtu_rsp { + u16_t mtu; +}; + +typedef struct bt_att_read_type_req bt_att_read_type_req, *Pbt_att_read_type_req; + +struct bt_att_read_type_req { + u16_t start_handle; + u16_t end_handle; + u8_t[0] uuid; +}; + +typedef struct bt_att_find_type_req bt_att_find_type_req, *Pbt_att_find_type_req; + +struct bt_att_find_type_req { + u16_t start_handle; + u16_t end_handle; + u16_t type; + u8_t[0] value; +}; + +typedef struct bt_att_exec_write_req bt_att_exec_write_req, *Pbt_att_exec_write_req; + +struct bt_att_exec_write_req { + u8_t flags; +}; + +typedef struct bt_att_indicate bt_att_indicate, *Pbt_att_indicate; + +struct bt_att_indicate { + u16_t handle; + u8_t[0] value; +}; + +typedef struct wifi_mgmr wifi_mgmr, *Pwifi_mgmr; + +typedef struct wifi_mgmr wifi_mgmr_t; + +typedef struct wlan_netif wlan_netif, *Pwlan_netif; + +typedef enum WIFI_MGMR_CONNECTION_STATUS { + WIFI_MGMR_CONNECTION_STATUS_CONNECTED_IP_NO=3, + WIFI_MGMR_CONNECTION_STATUS_CONNECTED_IP_YES=2, + WIFI_MGMR_CONNECTION_STATUS_CONNECTING=1, + WIFI_MGMR_CONNECTION_STATUS_DISCONNECTED=4, + WIFI_MGMR_CONNECTION_STATUS_IDLE=0 +} WIFI_MGMR_CONNECTION_STATUS; + +typedef enum WIFI_MGMR_CONNECTION_STATUS WIFI_MGMR_CONNECTION_STATUS_T; + +typedef struct wifi_mgmr_profile wifi_mgmr_profile, *Pwifi_mgmr_profile; + +typedef struct wifi_mgmr_profile wifi_mgmr_profile_t; + +typedef struct wifi_mgmr_scan_item wifi_mgmr_scan_item, *Pwifi_mgmr_scan_item; + +typedef struct wifi_mgmr_scan_item wifi_mgmr_scan_item_t; + +typedef struct xSTATIC_STREAM_BUFFER xSTATIC_STREAM_BUFFER, *PxSTATIC_STREAM_BUFFER; + +typedef struct xSTATIC_STREAM_BUFFER StaticStreamBuffer_t; + +typedef StaticStreamBuffer_t StaticMessageBuffer_t; + +typedef StaticMessageBuffer_t os_messagequeue_t; + +typedef struct stateMachine stateMachine, *PstateMachine; + +typedef struct wifi_mgmr_connect_ind_stat_info wifi_mgmr_connect_ind_stat_info, *Pwifi_mgmr_connect_ind_stat_info; + +typedef struct wifi_mgmr_connect_ind_stat_info wifi_mgmr_connect_ind_stat_info_t; + +typedef struct anon_struct_for_ipv4 anon_struct_for_ipv4, *Panon_struct_for_ipv4; + + +// WARNING! conflicting data type names: /DWARF/wifi_mgmr.h/wlan_netif/anon_union_for_field_5 - /DWARF/hal_desc.h/tx_hd/anon_union_for_field_5 + +typedef struct state state, *Pstate; + +typedef struct event event, *Pevent; + +typedef struct transition transition, *Ptransition; + +struct wifi_mgmr_connect_ind_stat_info { + uint16_t status_code; + uint8_t type_ind; + char ssid[32]; + char psk[65]; + uint8_t bssid[6]; + uint16_t chan_freq; + uint8_t chan_band; + undefined field_0x6d; +}; + +struct wifi_mgmr_profile { + char ssid[33]; + uint8_t no_autoconnect; + undefined field_0x22; + undefined field_0x23; + uint32_t ssid_len; + char psk[65]; + undefined field_0x69; + undefined field_0x6a; + undefined field_0x6b; + uint32_t psk_len; + char pmk[65]; + undefined field_0xb1; + undefined field_0xb2; + undefined field_0xb3; + uint32_t pmk_len; + uint8_t mac[6]; + uint8_t dhcp_use; + uint8_t priority; + uint8_t isActive; + uint8_t isUsed; + undefined field_0xc2; + undefined field_0xc3; +}; + +struct anon_struct_for_ipv4 { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +struct state { + struct state * parentState; + struct state * entryState; + struct transition * transitions; + size_t numTransitions; + void * data; + void (* entryAction)(void *, struct event *); + void (* exitAction)(void *, struct event *); +}; + +struct event { + int type; + void * data; +}; + +struct wlan_netif { + int mode; + uint8_t vif_index; + uint8_t mac[6]; + undefined field_0xb; + struct anon_struct_for_ipv4 ipv4; + struct netif netif; + union anon_union_for_field_5 field_5; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +struct xSTATIC_STREAM_BUFFER { + size_t uxDummy1[4]; + void * pvDummy2[3]; + uint8_t ucDummy3; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; + UBaseType_t uxDummy4; +}; + +struct stateMachine { + struct state * currentState; + struct state * previousState; + struct state * errorState; +}; + +struct wifi_mgmr_scan_item { + char ssid[32]; + char ssid_tail[1]; + undefined field_0x21; + undefined field_0x22; + undefined field_0x23; + uint32_t ssid_len; + uint8_t bssid[6]; + uint8_t channel; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t auth; + uint8_t cipher; + uint8_t is_used; + undefined field_0x35; + undefined field_0x36; + undefined field_0x37; + uint32_t timestamp_lastseen; +}; + +struct wifi_mgmr { + uint8_t ready; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + int channel; + int inf_ap_enabled; + struct wlan_netif wlan_sta; + struct wlan_netif wlan_ap; + WIFI_MGMR_CONNECTION_STATUS_T status; + undefined field_0xed; + undefined field_0xee; + undefined field_0xef; + wifi_mgmr_profile_t profiles[2]; + int profile_active_index; + wifi_mgmr_scan_item_t scan_items[50]; + os_messagequeue_t mq; + uint8_t mq_pool[2240]; + struct stateMachine m; + os_timer_t timer; + wifi_mgmr_connect_ind_stat_info_t wifi_mgmr_stat_info; + char country_code[3]; + uint8_t disable_autoreconnect; + undefined field_0x17c2; + undefined field_0x17c3; + int channel_nums; + uint32_t pending_task; + uint32_t features; + int scan_item_timeout; +}; + +struct transition { + int eventType; + void * condition; + _Bool (* guard)(void *, struct event *); + void (* action)(void *, struct event *, void *); + struct state * nextState; +}; + +typedef struct anon_struct.conflict18 anon_struct.conflict18, *Panon_struct.conflict18; + +struct anon_struct.conflict18 { + int8_t rssi; +}; + +typedef struct anon_struct.conflict17 anon_struct.conflict17, *Panon_struct.conflict17; + +struct anon_struct.conflict17 { + int8_t rssi; +}; + +typedef struct anon_struct.conflict15 anon_struct.conflict15, *Panon_struct.conflict15; + +struct anon_struct.conflict15 { + int8_t rssi; +}; + +typedef struct anon_struct.conflict14 anon_struct.conflict14, *Panon_struct.conflict14; + +struct anon_struct.conflict14 { + int8_t rssi; +}; + +typedef struct anon_struct.conflict13 anon_struct.conflict13, *Panon_struct.conflict13; + +struct anon_struct.conflict13 { + int8_t rssi; +}; + +typedef struct anon_struct.conflict12 anon_struct.conflict12, *Panon_struct.conflict12; + +struct anon_struct.conflict12 { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +typedef struct wifi_mgmr_cfg_element_msg wifi_mgmr_cfg_element_msg, *Pwifi_mgmr_cfg_element_msg; + +struct wifi_mgmr_cfg_element_msg { + uint32_t ops; + uint32_t task; + uint32_t element; + uint32_t type; + uint32_t length; + uint32_t[0] buf; +}; + +typedef union anon_union.conflict10 anon_union.conflict10, *Panon_union.conflict10; + +union anon_union.conflict10 { + struct anon_struct.conflict18 sta; +}; + +typedef union anon_union.conflict11 anon_union.conflict11, *Panon_union.conflict11; + +typedef struct anon_struct.conflict22 anon_struct.conflict22, *Panon_struct.conflict22; + +struct anon_struct.conflict22 { + int8_t rssi; +}; + +union anon_union.conflict11 { + struct anon_struct.conflict22 sta; +}; + +typedef union anon_union.conflict12 anon_union.conflict12, *Panon_union.conflict12; + +typedef struct anon_struct.conflict24 anon_struct.conflict24, *Panon_struct.conflict24; + +struct anon_struct.conflict24 { + int8_t rssi; +}; + +union anon_union.conflict12 { + struct anon_struct.conflict24 sta; +}; + +typedef union anon_union.conflict8 anon_union.conflict8, *Panon_union.conflict8; + +union anon_union.conflict8 { + struct anon_struct.conflict13 sta; +}; + +typedef union anon_union.conflict9 anon_union.conflict9, *Panon_union.conflict9; + +union anon_union.conflict9 { + struct anon_struct.conflict15 sta; +}; + +typedef struct wifi_mgmr_sta_basic_info wifi_mgmr_sta_basic_info, *Pwifi_mgmr_sta_basic_info; + +typedef struct wifi_mgmr_sta_basic_info wifi_mgmr_sta_basic_info_t; + +struct wifi_mgmr_sta_basic_info { + uint8_t sta_idx; + uint8_t is_used; + uint8_t sta_mac[6]; + uint32_t tsfhi; + uint32_t tsflo; + int rssi; + uint8_t data_rate; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct wifi_mgmr_ipgot_msg wifi_mgmr_ipgot_msg, *Pwifi_mgmr_ipgot_msg; + +struct wifi_mgmr_ipgot_msg { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +typedef struct wifi_mgmr_msg wifi_mgmr_msg, *Pwifi_mgmr_msg; + +typedef struct wifi_mgmr_msg wifi_mgmr_msg_t; + +typedef enum WIFI_MGMR_EVENT { + WIFI_MGMR_EVENT_APP_AP_START=8, + WIFI_MGMR_EVENT_APP_AP_STOP=9, + WIFI_MGMR_EVENT_APP_CONF_MAX_STA=10, + WIFI_MGMR_EVENT_APP_CONNECT=1, + WIFI_MGMR_EVENT_APP_CONNECTED=3, + WIFI_MGMR_EVENT_APP_DENOISE=12, + WIFI_MGMR_EVENT_APP_DISCONNECT=5, + WIFI_MGMR_EVENT_APP_IDLE=0, + WIFI_MGMR_EVENT_APP_IP_GOT=4, + WIFI_MGMR_EVENT_APP_PHY_UP=7, + WIFI_MGMR_EVENT_APP_RC_CONFIG=11, + WIFI_MGMR_EVENT_APP_RECONNECT=6, + WIFI_MGMR_EVENT_APP_RELOAD_TSEN=13, + WIFI_MGMR_EVENT_APP_SNIFFER=2, + WIFI_MGMR_EVENT_FW_CFG_REQ=22, + WIFI_MGMR_EVENT_FW_CHANNEL_SET=17, + WIFI_MGMR_EVENT_FW_DATA_RAW_SEND=21, + WIFI_MGMR_EVENT_FW_DISCONNECT=15, + WIFI_MGMR_EVENT_FW_IND_CONNECTED=20, + WIFI_MGMR_EVENT_FW_IND_DISCONNECT=19, + WIFI_MGMR_EVENT_FW_POWERSAVING=16, + WIFI_MGMR_EVENT_FW_SCAN=18, + WIFI_MGMR_EVENT_GLB_AP_IND_STA_DEL=27, + WIFI_MGMR_EVENT_GLB_AP_IND_STA_NEW=26, + WIFI_MGMR_EVENT_GLB_DISABLE_AUTORECONNECT=28, + WIFI_MGMR_EVENT_GLB_ENABLE_AUTORECONNECT=29, + WIFI_MGMR_EVENT_GLB_IP_UPDATE=30, + WIFI_MGMR_EVENT_GLB_SCAN_IND_BEACON=24, + WIFI_MGMR_EVENT_GLB_SCAN_IND_PROBE_RESP=25, + WIFI_MGMR_EVENT_MAXAPP_MINIFW=14, + WIFI_MGMR_EVENT_MAXFW_MINI_GLOBAL=23 +} WIFI_MGMR_EVENT; + +typedef enum WIFI_MGMR_EVENT WIFI_MGMR_EVENT_T; + +struct wifi_mgmr_msg { + WIFI_MGMR_EVENT_T ev; + void * data1; + void * data2; + uint32_t len; + uint8_t[0] data; +}; + +typedef struct anon_struct.conflict61 anon_struct.conflict61, *Panon_struct.conflict61; + +struct anon_struct.conflict61 { + int8_t rssi; +}; + +typedef struct wifi_mgmr_cfg_element_msg wifi_mgmr_cfg_element_msg_t; + +typedef struct wifi_mgmr_ipgot_msg wifi_mgmr_ipgot_msg_t; + +typedef enum EVENT_TYPE { + EVENT_TYPE_APP=1, + EVENT_TYPE_FW=0, + EVENT_TYPE_GLB=2 +} EVENT_TYPE; + +typedef struct wifi_mgmr_ap_msg wifi_mgmr_ap_msg, *Pwifi_mgmr_ap_msg; + +struct wifi_mgmr_ap_msg { + int32_t channel; + char ssid[32]; + char ssid_tail[1]; + uint8_t hidden_ssid; + uint32_t ssid_len; + char psk[64]; + char psk_tail[1]; + uint32_t psk_len; +}; + +typedef struct anon_struct.conflict21 anon_struct.conflict21, *Panon_struct.conflict21; + +struct anon_struct.conflict21 { + int8_t rssi; +}; + +typedef struct anon_struct.conflict20 anon_struct.conflict20, *Panon_struct.conflict20; + +struct anon_struct.conflict20 { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +typedef struct wifi_mgmr_ap_msg wifi_mgmr_ap_msg_t; + +typedef struct anon_struct.conflict23 anon_struct.conflict23, *Panon_struct.conflict23; + +struct anon_struct.conflict23 { + int8_t rssi; +}; + +typedef struct anon_struct.conflict19 anon_struct.conflict19, *Panon_struct.conflict19; + +struct anon_struct.conflict19 { + uint32_t ip; + uint32_t mask; + uint32_t gw; + uint32_t dns1; + uint32_t dns2; +}; + +typedef struct mm_bcn_env_tag mm_bcn_env_tag, *Pmm_bcn_env_tag; + +struct mm_bcn_env_tag { + struct mm_bcn_change_req * param; + int tx_cfm; + _Bool tx_pending; + _Bool update_ongoing; + _Bool update_pending; + undefined field_0xb; + struct hal_dma_desc_tag dma; + struct co_list tim_list; +}; + +typedef struct led_trigger_item led_trigger_item, *Pled_trigger_item; + +typedef struct loop_timer loop_timer, *Ploop_timer; + +typedef struct loop_ctx loop_ctx, *Ploop_ctx; + +typedef struct utils_list utils_list, *Putils_list; + +typedef struct loop_evt_handler_statistic loop_evt_handler_statistic, *Ploop_evt_handler_statistic; + +typedef struct loop_evt_handler loop_evt_handler, *Ploop_evt_handler; + +typedef struct loop_msg loop_msg, *Ploop_msg; + + +// WARNING! conflicting data type names: /DWARF/bloop.h/loop_msg/anon_union_for_u - /DWARF/timers.c/tmrTimerQueueMessage/anon_union_for_u + +struct loop_timer { + utils_dlist_t dlist_item; + uint8_t flags; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + uint time_added; + uint time_target; + int idx_task; + uint32_t evt_type_map; + void (* cb)(struct loop_ctx *, struct loop_timer *, void *); + void * arg; +}; + +struct led_trigger_item { + utils_dlist_t dlist_item; + struct loop_timer timer; + int type; + int pin; + int active; + int current_val; +}; + +struct utils_list { + struct utils_list_hdr * first; + struct utils_list_hdr * last; +}; + +struct loop_evt_handler { + char * name; + int (* evt)(struct loop_ctx *, struct loop_evt_handler *, uint32_t *, uint32_t *); + int (* handle)(struct loop_ctx *, struct loop_evt_handler *, struct loop_msg *); +}; + +struct loop_evt_handler_statistic { + uint time_max; + uint time_consumed; + uint time_accumulated; + uint count_triggered; +}; + +struct loop_ctx { + TaskHandle_t looper; + uint32_t bitmap_evt_async; + uint32_t bitmap_evt_sync; + uint32_t bitmap_msg; + uint32_t evt_type_map_async[32]; + uint32_t evt_type_map_sync[32]; + struct utils_list list[32]; + struct loop_evt_handler_statistic statistic[32]; + struct loop_evt_handler * handlers[32]; + utils_dlist_t timer_dlist; + utils_dlist_t timer_dued; +}; + +struct loop_msg { + struct utils_list_hdr item; + union anon_union_for_u u; + void * arg1; + void * arg2; + uint time_added; + uint time_consumed; +}; + +typedef struct led_trigger_ctx led_trigger_ctx, *Pled_trigger_ctx; + +struct led_trigger_ctx { + utils_dlist_t trigger_queue; + utils_dlist_t waiting_queue; +}; + +typedef struct loop_evt_handler_holder loop_evt_handler_holder, *Ploop_evt_handler_holder; + +struct loop_evt_handler_holder { + struct loop_evt_handler handler; + struct led_trigger_ctx * ctx; +}; + + +// WARNING! conflicting data type names: /DWARF/_types.h/anon_union - /DWARF/gatt.c/parse_service/anon_union + +typedef struct rijndael_ctx rijndael_ctx, *Prijndael_ctx; + +typedef uint u32.conflict; + +struct rijndael_ctx { + int decrypt; + int Nr; + u32.conflict key[60]; +}; + +typedef struct rf_para_flash_tag rf_para_flash_tag, *Prf_para_flash_tag; + +struct rf_para_flash_tag { + uint32_t magic; + uint8_t capcode_valid; + uint8_t capcode; + uint8_t poweroffset_valid; + int8_t poweroffset[3]; + uint8_t mac_valid; + uint8_t mac[6]; + uint8_t rsvd[3]; + uint32_t crc32; +}; + +typedef struct rf_para_flash_tag rf_para_flash_t; + +typedef struct rf_calib2_tag rf_calib2_tag, *Prf_calib2_tag; + +struct rf_calib2_tag { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct anon_struct.conflict224 anon_struct.conflict224, *Panon_struct.conflict224; + +typedef struct rf_calib1_tag.conflict2 rf_calib1_tag.conflict2, *Prf_calib1_tag.conflict2; + +typedef struct rf_calib2_tag.conflict2 rf_calib2_tag.conflict2, *Prf_calib2_tag.conflict2; + +typedef struct rf_calib3_tag.conflict2 rf_calib3_tag.conflict2, *Prf_calib3_tag.conflict2; + +typedef struct rf_calib4_tag.conflict2 rf_calib4_tag.conflict2, *Prf_calib4_tag.conflict2; + +struct rf_calib3_tag.conflict2 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +struct rf_calib2_tag.conflict2 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +struct rf_calib1_tag.conflict2 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +struct rf_calib4_tag.conflict2 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +struct anon_struct.conflict224 { + uint32_t inited; + struct rf_calib1_tag.conflict2 cal; + struct rf_calib2_tag.conflict2 lo[21]; + undefined field_0x46; + undefined field_0x47; + struct rf_calib3_tag.conflict2 rxcal[4]; + struct rf_calib4_tag.conflict2 txcal[8]; +}; + +typedef struct anon_struct.conflict225 anon_struct.conflict225, *Panon_struct.conflict225; + +typedef struct rf_calib1_tag.conflict3 rf_calib1_tag.conflict3, *Prf_calib1_tag.conflict3; + +typedef struct rf_calib2_tag.conflict3 rf_calib2_tag.conflict3, *Prf_calib2_tag.conflict3; + +typedef struct rf_calib3_tag.conflict3 rf_calib3_tag.conflict3, *Prf_calib3_tag.conflict3; + +typedef struct rf_calib4_tag.conflict3 rf_calib4_tag.conflict3, *Prf_calib4_tag.conflict3; + +struct rf_calib3_tag.conflict3 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +struct rf_calib2_tag.conflict3 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +struct rf_calib1_tag.conflict3 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +struct rf_calib4_tag.conflict3 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +struct anon_struct.conflict225 { + uint32_t inited; + struct rf_calib1_tag.conflict3 cal; + struct rf_calib2_tag.conflict3 lo[21]; + undefined field_0x46; + undefined field_0x47; + struct rf_calib3_tag.conflict3 rxcal[4]; + struct rf_calib4_tag.conflict3 txcal[8]; +}; + +typedef struct rf_calib1_tag.conflict4 rf_calib1_tag.conflict4, *Prf_calib1_tag.conflict4; + +struct rf_calib1_tag.conflict4 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib1_tag.conflict1 rf_calib1_tag.conflict1, *Prf_calib1_tag.conflict1; + +struct rf_calib1_tag.conflict1 { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib4_tag.conflict rf_calib4_tag.conflict, *Prf_calib4_tag.conflict; + +struct rf_calib4_tag.conflict { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib1_tag.conflict rf_calib1_tag.conflict, *Prf_calib1_tag.conflict; + +struct rf_calib1_tag.conflict { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct rf_calib4_tag.conflict4 rf_calib4_tag.conflict4, *Prf_calib4_tag.conflict4; + +struct rf_calib4_tag.conflict4 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib4_tag.conflict1 rf_calib4_tag.conflict1, *Prf_calib4_tag.conflict1; + +struct rf_calib4_tag.conflict1 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib4_tag.conflict5 rf_calib4_tag.conflict5, *Prf_calib4_tag.conflict5; + +struct rf_calib4_tag.conflict5 { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib_data_tag rf_calib_data_tag, *Prf_calib_data_tag; + +typedef struct rf_calib1_tag rf_calib1_tag, *Prf_calib1_tag; + +typedef struct rf_calib3_tag rf_calib3_tag, *Prf_calib3_tag; + +typedef struct rf_calib4_tag rf_calib4_tag, *Prf_calib4_tag; + +struct rf_calib3_tag { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +struct rf_calib4_tag { + uint32_t tosdac_i:6; + uint32_t tosdac_q:6; + uint32_t tx_iq_gain_comp:11; + undefined field_0x3; + uint32_t tx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +struct rf_calib1_tag { + uint32_t gpadc_oscode:12; + uint32_t rx_offset_i:10; + uint32_t rx_offset_q:10; + uint32_t rbb_cap1_fc_i:6; + uint32_t rbb_cap1_fc_q:6; + uint32_t rbb_cap2_fc_i:6; + uint32_t rbb_cap2_fc_q:6; + undefined field_0x7; + uint32_t tx_dc_comp_i:12; + uint32_t tx_dc_comp_q:12; + uint32_t tmx_cs:3; + uint32_t txpwr_att_rec:3; + uint32_t pa_pwrmx_osdac:4; + uint32_t tmx_csh:3; + uint32_t tmx_csl:3; + uint32_t tsen_refcode_rfcal:12; + undefined field_0xf; + uint32_t tsen_refcode_corner:12; + uint32_t rc32k_code_fr_ext:10; + uint32_t rc32m_code_fr_ext:8; + uint32_t saradc_oscode:10; + uint16_t fcal_4osmx:4; + undefined field_0x16; + undefined field_0x17; +}; + +struct rf_calib_data_tag { + uint32_t inited; + struct rf_calib1_tag cal; + struct rf_calib2_tag lo[21]; + undefined field_0x46; + undefined field_0x47; + struct rf_calib3_tag rxcal[4]; + struct rf_calib4_tag txcal[8]; +}; + +typedef struct rf_calib3_tag.conflict4 rf_calib3_tag.conflict4, *Prf_calib3_tag.conflict4; + +struct rf_calib3_tag.conflict4 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib3_tag.conflict5 rf_calib3_tag.conflict5, *Prf_calib3_tag.conflict5; + +struct rf_calib3_tag.conflict5 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib3_tag.conflict1 rf_calib3_tag.conflict1, *Prf_calib3_tag.conflict1; + +struct rf_calib3_tag.conflict1 { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib2_tag.conflict4 rf_calib2_tag.conflict4, *Prf_calib2_tag.conflict4; + +struct rf_calib2_tag.conflict4 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib2_tag.conflict1 rf_calib2_tag.conflict1, *Prf_calib2_tag.conflict1; + +struct rf_calib2_tag.conflict1 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib2_tag.conflict5 rf_calib2_tag.conflict5, *Prf_calib2_tag.conflict5; + +struct rf_calib2_tag.conflict5 { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct rf_calib3_tag.conflict rf_calib3_tag.conflict, *Prf_calib3_tag.conflict; + +struct rf_calib3_tag.conflict { + uint32_t rosdac_i:6; + uint32_t rosdac_q:6; + uint32_t rx_iq_gain_comp:11; + undefined field_0x3; + uint32_t rx_iq_phase_comp:10; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct rf_calib2_tag.conflict rf_calib2_tag.conflict, *Prf_calib2_tag.conflict; + +struct rf_calib2_tag.conflict { + uint16_t fcal:8; + uint16_t acal:5; +}; + +typedef struct anon_struct.conflict161 anon_struct.conflict161, *Panon_struct.conflict161; + +struct anon_struct.conflict161 { + uint32_t inited; + struct rf_calib1_tag cal; + struct rf_calib2_tag lo[21]; + undefined field_0x46; + undefined field_0x47; + struct rf_calib3_tag rxcal[4]; + struct rf_calib4_tag txcal[8]; +}; + +typedef struct rf_calib_data_tag.conflict rf_calib_data_tag.conflict, *Prf_calib_data_tag.conflict; + +struct rf_calib_data_tag.conflict { + uint32_t inited; + struct rf_calib1_tag.conflict4 cal; + struct rf_calib2_tag.conflict5 lo[21]; + undefined field_0x46; + undefined field_0x47; + struct rf_calib3_tag.conflict5 rxcal[4]; + struct rf_calib4_tag.conflict5 txcal[8]; +}; + +typedef struct bt_smp bt_smp, *Pbt_smp; + +typedef struct bt_l2cap_le_chan bt_l2cap_le_chan, *Pbt_l2cap_le_chan; + +typedef struct bt_le_oob_sc_data bt_le_oob_sc_data, *Pbt_le_oob_sc_data; + +struct bt_le_oob_sc_data { + u8_t r[16]; + u8_t c[16]; +}; + +struct bt_l2cap_le_chan { + struct bt_l2cap_chan chan; + struct bt_l2cap_le_endpoint rx; + struct bt_l2cap_le_endpoint tx; + struct k_fifo tx_queue; + struct net_buf * tx_buf; + struct net_buf * _sdu; + u16_t _sdu_len; + undefined field_0x7e; + undefined field_0x7f; + struct k_work rx_work; + struct k_fifo rx_queue; +}; + +struct bt_smp { + struct bt_l2cap_le_chan chan; + atomic_t allowed_cmds; + atomic_t flags[1]; + u8_t method; + u8_t preq[7]; + u8_t prsp[7]; + u8_t pcnf[16]; + u8_t prnd[16]; + u8_t rrnd[16]; + u8_t tk[16]; + u8_t pkey[64]; + u8_t dhkey[32]; + u8_t e[16]; + u8_t mackey[16]; + undefined field_0x16f; + u32_t.conflict passkey; + u8_t passkey_round; + undefined field_0x175; + undefined field_0x176; + undefined field_0x177; + struct bt_le_oob_sc_data * oobd_local; + struct bt_le_oob_sc_data * oobd_remote; + u8_t local_dist; + u8_t remote_dist; + undefined field_0x182; + undefined field_0x183; + struct k_delayed_work work; +}; + +typedef enum pairing_method { + JUST_WORKS=0, + LE_SC_OOB=5, + PASSKEY_CONFIRM=3, + PASSKEY_DISPLAY=2, + PASSKEY_INPUT=1, + PASSKEY_ROLE=4 +} pairing_method; + +typedef struct anon_struct.conflict85 anon_struct.conflict85, *Panon_struct.conflict85; + +struct anon_struct.conflict85 { + u8_t (* func)(struct bt_smp *, struct net_buf *); + u8_t expect_len; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict84 anon_struct.conflict84, *Panon_struct.conflict84; + +struct anon_struct.conflict84 { + u8_t (* func)(struct bt_smp *, struct net_buf *); + u8_t expect_len; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict83 anon_struct.conflict83, *Panon_struct.conflict83; + +struct anon_struct.conflict83 { + u8_t (* func)(struct bt_smp *, struct net_buf *); + u8_t expect_len; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct anon_struct.conflict82 anon_struct.conflict82, *Panon_struct.conflict82; + +struct anon_struct.conflict82 { + u8_t (* func)(struct bt_smp *, struct net_buf *); + u8_t expect_len; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct anon_struct_for_rand anon_struct_for_rand, *Panon_struct_for_rand; + +struct anon_struct_for_rand { + u8_t key[16]; + u8_t rand[8]; + u8_t ediv[2]; +}; + +typedef struct anon_struct_0 anon_struct_0, *Panon_struct_0; + +struct anon_struct_0 { + u32_t.conflict __v; +}; + +typedef void * MessageBufferHandle_t; + +typedef enum hostapd_state_tag { + HOSTAPD_STATE_IDLE=0, + HOSTAPD_STATE_MAX=1 +} hostapd_state_tag; + +typedef enum co_error { + CO_ERROR_ACL_CON_EXISTS=11, + CO_ERROR_AUTH_FAILURE=5, + CO_ERROR_CCA_REJ_USE_CLOCK_DRAG=64, + CO_ERROR_CHANNEL_CLASS_NOT_SUP=46, + CO_ERROR_COMMAND_DISALLOWED=12, + CO_ERROR_CONN_ACCEPT_TIMEOUT_EXCEED=16, + CO_ERROR_CONN_FAILED_TO_BE_EST=62, + CO_ERROR_CONN_REJ_LIMITED_RESOURCES=13, + CO_ERROR_CONN_REJ_SECURITY_REASONS=14, + CO_ERROR_CONN_REJ_UNACCEPTABLE_BDADDR=15, + CO_ERROR_CONTROLLER_BUSY=58, + CO_ERROR_CON_LIMIT_EXCEED=9, + CO_ERROR_CON_TERM_BY_LOCAL_HOST=22, + CO_ERROR_CON_TIMEOUT=8, + CO_ERROR_DIFF_TRANSACTION_COLLISION=42, + CO_ERROR_DIRECT_ADV_TO=60, + CO_ERROR_EIR_TOO_LARGE=54, + CO_ERROR_ENC_MODE_NOT_ACCEPT=37, + CO_ERROR_HARDWARE_FAILURE=3, + CO_ERROR_HOST_BUSY_PAIRING=56, + CO_ERROR_HW_MEM_ALLOC_FAIL=1, + CO_ERROR_HW_UART_OUT_OF_SYNC=0, + CO_ERROR_INSTANT_PASSED=40, + CO_ERROR_INSUFFICIENT_SECURITY=47, + CO_ERROR_INVALID_HCI_PARAM=18, + CO_ERROR_INVALID_LMP_PARAM=30, + CO_ERROR_LIMIT_REACHED=67, + CO_ERROR_LINK_KEY_CANT_CHANGE=38, + CO_ERROR_LMP_COLLISION=35, + CO_ERROR_LMP_PDU_NOT_ALLOWED=36, + CO_ERROR_LMP_RSP_TIMEOUT=34, + CO_ERROR_MEMORY_CAPA_EXCEED=7, + CO_ERROR_NO_ERROR=0, + CO_ERROR_OP_CANCELL_BY_HOST=68, + CO_ERROR_PAGE_TIMEOUT=4, + CO_ERROR_PAIRING_NOT_ALLOWED=24, + CO_ERROR_PAIRING_WITH_UNIT_KEY_NOT_SUP=41, + CO_ERROR_PARAM_OUT_OF_MAND_RANGE=48, + CO_ERROR_PIN_MISSING=6, + CO_ERROR_QOS_NOT_SUPPORTED=39, + CO_ERROR_QOS_REJECTED=45, + CO_ERROR_QOS_UNACCEPTABLE_PARAM=44, + CO_ERROR_REMOTE_DEV_POWER_OFF=21, + CO_ERROR_REMOTE_DEV_TERM_LOW_RESOURCES=20, + CO_ERROR_REMOTE_USER_TERM_CON=19, + CO_ERROR_REPEATED_ATTEMPTS=23, + CO_ERROR_RESERVED_SLOT_VIOLATION=52, + CO_ERROR_ROLE_CHANGE_NOT_ALLOWED=33, + CO_ERROR_ROLE_SWITCH_FAIL=53, + CO_ERROR_ROLE_SWITCH_PEND=50, + CO_ERROR_SCO_AIR_MODE_REJECTED=29, + CO_ERROR_SCO_INTERVAL_REJECTED=28, + CO_ERROR_SCO_OFFSET_REJECTED=27, + CO_ERROR_SP_NOT_SUPPORTED_HOST=55, + CO_ERROR_SYNC_CON_LIMIT_DEV_EXCEED=10, + CO_ERROR_TERMINATED_MIC_FAILURE=61, + CO_ERROR_UNACCEPTABLE_CONN_INT=59, + CO_ERROR_UNDEFINED=-1, + CO_ERROR_UNKNOWN_CONNECTION_ID=2, + CO_ERROR_UNKNOWN_HCI_COMMAND=1, + CO_ERROR_UNKNOWN_LMP_PDU=25, + CO_ERROR_UNKNOW_ADV_ID=66, + CO_ERROR_UNSPECIFIED_ERROR=31, + CO_ERROR_UNSUPPORTED=17, + CO_ERROR_UNSUPPORTED_LMP_PARAM_VALUE=32, + CO_ERROR_UNSUPPORTED_REMOTE_FEATURE=26 +} co_error; + +typedef struct bt_smp_pairing_random bt_smp_pairing_random, *Pbt_smp_pairing_random; + +struct bt_smp_pairing_random { + u8_t val[16]; +}; + +typedef struct bt_smp_pairing bt_smp_pairing, *Pbt_smp_pairing; + +struct bt_smp_pairing { + u8_t io_capability; + u8_t oob_flag; + u8_t auth_req; + u8_t max_key_size; + u8_t init_key_dist; + u8_t resp_key_dist; +}; + +typedef struct bt_smp_signing_info bt_smp_signing_info, *Pbt_smp_signing_info; + +struct bt_smp_signing_info { + u8_t csrk[16]; +}; + +typedef struct bt_smp_public_key bt_smp_public_key, *Pbt_smp_public_key; + +struct bt_smp_public_key { + u8_t x[32]; + u8_t y[32]; +}; + +typedef struct bt_smp_ident_info bt_smp_ident_info, *Pbt_smp_ident_info; + +struct bt_smp_ident_info { + u8_t irk[16]; +}; + +typedef struct bt_smp_master_ident bt_smp_master_ident, *Pbt_smp_master_ident; + +struct bt_smp_master_ident { + u8_t ediv[2]; + u8_t rand[8]; +}; + +typedef struct bt_smp_ident_addr_info bt_smp_ident_addr_info, *Pbt_smp_ident_addr_info; + +struct bt_smp_ident_addr_info { + struct bt_addr_le_t addr; +}; + +typedef struct bt_smp_pairing_fail bt_smp_pairing_fail, *Pbt_smp_pairing_fail; + +struct bt_smp_pairing_fail { + u8_t reason; +}; + +typedef struct bt_smp_dhkey_check bt_smp_dhkey_check, *Pbt_smp_dhkey_check; + +struct bt_smp_dhkey_check { + u8_t e[16]; +}; + +typedef struct bt_smp_security_request bt_smp_security_request, *Pbt_smp_security_request; + +struct bt_smp_security_request { + u8_t auth_req; +}; + +typedef struct bt_smp_hdr bt_smp_hdr, *Pbt_smp_hdr; + +struct bt_smp_hdr { + u8_t code; +}; + +typedef struct bt_smp_pairing_confirm bt_smp_pairing_confirm, *Pbt_smp_pairing_confirm; + +struct bt_smp_pairing_confirm { + u8_t val[16]; +}; + +typedef struct bt_smp_encrypt_info bt_smp_encrypt_info, *Pbt_smp_encrypt_info; + +struct bt_smp_encrypt_info { + u8_t ltk[16]; +}; + +typedef struct ip4_addr_packed ip4_addr_packed, *Pip4_addr_packed; + +struct ip4_addr_packed { + u32_t addr; +}; + +typedef struct ip_hdr ip_hdr, *Pip_hdr; + +typedef struct ip4_addr_packed ip4_addr_p_t; + +struct ip_hdr { + u8_t _v_hl; + u8_t _tos; + u16_t _len; + u16_t _id; + u16_t _offset; + u8_t _ttl; + u8_t _proto; + u16_t _chksum; + ip4_addr_p_t src; + ip4_addr_p_t dest; +}; + +typedef void (* tcpip_init_done_fn)(void *); + +typedef void (* tcpip_callback_fn)(void *); + +typedef struct cfg_element_entry cfg_element_entry, *Pcfg_element_entry; + +typedef enum CFG_ELEMENT_TYPE_OPS { + CFG_ELEMENT_TYPE_OPS_DUMP_DEBUG=3, + CFG_ELEMENT_TYPE_OPS_GET=1, + CFG_ELEMENT_TYPE_OPS_RESET=2, + CFG_ELEMENT_TYPE_OPS_SET=0, + CFG_ELEMENT_TYPE_OPS_UNKNOWN=4 +} CFG_ELEMENT_TYPE_OPS; + +struct cfg_element_entry { + uint32_t task; + uint16_t element; + uint16_t type; + char * name; + void * val; + int (* set)(struct cfg_element_entry *, void *, void *); + int (* get)(struct cfg_element_entry *, void *, void *); + int (* notify)(struct cfg_element_entry *, void *, void *, enum CFG_ELEMENT_TYPE_OPS); +}; + +typedef struct tc_hmac_state_struct tc_hmac_state_struct, *Ptc_hmac_state_struct; + +typedef struct tc_sha256_state_struct tc_sha256_state_struct, *Ptc_sha256_state_struct; + +struct tc_sha256_state_struct { + uint iv[8]; + uint64_t bits_hashed; + uint8_t leftover[64]; + size_t leftover_offset; + undefined field_0x6c; + undefined field_0x6d; + undefined field_0x6e; + undefined field_0x6f; +}; + +struct tc_hmac_state_struct { + struct tc_sha256_state_struct hash_state; + uint8_t key[128]; +}; + +typedef struct bl_txhdr bl_txhdr, *Pbl_txhdr; + +typedef union bl_hw_txstatus bl_hw_txstatus, *Pbl_hw_txstatus; + +typedef struct anon_struct.conflict59 anon_struct.conflict59, *Panon_struct.conflict59; + +struct anon_struct.conflict59 { + u32 tx_done:1; + u32 retry_required:1; + u32 sw_retry_required:1; + u32 reserved:29; +}; + +union bl_hw_txstatus { + struct anon_struct.conflict59 field_0; + u32 value; +}; + +struct bl_txhdr { + struct utils_list_hdr item; + union bl_hw_txstatus status; + uint32_t * p; + struct hostdesc host; +}; + +typedef struct scanu_start_req.conflict1 scanu_start_req.conflict1, *Pscanu_start_req.conflict1; + +typedef struct mac_addr.conflict43 mac_addr.conflict43, *Pmac_addr.conflict43; + +struct mac_addr.conflict43 { + uint16_t array[3]; +}; + +struct scanu_start_req.conflict1 { + struct scan_chan_tag chan[42]; + struct mac_ssid ssid[2]; + struct mac_addr.conflict43 bssid; + undefined field_0x146; + undefined field_0x147; + uint32_t add_ies; + uint16_t add_ie_len; + uint8_t vif_idx; + uint8_t chan_cnt; + uint8_t ssid_cnt; + _Bool no_cck; + undefined field_0x152; + undefined field_0x153; +}; + +typedef struct scanu_start_req.conflict3 scanu_start_req.conflict3, *Pscanu_start_req.conflict3; + +struct scanu_start_req.conflict3 { + struct scan_chan_tag chan[42]; + struct mac_ssid ssid[2]; + struct mac_addr.conflict bssid; + undefined field_0x146; + undefined field_0x147; + uint32_t add_ies; + uint16_t add_ie_len; + uint8_t vif_idx; + uint8_t chan_cnt; + uint8_t ssid_cnt; + _Bool no_cck; + undefined field_0x152; + undefined field_0x153; +}; + +typedef struct scanu_start_req.conflict2 scanu_start_req.conflict2, *Pscanu_start_req.conflict2; + +struct scanu_start_req.conflict2 { + struct scan_chan_tag chan[42]; + struct mac_ssid ssid[2]; + struct mac_addr.conflict bssid; + undefined field_0x146; + undefined field_0x147; + uint32_t add_ies; + uint16_t add_ie_len; + uint8_t vif_idx; + uint8_t chan_cnt; + uint8_t ssid_cnt; + _Bool no_cck; + undefined field_0x152; + undefined field_0x153; +}; + +typedef struct scanu_start_req.conflict5 scanu_start_req.conflict5, *Pscanu_start_req.conflict5; + +typedef struct mac_addr.conflict61 mac_addr.conflict61, *Pmac_addr.conflict61; + +struct mac_addr.conflict61 { + uint16_t array[3]; +}; + +struct scanu_start_req.conflict5 { + struct scan_chan_tag chan[42]; + struct mac_ssid ssid[2]; + struct mac_addr.conflict61 bssid; + undefined field_0x146; + undefined field_0x147; + uint32_t add_ies; + uint16_t add_ie_len; + uint8_t vif_idx; + uint8_t chan_cnt; + uint8_t ssid_cnt; + _Bool no_cck; + undefined field_0x152; + undefined field_0x153; +}; + +typedef struct scanu_start_req.conflict4 scanu_start_req.conflict4, *Pscanu_start_req.conflict4; + +typedef struct mac_addr.conflict60 mac_addr.conflict60, *Pmac_addr.conflict60; + +struct mac_addr.conflict60 { + uint16_t array[3]; +}; + +struct scanu_start_req.conflict4 { + struct scan_chan_tag chan[42]; + struct mac_ssid ssid[2]; + struct mac_addr.conflict60 bssid; + undefined field_0x146; + undefined field_0x147; + uint32_t add_ies; + uint16_t add_ie_len; + uint8_t vif_idx; + uint8_t chan_cnt; + uint8_t ssid_cnt; + _Bool no_cck; + undefined field_0x152; + undefined field_0x153; +}; + +typedef struct scanu_start_cfm scanu_start_cfm, *Pscanu_start_cfm; + +struct scanu_start_cfm { + uint8_t status; +}; + +typedef struct scanu_start_req.conflict7 scanu_start_req.conflict7, *Pscanu_start_req.conflict7; + +struct scanu_start_req.conflict7 { + struct scan_chan_tag chan[42]; + struct mac_ssid ssid[2]; + struct mac_addr.conflict171 bssid; + undefined field_0x146; + undefined field_0x147; + uint32_t add_ies; + uint16_t add_ie_len; + uint8_t vif_idx; + uint8_t chan_cnt; + uint8_t ssid_cnt; + _Bool no_cck; + undefined field_0x152; + undefined field_0x153; +}; + +typedef struct scanu_start_req.conflict6 scanu_start_req.conflict6, *Pscanu_start_req.conflict6; + +struct scanu_start_req.conflict6 { + struct scan_chan_tag chan[42]; + struct mac_ssid ssid[2]; + struct mac_addr.conflict171 bssid; + undefined field_0x146; + undefined field_0x147; + uint32_t add_ies; + uint16_t add_ie_len; + uint8_t vif_idx; + uint8_t chan_cnt; + uint8_t ssid_cnt; + _Bool no_cck; + undefined field_0x152; + undefined field_0x153; +}; + +typedef struct scanu_start_req.conflict9 scanu_start_req.conflict9, *Pscanu_start_req.conflict9; + +struct scanu_start_req.conflict9 { + struct scan_chan_tag chan[42]; + struct mac_ssid ssid[2]; + struct mac_addr.conflict171 bssid; + undefined field_0x146; + undefined field_0x147; + uint32_t add_ies; + uint16_t add_ie_len; + uint8_t vif_idx; + uint8_t chan_cnt; + uint8_t ssid_cnt; + _Bool no_cck; + undefined field_0x152; + undefined field_0x153; +}; + +typedef struct scanu_start_req.conflict8 scanu_start_req.conflict8, *Pscanu_start_req.conflict8; + +struct scanu_start_req.conflict8 { + struct scan_chan_tag chan[42]; + struct mac_ssid ssid[2]; + struct mac_addr.conflict171 bssid; + undefined field_0x146; + undefined field_0x147; + uint32_t add_ies; + uint16_t add_ie_len; + uint8_t vif_idx; + uint8_t chan_cnt; + uint8_t ssid_cnt; + _Bool no_cck; + undefined field_0x152; + undefined field_0x153; +}; + +typedef struct scanu_start_req.conflict scanu_start_req.conflict, *Pscanu_start_req.conflict; + +typedef struct mac_addr.conflict42 mac_addr.conflict42, *Pmac_addr.conflict42; + +struct mac_addr.conflict42 { + uint16_t array[3]; +}; + +struct scanu_start_req.conflict { + struct scan_chan_tag chan[42]; + struct mac_ssid ssid[2]; + struct mac_addr.conflict42 bssid; + undefined field_0x146; + undefined field_0x147; + uint32_t add_ies; + uint16_t add_ie_len; + uint8_t vif_idx; + uint8_t chan_cnt; + uint8_t ssid_cnt; + _Bool no_cck; + undefined field_0x152; + undefined field_0x153; +}; + +typedef struct Bl_SHA1_CTX Bl_SHA1_CTX, *PBl_SHA1_CTX; + +struct Bl_SHA1_CTX { + UINT32 Intermediate_Hash[5]; + UINT32 Length_Low; + UINT32 Length_High; + UINT32 Scratch[16]; + UINT8 Message_Block[64]; + SINT16 Message_Block_Index; + UINT8 Computed; + UINT8 Corrupted; +}; + +typedef struct tcp_pcb_listen tcp_pcb_listen, *Ptcp_pcb_listen; + +typedef struct tcp_pcb tcp_pcb, *Ptcp_pcb; + +typedef err_t (* tcp_accept_fn)(void *, struct tcp_pcb *, err_t); + +typedef u16_t tcpflags_t; + +typedef struct tcp_seg tcp_seg, *Ptcp_seg; + +typedef err_t (* tcp_connected_fn)(void *, struct tcp_pcb *, err_t); + +typedef struct tcp_hdr tcp_hdr, *Ptcp_hdr; + +struct tcp_hdr { + u16_t src; + u16_t dest; + u32_t seqno; + u32_t ackno; + u16_t _hdrlen_rsvd_flags; + u16_t wnd; + u16_t chksum; + u16_t urgp; +}; + +struct tcp_pcb_listen { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb_listen * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + tcp_accept_fn accept; +}; + +struct tcp_pcb { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +struct tcp_seg { + struct tcp_seg * next; + struct pbuf * p; + u16_t len; + u16_t chksum; + u8_t chksum_swapped; + u8_t flags; + undefined field_0xe; + undefined field_0xf; + struct tcp_hdr * tcphdr; +}; + +typedef struct tcpip_callback_msg tcpip_callback_msg, *Ptcpip_callback_msg; + +struct tcpip_callback_msg { +}; + +typedef struct k_delayed_work.conflict11 k_delayed_work.conflict11, *Pk_delayed_work.conflict11; + +typedef struct k_timer.conflict18 k_timer.conflict18, *Pk_timer.conflict18; + +typedef struct k_timer.conflict18 k_timer_t.conflict15; + +struct k_timer.conflict18 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +struct k_delayed_work.conflict11 { + struct k_work work; + struct k_work_q * work_q; + k_timer_t.conflict15 timer; +}; + +typedef struct k_delayed_work.conflict12 k_delayed_work.conflict12, *Pk_delayed_work.conflict12; + +typedef struct k_timer.conflict19 k_timer.conflict19, *Pk_timer.conflict19; + +typedef struct k_timer.conflict19 k_timer_t.conflict16; + +struct k_timer.conflict19 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +struct k_delayed_work.conflict12 { + struct k_work work; + struct k_work_q * work_q; + k_timer_t.conflict16 timer; +}; + +typedef struct k_delayed_work.conflict10 k_delayed_work.conflict10, *Pk_delayed_work.conflict10; + +typedef struct k_timer.conflict17 k_timer.conflict17, *Pk_timer.conflict17; + +typedef struct k_timer.conflict17 k_timer_t.conflict14; + +struct k_timer.conflict17 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +struct k_delayed_work.conflict10 { + struct k_work work; + struct k_work_q * work_q; + k_timer_t.conflict14 timer; +}; + +typedef struct k_delayed_work.conflict8 k_delayed_work.conflict8, *Pk_delayed_work.conflict8; + +typedef struct k_timer.conflict15 k_timer.conflict15, *Pk_timer.conflict15; + +typedef struct k_timer.conflict15 k_timer_t.conflict12; + +struct k_timer.conflict15 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +struct k_delayed_work.conflict8 { + struct k_work work; + struct k_work_q * work_q; + k_timer_t.conflict12 timer; +}; + +typedef struct k_delayed_work.conflict9 k_delayed_work.conflict9, *Pk_delayed_work.conflict9; + +typedef struct k_timer.conflict16 k_timer.conflict16, *Pk_timer.conflict16; + +typedef struct k_timer.conflict16 k_timer_t.conflict13; + +struct k_timer.conflict16 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +struct k_delayed_work.conflict9 { + struct k_work work; + struct k_work_q * work_q; + k_timer_t.conflict13 timer; +}; + +typedef struct k_delayed_work.conflict7 k_delayed_work.conflict7, *Pk_delayed_work.conflict7; + +typedef struct k_timer.conflict14 k_timer.conflict14, *Pk_timer.conflict14; + +typedef struct k_timer.conflict14 k_timer_t.conflict11; + +struct k_timer.conflict14 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +struct k_delayed_work.conflict7 { + struct k_work work; + struct k_work_q * work_q; + k_timer_t.conflict11 timer; +}; + +typedef struct mac_addr.conflict101 mac_addr.conflict101, *Pmac_addr.conflict101; + +struct mac_addr.conflict101 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict58 anon_struct.conflict58, *Panon_struct.conflict58; + +struct anon_struct.conflict58 { + u8 category; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + undefined field_0x4; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + undefined field_0x8; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + undefined field_0xc; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + undefined field_0x10; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + undefined field_0x18; + undefined field_0x19; +}; + +typedef struct anon_struct.conflict57 anon_struct.conflict57, *Panon_struct.conflict57; + +struct anon_struct.conflict57 { + u8 category; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + undefined field_0x4; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + undefined field_0x8; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + undefined field_0xc; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + undefined field_0x10; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + undefined field_0x18; + undefined field_0x19; +}; + +typedef struct anon_struct.conflict56 anon_struct.conflict56, *Panon_struct.conflict56; + +struct anon_struct.conflict56 { + u8 category; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + undefined field_0x4; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + undefined field_0x8; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + undefined field_0xc; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + undefined field_0x10; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; + undefined field_0x14; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + undefined field_0x18; + undefined field_0x19; +}; + +typedef struct mac_addr.conflict138 mac_addr.conflict138, *Pmac_addr.conflict138; + +struct mac_addr.conflict138 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict132 mac_addr.conflict132, *Pmac_addr.conflict132; + +struct mac_addr.conflict132 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict134 mac_addr.conflict134, *Pmac_addr.conflict134; + +struct mac_addr.conflict134 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict128 mac_addr.conflict128, *Pmac_addr.conflict128; + +struct mac_addr.conflict128 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict124 mac_addr.conflict124, *Pmac_addr.conflict124; + +struct mac_addr.conflict124 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict126 mac_addr.conflict126, *Pmac_addr.conflict126; + +struct mac_addr.conflict126 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict140 mac_addr.conflict140, *Pmac_addr.conflict140; + +struct mac_addr.conflict140 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict146 mac_addr.conflict146, *Pmac_addr.conflict146; + +struct mac_addr.conflict146 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict148 mac_addr.conflict148, *Pmac_addr.conflict148; + +struct mac_addr.conflict148 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict142 mac_addr.conflict142, *Pmac_addr.conflict142; + +struct mac_addr.conflict142 { + uint16_t array[3]; +}; + +typedef struct txl_buffer_tag txl_buffer_tag, *Ptxl_buffer_tag; + +typedef struct txdesc txdesc, *Ptxdesc; + +typedef struct umacdesc umacdesc, *Pumacdesc; + +typedef struct lmacdesc lmacdesc, *Plmacdesc; + +typedef struct tx_hw_desc tx_hw_desc, *Ptx_hw_desc; + +typedef struct tx_cfm_tag tx_cfm_tag, *Ptx_cfm_tag; + +typedef struct tx_agg_desc tx_agg_desc, *Ptx_agg_desc; + +struct txl_buffer_tag { + uint32_t length; + uint32_t lenheader; + uint32_t lenpad; + uint32_t flags; + struct txl_buffer_tag * next; + struct txdesc * txdesc; + struct dma_desc dma_desc[1]; + struct dma_desc dma_desc_pat; + struct tx_pbd tbd; + struct tx_pbd tbd_body[8]; + uint8_t user_idx; + undefined field_0xed; + undefined field_0xee; + undefined field_0xef; + struct txl_buffer_control buffer_control; + struct tx_pbd tkip_mic_icv_pbd; + uint8_t tkip_mic_icv[12]; + uint32_t[0] payload; +}; + +struct umacdesc { + struct txl_buffer_control * buf_control; + uint32_t buff_offset; + uint16_t payl_len; + uint8_t head_len; + uint8_t hdr_len_802_2; + uint8_t tail_len; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; +}; + +struct lmacdesc { + struct tx_agg_desc * agg_desc; + struct txl_buffer_tag * buffer; + struct tx_hw_desc * hw_desc; +}; + +struct tx_cfm_tag { + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + int8_t credits; + uint8_t ampdu_size; + uint8_t pad[2]; + uint32_t status; +}; + +struct tx_hw_desc { + struct tx_cfm_tag * cfm_ptr; + struct tx_hd thd; +}; + +struct txdesc { + struct co_list_hdr list_hdr; + struct hostdesc.conflict host; + struct umacdesc umac; + struct lmacdesc lmac; + struct tx_hw_desc hw_desc; + struct tx_cfm_tag hw_cfm; + uint32_t buf[128]; +}; + +struct tx_agg_desc { + uint8_t reserved; +}; + +typedef struct mblock_free mblock_free, *Pmblock_free; + +struct mblock_free { + uint16_t corrupt_check; + uint16_t free_size; + struct mblock_free * next; + struct mblock_free * previous; +}; + +typedef struct inode_t inode_t, *Pinode_t; + +typedef union inode_ops_t inode_ops_t, *Pinode_ops_t; + +typedef struct file_ops file_ops, *Pfile_ops; + +typedef struct file_t file_t, *Pfile_t; + +typedef struct file_ops file_ops_t; + +typedef struct fs_ops fs_ops, *Pfs_ops; + + +// WARNING! conflicting data type names: /DWARF/stat.h/stat - /stat.h/stat + +typedef struct fs_ops fs_ops_t; + +struct file_ops { + int (* open)(struct inode_t *, struct file_t *); + int (* close)(struct file_t *); + ssize_t (* read)(struct file_t *, void *, size_t); + ssize_t (* write)(struct file_t *, void *, size_t); + int (* ioctl)(struct file_t *, int, ulong); + int (* poll)(struct file_t *, _Bool, void (* )(struct pollfd *, void *), struct pollfd *, void *); + int (* sync)(struct file_t *); +}; + +union inode_ops_t { + file_ops_t * i_ops; + fs_ops_t * i_fops; +}; + +struct inode_t { + union inode_ops_t ops; + void * i_arg; + char * i_name; + int i_flags; + uint8_t type; + uint8_t refs; + undefined field_0x12; + undefined field_0x13; +}; + +struct fs_ops { + int (* open)(struct file_t *, char *, int); + int (* close)(struct file_t *); + ssize_t (* read)(struct file_t *, char *, size_t); + ssize_t (* write)(struct file_t *, char *, size_t); + off_t (* lseek)(struct file_t *, off_t, int); + int (* sync)(struct file_t *); + int (* stat)(struct file_t *, char *, struct stat *); + int (* unlink)(struct file_t *, char *); + int (* rename)(struct file_t *, char *, char *); + aos_dir_t * (* opendir)(struct file_t *, char *); + aos_dirent_t * (* readdir)(struct file_t *, struct aos_dir_t *); + int (* closedir)(struct file_t *, struct aos_dir_t *); + int (* mkdir)(struct file_t *, char *); + int (* rmdir)(struct file_t *, char *); + void (* rewinddir)(struct file_t *, struct aos_dir_t *); + long (* telldir)(struct file_t *, struct aos_dir_t *); + void (* seekdir)(struct file_t *, struct aos_dir_t *, long); + int (* ioctl)(struct file_t *, int, ulong); + int (* statfs)(struct file_t *, char *, struct statfs *); + int (* access)(struct file_t *, char *, int); +}; + +struct file_t { + struct inode_t * node; + void * f_arg; + size_t offset; +}; + +typedef struct lwip_cyclic_timer.conflict lwip_cyclic_timer.conflict, *Plwip_cyclic_timer.conflict; + +struct lwip_cyclic_timer.conflict { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct mac_addr.conflict179 mac_addr.conflict179, *Pmac_addr.conflict179; + +struct mac_addr.conflict179 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict177 mac_addr.conflict177, *Pmac_addr.conflict177; + +struct mac_addr.conflict177 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict161 mac_addr.conflict161, *Pmac_addr.conflict161; + +struct mac_addr.conflict161 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict163 mac_addr.conflict163, *Pmac_addr.conflict163; + +struct mac_addr.conflict163 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict169 mac_addr.conflict169, *Pmac_addr.conflict169; + +struct mac_addr.conflict169 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict165 mac_addr.conflict165, *Pmac_addr.conflict165; + +struct mac_addr.conflict165 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict196 mac_addr.conflict196, *Pmac_addr.conflict196; + +struct mac_addr.conflict196 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict191 mac_addr.conflict191, *Pmac_addr.conflict191; + +struct mac_addr.conflict191 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict198 mac_addr.conflict198, *Pmac_addr.conflict198; + +struct mac_addr.conflict198 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict185 mac_addr.conflict185, *Pmac_addr.conflict185; + +struct mac_addr.conflict185 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict181 mac_addr.conflict181, *Pmac_addr.conflict181; + +struct mac_addr.conflict181 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict187 mac_addr.conflict187, *Pmac_addr.conflict187; + +struct mac_addr.conflict187 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict217 mac_addr.conflict217, *Pmac_addr.conflict217; + +struct mac_addr.conflict217 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict211 mac_addr.conflict211, *Pmac_addr.conflict211; + +struct mac_addr.conflict211 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict206 mac_addr.conflict206, *Pmac_addr.conflict206; + +struct mac_addr.conflict206 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict204 mac_addr.conflict204, *Pmac_addr.conflict204; + +struct mac_addr.conflict204 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict200 mac_addr.conflict200, *Pmac_addr.conflict200; + +struct mac_addr.conflict200 { + uint16_t array[3]; +}; + +typedef struct lwip_cyclic_timer.conflict3 lwip_cyclic_timer.conflict3, *Plwip_cyclic_timer.conflict3; + +struct lwip_cyclic_timer.conflict3 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct mac_addr.conflict238 mac_addr.conflict238, *Pmac_addr.conflict238; + +struct mac_addr.conflict238 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict233 mac_addr.conflict233, *Pmac_addr.conflict233; + +struct mac_addr.conflict233 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict227 mac_addr.conflict227, *Pmac_addr.conflict227; + +struct mac_addr.conflict227 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict251 mac_addr.conflict251, *Pmac_addr.conflict251; + +struct mac_addr.conflict251 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict257 mac_addr.conflict257, *Pmac_addr.conflict257; + +struct mac_addr.conflict257 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict255 mac_addr.conflict255, *Pmac_addr.conflict255; + +struct mac_addr.conflict255 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict249 mac_addr.conflict249, *Pmac_addr.conflict249; + +struct mac_addr.conflict249 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict247 mac_addr.conflict247, *Pmac_addr.conflict247; + +struct mac_addr.conflict247 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict242 mac_addr.conflict242, *Pmac_addr.conflict242; + +struct mac_addr.conflict242 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict151 anon_struct.conflict151, *Panon_struct.conflict151; + +struct anon_struct.conflict151 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict194 anon_struct.conflict194, *Panon_struct.conflict194; + +struct anon_struct.conflict194 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct mac_addr.conflict21 mac_addr.conflict21, *Pmac_addr.conflict21; + +struct mac_addr.conflict21 { + uint16_t array[3]; +}; + +typedef uint16_t ke_state_t.conflict; + +typedef struct mac_addr.conflict16 mac_addr.conflict16, *Pmac_addr.conflict16; + +struct mac_addr.conflict16 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict31 mac_addr.conflict31, *Pmac_addr.conflict31; + +struct mac_addr.conflict31 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict26 mac_addr.conflict26, *Pmac_addr.conflict26; + +struct mac_addr.conflict26 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict36 mac_addr.conflict36, *Pmac_addr.conflict36; + +struct mac_addr.conflict36 { + uint16_t array[3]; +}; + +typedef struct ke_state_handler ke_state_handler, *Pke_state_handler; + +typedef struct ke_msg_handler ke_msg_handler, *Pke_msg_handler; + +typedef uint16_t ke_msg_id_t; + +struct ke_state_handler { + struct ke_msg_handler * msg_table; + uint16_t msg_cnt; + undefined field_0x6; + undefined field_0x7; +}; + +struct ke_msg_handler { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct mac_addr.conflict97 mac_addr.conflict97, *Pmac_addr.conflict97; + +struct mac_addr.conflict97 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict93 mac_addr.conflict93, *Pmac_addr.conflict93; + +struct mac_addr.conflict93 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict91 mac_addr.conflict91, *Pmac_addr.conflict91; + +struct mac_addr.conflict91 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict46 mac_addr.conflict46, *Pmac_addr.conflict46; + +struct mac_addr.conflict46 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict64 mac_addr.conflict64, *Pmac_addr.conflict64; + +struct mac_addr.conflict64 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict56 mac_addr.conflict56, *Pmac_addr.conflict56; + +struct mac_addr.conflict56 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict71 mac_addr.conflict71, *Pmac_addr.conflict71; + +struct mac_addr.conflict71 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict87 mac_addr.conflict87, *Pmac_addr.conflict87; + +struct mac_addr.conflict87 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict85 mac_addr.conflict85, *Pmac_addr.conflict85; + +struct mac_addr.conflict85 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict83 mac_addr.conflict83, *Pmac_addr.conflict83; + +struct mac_addr.conflict83 { + uint16_t array[3]; +}; + +typedef enum anon_enum_8_for_oob_config.conflict { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BT_CONN_AUTO_CONNECT=0, + BT_CONN_AUTO_FEATURE_EXCH=13, + BT_CONN_AUTO_PHY_COMPLETE=12, + BT_CONN_AUTO_PHY_UPDATE=7, + BT_CONN_AUTO_VERSION_INFO=14, + BT_CONN_BR_LEGACY_SECURE=1, + BT_CONN_BR_NOBOND=4, + BT_CONN_BR_PAIRING=3, + BT_CONN_BR_PAIRING_INITIATOR=5, + BT_CONN_CLEANUP=6, + BT_CONN_FORCE_PAIR=11, + BT_CONN_NUM_FLAGS=15, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_SLAVE_PARAM_L2CAP=10, + BT_CONN_SLAVE_PARAM_SET=9, + BT_CONN_SLAVE_PARAM_UPDATE=8, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_CONN_USER=2, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_EVENT_CMD_TX=0, + BT_EVENT_CONN_TX_QUEUE=1, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_KEYS_ALL=63, + BT_KEYS_AUTHENTICATED=1, + BT_KEYS_DEBUG=2, + BT_KEYS_ID_PENDING_ADD=4, + BT_KEYS_ID_PENDING_DEL=8, + BT_KEYS_IRK=2, + BT_KEYS_LOCAL_CSRK=8, + BT_KEYS_LTK=4, + BT_KEYS_LTK_P256=32, + BT_KEYS_REMOTE_CSRK=16, + BT_KEYS_SC=16, + BT_KEYS_SLAVE_LTK=1, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_LE_SCAN_FILTER_DUPLICATE=1, + BT_LE_SCAN_FILTER_EXTENDED=4, + BT_LE_SCAN_FILTER_WHITELIST=2, + BT_QUIRK_NO_RESET=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + I2C_IRQn=48, + INFO_PAR_OGF=4, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_IDLE=0, + KE_EVT_RUNNING=1, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MEXT_IRQn=11, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + POOL_LINKED_LIST=0, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PT_ENTRY_FW_CPU0=0, + PT_ENTRY_FW_CPU1=1, + PT_ENTRY_MAX=16, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VFS_TYPE_BLOCK_DEV=2, + VFS_TYPE_CHAR_DEV=1, + VFS_TYPE_FS_DEV=3, + VFS_TYPE_NOT_INIT=0, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4 +} anon_enum_8_for_oob_config.conflict; + +typedef enum anon_enum_8_for_oob_config { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_LE_SCAN_FILTER_DUPLICATE=1, + BT_LE_SCAN_FILTER_EXTENDED=4, + BT_LE_SCAN_FILTER_WHITELIST=2, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + I2C_IRQn=48, + INFO_PAR_OGF=4, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_IDLE=0, + KE_EVT_RUNNING=1, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MEXT_IRQn=11, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + POOL_LINKED_LIST=0, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PT_ENTRY_FW_CPU0=0, + PT_ENTRY_FW_CPU1=1, + PT_ENTRY_MAX=16, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VFS_TYPE_BLOCK_DEV=2, + VFS_TYPE_CHAR_DEV=1, + VFS_TYPE_FS_DEV=3, + VFS_TYPE_NOT_INIT=0, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4 +} anon_enum_8_for_oob_config; + +typedef union anon_union_for_u.conflict anon_union_for_u.conflict, *Panon_union_for_u.conflict; + +typedef struct anon_struct.conflict50 anon_struct.conflict50, *Panon_struct.conflict50; + +typedef struct anon_struct.conflict51 anon_struct.conflict51, *Panon_struct.conflict51; + +typedef struct anon_struct.conflict52 anon_struct.conflict52, *Panon_struct.conflict52; + +typedef struct anon_struct.conflict53 anon_struct.conflict53, *Panon_struct.conflict53; + +typedef struct anon_struct.conflict54 anon_struct.conflict54, *Panon_struct.conflict54; + +struct anon_struct.conflict54 { + u8 action_code; + u8 dialog_token; + u8 tpc_elem_id; + u8 tpc_elem_length; +}; + +struct anon_struct.conflict53 { + u8 action_code; + u8 membership[8]; + u8 position[16]; +}; + +struct anon_struct.conflict52 { + u8 action_code; + u8 operating_mode; +}; + +struct anon_struct.conflict51 { + u8 action_code; + u8 dialog_token; + __le16 capability; + u8[0] variable; +}; + +struct anon_struct.conflict50 { + u8 action_code; + u8 chanwidth; +}; + +union anon_union_for_u.conflict { + struct anon_struct.conflict57 wme_action; + struct anon_struct.conflict57 chan_switch; + struct anon_struct.conflict57 ext_chan_switch; + struct anon_struct.conflict57 measurement; + struct anon_struct.conflict57 addba_req; + struct anon_struct.conflict57 addba_resp; + struct anon_struct.conflict57 delba; + struct anon_struct.conflict57 self_prot; + struct anon_struct.conflict57 mesh_action; + struct anon_struct.conflict57 sa_query; + struct anon_struct.conflict57 ht_smps; + struct anon_struct.conflict50 ht_notify_cw; + struct anon_struct.conflict51 tdls_discover_resp; + struct anon_struct.conflict52 vht_opmode_notif; + struct anon_struct.conflict53 vht_group_notif; + struct anon_struct.conflict54 tpc_report; + struct anon_struct.conflict57 ftm; +}; + + +// WARNING! conflicting data type names: /DWARF/_UNCATEGORIZED_/anon_struct/anon_union_for_u - /DWARF/timers.c/tmrTimerQueueMessage/anon_union_for_u + +typedef union anon_union_for_u.conflict2 anon_union_for_u.conflict2, *Panon_union_for_u.conflict2; + +typedef struct anon_struct.conflict42 anon_struct.conflict42, *Panon_struct.conflict42; + +typedef struct anon_struct.conflict43 anon_struct.conflict43, *Panon_struct.conflict43; + +typedef struct anon_struct.conflict44 anon_struct.conflict44, *Panon_struct.conflict44; + +typedef struct anon_struct.conflict45 anon_struct.conflict45, *Panon_struct.conflict45; + +typedef struct anon_struct.conflict46 anon_struct.conflict46, *Panon_struct.conflict46; + +typedef struct anon_struct.conflict47 anon_struct.conflict47, *Panon_struct.conflict47; + +typedef struct anon_struct.conflict48 anon_struct.conflict48, *Panon_struct.conflict48; + +typedef struct anon_struct.conflict49 anon_struct.conflict49, *Panon_struct.conflict49; + +typedef struct anon_struct.conflict55 anon_struct.conflict55, *Panon_struct.conflict55; + +struct anon_struct.conflict55 { + u8 action_code; + u8 dialog_token; + u8 follow_up; + u8 tod[6]; + u8 toa[6]; + __le16 tod_error; + __le16 toa_error; + u8[0] variable; +}; + +struct anon_struct.conflict43 { + u8 action_code; + u8[0] variable; +}; + +struct anon_struct.conflict42 { + u8 action_code; + u8 dialog_token; + u8 status_code; + u8[0] variable; +}; + +struct anon_struct.conflict49 { + u8 action; + u8 smps_control; +}; + +struct anon_struct.conflict48 { + u8 action; + u8 trans_id[2]; +}; + +struct anon_struct.conflict47 { + u8 action_code; + __le16 params; + __le16 reason_code; +}; + +struct anon_struct.conflict46 { + u8 action_code; + u8 dialog_token; + __le16 status; + __le16 capab; + __le16 timeout; +}; + +struct anon_struct.conflict45 { + u8 action_code; + u8 dialog_token; + __le16 capab; + __le16 timeout; + __le16 start_seq_num; +}; + +struct anon_struct.conflict44 { + u8 action_code; + u8 dialog_token; + u8 element_id; + u8 length; +}; + +union anon_union_for_u.conflict2 { + struct anon_struct.conflict42 wme_action; + struct anon_struct.conflict43 chan_switch; + struct anon_struct.conflict43 ext_chan_switch; + struct anon_struct.conflict44 measurement; + struct anon_struct.conflict45 addba_req; + struct anon_struct.conflict46 addba_resp; + struct anon_struct.conflict47 delba; + struct anon_struct.conflict43 self_prot; + struct anon_struct.conflict43 mesh_action; + struct anon_struct.conflict48 sa_query; + struct anon_struct.conflict49 ht_smps; + struct anon_struct.conflict50 ht_notify_cw; + struct anon_struct.conflict51 tdls_discover_resp; + struct anon_struct.conflict52 vht_opmode_notif; + struct anon_struct.conflict53 vht_group_notif; + struct anon_struct.conflict54 tpc_report; + struct anon_struct.conflict55 ftm; +}; + +typedef union anon_union_for_u.conflict1 anon_union_for_u.conflict1, *Panon_union_for_u.conflict1; + +union anon_union_for_u.conflict1 { + struct anon_struct.conflict58 wme_action; + struct anon_struct.conflict58 chan_switch; + struct anon_struct.conflict58 ext_chan_switch; + struct anon_struct.conflict58 measurement; + struct anon_struct.conflict58 addba_req; + struct anon_struct.conflict58 addba_resp; + struct anon_struct.conflict58 delba; + struct anon_struct.conflict58 self_prot; + struct anon_struct.conflict58 mesh_action; + struct anon_struct.conflict58 sa_query; + struct anon_struct.conflict58 ht_smps; + struct anon_struct.conflict50 ht_notify_cw; + struct anon_struct.conflict51 tdls_discover_resp; + struct anon_struct.conflict52 vht_opmode_notif; + struct anon_struct.conflict53 vht_group_notif; + struct anon_struct.conflict54 tpc_report; + struct anon_struct.conflict58 ftm; +}; + +typedef enum anon_enum_8_for_oob_config.conflict3 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BT_CONN_AUTO_CONNECT=0, + BT_CONN_AUTO_FEATURE_EXCH=13, + BT_CONN_AUTO_PHY_COMPLETE=12, + BT_CONN_AUTO_PHY_UPDATE=7, + BT_CONN_AUTO_VERSION_INFO=14, + BT_CONN_BR_LEGACY_SECURE=1, + BT_CONN_BR_NOBOND=4, + BT_CONN_BR_PAIRING=3, + BT_CONN_BR_PAIRING_INITIATOR=5, + BT_CONN_CLEANUP=6, + BT_CONN_FORCE_PAIR=11, + BT_CONN_NUM_FLAGS=15, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_SLAVE_PARAM_L2CAP=10, + BT_CONN_SLAVE_PARAM_SET=9, + BT_CONN_SLAVE_PARAM_UPDATE=8, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_CONN_USER=2, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_EVENT_CMD_TX=0, + BT_EVENT_CONN_TX_QUEUE=1, + BT_GATT_DISCOVER_ATTRIBUTE=5, + BT_GATT_DISCOVER_CHARACTERISTIC=3, + BT_GATT_DISCOVER_DESCRIPTOR=4, + BT_GATT_DISCOVER_INCLUDE=2, + BT_GATT_DISCOVER_PRIMARY=0, + BT_GATT_DISCOVER_SECONDARY=1, + BT_GATT_ITER_CONTINUE=1, + BT_GATT_ITER_STOP=0, + BT_GATT_PERM_NONE=0, + BT_GATT_PERM_PREPARE_WRITE=64, + BT_GATT_PERM_READ=1, + BT_GATT_PERM_READ_AUTHEN=16, + BT_GATT_PERM_READ_ENCRYPT=4, + BT_GATT_PERM_WRITE=2, + BT_GATT_PERM_WRITE_AUTHEN=32, + BT_GATT_PERM_WRITE_ENCRYPT=8, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_HCI_ACL_DATA=1, + BT_HCI_CMD=0, + BT_HCI_CMD_CMP_EVT=2, + BT_HCI_CMD_STAT_EVT=3, + BT_HCI_EVT=5, + BT_HCI_LE_EVT=4, + BT_KEYS_ALL=63, + BT_KEYS_AUTHENTICATED=1, + BT_KEYS_DEBUG=2, + BT_KEYS_ID_PENDING_ADD=4, + BT_KEYS_ID_PENDING_DEL=8, + BT_KEYS_IRK=2, + BT_KEYS_LOCAL_CSRK=8, + BT_KEYS_LTK=4, + BT_KEYS_LTK_P256=32, + BT_KEYS_REMOTE_CSRK=16, + BT_KEYS_SC=16, + BT_KEYS_SLAVE_LTK=1, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_LE_SCAN_FILTER_DUPLICATE=1, + BT_LE_SCAN_FILTER_EXTENDED=4, + BT_LE_SCAN_FILTER_WHITELIST=2, + BT_QUIRK_NO_RESET=1, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + I2C_IRQn=48, + INFO_PAR_OGF=4, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_IDLE=0, + KE_EVT_RUNNING=1, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + K_WORK_STATE_PENDING=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MEXT_IRQn=11, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + POOL_LINKED_LIST=0, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PT_ENTRY_FW_CPU0=0, + PT_ENTRY_FW_CPU1=1, + PT_ENTRY_MAX=16, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SC_INDICATE_PENDING=1, + SC_NUM_FLAGS=2, + SC_RANGE_CHANGED=0, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SMP_FLAG_BOND=12, + SMP_FLAG_BR_CONNECTED=17, + SMP_FLAG_BR_PAIR=18, + SMP_FLAG_CFM_DELAYED=0, + SMP_FLAG_CT2=19, + SMP_FLAG_DERIVE_LK=16, + SMP_FLAG_DHCHECK_WAIT=15, + SMP_FLAG_DHKEY_PENDING=7, + SMP_FLAG_DHKEY_SEND=8, + SMP_FLAG_DISPLAY=10, + SMP_FLAG_ENC_PENDING=1, + SMP_FLAG_KEYS_DISTR=2, + SMP_FLAG_OOB_PENDING=11, + SMP_FLAG_PAIRING=3, + SMP_FLAG_PKEY_SEND=6, + SMP_FLAG_SC=5, + SMP_FLAG_SC_DEBUG_KEY=13, + SMP_FLAG_SEC_REQ=14, + SMP_FLAG_TIMEOUT=4, + SMP_FLAG_USER=9, + SMP_NUM_FLAGS=20, + SPI_IRQn=43, + STAT_PAR_OGF=5, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VFS_TYPE_BLOCK_DEV=2, + VFS_TYPE_CHAR_DEV=1, + VFS_TYPE_FS_DEV=3, + VFS_TYPE_NOT_INIT=0, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4 +} anon_enum_8_for_oob_config.conflict3; + +typedef enum anon_enum_8_for_oob_config.conflict4 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + ATT_DISCONNECTED=2, + ATT_NUM_FLAGS=3, + ATT_PENDING_CFM=1, + ATT_PENDING_RSP=0, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BT_CONN_AUTO_CONNECT=0, + BT_CONN_AUTO_FEATURE_EXCH=13, + BT_CONN_AUTO_PHY_COMPLETE=12, + BT_CONN_AUTO_PHY_UPDATE=7, + BT_CONN_AUTO_VERSION_INFO=14, + BT_CONN_BR_LEGACY_SECURE=1, + BT_CONN_BR_NOBOND=4, + BT_CONN_BR_PAIRING=3, + BT_CONN_BR_PAIRING_INITIATOR=5, + BT_CONN_CLEANUP=6, + BT_CONN_FORCE_PAIR=11, + BT_CONN_NUM_FLAGS=15, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_SLAVE_PARAM_L2CAP=10, + BT_CONN_SLAVE_PARAM_SET=9, + BT_CONN_SLAVE_PARAM_UPDATE=8, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_CONN_USER=2, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_EVENT_CMD_TX=0, + BT_EVENT_CONN_TX_QUEUE=1, + BT_GATT_DISCOVER_ATTRIBUTE=5, + BT_GATT_DISCOVER_CHARACTERISTIC=3, + BT_GATT_DISCOVER_DESCRIPTOR=4, + BT_GATT_DISCOVER_INCLUDE=2, + BT_GATT_DISCOVER_PRIMARY=0, + BT_GATT_DISCOVER_SECONDARY=1, + BT_GATT_ITER_CONTINUE=1, + BT_GATT_ITER_STOP=0, + BT_GATT_PERM_NONE=0, + BT_GATT_PERM_PREPARE_WRITE=64, + BT_GATT_PERM_READ=1, + BT_GATT_PERM_READ_AUTHEN=16, + BT_GATT_PERM_READ_ENCRYPT=4, + BT_GATT_PERM_WRITE=2, + BT_GATT_PERM_WRITE_AUTHEN=32, + BT_GATT_PERM_WRITE_ENCRYPT=8, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_GATT_WRITE_FLAG_CMD=2, + BT_GATT_WRITE_FLAG_PREPARE=1, + BT_HCI_ACL_DATA=1, + BT_HCI_CMD=0, + BT_HCI_CMD_CMP_EVT=2, + BT_HCI_CMD_STAT_EVT=3, + BT_HCI_EVT=5, + BT_HCI_LE_EVT=4, + BT_KEYS_ALL=63, + BT_KEYS_AUTHENTICATED=1, + BT_KEYS_DEBUG=2, + BT_KEYS_ID_PENDING_ADD=4, + BT_KEYS_ID_PENDING_DEL=8, + BT_KEYS_IRK=2, + BT_KEYS_LOCAL_CSRK=8, + BT_KEYS_LTK=4, + BT_KEYS_LTK_P256=32, + BT_KEYS_REMOTE_CSRK=16, + BT_KEYS_SC=16, + BT_KEYS_SLAVE_LTK=1, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_LE_SCAN_FILTER_DUPLICATE=1, + BT_LE_SCAN_FILTER_EXTENDED=4, + BT_LE_SCAN_FILTER_WHITELIST=2, + BT_QUIRK_NO_RESET=1, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + I2C_IRQn=48, + INFO_PAR_OGF=4, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_IDLE=0, + KE_EVT_RUNNING=1, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + K_WORK_STATE_PENDING=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MEXT_IRQn=11, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + POOL_LINKED_LIST=0, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PT_ENTRY_FW_CPU0=0, + PT_ENTRY_FW_CPU1=1, + PT_ENTRY_MAX=16, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SC_INDICATE_PENDING=1, + SC_NUM_FLAGS=2, + SC_RANGE_CHANGED=0, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SMP_FLAG_BOND=12, + SMP_FLAG_BR_CONNECTED=17, + SMP_FLAG_BR_PAIR=18, + SMP_FLAG_CFM_DELAYED=0, + SMP_FLAG_CT2=19, + SMP_FLAG_DERIVE_LK=16, + SMP_FLAG_DHCHECK_WAIT=15, + SMP_FLAG_DHKEY_PENDING=7, + SMP_FLAG_DHKEY_SEND=8, + SMP_FLAG_DISPLAY=10, + SMP_FLAG_ENC_PENDING=1, + SMP_FLAG_KEYS_DISTR=2, + SMP_FLAG_OOB_PENDING=11, + SMP_FLAG_PAIRING=3, + SMP_FLAG_PKEY_SEND=6, + SMP_FLAG_SC=5, + SMP_FLAG_SC_DEBUG_KEY=13, + SMP_FLAG_SEC_REQ=14, + SMP_FLAG_TIMEOUT=4, + SMP_FLAG_USER=9, + SMP_NUM_FLAGS=20, + SPI_IRQn=43, + STAT_PAR_OGF=5, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VFS_TYPE_BLOCK_DEV=2, + VFS_TYPE_CHAR_DEV=1, + VFS_TYPE_FS_DEV=3, + VFS_TYPE_NOT_INIT=0, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4 +} anon_enum_8_for_oob_config.conflict4; + +typedef enum anon_enum_8_for_oob_config.conflict1 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BT_CONN_AUTO_CONNECT=0, + BT_CONN_AUTO_FEATURE_EXCH=13, + BT_CONN_AUTO_PHY_COMPLETE=12, + BT_CONN_AUTO_PHY_UPDATE=7, + BT_CONN_AUTO_VERSION_INFO=14, + BT_CONN_BR_LEGACY_SECURE=1, + BT_CONN_BR_NOBOND=4, + BT_CONN_BR_PAIRING=3, + BT_CONN_BR_PAIRING_INITIATOR=5, + BT_CONN_CLEANUP=6, + BT_CONN_FORCE_PAIR=11, + BT_CONN_NUM_FLAGS=15, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_SLAVE_PARAM_L2CAP=10, + BT_CONN_SLAVE_PARAM_SET=9, + BT_CONN_SLAVE_PARAM_UPDATE=8, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_CONN_USER=2, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_EVENT_CMD_TX=0, + BT_EVENT_CONN_TX_QUEUE=1, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_KEYS_ALL=63, + BT_KEYS_AUTHENTICATED=1, + BT_KEYS_DEBUG=2, + BT_KEYS_ID_PENDING_ADD=4, + BT_KEYS_ID_PENDING_DEL=8, + BT_KEYS_IRK=2, + BT_KEYS_LOCAL_CSRK=8, + BT_KEYS_LTK=4, + BT_KEYS_LTK_P256=32, + BT_KEYS_REMOTE_CSRK=16, + BT_KEYS_SC=16, + BT_KEYS_SLAVE_LTK=1, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_LE_SCAN_FILTER_DUPLICATE=1, + BT_LE_SCAN_FILTER_EXTENDED=4, + BT_LE_SCAN_FILTER_WHITELIST=2, + BT_QUIRK_NO_RESET=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + I2C_IRQn=48, + INFO_PAR_OGF=4, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_IDLE=0, + KE_EVT_RUNNING=1, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MEXT_IRQn=11, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + POOL_LINKED_LIST=0, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PT_ENTRY_FW_CPU0=0, + PT_ENTRY_FW_CPU1=1, + PT_ENTRY_MAX=16, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SMP_FLAG_BOND=12, + SMP_FLAG_BR_CONNECTED=17, + SMP_FLAG_BR_PAIR=18, + SMP_FLAG_CFM_DELAYED=0, + SMP_FLAG_CT2=19, + SMP_FLAG_DERIVE_LK=16, + SMP_FLAG_DHCHECK_WAIT=15, + SMP_FLAG_DHKEY_PENDING=7, + SMP_FLAG_DHKEY_SEND=8, + SMP_FLAG_DISPLAY=10, + SMP_FLAG_ENC_PENDING=1, + SMP_FLAG_KEYS_DISTR=2, + SMP_FLAG_OOB_PENDING=11, + SMP_FLAG_PAIRING=3, + SMP_FLAG_PKEY_SEND=6, + SMP_FLAG_SC=5, + SMP_FLAG_SC_DEBUG_KEY=13, + SMP_FLAG_SEC_REQ=14, + SMP_FLAG_TIMEOUT=4, + SMP_FLAG_USER=9, + SMP_NUM_FLAGS=20, + SPI_IRQn=43, + STAT_PAR_OGF=5, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VFS_TYPE_BLOCK_DEV=2, + VFS_TYPE_CHAR_DEV=1, + VFS_TYPE_FS_DEV=3, + VFS_TYPE_NOT_INIT=0, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4 +} anon_enum_8_for_oob_config.conflict1; + +typedef enum anon_enum_8_for_oob_config.conflict2 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BT_CONN_AUTO_CONNECT=0, + BT_CONN_AUTO_FEATURE_EXCH=13, + BT_CONN_AUTO_PHY_COMPLETE=12, + BT_CONN_AUTO_PHY_UPDATE=7, + BT_CONN_AUTO_VERSION_INFO=14, + BT_CONN_BR_LEGACY_SECURE=1, + BT_CONN_BR_NOBOND=4, + BT_CONN_BR_PAIRING=3, + BT_CONN_BR_PAIRING_INITIATOR=5, + BT_CONN_CLEANUP=6, + BT_CONN_FORCE_PAIR=11, + BT_CONN_NUM_FLAGS=15, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_SLAVE_PARAM_L2CAP=10, + BT_CONN_SLAVE_PARAM_SET=9, + BT_CONN_SLAVE_PARAM_UPDATE=8, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_CONN_USER=2, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_EVENT_CMD_TX=0, + BT_EVENT_CONN_TX_QUEUE=1, + BT_GATT_DISCOVER_ATTRIBUTE=5, + BT_GATT_DISCOVER_CHARACTERISTIC=3, + BT_GATT_DISCOVER_DESCRIPTOR=4, + BT_GATT_DISCOVER_INCLUDE=2, + BT_GATT_DISCOVER_PRIMARY=0, + BT_GATT_DISCOVER_SECONDARY=1, + BT_GATT_ITER_CONTINUE=1, + BT_GATT_ITER_STOP=0, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_HCI_ACL_DATA=1, + BT_HCI_CMD=0, + BT_HCI_CMD_CMP_EVT=2, + BT_HCI_CMD_STAT_EVT=3, + BT_HCI_EVT=5, + BT_HCI_LE_EVT=4, + BT_KEYS_ALL=63, + BT_KEYS_AUTHENTICATED=1, + BT_KEYS_DEBUG=2, + BT_KEYS_ID_PENDING_ADD=4, + BT_KEYS_ID_PENDING_DEL=8, + BT_KEYS_IRK=2, + BT_KEYS_LOCAL_CSRK=8, + BT_KEYS_LTK=4, + BT_KEYS_LTK_P256=32, + BT_KEYS_REMOTE_CSRK=16, + BT_KEYS_SC=16, + BT_KEYS_SLAVE_LTK=1, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_LE_SCAN_FILTER_DUPLICATE=1, + BT_LE_SCAN_FILTER_EXTENDED=4, + BT_LE_SCAN_FILTER_WHITELIST=2, + BT_QUIRK_NO_RESET=1, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + I2C_IRQn=48, + INFO_PAR_OGF=4, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_IDLE=0, + KE_EVT_RUNNING=1, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + K_WORK_STATE_PENDING=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MEXT_IRQn=11, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + POOL_LINKED_LIST=0, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PT_ENTRY_FW_CPU0=0, + PT_ENTRY_FW_CPU1=1, + PT_ENTRY_MAX=16, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SMP_FLAG_BOND=12, + SMP_FLAG_BR_CONNECTED=17, + SMP_FLAG_BR_PAIR=18, + SMP_FLAG_CFM_DELAYED=0, + SMP_FLAG_CT2=19, + SMP_FLAG_DERIVE_LK=16, + SMP_FLAG_DHCHECK_WAIT=15, + SMP_FLAG_DHKEY_PENDING=7, + SMP_FLAG_DHKEY_SEND=8, + SMP_FLAG_DISPLAY=10, + SMP_FLAG_ENC_PENDING=1, + SMP_FLAG_KEYS_DISTR=2, + SMP_FLAG_OOB_PENDING=11, + SMP_FLAG_PAIRING=3, + SMP_FLAG_PKEY_SEND=6, + SMP_FLAG_SC=5, + SMP_FLAG_SC_DEBUG_KEY=13, + SMP_FLAG_SEC_REQ=14, + SMP_FLAG_TIMEOUT=4, + SMP_FLAG_USER=9, + SMP_NUM_FLAGS=20, + SPI_IRQn=43, + STAT_PAR_OGF=5, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VFS_TYPE_BLOCK_DEV=2, + VFS_TYPE_CHAR_DEV=1, + VFS_TYPE_FS_DEV=3, + VFS_TYPE_NOT_INIT=0, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4 +} anon_enum_8_for_oob_config.conflict2; + +typedef union anon_union_for_field_1.conflict anon_union_for_field_1.conflict, *Panon_union_for_field_1.conflict; + +typedef struct anon_struct.conflict80 anon_struct.conflict80, *Panon_struct.conflict80; + +struct anon_struct.conflict80 { + enum anon_enum_8_for_oob_config.conflict oob_config; +}; + +union anon_union_for_field_1.conflict { + struct anon_struct.conflict80 lesc; +}; + +typedef enum anon_enum_8_for_type.conflict { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BT_CONN_AUTO_CONNECT=0, + BT_CONN_AUTO_FEATURE_EXCH=13, + BT_CONN_AUTO_PHY_COMPLETE=12, + BT_CONN_AUTO_PHY_UPDATE=7, + BT_CONN_AUTO_VERSION_INFO=14, + BT_CONN_BR_LEGACY_SECURE=1, + BT_CONN_BR_NOBOND=4, + BT_CONN_BR_PAIRING=3, + BT_CONN_BR_PAIRING_INITIATOR=5, + BT_CONN_CLEANUP=6, + BT_CONN_FORCE_PAIR=11, + BT_CONN_NUM_FLAGS=15, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_SLAVE_PARAM_L2CAP=10, + BT_CONN_SLAVE_PARAM_SET=9, + BT_CONN_SLAVE_PARAM_UPDATE=8, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_CONN_USER=2, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_EVENT_CMD_TX=0, + BT_EVENT_CONN_TX_QUEUE=1, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_KEYS_ALL=63, + BT_KEYS_AUTHENTICATED=1, + BT_KEYS_DEBUG=2, + BT_KEYS_ID_PENDING_ADD=4, + BT_KEYS_ID_PENDING_DEL=8, + BT_KEYS_IRK=2, + BT_KEYS_LOCAL_CSRK=8, + BT_KEYS_LTK=4, + BT_KEYS_LTK_P256=32, + BT_KEYS_REMOTE_CSRK=16, + BT_KEYS_SC=16, + BT_KEYS_SLAVE_LTK=1, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_LE_SCAN_FILTER_DUPLICATE=1, + BT_LE_SCAN_FILTER_EXTENDED=4, + BT_LE_SCAN_FILTER_WHITELIST=2, + BT_QUIRK_NO_RESET=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + I2C_IRQn=48, + INFO_PAR_OGF=4, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_IDLE=0, + KE_EVT_RUNNING=1, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MEXT_IRQn=11, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + POOL_LINKED_LIST=0, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PT_ENTRY_FW_CPU0=0, + PT_ENTRY_FW_CPU1=1, + PT_ENTRY_MAX=16, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VFS_TYPE_BLOCK_DEV=2, + VFS_TYPE_CHAR_DEV=1, + VFS_TYPE_FS_DEV=3, + VFS_TYPE_NOT_INIT=0, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4 +} anon_enum_8_for_type.conflict; + +typedef union anon_union_for_field_1.conflict2 anon_union_for_field_1.conflict2, *Panon_union_for_field_1.conflict2; + +typedef struct anon_struct.conflict102 anon_struct.conflict102, *Panon_struct.conflict102; + +struct anon_struct.conflict102 { + enum anon_enum_8_for_oob_config.conflict2 oob_config; +}; + +union anon_union_for_field_1.conflict2 { + struct anon_struct.conflict102 lesc; +}; + +typedef enum anon_enum_8_for_type.conflict1 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BT_CONN_AUTO_CONNECT=0, + BT_CONN_AUTO_FEATURE_EXCH=13, + BT_CONN_AUTO_PHY_COMPLETE=12, + BT_CONN_AUTO_PHY_UPDATE=7, + BT_CONN_AUTO_VERSION_INFO=14, + BT_CONN_BR_LEGACY_SECURE=1, + BT_CONN_BR_NOBOND=4, + BT_CONN_BR_PAIRING=3, + BT_CONN_BR_PAIRING_INITIATOR=5, + BT_CONN_CLEANUP=6, + BT_CONN_FORCE_PAIR=11, + BT_CONN_NUM_FLAGS=15, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_SLAVE_PARAM_L2CAP=10, + BT_CONN_SLAVE_PARAM_SET=9, + BT_CONN_SLAVE_PARAM_UPDATE=8, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_CONN_USER=2, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_EVENT_CMD_TX=0, + BT_EVENT_CONN_TX_QUEUE=1, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_KEYS_ALL=63, + BT_KEYS_AUTHENTICATED=1, + BT_KEYS_DEBUG=2, + BT_KEYS_ID_PENDING_ADD=4, + BT_KEYS_ID_PENDING_DEL=8, + BT_KEYS_IRK=2, + BT_KEYS_LOCAL_CSRK=8, + BT_KEYS_LTK=4, + BT_KEYS_LTK_P256=32, + BT_KEYS_REMOTE_CSRK=16, + BT_KEYS_SC=16, + BT_KEYS_SLAVE_LTK=1, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_LE_SCAN_FILTER_DUPLICATE=1, + BT_LE_SCAN_FILTER_EXTENDED=4, + BT_LE_SCAN_FILTER_WHITELIST=2, + BT_QUIRK_NO_RESET=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + I2C_IRQn=48, + INFO_PAR_OGF=4, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_IDLE=0, + KE_EVT_RUNNING=1, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MEXT_IRQn=11, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + POOL_LINKED_LIST=0, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PT_ENTRY_FW_CPU0=0, + PT_ENTRY_FW_CPU1=1, + PT_ENTRY_MAX=16, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SMP_FLAG_BOND=12, + SMP_FLAG_BR_CONNECTED=17, + SMP_FLAG_BR_PAIR=18, + SMP_FLAG_CFM_DELAYED=0, + SMP_FLAG_CT2=19, + SMP_FLAG_DERIVE_LK=16, + SMP_FLAG_DHCHECK_WAIT=15, + SMP_FLAG_DHKEY_PENDING=7, + SMP_FLAG_DHKEY_SEND=8, + SMP_FLAG_DISPLAY=10, + SMP_FLAG_ENC_PENDING=1, + SMP_FLAG_KEYS_DISTR=2, + SMP_FLAG_OOB_PENDING=11, + SMP_FLAG_PAIRING=3, + SMP_FLAG_PKEY_SEND=6, + SMP_FLAG_SC=5, + SMP_FLAG_SC_DEBUG_KEY=13, + SMP_FLAG_SEC_REQ=14, + SMP_FLAG_TIMEOUT=4, + SMP_FLAG_USER=9, + SMP_NUM_FLAGS=20, + SPI_IRQn=43, + STAT_PAR_OGF=5, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VFS_TYPE_BLOCK_DEV=2, + VFS_TYPE_CHAR_DEV=1, + VFS_TYPE_FS_DEV=3, + VFS_TYPE_NOT_INIT=0, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4 +} anon_enum_8_for_type.conflict1; + +typedef union anon_union_for_field_1.conflict1 anon_union_for_field_1.conflict1, *Panon_union_for_field_1.conflict1; + +typedef struct anon_struct.conflict87 anon_struct.conflict87, *Panon_struct.conflict87; + +struct anon_struct.conflict87 { + enum anon_enum_8_for_oob_config.conflict1 oob_config; +}; + +union anon_union_for_field_1.conflict1 { + struct anon_struct.conflict87 lesc; +}; + +typedef union anon_union_for_field_1.conflict4 anon_union_for_field_1.conflict4, *Panon_union_for_field_1.conflict4; + +typedef struct anon_struct.conflict113 anon_struct.conflict113, *Panon_struct.conflict113; + +struct anon_struct.conflict113 { + enum anon_enum_8_for_oob_config.conflict4 oob_config; +}; + +union anon_union_for_field_1.conflict4 { + struct anon_struct.conflict113 lesc; +}; + +typedef union anon_union_for_field_1.conflict3 anon_union_for_field_1.conflict3, *Panon_union_for_field_1.conflict3; + +typedef struct anon_struct.conflict110 anon_struct.conflict110, *Panon_struct.conflict110; + +struct anon_struct.conflict110 { + enum anon_enum_8_for_oob_config.conflict3 oob_config; +}; + +union anon_union_for_field_1.conflict3 { + struct anon_struct.conflict110 lesc; +}; + +typedef enum anon_enum_8_for_type.conflict4 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + ATT_DISCONNECTED=2, + ATT_NUM_FLAGS=3, + ATT_PENDING_CFM=1, + ATT_PENDING_RSP=0, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BT_CONN_AUTO_CONNECT=0, + BT_CONN_AUTO_FEATURE_EXCH=13, + BT_CONN_AUTO_PHY_COMPLETE=12, + BT_CONN_AUTO_PHY_UPDATE=7, + BT_CONN_AUTO_VERSION_INFO=14, + BT_CONN_BR_LEGACY_SECURE=1, + BT_CONN_BR_NOBOND=4, + BT_CONN_BR_PAIRING=3, + BT_CONN_BR_PAIRING_INITIATOR=5, + BT_CONN_CLEANUP=6, + BT_CONN_FORCE_PAIR=11, + BT_CONN_NUM_FLAGS=15, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_SLAVE_PARAM_L2CAP=10, + BT_CONN_SLAVE_PARAM_SET=9, + BT_CONN_SLAVE_PARAM_UPDATE=8, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_CONN_USER=2, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_EVENT_CMD_TX=0, + BT_EVENT_CONN_TX_QUEUE=1, + BT_GATT_DISCOVER_ATTRIBUTE=5, + BT_GATT_DISCOVER_CHARACTERISTIC=3, + BT_GATT_DISCOVER_DESCRIPTOR=4, + BT_GATT_DISCOVER_INCLUDE=2, + BT_GATT_DISCOVER_PRIMARY=0, + BT_GATT_DISCOVER_SECONDARY=1, + BT_GATT_ITER_CONTINUE=1, + BT_GATT_ITER_STOP=0, + BT_GATT_PERM_NONE=0, + BT_GATT_PERM_PREPARE_WRITE=64, + BT_GATT_PERM_READ=1, + BT_GATT_PERM_READ_AUTHEN=16, + BT_GATT_PERM_READ_ENCRYPT=4, + BT_GATT_PERM_WRITE=2, + BT_GATT_PERM_WRITE_AUTHEN=32, + BT_GATT_PERM_WRITE_ENCRYPT=8, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_GATT_WRITE_FLAG_CMD=2, + BT_GATT_WRITE_FLAG_PREPARE=1, + BT_HCI_ACL_DATA=1, + BT_HCI_CMD=0, + BT_HCI_CMD_CMP_EVT=2, + BT_HCI_CMD_STAT_EVT=3, + BT_HCI_EVT=5, + BT_HCI_LE_EVT=4, + BT_KEYS_ALL=63, + BT_KEYS_AUTHENTICATED=1, + BT_KEYS_DEBUG=2, + BT_KEYS_ID_PENDING_ADD=4, + BT_KEYS_ID_PENDING_DEL=8, + BT_KEYS_IRK=2, + BT_KEYS_LOCAL_CSRK=8, + BT_KEYS_LTK=4, + BT_KEYS_LTK_P256=32, + BT_KEYS_REMOTE_CSRK=16, + BT_KEYS_SC=16, + BT_KEYS_SLAVE_LTK=1, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_LE_SCAN_FILTER_DUPLICATE=1, + BT_LE_SCAN_FILTER_EXTENDED=4, + BT_LE_SCAN_FILTER_WHITELIST=2, + BT_QUIRK_NO_RESET=1, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + I2C_IRQn=48, + INFO_PAR_OGF=4, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_IDLE=0, + KE_EVT_RUNNING=1, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + K_WORK_STATE_PENDING=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MEXT_IRQn=11, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + POOL_LINKED_LIST=0, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PT_ENTRY_FW_CPU0=0, + PT_ENTRY_FW_CPU1=1, + PT_ENTRY_MAX=16, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SC_INDICATE_PENDING=1, + SC_NUM_FLAGS=2, + SC_RANGE_CHANGED=0, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SMP_FLAG_BOND=12, + SMP_FLAG_BR_CONNECTED=17, + SMP_FLAG_BR_PAIR=18, + SMP_FLAG_CFM_DELAYED=0, + SMP_FLAG_CT2=19, + SMP_FLAG_DERIVE_LK=16, + SMP_FLAG_DHCHECK_WAIT=15, + SMP_FLAG_DHKEY_PENDING=7, + SMP_FLAG_DHKEY_SEND=8, + SMP_FLAG_DISPLAY=10, + SMP_FLAG_ENC_PENDING=1, + SMP_FLAG_KEYS_DISTR=2, + SMP_FLAG_OOB_PENDING=11, + SMP_FLAG_PAIRING=3, + SMP_FLAG_PKEY_SEND=6, + SMP_FLAG_SC=5, + SMP_FLAG_SC_DEBUG_KEY=13, + SMP_FLAG_SEC_REQ=14, + SMP_FLAG_TIMEOUT=4, + SMP_FLAG_USER=9, + SMP_NUM_FLAGS=20, + SPI_IRQn=43, + STAT_PAR_OGF=5, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VFS_TYPE_BLOCK_DEV=2, + VFS_TYPE_CHAR_DEV=1, + VFS_TYPE_FS_DEV=3, + VFS_TYPE_NOT_INIT=0, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4 +} anon_enum_8_for_type.conflict4; + +typedef enum anon_enum_8_for_type.conflict3 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BT_CONN_AUTO_CONNECT=0, + BT_CONN_AUTO_FEATURE_EXCH=13, + BT_CONN_AUTO_PHY_COMPLETE=12, + BT_CONN_AUTO_PHY_UPDATE=7, + BT_CONN_AUTO_VERSION_INFO=14, + BT_CONN_BR_LEGACY_SECURE=1, + BT_CONN_BR_NOBOND=4, + BT_CONN_BR_PAIRING=3, + BT_CONN_BR_PAIRING_INITIATOR=5, + BT_CONN_CLEANUP=6, + BT_CONN_FORCE_PAIR=11, + BT_CONN_NUM_FLAGS=15, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_SLAVE_PARAM_L2CAP=10, + BT_CONN_SLAVE_PARAM_SET=9, + BT_CONN_SLAVE_PARAM_UPDATE=8, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_CONN_USER=2, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_EVENT_CMD_TX=0, + BT_EVENT_CONN_TX_QUEUE=1, + BT_GATT_DISCOVER_ATTRIBUTE=5, + BT_GATT_DISCOVER_CHARACTERISTIC=3, + BT_GATT_DISCOVER_DESCRIPTOR=4, + BT_GATT_DISCOVER_INCLUDE=2, + BT_GATT_DISCOVER_PRIMARY=0, + BT_GATT_DISCOVER_SECONDARY=1, + BT_GATT_ITER_CONTINUE=1, + BT_GATT_ITER_STOP=0, + BT_GATT_PERM_NONE=0, + BT_GATT_PERM_PREPARE_WRITE=64, + BT_GATT_PERM_READ=1, + BT_GATT_PERM_READ_AUTHEN=16, + BT_GATT_PERM_READ_ENCRYPT=4, + BT_GATT_PERM_WRITE=2, + BT_GATT_PERM_WRITE_AUTHEN=32, + BT_GATT_PERM_WRITE_ENCRYPT=8, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_HCI_ACL_DATA=1, + BT_HCI_CMD=0, + BT_HCI_CMD_CMP_EVT=2, + BT_HCI_CMD_STAT_EVT=3, + BT_HCI_EVT=5, + BT_HCI_LE_EVT=4, + BT_KEYS_ALL=63, + BT_KEYS_AUTHENTICATED=1, + BT_KEYS_DEBUG=2, + BT_KEYS_ID_PENDING_ADD=4, + BT_KEYS_ID_PENDING_DEL=8, + BT_KEYS_IRK=2, + BT_KEYS_LOCAL_CSRK=8, + BT_KEYS_LTK=4, + BT_KEYS_LTK_P256=32, + BT_KEYS_REMOTE_CSRK=16, + BT_KEYS_SC=16, + BT_KEYS_SLAVE_LTK=1, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_LE_SCAN_FILTER_DUPLICATE=1, + BT_LE_SCAN_FILTER_EXTENDED=4, + BT_LE_SCAN_FILTER_WHITELIST=2, + BT_QUIRK_NO_RESET=1, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + I2C_IRQn=48, + INFO_PAR_OGF=4, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_IDLE=0, + KE_EVT_RUNNING=1, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + K_WORK_STATE_PENDING=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MEXT_IRQn=11, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + POOL_LINKED_LIST=0, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PT_ENTRY_FW_CPU0=0, + PT_ENTRY_FW_CPU1=1, + PT_ENTRY_MAX=16, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SC_INDICATE_PENDING=1, + SC_NUM_FLAGS=2, + SC_RANGE_CHANGED=0, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SMP_FLAG_BOND=12, + SMP_FLAG_BR_CONNECTED=17, + SMP_FLAG_BR_PAIR=18, + SMP_FLAG_CFM_DELAYED=0, + SMP_FLAG_CT2=19, + SMP_FLAG_DERIVE_LK=16, + SMP_FLAG_DHCHECK_WAIT=15, + SMP_FLAG_DHKEY_PENDING=7, + SMP_FLAG_DHKEY_SEND=8, + SMP_FLAG_DISPLAY=10, + SMP_FLAG_ENC_PENDING=1, + SMP_FLAG_KEYS_DISTR=2, + SMP_FLAG_OOB_PENDING=11, + SMP_FLAG_PAIRING=3, + SMP_FLAG_PKEY_SEND=6, + SMP_FLAG_SC=5, + SMP_FLAG_SC_DEBUG_KEY=13, + SMP_FLAG_SEC_REQ=14, + SMP_FLAG_TIMEOUT=4, + SMP_FLAG_USER=9, + SMP_NUM_FLAGS=20, + SPI_IRQn=43, + STAT_PAR_OGF=5, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VFS_TYPE_BLOCK_DEV=2, + VFS_TYPE_CHAR_DEV=1, + VFS_TYPE_FS_DEV=3, + VFS_TYPE_NOT_INIT=0, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4 +} anon_enum_8_for_type.conflict3; + +typedef enum anon_enum_8_for_type.conflict2 { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BT_CONN_AUTO_CONNECT=0, + BT_CONN_AUTO_FEATURE_EXCH=13, + BT_CONN_AUTO_PHY_COMPLETE=12, + BT_CONN_AUTO_PHY_UPDATE=7, + BT_CONN_AUTO_VERSION_INFO=14, + BT_CONN_BR_LEGACY_SECURE=1, + BT_CONN_BR_NOBOND=4, + BT_CONN_BR_PAIRING=3, + BT_CONN_BR_PAIRING_INITIATOR=5, + BT_CONN_CLEANUP=6, + BT_CONN_FORCE_PAIR=11, + BT_CONN_NUM_FLAGS=15, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_SLAVE_PARAM_L2CAP=10, + BT_CONN_SLAVE_PARAM_SET=9, + BT_CONN_SLAVE_PARAM_UPDATE=8, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_CONN_USER=2, + BT_DEV_ACTIVE_SCAN=12, + BT_DEV_ADVERTISING=6, + BT_DEV_ADVERTISING_CONNECTABLE=8, + BT_DEV_ADVERTISING_NAME=7, + BT_DEV_AUTO_CONN=15, + BT_DEV_ENABLE=0, + BT_DEV_EXPLICIT_SCAN=11, + BT_DEV_HAS_PUB_KEY=4, + BT_DEV_ID_PENDING=17, + BT_DEV_KEEP_ADVERTISING=9, + BT_DEV_NUM_FLAGS=18, + BT_DEV_PRESET_ID=2, + BT_DEV_PUB_KEY_BUSY=5, + BT_DEV_READY=1, + BT_DEV_RPA_VALID=16, + BT_DEV_SCANNING=10, + BT_DEV_SCAN_FILTER_DUP=13, + BT_DEV_SCAN_WL=14, + BT_DEV_USER_ID_ADDR=3, + BT_EVENT_CMD_TX=0, + BT_EVENT_CONN_TX_QUEUE=1, + BT_GATT_DISCOVER_ATTRIBUTE=5, + BT_GATT_DISCOVER_CHARACTERISTIC=3, + BT_GATT_DISCOVER_DESCRIPTOR=4, + BT_GATT_DISCOVER_INCLUDE=2, + BT_GATT_DISCOVER_PRIMARY=0, + BT_GATT_DISCOVER_SECONDARY=1, + BT_GATT_ITER_CONTINUE=1, + BT_GATT_ITER_STOP=0, + BT_GATT_SUBSCRIBE_FLAG_VOLATILE=0, + BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING=1, + BT_GATT_SUBSCRIBE_NUM_FLAGS=2, + BT_HCI_ACL_DATA=1, + BT_HCI_CMD=0, + BT_HCI_CMD_CMP_EVT=2, + BT_HCI_CMD_STAT_EVT=3, + BT_HCI_EVT=5, + BT_HCI_LE_EVT=4, + BT_KEYS_ALL=63, + BT_KEYS_AUTHENTICATED=1, + BT_KEYS_DEBUG=2, + BT_KEYS_ID_PENDING_ADD=4, + BT_KEYS_ID_PENDING_DEL=8, + BT_KEYS_IRK=2, + BT_KEYS_LOCAL_CSRK=8, + BT_KEYS_LTK=4, + BT_KEYS_LTK_P256=32, + BT_KEYS_REMOTE_CSRK=16, + BT_KEYS_SC=16, + BT_KEYS_SLAVE_LTK=1, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_LE_SCAN_FILTER_DUPLICATE=1, + BT_LE_SCAN_FILTER_EXTENDED=4, + BT_LE_SCAN_FILTER_WHITELIST=2, + BT_QUIRK_NO_RESET=1, + BT_UUID_TYPE_128=2, + BT_UUID_TYPE_16=0, + BT_UUID_TYPE_32=1, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + I2C_IRQn=48, + INFO_PAR_OGF=4, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_IDLE=0, + KE_EVT_RUNNING=1, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + K_WORK_STATE_PENDING=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MEXT_IRQn=11, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + POOL_LINKED_LIST=0, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PT_ENTRY_FW_CPU0=0, + PT_ENTRY_FW_CPU1=1, + PT_ENTRY_MAX=16, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SMP_FLAG_BOND=12, + SMP_FLAG_BR_CONNECTED=17, + SMP_FLAG_BR_PAIR=18, + SMP_FLAG_CFM_DELAYED=0, + SMP_FLAG_CT2=19, + SMP_FLAG_DERIVE_LK=16, + SMP_FLAG_DHCHECK_WAIT=15, + SMP_FLAG_DHKEY_PENDING=7, + SMP_FLAG_DHKEY_SEND=8, + SMP_FLAG_DISPLAY=10, + SMP_FLAG_ENC_PENDING=1, + SMP_FLAG_KEYS_DISTR=2, + SMP_FLAG_OOB_PENDING=11, + SMP_FLAG_PAIRING=3, + SMP_FLAG_PKEY_SEND=6, + SMP_FLAG_SC=5, + SMP_FLAG_SC_DEBUG_KEY=13, + SMP_FLAG_SEC_REQ=14, + SMP_FLAG_TIMEOUT=4, + SMP_FLAG_USER=9, + SMP_NUM_FLAGS=20, + SPI_IRQn=43, + STAT_PAR_OGF=5, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VFS_TYPE_BLOCK_DEV=2, + VFS_TYPE_CHAR_DEV=1, + VFS_TYPE_FS_DEV=3, + VFS_TYPE_NOT_INIT=0, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4 +} anon_enum_8_for_type.conflict2; + + +// WARNING! conflicting data type names: /DWARF/_UNCATEGORIZED_/ieee80211_mgmt/anon_union_for_u - /DWARF/timers.c/tmrTimerQueueMessage/anon_union_for_u + +typedef TimerHandle_t timer_cb_arg_t; + +typedef struct mm_env_tag mm_env_tag, *Pmm_env_tag; + +struct mm_env_tag { + uint32_t rx_filter_umac; + uint32_t rx_filter_lmac_enable; + uint16_t ampdu_max_dur[5]; + uint8_t prev_mm_state; + uint8_t prev_hw_state; + uint32_t basic_rates[2]; + uint32_t uapsd_timeout; + uint16_t lp_clk_accuracy; + uint8_t host_idle; + _Bool keep_alive_status_enabled; + uint32_t keep_alive_packet_counter; + uint32_t keep_alive_time_last_received; +}; + +typedef enum mm_features { + MM_FEAT_AMPDU_BIT=9, + MM_FEAT_AMSDU_BIT=10, + MM_FEAT_AUTOBCN_BIT=1, + MM_FEAT_BCN_BIT=0, + MM_FEAT_BFMEE_BIT=17, + MM_FEAT_BFMER_BIT=18, + MM_FEAT_CHNL_CTXT_BIT=11, + MM_FEAT_CMON_BIT=3, + MM_FEAT_DPSM_BIT=8, + MM_FEAT_HWSCAN_BIT=2, + MM_FEAT_MESH_BIT=23, + MM_FEAT_MFP_BIT=20, + MM_FEAT_MROLE_BIT=4, + MM_FEAT_MU_MIMO_RX_BIT=21, + MM_FEAT_MU_MIMO_TX_BIT=22, + MM_FEAT_P2P_BIT=13, + MM_FEAT_P2P_GO_BIT=14, + MM_FEAT_PS_BIT=6, + MM_FEAT_RADAR_BIT=5, + MM_FEAT_REORD_BIT=12, + MM_FEAT_TDLS_BIT=24, + MM_FEAT_UAPSD_BIT=7, + MM_FEAT_UMAC_BIT=15, + MM_FEAT_VHT_BIT=16, + MM_FEAT_WAPI_BIT=19 +} mm_features; + +typedef enum ea_elt_asap_type { + EA_FLAG_ASAP_LIMIT=2, + EA_FLAG_ASAP_NO_LIMIT=1, + EA_FLAG_MAX=3, + EA_FLAG_NO_ASAP=0 +} ea_elt_asap_type; + +typedef enum ea_param_req_action { + EA_PARAM_REQ_CHECK=1, + EA_PARAM_REQ_GET=0 +} ea_param_req_action; + +typedef struct ea_param_input ea_param_input, *Pea_param_input; + +struct ea_param_input { + uint16_t interval_min; + uint16_t interval_max; + uint32_t duration_min; + uint16_t duration_max; + uint8_t pref_period; + undefined field_0xb; + uint16_t offset; + uint8_t action; + undefined field_0xf; + uint16_t conhdl; + uint16_t role; + _Bool odd_offset; + undefined field_0x15; + uint16_t linkid; +}; + +typedef struct ea_param_output ea_param_output, *Pea_param_output; + +struct ea_param_output { + uint16_t interval; + undefined field_0x2; + undefined field_0x3; + uint32_t duration; + uint16_t offset; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct ea_interval_tag ea_interval_tag, *Pea_interval_tag; + +struct ea_interval_tag { + struct co_list_hdr hdr; + uint16_t interval_used; + uint16_t offset_used; + uint16_t bandwidth_used; + uint16_t conhdl_used; + uint16_t role_used; + uint16_t linkid; +}; + +typedef enum ea_error { + EA_ERROR_BW_FULL=3, + EA_ERROR_NOT_FOUND=2, + EA_ERROR_OK=0, + EA_ERROR_REJECTED=1 +} ea_error; + +typedef enum ea_elt_asap_parity { + EA_EVEN_SLOT=0, + EA_NO_PARITY=2, + EA_ODD_SLOT=1 +} ea_elt_asap_parity; + +typedef struct ea_env_tag ea_env_tag, *Pea_env_tag; + +struct ea_env_tag { + struct co_list elt_wait; + struct ea_elt_tag * elt_prog; + struct co_list elt_canceled; + struct co_list interval_list; + uint32_t finetarget_time; +}; + +typedef enum ea_conflict { + START_AFTER_END_AFTER=5, + START_BEFORE_END_AFTER=2, + START_BEFORE_END_BEFORE=0, + START_BEFORE_END_DURING=1, + START_DURING_END_AFTER=4, + START_DURING_END_DURING=3 +} ea_conflict; + +typedef enum rwip_prio_dft { + RWIP_PRIO_ADV_DFT=5, + RWIP_PRIO_ADV_HDC_DFT=10, + RWIP_PRIO_INIT_DFT=5, + RWIP_PRIO_LE_CON_ACT_DFT=15, + RWIP_PRIO_LE_CON_IDLE_DFT=10, + RWIP_PRIO_LE_ESTAB_DFT=20, + RWIP_PRIO_MAX=31, + RWIP_PRIO_SCAN_DFT=5 +} rwip_prio_dft; + +typedef enum rwip_coex_config_idx { + RWIP_COEX_ADV_IDX=2, + RWIP_COEX_CFG_MAX=5, + RWIP_COEX_CON_DATA_IDX=1, + RWIP_COEX_CON_IDX=0, + RWIP_COEX_INIT_IDX=4, + RWIP_COEX_SCAN_IDX=3 +} rwip_coex_config_idx; + +typedef enum rwip_incr_dft { + RWIP_INCR_ADV_DFT=1, + RWIP_INCR_ADV_HDC_PRIO_DFT=1, + RWIP_INCR_INIT_DFT=1, + RWIP_INCR_LE_CON_ACT_DFT=11, + RWIP_INCR_LE_CON_IDLE_DFT=1, + RWIP_INCR_LE_ESTAB_DFT=1, + RWIP_INCR_SCAN_DFT=1 +} rwip_incr_dft; + +typedef enum KE_EVENT_TYPE { + KE_EVENT_BLE_CRYPT=1, + KE_EVENT_BLE_EVT_DEFER=8, + KE_EVENT_BLE_EVT_DELETE=9, + KE_EVENT_BT_PSCAN_PROC=7, + KE_EVENT_ECC_MULTIPLICATION=0, + KE_EVENT_H4TL_CMD_HDR_RX=5, + KE_EVENT_H4TL_CMD_PLD_RX=6, + KE_EVENT_H4TL_TX=4, + KE_EVENT_KE_MESSAGE=2, + KE_EVENT_KE_TIMER=3, + KE_EVENT_MAX=10 +} KE_EVENT_TYPE; + +typedef enum rwip_prio_idx { + RWIP_PRIO_ADV_HDC_IDX=6, + RWIP_PRIO_ADV_IDX=5, + RWIP_PRIO_IDX_MAX=7, + RWIP_PRIO_INIT_IDX=1, + RWIP_PRIO_LE_CON_ACT_IDX=4, + RWIP_PRIO_LE_CON_IDLE_IDX=3, + RWIP_PRIO_LE_ESTAB_IDX=2, + RWIP_PRIO_SCAN_IDX=0 +} rwip_prio_idx; + +typedef enum KE_TASK_TYPE { + TASK_DBG=3, + TASK_HCI_ONCHIP=4, + TASK_LLC=1, + TASK_LLD=2, + TASK_LLM=0, + TASK_MAX=5, + TASK_NONE=-1 +} KE_TASK_TYPE; + +typedef TickType_t EventBits_t; + +typedef struct EventGroupDef_t EventGroupDef_t, *PEventGroupDef_t; + +typedef struct EventGroupDef_t * EventGroupHandle_t; + +struct EventGroupDef_t { + EventBits_t uxEventBits; + List_t xTasksWaitingForBits; + UBaseType_t uxEventGroupNumber; + uint8_t ucStaticallyAllocated; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; +}; + +typedef ulonglong uintmax_t; + +typedef longlong intmax_t; + +typedef longlong int64_t; + +typedef struct bt_l2cap_le_chan.conflict1 bt_l2cap_le_chan.conflict1, *Pbt_l2cap_le_chan.conflict1; + +typedef struct bt_l2cap_chan.conflict2 bt_l2cap_chan.conflict2, *Pbt_l2cap_chan.conflict2; + +struct bt_l2cap_chan.conflict2 { + struct bt_conn * conn; + struct bt_l2cap_chan_ops * ops; + sys_snode_t node; + void (* destroy)(struct bt_l2cap_chan *); + struct k_delayed_work.conflict9 rtx_work; + atomic_t status[1]; + bt_l2cap_chan_state_t state; + undefined field_0x39; + u16_t psm; + u8_t ident; + enum bt_security_t required_sec_level; + undefined field_0x3e; + undefined field_0x3f; +}; + +struct bt_l2cap_le_chan.conflict1 { + struct bt_l2cap_chan.conflict2 chan; + struct bt_l2cap_le_endpoint rx; + struct bt_l2cap_le_endpoint tx; + struct k_fifo tx_queue; + struct net_buf * tx_buf; + struct net_buf * _sdu; + u16_t _sdu_len; + undefined field_0x7e; + undefined field_0x7f; + struct k_work rx_work; + struct k_fifo rx_queue; +}; + +typedef struct bt_l2cap_le_chan.conflict2 bt_l2cap_le_chan.conflict2, *Pbt_l2cap_le_chan.conflict2; + +typedef struct bt_l2cap_chan.conflict3 bt_l2cap_chan.conflict3, *Pbt_l2cap_chan.conflict3; + +struct bt_l2cap_chan.conflict3 { + struct bt_conn * conn; + struct bt_l2cap_chan_ops * ops; + sys_snode_t node; + void (* destroy)(struct bt_l2cap_chan *); + struct k_delayed_work.conflict11 rtx_work; + atomic_t status[1]; + bt_l2cap_chan_state_t state; + undefined field_0x39; + u16_t psm; + u8_t ident; + enum bt_security_t required_sec_level; + undefined field_0x3e; + undefined field_0x3f; +}; + +struct bt_l2cap_le_chan.conflict2 { + struct bt_l2cap_chan.conflict3 chan; + struct bt_l2cap_le_endpoint rx; + struct bt_l2cap_le_endpoint tx; + struct k_fifo tx_queue; + struct net_buf * tx_buf; + struct net_buf * _sdu; + u16_t _sdu_len; + undefined field_0x7e; + undefined field_0x7f; + struct k_work rx_work; + struct k_fifo rx_queue; +}; + +typedef enum bt_l2cap_chan_status { + BT_L2CAP_NUM_STATUS=1, + BT_L2CAP_STATUS_OUT=0 +} bt_l2cap_chan_status; + +typedef struct bt_l2cap_chan.conflict bt_l2cap_chan.conflict, *Pbt_l2cap_chan.conflict; + +struct bt_l2cap_chan.conflict { + struct bt_conn * conn; + struct bt_l2cap_chan_ops * ops; + sys_snode_t node; + void (* destroy)(struct bt_l2cap_chan *); + struct k_delayed_work.conflict7 rtx_work; + atomic_t status[1]; + bt_l2cap_chan_state_t state; + undefined field_0x39; + u16_t psm; + u8_t ident; + enum bt_security_t required_sec_level; + undefined field_0x3e; + undefined field_0x3f; +}; + +typedef struct bt_l2cap_chan.conflict1 bt_l2cap_chan.conflict1, *Pbt_l2cap_chan.conflict1; + +struct bt_l2cap_chan.conflict1 { + struct bt_conn * conn; + struct bt_l2cap_chan_ops * ops; + sys_snode_t node; + void (* destroy)(struct bt_l2cap_chan *); + struct k_delayed_work.conflict8 rtx_work; + atomic_t status[1]; + bt_l2cap_chan_state_t state; + undefined field_0x39; + u16_t psm; + u8_t ident; + enum bt_security_t required_sec_level; + undefined field_0x3e; + undefined field_0x3f; +}; + +typedef struct bt_l2cap_le_chan.conflict bt_l2cap_le_chan.conflict, *Pbt_l2cap_le_chan.conflict; + +struct bt_l2cap_le_chan.conflict { + struct bt_l2cap_chan.conflict1 chan; + struct bt_l2cap_le_endpoint rx; + struct bt_l2cap_le_endpoint tx; + struct k_fifo tx_queue; + struct net_buf * tx_buf; + struct net_buf * _sdu; + u16_t _sdu_len; + undefined field_0x7e; + undefined field_0x7f; + struct k_work rx_work; + struct k_fifo rx_queue; +}; + +typedef struct bt_l2cap_server bt_l2cap_server, *Pbt_l2cap_server; + +struct bt_l2cap_server { + u16_t psm; + enum bt_security_t sec_level; + undefined field_0x3; + int (* accept)(struct bt_conn *, struct bt_l2cap_chan * *); + sys_snode_t node; +}; + +typedef struct bt_l2cap bt_l2cap, *Pbt_l2cap; + +struct bt_l2cap { + struct bt_l2cap_le_chan chan; +}; + +typedef struct EventGroupDef_t EventGroup_t; + +typedef struct Ring_Buffer_Type Ring_Buffer_Type, *PRing_Buffer_Type; + +struct Ring_Buffer_Type { + uint8_t * pointer; + uint8_t readMirror; + undefined field_0x5; + uint16_t readIndex; + uint8_t writeMirror; + undefined field_0x9; + uint16_t writeIndex; + uint16_t size; + undefined field_0xe; + undefined field_0xf; + void (* lock)(void); + void (* unlock)(void); +}; + +typedef struct udp_hdr udp_hdr, *Pudp_hdr; + +struct udp_hdr { + u16_t src; + u16_t dest; + u16_t len; + u16_t chksum; +}; + +typedef struct rx_pbd rx_pbd, *Prx_pbd; + +struct rx_pbd { + uint32_t upattern; + uint32_t next; + uint32_t datastartptr; + uint32_t dataendptr; + uint16_t bufstatinfo; + uint16_t reserved; +}; + +typedef struct rx_payloaddesc rx_payloaddesc, *Prx_payloaddesc; + +struct rx_payloaddesc { + struct rx_pbd pbd; + uint32_t pd_status; + uint32_t * buffer_rx; + void * pbuf_holder[6]; +}; + +typedef struct tx_compressed_policy_tbl tx_compressed_policy_tbl, *Ptx_compressed_policy_tbl; + +struct tx_compressed_policy_tbl { + uint32_t upatterntx; + uint32_t sec_user_control; +}; + +typedef struct rx_dmadesc rx_dmadesc, *Prx_dmadesc; + +typedef struct rx_hd rx_hd, *Prx_hd; + +typedef struct phy_channel_info phy_channel_info, *Pphy_channel_info; + +typedef struct rx_swdesc rx_swdesc, *Prx_swdesc; + +struct rx_hd { + uint32_t upatternrx; + uint32_t next; + uint32_t first_pbd_ptr; + struct rx_swdesc * swdesc; + uint32_t datastartptr; + uint32_t dataendptr; + uint32_t headerctrlinfo; + uint16_t frmlen; + uint16_t ampdu_stat_info; + uint32_t tsflo; + uint32_t tsfhi; + uint32_t recvec1a; + uint32_t recvec1b; + uint32_t recvec1c; + uint32_t recvec1d; + uint32_t recvec2a; + uint32_t recvec2b; + uint32_t statinfo; +}; + +struct phy_channel_info { + uint32_t info1; + uint32_t info2; +}; + +struct rx_dmadesc { + struct rx_hd hd; + struct phy_channel_info phy_info; + uint32_t flags; + uint32_t pattern; + uint32_t payl_offset; + uint32_t reserved_pad[2]; + uint32_t use_in_tcpip; +}; + +struct rx_swdesc { + struct co_list_hdr list_hdr; + struct rx_dmadesc * dma_hdrdesc; + struct rx_payloaddesc * pd; + struct rx_pbd * last_pbd; + struct rx_pbd * spare_pbd; + uint32_t host_id; + uint32_t frame_len; + uint8_t status; + uint8_t pbd_count; + uint8_t use_in_tcpip; + undefined field_0x1f; +}; + +typedef struct tx_policy_tbl tx_policy_tbl, *Ptx_policy_tbl; + +struct tx_policy_tbl { + uint32_t upatterntx; + uint32_t phycntrlinfo1; + uint32_t phycntrlinfo2; + uint32_t maccntrlinfo1; + uint32_t maccntrlinfo2; + uint32_t ratecntrlinfo[4]; + uint32_t powercntrlinfo[4]; +}; + +typedef struct PtTable_Entry_Config PtTable_Entry_Config, *PPtTable_Entry_Config; + +struct PtTable_Entry_Config { + uint8_t type; + uint8_t device; + uint8_t activeIndex; + uint8_t name[9]; + uint32_t Address[2]; + uint32_t maxLen[2]; + uint32_t len; + uint32_t age; +}; + +typedef struct PtTable_Stuff_Config PtTable_Stuff_Config, *PPtTable_Stuff_Config; + +typedef struct PtTable_Config PtTable_Config, *PPtTable_Config; + +struct PtTable_Config { + uint32_t magicCode; + uint16_t version; + uint16_t entryCnt; + uint32_t age; + uint32_t crc32; +}; + +struct PtTable_Stuff_Config { + struct PtTable_Config ptTable; + struct PtTable_Entry_Config ptEntries[16]; + uint32_t crc32; +}; + + +// WARNING! conflicting data type names: /DWARF/bl_boot2.h/anon_enum_8 - /DWARF/debug.c/vsnprintf/anon_enum_8 + +typedef enum _blog_leve { + BLOG_LEVEL_ALL=0, + BLOG_LEVEL_ASSERT=5, + BLOG_LEVEL_DEBUG=1, + BLOG_LEVEL_ERROR=4, + BLOG_LEVEL_INFO=2, + BLOG_LEVEL_NEVER=6, + BLOG_LEVEL_WARN=3 +} _blog_leve; + +typedef enum _blog_leve blog_level_t; + +typedef struct _blog_info _blog_info, *P_blog_info; + +typedef struct _blog_info blog_info_t; + +struct _blog_info { + blog_level_t * level; + char * name; +}; + +typedef enum lld_ch_asses_ponderation { + LLD_CH_ASSES_CRC_ERR=-3, + LLD_CH_ASSES_SYNC_ERR_HIGH_RSSI=-3, + LLD_CH_ASSES_SYNC_ERR_LOW_RSSI_LATENCY=0, + LLD_CH_ASSES_SYNC_ERR_LOW_RSSI_NO_LATENCY=-1, + LLD_CH_ASSES_SYNC_FOUND_NO_CRC_ERR=3 +} lld_ch_asses_ponderation; + +typedef enum HCI_TX_STATE { + HCI_STATE_TX_IDLE=1, + HCI_STATE_TX_ONGOING=0 +} HCI_TX_STATE; + +typedef struct hci_tl_env_tag hci_tl_env_tag, *Phci_tl_env_tag; + +typedef struct ke_msg ke_msg, *Pke_msg; + +struct ke_msg { + struct co_list_hdr hdr; + ke_msg_id_t id; + ke_task_id_t dest_id; + ke_task_id_t src_id; + uint16_t param_len; + uint32_t param[1]; +}; + +struct hci_tl_env_tag { + struct co_list tx_queue; + struct co_list acl_queue; + struct ke_msg * curr_tx_msg; + struct em_buf_node * txtag; + uint8_t tx_state; + int8_t nb_h2c_cmd_pkts; + undefined field_0x1a; + undefined field_0x1b; +}; + +typedef struct _bl_sha_SEC_Eng_SHA256_Ctx_t _bl_sha_SEC_Eng_SHA256_Ctx_t, *P_bl_sha_SEC_Eng_SHA256_Ctx_t; + +struct _bl_sha_SEC_Eng_SHA256_Ctx_t { + uint32_t total[2]; + uint32_t * shaBuf; + uint32_t * shaPadding; + uint8_t shaFeed; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; +}; + +typedef enum bl_sha_type_t { + BL_SHA1=2, + BL_SHA224=1, + BL_SHA256=0 +} bl_sha_type_t; + +typedef struct bl_sha_ctx bl_sha_ctx, *Pbl_sha_ctx; + +struct bl_sha_ctx { + struct _bl_sha_SEC_Eng_SHA256_Ctx_t sha_ctx; + uint32_t tmp[16]; + uint32_t pad[16]; +}; + +typedef struct bl_sha_ctx bl_sha_ctx_t; + +typedef struct Efuse_TSEN_Refcode_Corner_Type.conflict Efuse_TSEN_Refcode_Corner_Type.conflict, *PEfuse_TSEN_Refcode_Corner_Type.conflict; + +struct Efuse_TSEN_Refcode_Corner_Type.conflict { + uint32_t tsenRefcodeCorner:12; + uint32_t tsenRefcodeCornerParity:1; + uint32_t tsenRefcodeCornerEn:1; + uint32_t tsenRefcodeCornerVersion:1; + uint32_t reserved:17; +}; + +typedef struct Efuse_Device_Info_Type.conflict1 Efuse_Device_Info_Type.conflict1, *PEfuse_Device_Info_Type.conflict1; + +struct Efuse_Device_Info_Type.conflict1 { + uint32_t rsvd:22; + uint32_t customerID:2; + uint32_t rsvd_info:3; + uint32_t memoryInfo:2; + uint32_t coreInfo:1; + uint32_t mcuInfo:1; + uint32_t pinInfo:1; +}; + +typedef struct Efuse_Ana_RC32M_Trim_Type.conflict Efuse_Ana_RC32M_Trim_Type.conflict, *PEfuse_Ana_RC32M_Trim_Type.conflict; + +struct Efuse_Ana_RC32M_Trim_Type.conflict { + uint32_t trimRc32mCodeFrExt:8; + uint32_t trimRc32mCodeFrExtParity:1; + uint32_t trimRc32mExtCodeEn:1; + uint32_t reserved:22; +}; + +typedef struct Efuse_Device_Info_Type.conflict Efuse_Device_Info_Type.conflict, *PEfuse_Device_Info_Type.conflict; + +struct Efuse_Device_Info_Type.conflict { + uint32_t rsvd:22; + uint32_t customerID:2; + uint32_t rsvd_info:3; + uint32_t memoryInfo:2; + uint32_t coreInfo:1; + uint32_t mcuInfo:1; + uint32_t pinInfo:1; +}; + +typedef struct Efuse_Ana_RC32M_Trim_Type.conflict4 Efuse_Ana_RC32M_Trim_Type.conflict4, *PEfuse_Ana_RC32M_Trim_Type.conflict4; + +struct Efuse_Ana_RC32M_Trim_Type.conflict4 { + uint32_t trimRc32mCodeFrExt:8; + uint32_t trimRc32mCodeFrExtParity:1; + uint32_t trimRc32mExtCodeEn:1; + uint32_t reserved:22; +}; + +typedef struct Efuse_ADC_Gain_Coeff_Type.conflict Efuse_ADC_Gain_Coeff_Type.conflict, *PEfuse_ADC_Gain_Coeff_Type.conflict; + +struct Efuse_ADC_Gain_Coeff_Type.conflict { + uint32_t adcGainCoeff:12; + uint32_t adcGainCoeffParity:1; + uint32_t adcGainCoeffEn:1; + uint32_t reserved:18; +}; + +typedef struct Efuse_Capcode_Info_Type.conflict1 Efuse_Capcode_Info_Type.conflict1, *PEfuse_Capcode_Info_Type.conflict1; + +struct Efuse_Capcode_Info_Type.conflict1 { + uint32_t capCode:6; + uint32_t parity:1; + uint32_t en:1; + uint32_t rsvd:24; +}; + +typedef struct Efuse_Capcode_Info_Type Efuse_Capcode_Info_Type, *PEfuse_Capcode_Info_Type; + +struct Efuse_Capcode_Info_Type { + uint32_t capCode:6; + uint32_t parity:1; + uint32_t en:1; + uint32_t rsvd:24; +}; + +typedef enum EF_Ctrl_Sign_Type { + EF_CTRL_SIGN_ECC=2, + EF_CTRL_SIGN_NONE=0, + EF_CTRL_SIGN_RSA=1 +} EF_Ctrl_Sign_Type; + +typedef struct Efuse_TSEN_Refcode_Corner_Type Efuse_TSEN_Refcode_Corner_Type, *PEfuse_TSEN_Refcode_Corner_Type; + +struct Efuse_TSEN_Refcode_Corner_Type { + uint32_t tsenRefcodeCorner:12; + uint32_t tsenRefcodeCornerParity:1; + uint32_t tsenRefcodeCornerEn:1; + uint32_t tsenRefcodeCornerVersion:1; + uint32_t reserved:17; +}; + +typedef struct Efuse_ADC_Gain_Coeff_Type Efuse_ADC_Gain_Coeff_Type, *PEfuse_ADC_Gain_Coeff_Type; + +struct Efuse_ADC_Gain_Coeff_Type { + uint32_t adcGainCoeff:12; + uint32_t adcGainCoeffParity:1; + uint32_t adcGainCoeffEn:1; + uint32_t reserved:18; +}; + +typedef struct EF_Ctrl_Sec_Param_Type EF_Ctrl_Sec_Param_Type, *PEF_Ctrl_Sec_Param_Type; + +typedef enum EF_Ctrl_Dbg_Mode_Type { + EF_CTRL_DBG_CLOSE=4, + EF_CTRL_DBG_OPEN=0, + EF_CTRL_DBG_PASSWORD=1 +} EF_Ctrl_Dbg_Mode_Type; + +struct EF_Ctrl_Sec_Param_Type { + enum EF_Ctrl_Dbg_Mode_Type ef_dbg_mode; + uint8_t ef_dbg_jtag_0_dis; + uint8_t ef_sboot_en; + uint8_t ef_no_hd_boot_en; +}; + +typedef struct Efuse_Capcode_Info_Type.conflict Efuse_Capcode_Info_Type.conflict, *PEfuse_Capcode_Info_Type.conflict; + +struct Efuse_Capcode_Info_Type.conflict { + uint32_t capCode:6; + uint32_t parity:1; + uint32_t en:1; + uint32_t rsvd:24; +}; + +typedef struct Efuse_TSEN_Refcode_Corner_Type.conflict3 Efuse_TSEN_Refcode_Corner_Type.conflict3, *PEfuse_TSEN_Refcode_Corner_Type.conflict3; + +struct Efuse_TSEN_Refcode_Corner_Type.conflict3 { + uint32_t tsenRefcodeCorner:12; + uint32_t tsenRefcodeCornerParity:1; + uint32_t tsenRefcodeCornerEn:1; + uint32_t tsenRefcodeCornerVersion:1; + uint32_t reserved:17; +}; + +typedef struct Efuse_Ana_RC32K_Trim_Type.conflict3 Efuse_Ana_RC32K_Trim_Type.conflict3, *PEfuse_Ana_RC32K_Trim_Type.conflict3; + +struct Efuse_Ana_RC32K_Trim_Type.conflict3 { + uint32_t trimRc32kCodeFrExt:10; + uint32_t trimRc32kCodeFrExtParity:1; + uint32_t trimRc32kExtCodeEn:1; + uint32_t reserved:20; +}; + +typedef struct Efuse_ADC_Gain_Coeff_Type.conflict3 Efuse_ADC_Gain_Coeff_Type.conflict3, *PEfuse_ADC_Gain_Coeff_Type.conflict3; + +struct Efuse_ADC_Gain_Coeff_Type.conflict3 { + uint32_t adcGainCoeff:12; + uint32_t adcGainCoeffParity:1; + uint32_t adcGainCoeffEn:1; + uint32_t reserved:18; +}; + +typedef struct Efuse_Ana_RC32K_Trim_Type.conflict Efuse_Ana_RC32K_Trim_Type.conflict, *PEfuse_Ana_RC32K_Trim_Type.conflict; + +struct Efuse_Ana_RC32K_Trim_Type.conflict { + uint32_t trimRc32kCodeFrExt:10; + uint32_t trimRc32kCodeFrExtParity:1; + uint32_t trimRc32kExtCodeEn:1; + uint32_t reserved:20; +}; + +typedef struct Efuse_Ana_RC32M_Trim_Type.conflict2 Efuse_Ana_RC32M_Trim_Type.conflict2, *PEfuse_Ana_RC32M_Trim_Type.conflict2; + +struct Efuse_Ana_RC32M_Trim_Type.conflict2 { + uint32_t trimRc32mCodeFrExt:8; + uint32_t trimRc32mCodeFrExtParity:1; + uint32_t trimRc32mExtCodeEn:1; + uint32_t reserved:22; +}; + +typedef struct Efuse_Ana_RC32M_Trim_Type.conflict1 Efuse_Ana_RC32M_Trim_Type.conflict1, *PEfuse_Ana_RC32M_Trim_Type.conflict1; + +struct Efuse_Ana_RC32M_Trim_Type.conflict1 { + uint32_t trimRc32mCodeFrExt:8; + uint32_t trimRc32mCodeFrExtParity:1; + uint32_t trimRc32mExtCodeEn:1; + uint32_t reserved:22; +}; + +typedef struct Efuse_Ana_RC32M_Trim_Type.conflict3 Efuse_Ana_RC32M_Trim_Type.conflict3, *PEfuse_Ana_RC32M_Trim_Type.conflict3; + +struct Efuse_Ana_RC32M_Trim_Type.conflict3 { + uint32_t trimRc32mCodeFrExt:8; + uint32_t trimRc32mCodeFrExtParity:1; + uint32_t trimRc32mExtCodeEn:1; + uint32_t reserved:22; +}; + +typedef struct Efuse_Ana_RC32M_Trim_Type Efuse_Ana_RC32M_Trim_Type, *PEfuse_Ana_RC32M_Trim_Type; + +struct Efuse_Ana_RC32M_Trim_Type { + uint32_t trimRc32mCodeFrExt:8; + uint32_t trimRc32mCodeFrExtParity:1; + uint32_t trimRc32mExtCodeEn:1; + uint32_t reserved:22; +}; + +typedef struct Efuse_TSEN_Refcode_Corner_Type.conflict1 Efuse_TSEN_Refcode_Corner_Type.conflict1, *PEfuse_TSEN_Refcode_Corner_Type.conflict1; + +struct Efuse_TSEN_Refcode_Corner_Type.conflict1 { + uint32_t tsenRefcodeCorner:12; + uint32_t tsenRefcodeCornerParity:1; + uint32_t tsenRefcodeCornerEn:1; + uint32_t tsenRefcodeCornerVersion:1; + uint32_t reserved:17; +}; + +typedef struct Efuse_TSEN_Refcode_Corner_Type.conflict2 Efuse_TSEN_Refcode_Corner_Type.conflict2, *PEfuse_TSEN_Refcode_Corner_Type.conflict2; + +struct Efuse_TSEN_Refcode_Corner_Type.conflict2 { + uint32_t tsenRefcodeCorner:12; + uint32_t tsenRefcodeCornerParity:1; + uint32_t tsenRefcodeCornerEn:1; + uint32_t tsenRefcodeCornerVersion:1; + uint32_t reserved:17; +}; + +typedef struct Efuse_Ana_RC32K_Trim_Type.conflict6 Efuse_Ana_RC32K_Trim_Type.conflict6, *PEfuse_Ana_RC32K_Trim_Type.conflict6; + +struct Efuse_Ana_RC32K_Trim_Type.conflict6 { + uint32_t trimRc32kCodeFrExt:10; + uint32_t trimRc32kCodeFrExtParity:1; + uint32_t trimRc32kExtCodeEn:1; + uint32_t reserved:20; +}; + +typedef struct Efuse_Device_Info_Type Efuse_Device_Info_Type, *PEfuse_Device_Info_Type; + +struct Efuse_Device_Info_Type { + uint32_t rsvd:22; + uint32_t customerID:2; + uint32_t rsvd_info:3; + uint32_t memoryInfo:2; + uint32_t coreInfo:1; + uint32_t mcuInfo:1; + uint32_t pinInfo:1; +}; + +typedef enum EF_Ctrl_SF_AES_Type { + EF_CTRL_SF_AES_128=1, + EF_CTRL_SF_AES_192=2, + EF_CTRL_SF_AES_256=3, + EF_CTRL_SF_AES_NONE=0 +} EF_Ctrl_SF_AES_Type; + +typedef struct Efuse_Ana_RC32K_Trim_Type.conflict5 Efuse_Ana_RC32K_Trim_Type.conflict5, *PEfuse_Ana_RC32K_Trim_Type.conflict5; + +struct Efuse_Ana_RC32K_Trim_Type.conflict5 { + uint32_t trimRc32kCodeFrExt:10; + uint32_t trimRc32kCodeFrExtParity:1; + uint32_t trimRc32kExtCodeEn:1; + uint32_t reserved:20; +}; + +typedef struct Efuse_Ana_RC32K_Trim_Type.conflict4 Efuse_Ana_RC32K_Trim_Type.conflict4, *PEfuse_Ana_RC32K_Trim_Type.conflict4; + +struct Efuse_Ana_RC32K_Trim_Type.conflict4 { + uint32_t trimRc32kCodeFrExt:10; + uint32_t trimRc32kCodeFrExtParity:1; + uint32_t trimRc32kExtCodeEn:1; + uint32_t reserved:20; +}; + +typedef struct Efuse_Ana_RC32K_Trim_Type.conflict2 Efuse_Ana_RC32K_Trim_Type.conflict2, *PEfuse_Ana_RC32K_Trim_Type.conflict2; + +struct Efuse_Ana_RC32K_Trim_Type.conflict2 { + uint32_t trimRc32kCodeFrExt:10; + uint32_t trimRc32kCodeFrExtParity:1; + uint32_t trimRc32kExtCodeEn:1; + uint32_t reserved:20; +}; + +typedef struct Efuse_Ana_RC32K_Trim_Type.conflict1 Efuse_Ana_RC32K_Trim_Type.conflict1, *PEfuse_Ana_RC32K_Trim_Type.conflict1; + +struct Efuse_Ana_RC32K_Trim_Type.conflict1 { + uint32_t trimRc32kCodeFrExt:10; + uint32_t trimRc32kCodeFrExtParity:1; + uint32_t trimRc32kExtCodeEn:1; + uint32_t reserved:20; +}; + +typedef struct Efuse_ADC_Gain_Coeff_Type.conflict2 Efuse_ADC_Gain_Coeff_Type.conflict2, *PEfuse_ADC_Gain_Coeff_Type.conflict2; + +struct Efuse_ADC_Gain_Coeff_Type.conflict2 { + uint32_t adcGainCoeff:12; + uint32_t adcGainCoeffParity:1; + uint32_t adcGainCoeffEn:1; + uint32_t reserved:18; +}; + +typedef struct Efuse_Ana_RC32K_Trim_Type Efuse_Ana_RC32K_Trim_Type, *PEfuse_Ana_RC32K_Trim_Type; + +struct Efuse_Ana_RC32K_Trim_Type { + uint32_t trimRc32kCodeFrExt:10; + uint32_t trimRc32kCodeFrExtParity:1; + uint32_t trimRc32kExtCodeEn:1; + uint32_t reserved:20; +}; + +typedef struct Efuse_ADC_Gain_Coeff_Type.conflict1 Efuse_ADC_Gain_Coeff_Type.conflict1, *PEfuse_ADC_Gain_Coeff_Type.conflict1; + +struct Efuse_ADC_Gain_Coeff_Type.conflict1 { + uint32_t adcGainCoeff:12; + uint32_t adcGainCoeffParity:1; + uint32_t adcGainCoeffEn:1; + uint32_t reserved:18; +}; + +typedef struct anon_struct.conflict5 anon_struct.conflict5, *Panon_struct.conflict5; + +struct anon_struct.conflict5 { + uint8_t priority; + uint8_t id_dst; + uint8_t id_msg; + uint8_t id_src; +}; + +typedef struct anon_struct.conflict4 anon_struct.conflict4, *Panon_struct.conflict4; + +struct anon_struct.conflict4 { + uint8_t priority; + uint8_t id_dst; + uint8_t id_msg; + uint8_t id_src; +}; + +typedef struct anon_struct.conflict3 anon_struct.conflict3, *Panon_struct.conflict3; + +struct anon_struct.conflict3 { + uint8_t priority; + uint8_t id_dst; + uint8_t id_msg; + uint8_t id_src; +}; + +typedef struct anon_struct.conflict117 anon_struct.conflict117, *Panon_struct.conflict117; + +struct anon_struct.conflict117 { + uint8_t priority; + uint8_t id_dst; + uint8_t id_msg; + uint8_t id_src; +}; + +typedef union anon_union.conflict2 anon_union.conflict2, *Panon_union.conflict2; + +union anon_union.conflict2 { + void * container; + struct anon_struct.conflict4 header; +}; + +typedef struct xSTATIC_QUEUE xSTATIC_QUEUE, *PxSTATIC_QUEUE; + + +// WARNING! conflicting data type names: /DWARF/FreeRTOS.h/xSTATIC_QUEUE/anon_union_for_u - /DWARF/timers.c/tmrTimerQueueMessage/anon_union_for_u + +struct xSTATIC_QUEUE { + void * pvDummy1[3]; + union anon_union_for_u u; + StaticList_t xDummy3[2]; + UBaseType_t uxDummy4[3]; + uint8_t ucDummy5[2]; + uint8_t ucDummy6; + undefined field_0x47; + UBaseType_t uxDummy8; + uint8_t ucDummy9; + undefined field_0x4d; + undefined field_0x4e; + undefined field_0x4f; +}; + +typedef struct xSTATIC_QUEUE StaticQueue_t; + +typedef StaticQueue_t StaticSemaphore_t; + +typedef union anon_union.conflict5 anon_union.conflict5, *Panon_union.conflict5; + +union anon_union.conflict5 { + void * pvDummy2; + UBaseType_t uxDummy2; +}; + +typedef union anon_union.conflict7 anon_union.conflict7, *Panon_union.conflict7; + +union anon_union.conflict7 { + void * pvDummy2; + UBaseType_t uxDummy2; +}; + +typedef struct bt_l2cap_cmd_reject bt_l2cap_cmd_reject, *Pbt_l2cap_cmd_reject; + +struct bt_l2cap_cmd_reject { + u16_t reason; + u8_t[0] data; +}; + +typedef struct bt_l2cap_disconn_rsp bt_l2cap_disconn_rsp, *Pbt_l2cap_disconn_rsp; + +struct bt_l2cap_disconn_rsp { + u16_t dcid; + u16_t scid; +}; + +typedef struct bt_l2cap_disconn_req bt_l2cap_disconn_req, *Pbt_l2cap_disconn_req; + +struct bt_l2cap_disconn_req { + u16_t dcid; + u16_t scid; +}; + +typedef struct bt_l2cap_cmd_reject_cid_data bt_l2cap_cmd_reject_cid_data, *Pbt_l2cap_cmd_reject_cid_data; + +struct bt_l2cap_cmd_reject_cid_data { + u16_t scid; + u16_t dcid; +}; + +typedef struct bt_l2cap_sig_hdr bt_l2cap_sig_hdr, *Pbt_l2cap_sig_hdr; + +struct bt_l2cap_sig_hdr { + u8_t code; + u8_t ident; + u16_t len; +}; + +typedef struct bt_l2cap_fixed_chan bt_l2cap_fixed_chan, *Pbt_l2cap_fixed_chan; + +struct bt_l2cap_fixed_chan { + u16_t cid; + undefined field_0x2; + undefined field_0x3; + int (* accept)(struct bt_conn *, struct bt_l2cap_chan * *); + sys_snode_t node; +}; + +typedef struct bt_l2cap_conn_param_rsp bt_l2cap_conn_param_rsp, *Pbt_l2cap_conn_param_rsp; + +struct bt_l2cap_conn_param_rsp { + u16_t result; +}; + +typedef struct bt_l2cap_le_conn_req bt_l2cap_le_conn_req, *Pbt_l2cap_le_conn_req; + +struct bt_l2cap_le_conn_req { + u16_t psm; + u16_t scid; + u16_t mtu; + u16_t mps; + u16_t credits; +}; + +typedef struct bt_l2cap_conn_param_req bt_l2cap_conn_param_req, *Pbt_l2cap_conn_param_req; + +struct bt_l2cap_conn_param_req { + u16_t min_interval; + u16_t max_interval; + u16_t latency; + u16_t timeout; +}; + +typedef struct bt_l2cap_le_credits bt_l2cap_le_credits, *Pbt_l2cap_le_credits; + +struct bt_l2cap_le_credits { + u16_t cid; + u16_t credits; +}; + +typedef struct bt_l2cap_le_conn_rsp bt_l2cap_le_conn_rsp, *Pbt_l2cap_le_conn_rsp; + +struct bt_l2cap_le_conn_rsp { + u16_t dcid; + u16_t mtu; + u16_t mps; + u16_t credits; + u16_t result; +}; + +typedef struct bt_l2cap_hdr bt_l2cap_hdr, *Pbt_l2cap_hdr; + +struct bt_l2cap_hdr { + u16_t len; + u16_t cid; +}; + +typedef struct aos_hdl_t aos_hdl_t, *Paos_hdl_t; + +typedef struct aos_hdl_t aos_timer_t; + +struct aos_hdl_t { + void * hdl; +}; + +typedef struct aos_hdl_t aos_queue_t; + +typedef uint aos_task_key_t; + +typedef struct aos_hdl_t aos_sem_t; + +typedef struct aos_hdl_t aos_task_t; + +typedef struct aos_hdl_t aos_mutex_t; + +typedef struct aos_hdl_t aos_work_t; + +typedef struct aos_workqueue_t aos_workqueue_t, *Paos_workqueue_t; + +struct aos_workqueue_t { + void * hdl; + void * stk; +}; + +typedef enum lld_evt_defer_type { + LLD_DEFER_CON_UP_INSTANT=3, + LLD_DEFER_END=1, + LLD_DEFER_MAP_UP_INSTANT=4, + LLD_DEFER_MAX=5, + LLD_DEFER_RX=0, + LLD_DEFER_TEST_END=2 +} lld_evt_defer_type; + +typedef struct ke_msg.conflict ke_msg.conflict, *Pke_msg.conflict; + +struct ke_msg.conflict { + struct co_list_hdr hdr; + ke_msg_id_t id; + ke_task_id_t dest_id; + ke_task_id_t src_id; + uint16_t param_len; + uint32_t[0] param; +}; + +typedef uint16_t ke_state_t.conflict31; + +typedef uint16_t ke_state_t.conflict25; + +typedef uint16_t ke_state_t.conflict47; + +typedef uint8_t ke_state_t; + +typedef uint16_t ke_state_t.conflict19; + +typedef uint16_t ke_state_t.conflict4; + +typedef struct ke_msg.conflict8 ke_msg.conflict8, *Pke_msg.conflict8; + +struct ke_msg.conflict8 { + struct co_list_hdr hdr; + ke_msg_id_t id; + ke_task_id_t dest_id; + ke_task_id_t src_id; + uint16_t param_len; + uint32_t[0] param; +}; + +typedef struct ke_msg.conflict9 ke_msg.conflict9, *Pke_msg.conflict9; + +struct ke_msg.conflict9 { + struct co_list_hdr hdr; + ke_msg_id_t id; + ke_task_id_t dest_id; + ke_task_id_t src_id; + uint16_t param_len; + uint32_t[0] param; +}; + +typedef struct ke_msg.conflict4 ke_msg.conflict4, *Pke_msg.conflict4; + +struct ke_msg.conflict4 { + struct co_list_hdr hdr; + ke_msg_id_t id; + ke_task_id_t dest_id; + ke_task_id_t src_id; + uint16_t param_len; + uint32_t[0] param; +}; + +typedef struct ke_msg.conflict5 ke_msg.conflict5, *Pke_msg.conflict5; + +struct ke_msg.conflict5 { + struct co_list_hdr hdr; + ke_msg_id_t id; + ke_task_id_t dest_id; + ke_task_id_t src_id; + uint16_t param_len; + uint32_t[0] param; +}; + +typedef struct ke_msg.conflict6 ke_msg.conflict6, *Pke_msg.conflict6; + +struct ke_msg.conflict6 { + struct co_list_hdr hdr; + ke_msg_id_t id; + ke_task_id_t dest_id; + ke_task_id_t src_id; + uint16_t param_len; + uint32_t[0] param; +}; + +typedef struct ke_msg.conflict7 ke_msg.conflict7, *Pke_msg.conflict7; + +struct ke_msg.conflict7 { + struct co_list_hdr hdr; + ke_msg_id_t id; + ke_task_id_t dest_id; + ke_task_id_t src_id; + uint16_t param_len; + uint32_t[0] param; +}; + +typedef struct ke_msg.conflict1 ke_msg.conflict1, *Pke_msg.conflict1; + +struct ke_msg.conflict1 { + struct co_list_hdr hdr; + ke_msg_id_t id; + ke_task_id_t dest_id; + ke_task_id_t src_id; + uint16_t param_len; + uint32_t[0] param; +}; + +typedef struct ke_msg.conflict2 ke_msg.conflict2, *Pke_msg.conflict2; + +struct ke_msg.conflict2 { + struct co_list_hdr hdr; + ke_msg_id_t id; + ke_task_id_t dest_id; + ke_task_id_t src_id; + uint16_t param_len; + uint32_t[0] param; +}; + +typedef struct ke_msg.conflict3 ke_msg.conflict3, *Pke_msg.conflict3; + +struct ke_msg.conflict3 { + struct co_list_hdr hdr; + ke_msg_id_t id; + ke_task_id_t dest_id; + ke_task_id_t src_id; + uint16_t param_len; + uint32_t[0] param; +}; + +typedef uint16_t ke_state_t.conflict21; + +typedef uint16_t ke_state_t.conflict14; + +typedef enum ke_msg_status_tag { + KE_MSG_CONSUMED=0, + KE_MSG_NO_FREE=1, + KE_MSG_SAVED=2 +} ke_msg_status_tag; + +typedef uint16_t ke_state_t.conflict2; + +typedef uint16_t ke_state_t.conflict1; + +typedef uint16_t ke_state_t.conflict6; + +typedef uint16_t ke_state_t.conflict5; + +typedef uint16_t ke_state_t.conflict3; + +typedef uint16_t ke_state_t.conflict9; + +typedef uint16_t ke_state_t.conflict8; + +typedef uint16_t ke_state_t.conflict7; + +typedef uint16_t ke_state_t.conflict37; + +typedef uint16_t ke_state_t.conflict43; + +typedef struct ke_msg.conflict11 ke_msg.conflict11, *Pke_msg.conflict11; + +struct ke_msg.conflict11 { + struct co_list_hdr hdr; + ke_msg_id_t id; + ke_task_id_t dest_id; + ke_task_id_t src_id; + uint16_t param_len; + uint32_t[0] param; +}; + +typedef struct ke_msg.conflict10 ke_msg.conflict10, *Pke_msg.conflict10; + +struct ke_msg.conflict10 { + struct co_list_hdr hdr; + ke_msg_id_t id; + ke_task_id_t dest_id; + ke_task_id_t src_id; + uint16_t param_len; + uint32_t[0] param; +}; + +typedef uint16_t ke_state_t.conflict39; + +typedef uint16_t ke_state_t.conflict45; + +typedef uint16_t ke_state_t.conflict10; + +typedef uint16_t ke_state_t.conflict46; + +typedef uint16_t ke_state_t.conflict27; + +typedef uint16_t ke_state_t.conflict16; + +typedef uint16_t ke_state_t.conflict33; + +typedef uint16_t ke_state_t.conflict20; + +typedef uint16_t ke_state_t.conflict22; + +typedef uint16_t ke_state_t.conflict17; + +typedef uint16_t ke_state_t.conflict18; + +typedef uint16_t ke_state_t.conflict13; + +typedef uint16_t ke_state_t.conflict12; + +typedef uint16_t ke_state_t.conflict15; + +typedef uint16_t ke_state_t.conflict11; + +typedef uint16_t ke_state_t.conflict29; + +typedef uint16_t ke_state_t.conflict41; + +typedef uint16_t ke_state_t.conflict35; + +typedef uint16_t ke_state_t.conflict42; + +typedef uint16_t ke_state_t.conflict44; + +typedef uint16_t ke_state_t.conflict40; + +typedef uint16_t ke_state_t.conflict38; + +typedef uint16_t ke_state_t.conflict34; + +typedef uint16_t ke_state_t.conflict36; + +typedef uint16_t ke_state_t.conflict30; + +typedef uint16_t ke_state_t.conflict32; + +typedef uint16_t ke_state_t.conflict23; + +typedef uint16_t ke_state_t.conflict28; + +typedef uint16_t ke_state_t.conflict24; + +typedef uint16_t ke_state_t.conflict26; + +typedef enum CFG_ELEMENT_TYPE { + CFG_ELEMENT_TYPE_BOOLEAN=1, + CFG_ELEMENT_TYPE_SINT16=4, + CFG_ELEMENT_TYPE_SINT32=6, + CFG_ELEMENT_TYPE_SINT8=2, + CFG_ELEMENT_TYPE_STRING=8, + CFG_ELEMENT_TYPE_UINT16=5, + CFG_ELEMENT_TYPE_UINT32=7, + CFG_ELEMENT_TYPE_UINT8=3, + CFG_ELEMENT_TYPE_UNKNOWN=0 +} CFG_ELEMENT_TYPE; + +typedef struct RSNConfig_t RSNConfig_t, *PRSNConfig_t; + +typedef struct AkmSuite_t AkmSuite_t, *PAkmSuite_t; + +typedef enum AkmType_e { + AKM_1X=1, + AKM_CCKM=99, + AKM_FT_1X=3, + AKM_FT_PSK=4, + AKM_NONE=0, + AKM_PSK=2, + AKM_RSN_MAX=6, + AKM_SHA256_1X=5, + AKM_SHA256_PSK=6, + AKM_SUITE_MAX=5, + AKM_TDLS=7, + AKM_WPA_MAX=2 +} AkmType_e; + +typedef enum AkmType_e AkmTypePacked_e; + +struct AkmSuite_t { + UINT8 akmOui[3]; + AkmTypePacked_e akmType; +}; + +struct RSNConfig_t { + UINT8 RSNEnabled:1; + UINT8 pmkidValid:1; + UINT8 rsnCapValid:1; + UINT8 grpMgmtCipherValid:1; + UINT8 rsvd:4; + struct SecurityMode_t wpaType; + struct Cipher_t.conflict mcstCipher; + struct Cipher_t.conflict ucstCipher; + struct AkmSuite_t AKM; + UINT8 PMKID[16]; + struct IEEEtypes_RSNCapability_t rsnCap; + struct Cipher_t.conflict grpMgmtCipher; +}; + +typedef enum ADC_Data_Width_Type { + ADC_DATA_WIDTH_12=0, + ADC_DATA_WIDTH_14_WITH_16_AVERAGE=1, + ADC_DATA_WIDTH_16_WITH_128_AVERAGE=3, + ADC_DATA_WIDTH_16_WITH_256_AVERAGE=4, + ADC_DATA_WIDTH_16_WITH_64_AVERAGE=2 +} ADC_Data_Width_Type; + +typedef enum ADC_Chan_Type { + ADC_CHAN0=0, + ADC_CHAN1=1, + ADC_CHAN10=10, + ADC_CHAN11=11, + ADC_CHAN2=2, + ADC_CHAN3=3, + ADC_CHAN4=4, + ADC_CHAN5=5, + ADC_CHAN6=6, + ADC_CHAN7=7, + ADC_CHAN8=8, + ADC_CHAN9=9, + ADC_CHAN_DAC_OUTA=12, + ADC_CHAN_DAC_OUTB=13, + ADC_CHAN_DCTEST=17, + ADC_CHAN_GND=23, + ADC_CHAN_SENP0=22, + ADC_CHAN_SENP1=21, + ADC_CHAN_SENP2=20, + ADC_CHAN_SENP3=19, + ADC_CHAN_TSEN_N=15, + ADC_CHAN_TSEN_P=14, + ADC_CHAN_VABT_HALF=18, + ADC_CHAN_VREF=16 +} ADC_Chan_Type; + +typedef enum ADC_INT_Type { + ADC_INT_ADC_READY=4, + ADC_INT_ALL=5, + ADC_INT_FIFO_OVERRUN=3, + ADC_INT_FIFO_UNDERRUN=2, + ADC_INT_NEG_SATURATION=1, + ADC_INT_POS_SATURATION=0 +} ADC_INT_Type; + +typedef struct ADC_Result_Type ADC_Result_Type, *PADC_Result_Type; + +struct ADC_Result_Type { + int8_t posChan; + int8_t negChan; + uint16_t value; + float volt; +}; + +typedef enum ADC_V18_SEL_Type { + ADC_V18_SEL_1P62V=0, + ADC_V18_SEL_1P72V=1, + ADC_V18_SEL_1P82V=2, + ADC_V18_SEL_1P92V=3 +} ADC_V18_SEL_Type; + +typedef enum ADC_PGA_GAIN_Type { + ADC_PGA_GAIN_1=1, + ADC_PGA_GAIN_16=5, + ADC_PGA_GAIN_2=2, + ADC_PGA_GAIN_32=6, + ADC_PGA_GAIN_4=3, + ADC_PGA_GAIN_8=4, + ADC_PGA_GAIN_NONE=0 +} ADC_PGA_GAIN_Type; + +typedef struct ADC_CFG_Type ADC_CFG_Type, *PADC_CFG_Type; + +typedef enum ADC_V11_SEL_Type { + ADC_V11_SEL_1P0V=0, + ADC_V11_SEL_1P18V=2, + ADC_V11_SEL_1P1V=1, + ADC_V11_SEL_1P26V=3 +} ADC_V11_SEL_Type; + +typedef enum ADC_CLK_Type { + ADC_CLK_DIV_1=0, + ADC_CLK_DIV_12=3, + ADC_CLK_DIV_16=4, + ADC_CLK_DIV_20=5, + ADC_CLK_DIV_24=6, + ADC_CLK_DIV_32=7, + ADC_CLK_DIV_4=1, + ADC_CLK_DIV_8=2 +} ADC_CLK_Type; + +typedef enum ADC_CHOP_MOD_Type { + ADC_CHOP_MOD_ALL_OFF=0, + ADC_CHOP_MOD_AZ_ON=1, + ADC_CHOP_MOD_AZ_PGA_ON=2, + ADC_CHOP_MOD_AZ_PGA_RPC_ON=3 +} ADC_CHOP_MOD_Type; + +typedef enum ADC_BIAS_SEL_Type { + ADC_BIAS_SEL_AON_BANDGAP=1, + ADC_BIAS_SEL_MAIN_BANDGAP=0 +} ADC_BIAS_SEL_Type; + +typedef enum ADC_PGA_VCM_Type { + ADC_PGA_VCM_1P2V=1, + ADC_PGA_VCM_1P4V=2, + ADC_PGA_VCM_1P6V=3, + ADC_PGA_VCM_1V=0 +} ADC_PGA_VCM_Type; + +typedef enum ADC_VREF_Type { + ADC_VREF_2V=1, + ADC_VREF_3P2V=0 +} ADC_VREF_Type; + +typedef enum ADC_SIG_INPUT_Type { + ADC_INPUT_DIFF=1, + ADC_INPUT_SINGLE_END=0 +} ADC_SIG_INPUT_Type; + +struct ADC_CFG_Type { + enum ADC_V18_SEL_Type v18Sel; + enum ADC_V11_SEL_Type v11Sel; + enum ADC_CLK_Type clkDiv; + enum ADC_PGA_GAIN_Type gain1; + enum ADC_PGA_GAIN_Type gain2; + enum ADC_CHOP_MOD_Type chopMode; + enum ADC_BIAS_SEL_Type biasSel; + enum ADC_PGA_VCM_Type vcm; + enum ADC_VREF_Type vref; + enum ADC_SIG_INPUT_Type inputMode; + enum ADC_Data_Width_Type resWidth; + enum BL_Fun_Type offsetCalibEn; + int16_t offsetCalibVal; +}; + +typedef struct ADC_MIC_Type ADC_MIC_Type, *PADC_MIC_Type; + +typedef enum ADC_MICBOOST_DB_Type { + ADC_MICBOOST_DB_16DB=0, + ADC_MICBOOST_DB_32DB=1 +} ADC_MICBOOST_DB_Type; + +typedef enum ADC_PGA2_GAIN_Type { + ADC_PGA2_GAIN_0DB=0, + ADC_PGA2_GAIN_12DB=3, + ADC_PGA2_GAIN_6DB=1, + ADC_PGA2_GAIN_N6DB=2 +} ADC_PGA2_GAIN_Type; + +typedef enum ADC_MIC_MODE_Type { + ADC_MIC_MODE_DIFF=1, + ADC_MIC_MODE_SINGLE=0 +} ADC_MIC_MODE_Type; + +struct ADC_MIC_Type { + enum ADC_MICBOOST_DB_Type micboostDb; + enum ADC_PGA2_GAIN_Type micPga2Gain; + enum ADC_MIC_MODE_Type mic1Mode; + enum ADC_MIC_MODE_Type mic2Mode; + enum BL_Fun_Type dwaEn; + enum BL_Fun_Type micboostBypassEn; + enum BL_Fun_Type micPgaEn; + enum BL_Fun_Type micBiasEn; +}; + +typedef struct ADC_Gain_Coeff_Type ADC_Gain_Coeff_Type, *PADC_Gain_Coeff_Type; + +struct ADC_Gain_Coeff_Type { + enum BL_Fun_Type adcGainCoeffEnable; + undefined field_0x1; + uint16_t adcgainCoeffVal; + float coe; +}; + +typedef enum ADC_TSEN_MOD_Type { + ADC_TSEN_MOD_EXTERNAL_DIODE=1, + ADC_TSEN_MOD_INTERNAL_DIODE=0 +} ADC_TSEN_MOD_Type; + +typedef struct ADC_FIFO_Cfg_Type ADC_FIFO_Cfg_Type, *PADC_FIFO_Cfg_Type; + +typedef enum ADC_FIFO_Threshold_Type { + ADC_FIFO_THRESHOLD_1=0, + ADC_FIFO_THRESHOLD_16=3, + ADC_FIFO_THRESHOLD_4=1, + ADC_FIFO_THRESHOLD_8=2 +} ADC_FIFO_Threshold_Type; + +struct ADC_FIFO_Cfg_Type { + enum ADC_FIFO_Threshold_Type fifoThreshold; + enum BL_Fun_Type dmaEn; +}; + +typedef struct anon_struct.conflict218 anon_struct.conflict218, *Panon_struct.conflict218; + +struct anon_struct.conflict218 { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict219 anon_struct.conflict219, *Panon_struct.conflict219; + +struct anon_struct.conflict219 { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict220 anon_struct.conflict220, *Panon_struct.conflict220; + +struct anon_struct.conflict220 { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct anon_struct.conflict221 anon_struct.conflict221, *Panon_struct.conflict221; + +struct anon_struct.conflict221 { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct anon_struct.conflict222 anon_struct.conflict222, *Panon_struct.conflict222; + +struct anon_struct.conflict222 { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct anon_struct.conflict223 anon_struct.conflict223, *Panon_struct.conflict223; + +struct anon_struct.conflict223 { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct regs_to_opti regs_to_opti, *Pregs_to_opti; + +struct regs_to_opti { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct notch_param notch_param, *Pnotch_param; + +struct notch_param { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct anon_struct.conflict158 anon_struct.conflict158, *Panon_struct.conflict158; + +struct anon_struct.conflict158 { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict159 anon_struct.conflict159, *Panon_struct.conflict159; + +struct anon_struct.conflict159 { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct tx_pwr_index tx_pwr_index, *Ptx_pwr_index; + +struct tx_pwr_index { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict160 anon_struct.conflict160, *Panon_struct.conflict160; + +struct anon_struct.conflict160 { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct anon_struct.conflict204 anon_struct.conflict204, *Panon_struct.conflict204; + +struct anon_struct.conflict204 { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict205 anon_struct.conflict205, *Panon_struct.conflict205; + +struct anon_struct.conflict205 { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict206 anon_struct.conflict206, *Panon_struct.conflict206; + +struct anon_struct.conflict206 { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct anon_struct.conflict207 anon_struct.conflict207, *Panon_struct.conflict207; + +struct anon_struct.conflict207 { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct anon_struct.conflict208 anon_struct.conflict208, *Panon_struct.conflict208; + +struct anon_struct.conflict208 { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct anon_struct.conflict209 anon_struct.conflict209, *Panon_struct.conflict209; + +struct anon_struct.conflict209 { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct anon_struct.conflict213 anon_struct.conflict213, *Panon_struct.conflict213; + +struct anon_struct.conflict213 { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef struct anon_struct.conflict214 anon_struct.conflict214, *Panon_struct.conflict214; + +struct anon_struct.conflict214 { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct anon_struct.conflict215 anon_struct.conflict215, *Panon_struct.conflict215; + +struct anon_struct.conflict215 { + uint32_t vbcore; + uint32_t iet; + uint32_t vbcore_11n; + uint32_t iet_11n; + uint32_t vbcore_11g; + uint32_t iet_11g; + uint32_t vbcore_11b; + uint32_t iet_11b; + uint32_t lo_fbdv_halfstep_en; + uint32_t lo_fbdv_halfstep_en_tx; + uint32_t lo_fbdv_halfstep_en_rx; + uint32_t clkpll_reset_postdiv; + uint32_t clkpll_dither_sel; +}; + +typedef struct anon_struct.conflict210 anon_struct.conflict210, *Panon_struct.conflict210; + +struct anon_struct.conflict210 { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict211 anon_struct.conflict211, *Panon_struct.conflict211; + +struct anon_struct.conflict211 { + uint32_t index; + int32_t dvga; +}; + +typedef struct anon_struct.conflict212 anon_struct.conflict212, *Panon_struct.conflict212; + +struct anon_struct.conflict212 { + uint32_t notch_en; + int32_t spur_freq; +}; + +typedef enum __fdlibm_version { + __fdlibm_ieee=-1, + __fdlibm_posix=0 +} __fdlibm_version; + +typedef struct HWStateMachineReg.conflict HWStateMachineReg.conflict, *PHWStateMachineReg.conflict; + +struct HWStateMachineReg.conflict { + uint32_t rxControl:6; + uint32_t reserved_7_6:2; + uint32_t txControl:9; + uint32_t reserved_23_17:7; + uint32_t macControl:8; +}; + +typedef struct HWStateMachineReg HWStateMachineReg, *PHWStateMachineReg; + +struct HWStateMachineReg { + uint32_t rxControl:6; + uint32_t reserved_7_6:2; + uint32_t txControl:9; + uint32_t reserved_23_17:7; + uint32_t macControl:8; +}; + +typedef struct dump_data_t dump_data_t, *Pdump_data_t; + +struct dump_data_t { + uint32_t time; + char * func_name; + uint32_t rc_state; + uint32_t rf_state; + uint32_t mac_debugRegHWSM1; + uint32_t mac_debugRegHWSM2; + uint16_t mac_debugPortCoex; + uint16_t mac_debugPortBackoff; + uint16_t mac_debugPortMacPhyIf; + uint16_t mac_debugPortMacPhyIf2; + uint16_t phy_debugPortMainFSM; + uint16_t phy_debugPortTDTX; + uint16_t phy_debugPortDSSSCCK1; + uint16_t phy_debugPortDSSSCCKTx; +}; + +typedef struct bt_bond_info bt_bond_info, *Pbt_bond_info; + +struct bt_bond_info { + struct bt_addr_le_t addr; +}; + +typedef struct bt_le_adv_param bt_le_adv_param, *Pbt_le_adv_param; + +struct bt_le_adv_param { + u8_t id; + u8_t options; + u16_t interval_min; + u16_t interval_max; +}; + +typedef struct bt_le_scan_param bt_le_scan_param, *Pbt_le_scan_param; + +struct bt_le_scan_param { + u8_t type; + u8_t filter_dup; + u16_t interval; + u16_t window; +}; + +typedef struct bt_le_oob bt_le_oob, *Pbt_le_oob; + +struct bt_le_oob { + struct bt_addr_le_t addr; + struct bt_le_oob_sc_data le_sc_data; +}; + +typedef enum PtTable_ID_Type { + PT_TABLE_ID_0=0, + PT_TABLE_ID_1=1, + PT_TABLE_ID_INVALID=2 +} PtTable_ID_Type; + +typedef enum PtTable_Error_Type { + PT_ERROR_CRC32=4, + PT_ERROR_ENTRY_NOT_FOUND=2, + PT_ERROR_ENTRY_UPDATE_FAIL=3, + PT_ERROR_FALSH_ERASE=8, + PT_ERROR_FALSH_READ=6, + PT_ERROR_FALSH_WRITE=7, + PT_ERROR_PARAMETER=5, + PT_ERROR_SUCCESS=0, + PT_ERROR_TABLE_NOT_VALID=1 +} PtTable_Error_Type; + +typedef struct mem mem, *Pmem; + +struct mem { + mem_size_t next; + mem_size_t prev; + u8_t used; + undefined field_0x5; +}; + +typedef enum lwip_iana_hwtype { + LWIP_IANA_HWTYPE_ETHERNET=1 +} lwip_iana_hwtype; + +typedef enum lwip_iana_port_number { + LWIP_IANA_PORT_DHCP_CLIENT=68, + LWIP_IANA_PORT_DHCP_SERVER=67, + LWIP_IANA_PORT_HTTP=80, + LWIP_IANA_PORT_HTTPS=443, + LWIP_IANA_PORT_MDNS=5353, + LWIP_IANA_PORT_MQTT=1883, + LWIP_IANA_PORT_NETBIOS=-119, + LWIP_IANA_PORT_SECURE_MQTT=8883, + LWIP_IANA_PORT_SMTP=25, + LWIP_IANA_PORT_SMTPS=465, + LWIP_IANA_PORT_SNMP=-95, + LWIP_IANA_PORT_SNMP_TRAP=-94, + LWIP_IANA_PORT_SNTP=123, + LWIP_IANA_PORT_TFTP=69 +} lwip_iana_port_number; + +typedef enum stateM_handleEventRetVals { + stateM_errArg=-2, + stateM_errorStateReached=-1, + stateM_finalStateReached=3, + stateM_noStateChange=2, + stateM_stateChanged=0, + stateM_stateLoopSelf=1 +} stateM_handleEventRetVals; + +typedef struct em_desc_node em_desc_node, *Pem_desc_node; + +struct em_desc_node { + struct co_list_hdr hdr; + uint16_t idx; + uint16_t buffer_idx; + uint16_t buffer_ptr; + uint8_t llid; + uint8_t length; +}; + +typedef struct em_buf_tx_desc em_buf_tx_desc, *Pem_buf_tx_desc; + +struct em_buf_tx_desc { + uint16_t txptr; + uint16_t txheader; + uint16_t txdataptr; + uint16_t txdle; +}; + +typedef struct em_buf_env_tag em_buf_env_tag, *Pem_buf_env_tag; + +struct em_buf_env_tag { + struct co_list tx_desc_free; + struct co_list tx_buff_free; + struct em_desc_node tx_desc_node[26]; + struct em_buf_node tx_buff_node[2]; + struct em_buf_tx_desc * tx_desc; + uint8_t rx_current; + undefined field_0x15d; + undefined field_0x15e; + undefined field_0x15f; +}; + +typedef struct encrypt encrypt, *Pencrypt; + +typedef struct encrypt * enc_handle_t; + +typedef struct payload payload, *Ppayload; + +typedef struct payload * pyld_handle_t; + +typedef struct pro_enc_func pro_enc_func, *Ppro_enc_func; + +typedef struct pro_pyld_func pro_pyld_func, *Ppro_pyld_func; + +struct payload { + struct pro_pyld_func * pfnc; + void * p_drv; + uint8_t pyld_type; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +struct encrypt { + pyld_handle_t pyld_handle; + struct payload pyld; + uint8_t is_head; + undefined field_0x11; + undefined field_0x12; + undefined field_0x13; + struct pro_enc_func * pfnc; + void * p_drv; +}; + +struct pro_pyld_func { + int (* pfn_pyld_read)(void *, uint8_t *, uint8_t *, uint8_t *, uint8_t *, uint8_t); + int (* pfn_pyld_write)(void *, uint8_t *, uint8_t *, uint8_t, uint8_t *, uint8_t, int16_t); +}; + +struct pro_enc_func { + int (* pfn_enc_read)(void *, uint8_t, uint8_t *, uint8_t *, uint8_t *, uint8_t *, size_t); + int (* pfn_enc_write)(void *, uint8_t, uint8_t, uint8_t *, uint8_t *, uint8_t *, uint8_t, int16_t); +}; + +typedef enum netifapi_arp_entry { + NETIFAPI_ARP_PERM=0 +} netifapi_arp_entry; + +typedef struct rxl_hwdesc_env_tag rxl_hwdesc_env_tag, *Prxl_hwdesc_env_tag; + +struct rxl_hwdesc_env_tag { + struct rx_pbd * last; + struct rx_pbd * free; +}; + +typedef struct KDE_t KDE_t, *PKDE_t; + +struct KDE_t { + UINT8 type; + UINT8 length; + UINT8 OUI[3]; + UINT8 dataType; + UINT8 data[1]; +}; + +typedef struct Hdr_8021x_t Hdr_8021x_t, *PHdr_8021x_t; + +struct Hdr_8021x_t { + UINT8 protocol_ver; + enum IEEEtypes_8021x_PacketType_e pckt_type; + UINT16 pckt_body_len; +}; + +typedef struct EAPOL_KeyMsg_t EAPOL_KeyMsg_t, *PEAPOL_KeyMsg_t; + +typedef struct key_info_t key_info_t, *Pkey_info_t; + +struct key_info_t { + UINT16 KeyMIC:1; + UINT16 Secure:1; + UINT16 Error:1; + UINT16 Request:1; + UINT16 EncryptedKeyData:1; + UINT16 Reserved:3; + UINT16 KeyDescriptorVersion:3; + UINT16 KeyType:1; + UINT16 KeyIndex:2; + UINT16 Install:1; + UINT16 KeyAck:1; +}; + +struct EAPOL_KeyMsg_t { + struct Hdr_8021x_t hdr_8021x; + UINT8 desc_type; + struct key_info_t key_info; + UINT16 key_length; + UINT32 replay_cnt[2]; + UINT8 key_nonce[32]; + UINT8 EAPOL_key_IV[16]; + UINT8 key_RSC[8]; + UINT8 key_ID[8]; + UINT8 key_MIC[16]; + UINT16 key_material_len; + UINT8 key_data[1]; +}; + +typedef struct EAPOL_KeyMsg_Tx_t EAPOL_KeyMsg_Tx_t, *PEAPOL_KeyMsg_Tx_t; + +struct EAPOL_KeyMsg_Tx_t { + struct ether_hdr_t ethHdr; + struct EAPOL_KeyMsg_t keyMsg; +}; + +typedef struct EAP_PacketMsg_t EAP_PacketMsg_t, *PEAP_PacketMsg_t; + +struct EAP_PacketMsg_t { + struct Hdr_8021x_t hdr_8021x; + enum IEEEtypes_8021x_CodeType_e code; + UINT8 identifier; + UINT16 length; + UINT8 data[1]; +}; + +typedef struct GTK_KDE_t GTK_KDE_t, *PGTK_KDE_t; + +struct GTK_KDE_t { + UINT8 KeyID:2; + UINT8 Tx:1; + UINT8 rsvd:5; + UINT8 rsvd1; + UINT8 GTK[1]; +}; + +typedef struct event_dev_t event_dev_t, *Pevent_dev_t; + +struct event_dev_t { + aos_mutex_t mutex; + void (* poll_cb)(struct pollfd *, void *); + struct pollfd * fd; + void * poll_data; + int counter; + dlist_t bufs; + int cache_count; + dlist_t buf_cache; +}; + +typedef struct dev_event_t dev_event_t, *Pdev_event_t; + +struct dev_event_t { + dlist_t node; + size_t len; + char[0] buf; +}; + +typedef struct in6_addr in6_addr, *Pin6_addr; + +typedef union anon_union_for_un anon_union_for_un, *Panon_union_for_un; + +union anon_union_for_un { + u32_t u32_addr[4]; + u8_t u8_addr[16]; +}; + +struct in6_addr { + union anon_union_for_un un; +}; + +typedef union anon_union.conflict1 anon_union.conflict1, *Panon_union.conflict1; + +union anon_union.conflict1 { + u32_t u32_addr[4]; + u8_t u8_addr[16]; +}; + +typedef uint32_t fdt32_t; + +typedef uint64_t fdt64_t; + +typedef ulong fd_mask; + +typedef struct _types_fd_set _types_fd_set, *P_types_fd_set; + +struct _types_fd_set { + fd_mask fds_bits[2]; +}; + +typedef struct poll_arg poll_arg, *Ppoll_arg; + +struct poll_arg { + aos_sem_t sem; +}; + +typedef struct tc_hmac_prng_struct tc_hmac_prng_struct, *Ptc_hmac_prng_struct; + +struct tc_hmac_prng_struct { + struct tc_hmac_state_struct h; + uint8_t key[32]; + uint8_t v[32]; + uint countdown; + undefined field_0x134; + undefined field_0x135; + undefined field_0x136; + undefined field_0x137; +}; + +typedef struct MIC_Error_t MIC_Error_t, *PMIC_Error_t; + +typedef enum MIC_Fail_State_e { + FIRST_MIC_FAIL_IN_60_SEC=1, + NO_MIC_FAILURE=0, + SECOND_MIC_FAIL_IN_60_SEC=2 +} MIC_Fail_State_e; + +struct MIC_Error_t { + enum MIC_Fail_State_e status; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + BOOLEAN MICCounterMeasureEnabled; + UINT32 disableStaAsso; +}; + +typedef struct TkipPtk_t TkipPtk_t, *PTkipPtk_t; + +struct TkipPtk_t { + UINT8 kck[16]; + UINT8 kek[16]; + UINT8 tk[16]; + UINT8 rxMicKey[8]; + UINT8 txMicKey[8]; +}; + +typedef struct customMIB_RSNStats_t customMIB_RSNStats_t, *PcustomMIB_RSNStats_t; + +struct customMIB_RSNStats_t { + UINT8 TKIPICVErrors; + UINT8 TKIPLocalMICFailures; + UINT8 TKIPCounterMeasuresInvoked; +}; + +typedef struct keyMgmtInfoSta_t keyMgmtInfoSta_t, *PkeyMgmtInfoSta_t; + +typedef struct cm_ConnectionInfo cm_ConnectionInfo, *Pcm_ConnectionInfo; + +typedef struct supplicantData supplicantData, *PsupplicantData; + +typedef union anon_union_for_specDat anon_union_for_specDat, *Panon_union_for_specDat; + +typedef struct SecurityParams_t SecurityParams_t, *PSecurityParams_t; + +typedef struct apSpecificData_t apSpecificData_t, *PapSpecificData_t; + +typedef struct BufferDesc BufferDesc, *PBufferDesc; + +typedef struct BufferDesc BufferDesc_t; + +typedef union anon_union_for_intf anon_union_for_intf, *Panon_union_for_intf; + +struct SecurityParams_t { + struct SecurityMode_t wpaType; + struct Cipher_t.conflict mcstCipher; + struct Cipher_t.conflict ucstCipher; +}; + +struct apSpecificData_t { + struct apInfo_t * apInfo; + BufferDesc_t * apInfoBuffDesc; + struct ChanBandInfo_t chanBandInfo; + undefined field_0xa; + undefined field_0xb; + struct staData_t staData; +}; + +union anon_union_for_specDat { + struct apSpecificData_t apData; +}; + +struct keyMgmtInfoSta_t { + UINT8 ANonce[32]; + UINT8 SNonce[32]; + UINT8 EAPOL_MIC_Key[16]; + UINT8 EAPOL_Encr_Key[16]; + UINT32 apCounterLo; + UINT32 apCounterHi; + UINT32 apCounterZeroDone; + UINT32 staCounterLo; + UINT32 staCounterHi; + BOOLEAN RSNDataTrafficEnabled; + BOOLEAN RSNSecured; + BOOLEAN pwkHandshakeComplete; + struct cipher_key_t * pRxDecryptKey; + struct KeyData_t PWKey; + struct KeyData_t GRKey; + struct KeyData_t newPWKey; + struct MIC_Error_t sta_MIC_Error; + struct mm_timer_tag rsnTimer; + struct cm_ConnectionInfo * connPtr; + struct KeyData_t IGtk; +}; + +struct supplicantData { + BOOLEAN inUse; + struct IEEEtypes_SsIdElement_t hashSsId; + IEEEtypes_MacAddr_t localBssid; + IEEEtypes_MacAddr_t localStaAddr; + struct customMIB_RSNStats_t customMIB_RSNStats; + struct RSNConfig_t customMIB_RSNConfig; + undefined field_0x51; + undefined field_0x52; + undefined field_0x53; + struct keyMgmtInfoSta_t keyMgmtInfoSta; + struct SecurityParams_t currParams; +}; + +struct cm_ConnectionInfo { + UINT8 conType; + UINT8 staId; + UINT8 instNbr; + UINT8 gtkHwKeyId; + UINT8 ptkHwKeyId; + UINT8 mfpHwKeyId; + undefined field_0x6; + undefined field_0x7; + struct supplicantData * suppData; + struct CommonMlmeData_t comData; + IEEEtypes_MacAddr_t peerMacAddr; + IEEEtypes_MacAddr_t localMacAddr; + union anon_union_for_specDat specDat; + cipher_key_buf_t TxRxCipherKeyBuf; +}; + +union anon_union_for_intf { + uint32 Interface; + struct cm_ConnectionInfo * connPtr; +}; + +struct BufferDesc { + union anon_union_for_intf intf; + uint16 DataLen; + undefined field_0x6; + undefined field_0x7; + void * Buffer; +}; + +typedef struct getopt_env getopt_env, *Pgetopt_env; + +typedef struct getopt_env getopt_env_t; + +struct getopt_env { + char * optarg; + int optind; + int opterr; + int optopt; + int __optpos; +}; + +typedef struct apm apm, *Papm; + +struct apm { + struct apm_start_req * param; + struct co_list bss_config; + uint8_t aging_sta_idx; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint8_t * bcn_buf; + _Bool apm_emb_enabled; + uint8_t hidden_ssid; + uint8_t assoc_sta_count; + uint8_t max_sta_supported; + struct anon_struct.conflict151 aid_list[10]; + undefined field_0x5e; + undefined field_0x5f; +}; + +typedef struct anon_struct.conflict179 anon_struct.conflict179, *Panon_struct.conflict179; + +struct anon_struct.conflict179 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict195 anon_struct.conflict195, *Panon_struct.conflict195; + +struct anon_struct.conflict195 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict202 anon_struct.conflict202, *Panon_struct.conflict202; + +struct anon_struct.conflict202 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict201 anon_struct.conflict201, *Panon_struct.conflict201; + +struct anon_struct.conflict201 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct anon_struct.conflict178 anon_struct.conflict178, *Panon_struct.conflict178; + +struct anon_struct.conflict178 { + uint8_t mac[6]; + uint8_t used; +}; + +typedef struct bt_conn_cb bt_conn_cb, *Pbt_conn_cb; + +typedef struct bt_le_conn_param bt_le_conn_param, *Pbt_le_conn_param; + +typedef enum bt_security_err { + BT_SECURITY_ERR_AUTH_FAIL=1, + BT_SECURITY_ERR_AUTH_REQUIREMENT=4, + BT_SECURITY_ERR_INVALID_PARAM=7, + BT_SECURITY_ERR_OOB_NOT_AVAILABLE=3, + BT_SECURITY_ERR_PAIR_NOT_ALLOWED=6, + BT_SECURITY_ERR_PAIR_NOT_SUPPORTED=5, + BT_SECURITY_ERR_PIN_OR_KEY_MISSING=2, + BT_SECURITY_ERR_SUCCESS=0, + BT_SECURITY_ERR_UNSPECIFIED=8 +} bt_security_err; + +struct bt_conn_cb { + void (* connected)(struct bt_conn *, u8_t); + void (* disconnected)(struct bt_conn *, u8_t); + _Bool (* le_param_req)(struct bt_conn *, struct bt_le_conn_param *); + void (* le_param_updated)(struct bt_conn *, u16_t, u16_t, u16_t); + void (* identity_resolved)(struct bt_conn *, struct bt_addr_le_t *, struct bt_addr_le_t *); + void (* security_changed)(struct bt_conn *, enum bt_security_t, enum bt_security_err); + struct bt_conn_cb * _next; +}; + +struct bt_le_conn_param { + u16_t interval_min; + u16_t interval_max; + u16_t latency; + u16_t timeout; +}; + +typedef struct bt_conn_le_info bt_conn_le_info, *Pbt_conn_le_info; + +struct bt_conn_le_info { + struct bt_addr_le_t * src; + struct bt_addr_le_t * dst; + struct bt_addr_le_t * local; + struct bt_addr_le_t * remote; + u16_t interval; + u16_t latency; + u16_t timeout; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct bt_conn_oob_info bt_conn_oob_info, *Pbt_conn_oob_info; + +typedef enum anon_enum_8_for_type { + AC_BE=1, + AC_BK=0, + AC_MAX=4, + AC_VI=2, + AC_VO=3, + ADDR_END=4, + ADDR_MASK=1, + ADDR_PUBLIC=0, + ADDR_RAND=1, + ADDR_RPA_MASK=2, + ADDR_RPA_OR_PUBLIC=2, + ADDR_RPA_OR_RAND=3, + ADV_CONN_DIR=1, + ADV_CONN_DIR_LDC=4, + ADV_CONN_UNDIR=0, + ADV_DIS=0, + ADV_DISC_UNDIR=2, + ADV_EN=1, + ADV_END=5, + ADV_EN_END=2, + ADV_NONCONN_UNDIR=3, + API_AC_BE=1, + API_AC_BK=0, + API_AC_MAX=4, + API_AC_VI=2, + API_AC_VO=3, + BLE_IRQn=72, + BMX_ERR_IRQn=16, + BMX_TO_IRQn=17, + BOR_IRQn=69, + BT_CONN_OOB_BOTH_PEERS=2, + BT_CONN_OOB_LE_LEGACY=0, + BT_CONN_OOB_LE_SC=1, + BT_CONN_OOB_LOCAL_ONLY=0, + BT_CONN_OOB_NO_DATA=3, + BT_CONN_OOB_REMOTE_ONLY=1, + BT_CONN_ROLE_MASTER=0, + BT_CONN_ROLE_SLAVE=1, + BT_CONN_TYPE_ALL=7, + BT_CONN_TYPE_BR=2, + BT_CONN_TYPE_LE=1, + BT_CONN_TYPE_SCO=4, + BT_LE_ADV_OPT_CONNECTABLE=1, + BT_LE_ADV_OPT_DIR_ADDR_RPA=32, + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY=16, + BT_LE_ADV_OPT_FILTER_CONN=-128, + BT_LE_ADV_OPT_FILTER_SCAN_REQ=64, + BT_LE_ADV_OPT_NONE=0, + BT_LE_ADV_OPT_ONE_TIME=2, + BT_LE_ADV_OPT_USE_IDENTITY=4, + BT_LE_ADV_OPT_USE_NAME=8, + BT_LE_SCAN_FILTER_DUPLICATE=1, + BT_LE_SCAN_FILTER_EXTENDED=4, + BT_LE_SCAN_FILTER_WHITELIST=2, + BZ_PHY_IRQn=71, + CLIC_SOFT_PEND_IRQn=12, + CNTLR_BB_OGF=3, + CONTROL_PORT_HOST=1, + CONTROL_PORT_NO_ENC=2, + CO_BAD_PARAM=4, + CO_BUSY=8, + CO_EMPTY=2, + CO_FAIL=1, + CO_FULL=3, + CO_NOT_FOUND=5, + CO_NO_ELT_IN_USE=7, + CO_NO_MORE_ELT_AVAILABLE=6, + CO_OK=0, + CO_OP_IN_PROGRESS=9, + DISABLE_HT=4, + DMA_ALL_IRQn=31, + DMA_BMX_ERR_IRQn=24, + EFUSE_IRQn=42, + ERR_ABRT=-13, + ERR_ALREADY=-9, + ERR_ARG=-16, + ERR_BUF=-2, + ERR_CLSD=-15, + ERR_CONN=-11, + ERR_IF=-12, + ERR_INPROGRESS=-5, + ERR_ISCONN=-10, + ERR_MEM=-1, + ERR_OK=0, + ERR_RST=-14, + ERR_RTE=-4, + ERR_TIMEOUT=-3, + ERR_USE=-8, + ERR_VAL=-6, + ERR_WOULDBLOCK=-7, + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6, + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1, + GPADC_DMA_IRQn=41, + GPIO_INT0_IRQn=60, + HBN_32K_DIG=3, + HBN_32K_RC=0, + HBN_32K_XTAL=1, + HBN_OUT0_IRQn=67, + HBN_OUT1_IRQn=68, + HBN_ROOT_CLK_PLL=2, + HBN_ROOT_CLK_RC32M=0, + HBN_ROOT_CLK_XTAL=1, + HBN_UART_CLK_160M=1, + HBN_UART_CLK_FCLK=0, + I2C_IRQn=48, + INFO_PAR_OGF=4, + INIT_FILT_END=2, + INIT_FILT_IGNORE_WLST=0, + INIT_FILT_USE_WLST=1, + IRQn_LAST=80, + IRRX_IRQn=36, + IRTX_IRQn=35, + KE_EVT_IDLE=0, + KE_EVT_RUNNING=1, + KE_MEM_BLOCK_EM=1, + KE_MEM_BLOCK_MAX=2, + KE_MEM_BLOCK_RAM=0, + KE_MEM_ENV=0, + KE_MEM_KE_MSG=0, + KE_MEM_NON_RETENTION=0, + L1C_BMX_ERR_IRQn=18, + L1C_BMX_TO_IRQn=19, + LE_CNTLR_OGF=8, + LINK_TYPE_END=2, + LIR_TYPE_A=1, + LIR_TYPE_B=2, + LIR_TYPE_C=3, + LIR_TYPE_D=4, + LIR_TYPE_E=5, + LIR_TYPE_F=6, + LIR_TYPE_G=7, + LIR_TYPE_H=8, + LIR_TYPE_I=9, + LIR_TYPE_J=10, + LK_CNTL_OGF=1, + LK_POL_OGF=2, + LLID_CNTL=3, + LLID_CONTINUE=1, + LLID_END=4, + LLID_RFU=0, + LLID_START=2, + LLM_LE_ADV_DUMMY_IDX=1, + LLM_LE_ADV_IDX=5, + LLM_LE_COEXT_SCAN_IDX=3, + LLM_LE_SCAN_CON_REQ_ADV_DIR_IDX=2, + LLM_LE_SCAN_RSP_IDX=4, + LL_ADV_CONN_DIR=1, + LL_ADV_CONN_UNDIR=0, + LL_ADV_DISC_UNDIR=6, + LL_ADV_END=8, + LL_ADV_NONCONN_UNDIR=2, + LL_CONNECT_REQ=5, + LL_EXT_ADV=7, + LL_SCAN_REQ=3, + LL_SCAN_RSP=4, + MAC_GEN_IRQn=77, + MAC_PORT_TRG_IRQn=78, + MAC_RX_TRG_IRQn=75, + MAC_TXRX_MISC_IRQn=74, + MAC_TXRX_TIMER_IRQn=73, + MAC_TX_TRG_IRQn=76, + MAX_OGF=64, + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1, + MEXT_IRQn=11, + MFP_IN_USE=16, + MM_AP=2, + MM_IBSS=1, + MM_MESH_POINT=3, + MM_STA=0, + MSOFT_IRQn=3, + MTIME_IRQn=7, + OP_CFLIRI_BUFFER=54, + OP_CFLIR_BUFFER=56, + OP_CFLIR_PLD=57, + OP_CLIR=53, + OP_CTLIRI_PLD=55, + OP_LADD=24, + OP_LCMP=25, + OP_LDIV=20, + OP_LDIV2N=18, + OP_LMUL=22, + OP_LMUL2N=19, + OP_LSQR=21, + OP_LSUB=23, + OP_MADD=40, + OP_MDIV2=33, + OP_MEXP=35, + OP_MINV=34, + OP_MMUL=37, + OP_MOD2N=17, + OP_MOVDAT=50, + OP_MREM=38, + OP_MSQR=36, + OP_MSUB=39, + OP_NLIR=51, + OP_PPSEL=0, + OP_RESIZE=49, + OP_SLIR=52, + PAYL_00001111=6, + PAYL_01010101=7, + PAYL_10101010=2, + PAYL_11110000=1, + PAYL_ALL_0=5, + PAYL_ALL_1=4, + PAYL_END=8, + PAYL_PSEUDO_RAND_15=3, + PAYL_PSEUDO_RAND_9=0, + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74, + PDS_WAKEUP_IRQn=66, + PHY_BAND_2G4=0, + PHY_BAND_5G=1, + PHY_BAND_MAX=2, + PHY_CHNL_BW_160=3, + PHY_CHNL_BW_20=0, + PHY_CHNL_BW_40=1, + PHY_CHNL_BW_80=2, + PHY_CHNL_BW_80P80=4, + PHY_CHNL_BW_OTHER=5, + POOL_LINKED_LIST=0, + PS_MODE_OFF=0, + PS_MODE_ON=1, + PS_MODE_ON_DYN=2, + PT_ENTRY_FW_CPU0=0, + PT_ENTRY_FW_CPU1=1, + PT_ENTRY_MAX=16, + PWM_IRQn=50, + RESERVED0=32, + RESERVED1=33, + RESERVED10=55, + RESERVED11=56, + RESERVED12=57, + RESERVED13=58, + RESERVED14=59, + RESERVED16=61, + RESERVED17=62, + RESERVED18=63, + RESERVED19=64, + RESERVED2=34, + RESERVED20=65, + RESERVED3=37, + RESERVED4=38, + RESERVED5=40, + RESERVED6=44, + RESERVED7=47, + RESERVED8=49, + RESERVED9=51, + RF_TOP_INT0_IRQn=21, + RF_TOP_INT1_IRQn=22, + RING_LINKED_LIST=1, + ROLE_END=2, + ROLE_MASTER=0, + ROLE_SLAVE=1, + SCAN_ACTIVE=1, + SCAN_DIS=0, + SCAN_EN=1, + SCAN_END=2, + SCAN_EN_END=2, + SCAN_PASSIVE=0, + SCA_100PPM=3, + SCA_150PPM=2, + SCA_20PPM=7, + SCA_250PPM=1, + SCA_30PPM=6, + SCA_500PPM=0, + SCA_50PPM=5, + SCA_75PPM=4, + SDIO_IRQn=23, + SEC_AES_IRQn=29, + SEC_BMX_ERR_IRQn=20, + SEC_CDET_IRQn=26, + SEC_GMAC_IRQn=25, + SEC_PKA_IRQn=27, + SEC_SHA_IRQn=30, + SEC_TRNG_IRQn=28, + SF_CTRL_IRQn=39, + SPI_IRQn=43, + STAT_PAR_OGF=5, + TASK_API=13, + TASK_APM=7, + TASK_BAM=8, + TASK_CFG=12, + TASK_DBG=1, + TASK_HOSTAPD_U=10, + TASK_LAST_EMB=12, + TASK_MAX=14, + TASK_ME=5, + TASK_MESH=9, + TASK_MM=0, + TASK_NONE=-1, + TASK_RXU=11, + TASK_SCAN=2, + TASK_SCANU=4, + TASK_SM=6, + TASK_TDLS=3, + TEST_END=3, + TEST_OGF=6, + TEST_RX=1, + TEST_RXTX=2, + TEST_TX=0, + TIMER_CH0_IRQn=52, + TIMER_CH1_IRQn=53, + TIMER_WDT_IRQn=54, + TX_LVL_CURRENT=0, + TX_LVL_LEN=2, + TX_LVL_MAX=1, + UART0_IRQn=45, + UART1_IRQn=46, + VFS_TYPE_BLOCK_DEV=2, + VFS_TYPE_CHAR_DEV=1, + VFS_TYPE_FS_DEV=3, + VFS_TYPE_NOT_INIT=0, + VS_OGF=63, + WIFI_IPC_PUBLIC_IRQn=79, + WIFI_IRQn=70, + WPA_WPA2_IN_USE=8, + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4 +} anon_enum_8_for_type; + + +// WARNING! conflicting data type names: /DWARF/conn.h/bt_conn_oob_info/anon_union_for_field_1 - /DWARF/dlist.h/_dnode/anon_union_for_field_1 + +struct bt_conn_oob_info { + enum anon_enum_8_for_type type; + union anon_union_for_field_1 field_1; +}; + +typedef struct bt_conn_auth_cb bt_conn_auth_cb, *Pbt_conn_auth_cb; + +struct bt_conn_auth_cb { + void (* passkey_display)(struct bt_conn *, uint); + void (* passkey_entry)(struct bt_conn *); + void (* passkey_confirm)(struct bt_conn *, uint); + void (* oob_data_request)(struct bt_conn *, struct bt_conn_oob_info *); + void (* cancel)(struct bt_conn *); + void (* pairing_confirm)(struct bt_conn *); + void (* pairing_complete)(struct bt_conn *, _Bool); + void (* pairing_failed)(struct bt_conn *, enum bt_security_err); +}; + +typedef struct bt_conn_info bt_conn_info, *Pbt_conn_info; + + +// WARNING! conflicting data type names: /DWARF/conn.h/bt_conn_info/anon_union_for_field_3 - /DWARF/gatt.h/bt_gatt_discover_params/anon_union_for_field_3 + +struct bt_conn_info { + u8_t type; + u8_t role; + u8_t id; + undefined field_0x3; + union anon_union_for_field_3 field_3; +}; + +typedef struct bt_conn_oob_info.conflict bt_conn_oob_info.conflict, *Pbt_conn_oob_info.conflict; + +struct bt_conn_oob_info.conflict { + enum anon_enum_8_for_type.conflict type; + union anon_union_for_field_1.conflict field_1; +}; + +typedef struct anon_struct.conflict78 anon_struct.conflict78, *Panon_struct.conflict78; + +struct anon_struct.conflict78 { + enum anon_enum_8_for_oob_config oob_config; +}; + +typedef struct bt_conn_oob_info.conflict3 bt_conn_oob_info.conflict3, *Pbt_conn_oob_info.conflict3; + +struct bt_conn_oob_info.conflict3 { + enum anon_enum_8_for_type.conflict3 type; + union anon_union_for_field_1.conflict3 field_1; +}; + +typedef struct bt_conn_oob_info.conflict4 bt_conn_oob_info.conflict4, *Pbt_conn_oob_info.conflict4; + +struct bt_conn_oob_info.conflict4 { + enum anon_enum_8_for_type.conflict4 type; + union anon_union_for_field_1.conflict4 field_1; +}; + +typedef struct bt_conn_oob_info.conflict1 bt_conn_oob_info.conflict1, *Pbt_conn_oob_info.conflict1; + +struct bt_conn_oob_info.conflict1 { + enum anon_enum_8_for_type.conflict1 type; + union anon_union_for_field_1.conflict1 field_1; +}; + +typedef struct bt_conn_oob_info.conflict2 bt_conn_oob_info.conflict2, *Pbt_conn_oob_info.conflict2; + +struct bt_conn_oob_info.conflict2 { + enum anon_enum_8_for_type.conflict2 type; + union anon_union_for_field_1.conflict2 field_1; +}; + +typedef struct bt_conn_br_info bt_conn_br_info, *Pbt_conn_br_info; + +struct bt_conn_br_info { + struct bt_addr_t * dst; +}; + +typedef struct supplicantData supplicantData_t; + +typedef struct tx_meta tx_meta, *Ptx_meta; + +typedef struct bt_conn_tx bt_conn_tx, *Pbt_conn_tx; + +struct tx_meta { + struct bt_conn_tx * tx; +}; + +struct bt_conn_tx { + sys_snode_t node; + void (* cb)(struct bt_conn *, void *); + void * user_data; + u32_t.conflict pending_no_cb; +}; + +typedef struct wifi_event_data_ind_scan_done wifi_event_data_ind_scan_done, *Pwifi_event_data_ind_scan_done; + +struct wifi_event_data_ind_scan_done { + uint32_t nothing; +}; + +typedef struct wifi_event_sm_connect_ind wifi_event_sm_connect_ind, *Pwifi_event_sm_connect_ind; + +struct wifi_event_sm_connect_ind { + uint16_t status_code; + uint8_t bssid[6]; + uint8_t vif_idx; + uint8_t ap_idx; + uint8_t ch_idx; + undefined field_0xb; + int qos; + uint16_t aid; + uint8_t band; + undefined field_0x13; + uint16_t center_freq; + uint8_t width; + undefined field_0x17; + uint32_t center_freq1; + uint32_t center_freq2; +}; + +typedef struct wifi_apm_sta_info wifi_apm_sta_info, *Pwifi_apm_sta_info; + +struct wifi_apm_sta_info { + uint8_t sta_idx; + uint8_t is_used; + uint8_t sta_mac[6]; + uint32_t tsfhi; + uint32_t tsflo; + int rssi; + uint8_t data_rate; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct wifi_event_beacon_ind wifi_event_beacon_ind, *Pwifi_event_beacon_ind; + +typedef struct wifi_cipher_t wifi_cipher_t, *Pwifi_cipher_t; + +typedef struct wifi_secmode_t wifi_secmode_t, *Pwifi_secmode_t; + +struct wifi_cipher_t { + uint8_t wep40:1; + uint8_t wep104:1; + uint8_t tkip:1; + uint8_t ccmp:1; + uint8_t rsvd:4; +}; + +struct wifi_secmode_t { + uint8_t noRsn:1; + uint8_t wepStatic:1; + uint8_t wepDynamic:1; + uint8_t wpa:1; + uint8_t wpaNone:1; + uint8_t wpa2:1; + uint8_t cckm:1; + uint8_t wapi:1; + uint8_t rsvd:8; +}; + +struct wifi_event_beacon_ind { + uint8_t bssid[6]; + uint8_t ssid[33]; + int8_t rssi; + int8_t ppm_abs; + int8_t ppm_rel; + uint8_t channel; + uint8_t auth; + uint8_t cipher; + struct wifi_cipher_t wpa_mcstCipher; + struct wifi_cipher_t wpa_ucstCipher; + struct wifi_cipher_t rsn_mcstCipher; + struct wifi_cipher_t rsn_ucstCipher; + struct wifi_secmode_t sec_mode; + undefined field_0x33; + int ssid_len; +}; + +typedef struct wifi_event_sm_disconnect_ind wifi_event_sm_disconnect_ind, *Pwifi_event_sm_disconnect_ind; + +struct wifi_event_sm_disconnect_ind { + uint16_t reason_code; + uint8_t vif_idx; + undefined field_0x3; + int ft_over_ds; +}; + +typedef struct wifi_event_data_ind_channel_switch wifi_event_data_ind_channel_switch, *Pwifi_event_data_ind_channel_switch; + +struct wifi_event_data_ind_channel_switch { + int channel; +}; + +typedef struct wifi_event wifi_event, *Pwifi_event; + +struct wifi_event { + uint32_t id; + uint8_t[0] data; +}; + +typedef struct phyif_utils_recvtable_t phyif_utils_recvtable_t, *Pphyif_utils_recvtable_t; + +struct phyif_utils_recvtable_t { + uint32_t recvtable1; + uint32_t recvtable2; + uint32_t recvtable3; + uint32_t recvtable4; + uint32_t recvtable5; + uint32_t recvtable6; +}; + +typedef struct dhcp_msg dhcp_msg, *Pdhcp_msg; + +struct dhcp_msg { + u8_t op; + u8_t htype; + u8_t hlen; + u8_t hops; + u32_t xid; + u16_t secs; + u16_t flags; + ip4_addr_p_t ciaddr; + ip4_addr_p_t yiaddr; + ip4_addr_p_t siaddr; + ip4_addr_p_t giaddr; + u8_t chaddr[16]; + u8_t sname[64]; + u8_t file[128]; + u32_t cookie; + u8_t options[68]; +}; + +typedef struct dhcp dhcp, *Pdhcp; + +struct dhcp { + u32_t xid; + u8_t pcb_allocated; + u8_t state; + u8_t tries; + u8_t subnet_mask_given; + u16_t request_timeout; + u16_t t1_timeout; + u16_t t2_timeout; + u16_t t1_renew_time; + u16_t t2_rebind_time; + u16_t lease_used; + u16_t t0_timeout; + undefined field_0x16; + undefined field_0x17; + ip_addr_t server_ip_addr; + ip4_addr_t offered_ip_addr; + ip4_addr_t offered_sn_mask; + ip4_addr_t offered_gw_addr; + u32_t offered_t0_lease; + u32_t offered_t1_renew; + u32_t offered_t2_rebind; +}; + +typedef enum dhcp_option_idx { + DHCP_OPTION_IDX_DNS_SERVER=8, + DHCP_OPTION_IDX_DNS_SERVER_LAST=9, + DHCP_OPTION_IDX_LEASE_TIME=3, + DHCP_OPTION_IDX_MAX=10, + DHCP_OPTION_IDX_MSG_TYPE=1, + DHCP_OPTION_IDX_OVERLOAD=0, + DHCP_OPTION_IDX_ROUTER=7, + DHCP_OPTION_IDX_SERVER_ID=2, + DHCP_OPTION_IDX_SUBNET_MASK=6, + DHCP_OPTION_IDX_T1=4, + DHCP_OPTION_IDX_T2=5 +} dhcp_option_idx; + +typedef struct phyif_utils_recvtable_priv_t phyif_utils_recvtable_priv_t, *Pphyif_utils_recvtable_priv_t; + +struct phyif_utils_recvtable_priv_t { + uint32_t leg_length:12; + uint32_t leg_rate:4; + uint32_t ht_length:16; + uint32_t _ht_length:4; + uint32_t short_gi:1; + uint32_t stbc:2; + uint32_t smoothing:1; + uint32_t mcs:7; + uint32_t pre_type:1; + uint32_t format_mod:3; + uint32_t ch_bw:2; + uint32_t n_sts:3; + uint32_t lsig_valid:1; + uint32_t sounding:1; + uint32_t num_extn_ss:2; + uint32_t aggregation:1; + uint32_t fec_coding:1; + uint32_t dyn_bw:1; + uint32_t doze_not_allowed:1; + uint32_t antenna_set:8; + uint32_t partial_aid:9; + uint32_t group_id:6; + uint32_t reserved_1c:1; + int32_t rssi1:8; + int32_t rssi2:8; + int32_t rssi3:8; + int32_t rssi4:8; + uint32_t reserved_1d:8; + uint32_t rcpi:8; + uint32_t evm1:8; + uint32_t evm2:8; + uint32_t evm3:8; + uint32_t evm4:8; + uint32_t reserved2b_1:8; + uint32_t reserved2b_2:8; + uint32_t reserved2b_3:8; +}; + +typedef struct xTIME_OUT xTIME_OUT, *PxTIME_OUT; + +typedef struct xTIME_OUT TimeOut_t; + +struct xTIME_OUT { + BaseType_t xOverflowCount; + TickType_t xTimeOnEntering; +}; + +typedef struct xMEMORY_REGION xMEMORY_REGION, *PxMEMORY_REGION; + +struct xMEMORY_REGION { + void * pvBaseAddress; + uint32_t ulLengthInBytes; + uint32_t ulParameters; +}; + +typedef struct xTASK_STATUS xTASK_STATUS, *PxTASK_STATUS; + +typedef struct xTASK_STATUS TaskStatus_t; + +typedef enum eTaskState { + eBlocked=2, + eDeleted=4, + eInvalid=5, + eReady=1, + eRunning=0, + eSuspended=3 +} eTaskState; + +struct xTASK_STATUS { + TaskHandle_t xHandle; + char * pcTaskName; + UBaseType_t xTaskNumber; + enum eTaskState eCurrentState; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + UBaseType_t uxCurrentPriority; + UBaseType_t uxBasePriority; + uint32_t ulRunTimeCounter; + StackType_t * pxStackBase; + uint16_t usStackHighWaterMark; + undefined field_0x22; + undefined field_0x23; +}; + +typedef enum eNotifyAction { + eIncrement=2, + eNoAction=0, + eSetBits=1, + eSetValueWithOverwrite=3, + eSetValueWithoutOverwrite=4 +} eNotifyAction; + +typedef struct xMEMORY_REGION MemoryRegion_t; + +typedef struct ip_globals ip_globals, *Pip_globals; + +struct ip_globals { + struct netif * current_netif; + struct netif * current_input_netif; + struct ip_hdr * current_ip4_header; + u16_t current_ip_header_tot_len; + undefined field_0xe; + undefined field_0xf; + ip_addr_t current_iphdr_src; + ip_addr_t current_iphdr_dest; +}; + +typedef uint32_t evt_field_t; + +typedef struct ke_env_tag ke_env_tag, *Pke_env_tag; + +struct ke_env_tag { + evt_field_t evt_field; + struct co_list queue_sent; + struct co_list queue_saved; + struct co_list queue_timer; + struct mblock_free * mblock_first; +}; + +typedef struct ke_env_tag.conflict ke_env_tag.conflict, *Pke_env_tag.conflict; + +struct ke_env_tag.conflict { + evt_field_t evt_field; + struct co_list queue_sent; + struct co_list queue_saved; + struct co_list queue_timer; + struct mblock_free * mblock_first; +}; + +typedef struct ble_ke_env_tag ble_ke_env_tag, *Pble_ke_env_tag; + +struct ble_ke_env_tag { + struct co_list queue_sent; + struct co_list queue_saved; + struct co_list queue_timer; + struct mblock_free * heap[2]; + uint16_t heap_size[2]; +}; + +typedef atomic_t atomic_val_t; + +typedef struct mblock_used mblock_used, *Pmblock_used; + +struct mblock_used { + uint16_t corrupt_check; + uint16_t size; +}; + +typedef struct mblock_free.conflict mblock_free.conflict, *Pmblock_free.conflict; + +struct mblock_free.conflict { + struct mblock_free * next; + uint32_t size; +}; + +typedef struct mblock_used.conflict mblock_used.conflict, *Pmblock_used.conflict; + +struct mblock_used.conflict { + uint32_t size; +}; + +typedef struct access_addr access_addr, *Paccess_addr; + +struct access_addr { + uint8_t addr[4]; +}; + +typedef enum adv_filter_policy { + ADV_ALLOW_SCAN_ANY_CON_ANY=0, + ADV_ALLOW_SCAN_ANY_CON_WLST=2, + ADV_ALLOW_SCAN_END=4, + ADV_ALLOW_SCAN_WLST_CON_ANY=1, + ADV_ALLOW_SCAN_WLST_CON_WLST=3 +} adv_filter_policy; + +typedef enum scan_filter_policy { + SCAN_ALLOW_ADV_ALL=0, + SCAN_ALLOW_ADV_ALL_AND_INIT_RPA=2, + SCAN_ALLOW_ADV_END=4, + SCAN_ALLOW_ADV_WLST=1, + SCAN_ALLOW_ADV_WLST_AND_INIT_RPA=3 +} scan_filter_policy; + +typedef struct back_packet_info back_packet_info, *Pback_packet_info; + +struct back_packet_info { + uint8_t used; + uint8_t advmode_headlen; + uint8_t head_flags; + struct bd_addr adva_addr; + struct bd_addr targeta_addr; + undefined field_0xf; + uint16_t adi; + uint8_t auxptr[3]; + uint8_t syncinfo[18]; + uint8_t txpwr; + uint8_t datalen; + uint8_t data[255]; +}; + +typedef enum rnd_addr_type { + RND_NON_RSLV_ADDR=0, + RND_RSLV_ADDR=64, + RND_STATIC_ADDR=-64 +} rnd_addr_type; + +typedef enum adv_channel_map { + ADV_ALL_CHNLS_EN=7, + ADV_CHNL_37_EN=1, + ADV_CHNL_38_EN=2, + ADV_CHNL_39_EN=4, + ADV_CHNL_END=8 +} adv_channel_map; + +typedef struct crc_init crc_init, *Pcrc_init; + +struct crc_init { + uint8_t crc[3]; +}; + +typedef enum scan_dup_filter_policy { + SCAN_FILT_DUPLIC_DIS=0, + SCAN_FILT_DUPLIC_EN=1, + SCAN_FILT_DUPLIC_END=2 +} scan_dup_filter_policy; + +typedef enum le_evt_mask { + LE_ADV_REP_EVT_BIT=1, + LE_ADV_REP_EVT_MSK=2, + LE_CH_SEL_ALGO_EVT_BIT=19, + LE_CH_SEL_ALGO_EVT_MSK=524288, + LE_CON_CMP_EVT_BIT=0, + LE_CON_CMP_EVT_MSK=1, + LE_CON_RD_REM_FEAT_EVT_BIT=3, + LE_CON_RD_REM_FEAT_EVT_MSK=8, + LE_CON_UPD_EVT_BIT=2, + LE_CON_UPD_EVT_MSK=4, + LE_DATA_LEN_CHG_EVT_BIT=6, + LE_DATA_LEN_CHG_EVT_MSK=64, + LE_DFT_EVT_MSK=31, + LE_DIR_ADV_REP_EVT_BIT=10, + LE_DIR_ADV_REP_EVT_MSK=1024, + LE_ENH_CON_CMP_EVT_BIT=9, + LE_ENH_CON_CMP_EVT_MSK=512, + LE_EXT_ADV_REP_EVT_BIT=12, + LE_EXT_ADV_REP_EVT_MSK=4096, + LE_EXT_ADV_SET_TER_EVT_BIT=17, + LE_EXT_ADV_SET_TER_EVT_MSK=131072, + LE_EXT_SCAN_TO_EVT_BIT=16, + LE_EXT_SCAN_TO_EVT_MSK=65536, + LE_GEN_DHKEY_CMP_EVT_BIT=8, + LE_GEN_DHKEY_CMP_EVT_MSK=256, + LE_LG_TR_KEY_REQ_EVT_BIT=4, + LE_LG_TR_KEY_REQ_EVT_MSK=16, + LE_PER_ADV_REP_EVT_BIT=14, + LE_PER_ADV_REP_EVT_MSK=16384, + LE_PER_ADV_SYNC_EST_EVT_BIT=13, + LE_PER_ADV_SYNC_EST_EVT_MSK=8192, + LE_PER_ADV_SYNC_LOST_EVT_BIT=15, + LE_PER_ADV_SYNC_LOST_EVT_MSK=-32768, + LE_PHY_UPD_CMP_EVT_BIT=11, + LE_PHY_UPD_CMP_EVT_MSK=2048, + LE_RD_LOC_P256_PUB_KEY_CMP_EVT_BIT=7, + LE_RD_LOC_P256_PUB_KEY_CMP_EVT_MSK=-128, + LE_REM_CON_PARA_REQ_EVT_BIT=5, + LE_REM_CON_PARA_REQ_EVT_MSK=32, + LE_SCAN_REQ_REC_EVT_BIT=18, + LE_SCAN_REQ_REC_EVT_MSK=262144 +} le_evt_mask; + +typedef enum bl_flag_wl { + LLM_UTIL_BL_CLEAR_WL=1, + LLM_UTIL_BL_NO_ACTION_WL=0, + LLM_UTIL_BL_SET_WL=2 +} bl_flag_wl; + +typedef struct llm_util_cnx_bd_addr_tag llm_util_cnx_bd_addr_tag, *Pllm_util_cnx_bd_addr_tag; + +struct llm_util_cnx_bd_addr_tag { + struct co_list_hdr hdr; + struct bd_addr dev_addr; + uint16_t conhdl; + uint8_t dev_addr_type; + _Bool in_wl; + undefined field_0xe; + undefined field_0xf; +}; + +typedef struct sha256_link_item sha256_link_item, *Psha256_link_item; + +struct sha256_link_item { + struct SEC_Eng_SHA256_Link_Ctx ctx; + struct SEC_Eng_SHA_Link_Config_Type linkCfg; + uint32_t tmp[16]; + uint32_t pad[16]; +}; + +typedef struct sha256_link_item sha256_link_item_t; + +typedef struct bt_pub_key_cb bt_pub_key_cb, *Pbt_pub_key_cb; + +struct bt_pub_key_cb { + void (* func)(u8_t *); + struct bt_pub_key_cb * _next; +}; + +typedef struct pbuf_rom pbuf_rom, *Ppbuf_rom; + +struct pbuf_rom { + struct pbuf * next; + void * payload; +}; + +typedef enum pbuf_layer { + PBUF_IP=-94, + PBUF_LINK=-114, + PBUF_RAW=0, + PBUF_RAW_TX=-128, + PBUF_TRANSPORT=-74 +} pbuf_layer; + +typedef enum pbuf_type { + PBUF_POOL=386, + PBUF_RAM=640, + PBUF_REF=65, + PBUF_ROM=1 +} pbuf_type; + +typedef enum SF_Ctrl_Sahb_Type { + SF_CTRL_FLASH_CLOCK=1, + SF_CTRL_SAHB_CLOCK=0 +} SF_Ctrl_Sahb_Type; + +typedef enum SF_Ctrl_Dmy_Mode_Type { + SF_CTRL_DUMMY_1_LINE=0, + SF_CTRL_DUMMY_2_LINES=1, + SF_CTRL_DUMMY_4_LINES=2 +} SF_Ctrl_Dmy_Mode_Type; + +typedef enum SF_Ctrl_Mode_Type { + SF_CTRL_QPI_MODE=1, + SF_CTRL_SPI_MODE=0 +} SF_Ctrl_Mode_Type; + +typedef enum SF_Ctrl_IO_Type { + SF_CTRL_DIO_MODE=3, + SF_CTRL_DO_MODE=1, + SF_CTRL_NIO_MODE=0, + SF_CTRL_QIO_MODE=4, + SF_CTRL_QO_MODE=2 +} SF_Ctrl_IO_Type; + +typedef enum SF_Ctrl_Data_Mode_Type { + SF_CTRL_DATA_1_LINE=0, + SF_CTRL_DATA_2_LINES=1, + SF_CTRL_DATA_4_LINES=2 +} SF_Ctrl_Data_Mode_Type; + +typedef struct SF_Ctrl_Cmd_Cfg_Type SF_Ctrl_Cmd_Cfg_Type, *PSF_Ctrl_Cmd_Cfg_Type; + +typedef enum SF_Ctrl_Cmd_Mode_Type { + SF_CTRL_CMD_1_LINE=0, + SF_CTRL_CMD_4_LINES=1 +} SF_Ctrl_Cmd_Mode_Type; + +typedef enum SF_Ctrl_Addr_Mode_Type { + SF_CTRL_ADDR_1_LINE=0, + SF_CTRL_ADDR_2_LINES=1, + SF_CTRL_ADDR_4_LINES=2 +} SF_Ctrl_Addr_Mode_Type; + +struct SF_Ctrl_Cmd_Cfg_Type { + uint8_t rwFlag; + enum SF_Ctrl_Cmd_Mode_Type cmdMode; + enum SF_Ctrl_Addr_Mode_Type addrMode; + uint8_t addrSize; + uint8_t dummyClks; + enum SF_Ctrl_Dmy_Mode_Type dummyMode; + enum SF_Ctrl_Data_Mode_Type dataMode; + uint8_t rsv[1]; + uint32_t nbData; + uint32_t cmdBuf[2]; +}; + +typedef struct SF_Ctrl_Cfg_Type SF_Ctrl_Cfg_Type, *PSF_Ctrl_Cfg_Type; + +typedef enum SF_Ctrl_Owner_Type { + SF_CTRL_OWNER_IAHB=1, + SF_CTRL_OWNER_SAHB=0 +} SF_Ctrl_Owner_Type; + +typedef enum SF_Ctrl_Ahb2sif_Type { + HIGH_SPEED_MODE_CLOCK=0, + REMOVE_CLOCK_CONSTRAIN=1 +} SF_Ctrl_Ahb2sif_Type; + +struct SF_Ctrl_Cfg_Type { + enum SF_Ctrl_Owner_Type owner; + enum SF_Ctrl_Sahb_Type sahbClock; + enum SF_Ctrl_Ahb2sif_Type ahb2sifMode; + uint8_t clkDelay; + uint8_t clkInvert; + uint8_t rxClkInvert; + uint8_t doDelay; + uint8_t diDelay; + uint8_t oeDelay; +}; + +typedef enum SF_Ctrl_Pad_Sel { + SF_CTRL_EMBEDDED_SEL=0, + SF_CTRL_EXTERNAL_0TO2_20TO22_SEL=2, + SF_CTRL_EXTERNAL_17TO22_SEL=1 +} SF_Ctrl_Pad_Sel; + +typedef enum SF_Ctrl_AES_Key_Type { + SF_CTRL_AES_128BITS=0, + SF_CTRL_AES_128BITS_DOUBLE_KEY=3, + SF_CTRL_AES_192BITS=2, + SF_CTRL_AES_256BITS=1 +} SF_Ctrl_AES_Key_Type; + +typedef struct mac_bss_info mac_bss_info, *Pmac_bss_info; + +typedef struct mac_edca_param_set mac_edca_param_set, *Pmac_edca_param_set; + +typedef struct mobility_domain mobility_domain, *Pmobility_domain; + +struct mac_edca_param_set { + uint8_t qos_info; + uint8_t acm; + undefined field_0x2; + undefined field_0x3; + uint32_t ac_param[4]; +}; + +struct mobility_domain { + uint16_t mdid; + uint8_t ft_capability_policy; + undefined field_0x3; +}; + +struct mac_bss_info { + struct mac_htcapability ht_cap; + struct mac_addr.conflict bssid; + struct mac_ssid ssid; + uint16_t bsstype; + undefined field_0x4a; + undefined field_0x4b; + struct scan_chan_tag * chan; + uint16_t center_freq1; + uint16_t center_freq2; + uint16_t beacon_period; + uint16_t cap_info; + struct mac_rateset rate_set; + undefined field_0x65; + undefined field_0x66; + undefined field_0x67; + struct mac_edca_param_set edca_param; + int8_t rssi; + int8_t ppm_rel; + int8_t ppm_abs; + uint8_t high_11b_rate; + uint16_t prot_status; + uint8_t bw; + uint8_t phy_bw; + uint8_t power_constraint; + undefined field_0x85; + undefined field_0x86; + undefined field_0x87; + uint32_t valid_flags; + struct mobility_domain mde; + _Bool is_supplicant_enabled; + struct SecurityMode_t wpa_wpa2_wep; + struct Cipher_t.conflict wpa_mcstCipher; + struct Cipher_t.conflict wpa_ucstCipher; + struct Cipher_t.conflict rsn_mcstCipher; + struct Cipher_t.conflict rsn_ucstCipher; + _Bool is_pmf_required; + _Bool is_wpa2_prefered; + uint8_t rsn_wpa_ie[32]; + uint8_t rsn_wpa_ie_len; + uint16_t beacon_interval; + uint16_t aid_bitmap; + uint16_t max_listen_interval; + uint8_t sec_type; + undefined field_0xc1; + undefined field_0xc2; + undefined field_0xc3; +}; + +typedef struct me_env_tag me_env_tag, *Pme_env_tag; + +struct me_env_tag { + uint32_t active_vifs; + uint32_t ps_disable_vifs; + ke_task_id_t requester_id; + undefined field_0xa; + undefined field_0xb; + struct mac_htcapability ht_cap; + uint16_t tx_lft; + _Bool ht_supported; + undefined field_0x2f; + struct me_chan_config_req chan; + uint8_t stbc_nss; + uint8_t phy_bw_max; + _Bool ps_on; + undefined field_0x131; + undefined field_0x132; + undefined field_0x133; +}; + +typedef union anon_union.conflict19 anon_union.conflict19, *Panon_union.conflict19; + +union anon_union.conflict19 { + struct anon_struct.conflict42 wme_action; + struct anon_struct.conflict43 chan_switch; + struct anon_struct.conflict43 ext_chan_switch; + struct anon_struct.conflict44 measurement; + struct anon_struct.conflict45 addba_req; + struct anon_struct.conflict46 addba_resp; + struct anon_struct.conflict47 delba; + struct anon_struct.conflict43 self_prot; + struct anon_struct.conflict43 mesh_action; + struct anon_struct.conflict48 sa_query; + struct anon_struct.conflict49 ht_smps; + struct anon_struct.conflict50 ht_notify_cw; + struct anon_struct.conflict51 tdls_discover_resp; + struct anon_struct.conflict52 vht_opmode_notif; + struct anon_struct.conflict53 vht_group_notif; + struct anon_struct.conflict54 tpc_report; + struct anon_struct.conflict55 ftm; +}; + +typedef struct anon_struct.conflict41 anon_struct.conflict41, *Panon_struct.conflict41; + +struct anon_struct.conflict41 { + __le64 timestamp; + __le16 beacon_int; + __le16 capab_info; + u8[0] variable; +}; + +typedef struct anon_struct.conflict40 anon_struct.conflict40, *Panon_struct.conflict40; + +struct anon_struct.conflict40 { + __le16 capab_info; + __le16 listen_interval; + u8 current_ap[6]; + u8[0] variable; +}; + +typedef union anon_union.conflict20 anon_union.conflict20, *Panon_union.conflict20; + +typedef struct anon_struct.conflict36 anon_struct.conflict36, *Panon_struct.conflict36; + +typedef struct anon_struct.conflict37 anon_struct.conflict37, *Panon_struct.conflict37; + +typedef struct anon_struct.conflict38 anon_struct.conflict38, *Panon_struct.conflict38; + +typedef struct anon_struct.conflict39 anon_struct.conflict39, *Panon_struct.conflict39; + +struct anon_struct.conflict39 { + __le16 capab_info; + __le16 status_code; + __le16 aid; + u8[0] variable; +}; + +struct anon_struct.conflict38 { + __le16 capab_info; + __le16 listen_interval; + u8[0] variable; +}; + +struct anon_struct.conflict37 { + __le16 reason_code; +}; + +struct anon_struct.conflict36 { + __le16 auth_alg; + __le16 auth_transaction; + __le16 status_code; + u8[0] variable; +}; + +union anon_union.conflict20 { + struct anon_struct.conflict36 auth; + struct anon_struct.conflict37 deauth; + struct anon_struct.conflict38 assoc_req; + struct anon_struct.conflict39 assoc_resp; + struct anon_struct.conflict39 reassoc_resp; + struct anon_struct.conflict40 reassoc_req; + struct anon_struct.conflict37 disassoc; + struct anon_struct.conflict41 beacon; + struct anon_struct probe_req; + struct anon_struct.conflict41 probe_resp; +}; + +typedef struct ieee80211_mgmt ieee80211_mgmt, *Pieee80211_mgmt; + +struct ieee80211_mgmt { + __le16 frame_control; + __le16 duration; + u8 da[6]; + u8 sa[6]; + u8 bssid[6]; + __le16 seq_ctrl; + undefined field_0x18; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; + undefined field_0x1c; + undefined field_0x1d; + undefined field_0x1e; + undefined field_0x1f; + undefined field_0x20; + undefined field_0x21; + undefined field_0x22; + undefined field_0x23; + undefined field_0x24; + undefined field_0x25; + undefined field_0x26; + undefined field_0x27; + undefined field_0x28; + undefined field_0x29; + undefined field_0x2a; + undefined field_0x2b; + undefined field_0x2c; + undefined field_0x2d; + undefined field_0x2e; + undefined field_0x2f; + undefined field_0x30; + undefined field_0x31; +}; + +typedef enum ieee80211_reasoncode { + WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT=15, + WLAN_REASON_CIPHER_SUITE_REJECTED=24, + WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA=6, + WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA=7, + WLAN_REASON_DEAUTH_LEAVING=3, + WLAN_REASON_DISASSOC_AP_BUSY=5, + WLAN_REASON_DISASSOC_BAD_POWER=10, + WLAN_REASON_DISASSOC_BAD_SUPP_CHAN=11, + WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY=4, + WLAN_REASON_DISASSOC_LOW_ACK=34, + WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP=35, + WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH=33, + WLAN_REASON_DISASSOC_STA_HAS_LEFT=8, + WLAN_REASON_DISASSOC_UNSPECIFIED_QOS=32, + WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT=16, + WLAN_REASON_IEEE8021X_FAILED=23, + WLAN_REASON_IE_DIFFERENT=17, + WLAN_REASON_INVALID_AKMP=20, + WLAN_REASON_INVALID_GROUP_CIPHER=18, + WLAN_REASON_INVALID_IE=13, + WLAN_REASON_INVALID_PAIRWISE_CIPHER=19, + WLAN_REASON_INVALID_RSN_IE_CAP=22, + WLAN_REASON_MAC_EXISTS_IN_MBSS=64, + WLAN_REASON_MESH_CHAN=66, + WLAN_REASON_MESH_CHAN_REGULATORY=65, + WLAN_REASON_MESH_CLOSE=55, + WLAN_REASON_MESH_CONFIG=54, + WLAN_REASON_MESH_CONFIRM_TIMEOUT=57, + WLAN_REASON_MESH_INCONSISTENT_PARAM=59, + WLAN_REASON_MESH_INVALID_GTK=58, + WLAN_REASON_MESH_INVALID_SECURITY=60, + WLAN_REASON_MESH_MAX_PEERS=53, + WLAN_REASON_MESH_MAX_RETRIES=56, + WLAN_REASON_MESH_PATH_DEST_UNREACHABLE=63, + WLAN_REASON_MESH_PATH_ERROR=61, + WLAN_REASON_MESH_PATH_NOFORWARD=62, + WLAN_REASON_MESH_PEER_CANCELED=52, + WLAN_REASON_MIC_FAILURE=14, + WLAN_REASON_PREV_AUTH_NOT_VALID=2, + WLAN_REASON_QSTA_CIPHER_NOT_SUPP=45, + WLAN_REASON_QSTA_LEAVE_QBSS=36, + WLAN_REASON_QSTA_NOT_USE=37, + WLAN_REASON_QSTA_REQUIRE_SETUP=38, + WLAN_REASON_QSTA_TIMEOUT=39, + WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH=9, + WLAN_REASON_TDLS_TEARDOWN_UNREACHABLE=25, + WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED=26, + WLAN_REASON_UNSPECIFIED=1, + WLAN_REASON_UNSUPP_RSN_VERSION=21 +} ieee80211_reasoncode; + +typedef struct anon_struct.conflict60 anon_struct.conflict60, *Panon_struct.conflict60; + +struct anon_struct.conflict60 { + u8 category; + union anon_union_for_u.conflict2 u; +}; + +typedef struct ke_msg_handler.conflict91 ke_msg_handler.conflict91, *Pke_msg_handler.conflict91; + +struct ke_msg_handler.conflict91 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict2 ke_msg_handler.conflict2, *Pke_msg_handler.conflict2; + +struct ke_msg_handler.conflict2 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict27 ke_msg_handler.conflict27, *Pke_msg_handler.conflict27; + +struct ke_msg_handler.conflict27 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict86 ke_msg_handler.conflict86, *Pke_msg_handler.conflict86; + +struct ke_msg_handler.conflict86 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_task_desc.conflict3 ke_task_desc.conflict3, *Pke_task_desc.conflict3; + +struct ke_task_desc.conflict3 { + struct ke_state_handler * state_handler; + struct ke_state_handler * default_handler; + ke_state_t * state; + uint16_t state_max; + uint16_t idx_max; +}; + +typedef struct ke_msg_handler.conflict38 ke_msg_handler.conflict38, *Pke_msg_handler.conflict38; + +struct ke_msg_handler.conflict38 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict3 ke_msg_handler.conflict3, *Pke_msg_handler.conflict3; + +struct ke_msg_handler.conflict3 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict158 ke_msg_handler.conflict158, *Pke_msg_handler.conflict158; + +struct ke_msg_handler.conflict158 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict28 ke_msg_handler.conflict28, *Pke_msg_handler.conflict28; + +struct ke_msg_handler.conflict28 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_task_desc.conflict1 ke_task_desc.conflict1, *Pke_task_desc.conflict1; + +struct ke_task_desc.conflict1 { + struct ke_state_handler * state_handler; + struct ke_state_handler * default_handler; + ke_state_t * state; + uint16_t state_max; + uint16_t idx_max; +}; + +typedef struct ke_task_desc.conflict2 ke_task_desc.conflict2, *Pke_task_desc.conflict2; + +struct ke_task_desc.conflict2 { + struct ke_state_handler * state_handler; + struct ke_state_handler * default_handler; + ke_state_t * state; + uint16_t state_max; + uint16_t idx_max; +}; + +typedef struct ke_msg_handler.conflict16 ke_msg_handler.conflict16, *Pke_msg_handler.conflict16; + +struct ke_msg_handler.conflict16 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict39 ke_msg_handler.conflict39, *Pke_msg_handler.conflict39; + +struct ke_msg_handler.conflict39 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict116 ke_msg_handler.conflict116, *Pke_msg_handler.conflict116; + +struct ke_msg_handler.conflict116 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict9 ke_msg_handler.conflict9, *Pke_msg_handler.conflict9; + +struct ke_msg_handler.conflict9 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict48 ke_msg_handler.conflict48, *Pke_msg_handler.conflict48; + +struct ke_msg_handler.conflict48 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict6 ke_msg_handler.conflict6, *Pke_msg_handler.conflict6; + +struct ke_msg_handler.conflict6 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict5 ke_msg_handler.conflict5, *Pke_msg_handler.conflict5; + +struct ke_msg_handler.conflict5 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict8 ke_msg_handler.conflict8, *Pke_msg_handler.conflict8; + +struct ke_msg_handler.conflict8 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict7 ke_msg_handler.conflict7, *Pke_msg_handler.conflict7; + +struct ke_msg_handler.conflict7 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict13 ke_msg_handler.conflict13, *Pke_msg_handler.conflict13; + +struct ke_msg_handler.conflict13 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict1 ke_msg_handler.conflict1, *Pke_msg_handler.conflict1; + +struct ke_msg_handler.conflict1 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict4 ke_msg_handler.conflict4, *Pke_msg_handler.conflict4; + +struct ke_msg_handler.conflict4 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict59 ke_msg_handler.conflict59, *Pke_msg_handler.conflict59; + +struct ke_msg_handler.conflict59 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict49 ke_msg_handler.conflict49, *Pke_msg_handler.conflict49; + +struct ke_msg_handler.conflict49 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict37 ke_msg_handler.conflict37, *Pke_msg_handler.conflict37; + +struct ke_msg_handler.conflict37 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict117 ke_msg_handler.conflict117, *Pke_msg_handler.conflict117; + +struct ke_msg_handler.conflict117 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict110 ke_msg_handler.conflict110, *Pke_msg_handler.conflict110; + +struct ke_msg_handler.conflict110 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict95 ke_msg_handler.conflict95, *Pke_msg_handler.conflict95; + +struct ke_msg_handler.conflict95 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict72 ke_msg_handler.conflict72, *Pke_msg_handler.conflict72; + +struct ke_msg_handler.conflict72 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict101 ke_msg_handler.conflict101, *Pke_msg_handler.conflict101; + +struct ke_msg_handler.conflict101 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict83 ke_msg_handler.conflict83, *Pke_msg_handler.conflict83; + +struct ke_msg_handler.conflict83 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict113 ke_msg_handler.conflict113, *Pke_msg_handler.conflict113; + +struct ke_msg_handler.conflict113 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict73 ke_msg_handler.conflict73, *Pke_msg_handler.conflict73; + +struct ke_msg_handler.conflict73 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict102 ke_msg_handler.conflict102, *Pke_msg_handler.conflict102; + +struct ke_msg_handler.conflict102 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict84 ke_msg_handler.conflict84, *Pke_msg_handler.conflict84; + +struct ke_msg_handler.conflict84 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict171 ke_msg_handler.conflict171, *Pke_msg_handler.conflict171; + +struct ke_msg_handler.conflict171 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict96 ke_msg_handler.conflict96, *Pke_msg_handler.conflict96; + +struct ke_msg_handler.conflict96 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict114 ke_msg_handler.conflict114, *Pke_msg_handler.conflict114; + +struct ke_msg_handler.conflict114 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_task_desc.conflict ke_task_desc.conflict, *Pke_task_desc.conflict; + +struct ke_task_desc.conflict { + struct ke_state_handler * state_handler; + struct ke_state_handler * default_handler; + ke_state_t * state; + uint16_t state_max; + uint16_t idx_max; +}; + +typedef struct ke_task_desc ke_task_desc, *Pke_task_desc; + +struct ke_task_desc { + struct ke_state_handler * state_handler; + struct ke_state_handler * default_handler; + ke_state_t * state; + uint16_t state_max; + uint16_t idx_max; +}; + +typedef struct ke_msg_handler.conflict170 ke_msg_handler.conflict170, *Pke_msg_handler.conflict170; + +struct ke_msg_handler.conflict170 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict29 ke_msg_handler.conflict29, *Pke_msg_handler.conflict29; + +struct ke_msg_handler.conflict29 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict85 ke_msg_handler.conflict85, *Pke_msg_handler.conflict85; + +struct ke_msg_handler.conflict85 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict17 ke_msg_handler.conflict17, *Pke_msg_handler.conflict17; + +struct ke_msg_handler.conflict17 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict94 ke_msg_handler.conflict94, *Pke_msg_handler.conflict94; + +struct ke_msg_handler.conflict94 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict82 ke_msg_handler.conflict82, *Pke_msg_handler.conflict82; + +struct ke_msg_handler.conflict82 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict98 ke_msg_handler.conflict98, *Pke_msg_handler.conflict98; + +struct ke_msg_handler.conflict98 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict18 ke_msg_handler.conflict18, *Pke_msg_handler.conflict18; + +struct ke_msg_handler.conflict18 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict89 ke_msg_handler.conflict89, *Pke_msg_handler.conflict89; + +struct ke_msg_handler.conflict89 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict88 ke_msg_handler.conflict88, *Pke_msg_handler.conflict88; + +struct ke_msg_handler.conflict88 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict87 ke_msg_handler.conflict87, *Pke_msg_handler.conflict87; + +struct ke_msg_handler.conflict87 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict81 ke_msg_handler.conflict81, *Pke_msg_handler.conflict81; + +struct ke_msg_handler.conflict81 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict174 ke_msg_handler.conflict174, *Pke_msg_handler.conflict174; + +struct ke_msg_handler.conflict174 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict80 ke_msg_handler.conflict80, *Pke_msg_handler.conflict80; + +struct ke_msg_handler.conflict80 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict42 ke_msg_handler.conflict42, *Pke_msg_handler.conflict42; + +struct ke_msg_handler.conflict42 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict79 ke_msg_handler.conflict79, *Pke_msg_handler.conflict79; + +struct ke_msg_handler.conflict79 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict78 ke_msg_handler.conflict78, *Pke_msg_handler.conflict78; + +struct ke_msg_handler.conflict78 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict77 ke_msg_handler.conflict77, *Pke_msg_handler.conflict77; + +struct ke_msg_handler.conflict77 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict76 ke_msg_handler.conflict76, *Pke_msg_handler.conflict76; + +struct ke_msg_handler.conflict76 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict75 ke_msg_handler.conflict75, *Pke_msg_handler.conflict75; + +struct ke_msg_handler.conflict75 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict74 ke_msg_handler.conflict74, *Pke_msg_handler.conflict74; + +struct ke_msg_handler.conflict74 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict71 ke_msg_handler.conflict71, *Pke_msg_handler.conflict71; + +struct ke_msg_handler.conflict71 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict70 ke_msg_handler.conflict70, *Pke_msg_handler.conflict70; + +struct ke_msg_handler.conflict70 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict53 ke_msg_handler.conflict53, *Pke_msg_handler.conflict53; + +struct ke_msg_handler.conflict53 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict69 ke_msg_handler.conflict69, *Pke_msg_handler.conflict69; + +struct ke_msg_handler.conflict69 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict68 ke_msg_handler.conflict68, *Pke_msg_handler.conflict68; + +struct ke_msg_handler.conflict68 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict67 ke_msg_handler.conflict67, *Pke_msg_handler.conflict67; + +struct ke_msg_handler.conflict67 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict66 ke_msg_handler.conflict66, *Pke_msg_handler.conflict66; + +struct ke_msg_handler.conflict66 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict65 ke_msg_handler.conflict65, *Pke_msg_handler.conflict65; + +struct ke_msg_handler.conflict65 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict64 ke_msg_handler.conflict64, *Pke_msg_handler.conflict64; + +struct ke_msg_handler.conflict64 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict63 ke_msg_handler.conflict63, *Pke_msg_handler.conflict63; + +struct ke_msg_handler.conflict63 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict62 ke_msg_handler.conflict62, *Pke_msg_handler.conflict62; + +struct ke_msg_handler.conflict62 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict152 ke_msg_handler.conflict152, *Pke_msg_handler.conflict152; + +struct ke_msg_handler.conflict152 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict61 ke_msg_handler.conflict61, *Pke_msg_handler.conflict61; + +struct ke_msg_handler.conflict61 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict60 ke_msg_handler.conflict60, *Pke_msg_handler.conflict60; + +struct ke_msg_handler.conflict60 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict ke_msg_handler.conflict, *Pke_msg_handler.conflict; + +struct ke_msg_handler.conflict { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict106 ke_msg_handler.conflict106, *Pke_msg_handler.conflict106; + +struct ke_msg_handler.conflict106 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict97 ke_msg_handler.conflict97, *Pke_msg_handler.conflict97; + +struct ke_msg_handler.conflict97 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict43 ke_msg_handler.conflict43, *Pke_msg_handler.conflict43; + +struct ke_msg_handler.conflict43 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict58 ke_msg_handler.conflict58, *Pke_msg_handler.conflict58; + +struct ke_msg_handler.conflict58 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict57 ke_msg_handler.conflict57, *Pke_msg_handler.conflict57; + +struct ke_msg_handler.conflict57 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict56 ke_msg_handler.conflict56, *Pke_msg_handler.conflict56; + +struct ke_msg_handler.conflict56 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict164 ke_msg_handler.conflict164, *Pke_msg_handler.conflict164; + +struct ke_msg_handler.conflict164 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict55 ke_msg_handler.conflict55, *Pke_msg_handler.conflict55; + +struct ke_msg_handler.conflict55 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict54 ke_msg_handler.conflict54, *Pke_msg_handler.conflict54; + +struct ke_msg_handler.conflict54 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef enum KE_TASK_STATUS { + KE_TASK_ALREADY_EXISTS=4, + KE_TASK_CAPA_EXCEEDED=3, + KE_TASK_FAIL=1, + KE_TASK_OK=0, + KE_TASK_UNKNOWN=2 +} KE_TASK_STATUS; + +typedef struct ke_msg_handler.conflict52 ke_msg_handler.conflict52, *Pke_msg_handler.conflict52; + +struct ke_msg_handler.conflict52 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict51 ke_msg_handler.conflict51, *Pke_msg_handler.conflict51; + +struct ke_msg_handler.conflict51 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict50 ke_msg_handler.conflict50, *Pke_msg_handler.conflict50; + +struct ke_msg_handler.conflict50 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict139 ke_msg_handler.conflict139, *Pke_msg_handler.conflict139; + +struct ke_msg_handler.conflict139 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict137 ke_msg_handler.conflict137, *Pke_msg_handler.conflict137; + +struct ke_msg_handler.conflict137 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict138 ke_msg_handler.conflict138, *Pke_msg_handler.conflict138; + +struct ke_msg_handler.conflict138 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict135 ke_msg_handler.conflict135, *Pke_msg_handler.conflict135; + +struct ke_msg_handler.conflict135 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict136 ke_msg_handler.conflict136, *Pke_msg_handler.conflict136; + +struct ke_msg_handler.conflict136 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict133 ke_msg_handler.conflict133, *Pke_msg_handler.conflict133; + +struct ke_msg_handler.conflict133 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict134 ke_msg_handler.conflict134, *Pke_msg_handler.conflict134; + +struct ke_msg_handler.conflict134 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict131 ke_msg_handler.conflict131, *Pke_msg_handler.conflict131; + +struct ke_msg_handler.conflict131 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict132 ke_msg_handler.conflict132, *Pke_msg_handler.conflict132; + +struct ke_msg_handler.conflict132 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict130 ke_msg_handler.conflict130, *Pke_msg_handler.conflict130; + +struct ke_msg_handler.conflict130 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict103 ke_msg_handler.conflict103, *Pke_msg_handler.conflict103; + +struct ke_msg_handler.conflict103 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict119 ke_msg_handler.conflict119, *Pke_msg_handler.conflict119; + +struct ke_msg_handler.conflict119 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict128 ke_msg_handler.conflict128, *Pke_msg_handler.conflict128; + +struct ke_msg_handler.conflict128 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict129 ke_msg_handler.conflict129, *Pke_msg_handler.conflict129; + +struct ke_msg_handler.conflict129 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict126 ke_msg_handler.conflict126, *Pke_msg_handler.conflict126; + +struct ke_msg_handler.conflict126 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict127 ke_msg_handler.conflict127, *Pke_msg_handler.conflict127; + +struct ke_msg_handler.conflict127 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict124 ke_msg_handler.conflict124, *Pke_msg_handler.conflict124; + +struct ke_msg_handler.conflict124 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict125 ke_msg_handler.conflict125, *Pke_msg_handler.conflict125; + +struct ke_msg_handler.conflict125 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict122 ke_msg_handler.conflict122, *Pke_msg_handler.conflict122; + +struct ke_msg_handler.conflict122 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict123 ke_msg_handler.conflict123, *Pke_msg_handler.conflict123; + +struct ke_msg_handler.conflict123 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict120 ke_msg_handler.conflict120, *Pke_msg_handler.conflict120; + +struct ke_msg_handler.conflict120 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict121 ke_msg_handler.conflict121, *Pke_msg_handler.conflict121; + +struct ke_msg_handler.conflict121 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict115 ke_msg_handler.conflict115, *Pke_msg_handler.conflict115; + +struct ke_msg_handler.conflict115 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict108 ke_msg_handler.conflict108, *Pke_msg_handler.conflict108; + +struct ke_msg_handler.conflict108 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict109 ke_msg_handler.conflict109, *Pke_msg_handler.conflict109; + +struct ke_msg_handler.conflict109 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict118 ke_msg_handler.conflict118, *Pke_msg_handler.conflict118; + +struct ke_msg_handler.conflict118 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict111 ke_msg_handler.conflict111, *Pke_msg_handler.conflict111; + +struct ke_msg_handler.conflict111 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict112 ke_msg_handler.conflict112, *Pke_msg_handler.conflict112; + +struct ke_msg_handler.conflict112 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict99 ke_msg_handler.conflict99, *Pke_msg_handler.conflict99; + +struct ke_msg_handler.conflict99 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict93 ke_msg_handler.conflict93, *Pke_msg_handler.conflict93; + +struct ke_msg_handler.conflict93 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict92 ke_msg_handler.conflict92, *Pke_msg_handler.conflict92; + +struct ke_msg_handler.conflict92 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict90 ke_msg_handler.conflict90, *Pke_msg_handler.conflict90; + +struct ke_msg_handler.conflict90 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict107 ke_msg_handler.conflict107, *Pke_msg_handler.conflict107; + +struct ke_msg_handler.conflict107 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict104 ke_msg_handler.conflict104, *Pke_msg_handler.conflict104; + +struct ke_msg_handler.conflict104 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict105 ke_msg_handler.conflict105, *Pke_msg_handler.conflict105; + +struct ke_msg_handler.conflict105 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict100 ke_msg_handler.conflict100, *Pke_msg_handler.conflict100; + +struct ke_msg_handler.conflict100 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict23 ke_msg_handler.conflict23, *Pke_msg_handler.conflict23; + +struct ke_msg_handler.conflict23 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict175 ke_msg_handler.conflict175, *Pke_msg_handler.conflict175; + +struct ke_msg_handler.conflict175 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict173 ke_msg_handler.conflict173, *Pke_msg_handler.conflict173; + +struct ke_msg_handler.conflict173 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict172 ke_msg_handler.conflict172, *Pke_msg_handler.conflict172; + +struct ke_msg_handler.conflict172 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict34 ke_msg_handler.conflict34, *Pke_msg_handler.conflict34; + +struct ke_msg_handler.conflict34 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict168 ke_msg_handler.conflict168, *Pke_msg_handler.conflict168; + +struct ke_msg_handler.conflict168 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict169 ke_msg_handler.conflict169, *Pke_msg_handler.conflict169; + +struct ke_msg_handler.conflict169 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict166 ke_msg_handler.conflict166, *Pke_msg_handler.conflict166; + +struct ke_msg_handler.conflict166 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict167 ke_msg_handler.conflict167, *Pke_msg_handler.conflict167; + +struct ke_msg_handler.conflict167 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict165 ke_msg_handler.conflict165, *Pke_msg_handler.conflict165; + +struct ke_msg_handler.conflict165 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict162 ke_msg_handler.conflict162, *Pke_msg_handler.conflict162; + +struct ke_msg_handler.conflict162 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict163 ke_msg_handler.conflict163, *Pke_msg_handler.conflict163; + +struct ke_msg_handler.conflict163 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict160 ke_msg_handler.conflict160, *Pke_msg_handler.conflict160; + +struct ke_msg_handler.conflict160 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict161 ke_msg_handler.conflict161, *Pke_msg_handler.conflict161; + +struct ke_msg_handler.conflict161 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict159 ke_msg_handler.conflict159, *Pke_msg_handler.conflict159; + +struct ke_msg_handler.conflict159 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict24 ke_msg_handler.conflict24, *Pke_msg_handler.conflict24; + +struct ke_msg_handler.conflict24 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict157 ke_msg_handler.conflict157, *Pke_msg_handler.conflict157; + +struct ke_msg_handler.conflict157 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict155 ke_msg_handler.conflict155, *Pke_msg_handler.conflict155; + +struct ke_msg_handler.conflict155 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict156 ke_msg_handler.conflict156, *Pke_msg_handler.conflict156; + +struct ke_msg_handler.conflict156 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict153 ke_msg_handler.conflict153, *Pke_msg_handler.conflict153; + +struct ke_msg_handler.conflict153 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict154 ke_msg_handler.conflict154, *Pke_msg_handler.conflict154; + +struct ke_msg_handler.conflict154 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict151 ke_msg_handler.conflict151, *Pke_msg_handler.conflict151; + +struct ke_msg_handler.conflict151 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict150 ke_msg_handler.conflict150, *Pke_msg_handler.conflict150; + +struct ke_msg_handler.conflict150 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict47 ke_msg_handler.conflict47, *Pke_msg_handler.conflict47; + +struct ke_msg_handler.conflict47 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict148 ke_msg_handler.conflict148, *Pke_msg_handler.conflict148; + +struct ke_msg_handler.conflict148 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict149 ke_msg_handler.conflict149, *Pke_msg_handler.conflict149; + +struct ke_msg_handler.conflict149 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict146 ke_msg_handler.conflict146, *Pke_msg_handler.conflict146; + +struct ke_msg_handler.conflict146 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict147 ke_msg_handler.conflict147, *Pke_msg_handler.conflict147; + +struct ke_msg_handler.conflict147 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict144 ke_msg_handler.conflict144, *Pke_msg_handler.conflict144; + +struct ke_msg_handler.conflict144 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict145 ke_msg_handler.conflict145, *Pke_msg_handler.conflict145; + +struct ke_msg_handler.conflict145 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict142 ke_msg_handler.conflict142, *Pke_msg_handler.conflict142; + +struct ke_msg_handler.conflict142 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict143 ke_msg_handler.conflict143, *Pke_msg_handler.conflict143; + +struct ke_msg_handler.conflict143 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict140 ke_msg_handler.conflict140, *Pke_msg_handler.conflict140; + +struct ke_msg_handler.conflict140 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict141 ke_msg_handler.conflict141, *Pke_msg_handler.conflict141; + +struct ke_msg_handler.conflict141 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict46 ke_msg_handler.conflict46, *Pke_msg_handler.conflict46; + +struct ke_msg_handler.conflict46 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict45 ke_msg_handler.conflict45, *Pke_msg_handler.conflict45; + +struct ke_msg_handler.conflict45 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict44 ke_msg_handler.conflict44, *Pke_msg_handler.conflict44; + +struct ke_msg_handler.conflict44 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict41 ke_msg_handler.conflict41, *Pke_msg_handler.conflict41; + +struct ke_msg_handler.conflict41 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict40 ke_msg_handler.conflict40, *Pke_msg_handler.conflict40; + +struct ke_msg_handler.conflict40 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict21 ke_msg_handler.conflict21, *Pke_msg_handler.conflict21; + +struct ke_msg_handler.conflict21 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict36 ke_msg_handler.conflict36, *Pke_msg_handler.conflict36; + +struct ke_msg_handler.conflict36 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict35 ke_msg_handler.conflict35, *Pke_msg_handler.conflict35; + +struct ke_msg_handler.conflict35 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict33 ke_msg_handler.conflict33, *Pke_msg_handler.conflict33; + +struct ke_msg_handler.conflict33 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict32 ke_msg_handler.conflict32, *Pke_msg_handler.conflict32; + +struct ke_msg_handler.conflict32 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict31 ke_msg_handler.conflict31, *Pke_msg_handler.conflict31; + +struct ke_msg_handler.conflict31 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict30 ke_msg_handler.conflict30, *Pke_msg_handler.conflict30; + +struct ke_msg_handler.conflict30 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict26 ke_msg_handler.conflict26, *Pke_msg_handler.conflict26; + +struct ke_msg_handler.conflict26 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict25 ke_msg_handler.conflict25, *Pke_msg_handler.conflict25; + +struct ke_msg_handler.conflict25 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict22 ke_msg_handler.conflict22, *Pke_msg_handler.conflict22; + +struct ke_msg_handler.conflict22 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict20 ke_msg_handler.conflict20, *Pke_msg_handler.conflict20; + +struct ke_msg_handler.conflict20 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict19 ke_msg_handler.conflict19, *Pke_msg_handler.conflict19; + +struct ke_msg_handler.conflict19 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict15 ke_msg_handler.conflict15, *Pke_msg_handler.conflict15; + +struct ke_msg_handler.conflict15 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict14 ke_msg_handler.conflict14, *Pke_msg_handler.conflict14; + +struct ke_msg_handler.conflict14 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict12 ke_msg_handler.conflict12, *Pke_msg_handler.conflict12; + +struct ke_msg_handler.conflict12 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict11 ke_msg_handler.conflict11, *Pke_msg_handler.conflict11; + +struct ke_msg_handler.conflict11 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct ke_msg_handler.conflict10 ke_msg_handler.conflict10, *Pke_msg_handler.conflict10; + +struct ke_msg_handler.conflict10 { + ke_msg_id_t id; + undefined field_0x2; + undefined field_0x3; + int (* func)(ke_msg_id_t, void *, ke_task_id_t, ke_task_id_t); +}; + +typedef struct mac_addr.conflict231 mac_addr.conflict231, *Pmac_addr.conflict231; + +struct mac_addr.conflict231 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict243 mac_addr.conflict243, *Pmac_addr.conflict243; + +struct mac_addr.conflict243 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict37 mac_addr.conflict37, *Pmac_addr.conflict37; + +struct mac_addr.conflict37 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict263 mac_addr.conflict263, *Pmac_addr.conflict263; + +struct mac_addr.conflict263 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict172 mac_addr.conflict172, *Pmac_addr.conflict172; + +struct mac_addr.conflict172 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict173 mac_addr.conflict173, *Pmac_addr.conflict173; + +struct mac_addr.conflict173 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict174 mac_addr.conflict174, *Pmac_addr.conflict174; + +struct mac_addr.conflict174 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict170 mac_addr.conflict170, *Pmac_addr.conflict170; + +struct mac_addr.conflict170 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict44 mac_addr.conflict44, *Pmac_addr.conflict44; + +struct mac_addr.conflict44 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict67 mac_addr.conflict67, *Pmac_addr.conflict67; + +struct mac_addr.conflict67 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict175 mac_addr.conflict175, *Pmac_addr.conflict175; + +struct mac_addr.conflict175 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict176 mac_addr.conflict176, *Pmac_addr.conflict176; + +struct mac_addr.conflict176 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict178 mac_addr.conflict178, *Pmac_addr.conflict178; + +struct mac_addr.conflict178 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict160 mac_addr.conflict160, *Pmac_addr.conflict160; + +struct mac_addr.conflict160 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict281 mac_addr.conflict281, *Pmac_addr.conflict281; + +struct mac_addr.conflict281 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict282 mac_addr.conflict282, *Pmac_addr.conflict282; + +struct mac_addr.conflict282 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict162 mac_addr.conflict162, *Pmac_addr.conflict162; + +struct mac_addr.conflict162 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict283 mac_addr.conflict283, *Pmac_addr.conflict283; + +struct mac_addr.conflict283 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict284 mac_addr.conflict284, *Pmac_addr.conflict284; + +struct mac_addr.conflict284 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict280 mac_addr.conflict280, *Pmac_addr.conflict280; + +struct mac_addr.conflict280 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict236 mac_addr.conflict236, *Pmac_addr.conflict236; + +struct mac_addr.conflict236 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict32 mac_addr.conflict32, *Pmac_addr.conflict32; + +struct mac_addr.conflict32 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict168 mac_addr.conflict168, *Pmac_addr.conflict168; + +struct mac_addr.conflict168 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict164 mac_addr.conflict164, *Pmac_addr.conflict164; + +struct mac_addr.conflict164 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict285 mac_addr.conflict285, *Pmac_addr.conflict285; + +struct mac_addr.conflict285 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict286 mac_addr.conflict286, *Pmac_addr.conflict286; + +struct mac_addr.conflict286 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict287 mac_addr.conflict287, *Pmac_addr.conflict287; + +struct mac_addr.conflict287 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict193 mac_addr.conflict193, *Pmac_addr.conflict193; + +struct mac_addr.conflict193 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict194 mac_addr.conflict194, *Pmac_addr.conflict194; + +struct mac_addr.conflict194 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict195 mac_addr.conflict195, *Pmac_addr.conflict195; + +struct mac_addr.conflict195 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict190 mac_addr.conflict190, *Pmac_addr.conflict190; + +struct mac_addr.conflict190 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict192 mac_addr.conflict192, *Pmac_addr.conflict192; + +struct mac_addr.conflict192 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict22 mac_addr.conflict22, *Pmac_addr.conflict22; + +struct mac_addr.conflict22 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict197 mac_addr.conflict197, *Pmac_addr.conflict197; + +struct mac_addr.conflict197 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict199 mac_addr.conflict199, *Pmac_addr.conflict199; + +struct mac_addr.conflict199 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict184 mac_addr.conflict184, *Pmac_addr.conflict184; + +struct mac_addr.conflict184 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict180 mac_addr.conflict180, *Pmac_addr.conflict180; + +struct mac_addr.conflict180 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict258 mac_addr.conflict258, *Pmac_addr.conflict258; + +struct mac_addr.conflict258 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict223 mac_addr.conflict223, *Pmac_addr.conflict223; + +struct mac_addr.conflict223 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict186 mac_addr.conflict186, *Pmac_addr.conflict186; + +struct mac_addr.conflict186 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict188 mac_addr.conflict188, *Pmac_addr.conflict188; + +struct mac_addr.conflict188 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict189 mac_addr.conflict189, *Pmac_addr.conflict189; + +struct mac_addr.conflict189 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict66 mac_addr.conflict66, *Pmac_addr.conflict66; + +struct mac_addr.conflict66 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict157 mac_addr.conflict157, *Pmac_addr.conflict157; + +struct mac_addr.conflict157 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict217 anon_struct.conflict217, *Panon_struct.conflict217; + +struct anon_struct.conflict217 { + uint32_t key[4]; +}; + +typedef struct mac_addr.conflict228 mac_addr.conflict228, *Pmac_addr.conflict228; + +struct mac_addr.conflict228 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict216 mac_addr.conflict216, *Pmac_addr.conflict216; + +struct mac_addr.conflict216 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict218 mac_addr.conflict218, *Pmac_addr.conflict218; + +struct mac_addr.conflict218 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict219 mac_addr.conflict219, *Pmac_addr.conflict219; + +struct mac_addr.conflict219 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict212 mac_addr.conflict212, *Pmac_addr.conflict212; + +struct mac_addr.conflict212 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict213 mac_addr.conflict213, *Pmac_addr.conflict213; + +struct mac_addr.conflict213 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict226 anon_struct.conflict226, *Panon_struct.conflict226; + +struct anon_struct.conflict226 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct mac_addr.conflict214 mac_addr.conflict214, *Pmac_addr.conflict214; + +struct mac_addr.conflict214 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict227 anon_struct.conflict227, *Panon_struct.conflict227; + +struct anon_struct.conflict227 { + uint32_t key[4]; +}; + +typedef struct mac_addr.conflict215 mac_addr.conflict215, *Pmac_addr.conflict215; + +struct mac_addr.conflict215 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict210 mac_addr.conflict210, *Pmac_addr.conflict210; + +struct mac_addr.conflict210 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict20 mac_addr.conflict20, *Pmac_addr.conflict20; + +struct mac_addr.conflict20 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict228 anon_struct.conflict228, *Panon_struct.conflict228; + +struct anon_struct.conflict228 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict229 anon_struct.conflict229, *Panon_struct.conflict229; + +struct anon_struct.conflict229 { + uint32_t key[4]; +}; + +typedef struct mac_addr.conflict209 mac_addr.conflict209, *Pmac_addr.conflict209; + +struct mac_addr.conflict209 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict205 mac_addr.conflict205, *Pmac_addr.conflict205; + +struct mac_addr.conflict205 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict207 mac_addr.conflict207, *Pmac_addr.conflict207; + +struct mac_addr.conflict207 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict208 mac_addr.conflict208, *Pmac_addr.conflict208; + +struct mac_addr.conflict208 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict18 mac_addr.conflict18, *Pmac_addr.conflict18; + +struct mac_addr.conflict18 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict51 mac_addr.conflict51, *Pmac_addr.conflict51; + +struct mac_addr.conflict51 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict19 mac_addr.conflict19, *Pmac_addr.conflict19; + +struct mac_addr.conflict19 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict236 anon_struct.conflict236, *Panon_struct.conflict236; + +struct anon_struct.conflict236 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict237 anon_struct.conflict237, *Panon_struct.conflict237; + +struct anon_struct.conflict237 { + uint32_t key[4]; +}; + +typedef struct mac_addr.conflict203 mac_addr.conflict203, *Pmac_addr.conflict203; + +struct mac_addr.conflict203 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict17 mac_addr.conflict17, *Pmac_addr.conflict17; + +struct mac_addr.conflict17 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict15 mac_addr.conflict15, *Pmac_addr.conflict15; + +struct mac_addr.conflict15 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict33 mac_addr.conflict33, *Pmac_addr.conflict33; + +struct mac_addr.conflict33 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict30 mac_addr.conflict30, *Pmac_addr.conflict30; + +struct mac_addr.conflict30 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict240 anon_struct.conflict240, *Panon_struct.conflict240; + +struct anon_struct.conflict240 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict241 anon_struct.conflict241, *Panon_struct.conflict241; + +struct anon_struct.conflict241 { + uint32_t key[4]; +}; + +typedef struct mac_addr.conflict117 mac_addr.conflict117, *Pmac_addr.conflict117; + +struct mac_addr.conflict117 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict118 mac_addr.conflict118, *Pmac_addr.conflict118; + +struct mac_addr.conflict118 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict239 mac_addr.conflict239, *Pmac_addr.conflict239; + +struct mac_addr.conflict239 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict119 mac_addr.conflict119, *Pmac_addr.conflict119; + +struct mac_addr.conflict119 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict29 mac_addr.conflict29, *Pmac_addr.conflict29; + +struct mac_addr.conflict29 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict113 mac_addr.conflict113, *Pmac_addr.conflict113; + +struct mac_addr.conflict113 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict234 mac_addr.conflict234, *Pmac_addr.conflict234; + +struct mac_addr.conflict234 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict114 mac_addr.conflict114, *Pmac_addr.conflict114; + +struct mac_addr.conflict114 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict235 mac_addr.conflict235, *Pmac_addr.conflict235; + +struct mac_addr.conflict235 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict27 mac_addr.conflict27, *Pmac_addr.conflict27; + +struct mac_addr.conflict27 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict115 mac_addr.conflict115, *Pmac_addr.conflict115; + +struct mac_addr.conflict115 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict248 anon_struct.conflict248, *Panon_struct.conflict248; + +struct anon_struct.conflict248 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct mac_addr.conflict28 mac_addr.conflict28, *Pmac_addr.conflict28; + +struct mac_addr.conflict28 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict116 mac_addr.conflict116, *Pmac_addr.conflict116; + +struct mac_addr.conflict116 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict249 anon_struct.conflict249, *Panon_struct.conflict249; + +struct anon_struct.conflict249 { + uint32_t key[4]; +}; + +typedef struct mac_addr.conflict237 mac_addr.conflict237, *Pmac_addr.conflict237; + +struct mac_addr.conflict237 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict25 mac_addr.conflict25, *Pmac_addr.conflict25; + +struct mac_addr.conflict25 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict230 mac_addr.conflict230, *Pmac_addr.conflict230; + +struct mac_addr.conflict230 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict110 mac_addr.conflict110, *Pmac_addr.conflict110; + +struct mac_addr.conflict110 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict23 mac_addr.conflict23, *Pmac_addr.conflict23; + +struct mac_addr.conflict23 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict111 mac_addr.conflict111, *Pmac_addr.conflict111; + +struct mac_addr.conflict111 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict244 anon_struct.conflict244, *Panon_struct.conflict244; + +struct anon_struct.conflict244 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct mac_addr.conflict232 mac_addr.conflict232, *Pmac_addr.conflict232; + +struct mac_addr.conflict232 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict24 mac_addr.conflict24, *Pmac_addr.conflict24; + +struct mac_addr.conflict24 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict112 mac_addr.conflict112, *Pmac_addr.conflict112; + +struct mac_addr.conflict112 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict245 anon_struct.conflict245, *Panon_struct.conflict245; + +struct anon_struct.conflict245 { + uint32_t key[4]; +}; + +typedef struct mac_addr.conflict40 mac_addr.conflict40, *Pmac_addr.conflict40; + +struct mac_addr.conflict40 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict252 anon_struct.conflict252, *Panon_struct.conflict252; + +struct anon_struct.conflict252 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct mac_addr.conflict106 mac_addr.conflict106, *Pmac_addr.conflict106; + +struct mac_addr.conflict106 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict107 mac_addr.conflict107, *Pmac_addr.conflict107; + +struct mac_addr.conflict107 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict108 mac_addr.conflict108, *Pmac_addr.conflict108; + +struct mac_addr.conflict108 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict229 mac_addr.conflict229, *Pmac_addr.conflict229; + +struct mac_addr.conflict229 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict109 mac_addr.conflict109, *Pmac_addr.conflict109; + +struct mac_addr.conflict109 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict102 mac_addr.conflict102, *Pmac_addr.conflict102; + +struct mac_addr.conflict102 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict103 mac_addr.conflict103, *Pmac_addr.conflict103; + +struct mac_addr.conflict103 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict224 mac_addr.conflict224, *Pmac_addr.conflict224; + +struct mac_addr.conflict224 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict75 mac_addr.conflict75, *Pmac_addr.conflict75; + +struct mac_addr.conflict75 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict38 mac_addr.conflict38, *Pmac_addr.conflict38; + +struct mac_addr.conflict38 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict104 mac_addr.conflict104, *Pmac_addr.conflict104; + +struct mac_addr.conflict104 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict225 mac_addr.conflict225, *Pmac_addr.conflict225; + +struct mac_addr.conflict225 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict139 anon_struct.conflict139, *Panon_struct.conflict139; + +struct anon_struct.conflict139 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct mac_addr.conflict39 mac_addr.conflict39, *Pmac_addr.conflict39; + +struct mac_addr.conflict39 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict105 mac_addr.conflict105, *Pmac_addr.conflict105; + +struct mac_addr.conflict105 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict226 mac_addr.conflict226, *Pmac_addr.conflict226; + +struct mac_addr.conflict226 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict253 anon_struct.conflict253, *Panon_struct.conflict253; + +struct anon_struct.conflict253 { + uint32_t key[4]; +}; + +typedef struct mac_addr.conflict220 mac_addr.conflict220, *Pmac_addr.conflict220; + +struct mac_addr.conflict220 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict34 mac_addr.conflict34, *Pmac_addr.conflict34; + +struct mac_addr.conflict34 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict100 mac_addr.conflict100, *Pmac_addr.conflict100; + +struct mac_addr.conflict100 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict221 mac_addr.conflict221, *Pmac_addr.conflict221; + +struct mac_addr.conflict221 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict35 mac_addr.conflict35, *Pmac_addr.conflict35; + +struct mac_addr.conflict35 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict222 mac_addr.conflict222, *Pmac_addr.conflict222; + +struct mac_addr.conflict222 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict250 mac_addr.conflict250, *Pmac_addr.conflict250; + +struct mac_addr.conflict250 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict139 mac_addr.conflict139, *Pmac_addr.conflict139; + +struct mac_addr.conflict139 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict135 mac_addr.conflict135, *Pmac_addr.conflict135; + +struct mac_addr.conflict135 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict256 mac_addr.conflict256, *Pmac_addr.conflict256; + +struct mac_addr.conflict256 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict136 mac_addr.conflict136, *Pmac_addr.conflict136; + +struct mac_addr.conflict136 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict137 mac_addr.conflict137, *Pmac_addr.conflict137; + +struct mac_addr.conflict137 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict259 mac_addr.conflict259, *Pmac_addr.conflict259; + +struct mac_addr.conflict259 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict131 mac_addr.conflict131, *Pmac_addr.conflict131; + +struct mac_addr.conflict131 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict133 mac_addr.conflict133, *Pmac_addr.conflict133; + +struct mac_addr.conflict133 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict254 mac_addr.conflict254, *Pmac_addr.conflict254; + +struct mac_addr.conflict254 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict240 mac_addr.conflict240, *Pmac_addr.conflict240; + +struct mac_addr.conflict240 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict245 mac_addr.conflict245, *Pmac_addr.conflict245; + +struct mac_addr.conflict245 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict125 mac_addr.conflict125, *Pmac_addr.conflict125; + +struct mac_addr.conflict125 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict246 mac_addr.conflict246, *Pmac_addr.conflict246; + +struct mac_addr.conflict246 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict72 mac_addr.conflict72, *Pmac_addr.conflict72; + +struct mac_addr.conflict72 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict127 mac_addr.conflict127, *Pmac_addr.conflict127; + +struct mac_addr.conflict127 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict248 mac_addr.conflict248, *Pmac_addr.conflict248; + +struct mac_addr.conflict248 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict120 mac_addr.conflict120, *Pmac_addr.conflict120; + +struct mac_addr.conflict120 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict241 mac_addr.conflict241, *Pmac_addr.conflict241; + +struct mac_addr.conflict241 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict121 mac_addr.conflict121, *Pmac_addr.conflict121; + +struct mac_addr.conflict121 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict122 mac_addr.conflict122, *Pmac_addr.conflict122; + +struct mac_addr.conflict122 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict123 mac_addr.conflict123, *Pmac_addr.conflict123; + +struct mac_addr.conflict123 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict244 mac_addr.conflict244, *Pmac_addr.conflict244; + +struct mac_addr.conflict244 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict270 mac_addr.conflict270, *Pmac_addr.conflict270; + +struct mac_addr.conflict270 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict150 mac_addr.conflict150, *Pmac_addr.conflict150; + +struct mac_addr.conflict150 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict271 mac_addr.conflict271, *Pmac_addr.conflict271; + +struct mac_addr.conflict271 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict151 mac_addr.conflict151, *Pmac_addr.conflict151; + +struct mac_addr.conflict151 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict272 mac_addr.conflict272, *Pmac_addr.conflict272; + +struct mac_addr.conflict272 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict152 mac_addr.conflict152, *Pmac_addr.conflict152; + +struct mac_addr.conflict152 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict273 mac_addr.conflict273, *Pmac_addr.conflict273; + +struct mac_addr.conflict273 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict278 mac_addr.conflict278, *Pmac_addr.conflict278; + +struct mac_addr.conflict278 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict62 mac_addr.conflict62, *Pmac_addr.conflict62; + +struct mac_addr.conflict62 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict158 mac_addr.conflict158, *Pmac_addr.conflict158; + +struct mac_addr.conflict158 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict279 mac_addr.conflict279, *Pmac_addr.conflict279; + +struct mac_addr.conflict279 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict159 mac_addr.conflict159, *Pmac_addr.conflict159; + +struct mac_addr.conflict159 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict153 mac_addr.conflict153, *Pmac_addr.conflict153; + +struct mac_addr.conflict153 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict274 mac_addr.conflict274, *Pmac_addr.conflict274; + +struct mac_addr.conflict274 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict154 mac_addr.conflict154, *Pmac_addr.conflict154; + +struct mac_addr.conflict154 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict275 mac_addr.conflict275, *Pmac_addr.conflict275; + +struct mac_addr.conflict275 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict155 mac_addr.conflict155, *Pmac_addr.conflict155; + +struct mac_addr.conflict155 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict276 mac_addr.conflict276, *Pmac_addr.conflict276; + +struct mac_addr.conflict276 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict156 mac_addr.conflict156, *Pmac_addr.conflict156; + +struct mac_addr.conflict156 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict277 mac_addr.conflict277, *Pmac_addr.conflict277; + +struct mac_addr.conflict277 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict260 mac_addr.conflict260, *Pmac_addr.conflict260; + +struct mac_addr.conflict260 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict261 mac_addr.conflict261, *Pmac_addr.conflict261; + +struct mac_addr.conflict261 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict141 mac_addr.conflict141, *Pmac_addr.conflict141; + +struct mac_addr.conflict141 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict262 mac_addr.conflict262, *Pmac_addr.conflict262; + +struct mac_addr.conflict262 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict267 mac_addr.conflict267, *Pmac_addr.conflict267; + +struct mac_addr.conflict267 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict147 mac_addr.conflict147, *Pmac_addr.conflict147; + +struct mac_addr.conflict147 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict268 mac_addr.conflict268, *Pmac_addr.conflict268; + +struct mac_addr.conflict268 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict96 mac_addr.conflict96, *Pmac_addr.conflict96; + +struct mac_addr.conflict96 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict269 mac_addr.conflict269, *Pmac_addr.conflict269; + +struct mac_addr.conflict269 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict149 mac_addr.conflict149, *Pmac_addr.conflict149; + +struct mac_addr.conflict149 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict216 anon_struct.conflict216, *Panon_struct.conflict216; + +struct anon_struct.conflict216 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct mac_addr.conflict1 mac_addr.conflict1, *Pmac_addr.conflict1; + +struct mac_addr.conflict1 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict2 mac_addr.conflict2, *Pmac_addr.conflict2; + +struct mac_addr.conflict2 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict264 mac_addr.conflict264, *Pmac_addr.conflict264; + +struct mac_addr.conflict264 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict265 mac_addr.conflict265, *Pmac_addr.conflict265; + +struct mac_addr.conflict265 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict145 mac_addr.conflict145, *Pmac_addr.conflict145; + +struct mac_addr.conflict145 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict266 mac_addr.conflict266, *Pmac_addr.conflict266; + +struct mac_addr.conflict266 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict94 mac_addr.conflict94, *Pmac_addr.conflict94; + +struct mac_addr.conflict94 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict95 mac_addr.conflict95, *Pmac_addr.conflict95; + +struct mac_addr.conflict95 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict92 mac_addr.conflict92, *Pmac_addr.conflict92; + +struct mac_addr.conflict92 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict90 mac_addr.conflict90, *Pmac_addr.conflict90; + +struct mac_addr.conflict90 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict186 anon_struct.conflict186, *Panon_struct.conflict186; + +struct anon_struct.conflict186 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict187 anon_struct.conflict187, *Panon_struct.conflict187; + +struct anon_struct.conflict187 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict192 anon_struct.conflict192, *Panon_struct.conflict192; + +struct anon_struct.conflict192 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict193 anon_struct.conflict193, *Panon_struct.conflict193; + +struct anon_struct.conflict193 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict198 anon_struct.conflict198, *Panon_struct.conflict198; + +struct anon_struct.conflict198 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict199 anon_struct.conflict199, *Panon_struct.conflict199; + +struct anon_struct.conflict199 { + uint32_t key[4]; +}; + +typedef struct mac_addr.conflict54 mac_addr.conflict54, *Pmac_addr.conflict54; + +struct mac_addr.conflict54 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict55 mac_addr.conflict55, *Pmac_addr.conflict55; + +struct mac_addr.conflict55 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict52 mac_addr.conflict52, *Pmac_addr.conflict52; + +struct mac_addr.conflict52 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict53 mac_addr.conflict53, *Pmac_addr.conflict53; + +struct mac_addr.conflict53 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict50 mac_addr.conflict50, *Pmac_addr.conflict50; + +struct mac_addr.conflict50 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict260 anon_struct.conflict260, *Panon_struct.conflict260; + +struct anon_struct.conflict260 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict140 anon_struct.conflict140, *Panon_struct.conflict140; + +struct anon_struct.conflict140 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict261 anon_struct.conflict261, *Panon_struct.conflict261; + +struct anon_struct.conflict261 { + uint32_t key[4]; +}; + +typedef struct mac_addr.conflict49 mac_addr.conflict49, *Pmac_addr.conflict49; + +struct mac_addr.conflict49 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict47 mac_addr.conflict47, *Pmac_addr.conflict47; + +struct mac_addr.conflict47 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict145 anon_struct.conflict145, *Panon_struct.conflict145; + +struct anon_struct.conflict145 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct mac_addr.conflict45 mac_addr.conflict45, *Pmac_addr.conflict45; + +struct mac_addr.conflict45 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict266 anon_struct.conflict266, *Panon_struct.conflict266; + +struct anon_struct.conflict266 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict146 anon_struct.conflict146, *Panon_struct.conflict146; + +struct anon_struct.conflict146 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict267 anon_struct.conflict267, *Panon_struct.conflict267; + +struct anon_struct.conflict267 { + uint32_t key[4]; +}; + +typedef struct mac_addr.conflict63 mac_addr.conflict63, *Pmac_addr.conflict63; + +struct mac_addr.conflict63 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict276 anon_struct.conflict276, *Panon_struct.conflict276; + +struct anon_struct.conflict276 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict277 anon_struct.conflict277, *Panon_struct.conflict277; + +struct anon_struct.conflict277 { + uint32_t key[4]; +}; + +typedef struct mac_addr.conflict76 mac_addr.conflict76, *Pmac_addr.conflict76; + +struct mac_addr.conflict76 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict77 mac_addr.conflict77, *Pmac_addr.conflict77; + +struct mac_addr.conflict77 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict74 mac_addr.conflict74, *Pmac_addr.conflict74; + +struct mac_addr.conflict74 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict70 mac_addr.conflict70, *Pmac_addr.conflict70; + +struct mac_addr.conflict70 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict282 anon_struct.conflict282, *Panon_struct.conflict282; + +struct anon_struct.conflict282 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict162 anon_struct.conflict162, *Panon_struct.conflict162; + +struct anon_struct.conflict162 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict283 anon_struct.conflict283, *Panon_struct.conflict283; + +struct anon_struct.conflict283 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict163 anon_struct.conflict163, *Panon_struct.conflict163; + +struct anon_struct.conflict163 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict280 anon_struct.conflict280, *Panon_struct.conflict280; + +struct anon_struct.conflict280 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict281 anon_struct.conflict281, *Panon_struct.conflict281; + +struct anon_struct.conflict281 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict169 anon_struct.conflict169, *Panon_struct.conflict169; + +struct anon_struct.conflict169 { + uint32_t key[4]; +}; + +typedef struct mac_addr.conflict69 mac_addr.conflict69, *Pmac_addr.conflict69; + +struct mac_addr.conflict69 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict168 anon_struct.conflict168, *Panon_struct.conflict168; + +struct anon_struct.conflict168 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct mac_addr.conflict68 mac_addr.conflict68, *Pmac_addr.conflict68; + +struct mac_addr.conflict68 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict86 mac_addr.conflict86, *Pmac_addr.conflict86; + +struct mac_addr.conflict86 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict84 mac_addr.conflict84, *Pmac_addr.conflict84; + +struct mac_addr.conflict84 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict81 mac_addr.conflict81, *Pmac_addr.conflict81; + +struct mac_addr.conflict81 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict82 mac_addr.conflict82, *Pmac_addr.conflict82; + +struct mac_addr.conflict82 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict80 mac_addr.conflict80, *Pmac_addr.conflict80; + +struct mac_addr.conflict80 { + uint16_t array[3]; +}; + +typedef struct anon_struct.conflict172 anon_struct.conflict172, *Panon_struct.conflict172; + +struct anon_struct.conflict172 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict173 anon_struct.conflict173, *Panon_struct.conflict173; + +struct anon_struct.conflict173 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict170 anon_struct.conflict170, *Panon_struct.conflict170; + +struct anon_struct.conflict170 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict171 anon_struct.conflict171, *Panon_struct.conflict171; + +struct anon_struct.conflict171 { + uint32_t key[4]; +}; + +typedef struct anon_struct.conflict176 anon_struct.conflict176, *Panon_struct.conflict176; + +struct anon_struct.conflict176 { + uint32_t tx_key[2]; + uint32_t rx_key[2]; +}; + +typedef struct anon_struct.conflict177 anon_struct.conflict177, *Panon_struct.conflict177; + +struct anon_struct.conflict177 { + uint32_t key[4]; +}; + +typedef struct mac_addr.conflict78 mac_addr.conflict78, *Pmac_addr.conflict78; + +struct mac_addr.conflict78 { + uint16_t array[3]; +}; + +typedef struct mac_addr.conflict79 mac_addr.conflict79, *Pmac_addr.conflict79; + +struct mac_addr.conflict79 { + uint16_t array[3]; +}; + +typedef struct _uart_ioctrl_wait_read _uart_ioctrl_wait_read, *P_uart_ioctrl_wait_read; + +struct _uart_ioctrl_wait_read { + char * buf; + int read_size; + uint32_t timeout; +}; + +typedef struct _uart_ioctrl_config _uart_ioctrl_config, *P_uart_ioctrl_config; + +typedef struct _uart_ioctrl_config uart_ioc_config_t; + +typedef enum ioc_uart_parity_t { + IO_UART_PARITY_EVEN=2, + IO_UART_PARITY_NONE=0, + IO_UART_PARITY_ODD=1 +} ioc_uart_parity_t; + +struct _uart_ioctrl_config { + uint32_t baud; + enum ioc_uart_parity_t parity; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; +}; + +typedef struct _uart_ioctrl_wait_read uart_ioc_waitread_t; + +typedef struct anon_struct.conflict1 anon_struct.conflict1, *Panon_struct.conflict1; + +struct anon_struct.conflict1 { + uint8_t partition_active_idx; + uint8_t pad[3]; + struct PtTable_Stuff_Config table; +}; + +typedef enum llc_util_enc_state { + LLC_ENC_DISABLED=0, + LLC_ENC_ENABLE=3, + LLC_ENC_FLOW_OFF=12, + LLC_ENC_PAUSE_PENDING=32, + LLC_ENC_REFRESH_PENDING=16, + LLC_ENC_RX=2, + LLC_ENC_RX_FLOW_OFF=8, + LLC_ENC_TX=1, + LLC_ENC_TX_FLOW_OFF=4 +} llc_util_enc_state; + +typedef struct HALPartition_Entry_Config HALPartition_Entry_Config, *PHALPartition_Entry_Config; + +struct HALPartition_Entry_Config { + uint8_t type; + uint8_t device; + uint8_t activeIndex; + uint8_t name[9]; + uint32_t Address[2]; + uint32_t maxLen[2]; + uint32_t len; + uint32_t age; +}; + +typedef enum HAL_Err_Type { + HAL_ERROR=1, + HAL_SUCCESS=0 +} HAL_Err_Type; + +typedef struct NoHostSecurityParams_t NoHostSecurityParams_t, *PNoHostSecurityParams_t; + +struct NoHostSecurityParams_t { + UINT8 CipherType; + UINT8 MulticastCipher; + UINT8 UnicastCipher; + char PSKPassPhrase[64]; +}; + +typedef struct phy_hal_tag phy_hal_tag, *Pphy_hal_tag; + +struct phy_hal_tag { + int16_t temperature; + uint8_t capcode; + undefined field_0x3; +}; + +typedef struct anon_struct.conflict11 anon_struct.conflict11, *Panon_struct.conflict11; + +struct anon_struct.conflict11 { + void * handle; + int fd; +}; + +typedef struct event_list_node_t event_list_node_t, *Pevent_list_node_t; + +struct event_list_node_t { + dlist_t node; + void (* cb)(struct input_event_t *, void *); + void * priv; + uint16_t type_filter; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct Bl_MD5_CTX Bl_MD5_CTX, *PBl_MD5_CTX; + +struct Bl_MD5_CTX { + ulong state[4]; + ulong count[2]; + ulong scratch[16]; + uchar buffer[64]; +}; + +typedef struct ke_task_elem ke_task_elem, *Pke_task_elem; + +struct ke_task_elem { + struct ke_task_desc * p_desc; +}; + +typedef struct ble_ke_task_env_tag ble_ke_task_env_tag, *Pble_ke_task_env_tag; + +struct ble_ke_task_env_tag { + struct ke_task_elem task_list[5]; +}; + +typedef struct input_t input_t, *Pinput_t; + +struct input_t { + int8_t rssi; + int8_t lna; + undefined field_0x2; + undefined field_0x3; + float ppm; + uint8_t new; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct pa_state_t pa_state_t, *Ppa_state_t; + +struct pa_state_t { + uint8_t used; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + uint32_t vif_tag; + struct input_t input_buffer[8]; + int8_t input_buffer_ptr; + undefined field_0x69; + undefined field_0x6a; + undefined field_0x6b; + uint32_t last_update; + int8_t rss; + int8_t rss_acq; + int8_t rss_trk; + int8_t rss_state; + uint8_t rss_hit_count; + undefined field_0x75; + undefined field_0x76; + undefined field_0x77; + uint32_t rss_count; + int8_t ris; + undefined field_0x7d; + undefined field_0x7e; + undefined field_0x7f; + float ce; + int8_t ce_in; + int8_t ce_acq; + int8_t ce_trk; + int8_t ce_state; + int8_t ce_num_up_cmds; + int8_t ce_num_dn_cmds; + undefined field_0x8a; + undefined field_0x8b; +}; + +typedef struct rvec_t rvec_t, *Prvec_t; + +struct rvec_t { + uint32_t leg_length:12; + uint32_t leg_rate:4; + uint32_t ht_length:16; + uint32_t _ht_length:4; + uint32_t short_gi:1; + uint32_t stbc:2; + uint32_t smoothing:1; + uint32_t mcs:7; + uint32_t pre_type:1; + uint32_t format_mod:3; + uint32_t ch_bw:2; + uint32_t n_sts:3; + uint32_t lsig_valid:1; + uint32_t sounding:1; + uint32_t num_extn_ss:2; + uint32_t aggregation:1; + uint32_t fec_coding:1; + uint32_t dyn_bw:1; + uint32_t doze_not_allowed:1; + uint32_t antenna_set:8; + uint32_t partial_aid:9; + uint32_t group_id:6; + uint32_t reserved_1c:1; + int32_t rssi1:8; + int32_t rssi2:8; + int32_t agc_lna:4; + int32_t agc_rbb1:5; + int32_t agc_dg:7; + uint32_t reserved_1d:8; + uint32_t rcpi:8; + uint32_t evm1:8; + uint32_t evm2:8; + uint32_t freqoff_lo:8; + uint32_t freqoff_hi:8; + uint32_t reserved2b_1:8; + uint32_t reserved2b_2:8; + uint32_t reserved2b_3:8; +}; + +typedef struct rvec_t.conflict1 rvec_t.conflict1, *Prvec_t.conflict1; + +struct rvec_t.conflict1 { + uint32_t leg_length:12; + uint32_t leg_rate:4; + uint32_t ht_length:16; + uint32_t _ht_length:4; + uint32_t short_gi:1; + uint32_t stbc:2; + uint32_t smoothing:1; + uint32_t mcs:7; + uint32_t pre_type:1; + uint32_t format_mod:3; + uint32_t ch_bw:2; + uint32_t n_sts:3; + uint32_t lsig_valid:1; + uint32_t sounding:1; + uint32_t num_extn_ss:2; + uint32_t aggregation:1; + uint32_t fec_coding:1; + uint32_t dyn_bw:1; + uint32_t doze_not_allowed:1; + uint32_t antenna_set:8; + uint32_t partial_aid:9; + uint32_t group_id:6; + uint32_t reserved_1c:1; + int32_t rssi1:8; + int32_t rssi2:8; + int32_t agc_lna:4; + int32_t agc_rbb1:5; + int32_t agc_dg:7; + uint32_t reserved_1d:8; + uint32_t rcpi:8; + uint32_t evm1:8; + uint32_t evm2:8; + uint32_t freqoff_lo:8; + uint32_t freqoff_hi:8; + uint32_t reserved2b_1:8; + uint32_t reserved2b_2:8; + uint32_t reserved2b_3:8; +}; + +typedef struct rvec_t.conflict rvec_t.conflict, *Prvec_t.conflict; + +struct rvec_t.conflict { + uint32_t leg_length:12; + uint32_t leg_rate:4; + uint32_t ht_length:16; + uint32_t _ht_length:4; + uint32_t short_gi:1; + uint32_t stbc:2; + uint32_t smoothing:1; + uint32_t mcs:7; + uint32_t pre_type:1; + uint32_t format_mod:3; + uint32_t ch_bw:2; + uint32_t n_sts:3; + uint32_t lsig_valid:1; + uint32_t sounding:1; + uint32_t num_extn_ss:2; + uint32_t aggregation:1; + uint32_t fec_coding:1; + uint32_t dyn_bw:1; + uint32_t doze_not_allowed:1; + uint32_t antenna_set:8; + uint32_t partial_aid:9; + uint32_t group_id:6; + uint32_t reserved_1c:1; + int32_t rssi1:8; + int32_t rssi2:8; + int32_t agc_lna:4; + int32_t agc_rbb1:5; + int32_t agc_dg:7; + uint32_t reserved_1d:8; + uint32_t rcpi:8; + uint32_t evm1:8; + uint32_t evm2:8; + uint32_t freqoff_lo:8; + uint32_t freqoff_hi:8; + uint32_t reserved2b_1:8; + uint32_t reserved2b_2:8; + uint32_t reserved2b_3:8; +}; + +typedef struct sm_env_tag sm_env_tag, *Psm_env_tag; + +struct sm_env_tag { + struct sm_connect_req * connect_param; + struct sm_connect_ind * connect_ind; + struct co_list bss_config; + _Bool join_passive; + _Bool ft_over_ds; + undefined field_0x12; + undefined field_0x13; + int exist_ssid_idx; + struct mac_addr.conflict47 ft_old_bssid; + undefined field_0x1e; + undefined field_0x1f; +}; + +typedef struct sm_env_tag.conflict1 sm_env_tag.conflict1, *Psm_env_tag.conflict1; + +struct sm_env_tag.conflict1 { + struct sm_connect_req * connect_param; + struct sm_connect_ind * connect_ind; + struct co_list bss_config; + _Bool join_passive; + _Bool ft_over_ds; + undefined field_0x12; + undefined field_0x13; + int exist_ssid_idx; + struct mac_addr.conflict97 ft_old_bssid; + undefined field_0x1e; + undefined field_0x1f; +}; + +typedef struct sm_env_tag.conflict sm_env_tag.conflict, *Psm_env_tag.conflict; + +struct sm_env_tag.conflict { + struct sm_connect_req * connect_param; + struct sm_connect_ind * connect_ind; + struct co_list bss_config; + _Bool join_passive; + _Bool ft_over_ds; + undefined field_0x12; + undefined field_0x13; + int exist_ssid_idx; + struct mac_addr.conflict56 ft_old_bssid; + undefined field_0x1e; + undefined field_0x1f; +}; + +typedef struct ke_timer ke_timer, *Pke_timer; + +struct ke_timer { + struct ke_timer * next; + ke_msg_id_t id; + ke_task_id_t task; + uint32_t time; +}; + +typedef struct anon_struct.conflict2 anon_struct.conflict2, *Panon_struct.conflict2; + +struct anon_struct.conflict2 { + uint32_t magic; + struct SPI_Flash_Cfg_Type flashCfg; +}; + +typedef struct igmp_group igmp_group, *Pigmp_group; + +struct igmp_group { + struct igmp_group * next; + ip4_addr_t group_address; + u8_t last_reporter_flag; + u8_t group_state; + u16_t timer; + u8_t use; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; +}; + +typedef struct igmp_msg igmp_msg, *Pigmp_msg; + +struct igmp_msg { + u8_t igmp_msgtype; + u8_t igmp_maxresp; + u16_t igmp_checksum; + ip4_addr_p_t igmp_group_address; +}; + +typedef struct env_hdr_data env_hdr_data, *Penv_hdr_data; + +typedef struct env_hdr_data * env_hdr_data_t; + +struct env_hdr_data { + uint8_t status_table[5]; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t magic; + uint32_t len; + uint32_t crc32; + uint8_t name_len; + undefined field_0x15; + undefined field_0x16; + undefined field_0x17; + uint32_t value_len; +}; + +typedef struct anon_struct.conflict115 anon_struct.conflict115, *Panon_struct.conflict115; + +struct anon_struct.conflict115 { + uint8_t store[3]; + uint8_t dirty[3]; +}; + +typedef struct anon_struct.conflict116 anon_struct.conflict116, *Panon_struct.conflict116; + +typedef enum sector_store_status { + SECTOR_STORE_EMPTY=1, + SECTOR_STORE_FULL=3, + SECTOR_STORE_STATUS_NUM=4, + SECTOR_STORE_UNUSED=0, + SECTOR_STORE_USING=2 +} sector_store_status; + +typedef enum sector_store_status sector_store_status_t; + +typedef enum sector_dirty_status { + SECTOR_DIRTY_FALSE=1, + SECTOR_DIRTY_GC=3, + SECTOR_DIRTY_STATUS_NUM=4, + SECTOR_DIRTY_TRUE=2, + SECTOR_DIRTY_UNUSED=0 +} sector_dirty_status; + +typedef enum sector_dirty_status sector_dirty_status_t; + +struct anon_struct.conflict116 { + sector_store_status_t store; + sector_dirty_status_t dirty; +}; + +typedef struct sector_cache_node sector_cache_node, *Psector_cache_node; + +struct sector_cache_node { + uint32_t addr; + uint32_t empty_addr; +}; + +typedef struct sector_meta_data sector_meta_data, *Psector_meta_data; + +typedef struct sector_meta_data * sector_meta_data_t; + +typedef struct anon_struct_for_status anon_struct_for_status, *Panon_struct_for_status; + +struct anon_struct_for_status { + sector_store_status_t store; + sector_dirty_status_t dirty; +}; + +struct sector_meta_data { + _Bool check_ok; + struct anon_struct_for_status status; + undefined field_0x3; + uint32_t addr; + uint32_t magic; + uint32_t combined; + size_t remain; + uint32_t empty_env; +}; + +typedef struct env_cache_node env_cache_node, *Penv_cache_node; + +struct env_cache_node { + uint16_t name_crc; + uint16_t active; + uint32_t addr; +}; + +typedef struct sector_hdr_data sector_hdr_data, *Psector_hdr_data; + +typedef struct anon_struct_for_status_table anon_struct_for_status_table, *Panon_struct_for_status_table; + +struct anon_struct_for_status_table { + uint8_t store[3]; + uint8_t dirty[3]; +}; + +struct sector_hdr_data { + struct anon_struct_for_status_table status_table; + undefined field_0x6; + undefined field_0x7; + uint32_t magic; + uint32_t combined; + uint32_t reserved; +}; + +typedef struct ecc_result_ind ecc_result_ind, *Pecc_result_ind; + +struct ecc_result_ind { + uint8_t key_res_x[32]; + uint8_t key_res_y[32]; +}; + +typedef uint32_t u_int32; + +typedef struct ecc_elt_tag ecc_elt_tag, *Pecc_elt_tag; + +typedef struct ECC_Jacobian_Point256 ECC_Jacobian_Point256, *PECC_Jacobian_Point256; + +typedef struct bigHex256 bigHex256, *PbigHex256; + +struct bigHex256 { + u_int32 num[8]; + u_int32 len; + u_int32 sign; +}; + +struct ECC_Jacobian_Point256 { + struct bigHex256 x; + struct bigHex256 y; + struct bigHex256 z; +}; + +struct ecc_elt_tag { + struct co_list_hdr hdr; + u_int32 Point_Mul_Word256; + struct ECC_Jacobian_Point256 Jacobian_PointQ256; + struct ECC_Jacobian_Point256 Jacobian_PointR256; + struct bigHex256 Pk256; + ke_msg_id_t msg_id; + ke_task_id_t client_id; + uint32_t current_val; + uint32_t bit_cursor; + uint8_t key_type; + undefined field_0x12d; + undefined field_0x12e; + undefined field_0x12f; + struct ECC_Jacobian_Point256 * win_4_table; +}; + +typedef uint8_t u_int8; + +typedef struct ecc_env_tag ecc_env_tag, *Pecc_env_tag; + +struct ecc_env_tag { + struct co_list ongoing_mul; +}; + +typedef struct ECC_Point256 ECC_Point256, *PECC_Point256; + +struct ECC_Point256 { + struct bigHex256 x; + struct bigHex256 y; +}; + +typedef ulonglong u64; + +typedef struct txdesc_host.conflict19 txdesc_host.conflict19, *Ptxdesc_host.conflict19; + +typedef struct hostdesc.conflict32 hostdesc.conflict32, *Phostdesc.conflict32; + +struct hostdesc.conflict32 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict168 eth_dest_addr; + struct mac_addr.conflict169 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict19 { + uint32_t ready; + struct hostdesc.conflict32 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict20 txdesc_host.conflict20, *Ptxdesc_host.conflict20; + +typedef struct hostdesc.conflict33 hostdesc.conflict33, *Phostdesc.conflict33; + +struct hostdesc.conflict33 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict170 eth_dest_addr; + struct mac_addr.conflict171 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict20 { + uint32_t ready; + struct hostdesc.conflict33 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict5 txdesc_host.conflict5, *Ptxdesc_host.conflict5; + +typedef struct hostdesc.conflict14 hostdesc.conflict14, *Phostdesc.conflict14; + +struct hostdesc.conflict14 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict92 eth_dest_addr; + struct mac_addr.conflict93 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict5 { + uint32_t ready; + struct hostdesc.conflict14 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict9 txdesc_host.conflict9, *Ptxdesc_host.conflict9; + +typedef struct hostdesc.conflict20 hostdesc.conflict20, *Phostdesc.conflict20; + +struct hostdesc.conflict20 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict131 eth_dest_addr; + struct mac_addr.conflict132 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict9 { + uint32_t ready; + struct hostdesc.conflict20 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict6 txdesc_host.conflict6, *Ptxdesc_host.conflict6; + +typedef struct hostdesc.conflict17 hostdesc.conflict17, *Phostdesc.conflict17; + +struct hostdesc.conflict17 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict125 eth_dest_addr; + struct mac_addr.conflict126 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict6 { + uint32_t ready; + struct hostdesc.conflict17 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict7 txdesc_host.conflict7, *Ptxdesc_host.conflict7; + +typedef struct hostdesc.conflict18 hostdesc.conflict18, *Phostdesc.conflict18; + +struct hostdesc.conflict18 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict127 eth_dest_addr; + struct mac_addr.conflict128 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict7 { + uint32_t ready; + struct hostdesc.conflict18 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict4 txdesc_host.conflict4, *Ptxdesc_host.conflict4; + +typedef struct hostdesc.conflict13 hostdesc.conflict13, *Phostdesc.conflict13; + +struct hostdesc.conflict13 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict90 eth_dest_addr; + struct mac_addr.conflict91 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict4 { + uint32_t ready; + struct hostdesc.conflict13 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict2 txdesc_host.conflict2, *Ptxdesc_host.conflict2; + +typedef struct hostdesc.conflict11 hostdesc.conflict11, *Phostdesc.conflict11; + +struct hostdesc.conflict11 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict86 eth_dest_addr; + struct mac_addr.conflict87 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict2 { + uint32_t ready; + struct hostdesc.conflict11 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict14 txdesc_host.conflict14, *Ptxdesc_host.conflict14; + +typedef struct hostdesc.conflict26 hostdesc.conflict26, *Phostdesc.conflict26; + +struct hostdesc.conflict26 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict145 eth_dest_addr; + struct mac_addr.conflict146 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict14 { + uint32_t ready; + struct hostdesc.conflict26 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict1 txdesc_host.conflict1, *Ptxdesc_host.conflict1; + +typedef struct hostdesc.conflict10 hostdesc.conflict10, *Phostdesc.conflict10; + +struct hostdesc.conflict10 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict84 eth_dest_addr; + struct mac_addr.conflict85 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict1 { + uint32_t ready; + struct hostdesc.conflict10 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict25 txdesc_host.conflict25, *Ptxdesc_host.conflict25; + +typedef struct hostdesc.conflict39 hostdesc.conflict39, *Phostdesc.conflict39; + +struct hostdesc.conflict39 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict186 eth_dest_addr; + struct mac_addr.conflict187 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict25 { + uint32_t ready; + struct hostdesc.conflict39 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict15 txdesc_host.conflict15, *Ptxdesc_host.conflict15; + +typedef struct hostdesc.conflict27 hostdesc.conflict27, *Phostdesc.conflict27; + +struct hostdesc.conflict27 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict147 eth_dest_addr; + struct mac_addr.conflict148 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict15 { + uint32_t ready; + struct hostdesc.conflict27 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict9 hostdesc.conflict9, *Phostdesc.conflict9; + +struct hostdesc.conflict9 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict82 eth_dest_addr; + struct mac_addr.conflict83 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict8 hostdesc.conflict8, *Phostdesc.conflict8; + +struct hostdesc.conflict8 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict70 eth_dest_addr; + struct mac_addr.conflict71 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict7 hostdesc.conflict7, *Phostdesc.conflict7; + +struct hostdesc.conflict7 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict63 eth_dest_addr; + struct mac_addr.conflict64 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict10 txdesc_host.conflict10, *Ptxdesc_host.conflict10; + +typedef struct hostdesc.conflict21 hostdesc.conflict21, *Phostdesc.conflict21; + +struct hostdesc.conflict21 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict133 eth_dest_addr; + struct mac_addr.conflict134 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict10 { + uint32_t ready; + struct hostdesc.conflict21 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict2 hostdesc.conflict2, *Phostdesc.conflict2; + +struct hostdesc.conflict2 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict20 eth_dest_addr; + struct mac_addr.conflict21 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict1 hostdesc.conflict1, *Phostdesc.conflict1; + +struct hostdesc.conflict1 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict15 eth_dest_addr; + struct mac_addr.conflict16 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict6 hostdesc.conflict6, *Phostdesc.conflict6; + +struct hostdesc.conflict6 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict45 eth_dest_addr; + struct mac_addr.conflict46 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict5 hostdesc.conflict5, *Phostdesc.conflict5; + +struct hostdesc.conflict5 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict35 eth_dest_addr; + struct mac_addr.conflict36 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict4 hostdesc.conflict4, *Phostdesc.conflict4; + +struct hostdesc.conflict4 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict30 eth_dest_addr; + struct mac_addr.conflict31 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict3 hostdesc.conflict3, *Phostdesc.conflict3; + +struct hostdesc.conflict3 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict25 eth_dest_addr; + struct mac_addr.conflict26 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict38 hostdesc.conflict38, *Phostdesc.conflict38; + +struct hostdesc.conflict38 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict184 eth_dest_addr; + struct mac_addr.conflict185 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict34 txdesc_host.conflict34, *Ptxdesc_host.conflict34; + +typedef struct hostdesc.conflict57 hostdesc.conflict57, *Phostdesc.conflict57; + +struct hostdesc.conflict57 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict254 eth_dest_addr; + struct mac_addr.conflict255 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict34 { + uint32_t ready; + struct hostdesc.conflict57 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict36 hostdesc.conflict36, *Phostdesc.conflict36; + +struct hostdesc.conflict36 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict180 eth_dest_addr; + struct mac_addr.conflict181 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict34 hostdesc.conflict34, *Phostdesc.conflict34; + +struct hostdesc.conflict34 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict176 eth_dest_addr; + struct mac_addr.conflict177 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict35 hostdesc.conflict35, *Phostdesc.conflict35; + +struct hostdesc.conflict35 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict178 eth_dest_addr; + struct mac_addr.conflict179 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict30 hostdesc.conflict30, *Phostdesc.conflict30; + +struct hostdesc.conflict30 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict164 eth_dest_addr; + struct mac_addr.conflict165 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict49 hostdesc.conflict49, *Phostdesc.conflict49; + +struct hostdesc.conflict49 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict226 eth_dest_addr; + struct mac_addr.conflict227 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict30 txdesc_host.conflict30, *Ptxdesc_host.conflict30; + +typedef struct hostdesc.conflict46 hostdesc.conflict46, *Phostdesc.conflict46; + +struct hostdesc.conflict46 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict205 eth_dest_addr; + struct mac_addr.conflict206 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict30 { + uint32_t ready; + struct hostdesc.conflict46 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict47 hostdesc.conflict47, *Phostdesc.conflict47; + +struct hostdesc.conflict47 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict210 eth_dest_addr; + struct mac_addr.conflict211 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict31 txdesc_host.conflict31, *Ptxdesc_host.conflict31; + +typedef struct hostdesc.conflict54 hostdesc.conflict54, *Phostdesc.conflict54; + +struct hostdesc.conflict54 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict248 eth_dest_addr; + struct mac_addr.conflict249 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict31 { + uint32_t ready; + struct hostdesc.conflict54 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict48 hostdesc.conflict48, *Phostdesc.conflict48; + +struct hostdesc.conflict48 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict216 eth_dest_addr; + struct mac_addr.conflict217 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict32 txdesc_host.conflict32, *Ptxdesc_host.conflict32; + +typedef struct hostdesc.conflict55 hostdesc.conflict55, *Phostdesc.conflict55; + +struct hostdesc.conflict55 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict250 eth_dest_addr; + struct mac_addr.conflict251 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict32 { + uint32_t ready; + struct hostdesc.conflict55 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict45 hostdesc.conflict45, *Phostdesc.conflict45; + +struct hostdesc.conflict45 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict203 eth_dest_addr; + struct mac_addr.conflict204 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict43 hostdesc.conflict43, *Phostdesc.conflict43; + +struct hostdesc.conflict43 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict199 eth_dest_addr; + struct mac_addr.conflict200 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict41 hostdesc.conflict41, *Phostdesc.conflict41; + +struct hostdesc.conflict41 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict195 eth_dest_addr; + struct mac_addr.conflict196 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict42 hostdesc.conflict42, *Phostdesc.conflict42; + +struct hostdesc.conflict42 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict197 eth_dest_addr; + struct mac_addr.conflict198 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict40 hostdesc.conflict40, *Phostdesc.conflict40; + +struct hostdesc.conflict40 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict190 eth_dest_addr; + struct mac_addr.conflict191 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict35 txdesc_host.conflict35, *Ptxdesc_host.conflict35; + +typedef struct hostdesc.conflict58 hostdesc.conflict58, *Phostdesc.conflict58; + +struct hostdesc.conflict58 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict256 eth_dest_addr; + struct mac_addr.conflict257 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict35 { + uint32_t ready; + struct hostdesc.conflict58 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict52 hostdesc.conflict52, *Phostdesc.conflict52; + +struct hostdesc.conflict52 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict241 eth_dest_addr; + struct mac_addr.conflict242 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict53 hostdesc.conflict53, *Phostdesc.conflict53; + +struct hostdesc.conflict53 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict246 eth_dest_addr; + struct mac_addr.conflict247 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict50 hostdesc.conflict50, *Phostdesc.conflict50; + +struct hostdesc.conflict50 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict232 eth_dest_addr; + struct mac_addr.conflict233 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict51 hostdesc.conflict51, *Phostdesc.conflict51; + +struct hostdesc.conflict51 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict237 eth_dest_addr; + struct mac_addr.conflict238 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict24 txdesc_host.conflict24, *Ptxdesc_host.conflict24; + +struct txdesc_host.conflict24 { + uint32_t ready; + struct hostdesc.conflict38 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict16 hostdesc.conflict16, *Phostdesc.conflict16; + +struct hostdesc.conflict16 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict123 eth_dest_addr; + struct mac_addr.conflict124 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict15 hostdesc.conflict15, *Phostdesc.conflict15; + +struct hostdesc.conflict15 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict100 eth_dest_addr; + struct mac_addr.conflict101 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict21 txdesc_host.conflict21, *Ptxdesc_host.conflict21; + +struct txdesc_host.conflict21 { + uint32_t ready; + struct hostdesc.conflict35 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict22 txdesc_host.conflict22, *Ptxdesc_host.conflict22; + +struct txdesc_host.conflict22 { + uint32_t ready; + struct hostdesc.conflict36 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict26 txdesc_host.conflict26, *Ptxdesc_host.conflict26; + +struct txdesc_host.conflict26 { + uint32_t ready; + struct hostdesc.conflict42 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict27 txdesc_host.conflict27, *Ptxdesc_host.conflict27; + +struct txdesc_host.conflict27 { + uint32_t ready; + struct hostdesc.conflict43 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict29 txdesc_host.conflict29, *Ptxdesc_host.conflict29; + +struct txdesc_host.conflict29 { + uint32_t ready; + struct hostdesc.conflict45 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict29 hostdesc.conflict29, *Phostdesc.conflict29; + +struct hostdesc.conflict29 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict162 eth_dest_addr; + struct mac_addr.conflict163 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct hostdesc.conflict28 hostdesc.conflict28, *Phostdesc.conflict28; + +struct hostdesc.conflict28 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict160 eth_dest_addr; + struct mac_addr.conflict161 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict11 txdesc_host.conflict11, *Ptxdesc_host.conflict11; + +typedef struct hostdesc.conflict23 hostdesc.conflict23, *Phostdesc.conflict23; + +struct hostdesc.conflict23 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict139 eth_dest_addr; + struct mac_addr.conflict140 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict11 { + uint32_t ready; + struct hostdesc.conflict23 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict12 txdesc_host.conflict12, *Ptxdesc_host.conflict12; + +typedef struct hostdesc.conflict24 hostdesc.conflict24, *Phostdesc.conflict24; + +struct hostdesc.conflict24 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict141 eth_dest_addr; + struct mac_addr.conflict142 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +struct txdesc_host.conflict12 { + uint32_t ready; + struct hostdesc.conflict24 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct hostdesc.conflict22 hostdesc.conflict22, *Phostdesc.conflict22; + +struct hostdesc.conflict22 { + uint32_t pbuf_addr; + uint32_t packet_addr; + uint16_t packet_len; + undefined field_0xa; + undefined field_0xb; + uint32_t status_addr; + struct mac_addr.conflict137 eth_dest_addr; + struct mac_addr.conflict138 eth_src_addr; + uint16_t ethertype; + uint16_t pn[4]; + uint16_t sn; + uint16_t timestamp; + uint8_t tid; + uint8_t vif_idx; + uint8_t staid; + undefined field_0x2d; + uint16_t flags; + uint32_t pbuf_chained_ptr[4]; + uint32_t pbuf_chained_len[4]; +}; + +typedef struct txdesc_host.conflict16 txdesc_host.conflict16, *Ptxdesc_host.conflict16; + +struct txdesc_host.conflict16 { + uint32_t ready; + struct hostdesc.conflict29 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct txdesc_host.conflict17 txdesc_host.conflict17, *Ptxdesc_host.conflict17; + +struct txdesc_host.conflict17 { + uint32_t ready; + struct hostdesc.conflict30 host; + uint32_t pad_txdesc[55]; + uint32_t pad_buf[128]; +}; + +typedef struct uart_priv_data uart_priv_data, *Puart_priv_data; + +typedef struct uart_priv_data uart_priv_data_t; + +struct uart_priv_data { + aos_mutex_t mutex; +}; + +typedef struct _feature_pin _feature_pin, *P_feature_pin; + +struct _feature_pin { + char * featue_name; + char * pin_name; + uint8_t value; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct bl_uart_notify bl_uart_notify, *Pbl_uart_notify; + +struct bl_uart_notify { + void (* rx_cb)(void *); + void * rx_cb_arg; + void (* tx_cb)(void *); + void * tx_cb_arg; +}; + +typedef struct bl_uart_notify bl_uart_notify_t; + +typedef struct apm_sta_add_ind.conflict apm_sta_add_ind.conflict, *Papm_sta_add_ind.conflict; + +struct apm_sta_add_ind.conflict { + uint32_t flags; + struct mac_addr.conflict74 sta_addr; + uint8_t vif_idx; + uint8_t sta_idx; + int8_t rssi; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t tsflo; + uint32_t tsfhi; + uint8_t data_rate; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; +}; + +typedef enum apm_state_tag { + APM_BCN_SETTING=2, + APM_BSS_PARAM_SETTING=1, + APM_IDLE=0, + APM_STATE_MAX=3 +} apm_state_tag; + +typedef struct apm_start_cac_req apm_start_cac_req, *Papm_start_cac_req; + +struct apm_start_cac_req { + struct scan_chan_tag chan; + undefined field_0x6; + undefined field_0x7; + uint32_t center_freq1; + uint32_t center_freq2; + uint8_t ch_width; + uint8_t vif_idx; + undefined field_0x12; + undefined field_0x13; +}; + +typedef struct apm_start_cac_cfm apm_start_cac_cfm, *Papm_start_cac_cfm; + +struct apm_start_cac_cfm { + uint8_t status; + uint8_t ch_idx; +}; + +typedef struct apm_stop_cac_req apm_stop_cac_req, *Papm_stop_cac_req; + +struct apm_stop_cac_req { + uint8_t vif_idx; +}; + +typedef struct UART_CFG_Type UART_CFG_Type, *PUART_CFG_Type; + +typedef enum UART_DataBits_Type { + UART_DATABITS_5=0, + UART_DATABITS_6=1, + UART_DATABITS_7=2, + UART_DATABITS_8=3 +} UART_DataBits_Type; + +typedef enum UART_StopBits_Type { + UART_STOPBITS_1=0, + UART_STOPBITS_1_5=1, + UART_STOPBITS_2=2 +} UART_StopBits_Type; + +typedef enum UART_Parity_Type { + UART_PARITY_EVEN=2, + UART_PARITY_NONE=0, + UART_PARITY_ODD=1 +} UART_Parity_Type; + +typedef enum UART_ByteBitInverse_Type { + UART_LSB_FIRST=0, + UART_MSB_FIRST=1 +} UART_ByteBitInverse_Type; + +struct UART_CFG_Type { + uint32_t uartClk; + uint32_t baudRate; + enum UART_DataBits_Type dataBits; + enum UART_StopBits_Type stopBits; + enum UART_Parity_Type parity; + enum BL_Fun_Type ctsFlowControl; + enum BL_Fun_Type rxDeglitch; + enum BL_Fun_Type rtsSoftwareControl; + enum UART_ByteBitInverse_Type byteBitInverse; + undefined field_0xf; +}; + +typedef struct UART_FifoCfg_Type UART_FifoCfg_Type, *PUART_FifoCfg_Type; + +struct UART_FifoCfg_Type { + uint8_t txFifoDmaThreshold; + uint8_t rxFifoDmaThreshold; + enum BL_Fun_Type txFifoDmaEnable; + enum BL_Fun_Type rxFifoDmaEnable; +}; + +typedef enum UART_ID_Type { + UART0_ID=0, + UART1_ID=1, + UART_ID_MAX=2 +} UART_ID_Type; + +typedef enum UART_AutoBaudDetection_Type { + UART_AUTOBAUD_0X55=0, + UART_AUTOBAUD_STARTBIT=1 +} UART_AutoBaudDetection_Type; + +typedef enum UART_Direction_Type { + UART_RX=1, + UART_TX=0, + UART_TXRX=2 +} UART_Direction_Type; + +typedef enum UART_Overflow_Type { + UART_RX_OVERFLOW=2, + UART_RX_UNDERFLOW=3, + UART_TX_OVERFLOW=0, + UART_TX_UNDERFLOW=1 +} UART_Overflow_Type; + +typedef struct UART_IrCfg_Type UART_IrCfg_Type, *PUART_IrCfg_Type; + +struct UART_IrCfg_Type { + enum BL_Fun_Type txIrEnable; + enum BL_Fun_Type rxIrEnable; + enum BL_Fun_Type txIrInverse; + enum BL_Fun_Type rxIrInverse; + uint16_t txIrPulseStart; + uint16_t txIrPulseStop; + uint16_t rxIrPulseStart; +}; + +typedef enum UART_INT_Type { + UART_INT_ALL=8, + UART_INT_PCE=5, + UART_INT_RTO=4, + UART_INT_RX_END=1, + UART_INT_RX_FER=7, + UART_INT_RX_FIFO_REQ=3, + UART_INT_TX_END=0, + UART_INT_TX_FER=6, + UART_INT_TX_FIFO_REQ=2 +} UART_INT_Type; + +typedef struct ethhdr ethhdr, *Pethhdr; + +struct ethhdr { + uchar h_dest[6]; + uchar h_source[6]; + __be16 h_proto; +}; + +typedef union anon_union.conflict14 anon_union.conflict14, *Panon_union.conflict14; + +union anon_union.conflict14 { + struct anon_struct.conflict25 sta; + struct anon_struct.conflict26 ap; + struct anon_struct.conflict27 ap_vlan; +}; + +typedef union anon_union.conflict15 anon_union.conflict15, *Panon_union.conflict15; + +typedef struct anon_struct.conflict30 anon_struct.conflict30, *Panon_struct.conflict30; + +struct anon_struct.conflict30 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +union anon_union.conflict15 { + struct anon_struct.conflict25 sta; + struct anon_struct.conflict30 ap; + struct anon_struct.conflict27 ap_vlan; +}; + +typedef union anon_union.conflict18 anon_union.conflict18, *Panon_union.conflict18; + +typedef struct anon_struct.conflict35 anon_struct.conflict35, *Panon_struct.conflict35; + +struct anon_struct.conflict35 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +union anon_union.conflict18 { + struct anon_struct.conflict25 sta; + struct anon_struct.conflict35 ap; + struct anon_struct.conflict27 ap_vlan; +}; + +typedef enum ieee80211_vht_mcs_support { + IEEE80211_VHT_MCS_NOT_SUPPORTED=3, + IEEE80211_VHT_MCS_SUPPORT_0_7=0, + IEEE80211_VHT_MCS_SUPPORT_0_8=1, + IEEE80211_VHT_MCS_SUPPORT_0_9=2 +} ieee80211_vht_mcs_support; + +typedef struct anon_struct.conflict34 anon_struct.conflict34, *Panon_struct.conflict34; + +struct anon_struct.conflict34 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict63 anon_struct.conflict63, *Panon_struct.conflict63; + +struct anon_struct.conflict63 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct anon_struct.conflict29 anon_struct.conflict29, *Panon_struct.conflict29; + +struct anon_struct.conflict29 { + u16 flags; + undefined field_0x2; + undefined field_0x3; + struct list_head sta_list; + struct bl_bcn bcn; + u8 bcmc_index; + undefined field_0x31; + undefined field_0x32; + undefined field_0x33; + struct list_head mpath_list; + struct list_head proxy_list; + _Bool create_path; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + int generation; +}; + +typedef struct txl_frame_desc_tag txl_frame_desc_tag, *Ptxl_frame_desc_tag; + +typedef struct txl_frame_cfm_tag txl_frame_cfm_tag, *Ptxl_frame_cfm_tag; + +struct txl_frame_cfm_tag { + void (* cfm_func)(void *, uint32_t); + void * env; +}; + +struct txl_frame_desc_tag { + struct txdesc txdesc; + struct txl_frame_cfm_tag cfm; + uint8_t type; + _Bool postponed; + _Bool keep_desc; + undefined field_0x2d7; +}; + +typedef struct txl_frame_env_tag txl_frame_env_tag, *Ptxl_frame_env_tag; + +struct txl_frame_env_tag { + struct co_list desc_free; + struct co_list desc_done; +}; + +typedef enum icmp_dur_type { + ICMP_DUR_FRAG=4, + ICMP_DUR_HOST=1, + ICMP_DUR_NET=0, + ICMP_DUR_PORT=3, + ICMP_DUR_PROTO=2, + ICMP_DUR_SR=5 +} icmp_dur_type; + +typedef struct icmp_echo_hdr icmp_echo_hdr, *Picmp_echo_hdr; + +struct icmp_echo_hdr { + u8_t type; + u8_t code; + u16_t chksum; + u16_t id; + u16_t seqno; +}; + +typedef struct pro_dev pro_dev, *Ppro_dev; + +typedef struct pro_dev * pro_handle_t; + +typedef struct pro_event pro_event, *Ppro_event; + +typedef struct pro_func pro_func, *Ppro_func; + +typedef enum event_type_t { + PROTOCOL_EVENT_CMD=0, + PROTOCOL_EVENT_DATA=1 +} event_type_t; + +struct pro_event { + enum event_type_t type; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + int event_id; + void * p_buf; + uint32_t length; +}; + +struct pro_dev { + enc_handle_t enc_handle; + struct encrypt enc; + uint8_t old_seq; + undefined field_0x21; + undefined field_0x22; + undefined field_0x23; + uint8_t * pyld_buf; + struct pro_event ev; + uint16_t tol_len_now; + uint16_t total_length; + uint16_t mtu; + uint16_t ack_len; + uint8_t * ack_buf; + undefined field_0x44; + undefined field_0x45; + undefined field_0x46; + undefined field_0x47; + longlong seq_start_ms; + SemaphoreHandle_t xSemaphore; + StaticSemaphore_t xSemaphoreBuffer; + struct pro_func * p_func; + void * p_drv; + undefined field_0xac; + undefined field_0xad; + undefined field_0xae; + undefined field_0xaf; +}; + +struct pro_func { + int (* pfu_bytes_send)(void *, void *, size_t); + int (* pfn_recv_event)(void *, struct pro_event *); +}; + +typedef struct general_head general_head, *Pgeneral_head; + +struct general_head { + uint8_t ctrl; + uint8_t seq; + uint16_t frag_ctrl; +}; + + +// WARNING! conflicting data type names: /DWARF/buf.c/net_buf_simple_pull_le16/lexical_block_0/anon_struct_0 - /DWARF/smp.c/smp_sign_buf/lexical_block_0/anon_struct_0 + + +// WARNING! conflicting data type names: /DWARF/buf.c/net_buf_simple_pull_be16/lexical_block_0/anon_struct_0 - /DWARF/smp.c/smp_sign_buf/lexical_block_0/anon_struct_0 + +typedef struct anon_struct.conflict10 anon_struct.conflict10, *Panon_struct.conflict10; + +struct anon_struct.conflict10 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict98 anon_struct.conflict98, *Panon_struct.conflict98; + +struct anon_struct.conflict98 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict97 anon_struct.conflict97, *Panon_struct.conflict97; + +struct anon_struct.conflict97 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict96 anon_struct.conflict96, *Panon_struct.conflict96; + +struct anon_struct.conflict96 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct net_buf_pool net_buf_pool, *Pnet_buf_pool; + +typedef struct k_lifo k_lifo, *Pk_lifo; + +typedef struct net_buf_data_alloc net_buf_data_alloc, *Pnet_buf_data_alloc; + +typedef struct net_buf_data_cb net_buf_data_cb, *Pnet_buf_data_cb; + +struct k_lifo { + struct k_queue _queue; +}; + +struct net_buf_pool { + struct k_lifo free; + u16_t buf_count; + u16_t uninit_count; + void (* destroy)(struct net_buf *); + struct net_buf_data_alloc * alloc; + struct net_buf * __bufs; +}; + +struct net_buf_data_cb { + u8_t * (* alloc)(struct net_buf *, size_t *, s32_t); + u8_t * (* ref)(struct net_buf *, u8_t *); + void (* unref)(struct net_buf *, u8_t *); +}; + +struct net_buf_data_alloc { + struct net_buf_data_cb * cb; + void * alloc_data; +}; + +typedef struct anon_struct.conflict95 anon_struct.conflict95, *Panon_struct.conflict95; + +struct anon_struct.conflict95 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict99 anon_struct.conflict99, *Panon_struct.conflict99; + +struct anon_struct.conflict99 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict103 anon_struct.conflict103, *Panon_struct.conflict103; + +struct anon_struct.conflict103 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict104 anon_struct.conflict104, *Panon_struct.conflict104; + +struct anon_struct.conflict104 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict100 anon_struct.conflict100, *Panon_struct.conflict100; + +struct anon_struct.conflict100 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict101 anon_struct.conflict101, *Panon_struct.conflict101; + +struct anon_struct.conflict101 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef union anon_union.conflict4 anon_union.conflict4, *Panon_union.conflict4; + +typedef struct anon_struct.conflict8 anon_struct.conflict8, *Panon_struct.conflict8; + +struct anon_struct.conflict8 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +union anon_union.conflict4 { + struct anon_struct.conflict8 field_0; + struct net_buf_simple b; +}; + +typedef struct anon_struct.conflict86 anon_struct.conflict86, *Panon_struct.conflict86; + +struct anon_struct.conflict86 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef union anon_union.conflict6 anon_union.conflict6, *Panon_union.conflict6; + +union anon_union.conflict6 { + struct anon_struct.conflict10 field_0; + struct net_buf_simple b; +}; + +typedef struct anon_struct.conflict81 anon_struct.conflict81, *Panon_struct.conflict81; + +struct anon_struct.conflict81 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict109 anon_struct.conflict109, *Panon_struct.conflict109; + +struct anon_struct.conflict109 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict88 anon_struct.conflict88, *Panon_struct.conflict88; + +struct anon_struct.conflict88 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict111 anon_struct.conflict111, *Panon_struct.conflict111; + +struct anon_struct.conflict111 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict112 anon_struct.conflict112, *Panon_struct.conflict112; + +struct anon_struct.conflict112 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef union anon_union.conflict3 anon_union.conflict3, *Panon_union.conflict3; + +union anon_union.conflict3 { + sys_snode_t node; + struct net_buf * frags; +}; + +typedef struct anon_struct.conflict76 anon_struct.conflict76, *Panon_struct.conflict76; + +struct anon_struct.conflict76 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict79 anon_struct.conflict79, *Panon_struct.conflict79; + +struct anon_struct.conflict79 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict77 anon_struct.conflict77, *Panon_struct.conflict77; + +struct anon_struct.conflict77 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct anon_struct.conflict9 anon_struct.conflict9, *Panon_struct.conflict9; + +struct anon_struct.conflict9 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef struct net_buf_pool_fixed net_buf_pool_fixed, *Pnet_buf_pool_fixed; + +struct net_buf_pool_fixed { + size_t data_size; + u8_t * data_pool; +}; + +typedef struct anon_struct.conflict7 anon_struct.conflict7, *Panon_struct.conflict7; + +struct anon_struct.conflict7 { + u8_t * data; + u16_t len; + u16_t size; + u8_t * __buf; +}; + +typedef enum bt_buf_type { + BT_BUF_ACL_IN=3, + BT_BUF_ACL_OUT=2, + BT_BUF_CMD=0, + BT_BUF_EVT=1 +} bt_buf_type; + +typedef struct fdt_property fdt_property, *Pfdt_property; + +struct fdt_property { + fdt32_t tag; + fdt32_t len; + fdt32_t nameoff; + char[0] data; +}; + +typedef struct fdt_reserve_entry fdt_reserve_entry, *Pfdt_reserve_entry; + +struct fdt_reserve_entry { + fdt64_t address; + fdt64_t size; +}; + +typedef struct fdt_node_header fdt_node_header, *Pfdt_node_header; + +struct fdt_node_header { + fdt32_t tag; + char[0] name; +}; + +typedef struct fdt_header fdt_header, *Pfdt_header; + +struct fdt_header { + fdt32_t magic; + fdt32_t totalsize; + fdt32_t off_dt_struct; + fdt32_t off_dt_strings; + fdt32_t off_mem_rsvmap; + fdt32_t version; + fdt32_t last_comp_version; + fdt32_t boot_cpuid_phys; + fdt32_t size_dt_strings; + fdt32_t size_dt_struct; +}; + +typedef struct cfg_start_cfm cfg_start_cfm, *Pcfg_start_cfm; + +struct cfg_start_cfm { + uint8_t status; +}; + +typedef enum cfg_state_tag { + CFG_IDLE=0, + CFG_STATE_MAX=1 +} cfg_state_tag; + +typedef struct anon_struct.conflict200 anon_struct.conflict200, *Panon_struct.conflict200; + +struct anon_struct.conflict200 { + uint32_t task; + uint32_t element; + uint32_t length; + uint32_t[0] buf; +}; + +typedef union tcp_listen_pcbs_t tcp_listen_pcbs_t, *Ptcp_listen_pcbs_t; + +union tcp_listen_pcbs_t { + struct tcp_pcb_listen * listen_pcbs; + struct tcp_pcb * pcbs; +}; + +typedef struct TIMER_CFG_Type TIMER_CFG_Type, *PTIMER_CFG_Type; + +typedef enum TIMER_Chan_Type { + TIMER_CH0=0, + TIMER_CH1=1, + TIMER_CH_MAX=2 +} TIMER_Chan_Type; + +typedef enum TIMER_ClkSrc_Type { + TIMER_CLKSRC_1K=2, + TIMER_CLKSRC_32K=1, + TIMER_CLKSRC_FCLK=0, + TIMER_CLKSRC_XTAL=3 +} TIMER_ClkSrc_Type; + +typedef enum TIMER_PreLoad_Trig_Type { + TIMER_PRELOAD_TRIG_COMP0=1, + TIMER_PRELOAD_TRIG_COMP1=2, + TIMER_PRELOAD_TRIG_COMP2=3, + TIMER_PRELOAD_TRIG_NONE=0 +} TIMER_PreLoad_Trig_Type; + +typedef enum TIMER_CountMode_Type { + TIMER_COUNT_FREERUN=1, + TIMER_COUNT_PRELOAD=0 +} TIMER_CountMode_Type; + +struct TIMER_CFG_Type { + enum TIMER_Chan_Type timerCh; + enum TIMER_ClkSrc_Type clkSrc; + enum TIMER_PreLoad_Trig_Type plTrigSrc; + enum TIMER_CountMode_Type countMode; + uint8_t clockDivision; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t matchVal0; + uint32_t matchVal1; + uint32_t matchVal2; + uint32_t preLoadVal; +}; + +typedef enum DMA_Trans_Dir_Type { + DMA_TRNS_M2M=0, + DMA_TRNS_M2P=1, + DMA_TRNS_P2M=2, + DMA_TRNS_P2P=3 +} DMA_Trans_Dir_Type; + +typedef enum DMA_Burst_Size_Type { + DMA_BURST_SIZE_1=0, + DMA_BURST_SIZE_16=3, + DMA_BURST_SIZE_4=1, + DMA_BURST_SIZE_8=2 +} DMA_Burst_Size_Type; + +typedef struct DMA_LLI_Ctrl_Type.conflict DMA_LLI_Ctrl_Type.conflict, *PDMA_LLI_Ctrl_Type.conflict; + +typedef struct DMA_Control_Reg.conflict1 DMA_Control_Reg.conflict1, *PDMA_Control_Reg.conflict1; + +struct DMA_Control_Reg.conflict1 { + uint32_t TransferSize:12; + uint32_t SBSize:3; + uint32_t DBSize:3; + uint32_t SWidth:3; + uint32_t DWidth:3; + uint32_t SLargerD:1; + uint32_t reserved_25:1; + uint32_t SI:1; + uint32_t DI:1; + uint32_t Prot:3; + uint32_t I:1; +}; + +struct DMA_LLI_Ctrl_Type.conflict { + uint32_t srcDmaAddr; + uint32_t destDmaAddr; + uint32_t nextLLI; + struct DMA_Control_Reg.conflict1 dmaCtrl; +}; + +typedef struct DMA_LLI_PP_Struct.conflict1 DMA_LLI_PP_Struct.conflict1, *PDMA_LLI_PP_Struct.conflict1; + +typedef struct DMA_Control_Reg.conflict6 DMA_Control_Reg.conflict6, *PDMA_Control_Reg.conflict6; + +typedef struct DMA_LLI_Cfg_Type DMA_LLI_Cfg_Type, *PDMA_LLI_Cfg_Type; + +typedef enum DMA_Periph_Req_Type { + DMA_REQ_GPADC0=22, + DMA_REQ_GPADC1=23, + DMA_REQ_I2C_RX=6, + DMA_REQ_I2C_TX=7, + DMA_REQ_NONE=0, + DMA_REQ_SPI_RX=10, + DMA_REQ_SPI_TX=11, + DMA_REQ_UART0_RX=0, + DMA_REQ_UART0_TX=1, + DMA_REQ_UART1_RX=2, + DMA_REQ_UART1_TX=3 +} DMA_Periph_Req_Type; + +struct DMA_LLI_Cfg_Type { + enum DMA_Trans_Dir_Type dir; + enum DMA_Periph_Req_Type srcPeriph; + enum DMA_Periph_Req_Type dstPeriph; +}; + +struct DMA_Control_Reg.conflict6 { + uint32_t TransferSize:12; + uint32_t SBSize:3; + uint32_t DBSize:3; + uint32_t SWidth:3; + uint32_t DWidth:3; + uint32_t SLargerD:1; + uint32_t reserved_25:1; + uint32_t SI:1; + uint32_t DI:1; + uint32_t Prot:3; + uint32_t I:1; +}; + +struct DMA_LLI_PP_Struct.conflict1 { + uint8_t trans_index; + uint8_t dmaChan; + undefined field_0x2; + undefined field_0x3; + struct DMA_Control_Reg.conflict6 dmaCtrlRegVal; + struct DMA_LLI_Cfg_Type * DMA_LLI_Cfg; + uint32_t operatePeriphAddr; + uint32_t chache_buf_addr[2]; + enum BL_Fun_Type is_single_mode; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; +}; + +typedef struct DMA_LLI_PP_Struct.conflict DMA_LLI_PP_Struct.conflict, *PDMA_LLI_PP_Struct.conflict; + +typedef struct DMA_Control_Reg.conflict4 DMA_Control_Reg.conflict4, *PDMA_Control_Reg.conflict4; + +struct DMA_Control_Reg.conflict4 { + uint32_t TransferSize:12; + uint32_t SBSize:3; + uint32_t DBSize:3; + uint32_t SWidth:3; + uint32_t DWidth:3; + uint32_t SLargerD:1; + uint32_t reserved_25:1; + uint32_t SI:1; + uint32_t DI:1; + uint32_t Prot:3; + uint32_t I:1; +}; + +struct DMA_LLI_PP_Struct.conflict { + uint8_t trans_index; + uint8_t dmaChan; + undefined field_0x2; + undefined field_0x3; + struct DMA_Control_Reg.conflict4 dmaCtrlRegVal; + struct DMA_LLI_Cfg_Type * DMA_LLI_Cfg; + uint32_t operatePeriphAddr; + uint32_t chache_buf_addr[2]; + enum BL_Fun_Type is_single_mode; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; +}; + +typedef struct DMA_LLI_Ctrl_Type.conflict2 DMA_LLI_Ctrl_Type.conflict2, *PDMA_LLI_Ctrl_Type.conflict2; + +typedef struct DMA_Control_Reg.conflict5 DMA_Control_Reg.conflict5, *PDMA_Control_Reg.conflict5; + +struct DMA_Control_Reg.conflict5 { + uint32_t TransferSize:12; + uint32_t SBSize:3; + uint32_t DBSize:3; + uint32_t SWidth:3; + uint32_t DWidth:3; + uint32_t SLargerD:1; + uint32_t reserved_25:1; + uint32_t SI:1; + uint32_t DI:1; + uint32_t Prot:3; + uint32_t I:1; +}; + +struct DMA_LLI_Ctrl_Type.conflict2 { + uint32_t srcDmaAddr; + uint32_t destDmaAddr; + uint32_t nextLLI; + struct DMA_Control_Reg.conflict5 dmaCtrl; +}; + +typedef enum DMA_Chan_Type { + DMA_CH0=0, + DMA_CH1=1, + DMA_CH2=2, + DMA_CH3=3, + DMA_CH_MAX=4 +} DMA_Chan_Type; + +typedef struct DMA_LLI_PP_Buf DMA_LLI_PP_Buf, *PDMA_LLI_PP_Buf; + +typedef struct DMA_LLI_Ctrl_Type DMA_LLI_Ctrl_Type, *PDMA_LLI_Ctrl_Type; + +typedef struct DMA_Control_Reg DMA_Control_Reg, *PDMA_Control_Reg; + +struct DMA_Control_Reg { + uint32_t TransferSize:12; + uint32_t SBSize:3; + uint32_t DBSize:3; + uint32_t SWidth:3; + uint32_t DWidth:3; + uint32_t SLargerD:1; + uint32_t reserved_25:1; + uint32_t SI:1; + uint32_t DI:1; + uint32_t Prot:3; + uint32_t I:1; +}; + +struct DMA_LLI_Ctrl_Type { + uint32_t srcDmaAddr; + uint32_t destDmaAddr; + uint32_t nextLLI; + struct DMA_Control_Reg dmaCtrl; +}; + +struct DMA_LLI_PP_Buf { + uint8_t idleIndex; + uint8_t dmaChan; + undefined field_0x2; + undefined field_0x3; + struct DMA_LLI_Ctrl_Type * lliListHeader[2]; + void (* onTransCompleted)(struct DMA_LLI_Ctrl_Type *); +}; + +typedef enum DMA_INT_Type { + DMA_INT_ALL=2, + DMA_INT_ERR=1, + DMA_INT_TCOMPLETED=0 +} DMA_INT_Type; + +typedef struct DMA_LLI_Ctrl_Type.conflict1 DMA_LLI_Ctrl_Type.conflict1, *PDMA_LLI_Ctrl_Type.conflict1; + +typedef struct DMA_Control_Reg.conflict2 DMA_Control_Reg.conflict2, *PDMA_Control_Reg.conflict2; + +struct DMA_Control_Reg.conflict2 { + uint32_t TransferSize:12; + uint32_t SBSize:3; + uint32_t DBSize:3; + uint32_t SWidth:3; + uint32_t DWidth:3; + uint32_t SLargerD:1; + uint32_t reserved_25:1; + uint32_t SI:1; + uint32_t DI:1; + uint32_t Prot:3; + uint32_t I:1; +}; + +struct DMA_LLI_Ctrl_Type.conflict1 { + uint32_t srcDmaAddr; + uint32_t destDmaAddr; + uint32_t nextLLI; + struct DMA_Control_Reg.conflict2 dmaCtrl; +}; + +typedef struct DMA_Channel_Cfg_Type DMA_Channel_Cfg_Type, *PDMA_Channel_Cfg_Type; + +typedef enum DMA_Trans_Width_Type { + DMA_TRNS_WIDTH_16BITS=1, + DMA_TRNS_WIDTH_32BITS=2, + DMA_TRNS_WIDTH_8BITS=0 +} DMA_Trans_Width_Type; + +struct DMA_Channel_Cfg_Type { + uint32_t srcDmaAddr; + uint32_t destDmaAddr; + uint32_t transfLength; + enum DMA_Trans_Dir_Type dir; + enum DMA_Chan_Type ch; + enum DMA_Trans_Width_Type srcTransfWidth; + enum DMA_Trans_Width_Type dstTransfWidth; + enum DMA_Burst_Size_Type srcBurstSzie; + enum DMA_Burst_Size_Type dstBurstSzie; + uint8_t srcAddrInc; + uint8_t destAddrInc; + enum DMA_Periph_Req_Type srcPeriph; + enum DMA_Periph_Req_Type dstPeriph; + undefined field_0x16; + undefined field_0x17; +}; + +typedef struct DMA_LLI_PP_Struct DMA_LLI_PP_Struct, *PDMA_LLI_PP_Struct; + +typedef struct DMA_Control_Reg.conflict3 DMA_Control_Reg.conflict3, *PDMA_Control_Reg.conflict3; + +struct DMA_Control_Reg.conflict3 { + uint32_t TransferSize:12; + uint32_t SBSize:3; + uint32_t DBSize:3; + uint32_t SWidth:3; + uint32_t DWidth:3; + uint32_t SLargerD:1; + uint32_t reserved_25:1; + uint32_t SI:1; + uint32_t DI:1; + uint32_t Prot:3; + uint32_t I:1; +}; + +struct DMA_LLI_PP_Struct { + uint8_t trans_index; + uint8_t dmaChan; + undefined field_0x2; + undefined field_0x3; + struct DMA_Control_Reg.conflict3 dmaCtrlRegVal; + struct DMA_LLI_Cfg_Type * DMA_LLI_Cfg; + uint32_t operatePeriphAddr; + uint32_t chache_buf_addr[2]; + enum BL_Fun_Type is_single_mode; + undefined field_0x19; + undefined field_0x1a; + undefined field_0x1b; +}; + +typedef struct anon_struct.conflict285 anon_struct.conflict285, *Panon_struct.conflict285; + +struct anon_struct.conflict285 { + uint frac:23; + uint exp:8; + uint sign:1; +}; + +typedef union _FP_UNION_S _FP_UNION_S, *P_FP_UNION_S; + +typedef float SFtype; + +union _FP_UNION_S { + SFtype flt; + struct anon_struct.conflict285 bits; +}; + +typedef SemaphoreHandle_t sys_mutex_t; + +typedef QueueHandle_t sys_mbox_t; + +typedef TaskHandle_t sys_thread_t; + +typedef enum BL_Sts_Type { + RESET=0, + SET=1 +} BL_Sts_Type; + +typedef enum BL_Err_Type { + ERROR=1, + SUCCESS=0, + TIMEOUT=2 +} BL_Err_Type; + +typedef enum BL_Mask_Type { + MASK=1, + UNMASK=0 +} BL_Mask_Type; + +typedef struct scan_cancel_cfm scan_cancel_cfm, *Pscan_cancel_cfm; + +struct scan_cancel_cfm { + uint8_t status; +}; + +typedef struct scan_start_cfm scan_start_cfm, *Pscan_start_cfm; + +struct scan_start_cfm { + uint8_t status; +}; + +typedef enum scan_state_tag { + SCAN_IDLE=0, + SCAN_STATE_MAX=4, + SCAN_WAIT_BEACON_PROBE_RSP=3, + SCAN_WAIT_CHANNEL=2, + SCAN_WAIT_IE_DWNLD=1 +} scan_state_tag; + +typedef enum scan_msg_tag { + SCAN_CANCEL_CFM=2052, + SCAN_CANCEL_REQ=2051, + SCAN_DONE_IND=2050, + SCAN_MAX=2054, + SCAN_START_CFM=2049, + SCAN_START_REQ=2048, + SCAN_TIMER=2053 +} scan_msg_tag; + +typedef struct pka0_bit_shift_op_cfg pka0_bit_shift_op_cfg, *Ppka0_bit_shift_op_cfg; + + +// WARNING! conflicting data type names: /DWARF/sec_eng.c/pka0_bit_shift_op_cfg/anon_union_for_value - /DWARF/bl602_sec_eng.c/pka0_pldi_cfg/anon_union_for_value + +struct pka0_bit_shift_op_cfg { + union anon_union_for_value value; +}; + +typedef struct pka0_common_op_first_cfg pka0_common_op_first_cfg, *Ppka0_common_op_first_cfg; + + +// WARNING! conflicting data type names: /DWARF/sec_eng.c/pka0_common_op_first_cfg/anon_union_for_value - /DWARF/bl602_sec_eng.c/pka0_pldi_cfg/anon_union_for_value + +struct pka0_common_op_first_cfg { + union anon_union_for_value value; +}; + +typedef struct anon_struct.conflict75 anon_struct.conflict75, *Panon_struct.conflict75; + +struct anon_struct.conflict75 { + uint32_t bit_shift:15; + uint32_t reserved_24_31:17; +}; + +typedef struct pka0_pld_cfg pka0_pld_cfg, *Ppka0_pld_cfg; + + +// WARNING! conflicting data type names: /DWARF/sec_eng.c/pka0_pld_cfg/anon_union_for_value - /DWARF/bl602_sec_eng.c/pka0_pldi_cfg/anon_union_for_value + +struct pka0_pld_cfg { + union anon_union_for_value value; +}; + +typedef struct anon_struct.conflict74 anon_struct.conflict74, *Panon_struct.conflict74; + +struct anon_struct.conflict74 { + uint32_t bit_shift:15; + uint32_t reserved_24_31:17; +}; + +typedef struct anon_struct.conflict73 anon_struct.conflict73, *Panon_struct.conflict73; + +struct anon_struct.conflict73 { + uint32_t s2_reg_idx:8; + uint32_t s2_reg_type:4; + uint32_t s1_reg_idx:8; + uint32_t s1_reg_type:4; + uint32_t reserved_24_31:8; +}; + +typedef struct anon_struct.conflict72 anon_struct.conflict72, *Panon_struct.conflict72; + +struct anon_struct.conflict72 { + uint32_t s2_reg_idx:8; + uint32_t s2_reg_type:4; + uint32_t s1_reg_idx:8; + uint32_t s1_reg_type:4; + uint32_t reserved_24_31:8; +}; + +typedef struct anon_struct.conflict71 anon_struct.conflict71, *Panon_struct.conflict71; + +struct anon_struct.conflict71 { + uint32_t s2_reg_idx:8; + uint32_t s2_reg_type:4; + uint32_t reserved_12_31:20; +}; + +typedef struct anon_struct.conflict70 anon_struct.conflict70, *Panon_struct.conflict70; + +struct anon_struct.conflict70 { + uint32_t s2_reg_idx:8; + uint32_t s2_reg_type:4; + uint32_t reserved_12_31:20; +}; + +typedef struct pka0_common_op_snd_cfg_S2_only pka0_common_op_snd_cfg_S2_only, *Ppka0_common_op_snd_cfg_S2_only; + + +// WARNING! conflicting data type names: /DWARF/sec_eng.c/pka0_common_op_snd_cfg_S2_only/anon_union_for_value - /DWARF/bl602_sec_eng.c/pka0_pldi_cfg/anon_union_for_value + +struct pka0_common_op_snd_cfg_S2_only { + union anon_union_for_value value; +}; + +typedef struct pka0_common_op_snd_cfg_S1_S2 pka0_common_op_snd_cfg_S1_S2, *Ppka0_common_op_snd_cfg_S1_S2; + + +// WARNING! conflicting data type names: /DWARF/sec_eng.c/pka0_common_op_snd_cfg_S1_S2/anon_union_for_value - /DWARF/bl602_sec_eng.c/pka0_pldi_cfg/anon_union_for_value + +struct pka0_common_op_snd_cfg_S1_S2 { + union anon_union_for_value value; +}; + +typedef struct pka0_common_op_snd_cfg_S1_only pka0_common_op_snd_cfg_S1_only, *Ppka0_common_op_snd_cfg_S1_only; + + +// WARNING! conflicting data type names: /DWARF/sec_eng.c/pka0_common_op_snd_cfg_S1_only/anon_union_for_value - /DWARF/bl602_sec_eng.c/pka0_pldi_cfg/anon_union_for_value + +struct pka0_common_op_snd_cfg_S1_only { + union anon_union_for_value value; +}; + +typedef struct anon_struct.conflict65 anon_struct.conflict65, *Panon_struct.conflict65; + +struct anon_struct.conflict65 { + uint32_t size:12; + uint32_t d_reg_index:8; + uint32_t d_reg_type:4; + uint32_t op:7; + uint32_t last_op:1; +}; + +typedef struct anon_struct.conflict64 anon_struct.conflict64, *Panon_struct.conflict64; + +struct anon_struct.conflict64 { + uint32_t size:12; + uint32_t d_reg_index:8; + uint32_t d_reg_type:4; + uint32_t op:7; + uint32_t last_op:1; +}; + +typedef struct anon_struct.conflict69 anon_struct.conflict69, *Panon_struct.conflict69; + +struct anon_struct.conflict69 { + uint32_t reserved_0_11:12; + uint32_t s1_reg_idx:8; + uint32_t s1_reg_type:4; + uint32_t reserved_24_31:8; +}; + +typedef struct anon_struct.conflict68 anon_struct.conflict68, *Panon_struct.conflict68; + +struct anon_struct.conflict68 { + uint32_t reserved_0_11:12; + uint32_t s1_reg_idx:8; + uint32_t s1_reg_type:4; + uint32_t reserved_24_31:8; +}; + +typedef struct anon_struct.conflict67 anon_struct.conflict67, *Panon_struct.conflict67; + +struct anon_struct.conflict67 { + uint32_t s0_reg_idx:8; + uint32_t s0_reg_type:4; + uint32_t d_reg_idx:8; + uint32_t d_reg_type:4; + uint32_t op:7; + uint32_t last_op:1; +}; + +typedef struct anon_struct.conflict66 anon_struct.conflict66, *Panon_struct.conflict66; + +struct anon_struct.conflict66 { + uint32_t s0_reg_idx:8; + uint32_t s0_reg_type:4; + uint32_t d_reg_idx:8; + uint32_t d_reg_type:4; + uint32_t op:7; + uint32_t last_op:1; +}; + +typedef enum task_mm_cfg { + TASK_MM_CFG_KEEP_ALIVE_PACKET_COUNTER=2, + TASK_MM_CFG_KEEP_ALIVE_STATUS_ENABLED=0, + TASK_MM_CFG_KEEP_ALIVE_TIME_LAST_RECEIVED=1 +} task_mm_cfg; + +typedef int ptrdiff_t; + +typedef struct mm_timer_env_tag mm_timer_env_tag, *Pmm_timer_env_tag; + +struct mm_timer_env_tag { + struct co_list prog; +}; + +typedef enum dbg_sev_tag { + DBG_SEV_ALL=7, + DBG_SEV_IDX_CRT=1, + DBG_SEV_IDX_ERR=2, + DBG_SEV_IDX_INF=4, + DBG_SEV_IDX_MAX=6, + DBG_SEV_IDX_NONE=0, + DBG_SEV_IDX_VRB=5, + DBG_SEV_IDX_WRN=3 +} dbg_sev_tag; + +typedef struct debug_env_tag debug_env_tag, *Pdebug_env_tag; + +struct debug_env_tag { + uint32_t filter_module; + uint32_t filter_severity; +}; + +typedef enum dbg_mod_tag { + DBG_MOD_IDX_DBG=1, + DBG_MOD_IDX_DMA=3, + DBG_MOD_IDX_IPC=2, + DBG_MOD_IDX_KE=0, + DBG_MOD_IDX_MAX=8, + DBG_MOD_IDX_MM=4, + DBG_MOD_IDX_PHY=7, + DBG_MOD_IDX_RX=6, + DBG_MOD_IDX_TX=5 +} dbg_mod_tag; + +typedef struct anon_struct.conflict183 anon_struct.conflict183, *Panon_struct.conflict183; + +struct anon_struct.conflict183 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict184 anon_struct.conflict184, *Panon_struct.conflict184; + +struct anon_struct.conflict184 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict185 anon_struct.conflict185, *Panon_struct.conflict185; + +struct anon_struct.conflict185 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict180 anon_struct.conflict180, *Panon_struct.conflict180; + +struct anon_struct.conflict180 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict181 anon_struct.conflict181, *Panon_struct.conflict181; + +struct anon_struct.conflict181 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict182 anon_struct.conflict182, *Panon_struct.conflict182; + +struct anon_struct.conflict182 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict188 anon_struct.conflict188, *Panon_struct.conflict188; + +struct anon_struct.conflict188 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict189 anon_struct.conflict189, *Panon_struct.conflict189; + +struct anon_struct.conflict189 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef enum VIF_AP_BCMC_STATUS { + VIF_AP_BCMC_BUFFERED=1, + VIF_AP_BCMC_MOREDATA=2 +} VIF_AP_BCMC_STATUS; + +typedef struct anon_struct.conflict196 anon_struct.conflict196, *Panon_struct.conflict196; + +struct anon_struct.conflict196 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict197 anon_struct.conflict197, *Panon_struct.conflict197; + +struct anon_struct.conflict197 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict230 anon_struct.conflict230, *Panon_struct.conflict230; + +struct anon_struct.conflict230 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict190 anon_struct.conflict190, *Panon_struct.conflict190; + +struct anon_struct.conflict190 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict191 anon_struct.conflict191, *Panon_struct.conflict191; + +struct anon_struct.conflict191 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict235 anon_struct.conflict235, *Panon_struct.conflict235; + +struct anon_struct.conflict235 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict238 anon_struct.conflict238, *Panon_struct.conflict238; + +struct anon_struct.conflict238 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict231 anon_struct.conflict231, *Panon_struct.conflict231; + +struct anon_struct.conflict231 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict232 anon_struct.conflict232, *Panon_struct.conflict232; + +struct anon_struct.conflict232 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict233 anon_struct.conflict233, *Panon_struct.conflict233; + +struct anon_struct.conflict233 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict234 anon_struct.conflict234, *Panon_struct.conflict234; + +struct anon_struct.conflict234 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict239 anon_struct.conflict239, *Panon_struct.conflict239; + +struct anon_struct.conflict239 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict246 anon_struct.conflict246, *Panon_struct.conflict246; + +struct anon_struct.conflict246 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict247 anon_struct.conflict247, *Panon_struct.conflict247; + +struct anon_struct.conflict247 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict242 anon_struct.conflict242, *Panon_struct.conflict242; + +struct anon_struct.conflict242 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict243 anon_struct.conflict243, *Panon_struct.conflict243; + +struct anon_struct.conflict243 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict250 anon_struct.conflict250, *Panon_struct.conflict250; + +struct anon_struct.conflict250 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict251 anon_struct.conflict251, *Panon_struct.conflict251; + +struct anon_struct.conflict251 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict257 anon_struct.conflict257, *Panon_struct.conflict257; + +struct anon_struct.conflict257 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict258 anon_struct.conflict258, *Panon_struct.conflict258; + +struct anon_struct.conflict258 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict259 anon_struct.conflict259, *Panon_struct.conflict259; + +struct anon_struct.conflict259 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict254 anon_struct.conflict254, *Panon_struct.conflict254; + +struct anon_struct.conflict254 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict255 anon_struct.conflict255, *Panon_struct.conflict255; + +struct anon_struct.conflict255 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict256 anon_struct.conflict256, *Panon_struct.conflict256; + +struct anon_struct.conflict256 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict141 anon_struct.conflict141, *Panon_struct.conflict141; + +struct anon_struct.conflict141 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict262 anon_struct.conflict262, *Panon_struct.conflict262; + +struct anon_struct.conflict262 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict142 anon_struct.conflict142, *Panon_struct.conflict142; + +struct anon_struct.conflict142 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict263 anon_struct.conflict263, *Panon_struct.conflict263; + +struct anon_struct.conflict263 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict147 anon_struct.conflict147, *Panon_struct.conflict147; + +struct anon_struct.conflict147 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict268 anon_struct.conflict268, *Panon_struct.conflict268; + +struct anon_struct.conflict268 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict148 anon_struct.conflict148, *Panon_struct.conflict148; + +struct anon_struct.conflict148 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict269 anon_struct.conflict269, *Panon_struct.conflict269; + +struct anon_struct.conflict269 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict149 anon_struct.conflict149, *Panon_struct.conflict149; + +struct anon_struct.conflict149 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct vif_mgmt_env_tag vif_mgmt_env_tag, *Pvif_mgmt_env_tag; + +struct vif_mgmt_env_tag { + struct co_list free_list; + struct co_list used_list; + uint8_t vif_sta_cnt; + uint8_t vif_ap_cnt; + uint8_t low_bcn_int_idx; + undefined field_0x13; +}; + +typedef struct anon_struct.conflict143 anon_struct.conflict143, *Panon_struct.conflict143; + +struct anon_struct.conflict143 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict264 anon_struct.conflict264, *Panon_struct.conflict264; + +struct anon_struct.conflict264 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict144 anon_struct.conflict144, *Panon_struct.conflict144; + +struct anon_struct.conflict144 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict265 anon_struct.conflict265, *Panon_struct.conflict265; + +struct anon_struct.conflict265 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct vif_info_tag vif_info_tag, *Pvif_info_tag; + + +// WARNING! conflicting data type names: /DWARF/vif_mgmt.h/vif_info_tag/anon_union_for_u - /DWARF/timers.c/tmrTimerQueueMessage/anon_union_for_u + +struct vif_info_tag { + struct co_list_hdr list_hdr; + uint32_t prevent_sleep; + uint32_t txq_params[4]; + struct mm_timer_tag tbtt_timer; + struct mm_timer_tag tmr_bcn_to; + struct mac_addr.conflict bssid; + undefined field_0x3e; + undefined field_0x3f; + struct chan_ctxt_tag * chan_ctxt; + struct chan_tbtt_tag tbtt_switch; + struct mac_addr.conflict mac_addr; + uint8_t type; + uint8_t index; + _Bool active; + int8_t tx_power; + int8_t user_tx_power; + undefined field_0x5b; + union anon_union_for_u u; + struct co_list sta_list; + struct mac_bss_info bss_info; + undefined field_0x41c; + undefined field_0x41d; + undefined field_0x41e; + undefined field_0x41f; + struct key_info_tag key_info[4]; + struct key_info_tag * default_key; + uint32_t flags; + struct mm_chan_ctxt_add_req csa_channel; + undefined field_0x5d2; + undefined field_0x5d3; + undefined field_0x5d4; + undefined field_0x5d5; + undefined field_0x5d6; + undefined field_0x5d7; +}; + +typedef struct anon_struct.conflict150 anon_struct.conflict150, *Panon_struct.conflict150; + +struct anon_struct.conflict150 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict271 anon_struct.conflict271, *Panon_struct.conflict271; + +struct anon_struct.conflict271 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict272 anon_struct.conflict272, *Panon_struct.conflict272; + +struct anon_struct.conflict272 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict152 anon_struct.conflict152, *Panon_struct.conflict152; + +struct anon_struct.conflict152 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict273 anon_struct.conflict273, *Panon_struct.conflict273; + +struct anon_struct.conflict273 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict153 anon_struct.conflict153, *Panon_struct.conflict153; + +struct anon_struct.conflict153 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict274 anon_struct.conflict274, *Panon_struct.conflict274; + +struct anon_struct.conflict274 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict270 anon_struct.conflict270, *Panon_struct.conflict270; + +struct anon_struct.conflict270 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict279 anon_struct.conflict279, *Panon_struct.conflict279; + +struct anon_struct.conflict279 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict154 anon_struct.conflict154, *Panon_struct.conflict154; + +struct anon_struct.conflict154 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict275 anon_struct.conflict275, *Panon_struct.conflict275; + +struct anon_struct.conflict275 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict155 anon_struct.conflict155, *Panon_struct.conflict155; + +struct anon_struct.conflict155 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict156 anon_struct.conflict156, *Panon_struct.conflict156; + +struct anon_struct.conflict156 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict157 anon_struct.conflict157, *Panon_struct.conflict157; + +struct anon_struct.conflict157 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict278 anon_struct.conflict278, *Panon_struct.conflict278; + +struct anon_struct.conflict278 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict164 anon_struct.conflict164, *Panon_struct.conflict164; + +struct anon_struct.conflict164 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict165 anon_struct.conflict165, *Panon_struct.conflict165; + +struct anon_struct.conflict165 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict166 anon_struct.conflict166, *Panon_struct.conflict166; + +struct anon_struct.conflict166 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict167 anon_struct.conflict167, *Panon_struct.conflict167; + +struct anon_struct.conflict167 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct anon_struct.conflict174 anon_struct.conflict174, *Panon_struct.conflict174; + +struct anon_struct.conflict174 { + uint16_t listen_interval; + _Bool dont_wait_bcmc; + uint8_t ps_retry; + uint8_t ap_id; + undefined field_0x5; + undefined field_0x6; + undefined field_0x7; + uint32_t uapsd_last_rxtx; + uint8_t uapsd_queues; + undefined field_0xd; + undefined field_0xe; + undefined field_0xf; + uint32_t mon_last_tx; + uint32_t mon_last_crc; + uint8_t beacon_loss_cnt; + int8_t rssi; + int8_t rssi_thold; + uint8_t rssi_hyst; + _Bool rssi_status; + uint8_t csa_count; + _Bool csa_occured; + undefined field_0x1f; +}; + +typedef struct anon_struct.conflict175 anon_struct.conflict175, *Panon_struct.conflict175; + +struct anon_struct.conflict175 { + uint32_t dummy; + struct txl_frame_desc_tag bcn_desc; + uint16_t bcn_len; + uint16_t tim_len; + uint16_t tim_bitmap_set; + uint16_t bcn_int; + uint8_t bcn_tbtt_ratio; + uint8_t bcn_tbtt_cnt; + _Bool bcn_configured; + uint8_t dtim_count; + uint8_t tim_n1; + uint8_t tim_n2; + uint8_t bc_mc_status; + uint8_t csa_count; + uint8_t csa_oft[2]; + uint8_t ps_sta_cnt; + undefined field_0x2ef; + uint16_t ctrl_port_ethertype; + undefined field_0x2f2; + undefined field_0x2f3; +}; + +typedef struct _wifi_conn _wifi_conn, *P_wifi_conn; + +struct _wifi_conn { + char ssid[32]; + char ssid_tail[1]; + char pask[64]; +}; + +typedef struct _wifi_item _wifi_item, *P_wifi_item; + +struct _wifi_item { + char ssid[32]; + uint32_t ssid_len; + uint8_t bssid[6]; + uint8_t channel; + uint8_t auth; + int8_t rssi; + undefined field_0x2d; + undefined field_0x2e; + undefined field_0x2f; +}; + +typedef struct _wifi_item _wifi_item_t; + +typedef struct _wifi_state _wifi_state, *P_wifi_state; + +struct _wifi_state { + char ip[16]; + char gw[16]; + char mask[16]; + char ssid[32]; + char ssid_tail[1]; + uint8_t bssid[6]; + uint8_t state; +}; + +typedef struct wifi_state wifi_state, *Pwifi_state; + +struct wifi_state { + char ip[16]; + char gw[16]; + char mask[16]; + char ssid[32]; + char ssid_tail[1]; + uint8_t bssid[6]; + uint8_t state; +}; + +typedef struct blesync_wifi_item blesync_wifi_item, *Pblesync_wifi_item; + +struct blesync_wifi_item { + char ssid[32]; + uint32_t ssid_len; + uint8_t bssid[6]; + uint8_t channel; + uint8_t auth; + int8_t rssi; + undefined field_0x2d; + undefined field_0x2e; + undefined field_0x2f; +}; + +typedef struct bl_ble_sync bl_ble_sync, *Pbl_ble_sync; + +typedef struct bl_ble_sync bl_ble_sync_t; + +typedef struct queue_buf queue_buf, *Pqueue_buf; + +typedef struct blesync_wifi_func blesync_wifi_func, *Pblesync_wifi_func; + +typedef struct wifi_conn wifi_conn, *Pwifi_conn; + +typedef struct blesync_wifi_item blesync_wifi_item_t; + +struct queue_buf { + uint8_t buf[256]; + uint32_t len; +}; + +struct blesync_wifi_func { + void (* local_connect_remote_ap)(struct wifi_conn *); + void (* local_disconnect_remote_ap)(void); + void (* local_wifi_scan)(void (* )(void *)); + void (* local_wifi_state_get)(void (* )(void *)); +}; + +struct wifi_conn { + uint8_t ssid[32]; + uint8_t ssid_tail[1]; + uint8_t pask[64]; +}; + +struct bl_ble_sync { + SemaphoreHandle_t xSemaphore; + StaticSemaphore_t xSemaphoreBuffer; + struct wifi_state state; + QueueHandle_t xQueue1; + StaticQueue_t xQueueBuffer; + struct queue_buf buf[2]; + struct queue_buf send_buf; + pro_handle_t pro_handle; + void (* complete_cb)(void *); + void * p_arg; + struct blesync_wifi_func * wifi_func; + uint8_t attr_read_buf[256]; + uint8_t attr_write_buf[256]; + uint16_t rbuf_len; + uint8_t task_runing; + uint8_t scaning; + uint8_t stop_flag; + struct wifi_conn conn_info; + undefined field_0x682; + undefined field_0x683; + struct bt_conn * p_cur_conn; + StackType_t stack[512]; + StaticTask_t task; + TaskHandle_t task_handle; + undefined field_0xeec; + undefined field_0xeed; + undefined field_0xeee; + undefined field_0xeef; + struct pro_dev pro_dev; + blesync_wifi_item_t ap_item[50]; + uint8_t w_ap_item; + uint8_t r_ap_item; + undefined field_0x1902; + undefined field_0x1903; + undefined field_0x1904; + undefined field_0x1905; + undefined field_0x1906; + undefined field_0x1907; +}; + +typedef struct bl_ble_sync.conflict1 bl_ble_sync.conflict1, *Pbl_ble_sync.conflict1; + +typedef void (* pfn_complete_cb_t.conflict)(void *); + +struct bl_ble_sync.conflict1 { + SemaphoreHandle_t xSemaphore; + StaticSemaphore_t xSemaphoreBuffer; + struct wifi_state state; + QueueHandle_t xQueue1; + StaticQueue_t xQueueBuffer; + struct queue_buf buf[2]; + struct queue_buf send_buf; + pro_handle_t pro_handle; + pfn_complete_cb_t.conflict complete_cb; + void * p_arg; + struct blesync_wifi_func * wifi_func; + uint8_t attr_read_buf[256]; + uint8_t attr_write_buf[256]; + uint16_t rbuf_len; + uint8_t task_runing; + uint8_t scaning; + uint8_t stop_flag; + struct wifi_conn conn_info; + undefined field_0x682; + undefined field_0x683; + struct bt_conn * p_cur_conn; + StackType_t stack[512]; + StaticTask_t task; + TaskHandle_t task_handle; + undefined field_0xeec; + undefined field_0xeed; + undefined field_0xeee; + undefined field_0xeef; + struct pro_dev pro_dev; + blesync_wifi_item_t ap_item[50]; + uint8_t w_ap_item; + uint8_t r_ap_item; + undefined field_0x1902; + undefined field_0x1903; + undefined field_0x1904; + undefined field_0x1905; + undefined field_0x1906; + undefined field_0x1907; +}; + +typedef struct bl_ble_sync.conflict1 bl_ble_sync_t.conflict; + +typedef struct bl_ble_sync.conflict bl_ble_sync.conflict, *Pbl_ble_sync.conflict; + +struct bl_ble_sync.conflict { + SemaphoreHandle_t xSemaphore; + StaticSemaphore_t xSemaphoreBuffer; + struct wifi_state state; + QueueHandle_t xQueue1; + StaticQueue_t xQueueBuffer; + struct queue_buf buf[2]; + struct queue_buf send_buf; + pro_handle_t pro_handle; + pfn_complete_cb_t.conflict complete_cb; + void * p_arg; + struct blesync_wifi_func * wifi_func; + uint8_t attr_read_buf[256]; + uint8_t attr_write_buf[256]; + uint16_t rbuf_len; + uint8_t task_runing; + uint8_t scaning; + uint8_t stop_flag; + struct wifi_conn conn_info; + undefined field_0x682; + undefined field_0x683; + struct bt_conn * p_cur_conn; + StackType_t stack[512]; + StaticTask_t task; + TaskHandle_t task_handle; + undefined field_0xeec; + undefined field_0xeed; + undefined field_0xeee; + undefined field_0xeef; + struct pro_dev pro_dev; + blesync_wifi_item_t ap_item[50]; + uint8_t w_ap_item; + uint8_t r_ap_item; + undefined field_0x1902; + undefined field_0x1903; + undefined field_0x1904; + undefined field_0x1905; + undefined field_0x1906; + undefined field_0x1907; +}; + +typedef struct tcpip_msg tcpip_msg, *Ptcpip_msg; + +typedef enum tcpip_msg_type { + TCPIP_MSG_API=0, + TCPIP_MSG_API_CALL=1, + TCPIP_MSG_CALLBACK=3, + TCPIP_MSG_CALLBACK_STATIC=4, + TCPIP_MSG_INPKT=2 +} tcpip_msg_type; + + +// WARNING! conflicting data type names: /DWARF/tcpip_priv.h/tcpip_msg/anon_union_for_msg - /DWARF/api_msg.h/netifapi_msg/anon_union_for_msg + +struct tcpip_msg { + enum tcpip_msg_type type; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + union anon_union_for_msg msg; +}; + +typedef struct anon_struct.conflict121 anon_struct.conflict121, *Panon_struct.conflict121; + +struct anon_struct.conflict121 { + tcpip_callback_fn function; + void * msg; +}; + +typedef struct anon_struct.conflict122 anon_struct.conflict122, *Panon_struct.conflict122; + +struct anon_struct.conflict122 { + err_t (* function)(struct tcpip_api_call_data *); + struct tcpip_api_call_data * arg; + sys_sem_t * sem; +}; + +typedef struct anon_struct.conflict123 anon_struct.conflict123, *Panon_struct.conflict123; + +struct anon_struct.conflict123 { + struct pbuf * p; + struct netif * netif; + err_t (* input_fn)(struct pbuf *, struct netif *); +}; + +typedef struct anon_struct.conflict124 anon_struct.conflict124, *Panon_struct.conflict124; + +struct anon_struct.conflict124 { + tcpip_callback_fn function; + void * ctx; +}; + +typedef struct DMA_Control_Reg.conflict DMA_Control_Reg.conflict, *PDMA_Control_Reg.conflict; + +struct DMA_Control_Reg.conflict { + uint32_t TransferSize:12; + uint32_t SBSize:3; + uint32_t DBSize:3; + uint32_t SWidth:3; + uint32_t DWidth:3; + uint32_t SLargerD:1; + uint32_t reserved_25:1; + uint32_t SI:1; + uint32_t DI:1; + uint32_t Prot:3; + uint32_t I:1; +}; + +typedef struct dhcp_server dhcp_server, *Pdhcp_server; + +typedef struct dhcp_client_node dhcp_client_node, *Pdhcp_client_node; + +struct dhcp_server { + struct dhcp_server * next; + struct netif * netif; + struct udp_pcb * pcb; + struct dhcp_client_node * node_list; + ip4_addr_t start; + ip4_addr_t end; + ip4_addr_t current; +}; + +struct dhcp_client_node { + struct dhcp_client_node * next; + u8_t chaddr[6]; + undefined field_0xa; + undefined field_0xb; + ip4_addr_t ipaddr; + u32_t lease_end; +}; + +typedef struct eth_hdr eth_hdr, *Peth_hdr; + +struct eth_hdr { + struct eth_addr dest; + struct eth_addr src; + u16_t type; +}; + +typedef struct tc_cmac_struct tc_cmac_struct, *Ptc_cmac_struct; + +struct tc_cmac_struct { + uint8_t iv[16]; + uint8_t K1[16]; + uint8_t K2[16]; + uint8_t leftover[16]; + uint keyid; + uint leftover_offset; + TCAesKeySched_t sched; + undefined field_0x4c; + undefined field_0x4d; + undefined field_0x4e; + undefined field_0x4f; + uint64_t countdown; +}; + +typedef struct tc_cmac_struct * TCCmacState_t; + +typedef enum ps_dpsm_state_bit_pos { + PS_DPSM_STATE_ON=0, + PS_DPSM_STATE_PAUSE=3, + PS_DPSM_STATE_PAUSING=1, + PS_DPSM_STATE_RESUMING=2, + PS_DPSM_STATE_SET_MODE_REQ=4 +} ps_dpsm_state_bit_pos; + +typedef struct ps_env_tag ps_env_tag, *Pps_env_tag; + +struct ps_env_tag { + _Bool ps_on; + undefined field_0x1; + ke_task_id_t taskid; + uint32_t prevent_sleep; + uint8_t cfm_cnt; + undefined field_0x9; + undefined field_0xa; + undefined field_0xb; + struct mm_timer_tag uapsd_timer; + _Bool uapsd_tmr_on; + _Bool uapsd_on; + undefined field_0x1e; + undefined field_0x1f; + uint32_t uapsd_timeout; + uint8_t dpsm_state; + uint8_t next_mode; + undefined field_0x26; + undefined field_0x27; +}; + +typedef struct tcp_pcb.conflict10 tcp_pcb.conflict10, *Ptcp_pcb.conflict10; + +struct tcp_pcb.conflict10 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict tcp_pcb.conflict, *Ptcp_pcb.conflict; + +struct tcp_pcb.conflict { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict9 tcp_pcb.conflict9, *Ptcp_pcb.conflict9; + +struct tcp_pcb.conflict9 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict7 tcp_pcb.conflict7, *Ptcp_pcb.conflict7; + +struct tcp_pcb.conflict7 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict8 tcp_pcb.conflict8, *Ptcp_pcb.conflict8; + +struct tcp_pcb.conflict8 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict1 tcp_pcb.conflict1, *Ptcp_pcb.conflict1; + +struct tcp_pcb.conflict1 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict2 tcp_pcb.conflict2, *Ptcp_pcb.conflict2; + +struct tcp_pcb.conflict2 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict5 tcp_pcb.conflict5, *Ptcp_pcb.conflict5; + +struct tcp_pcb.conflict5 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict6 tcp_pcb.conflict6, *Ptcp_pcb.conflict6; + +struct tcp_pcb.conflict6 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict3 tcp_pcb.conflict3, *Ptcp_pcb.conflict3; + +struct tcp_pcb.conflict3 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct tcp_pcb.conflict4 tcp_pcb.conflict4, *Ptcp_pcb.conflict4; + +struct tcp_pcb.conflict4 { + ip_addr_t local_ip; + ip_addr_t remote_ip; + u8_t netif_idx; + u8_t so_options; + u8_t tos; + u8_t ttl; + struct tcp_pcb * next; + void * callback_arg; + enum tcp_state state; + u8_t prio; + u16_t local_port; + u16_t remote_port; + tcpflags_t flags; + u8_t polltmr; + u8_t pollinterval; + u8_t last_timer; + undefined field_0x1f; + u32_t tmr; + u32_t rcv_nxt; + tcpwnd_size_t rcv_wnd; + tcpwnd_size_t rcv_ann_wnd; + u32_t rcv_ann_right_edge; + s16_t rtime; + u16_t mss; + u32_t rttest; + u32_t rtseq; + s16_t sa; + s16_t sv; + s16_t rto; + u8_t nrtx; + u8_t dupacks; + u32_t lastack; + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + u32_t rto_end; + u32_t snd_nxt; + u32_t snd_wl1; + u32_t snd_wl2; + u32_t snd_lbb; + tcpwnd_size_t snd_wnd; + tcpwnd_size_t snd_wnd_max; + tcpwnd_size_t snd_buf; + u16_t snd_queuelen; + u16_t unsent_oversize; + tcpwnd_size_t bytes_acked; + struct tcp_seg * unsent; + struct tcp_seg * unacked; + struct tcp_seg * ooseq; + struct pbuf * refused_data; + struct tcp_pcb_listen * listener; + err_t (* sent)(void *, struct tcp_pcb *, u16_t); + err_t (* recv)(void *, struct tcp_pcb *, struct pbuf *, err_t); + tcp_connected_fn connected; + err_t (* poll)(void *, struct tcp_pcb *); + void (* errf)(void *, err_t); + u32_t keep_idle; + u32_t keep_intvl; + u32_t keep_cnt; + u8_t persist_cnt; + u8_t persist_backoff; + u8_t persist_probe; + u8_t keep_cnt_sent; +}; + +typedef struct HeapRegion HeapRegion, *PHeapRegion; + +struct HeapRegion { + uint8_t * pucStartAddress; + size_t xSizeInBytes; +}; + +typedef struct HeapRegion HeapRegion_t; + +typedef struct _IEEEtypes_Rsn_t _IEEEtypes_Rsn_t, *P_IEEEtypes_Rsn_t; + +typedef struct _IEEEtypes_Rsn_t IEEEtypes_Rsn_t; + +typedef struct _wpa_suite_t _wpa_suite_t, *P_wpa_suite_t; + +typedef struct _wpa_suite_t wpa_suite_mcast_t; + +typedef struct anon_struct.conflict203 anon_struct.conflict203, *Panon_struct.conflict203; + +typedef struct anon_struct.conflict203 wpa_suite_ucast_t; + +typedef struct anon_struct.conflict203 wpa_suite_auth_key_mgmt_t; + +typedef struct _wpa_suite_t wpa_suite; + +struct _wpa_suite_t { + uint8_t oui[3]; + uint8_t type; +}; + +struct anon_struct.conflict203 { + uint16_t count; + wpa_suite list[2]; +}; + +struct _IEEEtypes_Rsn_t { + uint8_t element_id; + uint8_t len; + uint16_t version; + wpa_suite_mcast_t group_cipher; + wpa_suite_ucast_t pairwise_cipher; + wpa_suite_auth_key_mgmt_t auth_key_mgmt; +}; + +typedef struct _IEEEtypes_Wpa_t _IEEEtypes_Wpa_t, *P_IEEEtypes_Wpa_t; + +typedef struct _IEEEtypes_Wpa_t IEEEtypes_Wpa_t; + +struct _IEEEtypes_Wpa_t { + uint8_t element_id; + uint8_t len; + uint8_t oui[4]; + uint16_t version; + wpa_suite_mcast_t group_cipher; + wpa_suite_ucast_t pairwise_cipher; + wpa_suite_auth_key_mgmt_t auth_key_mgmt; +}; + +typedef struct cm_ConnectionInfo cm_ConnectionInfo_t; + +typedef struct wifi_ap_data_rate wifi_ap_data_rate, *Pwifi_ap_data_rate; + +struct wifi_ap_data_rate { + uint8_t data_rate; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + char * val; +}; + +typedef struct rc4_key rc4_key, *Prc4_key; + +struct rc4_key { + uchar state[256]; + uchar x; + uchar y; +}; + +typedef struct netif.conflict netif.conflict, *Pnetif.conflict; + +typedef void (* netif_status_callback_fn.conflict)(struct netif *); + +struct netif.conflict { + struct netif * next; + ip_addr_t ip_addr; + ip_addr_t netmask; + ip_addr_t gw; + err_t (* input)(struct pbuf *, struct netif *); + err_t (* output)(struct netif *, struct pbuf *, ip4_addr_t *); + err_t (* linkoutput)(struct netif *, struct pbuf *); + netif_status_callback_fn.conflict status_callback; + netif_status_callback_fn.conflict link_callback; + void * state; + void * client_data[3]; + char * hostname; + u16_t mtu; + u8_t hwaddr[6]; + u8_t hwaddr_len; + u8_t flags; + char name[2]; + u8_t num; + u8_t rs_count; + undefined field_0x46; + undefined field_0x47; + err_t (* igmp_mac_filter)(struct netif *, ip4_addr_t *, enum netif_mac_filter_action); +}; + +typedef u8_t netif_addr_idx_t; + +typedef enum lwip_internal_netif_client_data_index { + LWIP_NETIF_CLIENT_DATA_INDEX_DHCP=0, + LWIP_NETIF_CLIENT_DATA_INDEX_IGMP=1, + LWIP_NETIF_CLIENT_DATA_INDEX_MAX=2 +} lwip_internal_netif_client_data_index; + +typedef enum co_llcp_opcode { + LLCP_CHANNEL_MAP_IND_OPCODE=1, + LLCP_CONNECTION_PARAM_REQ_OPCODE=15, + LLCP_CONNECTION_PARAM_RSP_OPCODE=16, + LLCP_CONNECTION_UPDATE_IND_OPCODE=0, + LLCP_ENC_REQ_OPCODE=3, + LLCP_ENC_RSP_OPCODE=4, + LLCP_FEATURE_REQ_OPCODE=8, + LLCP_FEATURE_RSP_OPCODE=9, + LLCP_LENGTH_REQ_OPCODE=20, + LLCP_LENGTH_RSP_OPCODE=21, + LLCP_OPCODE_MAX_OPCODE=22, + LLCP_PAUSE_ENC_REQ_OPCODE=10, + LLCP_PAUSE_ENC_RSP_OPCODE=11, + LLCP_PING_REQ_OPCODE=18, + LLCP_PING_RSP_OPCODE=19, + LLCP_REJECT_IND_EXT_OPCODE=17, + LLCP_REJECT_IND_OPCODE=13, + LLCP_SLAVE_FEATURE_REQ_OPCODE=14, + LLCP_START_ENC_REQ_OPCODE=5, + LLCP_START_ENC_RSP_OPCODE=6, + LLCP_TERMINATE_IND_OPCODE=2, + LLCP_UNKNOWN_RSP_OPCODE=7, + LLCP_VERSION_IND_OPCODE=12 +} co_llcp_opcode; + +typedef enum co_llcp_length { + LLCP_CH_MAP_REQ_LEN=8, + LLCP_CON_PARAM_REQ_LEN=24, + LLCP_CON_PARAM_RSP_LEN=24, + LLCP_CON_REQ_LEN=34, + LLCP_CON_UPD_IND_LEN=12, + LLCP_ENC_REQ_LEN=23, + LLCP_ENC_RSP_LEN=13, + LLCP_FEAT_REQ_LEN=9, + LLCP_FEAT_RSP_LEN=9, + LLCP_LENGTH_REQ_LEN=9, + LLCP_LENGTH_RSP_LEN=9, + LLCP_PA_ENC_REQ_LEN=1, + LLCP_PA_ENC_RSP_LEN=1, + LLCP_PDU_LENGTH_MAX=34, + LLCP_PING_REQ_LEN=1, + LLCP_PING_RSP_LEN=1, + LLCP_REJECT_IND_EXT_LEN=3, + LLCP_REJ_IND_LEN=2, + LLCP_SLAVE_FEATURE_REQ_LEN=9, + LLCP_ST_ENC_REQ_LEN=1, + LLCP_ST_ENC_RSP_LEN=1, + LLCP_TERM_IND_LEN=2, + LLCP_UNKN_RSP_LEN=2, + LLCP_VERS_IND_LEN=6 +} co_llcp_length; + +typedef int __intptr_t; + +typedef __intptr_t intptr_t; + +typedef struct rxl_cntrl_env_tag rxl_cntrl_env_tag, *Prxl_cntrl_env_tag; + +struct rxl_cntrl_env_tag { + struct co_list ready; + struct rx_dmadesc * first; + struct rx_dmadesc * last; + struct rx_dmadesc * free; + uint32_t packet_stack_cnt; +}; + +typedef struct counter_fc counter_fc, *Pcounter_fc; + +struct counter_fc { + uint16_t acl_pkt_sent; +}; + +typedef struct host_set_fc host_set_fc, *Phost_set_fc; + +struct host_set_fc { + _Bool acl_flow_cntl_en; + undefined field_0x1; + uint16_t acl_pkt_len; + uint16_t acl_pkt_nb; + uint16_t curr_pkt_nb; +}; + +typedef struct hci_fc_tag hci_fc_tag, *Phci_fc_tag; + +struct hci_fc_tag { + struct host_set_fc host_set; + struct counter_fc cntr; +}; + +typedef struct _gpio_ctx_desc _gpio_ctx_desc, *P_gpio_ctx_desc; + +struct _gpio_ctx_desc { + struct _gpio_ctx_desc * next; + void (* gpio_handler)(void *); + void * arg; + uint8_t gpioPin; + uint8_t intCtrlMod; + uint8_t intTrgMod; + undefined field_0xf; +}; + +typedef struct _gpio_ctx_desc gpio_ctx_t; + +typedef struct gpio_feature_config gpio_feature_config, *Pgpio_feature_config; + +struct gpio_feature_config { + int pin; + uint8_t valid; + uint8_t feature; + uint8_t active; + uint8_t mode; + uint time; +}; + +typedef struct GLB_GPIO_Cfg_Type GLB_GPIO_Cfg_Type, *PGLB_GPIO_Cfg_Type; + +struct GLB_GPIO_Cfg_Type { + uint8_t gpioPin; + uint8_t gpioFun; + uint8_t gpioMode; + uint8_t pullType; + uint8_t drive; + uint8_t smtCtrl; +}; + +typedef enum GLB_GPIO_FUNC_Type { + GPIO_FUN_ANALOG=10, + GPIO_FUN_EXT_PA=9, + GPIO_FUN_FLASH=2, + GPIO_FUN_I2C=6, + GPIO_FUN_JTAG=14, + GPIO_FUN_PWM=8, + GPIO_FUN_SDIO=1, + GPIO_FUN_SPI=4, + GPIO_FUN_SWGPIO=11, + GPIO_FUN_UART=7 +} GLB_GPIO_FUNC_Type; + +typedef enum GLB_GPIO_Type { + GLB_GPIO_PIN_0=0, + GLB_GPIO_PIN_1=1, + GLB_GPIO_PIN_10=10, + GLB_GPIO_PIN_11=11, + GLB_GPIO_PIN_12=12, + GLB_GPIO_PIN_13=13, + GLB_GPIO_PIN_14=14, + GLB_GPIO_PIN_15=15, + GLB_GPIO_PIN_16=16, + GLB_GPIO_PIN_17=17, + GLB_GPIO_PIN_18=18, + GLB_GPIO_PIN_19=19, + GLB_GPIO_PIN_2=2, + GLB_GPIO_PIN_20=20, + GLB_GPIO_PIN_21=21, + GLB_GPIO_PIN_22=22, + GLB_GPIO_PIN_3=3, + GLB_GPIO_PIN_4=4, + GLB_GPIO_PIN_5=5, + GLB_GPIO_PIN_6=6, + GLB_GPIO_PIN_7=7, + GLB_GPIO_PIN_8=8, + GLB_GPIO_PIN_9=9, + GLB_GPIO_PIN_MAX=23 +} GLB_GPIO_Type; + +typedef struct txl_buffer_list_tag txl_buffer_list_tag, *Ptxl_buffer_list_tag; + +struct txl_buffer_list_tag { + struct txl_buffer_tag * first; + struct txl_buffer_tag * last; +}; + +typedef struct txl_buffer_env_tag txl_buffer_env_tag, *Ptxl_buffer_env_tag; + +typedef struct txl_buffer_idx_tag txl_buffer_idx_tag, *Ptxl_buffer_idx_tag; + +typedef struct txl_buffer_hw_desc_tag txl_buffer_hw_desc_tag, *Ptxl_buffer_hw_desc_tag; + +struct txl_buffer_idx_tag { + uint32_t used_area; + uint32_t free; + uint32_t free_size; + uint32_t last; + uint32_t next_needed; + uint32_t buf_size; + uint32_t * pool; + struct txl_buffer_hw_desc_tag * desc; + uint8_t count; + undefined field_0x21; + undefined field_0x22; + undefined field_0x23; +}; + +struct txl_buffer_env_tag { + struct txl_buffer_idx_tag buf_idx[5][1]; + struct txl_buffer_list_tag list[5]; +}; + +struct txl_buffer_hw_desc_tag { + struct dma_desc dma_desc; + struct tx_pbd pbd; +}; + +typedef enum riscv_abi_type { + ABI_ILP32=0, + ABI_ILP32D=3, + ABI_ILP32E=1, + ABI_ILP32F=2, + ABI_LP64=4, + ABI_LP64D=6, + ABI_LP64F=5 +} riscv_abi_type; + +typedef enum riscv_microarchitecture_type { + generic=0, + sifive_7=1 +} riscv_microarchitecture_type; + +typedef enum riscv_code_model { + CM_MEDANY=1, + CM_MEDLOW=0, + CM_PIC=2 +} riscv_code_model; + +typedef struct PDS_DEFAULT_LV_CFG_Type.conflict1 PDS_DEFAULT_LV_CFG_Type.conflict1, *PPDS_DEFAULT_LV_CFG_Type.conflict1; + +typedef struct PDS_CTL_Type.conflict3 PDS_CTL_Type.conflict3, *PPDS_CTL_Type.conflict3; + +typedef struct PDS_CTL2_Type.conflict3 PDS_CTL2_Type.conflict3, *PPDS_CTL2_Type.conflict3; + +typedef struct PDS_CTL3_Type.conflict3 PDS_CTL3_Type.conflict3, *PPDS_CTL3_Type.conflict3; + +typedef struct PDS_CTL4_Type.conflict3 PDS_CTL4_Type.conflict3, *PPDS_CTL4_Type.conflict3; + +struct PDS_CTL4_Type.conflict3 { + uint32_t cpuPwrOff:1; + uint32_t cpuRst:1; + uint32_t cpuMemStby:1; + uint32_t cpuGateClk:1; + uint32_t rsv4_11:8; + uint32_t WbPwrOff:1; + uint32_t WbRst:1; + uint32_t WbMemStby:1; + uint32_t WbGateClk:1; + uint32_t rsv16_23:8; + uint32_t MiscPwrOff:1; + uint32_t MiscRst:1; + uint32_t MiscMemStby:1; + uint32_t MiscGateClk:1; + uint32_t rsv28_31:4; +}; + +struct PDS_CTL_Type.conflict3 { + uint32_t pdsStart:1; + uint32_t sleepForever:1; + uint32_t xtalForceOff:1; + uint32_t saveWiFiState:1; + uint32_t dcdc18Off:1; + uint32_t bgSysOff:1; + uint32_t rsv6_7:2; + uint32_t clkOff:1; + uint32_t memStby:1; + uint32_t rsv10:1; + uint32_t isolation:1; + uint32_t waitXtalRdy:1; + uint32_t pdsPwrOff:1; + uint32_t xtalOff:1; + uint32_t socEnbForceOn:1; + uint32_t pdsRstSocEn:1; + uint32_t pdsRC32mOn:1; + uint32_t pdsLdoVselEn:1; + uint32_t rsv19_20:2; + uint32_t wfiMask:1; + uint32_t ldo11Off:1; + uint32_t rsv23:1; + uint32_t pdsLdoVol:4; + uint32_t pdsCtlRfSel:2; + uint32_t pdsCtlPllSel:2; +}; + +struct PDS_CTL3_Type.conflict3 { + uint32_t rsv0:1; + uint32_t forceMiscPwrOff:1; + uint32_t rsv2_3:2; + uint32_t forceMiscIsoEn:1; + uint32_t rsv5_6:2; + uint32_t forceMiscPdsRst:1; + uint32_t rsv8_9:2; + uint32_t forceMiscMemStby:1; + uint32_t rsv11_12:2; + uint32_t forceMiscGateClk:1; + uint32_t rsv14_23:10; + uint32_t CpuIsoEn:1; + uint32_t rsv25_26:2; + uint32_t WbIsoEn:1; + uint32_t rsv28_29:2; + uint32_t MiscIsoEn:1; + uint32_t rsv31:1; +}; + +struct PDS_CTL2_Type.conflict3 { + uint32_t forceCpuPwrOff:1; + uint32_t rsv1:1; + uint32_t forceWbPwrOff:1; + uint32_t rsv3:1; + uint32_t forceCpuIsoPwrOff:1; + uint32_t rsv5:1; + uint32_t forceWbIsoPwrOff:1; + uint32_t rsv7:1; + uint32_t forceCpuPdsRst:1; + uint32_t rsv9:1; + uint32_t forceWbPdsRst:1; + uint32_t rsv11:1; + uint32_t forceCpuMemStby:1; + uint32_t rsv13:1; + uint32_t forceWbMemStby:1; + uint32_t rsv15:1; + uint32_t forceCpuGateClk:1; + uint32_t rsv17:1; + uint32_t forceWbGateClk:1; + uint32_t rsv19_31:12; +}; + +struct PDS_DEFAULT_LV_CFG_Type.conflict1 { + struct PDS_CTL_Type.conflict3 pdsCtl; + struct PDS_CTL2_Type.conflict3 pdsCtl2; + struct PDS_CTL3_Type.conflict3 pdsCtl3; + struct PDS_CTL4_Type.conflict3 pdsCtl4; +}; + +typedef struct PDS_CTL2_Type.conflict PDS_CTL2_Type.conflict, *PPDS_CTL2_Type.conflict; + +struct PDS_CTL2_Type.conflict { + uint32_t forceCpuPwrOff:1; + uint32_t rsv1:1; + uint32_t forceWbPwrOff:1; + uint32_t rsv3:1; + uint32_t forceCpuIsoPwrOff:1; + uint32_t rsv5:1; + uint32_t forceWbIsoPwrOff:1; + uint32_t rsv7:1; + uint32_t forceCpuPdsRst:1; + uint32_t rsv9:1; + uint32_t forceWbPdsRst:1; + uint32_t rsv11:1; + uint32_t forceCpuMemStby:1; + uint32_t rsv13:1; + uint32_t forceWbMemStby:1; + uint32_t rsv15:1; + uint32_t forceCpuGateClk:1; + uint32_t rsv17:1; + uint32_t forceWbGateClk:1; + uint32_t rsv19_31:12; +}; + +typedef struct PDS_CTL3_Type.conflict4 PDS_CTL3_Type.conflict4, *PPDS_CTL3_Type.conflict4; + +struct PDS_CTL3_Type.conflict4 { + uint32_t rsv0:1; + uint32_t forceMiscPwrOff:1; + uint32_t rsv2_3:2; + uint32_t forceMiscIsoEn:1; + uint32_t rsv5_6:2; + uint32_t forceMiscPdsRst:1; + uint32_t rsv8_9:2; + uint32_t forceMiscMemStby:1; + uint32_t rsv11_12:2; + uint32_t forceMiscGateClk:1; + uint32_t rsv14_23:10; + uint32_t CpuIsoEn:1; + uint32_t rsv25_26:2; + uint32_t WbIsoEn:1; + uint32_t rsv28_29:2; + uint32_t MiscIsoEn:1; + uint32_t rsv31:1; +}; + +typedef struct PDS_RAM_CFG_Type.conflict1 PDS_RAM_CFG_Type.conflict1, *PPDS_RAM_CFG_Type.conflict1; + +struct PDS_RAM_CFG_Type.conflict1 { + uint32_t PDS_RAM_CFG_0KB_16KB_CPU_RAM_RET:1; + uint32_t PDS_RAM_CFG_16KB_32KB_CPU_RAM_RET:1; + uint32_t PDS_RAM_CFG_32KB_48KB_CPU_RAM_RET:1; + uint32_t PDS_RAM_CFG_48KB_64KB_CPU_RAM_RET:1; + uint32_t PDS_RAM_CFG_0KB_16KB_CPU_RAM_SLP:1; + uint32_t PDS_RAM_CFG_16KB_32KB_CPU_RAM_SLP:1; + uint32_t PDS_RAM_CFG_32KB_48KB_CPU_RAM_SLP:1; + uint32_t PDS_RAM_CFG_48KB_64KB_CPU_RAM_SLP:1; + uint32_t PDS_RAM_CFG_RSV:24; +}; + +typedef struct PDS_CTL4_Type PDS_CTL4_Type, *PPDS_CTL4_Type; + +struct PDS_CTL4_Type { + uint32_t cpuPwrOff:1; + uint32_t cpuRst:1; + uint32_t cpuMemStby:1; + uint32_t cpuGateClk:1; + uint32_t rsv4_11:8; + uint32_t WbPwrOff:1; + uint32_t WbRst:1; + uint32_t WbMemStby:1; + uint32_t WbGateClk:1; + uint32_t rsv16_23:8; + uint32_t MiscPwrOff:1; + uint32_t MiscRst:1; + uint32_t MiscMemStby:1; + uint32_t MiscGateClk:1; + uint32_t rsv28_31:4; +}; + +typedef struct PDS_CTL3_Type.conflict1 PDS_CTL3_Type.conflict1, *PPDS_CTL3_Type.conflict1; + +struct PDS_CTL3_Type.conflict1 { + uint32_t rsv0:1; + uint32_t forceMiscPwrOff:1; + uint32_t rsv2_3:2; + uint32_t forceMiscIsoEn:1; + uint32_t rsv5_6:2; + uint32_t forceMiscPdsRst:1; + uint32_t rsv8_9:2; + uint32_t forceMiscMemStby:1; + uint32_t rsv11_12:2; + uint32_t forceMiscGateClk:1; + uint32_t rsv14_23:10; + uint32_t CpuIsoEn:1; + uint32_t rsv25_26:2; + uint32_t WbIsoEn:1; + uint32_t rsv28_29:2; + uint32_t MiscIsoEn:1; + uint32_t rsv31:1; +}; + +typedef struct PDS_CTL3_Type.conflict2 PDS_CTL3_Type.conflict2, *PPDS_CTL3_Type.conflict2; + +struct PDS_CTL3_Type.conflict2 { + uint32_t rsv0:1; + uint32_t forceMiscPwrOff:1; + uint32_t rsv2_3:2; + uint32_t forceMiscIsoEn:1; + uint32_t rsv5_6:2; + uint32_t forceMiscPdsRst:1; + uint32_t rsv8_9:2; + uint32_t forceMiscMemStby:1; + uint32_t rsv11_12:2; + uint32_t forceMiscGateClk:1; + uint32_t rsv14_23:10; + uint32_t CpuIsoEn:1; + uint32_t rsv25_26:2; + uint32_t WbIsoEn:1; + uint32_t rsv28_29:2; + uint32_t MiscIsoEn:1; + uint32_t rsv31:1; +}; + +typedef struct PDS_RAM_CFG_Type.conflict PDS_RAM_CFG_Type.conflict, *PPDS_RAM_CFG_Type.conflict; + +struct PDS_RAM_CFG_Type.conflict { + uint32_t PDS_RAM_CFG_0KB_16KB_CPU_RAM_RET:1; + uint32_t PDS_RAM_CFG_16KB_32KB_CPU_RAM_RET:1; + uint32_t PDS_RAM_CFG_32KB_48KB_CPU_RAM_RET:1; + uint32_t PDS_RAM_CFG_48KB_64KB_CPU_RAM_RET:1; + uint32_t PDS_RAM_CFG_0KB_16KB_CPU_RAM_SLP:1; + uint32_t PDS_RAM_CFG_16KB_32KB_CPU_RAM_SLP:1; + uint32_t PDS_RAM_CFG_32KB_48KB_CPU_RAM_SLP:1; + uint32_t PDS_RAM_CFG_48KB_64KB_CPU_RAM_SLP:1; + uint32_t PDS_RAM_CFG_RSV:24; +}; + +typedef struct PDS_DEFAULT_LV_CFG_Type PDS_DEFAULT_LV_CFG_Type, *PPDS_DEFAULT_LV_CFG_Type; + +typedef struct PDS_CTL_Type.conflict1 PDS_CTL_Type.conflict1, *PPDS_CTL_Type.conflict1; + +typedef struct PDS_CTL2_Type.conflict1 PDS_CTL2_Type.conflict1, *PPDS_CTL2_Type.conflict1; + +typedef struct PDS_CTL4_Type.conflict1 PDS_CTL4_Type.conflict1, *PPDS_CTL4_Type.conflict1; + +struct PDS_CTL2_Type.conflict1 { + uint32_t forceCpuPwrOff:1; + uint32_t rsv1:1; + uint32_t forceWbPwrOff:1; + uint32_t rsv3:1; + uint32_t forceCpuIsoPwrOff:1; + uint32_t rsv5:1; + uint32_t forceWbIsoPwrOff:1; + uint32_t rsv7:1; + uint32_t forceCpuPdsRst:1; + uint32_t rsv9:1; + uint32_t forceWbPdsRst:1; + uint32_t rsv11:1; + uint32_t forceCpuMemStby:1; + uint32_t rsv13:1; + uint32_t forceWbMemStby:1; + uint32_t rsv15:1; + uint32_t forceCpuGateClk:1; + uint32_t rsv17:1; + uint32_t forceWbGateClk:1; + uint32_t rsv19_31:12; +}; + +struct PDS_CTL4_Type.conflict1 { + uint32_t cpuPwrOff:1; + uint32_t cpuRst:1; + uint32_t cpuMemStby:1; + uint32_t cpuGateClk:1; + uint32_t rsv4_11:8; + uint32_t WbPwrOff:1; + uint32_t WbRst:1; + uint32_t WbMemStby:1; + uint32_t WbGateClk:1; + uint32_t rsv16_23:8; + uint32_t MiscPwrOff:1; + uint32_t MiscRst:1; + uint32_t MiscMemStby:1; + uint32_t MiscGateClk:1; + uint32_t rsv28_31:4; +}; + +struct PDS_CTL_Type.conflict1 { + uint32_t pdsStart:1; + uint32_t sleepForever:1; + uint32_t xtalForceOff:1; + uint32_t saveWiFiState:1; + uint32_t dcdc18Off:1; + uint32_t bgSysOff:1; + uint32_t rsv6_7:2; + uint32_t clkOff:1; + uint32_t memStby:1; + uint32_t rsv10:1; + uint32_t isolation:1; + uint32_t waitXtalRdy:1; + uint32_t pdsPwrOff:1; + uint32_t xtalOff:1; + uint32_t socEnbForceOn:1; + uint32_t pdsRstSocEn:1; + uint32_t pdsRC32mOn:1; + uint32_t pdsLdoVselEn:1; + uint32_t rsv19_20:2; + uint32_t wfiMask:1; + uint32_t ldo11Off:1; + uint32_t rsv23:1; + uint32_t pdsLdoVol:4; + uint32_t pdsCtlRfSel:2; + uint32_t pdsCtlPllSel:2; +}; + +struct PDS_DEFAULT_LV_CFG_Type { + struct PDS_CTL_Type.conflict1 pdsCtl; + struct PDS_CTL2_Type.conflict1 pdsCtl2; + struct PDS_CTL3_Type.conflict1 pdsCtl3; + struct PDS_CTL4_Type.conflict1 pdsCtl4; +}; + +typedef struct PDS_RAM_CFG_Type PDS_RAM_CFG_Type, *PPDS_RAM_CFG_Type; + +struct PDS_RAM_CFG_Type { + uint32_t PDS_RAM_CFG_0KB_16KB_CPU_RAM_RET:1; + uint32_t PDS_RAM_CFG_16KB_32KB_CPU_RAM_RET:1; + uint32_t PDS_RAM_CFG_32KB_48KB_CPU_RAM_RET:1; + uint32_t PDS_RAM_CFG_48KB_64KB_CPU_RAM_RET:1; + uint32_t PDS_RAM_CFG_0KB_16KB_CPU_RAM_SLP:1; + uint32_t PDS_RAM_CFG_16KB_32KB_CPU_RAM_SLP:1; + uint32_t PDS_RAM_CFG_32KB_48KB_CPU_RAM_SLP:1; + uint32_t PDS_RAM_CFG_48KB_64KB_CPU_RAM_SLP:1; + uint32_t PDS_RAM_CFG_RSV:24; +}; + +typedef struct PDS_CTL4_Type.conflict2 PDS_CTL4_Type.conflict2, *PPDS_CTL4_Type.conflict2; + +struct PDS_CTL4_Type.conflict2 { + uint32_t cpuPwrOff:1; + uint32_t cpuRst:1; + uint32_t cpuMemStby:1; + uint32_t cpuGateClk:1; + uint32_t rsv4_11:8; + uint32_t WbPwrOff:1; + uint32_t WbRst:1; + uint32_t WbMemStby:1; + uint32_t WbGateClk:1; + uint32_t rsv16_23:8; + uint32_t MiscPwrOff:1; + uint32_t MiscRst:1; + uint32_t MiscMemStby:1; + uint32_t MiscGateClk:1; + uint32_t rsv28_31:4; +}; + +typedef struct PDS_CTL2_Type PDS_CTL2_Type, *PPDS_CTL2_Type; + +struct PDS_CTL2_Type { + uint32_t forceCpuPwrOff:1; + uint32_t rsv1:1; + uint32_t forceWbPwrOff:1; + uint32_t rsv3:1; + uint32_t forceCpuIsoPwrOff:1; + uint32_t rsv5:1; + uint32_t forceWbIsoPwrOff:1; + uint32_t rsv7:1; + uint32_t forceCpuPdsRst:1; + uint32_t rsv9:1; + uint32_t forceWbPdsRst:1; + uint32_t rsv11:1; + uint32_t forceCpuMemStby:1; + uint32_t rsv13:1; + uint32_t forceWbMemStby:1; + uint32_t rsv15:1; + uint32_t forceCpuGateClk:1; + uint32_t rsv17:1; + uint32_t forceWbGateClk:1; + uint32_t rsv19_31:12; +}; + +typedef enum PDS_PLL_CLK_Type { + PDS_PLL_CLK_120M=4, + PDS_PLL_CLK_160M=3, + PDS_PLL_CLK_192M=2, + PDS_PLL_CLK_240M=1, + PDS_PLL_CLK_32M=8, + PDS_PLL_CLK_480M=0, + PDS_PLL_CLK_48M=7, + PDS_PLL_CLK_80M=6, + PDS_PLL_CLK_96M=5 +} PDS_PLL_CLK_Type; + +typedef struct PDS_CTL4_Type.conflict PDS_CTL4_Type.conflict, *PPDS_CTL4_Type.conflict; + +struct PDS_CTL4_Type.conflict { + uint32_t cpuPwrOff:1; + uint32_t cpuRst:1; + uint32_t cpuMemStby:1; + uint32_t cpuGateClk:1; + uint32_t rsv4_11:8; + uint32_t WbPwrOff:1; + uint32_t WbRst:1; + uint32_t WbMemStby:1; + uint32_t WbGateClk:1; + uint32_t rsv16_23:8; + uint32_t MiscPwrOff:1; + uint32_t MiscRst:1; + uint32_t MiscMemStby:1; + uint32_t MiscGateClk:1; + uint32_t rsv28_31:4; +}; + +typedef struct PDS_CTL3_Type.conflict PDS_CTL3_Type.conflict, *PPDS_CTL3_Type.conflict; + +struct PDS_CTL3_Type.conflict { + uint32_t rsv0:1; + uint32_t forceMiscPwrOff:1; + uint32_t rsv2_3:2; + uint32_t forceMiscIsoEn:1; + uint32_t rsv5_6:2; + uint32_t forceMiscPdsRst:1; + uint32_t rsv8_9:2; + uint32_t forceMiscMemStby:1; + uint32_t rsv11_12:2; + uint32_t forceMiscGateClk:1; + uint32_t rsv14_23:10; + uint32_t CpuIsoEn:1; + uint32_t rsv25_26:2; + uint32_t WbIsoEn:1; + uint32_t rsv28_29:2; + uint32_t MiscIsoEn:1; + uint32_t rsv31:1; +}; + +typedef struct PDS_CTL3_Type PDS_CTL3_Type, *PPDS_CTL3_Type; + +struct PDS_CTL3_Type { + uint32_t rsv0:1; + uint32_t forceMiscPwrOff:1; + uint32_t rsv2_3:2; + uint32_t forceMiscIsoEn:1; + uint32_t rsv5_6:2; + uint32_t forceMiscPdsRst:1; + uint32_t rsv8_9:2; + uint32_t forceMiscMemStby:1; + uint32_t rsv11_12:2; + uint32_t forceMiscGateClk:1; + uint32_t rsv14_23:10; + uint32_t CpuIsoEn:1; + uint32_t rsv25_26:2; + uint32_t WbIsoEn:1; + uint32_t rsv28_29:2; + uint32_t MiscIsoEn:1; + uint32_t rsv31:1; +}; + +typedef struct PDS_CTL2_Type.conflict4 PDS_CTL2_Type.conflict4, *PPDS_CTL2_Type.conflict4; + +struct PDS_CTL2_Type.conflict4 { + uint32_t forceCpuPwrOff:1; + uint32_t rsv1:1; + uint32_t forceWbPwrOff:1; + uint32_t rsv3:1; + uint32_t forceCpuIsoPwrOff:1; + uint32_t rsv5:1; + uint32_t forceWbIsoPwrOff:1; + uint32_t rsv7:1; + uint32_t forceCpuPdsRst:1; + uint32_t rsv9:1; + uint32_t forceWbPdsRst:1; + uint32_t rsv11:1; + uint32_t forceCpuMemStby:1; + uint32_t rsv13:1; + uint32_t forceWbMemStby:1; + uint32_t rsv15:1; + uint32_t forceCpuGateClk:1; + uint32_t rsv17:1; + uint32_t forceWbGateClk:1; + uint32_t rsv19_31:12; +}; + +typedef struct PDS_CTL2_Type.conflict2 PDS_CTL2_Type.conflict2, *PPDS_CTL2_Type.conflict2; + +struct PDS_CTL2_Type.conflict2 { + uint32_t forceCpuPwrOff:1; + uint32_t rsv1:1; + uint32_t forceWbPwrOff:1; + uint32_t rsv3:1; + uint32_t forceCpuIsoPwrOff:1; + uint32_t rsv5:1; + uint32_t forceWbIsoPwrOff:1; + uint32_t rsv7:1; + uint32_t forceCpuPdsRst:1; + uint32_t rsv9:1; + uint32_t forceWbPdsRst:1; + uint32_t rsv11:1; + uint32_t forceCpuMemStby:1; + uint32_t rsv13:1; + uint32_t forceWbMemStby:1; + uint32_t rsv15:1; + uint32_t forceCpuGateClk:1; + uint32_t rsv17:1; + uint32_t forceWbGateClk:1; + uint32_t rsv19_31:12; +}; + +typedef struct PDS_CTL_Type.conflict PDS_CTL_Type.conflict, *PPDS_CTL_Type.conflict; + +struct PDS_CTL_Type.conflict { + uint32_t pdsStart:1; + uint32_t sleepForever:1; + uint32_t xtalForceOff:1; + uint32_t saveWiFiState:1; + uint32_t dcdc18Off:1; + uint32_t bgSysOff:1; + uint32_t rsv6_7:2; + uint32_t clkOff:1; + uint32_t memStby:1; + uint32_t rsv10:1; + uint32_t isolation:1; + uint32_t waitXtalRdy:1; + uint32_t pdsPwrOff:1; + uint32_t xtalOff:1; + uint32_t socEnbForceOn:1; + uint32_t pdsRstSocEn:1; + uint32_t pdsRC32mOn:1; + uint32_t pdsLdoVselEn:1; + uint32_t rsv19_20:2; + uint32_t wfiMask:1; + uint32_t ldo11Off:1; + uint32_t rsv23:1; + uint32_t pdsLdoVol:4; + uint32_t pdsCtlRfSel:2; + uint32_t pdsCtlPllSel:2; +}; + +typedef struct PDS_CTL_Type.conflict2 PDS_CTL_Type.conflict2, *PPDS_CTL_Type.conflict2; + +struct PDS_CTL_Type.conflict2 { + uint32_t pdsStart:1; + uint32_t sleepForever:1; + uint32_t xtalForceOff:1; + uint32_t saveWiFiState:1; + uint32_t dcdc18Off:1; + uint32_t bgSysOff:1; + uint32_t rsv6_7:2; + uint32_t clkOff:1; + uint32_t memStby:1; + uint32_t rsv10:1; + uint32_t isolation:1; + uint32_t waitXtalRdy:1; + uint32_t pdsPwrOff:1; + uint32_t xtalOff:1; + uint32_t socEnbForceOn:1; + uint32_t pdsRstSocEn:1; + uint32_t pdsRC32mOn:1; + uint32_t pdsLdoVselEn:1; + uint32_t rsv19_20:2; + uint32_t wfiMask:1; + uint32_t ldo11Off:1; + uint32_t rsv23:1; + uint32_t pdsLdoVol:4; + uint32_t pdsCtlRfSel:2; + uint32_t pdsCtlPllSel:2; +}; + +typedef enum PDS_PLL_XTAL_Type { + PDS_PLL_XTAL_24M=1, + PDS_PLL_XTAL_26M=5, + PDS_PLL_XTAL_32M=2, + PDS_PLL_XTAL_38P4M=3, + PDS_PLL_XTAL_40M=4, + PDS_PLL_XTAL_NONE=0, + PDS_PLL_XTAL_RC32M=6 +} PDS_PLL_XTAL_Type; + +typedef struct PDS_DEFAULT_LV_CFG_Type.conflict PDS_DEFAULT_LV_CFG_Type.conflict, *PPDS_DEFAULT_LV_CFG_Type.conflict; + +struct PDS_DEFAULT_LV_CFG_Type.conflict { + struct PDS_CTL_Type.conflict2 pdsCtl; + struct PDS_CTL2_Type.conflict2 pdsCtl2; + struct PDS_CTL3_Type.conflict2 pdsCtl3; + struct PDS_CTL4_Type.conflict2 pdsCtl4; +}; + +typedef struct PDS_CTL_Type PDS_CTL_Type, *PPDS_CTL_Type; + +struct PDS_CTL_Type { + uint32_t pdsStart:1; + uint32_t sleepForever:1; + uint32_t xtalForceOff:1; + uint32_t saveWiFiState:1; + uint32_t dcdc18Off:1; + uint32_t bgSysOff:1; + uint32_t rsv6_7:2; + uint32_t clkOff:1; + uint32_t memStby:1; + uint32_t rsv10:1; + uint32_t isolation:1; + uint32_t waitXtalRdy:1; + uint32_t pdsPwrOff:1; + uint32_t xtalOff:1; + uint32_t socEnbForceOn:1; + uint32_t pdsRstSocEn:1; + uint32_t pdsRC32mOn:1; + uint32_t pdsLdoVselEn:1; + uint32_t rsv19_20:2; + uint32_t wfiMask:1; + uint32_t ldo11Off:1; + uint32_t rsv23:1; + uint32_t pdsLdoVol:4; + uint32_t pdsCtlRfSel:2; + uint32_t pdsCtlPllSel:2; +}; + +typedef enum anon_enum_16 { + HAL_AC0_TIMER_BIT=1, + HAL_AC1_TIMER_BIT=2, + HAL_AC2_TIMER_BIT=4, + HAL_AC3_TIMER_BIT=8, + HAL_BCN_TIMER_BIT=16, + HAL_IDLE_TIMER_BIT=32, + HAL_KE_TIMER_BIT=256, + HAL_MM_TIMER_BIT=-128, + HAL_RX_TIMER_BIT=64, + LLD_EXT_ADV_STOP_IND=513, + LLD_STOP_IND=512, + ME_CHAN_CONFIG_CFM=5123, + ME_CHAN_CONFIG_REQ=5122, + ME_CONFIG_CFM=5121, + ME_CONFIG_REQ=5120, + ME_MAX=5137, + ME_RC_SET_RATE_REQ=5136, + ME_RC_STATS_CFM=5135, + ME_RC_STATS_REQ=5134, + ME_SET_ACTIVE_CFM=5138, + ME_SET_ACTIVE_REQ=5137, + ME_SET_CONTROL_PORT_CFM=5125, + ME_SET_CONTROL_PORT_REQ=5124, + ME_SET_PS_DISABLE_CFM=5140, + ME_SET_PS_DISABLE_REQ=5139, + ME_STA_ADD_CFM=5128, + ME_STA_ADD_REQ=5127, + ME_STA_DEL_CFM=5130, + ME_STA_DEL_REQ=5129, + ME_TKIP_MIC_FAILURE_IND=5126, + ME_TRAFFIC_IND_CFM=5133, + ME_TRAFFIC_IND_REQ=5132, + ME_TX_CREDITS_UPDATE_IND=5131, + PBUF_POOL=386, + PBUF_RAM=640, + PBUF_REF=65, + PBUF_ROM=1, + ROM_API_INDEX_AON_Get_Xtal_CapCode=8, + ROM_API_INDEX_AON_LowPower_Enter_PDS0=18, + ROM_API_INDEX_AON_LowPower_Exit_PDS0=19, + ROM_API_INDEX_AON_Power_Off_BG=11, + ROM_API_INDEX_AON_Power_Off_LDO11_SOC=13, + ROM_API_INDEX_AON_Power_Off_LDO15_RF=15, + ROM_API_INDEX_AON_Power_Off_MBG=5, + ROM_API_INDEX_AON_Power_Off_SFReg=17, + ROM_API_INDEX_AON_Power_Off_XTAL=9, + ROM_API_INDEX_AON_Power_On_BG=10, + ROM_API_INDEX_AON_Power_On_LDO11_SOC=12, + ROM_API_INDEX_AON_Power_On_LDO15_RF=14, + ROM_API_INDEX_AON_Power_On_MBG=4, + ROM_API_INDEX_AON_Power_On_SFReg=16, + ROM_API_INDEX_AON_Power_On_XTAL=6, + ROM_API_INDEX_AON_Set_Xtal_CapCode=7, + ROM_API_INDEX_ASM_Delay_Us=20, + ROM_API_INDEX_BFLB_Soft_CRC32=-81, + ROM_API_INDEX_BL602_Delay_MS=22, + ROM_API_INDEX_BL602_Delay_US=21, + ROM_API_INDEX_BL602_MemCmp=28, + ROM_API_INDEX_BL602_MemCpy=23, + ROM_API_INDEX_BL602_MemCpy4=24, + ROM_API_INDEX_BL602_MemCpy_Fast=25, + ROM_API_INDEX_BL602_MemSet=26, + ROM_API_INDEX_BL602_MemSet4=27, + ROM_API_INDEX_EF_Ctrl_AutoLoad_Done=33, + ROM_API_INDEX_EF_Ctrl_Busy=32, + ROM_API_INDEX_EF_Ctrl_Clear=37, + ROM_API_INDEX_EF_Ctrl_Get_Trim_Parity=34, + ROM_API_INDEX_EF_Ctrl_Load_Efuse_R0=31, + ROM_API_INDEX_EF_Ctrl_Program_Efuse_0=30, + ROM_API_INDEX_EF_Ctrl_Read_RC32K_Trim=36, + ROM_API_INDEX_EF_Ctrl_Read_RC32M_Trim=35, + ROM_API_INDEX_EF_Ctrl_Sw_AHB_Clk_0=29, + ROM_API_INDEX_FUNC_EMPTY_END=511, + ROM_API_INDEX_FUNC_EMPTY_START=-80, + ROM_API_INDEX_GLB_Deswap_Flash_Pin=52, + ROM_API_INDEX_GLB_GPIO_Get_Fun=58, + ROM_API_INDEX_GLB_GPIO_Init=54, + ROM_API_INDEX_GLB_GPIO_OUTPUT_Disable=56, + ROM_API_INDEX_GLB_GPIO_OUTPUT_Enable=55, + ROM_API_INDEX_GLB_GPIO_Set_HZ=57, + ROM_API_INDEX_GLB_Get_BCLK_Div=40, + ROM_API_INDEX_GLB_Get_HCLK_Div=41, + ROM_API_INDEX_GLB_Get_Root_CLK_Sel=38, + ROM_API_INDEX_GLB_SW_CPU_Reset=48, + ROM_API_INDEX_GLB_SW_POR_Reset=49, + ROM_API_INDEX_GLB_SW_System_Reset=47, + ROM_API_INDEX_GLB_Select_External_Flash=51, + ROM_API_INDEX_GLB_Select_Internal_Flash=50, + ROM_API_INDEX_GLB_Set_PKA_CLK_Sel=46, + ROM_API_INDEX_GLB_Set_SF_CLK=45, + ROM_API_INDEX_GLB_Set_System_CLK=43, + ROM_API_INDEX_GLB_Set_System_CLK_Div=39, + ROM_API_INDEX_GLB_Swap_Flash_Pin=53, + ROM_API_INDEX_HBN_32K_Sel=66, + ROM_API_INDEX_HBN_Enable=61, + ROM_API_INDEX_HBN_GPIO7_Dbg_Pull_Cfg=75, + ROM_API_INDEX_HBN_Hw_Pu_Pd_Cfg=73, + ROM_API_INDEX_HBN_Mode_Enter=59, + ROM_API_INDEX_HBN_Pin_WakeUp_Mask=74, + ROM_API_INDEX_HBN_Power_Down_Flash=60, + ROM_API_INDEX_HBN_Power_Off_RC32K=71, + ROM_API_INDEX_HBN_Power_Off_Xtal_32K=69, + ROM_API_INDEX_HBN_Power_On_RC32K=70, + ROM_API_INDEX_HBN_Power_On_Xtal_32K=68, + ROM_API_INDEX_HBN_Reset=62, + ROM_API_INDEX_HBN_Set_Embedded_Flash_Pullup=76, + ROM_API_INDEX_HBN_Set_Ldo11_Aon_Vout=63, + ROM_API_INDEX_HBN_Set_Ldo11_Rt_Vout=64, + ROM_API_INDEX_HBN_Set_Ldo11_Soc_Vout=65, + ROM_API_INDEX_HBN_Set_ROOT_CLK_Sel=67, + ROM_API_INDEX_HBN_Trim_RC32K=72, + ROM_API_INDEX_L1C_IROM_2T_Access_Set=79, + ROM_API_INDEX_L1C_Set_Way_Disable=78, + ROM_API_INDEX_L1C_Set_Wrap=77, + ROM_API_INDEX_PDS_Default_Level_Config=84, + ROM_API_INDEX_PDS_Disable_PLL_All_Clks=90, + ROM_API_INDEX_PDS_Disable_PLL_Clk=92, + ROM_API_INDEX_PDS_Enable=81, + ROM_API_INDEX_PDS_Enable_PLL_All_Clks=89, + ROM_API_INDEX_PDS_Enable_PLL_Clk=91, + ROM_API_INDEX_PDS_Force_Config=82, + ROM_API_INDEX_PDS_Power_Off_PLL=93, + ROM_API_INDEX_PDS_Power_On_PLL=88, + ROM_API_INDEX_PDS_RAM_Config=83, + ROM_API_INDEX_PDS_Reset=80, + ROM_API_INDEX_PDS_Select_RC32M_As_PLL_Ref=86, + ROM_API_INDEX_PDS_Select_XTAL_As_PLL_Ref=87, + ROM_API_INDEX_PDS_Trim_RC32M=85, + ROM_API_INDEX_RSVD_0=1, + ROM_API_INDEX_RSVD_1=2, + ROM_API_INDEX_RSVD_LAST=3, + ROM_API_INDEX_SEC_Eng_Turn_Off_Sec_Ring=95, + ROM_API_INDEX_SEC_Eng_Turn_On_Sec_Ring=94, + ROM_API_INDEX_SF_Cfg_Deinit_Ext_Flash_Gpio=-123, + ROM_API_INDEX_SF_Cfg_Flash_Identify=-119, + ROM_API_INDEX_SF_Cfg_Get_Flash_Cfg_Need_Lock=-121, + ROM_API_INDEX_SF_Cfg_Init_Ext_Flash_Gpio=-125, + ROM_API_INDEX_SF_Cfg_Init_Flash_Gpio=-120, + ROM_API_INDEX_SF_Cfg_Init_Internal_Flash_Gpio=-124, + ROM_API_INDEX_SF_Cfg_Restore_GPIO17_Fun=-122, + ROM_API_INDEX_SF_Ctrl_AES_Disable=-106, + ROM_API_INDEX_SF_Ctrl_AES_Enable=-107, + ROM_API_INDEX_SF_Ctrl_AES_Enable_BE=-114, + ROM_API_INDEX_SF_Ctrl_AES_Enable_LE=-113, + ROM_API_INDEX_SF_Ctrl_AES_Set_IV=-109, + ROM_API_INDEX_SF_Ctrl_AES_Set_IV_BE=-108, + ROM_API_INDEX_SF_Ctrl_AES_Set_Key=-111, + ROM_API_INDEX_SF_Ctrl_AES_Set_Key_BE=-110, + ROM_API_INDEX_SF_Ctrl_AES_Set_Region=-112, + ROM_API_INDEX_SF_Ctrl_Disable=-115, + ROM_API_INDEX_SF_Ctrl_Enable=-118, + ROM_API_INDEX_SF_Ctrl_GetBusyState=-99, + ROM_API_INDEX_SF_Ctrl_Get_Clock_Delay=-97, + ROM_API_INDEX_SF_Ctrl_Get_Flash_Image_Offset=-104, + ROM_API_INDEX_SF_Ctrl_Icache2_Set=-100, + ROM_API_INDEX_SF_Ctrl_Icache_Set=-101, + ROM_API_INDEX_SF_Ctrl_Is_AES_Enable=-98, + ROM_API_INDEX_SF_Ctrl_Select_Clock=-103, + ROM_API_INDEX_SF_Ctrl_Select_Pad=-117, + ROM_API_INDEX_SF_Ctrl_SendCmd=-102, + ROM_API_INDEX_SF_Ctrl_Set_Clock_Delay=-96, + ROM_API_INDEX_SF_Ctrl_Set_Flash_Image_Offset=-105, + ROM_API_INDEX_SF_Ctrl_Set_Owner=-116, + ROM_API_INDEX_SFlash_Blk32_Erase=106, + ROM_API_INDEX_SFlash_Blk64_Erase=107, + ROM_API_INDEX_SFlash_Busy=100, + ROM_API_INDEX_SFlash_Cache_Enable_Set=121, + ROM_API_INDEX_SFlash_Cache_Flush=122, + ROM_API_INDEX_SFlash_Cache_Hit_Count_Get=124, + ROM_API_INDEX_SFlash_Cache_Miss_Count_Get=125, + ROM_API_INDEX_SFlash_Cache_Read_Disable=126, + ROM_API_INDEX_SFlash_Cache_Read_Enable=123, + ROM_API_INDEX_SFlash_Chip_Erase=104, + ROM_API_INDEX_SFlash_DisableBurstWrap=116, + ROM_API_INDEX_SFlash_Erase=108, + ROM_API_INDEX_SFlash_GetDeviceId=112, + ROM_API_INDEX_SFlash_GetJedecId=111, + ROM_API_INDEX_SFlash_GetUniqueId=110, + ROM_API_INDEX_SFlash_IDbus_Read_Enable=120, + ROM_API_INDEX_SFlash_Init=96, + ROM_API_INDEX_SFlash_Powerdown=113, + ROM_API_INDEX_SFlash_Program=109, + ROM_API_INDEX_SFlash_Qspi_Enable=102, + ROM_API_INDEX_SFlash_Read=127, + ROM_API_INDEX_SFlash_Read_Reg=98, + ROM_API_INDEX_SFlash_Read_Reg_With_Cmd=-128, + ROM_API_INDEX_SFlash_Releae_Powerdown=114, + ROM_API_INDEX_SFlash_Reset_Continue_Read=118, + ROM_API_INDEX_SFlash_Restore_From_Powerdown=-126, + ROM_API_INDEX_SFlash_Sector_Erase=105, + ROM_API_INDEX_SFlash_SetBurstWrap=115, + ROM_API_INDEX_SFlash_SetSPIMode=97, + ROM_API_INDEX_SFlash_Set_IDbus_Cfg=119, + ROM_API_INDEX_SFlash_Software_Reset=117, + ROM_API_INDEX_SFlash_Volatile_Reg_Write_Enable=103, + ROM_API_INDEX_SFlash_Write_Enable=101, + ROM_API_INDEX_SFlash_Write_Reg=99, + ROM_API_INDEX_SFlash_Write_Reg_With_Cmd=-127, + ROM_API_INDEX_System_Core_Clock_Update_From_RC32M=44, + ROM_API_INDEX_Update_SystemCoreClockWith_XTAL=42, + ROM_API_INDEX_VERSION=0, + ROM_API_INDEX_XIP_SFlash_Erase_Need_Lock=-93, + ROM_API_INDEX_XIP_SFlash_Erase_With_Lock=-84, + ROM_API_INDEX_XIP_SFlash_GetDeviceId_Need_Lock=-89, + ROM_API_INDEX_XIP_SFlash_GetJedecId_Need_Lock=-90, + ROM_API_INDEX_XIP_SFlash_GetUniqueId_Need_Lock=-88, + ROM_API_INDEX_XIP_SFlash_Opt_Enter=-83, + ROM_API_INDEX_XIP_SFlash_Opt_Exit=-82, + ROM_API_INDEX_XIP_SFlash_Read_Need_Lock=-91, + ROM_API_INDEX_XIP_SFlash_Read_Via_Cache_Need_Lock=-87, + ROM_API_INDEX_XIP_SFlash_Read_With_Lock=-86, + ROM_API_INDEX_XIP_SFlash_State_Restore=-94, + ROM_API_INDEX_XIP_SFlash_State_Save=-95, + ROM_API_INDEX_XIP_SFlash_Write_Need_Lock=-92, + ROM_API_INDEX_XIP_SFlash_Write_With_Lock=-85, + SCANU_JOIN_CFM=4099, + SCANU_JOIN_REQ=4098, + SCANU_MAX=4103, + SCANU_RAW_SEND_CFM=4102, + SCANU_RAW_SEND_REQ=4101, + SCANU_RESULT_IND=4100, + SCANU_START_CFM=4097, + SCANU_START_REQ=4096 +} anon_enum_16; + +typedef uintptr_t insn_t; + +typedef struct llm_pdu_adv llm_pdu_adv, *Pllm_pdu_adv; + +struct llm_pdu_adv { + struct bd_addr adva; + undefined field_0x6; + undefined field_0x7; + uint8_t * adva_data; +}; + +typedef struct scanning_pdu_params scanning_pdu_params, *Pscanning_pdu_params; + +struct scanning_pdu_params { + struct em_buf_node * conn_req_desc_node; + uint16_t interval; + uint16_t window; + uint8_t filterpolicy; + uint8_t type; + uint8_t filter_duplicate; + uint8_t own_addr_type; +}; + +typedef struct llm_le_env_tag llm_le_env_tag, *Pllm_le_env_tag; + +typedef struct advertising_pdu_params advertising_pdu_params, *Padvertising_pdu_params; + +typedef struct data_len_ext data_len_ext, *Pdata_len_ext; + +typedef struct channel_map_assess channel_map_assess, *Pchannel_map_assess; + +typedef struct access_addr_gen access_addr_gen, *Paccess_addr_gen; + +typedef struct llm_test_mode llm_test_mode, *Pllm_test_mode; + +typedef struct t_public_key256 t_public_key256, *Pt_public_key256; + +typedef enum t_key_multiplication_type { + LLM_DHKEY_GENERATION=2, + LLM_ECC_IDLE=0, + LLM_PUBLIC_KEY_GENERATION=1 +} t_key_multiplication_type; + +typedef enum t_key_multiplication_type t_key_multi_type; + +struct t_public_key256 { + uint8_t x[32]; + uint8_t y[32]; +}; + +struct llm_test_mode { + _Bool end_of_tst; + uint8_t directtesttype; +}; + +struct channel_map_assess { + uint16_t assess_timer; + int8_t lower_limit; + int8_t upper_limit; + int8_t rssi_noise_limit; + uint8_t reassess_count; + struct le_chnl_map ch_map; + _Bool llm_le_set_host_ch_class_cmd_sto; +}; + +struct data_len_ext { + uint16_t conn_initial_max_tx_octets; + uint16_t conn_initial_max_tx_time; + uint16_t suppted_max_tx_octets; + uint16_t suppted_max_tx_time; + uint16_t suppted_max_rx_octets; + uint16_t suppted_max_rx_time; +}; + +struct access_addr_gen { + uint8_t intrand; + uint8_t ct1_idx; + uint8_t ct2_idx; +}; + +struct llm_le_env_tag { + struct co_list enc_req; + struct co_list adv_list; + struct scanning_pdu_params * scanning_params; + struct advertising_pdu_params * advertising_params; + struct co_list cnx_list; + struct data_len_ext data_len_val; + struct channel_map_assess ch_map_assess; + struct evt_mask eventmask; + struct access_addr_gen aa; + undefined field_0x43; + uint16_t conhdl_alloc; + undefined field_0x46; + undefined field_0x47; + struct ea_elt_tag * elt; + _Bool last_opcode; + undefined field_0x4d; + uint16_t opcode2; + uint8_t state2; + undefined field_0x51; + undefined field_0x52; + undefined field_0x53; + struct ea_elt_tag * elt_coext_scan; + _Bool enc_pend; + struct llm_test_mode test_mode; + struct bd_addr rand_add; + struct bd_addr public_add; + undefined field_0x67; + uint16_t enh_priv_rpa_timeout; + uint16_t p256_byte_process_timeout; + uint16_t opcode; + uint8_t state; + uint8_t enh_priv_info; + uint8_t curr_addr_type; + uint8_t nb_dev_in_wl; + uint8_t nb_dev_in_hw_wl; + struct t_public_key256 public_key256; + uint8_t secret_key256[32]; + t_key_multi_type cur_ecc_multiplication; +}; + +struct advertising_pdu_params { + struct ke_msg * adv_data_req; + struct ke_msg * scan_rsp_req; + struct em_buf_node * adv_desc_node; + struct em_buf_node * scan_rsp_desc_node; + struct bd_addr peer_addr; + uint16_t intervalmin; + uint16_t intervalmax; + uint8_t channelmap; + uint8_t filterpolicy; + uint8_t type; + uint8_t datalen; + uint8_t scanrsplen; + uint8_t own_addr_type; + uint8_t peer_addr_type; + _Bool adv_ldc_flag; + undefined field_0x22; + undefined field_0x23; +}; + +typedef struct llm_pdu_con_req_tx llm_pdu_con_req_tx, *Pllm_pdu_con_req_tx; + +struct llm_pdu_con_req_tx { + struct access_addr aa; + struct crc_init crcinit; + uint8_t winsize; + uint16_t winoffset; + uint16_t interval; + uint16_t latency; + uint16_t timeout; + struct le_chnl_map chm; + uint8_t hop_sca; +}; + +typedef struct adv_device_list adv_device_list, *Padv_device_list; + +struct adv_device_list { + struct co_list_hdr hdr; + uint8_t adv_type; + struct bd_addr adv_addr; + undefined field_0xb; +}; + +typedef enum llm_enh_priv { + LLM_PRIV_ENABLE_LSB=0, + LLM_PRIV_ENABLE_MASK=1, + LLM_PRIV_RFU_LSB=2, + LLM_PRIV_RFU_MASK=-116, + LLM_RPA_RENEW_TIMER_EN_LSB=1, + LLM_RPA_RENEW_TIMER_EN_MASK=2 +} llm_enh_priv; + +typedef struct llm_pdu_con_req_rx llm_pdu_con_req_rx, *Pllm_pdu_con_req_rx; + +struct llm_pdu_con_req_rx { + struct bd_addr inita; + struct bd_addr adva; + struct access_addr aa; + struct crc_init crcinit; + uint8_t winsize; + uint16_t winoffset; + uint16_t interval; + uint16_t latency; + uint16_t timeout; + struct le_chnl_map chm; + uint8_t hop_sca; +}; + +typedef struct bl_mtd_info_t bl_mtd_info_t, *Pbl_mtd_info_t; + +struct bl_mtd_info_t { + char name[16]; + uint offset; + uint size; + void * xip_addr; +}; + +typedef void * bl_mtd_handle_t; + +typedef struct key_MgtMaterial_t key_MgtMaterial_t, *Pkey_MgtMaterial_t; + +typedef union anon_union_for_keyEncypt anon_union_for_keyEncypt, *Panon_union_for_keyEncypt; + +typedef struct key_Type_TKIP_t key_Type_TKIP_t, *Pkey_Type_TKIP_t; + +typedef struct key_Type_AES_t key_Type_AES_t, *Pkey_Type_AES_t; + +typedef struct key_Type_WEP_t key_Type_WEP_t, *Pkey_Type_WEP_t; + +typedef struct key_Type_WAPI_t key_Type_WAPI_t, *Pkey_Type_WAPI_t; + +typedef struct key_Type_AES_CMAC_t key_Type_AES_CMAC_t, *Pkey_Type_AES_CMAC_t; + +struct key_Type_WEP_t { + UINT8 keyIndex; + UINT8 isDefaultTx; + UINT8 key[13]; +}; + +struct key_Type_WAPI_t { + UINT8 keyIndex; + UINT8 isDefKey; + UINT8 key[16]; + UINT8 mickey[16]; + UINT8 rxPN[16]; +}; + +struct key_Type_TKIP_t { + UINT8 key[16]; + UINT8 txMicKey[8]; + UINT8 rxMicKey[8]; +}; + +struct key_Type_AES_CMAC_t { + UINT8 ipn[6]; + UINT8 reserved[2]; + UINT8 key[16]; +}; + +struct key_Type_AES_t { + UINT8 key[16]; +}; + +union anon_union_for_keyEncypt { + struct key_Type_TKIP_t TKIP; + struct key_Type_AES_t AES1; + struct key_Type_WEP_t WEP; + struct key_Type_WAPI_t WAPI; + struct key_Type_AES_CMAC_t iGTK; +}; + +struct key_MgtMaterial_t { + UINT16 keyType; + UINT16 keyInfo; + UINT16 keyLen; + union anon_union_for_keyEncypt keyEncypt; +}; + +typedef uint hashval_t; + +typedef struct notifier_block notifier_block, *Pnotifier_block; + +struct notifier_block { + int (* cb)(struct notifier_block *, int, void *); + struct notifier_block * next; + int priority; +}; + +typedef struct rd_env_tag rd_env_tag, *Prd_env_tag; + +struct rd_env_tag { + struct co_list event_free_list; +}; + +typedef enum GLB_DIG_CLK_Type { + GLB_DIG_CLK_PLL_32M=0, + GLB_DIG_CLK_XCLK=1 +} GLB_DIG_CLK_Type; + +typedef enum BMX_BUS_ERR_Type { + BMX_BUS_ERR_ADDR_DECODE=1, + BMX_BUS_ERR_TRUSTZONE_DECODE=0 +} BMX_BUS_ERR_Type; + +typedef enum GLB_SPI_PAD_ACT_AS_Type { + GLB_SPI_PAD_ACT_AS_MASTER=1, + GLB_SPI_PAD_ACT_AS_SLAVE=0 +} GLB_SPI_PAD_ACT_AS_Type; + +typedef enum GLB_EM_Type { + GLB_EM_0KB=0, + GLB_EM_16KB=15, + GLB_EM_8KB=3 +} GLB_EM_Type; + +typedef enum BMX_ERR_INT_Type { + BMX_ERR_INT_ALL=1, + BMX_ERR_INT_ERR=0 +} BMX_ERR_INT_Type; + +typedef struct BMX_Cfg_Type BMX_Cfg_Type, *PBMX_Cfg_Type; + +typedef enum BMX_ARB_Type { + BMX_ARB_FIX=0, + BMX_ARB_RANDOM=2, + BMX_ARB_ROUND_ROBIN=1 +} BMX_ARB_Type; + +struct BMX_Cfg_Type { + uint8_t timeoutEn; + enum BL_Fun_Type errEn; + enum BMX_ARB_Type arbMod; +}; + +typedef enum GLB_PLL_XTAL_Type { + GLB_PLL_XTAL_24M=1, + GLB_PLL_XTAL_26M=5, + GLB_PLL_XTAL_32M=2, + GLB_PLL_XTAL_38P4M=3, + GLB_PLL_XTAL_40M=4, + GLB_PLL_XTAL_NONE=0, + GLB_PLL_XTAL_RC32M=6 +} GLB_PLL_XTAL_Type; + +typedef enum GLB_SYS_CLK_Type { + GLB_SYS_CLK_PLL120M=3, + GLB_SYS_CLK_PLL160M=4, + GLB_SYS_CLK_PLL192M=5, + GLB_SYS_CLK_PLL48M=2, + GLB_SYS_CLK_RC32M=0, + GLB_SYS_CLK_XTAL=1 +} GLB_SYS_CLK_Type; + +typedef enum GLB_BT_BANDWIDTH_Type { + GLB_BT_BANDWIDTH_1M=0, + GLB_BT_BANDWIDTH_2M=1 +} GLB_BT_BANDWIDTH_Type; + +typedef enum GLB_GPIO_INT_TRIG_Type { + GLB_GPIO_INT_TRIG_NEG_LEVEL=2, + GLB_GPIO_INT_TRIG_NEG_PULSE=0, + GLB_GPIO_INT_TRIG_POS_LEVEL=3, + GLB_GPIO_INT_TRIG_POS_PULSE=1 +} GLB_GPIO_INT_TRIG_Type; + +typedef enum GLB_DMA_CLK_ID_Type { + GLB_DMA_CLK_DMA0_CH0=0, + GLB_DMA_CLK_DMA0_CH1=1, + GLB_DMA_CLK_DMA0_CH2=2, + GLB_DMA_CLK_DMA0_CH3=3 +} GLB_DMA_CLK_ID_Type; + +typedef enum GLB_UART_SIG_FUN_Type { + GLB_UART_SIG_FUN_UART0_CTS=1, + GLB_UART_SIG_FUN_UART0_RTS=0, + GLB_UART_SIG_FUN_UART0_RXD=3, + GLB_UART_SIG_FUN_UART0_TXD=2, + GLB_UART_SIG_FUN_UART1_CTS=5, + GLB_UART_SIG_FUN_UART1_RTS=4, + GLB_UART_SIG_FUN_UART1_RXD=7, + GLB_UART_SIG_FUN_UART1_TXD=6 +} GLB_UART_SIG_FUN_Type; + +typedef enum GLB_PLL_CLK_Type { + GLB_PLL_CLK_120M=4, + GLB_PLL_CLK_160M=3, + GLB_PLL_CLK_192M=2, + GLB_PLL_CLK_240M=1, + GLB_PLL_CLK_32M=8, + GLB_PLL_CLK_480M=0, + GLB_PLL_CLK_48M=7, + GLB_PLL_CLK_80M=6, + GLB_PLL_CLK_96M=5 +} GLB_PLL_CLK_Type; + +typedef enum GLB_ROOT_CLK_Type { + GLB_ROOT_CLK_PLL=2, + GLB_ROOT_CLK_RC32M=0, + GLB_ROOT_CLK_XTAL=1 +} GLB_ROOT_CLK_Type; + +typedef enum GLB_SFLASH_CLK_Type { + GLB_SFLASH_CLK_120M=0, + GLB_SFLASH_CLK_48M=2, + GLB_SFLASH_CLK_80M=3, + GLB_SFLASH_CLK_96M=5, + GLB_SFLASH_CLK_BCLK=4, + GLB_SFLASH_CLK_XTAL=1 +} GLB_SFLASH_CLK_Type; + +typedef enum BMX_TO_INT_Type { + BMX_TO_INT_ALL=1, + BMX_TO_INT_TIMEOUT=0 +} BMX_TO_INT_Type; + +typedef enum GLB_DAC_CLK_Type { + GLB_DAC_CLK_32M=0, + GLB_DAC_CLK_XCLK=1 +} GLB_DAC_CLK_Type; + +typedef enum GLB_IR_CLK_SRC_Type { + GLB_IR_CLK_SRC_XCLK=0 +} GLB_IR_CLK_SRC_Type; + +typedef enum GLB_ADC_CLK_Type { + GLB_ADC_CLK_96M=0, + GLB_ADC_CLK_XCLK=1 +} GLB_ADC_CLK_Type; + +typedef enum GLB_GPIO_INT_CONTROL_Type { + GLB_GPIO_INT_CONTROL_ASYNC=1, + GLB_GPIO_INT_CONTROL_SYNC=0 +} GLB_GPIO_INT_CONTROL_Type; + +typedef enum GLB_MTIMER_CLK_Type { + GLB_MTIMER_CLK_32K=1, + GLB_MTIMER_CLK_BCLK=0 +} GLB_MTIMER_CLK_Type; + +typedef enum GLB_GPIO_REAL_MODE_Type { + GLB_GPIO_REAL_MODE_CCI=15, + GLB_GPIO_REAL_MODE_JTAG=14, + GLB_GPIO_REAL_MODE_REG=0, + GLB_GPIO_REAL_MODE_RF=12, + GLB_GPIO_REAL_MODE_SDIO=1 +} GLB_GPIO_REAL_MODE_Type; + +typedef enum GLB_PKA_CLK_Type { + GLB_PKA_CLK_HCLK=0, + GLB_PKA_CLK_PLL120M=1 +} GLB_PKA_CLK_Type; + +typedef enum GLB_UART_SIG_Type { + GLB_UART_SIG_0=0, + GLB_UART_SIG_1=1, + GLB_UART_SIG_2=2, + GLB_UART_SIG_3=3, + GLB_UART_SIG_4=4, + GLB_UART_SIG_5=5, + GLB_UART_SIG_6=6, + GLB_UART_SIG_7=7 +} GLB_UART_SIG_Type; + +typedef struct phy_env_tag phy_env_tag, *Pphy_env_tag; + +typedef struct phy_bl602_cfg_tag phy_bl602_cfg_tag, *Pphy_bl602_cfg_tag; + +struct phy_bl602_cfg_tag { + uint32_t reserved; +}; + +struct phy_env_tag { + struct phy_bl602_cfg_tag cfg; + uint16_t chnl_prim20_freq; + uint16_t chnl_center1_freq; + uint16_t chnl_center2_freq; + uint8_t band; + uint8_t chnl_type; +}; + +typedef struct lld_evt_env_tag lld_evt_env_tag, *Plld_evt_env_tag; + +struct lld_evt_env_tag { + struct co_list elt_prog; + struct co_list elt_wait; + struct co_list elt_deferred; + struct co_list rx_pkt_deferred; + struct co_list elt_to_be_deleted; + uint8_t sca; + _Bool renew; + uint8_t hw_wa_sleep_compensation; + undefined field_0x2b; +}; + +typedef struct lld_evt_wait_tag lld_evt_wait_tag, *Plld_evt_wait_tag; + +struct lld_evt_wait_tag { + struct co_list_hdr hdr; + struct ea_elt_tag * elt_ptr; +}; + +typedef struct lld_conn lld_conn, *Plld_conn; + +struct lld_conn { + uint32_t sync_win_size; + uint32_t sca_drift; + uint16_t instant; + uint16_t latency; + uint16_t counter; + uint16_t missed_cnt; + uint16_t duration_dft; + uint16_t update_offset; + uint16_t eff_max_tx_time; + uint16_t eff_max_tx_size; + uint8_t update_size; + uint8_t instant_action; + uint8_t mst_sca; + uint8_t last_md_rx; + uint8_t tx_prog_pkt_cnt; + _Bool wait_con_up_sync; + undefined field_0x1e; + undefined field_0x1f; +}; + +typedef struct lld_evt_delete_tag lld_evt_delete_tag, *Plld_evt_delete_tag; + +struct lld_evt_delete_tag { + struct co_list_hdr hdr; + struct ea_elt_tag * elt_ptr; + _Bool flush; + _Bool send_ind; + undefined field_0xa; + undefined field_0xb; +}; + +typedef struct lld_evt_anchor lld_evt_anchor, *Plld_evt_anchor; + +struct lld_evt_anchor { + uint32_t basetime_cnt; + uint16_t finetime_cnt; + uint16_t evt_cnt; +}; + +typedef enum lld_evt_flag { + LLD_EVT_FLAG_APFM=64, + LLD_EVT_FLAG_LATENCY_ACTIVE=-128, + LLD_EVT_FLAG_NO_RESTART=32, + LLD_EVT_FLAG_WAITING_ACK=1, + LLD_EVT_FLAG_WAITING_EOEVT_TO_DELETE=16, + LLD_EVT_FLAG_WAITING_INSTANT=8, + LLD_EVT_FLAG_WAITING_SYNC=2, + LLD_EVT_FLAG_WAITING_TXPROG=4 +} lld_evt_flag; + +typedef struct lld_evt_deferred_tag lld_evt_deferred_tag, *Plld_evt_deferred_tag; + +struct lld_evt_deferred_tag { + struct co_list_hdr hdr; + struct ea_elt_tag * elt_ptr; + uint8_t type; + uint8_t rx_desc_cnt; + undefined field_0xa; + undefined field_0xb; +}; + +typedef enum lld_evt_mode { + LLD_EVT_ADV_MODE=0, + LLD_EVT_EXT_ADV_MODE=5, + LLD_EVT_EXT_SCAN_MODE=7, + LLD_EVT_MODE_MAX=8, + LLD_EVT_MST_MODE=3, + LLD_EVT_PER_ADV_MODE=6, + LLD_EVT_SCAN_MODE=1, + LLD_EVT_SLV_MODE=4, + LLD_EVT_TEST_MODE=2 +} lld_evt_mode; + +typedef struct lld_evt_tag lld_evt_tag, *Plld_evt_tag; + +typedef union lld_evt_info lld_evt_info, *Plld_evt_info; + +typedef struct lld_non_conn lld_non_conn, *Plld_non_conn; + +struct lld_non_conn { + uint32_t window; + uint32_t anchor; + uint32_t end_ts; + _Bool initiate; + _Bool connect_req_sent; + undefined field_0xe; + undefined field_0xf; +}; + +union lld_evt_info { + struct lld_non_conn non_conn; + struct lld_conn conn; +}; + +struct lld_evt_tag { + struct lld_evt_anchor anchor_point; + struct co_list tx_acl_rdy; + struct co_list tx_acl_tofree; + struct co_list tx_llcp_pdu_rdy; + struct co_list tx_prog; + struct ea_interval_tag * interval_elt; + union lld_evt_info evt; + uint16_t conhdl; + uint16_t cs_ptr; + uint16_t interval; + uint8_t rx_cnt; + uint8_t mode; + uint8_t tx_pwr; + uint8_t default_prio; + uint8_t evt_flag; + _Bool delete_ongoing; +}; + +typedef enum lld_evt_cs_format { + LLD_ACTIVE_SCANNING=9, + LLD_HD_ADVERTISER=5, + LLD_INITIATING=15, + LLD_LD_ADVERTISER=4, + LLD_MASTER_CONNECTED=2, + LLD_PASSIVE_SCANNING=8, + LLD_RXTEST_MODE=29, + LLD_SLAVE_CONNECTED=3, + LLD_TXRXTEST_MODE=30, + LLD_TXTEST_MODE=28 +} lld_evt_cs_format; + +typedef struct lld_evt_update_tag lld_evt_update_tag, *Plld_evt_update_tag; + +struct lld_evt_update_tag { + uint16_t win_offset; + uint16_t instant; + uint8_t win_size; + undefined field_0x5; +}; + +typedef struct sys_timeo sys_timeo, *Psys_timeo; + +struct sys_timeo { + struct sys_timeo * next; + u32_t time; + void (* h)(void *); + void * arg; +}; + +typedef struct lwip_cyclic_timer lwip_cyclic_timer, *Plwip_cyclic_timer; + +typedef void (* lwip_cyclic_timer_handler)(void); + +struct lwip_cyclic_timer { + u32_t interval_ms; + lwip_cyclic_timer_handler handler; +}; + +typedef struct lwip_cyclic_timer.conflict2 lwip_cyclic_timer.conflict2, *Plwip_cyclic_timer.conflict2; + +struct lwip_cyclic_timer.conflict2 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict6 lwip_cyclic_timer.conflict6, *Plwip_cyclic_timer.conflict6; + +struct lwip_cyclic_timer.conflict6 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict7 lwip_cyclic_timer.conflict7, *Plwip_cyclic_timer.conflict7; + +struct lwip_cyclic_timer.conflict7 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict1 lwip_cyclic_timer.conflict1, *Plwip_cyclic_timer.conflict1; + +struct lwip_cyclic_timer.conflict1 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict5 lwip_cyclic_timer.conflict5, *Plwip_cyclic_timer.conflict5; + +struct lwip_cyclic_timer.conflict5 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef struct lwip_cyclic_timer.conflict4 lwip_cyclic_timer.conflict4, *Plwip_cyclic_timer.conflict4; + +struct lwip_cyclic_timer.conflict4 { + u32_t interval_ms; + void (* handler)(void); +}; + +typedef enum raw_input_state { + RAW_INPUT_DELIVERED=2, + RAW_INPUT_EATEN=1, + RAW_INPUT_NONE=0 +} raw_input_state; + +typedef enum raw_input_state raw_input_state_t; + +typedef enum memp_t { + MEMP_ALTCP_PCB=5, + MEMP_IGMP_GROUP=10, + MEMP_MAX=15, + MEMP_NETBUF=6, + MEMP_NETCONN=7, + MEMP_NETDB=12, + MEMP_PBUF=13, + MEMP_PBUF_POOL=14, + MEMP_RAW_PCB=0, + MEMP_SYS_TIMEOUT=11, + MEMP_TCPIP_MSG_API=8, + MEMP_TCPIP_MSG_INPKT=9, + MEMP_TCP_PCB=2, + MEMP_TCP_PCB_LISTEN=3, + MEMP_TCP_SEG=4, + MEMP_UDP_PCB=1 +} memp_t; + +typedef struct bl_mtd_handle_priv bl_mtd_handle_priv, *Pbl_mtd_handle_priv; + +struct bl_mtd_handle_priv { + char name[16]; + int id; + uint offset; + uint size; + void * xip_addr; +}; + +typedef struct bl_mtd_handle_priv * bl_mtd_handle_priv_t; + +typedef enum LOG_BUF_OUT_DATA_TYPE { + LOG_BUF_OUT_DATA_TYPE_HEX=0, + LOG_BUF_OUT_DATA_TYPE_INT8=1, + LOG_BUF_OUT_DATA_TYPE_UNT8=2 +} LOG_BUF_OUT_DATA_TYPE; + +typedef enum LOG_BUF_OUT_DATA_TYPE LOG_BUF_OUT_DATA_TYPE_T; + +typedef int __gcc_CMPtype; + +typedef struct k_thread k_thread, *Pk_thread; + +typedef uint32_t _task_t; + +struct k_thread { + _task_t task; +}; + +typedef struct k_mutex k_mutex, *Pk_mutex; + +typedef struct bl_hdl_t _mutex_t; + +struct k_mutex { + _mutex_t mutex; + sys_dlist_t poll_events; +}; + +typedef struct k_timer.conflict11 k_timer.conflict11, *Pk_timer.conflict11; + +struct k_timer.conflict11 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +typedef struct k_timer.conflict10 k_timer.conflict10, *Pk_timer.conflict10; + +struct k_timer.conflict10 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +typedef struct k_timer.conflict k_timer.conflict, *Pk_timer.conflict; + +struct k_timer.conflict { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +typedef struct k_timer.conflict1 k_timer.conflict1, *Pk_timer.conflict1; + +typedef struct k_timer.conflict1 k_timer_t.conflict; + +struct k_timer.conflict1 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +typedef void (* k_thread_entry_t)(void *); + +typedef struct k_timer.conflict2 k_timer.conflict2, *Pk_timer.conflict2; + +typedef struct k_timer.conflict2 k_timer_t.conflict1; + +struct k_timer.conflict2 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +typedef struct k_timer.conflict11 k_timer_t.conflict8; + +typedef struct k_timer.conflict4 k_timer.conflict4, *Pk_timer.conflict4; + +typedef struct k_timer.conflict4 k_timer_t.conflict2; + +struct k_timer.conflict4 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +typedef struct k_timer.conflict3 k_timer.conflict3, *Pk_timer.conflict3; + +struct k_timer.conflict3 { + bl_timer_t timer; + k_timer_handler_t.conflict handler; + void * args; + uint32_t timeout; + uint32_t start_ms; +}; + +typedef enum LLC_MSG { + LLC_AUTH_PAYL_NEARLY_TO=259, + LLC_AUTH_PAYL_REAL_TO=260, + LLC_CHMAP_UPDATE_REQ_IND=264, + LLC_CHNL_ASSESS_TO=261, + LLC_CON_UPD_REQ_IND=265, + LLC_DATA_IND=256, + LLC_ENC_MGT_IND=262, + LLC_LENGTH_REQ_IND=263, + LLC_LE_LINK_SUP_TO=257, + LLC_LLCP_RECV_IND=266, + LLC_LLCP_RSP_TO=258 +} LLC_MSG; + +typedef struct llc_create_con_req_ind llc_create_con_req_ind, *Pllc_create_con_req_ind; + +struct llc_create_con_req_ind { + uint16_t con_int; + uint16_t con_lat; + uint16_t sup_to; + uint16_t ral_ptr; + struct bd_addr peer_addr; + uint8_t peer_addr_type; + uint8_t hop_inc; + uint8_t sleep_clk_acc; + uint8_t filter_policy; +}; + +typedef struct llc_data_ind llc_data_ind, *Pllc_data_ind; + +struct llc_data_ind { + uint16_t conhdl; + uint8_t pb_bc_flag; + undefined field_0x3; + uint16_t length; + uint8_t rx_hdl; + undefined field_0x7; +}; + +typedef enum llc_loc_proc_state { + LLC_LOC_IDLE=0, + LLC_LOC_SEND_START_ENC_RSP=17, + LLC_LOC_WAIT_CON_PARAM_RSP=7, + LLC_LOC_WAIT_CON_UPD_INSTANT=9, + LLC_LOC_WAIT_CON_UPD_REQ=8, + LLC_LOC_WAIT_ENC_RSP=13, + LLC_LOC_WAIT_FEAT_RSP=1, + LLC_LOC_WAIT_LENGTH_RSP=4, + LLC_LOC_WAIT_MAP_UPD_INSTANT=6, + LLC_LOC_WAIT_PAUSE_ENC_RSP=11, + LLC_LOC_WAIT_PAUSE_ENC_RSP_SENT=12, + LLC_LOC_WAIT_PING_RSP=5, + LLC_LOC_WAIT_RANDN_GEN_IND=19, + LLC_LOC_WAIT_SK=15, + LLC_LOC_WAIT_SK_AND_START_ENC_REQ=14, + LLC_LOC_WAIT_START_ENC_REQ=16, + LLC_LOC_WAIT_START_ENC_RSP=18, + LLC_LOC_WAIT_TERM_ACK=3, + LLC_LOC_WAIT_TRAFFIC_PAUSED=10, + LLC_LOC_WAIT_VERS_IND=2 +} llc_loc_proc_state; + +typedef struct llc_con_upd_req_ind llc_con_upd_req_ind, *Pllc_con_upd_req_ind; + +struct llc_con_upd_req_ind { + uint8_t operation; + undefined field_0x1; + uint16_t con_intv_min; + uint16_t con_intv_max; + uint16_t con_latency; + uint16_t superv_to; + uint16_t ce_len_min; + uint16_t ce_len_max; + uint16_t interval_min; + uint16_t interval_max; + uint8_t pref_period; + undefined field_0x13; + uint16_t ref_con_event_count; + uint16_t offset0; + uint16_t offset1; + uint16_t offset2; + uint16_t offset3; + uint16_t offset4; + uint16_t offset5; +}; + +typedef enum llc_op_type { + LLC_OP_DLE_UPD=3, + LLC_OP_ENCRYPT=2, + LLC_OP_LOC_PARAM_UPD=0, + LLC_OP_MAX=4, + LLC_OP_REM_PARAM_UPD=1 +} llc_op_type; + +typedef enum llc_con_up_op { + LLC_CON_UP_FORCE=2, + LLC_CON_UP_HCI_REQ=0, + LLC_CON_UP_LOC_REQ=4, + LLC_CON_UP_MOVE_ANCHOR=1, + LLC_CON_UP_PEER_REQ=3 +} llc_con_up_op; + +typedef struct llc_llcp_recv_ind llc_llcp_recv_ind, *Pllc_llcp_recv_ind; + +struct llc_llcp_recv_ind { + uint8_t status; + uint8_t dummy; + union llcp_pdu pdu; +}; + +typedef enum llc_rem_proc_state { + LLC_REM_IDLE=0, + LLC_REM_WAIT_CON_PARAM_HOST_RSP=2, + LLC_REM_WAIT_CON_UPD_INSTANT=4, + LLC_REM_WAIT_CON_UPD_REQ=3, + LLC_REM_WAIT_ENC_REJECT_ACK=13, + LLC_REM_WAIT_ENC_REQ=7, + LLC_REM_WAIT_LTK=9, + LLC_REM_WAIT_MAP_UPD_INSTANT=1, + LLC_REM_WAIT_PAUSE_ENC_RSP=6, + LLC_REM_WAIT_RANDN_GEN_IND=14, + LLC_REM_WAIT_SK=10, + LLC_REM_WAIT_START_ENC_RSP=11, + LLC_REM_WAIT_START_ENC_RSP_ACK=12, + LLC_REM_WAIT_TP_FOR_ENC_REQ=8, + LLC_REM_WAIT_TP_FOR_PAUSE_ENC_REQ=5 +} llc_rem_proc_state; + +typedef enum llc_state_id { + LLC_CONNECTED=0, + LLC_DISC_BUSY=15, + LLC_FREE=127, + LLC_LOC_PROC_BUSY=1, + LLC_REM_PROC_BUSY=2, + LLC_STATE_MAX=-128, + LLC_TRAFFIC_PAUSED_BUSY=4 +} llc_state_id; + +typedef enum llc_proc_field { + LLC_DISC=3, + LLC_LOC_PROC=0, + LLC_REM_PROC=1, + LLC_TRAFFIC_PAUSED=2 +} llc_proc_field; + +typedef struct bt_conn.conflict2 bt_conn.conflict2, *Pbt_conn.conflict2; + +struct bt_conn.conflict2 { + u16_t handle; + u8_t type; + u8_t role; + atomic_t flags[1]; + u8_t id; + enum bt_security_t sec_level; + enum bt_security_t required_sec_level; + u8_t encrypt; + u8_t err; + enum bt_conn_state_t state; + u16_t rx_len; + struct net_buf * rx; + sys_slist_t tx_pending; + u32_t.conflict pending_no_cb; + sys_slist_t tx_complete; + struct k_work tx_complete_work; + struct k_fifo tx_queue; + sys_slist_t channels; + atomic_t ref; + struct k_delayed_work.conflict6 update_work; + union anon_union_for_field_20 field_20; +}; + +typedef struct bt_conn.conflict1 bt_conn.conflict1, *Pbt_conn.conflict1; + +struct bt_conn.conflict1 { + u16_t handle; + u8_t type; + u8_t role; + atomic_t flags[1]; + u8_t id; + enum bt_security_t sec_level; + enum bt_security_t required_sec_level; + u8_t encrypt; + u8_t err; + enum bt_conn_state_t state; + u16_t rx_len; + struct net_buf * rx; + sys_slist_t tx_pending; + u32_t.conflict pending_no_cb; + sys_slist_t tx_complete; + struct k_work tx_complete_work; + struct k_fifo tx_queue; + sys_slist_t channels; + atomic_t ref; + struct k_delayed_work.conflict2 update_work; + union anon_union_for_field_20 field_20; +}; + +typedef struct bt_conn.conflict bt_conn.conflict, *Pbt_conn.conflict; + +struct bt_conn.conflict { + u16_t handle; + u8_t type; + u8_t role; + atomic_t flags[1]; + u8_t id; + enum bt_security_t sec_level; + enum bt_security_t required_sec_level; + u8_t encrypt; + u8_t err; + enum bt_conn_state_t state; + u16_t rx_len; + struct net_buf * rx; + sys_slist_t tx_pending; + u32_t.conflict pending_no_cb; + sys_slist_t tx_complete; + struct k_work tx_complete_work; + struct k_fifo tx_queue; + sys_slist_t channels; + atomic_t ref; + struct k_delayed_work.conflict1 update_work; + union anon_union_for_field_20 field_20; +}; + +typedef struct lld_pdu_pack_desc.conflict5 lld_pdu_pack_desc.conflict5, *Plld_pdu_pack_desc.conflict5; + +struct lld_pdu_pack_desc.conflict5 { + uint8_t pdu_len; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + void * pack_fmt; + void (* unpack_func)(uint16_t, uint8_t, uint8_t *); +}; + +typedef struct lld_pdu_pack_desc lld_pdu_pack_desc, *Plld_pdu_pack_desc; + +struct lld_pdu_pack_desc { + uint8_t pdu_len; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + void * pack_fmt; + void (* unpack_func)(uint16_t, uint8_t, uint8_t *); +}; + +typedef enum lld_pdu_pack_status { + LLC_PDU_PACK_OK=0, + LLC_PDU_PACK_UNKNOWN=2, + LLC_PDU_PACK_WRONG_FORMAT=1 +} lld_pdu_pack_status; + +typedef struct lld_pdu_pack_desc.conflict4 lld_pdu_pack_desc.conflict4, *Plld_pdu_pack_desc.conflict4; + +struct lld_pdu_pack_desc.conflict4 { + uint8_t pdu_len; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + void * pack_fmt; + void (* unpack_func)(uint16_t, uint8_t, uint8_t *); +}; + +typedef struct lld_pdu_pack_desc.conflict2 lld_pdu_pack_desc.conflict2, *Plld_pdu_pack_desc.conflict2; + +struct lld_pdu_pack_desc.conflict2 { + uint8_t pdu_len; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + void * pack_fmt; + void (* unpack_func)(uint16_t, uint8_t, uint8_t *); +}; + +typedef struct lld_pdu_pack_desc.conflict3 lld_pdu_pack_desc.conflict3, *Plld_pdu_pack_desc.conflict3; + +struct lld_pdu_pack_desc.conflict3 { + uint8_t pdu_len; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + void * pack_fmt; + void (* unpack_func)(uint16_t, uint8_t, uint8_t *); +}; + +typedef struct lld_pdu_pack_desc.conflict1 lld_pdu_pack_desc.conflict1, *Plld_pdu_pack_desc.conflict1; + +struct lld_pdu_pack_desc.conflict1 { + uint8_t pdu_len; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + void * pack_fmt; + void (* unpack_func)(uint16_t, uint8_t, uint8_t *); +}; + +typedef struct lld_pdu_pack_desc.conflict lld_pdu_pack_desc.conflict, *Plld_pdu_pack_desc.conflict; + +struct lld_pdu_pack_desc.conflict { + uint8_t pdu_len; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + void * pack_fmt; + void (* unpack_func)(uint16_t, uint8_t, uint8_t *); +}; + +typedef struct lld_pdu_rx_info lld_pdu_rx_info, *Plld_pdu_rx_info; + +struct lld_pdu_rx_info { + struct co_list_hdr hdr; + uint8_t rx_hdl; + _Bool free; + uint16_t conhdl; + uint16_t status; + uint8_t length; + uint8_t channel; + uint8_t rssi; + uint8_t audio; + undefined field_0xe; + undefined field_0xf; +}; + +typedef uint __uintptr_t; + +typedef char __int8_t; + +typedef longlong __int64_t; + +typedef struct lld_pdu_data_tx_tag lld_pdu_data_tx_tag, *Plld_pdu_data_tx_tag; + +struct lld_pdu_data_tx_tag { + struct co_list_hdr hdr; + uint16_t idx; + uint16_t conhdl; + uint16_t length; + uint8_t pb_bc_flag; + undefined field_0xb; + struct em_buf_node * buf; +}; + +typedef struct bl_env_tag bl_env_tag, *Pbl_env_tag; + +struct bl_env_tag { + uint8_t prev_hw_state; + undefined field_0x1; + undefined field_0x2; + undefined field_0x3; + int hw_in_doze; +}; + + +// WARNING! conflicting data type names: /stddef.h/size_t - /DWARF/stddef.h/size_t + +typedef struct __locale_data __locale_data, *P__locale_data; + +struct __locale_data { +}; + +typedef struct __locale_struct __locale_struct, *P__locale_struct; + +struct __locale_struct { + struct __locale_data * __locales[13]; + ushort * __ctype_b; + int * __ctype_tolower; + int * __ctype_toupper; + char * __names[13]; +}; + + +// WARNING! conflicting data type names: /xlocale.h/__locale_t - /DWARF/_UNCATEGORIZED_/__locale_t + +typedef enum Elf_ProgramHeaderType { + PT_DYNAMIC=2, + PT_GNU_EH_FRAME=1685382480, + PT_GNU_RELRO=1685382482, + PT_GNU_STACK=1685382481, + PT_INTERP=3, + PT_LOAD=1, + PT_NOTE=4, + PT_NULL=0, + PT_PHDR=6, + PT_SHLIB=5, + PT_TLS=7 +} Elf_ProgramHeaderType; + +typedef struct Elf32_Shdr Elf32_Shdr, *PElf32_Shdr; + +typedef enum Elf_SectionHeaderType { + SHT_CHECKSUM=1879048184, + SHT_DYNAMIC=6, + SHT_DYNSYM=11, + SHT_FINI_ARRAY=15, + SHT_GNU_ATTRIBUTES=1879048181, + SHT_GNU_HASH=1879048182, + SHT_GNU_LIBLIST=1879048183, + SHT_GNU_verdef=1879048189, + SHT_GNU_verneed=1879048190, + SHT_GNU_versym=1879048191, + SHT_GROUP=17, + SHT_HASH=5, + SHT_INIT_ARRAY=14, + SHT_NOBITS=8, + SHT_NOTE=7, + SHT_NULL=0, + SHT_PREINIT_ARRAY=16, + SHT_PROGBITS=1, + SHT_REL=9, + SHT_RELA=4, + SHT_SHLIB=10, + SHT_STRTAB=3, + SHT_SUNW_COMDAT=1879048187, + SHT_SUNW_move=1879048186, + SHT_SUNW_syminfo=1879048188, + SHT_SYMTAB=2, + SHT_SYMTAB_SHNDX=18 +} Elf_SectionHeaderType; + +struct Elf32_Shdr { + dword sh_name; + enum Elf_SectionHeaderType sh_type; + dword sh_flags; + dword sh_addr; + dword sh_offset; + dword sh_size; + dword sh_link; + dword sh_info; + dword sh_addralign; + dword sh_entsize; +}; + +typedef struct Elf32_Sym Elf32_Sym, *PElf32_Sym; + +struct Elf32_Sym { + dword st_name; + dword st_value; + dword st_size; + byte st_info; + byte st_other; + word st_shndx; +}; + +typedef struct Elf32_Phdr Elf32_Phdr, *PElf32_Phdr; + +struct Elf32_Phdr { + enum Elf_ProgramHeaderType p_type; + dword p_offset; + dword p_vaddr; + dword p_paddr; + dword p_filesz; + dword p_memsz; + dword p_flags; + dword p_align; +}; + +typedef struct Elf32_Ehdr Elf32_Ehdr, *PElf32_Ehdr; + +struct Elf32_Ehdr { + byte e_ident_magic_num; + char e_ident_magic_str[3]; + byte e_ident_class; + byte e_ident_data; + byte e_ident_version; + byte e_ident_pad[9]; + word e_type; + word e_machine; + dword e_version; + dword e_entry; + dword e_phoff; + dword e_shoff; + dword e_flags; + word e_ehsize; + word e_phentsize; + word e_phnum; + word e_shentsize; + word e_shnum; + word e_shstrndx; +}; + + + + +void bl602_start(void); +void _dump_partition(void); +uint32_t hal_boot2_get_flash_addr(void); +int hal_boot2_partition_bus_addr(char *name,uint32_t *addr0,uint32_t *addr1,uint32_t *size0,uint32_t *size1,int *active); +int hal_boot2_partition_bus_addr_active(char *name,uint32_t *addr,uint32_t *size); +int hal_boot2_partition_bus_addr_inactive(char *name,uint32_t *addr,uint32_t *size); +int hal_boot2_partition_addr(char *name,uint32_t *addr0,uint32_t *addr1,uint32_t *size0,uint32_t *size1,int *active); +int hal_boot2_partition_addr_active(char *name,uint32_t *addr,uint32_t *size); +int hal_boot2_partition_addr_inactive(char *name,uint32_t *addr,uint32_t *size); +int hal_boot2_init(void); +int bl_flash_erase(uint32_t addr,int len); +int bl_flash_write(uint32_t addr,uint8_t *src,int len); +int bl_flash_read(uint32_t addr,uint8_t *dst,int len); +undefined4 bl_flash_config_update(void); +void cmd_blsync_ble_stop(char *buf,int len,int argc,char **argv); +void stack_wifi(void); +void cmd_blsync_ble_start(char *buf,int len,int argc,char **argv); +void app_delayed_action_ble(void *arg); +void app_delayed_action_wifi(void *arg); +void app_delayed_action_bleadv(void *arg); +void scan_complete_cb(void *p_arg,void *param); +void scan_item_cb(wifi_mgmr_ap_item_t *env,uint32_t *param1,wifi_mgmr_ap_item_t *item); +void wifiprov_wifi_state_get(void *p_arg); +__uint8_t char_to_hex(char asccode); +void _connect_wifi(undefined4 param_1); +void event_cb_wifi_event(input_event_t *event,void *private_data); +void event_cb_cli(input_event_t *event,void *p_arg); +void aos_loop_proc(void *pvParameters); +void vApplicationStackOverflowHook(TaskHandle_t xTask,char *pcTaskName); +void vApplicationMallocFailedHook(void); +void vApplicationIdleHook(void); +void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,StackType_t **ppxIdleTaskStackBuffer,uint32_t *pulIdleTaskStackSize); +void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer,StackType_t **ppxTimerTaskStackBuffer,uint32_t *pulTimerTaskStackSize); +void vAssertCalled(void); +void bfl_main(void); +void blesync_complete_cb(void *p_arg); +void wifiprov_api_state_get(anon_subr_void_void_ptr *state_get); +void wifiprov_wifi_scan(anon_subr_void_void_ptr *complete); +void wifiprov_disc_from_ap_ind(void); +void wifiprov_connect_ap_ind(wifi_conn *info); +void blsync_init(int err); +void blsync_ble_start(void); +void blsync_ble_stop(void); +int wifi_prov_api_event_trigger_connect(wifi_conn *info); +int wifi_prov_api_event_trigger_disconnect(void); +int wifi_prov_api_event_trigger_scan(anon_subr_void_void_ptr *complete); +int wifi_prov_api_event_state_get(anon_subr_void_void_ptr *state_get); +void bl_printk(char *format,...); +int log_buf_out(char *file,int line,void *inbuf,int len,LOG_BUF_OUT_DATA_TYPE_T type); +int vfs_init(void); +int aos_open(char *path,int flags); +int aos_close(int fd); +ssize_t aos_read(int fd,void *buf,size_t nbytes); +ssize_t aos_write(int fd,void *buf,size_t nbytes); +int aos_ioctl(int fd,int cmd,ulong arg); +int aos_stat(char *path,stat *st); +aos_dir_t * aos_opendir(char *path); +int aos_closedir(aos_dir_t *dir); +aos_dirent_t * aos_readdir(aos_dir_t *dir); +file_t * new_file(inode_t *node); +void del_file(file_t *file); +int get_fd(file_t *file); +file_t * get_file(int fd); +int inode_init(void); +int inode_alloc(void); +inode_t * inode_open(char *path); +int inode_forearch_name(anon_subr_int_void_ptr_inode_t_ptr *cb,void *arg); +void inode_ref(inode_t *node); +void inode_unref(inode_t *node); +int inode_reserve(char *path,inode_t **inode); +yloop_ctx_t * get_context(void); +void aos_loop_set_eventfd(int fd); +aos_loop_t aos_loop_init(void); +int aos_poll_read_fd(int sock,aos_poll_call_t *cb,void *private_data); +int aos_post_delayed_action(int ms,aos_call_t *action,void *param); +void aos_loop_run(yloop_sock_t *param_1); +void vfs_poll_notify(pollfd *fd,void *arg); +int aos_poll(pollfd *fds,int nfds,int timeout); +int aos_fcntl(int fd,int cmd,int val); +void dfl_entry(void *arg); +int aos_task_new(char *name,anon_subr_void_void_ptr *fn,void *arg,int stack_size); +void aos_task_exit(int code); +int aos_task_key_create(aos_task_key_t *key); +int aos_task_setspecific(aos_task_key_t key,void *vp); +void * aos_task_getspecific(aos_task_key_t key); +int aos_mutex_new(aos_mutex_t *mutex); +void aos_mutex_free(aos_mutex_t *mutex); +int aos_mutex_lock(aos_mutex_t *mutex,uint ms); +int aos_mutex_unlock(aos_mutex_t *mutex); +int aos_sem_new(aos_sem_t *sem,int count); +void aos_sem_free(aos_sem_t *sem); +int aos_sem_wait(aos_sem_t *sem,uint ms); +void aos_sem_signal(aos_sem_t *sem); +void * aos_malloc(size_t xWantedSize); +void free(void *pv); +void aos_free(void *pv); +void * malloc(size_t xWantedSize); +longlong aos_now_ms(void); +int event_poll(file_t *f,_Bool setup,poll_notify_t *notify,pollfd *fd,void *opa); +int event_open(inode_t *node,file_t *file); +ssize_t _event_write(void *buf,size_t len,_Bool urgent); +int event_ioctl(file_t *f,int cmd,ulong arg); +ssize_t event_write(file_t *f,void *buf,size_t len); +int event_close(file_t *file); +ssize_t event_read(file_t *f,void *buf,size_t len); +int vfs_device_init(void); +void event_read_cb(int fd,void *param); +int aos_event_service_init(void); +int aos_post_event(uint16_t type,uint16_t code,ulong value); +int aos_register_event_filter(uint16_t type,aos_event_cb *cb,void *priv); +size_t format_int(char *q,size_t n,uint flags,int base,int width,int prec); +char * cvt(int ndigits,int *decpt,int *sign,char *buf,int eflag); +char * ecvtbuf(int ndigits,int *decpt,int *sign,char *buf); +char * fcvtbuf(int ndigits,int *decpt,int *sign,char *buf); +char * flt(char *str,int size,int precision,char fmt,int flags); +int vsnprintf(char *buffer,size_t n,char *format,va_list ap); +int vsprintf(char *buffer,char *format,va_list ap); +void vprint(char *fmt,va_list argp); +int bl_putchar(int c); +int puts(char *s); +int printf(char *fmt,...); +int sprintf(char *buffer,char *format,...); +int snprintf(char *buffer,size_t n,char *format,...); +_Bool stateSnifferGuard(void *ch,event *event); +_Bool stateConnectedIPYesGuard_ip_update(void *ch,event *event); +void printErrMsg(void *stateData,event *event); +void stateSnifferExit(void *stateData,event *event); +void stateSnifferAction(void *oldStateData,event *event,void *newStateData); +void stateConnectedIPNoAction_ipgot(void *oldStateData,event *event,void *newStateData); +void stateGlobalEnter(void *stateData,event *event); +void stateGlobalAction(void *oldStateData,event *event,void *newStateData); +void stateConnectingEnter(void *stateData,event *event); +_Bool stateSnifferGuard_ChannelSet(void *ch,event *event); +_Bool stateIdleGuard_sniffer(void *ev,event *event); +void stateConnectedIPNoExit(void *stateData,event *event); +void stateDisconnect_action_idle(void *oldStateData,event *event,void *newStateData); +void stateDisconnect_action_reconnect(void *oldStateData,event *event,void *newStateData); +void ip_obtaining_timeout(timer_cb_arg_t data); +void stateConnectedIPNoEnter(void *stateData,event *event); +_Bool stateConnectedIPNoGuard_disconnect(void *ch,event *event); +_Bool stateConnectedIPYesGuard_disconnect(void *ch,event *event); +_Bool stateConnectedIPYesGuard_rcconfig(void *ch,event *event); +void stateIdleAction_connect(void *oldStateData,event *event,void *newStateData); +_Bool stateGlobal_cfg_req(void *ch,event *event); +_Bool stateGlobalGuard_fw_powersaving(void *ch,event *event); +_Bool stateGlobalGuard_conf_max_sta(void *ev,event *event); +_Bool stateGlobalGuard_AP(void *ev,event *event); +_Bool stateGlobalGuard_scan_beacon(void *ch,event *event); +void __reload_tsen(timer_cb_arg_t data); +void event_cb_wifi_event_mgmr(input_event_t *event,void *private_data); +void trigger_auto_denoise(void *arg); +void stateDisconnect_exit(void *stateData,event *event); +void disconnect_retry(timer_cb_arg_t data); +_Bool stateGlobalGuard_fw_disconnect(void *ch,event *event); +void stateConnectedIPYes_exit(void *stateData,event *event); +_Bool stateGlobalGuard_denoise(void *ev,event *event); +_Bool stateIdleGuard_connect(void *ev,event *event); +_Bool stateIfaceDownGuard_phyup(void *ev,event *event); +_Bool stateSnifferGuard_raw_send(void *ch,event *event); +_Bool stateGlobalGuard_stop(void *ev,event *event); +_Bool stateGlobalGuard_enable_autoreconnect(void *ch,event *event); +_Bool stateGlobalGuard_disable_autoreconnect(void *ch,event *event); +void stateDisconnect_enter(void *stateData,event *event); +_Bool stateGlobalGuard_fw_scan(void *ch,event *event); +uint stateDisconnect_guard(uint param_1,int param_2); +void stateGlobalExit(void); +void stateSnifferEnter(void); +uint stateConnectingGuard(uint param_1,int param_2); +void stateConnectingAction_connected(void); +void stateConnectingAction_disconnect(void); +void stateConnectingExit(void); +void stateIdleAction_sniffer(void); +void stateIdleEnter(void); +void stateIdleExit(void); +void stateIfaceDownAction_phyup(void); +void stateIfaceDownEnter(void); +void stateIfaceDownExit(void); +uint stateConnectedIPNoGuard(uint param_1,int param_2); +void stateConnectedIPNoAction_disconnect(void); +uint stateConnectedIPYesGuard(uint param_1,int param_2); +void stateConnectedIPYes_action(void); +void stateConnectedIPYes_enter(void *stateData,event *event); +char * wifi_mgmr_auth_to_str(uint8_t auth); +char * wifi_mgmr_cipher_to_str(uint8_t cipher); +int wifi_mgmr_event_notify(wifi_mgmr_msg_t *msg); +void wifi_mgmr_start(void); +void _wifi_mgmr_entry(void *pvParameters); +void wifi_mgmr_start_background(wifi_conf_t *conf); +int wifi_mgmr_init(void); +int wifi_mgmr_status_code_clean_internal(void); +int wifi_mgmr_state_get_internal(int *state); +void wifi_mgmr_set_connect_stat_info(wifi_event_sm_connect_ind *ind,uint8_t type_ind); +int wifi_mgmr_set_country_code_internal(char *country_code); +int wifi_mgmr_ap_sta_cnt_get_internal(uint8_t *sta_cnt); +int wifi_mgmr_ap_sta_info_get_internal(wifi_mgmr_sta_basic_info_t *sta_info_internal,uint8_t idx); +int wifi_mgmr_ap_sta_delete_internal(uint8_t sta_idx); +int wifi_mgmr_scan_complete_notify(void); +int wifi_mgmr_api_connect(char *ssid,char *psk,char *pmk,uint8_t *mac,uint8_t band,uint16_t freq); +int wifi_mgmr_api_cfg_req(uint32_t ops,uint32_t task,uint32_t element,uint32_t type,uint32_t length,uint32_t *buf); +int wifi_mgmr_api_ip_got(uint32_t ip,uint32_t mask,uint32_t gw,uint32_t dns1,uint32_t dns2); +int wifi_mgmr_api_ip_update(void); +int wifi_mgmr_api_reconnect(void); +int wifi_mgmr_api_disable_autoreconnect(void); +int wifi_mgmr_api_enable_autoreconnect(void); +int wifi_mgmr_api_disconnect(void); +int wifi_mgmr_api_rate_config(uint16_t config); +int wifi_mgmr_api_conf_max_sta(uint8_t max_sta_supported); +int wifi_mgmr_api_ifaceup(void); +int wifi_mgmr_api_sniffer_enable(void); +int wifi_mgmr_api_scan_item_beacon(uint8_t channel,int8_t rssi,uint8_t auth,uint8_t *mac,uint8_t *ssid,int len,int8_t ppm_abs,int8_t ppm_rel,uint8_t cipher); +int wifi_mgmr_api_fw_disconnect(void); +int wifi_mgmr_api_fw_tsen_reload(void); +int wifi_mgmr_api_fw_scan(void); +int wifi_mgmr_api_fw_powersaving(int mode); +int wifi_mgmr_api_ap_start(char *ssid,char *passwd,int channel,uint8_t hidden_ssid); +int wifi_mgmr_api_ap_stop(void); +int wifi_mgmr_api_idle(void); +int wifi_mgmr_api_denoise_enable(void); +int wifi_mgmr_api_denoise_disable(void); +int wifi_mgmr_api_raw_send(uint8_t *pkt,int len); +int wifi_mgmr_api_set_country_code(char *country_code); +void cmd_rf_dump(char *buf,int len,int argc,char **argv); +void cmd_dump_reset(char *buf,int len,int argc,char **argv); +void cmd_wifi_power_table_update(char *buf,int len,int argc,char **argv); +void cmd_wifi_state_get(char *buf,int len,int argc,char **argv); +void wifi_sta_get_state_cmd(char *buf,int len,int argc,char **argv); +void wifi_edca_dump_cmd(char *buf,int len,int argc,char **argv); +void wifi_ap_sta_list_get_cmd(char *buf,int len,int argc,char **argv); +void wifi_ap_sta_delete_cmd(char *buf,int len,int argc,char **argv); +void cmd_wifi_coex_pta_force_off(char *buf,int len,int argc,char **argv); +void cmd_wifi_coex_pta_force_on(char *buf,int len,int argc,char **argv); +void cmd_wifi_coex_pti_force_off(char *buf,int len,int argc,char **argv); +void cmd_wifi_coex_pti_force_on(char *buf,int len,int argc,char **argv); +void cmd_wifi_coex_rf_force_off(char *buf,int len,int argc,char **argv); +void cmd_wifi_coex_rf_force_on(char *buf,int len,int argc,char **argv); +void cmd_wifi_mib(char *buf,int len,int argc,char **argv); +void cmd_wifi_cfg(char *buf,int len,int argc,char **argv); +void cmd_wifi_ap_stop(char *buf,int len,int argc,char **argv); +void cmd_wifi_ap_start(char *buf,int len,int argc,char **argv); +void wifi_sniffer_off_cmd(char *buf,int len,int argc,char **argv); +void wifi_sniffer_on_cmd(char *buf,int len,int argc,char **argv); +int wifi_denoise_disable_cmd(void); +int wifi_denoise_enable_cmd(void); +void wifi_power_saving_off_cmd(char *buf,int len,int argc,char **argv); +void wifi_power_saving_on_cmd(char *buf,int len,int argc,char **argv); +void wifi_rc_fixed_disable(char *buf,int len,int argc,char **argv); +int wifi_disable_autoreconnect_cmd(void); +int wifi_enable_autoreconnect_cmd(void); +void wifi_disconnect_cmd(char *buf,int len,int argc,char **argv); +int wifi_sta_ip_unset_cmd(void); +void wifi_sta_ip_info(char *buf,int len,int argc,char **argv); +void cmd_wifi_raw_send(char *buf,int len,int argc,char **argv); +void wifi_scan_cmd(char *buf,int len,int argc,char **argv); +void sniffer_cb(void *env,uint8_t *pkt,int len); +void cmd_wifi_dump(char *buf,int len,int argc,char **argv); +void cmd_wifi_ap_conf_max_sta(char *buf,int len,int argc,char **argv); +void wifi_mon_cmd(char *buf,int len,int argc,char **argv); +void wifi_rc_fixed_enable(char *buf,int len,int argc,char **argv); +void wifi_connect_cmd(char *buf,int len,int argc,char **argv); +void wifi_sta_ip_set_cmd(char *buf,int len,int argc,char **argv); +void wifi_scan_filter_cmd(char *buf,int len,int argc,char **argv); +void wifi_capcode_cmd(char *buf,int len,int argc,char **argv); +int wifi_mgmr_cli_scanlist(void); +int wifi_mgmr_ext_dump_needed(void); +int wifi_mgmr_cli_init(void); +int mac_is_unvalid(uint8_t *mac); +int wifi_mgmr_psk_cal(char *password,char *ssid,int ssid_len,char *output); +int wifi_mgmr_drv_init(wifi_conf_t *conf); +wifi_interface_t wifi_mgmr_sta_enable(void); +int wifi_mgmr_sta_disable(wifi_interface_t *interface); +int wifi_mgmr_sta_ip_get(uint32_t *ip,uint32_t *gw,uint32_t *mask); +int wifi_mgmr_sta_dns_get(uint32_t *dns1,uint32_t *dns2); +int wifi_mgmr_sta_ip_set(uint32_t ip,uint32_t mask,uint32_t gw,uint32_t dns1,uint32_t dns2); +int wifi_mgmr_sta_ip_unset(void); +int wifi_mgmr_sta_disconnect(void); +int wifi_mgmr_sta_powersaving(int ps); +int wifi_mgmr_sta_autoconnect_enable(void); +int wifi_mgmr_sta_autoconnect_disable(void); +void wifi_mgmr_sta_connect_ind_stat_get(wifi_mgmr_sta_connect_ind_stat_info_t *wifi_mgmr_ind_stat); +void wifi_mgmr_sta_ssid_set(char *ssid); +void wifi_mgmr_sta_psk_set(char *psk); +int wifi_mgmr_sta_connect(wifi_interface_t *wifi_interface,char *ssid,char *psk,char *pmk,uint8_t *mac,uint8_t band,uint16_t freq); +wifi_interface_t wifi_mgmr_ap_enable(void); +int wifi_mgmr_ap_start(wifi_interface_t *interface,char *ssid,int hidden_ssid,char *passwd,int channel); +int wifi_mgmr_ap_stop(wifi_interface_t *interface); +int wifi_mgmr_ap_sta_cnt_get(uint8_t *sta_cnt); +int wifi_mgmr_ap_sta_info_get(wifi_sta_basic_info *sta_info,uint8_t idx); +int wifi_mgmr_ap_sta_delete(uint8_t sta_idx); +int wifi_mgmr_sniffer_register(void *env,sniffer_cb_t *cb); +int wifi_mgmr_sniffer_unregister(void *env); +int wifi_mgmr_sniffer_enable(void); +int wifi_mgmr_sniffer_disable(void); +int wifi_mgmr_rate_config(uint16_t config); +int wifi_mgmr_conf_max_sta(uint8_t max_sta_supported); +int wifi_mgmr_state_get(int *state); +int wifi_mgmr_rssi_get(int *rssi); +int wifi_mgmr_raw_80211_send(uint8_t *pkt,int len); +int wifi_mgmr_scan(void *data,scan_complete_cb_t *cb); +int wifi_mgmr_cfg_req(uint32_t ops,uint32_t task,uint32_t element,uint32_t type,uint32_t length,uint32_t *buf); +int wifi_mgmr_scan_filter_hidden_ssid(int filter); +int wifi_mgmr_scan_complete_callback(void); +int wifi_mgmr_scan_ap_all(wifi_mgmr_ap_item_t *env,uint32_t *param1,scan_item_cb_t *cb); +char * wifi_mgmr_status_code_str(uint16_t status_code); +int wifi_mgmr_profile_add(wifi_mgmr_t *mgmr,wifi_mgmr_profile_msg_t *profile_msg,int index); +int wifi_mgmr_profile_get(wifi_mgmr_t *mgmr,wifi_mgmr_profile_msg_t *profile_msg); +int wifi_mgmr_profile_autoreconnect_is_enabled(wifi_mgmr_t *mgmr,int index); +int wifi_mgmr_profile_autoreconnect_disable(wifi_mgmr_t *mgmr,int index); +int wifi_mgmr_profile_autoreconnect_enable(wifi_mgmr_t *mgmr,int index); +int wifi_netif_dhcp_start(netif *netif); +void cb_rssi_ind(void *env,int8_t rssi); +void cb_probe_resp_ind(void *env); +void cb_beacon_ind(void *env,wifi_event_beacon_ind *ind); +void cb_disconnect_ind(void *env,wifi_event_sm_disconnect_ind *ind); +void cb_connect_ind(void *env,wifi_event_sm_connect_ind *ind); +void cb_event_ind(void *env,wifi_event *event); +int wifi_mgmr_event_init(void); +int bl_main_disconnect(void); +int bl_main_powersaving(int mode); +int bl_main_denoise(int mode); +int bl_main_monitor(void); +int bl_main_phy_up(void); +int bl_main_monitor_channel_set(int channel,int use_40MHZ); +int bl_main_if_remove(uint8_t vif_index); +int bl_main_raw_send(uint8_t *pkt,int len); +int bl_main_rate_config(uint8_t sta_idx,uint16_t fixed_rate_cfg); +int bl_main_set_country_code(char *country_code); +int bl_main_get_channel_nums(void); +int bl_main_if_add(int is_sta,netif *netif,uint8_t *vif_index); +int bl_main_apm_start(char *ssid,char *password,int channel,uint8_t vif_index,uint8_t hidden_ssid); +int bl_main_apm_stop(uint8_t vif_index); +int bl_main_apm_sta_cnt_get(uint8_t *sta_cnt); +int bl_main_apm_sta_info_get(wifi_apm_sta_info *apm_sta_info,uint8_t idx); +int bl_main_apm_sta_delete(uint8_t sta_idx); +int bl_main_apm_remove_all_sta(void); +int bl_main_conf_max_sta(uint8_t max_sta_supported); +int bl_main_cfg_task_req(uint32_t ops,uint32_t task,uint32_t element,uint32_t type,void *arg1,void *arg2); +int bl_main_scan(void); +int bl_cfg80211_connect(bl_hw *bl_hw,cfg80211_connect_params *sme); +int bl_main_connect(uint8_t *ssid,int ssid_len,uint8_t *psk,int psk_len,uint8_t *pmk,int pmk_len,uint8_t *mac,uint8_t band,uint16_t freq); +void bl_main_event_handle(void); +void bl_main_lowlevel_init(void); +int bl_main_rtthread_start(bl_hw **bl_hw); +int bl_handle_dynparams(bl_hw *bl_hw); +int bl_send_msg(bl_hw *bl_hw,void *msg_params,int reqcfm,lmac_msg_id_t reqid,void *cfm); +void * bl_msg_zalloc(lmac_msg_id_t id,lmac_task_id_t dest_id,uint16_t param_len); +void bl_msg_update_channel_cfg(char *code); +int bl_msg_get_channel_nums(void); +int bl_send_reset(bl_hw *bl_hw); +int bl_send_monitor_enable(bl_hw *bl_hw,mm_monitor_cfm *cfm); +int bl_send_monitor_channel_set(bl_hw *bl_hw,mm_monitor_channel_cfm *cfm,int channel,int use_40Mhz); +int bl_send_version_req(bl_hw *bl_hw,mm_version_cfm *cfm); +int bl_send_me_config_req(bl_hw *bl_hw); +int bl_send_me_chan_config_req(bl_hw *bl_hw); +int bl_send_me_rate_config_req(bl_hw *bl_hw,uint8_t sta_idx,uint16_t fixed_rate_cfg); +int bl_send_start(bl_hw *bl_hw); +int bl_send_add_if(bl_hw *bl_hw,uchar *mac,nl80211_iftype iftype,_Bool p2p,mm_add_if_cfm *cfm); +int bl_send_remove_if(bl_hw *bl_hw,uint8_t inst_nbr); +int bl_send_scanu_req(bl_hw *bl_hw); +int bl_send_scanu_raw_send(bl_hw *bl_hw,uint8_t *pkt,int len); +int bl_send_sm_connect_req(bl_hw *bl_hw,cfg80211_connect_params *sme,sm_connect_cfm *cfm); +int bl_send_sm_disconnect_req(bl_hw *bl_hw,u16 reason); +int bl_send_mm_powersaving_req(bl_hw *bl_hw,int mode); +int bl_send_mm_denoise_req(bl_hw *bl_hw,int mode); +int bl_send_apm_start_req(bl_hw *bl_hw,apm_start_cfm *cfm,char *ssid,char *password,int channel,uint8_t vif_index,uint8_t hidden_ssid); +int bl_send_apm_stop_req(bl_hw *bl_hw,uint8_t vif_idx); +int bl_send_apm_sta_del_req(bl_hw *bl_hw,apm_sta_del_cfm *cfm,uint8_t sta_idx,uint8_t vif_idx); +int bl_send_apm_conf_max_sta_req(bl_hw *bl_hw,uint8_t max_sta_supported); +int bl_send_cfg_task_req(bl_hw *bl_hw,uint32_t ops,uint32_t task,uint32_t element,uint32_t type,void *arg1,void *arg2); +int bl_platform_on(bl_hw *bl_hw); +int bl_rx_chan_pre_switch_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_rssi_status_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_apm_sta_del_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_apm_sta_add_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +void notify_event_scan_done(int join_scan); +int bl_rx_scanu_join_cfm(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_scanu_start_cfm(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_chan_switch_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_sm_connect_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +int bl_rx_sm_disconnect_ind(bl_hw *bl_hw,bl_cmd *cmd,ipc_e2a_msg *msg); +undefined4 bl_rx_scanu_result_ind(int param_1,longlong param_2); +undefined4 bl_rx_mesh_path_update_ind(void); +undefined4 bl_rx_mesh_proxy_update_ind(void); +undefined4 bl_rx_remain_on_channel_exp_ind(void); +undefined4 bl_rx_ps_change_ind(void); +undefined4 bl_rx_traffic_req_ind(void); +undefined4 bl_rx_csa_counter_ind(void); +undefined4 bl_rx_csa_finish_ind(void); +undefined4 bl_rx_csa_traffic_ind(void); +undefined4 bl_rx_channel_survey_ind(void); +undefined4 bl_rx_dbg_error_ind(void); +undefined4 bl_rx_tdls_chan_switch_cfm(void); +undefined4 bl_rx_tdls_chan_switch_ind(void); +undefined4 bl_rx_tdls_chan_switch_base_ind(void); +undefined4 bl_rx_tdls_peer_ps_ind(void); +undefined4 bl_rx_me_tkip_mic_failure_ind(void); +undefined4 bl_rx_me_tx_credits_update_ind(void); +undefined4 bl_rx_mesh_path_create_cfm(void); +undefined4 bl_rx_mesh_peer_update_ind(void); +int bl_rx_sm_connect_ind_cb_register(void *env,wifi_event_sm_connect_ind_cb_t *cb); +int bl_rx_sm_disconnect_ind_cb_register(void *env,wifi_event_sm_disconnect_ind_cb_t *cb); +int bl_rx_beacon_ind_cb_register(void *env,wifi_event_beacon_ind_cb_t *cb); +int bl_rx_probe_resp_ind_cb_register(void *env,wifi_event_probe_resp_ind_cb_t *cb); +int bl_rx_pkt_cb_register(void *env,wifi_event_pkt_cb_t *cb); +int bl_rx_pkt_cb_unregister(void *env); +int bl_rx_rssi_cb_register(void *env,wifi_event_rssi_cb_t *cb); +int bl_rx_event_register(void *env,wifi_event_cb_t *cb); +void bl_rx_e2a_handler(void *arg); +void bl_rx_pkt_cb(uint8_t *pkt,int len); +void bl_tx_push(bl_hw *bl_hw,bl_txhdr *txhdr); +void bl_tx_resend(void); +void bl_tx_try_flush(void); +int bl_txdatacfm(void *pthis,void *host_id); +void bl_tx_notify(void); +err_t bl_output(bl_hw *bl_hw,netif *netif,pbuf *p,int is_sta); +u8 bl_radarind(void *pthis,void *hostid); +u8 bl_msgackind(void *pthis,void *hostid); +void bl_prim_tbtt_ind(void *pthis); +void my_pbuf_free_custom(pbuf *p); +undefined4 bl_dbgind(void); +void bl_sec_tbtt_ind(void); +void my_pbuf_free_custom_fake(void); +int tcpip_stack_input(void *swdesc,uint8_t status,void *hwhdr,uint msdu_offset,wifi_pkt *pkt); +int bl_utils_idx_lookup(bl_hw *bl_hw,uint8_t *mac); +int bl_ipc_init(bl_hw *bl_hw,ipc_shared_env_tag *ipc_shared_mem); +void bl_utils_dump(void); +void goToErrorState(stateMachine *fsm,event *event); +void stateM_init(stateMachine *fsm,state *initialState,state *errorState); +int stateM_handleEvent(stateMachine *fsm,event *event); +void netif_status_callback(netif *netif); +err_t wifi_tx(netif *netif,pbuf *p); +err_t bl606a0_wifi_netif_init(netif *netif); +int bl606a0_wifi_init(wifi_conf_t *conf); +u32 ipc_emb2app_rawstatus_get(void); +void ipc_host_init(ipc_host_env_tag *env,ipc_host_cb_tag *cb,ipc_shared_env_tag *shared_env_ptr,void *pthis); +int ipc_host_msg_push(ipc_host_env_tag *env,void *msg_buf,uint16_t len); +uint32_t ipc_host_get_rawstatus(ipc_host_env_tag *env); +txdesc_host * ipc_host_txdesc_get(ipc_host_env_tag *env); +void ipc_host_txdesc_push(ipc_host_env_tag *env,void *host_id); +void ipc_host_irq(ipc_host_env_tag *env,uint32_t status); +void ipc_host_enable_irq(ipc_host_env_tag *env,uint32_t value); +void ipc_host_disable_irq_e2a(void); +void cmd_mgr_print(bl_cmd_mgr *cmd_mgr); +void cmd_complete(bl_cmd *cmd); +int cmd_mgr_msgind(bl_cmd_mgr *cmd_mgr,ipc_e2a_msg *msg,msg_cb_fct *cb); +int cmd_mgr_llind(bl_cmd_mgr *cmd_mgr,bl_cmd *cmd); +undefined4 cmd_mgr_queue(char *param_1,char **param_2); +void cmd_mgr_drain(bl_cmd_mgr *cmd_mgr); +void bl_cmd_mgr_init(bl_cmd_mgr *cmd_mgr); +int bl_irqs_init(bl_hw *bl_hw); +void bl_irq_bottomhalf(bl_hw *bl_hw); +uint32_t BLE_ROM_patch(void *pRet,...); +void blecontroller_main(void *pvParameters); +void BLE_ROM_hook_init(void); +_Bool rw_main_task_post(void *msg,uint32_t timeout); +void rw_main_task_post_from_fw(void); +void bdaddr_init(void); +void ble_controller_init(uint8_t task_priority); +void ble_controller_deinit(void); +void rwble_init(void); +void rwble_isr_clear(void); +void rwble_isr(void); +uint8_t ea_conflict_check(ea_elt_tag *evt_a,ea_elt_tag *evt_b); +void ea_elt_cancel(ea_elt_tag *param_1); +void ea_init(_Bool reset); +ea_elt_tag * ea_elt_create(uint16_t size_of_env); +ea_interval_tag * ea_interval_create(void); +void ea_interval_insert(ea_interval_tag *interval_to_add); +void ea_interval_remove(ea_interval_tag *interval_to_remove); +void ea_sw_isr(void); +uint8_t ea_offset_req(ea_param_input *input_param,ea_param_output *output_param); +uint32_t ea_time_get_halfslot_rounded(void); +uint32_t ea_time_get_slot_rounded(void); +void ea_prog_timer(void); +void ea_finetimer_isr(void); +void ea_interval_duration_req(ea_param_input *input_param,ea_param_output *output_param); +void hci_send_2_host(void *param); +void hci_send_2_controller(int param_1); +uint8_t hci_evt_mask_set(evt_mask *evt_msk,uint8_t page); +void hci_init(void); +void hci_reset(void); +void rwip_init(uint32_t error); +void rwip_schedule(void); +void rwip_wakeup_delay_set(uint16_t wakeup_delay); +void rwip_wakeup(void); +void rwip_wakeup_end(void); +uint32_t rwip_sleep_lpcycles_2_us(uint32_t lpcycles); +uint32_t rwip_us_2_lpcycles(uint32_t us); +void ble_co_list_init(co_list *list); +void ble_co_list_push_back(int *param_1,undefined4 *param_2); +void ble_co_list_push_front(co_list *list,co_list_hdr *list_hdr); +co_list_hdr * ble_co_list_pop_front(co_list *list); +_Bool ble_co_list_extract(co_list *list,co_list_hdr *list_hdr,uint8_t nb_following); +void ble_co_list_extract_after(co_list *list,co_list_hdr *elt_ref_hdr,co_list_hdr *elt_to_rem_hdr); +_Bool ble_co_list_find(co_list *list,co_list_hdr *list_hdr); +void ble_co_list_merge(int *param_1,int *param_2); +void ble_co_list_insert_after(co_list *list,co_list_hdr *elt_ref_hdr,co_list_hdr *elt_to_add_hdr); +uint16_t ble_co_list_size(co_list *list); +void co_bdaddr_set(uint8_t *bdaddr); +_Bool co_bdaddr_compare(bd_addr *bd_address1,bd_addr *bd_address2); +void Mont2GF(uint8_t reg_idx); +void getFinalPoint(uint8_t reg_idx); +void pka_point_addition(uint8_t x1_idx,uint8_t x2_idx,uint8_t ret_idx); +void pka_read_result(ECC_Jacobian_Point256 *point,uint8_t idx); +void pka_cp_x2_to_x1(uint8_t x1_idx,uint8_t x2_idx); +void pka_point_inf_check(uint8_t x1_idx,uint8_t *p1_eq_inf); +void GF2Mont(u_int32 *numA,u_int32 *result); +void pka_point_double(uint8_t x_idx); +void pka_addition_win(ECC_Jacobian_Point256 *src1,ECC_Jacobian_Point256 *src2,ECC_Jacobian_Point256 *ret); +void ecc_multiplication_event_handler(uint8_t param_1); +void ecc_init(int param_1); +uint8_t ecc_generate_key256(u_int8 key_type,u_int8 *secret_key,u_int8 *public_key_x,u_int8 *public_key_y,ke_msg_id_t msg_id,ke_task_id_t task_id); +void ecc_gen_new_public_key(u_int8 *secret_key,ke_msg_id_t msg_id,ke_task_id_t task_id); +void ecc_gen_new_secret_key(uint8_t *secret_key256,_Bool forced); +void ble_ke_event_init(void); +uint8_t ble_ke_event_callback_set(uint8_t event_type,intCallback_Type *p_callback); +void ble_ke_event_flush(void); +void ble_ke_event_schedule(void); +_Bool ble_ke_mem_is_in_heap(uint8_t type,void *mem_ptr); +_Bool ble_ke_is_free(void *mem_ptr); +void * ble_ke_msg_alloc(ke_msg_id_t id,ke_task_id_t dest_id,ke_task_id_t src_id,uint16_t param_len); +void ble_ke_msg_send_basic(ke_msg_id_t id,ke_task_id_t dest_id,ke_task_id_t src_id); +void ble_ke_msg_free(ke_msg *msg); +_Bool ble_cmp_abs_time(co_list_hdr *timerA,co_list_hdr *timerB); +_Bool ble_cmp_timer_id(co_list_hdr *timer,uint32_t timer_task); +uint32_t ble_ke_time(void); +_Bool ble_ke_time_cmp(uint32_t newer,uint32_t older); +_Bool ble_ke_time_past(uint32_t time); +void ble_ke_timer_hw_set(ke_timer *timer); +void ble_ke_timer_schedule(void); +void ble_ke_timer_init(void); +void ble_ke_timer_set(ke_msg_id_t timer_id,ke_task_id_t task_id,uint32_t delay); +void ble_ke_timer_clear(ke_msg_id_t timer_id,ke_task_id_t task_id); +_Bool ble_ke_timer_active(ke_msg_id_t timer_id,ke_task_id_t task_id); +void ble_ke_init(void); +void ble_ke_flush(void); +void rf_force_agc_enable(_Bool en); +uint8_t rf_txpwr_dbm_get(uint8_t txpwr_idx,uint8_t modulation); +int8_t rf_rssi_convert(uint8_t rssi_reg); +uint32_t rf_reg_rd(uint16_t addr); +void rf_reg_wr(uint16_t addr,uint32_t value); +void rf_sleep(void); +_Bool rf_txpwr_dec(uint8_t dec); +_Bool rf_txpwr_inc(uint8_t inc); +void rf_txpwr_max_set(int8_t txpwr_dbm); +void rf_reset(void); +void ble_rf_set_pwr_offset(int8_t offset); +void ble_controller_set_tx_pwr(int ble_tx_power); +void ble_rf_init(rwip_rf_api.conflict5 *api); +void pka0_write_common_op_first_cfg(uint8_t s0_reg_index,uint8_t s0_reg_type,uint8_t d_reg_index,uint8_t d_reg_type,uint8_t op,_Bool last_op); +void pka0_write_common_op_snd_cfg_S1(uint8_t s1_reg_index,uint8_t s1_reg_type); +void pka0_write_common_op_snd_cfg_S1_S2(uint8_t s1_reg_index,uint8_t s1_reg_type,uint8_t s2_reg_index,uint8_t s2_reg_type); +void sec_eng_pka0_reset(void); +void sec_eng_pka0_clear_int(void); +void sec_eng_pka0_pld(uint16_t size,uint32_t *data,uint8_t reg_index,uint8_t reg_type,uint8_t op,_Bool last_op); +void sec_eng_pka0_wait_4_isr(void); +void sec_eng_pka0_read_data(uint8_t reg_ype,uint8_t reg_idx,uint32_t *result,uint8_t ret_size); +void sec_eng_pka0_clir(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t size); +void sec_eng_pka0_movdat(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type,uint8_t s0_reg_idx); +void sec_eng_pka0_msub(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type,uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx,uint8_t s2_reg_type,uint8_t s2_reg_idx); +void sec_eng_pka0_mrem(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type,uint8_t s0_reg_idx,uint8_t s2_reg_type,uint8_t s2_reg_idx); +void sec_eng_pka0_mmul(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type,uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx,uint8_t s2_reg_type,uint8_t s2_reg_idx); +void sec_eng_pka0_mexp(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type,uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx,uint8_t s2_reg_type,uint8_t s2_reg_idx); +void sec_eng_pka0_lcmp(uint8_t *cout,uint8_t s0_reg_type,uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx); +void sec_eng_pka0_lsub(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type,uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx); +void sec_eng_pka0_lmul(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type,uint8_t s0_reg_idx,uint8_t s1_reg_type,uint8_t s1_reg_idx); +void sec_eng_pka0_lmul2n(uint8_t last_op,uint8_t d_reg_type,uint8_t d_reg_idx,uint8_t s0_reg_type,uint8_t s0_reg_idx,uint16_t bit_shift); +void em_buf_init(void); +void em_buf_rx_free(uint8_t hdl); +uint8_t * em_buf_rx_buff_addr_get(uint16_t rx_hdl); +void llc_init(void); +void llc_stop(int param_1); +void llc_reset(void); +void llc_discon_event_complete_send(ke_task_id_t src_id,uint8_t status,uint8_t conhdl,uint8_t reason); +void llc_le_con_cmp_evt_send(uint8_t status,uint16_t conhdl,llc_create_con_req_ind *param); +void llc_le_ch_sel_algo_evt_send(uint8_t chSel,uint16_t conhdl,llc_create_con_req_ind *param); +void llc_start(llc_create_con_req_ind *param_1,ea_elt_tag *param_2); +void llc_con_update_complete_send(uint8_t status,uint16_t conhdl,lld_evt_tag *evt); +void llc_ltk_req_send(uint16_t conhdl,llcp_enc_req *param); +void llc_feats_rd_event_send(uint8_t status,uint16_t conhdl,le_features *feats); +void llc_version_rd_event_send(uint8_t status,uint16_t conhdl); +void llc_common_cmd_complete_send(uint16_t opcode,uint8_t status,uint16_t conhdl); +void llc_common_cmd_status_send(uint16_t opcode,uint8_t status,uint16_t conhdl); +void llc_common_flush_occurred_send(uint16_t conhdl); +void llc_common_enc_key_ref_comp_evt_send(uint16_t conhdl,uint8_t status); +void llc_common_enc_change_evt_send(uint16_t conhdl,uint8_t enc_status,uint8_t status); +void llc_common_nb_of_pkt_comp_evt_send(uint16_t conhdl,uint8_t nb_of_pkt); +void llc_con_update_ind(uint16_t conhdl,ea_elt_tag *elt_new); +void llc_lsto_con_update(uint16_t conhdl); +void llc_map_update_ind(uint16_t conhdl); +void llc_con_update_finished(int param_1); +void llc_map_update_finished(int param_1); +void lld_evt_winsize_change(lld_evt_tag *evt,_Bool instant); +void lld_evt_slave_time_compute(ea_elt_tag *elt,uint16_t slot_offset); +void lld_evt_prevent_stop(ea_elt_tag *elt); +void lld_evt_deferred_elt_push(ea_elt_tag *elt,uint8_t type,uint8_t rx_desc_cnt); +void lld_evt_elt_wait_insert(ea_elt_tag *elt); +uint32_t lld_evt_get_next_free_slot(void); +lld_evt_wait_tag * lld_evt_elt_wait_get(ea_elt_tag *elt); +void lld_evt_schedule(ea_elt_tag *elt); +void lld_evt_channel_next(uint16_t conhdl,int16_t nb_inc); +uint16_t lld_evt_drift_compute(uint16_t delay,uint8_t master_sca); +void lld_evt_rxwin_compute(ea_elt_tag *elt); +void lld_evt_canceled(ea_elt_tag *elt); +ea_elt_tag * lld_evt_scan_create(uint16_t handle,uint16_t latency); +ea_elt_tag *lld_evt_move_to_master(ea_elt_tag *elt_scan,uint16_t conhdl,llc_create_con_req_ind *pdu_tx,uint8_t rx_hdl); +ea_elt_tag *lld_evt_update_create(ea_elt_tag *elt_old,uint16_t ce_len,uint16_t mininterval,uint16_t maxinterval,uint16_t latency,uint8_t pref_period,lld_evt_update_tag *upd_par); +ea_elt_tag *lld_evt_move_to_slave(llc_create_con_req_ind *con_par,llm_pdu_con_req_rx *con_req_pdu,ea_elt_tag *elt_adv,uint16_t conhdl); +void lld_evt_slave_update(llcp_con_upd_ind *param_pdu,ea_elt_tag *elt_old); +ea_elt_tag *lld_evt_adv_create(uint16_t handle,uint16_t mininterval,uint16_t maxinterval,_Bool restart_pol); +void lld_evt_end(ea_elt_tag *elt); +void lld_evt_rx(ea_elt_tag *elt); +void lld_evt_rx_afs(ea_elt_tag *elt,uint8_t num); +void lld_evt_timer_isr(void); +void lld_evt_end_isr(_Bool apfm); +void lld_evt_rx_isr(void); +void lld_evt_afs_isr(uint8_t num); +void lld_pdu_llcp_con_param_req_unpk(uint16_t pdu_ptr,uint8_t parlen,uint8_t *param); +void lld_pdu_llcp_con_param_rsp_unpk(uint16_t pdu_ptr,uint8_t parlen,uint8_t *param); +void lld_pdu_llcp_length_req_unpk(uint16_t pdu_ptr,uint8_t parlen,uint8_t *param); +void lld_pdu_llcp_length_rsp_unpk(uint16_t pdu_ptr,uint8_t parlen,uint8_t *param); +uint8_t lld_pdu_pack(uint8_t *p_data,uint8_t *p_length,char *format); +void lld_pdu_cntl_aligned_unpk(uint16_t pdu_ptr,uint8_t parlen,uint8_t *param); +void lld_pdu_data_tx_push(lld_evt_tag *evt,em_desc_node *txnode,_Bool can_be_freed,_Bool encrypted); +void lld_pdu_tx_prog(lld_evt_tag *param_1); +uint8_t lld_pdu_adv_pack(uint8_t code,uint8_t *buf,uint8_t *p_len); +void lld_pdu_rx_handler(lld_evt_tag *evt,uint8_t nb_rx_desc); +void lld_sleep_init(void); +void lld_sleep_wakeup(void); +void lld_sleep_wakeup_end(void); +uint16_t lld_util_instant_get(void *event,uint8_t action); +void lld_util_set_bd_address(bd_addr *bd_addr,uint8_t type); +uint8_t lld_util_freq2chnl(uint8_t freq); +uint16_t lld_util_get_local_offset(uint16_t PeerOffset,uint16_t Interval,uint32_t AnchorPoint); +uint16_t lld_util_get_peer_offset(uint16_t LocalOffset,uint16_t Interval,uint32_t AnchorPoint); +void lld_util_connection_param_set(ea_elt_tag *elt,ea_param_output *param); +void lld_util_dle_set_cs_fields(uint16_t conhdl); +void lld_util_anchor_point_move(ea_elt_tag *elt_connect); +void lld_util_flush_list(co_list *list); +_Bool lld_util_instant_ongoing(ea_elt_tag *elt); +void lld_util_compute_ce_max(ea_elt_tag *elt,uint16_t tx_time,uint16_t rx_time); +void lld_util_priority_set(ea_elt_tag *elt,uint8_t priority_index); +uint8_t lld_util_get_tx_pkt_cnt(ea_elt_tag *elt); +void lld_util_eff_tx_time_set(ea_elt_tag *elt,uint16_t max_tx_time,uint16_t max_tx_size); +void lld_wlcoex_set(int param_1); +void lld_init(_Bool reset); +void lld_core_reset(void); +void lld_adv_stop(ea_elt_tag *elt); +void lld_scan_stop(ea_elt_tag *elt); +ea_elt_tag *lld_move_to_master(ea_elt_tag *elt,uint16_t conhdl,llc_create_con_req_ind *param,uint8_t rx_hdl); +void lld_con_update_req(ea_elt_tag *elt_old,llc_con_upd_req_ind *param,llcp_con_upd_ind *param_pdu); +uint8_t lld_con_update_after_param_req(uint16_t conhdl,ea_elt_tag *elt_old,llc_con_upd_req_ind *param,llcp_con_upd_ind *param_pdu,_Bool bypass_offchk); +uint8_t lld_con_param_rsp(uint16_t conhdl,ea_elt_tag *elt,llc_con_upd_req_ind *param); +void lld_con_param_req(uint16_t conhdl,ea_elt_tag *elt,llc_con_upd_req_ind *param); +void lld_con_stop(ea_elt_tag *elt); +uint8_t lld_get_mode(uint16_t conhdl); +ea_elt_tag *lld_move_to_slave(llc_create_con_req_ind *con_par,llm_pdu_con_req_rx *con_req_pdu,ea_elt_tag *elt_adv,uint16_t conhdl,uint8_t rx_hdl); +void lld_ch_map_ind(ea_elt_tag *elt,uint16_t instant); +void lld_con_update_ind(ea_elt_tag *elt_old,llcp_con_upd_ind *param_pdu); +void lld_crypt_isr(void); +ea_elt_tag * lld_test_mode_tx(em_desc_node *txdesc,uint8_t tx_freq,uint8_t tx_phy); +ea_elt_tag * lld_test_mode_rx(uint8_t rx_freq); +void lld_test_stop(ea_elt_tag *elt); +uint16_t llm_util_bd_addr_wl_position(bd_addr *bd_address,uint8_t bd_addr_type); +uint8_t llm_util_check_address_validity(bd_addr *bd_address,uint8_t addr_type); +uint8_t llm_util_check_map_validity(uint8_t *channel_map,uint8_t nb_octet); +void llm_util_apply_bd_addr(uint8_t addr_type); +_Bool llm_util_check_evt_mask(uint8_t event_id); +void llm_util_get_channel_map(le_chnl_map *map); +void llm_util_get_supp_features(le_features *feats); +void llm_util_adv_data_update(void); +uint8_t llm_util_bl_check(bd_addr *bd_addr_to_add,uint8_t bd_addr_type,uint16_t *conhdl,uint8_t wl_flag_action,_Bool *in_wl); +_Bool llm_util_bd_addr_in_wl(bd_addr *bd_address,uint8_t bd_addr_type,_Bool *in_black_list); +uint8_t llm_util_bl_add(bd_addr *bd_addr_to_add,uint8_t bd_addr_type,uint16_t conhdl); +uint8_t llm_util_bl_rem(uint16_t conhdl); +void llm_end_evt_defer(void); +_Bool llm_pdu_defer(uint16_t status,uint8_t rx_hdl,uint8_t tx_cnt); +void llm_wlpub_addr_set(uint16_t elem_index,bd_addr *bdaddr); +void llm_wlpriv_addr_set(uint16_t elem_index,bd_addr *bdaddr); +void llm_con_req_ind(uint8_t rx_hdl,uint16_t status); +void llm_le_adv_report_ind(uint8_t rx_hdl); +void llm_con_req_tx_cfm(uint8_t rx_hdl); +void llm_common_cmd_complete_send(uint16_t opcode,uint8_t status); +void llm_common_cmd_status_send(uint16_t opcode,uint8_t status); +uint8_t llm_test_mode_start_rx(hci_le_rx_test_cmd *param); +uint8_t llm_set_adv_param(hci_le_set_adv_param_cmd *param); +uint8_t llm_set_adv_en(hci_le_set_adv_en_cmd *param); +uint8_t llm_set_adv_data(hci_le_set_adv_data_cmd *param); +uint8_t llm_set_scan_rsp_data(hci_le_set_scan_rsp_data_cmd *param); +uint8_t llm_set_scan_param(hci_le_set_scan_param_cmd *param); +uint8_t llm_set_scan_en(hci_le_set_scan_en_cmd *param); +void llm_wl_clr(void); +void llm_init(_Bool reset); +void llm_wl_dev_add(bd_addr *bd_addr,uint8_t bd_addr_type); +void llm_wl_dev_rem(bd_addr *bd_addr,uint8_t bd_addr_type); +uint8_t llm_wl_dev_add_hdl(bd_addr *bd_addr,uint8_t bd_addr_type); +uint8_t llm_wl_dev_rem_hdl(bd_addr *bd_addr,uint8_t bd_addr_type); +uint8_t llm_create_con(hci_le_create_con_cmd *param); +void llm_encryption_start(llm_enc_req *param); +void llm_encryption_done(void); +void hci_fc_init(void); +uint8_t hci_fc_acl_buf_size_set(uint16_t acl_pkt_len,uint16_t nb_acl_pkts); +uint8_t hci_fc_acl_en(_Bool flow_enable); +void hci_fc_host_nb_acl_pkts_complete(uint16_t acl_pkt_nb); +uint8_t hci_pack_bytes(uint8_t **pp_in,uint8_t **pp_out,uint8_t *p_in_end,uint8_t *p_out_end,uint8_t len); +uint8_t hci_host_nb_cmp_pkts_cmd_pkupk(uint8_t *out,uint8_t *in,uint16_t *out_len,uint16_t in_len); +uint8_t hci_le_adv_report_evt_pkupk(uint8_t *out,uint8_t *in,uint16_t *out_len,uint16_t in_len); +uint8_t hci_le_dir_adv_report_evt_pkupk(uint8_t *out,uint8_t *in,uint16_t *out_len,uint16_t in_len); +hci_cmd_desc_tag * hci_look_for_cmd_desc(uint16_t opcode); +hci_evt_desc_tag * hci_look_for_evt_desc(uint8_t code); +hci_evt_desc_tag * hci_look_for_le_evt_desc(uint8_t subcode); +void hci_tl_init(_Bool reset); +uint16_t hci_util_read_array_size(char **fmt_cursor); +HCI_PACK_STATUS hci_util_pack(uint8_t *inout,uint16_t *inout_len,char *format); +HCI_PACK_STATUS hci_util_unpack(uint8_t *out,uint8_t *in,uint16_t *out_len,uint16_t in_len,char *format); +uint8_t * hci_build_cc_evt(ke_msg *msg,int8_t nb_h2c_cmd_pkts); +uint8_t * hci_build_evt(ke_msg *msg); +uint8_t * hci_build_le_evt(ke_msg *msg); +uint8_t * hci_build_acl_rx_data(ke_msg *msg); +co_list_hdr *ble_ke_queue_extract(co_list *queue,anon_subr__Bool_co_list_hdr_ptr_uint32_t.conflict *func,uint32_t arg); +void ble_ke_queue_insert(co_list *queue,co_list_hdr *element,anon_subr__Bool_co_list_hdr_ptr_co_list_hdr_ptr *cmp); +_Bool ble_cmp_dest_id(co_list_hdr *msg,uint32_t dest_id); +ke_msg_func_t * ble_ke_handler_search(ke_msg_id_t msg_id,ke_state_handler *state_handler); +ke_msg_func_t * ble_ke_task_handler_get(ke_msg_id_t msg_id,ke_task_id_t task_id); +void ble_ke_task_init(void); +void ble_ke_state_set(ke_task_id_t id,ke_state_t state_id); +undefined4 llcp_ping_rsp_handler(int param_1,ke_task_id_t param_2); +int llcp_terminate_ind_handler(uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_terminate_ind *param); +void llc_llcp_reject_ind(int param_1,ke_task_id_t param_2,int param_3,int param_4); +int llcp_reject_ind_ext_handler(uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_reject_ind_ext *param); +int llcp_reject_ind_handler(uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_reject_ind *param); +undefined4 llcp_start_enc_req_handler(int param_1,ke_task_id_t param_2); +undefined4 llcp_unknown_rsp_handler(int param_1,ke_task_id_t param_2,int param_3); +void llc_llcp_version_ind_pdu_send(uint16_t conhdl); +undefined4 llcp_vers_ind_handler(int param_1,ke_task_id_t param_2,int param_3); +void llc_llcp_ch_map_update_pdu_send(uint16_t conhdl); +void llc_llcp_pause_enc_req_pdu_send(uint16_t conhdl); +void llc_llcp_pause_enc_rsp_pdu_send(uint16_t conhdl); +void llc_llcp_enc_req_pdu_send(uint16_t conhdl,hci_le_start_enc_cmd *param); +void llc_llcp_enc_rsp_pdu_send(uint16_t conhdl,llcp_enc_req *param); +void llc_llcp_start_enc_rsp_pdu_send(uint16_t conhdl); +void llc_llcp_reject_ind_pdu_send(uint16_t conhdl,uint8_t rej_opcode,uint8_t reason); +int llcp_con_param_rsp_handler(uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_con_param_rsp *param); +undefined4 llcp_feats_rsp_handler(int param_1,ke_task_id_t param_2,uint8_t *param_3); +int llcp_channel_map_ind_handler(int param_1,ke_task_id_t param_2,int param_3,uint8_t *param_4); +int llcp_con_upd_ind_handler(int param_1,ke_task_id_t param_2,int param_3,llcp_con_upd_ind *param_4); +void llc_llcp_con_update_pdu_send(uint16_t conhdl,llcp_con_upd_ind *param); +void llc_llcp_con_param_req_pdu_send(uint16_t conhdl,llc_con_upd_req_ind *param); +void llc_llcp_con_param_rsp_pdu_send(uint16_t conhdl,llc_con_upd_req_ind *param); +undefined4 llcp_con_param_req_handler(int param_1,ke_task_id_t param_2,uint8_t *param_3); +void llc_llcp_feats_req_pdu_send(uint16_t conhdl); +void llc_llcp_feats_rsp_pdu_send(uint16_t conhdl); +void llc_llcp_start_enc_req_pdu_send(uint16_t conhdl); +void llc_llcp_terminate_ind_pdu_send(uint16_t conhdl,uint8_t err_code); +void llc_llcp_unknown_rsp_send_pdu(uint16_t conhdl,uint8_t unk_type); +int llc_llcp_unknown_ind_handler(uint16_t conhdl,uint8_t opcode); +int llcp_feats_req_handler(uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_feats_req *param); +int llcp_slave_feature_req_handler(uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,llcp_slave_feature_req *param); +void llc_llcp_ping_req_pdu_send(uint16_t conhdl); +void llc_llcp_ping_rsp_pdu_send(uint16_t conhdl); +int llcp_ping_req_handler(uint16_t conhdl,ke_task_id_t dest_id,_Bool int_ctx,void *param); +void llc_llcp_length_req_pdu_send(uint16_t conhdl); +void llc_llcp_length_rsp_pdu_send(uint16_t conhdl); +int llc_llcp_recv_handler(uint param_1,int param_2,byte *param_3,int param_4); +uint8_t llc_llcp_get_autorize(uint8_t opcode); +int llc_dft_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +undefined4 llm_enc_ind_handler(int param_1,uint param_2); +int llc_llcp_recv_ind_handler(ke_msg_id_t msgid,llc_llcp_recv_ind *ind,ke_task_id_t dest_id,ke_task_id_t src_id); +undefined4 llc_chmap_update_req_ind_handler(uint param_1); +undefined4 llc_auth_payl_real_to_ind_handler(uint param_1); +undefined4 llc_con_upd_req_ind_handler(llc_con_upd_req_ind *param_1,uint param_2); +undefined4 llc_length_req_ind_handler(uint param_1); +void llc_task_random_gen_request(ke_task_id_t dest_id); +undefined4 llc_enc_mgt_ind_handler(uint param_1); +undefined4 llc_chnl_assess_timer_handler(uint param_1); +int llc_llcp_rsp_to_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +undefined4 llc_link_sup_to_ind_handler(uint param_1); +undefined4 llc_auth_payl_nearly_to_ind_handler(uint param_1); +undefined4 llc_data_ind_handler(void *param_1,uint param_2); +undefined4 lld_stop_ind_handler(uint param_1); +uint8_t llc_util_get_free_conhdl(uint16_t *conhdl); +uint8_t llc_util_get_nb_active_link(void); +void llc_util_update_channel_map(uint16_t conhdl,le_chnl_map *map); +void llc_util_set_auth_payl_to_margin(lld_evt_tag *evt); +void llc_util_clear_operation_ptr(int param_1,int param_2); +void llc_util_bw_mgt(uint16_t conhdl); +void llc_end_evt_defer(int param_1); +void llc_pdu_acl_tx_ack_defer(uint16_t conhdl,uint8_t tx_cnt); +void llc_pdu_defer(uint16_t conhdl,uint16_t status,uint8_t rssi,uint8_t channel,uint8_t length); +int llm_dft_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int llm_le_set_host_ch_class_cmd_sto_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int llm_ecc_result_ind_handler(ke_msg_id_t msgid,ecc_result_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int llm_enc_req_handler(ke_msg_id_t msgid,llm_enc_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int lld_stop_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +void llc_ch_assess_local(int param_1,uint param_2,int param_3,int param_4); +uint8_t llc_ch_assess_get_local_ch_map(uint16_t conhdl,le_chnl_map *map,le_chnl_map *hostmap); +le_chnl_map * llc_ch_assess_get_current_ch_map(uint16_t conhdl); +void llc_ch_assess_reass_ch(uint16_t conhdl,le_chnl_map *map,le_chnl_map *hostmap,uint8_t nb_chgood); +undefined4 hci_le_set_data_len_cmd_handler(ushort *param_1,ke_task_id_t param_2,uint16_t param_3); +undefined4 hci_le_rem_con_param_req_neg_reply_cmd_handler(ushort *param_1,ke_task_id_t param_2,uint16_t param_3); +undefined4 hci_le_rem_con_param_req_reply_cmd_handler(ushort *param_1,ke_task_id_t param_2,uint16_t param_3); +undefined4 hci_le_ltk_req_reply_cmd_handler(ushort *param_1,ke_task_id_t param_2,uint16_t param_3); +undefined4 hci_disconnect_cmd_handler(uint16_t *param_1,ke_task_id_t param_2,uint16_t param_3); +int hci_le_rd_rem_used_feats_cmd_handler(ke_msg_id_t msgid,hci_le_rd_rem_used_feats_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +undefined4 hci_le_rd_chnl_map_cmd_handler(ke_task_id_t *param_1,ke_task_id_t param_2); +undefined4 hci_rd_auth_payl_to_cmd_handler(ke_task_id_t *param_1,uint param_2); +undefined4 hci_rd_rssi_cmd_handler(ke_task_id_t *param_1,ke_task_id_t param_2); +undefined4 hci_rd_tx_pwr_lvl_cmd_handler(ke_task_id_t *param_1,ke_task_id_t param_2); +undefined4 hci_le_con_update_cmd_handler(ushort *param_1,ke_task_id_t param_2,uint16_t param_3); +undefined4 hci_wr_auth_payl_to_cmd_handler(ke_task_id_t *param_1,uint param_2); +int hci_flush_cmd_handler(ke_msg_id_t msgid,hci_basic_conhdl_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +undefined4 hci_rd_rem_ver_info_cmd_handler(uint16_t *param_1,uint param_2,uint16_t param_3); +int llc_hci_command_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_vsc_set_tx_pwr(ke_msg_id_t msgid,hci_vsc_set_tx_pwr_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_wr_rfpath_compensation_cmd_handler(ke_msg_id_t msgid,hci_le_wr_rfpath_cps_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_wr_le_host_supp_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_wr_suggted_dft_data_len_cmd_handler(ke_msg_id_t msgid,hci_le_wr_suggted_dft_data_len_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_set_evt_mask_cmd_handler(ke_msg_id_t msgid,hci_le_set_evt_mask_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rd_rfpath_compensation_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rd_trans_pwr_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_rd_buff_size_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_rd_local_supp_feats_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_rd_local_supp_cmds_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_rd_local_ver_info_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_rd_bd_addr_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rd_max_data_len_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rd_suggted_dft_data_len_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rd_supp_states_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rd_wl_size_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rd_adv_ch_tx_pw_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rd_local_supp_feats_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rd_buff_size_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_generate_dhkey_cmd_handler(ke_msg_id_t msgid,hci_le_generate_dh_key_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_host_nb_cmp_pkts_cmd_handler(ke_msg_id_t msgid,hci_host_nb_cmp_pkts_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_host_buf_size_cmd_handler(ke_msg_id_t msgid,hci_host_buf_size_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_set_evt_mask_page_2_cmd_handler(ke_msg_id_t msgid,hci_set_evt_mask_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_set_evt_mask_cmd_handler(ke_msg_id_t msgid,hci_set_evt_mask_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_set_ctrl_to_host_flow_ctrl_cmd_handler(ke_msg_id_t msgid,hci_set_ctrl_to_host_flow_ctrl_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_reset_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_tx_test_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rx_test_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rand_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_enc_cmd_handler(ke_msg_id_t msgid,hci_le_enc_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_wl_mngt_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_set_host_ch_class_cmd_handler(ke_msg_id_t msgid,hci_le_set_host_ch_class_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_create_con_cmd_handler(ke_msg_id_t msgid,hci_le_create_con_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_set_scan_en_cmd_handler(ke_msg_id_t msgid,hci_le_set_scan_en_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_set_scan_param_cmd_handler(ke_msg_id_t msgid,hci_le_set_scan_param_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_set_adv_en_cmd_handler(ke_msg_id_t msgid,hci_le_set_adv_en_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_set_adv_param_cmd_handler(ke_msg_id_t msgid,hci_le_set_adv_param_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_set_rand_add_cmd_handler(ke_msg_id_t msgid,hci_le_set_rand_addr_cmd *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_rd_local_p256_public_key_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_test_end_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_le_create_con_cancel_cmd_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_command_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hci_driver_send(net_buf *buf); +int hci_driver_open(void); +void recv_thread(void *p1); +void hci_driver_enque_recvq(net_buf *buf); +int hci_driver_init(void); +void le_dhkey_complete(net_buf *buf); +void hci_data_buf_overflow(net_buf *buf); +int atomic_test_bit(atomic_t *target,int bit); +void bt_addr_le_copy(bt_addr_le_t *dst,bt_addr_le_t *src); +void le_pkey_complete(net_buf *buf); +void atomic_set_bit_to(atomic_t *target,int bit,_Bool val); +void slave_update_conn_param(bt_conn *conn); +void le_remote_feat_complete(net_buf *buf); +void le_conn_update_complete(net_buf *buf); +void hci_num_completed_packets(net_buf *buf); +void update_sec_level(bt_conn *conn); +void hci_encrypt_key_refresh_complete(net_buf *buf); +void hci_encrypt_change(net_buf *buf); +bt_conn * find_pending_connect(bt_addr_le_t *peer_addr); +void hci_vendor_event(net_buf *buf); +void handle_event(u8_t event,net_buf *buf,event_handler *handlers,size_t num_handlers); +void hci_le_meta_event(net_buf *buf); +void hci_cmd_done(u16_t opcode,u8_t status,net_buf *buf); +void hci_cmd_status(net_buf *buf); +void hci_cmd_complete(net_buf *buf); +int id_find(bt_addr_le_t *addr); +void sys_put_le64(u8_t *dst); +net_buf * bt_hci_cmd_create(u16_t opcode,u8_t param_len); +int bt_hci_cmd_send_sync(u16_t opcode,net_buf *buf,net_buf **rsp); +int set_le_scan_enable(u8_t enable); +int set_random_address(bt_addr_t *addr); +int le_set_private_addr(void); +int hci_id_add(bt_addr_le_t *addr,u8_t *val); +void keys_add_id(bt_keys *keys,void *data); +int addr_res_enable(u8_t enable); +int set_advertise_enable(_Bool enable); +void hci_disconn_complete(net_buf *buf); +int set_ad(u16_t hci_op,bt_ad *ad,size_t ad_len); +int le_adv_update(bt_data *ad,size_t ad_len,bt_data *sd,size_t sd_len,_Bool connectable,_Bool use_name); +bt_addr_le_t * bt_lookup_id_addr(u8_t id,bt_addr_le_t *addr); +_Bool bt_le_conn_params_valid(bt_le_conn_param *param); +int bt_unpair(u8_t id,bt_addr_le_t *addr); +void bt_id_add(bt_keys *keys); +void bt_id_del(bt_keys *keys); +void update_pending_id(bt_keys *keys,void *data); +void bt_data_parse(net_buf_simple *ad,anon_subr__Bool_bt_data_ptr_void_ptr *func,void *user_data); +int bt_addr_le_create_static(bt_addr_le_t *addr); +void id_create(u8_t id,bt_addr_le_t *addr); +int bt_send(net_buf *buf); +int bt_hci_cmd_send(u16_t opcode,net_buf *buf); +int bt_le_set_data_len(bt_conn *conn,u16_t tx_octets,u16_t tx_time); +int start_le_scan(u8_t scan_type,u16_t interval,u16_t window); +int bt_le_scan_update(_Bool fast_scan); +void le_adv_report(net_buf *buf); +void le_ltk_request(net_buf *buf); +void le_conn_param_neg_reply(u16_t handle,u8_t reason); +void le_conn_param_req(net_buf *buf); +void enh_conn_complete(bt_hci_evt_le_enh_conn_complete *evt); +void le_enh_conn_complete(net_buf *buf); +void le_legacy_conn_complete(net_buf *buf); +void hci_tx_thread(void *p1); +int bt_recv(net_buf *buf); +undefined4 bt_recv_prio(net_buf *param_1); +int bt_hci_driver_register(bt_hci_driver *drv); +void bt_finalize_init(void); +void bt_delete_queue(k_fifo *queue_to_del); +int bt_disable_action(void); +int bt_disable(void); +int bt_set_name(char *name); +int bt_enable(bt_ready_cb_t *cb); +char * bt_get_name(void); +int bt_id_create(bt_addr_le_t *addr,u8_t *irk); +int bt_setup_id_addr(void); +void init_work(k_work *work); +_Bool bt_addr_le_is_bonded(u8_t id,bt_addr_le_t *addr); +int bt_le_adv_start_internal(byte *param_1,bt_data *param_2,size_t param_3,bt_data *param_4,size_t param_5,bt_addr_le_t *param_6); +int set_adv_channel_map(u8_t channel); +int bt_get_local_public_address(bt_addr_le_t *adv_addr); +int bt_get_local_ramdon_address(bt_addr_le_t *adv_addr); +int bt_le_adv_start(bt_le_adv_param *param,bt_data *ad,size_t ad_len,bt_data *sd,size_t sd_len); +int bt_le_adv_stop(void); +int bt_le_scan_start(byte *param_1,bt_le_scan_cb_t.conflict1 *param_2); +int bt_le_scan_stop(void); +int bt_set_tx_pwr(int8_t power); +int bt_buf_get_rx_avail_cnt(void); +net_buf * bt_buf_get_rx(bt_buf_type type,s32_t timeout); +net_buf * bt_buf_get_cmd_complete(s32_t timeout); +int bt_pub_key_gen(bt_pub_key_cb *new_cb); +u8_t * bt_pub_key_get(void); +int bt_dh_key_gen(u8_t *remote_pk,bt_dh_key_cb_t *cb); +void sys_slist_remove(sys_slist_t *list,sys_snode_t *prev_node,sys_snode_t *node); +size_t net_buf_frags_len(net_buf *buf); +u8_t get_ident(void); +bt_l2cap_le_chan * __l2cap_lookup_ident(bt_conn *conn,u16_t ident,_Bool remove); +bt_l2cap_server * l2cap_server_lookup_psm(u16_t psm); +bt_l2cap_le_chan * l2cap_remove_rx_cid(bt_conn *conn,u16_t cid); +void l2cap_chan_sdu_sent(bt_conn *conn,void *user_data); +net_buf * l2cap_alloc_frag(s32_t timeout,void *user_data); +void l2cap_connected(bt_l2cap_chan *chan); +void l2cap_chan_destroy(bt_l2cap_chan *chan); +void l2cap_chan_tx_init(bt_l2cap_le_chan *chan); +void l2cap_chan_rx_init(bt_l2cap_le_chan *chan); +int l2cap_accept(bt_conn *conn,bt_l2cap_chan **chan); +net_buf * l2cap_create_le_sig_pdu(u8_t code,u8_t ident,u16_t len); +void l2cap_chan_tx_give_credits(bt_l2cap_le_chan *chan,u16_t credits); +void l2cap_disconnected(void); +void bt_l2cap_chan_remove(bt_conn *conn,bt_l2cap_chan *ch); +void bt_l2cap_chan_del(bt_l2cap_chan *chan); +void l2cap_rtx_timeout(k_work *work); +void bt_l2cap_disconnected(bt_conn *conn); +net_buf * bt_l2cap_create_pdu_timeout(net_buf_pool *pool,size_t reserve,s32_t timeout); +int bt_l2cap_send_cb(bt_conn *conn,u16_t cid,net_buf *buf,bt_conn_tx_cb_t *cb,void *user_data); +void bt_l2cap_send(bt_conn *conn,u16_t cid,net_buf *buf); +void l2cap_chan_send_credits(bt_l2cap_le_chan *chan,u16_t credits); +int l2cap_le_conn_req(bt_l2cap_le_chan *ch); +void bt_l2cap_encrypt_change(bt_conn *conn,u8_t hci_status); +void l2cap_send_reject(bt_conn *conn,u8_t ident,u16_t reason,void *data,u8_t data_len); +int l2cap_chan_le_send(bt_l2cap_le_chan *ch,net_buf *buf,u16_t sdu_hdr_len); +int l2cap_chan_le_send_sdu(bt_l2cap_le_chan *param_1,net_buf **param_2,ushort param_3); +bt_l2cap_chan * bt_l2cap_le_lookup_tx_cid(bt_conn *conn,u16_t cid); +bt_l2cap_chan * bt_l2cap_le_lookup_rx_cid(bt_conn *conn,u16_t cid); +_Bool l2cap_chan_add(bt_conn *conn,bt_l2cap_chan *chan,bt_l2cap_chan_destroy_t *destroy); +void bt_l2cap_connected(bt_conn *conn); +void bt_l2cap_recv(bt_conn *conn,net_buf *buf); +int bt_l2cap_update_conn_param(bt_conn *conn,bt_le_conn_param *param); +void bt_l2cap_init(void); +int bt_l2cap_chan_disconnect(bt_l2cap_chan *chan); +void l2cap_chan_le_recv_seg(bt_l2cap_le_chan *param_1,net_buf *param_2); +void l2cap_rx_process(k_work *work); +int l2cap_recv(bt_l2cap_chan *chan_1,net_buf *buf); +void sys_memcpy_swap(void *dst,void *src,size_t length); +void sys_mem_swap(void *buf,size_t length); +u8_t get_io_capa(void); +bt_smp * smp_chan_get(bt_conn *conn); +void atomic_set_bit(atomic_t *target,int bit); +int atomic_test_bit(atomic_t *target,int bit); +void smp_reset(bt_smp *smp); +void smp_pairing_complete(bt_smp *smp,u8_t status); +int bt_smp_aes_cmac(u8_t *key,u8_t *in,size_t len,u8_t *out); +int smp_sign_buf(u8_t *key,u8_t *msg,u16_t len); +int smp_f4(u8_t *u,u8_t *v,u8_t *x,u8_t z,u8_t *res); +u8_t sc_smp_check_confirm(bt_smp *smp); +int smp_f5(u8_t *w,u8_t *n1,u8_t *n2,bt_addr_le_t *a1,bt_addr_le_t *a2,u8_t *mackey,u8_t *ltk); +int smp_f6(u8_t *w,u8_t *n1,u8_t *n2,u8_t *r,u8_t *iocap,bt_addr_le_t *a1,bt_addr_le_t *a2,u8_t *check); +int smp_g2(u8_t *u,u8_t *v,u8_t *x,u8_t *y,u32_t.conflict *passkey); +int atomic_test_and_clear_bit(atomic_t *target,int bit); +u8_t display_passkey(bt_smp *smp); +_Bool update_keys_check(bt_smp *smp); +u8_t smp_pairing_failed(bt_smp *smp,net_buf *buf); +void smp_timeout(k_work *work); +u8_t smp_ident_info(bt_smp *smp,net_buf *buf); +u8_t smp_encrypt_info(bt_smp *smp,net_buf *buf); +u8_t legacy_request_tk(bt_smp *smp); +void bt_smp_disconnected(bt_l2cap_chan *chan); +void bt_smp_connected(bt_l2cap_chan *chan); +u8_t get_auth(u8_t auth); +_Bool sec_level_reachable(void); +int bt_smp_accept(bt_conn *conn,bt_l2cap_chan **chan); +_Bool smp_keys_check(bt_conn *conn); +u8_t get_pair_method(bt_smp *smp,u8_t remote_io); +net_buf * smp_create_pdu(bt_smp *smp,u8_t op); +void smp_send(bt_smp *smp,net_buf *buf,bt_conn_tx_cb_t *cb); +u8_t sc_smp_send_dhkey_check(bt_smp *smp,u8_t *e); +u8_t compute_and_send_master_dhcheck(bt_smp *smp); +u8_t compute_and_check_and_send_slave_dhcheck(bt_smp *smp); +u8_t smp_dhkey_check(bt_smp *smp,net_buf *buf); +u8_t smp_send_pairing_random(bt_smp *smp); +u8_t sc_send_public_key(bt_smp *smp); +u8_t send_pairing_rsp(bt_smp *smp); +u8_t bt_smp_distribute_keys(bt_smp *smp); +u8_t smp_signing_info(bt_smp *smp,net_buf *buf); +u8_t smp_master_ident(bt_smp *smp,net_buf *buf); +int smp_init(bt_smp *smp); +int smp_send_pairing_req(bt_conn *conn); +u8_t smp_security_request(bt_smp *smp,net_buf *buf); +u8_t smp_pairing_req(bt_smp *smp,net_buf *buf); +void smp_check_complete(bt_conn *conn,u8_t dist_complete); +void smp_sign_info_sent(bt_conn *conn,void *user_data); +void le_sc_oob_config_set.isra.3.constprop.19(int *param_1,char *param_2); +int smp_error(bt_smp *smp,u8_t reason); +void bt_smp_dhkey_ready(u8_t *dhkey); +int bt_smp_recv(bt_l2cap_chan *chan,net_buf *buf); +void bt_smp_encrypt_change(bt_l2cap_chan *chan,u8_t hci_status); +u8_t smp_send_pairing_confirm(bt_smp *smp); +void smp_ident_sent(bt_conn *conn,void *user_data); +int smp_c1(u8_t *k,u8_t *r,u8_t *preq,u8_t *pres,bt_addr_le_t *ia,bt_addr_le_t *ra,u8_t *enc_data); +u8_t legacy_send_pairing_confirm(bt_smp *smp); +u8_t legacy_pairing_confirm(bt_smp *smp); +u8_t smp_pairing_confirm(bt_smp *smp,net_buf *buf); +u8_t smp_pairing_rsp(bt_smp *smp,net_buf *buf); +u8_t smp_ident_addr_info(bt_smp *smp,net_buf *buf); +u8_t smp_public_key_slave(bt_smp *smp); +u8_t smp_public_key(bt_smp *smp,net_buf *buf); +void bt_smp_pkey_ready(u8_t *pkey); +u8_t smp_pairing_random(bt_smp *smp,net_buf *buf); +_Bool bt_smp_request_ltk(bt_conn *conn,u16_t ediv,u8_t *ltk); +int bt_smp_sign_verify(bt_conn *conn,net_buf *buf); +int bt_smp_sign(bt_conn *conn,net_buf *buf); +int bt_smp_auth_passkey_entry(bt_conn *conn,uint passkey); +int bt_smp_auth_passkey_confirm(bt_conn *conn); +int bt_smp_auth_cancel(bt_conn *conn); +int bt_smp_auth_pairing_confirm(bt_conn *conn); +int bt_smp_start_security(bt_conn *conn); +void bt_smp_update_keys(bt_conn *conn); +int bt_smp_init(void); +bt_keys * bt_keys_find_addr(u8_t id,bt_addr_le_t *addr); +bt_keys * bt_keys_find(int type,u8_t id,bt_addr_le_t *addr); +bt_keys * bt_keys_get_addr(u8_t id,bt_addr_le_t *addr); +void bt_keys_foreach(int type,anon_subr_void_bt_keys_ptr_void_ptr *func,void *data); +bt_keys * bt_keys_find(int type,u8_t id,bt_addr_le_t *addr); +bt_keys * bt_keys_get_type(int type,u8_t id,bt_addr_le_t *addr); +bt_keys * bt_keys_find_irk(u8_t id,bt_addr_le_t *addr); +bt_keys * bt_keys_find_addr(u8_t id,bt_addr_le_t *addr); +void bt_keys_add_type(bt_keys *keys,int type); +void bt_keys_clear(bt_keys *keys); +void keys_clear_id(bt_keys *keys,void *data); +void bt_keys_clear_all(u8_t id); +void bt_keys_update_usage(u8_t id,bt_addr_le_t *addr); +u8_t notify_func(bt_conn *conn,bt_gatt_subscribe_params *params,void *data,u16_t length); +void le_param_updated(bt_conn *conn,u16_t interval,u16_t latency,u16_t timeout); +void ble_set_tx_pwr(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_unsubscribe(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void write_func(bt_conn *conn,u8_t err,bt_gatt_write_params *params); +void ble_exchange_mtu(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void exchange_func(bt_conn *conn,u8_t err,bt_gatt_exchange_params *params); +void ble_auth_pairing_confirm(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_auth_passkey_confirm(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_auth_cancel(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_auth(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_security(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_select_conn(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_disconnect(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_connect(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_stop_advertise(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_get_device_name(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_start_advertise(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_set_adv_channel(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_stop_scan(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_disable(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +u8_t discover_func(bt_conn *conn,bt_gatt_attr *attr,bt_gatt_discover_params *params); +void ble_set_data_len(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_subscribe(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_write(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_read(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +u8_t read_func(bt_conn *conn,u8_t err,bt_gatt_read_params *params,void *data,u16_t length); +_Bool data_cb(bt_data *data,void *user_data); +void ble_discover(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_auth_passkey(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_conn_update(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_unpair(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_start_scan(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_set_device_name(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_init(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +int bt_addr_le_to_str(bt_addr_le_t *addr,char *str); +void device_found(bt_addr_le_t *addr,s8_t rssi,u8_t evtype,net_buf_simple *buf); +void ble_read_local_address(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void connected(bt_conn *conn,u8_t err); +void disconnected(bt_conn *conn,u8_t reason); +void security_changed(bt_conn *conn,bt_security_t level,bt_security_err err); +void auth_passkey_display(bt_conn *conn,uint passkey); +void auth_passkey_entry(bt_conn *conn); +void auth_passkey_confirm(bt_conn *conn,uint passkey); +void auth_cancel(bt_conn *conn); +void auth_pairing_confirm(bt_conn *conn); +void auth_pairing_complete(bt_conn *conn,_Bool bonded); +void auth_pairing_failed(bt_conn *conn,bt_security_err reason); +void identity_resolved(bt_conn *conn,bt_addr_le_t *rpa,bt_addr_le_t *identity); +void ble_get_all_conn_info(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +void ble_write_without_rsp(char *pcWriteBuffer,int xWriteBufferLen,int argc,char **argv); +int ble_cli_register(void); +void k_queue_init(k_queue *queue,int size); +void k_queue_insert(k_queue *queue,void *prev,void *data); +void k_queue_append(k_queue *queue,void *data); +void k_queue_free(k_queue *queue); +void k_queue_prepend(k_queue *queue,void *data); +void k_queue_append_list(k_queue *queue,void *head,void *tail); +void * k_queue_get(k_queue *queue,s32_t timeout); +int k_queue_is_empty(k_queue *queue); +int k_queue_get_cnt(k_queue *queue); +int k_sem_init(k_sem *sem,uint initial_count,uint limit); +int k_sem_take(k_sem *sem,uint32_t timeout); +int k_sem_give(k_sem *sem); +int k_sem_delete(k_sem *sem); +uint k_sem_count_get(k_sem *sem); +int k_thread_create(k_thread *new_thread,char *name,size_t stack_size,k_thread_entry_t entry,int prio); +void k_thread_delete(k_thread *new_thread); +int k_yield(void); +uint irq_lock(void); +void irq_unlock(void); +void k_timer_init(k_timer_t.conflict1 *timer,k_timer_handler_t.conflict handle,void *args); +void k_timer_stop(k_timer_t.conflict1 *timer); +void k_timer_delete(k_timer_t.conflict1 *timer); +longlong k_now_ms(void); +u32_t.conflict k_uptime_get_32(void); +void k_timer_start(k_timer_t.conflict1 *timer,uint32_t timeout); +void k_get_random_byte_array(uint8_t *buf,size_t len); +void * k_malloc(size_t xWantedSize); +void k_free(void *pv); +int atomic_cas(atomic_t *target,atomic_val_t old_value,atomic_val_t new_value); +atomic_val_t atomic_inc(atomic_t *target); +atomic_val_t atomic_dec(atomic_t *target); +atomic_val_t atomic_get(atomic_t *target); +atomic_val_t atomic_set(atomic_t *target,atomic_val_t value); +atomic_val_t atomic_clear(atomic_t *target); +atomic_val_t atomic_or(atomic_t *target,atomic_val_t value); +atomic_val_t atomic_and(atomic_t *target,atomic_val_t value); +void fixed_data_unref(net_buf *buf,u8_t *data); +net_buf_pool * net_buf_pool_get(int id); +int net_buf_id(net_buf *buf); +u8_t * fixed_data_alloc(net_buf *buf,size_t *size,s32_t timeout); +net_buf * net_buf_alloc_len(net_buf_pool *pool,size_t size,s32_t timeout); +net_buf * net_buf_alloc_fixed(net_buf_pool *pool,s32_t timeout); +net_buf * net_buf_get(k_fifo *fifo,s32_t timeout); +void net_buf_simple_reserve(net_buf_simple *buf,size_t reserve); +void net_buf_put(k_fifo *fifo,net_buf *buf); +void net_buf_unref(net_buf *buf); +net_buf * net_buf_ref(net_buf *buf); +void net_buf_frag_insert(net_buf *parent,net_buf *frag); +net_buf * net_buf_frag_add(net_buf *head,net_buf *frag); +net_buf * net_buf_frag_del(net_buf *parent,net_buf *frag); +void * net_buf_simple_add(net_buf_simple *buf,size_t len); +void * net_buf_simple_add_mem(net_buf_simple *buf,void *mem,size_t len); +u8_t * net_buf_simple_add_u8(net_buf_simple *buf,u8_t val); +void net_buf_simple_add_le16(net_buf_simple *buf,u16_t val); +void * net_buf_simple_push(net_buf_simple *buf,size_t len); +void net_buf_simple_push_le16(net_buf_simple *buf,u16_t val); +void * net_buf_simple_pull(net_buf_simple *buf,size_t len); +void * net_buf_simple_pull_mem(net_buf_simple *buf,size_t len); +u8_t net_buf_simple_pull_u8(net_buf_simple *buf); +u16_t net_buf_simple_pull_le16(net_buf_simple *buf); +size_t net_buf_simple_headroom(net_buf_simple *buf); +size_t net_buf_simple_tailroom(net_buf_simple *buf); +size_t net_buf_append_bytes(net_buf *buf,size_t len,void *value,s32_t timeout,net_buf_allocator_cb *allocate_cb,void *user_data); +char * bt_hex_real(void *buf,size_t len); +char * bt_addr_le_str_real(bt_addr_le_t *addr); +_Bool polling_events(k_poll_event *events,int num_events,s32_t timeout,int *last_registered); +void k_poll_event_init(k_poll_event *event,u32_t.conflict type,int mode,void *obj); +int k_poll(k_poll_event *events,int num_events,s32_t timeout); +int k_poll_signal_raise(k_poll_signal *signal,int result); +_Bool bt_rpa_irk_matches(u8_t *irk,bt_addr_t *addr); +void k_work_submit_to_queue(k_work_q *work_q,k_work *work); +void work_queue_main(void *p1); +int k_work_q_start(void); +int k_work_init(k_work *work,k_work_handler_t *handler); +void k_work_submit(k_work *work); +void k_delayed_work_init(k_delayed_work *work,k_work_handler_t *handler); +void k_delayed_work_del_timer(k_delayed_work *work); +int add_timer_record(k_delayed_work *delay_work); +int remv_timer_record(k_delayed_work *delay_work); +int k_delayed_work_cancel(k_delayed_work *work); +int k_delayed_work_submit(k_delayed_work *work,uint32_t delay); +timer_rec_d * get_timer_record(void *hdl); +void work_timeout(void *timer); +void reverse_bytearray(uint8_t *src,uint8_t *result,int array_size); +void gf_double(uint8_t *out,uint8_t *in); +int tc_cmac_erase(TCCmacState_t s); +int tc_cmac_init(TCCmacState_t s); +int tc_cmac_setup(TCCmacState_t s,uint8_t *key,TCAesKeySched_t sched); +int tc_cmac_update(TCCmacState_t s,uint8_t *data,size_t data_length); +int tc_cmac_final(uint8_t *tag,TCCmacState_t s); +uint _copy(uint8_t *to,uint to_len,uint8_t *from,uint from_len); +void * _set(void *__s,int __c,size_t __n); +uint8_t _double_byte(uint8_t a); +rx_msg_struct * bl_find_valid_queued_entry(void); +void bl_onchiphci_rx_packet_handler(uint8_t pkt_type,uint16_t src_id,uint8_t *param,uint8_t param_len,void *rx_buf); +void bl_handle_queued_msg(void); +void bl_onchiphci_interface_deinit(void); +uint8_t bl_onchiphci_interface_init(void); +int bl_onchiphci_send_2_controller(net_buf *buf); +int atomic_test_bit(atomic_t *target,int bit); +void tx_free(bt_conn_tx *tx); +int send_frag(ushort *param_1,net_buf *param_2,int param_3,int param_4); +void notify_connected(bt_conn *conn); +void bt_conn_reset_rx_state(bt_conn *conn); +void conn_cleanup(bt_conn *conn); +void tx_notify(bt_conn *conn); +void tx_complete_work(k_work *work); +k_sem * bt_conn_get_pkts(bt_conn *conn); +void notify_le_param_updated(bt_conn *conn); +_Bool le_param_req(bt_conn *conn,bt_le_conn_param *param); +_Bool le_check_valid_conn(void); +void bt_conn_identity_resolved(bt_conn *conn); +int bt_conn_le_start_encryption(bt_conn *conn,u8_t *rand,u8_t *ediv,u8_t *ltk,size_t len); +void bt_conn_security_changed(bt_conn *param_1,int param_2); +int bt_conn_set_security(bt_conn *conn,bt_security_t sec); +bt_security_t bt_conn_get_security(bt_conn *conn); +void bt_conn_cb_register(bt_conn_cb *cb); +void bt_conn_recv(bt_conn *conn,net_buf *buf,u8_t flags); +int bt_conn_send_cb(bt_conn *conn,net_buf *buf,bt_conn_tx_cb_t *cb,void *user_data); +int bt_conn_prepare_events(k_poll_event *events); +bt_conn * bt_conn_add_le(u8_t id,bt_addr_le_t *peer); +void bt_conn_set_state(bt_conn *conn,bt_conn_state_t state); +bt_conn * bt_conn_lookup_handle(u16_t handle); +int bt_conn_addr_le_cmp(bt_conn *conn,bt_addr_le_t *peer); +bt_conn * bt_conn_lookup_state_le(bt_addr_le_t *peer,bt_conn_state_t state); +bt_conn * bt_conn_lookup_addr_le(u8_t id,bt_addr_le_t *peer); +bt_conn * bt_conn_lookup_state_le(bt_addr_le_t *peer,bt_conn_state_t state); +void bt_conn_foreach(int type,anon_subr_void_bt_conn_ptr_void_ptr *func,void *data); +void bt_conn_disconnect_all(u8_t id); +void bt_conn_unref(bt_conn *conn); +bt_addr_le_t * bt_conn_get_dst(bt_conn *conn); +int bt_conn_get_info(bt_conn *conn,bt_conn_info *info); +int bt_conn_get_remote_dev_info(bt_conn_info *info); +int bt_conn_disconnect(bt_conn *conn,u8_t reason); +void disconnect_all(bt_conn *conn,void *data); +bt_conn * bt_conn_create_le(bt_addr_le_t *peer,bt_le_conn_param *param); +int bt_conn_le_conn_update(bt_conn *conn,bt_le_conn_param *param); +int send_conn_le_param_update(bt_conn *conn,bt_le_conn_param *param); +void conn_update_timeout(k_work *work); +int bt_conn_le_param_update(bt_conn *conn,bt_le_conn_param *param); +net_buf * bt_conn_create_pdu_timeout(net_buf_pool *pool,size_t reserve,s32_t timeout); +net_buf * create_frag(net_buf *buf); +void bt_conn_process_tx(bt_conn *param_1); +int bt_conn_auth_cb_register(bt_conn_auth_cb *cb); +int bt_conn_auth_passkey_entry(bt_conn *conn,uint passkey); +int bt_conn_auth_passkey_confirm(bt_conn *conn); +int bt_conn_auth_cancel(bt_conn *conn); +int bt_conn_auth_pairing_confirm(bt_conn *conn); +u8_t bt_conn_index(bt_conn *conn); +int bt_conn_init(void); +int bt_rand(void *buf,size_t len); +int bt_encrypt_le(u8_t *key,u8_t *plaintext,u8_t *enc_data); +void sys_slist_remove(sys_slist_t *list,sys_snode_t *prev_node,sys_snode_t *node); +u8_t found_attr(bt_gatt_attr *attr,void *user_data); +u16_t find_static_attr(bt_gatt_attr *attr); +void gatt_ccc_changed(bt_gatt_attr *attr,_bt_gatt_ccc.conflict2 *ccc); +void gatt_indicate_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +void sc_restore_rsp(bt_conn *conn,bt_gatt_attr *attr,u8_t err); +void gatt_subscription_remove(bt_conn *conn,sys_snode_t *prev,bt_gatt_subscribe_params *params); +void gatt_mtu_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +void gatt_write_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +bt_gatt_ccc_cfg * find_ccc_cfg(bt_conn *conn,_bt_gatt_ccc.conflict2 *ccc); +int gatt_notify(bt_conn *conn,u16_t handle,bt_gatt_notify_params.conflict1 *params); +void gatt_read_multiple_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +void gatt_write_ccc_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +int gatt_send(bt_conn *conn,net_buf *buf,bt_att_func_t *func,void *params); +int gatt_indicate(bt_conn *conn,u16_t handle,bt_gatt_indicate_params.conflict2 *params); +undefined4 match_uuid(undefined4 param_1,undefined4 *param_2); +void sc_indicate_rsp(bt_conn *conn,bt_gatt_attr *attr,u8_t err); +u8_t disconnected_cb(bt_gatt_attr *attr,void *user_data); +gatt_sc_cfg * find_sc_cfg(u8_t id,bt_addr_le_t *addr); +int gatt_write_ccc(bt_conn *conn,u16_t handle,u16_t value,bt_gatt_subscribe_params *params); +ssize_t read_appearance(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset); +ssize_t read_ppcp(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset); +ssize_t read_name(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset); +ssize_t bt_gatt_attr_read_ccc(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset); +ssize_t bt_gatt_attr_read_service(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset); +void sc_save(u8_t id,bt_addr_le_t *peer,u16_t start,u16_t end); +_Bool sc_ccc_cfg_write(bt_conn *conn,bt_gatt_attr *attr,u16_t value); +u8_t notify_cb(bt_gatt_attr *attr,void *user_data); +void sc_indicate(u16_t start,u16_t end); +ssize_t bt_gatt_attr_write_ccc(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset,u8_t flags); +void bt_gatt_init(void); +void bt_gatt_deinit(void); +undefined4 bt_gatt_service_unregister(int *param_1); +ssize_t bt_gatt_attr_read(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t buf_len,u16_t offset,void *value,u16_t value_len); +uint16_t bt_gatt_attr_value_handle(bt_gatt_attr *attr); +uint lexical_block_0(bt_gatt_attr *param_1); +ssize_t bt_gatt_attr_read_chrc(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset); +void bt_gatt_foreach_attr_type(u16_t start_handle,u16_t end_handle,bt_uuid *uuid,void *attr_data,uint16_t num_matches,bt_gatt_attr_func_t *func,void *user_data); +void bt_gatt_foreach_attr(u16_t start_handle,u16_t end_handle,bt_gatt_attr_func_t *func,void *user_data); +int bt_gatt_service_register(bt_uuid **param_1); +int bt_gatt_indicate(bt_conn *conn,bt_gatt_indicate_params.conflict2 *params); +void sc_process(k_work *work); +u16_t bt_gatt_get_mtu(bt_conn *conn); +u8_t bt_gatt_check_perm(bt_conn *conn,bt_gatt_attr *attr,u8_t mask); +u8_t update_ccc(bt_gatt_attr *attr,void *user_data); +int bt_gatt_exchange_mtu(bt_conn *conn,bt_gatt_exchange_params *params); +int bt_gatt_discover(bt_conn *conn,bt_gatt_discover_params *params); +void gatt_discover_next(bt_conn *conn,u16_t last_handle,bt_gatt_discover_params *params); +void gatt_find_type_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +void gatt_read_group_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +void gatt_read_type_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +void read_included_uuid_cb(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +void gatt_find_info_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +int bt_gatt_read(bt_conn *conn,bt_gatt_read_params *params); +void gatt_read_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +int bt_gatt_write_without_response_cb(bt_conn *conn,u16_t handle,void *data,u16_t length,_Bool sign,bt_gatt_complete_func_t *func,void *user_data); +int bt_gatt_write(bt_conn *conn,bt_gatt_write_params *params); +void gatt_prepare_write_rsp(bt_conn *conn,u8_t err,void *pdu,u16_t length,void *user_data); +int bt_gatt_subscribe(bt_conn *conn,bt_gatt_subscribe_params *params); +int bt_gatt_unsubscribe(bt_conn *conn,bt_gatt_subscribe_params *params); +void bt_gatt_notification(bt_conn *conn,u16_t handle,void *data,u16_t length); +void bt_gatt_connected(bt_conn *conn); +void bt_gatt_encrypt_change(bt_conn *conn); +_Bool bt_gatt_change_aware(bt_conn *conn,_Bool req); +void bt_gatt_disconnected(bt_conn *conn); +void uuid_to_uuid128(bt_uuid *src,bt_uuid_128 *dst); +int bt_uuid_cmp(bt_uuid *u1,bt_uuid *u2); +_Bool bt_uuid_create(bt_uuid *uuid,u8_t *data,u8_t data_len); +void bt_uuid_to_str(bt_uuid *uuid,char *str,size_t len); +void bt_settings_encode_key(char *path,size_t path_size,char *subsys,bt_addr_le_t *addr,char *key); +u8_t u8_to_dec(char *buf,u8_t buflen,u8_t value); +void add_round_key(uint8_t *s,uint *k); +void shift_rows(uint8_t *s); +void mult_row_column(uint8_t *out,uint8_t *in); +int tc_aes128_set_encrypt_key(TCAesKeySched_t s,uint8_t *k); +int tc_aes_encrypt(uint8_t *out,uint8_t *in,TCAesKeySched_t s); +u8_t att_prepare_write_req(bt_att *att,net_buf *buf); +att_type_t att_op_get_type(u8_t op); +void att_req_destroy(bt_att_req.conflict26 *req); +u8_t att_notify(bt_att *att,net_buf *buf); +void bt_gatt_foreach_attr(u16_t start_handle,u16_t end_handle,bt_gatt_attr_func_t *func,void *user_data); +u8_t read_group_cb(bt_gatt_attr *attr,void *user_data); +u8_t read_type_cb(bt_gatt_attr *attr,void *user_data); +u8_t find_type_cb(bt_gatt_attr *attr,void *user_data); +u8_t find_info_cb(bt_gatt_attr *attr,void *user_data); +void bt_att_connected(bt_l2cap_chan *chan); +bt_conn_tx_cb_t * att_cb(void); +int att_send(bt_conn *conn,net_buf *buf,bt_conn_tx_cb_t *cb,void *user_data); +int att_send_req(bt_att *att,bt_att_req.conflict26 *req); +u8_t att_handle_rsp(bt_att *att,void *pdu,u16_t len,u8_t err); +u8_t att_handle_find_info_rsp(bt_att *att,net_buf *buf); +u8_t att_handle_find_type_rsp(bt_att *att,net_buf *buf); +u8_t att_handle_read_type_rsp(bt_att *att,net_buf *buf); +u8_t att_handle_read_rsp(bt_att *att,net_buf *buf); +u8_t att_handle_read_blob_rsp(bt_att *att,net_buf *buf); +u8_t att_handle_read_mult_rsp(bt_att *att,net_buf *buf); +u8_t att_handle_read_group_rsp(bt_att *att,net_buf *buf); +u8_t att_handle_write_rsp(bt_att *att,net_buf *buf); +u8_t att_handle_prepare_write_rsp(bt_att *att,net_buf *buf); +u8_t att_handle_exec_write_rsp(bt_att *att,net_buf *buf); +u8_t att_confirm(bt_att *att,net_buf *buf); +u8_t att_error_rsp(bt_att *att,net_buf *buf); +int bt_att_accept(bt_conn *conn,bt_l2cap_chan **chan); +u8_t att_mtu_rsp(bt_att *att,net_buf *buf); +void att_reset(bt_att *att); +void bt_att_disconnected(bt_l2cap_chan *chan); +void att_timeout(k_work *work); +void bt_att_encrypt_change(bt_l2cap_chan *chan,u8_t hci_status); +undefined4 att_exec_write_req(void); +void att_pdu_sent(bt_conn *conn,void *user_data); +bt_att * att_chan_get(bt_conn *conn); +void att_req_sent(bt_conn *conn,void *user_data); +void att_cfm_sent(bt_conn *conn,void *user_data); +void att_rsp_sent(bt_conn *conn,void *user_data); +u8_t write_cb(bt_gatt_attr *attr,void *user_data); +u8_t read_cb(bt_gatt_attr *attr,void *user_data); +net_buf * bt_att_create_pdu(bt_conn *conn,u8_t op,size_t len); +u8_t att_indicate(bt_att *att,net_buf *buf); +u8_t att_mtu_req(bt_att *att,net_buf *buf); +void send_err_rsp(bt_conn *conn,u8_t req,u16_t handle,u8_t err); +int bt_att_recv(bt_l2cap_chan *chan,net_buf *buf); +u8_t att_read_group_req(bt_att *att,net_buf *buf); +u8_t att_read_mult_req(bt_att *att,net_buf *buf); +u8_t att_read_rsp(bt_att *att,u8_t op,u8_t rsp,u16_t handle,u16_t offset); +u8_t att_read_blob_req(bt_att *att,net_buf *buf); +u8_t att_read_req(bt_att *att,net_buf *buf); +u8_t att_read_type_req(bt_att *att,net_buf *buf); +u8_t att_find_type_req(bt_att *att,net_buf *buf); +u8_t att_find_info_req(bt_att *att,net_buf *buf); +u8_t att_write_rsp(bt_conn *conn,u8_t req,u8_t rsp,u16_t handle,void *value,u16_t len); +u8_t att_write_req(bt_att *att,net_buf *buf); +u8_t att_write_cmd(bt_att *att,net_buf *buf); +u8_t att_signed_write_cmd(bt_att *att,net_buf *buf); +void bt_att_init(void); +u16_t bt_att_get_mtu(bt_conn *conn); +int bt_att_send(bt_conn *conn,net_buf *buf,bt_conn_tx_cb_t *cb,void *user_data); +int bt_att_req_send(bt_conn *conn,bt_att_req.conflict26 *req); +void bt_att_req_cancel(bt_conn *param_1,sys_snode_t param_2); +uint32_t fdt32_ld(fdt32_t *p); +int nextprop_(void *fdt,int offset); +fdt_property * fdt_get_property_by_offset_(void *fdt,int offset,int *lenp); +char * fdt_get_string(void *fdt,int stroffset,int *lenp); +char * fdt_get_name(void *fdt,int nodeoffset,int *len); +int fdt_subnode_offset_namelen(void *fdt,int offset,char *name,int namelen); +int fdt_subnode_offset(void *fdt,int parentoffset,char *name); +int fdt_first_property_offset(void *fdt,int nodeoffset); +int fdt_next_property_offset(void *fdt,int offset); +fdt_property *fdt_get_property_namelen_(void *fdt,int offset,char *name,int namelen,int *lenp,int *poffset); +void * fdt_getprop_namelen(void *fdt,int nodeoffset,char *name,int namelen,int *lenp); +void * fdt_getprop(void *fdt,int nodeoffset,char *name,int *lenp); +int fdt_stringlist_count(void *fdt,int nodeoffset,char *property); +char * fdt_stringlist_get(void *fdt,int nodeoffset,char *property,int idx,int *lenp); +uint32_t fdt32_ld(fdt32_t *p); +int fdt_ro_probe_(void *fdt); +void * fdt_offset_ptr(void *fdt,int offset,uint len); +uint32_t fdt_next_tag(void *fdt,int startoffset,int *nextoffset); +int fdt_check_node_offset_(void *fdt,int offset); +int fdt_check_prop_offset_(void *fdt,int offset); +int fdt_next_node(void *fdt,int offset,int *depth); +void cmd_blog_info_dump(char *buf,int len,int argc,char **argv); +size_t blog_strcpy(size_t cur_len,char *dst,char *src); +void cmd_blog_set_level(char *buf,int len,int argc,char **argv); +void blog_port_output(char *log,size_t size); +void blog_hexdump_out(char *name,uint8_t width,uint8_t *buf,uint16_t size); +void blog_init(void); +void wifiprov_ccc_cfg_changed(bt_gatt_attr *attr,u16_t value); +void __bl_ble_sync_task(void *p_arg); +void scan_complete_cb(void *param); +int __recv_event(void *p_drv,pro_event *p_event); +void wifi_state_get_cb(void *p_arg); +size_t write_data(bt_conn *param_1,uint8_t *param_2,size_t param_3); +undefined4 __ble_bytes_send(uint8_t *param_1,uint param_2); +void blsync_disconnected(bt_conn *conn,u8_t reason); +void blsync_exchange_func(bt_conn *conn,u8_t err,bt_gatt_exchange_params *params); +ssize_t read_data(bt_conn *conn,bt_gatt_attr *attr,void *buf,u16_t len,u16_t offset); +void blsync_connected(bt_conn *conn,u8_t err); +int bl_ble_sync_start(bl_ble_sync_t *index,blesync_wifi_func *func,pfn_complete_cb_t *cb,void *cb_arg); +int bl_ble_sync_stop(bl_ble_sync_t *index); +void * __malloc(size_t size); +void __free(void *ptr); +void __clear_dev(pro_handle_t handle); +int __protocol_send(pro_handle_t handle,uint8_t seq,uint8_t ack,uint8_t type,void *p_data,uint16_t length); +int pro_trans_read(pro_handle_t handle,void *buf,size_t bytes,uint16_t mtu); +int pro_trans_ack(pro_handle_t handle); +int pro_trans_layer_ack_read(pro_handle_t handle,void *ack_buf,size_t bytes); +pro_handle_t pro_trans_init(pro_dev *p_dev,pro_func *p_func,void *p_drv); +void pro_trans_reset(pro_handle_t handle); +int __pack_encrypt_read(void *p_drv,uint8_t pack_type,uint8_t *dst_id,uint8_t *dst_buf,uint8_t *dst_len,uint8_t *src_buf,size_t src_lenght); +int __pack_encrypt_write(void *p_drv,uint8_t pack_type,uint8_t src_id,uint8_t *dst_buf,uint8_t *dst_len,uint8_t *src_buf,uint8_t src_len,int16_t remain_len); +enc_handle_t pro_encrypt_init(encrypt *p_enc,void *p_drv); +int __payload_write(void *p_arg,uint8_t *dst_buf,uint8_t *dst_len,uint8_t src_id,uint8_t *src_buf,uint8_t src_len,int16_t remain_len); +int __payload_read(void *p_arg,uint8_t *dst_buf,uint8_t *dst_type,uint8_t *dst_len,uint8_t *src_buf,uint8_t src_len); +pyld_handle_t pro_payload_init(payload *p_pyld,void *p_drv); +cJSON * cJSON_New_Item(void); +char * ensure(printbuffer *p,int needed); +char * cJSON_strdup(char *str); +int update(printbuffer *p); +char * print_number(cJSON *item,printbuffer *p); +char * print_string_ptr(char *str,printbuffer *p); +char * print_array(int depth,int fmt,printbuffer *p); +char * print_value(cJSON *item,int depth,int fmt,printbuffer *p); +char * print_object(int depth,int fmt,printbuffer *p); +void cJSON_InitHooks(cJSON_Hooks *hooks); +void cJSON_Delete(cJSON *c); +char * cJSON_Print(cJSON *item); +void cJSON_AddItemToArray(cJSON *array,cJSON *item); +void cJSON_AddItemToObject(cJSON *object,char *string,cJSON *item); +cJSON * cJSON_CreateNumber(void); +cJSON * cJSON_CreateString(char *string); +cJSON * cJSON_CreateObject(void); +cli_command * cli_command_get(int idx,int *is_static_cmd); +void exit_cmd(char *buf,int len,int argc,char **argv); +int cb_idnoe(void *arg,inode_t *node); +void ota_cmd(char *buf,int len,int argc,char **argv); +void tftp_ota_thread(void *arg); +void cat_cmd(char *buf,int len,int argc,char **argv); +void hexdump_cmd(char *buf,int len,int argc,char **argv); +int aos_cli_init(int use_thread); +void * aos_cli_event_cb_read_get(void); +int cli_putstr(char *msg); +void ps_cmd(char *buf,int len,int argc,char **argv); +int aos_cli_printf(char *msg,...); +int proc_onecmd(int argc,char **argv); +void ls_cmd(char *buf,int len,int argc,char **argv); +void uptime_cmd(char *buf,int len,int argc,char **argv); +void reset_cmd(char *buf,int len,int argc,char **argv); +void poweroff_cmd(char *buf,int len,int argc,char **argv); +void reboot_cmd(char *buf,int len,int argc,char **argv); +void version_cmd(char *buf,int len,int argc,char **argv); +void devname_cmd(char *buf,int len,int argc,char **argv); +void echo_cmd(char *buf,int len,int argc,char **argv); +void mmem_cmd(char *buf,int len,int argc,char **argv); +void pmem_cmd(char *buf,int len,int argc,char **argv); +void help_cmd(char *buf,int len,int argc,char **argv); +int cli_getchar(char *inbuf); +void cli_main_input(char *buffer,int count); +void console_cb_read(int fd,void *param); +void aos_cli_input_direct(char *buffer,int count); +void get_dns_request(void *arg,udp_pcb *upcb,pbuf *p,ip_addr_t *addr,u16_t port); +void dns_server_init(void); +EfErrCode easyflash_init(void); +size_t get_status(uint8_t *status_table,size_t status_num); +void update_sector_cache(uint32_t sec_addr,uint32_t empty_addr); +uint32_t get_next_sector_addr(sector_meta_data_t pre_sec); +_Bool gc_check_cb(sector_meta_data_t sector,void *arg1,void *arg2); +void update_env_cache(char *name,size_t name_len,uint32_t addr); +_Bool find_env_cb(env_node_obj_t env,void *arg1,void *arg2); +_Bool sector_statistics_cb(sector_meta_data_t sector,void *arg1,void *arg2); +_Bool alloc_env_cb(sector_meta_data_t sector,void *arg1,void *arg2); +EfErrCode write_status(uint32_t addr,uint8_t *status_table,size_t status_num,size_t status_index); +EfErrCode read_env(env_node_obj_t env); +EfErrCode update_sec_status(sector_meta_data_t sector,size_t new_env_len,_Bool *is_full); +EfErrCode format_sector(uint32_t addr); +_Bool check_sec_hdr_cb(sector_meta_data_t sector,void *arg1,void *arg2); +uint32_t get_next_env_addr(sector_meta_data_t sector,env_node_obj_t pre_env); +EfErrCode read_sector_meta_data(uint32_t addr,sector_meta_data_t sector,_Bool traversal); +void sector_iterator(sector_meta_data_t sector,sector_store_status_t status,void *arg1,void *arg2,anon_subr__Bool_sector_meta_data_t_void_ptr_void_ptr *callback,_Bool traversal_env); +uint32_t alloc_env(sector_meta_data_t sector,size_t env_size); +void gc_collect(void); +uint32_t new_env(sector_meta_data_t sector,size_t env_size); +_Bool check_and_recovery_gc_cb(sector_meta_data_t sector,void *arg1,void *arg2); +void env_iterator(env_node_obj_t env,void *arg1,void *arg2,anon_subr__Bool_env_node_obj_t_void_ptr_void_ptr *callback); +_Bool find_env(char *key,env_node_obj_t env); +EfErrCode del_env(char *key,env_node_obj_t old_env,_Bool complete_del); +EfErrCode move_env(env_node_obj_t env); +_Bool check_and_recovery_env_cb(env_node_obj_t env,void *arg1,void *arg2); +_Bool do_gc(sector_meta_data_t sector,void *arg1,void *arg2); +EfErrCode create_env_blob(sector_meta_data_t sector,char *key,void *value,size_t len); +size_t ef_get_env_blob(char *key,void *value_buf,size_t buf_len,size_t *saved_value_len); +EfErrCode ef_set_env_blob(char *key,void *value_buf,size_t buf_len); +EfErrCode ef_set_env(char *key,char *value); +EfErrCode ef_save_env(void); +EfErrCode ef_env_set_default(void); +EfErrCode ef_load_env(void); +EfErrCode ef_env_init(ef_env *default_env,size_t default_env_size); +EfErrCode ef_port_read(uint32_t addr,uint32_t *buf,size_t size); +EfErrCode ef_port_write(uint32_t addr,uint32_t *buf,size_t size); +void ef_port_env_lock(void); +void ef_port_env_unlock(void); +void ef_log_debug(char *file,long line,char *format,...); +EfErrCode ef_port_erase(uint32_t addr,size_t size); +void ef_log_info(char *format,...); +EfErrCode ef_port_init(ef_env **default_env,size_t *default_env_size); +uint32_t ef_calc_crc32(uint32_t crc,void *buf,size_t size); +EventGroupHandle_t xEventGroupCreateStatic(StaticEventGroup_t *pxEventGroupBuffer); +EventBits_t xEventGroupWaitBits(EventGroupHandle_t xEventGroup,EventBits_t uxBitsToWaitFor,BaseType_t xClearOnExit,BaseType_t xWaitForAllBits,TickType_t xTicksToWait); +EventBits_t xEventGroupSetBits(EventGroupHandle_t xEventGroup,EventBits_t uxBitsToSet); +void vEventGroupDelete(EventGroupHandle_t xEventGroup); +void vListInitialise(List_t *pxList); +void vListInitialiseItem(ListItem_t *pxItem); +void vListInsertEnd(List_t *pxList,ListItem_t *pxNewListItem); +void vListInsert(List_t *pxList,ListItem_t *pxNewListItem); +UBaseType_t uxListRemove(ListItem_t *pxItemToRemove); +BaseType_t prvCopyDataToQueue(Queue_t *pxQueue,void *pvItemToQueue,BaseType_t xPosition); +void prvCopyDataFromQueue(Queue_t *pxQueue,void *pvBuffer); +void prvUnlockQueue(Queue_t *pxQueue); +BaseType_t xQueueGenericReset(QueueHandle_t xQueue,BaseType_t xNewQueue); +QueueHandle_t xQueueGenericCreateStatic(UBaseType_t uxQueueLength,UBaseType_t uxItemSize,uint8_t *pucQueueStorage,StaticQueue_t *pxStaticQueue,uint8_t ucQueueType); +QueueHandle_t xQueueGenericCreate(UBaseType_t uxQueueLength,UBaseType_t uxItemSize,uint8_t ucQueueType); +QueueHandle_t xQueueCreateCountingSemaphore(UBaseType_t uxMaxCount,UBaseType_t uxInitialCount); +BaseType_t xQueueGenericSend(QueueHandle_t xQueue,void *pvItemToQueue,TickType_t xTicksToWait,BaseType_t xCopyPosition); +QueueHandle_t xQueueCreateMutexStatic(uint8_t ucQueueType,StaticQueue_t *pxStaticQueue); +QueueHandle_t xQueueCreateMutex(uint8_t ucQueueType); +BaseType_t xQueueGenericSendFromISR(QueueHandle_t xQueue,void *pvItemToQueue,BaseType_t *pxHigherPriorityTaskWoken,BaseType_t xCopyPosition); +BaseType_t xQueueGiveFromISR(QueueHandle_t xQueue,BaseType_t *pxHigherPriorityTaskWoken); +BaseType_t xQueueReceive(QueueHandle_t xQueue,void *pvBuffer,TickType_t xTicksToWait); +BaseType_t xQueueSemaphoreTake(QueueHandle_t xQueue,TickType_t xTicksToWait); +UBaseType_t uxQueueMessagesWaiting(QueueHandle_t xQueue); +void vQueueDelete(QueueHandle_t xQueue); +void vQueueAddToRegistry(QueueHandle_t xQueue,char *pcQueueName); +void vQueueWaitForMessageRestricted(QueueHandle_t xQueue,TickType_t xTicksToWait,BaseType_t xWaitIndefinitely); +void prvInitialiseNewStreamBuffer(StreamBuffer_t *pxStreamBuffer,uint8_t *pucBuffer,size_t xBufferSizeBytes,size_t xTriggerLevelBytes,uint8_t ucFlags); +size_t prvWriteBytesToBuffer(StreamBuffer_t *pxStreamBuffer,uint8_t *pucData,size_t xCount); +size_t prvReadBytesFromBuffer(StreamBuffer_t *pxStreamBuffer,uint8_t *pucData,size_t xMaxCount,size_t xBytesAvailable); +StreamBufferHandle_t xStreamBufferGenericCreate(size_t xBufferSizeBytes,size_t xTriggerLevelBytes,BaseType_t xIsMessageBuffer); +StreamBufferHandle_t xStreamBufferGenericCreateStatic(size_t xBufferSizeBytes,size_t xTriggerLevelBytes,BaseType_t xIsMessageBuffer,uint8_t *pucStreamBufferStorageArea,StaticStreamBuffer_t *pxStaticStreamBuffer); +void vStreamBufferDelete(StreamBufferHandle_t xStreamBuffer); +size_t xStreamBufferSpacesAvailable(StreamBufferHandle_t xStreamBuffer); +size_t xStreamBufferSend(StreamBufferHandle_t xStreamBuffer,void *pvTxData,size_t xDataLengthBytes,TickType_t xTicksToWait); +size_t xStreamBufferSendFromISR(StreamBufferHandle_t xStreamBuffer,void *pvTxData,size_t xDataLengthBytes,BaseType_t *pxHigherPriorityTaskWoken); +size_t xStreamBufferReceive(StreamBufferHandle_t xStreamBuffer,void *pvRxData,size_t xBufferLengthBytes,TickType_t xTicksToWait); +size_t xStreamBufferReceiveFromISR(StreamBufferHandle_t xStreamBuffer,void *pvRxData,size_t xBufferLengthBytes,BaseType_t *pxHigherPriorityTaskWoken); +BaseType_t xStreamBufferIsEmpty(StreamBufferHandle_t xStreamBuffer); +void prvResetNextTaskUnblockTime(void); +void prvInitialiseNewTask(TaskFunction_t *pxTaskCode,char *pcName,uint32_t ulStackDepth,void *pvParameters,UBaseType_t uxPriority,TaskHandle_t *pxCreatedTask,TCB_t *pxNewTCB); +void prvDeleteTCB(TCB_t *pxTCB); +void prvAddCurrentTaskToDelayedList(TickType_t xTicksToWait,BaseType_t xCanBlockIndefinitely); +void vTaskEnterCritical(void); +void vTaskExitCritical(void); +void prvAddNewTaskToReadyList(TCB_t *pxNewTCB); +TaskHandle_t xTaskCreateStatic(TaskFunction_t *pxTaskCode,char *pcName,uint32_t ulStackDepth,void *pvParameters,UBaseType_t uxPriority,StackType_t *puxStackBuffer,StaticTask_t *pxTaskBuffer); +BaseType_t xTaskCreate(TaskFunction_t *pxTaskCode,char *pcName,uint16_t usStackDepth,void *pvParameters,UBaseType_t uxPriority,TaskHandle_t *pxCreatedTask); +void vTaskDelete(TaskHandle_t xTaskToDelete); +void vTaskSuspendAll(void); +TickType_t xTaskGetTickCount(void); +BaseType_t xTaskGetTickCount2(TickType_t *ticks,BaseType_t *overflow); +TickType_t xTaskGetTickCountFromISR(void); +BaseType_t xTaskIncrementTick(void); +void vTaskDelay(TickType_t xTicksToDelay); +void vTaskSwitchContext(void); +void vTaskPlaceOnEventList(List_t *pxEventList,TickType_t xTicksToWait); +void vTaskPlaceOnUnorderedEventList(List_t *pxEventList,TickType_t xItemValue,TickType_t xTicksToWait); +void vTaskPlaceOnEventListRestricted(List_t *pxEventList,TickType_t xTicksToWait,BaseType_t xWaitIndefinitely); +BaseType_t xTaskRemoveFromEventList(List_t *pxEventList); +void vTaskRemoveFromUnorderedEventList(ListItem_t *pxEventListItem,TickType_t xItemValue); +void vTaskInternalSetTimeOutState(TimeOut_t *pxTimeOut); +void vTaskMissedYield(void); +void vTaskGetInfo(TaskHandle_t xTask,TaskStatus_t *pxTaskStatus,BaseType_t xGetFreeStackSpace,eTaskState eState); +UBaseType_t prvListTasksWithinSingleList(TaskStatus_t *pxTaskStatusArray,List_t *pxList,eTaskState eState); +UBaseType_t uxTaskGetSystemState(TaskStatus_t *pxTaskStatusArray,UBaseType_t uxArraySize,uint32_t *pulTotalRunTime); +TaskHandle_t xTaskGetCurrentTaskHandle(void); +BaseType_t xTaskGetSchedulerState(void); +BaseType_t xTaskPriorityInherit(TaskHandle_t pxMutexHolder); +BaseType_t xTaskPriorityDisinherit(TaskHandle_t pxMutexHolder); +void vTaskPriorityDisinheritAfterTimeout(TaskHandle_t pxMutexHolder,UBaseType_t uxHighestPriorityWaitingTask); +void vTaskEnterCritical(void); +void vTaskExitCritical(void); +void vTaskList(char *pcWriteBuffer); +TickType_t uxTaskResetEventItemValue(void); +TaskHandle_t pvTaskIncrementMutexHeldCount(void); +BaseType_t xTaskGenericNotifyFromISR(TaskHandle_t xTaskToNotify,uint32_t ulValue,eNotifyAction eAction,uint32_t *pulPreviousNotificationValue,BaseType_t *pxHigherPriorityTaskWoken); +void vTaskNotifyGiveFromISR(TaskHandle_t xTaskToNotify,BaseType_t *pxHigherPriorityTaskWoken); +BaseType_t xTaskNotifyStateClear(TaskHandle_t xTask); +void prvCheckForValidListAndQueue(void); +BaseType_t prvInsertTimerInActiveList(Timer_t *pxTimer,TickType_t xNextExpiryTime,TickType_t xTimeNow,TickType_t xCommandTime); +BaseType_t xTimerCreateTimerTask(void); +TimerHandle_t xTimerCreate(char *pcTimerName,TickType_t xTimerPeriodInTicks,UBaseType_t uxAutoReload,void *pvTimerID,TimerCallbackFunction_t *pxCallbackFunction); +TimerHandle_t xTimerCreateStatic(char *pcTimerName,TickType_t xTimerPeriodInTicks,UBaseType_t uxAutoReload,void *pvTimerID,TimerCallbackFunction_t *pxCallbackFunction,StaticTimer_t *pxTimerBuffer); +BaseType_t xTimerGenericCommand(TimerHandle_t xTimer,BaseType_t xCommandID,TickType_t xOptionalValue,BaseType_t *pxHigherPriorityTaskWoken,TickType_t xTicksToWait); +void prvSwitchTimerLists(void); +void prvTimerTask(void *pvParameters); +void * pvTimerGetTimerID(TimerHandle_t xTimer); +void vPortSetupTimerInterrupt(void); +void pxPortInitialiseStack(int param_1,undefined4 param_2,undefined4 param_3); +void prvInsertBlockIntoFreeList(BlockLink_t *pxBlockToInsert); +void * pvPortMalloc(size_t xWantedSize); +void vPortFree(void *pv); +size_t xPortGetFreeHeapSize(void); +void vPortDefineHeapRegions(HeapRegion_t *pxHeapRegions); +void uart_generic_notify_handler(uint8_t id); +void UART0_IRQHandler(void); +void UART1_IRQHandler(void); +int bl_uart_init(uint8_t id,uint8_t tx_pin,uint8_t rx_pin,uint8_t cts_pin,uint8_t rts_pin,uint32_t baudrate); +int bl_uart_data_send(uint8_t id,uint8_t data); +int bl_uart_data_recv(uint8_t id); +int bl_uart_int_rx_enable(uint8_t id); +int bl_uart_int_rx_disable(uint8_t id); +int bl_uart_int_tx_enable(uint8_t id); +int bl_uart_int_tx_disable(uint8_t id); +int bl_uart_flush(uint8_t id); +void bl_uart_getdefconfig(uint8_t id,uint8_t *parity); +void bl_uart_setconfig(uint8_t id,uint32_t baudrate,UART_Parity_Type parity); +void bl_uart_setbaud(uint8_t id,uint32_t baud); +int bl_uart_int_enable(uint8_t id); +int bl_uart_int_disable(uint8_t id); +int bl_uart_int_rx_notify_register(uint8_t id,cb_uart_notify_t *cb,void *arg); +int bl_uart_int_tx_notify_register(uint8_t id,cb_uart_notify_t *cb,void *arg); +int bl_chip_info(char *info); +int bl_chip_banner(char **banner); +int bl_chip_memory_ram(int *num,uint *addr,uint *size,char (*desc) [6]); +int bl_sys_reset_por(void); +void bl_sys_reset_system(void); +int bl_sys_isxipaddr(uint32_t addr); +int bl_sys_em_config(void); +int bl_sys_init(void); +void bl_dma_int_process(void); +int bl_dma_int_clear(int ch); +void bl_dma_IRQHandler(void); +int bl_dma_irq_register(int channel,void *tc_handler,void *interr_handler,void *ctx); +void bl_dma_init(void); +void _irq_num_check(int irqnum); +void bl_irq_enable(uint source); +void bl_irq_disable(uint source); +void bl_irq_pending_clear(uint source); +void bl_irq_register_with_ctx(int irqnum,void *handler,void *ctx); +void bl_irq_ctx_get(int irqnum,void **ctx); +void bl_irq_register(int irqnum,void *handler); +void bl_irq_unregister(int irqnum,void *handler); +void interrupt_entry(uint32_t mcause); +void exception_entry(uint32_t mcause,uint32_t mepc,uint32_t mtval,uintptr_t *regs); +void bl_irq_init(void); +void _trng_trigger(void); +void wait_trng4feed(void); +void sec_trng_IRQHandler(uint param_1,int param_2); +uint32_t bl_sec_get_random_word(void); +void bl_rand_stream(uint8_t *buf,int len); +int bl_rand(void); +int bl_sec_init(void); +int bl_sec_test(void); +int bl_efuse_read_mac(uint8_t *mac); +int bl_efuse_read_mac_factory(uint8_t *mac); +int bl_efuse_read_capcode(uint8_t *capcode); +int bl_efuse_read_pwroft(int8_t *poweroffset); +int bl_wifi_clock_enable(void); +int bl_wifi_enable_irq(void); +int bl_wifi_sta_mac_addr_set(uint8_t *mac); +int bl_wifi_ap_mac_addr_set(uint8_t *mac); +int bl_wifi_mac_addr_get(uint8_t *mac); +int bl_wifi_country_code_set(uint8_t country_code); +int bl_wifi_ap_info_set(uint8_t *ssid,uint8_t ssid_len,uint8_t *psk,uint8_t psk_len,uint8_t chan); +int bl_wifi_sta_info_set(uint8_t *ssid,uint8_t ssid_len,uint8_t *psk,uint8_t psk_len,int autoconnect); +uint32_t fdt32_to_cpu(fdt32_t x); +int dev_uart_init(uint8_t id,char *path,uint32_t rx_buf_size,uint32_t tx_buf_size); +int32_t hal_uart_send_trigger(uart_dev_t *uart); +int32_t hal_uart_send_trigger_off(uart_dev_t *uart); +int32_t hal_uart_init(uart_dev_t *uart); +int32_t hal_uart_recv_II(uart_dev_t *uart,void *data,uint32_t expect_size,uint32_t *recv_size,uint32_t timeout); +int32_t hal_uart_send(uart_dev_t *uart,void *data,uint32_t size,uint32_t timeout); +int32_t hal_uart_finalize(uart_dev_t *uart); +int32_t hal_uart_notify_register(uart_dev_t *uart,hal_uart_int_t type,anon_subr_void_void_ptr *cb); +undefined4 vfs_uart_init(void *param_1,int param_2); +int32_t hal_uart_send_flush(uart_dev_t *uart,uint32_t timeout); +void hal_uart_setbaud(uart_dev_t *uart,uint32_t baud); +void hal_uart_setconfig(uart_dev_t *uart,uint32_t baud,hal_uart_parity_t parity); +undefined4 hal_gpio_init_from_dts(void *param_1,int param_2); +int hal_reboot(void); +void hal_sys_reset(void); +void hal_poweroff(void); +void hal_sys_capcode_update(uint8_t capin,uint8_t capout); +uint8_t hal_sys_capcode_get(void); +uint32_t fdt32_to_cpu(fdt32_t x); +uint32_t hal_board_get_factory_addr(void); +undefined4 hal_board_cfg(void); +void bl_tsen_adc_get(void); +int hal_wifi_start_firmware_task(void); +int bl_gpio_enable_output(uint8_t pin,uint8_t pullup,uint8_t pulldown); +int bl_gpio_output_set(uint8_t pin,uint8_t value); +void proc_entry_looprt(void *pvParameters); +void looprt_evt_notify_async(uint task,uint32_t evt_map); +void looprt_evt_status_dump(void); +int looprt_start(StackType_t *proc_stack_looprt,int stack_count,StaticTask_t *proc_task_looprt); +int looprt_handler_register(loop_evt_handler *handler,int priority); +int looprt_timer_register(loop_timer *timer); +void _cb_led_trigger(loop_ctx *loop,loop_timer *timer,void *arg); +int _led_bloop_msg(loop_ctx *loop,loop_evt_handler *handler,loop_msg *msg); +int _led_bloop_evt(loop_ctx *loop,loop_evt_handler *handler,uint32_t *bitmap_evt,uint32_t *evt_type_map); +int loopset_led_hook_on_looprt(void); +void loopset_led_trigger(int pin,uint timeon_ms); +err_t netifapi_do_netif_add(tcpip_api_call_data *m); +err_t netifapi_do_netif_set_addr(tcpip_api_call_data *m); +err_t netifapi_do_netif_common(tcpip_api_call_data *m); +err_t netifapi_netif_add(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw,void *state,netif_init_fn init,netif_input_fn *input); +err_t netifapi_netif_set_addr(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw); +err_t netifapi_netif_common(netif *netif,netifapi_void_fn voidfunc,netifapi_errt_fn errtfunc); +void tcpip_thread(void *arg); +err_t tcpip_inpkt(pbuf *p,netif *inp,netif_input_fn *input_fn); +err_t tcpip_input(pbuf *p,netif *inp); +err_t tcpip_try_callback(tcpip_callback_fn function,void *ctx); +err_t tcpip_api_call(tcpip_api_call_fn *fn,tcpip_api_call_data *call); +void tcpip_init(tcpip_init_done_fn initfunc,void *arg); +u16_t lwip_htons(u16_t n); +u32_t lwip_htonl(u32_t n); +void dns_call_found(u8_t idx,ip_addr_t *addr); +err_t dns_send(u8_t idx); +void dns_check_entry(u8_t i); +void dns_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port); +void dns_init(void); +void dns_setserver(u8_t numdns,ip_addr_t *dnsserver); +ip_addr_t * dns_getserver(u8_t numdns); +void dns_tmr(void); +void lwip_init(void); +void dhcp_set_state(dhcp *dhcp,u8_t new_state); +u16_t dhcp_option_short(u16_t options_out_len,u8_t *options,u16_t value); +u16_t dhcp_option_long(u16_t options_out_len,u8_t *options,u32_t value); +pbuf * dhcp_create_msg(netif *netif,dhcp *dhcp,u8_t message_type,u16_t *options_out_len); +void dhcp_option_trailer(u16_t options_out_len,u8_t *options,pbuf *p_out); +err_t dhcp_discover(netif *netif); +void dhcp_check(netif *netif); +void dhcp_bind(netif *netif); +err_t dhcp_inc_pcb_refcount(void); +u16_t dhcp_option_hostname(u16_t options_out_len,u8_t *options); +err_t dhcp_reboot(netif *netif); +err_t dhcp_select(netif *netif); +void dhcp_dec_pcb_refcount(void); +void dhcp_handle_ack(dhcp_msg *msg_in); +void dhcp_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *addr,u16_t port); +void dhcp_network_changed(netif *netif); +void dhcp_arp_reply(netif *netif,ip4_addr_t *addr); +err_t dhcp_renew(netif *netif); +u8_t dhcp_supplied_address(netif *netif); +void dhcp_release_and_stop(netif *netif); +err_t dhcp_start(netif *netif); +void dhcp_coarse_tmr(void); +void dhcp_fine_tmr(void); +void dhcp_stop(netif *netif); +void etharp_free_entry(int i); +s16_t etharp_find_entry(ip4_addr_t *ipaddr,u8_t flags,netif *netif); +err_t etharp_raw(netif *netif,eth_addr *ethsrc_addr,eth_addr *ethdst_addr,eth_addr *hwsrc_addr,ip4_addr_t *ipsrc_addr,eth_addr *hwdst_addr,ip4_addr_t *ipdst_addr,u16_t opcode); +void etharp_cleanup_netif(netif *netif); +void etharp_input(pbuf *p,netif *netif); +err_t etharp_request(netif *netif,ip4_addr_t *ipaddr); +void etharp_tmr(void); +err_t etharp_output_to_arp_index(netif *netif,pbuf *q,netif_addr_idx_t arp_idx); +err_t etharp_query(netif *netif,ip4_addr_t *ipaddr,pbuf *q); +err_t etharp_output(netif *netif,pbuf *q,ip4_addr_t *ipaddr); +void igmp_send(netif *netif,igmp_group *group,u8_t type); +void igmp_delaying_member(igmp_group *group,u8_t maxresp); +void igmp_init(void); +err_t igmp_stop(netif *netif); +void igmp_report_groups(netif *netif); +igmp_group * igmp_lookfor_group(netif *ifp,ip4_addr_t *addr); +igmp_group * igmp_lookup_group(netif *ifp,ip4_addr_t *addr); +err_t igmp_start(netif *netif); +void igmp_input(pbuf *p,netif *inp,ip4_addr_t *dest); +void igmp_tmr(void); +int ip4_input_accept(netif *netif); +netif * ip4_route(ip4_addr_t *dest); +err_t ip4_input(pbuf *p,netif *inp); +err_t ip4_output_if_opt_src(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto,netif *netif,void *ip_options,u16_t optlen); +err_t ip4_output_if_opt(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto,netif *netif,void *ip_options,u16_t optlen); +err_t ip4_output_if(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto,netif *netif); +err_t ip4_output_if_src(pbuf *p,ip4_addr_t *src,ip4_addr_t *dest,u8_t ttl,u8_t tos,u8_t proto,netif *netif); +u8_t ip4_addr_isbroadcast_u32(u32_t addr,netif *netif); +int ip4addr_aton(char *cp,ip4_addr_t *addr); +u32_t ipaddr_addr(char *cp); +char * ip4addr_ntoa_r(ip4_addr_t *addr,char *buf,int buflen); +char * ip4addr_ntoa(ip4_addr_t *addr); +void mem_init(void); +void mem_free(uint param_1); +mem * mem_trim(mem *param_1,uint param_2); +mem_size_t * mem_malloc(uint param_1); +void * do_memp_malloc_pool(memp_desc *desc); +void memp_init_pool(memp_desc *desc); +void memp_init(void); +void * memp_malloc(memp_t type); +void memp_free(memp_t type,void *mem); +err_t netif_null_output_ip4(netif *netif,pbuf *p,ip4_addr_t *ipaddr); +void netif_issue_reports(netif *netif,u8_t report_type); +int netif_do_set_ipaddr(netif *netif,ip4_addr_t *ipaddr,ip_addr_t *old_addr); +void netif_init(void); +void netif_set_ipaddr(netif *netif,ip4_addr_t *ipaddr); +void netif_set_netmask(netif *netif,ip4_addr_t *netmask); +void netif_set_gw(netif *netif,ip4_addr_t *gw); +void netif_set_addr(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw); +netif * netif_add(netif *netif,ip4_addr_t *ipaddr,ip4_addr_t *netmask,ip4_addr_t *gw,void *state,netif_init_fn.conflict *init,netif_input_fn *input); +void netif_set_default(netif *netif); +void netif_set_up(netif *netif); +void netif_set_down(netif *netif); +void netif_remove(netif *netif); +void netif_set_status_callback(netif *netif,netif_status_callback_fn *status_callback); +void netif_set_link_up(netif *netif); +void netif_set_link_down(netif *netif); +netif * netif_get_by_index(u8_t idx); +pbuf * pbuf_skip_const(pbuf *in,u16_t in_offset,u16_t *out_offset); +void pbuf_free_ooseq_callback(void *arg); +u8_t pbuf_add_header_impl(pbuf *p,size_t header_size_increment,u8_t force); +pbuf * pbuf_alloc_reference(void *payload,u16_t length,pbuf_type type); +pbuf * pbuf_alloced_custom(pbuf_layer l,u16_t length,pbuf_type type,pbuf_custom *p,void *payload_mem,u16_t payload_mem_len); +u8_t pbuf_add_header(pbuf *p,size_t header_size_increment); +u8_t pbuf_remove_header(pbuf *p,size_t header_size_decrement); +u8_t pbuf_header(pbuf *p,s16_t header_size_increment); +u8_t pbuf_header_force(pbuf *p,s16_t header_size_increment); +u8_t pbuf_free(pbuf *p); +pbuf * pbuf_alloc(pbuf_layer layer,u16_t length,pbuf_type type); +void pbuf_realloc(pbuf *p,u16_t new_len); +u16_t pbuf_clen(pbuf *p); +void pbuf_ref(pbuf *p); +void pbuf_cat(pbuf *h,pbuf *t); +void pbuf_chain(pbuf *h,pbuf *t); +err_t pbuf_copy(pbuf *p_to,pbuf *p_from); +u16_t pbuf_copy_partial(pbuf *buf,void *dataptr,u16_t len,u16_t offset); +err_t pbuf_take(pbuf *buf,void *dataptr,u16_t len); +err_t pbuf_take_at(pbuf *buf,void *dataptr,u16_t len,u16_t offset); +pbuf * pbuf_clone(pbuf_layer layer,pbuf_type type,pbuf *p); +int pbuf_try_get_at(pbuf *p,u16_t offset); +void pbuf_put_at(pbuf *p,u16_t offset,u8_t data); +raw_input_state_t raw_input(pbuf *p,netif *inp); +void raw_netif_ip_addr_changed(ip_addr_t *old_addr,ip_addr_t *new_addr); +void stats_init(void); +err_t tcp_close_shutdown_fin(tcp_pcb *pcb); +void tcp_init(void); +void tcp_free(tcp_pcb *pcb); +u32_t tcp_update_rcv_ann_wnd(tcp_pcb *pcb); +void tcp_recved(tcp_pcb *pcb,u16_t len); +void tcp_seg_free(tcp_seg *seg); +void tcp_segs_free(tcp_seg *seg); +tcp_seg * tcp_seg_copy(tcp_seg *seg); +u32_t tcp_next_iss(tcp_pcb *pcb); +u16_t tcp_eff_send_mss_netif(u16_t sendmss,netif *outif,ip_addr_t *dest); +void tcp_free_ooseq(tcp_pcb *pcb); +void tcp_pcb_purge(tcp_pcb *pcb); +void tcp_pcb_remove(tcp_pcb **pcblist,tcp_pcb *pcb); +void tcp_abandon(tcp_pcb *pcb,int reset); +void tcp_abort(tcp_pcb *pcb); +void tcp_netif_ip_addr_changed_pcblist(tcp_pcb *pcb_list); +void tcp_netif_ip_addr_changed(ip_addr_t *old_addr,ip_addr_t *new_addr); +void tcp_kill_state(tcp_state state); +tcp_pcb * tcp_alloc(u8_t prio); +err_t tcp_close_shutdown(tcp_pcb *pcb,u8_t rst_on_unacked_data); +err_t tcp_close(tcp_pcb *pcb); +err_t tcp_recv_null(void *arg,tcp_pcb *pcb,pbuf *p,err_t err); +err_t tcp_process_refused_data(tcp_pcb *pcb); +void tcp_fasttmr(void); +void tcp_slowtmr(void); +void tcp_tmr(void); +u8_t tcp_get_next_optbyte(void); +void tcp_oos_insert_segment(tcp_seg *cseg,tcp_seg *next); +void tcp_parseopt(undefined2 *param_1); +int tcp_input_delayed_close(tcp_pcb *pcb); +tcp_seg * tcp_free_acked_segments(tcp_seg *seg_list); +void tcp_receive(tcp_pcb *pcb); +void tcp_input(pbuf *p,netif *inp); +void tcp_trigger_input_pcb_close(void); +void tcp_seg_add_chksum(u16_t chksum,u16_t len,u16_t *seg_chksum,u8_t *seg_chksum_swapped); +tcp_seg * tcp_create_segment(tcp_pcb *pcb,pbuf *p,u8_t hdrflags,u32_t seqno,u8_t optflags); +pbuf * tcp_output_alloc_header_common(u32_t ackno,u16_t datalen,u32_t seqno_be,u16_t src_port,u16_t dst_port,u8_t flags,u16_t wnd); +pbuf * tcp_output_alloc_header(tcp_pcb *pcb,u16_t datalen,u32_t seqno_be); +err_t tcp_output_control_segment(tcp_pcb *pcb,pbuf *p,ip_addr_t *src,ip_addr_t *dst); +err_t tcp_split_unsent_seg(tcp_pcb *pcb,u16_t split); +err_t tcp_enqueue_flags(tcp_pcb *pcb,u8_t flags); +err_t tcp_send_fin(tcp_pcb *pcb); +err_t tcp_rexmit_rto_prepare(tcp_pcb *pcb); +err_t tcp_rexmit(tcp_pcb *pcb); +void tcp_rexmit_fast(tcp_pcb *pcb); +void tcp_rst(tcp_pcb *pcb,u32_t seqno,u32_t ackno,ip_addr_t *param_4,ip_addr_t *remote_ip,u16_t param_6,u16_t remote_port); +err_t tcp_send_empty_ack(tcp_pcb *pcb); +err_t tcp_output(tcp_pcb *pcb); +void tcp_rexmit_rto_commit(tcp_pcb *pcb); +void tcp_rexmit_rto(tcp_pcb *pcb); +err_t tcp_keepalive(tcp_pcb *pcb); +err_t tcp_zero_window_probe(tcp_pcb *pcb); +void sys_timeout_abs(u32_t abs_time,sys_timeout_handler *handler,void *arg); +void lwip_cyclic_timer(void *arg); +void sys_timeout(u32_t msecs,sys_timeout_handler *handler,void *arg); +void tcp_timer_needed(void); +void tcpip_tcp_timer(void *arg); +void sys_timeouts_init(void); +void sys_check_timeouts(void); +u32_t sys_timeouts_sleeptime(void); +void udp_init(void); +void udp_input(pbuf *p,netif *inp); +err_t udp_bind(udp_pcb *pcb,ip_addr_t *ipaddr,u16_t port); +err_t udp_sendto_if_src_chksum(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif,u8_t have_chksum,u16_t chksum,ip_addr_t *src_ip); +err_t udp_sendto_if_chksum(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif,u8_t have_chksum,u16_t chksum); +err_t udp_sendto_chksum(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,u8_t have_chksum,u16_t chksum); +err_t udp_sendto(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port); +err_t udp_sendto_if(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif); +err_t udp_sendto_if_src(udp_pcb *pcb,pbuf *p,ip_addr_t *dst_ip,u16_t dst_port,netif *netif,ip_addr_t *src_ip); +err_t udp_connect(udp_pcb *pcb,ip_addr_t *ipaddr,u16_t port); +void udp_recv(udp_pcb *pcb,udp_recv_fn *recv,void *recv_arg); +void udp_remove(udp_pcb *pcb); +udp_pcb * udp_new(void); +udp_pcb * udp_new_ip_type(void); +void udp_netif_ip_addr_changed(ip_addr_t *old_addr,ip_addr_t *new_addr); +err_t ethernet_input(pbuf *p,netif *netif); +err_t ethernet_output(netif *netif,pbuf *p,eth_addr *src,eth_addr *dst,u16_t eth_type); +err_t sys_mbox_new(sys_mbox_t *mbox,int size); +void sys_mbox_post(sys_mbox_t *mbox,void *data); +err_t sys_mbox_trypost(sys_mbox_t *mbox,void *msg); +u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox,void **msg,u32_t timeout); +uint sys_mbox_valid(int *param_1); +err_t sys_sem_new(sys_sem_t *sem,u8_t count); +u32_t sys_arch_sem_wait(sys_sem_t *sem,u32_t timeout); +void sys_sem_free(sys_sem_t *sem); +void sys_init(void); +err_t sys_mutex_new(sys_mutex_t *mutex); +void sys_mutex_lock(sys_mutex_t *mutex); +void sys_mutex_unlock(sys_mutex_t *mutex); +void sys_sem_signal(sys_mutex_t *mutex); +sys_thread_t sys_thread_new(char *name,lwip_thread_fn *thread,void *arg,int stacksize,int prio); +sys_prot_t sys_arch_protect(void); +void sys_arch_unprotect(void); +TickType_t sys_now(void); +u16_t lwip_standard_chksum(void *dataptr,int len); +u16_t inet_chksum_pseudo(pbuf *p,u8_t proto,u16_t proto_len,ip4_addr_t *src,ip4_addr_t *dest); +u16_t ip_chksum_pseudo(pbuf *p,u8_t proto,u16_t proto_len,ip4_addr_t *src,ip4_addr_t *dest); +u16_t inet_chksum_pseudo_partial(pbuf *p,u8_t proto,u16_t proto_len,u16_t chksum_len,ip4_addr_t *src,ip4_addr_t *dest); +u16_t ip_chksum_pseudo_partial(pbuf *p,u8_t proto,u16_t proto_len,u16_t chksum_len,ip4_addr_t *src,ip4_addr_t *dest); +u16_t inet_chksum(void *dataptr,u16_t len); +u16_t inet_chksum_pbuf(pbuf *p); +void icmp_input(pbuf *p,netif *inp); +void icmp_dest_unreach(pbuf *p,icmp_dur_type t); +u8_t * dhcp_server_option_find(u8_t *buf,u16_t len,u8_t option); +dhcp_client_node * dhcp_client_find_by_ip(uint8_t *ip); +void dhcp_server_recv(void *arg,udp_pcb *pcb,pbuf *p,ip_addr_t *recv_addr,u16_t port); +err_t dhcp_server_start(netif *netif,ip4_addr_t *start,ip4_addr_t *end); +err_t dhcp_server_stop(netif *netif); +void dhcpd_start(netif *netif); +int dirent_type(void *addr); +uint32_t dirent_hardfh(void *addr); +uint32_t dirent_childaddr(void *addr); +uint32_t dirent_size(void *addr); +int romfs_close(file_t *fp); +int romfs_ioctl(file_t *fp,int cmd,ulong arg); +ssize_t romfs_read(file_t *fp,char *buf,size_t length); +undefined4 file_info(char *param_1,char **param_2,char **param_3); +int romfs_closedir(file_t *fp,aos_dir_t *dir); +off_t romfs_lseek(file_t *fp,off_t off,int whence); +aos_dirent_t * romfs_readdir(file_t *fp,aos_dir_t *dir); +uint32_t dirent_file(char *path,void **p_addr_start_input,void **p_addr_end_input); +aos_dir_t * romfs_opendir(file_t *fp,char *path); +int romfs_stat(file_t *fp,char *path,stat *st); +int romfs_open(file_t *fp,char *path,int flags); +int romfs_register(void); +char * utils_bin2hex(char *dst,void *src,size_t count); +int utils_dns_domain_get(uint8_t *records,uint8_t *buf,int *len); +void utils_list_init(utils_list *list); +void utils_list_push_back(utils_list *list,utils_list_hdr *list_hdr); +utils_list_hdr * utils_list_pop_front(utils_list *list); +void utils_hexdump(void *mem,uint len); +int utils_getopt_init(getopt_env_t *env,int opterr); +int utils_getopt(getopt_env_t *env,int argc,char **argv,char *optstring); +int params_filter(uint32_t *r); +void get_bytearray_from_string(char **params,uint8_t *result,int array_size); +void get_uint8_from_string(char **params,uint8_t *result); +void get_uint16_from_string(char **params,uint16_t *result); +int utils_tlv_bl_pack_auto(uint32_t *buf,int buf_sz,uint16_t type,void *arg1); +int utils_tlv_bl_unpack_auto(uint32_t *buf,int buf_sz,uint16_t type,void *arg1); +int aos_register_driver(char *path,file_ops_t *ops,void *arg); +int aos_register_fs(char *path,fs_ops_t *ops,void *arg); +int vfs_uart_open(inode_t *inode,file_t *fp); +void __uart_rx_irq(void *p_arg); +void __uart_tx_irq(void *p_arg); +int vfs_uart_close(file_t *fp); +ssize_t vfs_uart_read(file_t *fp,void *buf,size_t nbytes); +ssize_t vfs_uart_write(file_t *fp,void *buf,size_t nbytes); +int vfs_uart_poll(file_t *fp,_Bool setup,poll_notify_t *notify,pollfd *fd,void *opa); +int vfs_uart_sync(file_t *fp); +int uart_ioctl_cmd_waimode(uart_dev_t *uart_dev,int cmd,ulong arg); +int uart_ioctl_cmd_setconfig(uart_dev_t *uart_dev,ulong arg); +int vfs_uart_ioctl(file_t *fp,int cmd,ulong arg); +BL_Err_Type UART_Init(UART_ID_Type uartId,UART_CFG_Type *uartCfg); +BL_Err_Type UART_FifoConfig(UART_ID_Type uartId,UART_FifoCfg_Type *fifoCfg); +BL_Err_Type UART_Enable(UART_ID_Type uartId,UART_Direction_Type direct); +BL_Err_Type UART_Disable(UART_ID_Type uartId,UART_Direction_Type direct); +BL_Err_Type UART_SetRxTimeoutValue(UART_ID_Type uartId,uint8_t time); +BL_Err_Type UART_TxFreeRun(UART_ID_Type uartId,BL_Fun_Type txFreeRun); +BL_Err_Type UART_IntMask(UART_ID_Type uartId,UART_INT_Type intType,BL_Mask_Type intMask); +uint8_t UART_GetTxFifoCount(UART_ID_Type uartId); +BL_Err_Type UART_SendData(UART_ID_Type uartId,uint8_t *data,uint32_t len); +uint8_t UART_GetRxFifoCount(UART_ID_Type uartId); +void ADC_Reset(void); +void ADC_Enable(void); +void ADC_Disable(void); +void ADC_Channel_Config(ADC_Chan_Type posCh,ADC_Chan_Type negCh,BL_Fun_Type contEn); +void ADC_Start(void); +void ADC_FIFO_Cfg(ADC_FIFO_Cfg_Type *fifoCfg); +uint8_t ADC_Get_FIFO_Count(void); +void ADC_Parse_Result(uint32_t *orgVal,uint32_t len,ADC_Result_Type *result); +void ADC_Tsen_Init(ADC_TSEN_MOD_Type tsenMod); +void ADC_SET_TSVBE_LOW(void); +void ADC_SET_TSVBE_HIGH(void); +uint32_t TSEN_Get_V_Error(void); +float TSEN_Get_Temp(uint32_t tsen_offset); +void ADC_Init(ADC_CFG_Type *cfg); +BL_Err_Type Sec_Eng_SHA256_Update(SEC_Eng_SHA256_Ctx *shaCtx,uint8_t *input,uint32_t len); +void Sec_Eng_SHA256_Init(SEC_Eng_SHA256_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,SEC_ENG_SHA_Type shaType,uint32_t *shaTmpBuf,uint32_t *padding); +void Sec_Eng_SHA_Start(SEC_ENG_SHA_ID_Type shaNo); +BL_Err_Type Sec_Eng_SHA256_Update(SEC_Eng_SHA256_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,uint8_t *input,uint32_t len); +BL_Err_Type Sec_Eng_SHA256_Finish(SEC_Eng_SHA256_Ctx *shaCtx,SEC_ENG_SHA_ID_Type shaNo,uint8_t *hash); +void DMA_Enable(void); +void DMA_Channel_Enable(uint8_t ch); +void DMA_LLI_Init(uint8_t ch,DMA_LLI_Cfg_Type *lliCfg); +void DMA_LLI_Update(uint8_t ch,uint32_t LLI); +void DMA_IntMask(uint8_t ch,DMA_INT_Type intType,BL_Mask_Type intMask); +void Default_Handler(void); +BL_Err_Type GLB_Set_UART_CLK(uint8_t enable,HBN_UART_CLK_Type clkSel,uint8_t div); +BL_Err_Type GLB_Set_EM_Sel(GLB_EM_Type emType); +BL_Err_Type GLB_Set_ADC_CLK(uint8_t enable,GLB_ADC_CLK_Type clkSel,uint8_t div); +BL_Err_Type GLB_UART_Fun_Sel(GLB_UART_SIG_Type sig,GLB_UART_SIG_FUN_Type fun); +BL_Err_Type GLB_GPIO_Write(GLB_GPIO_Type gpioPin,uint32_t val); +BL_Err_Type HBN_Set_UART_CLK_Sel(HBN_UART_CLK_Type clkSel); +BL_Err_Type HBN_Get_RTC_Timer_Val(uint32_t *valLow,uint32_t *valHigh); +BL_Err_Type HBN_Aon_Pad_IeSmt_Cfg(uint8_t padCfg); +uint32_t EF_Ctrl_Get_Byte_Zero_Cnt(uint8_t val); +BL_Err_Type EF_Ctrl_Read_MAC_Address(uint8_t *mac); +uint8_t EF_Ctrl_Is_MAC_Address_Slot_Empty(uint8_t slot,uint8_t reload); +BL_Err_Type EF_Ctrl_Read_MAC_Address_Opt(uint8_t slot,uint8_t *mac,uint8_t reload); +uint EF_Ctrl_Is_CapCode_Slot_Empty(int param_1,int param_2); +BL_Err_Type EF_Ctrl_Read_CapCode_Opt(uint8_t slot,uint8_t *code,uint8_t reload); +uint8_t EF_Ctrl_Is_PowerOffset_Slot_Empty(uint8_t slot,uint8_t reload); +BL_Err_Type EF_Ctrl_Read_PowerOffset_Opt(uint8_t slot,int8_t *pwrOffset,uint8_t reload); +int8_t mfg_media_read_xtal_capcode(uint8_t *capcode,uint8_t reload); +int8_t mfg_media_read_poweroffset(int8_t *pwrOffset,uint8_t reload); +int8_t mfg_media_read_macaddr(uint8_t *mac,uint8_t reload); +void bflb_platform_usart_dbg_send(uint8_t *data,uint32_t len); +void bflb_platform_printf(char *fmt,...); +void Default_Handler_Stub(void); +int8_t mfg_efuse_read_xtal_capcode(uint8_t *capcode,uint8_t reload); +int8_t mfg_efuse_read_poweroffset(int8_t *pwrOffset,uint8_t reload); +int8_t mfg_efuse_read_macaddr(uint8_t *mac,uint8_t reload); +int8_t mfg_flash_read_xtal_capcode(uint8_t *capcode,uint8_t reload); +int8_t mfg_flash_read_poweroffset(int8_t *pwrOffset,uint8_t reload); +int8_t mfg_flash_read_macaddr(uint8_t *mac,uint8_t reload); +void hal_mib_dump(void); +int mm_monitor_channel_req_handler(ke_msg_id_t msgid,mm_monitor_channel_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_monitor_enable_req_handler(ke_msg_id_t msgid,mm_monitor_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_cfg_rssi_req_handler(ke_msg_id_t msgid,mm_cfg_rssi_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_ps_options_req_handler(ke_msg_id_t msgid,mm_set_ps_options_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_tim_update_req_handler(ke_msg_id_t msgid,mm_tim_update_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_bcn_change_req_handler(ke_msg_id_t msgid,mm_bcn_change_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_remain_on_channel_req_handler(ke_msg_id_t msgid,mm_remain_on_channel_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_sta_del_req_handler(ke_msg_id_t msgid,mm_sta_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_sta_add_req_handler(ke_msg_id_t msgid,mm_sta_add_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_key_del_req_handler(ke_msg_id_t msgid,mm_key_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_key_add_req_handler(ke_msg_id_t msgid,mm_key_add_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_power_req_handler(ke_msg_id_t msgid,mm_set_power_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_idle_req_handler(ke_msg_id_t msgid,mm_set_idle_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_version_req_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_start_req_handler(ke_msg_id_t msgid,mm_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_ps_mode_req_handler(ke_msg_id_t msgid,mm_set_ps_mode_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_force_idle_req_handler(ke_msg_id_t msgid,mm_force_idle_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_hw_config_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int bl60x_edca_get(int ac,uint8_t *aifs,uint8_t *cwmin,uint8_t *cwmax,uint16_t *txop); +_Bool cmp_abs_time(co_list_hdr *timerA,co_list_hdr *timerB); +void mm_timer_init(void); +void mm_timer_set(mm_timer_tag *timer,uint32_t value); +void mm_timer_clear(mm_timer_tag *timer); +void mm_timer_schedule(int dummy); +void ps_uapsd_timer_handle(void *env); +void blmac_pwr_mgt_setf(uint8_t pwrmgt); +void ps_dpsm_update(_Bool pause); +uint8_t ps_send_pspoll(vif_info_tag *vif_entry); +void ps_init(void); +void ps_set_mode(uint8_t mode,ke_task_id_t taskid); +void ps_enable_cfm(void *env,uint32_t status); +void ps_disable_cfm(void *env,uint32_t status); +uint8_t ps_polling_frame(vif_info_tag *vif_entry); +void ps_check_beacon(int param_1,vif_info_tag *param_2); +void ps_check_frame(uint8_t *frame,uint32_t statinfo,vif_info_tag *vif_entry); +void ps_check_tx_frame(uint8_t staid,uint8_t tid); +void ps_uapsd_set(vif_info_tag *vif_entry,uint8_t hw_queue,_Bool uapsd); +void ps_traffic_status_update(uint8_t vif_index,uint8_t new_status); +void mm_ps_change_ind(uint8_t sta_idx,uint8_t ps_state); +void rxl_mpdu_transfer(rx_swdesc *swdesc); +void rxl_init(void); +void rxl_cntrl_dump(void); +void rxl_timer_int_handler(void); +void rxl_timeout_int_handler(void); +void rxl_dma_int_handler(void); +void rxl_dma_evt(int dummy); +void rxl_frame_release(rx_swdesc *swdesc); +void rxl_mpdu_free(rx_swdesc *swdesc); +void bl60x_firmwre_mpdu_free(void *swdesc_ptr); +void rxl_reset(void); +void rxl_hwdesc_dump(void); +void rxl_hwdesc_init(int init); +void rxl_hd_append(rx_dmadesc *desc); +void rxl_pd_append(rx_pbd *first,rx_pbd *last,rx_pbd *spare); +void sta_mgmt_entry_init(sta_info_tag *sta_entry); +void sta_mgmt_init(void); +uint8_t sta_mgmt_register(mm_sta_add_req *param,uint8_t *sta_idx); +void sta_mgmt_unregister(uint8_t sta_idx); +void sta_mgmt_add_key(mm_key_add_req *param,uint8_t hw_key_idx); +void sta_mgmt_del_key(sta_info_tag *sta); +int sta_mgmt_send_postponed_frame(vif_info_tag *p_vif_entry,sta_info_tag *p_sta_entry,int limit); +void td_timer_end(void *env); +void td_reset(uint8_t vif_index); +void td_init(void); +void td_start(uint8_t vif_index); +void td_pck_ind(uint8_t vif_index,uint8_t sta_index,_Bool rx); +void td_pck_ps_ind(uint8_t vif_index,_Bool rx); +void bl_tpc_update_power_table(int8_t *power_table); +void bl_tpc_power_table_get(int8_t *power_table_config); +void bl_tpc_update_power_rate_11b(int8_t *power_rate_table); +void bl_tpc_update_power_rate_11g(int8_t *power_rate_table); +void bl_tpc_update_power_rate_11n(int8_t *power_rate_table); +void tpc_update_tx_power(int8_t pwr); +void tpc_update_vif_tx_power(vif_info_tag *vif,int8_t *pwr,uint8_t *idx); +uint8_t tpc_get_vif_tx_power_vs_rate(uint32_t rate_config); +void tpc_update_frame_tx_power(vif_info_tag *vif,txl_frame_desc_tag *frame); +void txl_int_fake_transfer(txdesc *txdesc,uint8_t access_category); +void blmac_abs_timer_set(int reg_idx,uint32_t value); +void txl_machdr_format(uint32_t machdrptr); +void txl_cntrl_init(void); +_Bool txl_cntrl_tx_check(vif_info_tag *p_vif_entry); +void txl_cntrl_halt_ac(uint8_t access_category); +void txl_cntrl_flush_ac(uint8_t access_category,uint32_t status); +void txl_cntrl_inc_pck_cnt(void); +void txl_payload_handle(void); +void txl_payload_handle_backup(void); +void txl_transmit_trigger(void); +void txl_reset(void); +void txl_cntrl_env_dump(void); +void txl_frame_init_desc(txl_frame_desc_tag *frame,txl_buffer_tag *buffer,tx_hw_desc *hwdesc,txl_buffer_control *bufctrl); +void txl_frame_init(_Bool reset); +txl_frame_desc_tag * txl_frame_get(int type,int len); +_Bool txl_frame_push(txl_frame_desc_tag *frame,uint8_t ac); +_Bool txl_frame_push_force(txl_frame_desc_tag *frame,uint8_t ac); +void txl_frame_cfm(txdesc *txdesc); +void txl_frame_release(txdesc *txdesc,_Bool postponed); +uint8_t txl_frame_send_null_frame(uint8_t sta_idx,cfm_func_ptr *cfm,void *env); +uint8_t txl_frame_send_qosnull_frame(uint8_t sta_idx,uint16_t qos,cfm_func_ptr *cfm,void *env); +uint8_t txl_frame_send_eapol_frame(uint8_t sta_idx,cfm_func_ptr *cfm,void *cfm_env,uint8_t *pBuf,uint32_t pBuf_len); +void txl_frame_dump(void); +void txl_hwdesc_init(void); +void txl_hwdesc_reset(void); +void vif_mgmt_bcn_to_evt(void *env); +void vif_mgmt_init(void); +uint8_t vif_mgmt_register(mac_addr.conflict38 *mac_addr,uint8_t vif_type,_Bool p2p,uint8_t *vif_idx); +void vif_mgmt_unregister(uint8_t vif_idx); +void vif_mgmt_add_key(mm_key_add_req *param,uint8_t hw_key_idx); +void vif_mgmt_del_key(vif_info_tag *vif,uint8_t keyid); +void vif_mgmt_send_postponed_frame(vif_info_tag *p_vif_entry); +void vif_mgmt_reset(void); +void vif_mgmt_bcn_to_prog(vif_info_tag *p_vif_entry); +void vif_mgmt_bcn_recv(vif_info_tag *p_vif_entry); +void vif_mgmt_switch_channel(vif_info_tag *p_vif_entry); +vif_info_tag * vif_mgmt_get_first_ap_inf(void); +void me_init(void); +scan_chan_tag * me_freq_to_chan_ptr(uint8_t band,uint16_t freq); +void michael_block(mic_calc *mic_calc_ptr,uint32_t block); +void me_mic_init(mic_calc *mic_calc_ptr,uint32_t *mic_key_ptr,mac_addr.conflict51 *da,mac_addr.conflict51 *sa,uint8_t tid); +void me_mic_calc(mic_calc *mic_calc_ptr,uint32_t start_ptr,uint32_t data_len); +void me_mic_end(mic_calc *mic_calc_ptr); +uint8_t rxu_cntrl_machdr_len_get(uint16_t frame_cntl); +_Bool rxu_cntrl_protected_handle(uint8_t *frame,uint32_t statinfo); +undefined4 rxu_mgt_frame_check(rx_swdesc *param_1,uint param_2); +void rxu_cntrl_init(void); +void rxu_cntrl_monitor_pm(mac_addr.conflict *addr); +uint8_t rxu_cntrl_get_pm(void); +void rxu_cntrl_evt(int dummy); +void rxu_swdesc_upload_evt(int arg); +void scanu_confirm(uint8_t status); +void scanu_raw_send_cfm(uint8_t status,ke_task_id_t dst_id); +void scanu_init(void); +mac_scan_result * scanu_find_result(mac_addr.conflict *bssid_ptr,_Bool allocate); +undefined4 scanu_frame_handler(ushort *param_1); +mac_scan_result * scanu_search_by_bssid(mac_addr.conflict *bssid); +mac_scan_result * scanu_search_by_ssid(mac_ssid *ssid,int *idx); +void scanu_rm_exist_ssid(mac_ssid *ssid,int index); +void scanu_scan_next(void); +void scanu_dma_cb(void); +void scanu_start(void); +uint16_t txl_get_seq_ctrl(void); +void sm_delete_resources(vif_info_tag *vif); +void sm_frame_tx_cfm_handler(void *env,u32_l status); +void sm_init(void); +void sm_get_bss_params(mac_addr.conflict67 **bssid,scan_chan_tag **chan); +void sm_scan_bss(mac_addr.conflict67 *bssid,scan_chan_tag *chan_1); +void sm_join_bss(mac_addr.conflict67 *bssid,scan_chan_tag *chan,_Bool passive); +uint8_t sm_add_chan_ctx(uint8_t *p_chan_idx); +void sm_send_next_bss_param(void); +void sm_set_bss_param(void); +void sm_disconnect_process(vif_info_tag *vif,uint16_t reason); +void sm_deauth_cfm(void *env,u32_l status); +void sm_disconnect(uint8_t vif_index,uint16_t reason_code); +void sm_connect_ind(uint16_t status); +void sm_supplicant_deauth_cfm(void *env,u32_l status); +void sm_auth_send(uint16_t auth_seq,uint32_t *challenge); +void sm_assoc_req_send(void); +void sm_assoc_done(uint16_t aid); +void sm_auth_handler(rxu_mgt_ind *param); +void sm_assoc_rsp_handler(rxu_mgt_ind *param); +int sm_deauth_handler(rxu_mgt_ind *param); +void sm_handle_supplicant_result(uint8_t sta_id,uint16_t reason_code); +undefined2 * txu_cntrl_sec_hdr_append(int param_1,undefined2 *param_2,int param_3); +int txu_cntrl_sechdr_len_compute(txdesc *txdesc,int *tail_len); +void txu_cntrl_frame_build(txdesc *txdesc,uint32_t buf); +void txu_cntrl_tkip_mic_append(txdesc *txdesc,uint8_t ac); +void txu_cntrl_cfm(txdesc *txdesc); +void txu_cntrl_protect_mgmt_frame(txdesc *txdesc,uint32_t frame,uint16_t hdr_len); +int _aid_list_delete(uint8_t *mac); +void apm_sta_delete(u8_l sta_idx,uint8_t *mac); +void apm_tx_cfm_handler(uint8_t *param_1,int param_2); +void apm_init(void); +void apm_start_cfm(int param_1); +void apm_send_next_bss_param(void); +void apm_set_bss_param(void); +void apm_stop(vif_info_tag *vif); +_Bool apm_tx_int_ps_check(txdesc *txdesc); +void apm_tx_int_ps_postpone(txdesc *txdesc,sta_info_tag *sta); +txdesc * apm_tx_int_ps_get_postpone(vif_info_tag *vif,sta_info_tag *sta,int *stop); +void apm_tx_int_ps_clear(vif_info_tag *vif,u8_l sta_idx); +void apm_sta_fw_delete(u8_l sta_idx); +void apm_sta_add(u8_l sta_idx); +void apm_send_mlme(vif_info_tag *vif,uint16_t fctl,mac_addr.conflict75 *ra,cfm_func_ptr *cfm_func,void *env,uint16_t status_code); +_Bool apm_embedded_enabled(vif_info_tag *vif); +void apm_bcn_set(void); +void apm_probe_req_handler(ushort *param_1); +void apm_auth_handler(rxu_mgt_ind *param); +void apm_assoc_req_handler(ushort *param_1,int param_2); +void apm_deauth_handler(rxu_mgt_ind *param); +void apm_disassoc_handler(rxu_mgt_ind *param); +void apm_beacon_handler(rxu_mgt_ind *param); +void apm_sta_remove(u8_l vif_idx,u8_l sta_idx); +void co_list_init(co_list *list); +void co_list_push_back(co_list *list,co_list_hdr *list_hdr); +void co_list_push_front(co_list *list,co_list_hdr *list_hdr); +co_list_hdr * co_list_pop_front(co_list *list); +void co_list_extract(co_list *list,co_list_hdr *list_hdr); +uint32_t co_list_cnt(co_list *list); +void co_list_insert(co_list *list,co_list_hdr *element,anon_subr__Bool_co_list_hdr_ptr_co_list_hdr_ptr *cmp); +void co_list_insert_after(co_list *list,co_list_hdr *prev_element,co_list_hdr *element); +void co_list_remove(co_list *list,co_list_hdr *prev_element,co_list_hdr *element); +void bl_event_handle(int param); +void bl60x_fw_dump_statistic(int forced); +void ke_evt_schedule(void); +void ke_init(void); +void * ke_msg_alloc(ke_msg_id_t id,ke_task_id_t dest_id,ke_task_id_t src_id,uint16_t param_len); +void ke_msg_send(int param_1); +void ke_msg_send_basic(ke_msg_id_t id,ke_task_id_t dest_id,ke_task_id_t src_id); +void ke_msg_forward_and_change_id(void *param_ptr,ke_msg_id_t msg_id,ke_task_id_t dest_id,ke_task_id_t src_id); +_Bool cmp_dest_id(co_list_hdr *msg,u32_l dest_id); +_Bool ke_task_local(ke_task_id_t id); +ke_msg_func_t * ke_handler_search(ke_msg_id_t msg_id,ke_state_handler *state_handler); +ke_state_t ke_state_get(ke_task_id_t id); +int ke_msg_discard(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int ke_msg_save(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +_Bool cmp_abs_time(co_list_hdr *timerA,co_list_hdr *timerB); +_Bool cmp_timer_id(co_list_hdr *timer,uint32_t timer_task); +void ke_timer_set(ke_msg_id_t timer_id,ke_task_id_t task_id,uint32_t delay); +void ke_timer_clear(ke_msg_id_t timer_id,ke_task_id_t task_id); +void ke_timer_schedule(int dummy); +void bl60x_current_time_us(longlong *time_now); +byte * mac_ie_find(byte *param_1,int param_2,uint param_3); +char * mac_vsie_find(char *param_1,int param_2,int param_3,int param_4); +BufferDesc_t *GetTxEAPOLBuffer(cm_ConnectionInfo_t *connPtr,EAPOL_KeyMsg_Tx_t **ppTxEapol,BufferDesc_t *pBufDesc); +void UpdateEAPOLWcbLenAndTransmit(BufferDesc_t *pBufDesc,UINT16 frameLen); +BOOLEAN keyMgmtProcessMsgExt(keyMgmtInfoSta_t *pKeyMgmtInfoSta,EAPOL_KeyMsg_t *pKeyMsg); +void KeyMgmtInitSta(cm_ConnectionInfo_t *connPtr); +void keyMgmtSta_StartSession(cm_ConnectionInfo_t *connPtr,CHAR *pBssid,UINT8 *pStaAddr); +void init_customApp_mibs(supplicantData_t *suppData); +UINT8 supplicantIsEnabled(void *connectionPtr); +void supplicantInitSession(cm_ConnectionInfo_t *connPtr,CHAR *pSsid,UINT16 len,CHAR *pBssid,UINT8 *pStaAddr); +void supplicantDisable(cm_ConnectionInfo_t *connPtr); +void supplicantEnable(void *connectionPtr,int security_mode,void *mcstCipher,void *ucstCipher,_Bool is_pmf_required); +UINT16 keyMgmtFormatWpaRsnIe(cm_ConnectionInfo_t *connPtr,UINT8 *pos,IEEEtypes_MacAddr_t *pBssid,IEEEtypes_MacAddr_t *pStaAddr,UINT8 *pPmkid,BOOLEAN addPmkid); +Status_e GeneratePWKMsg2(BufferDesc_t *pEAPoLBufDesc,UINT8 *pSNonce,UINT8 *pEAPOLMICKey,UINT8 forceKeyDescVersion); +BOOLEAN KeyMgmtStaHsk_Recvd_PWKMsg1(BufferDesc_t *pEAPoLBufDesc,IEEEtypes_MacAddr_t *sa,IEEEtypes_MacAddr_t *da); +void supplicantInit(supplicantData_t *suppData); +void allocSupplicantData(void *connectionPtr); +UINT16 keyMgmtGetKeySize(cm_ConnectionInfo_t *connPtr,UINT8 isPairwise); +uint8_t add_key_to_mac(cm_ConnectionInfo_t *connPtr,UINT8 pairwise); +BufferReturnNotify_t * keyMgmtKeyGroupTxDone(void); +Status_e GenerateGrpMsg2(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta); +EAPOL_KeyMsg_t * KeyMgmtStaHsk_Recvd_GrpMsg1(BufferDesc_t *pEAPoLBufDesc); +uint8_t add_mfp_key_to_mac(cm_ConnectionInfo_t *connPtr,UINT8 pairwise); +void keyMgmtPlumbPairwiseKey(cm_ConnectionInfo_t *connPtr); +BufferReturnNotify_t * keyMgmtKeyPairwiseTxDone(void); +Status_e GeneratePWKMsg4(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta,BOOLEAN groupKeyReceived); +EAPOL_KeyMsg_t * KeyMgmtStaHsk_Recvd_PWKMsg3(BufferDesc_t *pEAPoLBufDesc); +void ProcessKeyMgmtDataSta(BufferDesc_t *pBufDesc,IEEEtypes_MacAddr_t *sa,IEEEtypes_MacAddr_t *da); +UINT8 ProcessEAPoLPkt(BufferDesc_t *bufDesc,IEEEtypes_MacAddr_t *sa,IEEEtypes_MacAddr_t *da); +uchar process_rsn_ie(uint8_t *rsn_ie,Cipher_t.conflict *mcstCipher,Cipher_t.conflict *ucstCipher,_Bool *is_pmf_required,SecurityMode_t *security_mode,_Bool wpa2_prefered); +uchar process_wpa_ie(uint8_t *wpa_ie,Cipher_t.conflict *mcstCipher,Cipher_t.conflict *ucstCipher); +void keyMgmtStaRsnSecuredTimeoutHandler(void *env); +void supplicantGenerateRand(UINT8 *dataOut,UINT32 length); +void ComputeEAPOL_MIC(EAPOL_KeyMsg_t *pKeyMsg,UINT16 data_length,UINT8 *MIC_Key,UINT8 MIC_Key_length,UINT8 micKeyDescVersion); +UINT16 keyMgmtGetKeySize_internal(RSNConfig_t *pRsnConfig,UINT8 isPairwise); +int isApReplayCounterFresh(keyMgmtInfoSta_t *pKeyMgmtInfoSta,UINT8 *pRxReplayCount); +void updateApReplayCounter(keyMgmtInfoSta_t *pKeyMgmtStaInfo,UINT8 *pRxReplayCount); +void formEAPOLEthHdr(EAPOL_KeyMsg_Tx_t *pTxEapol,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa); +BOOLEAN IsEAPOL_MICValid(EAPOL_KeyMsg_t *pKeyMsg,UINT8 *pMICKey); +UINT16 KeyMgmtSta_PopulateEAPOLLengthMic(EAPOL_KeyMsg_Tx_t *pTxEapol,UINT8 *pEAPOLMICKey,UINT8 eapolProtocolVersion,UINT8 forceKeyDescVersion); +KDE_t * parseKeyKDE(IEEEtypes_InfoElementHdr_t *pIe); +KDE_t * parseKeyKDE_DataType(UINT8 *pData,SINT32 dataLen,IEEEtypes_KDEDataType_e KDEDataType); +KDE_t * parseKeyDataGTK(UINT8 *pKey,UINT16 len,KeyData_t *pGRKey); +void KeyMgmtSta_ApplyKEK(EAPOL_KeyMsg_t *pKeyMsg,KeyData_t *pGRKey,UINT8 *EAPOL_Encr_Key); +BOOLEAN KeyMgmtSta_IsRxEAPOLValid(keyMgmtInfoSta_t *pKeyMgmtInfoSta,EAPOL_KeyMsg_t *pKeyMsg); +void KeyMgmtSta_PrepareEAPOLFrame(EAPOL_KeyMsg_Tx_t *pTxEapol,EAPOL_KeyMsg_t *pRxEapol,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa,UINT8 *pSNonce); +BOOLEAN supplicantAkmIsWpaWpa2(AkmSuite_t *pAkm); +BOOLEAN supplicantAkmIsWpa2(AkmSuite_t *pAkm); +BOOLEAN supplicantAkmIsWpaWpa2Psk(AkmSuite_t *pAkm); +BOOLEAN supplicantAkmUsesKdf(AkmSuite_t *pAkm); +void supplicantConstructContext(IEEEtypes_MacAddr_t *pAddr1,IEEEtypes_MacAddr_t *pAddr2,UINT8 *pNonce1,UINT8 *pNonce2,UINT8 *pContext); +void KeyMgmt_DerivePTK(IEEEtypes_MacAddr_t *pAddr1,IEEEtypes_MacAddr_t *pAddr2,UINT8 *pNonce1,UINT8 *pNonce2,UINT8 *pPTK,UINT8 *pPMK,BOOLEAN use_kdf); +void KeyMgmtSta_DeriveKeys(UINT8 *pPMK,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa,UINT8 *ANonce,UINT8 *SNonce,UINT8 *EAPOL_MIC_Key,UINT8 *EAPOL_Encr_Key,KeyData_t *newPWKey,BOOLEAN use_kdf); +void SetEAPOLKeyDescTypeVersion(EAPOL_KeyMsg_Tx_t *pTxEapol,BOOLEAN isWPA2,BOOLEAN isKDF,BOOLEAN nonTKIP); +EAPOL_KeyMsg_t *GetKeyMsgNonceFromEAPOL(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta); +EAPOL_KeyMsg_t *ProcessRxEAPOL_PwkMsg3(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta); +EAPOL_KeyMsg_t *ProcessRxEAPOL_GrpMsg1(BufferDesc_t *pEAPoLBufDesc,keyMgmtInfoSta_t *pKeyMgmtInfoSta); +void KeyMgmtResetCounter(keyMgmtInfoSta_t *pKeyMgmtInfo); +void keyMgmtSta_StartSession_internal(keyMgmtInfoSta_t *pKeyMgmtInfoSta,UINT32 expiry); +void KeyMgmtSta_InitSession(keyMgmtInfoSta_t *pKeyMgmtInfoSta); +void bl_sha256_crypto_kdf(UINT8 *pKey,UINT8 key_len,char *label,UINT8 label_len,UINT8 *pContext,UINT16 context_len,UINT8 *pOutput,UINT16 output_len); +void Bl_F(uchar *digest,uchar *digest1,char *password,uchar *ssid,int ssidlength,int iterations,int count,uchar *output); +int Bl_PasswordHash(char *password,uchar *ssid,int ssidlength,uchar *output); +int bl60x_fw_password_hash(char *password,uchar *ssid,int ssidlength,uchar *output); +UINT8 * pmkCacheFindPSK(UINT8 *pSsid,UINT8 ssidLen); +void pmkCacheSetPassphrase(UINT8 *pSsid,UINT8 ssidLen,UINT8 *pPassphrase,UINT8 PassphraseLen); +void pmkCacheInit(void); +void pmkCacheRomInit(void); +pmkElement_t * pmkCacheNewElement(void); +void pmkCacheUpdateReplacementRank(pmkElement_t *pPMKElement); +pmkElement_t * pmkCacheFindPSKElement(UINT8 *pSsid,UINT8 ssidLen); +void pmkCacheAddPSK(UINT8 *pSsid,UINT8 ssidLen,UINT8 *pPSK,UINT8 pPSKLen); +void pmkCacheDeletePSK(UINT8 *pSsid,UINT8 ssidLen); +UINT8 pmkCacheGetHexNibble(UINT8 nibble); +void pmkCacheGeneratePSK(UINT8 *pSsid,UINT8 ssidLen,UINT8 *pPassphrase,UINT8 PassphraseLen,UINT8 *pPSK); +void prepare_key(uchar *key_data_ptr,int key_data_len,rc4_key *key); +void rc4(uchar *buffer_ptr,int buffer_len,int skip,rc4_key *key); +void RC4_Encrypt(uchar *Encr_Key,uchar *IV,__uint16_t iv_length,uchar *Data,__uint16_t data_length,__uint16_t skipBytes); +int sha256_compress(sha256_state *md,UINT8 *msgBuf,UINT8 *pScratchMem); +void sha256_init(sha256_state *md); +void sha256_vector(size_t num_elem,UINT8 **addr,size_t *len,UINT8 *mac,UINT8 *pScratchMem); +void hmac_sha256_vector(UINT8 *key,size_t key_len,size_t num_elem,UINT8 **addr,size_t *len,UINT8 *mac); +void KeyMgmtInit(cm_ConnectionInfo_t *connPtr); +BufferDesc_t *PrepDefaultEapolMsg(cm_ConnectionInfo_t *connPtr,EAPOL_KeyMsg_Tx_t **pTxEapolPtr,BufferDesc_t *pBufDesc); +Status_e GeneratePWKMsg1(cm_ConnectionInfo_t *connPtr,BufferDesc_t *pBufDesc); +Status_e GeneratePWKMsg3(cm_ConnectionInfo_t *connPtr,BufferDesc_t *pBufDesc); +Status_e ProcessPWKMsg4(BufferDesc_t *pBufDesc); +Status_e GenerateApEapolMsg(cm_ConnectionInfo_t *connPtr,keyMgmtState_e msgState,BufferDesc_t *pBufDesc); +Status_e ProcessPWKMsg2(BufferDesc_t *pBufDesc); +BOOLEAN SendEAPOLMsgUsingBufDesc(cm_ConnectionInfo_t *connPtr,BufferDesc_t *pBufDesc); +Status_e ProcessKeyMgmtDataAp(BufferDesc_t *pBufDesc); +void InitStaKeyInfo(void *pConn,SecurityMode_t *secType,Cipher_t.conflict *pwCipher,UINT16 staRsnCap,UINT8 akmType); +void RemoveAPKeyInfo(void *pConn); +void InitGroupKey(cm_ConnectionInfo_t *connPtr); +void GenerateGTK_internal(KeyData_t *grpKeyData,UINT8 *nonce,IEEEtypes_Addr_t *StaMacAddr); +void PopulateKeyMsg(EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,Cipher_t.conflict *Cipher,UINT16 Type,UINT32 *replay_cnt,UINT8 *Nonce); +void prepareKDE(EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,KeyData_t *grKey,Cipher_t.conflict *cipher); +BOOLEAN Encrypt_keyData(EAPOL_KeyMsg_Tx_t *tx_eapol_ptr,UINT8 *EAPOL_Encr_Key,Cipher_t.conflict *cipher); +void KeyMgmtAp_DerivePTK(UINT8 *pPMK,IEEEtypes_MacAddr_t *da,IEEEtypes_MacAddr_t *sa,UINT8 *ANonce,UINT8 *SNonce,UINT8 *EAPOL_MIC_Key,UINT8 *EAPOL_Encr_Key,KeyData_t *newPWKey,BOOLEAN use_kdf); +BOOLEAN KeyData_CopyWPAWP2(EAPOL_KeyMsg_Tx_t *pTxEAPOL,void *pIe); +BOOLEAN KeyData_UpdateKeyMaterial(EAPOL_KeyMsg_Tx_t *pTxEAPOL,SecurityMode_t *pSecType,void *pWPA,void *pWPA2); +void ROM_InitGTK(KeyData_t *grpKeyData,UINT8 *nonce,IEEEtypes_Addr_t *StaMacAddr); +void InitKeyMgmtInfo(apKeyMgmtInfoStaRom_t *pKeyMgmtInfo,SecurityMode_t *secType,Cipher_t.conflict *pwCipher,UINT16 staRsnCap,UINT8 akmType); +apInfo_t * cm_GetApInfo(cm_ConnectionInfo_t *connPtr); +apSpecificData_t * cm_GetApData(cm_ConnectionInfo_t *connPtr); +Status_e cm_AllocAPResources(cm_ConnectionInfo_t *connPtr); +Status_e cm_AllocResources(cm_ConnectionInfo_t *connPtr); +cm_ConnectionInfo_t *cm_InitConnection(UINT8 conType,UINT8 bssType,UINT8 bssNum,IEEEtypes_MacAddr_t *bssId,IEEEtypes_MacAddr_t *peerMacAddr,UINT8 channel,unkbyte0 *hostMdev); +void cm_DeleteConnection(cm_ConnectionInfo_t *connPtr); +void cm_SetPeerAddr(cm_ConnectionInfo_t *connPtr,IEEEtypes_MacAddr_t *bssId,IEEEtypes_MacAddr_t *peerMacAddr); +void cm_SetComData(cm_ConnectionInfo_t *connPtr,char *ssid); +void assert_err(char *condition,char *file,int line); +void assert_warn(char *condition,char *file,int line); +void coex_wifi_rf_forece_enable(int enable); +void coex_wifi_pti_forece_enable(int enable); +void wifi_main(void); +void ipc_emb_notify(void); +void ipc_emb_wait(void); +void ipc_emb_init(void); +void ipc_emb_tx_irq(void); +void ipc_emb_tx_evt(int queue_idx); +void ipc_emb_cfmback_irq(void); +void ipc_emb_txcfm_ind(uint32_t queue_bits); +void ipc_emb_msg_irq(void); +void ipc_emb_msg_evt(void); +void ipc_emb_msg_dma_int_handler(void); +void ipc_emb_dbg_dma_int_handler(void); +void ipc_emb_dump(void); +void mdm_txcbwmax_setf(uint8_t txcbwmax); +void phy_config_rxgain(int offset); +void agc_config(void); +void mdm_reset(void); +void phy_powroffset_set(int8_t *power_offset); +void phy_hw_set_channel(uint8_t band,uint16_t freq,uint16_t freq1,uint8_t chantype); +void phy_get_channel(phy_channel_info *info,uint8_t index); +void phy_set_channel(uint8_t band,uint8_t type,uint16_t prim20_freq,uint16_t center1_freq,uint16_t center2_freq,uint8_t index); +void phy_get_version(uint32_t *version_1,uint32_t *version_2); +_Bool phy_vht_supported(void); +void phy_init(phy_cfg_tag *config); +uint8_t phy_get_nss(void); +uint8_t phy_get_ntx(void); +void phy_stop(void); +_Bool phy_ldpc_tx_supported(void); +uint8_t phy_get_mac_freq(void); +void phy_get_rf_gain_idx(int8_t *power,uint8_t *idx); +void phy_get_rf_gain_capab(int8_t *max,int8_t *min); +void bz_phy_reset(void); +void mpif_clk_init(void); +void phy_mdm_isr(void); +void phy_rc_isr(void); +void pa_init(void); +void pa_input(uint8_t id,rx_hd *rhd); +uint8_t hal_get_capcode(void); +void hal_set_capcode(uint32_t capcode); +_Bool hal_get_temperature(int16_t *temperature); +void hal_set_temperature(int16_t temperature); +void trpc_update_power(int8_t (*power_rate_table) [8]); +void trpc_power_get(int8_t *power_rate_table); +void trpc_update_power_11b(int8_t *power_rate_table); +void trpc_update_power_11g(int8_t *power_rate_table); +void trpc_update_power_11n(int8_t *power_rate_table); +void trpc_init(void); +int8_t trpc_get_rf_max_power(void); +int8_t trpc_get_rf_min_power(void); +uint8_t trpc_get_power_idx(uint8_t formatmod,uint8_t mcs,int8_t pwr_dbm); +uint8_t trpc_get_default_power_idx(uint8_t formatmod,uint8_t mcs); +void trpc_update_vs_channel(int8_t channel_MHz); +void trpc_update_vs_temperature(int8_t temperature); +void phy_tcal_reset(void); +void phy_tcal_start(void); +void phy_tcal_txpwr(int16_t curr_temperature); +void phy_tcal_callback(int16_t temperature); +int bl60x_check_mac_status(int *is_ok); +void helper_record_dump(void); +void helper_record_rc_rf_states(uint *param_1,uint *param_2); +void helper_record_all_states(char *func_name); +void rf_fsm_ctrl_en_setf(uint32_t x); +void rf_gc_tbb_setf(uint32_t x); +void rf_gc_tmx_setf(uint32_t x); +void rf_pa_ib_fix_setf(uint32_t x); +void rf_pa_vbcas_setf(uint32_t x); +void rf_pa_vbcore_setf(uint32_t x); +void rf_tmx_cs_setf(uint32_t x); +void rf_fsm_st_dbg_en_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc3_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc2_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc1_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc0_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc7_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc6_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc5_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc4_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc11_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc10_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc9_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc8_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc15_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc14_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc13_setf(uint32_t x); +void rf_tx_dvga_gain_qdb_gc12_setf(uint32_t x); +void wait_us(uint32_t us); +void rf_pa_etb_en_setf(void); +void rf_pa_half_on_setf(void); +void _print_channel_info(void); +void rfc_init(uint32_t xtalfreq_hz); +void rfc_rxdfe_set_notch0(uint8_t en,uint8_t alpha,int8_t nrmfc); +void rfc_config_channel(uint32_t channel_freq); +void rfc_coex_force_to(uint32_t force_enable,uint32_t bbmode); +_Bool rfc_config_power_ble(int32_t pwr_dbm); +uint32_t rfc_get_power_level(uint32_t formatmod,int32_t power); +void rfc_apply_tx_dvga(int8_t *dvga_qdb); +void rfc_apply_tx_power_offset(uint8_t channel,int8_t *power_offset); +void rf_pri_set_gain_table_regs(void); +void rf_pri_manu_pu(uint32_t mode); +void rf_pri_save_state_for_cal(void); +void rf_pri_restore_state_for_cal(void); +void rf_pri_singen_start(void); +uint32_t rf_pri_pm_pwr(void); +void rf_pri_start_txdfe(void); +int32_t rf_pri_pm_pwr_avg(uint32_t iq,uint32_t acc_len); +void rf_pri_txcal_config_hw(void); +uint16_t rf_pri_fcal_meas(uint32_t cw); +void rf_pri_rccal_config(uint32_t rbb_fc); +void rf_pri_rccal_config(uint32_t iq,uint32_t rbb_fc); +void rf_pri_txcal_config(uint32_t param_ind,int32_t val); +int32_t rf_pri_txcal_search_core(uint32_t param_ind,uint32_t center,uint32_t delta,uint32_t meas_freq); +void rf_pri_singen_config(uint32_t fcw); +uint32_t rf_pri_rccal_iq(uint32_t iq); +void rf_pri_config_channel(void); +uint32_t rf_pri_roscal_iq(uint32_t iq); +void rf_pri_chipv(uint8_t chipv); +void rf_pri_update_tx_power_offset(uint8_t channel,int8_t *power_offset); +void rf_pri_get_notch_param(uint32_t chanfreq_MHz,uint8_t *ncf_on,int32_t *ncf_freq_Hz); +void rf_pri_update_param(uint32_t chanfreq_MHz); +void rf_pri_xtalfreq(uint32_t xtalfreq); +uint32_t rf_pri_get_vco_freq_cw(uint32_t chanfreq_MHz); +uint32_t rf_pri_get_vco_idac_cw(uint32_t chanfreq_MHz); +int32_t rf_pri_get_txgain_max(void); +int32_t rf_pri_get_txgain_min(void); +uint32_t rf_pri_get_txgain_index(int32_t pwr,uint32_t mode); +void rf_pri_query_txgain_table(uint32_t index,uint32_t *rfg_index,uint32_t *dg); +void rf_pri_update_dvga_os(int8_t dvga_os); +void rf_pri_tx_gain_comp(int32_t Tsens); +void rf_pri_txcal(void); +void rf_pri_roscal(void); +void rf_pri_rccal(void); +void rf_pri_lo_acal(void); +void rf_pri_fcal(void); +void rf_pri_full_cal(void); +void rf_pri_restore_cal_reg(void); +void rf_pri_init(uint8_t reset,uint8_t chipv); +void rf_pri_update_power_offset(int32_t *power_offset); +int phyif_utils_decode(phyif_utils_recvtable_t *vec,int8_t *ppm); +void sysctrl_init(void); +void intc_spurious(void); +void intc_enable_irq(int index); +void intc_init(void); +void mac_irq(void); +void bl_irq_handler(void); +void blmac_pwr_mgt_setf(uint8_t pwrmgt); +chan_ctxt_tag * chan_get_next_chan(void); +void chan_conn_less_delay_prog(void); +void chan_upd_nb_rem_slots(uint32_t current_time); +_Bool chan_tbtt_detect_conflict(void); +void chan_tbtt_insert(chan_tbtt_tag *p_tbtt_entry); +void chan_upd_ctxt_status(chan_ctxt_tag *p_chan_entry,uint8_t next_status); +void chan_switch_start(chan_ctxt_tag *p_chan_entry); +void chan_conn_less_delay_evt(void *env); +void chan_tbtt_switch_evt(void *env); +void chan_tbtt_schedule(chan_tbtt_tag *p_tbtt_entry); +void chan_cde_evt(void *env); +void chan_goto_idle_cb(void); +void chan_tx_cfm(void *dummy,uint32_t status); +void chan_init(void); +void chan_scan_req(uint8_t band,uint16_t freq,int8_t pwr,uint32_t duration_us,uint8_t vif_index); +uint8_t chan_roc_req(mm_remain_on_channel_req *req,ke_task_id_t taskid); +uint8_t chan_ctxt_add(mm_chan_ctxt_add_req *p_add_req,uint8_t *idx); +void chan_ctxt_del(uint8_t chan_idx); +void chan_tbtt_switch_update(vif_info_tag *p_vif_entry,uint32_t tbtt_time); +void chan_bcn_to_evt(vif_info_tag *p_vif_entry); +void chan_bcn_detect_start(vif_info_tag *p_vif_entry); +_Bool chan_is_on_channel(vif_info_tag *p_vif_entry); +_Bool chan_is_tx_allowed(vif_info_tag *p_vif_entry); +_Bool chan_is_on_operational_channel(vif_info_tag *p_vif_entry); +void chan_update_tx_power(chan_ctxt_tag *p_chan_entry); +void chan_ctxt_link(uint8_t vif_idx,uint8_t chan_idx); +void chan_ctxt_unlink(uint8_t vif_idx); +void hal_dma_init(void); +u8_l blmac_soft_reset_getf(void); +void blmac_wt_2_crypt_clk_ratio_setf(u8_l wt2cryptclkratio); +void blmac_rx_flow_cntrl_en_setf(void); +void blmac_key_sto_ram_reset_setf(void); +void hal_machw_stop(void); +void hal_machw_init(void); +void hal_machw_disable_int(void); +void hal_machw_reset(void); +u8_l hal_machw_search_addr(mac_addr.conflict171 *addr); +void hal_machw_monitor_mode(void); +_Bool hal_machw_sleep_check(void); +void hal_machw_gen_handler(void); +void mm_rx_filter_set(void); +int element_notify_status_enabled(cfg_element_entry *entry,void *arg1,void *arg2,CFG_ELEMENT_TYPE_OPS ops); +void blmac_ap_setf(uint8_t ap); +uchar ascii_to_hex(char asccode); +undefined4 element_notify_time_last_received_set(void); +void blmac_encr_cntrl_pack(uint8_t newread,uint8_t newwrite,uint16_t keyindexram,uint8_t ctyperam,uint8_t vlanidram,uint8_t sppram,uint8_t usedefkeyram,uint8_t clenram); +undefined4 element_notify_keepalive_received(void); +uint32_t hal_machw_rx_duration(rx_hd *rhd,uint16_t len); +void mm_env_max_ampdu_duration_set(void); +void mm_env_init(void); +void mm_init(void); +void mm_active(void); +void mm_reset(void); +uint8_t mm_sec_machwaddr_wr(uint8_t sta_idx,uint8_t inst_nbr); +uint8_t mm_sec_machwkey_wr(mm_key_add_req *param); +void mm_sec_machwkey_del(uint8_t hw_key_idx); +void mm_sec_machwaddr_del(uint8_t sta_idx); +void mm_hw_idle_evt(int dummy); +void mm_hw_info_set(mac_addr.conflict171 *mac_addr); +void mm_hw_ap_info_set(void); +void mm_hw_ap_info_reset(void); +void mm_back_to_host_idle(void); +uint8_t mm_sta_add(mm_sta_add_req *param,uint8_t *sta_idx,uint8_t *hw_sta_idx); +void mm_sta_del(uint8_t sta_idx); +void mm_cfg_element_keepalive_timestamp_update(void); +void mm_send_connection_loss_ind(vif_info_tag *p_vif_entry); +void mm_ap_probe_cfm(void *env,uint32_t status); +void mm_check_rssi(vif_info_tag *vif_entry,int8_t rssi); +void mm_send_csa_traffic_ind(uint8_t vif_index,_Bool enable); +uint mm_check_beacon(rx_hd *param_1,vif_info_tag *param_2,int param_3,char **param_4); +void mm_sta_tbtt(void *env); +uint16_t mm_get_rsn_wpa_ie(uint8_t sta_id,uint8_t *wpa_ie); +void mm_tim_update_proceed(ushort *param_1); +void mm_bcn_init(void); +void mm_bcn_init_vif(vif_info_tag *vif_entry); +void mm_tim_update(mm_tim_update_req *param); +void mm_bcn_transmit(void); +void mm_bcn_updated(void *env,int dma_queue); +void mm_bcn_update(mm_bcn_change_req *param); +void mm_bcn_transmitted(vif_info_tag *param_1); +void mm_bcn_change(mm_bcn_change_req *param); +void bl_init(void); +int bl_sleep(void); +uint32_t bl_nap_calculate(void); +void rx_swdesc_init(void); +void scan_search_ds(void); +void scan_init(void); +void scan_set_channel_request(void); +void dma_cb(void *env,int dma_queue); +void scan_ie_download(scan_start_req *param); +void scan_probe_req_tx(void); +void scan_send_cancel_cfm(uint8_t status,ke_task_id_t dest_id); +int scan_cancel_req_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scan_start_req_handler(ke_msg_id_t msgid,scan_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +undefined4 mm_scan_channel_end_ind_handler(void); +int mm_scan_channel_start_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +void txl_buffer_reinit(void); +void txl_buffer_init(void); +void txl_buffer_reset(void); +txl_buffer_tag * txl_buffer_alloc(txdesc *txdesc,uint8_t access_category,uint8_t user_idx); +void txl_buffer_update_thd(txdesc *txdesc); +void txl_cfm_init(void); +void txl_cfm_push(txdesc *txdesc,u32_l status,u8_l access_category); +void txl_cfm_flush(u8_l access_category,co_list *list,u32_l status); +void txl_cfm_dma_int_handler(void); +void txl_cfm_dump(void); +void bam_init(void); +void bam_send_air_action_frame(int param_1,bam_env_tag *param_2,int param_3,uint8_t param_4,int param_5,uint16_t param_6,cfm_func_ptr *param_7); +undefined4 rxu_mgt_ind_handler(int param_1); +void co_pack8p(uint32_t dst,uint8_t *src,uint32_t len); +int phy_freq_to_channel(uint8_t band,uint16_t freq); +uint16_t phy_channel_to_freq(uint8_t band,int channel); +uint32_t me_add_ie_ssid(uint32_t *frame_addr,uint8_t ssid_len,uint8_t *p_ssid); +uint32_t me_add_ie_supp_rates(uint32_t *frame_addr,mac_rateset *p_rateset); +uint32_t me_add_ie_ext_supp_rates(uint32_t *frame_addr,mac_rateset *p_rateset); +uint32_t me_add_ie_ds(uint32_t *frame_addr,uint8_t channel); +uint32_t me_add_ie_erp(uint32_t *frame_addr,uint8_t erp_info); +uint32_t me_add_ie_rsn(uint32_t *frame_addr,uint8_t enc_type); +uint32_t me_add_ie_wpa(uint32_t *frame_addr,uint8_t enc_type); +uint32_t me_add_ie_tim(uint32_t *frame_addr,uint8_t dtim_period); +uint32_t me_add_ie_ht_capa(uint32_t *frame_addr); +uint32_t me_add_ie_ht_oper(uint32_t *frame_addr,vif_info_tag *p_vif_entry); +uint16_t me_build_authenticate(uint32_t frame,uint16_t algo_type,uint16_t seq_nbr,uint16_t status_code,uint32_t *challenge_array_ptr); +uint16_t me_build_deauthenticate(uint32_t frame,uint16_t reason_code); +uint16_t me_build_associate_req(uint32_t frame,mac_bss_info *bss,mac_addr.conflict171 *old_ap_addr_ptr,uint8_t vif_idx,uint32_t *ie_addr,uint16_t *ie_len,sm_connect_req *con_par); +uint16_t me_build_add_ba_req(uint32_t frame,bam_env_tag *bam_env); +uint16_t me_build_add_ba_rsp(uint32_t frame,bam_env_tag *bam_env,uint16_t param,uint8_t dialog_token,uint16_t status_code); +uint16_t me_build_del_ba(uint32_t frame,bam_env_tag *bam_env,uint16_t reason_code); +void me_extract_rate_set(uint32_t buffer,uint16_t buflen,mac_rateset *mac_rate_set_ptr); +void me_extract_power_constraint(uint32_t buffer,uint16_t buflen,mac_bss_info *bss); +void me_extract_country_reg(int param_1); +void me_extract_mobility_domain(uint32_t buffer,uint16_t buflen,mac_bss_info *bss); +uint me_extract_csa(undefined4 param_1,undefined4 param_2,undefined *param_3,int param_4); +uint16_t me_build_beacon(uint32_t frame,uint8_t vif_idx,uint16_t *tim_oft,uint8_t *tim_len,uint8_t hidden_ssid); +uint16_t me_build_probe_rsp(uint32_t frame,uint8_t vif_idx); +uint16_t me_build_associate_rsp(uint32_t frame,uint8_t vif_idx,uint16_t status_code,me_sta_add_req *req); +int me_rc_set_rate_req_handler(ke_msg_id_t msgid,me_rc_set_rate_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_rc_stats_req_handler(ke_msg_id_t msgid,me_rc_stats_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_traffic_ind_req_handler(ke_msg_id_t msgid,me_traffic_ind_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_sta_del_req_handler(ke_msg_id_t msgid,me_sta_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_control_port_req_handler(ke_msg_id_t msgid,me_set_control_port_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_chan_config_req_handler(ke_msg_id_t msgid,me_chan_config_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_ps_mode_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_idle_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_config_req_handler(ke_msg_id_t msgid,me_config_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_ps_disable_req_handler(ke_msg_id_t msgid,me_set_ps_disable_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_active_req_handler(ke_msg_id_t msgid,me_set_active_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_sta_add_req_handler(ke_msg_id_t msgid,me_sta_add_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +_Bool me_set_sta_ht_vht_param(sta_info_tag *sta,mac_bss_info *bss); +uint8_t me_11n_nss_max(uint8_t *mcs_set); +uint8_t me_legacy_ridx_min(uint16_t rate_map); +uint8_t me_legacy_ridx_max(uint16_t rate_map); +uint8_t me_rate_translate(uint8_t rate); +void me_get_basic_rates(mac_rateset *rateset,mac_rateset *basic_ratest); +uint16_t me_legacy_rate_bitfield_build(mac_rateset *rateset,_Bool basic_only); +uint16_t me_build_capability(uint8_t vif_idx); +void me_init_bcmc_rate(sta_info_tag *sta_entry); +void me_tx_cfm_singleton(txdesc *txdesc); +void me_check_rc(u8_l sta_idx,_Bool *tx_ampdu); +void me_init_rate(sta_info_tag *sta_entry); +void me_bw_check(int param_1,int param_2); +void me_beacon_check(uint8_t vif_idx,uint16_t length,uint32_t bcn_addr); +void me_sta_bw_nss_max_upd(uint8_t sta_idx,uint8_t bw,uint8_t nss); +uint8_t me_add_chan_ctx(uint8_t *p_chan_idx,scan_chan_tag *p_chan,uint32_t center_freq1,uint32_t center_freq2,uint8_t ch_width); +u8_l rc_get_nss(uint16_t rate_config); +u8_l rc_get_mcs_index(uint16_t rate_config); +uint16_t rc_set_previous_mcs_index(rc_sta_stats *rc_ss,uint16_t rate_config); +uint16_t rc_set_next_mcs_index(rc_sta_stats *rc_ss,uint16_t rate_config); +_Bool is_cck_group(uint16_t rate_config); +void rc_update_retry_chain(rc_sta_stats *rc_ss,uint32_t *cur_tp); +uint16_t rc_get_lowest_rate_config(rc_sta_stats *rc_ss); +void rc_sort_samples_tp(rc_sta_stats *rc_ss,uint32_t *cur_tp); +uint16_t rc_get_initial_rate_config(rc_sta_stats *rc_ss); +void rc_calc_prob_ewma(rc_rate_stats *rc_rs); +_Bool rc_check_valid_rate(rc_sta_stats *rc_ss,uint16_t rate_config); +uint16_t rc_new_random_rate(rc_sta_stats *rc_ss); +void rc_update_counters(u8_l sta_idx,u32_l attempts,u32_l failures,_Bool tx_ampdu,_Bool retry_required); +uint32_t rc_get_duration(uint param_1); +void rc_update_bw_nss_max(u8_l sta_idx,u8_l bw_max,u8_l nss_max); +void rc_init_bcmc_rate(sta_info_tag *sta_entry,u8_l basic_rate_idx); +_Bool rc_check_fixed_rate_config(rc_sta_stats *rc_ss,uint16_t fixed_rate_config); +u32_l rc_calc_tp(rc_sta_stats *rc_ss,u8_l sample_idx); +_Bool rc_update_stats(rc_sta_stats *rc_ss,_Bool init); +void rc_init(sta_info_tag *sta_entry); +void rc_check(u8_l sta_idx,_Bool *tx_ampdu); +void cfm_raw_send(void *env,uint32_t status); +int scanu_raw_send_req_handler(ke_msg_id_t msgid,scanu_raw_send_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scanu_join_req_handler(ke_msg_id_t msgid,scanu_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scanu_start_req_handler(ke_msg_id_t msgid,scanu_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int rxu_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scan_done_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scan_start_cfm_handler(ke_msg_id_t msgid,scan_start_cfm *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_ps_disable_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_bss_param_setting_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int sm_rsp_timeout_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scanu_start_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_connection_loss_ind_handler(ke_msg_id_t msgid,mm_connection_loss_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int scanu_join_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int sm_connect_req_handler(ke_msg_id_t msgid,sm_connect_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int rxu_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_set_vif_state_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_active_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_sta_add_cfm_handler(ke_msg_id_t msgid,mm_sta_add_cfm *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int sm_disconnect_req_handler(ke_msg_id_t msgid,sm_disconnect_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int apm_sta_connect_timeout_ind_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int rxu_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int apm_sta_add_cfm_handler(ke_msg_id_t msgid,me_sta_add_cfm *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int apm_sta_del_req_handler(ke_msg_id_t msgid,apm_sta_del_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int apm_conf_max_sta_req_handler(ke_msg_id_t msgid,apm_conf_max_sta_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_ps_disable_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_bss_param_setting_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int mm_bcn_change_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int apm_stop_req_handler(ke_msg_id_t msgid,apm_stop_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int apm_start_req_handler(ke_msg_id_t msgid,apm_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int me_set_active_cfm_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int hostapd_mgt_ind_handler(ke_msg_id_t msgid,rxu_mgt_ind *param,ke_task_id_t dest_id,ke_task_id_t src_id); +void dump_cfg_entries(void); +int cfg_start_req_handler(ke_msg_id_t msgid,cfg_start_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +char * cfg_api_element_dump(void *val,CFG_ELEMENT_TYPE type,char *strs); +int cfg_api_element_general_set(cfg_element_entry *entry,void *arg1,void *arg2); +int cfg_api_element_general_get(cfg_element_entry *entry,void *arg1,void *arg2); +int cfg_api_element_set(uint32_t task,uint32_t element,uint32_t type,void *arg1,void *arg2); +uint32_t co_crc32(uint32_t addr,uint32_t len,uint32_t crc); +void dbg_init(void); +void dbg_test_print(char *fmt,...); +int dbg_get_sys_stat_req_handler(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int dbg_mem_write_req_handler(ke_msg_id_t msgid,dbg_mem_write_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int dbg_mem_read_req_handler(ke_msg_id_t msgid,dbg_mem_read_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int dbg_set_sev_filter_req_handler(ke_msg_id_t msgid,dbg_set_sev_filter_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +int dbg_set_mod_filter_req_handler(ke_msg_id_t msgid,dbg_set_mod_filter_req *param,ke_task_id_t dest_id,ke_task_id_t src_id); +co_list_hdr *ke_queue_extract(co_list *queue,anon_subr__Bool_co_list_hdr_ptr_uint32_t.conflict2 *func,uint32_t arg); +void bl_aes_128(UINT8 *key,UINT8 *input,UINT8 *output); +void xor_128(UINT8 *a,UINT8 *b,UINT8 *out); +void leftshift_onebit(UINT8 *input,UINT8 *output); +void generate_subkey(UINT8 *key,UINT8 *K1,UINT8 *K2); +void padding(UINT8 *lastb,UINT8 *pad,int length); +void bl_aes_cmac(UINT8 *key,UINT8 *input,int length,UINT8 *mac); +int BL_AES_MEMCMP(UINT8 *dst,UINT8 *src,int len); +void BL_AES_MEMSET(UINT8 *dst,UINT8 val,int size); +void BL_AES_MEMCPY(UINT8 *dst,UINT8 *src,int size); +int BL_AesEncrypt(UINT8 *kek,UINT8 kekLen,UINT8 *data,UINT8 *ret); +int BL_AesWrap(UINT8 *kek,UINT8 kekLen,UINT32 n,UINT8 *plain,UINT8 *keyIv,UINT8 *cipher); +int BL_AesUnWrap(UINT8 *kek,UINT8 kekLen,UINT32 n,UINT8 *cipher,UINT8 *keyIv,UINT8 *plain); +void Bl_hmac_md5(UINT8 *text_data,int text_len,UINT8 *key,int key_len,void *digest); +void Bl_hmac_sha1(uchar **ppText,int *pTextLen,int textNum,uchar *key,int key_len,uchar *output,int outputLen); +void Bl_PRF(uchar *key,int key_len,uchar *prefix,int prefix_len,uchar *data,int data_len,uchar *output,int len); +void set_psk(char *pSsid,UINT8 ssidLen,char *phrase); +void remove_psk(char *pSsid,UINT8 ssidLen); +void wpa_MD5Transform(UINT32 *state,ulong *block); +void wpa_MD5Init(Bl_MD5_CTX *context); +void wpa_MD5Update(Bl_MD5_CTX *context,UINT8 *input,UINT32 inputLen); +void wpa_MD5Final(uchar *digest,Bl_MD5_CTX *context); +int rijndaelKeySetupEnc(u32.conflict *rk,u8 *cipherKey,int keyBits); +void rijndael_set_key(rijndael_ctx *ctx,u8 *key,int bits,int encrypt); +void rijndael_decrypt(rijndael_ctx *ctx,u8 *src,u8 *dst); +void rijndael_encrypt(rijndael_ctx *ctx,u8 *src,u8 *dst); +void Bl_SHA1ProcessMessageBlock(Bl_SHA1_CTX *context); +int Bl_SHA1Init(Bl_SHA1_CTX *context); +int Bl_SHA1Final(Bl_SHA1_CTX *context,UINT8 *Message_Digest); +int Bl_SHA1Update(Bl_SHA1_CTX *context,UINT8 *message_array,uint length); +Status_e supplicantRestoreDefaults(void); +void supplicantFuncInit(void); +void ap_setpsk(cm_ConnectionInfo_t *connPtr,CHAR *ssid,CHAR *passphrase); +void ap_resetConfiguration(cm_ConnectionInfo_t *connPtr); +void InitializeAp(cm_ConnectionInfo_t *connPtr); +void rf_set_channel(uint8_t bandwidth,uint16_t channel_freq); +void rf_dump_status(void); +int bt_hcionchip_recv(ke_msg_id_t msgid,void *param,ke_task_id_t dest_id,ke_task_id_t src_id); +uint8_t bt_onchiphci_interface_init(bt_hci_recv_cb *cb); +uint bt_onchiphci_hanlde_rx_acl(int param_1,void *param_2); +int bl_mtd_open(char *name,bl_mtd_handle_t *handle,uint flags); +int bl_mtd_info(bl_mtd_handle_t handle,bl_mtd_info_t *info); +int bl_mtd_erase(bl_mtd_handle_t handle,uint addr,uint size); +int bl_mtd_write(bl_mtd_handle_t handle,uint addr,uint size,uint8_t *data); +int bl_mtd_read(bl_mtd_handle_t handle,uint addr,uint size,uint8_t *data); +int bloop_init(loop_ctx *loop); +int bloop_handler_register(loop_ctx *loop,loop_evt_handler *handler,int priority); +void bloop_timer_init(loop_timer *timer,int use_auto_free); +void bloop_timer_configure(loop_timer *timer,uint delay_ms,anon_subr_void_loop_ctx_ptr_loop_timer_ptr_void_ptr *cb,void *arg,int idx_task,uint32_t evt_type_map); +void bloop_timer_repeat_enable(loop_timer *timer); +void bloop_timer_repeat_reconfigure(loop_timer *timer); +void bloop_timer_register(loop_ctx *loop,loop_timer *timer); +void bloop_wait_startup(loop_ctx *loop); +void bloop_evt_set_async(loop_ctx *loop,uint evt,uint32_t evt_map); +void bloop_evt_set_sync(loop_ctx *loop,uint evt,uint32_t evt_map); +void bloop_evt_unset_sync(loop_ctx *loop,uint evt); +void bloop_run(loop_ctx *param_1); +int bloop_status_dump(loop_ctx *loop); +int loop_evt_entity_sys_handler(loop_ctx *loop,loop_evt_handler *handler,loop_msg *msg); +int loop_evt_entity_sys_evt(loop_ctx *loop,loop_evt_handler *handler,uint32_t *bitmap_evt,uint32_t *evt_type_map); +int bl_sys_time_sync_state(uint32_t *xTicksToJump); +void get_f32_reg(void); +void put_f32_reg(void); +int backtrace_riscv(anon_subr_int_char_ptr *print_func,uintptr_t *regs); +uint32_t bl_timer_now_us(void); +uint64_t bl_rtc_get_counter(void); +uint64_t bl_rtc_get_timestamp_ms(void); +void set_if(netif *netif,char *ip_addr,char *gw_addr,char *nm_addr); +void Bl_F_fast(uchar *digest,uchar *digest1,char *password,uchar *ssid,int ssidlength,int count,uchar *output); +int utils_wifi_psk_cal_fast_bin(char *password,uchar *ssid,int ssidlength,uchar *output); +void utils_hmac_sha1_fast(uchar **ppText,int *pTextLen,int textNum,uchar *key,int key_len,uchar *output,int outputLen); +int bl_sha_mutex_take(void); +int bl_sha_mutex_give(void); +void bl_sha_init(bl_sha_ctx_t *ctx,bl_sha_type_t type); +int bl_sha_update(bl_sha_ctx_t *ctx,uint8_t *input,uint32_t len); +int bl_sha_finish(bl_sha_ctx_t *ctx,uint8_t *hash); +double fabs(double __x); +double floor(double __x); +double modf(double __x,double *__iptr); +DItype __lshrdi3(shift_count_type b); +int __clzsi2(USItype x); +DItype __divdi3(void); +DItype __moddi3(void); +UDItype __udivdi3(void); +UDItype __umoddi3(void); +__gcc_CMPtype __eqdf2(void); +__gcc_CMPtype __gedf2(void); +__gcc_CMPtype __ledf2(void); +SItype __fixdfsi(void); +USItype __fixunsdfsi(void); +DFtype __floatsidf(SItype i); +DFtype __floatunsidf(USItype i); +SFtype __truncdfsf2(void); +int atoi(char *__nptr); +void _atoi_r(void); +undefined * __errno(void); +void * memchr(void *__s,int __c,size_t __n); +int memcmp(void *__s1,void *__s2,size_t __n); +void * memcpy(void *__dest,void *__src,size_t __n); +void * memmove(void *__dest,void *__src,size_t __n); +void * memset(void *__s,int __c,size_t __n); +char * strchr(char *__s,int __c); +int strcmp(char *__s1,char *__s2); +char * strcpy(char *__dest,char *__src); +size_t strlen(char *__s); +int strncmp(char *__s1,char *__s2,size_t __n); +char * strncpy(char *__dest,char *__src,size_t __n); +size_t strnlen(char *__string,size_t __maxlen); +char * strrchr(char *__s,int __c); +byte * two_way_long_needle(int param_1,int param_2,byte *param_3,byte *param_4); +char * strstr(char *__haystack,char *__needle); +uint _strtol_l.isra.0(undefined4 *param_1,byte *param_2,byte **param_3,uint param_4); +uint _strtol_r(undefined4 *param_1,byte *param_2,byte **param_3,uint param_4); +long strtol_l(char *__nptr,char **__endptr,int __base,__locale_t __loc); +long strtol(char *__nptr,char **__endptr,int __base); +int stat(char *__file,stat *__buf); +void _stat_r(int *param_1,undefined4 param_2,undefined4 param_3); +int _stat(int param_1,undefined4 param_2); +void _conv_stat(undefined2 *param_1,undefined4 *param_2); +BL_Err_Type AON_Power_On_BG(void); +BL_Err_Type AON_Power_Off_BG(void); +BL_Err_Type AON_Power_On_LDO11_SOC(void); +BL_Err_Type AON_Power_Off_LDO11_SOC(void); +BL_Err_Type AON_Power_On_LDO15_RF(void); +BL_Err_Type AON_Power_Off_LDO15_RF(void); +BL_Err_Type AON_Power_On_SFReg(void); +BL_Err_Type AON_Power_Off_SFReg(void); +BL_Err_Type AON_LowPower_Enter_PDS0(void); +BL_Err_Type AON_LowPower_Exit_PDS0(void); +void ASM_Delay_Us(uint32_t core,uint32_t cnt); +void BL602_Delay_US(uint32_t cnt); +void BL602_Delay_MS(uint32_t cnt); +void * BL602_MemCpy(void *dst,void *src,uint32_t n); +uint32_t * BL602_MemCpy4(uint32_t *dst,uint32_t *src,uint32_t n); +void * BL602_MemCpy_Fast(void *pdst,void *psrc,uint32_t n); +void * BL602_MemSet(void *s,uint8_t c,uint32_t n); +uint32_t * BL602_MemSet4(uint32_t *dst,uint32_t val,uint32_t n); +int BL602_MemCmp(void *s1,void *s2,uint32_t n); +void EF_Ctrl_Sw_AHB_Clk_0(void); +void EF_Ctrl_Program_Efuse_0(void); +void EF_Ctrl_Load_Efuse_R0(void); +BL_Sts_Type EF_Ctrl_Busy(void); +BL_Sts_Type EF_Ctrl_AutoLoad_Done(void); +void EF_Ctrl_Clear(uint32_t index,uint32_t len); +BL_Err_Type GLB_SW_System_Reset(void); +BL_Err_Type GLB_SW_CPU_Reset(void); +BL_Err_Type GLB_SW_POR_Reset(void); +BL_Err_Type GLB_Select_Internal_Flash(void); +BL_Err_Type GLB_Select_External_Flash(void); +BL_Err_Type GLB_Deswap_Flash_Pin(void); +BL_Err_Type GLB_Swap_Flash_Pin(void); +BL_Err_Type GLB_GPIO_Init(GLB_GPIO_Cfg_Type *cfg); +BL_Err_Type GLB_GPIO_OUTPUT_Enable(GLB_GPIO_Type gpioPin); +BL_Err_Type GLB_GPIO_OUTPUT_Disable(GLB_GPIO_Type gpioPin); +BL_Err_Type GLB_GPIO_Set_HZ(GLB_GPIO_Type gpioPin); +uint8_t GLB_GPIO_Get_Fun(GLB_GPIO_Type gpioPin); +void HBN_Mode_Enter(HBN_APP_CFG_Type *cfg); +void HBN_Power_Down_Flash(SPI_Flash_Cfg_Type *flashCfg); +void HBN_Enable(uint8_t aGPIOIeCfg,HBN_LDO_LEVEL_Type ldoLevel,HBN_LEVEL_Type hbnLevel); +BL_Err_Type HBN_Reset(void); +BL_Err_Type HBN_Set_Ldo11_Aon_Vout(HBN_LDO_LEVEL_Type ldoLevel); +BL_Err_Type HBN_Set_Ldo11_Rt_Vout(HBN_LDO_LEVEL_Type ldoLevel); +BL_Err_Type HBN_Set_Ldo11_Soc_Vout(HBN_LDO_LEVEL_Type ldoLevel); +BL_Err_Type HBN_Hw_Pu_Pd_Cfg(uint8_t enable); +BL_Err_Type HBN_Pin_WakeUp_Mask(uint8_t maskVal); +BL_Err_Type HBN_GPIO7_Dbg_Pull_Cfg(BL_Fun_Type pupdEn,BL_Fun_Type iesmtEn,BL_Fun_Type dlyEn,uint8_t dlySec); +BL_Err_Type HBN_Set_Embedded_Flash_Pullup(uint8_t enable); +BL_Err_Type L1C_Set_Wrap(BL_Fun_Type wrap); +BL_Err_Type L1C_Set_Way_Disable(uint8_t disableVal); +BL_Err_Type L1C_IROM_2T_Access_Set(uint8_t enable); +BL_Err_Type PDS_Reset(void); +BL_Err_Type PDS_Force_Config(PDS_CTL2_Type.conflict4 *cfg2,PDS_CTL3_Type.conflict4 *cfg3); +BL_Err_Type PDS_RAM_Config(PDS_RAM_CFG_Type.conflict1 *ramCfg); +BL_Err_Type PDS_Default_Level_Config(PDS_DEFAULT_LV_CFG_Type.conflict1 *defaultLvCfg,PDS_RAM_CFG_Type.conflict1 *ramCfg,uint32_t pdsSleepCnt); +void SEC_Eng_Turn_On_Sec_Ring(void); +void SEC_Eng_Turn_Off_Sec_Ring(void); +void SFlash_Init(SF_Ctrl_Cfg_Type *pSfCtrlCfg); +BL_Err_Type SFlash_SetSPIMode(SF_Ctrl_Mode_Type mode); +BL_Err_Type SFlash_Read_Reg(SPI_Flash_Cfg_Type *flashCfg,uint8_t regIndex,uint8_t *regValue,uint8_t regLen); +BL_Err_Type SFlash_Write_Reg(SPI_Flash_Cfg_Type *flashCfg,uint8_t regIndex,uint8_t *regValue,uint8_t regLen); +BL_Sts_Type SFlash_Busy(SPI_Flash_Cfg_Type *flashCfg); +BL_Err_Type SFlash_Write_Enable(SPI_Flash_Cfg_Type *flashCfg); +BL_Err_Type SFlash_Qspi_Enable(SPI_Flash_Cfg_Type *flashCfg); +void SFlash_Volatile_Reg_Write_Enable(SPI_Flash_Cfg_Type *flashCfg); +BL_Err_Type SFlash_Chip_Erase(SPI_Flash_Cfg_Type *flashCfg); +BL_Err_Type SFlash_Sector_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t secNum); +BL_Err_Type SFlash_Blk32_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t blkNum); +BL_Err_Type SFlash_Blk64_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t blkNum); +BL_Err_Type SFlash_Erase(SPI_Flash_Cfg_Type *flashCfg,uint32_t startaddr,uint32_t endaddr); +BL_Err_Type SFlash_Program(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint32_t addr,uint8_t *data,uint32_t len); +void SFlash_GetUniqueId(uint8_t *data,uint8_t idLen); +void SFlash_GetJedecId(SPI_Flash_Cfg_Type *flashCfg,uint8_t *data); +void SFlash_GetDeviceId(uint8_t *data); +void SFlash_Powerdown(void); +void SFlash_Releae_Powerdown(SPI_Flash_Cfg_Type *flashCfg); +void SFlash_SetBurstWrap(SPI_Flash_Cfg_Type *flashCfg); +void SFlash_DisableBurstWrap(SPI_Flash_Cfg_Type *flashCfg); +BL_Err_Type SFlash_Software_Reset(SPI_Flash_Cfg_Type *flashCfg); +void SFlash_Reset_Continue_Read(SPI_Flash_Cfg_Type *flashCfg); +BL_Err_Type SFlash_Set_IDbus_Cfg(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead,uint32_t addr,uint32_t len); +BL_Err_Type SFlash_IDbus_Read_Enable(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead); +BL_Err_Type SFlash_Cache_Enable_Set(uint8_t wayDisable); +BL_Err_Type SFlash_Cache_Flush(void); +BL_Err_Type SFlash_Cache_Read_Enable(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead,uint8_t wayDisable); +void SFlash_Cache_Hit_Count_Get(uint32_t *hitCountLow,uint32_t *hitCountHigh); +uint32_t SFlash_Cache_Miss_Count_Get(void); +void SFlash_Cache_Read_Disable(void); +BL_Err_Type SFlash_Read(SPI_Flash_Cfg_Type *flashCfg,SF_Ctrl_IO_Type ioMode,uint8_t contRead,uint32_t addr,uint8_t *data,uint32_t len); +BL_Err_Type SFlash_Read_Reg_With_Cmd(SPI_Flash_Cfg_Type *flashCfg,uint8_t readRegCmd,uint8_t *regValue,uint8_t regLen); +BL_Err_Type SFlash_Write_Reg_With_Cmd(SPI_Flash_Cfg_Type *flashCfg,uint8_t writeRegCmd,uint8_t *regValue,uint8_t regLen); +void SF_Cfg_Init_Ext_Flash_Gpio(uint8_t extFlashPin); +void SF_Cfg_Init_Internal_Flash_Gpio(void); +void SF_Cfg_Deinit_Ext_Flash_Gpio(uint8_t extFlashPin); +void SF_Cfg_Restore_GPIO17_Fun(uint8_t fun); +BL_Err_Type SF_Cfg_Get_Flash_Cfg_Need_Lock(uint32_t flashID,SPI_Flash_Cfg_Type *pFlashCfg); +void SF_Cfg_Init_Flash_Gpio(uint8_t flashPinCfg,uint8_t restoreDefault); +uint32_t SF_Cfg_Flash_Identify(uint8_t callFromFlash,uint32_t autoScan,uint32_t flashPinCfg,uint8_t restoreDefault,SPI_Flash_Cfg_Type *pFlashCfg); +void SF_Ctrl_Enable(SF_Ctrl_Cfg_Type *cfg); +void SF_Ctrl_Select_Pad(SF_Ctrl_Pad_Sel sel); +void SF_Ctrl_Set_Owner(SF_Ctrl_Owner_Type owner); +void SF_Ctrl_Disable(void); +void SF_Ctrl_AES_Enable_BE(void); +void SF_Ctrl_AES_Enable_LE(void); +void SF_Ctrl_AES_Set_Region(uint8_t region,uint8_t enable,uint8_t hwKey,uint32_t startAddr,uint32_t endAddr,uint8_t locked); +void SF_Ctrl_AES_Set_Key(uint8_t region,uint8_t *key,SF_Ctrl_AES_Key_Type keyType); +void SF_Ctrl_AES_Set_Key_BE(uint8_t region,uint8_t *key,SF_Ctrl_AES_Key_Type keyType); +void SF_Ctrl_AES_Set_IV(uint8_t region,uint8_t *iv,uint32_t addrOffset); +void SF_Ctrl_AES_Set_IV_BE(uint8_t region,uint8_t *iv,uint32_t addrOffset); +void SF_Ctrl_AES_Enable(void); +void SF_Ctrl_AES_Disable(void); +void SF_Ctrl_Set_Flash_Image_Offset(uint32_t addrOffset); +uint32_t SF_Ctrl_Get_Flash_Image_Offset(void); +void SF_Ctrl_Select_Clock(SF_Ctrl_Sahb_Type sahbType); +void SF_Ctrl_SendCmd(SF_Ctrl_Cmd_Cfg_Type *cfg); +void SF_Ctrl_Icache_Set(SF_Ctrl_Cmd_Cfg_Type *cfg,uint8_t cmdValid); +void SF_Ctrl_Icache2_Set(SF_Ctrl_Cmd_Cfg_Type *cfg,uint8_t cmdValid); +BL_Sts_Type SF_Ctrl_GetBusyState(void); +uint8_t SF_Ctrl_Is_AES_Enable(void); +uint8_t SF_Ctrl_Get_Clock_Delay(void); +void SF_Ctrl_Set_Clock_Delay(uint8_t delay); +BL_Err_Type XIP_SFlash_State_Save(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t *offset); +BL_Err_Type XIP_SFlash_State_Restore(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t offset); +BL_Err_Type XIP_SFlash_Erase_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t startaddr,uint32_t endaddr); +BL_Err_Type XIP_SFlash_Write_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *data,uint32_t len); +BL_Err_Type XIP_SFlash_Read_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *data,uint32_t len); +BL_Err_Type XIP_SFlash_GetJedecId_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint8_t *data); +BL_Err_Type XIP_SFlash_GetDeviceId_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint8_t *data); +BL_Err_Type XIP_SFlash_GetUniqueId_Need_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint8_t *data,uint8_t idLen); +BL_Err_Type XIP_SFlash_Read_Via_Cache_Need_Lock(uint32_t addr,uint8_t *data,uint32_t len); +int XIP_SFlash_Read_With_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *dst,int len); +int XIP_SFlash_Write_With_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,uint8_t *src,int len); +int XIP_SFlash_Erase_With_Lock(SPI_Flash_Cfg_Type *pFlashCfg,uint32_t addr,int len); +void XIP_SFlash_Opt_Enter(uint8_t *aesEnable); +void XIP_SFlash_Opt_Exit(uint8_t aesEnable); +uint32_t BFLB_Soft_CRC32(void *dataIn,uint32_t len); +BL_Err_Type ADC_Trim_TSEN(uint16_t *tsen_offset); +BL_Err_Type ADC_Gain_Trim(void); +uint8_t EF_Ctrl_Get_Trim_Parity(uint32_t val,uint8_t len); +void EF_Ctrl_Read_RC32M_Trim(Efuse_Ana_RC32M_Trim_Type.conflict1 *trim); +void EF_Ctrl_Read_RC32K_Trim(Efuse_Ana_RC32K_Trim_Type.conflict3 *trim); +void EF_Ctrl_Read_TSEN_Trim(Efuse_TSEN_Refcode_Corner_Type.conflict3 *trim); +void EF_Ctrl_Read_ADC_Gain_Trim(Efuse_ADC_Gain_Coeff_Type.conflict3 *trim); +BL_Err_Type AON_Power_On_MBG(void); +BL_Err_Type AON_Power_Off_MBG(void); +BL_Err_Type AON_Power_On_XTAL(void); +BL_Err_Type AON_Set_Xtal_CapCode(uint8_t capIn,uint8_t capOut); +uint8_t AON_Get_Xtal_CapCode(void); +BL_Err_Type AON_Power_Off_XTAL(void); +uint8_t EF_Ctrl_Get_Trim_Parity(uint32_t val,uint8_t len); +void EF_Ctrl_Read_RC32M_Trim(Efuse_Ana_RC32M_Trim_Type.conflict4 *trim); +void EF_Ctrl_Read_RC32K_Trim(Efuse_Ana_RC32K_Trim_Type.conflict6 *trim); +GLB_ROOT_CLK_Type GLB_Get_Root_CLK_Sel(void); +BL_Err_Type GLB_Set_System_CLK_Div(uint8_t hclkDiv,uint8_t bclkDiv); +uint8_t GLB_Get_BCLK_Div(void); +uint8_t GLB_Get_HCLK_Div(void); +BL_Err_Type Update_SystemCoreClockWith_XTAL(GLB_PLL_XTAL_Type xtalType); +BL_Err_Type GLB_Set_System_CLK(GLB_PLL_XTAL_Type xtalType,GLB_SYS_CLK_Type clkFreq); +BL_Err_Type System_Core_Clock_Update_From_RC32M(void); +BL_Err_Type GLB_Set_SF_CLK(uint8_t enable,GLB_SFLASH_CLK_Type clkSel,uint8_t div); +BL_Err_Type GLB_Set_PKA_CLK_Sel(GLB_PKA_CLK_Type clkSel); +BL_Err_Type HBN_32K_Sel(HBN_32K_CLK_Type clkType); +BL_Err_Type HBN_Set_ROOT_CLK_Sel(HBN_ROOT_CLK_Type rootClk); +BL_Err_Type HBN_Power_On_Xtal_32K(void); +BL_Err_Type HBN_Power_Off_Xtal_32K(void); +BL_Err_Type HBN_Power_On_RC32K(void); +BL_Err_Type HBN_Power_Off_RC32K(void); +BL_Err_Type HBN_Trim_RC32K(void); +BL_Err_Type PDS_Trim_RC32M(void); +BL_Err_Type PDS_Select_RC32M_As_PLL_Ref(void); +BL_Err_Type PDS_Select_XTAL_As_PLL_Ref(void); +BL_Err_Type PDS_Power_On_PLL(PDS_PLL_XTAL_Type xtalType); +BL_Err_Type PDS_Enable_PLL_All_Clks(void); +BL_Err_Type PDS_Disable_PLL_All_Clks(void); +BL_Err_Type PDS_Enable_PLL_Clk(PDS_PLL_CLK_Type pllClk); +BL_Err_Type PDS_Disable_PLL_Clk(PDS_PLL_CLK_Type pllClk); +BL_Err_Type PDS_Power_Off_PLL(void); + From 19afc829ab757c30c3512cbeca5ab9cb6bbd0f1e Mon Sep 17 00:00:00 2001 From: Fangfei Yang Date: Mon, 2 Nov 2020 23:48:58 -0600 Subject: [PATCH 2/2] update work log --- README.adoc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.adoc b/README.adoc index cec03f0..fd5cb02 100644 --- a/README.adoc +++ b/README.adoc @@ -45,3 +45,7 @@ * The three examples are from commit 9a10205e96a6b10e22069c87625550cad666b1b4, bl602_demo_at, bl602_demo_wifi and sdk_app_ble_sync. * They are compiled with the riscv toolchain shipped with the sdk and using `make -j` directly in the folders with `CONFIG_CHIP_NAME=BL602` and `CONFIG_LINK_ROM=1`. The disassembly is generated with `riscv64-unknown-elf-objdump -d ./x.elf > ./x.S` + + +=== Yangff (2 Nov 2020) + * Added Ghidra decompile results, using all default setting on ghidra. \ No newline at end of file